All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] regulator: da9211: Use irq handler when ready
@ 2022-11-27 21:06 Ricardo Ribalda
  2022-11-27 21:10 ` DLG Adam Ward
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Ricardo Ribalda @ 2022-11-27 21:06 UTC (permalink / raw)
  To: Liam Girdwood, Support Opensource, Mark Brown
  Cc: Ricardo Ribalda, linux-kernel

If the system does not come from reset (like when it is kexec()), the
regulator might have an IRQ waiting for us.

If we enable the IRQ handler before its structures are ready, we crash.

This patch fixes:

[    1.141839] Unable to handle kernel read from unreadable memory at virtual address 0000000000000078
[    1.316096] Call trace:
[    1.316101]  blocking_notifier_call_chain+0x20/0xa8
[    1.322757] cpu cpu0: dummy supplies not allowed for exclusive requests
[    1.327823]  regulator_notifier_call_chain+0x1c/0x2c
[    1.327825]  da9211_irq_handler+0x68/0xf8
[    1.327829]  irq_thread+0x11c/0x234
[    1.327833]  kthread+0x13c/0x154

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
regulator: da9211: Fix crash when irqs are pre-enabled

If the system does not come from reset (like when it is kexec()), the
regulator might have an IRQ waiting for us.

If we enable the IRQ handler before its structures are ready, we crash.

To: Support Opensource <support.opensource@diasemi.com>
To: Liam Girdwood <lgirdwood@gmail.com>
To: Mark Brown <broonie@kernel.org>
Cc: linux-kernel@vger.kernel.org
---
Changes in v2:
- Move chip_irq assignment before regulator_init (Thanks Adam)
- Reduce commit message (Thanks Mark)
- Link to v1: https://lore.kernel.org/r/20221124-da9211-v1-0-a54549aa6d3b@chromium.org
---
 drivers/regulator/da9211-regulator.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/regulator/da9211-regulator.c b/drivers/regulator/da9211-regulator.c
index e01b32d1fa17..00828f5baa97 100644
--- a/drivers/regulator/da9211-regulator.c
+++ b/drivers/regulator/da9211-regulator.c
@@ -498,6 +498,12 @@ static int da9211_i2c_probe(struct i2c_client *i2c)
 
 	chip->chip_irq = i2c->irq;
 
+	ret = da9211_regulator_init(chip);
+	if (ret < 0) {
+		dev_err(chip->dev, "Failed to initialize regulator: %d\n", ret);
+		return ret;
+	}
+
 	if (chip->chip_irq != 0) {
 		ret = devm_request_threaded_irq(chip->dev, chip->chip_irq, NULL,
 					da9211_irq_handler,
@@ -512,11 +518,6 @@ static int da9211_i2c_probe(struct i2c_client *i2c)
 		dev_warn(chip->dev, "No IRQ configured\n");
 	}
 
-	ret = da9211_regulator_init(chip);
-
-	if (ret < 0)
-		dev_err(chip->dev, "Failed to initialize regulator: %d\n", ret);
-
 	return ret;
 }
 

---
base-commit: 4312098baf37ee17a8350725e6e0d0e8590252d4
change-id: 20221124-da9211-4b8904b4feb5

Best regards,
-- 
Ricardo Ribalda <ribalda@chromium.org>

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

* RE: [PATCH v2] regulator: da9211: Use irq handler when ready
  2022-11-27 21:06 [PATCH v2] regulator: da9211: Use irq handler when ready Ricardo Ribalda
@ 2022-11-27 21:10 ` DLG Adam Ward
  2022-11-28 11:56 ` Mark Brown
  2022-11-29 16:46 ` Mark Brown
  2 siblings, 0 replies; 6+ messages in thread
From: DLG Adam Ward @ 2022-11-27 21:10 UTC (permalink / raw)
  To: Ricardo Ribalda, Liam Girdwood, Support Opensource, Mark Brown
  Cc: linux-kernel

On 27 November 2022 21:06, Ricardo Ribalda wrote:

> Changes in v2:

That was quick! Thank you :-)

Reviewed-by: Adam Ward <DLG-Adam.Ward.opensource@dm.renesas.com>

Regards,
Adam

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

* Re: [PATCH v2] regulator: da9211: Use irq handler when ready
  2022-11-27 21:06 [PATCH v2] regulator: da9211: Use irq handler when ready Ricardo Ribalda
  2022-11-27 21:10 ` DLG Adam Ward
@ 2022-11-28 11:56 ` Mark Brown
  2022-11-28 12:16   ` Ricardo Ribalda
  2022-11-29 16:46 ` Mark Brown
  2 siblings, 1 reply; 6+ messages in thread
From: Mark Brown @ 2022-11-28 11:56 UTC (permalink / raw)
  To: Ricardo Ribalda; +Cc: Liam Girdwood, Support Opensource, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 446 bytes --]

On Sun, Nov 27, 2022 at 10:06:02PM +0100, Ricardo Ribalda wrote:

> [    1.327829]  irq_thread+0x11c/0x234
> [    1.327833]  kthread+0x13c/0x154
> 
> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
> ---
> regulator: da9211: Fix crash when irqs are pre-enabled
> 
> If the system does not come from reset (like when it is kexec()), the
> regulator might have an IRQ waiting for us.

You've included two entire changelogs here.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 484 bytes --]

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

* Re: [PATCH v2] regulator: da9211: Use irq handler when ready
  2022-11-28 11:56 ` Mark Brown
@ 2022-11-28 12:16   ` Ricardo Ribalda
  2022-11-28 12:29     ` Mark Brown
  0 siblings, 1 reply; 6+ messages in thread
From: Ricardo Ribalda @ 2022-11-28 12:16 UTC (permalink / raw)
  To: Mark Brown; +Cc: Liam Girdwood, Support Opensource, linux-kernel

Hi Mark


On Mon, 28 Nov 2022 at 12:56, Mark Brown <broonie@kernel.org> wrote:
>
> On Sun, Nov 27, 2022 at 10:06:02PM +0100, Ricardo Ribalda wrote:
>
> > [    1.327829]  irq_thread+0x11c/0x234
> > [    1.327833]  kthread+0x13c/0x154
> >
> > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
> > ---
> > regulator: da9211: Fix crash when irqs are pre-enabled
> >
> > If the system does not come from reset (like when it is kexec()), the
> > regulator might have an IRQ waiting for us.
>
> You've included two entire changelogs here.


Sorry

First time that I used single-message b4 send :S. I think I have fixed it.

The extra changelog comes after ---, so it should be ignored by git.
Do you want me to resend it anyway?

Thanks!


-- 
Ricardo Ribalda

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

* Re: [PATCH v2] regulator: da9211: Use irq handler when ready
  2022-11-28 12:16   ` Ricardo Ribalda
@ 2022-11-28 12:29     ` Mark Brown
  0 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2022-11-28 12:29 UTC (permalink / raw)
  To: Ricardo Ribalda; +Cc: Liam Girdwood, Support Opensource, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 294 bytes --]

On Mon, Nov 28, 2022 at 01:16:17PM +0100, Ricardo Ribalda wrote:

> First time that I used single-message b4 send :S. I think I have fixed it.
> 
> The extra changelog comes after ---, so it should be ignored by git.
> Do you want me to resend it anyway?

Hopefully git figured it out.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH v2] regulator: da9211: Use irq handler when ready
  2022-11-27 21:06 [PATCH v2] regulator: da9211: Use irq handler when ready Ricardo Ribalda
  2022-11-27 21:10 ` DLG Adam Ward
  2022-11-28 11:56 ` Mark Brown
@ 2022-11-29 16:46 ` Mark Brown
  2 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2022-11-29 16:46 UTC (permalink / raw)
  To: Liam Girdwood, Support Opensource, Ricardo Ribalda; +Cc: linux-kernel

On Sun, 27 Nov 2022 22:06:02 +0100, Ricardo Ribalda wrote:
> If the system does not come from reset (like when it is kexec()), the
> regulator might have an IRQ waiting for us.
> 
> If we enable the IRQ handler before its structures are ready, we crash.
> 
> This patch fixes:
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next

Thanks!

[1/1] regulator: da9211: Use irq handler when ready
      commit: 02228f6aa6a64d588bc31e3267d05ff184d772eb

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

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

end of thread, other threads:[~2022-11-29 16:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-27 21:06 [PATCH v2] regulator: da9211: Use irq handler when ready Ricardo Ribalda
2022-11-27 21:10 ` DLG Adam Ward
2022-11-28 11:56 ` Mark Brown
2022-11-28 12:16   ` Ricardo Ribalda
2022-11-28 12:29     ` Mark Brown
2022-11-29 16:46 ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.