This series fixes some of the issues which were observed during an attempt to
enhance automated test coverage on Jetson AGX Orin. Below is a short summary
of the issues and fixes:
* Sample rate coversion failures above 48kHz.
* AMX and ADX test cases failures due to incorrect byte mask.
* Atomic sleep in RT5640 codec which is present on Jetson AGX Orin.
* AHUB clock fixes on Tegra234 and previous chips.
* Minor cleanups in ASRC and AHUB driver.
Changelog
=========
v1 -> v2:
---------
* Few patches got accepted in the original (v1) series. Now v2
addresses comments for remaining patches.
* AMX/ADX byte map fix patch is updated with more details
in the commit message and added TODO item in the driver
to improve the logic.
* For RT5640 codec patch, the threaded IRQ is used for
only for rt5640_irq() and rt5640_jd_gpio_irq() is left
untouched.
Sameer Pujar (2):
ASoC: rt5640: Fix sleep in atomic context
arm64: tegra: Update AHUB clock parent and rate
Sheetal (3):
ASoC: tegra: Fix AMX byte map
ASoC: tegra: Fix ADX byte map
arm64: tegra: Update AHUB clock parent and rate on Tegra234
arch/arm64/boot/dts/nvidia/tegra186.dtsi | 3 ++-
arch/arm64/boot/dts/nvidia/tegra194.dtsi | 3 ++-
arch/arm64/boot/dts/nvidia/tegra210.dtsi | 3 ++-
arch/arm64/boot/dts/nvidia/tegra234.dtsi | 3 ++-
sound/soc/codecs/rt5640.c | 12 ++++++----
sound/soc/tegra/tegra210_adx.c | 34 +++++++++++++++++----------
sound/soc/tegra/tegra210_amx.c | 40 ++++++++++++++++++--------------
7 files changed, 59 insertions(+), 39 deletions(-)
--
2.7.4
From: Sheetal <[email protected]>
I2S data sanity tests fail beyond a bit clock frequency of 6.144MHz.
This happens because the AHUB clock rate is too low and it shows
9.83MHz on boot.
The maximum rate of PLLA_OUT0 is 49.152MHz and is used to serve I/O
clocks. It is recommended that AHUB clock operates higher than this.
Thus fix this by using PLLP_OUT0 as parent clock for AHUB instead of
PLLA_OUT0 and fix the rate to 81.6MHz.
Fixes: dc94a94daa39 ("arm64: tegra: Add audio devices on Tegra234")
Cc: [email protected]
Signed-off-by: Sheetal <[email protected]>
Signed-off-by: Sameer Pujar <[email protected]>
Reviewed-by: Mohan Kumar D <[email protected]>
---
arch/arm64/boot/dts/nvidia/tegra234.dtsi | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/arm64/boot/dts/nvidia/tegra234.dtsi b/arch/arm64/boot/dts/nvidia/tegra234.dtsi
index f4974e8..0f12a8de 100644
--- a/arch/arm64/boot/dts/nvidia/tegra234.dtsi
+++ b/arch/arm64/boot/dts/nvidia/tegra234.dtsi
@@ -180,7 +180,8 @@
clocks = <&bpmp TEGRA234_CLK_AHUB>;
clock-names = "ahub";
assigned-clocks = <&bpmp TEGRA234_CLK_AHUB>;
- assigned-clock-parents = <&bpmp TEGRA234_CLK_PLLA_OUT0>;
+ assigned-clock-parents = <&bpmp TEGRA234_CLK_PLLP_OUT0>;
+ assigned-clock-rates = <81600000>;
status = "disabled";
#address-cells = <2>;
--
2.7.4
Following prints are observed while testing audio on Jetson AGX Orin which
has onboard RT5640 audio codec:
BUG: sleeping function called from invalid context at kernel/workqueue.c:3027
in_atomic(): 1, irqs_disabled(): 128, non_block: 0, pid: 0, name: swapper/0
preempt_count: 10001, expected: 0
RCU nest depth: 0, expected: 0
------------[ cut here ]------------
WARNING: CPU: 0 PID: 0 at kernel/irq/handle.c:159 __handle_irq_event_percpu+0x1e0/0x270
---[ end trace ad1c64905aac14a6 ]-
The IRQ handler rt5640_irq() runs in interrupt context and can sleep
during cancel_delayed_work_sync().
Fix this by running IRQ handler, rt5640_irq(), in thread context.
Hence replace request_irq() calls with devm_request_threaded_irq().
Fixes: 051dade34695 ("ASoC: rt5640: Fix the wrong state of JD1 and JD2")
Cc: [email protected]
Cc: Oder Chiou <[email protected]>
Signed-off-by: Sameer Pujar <[email protected]>
---
sound/soc/codecs/rt5640.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c
index 0ed4fa2..e24ed75 100644
--- a/sound/soc/codecs/rt5640.c
+++ b/sound/soc/codecs/rt5640.c
@@ -2567,9 +2567,10 @@ static void rt5640_enable_jack_detect(struct snd_soc_component *component,
if (jack_data && jack_data->use_platform_clock)
rt5640->use_platform_clock = jack_data->use_platform_clock;
- ret = request_irq(rt5640->irq, rt5640_irq,
- IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
- "rt5640", rt5640);
+ ret = devm_request_threaded_irq(component->dev, rt5640->irq,
+ NULL, rt5640_irq,
+ IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
+ "rt5640", rt5640);
if (ret) {
dev_warn(component->dev, "Failed to reguest IRQ %d: %d\n", rt5640->irq, ret);
rt5640_disable_jack_detect(component);
@@ -2622,8 +2623,9 @@ static void rt5640_enable_hda_jack_detect(
rt5640->jack = jack;
- ret = request_irq(rt5640->irq, rt5640_irq,
- IRQF_TRIGGER_RISING | IRQF_ONESHOT, "rt5640", rt5640);
+ ret = devm_request_threaded_irq(component->dev, rt5640->irq,
+ NULL, rt5640_irq, IRQF_TRIGGER_RISING | IRQF_ONESHOT,
+ "rt5640", rt5640);
if (ret) {
dev_warn(component->dev, "Failed to reguest IRQ %d: %d\n", rt5640->irq, ret);
rt5640->irq = -ENXIO;
--
2.7.4
From: Sameer Pujar
> Sent: 29 June 2023 06:12
>
> Following prints are observed while testing audio on Jetson AGX Orin which
> has onboard RT5640 audio codec:
>
> BUG: sleeping function called from invalid context at kernel/workqueue.c:3027
> in_atomic(): 1, irqs_disabled(): 128, non_block: 0, pid: 0, name: swapper/0
> preempt_count: 10001, expected: 0
> RCU nest depth: 0, expected: 0
> ------------[ cut here ]------------
> WARNING: CPU: 0 PID: 0 at kernel/irq/handle.c:159 __handle_irq_event_percpu+0x1e0/0x270
> ---[ end trace ad1c64905aac14a6 ]-
>
> The IRQ handler rt5640_irq() runs in interrupt context and can sleep
> during cancel_delayed_work_sync().
>
> Fix this by running IRQ handler, rt5640_irq(), in thread context.
> Hence replace request_irq() calls with devm_request_threaded_irq().
My 'gut feel' is that this will just move the problem elsewhere.
If the ISR is responsible for adding audio buffers (etc) then it is
also not unlikely that the scheduling delays in running a threaded ISR
will cause audio glitches if the system is busy.
>
> Fixes: 051dade34695 ("ASoC: rt5640: Fix the wrong state of JD1 and JD2")
> Cc: [email protected]
> Cc: Oder Chiou <[email protected]>
> Signed-off-by: Sameer Pujar <[email protected]>
> ---
> sound/soc/codecs/rt5640.c | 12 +++++++-----
> 1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c
> index 0ed4fa2..e24ed75 100644
> --- a/sound/soc/codecs/rt5640.c
> +++ b/sound/soc/codecs/rt5640.c
> @@ -2567,9 +2567,10 @@ static void rt5640_enable_jack_detect(struct snd_soc_component *component,
> if (jack_data && jack_data->use_platform_clock)
> rt5640->use_platform_clock = jack_data->use_platform_clock;
>
> - ret = request_irq(rt5640->irq, rt5640_irq,
> - IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
> - "rt5640", rt5640);
> + ret = devm_request_threaded_irq(component->dev, rt5640->irq,
> + NULL, rt5640_irq,
> + IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
> + "rt5640", rt5640);
You need a comment saying this must be a threaded IRQ because the ISR
calls cancel_delayed_work_sync().
David
> if (ret) {
> dev_warn(component->dev, "Failed to reguest IRQ %d: %d\n", rt5640->irq, ret);
> rt5640_disable_jack_detect(component);
> @@ -2622,8 +2623,9 @@ static void rt5640_enable_hda_jack_detect(
>
> rt5640->jack = jack;
>
> - ret = request_irq(rt5640->irq, rt5640_irq,
> - IRQF_TRIGGER_RISING | IRQF_ONESHOT, "rt5640", rt5640);
> + ret = devm_request_threaded_irq(component->dev, rt5640->irq,
> + NULL, rt5640_irq, IRQF_TRIGGER_RISING | IRQF_ONESHOT,
> + "rt5640", rt5640);
> if (ret) {
> dev_warn(component->dev, "Failed to reguest IRQ %d: %d\n", rt5640->irq, ret);
> rt5640->irq = -ENXIO;
> --
> 2.7.4
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
On Thu, Jun 29, 2023 at 08:38:09AM +0000, David Laight wrote:
> From: Sameer Pujar
> > Following prints are observed while testing audio on Jetson AGX Orin which
> > has onboard RT5640 audio codec:
> >
> > BUG: sleeping function called from invalid context at kernel/workqueue.c:3027
> > in_atomic(): 1, irqs_disabled(): 128, non_block: 0, pid: 0, name: swapper/0
> My 'gut feel' is that this will just move the problem elsewhere.
> If the ISR is responsible for adding audio buffers (etc) then it is
> also not unlikely that the scheduling delays in running a threaded ISR
> will cause audio glitches if the system is busy.
What makes you think this is anything to do with audio glitches? The
bug is literally what is described, it is not valid to sleep in atomic
contexts and if we ever actually try things are likely to go badly.
On Thu, Jun 29, 2023 at 10:21:06AM +0000, David Laight wrote:
> From: Mark Brown
> > What makes you think this is anything to do with audio glitches? The
> > bug is literally what is described, it is not valid to sleep in atomic
> > contexts and if we ever actually try things are likely to go badly.
> What I mean is that deferring the ISR to process context
> is likely to generate audio glitches on a busy system.
This is an I2C connected CODEC. We're not doing anything with it in
atomic context, and nothing it does is going to be *that* latency
sensitive.
From: Mark Brown
> Sent: 29 June 2023 11:11
>
> On Thu, Jun 29, 2023 at 08:38:09AM +0000, David Laight wrote:
> > From: Sameer Pujar
>
> > > Following prints are observed while testing audio on Jetson AGX Orin which
> > > has onboard RT5640 audio codec:
> > >
> > > BUG: sleeping function called from invalid context at kernel/workqueue.c:3027
> > > in_atomic(): 1, irqs_disabled(): 128, non_block: 0, pid: 0, name: swapper/0
>
> > My 'gut feel' is that this will just move the problem elsewhere.
>
> > If the ISR is responsible for adding audio buffers (etc) then it is
> > also not unlikely that the scheduling delays in running a threaded ISR
> > will cause audio glitches if the system is busy.
>
> What makes you think this is anything to do with audio glitches? The
> bug is literally what is described, it is not valid to sleep in atomic
> contexts and if we ever actually try things are likely to go badly.
What I mean is that deferring the ISR to process context
is likely to generate audio glitches on a busy system.
I realise that sleeping in an ISR goes badly wrong.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
On Thu, 29 Jun 2023 10:42:12 +0530, Sameer Pujar wrote:
> This series fixes some of the issues which were observed during an attempt to
> enhance automated test coverage on Jetson AGX Orin. Below is a short summary
> of the issues and fixes:
>
> * Sample rate coversion failures above 48kHz.
> * AMX and ADX test cases failures due to incorrect byte mask.
> * Atomic sleep in RT5640 codec which is present on Jetson AGX Orin.
> * AHUB clock fixes on Tegra234 and previous chips.
> * Minor cleanups in ASRC and AHUB driver.
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/5] ASoC: tegra: Fix AMX byte map
commit: 49bd7b08149417a30aa7d92c8c85b3518de44a76
[2/5] ASoC: tegra: Fix ADX byte map
commit: 6dfe70be0b0dec0f9297811501bec26c05fd96ad
[3/5] ASoC: rt5640: Fix sleep in atomic context
commit: 70a6404ff610aa4889d98977da131c37f9ff9d1f
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
From: Thierry Reding <[email protected]>
On Thu, 29 Jun 2023 10:42:12 +0530, Sameer Pujar wrote:
> This series fixes some of the issues which were observed during an attempt to
> enhance automated test coverage on Jetson AGX Orin. Below is a short summary
> of the issues and fixes:
>
> * Sample rate coversion failures above 48kHz.
> * AMX and ADX test cases failures due to incorrect byte mask.
> * Atomic sleep in RT5640 codec which is present on Jetson AGX Orin.
> * AHUB clock fixes on Tegra234 and previous chips.
> * Minor cleanups in ASRC and AHUB driver.
>
> [...]
Applied, thanks!
[4/5] arm64: tegra: Update AHUB clock parent and rate on Tegra234
commit: e483fe34adab3197558b7284044c1b26f5ede20e
[5/5] arm64: tegra: Update AHUB clock parent and rate
commit: dc6d5d85ed3a3fe566314f388bce4c71a26b1677
Best regards,
--
Thierry Reding <[email protected]>