Skip to content

Commit 0c08754

Browse files
Jyri Sarhathierryreding
authored andcommitted
drm/panel: Add device_link from panel device to DRM device
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
1 parent 38992c5 commit 0c08754

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

drivers/gpu/drm/drm_panel.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <linux/err.h>
2525
#include <linux/module.h>
2626

27+
#include <drm/drm_device.h>
2728
#include <drm/drm_crtc.h>
2829
#include <drm/drm_panel.h>
2930

@@ -104,6 +105,13 @@ int drm_panel_attach(struct drm_panel *panel, struct drm_connector *connector)
104105
if (panel->connector)
105106
return -EBUSY;
106107

108+
panel->link = device_link_add(connector->dev->dev, panel->dev, 0);
109+
if (!panel->link) {
110+
dev_err(panel->dev, "failed to link panel to %s\n",
111+
dev_name(connector->dev->dev));
112+
return -EINVAL;
113+
}
114+
107115
panel->connector = connector;
108116
panel->drm = connector->dev;
109117

@@ -125,6 +133,8 @@ EXPORT_SYMBOL(drm_panel_attach);
125133
*/
126134
int drm_panel_detach(struct drm_panel *panel)
127135
{
136+
device_link_del(panel->link);
137+
128138
panel->connector = NULL;
129139
panel->drm = NULL;
130140

include/drm/drm_panel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ struct drm_panel {
8989
struct drm_device *drm;
9090
struct drm_connector *connector;
9191
struct device *dev;
92+
struct device_link *link;
9293

9394
const struct drm_panel_funcs *funcs;
9495

0 commit comments

Comments
 (0)