<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<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);">
>From a6512c0897aa58ccac9e5483d31193d83fb590b2 Mon Sep 17 00:00:00 2001
<div>From: Marina Nikolic <Marina.Nikolic@amd.com></div>
<div>Date: Tue, 14 Dec 2021 20:57:53 +0800</div>
<div>Subject: [PATCH] amdgpu/pm: Modify sysfs to have only read permission in</div>
<div> SRIOV/ONEVF mode</div>
<div><br>
</div>
<div>== Description ==</div>
<div>Setting through sysfs should not be allowed in SRIOV mode.</div>
<div>These calls will not be processed by FW anyway,</div>
<div>but error handling on sysfs level should be improved.</div>
<div><br>
</div>
<div>== Changes ==</div>
<div>This patch prohibits performing of all set commands</div>
<div>in SRIOV mode on sysfs level.</div>
<div>It offers better error handling as calls that are</div>
<div>not allowed will not be propagated further.</div>
<div><br>
</div>
<div>== Test ==</div>
<div>Writing to any sysfs file in passthrough mode will succeed.</div>
<div>Writing to any sysfs file in ONEVF mode will yield error:</div>
<div>"calling process does not have sufficient permission to execute a command".</div>
<div><br>
</div>
<div>Signed-off-by: Marina Nikolic <Marina.Nikolic@amd.com></div>
<div>---</div>
<div> drivers/gpu/drm/amd/pm/amdgpu_pm.c | 6 ++++++</div>
<div> 1 file changed, 6 insertions(+)</div>
<div><br>
</div>
<div>diff --git a/drivers/gpu/drm/amd/pm/amdgpu_pm.c b/drivers/gpu/drm/amd/pm/amdgpu_pm.c</div>
<div>index 082539c70fd4..c43818cd02aa 100644</div>
<div>--- a/drivers/gpu/drm/amd/pm/amdgpu_pm.c</div>
<div>+++ b/drivers/gpu/drm/amd/pm/amdgpu_pm.c</div>
<div>@@ -2133,6 +2133,12 @@ static int default_attr_update(struct amdgpu_device *adev, struct amdgpu_device_</div>
<div> }</div>
<div> }</div>
<div><br>
</div>
<div>+ /* setting should not be allowed from VF */</div>
<div>+ if (amdgpu_sriov_vf(adev)) {</div>
<div>+ dev_attr->attr.mode &= ~S_IWUGO;</div>
<div>+ dev_attr->store = NULL;</div>
<div>+ }</div>
<div>+</div>
<div> #undef DEVICE_ATTR_IS</div>
<div><br>
</div>
<div> return 0;</div>
<div>--</div>
<div>2.20.1</div>
<span></span><br>
</div>
<div>
<div id="appendonsend"></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Quan, Evan <Evan.Quan@amd.com><br>
<b>Sent:</b> Wednesday, December 22, 2021 4:19 AM<br>
<b>To:</b> Nikolic, Marina <Marina.Nikolic@amd.com>; Russell, Kent <Kent.Russell@amd.com>; amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Cc:</b> Mitrovic, Milan <Milan.Mitrovic@amd.com>; Kitchen, Greg <Greg.Kitchen@amd.com><br>
<b>Subject:</b> RE: [PATCH] amdgpu/pm: Modify sysfs pp_dpm_sclk to have only read premission in ONEVF mode</font>
<div> </div>
</div>
<div lang="EN-US" style="word-wrap:break-word">
<div class="x_WordSection1">
<p class="x_msipheadera4477989" style="margin-right: 0in; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif;margin:0in">
<span style="font-size:10.0pt; font-family:"Arial",sans-serif; color:blue">[AMD Official Use Only]</span></p>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
</p>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
</p>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
</p>
<div style="border:none; border-left:solid blue 1.5pt; padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none; border-top:solid #E1E1E1 1.0pt; padding:3.0pt 0in 0in 0in">
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<b>From:</b> amd-gfx <amd-gfx-bounces@lists.freedesktop.org> <b>On Behalf Of </b>
Nikolic, Marina<br>
<b>Sent:</b> Tuesday, December 21, 2021 10:36 PM<br>
<b>To:</b> Russell, Kent <Kent.Russell@amd.com>; amd-gfx@lists.freedesktop.org<br>
<b>Cc:</b> Mitrovic, Milan <Milan.Mitrovic@amd.com>; Kitchen, Greg <Greg.Kitchen@amd.com><br>
<b>Subject:</b> Re: [PATCH] amdgpu/pm: Modify sysfs pp_dpm_sclk to have only read premission in ONEVF mode</p>
</div>
</div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
</p>
<p style="margin:5.0pt"><span style="font-size:10.0pt; font-family:"Arial",sans-serif; color:blue">[AMD Official Use Only]</span></p>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
</p>
<div>
<p style="margin:5.0pt"><span style="font-size:10.0pt; font-family:"Arial",sans-serif; color:blue">[AMD Official Use Only]</span></p>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
</p>
<div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black">From 06359f3be0c0b889519d6dd954fb11f31e9a15e0 Mon Sep 17 00:00:00 2001
</span></p>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black">From: Marina Nikolic <<a href="mailto:Marina.Nikolic@amd.com">Marina.Nikolic@amd.com</a>></span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black">Date: Tue, 14 Dec 2021 20:57:53 +0800</span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black">Subject: [PATCH] amdgpu/pm: Modify sysfs pp_dpm_sclk to have only read</span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black"> permission in ONEVF mode</span></p>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<b><i>[Quan, Evan] With the subject updated(remove the description about pp_dpm_sclk), the patch is acked-by: Evan Quan <evan.quan@amd.com></i></b></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt"> </span></p>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt">BR</span></p>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt">Evan</span><b><i></i></b></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black">== Description ==</span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black">Setting through sysfs should not be allowed in SRIOV mode.</span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black">These calls will not be processed by FW anyway,</span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black">but error handling on sysfs level should be improved.</span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black"> </span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black">== Changes ==</span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black">This patch prohibits performing of all set commands</span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black">in SRIOV mode on sysfs level.</span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black">It offers better error handling as calls that are</span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black">not allowed will not be propagated further.</span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black"> </span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black">== Test ==</span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black">Writing to any sysfs file in passthrough mode will succeed.</span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black">Writing to any sysfs file in ONEVF mode will yield error:</span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black">"calling process does not have sufficient permission to execute a command".</span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black"> </span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black">Signed-off-by: Marina Nikolic <<a href="mailto:Marina.Nikolic@amd.com">Marina.Nikolic@amd.com</a>></span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black">---</span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black"> drivers/gpu/drm/amd/pm/amdgpu_pm.c | 6 ++++++</span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black"> 1 file changed, 6 insertions(+)</span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black"> </span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black">diff --git a/drivers/gpu/drm/amd/pm/amdgpu_pm.c b/drivers/gpu/drm/amd/pm/amdgpu_pm.c</span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black">index 082539c70fd4..c43818cd02aa 100644</span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black">--- a/drivers/gpu/drm/amd/pm/amdgpu_pm.c</span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black">+++ b/drivers/gpu/drm/amd/pm/amdgpu_pm.c</span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black">@@ -2133,6 +2133,12 @@ static int default_attr_update(struct amdgpu_device *adev, struct amdgpu_device_</span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black"> }</span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black"> }</span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black"> </span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black">+ /* setting should not be allowed from VF */</span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black">+ if (amdgpu_sriov_vf(adev)) {</span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black">+ dev_attr->attr.mode &= ~S_IWUGO;</span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black">+ dev_attr->store = NULL;</span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black">+ }</span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black">+</span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black"> #undef DEVICE_ATTR_IS</span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black"> </span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black"> return 0;</span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black">--</span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black">2.20.1</span></p>
</div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black"> </span></p>
</div>
<div class="x_MsoNormal" align="center" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;text-align:center">
<hr size="2" width="98%" align="center">
</div>
<div id="x_divRplyFwdMsg">
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<b><span style="color:black">From:</span></b><span style="color:black"> Nikolic, Marina <<a href="mailto:Marina.Nikolic@amd.com">Marina.Nikolic@amd.com</a>><br>
<b>Sent:</b> Tuesday, December 21, 2021 3:15 PM<br>
<b>To:</b> Russell, Kent <<a href="mailto:Kent.Russell@amd.com">Kent.Russell@amd.com</a>>;
<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> Mitrovic, Milan <<a href="mailto:Milan.Mitrovic@amd.com">Milan.Mitrovic@amd.com</a>>; Kitchen, Greg <<a href="mailto:Greg.Kitchen@amd.com">Greg.Kitchen@amd.com</a>><br>
<b>Subject:</b> Re: [PATCH] amdgpu/pm: Modify sysfs pp_dpm_sclk to have only read premission in ONEVF mode</span>
</p>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
</p>
</div>
</div>
<div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black">Hi Kent, </span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black"> </span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black">Thank you for the review. Yes, I can confirm I am trying to set this for every single file for SRIOV mode.</span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black"><a id="OWAAM749892" href="mailto:Greg.Kitchen@amd.com"><span style="font-family:"Calibri",sans-serif; text-decoration:none">@Kitchen, Greg</span></a> required this for ROCM-SMI 5.0 release. In case you need it, he
can provide more details.</span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black">I'm going to clarify commit message more and send a new patch.</span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black"> </span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black">BR,<br>
Marina</span></p>
</div>
<div class="x_MsoNormal" align="center" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;text-align:center">
<hr size="2" width="98%" align="center">
</div>
<div id="x_x_divRplyFwdMsg">
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<b><span style="color:black">From:</span></b><span style="color:black"> Russell, Kent <<a href="mailto:Kent.Russell@amd.com">Kent.Russell@amd.com</a>><br>
<b>Sent:</b> Monday, December 20, 2021 8:01 PM<br>
<b>To:</b> Nikolic, Marina <<a href="mailto:Marina.Nikolic@amd.com">Marina.Nikolic@amd.com</a>>;
<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> Mitrovic, Milan <<a href="mailto:Milan.Mitrovic@amd.com">Milan.Mitrovic@amd.com</a>>; Nikolic, Marina <<a href="mailto:Marina.Nikolic@amd.com">Marina.Nikolic@amd.com</a>>; Kitchen, Greg <<a href="mailto:Greg.Kitchen@amd.com">Greg.Kitchen@amd.com</a>><br>
<b>Subject:</b> RE: [PATCH] amdgpu/pm: Modify sysfs pp_dpm_sclk to have only read premission in ONEVF mode</span>
</p>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
</p>
</div>
</div>
<div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;margin-bottom:12.0pt">
<a name="x_x_BM_BEGIN"></a><span style="font-family:"Times New Roman",serif">[AMD Official Use Only]<br>
<br>
> -----Original Message-----<br>
> From: amd-gfx <<a href="mailto:amd-gfx-bounces@lists.freedesktop.org">amd-gfx-bounces@lists.freedesktop.org</a>> On Behalf Of Marina Nikolic<br>
> Sent: Monday, December 20, 2021 11:09 AM<br>
> To: <a href="mailto:amd-gfx@lists.freedesktop.org">amd-gfx@lists.freedesktop.org</a><br>
> Cc: Mitrovic, Milan <<a href="mailto:Milan.Mitrovic@amd.com">Milan.Mitrovic@amd.com</a>>; Nikolic, Marina<br>
> <<a href="mailto:Marina.Nikolic@amd.com">Marina.Nikolic@amd.com</a>>; Kitchen, Greg <<a href="mailto:Greg.Kitchen@amd.com">Greg.Kitchen@amd.com</a>><br>
> Subject: [PATCH] amdgpu/pm: Modify sysfs pp_dpm_sclk to have only read premission in<br>
> ONEVF mode<br>
><br>
> == 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 <<a href="mailto:Marina.Nikolic@amd.com">Marina.Nikolic@amd.com</a>><br>
> ---<br>
> drivers/gpu/drm/amd/pm/amdgpu_pm.c | 6 ++++++<br>
> 1 file changed, 6 insertions(+)<br>
><br>
> diff --git a/drivers/gpu/drm/amd/pm/amdgpu_pm.c<br>
> b/drivers/gpu/drm/amd/pm/amdgpu_pm.c<br>
> index 082539c70fd4..d2b168babc7d 100644<br>
> --- a/drivers/gpu/drm/amd/pm/amdgpu_pm.c<br>
> +++ b/drivers/gpu/drm/amd/pm/amdgpu_pm.c<br>
> @@ -2133,6 +2133,12 @@ static int default_attr_update(struct amdgpu_device *adev,<br>
> struct amdgpu_device_<br>
> }<br>
> }<br>
><br>
> + /* security: setting should not be allowed from VF */<br>
> + if (amdgpu_sriov_vf(adev)) {<br>
<br>
You should be checking for pp_dpm_sclk here, for example:<br>
if (DEVICE_ATTR_IS(pp_dpm_sclk) {<br>
<br>
Otherwise I am pretty sure you're setting this for every single file. And is it only sclk? Or does it also need to affect mclk/fclk/etc? If it's only sclk, the line above should help. If it's for more, then the commit should try to clarify that as it's not
100% clear.<br>
<br>
Kent<br>
<br>
> + dev_attr->attr.mode &= ~S_IWUGO;<br>
> + dev_attr->store = NULL;<br>
> + }<br>
> +<br>
> #undef DEVICE_ATTR_IS<br>
><br>
> return 0;<br>
> --<br>
> 2.20.1</span><span style="font-size:12.0pt; font-family:"Times New Roman",serif"></span></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>