Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] drm/amdgpu/gfx11: wrong regGCVM_L2_STATUS offset in
  gfx_v11_0_wait_gc_idle()
--

commit b092d369a399e18251a9318c45400741bdc05ea3
Author: Jesse Zhang <[email protected]>

drm/amdgpu/gfx11: include SOFT_RESET_GFX in the gfx engine soft reset

This commit halts MES and RLC F32, waits for in-flight GC memory requests
to drain in gfx_v11_0_wait_gc_idle(), and pulses SOFT_RESET_GFX together
with SOFT_RESET_CPF and SOFT_RESET_CPG during a gfx engine soft reset.

> diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c 
> b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
> index a0ed3363f84d1..824d7914bece9 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
> @@ -6827,15 +6827,74 @@ static void gfx_v11_0_emit_mem_sync(struct 
> amdgpu_ring *ring)
>                                CP_STAT__UTCL2IU_BUSY_MASK)
>  
>  /* Reset CPF/CPG, PFP/ME and the gfx HQDs, then boot PFP/ME again. */
> +/*
> + * SOFT_RESET_GFX drops the memory requests in flight through the blocks it
> + * resets, and their clients then wait for them forever: MES still fetches
> + * instructions with its queues suspended, and RLC still writes its DRAM log
> + * in safe mode. The reset halts both, then waits for these busy bits of the
> + * GC memory interfaces to clear.
> + */
> +#define GFX11_GC_MEM_BUSY    (GRBM_STATUS2__EA_BUSY_MASK | \
> +                              GRBM_STATUS2__EA_LINK_BUSY_MASK | \
> +                              GRBM_STATUS2__UTCL2_BUSY_MASK | \
> +                              GRBM_STATUS2__UTCL2_RQ_PENDING_MASK | \
> +                              GRBM_STATUS2__TCP_BUSY_MASK | \
> +                              GRBM_STATUS2__CPC_BUSY_MASK | \
> +                              GRBM_STATUS2__RLC_BUSY_MASK | \
> +                              GRBM_STATUS2__RLC_RQ_PENDING_MASK | \
> +                              GRBM_STATUS2__SDMA_BUSY_MASK | \
> +                              GRBM_STATUS2__SDMA_SCH_RQ_PENDING_MASK | \
> +                              GRBM_STATUS2__SDMA0_RQ_PENDING_MASK | \
> +                              GRBM_STATUS2__SDMA1_RQ_PENDING_MASK)
> +
> +/* The RLC busy bits of its memory requests */
> +#define GFX11_RLC_MEM_BUSY   (RLC_STAT__MC_BUSY_MASK | \
> +                              RLC_STAT__RLC_SRM_BUSY_MASK | \
> +                              RLC_STAT__RLC_SPM_BUSY_MASK)
> +
> +/* Wait for the requests in flight in the GC, with MES and RLC F32 halted. */
> +static int gfx_v11_0_wait_gc_idle(struct amdgpu_device *adev)
> +{
> +     u32 busy, cpc, rlc;
> +     int i;
> +
> +     for (i = 0; i < adev->usec_timeout; i++) {
> +             busy = RREG32_SOC15(GC, 0, regGRBM_STATUS2) & GFX11_GC_MEM_BUSY;
> +             cpc = RREG32_SOC15(GC, 0, regCP_CPC_STATUS);
> +             rlc = RREG32_SOC15(GC, 0, regRLC_STAT);
> +
> +             /* The halted MES and F32 can stay busy, not their memory 
> requests. */
> +             if (!(cpc & GENMASK(21, 0) & ~CP_CPC_STATUS__MES_BUSY_MASK))
> +                     busy &= ~GRBM_STATUS2__CPC_BUSY_MASK;
> +             if (!(rlc & GFX11_RLC_MEM_BUSY))
> +                     busy &= ~GRBM_STATUS2__RLC_BUSY_MASK;
> +
> +             if (!busy && !(RREG32_SOC15(GC, 0, regGCVM_L2_STATUS) &
> +                            GCVM_L2_STATUS__L2_BUSY_MASK))
> +                     return 0;

[Severity: Medium]
Does RREG32_SOC15(GC, 0, regGCVM_L2_STATUS) read the wrong MMIO offset on
GC 11.0.3, GC 11.5.x and GC 11.7.x?

gfx_v11_0.c includes gc/gc_11_0_0_offset.h, where regGCVM_L2_STATUS is
0x15bf (BASE_IDX 0).  On GC 11.0.3 (gc/gc_11_0_3_offset.h) and GC 11.5.x /
11.7.x (gc/gc_11_5_0_offset.h), the gc_gcvml2pfdec block is shifted by 4
dwords (which is why gmc_v11_0_set_gfxhub_funcs() selects
gfxhub_v3_0_3_funcs and gfxhub_v11_5_0_funcs for those IP versions):
regGCVM_L2_CNTL is at 0x15c0 and regGCVM_L2_STATUS is at 0x15c3, leaving
0x15bf in an unmapped gap before regGCVM_L2_CNTL.

On those ASICs (such as GC 11.5.1 and GC 11.5.3 where gfx engine soft
reset is enabled), gfx_v11_0_wait_gc_idle() will not poll the real
GCVM_L2_STATUS register and can pulse SOFT_RESET_GFX while L2 requests are
still in flight, or time out if the unmapped read returns all-ones.

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=12

Reply via email to