From: John Stultz <john.stultz@linaro.org>
To: Shengjiu Wang <shengjiu.wang@gmail.com>
Cc: Mark Rutland <mark.rutland@arm.com>,
"open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS"
<devicetree@vger.kernel.org>,
Linux-ALSA <alsa-devel@alsa-project.org>,
Lars-Peter Clausen <lars@metafoo.de>,
Timur Tabi <timur@kernel.org>, Xiubo Li <Xiubo.Lee@gmail.com>,
Fabio Estevam <festevam@gmail.com>,
Shengjiu Wang <shengjiu.wang@nxp.com>,
Takashi Iwai <tiwai@suse.com>,
Liam Girdwood <lgirdwood@gmail.com>,
Nicolin Chen <nicoleotsuka@gmail.com>,
Rob Herring <robh+dt@kernel.org>, Mark Brown <broonie@kernel.org>,
linuxppc-dev@lists.ozlabs.org,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [alsa-devel] [PATCH V6 3/4] ASoC: pcm_dmaengine: Extract snd_dmaengine_pcm_refine_runtime_hwparams
Date: Fri, 17 Jan 2020 20:02:04 -0800 [thread overview]
Message-ID: <CALAqxLVapiMC-qPX4fza9cPCKFqvoi2KWhZkJa42DiHwOqGe8Q@mail.gmail.com> (raw)
In-Reply-To: <CAA+D8AP39bo6EsHvWhVXvAYAho_xMnWmePPAK6dBsOh5wsz48Q@mail.gmail.com>
On Thu, Jan 16, 2020 at 11:11 PM Shengjiu Wang <shengjiu.wang@gmail.com> wrote:
>
> Hi
>
> On Thu, Jan 16, 2020 at 1:56 PM John Stultz <john.stultz@linaro.org> wrote:
> >
> > On Wed, Jan 8, 2020 at 8:58 PM John Stultz <john.stultz@linaro.org> wrote:
> > > On Thu, Sep 26, 2019 at 6:50 PM Shengjiu Wang <shengjiu.wang@nxp.com> wrote:
> > > >
> > > > When set the runtime hardware parameters, we may need to query
> > > > the capability of DMA to complete the parameters.
> > > >
> > > > This patch is to Extract this operation from
> > > > dmaengine_pcm_set_runtime_hwparams function to a separate function
> > > > snd_dmaengine_pcm_refine_runtime_hwparams, that other components
> > > > which need this feature can call this function.
> > > >
> > > > Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
> > > > Reviewed-by: Nicolin Chen <nicoleotsuka@gmail.com>
> > >
> > > As a heads up, this patch seems to be causing a regression on the HiKey board.
> > >
> > > On boot up I'm seeing:
> > > [ 17.721424] hi6210_i2s f7118000.i2s: ASoC: can't open component
> > > f7118000.i2s: -6
> > >
> > > And HDMI audio isn't working. With this patch reverted, audio works again.
> > >
> > >
> > > > diff --git a/sound/core/pcm_dmaengine.c b/sound/core/pcm_dmaengine.c
> > > > index 89a05926ac73..5749a8a49784 100644
> > > > --- a/sound/core/pcm_dmaengine.c
> > > > +++ b/sound/core/pcm_dmaengine.c
> > > > @@ -369,4 +369,87 @@ int snd_dmaengine_pcm_close_release_chan(struct snd_pcm_substream *substream)
> > > ...
> > > > + ret = dma_get_slave_caps(chan, &dma_caps);
> > > > + if (ret == 0) {
> > > > + if (dma_caps.cmd_pause && dma_caps.cmd_resume)
> > > > + hw->info |= SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME;
> > > > + if (dma_caps.residue_granularity <= DMA_RESIDUE_GRANULARITY_SEGMENT)
> > > > + hw->info |= SNDRV_PCM_INFO_BATCH;
> > > > +
> > > > + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
> > > > + addr_widths = dma_caps.dst_addr_widths;
> > > > + else
> > > > + addr_widths = dma_caps.src_addr_widths;
> > > > + }
> > >
> > > It seems a failing ret from dma_get_slave_caps() here is being returned...
> > >
> > > > +
> > > > + /*
> > > > + * If SND_DMAENGINE_PCM_DAI_FLAG_PACK is set keep
> > > > + * hw.formats set to 0, meaning no restrictions are in place.
> > > > + * In this case it's the responsibility of the DAI driver to
> > > > + * provide the supported format information.
> > > > + */
> > > > + if (!(dma_data->flags & SND_DMAENGINE_PCM_DAI_FLAG_PACK))
> > > > + /*
> > > > + * Prepare formats mask for valid/allowed sample types. If the
> > > > + * dma does not have support for the given physical word size,
> > > > + * it needs to be masked out so user space can not use the
> > > > + * format which produces corrupted audio.
> > > > + * In case the dma driver does not implement the slave_caps the
> > > > + * default assumption is that it supports 1, 2 and 4 bytes
> > > > + * widths.
> > > > + */
> > > > + for (i = SNDRV_PCM_FORMAT_FIRST; i <= SNDRV_PCM_FORMAT_LAST; i++) {
> > > > + int bits = snd_pcm_format_physical_width(i);
> > > > +
> > > > + /*
> > > > + * Enable only samples with DMA supported physical
> > > > + * widths
> > > > + */
> > > > + switch (bits) {
> > > > + case 8:
> > > > + case 16:
> > > > + case 24:
> > > > + case 32:
> > > > + case 64:
> > > > + if (addr_widths & (1 << (bits / 8)))
> > > > + hw->formats |= pcm_format_to_bits(i);
> > > > + break;
> > > > + default:
> > > > + /* Unsupported types */
> > > > + break;
> > > > + }
> > > > + }
> > > > +
> > > > + return ret;
> > >
> > > ... down here.
> > >
> > > Where as in the old code...
> > >
> > > > diff --git a/sound/soc/soc-generic-dmaengine-pcm.c b/sound/soc/soc-generic-dmaengine-pcm.c
> > > > index 748f5f641002..b9f147eaf7c4 100644
> > > > --- a/sound/soc/soc-generic-dmaengine-pcm.c
> > > > +++ b/sound/soc/soc-generic-dmaengine-pcm.c
> > >
> > > > @@ -145,56 +140,12 @@ static int dmaengine_pcm_set_runtime_hwparams(struct snd_pcm_substream *substrea
> > > > if (pcm->flags & SND_DMAENGINE_PCM_FLAG_NO_RESIDUE)
> > > > hw.info |= SNDRV_PCM_INFO_BATCH;
> > > >
> > > > - ret = dma_get_slave_caps(chan, &dma_caps);
> > > > - if (ret == 0) {
> > > > - if (dma_caps.cmd_pause && dma_caps.cmd_resume)
> > > > - hw.info |= SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME;
> > > > - if (dma_caps.residue_granularity <= DMA_RESIDUE_GRANULARITY_SEGMENT)
> > > > - hw.info |= SNDRV_PCM_INFO_BATCH;
> > > > -
> > > > - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
> > > > - addr_widths = dma_caps.dst_addr_widths;
> > > > - else
> > > > - addr_widths = dma_caps.src_addr_widths;
> > > > - }
> > >
> > > ...the ret from dma_get_slave_caps() checked above, but is not
> > > actually returned.
> > >
> > > Suggestions on how to sort this out?
> >
> > Just wanted to check in on this, as I'm still seeing this regression with -rc6.
> >
> Compare with the old code. it seems that we shouldn't check the return value.
>
> Could you help to test below changes?
>
> --- a/sound/soc/soc-generic-dmaengine-pcm.c
> +++ b/sound/soc/soc-generic-dmaengine-pcm.c
> @@ -138,12 +138,10 @@ dmaengine_pcm_set_runtime_hwparams(struct
> snd_soc_component *component,
> if (pcm->flags & SND_DMAENGINE_PCM_FLAG_NO_RESIDUE)
> hw.info |= SNDRV_PCM_INFO_BATCH;
>
> - ret = snd_dmaengine_pcm_refine_runtime_hwparams(substream,
> + snd_dmaengine_pcm_refine_runtime_hwparams(substream,
> dma_data,
> &hw,
> chan);
> - if (ret)
> - return ret;
>
> return snd_soc_set_runtime_hwparams(substream, &hw);
> }
Yes, thanks for taking a look at this! Your patch does appear to avoid
the regression.
(Though you'll want to drop the ret declaration to avoid "warning:
unused variable 'ret'" compiler warnings.)
thanks
-john
next prev parent reply other threads:[~2020-01-18 4:03 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-27 1:46 [PATCH V6 0/4] update supported sample format Shengjiu Wang
2019-09-27 1:46 ` [PATCH V6 1/4] ASoC: fsl_asrc: Use in(out)put_format instead of in(out)put_word_width Shengjiu Wang
2019-10-01 11:40 ` Applied "ASoC: fsl_asrc: Use in(out)put_format instead of in(out)put_word_width" to the asoc tree Mark Brown
2019-09-27 1:46 ` [PATCH V6 2/4] ASoC: fsl_asrc: update supported sample format Shengjiu Wang
2019-10-01 11:40 ` Applied "ASoC: fsl_asrc: update supported sample format" to the asoc tree Mark Brown
2019-09-27 1:46 ` [PATCH V6 3/4] ASoC: pcm_dmaengine: Extract snd_dmaengine_pcm_refine_runtime_hwparams Shengjiu Wang
2019-10-01 11:40 ` Applied "ASoC: pcm_dmaengine: Extract snd_dmaengine_pcm_refine_runtime_hwparams" to the asoc tree Mark Brown
2020-01-09 4:58 ` [PATCH V6 3/4] ASoC: pcm_dmaengine: Extract snd_dmaengine_pcm_refine_runtime_hwparams John Stultz
2020-01-16 5:54 ` John Stultz
2020-01-17 7:11 ` [alsa-devel] " Shengjiu Wang
2020-01-18 4:02 ` John Stultz [this message]
2019-09-27 1:46 ` [PATCH V6 4/4] ASoC: fsl_asrc: Fix error with S24_3LE format bitstream in i.MX8 Shengjiu Wang
2019-09-27 1:53 ` Nicolin Chen
2019-10-01 11:40 ` Applied "ASoC: fsl_asrc: Fix error with S24_3LE format bitstream in i.MX8" to the asoc tree 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=CALAqxLVapiMC-qPX4fza9cPCKFqvoi2KWhZkJa42DiHwOqGe8Q@mail.gmail.com \
--to=john.stultz@linaro.org \
--cc=Xiubo.Lee@gmail.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=festevam@gmail.com \
--cc=lars@metafoo.de \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mark.rutland@arm.com \
--cc=nicoleotsuka@gmail.com \
--cc=robh+dt@kernel.org \
--cc=shengjiu.wang@gmail.com \
--cc=shengjiu.wang@nxp.com \
--cc=timur@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).