Skip to content

Commit d934e53

Browse files
Yang Wangalexdeucher
authored andcommitted
drm/amd/pm: fix smu i2c data read risk
the smu driver_table is used for all types of smu tables data transcation (e.g: PPtable, Metrics, i2c, Ecc..). it is necessary to hold this lock to avoiding data tampering during the i2c read operation. Signed-off-by: Yang Wang <[email protected]> Reviewed-by: Lijo Lazar <[email protected]> Signed-off-by: Alex Deucher <[email protected]> Cc: [email protected]
1 parent 6725f33 commit d934e53

File tree

6 files changed

+6
-6
lines changed

6 files changed

+6
-6
lines changed

drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2113,7 +2113,6 @@ static int arcturus_i2c_xfer(struct i2c_adapter *i2c_adap,
21132113
}
21142114
mutex_lock(&adev->pm.mutex);
21152115
r = smu_cmn_update_table(smu, SMU_TABLE_I2C_COMMANDS, 0, req, true);
2116-
mutex_unlock(&adev->pm.mutex);
21172116
if (r)
21182117
goto fail;
21192118

@@ -2130,6 +2129,7 @@ static int arcturus_i2c_xfer(struct i2c_adapter *i2c_adap,
21302129
}
21312130
r = num_msgs;
21322131
fail:
2132+
mutex_unlock(&adev->pm.mutex);
21332133
kfree(req);
21342134
return r;
21352135
}

drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3021,7 +3021,6 @@ static int navi10_i2c_xfer(struct i2c_adapter *i2c_adap,
30213021
}
30223022
mutex_lock(&adev->pm.mutex);
30233023
r = smu_cmn_update_table(smu, SMU_TABLE_I2C_COMMANDS, 0, req, true);
3024-
mutex_unlock(&adev->pm.mutex);
30253024
if (r)
30263025
goto fail;
30273026

@@ -3038,6 +3037,7 @@ static int navi10_i2c_xfer(struct i2c_adapter *i2c_adap,
30383037
}
30393038
r = num_msgs;
30403039
fail:
3040+
mutex_unlock(&adev->pm.mutex);
30413041
kfree(req);
30423042
return r;
30433043
}

drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3842,7 +3842,6 @@ static int sienna_cichlid_i2c_xfer(struct i2c_adapter *i2c_adap,
38423842
}
38433843
mutex_lock(&adev->pm.mutex);
38443844
r = smu_cmn_update_table(smu, SMU_TABLE_I2C_COMMANDS, 0, req, true);
3845-
mutex_unlock(&adev->pm.mutex);
38463845
if (r)
38473846
goto fail;
38483847

@@ -3859,6 +3858,7 @@ static int sienna_cichlid_i2c_xfer(struct i2c_adapter *i2c_adap,
38593858
}
38603859
r = num_msgs;
38613860
fail:
3861+
mutex_unlock(&adev->pm.mutex);
38623862
kfree(req);
38633863
return r;
38643864
}

drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1525,7 +1525,6 @@ static int aldebaran_i2c_xfer(struct i2c_adapter *i2c_adap,
15251525
}
15261526
mutex_lock(&adev->pm.mutex);
15271527
r = smu_cmn_update_table(smu, SMU_TABLE_I2C_COMMANDS, 0, req, true);
1528-
mutex_unlock(&adev->pm.mutex);
15291528
if (r)
15301529
goto fail;
15311530

@@ -1542,6 +1541,7 @@ static int aldebaran_i2c_xfer(struct i2c_adapter *i2c_adap,
15421541
}
15431542
r = num_msgs;
15441543
fail:
1544+
mutex_unlock(&adev->pm.mutex);
15451545
kfree(req);
15461546
return r;
15471547
}

drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2320,7 +2320,6 @@ static int smu_v13_0_0_i2c_xfer(struct i2c_adapter *i2c_adap,
23202320
}
23212321
mutex_lock(&adev->pm.mutex);
23222322
r = smu_cmn_update_table(smu, SMU_TABLE_I2C_COMMANDS, 0, req, true);
2323-
mutex_unlock(&adev->pm.mutex);
23242323
if (r)
23252324
goto fail;
23262325

@@ -2337,6 +2336,7 @@ static int smu_v13_0_0_i2c_xfer(struct i2c_adapter *i2c_adap,
23372336
}
23382337
r = num_msgs;
23392338
fail:
2339+
mutex_unlock(&adev->pm.mutex);
23402340
kfree(req);
23412341
return r;
23422342
}

drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1763,7 +1763,6 @@ static int smu_v13_0_6_i2c_xfer(struct i2c_adapter *i2c_adap,
17631763
}
17641764
mutex_lock(&adev->pm.mutex);
17651765
r = smu_v13_0_6_request_i2c_xfer(smu, req);
1766-
mutex_unlock(&adev->pm.mutex);
17671766
if (r)
17681767
goto fail;
17691768

@@ -1780,6 +1779,7 @@ static int smu_v13_0_6_i2c_xfer(struct i2c_adapter *i2c_adap,
17801779
}
17811780
r = num_msgs;
17821781
fail:
1782+
mutex_unlock(&adev->pm.mutex);
17831783
kfree(req);
17841784
return r;
17851785
}

0 commit comments

Comments
 (0)