<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<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 style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
ping ...</div>
<div class="elementToProof">
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div id="Signature">
<div>
<div id="divtagdefaultwrapper" dir="ltr" style="font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; color: rgb(0, 0, 0);">
<p>Thanks & Best Regards!</p>
<p><br>
</p>
<p>James Zhu<br>
</p>
</div>
</div>
</div>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Zhu, James <James.Zhu@amd.com><br>
<b>Sent:</b> Thursday, September 7, 2023 10:41 AM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Cc:</b> Kamal, Asad <Asad.Kamal@amd.com>; Lin, Amber <Amber.Lin@amd.com>; Zhu, James <James.Zhu@amd.com><br>
<b>Subject:</b> [PATCH] drm/amdxcp: fix amdxcp unloads incompletely</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">amdxcp unloads incompletely, and below error will be seen during load/unload,<br>
sysfs: cannot create duplicate filename '/devices/platform/amdgpu_xcp.0'<br>
<br>
devres_release_group will free xcp device at first, platform device will be<br>
unregistered later in platform_device_unregister.<br>
<br>
Signed-off-by: James Zhu <James.Zhu@amd.com><br>
---<br>
 drivers/gpu/drm/amd/amdxcp/amdgpu_xcp_drv.c | 7 ++++---<br>
 1 file changed, 4 insertions(+), 3 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdxcp/amdgpu_xcp_drv.c b/drivers/gpu/drm/amd/amdxcp/amdgpu_xcp_drv.c<br>
index 353597fc908d..90ddd8371176 100644<br>
--- a/drivers/gpu/drm/amd/amdxcp/amdgpu_xcp_drv.c<br>
+++ b/drivers/gpu/drm/amd/amdxcp/amdgpu_xcp_drv.c<br>
@@ -89,9 +89,10 @@ EXPORT_SYMBOL(amdgpu_xcp_drm_dev_alloc);<br>
 void amdgpu_xcp_drv_release(void)<br>
 {<br>
         for (--pdev_num; pdev_num >= 0; --pdev_num) {<br>
-               devres_release_group(&xcp_dev[pdev_num]->pdev->dev, NULL);<br>
-               platform_device_unregister(xcp_dev[pdev_num]->pdev);<br>
-               xcp_dev[pdev_num]->pdev = NULL;<br>
+               struct platform_device *pdev = xcp_dev[pdev_num]->pdev;<br>
+<br>
+               devres_release_group(&pdev->dev, NULL);<br>
+               platform_device_unregister(pdev);<br>
                 xcp_dev[pdev_num] = NULL;<br>
         }<br>
         pdev_num = 0;<br>
-- <br>
2.34.1<br>
<br>
</div>
</span></font></div>
</div>
</body>
</html>