Skip to content

Commit 7bd68ce

Browse files
hghimiralucasdemarchi
authored andcommitted
drm/gpusvm: Introduce devmem_only flag for allocation
This commit adds a new flag, devmem_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 memory. If the allocation from device memory fails, the function will return an -EFAULT error. Required for shared CPU and GPU atomics on certain devices. v3: - s/vram_only/devmem_only/ Fixes: 99624bd ("drm/gpusvm: Add support for GPU Shared Virtual Memory") Cc: stable@vger.kernel.org Signed-off-by: Matthew Brost <matthew.brost@intel.com> Signed-off-by: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com> Reviewed-by: Matthew Brost <matthew.brost@intel.com> Link: https://lore.kernel.org/r/20250512135500.1405019-2-matthew.brost@intel.com (cherry picked from commit 8a9b978) Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
1 parent b1f7041 commit 7bd68ce

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

drivers/gpu/drm/drm_gpusvm.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1454,6 +1454,11 @@ int drm_gpusvm_range_get_pages(struct drm_gpusvm *gpusvm,
14541454
goto err_unmap;
14551455
}
14561456

1457+
if (ctx->devmem_only) {
1458+
err = -EFAULT;
1459+
goto err_unmap;
1460+
}
1461+
14571462
addr = dma_map_page(gpusvm->drm->dev,
14581463
page, 0,
14591464
PAGE_SIZE << order,

include/drm/drm_gpusvm.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ struct drm_gpusvm {
286286
* @in_notifier: entering from a MMU notifier
287287
* @read_only: operating on read-only memory
288288
* @devmem_possible: possible to use device memory
289+
* @devmem_only: use only device memory
289290
*
290291
* Context that is DRM GPUSVM is operating in (i.e. user arguments).
291292
*/
@@ -294,6 +295,7 @@ struct drm_gpusvm_ctx {
294295
unsigned int in_notifier :1;
295296
unsigned int read_only :1;
296297
unsigned int devmem_possible :1;
298+
unsigned int devmem_only :1;
297299
};
298300

299301
int drm_gpusvm_init(struct drm_gpusvm *gpusvm,

0 commit comments

Comments
 (0)