Re: [PATCH drm-misc-next v8 01/12] drm: manager to keep track of GPUs VA mappings

From: Steven Price
Date: Thu Jul 20 2023 - 06:44:14 EST


On 20/07/2023 01:14, Danilo Krummrich wrote:
> Add infrastructure to keep track of GPU virtual address (VA) mappings
> with a decicated VA space manager implementation.
>
> New UAPIs, motivated by Vulkan sparse memory bindings graphics drivers
> start implementing, allow userspace applications to request multiple and
> arbitrary GPU VA mappings of buffer objects. The DRM GPU VA manager is
> intended to serve the following purposes in this context.
>
> 1) Provide infrastructure to track GPU VA allocations and mappings,
> making using an interval tree (RB-tree).
>
> 2) Generically connect GPU VA mappings to their backing buffers, in
> particular DRM GEM objects.
>
> 3) Provide a common implementation to perform more complex mapping
> operations on the GPU VA space. In particular splitting and merging
> of GPU VA mappings, e.g. for intersecting mapping requests or partial
> unmap requests.
>
> Acked-by: Thomas Hellström <thomas.hellstrom@xxxxxxxxxxxxxxx>
> Acked-by: Matthew Brost <matthew.brost@xxxxxxxxx>
> Reviewed-by: Boris Brezillon <boris.brezillon@xxxxxxxxxxxxx>
> Tested-by: Matthew Brost <matthew.brost@xxxxxxxxx>
> Tested-by: Donald Robson <donald.robson@xxxxxxxxxx>
> Suggested-by: Dave Airlie <airlied@xxxxxxxxxx>
> Signed-off-by: Danilo Krummrich <dakr@xxxxxxxxxx>

[...]

> diff --git a/drivers/gpu/drm/drm_gpuva_mgr.c b/drivers/gpu/drm/drm_gpuva_mgr.c
> new file mode 100644
> index 000000000000..dee2235530d6
> --- /dev/null
> +++ b/drivers/gpu/drm/drm_gpuva_mgr.c

[...]

> +static bool
> +drm_gpuva_check_overflow(u64 addr, u64 range)
> +{
> + u64 end;
> +
> + return WARN(check_add_overflow(addr, range, &end),
> + "GPUVA address limited to %lu bytes.\n", sizeof(end));
> +}

This produces a warning on 32 bit systems as sizeof() isn't necessarily
an unsigned long. The fix below silences the warning.

Thanks,

Steve

---8<-----