]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
i3c: dw: fix slave device setup after DAA
authorPranav Tilak <pranav.vinaytilak@amd.com>
Thu, 9 Jul 2026 09:12:55 +0000 (14:42 +0530)
committerTom Rini <trini@konsulko.com>
Wed, 22 Jul 2026 19:10:21 +0000 (13:10 -0600)
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: 1009c96f1590 ("drivers: i3c: Add driver for MIPI DWI3C")
Signed-off-by: Pranav Tilak <pranav.vinaytilak@amd.com>
Reviewed-by: Dinesh Maniyam <dinesh.maniyam@altera.com>
drivers/i3c/master.c
drivers/i3c/master/dw-i3c-master.c

index 019167a2dc5149410fbaeb76f203ef91b69d3067..1cf1ffd99ccca3e6075bd6d53c2a956dc08c8041 100644 (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;
index c6ce54a1d3be6bdf230f3f47b017df0971de4a9e..25933adf010b1dff0c3aeac4b2ee372fb0089543 100644 (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 +