drm/amdgpu: add a debug flag to disable the userptr size limit
Subsystems (2)
PATCH 1/1 drm/amdgpu: add a debug flag to disable the userptr size limit
The GEM_USERPTR ioctl now rejects userptrs above 1GiB. Existing applications that register larger ranges fail with -EINVAL, and the limit might need to be adjusted based on customer feedback.
Add AMDGPU_DEBUG_DISABLE_USERPTR_SIZE_LIMIT (amdgpu.debug_mask=0x4000) as a workaround to lift the limit, and print a one time warning naming the flag when a userptr is rejected for its size so affected users can find it. A zero sized userptr is still rejected.
to disable the limit:
sudo modprobe amdgpu debug_mask=0x4000
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 7 +++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 8 +++++++- 3 files changed, 15 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
@@ -959,6 +959,7 @@ struct amdgpu_device {bool debug_enable_ce_cs;bool debug_hibernation_thaw_resume_gpu;bool debug_disable_ip_block_soft_reset; +bool debug_disable_userptr_size_limit;/* Protection for the following isolation structure */ struct mutex enforce_isolation_mutex;
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +7 -0
@@ -150,6 +150,7 @@ enum AMDGPU_DEBUG_MASK {AMDGPU_DEBUG_HIBERNATION_THAW_RESUME_GPU =BIT (11 ),AMDGPU_DEBUG_DISABLE_IP_BLOCK_SOFT_RESET =BIT (12 ),AMDGPU_DEBUG_SDMA_RB_CMD =BIT (13 ), + AMDGPU_DEBUG_DISABLE_USERPTR_SIZE_LIMIT = BIT(14), };unsigned int amdgpu_vram_limit =UINT_MAX ;
@@ -1092,6 +1093,7 @@ module_param_named(seamless, amdgpu_seamless, int, 0444);* - 0x20: Enable experimental resets * - 0x40: Disable ring resets * - 0x80: Use VRAM for SMU pool +* - 0x4000: Disable the 1GiB size limit of GEM_USERPTR */ MODULE_PARM_DESC (debug_mask,"debug options for amdgpu, disabled by default" );module_param_named_unsafe (debug_mask, amdgpu_debug_mask, uint,0444 );
@@ -2345,6 +2347,11 @@ static void amdgpu_init_debug_options(struct amdgpu_device *adev)pr_info ("debug: enable SDMA RB command switch\n" ); adev->sdma.sdma_debug = true; } + +if (amdgpu_debug_mask &AMDGPU_DEBUG_DISABLE_USERPTR_SIZE_LIMIT ) { +pr_info ("debug: userptr size limit disabled\n" ); + adev->debug_disable_userptr_size_limit = true; + } }static unsigned long amdgpu_fix_asic_type (struct pci_dev *pdev,unsigned long flags)
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +7 -1
@@ -567,8 +567,14 @@ int amdgpu_gem_userptr_ioctl(struct drm_device *dev, void *data,return -EFAULT ;/* Userptrs are for temporary uploads, not a general memory allocator */ -if (args->size ==0 || args->size >SZ_1G ) +if (args->size ==0 )return -EINVAL ; +if (args->size >SZ_1G && !adev->debug_disable_userptr_size_limit) { +dev_warn_once (adev->dev, +"userptr size %llu exceeds 1GiB, set amdgpu.debug_mask=0x4000 to lift the limit\n" , + args->size); +return -EINVAL ; + }/* reject unknown flag values */ if (args->flags & ~(AMDGPU_GEM_USERPTR_READONLY |
Signature · 1 line
2.34.1
AMD General
This patch is
-----Original Message-----
From: Yuan, Perry <[email protected]>
Sent: Tuesday, November 3, 2026 3:43 PM
To: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; [email protected]
Cc: Zhang, Yifan <[email protected]>; Yuan, Perry <[email protected]>
Subject: [PATCH] drm/amdgpu: add a debug flag to disable the userptr size limit
The GEM_USERPTR ioctl now rejects userptrs above 1GiB. Existing applications that register larger ranges fail with -EINVAL, and the limit might need to be adjusted based on customer feedback.
Add AMDGPU_DEBUG_DISABLE_USERPTR_SIZE_LIMIT (amdgpu.debug_mask=0x4000) as a workaround to lift the limit, and print a one time warning naming the flag when a userptr is rejected for its size so affected users can find it. A zero sized userptr is still rejected.
to disable the limit:
sudo modprobe amdgpu debug_mask=0x4000
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 7 +++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 8 +++++++- 3 files changed, 15 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
@@ -959,6 +959,7 @@ struct amdgpu_device {bool debug_enable_ce_cs;bool debug_hibernation_thaw_resume_gpu;bool debug_disable_ip_block_soft_reset; +bool debug_disable_userptr_size_limit;/* Protection for the following isolation structure */ struct mutex enforce_isolation_mutex;
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1 -0
@@ -150,6 +150,7 @@ enum AMDGPU_DEBUG_MASK {AMDGPU_DEBUG_HIBERNATION_THAW_RESUME_GPU =BIT (11 ),AMDGPU_DEBUG_DISABLE_IP_BLOCK_SOFT_RESET =BIT (12 ),AMDGPU_DEBUG_SDMA_RB_CMD =BIT (13 ), + AMDGPU_DEBUG_DISABLE_USERPTR_SIZE_LIMIT = BIT(14), }; unsigned int amdgpu_vram_limit = UINT_MAX; @@ -1092,6 +1093,7 @@ module_param_named(seamless, amdgpu_seamless, int, 0444);
* - 0x20: Enable experimental resets
* - 0x40: Disable ring resets
* - 0x80: Use VRAM for SMU pool
+ * - 0x4000: Disable the 1GiB size limit of GEM_USERPTR
*/
MODULE_PARM_DESC(debug_mask, "debug options for amdgpu, disabled by default"); module_param_named_unsafe(debug_mask, amdgpu_debug_mask, uint, 0444); @@ -2345,6 +2347,11 @@ static void amdgpu_init_debug_options(struct amdgpu_device *adev)
pr_info("debug: enable SDMA RB command switch\n");
adev->sdma.sdma_debug = true;
}+
+ if (amdgpu_debug_mask & AMDGPU_DEBUG_DISABLE_USERPTR_SIZE_LIMIT) {
+ pr_info("debug: userptr size limit disabled\n");
+ adev->debug_disable_userptr_size_limit = true;
+ }
}
static unsigned long amdgpu_fix_asic_type(struct pci_dev *pdev, unsigned long flags) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
index 348693023563..77e0e063147a 100644
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +7 -1
@@ -567,8 +567,14 @@ int amdgpu_gem_userptr_ioctl(struct drm_device *dev, void *data,return -EFAULT ;/* Userptrs are for temporary uploads, not a general memory allocator */ -if (args->size ==0 || args->size >SZ_1G ) +if (args->size ==0 )return -EINVAL ; +if (args->size >SZ_1G && !adev->debug_disable_userptr_size_limit) { +dev_warn_once (adev->dev, +"userptr size %llu exceeds 1GiB, set amdgpu.debug_mask=0x4000 to lift the limit\n" , + args->size); +return -EINVAL ; + }/* reject unknown flag values */ if (args->flags & ~(AMDGPU_GEM_USERPTR_READONLY |
--
2.34.1
Quoted 91 lines · Yifan
AMD General
This patch is
Reviewed-by Yifan Zhang <[email protected]>-----Original Message-----
From: Yuan, Perry <[email protected]>
Sent: Tuesday, November 3, 2026 3:43 PM
To: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; [email protected]
Cc: Zhang, Yifan <[email protected]>; Yuan, Perry <[email protected]>
Subject: [PATCH] drm/amdgpu: add a debug flag to disable the userptr size limitThe
GEM_USERPTRioctl now rejects userptrs above 1GiB. Existing applications that register larger ranges fail with-EINVAL, and the limit might need to be adjusted based on customer feedback.Add
AMDGPU_DEBUG_DISABLE_USERPTR_SIZE_LIMIT(amdgpu.debug_mask=0x4000) as a workaround to lift the limit, and print a one time warning naming the flag when a userptr is rejected for its size so affected users can find it. A zero sized userptr is still rejected.to disable the limit:
sudo modprobe amdgpu debug_mask=0x4000Suggested-by Christian König <[email protected]>Signed-off-by Perry Yuan <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 7 +++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 8 +++++++- 3 files changed, 15 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +1
-0@@ -959,6 +959,7 @@ struct amdgpu_device {bool debug_enable_ce_cs;bool debug_hibernation_thaw_resume_gpu;bool debug_disable_ip_block_soft_reset; +bool debug_disable_userptr_size_limit;/* Protection for the following isolation structure */ struct mutex enforce_isolation_mutex;drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1
-0@@ -150,6 +150,7 @@ enum AMDGPU_DEBUG_MASK {AMDGPU_DEBUG_HIBERNATION_THAW_RESUME_GPU =BIT (11 ),AMDGPU_DEBUG_DISABLE_IP_BLOCK_SOFT_RESET =BIT (12 ),AMDGPU_DEBUG_SDMA_RB_CMD =BIT (13 ), + AMDGPU_DEBUG_DISABLE_USERPTR_SIZE_LIMIT = BIT(14), }; unsigned int amdgpu_vram_limit = UINT_MAX; @@ -1092,6 +1093,7 @@ module_param_named(seamless, amdgpu_seamless, int, 0444);* -
0x20: Enable experimental resets
* -0x40: Disable ring resets
* -0x80: Use VRAM for SMU pool
+ * -0x4000: Disable the 1GiB size limit ofGEM_USERPTR
*/
MODULE_PARM_DESC(debug_mask, "debug options for amdgpu, disabled by default");module_param_named_unsafe(debug_mask, amdgpu_debug_mask, uint, 0444); @@ -2345,6 +2347,11 @@ static voidamdgpu_init_debug_options(struct amdgpu_device *adev)pr_info("debug: enable SDMA RB command switch\n"); adev->sdma.sdma_debug = true; }drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +5
-0+ +if (amdgpu_debug_mask &AMDGPU_DEBUG_DISABLE_USERPTR_SIZE_LIMIT ) { +pr_info ("debug: userptr size limit disabled\n" ); + adev->debug_disable_userptr_size_limit = true; + } } static unsigned long amdgpu_fix_asic_type(struct pci_dev *pdev, unsigned long flags) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.cindex 348693023563..77e0e063147a 100644
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +7
-2@@ -567,8 +567,14 @@ int amdgpu_gem_userptr_ioctl(struct drm_device *dev, void *data,return -EFAULT ;/* Userptrs are for temporary uploads, not a general memory allocator */ -if (args->size ==0 || args->size >SZ_1G ) +if (args->size ==0 )return -EINVAL ; +if (args->size >SZ_1G && !adev->debug_disable_userptr_size_limit) { +dev_warn_once (adev->dev, +"userptr size %llu exceeds 1GiB, set amdgpu.debug_mask=0x4000 to lift the limit\n" , + args->size); +return -EINVAL ; + }/* reject unknown flag values */ if (args->flags & ~(AMDGPU_GEM_USERPTR_READONLY | --2.34.1