Skip to content

Commit 2114f80

Browse files
Andrey Grodzovskygregkh
authored andcommitted
drm/amdgpu: Fix MMIO access page fault
[ Upstream commit c03509c ] Add more guards to MMIO access post device unbind/unplug Bug: https://bugs.archlinux.org/task/72092?project=1&order=dateopened&sort=desc&pagenum=1 Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com> Reviewed-by: James Zhu <James.Zhu@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 68ac723 commit 2114f80

2 files changed

Lines changed: 17 additions & 8 deletions

File tree

‎drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
*/
2323

2424
#include <linux/firmware.h>
25+
#include <drm/drm_drv.h>
2526

2627
#include "amdgpu.h"
2728
#include "amdgpu_vcn.h"
@@ -192,11 +193,14 @@ static int vcn_v2_0_sw_init(void *handle)
192193
*/
193194
static int vcn_v2_0_sw_fini(void *handle)
194195
{
195-
int r;
196+
int r, idx;
196197
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
197198
volatile struct amdgpu_fw_shared *fw_shared = adev->vcn.inst->fw_shared_cpu_addr;
198199

199-
fw_shared->present_flag_0 = 0;
200+
if (drm_dev_enter(&adev->ddev, &idx)) {
201+
fw_shared->present_flag_0 = 0;
202+
drm_dev_exit(idx);
203+
}
200204

201205
amdgpu_virt_free_mm_table(adev);
202206

‎drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
*/
2323

2424
#include <linux/firmware.h>
25+
#include <drm/drm_drv.h>
2526

2627
#include "amdgpu.h"
2728
#include "amdgpu_vcn.h"
@@ -233,17 +234,21 @@ static int vcn_v2_5_sw_init(void *handle)
233234
*/
234235
static int vcn_v2_5_sw_fini(void *handle)
235236
{
236-
int i, r;
237+
int i, r, idx;
237238
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
238239
volatile struct amdgpu_fw_shared *fw_shared;
239240

240-
for (i = 0; i < adev->vcn.num_vcn_inst; i++) {
241-
if (adev->vcn.harvest_config & (1 << i))
242-
continue;
243-
fw_shared = adev->vcn.inst[i].fw_shared_cpu_addr;
244-
fw_shared->present_flag_0 = 0;
241+
if (drm_dev_enter(&adev->ddev, &idx)) {
242+
for (i = 0; i < adev->vcn.num_vcn_inst; i++) {
243+
if (adev->vcn.harvest_config & (1 << i))
244+
continue;
245+
fw_shared = adev->vcn.inst[i].fw_shared_cpu_addr;
246+
fw_shared->present_flag_0 = 0;
247+
}
248+
drm_dev_exit(idx);
245249
}
246250

251+
247252
if (amdgpu_sriov_vf(adev))
248253
amdgpu_virt_free_mm_table(adev);
249254

0 commit comments

Comments
 (0)