Add CWSR support to user queues
Subsystems (3)
v5 cover Add CWSR support to user queues
This series ports some of CWSR functions from KFD to KGD side for userqueues.
Things which are part of this series -
v1:
Allocation of TBA/TMA regions for first level handler. First level handler is always from driver. Presently, this takes care of only dGPU allocations and is TBD for APUs. Backend to add second level handler is added, but there is no IOCTL provided yet. TBA is allocated only once and TMA is allocated per VM. It's tracked by a cwsr object which is maintained in userqueue manager.
Adds save area and control stack calculations to KGD side. Also, support to specify save/restore area params while creating user queues. TBD:IOCTL parameters need to be modified to specify save area params. Also, need to confirm size calculations with multi-xcc and obtain the number of XCCs used by a userqueue manager.
v2:
Remove association of cwsr with user queue manager (Christian)
Add ioctl support to query cwsr size, set cwsr parameters for user queues and set second level handler.
TBD: Handle level1 trap handler allocation for APUs.
v3:
Removed 'TBD: Handle level1 trap handler allocation for APUs' (confirmed that APUs also use the same path).
Rebase against amd-staging-drm-next.
Fixes for issues reported by Jesse Zhang:
Keep 2 pages for cwsr handler (TBA) and 1 page for TMA.
Add cwsr_enabled in addition to cwsr_supported and use it for NULL pointer issues.
v4:
Add disable userqueue check (Alex)
Fix usage of __free (Krzysztof)
Relocate userqueue trap VA to avoid conflict (Jesse)
Keep the user save area size check to be minimum size required.(Alex). Control stack size is still matched.
Set trap enable flag (Jesse)
Rename input parameter for consistency (Alex)
Add new function to set debug trap flag.
v5:
Remove control stack size from input parameter (Alex). Add upper bound check for save area size (Alex)
Lijo Lazar (11):
drm/amdgpu: Add helper function to get xcc count drm/amdgpu: Add cwsr functions
drm/amdgpu: Fill cwsr save area details drm/amdgpu: Add user save area params validation drm/amdgpu: Add cwsr to device init/fini sequence drm/amdgpu: Add first level cwsr handler to userq drm/amdgpu: Add user save area params to mqd input drm/amdgpu: Add ioctl to get cwsr details drm/amdgpu: Add ioctl support for cwsr params drm/amdgpu: Add ioctl to set level2 handler drm/amdgpu: Add interface to set debug trap flag
drivers/gpu/drm/amd/amdgpu/Makefile | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 10 +- drivers/gpu/drm/amd/amdgpu/amdgpu_cwsr.c | 629 +++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_cwsr.h | 99 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 8 + drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 2 + drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 29 + drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 24 + drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h | 5 + drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 13 +- drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.h | 22 + drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 14 + drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 33 ++ include/uapi/drm/amdgpu_drm.h | 51 ++ 14 files changed, 936 insertions(+), 5 deletions(-) create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_cwsr.c create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_cwsr.h
Signature · 1 line
2.49.0
PATCH v5 1/11 drm/amdgpu: Add helper function to get xcc count
Add a helper function to get the number of XCCs given a parition id. If there is no partition manager, return 1 as default.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.h +22 -0
@@ -217,4 +217,26 @@ amdgpu_get_next_xcp(struct amdgpu_xcp_mgr *xcp_mgr, int *from)for (i =0 , xcp =amdgpu_get_next_xcp (xcp_mgr, &i); xcp; \ ++i, xcp =amdgpu_get_next_xcp (xcp_mgr, &i)) +static inline int amdgpu_xcp_get_num_xcc(struct amdgpu_xcp_mgr *xcp_mgr, +int xcp_id) +{ +struct amdgpu_xcp *xcp; +uint32_t xcc_mask; +int i, r; + +if (!xcp_mgr || xcp_id ==AMDGPU_XCP_NO_PARTITION ) +return 1 ; +for_each_xcp (xcp_mgr, xcp, i) { +if (xcp->id == xcp_id) { + r =amdgpu_xcp_get_inst_details (xcp,AMDGPU_XCP_GFX , + &xcc_mask); +if (unlikely (r)) +return 1 ; +else +return hweight32 (xcc_mask); + } + } + +return 1 ; +}#endif
Signature · 1 line
2.49.0
PATCH v5 2/11 drm/amdgpu: Add cwsr functions
In reply to Lijo LazarAdd functions related to cwsr handling inside amdgpu framework.
--- drivers/gpu/drm/amd/amdgpu/Makefile | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 3 + drivers/gpu/drm/amd/amdgpu/amdgpu_cwsr.c | 364 +++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_cwsr.h | 67 +++++ drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 13 +- 5 files changed, 445 insertions(+), 4 deletions(-) create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_cwsr.c create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_cwsr.h
drivers/gpu/drm/amd/amdgpu/Makefile +1 -1
@@ -67,7 +67,7 @@ amdgpu-y += amdgpu_device.o amdgpu_doorbell_mgr.o amdgpu_kms.o \ amdgpu_fw_attestation.o amdgpu_securedisplay.o \ amdgpu_eeprom.o amdgpu_mca.o amdgpu_psp_ta.o amdgpu_lsdma.o \ amdgpu_ring_mux.o amdgpu_xcp.o amdgpu_seq64.o amdgpu_aca.o amdgpu_dev_coredump.o \ - amdgpu_cper.o amdgpu_userq_fence.o amdgpu_eviction_fence.o amdgpu_ip.o + amdgpu_cper.o amdgpu_userq_fence.o amdgpu_eviction_fence.o amdgpu_ip.o amdgpu_cwsr.o amdgpu-$(CONFIG_PROC_FS) += amdgpu_fdinfo.o
drivers/gpu/drm/amd/amdgpu/amdgpu.h +3 -0
@@ -328,6 +328,7 @@ struct kfd_vm_fault_info;struct amdgpu_hive_info ;struct amdgpu_reset_context ;struct amdgpu_reset_control ; +struct amdgpu_cwsr_isa ;enum amdgpu_cp_irq {AMDGPU_CP_IRQ_GFX_ME0_PIPE0_EOP =0 ,
@@ -1237,6 +1238,8 @@ struct amdgpu_device {* Must be last --ends in a flexible-array member. */ struct amdgpu_kfd_dev kfd; + +struct amdgpu_cwsr_info *cwsr_info; }; static inline uint32_t amdgpu_ip_version(const struct amdgpu_device *adev,
drivers/gpu/drm/amd/amdgpu/amdgpu_cwsr.c new file +364 -0
364 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_cwsr.h new file +67 -0
67 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +10 -3
@@ -176,10 +176,17 @@ struct amdgpu_bo_vm;#define AMDGPU_VA_RESERVED_TRAP_SIZE (2ULL << 12)#define AMDGPU_VA_RESERVED_TRAP_START (adev) (AMDGPU_VA_RESERVED_SEQ64_START(adev) \ - AMDGPU_VA_RESERVED_TRAP_SIZE) +/* TBD: Ideally, existing TRAP VA should do. There is a conflict with KFD mapping that needs to be +* resolved. Revisit later. +*/ +#define AMDGPU_VA_RESERVED_TRAP_UQ_SIZE (3ULL << 12) +#define AMDGPU_VA_RESERVED_TRAP_UQ_START (adev) \ + (AMDGPU_VA_RESERVED_TRAP_START(adev) - AMDGPU_VA_RESERVED_TRAP_UQ_SIZE) +#define AMDGPU_VA_RESERVED_BOTTOM (1ULL << 16) -#define AMDGPU_VA_RESERVED_TOP (AMDGPU_VA_RESERVED_TRAP_SIZE + \ - AMDGPU_VA_RESERVED_SEQ64_SIZE + \ - AMDGPU_VA_RESERVED_CSA_SIZE) +#define AMDGPU_VA_RESERVED_TOP \ + (AMDGPU_VA_RESERVED_TRAP_UQ_SIZE + AMDGPU_VA_RESERVED_TRAP_SIZE + \ + AMDGPU_VA_RESERVED_SEQ64_SIZE + AMDGPU_VA_RESERVED_CSA_SIZE)/* See vm_update_mode */ #define AMDGPU_VM_USE_CPU_FOR_GFX (1 << 0)
Signature · 1 line
2.49.0
PATCH v5 3/11 drm/amdgpu: Fill cwsr save area details
In reply to Lijo LazarCalculate control stack and total save area size required.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cwsr.c | 104 +++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_cwsr.h | 4 + 2 files changed, 108 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_cwsr.c +104 -0
@@ -32,6 +32,13 @@ extern int cwsr_enable;#define AMDGPU_CWSR_TMA_MAX_SIZE (AMDGPU_GPU_PAGE_SIZE)#define AMDGPU_CWSR_TMA_OFFSET (AMDGPU_CWSR_TBA_MAX_SIZE) +#define SGPR_SIZE_PER_CU 0x4000 +#define LDS_SIZE_PER_CU 0x10000 +#define HWREG_SIZE_PER_CU 0x1000 +#define DEBUGGER_BYTES_ALIGN 64 +#define DEBUGGER_BYTES_PER_WAVE 32 +#define SIZEOF_HSA_USER_CONTEXT_SAVE_AREA_HEADER 40 +enum amdgpu_cwsr_region {AMDGPU_CWSR_TBA ,AMDGPU_CWSR_TMA ,
@@ -121,6 +128,101 @@ static void amdgpu_cwsr_init_isa_details(struct amdgpu_device *adev, } } +static uint32_t amdgpu_cwsr_get_vgpr_size_per_cu (struct amdgpu_device *adev) +{ +uint32_t gc_ver =amdgpu_ip_version (adev,GC_HWIP ,0 ); +uint32_t vgpr_size; + +switch (gc_ver) { +case IP_VERSION (9 ,4 ,1 ):/* GFX_VERSION_ARCTURUS */ +case IP_VERSION (9 ,4 ,2 ):/* GFX_VERSION_ALDEBARAN */ +case IP_VERSION (9 ,4 ,3 ):/* GFX_VERSION_AQUA_VANJARAM */ +case IP_VERSION (9 ,4 ,4 ):/* GFX_VERSION_AQUA_VANJARAM */ +case IP_VERSION (9 ,5 ,0 ): + vgpr_size =0x80000 ; +break ; +case IP_VERSION (11 ,0 ,0 ): +case IP_VERSION (11 ,0 ,2 ): +case IP_VERSION (11 ,0 ,3 ): +case IP_VERSION (12 ,0 ,0 ): +case IP_VERSION (12 ,0 ,1 ): + vgpr_size =0x60000 ; +break ; +default : + vgpr_size =0x40000 ; +break ; + } + +return vgpr_size; +} + +static uint32_t amdgpu_cwsr_get_wg_ctxt_size_per_cu (struct amdgpu_device *adev) +{ +uint32_t lds_sz_per_cu; + + lds_sz_per_cu = + (amdgpu_ip_version (adev,GC_HWIP ,0 ) ==IP_VERSION (9 ,5 ,0 )) ? + (adev->gfx.cu_info.lds_size <<10 ) : +LDS_SIZE_PER_CU ; + +return amdgpu_cwsr_get_vgpr_size_per_cu (adev) +SGPR_SIZE_PER_CU + + lds_sz_per_cu +HWREG_SIZE_PER_CU ; +} + +static uint32_t amdgpu_cwsr_ctl_stack_bytes_per_wave (struct amdgpu_device *adev) +{ +uint32_t sz; + +if (amdgpu_ip_version (adev,GC_HWIP ,0 ) >=IP_VERSION (10 ,1 ,0 )) + sz =12 ; +else + sz =8 ; +return sz; +} + +static void amdgpu_cwsr_init_save_area_info (struct amdgpu_device *adev, +struct amdgpu_cwsr_info *cwsr_info) +{ +struct amdgpu_gfx_config *gfx_info = &adev->gfx.config; +uint32_t gc_ver =amdgpu_ip_version (adev,GC_HWIP ,0 ); +uint32_t ctl_stack_size, wg_data_size, dbg_mem_size; +uint32_t array_count; +uint32_t wave_num; +uint32_t cu_num; + +if (gc_ver <IP_VERSION (9 ,0 ,1 )) +return ; + + array_count = gfx_info->max_shader_engines * gfx_info->max_sh_per_se; + + cu_num = adev->gfx.cu_info.number /NUM_XCC (adev->gfx.xcc_mask); + wave_num = (gc_ver <IP_VERSION (10 ,1 ,0 )) ?/* GFX_VERSION_NAVI10 */ +min (cu_num *40 , + array_count / gfx_info->max_sh_per_se *512 ) : + cu_num *32 ; + + wg_data_size =ALIGN (cu_num *amdgpu_cwsr_get_wg_ctxt_size_per_cu (adev), +PAGE_SIZE ); + ctl_stack_size = + wave_num *amdgpu_cwsr_ctl_stack_bytes_per_wave (adev) +8 ; + ctl_stack_size = +ALIGN (SIZEOF_HSA_USER_CONTEXT_SAVE_AREA_HEADER + ctl_stack_size, +PAGE_SIZE ); + dbg_mem_size = +ALIGN (wave_num *DEBUGGER_BYTES_PER_WAVE ,DEBUGGER_BYTES_ALIGN ); +/* +* HW design limits control stack size to 0x7000. +* This is insufficient for theoretical PM4 cases +* but sufficient for AQL, limited by SPI events. +*/ +if (IP_VERSION_MAJ (gc_ver) ==10 ) + ctl_stack_size =min (ctl_stack_size,0x7000 ); + + cwsr_info->xcc_ctl_stack_sz = ctl_stack_size; + cwsr_info->xcc_cwsr_sz = ctl_stack_size + wg_data_size; + cwsr_info->xcc_dbg_mem_sz = dbg_mem_size; +} +int amdgpu_cwsr_init (struct amdgpu_device *adev) { struct amdgpu_cwsr_info *cwsr_info __free(kfree) =
@@ -145,6 +247,8 @@ int amdgpu_cwsr_init(struct amdgpu_device *adev)return r;memcpy (ptr, cwsr_info->isa_buf, cwsr_info->isa_sz); + +amdgpu_cwsr_init_save_area_info (adev, cwsr_info); adev->cwsr_info =no_free_ptr (cwsr_info);return 0 ;
drivers/gpu/drm/amd/amdgpu/amdgpu_cwsr.h +4 -0
@@ -50,6 +50,10 @@ struct amdgpu_cwsr_info {struct amdgpu_bo *isa_bo;const void *isa_buf;uint32_t isa_sz; +/* cwsr size info per XCC*/ +uint32_t xcc_ctl_stack_sz; +uint32_t xcc_dbg_mem_sz; +uint32_t xcc_cwsr_sz; };int amdgpu_cwsr_init (struct amdgpu_device *adev);
Signature · 1 line
2.49.0
PATCH v5 4/11 drm/amdgpu: Add user save area params validation
In reply to Lijo LazarAdd an interface to validate user provided save area parameters. Address validation is not done and expected to be done outside.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cwsr.c | 39 ++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_cwsr.h | 10 ++++++ 2 files changed, 49 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_cwsr.c +39 -0
@@ -64,6 +64,15 @@ static inline bool amdgpu_cwsr_is_supported(struct amdgpu_device *adev)return true; } +uint32_t amdgpu_cwsr_size_needed (struct amdgpu_device *adev,int num_xcc) +{ +if (!amdgpu_cwsr_is_enabled (adev)) +return 0 ; + +return num_xcc * + (adev->cwsr_info->xcc_cwsr_sz + adev->cwsr_info->xcc_dbg_mem_sz); +} +static void amdgpu_cwsr_init_isa_details (struct amdgpu_device *adev,struct amdgpu_cwsr_info *cwsr_info) {
@@ -425,6 +434,36 @@ int amdgpu_cwsr_alloc(struct amdgpu_device *adev, struct amdgpu_vm *vm,return r; } +int amdgpu_cwsr_validate_params (struct amdgpu_device *adev, +struct amdgpu_cwsr_params *cwsr_params, +int num_xcc) +{ +uint32_t min_size, max_size; + +if (!amdgpu_cwsr_is_enabled (adev)) +return -EOPNOTSUPP ; + +if (!cwsr_params) +return -EINVAL ; + + min_size =amdgpu_cwsr_size_needed (adev, num_xcc); + max_size =2 * min_size; +/* +* Only save area size details checked. Address validation needs to be +* carried out separately. User is expected to pass a cwsr buffer area +* with size >= ctl stack size + wg data size + debug memory size +*/ +if (cwsr_params->cwsr_sz < min_size || + cwsr_params->cwsr_sz > max_size) { +dev_dbg (adev->dev, +"queue cwsr size 0x%x should be within min %u : max %u\n" , + cwsr_params->cwsr_sz, min_size, max_size); +return -EINVAL ; + } + +return 0 ; +} +void amdgpu_cwsr_free (struct amdgpu_device *adev,struct amdgpu_vm *vm,struct amdgpu_cwsr_trap_obj **trap_obj) {
drivers/gpu/drm/amd/amdgpu/amdgpu_cwsr.h +10 -0
@@ -56,6 +56,12 @@ struct amdgpu_cwsr_info {uint32_t xcc_cwsr_sz; }; +struct amdgpu_cwsr_params { +uint64_t ctx_save_area_address; +/* cwsr size info */ +uint32_t cwsr_sz; +}; +int amdgpu_cwsr_init (struct amdgpu_device *adev);void amdgpu_cwsr_fini (struct amdgpu_device *adev);
@@ -68,4 +74,8 @@ static inline bool amdgpu_cwsr_is_enabled(struct amdgpu_device *adev) return adev->cwsr_info != NULL; } +uint32_t amdgpu_cwsr_size_needed (struct amdgpu_device *adev,int num_xcc); +int amdgpu_cwsr_validate_params (struct amdgpu_device *adev, +struct amdgpu_cwsr_params *cwsr_params, +int num_xcc);#endif
Signature · 1 line
2.49.0
Re: [PATCH v5 04/11] drm/amdgpu: Add user save area params validation
Quoted 5 lines · Lijo Lazar
Add an interface to validate user provided save area parameters. Address validation is not done and expected to be done outside.
Signed-off-by Lijo Lazar <[email protected]>
Quoted 91 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cwsr.c | 39 ++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_cwsr.h | 10 ++++++ 2 files changed, 49 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_cwsr.c +39
-0@@ -64,6 +64,15 @@ static inline bool amdgpu_cwsr_is_supported(struct amdgpu_device *adev)return true; } +uint32_t amdgpu_cwsr_size_needed (struct amdgpu_device *adev,int num_xcc) +{ +if (!amdgpu_cwsr_is_enabled (adev)) +return 0 ; + +return num_xcc * + (adev->cwsr_info->xcc_cwsr_sz + adev->cwsr_info->xcc_dbg_mem_sz); +} +static void amdgpu_cwsr_init_isa_details (struct amdgpu_device *adev,struct amdgpu_cwsr_info *cwsr_info) {@@ -425,6 +434,36 @@ int amdgpu_cwsr_alloc(struct amdgpu_device *adev, struct amdgpu_vm *vm,return r; } +int amdgpu_cwsr_validate_params (struct amdgpu_device *adev, +struct amdgpu_cwsr_params *cwsr_params, +int num_xcc) +{ +uint32_t min_size, max_size; + +if (!amdgpu_cwsr_is_enabled (adev)) +return -EOPNOTSUPP ; + +if (!cwsr_params) +return -EINVAL ; + + min_size =amdgpu_cwsr_size_needed (adev, num_xcc); + max_size =2 * min_size; +/* +* Only save area size details checked. Address validation needs to be +* carried out separately. User is expected to pass a cwsr buffer area +* with size >= ctl stack size + wg data size + debug memory size +*/ +if (cwsr_params->cwsr_sz < min_size || + cwsr_params->cwsr_sz > max_size) { +dev_dbg (adev->dev, +"queue cwsr size 0x%x should be within min %u : max %u\n" , + cwsr_params->cwsr_sz, min_size, max_size); +return -EINVAL ; + } + +return 0 ; +} +void amdgpu_cwsr_free (struct amdgpu_device *adev,struct amdgpu_vm *vm,struct amdgpu_cwsr_trap_obj **trap_obj) {drivers/gpu/drm/amd/amdgpu/amdgpu_cwsr.h +10
-1@@ -56,6 +56,12 @@ struct amdgpu_cwsr_info {uint32_t xcc_cwsr_sz; }; +struct amdgpu_cwsr_params { +uint64_t ctx_save_area_address; +/* cwsr size info */ +uint32_t cwsr_sz; +}; +int amdgpu_cwsr_init (struct amdgpu_device *adev);void amdgpu_cwsr_fini (struct amdgpu_device *adev);@@ -68,4 +74,8 @@ static inline bool amdgpu_cwsr_is_enabled(struct amdgpu_device *adev) return adev->cwsr_info != NULL; } +uint32_t amdgpu_cwsr_size_needed (struct amdgpu_device *adev,int num_xcc); +int amdgpu_cwsr_validate_params (struct amdgpu_device *adev, +struct amdgpu_cwsr_params *cwsr_params, +int num_xcc);#endif --2.49.0
PATCH v5 5/11 drm/amdgpu: Add cwsr to device init/fini sequence
In reply to Lijo LazarInitialize cwsr handler related info during device initialization.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +8 -0
@@ -78,6 +78,7 @@#include "amdgpu_reset.h" #include "amdgpu_virt.h" #include "amdgpu_dev_coredump.h" +#include "amdgpu_cwsr.h" #include <linux/suspend.h> #include <drm/task_barrier.h>
@@ -3171,6 +3172,12 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev) r =amdgpu_cper_init (adev); +if (!r) { + r =amdgpu_cwsr_init (adev); +if (r == -EOPNOTSUPP ) + r =0 ; + } + init_failed:return r;
@@ -3561,6 +3568,7 @@ static int amdgpu_device_ip_fini(struct amdgpu_device *adev) {int i, r; +amdgpu_cwsr_fini (adev);amdgpu_cper_fini (adev);if (amdgpu_sriov_vf (adev) && adev->virt.ras_init_done)
Signature · 1 line
2.49.0
PATCH v5 6/11 drm/amdgpu: Add first level cwsr handler to userq
In reply to Lijo LazarAdd cwsr_trap_obj to render file handle. It maps the first level cwsr handler to the vm with which the file handle is associated. Use cwsr trap object's tba/tma address for the userqueue.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_cwsr.h | 6 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 8 ++++++++ drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 7 +++++++ 4 files changed, 23 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -0
@@ -329,6 +329,7 @@ struct amdgpu_hive_info;struct amdgpu_reset_context ;struct amdgpu_reset_control ;struct amdgpu_cwsr_isa ; +struct amdgpu_cwsr_trap_obj ;enum amdgpu_cp_irq {AMDGPU_CP_IRQ_GFX_ME0_PIPE0_EOP =0 ,
@@ -449,6 +450,7 @@ struct amdgpu_fpriv {struct idr bo_list_handles;struct amdgpu_ctx_mgr ctx_mgr;struct amdgpu_userq_mgr userq_mgr; +struct amdgpu_cwsr_trap_obj *cwsr_trap;/* Eviction fence infra */ struct amdgpu_eviction_fence_mgr evf_mgr;
drivers/gpu/drm/amd/amdgpu/amdgpu_cwsr.h +6 -0
@@ -78,4 +78,10 @@ uint32_t amdgpu_cwsr_size_needed(struct amdgpu_device *adev, int num_xcc);int amdgpu_cwsr_validate_params (struct amdgpu_device *adev,struct amdgpu_cwsr_params *cwsr_params,int num_xcc); +static inline bool amdgpu_cwsr_has_dbg_wa (struct amdgpu_device *adev) +{ +uint32_t gc_ver =amdgpu_ip_version (adev,GC_HWIP ,0 ); + +return gc_ver >=IP_VERSION (11 ,0 ,0 ) && gc_ver <=IP_VERSION (11 ,0 ,3 ); +}#endif
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +8 -0
@@ -46,6 +46,7 @@#include "amdgpu_reset.h" #include "amd_pcie.h" #include "amdgpu_userq.h" +#include "amdgpu_cwsr.h" void amdgpu_unregister_gpu_instance (struct amdgpu_device *adev) {
@@ -1512,6 +1513,12 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)"Failed to init usermode queue manager (%d), use legacy workload submission only\n" , r); +if (amdgpu_cwsr_is_enabled (adev)) { + r =amdgpu_cwsr_alloc (adev, &fpriv->vm, &fpriv->cwsr_trap); +if (r) +dev_dbg (adev->dev,"cwsr trap not enabled" ); + } + r =amdgpu_eviction_fence_init (&fpriv->evf_mgr);if (r) goto error_vm;
@@ -1584,6 +1591,7 @@ void amdgpu_driver_postclose_kms(struct drm_device *dev, }amdgpu_ctx_mgr_fini (&fpriv->ctx_mgr); +amdgpu_cwsr_free (adev, &fpriv->vm, &fpriv->cwsr_trap);amdgpu_vm_fini (adev, &fpriv->vm);if (pasid)
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +7 -0
@@ -26,6 +26,7 @@#include "amdgpu_gfx.h" #include "mes_userqueue.h" #include "amdgpu_userq_fence.h" +#include "amdgpu_cwsr.h" #define AMDGPU_USERQ_PROC_CTX_SZ PAGE_SIZE#define AMDGPU_USERQ_GANG_CTX_SZ PAGE_SIZE
@@ -136,6 +137,7 @@ static int convert_to_mes_priority(int priority)static int mes_userq_map (struct amdgpu_usermode_queue *queue) {struct amdgpu_userq_mgr *uq_mgr = queue->userq_mgr; +struct amdgpu_fpriv *fpriv =uq_mgr_to_fpriv (uq_mgr);struct amdgpu_device *adev = uq_mgr->adev;struct amdgpu_userq_obj *ctx = &queue->fw_obj;struct amdgpu_mqd_prop *userq_props = queue->userq_prop;
@@ -165,6 +167,11 @@ static int mes_userq_map(struct amdgpu_usermode_queue *queue) queue_input.doorbell_offset = userq_props->doorbell_index; queue_input.page_table_base_addr =amdgpu_gmc_pd_addr (queue->vm->root.bo); queue_input.wptr_mc_addr = queue->wptr_obj.gpu_addr; +if (fpriv->cwsr_trap) { + queue_input.tba_addr = fpriv->cwsr_trap->tba_gpu_va_addr; + queue_input.tma_addr = fpriv->cwsr_trap->tma_gpu_va_addr; + queue_input.trap_en = !amdgpu_cwsr_has_dbg_wa (adev); + }amdgpu_mes_lock (&adev->mes); r = adev->mes.funcs->add_hw_queue (&adev->mes, &queue_input);
Signature · 1 line
2.49.0
PATCH v5 7/11 drm/amdgpu: Add user save area params to mqd input
In reply to Lijo LazarAdd user save area parameters to mqd properties for queue creation. Validate the parameters before using for mqd initialization.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 4 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 24 ++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h | 5 +++++ drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 14 +++++++++++++ drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 23 +++++++++++++++++++++ 5 files changed, 70 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +4 -0
@@ -814,6 +814,10 @@ struct amdgpu_mqd_prop {uint64_t fence_address;bool tmz_queue;bool kernel_queue; +/* cwsr params*/ +uint64_t ctx_save_area_addr; +uint32_t ctx_save_area_size; +uint32_t ctl_stack_size; };struct amdgpu_mqd {
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +24 -0
@@ -33,6 +33,7 @@#include "amdgpu_userq.h" #include "amdgpu_hmm.h" #include "amdgpu_userq_fence.h" +#include "amdgpu_cwsr.h" u32 amdgpu_userq_get_supported_ip_mask (struct amdgpu_device *adev) {
@@ -265,6 +266,29 @@ int amdgpu_userq_input_va_validate(struct amdgpu_device *adev,return r; } +int amdgpu_userq_input_cwsr_params_validate ( +struct amdgpu_usermode_queue *queue, +struct amdgpu_cwsr_params *cwsr_params) +{ +struct amdgpu_fpriv *fpriv =uq_mgr_to_fpriv (queue->userq_mgr); +struct amdgpu_device *adev = queue->userq_mgr->adev; +uint32_t cwsr_size; +int num_xcc; +int r; + + num_xcc =amdgpu_xcp_get_num_xcc (adev->xcp_mgr, fpriv->xcp_id); + r =amdgpu_cwsr_validate_params (queue->userq_mgr->adev, cwsr_params, + num_xcc); +if (r) +return r; + cwsr_size =amdgpu_cwsr_size_needed (queue->userq_mgr->adev, num_xcc); +if (!cwsr_size) +return -EOPNOTSUPP ; + +return amdgpu_userq_input_va_validate ( + adev, queue, cwsr_params->ctx_save_area_address, cwsr_size); +} +static bool amdgpu_userq_buffer_va_mapped (struct amdgpu_vm *vm,u64 addr) {struct amdgpu_bo_va_mapping *mapping;
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h +5 -0
@@ -41,6 +41,7 @@ enum amdgpu_userq_state { };struct amdgpu_mqd_prop ; +struct amdgpu_cwsr_params ;struct amdgpu_userq_obj {void *cpu_ptr;
@@ -157,4 +158,8 @@ int amdgpu_userq_input_va_validate(struct amdgpu_device *adev,int amdgpu_userq_gem_va_unmap_validate (struct amdgpu_device *adev,struct amdgpu_bo_va_mapping *mapping,uint64_t saddr); +int amdgpu_userq_input_cwsr_params_validate ( +struct amdgpu_usermode_queue *queue, +struct amdgpu_cwsr_params *cwsr_params); +#endif
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +14 -0
@@ -3243,6 +3243,20 @@ static int gfx_v12_0_compute_mqd_init(struct amdgpu_device *adev, void *m, mqd->fence_address_lo =lower_32_bits (prop->fence_address); mqd->fence_address_hi =upper_32_bits (prop->fence_address); +/* If non-zero, assume cwsr is enabled */ +if (prop->ctx_save_area_addr) { + mqd->cp_hqd_persistent_state |= + (1 <<CP_HQD_PERSISTENT_STATE__QSWITCH_MODE__SHIFT ); + mqd->cp_hqd_ctx_save_base_addr_lo = +lower_32_bits (prop->ctx_save_area_addr); + mqd->cp_hqd_ctx_save_base_addr_hi = +upper_32_bits (prop->ctx_save_area_addr); + mqd->cp_hqd_ctx_save_size = prop->ctx_save_area_size; + mqd->cp_hqd_cntl_stack_size = prop->ctl_stack_size; + mqd->cp_hqd_cntl_stack_offset = prop->ctl_stack_size; + mqd->cp_hqd_wg_state_offset = prop->ctl_stack_size; + } +return 0 ; }
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +23 -0
@@ -314,6 +314,7 @@ static int mes_userq_mqd_create(struct amdgpu_usermode_queue *queue,if (queue->queue_type ==AMDGPU_HW_IP_COMPUTE ) {struct drm_amdgpu_userq_mqd_compute_gfx11 *compute_mqd; +struct amdgpu_cwsr_params cwsr_params;if (mqd_user->mqd_size !=sizeof (*compute_mqd)) {DRM_ERROR ("Invalid compute IP MQD size\n" );
@@ -339,6 +340,28 @@ static int mes_userq_mqd_create(struct amdgpu_usermode_queue *queue, userq_props->hqd_active = false; userq_props->tmz_queue = mqd_user->flags &AMDGPU_USERQ_CREATE_FLAGS_QUEUE_SECURE ; + +if (amdgpu_cwsr_is_enabled (adev)) { +struct amdgpu_fpriv *fpriv = +uq_mgr_to_fpriv (queue->userq_mgr); +int num_xcc; + + num_xcc =amdgpu_xcp_get_num_xcc (adev->xcp_mgr, + fpriv->xcp_id); + cwsr_params.ctx_save_area_address = + userq_props->ctx_save_area_addr; + cwsr_params.cwsr_sz = userq_props->ctx_save_area_size; + userq_props->ctl_stack_size = + adev->cwsr_info->xcc_ctl_stack_sz * num_xcc; + + r =amdgpu_userq_input_cwsr_params_validate ( + queue, &cwsr_params); +if (r) { +kfree (compute_mqd); + goto free_mqd; + } + } +kfree (compute_mqd); }else if (queue->queue_type ==AMDGPU_HW_IP_GFX ) {struct drm_amdgpu_userq_mqd_gfx11 *mqd_gfx_v11;
Signature · 1 line
2.49.0
PATCH v5 8/11 drm/amdgpu: Add ioctl to get cwsr details
In reply to Lijo LazarAdd an ioctl to return size information required for CWSR regions.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 21 +++++++++++++++++++++ include/uapi/drm/amdgpu_drm.h | 16 ++++++++++++++++ 2 files changed, 37 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +21 -0
@@ -1426,6 +1426,27 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)return -EINVAL ; } } +case AMDGPU_INFO_CWSR : { +struct drm_amdgpu_info_cwsr cwsr_info; +int num_xcc, r; + + fpriv = (struct amdgpu_fpriv *)filp->driver_priv; +if (!amdgpu_cwsr_is_enabled (adev) || !fpriv->cwsr_trap) +return -EOPNOTSUPP ; + num_xcc =amdgpu_xcp_get_num_xcc (adev->xcp_mgr, fpriv->xcp_id); + cwsr_info.ctl_stack_size = + adev->cwsr_info->xcc_ctl_stack_sz * num_xcc; + cwsr_info.dbg_mem_size = + adev->cwsr_info->xcc_dbg_mem_sz * num_xcc; + cwsr_info.min_save_area_size = +amdgpu_cwsr_size_needed (adev, num_xcc); + r =copy_to_user (out, &cwsr_info, +min ((size_t )size,sizeof (cwsr_info))) ? + -EFAULT : +0 ; +return r; + } +default :DRM_DEBUG_KMS ("Invalid request %d\n" , info->query);return -EINVAL ;
include/uapi/drm/amdgpu_drm.h +16 -0
@@ -1269,6 +1269,8 @@ struct drm_amdgpu_cs_chunk_cp_gfx_shadow {#define AMDGPU_INFO_GPUVM_FAULT 0x23/* query FW object size and alignment */ #define AMDGPU_INFO_UQ_FW_AREAS 0x24 +/* query CWSR size and alignment */ +#define AMDGPU_INFO_CWSR 0x25#define AMDGPU_INFO_MMR_SE_INDEX_SHIFT 0#define AMDGPU_INFO_MMR_SE_INDEX_MASK 0xff
@@ -1648,6 +1650,20 @@ struct drm_amdgpu_info_uq_metadata { }; }; +/** +* struct drm_amdgpu_info_cwsr - cwsr information +* +* Gives cwsr related size details. User needs to allocate buffer based on this. +*/ +struct drm_amdgpu_info_cwsr { +/* Control stack size */ +__u32 ctl_stack_size; +/* Debug memory area size */ +__u32 dbg_mem_size; +/* Minimum save area size required */ +__u32 min_save_area_size; +}; +/* * Supported GPU families */
Signature · 1 line
2.49.0
PATCH v5 9/11 drm/amdgpu: Add ioctl support for cwsr params
In reply to Lijo LazarAdd cwsr parameters to userqueue ioctl. User should pass the GPU virtual address for save/restore buffer, and size allocated. They are supported only for user compute queues.
--- drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 13 ++++++++----- include/uapi/drm/amdgpu_drm.h | 11 +++++++++++ 2 files changed, 19 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +8 -5
@@ -349,17 +349,20 @@ static int mes_userq_mqd_create(struct amdgpu_usermode_queue *queue, num_xcc =amdgpu_xcp_get_num_xcc (adev->xcp_mgr, fpriv->xcp_id); cwsr_params.ctx_save_area_address = - userq_props->ctx_save_area_addr; - cwsr_params.cwsr_sz = userq_props->ctx_save_area_size; - userq_props->ctl_stack_size = - adev->cwsr_info->xcc_ctl_stack_sz * num_xcc; - + compute_mqd->ctx_save_area_va; + cwsr_params.cwsr_sz = compute_mqd->ctx_save_area_size; r =amdgpu_userq_input_cwsr_params_validate ( queue, &cwsr_params);if (r) {kfree (compute_mqd); goto free_mqd; } + userq_props->ctx_save_area_addr = + compute_mqd->ctx_save_area_va; + userq_props->ctx_save_area_size = + compute_mqd->ctx_save_area_size; + userq_props->ctl_stack_size = + adev->cwsr_info->xcc_ctl_stack_sz * num_xcc; }kfree (compute_mqd);
include/uapi/drm/amdgpu_drm.h +11 -0
@@ -460,6 +460,17 @@ struct drm_amdgpu_userq_mqd_compute_gfx11 {* to get the size. */ __u64 eop_va; +/** +* @ctx_save_area_va: Virtual address of the GPU memory for save/restore buffer. +* This must be from a separate GPU object, and use AMDGPU_INFO IOCTL +* to get the size. This includes control stack, wave context and debugger memory. +*/ +__u64 ctx_save_area_va; +/** +* @ctx_save_area_size: Total size (in bytes) allocated for save/restore buffer. +* Use AMDGPU_INFO IOCTL to get the size. +*/ +__u32 ctx_save_area_size; };/* userq signal/wait ioctl */
Signature · 1 line
2.49.0
Re: [PATCH v5 09/11] drm/amdgpu: Add ioctl support for cwsr params
Quoted 6 lines · Lijo Lazar
Add cwsr parameters to userqueue ioctl. User should pass the GPU virtual address for save/restore buffer, and size allocated. They are supported only for user compute queues.
Signed-off-by Lijo Lazar <[email protected]>
Quoted 60 lines
--- drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 13 ++++++++----- include/uapi/drm/amdgpu_drm.h | 11 +++++++++++ 2 files changed, 19 insertions(+), 5 deletions(-)drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +8
-5@@ -349,17 +349,20 @@ static int mes_userq_mqd_create(struct amdgpu_usermode_queue *queue, num_xcc =amdgpu_xcp_get_num_xcc (adev->xcp_mgr, fpriv->xcp_id); cwsr_params.ctx_save_area_address = - userq_props->ctx_save_area_addr; - cwsr_params.cwsr_sz = userq_props->ctx_save_area_size; - userq_props->ctl_stack_size = - adev->cwsr_info->xcc_ctl_stack_sz * num_xcc; - + compute_mqd->ctx_save_area_va; + cwsr_params.cwsr_sz = compute_mqd->ctx_save_area_size; r =amdgpu_userq_input_cwsr_params_validate ( queue, &cwsr_params);if (r) {kfree (compute_mqd); goto free_mqd; } + userq_props->ctx_save_area_addr = + compute_mqd->ctx_save_area_va; + userq_props->ctx_save_area_size = + compute_mqd->ctx_save_area_size; + userq_props->ctl_stack_size = + adev->cwsr_info->xcc_ctl_stack_sz * num_xcc; }kfree (compute_mqd);include/uapi/drm/amdgpu_drm.h +11
-1@@ -460,6 +460,17 @@ struct drm_amdgpu_userq_mqd_compute_gfx11 {* to get the size. */ __u64 eop_va; +/** +* @ctx_save_area_va: Virtual address of the GPU memory for save/restore buffer. +* This must be from a separate GPU object, and use AMDGPU_INFO IOCTL +* to get the size. This includes control stack, wave context and debugger memory. +*/ +__u64 ctx_save_area_va; +/** +* @ctx_save_area_size: Total size (in bytes) allocated for save/restore buffer. +* Use AMDGPU_INFO IOCTL to get the size. +*/ +__u32 ctx_save_area_size; };/* userq signal/wait ioctl */ --2.49.0
PATCH v5 10/11 drm/amdgpu: Add ioctl to set level2 handler
In reply to Lijo LazarAdd ioctl to set tba/tma of level2 trap handler
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 - drivers/gpu/drm/amd/amdgpu/amdgpu_cwsr.c | 105 +++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_cwsr.h | 11 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 2 + include/uapi/drm/amdgpu_drm.h | 24 ++++++ 5 files changed, 141 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -1
@@ -1575,7 +1575,6 @@ int amdgpu_enable_vblank_kms(struct drm_crtc *crtc);void amdgpu_disable_vblank_kms (struct drm_crtc *crtc);int amdgpu_info_ioctl (struct drm_device *dev,void *data,struct drm_file *filp); -/* * functions used by amdgpu_encoder.c */
drivers/gpu/drm/amd/amdgpu/amdgpu_cwsr.c +105 -0
109 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_cwsr.h +10 -1
@@ -31,7 +31,7 @@ struct amdgpu_device;struct amdgpu_vm ;/** -* struct amdgpu_cwsr_obj - CWSR (Compute Wave Save Restore) buffer tracking +* struct amdgpu_cwsr_trap_obj - CWSR (Compute Wave Save Restore) buffer tracking * @bo: Buffer object for CWSR area * @bo_va: Buffer object virtual address mapping */
@@ -62,6 +62,11 @@ struct amdgpu_cwsr_params {uint32_t cwsr_sz; }; +struct amdgpu_cwsr_usr_addr { +uint64_t addr; +uint32_t size; +}; +int amdgpu_cwsr_init (struct amdgpu_device *adev);void amdgpu_cwsr_fini (struct amdgpu_device *adev);
@@ -84,4 +89,8 @@ static inline bool amdgpu_cwsr_has_dbg_wa(struct amdgpu_device *adev) return gc_ver >= IP_VERSION(11, 0, 0) && gc_ver <= IP_VERSION(11, 0, 3); } + +int amdgpu_cwsr_ioctl (struct drm_device *dev,void *data, +struct drm_file *filp); +#endif
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2 -0
@@ -53,6 +53,7 @@#include "amdgpu_sched.h" #include "amdgpu_xgmi.h" #include "amdgpu_userq.h" +#include "amdgpu_cwsr.h" #include "amdgpu_userq_fence.h" #include "../amdxcp/amdgpu_xcp_drv.h"
@@ -3074,6 +3075,7 @@ const struct drm_ioctl_desc amdgpu_ioctls_kms[] = {DRM_IOCTL_DEF_DRV (AMDGPU_SCHED , amdgpu_sched_ioctl,DRM_MASTER ),DRM_IOCTL_DEF_DRV (AMDGPU_BO_LIST , amdgpu_bo_list_ioctl,DRM_AUTH |DRM_RENDER_ALLOW ),DRM_IOCTL_DEF_DRV (AMDGPU_FENCE_TO_HANDLE , amdgpu_cs_fence_to_handle_ioctl,DRM_AUTH |DRM_RENDER_ALLOW ), +DRM_IOCTL_DEF_DRV (AMDGPU_CWSR , amdgpu_cwsr_ioctl,DRM_AUTH |DRM_RENDER_ALLOW ),/* KMS */ DRM_IOCTL_DEF_DRV (AMDGPU_GEM_MMAP , amdgpu_gem_mmap_ioctl,DRM_AUTH |DRM_RENDER_ALLOW ), DRM_IOCTL_DEF_DRV(AMDGPU_GEM_WAIT_IDLE, amdgpu_gem_wait_idle_ioctl, DRM_AUTH|DRM_RENDER_ALLOW),
include/uapi/drm/amdgpu_drm.h +24 -0
@@ -58,6 +58,7 @@ extern "C" {#define DRM_AMDGPU_USERQ_SIGNAL 0x17#define DRM_AMDGPU_USERQ_WAIT 0x18#define DRM_AMDGPU_GEM_LIST_HANDLES 0x19 +#define DRM_AMDGPU_CWSR 0x20#define DRM_IOCTL_AMDGPU_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_CREATE, union drm_amdgpu_gem_create)#define DRM_IOCTL_AMDGPU_GEM_MMAP DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_MMAP, union drm_amdgpu_gem_mmap)
@@ -79,6 +80,8 @@ extern "C" {#define DRM_IOCTL_AMDGPU_USERQ_SIGNAL DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_USERQ_SIGNAL, struct drm_amdgpu_userq_signal)#define DRM_IOCTL_AMDGPU_USERQ_WAIT DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_USERQ_WAIT, struct drm_amdgpu_userq_wait)#define DRM_IOCTL_AMDGPU_GEM_LIST_HANDLES DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_LIST_HANDLES, struct drm_amdgpu_gem_list_handles) +#define DRM_IOCTL_AMDGPU_CWSR \ + DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_CWSR, union drm_amdgpu_cwsr)/** * DOC: memory domains
@@ -1675,6 +1678,27 @@ struct drm_amdgpu_info_cwsr {__u32 min_save_area_size; }; +/* cwsr ioctl */ +#define AMDGPU_CWSR_OP_SET_L2_TRAP 1 + +struct drm_amdgpu_cwsr_in { +/* AMDGPU_CWSR_OP_* */ +__u32 op; +struct { +/* Level 2 trap handler base address */ +__u64 tba_va; +/* Level 2 trap handler buffer size (in bytes) */ +__u32 tba_sz; +/* Level 2 trap memory buffer address */ +__u64 tma_va; +/* Level 2 trap memory buffer size (in bytes) */ +__u32 tma_sz; + } l2trap; +}; + +union drm_amdgpu_cwsr { +struct drm_amdgpu_cwsr_in in; +};/* * Supported GPU families */
Signature · 1 line
2.49.0
PATCH v5 11/11 drm/amdgpu: Add interface to set debug trap flag
In reply to Lijo LazarAdd interface to set debugger trap flag in TMA region.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cwsr.c | 19 ++++++++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_cwsr.h | 3 +++ 2 files changed, 21 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cwsr.c +18 -1
@@ -19,7 +19,6 @@* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. */ -#include <drm/drm_exec.h> #include "amdgpu.h"
@@ -609,4 +608,22 @@ int amdgpu_cwsr_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) }return r; +} + +int amdgpu_cwsr_set_trap_debug_flag (struct amdgpu_device *adev, +struct amdgpu_cwsr_trap_obj *cwsr_obj, +bool enabled) +{ +uint64_t *l1tma; + +if (!amdgpu_cwsr_is_enabled (adev)) +return -EOPNOTSUPP ; + +if (!cwsr_obj) +return -EINVAL ; + + l1tma = (uint64_t *)(cwsr_obj->tma_cpu_addr); + l1tma[2 ] = enabled; + +return 0 ; }
drivers/gpu/drm/amd/amdgpu/amdgpu_cwsr.h +3 -0
@@ -92,5 +92,8 @@ static inline bool amdgpu_cwsr_has_dbg_wa(struct amdgpu_device *adev)int amdgpu_cwsr_ioctl (struct drm_device *dev,void *data,struct drm_file *filp); +int amdgpu_cwsr_set_trap_debug_flag (struct amdgpu_device *adev, +struct amdgpu_cwsr_trap_obj *cwsr_obj, +bool enabled);#endif
Signature · 1 line
2.49.0
Re: [PATCH v5 11/11] drm/amdgpu: Add interface to set debug trap flag
Quoted 4 lines · Lijo Lazar
Add interface to set debugger trap flag in TMA region.
Signed-off-by Lijo Lazar <[email protected]>
Quoted 57 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cwsr.c | 19 ++++++++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_cwsr.h | 3 +++ 2 files changed, 21 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_cwsr.c +18
-1@@ -19,7 +19,6 @@* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. */ -#include <drm/drm_exec.h> #include "amdgpu.h" @@ -609,4 +608,22 @@ int amdgpu_cwsr_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) }return r; +} + +int amdgpu_cwsr_set_trap_debug_flag (struct amdgpu_device *adev, +struct amdgpu_cwsr_trap_obj *cwsr_obj, +bool enabled) +{ +uint64_t *l1tma; + +if (!amdgpu_cwsr_is_enabled (adev)) +return -EOPNOTSUPP ; + +if (!cwsr_obj) +return -EINVAL ; + + l1tma = (uint64_t *)(cwsr_obj->tma_cpu_addr); + l1tma[2 ] = enabled; + +return 0 ; }drivers/gpu/drm/amd/amdgpu/amdgpu_cwsr.h +3
-1@@ -92,5 +92,8 @@ static inline bool amdgpu_cwsr_has_dbg_wa(struct amdgpu_device *adev)int amdgpu_cwsr_ioctl (struct drm_device *dev,void *data,struct drm_file *filp); +int amdgpu_cwsr_set_trap_debug_flag (struct amdgpu_device *adev, +struct amdgpu_cwsr_trap_obj *cwsr_obj, +bool enabled);#endif --2.49.0