[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <29299d67-d7e5-435e-9c80-89d8cce6ed95@amd.com>
Date: Fri, 21 Nov 2025 16:23:52 +0100
From: Christian König <christian.koenig@....com>
To: Pierre-Eric Pelloux-Prayer <pierre-eric@...sy.net>,
Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@....com>,
Alex Deucher <alexander.deucher@....com>, David Airlie <airlied@...il.com>,
Simona Vetter <simona@...ll.ch>
Cc: amd-gfx@...ts.freedesktop.org, dri-devel@...ts.freedesktop.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 18/28] drm/amdgpu: move sched status check inside
amdgpu_ttm_set_buffer_funcs_status
On 11/21/25 16:12, Pierre-Eric Pelloux-Prayer wrote:
>
>
> Le 21/11/2025 à 16:08, Christian König a écrit :
>>
>>
>> On 11/21/25 11:12, Pierre-Eric Pelloux-Prayer wrote:
>>> It avoids duplicated code and allows to output a warning.
>>>
>>> Signed-off-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@....com>
>>> ---
>>> drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 13 ++++---------
>>> drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 6 ++++++
>>> 2 files changed, 10 insertions(+), 9 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
>>> index 54f7c81f287b..7167db54d722 100644
>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
>>> @@ -3309,9 +3309,7 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev)
>>> if (r)
>>> goto init_failed;
>>> - if (adev->mman.buffer_funcs_ring &&
>>> - adev->mman.buffer_funcs_ring->sched.ready)
>>> - amdgpu_ttm_set_buffer_funcs_status(adev, true);
>>> + amdgpu_ttm_set_buffer_funcs_status(adev, true);
>>> /* Don't init kfd if whole hive need to be reset during init */
>>> if (adev->init_lvl->level != AMDGPU_INIT_LEVEL_MINIMAL_XGMI) {
>>> @@ -4191,8 +4189,7 @@ static int amdgpu_device_ip_resume(struct amdgpu_device *adev)
>>> r = amdgpu_device_ip_resume_phase2(adev);
>>> - if (adev->mman.buffer_funcs_ring->sched.ready)
>>> - amdgpu_ttm_set_buffer_funcs_status(adev, true);
>>> + amdgpu_ttm_set_buffer_funcs_status(adev, true);
>>> if (r)
>>> return r;
>>> @@ -5321,8 +5318,7 @@ int amdgpu_device_suspend(struct drm_device *dev, bool notify_clients)
>>> return 0;
>>> unwind_evict:
>>> - if (adev->mman.buffer_funcs_ring->sched.ready)
>>> - amdgpu_ttm_set_buffer_funcs_status(adev, true);
>>> + amdgpu_ttm_set_buffer_funcs_status(adev, true);
>>> amdgpu_fence_driver_hw_init(adev);
>>> unwind_userq:
>>> @@ -6050,8 +6046,7 @@ int amdgpu_device_reinit_after_reset(struct amdgpu_reset_context *reset_context)
>>> if (r)
>>> goto out;
>>> - if (tmp_adev->mman.buffer_funcs_ring->sched.ready)
>>> - amdgpu_ttm_set_buffer_funcs_status(tmp_adev, true);
>>> + amdgpu_ttm_set_buffer_funcs_status(tmp_adev, true);
>>> r = amdgpu_device_ip_resume_phase3(tmp_adev);
>>> if (r)
>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
>>> index 489880b2fb8e..9024dde0c5a7 100644
>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
>>> @@ -2233,6 +2233,12 @@ u32 amdgpu_ttm_set_buffer_funcs_status(struct amdgpu_device *adev, bool enable)
>>> adev->mman.buffer_funcs_enabled == enable || adev->gmc.is_app_apu)
>>> return reserved_windows;
>>> + if ((!adev->mman.buffer_funcs_ring || !adev->mman.buffer_funcs_ring->sched.ready) &&
>>> + enable) {
>>> + dev_warn(adev->dev, "Not enabling DMA transfers for in kernel use");
>>> + return 0;
>>> + }
>>> +
>>
>> Only check that when enabling the functions. Could be that when disabling them we have sched.ready set to false already.
>
> The check already has a "&& enable" condition. Are you suggesting something different?
Ah, missed that. But you have an "if (enabled) {" right below it. So I suggest to just move the check in there.
Regards,
Christian.
>
> PE
>
>
>>
>> Apart from that looks good to me.
>>
>> Regards,
>> Christian.
>>
>>> if (enable) {
>>> struct amdgpu_ring *ring;
>>> struct drm_gpu_scheduler *sched;
Powered by blists - more mailing lists