All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Timur Kristóf" <timur.kristof@gmail.com>
To: amd-gfx@lists.freedesktop.org,
	Alex Deucher <alexander.deucher@amd.com>,
	christian.koenig@amd.com, pierre-eric.pelloux-prayer@amd.com,
	Natalie Vock <natalie.vock@gmx.de>,
	Tvrtko Ursulin <tursulin@ursulin.net>
Subject: Re: [PATCH 6/9] drm/amdgpu/gfx7: Clean up gfx ring during reset
Date: Wed, 15 Jul 2026 12:16:36 +0200	[thread overview]
Message-ID: <20288812.fSG56mABFh@timur-max> (raw)
In-Reply-To: <d6e5a13d-bb65-4633-8c0e-8b89f292bc3f@ursulin.net>

On 2026. július 15., szerda 11:18:19 közép-európai nyári idő Tvrtko Ursulin 
wrote:
> On 13/07/2026 13:58, Timur Kristóf wrote:
> > Clear the WPTR and RPTR at ring initialization.
> > Additionally clear the ring contents during reset.
> 
> Please add the why part to your commit messages. ;)

After a reset, the ring contents could be "dirty" and thus need to be cleared 
to prevent the command processor from executing packets left over in the ring 
from before the reset. I think this is obvious, but I'm happy to add some text 
to the commit message to explain it more.

> 
> Cover letter mentions the series is reworking to match gfx7 to gfx8 but
> I looked in drm-tip and amd-staging-drm-next and
> gfx_v8_0_cp_gfx_resume() does not yet have these changes.

The GFX8 code does have this:

For graphics queues:
In gfx_v8_0_cp_gfx_resume() it also sets wptr = 0; and calls 
amdgpu_ring_clear_ring() unconditionally. This is actually not needed during 
first initialization because the amdgpu_ring_init() called from 
gfx_v8_0_sw_init() already clears the ring, which is why I call the clear 
conditionally on GFX6-7. I could of course change the GFX6-7 code to also call 
it unconditionally though for the sake of simplicity and consistency.
(It is missing the atomic things though. I think it should have that too.)

For compute queues:
In gfx_v8_0_kcq_init_queue() it clears the wptr, also the wptr_cpu_addr and 
also calls amdgpu_ring_clear_ring().


> 
> > Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
> > ---
> > 
> >   drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c | 9 ++++++++-
> >   1 file changed, 8 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c
> > b/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c index a93cc02c3400..915612628f9a
> > 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c
> > @@ -2546,8 +2546,14 @@ static int gfx_v7_0_cp_gfx_resume(struct
> > amdgpu_device *adev)> 
> >   	WREG32(mmSCRATCH_ADDR, 0);
> >   	
> >   	/* ring 0 - compute and gfx */
> > 
> > -	/* Set ring buffer size */
> > 
> >   	ring = &adev->gfx.gfx_ring[0];
> > 
> > +	atomic64_set((atomic64_t *)ring->wptr_cpu_addr, 0);
> > +	atomic64_set((atomic64_t *)ring->rptr_cpu_addr, 0);
> 
> One day we need to fix this whole atomic64 situation.

What is the situation that needs to be fixed?


> 
> > +
> > +	if (amdgpu_in_reset(adev))
> > +		amdgpu_ring_clear_ring(ring);
> > +
> > +	/* Set ring buffer size */
> > 
> >   	rb_bufsz = order_base_2(ring->ring_size / 8);
> >   	tmp = (order_base_2(AMDGPU_GPU_PAGE_SIZE/8) << 8) | rb_bufsz;
> >   
> >   #ifdef __BIG_ENDIAN
> > 
> > @@ -2559,6 +2565,7 @@ static int gfx_v7_0_cp_gfx_resume(struct
> > amdgpu_device *adev)> 
> >   	WREG32(mmCP_RB0_CNTL, tmp | CP_RB0_CNTL__RB_RPTR_WR_ENA_MASK);
> >   	ring->wptr = 0;
> >   	WREG32(mmCP_RB0_WPTR, lower_32_bits(ring->wptr));
> > 
> > +	WREG32(mmCP_RB0_RPTR, lower_32_bits(ring->wptr));
> > 
> >   	/* set the wb address whether it's enabled or not */
> >   	rptr_addr = ring->rptr_gpu_addr;





  reply	other threads:[~2026-07-15 10:16 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-13 12:58 [PATCH 0/9] drm/amdgpu/gfx7: Use GFX IP block soft reset on GFX7 Timur Kristóf
2026-07-13 12:58 ` [PATCH 1/9] drm/amdgpu/gfx7: Make amdgpu_gfx_mqd_sw_init() usable " Timur Kristóf
2026-07-14 14:59   ` Tvrtko Ursulin
2026-07-14 15:05     ` Alex Deucher
2026-07-14 15:19       ` Tvrtko Ursulin
2026-07-14 15:39         ` Timur Kristóf
2026-07-14 18:23           ` Tvrtko Ursulin
2026-07-13 12:58 ` [PATCH 2/9] drm/amdgpu/gfx7: Refactor MQD initialization and finalization Timur Kristóf
2026-07-14 18:47   ` Tvrtko Ursulin
2026-07-15  8:08     ` Timur Kristóf
2026-07-15  8:26       ` Tvrtko Ursulin
2026-07-13 12:58 ` [PATCH 3/9] drm/amdgpu/gfx7: Return error code when compute ring tests fail Timur Kristóf
2026-07-14 18:55   ` Tvrtko Ursulin
2026-07-14 20:41     ` Alex Deucher
2026-07-15  8:02       ` Timur Kristóf
2026-07-15  9:50         ` Christian König
2026-07-15 10:50           ` Timur Kristóf
2026-07-13 12:58 ` [PATCH 4/9] drm/amdgpu/gfx7: Return error code when failing to start GFX ring Timur Kristóf
2026-07-14 18:58   ` Tvrtko Ursulin
2026-07-13 12:58 ` [PATCH 5/9] drm/amdgpu/gfx7: Fixup emitting SWITCH_BUFFER packets Timur Kristóf
2026-07-15  8:56   ` Tvrtko Ursulin
2026-07-15 10:36     ` Timur Kristóf
2026-07-15 11:20       ` Tvrtko Ursulin
2026-07-15 11:50       ` Christian König
2026-07-13 12:58 ` [PATCH 6/9] drm/amdgpu/gfx7: Clean up gfx ring during reset Timur Kristóf
2026-07-15  9:18   ` Tvrtko Ursulin
2026-07-15 10:16     ` Timur Kristóf [this message]
2026-07-15 11:07       ` Tvrtko Ursulin
2026-07-13 12:58 ` [PATCH 7/9] drm/amdgpu/gfx7: Use COND_EXEC Timur Kristóf
2026-07-15  9:38   ` Tvrtko Ursulin
2026-07-15 10:45     ` Timur Kristóf
2026-07-13 12:58 ` [PATCH 8/9] drm/amdgpu/gfx7: Fixup IP block soft reset Timur Kristóf
2026-07-15  9:53   ` Tvrtko Ursulin
2026-07-13 12:58 ` [PATCH 9/9] drm/amdgpu/gfx7: Enable IP block soft reset as a GPU recovery method Timur Kristóf
2026-07-15  9:55   ` Tvrtko Ursulin

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=20288812.fSG56mABFh@timur-max \
    --to=timur.kristof@gmail.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=christian.koenig@amd.com \
    --cc=natalie.vock@gmx.de \
    --cc=pierre-eric.pelloux-prayer@amd.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.