From: Frank Li <Frank.li@oss.nxp.com>
To: Shubham Patil <shubhamsanjay.patil@amd.com>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>,
Frank Li <Frank.Li@nxp.com>,
Jeremy Kerr <jk@codeconstruct.com.au>,
Matt Johnston <matt@codeconstruct.com.au>,
linux-i3c@lists.infradead.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, meaganlloyd@linux.microsoft.com,
git@amd.com
Subject: Re: [PATCH v3 2/3] i3c: dw: Track the transmit and receive buffer depths separately
Date: Tue, 24 Nov 2026 15:55:02 -0500 [thread overview]
Message-ID: <awX5plL9Ui08Ef91@lizhi-Precision-Tower-5810> (raw)
In-Reply-To: <20261124060651.1987454-3-shubhamsanjay.patil@amd.com>
On Tue, Nov 24, 2026 at 11:36:50AM +0530, Shubham Patil wrote:
> The driver currently uses the transmit buffer depth to validate both
> transmit and receive transfers. Since the transmit and receive buffers
> can have different capacities, receive transfers must instead be
> validated against the receive buffer depth.
>
> QUEUE_SIZE_CAPABILITY reports the configured size of each buffer. Take
> the receive depth from there, leave the transmit and command depths on
> the status level registers they already use, and split
> caps.datafifodepth into caps.txfifodepth and caps.rxfifodepth so that
> each direction is checked against its own buffer.
>
> That register was already defined at the right offset, but under a name
> that does not appear in the databook and with no user at all. Rename
> EXTENDED_CAPABILITY to QUEUE_SIZE_CAPABILITY and add the field
> accessor.
>
> The DesignWare I2C/I3C databook, section 11.1.58 ("QUEUE_SIZE_CAPABILITY"),
> defines RX_BUF_SIZE in bits [7:4]. The documented encodings 0 through 5
> represent 2 through 64 DWORDs, respectively, corresponding to
> 2U << RX_BUF_SIZE.
>
> Publish both depths in bytes through base.max_tx_bytes and
> base.max_rx_bytes, so that device drivers can size a transfer this
> controller will accept.
>
> Signed-off-by: Shubham Patil <shubhamsanjay.patil@amd.com>
> ---
Reviewed-by: Frank Li <Frank.Li@nxp.com>
> Changes in v3:
> - Use FIELD_GET() and a u32 variable for RX_BUF_SIZE extraction.
> - Use sizeof(u32) for byte conversion and the renamed controller fields.
> - Add the RX_BUF_SIZE encoding and databook reference.
>
> drivers/i3c/master/dw-i3c-master.c | 24 +++++++++++++++++-------
> drivers/i3c/master/dw-i3c-master.h | 3 ++-
> 2 files changed, 19 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/i3c/master/dw-i3c-master.c b/drivers/i3c/master/dw-i3c-master.c
> index d1119f203d1b..21bd94e5a6be 100644
> --- a/drivers/i3c/master/dw-i3c-master.c
> +++ b/drivers/i3c/master/dw-i3c-master.c
> @@ -203,7 +203,10 @@
> #define BUS_IDLE_TIMING 0xd8
> #define I3C_VER_ID 0xe0
> #define I3C_VER_TYPE 0xe4
> -#define EXTENDED_CAPABILITY 0xe8
> +#define QUEUE_SIZE_CAPABILITY 0xe8
> +#define QUEUE_SIZE_CAPABILITY_RX_BUF(x) FIELD_GET(GENMASK(7, 4), (x))
> +/* Sizes are encoded, 0 meaning 2 DWORDs and every further step doubling it. */
> +#define QUEUE_SIZE_TO_DWORDS(x) (2U << (x))
> #define SLAVE_CONFIG 0xec
>
> #define DYN_ADDR_LO_MASK GENMASK(4, 0)
> @@ -978,8 +981,8 @@ static int dw_i3c_master_i3c_xfers(struct i3c_dev_desc *dev,
> ntxwords += DIV_ROUND_UP(i3c_xfers[i].len, 4);
> }
>
> - if (ntxwords > master->caps.datafifodepth ||
> - nrxwords > master->caps.datafifodepth)
> + if (ntxwords > master->caps.txfifodepth ||
> + nrxwords > master->caps.rxfifodepth)
> return -EOPNOTSUPP;
>
> struct dw_i3c_xfer *xfer __free(kfree) = dw_i3c_master_alloc_xfer(master, i3c_nxfers);
> @@ -1136,8 +1139,8 @@ static int dw_i3c_master_i2c_xfers(struct i2c_dev_desc *dev,
> ntxwords += DIV_ROUND_UP(i2c_xfers[i].len, 4);
> }
>
> - if (ntxwords > master->caps.datafifodepth ||
> - nrxwords > master->caps.datafifodepth)
> + if (ntxwords > master->caps.txfifodepth ||
> + nrxwords > master->caps.rxfifodepth)
> return -EOPNOTSUPP;
>
> struct dw_i3c_xfer *xfer __free(kfree) = dw_i3c_master_alloc_xfer(master, i2c_nxfers);
> @@ -1666,7 +1669,7 @@ int dw_i3c_common_probe(struct dw_i3c_master *master,
> struct platform_device *pdev)
> {
> int ret, irq;
> - u32 thld_ctrl;
> + u32 thld_ctrl, val;
> const struct dw_i3c_drvdata *drvdata;
> unsigned long quirks = 0;
>
> @@ -1738,7 +1741,14 @@ int dw_i3c_common_probe(struct dw_i3c_master *master,
> master->caps.cmdfifodepth = QUEUE_STATUS_LEVEL_CMD(ret);
>
> ret = readl(master->regs + DATA_BUFFER_STATUS_LEVEL);
> - master->caps.datafifodepth = DATA_BUFFER_STATUS_LEVEL_TX(ret);
> + master->caps.txfifodepth = DATA_BUFFER_STATUS_LEVEL_TX(ret);
> +
> + val = readl(master->regs + QUEUE_SIZE_CAPABILITY);
> + master->caps.rxfifodepth =
> + QUEUE_SIZE_TO_DWORDS(QUEUE_SIZE_CAPABILITY_RX_BUF(val));
> +
> + master->base.max_tx_bytes = master->caps.txfifodepth * sizeof(u32);
> + master->base.max_rx_bytes = master->caps.rxfifodepth * sizeof(u32);
>
> ret = readl(master->regs + DEVICE_ADDR_TABLE_POINTER);
> master->datstartaddr = ret;
> diff --git a/drivers/i3c/master/dw-i3c-master.h b/drivers/i3c/master/dw-i3c-master.h
> index f5b4491b247a..e23554bfc5e4 100644
> --- a/drivers/i3c/master/dw-i3c-master.h
> +++ b/drivers/i3c/master/dw-i3c-master.h
> @@ -14,7 +14,8 @@
>
> struct dw_i3c_master_caps {
> u8 cmdfifodepth;
> - u8 datafifodepth;
> + u8 txfifodepth;
> + u8 rxfifodepth;
> };
>
> struct dw_i3c_dat_entry {
> --
> 2.34.1
>
next prev parent reply other threads:[~2026-11-24 20:55 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 6:06 [PATCH v3 0/3] i3c: account for controller transfer limits Shubham Patil
2026-11-24 6:06 ` [PATCH v3 1/3] i3c: Add helpers to get the maximum transfer size for a device Shubham Patil
2026-11-24 20:51 ` Frank Li
2026-11-24 6:06 ` [PATCH v3 2/3] i3c: dw: Track the transmit and receive buffer depths separately Shubham Patil
2026-11-24 20:55 ` Frank Li [this message]
2026-11-24 6:06 ` [PATCH v3 3/3] net: mctp i3c: clamp transfer lengths to the controller limits Shubham Patil
2026-11-24 21:01 ` Frank Li
2026-11-25 0:39 ` Jeremy Kerr
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=awX5plL9Ui08Ef91@lizhi-Precision-Tower-5810 \
--to=frank.li@oss.nxp.com \
--cc=Frank.Li@nxp.com \
--cc=alexandre.belloni@bootlin.com \
--cc=git@amd.com \
--cc=jk@codeconstruct.com.au \
--cc=linux-i3c@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matt@codeconstruct.com.au \
--cc=meaganlloyd@linux.microsoft.com \
--cc=netdev@vger.kernel.org \
--cc=shubhamsanjay.patil@amd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox