summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2024-08-15 03:04:19 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2024-08-15 03:04:19 +0000
commitf704cfac6077ab1c3a532cb329e4340d2d88fe43 (patch)
tree7dfb065cf472350200442df8654a803308b76c51 /sys
parentc567299c3d89e4c7ab3fe8b1ab2a9583900f374f (diff)
drm/amdgpu: Add lock around VF RLCG interface
From Victor Skvortsov 1adb5ebe205e96af77a93512e2d5b8c437548787 in linux-6.6.y/6.6.46 e864180ee49b4d30e640fd1e1d852b86411420c9 in mainline linux
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/pci/drm/amd/amdgpu/amdgpu_device.c1
-rw-r--r--sys/dev/pci/drm/amd/amdgpu/amdgpu_virt.c6
-rw-r--r--sys/dev/pci/drm/amd/amdgpu/amdgpu_virt.h2
3 files changed, 9 insertions, 0 deletions
diff --git a/sys/dev/pci/drm/amd/amdgpu/amdgpu_device.c b/sys/dev/pci/drm/amd/amdgpu/amdgpu_device.c
index 81464ea3ab3..948b0fe0765 100644
--- a/sys/dev/pci/drm/amd/amdgpu/amdgpu_device.c
+++ b/sys/dev/pci/drm/amd/amdgpu/amdgpu_device.c
@@ -3593,6 +3593,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
rw_init(&adev->grbm_idx_mutex, "grbmidx");
rw_init(&adev->mn_lock, "agpumn");
rw_init(&adev->virt.vf_errors.lock, "vferr");
+ rw_init(&adev->virt.rlcg_reg_lock, "vrlcg");
hash_init(adev->mn_hash);
rw_init(&adev->psp.mutex, "agpsp");
rw_init(&adev->notifier_lock, "agnf");
diff --git a/sys/dev/pci/drm/amd/amdgpu/amdgpu_virt.c b/sys/dev/pci/drm/amd/amdgpu/amdgpu_virt.c
index f43b5ca1bc9..2be313e5f4b 100644
--- a/sys/dev/pci/drm/amd/amdgpu/amdgpu_virt.c
+++ b/sys/dev/pci/drm/amd/amdgpu/amdgpu_virt.c
@@ -1004,6 +1004,9 @@ static u32 amdgpu_virt_rlcg_reg_rw(struct amdgpu_device *adev, u32 offset, u32 v
scratch_reg1 = (void __iomem *)adev->rmmio + 4 * reg_access_ctrl->scratch_reg1;
scratch_reg2 = (void __iomem *)adev->rmmio + 4 * reg_access_ctrl->scratch_reg2;
scratch_reg3 = (void __iomem *)adev->rmmio + 4 * reg_access_ctrl->scratch_reg3;
+
+ mutex_lock(&adev->virt.rlcg_reg_lock);
+
if (reg_access_ctrl->spare_int)
spare_int = (void __iomem *)adev->rmmio + 4 * reg_access_ctrl->spare_int;
@@ -1059,6 +1062,9 @@ static u32 amdgpu_virt_rlcg_reg_rw(struct amdgpu_device *adev, u32 offset, u32 v
}
ret = readl(scratch_reg0);
+
+ mutex_unlock(&adev->virt.rlcg_reg_lock);
+
return ret;
}
diff --git a/sys/dev/pci/drm/amd/amdgpu/amdgpu_virt.h b/sys/dev/pci/drm/amd/amdgpu/amdgpu_virt.h
index b62bfd895d3..4362955f648 100644
--- a/sys/dev/pci/drm/amd/amdgpu/amdgpu_virt.h
+++ b/sys/dev/pci/drm/amd/amdgpu/amdgpu_virt.h
@@ -263,6 +263,8 @@ struct amdgpu_virt {
/* the ucode id to signal the autoload */
uint32_t autoload_ucode_id;
+
+ struct rwlock rlcg_reg_lock;
};
struct amdgpu_video_codec_info;