Skip to contentSkip to conversation

Allow * for ipname in --read/--write/--write-bit (v2)

PATCH New Tom St Denis 1 participant 1 message Feb 23, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Allow * for ipname in --read/--write/--write-bit (v2)

To simplify scripting you can now use * for ipnames as well.

(v2) Continue matching other IP blocks after first register hit.

---
 doc/umr.1         |   6 ++-
 src/app/main.c    |   5 ++-
 src/app/scan.c    |  32 ++++++++-------
 src/app/set_bit.c | 117 +++++++++++++++++++++++++++---------------------------
 src/app/set_reg.c |  91 +++++++++++++++++++++---------------------
 5 files changed, 128 insertions(+), 123 deletions(-)
doc/umr.1 +4 -2
index 5ed2c3bb93ae..a12dfb0a00ff 100644
@@ -34,7 +34,7 @@ Look up an MMIO register by address and bitfield decode the value specified.
 Write a value specified in hex to a register specified with a complete
 register path in the form <
 .B asicname.ipname.regname
->.  For example, fiji.uvd6.mmUVD_CGC_GATE.  The value of asicname can be
+>.  For example, fiji.uvd6.mmUVD_CGC_GATE.  The value of asicname and/or ipname can be
 .B *
 to simplify scripting.  This command can be used multiple times to
 write to multiple registers in a single invocation.
@@ -52,7 +52,9 @@ command but also allows
 for the regname field.
 .IP "--scan, -s <string>"
 Scan and print an IP block by name, for example,
-.B uvd5.
+.B uvd6
+or
+.B carrizo.uvd6.
 Can be used multiple times in a single invocation.
 .IP "--ring, -R <string>(from:to)"
 Read the contents of a ring named by the string without the
src/app/main.c +3 -2
index 8364d54c5227..99e014888571 100644
@@ -364,12 +364,13 @@ int main(int argc, char **argv)
 "\n\t--write, -w <address> <number>\n\t\tWrite a value in hex to a register specified as a register path in the"
 	"\n\t\tform <asicname.ipname.regname>.  For instance \"tonga.uvd5.mmUVD_SOFT_RESET\"."
 	"\n\t\tCan be used multiple times to set multiple registers.  You can"
-	"\n\t\tspecify * for asicname to simplify scripts.\n"
+	"\n\t\tspecify * for asicname and/or ipname to simplify scripts.\n"
 "\n\t--writebit, -wb <string> <number>\n\t\tWrite a value in hex to a register bitfield specified as in --write but"
 	"\n\t\tthe addition of the bitfield name.  For instance: \"*.gfx80.mmRLC_PG_CNTL.PG_OVERRIDE\"\n"
 "\n\t--read, -r <string>\n\t\tRead a value from a register and print it to stdout.  This command"
 	"\n\t\tuses the same path notation as --write.  It also accepts * for regname.\n"
-"\n\t--scan, -s <string>\n\t\tScan and print an ip block by name, e.g. \"uvd5\".  Can be used multiple times.\n"
+"\n\t--scan, -s <string>\n\t\tScan and print an ip block by name, e.g. \"uvd6\" or \"carrizo.uvd6\"."
+	"\n\t\tCan be used multiple times.\n"
 "\n\t--ring, -R <string>([from:to])\n\t\tRead the contents of a ring named by the string without the amdgpu_ring_ prefix. "
 	"\n\t\tBy default it will read and display the entire ring.  A starting and ending "
 	"\n\t\taddress can be specified in decimal or a '.' can be used to indicate relative "
src/app/scan.c +18 -14
index 19c97fe1499d..e91fbd4649c8 100644
@@ -27,27 +27,30 @@
 int umr_scan_asic(struct umr_asic *asic, char *asicname, char *ipname, char *regname)
 {
 	int r, fd;
-	int i, j, k;
+	int first, i, j, k;
 	uint64_t addr, scale;
 	char buf[256];
 
 	/* scan them all in order */
 	if (!asicname[0] || !strcmp(asicname, "*") || !strcmp(asicname, asic->asicname)) {
 		for (i = 0; i < asic->no_blocks; i++) {
-			if (!ipname[0] || !strcmp(ipname, asic->blocks[i]->ipname)) {
-				if (asic->blocks[i]->grant) {
-					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;
-					}
-				}
+			if (!ipname[0] || ipname[0] == '*' || !strcmp(ipname, asic->blocks[i]->ipname)) {
+				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))) {
+						// only grant if any regspec matches otherwise it's a waste
+						if (first && asic->blocks[i]->grant) {
+							first = 0;
+							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;
+							}
+						}
 						if (asic->pci.mem == NULL) {
 							switch(asic->blocks[i]->regs[j].type) {
 							case REG_MMIO: fd = asic->fd.mmio; scale = 4; break;
@@ -89,7 +92,7 @@ int umr_scan_asic(struct umr_asic *asic, char *asicname, char *ipname, char *reg
 						}
 						if (regname[0]) {
 							if (options.named)
-								printf("%s%s%s => ", CYAN, asic->blocks[i]->regs[j].regname, RST);
+								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)
 								for (k = 0; k < asic->blocks[i]->regs[j].no_bits; k++) {
@@ -101,7 +104,8 @@ int umr_scan_asic(struct umr_asic *asic, char *asicname, char *ipname, char *reg
 						}
 					}
 				}
-				if (asic->blocks[i]->release) {
+				// only release if granted
+				if (!first && asic->blocks[i]->release) {
 					r = asic->blocks[i]->release(asic);
 					if (r)
 						goto error;
src/app/set_bit.c +58 -59

137 lines not on this page · raw message

src/app/set_reg.c +45 -46

109 lines not on this page · raw message

Signature · 6 lines
2.11.0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx