From: Frank Li <Frank.li@nxp.com>
To: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: "Alexandre Belloni" <alexandre.belloni@bootlin.com>,
"Miquel Raynal" <miquel.raynal@bootlin.com>,
"Jonathan Cameron" <jic23@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org,
imx@lists.linux.dev, linux-iio@vger.kernel.org,
joshua.yeong@starfivetech.com, devicetree@vger.kernel.org
Subject: Re: [PATCH v6 1/5] i3c: Add HDR API support
Date: Thu, 23 Oct 2025 11:18:37 -0400 [thread overview]
Message-ID: <aPpHTej/vKfiN68k@lizhi-Precision-Tower-5810> (raw)
In-Reply-To: <aPnmCwwZVZ5egqkP@smile.fi.intel.com>
On Thu, Oct 23, 2025 at 11:23:39AM +0300, Andy Shevchenko wrote:
> On Tue, Oct 14, 2025 at 12:40:00PM -0400, Frank Li wrote:
> > Rename struct i3c_priv_xfer to struct i3c_xfer, since private xfer in the
> > I3C spec refers only to SDR transfers. Ref: i3c spec ver1.2, section 3,
> > Technical Overview.
> >
> > i3c_xfer will be used for both SDR and HDR.
> >
> > Rename enum i3c_hdr_mode to i3c_xfer_mode. Previous definition need match
> > CCC GET_CAP1 bit position. Use 31 as SDR transfer mode.
> >
> > Add i3c_device_do_xfers() with an xfer mode argument, while keeping
> > i3c_device_do_priv_xfers() as a wrapper that calls i3c_device_do_xfers()
> > with I3C_SDR for backward compatibility.
> >
> > Introduce a 'cmd' field in struct i3c_xfer as an anonymous union with
> > 'rnw', since HDR mode uses read/write commands instead of the SDR address
> > bit.
> >
> > Add .i3c_xfers() callback for master controllers. If not implemented, fall
> > back to SDR with .priv_xfers(). The .priv_xfers() API can be removed once
> > all controllers switch to .i3c_xfers().
> >
> > Add 'mode_mask' bitmask to advertise controller capability.
>
> ...
>
> > static int i3c_master_check_ops(const struct i3c_master_controller_ops *ops)
> > {
> > - if (!ops || !ops->bus_init || !ops->priv_xfers ||
> > + if (!ops || !ops->bus_init ||
> > !ops->send_ccc_cmd || !ops->do_daa || !ops->i2c_xfers)
> > return -EINVAL;
> >
> > + if (!ops->priv_xfers && !ops->i3c_xfers)
> > + return -EINVAL;
>
> I would find the logically coupled proto-based xfers:
>
> if (!ops->i2c_xfers && !ops->i3c_xfers)
> return -EINVAL;
Not exactly, priv_xfers is old API, which supported now. I plan remove it
after remove all from i3c master controller driver after this patch merged.
i2c_xfers: must be no NULL
priv_xfers and i3c_xfers, one of both should be no NULL.
i2c_xfer is NULL, should be return -EINVAL, but you logic may success if
i3c_xfers is not NULL.
>
>
> > if (ops->request_ibi &&
> > (!ops->enable_ibi || !ops->disable_ibi || !ops->free_ibi ||
> > !ops->recycle_ibi_slot))
>
> > }
>
> ...
>
> > -enum i3c_hdr_mode {
> > +enum i3c_xfer_mode {
> > + /* The below 3 value (I3C_HDR*) must match GETCAP1 Byte bit position */
> > I3C_HDR_DDR,
> > I3C_HDR_TSP,
> > I3C_HDR_TSL,
> > + /* Use for default SDR transfer mode */
> > + I3C_SDR = 0x31,
>
> Why has this a specific value, while the rest have not? If it's HW mandated,
> the all of them has to be assigned properly to avoid potential bugs.
>
> > };
>
> ...
>
> > /**
> > - * struct i3c_priv_xfer - I3C SDR private transfer
> > + * struct i3c_xfer - I3C data transfer
> > * @rnw: encodes the transfer direction. true for a read, false for a write
> > + * @cmd: Read/Write command in HDR mode, read: 0x80 - 0xff, write: 0x00 - 0x7f
> > * @len: transfer length in bytes of the transfer
> > * @actual_len: actual length in bytes are transferred by the controller
> > * @data: input/output buffer
>
> > * @data.out: output buffer. Must point to a DMA-able buffer
> > * @err: I3C error code
> > */
> > -struct i3c_priv_xfer {
> > - u8 rnw;
> > +struct i3c_xfer {
> > + union {
> > + u8 rnw;
> > + u8 cmd;
> > + };
>
> What field is used to distinguish the union member in current use?
> In another word, union must be accompanied with a selector.
This struct use only for i3c_device_do_xfers(), which pass i3c_xfer_mode
informaiton. argument 'mode' will distrigiush rnw/cmd.
i3c_xfer[] array don't allow switch transfer mode during whole i3c
transcation. So doesn't put mode in here.
>
> > u16 len;
> > u16 actual_len;
> > union {
>
> > enum i3c_error_code err;
> > };
>
> ...
>
> > +/* keep back compatible */
> > +#define i3c_priv_xfer i3c_xfer
>
> How many of the current users do this? Can't we just rename treewide?
git grep -r priv_xfer drivers/
drivers/base/regmap/regmap-i3c.c: struct i3c_priv_xfer xfers[] = {
drivers/base/regmap/regmap-i3c.c: return i3c_device_do_priv_xfers(i3c, xfers, 1);
drivers/base/regmap/regmap-i3c.c: struct i3c_priv_xfer xfers[2];
drivers/base/regmap/regmap-i3c.c: return i3c_device_do_priv_xfers(i3c, xfers, 2);
drivers/hwmon/lm75.c: struct i3c_priv_xfer xfers[] = {
drivers/hwmon/lm75.c: ret = i3c_device_do_priv_xfers(i3cdev, xfers, 2);
drivers/hwmon/lm75.c: struct i3c_priv_xfer xfers[] = {
drivers/hwmon/lm75.c: return i3c_device_do_priv_xfers(i3cdev, xfers, 1);
drivers/i3c/device.c:int i3c_device_do_xfers(struct i3c_device *dev, struct i3c_priv_xfer *xfers,
drivers/i3c/master.c: if (!ops->priv_xfers && !ops->i3c_xfers)
drivers/i3c/master.c: if (!master->ops->priv_xfers)
drivers/i3c/master.c: return master->ops->priv_xfers(dev, xfers, nxfers);
drivers/i3c/master/dw-i3c-master.c:static int dw_i3c_master_priv_xfers(struct i3c_dev_desc *dev,
drivers/i3c/master/dw-i3c-master.c: struct i3c_priv_xfer *i3c_xfers,
drivers/i3c/master/dw-i3c-master.c: .priv_xfers = dw_i3c_master_priv_xfers,
drivers/i3c/master/i3c-master-cdns.c:static int cdns_i3c_master_priv_xfers(struct i3c_dev_desc *dev,
drivers/i3c/master/i3c-master-cdns.c: struct i3c_priv_xfer *xfers,
drivers/i3c/master/i3c-master-cdns.c: .priv_xfers = cdns_i3c_master_priv_xfers,
drivers/i3c/master/mipi-i3c-hci/core.c:static int i3c_hci_priv_xfers(struct i3c_dev_desc *dev,
drivers/i3c/master/mipi-i3c-hci/core.c: struct i3c_priv_xfer *i3c_xfers,
drivers/i3c/master/mipi-i3c-hci/core.c: .priv_xfers = i3c_hci_priv_xfers,
drivers/i3c/master/renesas-i3c.c:static int renesas_i3c_priv_xfers(struct i3c_dev_desc *dev, struct i3c_priv_xfer *i3c_xfers,
drivers/i3c/master/renesas-i3c.c: .priv_xfers = renesas_i3c_priv_xfers,
drivers/i3c/master/svc-i3c-master.c: struct i3c_priv_xfer *xfer;
drivers/i3c/master/svc-i3c-master.c: * at svc_i3c_master_priv_xfers().
drivers/i3c/master/svc-i3c-master.c:static int svc_i3c_master_i3c_xfers(struct i3c_dev_desc *dev, struct i3c_priv_xfer *xfers,
drivers/net/mctp/mctp-i3c.c: struct i3c_priv_xfer xfer = { .rnw = 1, .len = mi->mrl };
drivers/net/mctp/mctp-i3c.c: rc = i3c_device_do_priv_xfers(mi->i3c, &xfer, 1);
drivers/net/mctp/mctp-i3c.c: struct i3c_priv_xfer xfer = { .rnw = false };
drivers/net/mctp/mctp-i3c.c: rc = i3c_device_do_priv_xfers(mi->i3c, &xfer, 1);
After this patch merged, I can clean up it at difference subsytem. After
all cleanup done, we can safely remove this define.
Frank
>
> --
> With Best Regards,
> Andy Shevchenko
>
>
next prev parent reply other threads:[~2025-10-23 15:18 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-14 16:39 [PATCH v6 0/5] i3c: Add basic HDR mode support Frank Li
2025-10-14 16:40 ` [PATCH v6 1/5] i3c: Add HDR API support Frank Li
2025-10-23 8:23 ` Andy Shevchenko
2025-10-23 15:18 ` Frank Li [this message]
2025-10-23 18:22 ` Andy Shevchenko
2025-10-23 23:53 ` Frank Li
2025-10-24 6:13 ` Andy Shevchenko
2025-10-24 14:03 ` Frank Li
2025-10-24 16:03 ` Andy Shevchenko
2025-10-24 16:29 ` Frank Li
2025-10-24 21:12 ` Alexandre Belloni
2025-10-14 16:40 ` [PATCH v6 2/5] i3c: master: svc: Replace bool rnw with union for HDR support Frank Li
2025-10-23 8:26 ` Andy Shevchenko
2025-10-23 15:21 ` Frank Li
2025-10-14 16:40 ` [PATCH v6 3/5] i3c: master: svc: Add basic HDR mode support Frank Li
2025-10-23 8:29 ` Andy Shevchenko
2025-10-23 15:24 ` Frank Li
2025-10-23 18:25 ` Andy Shevchenko
2025-10-23 23:44 ` Frank Li
2025-10-14 16:40 ` [PATCH v6 4/5] dt-bindings: trivial-devices: add MEMSIC 3-axis magnetometer Frank Li
2025-10-14 16:40 ` [PATCH v6 5/5] iio: magnetometer: Add mmc5633 sensor Frank Li
2025-10-18 16:52 ` Jonathan Cameron
2025-10-18 16:54 ` Jonathan Cameron
2025-10-23 8:46 ` Andy Shevchenko
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=aPpHTej/vKfiN68k@lizhi-Precision-Tower-5810 \
--to=frank.li@nxp.com \
--cc=alexandre.belloni@bootlin.com \
--cc=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=imx@lists.linux.dev \
--cc=jic23@kernel.org \
--cc=joshua.yeong@starfivetech.com \
--cc=krzk+dt@kernel.org \
--cc=linux-i3c@lists.infradead.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=miquel.raynal@bootlin.com \
--cc=nuno.sa@analog.com \
--cc=robh@kernel.org \
/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