From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Andrey Grodzovsky <andrey.grodzovsky@amd.com>,
James Zhu <James.Zhu@amd.com>,
Alex Deucher <alexander.deucher@amd.com>,
Sasha Levin <sashal@kernel.org>,
christian.koenig@amd.com, Xinhui.Pan@amd.com, airlied@linux.ie,
daniel@ffwll.ch, leo.liu@amd.com, guchun.chen@amd.com,
Oak.Zeng@amd.com, lee.jones@linaro.org, satyajit.sahu@amd.com,
amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: [PATCH AUTOSEL 5.14 026/138] drm/amdgpu: Fix MMIO access page fault
Date: Mon, 8 Nov 2021 12:44:52 -0500 [thread overview]
Message-ID: <20211108174644.1187889-26-sashal@kernel.org> (raw)
In-Reply-To: <20211108174644.1187889-1-sashal@kernel.org>
From: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
[ Upstream commit c03509cbc01559549700e14c4a6239f2572ab4ba ]
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>
---
drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c | 8 ++++++--
drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c | 17 +++++++++++------
2 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c b/drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c
index f4686e918e0d1..c405075a572c1 100644
--- a/drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c
+++ b/drivers/gpu/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/drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c b/drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c
index e0c0c3734432e..a0956d8623770 100644
--- a/drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c
+++ b/drivers/gpu/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);
--
2.33.0
next prev parent reply other threads:[~2021-11-09 1:05 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-08 17:44 [PATCH AUTOSEL 5.14 001/138] dma-buf: WARN on dmabuf release with pending attachments Sasha Levin
2021-11-08 17:44 ` [PATCH AUTOSEL 5.14 002/138] drm: panel-orientation-quirks: Update the Lenovo Ideapad D330 quirk (v2) Sasha Levin
2021-11-08 17:44 ` [PATCH AUTOSEL 5.14 003/138] drm: panel-orientation-quirks: Add quirk for KD Kurio Smart C15200 2-in-1 Sasha Levin
2021-11-08 17:44 ` [PATCH AUTOSEL 5.14 004/138] drm: panel-orientation-quirks: Add quirk for the Samsung Galaxy Book 10.6 Sasha Levin
2021-11-08 17:44 ` [PATCH AUTOSEL 5.14 005/138] Bluetooth: sco: Fix lock_sock() blockage by memcpy_from_msg() Sasha Levin
2021-11-08 17:44 ` [PATCH AUTOSEL 5.14 006/138] Bluetooth: fix use-after-free error in lock_sock_nested() Sasha Levin
2021-11-08 17:44 ` [PATCH AUTOSEL 5.14 007/138] drm/panel-orientation-quirks: add Valve Steam Deck Sasha Levin
2021-11-08 17:44 ` [PATCH AUTOSEL 5.14 008/138] rcutorture: Avoid problematic critical section nesting on PREEMPT_RT Sasha Levin
2021-11-08 17:44 ` [PATCH AUTOSEL 5.14 009/138] platform/x86: wmi: do not fail if disabling fails Sasha Levin
2021-11-08 17:44 ` [PATCH AUTOSEL 5.14 010/138] MIPS: lantiq: dma: add small delay after reset Sasha Levin
2021-11-08 17:44 ` [PATCH AUTOSEL 5.14 011/138] MIPS: lantiq: dma: reset correct number of channel Sasha Levin
2021-11-08 17:44 ` [PATCH AUTOSEL 5.14 012/138] locking/lockdep: Avoid RCU-induced noinstr fail Sasha Levin
2021-11-08 17:44 ` [PATCH AUTOSEL 5.14 013/138] net: sched: update default qdisc visibility after Tx queue cnt changes Sasha Levin
2021-11-08 17:44 ` [PATCH AUTOSEL 5.14 014/138] ACPI: resources: Add DMI-based legacy IRQ override quirk Sasha Levin
2021-11-08 17:44 ` [PATCH AUTOSEL 5.14 015/138] rcu-tasks: Move RTGS_WAIT_CBS to beginning of rcu_tasks_kthread() loop Sasha Levin
2021-11-08 17:44 ` [PATCH AUTOSEL 5.14 016/138] smackfs: Fix use-after-free in netlbl_catmap_walk() Sasha Levin
2021-11-08 17:44 ` [PATCH AUTOSEL 5.14 017/138] ath11k: Align bss_chan_info structure with firmware Sasha Levin
2021-11-08 17:44 ` [PATCH AUTOSEL 5.14 018/138] crypto: aesni - check walk.nbytes instead of err Sasha Levin
2021-11-08 17:44 ` [PATCH AUTOSEL 5.14 019/138] NET: IPV4: fix error "do not initialise globals to 0" Sasha Levin
2021-11-08 17:44 ` [PATCH AUTOSEL 5.14 020/138] x86/mm/64: Improve stack overflow warnings Sasha Levin
2021-11-08 17:44 ` [PATCH AUTOSEL 5.14 021/138] x86: Increase exception stack sizes Sasha Levin
2021-11-08 17:44 ` [PATCH AUTOSEL 5.14 022/138] mwifiex: Run SET_BSS_MODE when changing from P2P to STATION vif-type Sasha Levin
2021-11-08 17:44 ` [PATCH AUTOSEL 5.14 023/138] mwifiex: Properly initialize private structure on interface type changes Sasha Levin
2021-11-08 17:44 ` [PATCH AUTOSEL 5.14 024/138] spi: Check we have a spi_device_id for each DT compatible Sasha Levin
2021-11-08 17:44 ` [PATCH AUTOSEL 5.14 025/138] fscrypt: allow 256-bit master keys with AES-256-XTS Sasha Levin
2021-11-08 17:44 ` Sasha Levin [this message]
2021-11-08 17:44 ` [PATCH AUTOSEL 5.14 027/138] drm/amd/display: Fix null pointer dereference for encoders Sasha Levin
2021-11-08 17:44 ` [PATCH AUTOSEL 5.14 028/138] selftests: net: fib_nexthops: Wait before checking reported idle time Sasha Levin
2021-11-08 17:44 ` [PATCH AUTOSEL 5.14 029/138] leds: trigger: use RCU to protect the led_cdevs list Sasha Levin
2021-11-08 17:44 ` [PATCH AUTOSEL 5.14 030/138] ath11k: Avoid reg rules update during firmware recovery Sasha Levin
2021-11-08 17:44 ` [PATCH AUTOSEL 5.14 031/138] ath11k: add handler for scan event WMI_SCAN_EVENT_DEQUEUED Sasha Levin
2021-11-08 17:44 ` [PATCH AUTOSEL 5.14 032/138] ath11k: Change DMA_FROM_DEVICE to DMA_TO_DEVICE when map reinjected packets Sasha Levin
2021-11-08 17:44 ` [PATCH AUTOSEL 5.14 033/138] ath10k: high latency fixes for beacon buffer Sasha Levin
2021-11-08 17:45 ` [PATCH AUTOSEL 5.14 034/138] octeontx2-pf: Enable promisc/allmulti match MCAM entries Sasha Levin
2021-11-08 17:45 ` [PATCH AUTOSEL 5.14 035/138] media: mt9p031: Fix corrupted frame after restarting stream Sasha Levin
2021-11-08 17:45 ` [PATCH AUTOSEL 5.14 036/138] media: netup_unidvb: handle interrupt properly according to the firmware Sasha Levin
2021-11-08 17:45 ` [PATCH AUTOSEL 5.14 037/138] media: atomisp: Fix error handling in probe Sasha Levin
2021-11-08 17:45 ` [PATCH AUTOSEL 5.14 038/138] media: stm32: Potential NULL pointer dereference in dcmi_irq_thread() Sasha Levin
2021-11-08 17:45 ` [PATCH AUTOSEL 5.14 039/138] media: uvcvideo: Set capability in s_param Sasha Levin
2021-11-08 17:45 ` [PATCH AUTOSEL 5.14 040/138] media: uvcvideo: Return -EIO for control errors Sasha Levin
2021-11-08 17:45 ` [PATCH AUTOSEL 5.14 041/138] media: uvcvideo: Set unique vdev name based in type Sasha Levin
2021-11-08 17:45 ` [PATCH AUTOSEL 5.14 042/138] media: vidtv: Fix memory leak in remove Sasha Levin
2021-11-08 17:45 ` [PATCH AUTOSEL 5.14 043/138] media: s5p-mfc: fix possible null-pointer dereference in s5p_mfc_probe() Sasha Levin
2021-11-08 17:45 ` [PATCH AUTOSEL 5.14 044/138] media: s5p-mfc: Add checking to s5p_mfc_probe() Sasha Levin
2021-11-08 17:45 ` [PATCH AUTOSEL 5.14 045/138] media: videobuf2: rework vb2_mem_ops API Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211108174644.1187889-26-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=James.Zhu@amd.com \
--cc=Oak.Zeng@amd.com \
--cc=Xinhui.Pan@amd.com \
--cc=airlied@linux.ie \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=andrey.grodzovsky@amd.com \
--cc=christian.koenig@amd.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=guchun.chen@amd.com \
--cc=lee.jones@linaro.org \
--cc=leo.liu@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=satyajit.sahu@amd.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox