Re: [PATCH v5 04/11] drm/gpuvm: Add a helper to check if two VA can be merged
From: Alice Ryhl
Date: Fri Mar 27 2026 - 05:32:40 EST
On Fri, Mar 13, 2026 at 03:09:41PM +0000, Adrián Larumbe wrote:
> From: Boris Brezillon <boris.brezillon@xxxxxxxxxxxxx>
>
> We are going to add flags/properties that will impact the VA merging
> ability. Instead of sprinkling tests all over the place in
> __drm_gpuvm_sm_map(), let's add a helper aggregating all these checks
> can call it for every existing VA we walk through in the
> __drm_gpuvm_sm_map() loop.
>
> Signed-off-by: Boris Brezillon <boris.brezillon@xxxxxxxxxxxxx>
> Signed-off-by: Caterina Shablia <caterina.shablia@xxxxxxxxxxxxx>
> + /* We intentionally ignore u64 underflows because all we care about
> + * here is whether the VA diff matches the GEM offset diff.
> + */
> + return b->va.addr - a->va.addr == b->gem.offset - a->gem.offset;
Please use wrapping_sub() to make it clear to sanitizers etc that
underflow is intentional in this case.
Alice