mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/3] mfd: Fix an out-of-bounds IRQ map and error-path bugs
@ 2026-11-27  4:17 shao.mingyin
  2026-11-27  4:17 ` [PATCH v2 1/3] mfd: tps65219: Fix the TPS65214 main IRQ bit mapping shao.mingyin
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: shao.mingyin @ 2026-11-27  4:17 UTC (permalink / raw)
  To: lee, mfd
  Cc: tony, linux-omap, support.opensource, patches, ckeepax, linux-kernel

This is the second revision of three fixes from the [PATCH 0/5] mfd
series posted on November 7, following Lee's review on November 18.
The 2/5 twl6030 change was not commented on and is not resent; the 5/5
gateworks-gsc change has its own history and is posted separately as v4.

Shao Mingyin (3):
  mfd: tps65219: Fix the TPS65214 main IRQ bit mapping
  mfd: arizona: Free only registered diagnostic IRQs
  mfd: da9052: Balance the parent IRQ wake reference

 drivers/mfd/arizona-core.c        | 49 ++++++++++++++++++++++++++++++++-------
 drivers/mfd/da9052-irq.c          |  7 ++++--
 drivers/mfd/tps65219.c            | 14 +++++++------
 include/linux/mfd/arizona/core.h  |  1 +
 include/linux/mfd/da9052/da9052.h |  1 +
 5 files changed, 54 insertions(+), 18 deletions(-)

Changes in v2:
- 1/3: specify every table entry by its hardware bit index instead of
  adding a placeholder entry for the reserved bit (Lee).
- 2/3: free only the diagnostic IRQs whose request succeeded, so probe
  rollback cannot free a virq that has no action.  Charles is asked for
  another look, as his earlier tag covered the unconditional free.
- 3/3: request ADC_EOM before enabling wake, and keep the conditional
  disable because an unbalanced wake disable warns (Lee).

v1: https://lore.kernel.org/all/202611071607376342uPiYA9rHRC7ZI9Ix-8xh@zte.com.cn/

base-commit: e8017d29067fd1310a65c3494ce1a1b492adbac6

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 1/3] mfd: tps65219: Fix the TPS65214 main IRQ bit mapping
  2026-11-27  4:17 [PATCH v2 0/3] mfd: Fix an out-of-bounds IRQ map and error-path bugs shao.mingyin
@ 2026-11-27  4:17 ` shao.mingyin
  2026-11-27  4:17 ` [PATCH v2 2/3] mfd: arizona: Free only registered diagnostic IRQs shao.mingyin
  2026-11-27  4:17 ` [PATCH v2 3/3] mfd: da9052: Balance the parent IRQ wake reference shao.mingyin
  2 siblings, 0 replies; 4+ messages in thread
From: shao.mingyin @ 2026-11-27  4:17 UTC (permalink / raw)
  To: lee, mfd
  Cc: tony, linux-omap, support.opensource, patches, ckeepax, linux-kernel

The TPS65214 sub-IRQ table has seven entries because INT_SOURCE bit 6
is reserved. Regmap IRQ indexes the table by bit number, so the power
button status on bit 7 accesses the table past its end.

Initialize each entry at its hardware bit index. Bit 6 is implicitly
zero-initialized, so regmap IRQ skips it without reading a status
register.

Fixes: 7947219ab1a2 ("mfd: tps65219: Add support for TI TPS65214 PMIC")
Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
---
Changes in v2:
- Use designated initializers for the hardware bit indices.

Previous version: https://lore.kernel.org/all/20261107162119836VR3jHjgaOF-Np7Cmm0nl3@zte.com.cn/

Build-tested on Linux-next next-20261118 with GCC 13.3.0 for x86_64.

 drivers/mfd/tps65219.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/mfd/tps65219.c b/drivers/mfd/tps65219.c
index 69cf52a595d6..f65fda6acc74 100644
--- a/drivers/mfd/tps65219.c
+++ b/drivers/mfd/tps65219.c
@@ -262,13 +262,13 @@ static const struct regmap_irq_sub_irq_map tps65215_sub_irq_offsets[] = {
 };
 
 static const struct regmap_irq_sub_irq_map tps65214_sub_irq_offsets[] = {
-	REGMAP_IRQ_MAIN_REG_OFFSET(tps65214_bit0_offsets),
-	REGMAP_IRQ_MAIN_REG_OFFSET(tps65214_bit1_offsets),
-	REGMAP_IRQ_MAIN_REG_OFFSET(tps65214_bit2_offsets),
-	REGMAP_IRQ_MAIN_REG_OFFSET(tps65214_bit3_offsets),
-	REGMAP_IRQ_MAIN_REG_OFFSET(tps65214_bit4_offsets),
-	REGMAP_IRQ_MAIN_REG_OFFSET(tps65214_bit5_offsets),
-	REGMAP_IRQ_MAIN_REG_OFFSET(tps65214_bit7_offsets),
+	[0] = REGMAP_IRQ_MAIN_REG_OFFSET(tps65214_bit0_offsets),
+	[1] = REGMAP_IRQ_MAIN_REG_OFFSET(tps65214_bit1_offsets),
+	[2] = REGMAP_IRQ_MAIN_REG_OFFSET(tps65214_bit2_offsets),
+	[3] = REGMAP_IRQ_MAIN_REG_OFFSET(tps65214_bit3_offsets),
+	[4] = REGMAP_IRQ_MAIN_REG_OFFSET(tps65214_bit4_offsets),
+	[5] = REGMAP_IRQ_MAIN_REG_OFFSET(tps65214_bit5_offsets),
+	[7] = REGMAP_IRQ_MAIN_REG_OFFSET(tps65214_bit7_offsets),
 };
 
 #define TPS65219_REGMAP_IRQ_REG(int_name, register_position) \

base-commit: e8017d29067fd1310a65c3494ce1a1b492adbac6
-- 
2.43.0

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 2/3] mfd: arizona: Free only registered diagnostic IRQs
  2026-11-27  4:17 [PATCH v2 0/3] mfd: Fix an out-of-bounds IRQ map and error-path bugs shao.mingyin
  2026-11-27  4:17 ` [PATCH v2 1/3] mfd: tps65219: Fix the TPS65214 main IRQ bit mapping shao.mingyin
@ 2026-11-27  4:17 ` shao.mingyin
  2026-11-27  4:17 ` [PATCH v2 3/3] mfd: da9052: Balance the parent IRQ wake reference shao.mingyin
  2 siblings, 0 replies; 4+ messages in thread
From: shao.mingyin @ 2026-11-27  4:17 UTC (permalink / raw)
  To: lee, mfd
  Cc: tony, linux-omap, support.opensource, patches, ckeepax, linux-kernel

arizona_dev_init() requests three diagnostic IRQs before adding MFD
children. If adding the children fails after any of those requests
succeed, the probe error path tears down the IRQ mappings while the
diagnostic IRQ actions are still registered.

Record which requests succeed and free those IRQs before IRQ teardown
on probe failure and on removal. Diagnostic IRQs remain optional, and
a failed request never leads to a call to free its action.

Fixes: 3cc729869475 ("mfd: arizona: Core driver")
Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
---
Changes in v2:
- Record successful IRQ requests and share cleanup between probe
  failure and removal.

Previous version: https://lore.kernel.org/all/20261107162122461AuQ94DzIh_R4gD8FWdVlC@zte.com.cn/

Build-tested on Linux-next next-20261118 with GCC 13.3.0 for x86_64.

 drivers/mfd/arizona-core.c       | 49 ++++++++++++++++++++++++++------
 include/linux/mfd/arizona/core.h |  1 +
 2 files changed, 41 insertions(+), 9 deletions(-)

diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
index 91975536d14d..8e5b8a75e773 100644
--- a/drivers/mfd/arizona-core.c
+++ b/drivers/mfd/arizona-core.c
@@ -231,6 +231,43 @@ static irqreturn_t arizona_overclocked(int irq, void *data)
 	return IRQ_HANDLED;
 }
 
+static const struct {
+	int irq;
+	char *name;
+	irq_handler_t handler;
+} arizona_info_irqs[] = {
+	{ ARIZONA_IRQ_CLKGEN_ERR, "CLKGEN error", arizona_clkgen_err },
+	{ ARIZONA_IRQ_OVERCLOCKED, "Overclocked", arizona_overclocked },
+	{ ARIZONA_IRQ_UNDERCLOCKED, "Underclocked", arizona_underclocked },
+};
+
+static void arizona_request_info_irqs(struct arizona *arizona)
+{
+	unsigned int i;
+	int ret;
+
+	for (i = 0; i < ARRAY_SIZE(arizona_info_irqs); i++) {
+		ret = arizona_request_irq(arizona, arizona_info_irqs[i].irq,
+					  arizona_info_irqs[i].name,
+					  arizona_info_irqs[i].handler,
+					  arizona);
+		if (!ret)
+			arizona->info_irq_mask |= BIT(i);
+	}
+}
+
+static void arizona_free_info_irqs(struct arizona *arizona)
+{
+	int i;
+
+	for (i = ARRAY_SIZE(arizona_info_irqs) - 1; i >= 0; i--)
+		if (arizona->info_irq_mask & BIT(i))
+			arizona_free_irq(arizona, arizona_info_irqs[i].irq,
+					 arizona);
+
+	arizona->info_irq_mask = 0;
+}
+
 #define ARIZONA_REG_POLL_DELAY_US 7500
 
 static inline bool arizona_poll_reg_delay(ktime_t timeout)
@@ -1355,12 +1392,7 @@ int arizona_dev_init(struct arizona *arizona)
 	pm_runtime_set_autosuspend_delay(arizona->dev, 100);
 	pm_runtime_use_autosuspend(arizona->dev);
 
-	arizona_request_irq(arizona, ARIZONA_IRQ_CLKGEN_ERR, "CLKGEN error",
-			    arizona_clkgen_err, arizona);
-	arizona_request_irq(arizona, ARIZONA_IRQ_OVERCLOCKED, "Overclocked",
-			    arizona_overclocked, arizona);
-	arizona_request_irq(arizona, ARIZONA_IRQ_UNDERCLOCKED, "Underclocked",
-			    arizona_underclocked, arizona);
+	arizona_request_info_irqs(arizona);
 
 	ret = mfd_add_devices(arizona->dev, PLATFORM_DEVID_NONE,
 			      subdevs, n_subdevs, NULL, 0, NULL);
@@ -1373,6 +1405,7 @@ int arizona_dev_init(struct arizona *arizona)
 	return 0;
 
 err_irq:
+	arizona_free_info_irqs(arizona);
 	arizona_irq_exit(arizona);
 err_pm:
 	pm_runtime_disable(arizona->dev);
@@ -1417,9 +1450,7 @@ int arizona_dev_exit(struct arizona *arizona)
 	}
 
 	mfd_remove_devices(arizona->dev);
-	arizona_free_irq(arizona, ARIZONA_IRQ_UNDERCLOCKED, arizona);
-	arizona_free_irq(arizona, ARIZONA_IRQ_OVERCLOCKED, arizona);
-	arizona_free_irq(arizona, ARIZONA_IRQ_CLKGEN_ERR, arizona);
+	arizona_free_info_irqs(arizona);
 	arizona_irq_exit(arizona);
 	arizona_enable_reset(arizona);
 
diff --git a/include/linux/mfd/arizona/core.h b/include/linux/mfd/arizona/core.h
index 6d6f96b2b29f..3a9881a1c0c9 100644
--- a/include/linux/mfd/arizona/core.h
+++ b/include/linux/mfd/arizona/core.h
@@ -136,6 +136,7 @@ struct arizona {
 	struct irq_domain *virq;
 	struct regmap_irq_chip_data *aod_irq_chip;
 	struct regmap_irq_chip_data *irq_chip;
+	unsigned int info_irq_mask;
 
 	bool hpdet_clamp;
 	unsigned int hp_ena;

base-commit: e8017d29067fd1310a65c3494ce1a1b492adbac6
-- 
2.43.0

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 3/3] mfd: da9052: Balance the parent IRQ wake reference
  2026-11-27  4:17 [PATCH v2 0/3] mfd: Fix an out-of-bounds IRQ map and error-path bugs shao.mingyin
  2026-11-27  4:17 ` [PATCH v2 1/3] mfd: tps65219: Fix the TPS65214 main IRQ bit mapping shao.mingyin
  2026-11-27  4:17 ` [PATCH v2 2/3] mfd: arizona: Free only registered diagnostic IRQs shao.mingyin
@ 2026-11-27  4:17 ` shao.mingyin
  2 siblings, 0 replies; 4+ messages in thread
From: shao.mingyin @ 2026-11-27  4:17 UTC (permalink / raw)
  To: lee, mfd
  Cc: tony, linux-omap, support.opensource, patches, ckeepax, linux-kernel

da9052_irq_init() enables wake on the chip IRQ before requesting ADC_EOM.
The error path and da9052_irq_exit() leave a successful wake enable
unbalanced, so the IRQ retains its wake reference after probe failure
or device removal.

Enable wake after requesting ADC_EOM, and record whether the enable
succeeded. Drop that reference before tearing down the parent IRQ
chip. The device can still probe when wake is unavailable.

Fixes: ed05be56643e ("mfd: da9052: Register ability of device to cause a wake-up interrupt")
Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
---
Changes in v2:
- Enable wake after requesting ADC_EOM and keep the conditional
  disable for irqchips that reject wake enable.

Previous version: https://lore.kernel.org/all/20261107162123768WcPgulYo-5-EuCbXTrwwH@zte.com.cn/

Build-tested on Linux-next next-20261118 with GCC 13.3.0 for x86_64.

 drivers/mfd/da9052-irq.c          | 7 +++++--
 include/linux/mfd/da9052/da9052.h | 1 +
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/mfd/da9052-irq.c b/drivers/mfd/da9052-irq.c
index abbdbf0337e2..0fbf274a8fd2 100644
--- a/drivers/mfd/da9052-irq.c
+++ b/drivers/mfd/da9052-irq.c
@@ -259,8 +259,6 @@ int da9052_irq_init(struct da9052 *da9052)
 		goto regmap_err;
 	}
 
-	enable_irq_wake(da9052->chip_irq);
-
 	ret = da9052_request_irq(da9052, DA9052_IRQ_ADC_EOM, "adc-irq",
 			    da9052_auxadc_irq, da9052);
 
@@ -269,6 +267,9 @@ int da9052_irq_init(struct da9052 *da9052)
 		goto request_irq_err;
 	}
 
+	ret = enable_irq_wake(da9052->chip_irq);
+	da9052->irq_wake_enabled = !ret;
+
 	return 0;
 
 request_irq_err:
@@ -281,6 +282,8 @@ int da9052_irq_init(struct da9052 *da9052)
 int da9052_irq_exit(struct da9052 *da9052)
 {
 	da9052_free_irq(da9052, DA9052_IRQ_ADC_EOM, da9052);
+	if (da9052->irq_wake_enabled)
+		disable_irq_wake(da9052->chip_irq);
 	regmap_del_irq_chip(da9052->chip_irq, da9052->irq_data);
 
 	return 0;
diff --git a/include/linux/mfd/da9052/da9052.h b/include/linux/mfd/da9052/da9052.h
index 9cb2fc2938ce..ba155de6bf24 100644
--- a/include/linux/mfd/da9052/da9052.h
+++ b/include/linux/mfd/da9052/da9052.h
@@ -92,6 +92,7 @@ struct da9052 {
 	u8 chip_id;
 
 	int chip_irq;
+	bool irq_wake_enabled;
 
 	int fault_log;
 

base-commit: e8017d29067fd1310a65c3494ce1a1b492adbac6
-- 
2.43.0

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-27  4:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-27  4:17 [PATCH v2 0/3] mfd: Fix an out-of-bounds IRQ map and error-path bugs shao.mingyin
2026-11-27  4:17 ` [PATCH v2 1/3] mfd: tps65219: Fix the TPS65214 main IRQ bit mapping shao.mingyin
2026-11-27  4:17 ` [PATCH v2 2/3] mfd: arizona: Free only registered diagnostic IRQs shao.mingyin
2026-11-27  4:17 ` [PATCH v2 3/3] mfd: da9052: Balance the parent IRQ wake reference shao.mingyin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®