[PATCH v4 0/7] Fix races on creation of SDCA jack detection

Charles Keepax posted 7 patches 3 days, 9 hours ago
include/sound/sdca_fdl.h             |   2 +
include/sound/sdca_interrupts.h      |  14 ++-
include/sound/sdca_jack.h            |   3 +
include/sound/soc-component.h        |   2 +
sound/soc/sdca/sdca_class.c          |   4 +-
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           |  88 ++++++++------
sound/soc/soc-component.c            |  10 ++
sound/soc/soc-core.c                 |   5 +
11 files changed, 200 insertions(+), 121 deletions(-)
[PATCH v4 0/7] Fix races on creation of SDCA jack detection
Posted by Charles Keepax 3 days, 9 hours ago
Currently there exists a couple races that can result in the DAPM graph
coming up in a state that doesn't match the hardware with respect to
SDCA jack detection. This series fixes these up by adding a component
level fixup_controls helper into the asoc core and shuffling around the
IRQ requests from the SDCA side.

The core creates DAPM widgets/routes quite a long time before
it creates the associated ALSA control, and the jack detection
IRQ is currently registered in component probe. At the time of
component probe, the DAPM widgets exist, shortly after this the
DAPM routes are added. At the time the DAPM routes are added the
register value for the control is checked and the appropriate path
is connected. The existing handling in the SDCA jack IRQ handles
the case the control doesn't exist and updates the registers
directly, which works until the DAPM routes are added.  After the
routes are added the DAPM graph has already set connected on a
particular DAPM path, which will not be updated until an IRQ is
received when the control is present. Thus those updates are
usually not reflected in the resulting DAPM graph which can lead
to the audio path being erroneously powered on/off.

Thanks,
Charles

Changes since v1:
 - Clean up freeing of the interrupt name, Sashiko astutely pointed out
   there was a memory leak there.
Changes since v2:
 - Add back bus remove in the class driver, and split the IRQ free into
   two functions.
Changes since v3:
 - Renamed sdca_irq_allocate to make more clear it uses devm.
 - Added description of the race onto this cover-letter as well.
 - Removed devm usage from all the primary IRQ requesting, although it
   is still used for the IRQ struct allocation.
 - Added one more fix to move the kcontrol search out of the IRQ.

Charles Keepax (7):
  ASoC: SDCA: Rename sdca_irq_allocate() to include devm
  ASoC: SDCA: Add sdca_irq_cleanup_late()
  ASoC: SDCA: Remove devm from primary IRQ cleanup
  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

 include/sound/sdca_fdl.h             |   2 +
 include/sound/sdca_interrupts.h      |  14 ++-
 include/sound/sdca_jack.h            |   3 +
 include/sound/soc-component.h        |   2 +
 sound/soc/sdca/sdca_class.c          |   4 +-
 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           |  88 ++++++++------
 sound/soc/soc-component.c            |  10 ++
 sound/soc/soc-core.c                 |   5 +
 11 files changed, 200 insertions(+), 121 deletions(-)

-- 
2.47.3