From mboxrd@z Thu Jan 1 00:00:00 1970 From: Claude Code Review Bot To: dri-devel-reviews@example.com Subject: Claude review: udmabuf: emit one sg entry per pinned folio Date: Fri, 05 Jun 2026 06:49:28 +1000 Message-ID: In-Reply-To: <20260603-tcpdm-large-niovs-v1-2-f37a4ac6726c@meta.com> References: <20260603-tcpdm-large-niovs-v1-0-f37a4ac6726c@meta.com> <20260603-tcpdm-large-niovs-v1-2-f37a4ac6726c@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 This patch generalizes udmabuf's sg table construction to coalesce contiguous folio pages into single sg entries. **Observations:** 1. **Tree divergence:** The current drm-next tree uses `ubuf->pages[]` and `sg_alloc_table_from_pages()`, while this patch operates on `ubuf->folios[]` and `ubuf->offsets[]`. This is a dependency on an upstream udmabuf refactoring that isn't in drm-next yet. Not a bug in the patch, but the base must merge first. 2. **Double traversal of folio array:** ```c nents = udmabuf_sg_nents(ubuf); /* ... allocate ... */ for (i = 0; i < ubuf->pagecount; i += run) { run = udmabuf_folio_nr_pages(ubuf, i); ``` `udmabuf_folio_nr_pages` is called once in `udmabuf_sg_nents()` and again in the sg construction loop, so the folio array is traversed twice. This is fine for setup-time code, but if a reviewer is concerned about large page counts (NUM_PAGES is 16000), a single-pass approach could be considered. 3. **`sg_next()` after last entry:** ```c sgl = sg->sgl; for (i = 0; i < ubuf->pagecount; i += run) { run = udmabuf_folio_nr_pages(ubuf, i); sg_set_folio(sgl, ubuf->folios[i], run << PAGE_SHIFT, ubuf->offsets[i]); sgl = sg_next(sgl); } ``` After the last iteration, `sg_next(sgl)` returns NULL, and `sgl` is never used again. Harmless, but a more defensive approach would be to only call `sg_next` when there's a next iteration. 4. **The comment block style** uses `/* ... */` spanning multiple lines but without leading `*` on intermediate lines, which is inconsistent with typical kernel style (though acceptable per the coding guidelines as long as it's consistent within the file): ```c +/* Return the number of contiguous pages backed by the folio at @i. + * A udmabuf may map only part of a folio, or reference the same folio + * in multiple non-contiguous runs, so folio_nr_pages() can't be used. + */ ``` This is actually fine -- it does use `*` prefixes. No issue. --- Generated by Claude Code Patch Reviewer