Various upgrades to umr including VM/MMHUB decoding
This patch series reflects a slew of changes that fell out of team meetings with mesa/kmd members over the last week.
We remove the "risky" option and the --print command since it's more annoying than helpful.
We add the ability to specify the VMID in hex with --vram which is handy with the last patch since you can specify which VM hub to use in hex easier than in decimal.
The third patch includes various small cleanups found by static analysis and code review.
The last patch includes two new features which were written at the same time and were a bit tricky to separate (more effort than worth). First, we add the ability to halt waves when reading them which should help reading consistent data. Next we add the ability to decode multimedia IBs from the UVD/VCN rings. Next we fix using the 'mmMC_VM_FB_LOCATION' register which was traditionally zero on VI (and below) but now has non-zero values which broke VM decoding. Tested on Carrizo/Polaris/Raven.
Finally, the last patch adds the ability to specify a 'verbose' option which prints out VM decoding information handy for debugging both umr and the kmd.
_______________________________________________
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): [email protected]
PATCH 1/4 Remove 'risky' option --print command.
--- demo/update/read_sensor.sh | 2 +- doc/umr.1 | 6 ------ src/app/main.c | 8 +------- src/app/scan.c | 1 - src/app/set_bit.c | 1 - src/app/set_reg.c | 1 - src/lib/ip/gfx60.c | 15 ++------------- src/lib/ip/gfx70.c | 15 ++------------- src/lib/ip/gfx72.c | 15 ++------------- src/lib/ip/gfx80.c | 15 ++------------- src/lib/ip/gfx81.c | 15 ++------------- src/lib/ip/gfx90.c | 13 ------------- src/lib/ip/gfx91.c | 13 ------------- src/lib/ip/mmhub10.c | 13 ------------- src/lib/ip/mmhub91.c | 13 ------------- src/lib/ip/mp100.c | 13 ------------- src/lib/ip/mp90.c | 13 ------------- src/lib/ip/oss10.c | 15 ++------------- src/lib/ip/oss20.c | 15 ++------------- src/lib/ip/oss30.c | 15 ++------------- src/lib/ip/smu60.c | 15 ++------------- src/lib/ip/smu700.c | 15 ++------------- src/lib/ip/smu701.c | 15 ++------------- src/lib/ip/smu710.c | 15 ++------------- src/lib/ip/smu711.c | 15 ++------------- src/lib/ip/smu712.c | 15 ++------------- src/lib/ip/smu713.c | 15 ++------------- src/lib/ip/smu80.c | 15 ++------------- src/umr.h | 1 - 29 files changed, 34 insertions(+), 304 deletions(-)
demo/update/read_sensor.sh +1 -1
@@ -6,7 +6,7 @@ # In this case we're reading the NB voltage sensor from Carrizo # capture value in hex -NB_VID=`umr -O risky,risky,read_smc -u carrizo.update -r carrizo.smu80.ixSMUSVI_NB_CURRENTVID | cut -b1-4` +NB_VID=`umr -O read_smc -u carrizo.update -r carrizo.smu80.ixSMUSVI_NB_CURRENTVID | cut -b1-4` # convert to decimal NB_VID_DEC=`printf "%d" ${NB_VID}`
doc/umr.1 +0 -6
@@ -107,12 +107,6 @@ separated strings. Options should be specified before --update or --force comma .B quiet Disable various informative but not required (for functionality) outputs. -.B risky - enables scanning risky ip blocks (such as GFX). Specify twice for SMU - blocks. This flag is necessary since some blocks are not stable to blindly - --scan (or --print) without causing GPU hangs. The flag is intended to prevent - accidental hangs. - .B read_smc Enable scanning of SMC registers.
src/app/main.c +1 -7
@@ -83,9 +83,7 @@ static void parse_options(char *str) *p =0 ;if (*str ==',' ) ++str; -if (!strcmp (option,"risky" )) { - options.risky++; - }else if (!strcmp (option,"named" )) { +if (!strcmp (option,"named" )) { options.named =1 ; }else if (!strcmp (option,"many" )) { options.named =1 ;
@@ -184,9 +182,6 @@ int main(int argc, char **argv)printf ("--pci requires domain:bus:slot.function\n" );return EXIT_FAILURE ; } - }else if (!strcmp (argv[i],"--print" ) || !strcmp (argv[i],"-p" )) { - options.print =1 ; - options.need_scan =1 ; }else if (!strcmp (argv[i],"--config" ) || !strcmp (argv[i],"-c" )) {if (!asic) asic =get_asic ();
@@ -398,7 +393,6 @@ int main(int argc, char **argv)"\n\t\tForce a specific PCI device using the domain:bus:slot.function format in hex." "\n\t\tThis is useful when more than one GPU is available. If the amdgpu driver is" "\n\t\tloaded the corresponding instance will be automatically detected.\n" -"\n\t--print, -p\n\t\tEnable dumping of all device registers. (default: off)\n" "\n\t--config, -c\n\t\tPrint out configuation data read from kernel driver.\n" "\n\t--enumerate, -e\n\t\tEnumerate all AMDGPU devices detected.\n" "\n\t--list-blocks, -lb\n\t\tList IP blocks discovered for this device.\n"
src/app/scan.c +0 -1
@@ -45,7 +45,6 @@ int umr_scan_asic(struct umr_asic *asic, char *asicname, char *ipname, char *reg r = asic->blocks[i]->grant (asic);if (r) {if (ipname[0 ]) { -fprintf (stderr,"[ERROR]: Must specify at least one 'risky' option before scanning specific blocks.\n" );exit (EXIT_FAILURE ); }continue ;
src/app/set_bit.c +0 -1
@@ -64,7 +64,6 @@ int umr_set_register_bit(struct umr_asic *asic, char *regpath, char *regvalue) }if (asic->blocks[i]->grant) {if (asic->blocks[i]->grant (asic)) { -fprintf (stderr,"[ERROR]: Must specify at least one 'risky' before writing to this block.\n" );return -1 ; } }
src/app/set_reg.c +0 -1
@@ -61,7 +61,6 @@ int umr_set_register(struct umr_asic *asic, char *regpath, char *regvalue)if (asic->blocks[i]->grant) {if (asic->blocks[i]->grant (asic)) { -fprintf (stderr,"[ERROR]: Must specify at least one 'risky' before writing to this block.\n" );return -1 ; } }
src/lib/ip/gfx60.c +2 -13
@@ -30,22 +30,12 @@ static const struct umr_reg gfx60_registers[] = {#include "gfx60_regs.i" }; -static int grant (struct umr_asic *asic) -{ - (void )asic; -return 0 ; -} - -static int deny (struct umr_asic *asic) -{ - (void )asic; -return -1 ; -} -struct umr_ip_block *umr_create_gfx60 (struct umr_options *options) {struct umr_ip_block *ip; + (void )options; + ip =calloc (1 ,sizeof *ip);if (!ip)return NULL ;
@@ -57,7 +47,6 @@ struct umr_ip_block *umr_create_gfx60(struct umr_options *options)free (ip);return NULL ; } - ip->grant = (options->risky >=1 ) ? grant : deny;memcpy (ip->regs, gfx60_registers,sizeof (gfx60_registers));return ip; }
src/lib/ip/gfx70.c +2 -13
@@ -29,22 +29,12 @@ static const struct umr_reg gfx70_registers[] = {#include "gfx70_regs.i" }; -static int grant (struct umr_asic *asic) -{ - (void )asic; -return 0 ; -} - -static int deny (struct umr_asic *asic) -{ - (void )asic; -return -1 ; -} -struct umr_ip_block *umr_create_gfx70 (struct umr_options *options) {struct umr_ip_block *ip; + (void )options; + ip =calloc (1 ,sizeof *ip);if (!ip)return NULL ;
@@ -56,7 +46,6 @@ struct umr_ip_block *umr_create_gfx70(struct umr_options *options)free (ip);return NULL ; } - ip->grant = (options->risky >=1 ) ? grant : deny;memcpy (ip->regs, gfx70_registers,sizeof (gfx70_registers));return ip; }
src/lib/ip/gfx72.c +2 -13
@@ -30,22 +30,12 @@ static const struct umr_reg gfx72_registers[] = {#include "gfx72_regs.i" }; -static int grant (struct umr_asic *asic) -{ - (void )asic; -return 0 ; -} - -static int deny (struct umr_asic *asic) -{ - (void )asic; -return -1 ; -} -struct umr_ip_block *umr_create_gfx72 (struct umr_options *options) {struct umr_ip_block *ip; + (void )options; + ip =calloc (1 ,sizeof *ip);if (!ip)return NULL ;
@@ -57,7 +47,6 @@ struct umr_ip_block *umr_create_gfx72(struct umr_options *options)free (ip);return NULL ; } - ip->grant = (options->risky >=1 ) ? grant : deny;memcpy (ip->regs, gfx72_registers,sizeof (gfx72_registers));return ip; }
src/lib/ip/gfx80.c +2 -13
@@ -30,22 +30,12 @@ static const struct umr_reg gfx80_registers[] = {#include "gfx80_regs.i" }; -static int grant (struct umr_asic *asic) -{ - (void )asic; -return 0 ; -} - -static int deny (struct umr_asic *asic) -{ - (void )asic; -return -1 ; -} -struct umr_ip_block *umr_create_gfx80 (struct umr_options *options) {struct umr_ip_block *ip; + (void )options; + ip =calloc (1 ,sizeof *ip);if (!ip)return NULL ;
@@ -57,7 +47,6 @@ struct umr_ip_block *umr_create_gfx80(struct umr_options *options)free (ip);return NULL ; } - ip->grant = (options->risky >=1 ) ? grant : deny;memcpy (ip->regs, gfx80_registers,sizeof (gfx80_registers));return ip; }
src/lib/ip/gfx81.c +2 -13
@@ -30,22 +30,12 @@ static const struct umr_reg gfx81_registers[] = {#include "gfx81_regs.i" }; -static int grant (struct umr_asic *asic) -{ - (void )asic; -return 0 ; -} - -static int deny (struct umr_asic *asic) -{ - (void )asic; -return -1 ; -} -struct umr_ip_block *umr_create_gfx81 (struct umr_options *options) {struct umr_ip_block *ip; + (void )options; + ip =calloc (1 ,sizeof *ip);if (!ip)return NULL ;
@@ -57,7 +47,6 @@ struct umr_ip_block *umr_create_gfx81(struct umr_options *options)free (ip);return NULL ; } - ip->grant = (options->risky >=1 ) ? grant : deny;memcpy (ip->regs, gfx81_registers,sizeof (gfx81_registers));return ip; }
src/lib/ip/gfx90.c +0 -13
@@ -30,18 +30,6 @@ static const struct umr_reg_soc15 gfx90_registers[] = {#include "gfx90_regs.i" }; -static int grant (struct umr_asic *asic) -{ - (void )asic; -return 0 ; -} - -static int deny (struct umr_asic *asic) -{ - (void )asic; -return -1 ; -} -struct umr_ip_block *umr_create_gfx90 (struct umr_ip_offsets_soc15 *soc15_offsets,struct umr_options *options) {struct umr_ip_block *ip;
@@ -57,7 +45,6 @@ struct umr_ip_block *umr_create_gfx90(struct umr_ip_offsets_soc15 *soc15_offsetsfree (ip);return NULL ; } - ip->grant = (options->risky >=1 ) ? grant : deny;if (umr_transfer_soc15_to_reg (options, soc15_offsets,"GC" , gfx90_registers, ip)) {free (ip);
src/lib/ip/gfx91.c +0 -13
@@ -30,18 +30,6 @@ static const struct umr_reg_soc15 gfx91_registers[] = {#include "gfx91_regs.i" }; -static int grant (struct umr_asic *asic) -{ - (void )asic; -return 0 ; -} - -static int deny (struct umr_asic *asic) -{ - (void )asic; -return -1 ; -} -struct umr_ip_block *umr_create_gfx91 (struct umr_ip_offsets_soc15 *soc15_offsets,struct umr_options *options) {struct umr_ip_block *ip;
@@ -57,7 +45,6 @@ struct umr_ip_block *umr_create_gfx91(struct umr_ip_offsets_soc15 *soc15_offsetsfree (ip);return NULL ; } - ip->grant = (options->risky >=1 ) ? grant : deny;if (umr_transfer_soc15_to_reg (options, soc15_offsets,"GC" , gfx91_registers, ip)) {free (ip);
src/lib/ip/mmhub10.c +0 -13
@@ -30,18 +30,6 @@ static const struct umr_reg_soc15 mmhub10_registers[] = {#include "mmhub10_regs.i" }; -static int grant (struct umr_asic *asic) -{ - (void )asic; -return 0 ; -} - -static int deny (struct umr_asic *asic) -{ - (void )asic; -return -1 ; -} -struct umr_ip_block *umr_create_mmhub10 (struct umr_ip_offsets_soc15 *soc15_offsets,struct umr_options *options) {struct umr_ip_block *ip;
@@ -57,7 +45,6 @@ struct umr_ip_block *umr_create_mmhub10(struct umr_ip_offsets_soc15 *soc15_offsefree (ip);return NULL ; } - ip->grant = (options->risky >=1 ) ? grant : deny;if (umr_transfer_soc15_to_reg (options, soc15_offsets,"MMHUB" , mmhub10_registers, ip)) {free (ip);
src/lib/ip/mmhub91.c +0 -13
@@ -30,18 +30,6 @@ static const struct umr_reg_soc15 mmhub91_registers[] = {#include "mmhub91_regs.i" }; -static int grant (struct umr_asic *asic) -{ - (void )asic; -return 0 ; -} - -static int deny (struct umr_asic *asic) -{ - (void )asic; -return -1 ; -} -struct umr_ip_block *umr_create_mmhub91 (struct umr_ip_offsets_soc15 *soc15_offsets,struct umr_options *options) {struct umr_ip_block *ip;
@@ -57,7 +45,6 @@ struct umr_ip_block *umr_create_mmhub91(struct umr_ip_offsets_soc15 *soc15_offsefree (ip);return NULL ; } - ip->grant = (options->risky >=1 ) ? grant : deny;if (umr_transfer_soc15_to_reg (options, soc15_offsets,"MMHUB" , mmhub91_registers, ip)) {free (ip);
src/lib/ip/mp100.c +0 -13
@@ -30,18 +30,6 @@ static const struct umr_reg_soc15 mp100_registers[] = {#include "mp100_regs.i" }; -static int grant (struct umr_asic *asic) -{ - (void )asic; -return 0 ; -} - -static int deny (struct umr_asic *asic) -{ - (void )asic; -return -1 ; -} -struct umr_ip_block *umr_create_mp100 (struct umr_ip_offsets_soc15 *soc15_offsets,struct umr_options *options) {struct umr_ip_block *ip;
@@ -57,7 +45,6 @@ struct umr_ip_block *umr_create_mp100(struct umr_ip_offsets_soc15 *soc15_offsetsfree (ip);return NULL ; } - ip->grant = (options->risky >=1 ) ? grant : deny;if (umr_transfer_soc15_to_reg (options, soc15_offsets,"MP0" , mp100_registers, ip)) {// this might be broken because there is MP1/2 as well free (ip);
src/lib/ip/mp90.c +0 -13
@@ -30,18 +30,6 @@ static const struct umr_reg_soc15 mp90_registers[] = {#include "mp90_regs.i" }; -static int grant (struct umr_asic *asic) -{ - (void )asic; -return 0 ; -} - -static int deny (struct umr_asic *asic) -{ - (void )asic; -return -1 ; -} -struct umr_ip_block *umr_create_mp90 (struct umr_ip_offsets_soc15 *soc15_offsets,struct umr_options *options) {struct umr_ip_block *ip;
@@ -57,7 +45,6 @@ struct umr_ip_block *umr_create_mp90(struct umr_ip_offsets_soc15 *soc15_offsets,free (ip);return NULL ; } - ip->grant = (options->risky >=1 ) ? grant : deny;if (umr_transfer_soc15_to_reg (options, soc15_offsets,"MP0" , mp90_registers, ip)) {// this might be broken because there is MP1/2 as well free (ip);
src/lib/ip/oss10.c +2 -13
@@ -30,22 +30,12 @@ static const struct umr_reg oss10_registers[] = {#include "oss10_regs.i" }; -static int grant (struct umr_asic *asic) -{ - (void )asic; -return 0 ; -} - -static int deny (struct umr_asic *asic) -{ - (void )asic; -return -1 ; -} -struct umr_ip_block *umr_create_oss10 (struct umr_options *options) {struct umr_ip_block *ip; + (void )options; + ip =calloc (1 ,sizeof *ip);if (!ip)return NULL ;
@@ -57,7 +47,6 @@ struct umr_ip_block *umr_create_oss10(struct umr_options *options)free (ip);return NULL ; } - ip->grant = (options->risky >=2 ) ? grant : deny;memcpy (ip->regs, oss10_registers,sizeof (oss10_registers));return ip; }
src/lib/ip/oss20.c +2 -13
@@ -30,22 +30,12 @@ static const struct umr_reg oss20_registers[] = {#include "oss20_regs.i" }; -static int grant (struct umr_asic *asic) -{ - (void )asic; -return 0 ; -} - -static int deny (struct umr_asic *asic) -{ - (void )asic; -return -1 ; -} -struct umr_ip_block *umr_create_oss20 (struct umr_options *options) {struct umr_ip_block *ip; + (void )options; + ip =calloc (1 ,sizeof *ip);if (!ip)return NULL ;
@@ -57,7 +47,6 @@ struct umr_ip_block *umr_create_oss20(struct umr_options *options)free (ip);return NULL ; } - ip->grant = (options->risky >=2 ) ? grant : deny;memcpy (ip->regs, oss20_registers,sizeof (oss20_registers));return ip; }
src/lib/ip/oss30.c +2 -13
@@ -30,22 +30,12 @@ static const struct umr_reg oss30_registers[] = {#include "oss30_regs.i" }; -static int grant (struct umr_asic *asic) -{ - (void )asic; -return 0 ; -} - -static int deny (struct umr_asic *asic) -{ - (void )asic; -return -1 ; -} -struct umr_ip_block *umr_create_oss30 (struct umr_options *options) {struct umr_ip_block *ip; + (void )options; + ip =calloc (1 ,sizeof *ip);if (!ip)return NULL ;
@@ -57,7 +47,6 @@ struct umr_ip_block *umr_create_oss30(struct umr_options *options)free (ip);return NULL ; } - ip->grant = (options->risky >=2 ) ? grant : deny;memcpy (ip->regs, oss30_registers,sizeof (oss30_registers));return ip; }
src/lib/ip/smu60.c +2 -13
@@ -30,22 +30,12 @@ static const struct umr_reg smu60_registers[] = {#include "smu60_regs.i" }; -static int grant (struct umr_asic *asic) -{ - (void )asic; -return 0 ; -} - -static int deny (struct umr_asic *asic) -{ - (void )asic; -return -1 ; -} -struct umr_ip_block *umr_create_smu60 (struct umr_options *options) {struct umr_ip_block *ip; + (void )options; + ip =calloc (1 ,sizeof *ip);if (!ip)return NULL ;
@@ -57,7 +47,6 @@ struct umr_ip_block *umr_create_smu60(struct umr_options *options)free (ip);return NULL ; } - ip->grant = (options->risky >=2 ) ? grant : deny;memcpy (ip->regs, smu60_registers,sizeof (smu60_registers));return ip; }
src/lib/ip/smu700.c +2 -13
@@ -30,22 +30,12 @@ static const struct umr_reg smu700_registers[] = {#include "smu700_regs.i" }; -static int grant (struct umr_asic *asic) -{ - (void )asic; -return 0 ; -} - -static int deny (struct umr_asic *asic) -{ - (void )asic; -return -1 ; -} -struct umr_ip_block *umr_create_smu700 (struct umr_options *options) {struct umr_ip_block *ip; + (void )options; + ip =calloc (1 ,sizeof *ip);if (!ip)return NULL ;
@@ -57,7 +47,6 @@ struct umr_ip_block *umr_create_smu700(struct umr_options *options)free (ip);return NULL ; } - ip->grant = (options->risky >=2 ) ? grant : deny;memcpy (ip->regs, smu700_registers,sizeof (smu700_registers));return ip; }
src/lib/ip/smu701.c +2 -13
@@ -30,22 +30,12 @@ static const struct umr_reg smu701_registers[] = {#include "smu701_regs.i" }; -static int grant (struct umr_asic *asic) -{ - (void )asic; -return 0 ; -} - -static int deny (struct umr_asic *asic) -{ - (void )asic; -return -1 ; -} -struct umr_ip_block *umr_create_smu701 (struct umr_options *options) {struct umr_ip_block *ip; + (void )options; + ip =calloc (1 ,sizeof *ip);if (!ip)return NULL ;
@@ -57,7 +47,6 @@ struct umr_ip_block *umr_create_smu701(struct umr_options *options)free (ip);return NULL ; } - ip->grant = (options->risky >=2 ) ? grant : deny;memcpy (ip->regs, smu701_registers,sizeof (smu701_registers));return ip; }
src/lib/ip/smu710.c +2 -13
@@ -30,22 +30,12 @@ static const struct umr_reg smu710_registers[] = {#include "smu710_regs.i" }; -static int grant (struct umr_asic *asic) -{ - (void )asic; -return 0 ; -} - -static int deny (struct umr_asic *asic) -{ - (void )asic; -return -1 ; -} -struct umr_ip_block *umr_create_smu710 (struct umr_options *options) {struct umr_ip_block *ip; + (void )options; + ip =calloc (1 ,sizeof *ip);if (!ip)return NULL ;
@@ -57,7 +47,6 @@ struct umr_ip_block *umr_create_smu710(struct umr_options *options)free (ip);return NULL ; } - ip->grant = (options->risky >=2 ) ? grant : deny;memcpy (ip->regs, smu710_registers,sizeof (smu710_registers));return ip; }
src/lib/ip/smu711.c +2 -13
@@ -30,22 +30,12 @@ static const struct umr_reg smu711_registers[] = {#include "smu711_regs.i" }; -static int grant (struct umr_asic *asic) -{ - (void )asic; -return 0 ; -} - -static int deny (struct umr_asic *asic) -{ - (void )asic; -return -1 ; -} -struct umr_ip_block *umr_create_smu711 (struct umr_options *options) {struct umr_ip_block *ip; + (void )options; + ip =calloc (1 ,sizeof *ip);if (!ip)return NULL ;
@@ -57,7 +47,6 @@ struct umr_ip_block *umr_create_smu711(struct umr_options *options)free (ip);return NULL ; } - ip->grant = (options->risky >=2 ) ? grant : deny;memcpy (ip->regs, smu711_registers,sizeof (smu711_registers));return ip; }
src/lib/ip/smu712.c +2 -13
@@ -30,22 +30,12 @@ static const struct umr_reg smu712_registers[] = {#include "smu712_regs.i" }; -static int grant (struct umr_asic *asic) -{ - (void )asic; -return 0 ; -} - -static int deny (struct umr_asic *asic) -{ - (void )asic; -return -1 ; -} -struct umr_ip_block *umr_create_smu712 (struct umr_options *options) {struct umr_ip_block *ip; + (void )options; + ip =calloc (1 ,sizeof *ip);if (!ip)return NULL ;
@@ -57,7 +47,6 @@ struct umr_ip_block *umr_create_smu712(struct umr_options *options)free (ip);return NULL ; } - ip->grant = (options->risky >=2 ) ? grant : deny;memcpy (ip->regs, smu712_registers,sizeof (smu712_registers));return ip; }
src/lib/ip/smu713.c +2 -13
@@ -30,22 +30,12 @@ static const struct umr_reg smu713_registers[] = {#include "smu713_regs.i" }; -static int grant (struct umr_asic *asic) -{ - (void )asic; -return 0 ; -} - -static int deny (struct umr_asic *asic) -{ - (void )asic; -return -1 ; -} -struct umr_ip_block *umr_create_smu713 (struct umr_options *options) {struct umr_ip_block *ip; + (void )options; + ip =calloc (1 ,sizeof *ip);if (!ip)return NULL ;
@@ -57,7 +47,6 @@ struct umr_ip_block *umr_create_smu713(struct umr_options *options)free (ip);return NULL ; } - ip->grant = (options->risky >=2 ) ? grant : deny;memcpy (ip->regs, smu713_registers,sizeof (smu713_registers));return ip; }
src/lib/ip/smu80.c +2 -13
@@ -30,22 +30,12 @@ static const struct umr_reg smu80_registers[] = {#include "smu80_regs.i" }; -static int grant (struct umr_asic *asic) -{ - (void )asic; -return 0 ; -} - -static int deny (struct umr_asic *asic) -{ - (void )asic; -return -1 ; -} -struct umr_ip_block *umr_create_smu80 (struct umr_options *options) {struct umr_ip_block *ip; + (void )options; + ip =calloc (1 ,sizeof *ip);if (!ip)return NULL ;
@@ -57,7 +47,6 @@ struct umr_ip_block *umr_create_smu80(struct umr_options *options)free (ip);return NULL ; } - ip->grant = (options->risky >=2 ) ? grant : deny;memcpy (ip->regs, smu80_registers,sizeof (smu80_registers));return ip; }
src/umr.h +0 -1
@@ -162,7 +162,6 @@ struct umr_options { instance, need_scan, print, - risky, bitfields, bitfields_full, named,
Signature · 6 lines
2.12.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 2/4 Add ability to specify VMID in hex
In reply to a message not in the archive--- doc/umr.1 | 5 +++-- src/app/main.c | 11 +++++++---- 2 files changed, 10 insertions(+), 6 deletions(-)
doc/umr.1 +3 -2
@@ -92,8 +92,9 @@ will operate regardless of whether GFX PG is enabled or not. Can use to decode the wave bitfields. .IP "--vram, -v [vmid@]<address> <size>" Read 'size' bytes (in hex) from the address specified (in hexadecimal) from VRAM -to stdout. Optionally specify the VMID (in decimal) treating the address as a -virtual address instead. Can use 'use_pci' to directly access VRAM. +to stdout. Optionally specify the VMID (in decimal or in hex with a 0x prefix) +treating the address as a virtual address instead. Can use 'use_pci' to +directly access VRAM. .IP "--update, -u" <filename> Specify update file to add, change, or delete registers from the register
src/app/main.c +7 -4
@@ -346,10 +346,13 @@ int main(int argc, char **argv)if (!asic) asic =get_asic (); -if ((n =sscanf (argv[i+1 ],"%" SCNu32"@%" SCNx64, &vmid, &address)) !=2 ) { -sscanf (argv[i+1 ],"%" SCNx64, &address); - vmid =0xFFFF ; - } +// allow specifying the vmid in hex as well so +// people can add the HUB flags more easily +if ((n =sscanf (argv[i+1 ],"0x%" SCNx32"@%" SCNx64, &vmid, &address)) !=2 ) +if ((n =sscanf (argv[i+1 ],"%" SCNu32"@%" SCNx64, &vmid, &address)) !=2 ) { +sscanf (argv[i+1 ],"%" SCNx64, &address); + vmid =UMR_LINEAR_HUB ; + }sscanf (argv[i+2 ],"%" SCNx32, &size);while (size) { n = size >sizeof (buf) ?sizeof (buf) : size;
Signature · 6 lines
2.12.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 3/4 Various cleanups found by static analysis.
In reply to a message not in the archive--- src/app/enum.c | 4 ++-- src/lib/create_asic_helper.c | 5 +++++ src/lib/discover.c | 9 +++++++-- src/lib/mmio.c | 8 ++++++++ 4 files changed, 22 insertions(+), 4 deletions(-)
src/app/enum.c +2 -2
@@ -66,10 +66,10 @@ void umr_enumerate_devices(void) asics[devices++].pcopy = *pdevice; x =1 ; } - }while (pdevice && devices <MAX_DEV ); + }while (x && pdevice && devices <MAX_DEV );// now try to match devices against instances -for (y =0 ; y <MAX_DEV ; y++) { +for (y =0 ; y < devices; y++) {snprintf (path,sizeof (path)-1 ,"/sys/kernel/debug/dri/%d/name" , y); dri =fopen (path,"r" );if (dri) {
src/lib/create_asic_helper.c +5 -0
@@ -48,6 +48,11 @@ struct umr_asic *umr_create_asic_helper(char *name, int family, ...) }va_end (ap); +if (!asic->no_blocks) { +free (asic); +return NULL ; + } + asic->blocks =calloc (asic->no_blocks,sizeof (struct umr_ip_block *));if (!asic->blocks) {free (asic);
src/lib/discover.c +7 -2
@@ -269,20 +269,25 @@ struct umr_asic *umr_discover_asic(struct umr_options *options) goto err_pci; }pci_iterator_destroy (pci_iter); + +// enable device if kernel module isn't present +if (asic->options.no_kernel) +pci_device_enable (asic->pci.pdevice); +pci_device_probe (asic->pci.pdevice); use_region =6 ;// try to detect based on ASIC family if (asic->family <=FAMILY_SI ) {// try region 2 for SI -if ( asic->pci.pdevice->regions[2 ].is_64 ==0 && +if (asic->pci.pdevice->regions[2 ].is_64 ==0 && asic->pci.pdevice->regions[2 ].is_prefetchable ==0 && asic->pci.pdevice->regions[2 ].is_IO ==0 ) { use_region =2 ; } }else if (asic->family <=FAMILY_VI ) {// try region 5 for CIK..VI -if ( asic->pci.pdevice->regions[5 ].is_64 ==0 && +if (asic->pci.pdevice->regions[5 ].is_64 ==0 && asic->pci.pdevice->regions[5 ].is_prefetchable ==0 && asic->pci.pdevice->regions[5 ].is_IO ==0 ) { use_region =5 ;
src/lib/mmio.c +8 -0
@@ -88,6 +88,10 @@ uint32_t umr_read_reg(struct umr_asic *asic, uint64_t addr, enum regclass type)if (addr ==0xFFFFFFFF )fprintf (stderr,"[BUG]: reading from addr==0xFFFFFFFF is likely a bug\n" ); +// lop off top bits in no-kernel mode +if (asic->options.no_kernel) + addr &=0xFFFFFF ; +switch (type) {case REG_MMIO :if (asic->pci.mem && !(addr & ~0xFFFFFULL )) {// only use pci if enabled and not using high bits
@@ -113,6 +117,10 @@ int umr_write_reg(struct umr_asic *asic, uint64_t addr, uint32_t value, enum regif (addr ==0xFFFFFFFF )fprintf (stderr,"[BUG]: reading from addr==0xFFFFFFFF is likely a bug\n" ); +// lop off top bits in no-kernel mode +if (asic->options.no_kernel) + addr &=0xFFFFFF ; +switch (type) {case REG_MMIO :if (asic->pci.mem && !(addr & ~0xFFFFFULL )) {
Signature · 6 lines
2.12.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 4/4 Add ability to halt waves and better VM decoding
In reply to a message not in the archiveThis patch involves two things I was working on at once so the patches are a bit intertwined. It adds
1. The ability to halt SQ waves when reading waves on CIK and later ASICs.
2. The ability to enable verbose decoding when reading vram
3. The ability to decode virtual addresses in the mmhub (for say VCN)
--- doc/umr.1 | 6 +++ src/app/main.c | 15 +++++-- src/app/print_waves.c | 6 +++ src/lib/CMakeLists.txt | 1 + src/lib/dump_ib.c | 6 ++- src/lib/find_reg.c | 11 ++++- src/lib/mmio.c | 36 +++++++++++++---- src/lib/read_vram.c | 98 ++++++++++++++++++++++++++++++++++++++------- src/lib/ring_decode.c | 4 +- src/lib/sq_cmd_halt_waves.c | 57 ++++++++++++++++++++++++++ src/umr.h | 26 ++++++++++++ 11 files changed, 233 insertions(+), 33 deletions(-) create mode 100644 src/lib/sq_cmd_halt_waves.c
doc/umr.1 +6 -0
@@ -148,6 +148,12 @@ separated strings. Options should be specified before --update or --force comma be used only if the KMD is hung or otherwise not working correctly. Using it on live systems may result in race conditions. +.B verbose + Enable verbose diagnostics (used in --vram). + +.B halt_waves + Halt/resume all waves while reading wave status. + .SH "Notes" - The "Waves" field in the DRM section of --top only works if GFX PG has been disabled. Otherwise,
src/app/main.c +11 -4
@@ -107,6 +107,10 @@ static void parse_options(char *str) options.quiet =1 ; }else if (!strcmp (option,"follow_ib" )) { options.follow_ib =1 ; + }else if (!strcmp (option,"verbose" )) { + options.verbose =1 ; + }else if (!strcmp (option,"halt_waves" )) { + options.halt_waves =1 ; }else if (!strcmp (option,"no_kernel" )) { options.no_kernel =1 ; options.use_pci =1 ;
@@ -422,12 +426,15 @@ int main(int argc, char **argv)"\n\t--top, -t\n\t\tSummarize GPU utilization. Can select a SE block with --bank. Can use" "\n\t\toptions 'use_colour' to colourize output and 'use_pci' to improve efficiency.\n" "\n\t--waves, -wa\n\t\tPrint out information about any active CU waves. Can use '-O bits'" -"\n\t\tto see decoding of various wave fields.\n" +"\n\t\tto see decoding of various wave fields. Can use the '-O halt_waves' option" +"\n\t\tto halt the SQ while reading registers.\n" "\n\t--vram, -v [<vmid>@]<address> <size>" "\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, no_kernel.\n" +"\n\t\tspecify the VMID (in decimal or in hex with a '0x' prefix) treating the address" +"\n\t\tas a virtual address instead. Can use 'verbose' option to print out PDE/PTE" +"\n\t\tdecodings.\n" +"\n\t--option -O <string>[,<string>,...]\n\t\tEnable various flags: bits, bitsfull, empty_log, follow, named, many," +"\n\t\tuse_pci, use_colour, read_smc, quiet, no_kernel, verbose, halt_waves.\n" "\n\n", UMR_BUILD_VER, UMR_BUILD_REV);exit (EXIT_SUCCESS ); }else {
src/app/print_waves.c +6 -0
@@ -40,6 +40,9 @@ void umr_print_waves(struct umr_asic *asic)struct umr_wave_status ws;int first =1 , col =0 ; +if (asic->options.halt_waves) +umr_sq_cmd_halt_waves (asic,UMR_SQ_CMD_HALT ); +if (asic->family <=FAMILY_CIK ) shift =3 ;// on SI..CIK allocations were done in 8-dword blocks else
@@ -206,4 +209,7 @@ void umr_print_waves(struct umr_asic *asic) }if (first)printf ("No active waves!\n" ); + +if (asic->options.halt_waves) +umr_sq_cmd_halt_waves (asic,UMR_SQ_CMD_RESUME ); }
src/lib/CMakeLists.txt +1 -0
@@ -21,6 +21,7 @@ add_library(umrcore STATIC read_vram.c ring_decode.c scan_config.c + sq_cmd_halt_waves.c transfer_soc15.c wave_status.c update.c
src/lib/dump_ib.c +4 -2
@@ -28,9 +28,11 @@void umr_dump_ib (struct umr_asic *asic,struct umr_ring_decoder *decoder) {uint32_t *data =NULL , x; +static const char *hubs[] = {"gfxhub" ,"mmhub" }; -printf ("Dumping IB at VMID:%u 0x%llx of %u words\n" , - (unsigned )decoder->next_ib_info.vmid, +printf ("Dumping IB at (%s) VMID:%u 0x%llx of %u words\n" , + hubs[decoder->next_ib_info.vmid >>8 ], + (unsigned )decoder->next_ib_info.vmid &0xFF , (unsigned long long )decoder->next_ib_info.ib_addr, (unsigned )decoder->next_ib_info.size/4 );
src/lib/find_reg.c +9 -2
@@ -36,14 +36,21 @@ uint32_t umr_find_reg(struct umr_asic *asic, char *regname)return 0xFFFFFFFF ; } -struct umr_reg *umr_find_reg_data (struct umr_asic *asic,char *regname) +struct umr_reg *umr_find_reg_data_by_ip (struct umr_asic *asic,char *ip,char *regname) {int i, j; -for (i =0 ; i < asic->no_blocks; i++) +for (i =0 ; i < asic->no_blocks; i++) { +if (ip &&memcmp (asic->blocks[i]->ipname, ip,strlen (ip)))continue ;for (j =0 ; j < asic->blocks[i]->no_regs; j++)if (!strcmp (asic->blocks[i]->regs[j].regname, regname))return &asic->blocks[i]->regs[j]; + }fprintf (stderr,"[BUG]: reg [%s] not found on asic [%s]\n" , regname, asic->asicname);return NULL ; } + +struct umr_reg *umr_find_reg_data (struct umr_asic *asic,char *regname) +{ +return umr_find_reg_data_by_ip (asic,NULL , regname); +}
src/lib/mmio.c +28 -8
@@ -145,26 +145,36 @@ int umr_write_reg(struct umr_asic *asic, uint64_t addr, uint32_t value, enum regreturn 0 ; } -uint32_t umr_read_reg_by_name (struct umr_asic *asic,char *name) +uint32_t umr_read_reg_by_name_by_ip (struct umr_asic *asic,char *ip,char *name) {struct umr_reg *reg; - reg =umr_find_reg_data (asic, name); + reg =umr_find_reg_data_by_ip (asic, ip, name);if (reg)return umr_read_reg (asic, reg->addr * (reg->type ==REG_MMIO ?4 :1 ), reg->type);else return 0 ; } -int umr_write_reg_by_name (struct umr_asic *asic,char *name,uint32_t value) +uint32_t umr_read_reg_by_name (struct umr_asic *asic,char *name) +{ +return umr_read_reg_by_name_by_ip (asic,NULL , name); +} + +int umr_write_reg_by_name_by_ip (struct umr_asic *asic,char *ip,char *name,uint32_t value) {struct umr_reg *reg; - reg =umr_find_reg_data (asic, name); + reg =umr_find_reg_data_by_ip (asic, ip, name);if (reg)return umr_write_reg (asic, reg->addr * (reg->type ==REG_MMIO ?4 :1 ), value, reg->type);else return -1 ; } +int umr_write_reg_by_name (struct umr_asic *asic,char *name,uint32_t value) +{ +return umr_write_reg_by_name_by_ip (asic,NULL , name, value); +} +uint32_t umr_bitslice_reg (struct umr_asic *asic,struct umr_reg *reg,char *bitname,uint32_t regvalue) {int i;
@@ -193,26 +203,36 @@ uint32_t umr_bitslice_compose_value(struct umr_asic *asic, struct umr_reg *reg,return 0 ; } -uint32_t umr_bitslice_reg_by_name (struct umr_asic *asic,char *regname,char *bitname,uint32_t regvalue) +uint32_t umr_bitslice_reg_by_name_by_ip (struct umr_asic *asic,char *ip,char *regname,char *bitname,uint32_t regvalue) {struct umr_reg *reg; - reg =umr_find_reg_data (asic, regname); + reg =umr_find_reg_data_by_ip (asic, ip, regname);if (reg)return umr_bitslice_reg (asic, reg, bitname, regvalue);else return 0 ; } -uint32_t umr_bitslice_compose_value_by_name (struct umr_asic *asic,char *regname,char *bitname,uint32_t regvalue) +uint32_t umr_bitslice_reg_by_name (struct umr_asic *asic,char *regname,char *bitname,uint32_t regvalue) +{ +return umr_bitslice_reg_by_name_by_ip (asic,NULL , regname, bitname, regvalue); +} + +uint32_t umr_bitslice_compose_value_by_name_by_ip (struct umr_asic *asic,char *ip,char *regname,char *bitname,uint32_t regvalue) {struct umr_reg *reg; - reg =umr_find_reg_data (asic, regname); + reg =umr_find_reg_data_by_ip (asic, ip, regname);if (reg)return umr_bitslice_compose_value (asic, reg, bitname, regvalue);else return 0 ; } +uint32_t umr_bitslice_compose_value_by_name (struct umr_asic *asic,char *regname,char *bitname,uint32_t regvalue) +{ +return umr_bitslice_compose_value_by_name_by_ip (asic,NULL , regname, bitname, regvalue); +} +int umr_grbm_select_index (struct umr_asic *asic,uint32_t se,uint32_t sh,uint32_t instance) {struct umr_reg *grbm_idx;
src/lib/read_vram.c +83 -15
229 lines not on this page · raw message
src/lib/ring_decode.c +2 -2
@@ -589,7 +589,7 @@ static void print_decode_pm4(struct umr_asic *asic, struct umr_ring_decoder *dec// detect VCN/UVD IBs and chain them once all // 4 pieces of information are found if (!strcmp (name,"mmUVD_LMI_RBC_IB_VMID" )) { - decoder->pm4.next_ib_state.ib_vmid = ib; + decoder->pm4.next_ib_state.ib_vmid = ib | ((asic->family <=FAMILY_VI ) ?0 :UMR_MM_HUB ); decoder->pm4.next_ib_state.tally |=1 ; }else if (!strcmp (name,"mmUVD_LMI_RBC_IB_64BIT_BAR_LOW" )) { decoder->pm4.next_ib_state.ib_addr_lo = ib;
@@ -598,7 +598,7 @@ static void print_decode_pm4(struct umr_asic *asic, struct umr_ring_decoder *dec decoder->pm4.next_ib_state.ib_addr_hi = ib; decoder->pm4.next_ib_state.tally |=4 ; }else if (!strcmp (name,"mmUVD_RBC_IB_SIZE" )) { - decoder->pm4.next_ib_state.ib_size = ib; + decoder->pm4.next_ib_state.ib_size = ib *4 ; decoder->pm4.next_ib_state.tally |=8 ; }
src/lib/sq_cmd_halt_waves.c new file +57 -0
57 lines not on this page · raw message
src/umr.h +26 -0
@@ -33,6 +33,20 @@#include <pciaccess.h> #include <pthread.h> +/* SQ_CMD halt/resume */ +enum umr_sq_cmd_halt_resume { +UMR_SQ_CMD_HALT =0 , +UMR_SQ_CMD_RESUME , +}; + +/* memory space hubs */ +enum umr_hub_space { +UMR_GFX_HUB =0 <<8 ,// default on everything before AI +UMR_MM_HUB =1 <<8 ,// available on AI and later + +UMR_LINEAR_HUB =0xFF <<8 ,// this is for linear access to vram +}; +/* sourced from amd_powerplay.h from the kernel */ enum amd_pp_sensors {AMDGPU_PP_SENSOR_GFX_SCLK =0 ,
@@ -174,6 +188,8 @@ struct umr_options { read_smc, quiet, follow_ib, + verbose, + halt_waves, no_kernel;unsigned instance_bank,
@@ -477,6 +493,7 @@ int umr_create_mmio_accel(struct umr_asic *asic);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_by_ip (struct umr_asic *asic,char *ip,char *regname);struct umr_reg *umr_find_reg_data (struct umr_asic *asic,char *regname);// read/write a 32-bit register given a BYTE address
@@ -487,17 +504,26 @@ int umr_write_reg(struct umr_asic *asic, uint64_t addr, uint32_t value, enum reguint32_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); +// read/write a register by ip/name +uint32_t umr_read_reg_by_name_by_ip (struct umr_asic *asic,char *ip,char *name); +int umr_write_reg_by_name_by_ip (struct umr_asic *asic,char *ip,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); +uint32_t umr_bitslice_reg_by_name_by_ip (struct umr_asic *asic,char *ip,char *regname,char *bitname,uint32_t regvalue);// 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); +uint32_t umr_bitslice_compose_value_by_name_by_ip (struct umr_asic *asic,char *ip,char *regname,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); +// halt/resume SQ waves +int umr_sq_cmd_halt_waves (struct umr_asic *asic,enum umr_sq_cmd_halt_resume mode); +/* IB/ring decoding/dumping/etc */ void umr_print_decode (struct umr_asic *asic,struct umr_ring_decoder *decoder,uint32_t ib);void umr_dump_ib (struct umr_asic *asic,struct umr_ring_decoder *decoder);
Signature · 6 lines
2.12.0 _______________________________________________ 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): [email protected]
Alex Deucher
Acked-byRe: [PATCH umr 4/4] Add ability to halt waves and better VM decoding
Quoted 11 lines · Tom St Denis
This patch involves two things I was working on at once so the patches are a bit intertwined. It adds
1. The ability to halt SQ waves when reading waves on CIK and later ASICs.
2. The ability to enable verbose decoding when reading vram
3. The ability to decode virtual addresses in the mmhub (for say VCN)
Signed-off-by Tom St Denis <[email protected]>
Series is:
Quoted 641 lines
--- doc/umr.1 | 6 +++ src/app/main.c | 15 +++++-- src/app/print_waves.c | 6 +++ src/lib/CMakeLists.txt | 1 + src/lib/dump_ib.c | 6 ++- src/lib/find_reg.c | 11 ++++- src/lib/mmio.c | 36 +++++++++++++---- src/lib/read_vram.c | 98 ++++++++++++++++++++++++++++++++++++++------- src/lib/ring_decode.c | 4 +- src/lib/sq_cmd_halt_waves.c | 57 ++++++++++++++++++++++++++ src/umr.h | 26 ++++++++++++ 11 files changed, 233 insertions(+), 33 deletions(-) create mode 100644 src/lib/sq_cmd_halt_waves.cdoc/umr.1 +6
-0@@ -148,6 +148,12 @@ separated strings. Options should be specified before --update or --force comma be used only if the KMD is hung or otherwise not working correctly. Using it on live systems may result in race conditions. +.B verbose + Enable verbose diagnostics (used in --vram). + +.B halt_waves + Halt/resume all waves while reading wave status. + .SH "Notes" - The "Waves" field in the DRM section of --top only works if GFX PG has been disabled. Otherwise,src/app/main.c +11
-4@@ -107,6 +107,10 @@ static void parse_options(char *str) options.quiet =1 ; }else if (!strcmp (option,"follow_ib" )) { options.follow_ib =1 ; + }else if (!strcmp (option,"verbose" )) { + options.verbose =1 ; + }else if (!strcmp (option,"halt_waves" )) { + options.halt_waves =1 ; }else if (!strcmp (option,"no_kernel" )) { options.no_kernel =1 ; options.use_pci =1 ;@@ -422,12 +426,15 @@ int main(int argc, char **argv)"\n\t--top, -t\n\t\tSummarize GPU utilization. Can select a SE block with --bank. Can use" "\n\t\toptions 'use_colour' to colourize output and 'use_pci' to improve efficiency.\n" "\n\t--waves, -wa\n\t\tPrint out information about any active CU waves. Can use '-O bits'" -"\n\t\tto see decoding of various wave fields.\n" +"\n\t\tto see decoding of various wave fields. Can use the '-O halt_waves' option" +"\n\t\tto halt the SQ while reading registers.\n" "\n\t--vram, -v [<vmid>@]<address> <size>" "\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, no_kernel.\n" +"\n\t\tspecify the VMID (in decimal or in hex with a '0x' prefix) treating the address" +"\n\t\tas a virtual address instead. Can use 'verbose' option to print out PDE/PTE" +"\n\t\tdecodings.\n" +"\n\t--option -O <string>[,<string>,...]\n\t\tEnable various flags: bits, bitsfull, empty_log, follow, named, many," +"\n\t\tuse_pci, use_colour, read_smc, quiet, no_kernel, verbose, halt_waves.\n" "\n\n", UMR_BUILD_VER, UMR_BUILD_REV);exit (EXIT_SUCCESS ); }else {src/app/print_waves.c +6
-0@@ -40,6 +40,9 @@ void umr_print_waves(struct umr_asic *asic)struct umr_wave_status ws;int first =1 , col =0 ; +if (asic->options.halt_waves) +umr_sq_cmd_halt_waves (asic,UMR_SQ_CMD_HALT ); +if (asic->family <=FAMILY_CIK ) shift =3 ;// on SI..CIK allocations were done in 8-dword blocks else @@ -206,4 +209,7 @@ void umr_print_waves(struct umr_asic *asic) }if (first)printf ("No active waves!\n" ); + +if (asic->options.halt_waves) +umr_sq_cmd_halt_waves (asic,UMR_SQ_CMD_RESUME ); }src/lib/CMakeLists.txt +1
-0@@ -21,6 +21,7 @@ add_library(umrcore STATIC read_vram.c ring_decode.c scan_config.c + sq_cmd_halt_waves.c transfer_soc15.c wave_status.c update.csrc/lib/dump_ib.c +4
-2@@ -28,9 +28,11 @@void umr_dump_ib (struct umr_asic *asic,struct umr_ring_decoder *decoder) {uint32_t *data =NULL , x; +static const char *hubs[] = {"gfxhub" ,"mmhub" }; -printf ("Dumping IB at VMID:%u 0x%llx of %u words\n" , - (unsigned )decoder->next_ib_info.vmid, +printf ("Dumping IB at (%s) VMID:%u 0x%llx of %u words\n" , + hubs[decoder->next_ib_info.vmid >>8 ], + (unsigned )decoder->next_ib_info.vmid &0xFF , (unsigned long long )decoder->next_ib_info.ib_addr, (unsigned )decoder->next_ib_info.size/4 );src/lib/find_reg.c +9
-2@@ -36,14 +36,21 @@ uint32_t umr_find_reg(struct umr_asic *asic, char *regname)return 0xFFFFFFFF ; } -struct umr_reg *umr_find_reg_data (struct umr_asic *asic,char *regname) +struct umr_reg *umr_find_reg_data_by_ip (struct umr_asic *asic,char *ip,char *regname) {int i, j; -for (i =0 ; i < asic->no_blocks; i++) +for (i =0 ; i < asic->no_blocks; i++) { +if (ip &&memcmp (asic->blocks[i]->ipname, ip,strlen (ip)))continue ;for (j =0 ; j < asic->blocks[i]->no_regs; j++)if (!strcmp (asic->blocks[i]->regs[j].regname, regname))return &asic->blocks[i]->regs[j]; + }fprintf (stderr,"[BUG]: reg [%s] not found on asic [%s]\n" , regname, asic->asicname);return NULL ; } + +struct umr_reg *umr_find_reg_data (struct umr_asic *asic,char *regname) +{ +return umr_find_reg_data_by_ip (asic,NULL , regname); +}src/lib/mmio.c +28
-8@@ -145,26 +145,36 @@ int umr_write_reg(struct umr_asic *asic, uint64_t addr, uint32_t value, enum regreturn 0 ; } -uint32_t umr_read_reg_by_name (struct umr_asic *asic,char *name) +uint32_t umr_read_reg_by_name_by_ip (struct umr_asic *asic,char *ip,char *name) {struct umr_reg *reg; - reg =umr_find_reg_data (asic, name); + reg =umr_find_reg_data_by_ip (asic, ip, name);if (reg)return umr_read_reg (asic, reg->addr * (reg->type ==REG_MMIO ?4 :1 ), reg->type);else return 0 ; } -int umr_write_reg_by_name (struct umr_asic *asic,char *name,uint32_t value) +uint32_t umr_read_reg_by_name (struct umr_asic *asic,char *name) +{ +return umr_read_reg_by_name_by_ip (asic,NULL , name); +} + +int umr_write_reg_by_name_by_ip (struct umr_asic *asic,char *ip,char *name,uint32_t value) {struct umr_reg *reg; - reg =umr_find_reg_data (asic, name); + reg =umr_find_reg_data_by_ip (asic, ip, name);if (reg)return umr_write_reg (asic, reg->addr * (reg->type ==REG_MMIO ?4 :1 ), value, reg->type);else return -1 ; } +int umr_write_reg_by_name (struct umr_asic *asic,char *name,uint32_t value) +{ +return umr_write_reg_by_name_by_ip (asic,NULL , name, value); +} +uint32_t umr_bitslice_reg (struct umr_asic *asic,struct umr_reg *reg,char *bitname,uint32_t regvalue) {int i;@@ -193,26 +203,36 @@ uint32_t umr_bitslice_compose_value(struct umr_asic *asic, struct umr_reg *reg,return 0 ; } -uint32_t umr_bitslice_reg_by_name (struct umr_asic *asic,char *regname,char *bitname,uint32_t regvalue) +uint32_t umr_bitslice_reg_by_name_by_ip (struct umr_asic *asic,char *ip,char *regname,char *bitname,uint32_t regvalue) {struct umr_reg *reg; - reg =umr_find_reg_data (asic, regname); + reg =umr_find_reg_data_by_ip (asic, ip, regname);if (reg)return umr_bitslice_reg (asic, reg, bitname, regvalue);else return 0 ; } -uint32_t umr_bitslice_compose_value_by_name (struct umr_asic *asic,char *regname,char *bitname,uint32_t regvalue) +uint32_t umr_bitslice_reg_by_name (struct umr_asic *asic,char *regname,char *bitname,uint32_t regvalue) +{ +return umr_bitslice_reg_by_name_by_ip (asic,NULL , regname, bitname, regvalue); +} + +uint32_t umr_bitslice_compose_value_by_name_by_ip (struct umr_asic *asic,char *ip,char *regname,char *bitname,uint32_t regvalue) {struct umr_reg *reg; - reg =umr_find_reg_data (asic, regname); + reg =umr_find_reg_data_by_ip (asic, ip, regname);if (reg)return umr_bitslice_compose_value (asic, reg, bitname, regvalue);else return 0 ; } +uint32_t umr_bitslice_compose_value_by_name (struct umr_asic *asic,char *regname,char *bitname,uint32_t regvalue) +{ +return umr_bitslice_compose_value_by_name_by_ip (asic,NULL , regname, bitname, regvalue); +} +int umr_grbm_select_index (struct umr_asic *asic,uint32_t se,uint32_t sh,uint32_t instance) {struct umr_reg *grbm_idx;src/lib/read_vram.c +83
-15@@ -135,7 +135,7 @@ static int umr_read_vram_vi(struct umr_asic *asic, uint32_t vmid, uint64_t addresprintf (buf,"mmVM_CONTEXT%d_PAGE_TABLE_BASE_ADDR" , (int )vmid); page_table_base_addr = (uint64_t )umr_read_reg_by_name (asic, buf) <<12 ; - vm_fb_base = ((uint64_t )umr_read_reg_by_name (asic,"mmMC_VM_FB_LOCATION" ) >>16 ) <<24 ; + vm_fb_base = ((uint64_t )umr_read_reg_by_name (asic,"mmMC_VM_FB_LOCATION" ) &0xFFFF ) <<24 ;DEBUG ("mmVM_CONTEXTx_PAGE_TABLE_START_ADDR = %08llx\n" , (unsigned long long )page_table_start_addr);DEBUG ("mmVM_CONTEXTx_PAGE_TABLE_BASE_ADDR = 0x%08llx\n" , (unsigned long long )page_table_base_addr);@@ -143,6 +143,21 @@ static int umr_read_vram_vi(struct umr_asic *asic, uint32_t vmid, uint64_t addreDEBUG ("mmVM_CONTEXTx_CNTL.PAGE_TABLE_DEPTH = %d\n" , page_table_depth);DEBUG ("mmMC_VM_FB_LOCATION == %llx\n" , (unsigned long long )vm_fb_base); +if (asic->options.verbose) +fprintf (stderr,"[VERBOSE]: Decoding %u@0x%llx\n" +"[VERBOSE]: PAGE_TABLE_START_ADDR=0x%llx\n" +"[VERBOSE]: PAGE_TABLE_BASE_ADDR=0x%llx\n" +"[VERBOSE]: PAGE_TABLE_BLOCK_SIZE=%u\n" +"[VERBOSE]: PAGE_TABLE_DEPTH=%u\n" +"[VERBOSE]: MC_VM_FB_LOCATION=0x%llx\n" , + (unsigned )vmid, + (unsigned long long )address, + (unsigned long long )page_table_start_addr, + (unsigned long long )page_table_base_addr, + (unsigned )page_table_size, + (unsigned )page_table_depth, + (unsigned long long )vm_fb_base); + address -= page_table_start_addr;while (size) {@@ -152,17 +167,21 @@ static int umr_read_vram_vi(struct umr_asic *asic, uint32_t vmid, uint64_t addre pte_idx = (address >>12 ) & ((1ULL << (9 + page_table_size)) -1 );// read PDE entry -umr_read_vram (asic,0xFFFF , page_table_base_addr + pde_idx *8 ,8 , &pde_entry); +umr_read_vram (asic,UMR_LINEAR_HUB , page_table_base_addr + pde_idx *8 - vm_fb_base,8 , &pde_entry);// decode PDE values pde_fields.frag_size = (pde_entry >>59 ) &0x1F ; pde_fields.pte_base_addr = pde_entry &0xFFFFFFF000ULL ; pde_fields.valid = pde_entry &1 ; +if (asic->options.verbose) +fprintf (stderr,"[VERBOSE]: PDE.pte_base_addr==0x%llx, PDE.valid=%d\n" , + (unsigned long long )pde_fields.pte_base_addr, + (int )pde_fields.valid);DEBUG ("PDE==%llx, pde_idx=%llx, frag_size=%u, pte_base_addr=0x%llx, valid=%d\n" , (unsigned long long )pde_entry, (unsigned long long )pde_idx, (unsigned )pde_fields.frag_size, (unsigned long long )pde_fields.pte_base_addr, (int )pde_fields.valid);// now read PTE entry for this page -if (umr_read_vram (asic,0xFFFF , pde_fields.pte_base_addr + pte_idx*8 ,8 , &pte_entry) <0 ) +if (umr_read_vram (asic,UMR_LINEAR_HUB , pde_fields.pte_base_addr + pte_idx*8 - vm_fb_base,8 , &pte_entry) <0 )return -1 ;// decode PTE values @@ -170,6 +189,11 @@ static int umr_read_vram_vi(struct umr_asic *asic, uint32_t vmid, uint64_t addre pte_fields.fragment = (pte_entry >>7 ) &0x1F ; pte_fields.system = (pte_entry >>1 ) &1 ; pte_fields.valid = pte_entry &1 ; +if (asic->options.verbose) +fprintf (stderr,"[VERBOSE]: PTE.page_base_addr==0x%08llx, PTE.system=%d, PTE.valid=%d\n" , + (unsigned long long )pte_fields.page_base_addr, + (int )pte_fields.system, + (int )pte_fields.valid);DEBUG ("PTE=%llx, pte_idx=%llx, page_base_addr=0x%llx, fragment=%u, system=%d, valid=%d\n" , (unsigned long long )pte_entry, (unsigned long long )pte_idx, (unsigned long long )pte_fields.page_base_addr, (unsigned )pte_fields.fragment, (int )pte_fields.system, (int )pte_fields.valid);@@ -179,7 +203,7 @@ static int umr_read_vram_vi(struct umr_asic *asic, uint32_t vmid, uint64_t addre// depth == 0 == PTE only pte_idx = (address >>12 ); -if (umr_read_vram (asic,0xFFFF , page_table_base_addr + pte_idx *8 ,8 , &pte_entry) <0 ) +if (umr_read_vram (asic,UMR_LINEAR_HUB , page_table_base_addr + pte_idx *8 - vm_fb_base,8 , &pte_entry) <0 )return -1 ;// decode PTE values @@ -187,6 +211,11 @@ static int umr_read_vram_vi(struct umr_asic *asic, uint32_t vmid, uint64_t addre pte_fields.fragment = (pte_entry >>7 ) &0x1F ; pte_fields.system = (pte_entry >>1 ) &1 ; pte_fields.valid = pte_entry &1 ; +if (asic->options.verbose) +fprintf (stderr,"[VERBOSE]: PTE.page_base_addr==0x%08llx, PTE.system=%d, PTE.valid=%d\n" , + (unsigned long long )pte_fields.page_base_addr, + (int )pte_fields.system, + (int )pte_fields.valid);DEBUG ("pte_idx=%llx, page_base_addr=0x%llx, fragment=%u, system=%d, valid=%d\n" , (unsigned long long )pte_idx, (unsigned long long )pte_fields.page_base_addr, (unsigned )pte_fields.fragment, (int )pte_fields.system, (int )pte_fields.valid);// compute starting address @@ -207,7 +236,7 @@ static int umr_read_vram_vi(struct umr_asic *asic, uint32_t vmid, uint64_t addrereturn -1 ; } }else { -if (umr_read_vram (asic,0xFFFF , start_addr, chunk_size, pdst) <0 ) { +if (umr_read_vram (asic,UMR_LINEAR_HUB , start_addr, chunk_size, pdst) <0 ) {fprintf (stderr,"[ERROR]: Cannot read from VRAM\n" );return -1 ; }@@ -244,6 +273,7 @@ static int umr_read_vram_ai(struct umr_asic *asic, uint32_t vmid, uint64_t addre } pte_fields;char buf[64 ];unsigned char *pdst = dst; +char *hub;/* * PTE format on AI: @@ -266,21 +296,28 @@ static int umr_read_vram_ai(struct umr_asic *asic, uint32_t vmid, uint64_t addre* 0 valid */ +if ((vmid &0xFF00 ) ==UMR_MM_HUB ) + hub ="mmhub" ; +else + hub ="gfx" ; + + vmid &=0xFF ; +// read vm registers sprintf (buf,"mmVM_CONTEXT%d_PAGE_TABLE_START_ADDR_LO32" , (int )vmid); - page_table_start_addr = (uint64_t )umr_read_reg_by_name (asic, buf) <<12 ; + page_table_start_addr = (uint64_t )umr_read_reg_by_name_by_ip (asic, hub, buf) <<12 ;sprintf (buf,"mmVM_CONTEXT%d_PAGE_TABLE_START_ADDR_HI32" , (int )vmid); - page_table_start_addr |= (uint64_t )umr_read_reg_by_name (asic, buf) <<44 ; + page_table_start_addr |= (uint64_t )umr_read_reg_by_name_by_ip (asic, hub, buf) <<44 ;sprintf (buf,"mmVM_CONTEXT%d_CNTL" , (int )vmid); - tmp =umr_read_reg_by_name (asic, buf); + tmp =umr_read_reg_by_name_by_ip (asic, hub, buf); page_table_depth =umr_bitslice_reg_by_name (asic, buf,"PAGE_TABLE_DEPTH" , tmp); page_table_size =umr_bitslice_reg_by_name (asic, buf,"PAGE_TABLE_BLOCK_SIZE" , tmp);sprintf (buf,"mmVM_CONTEXT%d_PAGE_TABLE_BASE_ADDR_LO32" , (int )vmid); - page_table_base_addr = (uint64_t )umr_read_reg_by_name (asic, buf) <<0 ; + page_table_base_addr = (uint64_t )umr_read_reg_by_name_by_ip (asic, hub, buf) <<0 ;sprintf (buf,"mmVM_CONTEXT%d_PAGE_TABLE_BASE_ADDR_HI32" , (int )vmid); - page_table_base_addr |= (uint64_t )umr_read_reg_by_name (asic, buf) <<32 ; + page_table_base_addr |= (uint64_t )umr_read_reg_by_name_by_ip (asic, hub, buf) <<32 ;DEBUG ("VIRT_ADDR = %08llx\n" , (unsigned long long )address);DEBUG ("mmVM_CONTEXTx_PAGE_TABLE_START_ADDR = %08llx\n" , (unsigned long long )page_table_start_addr);@@ -288,6 +325,15 @@ static int umr_read_vram_ai(struct umr_asic *asic, uint32_t vmid, uint64_t addreDEBUG ("mmVM_CONTEXTx_CNTL.PAGE_TABLE_BLOCK_SIZE = %lu\n" , page_table_size);DEBUG ("mmVM_CONTEXTx_CNTL.PAGE_TABLE_DEPTH = %d\n" , page_table_depth); +if (asic->options.verbose) +fprintf (stderr,"[VERBOSE]: Decoding %u@0x%llx\nPAGE_TABLE_START_ADDR=0x%llx\nPAGE_TABLE_BASE_ADDR=0x%llx\nPAGE_TABLE_BLOCK_SIZE=%u\nPAGE_TABLE_DEPTH=%u\n" , + (unsigned )vmid, + (unsigned long long )address, + (unsigned long long )page_table_start_addr, + (unsigned long long )page_table_base_addr, + (unsigned )page_table_size, + (unsigned )page_table_depth); + address -= page_table_start_addr;// update addresses for APUs @@ -336,7 +382,7 @@ static int umr_read_vram_ai(struct umr_asic *asic, uint32_t vmid, uint64_t addreDEBUG ("selector mask == %llx\n" , ((unsigned long long )511 << ((page_table_depth-1 )*9 + (12 +9 + page_table_size))));// read PDE entry -if (umr_read_vram (asic,0xFFFF , pde_address + pde_idx *8 ,8 , &pde_entry) <0 ) +if (umr_read_vram (asic,UMR_LINEAR_HUB , pde_address + pde_idx *8 ,8 , &pde_entry) <0 )return -1 ;// decode PDE values @@ -349,6 +395,13 @@ static int umr_read_vram_ai(struct umr_asic *asic, uint32_t vmid, uint64_t addreDEBUG ("PDE==%llx, frag_size=%u, pte_base_addr=0x%llx, valid=%d, system=%d, cache=%d, pte=%d\n" , (unsigned long long )pde_entry, (unsigned )pde_fields.frag_size, (unsigned long long )pde_fields.pte_base_addr, (int )pde_fields.valid, (int )pde_fields.system, (int )pde_fields.cache, (int )pde_fields.pte); +if (asic->options.verbose) +fprintf (stderr,"[VERBOSE]: PDE.pte_base_addr==0x%llx, PDE.valid=%d, PDE.system=%d, PDE.cache=%d, PDE.pte=%d\n" , + (unsigned long long )pde_fields.pte_base_addr, + (int )pde_fields.valid, + (int )pde_fields.system, + (int )pde_fields.cache, + (int )pde_fields.pte);if (!pde_fields.system) pde_fields.pte_base_addr -= vm_fb_offset;@@ -360,7 +413,7 @@ static int umr_read_vram_ai(struct umr_asic *asic, uint32_t vmid, uint64_t addre }// now read PTE entry for this page -if (umr_read_vram (asic,0xFFFF , pde_fields.pte_base_addr + pte_idx*8 ,8 , &pte_entry) <0 ) +if (umr_read_vram (asic,UMR_LINEAR_HUB , pde_fields.pte_base_addr + pte_idx*8 ,8 , &pte_entry) <0 )return -1 ;// decode PTE values @@ -371,6 +424,11 @@ static int umr_read_vram_ai(struct umr_asic *asic, uint32_t vmid, uint64_t addreDEBUG ("PTE=%llx, pte_idx=%llx, page_base_addr=0x%llx, fragment=%u, system=%d, valid=%d\n" , (unsigned long long )pte_entry, (unsigned long long )pte_idx, (unsigned long long )pte_fields.page_base_addr, (unsigned )pte_fields.fragment, (int )pte_fields.system, (int )pte_fields.valid); +if (asic->options.verbose) +fprintf (stderr,"[VERBOSE]: PTE.page_base_addr==0x%08llx, PTE.system=%d, PTE.valid=%d\n" , + (unsigned long long )pte_fields.page_base_addr, + (int )pte_fields.system, + (int )pte_fields.valid);if (!pte_fields.system) pte_fields.page_base_addr -= vm_fb_offset;@@ -390,11 +448,16 @@ static int umr_read_vram_ai(struct umr_asic *asic, uint32_t vmid, uint64_t addreDEBUG ("pde_idx=%llx, frag_size=%u, pte_base_addr=0x%llx, system=%d, valid=%d\n" , (unsigned long long )pde_idx, (unsigned )pde_fields.frag_size, (unsigned long long )pde_fields.pte_base_addr, (int )pde_fields.system, (int )pde_fields.valid); +if (asic->options.verbose) +fprintf (stderr,"[VERBOSE]: PDE.pte_base_addr==0x%llx, PDE.valid=%d, PDE.system=%d\n" , + (unsigned long long )pde_fields.pte_base_addr, + (int )pde_fields.valid, + (int )pde_fields.system);// PTE addr = baseaddr[47:6] + (logical - start) >> fragsize) pte_idx = (address >> (12 + pde_fields.frag_size)); -if (umr_read_vram (asic,0xFFFF , pde_fields.pte_base_addr + pte_idx *8 ,8 , &pte_entry) <0 ) +if (umr_read_vram (asic,UMR_LINEAR_HUB , pde_fields.pte_base_addr + pte_idx *8 ,8 , &pte_entry) <0 )return -1 ;// decode PTE values @@ -405,6 +468,11 @@ static int umr_read_vram_ai(struct umr_asic *asic, uint32_t vmid, uint64_t addreDEBUG ("pte_idx=%llx, page_base_addr=0x%llx, fragment=%u, system=%d, valid=%d\n" , (unsigned long long )pte_idx, (unsigned long long )pte_fields.page_base_addr, (unsigned )pte_fields.fragment, (int )pte_fields.system, (int )pte_fields.valid); +if (asic->options.verbose) +fprintf (stderr,"[VERBOSE]: PTE.page_base_addr==0x%08llx, PTE.system=%d, PTE.valid=%d\n" , + (unsigned long long )pte_fields.page_base_addr, + (int )pte_fields.system, + (int )pte_fields.valid);// compute starting address @@ -427,7 +495,7 @@ static int umr_read_vram_ai(struct umr_asic *asic, uint32_t vmid, uint64_t addrereturn -1 ; } }else { -if (umr_read_vram (asic,0xFFFF , start_addr, chunk_size, pdst) <0 ) { +if (umr_read_vram (asic,UMR_LINEAR_HUB , start_addr, chunk_size, pdst) <0 ) {fprintf (stderr,"[ERROR]: Cannot read from VRAM\n" );return -1 ; }@@ -451,7 +519,7 @@ int umr_read_vram(struct umr_asic *asic, uint32_t vmid, uint64_t address, uint32return -1 ; } -if (vmid ==0xFFFF ) { +if ((vmid &0xFF00 ) ==UMR_LINEAR_HUB ) {DEBUG ("Reading physical VRAM addr: 0x%llx\n" , (unsigned long long )address);// addressing is physical if (asic->options.use_pci ==0 ) {src/lib/ring_decode.c +2
-2@@ -589,7 +589,7 @@ static void print_decode_pm4(struct umr_asic *asic, struct umr_ring_decoder *dec// detect VCN/UVD IBs and chain them once all // 4 pieces of information are found if (!strcmp (name,"mmUVD_LMI_RBC_IB_VMID" )) { - decoder->pm4.next_ib_state.ib_vmid = ib; + decoder->pm4.next_ib_state.ib_vmid = ib | ((asic->family <=FAMILY_VI ) ?0 :UMR_MM_HUB ); decoder->pm4.next_ib_state.tally |=1 ; }else if (!strcmp (name,"mmUVD_LMI_RBC_IB_64BIT_BAR_LOW" )) { decoder->pm4.next_ib_state.ib_addr_lo = ib;@@ -598,7 +598,7 @@ static void print_decode_pm4(struct umr_asic *asic, struct umr_ring_decoder *dec decoder->pm4.next_ib_state.ib_addr_hi = ib; decoder->pm4.next_ib_state.tally |=4 ; }else if (!strcmp (name,"mmUVD_RBC_IB_SIZE" )) { - decoder->pm4.next_ib_state.ib_size = ib; + decoder->pm4.next_ib_state.ib_size = ib *4 ; decoder->pm4.next_ib_state.tally |=8 ; }src/lib/sq_cmd_halt_waves.c new file +57
-0@@ -0,0 +1,57 @@ +/* +* Copyright 2017 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +* +* Authors: Tom St Denis <[email protected]> +* +*/ +#include "umr.h" + +int umr_sq_cmd_halt_waves (struct umr_asic *asic,enum umr_sq_cmd_halt_resume mode) +{ +struct umr_reg *reg; +uint32_t value; +uint64_t addr; + + reg =umr_find_reg_data (asic,"SQ_CMD" ); +if (!reg) { +fprintf (stderr,"[BUG]: Cannot find SQ_CMD register in umr_sq_cmd_halt_waves()\n" ); +return -1 ; + } + +// compose value +if (asic->family ==FAMILY_CIK ) { + value =umr_bitslice_compose_value (asic, reg,"CMD" , mode ==UMR_SQ_CMD_HALT ?1 :2 );// SETHALT + }else { + value =umr_bitslice_compose_value (asic, reg,"CMD" ,1 );// SETHALT + value |=umr_bitslice_compose_value (asic, reg,"DATA" , mode ==UMR_SQ_CMD_HALT ?1 :0 ); + } + value |=umr_bitslice_compose_value (asic, reg,"MODE" ,1 );// BROADCAST + +// compose address + addr = reg->addr *4 ; + addr |= (1ULL <<62 ) |// we need to take the lock so we can ensure a broadcast write + (0x3FFULL <<24 ) | + (0x3FFULL <<34 ) | + (0x3FFULL <<44 ); +umr_write_reg (asic, addr, value, reg->type); + +return 0 ; +}src/umr.h +26
-1@@ -33,6 +33,20 @@#include <pciaccess.h> #include <pthread.h> +/* SQ_CMD halt/resume */ +enum umr_sq_cmd_halt_resume { +UMR_SQ_CMD_HALT =0 , +UMR_SQ_CMD_RESUME , +}; + +/* memory space hubs */ +enum umr_hub_space { +UMR_GFX_HUB =0 <<8 ,// default on everything before AI +UMR_MM_HUB =1 <<8 ,// available on AI and later + +UMR_LINEAR_HUB =0xFF <<8 ,// this is for linear access to vram +}; +/* sourced from amd_powerplay.h from the kernel */ enum amd_pp_sensors {AMDGPU_PP_SENSOR_GFX_SCLK =0 ,@@ -174,6 +188,8 @@ struct umr_options { read_smc, quiet, follow_ib, + verbose, + halt_waves, no_kernel;unsigned instance_bank,@@ -477,6 +493,7 @@ int umr_create_mmio_accel(struct umr_asic *asic);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_by_ip (struct umr_asic *asic,char *ip,char *regname);struct umr_reg *umr_find_reg_data (struct umr_asic *asic,char *regname);// read/write a 32-bit register given a BYTE address @@ -487,17 +504,26 @@ int umr_write_reg(struct umr_asic *asic, uint64_t addr, uint32_t value, enum reguint32_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); +// read/write a register by ip/name +uint32_t umr_read_reg_by_name_by_ip (struct umr_asic *asic,char *ip,char *name); +int umr_write_reg_by_name_by_ip (struct umr_asic *asic,char *ip,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); +uint32_t umr_bitslice_reg_by_name_by_ip (struct umr_asic *asic,char *ip,char *regname,char *bitname,uint32_t regvalue);// 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); +uint32_t umr_bitslice_compose_value_by_name_by_ip (struct umr_asic *asic,char *ip,char *regname,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); +// halt/resume SQ waves +int umr_sq_cmd_halt_waves (struct umr_asic *asic,enum umr_sq_cmd_halt_resume mode); +/* IB/ring decoding/dumping/etc */ void umr_print_decode (struct umr_asic *asic,struct umr_ring_decoder *decoder,uint32_t ib);void umr_dump_ib (struct umr_asic *asic,struct umr_ring_decoder *decoder); --2.12.0
Quoted 4 lines
_______________________________________________
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
Quoted 13 lines · Tom St Denis
This patch series reflects a slew of changes that fell out of team meetings with mesa/kmd members over the last week.
We remove the "risky" option and the --print command since it's more annoying than helpful.
We add the ability to specify the VMID in hex with --vram which is handy with the last patch since you can specify which VM hub to use in hex easier than in decimal.
The third patch includes various small cleanups found by static analysis and code review.
Quoted 7 lines
The last patch includes two new features which were written at the same time and were a bit tricky to separate (more effort than worth). First, we add the ability to halt waves when reading them which should help reading consistent data. Next we add the ability to decode multimedia IBs from the UVD/VCN rings. Next we fix using the '
mmMC_VM_FB_LOCATION' register which was traditionally zero on VI (and below) but now has non-zero values which broke VM decoding. Tested on Carrizo/Polaris/Raven.
Note that the fb_location is potentially non-0 on all asics going forward. We just leave it as programmed via the vbios now.
Alex
Quoted 9 lines
Finally, the last patch adds the ability to specify a 'verbose' option which prints out VM decoding information handy for debugging both umr and the kmd.
_______________________________________________
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
Quoted 22 lines · Alex Deucher
Quoted 13 lines · Tom St Denis
This patch series reflects a slew of changes that fell out of team meetings with mesa/kmd members over the last week.
We remove the "risky" option and the --print command since it's more annoying than helpful.
We add the ability to specify the VMID in hex with --vram which is handy with the last patch since you can specify which VM hub to use in hex easier than in decimal.
The third patch includes various small cleanups found by static analysis and code review.
Quoted 7 lines
The last patch includes two new features which were written at the same time and were a bit tricky to separate (more effort than worth). First, we add the ability to halt waves when reading them which should help reading consistent data. Next we add the ability to decode multimedia IBs from the UVD/VCN rings. Next we fix using the '
mmMC_VM_FB_LOCATION' register which was traditionally zero on VI (and below) but now has non-zero values which broke VM decoding. Tested on Carrizo/Polaris/Raven.
Quoted 2 lines
Note that the
fb_locationis potentially non-0 on all asics going forward. We just leave it as programmed via the vbios now.
umr treated it as zero previously and I was able to read IBs/etc on my various VI hardware. In testing the patches this morning I discovered it didn't work and my offsets were off by a huge margin which aligned with what I was reading from the register :-).
As of this morning I can read gfx/uvd IBs on VI APU/dGPU and my only AI+ hardware which is an APU. I assume vega10 will be the same though hopefully.
If someone with a vega10 could run
umr -O follow_ib,verbose -R vcn_dec[0:79]
(with /dev/fmem or STRICT_MEM disabled...) that could easily confirm if VMID 0 decodings are working.
Thanks,
Tom
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx