mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] i2c: rcar: release DMA channels when host notify setup fails
@ 2026-11-26 13:31 Yige Jiang
  2026-11-26 13:44 ` Geert Uytterhoeven
  0 siblings, 1 reply; 2+ messages in thread
From: Yige Jiang @ 2026-11-26 13:31 UTC (permalink / raw)
  To: Wolfram Sang, Andi Shyti, Geert Uytterhoeven, Magnus Damm
  Cc: Yige Jiang, linux-renesas-soc, linux-i2c, linux-kernel, stable

rcar_i2c_master_xfer() requests the DMA channels lazily, on the first
transfer that finds priv->dma_tx or priv->dma_rx still set to
ERR_PTR(-EPROBE_DEFER). Clients probed while i2c_add_numbered_adapter()
registers the adapter can already issue such transfers, so the channels
may be held by the time rcar_i2c_probe() creates the host notify client.

If i2c_new_slave_host_notify_device() then fails, the out_del_device
path deletes the adapter but does not call rcar_i2c_release_dma(); only
rcar_i2c_remove() does. The channels then stay allocated, together with
their DMA engine references, after probe has failed and priv is freed.

Release the DMA channels right after deleting the adapter, in the same
order as rcar_i2c_remove(). rcar_i2c_release_dma() skips channels that
were never requested.

Fixes: c4651f11d09a ("i2c: rcar: add HostNotify support")
Cc: stable@vger.kernel.org
Signed-off-by: Yige Jiang <yigejiang86@gmail.com>
---
Based on linux-next next-20261109 (630059a5a632).
Compile-tested: arm64, GCC 14.2.0, W=1, CONFIG_I2C_RCAR=m, CONFIG_COMPILE_TEST=y (object only; no new warnings).
No hardware or runtime test was performed.
Needs a pre-Gen3 R-Car I2C node with the "smbus" property and dmas, a client transfer during adapter registration, and a failing i2c_new_slave_host_notify_device() (e.g. a client already at 0x08); no in-tree DT sets "smbus" on an R-Car I2C node.

 drivers/i2c/busses/i2c-rcar.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c
index fcb15be59cb5..b5c964c367e7 100644
--- a/drivers/i2c/busses/i2c-rcar.c
+++ b/drivers/i2c/busses/i2c-rcar.c
@@ -1241,6 +1241,7 @@ static int rcar_i2c_probe(struct platform_device *pdev)
 
  out_del_device:
 	i2c_del_adapter(&priv->adap);
+	rcar_i2c_release_dma(priv);
  out_pm_put:
 	if (priv->flags & ID_P_PM_BLOCKED)
 		pm_runtime_put(dev);

base-commit: 630059a5a632377b9b7b487baccde92b7ae1dd47

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

* Re: [PATCH] i2c: rcar: release DMA channels when host notify setup fails
  2026-11-26 13:31 [PATCH] i2c: rcar: release DMA channels when host notify setup fails Yige Jiang
@ 2026-11-26 13:44 ` Geert Uytterhoeven
  0 siblings, 0 replies; 2+ messages in thread
From: Geert Uytterhoeven @ 2026-11-26 13:44 UTC (permalink / raw)
  To: Yige Jiang, Wolfram Sang, Andi Shyti, Magnus Damm
  Cc: linux-renesas-soc, linux-i2c, linux-kernel, stable

Hi Yige,

On Thu, Nov 26, 2026, at 14:31, Yige Jiang wrote:
> rcar_i2c_master_xfer() requests the DMA channels lazily, on the first
> transfer that finds priv->dma_tx or priv->dma_rx still set to
> ERR_PTR(-EPROBE_DEFER). Clients probed while i2c_add_numbered_adapter()
> registers the adapter can already issue such transfers, so the channels
> may be held by the time rcar_i2c_probe() creates the host notify client.
>
> If i2c_new_slave_host_notify_device() then fails, the out_del_device
> path deletes the adapter but does not call rcar_i2c_release_dma(); only
> rcar_i2c_remove() does. The channels then stay allocated, together with
> their DMA engine references, after probe has failed and priv is freed.
>
> Release the DMA channels right after deleting the adapter, in the same
> order as rcar_i2c_remove(). rcar_i2c_release_dma() skips channels that
> were never requested.
>
> Fixes: c4651f11d09a ("i2c: rcar: add HostNotify support")
> Cc: stable@vger.kernel.org
> Signed-off-by: Yige Jiang <yigejiang86@gmail.com>

Thanks for your patch!

> ---
> Based on linux-next next-20261109 (630059a5a632).
> Compile-tested: arm64, GCC 14.2.0, W=1, CONFIG_I2C_RCAR=m, 
> CONFIG_COMPILE_TEST=y (object only; no new warnings).
> No hardware or runtime test was performed.
> Needs a pre-Gen3 R-Car I2C node with the "smbus" property and dmas, a 

Why does it need a pre-Gen3 R-Car I2C node to trigger?
Pre-Gen3 I2C controller do not support DMA, so this cannot happen?

> client transfer during adapter registration, and a failing 
> i2c_new_slave_host_notify_device() (e.g. a client already at 0x08); no 
> in-tree DT sets "smbus" on an R-Car I2C node.

Gr{oetje,eeting}s,

                                                Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                                            -- Linus Torvalds

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

end of thread, other threads:[~2026-11-26 13:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-26 13:31 [PATCH] i2c: rcar: release DMA channels when host notify setup fails Yige Jiang
2026-11-26 13:44 ` Geert Uytterhoeven

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®