From: Frank Li <Frank.li@oss.nxp.com>
To: Sam Agazaryan <samagazaryan@google.com>
Cc: linux-i3c@lists.infradead.org,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
Frank Li <Frank.Li@nxp.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Arnd Bergmann <arnd@arndb.de>,
Vitor Soares <vitor.soares@toradex.com>,
Oleksandr Shulzhenko <oleksandr.shulzhenko.viktorovych@intel.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 3/3] i3c: add i3cdev module to expose i3c dev in /dev
Date: Fri, 11 Sep 2026 10:10:06 -0500 [thread overview]
Message-ID: <aqQZzqJohIxBwnk0@SMW015318> (raw)
In-Reply-To: <DLC6ERLST1B6.6K3HLH38DQLK@google.com>
On Fri, Sep 11, 2026 at 03:44:40AM +0000, Sam Agazaryan wrote:
> On Wed Sep 9, 2026 at 9:51 PM UTC, Frank Li wrote:
> > On Sun, Sep 06, 2026 at 08:27:47PM +0000, Sam Agazaryan wrote:
> >> From: Vitor Soares <vitor.soares@toradex.com>
> >>
> >> This patch adds userspace character device support for I3C SDR private
> >> transfers via /dev.
> >
> > Add userspace character device ...
>
> Updated in v5.
>
>
> >>
> >> - Dynamically exposes /dev/bus/i3c/<device> character devices for I3C
> >> devices when unbound from kernel drivers.
> >> - Dynamically allocates character device minor numbers using the IDA
> >> allocator.
> >> - Implements private SDR read/write transfers via I3C_IOC_PRIV_XFER ioctl
> >> with 64-bit aligned UAPI data structures.
> >
> > Consider PRIV for SDR, need unified HDR also,
> >
> > I3C_IOC_XFER
> >
>
> At this very moment the production use case we have (OCP Recovery) supports SDR mode. That being said
> supporting HDR mode also makes sense.
>
> >> + * Copyright (c) 2020 Synopsys, Inc. and/or its affiliates.
> >
> > new post, should be 2026
>
> Updated in v5.
>
> >> +
> >> + i3cdev = kzalloc(sizeof(*i3cdev), GFP_KERNEL);
> >
> > kzalloc_obj()
> >
>
> Updated in v5.
>
> >> + dev_dbg(&i3c->dev, "Reading %zu bytes.\n", count);
> >> +
> >> + ret = i3c_device_do_xfers(i3c, &xfers, 1, I3C_SDR);
> >
> > why force to SDR here.
> >
>
> For reads and writes we don't really have an option of passing down a struct denoting cmd mode.
> Is there a different default behavior you had in mind for read/write besides SDR mode?
this is problem, Maybe we can use ioctrl to set default cmd, hdr/ sdr(default).
>
> >> +err_out:
> >> + mutex_unlock(&i3cdev->xfer_lock);
> >
> > use cleanup guard()
> >
>
> Updated in v5.
>
> >> + for (i = 0; i < nxfers; i++) {
> >> + if (xfers[i].rnw) {
> >> + if (copy_to_user(u64_to_user_ptr(xfers[i].data),
> >> + data_ptrs[i], xfers[i].len))
> >
> > Use actual_len,
> >
>
> Updated in v5.
>
> >> + ret = -EFAULT;
> >> + }
> >> + }
> >> +
> >> +err_free_mem:
> >> + for (j = 0; j < i; j++)
> >> + kfree(data_ptrs[j]);
> >> + kfree(k_xfers);
> >
> >
> > use clean up __free(kfree) when alloc.
> >
>
> Updated in v5.
>
> >> + case BUS_NOTIFY_ADD_DEVICE:
> >> + case BUS_NOTIFY_UNBOUND_DRIVER:
> >> + return i3cdev_attach(dev, NULL);
> >
> > Does all i3c devices attach this driver?
> >
>
> Just i3c target devices without a bound driver, the controller should not attach.
> The controller itself is explicitly skipped:
> if (dev->type == &i3c_masterdev_type || dev->driver)
> return 0;
How about this driver built-in and other devices build as modules, modules
load maybe later than this driver?
Frank
>
> >> +struct i3c_ioc_priv_xfer {
> >> + __u64 data;
> >> + __u16 len;
> >> + __u8 rnw;
> >
> > In HDR mode, rnw is command.
> >
>
> Addressing this in the final comment in this message alongside the rest of
> the HDR suggestions.
>
> >> + __u8 pad[5];
> >> +};
> >> +
> >> +#define I3C_PRIV_XFER_SIZE(N) \
> >> + ((((sizeof(struct i3c_ioc_priv_xfer)) * (N)) < (1 << _IOC_SIZEBITS)) \
> >> + ? ((sizeof(struct i3c_ioc_priv_xfer)) * (N)) : 0)
> >> +
> >> +#define I3C_IOC_PRIV_XFER(N) \
> >> + _IOC(_IOC_READ|_IOC_WRITE, I3C_DEV_IOC_MAGIC, 30, I3C_PRIV_XFER_SIZE(N))
> >
> > I3C_IOC_SDR_XFER, support DDR, TSP, TSL future.
> >
> > Frank
>
>
> On HDR modes - I think it makes sense to ensure the UAPI supports HDR modes now that
> they're integrated into the i3c core. Would you prefer a scheme where we pass
> in a more unified struct to specify either: SDR mode r/w or an HDR mode r/w
> with ioctl?
>
> Drawing inspiration from i3c_xfer:
>
> struct i3c_ioc_xfer {
> __u64 data;
> __u16 len;
> __u16 actual_len;
> union {
> __u8 rnw;
> __u8 cmd;
> };
> __u8 mode;
> __u8 pad[2];
> };
>
>
>
> Thanks,
> Sam
next prev parent reply other threads:[~2026-09-11 15:10 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-06 20:27 [PATCH v4 0/3] i3c: Introduce i3c device userspace interface Sam Agazaryan
2026-09-06 20:27 ` [PATCH v4 1/3] i3c: master: export i3c_masterdev_type Sam Agazaryan
2026-09-06 20:27 ` [PATCH v4 2/3] i3c: master: add i3c_for_each_dev helper Sam Agazaryan
2026-09-06 20:27 ` [PATCH v4 3/3] i3c: add i3cdev module to expose i3c dev in /dev Sam Agazaryan
2026-09-07 14:40 ` Greg Kroah-Hartman
2026-09-09 6:13 ` Sam Agazaryan
2026-09-09 21:51 ` Frank Li
2026-09-11 3:44 ` Sam Agazaryan
2026-09-11 15:10 ` Frank Li [this message]
2026-09-11 23:57 ` Sam Agazaryan
2026-09-11 19:03 ` Adrian Hunter
2026-09-14 23:46 ` Sam Agazaryan
2026-09-15 9:49 ` Adrian Hunter
2026-09-15 21:26 ` Sam Agazaryan
2026-09-11 22:05 ` Meagan Lloyd
2026-09-12 0:12 ` Sam Agazaryan
2026-09-17 22:27 ` Meagan Lloyd
2026-09-18 18:59 ` Meagan Lloyd
2026-09-18 20:21 ` Greg Kroah-Hartman
2026-09-18 22:47 ` Sam Agazaryan
2026-09-08 11:48 ` [PATCH v4 0/3] i3c: Introduce i3c device userspace interface Wolfram Sang
2026-09-12 11:12 ` Wolfram Sang
2026-09-14 20:58 ` Sam Agazaryan
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=aqQZzqJohIxBwnk0@SMW015318 \
--to=frank.li@oss.nxp.com \
--cc=Frank.Li@nxp.com \
--cc=alexandre.belloni@bootlin.com \
--cc=arnd@arndb.de \
--cc=gregkh@linuxfoundation.org \
--cc=linux-i3c@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=oleksandr.shulzhenko.viktorovych@intel.com \
--cc=samagazaryan@google.com \
--cc=vitor.soares@toradex.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
all inboxes | Powered by JetHome®