From: Yaohan Li <shunsheng1218@gmail.com>
To: jeff.hugo@oss.qualcomm.com, ogabbay@kernel.org
Cc: carl.vanderlip@oss.qualcomm.com, linux-arm-msm@vger.kernel.org,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
jacek.lawrynowicz@linux.intel.com, quic_pkanojiy@quicinc.com,
stanislaw.gruszka@linux.intel.com
Subject: [PATCH] accel/qaic: drain the control workqueue before the device is freed
Date: Wed, 18 Nov 2026 15:24:48 +0800 [thread overview]
Message-ID: <20261118072448.1259909-1-shunsheng1218@gmail.com> (raw)
qaic_pci_remove() tears the MHI controller down and destroys the DRM
device, but nothing drains qdev->cntl_wq. qdev itself is allocated with
devm_kzalloc_flex() and is freed as soon as the PCI device is unbound,
while cntl_wq is a DRM-managed resource that survives until the last
open file drops its reference to the DRM device.
resp_work is queued from qaic_mhi_dl_xfer_cb() and resp_worker()
dereferences qdev, so a work item that is still queued, or still
running, when the driver instance goes away touches freed memory.
mhi_power_down() moves the controller to the shutdown state, disables
the interrupt and flushes the state worker that destroys the channel
devices, and mhi_unregister_controller() removes the controller, so no
data event can reach qaic_mhi_dl_xfer_cb() once
qaic_mhi_free_controller() has returned. Flushing the workqueue after
it therefore covers every work item that can still be queued.
Fixes: c501ca23a6a3 ("accel/qaic: Add uapi and core driver file")
Signed-off-by: Yaohan Li <shunsheng1218@gmail.com>
---
Prepared against v7.4-rc1-1969-g666539eecdf4.
AI assistance: the analysis, the change and its review notes were
prepared with Claude (Anthropic) as a coding assistant. The author
reviewed the reasoning and takes responsibility for the content.
Testing: compile tested only (arm64, gcc 11.4). No QAIC hardware was
available, so the teardown race was not run.
drivers/accel/qaic/qaic_drv.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/accel/qaic/qaic_drv.c b/drivers/accel/qaic/qaic_drv.c
index 90c0d31e414a..c4c3f450e67b 100644
--- a/drivers/accel/qaic/qaic_drv.c
+++ b/drivers/accel/qaic/qaic_drv.c
@@ -625,6 +625,15 @@ static void qaic_pci_remove(struct pci_dev *pdev)
qaic_dev_reset_clean_local_state(qdev);
qaic_mhi_free_controller(qdev->mhi_cntrl, link_up);
+
+ /*
+ * The control channel is gone, so nothing can queue resp_work any
+ * more. Drain it before qdev is freed: the workqueue belongs to the
+ * DRM device and may outlive this driver instance, and resp_worker()
+ * dereferences qdev.
+ */
+ flush_workqueue(qdev->cntl_wq);
+
qaic_destroy_drm_device(qdev, QAIC_NO_PARTITION);
}
--
2.34.1
reply other threads:[~2026-11-18 7:24 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261118072448.1259909-1-shunsheng1218@gmail.com \
--to=shunsheng1218@gmail.com \
--cc=carl.vanderlip@oss.qualcomm.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=jacek.lawrynowicz@linux.intel.com \
--cc=jeff.hugo@oss.qualcomm.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ogabbay@kernel.org \
--cc=quic_pkanojiy@quicinc.com \
--cc=stanislaw.gruszka@linux.intel.com \
/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
all inboxes | Powered by JetHome®