* [PATCH] add vbios info query
@ 2021-05-12 3:34 Jiawei Gu
2021-05-14 3:03 ` Gu, JiaWei (Will)
0 siblings, 1 reply; 4+ messages in thread
From: Jiawei Gu @ 2021-05-12 3:34 UTC (permalink / raw)
To: tom.stdenis, amd-gfx; +Cc: alexander.deucher, Jiawei Gu
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
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply related [flat|nested] 4+ messages in thread
* RE: [PATCH] add vbios info query
2021-05-12 3:34 [PATCH] add vbios info query Jiawei Gu
@ 2021-05-14 3:03 ` Gu, JiaWei (Will)
2021-05-14 4:29 ` Alex Deucher
0 siblings, 1 reply; 4+ messages in thread
From: Gu, JiaWei (Will) @ 2021-05-14 3:03 UTC (permalink / raw)
To: Gu, JiaWei (Will), StDenis, Tom, amd-gfx; +Cc: Deucher, Alexander
[-- 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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] add vbios info query
2021-05-14 3:03 ` Gu, JiaWei (Will)
@ 2021-05-14 4:29 ` Alex Deucher
0 siblings, 0 replies; 4+ messages in thread
From: Alex Deucher @ 2021-05-14 4:29 UTC (permalink / raw)
To: Gu, JiaWei (Will); +Cc: StDenis, Tom, Deucher, Alexander, amd-gfx
On Thu, May 13, 2021 at 11:03 PM Gu, JiaWei (Will) <JiaWei.Gu@amd.com> wrote:
>
> [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.
We need to wait until the kernel driver patch lands in upstream
drm-next (https://cgit.freedesktop.org/drm/drm/). I haven't sent it
upstream yet because the ioctl is still in flux. We still need to
sort out the pci id handling in the ioctl.
Alex
>
> 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
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] add vbios info query
@ 2021-05-20 3:33 Jiawei Gu
0 siblings, 0 replies; 4+ messages in thread
From: Jiawei Gu @ 2021-05-20 3:33 UTC (permalink / raw)
To: tom.stdenis, amd-gfx, christian.koenig, david.nieto, alexander.deucher
Cc: emily.deng, Jiawei Gu
Signed-off-by: Jiawei Gu <Jiawei.Gu@amd.com>
---
src/app/CMakeLists.txt | 1 +
src/app/main.c | 8 +++++
src/app/vbios.c | 53 ++++++++++++++++++++++++++++++
src/lib/lowlevel/linux/query_drm.c | 11 +++++++
src/umr.h | 11 +++++++
src/umrapp.h | 1 +
6 files changed, 85 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..fa0a3a3
--- /dev/null
+++ b/src/app/vbios.c
@@ -0,0 +1,53 @@
+/*
+ * 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 pn : %s\n", vbios_info.vbios_pn);
+ printf("vbios version : %d\n", vbios_info.version);
+ printf("vbios ver_str : %s\n", vbios_info.vbios_ver_str);
+ printf("vbios date : %s\n", vbios_info.date);
+
+ 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..9b80987 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,16 @@ struct umr_soc15_database {
struct umr_soc15_database *next;
};
+// vbios
+struct umr_vbios_info {
+ uint8_t name[64];
+ uint8_t vbios_pn[64];
+ uint32_t version;
+ uint32_t pad;
+ uint8_t vbios_ver_str[32];
+ uint8_t date[32];
+};
+
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
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-05-20 3:33 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-12 3:34 [PATCH] add vbios info query Jiawei Gu
2021-05-14 3:03 ` Gu, JiaWei (Will)
2021-05-14 4:29 ` Alex Deucher
2021-05-20 3:33 Jiawei Gu
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.