Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [High] drm/amdgpu: unrolled sync_seq increment on MES error_undo paths
  [1]
--

commit 285ec5bbb9066cd84ed61683a42ebeae06434475
Author: Alex Deucher <[email protected]>

drm/amdgpu/mes11: add support for setting gang submit

This commit implements the set_gang_submit callback for MES v11 to allow a
primary and secondary queue to schedule together.

> diff --git a/drivers/gpu/drm/amd/amdgpu/mes_v11_0.c 
> b/drivers/gpu/drm/amd/amdgpu/mes_v11_0.c
> index 75e6079e6e332..d67dbc93e10d4 100644
> --- a/drivers/gpu/drm/amd/amdgpu/mes_v11_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/mes_v11_0.c
> @@ -1275,6 +1275,27 @@ static int mes_v11_0_enable_dbgext_irq(struct 
> amdgpu_mes *mes, bool enable)
>       return 0;
>  }
>  
> +static int mes_v11_0_set_gang_submit(struct amdgpu_mes *mes,
> +                                  struct mes_set_gang_submit_input *input)
> +{
> +     union MESAPI__SET_GANG_SUBMIT mes_gang_submit_pkt;
> +
> +     memset(&mes_gang_submit_pkt, 0, sizeof(mes_gang_submit_pkt));
> +
> +     mes_gang_submit_pkt.header.type = MES_API_TYPE_SCHEDULER;
> +     mes_gang_submit_pkt.header.opcode = MES_SCH_API_SET_GANG_SUBMIT;
> +     mes_gang_submit_pkt.header.dwsize = API_FRAME_SIZE_IN_DWORDS;
> +
> +     mes_gang_submit_pkt.set_gang_submit.gang_context_addr =
> +             input->primary_gang_context_addr;
> +     mes_gang_submit_pkt.set_gang_submit.slave_gang_context_addr =
> +             input->secondary_gang_context_addr;
> +
> +     return mes_v11_0_submit_pkt_and_poll_completion(mes,
> +                     &mes_gang_submit_pkt, sizeof(mes_gang_submit_pkt),
> +                     offsetof(union MESAPI__SET_GANG_SUBMIT, api_status));
> +}

[Severity: High]
This problem wasn't introduced by this patch, but can
mes_v11_0_submit_pkt_and_poll_completion() leave ring->fence_drv.sync_seq
incremented when amdgpu_fence_wait_polling() times out [1]?

drivers/gpu/drm/amd/amdgpu/mes_v11_0.c:mes_v11_0_submit_pkt_and_poll_completion()
 {
        ...
        seq = ++ring->fence_drv.sync_seq;
        r = amdgpu_fence_wait_polling(ring,
                                      seq - ring->fence_drv.num_fences_mask,
                                      timeout);
        if (r < 1) {
                r = -ETIMEDOUT;
                goto error_undo;
        }
        ...
error_undo:
        dev_err(adev->dev, "MES ring buffer is full.\n");
        amdgpu_ring_undo(ring);
        ...
}

The error_undo path rolls back the ring write pointer without decrementing
ring->fence_drv.sync_seq and without emitting the status fence packet.
Once ring->fence_drv.num_fences_mask timeouts accumulate, seq -
ring->fence_drv.num_fences_mask exceeds the highest fence sequence number
ever emitted to the ring, causing all subsequent MES submissions to time
out waiting on an unemitted fence until a GPU reset.  The same issue also
exists in mes_v12_0_submit_pkt_and_poll_completion() and
mes_v12_1_submit_pkt_and_poll_completion().

[1] https://sashiko.dev/#/bug/linux-dce92d12-1446-4f12-a395-575847569192

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

Reply via email to