[PATCH] drm/amd/display: Align num_crtc to max_streams
Hamza Mahfooz
hamza.mahfooz at amd.com
Tue Feb 7 14:41:26 UTC 2023
On 2/7/23 09:31, Harry Wentland wrote:
>
>
> On 2/7/23 08:00, Hamza Mahfooz wrote:
>>
>> On 2/6/23 23:05, Tianci Yin wrote:
>>> From: tiancyin <tianci.yin at amd.com>
>>>
>>> [Why]
>>> Display pipe might be harvested on some SKUs, that cause the
>>> adev->mode_info.num_crtc mismatch with the usable crtc number,
>>> then below error dmesgs observed after GPU recover.
>>>
>>> *ERROR* amdgpu_dm_set_crtc_irq_state: crtc is NULL at id :3
>>> *ERROR* amdgpu_dm_set_crtc_irq_state: crtc is NULL at id :3
>>> *ERROR* amdgpu_dm_set_crtc_irq_state: crtc is NULL at id :3
>>> *ERROR* amdgpu_dm_set_pflip_irq_state: crtc is NULL at id :3
>>> *ERROR* amdgpu_dm_set_pflip_irq_state: crtc is NULL at id :3
>>> *ERROR* amdgpu_dm_set_pflip_irq_state: crtc is NULL at id :3
>>> *ERROR* amdgpu_dm_set_pflip_irq_state: crtc is NULL at id :3
>>> *ERROR* amdgpu_dm_set_vupdate_irq_state: crtc is NULL at id :3
>>> *ERROR* amdgpu_dm_set_vupdate_irq_state: crtc is NULL at id :3
>>> *ERROR* amdgpu_dm_set_vupdate_irq_state: crtc is NULL at id :3
>>>
>>> [How]
>>> The max_streams is limited number after pipe fuse, align num_crtc
>>> to max_streams to eliminate the error logs.
>>>
>>> Signed-off-by: tiancyin <tianci.yin at amd.com>
>>> ---
>>> drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 +++
>>> 1 file changed, 3 insertions(+)
>>>
>>> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
>>> index b31cfda30ff9..87ec2574cc09 100644
>>> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
>>> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
>>> @@ -4285,6 +4285,9 @@ static int amdgpu_dm_initialize_drm_device(struct amdgpu_device *adev)
>>> break;
>>> }
>>> + /* Adjust the crtc number according to the DCN pipe fuse. */
>>> + adev->mode_info.num_crtc = dm->dc->caps.max_streams;
>>
>> This would introduce array-out-bounds issues, since there are arrays of
>> size AMDGPU_MAX_CRTCS that use num_crtc as a bounds check.
>
> From what I can tell max_streams is always <= AMDGPU_MAX_CRTCS (6),
> though we're not checking. Maybe it'd be good to check and print a
> DRM_ERROR here if that's ever not the case (e.g., if we ever add
> any new ASIC that has more streams).
I have had UBSAN warns before commit d633b7a25fbe ("drm/amd/display: fix
possible buffer overflow relating to secure display") was applied, so it
seems to already be the case, maybe due to virtual streams.
>
> Harry
>
>>
>>> +
>>> for (i = 0; i < dm->dc->caps.max_streams; i++)
>>> if (amdgpu_dm_crtc_init(dm, mode_info->planes[i], i)) {
>>> DRM_ERROR("KMS: Failed to initialize crtc\n");
>>
>
--
Hamza
More information about the amd-gfx
mailing list