lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <0670df68-ccc0-6806-cc78-15187481b973@perex.cz>
Date:   Mon, 30 Jan 2023 23:26:14 +0100
From:   Jaroslav Kysela <perex@...ex.cz>
To:     Mario Limonciello <mario.limonciello@....com>,
        Mukunda Vijendar <Vijendar.Mukunda@....com>,
        Saba Kareem Syed <Syed.SabaKareem@....com>,
        linux-kernel@...r.kernel.org
Cc:     Pananchikkal Renjith <Renjith.Pananchikkal@....com>,
        Mark Pearson <mpearson@...ovo.com>,
        Liam Girdwood <lgirdwood@...il.com>,
        Mark Brown <broonie@...nel.org>,
        Jaroslav Kysela <perex@...ex.cz>,
        Takashi Iwai <tiwai@...e.com>, alsa-devel@...a-project.org
Subject: Re: [PATCH v2 2/6] ASoC: amd: yc: Add a module parameter to influence
 pdm_gain

On 30. 01. 23 23:07, Mario Limonciello wrote:
> In case of regressions for any users that the new pdm_gain value is
> too high and for additional debugging, introduce a module parameter
> that would let them configure it.
> 
> This parameter should be removed in the future:
>   * If it's determined that the parameter is not needed, just hardcode
>     the correct value as before
>   * If users do end up using it to debug and report different values
>     we should introduce a config knob that can have policy set by ucm.
> 
> Signed-off-by: Mario Limonciello <mario.limonciello@....com>
> ---
> v1->v2:
>   * Add a guard for values > 3 to overflow the FIELD_PREP
>   * Clear ACP_WOV_GAIN_CONTROL before setting it
> ---
>   sound/soc/amd/yc/acp6x-pdm-dma.c | 10 +++++++++-
>   sound/soc/amd/yc/acp6x.h         |  2 +-
>   2 files changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/sound/soc/amd/yc/acp6x-pdm-dma.c b/sound/soc/amd/yc/acp6x-pdm-dma.c
> index acecd6a4ec4b1..2bb3ea14bae9c 100644
> --- a/sound/soc/amd/yc/acp6x-pdm-dma.c
> +++ b/sound/soc/amd/yc/acp6x-pdm-dma.c
> @@ -7,6 +7,7 @@
>   
>   #include <linux/platform_device.h>
>   #include <linux/module.h>
> +#include <linux/bitfield.h>
>   #include <linux/err.h>
>   #include <linux/io.h>
>   #include <sound/pcm_params.h>
> @@ -18,6 +19,10 @@
>   
>   #define DRV_NAME "acp_yc_pdm_dma"
>   
> +static int pdm_gain = 3;
> +module_param(pdm_gain, int, 0644);
> +MODULE_PARM_DESC(pdm_gain, "Gain control (0-3)");
> +
>   static const struct snd_pcm_hardware acp6x_pdm_hardware_capture = {
>   	.info = SNDRV_PCM_INFO_INTERLEAVED |
>   		SNDRV_PCM_INFO_BLOCK_TRANSFER |
> @@ -55,7 +60,10 @@ static void acp6x_enable_pdm_clock(void __iomem *acp_base)
>   
>   	acp6x_writel(pdm_clk_enable, acp_base + ACP_WOV_CLK_CTRL);
>   	pdm_ctrl = acp6x_readl(acp_base + ACP_WOV_MISC_CTRL);
> -	pdm_ctrl |= ACP_WOV_MISC_CTRL_MASK;
> +	pdm_ctrl &= FIELD_PREP(ACP_WOV_GAIN_CONTROL, 0);

It should be 'pdm_ctrl &= ~ACP_WOV_GAIN_CONTROL' see include/linux/bitfield.h 
(Modify: comment).

> +	if (pdm_gain > 3)
> +		pdm_gain = 3;

Negative values are not handled. Use clamp(pdm_gain, 0, 3) - see 
include/linux/minmax.h.

> +	pdm_ctrl |= FIELD_PREP(ACP_WOV_GAIN_CONTROL, pdm_gain);
>   	acp6x_writel(pdm_ctrl, acp_base + ACP_WOV_MISC_CTRL);

					Jaroslav

-- 
Jaroslav Kysela <perex@...ex.cz>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ