U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Pranav Tilak <pranav.vinaytilak@amd.com>
To: <u-boot@lists.denx.de>, <michal.simek@amd.com>
Cc: <git@amd.com>, <padmarao.begari@amd.com>,
	Pranav Tilak <pranav.vinaytilak@amd.com>,
	Dinesh <dinesh.maniyam@altera.com>, Tom Rini <trini@konsulko.com>
Subject: [PATCH v2 4/4] i3c: dw: fix slave device setup after DAA
Date: Thu, 9 Jul 2026 14:42:55 +0530	[thread overview]
Message-ID: <20260709091357.1860417-5-pranav.vinaytilak@amd.com> (raw)
In-Reply-To: <20260709091357.1860417-1-pranav.vinaytilak@amd.com>

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>
---
 drivers/i3c/master.c               | 1 -
 drivers/i3c/master/dw-i3c-master.c | 5 +++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c
index 019167a2dc5..1cf1ffd99cc 100644
--- a/drivers/i3c/master.c
+++ b/drivers/i3c/master.c
@@ -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;
diff --git a/drivers/i3c/master/dw-i3c-master.c b/drivers/i3c/master/dw-i3c-master.c
index c6ce54a1d3b..25933adf010 100644
--- a/drivers/i3c/master/dw-i3c-master.c
+++ b/drivers/i3c/master/dw-i3c-master.c
@@ -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 +
-- 
2.34.1


      parent reply	other threads:[~2026-07-09  9:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-09  9:12 [PATCH v2 0/4] i3c: dw: fix slave device setup and probe issues Pranav Tilak
2026-07-09  9:12 ` [PATCH v2 1/4] i3c: dw: make resets optional in probe Pranav Tilak
2026-07-09  9:12 ` [PATCH v2 2/4] cmd: i3c: fix list and current needing pre-selected controller Pranav Tilak
2026-07-09  9:12 ` [PATCH v2 3/4] configs: versal2: enable I3C support Pranav Tilak
2026-07-09  9:12 ` Pranav Tilak [this message]

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=20260709091357.1860417-5-pranav.vinaytilak@amd.com \
    --to=pranav.vinaytilak@amd.com \
    --cc=dinesh.maniyam@altera.com \
    --cc=git@amd.com \
    --cc=michal.simek@amd.com \
    --cc=padmarao.begari@amd.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox