Re: [PATCH v2 0/4] gpu: nova-core: gsp: add locking to Cmdq
From: Zhi Wang
Date: Thu Feb 26 2026 - 14:05:59 EST
On Thu, 26 Feb 2026 23:50:22 +0900
Eliot Courtney <ecourtney@xxxxxxxxxx> wrote:
Tested-by: Zhi Wang <zhiw@xxxxxxxxxx>
> Add locking to Cmdq. This is required e.g. for unloading the driver,
> which needs to send the UnloadingGuestDriver via the command queue
> on unbind which may be on a different thread.
>
> We have commands that need a reply ("sync") and commands that don't
> ("async"). For sync commands we want to make sure that they don't get
> the reply of a different command back. The approach this patch series
> takes is by making sync commands block until they get a response. For
> now this should be ok, and we expect GSP to be fast anyway.
>
> To do this, we need to know which commands expect a reply and which
> don't. John's existing series[1] adds IS_ASYNC which solves part of
> the problem, but we need to know a bit more. So instead, add an
> associated type called Reply which tells us what the reply is.
>
> An alternative would be to define traits inheriting CommandToGsp, e.g.
> SyncCommand and AsyncCommand, instead of using the associated type. I
> implemented the associated type version because it feels more
> compositional rather than inherity so seemed a bit better to me. But
> both of these approaches work and are fine, IMO.
>
> In summary, this patch series has three steps:
> 1. Add the type infrastructure to know what replies are expected for a
> command and update each caller to explicitly send a sync or async
> command.
> 2. Make Cmdq pinned so we can use Mutex
> 3. Add a Mutex to protect Cmdq by moving the relevant state to an
> inner struct.
>
> [1]:
> https://lore.kernel.org/all/20260211000451.192109-1-jhubbard@xxxxxxxxxx/
>
> Signed-off-by: Eliot Courtney <ecourtney@xxxxxxxxxx>
> ---
> Changes in v2:
> - Rebase on drm-rust-next
> - Link to v1:
> https://lore.kernel.org/r/20260225-cmdq-locking-v1-0-bbf6b4156706@xxxxxxxxxx
>
> ---
> Eliot Courtney (4):
> gpu: nova-core: gsp: fix stale doc comments on command queue
> methods gpu: nova-core: gsp: add sync and async command queue API to
> `Cmdq` gpu: nova-core: gsp: make `Cmdq` a pinned type
> gpu: nova-core: gsp: add mutex locking to Cmdq
>
> drivers/gpu/nova-core/gsp.rs | 5 +-
> drivers/gpu/nova-core/gsp/boot.rs | 13 +-
> drivers/gpu/nova-core/gsp/cmdq.rs | 246
> +++++++++++++++++++++------------
> drivers/gpu/nova-core/gsp/commands.rs | 23 ++-
> drivers/gpu/nova-core/gsp/sequencer.rs | 2 +- 5 files changed, 183
> insertions(+), 106 deletions(-) ---
> base-commit: 4a49fe23e357b48845e31fe9c28a802c05458198
> change-id: 20260225-cmdq-locking-d32928a2c2cf
> prerequisite-message-id:
> <20260226-cmdq-continuation-v3-0-572ab9916766@xxxxxxxxxx>
> prerequisite-patch-id: fd45bc5b8eda5e2b54a052dddb1a1c363107f0a7
> prerequisite-patch-id: d0f59ef489346e978a222755f9fb42dfe7af19e5
> prerequisite-patch-id: 8844970d0e387488c70979a73732579ba174b46c
> prerequisite-patch-id: e138a94ed48fa8d50d5ed1eb36524f98923ed478
> prerequisite-patch-id: 4599a5e90d6665fa3acb7d4045de5d378ac28b4d
> prerequisite-patch-id: 30ed64c398e541d6efbcb2e46ed9a9e6cf953f4f
> prerequisite-patch-id: 9a965e9f29c8680c0b554e656ff8e9a1bfc67280
> prerequisite-patch-id: d8cccc3dfb070f304805fc7e0f24121809b4b300
> prerequisite-patch-id: c0a73dfd1fb630ab02486f0180b90f8fe850b4dc
>
> Best regards,