<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
{font-family:SimSun;
panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:"\@SimSun";
panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
font-size:12.0pt;
font-family:SimSun;
mso-fareast-language:ZH-CN;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
span.EmailStyle20
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;
mso-ligatures:none;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72" style="word-wrap:break-word">
<p style="font-family:Arial;font-size:10pt;color:#0000FF;margin:5pt;font-style:normal;font-weight:normal;text-decoration:none;" align="Left">
[AMD Official Use Only - General]<br>
</p>
<br>
<div>
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;mso-fareast-language:EN-US">Reviewed-by: Asad Kamal
<a href="mailto:asad.kamal@amd.com">asad.kamal@amd.com</a><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;mso-fareast-language:EN-US">Thanks & Regards<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;mso-fareast-language:EN-US">Asad<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> amd-gfx <amd-gfx-bounces@lists.freedesktop.org>
<b>On Behalf Of </b>Wang, Yang(Kevin)<br>
<b>Sent:</b> Friday, August 25, 2023 4:46 PM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org; Lazar, Lijo <Lijo.Lazar@amd.com><br>
<b>Cc:</b> Deucher, Alexander <Alexander.Deucher@amd.com>; Zhang, Hawking <Hawking.Zhang@amd.com><br>
<b>Subject:</b> Re: [PATCH] drm/amdgpu: Add only valid firmware version nodes<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p style="margin:5.0pt"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:blue">[AMD Official Use Only - General]<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p style="margin:5.0pt"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:blue">[AMD Official Use Only - General]<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal">Reviewed-by: Yang Wang <<a href="mailto:kevinyang.wang@amd.com">kevinyang.wang@amd.com</a>><o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Best Regards,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Kevin<o:p></o:p></p>
</div>
<div id="mail-editor-reference-message-container">
<div class="MsoNormal" align="center" style="text-align:center">
<hr size="2" width="98%" align="center">
</div>
<div id="divRplyFwdMsg">
<p class="MsoNormal"><b><span lang="ZH-CN">发件人</span></b><b><span style="font-family:"Calibri",sans-serif">:</span></b><span style="font-family:"Calibri",sans-serif"> amd-gfx <<a href="mailto:amd-gfx-bounces@lists.freedesktop.org">amd-gfx-bounces@lists.freedesktop.org</a>>
</span><span lang="ZH-CN">代表</span><span style="font-family:"Calibri",sans-serif"> Lijo Lazar <<a href="mailto:lijo.lazar@amd.com">lijo.lazar@amd.com</a>><br>
</span><b><span lang="ZH-CN">发送时间</span></b><b><span style="font-family:"Calibri",sans-serif">:</span></b><span style="font-family:"Calibri",sans-serif">
</span><span lang="ZH-CN">星期五</span><span style="font-family:"Calibri",sans-serif">,
</span><span lang="ZH-CN">八月</span><span style="font-family:"Calibri",sans-serif"> 25, 2023 17:29<br>
</span><b><span lang="ZH-CN">收件人</span></b><b><span style="font-family:"Calibri",sans-serif">:</span></b><span style="font-family:"Calibri",sans-serif">
<a href="mailto:amd-gfx@lists.freedesktop.org">amd-gfx@lists.freedesktop.org</a> <<a href="mailto:amd-gfx@lists.freedesktop.org">amd-gfx@lists.freedesktop.org</a>><br>
</span><b><span lang="ZH-CN">抄送</span></b><b><span style="font-family:"Calibri",sans-serif">:</span></b><span style="font-family:"Calibri",sans-serif"> Deucher, Alexander <<a href="mailto:Alexander.Deucher@amd.com">Alexander.Deucher@amd.com</a>>; Zhang, Hawking
<<a href="mailto:Hawking.Zhang@amd.com">Hawking.Zhang@amd.com</a>><br>
</span><b><span lang="ZH-CN">主题</span></b><b><span style="font-family:"Calibri",sans-serif">:</span></b><span style="font-family:"Calibri",sans-serif"> [PATCH] drm/amdgpu: Add only valid firmware version nodes
<o:p></o:p></span></p>
<div>
<p class="MsoNormal"><span style="font-family:"Calibri",sans-serif"> <o:p></o:p></span></p>
</div>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-size:11.0pt">Show only firmware version attributes that have valid version. Hide<br>
others.<br>
<br>
Signed-off-by: Lijo Lazar <<a href="mailto:lijo.lazar@amd.com">lijo.lazar@amd.com</a>><br>
---<br>
drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c | 33 ++++++++++++++++++++---<br>
1 file changed, 29 insertions(+), 4 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c<br>
index 8beefc045e14..b0b37c056c36 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c<br>
@@ -669,15 +669,25 @@ const char *amdgpu_ucode_name(enum AMDGPU_UCODE_ID ucode_id)<br>
}<br>
}<br>
<br>
+static inline int amdgpu_ucode_is_valid(uint32_t fw_version)<br>
+{<br>
+ if (!fw_version)<br>
+ return -EINVAL;<br>
+<br>
+ return 0;<br>
+}<br>
+<br>
#define FW_VERSION_ATTR(name, mode, field) \<br>
static ssize_t show_##name(struct device *dev, \<br>
- struct device_attribute *attr, \<br>
- char *buf) \<br>
+ struct device_attribute *attr, char *buf) \<br>
{ \<br>
struct drm_device *ddev = dev_get_drvdata(dev); \<br>
struct amdgpu_device *adev = drm_to_adev(ddev); \<br>
\<br>
- return sysfs_emit(buf, "0x%08x\n", adev->field); \<br>
+ if (!buf) \<br>
+ return amdgpu_ucode_is_valid(adev->field); \<br>
+ \<br>
+ return sysfs_emit(buf, "0x%08x\n", adev->field); \<br>
} \<br>
static DEVICE_ATTR(name, mode, show_##name, NULL)<br>
<br>
@@ -722,9 +732,24 @@ static struct attribute *fw_attrs[] = {<br>
NULL<br>
};<br>
<br>
+#define to_dev_attr(x) container_of(x, struct device_attribute, attr)<br>
+<br>
+static umode_t amdgpu_ucode_sys_visible(struct kobject *kobj,<br>
+ struct attribute *attr, int idx)<br>
+{<br>
+ struct device_attribute *dev_attr = to_dev_attr(attr);<br>
+ struct device *dev = kobj_to_dev(kobj);<br>
+<br>
+ if (dev_attr->show(dev, dev_attr, NULL) == -EINVAL)<br>
+ return 0;<br>
+<br>
+ return attr->mode;<br>
+}<br>
+<br>
static const struct attribute_group fw_attr_group = {<br>
.name = "fw_version",<br>
- .attrs = fw_attrs<br>
+ .attrs = fw_attrs,<br>
+ .is_visible = amdgpu_ucode_sys_visible<br>
};<br>
<br>
int amdgpu_ucode_sysfs_init(struct amdgpu_device *adev)<br>
-- <br>
2.25.1<o:p></o:p></span></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>