Skip to contentSkip to conversation

Fix races on creation of SDCA jack detection

PATCH In review Charles Keepax 2 participants 9 messages Jul 21 – Jul 27

Subsystems (3)
lore
Share & tools
lore

Charles Keepax

author maintainer
#0 lore raw

v4 cover Fix races on creation of SDCA jack detection

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(-)
Signature · 1 line
2.47.3
author maintainer
#1 lore raw

PATCH v4 1/7 ASoC: SDCA: Rename sdca_irq_allocate() to include devm

Make it more clear sdca_irq_allocate() uses devm allocations by adding it into the name.

---

New since v3.

 include/sound/sdca_interrupts.h  | 5 +++--
 sound/soc/sdca/sdca_class.c      | 4 ++--
 sound/soc/sdca/sdca_interrupts.c | 8 ++++----
 3 files changed, 9 insertions(+), 8 deletions(-)
include/sound/sdca_interrupts.h +3 -2
index a515cc3df0971..28fd44eb93343 100644
@@ -86,8 +86,9 @@ int sdca_irq_populate(struct sdca_function_data *function,
 void sdca_irq_cleanup(struct device *dev,
 		      struct sdca_function_data *function,
 		      struct sdca_interrupt_info *info);
-struct sdca_interrupt_info *sdca_irq_allocate(struct device *dev,
-					      struct regmap *regmap, int irq);
+
+struct sdca_interrupt_info *devm_sdca_irq_allocate(struct device *dev,
+						   struct regmap *regmap, int irq);
 
 void sdca_irq_enable_early(struct sdca_function_data *function,
 			   struct sdca_interrupt_info *info);
sound/soc/sdca/sdca_class.c +2 -2
index 8d7b007a068fd..d7444f442c71c 100644
@@ -111,8 +111,8 @@ static void class_boot_work(struct work_struct *work)
 
 	regcache_cache_only(drv->dev_regmap, false);
 
-	drv->irq_info = sdca_irq_allocate(drv->dev, drv->dev_regmap,
-					  drv->sdw->irq);
+	drv->irq_info = devm_sdca_irq_allocate(drv->dev, drv->dev_regmap,
+					       drv->sdw->irq);
 	if (IS_ERR(drv->irq_info))
 		goto err;
 
sound/soc/sdca/sdca_interrupts.c +4 -4
index 4539a52a8e32b..1e4efc0609d93 100644
@@ -592,7 +592,7 @@ void sdca_irq_cleanup(struct device *dev,
 EXPORT_SYMBOL_NS_GPL(sdca_irq_cleanup, "SND_SOC_SDCA");
 
 /**
- * sdca_irq_allocate - allocate an SDCA interrupt structure for a device
+ * devm_sdca_irq_allocate - allocate an SDCA interrupt structure for a device
  * @sdev: Device pointer against which things should be allocated.
  * @regmap: regmap to be used for accessing the SDCA IRQ registers.
  * @irq: The interrupt number.
@@ -604,8 +604,8 @@ EXPORT_SYMBOL_NS_GPL(sdca_irq_cleanup, "SND_SOC_SDCA");
  * Return: A pointer to the allocated sdca_interrupt_info struct, or an
  * error code.
  */
-struct sdca_interrupt_info *sdca_irq_allocate(struct device *sdev,
-					      struct regmap *regmap, int irq)
+struct sdca_interrupt_info *devm_sdca_irq_allocate(struct device *sdev,
+						   struct regmap *regmap, int irq)
 {
 	struct sdca_interrupt_info *info;
 	int ret, i;
@@ -634,7 +634,7 @@ struct sdca_interrupt_info *sdca_irq_allocate(struct device *sdev,
 
 	return info;
 }
-EXPORT_SYMBOL_NS_GPL(sdca_irq_allocate, "SND_SOC_SDCA");
+EXPORT_SYMBOL_NS_GPL(devm_sdca_irq_allocate, "SND_SOC_SDCA");
 
 static void irq_enable_flags(struct sdca_function_data *function,
 			     struct sdca_interrupt_info *info, bool early)
Signature · 1 line
2.47.3
author maintainer
#2 lore raw

PATCH v4 2/7 ASoC: SDCA: Add sdca_irq_cleanup_late()

In reply to Charles Keepax

The SDCA IRQs are split into two groups, those registered at bus probe time (basically just FDL) and those registered at component time. There currently exists only a single cleanup function, if the FDL IRQ is freed at component time, then nothing would re-register it if the component is probed again. But the IRQs depending on a component need to be freed if the card is destroyed so they can't use stale components.

Split the clean up into two functions one for the component level and one for the bus level.

---

Changes since v3:
- Switched to using an early request flag rather than a big switch.
- Renamed the cleanup flag to be a little clear.

 include/sound/sdca_interrupts.h      |  5 +++
 sound/soc/sdca/sdca_class_function.c |  2 +-
 sound/soc/sdca/sdca_interrupts.c     | 53 ++++++++++++++++++++++------
 3 files changed, 48 insertions(+), 12 deletions(-)
include/sound/sdca_interrupts.h +5 -0
index 28fd44eb93343..38c6c58c2cc78 100644
@@ -33,6 +33,7 @@ struct sdca_function_data;
  * @priv: Pointer to private data for use by the handler.
  * @irq: IRQ number allocated to this interrupt, also used internally to track
  * the IRQ being assigned.
+ * @early_request: Flag to indicate this IRQ was requested at bus probe time.
  */
 struct sdca_interrupt {
 	const char *name;
@@ -48,6 +49,7 @@ struct sdca_interrupt {
 	void *priv;
 
 	int irq;
+	bool early_request;
 };
 
 /**
@@ -86,6 +88,9 @@ int sdca_irq_populate(struct sdca_function_data *function,
 void sdca_irq_cleanup(struct device *dev,
 		      struct sdca_function_data *function,
 		      struct sdca_interrupt_info *info);
+void sdca_irq_cleanup_late(struct device *dev,
+			   struct sdca_function_data *function,
+			   struct sdca_interrupt_info *info);
 
 struct sdca_interrupt_info *devm_sdca_irq_allocate(struct device *dev,
 						   struct regmap *regmap, int irq);
sound/soc/sdca/sdca_class_function.c +1 -1
index 1496a15f7d2ac..5ae6c727c796d 100644
@@ -408,7 +408,7 @@ static void class_function_remove(struct auxiliary_device *auxdev)
 {
 	struct class_function_drv *drv = auxiliary_get_drvdata(auxdev);
 
-	sdca_irq_cleanup(drv->dev, drv->function, drv->core->irq_info);
+	sdca_irq_cleanup_late(drv->dev, drv->function, drv->core->irq_info);
 }
 
 static int class_function_runtime_suspend(struct device *dev)
sound/soc/sdca/sdca_interrupts.c +42 -11

78 lines not on this page · raw message

Signature · 1 line
2.47.3
author maintainer
#3 lore raw

PATCH v4 3/7 ASoC: SDCA: Remove devm from primary IRQ cleanup

In reply to Charles Keepax

To provide greater flexibility on when the IRQs are requested for client drivers don't use devm for the primary IRQ request/cleanup helper functions.

---

New since v3.

 include/sound/sdca_fdl.h         |  2 ++
 include/sound/sdca_interrupts.h  |  2 ++
 include/sound/sdca_jack.h        |  2 ++
 sound/soc/sdca/sdca_fdl.c        | 13 +++++++++++--
 sound/soc/sdca/sdca_interrupts.c |  8 ++++++++
 sound/soc/sdca/sdca_jack.c       | 13 +++++++++++--
 6 files changed, 36 insertions(+), 4 deletions(-)
include/sound/sdca_fdl.h +2 -0
index fbaf4b384c8af..dc33927b82bde 100644
@@ -67,6 +67,8 @@ struct fdl_state {
 #if IS_ENABLED(CONFIG_SND_SOC_SDCA_FDL)
 
 int sdca_fdl_alloc_state(struct sdca_interrupt *interrupt);
+void sdca_fdl_free_state(struct sdca_interrupt *interrupt);
+
 int sdca_fdl_process(struct sdca_interrupt *interrupt);
 int sdca_fdl_sync(struct device *dev, struct sdca_function_data *function,
 		  struct sdca_interrupt_info *info);
include/sound/sdca_interrupts.h +2 -0
index 38c6c58c2cc78..8a44c19e917ce 100644
@@ -31,6 +31,7 @@ struct sdca_function_data;
  * @entity: Pointer to the Entity that the interrupt is associated with.
  * @control: Pointer to the Control that the interrupt is associated with.
  * @priv: Pointer to private data for use by the handler.
+ * @free_priv: Pointer to a function that can be used to free the priv data.
  * @irq: IRQ number allocated to this interrupt, also used internally to track
  * the IRQ being assigned.
  * @early_request: Flag to indicate this IRQ was requested at bus probe time.
@@ -47,6 +48,7 @@ struct sdca_interrupt {
 	struct sdca_control *control;
 
 	void *priv;
+	void (*free_priv)(struct sdca_interrupt *interrupt);
 
 	int irq;
 	bool early_request;
include/sound/sdca_jack.h +2 -0
index 181541f0f4d8c..59de40b7d7d01 100644
@@ -28,6 +28,8 @@ struct jack_state {
 };
 
 int sdca_jack_alloc_state(struct sdca_interrupt *interrupt);
+void sdca_jack_free_state(struct sdca_interrupt *interrupt);
+
 int sdca_jack_process(struct sdca_interrupt *interrupt);
 int sdca_jack_set_jack(struct sdca_interrupt_info *info, struct snd_soc_jack *jack);
 int sdca_jack_report(struct sdca_interrupt *interrupt);
sound/soc/sdca/sdca_fdl.c +11 -2
index 994821a6df617..82e09d960c127 100644
@@ -481,10 +481,9 @@ EXPORT_SYMBOL_NS_GPL(sdca_fdl_process, "SND_SOC_SDCA");
  */
 int sdca_fdl_alloc_state(struct sdca_interrupt *interrupt)
 {
-	struct device *dev = interrupt->dev;
 	struct fdl_state *fdl_state;
 
-	fdl_state = devm_kzalloc(dev, sizeof(*fdl_state), GFP_KERNEL);
+	fdl_state = kzalloc_obj(*fdl_state);
 	if (!fdl_state)
 		return -ENOMEM;
 
@@ -499,3 +498,13 @@ int sdca_fdl_alloc_state(struct sdca_interrupt *interrupt)
 	return 0;
 }
 EXPORT_SYMBOL_NS_GPL(sdca_fdl_alloc_state, "SND_SOC_SDCA");
+
+/**
+ * sdca_fdl_free_state - free state for an FDL interrupt
+ * @interrupt: SDCA interrupt structure.
+ */
+void sdca_fdl_free_state(struct sdca_interrupt *interrupt)
+{
+	kfree(interrupt->priv);
+}
+EXPORT_SYMBOL_NS_GPL(sdca_fdl_free_state, "SND_SOC_SDCA");
sound/soc/sdca/sdca_interrupts.c +8 -0
index d86884a89c405..cd2c5d49bb95b 100644
@@ -457,6 +457,7 @@ int sdca_irq_populate_early(struct device *dev, struct regmap *regmap,
 					return ret;
 
 				interrupt->early_request = true;
+				interrupt->free_priv = sdca_fdl_free_state;
 
 				ret = sdca_fdl_alloc_state(interrupt);
 				if (ret)
@@ -530,6 +531,8 @@ int sdca_irq_populate(struct sdca_function_data *function,
 				handler = function_status_handler;
 				break;
 			case SDCA_CTL_TYPE_S(GE, DETECTED_MODE):
+				interrupt->free_priv = sdca_jack_free_state;
+
 				ret = sdca_jack_alloc_state(interrupt);
 				if (ret)
 					return ret;
@@ -537,6 +540,8 @@ int sdca_irq_populate(struct sdca_function_data *function,
 				handler = detected_mode_handler;
 				break;
 			case SDCA_CTL_TYPE_S(XU, FDL_CURRENTOWNER):
+				interrupt->free_priv = sdca_fdl_free_state;
+
 				ret = sdca_fdl_alloc_state(interrupt);
 				if (ret)
 					return ret;
@@ -584,6 +589,9 @@ static void sdca_irq_cleanup_flags(struct device *dev,
 
 		sdca_irq_free_locked(dev, info, i, interrupt->name, interrupt);
 
+		if (interrupt->free_priv)
+			interrupt->free_priv(interrupt);
+
 		kfree(interrupt->name);
 	}
 }
sound/soc/sdca/sdca_jack.c +11 -2
index ae9636622a840..ffa8709649248 100644
@@ -132,10 +132,9 @@ EXPORT_SYMBOL_NS_GPL(sdca_jack_process, "SND_SOC_SDCA");
  */
 int sdca_jack_alloc_state(struct sdca_interrupt *interrupt)
 {
-	struct device *dev = interrupt->dev;
 	struct jack_state *jack_state;
 
-	jack_state = devm_kzalloc(dev, sizeof(*jack_state), GFP_KERNEL);
+	jack_state = kzalloc_obj(*jack_state);
 	if (!jack_state)
 		return -ENOMEM;
 
@@ -145,6 +144,16 @@ int sdca_jack_alloc_state(struct sdca_interrupt *interrupt)
 }
 EXPORT_SYMBOL_NS_GPL(sdca_jack_alloc_state, "SND_SOC_SDCA");
 
+/**
+ * sdca_jack_free_state - free state for a jack interrupt
+ * @interrupt: SDCA interrupt structure.
+ */
+void sdca_jack_free_state(struct sdca_interrupt *interrupt)
+{
+	kfree(interrupt->priv);
+}
+EXPORT_SYMBOL_NS_GPL(sdca_jack_free_state, "SND_SOC_SDCA");
+
 static int type_get_mask(enum sdca_terminal_type type)
 {
 	switch (type) {
Signature · 1 line
2.47.3
author maintainer
#4 lore raw

PATCH v4 4/7 ASoC: SDCA: Populate IRQ data earlier

In reply to Charles Keepax

Currently, the IRQ data (attached Entity/Control/etc) is populated as the IRQ is requested. However, this can cause issues as occasionally the setup process wants to access specifics of an IRQ before the IRQ is actually enabled. To facilitate this cache all the IRQ data during sdca_irq_populate_early() and make sdca_irq_populate() simply request the outstanding IRQs. This also has the advantage that sdca_irq_populate() can now just iterate through the IRQ array which is much smaller/faster than going through every Entity in the Function for Controls.

---

Changes since v3:
- Updated some bits of kernel doc
- Moved before fixup_controls in the chain

 include/sound/sdca_interrupts.h  |   2 +
 sound/soc/sdca/sdca_interrupts.c | 115 ++++++++++++-------------------
 2 files changed, 47 insertions(+), 70 deletions(-)
include/sound/sdca_interrupts.h +2 -0
index 8a44c19e917ce..3b30146e21db5 100644
@@ -30,6 +30,7 @@ struct sdca_function_data;
  * @function: Pointer to the Function that the interrupt is associated with.
  * @entity: Pointer to the Entity that the interrupt is associated with.
  * @control: Pointer to the Control that the interrupt is associated with.
+ * @handler: Handler function to be called for the IRQ.
  * @priv: Pointer to private data for use by the handler.
  * @free_priv: Pointer to a function that can be used to free the priv data.
  * @irq: IRQ number allocated to this interrupt, also used internally to track
@@ -46,6 +47,7 @@ struct sdca_interrupt {
 	struct sdca_function_data *function;
 	struct sdca_entity *entity;
 	struct sdca_control *control;
+	irq_handler_t handler;
 
 	void *priv;
 	void (*free_priv)(struct sdca_interrupt *interrupt);
sound/soc/sdca/sdca_interrupts.c +45 -70

166 lines not on this page · raw message

Signature · 1 line
2.47.3
author maintainer
#5 lore raw

PATCH v4 5/7 ASoC: Add a component fixup_controls callback

In reply to Charles Keepax

A card level fixup_controls callback was added in:

commit df4d27b19b89 ("ASoC: Introduce 'fixup_controls' card method")

This allowed the machine driver to take actions after all the card controls have been added. However, there are times when a codec driver would also want to do things like obtain references to controls for later use, which require all the controls to be present. Add a component level fixup_controls callback, echoing the card level option.

---

No changes since v3.

 include/sound/soc-component.h |  2 ++
 sound/soc/soc-component.c     | 10 ++++++++++
 sound/soc/soc-core.c          |  5 +++++
 3 files changed, 17 insertions(+)
include/sound/soc-component.h +2 -0
index aa423865dbe7c..4b7d7954953db 100644
@@ -78,6 +78,7 @@ struct snd_soc_component_driver {
 	unsigned int num_dapm_routes;
 
 	int (*probe)(struct snd_soc_component *component);
+	int (*fixup_controls)(struct snd_soc_component *component);
 	void (*remove)(struct snd_soc_component *component);
 	int (*suspend)(struct snd_soc_component *component);
 	int (*resume)(struct snd_soc_component *component);
@@ -380,6 +381,7 @@ void snd_soc_component_suspend(struct snd_soc_component *component);
 void snd_soc_component_resume(struct snd_soc_component *component);
 int snd_soc_component_is_suspended(struct snd_soc_component *component);
 int snd_soc_component_probe(struct snd_soc_component *component);
+int snd_soc_component_fixup_controls(struct snd_soc_component *component);
 void snd_soc_component_remove(struct snd_soc_component *component);
 int snd_soc_component_of_xlate_dai_id(struct snd_soc_component *component,
 				      struct device_node *ep);
sound/soc/soc-component.c +10 -0
index 21492d15833f7..2ce24513fac5d 100644
@@ -310,6 +310,16 @@ int snd_soc_component_probe(struct snd_soc_component *component)
 	return soc_component_ret(component, ret);
 }
 
+int snd_soc_component_fixup_controls(struct snd_soc_component *component)
+{
+	int ret = 0;
+
+	if (component->driver->fixup_controls)
+		ret = component->driver->fixup_controls(component);
+
+	return soc_component_ret(component, ret);
+}
+
 void snd_soc_component_remove(struct snd_soc_component *component)
 {
 	if (component->driver->remove)
sound/soc/soc-core.c +5 -0
index 7817beea5b3bc..44f9bb4473f55 100644
@@ -2162,6 +2162,11 @@ static int snd_soc_bind_card(struct snd_soc_card *card)
 		goto probe_end;
 
 	snd_soc_dapm_new_widgets(card);
+	for_each_card_components(card, component) {
+		ret = snd_soc_component_fixup_controls(component);
+		if (ret < 0)
+			goto probe_end;
+	}
 	snd_soc_card_fixup_controls(card);
 
 	ret = snd_card_register(card->snd_card);
Signature · 1 line
2.47.3
author maintainer
#6 lore raw

PATCH v4 6/7 ASoC: SDCA: Switch to fixup_controls callback for IRQ registration

In reply to Charles Keepax

Currently there are some race conditions around the boot of SDCA jack detection. 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.

Switch to the new fixup_controls callback to register the IRQs, this is guaranteed to run after all the controls have been created. Which means we can avoid the aforementioned race condition and as a bonus no longer need to concern ourselves with a case where the IRQ handler runs and the ALSA control is unavailable.

---

Changes since v3:
- Switch to sdca_irq_cleanup_late was done in the patch that added it.

 sound/soc/sdca/sdca_class_function.c |  4 +--
 sound/soc/sdca/sdca_jack.c           | 44 ++++++++++++----------------
 2 files changed, 21 insertions(+), 27 deletions(-)
sound/soc/sdca/sdca_class_function.c +2 -2
index 5ae6c727c796d..2fb2b043c979c 100644
@@ -191,7 +191,7 @@ static const struct snd_soc_dai_ops class_function_sdw_ops = {
 	.hw_free	= class_function_sdw_remove_peripheral,
 };
 
-static int class_function_component_probe(struct snd_soc_component *component)
+static int class_function_component_fixup_controls(struct snd_soc_component *component)
 {
 	struct class_function_drv *drv = snd_soc_component_get_drvdata(component);
 	struct sdca_class_drv *core = drv->core;
@@ -217,7 +217,7 @@ static int class_function_set_jack(struct snd_soc_component *component,
 }
 
 static const struct snd_soc_component_driver class_function_component_drv = {
-	.probe			= class_function_component_probe,
+	.fixup_controls		= class_function_component_fixup_controls,
 	.remove			= class_function_component_remove,
 	.endianness		= 1,
 };
sound/soc/sdca/sdca_jack.c +19 -25

72 lines not on this page · raw message

Signature · 1 line
2.47.3
author maintainer
#7 lore raw

PATCH v4 7/7 ASoC: SDCA: Move kcontrol search out of IRQ

In reply to Charles Keepax

Now that the IRQs are always registered after all the ALSA controls are created it is possible to search for the control at the point the IRQ is requested. Move the control search out of the IRQ handler and do it at IRQ request time.

This also fixes a potential issue when the card was torn down and reprobed without destroying the codec device, the kctl pointer stored by the IRQ handler would not be updated to the new control on the second probe.

---

New since v3.

 include/sound/sdca_jack.h        |  1 +
 sound/soc/sdca/sdca_interrupts.c | 12 +++++++++
 sound/soc/sdca/sdca_jack.c       | 43 +++++++++++++++++++-------------
 3 files changed, 39 insertions(+), 17 deletions(-)
include/sound/sdca_jack.h +1 -0
index 59de40b7d7d01..871ba2d8146a3 100644
@@ -28,6 +28,7 @@ struct jack_state {
 };
 
 int sdca_jack_alloc_state(struct sdca_interrupt *interrupt);
+int sdca_jack_init_state(struct sdca_interrupt *interrupt);
 void sdca_jack_free_state(struct sdca_interrupt *interrupt);
 
 int sdca_jack_process(struct sdca_interrupt *interrupt);
sound/soc/sdca/sdca_interrupts.c +12 -0
index 6f0d8c0fe622d..42fbd3af8a754 100644
@@ -521,6 +521,8 @@ int sdca_irq_populate(struct sdca_function_data *function,
 
 	for (i = 0; i < SDCA_MAX_INTERRUPTS; i++) {
 		struct sdca_interrupt *interrupt = &info->irqs[i];
+		struct sdca_control *control = interrupt->control;
+		struct sdca_entity *entity = interrupt->entity;
 		int irq;
 
 		if (interrupt->function != function || interrupt->irq)
@@ -528,6 +530,16 @@ int sdca_irq_populate(struct sdca_function_data *function,
 
 		interrupt->component = component;
 
+		switch (SDCA_CTL_TYPE(entity->type, control->sel)) {
+		case SDCA_CTL_TYPE_S(GE, DETECTED_MODE):
+			ret = sdca_jack_init_state(interrupt);
+			if (ret)
+				return ret;
+			break;
+		default:
+			break;
+		}
+
 		irq = interrupt->control->interrupt_position;
 		ret = sdca_irq_request_locked(dev, info, irq, interrupt->name,
 					      interrupt->handler, interrupt);
sound/soc/sdca/sdca_jack.c +26 -17

55 lines not on this page · raw message

Signature · 1 line
2.47.3
maintainer
#8 lore raw
In reply to Charles Keepax
Quoted 9 lines · Charles Keepax

Fix races on creation of SDCA jack detection

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.

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.2

Thanks!

[1/7] ASoC: SDCA: Rename sdca_irq_allocate() to include devm

      https://git.kernel.org/broonie/sound/c/4ecef577d1ce
[2/7] ASoC: SDCA: Add sdca_irq_cleanup_late()
      https://git.kernel.org/broonie/sound/c/f18e97fa7f12
[3/7] ASoC: SDCA: Remove devm from primary IRQ cleanup
      https://git.kernel.org/broonie/sound/c/0880082c27b6
[4/7] ASoC: SDCA: Populate IRQ data earlier
      https://git.kernel.org/broonie/sound/c/050406cbd676
[5/7] ASoC: Add a component fixup_controls callback
      https://git.kernel.org/broonie/sound/c/3e81e2fb2163
[6/7] ASoC: SDCA: Switch to fixup_controls callback for IRQ registration
      https://git.kernel.org/broonie/sound/c/b8f71f16134f
[7/7] ASoC: SDCA: Move kcontrol search out of IRQ
      https://git.kernel.org/broonie/sound/c/bf1b7821f853

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