public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: gpu: nova-core: gsp: add mechanism to wait for space on command queue
Date: Thu, 19 Feb 2026 18:43:07 +1000	[thread overview]
Message-ID: <review-patch2-20260219-cmdq-continuation-v2-2-2e8b7615536f@nvidia.com> (raw)
In-Reply-To: <20260219-cmdq-continuation-v2-2-2e8b7615536f@nvidia.com>

Patch Review

This patch adds `driver_write_area_size()` and changes `allocate_command` to poll-wait for space using `read_poll_timeout` instead of returning `EAGAIN` immediately.

> +    fn driver_write_area_size(&self) -> usize {
> +        let tx = self.cpu_write_ptr();
> +        let rx = self.gsp_read_ptr();
> +
> +        // `rx` and `tx` are both in `0..MSGQ_NUM_PAGES` per the invariants of `gsp_read_ptr` and
> +        // `cpu_write_ptr`. The minimum value case is where `rx == 0` and `tx == MSGQ_NUM_PAGES -
> +        // 1`, which gives `0 + MSGQ_NUM_PAGES - (MSGQ_NUM_PAGES - 1) - 1 == 0`.
> +        let slots = (rx + MSGQ_NUM_PAGES - tx - 1) % MSGQ_NUM_PAGES;
> +        num::u32_as_usize(slots) * GSP_PAGE_SIZE
> +    }

The comment says `rx` and `tx` are both in `0..MSGQ_NUM_PAGES`, but the invariant comments on `gsp_read_ptr` and `cpu_write_ptr` say "between `0` and `MSGQ_NUM_PAGES`" which is ambiguous about whether `MSGQ_NUM_PAGES` itself is included. Looking at the code, both functions use `% MSGQ_NUM_PAGES`, so the range is `0..MSGQ_NUM_PAGES` (exclusive of `MSGQ_NUM_PAGES`). The comment here is consistent and the math checks out.

> +        read_poll_timeout(
> +            || Ok(self.driver_write_area_size()),
> +            |available_bytes| *available_bytes >= size_of::<GspMsgElement>() + size,
> +            Delta::ZERO,
> +            timeout,
> +        )?;

After `read_poll_timeout` succeeds, the code calls `self.driver_write_area()` to get the actual mutable slices. Since `gsp_read_ptr` can only advance between the two calls (the GSP consumes data), the actual area is at least as large as what was polled, so no underflow can occur. The `&mut self` receiver prevents concurrent driver-side calls. This is safe.

The 1-second timeout used in `send_command` matches the nouveau driver pattern. No issues found.

---
Generated by Claude Code Patch Reviewer

  reply	other threads:[~2026-02-19  8:43 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-19  7:30 [PATCH v2 0/9] gpu: nova-core: gsp: add continuation record support Eliot Courtney
2026-02-19  7:30 ` [PATCH v2 1/9] gpu: nova-core: gsp: sort MsgFunction variants alphabetically Eliot Courtney
2026-02-19  8:43   ` Claude review: " Claude Code Review Bot
2026-02-19  7:30 ` [PATCH v2 2/9] gpu: nova-core: gsp: add mechanism to wait for space on command queue Eliot Courtney
2026-02-19  8:43   ` Claude Code Review Bot [this message]
2026-02-19  7:30 ` [PATCH v2 3/9] rust: add EMSGSIZE error code Eliot Courtney
2026-02-19  8:43   ` Claude review: " Claude Code Review Bot
2026-02-19  7:30 ` [PATCH v2 4/9] gpu: nova-core: gsp: add checking oversized commands Eliot Courtney
2026-02-19  8:43   ` Claude review: " Claude Code Review Bot
2026-02-19  7:30 ` [PATCH v2 5/9] gpu: nova-core: gsp: clarify invariant on command queue Eliot Courtney
2026-02-19  8:43   ` Claude review: " Claude Code Review Bot
2026-02-19  7:30 ` [PATCH v2 6/9] gpu: nova-core: gsp: unconditionally call variable payload handling Eliot Courtney
2026-02-19  8:43   ` Claude review: " Claude Code Review Bot
2026-02-19  7:30 ` [PATCH v2 7/9] gpu: nova-core: gsp: add command_size helper Eliot Courtney
2026-02-19  8:43   ` Claude review: " Claude Code Review Bot
2026-02-19  7:30 ` [PATCH v2 8/9] gpu: nova-core: gsp: support large RPCs via continuation record Eliot Courtney
2026-02-19  8:43   ` Claude review: " Claude Code Review Bot
2026-02-19  7:30 ` [PATCH v2 9/9] gpu: nova-core: gsp: add tests for SplitState Eliot Courtney
2026-02-19  8:43   ` Claude review: " Claude Code Review Bot
2026-02-19  8:43 ` Claude review: gpu: nova-core: gsp: add continuation record support Claude Code Review Bot
  -- strict thread matches above, loose matches on Subject: below --
2026-02-26 11:45 [PATCH v3 0/9] " Eliot Courtney
2026-02-26 11:45 ` [PATCH v3 2/9] gpu: nova-core: gsp: add mechanism to wait for space on command queue Eliot Courtney
2026-02-27  2:21   ` Claude review: " Claude Code Review Bot
2026-03-02 11:42 [PATCH v4 0/9] gpu: nova-core: gsp: add continuation record support Eliot Courtney
2026-03-02 11:42 ` [PATCH v4 2/9] gpu: nova-core: gsp: add mechanism to wait for space on command queue Eliot Courtney
2026-03-03  3:34   ` Claude review: " Claude Code Review Bot
2026-03-04  1:42 [PATCH v5 0/9] gpu: nova-core: gsp: add continuation record support Eliot Courtney
2026-03-04  1:42 ` [PATCH v5 2/9] gpu: nova-core: gsp: add mechanism to wait for space on command queue Eliot Courtney
2026-03-05  3:55   ` Claude review: " Claude Code Review Bot
2026-03-06  7:21 [PATCH v6 0/9] gpu: nova-core: gsp: add continuation record support Eliot Courtney
2026-03-06  7:21 ` [PATCH v6 2/9] gpu: nova-core: gsp: add mechanism to wait for space on command queue Eliot Courtney
2026-03-08 23:11   ` Claude review: " Claude Code Review Bot

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=review-patch2-20260219-cmdq-continuation-v2-2-2e8b7615536f@nvidia.com \
    --to=claude-review@example.com \
    --cc=dri-devel-reviews@example.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox