[PATCH umr 2/2] Simplify the ability to read multiple registers at once

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Previously the "many" option would be needed to read related
registers at once.  This adds the ability to simply using a trailing
star on the name, for instance,

$ umr -r *.vcn10.ADDR*
vcn10.mmUVD_JPEG_ADDR_CONFIG => 0x22010010
vcn10.mmUVD_JPEG_UV_ADDR_CONFIG => 0x22010010
vcn10.mmUVD_SEMA_ADDR_LOW => 0x00000000
vcn10.mmUVD_SEMA_ADDR_HIGH => 0x00000000
vcn10.mmUVD_UDEC_DBW_UV_ADDR_CONFIG => 0x22010010
...<snip>...

Signed-off-by: Tom St Denis <tom.stdenis at amd.com>
---
 doc/sphinx/source/register_access.rst |  9 +++++++++
 doc/umr.1                             |  7 ++++++-
 src/app/main.c                        |  4 +++-
 src/app/scan.c                        | 18 +++++++++++++-----
 4 files changed, 31 insertions(+), 7 deletions(-)

diff --git a/doc/sphinx/source/register_access.rst b/doc/sphinx/source/register_access.rst
index 58dd783d2e19..8ea8c4596d5e 100644
--- a/doc/sphinx/source/register_access.rst
+++ b/doc/sphinx/source/register_access.rst
@@ -63,6 +63,15 @@ example:
 Will read and print out any register with the word 'GATE' contained
 in the register name in the uvd6 IP block.
 
+This can also be accomplished by using a '*' at the end of the register
+name.  For example:
+
+::
+
+	umr --read *.uvd6.GATE*
+
+would accomplish the same as the previous example.
+
 --------------------------
 Reading an entire IP block
 --------------------------
diff --git a/doc/umr.1 b/doc/umr.1
index c64855ca439f..ab6dbd51fd6e 100644
--- a/doc/umr.1
+++ b/doc/umr.1
@@ -56,7 +56,12 @@ This command uses the same syntax as the
 .B --write
 command but also allows
 .B *
-for the regname field.
+for the regname field to read an entire block.  Additionally,
+a
+.B *
+can be appended to a register name to read any register that contains
+a partial match.  For instance, "*.vcn10.ADDR*" would read any register
+from the 'VCN10' block which contains 'ADDR' in the name.
 .IP "--scan, -s <string>"
 Scan and print an IP block by name, for example,
 .B uvd6
diff --git a/src/app/main.c b/src/app/main.c
index cea6ac2e1069..6165b44d2799 100644
--- a/src/app/main.c
+++ b/src/app/main.c
@@ -512,7 +512,9 @@ int main(int argc, char **argv)
 "\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\tuses the same path notation as --write.  It also accepts * for regname."
+	"\n\t\tA trailing * on a regname will read any register that has a name that contains the"
+	"\n\t\tremainder of the name specified.\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. "
diff --git a/src/app/scan.c b/src/app/scan.c
index 684417704126..287c791e8ec7 100644
--- a/src/app/scan.c
+++ b/src/app/scan.c
@@ -26,10 +26,18 @@
 
 int umr_scan_asic(struct umr_asic *asic, char *asicname, char *ipname, char *regname)
 {
-	int r, fd;
-	int first, i, j, k;
+	int r, fd, many = asic->options.many, named = asic->options.named,
+	    first, i, j, k;
 	uint64_t addr, scale;
-	char buf[256];
+	char buf[256], regname_copy[256];
+
+	// does the register name contain a trailing star?
+	strcpy(regname_copy, regname);
+	if (strlen(regname) > 1 && strstr(regname, "*")) {
+		many = 1;
+		named = 1;
+		regname_copy[strlen(regname_copy)-1] = 0;
+	}
 
 	/* scan them all in order */
 	if (!asicname[0] || !strcmp(asicname, "*") || !strcmp(asicname, asic->asicname)) {
@@ -38,7 +46,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) ||
-					(asic->options.many && strstr(asic->blocks[i]->regs[j].regname, regname))) {
+					(many && strstr(asic->blocks[i]->regs[j].regname, regname_copy))) {
 						// only grant if any regspec matches otherwise it's a waste
 						if (first && asic->blocks[i]->grant) {
 							first = 0;
@@ -91,7 +99,7 @@ int umr_scan_asic(struct umr_asic *asic, char *asicname, char *ipname, char *reg
 								umr_grbm_select_index(asic, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF);
 						}
 						if (regname[0]) {
-							if (asic->options.named)
+							if (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 (asic->options.bitfields)
-- 
2.14.3



[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux