i3c: dw: fix slave device setup after DAA

i3c_master_add_i3c_dev_locked() incorrectly set master->this to the
newly discovered slave device, causing i3c_master_attach_i3c_dev()
to skip the attach_i3c_dev() callback. As a result the slave device
never got its master_priv (DAT slot index) allocated, free_pos was
never updated, and the DAT entry was never written.

Fix by removing the incorrect master->this assignment. Store the
slave descriptor directly in master->i3cdev[pos] inside
dw_i3c_master_attach_i3c_dev() where the DAT slot index is already
known. Also check the return value of i3c_master_add_i3c_dev_locked()
and skip num_i3cdevs increment on failure, fixing dummy devices shown
when no slaves are present on the bus.

Fixes: 1009c96f15 ("drivers: i3c: Add driver for MIPI DWI3C")
Signed-off-by: Pranav Tilak <pranav.vinaytilak@amd.com>
Reviewed-by: Dinesh Maniyam <dinesh.maniyam@altera.com>
This commit is contained in:
Pranav Tilak
2026-07-22 13:10:21 -06:00
committed by Tom Rini
parent 331d9b8cf6
commit 57b60ccd79
2 changed files with 3 additions and 3 deletions
-1
View File
@@ -1443,7 +1443,6 @@ int i3c_master_add_i3c_dev_locked(struct i3c_master_controller *master,
if (IS_ERR(newdev))
return PTR_ERR(newdev);
master->this = newdev;
ret = i3c_master_attach_i3c_dev(master, newdev);
if (ret)
goto err_free_dev;
+3 -2
View File
@@ -671,8 +671,8 @@ static int dw_i3c_master_daa(struct i3c_master_controller *m)
for (pos = 0; pos < master->maxdevs; pos++) {
if (newdevs & BIT(pos)) {
i3c_master_add_i3c_dev_locked(m, master->addrs[pos]);
master->i3cdev[pos] = m->this;
if (i3c_master_add_i3c_dev_locked(m, master->addrs[pos]))
continue;
master->num_i3cdevs++;
}
}
@@ -806,6 +806,7 @@ static int dw_i3c_master_attach_i3c_dev(struct i3c_dev_desc *dev)
master->addrs[pos] = dev->info.dyn_addr ? : dev->info.static_addr;
master->free_pos &= ~BIT(pos);
i3c_dev_set_master_data(dev, data);
master->i3cdev[pos] = dev;
writel(DEV_ADDR_TABLE_DYNAMIC_ADDR(master->addrs[pos]),
master->regs +