All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Eric Curtin" <ericcurtin17@gmail.com>
Cc: linux-sound@vger.kernel.org
Subject: Re: [RFC PATCH v2 1/3] ALSA: Handle run-time PAGE_SIZE in PCM hardware tables and #if checks
Date: Wed, 02 Dec 2026 03:31:09 +0000	[thread overview]
Message-ID: <sashiko-outbox-244785@kernel.org> (raw)
In-Reply-To: <20261202031733.1704898-2-ericcurtin17@gmail.com>

Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [High] ALSA: undefined PAGE_SIZE_MIN/MAX and
  DEFINE_GLOBAL_PAGE_SIZE_VAR macros
- [High] ALSA: seq_midi: DEFINE_GLOBAL_PAGE_SIZE_VAR incompatible with
  module_param()
- [High] ASoC: stm32: non-constant PCM hardware addresses in static
  const configs
--

commit d082150f9e50604189f172c34889dabc193b0410
Author: Eric Curtin <eric.curtin@docker.com>

ALSA: Handle run-time PAGE_SIZE in PCM hardware tables and #if checks

This commit converts ALSA module parameters, static PCM hardware and DMA
configuration tables, and preprocessor page size checks to use
DEFINE_GLOBAL_PAGE_SIZE_VAR, DEFINE_GLOBAL_PAGE_SIZE_VAR_CONST,
PAGE_SIZE_MIN, and PAGE_SIZE_MAX for boot-time page size selection.

> diff --git a/sound/core/seq/seq_midi.c b/sound/core/seq/seq_midi.c
> index a16a5debf3391..7e03e55392d62 100644
> --- a/sound/core/seq/seq_midi.c
> +++ b/sound/core/seq/seq_midi.c
> @@ -29,10 +29,10 @@ Possible options for midisynth module:
>  MODULE_AUTHOR("Frank van de Pol <fvdpol@coil.demon.nl>, Jaroslav Kysela <perex@perex.cz>");
>  MODULE_DESCRIPTION("Advanced Linux Sound Architecture sequencer MIDI synth.");
>  MODULE_LICENSE("GPL");
> -static int output_buffer_size = PAGE_SIZE;
> +static DEFINE_GLOBAL_PAGE_SIZE_VAR(int, output_buffer_size, PAGE_SIZE);
>  module_param(output_buffer_size, int, 0644);
>  MODULE_PARM_DESC(output_buffer_size, "Output buffer size in bytes.");
> -static int input_buffer_size = PAGE_SIZE;
> +static DEFINE_GLOBAL_PAGE_SIZE_VAR(int, input_buffer_size, PAGE_SIZE);
>  module_param(input_buffer_size, int, 0644);
>  MODULE_PARM_DESC(input_buffer_size, "Input buffer size in bytes.");

[Severity: High]
Can output_buffer_size and input_buffer_size be defined with
DEFINE_GLOBAL_PAGE_SIZE_VAR() when they are passed to module_param()?

With boot-time PAGE_SIZE, DEFINE_GLOBAL_PAGE_SIZE_VAR() defines the
variable name as a macro expanding to a dereferenced accessor call.
module_param() expands its first argument before passing it to
module_param_named(), breaking token pasting on __param_str_##name and
failing to compile because &(value) in the static struct kernel_param
initializer is no longer a compile-time constant address.  In addition,
the module parameter code reads and writes the underlying storage directly
without running the lazy initializer, so sysfs reads before first access
would see 0 and user-supplied parameter values would be overwritten on
first lazy initialization.

> diff --git a/sound/pci/echoaudio/echoaudio_dsp.c b/sound/pci/echoaudio/echoaudio_dsp.c
> index 4dd494508c9b1..4ccf4e7de5640 100644
> --- a/sound/pci/echoaudio/echoaudio_dsp.c
> +++ b/sound/pci/echoaudio/echoaudio_dsp.c
> @@ -13,7 +13,7 @@
>  
>  ****************************************************************************/
>  
> -#if PAGE_SIZE < 4096
> +#if PAGE_SIZE_MIN < 4096
>  #error PAGE_SIZE is < 4k
>  #endif

[Severity: High]
Are the prerequisite definitions for PAGE_SIZE_MIN, PAGE_SIZE_MAX,
DEFINE_GLOBAL_PAGE_SIZE_VAR(), and DEFINE_GLOBAL_PAGE_SIZE_VAR_CONST()
missing from this tree?

None of these macros are defined in include/vdso/page.h or anywhere else,
causing build failures across all 13 modified drivers.  In preprocessor
directives, undefined PAGE_SIZE_MIN and PAGE_SIZE_MAX evaluate to 0 (with
-Wundef warnings), triggering this #error unconditionally in
echoaudio_dsp.c and disabling the 4 KiB and 8 KiB fast paths in
sound/pci/emu10k1/memory.c and sound/pci/trident/trident_memory.c.

[ ... ]

> diff --git a/sound/soc/stm/stm32_sai_sub.c b/sound/soc/stm/stm32_sai_sub.c
> index 5d88507b4d0f0..0f34f27041cbd 100644
> --- a/sound/soc/stm/stm32_sai_sub.c
> +++ b/sound/soc/stm/stm32_sai_sub.c
> @@ -1433,23 +1433,25 @@ static int stm32_sai_pcm_process_spdif(struct snd_pcm_substream *substream,
>  }
>  
>  /* No support of mmap in S/PDIF mode */
> -static const struct snd_pcm_hardware stm32_sai_pcm_hw_spdif = {
> +static DEFINE_GLOBAL_PAGE_SIZE_VAR_CONST(struct snd_pcm_hardware,
> +					stm32_sai_pcm_hw_spdif, {
>  	.info = SNDRV_PCM_INFO_INTERLEAVED,
>  	.buffer_bytes_max = 8 * PAGE_SIZE,
>  	.period_bytes_min = 1024,
>  	.period_bytes_max = PAGE_SIZE,
>  	.periods_min = 2,
>  	.periods_max = 8,
> -};
> +});
>  
> -static const struct snd_pcm_hardware stm32_sai_pcm_hw = {
> +static DEFINE_GLOBAL_PAGE_SIZE_VAR_CONST(struct snd_pcm_hardware,
> +					stm32_sai_pcm_hw, {
>  	.info = SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP,
>  	.buffer_bytes_max = 8 * PAGE_SIZE,
>  	.period_bytes_min = 1024, /* 5ms at 48kHz */
>  	.period_bytes_max = PAGE_SIZE,
>  	.periods_min = 2,
>  	.periods_max = 8,
> -};
> +});

[Severity: High]
Does converting stm32_sai_pcm_hw_spdif, stm32_sai_pcm_hw, and
stm32_spdifrx_pcm_hw to DEFINE_GLOBAL_PAGE_SIZE_VAR_CONST() break the
static initializers of stm32_sai_pcm_config, stm32_sai_pcm_config_spdif,
and stm32_spdifrx_pcm_config when PAGE_SIZE is not a compile-time
constant?

Unlike stm32_i2s_pcm_config in sound/soc/stm/stm32_i2s.c, those three
struct snd_dmaengine_pcm_config tables remain plain static const variables:

sound/soc/stm/stm32_sai_sub.c:
static const struct snd_dmaengine_pcm_config stm32_sai_pcm_config = {
	.pcm_hardware = &stm32_sai_pcm_hw,
	.prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config,
};

static const struct snd_dmaengine_pcm_config stm32_sai_pcm_config_spdif = {
	.pcm_hardware = &stm32_sai_pcm_hw_spdif,
	.prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config,
	.process = stm32_sai_pcm_process_spdif,
};

When boot-time page size selection is enabled, &stm32_sai_pcm_hw,
&stm32_sai_pcm_hw_spdif, and &stm32_spdifrx_pcm_hw expand to the address
of a dereferenced accessor call rather than a compile-time constant
address, failing compilation.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261202031733.1704898-1-ericcurtin17@gmail.com?part=1

  reply	other threads:[~2026-12-02  3:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02  3:17 [RFC PATCH v2 0/3] ALSA/ASoC: Prepare for boot-time page size selection on arm64 Eric Curtin
2026-12-02  3:17 ` [RFC PATCH v2 1/3] ALSA: Handle run-time PAGE_SIZE in PCM hardware tables and #if checks Eric Curtin
2026-12-02  3:31   ` sashiko-bot [this message]
2026-12-02  3:17 ` [RFC PATCH v2 2/3] ASoC: tegra: Initialise PCM hardware limits at boot for page size Eric Curtin
2026-12-02  3:27   ` sashiko-bot
2026-12-02  3:17 ` [RFC PATCH v2 3/3] ASoC: codecs: Initialise PCM hardware tables " Eric Curtin
2026-12-02  3:28   ` sashiko-bot

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=sashiko-outbox-244785@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=ericcurtin17@gmail.com \
    --cc=linux-sound@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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.