All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Lazar, Lijo" <lijo.lazar@amd.com>
To: "Timur Kristóf" <timur.kristof@gmail.com>,
	amd-gfx@lists.freedesktop.org, Alexander.Deucher@amd.com,
	"Christian König" <christian.koenig@amd.com>,
	"Natalie Vock" <natalie.vock@gmx.de>,
	"Marek Olšák" <maraeo@gmail.com>,
	"Mario Limonciello" <mario.limonciello@amd.com>,
	"Tvrtko Ursulin" <tursulin@ursulin.net>,
	"Felix Kuehling" <Felix.Kuehling@amd.com>
Subject: Re: [PATCH 3/5] drm/amdgpu/sdma: Move SDMA v5.x queue reset to common code
Date: Fri, 28 Aug 2026 19:50:19 +0530	[thread overview]
Message-ID: <032550fc-5680-4f6c-974c-fe96cc8083e1@amd.com> (raw)
In-Reply-To: <20260828120729.25908-4-timur.kristof@gmail.com>



On 28-Aug-26 5:37 PM, Timur Kristóf wrote:
> The code was exactly the same between SDMA v5.0 and v5.2
> furthermore the exact same implementation can be shared
> between all SDMA versions that don't use MES.
> 
> Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c | 37 ++++++++++++++++++++++++
>   drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h |  4 +++
>   drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c   | 25 +---------------
>   drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c   | 25 +---------------
>   4 files changed, 43 insertions(+), 48 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c
> index 66f278f77f71..9eebd8380834 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c
> @@ -635,3 +635,40 @@ int amdgpu_sdma_reset_engine(struct amdgpu_device *adev, uint32_t instance_id,
>   
>   	return ret;
>   }
> +
> +/**
> + * amdgpu_sdma_reset_queue_legacy() - Reset legacy SDMA queue after timeout (without MES)
> + *
> + * @ring: Pointer to the ring of the SDMA queue
> + * @vmid: VMID of the timed out job
> + * @timedout_fence: Fence of the timed out job
> + *
> + * Common implementation for resetting SDMA queues without MES (legacy).
> + * This relies on the proper amdgpu_sdma_funcs to be set up
> + * for the given ring.
> + *
> + * Applicable to SDMA versions that don't rely on the MES yet,
> + * that is all versions up to SDMA v5.x and older.
> + */
> +int amdgpu_sdma_reset_queue_legacy(struct amdgpu_ring *ring,
> +				   unsigned int vmid,
> +				   struct amdgpu_fence *timedout_fence)
> +{
> +	struct amdgpu_device *adev = ring->adev;
> +	int r;
> +
> +	if (ring->me >= adev->sdma.num_instances) {
> +		dev_err(adev->dev, "sdma instance not found\n");
> +		return -EINVAL;
> +	}
> +
> +	amdgpu_ring_reset_helper_begin(ring, timedout_fence);
> +
> +	amdgpu_amdkfd_suspend(adev, true);
> +	r = amdgpu_sdma_reset_engine(adev, ring->me, true);
> +	amdgpu_amdkfd_resume(adev, true);
> +	if (r)
> +		return r;
> +
> +	return amdgpu_ring_reset_helper_end(ring, timedout_fence);
> +}

Instead of moving it here - sdma_v5_x_reset_queue and using it for 5.2 
is better. This may not work in the same way for all legacy queues.

Thanks,
Lijo

> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h
> index 4f4e56022c97..7c4e145ca0c1 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h
> @@ -160,6 +160,10 @@ struct amdgpu_buffer_funcs {
>   int amdgpu_sdma_reset_engine(struct amdgpu_device *adev, uint32_t instance_id,
>   			     bool caller_handles_kernel_queues);
>   
> +int amdgpu_sdma_reset_queue_legacy(struct amdgpu_ring *ring,
> +				   unsigned int vmid,
> +				   struct amdgpu_fence *timedout_fence);
> +
>   #define amdgpu_emit_copy_buffer(adev, ib, s, d, b, t) (adev)->mman.buffer_funcs->emit_copy_buffer((ib),  (s), (d), (b), (t))
>   #define amdgpu_emit_fill_buffer(adev, ib, s, d, b) (adev)->mman.buffer_funcs->emit_fill_buffer((ib), (s), (d), (b))
>   
> diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c b/drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c
> index 0da54c335822..76f8765fb175 100644
> --- a/drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c
> @@ -1518,29 +1518,6 @@ static int sdma_v5_0_wait_for_idle(struct amdgpu_ip_block *ip_block)
>   	return -ETIMEDOUT;
>   }
>   
> -static int sdma_v5_0_reset_queue(struct amdgpu_ring *ring,
> -				 unsigned int vmid,
> -				 struct amdgpu_fence *timedout_fence)
> -{
> -	struct amdgpu_device *adev = ring->adev;
> -	int r;
> -
> -	if (ring->me >= adev->sdma.num_instances) {
> -		dev_err(adev->dev, "sdma instance not found\n");
> -		return -EINVAL;
> -	}
> -
> -	amdgpu_ring_reset_helper_begin(ring, timedout_fence);
> -
> -	amdgpu_amdkfd_suspend(adev, true);
> -	r = amdgpu_sdma_reset_engine(adev, ring->me, true);
> -	amdgpu_amdkfd_resume(adev, true);
> -	if (r)
> -		return r;
> -
> -	return amdgpu_ring_reset_helper_end(ring, timedout_fence);
> -}
> -
>   static int sdma_v5_0_stop_queue(struct amdgpu_ring *ring)
>   {
>   	u32 f32_cntl, freeze, cntl, stat1_reg;
> @@ -1936,7 +1913,7 @@ static const struct amdgpu_ring_funcs sdma_v5_0_ring_funcs = {
>   	.emit_reg_write_reg_wait = sdma_v5_0_ring_emit_reg_write_reg_wait,
>   	.init_cond_exec = sdma_v5_0_ring_init_cond_exec,
>   	.preempt_ib = sdma_v5_0_ring_preempt_ib,
> -	.reset = sdma_v5_0_reset_queue,
> +	.reset = amdgpu_sdma_reset_queue_legacy,
>   };
>   
>   static void sdma_v5_0_set_ring_funcs(struct amdgpu_device *adev)
> diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c b/drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c
> index 5543e381dcca..e7f4b74f27b4 100644
> --- a/drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c
> +++ b/drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c
> @@ -1436,29 +1436,6 @@ static int sdma_v5_2_wait_for_idle(struct amdgpu_ip_block *ip_block)
>   	return -ETIMEDOUT;
>   }
>   
> -static int sdma_v5_2_reset_queue(struct amdgpu_ring *ring,
> -				 unsigned int vmid,
> -				 struct amdgpu_fence *timedout_fence)
> -{
> -	struct amdgpu_device *adev = ring->adev;
> -	int r;
> -
> -	if (ring->me >= adev->sdma.num_instances) {
> -		dev_err(adev->dev, "sdma instance not found\n");
> -		return -EINVAL;
> -	}
> -
> -	amdgpu_ring_reset_helper_begin(ring, timedout_fence);
> -
> -	amdgpu_amdkfd_suspend(adev, true);
> -	r = amdgpu_sdma_reset_engine(adev, ring->me, true);
> -	amdgpu_amdkfd_resume(adev, true);
> -	if (r)
> -		return r;
> -
> -	return amdgpu_ring_reset_helper_end(ring, timedout_fence);
> -}
> -
>   static int sdma_v5_2_stop_queue(struct amdgpu_ring *ring)
>   {
>   	u32 f32_cntl, freeze, cntl, stat1_reg;
> @@ -1951,7 +1928,7 @@ static const struct amdgpu_ring_funcs sdma_v5_2_ring_funcs = {
>   	.emit_reg_write_reg_wait = sdma_v5_2_ring_emit_reg_write_reg_wait,
>   	.init_cond_exec = sdma_v5_2_ring_init_cond_exec,
>   	.preempt_ib = sdma_v5_2_ring_preempt_ib,
> -	.reset = sdma_v5_2_reset_queue,
> +	.reset = amdgpu_sdma_reset_queue_legacy,
>   };
>   
>   static void sdma_v5_2_set_ring_funcs(struct amdgpu_device *adev)


  reply	other threads:[~2026-08-28 14:20 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-28 12:07 [PATCH 0/5] drm/amdgpu/sdma: Improve existing SDMA queue resets Timur Kristóf
2026-08-28 12:07 ` [PATCH 1/5] drm/amdgpu/sdma: Clear SDMA rings after reset before starting them Timur Kristóf
2026-08-28 12:07 ` [PATCH 2/5] drm/amdgpu/sdma: Remove unimplemented soft_reset() for SDMA and SI DMA Timur Kristóf
2026-08-28 14:21   ` Lazar, Lijo
2026-08-28 12:07 ` [PATCH 3/5] drm/amdgpu/sdma: Move SDMA v5.x queue reset to common code Timur Kristóf
2026-08-28 14:20   ` Lazar, Lijo [this message]
2026-08-28 15:37     ` Timur Kristóf
2026-08-28 15:52       ` Alex Deucher
2026-08-28 15:53       ` Lazar, Lijo
2026-08-28 12:07 ` [PATCH 4/5] drm/amdgpu/sdma: Use common SDMA legacy queue reset on SDMA v4.4.2 Timur Kristóf
2026-08-28 14:16   ` Lazar, Lijo
2026-08-28 15:36     ` Timur Kristóf
2026-08-28 15:46       ` Lazar, Lijo
2026-08-28 12:07 ` [PATCH 5/5] drm/amdgpu/sdma: In legacy queue reset function, check if KFD is initialized Timur Kristóf
2026-08-28 14:11   ` Lazar, Lijo
2026-08-28 15:34     ` Timur Kristóf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=032550fc-5680-4f6c-974c-fe96cc8083e1@amd.com \
    --to=lijo.lazar@amd.com \
    --cc=Alexander.Deucher@amd.com \
    --cc=Felix.Kuehling@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=christian.koenig@amd.com \
    --cc=maraeo@gmail.com \
    --cc=mario.limonciello@amd.com \
    --cc=natalie.vock@gmx.de \
    --cc=timur.kristof@gmail.com \
    --cc=tursulin@ursulin.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.