<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=us-ascii">
<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:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:DengXian;
panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:"\@DengXian";
panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
p.msipheadera92e061b, li.msipheadera92e061b, div.msipheadera92e061b
{mso-style-name:msipheadera92e061b;
mso-margin-top-alt:auto;
margin-right:0in;
mso-margin-bottom-alt:auto;
margin-left:0in;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
span.EmailStyle20
{mso-style-type:personal-compose;
font-family:"Arial",sans-serif;
color:#0078D7;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@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="blue" vlink="purple">
<p style="font-family:Arial;font-size:10pt;color:#0078D7;margin:15pt;" align="Left">
[AMD Official Use Only - Internal Distribution Only]<br>
</p>
<br>
<div>
<div class="WordSection1">
<p class="msipheadera92e061b" style="margin:0in;margin-bottom:.0001pt"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:#0078D7">[AMD Official Use Only - Internal Distribution Only]</span><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">+ if (adev != hive->adev) {<br>
+ sysfs_remove_link(&adev->dev->kobj,"xgmi_hive_info");<br>
+ }<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Please drop the braces in above code segment. Other than that, the patch is<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Regards,<br>
Hawking<o:p></o:p></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b>From:</b> amd-gfx <amd-gfx-bounces@lists.freedesktop.org>
<b>On Behalf Of </b>Zhang, Jack (Jian)<br>
<b>Sent:</b> Wednesday, May 20, 2020 08:14<br>
<b>To:</b> amd-gfx@lists.freedesktop.org<br>
<b>Subject:</b> Re: [PATCH] drm/amdgpu fix incorrect sysfs remove behavior for xgmi<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p style="margin:15.0pt"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:#0078D7">[AMD Official Use Only - Internal Distribution Only]<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p style="margin:15.0pt"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:#0078D7">[AMD Official Use Only - Internal Distribution Only]<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal" style="background:white"><span style="color:#212121">ping<o:p></o:p></span></p>
<div id="ms-outlook-mobile-signature">
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoNormal"> <a href="https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Faka.ms%2Fghei36&data=02%7C01%7Chawking.zhang%40amd.com%7Cae55d8dca7cb42c5a77408d7fc52bde4%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637255306473528001&sdata=JjFZsnqaTYv1ShkWrIpTi0QW500U0mNYolWfI1a6lX0%3D&reserved=0">Outlook
for Android</a><o:p></o:p></p>
</div>
<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 style="color:black">From:</span></b><span style="color:black"> Jack Zhang <<a href="mailto:Jack.Zhang1@amd.com">Jack.Zhang1@amd.com</a>><br>
<b>Sent:</b> Monday, May 18, 2020 5:00:53 PM<br>
<b>To:</b> <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>
<b>Cc:</b> Zhang, Jack (Jian) <<a href="mailto:Jack.Zhang1@amd.com">Jack.Zhang1@amd.com</a>><br>
<b>Subject:</b> [PATCH] drm/amdgpu fix incorrect sysfs remove behavior for xgmi</span>
<o:p></o:p></p>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">Under xgmi setup,some sysfs fail to create for the second time of kmd<br>
driver loading. It's due to sysfs nodes are not removed appropriately<br>
in the last unlod time.<br>
<br>
Changes of this patch:<br>
1. remove sysfs for dev_attr_xgmi_error<br>
2. remove sysfs_link adev->dev->kobj with target name.<br>
And it only needs to be removed once for a xgmi setup<br>
3. remove sysfs_link hive->kobj with target name<br>
<br>
In amdgpu_xgmi_remove_device:<br>
1. amdgpu_xgmi_sysfs_rem_dev_info needs to be run per device<br>
2. amdgpu_xgmi_sysfs_destroy needs to be run on the last node of<br>
device.<br>
<br>
v2: initialize array with memset<br>
<br>
Signed-off-by: Jack Zhang <<a href="mailto:Jack.Zhang1@amd.com">Jack.Zhang1@amd.com</a>><br>
---<br>
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c | 24 +++++++++++++++++-------<br>
1 file changed, 17 insertions(+), 7 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c<br>
index e9e59bc..3b46ea8 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c<br>
@@ -325,9 +325,19 @@ static int amdgpu_xgmi_sysfs_add_dev_info(struct amdgpu_device *adev,<br>
static void amdgpu_xgmi_sysfs_rem_dev_info(struct amdgpu_device *adev,<br>
struct amdgpu_hive_info *hive)<br>
{<br>
+ char node[10];<br>
+ memset(node, 0, sizeof(node));<br>
+<br>
device_remove_file(adev->dev, &dev_attr_xgmi_device_id);<br>
- sysfs_remove_link(&adev->dev->kobj, adev->ddev->unique);<br>
- sysfs_remove_link(hive->kobj, adev->ddev->unique);<br>
+ device_remove_file(adev->dev, &dev_attr_xgmi_error);<br>
+<br>
+ if (adev != hive->adev) {<br>
+ sysfs_remove_link(&adev->dev->kobj,"xgmi_hive_info");<br>
+ }<br>
+<br>
+ sprintf(node, "node%d", hive->number_devices);<br>
+ sysfs_remove_link(hive->kobj, node);<br>
+<br>
}<br>
<br>
<br>
@@ -583,14 +593,14 @@ int amdgpu_xgmi_remove_device(struct amdgpu_device *adev)<br>
if (!hive)<br>
return -EINVAL;<br>
<br>
- if (!(hive->number_devices--)) {<br>
+ task_barrier_rem_task(&hive->tb);<br>
+ amdgpu_xgmi_sysfs_rem_dev_info(adev, hive);<br>
+ mutex_unlock(&hive->hive_lock);<br>
+<br>
+ if(!(--hive->number_devices)){<br>
amdgpu_xgmi_sysfs_destroy(adev, hive);<br>
mutex_destroy(&hive->hive_lock);<br>
mutex_destroy(&hive->reset_lock);<br>
- } else {<br>
- task_barrier_rem_task(&hive->tb);<br>
- amdgpu_xgmi_sysfs_rem_dev_info(adev, hive);<br>
- mutex_unlock(&hive->hive_lock);<br>
}<br>
<br>
return psp_xgmi_terminate(&adev->psp);<br>
-- <br>
2.7.4<o:p></o:p></p>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>