<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
</head>
<body>
Good point.<br>
<br>
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.<br>
<br>
Regards,<br>
Christian.<br>
<br>
<div class="moz-cite-prefix">Am 19.05.21 um 15:09 schrieb Deucher,
Alexander:<br>
</div>
<blockquote type="cite"
cite="mid:MN2PR12MB4488EAC16AE52CD7160D53F5F72B9@MN2PR12MB4488.namprd12.prod.outlook.com">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<style type="text/css" style="display:none;">P {margin-top:0;margin-bottom:0;}</style>
<p
style="font-family:Arial;font-size:10pt;color:#008000;margin:15pt;"
align="Left">
[Public]<br>
</p>
<br>
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
The structure is not 64 bit aligned. I think you want
something like:</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
> +struct drm_amdgpu_info_vbios {<br>
> + __u8 name[64];<br>
> + __u8 vbios_pn[64];<br>
> + __u32 version;</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
> + __u32 pad;<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
> + __u8 vbios_ver_str[32];<br>
> + __u8 date[32];<br>
> +};<br>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font style="font-size:11pt"
face="Calibri, sans-serif" color="#000000"><b>From:</b> Gu,
JiaWei (Will) <a class="moz-txt-link-rfc2396E" href="mailto:JiaWei.Gu@amd.com"><JiaWei.Gu@amd.com></a><br>
<b>Sent:</b> Tuesday, May 18, 2021 1:58 AM<br>
<b>To:</b> Nieto, David M <a class="moz-txt-link-rfc2396E" href="mailto:David.Nieto@amd.com"><David.Nieto@amd.com></a>;
Koenig, Christian <a class="moz-txt-link-rfc2396E" href="mailto:Christian.Koenig@amd.com"><Christian.Koenig@amd.com></a>;
<a class="moz-txt-link-abbreviated" href="mailto:amd-gfx@lists.freedesktop.org">amd-gfx@lists.freedesktop.org</a>
<a class="moz-txt-link-rfc2396E" href="mailto:amd-gfx@lists.freedesktop.org"><amd-gfx@lists.freedesktop.org></a>; <a class="moz-txt-link-abbreviated" href="mailto:maraeo@gmail.com">maraeo@gmail.com</a>
<a class="moz-txt-link-rfc2396E" href="mailto:maraeo@gmail.com"><maraeo@gmail.com></a>; Deucher, Alexander
<a class="moz-txt-link-rfc2396E" href="mailto:Alexander.Deucher@amd.com"><Alexander.Deucher@amd.com></a><br>
<b>Cc:</b> Deng, Emily <a class="moz-txt-link-rfc2396E" href="mailto:Emily.Deng@amd.com"><Emily.Deng@amd.com></a><br>
<b>Subject:</b> RE: [PATCH] drm/amdgpu: Add vbios info ioctl
interface</font>
<div> </div>
</div>
<style>@font-face
{font-family:"Cambria Math"}@font-face
{font-family:DengXian}@font-face
{font-family:Calibri}@font-face
{}@font-face
{font-family:"Segoe UI"}p.x_MsoNormal, li.x_MsoNormal, div.x_MsoNormal
{margin:0in;
font-size:11.0pt;
font-family:"Calibri",sans-serif}a:link, span.x_MsoHyperlink
{color:#0563C1;
text-decoration:underline}p.x_xmsonormal, li.x_xmsonormal, div.x_xmsonormal
{margin:0in;
font-size:11.0pt;
font-family:"Calibri",sans-serif}p.x_xmsipheader4d111418, li.x_xmsipheader4d111418, div.x_xmsipheader4d111418
{margin-right:0in;
margin-left:0in;
font-size:11.0pt;
font-family:"Calibri",sans-serif}span.x_EmailStyle25
{font-family:"Calibri",sans-serif;
color:windowtext}.x_MsoChpDefault
{font-size:10.0pt}div.x_WordSection1
{}</style>
<div link="#0563C1" vlink="purple" style="word-wrap:break-word"
lang="EN-US">
<p style="font-family:Arial; font-size:10pt; color:#008000;
margin:15pt" align="Left">
[Public]<br>
</p>
<br>
<div>
<div class="x_WordSection1">
<p class="x_MsoNormal">Hi all,</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">Then the struct looks like:</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">> +struct drm_amdgpu_info_vbios
{<br>
> + __u8 name[64];<br>
> + __u8 vbios_pn[64];<br>
> + __u32 version;<br>
> + __u8 vbios_ver_str[32];<br>
> + __u8 date[32];<br>
> +};</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">Sample output:</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal"><span style="font-size:10.5pt;
font-family:"Segoe UI",sans-serif">vbios
name : NAVI12 A0 XT D30501 8GB EVAL 1150e/334m HYN/SAM<br>
vbios pn : 113-D3050100-104<br>
vbios version : 285409288<br>
vbios ver_str : 017.003.000.008.016956<br>
vbios date : 2021/05/03 23:32<br>
<br>
</span></p>
<p class="x_MsoNormal">Please help double confirm that
we’re all fine with it and there’s no need to add &
remove anything.</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">Best regards,</p>
<p class="x_MsoNormal">Jiawei</p>
<p class="x_MsoNormal"> </p>
<div>
<div style="border:none; border-top:solid #E1E1E1 1.0pt;
padding:3.0pt 0in 0in 0in">
<p class="x_MsoNormal"><b>From:</b> Nieto, David M
<a class="moz-txt-link-rfc2396E" href="mailto:David.Nieto@amd.com"><David.Nieto@amd.com></a> <br>
<b>Sent:</b> Tuesday, May 18, 2021 12:40 PM<br>
<b>To:</b> Gu, JiaWei (Will)
<a class="moz-txt-link-rfc2396E" href="mailto:JiaWei.Gu@amd.com"><JiaWei.Gu@amd.com></a>; Koenig, Christian
<a class="moz-txt-link-rfc2396E" href="mailto:Christian.Koenig@amd.com"><Christian.Koenig@amd.com></a>;
<a class="moz-txt-link-abbreviated" href="mailto:amd-gfx@lists.freedesktop.org">amd-gfx@lists.freedesktop.org</a>; <a class="moz-txt-link-abbreviated" href="mailto:maraeo@gmail.com">maraeo@gmail.com</a>;
Deucher, Alexander <a class="moz-txt-link-rfc2396E" href="mailto:Alexander.Deucher@amd.com"><Alexander.Deucher@amd.com></a><br>
<b>Cc:</b> Deng, Emily <a class="moz-txt-link-rfc2396E" href="mailto:Emily.Deng@amd.com"><Emily.Deng@amd.com></a><br>
<b>Subject:</b> Re: [PATCH] drm/amdgpu: Add vbios
info ioctl interface</p>
</div>
</div>
<p class="x_MsoNormal"> </p>
<p style="margin:15.0pt"><span style="font-size:10.0pt;
font-family:"Arial",sans-serif; color:green">[Public]</span></p>
<p class="x_MsoNormal"> </p>
<div>
<div>
<p class="x_MsoNormal" style="background:white"><span
style="font-size:12.0pt; color:black">Yes, let's
remove that too,</span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span
style="font-size:12.0pt; color:black"> </span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span
style="font-size:12.0pt; color:black">Thanks,</span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span
style="font-size:12.0pt; color:black"> </span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span
style="font-size:12.0pt; color:black">David</span></p>
</div>
<div class="x_MsoNormal" style="text-align:center"
align="center">
<hr width="98%" size="2" align="center">
</div>
<div id="x_divRplyFwdMsg">
<p class="x_MsoNormal"><b><span style="color:black">From:</span></b><span
style="color:black"> Gu, JiaWei (Will) <<a
href="mailto:JiaWei.Gu@amd.com"
moz-do-not-send="true">JiaWei.Gu@amd.com</a>><br>
<b>Sent:</b> Monday, May 17, 2021 8:07 PM<br>
<b>To:</b> Nieto, David M <<a
href="mailto:David.Nieto@amd.com"
moz-do-not-send="true">David.Nieto@amd.com</a>>;
Koenig, Christian <<a
href="mailto:Christian.Koenig@amd.com"
moz-do-not-send="true">Christian.Koenig@amd.com</a>>;
<a href="mailto:amd-gfx@lists.freedesktop.org"
moz-do-not-send="true">amd-gfx@lists.freedesktop.org</a>
<<a href="mailto:amd-gfx@lists.freedesktop.org"
moz-do-not-send="true">amd-gfx@lists.freedesktop.org</a>>;
<a href="mailto:maraeo@gmail.com"
moz-do-not-send="true">maraeo@gmail.com</a> <<a
href="mailto:maraeo@gmail.com"
moz-do-not-send="true">maraeo@gmail.com</a>>;
Deucher, Alexander <<a
href="mailto:Alexander.Deucher@amd.com"
moz-do-not-send="true">Alexander.Deucher@amd.com</a>><br>
<b>Cc:</b> Deng, Emily <<a
href="mailto:Emily.Deng@amd.com"
moz-do-not-send="true">Emily.Deng@amd.com</a>><br>
<b>Subject:</b> RE: [PATCH] drm/amdgpu: Add vbios
info ioctl interface</span> </p>
<div>
<p class="x_MsoNormal"> </p>
</div>
</div>
<div>
<div>
<p class="x_xmsipheader4d111418" style="margin:0in"><span
style="font-family:"Arial",sans-serif;
color:#0078D7">[AMD Official Use Only - Internal
Distribution Only]</span></p>
<p class="x_xmsonormal"> </p>
<p class="x_xmsonormal">OK let’s remove serial.</p>
<p class="x_xmsonormal"> </p>
<p class="x_xmsonormal">dbdf comes from this: </p>
<p class="x_xmsonormal">vbios_info.dbdf =
PCI_DEVID(adev->pdev->bus->number,
adev->pdev->devfn);</p>
<p class="x_xmsonormal"> </p>
<p class="x_xmsonormal">I think we can remove dbdf
as well.</p>
<p class="x_xmsonormal"> </p>
<p class="x_xmsonormal">Best regards,</p>
<p class="x_xmsonormal">Jiawei</p>
<p class="x_xmsonormal"> </p>
<div>
<div style="border:none; border-top:solid #E1E1E1
1.0pt; padding:3.0pt 0in 0in 0in">
<p class="x_xmsonormal"><b>From:</b> Nieto,
David M <<a
href="mailto:David.Nieto@amd.com"
moz-do-not-send="true">David.Nieto@amd.com</a>>
<br>
<b>Sent:</b> Tuesday, May 18, 2021 10:45 AM<br>
<b>To:</b> Gu, JiaWei (Will) <<a
href="mailto:JiaWei.Gu@amd.com"
moz-do-not-send="true">JiaWei.Gu@amd.com</a>>;
Koenig, Christian <<a
href="mailto:Christian.Koenig@amd.com"
moz-do-not-send="true">Christian.Koenig@amd.com</a>>;
<a href="mailto:amd-gfx@lists.freedesktop.org"
moz-do-not-send="true">amd-gfx@lists.freedesktop.org</a>;
<a href="mailto:maraeo@gmail.com"
moz-do-not-send="true">maraeo@gmail.com</a>;
Deucher, Alexander <<a
href="mailto:Alexander.Deucher@amd.com"
moz-do-not-send="true">Alexander.Deucher@amd.com</a>><br>
<b>Cc:</b> Deng, Emily <<a
href="mailto:Emily.Deng@amd.com"
moz-do-not-send="true">Emily.Deng@amd.com</a>><br>
<b>Subject:</b> Re: [PATCH] drm/amdgpu: Add
vbios info ioctl interface</p>
</div>
</div>
<p class="x_xmsonormal"> </p>
<p style="margin:5.0pt"><span
style="font-family:"Arial",sans-serif;
color:#0078D7">[AMD Official Use Only - Internal
Distribution Only]</span></p>
<p class="x_xmsonormal"> </p>
<div>
<div>
<p class="x_xmsonormal" style="background:white"><span
style="font-size:12.0pt; color:black">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.</span></p>
</div>
<div>
<p class="x_xmsonormal" style="background:white"><span
style="font-size:12.0pt; color:black"> </span></p>
</div>
<div>
<p class="x_xmsonormal" style="background:white"><span
style="font-size:12.0pt; color:black">Not
sure what dbdf stands for.</span></p>
</div>
<div class="x_MsoNormal" style="text-align:center"
align="center">
<hr width="98%" size="2" align="center">
</div>
<div id="x_x_divRplyFwdMsg">
<p class="x_xmsonormal"><b><span
style="color:black">From:</span></b><span
style="color:black"> Gu, JiaWei (Will) <<a
href="mailto:JiaWei.Gu@amd.com"
moz-do-not-send="true">JiaWei.Gu@amd.com</a>><br>
<b>Sent:</b> Monday, May 17, 2021 7:11 PM<br>
<b>To:</b> Koenig, Christian <<a
href="mailto:Christian.Koenig@amd.com"
moz-do-not-send="true">Christian.Koenig@amd.com</a>>;
<a
href="mailto:amd-gfx@lists.freedesktop.org"
moz-do-not-send="true">amd-gfx@lists.freedesktop.org</a>
<<a
href="mailto:amd-gfx@lists.freedesktop.org"
moz-do-not-send="true">amd-gfx@lists.freedesktop.org</a>>;
Nieto, David M <<a
href="mailto:David.Nieto@amd.com"
moz-do-not-send="true">David.Nieto@amd.com</a>>;
<a href="mailto:maraeo@gmail.com"
moz-do-not-send="true">maraeo@gmail.com</a>
<<a href="mailto:maraeo@gmail.com"
moz-do-not-send="true">maraeo@gmail.com</a>>;
Deucher, Alexander <<a
href="mailto:Alexander.Deucher@amd.com"
moz-do-not-send="true">Alexander.Deucher@amd.com</a>><br>
<b>Cc:</b> Deng, Emily <<a
href="mailto:Emily.Deng@amd.com"
moz-do-not-send="true">Emily.Deng@amd.com</a>><br>
<b>Subject:</b> RE: [PATCH] drm/amdgpu: Add
vbios info ioctl interface</span> </p>
<div>
<p class="x_xmsonormal"> </p>
</div>
</div>
<div>
<div>
<p class="x_xmsonormal">[AMD Official Use Only
- Internal Distribution Only]<br>
<br>
So I guess the dbdf is also needed to be
removed?<br>
And how about serial?<br>
<br>
> +struct drm_amdgpu_info_vbios {<br>
> + __u8 name[64];<br>
> + __u32 dbdf; // do we need this?<br>
> + __u8 vbios_pn[64];<br>
> + __u32 version;<br>
> + __u8 vbios_ver_str[32];<br>
> + __u8 date[32];<br>
> + __u64 serial; // do we need this?<br>
> +};<br>
<br>
Best regards,<br>
Jiawei<br>
<br>
-----Original Message-----<br>
From: Koenig, Christian <<a
href="mailto:Christian.Koenig@amd.com"
moz-do-not-send="true">Christian.Koenig@amd.com</a>>
<br>
Sent: Monday, May 17, 2021 8:26 PM<br>
To: Gu, JiaWei (Will) <<a
href="mailto:JiaWei.Gu@amd.com"
moz-do-not-send="true">JiaWei.Gu@amd.com</a>>;
<a
href="mailto:amd-gfx@lists.freedesktop.org"
moz-do-not-send="true">amd-gfx@lists.freedesktop.org</a>;
Nieto, David M <<a
href="mailto:David.Nieto@amd.com"
moz-do-not-send="true">David.Nieto@amd.com</a>>;
<a href="mailto:maraeo@gmail.com"
moz-do-not-send="true">maraeo@gmail.com</a>;
Deucher, Alexander <<a
href="mailto:Alexander.Deucher@amd.com"
moz-do-not-send="true">Alexander.Deucher@amd.com</a>><br>
Cc: Deng, Emily <<a
href="mailto:Emily.Deng@amd.com"
moz-do-not-send="true">Emily.Deng@amd.com</a>><br>
Subject: Re: [PATCH] drm/amdgpu: Add vbios
info ioctl interface<br>
<br>
I'm not very familiar with the technical
background why we have the fields here once
more.<br>
<br>
But of hand we should at least remove
everything which is also available from the
PCI information.<br>
<br>
E.g. dev_id, rev_id, sub_dev_id, sub_ved_id.<br>
<br>
Regards,<br>
Christian.<br>
<br>
Am 17.05.21 um 14:17 schrieb Gu, JiaWei
(Will):<br>
> [AMD Official Use Only - Internal
Distribution Only]<br>
><br>
> Hi all,<br>
><br>
> Thanks Christian's suggestion.<br>
> I reverted the previous patches and
squash them into this single one.<br>
><br>
> As this patch shows, the current uapi
change looks like this:<br>
><br>
> +struct drm_amdgpu_info_vbios {<br>
> + __u8 name[64];<br>
> + __u32 dbdf;<br>
> + __u8 vbios_pn[64];<br>
> + __u32 version;<br>
> + __u8 vbios_ver_str[32];<br>
> + __u8 date[32];<br>
> + __u64 serial;<br>
> + __u32 dev_id;<br>
> + __u32 rev_id;<br>
> + __u32 sub_dev_id;<br>
> + __u32 sub_ved_id;<br>
> +};<br>
><br>
> As we know there's some redundant info
in this struct.<br>
> Please feel free to give any comments
or suggestion about what it should &
shouldn't include.<br>
><br>
> Best regards,<br>
> Jiawei<br>
><br>
> -----Original Message-----<br>
> From: Jiawei Gu <<a
href="mailto:Jiawei.Gu@amd.com"
moz-do-not-send="true">Jiawei.Gu@amd.com</a>><br>
> Sent: Monday, May 17, 2021 8:08 PM<br>
> To: <a
href="mailto:amd-gfx@lists.freedesktop.org"
moz-do-not-send="true">amd-gfx@lists.freedesktop.org</a>;
Koenig, Christian
<br>
> <<a
href="mailto:Christian.Koenig@amd.com"
moz-do-not-send="true">Christian.Koenig@amd.com</a>>;
Nieto, David M <<a
href="mailto:David.Nieto@amd.com"
moz-do-not-send="true">David.Nieto@amd.com</a>>;
<br>
> <a href="mailto:maraeo@gmail.com"
moz-do-not-send="true">maraeo@gmail.com</a>;
Deucher, Alexander <<a
href="mailto:Alexander.Deucher@amd.com"
moz-do-not-send="true">Alexander.Deucher@amd.com</a>><br>
> Cc: Deng, Emily <<a
href="mailto:Emily.Deng@amd.com"
moz-do-not-send="true">Emily.Deng@amd.com</a>>;
Gu, JiaWei (Will)
<br>
> <<a href="mailto:JiaWei.Gu@amd.com"
moz-do-not-send="true">JiaWei.Gu@amd.com</a>><br>
> Subject: [PATCH] drm/amdgpu: Add vbios
info ioctl interface<br>
><br>
> Add AMDGPU_INFO_VBIOS_INFO subquery id
for detailed vbios info.<br>
><br>
> Provides a way for the user application
to get the VBIOS information without having
to parse the binary.<br>
> 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.<br>
><br>
> V2:<br>
> Use numeric serial.<br>
> Parse and expose vbios version string.<br>
><br>
> Signed-off-by: Jiawei Gu <<a
href="mailto:Jiawei.Gu@amd.com"
moz-do-not-send="true">Jiawei.Gu@amd.com</a>><br>
> Acked-by: Christian König <<a
href="mailto:christian.koenig@amd.com"
moz-do-not-send="true">christian.koenig@amd.com</a>><br>
> ---<br>
>
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
| 21 +++<br>
>
drivers/gpu/drm/amd/amdgpu/atom.c |
174 +++++++++++++++++++++<br>
>
drivers/gpu/drm/amd/amdgpu/atom.h
| 12 ++<br>
>
drivers/gpu/drm/amd/include/atomfirmware.h
| 5 +<br>
>
include/uapi/drm/amdgpu_drm.h
| 16 ++<br>
> 5 files changed, 228 insertions(+)<br>
><br>
> diff --git
a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c <br>
>
b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c<br>
> index 8d12e474745a..30e4fed3de22 100644<br>
> ---
a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c<br>
> +++
b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c<br>
> @@ -861,6 +861,27 @@ int
amdgpu_info_ioctl(struct drm_device *dev,
void *data, struct drm_file *filp)<br>
> min((size_t)size,
(size_t)(bios_size - bios_offset)))<br>
>
? -EFAULT : 0;<br>
> }<br>
> + case
AMDGPU_INFO_VBIOS_INFO: {<br>
> + struct
drm_amdgpu_info_vbios vbios_info = {};<br>
> + struct
atom_context *atom_context;<br>
> +<br>
> + atom_context =
adev->mode_info.atom_context;<br>
> +
memcpy(vbios_info.name,
atom_context->name,
sizeof(atom_context->name));<br>
> + vbios_info.dbdf =
PCI_DEVID(adev->pdev->bus->number,
adev->pdev->devfn);<br>
> +
memcpy(vbios_info.vbios_pn,
atom_context->vbios_pn,
sizeof(atom_context->vbios_pn));<br>
> +
vbios_info.version =
atom_context->version;<br>
> +
memcpy(vbios_info.vbios_ver_str,
atom_context->vbios_ver_str,<br>
>
+
sizeof(atom_context->vbios_ver_str));<br>
> +
memcpy(vbios_info.date,
atom_context->date,
sizeof(atom_context->date));<br>
> + vbios_info.serial
= adev->unique_id;<br>
> + vbios_info.dev_id
= adev->pdev->device;<br>
> + vbios_info.rev_id
= adev->pdev->revision;<br>
> +
vbios_info.sub_dev_id =
atom_context->sub_dev_id;<br>
> +
vbios_info.sub_ved_id =
atom_context->sub_ved_id;<br>
> +<br>
> + return
copy_to_user(out, &vbios_info,<br>
>
+
min((size_t)size, sizeof(vbios_info))) ?
-EFAULT : 0;<br>
> + }<br>
> default:<br>
>
DRM_DEBUG_KMS("Invalid request %d\n",<br>
>
info->vbios_info.type);<br>
> diff --git
a/drivers/gpu/drm/amd/amdgpu/atom.c <br>
> b/drivers/gpu/drm/amd/amdgpu/atom.c<br>
> index 3dcb8b32f48b..542b2c2414e4 100644<br>
> --- a/drivers/gpu/drm/amd/amdgpu/atom.c<br>
> +++ b/drivers/gpu/drm/amd/amdgpu/atom.c<br>
> @@ -31,6 +31,7 @@<br>
> <br>
> #define ATOM_DEBUG<br>
> <br>
> +#include "atomfirmware.h"<br>
> #include "atom.h"<br>
> #include "atom-names.h"<br>
> #include "atom-bits.h"<br>
> @@ -1299,12 +1300,168 @@ static void
atom_index_iio(struct atom_context *ctx, int
base)<br>
> }<br>
> }<br>
> <br>
> +static void atom_get_vbios_name(struct
atom_context *ctx) {<br>
> + unsigned char *p_rom;<br>
> + unsigned char str_num;<br>
> + unsigned short off_to_vbios_str;<br>
> + unsigned char *c_ptr;<br>
> + int name_size;<br>
> + int i;<br>
> +<br>
> + const char *na = "--N/A--";<br>
> + char *back;<br>
> +<br>
> + p_rom = ctx->bios;<br>
> +<br>
> + str_num = *(p_rom +
OFFSET_TO_GET_ATOMBIOS_NUMBER_OF_STRINGS);<br>
> + if (str_num != 0) {<br>
> + off_to_vbios_str =<br>
> + *(unsigned short
*)(p_rom +
OFFSET_TO_GET_ATOMBIOS_STRING_START);<br>
> +<br>
> + c_ptr = (unsigned char
*)(p_rom + off_to_vbios_str);<br>
> + } else {<br>
> + /* do not know where to
find name */<br>
> + memcpy(ctx->name, na,
7);<br>
> + ctx->name[7] = 0;<br>
> + return;<br>
> + }<br>
> +<br>
> + /*<br>
> + * skip the atombios strings,
usually 4<br>
> + * 1st is P/N, 2nd is ASIC, 3rd
is PCI type, 4th is Memory type<br>
> + */<br>
> + for (i = 0; i < str_num; i++)
{<br>
> + while (*c_ptr != 0)<br>
> + c_ptr++;<br>
> + c_ptr++;<br>
> + }<br>
> +<br>
> + /* skip the following 2 chars:
0x0D 0x0A */<br>
> + c_ptr += 2;<br>
> +<br>
> + name_size = strnlen(c_ptr,
STRLEN_LONG - 1);<br>
> + memcpy(ctx->name, c_ptr,
name_size);<br>
> + back = ctx->name + name_size;<br>
> + while ((*--back) == ' ')<br>
> + ;<br>
> + *(back + 1) = '\0';<br>
> +}<br>
> +<br>
> +static void atom_get_vbios_date(struct
atom_context *ctx) {<br>
> + unsigned char *p_rom;<br>
> + unsigned char *date_in_rom;<br>
> +<br>
> + p_rom = ctx->bios;<br>
> +<br>
> + date_in_rom = p_rom +
OFFSET_TO_VBIOS_DATE;<br>
> +<br>
> + ctx->date[0] = '2';<br>
> + ctx->date[1] = '0';<br>
> + ctx->date[2] = date_in_rom[6];<br>
> + ctx->date[3] = date_in_rom[7];<br>
> + ctx->date[4] = '/';<br>
> + ctx->date[5] = date_in_rom[0];<br>
> + ctx->date[6] = date_in_rom[1];<br>
> + ctx->date[7] = '/';<br>
> + ctx->date[8] = date_in_rom[3];<br>
> + ctx->date[9] = date_in_rom[4];<br>
> + ctx->date[10] = ' ';<br>
> + ctx->date[11] =
date_in_rom[9];<br>
> + ctx->date[12] =
date_in_rom[10];<br>
> + ctx->date[13] =
date_in_rom[11];<br>
> + ctx->date[14] =
date_in_rom[12];<br>
> + ctx->date[15] =
date_in_rom[13];<br>
> + ctx->date[16] = '\0';<br>
> +}<br>
> +<br>
> +static unsigned char
*atom_find_str_in_rom(struct atom_context
*ctx, char *str, int start,<br>
>
+ int
end, int maxlen)<br>
> +{<br>
> + unsigned long str_off;<br>
> + unsigned char *p_rom;<br>
> + unsigned short str_len;<br>
> +<br>
> + str_off = 0;<br>
> + str_len = strnlen(str, maxlen);<br>
> + p_rom = ctx->bios;<br>
> +<br>
> + for (; start <= end; ++start)
{<br>
> + for (str_off = 0; str_off
< str_len; ++str_off) {<br>
> + if (str[str_off]
!= *(p_rom + start + str_off))<br>
> + break;<br>
> + }<br>
> +<br>
> + if (str_off == str_len ||
str[str_off] == 0)<br>
> + return p_rom +
start;<br>
> + }<br>
> + return NULL;<br>
> +}<br>
> +<br>
> +static void atom_get_vbios_pn(struct
atom_context *ctx) {<br>
> + unsigned char *p_rom;<br>
> + unsigned short off_to_vbios_str;<br>
> + unsigned char *vbios_str;<br>
> + int count;<br>
> +<br>
> + off_to_vbios_str = 0;<br>
> + p_rom = ctx->bios;<br>
> +<br>
> + if (*(p_rom +
OFFSET_TO_GET_ATOMBIOS_NUMBER_OF_STRINGS) !=
0) {<br>
> + off_to_vbios_str =<br>
> + *(unsigned short
*)(p_rom +
OFFSET_TO_GET_ATOMBIOS_STRING_START);<br>
> +<br>
> + vbios_str = (unsigned
char *)(p_rom + off_to_vbios_str);<br>
> + } else {<br>
> + vbios_str = p_rom +
OFFSET_TO_VBIOS_PART_NUMBER;<br>
> + }<br>
> +<br>
> + if (*vbios_str == 0) {<br>
> + vbios_str =
atom_find_str_in_rom(ctx, BIOS_ATOM_PREFIX,
3, 1024, 64);<br>
> + if (vbios_str == NULL)<br>
> + vbios_str +=
sizeof(BIOS_ATOM_PREFIX) - 1;<br>
> + }<br>
> + if (vbios_str != NULL &&
*vbios_str == 0)<br>
> + vbios_str++;<br>
> +<br>
> + if (vbios_str != NULL) {<br>
> + count = 0;<br>
> + while ((count <
BIOS_STRING_LENGTH) &&
vbios_str[count] >= ' ' &&<br>
> + vbios_str[count]
<= 'z') {<br>
> +
ctx->vbios_pn[count] = vbios_str[count];<br>
> + count++;<br>
> + }<br>
> +<br>
> + ctx->vbios_pn[count] =
0;<br>
> + }<br>
> +}<br>
> +<br>
> +static void
atom_get_vbios_version(struct atom_context
*ctx) {<br>
> + unsigned char *vbios_ver;<br>
> +<br>
> + /* find anchor ATOMBIOSBK-AMD */<br>
> + vbios_ver =
atom_find_str_in_rom(ctx,
BIOS_VERSION_PREFIX, 3, 1024, 64);<br>
> + if (vbios_ver != NULL) {<br>
> + /* skip ATOMBIOSBK-AMD
VER */<br>
> + vbios_ver += 18;<br>
> +
memcpy(ctx->vbios_ver_str, vbios_ver,
STRLEN_NORMAL);<br>
> + } else {<br>
> + ctx->vbios_ver_str[0]
= '\0';<br>
> + }<br>
> +}<br>
> +<br>
> struct atom_context
*amdgpu_atom_parse(struct card_info *card,
void *bios) {<br>
> int base;<br>
> struct atom_context *ctx =<br>
> kzalloc(sizeof(struct
atom_context), GFP_KERNEL);<br>
> char *str;<br>
> + struct _ATOM_ROM_HEADER
*atom_rom_header;<br>
> + struct _ATOM_MASTER_DATA_TABLE
*master_table;<br>
> + struct _ATOM_FIRMWARE_INFO
*atom_fw_info;<br>
> u16 idx;<br>
> <br>
> if (!ctx)<br>
> @@ -1353,6 +1510,23 @@ struct
atom_context *amdgpu_atom_parse(struct
card_info *card, void *bios)<br>
>
strlcpy(ctx->vbios_version, str,
sizeof(ctx->vbios_version));<br>
> }<br>
> <br>
> + atom_rom_header = (struct
_ATOM_ROM_HEADER *)CSTR(base);<br>
> + ctx->sub_dev_id =
atom_rom_header->usSubsystemVendorID;<br>
> + ctx->sub_ved_id =
atom_rom_header->usSubsystemID;<br>
> + if
(atom_rom_header->usMasterDataTableOffset
!= 0) {<br>
> + master_table = (struct
_ATOM_MASTER_DATA_TABLE *)<br>
> +
CSTR(atom_rom_header->usMasterDataTableOffset);<br>
> + if
(master_table->ListOfDataTables.FirmwareInfo
!= 0) {<br>
> + atom_fw_info =
(struct _ATOM_FIRMWARE_INFO *)<br>
> +
CSTR(master_table->ListOfDataTables.FirmwareInfo);<br>
> + ctx->version =
atom_fw_info->ulFirmwareRevision;<br>
> + }<br>
> + }<br>
> +<br>
> + atom_get_vbios_name(ctx);<br>
> + atom_get_vbios_pn(ctx);<br>
> + atom_get_vbios_date(ctx);<br>
> + atom_get_vbios_version(ctx);<br>
> <br>
> return ctx;<br>
> }<br>
> diff --git
a/drivers/gpu/drm/amd/amdgpu/atom.h <br>
> b/drivers/gpu/drm/amd/amdgpu/atom.h<br>
> index d279759cab47..6463ce6e756d 100644<br>
> --- a/drivers/gpu/drm/amd/amdgpu/atom.h<br>
> +++ b/drivers/gpu/drm/amd/amdgpu/atom.h<br>
> @@ -112,6 +112,10 @@ struct drm_device;<br>
> #define ATOM_IO_SYSIO 2<br>
> #define ATOM_IO_IIO 0x80<br>
> <br>
> +#define STRLEN_NORMAL
32<br>
> +#define STRLEN_LONG 64<br>
> +#define STRLEN_VERYLONG
254<br>
> +<br>
> struct card_info {<br>
> struct drm_device *dev;<br>
> void (* reg_write)(struct
card_info *, uint32_t, uint32_t); /*
filled by driver */<br>
> @@ -140,6 +144,14 @@ struct
atom_context {<br>
> uint32_t *scratch;<br>
> int scratch_size_bytes;<br>
> char vbios_version[20];<br>
> +<br>
> + uint8_t name[STRLEN_LONG];<br>
> + uint8_t vbios_pn[STRLEN_LONG];<br>
> + uint32_t version;<br>
> + uint8_t
vbios_ver_str[STRLEN_NORMAL];<br>
> + uint8_t date[STRLEN_NORMAL];<br>
> + uint32_t sub_dev_id;<br>
> + uint32_t sub_ved_id;<br>
> };<br>
> <br>
> extern int amdgpu_atom_debug;<br>
> diff --git
a/drivers/gpu/drm/amd/include/atomfirmware.h
<br>
>
b/drivers/gpu/drm/amd/include/atomfirmware.h<br>
> index 275468e4be60..28deecc2f990 100644<br>
> ---
a/drivers/gpu/drm/amd/include/atomfirmware.h<br>
> +++
b/drivers/gpu/drm/amd/include/atomfirmware.h<br>
> @@ -197,6 +197,9 @@ enum
atom_dp_vs_preemph_def{<br>
> DP_VS_LEVEL0_PREEMPH_LEVEL3 = 0x18,<br>
> };<br>
> <br>
> +#define BIOS_ATOM_PREFIX "ATOMBIOS"<br>
> +#define BIOS_VERSION_PREFIX
"ATOMBIOSBK-AMD"<br>
> +#define BIOS_STRING_LENGTH 43<br>
> <br>
> /*<br>
> enum atom_string_def{<br>
> @@ -215,6 +218,8 @@ enum
atombios_image_offset{<br>
>
MAXSIZE_OF_ATOMBIOS_ASIC_BUS_MEM_TYPE =
20, /*including the terminator 0x0!*/<br>
>
OFFSET_TO_GET_ATOMBIOS_NUMBER_OF_STRINGS =
0x2f,<br>
>
OFFSET_TO_GET_ATOMBIOS_STRING_START =
0x6e,<br>
> +
OFFSET_TO_VBIOS_PART_NUMBER =
0x80,<br>
> +
OFFSET_TO_VBIOS_DATE =
0x50,<br>
> };<br>
> <br>
> <br>
>
/*********************************************************************<br>
> ******* diff --git
a/include/uapi/drm/amdgpu_drm.h <br>
> b/include/uapi/drm/amdgpu_drm.h index
9169df7fadee..e0f98ca9a755 <br>
> 100644<br>
> --- a/include/uapi/drm/amdgpu_drm.h<br>
> +++ b/include/uapi/drm/amdgpu_drm.h<br>
> @@ -756,6 +756,8 @@ struct
drm_amdgpu_cs_chunk_data {<br>
> #define
AMDGPU_INFO_VBIOS_SIZE 0x1<br>
> /* Subquery id: Query vbios
image */<br>
> #define
AMDGPU_INFO_VBIOS_IMAGE 0x2<br>
> + /* Subquery id: Query vbios info
*/<br>
> + #define
AMDGPU_INFO_VBIOS_INFO 0x3<br>
> /* Query UVD handles */<br>
> #define
AMDGPU_INFO_NUM_HANDLES
0x1C<br>
> /* Query sensor related information
*/ @@ -949,6 +951,20 @@ struct <br>
> drm_amdgpu_info_firmware {<br>
> __u32 feature;<br>
> };<br>
> <br>
> +struct drm_amdgpu_info_vbios {<br>
> + __u8 name[64];<br>
> + __u32 dbdf;<br>
> + __u8 vbios_pn[64];<br>
> + __u32 version;<br>
> + __u8 vbios_ver_str[32];<br>
> + __u8 date[32];<br>
> + __u64 serial;<br>
> + __u32 dev_id;<br>
> + __u32 rev_id;<br>
> + __u32 sub_dev_id;<br>
> + __u32 sub_ved_id;<br>
> +};<br>
> +<br>
> #define AMDGPU_VRAM_TYPE_UNKNOWN 0<br>
> #define AMDGPU_VRAM_TYPE_GDDR1 1<br>
> #define AMDGPU_VRAM_TYPE_DDR2 2<br>
> --<br>
> 2.17.1</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
amd-gfx mailing list
<a class="moz-txt-link-abbreviated" href="mailto:amd-gfx@lists.freedesktop.org">amd-gfx@lists.freedesktop.org</a>
<a class="moz-txt-link-freetext" href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a>
</pre>
</blockquote>
<br>
</body>
</html>