On 28.12.2012 23:21, Thierry Reding wrote:
Instead of going over this back and forth, I've decided to rewrite this patch from scratch the way I think it should be done. Maybe that'll make things clearer. I haven't tested it on real hardware yet because I don't have access over the holidays, but I'll post the patch once I've verified that it actually works. The code is based on patches 1-4 of this series and is meant to replace patch 5.
I'm still not happy that host1x needs to know about drm. That's just a wrong dependency, and wrong dependencies always end up biting back. We need to figure out solution that satisfies both mine and your requirements and reduce complexity.
DC/HDMI/GR2D probes are using the global data only for managing the lists "drm_clients" and "clients". "clients" list is only required after tegra_drm_load(). "drm_clients" is required to establish driver load order.
With dummy device, we can determine the registration (and probe) order. tegra-drm can register the drivers for DC/HDMI/GR2D devices first, and as last the device and driver for tegra-drm.
tegra-drm probe will allocate the global data, enumerate all drivers and add them to the clients list. If one driver is not initialized, it'll return with -EPROBE_DEFER and will be called again later. When all this is successful, it'll call drm_platform_init().
The advantages: * No management of drm_clients list * No mucking with drvdata * host1x doesn't need to know about drm * The global data is allocated and deallocated by tegra-drm probe and remove, and accessed only via drm_device->dev_private * Much less code
Something like the attached patch - not tested, as I don't have access to hw now, but it shows the idea. It's based on patches 1-5 in the series, and could replace patch 5.
Terje