From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
To: Johan Hovold <johan+linaro@kernel.org>,
Mark Brown <broonie@kernel.org>, Vinod Koul <vkoul@kernel.org>
Cc: Bard Liao <yung-chuan.liao@linux.intel.com>,
Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>,
Sanyog Kale <sanyog.r.kale@intel.com>,
Banajit Goswami <bgoswami@quicinc.com>,
Liam Girdwood <lgirdwood@gmail.com>,
Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH 4/8] ASoC: codecs: wcd938x: fix resource leaks on component remove
Date: Thu, 6 Jul 2023 12:09:24 +0100 [thread overview]
Message-ID: <691cdd52-4265-da42-04c1-8a5b533e2f2a@linaro.org> (raw)
In-Reply-To: <20230705123018.30903-5-johan+linaro@kernel.org>
On 05/07/2023 13:30, Johan Hovold wrote:
> Make sure to release allocated resources on component probe failure and
> on remove.
>
> This is specifically needed to allow probe deferrals of the sound card
> which otherwise fails when reprobing the codec component:
>
> snd-sc8280xp sound: ASoC: failed to instantiate card -517
> genirq: Flags mismatch irq 289. 00002001 (HPHR PDM WD INT) vs. 00002001 (HPHR PDM WD INT)
> wcd938x_codec audio-codec: Failed to request HPHR WD interrupt (-16)
> genirq: Flags mismatch irq 290. 00002001 (HPHL PDM WD INT) vs. 00002001 (HPHL PDM WD INT)
> wcd938x_codec audio-codec: Failed to request HPHL WD interrupt (-16)
> genirq: Flags mismatch irq 291. 00002001 (AUX PDM WD INT) vs. 00002001 (AUX PDM WD INT)
> wcd938x_codec audio-codec: Failed to request Aux WD interrupt (-16)
> genirq: Flags mismatch irq 292. 00002001 (mbhc sw intr) vs. 00002001 (mbhc sw intr)
> wcd938x_codec audio-codec: Failed to request mbhc interrupts -16
>
> Fixes: 8d78602aa87a ("ASoC: codecs: wcd938x: add basic driver")
> Cc: stable@vger.kernel.org # 5.14
> Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
> ---
Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> sound/soc/codecs/wcd938x.c | 55 +++++++++++++++++++++++++++++++++-----
> 1 file changed, 48 insertions(+), 7 deletions(-)
>
> diff --git a/sound/soc/codecs/wcd938x.c b/sound/soc/codecs/wcd938x.c
> index 2e342398d027..be38cad5f354 100644
> --- a/sound/soc/codecs/wcd938x.c
> +++ b/sound/soc/codecs/wcd938x.c
> @@ -2636,6 +2636,14 @@ static int wcd938x_mbhc_init(struct snd_soc_component *component)
>
> return 0;
> }
> +
> +static void wcd938x_mbhc_deinit(struct snd_soc_component *component)
> +{
> + struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component);
> +
> + wcd_mbhc_deinit(wcd938x->wcd_mbhc);
> +}
> +
> /* END MBHC */
>
> static const struct snd_kcontrol_new wcd938x_snd_controls[] = {
> @@ -3131,20 +3139,26 @@ static int wcd938x_soc_codec_probe(struct snd_soc_component *component)
> ret = request_threaded_irq(wcd938x->hphr_pdm_wd_int, NULL, wcd938x_wd_handle_irq,
> IRQF_ONESHOT | IRQF_TRIGGER_RISING,
> "HPHR PDM WD INT", wcd938x);
> - if (ret)
> + if (ret) {
> dev_err(dev, "Failed to request HPHR WD interrupt (%d)\n", ret);
> + goto err_free_clsh_ctrl;
> + }
>
> ret = request_threaded_irq(wcd938x->hphl_pdm_wd_int, NULL, wcd938x_wd_handle_irq,
> IRQF_ONESHOT | IRQF_TRIGGER_RISING,
> "HPHL PDM WD INT", wcd938x);
> - if (ret)
> + if (ret) {
> dev_err(dev, "Failed to request HPHL WD interrupt (%d)\n", ret);
> + goto err_free_hphr_pdm_wd_int;
> + }
>
> ret = request_threaded_irq(wcd938x->aux_pdm_wd_int, NULL, wcd938x_wd_handle_irq,
> IRQF_ONESHOT | IRQF_TRIGGER_RISING,
> "AUX PDM WD INT", wcd938x);
> - if (ret)
> + if (ret) {
> dev_err(dev, "Failed to request Aux WD interrupt (%d)\n", ret);
> + goto err_free_hphl_pdm_wd_int;
> + }
>
> /* Disable watchdog interrupt for HPH and AUX */
> disable_irq_nosync(wcd938x->hphr_pdm_wd_int);
> @@ -3159,7 +3173,7 @@ static int wcd938x_soc_codec_probe(struct snd_soc_component *component)
> dev_err(component->dev,
> "%s: Failed to add snd ctrls for variant: %d\n",
> __func__, wcd938x->variant);
> - goto err;
> + goto err_free_aux_pdm_wd_int;
> }
> break;
> case WCD9385:
> @@ -3169,7 +3183,7 @@ static int wcd938x_soc_codec_probe(struct snd_soc_component *component)
> dev_err(component->dev,
> "%s: Failed to add snd ctrls for variant: %d\n",
> __func__, wcd938x->variant);
> - goto err;
> + goto err_free_aux_pdm_wd_int;
> }
> break;
> default:
> @@ -3177,12 +3191,38 @@ static int wcd938x_soc_codec_probe(struct snd_soc_component *component)
> }
>
> ret = wcd938x_mbhc_init(component);
> - if (ret)
> + if (ret) {
> dev_err(component->dev, "mbhc initialization failed\n");
> -err:
> + goto err_free_aux_pdm_wd_int;
> + }
> +
> + return 0;
> +
> +err_free_aux_pdm_wd_int:
> + free_irq(wcd938x->aux_pdm_wd_int, wcd938x);
> +err_free_hphl_pdm_wd_int:
> + free_irq(wcd938x->hphl_pdm_wd_int, wcd938x);
> +err_free_hphr_pdm_wd_int:
> + free_irq(wcd938x->hphr_pdm_wd_int, wcd938x);
> +err_free_clsh_ctrl:
> + wcd_clsh_ctrl_free(wcd938x->clsh_info);
> +
> return ret;
> }
>
> +static void wcd938x_soc_codec_remove(struct snd_soc_component *component)
> +{
> + struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component);
> +
> + wcd938x_mbhc_deinit(component);
> +
> + free_irq(wcd938x->aux_pdm_wd_int, wcd938x);
> + free_irq(wcd938x->hphl_pdm_wd_int, wcd938x);
> + free_irq(wcd938x->hphr_pdm_wd_int, wcd938x);
> +
> + wcd_clsh_ctrl_free(wcd938x->clsh_info);
> +}
> +
> static int wcd938x_codec_set_jack(struct snd_soc_component *comp,
> struct snd_soc_jack *jack, void *data)
> {
> @@ -3199,6 +3239,7 @@ static int wcd938x_codec_set_jack(struct snd_soc_component *comp,
> static const struct snd_soc_component_driver soc_codec_dev_wcd938x = {
> .name = "wcd938x_codec",
> .probe = wcd938x_soc_codec_probe,
> + .remove = wcd938x_soc_codec_remove,
> .controls = wcd938x_snd_controls,
> .num_controls = ARRAY_SIZE(wcd938x_snd_controls),
> .dapm_widgets = wcd938x_dapm_widgets,
next prev parent reply other threads:[~2023-07-06 11:09 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-05 12:30 [PATCH 0/8] ASoC/soundwire/qdsp6/wcd: fix leaks and probe deferral Johan Hovold
2023-07-05 12:30 ` [PATCH 1/8] soundwire: fix enumeration completion Johan Hovold
2023-07-05 12:53 ` Pierre-Louis Bossart
2023-07-05 14:30 ` Johan Hovold
2023-07-05 14:44 ` Pierre-Louis Bossart
2023-07-05 12:30 ` [PATCH 2/8] ASoC: qdsp6: audioreach: fix topology probe deferral Johan Hovold
2023-07-06 11:09 ` Srinivas Kandagatla
2023-07-05 12:30 ` [PATCH 3/8] ASoC: codecs: wcd938x: fix missing clsh ctrl error handling Johan Hovold
2023-07-06 11:09 ` Srinivas Kandagatla
2023-07-05 12:30 ` [PATCH 4/8] ASoC: codecs: wcd938x: fix resource leaks on component remove Johan Hovold
2023-07-06 11:09 ` Srinivas Kandagatla [this message]
2023-07-05 12:30 ` [PATCH 5/8] ASoC: codecs: wcd934x: " Johan Hovold
2023-07-06 11:09 ` Srinivas Kandagatla
2023-07-05 12:30 ` [PATCH 6/8] ASoC: codecs: wcd-mbhc-v2: " Johan Hovold
2023-07-06 11:09 ` Srinivas Kandagatla
2023-07-05 12:30 ` [PATCH 7/8] ASoC: topology: suppress probe deferral errors Johan Hovold
2023-07-05 15:07 ` Amadeusz Sławiński
2023-07-06 6:14 ` Johan Hovold
2023-07-06 7:25 ` Amadeusz Sławiński
2023-07-10 12:01 ` Johan Hovold
2023-07-05 12:30 ` [PATCH 8/8] ASoC: core: " Johan Hovold
2023-07-10 8:53 ` (subset) [PATCH 0/8] ASoC/soundwire/qdsp6/wcd: fix leaks and probe deferral Vinod Koul
2023-07-11 20:44 ` 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=691cdd52-4265-da42-04c1-8a5b533e2f2a@linaro.org \
--to=srinivas.kandagatla@linaro.org \
--cc=alsa-devel@alsa-project.org \
--cc=bgoswami@quicinc.com \
--cc=broonie@kernel.org \
--cc=johan+linaro@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=perex@perex.cz \
--cc=pierre-louis.bossart@linux.intel.com \
--cc=sanyog.r.kale@intel.com \
--cc=stable@vger.kernel.org \
--cc=tiwai@suse.com \
--cc=vkoul@kernel.org \
--cc=yung-chuan.liao@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®