[PATCH v19 6/8] i3c: hub: Add support for the I3C interface in the I3C hub

Alexandre Belloni alexandre.belloni at bootlin.com
Mon Sep 21 14:15:13 PDT 2026


On 16/09/2026 12:37:26+0530, Lakshay Piplani wrote:
> Add virtual I3C bus support for the hub and provide interface to enable
> or disable downstream ports.
> 
> Signed-off-by: Aman Kumar Pandey <aman.kumarpandey at nxp.com>
> Signed-off-by: Vikash Bansal <vikash.bansal at nxp.com>
> Signed-off-by: Lakshay Piplani <lakshay.piplani at nxp.com>
> Reviewed-by: Frank Li <Frank.Li at nxp.com>
> 
> ---
> Changes in v19:
>  - No change
> 
> Changes in v18:
>  - Rebased onto v7.3-rc1; no intended driver behaviour changes
> 
> Changes in v17:
>  - Move the lockdep-only routing-lock class assignment into a dedicated
>    helper, leaving hub context initialization unconditional when
>    CONFIG_LOCKDEP is disabled
>  - Document that hub_dev must already be registered and remove the
>    WARN_ON_ONCE checks for its descriptor and parent controller
>  - Export i3c_hub_master_ops as a const object and reference it directly
>    instead of returning it through an accessor
>  - Document that downstream ports share the parent controller's dynamic
>    address domain and that independent per-port DAA domains are not
>    provided
>  - Document that a broadcast CCC on a virtual bus reaches the parent bus
>    and devices behind other connected ports; directed CCCs must be used
>    for per-device scope
>  - Document that fixed-DT address reservations remain allocated for the
>    lifetime of the parent bus, are reused across driver reprobes, and
>    that downstream hot-join support would also require reserving static
>    addresses
> 
> Changes in v16:
>  - Fix the lockdep "recursive locking" false positive on the forwarding path
>    (holding the virtual bus lock while taking the parent bus lock, both
>    sharing one class). Introduce per-nesting-depth lock_class_key arrays for
>    the bus lock and the routing mutex, computed via
>    i3c_hub_controller_depth(), assigned in i3c_hub_master_bus_init() and
>    i3c_hub_init()
>  - Fix the parent-bus dynamic-address reservation: reserve by
>    "assigned-address" regardless of the static address (the old
>    static_addr != assigned_addr skip left addresses free and risked ENTDAA
>    collisions). Reserve only when the slot is currently FREE, under the
>    parent bus maintenance lock
>  - Make the reattach info update atomic w.r.t. asynchronous IBI: update
>    parent_desc.info under i3c_bus_maintenance_lock(&parent->bus) and reject
>    reattach with -EBUSY (WARN_ON_ONCE) while parent_desc.ibi is live
>  - Document and check the detach-time IBI lifecycle invariant:
>    parent_desc.ibi must already have been cleared through i3c_hub_free_ibi()
>    before the parent-facing descriptor is detached and freed. Add
>    WARN_ON_ONCE() to detect a violation. The underlying generic I3C-core
>    unregister/IBI-quiesce behaviour is a known I3C-core limitation
>  - Document that DAA is intentionally run on the parent controller because
>    downstream devices share the parent's dynamic-address space; broadcast
>    RSTDAA is intentionally not forwarded (would reset the hub address)
> 
> Changes in v15:
>  - Replace temporary descriptor reparenting and hub-address switching with
>    a permanent parent-facing descriptor for each downstream I3C device
>  - Keep the logical device descriptor associated with the virtual hub
>    controller while using the parent-facing descriptor for physical
>    controller operations
>  - Implement downstream device attach, reattach and detach using the new
>    controller-only helpers
>  - Forward IBI slot recycling to the physical parent controller
>  - Remove the helper that temporarily changed the logical descriptor's
>    master pointer
> 
> Changes in v14:
>  - Add hub route serialization around DAA, CCC, private transfer and IBI paths
>  - Add comments explaining that downstream devices behind hub target ports
>    share the parent controller address space
>  - Use i3c_bus_maintenance_lock()/unlock() instead of raw parent bus lock
>    operations
>  - Hold the parent maintenance lock across temporary hub address reattach,
>    transfer and address restore
>  - Rework IBI request/free forwarding, so downstream devices are temporarily
>    attached to the parent controller for IBI setup
>  - Clean up the preallocated virtual IBI object and workqueue before forwarding
>    the IBI request to the parent controller
>  - Avoid NULL dereference in the core IBI free path when the forwarding
>    callback has already cleared dev->ibi
> 
> Changes in v13:
>  - Reserve parent I3C bus address slots for downstream devices with matching static and
>    assigned addresses by parsing target-port DT nodes
>  - Keep broadcast RSTDAA blocked and add explanatory comment
>  - Add TODO for empty IBI slot recycle callback
>  - Add comments for intentional no-op callbacks
> 
> Changes in v12:
>  - Drop redundant depends on I3C from config I3C_HUB
>  - Return -EOPNOTSUPP for unsupported I2C transfers instead of reporting
>    success.
> 
> Changes in v11:
>  - Fix virtual hub address reattach handling
>  - Fix parent bus locking during address reattach operations
>  - Improve transfer and IBI request error handling
> 
> Changes in v10:
>  - Remove unnecessary ibi_lock handling in request/enable/disable/free
>    IBI APIs
>  - Remove redundant parent pointer from struct i3c_hub and derive upstream
>    master from hub_dev
> 
> Changes in v9:
>  - No change
> 
> Changes in v8:
>  - No change
> 
> Changes in v7:
>  - Convert Kconfig option to tristate
>  - Fix signedness issue in return value
>  - Fix kernel-doc warnings
> 
> Changes in v6:
>  - Add support for the generic I3C interface in the I3C Hub
> ---
> ---
>  MAINTAINERS             |   2 +
>  drivers/i3c/Kconfig     |  14 +
>  drivers/i3c/Makefile    |   1 +
>  drivers/i3c/hub.c       | 832 ++++++++++++++++++++++++++++++++++++++++
>  include/linux/i3c/hub.h |  92 +++++
>  5 files changed, 941 insertions(+)
>  create mode 100644 drivers/i3c/hub.c
>  create mode 100644 include/linux/i3c/hub.h
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 514cda5088ba..142b0f7636c1 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -19766,8 +19766,10 @@ L:	linux-kernel at vger.kernel.org
>  L:	linux-i3c at lists.infradead.org
>  S:	Maintained
>  F:	Documentation/devicetree/bindings/i3c/nxp,p3h2840.yaml
> +F:	drivers/i3c/hub.c
>  F:	drivers/mfd/p3h2840.c
>  F:	drivers/regulator/p3h2840_i3c_hub_regulator.c
> +F:	include/linux/i3c/hub.h
>  F:	include/linux/mfd/p3h2840.h

This should be moved to 7/8 so it can be applied independently of the
p3h2840 driver itself. I'm ready to take 1,2 and 6 but to be able to
apply the rest, I need an ack from Lee on 4/8.


-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com



More information about the linux-i3c mailing list