[PATCH umr] Add vbios_version to config data and print out with 'umr -c'

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

 



Signed-off-by: Tom St Denis <tom.stdenis at amd.com>
---
 src/app/print_config.c |  8 ++++++--
 src/lib/discover.c     | 23 +++++++++++++++--------
 src/lib/scan_config.c  |  9 +++++++++
 src/umr.h              |  1 +
 4 files changed, 31 insertions(+), 10 deletions(-)

diff --git a/src/app/print_config.c b/src/app/print_config.c
index 051666d52e02..1e481906a3be 100644
--- a/src/app/print_config.c
+++ b/src/app/print_config.c
@@ -100,8 +100,12 @@ void umr_print_config(struct umr_asic *asic)
 {
 	int r, x;
 
-	printf("\tasic.instance == %d\n\n", asic->instance);
-	printf("\tumr.version == %s\n\n", UMR_BUILD_REV);
+	printf("\tasic.instance == %d\n", asic->instance);
+	printf("\tasic.devname == %s\n", asic->options.pci.name);
+
+	printf("\n\tumr.version == %s\n\n", UMR_BUILD_REV);
+
+	printf("\tvbios.version == %s\n\n", asic->config.vbios_version);
 
 	for (r = 0; asic->config.fw[r].name[0]; r++) {
 		printf("\tfw.%s == .feature==%lu .firmware==0x%08lx\n",
diff --git a/src/lib/discover.c b/src/lib/discover.c
index 31ff25b06f9f..dcc212fc39e4 100644
--- a/src/lib/discover.c
+++ b/src/lib/discover.c
@@ -101,7 +101,7 @@ struct umr_asic *umr_discover_asic(struct umr_options *options)
 	unsigned did;
 	struct umr_asic *asic;
 	long trydid = options->forcedid;
-	int busmatch = 0, parsed_did;
+	int busmatch = 0, parsed_did, need_config_scan = 0;
 
 	// Try to map to instance if we have a specific pci device
 	if (options->pci.domain || options->pci.bus ||
@@ -169,13 +169,16 @@ struct umr_asic *umr_discover_asic(struct umr_options *options)
 		if (strstr(name, "dev="))
 			memmove(name, name+4, strlen(name)-3);
 
-		// read the PCI info
-		strcpy(options->pci.name, name);
-		sscanf(name, "%04x:%02x:%02x.%x",
-			&options->pci.domain,
-			&options->pci.bus,
-			&options->pci.slot,
-			&options->pci.func);
+		if (!strlen(options->pci.name)) {
+			// read the PCI info
+			strcpy(options->pci.name, name);
+			sscanf(name, "%04x:%02x:%02x.%x",
+				&options->pci.domain,
+				&options->pci.bus,
+				&options->pci.slot,
+				&options->pci.func);
+			need_config_scan = 1;
+		}
 	}
 
 	if (trydid < 0) {
@@ -321,6 +324,10 @@ struct umr_asic *umr_discover_asic(struct umr_options *options)
 			asic->pci.mem = pcimem_v;
 		}
 	}
+
+	if (need_config_scan)
+		umr_scan_config(asic);
+
 	return asic;
 err_pci:
 	umr_close_asic(asic);
diff --git a/src/lib/scan_config.c b/src/lib/scan_config.c
index 5d2975f33e34..ade2d6e032bf 100644
--- a/src/lib/scan_config.c
+++ b/src/lib/scan_config.c
@@ -87,6 +87,15 @@ int umr_scan_config(struct umr_asic *asic)
 	if (asic->options.no_kernel)
 		return -1;
 
+	// read vbios version
+	snprintf(fname, sizeof(fname)-1, "/sys/bus/pci/devices/%s/vbios_version", asic->options.pci.name);
+	f = fopen(fname, "r");
+	if (f) {
+		fgets(asic->config.vbios_version, sizeof(asic->config.vbios_version)-1, f);
+		asic->config.vbios_version[strlen(asic->config.vbios_version)-1] = 0; // remove newline...
+		fclose(f);
+	}
+
 	/* process FW block */
 	snprintf(fname, sizeof(fname)-1, "/sys/kernel/debug/dri/%d/amdgpu_firmware_info", asic->instance);
 	f = fopen(fname, "r");
diff --git a/src/umr.h b/src/umr.h
index fa89b92a4b8c..b6fe4ee876a7 100644
--- a/src/umr.h
+++ b/src/umr.h
@@ -232,6 +232,7 @@ struct umr_asic {
 		struct umr_gfx_config gfx;
 		struct umr_fw_config fw[UMR_MAX_FW];
 		struct umr_pci_config pci;
+		char vbios_version[128];
 	} config;
 	struct {
 		int mmio,
-- 
2.12.0



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

  Powered by Linux