summaryrefslogtreecommitdiff
path: root/sys/dev/pci/drm
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2021-11-19 03:06:02 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2021-11-19 03:06:02 +0000
commitbc8795e9249bcae70bee9f21b36e63570ade0475 (patch)
tree11e0e693fe0a2448a7c86144b37cef66f748e5d8 /sys/dev/pci/drm
parent754cca8b62d8c4f88cb860a35af6a4f64dfcf5a9 (diff)
drm/amdgpu: Fix MMIO access page fault
From Andrey Grodzovsky 2114f80889d89f96e65e0f8a74bd0ecf10b658f5 in linux 5.10.y/5.10.80 c03509cbc01559549700e14c4a6239f2572ab4ba in mainline linux
Diffstat (limited to 'sys/dev/pci/drm')
-rw-r--r--sys/dev/pci/drm/amd/amdgpu/vcn_v2_0.c8
-rw-r--r--sys/dev/pci/drm/amd/amdgpu/vcn_v2_5.c17
2 files changed, 17 insertions, 8 deletions
diff --git a/sys/dev/pci/drm/amd/amdgpu/vcn_v2_0.c b/sys/dev/pci/drm/amd/amdgpu/vcn_v2_0.c
index 6e0612003c0..2b8e8758a59 100644
--- a/sys/dev/pci/drm/amd/amdgpu/vcn_v2_0.c
+++ b/sys/dev/pci/drm/amd/amdgpu/vcn_v2_0.c
@@ -22,6 +22,7 @@
*/
#include <linux/firmware.h>
+#include <drm/drm_drv.h>
#include "amdgpu.h"
#include "amdgpu_vcn.h"
@@ -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);
diff --git a/sys/dev/pci/drm/amd/amdgpu/vcn_v2_5.c b/sys/dev/pci/drm/amd/amdgpu/vcn_v2_5.c
index b0f7239f56b..124f41752bf 100644
--- a/sys/dev/pci/drm/amd/amdgpu/vcn_v2_5.c
+++ b/sys/dev/pci/drm/amd/amdgpu/vcn_v2_5.c
@@ -22,6 +22,7 @@
*/
#include <linux/firmware.h>
+#include <drm/drm_drv.h>
#include "amdgpu.h"
#include "amdgpu_vcn.h"
@@ -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);