Skip to content

Commit 199cf07

Browse files
Liu Yingsuperna9999
authored andcommitted
drm/bridge: panel: Add a device link between drm device and panel device
Add the device link when panel bridge is attached and delete the link when panel bridge is detached. The drm device is the consumer while the panel device is the supplier. This makes sure that the drm device suspends eariler and resumes later than the panel device, hence resolves problems where the order is reversed, like the problematic case mentioned in the below link. Link: https://lore.kernel.org/lkml/CAPDyKFr0XjrU_udKoUKQ_q8RWaUkyqL+8fV-7s1CTMqi7u3-Rg@mail.gmail.com/T/ Suggested-by: Ulf Hansson <ulf.hansson@linaro.org> Signed-off-by: Liu Ying <victor.liu@nxp.com> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org> Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org> Link: https://patchwork.freedesktop.org/patch/msgid/20230807061115.3244501-1-victor.liu@nxp.com
1 parent 4d49d87 commit 199cf07

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

drivers/gpu/drm/bridge/panel.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* Copyright (C) 2017 Broadcom
55
*/
66

7+
#include <linux/device.h>
8+
79
#include <drm/drm_atomic_helper.h>
810
#include <drm/drm_bridge.h>
911
#include <drm/drm_connector.h>
@@ -19,6 +21,7 @@ struct panel_bridge {
1921
struct drm_bridge bridge;
2022
struct drm_connector connector;
2123
struct drm_panel *panel;
24+
struct device_link *link;
2225
u32 connector_type;
2326
};
2427

@@ -60,6 +63,8 @@ static int panel_bridge_attach(struct drm_bridge *bridge,
6063
{
6164
struct panel_bridge *panel_bridge = drm_bridge_to_panel_bridge(bridge);
6265
struct drm_connector *connector = &panel_bridge->connector;
66+
struct drm_panel *panel = panel_bridge->panel;
67+
struct drm_device *drm_dev = bridge->dev;
6368
int ret;
6469

6570
if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR)
@@ -70,6 +75,14 @@ static int panel_bridge_attach(struct drm_bridge *bridge,
7075
return -ENODEV;
7176
}
7277

78+
panel_bridge->link = device_link_add(drm_dev->dev, panel->dev,
79+
DL_FLAG_STATELESS);
80+
if (!panel_bridge->link) {
81+
DRM_ERROR("Failed to add device link between %s and %s\n",
82+
dev_name(drm_dev->dev), dev_name(panel->dev));
83+
return -EINVAL;
84+
}
85+
7386
drm_connector_helper_add(connector,
7487
&panel_bridge_connector_helper_funcs);
7588

@@ -78,6 +91,7 @@ static int panel_bridge_attach(struct drm_bridge *bridge,
7891
panel_bridge->connector_type);
7992
if (ret) {
8093
DRM_ERROR("Failed to initialize connector\n");
94+
device_link_del(panel_bridge->link);
8195
return ret;
8296
}
8397

@@ -100,6 +114,8 @@ static void panel_bridge_detach(struct drm_bridge *bridge)
100114
struct panel_bridge *panel_bridge = drm_bridge_to_panel_bridge(bridge);
101115
struct drm_connector *connector = &panel_bridge->connector;
102116

117+
device_link_del(panel_bridge->link);
118+
103119
/*
104120
* Cleanup the connector if we know it was initialized.
105121
*

0 commit comments

Comments
 (0)