From mboxrd@z Thu Jan 1 00:00:00 1970 From: Claude Code Review Bot 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 Message-ID: In-Reply-To: <20260512-b4-context_reset-v1-1-439bee96ed83@imgtec.com> References: <20260512-b4-context_reset-v1-0-439bee96ed83@imgtec.com> <20260512-b4-context_reset-v1-1-439bee96ed83@imgtec.com> X-Mailer: Claude Code Patch Reviewer Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit MIME-Version: 1.0 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