All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sascha Hauer <sha@pengutronix.de>
To: Codrin Ciubotariu <codrin.ciubotariu@microchip.com>
Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org,
	devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	lars@metafoo.de, broonie@kernel.org, perex@perex.cz,
	tiwai@suse.com, robh+dt@kernel.org, nicolas.ferre@microchip.com
Subject: Re: [PATCH v3 1/6] ASoC: dmaengine: do not use a NULL prepare_slave_config() callback
Date: Wed, 20 Apr 2022 11:15:52 +0200	[thread overview]
Message-ID: <20220420091552.GD2387@pengutronix.de> (raw)
In-Reply-To: <20220307122202.2251639-2-codrin.ciubotariu@microchip.com>

Hi,

On Mon, Mar 07, 2022 at 02:21:57PM +0200, Codrin Ciubotariu wrote:
> Even if struct snd_dmaengine_pcm_config is used, prepare_slave_config()
> callback might not be set. Check if this callback is set before using it.
> 
> Fixes: fa654e085300 ("ASoC: dmaengine-pcm: Provide default config")
> Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@microchip.com>
> ---
> 
> Changes in v2,v3:
>  - none
> 
>  sound/soc/soc-generic-dmaengine-pcm.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/sound/soc/soc-generic-dmaengine-pcm.c b/sound/soc/soc-generic-dmaengine-pcm.c
> index 285441d6aeed..2ab2ddc1294d 100644
> --- a/sound/soc/soc-generic-dmaengine-pcm.c
> +++ b/sound/soc/soc-generic-dmaengine-pcm.c
> @@ -86,10 +86,10 @@ static int dmaengine_pcm_hw_params(struct snd_soc_component *component,
>  
>  	memset(&slave_config, 0, sizeof(slave_config));
>  
> -	if (!pcm->config)
> -		prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config;
> -	else
> +	if (pcm->config && pcm->config->prepare_slave_config)
>  		prepare_slave_config = pcm->config->prepare_slave_config;
> +	else
> +		prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config;
>  
>  	if (prepare_slave_config) {
>  		int ret = prepare_slave_config(substream, params, &slave_config);

I wonder if this patch is correct. There are drivers like
sound/soc/mxs/mxs-pcm.c which call snd_dmaengine_pcm_register() with a
config which has the prepare_slave_config callback unset. For these
drivers dmaengine_pcm_hw_params() previously was a no-op. Now with this
patch snd_dmaengine_pcm_prepare_slave_config() and
dmaengine_slave_config() are called. At least for the mxs-pcm driver
calling dmaengine_slave_config() will return -ENOSYS.

At least the "Check if this callback is set before using it" part is
wrong, the callback is checked before using it with

	if (prepare_slave_config) {
		...
	}

I don't have any mxs hardware at hand to test this. I just stumbled upon
the change of behaviour when rebasing
https://patchwork.kernel.org/project/alsa-devel/patch/20220301122111.1073174-1-s.hauer@pengutronix.de/
on current master.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

WARNING: multiple messages have this Message-ID (diff)
From: Sascha Hauer <sha@pengutronix.de>
To: Codrin Ciubotariu <codrin.ciubotariu@microchip.com>
Cc: devicetree@vger.kernel.org, alsa-devel@alsa-project.org,
	lars@metafoo.de, tiwai@suse.com, linux-kernel@vger.kernel.org,
	robh+dt@kernel.org, broonie@kernel.org,
	linux-arm-kernel@lists.infradead.org,
	nicolas.ferre@microchip.com
Subject: Re: [PATCH v3 1/6] ASoC: dmaengine: do not use a NULL prepare_slave_config() callback
Date: Wed, 20 Apr 2022 11:15:52 +0200	[thread overview]
Message-ID: <20220420091552.GD2387@pengutronix.de> (raw)
In-Reply-To: <20220307122202.2251639-2-codrin.ciubotariu@microchip.com>

Hi,

On Mon, Mar 07, 2022 at 02:21:57PM +0200, Codrin Ciubotariu wrote:
> Even if struct snd_dmaengine_pcm_config is used, prepare_slave_config()
> callback might not be set. Check if this callback is set before using it.
> 
> Fixes: fa654e085300 ("ASoC: dmaengine-pcm: Provide default config")
> Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@microchip.com>
> ---
> 
> Changes in v2,v3:
>  - none
> 
>  sound/soc/soc-generic-dmaengine-pcm.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/sound/soc/soc-generic-dmaengine-pcm.c b/sound/soc/soc-generic-dmaengine-pcm.c
> index 285441d6aeed..2ab2ddc1294d 100644
> --- a/sound/soc/soc-generic-dmaengine-pcm.c
> +++ b/sound/soc/soc-generic-dmaengine-pcm.c
> @@ -86,10 +86,10 @@ static int dmaengine_pcm_hw_params(struct snd_soc_component *component,
>  
>  	memset(&slave_config, 0, sizeof(slave_config));
>  
> -	if (!pcm->config)
> -		prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config;
> -	else
> +	if (pcm->config && pcm->config->prepare_slave_config)
>  		prepare_slave_config = pcm->config->prepare_slave_config;
> +	else
> +		prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config;
>  
>  	if (prepare_slave_config) {
>  		int ret = prepare_slave_config(substream, params, &slave_config);

I wonder if this patch is correct. There are drivers like
sound/soc/mxs/mxs-pcm.c which call snd_dmaengine_pcm_register() with a
config which has the prepare_slave_config callback unset. For these
drivers dmaengine_pcm_hw_params() previously was a no-op. Now with this
patch snd_dmaengine_pcm_prepare_slave_config() and
dmaengine_slave_config() are called. At least for the mxs-pcm driver
calling dmaengine_slave_config() will return -ENOSYS.

At least the "Check if this callback is set before using it" part is
wrong, the callback is checked before using it with

	if (prepare_slave_config) {
		...
	}

I don't have any mxs hardware at hand to test this. I just stumbled upon
the change of behaviour when rebasing
https://patchwork.kernel.org/project/alsa-devel/patch/20220301122111.1073174-1-s.hauer@pengutronix.de/
on current master.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

WARNING: multiple messages have this Message-ID (diff)
From: Sascha Hauer <sha@pengutronix.de>
To: Codrin Ciubotariu <codrin.ciubotariu@microchip.com>
Cc: devicetree@vger.kernel.org, alsa-devel@alsa-project.org,
	lars@metafoo.de, tiwai@suse.com, linux-kernel@vger.kernel.org,
	robh+dt@kernel.org, perex@perex.cz, broonie@kernel.org,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v3 1/6] ASoC: dmaengine: do not use a NULL prepare_slave_config() callback
Date: Wed, 20 Apr 2022 11:15:52 +0200	[thread overview]
Message-ID: <20220420091552.GD2387@pengutronix.de> (raw)
In-Reply-To: <20220307122202.2251639-2-codrin.ciubotariu@microchip.com>

Hi,

On Mon, Mar 07, 2022 at 02:21:57PM +0200, Codrin Ciubotariu wrote:
> Even if struct snd_dmaengine_pcm_config is used, prepare_slave_config()
> callback might not be set. Check if this callback is set before using it.
> 
> Fixes: fa654e085300 ("ASoC: dmaengine-pcm: Provide default config")
> Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@microchip.com>
> ---
> 
> Changes in v2,v3:
>  - none
> 
>  sound/soc/soc-generic-dmaengine-pcm.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/sound/soc/soc-generic-dmaengine-pcm.c b/sound/soc/soc-generic-dmaengine-pcm.c
> index 285441d6aeed..2ab2ddc1294d 100644
> --- a/sound/soc/soc-generic-dmaengine-pcm.c
> +++ b/sound/soc/soc-generic-dmaengine-pcm.c
> @@ -86,10 +86,10 @@ static int dmaengine_pcm_hw_params(struct snd_soc_component *component,
>  
>  	memset(&slave_config, 0, sizeof(slave_config));
>  
> -	if (!pcm->config)
> -		prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config;
> -	else
> +	if (pcm->config && pcm->config->prepare_slave_config)
>  		prepare_slave_config = pcm->config->prepare_slave_config;
> +	else
> +		prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config;
>  
>  	if (prepare_slave_config) {
>  		int ret = prepare_slave_config(substream, params, &slave_config);

I wonder if this patch is correct. There are drivers like
sound/soc/mxs/mxs-pcm.c which call snd_dmaengine_pcm_register() with a
config which has the prepare_slave_config callback unset. For these
drivers dmaengine_pcm_hw_params() previously was a no-op. Now with this
patch snd_dmaengine_pcm_prepare_slave_config() and
dmaengine_slave_config() are called. At least for the mxs-pcm driver
calling dmaengine_slave_config() will return -ENOSYS.

At least the "Check if this callback is set before using it" part is
wrong, the callback is checked before using it with

	if (prepare_slave_config) {
		...
	}

I don't have any mxs hardware at hand to test this. I just stumbled upon
the change of behaviour when rebasing
https://patchwork.kernel.org/project/alsa-devel/patch/20220301122111.1073174-1-s.hauer@pengutronix.de/
on current master.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2022-04-20  9:15 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-07 12:21 [PATCH v3 0/6] Add driver for SAMA7G5's PDMC Codrin Ciubotariu
2022-03-07 12:21 ` Codrin Ciubotariu
2022-03-07 12:21 ` Codrin Ciubotariu
2022-03-07 12:21 ` [PATCH v3 1/6] ASoC: dmaengine: do not use a NULL prepare_slave_config() callback Codrin Ciubotariu
2022-03-07 12:21   ` Codrin Ciubotariu
2022-03-07 12:21   ` Codrin Ciubotariu
2022-04-20  9:15   ` Sascha Hauer [this message]
2022-04-20  9:15     ` Sascha Hauer
2022-04-20  9:15     ` Sascha Hauer
2022-04-20  9:58     ` Codrin.Ciubotariu
2022-04-20  9:58       ` Codrin.Ciubotariu
2022-04-20  9:58       ` Codrin.Ciubotariu
2022-04-20 10:06       ` Sascha Hauer
2022-04-20 10:06         ` Sascha Hauer
2022-04-20 10:06         ` Sascha Hauer
2022-04-20 10:17         ` Codrin.Ciubotariu
2022-04-20 10:17           ` Codrin.Ciubotariu
2022-04-20 10:17           ` Codrin.Ciubotariu
2022-03-07 12:21 ` [PATCH v3 2/6] ASoC: dt-bindings: Document Microchip's PDMC Codrin Ciubotariu
2022-03-07 12:21   ` Codrin Ciubotariu
2022-03-07 12:21   ` Codrin Ciubotariu
2022-03-07 19:05   ` Krzysztof Kozlowski
2022-03-07 19:05     ` Krzysztof Kozlowski
2022-03-07 19:05     ` Krzysztof Kozlowski
2022-03-07 12:21 ` [PATCH v3 3/6] ASoC: atmel: mchp-pdmc: add PDMC driver Codrin Ciubotariu
2022-03-07 12:21   ` Codrin Ciubotariu
2022-03-07 12:21   ` Codrin Ciubotariu
2022-03-07 12:22 ` [PATCH v3 4/6] ARM: dts: at91: sama7g5: add nodes for PDMC Codrin Ciubotariu
2022-03-07 12:22   ` Codrin Ciubotariu
2022-03-07 12:22   ` Codrin Ciubotariu
2022-03-07 12:22 ` [PATCH v3 5/6] ARM: dts: at91: sama7g5ek: add node for PDMC0 Codrin Ciubotariu
2022-03-07 12:22   ` Codrin Ciubotariu
2022-03-07 12:22   ` Codrin Ciubotariu
2022-03-07 12:22 ` [PATCH v3 6/6] ARM: configs: at91: sama7_defconfig: add MCHP PDMC and DMIC drivers Codrin Ciubotariu
2022-03-07 12:22   ` Codrin Ciubotariu
2022-03-07 12:22   ` Codrin Ciubotariu
2022-05-05 13:58   ` Nicolas Ferre
2022-05-05 13:58     ` Nicolas Ferre
2022-05-05 13:58     ` Nicolas Ferre
2022-05-05 14:47     ` Codrin.Ciubotariu
2022-05-05 14:47       ` Codrin.Ciubotariu
2022-05-05 14:47       ` Codrin.Ciubotariu
2022-05-05 15:01       ` Mark Brown
2022-05-05 15:01         ` Mark Brown
2022-05-05 15:01         ` Mark Brown
2022-05-05 15:07         ` Nicolas Ferre
2022-05-05 15:07           ` Nicolas Ferre
2022-05-05 15:07           ` Nicolas Ferre
2022-03-08 17:21 ` (subset) [PATCH v3 0/6] Add driver for SAMA7G5's PDMC Mark Brown
2022-03-08 17:21   ` Mark Brown
2022-03-08 17:21   ` 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=20220420091552.GD2387@pengutronix.de \
    --to=sha@pengutronix.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=codrin.ciubotariu@microchip.com \
    --cc=devicetree@vger.kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nicolas.ferre@microchip.com \
    --cc=perex@perex.cz \
    --cc=robh+dt@kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.