mbox series

[SRU,R,v2,00/14] Fix SDCA jack detection race and reprobe issues on Dell Slate Max platform with CirrusLogic audio solution

Message ID 20260826082456.892463-1-chris.chiu@canonical.com
Headers show
Series Fix SDCA jack detection race and reprobe issues on Dell Slate Max platform with CirrusLogic audio solution | expand

Message

Chris Chiu Aug. 26, 2026, 8:24 a.m. UTC
BugLink: https://bugs.launchpad.net/bugs/2163215

v2 change:
- Added missing fix commit 36c543cc5100 ("ASoC: SDCA: Fix bad move of
  jack_state initialisation") which fixes cb3c257e0824 ("ASoC: SDCA:
  Add correct masks whilst reporting SDCA jack status"). Without this
  commit, the jack_state initialisation was accidentally moved after
  its use, causing incorrect jack detection behavior.

[Impact]
On Dell Slate Max systems with SoundWire Device Class Audio (SDCA) hardware, there is a race condition when setting up jack detection.
Plug headset first, sound can output and headset Mic is workable.
But after cold boot/reboot, audio device is keep but no sound output from headset, headset Mic also no function. Hot plug headset can recovery.

[Fix]
Reorganize SDCA IRQ registration and lifecycle management to run at the correct time and avoid races.

The fixes do this by adding a new component-level callback that runs after all ALSA controls are created. This ensures the jack detection IRQs are registered only when the controls are ready.

Upstream commits (first appeared in v7.2-rc6):
- 3e81e2fb2163 ASoC: Add a component fixup_controls callback
- b8f71f16134f ASoC: SDCA: Switch to fixup_controls callback for IRQ registration
- bf1b7821f853 ASoC: SDCA: Move kcontrol search out of IRQ
- 050406cbd676 ASoC: SDCA: Populate IRQ data earlier
- 0880082c27b6 ASoC: SDCA: Remove devm from primary IRQ cleanup
- f18e97fa7f12 ASoC: SDCA: Add sdca_irq_cleanup_late()
- 4ecef577d1ce ASoC: SDCA: Rename sdca_irq_allocate() to include devm

[Test Plan]
Boot the system, plug headphones in and out, and check if audio switches correctly.

1. Boot the system with headphones unplugged.
2. Plug headphones in and check the jack state:
   $ evtest
   (or check alsamixer/sound settings)
3. Unplug headphones and verify sound switches back.
4. Reload the SoundWire driver modules or trigger suspend/resume to force card teardown and reprobe:
   $ sudo rtcwake -m mem -s 15

   Or reload the SoundWire modules:
   $ sudo modprobe -r snd_sof_intel_sdw
   $ sudo modprobe snd_sof_intel_sdw

Without these patches:
- On boot, headphones might show up as connected when they are not, or sound might not switch correctly when plugged in.
- After suspend/resume or reloading modules, jack detection stops working, or the system crashes/shows warnings due to stale pointers.

With these patches:
- Headphones and speaker paths are always set correctly on boot.
- Jack detection and audio routing work correctly after suspend/resume and driver reloads.

[Where problems could occur]
Could break SDCA jack detection and SoundWire audio class drivers.
If the new fixup_controls callback has a bug, jack IRQs will not be registered. Jack detection could stop working completely.
If the cached kcontrol search gets a wrong pointer, the kernel will crash with a NULL pointer dereference when the IRQ handler runs.

[Other Info]
All seven patches are upstream in v7.2-rc6.

Charles Keepax (14):
  ASoC: SDCA: Add correct masks whilst reporting SDCA jack status
  ASoC: SDCA: Fix bad move of jack_state initialisation
  soundwire: Add a helper function to wait for device initialisation
  soundwire: Always wait for initialisation of unattached devices
  ASoC: SDCA: Use new SoundWire enumeration helper
  ASoC: SDCA: Rename sdca_irq_allocate() to include devm
  ASoC: SDCA: Correct kernel doc for sdca_irq_cleanup()
  ASoC: SDCA: Add sdca_irq_cleanup_late()
  ASoC: SDCA: Remove devm from primary IRQ cleanup
  ASoC: SDCA: Add missing stub for sdca_fdl_free_state()
  ASoC: SDCA: Populate IRQ data earlier
  ASoC: Add a component fixup_controls callback
  ASoC: SDCA: Switch to fixup_controls callback for IRQ registration
  ASoC: SDCA: Move kcontrol search out of IRQ

 drivers/soundwire/bus.c              |  28 +++++
 include/linux/soundwire/sdw.h        |   8 ++
 include/sound/sdca_fdl.h             |   6 +
 include/sound/sdca_interrupts.h      |  14 ++-
 include/sound/sdca_jack.h            |   6 +
 include/sound/soc-component.h        |   2 +
 sound/soc/sdca/sdca_class.c          |  57 ++-------
 sound/soc/sdca/sdca_class.h          |   3 -
 sound/soc/sdca/sdca_class_function.c |   6 +-
 sound/soc/sdca/sdca_fdl.c            |  13 +-
 sound/soc/sdca/sdca_interrupts.c     | 174 +++++++++++++++------------
 sound/soc/sdca/sdca_jack.c           | 164 ++++++++++++++-----------
 sound/soc/soc-component.c            |  10 ++
 sound/soc/soc-core.c                 |   5 +
 14 files changed, 293 insertions(+), 203 deletions(-)

Comments

Rickey Castillo Valenzuela Aug. 26, 2026, 5:10 p.m. UTC | #1
On 8/26/26 02:24, Chris Chiu via kernel-team wrote:
> BugLink: https://bugs.launchpad.net/bugs/2163215
>
> v2 change:
> - Added missing fix commit 36c543cc5100 ("ASoC: SDCA: Fix bad move of
>    jack_state initialisation") which fixes cb3c257e0824 ("ASoC: SDCA:
>    Add correct masks whilst reporting SDCA jack status"). Without this
>    commit, the jack_state initialisation was accidentally moved after
>    its use, causing incorrect jack detection behavior.
>
> [Impact]
> On Dell Slate Max systems with SoundWire Device Class Audio (SDCA) hardware, there is a race condition when setting up jack detection.
> Plug headset first, sound can output and headset Mic is workable.
> But after cold boot/reboot, audio device is keep but no sound output from headset, headset Mic also no function. Hot plug headset can recovery.
>
> [Fix]
> Reorganize SDCA IRQ registration and lifecycle management to run at the correct time and avoid races.
>
> The fixes do this by adding a new component-level callback that runs after all ALSA controls are created. This ensures the jack detection IRQs are registered only when the controls are ready.
>
> Upstream commits (first appeared in v7.2-rc6):
> - 3e81e2fb2163 ASoC: Add a component fixup_controls callback
> - b8f71f16134f ASoC: SDCA: Switch to fixup_controls callback for IRQ registration
> - bf1b7821f853 ASoC: SDCA: Move kcontrol search out of IRQ
> - 050406cbd676 ASoC: SDCA: Populate IRQ data earlier
> - 0880082c27b6 ASoC: SDCA: Remove devm from primary IRQ cleanup
> - f18e97fa7f12 ASoC: SDCA: Add sdca_irq_cleanup_late()
> - 4ecef577d1ce ASoC: SDCA: Rename sdca_irq_allocate() to include devm
>
> [Test Plan]
> Boot the system, plug headphones in and out, and check if audio switches correctly.
>
> 1. Boot the system with headphones unplugged.
> 2. Plug headphones in and check the jack state:
>     $ evtest
>     (or check alsamixer/sound settings)
> 3. Unplug headphones and verify sound switches back.
> 4. Reload the SoundWire driver modules or trigger suspend/resume to force card teardown and reprobe:
>     $ sudo rtcwake -m mem -s 15
>
>     Or reload the SoundWire modules:
>     $ sudo modprobe -r snd_sof_intel_sdw
>     $ sudo modprobe snd_sof_intel_sdw
>
> Without these patches:
> - On boot, headphones might show up as connected when they are not, or sound might not switch correctly when plugged in.
> - After suspend/resume or reloading modules, jack detection stops working, or the system crashes/shows warnings due to stale pointers.
>
> With these patches:
> - Headphones and speaker paths are always set correctly on boot.
> - Jack detection and audio routing work correctly after suspend/resume and driver reloads.
>
> [Where problems could occur]
> Could break SDCA jack detection and SoundWire audio class drivers.
> If the new fixup_controls callback has a bug, jack IRQs will not be registered. Jack detection could stop working completely.
> If the cached kcontrol search gets a wrong pointer, the kernel will crash with a NULL pointer dereference when the IRQ handler runs.
>
> [Other Info]
> All seven patches are upstream in v7.2-rc6.
>
> Charles Keepax (14):
>    ASoC: SDCA: Add correct masks whilst reporting SDCA jack status
>    ASoC: SDCA: Fix bad move of jack_state initialisation
>    soundwire: Add a helper function to wait for device initialisation
>    soundwire: Always wait for initialisation of unattached devices
>    ASoC: SDCA: Use new SoundWire enumeration helper
>    ASoC: SDCA: Rename sdca_irq_allocate() to include devm
>    ASoC: SDCA: Correct kernel doc for sdca_irq_cleanup()
>    ASoC: SDCA: Add sdca_irq_cleanup_late()
>    ASoC: SDCA: Remove devm from primary IRQ cleanup
>    ASoC: SDCA: Add missing stub for sdca_fdl_free_state()
>    ASoC: SDCA: Populate IRQ data earlier
>    ASoC: Add a component fixup_controls callback
>    ASoC: SDCA: Switch to fixup_controls callback for IRQ registration
>    ASoC: SDCA: Move kcontrol search out of IRQ
>
>   drivers/soundwire/bus.c              |  28 +++++
>   include/linux/soundwire/sdw.h        |   8 ++
>   include/sound/sdca_fdl.h             |   6 +
>   include/sound/sdca_interrupts.h      |  14 ++-
>   include/sound/sdca_jack.h            |   6 +
>   include/sound/soc-component.h        |   2 +
>   sound/soc/sdca/sdca_class.c          |  57 ++-------
>   sound/soc/sdca/sdca_class.h          |   3 -
>   sound/soc/sdca/sdca_class_function.c |   6 +-
>   sound/soc/sdca/sdca_fdl.c            |  13 +-
>   sound/soc/sdca/sdca_interrupts.c     | 174 +++++++++++++++------------
>   sound/soc/sdca/sdca_jack.c           | 164 ++++++++++++++-----------
>   sound/soc/soc-component.c            |  10 ++
>   sound/soc/soc-core.c                 |   5 +
>   14 files changed, 293 insertions(+), 203 deletions(-)
>
Please update the LP bug description to add the extra commits info.

Acked-by: Rickey Castillo <rickey.castillo.valenzuela@canonical.com>
Kuan-Ying Lee Aug. 28, 2026, 5:19 a.m. UTC | #2
On Wed, Aug 26, 2026 at 04:24:41PM +0800, Chris Chiu via kernel-team wrote:
> BugLink: https://bugs.launchpad.net/bugs/2163215
> 
> v2 change:
> - Added missing fix commit 36c543cc5100 ("ASoC: SDCA: Fix bad move of
>   jack_state initialisation") which fixes cb3c257e0824 ("ASoC: SDCA:
>   Add correct masks whilst reporting SDCA jack status"). Without this
>   commit, the jack_state initialisation was accidentally moved after
>   its use, causing incorrect jack detection behavior.
> 
> [Impact]
> On Dell Slate Max systems with SoundWire Device Class Audio (SDCA) hardware, there is a race condition when setting up jack detection.
> Plug headset first, sound can output and headset Mic is workable.
> But after cold boot/reboot, audio device is keep but no sound output from headset, headset Mic also no function. Hot plug headset can recovery.
> 
> [Fix]
> Reorganize SDCA IRQ registration and lifecycle management to run at the correct time and avoid races.
> 
> The fixes do this by adding a new component-level callback that runs after all ALSA controls are created. This ensures the jack detection IRQs are registered only when the controls are ready.
> 
> Upstream commits (first appeared in v7.2-rc6):
> - 3e81e2fb2163 ASoC: Add a component fixup_controls callback
> - b8f71f16134f ASoC: SDCA: Switch to fixup_controls callback for IRQ registration
> - bf1b7821f853 ASoC: SDCA: Move kcontrol search out of IRQ
> - 050406cbd676 ASoC: SDCA: Populate IRQ data earlier
> - 0880082c27b6 ASoC: SDCA: Remove devm from primary IRQ cleanup
> - f18e97fa7f12 ASoC: SDCA: Add sdca_irq_cleanup_late()
> - 4ecef577d1ce ASoC: SDCA: Rename sdca_irq_allocate() to include devm
> 
> [Test Plan]
> Boot the system, plug headphones in and out, and check if audio switches correctly.
> 
> 1. Boot the system with headphones unplugged.
> 2. Plug headphones in and check the jack state:
>    $ evtest
>    (or check alsamixer/sound settings)
> 3. Unplug headphones and verify sound switches back.
> 4. Reload the SoundWire driver modules or trigger suspend/resume to force card teardown and reprobe:
>    $ sudo rtcwake -m mem -s 15
> 
>    Or reload the SoundWire modules:
>    $ sudo modprobe -r snd_sof_intel_sdw
>    $ sudo modprobe snd_sof_intel_sdw
> 
> Without these patches:
> - On boot, headphones might show up as connected when they are not, or sound might not switch correctly when plugged in.
> - After suspend/resume or reloading modules, jack detection stops working, or the system crashes/shows warnings due to stale pointers.
> 
> With these patches:
> - Headphones and speaker paths are always set correctly on boot.
> - Jack detection and audio routing work correctly after suspend/resume and driver reloads.
> 
> [Where problems could occur]
> Could break SDCA jack detection and SoundWire audio class drivers.
> If the new fixup_controls callback has a bug, jack IRQs will not be registered. Jack detection could stop working completely.
> If the cached kcontrol search gets a wrong pointer, the kernel will crash with a NULL pointer dereference when the IRQ handler runs.
> 
> [Other Info]
> All seven patches are upstream in v7.2-rc6.
> 
> Charles Keepax (14):
>   ASoC: SDCA: Add correct masks whilst reporting SDCA jack status
>   ASoC: SDCA: Fix bad move of jack_state initialisation
>   soundwire: Add a helper function to wait for device initialisation
>   soundwire: Always wait for initialisation of unattached devices
>   ASoC: SDCA: Use new SoundWire enumeration helper
>   ASoC: SDCA: Rename sdca_irq_allocate() to include devm
>   ASoC: SDCA: Correct kernel doc for sdca_irq_cleanup()
>   ASoC: SDCA: Add sdca_irq_cleanup_late()
>   ASoC: SDCA: Remove devm from primary IRQ cleanup
>   ASoC: SDCA: Add missing stub for sdca_fdl_free_state()
>   ASoC: SDCA: Populate IRQ data earlier
>   ASoC: Add a component fixup_controls callback
>   ASoC: SDCA: Switch to fixup_controls callback for IRQ registration
>   ASoC: SDCA: Move kcontrol search out of IRQ
> 
>  drivers/soundwire/bus.c              |  28 +++++
>  include/linux/soundwire/sdw.h        |   8 ++
>  include/sound/sdca_fdl.h             |   6 +
>  include/sound/sdca_interrupts.h      |  14 ++-
>  include/sound/sdca_jack.h            |   6 +
>  include/sound/soc-component.h        |   2 +
>  sound/soc/sdca/sdca_class.c          |  57 ++-------
>  sound/soc/sdca/sdca_class.h          |   3 -
>  sound/soc/sdca/sdca_class_function.c |   6 +-
>  sound/soc/sdca/sdca_fdl.c            |  13 +-
>  sound/soc/sdca/sdca_interrupts.c     | 174 +++++++++++++++------------
>  sound/soc/sdca/sdca_jack.c           | 164 ++++++++++++++-----------
>  sound/soc/soc-component.c            |  10 ++
>  sound/soc/soc-core.c                 |   5 +
>  14 files changed, 293 insertions(+), 203 deletions(-)

Acked-by: Kuan-Ying Lee <kuan-ying.lee@canonical.com>
Edoardo Canepa Aug. 28, 2026, 6:53 p.m. UTC | #3
Rejected for the following reasons:

10/14 commits are features/refactor. These modifications are too much 
for SRU

On 8/26/26 11:24, Chris Chiu via kernel-team wrote:
> BugLink: https://bugs.launchpad.net/bugs/2163215
>
> v2 change:
> - Added missing fix commit 36c543cc5100 ("ASoC: SDCA: Fix bad move of
>    jack_state initialisation") which fixes cb3c257e0824 ("ASoC: SDCA:
>    Add correct masks whilst reporting SDCA jack status"). Without this
>    commit, the jack_state initialisation was accidentally moved after
>    its use, causing incorrect jack detection behavior.
>
> [Impact]
> On Dell Slate Max systems with SoundWire Device Class Audio (SDCA) hardware, there is a race condition when setting up jack detection.
> Plug headset first, sound can output and headset Mic is workable.
> But after cold boot/reboot, audio device is keep but no sound output from headset, headset Mic also no function. Hot plug headset can recovery.
>
> [Fix]
> Reorganize SDCA IRQ registration and lifecycle management to run at the correct time and avoid races.
>
> The fixes do this by adding a new component-level callback that runs after all ALSA controls are created. This ensures the jack detection IRQs are registered only when the controls are ready.
>
> Upstream commits (first appeared in v7.2-rc6):
> - 3e81e2fb2163 ASoC: Add a component fixup_controls callback
> - b8f71f16134f ASoC: SDCA: Switch to fixup_controls callback for IRQ registration
> - bf1b7821f853 ASoC: SDCA: Move kcontrol search out of IRQ
> - 050406cbd676 ASoC: SDCA: Populate IRQ data earlier
> - 0880082c27b6 ASoC: SDCA: Remove devm from primary IRQ cleanup
> - f18e97fa7f12 ASoC: SDCA: Add sdca_irq_cleanup_late()
> - 4ecef577d1ce ASoC: SDCA: Rename sdca_irq_allocate() to include devm
>
> [Test Plan]
> Boot the system, plug headphones in and out, and check if audio switches correctly.
>
> 1. Boot the system with headphones unplugged.
> 2. Plug headphones in and check the jack state:
>     $ evtest
>     (or check alsamixer/sound settings)
> 3. Unplug headphones and verify sound switches back.
> 4. Reload the SoundWire driver modules or trigger suspend/resume to force card teardown and reprobe:
>     $ sudo rtcwake -m mem -s 15
>
>     Or reload the SoundWire modules:
>     $ sudo modprobe -r snd_sof_intel_sdw
>     $ sudo modprobe snd_sof_intel_sdw
>
> Without these patches:
> - On boot, headphones might show up as connected when they are not, or sound might not switch correctly when plugged in.
> - After suspend/resume or reloading modules, jack detection stops working, or the system crashes/shows warnings due to stale pointers.
>
> With these patches:
> - Headphones and speaker paths are always set correctly on boot.
> - Jack detection and audio routing work correctly after suspend/resume and driver reloads.
>
> [Where problems could occur]
> Could break SDCA jack detection and SoundWire audio class drivers.
> If the new fixup_controls callback has a bug, jack IRQs will not be registered. Jack detection could stop working completely.
> If the cached kcontrol search gets a wrong pointer, the kernel will crash with a NULL pointer dereference when the IRQ handler runs.
>
> [Other Info]
> All seven patches are upstream in v7.2-rc6.
>
> Charles Keepax (14):
>    ASoC: SDCA: Add correct masks whilst reporting SDCA jack status
>    ASoC: SDCA: Fix bad move of jack_state initialisation
>    soundwire: Add a helper function to wait for device initialisation
>    soundwire: Always wait for initialisation of unattached devices
>    ASoC: SDCA: Use new SoundWire enumeration helper
>    ASoC: SDCA: Rename sdca_irq_allocate() to include devm
>    ASoC: SDCA: Correct kernel doc for sdca_irq_cleanup()
>    ASoC: SDCA: Add sdca_irq_cleanup_late()
>    ASoC: SDCA: Remove devm from primary IRQ cleanup
>    ASoC: SDCA: Add missing stub for sdca_fdl_free_state()
>    ASoC: SDCA: Populate IRQ data earlier
>    ASoC: Add a component fixup_controls callback
>    ASoC: SDCA: Switch to fixup_controls callback for IRQ registration
>    ASoC: SDCA: Move kcontrol search out of IRQ
>
>   drivers/soundwire/bus.c              |  28 +++++
>   include/linux/soundwire/sdw.h        |   8 ++
>   include/sound/sdca_fdl.h             |   6 +
>   include/sound/sdca_interrupts.h      |  14 ++-
>   include/sound/sdca_jack.h            |   6 +
>   include/sound/soc-component.h        |   2 +
>   sound/soc/sdca/sdca_class.c          |  57 ++-------
>   sound/soc/sdca/sdca_class.h          |   3 -
>   sound/soc/sdca/sdca_class_function.c |   6 +-
>   sound/soc/sdca/sdca_fdl.c            |  13 +-
>   sound/soc/sdca/sdca_interrupts.c     | 174 +++++++++++++++------------
>   sound/soc/sdca/sdca_jack.c           | 164 ++++++++++++++-----------
>   sound/soc/soc-component.c            |  10 ++
>   sound/soc/soc-core.c                 |   5 +
>   14 files changed, 293 insertions(+), 203 deletions(-)
>