mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] i2c: bcm2835: remove clients before releasing resources
@ 2026-11-29 12:29 Jiawen Liu
  2026-12-02 15:35 ` Andi Shyti
  0 siblings, 1 reply; 2+ messages in thread
From: Jiawen Liu @ 2026-11-29 12:29 UTC (permalink / raw)
  To: Andi Shyti, Florian Fainelli, Ray Jui, Scott Branden
  Cc: Broadcom internal kernel review list, linux-i2c,
	linux-rpi-kernel, linux-arm-kernel, linux-kernel

bcm2835_i2c_remove() releases the exclusive clock-rate reservation,
disables the bus clock, and frees the transfer IRQ before removing the
adapter. Adapter deletion synchronously invokes bound client remove
callbacks, and those callbacks may issue I2C transfers. For example,
ina209 restores its configuration and calibration during removal.

The transfer path waits for completion signaled by the IRQ handler that
has already been freed, so cleanup times out and may access the controller
with its bus clock disabled. Remove the adapter first, then release the
resources after all clients have gone away.

Fixes: f3b54b9a066e ("i2c: add bcm2835 driver")
Signed-off-by: Jiawen Liu <1298662399@qq.com>
---
 drivers/i2c/busses/i2c-bcm2835.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-bcm2835.c b/drivers/i2c/busses/i2c-bcm2835.c
index 0fea44d4df6e8..a9067390c1f73 100644
--- a/drivers/i2c/busses/i2c-bcm2835.c
+++ b/drivers/i2c/busses/i2c-bcm2835.c
@@ -506,11 +506,12 @@ static void bcm2835_i2c_remove(struct platform_device *pdev)
 {
 	struct bcm2835_i2c_dev *i2c_dev = platform_get_drvdata(pdev);
 
+	i2c_del_adapter(&i2c_dev->adapter);
+
 	clk_rate_exclusive_put(i2c_dev->bus_clk);
 	clk_disable_unprepare(i2c_dev->bus_clk);
 
 	free_irq(i2c_dev->irq, i2c_dev);
-	i2c_del_adapter(&i2c_dev->adapter);
 }
 
 static const struct of_device_id bcm2835_i2c_of_match[] = {
-- 
2.34.1


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

* Re: [PATCH] i2c: bcm2835: remove clients before releasing resources
  2026-11-29 12:29 [PATCH] i2c: bcm2835: remove clients before releasing resources Jiawen Liu
@ 2026-12-02 15:35 ` Andi Shyti
  0 siblings, 0 replies; 2+ messages in thread
From: Andi Shyti @ 2026-12-02 15:35 UTC (permalink / raw)
  To: Jiawen Liu
  Cc: Florian Fainelli, Ray Jui, Scott Branden,
	Broadcom internal kernel review list, linux-i2c,
	linux-rpi-kernel, linux-arm-kernel, linux-kernel

Hi Jiawen,

On Sun, Nov 29, 2026 at 04:29:28PM +0400, Jiawen Liu wrote:
> bcm2835_i2c_remove() releases the exclusive clock-rate reservation,
> disables the bus clock, and frees the transfer IRQ before removing the
> adapter. Adapter deletion synchronously invokes bound client remove
> callbacks, and those callbacks may issue I2C transfers. For example,
> ina209 restores its configuration and calibration during removal.
> 
> The transfer path waits for completion signaled by the IRQ handler that
> has already been freed, so cleanup times out and may access the controller
> with its bus clock disabled. Remove the adapter first, then release the
> resources after all clients have gone away.
> 
> Fixes: f3b54b9a066e ("i2c: add bcm2835 driver")
> Signed-off-by: Jiawen Liu <1298662399@qq.com>

please group similar patches in a series.

Andi

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

end of thread, other threads:[~2026-12-02 15:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-29 12:29 [PATCH] i2c: bcm2835: remove clients before releasing resources Jiawen Liu
2026-12-02 15:35 ` Andi Shyti

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®