Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

2021-05-20 Thread Christian König
Kudos should go to Nirmoy who mentioned that tool in one of our 
discussions. But, yeah it is rather useful :)


Regards,
Christian.

Am 20.05.21 um 03:30 schrieb Gu, JiaWei (Will):


[AMD Official Use Only - Internal Distribution Only]

Thanks Christian!

Happy to learn new tricks.

Best regards,

Jiawei

*From:* Christian König 
*Sent:* Wednesday, May 19, 2021 9:23 PM
*To:* Deucher, Alexander ; Gu, JiaWei 
(Will) ; Nieto, David M ; 
Koenig, Christian ; 
amd-gfx@lists.freedesktop.org; mar...@gmail.com

*Cc:* Deng, Emily 
*Subject:* Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

Good point.

If you want to double check the alignment you can use something like 
"pahole drivers/gpu/drm/amd/amdgpu/amdgpu.ko -C drm_amdgpu_info_vbios" 
after building the kernel module.


Regards,
Christian.

Am 19.05.21 um 15:09 schrieb Deucher, Alexander:

[Public]

The structure is not 64 bit aligned.  I think you want something like:

> +struct drm_amdgpu_info_vbios {
> + __u8 name[64];
> + __u8 vbios_pn[64];
> + __u32 version;

> + __u32 pad;

> + __u8 vbios_ver_str[32];
> + __u8 date[32];
> +};



*From:*Gu, JiaWei (Will) 
<mailto:jiawei...@amd.com>
*Sent:* Tuesday, May 18, 2021 1:58 AM
*To:* Nieto, David M 
<mailto:david.ni...@amd.com>; Koenig, Christian
 <mailto:christian.koe...@amd.com>;
amd-gfx@lists.freedesktop.org
<mailto:amd-gfx@lists.freedesktop.org>

<mailto:amd-gfx@lists.freedesktop.org>; mar...@gmail.com
<mailto:mar...@gmail.com> 
<mailto:mar...@gmail.com>; Deucher, Alexander
 <mailto:alexander.deuc...@amd.com>
*Cc:* Deng, Emily  <mailto:emily.d...@amd.com>
*Subject:* RE: [PATCH] drm/amdgpu: Add vbios info ioctl interface

[Public]

Hi all,

Then the struct looks like:

> +struct drm_amdgpu_info_vbios {
> + __u8 name[64];
> + __u8 vbios_pn[64];
> + __u32 version;
> + __u8 vbios_ver_str[32];
> + __u8 date[32];
> +};

Sample output:

vbios name : NAVI12 A0 XT D30501 8GB EVAL 1150e/334m HYN/SAM
vbios pn : 113-D3050100-104
vbios version : 285409288
vbios ver_str : 017.003.000.008.016956
vbios date : 2021/05/03 23:32

Please help double confirm that we’re all fine with it and there’s
no need to add & remove anything.

Best regards,

Jiawei

*From:* Nieto, David M 
<mailto:david.ni...@amd.com>
*Sent:* Tuesday, May 18, 2021 12:40 PM
*To:* Gu, JiaWei (Will) 
<mailto:jiawei...@amd.com>; Koenig, Christian
 <mailto:christian.koe...@amd.com>;
amd-gfx@lists.freedesktop.org
<mailto:amd-gfx@lists.freedesktop.org>; mar...@gmail.com
<mailto:mar...@gmail.com>; Deucher, Alexander
     <mailto:alexander.deuc...@amd.com>
*Cc:* Deng, Emily  <mailto:emily.d...@amd.com>
*Subject:* Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

[Public]

Yes, let's remove that too,

Thanks,

David



*From:*Gu, JiaWei (Will) mailto:jiawei...@amd.com>>
*Sent:* Monday, May 17, 2021 8:07 PM
*To:* Nieto, David M mailto:david.ni...@amd.com>>; Koenig, Christian
mailto:christian.koe...@amd.com>>;
amd-gfx@lists.freedesktop.org
<mailto:amd-gfx@lists.freedesktop.org>
mailto:amd-gfx@lists.freedesktop.org>>; mar...@gmail.com
<mailto:mar...@gmail.com> mailto:mar...@gmail.com>>; Deucher, Alexander
mailto:alexander.deuc...@amd.com>>
*Cc:* Deng, Emily mailto:emily.d...@amd.com>>
*Subject:* RE: [PATCH] drm/amdgpu: Add vbios info ioctl interface

[AMD Official Use Only - Internal Distribution Only]

OK let’s remove serial.

dbdf comes from this:

vbios_info.dbdf = PCI_DEVID(adev->pdev->bus->number,
adev->pdev->devfn);

I think we can remove dbdf as well.

Best regards,

Jiawei

*From:* Nieto, David M mailto:david.ni...@amd.com>>
*Sent:* Tuesday, May 18, 2021 10:45 AM
*To:* Gu, JiaWei (Will) mailto:jiawei...@amd.com>>; Koenig, Christian
mailto:christian.koe...@amd.com>>;
amd-gfx@lists.freedesktop.org
    <mailto:amd-gfx@lists.freedesktop.org>; mar...@gmail.com
<mailto:mar...@gmail.com>; Deucher, Alexander
mailto:alexander.deuc...@amd.com>>
*Cc:* Deng, Emily mailto:emily.d...@amd.com>>
*Subject:* Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

[AMD Official Use Only - Internal Distribution Only]

The serial number is ASIC information, not VBIOS information, and
it is still available as a sysfs node... I don't think w

Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

2021-05-19 Thread Alex Deucher
On Wed, May 19, 2021 at 10:59 PM Jiawei Gu  wrote:
>
> Add AMDGPU_INFO_VBIOS_INFO subquery id for detailed vbios info.
>
> Provides a way for the user application to get the VBIOS
> information without having to parse the binary.
> It is useful for the user to be able to display in a simple way the VBIOS
> version in their system if they happen to encounter an issue.
>
> V2:
> Use numeric serial.
> Parse and expose vbios version string.
>
> V3:
> Remove redundant data in drm_amdgpu_info_vbios struct.
>
> V4:
> 64 bit alignment in drm_amdgpu_info_vbios.
>
> Signed-off-by: Jiawei Gu 

Assuming you send out the updated umr patch,
Reviewed-by: Alex Deucher 

> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c|  15 ++
>  drivers/gpu/drm/amd/amdgpu/atom.c  | 172 +
>  drivers/gpu/drm/amd/amdgpu/atom.h  |  10 ++
>  drivers/gpu/drm/amd/include/atomfirmware.h |   5 +
>  include/uapi/drm/amdgpu_drm.h  |  11 ++
>  5 files changed, 213 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> index 8d12e474745a..524e4fe5efe8 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> @@ -861,6 +861,21 @@ int amdgpu_info_ioctl(struct drm_device *dev, void 
> *data, struct drm_file *filp)
> min((size_t)size, 
> (size_t)(bios_size - bios_offset)))
> ? -EFAULT : 0;
> }
> +   case AMDGPU_INFO_VBIOS_INFO: {
> +   struct drm_amdgpu_info_vbios vbios_info = {};
> +   struct atom_context *atom_context;
> +
> +   atom_context = adev->mode_info.atom_context;
> +   memcpy(vbios_info.name, atom_context->name, 
> sizeof(atom_context->name));
> +   memcpy(vbios_info.vbios_pn, atom_context->vbios_pn, 
> sizeof(atom_context->vbios_pn));
> +   vbios_info.version = atom_context->version;
> +   memcpy(vbios_info.vbios_ver_str, 
> atom_context->vbios_ver_str,
> +   
> sizeof(atom_context->vbios_ver_str));
> +   memcpy(vbios_info.date, atom_context->date, 
> sizeof(atom_context->date));
> +
> +   return copy_to_user(out, _info,
> +   min((size_t)size, 
> sizeof(vbios_info))) ? -EFAULT : 0;
> +   }
> default:
> DRM_DEBUG_KMS("Invalid request %d\n",
> info->vbios_info.type);
> diff --git a/drivers/gpu/drm/amd/amdgpu/atom.c 
> b/drivers/gpu/drm/amd/amdgpu/atom.c
> index 3dcb8b32f48b..6fa2229b7229 100644
> --- a/drivers/gpu/drm/amd/amdgpu/atom.c
> +++ b/drivers/gpu/drm/amd/amdgpu/atom.c
> @@ -31,6 +31,7 @@
>
>  #define ATOM_DEBUG
>
> +#include "atomfirmware.h"
>  #include "atom.h"
>  #include "atom-names.h"
>  #include "atom-bits.h"
> @@ -1299,12 +1300,168 @@ static void atom_index_iio(struct atom_context *ctx, 
> int base)
> }
>  }
>
> +static void atom_get_vbios_name(struct atom_context *ctx)
> +{
> +   unsigned char *p_rom;
> +   unsigned char str_num;
> +   unsigned short off_to_vbios_str;
> +   unsigned char *c_ptr;
> +   int name_size;
> +   int i;
> +
> +   const char *na = "--N/A--";
> +   char *back;
> +
> +   p_rom = ctx->bios;
> +
> +   str_num = *(p_rom + OFFSET_TO_GET_ATOMBIOS_NUMBER_OF_STRINGS);
> +   if (str_num != 0) {
> +   off_to_vbios_str =
> +   *(unsigned short *)(p_rom + 
> OFFSET_TO_GET_ATOMBIOS_STRING_START);
> +
> +   c_ptr = (unsigned char *)(p_rom + off_to_vbios_str);
> +   } else {
> +   /* do not know where to find name */
> +   memcpy(ctx->name, na, 7);
> +   ctx->name[7] = 0;
> +   return;
> +   }
> +
> +   /*
> +* skip the atombios strings, usually 4
> +* 1st is P/N, 2nd is ASIC, 3rd is PCI type, 4th is Memory type
> +*/
> +   for (i = 0; i < str_num; i++) {
> +   while (*c_ptr != 0)
> +   c_ptr++;
> +   c_ptr++;
> +   }
> +
> +   /* skip the following 2 chars: 0x0D 0x0A */
> +   c_ptr += 2;
> +
> +   name_size = strnlen(c_ptr, STRLEN_LONG - 1);
> +   memcpy(ctx->name, c_ptr, name_size);
> +   back = ctx->name + name_size;
> +   while ((*--back) == ' ')
> +   ;
> +   *(back + 1) = '\0';
> +}
> +
> +static void atom_get_vbios_date(struct atom_context *ctx)
> +{
> +   unsigned char *p_rom;
> +   unsigned char *date_in_rom;
> +
> +   p_rom = ctx->bios;
> +
> +   date_in_rom = p_rom + OFFSET_TO_VBIOS_DATE;
> +
> +   ctx->date[0] = '2';
> +   ctx->date[1] = '0';
> +   ctx->date[2] = date_in_rom[6];
> +   

[PATCH] drm/amdgpu: Add vbios info ioctl interface

2021-05-19 Thread Jiawei Gu
Add AMDGPU_INFO_VBIOS_INFO subquery id for detailed vbios info.

Provides a way for the user application to get the VBIOS
information without having to parse the binary.
It is useful for the user to be able to display in a simple way the VBIOS
version in their system if they happen to encounter an issue.

V2:
Use numeric serial.
Parse and expose vbios version string.

V3:
Remove redundant data in drm_amdgpu_info_vbios struct.

V4:
64 bit alignment in drm_amdgpu_info_vbios.

Signed-off-by: Jiawei Gu 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c|  15 ++
 drivers/gpu/drm/amd/amdgpu/atom.c  | 172 +
 drivers/gpu/drm/amd/amdgpu/atom.h  |  10 ++
 drivers/gpu/drm/amd/include/atomfirmware.h |   5 +
 include/uapi/drm/amdgpu_drm.h  |  11 ++
 5 files changed, 213 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
index 8d12e474745a..524e4fe5efe8 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
@@ -861,6 +861,21 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, 
struct drm_file *filp)
min((size_t)size, 
(size_t)(bios_size - bios_offset)))
? -EFAULT : 0;
}
+   case AMDGPU_INFO_VBIOS_INFO: {
+   struct drm_amdgpu_info_vbios vbios_info = {};
+   struct atom_context *atom_context;
+
+   atom_context = adev->mode_info.atom_context;
+   memcpy(vbios_info.name, atom_context->name, 
sizeof(atom_context->name));
+   memcpy(vbios_info.vbios_pn, atom_context->vbios_pn, 
sizeof(atom_context->vbios_pn));
+   vbios_info.version = atom_context->version;
+   memcpy(vbios_info.vbios_ver_str, 
atom_context->vbios_ver_str,
+   
sizeof(atom_context->vbios_ver_str));
+   memcpy(vbios_info.date, atom_context->date, 
sizeof(atom_context->date));
+
+   return copy_to_user(out, _info,
+   min((size_t)size, 
sizeof(vbios_info))) ? -EFAULT : 0;
+   }
default:
DRM_DEBUG_KMS("Invalid request %d\n",
info->vbios_info.type);
diff --git a/drivers/gpu/drm/amd/amdgpu/atom.c 
b/drivers/gpu/drm/amd/amdgpu/atom.c
index 3dcb8b32f48b..6fa2229b7229 100644
--- a/drivers/gpu/drm/amd/amdgpu/atom.c
+++ b/drivers/gpu/drm/amd/amdgpu/atom.c
@@ -31,6 +31,7 @@
 
 #define ATOM_DEBUG
 
+#include "atomfirmware.h"
 #include "atom.h"
 #include "atom-names.h"
 #include "atom-bits.h"
@@ -1299,12 +1300,168 @@ static void atom_index_iio(struct atom_context *ctx, 
int base)
}
 }
 
+static void atom_get_vbios_name(struct atom_context *ctx)
+{
+   unsigned char *p_rom;
+   unsigned char str_num;
+   unsigned short off_to_vbios_str;
+   unsigned char *c_ptr;
+   int name_size;
+   int i;
+
+   const char *na = "--N/A--";
+   char *back;
+
+   p_rom = ctx->bios;
+
+   str_num = *(p_rom + OFFSET_TO_GET_ATOMBIOS_NUMBER_OF_STRINGS);
+   if (str_num != 0) {
+   off_to_vbios_str =
+   *(unsigned short *)(p_rom + 
OFFSET_TO_GET_ATOMBIOS_STRING_START);
+
+   c_ptr = (unsigned char *)(p_rom + off_to_vbios_str);
+   } else {
+   /* do not know where to find name */
+   memcpy(ctx->name, na, 7);
+   ctx->name[7] = 0;
+   return;
+   }
+
+   /*
+* skip the atombios strings, usually 4
+* 1st is P/N, 2nd is ASIC, 3rd is PCI type, 4th is Memory type
+*/
+   for (i = 0; i < str_num; i++) {
+   while (*c_ptr != 0)
+   c_ptr++;
+   c_ptr++;
+   }
+
+   /* skip the following 2 chars: 0x0D 0x0A */
+   c_ptr += 2;
+
+   name_size = strnlen(c_ptr, STRLEN_LONG - 1);
+   memcpy(ctx->name, c_ptr, name_size);
+   back = ctx->name + name_size;
+   while ((*--back) == ' ')
+   ;
+   *(back + 1) = '\0';
+}
+
+static void atom_get_vbios_date(struct atom_context *ctx)
+{
+   unsigned char *p_rom;
+   unsigned char *date_in_rom;
+
+   p_rom = ctx->bios;
+
+   date_in_rom = p_rom + OFFSET_TO_VBIOS_DATE;
+
+   ctx->date[0] = '2';
+   ctx->date[1] = '0';
+   ctx->date[2] = date_in_rom[6];
+   ctx->date[3] = date_in_rom[7];
+   ctx->date[4] = '/';
+   ctx->date[5] = date_in_rom[0];
+   ctx->date[6] = date_in_rom[1];
+   ctx->date[7] = '/';
+   ctx->date[8] = date_in_rom[3];
+   ctx->date[9] = date_in_rom[4];
+   ctx->date[10] = ' ';
+   ctx->date[11] = date_in_rom[9];
+   ctx->date[12] = date_in_rom[10];
+   ctx->date[13] = date_in_rom[11];
+

RE: [PATCH] drm/amdgpu: Add vbios info ioctl interface

2021-05-19 Thread Gu, JiaWei (Will)
[AMD Official Use Only - Internal Distribution Only]

Thanks Christian!

Happy to learn new tricks.

Best regards,
Jiawei

From: Christian König 
Sent: Wednesday, May 19, 2021 9:23 PM
To: Deucher, Alexander ; Gu, JiaWei (Will) 
; Nieto, David M ; Koenig, Christian 
; amd-gfx@lists.freedesktop.org; mar...@gmail.com
Cc: Deng, Emily 
Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

Good point.

If you want to double check the alignment you can use something like "pahole 
drivers/gpu/drm/amd/amdgpu/amdgpu.ko -C drm_amdgpu_info_vbios" after building 
the kernel module.

Regards,
Christian.
Am 19.05.21 um 15:09 schrieb Deucher, Alexander:

[Public]

The structure is not 64 bit aligned.  I think you want something like:

> +struct drm_amdgpu_info_vbios {
> + __u8 name[64];
> + __u8 vbios_pn[64];
> + __u32 version;
> + __u32 pad;
> + __u8 vbios_ver_str[32];
> + __u8 date[32];
> +};

From: Gu, JiaWei (Will) <mailto:jiawei...@amd.com>
Sent: Tuesday, May 18, 2021 1:58 AM
To: Nieto, David M <mailto:david.ni...@amd.com>; Koenig, 
Christian <mailto:christian.koe...@amd.com>; 
amd-gfx@lists.freedesktop.org<mailto:amd-gfx@lists.freedesktop.org> 
<mailto:amd-gfx@lists.freedesktop.org>; 
mar...@gmail.com<mailto:mar...@gmail.com> 
<mailto:mar...@gmail.com>; Deucher, Alexander 
<mailto:alexander.deuc...@amd.com>
Cc: Deng, Emily <mailto:emily.d...@amd.com>
Subject: RE: [PATCH] drm/amdgpu: Add vbios info ioctl interface


[Public]


Hi all,



Then the struct looks like:



> +struct drm_amdgpu_info_vbios {
> + __u8 name[64];
> + __u8 vbios_pn[64];
> + __u32 version;
> + __u8 vbios_ver_str[32];
> + __u8 date[32];
> +};



Sample output:



vbios name : NAVI12 A0 XT D30501 8GB EVAL 1150e/334m HYN/SAM
vbios pn : 113-D3050100-104
vbios version : 285409288
vbios ver_str : 017.003.000.008.016956
vbios date : 2021/05/03 23:32

Please help double confirm that we're all fine with it and there's no need to 
add & remove anything.



Best regards,

Jiawei



From: Nieto, David M <mailto:david.ni...@amd.com>
Sent: Tuesday, May 18, 2021 12:40 PM
To: Gu, JiaWei (Will) <mailto:jiawei...@amd.com>; Koenig, 
Christian <mailto:christian.koe...@amd.com>; 
amd-gfx@lists.freedesktop.org<mailto:amd-gfx@lists.freedesktop.org>; 
mar...@gmail.com<mailto:mar...@gmail.com>; Deucher, Alexander 
<mailto:alexander.deuc...@amd.com>
Cc: Deng, Emily <mailto:emily.d...@amd.com>
Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface



[Public]



Yes, let's remove that too,



Thanks,



David



From: Gu, JiaWei (Will) mailto:jiawei...@amd.com>>
Sent: Monday, May 17, 2021 8:07 PM
To: Nieto, David M mailto:david.ni...@amd.com>>; Koenig, 
Christian mailto:christian.koe...@amd.com>>; 
amd-gfx@lists.freedesktop.org<mailto:amd-gfx@lists.freedesktop.org> 
mailto:amd-gfx@lists.freedesktop.org>>; 
mar...@gmail.com<mailto:mar...@gmail.com> 
mailto:mar...@gmail.com>>; Deucher, Alexander 
mailto:alexander.deuc...@amd.com>>
Cc: Deng, Emily mailto:emily.d...@amd.com>>
Subject: RE: [PATCH] drm/amdgpu: Add vbios info ioctl interface



[AMD Official Use Only - Internal Distribution Only]



OK let's remove serial.



dbdf comes from this:

vbios_info.dbdf = PCI_DEVID(adev->pdev->bus->number, adev->pdev->devfn);



I think we can remove dbdf as well.



Best regards,

Jiawei



From: Nieto, David M mailto:david.ni...@amd.com>>
Sent: Tuesday, May 18, 2021 10:45 AM
To: Gu, JiaWei (Will) mailto:jiawei...@amd.com>>; Koenig, 
Christian mailto:christian.koe...@amd.com>>; 
amd-gfx@lists.freedesktop.org<mailto:amd-gfx@lists.freedesktop.org>; 
mar...@gmail.com<mailto:mar...@gmail.com>; Deucher, Alexander 
mailto:alexander.deuc...@amd.com>>
Cc: Deng, Emily mailto:emily.d...@amd.com>>
Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface



[AMD Official Use Only - Internal Distribution Only]



The serial number is ASIC information, not VBIOS information, and it is still 
available as a sysfs node... I don't think we should put it there.



Not sure what dbdf stands for.



From: Gu, JiaWei (Will) mailto:jiawei...@amd.com>>
Sent: Monday, May 17, 2021 7:11 PM
To: Koenig, Christian 
mailto:christian.koe...@amd.com>>; 
amd-gfx@lists.freedesktop.org<mailto:amd-gfx@lists.freedesktop.org> 
mailto:amd-gfx@lists.freedesktop.org>>; Nieto, 
David M mailto:david.ni...@amd.com>>; 
mar...@gmail.com<mailto:mar...@gmail.com> 
mailto:mar...@gmail.com>>; Deucher, Alexander 
mailto:alexander.deuc...@amd.com>>
Cc: Deng, Emily mailto:emily.d...@amd.com>>
Subject: RE: [PATCH] drm/amdgpu: Add vbios info ioctl interface


Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

2021-05-19 Thread Christian König

Good point.

If you want to double check the alignment you can use something like 
"pahole drivers/gpu/drm/amd/amdgpu/amdgpu.ko -C drm_amdgpu_info_vbios" 
after building the kernel module.


Regards,
Christian.

Am 19.05.21 um 15:09 schrieb Deucher, Alexander:


[Public]


The structure is not 64 bit aligned.  I think you want something like:

> +struct drm_amdgpu_info_vbios {
> + __u8 name[64];
> + __u8 vbios_pn[64];
> + __u32 version;
> + __u32 pad;
> + __u8 vbios_ver_str[32];
> + __u8 date[32];
> +};

*From:* Gu, JiaWei (Will) 
*Sent:* Tuesday, May 18, 2021 1:58 AM
*To:* Nieto, David M ; Koenig, Christian 
; amd-gfx@lists.freedesktop.org 
; mar...@gmail.com ; 
Deucher, Alexander 

*Cc:* Deng, Emily 
*Subject:* RE: [PATCH] drm/amdgpu: Add vbios info ioctl interface

[Public]


Hi all,

Then the struct looks like:

> +struct drm_amdgpu_info_vbios {
> + __u8 name[64];
> + __u8 vbios_pn[64];
> + __u32 version;
> + __u8 vbios_ver_str[32];
> + __u8 date[32];
> +};

Sample output:

vbios name : NAVI12 A0 XT D30501 8GB EVAL 1150e/334m HYN/SAM
vbios pn : 113-D3050100-104
vbios version : 285409288
vbios ver_str : 017.003.000.008.016956
vbios date : 2021/05/03 23:32

Please help double confirm that we’re all fine with it and there’s no 
need to add & remove anything.


Best regards,

Jiawei

*From:* Nieto, David M 
*Sent:* Tuesday, May 18, 2021 12:40 PM
*To:* Gu, JiaWei (Will) ; Koenig, Christian 
; amd-gfx@lists.freedesktop.org; 
mar...@gmail.com; Deucher, Alexander 

*Cc:* Deng, Emily 
*Subject:* Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

[Public]

Yes, let's remove that too,

Thanks,

David



*From:*Gu, JiaWei (Will) mailto:jiawei...@amd.com>>
*Sent:* Monday, May 17, 2021 8:07 PM
*To:* Nieto, David M <mailto:david.ni...@amd.com>>; Koenig, Christian 
mailto:christian.koe...@amd.com>>; 
amd-gfx@lists.freedesktop.org <mailto:amd-gfx@lists.freedesktop.org> 
<mailto:amd-gfx@lists.freedesktop.org>>; mar...@gmail.com 
<mailto:mar...@gmail.com> <mailto:mar...@gmail.com>>; Deucher, Alexander 
mailto:alexander.deuc...@amd.com>>

*Cc:* Deng, Emily mailto:emily.d...@amd.com>>
*Subject:* RE: [PATCH] drm/amdgpu: Add vbios info ioctl interface

[AMD Official Use Only - Internal Distribution Only]

OK let’s remove serial.

dbdf comes from this:

vbios_info.dbdf = PCI_DEVID(adev->pdev->bus->number, adev->pdev->devfn);

I think we can remove dbdf as well.

Best regards,

Jiawei

*From:* Nieto, David M mailto:david.ni...@amd.com>>
*Sent:* Tuesday, May 18, 2021 10:45 AM
*To:* Gu, JiaWei (Will) <mailto:jiawei...@amd.com>>; Koenig, Christian 
mailto:christian.koe...@amd.com>>; 
amd-gfx@lists.freedesktop.org <mailto:amd-gfx@lists.freedesktop.org>; 
mar...@gmail.com <mailto:mar...@gmail.com>; Deucher, Alexander 
mailto:alexander.deuc...@amd.com>>

*Cc:* Deng, Emily mailto:emily.d...@amd.com>>
*Subject:* Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

[AMD Official Use Only - Internal Distribution Only]

The serial number is ASIC information, not VBIOS information, and it 
is still available as a sysfs node... I don't think we should put it 
there.


Not sure what dbdf stands for.



*From:*Gu, JiaWei (Will) mailto:jiawei...@amd.com>>
*Sent:* Monday, May 17, 2021 7:11 PM
*To:* Koenig, Christian <mailto:christian.koe...@amd.com>>; amd-gfx@lists.freedesktop.org 
<mailto:amd-gfx@lists.freedesktop.org> <mailto:amd-gfx@lists.freedesktop.org>>; Nieto, David M 
mailto:david.ni...@amd.com>>; mar...@gmail.com 
<mailto:mar...@gmail.com> <mailto:mar...@gmail.com>>; Deucher, Alexander 
mailto:alexander.deuc...@amd.com>>

*Cc:* Deng, Emily mailto:emily.d...@amd.com>>
*Subject:* RE: [PATCH] drm/amdgpu: Add vbios info ioctl interface

[AMD Official Use Only - Internal Distribution Only]

So I guess the dbdf is also needed to be removed?
And how about serial?

> +struct drm_amdgpu_info_vbios {
> + __u8 name[64];
> + __u32 dbdf; // do we need this?
> + __u8 vbios_pn[64];
> + __u32 version;
> + __u8 vbios_ver_str[32];
> + __u8 date[32];
> + __u64 serial; // do we need this?
> +};

Best regards,
Jiawei

-Original Message-
From: Koenig, Christian <mailto:christian.koe...@amd.com>>

Sent: Monday, May 17, 2021 8:26 PM
To: Gu, JiaWei (Will) mailto:jiawei...@amd.com>>; 
amd-gfx@lists.freedesktop.org <mailto:amd-gfx@lists.freedesktop.org>; 
Nieto, David M mailto:david.ni...@amd.com>>; 
mar...@gmail.com <mailto:mar...@gmail.com>; Deucher, Alexand

Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

2021-05-19 Thread Deucher, Alexander
[Public]

The structure is not 64 bit aligned.  I think you want something like:

> +struct drm_amdgpu_info_vbios {
> + __u8 name[64];
> + __u8 vbios_pn[64];
> + __u32 version;
> + __u32 pad;
> + __u8 vbios_ver_str[32];
> + __u8 date[32];
> +};

From: Gu, JiaWei (Will) 
Sent: Tuesday, May 18, 2021 1:58 AM
To: Nieto, David M ; Koenig, Christian 
; amd-gfx@lists.freedesktop.org 
; mar...@gmail.com ; Deucher, 
Alexander 
Cc: Deng, Emily 
Subject: RE: [PATCH] drm/amdgpu: Add vbios info ioctl interface


[Public]


Hi all,



Then the struct looks like:



> +struct drm_amdgpu_info_vbios {
> + __u8 name[64];
> + __u8 vbios_pn[64];
> + __u32 version;
> + __u8 vbios_ver_str[32];
> + __u8 date[32];
> +};



Sample output:



vbios name : NAVI12 A0 XT D30501 8GB EVAL 1150e/334m HYN/SAM
vbios pn : 113-D3050100-104
vbios version : 285409288
vbios ver_str : 017.003.000.008.016956
vbios date : 2021/05/03 23:32


Please help double confirm that we’re all fine with it and there’s no need to 
add & remove anything.



Best regards,

Jiawei



From: Nieto, David M 
Sent: Tuesday, May 18, 2021 12:40 PM
To: Gu, JiaWei (Will) ; Koenig, Christian 
; amd-gfx@lists.freedesktop.org; mar...@gmail.com; 
Deucher, Alexander 
Cc: Deng, Emily 
Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface



[Public]



Yes, let's remove that too,



Thanks,



David



From: Gu, JiaWei (Will) mailto:jiawei...@amd.com>>
Sent: Monday, May 17, 2021 8:07 PM
To: Nieto, David M mailto:david.ni...@amd.com>>; Koenig, 
Christian mailto:christian.koe...@amd.com>>; 
amd-gfx@lists.freedesktop.org<mailto:amd-gfx@lists.freedesktop.org> 
mailto:amd-gfx@lists.freedesktop.org>>; 
mar...@gmail.com<mailto:mar...@gmail.com> 
mailto:mar...@gmail.com>>; Deucher, Alexander 
mailto:alexander.deuc...@amd.com>>
Cc: Deng, Emily mailto:emily.d...@amd.com>>
Subject: RE: [PATCH] drm/amdgpu: Add vbios info ioctl interface



[AMD Official Use Only - Internal Distribution Only]



OK let’s remove serial.



dbdf comes from this:

vbios_info.dbdf = PCI_DEVID(adev->pdev->bus->number, adev->pdev->devfn);



I think we can remove dbdf as well.



Best regards,

Jiawei



From: Nieto, David M mailto:david.ni...@amd.com>>
Sent: Tuesday, May 18, 2021 10:45 AM
To: Gu, JiaWei (Will) mailto:jiawei...@amd.com>>; Koenig, 
Christian mailto:christian.koe...@amd.com>>; 
amd-gfx@lists.freedesktop.org<mailto:amd-gfx@lists.freedesktop.org>; 
mar...@gmail.com<mailto:mar...@gmail.com>; Deucher, Alexander 
mailto:alexander.deuc...@amd.com>>
Cc: Deng, Emily mailto:emily.d...@amd.com>>
Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface



[AMD Official Use Only - Internal Distribution Only]



The serial number is ASIC information, not VBIOS information, and it is still 
available as a sysfs node... I don't think we should put it there.



Not sure what dbdf stands for.



From: Gu, JiaWei (Will) mailto:jiawei...@amd.com>>
Sent: Monday, May 17, 2021 7:11 PM
To: Koenig, Christian 
mailto:christian.koe...@amd.com>>; 
amd-gfx@lists.freedesktop.org<mailto:amd-gfx@lists.freedesktop.org> 
mailto:amd-gfx@lists.freedesktop.org>>; Nieto, 
David M mailto:david.ni...@amd.com>>; 
mar...@gmail.com<mailto:mar...@gmail.com> 
mailto:mar...@gmail.com>>; Deucher, Alexander 
mailto:alexander.deuc...@amd.com>>
Cc: Deng, Emily mailto:emily.d...@amd.com>>
Subject: RE: [PATCH] drm/amdgpu: Add vbios info ioctl interface



[AMD Official Use Only - Internal Distribution Only]

So I guess the dbdf is also needed to be removed?
And how about serial?

> +struct drm_amdgpu_info_vbios {
> + __u8 name[64];
> + __u32 dbdf; // do we need this?
> + __u8 vbios_pn[64];
> + __u32 version;
> + __u8 vbios_ver_str[32];
> + __u8 date[32];
> + __u64 serial; // do we need this?
> +};

Best regards,
Jiawei

-Original Message-
From: Koenig, Christian 
mailto:christian.koe...@amd.com>>
Sent: Monday, May 17, 2021 8:26 PM
To: Gu, JiaWei (Will) mailto:jiawei...@amd.com>>; 
amd-gfx@lists.freedesktop.org<mailto:amd-gfx@lists.freedesktop.org>; Nieto, 
David M mailto:david.ni...@amd.com>>; 
mar...@gmail.com<mailto:mar...@gmail.com>; Deucher, Alexander 
mailto:alexander.deuc...@amd.com>>
Cc: Deng, Emily mailto:emily.d...@amd.com>>
Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

I'm not very familiar with the technical background why we have the fields here 
once more.

But of hand we should at least remove everything which is also available from 
the PCI information.

E.g. dev_id, rev_id, sub_dev_id, sub_ved_id.

Regards,
Christian.

Am 17.05.21 um 1

Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

2021-05-18 Thread Nieto, David M
[Public]

That is correct, it is 0x11030008, that matches the FW information.

From: Lazar, Lijo 
Sent: Tuesday, May 18, 2021 3:50 AM
To: Gu, JiaWei (Will) ; Nieto, David M 
; Koenig, Christian ; 
amd-gfx@lists.freedesktop.org ; mar...@gmail.com 
; Deucher, Alexander 
Cc: Deng, Emily 
Subject: RE: [PATCH] drm/amdgpu: Add vbios info ioctl interface


[Public]


Not sure about this one –  vbios version : 285409288



Windows driver reports VBIOS version from atom_firmware_info_v3_1 / 
firmware_revision.



Thanks,

Lijo



From: amd-gfx  On Behalf Of Gu, JiaWei 
(Will)
Sent: Tuesday, May 18, 2021 11:28 AM
To: Nieto, David M ; Koenig, Christian 
; amd-gfx@lists.freedesktop.org; mar...@gmail.com; 
Deucher, Alexander 
Cc: Deng, Emily 
Subject: RE: [PATCH] drm/amdgpu: Add vbios info ioctl interface



[Public]



[Public]



Hi all,



Then the struct looks like:



> +struct drm_amdgpu_info_vbios {
> + __u8 name[64];
> + __u8 vbios_pn[64];
> + __u32 version;
> + __u8 vbios_ver_str[32];
> + __u8 date[32];
> +};



Sample output:



vbios name : NAVI12 A0 XT D30501 8GB EVAL 1150e/334m HYN/SAM
vbios pn : 113-D3050100-104
vbios version : 285409288
vbios ver_str : 017.003.000.008.016956
vbios date : 2021/05/03 23:32

Please help double confirm that we’re all fine with it and there’s no need to 
add & remove anything.



Best regards,

Jiawei



From: Nieto, David M mailto:david.ni...@amd.com>>
Sent: Tuesday, May 18, 2021 12:40 PM
To: Gu, JiaWei (Will) mailto:jiawei...@amd.com>>; Koenig, 
Christian mailto:christian.koe...@amd.com>>; 
amd-gfx@lists.freedesktop.org<mailto:amd-gfx@lists.freedesktop.org>; 
mar...@gmail.com<mailto:mar...@gmail.com>; Deucher, Alexander 
mailto:alexander.deuc...@amd.com>>
Cc: Deng, Emily mailto:emily.d...@amd.com>>
Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface



[Public]



Yes, let's remove that too,



Thanks,



David



From: Gu, JiaWei (Will) mailto:jiawei...@amd.com>>
Sent: Monday, May 17, 2021 8:07 PM
To: Nieto, David M mailto:david.ni...@amd.com>>; Koenig, 
Christian mailto:christian.koe...@amd.com>>; 
amd-gfx@lists.freedesktop.org<mailto:amd-gfx@lists.freedesktop.org> 
mailto:amd-gfx@lists.freedesktop.org>>; 
mar...@gmail.com<mailto:mar...@gmail.com> 
mailto:mar...@gmail.com>>; Deucher, Alexander 
mailto:alexander.deuc...@amd.com>>
Cc: Deng, Emily mailto:emily.d...@amd.com>>
Subject: RE: [PATCH] drm/amdgpu: Add vbios info ioctl interface



[AMD Official Use Only - Internal Distribution Only]



OK let’s remove serial.



dbdf comes from this:

vbios_info.dbdf = PCI_DEVID(adev->pdev->bus->number, adev->pdev->devfn);



I think we can remove dbdf as well.



Best regards,

Jiawei



From: Nieto, David M mailto:david.ni...@amd.com>>
Sent: Tuesday, May 18, 2021 10:45 AM
To: Gu, JiaWei (Will) mailto:jiawei...@amd.com>>; Koenig, 
Christian mailto:christian.koe...@amd.com>>; 
amd-gfx@lists.freedesktop.org<mailto:amd-gfx@lists.freedesktop.org>; 
mar...@gmail.com<mailto:mar...@gmail.com>; Deucher, Alexander 
mailto:alexander.deuc...@amd.com>>
Cc: Deng, Emily mailto:emily.d...@amd.com>>
Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface



[AMD Official Use Only - Internal Distribution Only]



The serial number is ASIC information, not VBIOS information, and it is still 
available as a sysfs node... I don't think we should put it there.



Not sure what dbdf stands for.



From: Gu, JiaWei (Will) mailto:jiawei...@amd.com>>
Sent: Monday, May 17, 2021 7:11 PM
To: Koenig, Christian 
mailto:christian.koe...@amd.com>>; 
amd-gfx@lists.freedesktop.org<mailto:amd-gfx@lists.freedesktop.org> 
mailto:amd-gfx@lists.freedesktop.org>>; Nieto, 
David M mailto:david.ni...@amd.com>>; 
mar...@gmail.com<mailto:mar...@gmail.com> 
mailto:mar...@gmail.com>>; Deucher, Alexander 
mailto:alexander.deuc...@amd.com>>
Cc: Deng, Emily mailto:emily.d...@amd.com>>
Subject: RE: [PATCH] drm/amdgpu: Add vbios info ioctl interface



[AMD Official Use Only - Internal Distribution Only]

So I guess the dbdf is also needed to be removed?
And how about serial?

> +struct drm_amdgpu_info_vbios {
> + __u8 name[64];
> + __u32 dbdf; // do we need this?
> + __u8 vbios_pn[64];
> + __u32 version;
> + __u8 vbios_ver_str[32];
> + __u8 date[32];
> + __u64 serial; // do we need this?
> +};

Best regards,
Jiawei

-Original Message-
From: Koenig, Christian 
mailto:christian.koe...@amd.com>>
Sent: Monday, May 17, 2021 8:26 PM
To: Gu, JiaWei (Will) mailto:jiawei...@amd.com>>; 
amd-gfx@lists.freedesktop.org<mailto:amd-gfx@lists.freedesktop.org>; Nieto, 
David M mailto:david.ni...@amd.c

Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

2021-05-18 Thread Marek Olšák
Mesa doesn't have any use for this. It should be ok to expose just the
ioctl without userspace because it's just vbios info.

Marek

On Tue., May 18, 2021, 22:41 Gu, JiaWei (Will),  wrote:

> [AMD Official Use Only - Internal Distribution Only]
>
> Thanks Tom's suggestion.
> I'm fine to replace ioctl with sysfs.
>
> Hi all, how about this sysfs alternative?
>
> And if it's a must to insist on ioctl, is there any Mesa expert to help
> provide the patch?
>
> Best regards,
> Jiawei
>
>
> -Original Message-
> From: StDenis, Tom 
> Sent: Tuesday, May 18, 2021 9:26 PM
> To: Koenig, Christian ; Gu, JiaWei (Will) <
> jiawei...@amd.com>; amd-gfx@lists.freedesktop.org; Nieto, David M <
> david.ni...@amd.com>; mar...@gmail.com; Deucher, Alexander <
> alexander.deuc...@amd.com>
> Cc: Deng, Emily 
> Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface
>
> [AMD Official Use Only - Internal Distribution Only]
>
> If changing the ioctl is an issue why not just use sysfs?  umr already
> makes uses of all three for it's purposes so it's fine by me for either.
>
> Tom
>
> 
> From: amd-gfx  on behalf of
> Christian König 
> Sent: Tuesday, May 18, 2021 09:17
> To: Gu, JiaWei (Will); amd-gfx@lists.freedesktop.org; Nieto, David M;
> mar...@gmail.com; Deucher, Alexander
> Cc: Deng, Emily
> Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface
>
> Well not an expert on that stuff, but looks like that should work for me.
>
> Question is can you provide a patch to use that information in Mesa as
> well? Umr might be sufficient as well as justification for upstreaming, but
> I want to be better save than sorry.
>
> Unless Marek has a better idea maybe add the vbios version to the string
> returned by GLX_MESA_query_renderer or something like that.
>
> Thanks,
> Christian.
>
> Am 18.05.21 um 14:19 schrieb Gu, JiaWei (Will):
> > [AMD Official Use Only - Internal Distribution Only]
> >
> > Hi all,
> >
> > Please help confirm that we're all fine with this new struct in uapi in
> this V3 patch:
> >
> > +struct drm_amdgpu_info_vbios {
> > + __u8 name[64];
> > + __u8 vbios_pn[64];
> > + __u32 version;
> > + __u8 vbios_ver_str[32];
> > + __u8 date[32];
> > +};
> >
> > Best regards,
> > Jiawei
> >
> > -----Original Message-
> > From: Jiawei Gu 
> > Sent: Tuesday, May 18, 2021 8:16 PM
> > To: amd-gfx@lists.freedesktop.org; Koenig, Christian
> > ; Nieto, David M ;
> > mar...@gmail.com; Deucher, Alexander 
> > Cc: Deng, Emily ; Gu, JiaWei (Will)
> > 
> > Subject: [PATCH] drm/amdgpu: Add vbios info ioctl interface
> >
> > Add AMDGPU_INFO_VBIOS_INFO subquery id for detailed vbios info.
> >
> > Provides a way for the user application to get the VBIOS information
> without having to parse the binary.
> > It is useful for the user to be able to display in a simple way the
> VBIOS version in their system if they happen to encounter an issue.
> >
> > V2:
> > Use numeric serial.
> > Parse and expose vbios version string.
> >
> > V3:
> > Remove redundant data in drm_amdgpu_info_vbios struct.
> >
> > Signed-off-by: Jiawei Gu 
> > ---
> >   drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c|  15 ++
> >   drivers/gpu/drm/amd/amdgpu/atom.c  | 172 +
> >   drivers/gpu/drm/amd/amdgpu/atom.h  |  10 ++
> >   drivers/gpu/drm/amd/include/atomfirmware.h |   5 +
> >   include/uapi/drm/amdgpu_drm.h  |  10 ++
> >   5 files changed, 212 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> > b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> > index 8d12e474745a..524e4fe5efe8 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> > @@ -861,6 +861,21 @@ int amdgpu_info_ioctl(struct drm_device *dev, void
> *data, struct drm_file *filp)
> >   min((size_t)size,
> (size_t)(bios_size - bios_offset)))
> >   ? -EFAULT : 0;
> >   }
> > + case AMDGPU_INFO_VBIOS_INFO: {
> > + struct drm_amdgpu_info_vbios vbios_info = {};
> > + struct atom_context *atom_context;
> > +
> > + atom_context = adev->mode_info.atom_context;
> > + memcpy(vbios_info.name, atom_context->name,
> sizeof(atom_context->name));
> > 

RE: [PATCH] drm/amdgpu: Add vbios info ioctl interface

2021-05-18 Thread Gu, JiaWei (Will)
[AMD Official Use Only - Internal Distribution Only]

Thanks Tom's suggestion.
I'm fine to replace ioctl with sysfs.

Hi all, how about this sysfs alternative?

And if it's a must to insist on ioctl, is there any Mesa expert to help provide 
the patch?

Best regards,
Jiawei


-Original Message-
From: StDenis, Tom  
Sent: Tuesday, May 18, 2021 9:26 PM
To: Koenig, Christian ; Gu, JiaWei (Will) 
; amd-gfx@lists.freedesktop.org; Nieto, David M 
; mar...@gmail.com; Deucher, Alexander 

Cc: Deng, Emily 
Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

[AMD Official Use Only - Internal Distribution Only]

If changing the ioctl is an issue why not just use sysfs?  umr already makes 
uses of all three for it's purposes so it's fine by me for either.

Tom


From: amd-gfx  on behalf of Christian 
König 
Sent: Tuesday, May 18, 2021 09:17
To: Gu, JiaWei (Will); amd-gfx@lists.freedesktop.org; Nieto, David M; 
mar...@gmail.com; Deucher, Alexander
Cc: Deng, Emily
Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

Well not an expert on that stuff, but looks like that should work for me.

Question is can you provide a patch to use that information in Mesa as well? 
Umr might be sufficient as well as justification for upstreaming, but I want to 
be better save than sorry.

Unless Marek has a better idea maybe add the vbios version to the string 
returned by GLX_MESA_query_renderer or something like that.

Thanks,
Christian.

Am 18.05.21 um 14:19 schrieb Gu, JiaWei (Will):
> [AMD Official Use Only - Internal Distribution Only]
>
> Hi all,
>
> Please help confirm that we're all fine with this new struct in uapi in this 
> V3 patch:
>
> +struct drm_amdgpu_info_vbios {
> + __u8 name[64];
> + __u8 vbios_pn[64];
> + __u32 version;
> + __u8 vbios_ver_str[32];
> + __u8 date[32];
> +};
>
> Best regards,
> Jiawei
>
> -Original Message-
> From: Jiawei Gu 
> Sent: Tuesday, May 18, 2021 8:16 PM
> To: amd-gfx@lists.freedesktop.org; Koenig, Christian 
> ; Nieto, David M ; 
> mar...@gmail.com; Deucher, Alexander 
> Cc: Deng, Emily ; Gu, JiaWei (Will) 
> 
> Subject: [PATCH] drm/amdgpu: Add vbios info ioctl interface
>
> Add AMDGPU_INFO_VBIOS_INFO subquery id for detailed vbios info.
>
> Provides a way for the user application to get the VBIOS information without 
> having to parse the binary.
> It is useful for the user to be able to display in a simple way the VBIOS 
> version in their system if they happen to encounter an issue.
>
> V2:
> Use numeric serial.
> Parse and expose vbios version string.
>
> V3:
> Remove redundant data in drm_amdgpu_info_vbios struct.
>
> Signed-off-by: Jiawei Gu 
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c|  15 ++
>   drivers/gpu/drm/amd/amdgpu/atom.c  | 172 +
>   drivers/gpu/drm/amd/amdgpu/atom.h  |  10 ++
>   drivers/gpu/drm/amd/include/atomfirmware.h |   5 +
>   include/uapi/drm/amdgpu_drm.h  |  10 ++
>   5 files changed, 212 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> index 8d12e474745a..524e4fe5efe8 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> @@ -861,6 +861,21 @@ int amdgpu_info_ioctl(struct drm_device *dev, void 
> *data, struct drm_file *filp)
>   min((size_t)size, 
> (size_t)(bios_size - bios_offset)))
>   ? -EFAULT : 0;
>   }
> + case AMDGPU_INFO_VBIOS_INFO: {
> + struct drm_amdgpu_info_vbios vbios_info = {};
> + struct atom_context *atom_context;
> +
> + atom_context = adev->mode_info.atom_context;
> + memcpy(vbios_info.name, atom_context->name, 
> sizeof(atom_context->name));
> + memcpy(vbios_info.vbios_pn, atom_context->vbios_pn, 
> sizeof(atom_context->vbios_pn));
> + vbios_info.version = atom_context->version;
> + memcpy(vbios_info.vbios_ver_str, 
> atom_context->vbios_ver_str,
> + 
> sizeof(atom_context->vbios_ver_str));
> + memcpy(vbios_info.date, atom_context->date, 
> +sizeof(atom_context->date));
> +
> + return copy_to_user(out, _info,
> + min((size_t)size, 
> sizeof(vbios_info))) ? -EFAULT : 0;
> + }
>   default:
>   DRM_DEBUG_KMS("Invalid request %d\n",
>  

Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

2021-05-18 Thread StDenis, Tom
[AMD Official Use Only - Internal Distribution Only]

If changing the ioctl is an issue why not just use sysfs?  umr already makes 
uses of all three for it's purposes so it's fine by me for either.

Tom


From: amd-gfx  on behalf of Christian 
König 
Sent: Tuesday, May 18, 2021 09:17
To: Gu, JiaWei (Will); amd-gfx@lists.freedesktop.org; Nieto, David M; 
mar...@gmail.com; Deucher, Alexander
Cc: Deng, Emily
Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

Well not an expert on that stuff, but looks like that should work for me.

Question is can you provide a patch to use that information in Mesa as
well? Umr might be sufficient as well as justification for upstreaming,
but I want to be better save than sorry.

Unless Marek has a better idea maybe add the vbios version to the string
returned by GLX_MESA_query_renderer or something like that.

Thanks,
Christian.

Am 18.05.21 um 14:19 schrieb Gu, JiaWei (Will):
> [AMD Official Use Only - Internal Distribution Only]
>
> Hi all,
>
> Please help confirm that we're all fine with this new struct in uapi in this 
> V3 patch:
>
> +struct drm_amdgpu_info_vbios {
> + __u8 name[64];
> + __u8 vbios_pn[64];
> + __u32 version;
> + __u8 vbios_ver_str[32];
> + __u8 date[32];
> +};
>
> Best regards,
> Jiawei
>
> -Original Message-
> From: Jiawei Gu 
> Sent: Tuesday, May 18, 2021 8:16 PM
> To: amd-gfx@lists.freedesktop.org; Koenig, Christian 
> ; Nieto, David M ; 
> mar...@gmail.com; Deucher, Alexander 
> Cc: Deng, Emily ; Gu, JiaWei (Will) 
> Subject: [PATCH] drm/amdgpu: Add vbios info ioctl interface
>
> Add AMDGPU_INFO_VBIOS_INFO subquery id for detailed vbios info.
>
> Provides a way for the user application to get the VBIOS information without 
> having to parse the binary.
> It is useful for the user to be able to display in a simple way the VBIOS 
> version in their system if they happen to encounter an issue.
>
> V2:
> Use numeric serial.
> Parse and expose vbios version string.
>
> V3:
> Remove redundant data in drm_amdgpu_info_vbios struct.
>
> Signed-off-by: Jiawei Gu 
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c|  15 ++
>   drivers/gpu/drm/amd/amdgpu/atom.c  | 172 +
>   drivers/gpu/drm/amd/amdgpu/atom.h  |  10 ++
>   drivers/gpu/drm/amd/include/atomfirmware.h |   5 +
>   include/uapi/drm/amdgpu_drm.h  |  10 ++
>   5 files changed, 212 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> index 8d12e474745a..524e4fe5efe8 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> @@ -861,6 +861,21 @@ int amdgpu_info_ioctl(struct drm_device *dev, void 
> *data, struct drm_file *filp)
>   min((size_t)size, 
> (size_t)(bios_size - bios_offset)))
>   ? -EFAULT : 0;
>   }
> + case AMDGPU_INFO_VBIOS_INFO: {
> + struct drm_amdgpu_info_vbios vbios_info = {};
> + struct atom_context *atom_context;
> +
> + atom_context = adev->mode_info.atom_context;
> + memcpy(vbios_info.name, atom_context->name, 
> sizeof(atom_context->name));
> + memcpy(vbios_info.vbios_pn, atom_context->vbios_pn, 
> sizeof(atom_context->vbios_pn));
> + vbios_info.version = atom_context->version;
> + memcpy(vbios_info.vbios_ver_str, 
> atom_context->vbios_ver_str,
> + 
> sizeof(atom_context->vbios_ver_str));
> + memcpy(vbios_info.date, atom_context->date,
> +sizeof(atom_context->date));
> +
> + return copy_to_user(out, _info,
> + min((size_t)size, 
> sizeof(vbios_info))) ? -EFAULT : 0;
> + }
>   default:
>   DRM_DEBUG_KMS("Invalid request %d\n",
>   info->vbios_info.type);
> diff --git a/drivers/gpu/drm/amd/amdgpu/atom.c 
> b/drivers/gpu/drm/amd/amdgpu/atom.c
> index 3dcb8b32f48b..6fa2229b7229 100644
> --- a/drivers/gpu/drm/amd/amdgpu/atom.c
> +++ b/drivers/gpu/drm/amd/amdgpu/atom.c
> @@ -31,6 +31,7 @@
>
>   #define ATOM_DEBUG
>
> +#include "atomfirmware.h"
>   #include "atom.h"
>   #include "atom-names.h"
>   #include "atom-bits.h"
> @@ -1299,12 +1300,168 @@ static void atom_index_iio(struct atom_context *ctx, 
>

Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

2021-05-18 Thread Christian König

Well not an expert on that stuff, but looks like that should work for me.

Question is can you provide a patch to use that information in Mesa as 
well? Umr might be sufficient as well as justification for upstreaming, 
but I want to be better save than sorry.


Unless Marek has a better idea maybe add the vbios version to the string 
returned by GLX_MESA_query_renderer or something like that.


Thanks,
Christian.

Am 18.05.21 um 14:19 schrieb Gu, JiaWei (Will):

[AMD Official Use Only - Internal Distribution Only]

Hi all,

Please help confirm that we're all fine with this new struct in uapi in this V3 
patch:

+struct drm_amdgpu_info_vbios {
+   __u8 name[64];
+   __u8 vbios_pn[64];
+   __u32 version;
+   __u8 vbios_ver_str[32];
+   __u8 date[32];
+};

Best regards,
Jiawei

-Original Message-
From: Jiawei Gu 
Sent: Tuesday, May 18, 2021 8:16 PM
To: amd-gfx@lists.freedesktop.org; Koenig, Christian ; Nieto, 
David M ; mar...@gmail.com; Deucher, Alexander 

Cc: Deng, Emily ; Gu, JiaWei (Will) 
Subject: [PATCH] drm/amdgpu: Add vbios info ioctl interface

Add AMDGPU_INFO_VBIOS_INFO subquery id for detailed vbios info.

Provides a way for the user application to get the VBIOS information without 
having to parse the binary.
It is useful for the user to be able to display in a simple way the VBIOS 
version in their system if they happen to encounter an issue.

V2:
Use numeric serial.
Parse and expose vbios version string.

V3:
Remove redundant data in drm_amdgpu_info_vbios struct.

Signed-off-by: Jiawei Gu 
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c|  15 ++
  drivers/gpu/drm/amd/amdgpu/atom.c  | 172 +
  drivers/gpu/drm/amd/amdgpu/atom.h  |  10 ++
  drivers/gpu/drm/amd/include/atomfirmware.h |   5 +
  include/uapi/drm/amdgpu_drm.h  |  10 ++
  5 files changed, 212 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
index 8d12e474745a..524e4fe5efe8 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
@@ -861,6 +861,21 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, 
struct drm_file *filp)
min((size_t)size, 
(size_t)(bios_size - bios_offset)))
? -EFAULT : 0;
}
+   case AMDGPU_INFO_VBIOS_INFO: {
+   struct drm_amdgpu_info_vbios vbios_info = {};
+   struct atom_context *atom_context;
+
+   atom_context = adev->mode_info.atom_context;
+   memcpy(vbios_info.name, atom_context->name, 
sizeof(atom_context->name));
+   memcpy(vbios_info.vbios_pn, atom_context->vbios_pn, 
sizeof(atom_context->vbios_pn));
+   vbios_info.version = atom_context->version;
+   memcpy(vbios_info.vbios_ver_str, 
atom_context->vbios_ver_str,
+   
sizeof(atom_context->vbios_ver_str));
+   memcpy(vbios_info.date, atom_context->date,
+sizeof(atom_context->date));
+
+   return copy_to_user(out, _info,
+   min((size_t)size, 
sizeof(vbios_info))) ? -EFAULT : 0;
+   }
default:
DRM_DEBUG_KMS("Invalid request %d\n",
info->vbios_info.type);
diff --git a/drivers/gpu/drm/amd/amdgpu/atom.c 
b/drivers/gpu/drm/amd/amdgpu/atom.c
index 3dcb8b32f48b..6fa2229b7229 100644
--- a/drivers/gpu/drm/amd/amdgpu/atom.c
+++ b/drivers/gpu/drm/amd/amdgpu/atom.c
@@ -31,6 +31,7 @@
  
  #define ATOM_DEBUG
  
+#include "atomfirmware.h"

  #include "atom.h"
  #include "atom-names.h"
  #include "atom-bits.h"
@@ -1299,12 +1300,168 @@ static void atom_index_iio(struct atom_context *ctx, 
int base)
}
  }
  
+static void atom_get_vbios_name(struct atom_context *ctx) {

+   unsigned char *p_rom;
+   unsigned char str_num;
+   unsigned short off_to_vbios_str;
+   unsigned char *c_ptr;
+   int name_size;
+   int i;
+
+   const char *na = "--N/A--";
+   char *back;
+
+   p_rom = ctx->bios;
+
+   str_num = *(p_rom + OFFSET_TO_GET_ATOMBIOS_NUMBER_OF_STRINGS);
+   if (str_num != 0) {
+   off_to_vbios_str =
+   *(unsigned short *)(p_rom + 
OFFSET_TO_GET_ATOMBIOS_STRING_START);
+
+   c_ptr = (unsigned char *)(p_rom + off_to_vbios_str);
+   } else {
+   /* do not know where to find name */
+   memcpy(ctx->name, na, 7);
+   ctx->name[7] = 0;
+   return;
+   }
+
+   /*
+* skip the atombios strings, usually 4
+* 1st is P/N, 2nd is ASIC, 3rd is PCI type, 4th

RE: [PATCH] drm/amdgpu: Add vbios info ioctl interface

2021-05-18 Thread Gu, JiaWei (Will)
[AMD Official Use Only - Internal Distribution Only]

Hi all,

Please help confirm that we're all fine with this new struct in uapi in this V3 
patch:

+struct drm_amdgpu_info_vbios {
+   __u8 name[64];
+   __u8 vbios_pn[64];
+   __u32 version;
+   __u8 vbios_ver_str[32];
+   __u8 date[32];
+};

Best regards,
Jiawei

-Original Message-
From: Jiawei Gu  
Sent: Tuesday, May 18, 2021 8:16 PM
To: amd-gfx@lists.freedesktop.org; Koenig, Christian 
; Nieto, David M ; 
mar...@gmail.com; Deucher, Alexander 
Cc: Deng, Emily ; Gu, JiaWei (Will) 
Subject: [PATCH] drm/amdgpu: Add vbios info ioctl interface

Add AMDGPU_INFO_VBIOS_INFO subquery id for detailed vbios info.

Provides a way for the user application to get the VBIOS information without 
having to parse the binary.
It is useful for the user to be able to display in a simple way the VBIOS 
version in their system if they happen to encounter an issue.

V2:
Use numeric serial.
Parse and expose vbios version string.

V3:
Remove redundant data in drm_amdgpu_info_vbios struct.

Signed-off-by: Jiawei Gu 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c|  15 ++
 drivers/gpu/drm/amd/amdgpu/atom.c  | 172 +
 drivers/gpu/drm/amd/amdgpu/atom.h  |  10 ++
 drivers/gpu/drm/amd/include/atomfirmware.h |   5 +
 include/uapi/drm/amdgpu_drm.h  |  10 ++
 5 files changed, 212 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
index 8d12e474745a..524e4fe5efe8 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
@@ -861,6 +861,21 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, 
struct drm_file *filp)
min((size_t)size, 
(size_t)(bios_size - bios_offset)))
? -EFAULT : 0;
}
+   case AMDGPU_INFO_VBIOS_INFO: {
+   struct drm_amdgpu_info_vbios vbios_info = {};
+   struct atom_context *atom_context;
+
+   atom_context = adev->mode_info.atom_context;
+   memcpy(vbios_info.name, atom_context->name, 
sizeof(atom_context->name));
+   memcpy(vbios_info.vbios_pn, atom_context->vbios_pn, 
sizeof(atom_context->vbios_pn));
+   vbios_info.version = atom_context->version;
+   memcpy(vbios_info.vbios_ver_str, 
atom_context->vbios_ver_str,
+   
sizeof(atom_context->vbios_ver_str));
+   memcpy(vbios_info.date, atom_context->date, 
+sizeof(atom_context->date));
+
+   return copy_to_user(out, _info,
+   min((size_t)size, 
sizeof(vbios_info))) ? -EFAULT : 0;
+   }
default:
DRM_DEBUG_KMS("Invalid request %d\n",
info->vbios_info.type);
diff --git a/drivers/gpu/drm/amd/amdgpu/atom.c 
b/drivers/gpu/drm/amd/amdgpu/atom.c
index 3dcb8b32f48b..6fa2229b7229 100644
--- a/drivers/gpu/drm/amd/amdgpu/atom.c
+++ b/drivers/gpu/drm/amd/amdgpu/atom.c
@@ -31,6 +31,7 @@
 
 #define ATOM_DEBUG
 
+#include "atomfirmware.h"
 #include "atom.h"
 #include "atom-names.h"
 #include "atom-bits.h"
@@ -1299,12 +1300,168 @@ static void atom_index_iio(struct atom_context *ctx, 
int base)
}
 }
 
+static void atom_get_vbios_name(struct atom_context *ctx) {
+   unsigned char *p_rom;
+   unsigned char str_num;
+   unsigned short off_to_vbios_str;
+   unsigned char *c_ptr;
+   int name_size;
+   int i;
+
+   const char *na = "--N/A--";
+   char *back;
+
+   p_rom = ctx->bios;
+
+   str_num = *(p_rom + OFFSET_TO_GET_ATOMBIOS_NUMBER_OF_STRINGS);
+   if (str_num != 0) {
+   off_to_vbios_str =
+   *(unsigned short *)(p_rom + 
OFFSET_TO_GET_ATOMBIOS_STRING_START);
+
+   c_ptr = (unsigned char *)(p_rom + off_to_vbios_str);
+   } else {
+   /* do not know where to find name */
+   memcpy(ctx->name, na, 7);
+   ctx->name[7] = 0;
+   return;
+   }
+
+   /*
+* skip the atombios strings, usually 4
+* 1st is P/N, 2nd is ASIC, 3rd is PCI type, 4th is Memory type
+*/
+   for (i = 0; i < str_num; i++) {
+   while (*c_ptr != 0)
+   c_ptr++;
+   c_ptr++;
+   }
+
+   /* skip the following 2 chars: 0x0D 0x0A */
+   c_ptr += 2;
+
+   name_size = strnlen(c_ptr, STRLEN_LONG - 1);
+   memcpy(ctx->name, c_ptr, name_size);
+   back = ctx->name + name_size;
+   while ((*--back) == ' ')
+   ;
+   *(back + 1) = '\0';
+}
+
+static void a

[PATCH] drm/amdgpu: Add vbios info ioctl interface

2021-05-18 Thread Jiawei Gu
Add AMDGPU_INFO_VBIOS_INFO subquery id for detailed vbios info.

Provides a way for the user application to get the VBIOS
information without having to parse the binary.
It is useful for the user to be able to display in a simple way the VBIOS
version in their system if they happen to encounter an issue.

V2:
Use numeric serial.
Parse and expose vbios version string.

V3:
Remove redundant data in drm_amdgpu_info_vbios struct.

Signed-off-by: Jiawei Gu 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c|  15 ++
 drivers/gpu/drm/amd/amdgpu/atom.c  | 172 +
 drivers/gpu/drm/amd/amdgpu/atom.h  |  10 ++
 drivers/gpu/drm/amd/include/atomfirmware.h |   5 +
 include/uapi/drm/amdgpu_drm.h  |  10 ++
 5 files changed, 212 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
index 8d12e474745a..524e4fe5efe8 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
@@ -861,6 +861,21 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, 
struct drm_file *filp)
min((size_t)size, 
(size_t)(bios_size - bios_offset)))
? -EFAULT : 0;
}
+   case AMDGPU_INFO_VBIOS_INFO: {
+   struct drm_amdgpu_info_vbios vbios_info = {};
+   struct atom_context *atom_context;
+
+   atom_context = adev->mode_info.atom_context;
+   memcpy(vbios_info.name, atom_context->name, 
sizeof(atom_context->name));
+   memcpy(vbios_info.vbios_pn, atom_context->vbios_pn, 
sizeof(atom_context->vbios_pn));
+   vbios_info.version = atom_context->version;
+   memcpy(vbios_info.vbios_ver_str, 
atom_context->vbios_ver_str,
+   
sizeof(atom_context->vbios_ver_str));
+   memcpy(vbios_info.date, atom_context->date, 
sizeof(atom_context->date));
+
+   return copy_to_user(out, _info,
+   min((size_t)size, 
sizeof(vbios_info))) ? -EFAULT : 0;
+   }
default:
DRM_DEBUG_KMS("Invalid request %d\n",
info->vbios_info.type);
diff --git a/drivers/gpu/drm/amd/amdgpu/atom.c 
b/drivers/gpu/drm/amd/amdgpu/atom.c
index 3dcb8b32f48b..6fa2229b7229 100644
--- a/drivers/gpu/drm/amd/amdgpu/atom.c
+++ b/drivers/gpu/drm/amd/amdgpu/atom.c
@@ -31,6 +31,7 @@
 
 #define ATOM_DEBUG
 
+#include "atomfirmware.h"
 #include "atom.h"
 #include "atom-names.h"
 #include "atom-bits.h"
@@ -1299,12 +1300,168 @@ static void atom_index_iio(struct atom_context *ctx, 
int base)
}
 }
 
+static void atom_get_vbios_name(struct atom_context *ctx)
+{
+   unsigned char *p_rom;
+   unsigned char str_num;
+   unsigned short off_to_vbios_str;
+   unsigned char *c_ptr;
+   int name_size;
+   int i;
+
+   const char *na = "--N/A--";
+   char *back;
+
+   p_rom = ctx->bios;
+
+   str_num = *(p_rom + OFFSET_TO_GET_ATOMBIOS_NUMBER_OF_STRINGS);
+   if (str_num != 0) {
+   off_to_vbios_str =
+   *(unsigned short *)(p_rom + 
OFFSET_TO_GET_ATOMBIOS_STRING_START);
+
+   c_ptr = (unsigned char *)(p_rom + off_to_vbios_str);
+   } else {
+   /* do not know where to find name */
+   memcpy(ctx->name, na, 7);
+   ctx->name[7] = 0;
+   return;
+   }
+
+   /*
+* skip the atombios strings, usually 4
+* 1st is P/N, 2nd is ASIC, 3rd is PCI type, 4th is Memory type
+*/
+   for (i = 0; i < str_num; i++) {
+   while (*c_ptr != 0)
+   c_ptr++;
+   c_ptr++;
+   }
+
+   /* skip the following 2 chars: 0x0D 0x0A */
+   c_ptr += 2;
+
+   name_size = strnlen(c_ptr, STRLEN_LONG - 1);
+   memcpy(ctx->name, c_ptr, name_size);
+   back = ctx->name + name_size;
+   while ((*--back) == ' ')
+   ;
+   *(back + 1) = '\0';
+}
+
+static void atom_get_vbios_date(struct atom_context *ctx)
+{
+   unsigned char *p_rom;
+   unsigned char *date_in_rom;
+
+   p_rom = ctx->bios;
+
+   date_in_rom = p_rom + OFFSET_TO_VBIOS_DATE;
+
+   ctx->date[0] = '2';
+   ctx->date[1] = '0';
+   ctx->date[2] = date_in_rom[6];
+   ctx->date[3] = date_in_rom[7];
+   ctx->date[4] = '/';
+   ctx->date[5] = date_in_rom[0];
+   ctx->date[6] = date_in_rom[1];
+   ctx->date[7] = '/';
+   ctx->date[8] = date_in_rom[3];
+   ctx->date[9] = date_in_rom[4];
+   ctx->date[10] = ' ';
+   ctx->date[11] = date_in_rom[9];
+   ctx->date[12] = date_in_rom[10];
+   ctx->date[13] = date_in_rom[11];
+   ctx->date[14] = date_in_rom[12];
+   

RE: [PATCH] drm/amdgpu: Add vbios info ioctl interface

2021-05-18 Thread Lazar, Lijo
[Public]

Not sure about this one -  vbios version : 285409288

Windows driver reports VBIOS version from atom_firmware_info_v3_1 / 
firmware_revision.

Thanks,
Lijo

From: amd-gfx  On Behalf Of Gu, JiaWei 
(Will)
Sent: Tuesday, May 18, 2021 11:28 AM
To: Nieto, David M ; Koenig, Christian 
; amd-gfx@lists.freedesktop.org; mar...@gmail.com; 
Deucher, Alexander 
Cc: Deng, Emily 
Subject: RE: [PATCH] drm/amdgpu: Add vbios info ioctl interface


[Public]


[Public]

Hi all,

Then the struct looks like:

> +struct drm_amdgpu_info_vbios {
> + __u8 name[64];
> + __u8 vbios_pn[64];
> + __u32 version;
> + __u8 vbios_ver_str[32];
> + __u8 date[32];
> +};

Sample output:

vbios name : NAVI12 A0 XT D30501 8GB EVAL 1150e/334m HYN/SAM
vbios pn : 113-D3050100-104
vbios version : 285409288
vbios ver_str : 017.003.000.008.016956
vbios date : 2021/05/03 23:32
Please help double confirm that we're all fine with it and there's no need to 
add & remove anything.

Best regards,
Jiawei

From: Nieto, David M mailto:david.ni...@amd.com>>
Sent: Tuesday, May 18, 2021 12:40 PM
To: Gu, JiaWei (Will) mailto:jiawei...@amd.com>>; Koenig, 
Christian mailto:christian.koe...@amd.com>>; 
amd-gfx@lists.freedesktop.org<mailto:amd-gfx@lists.freedesktop.org>; 
mar...@gmail.com<mailto:mar...@gmail.com>; Deucher, Alexander 
mailto:alexander.deuc...@amd.com>>
Cc: Deng, Emily mailto:emily.d...@amd.com>>
Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface


[Public]

Yes, let's remove that too,

Thanks,

David

From: Gu, JiaWei (Will) mailto:jiawei...@amd.com>>
Sent: Monday, May 17, 2021 8:07 PM
To: Nieto, David M mailto:david.ni...@amd.com>>; Koenig, 
Christian mailto:christian.koe...@amd.com>>; 
amd-gfx@lists.freedesktop.org<mailto:amd-gfx@lists.freedesktop.org> 
mailto:amd-gfx@lists.freedesktop.org>>; 
mar...@gmail.com<mailto:mar...@gmail.com> 
mailto:mar...@gmail.com>>; Deucher, Alexander 
mailto:alexander.deuc...@amd.com>>
Cc: Deng, Emily mailto:emily.d...@amd.com>>
Subject: RE: [PATCH] drm/amdgpu: Add vbios info ioctl interface


[AMD Official Use Only - Internal Distribution Only]



OK let's remove serial.



dbdf comes from this:

vbios_info.dbdf = PCI_DEVID(adev->pdev->bus->number, adev->pdev->devfn);



I think we can remove dbdf as well.



Best regards,

Jiawei



From: Nieto, David M mailto:david.ni...@amd.com>>
Sent: Tuesday, May 18, 2021 10:45 AM
To: Gu, JiaWei (Will) mailto:jiawei...@amd.com>>; Koenig, 
Christian mailto:christian.koe...@amd.com>>; 
amd-gfx@lists.freedesktop.org<mailto:amd-gfx@lists.freedesktop.org>; 
mar...@gmail.com<mailto:mar...@gmail.com>; Deucher, Alexander 
mailto:alexander.deuc...@amd.com>>
Cc: Deng, Emily mailto:emily.d...@amd.com>>
Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface



[AMD Official Use Only - Internal Distribution Only]



The serial number is ASIC information, not VBIOS information, and it is still 
available as a sysfs node... I don't think we should put it there.



Not sure what dbdf stands for.



From: Gu, JiaWei (Will) mailto:jiawei...@amd.com>>
Sent: Monday, May 17, 2021 7:11 PM
To: Koenig, Christian 
mailto:christian.koe...@amd.com>>; 
amd-gfx@lists.freedesktop.org<mailto:amd-gfx@lists.freedesktop.org> 
mailto:amd-gfx@lists.freedesktop.org>>; Nieto, 
David M mailto:david.ni...@amd.com>>; 
mar...@gmail.com<mailto:mar...@gmail.com> 
mailto:mar...@gmail.com>>; Deucher, Alexander 
mailto:alexander.deuc...@amd.com>>
Cc: Deng, Emily mailto:emily.d...@amd.com>>
Subject: RE: [PATCH] drm/amdgpu: Add vbios info ioctl interface



[AMD Official Use Only - Internal Distribution Only]

So I guess the dbdf is also needed to be removed?
And how about serial?

> +struct drm_amdgpu_info_vbios {
> + __u8 name[64];
> + __u32 dbdf; // do we need this?
> + __u8 vbios_pn[64];
> + __u32 version;
> + __u8 vbios_ver_str[32];
> + __u8 date[32];
> + __u64 serial; // do we need this?
> +};

Best regards,
Jiawei

-Original Message-
From: Koenig, Christian 
mailto:christian.koe...@amd.com>>
Sent: Monday, May 17, 2021 8:26 PM
To: Gu, JiaWei (Will) mailto:jiawei...@amd.com>>; 
amd-gfx@lists.freedesktop.org<mailto:amd-gfx@lists.freedesktop.org>; Nieto, 
David M mailto:david.ni...@amd.com>>; 
mar...@gmail.com<mailto:mar...@gmail.com>; Deucher, Alexander 
mailto:alexander.deuc...@amd.com>>
Cc: Deng, Emily mailto:emily.d...@amd.com>>
Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

I'm not very familiar with the technical background why we have the fields here 
once more.

But of hand we should at least remove everything which is also available from 
the PCI 

Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

2021-05-18 Thread Nieto, David M
[Public]

That looks like the right output to me.

From: Gu, JiaWei (Will) 
Sent: Monday, May 17, 2021 10:58 PM
To: Nieto, David M ; Koenig, Christian 
; amd-gfx@lists.freedesktop.org 
; mar...@gmail.com ; Deucher, 
Alexander 
Cc: Deng, Emily 
Subject: RE: [PATCH] drm/amdgpu: Add vbios info ioctl interface


[Public]


Hi all,



Then the struct looks like:



> +struct drm_amdgpu_info_vbios {
> + __u8 name[64];
> + __u8 vbios_pn[64];
> + __u32 version;
> + __u8 vbios_ver_str[32];
> + __u8 date[32];
> +};



Sample output:



vbios name : NAVI12 A0 XT D30501 8GB EVAL 1150e/334m HYN/SAM
vbios pn : 113-D3050100-104
vbios version : 285409288
vbios ver_str : 017.003.000.008.016956
vbios date : 2021/05/03 23:32


Please help double confirm that we’re all fine with it and there’s no need to 
add & remove anything.



Best regards,

Jiawei



From: Nieto, David M 
Sent: Tuesday, May 18, 2021 12:40 PM
To: Gu, JiaWei (Will) ; Koenig, Christian 
; amd-gfx@lists.freedesktop.org; mar...@gmail.com; 
Deucher, Alexander 
Cc: Deng, Emily 
Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface



[Public]



Yes, let's remove that too,



Thanks,



David



From: Gu, JiaWei (Will) mailto:jiawei...@amd.com>>
Sent: Monday, May 17, 2021 8:07 PM
To: Nieto, David M mailto:david.ni...@amd.com>>; Koenig, 
Christian mailto:christian.koe...@amd.com>>; 
amd-gfx@lists.freedesktop.org<mailto:amd-gfx@lists.freedesktop.org> 
mailto:amd-gfx@lists.freedesktop.org>>; 
mar...@gmail.com<mailto:mar...@gmail.com> 
mailto:mar...@gmail.com>>; Deucher, Alexander 
mailto:alexander.deuc...@amd.com>>
Cc: Deng, Emily mailto:emily.d...@amd.com>>
Subject: RE: [PATCH] drm/amdgpu: Add vbios info ioctl interface



[AMD Official Use Only - Internal Distribution Only]



OK let’s remove serial.



dbdf comes from this:

vbios_info.dbdf = PCI_DEVID(adev->pdev->bus->number, adev->pdev->devfn);



I think we can remove dbdf as well.



Best regards,

Jiawei



From: Nieto, David M mailto:david.ni...@amd.com>>
Sent: Tuesday, May 18, 2021 10:45 AM
To: Gu, JiaWei (Will) mailto:jiawei...@amd.com>>; Koenig, 
Christian mailto:christian.koe...@amd.com>>; 
amd-gfx@lists.freedesktop.org<mailto:amd-gfx@lists.freedesktop.org>; 
mar...@gmail.com<mailto:mar...@gmail.com>; Deucher, Alexander 
mailto:alexander.deuc...@amd.com>>
Cc: Deng, Emily mailto:emily.d...@amd.com>>
Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface



[AMD Official Use Only - Internal Distribution Only]



The serial number is ASIC information, not VBIOS information, and it is still 
available as a sysfs node... I don't think we should put it there.



Not sure what dbdf stands for.



From: Gu, JiaWei (Will) mailto:jiawei...@amd.com>>
Sent: Monday, May 17, 2021 7:11 PM
To: Koenig, Christian 
mailto:christian.koe...@amd.com>>; 
amd-gfx@lists.freedesktop.org<mailto:amd-gfx@lists.freedesktop.org> 
mailto:amd-gfx@lists.freedesktop.org>>; Nieto, 
David M mailto:david.ni...@amd.com>>; 
mar...@gmail.com<mailto:mar...@gmail.com> 
mailto:mar...@gmail.com>>; Deucher, Alexander 
mailto:alexander.deuc...@amd.com>>
Cc: Deng, Emily mailto:emily.d...@amd.com>>
Subject: RE: [PATCH] drm/amdgpu: Add vbios info ioctl interface



[AMD Official Use Only - Internal Distribution Only]

So I guess the dbdf is also needed to be removed?
And how about serial?

> +struct drm_amdgpu_info_vbios {
> + __u8 name[64];
> + __u32 dbdf; // do we need this?
> + __u8 vbios_pn[64];
> + __u32 version;
> + __u8 vbios_ver_str[32];
> + __u8 date[32];
> + __u64 serial; // do we need this?
> +};

Best regards,
Jiawei

-Original Message-
From: Koenig, Christian 
mailto:christian.koe...@amd.com>>
Sent: Monday, May 17, 2021 8:26 PM
To: Gu, JiaWei (Will) mailto:jiawei...@amd.com>>; 
amd-gfx@lists.freedesktop.org<mailto:amd-gfx@lists.freedesktop.org>; Nieto, 
David M mailto:david.ni...@amd.com>>; 
mar...@gmail.com<mailto:mar...@gmail.com>; Deucher, Alexander 
mailto:alexander.deuc...@amd.com>>
Cc: Deng, Emily mailto:emily.d...@amd.com>>
Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

I'm not very familiar with the technical background why we have the fields here 
once more.

But of hand we should at least remove everything which is also available from 
the PCI information.

E.g. dev_id, rev_id, sub_dev_id, sub_ved_id.

Regards,
Christian.

Am 17.05.21 um 14:17 schrieb Gu, JiaWei (Will):
> [AMD Official Use Only - Internal Distribution Only]
>
> Hi all,
>
> Thanks Christian's suggestion.
> I reverted the previous patches and squash them into this single one.
>
> As th

RE: [PATCH] drm/amdgpu: Add vbios info ioctl interface

2021-05-17 Thread Gu, JiaWei (Will)
[Public]

Hi all,

Then the struct looks like:

> +struct drm_amdgpu_info_vbios {
> + __u8 name[64];
> + __u8 vbios_pn[64];
> + __u32 version;
> + __u8 vbios_ver_str[32];
> + __u8 date[32];
> +};

Sample output:

vbios name : NAVI12 A0 XT D30501 8GB EVAL 1150e/334m HYN/SAM
vbios pn : 113-D3050100-104
vbios version : 285409288
vbios ver_str : 017.003.000.008.016956
vbios date : 2021/05/03 23:32

Please help double confirm that we're all fine with it and there's no need to 
add & remove anything.

Best regards,
Jiawei

From: Nieto, David M 
Sent: Tuesday, May 18, 2021 12:40 PM
To: Gu, JiaWei (Will) ; Koenig, Christian 
; amd-gfx@lists.freedesktop.org; mar...@gmail.com; 
Deucher, Alexander 
Cc: Deng, Emily 
Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface


[Public]

Yes, let's remove that too,

Thanks,

David

From: Gu, JiaWei (Will) mailto:jiawei...@amd.com>>
Sent: Monday, May 17, 2021 8:07 PM
To: Nieto, David M mailto:david.ni...@amd.com>>; Koenig, 
Christian mailto:christian.koe...@amd.com>>; 
amd-gfx@lists.freedesktop.org<mailto:amd-gfx@lists.freedesktop.org> 
mailto:amd-gfx@lists.freedesktop.org>>; 
mar...@gmail.com<mailto:mar...@gmail.com> 
mailto:mar...@gmail.com>>; Deucher, Alexander 
mailto:alexander.deuc...@amd.com>>
Cc: Deng, Emily mailto:emily.d...@amd.com>>
Subject: RE: [PATCH] drm/amdgpu: Add vbios info ioctl interface


[AMD Official Use Only - Internal Distribution Only]



OK let's remove serial.



dbdf comes from this:

vbios_info.dbdf = PCI_DEVID(adev->pdev->bus->number, adev->pdev->devfn);



I think we can remove dbdf as well.



Best regards,

Jiawei



From: Nieto, David M mailto:david.ni...@amd.com>>
Sent: Tuesday, May 18, 2021 10:45 AM
To: Gu, JiaWei (Will) mailto:jiawei...@amd.com>>; Koenig, 
Christian mailto:christian.koe...@amd.com>>; 
amd-gfx@lists.freedesktop.org<mailto:amd-gfx@lists.freedesktop.org>; 
mar...@gmail.com<mailto:mar...@gmail.com>; Deucher, Alexander 
mailto:alexander.deuc...@amd.com>>
Cc: Deng, Emily mailto:emily.d...@amd.com>>
Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface



[AMD Official Use Only - Internal Distribution Only]



The serial number is ASIC information, not VBIOS information, and it is still 
available as a sysfs node... I don't think we should put it there.



Not sure what dbdf stands for.



From: Gu, JiaWei (Will) mailto:jiawei...@amd.com>>
Sent: Monday, May 17, 2021 7:11 PM
To: Koenig, Christian 
mailto:christian.koe...@amd.com>>; 
amd-gfx@lists.freedesktop.org<mailto:amd-gfx@lists.freedesktop.org> 
mailto:amd-gfx@lists.freedesktop.org>>; Nieto, 
David M mailto:david.ni...@amd.com>>; 
mar...@gmail.com<mailto:mar...@gmail.com> 
mailto:mar...@gmail.com>>; Deucher, Alexander 
mailto:alexander.deuc...@amd.com>>
Cc: Deng, Emily mailto:emily.d...@amd.com>>
Subject: RE: [PATCH] drm/amdgpu: Add vbios info ioctl interface



[AMD Official Use Only - Internal Distribution Only]

So I guess the dbdf is also needed to be removed?
And how about serial?

> +struct drm_amdgpu_info_vbios {
> + __u8 name[64];
> + __u32 dbdf; // do we need this?
> + __u8 vbios_pn[64];
> + __u32 version;
> + __u8 vbios_ver_str[32];
> + __u8 date[32];
> + __u64 serial; // do we need this?
> +};

Best regards,
Jiawei

-Original Message-
From: Koenig, Christian 
mailto:christian.koe...@amd.com>>
Sent: Monday, May 17, 2021 8:26 PM
To: Gu, JiaWei (Will) mailto:jiawei...@amd.com>>; 
amd-gfx@lists.freedesktop.org<mailto:amd-gfx@lists.freedesktop.org>; Nieto, 
David M mailto:david.ni...@amd.com>>; 
mar...@gmail.com<mailto:mar...@gmail.com>; Deucher, Alexander 
mailto:alexander.deuc...@amd.com>>
Cc: Deng, Emily mailto:emily.d...@amd.com>>
Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

I'm not very familiar with the technical background why we have the fields here 
once more.

But of hand we should at least remove everything which is also available from 
the PCI information.

E.g. dev_id, rev_id, sub_dev_id, sub_ved_id.

Regards,
Christian.

Am 17.05.21 um 14:17 schrieb Gu, JiaWei (Will):
> [AMD Official Use Only - Internal Distribution Only]
>
> Hi all,
>
> Thanks Christian's suggestion.
> I reverted the previous patches and squash them into this single one.
>
> As this patch shows, the current uapi change looks like this:
>
> +struct drm_amdgpu_info_vbios {
> + __u8 name[64];
> + __u32 dbdf;
> + __u8 vbios_pn[64];
> + __u32 version;
> + __u8 vbios_ver_str[32];
> + __u8 date[32];
> + __u64 serial;
> + __u32 dev_id;
> + __u32 rev_id;
> + __u32 sub_dev_id;
> +

Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

2021-05-17 Thread Nieto, David M
[Public]

Yes, let's remove that too,

Thanks,

David

From: Gu, JiaWei (Will) 
Sent: Monday, May 17, 2021 8:07 PM
To: Nieto, David M ; Koenig, Christian 
; amd-gfx@lists.freedesktop.org 
; mar...@gmail.com ; Deucher, 
Alexander 
Cc: Deng, Emily 
Subject: RE: [PATCH] drm/amdgpu: Add vbios info ioctl interface


[AMD Official Use Only - Internal Distribution Only]



OK let’s remove serial.



dbdf comes from this:

vbios_info.dbdf = PCI_DEVID(adev->pdev->bus->number, adev->pdev->devfn);



I think we can remove dbdf as well.



Best regards,

Jiawei



From: Nieto, David M 
Sent: Tuesday, May 18, 2021 10:45 AM
To: Gu, JiaWei (Will) ; Koenig, Christian 
; amd-gfx@lists.freedesktop.org; mar...@gmail.com; 
Deucher, Alexander 
Cc: Deng, Emily 
Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface



[AMD Official Use Only - Internal Distribution Only]



The serial number is ASIC information, not VBIOS information, and it is still 
available as a sysfs node... I don't think we should put it there.



Not sure what dbdf stands for.



From: Gu, JiaWei (Will) mailto:jiawei...@amd.com>>
Sent: Monday, May 17, 2021 7:11 PM
To: Koenig, Christian 
mailto:christian.koe...@amd.com>>; 
amd-gfx@lists.freedesktop.org<mailto:amd-gfx@lists.freedesktop.org> 
mailto:amd-gfx@lists.freedesktop.org>>; Nieto, 
David M mailto:david.ni...@amd.com>>; 
mar...@gmail.com<mailto:mar...@gmail.com> 
mailto:mar...@gmail.com>>; Deucher, Alexander 
mailto:alexander.deuc...@amd.com>>
Cc: Deng, Emily mailto:emily.d...@amd.com>>
Subject: RE: [PATCH] drm/amdgpu: Add vbios info ioctl interface



[AMD Official Use Only - Internal Distribution Only]

So I guess the dbdf is also needed to be removed?
And how about serial?

> +struct drm_amdgpu_info_vbios {
> + __u8 name[64];
> + __u32 dbdf; // do we need this?
> + __u8 vbios_pn[64];
> + __u32 version;
> + __u8 vbios_ver_str[32];
> + __u8 date[32];
> + __u64 serial; // do we need this?
> +};

Best regards,
Jiawei

-Original Message-
From: Koenig, Christian 
mailto:christian.koe...@amd.com>>
Sent: Monday, May 17, 2021 8:26 PM
To: Gu, JiaWei (Will) mailto:jiawei...@amd.com>>; 
amd-gfx@lists.freedesktop.org<mailto:amd-gfx@lists.freedesktop.org>; Nieto, 
David M mailto:david.ni...@amd.com>>; 
mar...@gmail.com<mailto:mar...@gmail.com>; Deucher, Alexander 
mailto:alexander.deuc...@amd.com>>
Cc: Deng, Emily mailto:emily.d...@amd.com>>
Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

I'm not very familiar with the technical background why we have the fields here 
once more.

But of hand we should at least remove everything which is also available from 
the PCI information.

E.g. dev_id, rev_id, sub_dev_id, sub_ved_id.

Regards,
Christian.

Am 17.05.21 um 14:17 schrieb Gu, JiaWei (Will):
> [AMD Official Use Only - Internal Distribution Only]
>
> Hi all,
>
> Thanks Christian's suggestion.
> I reverted the previous patches and squash them into this single one.
>
> As this patch shows, the current uapi change looks like this:
>
> +struct drm_amdgpu_info_vbios {
> + __u8 name[64];
> + __u32 dbdf;
> + __u8 vbios_pn[64];
> + __u32 version;
> + __u8 vbios_ver_str[32];
> + __u8 date[32];
> + __u64 serial;
> + __u32 dev_id;
> + __u32 rev_id;
> + __u32 sub_dev_id;
> + __u32 sub_ved_id;
> +};
>
> As we know there's some redundant info in this struct.
> Please feel free to give any comments or suggestion about what it should & 
> shouldn't include.
>
> Best regards,
> Jiawei
>
> -Original Message-
> From: Jiawei Gu mailto:jiawei...@amd.com>>
> Sent: Monday, May 17, 2021 8:08 PM
> To: amd-gfx@lists.freedesktop.org<mailto:amd-gfx@lists.freedesktop.org>; 
> Koenig, Christian
> mailto:christian.koe...@amd.com>>; Nieto, David M 
> mailto:david.ni...@amd.com>>;
> mar...@gmail.com<mailto:mar...@gmail.com>; Deucher, Alexander 
> mailto:alexander.deuc...@amd.com>>
> Cc: Deng, Emily mailto:emily.d...@amd.com>>; Gu, JiaWei 
> (Will)
> mailto:jiawei...@amd.com>>
> Subject: [PATCH] drm/amdgpu: Add vbios info ioctl interface
>
> Add AMDGPU_INFO_VBIOS_INFO subquery id for detailed vbios info.
>
> Provides a way for the user application to get the VBIOS information without 
> having to parse the binary.
> It is useful for the user to be able to display in a simple way the VBIOS 
> version in their system if they happen to encounter an issue.
>
> V2:
> Use numeric serial.
> Parse and expose vbios version string.
>
> Signed-off-by: Jiawei Gu mailto:jiawei...@amd.com>>
> Acked-by: Christian König

RE: [PATCH] drm/amdgpu: Add vbios info ioctl interface

2021-05-17 Thread Gu, JiaWei (Will)
[AMD Official Use Only - Internal Distribution Only]

OK let's remove serial.

dbdf comes from this:
vbios_info.dbdf = PCI_DEVID(adev->pdev->bus->number, adev->pdev->devfn);

I think we can remove dbdf as well.

Best regards,
Jiawei

From: Nieto, David M 
Sent: Tuesday, May 18, 2021 10:45 AM
To: Gu, JiaWei (Will) ; Koenig, Christian 
; amd-gfx@lists.freedesktop.org; mar...@gmail.com; 
Deucher, Alexander 
Cc: Deng, Emily 
Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface


[AMD Official Use Only - Internal Distribution Only]

The serial number is ASIC information, not VBIOS information, and it is still 
available as a sysfs node... I don't think we should put it there.

Not sure what dbdf stands for.

From: Gu, JiaWei (Will) mailto:jiawei...@amd.com>>
Sent: Monday, May 17, 2021 7:11 PM
To: Koenig, Christian 
mailto:christian.koe...@amd.com>>; 
amd-gfx@lists.freedesktop.org<mailto:amd-gfx@lists.freedesktop.org> 
mailto:amd-gfx@lists.freedesktop.org>>; Nieto, 
David M mailto:david.ni...@amd.com>>; 
mar...@gmail.com<mailto:mar...@gmail.com> 
mailto:mar...@gmail.com>>; Deucher, Alexander 
mailto:alexander.deuc...@amd.com>>
Cc: Deng, Emily mailto:emily.d...@amd.com>>
Subject: RE: [PATCH] drm/amdgpu: Add vbios info ioctl interface

[AMD Official Use Only - Internal Distribution Only]

So I guess the dbdf is also needed to be removed?
And how about serial?

> +struct drm_amdgpu_info_vbios {
> + __u8 name[64];
> + __u32 dbdf; // do we need this?
> + __u8 vbios_pn[64];
> + __u32 version;
> + __u8 vbios_ver_str[32];
> + __u8 date[32];
> + __u64 serial; // do we need this?
> +};

Best regards,
Jiawei

-Original Message-
From: Koenig, Christian 
mailto:christian.koe...@amd.com>>
Sent: Monday, May 17, 2021 8:26 PM
To: Gu, JiaWei (Will) mailto:jiawei...@amd.com>>; 
amd-gfx@lists.freedesktop.org<mailto:amd-gfx@lists.freedesktop.org>; Nieto, 
David M mailto:david.ni...@amd.com>>; 
mar...@gmail.com<mailto:mar...@gmail.com>; Deucher, Alexander 
mailto:alexander.deuc...@amd.com>>
Cc: Deng, Emily mailto:emily.d...@amd.com>>
Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

I'm not very familiar with the technical background why we have the fields here 
once more.

But of hand we should at least remove everything which is also available from 
the PCI information.

E.g. dev_id, rev_id, sub_dev_id, sub_ved_id.

Regards,
Christian.

Am 17.05.21 um 14:17 schrieb Gu, JiaWei (Will):
> [AMD Official Use Only - Internal Distribution Only]
>
> Hi all,
>
> Thanks Christian's suggestion.
> I reverted the previous patches and squash them into this single one.
>
> As this patch shows, the current uapi change looks like this:
>
> +struct drm_amdgpu_info_vbios {
> + __u8 name[64];
> + __u32 dbdf;
> + __u8 vbios_pn[64];
> + __u32 version;
> + __u8 vbios_ver_str[32];
> + __u8 date[32];
> + __u64 serial;
> + __u32 dev_id;
> + __u32 rev_id;
> + __u32 sub_dev_id;
> + __u32 sub_ved_id;
> +};
>
> As we know there's some redundant info in this struct.
> Please feel free to give any comments or suggestion about what it should & 
> shouldn't include.
>
> Best regards,
> Jiawei
>
> -Original Message-
> From: Jiawei Gu mailto:jiawei...@amd.com>>
> Sent: Monday, May 17, 2021 8:08 PM
> To: amd-gfx@lists.freedesktop.org<mailto:amd-gfx@lists.freedesktop.org>; 
> Koenig, Christian
> mailto:christian.koe...@amd.com>>; Nieto, David M 
> mailto:david.ni...@amd.com>>;
> mar...@gmail.com<mailto:mar...@gmail.com>; Deucher, Alexander 
> mailto:alexander.deuc...@amd.com>>
> Cc: Deng, Emily mailto:emily.d...@amd.com>>; Gu, JiaWei 
> (Will)
> mailto:jiawei...@amd.com>>
> Subject: [PATCH] drm/amdgpu: Add vbios info ioctl interface
>
> Add AMDGPU_INFO_VBIOS_INFO subquery id for detailed vbios info.
>
> Provides a way for the user application to get the VBIOS information without 
> having to parse the binary.
> It is useful for the user to be able to display in a simple way the VBIOS 
> version in their system if they happen to encounter an issue.
>
> V2:
> Use numeric serial.
> Parse and expose vbios version string.
>
> Signed-off-by: Jiawei Gu mailto:jiawei...@amd.com>>
> Acked-by: Christian König 
> mailto:christian.koe...@amd.com>>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c|  21 +++
>   drivers/gpu/drm/amd/amdgpu/atom.c  | 174 +
>   drivers/gpu/drm/amd/amdgpu/atom.h  |  12 ++
>   drivers/gpu/drm/amd/include/atomfirmware.h |   5 +
>   include/uapi/drm/amdgpu_drm.h

Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

2021-05-17 Thread Nieto, David M
[AMD Official Use Only - Internal Distribution Only]

The serial number is ASIC information, not VBIOS information, and it is still 
available as a sysfs node... I don't think we should put it there.

Not sure what dbdf stands for.

From: Gu, JiaWei (Will) 
Sent: Monday, May 17, 2021 7:11 PM
To: Koenig, Christian ; amd-gfx@lists.freedesktop.org 
; Nieto, David M ; 
mar...@gmail.com ; Deucher, Alexander 

Cc: Deng, Emily 
Subject: RE: [PATCH] drm/amdgpu: Add vbios info ioctl interface

[AMD Official Use Only - Internal Distribution Only]

So I guess the dbdf is also needed to be removed?
And how about serial?

> +struct drm_amdgpu_info_vbios {
> + __u8 name[64];
> + __u32 dbdf; // do we need this?
> + __u8 vbios_pn[64];
> + __u32 version;
> + __u8 vbios_ver_str[32];
> + __u8 date[32];
> + __u64 serial; // do we need this?
> +};

Best regards,
Jiawei

-Original Message-
From: Koenig, Christian 
Sent: Monday, May 17, 2021 8:26 PM
To: Gu, JiaWei (Will) ; amd-gfx@lists.freedesktop.org; 
Nieto, David M ; mar...@gmail.com; Deucher, Alexander 

Cc: Deng, Emily 
Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

I'm not very familiar with the technical background why we have the fields here 
once more.

But of hand we should at least remove everything which is also available from 
the PCI information.

E.g. dev_id, rev_id, sub_dev_id, sub_ved_id.

Regards,
Christian.

Am 17.05.21 um 14:17 schrieb Gu, JiaWei (Will):
> [AMD Official Use Only - Internal Distribution Only]
>
> Hi all,
>
> Thanks Christian's suggestion.
> I reverted the previous patches and squash them into this single one.
>
> As this patch shows, the current uapi change looks like this:
>
> +struct drm_amdgpu_info_vbios {
> + __u8 name[64];
> + __u32 dbdf;
> + __u8 vbios_pn[64];
> + __u32 version;
> + __u8 vbios_ver_str[32];
> + __u8 date[32];
> + __u64 serial;
> + __u32 dev_id;
> + __u32 rev_id;
> + __u32 sub_dev_id;
> + __u32 sub_ved_id;
> +};
>
> As we know there's some redundant info in this struct.
> Please feel free to give any comments or suggestion about what it should & 
> shouldn't include.
>
> Best regards,
> Jiawei
>
> -Original Message-
> From: Jiawei Gu 
> Sent: Monday, May 17, 2021 8:08 PM
> To: amd-gfx@lists.freedesktop.org; Koenig, Christian
> ; Nieto, David M ;
> mar...@gmail.com; Deucher, Alexander 
> Cc: Deng, Emily ; Gu, JiaWei (Will)
> 
> Subject: [PATCH] drm/amdgpu: Add vbios info ioctl interface
>
> Add AMDGPU_INFO_VBIOS_INFO subquery id for detailed vbios info.
>
> Provides a way for the user application to get the VBIOS information without 
> having to parse the binary.
> It is useful for the user to be able to display in a simple way the VBIOS 
> version in their system if they happen to encounter an issue.
>
> V2:
> Use numeric serial.
> Parse and expose vbios version string.
>
> Signed-off-by: Jiawei Gu 
> Acked-by: Christian König 
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c|  21 +++
>   drivers/gpu/drm/amd/amdgpu/atom.c  | 174 +
>   drivers/gpu/drm/amd/amdgpu/atom.h  |  12 ++
>   drivers/gpu/drm/amd/include/atomfirmware.h |   5 +
>   include/uapi/drm/amdgpu_drm.h  |  16 ++
>   5 files changed, 228 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> index 8d12e474745a..30e4fed3de22 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> @@ -861,6 +861,27 @@ int amdgpu_info_ioctl(struct drm_device *dev, void 
> *data, struct drm_file *filp)
>min((size_t)size, 
> (size_t)(bios_size - bios_offset)))
>? -EFAULT : 0;
>}
> + case AMDGPU_INFO_VBIOS_INFO: {
> + struct drm_amdgpu_info_vbios vbios_info = {};
> + struct atom_context *atom_context;
> +
> + atom_context = adev->mode_info.atom_context;
> + memcpy(vbios_info.name, atom_context->name, 
> sizeof(atom_context->name));
> + vbios_info.dbdf = PCI_DEVID(adev->pdev->bus->number, 
> adev->pdev->devfn);
> + memcpy(vbios_info.vbios_pn, atom_context->vbios_pn, 
> sizeof(atom_context->vbios_pn));
> + vbios_info.version = atom_context->version;
> + memcpy(vbios_info.vbios_ver_str, 
> atom_context->vbios_ver_str,
> + 
&

RE: [PATCH] drm/amdgpu: Add vbios info ioctl interface

2021-05-17 Thread Gu, JiaWei (Will)
[AMD Official Use Only - Internal Distribution Only]

So I guess the dbdf is also needed to be removed?
And how about serial?

> +struct drm_amdgpu_info_vbios {
> + __u8 name[64];
> + __u32 dbdf; // do we need this?
> + __u8 vbios_pn[64];
> + __u32 version;
> + __u8 vbios_ver_str[32];
> + __u8 date[32];
> + __u64 serial; // do we need this?
> +};

Best regards,
Jiawei

-Original Message-
From: Koenig, Christian  
Sent: Monday, May 17, 2021 8:26 PM
To: Gu, JiaWei (Will) ; amd-gfx@lists.freedesktop.org; 
Nieto, David M ; mar...@gmail.com; Deucher, Alexander 

Cc: Deng, Emily 
Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

I'm not very familiar with the technical background why we have the fields here 
once more.

But of hand we should at least remove everything which is also available from 
the PCI information.

E.g. dev_id, rev_id, sub_dev_id, sub_ved_id.

Regards,
Christian.

Am 17.05.21 um 14:17 schrieb Gu, JiaWei (Will):
> [AMD Official Use Only - Internal Distribution Only]
>
> Hi all,
>
> Thanks Christian's suggestion.
> I reverted the previous patches and squash them into this single one.
>
> As this patch shows, the current uapi change looks like this:
>
> +struct drm_amdgpu_info_vbios {
> + __u8 name[64];
> + __u32 dbdf;
> + __u8 vbios_pn[64];
> + __u32 version;
> + __u8 vbios_ver_str[32];
> + __u8 date[32];
> + __u64 serial;
> + __u32 dev_id;
> + __u32 rev_id;
> + __u32 sub_dev_id;
> + __u32 sub_ved_id;
> +};
>
> As we know there's some redundant info in this struct.
> Please feel free to give any comments or suggestion about what it should & 
> shouldn't include.
>
> Best regards,
> Jiawei
>
> -Original Message-
> From: Jiawei Gu 
> Sent: Monday, May 17, 2021 8:08 PM
> To: amd-gfx@lists.freedesktop.org; Koenig, Christian 
> ; Nieto, David M ; 
> mar...@gmail.com; Deucher, Alexander 
> Cc: Deng, Emily ; Gu, JiaWei (Will) 
> 
> Subject: [PATCH] drm/amdgpu: Add vbios info ioctl interface
>
> Add AMDGPU_INFO_VBIOS_INFO subquery id for detailed vbios info.
>
> Provides a way for the user application to get the VBIOS information without 
> having to parse the binary.
> It is useful for the user to be able to display in a simple way the VBIOS 
> version in their system if they happen to encounter an issue.
>
> V2:
> Use numeric serial.
> Parse and expose vbios version string.
>
> Signed-off-by: Jiawei Gu 
> Acked-by: Christian König 
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c|  21 +++
>   drivers/gpu/drm/amd/amdgpu/atom.c  | 174 +
>   drivers/gpu/drm/amd/amdgpu/atom.h  |  12 ++
>   drivers/gpu/drm/amd/include/atomfirmware.h |   5 +
>   include/uapi/drm/amdgpu_drm.h  |  16 ++
>   5 files changed, 228 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> index 8d12e474745a..30e4fed3de22 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> @@ -861,6 +861,27 @@ int amdgpu_info_ioctl(struct drm_device *dev, void 
> *data, struct drm_file *filp)
>   min((size_t)size, 
> (size_t)(bios_size - bios_offset)))
>   ? -EFAULT : 0;
>   }
> + case AMDGPU_INFO_VBIOS_INFO: {
> + struct drm_amdgpu_info_vbios vbios_info = {};
> + struct atom_context *atom_context;
> +
> + atom_context = adev->mode_info.atom_context;
> + memcpy(vbios_info.name, atom_context->name, 
> sizeof(atom_context->name));
> + vbios_info.dbdf = PCI_DEVID(adev->pdev->bus->number, 
> adev->pdev->devfn);
> + memcpy(vbios_info.vbios_pn, atom_context->vbios_pn, 
> sizeof(atom_context->vbios_pn));
> + vbios_info.version = atom_context->version;
> + memcpy(vbios_info.vbios_ver_str, 
> atom_context->vbios_ver_str,
> + 
> sizeof(atom_context->vbios_ver_str));
> + memcpy(vbios_info.date, atom_context->date, 
> sizeof(atom_context->date));
> + vbios_info.serial = adev->unique_id;
> + vbios_info.dev_id = adev->pdev->device;
> + vbios_info.rev_id = adev->pdev->revision;
> + vbios_info.sub_dev_id = atom_context->sub_dev_id;
> + vbios_info.sub_ved_id = atom_context->sub_ved_id;
> +
> +

Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

2021-05-17 Thread Christian König
I'm not very familiar with the technical background why we have the 
fields here once more.


But of hand we should at least remove everything which is also available 
from the PCI information.


E.g. dev_id, rev_id, sub_dev_id, sub_ved_id.

Regards,
Christian.

Am 17.05.21 um 14:17 schrieb Gu, JiaWei (Will):

[AMD Official Use Only - Internal Distribution Only]

Hi all,

Thanks Christian's suggestion.
I reverted the previous patches and squash them into this single one.

As this patch shows, the current uapi change looks like this:

+struct drm_amdgpu_info_vbios {
+   __u8 name[64];
+   __u32 dbdf;
+   __u8 vbios_pn[64];
+   __u32 version;
+   __u8 vbios_ver_str[32];
+   __u8 date[32];
+   __u64 serial;
+   __u32 dev_id;
+   __u32 rev_id;
+   __u32 sub_dev_id;
+   __u32 sub_ved_id;
+};

As we know there's some redundant info in this struct.
Please feel free to give any comments or suggestion about what it should & 
shouldn't include.

Best regards,
Jiawei

-Original Message-
From: Jiawei Gu 
Sent: Monday, May 17, 2021 8:08 PM
To: amd-gfx@lists.freedesktop.org; Koenig, Christian ; Nieto, 
David M ; mar...@gmail.com; Deucher, Alexander 

Cc: Deng, Emily ; Gu, JiaWei (Will) 
Subject: [PATCH] drm/amdgpu: Add vbios info ioctl interface

Add AMDGPU_INFO_VBIOS_INFO subquery id for detailed vbios info.

Provides a way for the user application to get the VBIOS information without 
having to parse the binary.
It is useful for the user to be able to display in a simple way the VBIOS 
version in their system if they happen to encounter an issue.

V2:
Use numeric serial.
Parse and expose vbios version string.

Signed-off-by: Jiawei Gu 
Acked-by: Christian König 
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c|  21 +++
  drivers/gpu/drm/amd/amdgpu/atom.c  | 174 +
  drivers/gpu/drm/amd/amdgpu/atom.h  |  12 ++
  drivers/gpu/drm/amd/include/atomfirmware.h |   5 +
  include/uapi/drm/amdgpu_drm.h  |  16 ++
  5 files changed, 228 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
index 8d12e474745a..30e4fed3de22 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
@@ -861,6 +861,27 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, 
struct drm_file *filp)
min((size_t)size, 
(size_t)(bios_size - bios_offset)))
? -EFAULT : 0;
}
+   case AMDGPU_INFO_VBIOS_INFO: {
+   struct drm_amdgpu_info_vbios vbios_info = {};
+   struct atom_context *atom_context;
+
+   atom_context = adev->mode_info.atom_context;
+   memcpy(vbios_info.name, atom_context->name, 
sizeof(atom_context->name));
+   vbios_info.dbdf = PCI_DEVID(adev->pdev->bus->number, 
adev->pdev->devfn);
+   memcpy(vbios_info.vbios_pn, atom_context->vbios_pn, 
sizeof(atom_context->vbios_pn));
+   vbios_info.version = atom_context->version;
+   memcpy(vbios_info.vbios_ver_str, 
atom_context->vbios_ver_str,
+   
sizeof(atom_context->vbios_ver_str));
+   memcpy(vbios_info.date, atom_context->date, 
sizeof(atom_context->date));
+   vbios_info.serial = adev->unique_id;
+   vbios_info.dev_id = adev->pdev->device;
+   vbios_info.rev_id = adev->pdev->revision;
+   vbios_info.sub_dev_id = atom_context->sub_dev_id;
+   vbios_info.sub_ved_id = atom_context->sub_ved_id;
+
+   return copy_to_user(out, _info,
+   min((size_t)size, 
sizeof(vbios_info))) ? -EFAULT : 0;
+   }
default:
DRM_DEBUG_KMS("Invalid request %d\n",
info->vbios_info.type);
diff --git a/drivers/gpu/drm/amd/amdgpu/atom.c 
b/drivers/gpu/drm/amd/amdgpu/atom.c
index 3dcb8b32f48b..542b2c2414e4 100644
--- a/drivers/gpu/drm/amd/amdgpu/atom.c
+++ b/drivers/gpu/drm/amd/amdgpu/atom.c
@@ -31,6 +31,7 @@
  
  #define ATOM_DEBUG
  
+#include "atomfirmware.h"

  #include "atom.h"
  #include "atom-names.h"
  #include "atom-bits.h"
@@ -1299,12 +1300,168 @@ static void atom_index_iio(struct atom_context *ctx, 
int base)
}
  }
  
+static void atom_get_vbios_name(struct atom_context *ctx) {

+   unsigned char *p_rom;
+   unsigned char str_num;
+   unsigned short off_to_vbios_str;
+   unsigned char *c_ptr;
+   int name_size;
+   int i;
+
+   const char *na = "--N/A--";
+   char 

RE: [PATCH] drm/amdgpu: Add vbios info ioctl interface

2021-05-17 Thread Gu, JiaWei (Will)
[AMD Official Use Only - Internal Distribution Only]

Hi all,

Thanks Christian's suggestion.
I reverted the previous patches and squash them into this single one.

As this patch shows, the current uapi change looks like this:

+struct drm_amdgpu_info_vbios {
+   __u8 name[64];
+   __u32 dbdf;
+   __u8 vbios_pn[64];
+   __u32 version;
+   __u8 vbios_ver_str[32];
+   __u8 date[32];
+   __u64 serial;
+   __u32 dev_id;
+   __u32 rev_id;
+   __u32 sub_dev_id;
+   __u32 sub_ved_id;
+};

As we know there's some redundant info in this struct.
Please feel free to give any comments or suggestion about what it should & 
shouldn't include.

Best regards,
Jiawei

-Original Message-
From: Jiawei Gu  
Sent: Monday, May 17, 2021 8:08 PM
To: amd-gfx@lists.freedesktop.org; Koenig, Christian 
; Nieto, David M ; 
mar...@gmail.com; Deucher, Alexander 
Cc: Deng, Emily ; Gu, JiaWei (Will) 
Subject: [PATCH] drm/amdgpu: Add vbios info ioctl interface

Add AMDGPU_INFO_VBIOS_INFO subquery id for detailed vbios info.

Provides a way for the user application to get the VBIOS information without 
having to parse the binary.
It is useful for the user to be able to display in a simple way the VBIOS 
version in their system if they happen to encounter an issue.

V2:
Use numeric serial.
Parse and expose vbios version string.

Signed-off-by: Jiawei Gu 
Acked-by: Christian König 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c|  21 +++
 drivers/gpu/drm/amd/amdgpu/atom.c  | 174 +
 drivers/gpu/drm/amd/amdgpu/atom.h  |  12 ++
 drivers/gpu/drm/amd/include/atomfirmware.h |   5 +
 include/uapi/drm/amdgpu_drm.h  |  16 ++
 5 files changed, 228 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
index 8d12e474745a..30e4fed3de22 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
@@ -861,6 +861,27 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, 
struct drm_file *filp)
min((size_t)size, 
(size_t)(bios_size - bios_offset)))
? -EFAULT : 0;
}
+   case AMDGPU_INFO_VBIOS_INFO: {
+   struct drm_amdgpu_info_vbios vbios_info = {};
+   struct atom_context *atom_context;
+
+   atom_context = adev->mode_info.atom_context;
+   memcpy(vbios_info.name, atom_context->name, 
sizeof(atom_context->name));
+   vbios_info.dbdf = PCI_DEVID(adev->pdev->bus->number, 
adev->pdev->devfn);
+   memcpy(vbios_info.vbios_pn, atom_context->vbios_pn, 
sizeof(atom_context->vbios_pn));
+   vbios_info.version = atom_context->version;
+   memcpy(vbios_info.vbios_ver_str, 
atom_context->vbios_ver_str,
+   
sizeof(atom_context->vbios_ver_str));
+   memcpy(vbios_info.date, atom_context->date, 
sizeof(atom_context->date));
+   vbios_info.serial = adev->unique_id;
+   vbios_info.dev_id = adev->pdev->device;
+   vbios_info.rev_id = adev->pdev->revision;
+   vbios_info.sub_dev_id = atom_context->sub_dev_id;
+   vbios_info.sub_ved_id = atom_context->sub_ved_id;
+
+   return copy_to_user(out, _info,
+   min((size_t)size, 
sizeof(vbios_info))) ? -EFAULT : 0;
+   }
default:
DRM_DEBUG_KMS("Invalid request %d\n",
info->vbios_info.type);
diff --git a/drivers/gpu/drm/amd/amdgpu/atom.c 
b/drivers/gpu/drm/amd/amdgpu/atom.c
index 3dcb8b32f48b..542b2c2414e4 100644
--- a/drivers/gpu/drm/amd/amdgpu/atom.c
+++ b/drivers/gpu/drm/amd/amdgpu/atom.c
@@ -31,6 +31,7 @@
 
 #define ATOM_DEBUG
 
+#include "atomfirmware.h"
 #include "atom.h"
 #include "atom-names.h"
 #include "atom-bits.h"
@@ -1299,12 +1300,168 @@ static void atom_index_iio(struct atom_context *ctx, 
int base)
}
 }
 
+static void atom_get_vbios_name(struct atom_context *ctx) {
+   unsigned char *p_rom;
+   unsigned char str_num;
+   unsigned short off_to_vbios_str;
+   unsigned char *c_ptr;
+   int name_size;
+   int i;
+
+   const char *na = "--N/A--";
+   char *back;
+
+   p_rom = ctx->bios;
+
+   str_num = *(p_rom + OFFSET_TO_GET_ATOMBIOS_NUMBER_OF_STRINGS);
+   if (str_num != 0) {
+   off_to_vbios_str =
+   *(unsigned short *)(p_rom + 
OFFSET_TO_GET_ATOMBIOS_STRING_START);
+
+   c_ptr = (unsigned char *)(

[PATCH] drm/amdgpu: Add vbios info ioctl interface

2021-05-17 Thread Jiawei Gu
Add AMDGPU_INFO_VBIOS_INFO subquery id for detailed vbios info.

Provides a way for the user application to get the VBIOS
information without having to parse the binary.
It is useful for the user to be able to display in a simple way the VBIOS
version in their system if they happen to encounter an issue.

V2:
Use numeric serial.
Parse and expose vbios version string.

Signed-off-by: Jiawei Gu 
Acked-by: Christian König 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c|  21 +++
 drivers/gpu/drm/amd/amdgpu/atom.c  | 174 +
 drivers/gpu/drm/amd/amdgpu/atom.h  |  12 ++
 drivers/gpu/drm/amd/include/atomfirmware.h |   5 +
 include/uapi/drm/amdgpu_drm.h  |  16 ++
 5 files changed, 228 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
index 8d12e474745a..30e4fed3de22 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
@@ -861,6 +861,27 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, 
struct drm_file *filp)
min((size_t)size, 
(size_t)(bios_size - bios_offset)))
? -EFAULT : 0;
}
+   case AMDGPU_INFO_VBIOS_INFO: {
+   struct drm_amdgpu_info_vbios vbios_info = {};
+   struct atom_context *atom_context;
+
+   atom_context = adev->mode_info.atom_context;
+   memcpy(vbios_info.name, atom_context->name, 
sizeof(atom_context->name));
+   vbios_info.dbdf = PCI_DEVID(adev->pdev->bus->number, 
adev->pdev->devfn);
+   memcpy(vbios_info.vbios_pn, atom_context->vbios_pn, 
sizeof(atom_context->vbios_pn));
+   vbios_info.version = atom_context->version;
+   memcpy(vbios_info.vbios_ver_str, 
atom_context->vbios_ver_str,
+   
sizeof(atom_context->vbios_ver_str));
+   memcpy(vbios_info.date, atom_context->date, 
sizeof(atom_context->date));
+   vbios_info.serial = adev->unique_id;
+   vbios_info.dev_id = adev->pdev->device;
+   vbios_info.rev_id = adev->pdev->revision;
+   vbios_info.sub_dev_id = atom_context->sub_dev_id;
+   vbios_info.sub_ved_id = atom_context->sub_ved_id;
+
+   return copy_to_user(out, _info,
+   min((size_t)size, 
sizeof(vbios_info))) ? -EFAULT : 0;
+   }
default:
DRM_DEBUG_KMS("Invalid request %d\n",
info->vbios_info.type);
diff --git a/drivers/gpu/drm/amd/amdgpu/atom.c 
b/drivers/gpu/drm/amd/amdgpu/atom.c
index 3dcb8b32f48b..542b2c2414e4 100644
--- a/drivers/gpu/drm/amd/amdgpu/atom.c
+++ b/drivers/gpu/drm/amd/amdgpu/atom.c
@@ -31,6 +31,7 @@
 
 #define ATOM_DEBUG
 
+#include "atomfirmware.h"
 #include "atom.h"
 #include "atom-names.h"
 #include "atom-bits.h"
@@ -1299,12 +1300,168 @@ static void atom_index_iio(struct atom_context *ctx, 
int base)
}
 }
 
+static void atom_get_vbios_name(struct atom_context *ctx)
+{
+   unsigned char *p_rom;
+   unsigned char str_num;
+   unsigned short off_to_vbios_str;
+   unsigned char *c_ptr;
+   int name_size;
+   int i;
+
+   const char *na = "--N/A--";
+   char *back;
+
+   p_rom = ctx->bios;
+
+   str_num = *(p_rom + OFFSET_TO_GET_ATOMBIOS_NUMBER_OF_STRINGS);
+   if (str_num != 0) {
+   off_to_vbios_str =
+   *(unsigned short *)(p_rom + 
OFFSET_TO_GET_ATOMBIOS_STRING_START);
+
+   c_ptr = (unsigned char *)(p_rom + off_to_vbios_str);
+   } else {
+   /* do not know where to find name */
+   memcpy(ctx->name, na, 7);
+   ctx->name[7] = 0;
+   return;
+   }
+
+   /*
+* skip the atombios strings, usually 4
+* 1st is P/N, 2nd is ASIC, 3rd is PCI type, 4th is Memory type
+*/
+   for (i = 0; i < str_num; i++) {
+   while (*c_ptr != 0)
+   c_ptr++;
+   c_ptr++;
+   }
+
+   /* skip the following 2 chars: 0x0D 0x0A */
+   c_ptr += 2;
+
+   name_size = strnlen(c_ptr, STRLEN_LONG - 1);
+   memcpy(ctx->name, c_ptr, name_size);
+   back = ctx->name + name_size;
+   while ((*--back) == ' ')
+   ;
+   *(back + 1) = '\0';
+}
+
+static void atom_get_vbios_date(struct atom_context *ctx)
+{
+   unsigned char *p_rom;
+   unsigned char *date_in_rom;
+
+   p_rom = ctx->bios;
+
+   date_in_rom = p_rom + OFFSET_TO_VBIOS_DATE;
+
+   ctx->date[0] = '2';
+   ctx->date[1] = '0';
+   ctx->date[2] = date_in_rom[6];
+   ctx->date[3] = date_in_rom[7];
+   

Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

2021-05-09 Thread Kees Cook
Hi!

This patch needs some fixing.

On Thu, Apr 22, 2021 at 10:34:48AM +0800, Jiawei Gu wrote:
> + case AMDGPU_INFO_VBIOS_INFO: {
> + struct drm_amdgpu_info_vbios vbios_info = {};
> + struct atom_context *atom_context;
> +
> + atom_context = adev->mode_info.atom_context;
> + memcpy(vbios_info.name, atom_context->name, 
> sizeof(atom_context->name));
> + vbios_info.dbdf = PCI_DEVID(adev->pdev->bus->number, 
> adev->pdev->devfn);
> + memcpy(vbios_info.vbios_pn, atom_context->vbios_pn, 
> sizeof(atom_context->vbios_pn));
> + vbios_info.version = atom_context->version;
> + memcpy(vbios_info.date, atom_context->date, 
> sizeof(atom_context->date));
> + memcpy(vbios_info.serial, adev->serial, 
> sizeof(adev->serial));

This writes beyond the end of vbios_info.serial.

> + vbios_info.dev_id = adev->pdev->device;
> + vbios_info.rev_id = adev->pdev->revision;
> + vbios_info.sub_dev_id = atom_context->sub_dev_id;
> + vbios_info.sub_ved_id = atom_context->sub_ved_id;

Though it gets "repaired" by these writes.

> +
> + return copy_to_user(out, _info,
> + min((size_t)size, 
> sizeof(vbios_info))) ? -EFAULT : 0;
> + }

sizeof(adev->serial) != sizeof(vbios_info.serial)

adev is struct amdgpu_device:

struct amdgpu_device {
...
charserial[20];


> +struct drm_amdgpu_info_vbios {
> [...]
> + __u8 serial[16];
> + __u32 dev_id;
> + __u32 rev_id;
> + __u32 sub_dev_id;
> + __u32 sub_ved_id;
> +};

Is there a truncation issue (20 vs 16) and is this intended to be a
NUL-terminated string?

-- 
Kees Cook
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

2021-05-09 Thread Kees Cook
On Sat, May 08, 2021 at 06:01:23AM +, Gu, JiaWei (Will) wrote:
> [AMD Official Use Only - Internal Distribution Only]
> 
> Thanks for this catching Kees.
> 
> Yes it should be 20, not 16. I was not aware that serial size had been 
> changed from 16 to 20 in struct amdgpu_device.
> Will submit a fix soon.

You might want to add a BUILD_BUG_ON() to keep those in sync, especially
since it's about to be UAPI.

-Kees

> 
> Best regards,
> Jiawei
> 
> 
> -Original Message-
> From: Kees Cook  
> Sent: Saturday, May 8, 2021 12:28 PM
> To: Gu, JiaWei (Will) ; Deucher, Alexander 
> 
> Cc: StDenis, Tom ; Deucher, Alexander 
> ; Christian König 
> ; Gu, JiaWei (Will) ; 
> amd-gfx@lists.freedesktop.org; Nieto, David M ; 
> linux-n...@vger.kernel.org
> Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface
> 
> Hi!
> 
> This patch needs some fixing.
> 
> On Thu, Apr 22, 2021 at 10:34:48AM +0800, Jiawei Gu wrote:
> > +   case AMDGPU_INFO_VBIOS_INFO: {
> > +   struct drm_amdgpu_info_vbios vbios_info = {};
> > +   struct atom_context *atom_context;
> > +
> > +   atom_context = adev->mode_info.atom_context;
> > +   memcpy(vbios_info.name, atom_context->name, 
> > sizeof(atom_context->name));
> > +   vbios_info.dbdf = PCI_DEVID(adev->pdev->bus->number, 
> > adev->pdev->devfn);
> > +   memcpy(vbios_info.vbios_pn, atom_context->vbios_pn, 
> > sizeof(atom_context->vbios_pn));
> > +   vbios_info.version = atom_context->version;
> > +   memcpy(vbios_info.date, atom_context->date, 
> > sizeof(atom_context->date));
> > +   memcpy(vbios_info.serial, adev->serial, 
> > sizeof(adev->serial));
> 
> This writes beyond the end of vbios_info.serial.
> 
> > +   vbios_info.dev_id = adev->pdev->device;
> > +   vbios_info.rev_id = adev->pdev->revision;
> > +   vbios_info.sub_dev_id = atom_context->sub_dev_id;
> > +   vbios_info.sub_ved_id = atom_context->sub_ved_id;
> 
> Though it gets "repaired" by these writes.
> 
> > +
> > +   return copy_to_user(out, _info,
> > +   min((size_t)size, 
> > sizeof(vbios_info))) ? -EFAULT : 0;
> > +   }
> 
> sizeof(adev->serial) != sizeof(vbios_info.serial)
> 
> adev is struct amdgpu_device:
> 
> struct amdgpu_device {
> ...
> charserial[20];
> 
> 
> > +struct drm_amdgpu_info_vbios {
> > [...]
> > +   __u8 serial[16];
> > +   __u32 dev_id;
> > +   __u32 rev_id;
> > +   __u32 sub_dev_id;
> > +   __u32 sub_ved_id;
> > +};
> 
> Is there a truncation issue (20 vs 16) and is this intended to be a 
> NUL-terminated string?
> 
> --
> Kees Cook

-- 
Kees Cook
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

2021-05-08 Thread Nieto, David M
[AMD Public Use]

The full vbios versioning information consists of the version (numeric), build 
date and the name... I this this interface exposes only the name.

Should we expose those on different sysfs files or just combine all of them in 
a single file?

David

From: Kees Cook 
Sent: Saturday, May 8, 2021 2:51 AM
To: Gu, JiaWei (Will) 
Cc: Deucher, Alexander ; StDenis, Tom 
; Christian König ; 
amd-gfx@lists.freedesktop.org ; Nieto, David M 
; linux-n...@vger.kernel.org 
Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

On Sat, May 08, 2021 at 06:01:23AM +, Gu, JiaWei (Will) wrote:
> [AMD Official Use Only - Internal Distribution Only]
>
> Thanks for this catching Kees.
>
> Yes it should be 20, not 16. I was not aware that serial size had been 
> changed from 16 to 20 in struct amdgpu_device.
> Will submit a fix soon.

You might want to add a BUILD_BUG_ON() to keep those in sync, especially
since it's about to be UAPI.

-Kees

>
> Best regards,
> Jiawei
>
>
> -Original Message-
> From: Kees Cook 
> Sent: Saturday, May 8, 2021 12:28 PM
> To: Gu, JiaWei (Will) ; Deucher, Alexander 
> 
> Cc: StDenis, Tom ; Deucher, Alexander 
> ; Christian König 
> ; Gu, JiaWei (Will) ; 
> amd-gfx@lists.freedesktop.org; Nieto, David M ; 
> linux-n...@vger.kernel.org
> Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface
>
> Hi!
>
> This patch needs some fixing.
>
> On Thu, Apr 22, 2021 at 10:34:48AM +0800, Jiawei Gu wrote:
> > +   case AMDGPU_INFO_VBIOS_INFO: {
> > +   struct drm_amdgpu_info_vbios vbios_info = {};
> > +   struct atom_context *atom_context;
> > +
> > +   atom_context = adev->mode_info.atom_context;
> > +   memcpy(vbios_info.name, atom_context->name, 
> > sizeof(atom_context->name));
> > +   vbios_info.dbdf = PCI_DEVID(adev->pdev->bus->number, 
> > adev->pdev->devfn);
> > +   memcpy(vbios_info.vbios_pn, atom_context->vbios_pn, 
> > sizeof(atom_context->vbios_pn));
> > +   vbios_info.version = atom_context->version;
> > +   memcpy(vbios_info.date, atom_context->date, 
> > sizeof(atom_context->date));
> > +   memcpy(vbios_info.serial, adev->serial, 
> > sizeof(adev->serial));
>
> This writes beyond the end of vbios_info.serial.
>
> > +   vbios_info.dev_id = adev->pdev->device;
> > +   vbios_info.rev_id = adev->pdev->revision;
> > +   vbios_info.sub_dev_id = atom_context->sub_dev_id;
> > +   vbios_info.sub_ved_id = atom_context->sub_ved_id;
>
> Though it gets "repaired" by these writes.
>
> > +
> > +   return copy_to_user(out, _info,
> > +   min((size_t)size, 
> > sizeof(vbios_info))) ? -EFAULT : 0;
> > +   }
>
> sizeof(adev->serial) != sizeof(vbios_info.serial)
>
> adev is struct amdgpu_device:
>
> struct amdgpu_device {
> ...
> charserial[20];
>
>
> > +struct drm_amdgpu_info_vbios {
> > [...]
> > +   __u8 serial[16];
> > +   __u32 dev_id;
> > +   __u32 rev_id;
> > +   __u32 sub_dev_id;
> > +   __u32 sub_ved_id;
> > +};
>
> Is there a truncation issue (20 vs 16) and is this intended to be a 
> NUL-terminated string?
>
> --
> Kees Cook

--
Kees Cook
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


RE: [PATCH] drm/amdgpu: Add vbios info ioctl interface

2021-05-08 Thread Gu, JiaWei (Will)
[AMD Official Use Only - Internal Distribution Only]

Thanks for this catching Kees.

Yes it should be 20, not 16. I was not aware that serial size had been changed 
from 16 to 20 in struct amdgpu_device.
Will submit a fix soon.

Best regards,
Jiawei


-Original Message-
From: Kees Cook  
Sent: Saturday, May 8, 2021 12:28 PM
To: Gu, JiaWei (Will) ; Deucher, Alexander 

Cc: StDenis, Tom ; Deucher, Alexander 
; Christian König 
; Gu, JiaWei (Will) ; 
amd-gfx@lists.freedesktop.org; Nieto, David M ; 
linux-n...@vger.kernel.org
Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

Hi!

This patch needs some fixing.

On Thu, Apr 22, 2021 at 10:34:48AM +0800, Jiawei Gu wrote:
> + case AMDGPU_INFO_VBIOS_INFO: {
> + struct drm_amdgpu_info_vbios vbios_info = {};
> + struct atom_context *atom_context;
> +
> + atom_context = adev->mode_info.atom_context;
> + memcpy(vbios_info.name, atom_context->name, 
> sizeof(atom_context->name));
> + vbios_info.dbdf = PCI_DEVID(adev->pdev->bus->number, 
> adev->pdev->devfn);
> + memcpy(vbios_info.vbios_pn, atom_context->vbios_pn, 
> sizeof(atom_context->vbios_pn));
> + vbios_info.version = atom_context->version;
> + memcpy(vbios_info.date, atom_context->date, 
> sizeof(atom_context->date));
> + memcpy(vbios_info.serial, adev->serial, 
> sizeof(adev->serial));

This writes beyond the end of vbios_info.serial.

> + vbios_info.dev_id = adev->pdev->device;
> + vbios_info.rev_id = adev->pdev->revision;
> + vbios_info.sub_dev_id = atom_context->sub_dev_id;
> + vbios_info.sub_ved_id = atom_context->sub_ved_id;

Though it gets "repaired" by these writes.

> +
> + return copy_to_user(out, _info,
> + min((size_t)size, 
> sizeof(vbios_info))) ? -EFAULT : 0;
> + }

sizeof(adev->serial) != sizeof(vbios_info.serial)

adev is struct amdgpu_device:

struct amdgpu_device {
...
charserial[20];


> +struct drm_amdgpu_info_vbios {
> [...]
> + __u8 serial[16];
> + __u32 dev_id;
> + __u32 rev_id;
> + __u32 sub_dev_id;
> + __u32 sub_ved_id;
> +};

Is there a truncation issue (20 vs 16) and is this intended to be a 
NUL-terminated string?

--
Kees Cook
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

2021-04-28 Thread StDenis, Tom
[AMD Official Use Only - Internal Distribution Only]

Done.


From: Alex Deucher 
Sent: Wednesday, April 28, 2021 16:53
To: StDenis, Tom
Cc: Gu, JiaWei (Will); Christian König; Nieto, David M; 
amd-gfx@lists.freedesktop.org; Deucher, Alexander
Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

Please revert the patch in umr until the kernel side lands in upstream drm-next.

Alex

On Wed, Apr 28, 2021 at 7:30 AM StDenis, Tom  wrote:
>
> [AMD Official Use Only - Internal Distribution Only]
>
> Hi Will,
>
> I've merged in your v2 patch last week.  If that's still the latest you 
> should be good to go.
>
> Tom
>
> 
> From: Gu, JiaWei (Will) 
> Sent: Wednesday, April 28, 2021 06:38
> To: Christian König; Nieto, David M; amd-gfx@lists.freedesktop.org; StDenis, 
> Tom
> Cc: Deucher, Alexander
> Subject: RE: [PATCH] drm/amdgpu: Add vbios info ioctl interface
>
> [AMD Official Use Only - Internal Distribution Only]
>
> Hi @StDenis, Tom<mailto:tom.stde...@amd.com>,
>
> We have merged vbios info ioctl patch.
> Could you help re-merge the UMR side one again if it was reverted before?
>
> Thanks in advance!
> Jiawei
>
> From: Gu, JiaWei (Will)
> Sent: Wednesday, April 28, 2021 4:21 PM
> To: Christian König ; Nieto, David M 
> ; amd-gfx@lists.freedesktop.org
> Cc: Deucher, Alexander ; StDenis, Tom 
> 
> Subject: RE: [PATCH] drm/amdgpu: Add vbios info ioctl interface
>
>
> [AMD Official Use Only - Internal Distribution Only]
>
> Thanks Christian,
>
> I amended the commit message and resend the patch out.
> Please feel free to let me know if message is not clear enough.
>
> Best regards,
> Jiawei
>
> From: Christian König 
> mailto:ckoenig.leichtzumer...@gmail.com>>
> Sent: Wednesday, April 28, 2021 3:43 PM
> To: Nieto, David M mailto:david.ni...@amd.com>>; Gu, 
> JiaWei (Will) mailto:jiawei...@amd.com>>; 
> amd-gfx@lists.freedesktop.org<mailto:amd-gfx@lists.freedesktop.org>
> Cc: Deucher, Alexander 
> mailto:alexander.deuc...@amd.com>>; StDenis, Tom 
> mailto:tom.stde...@amd.com>>
> Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface
>
> Yeah, makes sense. Please note that in the commit message.
>
> With that feel free to put an Acked-by: Christian König 
> <mailto:christian.koe...@amd.com> on it.
>
> Regards,
> Christian.
> Am 28.04.21 um 09:25 schrieb Nieto, David M:
> I think this change may be orthogonal to that. Here we want to provide a way 
> for the user application to get the VBIOS information without having to parse 
> the binary…
>
> And I agree that we should not have strong dependencies unless the encounter 
> buggy VBIOS on the field, but I still think it is useful for the user to be 
> able to display in a simple way the VBIOS version in their system if they 
> happen to encounter an issue.
>
> Regards,
> David
>
> From: Christian König 
> <mailto:ckoenig.leichtzumer...@gmail.com>
> Date: Wednesday, April 28, 2021 at 12:15 AM
> To: "Nieto, David M" <mailto:david.ni...@amd.com>, "Gu, 
> JiaWei (Will)" <mailto:jiawei...@amd.com>, 
> "amd-gfx@lists.freedesktop.org"<mailto:amd-gfx@lists.freedesktop.org> 
> <mailto:amd-gfx@lists.freedesktop.org>
> Cc: "Deucher, Alexander" 
> <mailto:alexander.deuc...@amd.com>, "StDenis, Tom" 
> <mailto:tom.stde...@amd.com>
> Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface
>
> Well displaying the VBIOS information along with the other firmware in 
> userspace is certainly useful.
>
> We should just avoid making strong dependencies on that.
>
> Firmware and VBIOS must always be backward compatible and the driver must 
> always work with any released firmware and VBIOS combination.
>
> What we can do is to display a warning when we detect and/or old/buggy 
> firmware.
>
> Regards,
> Christian.
> Am 28.04.21 um 08:47 schrieb Nieto, David M:
> Besides system management, it provides parseable details on the VBIOS version 
> and information. This is useful renderer information as the GPU behavior 
> depends not only on the driver version but also on the firmwares running on 
> the GPU.
>
> The AMDGPU_INFO ioctl contains a method to get the versions of the ucode for 
> all the IPs, but for VBIOS, only a way to dump the entire image is provided. 
> While it Is possible to implement the whole logic of VBIOS parsing on 
> userspace, it requires the application to have details on the header and 
> table formats to parse the data. Moreover there is no guarantee that the 
> format and header 

Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

2021-04-28 Thread Alex Deucher
Please revert the patch in umr until the kernel side lands in upstream drm-next.

Alex

On Wed, Apr 28, 2021 at 7:30 AM StDenis, Tom  wrote:
>
> [AMD Official Use Only - Internal Distribution Only]
>
> Hi Will,
>
> I've merged in your v2 patch last week.  If that's still the latest you 
> should be good to go.
>
> Tom
>
> 
> From: Gu, JiaWei (Will) 
> Sent: Wednesday, April 28, 2021 06:38
> To: Christian König; Nieto, David M; amd-gfx@lists.freedesktop.org; StDenis, 
> Tom
> Cc: Deucher, Alexander
> Subject: RE: [PATCH] drm/amdgpu: Add vbios info ioctl interface
>
> [AMD Official Use Only - Internal Distribution Only]
>
> Hi @StDenis, Tom<mailto:tom.stde...@amd.com>,
>
> We have merged vbios info ioctl patch.
> Could you help re-merge the UMR side one again if it was reverted before?
>
> Thanks in advance!
> Jiawei
>
> From: Gu, JiaWei (Will)
> Sent: Wednesday, April 28, 2021 4:21 PM
> To: Christian König ; Nieto, David M 
> ; amd-gfx@lists.freedesktop.org
> Cc: Deucher, Alexander ; StDenis, Tom 
> 
> Subject: RE: [PATCH] drm/amdgpu: Add vbios info ioctl interface
>
>
> [AMD Official Use Only - Internal Distribution Only]
>
> Thanks Christian,
>
> I amended the commit message and resend the patch out.
> Please feel free to let me know if message is not clear enough.
>
> Best regards,
> Jiawei
>
> From: Christian König 
> mailto:ckoenig.leichtzumer...@gmail.com>>
> Sent: Wednesday, April 28, 2021 3:43 PM
> To: Nieto, David M mailto:david.ni...@amd.com>>; Gu, 
> JiaWei (Will) mailto:jiawei...@amd.com>>; 
> amd-gfx@lists.freedesktop.org<mailto:amd-gfx@lists.freedesktop.org>
> Cc: Deucher, Alexander 
> mailto:alexander.deuc...@amd.com>>; StDenis, Tom 
> mailto:tom.stde...@amd.com>>
> Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface
>
> Yeah, makes sense. Please note that in the commit message.
>
> With that feel free to put an Acked-by: Christian König 
> <mailto:christian.koe...@amd.com> on it.
>
> Regards,
> Christian.
> Am 28.04.21 um 09:25 schrieb Nieto, David M:
> I think this change may be orthogonal to that. Here we want to provide a way 
> for the user application to get the VBIOS information without having to parse 
> the binary…
>
> And I agree that we should not have strong dependencies unless the encounter 
> buggy VBIOS on the field, but I still think it is useful for the user to be 
> able to display in a simple way the VBIOS version in their system if they 
> happen to encounter an issue.
>
> Regards,
> David
>
> From: Christian König 
> <mailto:ckoenig.leichtzumer...@gmail.com>
> Date: Wednesday, April 28, 2021 at 12:15 AM
> To: "Nieto, David M" <mailto:david.ni...@amd.com>, "Gu, 
> JiaWei (Will)" <mailto:jiawei...@amd.com>, 
> "amd-gfx@lists.freedesktop.org"<mailto:amd-gfx@lists.freedesktop.org> 
> <mailto:amd-gfx@lists.freedesktop.org>
> Cc: "Deucher, Alexander" 
> <mailto:alexander.deuc...@amd.com>, "StDenis, Tom" 
> <mailto:tom.stde...@amd.com>
> Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface
>
> Well displaying the VBIOS information along with the other firmware in 
> userspace is certainly useful.
>
> We should just avoid making strong dependencies on that.
>
> Firmware and VBIOS must always be backward compatible and the driver must 
> always work with any released firmware and VBIOS combination.
>
> What we can do is to display a warning when we detect and/or old/buggy 
> firmware.
>
> Regards,
> Christian.
> Am 28.04.21 um 08:47 schrieb Nieto, David M:
> Besides system management, it provides parseable details on the VBIOS version 
> and information. This is useful renderer information as the GPU behavior 
> depends not only on the driver version but also on the firmwares running on 
> the GPU.
>
> The AMDGPU_INFO ioctl contains a method to get the versions of the ucode for 
> all the IPs, but for VBIOS, only a way to dump the entire image is provided. 
> While it Is possible to implement the whole logic of VBIOS parsing on 
> userspace, it requires the application to have details on the header and 
> table formats to parse the data. Moreover there is no guarantee that the 
> format and header locations will remain constant across ASIC generations, so 
> the maintainance cost and complexity seems unreasonable.
>
> Providing a simple, and stable interface to the application seems to us like 
> a sensible choice.
>
> Thanks,
> David
>
> From: amd-gfx 
> <mailto:amd-gfx-boun...@lists.freedesktop.org>

Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

2021-04-28 Thread StDenis, Tom
[AMD Official Use Only - Internal Distribution Only]

Hi Will,

I've merged in your v2 patch last week.  If that's still the latest you should 
be good to go.

Tom


From: Gu, JiaWei (Will) 
Sent: Wednesday, April 28, 2021 06:38
To: Christian König; Nieto, David M; amd-gfx@lists.freedesktop.org; StDenis, Tom
Cc: Deucher, Alexander
Subject: RE: [PATCH] drm/amdgpu: Add vbios info ioctl interface

[AMD Official Use Only - Internal Distribution Only]

Hi @StDenis, Tom<mailto:tom.stde...@amd.com>,

We have merged vbios info ioctl patch.
Could you help re-merge the UMR side one again if it was reverted before?

Thanks in advance!
Jiawei

From: Gu, JiaWei (Will)
Sent: Wednesday, April 28, 2021 4:21 PM
To: Christian König ; Nieto, David M 
; amd-gfx@lists.freedesktop.org
Cc: Deucher, Alexander ; StDenis, Tom 

Subject: RE: [PATCH] drm/amdgpu: Add vbios info ioctl interface


[AMD Official Use Only - Internal Distribution Only]

Thanks Christian,

I amended the commit message and resend the patch out.
Please feel free to let me know if message is not clear enough.

Best regards,
Jiawei

From: Christian König 
mailto:ckoenig.leichtzumer...@gmail.com>>
Sent: Wednesday, April 28, 2021 3:43 PM
To: Nieto, David M mailto:david.ni...@amd.com>>; Gu, 
JiaWei (Will) mailto:jiawei...@amd.com>>; 
amd-gfx@lists.freedesktop.org<mailto:amd-gfx@lists.freedesktop.org>
Cc: Deucher, Alexander 
mailto:alexander.deuc...@amd.com>>; StDenis, Tom 
mailto:tom.stde...@amd.com>>
Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

Yeah, makes sense. Please note that in the commit message.

With that feel free to put an Acked-by: Christian König 
<mailto:christian.koe...@amd.com> on it.

Regards,
Christian.
Am 28.04.21 um 09:25 schrieb Nieto, David M:
I think this change may be orthogonal to that. Here we want to provide a way 
for the user application to get the VBIOS information without having to parse 
the binary…

And I agree that we should not have strong dependencies unless the encounter 
buggy VBIOS on the field, but I still think it is useful for the user to be 
able to display in a simple way the VBIOS version in their system if they 
happen to encounter an issue.

Regards,
David

From: Christian König 
<mailto:ckoenig.leichtzumer...@gmail.com>
Date: Wednesday, April 28, 2021 at 12:15 AM
To: "Nieto, David M" <mailto:david.ni...@amd.com>, "Gu, 
JiaWei (Will)" <mailto:jiawei...@amd.com>, 
"amd-gfx@lists.freedesktop.org"<mailto:amd-gfx@lists.freedesktop.org> 
<mailto:amd-gfx@lists.freedesktop.org>
Cc: "Deucher, Alexander" 
<mailto:alexander.deuc...@amd.com>, "StDenis, Tom" 
<mailto:tom.stde...@amd.com>
Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

Well displaying the VBIOS information along with the other firmware in 
userspace is certainly useful.

We should just avoid making strong dependencies on that.

Firmware and VBIOS must always be backward compatible and the driver must 
always work with any released firmware and VBIOS combination.

What we can do is to display a warning when we detect and/or old/buggy firmware.

Regards,
Christian.
Am 28.04.21 um 08:47 schrieb Nieto, David M:
Besides system management, it provides parseable details on the VBIOS version 
and information. This is useful renderer information as the GPU behavior 
depends not only on the driver version but also on the firmwares running on the 
GPU.

The AMDGPU_INFO ioctl contains a method to get the versions of the ucode for 
all the IPs, but for VBIOS, only a way to dump the entire image is provided. 
While it Is possible to implement the whole logic of VBIOS parsing on 
userspace, it requires the application to have details on the header and table 
formats to parse the data. Moreover there is no guarantee that the format and 
header locations will remain constant across ASIC generations, so the 
maintainance cost and complexity seems unreasonable.

Providing a simple, and stable interface to the application seems to us like a 
sensible choice.

Thanks,
David

From: amd-gfx 
<mailto:amd-gfx-boun...@lists.freedesktop.org>
 on behalf of "Gu, JiaWei (Will)" <mailto:jiawei...@amd.com>
Date: Thursday, April 22, 2021 at 8:25 PM
To: Christian König 
<mailto:ckoenig.leichtzumer...@gmail.com>, 
"amd-gfx@lists.freedesktop.org"<mailto:amd-gfx@lists.freedesktop.org> 
<mailto:amd-gfx@lists.freedesktop.org>
Cc: "Deucher, Alexander" 
<mailto:alexander.deuc...@amd.com>, "StDenis, Tom" 
<mailto:tom.stde...@amd.com>, "Nieto, David M" 
<mailto:david.ni...@amd.com>
Subject: RE: [PATCH] drm/amdgpu: Add vbios info ioctl interface


[AMD Official Use Only - Internal Distribution Only]

Hi Christian,
It will be used by a user space SMI-lib for GPU status query.


RE: [PATCH] drm/amdgpu: Add vbios info ioctl interface

2021-04-28 Thread Gu, JiaWei (Will)
[AMD Official Use Only - Internal Distribution Only]

Hi @StDenis, Tom<mailto:tom.stde...@amd.com>,

We have merged vbios info ioctl patch.
Could you help re-merge the UMR side one again if it was reverted before?

Thanks in advance!
Jiawei

From: Gu, JiaWei (Will)
Sent: Wednesday, April 28, 2021 4:21 PM
To: Christian König ; Nieto, David M 
; amd-gfx@lists.freedesktop.org
Cc: Deucher, Alexander ; StDenis, Tom 

Subject: RE: [PATCH] drm/amdgpu: Add vbios info ioctl interface


[AMD Official Use Only - Internal Distribution Only]

Thanks Christian,

I amended the commit message and resend the patch out.
Please feel free to let me know if message is not clear enough.

Best regards,
Jiawei

From: Christian König 
mailto:ckoenig.leichtzumer...@gmail.com>>
Sent: Wednesday, April 28, 2021 3:43 PM
To: Nieto, David M mailto:david.ni...@amd.com>>; Gu, 
JiaWei (Will) mailto:jiawei...@amd.com>>; 
amd-gfx@lists.freedesktop.org<mailto:amd-gfx@lists.freedesktop.org>
Cc: Deucher, Alexander 
mailto:alexander.deuc...@amd.com>>; StDenis, Tom 
mailto:tom.stde...@amd.com>>
Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

Yeah, makes sense. Please note that in the commit message.

With that feel free to put an Acked-by: Christian König 
<mailto:christian.koe...@amd.com> on it.

Regards,
Christian.
Am 28.04.21 um 09:25 schrieb Nieto, David M:
I think this change may be orthogonal to that. Here we want to provide a way 
for the user application to get the VBIOS information without having to parse 
the binary...

And I agree that we should not have strong dependencies unless the encounter 
buggy VBIOS on the field, but I still think it is useful for the user to be 
able to display in a simple way the VBIOS version in their system if they 
happen to encounter an issue.

Regards,
David

From: Christian König 
<mailto:ckoenig.leichtzumer...@gmail.com>
Date: Wednesday, April 28, 2021 at 12:15 AM
To: "Nieto, David M" <mailto:david.ni...@amd.com>, "Gu, 
JiaWei (Will)" <mailto:jiawei...@amd.com>, 
"amd-gfx@lists.freedesktop.org"<mailto:amd-gfx@lists.freedesktop.org> 
<mailto:amd-gfx@lists.freedesktop.org>
Cc: "Deucher, Alexander" 
<mailto:alexander.deuc...@amd.com>, "StDenis, Tom" 
<mailto:tom.stde...@amd.com>
Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

Well displaying the VBIOS information along with the other firmware in 
userspace is certainly useful.

We should just avoid making strong dependencies on that.

Firmware and VBIOS must always be backward compatible and the driver must 
always work with any released firmware and VBIOS combination.

What we can do is to display a warning when we detect and/or old/buggy firmware.

Regards,
Christian.
Am 28.04.21 um 08:47 schrieb Nieto, David M:
Besides system management, it provides parseable details on the VBIOS version 
and information. This is useful renderer information as the GPU behavior 
depends not only on the driver version but also on the firmwares running on the 
GPU.

The AMDGPU_INFO ioctl contains a method to get the versions of the ucode for 
all the IPs, but for VBIOS, only a way to dump the entire image is provided. 
While it Is possible to implement the whole logic of VBIOS parsing on 
userspace, it requires the application to have details on the header and table 
formats to parse the data. Moreover there is no guarantee that the format and 
header locations will remain constant across ASIC generations, so the 
maintainance cost and complexity seems unreasonable.

Providing a simple, and stable interface to the application seems to us like a 
sensible choice.

Thanks,
David

From: amd-gfx 
<mailto:amd-gfx-boun...@lists.freedesktop.org>
 on behalf of "Gu, JiaWei (Will)" <mailto:jiawei...@amd.com>
Date: Thursday, April 22, 2021 at 8:25 PM
To: Christian König 
<mailto:ckoenig.leichtzumer...@gmail.com>, 
"amd-gfx@lists.freedesktop.org"<mailto:amd-gfx@lists.freedesktop.org> 
<mailto:amd-gfx@lists.freedesktop.org>
Cc: "Deucher, Alexander" 
<mailto:alexander.deuc...@amd.com>, "StDenis, Tom" 
<mailto:tom.stde...@amd.com>, "Nieto, David M" 
<mailto:david.ni...@amd.com>
Subject: RE: [PATCH] drm/amdgpu: Add vbios info ioctl interface


[AMD Official Use Only - Internal Distribution Only]

Hi Christian,
It will be used by a user space SMI-lib for GPU status query.

Hi David, please feel free to correct my statement since I'm not sure I have a 
view of whole picture.

Thanks,
Jiawei

From: Christian König 
<mailto:ckoenig.leichtzumer...@gmail.com>
Sent: Thursday, April 22, 2021 9:27 PM
To: Gu, JiaWei (Will) <mailto:jiawei...@amd.com>; 
amd-gfx@lists.freedesktop.org<mailto:amd-gfx@lists.freedesktop.org>
Cc: Deucher, Alexander 
<mailto:alexander.deuc...@amd.com>; StDenis, Tom 
&

RE: [PATCH] drm/amdgpu: Add vbios info ioctl interface

2021-04-28 Thread Gu, JiaWei (Will)
[AMD Official Use Only - Internal Distribution Only]

Thanks Christian,

I amended the commit message and resend the patch out.
Please feel free to let me know if message is not clear enough.

Best regards,
Jiawei

From: Christian König 
Sent: Wednesday, April 28, 2021 3:43 PM
To: Nieto, David M ; Gu, JiaWei (Will) 
; amd-gfx@lists.freedesktop.org
Cc: Deucher, Alexander ; StDenis, Tom 

Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

Yeah, makes sense. Please note that in the commit message.

With that feel free to put an Acked-by: Christian König 
<mailto:christian.koe...@amd.com> on it.

Regards,
Christian.
Am 28.04.21 um 09:25 schrieb Nieto, David M:
I think this change may be orthogonal to that. Here we want to provide a way 
for the user application to get the VBIOS information without having to parse 
the binary...

And I agree that we should not have strong dependencies unless the encounter 
buggy VBIOS on the field, but I still think it is useful for the user to be 
able to display in a simple way the VBIOS version in their system if they 
happen to encounter an issue.

Regards,
David

From: Christian König 
<mailto:ckoenig.leichtzumer...@gmail.com>
Date: Wednesday, April 28, 2021 at 12:15 AM
To: "Nieto, David M" <mailto:david.ni...@amd.com>, "Gu, 
JiaWei (Will)" <mailto:jiawei...@amd.com>, 
"amd-gfx@lists.freedesktop.org"<mailto:amd-gfx@lists.freedesktop.org> 
<mailto:amd-gfx@lists.freedesktop.org>
Cc: "Deucher, Alexander" 
<mailto:alexander.deuc...@amd.com>, "StDenis, Tom" 
<mailto:tom.stde...@amd.com>
Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

Well displaying the VBIOS information along with the other firmware in 
userspace is certainly useful.

We should just avoid making strong dependencies on that.

Firmware and VBIOS must always be backward compatible and the driver must 
always work with any released firmware and VBIOS combination.

What we can do is to display a warning when we detect and/or old/buggy firmware.

Regards,
Christian.
Am 28.04.21 um 08:47 schrieb Nieto, David M:
Besides system management, it provides parseable details on the VBIOS version 
and information. This is useful renderer information as the GPU behavior 
depends not only on the driver version but also on the firmwares running on the 
GPU.

The AMDGPU_INFO ioctl contains a method to get the versions of the ucode for 
all the IPs, but for VBIOS, only a way to dump the entire image is provided. 
While it Is possible to implement the whole logic of VBIOS parsing on 
userspace, it requires the application to have details on the header and table 
formats to parse the data. Moreover there is no guarantee that the format and 
header locations will remain constant across ASIC generations, so the 
maintainance cost and complexity seems unreasonable.

Providing a simple, and stable interface to the application seems to us like a 
sensible choice.

Thanks,
David

From: amd-gfx 
<mailto:amd-gfx-boun...@lists.freedesktop.org>
 on behalf of "Gu, JiaWei (Will)" <mailto:jiawei...@amd.com>
Date: Thursday, April 22, 2021 at 8:25 PM
To: Christian König 
<mailto:ckoenig.leichtzumer...@gmail.com>, 
"amd-gfx@lists.freedesktop.org"<mailto:amd-gfx@lists.freedesktop.org> 
<mailto:amd-gfx@lists.freedesktop.org>
Cc: "Deucher, Alexander" 
<mailto:alexander.deuc...@amd.com>, "StDenis, Tom" 
<mailto:tom.stde...@amd.com>, "Nieto, David M" 
<mailto:david.ni...@amd.com>
Subject: RE: [PATCH] drm/amdgpu: Add vbios info ioctl interface


[AMD Official Use Only - Internal Distribution Only]

Hi Christian,
It will be used by a user space SMI-lib for GPU status query.

Hi David, please feel free to correct my statement since I'm not sure I have a 
view of whole picture.

Thanks,
Jiawei

From: Christian König 
<mailto:ckoenig.leichtzumer...@gmail.com>
Sent: Thursday, April 22, 2021 9:27 PM
To: Gu, JiaWei (Will) <mailto:jiawei...@amd.com>; 
amd-gfx@lists.freedesktop.org<mailto:amd-gfx@lists.freedesktop.org>
Cc: Deucher, Alexander 
<mailto:alexander.deuc...@amd.com>; StDenis, Tom 
<mailto:tom.stde...@amd.com>
Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

Is that useful to Vulkan/OpenGL/other clients in any way?

Christian.
Am 22.04.21 um 15:18 schrieb Gu, JiaWei (Will):



CC Tom.



On Apr 22, 2021, at 21:09, Gu, JiaWei (Will) 
<mailto:jiawei...@amd.com> wrote:



<[v2][umr]add-vbios-info-query.patch>

UMR patch which calls this new IOCTL attached.



Best regards,

Jiawei



On Apr 22, 2021, at 10:34, Jiawei Gu 
<mailto:jiawei...@amd.com> wrote:



Add AMDGPU_INFO_VBIOS_INFO subquery id for detailed vbios info.



Signed-off-by: Jiawei Gu <mailto:jiawei...@amd.com>

---

drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c|  19 +++

drivers/gpu/drm/amd/amdgpu/at

[PATCH] drm/amdgpu: Add vbios info ioctl interface

2021-04-28 Thread Jiawei Gu
Add AMDGPU_INFO_VBIOS_INFO subquery id for detailed vbios info.

Provides a way for the user application to get the VBIOS
information without having to parse the binary.
It is useful for the user to be able to display in a simple way the VBIOS
version in their system if they happen to encounter an issue.

Signed-off-by: Jiawei Gu 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c|  19 +++
 drivers/gpu/drm/amd/amdgpu/atom.c  | 158 +
 drivers/gpu/drm/amd/amdgpu/atom.h  |  11 ++
 drivers/gpu/drm/amd/include/atomfirmware.h |  16 ++-
 include/uapi/drm/amdgpu_drm.h  |  15 ++
 5 files changed, 213 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
index 39ee88d29cca..a20b016b05ab 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
@@ -861,6 +861,25 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, 
struct drm_file *filp)
min((size_t)size, 
(size_t)(bios_size - bios_offset)))
? -EFAULT : 0;
}
+   case AMDGPU_INFO_VBIOS_INFO: {
+   struct drm_amdgpu_info_vbios vbios_info = {};
+   struct atom_context *atom_context;
+
+   atom_context = adev->mode_info.atom_context;
+   memcpy(vbios_info.name, atom_context->name, 
sizeof(atom_context->name));
+   vbios_info.dbdf = PCI_DEVID(adev->pdev->bus->number, 
adev->pdev->devfn);
+   memcpy(vbios_info.vbios_pn, atom_context->vbios_pn, 
sizeof(atom_context->vbios_pn));
+   vbios_info.version = atom_context->version;
+   memcpy(vbios_info.date, atom_context->date, 
sizeof(atom_context->date));
+   memcpy(vbios_info.serial, adev->serial, 
sizeof(adev->serial));
+   vbios_info.dev_id = adev->pdev->device;
+   vbios_info.rev_id = adev->pdev->revision;
+   vbios_info.sub_dev_id = atom_context->sub_dev_id;
+   vbios_info.sub_ved_id = atom_context->sub_ved_id;
+
+   return copy_to_user(out, _info,
+   min((size_t)size, 
sizeof(vbios_info))) ? -EFAULT : 0;
+   }
default:
DRM_DEBUG_KMS("Invalid request %d\n",
info->vbios_info.type);
diff --git a/drivers/gpu/drm/amd/amdgpu/atom.c 
b/drivers/gpu/drm/amd/amdgpu/atom.c
index 3dcb8b32f48b..0e2f0ea13b40 100644
--- a/drivers/gpu/drm/amd/amdgpu/atom.c
+++ b/drivers/gpu/drm/amd/amdgpu/atom.c
@@ -31,6 +31,7 @@
 
 #define ATOM_DEBUG
 
+#include "atomfirmware.h"
 #include "atom.h"
 #include "atom-names.h"
 #include "atom-bits.h"
@@ -1299,12 +1300,153 @@ static void atom_index_iio(struct atom_context *ctx, 
int base)
}
 }
 
+static void atom_get_vbios_name(struct atom_context *ctx)
+{
+   unsigned char *p_rom;
+   unsigned char str_num;
+   unsigned short off_to_vbios_str;
+   unsigned char *c_ptr;
+   int name_size;
+   int i;
+
+   const char *na = "--N/A--";
+   char *back;
+
+   p_rom = ctx->bios;
+
+   str_num = *(p_rom + OFFSET_TO_GET_ATOMBIOS_NUMBER_OF_STRINGS);
+   if (str_num != 0) {
+   off_to_vbios_str =
+   *(unsigned short *)(p_rom + 
OFFSET_TO_GET_ATOMBIOS_STRING_START);
+
+   c_ptr = (unsigned char *)(p_rom + off_to_vbios_str);
+   } else {
+   /* do not know where to find name */
+   memcpy(ctx->name, na, 7);
+   ctx->name[7] = 0;
+   return;
+   }
+
+   /*
+* skip the atombios strings, usually 4
+* 1st is P/N, 2nd is ASIC, 3rd is PCI type, 4th is Memory type
+*/
+   for (i = 0; i < str_num; i++) {
+   while (*c_ptr != 0)
+   c_ptr++;
+   c_ptr++;
+   }
+
+   /* skip the following 2 chars: 0x0D 0x0A */
+   c_ptr += 2;
+
+   name_size = strnlen(c_ptr, STRLEN_LONG - 1);
+   memcpy(ctx->name, c_ptr, name_size);
+   back = ctx->name + name_size;
+   while ((*--back) == ' ')
+   ;
+   *(back + 1) = '\0';
+}
+
+static void atom_get_vbios_date(struct atom_context *ctx)
+{
+   unsigned char *p_rom;
+   unsigned char *date_in_rom;
+
+   p_rom = ctx->bios;
+
+   date_in_rom = p_rom + OFFSET_TO_VBIOS_DATE;
+
+   ctx->date[0] = '2';
+   ctx->date[1] = '0';
+   ctx->date[2] = date_in_rom[6];
+   ctx->date[3] = date_in_rom[7];
+   ctx->date[4] = '/';
+   ctx->date[5] = date_in_rom[0];
+   ctx->date[6] = date_in_rom[1];
+   ctx->date[7] = '/';
+   ctx->date[8] = date_in_rom[3];
+   ctx->date[9] = date_in_rom[4];
+   

Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

2021-04-28 Thread Christian König

Yeah, makes sense. Please note that in the commit message.

With that feel free to put an Acked-by: Christian König 
 on it.


Regards,
Christian.

Am 28.04.21 um 09:25 schrieb Nieto, David M:


I think this change may be orthogonal to that. Here we want to provide 
a way for the user application to get the VBIOS information without 
having to parse the binary…


And I agree that we should not have strong dependencies unless the 
encounter buggy VBIOS on the field, but I still think it is useful for 
the user to be able to display in a simple way the VBIOS version in 
their system if they happen to encounter an issue.


Regards,

David

*From: *Christian König 
*Date: *Wednesday, April 28, 2021 at 12:15 AM
*To: *"Nieto, David M" , "Gu, JiaWei (Will)" 
, "amd-gfx@lists.freedesktop.org" 

*Cc: *"Deucher, Alexander" , "StDenis, Tom" 


*Subject: *Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

Well displaying the VBIOS information along with the other firmware in 
userspace is certainly useful.


We should just avoid making strong dependencies on that.

Firmware and VBIOS must always be backward compatible and the driver 
must always work with any released firmware and VBIOS combination.


What we can do is to display a warning when we detect and/or old/buggy 
firmware.


Regards,
Christian.

Am 28.04.21 um 08:47 schrieb Nieto, David M:

Besides system management, it provides parseable details on the
VBIOS version and information. This is useful renderer information
as the GPU behavior depends not only on the driver version but
also on the firmwares running on the GPU.

The AMDGPU_INFO ioctl contains a method to get the versions of the
ucode for all the IPs, but for VBIOS, only a way to dump the
entire image is provided. While it Is possible to implement the
whole logic of VBIOS parsing on userspace, it requires the
application to have details on the header and table formats to
parse the data. Moreover there is no guarantee that the format and
header locations will remain constant across ASIC generations, so
the maintainance cost and complexity seems unreasonable.

Providing a simple, and stable interface to the application seems
to us like a sensible choice.

Thanks,

David

*From: *amd-gfx 
<mailto:amd-gfx-boun...@lists.freedesktop.org> on behalf of "Gu,
JiaWei (Will)"  <mailto:jiawei...@amd.com>
*Date: *Thursday, April 22, 2021 at 8:25 PM
*To: *Christian König 
<mailto:ckoenig.leichtzumer...@gmail.com>,
"amd-gfx@lists.freedesktop.org"
<mailto:amd-gfx@lists.freedesktop.org>
 <mailto:amd-gfx@lists.freedesktop.org>
*Cc: *"Deucher, Alexander" 
<mailto:alexander.deuc...@amd.com>, "StDenis, Tom"
     <mailto:tom.stde...@amd.com>, "Nieto, David
M"  <mailto:david.ni...@amd.com>
*Subject: *RE: [PATCH] drm/amdgpu: Add vbios info ioctl interface

[AMD Official Use Only - Internal Distribution Only]

Hi Christian,

It will be used by a user space SMI-lib for GPU status query.

Hi David, please feel free to correct my statement since I’m not
sure I have a view of whole picture.

Thanks,

Jiawei

*From:* Christian König 
<mailto:ckoenig.leichtzumer...@gmail.com>
*Sent:* Thursday, April 22, 2021 9:27 PM
*To:* Gu, JiaWei (Will) 
<mailto:jiawei...@amd.com>; amd-gfx@lists.freedesktop.org
<mailto:amd-gfx@lists.freedesktop.org>
*Cc:* Deucher, Alexander 
<mailto:alexander.deuc...@amd.com>; StDenis, Tom
 <mailto:tom.stde...@amd.com>
*Subject:* Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

Is that useful to Vulkan/OpenGL/other clients in any way?

Christian.

Am 22.04.21 um 15:18 schrieb Gu, JiaWei (Will):

  


CC Tom.

  


On Apr 22, 2021, at 21:09, Gu, JiaWei (Will)  
<mailto:jiawei...@amd.com>  wrote:

  


<[v2][umr]add-vbios-info-query.patch>

UMR patch which calls this new IOCTL attached.

  


Best regards,

Jiawei

  


On Apr 22, 2021, at 10:34, Jiawei Gu  
<mailto:jiawei...@amd.com>  wrote:

  


Add AMDGPU_INFO_VBIOS_INFO subquery id for detailed vbios info.

  


Signed-off-by: Jiawei Gu  
<mailto:jiawei...@amd.com>

---

drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c    |  19 +++

drivers/gpu/drm/amd/amdgpu/atom.c  | 158 
+

drivers/gpu/drm/amd/amdgpu/atom.h  |  11 ++

drivers/gpu/drm/amd/include/atomfirmware.h |  16 ++-

include/uapi/drm/amdgpu_drm.h  |  15 ++

Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

2021-04-28 Thread Nieto, David M
I think this change may be orthogonal to that. Here we want to provide a way 
for the user application to get the VBIOS information without having to parse 
the binary…

And I agree that we should not have strong dependencies unless the encounter 
buggy VBIOS on the field, but I still think it is useful for the user to be 
able to display in a simple way the VBIOS version in their system if they 
happen to encounter an issue.

Regards,
David

From: Christian König 
Date: Wednesday, April 28, 2021 at 12:15 AM
To: "Nieto, David M" , "Gu, JiaWei (Will)" 
, "amd-gfx@lists.freedesktop.org" 

Cc: "Deucher, Alexander" , "StDenis, Tom" 

Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

Well displaying the VBIOS information along with the other firmware in 
userspace is certainly useful.

We should just avoid making strong dependencies on that.

Firmware and VBIOS must always be backward compatible and the driver must 
always work with any released firmware and VBIOS combination.

What we can do is to display a warning when we detect and/or old/buggy firmware.

Regards,
Christian.
Am 28.04.21 um 08:47 schrieb Nieto, David M:
Besides system management, it provides parseable details on the VBIOS version 
and information. This is useful renderer information as the GPU behavior 
depends not only on the driver version but also on the firmwares running on the 
GPU.

The AMDGPU_INFO ioctl contains a method to get the versions of the ucode for 
all the IPs, but for VBIOS, only a way to dump the entire image is provided. 
While it Is possible to implement the whole logic of VBIOS parsing on 
userspace, it requires the application to have details on the header and table 
formats to parse the data. Moreover there is no guarantee that the format and 
header locations will remain constant across ASIC generations, so the 
maintainance cost and complexity seems unreasonable.

Providing a simple, and stable interface to the application seems to us like a 
sensible choice.

Thanks,
David

From: amd-gfx 
<mailto:amd-gfx-boun...@lists.freedesktop.org>
 on behalf of "Gu, JiaWei (Will)" <mailto:jiawei...@amd.com>
Date: Thursday, April 22, 2021 at 8:25 PM
To: Christian König 
<mailto:ckoenig.leichtzumer...@gmail.com>, 
"amd-gfx@lists.freedesktop.org"<mailto:amd-gfx@lists.freedesktop.org> 
<mailto:amd-gfx@lists.freedesktop.org>
Cc: "Deucher, Alexander" 
<mailto:alexander.deuc...@amd.com>, "StDenis, Tom" 
<mailto:tom.stde...@amd.com>, "Nieto, David M" 
<mailto:david.ni...@amd.com>
Subject: RE: [PATCH] drm/amdgpu: Add vbios info ioctl interface


[AMD Official Use Only - Internal Distribution Only]

Hi Christian,
It will be used by a user space SMI-lib for GPU status query.

Hi David, please feel free to correct my statement since I’m not sure I have a 
view of whole picture.

Thanks,
Jiawei

From: Christian König 
<mailto:ckoenig.leichtzumer...@gmail.com>
Sent: Thursday, April 22, 2021 9:27 PM
To: Gu, JiaWei (Will) <mailto:jiawei...@amd.com>; 
amd-gfx@lists.freedesktop.org<mailto:amd-gfx@lists.freedesktop.org>
Cc: Deucher, Alexander 
<mailto:alexander.deuc...@amd.com>; StDenis, Tom 
<mailto:tom.stde...@amd.com>
Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

Is that useful to Vulkan/OpenGL/other clients in any way?

Christian.
Am 22.04.21 um 15:18 schrieb Gu, JiaWei (Will):



CC Tom.



On Apr 22, 2021, at 21:09, Gu, JiaWei (Will) 
<mailto:jiawei...@amd.com> wrote:



<[v2][umr]add-vbios-info-query.patch>

UMR patch which calls this new IOCTL attached.



Best regards,

Jiawei



On Apr 22, 2021, at 10:34, Jiawei Gu 
<mailto:jiawei...@amd.com> wrote:



Add AMDGPU_INFO_VBIOS_INFO subquery id for detailed vbios info.



Signed-off-by: Jiawei Gu <mailto:jiawei...@amd.com>

---

drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c|  19 +++

drivers/gpu/drm/amd/amdgpu/atom.c  | 158 +

drivers/gpu/drm/amd/amdgpu/atom.h  |  11 ++

drivers/gpu/drm/amd/include/atomfirmware.h |  16 ++-

include/uapi/drm/amdgpu_drm.h  |  15 ++

5 files changed, 213 insertions(+), 6 deletions(-)



diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c

index 39ee88d29cca..a20b016b05ab 100644

--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c

+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c

@@ -861,6 +861,25 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, 
struct drm_file *filp)

   min((size_t)size, (size_t)(bios_size - 
bios_offset)))

   ? -EFAULT : 0;

 }

+case AMDGPU_INFO_VBIOS_INFO: {

+   struct drm_amdgpu_info_vbios vbios_info = {};

+   struct atom_context *atom_context;

+

+   atom_context = adev

Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

2021-04-28 Thread Christian König
Well displaying the VBIOS information along with the other firmware in 
userspace is certainly useful.


We should just avoid making strong dependencies on that.

Firmware and VBIOS must always be backward compatible and the driver 
must always work with any released firmware and VBIOS combination.


What we can do is to display a warning when we detect and/or old/buggy 
firmware.


Regards,
Christian.

Am 28.04.21 um 08:47 schrieb Nieto, David M:


Besides system management, it provides parseable details on the VBIOS 
version and information. This is useful renderer information as the 
GPU behavior depends not only on the driver version but also on the 
firmwares running on the GPU.


The AMDGPU_INFO ioctl contains a method to get the versions of the 
ucode for all the IPs, but for VBIOS, only a way to dump the entire 
image is provided. While it Is possible to implement the whole logic 
of VBIOS parsing on userspace, it requires the application to have 
details on the header and table formats to parse the data. Moreover 
there is no guarantee that the format and header locations will remain 
constant across ASIC generations, so the maintainance cost and 
complexity seems unreasonable.


Providing a simple, and stable interface to the application seems to 
us like a sensible choice.


Thanks,

David

*From: *amd-gfx  on behalf of 
"Gu, JiaWei (Will)" 

*Date: *Thursday, April 22, 2021 at 8:25 PM
*To: *Christian König , 
"amd-gfx@lists.freedesktop.org" 
*Cc: *"Deucher, Alexander" , "StDenis, Tom" 
, "Nieto, David M" 

*Subject: *RE: [PATCH] drm/amdgpu: Add vbios info ioctl interface

[AMD Official Use Only - Internal Distribution Only]

Hi Christian,

It will be used by a user space SMI-lib for GPU status query.

Hi David, please feel free to correct my statement since I’m not sure 
I have a view of whole picture.


Thanks,

Jiawei

*From:* Christian König 
*Sent:* Thursday, April 22, 2021 9:27 PM
*To:* Gu, JiaWei (Will) ; amd-gfx@lists.freedesktop.org
*Cc:* Deucher, Alexander ; StDenis, Tom 


*Subject:* Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

Is that useful to Vulkan/OpenGL/other clients in any way?

Christian.

Am 22.04.21 um 15:18 schrieb Gu, JiaWei (Will):

  


CC Tom.

  


On Apr 22, 2021, at 21:09, Gu, JiaWei (Will)  
<mailto:jiawei...@amd.com>  wrote:

  


<[v2][umr]add-vbios-info-query.patch>

UMR patch which calls this new IOCTL attached.

  


Best regards,

Jiawei

  


On Apr 22, 2021, at 10:34, Jiawei Gu  
<mailto:jiawei...@amd.com>  wrote:

  


Add AMDGPU_INFO_VBIOS_INFO subquery id for detailed vbios info.

  


Signed-off-by: Jiawei Gu  
<mailto:jiawei...@amd.com>

---

drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c    |  19 +++

drivers/gpu/drm/amd/amdgpu/atom.c  | 158 
+

drivers/gpu/drm/amd/amdgpu/atom.h  |  11 ++

drivers/gpu/drm/amd/include/atomfirmware.h |  16 ++-

include/uapi/drm/amdgpu_drm.h  |  15 ++

5 files changed, 213 insertions(+), 6 deletions(-)

  


diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c

index 39ee88d29cca..a20b016b05ab 100644

--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c

+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c

@@ -861,6 +861,25 @@ int amdgpu_info_ioctl(struct drm_device *dev, 
void *data, struct drm_file *filp)

        min((size_t)size, 
(size_t)(bios_size - bios_offset)))

    ? -EFAULT : 0;

  }

+    case AMDGPU_INFO_VBIOS_INFO: {

+   struct drm_amdgpu_info_vbios vbios_info = {};

+   struct atom_context *atom_context;

+

+   atom_context = adev->mode_info.atom_context;

+     memcpy(vbios_info.name, atom_context->name, 
sizeof(atom_context->name));

+     vbios_info.dbdf = PCI_DEVID(adev->pdev->bus->number, 
adev->pdev->devfn);

+     memcpy(vbios_info.vbios_pn, atom_context->vbios_pn, 
sizeof(atom_context->vbios_pn));

+     vbios_info.version = atom_context->version;

+     memcpy(vbios_info.date, atom_context->date, 
sizeof(atom_context->date));

+     memcpy(vbios_info.serial, adev->serial, 
sizeof(adev->serial));

+     vbios_info.dev_id = adev->pdev->device;

+     

Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

2021-04-28 Thread Nieto, David M
Besides system management, it provides parseable details on the VBIOS version 
and information. This is useful renderer information as the GPU behavior 
depends not only on the driver version but also on the firmwares running on the 
GPU.

The AMDGPU_INFO ioctl contains a method to get the versions of the ucode for 
all the IPs, but for VBIOS, only a way to dump the entire image is provided. 
While it Is possible to implement the whole logic of VBIOS parsing on 
userspace, it requires the application to have details on the header and table 
formats to parse the data. Moreover there is no guarantee that the format and 
header locations will remain constant across ASIC generations, so the 
maintainance cost and complexity seems unreasonable.

Providing a simple, and stable interface to the application seems to us like a 
sensible choice.

Thanks,
David

From: amd-gfx  on behalf of "Gu, JiaWei 
(Will)" 
Date: Thursday, April 22, 2021 at 8:25 PM
To: Christian König , 
"amd-gfx@lists.freedesktop.org" 
Cc: "Deucher, Alexander" , "StDenis, Tom" 
, "Nieto, David M" 
Subject: RE: [PATCH] drm/amdgpu: Add vbios info ioctl interface


[AMD Official Use Only - Internal Distribution Only]

Hi Christian,
It will be used by a user space SMI-lib for GPU status query.

Hi David, please feel free to correct my statement since I’m not sure I have a 
view of whole picture.

Thanks,
Jiawei

From: Christian König 
Sent: Thursday, April 22, 2021 9:27 PM
To: Gu, JiaWei (Will) ; amd-gfx@lists.freedesktop.org
Cc: Deucher, Alexander ; StDenis, Tom 

Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

Is that useful to Vulkan/OpenGL/other clients in any way?

Christian.
Am 22.04.21 um 15:18 schrieb Gu, JiaWei (Will):



CC Tom.



On Apr 22, 2021, at 21:09, Gu, JiaWei (Will) 
<mailto:jiawei...@amd.com> wrote:



<[v2][umr]add-vbios-info-query.patch>

UMR patch which calls this new IOCTL attached.



Best regards,

Jiawei



On Apr 22, 2021, at 10:34, Jiawei Gu 
<mailto:jiawei...@amd.com> wrote:



Add AMDGPU_INFO_VBIOS_INFO subquery id for detailed vbios info.



Signed-off-by: Jiawei Gu <mailto:jiawei...@amd.com>

---

drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c|  19 +++

drivers/gpu/drm/amd/amdgpu/atom.c  | 158 +

drivers/gpu/drm/amd/amdgpu/atom.h  |  11 ++

drivers/gpu/drm/amd/include/atomfirmware.h |  16 ++-

include/uapi/drm/amdgpu_drm.h  |  15 ++

5 files changed, 213 insertions(+), 6 deletions(-)



diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c

index 39ee88d29cca..a20b016b05ab 100644

--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c

+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c

@@ -861,6 +861,25 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, 
struct drm_file *filp)

   min((size_t)size, (size_t)(bios_size - 
bios_offset)))

   ? -EFAULT : 0;

 }

+case AMDGPU_INFO_VBIOS_INFO: {

+   struct drm_amdgpu_info_vbios vbios_info = {};

+   struct atom_context *atom_context;

+

+   atom_context = adev->mode_info.atom_context;

+ memcpy(vbios_info.name, atom_context->name, 
sizeof(atom_context->name));

+ vbios_info.dbdf = PCI_DEVID(adev->pdev->bus->number, 
adev->pdev->devfn);

+ memcpy(vbios_info.vbios_pn, atom_context->vbios_pn, 
sizeof(atom_context->vbios_pn));

+ vbios_info.version = atom_context->version;

+ memcpy(vbios_info.date, atom_context->date, 
sizeof(atom_context->date));

+ memcpy(vbios_info.serial, adev->serial, sizeof(adev->serial));

+ vbios_info.dev_id = adev->pdev->device;

+ vbios_info.rev_id = adev->pdev->revision;

+ vbios_info.sub_dev_id = atom_context->sub_dev_id;

+ vbios_info.sub_ved_id = atom_context->sub_ved_id;

+

+   return copy_to_user(out, _info,

+  min((size_t)size, sizeof(vbios_info))) ? 
-EFAULT : 0;

+}

 default:

  DRM_DEBUG_KMS("Invalid request %d\n",

info->vbios_info.type);

diff --git a/drivers/gpu/drm/amd/amdgpu/atom.c 
b/drivers/gpu/drm/amd/amdgpu/atom.c

index 3dcb8b32f48b..0e2f0ea13b40 100644

--- a/drivers/gpu/drm/amd/amdgpu/atom.c

+++ b/drivers/gpu/drm/amd/amdgpu/atom.c

@@ -31,6 +31,7 @@



#define ATOM_DEBUG



+#include "atomfirmware.h"

#include "atom.h"

#include "atom-names.h"

#include "atom-bits.h"

@@ -1299,12 +1300,153 @@ static void atom_index_iio(struct atom_context *ctx, 
int base)

 }

}



+static void atom_get_vbios_name(struct atom_context *

RE: [PATCH] drm/amdgpu: Add vbios info ioctl interface

2021-04-22 Thread Gu, JiaWei (Will)
[AMD Official Use Only - Internal Distribution Only]

Hi Christian,
It will be used by a user space SMI-lib for GPU status query.

Hi David, please feel free to correct my statement since I'm not sure I have a 
view of whole picture.

Thanks,
Jiawei

From: Christian König 
Sent: Thursday, April 22, 2021 9:27 PM
To: Gu, JiaWei (Will) ; amd-gfx@lists.freedesktop.org
Cc: Deucher, Alexander ; StDenis, Tom 

Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

Is that useful to Vulkan/OpenGL/other clients in any way?

Christian.
Am 22.04.21 um 15:18 schrieb Gu, JiaWei (Will):



CC Tom.



On Apr 22, 2021, at 21:09, Gu, JiaWei (Will) 
<mailto:jiawei...@amd.com> wrote:



<[v2][umr]add-vbios-info-query.patch>

UMR patch which calls this new IOCTL attached.



Best regards,

Jiawei



On Apr 22, 2021, at 10:34, Jiawei Gu 
<mailto:jiawei...@amd.com> wrote:



Add AMDGPU_INFO_VBIOS_INFO subquery id for detailed vbios info.



Signed-off-by: Jiawei Gu <mailto:jiawei...@amd.com>

---

drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c|  19 +++

drivers/gpu/drm/amd/amdgpu/atom.c  | 158 +

drivers/gpu/drm/amd/amdgpu/atom.h  |  11 ++

drivers/gpu/drm/amd/include/atomfirmware.h |  16 ++-

include/uapi/drm/amdgpu_drm.h  |  15 ++

5 files changed, 213 insertions(+), 6 deletions(-)



diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c

index 39ee88d29cca..a20b016b05ab 100644

--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c

+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c

@@ -861,6 +861,25 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, 
struct drm_file *filp)

   min((size_t)size, (size_t)(bios_size - 
bios_offset)))

   ? -EFAULT : 0;

 }

+case AMDGPU_INFO_VBIOS_INFO: {

+   struct drm_amdgpu_info_vbios vbios_info = {};

+   struct atom_context *atom_context;

+

+   atom_context = adev->mode_info.atom_context;

+ memcpy(vbios_info.name, atom_context->name, 
sizeof(atom_context->name));

+ vbios_info.dbdf = PCI_DEVID(adev->pdev->bus->number, 
adev->pdev->devfn);

+ memcpy(vbios_info.vbios_pn, atom_context->vbios_pn, 
sizeof(atom_context->vbios_pn));

+ vbios_info.version = atom_context->version;

+ memcpy(vbios_info.date, atom_context->date, 
sizeof(atom_context->date));

+ memcpy(vbios_info.serial, adev->serial, sizeof(adev->serial));

+ vbios_info.dev_id = adev->pdev->device;

+ vbios_info.rev_id = adev->pdev->revision;

+ vbios_info.sub_dev_id = atom_context->sub_dev_id;

+ vbios_info.sub_ved_id = atom_context->sub_ved_id;

+

+   return copy_to_user(out, _info,

+  min((size_t)size, sizeof(vbios_info))) ? 
-EFAULT : 0;

+}

 default:

  DRM_DEBUG_KMS("Invalid request %d\n",

info->vbios_info.type);

diff --git a/drivers/gpu/drm/amd/amdgpu/atom.c 
b/drivers/gpu/drm/amd/amdgpu/atom.c

index 3dcb8b32f48b..0e2f0ea13b40 100644

--- a/drivers/gpu/drm/amd/amdgpu/atom.c

+++ b/drivers/gpu/drm/amd/amdgpu/atom.c

@@ -31,6 +31,7 @@



#define ATOM_DEBUG



+#include "atomfirmware.h"

#include "atom.h"

#include "atom-names.h"

#include "atom-bits.h"

@@ -1299,12 +1300,153 @@ static void atom_index_iio(struct atom_context *ctx, 
int base)

 }

}



+static void atom_get_vbios_name(struct atom_context *ctx)

+{

+unsigned char *p_rom;

+unsigned char str_num;

+unsigned short off_to_vbios_str;

+unsigned char *c_ptr;

+int name_size;

+int i;

+

+const char *na = "--N/A--";

+char *back;

+

+p_rom = ctx->bios;

+

+str_num = *(p_rom + OFFSET_TO_GET_ATOMBIOS_NUMBER_OF_STRINGS);

+if (str_num != 0) {

+off_to_vbios_str =

+   *(unsigned short *)(p_rom + 
OFFSET_TO_GET_ATOMBIOS_STRING_START);

+

+c_ptr = (unsigned char *)(p_rom + off_to_vbios_str);

+} else {

+/* do not know where to find name */

+memcpy(ctx->name, na, 7);

+ctx->name[7] = 0;

+return;

+}

+

+/*

+ * skip the atombios strings, usually 4

+ * 1st is P/N, 2nd is ASIC, 3rd is PCI type, 4th is Memory type

+ */

+for (i = 0; i < str_num; i++) {

+while (*c_ptr != 0)

+   c_ptr++;

+c_ptr++;

+}

+

+/* skip the following 2 chars: 0x0D 0x0A */

+c_ptr += 2;

+

+name_size = strnlen(c_ptr, STRLEN_LONG - 1);

+memcpy(ctx->name, c_ptr, name_size);

+bac

Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

2021-04-22 Thread Christian König

Is that useful to Vulkan/OpenGL/other clients in any way?

Christian.

Am 22.04.21 um 15:18 schrieb Gu, JiaWei (Will):

CC Tom.


On Apr 22, 2021, at 21:09, Gu, JiaWei (Will)  wrote:

<[v2][umr]add-vbios-info-query.patch>
UMR patch which calls this new IOCTL attached.

Best regards,
Jiawei


On Apr 22, 2021, at 10:34, Jiawei Gu  wrote:

Add AMDGPU_INFO_VBIOS_INFO subquery id for detailed vbios info.

Signed-off-by: Jiawei Gu 
---
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c|  19 +++
drivers/gpu/drm/amd/amdgpu/atom.c  | 158 +
drivers/gpu/drm/amd/amdgpu/atom.h  |  11 ++
drivers/gpu/drm/amd/include/atomfirmware.h |  16 ++-
include/uapi/drm/amdgpu_drm.h  |  15 ++
5 files changed, 213 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
index 39ee88d29cca..a20b016b05ab 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
@@ -861,6 +861,25 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, 
struct drm_file *filp)
min((size_t)size, 
(size_t)(bios_size - bios_offset)))
? -EFAULT : 0;
}
+   case AMDGPU_INFO_VBIOS_INFO: {
+   struct drm_amdgpu_info_vbios vbios_info = {};
+   struct atom_context *atom_context;
+
+   atom_context = adev->mode_info.atom_context;
+   memcpy(vbios_info.name, atom_context->name, 
sizeof(atom_context->name));
+   vbios_info.dbdf = PCI_DEVID(adev->pdev->bus->number, 
adev->pdev->devfn);
+   memcpy(vbios_info.vbios_pn, atom_context->vbios_pn, 
sizeof(atom_context->vbios_pn));
+   vbios_info.version = atom_context->version;
+   memcpy(vbios_info.date, atom_context->date, 
sizeof(atom_context->date));
+   memcpy(vbios_info.serial, adev->serial, 
sizeof(adev->serial));
+   vbios_info.dev_id = adev->pdev->device;
+   vbios_info.rev_id = adev->pdev->revision;
+   vbios_info.sub_dev_id = atom_context->sub_dev_id;
+   vbios_info.sub_ved_id = atom_context->sub_ved_id;
+
+   return copy_to_user(out, _info,
+   min((size_t)size, 
sizeof(vbios_info))) ? -EFAULT : 0;
+   }
default:
DRM_DEBUG_KMS("Invalid request %d\n",
info->vbios_info.type);
diff --git a/drivers/gpu/drm/amd/amdgpu/atom.c 
b/drivers/gpu/drm/amd/amdgpu/atom.c
index 3dcb8b32f48b..0e2f0ea13b40 100644
--- a/drivers/gpu/drm/amd/amdgpu/atom.c
+++ b/drivers/gpu/drm/amd/amdgpu/atom.c
@@ -31,6 +31,7 @@

#define ATOM_DEBUG

+#include "atomfirmware.h"
#include "atom.h"
#include "atom-names.h"
#include "atom-bits.h"
@@ -1299,12 +1300,153 @@ static void atom_index_iio(struct atom_context *ctx, 
int base)
}
}

+static void atom_get_vbios_name(struct atom_context *ctx)
+{
+   unsigned char *p_rom;
+   unsigned char str_num;
+   unsigned short off_to_vbios_str;
+   unsigned char *c_ptr;
+   int name_size;
+   int i;
+
+   const char *na = "--N/A--";
+   char *back;
+
+   p_rom = ctx->bios;
+
+   str_num = *(p_rom + OFFSET_TO_GET_ATOMBIOS_NUMBER_OF_STRINGS);
+   if (str_num != 0) {
+   off_to_vbios_str =
+   *(unsigned short *)(p_rom + 
OFFSET_TO_GET_ATOMBIOS_STRING_START);
+
+   c_ptr = (unsigned char *)(p_rom + off_to_vbios_str);
+   } else {
+   /* do not know where to find name */
+   memcpy(ctx->name, na, 7);
+   ctx->name[7] = 0;
+   return;
+   }
+
+   /*
+* skip the atombios strings, usually 4
+* 1st is P/N, 2nd is ASIC, 3rd is PCI type, 4th is Memory type
+*/
+   for (i = 0; i < str_num; i++) {
+   while (*c_ptr != 0)
+   c_ptr++;
+   c_ptr++;
+   }
+
+   /* skip the following 2 chars: 0x0D 0x0A */
+   c_ptr += 2;
+
+   name_size = strnlen(c_ptr, STRLEN_LONG - 1);
+   memcpy(ctx->name, c_ptr, name_size);
+   back = ctx->name + name_size;
+   while ((*--back) == ' ')
+   ;
+   *(back + 1) = '\0';
+}
+
+static void atom_get_vbios_date(struct atom_context *ctx)
+{
+   unsigned char *p_rom;
+   unsigned char *date_in_rom;
+
+   p_rom = ctx->bios;
+
+   date_in_rom = p_rom + OFFSET_TO_VBIOS_DATE;
+
+   ctx->date[0] = '2';
+   ctx->date[1] = '0';
+   ctx->date[2] = date_in_rom[6];
+   ctx->date[3] = date_in_rom[7];
+   ctx->date[4] = '/';
+   ctx->date[5] = date_in_rom[0];
+   ctx->date[6] = date_in_rom[1];
+   ctx->date[7] = '/';
+   

Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

2021-04-22 Thread Gu, JiaWei (Will)

CC Tom.

> On Apr 22, 2021, at 21:09, Gu, JiaWei (Will)  wrote:
> 
> <[v2][umr]add-vbios-info-query.patch>
> UMR patch which calls this new IOCTL attached.
> 
> Best regards,
> Jiawei
> 
>> On Apr 22, 2021, at 10:34, Jiawei Gu  wrote:
>> 
>> Add AMDGPU_INFO_VBIOS_INFO subquery id for detailed vbios info.
>> 
>> Signed-off-by: Jiawei Gu 
>> ---
>> drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c|  19 +++
>> drivers/gpu/drm/amd/amdgpu/atom.c  | 158 +
>> drivers/gpu/drm/amd/amdgpu/atom.h  |  11 ++
>> drivers/gpu/drm/amd/include/atomfirmware.h |  16 ++-
>> include/uapi/drm/amdgpu_drm.h  |  15 ++
>> 5 files changed, 213 insertions(+), 6 deletions(-)
>> 
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c 
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
>> index 39ee88d29cca..a20b016b05ab 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
>> @@ -861,6 +861,25 @@ int amdgpu_info_ioctl(struct drm_device *dev, void 
>> *data, struct drm_file *filp)
>>  min((size_t)size, 
>> (size_t)(bios_size - bios_offset)))
>>  ? -EFAULT : 0;
>>  }
>> +case AMDGPU_INFO_VBIOS_INFO: {
>> +struct drm_amdgpu_info_vbios vbios_info = {};
>> +struct atom_context *atom_context;
>> +
>> +atom_context = adev->mode_info.atom_context;
>> +memcpy(vbios_info.name, atom_context->name, 
>> sizeof(atom_context->name));
>> +vbios_info.dbdf = PCI_DEVID(adev->pdev->bus->number, 
>> adev->pdev->devfn);
>> +memcpy(vbios_info.vbios_pn, atom_context->vbios_pn, 
>> sizeof(atom_context->vbios_pn));
>> +vbios_info.version = atom_context->version;
>> +memcpy(vbios_info.date, atom_context->date, 
>> sizeof(atom_context->date));
>> +memcpy(vbios_info.serial, adev->serial, 
>> sizeof(adev->serial));
>> +vbios_info.dev_id = adev->pdev->device;
>> +vbios_info.rev_id = adev->pdev->revision;
>> +vbios_info.sub_dev_id = atom_context->sub_dev_id;
>> +vbios_info.sub_ved_id = atom_context->sub_ved_id;
>> +
>> +return copy_to_user(out, _info,
>> +min((size_t)size, 
>> sizeof(vbios_info))) ? -EFAULT : 0;
>> +}
>>  default:
>>  DRM_DEBUG_KMS("Invalid request %d\n",
>>  info->vbios_info.type);
>> diff --git a/drivers/gpu/drm/amd/amdgpu/atom.c 
>> b/drivers/gpu/drm/amd/amdgpu/atom.c
>> index 3dcb8b32f48b..0e2f0ea13b40 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/atom.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/atom.c
>> @@ -31,6 +31,7 @@
>> 
>> #define ATOM_DEBUG
>> 
>> +#include "atomfirmware.h"
>> #include "atom.h"
>> #include "atom-names.h"
>> #include "atom-bits.h"
>> @@ -1299,12 +1300,153 @@ static void atom_index_iio(struct atom_context 
>> *ctx, int base)
>>  }
>> }
>> 
>> +static void atom_get_vbios_name(struct atom_context *ctx)
>> +{
>> +unsigned char *p_rom;
>> +unsigned char str_num;
>> +unsigned short off_to_vbios_str;
>> +unsigned char *c_ptr;
>> +int name_size;
>> +int i;
>> +
>> +const char *na = "--N/A--";
>> +char *back;
>> +
>> +p_rom = ctx->bios;
>> +
>> +str_num = *(p_rom + OFFSET_TO_GET_ATOMBIOS_NUMBER_OF_STRINGS);
>> +if (str_num != 0) {
>> +off_to_vbios_str =
>> +*(unsigned short *)(p_rom + 
>> OFFSET_TO_GET_ATOMBIOS_STRING_START);
>> +
>> +c_ptr = (unsigned char *)(p_rom + off_to_vbios_str);
>> +} else {
>> +/* do not know where to find name */
>> +memcpy(ctx->name, na, 7);
>> +ctx->name[7] = 0;
>> +return;
>> +}
>> +
>> +/*
>> + * skip the atombios strings, usually 4
>> + * 1st is P/N, 2nd is ASIC, 3rd is PCI type, 4th is Memory type
>> + */
>> +for (i = 0; i < str_num; i++) {
>> +while (*c_ptr != 0)
>> +c_ptr++;
>> +c_ptr++;
>> +}
>> +
>> +/* skip the following 2 chars: 0x0D 0x0A */
>> +c_ptr += 2;
>> +
>> +name_size = strnlen(c_ptr, STRLEN_LONG - 1);
>> +memcpy(ctx->name, c_ptr, name_size);
>> +back = ctx->name + name_size;
>> +while ((*--back) == ' ')
>> +;
>> +*(back + 1) = '\0';
>> +}
>> +
>> +static void atom_get_vbios_date(struct atom_context *ctx)
>> +{
>> +unsigned char *p_rom;
>> +unsigned char *date_in_rom;
>> +
>> +p_rom = ctx->bios;
>> +
>> +date_in_rom = p_rom + OFFSET_TO_VBIOS_DATE;
>> +
>> +ctx->date[0] = '2';
>> +ctx->date[1] = '0';
>> +ctx->date[2] = date_in_rom[6];
>> +ctx->date[3] = date_in_rom[7];
>> +ctx->date[4] = '/';
>> +ctx->date[5] = 

Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

2021-04-22 Thread Gu, JiaWei (Will)

UMR patch which calls this new IOCTL attached.

Best regards,
Jiawei

> On Apr 22, 2021, at 10:34, Jiawei Gu  wrote:
> 
> Add AMDGPU_INFO_VBIOS_INFO subquery id for detailed vbios info.
> 
> Signed-off-by: Jiawei Gu 
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c|  19 +++
> drivers/gpu/drm/amd/amdgpu/atom.c  | 158 +
> drivers/gpu/drm/amd/amdgpu/atom.h  |  11 ++
> drivers/gpu/drm/amd/include/atomfirmware.h |  16 ++-
> include/uapi/drm/amdgpu_drm.h  |  15 ++
> 5 files changed, 213 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> index 39ee88d29cca..a20b016b05ab 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> @@ -861,6 +861,25 @@ int amdgpu_info_ioctl(struct drm_device *dev, void 
> *data, struct drm_file *filp)
>   min((size_t)size, 
> (size_t)(bios_size - bios_offset)))
>   ? -EFAULT : 0;
>   }
> + case AMDGPU_INFO_VBIOS_INFO: {
> + struct drm_amdgpu_info_vbios vbios_info = {};
> + struct atom_context *atom_context;
> +
> + atom_context = adev->mode_info.atom_context;
> + memcpy(vbios_info.name, atom_context->name, 
> sizeof(atom_context->name));
> + vbios_info.dbdf = PCI_DEVID(adev->pdev->bus->number, 
> adev->pdev->devfn);
> + memcpy(vbios_info.vbios_pn, atom_context->vbios_pn, 
> sizeof(atom_context->vbios_pn));
> + vbios_info.version = atom_context->version;
> + memcpy(vbios_info.date, atom_context->date, 
> sizeof(atom_context->date));
> + memcpy(vbios_info.serial, adev->serial, 
> sizeof(adev->serial));
> + vbios_info.dev_id = adev->pdev->device;
> + vbios_info.rev_id = adev->pdev->revision;
> + vbios_info.sub_dev_id = atom_context->sub_dev_id;
> + vbios_info.sub_ved_id = atom_context->sub_ved_id;
> +
> + return copy_to_user(out, _info,
> + min((size_t)size, 
> sizeof(vbios_info))) ? -EFAULT : 0;
> + }
>   default:
>   DRM_DEBUG_KMS("Invalid request %d\n",
>   info->vbios_info.type);
> diff --git a/drivers/gpu/drm/amd/amdgpu/atom.c 
> b/drivers/gpu/drm/amd/amdgpu/atom.c
> index 3dcb8b32f48b..0e2f0ea13b40 100644
> --- a/drivers/gpu/drm/amd/amdgpu/atom.c
> +++ b/drivers/gpu/drm/amd/amdgpu/atom.c
> @@ -31,6 +31,7 @@
> 
> #define ATOM_DEBUG
> 
> +#include "atomfirmware.h"
> #include "atom.h"
> #include "atom-names.h"
> #include "atom-bits.h"
> @@ -1299,12 +1300,153 @@ static void atom_index_iio(struct atom_context *ctx, 
> int base)
>   }
> }
> 
> +static void atom_get_vbios_name(struct atom_context *ctx)
> +{
> + unsigned char *p_rom;
> + unsigned char str_num;
> + unsigned short off_to_vbios_str;
> + unsigned char *c_ptr;
> + int name_size;
> + int i;
> +
> + const char *na = "--N/A--";
> + char *back;
> +
> + p_rom = ctx->bios;
> +
> + str_num = *(p_rom + OFFSET_TO_GET_ATOMBIOS_NUMBER_OF_STRINGS);
> + if (str_num != 0) {
> + off_to_vbios_str =
> + *(unsigned short *)(p_rom + 
> OFFSET_TO_GET_ATOMBIOS_STRING_START);
> +
> + c_ptr = (unsigned char *)(p_rom + off_to_vbios_str);
> + } else {
> + /* do not know where to find name */
> + memcpy(ctx->name, na, 7);
> + ctx->name[7] = 0;
> + return;
> + }
> +
> + /*
> +  * skip the atombios strings, usually 4
> +  * 1st is P/N, 2nd is ASIC, 3rd is PCI type, 4th is Memory type
> +  */
> + for (i = 0; i < str_num; i++) {
> + while (*c_ptr != 0)
> + c_ptr++;
> + c_ptr++;
> + }
> +
> + /* skip the following 2 chars: 0x0D 0x0A */
> + c_ptr += 2;
> +
> + name_size = strnlen(c_ptr, STRLEN_LONG - 1);
> + memcpy(ctx->name, c_ptr, name_size);
> + back = ctx->name + name_size;
> + while ((*--back) == ' ')
> + ;
> + *(back + 1) = '\0';
> +}
> +
> +static void atom_get_vbios_date(struct atom_context *ctx)
> +{
> + unsigned char *p_rom;
> + unsigned char *date_in_rom;
> +
> + p_rom = ctx->bios;
> +
> + date_in_rom = p_rom + OFFSET_TO_VBIOS_DATE;
> +
> + ctx->date[0] = '2';
> + ctx->date[1] = '0';
> + ctx->date[2] = date_in_rom[6];
> + ctx->date[3] = date_in_rom[7];
> + ctx->date[4] = '/';
> + ctx->date[5] = date_in_rom[0];
> + ctx->date[6] = date_in_rom[1];
> + ctx->date[7] = '/';
> + ctx->date[8] = date_in_rom[3];
> + ctx->date[9] = date_in_rom[4];
> + ctx->date[10] = ' ';
> 

[PATCH] drm/amdgpu: Add vbios info ioctl interface

2021-04-21 Thread Jiawei Gu
Add AMDGPU_INFO_VBIOS_INFO subquery id for detailed vbios info.

Signed-off-by: Jiawei Gu 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c|  19 +++
 drivers/gpu/drm/amd/amdgpu/atom.c  | 158 +
 drivers/gpu/drm/amd/amdgpu/atom.h  |  11 ++
 drivers/gpu/drm/amd/include/atomfirmware.h |  16 ++-
 include/uapi/drm/amdgpu_drm.h  |  15 ++
 5 files changed, 213 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
index 39ee88d29cca..a20b016b05ab 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
@@ -861,6 +861,25 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, 
struct drm_file *filp)
min((size_t)size, 
(size_t)(bios_size - bios_offset)))
? -EFAULT : 0;
}
+   case AMDGPU_INFO_VBIOS_INFO: {
+   struct drm_amdgpu_info_vbios vbios_info = {};
+   struct atom_context *atom_context;
+
+   atom_context = adev->mode_info.atom_context;
+   memcpy(vbios_info.name, atom_context->name, 
sizeof(atom_context->name));
+   vbios_info.dbdf = PCI_DEVID(adev->pdev->bus->number, 
adev->pdev->devfn);
+   memcpy(vbios_info.vbios_pn, atom_context->vbios_pn, 
sizeof(atom_context->vbios_pn));
+   vbios_info.version = atom_context->version;
+   memcpy(vbios_info.date, atom_context->date, 
sizeof(atom_context->date));
+   memcpy(vbios_info.serial, adev->serial, 
sizeof(adev->serial));
+   vbios_info.dev_id = adev->pdev->device;
+   vbios_info.rev_id = adev->pdev->revision;
+   vbios_info.sub_dev_id = atom_context->sub_dev_id;
+   vbios_info.sub_ved_id = atom_context->sub_ved_id;
+
+   return copy_to_user(out, _info,
+   min((size_t)size, 
sizeof(vbios_info))) ? -EFAULT : 0;
+   }
default:
DRM_DEBUG_KMS("Invalid request %d\n",
info->vbios_info.type);
diff --git a/drivers/gpu/drm/amd/amdgpu/atom.c 
b/drivers/gpu/drm/amd/amdgpu/atom.c
index 3dcb8b32f48b..0e2f0ea13b40 100644
--- a/drivers/gpu/drm/amd/amdgpu/atom.c
+++ b/drivers/gpu/drm/amd/amdgpu/atom.c
@@ -31,6 +31,7 @@
 
 #define ATOM_DEBUG
 
+#include "atomfirmware.h"
 #include "atom.h"
 #include "atom-names.h"
 #include "atom-bits.h"
@@ -1299,12 +1300,153 @@ static void atom_index_iio(struct atom_context *ctx, 
int base)
}
 }
 
+static void atom_get_vbios_name(struct atom_context *ctx)
+{
+   unsigned char *p_rom;
+   unsigned char str_num;
+   unsigned short off_to_vbios_str;
+   unsigned char *c_ptr;
+   int name_size;
+   int i;
+
+   const char *na = "--N/A--";
+   char *back;
+
+   p_rom = ctx->bios;
+
+   str_num = *(p_rom + OFFSET_TO_GET_ATOMBIOS_NUMBER_OF_STRINGS);
+   if (str_num != 0) {
+   off_to_vbios_str =
+   *(unsigned short *)(p_rom + 
OFFSET_TO_GET_ATOMBIOS_STRING_START);
+
+   c_ptr = (unsigned char *)(p_rom + off_to_vbios_str);
+   } else {
+   /* do not know where to find name */
+   memcpy(ctx->name, na, 7);
+   ctx->name[7] = 0;
+   return;
+   }
+
+   /*
+* skip the atombios strings, usually 4
+* 1st is P/N, 2nd is ASIC, 3rd is PCI type, 4th is Memory type
+*/
+   for (i = 0; i < str_num; i++) {
+   while (*c_ptr != 0)
+   c_ptr++;
+   c_ptr++;
+   }
+
+   /* skip the following 2 chars: 0x0D 0x0A */
+   c_ptr += 2;
+
+   name_size = strnlen(c_ptr, STRLEN_LONG - 1);
+   memcpy(ctx->name, c_ptr, name_size);
+   back = ctx->name + name_size;
+   while ((*--back) == ' ')
+   ;
+   *(back + 1) = '\0';
+}
+
+static void atom_get_vbios_date(struct atom_context *ctx)
+{
+   unsigned char *p_rom;
+   unsigned char *date_in_rom;
+
+   p_rom = ctx->bios;
+
+   date_in_rom = p_rom + OFFSET_TO_VBIOS_DATE;
+
+   ctx->date[0] = '2';
+   ctx->date[1] = '0';
+   ctx->date[2] = date_in_rom[6];
+   ctx->date[3] = date_in_rom[7];
+   ctx->date[4] = '/';
+   ctx->date[5] = date_in_rom[0];
+   ctx->date[6] = date_in_rom[1];
+   ctx->date[7] = '/';
+   ctx->date[8] = date_in_rom[3];
+   ctx->date[9] = date_in_rom[4];
+   ctx->date[10] = ' ';
+   ctx->date[11] = date_in_rom[9];
+   ctx->date[12] = date_in_rom[10];
+   ctx->date[13] = date_in_rom[11];
+   ctx->date[14] = date_in_rom[12];
+   ctx->date[15] = date_in_rom[13];
+   ctx->date[16] = 

Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

2021-04-14 Thread Alex Deucher
On Wed, Apr 14, 2021 at 5:09 AM Jiawei Gu  wrote:
>
> Add AMDGPU_INFO_VBIOS_INFO subquery id for detailed vbios info.

Please provide a link to patches for an open source tool which uses
this new query.

>
> Signed-off-by: Jiawei Gu 
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c|  19 +++
>  drivers/gpu/drm/amd/amdgpu/atom.c  | 158 +
>  drivers/gpu/drm/amd/amdgpu/atom.h  |  11 ++
>  drivers/gpu/drm/amd/include/atomfirmware.h |  16 ++-
>  include/uapi/drm/amdgpu_drm.h  |  15 ++
>  5 files changed, 213 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> index 39ee88d29cca..a20b016b05ab 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> @@ -861,6 +861,25 @@ int amdgpu_info_ioctl(struct drm_device *dev, void 
> *data, struct drm_file *filp)
> min((size_t)size, 
> (size_t)(bios_size - bios_offset)))
> ? -EFAULT : 0;
> }
> +   case AMDGPU_INFO_VBIOS_INFO: {
> +   struct drm_amdgpu_info_vbios vbios_info = {};
> +   struct atom_context *atom_context;
> +
> +   atom_context = adev->mode_info.atom_context;
> +   memcpy(vbios_info.name, atom_context->name, 
> sizeof(atom_context->name));
> +   vbios_info.dbdf = PCI_DEVID(adev->pdev->bus->number, 
> adev->pdev->devfn);
> +   memcpy(vbios_info.vbios_pn, atom_context->vbios_pn, 
> sizeof(atom_context->vbios_pn));
> +   vbios_info.version = atom_context->version;
> +   memcpy(vbios_info.date, atom_context->date, 
> sizeof(atom_context->date));
> +   memcpy(vbios_info.serial, adev->serial, 
> sizeof(adev->serial));
> +   vbios_info.dev_id = adev->pdev->device;
> +   vbios_info.rev_id = adev->pdev->revision;
> +   vbios_info.sub_dev_id = atom_context->sub_dev_id;
> +   vbios_info.sub_ved_id = atom_context->sub_ved_id;
> +
> +   return copy_to_user(out, _info,
> +   min((size_t)size, 
> sizeof(vbios_info))) ? -EFAULT : 0;
> +   }
> default:
> DRM_DEBUG_KMS("Invalid request %d\n",
> info->vbios_info.type);
> diff --git a/drivers/gpu/drm/amd/amdgpu/atom.c 
> b/drivers/gpu/drm/amd/amdgpu/atom.c
> index 3dcb8b32f48b..0e2f0ea13b40 100644
> --- a/drivers/gpu/drm/amd/amdgpu/atom.c
> +++ b/drivers/gpu/drm/amd/amdgpu/atom.c
> @@ -31,6 +31,7 @@
>
>  #define ATOM_DEBUG
>
> +#include "atomfirmware.h"
>  #include "atom.h"
>  #include "atom-names.h"
>  #include "atom-bits.h"
> @@ -1299,12 +1300,153 @@ static void atom_index_iio(struct atom_context *ctx, 
> int base)
> }
>  }
>
> +static void atom_get_vbios_name(struct atom_context *ctx)
> +{
> +   unsigned char *p_rom;
> +   unsigned char str_num;
> +   unsigned short off_to_vbios_str;
> +   unsigned char *c_ptr;
> +   int name_size;
> +   int i;
> +
> +   const char *na = "--N/A--";
> +   char *back;
> +
> +   p_rom = ctx->bios;
> +
> +   str_num = *(p_rom + OFFSET_TO_GET_ATOMBIOS_NUMBER_OF_STRINGS);
> +   if (str_num != 0) {
> +   off_to_vbios_str =
> +   *(unsigned short *)(p_rom + 
> OFFSET_TO_GET_ATOMBIOS_STRING_START);
> +
> +   c_ptr = (unsigned char *)(p_rom + off_to_vbios_str);
> +   } else {
> +   /* do not know where to find name */
> +   memcpy(ctx->name, na, 7);
> +   ctx->name[7] = 0;
> +   return;
> +   }
> +
> +   /*
> +* skip the atombios strings, usually 4
> +* 1st is P/N, 2nd is ASIC, 3rd is PCI type, 4th is Memory type
> +*/
> +   for (i = 0; i < str_num; i++) {
> +   while (*c_ptr != 0)
> +   c_ptr++;
> +   c_ptr++;
> +   }
> +
> +   /* skip the following 2 chars: 0x0D 0x0A */
> +   c_ptr += 2;
> +
> +   name_size = strnlen(c_ptr, STRLEN_LONG - 1);
> +   memcpy(ctx->name, c_ptr, name_size);
> +   back = ctx->name + name_size;
> +   while ((*--back) == ' ')
> +   ;
> +   *(back + 1) = '\0';
> +}
> +
> +static void atom_get_vbios_date(struct atom_context *ctx)
> +{
> +   unsigned char *p_rom;
> +   unsigned char *date_in_rom;
> +
> +   p_rom = ctx->bios;
> +
> +   date_in_rom = p_rom + OFFSET_TO_VBIOS_DATE;
> +
> +   ctx->date[0] = '2';
> +   ctx->date[1] = '0';
> +   ctx->date[2] = date_in_rom[6];
> +   ctx->date[3] = date_in_rom[7];
> +   ctx->date[4] = '/';
> +   ctx->date[5] = date_in_rom[0];
> +   

[PATCH] drm/amdgpu: Add vbios info ioctl interface

2021-04-14 Thread Jiawei Gu
Add AMDGPU_INFO_VBIOS_INFO subquery id for detailed vbios info.

Signed-off-by: Jiawei Gu 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c|  19 +++
 drivers/gpu/drm/amd/amdgpu/atom.c  | 158 +
 drivers/gpu/drm/amd/amdgpu/atom.h  |  11 ++
 drivers/gpu/drm/amd/include/atomfirmware.h |  16 ++-
 include/uapi/drm/amdgpu_drm.h  |  15 ++
 5 files changed, 213 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
index 39ee88d29cca..a20b016b05ab 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
@@ -861,6 +861,25 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, 
struct drm_file *filp)
min((size_t)size, 
(size_t)(bios_size - bios_offset)))
? -EFAULT : 0;
}
+   case AMDGPU_INFO_VBIOS_INFO: {
+   struct drm_amdgpu_info_vbios vbios_info = {};
+   struct atom_context *atom_context;
+
+   atom_context = adev->mode_info.atom_context;
+   memcpy(vbios_info.name, atom_context->name, 
sizeof(atom_context->name));
+   vbios_info.dbdf = PCI_DEVID(adev->pdev->bus->number, 
adev->pdev->devfn);
+   memcpy(vbios_info.vbios_pn, atom_context->vbios_pn, 
sizeof(atom_context->vbios_pn));
+   vbios_info.version = atom_context->version;
+   memcpy(vbios_info.date, atom_context->date, 
sizeof(atom_context->date));
+   memcpy(vbios_info.serial, adev->serial, 
sizeof(adev->serial));
+   vbios_info.dev_id = adev->pdev->device;
+   vbios_info.rev_id = adev->pdev->revision;
+   vbios_info.sub_dev_id = atom_context->sub_dev_id;
+   vbios_info.sub_ved_id = atom_context->sub_ved_id;
+
+   return copy_to_user(out, _info,
+   min((size_t)size, 
sizeof(vbios_info))) ? -EFAULT : 0;
+   }
default:
DRM_DEBUG_KMS("Invalid request %d\n",
info->vbios_info.type);
diff --git a/drivers/gpu/drm/amd/amdgpu/atom.c 
b/drivers/gpu/drm/amd/amdgpu/atom.c
index 3dcb8b32f48b..0e2f0ea13b40 100644
--- a/drivers/gpu/drm/amd/amdgpu/atom.c
+++ b/drivers/gpu/drm/amd/amdgpu/atom.c
@@ -31,6 +31,7 @@
 
 #define ATOM_DEBUG
 
+#include "atomfirmware.h"
 #include "atom.h"
 #include "atom-names.h"
 #include "atom-bits.h"
@@ -1299,12 +1300,153 @@ static void atom_index_iio(struct atom_context *ctx, 
int base)
}
 }
 
+static void atom_get_vbios_name(struct atom_context *ctx)
+{
+   unsigned char *p_rom;
+   unsigned char str_num;
+   unsigned short off_to_vbios_str;
+   unsigned char *c_ptr;
+   int name_size;
+   int i;
+
+   const char *na = "--N/A--";
+   char *back;
+
+   p_rom = ctx->bios;
+
+   str_num = *(p_rom + OFFSET_TO_GET_ATOMBIOS_NUMBER_OF_STRINGS);
+   if (str_num != 0) {
+   off_to_vbios_str =
+   *(unsigned short *)(p_rom + 
OFFSET_TO_GET_ATOMBIOS_STRING_START);
+
+   c_ptr = (unsigned char *)(p_rom + off_to_vbios_str);
+   } else {
+   /* do not know where to find name */
+   memcpy(ctx->name, na, 7);
+   ctx->name[7] = 0;
+   return;
+   }
+
+   /*
+* skip the atombios strings, usually 4
+* 1st is P/N, 2nd is ASIC, 3rd is PCI type, 4th is Memory type
+*/
+   for (i = 0; i < str_num; i++) {
+   while (*c_ptr != 0)
+   c_ptr++;
+   c_ptr++;
+   }
+
+   /* skip the following 2 chars: 0x0D 0x0A */
+   c_ptr += 2;
+
+   name_size = strnlen(c_ptr, STRLEN_LONG - 1);
+   memcpy(ctx->name, c_ptr, name_size);
+   back = ctx->name + name_size;
+   while ((*--back) == ' ')
+   ;
+   *(back + 1) = '\0';
+}
+
+static void atom_get_vbios_date(struct atom_context *ctx)
+{
+   unsigned char *p_rom;
+   unsigned char *date_in_rom;
+
+   p_rom = ctx->bios;
+
+   date_in_rom = p_rom + OFFSET_TO_VBIOS_DATE;
+
+   ctx->date[0] = '2';
+   ctx->date[1] = '0';
+   ctx->date[2] = date_in_rom[6];
+   ctx->date[3] = date_in_rom[7];
+   ctx->date[4] = '/';
+   ctx->date[5] = date_in_rom[0];
+   ctx->date[6] = date_in_rom[1];
+   ctx->date[7] = '/';
+   ctx->date[8] = date_in_rom[3];
+   ctx->date[9] = date_in_rom[4];
+   ctx->date[10] = ' ';
+   ctx->date[11] = date_in_rom[9];
+   ctx->date[12] = date_in_rom[10];
+   ctx->date[13] = date_in_rom[11];
+   ctx->date[14] = date_in_rom[12];
+   ctx->date[15] = date_in_rom[13];
+   ctx->date[16] =