Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] Unreachable dead code block added for IOVA cursor segment advancement in xe_res_next(). --
--- Patch [27]: [PATCH v2 27/33] drm/xe: Add IOVA-based xe_res_cursor variant --- commit 8700355546957aacaa7e49fc841d6e860b3ed9e7 Author: Matthew Brost <[email protected]> drm/xe: Add IOVA-based xe_res_cursor variant Introduce xe_res_first_iova() to walk a buffer that was DMA mapped using the IOVA-based DMA API. Such a mapping is described by a struct dma_iova_state and is a single contiguous IOVA range, so the cursor walks it as one segment. > diff --git a/drivers/gpu/drm/xe/xe_res_cursor.h > b/drivers/gpu/drm/xe/xe_res_cursor.h > index 0522caafd89d7..f0f1d699e16e5 100644 > --- a/drivers/gpu/drm/xe/xe_res_cursor.h > +++ b/drivers/gpu/drm/xe/xe_res_cursor.h [ ... ] > @@ -255,6 +264,41 @@ static inline void xe_res_first_dma(const struct > drm_pagemap_addr *dma_addr, > +static inline void xe_res_first_iova(struct dma_iova_state *state, > + u64 start, u64 size, > + struct xe_res_cursor *cur) > +{ > + XE_WARN_ON(!state); > + XE_WARN_ON(start + size > dma_iova_size(state)); > + > + cur->node = NULL; > + cur->start = start; > + cur->remaining = size; > + cur->size = size; > + cur->dma_addr = NULL; > + cur->sgl = NULL; > + cur->dma_start = state->addr; > + cur->dma_seg_size = dma_iova_size(state); > + cur->mem_type = XE_PL_TT; > + cur->is_iova = true; > } [ ... ] > @@ -283,6 +327,13 @@ static inline void xe_res_next(struct xe_res_cursor > *cur, u64 size) > if (cur->size > size) { > cur->size -= size; > cur->start += size; > return; > } > > + if (cur->is_iova) { > + /* Single contiguous IOVA segment. */ > + cur->start += size; > + cur->size = cur->remaining; > + return; > + } > + [Severity: Low] Is this block unreachable dead code? In xe_res_first_iova(), the cursor is initialized as a single segment where cur->size is equal to cur->remaining: cur->remaining = size; cur->size = size; When xe_res_next(cur, size) is called, it first subtracts size from cur->remaining. If the entire remaining segment is consumed, it returns early via if (!cur->remaining). If only a portion of the segment is consumed, size is strictly less than cur->size. This causes the function to always take the early return path immediately above this newly added block: if (cur->size > size) { cur->size -= size; cur->start += size; return; } Because an IOVA cursor is a single contiguous segment where cur->size and cur->remaining start perfectly synchronized, does it ever need to bypass these early returns and evaluate the if (cur->is_iova) block? -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=27
