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/xe: Split TLB invalidation into submit and wait steps
Date: Tue, 03 Mar 2026 13:05:44 +1000	[thread overview]
Message-ID: <review-patch3-20260302163248.105454-4-thomas.hellstrom@linux.intel.com> (raw)
In-Reply-To: <20260302163248.105454-4-thomas.hellstrom@linux.intel.com>

Patch Review

This is a clean refactor that extracts the submit-and-wait logic from `xe_vm_range_tilemask_tlb_inval` into two separate functions in `xe_tlb_inval.c`.

**`xe_tlb_inval_batch` struct size concern:**

```c
struct xe_tlb_inval_batch {
	struct xe_tlb_inval_fence fence[XE_MAX_TILES_PER_DEVICE * XE_MAX_GT_PER_TILE];
	unsigned int num_fences;
};
```

With `XE_MAX_TILES_PER_DEVICE=2` and `XE_MAX_GT_PER_TILE=2`, this is 4 `xe_tlb_inval_fence` structs. Each contains a `struct dma_fence` (~80 bytes) plus overhead, so the batch is roughly ~400-500 bytes. This was already the case in the original `xe_vm_range_tilemask_tlb_inval` (which had `fence[XE_MAX_TILES_PER_DEVICE * XE_MAX_GT_PER_TILE]` on the stack), so it's not a regression. However, in patch 4 this struct gets embedded in `xe_userptr`, which means every userptr VMA now carries this overhead permanently. Worth noting but probably acceptable.

**Header include in `xe_tlb_inval_types.h`:**

```c
+#include "xe_device_types.h"
```

This pulls in the full device types header just for `XE_MAX_TILES_PER_DEVICE` and `XE_MAX_GT_PER_TILE`. Consider whether these constants could be defined in a smaller header or if `xe_device.h` (which has the `#define XE_MAX_GT_PER_TILE 2`) would be lighter-weight. Types headers generally try to minimize includes to avoid circular dependency issues.

**Error handling in `xe_svm_invalidate` caller:**

```c
	err = xe_tlb_inval_range_tilemask_submit(xe, vm->usm.asid, adj_start, adj_end,
						 tile_mask, &_batch);
	xe_tlb_inval_batch_wait(&_batch);
	WARN_ON_ONCE(err);
```

On error, `xe_tlb_inval_range_tilemask_submit` already calls `xe_tlb_inval_batch_wait` internally (the `goto wait` path sets `num_fences` and waits). Then the caller calls `xe_tlb_inval_batch_wait` again, but `num_fences` is 0 after the internal wait, so it's a no-op. This is harmless but slightly confusing - consider documenting that on error the batch is already waited/cleaned up.

**`xe_vm_invalidate_vma` behavior change:**

The original code called `xe_vm_range_tilemask_tlb_inval` which waited on error. The new code:
```c
	ret = xe_tlb_inval_range_tilemask_submit(xe, ..., &_batch);
	WRITE_ONCE(vma->tile_invalidated, vma->tile_mask);
	if (!ret)
		xe_tlb_inval_batch_wait(&_batch);
```

The `WRITE_ONCE(vma->tile_invalidated, vma->tile_mask)` now happens before the wait completes. In the original code it happened after the wait (since `xe_vm_range_tilemask_tlb_inval` blocked). This reordering seems intentional and is maintained in patch 4, but it means `tile_invalidated` is set before the TLB flush completes. Is this semantically correct? The pairing with `READ_ONCE` in `xe_vm_has_valid_gpu_mapping()` suggests this flag is read to check if invalidation was *initiated*, not *completed*, so it's likely fine.

**Naming: `_batch` with underscore prefix:**

The local variables in `xe_svm_invalidate` and `xe_vm_invalidate_vma` use `_batch` with a leading underscore. In kernel style, leading underscores on local variables are unusual and typically reserved for function/macro names. Consider just `batch` (as used in `xe_vm_invalidate_madvise_range`).

---

---
Generated by Claude Code Patch Reviewer

  parent reply	other threads:[~2026-03-03  3:05 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-02 16:32 [PATCH v2 0/4] Two-pass MMU interval notifiers Thomas Hellström
2026-03-02 16:32 ` [PATCH v2 1/4] mm/mmu_notifier: Allow two-pass struct mmu_interval_notifiers Thomas Hellström
2026-03-02 19:48   ` Matthew Brost
2026-03-02 21:12     ` Thomas Hellström
2026-03-03  3:05   ` Claude review: " Claude Code Review Bot
2026-03-02 16:32 ` [PATCH v2 2/4] drm/xe/userptr: Convert invalidation to two-pass MMU notifier Thomas Hellström
2026-03-02 18:57   ` Matthew Brost
2026-03-02 21:22     ` Thomas Hellström
2026-03-02 21:30       ` Matthew Brost
2026-03-03  3:05   ` Claude review: " Claude Code Review Bot
2026-03-02 16:32 ` [PATCH v2 3/4] drm/xe: Split TLB invalidation into submit and wait steps Thomas Hellström
2026-03-02 19:06   ` Matthew Brost
2026-03-02 21:29     ` Thomas Hellström
2026-03-02 21:31       ` Matthew Brost
2026-03-03  3:05   ` Claude Code Review Bot [this message]
2026-03-02 16:32 ` [PATCH v2 4/4] drm/xe/userptr: Defer Waiting for TLB invalidation to the second pass if possible Thomas Hellström
2026-03-02 19:14   ` Matthew Brost
2026-03-02 21:33     ` Thomas Hellström
2026-03-03  3:05   ` Claude review: " Claude Code Review Bot
2026-03-03  3:05 ` Claude review: Two-pass MMU interval notifiers Claude Code Review Bot
  -- strict thread matches above, loose matches on Subject: below --
2026-03-03 13:34 [PATCH v3 0/4] " Thomas Hellström
2026-03-03 13:34 ` [PATCH v3 3/4] drm/xe: Split TLB invalidation into submit and wait steps Thomas Hellström
2026-03-03 21:09   ` 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-patch3-20260302163248.105454-4-thomas.hellstrom@linux.intel.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