Skip to contentSkip to conversation

mfd: cs42l43: Stop using legacy SoundWire IRQ callback

PATCH Superseded Charles Keepax 2 participants 2 messages Nov 20

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mfd: cs42l43: Stop using legacy SoundWire IRQ callback

When removing the cs42l43 driver on SoundWire the core will warn of too many retries on the SoundWire alert. This is caused by the use of the legacy SoundWire IRQ callback to clear INT_STAT_GEN1. This implementation defined SoundWire alert bit is used to tie the cs42l43 internal interrupts into the SoundWire alert mechanism. However, the legacy SoundWire IRQ callback is gated by the probed flag inside the core and that is cleared before the driver's remove callback is called. This means that any IRQs triggered during the driver remove process will not clear INT_STAT_GEN1 leading to the device being stuck in the alert state until it is removed from the bus.

To fix this issue handling is moved to the regmap IRQ handle_post_irq callback which ensures that INT_STAT_GEN1 will be cleared right up until the IRQ itself is cleaned up.

---
 drivers/mfd/cs42l43-sdw.c |  9 ++++++---
 drivers/mfd/cs42l43.c     | 22 ++++++++--------------
 2 files changed, 14 insertions(+), 17 deletions(-)
drivers/mfd/cs42l43-sdw.c +6 -3
index cd0132e3632be..72833333b73ca 100644
@@ -112,9 +112,11 @@ static int cs42l43_sdw_update_status(struct sdw_slave *sdw, enum sdw_slave_statu
 	return 0;
 }
 
-static int cs42l43_sdw_interrupt(struct sdw_slave *sdw,
-				 struct sdw_slave_intr_status *status)
+static int cs42l43_sdw_interrupt(void *data)
 {
+	struct cs42l43 *cs42l43 = data;
+	struct sdw_slave *sdw = cs42l43->sdw;
+
 	/*
 	 * The IRQ itself was handled through the regmap_irq handler, this is
 	 * just clearing up the additional Cirrus SoundWire registers that are
@@ -155,7 +157,6 @@ static int cs42l43_sdw_bus_config(struct sdw_slave *sdw,
 static const struct sdw_slave_ops cs42l43_sdw_ops = {
 	.read_prop		= cs42l43_read_prop,
 	.update_status		= cs42l43_sdw_update_status,
-	.interrupt_callback	= cs42l43_sdw_interrupt,
 	.bus_config		= cs42l43_sdw_bus_config,
 };
 
@@ -172,6 +173,8 @@ static int cs42l43_sdw_probe(struct sdw_slave *sdw, const struct sdw_device_id *
 	cs42l43->sdw = sdw;
 	cs42l43->variant_id = (long)id->driver_data;
 
+	cs42l43->irq_chip.handle_post_irq = cs42l43_sdw_interrupt;
+
 	cs42l43->regmap = devm_regmap_init_sdw(sdw, &cs42l43_sdw_regmap);
 	if (IS_ERR(cs42l43->regmap))
 		return dev_err_probe(cs42l43->dev, PTR_ERR(cs42l43->regmap),
drivers/mfd/cs42l43.c +8 -14
index a83b62064dae6..d36628e8dc279 100644
@@ -515,19 +515,6 @@ static const struct regmap_irq cs42l43_regmap_irqs[] = {
 	CS42L43_IRQ_REG(HP_LOADDET_DONE,			HPOUT),
 };
 
-static const struct regmap_irq_chip cs42l43_irq_chip = {
-	.name = "cs42l43",
-
-	.status_base = CS42L43_DECIM_INT,
-	.mask_base = CS42L43_DECIM_MASK,
-	.num_regs = 16,
-
-	.irqs = cs42l43_regmap_irqs,
-	.num_irqs = ARRAY_SIZE(cs42l43_regmap_irqs),
-
-	.runtime_pm = true,
-};
-
 static const char * const cs42l43_core_supplies[] = {
 	"vdd-a", "vdd-io", "vdd-cp",
 };
@@ -917,7 +904,14 @@ static int cs42l43_irq_config(struct cs42l43 *cs42l43)
 	if (cs42l43->sdw)
 		cs42l43->irq = cs42l43->sdw->irq;
 
-	cs42l43->irq_chip = cs42l43_irq_chip;
+	/* Manually fill so extra settings from bus are preserved */
+	cs42l43->irq_chip.name = "cs42l43",
+	cs42l43->irq_chip.status_base = CS42L43_DECIM_INT,
+	cs42l43->irq_chip.mask_base = CS42L43_DECIM_MASK,
+	cs42l43->irq_chip.num_regs = 16,
+	cs42l43->irq_chip.irqs = cs42l43_regmap_irqs,
+	cs42l43->irq_chip.num_irqs = ARRAY_SIZE(cs42l43_regmap_irqs),
+	cs42l43->irq_chip.runtime_pm = true,
 	cs42l43->irq_chip.irq_drv_data = cs42l43;
 
 	irq_data = irq_get_irq_data(cs42l43->irq);
Signature · 1 line
2.47.3
#1 lore raw
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Low] mfd: cs42l43: missing Fixes trailer for SoundWire alert clearing fix - [Low] mfd: cs42l43: trailing…

Thank you for your contribution! Sashiko AI review found 2 potential issues to consider:
- [Low] mfd: cs42l43: missing Fixes trailer for SoundWire alert clearing fix
- [Low] mfd: cs42l43: trailing commas instead of semicolons in cs42l43_irq_config()
--

commit 1dac89cd53b087ddddba16f33e5c9fbd6eb8fbc3
Author: Charles Keepax <[email protected]>

Quoted 13 lines

mfd: cs42l43: Stop using legacy SoundWire IRQ callback

When removing the cs42l43 driver on SoundWire the core will warn of too many retries on the SoundWire alert. This is caused by the use of the legacy SoundWire IRQ callback to clear INT_STAT_GEN1. This implementation defined SoundWire alert bit is used to tie the cs42l43 internal interrupts into the SoundWire alert mechanism. However, the legacy SoundWire IRQ callback is gated by the probed flag inside the core and that is cleared before the driver's remove callback is called. This means that any IRQs triggered during the driver remove process will not clear INT_STAT_GEN1 leading to the device being stuck in the alert state until it is removed from the bus.

Quoted 5 lines

To fix this issue handling is moved to the regmap IRQ handle_post_irq callback which ensures that INT_STAT_GEN1 will be cleared right up until the IRQ itself is cleaned up.

[Severity: Low]
This fixes a bug where CS42L43_GEN_INT_STAT_1 is not cleared during SoundWire driver removal. Should this include:

Fixes ace6d1448138 ("mfd: cs42l43: Add support for cs42l43 core driver")
Quoted 4 lines
drivers/mfd/cs42l43.c +0 -0
index a83b62064dae6..d36628e8dc279 100644

[ ... ]

Quoted 4 lines
drivers/mfd/cs42l43.c +0 -0
@@ -917,7 +904,14 @@ static int cs42l43_irq_config(struct cs42l43 *cs42l43)
 	if (cs42l43->sdw)
 		cs42l43->irq = cs42l43->sdw->irq;
 

drivers/mfd/cs42l43.c static int cs42l43_irq_config(struct cs42l43 *cs42l43) · line 915

Quoted 10 lines
drivers/mfd/cs42l43.c +8 -1
-	cs42l43->irq_chip = cs42l43_irq_chip;
+	/* Manually fill so extra settings from bus are preserved */
+	cs42l43->irq_chip.name = "cs42l43",
+	cs42l43->irq_chip.status_base = CS42L43_DECIM_INT,
+	cs42l43->irq_chip.mask_base = CS42L43_DECIM_MASK,
+	cs42l43->irq_chip.num_regs = 16,
+	cs42l43->irq_chip.irqs = cs42l43_regmap_irqs,
+	cs42l43->irq_chip.num_irqs = ARRAY_SIZE(cs42l43_regmap_irqs),
+	cs42l43->irq_chip.runtime_pm = true,
 	cs42l43->irq_chip.irq_drv_data = cs42l43;

[Severity: Low]
The new cs42l43->irq_chip field assignments end with commas instead of semicolons, chaining them into a single comma-operator expression and triggering -Wcomma warnings.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1