From nobody Mon Jun 8 04:25:46 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8DF113E1D17; Tue, 2 Jun 2026 13:28:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780406923; cv=none; b=Itwetw+tL6st2tukGWRlYwK3eshQNCCA4+aXhbNuGEuD8d17fpue+NOHEzXXxLklIJPOtZ2WwxXXKODL/cN/UB2ZfGOF6hdHRtxEi57HFH9+GTV8t4kWhqXJLgrtjhVlcBcK+K0lQ1FLAxm3n45wkUKIg6L2tRTm1yE+DNVC5zs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780406923; c=relaxed/simple; bh=46GrvLvuc3Abquq1ngoYfLCfFgAigrm6D87Q7GpT2zE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dQWPu0nPf6bMjT0W72c3ztwpOj9leFvUsyNH5e6OAxptNFV53d+LlHaecsAgjdixMPGxGasPSj0poAPPbS5Pv1B8TSSrvoAXXbbmBMQ+YsS2EAAbOBu5JCgB/VpnBAhfe9uqaj/5i9XJS1On7NfeP4HWE1efrMPMpTa36CIk2SU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=o3FbB+7r; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="o3FbB+7r" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 886F31F00899; Tue, 2 Jun 2026 13:28:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1780406922; bh=tigAzvPOAhkM1zZ1LjDTmzJC8sEde+ltVFI35MgB/YU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=o3FbB+7rt0/09v/va6NQq+tvGHT4C9GUbpGxPniRWEgRF4uz5hXMBVFooEnYrguLZ qqBN5Q8S88ZAmLCKW0sKo2wkBXKJ0c3rWvVqSUyNOcbq0cO9bmx+x7u/rVpc846lpk irNk6NxVIg/dkfTK0QhmdbLh2bZ+u4CI7Wq8yw9kez+Gv825umfpnrPLrpYQ1kZiM6 dRGE4OYlOFhOOXyucJzciWOFTa1/D4ZKhqvMNjYGSAgNICowe5PbME5eAaFAJw3o4Y 5BtvhFjPaQzClqjGuzSNplRHaRQXP0M0lPoFweRftl0tNngdUs5oXiyxcAdFX3EiBt KJFVeQal/Zl9Q== From: Claudiu Beznea To: wsa+renesas@sang-engineering.com, tommaso.merciai.xr@bp.renesas.com, alexandre.belloni@bootlin.com, Frank.Li@nxp.com, p.zabel@pengutronix.de Cc: claudiu.beznea@kernel.org, claudiu.beznea@tuxon.dev, linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, Claudiu Beznea , stable@vger.kernel.org Subject: [PATCH v2 01/17] i3c: renesas: Check that the transfer is valid before accessing it Date: Tue, 2 Jun 2026 16:28:08 +0300 Message-ID: <20260602132824.3541151-2-claudiu.beznea@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260602132824.3541151-1-claudiu.beznea@kernel.org> References: <20260602132824.3541151-1-claudiu.beznea@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Claudiu Beznea The Renesas I3C driver uses an asynchronous model to transfer data. It prepares a struct renesas_i3c_xfer, enqueues it, and waits for completion. The interrupt handler dequeues the transfer, updates/uses it, and signals the waiting thread. If the completion times out, the waiting thread dequeues the transfer and free it. If an interrupt fires after that, the handler may access freed memory, leading to crashes. Check that the transfer is still valid before accessing it in the interrupt handler. Along with it, clear any status flag to avoid triggering the same interrupts again. Fixes: d028219a9f14 ("i3c: master: Add basic driver for the Renesas I3C con= troller") Cc: stable@vger.kernel.org Reviewed-by: Frank Li Signed-off-by: Claudiu Beznea --- Changes in v2: - clean the IRQ status bits before returning IRQ_HANDLED and adjusted the patch description to reflect this change - collected Frank's tag. Frank, please let me know if you consider I should drop your tag. Thanks! drivers/i3c/master/renesas-i3c.c | 44 +++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/drivers/i3c/master/renesas-i3c.c b/drivers/i3c/master/renesas-= i3c.c index f39c449922ca..6e7ece2e0b4e 100644 --- a/drivers/i3c/master/renesas-i3c.c +++ b/drivers/i3c/master/renesas-i3c.c @@ -1014,6 +1014,12 @@ static irqreturn_t renesas_i3c_tx_isr(int irq, void = *data) =20 scoped_guard(spinlock, &i3c->xferqueue.lock) { xfer =3D i3c->xferqueue.cur; + if (!xfer) { + /* Clear the Transmit Buffer Empty status flag. */ + renesas_clear_bit(i3c->regs, NTST, NTST_TDBEF0); + return IRQ_HANDLED; + } + cmd =3D xfer->cmds; =20 if (xfer->is_i2c_xfer) { @@ -1053,11 +1059,18 @@ static irqreturn_t renesas_i3c_resp_isr(int irq, vo= id *data) int ret =3D 0; =20 scoped_guard(spinlock, &i3c->xferqueue.lock) { + /* Clear the Respone Queue Full status flag */ + renesas_clear_bit(i3c->regs, NTST, NTST_RSPQFF); + xfer =3D i3c->xferqueue.cur; - cmd =3D xfer->cmds; + if (!xfer) { + /* Clear any error flags. */ + renesas_clear_bit(i3c->regs, BCTL, BCTL_ABT); + renesas_clear_bit(i3c->regs, NTST, NTST_TEF | NTST_TABTF); + return IRQ_HANDLED; + } =20 - /* Clear the Respone Queue Full status flag*/ - renesas_clear_bit(i3c->regs, NTST, NTST_RSPQFF); + cmd =3D xfer->cmds; =20 data_len =3D NRSPQP_DATA_LEN(resp_descriptor); =20 @@ -1138,6 +1151,12 @@ static irqreturn_t renesas_i3c_tend_isr(int irq, voi= d *data) =20 scoped_guard(spinlock, &i3c->xferqueue.lock) { xfer =3D i3c->xferqueue.cur; + if (!xfer) { + /* Clear any status flag. */ + renesas_clear_bit(i3c->regs, BST, BST_NACKDF | BST_TENDF); + return IRQ_HANDLED; + } + cmd =3D xfer->cmds; =20 if (xfer->is_i2c_xfer) { @@ -1184,6 +1203,14 @@ static irqreturn_t renesas_i3c_rx_isr(int irq, void = *data) =20 scoped_guard(spinlock, &i3c->xferqueue.lock) { xfer =3D i3c->xferqueue.cur; + if (!xfer) { + /* Clear any status registers. */ + renesas_clear_bit(i3c->regs, BST, BST_SPCNDDF); + /* Clear the Read Buffer Full status flag. */ + renesas_clear_bit(i3c->regs, NTST, NTST_RDBFF0); + return IRQ_HANDLED; + } + cmd =3D xfer->cmds; =20 if (xfer->is_i2c_xfer) { @@ -1235,6 +1262,11 @@ static irqreturn_t renesas_i3c_stop_isr(int irq, voi= d *data) =20 scoped_guard(spinlock, &i3c->xferqueue.lock) { xfer =3D i3c->xferqueue.cur; + if (!xfer) { + /* Clear the RX/TX Data Buffer Full status flag. */ + renesas_clear_bit(i3c->regs, NTST, NTST_TDBEF0 | NTST_RDBFF0); + return IRQ_HANDLED; + } =20 /* read back registers to confirm writes have fully propagated */ renesas_writel(i3c->regs, BST, 0); @@ -1259,6 +1291,12 @@ static irqreturn_t renesas_i3c_start_isr(int irq, vo= id *data) =20 scoped_guard(spinlock, &i3c->xferqueue.lock) { xfer =3D i3c->xferqueue.cur; + if (!xfer) { + /* Clear any status registers. */ + renesas_clear_bit(i3c->regs, BST, BST_STCNDDF); + return IRQ_HANDLED; + } + cmd =3D xfer->cmds; =20 if (xfer->is_i2c_xfer) { --=20 2.43.0 From nobody Mon Jun 8 04:25:46 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8FCA03E5EFA; Tue, 2 Jun 2026 13:28:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780406926; cv=none; b=ah7NZcltZJpQoJMNxQaJDIPLyDnofQWDpDiYDgfvoYxQ4+/R1lj8+cWynMw5xqfmFD7nPygs3oBhoihWsyMsANfo483LPJQguTYZTP/0SePAGp4RWwT2gFBg1SJamqbwwFE3vpIKHoylEkNbiUG2XriRIqT8hz9kebGEbngYDpI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780406926; c=relaxed/simple; bh=iMNe4mkmJ5TZaA4toPowsDiOO+8246clif64nTzPRQs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UdeWnvNVT/JAHZqgZ7nCFWdk/O1997RPd8uw1N50mg/x03bXvf+MbhopMljaJhfG2hprKOBHCAmgofy89oU9zYChQEi7Llr2KhbXlcd+pKCYPgMmTLu52HI9K+121AgJ3CHglYNx8UzBQNTjxgzE2j5CRi23TijkKugvpDjUdIM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kKaipM2H; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="kKaipM2H" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB11A1F00893; Tue, 2 Jun 2026 13:28:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1780406925; bh=+F8HoWQaPzi0AigpwIwaQzaOHhIjhtSUzJ3u8Xw8cto=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=kKaipM2Hrb+3Era4zpjZm1d4ziDA9WBPmfxfFWdih3cxJPCqppK9bxhzlbEWAiZqF +9AOE2s7U40ftdN8QIDowPOLP1ueF4Mse2R+T1jGUxNpfhCgq0QhjmOO62/erB9+Gx hLqS1bXSU2K4GSPh05CHdPJVWYxj+dqZdpIQRd/CZQNkxv5lQlkcem9SpAZURa+f52 ZtKFoQ5p5R3oEL1zE/CEclLEaZP8aVNjEShQaXozLpwaBcFpCUcxCUph2GOl7j3Q+j Y5RkwnZiQlfAraqx4uC8dXYFsVC/oy8aVg5uc9xYacZF9i9t2jGdmhg591+CYscweA vGfyDATco7vmA== From: Claudiu Beznea To: wsa+renesas@sang-engineering.com, tommaso.merciai.xr@bp.renesas.com, alexandre.belloni@bootlin.com, Frank.Li@nxp.com, p.zabel@pengutronix.de Cc: claudiu.beznea@kernel.org, claudiu.beznea@tuxon.dev, linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, Claudiu Beznea , stable@vger.kernel.org Subject: [PATCH v2 02/17] i3c: renesas: Restore STDBR and EXTBR registers on resume Date: Tue, 2 Jun 2026 16:28:09 +0300 Message-ID: <20260602132824.3541151-3-claudiu.beznea@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260602132824.3541151-1-claudiu.beznea@kernel.org> References: <20260602132824.3541151-1-claudiu.beznea@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Claudiu Beznea The Renesas RZ/G3S supports a power saving state where power to the most SoC componentes (including I3C) is lost. The STDBR and EXTBR are configured in initialization phase though the struct i3c_master_controller_ops::bus_init. Set them on resume function as well to keep the same state of the controller after a suspend with power loss and a similar initialization sequence as in bus_init. Fixes: e7218986319b ("i3c: renesas: Add suspend/resume support") Cc: stable@vger.kernel.org Reviewed-by: Frank Li Signed-off-by: Claudiu Beznea --- Changes in v2: - collected tags drivers/i3c/master/renesas-i3c.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/i3c/master/renesas-i3c.c b/drivers/i3c/master/renesas-= i3c.c index 6e7ece2e0b4e..88a16efe096d 100644 --- a/drivers/i3c/master/renesas-i3c.c +++ b/drivers/i3c/master/renesas-i3c.c @@ -260,6 +260,7 @@ struct renesas_i3c { u32 dyn_addr; u32 i2c_STDBR; u32 i3c_STDBR; + u32 extbr; unsigned long rate; u8 addrs[RENESAS_I3C_MAX_DEVS]; struct renesas_i3c_xferqueue xferqueue; @@ -607,10 +608,9 @@ static int renesas_i3c_bus_init(struct i3c_master_cont= roller *m) renesas_writel(i3c->regs, STDBR, i3c->i3c_STDBR); =20 /* Extended Bit Rate setting */ - renesas_writel(i3c->regs, EXTBR, EXTBR_EBRLO(od_low_ticks) | - EXTBR_EBRHO(od_high_ticks) | - EXTBR_EBRLP(pp_low_ticks) | - EXTBR_EBRHP(pp_high_ticks)); + i3c->extbr =3D EXTBR_EBRLO(od_low_ticks) | EXTBR_EBRHO(od_high_ticks) | + EXTBR_EBRLP(pp_low_ticks) | EXTBR_EBRHP(pp_high_ticks); + renesas_writel(i3c->regs, EXTBR, i3c->extbr); =20 renesas_writel(i3c->regs, REFCKCTL, REFCKCTL_IREFCKS(cks)); i3c->refclk_div =3D cks; @@ -1468,6 +1468,8 @@ static int renesas_i3c_resume_noirq(struct device *de= v) goto err_tresetn; =20 /* Re-store I3C registers value. */ + renesas_writel(i3c->regs, STDBR, i3c->i3c_STDBR); + renesas_writel(i3c->regs, EXTBR, i3c->extbr); renesas_writel(i3c->regs, REFCKCTL, REFCKCTL_IREFCKS(i3c->refclk_div)); renesas_writel(i3c->regs, MSDVAD, MSDVAD_MDYADV | --=20 2.43.0 From nobody Mon Jun 8 04:25:46 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 589F73E275E; Tue, 2 Jun 2026 13:28:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780406929; cv=none; b=kcJ7Qdd84VU+Ueo0q8UX6wUpQj8cqwYjZLsx8j/m5sRxZbd0303P1ELhwxcmTamWvFp0J2myOV7IMtjXtz6YffBJFKHkLwrWzyn05dLEjn8FfP9DHCiERnKLni6oIKduhBUzMeGWp/iYopx2/McyU6USlS0wQozaoALg0BVI0Ww= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780406929; c=relaxed/simple; bh=wLImk5vqFccHsK3MrHUG9UepGlm9irtdb2ohnox9GPA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=c8PcNdlybWirNHU07pQs7q6nShQfYGI6HxFZj8sPGwgJDi04ipBfP42v8lPcp39OjF/gi3ik/aPjYQZ+VhUItIihbRZTfzOjqj6jdzhGMPLCtcZDOJhHrogXfLGmND2hurqDmGu44Pm+zTGtcrHt7d7H4Xc8n11pFJiChxNFfN0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Py4aq7dZ; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Py4aq7dZ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB5EE1F00898; Tue, 2 Jun 2026 13:28:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1780406928; bh=zqUdJFTffah41MiqYor0O0hc6fcUw1Q2v/wZzX4zQWU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Py4aq7dZrQ1FCbnEndd+CRni4u0RDiKOUsa6gmolzaKatuU0pCuC2FRpwDaRZfAX4 lCP5nZdgFlqNU/wLnNPFDpVBcOda9UpYok0Uef7zrEVWQbJkjFDD1yKlD9qyvhOaiz ZgIhlyucyrd5RmQtP1LWfN806vh9zIfHnDecB5W2N7PGF0D0tD95tFZX33RVPSTHB0 AJw7SNGyHSiioOavXAO9WBFKaT7EEqT6J3D+e3RvOCBQL6s2/cB8HW8Ce7FgnP/PXd pPMt4wmtjd2IwY+BUa+rUVbXq/0xcmBvhqiriX1wlYkvioQBQMaK9Uai3yj28juf2q //7LbxAdhTSPw== From: Claudiu Beznea To: wsa+renesas@sang-engineering.com, tommaso.merciai.xr@bp.renesas.com, alexandre.belloni@bootlin.com, Frank.Li@nxp.com, p.zabel@pengutronix.de Cc: claudiu.beznea@kernel.org, claudiu.beznea@tuxon.dev, linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, Claudiu Beznea , stable@vger.kernel.org Subject: [PATCH v2 03/17] i3c: renesas: Follow the reset deassert order used in probe Date: Tue, 2 Jun 2026 16:28:10 +0300 Message-ID: <20260602132824.3541151-4-claudiu.beznea@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260602132824.3541151-1-claudiu.beznea@kernel.org> References: <20260602132824.3541151-1-claudiu.beznea@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Claudiu Beznea Use the same reset deassert order in the resume and probe paths to avoid potential failures due to ordering differences. Fixes: e7218986319b ("i3c: renesas: Add suspend/resume support") Cc: stable@vger.kernel.org Reviewed-by: Frank Li Signed-off-by: Claudiu Beznea --- Changes in v2: - collected tags drivers/i3c/master/renesas-i3c.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/i3c/master/renesas-i3c.c b/drivers/i3c/master/renesas-= i3c.c index 88a16efe096d..4c86e7257804 100644 --- a/drivers/i3c/master/renesas-i3c.c +++ b/drivers/i3c/master/renesas-i3c.c @@ -1455,17 +1455,17 @@ static int renesas_i3c_resume_noirq(struct device *= dev) struct renesas_i3c *i3c =3D dev_get_drvdata(dev); int i, ret; =20 - ret =3D reset_control_deassert(i3c->presetn); + ret =3D reset_control_deassert(i3c->tresetn); if (ret) return ret; =20 - ret =3D reset_control_deassert(i3c->tresetn); + ret =3D reset_control_deassert(i3c->presetn); if (ret) - goto err_presetn; + goto err_tresetn; =20 ret =3D clk_bulk_enable(i3c->num_clks, i3c->clks); if (ret) - goto err_tresetn; + goto err_presetn; =20 /* Re-store I3C registers value. */ renesas_writel(i3c->regs, STDBR, i3c->i3c_STDBR); @@ -1486,10 +1486,10 @@ static int renesas_i3c_resume_noirq(struct device *= dev) =20 return 0; =20 -err_tresetn: - reset_control_assert(i3c->tresetn); err_presetn: reset_control_assert(i3c->presetn); +err_tresetn: + reset_control_assert(i3c->tresetn); return ret; } =20 --=20 2.43.0 From nobody Mon Jun 8 04:25:46 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EA3BB3E5A21; Tue, 2 Jun 2026 13:28:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780406931; cv=none; b=d1/J5zEK/KpooGRsnC9HOYSpE2GgUne/P4aviGjlTYFOskW4gGGnaWTzaKC5bx30Y4Q264L9fVeopC6pbGdl+c4ZFu6HdT6kdtOnJrDJ0kqvWZWfaw6omVI21H7Vd0w7nzcnA84UU0z8N4povRl80DriNfCS6IqbTfOs4EQozxQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780406931; c=relaxed/simple; bh=/D9myWzOYhiJGEiwkgYqt1RXn9mtu4prLjo/v6yL5EY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Tj+Rtd3RUF3sMcVoWESsz2T/Pk8qp5BDGmpSfWzwZV9ZvJFJplee1xfAAa1e+1+OOyPN9A2YwJTmPJJ0/iNgVtSwslSAvdBx24egiGnIQSWpywI5jBoOtkW5pqfyambeinvtvUFTiQGJ+qniw0wtGiZDPsPCUwywTReHOrakRAk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YXvVOurL; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="YXvVOurL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7C0731F00893; Tue, 2 Jun 2026 13:28:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1780406930; bh=Qspis+L1JNnAbvAkosgr7KtefAU+xomaTqjuuxz6cHs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=YXvVOurLIVFgjm79RDECMKuvCjFBgY75NtILZzbDKD0Io5/oDfLID3eWGgOEU4hK1 GcKYI1dHMRdOvN5R8b/x+s6TSm1LpfNRIn4Y0h9on78kTHDy4gU5EjvRYZjHYEWefh jPADOZ6qzfIvnobCL+nVmJ3eW6GTbR8Nu9ZlRii5pddhUrzKmbuIg3yYhLc7vBRvW/ UbhiYhydeaFbxfF4V4RYILBK+n1Y3Rv4ndJn9wAzDvrsPtddVSsYAq/hYPI2MNrGZj NT/pMu9/rvd1D7B/OPQFTGjRQ3rpy23qV7oG7mNJYqO5ujO2F9C1ft5E29ltMlyCv5 60tTZvY33VkgA== From: Claudiu Beznea To: wsa+renesas@sang-engineering.com, tommaso.merciai.xr@bp.renesas.com, alexandre.belloni@bootlin.com, Frank.Li@nxp.com, p.zabel@pengutronix.de Cc: claudiu.beznea@kernel.org, claudiu.beznea@tuxon.dev, linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, Claudiu Beznea , stable@vger.kernel.org Subject: [PATCH v2 04/17] i3c: renesas: Reconfigure the DATBAS register on re-attach Date: Tue, 2 Jun 2026 16:28:11 +0300 Message-ID: <20260602132824.3541151-5-claudiu.beznea@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260602132824.3541151-1-claudiu.beznea@kernel.org> References: <20260602132824.3541151-1-claudiu.beznea@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Claudiu Beznea During re-attach, the device may change its position in the i3c->addrs[] array. As a result, it may use a different Device Address Table Basic Register (DATBAS), which needs to be reconfigured. Reconfigure the DATBAS register on re-attach. Along with it update software caches. Fixes: d028219a9f14 ("i3c: master: Add basic driver for the Renesas I3C con= troller") Cc: stable@vger.kernel.org Signed-off-by: Claudiu Beznea Reviewed-by: Frank Li --- Changes in v2: - dropped the "if (pos < 0)" check in renesas_i3c_reattach_i3c_dev() to all= ow re-attaching in case of a full bus; along with it the condition to update the DATBAS register and software caches was updated to if (data->index !=3D pos && pos >=3D 0) - adjusted the patch title drivers/i3c/master/renesas-i3c.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/i3c/master/renesas-i3c.c b/drivers/i3c/master/renesas-= i3c.c index 4c86e7257804..76a4831098c9 100644 --- a/drivers/i3c/master/renesas-i3c.c +++ b/drivers/i3c/master/renesas-i3c.c @@ -892,10 +892,26 @@ static int renesas_i3c_reattach_i3c_dev(struct i3c_de= v_desc *dev, struct i3c_master_controller *m =3D i3c_dev_get_master(dev); struct renesas_i3c *i3c =3D to_renesas_i3c(m); struct renesas_i3c_i2c_dev_data *data =3D i3c_dev_get_master_data(dev); + int pos; + + pos =3D renesas_i3c_get_free_pos(i3c); + + if (data->index !=3D pos && pos >=3D 0) { + renesas_writel(i3c->regs, DATBAS(data->index), 0); + i3c->addrs[data->index] =3D 0; + i3c->free_pos |=3D BIT(data->index); + + data->index =3D pos; + i3c->free_pos &=3D ~BIT(data->index); + } =20 i3c->addrs[data->index] =3D dev->info.dyn_addr ? dev->info.dyn_addr : dev->info.static_addr; =20 + renesas_writel(i3c->regs, DATBAS(data->index), + DATBAS_DVSTAD(dev->info.static_addr) | + datbas_dvdyad_with_parity(i3c->addrs[data->index])); + return 0; } =20 --=20 2.43.0 From nobody Mon Jun 8 04:25:46 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0CE9A3E5EC4; Tue, 2 Jun 2026 13:28:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780406935; cv=none; b=ZAmuhyY1Pz4uDjEWsPMpNGw2w1zAMbgvjFuraVNj9sbX+8Lb2ulS6/EUoT3zdLTehyszRYRDHlPKbtVo92a9qV4ufiMgPYsVAdEpGyW/xRIYFmI1rcTgmleqw6vh88gRagc4aUEz579dAnv5nlCrQNC0j563Ty62D1O0XokXT3A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780406935; c=relaxed/simple; bh=qI6kwWXjoWk71ZyBbwUIICzDd0nHr3yyBFsgbAjrEXI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OUPNUueVibZPVCbwUv5b44h81254uPc6cRmh+be/IXm5z/vI72r3B2rOtEZpPP0k/hIUlEZMA8r0sXGBXp0kkL9LJLbHxyxgtHBNVsEGPGh8ctQtGu9NUYLe4ddUnS0f33MQKbJe2YjXLRygqnzPw7FwWiFf9jkvrti9/dUK/zw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NPsV2gbg; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NPsV2gbg" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4F9451F00898; Tue, 2 Jun 2026 13:28:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1780406933; bh=0D0dLV/fBm0s6q+TqOcMlytNbQnf/vCu6r9Q0s5p2/4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=NPsV2gbgz0vamvhok1+NPNiys67x2d6zVnVyZOK77M8QHinio04gYeWBB/ataicie 1z3BAo0gMLY8hDqSrjB65ceFTD704xjJnq84yeZHORRNnvVq7cKzhwALjH/eGuOPqG 4jDnUQaST3IWH3axHMc+WbjaLijfdfsl2HuWkANmybFmSrQcBF5psF7p8EI0ZpEtU2 rlD8sMvaqsKyGnDtsZAWyMHLQfjsrjLqpdGnOa4OlQHDy6pTfj1xktBETlvEPhLhFt 9arX9E1ZTc0YLdJ3iQSpaQ/9NEEHac77H4htzoIk4T90E4pc0j9ADz6e2s2Hbq+XL4 kd2iVG1JE3SCg== From: Claudiu Beznea To: wsa+renesas@sang-engineering.com, tommaso.merciai.xr@bp.renesas.com, alexandre.belloni@bootlin.com, Frank.Li@nxp.com, p.zabel@pengutronix.de Cc: claudiu.beznea@kernel.org, claudiu.beznea@tuxon.dev, linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, Claudiu Beznea , stable@vger.kernel.org Subject: [PATCH v2 05/17] i3c: renesas: Reset the controller on resume Date: Tue, 2 Jun 2026 16:28:12 +0300 Message-ID: <20260602132824.3541151-6-claudiu.beznea@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260602132824.3541151-1-claudiu.beznea@kernel.org> References: <20260602132824.3541151-1-claudiu.beznea@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Claudiu Beznea Reset the controller on resume after enabling the clocks to follow the same sequence as in probe and avoid potential ordering related failures. With it, renesas_i3c_reset() was updated to use read_poll_timeout_atomic(), as the driver's resume callback is executed during the noirq phase of resume, where interrupts are disabled. Fixes: e7218986319b ("i3c: renesas: Add suspend/resume support") Cc: stable@vger.kernel.org Reviewed-by: Frank Li Signed-off-by: Claudiu Beznea --- Changes in v2: - replaced the read_poll_timeout() in renesas_i3c_reset() with read_poll_timeout_atomic() as the renesas_i3c_reset() is called in noirq phase of the suspend/resume; updated the patch description to reflect that - collected Frank's tag. Frank, please let me know if this should be dropped. Thanks! drivers/i3c/master/renesas-i3c.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/i3c/master/renesas-i3c.c b/drivers/i3c/master/renesas-= i3c.c index 76a4831098c9..7ef317b2ba39 100644 --- a/drivers/i3c/master/renesas-i3c.c +++ b/drivers/i3c/master/renesas-i3c.c @@ -480,8 +480,8 @@ static int renesas_i3c_reset(struct renesas_i3c *i3c) renesas_writel(i3c->regs, BCTL, 0); renesas_set_bit(i3c->regs, RSTCTL, RSTCTL_RI3CRST); =20 - return read_poll_timeout(renesas_readl, val, !(val & RSTCTL_RI3CRST), - 0, 1000, false, i3c->regs, RSTCTL); + return read_poll_timeout_atomic(renesas_readl, val, !(val & RSTCTL_RI3CRS= T), + 0, 1000, false, i3c->regs, RSTCTL); } =20 static void renesas_i3c_hw_init(struct renesas_i3c *i3c) @@ -1483,6 +1483,10 @@ static int renesas_i3c_resume_noirq(struct device *d= ev) if (ret) goto err_presetn; =20 + ret =3D renesas_i3c_reset(i3c); + if (ret) + goto err_clks_disable; + /* Re-store I3C registers value. */ renesas_writel(i3c->regs, STDBR, i3c->i3c_STDBR); renesas_writel(i3c->regs, EXTBR, i3c->extbr); @@ -1502,6 +1506,8 @@ static int renesas_i3c_resume_noirq(struct device *de= v) =20 return 0; =20 +err_clks_disable: + clk_bulk_disable(i3c->num_clks, i3c->clks); err_presetn: reset_control_assert(i3c->presetn); err_tresetn: --=20 2.43.0 From nobody Mon Jun 8 04:25:46 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D89EC3E834D; Tue, 2 Jun 2026 13:28:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780406938; cv=none; b=B6gQo4oc1WkXX1upsqFMihX2fIj0CmWMHbeQwXDAzcqIupiGU8+9OI046pUdoaQZ0vtipyNbLPTP5wk/1NlTu/SdP+zf6DiZYMWJW4kyUqqdqDplIyE9NCinL4Y0W65LcBmELFg9sYOrN5DGUb6Pil5C3thT+06oeZREG6N9QPA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780406938; c=relaxed/simple; bh=8SjuhPrv3uabNPKI6MGxfl/0UPfL1oNjBVyA8yOzaow=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Xl+RQBI+yrJonSyYbbDHXbGo3Cj3LiV53EOchCfLJaQo/+hewmm4PEn7krNyJNg0RMuEoYXJmWDui6SFb1DXP7xEyfKtL2CfW+wxgyGvjiOVU8naVirgqlCkotq7Uv5CpijbkoqaK0koQvtcTyCSbcsuua8rx7mig9EyRbsldNc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=djnFz0XS; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="djnFz0XS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 296061F00893; Tue, 2 Jun 2026 13:28:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1780406936; bh=ce6d448Crr+TTQaxq3i+6pbkRz+e4tsfgiKlchCYn5U=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=djnFz0XSIoV+rS5SKfgIiOxrRnONNwsmlTYRXAUsGLo58IRbKzd4QP/BhMM/7CGC5 nGMWaT1mGSFyAsZDlj4pO5lWMIs1Duab+YCjB9jTmIgq9Q1dM0eTgL5Vmg3y6jkVd/ q9JidZnJqVR3BafwBHnnlqiiTqniDkpO0hj+TqQmuGvIcffxC9vSplL3Qfvk/fpcyk U0subqqoLzJ+LMs3LG6oY8Cqf79oeX69eruR7RntnU+keGgQ8CVSVgGNYhDKc37ptk VcNneqtC8CQN1xe98QjJJvVSjGeCB6kzXh2RDZPE5HyLGaS6E25FWTIblEcno3m8Sz KMfbjtiUSzZew== From: Claudiu Beznea To: wsa+renesas@sang-engineering.com, tommaso.merciai.xr@bp.renesas.com, alexandre.belloni@bootlin.com, Frank.Li@nxp.com, p.zabel@pengutronix.de Cc: claudiu.beznea@kernel.org, claudiu.beznea@tuxon.dev, linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, Claudiu Beznea , stable@vger.kernel.org Subject: [PATCH v2 06/17] i3c: renesas: Perform Dynamic Address Assignment on resume Date: Tue, 2 Jun 2026 16:28:13 +0300 Message-ID: <20260602132824.3541151-7-claudiu.beznea@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260602132824.3541151-1-claudiu.beznea@kernel.org> References: <20260602132824.3541151-1-claudiu.beznea@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Claudiu Beznea The Renesas RZ/G3S SoC supports a power saving mode where power to most SoC components, including I3C, is turned off. On systems where the I3C devices also loses power during suspend (e.g. NXP P3T1085UK-ARD connected to the PMOD1_6A connector of the RZ SMARC Carrier 2 + Renesas RZ/G3S SMARC SOM), the devices becomes unreachable after resume. Running DAA in the controller resume path restores communication. However, DAA relies on interrupts for TX/RX, which are not available in the noirq suspend/resume phase (unless they are wakeup interrupts). For this, the suspend/resume callbacks were moved out of the noirq phase. Currently, there is no identified use case on either the Renesas RZ/G3S or Renesas RZ/G3E SoCs that requires the controller suspend/resume hooks to be part of the noirq suspend/resume phase. Since renesas_i3c_reset() is not called anymore in atomic context update it to use read_poll_timeout(). To cover the case where the controller had already attached all the i3c->maxdevs devices before a suspend/resume cycle and i3c->free_pos is zero, struct renesas_i3c::resuming flag was introduced. The flag is set in renesas_i3c_resume() before calling i3c_master_do_daa_ext() and checked in renesas_i3c_daa(). In case it is set the previous saved DATBAS register values are used for the slots already occupied before suspend. This allows keeping alive the connection to the I3C devices when all the supported slots are occupied before suspend. When resuming from suspend, renesas_i3c_daa() re-runs DAA for al slots except those used by I2C devices. I2C devices are attached during probe, at bus initialization time, and always occupy the first positions in i3c->free_pos. In addition, there are no DATBAS register settings associated with them. Fixes: e7218986319b ("i3c: renesas: Add suspend/resume support") Cc: stable@vger.kernel.org Signed-off-by: Claudiu Beznea --- Changes in v2: - adjusted the code to still work in case the full bus was occupied before a suspend/resume cycle; for that: -- introduced struct renesas_i3c_addr -- preserved i3c->DATBASn[] which is saved in suspend and used in resume, in renesas_i3c_daa() - updated the patch description to reflect the new updates drivers/i3c/master/renesas-i3c.c | 103 ++++++++++++++++++++++--------- 1 file changed, 75 insertions(+), 28 deletions(-) diff --git a/drivers/i3c/master/renesas-i3c.c b/drivers/i3c/master/renesas-= i3c.c index 7ef317b2ba39..695aae6ac263 100644 --- a/drivers/i3c/master/renesas-i3c.c +++ b/drivers/i3c/master/renesas-i3c.c @@ -252,6 +252,11 @@ struct renesas_i3c_xferqueue { spinlock_t lock; }; =20 +struct renesas_i3c_addr { + bool is_i2c; + u8 addr; +}; + struct renesas_i3c { struct i3c_master_controller base; enum i3c_internal_state internal_state; @@ -262,13 +267,14 @@ struct renesas_i3c { u32 i3c_STDBR; u32 extbr; unsigned long rate; - u8 addrs[RENESAS_I3C_MAX_DEVS]; + struct renesas_i3c_addr addrs[RENESAS_I3C_MAX_DEVS]; struct renesas_i3c_xferqueue xferqueue; void __iomem *regs; u32 *DATBASn; struct clk_bulk_data *clks; struct reset_control *presetn; struct reset_control *tresetn; + bool resuming; u8 num_clks; u8 refclk_div; }; @@ -335,7 +341,7 @@ static int renesas_i3c_get_addr_pos(struct renesas_i3c = *i3c, u8 addr) int pos; =20 for (pos =3D 0; pos < i3c->maxdevs; pos++) { - if (addr =3D=3D i3c->addrs[pos]) + if (addr =3D=3D i3c->addrs[pos].addr) return pos; } =20 @@ -480,8 +486,8 @@ static int renesas_i3c_reset(struct renesas_i3c *i3c) renesas_writel(i3c->regs, BCTL, 0); renesas_set_bit(i3c->regs, RSTCTL, RSTCTL_RI3CRST); =20 - return read_poll_timeout_atomic(renesas_readl, val, !(val & RSTCTL_RI3CRS= T), - 0, 1000, false, i3c->regs, RSTCTL); + return read_poll_timeout(renesas_readl, val, !(val & RSTCTL_RI3CRST), + 0, 1000, false, i3c->regs, RSTCTL); } =20 static void renesas_i3c_hw_init(struct renesas_i3c *i3c) @@ -641,8 +647,9 @@ static int renesas_i3c_daa(struct i3c_master_controller= *m) { struct renesas_i3c *i3c =3D to_renesas_i3c(m); struct renesas_i3c_cmd *cmd; - u32 olddevs, newdevs; u8 last_addr =3D 0, pos; + int last_i2c_pos =3D -1; + u32 olddevs, newdevs; int ret; =20 struct renesas_i3c_xfer *xfer __free(kfree) =3D renesas_i3c_alloc_xfer(i3= c, 1); @@ -657,14 +664,33 @@ static int renesas_i3c_daa(struct i3c_master_controll= er *m) =20 /* Setting DATBASn registers for target devices. */ for (pos =3D 0; pos < i3c->maxdevs; pos++) { - if (olddevs & BIT(pos)) + if (olddevs & BIT(pos)) { + /* + * In case of resume, reassign DAs for all devices on the + * bus to avoid failures when all i3c->maxdevs slots were + * already occupied before suspend. + * + * Exclude I2C devices, as they are attached during probe, + * at bus initialization time, and there are currently no + * register updates associated with them. + */ + if (i3c->resuming) { + if (i3c->addrs[pos].is_i2c) { + last_i2c_pos =3D pos; + } else { + renesas_writel(i3c->regs, DATBAS(pos), + i3c->DATBASn[pos]); + } + } + continue; + } =20 ret =3D i3c_master_get_free_addr(m, last_addr + 1); if (ret < 0) return -ENOSPC; =20 - i3c->addrs[pos] =3D ret; + i3c->addrs[pos].addr =3D ret; last_addr =3D ret; =20 renesas_writel(i3c->regs, DATBAS(pos), datbas_dvdyad_with_parity(ret)); @@ -674,9 +700,21 @@ static int renesas_i3c_daa(struct i3c_master_controlle= r *m) cmd =3D xfer->cmds; cmd->rx_count =3D 0; =20 - ret =3D renesas_i3c_get_free_pos(i3c); - if (ret < 0) - return ret; + if (i3c->resuming) { + /* Nothing to do if all slots are ocupied by I2C devices. */ + if (last_i2c_pos =3D=3D i3c->maxdevs - 1) + return 0; + + /* + * Do DAA for all the devices on the bus, if resuming, except + * the I2C ones. + */ + ret =3D last_i2c_pos < 0 ? 0 : last_i2c_pos + 1; + } else { + ret =3D renesas_i3c_get_free_pos(i3c); + if (ret < 0) + return ret; + } =20 /* * Setup the command descriptor to start the ENTDAA command @@ -694,7 +732,7 @@ static int renesas_i3c_daa(struct i3c_master_controller= *m) =20 for (pos =3D 0; pos < i3c->maxdevs; pos++) { if (newdevs & BIT(pos)) - i3c_master_add_i3c_dev_locked(m, i3c->addrs[pos]); + i3c_master_add_i3c_dev_locked(m, i3c->addrs[pos].addr); } =20 return 0; @@ -876,11 +914,11 @@ static int renesas_i3c_attach_i3c_dev(struct i3c_dev_= desc *dev) return -ENOMEM; =20 data->index =3D pos; - i3c->addrs[pos] =3D dev->info.dyn_addr ? : dev->info.static_addr; + i3c->addrs[pos].addr =3D dev->info.dyn_addr ? : dev->info.static_addr; i3c->free_pos &=3D ~BIT(pos); =20 renesas_writel(i3c->regs, DATBAS(pos), DATBAS_DVSTAD(dev->info.static_add= r) | - datbas_dvdyad_with_parity(i3c->addrs[pos])); + datbas_dvdyad_with_parity(i3c->addrs[pos].addr)); i3c_dev_set_master_data(dev, data); =20 return 0; @@ -898,19 +936,19 @@ static int renesas_i3c_reattach_i3c_dev(struct i3c_de= v_desc *dev, =20 if (data->index !=3D pos && pos >=3D 0) { renesas_writel(i3c->regs, DATBAS(data->index), 0); - i3c->addrs[data->index] =3D 0; + i3c->addrs[data->index].addr =3D 0; i3c->free_pos |=3D BIT(data->index); =20 data->index =3D pos; i3c->free_pos &=3D ~BIT(data->index); } =20 - i3c->addrs[data->index] =3D dev->info.dyn_addr ? dev->info.dyn_addr : + i3c->addrs[data->index].addr =3D dev->info.dyn_addr ? dev->info.dyn_addr : dev->info.static_addr; =20 renesas_writel(i3c->regs, DATBAS(data->index), DATBAS_DVSTAD(dev->info.static_addr) | - datbas_dvdyad_with_parity(i3c->addrs[data->index])); + datbas_dvdyad_with_parity(i3c->addrs[data->index].addr)); =20 return 0; } @@ -922,7 +960,7 @@ static void renesas_i3c_detach_i3c_dev(struct i3c_dev_d= esc *dev) struct renesas_i3c *i3c =3D to_renesas_i3c(m); =20 i3c_dev_set_master_data(dev, NULL); - i3c->addrs[data->index] =3D 0; + i3c->addrs[data->index].addr =3D 0; i3c->free_pos |=3D BIT(data->index); kfree(data); } @@ -1002,7 +1040,8 @@ static int renesas_i3c_attach_i2c_dev(struct i2c_dev_= desc *dev) return -ENOMEM; =20 data->index =3D pos; - i3c->addrs[pos] =3D dev->addr; + i3c->addrs[pos].addr =3D dev->addr; + i3c->addrs[pos].is_i2c =3D true; i3c->free_pos &=3D ~BIT(pos); i2c_dev_set_master_data(dev, data); =20 @@ -1016,7 +1055,8 @@ static void renesas_i3c_detach_i2c_dev(struct i2c_dev= _desc *dev) struct renesas_i3c *i3c =3D to_renesas_i3c(m); =20 i2c_dev_set_master_data(dev, NULL); - i3c->addrs[data->index] =3D 0; + i3c->addrs[data->index].addr =3D 0; + i3c->addrs[data->index].is_i2c =3D false; i3c->free_pos |=3D BIT(data->index); kfree(data); } @@ -1435,7 +1475,7 @@ static void renesas_i3c_remove(struct platform_device= *pdev) i3c_master_unregister(&i3c->base); } =20 -static int renesas_i3c_suspend_noirq(struct device *dev) +static int renesas_i3c_suspend(struct device *dev) { struct renesas_i3c *i3c =3D dev_get_drvdata(dev); int i, ret; @@ -1466,10 +1506,10 @@ static int renesas_i3c_suspend_noirq(struct device = *dev) return ret; } =20 -static int renesas_i3c_resume_noirq(struct device *dev) +static int renesas_i3c_resume(struct device *dev) { struct renesas_i3c *i3c =3D dev_get_drvdata(dev); - int i, ret; + int ret; =20 ret =3D reset_control_deassert(i3c->tresetn); if (ret) @@ -1495,15 +1535,23 @@ static int renesas_i3c_resume_noirq(struct device *= dev) renesas_writel(i3c->regs, MSDVAD, MSDVAD_MDYADV | MSDVAD_MDYAD(i3c->dyn_addr)); =20 - /* Restore Device Address Table values. */ - for (i =3D 0; i < i3c->maxdevs; i++) - renesas_writel(i3c->regs, DATBAS(i), i3c->DATBASn[i]); - /* I3C hw init. */ renesas_i3c_hw_init(i3c); =20 i2c_mark_adapter_resumed(&i3c->base.i2c); =20 + i3c->resuming =3D true; + + ret =3D i3c_master_do_daa_ext(&i3c->base, true); + if (ret) + dev_err(dev, "DAA failed on resume, ret=3D%d", ret); + + i3c->resuming =3D false; + + /* + * I3C devices may have retained their dynamic address anyway. Do not + * fail the resume because of DAA error. + */ return 0; =20 err_clks_disable: @@ -1516,8 +1564,7 @@ static int renesas_i3c_resume_noirq(struct device *de= v) } =20 static const struct dev_pm_ops renesas_i3c_pm_ops =3D { - NOIRQ_SYSTEM_SLEEP_PM_OPS(renesas_i3c_suspend_noirq, - renesas_i3c_resume_noirq) + SYSTEM_SLEEP_PM_OPS(renesas_i3c_suspend, renesas_i3c_resume) }; =20 static const struct of_device_id renesas_i3c_of_ids[] =3D { --=20 2.43.0 From nobody Mon Jun 8 04:25:46 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C1BCA3E835F; Tue, 2 Jun 2026 13:28:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780406940; cv=none; b=pCUwmaAS2ZkkaYau4Cy8XZ9f9zXqmJCcWc86c3NS6Dzk8xU7UC6prrXGOI/3JCtvO4qqvl2XW52xYNzCqAbEcNEfY2jBtTdgM5kn8EVT9yeIzrRr3LC6AiDnenOFwwphV6Lpfsdw5Yy7JzFph1ErtTf0mE5mM1iQt1qb8u9yEnk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780406940; c=relaxed/simple; bh=sJuC9Xkw6gSvyoP1DQwUIKxyM5R2tTCKV8RMXqIaWeM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OKG1bGmuZr6tOkti6KN7ZjGtJnd+4pGoOZqcyMFda54I2Tfdyu3T/gtQapKDxHCO+2PsxnBPx3Nva4vS6ZjnY82YJGyIGMq3GCl3HVHi9WOPbBwrb2xmQ5LhN1glM+Tok0nCwblYFwJjTUdmklsmonQgpNgV8faoa3/6E0uge6I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XNII7hWK; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XNII7hWK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 07B151F00898; Tue, 2 Jun 2026 13:28:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1780406939; bh=7/ANmW8xMeqtj8v82T2dps0zvcqGIwe6OGsGwbvUozQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=XNII7hWKd+0edWhj4oLzEQ5fnh0lOaU1PIQ9pvQ3HOdRgOVDokYBmj2/zOjDzv+3J pzXpbJU7KbU2jqaTmzhW4s7rEA8qN+LJ2b6SnbeHDNgN+I/LwP8E0gdaguDvYPGAv+ tuV6VgW218nuNdbY4aTaElZZaUPnGBW39w3rMq/HHAcPKn9tnuvZyEMF+TpJLdRPSg uHlFMKVghSprn2MSs4hgHuDwk+yeLZbubrvq9FQYMr1JiU4ImmnHNeNUcw1BdcMCO5 Z2gDnV5Cl9uFVDwYeVx092F5A7YK3MNln5Ry8AbfEwV9Uv9oJt6QSFPiYC0573QpZP 3F+xnId/Q7A/Q== From: Claudiu Beznea To: wsa+renesas@sang-engineering.com, tommaso.merciai.xr@bp.renesas.com, alexandre.belloni@bootlin.com, Frank.Li@nxp.com, p.zabel@pengutronix.de Cc: claudiu.beznea@kernel.org, claudiu.beznea@tuxon.dev, linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, Claudiu Beznea , stable@vger.kernel.org Subject: [PATCH v2 07/17] i3c: renesas: Do not attach devices if xfer failed Date: Tue, 2 Jun 2026 16:28:14 +0300 Message-ID: <20260602132824.3541151-8-claudiu.beznea@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260602132824.3541151-1-claudiu.beznea@kernel.org> References: <20260602132824.3541151-1-claudiu.beznea@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Claudiu Beznea The controller may return an NRSPQP_ERROR_* error code while still providing a valid cmd->rx_count. It has been observed that when the transfer fails with NRSPQP_ERROR_ADDRESS_NACK, calling i3c_master_add_i3c_dev_locked() may lead to crashes. Set newdevs to zero if the transfer failed. Fixes: e7218986319b ("i3c: renesas: Add suspend/resume support") Cc: stable@vger.kernel.org Signed-off-by: Claudiu Beznea --- Changes in v2: - none, this patch is new drivers/i3c/master/renesas-i3c.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/i3c/master/renesas-i3c.c b/drivers/i3c/master/renesas-= i3c.c index 695aae6ac263..de09f0cadb72 100644 --- a/drivers/i3c/master/renesas-i3c.c +++ b/drivers/i3c/master/renesas-i3c.c @@ -727,8 +727,13 @@ static int renesas_i3c_daa(struct i3c_master_controlle= r *m) =20 renesas_i3c_wait_xfer(i3c, xfer); =20 - newdevs =3D GENMASK(i3c->maxdevs - cmd->rx_count - 1, 0); - newdevs &=3D ~olddevs; + /* Skip attaching if there are failures on the xfer. */ + if (xfer->ret) { + newdevs =3D 0; + } else { + newdevs =3D GENMASK(i3c->maxdevs - cmd->rx_count - 1, 0); + newdevs &=3D ~olddevs; + } =20 for (pos =3D 0; pos < i3c->maxdevs; pos++) { if (newdevs & BIT(pos)) --=20 2.43.0 From nobody Mon Jun 8 04:25:46 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 998263E63A6; Tue, 2 Jun 2026 13:29:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780406943; cv=none; b=aBcyuM4n9NmqDbCsOvwVlICeb9rBHo9XKShoewRvg2h316njVrN7l1GpOkuBLGrhdc1J1S7sJr55tmCpyKtgrrcfOkAhzXcY6VaYaJHoLo8XjVofi9aRIUJEKrM8QJY5m+yMPoa6D7y88dATNRfSzlEaDn2atm7R8Bq4DLqkl8s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780406943; c=relaxed/simple; bh=YPbIXm+JSBimFwt0xBV5hfH5fdtSlFueddvGrzKCAd8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SOkVcok/hyKCmT8ttnjRtIzBxSr7TicpkbFLp2OH42l+MH9PUbWCu0nZeaMtVJYEhv1F/8O1ZTYHL6QLV6zA3nZgecKztyKgoFzYoP75bmTreAfvq6dgTVHcvMhLk26ko2T+8yPsJ062T5YXjVd2nBHiUkRBLiSxtlgL6mvJGkQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MSO0Uo1f; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="MSO0Uo1f" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D117C1F00893; Tue, 2 Jun 2026 13:28:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1780406942; bh=oYMOrxgRJMWSL8TQv7hQo8EwvU2bnk7SM1kv7Y62O6Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=MSO0Uo1f004DvILS7nrFuA1dvjTlttKNR0UToOdSXhXOSmB+Jl99Tvn4lapxBXglM BfUklN3KwDgq3FmBnr3GjPRzSx72L+eyiNfMW3sreUIJiN8lp+bun9e1DuD5yn8ZiV LYXzJySaEOhHOQdoVcL8NjT4Au9ssXA/xfNUXrzF1m2bFm60QLtCRXVXBKsbxZMCzg sDxB7L99LjpfEaXGq/TychYjP+OAUcPYJIy1Ob/OTBmWKmRV1/aBtnAK/M70r+MEup 6S3R/U2xiXM4bthVfM3k4NgAxwIo8ZnJGPrGv2jGqSk3k4w8LUYi5ZGNpnVLYCNj3B 18ORIoRy9WzWg== From: Claudiu Beznea To: wsa+renesas@sang-engineering.com, tommaso.merciai.xr@bp.renesas.com, alexandre.belloni@bootlin.com, Frank.Li@nxp.com, p.zabel@pengutronix.de Cc: claudiu.beznea@kernel.org, claudiu.beznea@tuxon.dev, linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, Claudiu Beznea , stable@vger.kernel.org Subject: [PATCH v2 08/17] i3c: renesas: Clean DATBAS register on detach Date: Tue, 2 Jun 2026 16:28:15 +0300 Message-ID: <20260602132824.3541151-9-claudiu.beznea@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260602132824.3541151-1-claudiu.beznea@kernel.org> References: <20260602132824.3541151-1-claudiu.beznea@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Claudiu Beznea The controller uses DATBAS registers on TX/RX logic. Clean the DATBAS register for the detached I3C device to avoid issues. Fixes: d028219a9f14 ("i3c: master: Add basic driver for the Renesas I3C con= troller") Cc: stable@vger.kernel.org Reviewed-by: Frank Li Signed-off-by: Claudiu Beznea --- Changes in v2: - collected tags drivers/i3c/master/renesas-i3c.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/i3c/master/renesas-i3c.c b/drivers/i3c/master/renesas-= i3c.c index de09f0cadb72..7167ca12a328 100644 --- a/drivers/i3c/master/renesas-i3c.c +++ b/drivers/i3c/master/renesas-i3c.c @@ -964,6 +964,8 @@ static void renesas_i3c_detach_i3c_dev(struct i3c_dev_d= esc *dev) struct i3c_master_controller *m =3D i3c_dev_get_master(dev); struct renesas_i3c *i3c =3D to_renesas_i3c(m); =20 + renesas_writel(i3c->regs, DATBAS(data->index), 0); + i3c_dev_set_master_data(dev, NULL); i3c->addrs[data->index].addr =3D 0; i3c->free_pos |=3D BIT(data->index); --=20 2.43.0 From nobody Mon Jun 8 04:25:46 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4393F3E95BD for ; Tue, 2 Jun 2026 13:29:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780406946; cv=none; b=RalJR3llSoKkHQVBf+R6JdivdMYAwWOMsUWQ6bQ8t+h2VeVRH4ZMD41QtHCq0wsW2bCIuEvDVTXSwRd3alM3u7FLoTRGhmrLQ1z9S9sedJff33RwpFHz0oGxVdz4HNIEeL8TnlCIZ017ni36eKb/gDbt2TehbdLxoErH2TRdUXA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780406946; c=relaxed/simple; bh=z4jo9wQK7BCuf2T6lxZzO0pH7gJx/4HknMx2a5pllMk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MBgFGPouFHDTlqqERAsmz2hcB62MqZiOikNGl/WW53w6HjcqLzprlichTeGVrwIOUZsHOiPU57X/xHIEmx6TlxLFXp1DQUpE19wCqiXrcELfO0qJQZ1ylW2m35/XCEZkhXoCE+Uf217FX7QEu5IYnN8fnpqp3FcUIyIzGLBbIME= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=T8uYQsmb; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="T8uYQsmb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AE0AF1F00898; Tue, 2 Jun 2026 13:29:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1780406944; bh=IfCVbZ5MNhLZ2k/mZZ6dMFMSJ/4ShA27RA4/y6hlIj8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=T8uYQsmb6a7hO5aBvyb/cEV+CKbuBff/eck/zWre1njfXZhiraKMedE8LTeNzdiLe 1a7FAa9baq9oiLv2379T9i3VpteMeqs57brn9PndPr9RZDPhgli9V/XtLzlAQmgt2E W5XDARPRmLy/y3q3HTAD5CfYLsM56S4HXTXYyn5Uv8X80BjeKNIo+VkORZfAhETiyV 81VNLTni5ZnUkoA608E3OhDb/WZuu3f220ZJ+t6du19mXhD+CrFTARtu0Sr2SjgZaJ lSnO7Xy0KDk4z+oszjjXwV8o9b6S0qQILGOuWbkxBesxPH408pp1AdC2SivDweLjbO jNLFJWSqzggCA== From: Claudiu Beznea To: wsa+renesas@sang-engineering.com, tommaso.merciai.xr@bp.renesas.com, alexandre.belloni@bootlin.com, Frank.Li@nxp.com, p.zabel@pengutronix.de Cc: claudiu.beznea@kernel.org, claudiu.beznea@tuxon.dev, linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, Claudiu Beznea Subject: [PATCH v2 09/17] i3c: renesas: Use reset_control_bulk_{assert, deassert}() Date: Tue, 2 Jun 2026 16:28:16 +0300 Message-ID: <20260602132824.3541151-10-claudiu.beznea@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260602132824.3541151-1-claudiu.beznea@kernel.org> References: <20260602132824.3541151-1-claudiu.beznea@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Claudiu Beznea Use reset_control_bulk_assert() and reset_control_bulk_deassert() in the suspend and resume paths to simplify the code. Signed-off-by: Claudiu Beznea --- Changes in v2: - none drivers/i3c/master/renesas-i3c.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/drivers/i3c/master/renesas-i3c.c b/drivers/i3c/master/renesas-= i3c.c index 7167ca12a328..860c9f2f17de 100644 --- a/drivers/i3c/master/renesas-i3c.c +++ b/drivers/i3c/master/renesas-i3c.c @@ -1485,6 +1485,10 @@ static void renesas_i3c_remove(struct platform_devic= e *pdev) static int renesas_i3c_suspend(struct device *dev) { struct renesas_i3c *i3c =3D dev_get_drvdata(dev); + struct reset_control_bulk_data resets[] =3D { + { .rstc =3D i3c->presetn }, + { .rstc =3D i3c->tresetn }, + }; int i, ret; =20 i2c_mark_adapter_suspended(&i3c->base.i2c); @@ -1493,20 +1497,14 @@ static int renesas_i3c_suspend(struct device *dev) for (i =3D 0; i < i3c->maxdevs; i++) i3c->DATBASn[i] =3D renesas_readl(i3c->regs, DATBAS(i)); =20 - ret =3D reset_control_assert(i3c->presetn); + ret =3D reset_control_bulk_assert(ARRAY_SIZE(resets), resets); if (ret) goto err_mark_resumed; =20 - ret =3D reset_control_assert(i3c->tresetn); - if (ret) - goto err_presetn; - clk_bulk_disable(i3c->num_clks, i3c->clks); =20 return 0; =20 -err_presetn: - reset_control_deassert(i3c->presetn); err_mark_resumed: i2c_mark_adapter_resumed(&i3c->base.i2c); =20 @@ -1516,19 +1514,19 @@ static int renesas_i3c_suspend(struct device *dev) static int renesas_i3c_resume(struct device *dev) { struct renesas_i3c *i3c =3D dev_get_drvdata(dev); + struct reset_control_bulk_data resets[] =3D { + { .rstc =3D i3c->presetn }, + { .rstc =3D i3c->tresetn }, + }; int ret; =20 - ret =3D reset_control_deassert(i3c->tresetn); + ret =3D reset_control_bulk_deassert(ARRAY_SIZE(resets), resets); if (ret) return ret; =20 - ret =3D reset_control_deassert(i3c->presetn); - if (ret) - goto err_tresetn; - ret =3D clk_bulk_enable(i3c->num_clks, i3c->clks); if (ret) - goto err_presetn; + goto err_resets_asserted; =20 ret =3D renesas_i3c_reset(i3c); if (ret) @@ -1563,10 +1561,8 @@ static int renesas_i3c_resume(struct device *dev) =20 err_clks_disable: clk_bulk_disable(i3c->num_clks, i3c->clks); -err_presetn: - reset_control_assert(i3c->presetn); -err_tresetn: - reset_control_assert(i3c->tresetn); +err_resets_asserted: + reset_control_bulk_assert(ARRAY_SIZE(resets), resets); return ret; } =20 --=20 2.43.0 From nobody Mon Jun 8 04:25:46 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E3F2A3C9EC2 for ; Tue, 2 Jun 2026 13:29:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780406948; cv=none; b=ijnG8F3Kct/3RGxt0dXcO59xrU0SSHGCg0tU6FstoDlR8LX4E9q20aDyT0cKBzDgakpJryJRr7V2c84CLr1cThFbZ53cQXtHdcJRsQezu+pKbjYU+w9DJrac15arzZU8ZInJ5mpIhnMXlpSecQUIPI1hRWLsUTCG3jzyj3tjguY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780406948; c=relaxed/simple; bh=ZtRDOcO/b9lKmUV2nNrZj4t/KjdDEepgY8EiXo7F51A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uuDdHIVejVHzWxz0mz77dskc5r0mXcYwbuaEGca/e06c3Mw13O/hsUxJeZdxcSmMarwYQeHaMrsg1PrclWN3AWOO9iV5x6GPXKBZt7nhvIoKLadxpcKfn+Z1OrZ9MaTV69hooCE2yy1xbZIHeiFwnlMaCATHFsjRyqWe1rOgL3c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UIwgl+6+; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="UIwgl+6+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4F2D11F00893; Tue, 2 Jun 2026 13:29:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1780406947; bh=NUfAs+sHMqHmxNkY0D9GV+o/r6ED3U2p1btc5r6UtuQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=UIwgl+6+I/qo083RzdVRohHXZbyCK+Fiiwnt7Ax7yoUgbLaocDzci4sBWeu6Lw9AQ DEZRgP15OdmkmyQyt9z2dlG1Z6Ge80NH6U04Bkh5MLIBRhWKk9iBfib446tXipBRQA OFrz0JlkPqNXMWSNMox9jHSEkqNzncLlnRHTG/+n0SlNDf6F4+9TQEXWFxQrurhsKh HTUSz5VNaSqD89OWFTmMjPO331hlmS9jWF0y+WCcBemDrncMXXWSBAWsSD4e2hhSod FTRm3v7lWhBUcsZ2/DKo1nhQm4y0i+ooihERDCvCKufbWk1nqTpD+3q7hfVanONDYE 2cZCS8CfilHGw== From: Claudiu Beznea To: wsa+renesas@sang-engineering.com, tommaso.merciai.xr@bp.renesas.com, alexandre.belloni@bootlin.com, Frank.Li@nxp.com, p.zabel@pengutronix.de Cc: claudiu.beznea@kernel.org, claudiu.beznea@tuxon.dev, linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, Claudiu Beznea Subject: [PATCH v2 10/17] i3c: renesas: Return immediately if there is no transfer Date: Tue, 2 Jun 2026 16:28:17 +0300 Message-ID: <20260602132824.3541151-11-claudiu.beznea@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260602132824.3541151-1-claudiu.beznea@kernel.org> References: <20260602132824.3541151-1-claudiu.beznea@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Claudiu Beznea There is no need to allocate a transfer structure when i2c_nxfers is zero. Return immediately instead of unnecessarily allocating memory. Signed-off-by: Claudiu Beznea --- Changes in v2: - updated patch title drivers/i3c/master/renesas-i3c.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/i3c/master/renesas-i3c.c b/drivers/i3c/master/renesas-= i3c.c index 860c9f2f17de..ed925b673b38 100644 --- a/drivers/i3c/master/renesas-i3c.c +++ b/drivers/i3c/master/renesas-i3c.c @@ -982,13 +982,13 @@ static int renesas_i3c_i2c_xfers(struct i2c_dev_desc = *dev, u8 start_bit =3D CNDCTL_STCND; int i; =20 + if (!i2c_nxfers) + return 0; + struct renesas_i3c_xfer *xfer __free(kfree) =3D renesas_i3c_alloc_xfer(i3= c, 1); if (!xfer) return -ENOMEM; =20 - if (!i2c_nxfers) - return 0; - renesas_i3c_bus_enable(m, false); =20 init_completion(&xfer->comp); --=20 2.43.0 From nobody Mon Jun 8 04:25:46 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5A6123E7BC2 for ; Tue, 2 Jun 2026 13:29:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780406951; cv=none; b=PZAhGPkaKffhIhZcSyNkjQHTc4WqHdy/Wb6bT/zqgWbAeRr9ZxLoJaxm7uODKhq5Z8HfqVSpUpmIdFMPWtnENhuxzXJmmHeB7bJyiNFmo/EQOkTkywO69ayXTpXfQ8GxljOYMQtbUTFshh031sxnDE6wbezi/GQRTO8DTn5Zy50= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780406951; c=relaxed/simple; bh=tgVVlSyYOTJDiVPVZXcyTXLuNA09VfTmvTcNL9J3tJk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WwlrmouYrhc5XZf6fa2B2SgoKzCrwOTE6GbufIJYsE8ZU6x5wq/JdJrpgWUlurrpFO1heZgzgEMNTU0FAda0duHvCBvJwSE+KwJlg7O6BnA8ectheY+PWeqfLsAa5Cg/ZcBLk0O2cAK/nRD6TyHQy5cd+vTK7J4wtk+1vEu0S64= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hZNwz7sy; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="hZNwz7sy" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E7D961F00898; Tue, 2 Jun 2026 13:29:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1780406950; bh=kB0mTS4bPznyvBQvcWqNat3upb4ComylAy+AiC3M3g8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=hZNwz7syLcUbmrM/ow3xjYOeuPvPmns+4mYEF4P9cQF4Z9TlaSqtMSeFzTyEM/H7f +pTrJRNfVeu7Op0Y7NqLn8TghYfLW+gAhy26IkEWcW/l1RS++paQIc8medr431uOkP FXZ995RW3mnEEBwwvUVKygZuP7zrLFJE5kHFXJx0LZHwR3q9xooM/XGpcfhgxiYxVl EzAUkLFpcm0RFFrwdNHuZ6D7HgSi4Q7R2+xtsCxnsSKUNOVSmP8a2jvleiEdfgH3KC HZ7cocmsPGQdNGf/EzVtUyEXyQdONmFTiolkLKC2y0OKGntx7Hgznq2mc5pBMcCDDQ eE3FBm5pLTBUg== From: Claudiu Beznea To: wsa+renesas@sang-engineering.com, tommaso.merciai.xr@bp.renesas.com, alexandre.belloni@bootlin.com, Frank.Li@nxp.com, p.zabel@pengutronix.de Cc: claudiu.beznea@kernel.org, claudiu.beznea@tuxon.dev, linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, Claudiu Beznea Subject: [PATCH v2 11/17] i3c: renesas: Follow a unified pattern for transfer and command initialization Date: Tue, 2 Jun 2026 16:28:18 +0300 Message-ID: <20260602132824.3541151-12-claudiu.beznea@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260602132824.3541151-1-claudiu.beznea@kernel.org> References: <20260602132824.3541151-1-claudiu.beznea@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Claudiu Beznea Follow a unified pattern for transfer and command initialization across the driver. This keeps the code cleaner and easier to follow. Also, in some cases the I3C device was enabled before the transfer data structure was even allocated. Reviewed-by: Frank Li Signed-off-by: Claudiu Beznea --- Changes in v2: - collected tags drivers/i3c/master/renesas-i3c.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/i3c/master/renesas-i3c.c b/drivers/i3c/master/renesas-= i3c.c index ed925b673b38..601d879fce9d 100644 --- a/drivers/i3c/master/renesas-i3c.c +++ b/drivers/i3c/master/renesas-i3c.c @@ -656,6 +656,10 @@ static int renesas_i3c_daa(struct i3c_master_controlle= r *m) if (!xfer) return -ENOMEM; =20 + init_completion(&xfer->comp); + cmd =3D xfer->cmds; + cmd->rx_count =3D 0; + /* Enable I3C bus. */ renesas_i3c_bus_enable(m, true); =20 @@ -696,10 +700,6 @@ static int renesas_i3c_daa(struct i3c_master_controlle= r *m) renesas_writel(i3c->regs, DATBAS(pos), datbas_dvdyad_with_parity(ret)); } =20 - init_completion(&xfer->comp); - cmd =3D xfer->cmds; - cmd->rx_count =3D 0; - if (i3c->resuming) { /* Nothing to do if all slots are ocupied by I2C devices. */ if (last_i2c_pos =3D=3D i3c->maxdevs - 1) @@ -804,13 +804,13 @@ static int renesas_i3c_send_ccc_cmd(struct i3c_master= _controller *m, if (!xfer) return -ENOMEM; =20 - renesas_i3c_bus_enable(m, true); - init_completion(&xfer->comp); cmd =3D xfer->cmds; cmd->rnw =3D ccc->rnw; cmd->cmd0 =3D 0; =20 + renesas_i3c_bus_enable(m, true); + /* Calculate the command descriptor. */ switch (ccc->id) { case I3C_CCC_SETDASA: @@ -860,15 +860,15 @@ static int renesas_i3c_i3c_xfers(struct i3c_dev_desc = *dev, struct i3c_xfer *i3c_ struct renesas_i3c_i2c_dev_data *data =3D i3c_dev_get_master_data(dev); int i; =20 - /* Enable I3C bus. */ - renesas_i3c_bus_enable(m, true); - struct renesas_i3c_xfer *xfer __free(kfree) =3D renesas_i3c_alloc_xfer(i3= c, 1); if (!xfer) return -ENOMEM; =20 init_completion(&xfer->comp); =20 + /* Enable I3C bus. */ + renesas_i3c_bus_enable(m, true); + for (i =3D 0; i < i3c_nxfers; i++) { struct renesas_i3c_cmd *cmd =3D xfer->cmds; =20 @@ -989,12 +989,12 @@ static int renesas_i3c_i2c_xfers(struct i2c_dev_desc = *dev, if (!xfer) return -ENOMEM; =20 - renesas_i3c_bus_enable(m, false); - init_completion(&xfer->comp); xfer->is_i2c_xfer =3D true; cmd =3D xfer->cmds; =20 + renesas_i3c_bus_enable(m, false); + if (!(renesas_readl(i3c->regs, BCST) & BCST_BFREF)) { cmd->err =3D -EBUSY; return cmd->err; --=20 2.43.0 From nobody Mon Jun 8 04:25:46 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 597943EAC89 for ; Tue, 2 Jun 2026 13:29:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780406954; cv=none; b=KfVgsYHxDLm2YJPtsvyI/TVQS5coK4SnS2z++orXLSurraJRj16aYtStFyLzDVYWXIudObIXFhUQhTNgBnTw+j0FcwXlfGtQ6d7MGXvcEU5T4XKj4EHODw+gPk9aYJCUsWdl1UOMqegHQOPtGVkr3B7zbzpPR02nhQnL77oV09o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780406954; c=relaxed/simple; bh=wMULQEqTTWQhaofR8oIc4NIvup3qw8WSWPfriG3yaT4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nAgtlXXsJhUVmR8KhnT6yQ4KEXboOflYeizkwG7DSzpRScvzxHwBvtzWavu6vDxqgUUTxOlfA8HwE23mV/bJ/9Lv/vZcaE7lxVqFwja8pUyg3c5cnLfyvZzHSUnEfVmeLwPVXcwpXRtbCSb1gY7dDPpMud14/9UtHTgaYsm1sVg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eThbhNp0; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="eThbhNp0" Received: by smtp.kernel.org (Postfix) with ESMTPSA id ACA4A1F00893; Tue, 2 Jun 2026 13:29:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1780406953; bh=jTdlX9zP0WzRiGWe22aG2+zirmD8Ab+DdfbEq8C2jSo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=eThbhNp0BZC+dZv28FvrYbiJPpGZ/zO6vAvWQStct9QlCzcI/ej1msEvZTwk1KrvF nnXNp9VIeDoYmG8H+Rau2XhINu//jieOqwQcff6uRsoYm/xItDPIsOhf9gCGZEY2e0 6dUeAYj01nR8Mvdk6EpxLcjAn2NoTxr40JUOpvGCWUksWrD7mvfh70O2gAVhGtLvsg fIYgN0wZY2RCVDHHbQYGCnsVJM7tnc8pJA+6yJRUj2onzon9IG9uWr8IK4/PG/DNhC r1Lm93RrSaFD1eCu6322ckvRKgX73fSuXAfM+b8UV5IoHLwJYs6IQiCyWyqygFXqPN 7UAMc/hoBWPZg== From: Claudiu Beznea To: wsa+renesas@sang-engineering.com, tommaso.merciai.xr@bp.renesas.com, alexandre.belloni@bootlin.com, Frank.Li@nxp.com, p.zabel@pengutronix.de Cc: claudiu.beznea@kernel.org, claudiu.beznea@tuxon.dev, linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, Claudiu Beznea Subject: [PATCH v2 12/17] i3c: renesas: Drop the explicit memset() call Date: Tue, 2 Jun 2026 16:28:19 +0300 Message-ID: <20260602132824.3541151-13-claudiu.beznea@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260602132824.3541151-1-claudiu.beznea@kernel.org> References: <20260602132824.3541151-1-claudiu.beznea@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Claudiu Beznea Drop the explicit memset() call on struct i3c_device_info object, as it is already initialized at declaration through compiler initialization. Reviewed-by: Frank Li Signed-off-by: Claudiu Beznea --- Changes in v2: - collected tags drivers/i3c/master/renesas-i3c.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/i3c/master/renesas-i3c.c b/drivers/i3c/master/renesas-= i3c.c index 601d879fce9d..6725b7fe5392 100644 --- a/drivers/i3c/master/renesas-i3c.c +++ b/drivers/i3c/master/renesas-i3c.c @@ -631,7 +631,6 @@ static int renesas_i3c_bus_init(struct i3c_master_contr= oller *m) i3c->dyn_addr =3D ret; renesas_writel(i3c->regs, MSDVAD, MSDVAD_MDYAD(ret) | MSDVAD_MDYADV); =20 - memset(&info, 0, sizeof(info)); info.dyn_addr =3D ret; return i3c_master_set_info(&i3c->base, &info); } --=20 2.43.0 From nobody Mon Jun 8 04:25:46 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BD2153EB810 for ; Tue, 2 Jun 2026 13:29:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780406956; cv=none; b=AqeRRW8WLvmmVfz9yf5S66Ok+Tfd+QSakyQwtrsUEN7M6ijjJwCKVyRtbVUW/aewCLj79uEOzkrfx/Xn6WJR72sqdyR7DayIPiCbrfsT4Ut82otPTqVJ+YyL6wEaHqVmOji+zk/nd67ifJNpA2gmnfyqA4FQb5jUy7hBqktsGLE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780406956; c=relaxed/simple; bh=Z6hPJ9X3KC/kpsiAsKJjOMy2UkVUH8G4KAynEwxrbPw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pRJpF5BGbWLmidxdpQF2nB3nHZ+ppVZWFqdqr3Oj1l/LzSxvNheBJay/zVuSAwxVAy/pooLuH/GhgR8/LcyroqiyuDmCVzvUCY/8NoBO3pzPwEGD1xVKQLKIIQvSRk/nkjG5wRUvKmW16nrv2xTSG09vJ9u7s5nFtZ1RORZxh0Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=g0Rqm/cy; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="g0Rqm/cy" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 655DD1F00898; Tue, 2 Jun 2026 13:29:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1780406955; bh=6yM2kI910zG9k3FdoXLV2c3FsWERxQ03lj2XknHEPAw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=g0Rqm/cyw0BXMqEg/vd10++W5AYij+XmQztJ/ex1B0Qo+N8wY8RiPXHOYMAsDURaA rwDm1P4eYnNKfO3Ce2AUXnKYIrQdSYXqGIGN7AhoRfTVBCZA18evzbu9EG2In8v4Oh K+02w6KlwB0rw6vCjNnxTYMu0SKwH+OYOqDx6okChb7oXTw6qMk/zGYWtkxBdLhKvW f8zqXSOigjABSfSXF4AA77tL/UNzcLFJsuqEuSE1hA1YtqhKSSpslW9sAHA821dKiw m8wsDHJhZiy2pPyJ2DdqsG+f0mY04mUDNHFQKZPlrncuFE7+Pmw2eMfxzJoILiWptU tPF0Hz3UXROSQ== From: Claudiu Beznea To: wsa+renesas@sang-engineering.com, tommaso.merciai.xr@bp.renesas.com, alexandre.belloni@bootlin.com, Frank.Li@nxp.com, p.zabel@pengutronix.de Cc: claudiu.beznea@kernel.org, claudiu.beznea@tuxon.dev, linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, Claudiu Beznea Subject: [PATCH v2 13/17] i3c: renesas: Update HW registers after SW computations are done Date: Tue, 2 Jun 2026 16:28:20 +0300 Message-ID: <20260602132824.3541151-14-claudiu.beznea@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260602132824.3541151-1-claudiu.beznea@kernel.org> References: <20260602132824.3541151-1-claudiu.beznea@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Claudiu Beznea renesas_i3c_bus_init() performs a number of computations and software cache updates, interleaving them with hardware register writes. While this works today, it makes it harder to minimize the time the controller must remain powered when runtime PM is introduced. Perform all software computations and cache updates first, then update the hardware registers. This prepares for future runtime PM support. Reviewed-by: Frank Li Signed-off-by: Claudiu Beznea --- Changes in v2: - collected tags drivers/i3c/master/renesas-i3c.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/i3c/master/renesas-i3c.c b/drivers/i3c/master/renesas-= i3c.c index 6725b7fe5392..9ffb4a9d1e46 100644 --- a/drivers/i3c/master/renesas-i3c.c +++ b/drivers/i3c/master/renesas-i3c.c @@ -557,10 +557,6 @@ static int renesas_i3c_bus_init(struct i3c_master_cont= roller *m) if (!i3c->rate) return -EINVAL; =20 - ret =3D renesas_i3c_reset(i3c); - if (ret) - return ret; - i2c_total_ticks =3D DIV_ROUND_UP(i3c->rate, bus->scl_rate.i2c); i3c_total_ticks =3D DIV_ROUND_UP(i3c->rate, bus->scl_rate.i3c); =20 @@ -611,27 +607,31 @@ static int renesas_i3c_bus_init(struct i3c_master_con= troller *m) STDBR_SBRHO(double_SBR, od_high_ticks) | STDBR_SBRLP(pp_low_ticks) | STDBR_SBRHP(pp_high_ticks); - renesas_writel(i3c->regs, STDBR, i3c->i3c_STDBR); =20 /* Extended Bit Rate setting */ i3c->extbr =3D EXTBR_EBRLO(od_low_ticks) | EXTBR_EBRHO(od_high_ticks) | EXTBR_EBRLP(pp_low_ticks) | EXTBR_EBRHP(pp_high_ticks); - renesas_writel(i3c->regs, EXTBR, i3c->extbr); - - renesas_writel(i3c->regs, REFCKCTL, REFCKCTL_IREFCKS(cks)); - i3c->refclk_div =3D cks; - - /* I3C hw init*/ - renesas_i3c_hw_init(i3c); =20 ret =3D i3c_master_get_free_addr(m, 0); if (ret < 0) return ret; =20 + info.dyn_addr =3D ret; i3c->dyn_addr =3D ret; - renesas_writel(i3c->regs, MSDVAD, MSDVAD_MDYAD(ret) | MSDVAD_MDYADV); + i3c->refclk_div =3D cks; + + ret =3D renesas_i3c_reset(i3c); + if (ret) + return ret; + + renesas_writel(i3c->regs, STDBR, i3c->i3c_STDBR); + renesas_writel(i3c->regs, EXTBR, i3c->extbr); + renesas_writel(i3c->regs, REFCKCTL, REFCKCTL_IREFCKS(cks)); + renesas_writel(i3c->regs, MSDVAD, MSDVAD_MDYAD(i3c->dyn_addr) | MSDVAD_MD= YADV); + + /* I3C hw init*/ + renesas_i3c_hw_init(i3c); =20 - info.dyn_addr =3D ret; return i3c_master_set_info(&i3c->base, &info); } =20 --=20 2.43.0 From nobody Mon Jun 8 04:25:46 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AD3153EBF24 for ; Tue, 2 Jun 2026 13:29:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780406959; cv=none; b=oGF0cgDJ08Mz46qE6J5q8SAtKPIo3nlsBieyvHxSOsuO6QKUNxp0nTKqfkis/IH9tyXGP2mzaQ4pDpMHjugfmGNGHxtEUB4lguJziuCpah9Axx5NZtsjCLk5X/fzx58FF3GbC0IynYiyjnk+PfJ09LZ5OJPI88R2hna1tOKkMFU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780406959; c=relaxed/simple; bh=R/6hwY9MG8GELg3JhPYfP2YJR7nQSyKwXfxYIinxivA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XpysKAN5VuqiT/xPu2OIs7vWVt1mxNDJAGIziU8BTz2OhlBAnCPwcLmlkTDLE8NfpUb/bSjfVxNV32XVuFFFooC9wykBUPlvh0+poncOZzoCqlo95qfu73tY3OlRN8YKdO8uLZwZhmplPX9zOp0cQnRPhs+YFd12GMHSFO9HoU4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=A8SJ/1Um; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="A8SJ/1Um" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 21C581F00899; Tue, 2 Jun 2026 13:29:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1780406958; bh=VGh00h5m8TDNfIxYGHg0jww3vZhwGYH7HN9uRv86q1U=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=A8SJ/1Um/R6GiexQ8hhR3CFOemBpBnFo7W4IFoPUrE6McqBbmb7rotgNJ+X2Eexyz 79MqBdLsHsB+fYfPzN30S0QsCBkSxjOsVpO2a85ju7MnROEKGg1tb6zcVDv+CABRmv ygbVMziFZyEHKhhBzyJ3wf6F0JfXQU5J51YBbTAXPcHgua8m4w67aUYScX61NF1RAr SUx5K0968O5bnszAi8AtrZyn9bhCk9vGD9DYlqs9bkK8K1nDG4jA+S2Iy3dIzRIXwS qnazDadjnu0/pP+w0iW3qYD552vP1JT2/Yw468QpX0J5zOykDlgwpxLgldZRUWEXBk 4JyJgyyKg9RQA== From: Claudiu Beznea To: wsa+renesas@sang-engineering.com, tommaso.merciai.xr@bp.renesas.com, alexandre.belloni@bootlin.com, Frank.Li@nxp.com, p.zabel@pengutronix.de Cc: claudiu.beznea@kernel.org, claudiu.beznea@tuxon.dev, linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, Claudiu Beznea Subject: [PATCH v2 14/17] i3c: renesas: Organize structures to avoid unnecessary padding Date: Tue, 2 Jun 2026 16:28:21 +0300 Message-ID: <20260602132824.3541151-15-claudiu.beznea@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260602132824.3541151-1-claudiu.beznea@kernel.org> References: <20260602132824.3541151-1-claudiu.beznea@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Claudiu Beznea Reorder structure members to reduce padding and improve memory layout. Reviewed-by: Frank Li Signed-off-by: Claudiu Beznea --- Changes in v2: - collected tags drivers/i3c/master/renesas-i3c.c | 34 ++++++++++++++++---------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/i3c/master/renesas-i3c.c b/drivers/i3c/master/renesas-= i3c.c index 9ffb4a9d1e46..e1aa445de933 100644 --- a/drivers/i3c/master/renesas-i3c.c +++ b/drivers/i3c/master/renesas-i3c.c @@ -221,19 +221,19 @@ enum renesas_i3c_event { }; =20 struct renesas_i3c_cmd { + const void *tx_buf; + void *rx_buf; + /* i2c xfer */ + u8 *i2c_buf; + const struct i2c_msg *msg; + int i2c_bytes_left; + int i2c_is_last; u32 cmd0; u32 len; - const void *tx_buf; u32 tx_count; - void *rx_buf; u32 rx_count; u32 err; u8 rnw; - /* i2c xfer */ - int i2c_bytes_left; - int i2c_is_last; - u8 *i2c_buf; - const struct i2c_msg *msg; }; =20 struct renesas_i3c_xfer { @@ -258,23 +258,23 @@ struct renesas_i3c_addr { }; =20 struct renesas_i3c { + void __iomem *regs; + struct clk_bulk_data *clks; + struct reset_control *presetn; + struct reset_control *tresetn; + u32 *DATBASn; + struct renesas_i3c_xferqueue xferqueue; struct i3c_master_controller base; + struct renesas_i3c_addr addrs[RENESAS_I3C_MAX_DEVS]; + unsigned long rate; enum i3c_internal_state internal_state; - u16 maxdevs; + bool resuming; u32 free_pos; u32 dyn_addr; u32 i2c_STDBR; u32 i3c_STDBR; u32 extbr; - unsigned long rate; - struct renesas_i3c_addr addrs[RENESAS_I3C_MAX_DEVS]; - struct renesas_i3c_xferqueue xferqueue; - void __iomem *regs; - u32 *DATBASn; - struct clk_bulk_data *clks; - struct reset_control *presetn; - struct reset_control *tresetn; - bool resuming; + u16 maxdevs; u8 num_clks; u8 refclk_div; }; --=20 2.43.0 From nobody Mon Jun 8 04:25:46 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 793723E8338 for ; Tue, 2 Jun 2026 13:29:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780406962; cv=none; b=UONrAvnH15wS6k/eHtPevntnksI0ZzfvevRpf8qSvivAngnFs7kgOhFkz6lUT1A6s9m0YpHXm1WKr7+tqdSowjgSWL083kvyKsRPdStpBfXogxQwkan6aYPGTp+Clt+PPC8G+O7GkIm121+z4bCtzeMKhPCqTwVaNoizmZ9PiyQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780406962; c=relaxed/simple; bh=hu4BZPrEuqJykp6hGkDm9m+FqSHlkyB/dwViU/niiEI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FXMFNJ5FFq6x1B+pZ+NmjlrzGSmPgQxAwWlzeLEWZd/dBpxmVIJlUPx2Fzw4DvfuvNUr55vSOrtI76kZmiY16PUJMpv0ezqtuTbCISUrtZCCqeU6B//6qdixNkHKLZNeYhZviULj85wy2fpQ867qRZW+IlgzAK3gNiH9juLssCc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hFPYWc4L; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="hFPYWc4L" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E6D7B1F00893; Tue, 2 Jun 2026 13:29:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1780406961; bh=Yqb9F/SWFWyaQnxe0OzvdBZA32dRT3tLYVEuPNodHio=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=hFPYWc4LeJwPLS2JTnRAs/UngqDwkxitPxQVJFnpsyNxSKeOQeBI/OUM38moSqGue 3Azlcivj8fPmje+GkhMHLpHoxV2JqjgszdQbjknTNEVTjjUzR3cclQ4tL/1GrC8/0J K7/hYyJVvJHMe1+lPOc68QxDiobptbGy+BY/59I3LeCfooc8H+dFuCTKwdGxm1fFxg 1zprK0Pw8MJStYV5DBbFwgVy61IB9jdDCAWu4Zj7A3X5WPIxkvt17KVv80akkaPAMK 8h5feRHOSXvVZurWBsNrHxeROZkYkxehgulIMrSqrl7Bgsqm250S7/rTABvvOMFu6t DmvrQy0l35muA== From: Claudiu Beznea To: wsa+renesas@sang-engineering.com, tommaso.merciai.xr@bp.renesas.com, alexandre.belloni@bootlin.com, Frank.Li@nxp.com, p.zabel@pengutronix.de Cc: claudiu.beznea@kernel.org, claudiu.beznea@tuxon.dev, linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, Claudiu Beznea Subject: [PATCH v2 15/17] i3c: renesas: Use the "dev_name:irq_name" format for the interrupt name Date: Tue, 2 Jun 2026 16:28:22 +0300 Message-ID: <20260602132824.3541151-16-claudiu.beznea@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260602132824.3541151-1-claudiu.beznea@kernel.org> References: <20260602132824.3541151-1-claudiu.beznea@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Claudiu Beznea Use the "dev_name:irq_name" format for the interrupt names. This makes it easier to identify interrupts in systems where multiple devices may request interrupts with the same name. Reviewed-by: Frank Li Signed-off-by: Claudiu Beznea --- Changes in v2: - collected tags drivers/i3c/master/renesas-i3c.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/i3c/master/renesas-i3c.c b/drivers/i3c/master/renesas-= i3c.c index e1aa445de933..1ccd1c4ea27c 100644 --- a/drivers/i3c/master/renesas-i3c.c +++ b/drivers/i3c/master/renesas-i3c.c @@ -1450,12 +1450,19 @@ static int renesas_i3c_probe(struct platform_device= *pdev) return ret; =20 for (i =3D 0; i < ARRAY_SIZE(renesas_i3c_irqs); i++) { + const char *irqname; + ret =3D platform_get_irq_byname(pdev, renesas_i3c_irqs[i].name); if (ret < 0) return ret; =20 + irqname =3D devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s:%s", dev_name(&pd= ev->dev), + renesas_i3c_irqs[i].desc); + if (!irqname) + return -ENOMEM; + ret =3D devm_request_irq(&pdev->dev, ret, renesas_i3c_irqs[i].isr, - 0, renesas_i3c_irqs[i].desc, i3c); + 0, irqname, i3c); if (ret) return ret; } --=20 2.43.0 From nobody Mon Jun 8 04:25:46 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 640E73ED3A9 for ; Tue, 2 Jun 2026 13:29:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780406965; cv=none; b=LUzrPHKxkicACSBI1q5LkfavP/zqtcUXZvDyuN9rU0u3gyDtrQO5dB1576Ve64ggbAsXAxItuijI1m8L1Z2X8d4/q2KmpHzeZW/DIoaWnXrHzIprYKS8FwjsMtiigTtfU4n8J3EeSwLfqnKXd1CgClp7dj1xlzlhu+A3uj+95Dw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780406965; c=relaxed/simple; bh=MtYSMWOdcN5N0QwjRul6aJyqFSe6eblfLGQDlSR6pus=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Vd14z3kYG9JMPYXzwSUIro6D1r0eADFWS/5mx9PTpBOAcwmtYMogZ2Sa1yz9phW3yBxR68cr4yGbx3Xbg92LzxA8e/MbHOI/4Whq/z14BebwDr/W3oscOGSa56mK35a0/zUepNrArjpb/vpNWsJep3Tn6+w2tJMukVf500KHTME= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lV6zGYbn; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lV6zGYbn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D11441F00898; Tue, 2 Jun 2026 13:29:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1780406964; bh=fZeedrLja92Z9bJCdVwk9qz/J7YvmgIy9rqBGdrsA7s=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=lV6zGYbnizZzhYeohQ7Oz/RiL3Ypwel0r9t64N24yaHkqw8TolUQzN4AFDW3ncy7V CQyBDC9SbFkIMuJ8Zle5kM6EmqMc64fawG8zVoY7gUYAvoW4Xuy0bLBUY/B9wnsv5t LVgsUuP/i9SWmZweFcnWU5ldZQRJwzUSUfRszqj5WCnQ05l3Z6yE559M2SgZ7wq+oi QNH8t6GJyFtjN3wBgRuwlBJLoO8Ph73H4F9Lf1zLRvH9m3ajHCwSZQ0xP0rYp+wzDy GLLVfqsfdQqU7fsNMv3t1zLNUxvV4NtMLRPM/55W2/SqDLQIesmHJvZt3AmWMYbNIV 9Gu32pExmyZPQ== From: Claudiu Beznea To: wsa+renesas@sang-engineering.com, tommaso.merciai.xr@bp.renesas.com, alexandre.belloni@bootlin.com, Frank.Li@nxp.com, p.zabel@pengutronix.de Cc: claudiu.beznea@kernel.org, claudiu.beznea@tuxon.dev, linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, Claudiu Beznea Subject: [PATCH v2 16/17] i3c: renesas: Drop unnecessary tab Date: Tue, 2 Jun 2026 16:28:23 +0300 Message-ID: <20260602132824.3541151-17-claudiu.beznea@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260602132824.3541151-1-claudiu.beznea@kernel.org> References: <20260602132824.3541151-1-claudiu.beznea@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Claudiu Beznea Remove an unnecessary tab to make the code cleaner. Reviewed-by: Frank Li Signed-off-by: Claudiu Beznea --- Changes in v2: - collected tags drivers/i3c/master/renesas-i3c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/i3c/master/renesas-i3c.c b/drivers/i3c/master/renesas-= i3c.c index 1ccd1c4ea27c..2a9bb035b8a2 100644 --- a/drivers/i3c/master/renesas-i3c.c +++ b/drivers/i3c/master/renesas-i3c.c @@ -109,7 +109,7 @@ #define NCMDQP_DATA_LENGTH(x) FIELD_PREP(GENMASK(31, 16), x) =20 #define NRSPQP 0x154 /* Normal Respone Queue */ -#define NRSPQP_NO_ERROR 0 +#define NRSPQP_NO_ERROR 0 #define NRSPQP_ERROR_CRC 1 #define NRSPQP_ERROR_PARITY 2 #define NRSPQP_ERROR_FRAME 3 --=20 2.43.0 From nobody Mon Jun 8 04:25:46 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E20AD3EDAD1 for ; Tue, 2 Jun 2026 13:29:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780406968; cv=none; b=Zr8X0EhBd4EKLXoA2CQ0zErVYpxfCnMWC6yTSqyJq2ghQMs7NKNJ6rTBu5ntlEu7GXkO5AdDSQWUMrW4Hxrfbq5WoBXS1ON8VvujPiCMXCnDu3RO7j7NyhD3TwSMJEZ7oWqLuJkEeTqJVFX2MMlxE8BCrOR5Yf3oTFBJVg3K4v4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780406968; c=relaxed/simple; bh=NsLKBCaW7hy5ZADtyI0FgyRZbgNcKaZVZyx7g591+po=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tiuSuKwTEFraFgOnhJG+PLNkHc7g2kjMA0qJFduGyM8nTrfFs88TYliDsA+Qfc9fydfOyIN3RlF0We1bv5FxSYNR4n0CsKSB3xH02VBJWm0jqhH4p6Cu2VVNhqv4Lbq0LQPt56SPKk8TENQjhGQxCrfpeZ7Hle9Ov1fyA//Bj34= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eWXEC6na; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="eWXEC6na" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8A4F61F00899; Tue, 2 Jun 2026 13:29:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1780406966; bh=OEhgPr0BUEi8Izexog/tRcESc55PyU3e7Rppt228wEM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=eWXEC6nayUj4WlRG0DkWWXpvXmeuFb2pMRtfHZHM6TZfTw8okPt2e4s+n4snj+AfK t23YM2XsAABG+EbyGg7Zlozhl/q0MJCeUDqDrEDm87MDMqmvoMo9RmSKvKlU6/2sOq wK8YM7+mrJqPIwUdxSG0P8rqo2dIfTihkSl5xOoe/SE/Za/2Hq34bci1m7Bqqp0YMZ OeHgq6wj26b2e2XC6U+NqaUcUMv5MQgnefd5lOkgVxD4sIPo28J+P7iCKbjKPPqNy1 CmJoSl0Yq9jtgvL0nV93JVRR0LxmJxM3Gsbywl4AYJNZHK6WLhJPGplGuwVsxtyM2c 04YgrId9mARqg== From: Claudiu Beznea To: wsa+renesas@sang-engineering.com, tommaso.merciai.xr@bp.renesas.com, alexandre.belloni@bootlin.com, Frank.Li@nxp.com, p.zabel@pengutronix.de Cc: claudiu.beznea@kernel.org, claudiu.beznea@tuxon.dev, linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, Claudiu Beznea Subject: [PATCH v2 17/17] i3c: renesas: Add runtime PM support Date: Tue, 2 Jun 2026 16:28:24 +0300 Message-ID: <20260602132824.3541151-18-claudiu.beznea@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260602132824.3541151-1-claudiu.beznea@kernel.org> References: <20260602132824.3541151-1-claudiu.beznea@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Claudiu Beznea On the SoCs where the Renesas I3C driver is enabled (RZ/G3S and RZ/G3E), the clocks of the IP are managed through a clock PM domain. To keep the I3C code simpler, the explicit clock handling was dropped along with the addition of runtime PM support, in favor of the runtime PM APIs. Only the code for getting tclk was preserved, as it is necessary to compute the I3C clock rate. All the APIs provided to the I3C subsystem through struct i3c_master_controller_ops are guarded with runtime PM APIs to enable/disable the controller at runtime. As the Renesas I3C driver implements an asynchronous transmit model by preparing a transfer and waiting for its completion through the ISR, renesas_i3c_abort_xfer() was added to disable interrupts and clear any pending IRQ status bits when there is no completion in the defined timeout. Along with this, renesas_i3c_wait_xfer() return type was changed to unsigned long. Add runtime PM support for the Renesas I3C driver. Signed-off-by: Claudiu Beznea --- Changes in v2: - dropped the runtime suspend/resume functions as for now, there will be no pinctrl sleep state described in DT - do not synchronize the IRQs in renesas_i3c_abort_xfer() as some handlers may re-enable interrupts; instead just disable the interrupts and clean any status bits that the IRQ handlers are touching; with this the struct renesas_i3c::{irqs, num_irqs} and the associated code was removed - dropped the renesas_i3c_dont_use_autosuspend() along with the devm_add_action_or_reset() call to set it since the same operation is done by the devres cleanup helper of devm_pm_runtime_enable() - adjusted the renesas_i3c_suspend() with RPM calls to save the DATBAS registers - use pm_runtime_resume_and_get() in renesas_i3c_resume() to avoid mixing gotos with cleanup helpers - adjusted the patch description to reflect these changes drivers/i3c/master/renesas-i3c.c | 158 +++++++++++++++++++++++++------ 1 file changed, 130 insertions(+), 28 deletions(-) diff --git a/drivers/i3c/master/renesas-i3c.c b/drivers/i3c/master/renesas-= i3c.c index 2a9bb035b8a2..6684a0e75bb9 100644 --- a/drivers/i3c/master/renesas-i3c.c +++ b/drivers/i3c/master/renesas-i3c.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include "../internals.h" @@ -199,8 +200,6 @@ #define RENESAS_I3C_MAX_DEVS 8 #define I2C_INIT_MSG -1 =20 -#define RENESAS_I3C_TCLK_IDX 1 - enum i3c_internal_state { I3C_INTERNAL_STATE_DISABLED, I3C_INTERNAL_STATE_CONTROLLER_IDLE, @@ -259,9 +258,10 @@ struct renesas_i3c_addr { =20 struct renesas_i3c { void __iomem *regs; - struct clk_bulk_data *clks; + struct clk *tclk; struct reset_control *presetn; struct reset_control *tresetn; + struct device *dev; u32 *DATBASn; struct renesas_i3c_xferqueue xferqueue; struct i3c_master_controller base; @@ -275,7 +275,6 @@ struct renesas_i3c { u32 i3c_STDBR; u32 extbr; u16 maxdevs; - u8 num_clks; u8 refclk_div; }; =20 @@ -440,7 +439,24 @@ static void renesas_i3c_enqueue_xfer(struct renesas_i3= c *i3c, struct renesas_i3c } } =20 -static void renesas_i3c_wait_xfer(struct renesas_i3c *i3c, struct renesas_= i3c_xfer *xfer) +static void renesas_i3c_abort_xfer(struct renesas_i3c *i3c) +{ + guard(spinlock_irqsave)(&i3c->xferqueue.lock); + + /* Disable all the interrupts */ + renesas_writel(i3c->regs, BIE, 0); + renesas_writel(i3c->regs, NTIE, 0); + + /* Clear normal transfer status flags. */ + renesas_clear_bit(i3c->regs, NTST, NTST_TDBEF0 | NTST_RDBFF0 | NTST_RSPQF= F | + NTST_TEF | NTST_TABTF); + /* Clear bus status flags. */ + renesas_clear_bit(i3c->regs, BST, BST_NACKDF | BST_TENDF | BST_SPCNDDF); + /* Clear error flags. */ + renesas_clear_bit(i3c->regs, BCTL, BCTL_ABT); +} + +static unsigned long renesas_i3c_wait_xfer(struct renesas_i3c *i3c, struct= renesas_i3c_xfer *xfer) { unsigned long time_left; =20 @@ -449,6 +465,8 @@ static void renesas_i3c_wait_xfer(struct renesas_i3c *i= 3c, struct renesas_i3c_xf time_left =3D wait_for_completion_timeout(&xfer->comp, msecs_to_jiffies(1= 000)); if (!time_left) renesas_i3c_dequeue_xfer(i3c, xfer); + + return time_left; } =20 static void renesas_i3c_set_prts(struct renesas_i3c *i3c, u32 val) @@ -482,6 +500,12 @@ static void renesas_i3c_bus_enable(struct i3c_master_c= ontroller *m, bool i3c_mod static int renesas_i3c_reset(struct renesas_i3c *i3c) { u32 val; + int ret; + + PM_RUNTIME_ACQUIRE_IF_ENABLED_AUTOSUSPEND(i3c->dev, pm); + ret =3D PM_RUNTIME_ACQUIRE_ERR(&pm); + if (ret) + return ret; =20 renesas_writel(i3c->regs, BCTL, 0); renesas_set_bit(i3c->regs, RSTCTL, RSTCTL_RI3CRST); @@ -553,7 +577,7 @@ static int renesas_i3c_bus_init(struct i3c_master_contr= oller *m) int od_high_ticks, od_low_ticks, i2c_total_ticks; int ret; =20 - i3c->rate =3D clk_get_rate(i3c->clks[RENESAS_I3C_TCLK_IDX].clk); + i3c->rate =3D clk_get_rate(i3c->tclk); if (!i3c->rate) return -EINVAL; =20 @@ -624,6 +648,11 @@ static int renesas_i3c_bus_init(struct i3c_master_cont= roller *m) if (ret) return ret; =20 + PM_RUNTIME_ACQUIRE_IF_ENABLED_AUTOSUSPEND(i3c->dev, pm); + ret =3D PM_RUNTIME_ACQUIRE_ERR(&pm); + if (ret) + return ret; + renesas_writel(i3c->regs, STDBR, i3c->i3c_STDBR); renesas_writel(i3c->regs, EXTBR, i3c->extbr); renesas_writel(i3c->regs, REFCKCTL, REFCKCTL_IREFCKS(cks)); @@ -646,6 +675,7 @@ static int renesas_i3c_daa(struct i3c_master_controller= *m) { struct renesas_i3c *i3c =3D to_renesas_i3c(m); struct renesas_i3c_cmd *cmd; + unsigned long time_left; u8 last_addr =3D 0, pos; int last_i2c_pos =3D -1; u32 olddevs, newdevs; @@ -659,6 +689,11 @@ static int renesas_i3c_daa(struct i3c_master_controlle= r *m) cmd =3D xfer->cmds; cmd->rx_count =3D 0; =20 + PM_RUNTIME_ACQUIRE_IF_ENABLED_AUTOSUSPEND(i3c->dev, pm); + ret =3D PM_RUNTIME_ACQUIRE_ERR(&pm); + if (ret) + return ret; + /* Enable I3C bus. */ renesas_i3c_bus_enable(m, true); =20 @@ -724,7 +759,9 @@ static int renesas_i3c_daa(struct i3c_master_controller= *m) NCMDQP_CMD(I3C_CCC_ENTDAA) | NCMDQP_DEV_INDEX(ret) | NCMDQP_DEV_COUNT(i3c->maxdevs - ret) | NCMDQP_TOC; =20 - renesas_i3c_wait_xfer(i3c, xfer); + time_left =3D renesas_i3c_wait_xfer(i3c, xfer); + if (!time_left) + renesas_i3c_abort_xfer(i3c); =20 /* Skip attaching if there are failures on the xfer. */ if (xfer->ret) { @@ -791,6 +828,7 @@ static int renesas_i3c_send_ccc_cmd(struct i3c_master_c= ontroller *m, { struct renesas_i3c *i3c =3D to_renesas_i3c(m); struct renesas_i3c_cmd *cmd; + unsigned long time_left; int ret, pos =3D 0; =20 if (ccc->id & I3C_CCC_DIRECT) { @@ -808,6 +846,11 @@ static int renesas_i3c_send_ccc_cmd(struct i3c_master_= controller *m, cmd->rnw =3D ccc->rnw; cmd->cmd0 =3D 0; =20 + PM_RUNTIME_ACQUIRE_IF_ENABLED_AUTOSUSPEND(i3c->dev, pm); + ret =3D PM_RUNTIME_ACQUIRE_ERR(&pm); + if (ret) + return ret; + renesas_i3c_bus_enable(m, true); =20 /* Calculate the command descriptor. */ @@ -842,7 +885,9 @@ static int renesas_i3c_send_ccc_cmd(struct i3c_master_c= ontroller *m, } } =20 - renesas_i3c_wait_xfer(i3c, xfer); + time_left =3D renesas_i3c_wait_xfer(i3c, xfer); + if (!time_left) + renesas_i3c_abort_xfer(i3c); =20 ret =3D xfer->ret; if (ret) @@ -857,7 +902,9 @@ static int renesas_i3c_i3c_xfers(struct i3c_dev_desc *d= ev, struct i3c_xfer *i3c_ struct i3c_master_controller *m =3D i3c_dev_get_master(dev); struct renesas_i3c *i3c =3D to_renesas_i3c(m); struct renesas_i3c_i2c_dev_data *data =3D i3c_dev_get_master_data(dev); - int i; + unsigned long time_left; + bool abort_xfer =3D false; + int i, ret; =20 struct renesas_i3c_xfer *xfer __free(kfree) =3D renesas_i3c_alloc_xfer(i3= c, 1); if (!xfer) @@ -865,6 +912,11 @@ static int renesas_i3c_i3c_xfers(struct i3c_dev_desc *= dev, struct i3c_xfer *i3c_ =20 init_completion(&xfer->comp); =20 + PM_RUNTIME_ACQUIRE_IF_ENABLED_AUTOSUSPEND(i3c->dev, pm); + ret =3D PM_RUNTIME_ACQUIRE_ERR(&pm); + if (ret) + return ret; + /* Enable I3C bus. */ renesas_i3c_bus_enable(m, true); =20 @@ -896,9 +948,14 @@ static int renesas_i3c_i3c_xfers(struct i3c_dev_desc *= dev, struct i3c_xfer *i3c_ renesas_set_bit(i3c->regs, NTIE, NTIE_TDBEIE0); } =20 - renesas_i3c_wait_xfer(i3c, xfer); + time_left =3D renesas_i3c_wait_xfer(i3c, xfer); + if (!time_left) + abort_xfer =3D true; } =20 + if (abort_xfer) + renesas_i3c_abort_xfer(i3c); + return 0; } =20 @@ -907,12 +964,17 @@ static int renesas_i3c_attach_i3c_dev(struct i3c_dev_= desc *dev) struct i3c_master_controller *m =3D i3c_dev_get_master(dev); struct renesas_i3c *i3c =3D to_renesas_i3c(m); struct renesas_i3c_i2c_dev_data *data; - int pos; + int pos, ret; =20 pos =3D renesas_i3c_get_free_pos(i3c); if (pos < 0) return pos; =20 + PM_RUNTIME_ACQUIRE_IF_ENABLED_AUTOSUSPEND(i3c->dev, pm); + ret =3D PM_RUNTIME_ACQUIRE_ERR(&pm); + if (ret) + return ret; + data =3D kzalloc_obj(*data); if (!data) return -ENOMEM; @@ -934,7 +996,12 @@ static int renesas_i3c_reattach_i3c_dev(struct i3c_dev= _desc *dev, struct i3c_master_controller *m =3D i3c_dev_get_master(dev); struct renesas_i3c *i3c =3D to_renesas_i3c(m); struct renesas_i3c_i2c_dev_data *data =3D i3c_dev_get_master_data(dev); - int pos; + int pos, ret; + + PM_RUNTIME_ACQUIRE_IF_ENABLED_AUTOSUSPEND(i3c->dev, pm); + ret =3D PM_RUNTIME_ACQUIRE_ERR(&pm); + if (ret) + return ret; =20 pos =3D renesas_i3c_get_free_pos(i3c); =20 @@ -962,8 +1029,12 @@ static void renesas_i3c_detach_i3c_dev(struct i3c_dev= _desc *dev) struct renesas_i3c_i2c_dev_data *data =3D i3c_dev_get_master_data(dev); struct i3c_master_controller *m =3D i3c_dev_get_master(dev); struct renesas_i3c *i3c =3D to_renesas_i3c(m); + int ret; =20 - renesas_writel(i3c->regs, DATBAS(data->index), 0); + PM_RUNTIME_ACQUIRE_IF_ENABLED_AUTOSUSPEND(i3c->dev, pm); + ret =3D PM_RUNTIME_ACQUIRE_ERR(&pm); + if (!ret) + renesas_writel(i3c->regs, DATBAS(data->index), 0); =20 i3c_dev_set_master_data(dev, NULL); i3c->addrs[data->index].addr =3D 0; @@ -979,7 +1050,9 @@ static int renesas_i3c_i2c_xfers(struct i2c_dev_desc *= dev, struct renesas_i3c *i3c =3D to_renesas_i3c(m); struct renesas_i3c_cmd *cmd; u8 start_bit =3D CNDCTL_STCND; - int i; + unsigned long time_left; + bool abort_xfer =3D false; + int i, ret; =20 if (!i2c_nxfers) return 0; @@ -992,6 +1065,11 @@ static int renesas_i3c_i2c_xfers(struct i2c_dev_desc = *dev, xfer->is_i2c_xfer =3D true; cmd =3D xfer->cmds; =20 + PM_RUNTIME_ACQUIRE_IF_ENABLED_AUTOSUSPEND(i3c->dev, pm); + ret =3D PM_RUNTIME_ACQUIRE_ERR(&pm); + if (ret) + return ret; + renesas_i3c_bus_enable(m, false); =20 if (!(renesas_readl(i3c->regs, BCST) & BCST_BFREF)) { @@ -1018,7 +1096,9 @@ static int renesas_i3c_i2c_xfers(struct i2c_dev_desc = *dev, =20 renesas_set_bit(i3c->regs, NTSTE, NTSTE_TDBEE0); =20 - wait_for_completion_timeout(&xfer->comp, m->i2c.timeout); + time_left =3D wait_for_completion_timeout(&xfer->comp, m->i2c.timeout); + if (!time_left) + abort_xfer =3D true; =20 if (cmd->err) break; @@ -1027,6 +1107,10 @@ static int renesas_i3c_i2c_xfers(struct i2c_dev_desc= *dev, } =20 renesas_i3c_dequeue_xfer(i3c, xfer); + + if (abort_xfer) + renesas_i3c_abort_xfer(i3c); + return cmd->err; } =20 @@ -1425,12 +1509,16 @@ static int renesas_i3c_probe(struct platform_device= *pdev) if (IS_ERR(i3c->regs)) return PTR_ERR(i3c->regs); =20 - ret =3D devm_clk_bulk_get_all_enabled(&pdev->dev, &i3c->clks); - if (ret <=3D RENESAS_I3C_TCLK_IDX) - return dev_err_probe(&pdev->dev, ret < 0 ? ret : -EINVAL, - "Failed to get clocks (need > %d, got %d)\n", - RENESAS_I3C_TCLK_IDX, ret); - i3c->num_clks =3D ret; + i3c->tclk =3D devm_clk_get(&pdev->dev, "tclk"); + if (IS_ERR(i3c->tclk)) + return dev_err_probe(&pdev->dev, PTR_ERR(i3c->tclk), "Failed to get tclk= "); + + i3c->dev =3D &pdev->dev; + pm_runtime_set_autosuspend_delay(&pdev->dev, 300); + pm_runtime_use_autosuspend(&pdev->dev); + ret =3D devm_pm_runtime_enable(&pdev->dev); + if (ret) + return ret; =20 i3c->tresetn =3D devm_reset_control_get_optional_exclusive_deasserted(&pd= ev->dev, "tresetn"); if (IS_ERR(i3c->tresetn)) @@ -1499,16 +1587,22 @@ static int renesas_i3c_suspend(struct device *dev) =20 i2c_mark_adapter_suspended(&i3c->base.i2c); =20 + ret =3D pm_runtime_resume_and_get(dev); + if (ret) + goto err_mark_resumed; + /* Store Device Address Table values. */ for (i =3D 0; i < i3c->maxdevs; i++) i3c->DATBASn[i] =3D renesas_readl(i3c->regs, DATBAS(i)); =20 + ret =3D pm_runtime_put_sync(dev); + if (ret < 0) + goto err_mark_resumed; + ret =3D reset_control_bulk_assert(ARRAY_SIZE(resets), resets); if (ret) goto err_mark_resumed; =20 - clk_bulk_disable(i3c->num_clks, i3c->clks); - return 0; =20 err_mark_resumed: @@ -1530,13 +1624,13 @@ static int renesas_i3c_resume(struct device *dev) if (ret) return ret; =20 - ret =3D clk_bulk_enable(i3c->num_clks, i3c->clks); + ret =3D renesas_i3c_reset(i3c); if (ret) goto err_resets_asserted; =20 - ret =3D renesas_i3c_reset(i3c); + ret =3D pm_runtime_resume_and_get(dev); if (ret) - goto err_clks_disable; + goto err_resets_asserted; =20 /* Re-store I3C registers value. */ renesas_writel(i3c->regs, STDBR, i3c->i3c_STDBR); @@ -1559,15 +1653,23 @@ static int renesas_i3c_resume(struct device *dev) =20 i3c->resuming =3D false; =20 + pm_runtime_put_autosuspend(dev); + /* * I3C devices may have retained their dynamic address anyway. Do not * fail the resume because of DAA error. */ return 0; =20 -err_clks_disable: - clk_bulk_disable(i3c->num_clks, i3c->clks); err_resets_asserted: + /* + * If this happens, there is no way to recover from this state without + * reloading the driver. We want to avoid keeping the reset line + * deasserted unnecessarily. The runtime paths will still work correctly + * even if the IP registers are accessed while reset is asserted (e.g. + * if a runtime path is triggered after a failed resume). Checked on + * RZ/G3S. + */ reset_control_bulk_assert(ARRAY_SIZE(resets), resets); return ret; } --=20 2.43.0