mfd: mt6397-irq: Fix PM notifier and IRQ domain teardown
Subsystems (2)
PATCH v2 1/1 mfd: mt6397-irq: Fix PM notifier and IRQ domain teardown
mt6397_irq_init() registers a PM notifier and creates an irq_domain. Both objects point back to the devm-managed mt6397_chip.
The notifier was not unregistered on probe failure or unbind, so a later PM transition could dereference freed chip state. The irq_domain had the opposite lifetime problem: it could be removed while the devm-managed parent IRQ was still active, but it was leaked on successful unbind.
Manage both lifetimes with devm actions. Register the domain cleanup before requesting the parent IRQ, so devres frees the parent IRQ before removing child mappings and the irq_domain. This keeps the domain alive while the parent IRQ handler can still run.
Also serialize PM notifier mask writes with irqlock. While suspend is in progress, keep wake_mask programmed in hardware even if a concurrent IRQ sync updates irq_masks_cur in software.
---
Changes in v2:
- Use devm actions for PM notifier and irq_domain cleanup.
- Remove direct irq_domain_remove() calls from failure paths.
- Serialize PM notifier mask writes with irqlock.
--- drivers/mfd/mt6397-core.c | 4 +- drivers/mfd/mt6397-irq.c | 85 +++++++++++++++++++++++---------- include/linux/mfd/mt6397/core.h | 1 + 3 files changed, 63 insertions(+), 27 deletions(-)
drivers/mfd/mt6397-core.c +1 -3
@@ -389,10 +389,8 @@ static int mt6397_probe(struct platform_device *pdev) ret =devm_mfd_add_devices (&pdev->dev,PLATFORM_DEVID_NONE , pmic_core->cells, pmic_core->cell_size,NULL ,0 , pmic->irq_domain); -if (ret) { -irq_domain_remove (pmic->irq_domain); +if (ret)dev_err (&pdev->dev,"failed to add child devices: %d\n" , ret); - }return ret; }
drivers/mfd/mt6397-irq.c +61 -24
124 lines not on this page · raw message
include/linux/mfd/mt6397/core.h +1 -0
@@ -66,6 +66,7 @@ struct mt6397_chip {int irq;struct irq_domain *irq_domain;struct mutex irqlock; +bool irq_suspended;u16 wake_mask[3 ];u16 irq_masks_cur[3 ];u16 irq_masks_cache[3 ];
Signature · 1 line
2.43.0