drm/amd/display: fix the ability to use lower resolution modes on eDP
PATCH 1/1 drm/amd/display: fix the ability to use lower resolution modes on eDP
On eDP we can receive invalid modes from dm_update_crtc_state() for entirely new streams for which drm_mode_set_crtcinfo() shouldn't be called on. So, instead of calling drm_mode_set_crtcinfo() from within create_stream_for_sink() we can instead call it from amdgpu_dm_connector_mode_valid(). Since, we are guaranteed to only call drm_mode_set_crtcinfo() for valid modes from that function (invalid modes are rejected by that callback) and that is the only user of create_validate_stream_for_sink() that we need to call drm_mode_set_crtcinfo() for (as before commit cb841d27b876 ("drm/amd/display: Always pass connector_state to stream validation"), that is the only place where create_validate_stream_for_sink()'s dm_state was NULL).
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2 -2
@@ -6128,8 +6128,6 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector,if (recalculate_timing)drm_mode_set_crtcinfo (&saved_mode,0 ); -else if (!old_stream) -drm_mode_set_crtcinfo (&mode,0 );/* * If scaling is enabled and refresh rate didn't change
@@ -6691,6 +6689,8 @@ enum drm_mode_status amdgpu_dm_connector_mode_valid(struct drm_connector *connec goto fail; } +drm_mode_set_crtcinfo (mode,0 ); + stream =create_validate_stream_for_sink (aconnector, mode,to_dm_connector_state (connector->state),NULL );
Signature · 1 line
2.42.0
Harry Wentland
maintainerQuoted 4 lines · Hamza Mahfooz
On eDP we can receive invalid modes from
dm_update_crtc_state()for entirely new streams for whichdrm_mode_set_crtcinfo()shouldn't be called on. So, instead of callingdrm_mode_set_crtcinfo()from withincreate_stream_for_sink()we can instead call it from
Quoted 9 lines
amdgpu_dm_connector_mode_valid(). Since, we are guaranteed to only calldrm_mode_set_crtcinfo()for valid modes from that function (invalid modes are rejected by that callback) and that is the only user ofcreate_validate_stream_for_sink()that we need to calldrm_mode_set_crtcinfo()for (as before commitcb841d27b876("drm/amd/display: Always passconnector_stateto stream validation"), that is the only place where create_validate_stream_for_sink()'sdm_statewas NULL).
I don't seem to see how a NULL dm_state in create_validate_stream_for_sink() (or create_stream_for_sink() for that matter) has an impact on the drm_mode_set_crtcinfo() call. That one depends on !old_stream and &mode.
It does look like &mode is an empty mode if we can't find a preferred_mode, though. Not sure if that can cause an issue.
Harry
Quoted 30 lines
Fixes cb841d27b876 ("drm/amd/display: Always pass connector_state to stream validation")Signed-off-by Hamza Mahfooz <[email protected]>--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2
-2@@ -6128,8 +6128,6 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector,if (recalculate_timing)drm_mode_set_crtcinfo (&saved_mode,0 ); -else if (!old_stream) -drm_mode_set_crtcinfo (&mode,0 );/* * If scaling is enabled and refresh rate didn't change @@ -6691,6 +6689,8 @@ enum drm_mode_status amdgpu_dm_connector_mode_valid(struct drm_connector *connec goto fail; } +drm_mode_set_crtcinfo (mode,0 ); + stream =create_validate_stream_for_sink (aconnector, mode,to_dm_connector_state (connector->state),NULL );
Quoted 15 lines · Harry Wentland
Quoted 4 lines · Hamza Mahfooz
On eDP we can receive invalid modes from
dm_update_crtc_state()for entirely new streams for whichdrm_mode_set_crtcinfo()shouldn't be called on. So, instead of callingdrm_mode_set_crtcinfo()from withincreate_stream_for_sink()we can instead call it fromQuoted 9 lines
amdgpu_dm_connector_mode_valid(). Since, we are guaranteed to only calldrm_mode_set_crtcinfo()for valid modes from that function (invalid modes are rejected by that callback) and that is the only user ofcreate_validate_stream_for_sink()that we need to calldrm_mode_set_crtcinfo()for (as before commitcb841d27b876("drm/amd/display: Always passconnector_stateto stream validation"), that is the only place where create_validate_stream_for_sink()'sdm_statewas NULL).
Quoted 4 lines
I don't seem to see how a NULL
dm_stateincreate_validate_stream_for_sink()(orcreate_stream_for_sink()for that matter) has an impact on thedrm_mode_set_crtcinfo()call. That one depends on !old_stream and &mode.
If we look back to commit 4a2df0d1f28e ("drm/amd/display: Fixed non-native modes not lighting up") it seems like the intent was to only have drm_mode_set_crtcinfo() called for amdgpu_dm_connector_mode_valid(). Since, even if we go that far back create_stream_for_sink()'s dm_state was only NULL when it was called from amdgpu_dm_connector_mode_valid().
Quoted 3 lines
It does look like &mode is an empty mode if we can't find a
preferred_mode, though. Not sure if that can cause an issue.
I don't think it should be an issue, since before commit 4a2df0d1f28e ("drm/amd/display: Fixed non-native modes not lighting up") we always called drm_mode_set_crtcinfo() in the aforementioned case (and only for that case).
Quoted 34 lines
Harry
Quoted 30 lines
Fixes cb841d27b876 ("drm/amd/display: Always pass connector_state to stream validation")Signed-off-by Hamza Mahfooz <[email protected]>--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2
-2@@ -6128,8 +6128,6 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector,if (recalculate_timing)drm_mode_set_crtcinfo (&saved_mode,0 ); -else if (!old_stream) -drm_mode_set_crtcinfo (&mode,0 );/* * If scaling is enabled and refresh rate didn't change @@ -6691,6 +6689,8 @@ enum drm_mode_status amdgpu_dm_connector_mode_valid(struct drm_connector *connec goto fail; } +drm_mode_set_crtcinfo (mode,0 ); + stream =create_validate_stream_for_sink (aconnector, mode,to_dm_connector_state (connector->state),NULL );
Signature · 1 line
Hamza
Quoted 30 lines · Hamza Mahfooz
Quoted 15 lines · Harry Wentland
Quoted 4 lines · Hamza Mahfooz
On eDP we can receive invalid modes from
dm_update_crtc_state()for entirely new streams for whichdrm_mode_set_crtcinfo()shouldn't be called on. So, instead of callingdrm_mode_set_crtcinfo()from withincreate_stream_for_sink()we can instead call it fromQuoted 9 lines
amdgpu_dm_connector_mode_valid(). Since, we are guaranteed to only calldrm_mode_set_crtcinfo()for valid modes from that function (invalid modes are rejected by that callback) and that is the only user ofcreate_validate_stream_for_sink()that we need to calldrm_mode_set_crtcinfo()for (as before commitcb841d27b876("drm/amd/display: Always passconnector_stateto stream validation"), that is the only place where create_validate_stream_for_sink()'sdm_statewas NULL).Quoted 4 lines
I don't seem to see how a NULL
dm_stateincreate_validate_stream_for_sink()(orcreate_stream_for_sink()for that matter) has an impact on thedrm_mode_set_crtcinfo()call. That one depends on !old_stream and &mode.If we look back to commit
4a2df0d1f28e("drm/amd/display: Fixed non-native modes not lighting up") it seems like the intent was to only havedrm_mode_set_crtcinfo()called foramdgpu_dm_connector_mode_valid(). Since, even if we go that far back create_stream_for_sink()'sdm_statewas only NULL when it was called fromamdgpu_dm_connector_mode_valid().Quoted 1 line
Quoted 5 lines
Quoted 2 lines
It does look like &mode is an empty mode if we can't find a
preferred_mode, though. Not sure if that can cause an issue.I don't think it should be an issue, since before commit
4a2df0d1f28e("drm/amd/display: Fixed non-native modes not lighting up") we always
I meant to refer to commit bd49f19039c1 ("drm/amd/display: Always set crtcinfo from create_stream_for_sink") here.
Quoted 35 lines
called
drm_mode_set_crtcinfo()in the aforementioned case (and only for that case).Quoted 33 lines
Harry
Quoted 29 lines
Fixes cb841d27b876 ("drm/amd/display: Always pass connector_state to stream validation")Signed-off-by Hamza Mahfooz <[email protected]>---
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0
-2@@ -6128,8 +6128,6 @@ create_stream_for_sink(structamdgpu_dm_connector *aconnector, if (recalculate_timing) drm_mode_set_crtcinfo(&saved_mode, 0); - else if (!old_stream) - drm_mode_set_crtcinfo(&mode, 0); /** If scaling is enabled and refresh rate didn't change @@ -6691,6 +6689,8 @@ enum drm_mode_statusamdgpu_dm_connector_mode_valid(struct
drm_connector*connec goto fail;
}
+drm_mode_set_crtcinfo(mode, 0);
+
stream =create_validate_stream_for_sink(aconnector, mode, to_dm_connector_state(connector->state), NULL);
Signature · 1 line
Hamza
Quoted 32 lines · Hamza Mahfooz
Quoted 30 lines · Hamza Mahfooz
Quoted 15 lines · Harry Wentland
Quoted 4 lines · Hamza Mahfooz
On eDP we can receive invalid modes from
dm_update_crtc_state()for entirely new streams for whichdrm_mode_set_crtcinfo()shouldn't be called on. So, instead of callingdrm_mode_set_crtcinfo()from withincreate_stream_for_sink()we can instead call it fromQuoted 9 lines
amdgpu_dm_connector_mode_valid(). Since, we are guaranteed to only calldrm_mode_set_crtcinfo()for valid modes from that function (invalid modes are rejected by that callback) and that is the only user ofcreate_validate_stream_for_sink()that we need to calldrm_mode_set_crtcinfo()for (as before commitcb841d27b876("drm/amd/display: Always passconnector_stateto stream validation"), that is the only place where create_validate_stream_for_sink()'sdm_statewas NULL).Quoted 4 lines
I don't seem to see how a NULL
dm_stateincreate_validate_stream_for_sink()(orcreate_stream_for_sink()for that matter) has an impact on thedrm_mode_set_crtcinfo()call. That one depends on !old_stream and &mode.If we look back to commit
4a2df0d1f28e("drm/amd/display: Fixed non-native modes not lighting up") it seems like the intent was to only havedrm_mode_set_crtcinfo()called foramdgpu_dm_connector_mode_valid(). Since, even if we go that far back create_stream_for_sink()'sdm_statewas only NULL when it was called fromamdgpu_dm_connector_mode_valid().Quoted 1 line
Quoted 11 lines
Quoted 5 lines
Quoted 2 lines
It does look like &mode is an empty mode if we can't find a
preferred_mode, though. Not sure if that can cause an issue.I don't think it should be an issue, since before commit
4a2df0d1f28e("drm/amd/display: Fixed non-native modes not lighting up") we alwaysI meant to refer to commit
bd49f19039c1("drm/amd/display: Always set crtcinfo fromcreate_stream_for_sink") here.Quoted 2 lines
called
drm_mode_set_crtcinfo()in the aforementioned case (and only for that case).
That's quite the tale of patches upon patches making things slightly worse until it no longer works right. Thanks for untangling this all the way back to 2018. It makes sense now.
Harry
Quoted 31 lines
Quoted 31 lines
Quoted 31 lines
Harry
Quoted 27 lines
Fixes cb841d27b876 ("drm/amd/display: Always pass connector_state to stream validation")Signed-off-by Hamza Mahfooz <[email protected]>---
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2
-2@@ -6128,8 +6128,6 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector, if (recalculate_timing) drm_mode_set_crtcinfo(&saved_mode, 0); - else if (!old_stream) - drm_mode_set_crtcinfo(&mode, 0); /** If scaling is enabled and refresh rate didn't change @@ -6691,6 +6689,8 @@ enum drm_mode_status amdgpu_dm_connector_mode_valid(struct drm_connector *connec goto fail; } + drm_mode_set_crtcinfo(mode, 0); + stream = create_validate_stream_for_sink(aconnector, mode, to_dm_connector_state(connector->state), NULL);