Commit 39d5b6a6 authored by Liu Ying's avatar Liu Ying Committed by Linus Walleij

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: 88787801 ("drm/bridge: panel: Fix device link for DRM_BRIDGE_ATTACH_NO_CONNECTOR")
Fixes: 199cf07e ("drm/bridge: panel: Add a device link between drm device and panel device")
Reported-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Closes: https://lore.kernel.org/lkml/CACRpkdaGzXD6HbiX7mVUNJAJtMEPG00Pp6+nJ1P0JrfJ-ArMvQ@mail.gmail.com/T/Tested-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarLiu Ying <victor.liu@nxp.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20231123032615.3760488-1-victor.liu@nxp.com
parent ab93edb2
...@@ -23,6 +23,7 @@ struct panel_bridge { ...@@ -23,6 +23,7 @@ struct panel_bridge {
struct drm_panel *panel; struct drm_panel *panel;
struct device_link *link; struct device_link *link;
u32 connector_type; u32 connector_type;
bool is_independent;
}; };
static inline struct panel_bridge * static inline struct panel_bridge *
...@@ -67,6 +68,10 @@ static int panel_bridge_attach(struct drm_bridge *bridge, ...@@ -67,6 +68,10 @@ static int panel_bridge_attach(struct drm_bridge *bridge,
struct drm_device *drm_dev = bridge->dev; struct drm_device *drm_dev = bridge->dev;
int ret; int ret;
panel_bridge->is_independent = !device_is_dependent(drm_dev->dev,
panel->dev);
if (panel_bridge->is_independent) {
panel_bridge->link = device_link_add(drm_dev->dev, panel->dev, panel_bridge->link = device_link_add(drm_dev->dev, panel->dev,
DL_FLAG_STATELESS); DL_FLAG_STATELESS);
if (!panel_bridge->link) { if (!panel_bridge->link) {
...@@ -74,12 +79,14 @@ static int panel_bridge_attach(struct drm_bridge *bridge, ...@@ -74,12 +79,14 @@ static int panel_bridge_attach(struct drm_bridge *bridge,
dev_name(drm_dev->dev), dev_name(panel->dev)); dev_name(drm_dev->dev), dev_name(panel->dev));
return -EINVAL; return -EINVAL;
} }
}
if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR) if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR)
return 0; return 0;
if (!bridge->encoder) { if (!bridge->encoder) {
DRM_ERROR("Missing encoder\n"); DRM_ERROR("Missing encoder\n");
if (panel_bridge->is_independent)
device_link_del(panel_bridge->link); device_link_del(panel_bridge->link);
return -ENODEV; return -ENODEV;
} }
...@@ -92,6 +99,7 @@ static int panel_bridge_attach(struct drm_bridge *bridge, ...@@ -92,6 +99,7 @@ static int panel_bridge_attach(struct drm_bridge *bridge,
panel_bridge->connector_type); panel_bridge->connector_type);
if (ret) { if (ret) {
DRM_ERROR("Failed to initialize connector\n"); DRM_ERROR("Failed to initialize connector\n");
if (panel_bridge->is_independent)
device_link_del(panel_bridge->link); device_link_del(panel_bridge->link);
return ret; return ret;
} }
...@@ -115,6 +123,7 @@ static void panel_bridge_detach(struct drm_bridge *bridge) ...@@ -115,6 +123,7 @@ static void panel_bridge_detach(struct drm_bridge *bridge)
struct panel_bridge *panel_bridge = drm_bridge_to_panel_bridge(bridge); struct panel_bridge *panel_bridge = drm_bridge_to_panel_bridge(bridge);
struct drm_connector *connector = &panel_bridge->connector; struct drm_connector *connector = &panel_bridge->connector;
if (panel_bridge->is_independent)
device_link_del(panel_bridge->link); device_link_del(panel_bridge->link);
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment