[PATCH v2 12/32] drm/gpusvm: Introduce vram_only flag for VRAM allocation
Matthew Brost
matthew.brost at intel.com
Thu Apr 17 03:07:35 UTC 2025
On Mon, Apr 07, 2025 at 03:46:59PM +0530, Himal Prasad Ghimiray wrote:
> This commit adds a new flag, vram_only, to the drm_gpusvm structure. The
> purpose of this flag is to ensure that the get_pages function allocates
> memory exclusively from the device's VRAM. If the allocation from VRAM
> fails, the function will return an -EFAULT error.
>
> Suggested-by: Matthew Brost <matthew.brost at intel.com>
Again this is included in [1] with you remaining as the author.
Anyways:
Reviewed-by: Matthew Brost <matthew.brost at intel.com>
[1] https://patchwork.freedesktop.org/series/147846/
> Signed-off-by: Himal Prasad Ghimiray <himal.prasad.ghimiray at intel.com>
> ---
> drivers/gpu/drm/drm_gpusvm.c | 5 +++++
> include/drm/drm_gpusvm.h | 2 ++
> 2 files changed, 7 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_gpusvm.c b/drivers/gpu/drm/drm_gpusvm.c
> index 2451c816edd5..149ac56eff70 100644
> --- a/drivers/gpu/drm/drm_gpusvm.c
> +++ b/drivers/gpu/drm/drm_gpusvm.c
> @@ -1454,6 +1454,11 @@ int drm_gpusvm_range_get_pages(struct drm_gpusvm *gpusvm,
> goto err_unmap;
> }
>
> + if (ctx->vram_only) {
> + err = -EFAULT;
> + goto err_unmap;
> + }
> +
> addr = dma_map_page(gpusvm->drm->dev,
> page, 0,
> PAGE_SIZE << order,
> diff --git a/include/drm/drm_gpusvm.h b/include/drm/drm_gpusvm.h
> index df120b4d1f83..8093cc6ab1f4 100644
> --- a/include/drm/drm_gpusvm.h
> +++ b/include/drm/drm_gpusvm.h
> @@ -286,6 +286,7 @@ struct drm_gpusvm {
> * @in_notifier: entering from a MMU notifier
> * @read_only: operating on read-only memory
> * @devmem_possible: possible to use device memory
> + * @vram_only: Use only device memory
> *
> * Context that is DRM GPUSVM is operating in (i.e. user arguments).
> */
> @@ -294,6 +295,7 @@ struct drm_gpusvm_ctx {
> unsigned int in_notifier :1;
> unsigned int read_only :1;
> unsigned int devmem_possible :1;
> + unsigned int vram_only :1;
> };
>
> int drm_gpusvm_init(struct drm_gpusvm *gpusvm,
> --
> 2.34.1
>
More information about the Intel-xe
mailing list