From: Chancel Liu <chancel.liu@oss.nxp.com>
To: Mark Brown <broonie@kernel.org>,
Liam Girdwood <lgirdwood@gmail.com>,
Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
Charles Keepax <ckeepax@opensource.cirrus.com>,
Oder Chiou <oder_chiou@realtek.com>,
Cezary Rojewski <cezary.rojewski@intel.com>
Cc: Support Opensource <support.opensource@diasemi.com>,
linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
patches@opensource.cirrus.com
Subject: [PATCH v2 21/21] ASoC: codecs: rt5514-spi: Free the DSP context on component remove
Date: Wed, 23 Sep 2026 15:13:05 +0900 [thread overview]
Message-ID: <20260923061305.4041197-22-chancel.liu@oss.nxp.com> (raw)
In-Reply-To: <20260923061305.4041197-1-chancel.liu@oss.nxp.com>
From: Chancel Liu <chancel.liu@nxp.com>
component->dev is the underlying SPI bus device, whose devres lifetime
follows the physical device's probe/remove rather than the ASoC card's
bind/unbind. The rt5514_dsp context was allocated in
rt5514_spi_pcm_probe() via devm_kzalloc(component->dev, ...) and its
delayed work and wakeup source were never torn down on component remove,
so the context leaked and the pending copy work / wakeup source were
left dangling on every card bind/unbind cycle.
Allocate the context with plain kzalloc() and add a component .remove
callback that cancels the copy work, undoes device_init_wakeup(),
destroys the mutex and frees the context.
Signed-off-by: Chancel Liu <chancel.liu@nxp.com>
---
sound/soc/codecs/rt5514-spi.c | 37 +++++++++++++++++++++++++++--------
1 file changed, 29 insertions(+), 8 deletions(-)
diff --git a/sound/soc/codecs/rt5514-spi.c b/sound/soc/codecs/rt5514-spi.c
index 91290bfe8daa..bcc2ff28b125 100644
--- a/sound/soc/codecs/rt5514-spi.c
+++ b/sound/soc/codecs/rt5514-spi.c
@@ -43,6 +43,7 @@ struct rt5514_dsp {
struct snd_pcm_substream *substream;
unsigned int buf_base, buf_limit, buf_rp;
size_t buf_size, get_size, dma_offset;
+ int irq;
};
static const struct snd_pcm_hardware rt5514_spi_pcm_hardware = {
@@ -257,8 +258,7 @@ static int rt5514_spi_pcm_probe(struct snd_soc_component *component)
struct rt5514_dsp *rt5514_dsp;
int ret;
- rt5514_dsp = devm_kzalloc(component->dev, sizeof(*rt5514_dsp),
- GFP_KERNEL);
+ rt5514_dsp = kzalloc_obj(*rt5514_dsp);
if (!rt5514_dsp)
return -ENOMEM;
@@ -268,21 +268,41 @@ static int rt5514_spi_pcm_probe(struct snd_soc_component *component)
snd_soc_component_set_drvdata(component, rt5514_dsp);
if (rt5514_spi->irq) {
- ret = devm_request_threaded_irq(&rt5514_spi->dev,
- rt5514_spi->irq, NULL, rt5514_spi_irq,
- IRQF_TRIGGER_RISING | IRQF_ONESHOT, "rt5514-spi",
- rt5514_dsp);
- if (ret)
+ ret = request_threaded_irq(rt5514_spi->irq, NULL,
+ rt5514_spi_irq,
+ IRQF_TRIGGER_RISING | IRQF_ONESHOT,
+ "rt5514-spi", rt5514_dsp);
+ if (ret) {
dev_err(&rt5514_spi->dev,
"%s Failed to request IRQ: %d\n", __func__,
ret);
- else
+ } else {
+ rt5514_dsp->irq = rt5514_spi->irq;
device_init_wakeup(rt5514_dsp->dev, true);
+ }
}
return 0;
}
+static void rt5514_spi_pcm_remove(struct snd_soc_component *component)
+{
+ struct rt5514_dsp *rt5514_dsp =
+ snd_soc_component_get_drvdata(component);
+
+ snd_soc_component_set_drvdata(component, NULL);
+
+ if (rt5514_dsp->irq) {
+ free_irq(rt5514_dsp->irq, rt5514_dsp);
+ device_init_wakeup(rt5514_dsp->dev, false);
+ }
+
+ cancel_delayed_work_sync(&rt5514_dsp->copy_work);
+
+ mutex_destroy(&rt5514_dsp->dma_lock);
+ kfree(rt5514_dsp);
+}
+
static int rt5514_spi_pcm_new(struct snd_soc_component *component,
struct snd_soc_pcm_runtime *rtd)
{
@@ -294,6 +314,7 @@ static int rt5514_spi_pcm_new(struct snd_soc_component *component,
static const struct snd_soc_component_driver rt5514_spi_component = {
.name = DRV_NAME,
.probe = rt5514_spi_pcm_probe,
+ .remove = rt5514_spi_pcm_remove,
.open = rt5514_spi_pcm_open,
.hw_params = rt5514_spi_hw_params,
.hw_free = rt5514_spi_hw_free,
--
2.50.1
next prev parent reply other threads:[~2026-09-23 6:15 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-23 6:12 [PATCH v2 00/21] ASoC: codecs: Fix resource leaks across card bind/unbind Chancel Liu
2026-09-23 6:12 ` [PATCH v2 01/21] ASoC: codecs: cpcap: Fix devm " Chancel Liu
2026-09-23 6:12 ` [PATCH v2 02/21] ASoC: codecs: da7218: " Chancel Liu
2026-09-23 6:12 ` [PATCH v2 03/21] ASoC: codecs: tlv320aic32x4: Fix clock leak from runtime callbacks Chancel Liu
2026-09-23 6:12 ` [PATCH v2 04/21] ASoC: codecs: twl4030: Acquire board params and hs_extmute GPIO in the platform probe Chancel Liu
2026-09-23 6:12 ` [PATCH v2 05/21] ASoC: codecs: es8316: Move mclk acquisition to the i2c probe Chancel Liu
2026-09-23 8:19 ` Cezary Rojewski
2026-09-23 6:12 ` [PATCH v2 06/21] ASoC: codecs: es8323: " Chancel Liu
2026-09-23 6:12 ` [PATCH v2 07/21] ASoC: codecs: es8311: " Chancel Liu
2026-09-23 6:12 ` [PATCH v2 08/21] ASoC: codecs: es8328: Move clk acquisition to the bus probe Chancel Liu
2026-09-23 6:12 ` [PATCH v2 09/21] ASoC: codecs: rt5640: Move mclk acquisition to the i2c probe Chancel Liu
2026-09-23 8:16 ` Cezary Rojewski
2026-09-23 8:22 ` Chancel Liu
2026-09-23 6:12 ` [PATCH v2 10/21] ASoC: codecs: rt5616: " Chancel Liu
2026-09-23 6:12 ` [PATCH v2 11/21] ASoC: codecs: rt5514: Move clk " Chancel Liu
2026-09-23 8:19 ` Cezary Rojewski
2026-09-23 6:12 ` [PATCH v2 12/21] ASoC: codecs: rt5682s: Move mclk " Chancel Liu
2026-09-23 6:12 ` [PATCH v2 13/21] ASoC: codecs: max98090: " Chancel Liu
2026-09-23 6:12 ` [PATCH v2 14/21] ASoC: codecs: max98095: " Chancel Liu
2026-09-23 6:12 ` [PATCH v2 15/21] ASoC: codecs: wm8985: Move regulator acquisition to the bus probe Chancel Liu
2026-09-23 8:56 ` Charles Keepax
2026-09-23 6:13 ` [PATCH v2 16/21] ASoC: codecs: wm8955: Move regulator acquisition to the i2c probe Chancel Liu
2026-09-23 6:13 ` [PATCH v2 17/21] ASoC: codecs: es8389: Move regulator and mclk " Chancel Liu
2026-09-23 6:13 ` [PATCH v2 18/21] ASoC: codecs: rt5677-spi: Free the DSP context on component remove Chancel Liu
2026-09-23 6:13 ` [PATCH v2 19/21] ASoC: codecs: rt1011: Free the bq/drc coefficient arrays " Chancel Liu
2026-09-23 6:13 ` [PATCH v2 20/21] ASoC: codecs: rt5645: Free the hardware EQ parameters " Chancel Liu
2026-09-23 6:13 ` Chancel Liu [this message]
2026-09-23 12:27 ` [PATCH v2 00/21] ASoC: codecs: Fix resource leaks across card bind/unbind Mark Brown
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=20260923061305.4041197-22-chancel.liu@oss.nxp.com \
--to=chancel.liu@oss.nxp.com \
--cc=broonie@kernel.org \
--cc=cezary.rojewski@intel.com \
--cc=ckeepax@opensource.cirrus.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=oder_chiou@realtek.com \
--cc=patches@opensource.cirrus.com \
--cc=perex@perex.cz \
--cc=support.opensource@diasemi.com \
--cc=tiwai@suse.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®