<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:#0078D7;margin:15pt;" align="Left">
[AMD Official Use Only - Internal Distribution Only]<br>
</p>
<br>
<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> amd-gfx <amd-gfx-bounces@lists.freedesktop.org> on behalf of Wenhui Sheng <Wenhui.Sheng@amd.com><br>
<b>Sent:</b> Tuesday, May 26, 2020 6:05 PM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Cc:</b> Sheng, Wenhui <Wenhui.Sheng@amd.com>; Zhang, Hawking <Hawking.Zhang@amd.com><br>
<b>Subject:</b> [PATCH 4/4] drm/amd/powerplay: add check before i2c_add_adapter</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt">
<div class="PlainText">smu_i2c_eeprom_init may be invoked twice or more<br>
under sroiv mode, while we don't want to add check<br>
if (!amdgpu_sriov_vf) before we invoke smu_i2c_eeprom_init/fini<br>
each time, so we check if i2c adapter is already added<br>
before we invoke i2c_add_adapter<br>
<br>
Signed-off-by: Wenhui Sheng <Wenhui.Sheng@amd.com><br>
Change-Id: I3500ff474e0f04ea6bd4f9adf9f97b159443dfd9<br>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com><br>
---<br>
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 24 +++++++-------------<br>
drivers/gpu/drm/amd/powerplay/arcturus_ppt.c | 14 ++++++++++++<br>
2 files changed, 22 insertions(+), 16 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c<br>
index 1e9be1dcc62b..8ce907280dc9 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c<br>
+++ b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c<br>
@@ -1354,11 +1354,9 @@ static int smu_hw_init(void *handle)<br>
if (ret)<br>
goto failed;<br>
<br>
- if (!amdgpu_sriov_vf(adev)) {<br>
- ret = smu_i2c_eeprom_init(smu, &adev->pm.smu_i2c);<br>
- if (ret)<br>
- goto failed;<br>
- }<br>
+ ret = smu_i2c_eeprom_init(smu, &adev->pm.smu_i2c);<br>
+ if (ret)<br>
+ goto failed;<br>
<br>
adev->pm.dpm_enabled = true;<br>
<br>
@@ -1396,9 +1394,7 @@ static int smu_hw_fini(void *handle)<br>
<br>
adev->pm.dpm_enabled = false;<br>
<br>
- if (!amdgpu_sriov_vf(adev)) {<br>
- smu_i2c_eeprom_fini(smu, &adev->pm.smu_i2c);<br>
- }<br>
+ smu_i2c_eeprom_fini(smu, &adev->pm.smu_i2c);<br>
<br>
ret = smu_stop_thermal_control(smu);<br>
if (ret) {<br>
@@ -1539,9 +1535,7 @@ static int smu_suspend(void *handle)<br>
<br>
adev->pm.dpm_enabled = false;<br>
<br>
- if (!amdgpu_sriov_vf(adev)) {<br>
- smu_i2c_eeprom_fini(smu, &adev->pm.smu_i2c);<br>
- }<br>
+ smu_i2c_eeprom_fini(smu, &adev->pm.smu_i2c);<br>
<br>
ret = smu_disable_dpm(smu);<br>
if (ret)<br>
@@ -1586,11 +1580,9 @@ static int smu_resume(void *handle)<br>
if (ret)<br>
goto failed;<br>
<br>
- if (!amdgpu_sriov_vf(adev)) {<br>
- ret = smu_i2c_eeprom_init(smu, &adev->pm.smu_i2c);<br>
- if (ret)<br>
- goto failed;<br>
- }<br>
+ ret = smu_i2c_eeprom_init(smu, &adev->pm.smu_i2c);<br>
+ if (ret)<br>
+ goto failed;<br>
<br>
if (smu->is_apu)<br>
smu_set_gfx_cgpg(&adev->smu, true);<br>
diff --git a/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c b/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c<br>
index 70cc1c12f196..437f8a317838 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c<br>
+++ b/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c<br>
@@ -2224,11 +2224,22 @@ static const struct i2c_algorithm arcturus_i2c_eeprom_i2c_algo = {<br>
.functionality = arcturus_i2c_eeprom_i2c_func,<br>
};<br>
<br>
+static bool arcturus_i2c_adapter_is_added(struct i2c_adapter *control)<br>
+{<br>
+ struct amdgpu_device *adev = to_amdgpu_device(control);<br>
+<br>
+ return control->dev.parent == &adev->pdev->dev ? true : false;</div>
<div class="PlainText">
<div style="margin: 0px; font-family: "Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif; background-color: rgb(255, 255, 255)">
[kevin]:</div>
<div style="margin: 0px; font-family: "Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif; background-color: rgb(255, 255, 255)">
please change code from</div>
<div style="margin: 0px; font-family: "Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif; background-color: rgb(255, 255, 255)">
"<span style="font-family: "Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif; background-color: rgb(255, 255, 255); display: inline !important">return control->dev.parent == &adev->pdev->dev
? true : false;"</span></div>
<div style="margin: 0px; font-family: "Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif; background-color: rgb(255, 255, 255)">
<span style="font-family: "Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif; background-color: rgb(255, 255, 255); display: inline !important">to </span></div>
<div style="margin: 0px; font-family: "Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif; background-color: rgb(255, 255, 255)">
<span style="font-family: "Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif; background-color: rgb(255, 255, 255); display: inline !important"><span style="font-family: "Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif; background-color: rgb(255, 255, 255); display: inline !important">"return
control->dev.parent == &adev->pdev->dev".</span></span></div>
<div style="margin: 0px; font-family: "Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif; background-color: rgb(255, 255, 255)">
<span style="font-family: "Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif; background-color: rgb(255, 255, 255); display: inline !important"><span style="font-family: "Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif; background-color: rgb(255, 255, 255); display: inline !important"><br>
</span></span></div>
<div style="margin: 0px; font-family: "Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif; background-color: rgb(255, 255, 255)">
after fixed, Series is </div>
<div style="margin: 0px; font-family: "Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif; background-color: rgb(255, 255, 255)">
Reviewed-by: Kevin Wang <kevin1.wang@amd.com></div>
<br>
+}</div>
<div class="PlainText"><br>
</div>
<div class="PlainText"><br>
</div>
<div class="PlainText">+<br>
static int arcturus_i2c_eeprom_control_init(struct i2c_adapter *control)<br>
{<br>
struct amdgpu_device *adev = to_amdgpu_device(control);<br>
int res;<br>
<br>
+ /* smu_i2c_eeprom_init may be called twice in sriov */<br>
+ if (arcturus_i2c_adapter_is_added(control))<br>
+ return 0;<br>
+<br>
control->owner = THIS_MODULE;<br>
control->class = I2C_CLASS_SPD;<br>
control->dev.parent = &adev->pdev->dev;<br>
@@ -2244,6 +2255,9 @@ static int arcturus_i2c_eeprom_control_init(struct i2c_adapter *control)<br>
<br>
static void arcturus_i2c_eeprom_control_fini(struct i2c_adapter *control)<br>
{<br>
+ if (!arcturus_i2c_adapter_is_added(control))<br>
+ return;<br>
+<br>
i2c_del_adapter(control);<br>
}<br>
<br>
-- <br>
2.17.1<br>
<br>
_______________________________________________<br>
amd-gfx mailing list<br>
amd-gfx@lists.freedesktop.org<br>
<a href="https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&data=02%7C01%7CKevin1.Wang%40amd.com%7C598c8cf6946745005df908d8015c692b%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637260843721510576&sdata=lQSeaMsfm7pHjDP%2FLo94JqVzSZEIF1NLTNz3fSvkJ3k%3D&reserved=0">https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&data=02%7C01%7CKevin1.Wang%40amd.com%7C598c8cf6946745005df908d8015c692b%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637260843721510576&sdata=lQSeaMsfm7pHjDP%2FLo94JqVzSZEIF1NLTNz3fSvkJ3k%3D&reserved=0</a><br>
</div>
</span></font></div>
</div>
</body>
</html>