Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ASoC: rt5640: Fix sleep in atomic context

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: stable@vger.kernel.org
Cc: Oder Chiou <oder_chiou@realtek.com>
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Link: https://lore.kernel.org/r/1688015537-31682-4-git-send-email-spujar@nvidia.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Sameer Pujar and committed by
Mark Brown
70a6404f 6dfe70be

+7 -5
+7 -5
sound/soc/codecs/rt5640.c
··· 2567 2567 if (jack_data && jack_data->use_platform_clock) 2568 2568 rt5640->use_platform_clock = jack_data->use_platform_clock; 2569 2569 2570 - ret = request_irq(rt5640->irq, rt5640_irq, 2571 - IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT, 2572 - "rt5640", rt5640); 2570 + ret = devm_request_threaded_irq(component->dev, rt5640->irq, 2571 + NULL, rt5640_irq, 2572 + IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT, 2573 + "rt5640", rt5640); 2573 2574 if (ret) { 2574 2575 dev_warn(component->dev, "Failed to reguest IRQ %d: %d\n", rt5640->irq, ret); 2575 2576 rt5640_disable_jack_detect(component); ··· 2623 2622 2624 2623 rt5640->jack = jack; 2625 2624 2626 - ret = request_irq(rt5640->irq, rt5640_irq, 2627 - IRQF_TRIGGER_RISING | IRQF_ONESHOT, "rt5640", rt5640); 2625 + ret = devm_request_threaded_irq(component->dev, rt5640->irq, 2626 + NULL, rt5640_irq, IRQF_TRIGGER_RISING | IRQF_ONESHOT, 2627 + "rt5640", rt5640); 2628 2628 if (ret) { 2629 2629 dev_warn(component->dev, "Failed to reguest IRQ %d: %d\n", rt5640->irq, ret); 2630 2630 rt5640->irq = -ENXIO;