All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Jeffery <andrew@codeconstruct.com.au>
To: "Frank Li" <Frank.Li@nxp.com>,
	"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>
Cc: 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,
	linux@roeck-us.net
Subject: Re: [PATCH v11 1/6] i3c: Add HDR API support
Date: Thu, 04 Dec 2025 10:47:57 +1030	[thread overview]
Message-ID: <16428df229c494c807ddc75009feffe219f11a22.camel@codeconstruct.com.au> (raw)
In-Reply-To: <20251106-i3c_ddr-v11-1-33a6a66ed095@nxp.com>

Hi Frank,

On Thu, 2025-11-06 at 12:36 -0500, 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.
> 
> Signed-off-by: Frank Li <Frank.Li@nxp.com>
> ---
> Why not add hdr mode in struct i3c_priv_xfer because mode can't be mixed in
> one i3c transfer. for example, can't send a HDR follow one SDR between
> START and STOP.
> 
> i3c_priv_xfer should be treat as whole i3c transactions. If user want send
> HDR follow SDR, should be call i3c_device_do_priv_xfers_mode() twice,
> instead put into a big i3c_priv_xfer[n].
> 
> change in v9
> - fix typo Deprecated
> - remove reduntant master->ops->priv_xfers check.
> 
> change in v8
> - new API use i3c_xfer instead of i3c_priv_xfer.
> 
> change in v7
> - explicit set enum I3C_HDR_* to value, which spec required.
> - add comments about check priv_xfers and i3c_xfers
> 
> change in v5-v6
> - none
> 
> change in v4
> - Rename enum i3c_hdr_mode to i3c_xfer_mode.
> 
> change in v3
> - Add Deprecated comment for priv_xfers.
> 
> change in v2
> - don't use 'priv_' since it is refer to sdr mode transfer in spec.
> - add 'mode_mask' indicate controller's capibility.
> - add helper function to check master's supported transfer mode.
> ---
>  drivers/i3c/device.c       | 27 ++++++++++++++++++++-------
>  drivers/i3c/internals.h    |  6 +++---
>  drivers/i3c/master.c       | 19 ++++++++++++++-----
>  include/linux/i3c/device.h | 40 +++++++++++++++++++++++++++++-----------
>  include/linux/i3c/master.h |  4 ++++
>  5 files changed, 70 insertions(+), 26 deletions(-)
> 

*snip*

>  
> diff --git a/include/linux/i3c/device.h b/include/linux/i3c/device.h
> index 7f136de4b73ef839fb4a1837a87b1aebbddbfe93..7f7738041f3809e538816e94f90b99e58eb806f9 100644
> --- a/include/linux/i3c/device.h
> +++ b/include/linux/i3c/device.h
> @@ -39,20 +39,25 @@ enum i3c_error_code {
>  };
>  
>  /**
> - * enum i3c_hdr_mode - HDR mode ids
> + * enum i3c_xfer_mode - I3C xfer mode ids
>   * @I3C_HDR_DDR: DDR mode
>   * @I3C_HDR_TSP: TSP mode
>   * @I3C_HDR_TSL: TSL mode
> + * @I3C_SDR: SDR mode (NOT HDR mode)
>   */
> -enum i3c_hdr_mode {
> -	I3C_HDR_DDR,
> -	I3C_HDR_TSP,
> -	I3C_HDR_TSL,
> +enum i3c_xfer_mode {
> +	/* The below 3 value (I3C_HDR*) must match GETCAP1 Byte bit position */
> +	I3C_HDR_DDR = 0,
> +	I3C_HDR_TSP = 1,
> +	I3C_HDR_TSL = 2,
> +	/* Use for default SDR transfer mode */
> +	I3C_SDR = 0x31,

0x31 is 49 - is that really what you intend here? For instance,
building this patch for ARM32 produces:

   In file included from ../include/linux/bits.h:5,
                    from ../include/linux/ratelimit_types.h:5,
                    from ../include/linux/printk.h:9,
                    from ../include/asm-generic/bug.h:31,
                    from ../arch/arm/include/asm/bug.h:60,
                    from ../include/linux/bug.h:5,
                    from ../drivers/i3c/device.c:9:
   ../drivers/i3c/device.c: In function ‘i3c_device_get_supported_xfer_mode’:
   ../include/vdso/bits.h:7:40: warning: left shift count >= width of type [-Wshift-count-overflow]
       7 | #define BIT(nr)                 (UL(1) << (nr))
         |                                        ^~
   ../drivers/i3c/device.c:272:68: note: in expansion of macro ‘BIT’
     272 |         return i3c_dev_get_master(dev->desc)->this->info.hdr_cap | BIT(I3C_SDR);
         |                                                                    ^~~

Should this be decimal 31, rather than hex 31?

Andrew

WARNING: multiple messages have this Message-ID (diff)
From: Andrew Jeffery <andrew@codeconstruct.com.au>
To: "Frank Li" <Frank.Li@nxp.com>,
	"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>
Cc: 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,
	linux@roeck-us.net
Subject: Re: [PATCH v11 1/6] i3c: Add HDR API support
Date: Thu, 04 Dec 2025 10:47:57 +1030	[thread overview]
Message-ID: <16428df229c494c807ddc75009feffe219f11a22.camel@codeconstruct.com.au> (raw)
In-Reply-To: <20251106-i3c_ddr-v11-1-33a6a66ed095@nxp.com>

Hi Frank,

On Thu, 2025-11-06 at 12:36 -0500, 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.
> 
> Signed-off-by: Frank Li <Frank.Li@nxp.com>
> ---
> Why not add hdr mode in struct i3c_priv_xfer because mode can't be mixed in
> one i3c transfer. for example, can't send a HDR follow one SDR between
> START and STOP.
> 
> i3c_priv_xfer should be treat as whole i3c transactions. If user want send
> HDR follow SDR, should be call i3c_device_do_priv_xfers_mode() twice,
> instead put into a big i3c_priv_xfer[n].
> 
> change in v9
> - fix typo Deprecated
> - remove reduntant master->ops->priv_xfers check.
> 
> change in v8
> - new API use i3c_xfer instead of i3c_priv_xfer.
> 
> change in v7
> - explicit set enum I3C_HDR_* to value, which spec required.
> - add comments about check priv_xfers and i3c_xfers
> 
> change in v5-v6
> - none
> 
> change in v4
> - Rename enum i3c_hdr_mode to i3c_xfer_mode.
> 
> change in v3
> - Add Deprecated comment for priv_xfers.
> 
> change in v2
> - don't use 'priv_' since it is refer to sdr mode transfer in spec.
> - add 'mode_mask' indicate controller's capibility.
> - add helper function to check master's supported transfer mode.
> ---
>  drivers/i3c/device.c       | 27 ++++++++++++++++++++-------
>  drivers/i3c/internals.h    |  6 +++---
>  drivers/i3c/master.c       | 19 ++++++++++++++-----
>  include/linux/i3c/device.h | 40 +++++++++++++++++++++++++++++-----------
>  include/linux/i3c/master.h |  4 ++++
>  5 files changed, 70 insertions(+), 26 deletions(-)
> 

*snip*

>  
> diff --git a/include/linux/i3c/device.h b/include/linux/i3c/device.h
> index 7f136de4b73ef839fb4a1837a87b1aebbddbfe93..7f7738041f3809e538816e94f90b99e58eb806f9 100644
> --- a/include/linux/i3c/device.h
> +++ b/include/linux/i3c/device.h
> @@ -39,20 +39,25 @@ enum i3c_error_code {
>  };
>  
>  /**
> - * enum i3c_hdr_mode - HDR mode ids
> + * enum i3c_xfer_mode - I3C xfer mode ids
>   * @I3C_HDR_DDR: DDR mode
>   * @I3C_HDR_TSP: TSP mode
>   * @I3C_HDR_TSL: TSL mode
> + * @I3C_SDR: SDR mode (NOT HDR mode)
>   */
> -enum i3c_hdr_mode {
> -	I3C_HDR_DDR,
> -	I3C_HDR_TSP,
> -	I3C_HDR_TSL,
> +enum i3c_xfer_mode {
> +	/* The below 3 value (I3C_HDR*) must match GETCAP1 Byte bit position */
> +	I3C_HDR_DDR = 0,
> +	I3C_HDR_TSP = 1,
> +	I3C_HDR_TSL = 2,
> +	/* Use for default SDR transfer mode */
> +	I3C_SDR = 0x31,

0x31 is 49 - is that really what you intend here? For instance,
building this patch for ARM32 produces:

   In file included from ../include/linux/bits.h:5,
                    from ../include/linux/ratelimit_types.h:5,
                    from ../include/linux/printk.h:9,
                    from ../include/asm-generic/bug.h:31,
                    from ../arch/arm/include/asm/bug.h:60,
                    from ../include/linux/bug.h:5,
                    from ../drivers/i3c/device.c:9:
   ../drivers/i3c/device.c: In function ‘i3c_device_get_supported_xfer_mode’:
   ../include/vdso/bits.h:7:40: warning: left shift count >= width of type [-Wshift-count-overflow]
       7 | #define BIT(nr)                 (UL(1) << (nr))
         |                                        ^~
   ../drivers/i3c/device.c:272:68: note: in expansion of macro ‘BIT’
     272 |         return i3c_dev_get_master(dev->desc)->this->info.hdr_cap | BIT(I3C_SDR);
         |                                                                    ^~~

Should this be decimal 31, rather than hex 31?

Andrew

-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

  reply	other threads:[~2025-12-04  0:18 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-06 17:35 [PATCH v11 0/6] i3c: Add basic HDR mode support Frank Li
2025-11-06 17:35 ` Frank Li
2025-11-06 17:36 ` [PATCH v11 1/6] i3c: Add HDR API support Frank Li
2025-11-06 17:36   ` Frank Li
2025-12-04  0:17   ` Andrew Jeffery [this message]
2025-12-04  0:17     ` Andrew Jeffery
2025-12-04  1:22     ` Frank Li
2025-12-04  1:22       ` Frank Li
2025-11-06 17:36 ` [PATCH v11 2/6] i3c: Switch to use new i3c_xfer from i3c_priv_xfer Frank Li
2025-11-06 17:36   ` Frank Li
2025-11-06 17:36 ` [PATCH v11 3/6] i3c: master: svc: Replace bool rnw with union for HDR support Frank Li
2025-11-06 17:36   ` Frank Li
2025-11-06 17:36 ` [PATCH v11 4/6] i3c: master: svc: Add basic HDR mode support Frank Li
2025-11-06 17:36   ` Frank Li
2025-11-06 17:36 ` [PATCH v11 5/6] dt-bindings: trivial-devices: add MEMSIC 3-axis magnetometer Frank Li
2025-11-06 17:36   ` Frank Li
2025-11-06 17:36 ` [PATCH v11 6/6] iio: magnetometer: Add mmc5633 sensor Frank Li
2025-11-06 17:36   ` Frank Li
2025-11-09 13:57   ` Jonathan Cameron
2025-11-09 13:57     ` Jonathan Cameron
2025-12-18 10:10     ` Alexandre Belloni
2025-12-18 10:10       ` Alexandre Belloni
2025-12-02 17:07 ` (subset) [PATCH v11 0/6] i3c: Add basic HDR mode support Alexandre Belloni
2025-12-02 17:07   ` Alexandre Belloni

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=16428df229c494c807ddc75009feffe219f11a22.camel@codeconstruct.com.au \
    --to=andrew@codeconstruct.com.au \
    --cc=Frank.Li@nxp.com \
    --cc=alexandre.belloni@bootlin.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=linux@roeck-us.net \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.