From mboxrd@z Thu Jan 1 00:00:00 1970 From: Claude Code Review Bot To: dri-devel-reviews@example.com Subject: Claude review: vfio/pci: Add mmap() attributes to DMABUF feature Date: Thu, 28 May 2026 12:28:53 +1000 Message-ID: In-Reply-To: <20260527102319.100128-10-mattev@meta.com> References: <20260527102319.100128-1-mattev@meta.com> <20260527102319.100128-10-mattev@meta.com> X-Mailer: Claude Code Patch Reviewer Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit MIME-Version: 1.0 Patch Review Adds `VFIO_DEVICE_FEATURE_DMA_BUF_MEMATTR` for setting UC/WC memory attributes on exported DMABUFs. **Bug -- wrong errno**: ```c + default: + ret = -ENOTSUPP; ``` `-ENOTSUPP` is `524` (kernel-internal, `EOPNOTSUPP` equivalent for in-kernel use only). For a UAPI-facing path that returns to userspace, this should be `-EOPNOTSUPP` (`95`). The docstring even says `ENOTSUPP` but userspace will see the raw `524` value which is non-standard. Fix: ```c ret = -EOPNOTSUPP; ``` **GET+SET combined semantics**: When both `VFIO_DEVICE_FEATURE_GET` and `VFIO_DEVICE_FEATURE_SET` are specified, the code applies SET first, then returns the *old* value via GET: ```c + uint32_t old_attr = priv->memattr; + if (flags & VFIO_DEVICE_FEATURE_SET) { ... } + db_attr.memattr = old_attr; + } + if (!ret && (flags & VFIO_DEVICE_FEATURE_GET)) { + if (copy_to_user(arg, &db_attr, sizeof(db_attr))) ``` This "swap" semantic (set new, return old) is unusual and should be documented in the UAPI header. Users would typically expect GET to return the current (post-SET) value. Consider whether this is the intended behavior or a bug. **`memattr` initialization for BAR mmap DMABUFs**: In `vfio_pci_core_mmap_prep_dmabuf()`, `priv->memattr` is not explicitly set, relying on `kzalloc` zero-initialization to give `VFIO_DEVICE_FEATURE_DMA_BUF_MEMATTR_NC = 0`. This is fine but fragile -- if the enum values ever change, this would break. The explicit `VFIO_DEVICE_FEATURE_DMA_BUF_MEMATTR_NC` enum name is used in patch 9 for the explicit export path, so it would be consistent to also set it explicitly in the mmap path. (Low priority.) **Naming inconsistency**: The enum uses `_NC` (noncached) but the UAPI docstring says "The default ... is NC." Meanwhile patch 7 uses `pgprot_noncached`. The cover letter and commit message say "UC" (uncached). These are the same thing in practice, but the UAPI should pick one term and stick with it. `UC` is more conventional for MMIO. --- Generated by Claude Code Patch Reviewer