drm/bridge/synopsys: dsi: Don't blindly call post_disable
Subsystems (3)
PATCH 1/1 drm/bridge/synopsys: dsi: Don't blindly call post_disable
The DRM documentation states that post_disable is an optional callback. As such an implementing device may not populate it. To avoid panicing the kernel by calling a NULL function pointer, we should NULL check it before blindy calling it.
---
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +2 -1
@@ -805,7 +805,8 @@ static void dw_mipi_dsi_bridge_post_disable(struct drm_bridge *bridge)* This needs to be fixed in the drm_bridge framework and the API * needs to be updated to manage our own call chains... */ - dsi->panel_bridge->funcs->post_disable (dsi->panel_bridge); +if (dsi->panel_bridge->funcs->post_disable) + dsi->panel_bridge->funcs->post_disable (dsi->panel_bridge);if (dsi->slave) {dw_mipi_dsi_disable (dsi->slave);
Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Hi Matt,
Thank you for the patch.
Quoted 6 lines · Matt Redfearn
The DRM documentation states that
post_disableis an optional callback. As such an implementing device may not populate it. To avoid panicing the kernel by calling a NULL function pointer, we should NULL check it before blindy calling it.Signed-off-by Matt Redfearn <[email protected]>
Quoted 19 lines
---
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +2
-1@@ -805,7 +805,8 @@ static void dw_mipi_dsi_bridge_post_disable(struct drm_bridge *bridge)* This needs to be fixed in the drm_bridge framework and the API * needs to be updated to manage our own call chains... */ - dsi->panel_bridge->funcs->post_disable (dsi->panel_bridge); +if (dsi->panel_bridge->funcs->post_disable) + dsi->panel_bridge->funcs->post_disable (dsi->panel_bridge);if (dsi->slave) {dw_mipi_dsi_disable (dsi->slave);
Signature · 3 lines
Regards, Laurent Pinchart
Quoted 17 lines · Matt Redfearn
The DRM documentation states that
post_disableis an optional callback. As such an implementing device may not populate it. To avoid panicing the kernel by calling a NULL function pointer, we should NULL check it before blindy calling it.Signed-off-by Matt Redfearn <[email protected]>---
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +0
-0
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c static void dw_mipi_dsi_bridge_post_disable(struct drm_bridge *bridge) · line 810
Quoted 7 lines
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +2
-1@@ -805,7 +805,8 @@ static void dw_mipi_dsi_bridge_post_disable(struct drm_bridge *bridge)* This needs to be fixed in the drm_bridge framework and the API * needs to be updated to manage our own call chains... */ - dsi->panel_bridge->funcs->post_disable (dsi->panel_bridge); +if (dsi->panel_bridge->funcs->post_disable) + dsi->panel_bridge->funcs->post_disable (dsi->panel_bridge);
Why not drm_bridge_post_disable ?
Regards
Andrzej
Quoted 2 lines
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +0
-0if (dsi->slave) {dw_mipi_dsi_disable (dsi->slave);
Hi Andrzej,
Quoted 13 lines · Andrzej Hajda
Quoted 12 lines · Matt Redfearn
The DRM documentation states that
post_disableis an optional callback. As such an implementing device may not populate it. To avoid panicing the kernel by calling a NULL function pointer, we should NULL check it before blindy calling it.Signed-off-by Matt Redfearn <[email protected]>---
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 14 lines
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c static void dw_mipi_dsi_bridge_post_disable(struct drm_bridge *bridge) · line 810
Quoted 12 lines
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +2
-1@@ -805,7 +805,8 @@ static void dw_mipi_dsi_bridge_post_disable(struct drm_bridge *bridge)* This needs to be fixed in the drm_bridge framework and the API * needs to be updated to manage our own call chains... */ - dsi->panel_bridge->funcs->post_disable (dsi->panel_bridge); +if (dsi->panel_bridge->funcs->post_disable) + dsi->panel_bridge->funcs->post_disable (dsi->panel_bridge);Why not
drm_bridge_post_disable?
Ah - that seems like a nicer fix! Do you think the comment above describing why this function pointer is called directly can be removed as well if we go this route?
If someone calls drm_bridge_post_disable() on the Synposys DSI drm_bridge it will go on to call post_disable on all other bridges in the chain, in addition to us calling them here. Is it an issue to call it multiple times?
Thanks,
Matt
Quoted 11 lines
Regards
Andrzej
Quoted 2 lines
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +0
-0if (dsi->slave) {dw_mipi_dsi_disable (dsi->slave);
Laurent Pinchart
reviewerHi Matt,
Quoted 29 lines · Matt Redfearn
Quoted 13 lines · Andrzej Hajda
Quoted 12 lines · Matt Redfearn
The DRM documentation states that
post_disableis an optional callback. As such an implementing device may not populate it. To avoid panicing the kernel by calling a NULL function pointer, we should NULL check it before blindy calling it.Signed-off-by Matt Redfearn <[email protected]>---
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)Quoted 14 lines
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c static void dw_mipi_dsi_bridge_post_disable(struct drm_bridge *bridge) · line 810
Quoted 12 lines
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +2
-1@@ -805,7 +805,8 @@ static void dw_mipi_dsi_bridge_post_disable(struct drm_bridge *bridge)* This needs to be fixed in the drm_bridge framework and the API * needs to be updated to manage our own call chains... */ - dsi->panel_bridge->funcs->post_disable (dsi->panel_bridge); +if (dsi->panel_bridge->funcs->post_disable) + dsi->panel_bridge->funcs->post_disable (dsi->panel_bridge);Why not
drm_bridge_post_disable?
Quoted 3 lines
Ah - that seems like a nicer fix! Do you think the comment above describing why this function pointer is called directly can be removed as well if we go this route?
It shouldn't be necessary to call ->post_disable manually here as the bridge core handles it internally. This is a hack to work around a problem, and should be fixed properly.
Quoted 4 lines
If someone calls
drm_bridge_post_disable()on the Synposys DSIdrm_bridgeit will go on to callpost_disableon all other bridges in the chain, in addition to us calling them here. Is it an issue to call it multiple times?
It depends on the panel implementation, but in general it's not a good idea. It may happen to work, but could break at any time in the future.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +0
-0if (dsi->slave) {dw_mipi_dsi_disable (dsi->slave);
Signature · 3 lines
Regards, Laurent Pinchart
Laurent Pinchart
reviewerQuoted 38 lines · Laurent Pinchart
Quoted 29 lines · Matt Redfearn
Quoted 13 lines · Andrzej Hajda
Quoted 12 lines · Matt Redfearn
The DRM documentation states that
post_disableis an optional callback. As such an implementing device may not populate it. To avoid panicing the kernel by calling a NULL function pointer, we should NULL check it before blindy calling it.Signed-off-by Matt Redfearn <[email protected]>---
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)Quoted 14 lines
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c static void dw_mipi_dsi_bridge_post_disable(struct drm_bridge *bridge) · line 810
Quoted 12 lines
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +2
-1@@ -805,7 +805,8 @@ static void dw_mipi_dsi_bridge_post_disable(struct drm_bridge *bridge)* This needs to be fixed in the drm_bridge framework and the API * needs to be updated to manage our own call chains... */ - dsi->panel_bridge->funcs->post_disable (dsi->panel_bridge); +if (dsi->panel_bridge->funcs->post_disable) + dsi->panel_bridge->funcs->post_disable (dsi->panel_bridge);Why not
drm_bridge_post_disable?Quoted 3 lines
Ah - that seems like a nicer fix! Do you think the comment above describing why this function pointer is called directly can be removed as well if we go this route?
It shouldn't be necessary to call ->post_disable manually here as the bridge core handles it internally. This is a hack to work around a problem, and should be fixed properly.
Quoted 7 lines
Quoted 4 lines
If someone calls
drm_bridge_post_disable()on the Synposys DSIdrm_bridgeit will go on to callpost_disableon all other bridges in the chain, in addition to us calling them here. Is it an issue to call it multiple times?It depends on the panel implementation, but in general it's not a good idea. It may happen to work, but could break at any time in the future.
Double-checking the driver, the .attach() operation doesn't propagate to the next bridge, so the bridge core will not know about it, and will not propagate .post_disable() either. I think this should be fixed in a way that uses the drm bridge core infrastructure.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +0
-0if (dsi->slave) {dw_mipi_dsi_disable (dsi->slave);
Signature · 3 lines
Regards, Laurent Pinchart