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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <a9725bfd-a2b8-4343-83f2-d18908029ea0@foss.st.com>
Date: Wed, 17 Sep 2025 16:20:23 +0200
From: Olivier MOYSAN <olivier.moysan@...s.st.com>
To: Kuninori Morimoto <kuninori.morimoto.gx@...esas.com>
CC: Arnaud Pouliquen <arnaud.pouliquen@...s.st.com>,
        Liam Girdwood
	<lgirdwood@...il.com>, Mark Brown <broonie@...nel.org>,
        Jaroslav Kysela
	<perex@...ex.cz>, Takashi Iwai <tiwai@...e.com>,
        Maxime Coquelin
	<mcoquelin.stm32@...il.com>,
        Alexandre Torgue <alexandre.torgue@...s.st.com>,
        <linux-sound@...r.kernel.org>,
        <linux-stm32@...md-mailman.stormreply.com>,
        <linux-arm-kernel@...ts.infradead.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] ASoC: stm32: sai: manage context in set_sysclk callback

Hi Kuninori,

On 9/17/25 02:32, Kuninori Morimoto wrote:
> 
> Hi Olivier
> 
> Thank you for your feedback
> 
>> Here is feedback regarding commit 5725bce709db1c001140d79398581e067e28c031
>> ASoC: simple-card-utils: Unify clock direction by clk_direction
> (snip)
>> To accommodate the change introduced by this commit, I added the property
>> "system-clock-direction-out" in the SAI device tree node.
> (snip)
>> * Before the change:
>> - Initialization:
>> simple_init_dai() -> set_sysclk(id=0, freq=sai_ck freq, dir=out)
>> 	Calls clk_set_rate_exclusive()
>> simple_util_shutdown() -> set_sysclk(id=0, freq=0, dir=out)
>> 	Calls clk_rate_exclusive_put() (releases the mclk clock)
> 
> Here, about "Before the change". Does this "change" mean "before adding
> system-clock-direction-out" or "before commit 5725bce709db1..." ?
> 

Oh yes, I mean both in fact. Namely, before having the commit and the 
system-clock-direction-out property. Typically, I tested on a v6.10 and 
on a v6.17 (or later) where I noticed a change in the SAI driver behavior.

>> * After the change:
>> - Initialization:
>> simple_init_dai() -> set_sysclk(id=0, freq=sai_ck freq, dir=out)
>> 	Calls clk_set_rate_exclusive()
>> simple_util_shutdown() -> set_sysclk(id=0, freq=0, dir=in)
>> 	clk_rate_exclusive_put() NOT called (mclk clock is not released)
> 
> Hmm...
> If it was latest kernel, and if you added "system-clock-direction-out" in DT,
> dir should be "out" in my understanding. dir=in means it doesn't have
> "system-clock-direction-out".
> 
> And, dir will not be changed (out/in) in init / shutdown.
> Are these same DAI ? Both "struct snd_soc_dai" and "struct simple_util_dai"
> have "*name". Could you please double-check it ?
> 

I did supplementary checks, keeping only one DAI and adding additional 
traces. It seems I reached a wrong conclusion regarding the cause of 
unbalanced calls. Sorry for the confusion.
Looking at the traces (see below), initially, we had one call with the 
'in' direction (kernel clock frequency) and one call with the 'out' 
direction.
Now, both calls have the 'out' direction when the property 
'system-clock-direction-out' is set. This seems more consistent with the 
changes from commit 5725bce709db1.
In my setup, the kernel clock is an input clock. Maybe it should be 
tagged as an input clock. However, we have no 
'system-clock-direction-in' property yet.
Anyway, the patch in the STM32 SAI driver is still valid.

v6.10

simple_init_dai - dai: 0x110b6418, dai name: cs42l51-hifi,
simple_init_dai - dai: 0x6204899f, dai name: 4400b004.audio-controller,
stm32_sai_set_sysclk - dai: 0x6204899f, dai name: 
4400b004.audio-controller, id: 0, freq: 29700000, dir: 0
stm32_sai_set_sysclk - dai: 0x6204899f, dai name: 
4400b004.audio-controller, id: 0, freq: 12288000, dir: 1
stm32_sai_set_sysclk - dai: 0x6204899f, [set_rate] current freq: 0, 
request freq: 12288000
simple_util_shutdown - dai: 0x6204899f, dai name: 
4400b004.audio-controller, dir: 0
stm32_sai_set_sysclk - dai: 0x6204899f, dai name: 
4400b004.audio-controller, id: 0, freq: 0, dir: 1
stm32_sai_set_sysclk - dai: 0x6204899f, [put_rate]

v6.17

simple_init_dai - dai: 0xbca889eb, dai name: cs42l51-hifi,
simple_init_dai - dai: 0x4c0382ed, dai name: 4400b004.audio-controller,
stm32_sai_set_sysclk - dai: 0x4c0382ed, dai name: 
4400b004.audio-controller, id: 0, freq: 29700000, dir: 1
stm32_sai_set_sysclk - dai: 0x4c0382ed, [set_rate] current freq: 0, 
request freq: 29700000
stm32_sai_set_sysclk - dai: 0x4c0382ed, dai name: 
4400b004.audio-controller, id: 0, freq: 12288000, dir: 1
stm32_sai_set_sysclk - dai: 0x4c0382ed, [set_rate] current freq: 
24573875, request freq: 12288000
stm32_sai_set_sysclk - dai: 0x4c0382ed, dai name: 
4400b004.audio-controller, id: 0, freq: 12288000, dir: 1
stm32_sai_set_sysclk - dai: 0x4c0382ed, [set_rate] current freq: 
24573875, request freq: 12288000
stm32_sai_set_sysclk - dai: 0x4c0382ed, dai name: 
4400b004.audio-controller, id: 0, freq: 12288000, dir: 1
stm32_sai_set_sysclk - dai: 0x4c0382ed, [set_rate] current freq: 
24573875, request freq: 12288000
stm32_sai_set_sysclk - dai: 0x4c0382ed, dai name: 
4400b004.audio-controller, id: 0, freq: 12288000, dir: 1
stm32_sai_set_sysclk - dai: 0x4c0382ed, [set_rate] current freq: 
24573875, request freq: 12288000
simple_util_shutdown - dai: 0x4c0382ed, dai name: 
4400b004.audio-controller, dir: 1
stm32_sai_set_sysclk - dai: 0x4c0382ed, dai name: 
4400b004.audio-controller, id: 0, freq: 0, dir: 1
stm32_sai_set_sysclk - dai: 0x4c0382ed, [put_rate]

I hope this can be helpful.

Thanks and Best regards
Olivier

> Thank you for your help !!
> 
> Best regards
> ---
> Kuninori Morimoto

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ