<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;" align="Left">
[AMD Official Use Only]<br>
</p>
<br>
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Please ignore this one.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
There was some issue, and all changes are not included in the patch.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I have sent an update in a new mail (same subject).</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Sorry for inconvenience.</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);">
BR,<br>
Marina </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> Marina Nikolic <Marina.Nikolic@amd.com><br>
<b>Sent:</b> Friday, December 10, 2021 1:00 PM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Cc:</b> Nikolic, Marina <Marina.Nikolic@amd.com>; Nikolic, Marina <Marina.Nikolic@amd.com><br>
<b>Subject:</b> [PATCH] amdgpu/pm: Modify sysfs pp_dpm_sclk to have only read premission in ONEVF mode</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">== Description ==<br>
Due to security reasons setting through sysfs<br>
should only be allowed in passthrough mode.<br>
Options that are not mapped as SMU messages<br>
do not have any mechanizm to distinguish between<br>
passthorugh, onevf and mutivf usecase.<br>
A unified approach is needed.<br>
<br>
== Changes ==<br>
This patch introduces a new mechanizm to distinguish<br>
ONEVF and PASSTHROUGH use case on sysfs level<br>
and prohibit setting (writting to sysfs).<br>
It also applies the new mechanizm on pp_dpm_sclk sysfs file.<br>
<br>
== Test ==<br>
Writing to pp_dpm_sclk sysfs file in passthrough mode will succeed.<br>
Writing to pp_dpm_sclk sysfs file in ONEVF mode will yield error:<br>
"calling process does not have sufficient permission to execute a command".<br>
Sysfs pp_dpm_sclk will not be created in MULTIVF mode.<br>
<br>
Signed-off-by: Marina Nikolic <marina.nikolic@amd.com><br>
---<br>
drivers/gpu/drm/amd/pm/amdgpu_pm.c | 2 +-<br>
drivers/gpu/drm/amd/pm/inc/amdgpu_pm.h | 4 ++++<br>
2 files changed, 5 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/pm/amdgpu_pm.c b/drivers/gpu/drm/amd/pm/amdgpu_pm.c<br>
index 082539c70fd4..a78dd0799492 100644<br>
--- a/drivers/gpu/drm/amd/pm/amdgpu_pm.c<br>
+++ b/drivers/gpu/drm/amd/pm/amdgpu_pm.c<br>
@@ -2021,7 +2021,7 @@ static struct amdgpu_device_attr amdgpu_device_attrs[] = {<br>
AMDGPU_DEVICE_ATTR_RO(pp_cur_state, ATTR_FLAG_BASIC|ATTR_FLAG_ONEVF),<br>
AMDGPU_DEVICE_ATTR_RW(pp_force_state, ATTR_FLAG_BASIC|ATTR_FLAG_ONEVF),<br>
AMDGPU_DEVICE_ATTR_RW(pp_table, ATTR_FLAG_BASIC|ATTR_FLAG_ONEVF),<br>
- AMDGPU_DEVICE_ATTR_RW(pp_dpm_sclk, ATTR_FLAG_BASIC|ATTR_FLAG_ONEVF),<br>
+ AMDGPU_DEVICE_ATTR_RRW(pp_dpm_sclk, ATTR_FLAG_BASIC, ATTR_FLAG_ONEVF),<br>
AMDGPU_DEVICE_ATTR_RW(pp_dpm_mclk, ATTR_FLAG_BASIC|ATTR_FLAG_ONEVF),<br>
AMDGPU_DEVICE_ATTR_RW(pp_dpm_socclk, ATTR_FLAG_BASIC|ATTR_FLAG_ONEVF),<br>
AMDGPU_DEVICE_ATTR_RW(pp_dpm_fclk, ATTR_FLAG_BASIC|ATTR_FLAG_ONEVF),<br>
diff --git a/drivers/gpu/drm/amd/pm/inc/amdgpu_pm.h b/drivers/gpu/drm/amd/pm/inc/amdgpu_pm.h<br>
index a920515e2274..1a30d9c48d13 100644<br>
--- a/drivers/gpu/drm/amd/pm/inc/amdgpu_pm.h<br>
+++ b/drivers/gpu/drm/amd/pm/inc/amdgpu_pm.h<br>
@@ -79,6 +79,10 @@ struct amdgpu_device_attr_entry {<br>
amdgpu_get_##_name, NULL, \<br>
_flags, ##__VA_ARGS__)<br>
<br>
+#define AMDGPU_DEVICE_ATTR_RRW(_name, _flags_full, _flags_restricted, ...) \<br>
+ AMDGPU_DEVICE_ATTR_RW(_name, _flags_full, ##__VA_ARGS__), \<br>
+ AMDGPU_DEVICE_ATTR_RO(_name, _flags_restricted, ##__VA_ARGS__)<br>
+<br>
int amdgpu_pm_sysfs_init(struct amdgpu_device *adev);<br>
int amdgpu_pm_virt_sysfs_init(struct amdgpu_device *adev);<br>
void amdgpu_pm_sysfs_fini(struct amdgpu_device *adev);<br>
-- <br>
2.20.1<br>
<br>
</div>
</span></font></div>
</div>
</body>
</html>