From: sashiko-bot@kernel.org
To: "Minda Chen" <minda.chen@starfivetech.com>
Cc: krzk+dt@kernel.org, devicetree@vger.kernel.org, robh@kernel.org,
conor+dt@kernel.org
Subject: Re: [PATCH v2 2/3] scsi: ufs: dwc: Rename amd-versal2 read/write PHY API and move to dwc common file
Date: Sat, 09 May 2026 06:43:55 +0000 [thread overview]
Message-ID: <20260509064355.EB1D1C2BCB2@smtp.kernel.org> (raw)
In-Reply-To: <20260509062759.125472-3-minda.chen@starfivetech.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The functions `ufs_dwc_phy_reg_write` and `ufs_dwc_phy_reg_read` use `static` local arrays (`phy_write_attrs` and `phy_read_attrs`) which are modified on every call, creating a severe data race.
--
commit b544cff60ab1cb7a813f07b65debab2ffee3a426
Author: Minda Chen <minda.chen@starfivetech.com>
scsi: ufs: dwc: Rename amd-versal2 read/write PHY API and move to dwc common file
This commit moves the read/write PHY register APIs from the AMD versal2
driver to a common file. This allows other vendors using the designware
UFS MIPI PHY to reuse the code.
> diff --git a/drivers/ufs/host/ufshcd-dwc.c b/drivers/ufs/host/ufshcd-dwc.c
> index 21b1cf912dcc6..b057a78e151c4 100644
> --- a/drivers/ufs/host/ufshcd-dwc.c
> +++ b/drivers/ufs/host/ufshcd-dwc.c
> @@ -15,6 +15,59 @@
> #include "ufshcd-dwc.h"
> #include "ufshci-dwc.h"
>
> +int ufs_dwc_phy_reg_write(struct ufs_hba *hba, u32 addr, u32 val)
> +{
> + static struct ufshcd_dme_attr_val phy_write_attrs[] = {
> + { UIC_ARG_MIB(CBCREGADDRLSB), 0, DME_LOCAL },
> + { UIC_ARG_MIB(CBCREGADDRMSB), 0, DME_LOCAL },
> + { UIC_ARG_MIB(CBCREGWRLSB), 0, DME_LOCAL },
> + { UIC_ARG_MIB(CBCREGWRMSB), 0, DME_LOCAL },
> + { UIC_ARG_MIB(CBCREGRDWRSEL), 1, DME_LOCAL },
> + { UIC_ARG_MIB(VS_MPHYCFGUPDT), 1, DME_LOCAL }
> + };
> +
> + phy_write_attrs[0].mib_val = (u8)addr;
> + phy_write_attrs[1].mib_val = (u8)(addr >> 8);
> + phy_write_attrs[2].mib_val = (u8)val;
> + phy_write_attrs[3].mib_val = (u8)(val >> 8);
Could moving this function into common code expose a data race regression?
Since phy_write_attrs is declared static, it is allocated in global memory and
shared across all threads and UFS device instances.
If multiple host controllers probe asynchronously or undergo concurrent power
state changes, will they clobber each other's register addresses and values
here before calling ufshcd_dwc_dme_set_attrs?
Would it be safer to remove the static keyword so this structure is safely
allocated on the stack per-invocation?
[ ... ]
> +int ufs_dwc_phy_reg_read(struct ufs_hba *hba, u32 addr, u32 *val)
> +{
> + u32 mib_val;
> + int ret;
> + static struct ufshcd_dme_attr_val phy_read_attrs[] = {
> + { UIC_ARG_MIB(CBCREGADDRLSB), 0, DME_LOCAL },
> + { UIC_ARG_MIB(CBCREGADDRMSB), 0, DME_LOCAL },
> + { UIC_ARG_MIB(CBCREGRDWRSEL), 0, DME_LOCAL },
> + { UIC_ARG_MIB(VS_MPHYCFGUPDT), 1, DME_LOCAL }
> + };
> +
> + phy_read_attrs[0].mib_val = (u8)addr;
> + phy_read_attrs[1].mib_val = (u8)(addr >> 8);
Does this static array have the same concurrency issue as phy_write_attrs
above?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260509062759.125472-1-minda.chen@starfivetech.com?part=2
next prev parent reply other threads:[~2026-05-09 6:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-09 6:27 [PATCH v2 0/3] Add StarFive JHB100 soc UFS platform driver Minda Chen
2026-05-09 6:27 ` [PATCH v2 1/3] scsi: ufs: dt-bindings: starfive: Add UFS Host Controller for JHB100 soc Minda Chen
2026-05-09 6:38 ` sashiko-bot
2026-05-09 6:27 ` [PATCH v2 2/3] scsi: ufs: dwc: Rename amd-versal2 read/write PHY API and move to dwc common file Minda Chen
2026-05-09 6:43 ` sashiko-bot [this message]
2026-05-09 6:27 ` [PATCH v2 3/3] scsi: ufs: starfive: Add UFS support for StarFive JHB100 SoC Minda Chen
2026-05-09 7:07 ` sashiko-bot
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=20260509064355.EB1D1C2BCB2@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=minda.chen@starfivetech.com \
--cc=robh@kernel.org \
--cc=sashiko@lists.linux.dev \
/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