drm/amd/display: Fix null pointer on analog detection
Subsystems (3)
Harry Wentland
maintainerPATCH 1/1 drm/amd/display: Fix null pointer on analog detection
Check if we have an amdgpu_dm_connector->dc_sink first before adding common modes for analog outputs. If we don't have a sink yet we can safely skip this.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -1
@@ -8669,7 +8669,7 @@ static int amdgpu_dm_connector_get_modes(struct drm_connector *connector) amdgpu_dm_connector->num_modes +=drm_add_modes_noedid (connector,1920 ,1080 ); -if (amdgpu_dm_connector->dc_sink->edid_caps.analog) { +if (amdgpu_dm_connector->dc_sink && amdgpu_dm_connector->dc_sink->edid_caps.analog) {/* Analog monitor connected by DAC load detection. * Add common modes. It will be up to the user to select one that works. */
Signature · 1 line
2.51.2
Quoted 3 lines · Harry Wentland
Check if we have an
amdgpu_dm_connector->dc_sinkfirst before adding common modes for analog outputs. If we don't have a sink yet we can safely skip this.
Hi Harry, nice catch!
Out of curiosity, how is it possible to reach this code when the dc_sink is NULL?
The patch is:
Quoted 29 lines
Fixes 0c9f9ca99238 ("drm/amd/display: Add common modes to analogdisplays without EDID")
Cc Timur Kristóf <[email protected]>Signed-off-by Harry Wentland <[email protected]>---
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 +-1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0
-0@@ -8669,7 +8669,7 @@ static int amdgpu_dm_connector_get_modes(struct drm_connector *connector)
amdgpu_dm_connector->num_modes+=drm_add_modes_noedid(connector, 1920, 1080);drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0
-1-if (amdgpu_dm_connector->dc_sink->edid_caps.analog){
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1
-0+ if (amdgpu_dm_connector->dc_sink &&
amdgpu_dm_connector->dc_sink->edid_caps.analog) {
/* Analog monitor connected by DAC load detection.
* Add common modes. It will be up to the user to select one that works.
*/
Harry Wentland
maintainerQuoted 10 lines · Timur Kristóf
Quoted 3 lines · Harry Wentland
Check if we have an
amdgpu_dm_connector->dc_sinkfirst before adding common modes for analog outputs. If we don't have a sink yet we can safely skip this.Hi Harry, nice catch!
Out of curiosity, how is it possible to reach this code when the
dc_sinkis NULL?
Huh, that was a bit of a goose chase.
amdgpu_dm_init
Quoted 3 lines
amdgpu_dm_initialize_drm_deviceamdgpu_set_panel_orientationamdgpu_dm_connector_get_modes
This will run even on disconnected (i.e., without dc_sink) connectors.
Maybe amdgpu_set_panel_orientation had better move into this hunk after the amdgpu_dm_update_connector_after_detect:
ret = dc_link_detect(link, DETECT_REASON_BOOT);
mutex_unlock(&dm->dc_lock);
printk("hwhw: %s %d\n", __func__, __LINE__);
if (ret) {
amdgpu_dm_update_connector_after_detect(aconnector);
printk("hwhw: %s %d\n", __func__, __LINE__);Either way, the NULL check is still prudent.
Harry
Quoted 32 lines
The patch is:
Reviewed-by Timur Kristóf <[email protected]>Quoted 29 lines
Fixes 0c9f9ca99238 ("drm/amd/display: Add common modes to analogdisplays without EDID")
Cc Timur Kristóf <[email protected]>Signed-off-by Harry Wentland <[email protected]>---
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 +-1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0
-0@@ -8669,7 +8669,7 @@ static int amdgpu_dm_connector_get_modes(struct drm_connector *connector)
amdgpu_dm_connector->num_modes+=drm_add_modes_noedid(connector, 1920, 1080);drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0
-1-if (amdgpu_dm_connector->dc_sink->edid_caps.analog){
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1
-0+ if (amdgpu_dm_connector->dc_sink &&
amdgpu_dm_connector->dc_sink->edid_caps.analog) {
/* Analog monitor connected by DAC load detection.
* Add common modes. It will be up to the user to select one that works.
*/
Quoted 16 lines · Harry Wentland
Quoted 10 lines · Timur Kristóf
Quoted 3 lines · Harry Wentland
Check if we have an
amdgpu_dm_connector->dc_sinkfirst before adding common modes for analog outputs. If we don't have a sink yet we can safely skip this.Hi Harry, nice catch!
Out of curiosity, how is it possible to reach this code when the
dc_sinkis NULL?Huh, that was a bit of a goose chase.
Quoted 7 lines
amdgpu_dm_initQuoted 3 lines
amdgpu_dm_initialize_drm_deviceamdgpu_set_panel_orientationamdgpu_dm_connector_get_modesThis will run even on disconnected (i.e., without
dc_sink) connectors.
Interesting. I hadn't encountered this code path during my testing, so I'm a bit baffled how you could trigger that.
I'm sorry for the goose chase, but glad you found a solution.
Quoted 12 lines
Maybe
amdgpu_set_panel_orientationhad better move into this hunk after theamdgpu_dm_update_connector_after_detect:ret = dc_link_detect(link, DETECT_REASON_BOOT); mutex_unlock(&dm->dc_lock); printk("hwhw: %s %d\n", __func__, __LINE__); if (ret) { amdgpu_dm_update_connector_after_detect(aconnector); printk("hwhw: %s %d\n", __func__, __LINE__);
Quoted 1 line
Either way, the NULL check is still prudent.
Yes, I agree with the NULL check. No argument there. Also agree with the suggestion above.
Thanks & best regards,
Timur
Quoted 35 lines
Quoted 35 lines
The patch is:
Reviewed-by Timur Kristóf <[email protected]>Quoted 32 lines
Fixes 0c9f9ca99238 ("drm/amd/display: Add common modes to analogdisplays without EDID")
Cc Timur Kristóf <[email protected]>Signed-off-by Harry Wentland <[email protected]>---
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 +-1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0
-0@@ -8669,7 +8669,7 @@ static intamdgpu_dm_connector_get_modes(struct
drm_connector*connector)amdgpu_dm_connector->num_modes+=drm_add_modes_noedid(connector, 1920, 1080);drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0
-1- if (amdgpu_dm_connector->dc_sink-Quoted 1 line
edid_caps.analog)
{
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1
-0+ if (amdgpu_dm_connector->dc_sink &&
amdgpu_dm_connector->dc_sink->edid_caps.analog) {
/* Analog monitor connected by DAC load detection.
* Add common modes. It will be up to the
user to select one that works.
*/