[PATCH v22 1/5] i3c: hub: Mark downstream DT addresses as desired on parent bus
From: Lakshay Piplani
Date: Thu Nov 19 2026 - 04:55:19 EST
I3C devices behind hub target ports share the parent controller's
dynamic address space. Their assigned dynamic addresses from Device
Tree must be preserved so that parent DAA does not allocate the same
addresses to other devices.
Previously, the hub reserved these addresses by marking the parent
bus slots as I3C_ADDR_SLOT_I3C_DEV, even though the downstream devices
were not attached to the parent bus. This could cause address
reconciliation to incorrectly treat these slots as occupied by
orphaned I3C devices.
Introduce i3c_bus_set_addr_slot_desired() to mark an address as
desired without changing its current slot status.
Use this helper when processing downstream I3C devices described in
Device Tree. This allows parent DAA to avoid the desired addresses
while keeping the slots free until the corresponding devices are
actually attached.
Keep the desired address markings for the lifetime of the parent bus,
as they represent the fixed Device Tree topology.
Signed-off-by: Lakshay Piplani <lakshay.piplani@xxxxxxx>
---
Changes in v22:
- Add a generic I3C core fix for downstream DT-assigned address handling
on the parent bus.
- Introduce i3c_bus_set_addr_slot_desired() to set
I3C_ADDR_SLOT_EXT_DESIRED without changing slot occupancy.
- Avoid treating downstream addresses as orphaned parent-bus devices
during DAA reconciliation.
- Preserve downstream address preferences across parent DAA.
---
---
drivers/i3c/hub.c | 18 +++++++++++-------
drivers/i3c/master.c | 20 ++++++++++++++++++++
include/linux/i3c/master.h | 2 ++
3 files changed, 33 insertions(+), 7 deletions(-)
diff --git a/drivers/i3c/hub.c b/drivers/i3c/hub.c
index 539028768084..95eec5b0cada 100644
--- a/drivers/i3c/hub.c
+++ b/drivers/i3c/hub.c
@@ -763,10 +763,15 @@ EXPORT_SYMBOL_GPL(i3c_hub_init);
* @hubc: I3C hub controller for a target-port virtual bus.
* @node: Target-port bus Device Tree node.
*
- * Reserve parent bus address slots for the assigned dynamic address of each
- * downstream I3C device described in the Device Tree, so that parent DAA does
- * not hand the same address to another device. Downstream devices behind hub
- * target ports share the parent controller's dynamic address space.
+ * Mark the assigned dynamic address of each downstream I3C device described in
+ * the Device Tree as desired on the parent bus, so that parent DAA avoids
+ * handing the same address to another device while it is still free.
+ * Downstream devices behind hub target ports share the parent controller's
+ * dynamic address space.
+ *
+ * A desired address is only a preference: the slot stays free, so the parent
+ * does not report it as occupied and address reconciliation does not mistake
+ * it for an orphaned device that has to be probed.
*
* The reservations describe a fixed Device Tree topology and are kept for the
* lifetime of the parent bus; they are not released when a target port is
@@ -816,9 +821,8 @@ int i3c_hub_reserve_parent_addrslots_from_dt(struct i3c_hub_controller *hubc,
status = i3c_bus_get_addr_slot_status(&parent->bus,
assigned_addr);
if (status == I3C_ADDR_SLOT_FREE)
- i3c_bus_set_addr_slot_status(&parent->bus,
- assigned_addr,
- I3C_ADDR_SLOT_I3C_DEV);
+ i3c_bus_set_addr_slot_desired(&parent->bus,
+ assigned_addr);
i3c_bus_maintenance_unlock(&parent->bus);
}
return 0;
diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c
index 9928c5dffb5b..146edbc279a3 100644
--- a/drivers/i3c/master.c
+++ b/drivers/i3c/master.c
@@ -448,6 +448,26 @@ void i3c_bus_set_addr_slot_status(struct i3c_bus *bus, u16 addr,
}
EXPORT_SYMBOL_GPL(i3c_bus_set_addr_slot_status);
+/**
+ * i3c_bus_set_addr_slot_desired() - Mark an I3C address as desired
+ * @bus: I3C bus.
+ * @addr: I3C address preferred by a device.
+ *
+ * Record that a device would like @addr without claiming that a device
+ * already uses it. Dynamic address assignment then avoids @addr while it
+ * is still free, but address reconciliation does not treat it as an
+ * orphaned device.
+ *
+ * The caller must hold the bus maintenance lock.
+ */
+void i3c_bus_set_addr_slot_desired(struct i3c_bus *bus, u16 addr)
+{
+ /* Narrow mask: set the desired flag without touching the status. */
+ i3c_bus_set_addr_slot_status_mask(bus, addr, I3C_ADDR_SLOT_EXT_DESIRED,
+ I3C_ADDR_SLOT_EXT_DESIRED);
+}
+EXPORT_SYMBOL_GPL(i3c_bus_set_addr_slot_desired);
+
static bool i3c_bus_dev_addr_is_avail(struct i3c_bus *bus, u8 addr)
{
enum i3c_addr_slot_status status;
diff --git a/include/linux/i3c/master.h b/include/linux/i3c/master.h
index d58070a72a49..6c90ccb41e49 100644
--- a/include/linux/i3c/master.h
+++ b/include/linux/i3c/master.h
@@ -793,6 +793,8 @@ i3c_bus_get_addr_slot_status(struct i3c_bus *bus, u16 addr);
void i3c_bus_set_addr_slot_status(struct i3c_bus *bus, u16 addr,
enum i3c_addr_slot_status status);
+void i3c_bus_set_addr_slot_desired(struct i3c_bus *bus, u16 addr);
+
void i3c_bus_maintenance_lock(struct i3c_bus *bus);
void i3c_bus_maintenance_unlock(struct i3c_bus *bus);
#endif /* I3C_MASTER_H */
--
2.25.1