On Wed, Feb 28, 2018 at 01:09:30PM +0200, Jyri Sarha wrote:
Add device_link from panel device (supplier) to drm device (consumer) with DL_FLAG_AUTOREMOVE when drm_panel_attach() is called. Currently the master drm driver is not protected against the attached. The device_link with DL_FLAG_AUTOREMOVE should make sure the drm device is unbound before the panel driver becomes unavailable.
The device_link is removed when drm_panel_detach() is called. The drm_panel_detach() should be called by the panel driver it self when it is removed. Otherwise the both driver are racing to delete the same link.
AFAICS drm_panel_detach() is always called by the DRM drivers, so it's confusing that you're saying here it should be called by the panel drivers. That would also seem to be asymmetric since drm_panel_attach() is called by the DRM drivers.
--- a/include/drm/drm_panel.h +++ b/include/drm/drm_panel.h @@ -89,6 +89,7 @@ struct drm_panel { struct drm_device *drm; struct drm_connector *connector; struct device *dev;
struct device_link *link;
const struct drm_panel_funcs *funcs;
If you ditch the device_link_del() and use DL_FLAG_AUTOREMOVE only, you don't need to save the pointer to struct device_link.
Thanks,
Lukas