]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
drm/panel: Add device_link from panel device to DRM device
authorJyri Sarha <jsarha@ti.com>
Thu, 26 Apr 2018 08:07:00 +0000 (11:07 +0300)
committerThierry Reding <treding@nvidia.com>
Fri, 18 May 2018 09:22:06 +0000 (11:22 +0200)
Add device_link from panel device (supplier) to DRM device (consumer)
when drm_panel_attach() is called. This patch should protect the master
DRM driver if an attached panel driver unbinds while it is in use. The
device_link 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 consumer DRM driver, not the
panel driver, otherwise both drivers are racing to delete the same link.

Signed-off-by: Jyri Sarha <jsarha@ti.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Thierry Reding <treding@nvidia.com>
Link: https://patchwork.freedesktop.org/patch/msgid/b53584fd988d045c13de22d81825395b0ae0aad7.1524727888.git.jsarha@ti.com
drivers/gpu/drm/drm_panel.c
include/drm/drm_panel.h

index 71e407574276be7b4af4945082a516394c117013..965530a6f4cd355cc82386a258b46f2363b63430 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/err.h>
 #include <linux/module.h>
 
+#include <drm/drm_device.h>
 #include <drm/drm_crtc.h>
 #include <drm/drm_panel.h>
 
@@ -104,6 +105,13 @@ int drm_panel_attach(struct drm_panel *panel, struct drm_connector *connector)
        if (panel->connector)
                return -EBUSY;
 
+       panel->link = device_link_add(connector->dev->dev, panel->dev, 0);
+       if (!panel->link) {
+               dev_err(panel->dev, "failed to link panel to %s\n",
+                       dev_name(connector->dev->dev));
+               return -EINVAL;
+       }
+
        panel->connector = connector;
        panel->drm = connector->dev;
 
@@ -125,6 +133,8 @@ EXPORT_SYMBOL(drm_panel_attach);
  */
 int drm_panel_detach(struct drm_panel *panel)
 {
+       device_link_del(panel->link);
+
        panel->connector = NULL;
        panel->drm = NULL;
 
index 14ac240a1f646d6253c0a076ecaaa9b8a1a567c3..26a1b5fd8796cb7b4e495ca09b60e49bc06733bc 100644 (file)
@@ -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;