All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Maniyam, Dinesh via U-Boot" <u-boot@lists.u-boot-project.org>
To: Pranav Tilak <pranav.vinaytilak@amd.com>,
	u-boot@lists.denx.de, michal.simek@amd.com
Cc: git@amd.com, padmarao.begari@amd.com, Tom Rini <trini@konsulko.com>
Subject: Re: [PATCH v2 4/4] i3c: dw: fix slave device setup after DAA
Date: Wed, 22 Jul 2026 11:54:52 +0800	[thread overview]
Message-ID: <63e12ae3-c214-4aa0-8634-a3df6c069660@altera.com> (raw)
In-Reply-To: <20260709091357.1860417-5-pranav.vinaytilak@amd.com>

Hi Pranav — thanks.

On 9/7/2026 5:12 pm, Pranav Tilak wrote:
> [CAUTION: This email is from outside your organization. Unless you trust the sender, do not click on links or open attachments as it may be a fraudulent email attempting to steal your information and/or compromise your computer.]
> 
> 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
> 

The master->this misuse before attach is a real bug (skips attach_i3c_dev for every slave).
Removing that assignment and recording i3cdev[] inside dw_i3c_master_attach_i3c_dev() looks correct to me.

Reviewed-by: Dinesh Maniyam dinesh.maniyam@altera.com


  reply	other threads:[~2026-07-22  3:55 UTC|newest]

Thread overview: 12+ 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-22  2:51   ` Maniyam, Dinesh via U-Boot
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 ` [PATCH v2 4/4] i3c: dw: fix slave device setup after DAA Pranav Tilak
2026-07-22  3:54   ` Maniyam, Dinesh via U-Boot [this message]
2026-07-21  8:07 ` [PATCH v2 0/4] i3c: dw: fix slave device setup and probe issues Michal Simek via U-Boot
2026-07-22  3:56   ` Maniyam, Dinesh via U-Boot
2026-07-22  5:30     ` Michal Simek via U-Boot
2026-07-22 16:19       ` Tom Rini via U-Boot
2026-07-22 20:27 ` Tom Rini via U-Boot

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=63e12ae3-c214-4aa0-8634-a3df6c069660@altera.com \
    --to=u-boot@lists.u-boot-project.org \
    --cc=dinesh.maniyam@altera.com \
    --cc=git@amd.com \
    --cc=michal.simek@amd.com \
    --cc=padmarao.begari@amd.com \
    --cc=pranav.vinaytilak@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.