linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Guenter Roeck <groeck@google.com>
To: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: Lukasz Majczak <lma@semihalf.com>,
	Liam Girdwood <liam.r.girdwood@linux.intel.com>,
	Jie Yang <yang.jie@linux.intel.com>,
	alsa-devel@alsa-project.org,
	Radoslaw Biernacki <rad@semihalf.com>,
	Ross Zwisler <zwisler@google.com>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	Bob Brandt <brndt@google.com>, Marcin Wojtas <mw@semihalf.com>,
	Alex Levin <levinale@chromium.org>,
	Guenter Roeck <groeck@chromium.org>
Subject: Re: [PATCH] ASoC: Intel: kbl_rt5663_rt5514_max98927: Split be_hw_params_fixup function
Date: Thu, 14 May 2020 06:56:37 -0700	[thread overview]
Message-ID: <CABXOdTeqjRh7st_fWYCZD0d8iuVJV+g+4ukoVHKEkOL4RmqQhg@mail.gmail.com> (raw)
In-Reply-To: <52ab4557-e551-ce20-247c-681c2a0d1ad1@linux.intel.com>

On Thu, May 14, 2020 at 5:47 AM Pierre-Louis Bossart
<pierre-louis.bossart@linux.intel.com> wrote:
>
>
>
> On 5/13/20 2:20 PM, Lukasz Majczak wrote:
> > Split be_hw_params_fixup function for different codecs as current common
> > function, leads to crash while trying to get snd_soc_dpcm with
> > container_of() macro in kabylake_ssp_fixup().
> > The crash call path looks as below:
> > soc_pcm_hw_params()
> > snd_soc_dai_hw_params(codec_dai, substream, &codec_params);
> > rtd->dai_link->be_hw_params_fixup(rtd, params)
> > kabylake_ssp_fixup()
> > In this case, codec_params is just a copy of an internal structure and is
> > not embedded into struct snd_soc_dpcm thus we cannot use
> > container_of() on it.
>
> This looks like a nice/welcome change, we've had these unexplained
> crashes on KBL since 4.19 (reported by Guenter and me). I thought they
> were topology related.
>

Not entirely unexplained. See
https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/1600868,
which fixes the problem for all three affected drivers.

Someone had told me, though, that the problem is no longer seen. Guess
that was wrong.

Guenter

> If indeed this fixes the issue, it might be worth applying in to all
> stable releases?
>
> Since we have the same code structure for the other kbl drivers, would
> it also make sense to apply the same fixes there:
>
> kbl_da7219_max98927.c:  struct snd_soc_dpcm *dpcm = container_of(
> kbl_rt5663_max98927.c:  struct snd_soc_dpcm *dpcm = container_of(
>
>
> >
> > Signed-off-by: Lukasz Majczak <lma@semihalf.com>
> > ---
> >   .../intel/boards/kbl_rt5663_rt5514_max98927.c | 68 +++++++++++--------
> >   1 file changed, 39 insertions(+), 29 deletions(-)
> >
> > diff --git a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
> > index 1b1f8d7a4ea3..2e0ae724122c 100644
> > --- a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
> > +++ b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
> > @@ -328,46 +328,55 @@ static const struct snd_soc_ops kabylake_rt5663_fe_ops = {
> >       .startup = kbl_fe_startup,
> >   };
> >
> > -static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd,
> > -                                     struct snd_pcm_hw_params *params)
> > +static void kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd,
> > +     struct snd_pcm_hw_params *params, snd_pcm_format_t pcm_fmt)
> >   {
> >       struct snd_interval *rate = hw_param_interval(params,
> >                       SNDRV_PCM_HW_PARAM_RATE);
> > -     struct snd_interval *chan = hw_param_interval(params,
> > +     struct snd_interval *channels = hw_param_interval(params,
> >                       SNDRV_PCM_HW_PARAM_CHANNELS);
> >       struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
> > -     struct snd_soc_dpcm *dpcm = container_of(
> > -                     params, struct snd_soc_dpcm, hw_params);
> > -     struct snd_soc_dai_link *fe_dai_link = dpcm->fe->dai_link;
> > -     struct snd_soc_dai_link *be_dai_link = dpcm->be->dai_link;
> >
> >       /*
> >        * The ADSP will convert the FE rate to 48k, stereo, 24 bit
> >        */
> > -     if (!strcmp(fe_dai_link->name, "Kbl Audio Port") ||
> > -         !strcmp(fe_dai_link->name, "Kbl Audio Headset Playback") ||
> > -         !strcmp(fe_dai_link->name, "Kbl Audio Capture Port")) {
> > -             rate->min = rate->max = 48000;
> > -             chan->min = chan->max = 2;
> > -             snd_mask_none(fmt);
> > -             snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S24_LE);
> > -     } else if (!strcmp(fe_dai_link->name, "Kbl Audio DMIC cap")) {
> > -             if (params_channels(params) == 2 ||
> > -                             DMIC_CH(dmic_constraints) == 2)
> > -                     chan->min = chan->max = 2;
> > -             else
> > -                     chan->min = chan->max = 4;
> > -     }
> > -     /*
> > -      * The speaker on the SSP0 supports S16_LE and not S24_LE.
> > -      * thus changing the mask here
> > -      */
> > -     if (!strcmp(be_dai_link->name, "SSP0-Codec"))
> > -             snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S16_LE);
> >
> > +     rate->min = rate->max = 48000;
> > +     channels->min = channels->max = 2;
> > +
> > +     snd_mask_none(fmt);
> > +     snd_mask_set_format(fmt, pcm_fmt);
> > +}
> > +
> > +static int kabylake_ssp0_fixup(struct snd_soc_pcm_runtime *rtd,
> > +     struct snd_pcm_hw_params *params)
> > +{
> > +     kabylake_ssp_fixup(rtd, params, SNDRV_PCM_FORMAT_S16_LE);
> >       return 0;
> >   }
> >
> > +static int kabylake_ssp1_fixup(struct snd_soc_pcm_runtime *rtd,
> > +     struct snd_pcm_hw_params *params)
> > +{
> > +
> > +     kabylake_ssp_fixup(rtd, params, SNDRV_PCM_FORMAT_S24_LE);
> > +     return 0;
> > +}
> > +
> > +static int kabylake_dmic_cap_fixup(struct snd_soc_pcm_runtime *rtd,
> > +     struct snd_pcm_hw_params *params)
> > +{
> > +     struct snd_interval *channels = hw_param_interval(params,
> > +                     SNDRV_PCM_HW_PARAM_CHANNELS);
> > +
> > +     if (params_channels(params) == 2 ||
> > +                     DMIC_CH(dmic_constraints) == 2)
> > +             channels->min = channels->max = 2;
> > +     else
> > +             channels->min = channels->max = 4;
> > +
> > +     return 0;
> > +}
> >   static int kabylake_rt5663_hw_params(struct snd_pcm_substream *substream,
> >       struct snd_pcm_hw_params *params)
> >   {
> > @@ -582,6 +591,7 @@ static struct snd_soc_dai_link kabylake_dais[] = {
> >               .dpcm_capture = 1,
> >               .nonatomic = 1,
> >               .dynamic = 1,
> > +             .be_hw_params_fixup = kabylake_dmic_cap_fixup,
> >               .ops = &kabylake_dmic_ops,
> >               SND_SOC_DAILINK_REG(dmic, dummy, platform),
> >       },
> > @@ -618,7 +628,7 @@ static struct snd_soc_dai_link kabylake_dais[] = {
> >                       SND_SOC_DAIFMT_NB_NF |
> >                       SND_SOC_DAIFMT_CBS_CFS,
> >               .ignore_pmdown_time = 1,
> > -             .be_hw_params_fixup = kabylake_ssp_fixup,
> > +             .be_hw_params_fixup = kabylake_ssp0_fixup,
> >               .dpcm_playback = 1,
> >               .dpcm_capture = 1,
> >               .ops = &kabylake_ssp0_ops,
> > @@ -632,7 +642,7 @@ static struct snd_soc_dai_link kabylake_dais[] = {
> >               .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
> >                       SND_SOC_DAIFMT_CBS_CFS,
> >               .ignore_pmdown_time = 1,
> > -             .be_hw_params_fixup = kabylake_ssp_fixup,
> > +             .be_hw_params_fixup = kabylake_ssp1_fixup,
> >               .ops = &kabylake_rt5663_ops,
> >               .dpcm_playback = 1,
> >               .dpcm_capture = 1,
> >

  reply	other threads:[~2020-05-14 13:56 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-13 19:20 [PATCH] ASoC: Intel: kbl_rt5663_rt5514_max98927: Split be_hw_params_fixup function Lukasz Majczak
2020-05-14 12:47 ` Pierre-Louis Bossart
2020-05-14 13:56   ` Guenter Roeck [this message]
2020-05-21 13:47 Lukasz Majczak
2020-05-21 14:25 ` Pierre-Louis Bossart
2020-05-21 14:36   ` Łukasz Majczak
2020-05-21 14:43     ` Łukasz Majczak
2020-05-21 15:14       ` Pierre-Louis Bossart

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=CABXOdTeqjRh7st_fWYCZD0d8iuVJV+g+4ukoVHKEkOL4RmqQhg@mail.gmail.com \
    --to=groeck@google.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=brndt@google.com \
    --cc=groeck@chromium.org \
    --cc=levinale@chromium.org \
    --cc=liam.r.girdwood@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lma@semihalf.com \
    --cc=mw@semihalf.com \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=rad@semihalf.com \
    --cc=yang.jie@linux.intel.com \
    --cc=zwisler@google.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).