Add 'no_kernel' option
PATCH 1/1 Add 'no_kernel' option
This flag allows umr to perform some operations it would normally need the kernel for in userspace. This is useful if the kernel driver is misbehaving. Don't use this on a healthy system as it could invoke race conditions.
This flag enables userland activities such as
- reading/writing MMIO registers (with bank selection)
- reading wave status and SGPR registers
Signed-off-by Tom St Denis <[email protected]>
--- doc/umr.1 | 5 +++ src/app/main.c | 5 ++- src/app/scan.c | 6 +++- src/app/set_bit.c | 4 +++ src/app/set_reg.c | 4 +++ src/lib/discover.c | 49 +++++++++++++++++---------- src/lib/mmio.c | 57 ++++++++++++++++++++++++++++++- src/lib/read_sgpr.c | 58 +++++++++++++++++++++++++------- src/lib/wave_status.c | 92 ++++++++++++++++++++++++++++++++++++++++++--------- src/umr.h | 23 +++++++++++-- 10 files changed, 252 insertions(+), 51 deletions(-)
doc/umr.1 +5 -0
@@ -138,6 +138,11 @@ separated strings. Enable colour output for --top command, scales from blue, green, yellow, to red. Also accepted is 'use_color'. +.B no_kernel + Disable using kernel files to access the device. Implies ''use_pci''. This is meant to + be used only if the KMD is hung or otherwise not working correctly. Using it on live systems + may result in race conditions. + .SH "Notes" - The "Waves" field in the DRM section of --top only works if GFX PG has been disabled. Otherwise,
src/app/main.c +4 -1
@@ -109,6 +109,9 @@ static void parse_options(char *str) options.quiet =1 ; }else if (!strcmp (option,"follow_ib" )) { options.follow_ib =1 ; + }else if (!strcmp (option,"no_kernel" )) { + options.no_kernel =1 ; + options.use_pci =1 ; }else {printf ("error: Unknown option [%s]\n" , option);exit (EXIT_FAILURE );
@@ -413,7 +416,7 @@ int main(int argc, char **argv)"\n\t\tRead 'size' bytes (in hex) from a given address (in hex) to stdout. Optionally" "\n\t\tspecify the VMID (in decimal) treating the address as a virtual address instead.\n" "\n\t--option -O <string>[,<string>,...]\n\t\tEnable various flags: risky, bits, bitsfull, empty_log, follow, named, many," -"\n\t\tuse_pci, use_colour, read_smc, quiet.\n" +"\n\t\tuse_pci, use_colour, read_smc, quiet, no_kernel.\n" "\n\n", UMR_BUILD_VER, UMR_BUILD_REV);exit (EXIT_SUCCESS ); }else {
src/app/scan.c +5 -1
@@ -88,7 +88,11 @@ 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].value = asic->pci.mem[asic->blocks[i]->regs[j].addr]; +if (options.use_bank && options.no_kernel) +umr_grbm_select_index (asic, options.se_bank, options.sh_bank, options.instance_bank); + asic->blocks[i]->regs[j].value =umr_read_reg (asic, asic->blocks[i]->regs[j].addr *4 ); +if (options.use_bank && options.no_kernel) +umr_grbm_select_index (asic,0xFFFFFFFF ,0xFFFFFFFF ,0xFFFFFFFF ); }if (regname[0 ]) {if (options.named)
src/app/set_bit.c +4 -0
@@ -96,9 +96,13 @@ 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); 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) +umr_grbm_select_index (asic,0xFFFFFFFF ,0xFFFFFFFF ,0xFFFFFFFF );if (!options.quiet)printf ("%s <= 0x%08lx\n" , regpath, (unsigned long )copy); }return 0 ;
src/app/set_reg.c +4 -0
@@ -84,7 +84,11 @@ 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 && options.no_kernel) +umr_grbm_select_index (asic, options.se_bank, options.sh_bank, options.instance_bank); asic->pci.mem[asic->blocks[i]->regs[j].addr] = value; +if (options.use_bank && options.no_kernel) +umr_grbm_select_index (asic,0xFFFFFFFF ,0xFFFFFFFF ,0xFFFFFFFF ); }return 0 ; }
src/lib/discover.c +31 -18
55 lines not on this page · raw message
src/lib/mmio.c +56 -1
65 lines not on this page · raw message
src/lib/read_sgpr.c +46 -12
68 lines not on this page · raw message
src/lib/wave_status.c +76 -16
110 lines not on this page · raw message
src/umr.h +21 -2
@@ -171,7 +171,8 @@ struct umr_options { use_colour, read_smc, quiet, - follow_ib; + follow_ib, + no_kernel;unsigned instance_bank, se_bank,
@@ -453,15 +454,33 @@ int umr_read_sgprs(struct umr_asic *asic, struct umr_wave_status *ws, uint32_t *int umr_read_sensor (struct umr_asic *asic,int sensor,void *dst,int *size);/* mmio helpers */ +// init the mmio lookup table +int umr_create_mmio_accel (struct umr_asic *asic); + +// find the word address of a register uint32_t umr_find_reg (struct umr_asic *asic,char *regname); + +// find the register data for a register struct umr_reg *umr_find_reg_data (struct umr_asic *asic,char *regname); + +// read/write a 32-bit register given a BYTE address uint32_t umr_read_reg (struct umr_asic *asic,uint64_t addr);int umr_write_reg (struct umr_asic *asic,uint64_t addr,uint32_t value); + +// read/write a register given a name uint32_t umr_read_reg_by_name (struct umr_asic *asic,char *name);int umr_write_reg_by_name (struct umr_asic *asic,char *name,uint32_t value); + +// slice a full register into bits (shifted into LSB) uint32_t umr_bitslice_reg (struct umr_asic *asic,struct umr_reg *reg,char *bitname,uint32_t regvalue);uint32_t umr_bitslice_reg_by_name (struct umr_asic *asic,char *regname,char *bitname,uint32_t regvalue); -int umr_create_mmio_accel (struct umr_asic *asic); + +// compose a 32-bit register with a value and a bitfield +uint32_t umr_bitslice_compose_value (struct umr_asic *asic,struct umr_reg *reg,char *bitname,uint32_t regvalue); +uint32_t umr_bitslice_compose_value_by_name (struct umr_asic *asic,char *reg,char *bitname,uint32_t regvalue); + +// select a GRBM_GFX_IDX +int umr_grbm_select_index (struct umr_asic *asic,uint32_t se,uint32_t sh,uint32_t instance);/* IB/ring decoding/dumping/etc */ void umr_print_decode (struct umr_asic *asic,struct umr_ring_decoder *decoder,uint32_t ib);
Signature · 6 lines
2.12.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx