Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/vc4: dsi: Only register our component once a DSI device is attached

If the DSI driver is the last to probe, component_add will try to run all
the bind callbacks straight away and return the error code.

However, since we depend on a power domain, we're pretty much guaranteed to
be in that case on the BCM2711, and are just lucky on the previous SoCs
since the v3d also depends on that power domain and is further in the probe
order.

In that case, the DSI host will not stick around in the system: the DSI
bind callback will be executed, will not find any DSI device attached and
will return EPROBE_DEFER, and we will then remove the DSI host and ask to
be probed later on.

But since that host doesn't stick around, DSI devices like the RaspberryPi
touchscreen whose probe is not linked to the DSI host (unlike the usual DSI
devices that will be probed through the call to mipi_dsi_host_register)
cannot attach to the DSI host, and we thus end up in a situation where the
DSI host cannot probe because the panel hasn't probed yet, and the panel
cannot probe because the DSI host hasn't yet.

In order to break this cycle, let's wait until there's a DSI device that
attaches to the DSI host to register the component and allow to progress
further.

Acked-by: Eric Anholt <eric@anholt.net>
Suggested-by: Andrzej Hajda <a.hajda@samsung.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Link: https://patchwork.freedesktop.org/patch/msgid/20200707101912.571531-1-maxime@cerno.tech

+8 -17
+8 -17
drivers/gpu/drm/vc4/vc4_dsi.c
··· 1246 1246 return ret; 1247 1247 } 1248 1248 1249 + static const struct component_ops vc4_dsi_ops; 1249 1250 static int vc4_dsi_host_attach(struct mipi_dsi_host *host, 1250 1251 struct mipi_dsi_device *device) 1251 1252 { 1252 1253 struct vc4_dsi *dsi = host_to_dsi(host); 1254 + int ret; 1253 1255 1254 1256 dsi->lanes = device->lanes; 1255 1257 dsi->channel = device->channel; ··· 1284 1282 dev_err(&dsi->pdev->dev, 1285 1283 "Only VIDEO mode panels supported currently.\n"); 1286 1284 return 0; 1285 + } 1286 + 1287 + ret = component_add(&dsi->pdev->dev, &vc4_dsi_ops); 1288 + if (ret) { 1289 + mipi_dsi_host_unregister(&dsi->dsi_host); 1290 + return ret; 1287 1291 } 1288 1292 1289 1293 return 0; ··· 1670 1662 { 1671 1663 struct device *dev = &pdev->dev; 1672 1664 struct vc4_dsi *dsi; 1673 - int ret; 1674 1665 1675 1666 dsi = devm_kzalloc(dev, sizeof(*dsi), GFP_KERNEL); 1676 1667 if (!dsi) ··· 1677 1670 dev_set_drvdata(dev, dsi); 1678 1671 1679 1672 dsi->pdev = pdev; 1680 - 1681 - /* Note, the initialization sequence for DSI and panels is 1682 - * tricky. The component bind above won't get past its 1683 - * -EPROBE_DEFER until the panel/bridge probes. The 1684 - * panel/bridge will return -EPROBE_DEFER until it has a 1685 - * mipi_dsi_host to register its device to. So, we register 1686 - * the host during pdev probe time, so vc4 as a whole can then 1687 - * -EPROBE_DEFER its component bind process until the panel 1688 - * successfully attaches. 1689 - */ 1690 1673 dsi->dsi_host.ops = &vc4_dsi_host_ops; 1691 1674 dsi->dsi_host.dev = dev; 1692 1675 mipi_dsi_host_register(&dsi->dsi_host); 1693 - 1694 - ret = component_add(&pdev->dev, &vc4_dsi_ops); 1695 - if (ret) { 1696 - mipi_dsi_host_unregister(&dsi->dsi_host); 1697 - return ret; 1698 - } 1699 1676 1700 1677 return 0; 1701 1678 }