From: Hongyan Xu <getshell@seu.edu.cn>
To: mchehab@kernel.org
Cc: hverkuil+cisco@kernel.org, 1742789905@qq.com,
u.kleine-koenig@baylibre.com, lgs201920130244@gmail.com,
kees@kernel.org, linux-media@vger.kernel.org,
linux-kernel@vger.kernel.org, jianhao.xu@seu.edu.cn,
Hongyan Xu <getshell@seu.edu.cn>
Subject: [PATCH] media: saa7164: drain IRQ work before freeing the device
Date: Mon, 28 Sep 2026 21:41:06 +0800 [thread overview]
Message-ID: <20260928134106.1930-1-getshell@seu.edu.cn> (raw)
The saa7164 interrupt handler queues command, encoder, and VBI work
embedded in the device and port objects. free_irq() waits for active
interrupt handlers, but it does not cancel work they queued. Teardown
can therefore free those objects while a worker still references them.
Free the interrupt after shutting down the hardware, then cancel each
work item that was initialized for the board before unregistering the
ports.
Fixes: 443c1228d505 ("V4L/DVB (12923): SAA7164: Add support for the NXP SAA7164 silicon")
Signed-off-by: Hongyan Xu <getshell@seu.edu.cn>
---
drivers/media/pci/saa7164/saa7164-core.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/drivers/media/pci/saa7164/saa7164-core.c b/drivers/media/pci/saa7164/saa7164-core.c
index ac5eb6b923e2..157f380f0df9 100644
--- a/drivers/media/pci/saa7164/saa7164-core.c
+++ b/drivers/media/pci/saa7164/saa7164-core.c
@@ -1492,6 +1492,20 @@ static void saa7164_finidev(struct pci_dev *pci_dev)
&dev->ports[SAA7164_PORT_VBI2].poll_interval);
saa7164_shutdown(dev);
+ free_irq(pci_dev->irq, dev);
+ cancel_work_sync(&dev->workcmd);
+
+ if (saa7164_boards[dev->board].portc == SAA7164_MPEG_ENCODER)
+ cancel_work_sync(&dev->ports[SAA7164_PORT_ENC1].workenc);
+
+ if (saa7164_boards[dev->board].portd == SAA7164_MPEG_ENCODER)
+ cancel_work_sync(&dev->ports[SAA7164_PORT_ENC2].workenc);
+
+ if (saa7164_boards[dev->board].porte == SAA7164_MPEG_VBI)
+ cancel_work_sync(&dev->ports[SAA7164_PORT_VBI1].workenc);
+
+ if (saa7164_boards[dev->board].portf == SAA7164_MPEG_VBI)
+ cancel_work_sync(&dev->ports[SAA7164_PORT_VBI2].workenc);
if (saa7164_boards[dev->board].porta == SAA7164_MPEG_DVB)
saa7164_dvb_unregister(&dev->ports[SAA7164_PORT_TS1]);
@@ -1515,9 +1529,6 @@ static void saa7164_finidev(struct pci_dev *pci_dev)
saa7164_i2c_unregister(&dev->i2c_bus[1]);
saa7164_i2c_unregister(&dev->i2c_bus[2]);
- /* unregister stuff */
- free_irq(pci_dev->irq, dev);
-
if (dev->msi) {
pci_disable_msi(pci_dev);
dev->msi = false;
--
2.50.1.windows.1
reply other threads:[~2026-09-28 13:41 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=20260928134106.1930-1-getshell@seu.edu.cn \
--to=getshell@seu.edu.cn \
--cc=1742789905@qq.com \
--cc=hverkuil+cisco@kernel.org \
--cc=jianhao.xu@seu.edu.cn \
--cc=kees@kernel.org \
--cc=lgs201920130244@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=u.kleine-koenig@baylibre.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®