From nobody Sun May 24 18:42:24 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 542F13D25C0; Fri, 22 May 2026 10:18:25 +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=1779445106; cv=none; b=bVMpUySTsHApvZKbd/bWCBzLXj5dcVxjhRCGO00cQWnjmbgpJoD1E5/lsaxjFsMA2IKZNW4vsx46FWBGB0BJ9FeWEYL47odhaCYyfh4s/8eUn5q+jOAMiiw7d4HtDiC8RdsII77ayVmcfIb2p45amrSghbcGhcIs0FCdMlPP7wU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779445106; c=relaxed/simple; bh=9PKlfJsF/AxORq/IuH3S75bzvw56fX4Ng5OOi276b+c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AzJM204Ya1sdb3GmLro1j0FeTLe4z2Uaj9+pwtiRYhDJAnCH+e5kZ6vqwAV+01RtLNAcSwbRR6mGN1OpPjTdyo+SMg10AtMruNTZurEhjLFXpm2kKKuoCOvOX6aSu5Mc705DxOtkVqJUMHvxQwPj7eksoJjSdRQejbxSBQA70NI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jVC9Nrpa; 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="jVC9Nrpa" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5A1D61F00ADE; Fri, 22 May 2026 10:18:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779445105; bh=N6Yc39X/4veC5J+8erpunKoVVlC+FuQ18yNeUE2JwLw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=jVC9NrpalTn7f3YOXQ1lobtn+LyQGxi8uCSwmMo2t4tzbYnCO3sDAIh9v0iTFmF3Q JtINr5KHf+5iAgEMCiXTYhHCYFXjTCsaou3FwYZS0mVBCIZU4PfVSHr8nHm0Sto9bo tUYR7eRu50OiBZ8jUtjYf/uAWPebBgpDy7YD41J4HpOfoKleCjcNdZ+p2FDxldjOAI BrbKJ9VBCF87wCF3CAtxZIA8XY0QHkTi+788yF5HknQ6UXWj7zLveflxPzwYNrQYxT 3lC289XnGAMew0QrK9I97F35beaNpkP8N54Xo8Jnq/mjqrwIzODIqXZ4wt9SlC5WFZ UArUFUTFie/4Q== 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, linux-renesas-soc@vger.kernel.org, Claudiu Beznea , stable@vger.kernel.org Subject: [PATCH 01/17] i3c: renesas: Check that the transfer is valid before accessing it Date: Fri, 22 May 2026 13:17:59 +0300 Message-ID: <20260522101815.1722909-2-claudiu.beznea@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260522101815.1722909-1-claudiu.beznea@kernel.org> References: <20260522101815.1722909-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. 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 --- drivers/i3c/master/renesas-i3c.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/i3c/master/renesas-i3c.c b/drivers/i3c/master/renesas-= i3c.c index f39c449922ca..36e3ccbe66b0 100644 --- a/drivers/i3c/master/renesas-i3c.c +++ b/drivers/i3c/master/renesas-i3c.c @@ -1014,6 +1014,9 @@ 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) + return IRQ_HANDLED; + cmd =3D xfer->cmds; =20 if (xfer->is_i2c_xfer) { @@ -1054,6 +1057,9 @@ static irqreturn_t renesas_i3c_resp_isr(int irq, void= *data) =20 scoped_guard(spinlock, &i3c->xferqueue.lock) { xfer =3D i3c->xferqueue.cur; + if (!xfer) + return IRQ_HANDLED; + cmd =3D xfer->cmds; =20 /* Clear the Respone Queue Full status flag*/ @@ -1138,6 +1144,9 @@ static irqreturn_t renesas_i3c_tend_isr(int irq, void= *data) =20 scoped_guard(spinlock, &i3c->xferqueue.lock) { xfer =3D i3c->xferqueue.cur; + if (!xfer) + return IRQ_HANDLED; + cmd =3D xfer->cmds; =20 if (xfer->is_i2c_xfer) { @@ -1184,6 +1193,9 @@ 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) + return IRQ_HANDLED; + cmd =3D xfer->cmds; =20 if (xfer->is_i2c_xfer) { @@ -1235,6 +1247,8 @@ static irqreturn_t renesas_i3c_stop_isr(int irq, void= *data) =20 scoped_guard(spinlock, &i3c->xferqueue.lock) { xfer =3D i3c->xferqueue.cur; + if (!xfer) + return IRQ_HANDLED; =20 /* read back registers to confirm writes have fully propagated */ renesas_writel(i3c->regs, BST, 0); @@ -1259,6 +1273,9 @@ static irqreturn_t renesas_i3c_start_isr(int irq, voi= d *data) =20 scoped_guard(spinlock, &i3c->xferqueue.lock) { xfer =3D i3c->xferqueue.cur; + if (!xfer) + return IRQ_HANDLED; + cmd =3D xfer->cmds; =20 if (xfer->is_i2c_xfer) { --=20 2.43.0 From nobody Sun May 24 18:42:24 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 BCEAF3D34A4; Fri, 22 May 2026 10:18:28 +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=1779445110; cv=none; b=tPIeFdN+ZOaOd1qjGtrSCHxNLyLnev0qSXE73w57AIL8fqv2hSBIrQ5Rl40wnjWj+kzAEe4XLmY9BI5x7oQ1SDGWCxTAzEa9sQ8J+xliM11W4KpOXpTGCI8FHnFSuL39xfAj32YXXuMX2H6qLijljstSTmfADIlUVN+JX0MlydE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779445110; c=relaxed/simple; bh=f3rUoCjVFnFdGs3Avn7zLRZ0/fuJbOP1xsSePKAp11g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Xd0G1hnmVngYBdt/sBj+VVJh7lP8q8Yc/g5EndN3a6SfPrx/T5hO1up0DVzobMksEo2KnR6hzeuyw/iHp6QMrxZk7XSxFCBNqFuGd3VlaRPdyc7P0PPAmksdaJqD+PLRNFNJgnrfmmjq1IMgGAgqiwxUXr51U8bI410BWqRTzc4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HTT4z8x3; 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="HTT4z8x3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A87531F000E9; Fri, 22 May 2026 10:18:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779445108; bh=yJQyuEWe74cl7D3825FOdpVlTkubYgooJJWbJo4v/c0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=HTT4z8x3sSC2eolwDB1V6RrOoK19V9Uc+PgfvGd0yoxZCzFSn9/dzEl4tx1DbCcAz sfD25s4VoLSVdDPxFv5mj/d8XexLzB/Zz4JWP1FA4F9N5QuKqbRXygCTNhcU+u786D QbU+vVCMxTUUPItVG3AqJ/gviB6+rI8YASAWuEdK+9MxUz2SOD+cBzXmSuv17piMZH D/50Bv0lM2DYSpMTYX8UUEaVXLOO2DjR/9QN1adh2E/8F67ikp9JkX/uHuUo7s7qik cOKWN58ZLfy0homMy61Fg/4lFDrU+UWAMztP94FFs4LKBSvsRSdshfQ7LUM7JNEEQb 2JnmTE9ABf9fg== 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, linux-renesas-soc@vger.kernel.org, Claudiu Beznea , stable@vger.kernel.org Subject: [PATCH 02/17] i3c: renesas: Use the divider 128 Date: Fri, 22 May 2026 13:18:00 +0300 Message-ID: <20260522101815.1722909-3-claudiu.beznea@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260522101815.1722909-1-claudiu.beznea@kernel.org> References: <20260522101815.1722909-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 REFCKCTL.IREFCKS field is 3 bits wide, and setting it to 7 selects a divider of 128 for the internal reference clock. Use this divider value. Fixes: d028219a9f14 ("i3c: master: Add basic driver for the Renesas I3C con= troller") Cc: stable@vger.kernel.org Signed-off-by: Claudiu Beznea --- 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 36e3ccbe66b0..1917549cf6d5 100644 --- a/drivers/i3c/master/renesas-i3c.c +++ b/drivers/i3c/master/renesas-i3c.c @@ -559,7 +559,7 @@ static int renesas_i3c_bus_init(struct i3c_master_contr= oller *m) =20 i2c_parse_fw_timings(&m->dev, &t, true); =20 - for (cks =3D 0; cks < 7; cks++) { + for (cks =3D 0; cks <=3D 7; cks++) { /* SCL low-period calculation in Open-drain mode */ od_low_ticks =3D ((i2c_total_ticks * 6) / 10); =20 --=20 2.43.0 From nobody Sun May 24 18:42:24 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 3EA363D45C5; Fri, 22 May 2026 10:18:31 +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=1779445113; cv=none; b=mhR3eQZkeYbbz3K9FTJXSXzfA9i/3uV247D4b3Lnht0Han6BZ9hZoBov0Rhb2nWgFDBnonVywg+LjbrwU8Fwb1rQXE5pWuEK0HINk8/7VRJrsFoP6/ymEKNbGxGkKFalGUo5UhuZodH5FGEVTQu3VSi7t6UEw5o0C7kbOe5dVgc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779445113; c=relaxed/simple; bh=CSU7J8SwuiLtOiP4Am1H8eZ4uiZ6BrvsQHIE+i4cp0Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GyURJjCW9xyoloof93Pchs99v5/X6BIQkJFB6+PVJBE5coJvMqJ3SM5sG6XaV1ccMZttclMX2e8SH/zAc2sBeYY3ZkhNQPk9VrNySk50UDQ54W6SSy+AherkVzIyZqZkA2K3qgTQ0rGAdWjYcTYtR5zXKoALLMQVkibVaXn/ktY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZSnOUwuW; 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="ZSnOUwuW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 202461F00A3D; Fri, 22 May 2026 10:18:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779445111; bh=3tvkeAA8mee6Hl0XfVK6GmwDt+kgUaPqK4c7VFuVgTk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ZSnOUwuW67UQ68iFvnK3WZeivbB9JWRzW5+LVMFaKrHy3bgjO+ZcND5iSGaoGZVFq J6RegIHBxLapEKkpfLHXGZpQ5Yax2RxRoOaz464jx/1EeAU2AaeLjjE+jftMrYW+4z WvcCBar2+bBbi3wKcm6XWzOjUVTg6j7on/V0A0KANhaKY2VdVeCwEp1BbmwZWOt1ek ZJEpPjyuv2utJ+bunSttFuXTproF/Ubhnx1sTt4Np6dZrEoG2POEcIaSOHlFtdix4A 6cYMTSnp0YqsXSxBPVrVXuOEnI/zg3ZPOI4UdHrsvoBM7hZyB8/eCPkTiRgLfV5KjQ vqU27GIP+Vq0Q== 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, linux-renesas-soc@vger.kernel.org, Claudiu Beznea , stable@vger.kernel.org Subject: [PATCH 03/17] i3c: renesas: Restore STDBR and EXTBR registers on resume Date: Fri, 22 May 2026 13:18:01 +0300 Message-ID: <20260522101815.1722909-4-claudiu.beznea@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260522101815.1722909-1-claudiu.beznea@kernel.org> References: <20260522101815.1722909-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 Signed-off-by: Claudiu Beznea --- 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 1917549cf6d5..6c23f956ad2a 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; @@ -1447,6 +1447,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 Sun May 24 18:42:24 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 59D8C3D45F3; Fri, 22 May 2026 10:18:35 +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=1779445116; cv=none; b=HegtzvDH7SWwScRwhBHkjhSJA5Iv3SOw0Aidq3SplpdGLsbTsmUjDOylVxSdzOnkEZ4Zvnvcman6WtjtY3n0gX/9KxTzxl9O98kHEotVbSw161rPBt8BXBkwv4wXceyb9ZlLme+E47zQMct9web0znugXbxwMnrOU6+mmlHzYz0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779445116; c=relaxed/simple; bh=uJvK9B00WcC8CRjLk5myaQMfYB/7tBx2ataIoocFi6w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XsrezkMLD4tOhETvafxETrRhuxel8jlkpUj4u6yUgXfDubHvWsCYdGl8Mkg6GG2rbu8lMJK7I0lM6zUTIfXYGXVqLF9Fjslv5TgJ/6AAYlG/NgnhIJfhIfMM6hKQNMghmG4NLuj6YdMDRhSPQbhwmais2iZwAFzvGbZ1NmVCfDY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UEhvacPt; 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="UEhvacPt" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 538E31F000E9; Fri, 22 May 2026 10:18:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779445115; bh=nlATKTBuVymR4RbCGx8EgOlGBJ0lcWHyDwOxkS9JM/c=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=UEhvacPtlFASvTveZ5wQiyCUCLIb5rPzdraj4eS39CKLa7qs+UcoayW4qr5b0NUvx GY3z53b/At+rc7tFIWcneAsh+YBMfOOB5ajSrTTuIkJp8ibEN/W6zR1CD+Ncl8Yrbc cYrFh9IIUNw5uEHqWqiyfgp5HSDeRCUrb6x4D8fVOunDXTvgYuKkshcEKC+Cf2a2RW GCcuKatRi4YswgLLCQ6O2UyH9rnTOxeMnHx9f+upb4tP1uzPdSbulFTjTvJSatqFjW rfddmAXSlKUs78l8VBIReNYQga1Nf5rf28zWKevNN9MjhQ/gKphrMFJvi/pi6hmB6a pcuPBnIwclfNw== 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, linux-renesas-soc@vger.kernel.org, Claudiu Beznea , stable@vger.kernel.org Subject: [PATCH 04/17] i3c: renesas: Follow the reset deassert order used in probe Date: Fri, 22 May 2026 13:18:02 +0300 Message-ID: <20260522101815.1722909-5-claudiu.beznea@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260522101815.1722909-1-claudiu.beznea@kernel.org> References: <20260522101815.1722909-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 Signed-off-by: Claudiu Beznea Reviewed-by: Frank Li --- 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 6c23f956ad2a..d2f29ed0b6ed 100644 --- a/drivers/i3c/master/renesas-i3c.c +++ b/drivers/i3c/master/renesas-i3c.c @@ -1434,17 +1434,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); @@ -1465,10 +1465,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 Sun May 24 18:42:24 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 7EEB63D47DE; Fri, 22 May 2026 10:18:38 +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=1779445119; cv=none; b=VLHdzk3pmfTkvlQ3t8qMlGTw9fsHUUFfgU4ovWouogbQEuyhwTgR0CRaYAh7CwIoQ1ay1Swir5EO1A9BYTwjCU5v0lEl2+OslL6itw3093cyUr0OclR1BzsQGxpIzsmFLt25FEYh1z/9sTB9p7IyS+p9bY44qSIFC4af9hhnrNQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779445119; c=relaxed/simple; bh=+R74E5YvNsL5Wej67ou6dUHWim3RWgIorQJ/LkW5EZI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=StZGYVSIRdW8CBVAP2CGDFz77h0/fFaq4y2rRl7o9ISfqCiiORUtyMOkGf9sK4NtStZ6fdrdcn45zmhn6YIZNuLkeXZu1kOW4GoA0pJU0ftExZitRNtNAAl16Ke7OeWcdZReenKLZhIgomSx5XMj3o5IACshMZoGbWa24MgkZI8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hyGcNSVR; 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="hyGcNSVR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 836F31F00A3D; Fri, 22 May 2026 10:18:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779445118; bh=ZdZdbTP0Zl4cO/TOEBD6ohZd0OjzNrlsg3iBs2gbCH0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=hyGcNSVR+OF9Z/oWgWO8av6LPOV4KJacF4eUTOfcvcdAVVvdTUG8N3IU2MWEuZSko dEAlbdLPP29iykxP8aNw4Y5KYDv2uSi9K4r4xuL25db0bMbAbYA5Qi/yUHSIhXOWa+ FuvZsmLYpaJwPRpB/8+NCtOsZG5CDdMkFdcQGt8rc40WZ+jSuqrg+pT93+L34SLwG9 xQDOtl5DTQpg4wjtA17puEdf06Uh8mujOgzXHMM6iQQ9KD6fM8+Rhx3OQjHZFy0CvN xYnsdggAWQg7eMiVNVqIPp11XUqFVS/5P1N1IT8Rnqq/L2Vf/GLCrkc3tDYt4clZou teFto687IxxLw== 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, linux-renesas-soc@vger.kernel.org, Claudiu Beznea , stable@vger.kernel.org Subject: [PATCH 05/17] i3c: renesas: Fix re-attach Date: Fri, 22 May 2026 13:18:03 +0300 Message-ID: <20260522101815.1722909-6-claudiu.beznea@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260522101815.1722909-1-claudiu.beznea@kernel.org> References: <20260522101815.1722909-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 --- drivers/i3c/master/renesas-i3c.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/i3c/master/renesas-i3c.c b/drivers/i3c/master/renesas-= i3c.c index d2f29ed0b6ed..5174a390d668 100644 --- a/drivers/i3c/master/renesas-i3c.c +++ b/drivers/i3c/master/renesas-i3c.c @@ -892,10 +892,28 @@ 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 (pos < 0) + return pos; + + if (data->index !=3D pos) { + 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 Sun May 24 18:42:24 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 056773CDBCF; Fri, 22 May 2026 10:18:41 +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=1779445124; cv=none; b=ZqUofDcBsfjiqdquEBJpINwA1ON3FOJOpQxr/+Al9qKojZ4UQIn0lYMtZ/nMCc6ffNiCI/riov214H7ToeKqdfguleEOw53azLFIHKlT0mxWAl/HFdigL1LWWebVkzzBwFvGnpXvg/SlponWLGJvEpPiu6vFlNok3yBBzYcL5BM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779445124; c=relaxed/simple; bh=d4brNAUNsGKbzRen8zF+Stw5edcbcNLiJdCTcWoQM3Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mt7Nlxwtpyt3rwPC7D2MRvyRajrHe1y/s/1XAGSAwjfQdw06CD1yyjUMFo7HjO1suxHV2xquy5rQppdZ5Brv3AC/gpNBCTpFT5748NRwv0M6T/cle+vgLlEzOkp/1h8KPrv990LHD3kw6/ePSiutb0XMOi8OdcsMFjsYis6QWz8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ecgwsESn; 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="ecgwsESn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BEE531F00A3F; Fri, 22 May 2026 10:18:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779445121; bh=2HcpYK49UBf/mKUAx3HBqJD/spvujUuD4VomntZMaFY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ecgwsESnFSbRIMClib3AsiGiUviF9EJENft1errAR5aEEf/490iNL8wcGNV9b3RtQ mj9foSOzaQ/n02MqUx3H9ZiDbmDX7d6TLTdWtpNXs4rVKie1wMC/eqgUg9enJPSNGa 7Rgb9yrBiVgHBhBeyxq+5fjieC1CVxyN8Sf5RMYjleP0/oV4GFOaWDOj7XMtIJRr1o KKQ+SBgXj36x3ntFM9klql7cAkyBRefEWfiYAs+lIboGjZ86sR2pBkVQ7voCMC+P+s FYCOLfZV5HSLetwf5v2eAg4iwB9n29mh5/e7NcijutaOFUm8iQCM+baec/uryDh11j 6h+zlL0heUijg== 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, linux-renesas-soc@vger.kernel.org, Claudiu Beznea , stable@vger.kernel.org Subject: [PATCH 06/17] i3c: renesas: Reset the controller on resume Date: Fri, 22 May 2026 13:18:04 +0300 Message-ID: <20260522101815.1722909-7-claudiu.beznea@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260522101815.1722909-1-claudiu.beznea@kernel.org> References: <20260522101815.1722909-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. Fixes: e7218986319b ("i3c: renesas: Add suspend/resume support") Cc: stable@vger.kernel.org Signed-off-by: Claudiu Beznea Reviewed-by: Frank Li --- drivers/i3c/master/renesas-i3c.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/i3c/master/renesas-i3c.c b/drivers/i3c/master/renesas-= i3c.c index 5174a390d668..2f3c6ddf75c0 100644 --- a/drivers/i3c/master/renesas-i3c.c +++ b/drivers/i3c/master/renesas-i3c.c @@ -1464,6 +1464,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); @@ -1483,6 +1487,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 Sun May 24 18:42:24 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 1EBF433987F; Fri, 22 May 2026 10:18: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=1779445126; cv=none; b=oVTXyAprasyJ6QrJ3Sw88lhrTg3xRLMpKx73VTbC+0g97pTBo/iv8yXQL4D9zNd1Y9UlVLotf7NS1oEapZEdDd1yFVmxChg1CSH/HHdEcZmq1hyh32+iez4nv4t9DsPFSYKzqAGCBVFw1E1I4961qzkYK/CrnocbC0AhwZ1gksI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779445126; c=relaxed/simple; bh=uf1sdahMWZZTQPeP17kiWLU0YKQLwyootUhMWZpohY0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ye4zONdpCeD/Z61Lewi/pwFy4URYKzicodjVdo5WLqzuO4uVWocrSWtCMKjB+drWz5dGrgU9xdUeQwhMpcEcbo+0vnGC/3QfKLMsg8GPt/XAqchJXa5tDAcaCqDm3WuGeQOIsSIgF7saON2VGnTZ/TcAF1SK9krfcktylFouQik= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mFr2qy3P; 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="mFr2qy3P" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 394221F000E9; Fri, 22 May 2026 10:18:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779445125; bh=dH5gWDSmYByXyG2JuND8wj6TGzWAjvFonp0Pwdsi5N8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=mFr2qy3P5R7exMaryITydrGH+J4pFwwf1e9wdQYYKKQT+w+g71bdQZTiNmFfH3IvG +N78wUfzAawz7H47mzSJvAphKt9jJx8rg7v2+XRW56KxMalTnr1MLFNEw4qJCcdV2S WBBpNFr34AFwKztaY7OHel85v4VYtBdj2dmj956cm/xYRzhUU6Xf1GTzYFN0YBSKlm D5SRPHUlRDkO51zXD4vnZ3TWaEhnB59mib9SxrILTs7rAX1vuJoyj5YvqC9WHP31x6 orhcOJZAWtruCtrOQGZPWYNoLtp5iNRpHS9m7yHDLEgj7WyQjhhKwaNf16zOwBqwdm o7qq+b4i/pv8A== 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, linux-renesas-soc@vger.kernel.org, Claudiu Beznea , stable@vger.kernel.org Subject: [PATCH 07/17] i3c: renesas: Perform Dynamic Address Assignment on resume Date: Fri, 22 May 2026 13:18:05 +0300 Message-ID: <20260522101815.1722909-8-claudiu.beznea@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260522101815.1722909-1-claudiu.beznea@kernel.org> References: <20260522101815.1722909-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. Along with this, struct renesas_i3c::DATBASn and its usage were removed, as they are no longer needed. Fixes: e7218986319b ("i3c: renesas: Add suspend/resume support") Cc: stable@vger.kernel.org Signed-off-by: Claudiu Beznea --- drivers/i3c/master/renesas-i3c.c | 34 ++++++++++++-------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/drivers/i3c/master/renesas-i3c.c b/drivers/i3c/master/renesas-= i3c.c index 2f3c6ddf75c0..c009d0de6a2b 100644 --- a/drivers/i3c/master/renesas-i3c.c +++ b/drivers/i3c/master/renesas-i3c.c @@ -265,7 +265,6 @@ struct renesas_i3c { u8 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; @@ -1400,12 +1399,6 @@ static int renesas_i3c_probe(struct platform_device = *pdev) i3c->maxdevs =3D RENESAS_I3C_MAX_DEVS; i3c->free_pos =3D GENMASK(i3c->maxdevs - 1, 0); =20 - /* Allocate dynamic Device Address Table backup. */ - i3c->DATBASn =3D devm_kzalloc(&pdev->dev, sizeof(u32) * i3c->maxdevs, - GFP_KERNEL); - if (!i3c->DATBASn) - return -ENOMEM; - return i3c_master_register(&i3c->base, &pdev->dev, &renesas_i3c_ops, fals= e); } =20 @@ -1416,17 +1409,13 @@ static void renesas_i3c_remove(struct platform_devi= ce *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; + int ret; =20 i2c_mark_adapter_suspended(&i3c->base.i2c); =20 - /* Store Device Address Table values. */ - for (i =3D 0; i < i3c->maxdevs; i++) - i3c->DATBASn[i] =3D renesas_readl(i3c->regs, DATBAS(i)); - ret =3D reset_control_assert(i3c->presetn); if (ret) goto err_mark_resumed; @@ -1447,10 +1436,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) @@ -1476,15 +1465,19 @@ 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 + ret =3D i3c_master_do_daa_ext(&i3c->base, true); + if (ret) + dev_err(dev, "DAA failed on resume, ret=3D%d", ret); + + /* + * I3C devices may have retained their dynamic address anyway. Do not + * fail the resume because of DAA error. + */ return 0; =20 err_clks_disable: @@ -1497,8 +1490,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 Sun May 24 18:42:24 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 A9B2C3D7D72; Fri, 22 May 2026 10:18: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=1779445129; cv=none; b=IkKm+8u0N3kwErQmttJMEZpkY+GCABW+bNsj6nK4YKzGlz00PlmkAszGrF3LKZAsWVb8MSEq32XtFHwNm6zD59I19hhHDIDylMGUaQoZoebf8oHoIfCr8bsYKTP6aA6gj4t1RhbSqR0wqf5pSGxvkTMg5cGSekutnlwoDLV5+hA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779445129; c=relaxed/simple; bh=2iSupFAJn6WtJHhPNlyOKraCP+YkbuT+aBwKAfdYoO4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rqBmStDtnELNgMoxKh5SAena3/WmfV72PF+ayhZNB1FTvntjzw89Dkl8uFe1ngjDh4Z6PKHR9eGMFY3mWT1G9i6RgJbr1SdjeOM99z2o9LY3jMpjKjnYmwsuVPM5gVRYSaT9bmVrt2D2HPnOVtiGlxEgM8mqJ5iHSjRyg/DePmk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kL2sobK5; 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="kL2sobK5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7AAD01F00A3F; Fri, 22 May 2026 10:18:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779445128; bh=gzq0ouywBIfZI5tPxbNKr6btyYhJQupzX9OFQUpjMEA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=kL2sobK5lJAlo1wLEv7GhhZOjTum5UKgAf4kPF2BqNxNkVJBNNf73k5ZRQfeEKwhB x48WIGgCgUJOyyDf9J8xHNVhnuzwr/LpZcItr1gso0FSw5/DVfavBsgsffYMYdo708 3G1y25zKZtwZXig/VtT0BPwxRJGEMslArTaPCFmTVmMkyCAH0qjJPEUMwkQjCuTHjo aDNDqNRR1Uhdya6+fRYXaB2Hite02GC5JksBNTE8R0lE8tcQ7+tojEn1M+zgeP1AB3 uR1L2/FLa5i+X3F0qInxYRCqUeSu71m6Rj4Odrtr46auHH/OqGEPI13dn8FJ6eVah6 E0a/zDvzOBWzg== 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, linux-renesas-soc@vger.kernel.org, Claudiu Beznea , stable@vger.kernel.org Subject: [PATCH 08/17] i3c: renesas: Clean DATBAS register on detach Date: Fri, 22 May 2026 13:18:06 +0300 Message-ID: <20260522101815.1722909-9-claudiu.beznea@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260522101815.1722909-1-claudiu.beznea@kernel.org> References: <20260522101815.1722909-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 Signed-off-by: Claudiu Beznea Reviewed-by: Frank Li --- 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 c009d0de6a2b..d32646deb69f 100644 --- a/drivers/i3c/master/renesas-i3c.c +++ b/drivers/i3c/master/renesas-i3c.c @@ -922,6 +922,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] =3D 0; i3c->free_pos |=3D BIT(data->index); --=20 2.43.0 From nobody Sun May 24 18:42:24 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 055003CDBDB; Fri, 22 May 2026 10:18:51 +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=1779445133; cv=none; b=dROnGuHhaVpeqf7re70kWyd8OaYcz2Br5kPwSMEBVJojOm/yxnQpAuiiY4Vc8iHqUa4yhvPi9bSPZsggrDxH6hpgULOPxxMhoMxO8RXQBbEcSfcS+G/qUtcn/ud12k2ULqJvtM3eI0Mta0FljpLZFj3YWTKlhZ93/CSO+Ld0YMQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779445133; c=relaxed/simple; bh=u2aSK1ItOQKT29AOld7hmd50ZTMZASsXhwHP+pH83Pc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=c0RyNJBzuXTo3umjFKVIfzXZ7ko+AVI/CHGzDNELmOyrRC1or23Wr8qJB5tWP5lpjM1c1oY3l4oyXKm2GLp1l6WL7QXSYIyyEHx496YwhXEizgH3SDICOIjX6+Cxm+FlGWLHpFXmaBU+fJa3zln3GztXo8x63/fAuogtEuRIU6M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lILRdStR; 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="lILRdStR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D990C1F000E9; Fri, 22 May 2026 10:18:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779445131; bh=fQueYcmdwnccioyNO8aGWs1lRM/qB9ET5VtaJlLRrkA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=lILRdStRs+CqQzCip+lPD5w3AffDPiy+rQYCSopIUO4TiF1p+/iC/3LrgphzdW70m pVLwkZyK2DYGoSD53GqZ3J9UFL22l+WFep2eBkK36/LWDIMt1FQc8+9fGoGorIsKdQ sAPH/EXUMBmMok6LxsES8jCQA0t8R0XOYKy0iiwSn0I8hFosjKtKaqJ17cf2NVjMU5 HqAvgob7QvV4H2fhFZMPAAh+o79F6T2huKiadyQa3j4/GFb4cXyDcGUoQXOcixPy8Q 0wgZtP1SV1urUuQuVdNhp6R7zCO6pWOLg12YCrVBVZj9LD5CCopnXTgHWP4pOkfhr1 CmDJ97HjulmBw== 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, linux-renesas-soc@vger.kernel.org, Claudiu Beznea Subject: [PATCH 09/17] i3c: renesas: Use reset_control_bulk_{assert, deassert}() Date: Fri, 22 May 2026 13:18:07 +0300 Message-ID: <20260522101815.1722909-10-claudiu.beznea@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260522101815.1722909-1-claudiu.beznea@kernel.org> References: <20260522101815.1722909-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 --- 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 d32646deb69f..e5963270d6e5 100644 --- a/drivers/i3c/master/renesas-i3c.c +++ b/drivers/i3c/master/renesas-i3c.c @@ -1414,24 +1414,22 @@ static void renesas_i3c_remove(struct platform_devi= ce *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 ret; =20 i2c_mark_adapter_suspended(&i3c->base.i2c); =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 @@ -1441,19 +1439,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) @@ -1484,10 +1482,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 Sun May 24 18:42:24 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 D86D13DCD83; Fri, 22 May 2026 10:18:54 +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=1779445136; cv=none; b=YAlsMfsLGCUdl7M8PXIpysKDD25HnoFjppAOCDMIkpG70puJ8ZomBPKwsqXI0Lqj1taTIUpyY4xqqOEDwEs/b6n9Cd59bYFbQCDTtQplrvWTuNmBtpOEdHPTU2ipnCBZu2vRbXApSc2665Lr1Pp5cLicEiwwRV0EniSnKwp//Fw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779445136; c=relaxed/simple; bh=bI5bHCRByTJMdedcq3DjLgbMIjC2BqnDoVFxqNcm2EU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cYwd2PGOMr0+L9glU+Xa6m+B29UDBB7fZ72uSGC0RLMcLWQiC8I+VwnYzERFx5gC/v85Y1kqD/ojESA2i4ZJVcFh2B0VvmSRQwQhCyR7KkJKuTKVy+R9SU7WWMwuo47D25GNLIxkpgGvcRI8XoV9Q9zXp4cUVV3rA0VzBDLjfFg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XNlWY6OP; 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="XNlWY6OP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 29D721F00A3D; Fri, 22 May 2026 10:18:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779445134; bh=ZjMZYfPSJO9ZQMhgvudeE6rW/MiN6FXWJF5z9WaCh7o=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=XNlWY6OPjVIBWhlFjQsA+z8YLFRh1Fle3nuYY28u9LrXGkBpfkuTMWsBRXPqrra31 cMAGTiIbbccR8PJncjGOkQs3IlqhDUo3d0yTPD6tm7dR0KKrLFtGVzHfjXayZ49/mF VapJF0cTUwC4IbuQg+9xlSyW0HZbf4TWv3wYCxQD/cuLL2NDHDOPQK1Jj0nBCbXLnu NEkTIsc7mxPJpo5631Q9arSaJrYgtrrPyXQdW7rwdVd9DT0rDH5Ee8Ur0VMrBi4j1w H/dbdFOyJB5K+T/18UOuOXolBqxAZ59qyyOIvxxCMWOiuwkk3R5Ccb6n3w88OSmF2w WmfT7nqlpP8iQ== 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, linux-renesas-soc@vger.kernel.org, Claudiu Beznea Subject: [PATCH 10/17] i3c: renesas: Return immediately if there is nothing to transfer Date: Fri, 22 May 2026 13:18:08 +0300 Message-ID: <20260522101815.1722909-11-claudiu.beznea@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260522101815.1722909-1-claudiu.beznea@kernel.org> References: <20260522101815.1722909-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 --- 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 e5963270d6e5..de75125eb013 100644 --- a/drivers/i3c/master/renesas-i3c.c +++ b/drivers/i3c/master/renesas-i3c.c @@ -940,13 +940,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 Sun May 24 18:42:24 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 0D23D3DD863; Fri, 22 May 2026 10:18:58 +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=1779445139; cv=none; b=cgTgkaG/IVE7c2/AOuR86jRqvg3ecNijp9EMT2xJpkULsVmvPsiDZHpxcyS+gxdedLwD+YwELxJvHux2I3I1cSX2iz9EUaSzxixNiZ3z+TkUp1dBhE/XMzgddf5niMKD94nQPk9JSOmr1tKf2xhTe5diAKRSsNVqxxVGW8zcfv4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779445139; c=relaxed/simple; bh=hLXRApDK04Hhk2uYEURZglRIH56F+fpQjp7Tww4fcGc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ohbijc/wBkMtBcMblqveaRL2wfWa8E/I2h5gGL673SvZDIbWjKmNj3En28rJ67zud9twkkmzika2AAIcGJixILhT8nuWW1zpF3VdPtf7Jj+H9NOqA5pYFtXTq8XQCo35lPT6rNRVmmL3a1dPKJJVYAp21asmQVFATWJfZAqYOWc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Zoj3Kl8Z; 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="Zoj3Kl8Z" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 549101F000E9; Fri, 22 May 2026 10:18:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779445137; bh=FzC0PfLaUCFbX40pK4alDEqv916An2KDJu11AtBrqdg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Zoj3Kl8ZSQOE6ScbTouakXO/xAzb9g7EICV6dBevs/Py4FSGEMd5AayGjRvt0S5d2 ykGam6xyi60rg34v3wnfX2EFk5JoKG1aErC7z9rNOhltiQTMpRA7PWX84RqICw1ZcY B097XIqFX+rJO2FluwaEq7Z8zf246yi7ysGiBlnQedj26sNRndK/mDtuLQ0cgw9vA7 R+Ui+BZKADuBinnAvwPemoVAZHjxVqNQVw0Qtc2QdGs+b7zzHbED+VM/lkaVKKRHoS tz2DeLGAI3djNHpK3oiFa+8ZQiwx2Ag13uQCW7881giUTEF7m67NIvFcsrIF0gx3os JD7y0BGxkgbAg== 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, linux-renesas-soc@vger.kernel.org, Claudiu Beznea Subject: [PATCH 11/17] i3c: renesas: Follow a unified pattern for transfer and command initialization Date: Fri, 22 May 2026 13:18:09 +0300 Message-ID: <20260522101815.1722909-12-claudiu.beznea@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260522101815.1722909-1-claudiu.beznea@kernel.org> References: <20260522101815.1722909-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. Signed-off-by: Claudiu Beznea Reviewed-by: Frank Li --- 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 de75125eb013..12bf4797a70d 100644 --- a/drivers/i3c/master/renesas-i3c.c +++ b/drivers/i3c/master/renesas-i3c.c @@ -648,6 +648,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 @@ -669,10 +673,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; - ret =3D renesas_i3c_get_free_pos(i3c); if (ret < 0) return ret; @@ -760,13 +760,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: @@ -816,15 +816,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 @@ -947,12 +947,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 Sun May 24 18:42:24 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 1A85F3DEFEB; Fri, 22 May 2026 10:19:01 +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=1779445142; cv=none; b=txgASzkiRnwcDxcp+et4DOPQmj3728YLVoH24otNLdYTg8dSjV+vrrEjXpfDsxJScNm1X/f7Is2CJ1qBOQK0th0o893/i8gxewa+HyLLwQrsY5sUOmBHWyVMjKnwnLZkDC0HihvePffOsROtF35GeJI14XhFA22Nu8ndVCdTcV8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779445142; c=relaxed/simple; bh=/X62KWmzAmStDDgZowmuKDOpnjU2J3YPFUr+QdPAhBg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kTkaBdGrouX3FZ/nrYCs9Y/W0r7KW7YylqHIgpTM+AfMI5K73jpu4gaOgE/S522RjsnWswzoLL0eVc41jGEp02E9EFYuaTLlxaLT9HM92d8eLVdc8Nq6RQnir4BGuAAOXzwHy2pPLDRLgz3P8VSTIshwmlCTr775XDQYHcCuvus= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eR948MYO; 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="eR948MYO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 659D61F00A3D; Fri, 22 May 2026 10:18:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779445141; bh=+vFJFlgaUSzlhWn87F6K4JPStiuv1ICWwA4GM2ytu98=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=eR948MYOknWWdHEvPctgZ+boHq0n3tHGuKVcPKzZM9R8pSXK9MBflVTBU8ZbYPUc1 t32ppFnSSusuWRaMvAhJqB/HB5GTdfa2AQiimTc6kHEygdBIZsTxjHyPVgOAQ1dApX 4iTPZe5TRO7Sjim1AV9JSe/uCA2Bxj1cANr23nirX9Iaz3wi9CB+y3GwSNxoT8PUeQ OTloT1Z4z7iqLpuZ2nnvfgPIb42WWbJ2JumVbdebBtDjxTRf70mBnEufvLU6Lnoq66 6EQrafoLNc8IjJXiNReWC48j41rs7b9midToC8wcmKdmVsjTFudZGpd86mUH+Obhqc fFjoJd4agtWZw== 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, linux-renesas-soc@vger.kernel.org, Claudiu Beznea Subject: [PATCH 12/17] i3c: renesas: Drop the explicit memset() call Date: Fri, 22 May 2026 13:18:10 +0300 Message-ID: <20260522101815.1722909-13-claudiu.beznea@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260522101815.1722909-1-claudiu.beznea@kernel.org> References: <20260522101815.1722909-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. Signed-off-by: Claudiu Beznea Reviewed-by: Frank Li --- 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 12bf4797a70d..865e67ac0fd2 100644 --- a/drivers/i3c/master/renesas-i3c.c +++ b/drivers/i3c/master/renesas-i3c.c @@ -624,7 +624,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 Sun May 24 18:42:24 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 933613E16B5; Fri, 22 May 2026 10:19: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=1779445148; cv=none; b=m3N7Srgpx+BQmnGrkG+ejluay6JGu/w/9FfwVfTjSIS+yZztBKlyHEbBj42yF0Up2aIdVw21xlt+p1rg9S/Pm4Wr3vreXlwEsUCa18EfoFJZ0qeTM6daN8Mw7HwQi4qpC4jBQ8Xg1TDpbo79/KoKmr90rUr7ezmmQCGw9LtOymo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779445148; c=relaxed/simple; bh=WBZhj4NgGiwjTi9j4Mqu2SHvcm9wglX+/npJOEzAaHs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=R7rtml1wwvXo0mcPSbp4bM60gYOGM6gI9REE/U3d1UIUsdnHPVDkn36E99ye6hqhQsoCsQ6WjuE75lppyIQiq4Atap/tB299MUu5mncXrtPC9p6PhqnV2b8WHOi6myqywwhqLVAfwYoRfSeHBtxG1rthl+UgidchgeQlUg92EJk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=evSBmtWe; 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="evSBmtWe" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8FC691F000E9; Fri, 22 May 2026 10:19:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779445144; bh=O48MvtboEsVG3v8Dnm6gl7B+O5EQNDH5bmjyaZheYiM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=evSBmtWeG6K9KrY0mMd0ISrjE23GUPv5y4BYGPnrJsC9SvF29iwYg2hLI98HvQae9 Xf1h4+OymJ/MtdMChqSOj9wiToMQO3pUz7DCmdN/gP6+IC8IGgT2JIgHOwCetY+l54 ND+geNs+kEct/xNL38IyAB1cJ+B9JMXjSvWQqYFa8yrpPSjv2cbOrqg2mFliqVlI6Y J8XjAwPeZu4uANh62RAAj/2if2hAknRYXSQxmTsok/3IpGk4L75DbSKvxUYDiRqCkh x52QEpEHMT+P9EZwkWtK6ToQjgcPvbJxF/jYTzJnvMN4WV8S9JDXbfVh5wBFcbuyj8 qqR8hxDQ0TXRQ== 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, linux-renesas-soc@vger.kernel.org, Claudiu Beznea Subject: [PATCH 13/17] i3c: renesas: Update HW registers after SW computations are done Date: Fri, 22 May 2026 13:18:11 +0300 Message-ID: <20260522101815.1722909-14-claudiu.beznea@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260522101815.1722909-1-claudiu.beznea@kernel.org> References: <20260522101815.1722909-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. Signed-off-by: Claudiu Beznea Reviewed-by: Frank Li --- 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 865e67ac0fd2..631c9c5d8038 100644 --- a/drivers/i3c/master/renesas-i3c.c +++ b/drivers/i3c/master/renesas-i3c.c @@ -550,10 +550,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 @@ -604,27 +600,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 Sun May 24 18:42:24 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 E5AEC3CB2D9; Fri, 22 May 2026 10:19: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=1779445149; cv=none; b=Wl1P5utmSFxfvaGqzthetGwUXQP8hBVMRfHgRARd7A1Nu+M79aCTVkNv7ojT08UbjBjFKf6h3JSM4HEjH4bpGahpHFiWx0rR+ob+gzcBWhzSbuHkLtg5pOq00WrroVUij+RHW+mTbf9L3D6m35m9BMdxT+7bLhNGadCn/Vm99r4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779445149; c=relaxed/simple; bh=OFODupkaKLfvDlYVNWWBsPRsyR4Wv5NeZvQbwSHUTP4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eo8qMIV+MDmbnB4sS4xpQvGZe3/ra+eVvEVOrarNA9fyivMDuYHk7fup2mfmkWNb4hDtPLA43cOJ/mZGLMkeCQ+pbv8V8CAkYhm5JfV/ssQHiaDxgwi7LJh84CcdHNcioJMF61xlwBzFJlv4OR2W7xwt5ongB2nAI9aOEs8tin8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=R890KuJL; 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="R890KuJL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9F2911F00A3D; Fri, 22 May 2026 10:19:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779445147; bh=t1ETYeozg7CFWt2DrNX0CbO/MU4FMFeuD38xoBF1sMg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=R890KuJLkTrgTHNT1i4/eHoOHOMtVRzBIUdmuZG3KNgLngTY77KKakYvXJtS+uqy7 +5MfVU5LahS7U3rfAKgnYKf1hIK6IEJadAN98U4pjs4/zZiwSjq8pvlWp8m2OO1PO1 a/y730K085NG3XWr+8eagG+/6s9F+M/mhQGPkOUvB47W75Hedjsp1dKuSqNLay9/N6 dKlGKBaFRNKv292cEbc1pLZf7IF6tTj7iRA/fGJwiZLWNcKiVjlQbnA6mIgTLbIqAz yTgs4frTHnOlG539uzif3YpxApiC6hqxe0KBI/6dTeapVl3cpcRPhE4dCIEbFIVRE8 YV5FrARG3eUtA== 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, linux-renesas-soc@vger.kernel.org, Claudiu Beznea Subject: [PATCH 14/17] i3c: renesas: Organize structures to avoid unnecessary padding Date: Fri, 22 May 2026 13:18:12 +0300 Message-ID: <20260522101815.1722909-15-claudiu.beznea@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260522101815.1722909-1-claudiu.beznea@kernel.org> References: <20260522101815.1722909-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. Signed-off-by: Claudiu Beznea Reviewed-by: Frank Li --- 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 631c9c5d8038..5614ed99553c 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 { @@ -253,21 +253,21 @@ struct renesas_i3c_xferqueue { }; =20 struct renesas_i3c { + void __iomem *regs; + struct clk_bulk_data *clks; + struct reset_control *presetn; + struct reset_control *tresetn; + struct renesas_i3c_xferqueue xferqueue; struct i3c_master_controller base; + unsigned long rate; enum i3c_internal_state internal_state; - u16 maxdevs; u32 free_pos; u32 dyn_addr; u32 i2c_STDBR; u32 i3c_STDBR; u32 extbr; - unsigned long rate; + u16 maxdevs; u8 addrs[RENESAS_I3C_MAX_DEVS]; - struct renesas_i3c_xferqueue xferqueue; - void __iomem *regs; - struct clk_bulk_data *clks; - struct reset_control *presetn; - struct reset_control *tresetn; u8 num_clks; u8 refclk_div; }; --=20 2.43.0 From nobody Sun May 24 18:42:24 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 21EEA3CFF69; Fri, 22 May 2026 10:19: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=1779445153; cv=none; b=EepTOl7NtoaiXmXX352X3cORmlKB8Fkkp6Y53D2/+yIlsvTnFUWVo7KnpJNwnHK1lPeBHfwcKIAQnApIDfxAnJBlP1u/BfH0wm26/qiGJJ0SUxHF3rR3AsR9slgr69ytsVTuWm9F+hNrFDJIKe7pfy/vQzuJSN3fcVc1QNZdeLk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779445153; c=relaxed/simple; bh=So7pwgWkCKK6qFNoIGV6sNXH+bSlX0B83MTCuYfx/Xk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Szwtb74p4JYSpGYFN+m+ewAMOQDqAAV+zOGB5qs01xNrJOEAW7Gj+2H2HpraoeBj2opxn2cjEr+ogpALC9eF5CD/uSyi1lSLm+YSaMVgGFZXqXT5/s1Tz9KrMhPQjUybhiGAyG5zpibflvulQdTai9Nd/x9CU22m1hJkW3ldEbg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DE46XXTF; 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="DE46XXTF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AAF321F00A3E; Fri, 22 May 2026 10:19:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779445150; bh=aSGJt3Bw4ZA4gZKsUVnQGrh272MXdVQ2Sy4qXRc2hO0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=DE46XXTFyTpSDLEKGYfUQXsXQUSuAPT4QxJy/YdnMmXlpeWr1b8d0A5LlS/7ZrRs0 QNqo/KMs0IbaJfbeXUVCmCEUIBtMfIgIxtEI4VLvMKtmLL5gIDuK++YdWQASJMhVQd brxKtppOWO37o3corXPOlic2aHg7QeYvklId5TTWQI8ELDQwIVwtAeYhjM1ox+bNR+ GlkMc9DUf4BjJOpdR4F2Q2t63UVYCQ7b4g5iRcd9rNmLLKDvFZptKI9aN0ho1pjNDa B5+ojGrIecMnEeQqa7194MXe5dmAHH8spFgTg6/BGTrrHk5B2setp5o3Lb5E1sV8hx 9k9GxN3zdFpXQ== 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, linux-renesas-soc@vger.kernel.org, Claudiu Beznea Subject: [PATCH 15/17] i3c: renesas: Use the "dev_name:irq_name" format for the interrupt name Date: Fri, 22 May 2026 13:18:13 +0300 Message-ID: <20260522101815.1722909-16-claudiu.beznea@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260522101815.1722909-1-claudiu.beznea@kernel.org> References: <20260522101815.1722909-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. Signed-off-by: Claudiu Beznea Reviewed-by: Frank Li --- 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 5614ed99553c..e6e05ac03082 100644 --- a/drivers/i3c/master/renesas-i3c.c +++ b/drivers/i3c/master/renesas-i3c.c @@ -1385,12 +1385,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 Sun May 24 18:42:24 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 41AB63D093F; Fri, 22 May 2026 10:19: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=1779445156; cv=none; b=Xvtel6bxWFYjmaK41/HSg6jyKDlYWaRlCQftTzwnA6+DBk2wrNy/f0Ck55sTkpvaE7tqvpD36OqrKAp7bHlyCEj+Rmpu1WQaL+08kv1RxzzdFERd5+JlxEIOzrV/7A03f9fOiMgrCieuL0fsFD3oU6wchMOcnOeTgSWWeI7khqI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779445156; c=relaxed/simple; bh=b+kcs4+oMOM/Llc+Sa70fX2t0XYd5cyiRIv3Vjtmdlo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LKWc3p80gQqzSfsoSrCrSRJ2BDHnCzlR61GQLlLHsjp45g+DdlkbN7eGn9vY3kAjmQs1ek926QBdLxRIP3ngjtsWI4++rOBDQndTvoSkbK0zYFL7iRXimcg+e1CR1Irq85zi1o7IV2Jn/3T+59qbQg7ydUhz2Jgf/rruVimngjo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dKrzilp3; 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="dKrzilp3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C529C1F00A3D; Fri, 22 May 2026 10:19:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779445153; bh=DsYiQHGyumygtMBJTB4arAhBm7bfD3isQprTj48F95g=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=dKrzilp3vQseph29uqh+gdL0lhzui08VFEISp1/cDsoJojVk0zB8yIp36SbbgSpMt kMD6cxlFGFqeJhWIMI8gYY1dkKbpXKcDbkTasQi0dhvOHDZWEQYMBK7FtppkxfJhQ9 05hZlPcgUXqFvTSGdVD68MoLdNeNgcgezprlcY1NYqZrc290G97XjRpMbrTL4KssHU +1tYOlB5Nrjogu97OHJgvIAWJ/aopmFkaWgW1C6EADm7a8ZRqmZ3gmEOEfKOzMEzij CFdjZYSa2AxVB9Ah9L1EQ7fBAf6AzC7X5qauzPiFKziPygQeDesq/M4YmeHaH5kxEA nKurnAW8GFjJg== 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, linux-renesas-soc@vger.kernel.org, Claudiu Beznea Subject: [PATCH 16/17] i3c: renesas: Drop unnecessary tab Date: Fri, 22 May 2026 13:18:14 +0300 Message-ID: <20260522101815.1722909-17-claudiu.beznea@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260522101815.1722909-1-claudiu.beznea@kernel.org> References: <20260522101815.1722909-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. Signed-off-by: Claudiu Beznea Reviewed-by: Frank Li --- 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 e6e05ac03082..a070db4d2440 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 Sun May 24 18:42:24 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 7E61A3CC338; Fri, 22 May 2026 10:19:17 +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=1779445161; cv=none; b=e6V1SgJjeA1nofMgKO6vq3DL8jsrF81sC+ksZRzkyLVlNAO58dxq7I77Vuu5jqw79q8fqGUwMqO4jU/xOq+gj+MzM4nSrNC9rGMr6wt2+Vm1wwNG+AyOaqmh/yfWFSNX1eUWD/YfUQNSRDZsAz6QJOn3pwL5GhUqhNhxHOYKfiY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779445161; c=relaxed/simple; bh=lT/z5Xfp2qo/mEEPD4Df20ERYvicqktVH99+TSP1XEs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JTIwi0EPqk/r8WOC40jKpgJvMvW4VYUo362VemfsXPm3xW3rqtnc5FxVFVCOOOw6r7JMLbYXpVlXLcfUye2uiw0oxOBs0TMPQmsvM20JaMDbeTckbNF2ZR4wFD3l81vfaUEq9uOdV7shl3pgX+4NxmpUEXHbu+HiuzfU89tZ8FM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VyaIQ0Me; 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="VyaIQ0Me" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0AC211F000E9; Fri, 22 May 2026 10:19:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779445156; bh=IzW7kACV2Oxk+ehTbe8c1b2lzYrTPzsmnd4TjxIv/+g=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=VyaIQ0MecAB2Ak4e/W6cpM6seljgKtOEmUqNpADbDOke70gpMBm7NYaf4xlLO5TES u2fpr8YF08yhl4Krki/ixG/ecR+cNCPZFrYZUngAubuw/Xowm/LRbwMRJgkqvfAbGG TkWm5S0rEKnCma9SQCy8yfCRoHvvrx9iNhjbHa/r+TawO9ms1YM8OKIp0Y2Jqo+Tls spSEO/bAxIpX4DFtWiDPw1UBZHlpPZ5kRhQk34Xu0ESRHVH4BFOtWfxio+vA2XJGDG AA6JBSLE0Dg/KUbav9PmCnguycli6Ay6WENuil9kmVvx17XtSd/D3g9fIb6cRkr69Q +5rWrkt1KQ02g== 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, linux-renesas-soc@vger.kernel.org, Claudiu Beznea Subject: [PATCH 17/17] i3c: renesas: Add runtime PM support Date: Fri, 22 May 2026 13:18:15 +0300 Message-ID: <20260522101815.1722909-18-claudiu.beznea@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260522101815.1722909-1-claudiu.beznea@kernel.org> References: <20260522101815.1722909-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 synchronize IRQs before runtime suspending the controller. For this, the interrupts were saved in struct renesas_i3c::irqs. Along with this, renesas_i3c_wait_xfer() return type was changed to unsigned long. Along with the clocks, the controller pin configuration is changed through the provided "sleep" pin configuration. Add runtime PM support for the Renesas I3C driver. Signed-off-by: Claudiu Beznea --- drivers/i3c/master/renesas-i3c.c | 183 ++++++++++++++++++++++++++----- 1 file changed, 156 insertions(+), 27 deletions(-) diff --git a/drivers/i3c/master/renesas-i3c.c b/drivers/i3c/master/renesas-= i3c.c index a070db4d2440..3b9807a89b54 100644 --- a/drivers/i3c/master/renesas-i3c.c +++ b/drivers/i3c/master/renesas-i3c.c @@ -21,7 +21,9 @@ #include #include #include +#include #include +#include #include #include #include "../internals.h" @@ -199,8 +201,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, @@ -254,12 +254,15 @@ struct renesas_i3c_xferqueue { =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; + int *irqs; struct renesas_i3c_xferqueue xferqueue; struct i3c_master_controller base; unsigned long rate; + unsigned int num_irqs; enum i3c_internal_state internal_state; u32 free_pos; u32 dyn_addr; @@ -268,7 +271,6 @@ struct renesas_i3c { u32 extbr; u16 maxdevs; u8 addrs[RENESAS_I3C_MAX_DEVS]; - u8 num_clks; u8 refclk_div; }; =20 @@ -433,7 +435,18 @@ 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) +{ + /* Disable all interrupts */ + renesas_writel(i3c->regs, BIE, 0); + renesas_writel(i3c->regs, NTIE, 0); + + /* Synchronize IRQs. */ + for (unsigned int i =3D 0; i < i3c->num_irqs; i++) + synchronize_irq(i3c->irqs[i]); +} + +static unsigned long renesas_i3c_wait_xfer(struct renesas_i3c *i3c, struct= renesas_i3c_xfer *xfer) { unsigned long time_left; =20 @@ -442,6 +455,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) @@ -475,6 +490,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); @@ -546,7 +567,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 @@ -617,6 +638,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)); @@ -639,6 +665,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; u32 olddevs, newdevs; u8 last_addr =3D 0, pos; int ret; @@ -651,6 +678,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 @@ -685,7 +717,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 newdevs =3D GENMASK(i3c->maxdevs - cmd->rx_count - 1, 0); newdevs &=3D ~olddevs; @@ -747,6 +781,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) { @@ -764,6 +799,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. */ @@ -798,7 +838,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) @@ -813,7 +855,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) @@ -821,6 +865,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 @@ -852,9 +901,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 @@ -863,12 +917,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; @@ -890,12 +949,17 @@ 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; + 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; + if (data->index !=3D pos) { renesas_writel(i3c->regs, DATBAS(data->index), 0); i3c->addrs[data->index] =3D 0; @@ -920,6 +984,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; + + PM_RUNTIME_ACQUIRE_IF_ENABLED_AUTOSUSPEND(i3c->dev, pm); + ret =3D PM_RUNTIME_ACQUIRE_ERR(&pm); + if (ret) + return; =20 renesas_writel(i3c->regs, DATBAS(data->index), 0); =20 @@ -937,7 +1007,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; @@ -950,6 +1022,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)) { @@ -976,7 +1053,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; @@ -985,6 +1064,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 @@ -1347,6 +1430,11 @@ static const struct renesas_i3c_irq_desc renesas_i3c= _irqs[] =3D { { .name =3D "nack", .isr =3D renesas_i3c_tend_isr, .desc =3D "i3c-nack" }, }; =20 +static void renesas_i3c_dont_use_autosuspend(void *data) +{ + pm_runtime_dont_use_autosuspend(data); +} + static int renesas_i3c_probe(struct platform_device *pdev) { struct renesas_i3c *i3c; @@ -1360,12 +1448,21 @@ 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_add_action_or_reset(&pdev->dev, renesas_i3c_dont_use_autosus= pend, + i3c->dev); + if (ret) + return ret; + + 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)) @@ -1384,19 +1481,25 @@ static int renesas_i3c_probe(struct platform_device= *pdev) if (ret) return ret; =20 + i3c->num_irqs =3D ARRAY_SIZE(renesas_i3c_irqs); + i3c->irqs =3D devm_kcalloc(&pdev->dev, i3c->num_irqs, sizeof(*i3c->irqs),= GFP_KERNEL); + if (!i3c->irqs) + return -ENOMEM; + for (i =3D 0; i < ARRAY_SIZE(renesas_i3c_irqs); i++) { const char *irqname; =20 ret =3D platform_get_irq_byname(pdev, renesas_i3c_irqs[i].name); if (ret < 0) return ret; + i3c->irqs[i] =3D 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; =20 - ret =3D devm_request_irq(&pdev->dev, ret, renesas_i3c_irqs[i].isr, + ret =3D devm_request_irq(&pdev->dev, i3c->irqs[i], renesas_i3c_irqs[i].i= sr, 0, irqname, i3c); if (ret) return ret; @@ -1432,10 +1535,14 @@ static int renesas_i3c_suspend(struct device *dev) if (ret) goto err_mark_resumed; =20 - clk_bulk_disable(i3c->num_clks, i3c->clks); + ret =3D pm_runtime_force_suspend(dev); + if (ret) + goto err_resets_deassert; =20 return 0; =20 +err_resets_deassert: + reset_control_bulk_deassert(ARRAY_SIZE(resets), resets); err_mark_resumed: i2c_mark_adapter_resumed(&i3c->base.i2c); =20 @@ -1451,17 +1558,22 @@ static int renesas_i3c_resume(struct device *dev) }; int ret; =20 + ret =3D pm_runtime_force_resume(dev); + if (ret) + return ret; + ret =3D reset_control_bulk_deassert(ARRAY_SIZE(resets), resets); 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); + PM_RUNTIME_ACQUIRE_IF_ENABLED_AUTOSUSPEND(i3c->dev, pm); + ret =3D PM_RUNTIME_ACQUIRE_ERR(&pm); if (ret) - goto err_clks_disable; + goto err_resets_asserted; =20 /* Re-store I3C registers value. */ renesas_writel(i3c->regs, STDBR, i3c->i3c_STDBR); @@ -1486,14 +1598,31 @@ static int renesas_i3c_resume(struct device *dev) */ 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 +static int renesas_i3c_runtime_suspend(struct device *dev) +{ + return pinctrl_pm_select_sleep_state(dev); +} + +static int renesas_i3c_runtime_resume(struct device *dev) +{ + return pinctrl_pm_select_default_state(dev); +} + static const struct dev_pm_ops renesas_i3c_pm_ops =3D { + RUNTIME_PM_OPS(renesas_i3c_runtime_suspend, renesas_i3c_runtime_resume, N= ULL) SYSTEM_SLEEP_PM_OPS(renesas_i3c_suspend, renesas_i3c_resume) }; =20 --=20 2.43.0