All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Gu, JiaWei (Will)" <JiaWei.Gu@amd.com>
To: "Gu, JiaWei (Will)" <JiaWei.Gu@amd.com>,
	"StDenis, Tom" <Tom.StDenis@amd.com>,
	"amd-gfx@lists.freedesktop.org" <amd-gfx@lists.freedesktop.org>
Cc: "Deucher, Alexander" <Alexander.Deucher@amd.com>
Subject: RE: [PATCH] add vbios info query
Date: Fri, 14 May 2021 03:03:11 +0000	[thread overview]
Message-ID: <CH0PR12MB51569D72B2C29929B5BBB127F8509@CH0PR12MB5156.namprd12.prod.outlook.com> (raw)
In-Reply-To: <20210512033451.19253-1-Jiawei.Gu@amd.com>

[-- Attachment #1: Type: text/plain, Size: 7506 bytes --]

[AMD Official Use Only - Internal Distribution Only]

Hi Tom,

Can you help review & merge this patch to bring vbios IOCTL usage in UMR back?
The patch is also attached.

Thanks in advance,
Jiawei

-----Original Message-----
From: Jiawei Gu <Jiawei.Gu@amd.com> 
Sent: Wednesday, May 12, 2021 11:35 AM
To: StDenis, Tom <Tom.StDenis@amd.com>; amd-gfx@lists.freedesktop.org
Cc: Deucher, Alexander <Alexander.Deucher@amd.com>; Gu, JiaWei (Will) <JiaWei.Gu@amd.com>
Subject: [PATCH] add vbios info query

Signed-off-by: Jiawei Gu <Jiawei.Gu@amd.com>
---
 src/app/CMakeLists.txt             |  1 +
 src/app/main.c                     |  8 +++++
 src/app/vbios.c                    | 58 ++++++++++++++++++++++++++++++
 src/lib/lowlevel/linux/query_drm.c | 11 ++++++
 src/umr.h                          | 15 ++++++++
 src/umrapp.h                       |  1 +
 6 files changed, 94 insertions(+)
 create mode 100644 src/app/vbios.c

diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index ca7d46b..462e4fc 100644
--- a/src/app/CMakeLists.txt
+++ b/src/app/CMakeLists.txt
@@ -35,6 +35,7 @@ add_library(umrapp STATIC
   pp_table.c
   navi10_ppt.c
   read_metrics.c
+  vbios.c
   ${GUI_SOURCE}
 )
 
diff --git a/src/app/main.c b/src/app/main.c index 47ddb38..b484cf3 100644
--- a/src/app/main.c
+++ b/src/app/main.c
@@ -825,6 +825,11 @@ int main(int argc, char **argv)
 				asic = get_asic();
 			ih_self_test(asic);
 #endif
+		} else if (!strcmp(argv[i], "--vbios_info") || !strcmp(argv[i], "-vi")) {
+			if (!asic)
+				asic = get_asic();
+			if (umr_print_vbios_info(asic) != 0)
+				fprintf(stderr, "[ERROR]: Cannot print vbios info.\n");
 		} else if (!strcmp(argv[i], "--help") || !strcmp(argv[i], "-h")) {
 			printf("User Mode Register debugger v%s for AMDGPU devices (build: %s [%s]), Copyright (c) 2021, AMD Inc.\n"
 "\n*** Device Selection ***\n"
@@ -951,6 +956,9 @@ printf(
 	"\n\t\tPrint the GPU metrics table for the device."
 "\n\t--power, -p \n\t\tRead the conetent of clocks, temperature, gpu loading at runtime"
 	"\n\t\toptions 'use_colour' to colourize output \n");
+printf(
+"\n*** Video BIOS Information ***\n"
+"\n\t--vbios_info, -vi \n\t\tPrint Video BIOS information\n");
 
 #if UMR_GUI
 printf(
diff --git a/src/app/vbios.c b/src/app/vbios.c new file mode 100644 index 0000000..98e0f87
--- /dev/null
+++ b/src/app/vbios.c
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2021 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 <tom.stdenis@amd.com>
+ *
+ */
+#include "umrapp.h"
+
+#define AMDGPU_INFO_VBIOS			0x1B
+#define AMDGPU_INFO_VBIOS_INFO			0x3
+int umr_print_vbios_info(struct umr_asic *asic) {
+	char fname[64];
+	int r;
+	struct umr_vbios_info vbios_info;
+
+	if (asic->fd.drm < 0) {
+		snprintf(fname, sizeof(fname)-1, "/dev/dri/card%d", asic->instance);
+		asic->fd.drm = open(fname, O_RDWR);
+	}
+
+	r = umr_query_drm_vbios(asic, AMDGPU_INFO_VBIOS, AMDGPU_INFO_VBIOS_INFO,
+			&vbios_info, sizeof(vbios_info));
+	if (r)
+		return r;
+
+	printf("vbios name          : %s\n", vbios_info.name);
+	printf("vbios dbdf          : 0x%x\n", vbios_info.dbdf);
+	printf("vbios pn            : %s\n", vbios_info.vbios_pn);
+	printf("vbios version       : %d\n", vbios_info.version);
+	printf("vbios date          : %s\n", vbios_info.date);
+	printf("vbios serial        : %lld\n", vbios_info.serial);
+	printf("vbios dev_id        : 0x%x\n", vbios_info.dev_id);
+	printf("vbios rev_id        : 0x%x\n", vbios_info.rev_id);
+	printf("vbios sub_dev_id    : 0x%x\n", vbios_info.sub_dev_id);
+	printf("vbios sub_ved_id    : 0x%x\n", vbios_info.sub_ved_id);
+
+	close(asic->fd.drm);
+	return 0;
+}
\ No newline at end of file
diff --git a/src/lib/lowlevel/linux/query_drm.c b/src/lib/lowlevel/linux/query_drm.c
index d0c82d4..f4ab709 100644
--- a/src/lib/lowlevel/linux/query_drm.c
+++ b/src/lib/lowlevel/linux/query_drm.c
@@ -49,7 +49,18 @@ int umr_query_drm(struct umr_asic *asic, int field, void *ret, int size)
 	inf.return_size = size;
 	inf.query = field;
 	return ioctl(asic->fd.drm, DRM_IOC(DRM_IOC_WRITE, DRM_IOCTL_BASE, DRM_COMMAND_BASE + DRM_AMDGPU_INFO, sizeof(inf)), &inf);
+}
 
+int umr_query_drm_vbios(struct umr_asic *asic, int field, int type, 
+void *ret, int size) {
+	struct drm_amdgpu_info inf;
+
+	memset(&inf, 0, sizeof inf);
+	inf.return_pointer = (uintptr_t)ret;
+	inf.return_size = size;
+	inf.query = field;
+	inf.vbios_info.type = type;
+	return ioctl(asic->fd.drm, DRM_IOC(DRM_IOC_WRITE, DRM_IOCTL_BASE, 
+DRM_COMMAND_BASE + DRM_AMDGPU_INFO, sizeof(inf)), &inf);
 }
 
 #else
diff --git a/src/umr.h b/src/umr.h
index 4e730e5..41266e2 100644
--- a/src/umr.h
+++ b/src/umr.h
@@ -973,6 +973,7 @@ void umr_free_asic(struct umr_asic *asic);  void umr_free_maps(struct umr_asic *asic);  void umr_close_asic(struct umr_asic *asic); // call this to close a fully open asic  int umr_query_drm(struct umr_asic *asic, int field, void *ret, int size);
+int umr_query_drm_vbios(struct umr_asic *asic, int field, int type, 
+void *ret, int size);
 void umr_enumerate_devices(void);
 int umr_update(struct umr_asic *asic, char *script);  int umr_update_string(struct umr_asic *asic, char *sdata); @@ -1349,6 +1350,20 @@ struct umr_soc15_database {
 	struct umr_soc15_database *next;
 };
 
+// vbios
+struct umr_vbios_info {
+	uint8_t name[64];
+	uint32_t dbdf;
+	uint8_t vbios_pn[64];
+	uint32_t version;
+	uint8_t date[32];
+	uint64_t serial;
+	uint32_t dev_id;
+	uint32_t rev_id;
+	uint32_t sub_dev_id;
+	uint32_t sub_ved_id;
+};
+
 FILE *umr_database_open(char *path, char *filename);  struct umr_soc15_database *umr_database_read_soc15(char *path, char *filename);  void umr_database_free_soc15(struct umr_soc15_database *soc15); diff --git a/src/umrapp.h b/src/umrapp.h index 14457fe..1336e07 100644
--- a/src/umrapp.h
+++ b/src/umrapp.h
@@ -57,5 +57,6 @@ void umr_clock_scan(struct umr_asic *asic, const char* clock_name);  void umr_clock_manual(struct umr_asic *asic, const char* clock_name, void* value);  int umr_print_pp_table(struct umr_asic *asic, const char* param);  int umr_print_gpu_metrics(struct umr_asic *asic);
+int umr_print_vbios_info(struct umr_asic *asic);
 
 void run_server_loop(const char *url, struct umr_asic * asic);
--
2.17.1

[-- Attachment #2: 0001-add-vbios-info-query.patch --]
[-- Type: application/octet-stream, Size: 6967 bytes --]

From 636698d457abf602019ee0ad60e8681e6723f7f5 Mon Sep 17 00:00:00 2001
From: Jiawei Gu <Jiawei.Gu@amd.com>
Date: Wed, 12 May 2021 11:30:56 +0800
Subject: [PATCH] add vbios info query

Signed-off-by: Jiawei Gu <Jiawei.Gu@amd.com>
---
 src/app/CMakeLists.txt             |  1 +
 src/app/main.c                     |  8 +++++
 src/app/vbios.c                    | 58 ++++++++++++++++++++++++++++++
 src/lib/lowlevel/linux/query_drm.c | 11 ++++++
 src/umr.h                          | 15 ++++++++
 src/umrapp.h                       |  1 +
 6 files changed, 94 insertions(+)
 create mode 100644 src/app/vbios.c

diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt
index ca7d46b..462e4fc 100644
--- a/src/app/CMakeLists.txt
+++ b/src/app/CMakeLists.txt
@@ -35,6 +35,7 @@ add_library(umrapp STATIC
   pp_table.c
   navi10_ppt.c
   read_metrics.c
+  vbios.c
   ${GUI_SOURCE}
 )
 
diff --git a/src/app/main.c b/src/app/main.c
index 47ddb38..b484cf3 100644
--- a/src/app/main.c
+++ b/src/app/main.c
@@ -825,6 +825,11 @@ int main(int argc, char **argv)
 				asic = get_asic();
 			ih_self_test(asic);
 #endif
+		} else if (!strcmp(argv[i], "--vbios_info") || !strcmp(argv[i], "-vi")) {
+			if (!asic)
+				asic = get_asic();
+			if (umr_print_vbios_info(asic) != 0)
+				fprintf(stderr, "[ERROR]: Cannot print vbios info.\n");
 		} else if (!strcmp(argv[i], "--help") || !strcmp(argv[i], "-h")) {
 			printf("User Mode Register debugger v%s for AMDGPU devices (build: %s [%s]), Copyright (c) 2021, AMD Inc.\n"
 "\n*** Device Selection ***\n"
@@ -951,6 +956,9 @@ printf(
 	"\n\t\tPrint the GPU metrics table for the device."
 "\n\t--power, -p \n\t\tRead the conetent of clocks, temperature, gpu loading at runtime"
 	"\n\t\toptions 'use_colour' to colourize output \n");
+printf(
+"\n*** Video BIOS Information ***\n"
+"\n\t--vbios_info, -vi \n\t\tPrint Video BIOS information\n");
 
 #if UMR_GUI
 printf(
diff --git a/src/app/vbios.c b/src/app/vbios.c
new file mode 100644
index 0000000..98e0f87
--- /dev/null
+++ b/src/app/vbios.c
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2021 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 <tom.stdenis@amd.com>
+ *
+ */
+#include "umrapp.h"
+
+#define AMDGPU_INFO_VBIOS			0x1B
+#define AMDGPU_INFO_VBIOS_INFO			0x3
+int umr_print_vbios_info(struct umr_asic *asic)
+{
+	char fname[64];
+	int r;
+	struct umr_vbios_info vbios_info;
+
+	if (asic->fd.drm < 0) {
+		snprintf(fname, sizeof(fname)-1, "/dev/dri/card%d", asic->instance);
+		asic->fd.drm = open(fname, O_RDWR);
+	}
+
+	r = umr_query_drm_vbios(asic, AMDGPU_INFO_VBIOS, AMDGPU_INFO_VBIOS_INFO,
+			&vbios_info, sizeof(vbios_info));
+	if (r)
+		return r;
+
+	printf("vbios name          : %s\n", vbios_info.name);
+	printf("vbios dbdf          : 0x%x\n", vbios_info.dbdf);
+	printf("vbios pn            : %s\n", vbios_info.vbios_pn);
+	printf("vbios version       : %d\n", vbios_info.version);
+	printf("vbios date          : %s\n", vbios_info.date);
+	printf("vbios serial        : %lld\n", vbios_info.serial);
+	printf("vbios dev_id        : 0x%x\n", vbios_info.dev_id);
+	printf("vbios rev_id        : 0x%x\n", vbios_info.rev_id);
+	printf("vbios sub_dev_id    : 0x%x\n", vbios_info.sub_dev_id);
+	printf("vbios sub_ved_id    : 0x%x\n", vbios_info.sub_ved_id);
+
+	close(asic->fd.drm);
+	return 0;
+}
\ No newline at end of file
diff --git a/src/lib/lowlevel/linux/query_drm.c b/src/lib/lowlevel/linux/query_drm.c
index d0c82d4..f4ab709 100644
--- a/src/lib/lowlevel/linux/query_drm.c
+++ b/src/lib/lowlevel/linux/query_drm.c
@@ -49,7 +49,18 @@ int umr_query_drm(struct umr_asic *asic, int field, void *ret, int size)
 	inf.return_size = size;
 	inf.query = field;
 	return ioctl(asic->fd.drm, DRM_IOC(DRM_IOC_WRITE, DRM_IOCTL_BASE, DRM_COMMAND_BASE + DRM_AMDGPU_INFO, sizeof(inf)), &inf);
+}
 
+int umr_query_drm_vbios(struct umr_asic *asic, int field, int type, void *ret, int size)
+{
+	struct drm_amdgpu_info inf;
+
+	memset(&inf, 0, sizeof inf);
+	inf.return_pointer = (uintptr_t)ret;
+	inf.return_size = size;
+	inf.query = field;
+	inf.vbios_info.type = type;
+	return ioctl(asic->fd.drm, DRM_IOC(DRM_IOC_WRITE, DRM_IOCTL_BASE, DRM_COMMAND_BASE + DRM_AMDGPU_INFO, sizeof(inf)), &inf);
 }
 
 #else
diff --git a/src/umr.h b/src/umr.h
index 4e730e5..41266e2 100644
--- a/src/umr.h
+++ b/src/umr.h
@@ -973,6 +973,7 @@ void umr_free_asic(struct umr_asic *asic);
 void umr_free_maps(struct umr_asic *asic);
 void umr_close_asic(struct umr_asic *asic); // call this to close a fully open asic
 int umr_query_drm(struct umr_asic *asic, int field, void *ret, int size);
+int umr_query_drm_vbios(struct umr_asic *asic, int field, int type, void *ret, int size);
 void umr_enumerate_devices(void);
 int umr_update(struct umr_asic *asic, char *script);
 int umr_update_string(struct umr_asic *asic, char *sdata);
@@ -1349,6 +1350,20 @@ struct umr_soc15_database {
 	struct umr_soc15_database *next;
 };
 
+// vbios
+struct umr_vbios_info {
+	uint8_t name[64];
+	uint32_t dbdf;
+	uint8_t vbios_pn[64];
+	uint32_t version;
+	uint8_t date[32];
+	uint64_t serial;
+	uint32_t dev_id;
+	uint32_t rev_id;
+	uint32_t sub_dev_id;
+	uint32_t sub_ved_id;
+};
+
 FILE *umr_database_open(char *path, char *filename);
 struct umr_soc15_database *umr_database_read_soc15(char *path, char *filename);
 void umr_database_free_soc15(struct umr_soc15_database *soc15);
diff --git a/src/umrapp.h b/src/umrapp.h
index 14457fe..1336e07 100644
--- a/src/umrapp.h
+++ b/src/umrapp.h
@@ -57,5 +57,6 @@ void umr_clock_scan(struct umr_asic *asic, const char* clock_name);
 void umr_clock_manual(struct umr_asic *asic, const char* clock_name, void* value);
 int umr_print_pp_table(struct umr_asic *asic, const char* param);
 int umr_print_gpu_metrics(struct umr_asic *asic);
+int umr_print_vbios_info(struct umr_asic *asic);
 
 void run_server_loop(const char *url, struct umr_asic * asic);
-- 
2.17.1


[-- Attachment #3: Type: text/plain, Size: 154 bytes --]

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  reply	other threads:[~2021-05-14  3:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-12  3:34 [PATCH] add vbios info query Jiawei Gu
2021-05-14  3:03 ` Gu, JiaWei (Will) [this message]
2021-05-14  4:29   ` Alex Deucher
2021-05-20  3:33 Jiawei Gu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CH0PR12MB51569D72B2C29929B5BBB127F8509@CH0PR12MB5156.namprd12.prod.outlook.com \
    --to=jiawei.gu@amd.com \
    --cc=Alexander.Deucher@amd.com \
    --cc=Tom.StDenis@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.