alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Jyri Sarha <jsarha@ti.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: "Ujfalusi, Peter" <peter.ujfalusi@ti.com>,
	alsa-devel@alsa-project.org, Mark Brown <broonie@kernel.org>
Subject: Re: ASoC: davinci-mcasp: Set rule constraints if implicit BCLK divider is used
Date: Mon, 13 Apr 2015 14:39:06 +0300	[thread overview]
Message-ID: <552BAADA.5060401@ti.com> (raw)
In-Reply-To: <20150410093336.GA5779@mwanda>

On 04/10/15 12:33, Dan Carpenter wrote:
> Hello Jyri Sarha,
>
> The patch a75a053f1eef: "ASoC: davinci-mcasp: Set rule constraints if
> implicit BCLK divider is used" from Mar 20, 2015, leads to the
> following Sparse warning:
>
> 	sound/soc/davinci/davinci-mcasp.c:1098:45:
> 	warning: Variable length array is used.
>
> sound/soc/davinci/davinci-mcasp.c
>    1088  static int davinci_mcasp_hw_rule_channels(struct snd_pcm_hw_params *params,
>    1089                                            struct snd_pcm_hw_rule *rule)
>    1090  {
>    1091          struct davinci_mcasp_ruledata *rd = rule->private;
>    1092          struct snd_interval *ci =
>    1093                  hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
>    1094          int sbits = params_width(params);
>    1095          int rate = params_rate(params);
>    1096          int max_chan_per_wire = rd->mcasp->tdm_slots < ci->max ?
>    1097                  rd->mcasp->tdm_slots : ci->max;
>    1098          unsigned int list[ci->max - ci->min + 1];
>                                    ^^^^^^^^^^^^^^^^^^^^^
> I wasnt able to determine where these values are capped.  The worry is
> that the kernel only has an 8k stack so if they are too high it could
> oops.  I think these values can come from the user in
> snd_pcm_hw_params_user() but I'm an newbie to the code and I didn't
> see where the limits were enforced.
>

In theory the ci->max should never be more than 512, because
static struct snd_soc_dai_driver davinci_mcasp_dai[] = {
...
			.channels_max	= 32 * 16,

should limit the maximum allowed channel index. Normally this value 
should be way smaller.

However, since there is considerable amount of code involved it is hard 
to be produce a proof of that. I could add a hard max limit of 512 - or 
even 128 - to the list size. The cases when the list size would need to 
be even close 128 are quite theoretical.

Best regards,
Jyri

>    1099          int c1, c, count = 0;
>    1100
>    1101          for (c1 = ci->min; c1 <= max_chan_per_wire; c1++) {
>    1102                  uint bclk_freq = c1*sbits*rate;
>    1103                  int ppm;
>
>
> regards,
> dan carpenter
>

  reply	other threads:[~2015-04-13 11:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-10  9:33 ASoC: davinci-mcasp: Set rule constraints if implicit BCLK divider is used Dan Carpenter
2015-04-13 11:39 ` Jyri Sarha [this message]
2015-04-13 12:16   ` Dan Carpenter
2015-04-13 13:32     ` Jyri Sarha
2015-04-13 13:58       ` Dan Carpenter
2015-04-13 14:22         ` Takashi Iwai
  -- strict thread matches above, loose matches on Subject: below --
2015-03-27  6:20 Dan Carpenter

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=552BAADA.5060401@ti.com \
    --to=jsarha@ti.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=dan.carpenter@oracle.com \
    --cc=peter.ujfalusi@ti.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).