<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body>
<p style="font-family:Calibri;font-size:10pt;color:#0000FF;margin:5pt;font-style:normal;font-weight:normal;text-decoration:none;" align="Left">
[AMD Official Use Only - AMD Internal Distribution Only]<br>
</p>
<br>
<div>
<div dir="auto">Reviewed-by: Vignesh.Chander@amd.com </div>
<div dir="auto">Verified-by: Vignesh.Chander@amd.com </div>
<div><br>
</div>
<div id="ms-outlook-mobile-signature" dir="auto"></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> Lijo Lazar <lijo.lazar@amd.com><br>
<b>Sent:</b> Tuesday, September 24, 2024 2:02:50 AM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Cc:</b> Zhang, Hawking <Hawking.Zhang@amd.com>; Deucher, Alexander <Alexander.Deucher@amd.com>; Chander, Vignesh <Vignesh.Chander@amd.com><br>
<b>Subject:</b> [PATCH 2/2] drm/amdgpu: Show current compute partition on VF</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Enable sysfs node for current compute partition mode on VFs also.<br>
<br>
Signed-off-by: Lijo Lazar <lijo.lazar@amd.com><br>
---<br>
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 29 +++++++++++++++++++++++--<br>
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c | 12 ++++------<br>
2 files changed, 31 insertions(+), 10 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c<br>
index 299c4461b606..fdc9656efdd3 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c<br>
@@ -1612,21 +1612,46 @@ static DEVICE_ATTR(available_compute_partition, 0444,<br>
<br>
int amdgpu_gfx_sysfs_init(struct amdgpu_device *adev)<br>
{<br>
+ struct amdgpu_xcp_mgr *xcp_mgr = adev->xcp_mgr;<br>
+ bool xcp_switch_supported;<br>
int r;<br>
<br>
+ if (!xcp_mgr)<br>
+ return 0;<br>
+<br>
+ xcp_switch_supported =<br>
+ (xcp_mgr->funcs && xcp_mgr->funcs->switch_partition_mode);<br>
+<br>
+ if (!xcp_switch_supported)<br>
+ dev_attr_current_compute_partition.attr.mode &=<br>
+ ~(S_IWUSR | S_IWGRP | S_IWOTH);<br>
+<br>
r = device_create_file(adev->dev, &dev_attr_current_compute_partition);<br>
if (r)<br>
return r;<br>
<br>
- r = device_create_file(adev->dev, &dev_attr_available_compute_partition);<br>
+ if (xcp_switch_supported)<br>
+ r = device_create_file(adev->dev,<br>
+ &dev_attr_available_compute_partition);<br>
<br>
return r;<br>
}<br>
<br>
void amdgpu_gfx_sysfs_fini(struct amdgpu_device *adev)<br>
{<br>
+ struct amdgpu_xcp_mgr *xcp_mgr = adev->xcp_mgr;<br>
+ bool xcp_switch_supported;<br>
+<br>
+ if (!xcp_mgr)<br>
+ return;<br>
+<br>
+ xcp_switch_supported =<br>
+ (xcp_mgr->funcs && xcp_mgr->funcs->switch_partition_mode);<br>
device_remove_file(adev->dev, &dev_attr_current_compute_partition);<br>
- device_remove_file(adev->dev, &dev_attr_available_compute_partition);<br>
+<br>
+ if (xcp_switch_supported)<br>
+ device_remove_file(adev->dev,<br>
+ &dev_attr_available_compute_partition);<br>
}<br>
<br>
int amdgpu_gfx_sysfs_isolation_shader_init(struct amdgpu_device *adev)<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c b/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c<br>
index c100845409f7..52322ca754c5 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c<br>
@@ -1165,12 +1165,9 @@ static int gfx_v9_4_3_sw_init(void *handle)<br>
if (r)<br>
return r;<br>
<br>
-<br>
- if (!amdgpu_sriov_vf(adev)) {<br>
- r = amdgpu_gfx_sysfs_init(adev);<br>
- if (r)<br>
- return r;<br>
- }<br>
+ r = amdgpu_gfx_sysfs_init(adev);<br>
+ if (r)<br>
+ return r;<br>
<br>
gfx_v9_4_3_alloc_ip_dump(adev);<br>
<br>
@@ -1201,8 +1198,7 @@ static int gfx_v9_4_3_sw_fini(void *handle)<br>
gfx_v9_4_3_mec_fini(adev);<br>
amdgpu_bo_unref(&adev->gfx.rlc.clear_state_obj);<br>
gfx_v9_4_3_free_microcode(adev);<br>
- if (!amdgpu_sriov_vf(adev))<br>
- amdgpu_gfx_sysfs_fini(adev);<br>
+ amdgpu_gfx_sysfs_fini(adev);<br>
amdgpu_gfx_sysfs_isolation_shader_fini(adev);<br>
<br>
kfree(adev->gfx.ip_dump_core);<br>
-- <br>
2.25.1<br>
<br>
</div>
</span></font></div>
</div>
</body>
</html>