Add srbm selection to both umr and kernel
Subsystems (2)
PATCH 1/1 Add srbm selection to both umr and kernel
A bit unconventional since these two patches are for two different trees but they're related so it's nice to review them as a pair.
They add the ability to select srbm banks via debugfs and the corresponding support in umr. The umr patch also adds some bug fixes related to how options were filtering down into the library.
Cheers,
Tom
Quoted 1 line
From
236e1b84a6a8a3a91cf487a73fe4dd48aa245b3bMon Sep 17 00:00:00 2001
From: Tom St Denis <[email protected]>
Date: Thu, 29 Mar 2018 08:41:28 -0400
Subject: [PATCH umr] Add support for SRBM selection (v3)
Also clean up grbm debugfs addressing by hoisting the inlined copies of the logic into a new function that is also used by srbm selection.
(v2) Drop 'x' support for SRBM and swap order of me/pipe/queue
to match what Andrey had already written for the kernel.
(v3) Fix various places which didn't use asic->options to get
at options.
--- doc/umr.1 | 6 ++++-- src/app/main.c | 30 ++++++++++++++++++++++------ src/app/scan.c | 23 ++++++++++------------ src/app/scan_log.c | 4 ++-- src/app/set_bit.c | 19 ++++++++---------- src/app/set_reg.c | 14 +++++--------- src/app/top.c | 4 ++-- src/lib/CMakeLists.txt | 1 + src/lib/umr_apply_bank_address.c | 42 ++++++++++++++++++++++++++++++++++++++++ src/umr.h | 23 ++++++++++++++++++---- 10 files changed, 117 insertions(+), 49 deletions(-) create mode 100644 src/lib/umr_apply_bank_address.c
doc/umr.1 +4 -2
@@ -12,8 +12,10 @@ Pick a device instance to work with. Defaults to the 0'th device. The instance refers to a directory under .B /sys/kernel/debug/dri/ where 0 is the first card probed. -.IP "--bank, -b <se_bank> <sh_bank> <instance>" -Select a GFX INSTANCE/SH/SE bank in decimal. Can use 'x' to denote a broadcast selection. +.IP "--bank, -b <se> <sh> <instance>" +Select a GRBM se/sh/instance bank in decimal. Can use 'x' to denote a broadcast selection. +.IP "--sbank, -sb <me> <pipe> <queue>" +Select a SRBM me/pipe/queue bank in decimal. .IP "--force -f <number>" Force a PCIE Device ID in hex or by asic name. This is used in case the amdgpu driver is not yet loaded or a display is not yet attached. A '@' prefix will specify a path to
src/app/main.c +24 -6
@@ -150,20 +150,35 @@ int main(int argc, char **argv)if (!asic) asic =get_asic ();if (i +3 < argc) { - options.se_bank = argv[i+1 ][0 ] =='x' ?0x3FF :atoi (argv[i+1 ]); - options.sh_bank = argv[i+2 ][0 ] =='x' ?0x3FF :atoi (argv[i+2 ]); - options.instance_bank = argv[i+3 ][0 ] =='x' ?0x3FF :atoi (argv[i+3 ]); -if ((options.se_bank !=0x3FF && options.se_bank >= asic->config.gfx.max_shader_engines) || - (options.sh_bank !=0x3FF && options.sh_bank >= asic->config.gfx.max_sh_per_se)) { + options.bank.grbm.se = argv[i+1 ][0 ] =='x' ?0x3FF :atoi (argv[i+1 ]); + options.bank.grbm.sh = argv[i+2 ][0 ] =='x' ?0x3FF :atoi (argv[i+2 ]); + options.bank.grbm.instance = argv[i+3 ][0 ] =='x' ?0x3FF :atoi (argv[i+3 ]); +if ((options.bank.grbm.se !=0x3FF && options.bank.grbm.se >= asic->config.gfx.max_shader_engines) || + (options.bank.grbm.sh !=0x3FF && options.bank.grbm.sh >= asic->config.gfx.max_sh_per_se)) {printf ("Invalid bank selection for specific ASIC\n" );return EXIT_FAILURE ; } options.use_bank =1 ; i +=3 ; + asic->options = options; }else {printf ("--bank requires three parameters\n" );return EXIT_FAILURE ; } + }else if (!strcmp (argv[i],"--sbank" ) || !strcmp (argv[i],"-sb" )) { +if (!asic) + asic =get_asic (); +if (i +3 < argc) { + options.bank.srbm.me =atoi (argv[i+1 ]); + options.bank.srbm.pipe =atoi (argv[i+2 ]); + options.bank.srbm.queue =atoi (argv[i+3 ]); + options.use_bank =2 ; + i +=3 ; + asic->options = options; + }else { +printf ("--sbank requires three parameters\n" ); +return EXIT_FAILURE ; + } }else if (!strcmp (argv[i],"--force" ) || !strcmp (argv[i],"-f" )) {if (i +1 < argc) {if (sscanf (argv[i+1 ],"0x%lx" , &options.forcedid) ==0 ) {
@@ -458,6 +473,8 @@ int main(int argc, char **argv)printf ("--option requires one parameter\n" );return EXIT_FAILURE ; } +if (asic) + asic->options = options; }else if (!strcmp (argv[i],"--update" ) || !strcmp (argv[i],"-u" )) {if (!asic) asic =get_asic ();
@@ -473,7 +490,8 @@ int main(int argc, char **argv)"\n\t--instance, -i <number>\n\t\tSelect a device instance to investigate. (default: 0)" "\n\t\tThe instance is the directory name under /sys/kernel/debug/dri/" "\n\t\tof the card you want to work with.\n" -"\n\t--bank, -b <se_bank> <sh_bank> <instance>\n\t\tSelect a GFX INSTANCE/SH/SE bank in decimal. Can use 'x' to denote broadcast.\n" +"\n\t--bank, -b <se> <sh> <instance>\n\t\tSelect a GRBM se/sh/instance bank in decimal. Can use 'x' to denote broadcast.\n" +"\n\t--sbank, -sb <me> <pipe> <queue>\n\t\tSelect a SRBM me/pipe/queue bank in decimal.\n" "\n\t--force, -f <number>\n\t\tForce a PCIE DID number in hex or asic name. Useful if amdgpu is" "\n\t\tnot loaded or a display is not attached.\n" "\n\t--pci <device>"
src/app/scan.c +10 -13
@@ -38,7 +38,7 @@ int umr_scan_asic(struct umr_asic *asic, char *asicname, char *ipname, char *reg first =1 ;for (j =0 ; j < asic->blocks[i]->no_regs; j++) {if (!regname[0 ] || !strcmp (regname,"*" ) || !strcmp (regname, asic->blocks[i]->regs[j].regname) || - (options.many &&strstr (asic->blocks[i]->regs[j].regname, regname))) { + (asic->options.many &&strstr (asic->blocks[i]->regs[j].regname, regname))) {// only grant if any regspec matches otherwise it's a waste if (first && asic->blocks[i]->grant) { first =0 ;
@@ -56,7 +56,7 @@ int umr_scan_asic(struct umr_asic *asic, char *asicname, char *ipname, char *regcase REG_DIDT : fd = asic->fd.didt; scale =1 ;break ;case REG_PCIE : fd = asic->fd.pcie; scale =1 ;break ;case REG_SMC : -if (options.read_smc) { +if (asic->options.read_smc) { fd = asic->fd.smc; scale =1 ; }else {continue ;
@@ -65,12 +65,8 @@ int umr_scan_asic(struct umr_asic *asic, char *asicname, char *ipname, char *regdefault :return -1 ; } -if (options.use_bank && asic->blocks[i]->regs[j].type ==REG_MMIO ) - addr = - (1ULL <<62 ) | - (((uint64_t )options.se_bank) <<24 ) | - (((uint64_t )options.sh_bank) <<34 ) | - (((uint64_t )options.instance_bank) <<44 ); +if (asic->blocks[i]->regs[j].type ==REG_MMIO ) + addr =umr_apply_bank_selection_address (asic);else addr =0 ;
@@ -87,17 +83,18 @@ int umr_scan_asic(struct umr_asic *asic, char *asicname, char *ipname, char *reg goto error; } }else if (asic->blocks[i]->regs[j].type ==REG_MMIO || asic->blocks[i]->regs[j].type ==REG_SMC ) { -if (options.use_bank) -umr_grbm_select_index (asic, options.se_bank, options.sh_bank, options.instance_bank); +// TODO: Add nokernel version of srbm select +if (asic->options.use_bank ==1 ) +umr_grbm_select_index (asic, asic->options.bank.grbm.se, asic->options.bank.grbm.sh, asic->options.bank.grbm.instance); asic->blocks[i]->regs[j].value =umr_read_reg (asic, asic->blocks[i]->regs[j].addr * (asic->blocks[i]->regs[j].type ==REG_MMIO ?4 :1 ), asic->blocks[i]->regs[j].type); -if (options.use_bank) +if (asic->options.use_bank ==1 )umr_grbm_select_index (asic,0xFFFFFFFF ,0xFFFFFFFF ,0xFFFFFFFF ); }if (regname[0 ]) { -if (options.named) +if (asic->options.named)printf ("%s%s.%s%s => " ,CYAN , asic->blocks[i]->ipname, asic->blocks[i]->regs[j].regname,RST );printf ("%s0x%08lx%s\n" ,YELLOW , (unsigned long )asic->blocks[i]->regs[j].value,RST ); -if (options.bitfields) +if (asic->options.bitfields)for (k =0 ; k < asic->blocks[i]->regs[j].no_bits; k++) {uint32_t v; v = (1UL << (asic->blocks[i]->regs[j].bits[k].stop +1 - asic->blocks[i]->regs[j].bits[k].start)) -1 ;
src/app/scan_log.c +2 -2
@@ -109,7 +109,7 @@ void umr_scan_log(struct umr_asic *asic) asic->asicname, iplist[regno]->ipname, reglist[regno]->regname, (unsigned long )delta, (unsigned long)value); -if (options.bitfields) +if (asic->options.bitfields)for (k =0 ; k < reglist[regno]->no_bits; k++) {uint32_t v; v = (1UL << (reglist[regno]->bits[k].stop +1 - reglist[regno]->bits[k].start)) -1 ;
@@ -127,7 +127,7 @@ out: } }fclose (f); -if (options.empty_log) { +if (asic->options.empty_log) { f =fopen ("/sys/kernel/debug/tracing/trace" ,"w" );if (f) {fprintf (f,"foo\n" );
src/app/set_bit.c +8 -11
@@ -68,12 +68,8 @@ int umr_set_register_bit(struct umr_asic *asic, char *regpath, char *regvalue) } } -if (options.use_bank && asic->blocks[i]->regs[j].type ==REG_MMIO ) - addr = - (1ULL <<62 ) | - (((uint64_t )options.se_bank) <<24 ) | - (((uint64_t )options.sh_bank) <<34 ) | - (((uint64_t )options.instance_bank) <<44 ); +if (asic->blocks[i]->regs[j].type ==REG_MMIO ) + addr =umr_apply_bank_selection_address (asic);else addr =0 ;
@@ -87,7 +83,7 @@ int umr_set_register_bit(struct umr_asic *asic, char *regpath, char *regvalue)lseek (fd, addr | (asic->blocks[i]->regs[j].addr<<2 ),SEEK_SET );write (fd, ©,4 ); -if (!options.quiet)printf ("%s <= 0x%08lx\n" , regpath, (unsigned long )copy); +if (!asic->options.quiet)printf ("%s <= 0x%08lx\n" , regpath, (unsigned long )copy);if (asic->blocks[i]->release) {if (asic->blocks[i]->release (asic)) {
@@ -95,14 +91,15 @@ int umr_set_register_bit(struct umr_asic *asic, char *regpath, char *regvalue) } } }else if (asic->blocks[i]->regs[j].type ==REG_MMIO ) { -if (options.use_bank && options.no_kernel) -umr_grbm_select_index (asic, options.se_bank, options.sh_bank, options.instance_bank); +// TODO: Add nokernel version of srbm_select +if (asic->options.use_bank ==1 && asic->options.no_kernel) +umr_grbm_select_index (asic, asic->options.bank.grbm.se, asic->options.bank.grbm.sh, asic->options.bank.grbm.instance); copy = asic->pci.mem[asic->blocks[i]->regs[j].addr] & ~mask; copy |= (value << asic->blocks[i]->regs[j].bits[k].start) & mask; asic->pci.mem[asic->blocks[i]->regs[j].addr] = copy; -if (options.use_bank && options.no_kernel) +if (asic->options.use_bank && asic->options.no_kernel)umr_grbm_select_index (asic,0xFFFFFFFF ,0xFFFFFFFF ,0xFFFFFFFF ); -if (!options.quiet)printf ("%s <= 0x%08lx\n" , regpath, (unsigned long )copy); +if (!asic->options.quiet)printf ("%s <= 0x%08lx\n" , regpath, (unsigned long )copy); }return 0 ; }
src/app/set_reg.c +5 -9
@@ -65,12 +65,8 @@ int umr_set_register(struct umr_asic *asic, char *regpath, char *regvalue) } } -if (options.use_bank && asic->blocks[i]->regs[j].type ==REG_MMIO ) - addr = - (1ULL <<62 ) | - (((uint64_t )options.se_bank) <<24 ) | - (((uint64_t )options.sh_bank) <<34 ) | - (((uint64_t )options.instance_bank) <<44 ); +if (asic->blocks[i]->regs[j].type ==REG_MMIO ) + addr =umr_apply_bank_selection_address (asic);else addr =0 ;
@@ -83,10 +79,10 @@ int umr_set_register(struct umr_asic *asic, char *regpath, char *regvalue) } } }else if (asic->blocks[i]->regs[j].type ==REG_MMIO ) { -if (options.use_bank) -umr_grbm_select_index (asic, options.se_bank, options.sh_bank, options.instance_bank); +if (asic->options.use_bank) +umr_grbm_select_index (asic, asic->options.bank.grbm.se, asic->options.bank.grbm.sh, asic->options.bank.grbm.instance); asic->pci.mem[asic->blocks[i]->regs[j].addr] = value; -if (options.use_bank) +if (asic->options.use_bank)umr_grbm_select_index (asic,0xFFFFFFFF ,0xFFFFFFFF ,0xFFFFFFFF ); }return 0 ;
src/app/top.c +2 -2
@@ -1043,8 +1043,8 @@ static void top_build_vi_program(struct umr_asic *asic)// which SE to read ... regname =calloc (1 ,64 ); -if (options.use_bank) -snprintf (regname,63 ,"mmGRBM_STATUS_SE%d" , options.se_bank); +if (options.use_bank ==1 ) +snprintf (regname,63 ,"mmGRBM_STATUS_SE%d" , options.bank.grbm.se);else snprintf (regname,63 ,"mmGRBM_STATUS" );
src/lib/CMakeLists.txt +1 -0
@@ -24,6 +24,7 @@ add_library(umrcore STATIC sq_cmd_halt_waves.c transfer_soc15.c wave_status.c + umr_apply_bank_address.c update.c version.c $<TARGET_OBJECTS:asic> $<TARGET_OBJECTS:ip>
src/lib/umr_apply_bank_address.c new file +42 -0
42 lines not on this page · raw message
src/umr.h +19 -4
@@ -192,10 +192,22 @@ struct umr_options { verbose, halt_waves, no_kernel; -unsigned - instance_bank, - se_bank, - sh_bank; + +union { +struct { +unsigned + instance, + se, + sh; + } grbm; +struct { +unsigned + me, + queue, + pipe; + } srbm; + } bank; +long forcedid;char *scanblock,
@@ -561,6 +573,9 @@ uint32_t umr_bitslice_compose_value(struct umr_asic *asic, struct umr_reg *reg,uint32_t umr_bitslice_compose_value_by_name (struct umr_asic *asic,char *reg,char *bitname,uint32_t regvalue);uint32_t umr_bitslice_compose_value_by_name_by_ip (struct umr_asic *asic,char *ip,char *regname,char *bitname,uint32_t regvalue); +// bank switching +uint64_t umr_apply_bank_selection_address (struct umr_asic *asic); +// select a GRBM_GFX_IDX int umr_grbm_select_index (struct umr_asic *asic,uint32_t se,uint32_t sh,uint32_t instance);
Signature · 1 line
2.14.3
Quoted 1 line
From
38cb2961c04c1fb0737b3118a2c54a4051fb8c31Mon Sep 17 00:00:00 2001
From: Andrey Grodzovsky <[email protected]>
Date: Thu, 29 Mar 2018 09:09:39 -0400
Subject: drm/amdgpu: Add support for SRBM selection
Also remove code duplication in write and read regs functions. This also fixes potential missing unlock in amdgpu_debugfs_regs_write in case get_user would fail.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 + drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 117 ++++++++++------------------ drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c | 7 ++ drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c | 7 ++ drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 7 ++ drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 7 ++ 6 files changed, 70 insertions(+), 77 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -0
@@ -890,6 +890,7 @@ struct amdgpu_gfx_funcs {void (*read_wave_data)(struct amdgpu_device *adev,uint32_t simd,uint32_t wave,uint32_t *dst,int *no_fields);void (*read_wave_vgprs)(struct amdgpu_device *adev,uint32_t simd,uint32_t wave,uint32_t thread,uint32_t start,uint32_t size,uint32_t *dst);void (*read_wave_sgprs)(struct amdgpu_device *adev,uint32_t simd,uint32_t wave,uint32_t start,uint32_t size,uint32_t *dst); +void (*select_me_pipe_q)(struct amdgpu_device *adev,u32 me,u32 pipe,u32 queue); };struct amdgpu_ngg_buf {
@@ -1815,6 +1816,7 @@ amdgpu_get_sdma_instance(struct amdgpu_ring *ring)#define amdgpu_gfx_select_se_sh (adev, se, sh, instance) (adev)->gfx.funcs->select_se_sh((adev), (se), (sh), (instance))#define amdgpu_gds_switch (adev, r, v, d, w, a) (adev)->gds.funcs->patch_gds_switch((r), (v), (d), (w), (a))#define amdgpu_psp_check_fw_loading_status (adev, i) (adev)->firmware.funcs->check_fw_loading_status((adev), (i)) +#define amdgpu_gfx_select_me_pipe_q (adev, me, pipe, q) (adev)->gfx.funcs->select_me_pipe_q((adev), (me), (pipe), (q))/* Common functions */ int amdgpu_device_gpu_recover(struct amdgpu_device *adev,
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +40 -77
162 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c +7 -0
@@ -3061,11 +3061,18 @@ static void gfx_v6_0_read_wave_sgprs(struct amdgpu_device *adev, uint32_t simd, start + SQIND_WAVE_SGPRS_OFFSET, size, dst); } +static void gfx_v6_0_select_me_pipe_q (struct amdgpu_device *adev, +u32 me,u32 pipe,u32 q) +{ +DRM_INFO ("Not implemented\n" ); +} +static const struct amdgpu_gfx_funcs gfx_v6_0_gfx_funcs = { .get_gpu_clock_counter = &gfx_v6_0_get_gpu_clock_counter, .select_se_sh = &gfx_v6_0_select_se_sh, .read_wave_data = &gfx_v6_0_read_wave_data, .read_wave_sgprs = &gfx_v6_0_read_wave_sgprs, + .select_me_pipe_q = &gfx_v6_0_select_me_pipe_q };static int gfx_v6_0_early_init (void *handle)
drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c +7 -0
@@ -4270,11 +4270,18 @@ static void gfx_v7_0_read_wave_sgprs(struct amdgpu_device *adev, uint32_t simd, start + SQIND_WAVE_SGPRS_OFFSET, size, dst); } +static void gfx_v7_0_select_me_pipe_q (struct amdgpu_device *adev, +u32 me,u32 pipe,u32 q) +{ +cik_srbm_select (adev, me, pipe, q,0 ); +} +static const struct amdgpu_gfx_funcs gfx_v7_0_gfx_funcs = { .get_gpu_clock_counter = &gfx_v7_0_get_gpu_clock_counter, .select_se_sh = &gfx_v7_0_select_se_sh, .read_wave_data = &gfx_v7_0_read_wave_data, .read_wave_sgprs = &gfx_v7_0_read_wave_sgprs, + .select_me_pipe_q = &gfx_v7_0_select_me_pipe_q };static const struct amdgpu_rlc_funcs gfx_v7_0_rlc_funcs = {
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +7 -0
@@ -3475,6 +3475,12 @@ static void gfx_v8_0_select_se_sh(struct amdgpu_device *adev,WREG32 (mmGRBM_GFX_INDEX, data); } +static void gfx_v8_0_select_me_pipe_q (struct amdgpu_device *adev, +u32 me,u32 pipe,u32 q) +{ +vi_srbm_select (adev, me, pipe, q,0 ); +} +static u32 gfx_v8_0_get_rb_active_bitmap (struct amdgpu_device *adev) {u32 data, mask;
@@ -5442,6 +5448,7 @@ static const struct amdgpu_gfx_funcs gfx_v8_0_gfx_funcs = { .select_se_sh = &gfx_v8_0_select_se_sh, .read_wave_data = &gfx_v8_0_read_wave_data, .read_wave_sgprs = &gfx_v8_0_read_wave_sgprs, + .select_me_pipe_q = &gfx_v8_0_select_me_pipe_q };static int gfx_v8_0_early_init (void *handle)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +7 -0
@@ -998,12 +998,19 @@ static void gfx_v9_0_read_wave_vgprs(struct amdgpu_device *adev, uint32_t simd, start + SQIND_WAVE_VGPRS_OFFSET, size, dst); } +static void gfx_v9_0_select_me_pipe_q (struct amdgpu_device *adev, +u32 me,u32 pipe,u32 q) +{ +soc15_grbm_select (adev, me, pipe, q,0 ); +} +static const struct amdgpu_gfx_funcs gfx_v9_0_gfx_funcs = { .get_gpu_clock_counter = &gfx_v9_0_get_gpu_clock_counter, .select_se_sh = &gfx_v9_0_select_se_sh, .read_wave_data = &gfx_v9_0_read_wave_data, .read_wave_sgprs = &gfx_v9_0_read_wave_sgprs, .read_wave_vgprs = &gfx_v9_0_read_wave_vgprs, + .select_me_pipe_q = &gfx_v9_0_select_me_pipe_q };static void gfx_v9_0_gpu_early_init (struct amdgpu_device *adev)
Signature · 1 line
2.7.4
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): a626c1cf-b48a-b317-e1e8-78ba5cff18f3-5C7GfCeVMHo@public.gmane.org
Alex Deucher
Reviewed-byPatches are:
Quoted 7 lines · Tom St Denis
A bit unconventional since these two patches are for two different trees but they're related so it's nice to review them as a pair.
They add the ability to select srbm banks via debugfs and the corresponding support in umr. The umr patch also adds some bug fixes related to how options were filtering down into the library.
Quoted 8 lines
Cheers,
Tom_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx