Skip to content

Commit 39d5b6a

Browse files
Liu Yinglinusw
authored andcommitted
drm/bridge: panel: Check device dependency before managing device link
Some panel devices already depend on DRM device, like the panel in arch/arm/boot/dts/st/ste-ux500-samsung-skomer.dts, because DRM device is the ancestor of those panel devices. device_link_add() would fail by returning a NULL pointer for those panel devices because of the existing dependency. So, check the dependency by calling device_is_dependent() before adding or deleting device link between panel device and DRM device so that the link is managed only for independent panel devices. Fixes: 8878780 ("drm/bridge: panel: Fix device link for DRM_BRIDGE_ATTACH_NO_CONNECTOR") Fixes: 199cf07 ("drm/bridge: panel: Add a device link between drm device and panel device") Reported-by: Linus Walleij <[email protected]> Closes: https://lore.kernel.org/lkml/CACRpkdaGzXD6HbiX7mVUNJAJtMEPG00Pp6+nJ1P0JrfJ-ArMvQ@mail.gmail.com/T/ Tested-by: Linus Walleij <[email protected]> Signed-off-by: Liu Ying <[email protected]> Signed-off-by: Linus Walleij <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent ab93edb commit 39d5b6a

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

drivers/gpu/drm/bridge/panel.c

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ struct panel_bridge {
2323
struct drm_panel *panel;
2424
struct device_link *link;
2525
u32 connector_type;
26+
bool is_independent;
2627
};
2728

2829
static inline struct panel_bridge *
@@ -67,20 +68,26 @@ static int panel_bridge_attach(struct drm_bridge *bridge,
6768
struct drm_device *drm_dev = bridge->dev;
6869
int ret;
6970

70-
panel_bridge->link = device_link_add(drm_dev->dev, panel->dev,
71-
DL_FLAG_STATELESS);
72-
if (!panel_bridge->link) {
73-
DRM_ERROR("Failed to add device link between %s and %s\n",
74-
dev_name(drm_dev->dev), dev_name(panel->dev));
75-
return -EINVAL;
71+
panel_bridge->is_independent = !device_is_dependent(drm_dev->dev,
72+
panel->dev);
73+
74+
if (panel_bridge->is_independent) {
75+
panel_bridge->link = device_link_add(drm_dev->dev, panel->dev,
76+
DL_FLAG_STATELESS);
77+
if (!panel_bridge->link) {
78+
DRM_ERROR("Failed to add device link between %s and %s\n",
79+
dev_name(drm_dev->dev), dev_name(panel->dev));
80+
return -EINVAL;
81+
}
7682
}
7783

7884
if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR)
7985
return 0;
8086

8187
if (!bridge->encoder) {
8288
DRM_ERROR("Missing encoder\n");
83-
device_link_del(panel_bridge->link);
89+
if (panel_bridge->is_independent)
90+
device_link_del(panel_bridge->link);
8491
return -ENODEV;
8592
}
8693

@@ -92,7 +99,8 @@ static int panel_bridge_attach(struct drm_bridge *bridge,
9299
panel_bridge->connector_type);
93100
if (ret) {
94101
DRM_ERROR("Failed to initialize connector\n");
95-
device_link_del(panel_bridge->link);
102+
if (panel_bridge->is_independent)
103+
device_link_del(panel_bridge->link);
96104
return ret;
97105
}
98106

@@ -115,7 +123,8 @@ static void panel_bridge_detach(struct drm_bridge *bridge)
115123
struct panel_bridge *panel_bridge = drm_bridge_to_panel_bridge(bridge);
116124
struct drm_connector *connector = &panel_bridge->connector;
117125

118-
device_link_del(panel_bridge->link);
126+
if (panel_bridge->is_independent)
127+
device_link_del(panel_bridge->link);
119128

120129
/*
121130
* Cleanup the connector if we know it was initialized.

0 commit comments

Comments
 (0)