Skip to content

Commit

Permalink
drm/amdgpu: Fix MMIO access page fault
Browse files Browse the repository at this point in the history
[ 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>
  • Loading branch information
Andrey Grodzovsky authored and gregkh committed Nov 17, 2021
1 parent 40cfb8e commit adb3b9b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
8 changes: 6 additions & 2 deletions drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c
Expand Up @@ -22,6 +22,7 @@
*/

#include <linux/firmware.h>
#include <drm/drm_drv.h>

#include "amdgpu.h"
#include "amdgpu_vcn.h"
Expand Down Expand Up @@ -192,11 +193,14 @@ static int vcn_v2_0_sw_init(void *handle)
*/
static int vcn_v2_0_sw_fini(void *handle)
{
int r;
int r, idx;
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
volatile struct amdgpu_fw_shared *fw_shared = adev->vcn.inst->fw_shared_cpu_addr;

fw_shared->present_flag_0 = 0;
if (drm_dev_enter(&adev->ddev, &idx)) {
fw_shared->present_flag_0 = 0;
drm_dev_exit(idx);
}

amdgpu_virt_free_mm_table(adev);

Expand Down
17 changes: 11 additions & 6 deletions drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c
Expand Up @@ -22,6 +22,7 @@
*/

#include <linux/firmware.h>
#include <drm/drm_drv.h>

#include "amdgpu.h"
#include "amdgpu_vcn.h"
Expand Down Expand Up @@ -233,17 +234,21 @@ static int vcn_v2_5_sw_init(void *handle)
*/
static int vcn_v2_5_sw_fini(void *handle)
{
int i, r;
int i, r, idx;
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
volatile struct amdgpu_fw_shared *fw_shared;

for (i = 0; i < adev->vcn.num_vcn_inst; i++) {
if (adev->vcn.harvest_config & (1 << i))
continue;
fw_shared = adev->vcn.inst[i].fw_shared_cpu_addr;
fw_shared->present_flag_0 = 0;
if (drm_dev_enter(&adev->ddev, &idx)) {
for (i = 0; i < adev->vcn.num_vcn_inst; i++) {
if (adev->vcn.harvest_config & (1 << i))
continue;
fw_shared = adev->vcn.inst[i].fw_shared_cpu_addr;
fw_shared->present_flag_0 = 0;
}
drm_dev_exit(idx);
}


if (amdgpu_sriov_vf(adev))
amdgpu_virt_free_mm_table(adev);

Expand Down

0 comments on commit adb3b9b

Please sign in to comment.