[PATCH v5 1/5] ASoC: amd: yc: stop the shared IRQ before tearing down platform devices
From: MuXian Chen
Date: Fri Dec 04 2026 - 01:02:24 EST
The IRQ handler dereferences adata->pdev[0], which is freed by
platform_device_unregister(). Mask the block's interrupts before the
platform devices are unregistered so that no new interrupt can be raised
while they are being torn down; the IRQ action itself stays owned by
devres and is released during the normal unwind.
The defensive !yc_pdm_data check is kept for a platform device whose
probe failed and left the drvdata unset, but it must clear the
write-1-to-clear status bit before returning: the line is
level-triggered, and leaving the bit latched re-fires the handler until
the IRQ is disabled.
Signed-off-by: MuXian Chen <a18165943161@xxxxxxxxx>
---
sound/soc/amd/yc/pci-acp6x.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/sound/soc/amd/yc/pci-acp6x.c b/sound/soc/amd/yc/pci-acp6x.c
index baf2baeb9952..499273784f97 100644
--- a/sound/soc/amd/yc/pci-acp6x.c
+++ b/sound/soc/amd/yc/pci-acp6x.c
@@ -133,6 +133,14 @@ static irqreturn_t acp6x_irq_handler(int irq, void *dev_id)
val = acp6x_readl(adata->acp6x_base + ACP_EXTERNAL_INTR_STAT);
if (val & BIT(PDM_DMA_STAT)) {
yc_pdm_data = dev_get_drvdata(&adata->pdev[0]->dev);
+ if (!yc_pdm_data) {
+ /* Level-triggered: clear the latched status or the
+ * line stays asserted and re-fires immediately.
+ */
+ acp6x_writel(BIT(PDM_DMA_STAT),
+ adata->acp6x_base + ACP_EXTERNAL_INTR_STAT);
+ return IRQ_HANDLED;
+ }
acp6x_writel(BIT(PDM_DMA_STAT), adata->acp6x_base + ACP_EXTERNAL_INTR_STAT);
if (yc_pdm_data->capture_stream)
snd_pcm_period_elapsed(yc_pdm_data->capture_stream);
@@ -355,6 +363,13 @@ static void snd_acp6x_remove(struct pci_dev *pci)
int ret, index;
adata = pci_get_drvdata(pci);
+
+ /* Mask the block's interrupts before the platform devices they
+ * dereference are unregistered; the IRQ action itself is owned by
+ * devres and is released during the normal unwind.
+ */
+ acp6x_disable_interrupts(adata->acp6x_base);
+
if (adata->acp6x_audio_mode == ACP6x_PDM_MODE) {
for (index = 0; index < ACP6x_DEVS; index++)
platform_device_unregister(adata->pdev[index]);
--
2.56.1