All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@gmail.com>
To: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Cc: Mark Brown <broonie@kernel.org>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Takashi Iwai <tiwai@suse.com>, Jaroslav Kysela <perex@perex.cz>,
	Jon Hunter <jonathanh@nvidia.com>,
	alsa-devel@alsa-project.org, linux-tegra@vger.kernel.org
Subject: Re: [PATCH 2/2] ASoC: simple-card-utils: Increase maximum number of links to 128
Date: Mon, 19 Apr 2021 16:51:42 +0200	[thread overview]
Message-ID: <YH2Y/rd2/q5qHvnz@orome.fritz.box> (raw)
In-Reply-To: <8735vn59sw.wl-kuninori.morimoto.gx@renesas.com>

[-- Attachment #1: Type: text/plain, Size: 1764 bytes --]

On Mon, Apr 19, 2021 at 10:42:55AM +0900, Kuninori Morimoto wrote:
> 
> Hi Thierry
> 
> > From: Thierry Reding <treding@nvidia.com>
> > 
> > On Tegra186 and later, the number of links can go up to 72, so bump the
> > maximum number of links to the next power of two (128).
> > 
> > Fixes: f2138aed231c ("ASoC: simple-card-utils: enable flexible CPU/Codec/Platform")
> > Signed-off-by: Thierry Reding <treding@nvidia.com>
> (snip)
> > +#define SNDRV_MAX_LINKS 128
> > +
> >  struct link_info {
> >  	int link; /* number of link */
> >  	int cpu;  /* turn for CPU / Codec */
> > -	struct prop_nums num[SNDRV_MINOR_DEVICES];
> > +	struct prop_nums num[SNDRV_MAX_LINKS];
> >  };
> 
> 
> How many numbers do you really need ?

As I mentioned in the commit message, the maximum I've seen is 72.
Rounding up to the next power of two seemed like a good idea to give a
bit of extra headroom.

> Because simple-card needs many parameters,
> thus I will get below warning.
> # It is not yet happen on upstream kernel, but will be
> 
> 	warning: the frame size of 2280 bytes is larger than 2048 bytes [-Wframe-larger-than=]
> 
> This warning doesn't appear if SNDRV_MAX_LINKS was 64.
> Can we reduce it ?

Reducing from 128 to, say, 80 should eliminate that warning, but I
wonder if perhaps a better solution for the longer term would be to
allocate this structure on the heap rather than on the stack? That
way we don't risk triggering this warning again in the future.

The data structure seems to be only used during initialization, so
something like a kzalloc()/kfree() pair doesn't seem like it would
hurt much performance-wise. Add in the devm_ variants and the code
complexity should also remain moderately low.

Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: Thierry Reding <thierry.reding@gmail.com>
To: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Cc: alsa-devel@alsa-project.org, Takashi Iwai <tiwai@suse.com>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>,
	linux-tegra@vger.kernel.org, Jon Hunter <jonathanh@nvidia.com>
Subject: Re: [PATCH 2/2] ASoC: simple-card-utils: Increase maximum number of links to 128
Date: Mon, 19 Apr 2021 16:51:42 +0200	[thread overview]
Message-ID: <YH2Y/rd2/q5qHvnz@orome.fritz.box> (raw)
In-Reply-To: <8735vn59sw.wl-kuninori.morimoto.gx@renesas.com>

[-- Attachment #1: Type: text/plain, Size: 1764 bytes --]

On Mon, Apr 19, 2021 at 10:42:55AM +0900, Kuninori Morimoto wrote:
> 
> Hi Thierry
> 
> > From: Thierry Reding <treding@nvidia.com>
> > 
> > On Tegra186 and later, the number of links can go up to 72, so bump the
> > maximum number of links to the next power of two (128).
> > 
> > Fixes: f2138aed231c ("ASoC: simple-card-utils: enable flexible CPU/Codec/Platform")
> > Signed-off-by: Thierry Reding <treding@nvidia.com>
> (snip)
> > +#define SNDRV_MAX_LINKS 128
> > +
> >  struct link_info {
> >  	int link; /* number of link */
> >  	int cpu;  /* turn for CPU / Codec */
> > -	struct prop_nums num[SNDRV_MINOR_DEVICES];
> > +	struct prop_nums num[SNDRV_MAX_LINKS];
> >  };
> 
> 
> How many numbers do you really need ?

As I mentioned in the commit message, the maximum I've seen is 72.
Rounding up to the next power of two seemed like a good idea to give a
bit of extra headroom.

> Because simple-card needs many parameters,
> thus I will get below warning.
> # It is not yet happen on upstream kernel, but will be
> 
> 	warning: the frame size of 2280 bytes is larger than 2048 bytes [-Wframe-larger-than=]
> 
> This warning doesn't appear if SNDRV_MAX_LINKS was 64.
> Can we reduce it ?

Reducing from 128 to, say, 80 should eliminate that warning, but I
wonder if perhaps a better solution for the longer term would be to
allocate this structure on the heap rather than on the stack? That
way we don't risk triggering this warning again in the future.

The data structure seems to be only used during initialization, so
something like a kzalloc()/kfree() pair doesn't seem like it would
hurt much performance-wise. Add in the devm_ variants and the code
complexity should also remain moderately low.

Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2021-04-19 14:51 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-16  7:11 [PATCH 1/2] ASoC: simple-card-utils: Propagate errors on too many links Thierry Reding
2021-04-16  7:11 ` Thierry Reding
2021-04-16  7:11 ` [PATCH 2/2] ASoC: simple-card-utils: Increase maximum number of links to 128 Thierry Reding
2021-04-16  7:11   ` Thierry Reding
2021-04-16 14:50   ` Jon Hunter
2021-04-16 14:50     ` Jon Hunter
2021-04-19  1:42   ` Kuninori Morimoto
2021-04-19  1:42     ` Kuninori Morimoto
2021-04-19 14:51     ` Thierry Reding [this message]
2021-04-19 14:51       ` Thierry Reding
2021-04-19 15:08       ` Mark Brown
2021-04-19 15:08         ` Mark Brown
2021-04-19 22:15         ` Kuninori Morimoto
2021-04-19 22:15           ` Kuninori Morimoto
2021-04-16 14:49 ` [PATCH 1/2] ASoC: simple-card-utils: Propagate errors on too many links Jon Hunter
2021-04-16 14:49   ` Jon Hunter
2021-04-16 15:55   ` Mark Brown
2021-04-16 15:55     ` Mark Brown
2021-04-16 16:01 ` Mark Brown
2021-04-16 16:01   ` 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=YH2Y/rd2/q5qHvnz@orome.fritz.box \
    --to=thierry.reding@gmail.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=jonathanh@nvidia.com \
    --cc=kuninori.morimoto.gx@renesas.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-tegra@vger.kernel.org \
    --cc=perex@perex.cz \
    --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.