Thank you for your contribution! Sashiko AI review found 1 potential issue(s) 
to consider:
- [Low] The newly added `is_iova` block in `xe_res_next()` is mathematically 
unreachable and completely redundant.
--

--- Patch [27]: [PATCH v3 27/33] drm/xe: Add IOVA-based xe_res_cursor variant 
---
commit 41ab8ab5c8919ddc065db2f6f0c78d6b5b1b51d0
Author: Matthew Brost <[email protected]>

drm/xe: Add IOVA-based xe_res_cursor variant

This patch introduces a variant of xe_res_cursor for walking buffer objects
DMA mapped using the IOVA-based DMA API. It adds an is_iova flag to
distinguish single contiguous IOVA mappings and updates the cursor functions
to handle this contiguous segment appropriately.

> 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
[ ... ]
> @@ -283,6 +327,13 @@ static inline void xe_res_next(struct xe_res_cursor 
> *cur, u64 size)
>               return;
>       }
>  
> +     if (cur->is_iova) {
> +             /* Single contiguous IOVA segment. */
> +             cur->start += size;
> +             cur->size = cur->remaining;
> +             return;
> +     }
> +

[Severity: Low]
Is this block reachable?

In xe_res_first_iova(), cur->size is initialized to the full size, matching
cur->remaining.

When xe_res_next(cur, size) is called, it first decrements cur->remaining:

        cur->remaining -= size;
        if (!cur->remaining)
                return;

If the cursor isn't exhausted, the original cur->remaining must have been
greater than size. Since cur->size equals the original cur->remaining for
single contiguous IOVA mappings, cur->size will also be greater than size. 

This means execution will always enter the generic segment advancement block
immediately preceding this one:

        if (cur->size > size) {
                cur->size -= size;
                cur->start += size;
                return;
        }

Does this make the newly added is_iova block mathematically unreachable dead
code?

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=27

Reply via email to