drm/amdgpu: drop unused structures in amdgpu_drm.h
Subsystems (3)
Alex Deucher
maintainerPATCH 1/7 drm/amdgpu: drop unused structures in amdgpu_drm.h
These were never used and are duplicated with the interface that is used. Maybe leftovers from a previous revision of the patch that added them.
--- include/uapi/drm/amdgpu_drm.h | 21 --------------------- 1 file changed, 21 deletions(-)
include/uapi/drm/amdgpu_drm.h +0 -21
@@ -1564,27 +1564,6 @@ struct drm_amdgpu_info_hw_ip {__u32 userq_num_slots; }; -/* GFX metadata BO sizes and alignment info (in bytes) */ -struct drm_amdgpu_info_uq_fw_areas_gfx { -/* shadow area size */ -__u32 shadow_size; -/* shadow area base virtual mem alignment */ -__u32 shadow_alignment; -/* context save area size */ -__u32 csa_size; -/* context save area base virtual mem alignment */ -__u32 csa_alignment; -}; - -/* IP specific fw related information used in the -* subquery AMDGPU_INFO_UQ_FW_AREAS -*/ -struct drm_amdgpu_info_uq_fw_areas { -union { -struct drm_amdgpu_info_uq_fw_areas_gfx gfx; - }; -}; -struct drm_amdgpu_info_num_handles {/** Max handles as supported by firmware for UVD */ __u32 uvd_max_handles;
Signature · 1 line
2.51.0
Alex Deucher
maintainerPATCH 2/7 drm/amdgpu/userq: fix SDMA and compute validation
The CSA and EOP buffers have different alignement requirements. Hardcode them for now as a bug fix. A proper query will be added in a subsequent patch.
--- drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +9 -5
@@ -254,7 +254,6 @@ static int mes_userq_mqd_create(struct amdgpu_userq_mgr *uq_mgr,struct amdgpu_mqd *mqd_hw_default = &adev->mqds[queue->queue_type];struct drm_amdgpu_userq_in *mqd_user = args_in;struct amdgpu_mqd_prop *userq_props; -struct amdgpu_gfx_shadow_info shadow_info;int r;/* Structure to initialize MQD for userqueue using generic MQD init function */
@@ -280,8 +279,6 @@ static int mes_userq_mqd_create(struct amdgpu_userq_mgr *uq_mgr, userq_props->doorbell_index = queue->doorbell_index; userq_props->fence_address = queue->fence_drv->gpu_addr; -if (adev->gfx.funcs->get_gfx_shadow_info) - adev->gfx.funcs->get_gfx_shadow_info (adev, &shadow_info, true);if (queue->queue_type ==AMDGPU_HW_IP_COMPUTE ) {struct drm_amdgpu_userq_mqd_compute_gfx11 *compute_mqd;
@@ -299,7 +296,7 @@ static int mes_userq_mqd_create(struct amdgpu_userq_mgr *uq_mgr, } r =amdgpu_userq_input_va_validate (queue, compute_mqd->eop_va, -max_t (u32,PAGE_SIZE ,AMDGPU_GPU_PAGE_SIZE )); +2048 );if (r) goto free_mqd;
@@ -312,6 +309,9 @@ static int mes_userq_mqd_create(struct amdgpu_userq_mgr *uq_mgr,kfree (compute_mqd); }else if (queue->queue_type ==AMDGPU_HW_IP_GFX ) {struct drm_amdgpu_userq_mqd_gfx11 *mqd_gfx_v11; +struct amdgpu_gfx_shadow_info shadow_info; + + adev->gfx.funcs->get_gfx_shadow_info (adev, &shadow_info, true);if (mqd_user->mqd_size !=sizeof (*mqd_gfx_v11) || !mqd_user->mqd) {DRM_ERROR ("Invalid GFX MQD\n" );
@@ -335,6 +335,10 @@ static int mes_userq_mqd_create(struct amdgpu_userq_mgr *uq_mgr, shadow_info.shadow_size);if (r) goto free_mqd; + r =amdgpu_userq_input_va_validate (queue, mqd_gfx_v11->csa_va, + shadow_info.csa_size); +if (r) + goto free_mqd;kfree (mqd_gfx_v11); }else if (queue->queue_type ==AMDGPU_HW_IP_DMA ) {
@@ -353,7 +357,7 @@ static int mes_userq_mqd_create(struct amdgpu_userq_mgr *uq_mgr, goto free_mqd; } r =amdgpu_userq_input_va_validate (queue, mqd_sdma_v11->csa_va, - shadow_info.csa_size); +32 );if (r) goto free_mqd;
Signature · 1 line
2.51.0
RE: [PATCH 2/7] drm/amdgpu/userq: fix SDMA and compute validation
[Public]
Regards,
Prike
Quoted 43 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Saturday, October 11, 2025 5:15 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: [PATCH 2/7] drm/amdgpu/userq: fix SDMA and compute validationThe CSA and EOP buffers have different alignement requirements. Hardcode them for now as a bug fix. A proper query will be added in a subsequent patch.
Fixes 9e46b8bb0539 ("drm/amdgpu: validate userq buffer virtual address and size")Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +0
-1@@ -254,7 +254,6 @@ static int mes_userq_mqd_create(structamdgpu_userq_mgr *uq_mgr, struct amdgpu_mqd *mqd_hw_default = &adev->mqds[queue->queue_type];struct drm_amdgpu_userq_in *mqd_user = args_in;struct amdgpu_mqd_prop *userq_props; -struct amdgpu_gfx_shadow_info shadow_info;int r;/* Structure to initialize MQD for userqueue using generic MQD init function */drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +0
-2@@ -280,8 +279,6 @@ static int mes_userq_mqd_create(struct amdgpu_userq_mgr *uq_mgr, userq_props->doorbell_index = queue->doorbell_index; userq_props->fence_address = queue->fence_drv->gpu_addr; -if (adev->gfx.funcs->get_gfx_shadow_info) - adev->gfx.funcs->get_gfx_shadow_info (adev, &shadow_info, true);if (queue->queue_type ==AMDGPU_HW_IP_COMPUTE ) {struct drm_amdgpu_userq_mqd_compute_gfx11 *compute_mqd;
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c static int mes_userq_mqd_create(struct · line 301
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +1
-1@@ -299,7 +296,7 @@ static int mes_userq_mqd_create(structamdgpu_userq_mgr *uq_mgr, } r =amdgpu_userq_input_va_validate (queue, compute_mqd->eop_va, -max_t (u32,PAGE_SIZE , AMDGPU_GPU_PAGE_SIZE)); + 2048);
[Prike] How did this issue occur? If we hardcode the value here, will userspace driver EOP buffer requests still be compatible? We may need to add a TODO comment to replace this with proper EOP-size queries in a future change.
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c static int mes_userq_mqd_create(struct · line 315
Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +0
-0if (r)goto free_mqd;drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +3
-0@@ -312,6 +309,9 @@ static int mes_userq_mqd_create(structamdgpu_userq_mgr *uq_mgr,kfree (compute_mqd ); }else if (queue->queue_type ==AMDGPU_HW_IP_GFX ) {struct drm_amdgpu_userq_mqd_gfx11 *mqd_gfx_v11; +struct amdgpu_gfx_shadow_info shadow_info; + + adev->gfx.funcs->get_gfx_shadow_info (adev, &shadow_info, true);
[Prike] We may need to validate the get_gfx_shadow_info() callback before using it.
Quoted 27 lines
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +0
-0if (mqd_user->mqd_size !=sizeof (*mqd_gfx_v11) || !mqd_user->mqd) {DRM_ERROR("Invalid GFX MQD\n");drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +4
-0@@ -335,6 +335,10 @@ static int mes_userq_mqd_create(struct amdgpu_userq_mgr *uq_mgr, shadow_info.shadow_size);if (r) goto free_mqd; + r =amdgpu_userq_input_va_validate (queue, mqd_gfx_v11->csa_va, + shadow_info.csa_size); +if (r) + goto free_mqd;kfree (mqd_gfx_v11);} else if (queue->queue_type == AMDGPU_HW_IP_DMA) { @@ -353,7 +357,7 @@ static int mes_userq_mqd_create(struct amdgpu_userq_mgr *uq_mgr, goto free_mqd; } r = amdgpu_userq_input_va_validate(queue, mqd_sdma_v11-Quoted 1 line
csa_va,drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +1
-2- shadow_info.csa_size); + 32);if (r) goto free_mqd; --2.51.0
Re: [PATCH 2/7] drm/amdgpu/userq: fix SDMA and compute validation
Quoted 52 lines · Prike
[Public]
Regards,
PrikeQuoted 46 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Saturday, October 11, 2025 5:15 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: [PATCH 2/7] drm/amdgpu/userq: fix SDMA and compute validationThe CSA and EOP buffers have different alignement requirements. Hardcode them for now as a bug fix. A proper query will be added in a subsequent patch.
Fixes 9e46b8bb0539 ("drm/amdgpu: validate userq buffer virtual address and size")Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +0
-1@@ -254,7 +254,6 @@ static int mes_userq_mqd_create(structamdgpu_userq_mgr *uq_mgr, struct amdgpu_mqd *mqd_hw_default = &adev->mqds[queue->queue_type];struct drm_amdgpu_userq_in *mqd_user = args_in;struct amdgpu_mqd_prop *userq_props; -struct amdgpu_gfx_shadow_info shadow_info;int r;/* Structure to initialize MQD for userqueue using generic MQD init function */drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +0
-2@@ -280,8 +279,6 @@ static int mes_userq_mqd_create(struct amdgpu_userq_mgr *uq_mgr, userq_props->doorbell_index = queue->doorbell_index; userq_props->fence_address = queue->fence_drv->gpu_addr; -if (adev->gfx.funcs->get_gfx_shadow_info) - adev->gfx.funcs->get_gfx_shadow_info (adev, &shadow_info, true);if (queue->queue_type ==AMDGPU_HW_IP_COMPUTE ) {struct drm_amdgpu_userq_mqd_compute_gfx11 *compute_mqd;@@ -299,7 +296,7 @@ static int mes_userq_mqd_create(struct amdgpu_userq_mgr *uq_mgr, }
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c static int mes_userq_mqd_create(struct amdgpu_userq_mgr *uq_mgr, · line 299
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +1
-1r =amdgpu_userq_input_va_validate (queue, compute_mqd->eop_va, -max_t (u32,PAGE_SIZE , AMDGPU_GPU_PAGE_SIZE)); + 2048);[Prike] How did this issue occur? If we hardcode the value here, will userspace driver EOP buffer requests still be compatible? We may need to add a TODO comment to replace this with proper EOP-size queries in a future change.
It's just temporary to make the patch easier to backport. It's fixed properly later in this series.
Quoted 4 lines
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +0
-0if (r)goto free_mqd;
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c static int mes_userq_mqd_create(struct · line 315
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +3
-0@@ -312,6 +309,9 @@ static int mes_userq_mqd_create(structamdgpu_userq_mgr *uq_mgr,kfree (compute_mqd ); }else if (queue->queue_type ==AMDGPU_HW_IP_GFX ) {struct drm_amdgpu_userq_mqd_gfx11 *mqd_gfx_v11; +struct amdgpu_gfx_shadow_info shadow_info; + + adev->gfx.funcs->get_gfx_shadow_info (adev, &shadow_info, true);[Prike] We may need to validate the
get_gfx_shadow_info()callback before using it.
It should always be implemented for user queues. If it's not, we don't have a way to know what the user queue metadata sizes are.
Alex
Quoted 29 lines
Quoted 28 lines
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +0
-0if (mqd_user->mqd_size !=sizeof (*mqd_gfx_v11) || !mqd_user->mqd) {DRM_ERROR("Invalid GFX MQD\n");drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +4
-0@@ -335,6 +335,10 @@ static int mes_userq_mqd_create(struct amdgpu_userq_mgr *uq_mgr, shadow_info.shadow_size);if (r) goto free_mqd; + r =amdgpu_userq_input_va_validate (queue, mqd_gfx_v11->csa_va, + shadow_info.csa_size); +if (r) + goto free_mqd;kfree (mqd_gfx_v11);} else if (queue->queue_type == AMDGPU_HW_IP_DMA) { @@ -353,7 +357,7 @@ static int mes_userq_mqd_create(struct amdgpu_userq_mgr *uq_mgr, goto free_mqd; } r = amdgpu_userq_input_va_validate(queue, mqd_sdma_v11-Quoted 1 line
csa_va,drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +1
-2- shadow_info.csa_size); + 32);if (r) goto free_mqd; --2.51.0
RE: [PATCH 2/7] drm/amdgpu/userq: fix SDMA and compute validation
[Public]
Regards,
Prike
Quoted 90 lines
-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Monday, October 13, 2025 9:43 PM
To: Liang, Prike <[email protected]>
Cc: Deucher, Alexander <[email protected]>; amd- [email protected]
Subject: Re: [PATCH 2/7] drm/amdgpu/userq: fix SDMA and compute validationQuoted 55 lines · Prike
[Public]
Regards,
PrikeQuoted 49 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Saturday, October 11, 2025 5:15 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: [PATCH 2/7] drm/amdgpu/userq: fix SDMA and compute validationThe CSA and EOP buffers have different alignement requirements. Hardcode them for now as a bug fix. A proper query will be added in a subsequent patch.
Fixes 9e46b8bb0539 ("drm/amdgpu: validate userq buffer virtualaddress and size")
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +0
-1@@ -254,7 +254,6 @@ static int mes_userq_mqd_create(structamdgpu_userq_mgr *uq_mgr, struct amdgpu_mqd *mqd_hw_default = &adev->mqds[queue->queue_type];struct drm_amdgpu_userq_in *mqd_user = args_in;struct amdgpu_mqd_prop *userq_props; -struct amdgpu_gfx_shadow_info shadow_info;int r;/* Structure to initialize MQD for userqueue using generic MQD init function */ @@ -280,8 +279,6 @@ static int mes_userq_mqd_create(struct amdgpu_userq_mgr *uq_mgr, userq_props->doorbell_index = queue->doorbell_index; userq_props->fence_address = queue->fence_drv->gpu_addr;drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +0
-2-if (adev->gfx.funcs->get_gfx_shadow_info) - adev->gfx.funcs->get_gfx_shadow_info (adev, &shadow_info, true);if (queue->queue_type ==AMDGPU_HW_IP_COMPUTE ) {struct drm_amdgpu_userq_mqd_compute_gfx11
*compute_mqd;drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +0
-0@@ -299,7 +296,7 @@ static int mes_userq_mqd_create(struct amdgpu_userq_mgr *uq_mgr, }Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c static int mes_userq_mqd_create(struct amdgpu_userq_mgr *uq_mgr, · line 299
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +1
-1r =amdgpu_userq_input_va_validate (queue, compute_mqd->eop_va, -max_t (u32,PAGE_SIZE , AMDGPU_GPU_PAGE_SIZE)); + 2048);[Prike] How did this issue occur? If we hardcode the value here, will userspace
driver EOP buffer requests still be compatible?
Quoted 1 line
We may need to add a TODO comment to replace this with proper EOP-size
queries in a future change.
It's just temporary to make the patch easier to backport. It's fixed properly later in this series.
Quoted 4 lines
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +0
-0if (r)goto free_mqd;Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c static int mes_userq_mqd_create(struct · line 316
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +4
-0@@ -312,6 +309,9 @@ static int mes_userq_mqd_create(structamdgpu_userq_mgr *uq_mgr,kfree (compute_mqd ); }else if (queue->queue_type ==AMDGPU_HW_IP_GFX ) {struct drm_amdgpu_userq_mqd_gfx11 *mqd_gfx_v11; +struct amdgpu_gfx_shadow_info shadow_info; + + adev->gfx.funcs->get_gfx_shadow_info (adev, + &shadow_info, true);[Prike] We may need to validate the
get_gfx_shadow_info()callback before using
Quoted 4 lines
it.
It should always be implemented for user queues. If it's not, we don't have a way to know what the user queue metadata sizes are.
Yes, there's no issue for the most common case. But for the NPI early phase the callback may miss implementing anyhow, that will result in a null pointer issue.
Quoted 33 lines
Alex
Quoted 31 lines
Quoted 30 lines
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +0
-0if (mqd_user->mqd_size != sizeof(*mqd_gfx_v11) ||!mqd_user->mqd) { DRM_ERROR("Invalid GFX MQD\n"); @@ -335,6 +335,10 @@ static int mes_userq_mqd_create(struct amdgpu_userq_mgr *uq_mgr, shadow_info.shadow_size); if (r) goto free_mqd;drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +6
-0+ r =amdgpu_userq_input_va_validate (queue, mqd_gfx_v11->csa_va, + shadow_info.csa_size); +if (r) + goto free_mqd;kfree (mqd_gfx_v11); } else if (queue->queue_type == AMDGPU_HW_IP_DMA) { @@ -353,7 +357,7 @@ static int mes_userq_mqd_create(struct amdgpu_userq_mgr +*uq_mgr, goto free_mqd; } r = amdgpu_userq_input_va_validate(queue,mqd_sdma_v11-
Quoted 1 line
csa_va,drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +1
-2- shadow_info.csa_size); + 32);if (r) goto free_mqd; --2.51.0
Alex Deucher
maintainerPATCH 3/7 drm/amdgpu/gfx: add eop size and alignment to shadow info
In reply to Alex DeucherThis is used by firmware for compute user queues.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 2 ++ drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 4 ++++ 3 files changed, 10 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +2 -0
@@ -328,6 +328,8 @@ struct amdgpu_gfx_shadow_info {u32 shadow_alignment;u32 csa_size;u32 csa_alignment; +u32 eop_size; +u32 eop_alignment; };struct amdgpu_gfx_funcs {
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +4 -0
@@ -1052,10 +1052,14 @@ static void gfx_v11_0_select_me_pipe_q(struct amdgpu_device *adev,static void gfx_v11_0_get_gfx_shadow_info_nocheck (struct amdgpu_device *adev,struct amdgpu_gfx_shadow_info *shadow_info) { +/* for gfx */ shadow_info->shadow_size =MQD_SHADOW_BASE_SIZE ; shadow_info->shadow_alignment =MQD_SHADOW_BASE_ALIGNMENT ; shadow_info->csa_size =MQD_FWWORKAREA_SIZE ; shadow_info->csa_alignment =MQD_FWWORKAREA_ALIGNMENT ; +/* for compute */ + shadow_info->eop_size =GFX11_MEC_HPD_SIZE ; + shadow_info->eop_alignment =256 ; } static int gfx_v11_0_get_gfx_shadow_info(struct amdgpu_device *adev,
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +4 -0
@@ -909,10 +909,14 @@ static void gfx_v12_0_select_me_pipe_q(struct amdgpu_device *adev,static void gfx_v12_0_get_gfx_shadow_info_nocheck (struct amdgpu_device *adev,struct amdgpu_gfx_shadow_info *shadow_info) { +/* for gfx */ shadow_info->shadow_size =MQD_SHADOW_BASE_SIZE ; shadow_info->shadow_alignment =MQD_SHADOW_BASE_ALIGNMENT ; shadow_info->csa_size =MQD_FWWORKAREA_SIZE ; shadow_info->csa_alignment =MQD_FWWORKAREA_ALIGNMENT ; +/* for compute */ + shadow_info->eop_size =GFX12_MEC_HPD_SIZE ; + shadow_info->eop_alignment =256 ; } static int gfx_v12_0_get_gfx_shadow_info(struct amdgpu_device *adev,
Signature · 1 line
2.51.0
RE: [PATCH 3/7] drm/amdgpu/gfx: add eop size and alignment to shadow info
[Public]
We may need to update the userspace EOP buffer request; otherwise, the EOP buffer validation may fail. Per this kernel change: Reviewed-by: Prike Liang <[email protected]>
Regards,
Prike
Quoted 75 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Saturday, October 11, 2025 5:15 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: [PATCH 3/7] drm/amdgpu/gfx: add eop size and alignment to shadow infoThis is used by firmware for compute user queues.
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 2 ++ drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 4 ++++ 3 files changed, 10 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +2
-0@@ -328,6 +328,8 @@ struct amdgpu_gfx_shadow_info {u32 shadow_alignment;u32 csa_size;u32 csa_alignment; +u32 eop_size; +u32 eop_alignment; };struct amdgpu_gfx_funcs {drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +0
-0@@ -1052,10 +1052,14 @@ static void gfx_v11_0_select_me_pipe_q(struct
amdgpu_device*adev, static void gfx_v11_0_get_gfx_shadow_info_nocheck(structamdgpu_device*adev,
structamdgpu_gfx_shadow_info*shadow_info) {drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +4
-0+/* for gfx */ shadow_info->shadow_size =MQD_SHADOW_BASE_SIZE ; shadow_info->shadow_alignment =MQD_SHADOW_BASE_ALIGNMENT ; shadow_info->csa_size =MQD_FWWORKAREA_SIZE ; shadow_info->csa_alignment =MQD_FWWORKAREA_ALIGNMENT ; +/* for compute */ + shadow_info->eop_size =GFX11_MEC_HPD_SIZE ; + shadow_info->eop_alignment =256 ; } static int gfx_v11_0_get_gfx_shadow_info(struct amdgpu_device *adev, diff --git
a/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.cb/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c
index453e4034389f2..fd37f2355f86e100644drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +0
-0@@ -909,10 +909,14 @@ static void gfx_v12_0_select_me_pipe_q(struct
amdgpu_device*adev, static void gfx_v12_0_get_gfx_shadow_info_nocheck(structamdgpu_device*adev,
structamdgpu_gfx_shadow_info*shadow_info) {drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +4
-1+/* for gfx */ shadow_info->shadow_size =MQD_SHADOW_BASE_SIZE ; shadow_info->shadow_alignment =MQD_SHADOW_BASE_ALIGNMENT ; shadow_info->csa_size =MQD_FWWORKAREA_SIZE ; shadow_info->csa_alignment =MQD_FWWORKAREA_ALIGNMENT ; +/* for compute */ + shadow_info->eop_size =GFX12_MEC_HPD_SIZE ; + shadow_info->eop_alignment =256 ; } static int gfx_v12_0_get_gfx_shadow_info(struct amdgpu_device *adev, --2.51.0
Re: [PATCH 3/7] drm/amdgpu/gfx: add eop size and alignment to shadow info
Quoted 4 lines · Prike
[Public]
We may need to update the userspace EOP buffer request; otherwise, the EOP buffer validation may fail.
Existing userspace should be ok. It currently uses PAGE_SIZE which is larger than 2048.
Quoted 1 line
Per this kernel change: Reviewed-by: Prike Liang <[email protected]>
Thanks!
Alex
Quoted 80 lines
Regards,
PrikeQuoted 75 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Saturday, October 11, 2025 5:15 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: [PATCH 3/7] drm/amdgpu/gfx: add eop size and alignment to shadow infoThis is used by firmware for compute user queues.
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 2 ++ drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 4 ++++ 3 files changed, 10 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +2
-0@@ -328,6 +328,8 @@ struct amdgpu_gfx_shadow_info {u32 shadow_alignment;u32 csa_size;u32 csa_alignment; +u32 eop_size; +u32 eop_alignment; };struct amdgpu_gfx_funcs {drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +0
-0@@ -1052,10 +1052,14 @@ static void gfx_v11_0_select_me_pipe_q(struct
amdgpu_device*adev, static void gfx_v11_0_get_gfx_shadow_info_nocheck(structamdgpu_device*adev,
structamdgpu_gfx_shadow_info*shadow_info) {drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +4
-0+/* for gfx */ shadow_info->shadow_size =MQD_SHADOW_BASE_SIZE ; shadow_info->shadow_alignment =MQD_SHADOW_BASE_ALIGNMENT ; shadow_info->csa_size =MQD_FWWORKAREA_SIZE ; shadow_info->csa_alignment =MQD_FWWORKAREA_ALIGNMENT ; +/* for compute */ + shadow_info->eop_size =GFX11_MEC_HPD_SIZE ; + shadow_info->eop_alignment =256 ; } static int gfx_v11_0_get_gfx_shadow_info(struct amdgpu_device *adev, diff --git
a/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.cb/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c
index453e4034389f2..fd37f2355f86e100644drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +0
-0@@ -909,10 +909,14 @@ static void gfx_v12_0_select_me_pipe_q(struct
amdgpu_device*adev, static void gfx_v12_0_get_gfx_shadow_info_nocheck(structamdgpu_device*adev,
structamdgpu_gfx_shadow_info*shadow_info) {drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +4
-1+/* for gfx */ shadow_info->shadow_size =MQD_SHADOW_BASE_SIZE ; shadow_info->shadow_alignment =MQD_SHADOW_BASE_ALIGNMENT ; shadow_info->csa_size =MQD_FWWORKAREA_SIZE ; shadow_info->csa_alignment =MQD_FWWORKAREA_ALIGNMENT ; +/* for compute */ + shadow_info->eop_size =GFX12_MEC_HPD_SIZE ; + shadow_info->eop_alignment =256 ; } static int gfx_v12_0_get_gfx_shadow_info(struct amdgpu_device *adev, --2.51.0
RE: [PATCH 3/7] drm/amdgpu/gfx: add eop size and alignment to shadow info
[Public]
Regards,
Prike
Quoted 11 lines
-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Monday, October 13, 2025 9:44 PM
To: Liang, Prike <[email protected]>
Cc: Deucher, Alexander <[email protected]>; amd- [email protected]
Subject: Re: [PATCH 3/7] drm/amdgpu/gfx: add eop size and alignment to shadow infoQuoted 1 line · Prike
Quoted 7 lines
Quoted 3 lines
[Public]
We may need to update the userspace EOP buffer request; otherwise, the EOP
buffer validation may fail.
Existing userspace should be ok. It currently uses
PAGE_SIZEwhich is larger than 2048.
The mesa uses the EOP size as max_t(u32, PAGE_SIZE, AMDGPU_GPU_PAGE_SIZE) which is sees larger than 2048, so the kernel validates the eop buffer can be successful at this point.
But the mesa may need to use the shadow_info->eop_size as well in the future?
Quoted 91 lines
Quoted 1 line
Per this kernel change: Reviewed-by: Prike Liang <[email protected]>
Thanks!
Alex
Quoted 85 lines
Regards,
PrikeQuoted 80 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Saturday, October 11, 2025 5:15 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: [PATCH 3/7] drm/amdgpu/gfx: add eop size and alignment to shadow infoThis is used by firmware for compute user queues.
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 2 ++ drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 4 ++++ 3 files changed, 10 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +2
-0@@ -328,6 +328,8 @@ struct amdgpu_gfx_shadow_info {u32 shadow_alignment;u32 csa_size;u32 csa_alignment; +u32 eop_size; +u32 eop_alignment; };struct amdgpu_gfx_funcs {drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +0
-0@@ -1052,10 +1052,14 @@ static voidgfx_v11_0_select_me_pipe_q(struct
amdgpu_device*adev, static void gfx_v11_0_get_gfx_shadow_info_nocheck(structamdgpu_device*adev,
structamdgpu_gfx_shadow_info*shadow_info) {drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +4
-0+/* for gfx */ shadow_info->shadow_size =MQD_SHADOW_BASE_SIZE ; shadow_info->shadow_alignment =MQD_SHADOW_BASE_ALIGNMENT ; shadow_info->csa_size =MQD_FWWORKAREA_SIZE ; shadow_info->csa_alignment =MQD_FWWORKAREA_ALIGNMENT ; +/* for compute */ + shadow_info->eop_size =GFX11_MEC_HPD_SIZE ; + shadow_info->eop_alignment =256 ; } static int gfx_v11_0_get_gfx_shadow_info(struct amdgpu_device*adev, diff --git
a/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.cb/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c
index453e4034389f2..fd37f2355f86e100644drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +0
-0@@ -909,10 +909,14 @@ static void gfx_v12_0_select_me_pipe_q(struct
amdgpu_device*adev, static void gfx_v12_0_get_gfx_shadow_info_nocheck(structamdgpu_device*adev,
structamdgpu_gfx_shadow_info*shadow_info) {drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +4
-0+/* for gfx */ shadow_info->shadow_size =MQD_SHADOW_BASE_SIZE ; shadow_info->shadow_alignment =MQD_SHADOW_BASE_ALIGNMENT ; shadow_info->csa_size =MQD_FWWORKAREA_SIZE ; shadow_info->csa_alignment =MQD_FWWORKAREA_ALIGNMENT ; +/* for compute */ + shadow_info->eop_size =GFX12_MEC_HPD_SIZE ; + shadow_info->eop_alignment =256 ; } static int gfx_v12_0_get_gfx_shadow_info(struct amdgpu_device*adev,
--
2.51.0
Re: [PATCH 3/7] drm/amdgpu/gfx: add eop size and alignment to shadow info
Quoted 19 lines · Prike
[Public]
Regards,
PrikeQuoted 13 lines
-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Monday, October 13, 2025 9:44 PM
To: Liang, Prike <[email protected]>
Cc: Deucher, Alexander <[email protected]>; amd- [email protected]
Subject: Re: [PATCH 3/7] drm/amdgpu/gfx: add eop size and alignment to shadow infoQuoted 3 lines · Prike
[Public]
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
We may need to update the userspace EOP buffer request; otherwise, the EOP
buffer validation may fail.
Existing userspace should be ok. It currently uses
PAGE_SIZEwhich is larger than 2048.The mesa uses the EOP size as
max_t(u32, PAGE_SIZE, AMDGPU_GPU_PAGE_SIZE)which is sees larger than 2048, so the kernel validates the eop buffer can be successful at this point.But the mesa may need to use the
shadow_info->eop_sizeas well in the future?
Ideally mesa would query the kernel to get the proper minimum size. Yogesh will be looking at this.
Alex
Quoted 92 lines
Quoted 92 lines
Quoted 2 lines
Per this kernel change: Reviewed-by: Prike Liang <[email protected]>
Thanks!
Alex
Quoted 85 lines
Regards,
PrikeQuoted 80 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Saturday, October 11, 2025 5:15 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: [PATCH 3/7] drm/amdgpu/gfx: add eop size and alignment to shadow infoThis is used by firmware for compute user queues.
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 2 ++ drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 4 ++++ 3 files changed, 10 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +2
-0@@ -328,6 +328,8 @@ struct amdgpu_gfx_shadow_info {u32 shadow_alignment;u32 csa_size;u32 csa_alignment; +u32 eop_size; +u32 eop_alignment; };struct amdgpu_gfx_funcs {drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +0
-0@@ -1052,10 +1052,14 @@ static voidgfx_v11_0_select_me_pipe_q(struct
amdgpu_device*adev, static void gfx_v11_0_get_gfx_shadow_info_nocheck(structamdgpu_device*adev,
structamdgpu_gfx_shadow_info*shadow_info) {drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +4
-0+/* for gfx */ shadow_info->shadow_size =MQD_SHADOW_BASE_SIZE ; shadow_info->shadow_alignment =MQD_SHADOW_BASE_ALIGNMENT ; shadow_info->csa_size =MQD_FWWORKAREA_SIZE ; shadow_info->csa_alignment =MQD_FWWORKAREA_ALIGNMENT ; +/* for compute */ + shadow_info->eop_size =GFX11_MEC_HPD_SIZE ; + shadow_info->eop_alignment =256 ; } static int gfx_v11_0_get_gfx_shadow_info(struct amdgpu_device*adev, diff --git
a/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.cb/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c
index453e4034389f2..fd37f2355f86e100644drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +0
-0@@ -909,10 +909,14 @@ static void gfx_v12_0_select_me_pipe_q(struct
amdgpu_device*adev, static void gfx_v12_0_get_gfx_shadow_info_nocheck(structamdgpu_device*adev,
structamdgpu_gfx_shadow_info*shadow_info) {drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +4
-0+/* for gfx */ shadow_info->shadow_size =MQD_SHADOW_BASE_SIZE ; shadow_info->shadow_alignment =MQD_SHADOW_BASE_ALIGNMENT ; shadow_info->csa_size =MQD_FWWORKAREA_SIZE ; shadow_info->csa_alignment =MQD_FWWORKAREA_ALIGNMENT ; +/* for compute */ + shadow_info->eop_size =GFX12_MEC_HPD_SIZE ; + shadow_info->eop_alignment =256 ; } static int gfx_v12_0_get_gfx_shadow_info(struct amdgpu_device*adev,
--
2.51.0
Re: [PATCH 3/7] drm/amdgpu/gfx: add eop size and alignment to shadow info
Quoted 33 lines · Alex Deucher
Quoted 13 lines · Prike
[Public]
Regards,
PrikeQuoted 7 lines
-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Monday, October 13, 2025 9:44 PM
To: Liang, Prike <[email protected]>
Cc: Deucher, Alexander <[email protected]>; amd- [email protected]
Subject: Re: [PATCH 3/7] drm/amdgpu/gfx: add eop size and alignment toshadow
Quoted 3 lines
Quoted 3 lines
info
On Mon, Oct 13, 2025 at 4:54 AM Liang, Prike <[email protected]>
Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 4 lines
[Public]
We may need to update the userspace EOP buffer request; otherwise,
the EOP
Quoted 3 lines
Quoted 3 lines
buffer validation may fail.
Existing userspace should be ok. It currently uses
PAGE_SIZEwhich islarger than
Quoted 2 lines
Quoted 1 line
2048.
The mesa uses the EOP size as max_t(u32,
PAGE_SIZE,
AMDGPU_GPU_PAGE_SIZE) which is sees larger than 2048, so the kernel validates the eop buffer can be successful at this point.Quoted 1 line
Quoted 8 lines
Quoted 1 line
But the mesa may need to use the
shadow_info->eop_sizeas well in thefuture?
Ideally mesa would query the kernel to get the proper minimum size. Yogesh will be looking at this.
Alex
Does the EOP buffer store privileged information? What is its content?
Marek
Re: [PATCH 3/7] drm/amdgpu/gfx: add eop size and alignment to shadow info
Quoted 32 lines · Marek Olšák
Quoted 30 lines · Alex Deucher
Quoted 27 lines · Prike
[Public]
Regards,
PrikeQuoted 11 lines
-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Monday, October 13, 2025 9:44 PM
To: Liang, Prike <[email protected]>
Cc: Deucher, Alexander <[email protected]>; amd- [email protected]
Subject: Re: [PATCH 3/7] drm/amdgpu/gfx: add eop size and alignment to shadow infoQuoted 1 line · Prike
Quoted 7 lines
Quoted 3 lines
[Public]
We may need to update the userspace EOP buffer request; otherwise, the EOP
buffer validation may fail.
Existing userspace should be ok. It currently uses
PAGE_SIZEwhich is larger than 2048.The mesa uses the EOP size as
max_t(u32, PAGE_SIZE, AMDGPU_GPU_PAGE_SIZE)which is sees larger than 2048, so the kernel validates the eop buffer can be successful at this point.But the mesa may need to use the
shadow_info->eop_sizeas well in the future?
Quoted 7 lines
Quoted 4 lines
Ideally mesa would query the kernel to get the proper minimum size. Yogesh will be looking at this.
Alex
Does the EOP buffer store privileged information? What is its content?
It stores end of pipe events for the compute queue generated from things like RELEASE_MEM or AQL packets. They are specific to each user queue. In theory corrupting or messing with the data in the buffer should only affect that queue.
Alex
Alex
Re: [PATCH 3/7] drm/amdgpu/gfx: add eop size and alignment to shadow info
Quoted 48 lines · Alex Deucher
Quoted 2 lines · Marek Olšák
On Mon, Oct 13, 2025 at 3:11 PM Alex Deucher <[email protected]>
Quoted 2 lines · wrote:
Quoted 2 lines
On Mon, Oct 13, 2025 at 10:21 AM Liang, Prike <[email protected]>
Quoted 6 lines · wrote:
Quoted 6 lines
Quoted 6 lines
[Public]
Regards,
PrikeQuoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Monday, October 13, 2025 9:44 PM
To: Liang, Prike <[email protected]>
Cc: Deucher, Alexander <[email protected]>; amd- [email protected]
Subject: Re: [PATCH 3/7] drm/amdgpu/gfx: add eop size and alignmentto shadow
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
info
On Mon, Oct 13, 2025 at 4:54 AM Liang, Prike <[email protected]>
Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
[Public]
We may need to update the userspace EOP buffer request;
otherwise, the EOP
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
buffer validation may fail.
Existing userspace should be ok. It currently uses
PAGE_SIZEwhichis larger than
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
2048.
The mesa uses the EOP size as max_t(u32,
PAGE_SIZE,
AMDGPU_GPU_PAGE_SIZE) which is sees larger than 2048, so the kernel validates the eop buffer can be successful at this point.Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
But the mesa may need to use the
shadow_info->eop_sizeas well in thefuture?
Quoted 7 lines
Quoted 5 lines
Ideally mesa would query the kernel to get the proper minimum size. Yogesh will be looking at this.
Alex
Quoted 7 lines
Quoted 1 line
Does the EOP buffer store privileged information? What is its content?
It stores end of pipe events for the compute queue generated from things like
RELEASE_MEMor AQL packets. They are specific to each user queue. In theory corrupting or messing with the data in the buffer should only affect that queue.
RELEASE_MEM has a hidden implicit VMID parameter. That's why it's important to know whether it's stored in the EOP buffer that can be overwritten by userspace.
Marek
Re: [PATCH 3/7] drm/amdgpu/gfx: add eop size and alignment to shadow info
Quoted 44 lines · Marek Olšák
Quoted 42 lines · Alex Deucher
Quoted 39 lines · Marek Olšák
Quoted 26 lines · Alex Deucher
Quoted 24 lines · Prike
[Public]
Regards,
PrikeQuoted 18 lines
-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Monday, October 13, 2025 9:44 PM
To: Liang, Prike <[email protected]>
Cc: Deucher, Alexander <[email protected]>; amd- [email protected]
Subject: Re: [PATCH 3/7] drm/amdgpu/gfx: add eop size and alignment to shadow infoQuoted 4 lines · Prike
[Public]
We may need to update the userspace EOP buffer request; otherwise, the EOP
buffer validation may fail.
Existing userspace should be ok. It currently uses
PAGE_SIZEwhich is larger than 2048.Quoted 8 lines
Quoted 3 lines
The mesa uses the EOP size as
max_t(u32, PAGE_SIZE, AMDGPU_GPU_PAGE_SIZE)which is sees larger than 2048, so the kernel validates the eop buffer can be successful at this point.But the mesa may need to use the
shadow_info->eop_sizeas well in the future?Ideally mesa would query the kernel to get the proper minimum size. Yogesh will be looking at this.
Alex
Does the EOP buffer store privileged information? What is its content?
Quoted 7 lines
Quoted 4 lines
It stores end of pipe events for the compute queue generated from things like
RELEASE_MEMor AQL packets. They are specific to each user queue. In theory corrupting or messing with the data in the buffer should only affect that queue.
RELEASE_MEMhas a hidden implicit VMID parameter. That's why it's important to know whether it's stored in the EOP buffer that can be overwritten by userspace.
My understanding is that that is only relevant for kernel queues where the vmid comes from the IB for each job. For user queues, the vmid is determined by the HQD so that is unused in the user queue case.
Alex
Re: [PATCH 3/7] drm/amdgpu/gfx: add eop size and alignment to shadow info
Quoted 61 lines · On Tue, Oct 14, 2025, 12:37 Alex Deucher <[email protected]> wrote:
Quoted 2 lines · Marek Olšák
On Tue, Oct 14, 2025 at 10:12 AM Alex Deucher <[email protected]>
Quoted 4 lines · wrote:
Quoted 4 lines · Marek Olšák
Quoted 2 lines
On Mon, Oct 13, 2025 at 3:11 PM Alex Deucher <[email protected]>
Quoted 2 lines · wrote:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
On Mon, Oct 13, 2025 at 10:21 AM Liang, Prike <[email protected]>
Quoted 6 lines · wrote:
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
[Public]
Regards,
PrikeQuoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Monday, October 13, 2025 9:44 PM
To: Liang, Prike <[email protected]>
Cc: Deucher, Alexander <[email protected]>; amd- [email protected]
Subject: Re: [PATCH 3/7] drm/amdgpu/gfx: add eop size andalignment to shadow
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
info
On Mon, Oct 13, 2025 at 4:54 AM Liang, Prike <
Quoted 4 lines · [email protected]> wrote:
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
[Public]
We may need to update the userspace EOP buffer request;
otherwise, the EOP
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
buffer validation may fail.
Existing userspace should be ok. It currently uses
PAGE_SIZEwhich is larger than
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
2048.
The mesa uses the EOP size as max_t(u32,
PAGE_SIZE,
AMDGPU_GPU_PAGE_SIZE) which is sees larger than 2048, so the kernel validates the eop buffer can be successful at this point.Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
But the mesa may need to use the
shadow_info->eop_sizeas well inthe future?
Quoted 15 lines
Quoted 13 lines
Quoted 8 lines
Quoted 5 lines
Ideally mesa would query the kernel to get the proper minimum size. Yogesh will be looking at this.
Alex
Does the EOP buffer store privileged information? What is its content?
It stores end of pipe events for the compute queue generated from things like
RELEASE_MEMor AQL packets. They are specific to each user queue. In theory corrupting or messing with the data in the buffer should only affect that queue.
Quoted 7 lines
Quoted 1 line
RELEASE_MEMhas a hidden implicit VMID parameter. That's why it'simportant to know whether it's stored in the EOP buffer that can be overwritten by userspace.
My understanding is that that is only relevant for kernel queues where the vmid comes from the IB for each job. For user queues, the vmid is determined by the HQD so that is unused in the user queue case.
This is NAK'd until a proof is given that the EOP buffer can't be used to change the VMID of EOP fence writes.
Marek
Re: [PATCH 3/7] drm/amdgpu/gfx: add eop size and alignment to shadow info
Quoted 54 lines · Marek Olšák
Quoted 52 lines · On Tue, Oct 14, 2025, 12:37 Alex Deucher <[email protected]> wrote:
Quoted 50 lines · Marek Olšák
Quoted 46 lines · Alex Deucher
Quoted 32 lines · Marek Olšák
Quoted 30 lines · Alex Deucher
Quoted 27 lines · Prike
[Public]
Regards,
PrikeQuoted 11 lines
-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Monday, October 13, 2025 9:44 PM
To: Liang, Prike <[email protected]>
Cc: Deucher, Alexander <[email protected]>; amd- [email protected]
Subject: Re: [PATCH 3/7] drm/amdgpu/gfx: add eop size and alignment to shadow infoQuoted 1 line · Prike
Quoted 7 lines
Quoted 3 lines
[Public]
We may need to update the userspace EOP buffer request; otherwise, the EOP
buffer validation may fail.
Existing userspace should be ok. It currently uses
PAGE_SIZEwhich is larger than 2048.The mesa uses the EOP size as
max_t(u32, PAGE_SIZE, AMDGPU_GPU_PAGE_SIZE)which is sees larger than 2048, so the kernel validates the eop buffer can be successful at this point.But the mesa may need to use the
shadow_info->eop_sizeas well in the future?Quoted 7 lines
Quoted 4 lines
Ideally mesa would query the kernel to get the proper minimum size. Yogesh will be looking at this.
Alex
Does the EOP buffer store privileged information? What is its content?
It stores end of pipe events for the compute queue generated from things like
RELEASE_MEMor AQL packets. They are specific to each user queue. In theory corrupting or messing with the data in the buffer should only affect that queue.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
RELEASE_MEMhas a hidden implicit VMID parameter. That's why it's important to know whether it's stored in the EOP buffer that can be overwritten by userspace.My understanding is that that is only relevant for kernel queues where the vmid comes from the IB for each job. For user queues, the vmid is determined by the HQD so that is unused in the user queue case.
This is NAK'd until a proof is given that the EOP buffer can't be used to change the VMID of EOP fence writes.
The EOP buffer allocation is already in use. It's used for compute user queues for both ROCm and KGD. All this patch does is allow userspace to query what the size requirements are. If we find a problem in the EOP handling in firmware we should fix it in firmware, but the software side is already in use.
Alex
RE: [PATCH 3/7] drm/amdgpu/gfx: add eop size and alignment to shadow info
[Public]
Regards,
Prike
Quoted 84 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Wednesday, October 15, 2025 2:50 AM
To: Marek Olšák <[email protected]>
Cc: Liang, Prike <[email protected]>; Deucher, Alexander <[email protected]>; amd-gfx mailing list <amd- [email protected]>; Olsak, Marek <[email protected]>; Mohan Marimuthu, Yogesh <[email protected]>
Subject: Re: [PATCH 3/7] drm/amdgpu/gfx: add eop size and alignment to shadow infoQuoted 6 lines · Marek Olšák
Quoted 4 lines · On Tue, Oct 14, 2025, 12:37 Alex Deucher <[email protected]> wrote:
Quoted 2 lines · Marek Olšák
On Tue, Oct 14, 2025 at 10:12 AM Alex Deucher <[email protected]>
Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines · Marek Olšák
Quoted 2 lines
On Mon, Oct 13, 2025 at 3:11 PM Alex Deucher <[email protected]>
Quoted 2 lines · wrote:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
On Mon, Oct 13, 2025 at 10:21 AM Liang, Prike <[email protected]>
Quoted 16 lines · wrote:
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
[Public]
Regards,
PrikeQuoted 10 lines
-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Monday, October 13, 2025 9:44 PM
To: Liang, Prike <[email protected]>
Cc: Deucher, Alexander <[email protected]>; amd- [email protected]
Subject: Re: [PATCH 3/7] drm/amdgpu/gfx: add eop size and alignment to shadow infoOn Mon, Oct 13, 2025 at 4:54 AM Liang, Prike
Quoted 10 lines · <[email protected]> wrote:
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
Quoted 5 lines
[Public]
We may need to update the userspace EOP buffer request; otherwise, the EOP
buffer validation may fail.
Existing userspace should be ok. It currently uses
PAGE_SIZEwhich is larger than 2048.The mesa uses the EOP size as max_t(u32,
PAGE_SIZE,
AMDGPU_GPU_PAGE_SIZE) which is sees larger than 2048, so the kernel validates the eop buffer can be successful at this point.Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
But the mesa may need to use the
shadow_info->eop_sizeas well in thefuture?
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Quoted 5 lines
Ideally mesa would query the kernel to get the proper minimum size. Yogesh will be looking at this.
Alex
Does the EOP buffer store privileged information? What is its content?
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
It stores end of pipe events for the compute queue generated from things like
RELEASE_MEMor AQL packets. They are specific to each user queue. In theory corrupting or messing with the data in the buffer should only affect that queue.
RELEASE_MEMhas a hidden implicit VMID parameter. That's why it'simportant to know whether it's stored in the EOP buffer that can be overwritten by userspace.
Quoted 6 lines
Quoted 4 lines
My understanding is that that is only relevant for kernel queues where the vmid comes from the IB for each job. For user queues, the vmid is determined by the HQD so that is unused in the user queue case.
Quoted 7 lines
Quoted 1 line
This is NAK'd until a proof is given that the EOP buffer can't be used to change the
VMID of EOP fence writes.
The EOP buffer allocation is already in use. It's used for compute user queues for both ROCm and KGD. All this patch does is allow userspace to query what the size requirements are. If we find a problem in the EOP handling in firmware we should fix it in firmware, but the software side is already in use.
From my understanding, the MEC firmware generates and populates the EOP buffer raw data, so the driver has no direct control over its contents. @Gallo, Luca, could you help providing more details?
Quoted 1 line
Alex
Re: [PATCH 3/7] drm/amdgpu/gfx: add eop size and alignment to shadow info
In reply to Alex DeucherQuoted 77 lines · Alex Deucher
Quoted 6 lines · Marek Olšák
Quoted 4 lines · On Tue, Oct 14, 2025, 12:37 Alex Deucher <[email protected]> wrote:
Quoted 2 lines · Marek Olšák
On Tue, Oct 14, 2025 at 10:12 AM Alex Deucher <[email protected]>
Quoted 2 lines · wrote:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
On Tue, Oct 14, 2025 at 2:49 AM Marek Olšák <[email protected]>
Quoted 2 lines · wrote:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
On Mon, Oct 13, 2025 at 3:11 PM Alex Deucher <
Quoted 2 lines · [email protected]> wrote:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
On Mon, Oct 13, 2025 at 10:21 AM Liang, Prike <
Quoted 6 lines · [email protected]> wrote:
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
[Public]
Regards,
PrikeQuoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Monday, October 13, 2025 9:44 PM
To: Liang, Prike <[email protected]>
Cc: Deucher, Alexander <[email protected]>; amd- [email protected]
Subject: Re: [PATCH 3/7] drm/amdgpu/gfx: add eop size andalignment to shadow
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
info
On Mon, Oct 13, 2025 at 4:54 AM Liang, Prike <
Quoted 4 lines · [email protected]> wrote:
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
[Public]
We may need to update the userspace EOP buffer request;
otherwise, the EOP
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
buffer validation may fail.
Existing userspace should be ok. It currently uses
PAGE_SIZEwhich is larger than
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
2048.
The mesa uses the EOP size as max_t(u32,
PAGE_SIZE,
AMDGPU_GPU_PAGE_SIZE) which is sees larger than 2048, so the kernel validates the eop buffer can be successful at this point.Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
But the mesa may need to use the
shadow_info->eop_sizeas wellin the future?
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Ideally mesa would query the kernel to get the proper minimum
size.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Yogesh will be looking at this.
Alex
Does the EOP buffer store privileged information? What is its
content?
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
It stores end of pipe events for the compute queue generated from things like
RELEASE_MEMor AQL packets. They are specific to each user queue. In theory corrupting or messing with the data in the buffer should only affect that queue.
RELEASE_MEMhas a hidden implicit VMID parameter. That's why it'simportant to know whether it's stored in the EOP buffer that can be overwritten by userspace.
Quoted 6 lines
Quoted 4 lines
My understanding is that that is only relevant for kernel queues where the vmid comes from the IB for each job. For user queues, the vmid is determined by the HQD so that is unused in the user queue case.
Quoted 9 lines
Quoted 1 line
This is NAK'd until a proof is given that the EOP buffer can't be used
to change the VMID of EOP fence writes.
The EOP buffer allocation is already in use. It's used for compute user queues for both ROCm and KGD. All this patch does is allow userspace to query what the size requirements are. If we find a problem in the EOP handling in firmware we should fix it in firmware, but the software side is already in use.
So are you going to just brush it off? Aren't you interested in at least verifying whether it's possible to do privilege escalation with it even if it's already used? Do you really just want to merge this quickly without verifying whether it allows userspace to write any physical address because "userspace already uses it"? Do you really not want to know what is possible to do with the EOP buffer?
Marek
Alex Deucher
maintainerPATCH 4/7 drm/amdgpu/sdma: add query for CSA size and alignment
In reply to Alex DeucherNeeded to query the CSA size and alignment for SDMA user queues.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h | 7 +++++++ drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c | 12 ++++++++++++ drivers/gpu/drm/amd/amdgpu/sdma_v7_0.c | 12 ++++++++++++ 3 files changed, 31 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h +7 -0
@@ -50,6 +50,11 @@ enum amdgpu_sdma_irq {#define NUM_SDMA (x) hweight32(x) +struct amdgpu_sdma_csa_info { +u32 size; +u32 alignment; +}; +struct amdgpu_sdma_funcs {int (*stop_kernel_queue)(struct amdgpu_ring *ring);int (*start_kernel_queue)(struct amdgpu_ring *ring);
@@ -133,6 +138,8 @@ struct amdgpu_sdma {struct list_head reset_callback_list;bool no_user_submission;bool disable_uq; +void (*get_csa_info)(struct amdgpu_device *adev, +struct amdgpu_sdma_csa_info *csa_info); };/*
drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c +12 -0
@@ -1282,6 +1282,17 @@ static void sdma_v6_0_set_ras_funcs(struct amdgpu_device *adev) } } +/* all sizes are in bytes */ +#define SDMA6_CSA_SIZE 32 +#define SDMA6_CSA_ALIGNMENT 4 + +static void sdma_v6_0_get_csa_info (struct amdgpu_device *adev, +struct amdgpu_sdma_csa_info *csa_info) +{ + csa_info->size =SDMA6_CSA_SIZE ; + csa_info->alignment =SDMA6_CSA_ALIGNMENT ; +} +static int sdma_v6_0_early_init (struct amdgpu_ip_block *ip_block) {struct amdgpu_device *adev = ip_block->adev;
@@ -1314,6 +1325,7 @@ static int sdma_v6_0_early_init(struct amdgpu_ip_block *ip_block)sdma_v6_0_set_irq_funcs (adev);sdma_v6_0_set_mqd_funcs (adev);sdma_v6_0_set_ras_funcs (adev); + adev->sdma.get_csa_info = &sdma_v6_0_get_csa_info;return 0 ; }
drivers/gpu/drm/amd/amdgpu/sdma_v7_0.c +12 -0
@@ -1267,6 +1267,17 @@ static void sdma_v7_0_ring_emit_reg_write_reg_wait(struct amdgpu_ring *ring,amdgpu_ring_emit_reg_wait (ring, reg1, mask, mask); } +/* all sizes are in bytes */ +#define SDMA7_CSA_SIZE 32 +#define SDMA7_CSA_ALIGNMENT 4 + +static void sdma_v7_0_get_csa_info (struct amdgpu_device *adev, +struct amdgpu_sdma_csa_info *csa_info) +{ + csa_info->size =SDMA7_CSA_SIZE ; + csa_info->alignment =SDMA7_CSA_ALIGNMENT ; +} +static int sdma_v7_0_early_init (struct amdgpu_ip_block *ip_block) {struct amdgpu_device *adev = ip_block->adev;
@@ -1300,6 +1311,7 @@ static int sdma_v7_0_early_init(struct amdgpu_ip_block *ip_block)sdma_v7_0_set_vm_pte_funcs (adev);sdma_v7_0_set_irq_funcs (adev);sdma_v7_0_set_mqd_funcs (adev); + adev->sdma.get_csa_info = &sdma_v7_0_get_csa_info;return 0 ; }
Signature · 1 line
2.51.0
RE: [PATCH 4/7] drm/amdgpu/sdma: add query for CSA size and alignment
[Public]
Regards,
Prike
Quoted 102 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Saturday, October 11, 2025 5:15 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: [PATCH 4/7] drm/amdgpu/sdma: add query for CSA size and alignmentNeeded to query the CSA size and alignment for SDMA user queues.
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h | 7 +++++++ drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c | 12 ++++++++++++ drivers/gpu/drm/amd/amdgpu/sdma_v7_0.c | 12 ++++++++++++ 3 files changed, 31 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h +5
-0@@ -50,6 +50,11 @@ enum amdgpu_sdma_irq {#define NUM_SDMA (x) hweight32(x) +struct amdgpu_sdma_csa_info { +u32 size; +u32 alignment; +}; +struct amdgpu_sdma_funcs {int (*stop_kernel_queue)(struct amdgpu_ring *ring); int (*start_kernel_queue)(struct amdgpu_ring *ring); @@ -133,6 +138,8 @@struct amdgpu_sdma { struct list_head reset_callback_list; bool no_user_submission; bool disable_uq;drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h +2
-0+void (*get_csa_info)(struct amdgpu_device *adev, +struct amdgpu_sdma_csa_info *csa_info); };/* drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c +9
-0@@ -1282,6 +1282,17 @@ static void sdma_v6_0_set_ras_funcs(struct amdgpu_device *adev) } } +/* all sizes are in bytes */ +#define SDMA6_CSA_SIZE 32 +#define SDMA6_CSA_ALIGNMENT 4 + +static void sdma_v6_0_get_csa_info (struct amdgpu_device *adev, +struct amdgpu_sdma_csa_info *csa_info) { + csa_info->size =SDMA6_CSA_SIZE ; + csa_info->alignment =SDMA6_CSA_ALIGNMENT ; } +static int sdma_v6_0_early_init (struct amdgpu_ip_block *ip_block) { struct amdgpu_device *adev = ip_block->adev; @@ -1314,6 +1325,7 @@static int
sdma_v6_0_early_init(struct amdgpu_ip_block *ip_block)sdma_v6_0_set_irq_funcs(adev); sdma_v6_0_set_mqd_funcs(adev); sdma_v6_0_set_ras_funcs(adev);drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c +1
-0+ adev->sdma.get_csa_info = &sdma_v6_0_get_csa_info;return 0 ; }drivers/gpu/drm/amd/amdgpu/sdma_v7_0.c +10
-1@@ -1267,6 +1267,17 @@ static void sdma_v7_0_ring_emit_reg_write_reg_wait(struct amdgpu_ring *ring,amdgpu_ring_emit_reg_wait (ring, reg1, mask, mask); } +/* all sizes are in bytes */ +#define SDMA7_CSA_SIZE 32 +#define SDMA7_CSA_ALIGNMENT 4 + +static void sdma_v7_0_get_csa_info (struct amdgpu_device *adev, +struct amdgpu_sdma_csa_info *csa_info) { + csa_info->size =SDMA7_CSA_SIZE ; + csa_info->alignment =SDMA7_CSA_ALIGNMENT ; } +static int sdma_v7_0_early_init (struct amdgpu_ip_block *ip_block) { struct amdgpu_device *adev = ip_block->adev; @@ -1300,6 +1311,7 @@ static int sdma_v7_0_early_init(struct amdgpu_ip_block *ip_block) sdma_v7_0_set_vm_pte_funcs(adev);sdma_v7_0_set_irq_funcs (adev);sdma_v7_0_set_mqd_funcs (adev); + adev->sdma.get_csa_info = &sdma_v7_0_get_csa_info;return 0 ; } --2.51.0
Alex Deucher
maintainerPATCH 5/7 drm/amdgpu: Update AMDGPU_INFO_UQ_FW_AREAS query for compute
In reply to Alex DeucherAdd a query for compute queues. Userspace can use this to query the size of the EOP buffers for compute user queues.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 26 +++++++++++++++++++++++++ include/uapi/drm/amdgpu_drm.h | 8 ++++++++ 2 files changed, 34 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +26 -0
@@ -391,6 +391,24 @@ static int amdgpu_userq_metadata_info_gfx(struct amdgpu_device *adev,return ret; } +static int amdgpu_userq_metadata_info_compute (struct amdgpu_device *adev, +struct drm_amdgpu_info *info, +struct drm_amdgpu_info_uq_metadata_compute *meta) +{ +int ret = -EOPNOTSUPP ; + +if (adev->gfx.funcs->get_gfx_shadow_info) { +struct amdgpu_gfx_shadow_info shadow = {}; + + adev->gfx.funcs->get_gfx_shadow_info (adev, &shadow, true); + meta->eop_size = shadow.eop_size; + meta->eop_alignment = shadow.eop_alignment; + ret =0 ; + } + +return ret; +} +static int amdgpu_hw_ip_info (struct amdgpu_device *adev,struct drm_amdgpu_info *info,struct drm_amdgpu_info_hw_ip *result)
@@ -1359,6 +1377,14 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)if (ret)return ret; + ret =copy_to_user (out, &meta_info, +min ((size_t )size,sizeof (meta_info))) ? -EFAULT :0 ; +return 0 ; +case AMDGPU_HW_IP_COMPUTE : + ret =amdgpu_userq_metadata_info_compute (adev, info, &meta_info.compute); +if (ret) +return ret; + ret =copy_to_user (out, &meta_info,min ((size_t )size,sizeof (meta_info))) ? -EFAULT :0 ;return 0 ;
include/uapi/drm/amdgpu_drm.h +8 -0
@@ -1638,9 +1638,17 @@ struct drm_amdgpu_info_uq_metadata_gfx {__u32 csa_alignment; }; +struct drm_amdgpu_info_uq_metadata_compute { +/* EOP size for gfx11 */ +__u32 eop_size; +/* EOP base virtual alignment for gfx11 */ +__u32 eop_alignment; +}; +struct drm_amdgpu_info_uq_metadata {union {struct drm_amdgpu_info_uq_metadata_gfx gfx; +struct drm_amdgpu_info_uq_metadata_compute compute; }; };
Signature · 1 line
2.51.0
RE: [PATCH 5/7] drm/amdgpu: Update AMDGPU_INFO_UQ_FW_AREAS query for compute
[Public]
Regards,
Prike
Quoted 92 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Saturday, October 11, 2025 5:15 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: [PATCH 5/7] drm/amdgpu: UpdateAMDGPU_INFO_UQ_FW_AREASquery for computeAdd a query for compute queues. Userspace can use this to query the size of the EOP buffers for compute user queues.
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 26 +++++++++++++++++++++++++ include/uapi/drm/amdgpu_drm.h | 8 ++++++++ 2 files changed, 34 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +18
-0@@ -391,6 +391,24 @@ static int amdgpu_userq_metadata_info_gfx(structamdgpu_device *adev, return ret; } +static int amdgpu_userq_metadata_info_compute (struct amdgpu_device *adev, +struct drm_amdgpu_info *info, +struct drm_amdgpu_info_uq_metadata_compute *meta) { +int ret = -EOPNOTSUPP ; + +if (adev->gfx.funcs->get_gfx_shadow_info) { +struct amdgpu_gfx_shadow_info shadow = {}; + + adev->gfx.funcs->get_gfx_shadow_info (adev, &shadow, true); + meta->eop_size = shadow.eop_size; + meta->eop_alignment = shadow.eop_alignment; + ret =0 ; + } + +return ret; +} +static int amdgpu_hw_ip_info (struct amdgpu_device *adev,struct drm_amdgpu_info *info, struct drm_amdgpu_info_hw_ip *result) @@ -1359,6 +1377,14 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct
drm_file*filp)if (ret) return ret;drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +2
-0+ ret =copy_to_user (out, &meta_info, + min((size_t)size, sizeof(meta_info))) ? -EFAULT : 0;
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +3
-0+return 0 ; +case AMDGPU_HW_IP_COMPUTE : + ret = amdgpu_userq_metadata_info_compute(adev, info,&meta_info.compute);
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +3
-0+if (ret) +return ret; + ret =copy_to_user (out, &meta_info, min((size_t)size, sizeof(meta_info))) ? -EFAULT : 0; return 0;include/uapi/drm/amdgpu_drm.h index renamed from include/uapi/drm/amdgpu_drm.h +0
-0
e5252bf597b36..881e8cc986e2b100644include/uapi/drm/amdgpu_drm.h +8
-1@@ -1638,9 +1638,17 @@ struct drm_amdgpu_info_uq_metadata_gfx {__u32 csa_alignment; }; +struct drm_amdgpu_info_uq_metadata_compute { +/* EOP size for gfx11 */ +__u32 eop_size; +/* EOP base virtual alignment for gfx11 */ +__u32 eop_alignment; +}; +struct drm_amdgpu_info_uq_metadata {union {struct drm_amdgpu_info_uq_metadata_gfx gfx; +struct drm_amdgpu_info_uq_metadata_compute compute; }; }; --2.51.0
Alex Deucher
maintainerPATCH 6/7 drm/amdgpu: Update AMDGPU_INFO_UQ_FW_AREAS query for sdma
In reply to Alex DeucherAdd a query for sdma queues. Userspace can use this to query the size of the CSA buffers for sdma user queues.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 26 +++++++++++++++++++++++++ include/uapi/drm/amdgpu_drm.h | 8 ++++++++ 2 files changed, 34 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +26 -0
@@ -409,6 +409,24 @@ static int amdgpu_userq_metadata_info_compute(struct amdgpu_device *adev,return ret; } +static int amdgpu_userq_metadata_info_sdma (struct amdgpu_device *adev, +struct drm_amdgpu_info *info, +struct drm_amdgpu_info_uq_metadata_sdma *meta) +{ +int ret = -EOPNOTSUPP ; + +if (adev->sdma.get_csa_info) { +struct amdgpu_sdma_csa_info csa = {}; + + adev->sdma.get_csa_info (adev, &csa); + meta->csa_size = csa.size; + meta->csa_alignment = csa.alignment; + ret =0 ; + } + +return ret; +} +static int amdgpu_hw_ip_info (struct amdgpu_device *adev,struct drm_amdgpu_info *info,struct drm_amdgpu_info_hw_ip *result)
@@ -1385,6 +1403,14 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)if (ret)return ret; + ret =copy_to_user (out, &meta_info, +min ((size_t )size,sizeof (meta_info))) ? -EFAULT :0 ; +return 0 ; +case AMDGPU_HW_IP_DMA : + ret =amdgpu_userq_metadata_info_sdma (adev, info, &meta_info.sdma); +if (ret) +return ret; + ret =copy_to_user (out, &meta_info,min ((size_t )size,sizeof (meta_info))) ? -EFAULT :0 ;return 0 ;
include/uapi/drm/amdgpu_drm.h +8 -0
@@ -1645,10 +1645,18 @@ struct drm_amdgpu_info_uq_metadata_compute {__u32 eop_alignment; }; +struct drm_amdgpu_info_uq_metadata_sdma { +/* context save area size for sdma6 */ +__u32 csa_size; +/* context save area base virtual alignment for sdma6 */ +__u32 csa_alignment; +}; +struct drm_amdgpu_info_uq_metadata {union {struct drm_amdgpu_info_uq_metadata_gfx gfx;struct drm_amdgpu_info_uq_metadata_compute compute; +struct drm_amdgpu_info_uq_metadata_sdma sdma; }; };
Signature · 1 line
2.51.0
RE: [PATCH 6/7] drm/amdgpu: Update AMDGPU_INFO_UQ_FW_AREAS query for sdma
[Public]
Regards,
Prike
Quoted 93 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Saturday, October 11, 2025 5:15 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: [PATCH 6/7] drm/amdgpu: UpdateAMDGPU_INFO_UQ_FW_AREASquery for sdmaAdd a query for sdma queues. Userspace can use this to query the size of the CSA buffers for sdma user queues.
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 26 +++++++++++++++++++++++++ include/uapi/drm/amdgpu_drm.h | 8 ++++++++ 2 files changed, 34 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +18
-0@@ -409,6 +409,24 @@ static int amdgpu_userq_metadata_info_compute(structamdgpu_device *adev, return ret; } +static int amdgpu_userq_metadata_info_sdma (struct amdgpu_device *adev, +struct drm_amdgpu_info *info, +struct drm_amdgpu_info_uq_metadata_sdma *meta) { +int ret = -EOPNOTSUPP ; + +if (adev->sdma.get_csa_info) { +struct amdgpu_sdma_csa_info csa = {}; + + adev->sdma.get_csa_info (adev, &csa); + meta->csa_size = csa.size; + meta->csa_alignment = csa.alignment; + ret =0 ; + } + +return ret; +} +static int amdgpu_hw_ip_info (struct amdgpu_device *adev,struct drm_amdgpu_info *info, struct drm_amdgpu_info_hw_ip *result) @@ -1385,6 +1403,14 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct
drm_file*filp)if (ret) return ret;drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +2
-0+ ret =copy_to_user (out, &meta_info, + min((size_t)size, sizeof(meta_info))) ? -EFAULT : 0;
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +3
-0+return 0 ; +case AMDGPU_HW_IP_DMA : + ret = amdgpu_userq_metadata_info_sdma(adev, info,&meta_info.sdma);
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +3
-0+if (ret) +return ret; + ret =copy_to_user (out, &meta_info, min((size_t)size, sizeof(meta_info))) ? -EFAULT : 0; return 0;include/uapi/drm/amdgpu_drm.h index renamed from include/uapi/drm/amdgpu_drm.h +0
-0
881e8cc986e2b..021ed8a49600e100644include/uapi/drm/amdgpu_drm.h +8
-1@@ -1645,10 +1645,18 @@ struct drm_amdgpu_info_uq_metadata_compute {__u32 eop_alignment; }; +struct drm_amdgpu_info_uq_metadata_sdma { +/* context save area size for sdma6 */ +__u32 csa_size; +/* context save area base virtual alignment for sdma6 */ +__u32 csa_alignment; +}; +struct drm_amdgpu_info_uq_metadata {union {struct drm_amdgpu_info_uq_metadata_gfx gfx;struct drm_amdgpu_info_uq_metadata_compute compute; +struct drm_amdgpu_info_uq_metadata_sdma sdma; }; }; --2.51.0
Alex Deucher
maintainerPATCH 7/7 drm/amdgpu/userq: fix SDMA and compute validation properly
In reply to Alex DeucherThe CSA and EOP buffers have different alignement requirements. Replace the hardcoded sizes with proper queries to the IPs.
--- drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +8 -2
@@ -281,6 +281,9 @@ static int mes_userq_mqd_create(struct amdgpu_userq_mgr *uq_mgr,if (queue->queue_type ==AMDGPU_HW_IP_COMPUTE ) {struct drm_amdgpu_userq_mqd_compute_gfx11 *compute_mqd; +struct amdgpu_gfx_shadow_info shadow_info; + + adev->gfx.funcs->get_gfx_shadow_info (adev, &shadow_info, true);if (mqd_user->mqd_size !=sizeof (*compute_mqd)) {DRM_ERROR ("Invalid compute IP MQD size\n" );
@@ -296,7 +299,7 @@ static int mes_userq_mqd_create(struct amdgpu_userq_mgr *uq_mgr, } r =amdgpu_userq_input_va_validate (queue, compute_mqd->eop_va, -2048 ); + shadow_info.eop_size);if (r) goto free_mqd;
@@ -343,6 +346,9 @@ static int mes_userq_mqd_create(struct amdgpu_userq_mgr *uq_mgr,kfree (mqd_gfx_v11); }else if (queue->queue_type ==AMDGPU_HW_IP_DMA ) {struct drm_amdgpu_userq_mqd_sdma_gfx11 *mqd_sdma_v11; +struct amdgpu_sdma_csa_info csa; + + adev->sdma.get_csa_info (adev, &csa);if (mqd_user->mqd_size !=sizeof (*mqd_sdma_v11) || !mqd_user->mqd) {DRM_ERROR ("Invalid SDMA MQD\n" );
@@ -357,7 +363,7 @@ static int mes_userq_mqd_create(struct amdgpu_userq_mgr *uq_mgr, goto free_mqd; } r =amdgpu_userq_input_va_validate (queue, mqd_sdma_v11->csa_va, -32 ); + csa.size);if (r) goto free_mqd;
Signature · 1 line
2.51.0
RE: [PATCH 7/7] drm/amdgpu/userq: fix SDMA and compute validation properly
[Public]
Regards,
Prike
Quoted 22 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Saturday, October 11, 2025 5:15 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: [PATCH 7/7] drm/amdgpu/userq: fix SDMA and compute validation properlyThe CSA and EOP buffers have different alignement requirements. Replace the hardcoded sizes with proper queries to the IPs.
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +0
-0
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c static int mes_userq_mqd_create(struct · line 287
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +3
-0@@ -281,6 +281,9 @@ static int mes_userq_mqd_create(struct amdgpu_userq_mgr *uq_mgr, if (queue->queue_type == AMDGPU_HW_IP_COMPUTE) {struct drm_amdgpu_userq_mqd_compute_gfx11 *compute_mqd; +struct amdgpu_gfx_shadow_info shadow_info; + + adev->gfx.funcs->get_gfx_shadow_info (adev, &shadow_info, true);
[Prike] May need to validate the get_gfx_shadow_info() callback first before using it.
Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +2
-1if (mqd_user->mqd_size !=sizeof (*compute_mqd)) { DRM_ERROR("Invalid compute IP MQD size\n"); @@ -296,7 +299,7 @@ static int mes_userq_mqd_create(struct amdgpu_userq_mgr *uq_mgr, } r =amdgpu_userq_input_va_validate (queue, compute_mqd->eop_va, -2048 ); + shadow_info.eop_size);if (r) goto free_mqd;
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c static int mes_userq_mqd_create(struct · line 352
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +3
-0@@ -343,6 +346,9 @@ static int mes_userq_mqd_create(structamdgpu_userq_mgr *uq_mgr,kfree (mqd_gfx_v11 ); }else if (queue->queue_type ==AMDGPU_HW_IP_DMA ) {struct drm_amdgpu_userq_mqd_sdma_gfx11 *mqd_sdma_v11; +struct amdgpu_sdma_csa_info csa; + + adev->sdma.get_csa_info (adev, &csa);
Same here. Other than that, the patch is Reviewed-by: Prike Liang <[email protected]>
Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +0
-0if (mqd_user->mqd_size !=sizeof (*mqd_sdma_v11) || !mqd_user- >mqd) {DRM_ERROR("Invalid SDMA MQD\n");drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +1
-1@@ -357,7 +363,7 @@ static int mes_userq_mqd_create(structamdgpu_userq_mgr *uq_mgr, goto free_mqd; } r =amdgpu_userq_input_va_validate (queue, mqd_sdma_v11- >csa_va, -32 ); + csa.size);if (r)goto free_mqd;--
2.51.0
[Public]
Regards,
Prike
Quoted 52 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Saturday, October 11, 2025 5:15 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: [PATCH 1/7] drm/amdgpu: drop unused structures inamdgpu_drm.hThese were never used and are duplicated with the interface that is used. Maybe leftovers from a previous revision of the patch that added them.
Fixes 90c448fef312 ("drm/amdgpu: add new AMDGPU_INFO subquery for userqobjects")
Signed-off-by Alex Deucher <[email protected]>--- include/uapi/drm/amdgpu_drm.h | 21 --------------------- 1 file changed, 21 deletions(-)include/uapi/drm/amdgpu_drm.h index renamed from include/uapi/drm/amdgpu_drm.h +0
-0
3cb316ad54b34..e5252bf597b36100644include/uapi/drm/amdgpu_drm.h +0
-21@@ -1564,27 +1564,6 @@ struct drm_amdgpu_info_hw_ip {__u32 userq_num_slots; }; -/* GFX metadata BO sizes and alignment info (in bytes) */ -struct drm_amdgpu_info_uq_fw_areas_gfx { -/* shadow area size */ -__u32 shadow_size; -/* shadow area base virtual mem alignment */ -__u32 shadow_alignment; -/* context save area size */ -__u32 csa_size; -/* context save area base virtual mem alignment */ -__u32 csa_alignment; -}; - -/* IP specific fw related information used in the -* subquery AMDGPU_INFO_UQ_FW_AREAS -*/ -struct drm_amdgpu_info_uq_fw_areas { -union { -struct drm_amdgpu_info_uq_fw_areas_gfx gfx; - }; -}; -struct drm_amdgpu_info_num_handles {/** Max handles as supported by firmware for UVD */ __u32 uvd_max_handles; --2.51.0