From: Bart Van Assche <bvanassche@acm.org>
To: Yixun Lan <dlan@kernel.org>,
Alim Akhtar <alim.akhtar@samsung.com>,
Avri Altman <avri.altman@sandisk.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
Philipp Zabel <p.zabel@pengutronix.de>,
Paul Walmsley <pjw@kernel.org>,
Palmer Dabbelt <palmer@dabbelt.com>,
Albert Ou <aou@eecs.berkeley.edu>,
Alexandre Ghiti <alex@ghiti.fr>
Cc: linux-scsi@vger.kernel.org, devicetree@vger.kernel.org,
linux-riscv@lists.infradead.org, spacemit@lists.linux.dev,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] scsi: ufs: spacemit: k3: Add UFS Host Controller driver
Date: Mon, 6 Jul 2026 07:01:42 -0700 [thread overview]
Message-ID: <f46d7520-bc2e-49f7-9049-ecdba2837b5d@acm.org> (raw)
In-Reply-To: <20260702-08-k3-ufs-support-v1-2-1a64a3ab128f@kernel.org>
On 7/1/26 7:31 PM, Yixun Lan wrote:
> +config SCSI_UFS_SPACEMIT
> + tristate "SpacemiT UFS controller driver"
> + depends on SCSI_UFSHCD_PLATFORM && ARCH_SPACEMIT
What would break if ARCH_SPACEMIT is left out?
Please make sure that this driver can be compile-tested easily.
> + u32 host_reg[] = {
> + (UFS_PHY_MNG_BASE + UFS_MPHY_RST_CTRL),
> + (UFS_PHY_MNG_BASE + UFS_MPHY_PU_CTRL),
> + (UFS_PHY_MNG_BASE + UFS_DEVICE_IO_CTRL),
> + 0xFFF,
> + };
Can this array be declared 'static const'?
The parentheses in the above array definition are superfluous.
Please remove these.
> + buf = kzalloc(VENDOR_DUMP_BUF_SIZE, GFP_ATOMIC);
Why GFP_ATOMIC? ufs_spacemit_dump_host_regs() is never called from
atomic context, isn't it?
> + len += scnprintf(buf + len, VENDOR_DUMP_BUF_SIZE - len, "vendor specific registers:");
This function will be much easier to review and to maintain if a struct
seq_buf instance is created for 'buf' and if seq_buf_printf() would be
used instead of scnprintf().
> +static bool is_fsm_state_valid(u32 state)
> +{
> + return (state == FSM_STATE_ACTIVE || state == FSM_STATE_LS_BURST);
> +}
"return" is not a function. Please remove the superfluous parentheses.
> +static int ufs_spacemit_mphy_init(struct ufs_hba *hba)
> +{
> + int ret;
> +
> + /* reset all mphy logical */
> + ufshcd_writel(hba, 0x003, UFS_PHY_MNG_BASE + 0x0);
> + mdelay(1);
Why mdelay() instead of msleep()?
> +static int ufs_spacemit_uniprov1p6_init(struct ufs_hba *hba)
> +{
> + /* PA_TXHSG1SYNCLENGTH */
> + ufshcd_dme_set(hba, UIC_ARG_MIB(0x1552), 0x4f);
> +
> + /* PA_TXHSG1PREPARELENGTH */
> + ufshcd_dme_set(hba, UIC_ARG_MIB(0x1553), 0xf);
The code in this function is very repetitive. Please convert all the
ufshcd_dme_set() calls into a loop over an array.
> + /*LCC_DISABLE*/
Here and everywhere else in this source file, please follow the
convention used elsewhere in the Linux kernel and change /*comment*/
into /* comment */.
> +/**
> + * ufs_spacemit_hibern8_notify - Handle hibernate enter/exit
> + * @hba: host controller instance
> + * @cmd: UIC command (HIBER_ENTER or HIBER_EXIT)
> + * @status: notification status
> + *
> + * Manages M-PHY power state during hibernate transitions.
> + */
> +static void ufs_spacemit_hibern8_notify(struct ufs_hba *hba, enum uic_cmd_dme cmd,
> + enum ufs_notify_change_status status)
> +{
> + int ret;
> +
> + dev_dbg(hba->dev, "Hibern8 notify: cmd=%d, status=%d\n", cmd, status);
> + if (status == PRE_CHANGE) {
> + if (cmd == UIC_CMD_DME_HIBER_EXIT) {
> + mdelay(1);
> +
> + /* Enable reference clock */
> + ufshcd_writel(hba, MPHY_DEVICE_RESET_DEASSERT,
> + UFS_PHY_MNG_BASE + UFS_DEVICE_IO_CTRL);
> + mdelay(1);
> +
> + /* Power up all */
> + ufshcd_writel(hba, MPHY_PU_ALL, UFS_PHY_MNG_BASE + UFS_MPHY_PU_CTRL);
> + mdelay(1);
> +
> + /* Assert ana_rx_hb8_reset */
> + ufshcd_writel(hba, MPHY_PU_WITH_HB8_RESET,
> + UFS_PHY_MNG_BASE + UFS_MPHY_PU_CTRL);
> + mdelay(1);
> +
> + /* Deassert ana_rx_hb8_reset */
> + ufshcd_writel(hba, MPHY_PU_ALL, UFS_PHY_MNG_BASE + UFS_MPHY_PU_CTRL);
> +
> + ret = ufs_spacemit_wait_mphy_pll_lock(hba);
> + if (ret < 0)
> + return;
> +
> + mdelay(1);
> + ufshcd_dme_set(hba, UIC_ARG_MIB(0xdd), 0x57);
> + mdelay(1);
> + ufshcd_dme_set(hba, UIC_ARG_MIB(0xe8), 0x57);
> + }
> + }
Please move all the code in this function that is indented by two tabs
into new functions to improve code readability and to reduce
indentation. This advice comes from the Linux kernel coding style guide.
Thanks,
Bart.
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2026-07-06 14:02 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-02 2:31 [PATCH 0/3] Add UFS Host driver support for SpacemiT K3 SoC Yixun Lan
2026-07-02 2:31 ` [PATCH 1/3] scsi: ufs: spacemit: dt-bindings: Add UFS controller for " Yixun Lan
2026-07-02 2:31 ` [PATCH 2/3] scsi: ufs: spacemit: k3: Add UFS Host Controller driver Yixun Lan
2026-07-02 7:53 ` Philipp Zabel
2026-07-03 0:16 ` Yixun Lan
2026-07-02 17:21 ` Yao Zi
2026-07-03 1:28 ` Yixun Lan
2026-07-06 14:01 ` Bart Van Assche [this message]
2026-07-02 2:31 ` [PATCH 3/3] riscv: dts: spacemit: k3: Add UFS support Yixun Lan
2026-07-04 14:01 ` Jennifer Berringer
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=f46d7520-bc2e-49f7-9049-ecdba2837b5d@acm.org \
--to=bvanassche@acm.org \
--cc=James.Bottomley@HansenPartnership.com \
--cc=alex@ghiti.fr \
--cc=alim.akhtar@samsung.com \
--cc=aou@eecs.berkeley.edu \
--cc=avri.altman@sandisk.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlan@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=p.zabel@pengutronix.de \
--cc=palmer@dabbelt.com \
--cc=pjw@kernel.org \
--cc=robh@kernel.org \
--cc=spacemit@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