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: drm/imagination: Populate FW common context ID before passing to the FW
Date: Sat, 16 May 2026 14:11:25 +1000	[thread overview]
Message-ID: <review-patch1-20260512-b4-context_reset-v1-1-439bee96ed83@imgtec.com> (raw)
In-Reply-To: <20260512-b4-context_reset-v1-1-439bee96ed83@imgtec.com>

Patch Review

**Verdict: Good fix, minor nit**

This fixes a real bug. Before this patch, `ctx->ctx_id` was allocated via `xa_alloc()` *after* `pvr_context_create_queues()` which calls `pvr_queue_init_fw_context()`, which copies `ctx->ctx_id` into the firmware context at `pvr_queue.c:1097`:

```c
cctx_fw->server_common_context_id = ctx->ctx_id;
```

Since the struct is `kzalloc`'d, the firmware would always see `server_common_context_id = 0` instead of the actual allocated ID. Moving `xa_alloc()` earlier is the correct fix.

The cleanup of the old error path is also good. The old code had a comment about a race where another thread could take a reference on the context via `ctx_ids` between the `ctx_ids` allocation and the `ctx_handles` allocation failure. The new code's comment at `err_free_ctx_id` correctly explains why the erase is safe:

```c
/*
 * Ctx_id is not exposed to userspace and not visible yet within
 * the kernel/FW, plus a matching context handle (exposed to userspace)
 * hasn't been allocated yet, so it is safe to remove ctx_id
 * from the ctx_ids xarray.
 */
xa_erase(&pvr_dev->ctx_ids, ctx->ctx_id);
```

**Nit:** However, note that by moving `xa_alloc` for `ctx_ids` *earlier*, the window during which a partially-initialized context is visible in the `ctx_ids` xarray is now *larger*. If any code path does `xa_load(&pvr_dev->ctx_ids, id)` during this window, it would find a half-built context. The old code acknowledged this race. The commit message should mention why this is safe (e.g., "ctx_ids lookup only happens after the context handle is published to userspace").

---
Generated by Claude Code Patch Reviewer

  reply	other threads:[~2026-05-16  4:11 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-12  6:47 [PATCH 0/4] drm/imagination: Multiple enhancement Brajesh Gupta
2026-05-12  6:47 ` [PATCH 1/4] drm/imagination: Populate FW common context ID before passing to the FW Brajesh Gupta
2026-05-16  4:11   ` Claude Code Review Bot [this message]
2026-05-12  6:47 ` [PATCH 2/4] drm/imagination: Don't timeout job if its fence has been signaled Brajesh Gupta
2026-05-16  4:11   ` Claude review: " Claude Code Review Bot
2026-05-12  6:47 ` [PATCH 3/4] drm/imagination: Rename FW booted to FW initialised Brajesh Gupta
2026-05-16  4:11   ` Claude review: " Claude Code Review Bot
2026-05-12  6:47 ` [PATCH 4/4] drm/imagination: Access FW initialised state with READ/WRITE_ONCE Brajesh Gupta
2026-05-16  4:11   ` Claude review: " Claude Code Review Bot
2026-05-16  4:11 ` Claude review: drm/imagination: Multiple enhancement 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-patch1-20260512-b4-context_reset-v1-1-439bee96ed83@imgtec.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