Add UFS Host driver support for SpacemiT K3 SoC
Subsystems (5)
Yixun Lan
maintainerv8 cover Add UFS Host driver support for SpacemiT K3 SoC
This series try to add UFS support for SpacemiT K3 SoC, the controller components consists of System Bus Interface Unit, UFS Host Controller Interface, UFS Transport Protocol Layer, UFS Host Registers, Device Management Entity (DME), Transport Layer, Network Layer, Data Link Layer, PHY Adapter Layer, and M-PHY Interface. A more detail functional block diagram can be found in SpacemiT website, chapter 9.7.3 [1]
The DTS patch has been dropped in this series [2], and will send in separate series once this patch accepted. For people who want to test UFS driver, please grab the DT patch from version v5 [3].
Enable UFSHCD_CAP_KEEP_AUTO_BKOPS_ENABLED_EXCEPT_SUSPEND, This allows the device auto-bkops to be always enabled except during suspend (both runtime and suspend), with this feature, the BKOPS interrupt (log below) isn't reported anymore.
[ 806.710763] ufshcd-spacemit c0e00000.ufshc: ufshcd_bkops_exception_event_handler: device raised urgent BKOPS exception for bkops status 1
---
Changes in v8:
- enable UFSHCD_CAP_KEEP_AUTO_BKOPS_ENABLED_EXCEPT_SUSPEND
- rename to "ref_clk", see explanation in patch
- add delay between enable clk & deassert reset
- respect bRefClkGatingWaitTime, add wait delay
- drop comment of ufs_hba_spacemit_vops, which got CI complaint
- rebase to v7.4-rc1
- Link to v7: https://patch.msgid.link/[email protected]
Changes in v7:
- check err return value of ufs_spacemit_quirk_host_pa_saveconfigtime()
- Link to v6: https://patch.msgid.link/[email protected]
Changes in v6:
- drop unused macro and dev_req_params
- use global PX_xx macros
- fix axi clock name
- drop dts patch
- collect tags
- Link to v5: https://patch.msgid.link/[email protected]
Changes in v5:
- adjust clock names
- add runtime power support
- collect tags
- Link to v4: https://patch.msgid.link/[email protected]
Changes in v4:
- fix clock and reset settings
- drop function which retrieve value of tx_lanes
- propagate return error of ufs_spacemit_dme_set()
- check return value ufs_spacemit_check_hibern8()
- drop call to ufshcd_vops_phy_initialization()
- handle compiling warning if CONFIG_OF not enabled
add __maybe_unused to ufs_spacemit_of_match
- Link to v3: https://patch.msgid.link/[email protected]
Changes in v3:
- collect tags
- fix dt-binding warning reported-by sashiko
- fix low freq in opp-2 table
- fix err checking in check_hibern8()
- propagate err code in link_startup_notify()
- update documents for event_notify()
- ufs clock driver is merged into v7.3-rc1, update cover letter
- Link to v2: https://patch.msgid.link/[email protected]
Changes in v2:
- fix missing interrupts property
- move ufs node to k3-com260.dtsi
- convert freq-table-hz to operating-points-v2
- rework reset_control, fix header and drop global variable
- drop dump_host_regs() debug interface
- converge and refactor dme_set() operations
- massive reduce of busy delay() loops
- drop vendor specific hce_enable_notify(), fallback to default
- drop unused member from struct ufs_spacemit_host
- add COMPILE_TEST support to Kconfig
- comment style fix
- Link to v1: https://patch.msgid.link/[email protected]
---
Yixun Lan (2):
scsi: ufs: spacemit: dt-bindings: Add UFS controller for K3 SoC
scsi: ufs: spacemit: k3: Add UFS Host Controller driver
.../devicetree/bindings/ufs/spacemit,k3-ufshc.yaml | 56 ++ drivers/ufs/host/Kconfig | 12 + drivers/ufs/host/Makefile | 1 + drivers/ufs/host/ufs-spacemit.c | 655 +++++++++++++++++++++ drivers/ufs/host/ufs-spacemit.h | 77 +++ 5 files changed, 801 insertions(+)
---
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
change-id: 20260605-08-k3-ufs-support-c8b308e415e2
Best regards,
Signature · 1 line
Yixun Lan <[email protected]>
Yixun Lan
maintainerPATCH v8 1/2 scsi: ufs: spacemit: dt-bindings: Add UFS controller for K3 SoC
Document the compatible for UFS (Universal Flash Storage) Host Controller which found in SpacemiT K3 SoC chip. Its features are listed below:
- Compliant with MIPI UniPro v1.61 specification.
- Compliant with M-PHY v3.0 specification.
- Compliant with UFS HCI v2.1 specification.
- Supports up to 2 Tx and 2 Rx lanes, up to HS-GEAR3 5.8 Gbps per lane.
- Supports standard low-power hibernate to reduce power consumption.
---
Changes in v8:
- rename to "ref_clk" clock
UFS core will search specific "ref_clk" clock, retrieve the frequency, and then set bRefClkFreq, see ufshcd_parse_dev_ref_clk_freq() and ufshcd_set_dev_ref_clk(). It will also set keep_link_active feature.
to Krzysztof, please note, I've kept the Reviewed-by in this version
even with clk name change, let me know if you have any objection.
--- .../devicetree/bindings/ufs/spacemit,k3-ufshc.yaml | 56 ++++++++++++++++++++++ 1 file changed, 56 insertions(+)
Documentation/devicetree/bindings/ufs/spacemit,k3-ufshc.yaml new file +56 -0
@@ -0,0 +1,56 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/ufs/spacemit,k3-ufshc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: SpacemiT K3 SoC UFS Host Controller + +maintainers: + - Yixun Lan <[email protected]> + +properties: + compatible: + const: spacemit,k3-ufshc + + reg: + maxItems: 1 + + clocks: + maxItems: 2 + + clock-names: + items: + - const: axi + - const: ref_clk + + resets: + maxItems: 1 + +required: + - compatible + - reg + - clocks + - clock-names + - resets + +allOf: + - $ref: ufs-common.yaml + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/clock/spacemit,k3-clocks.h> + #include <dt-bindings/reset/spacemit,k3-resets.h> + #include <dt-bindings/interrupt-controller/irq.h> + ufs@c0e00000 { + compatible = "spacemit,k3-ufshc"; + reg = <0xc0e00000 0x40000>; + clocks = <&syscon_apmu CLK_APMU_UFS_ACLK>, + <&syscon_apmu CLK_APMU_UFS_REFCLK>; + clock-names = "axi", "ref_clk"; + resets = <&syscon_apmu RESET_APMU_UFS_ACLK>; + interrupts = <135 IRQ_TYPE_LEVEL_HIGH>; + lanes-per-direction = <2>; + };
Signature · 1 line
2.56.0
Yixun Lan
maintainerPATCH v8 2/2 scsi: ufs: spacemit: k3: Add UFS Host Controller driver
In reply to Yixun LanSpacemiT K3 SoC consist of UFS (Universal Flash Storage) Host Controller which has features compatible with JEDEC UFS 2.2, MIPI UniPro v1.61 and M-PHY v3.0 standard.
--- drivers/ufs/host/Kconfig | 12 + drivers/ufs/host/Makefile | 1 + drivers/ufs/host/ufs-spacemit.c | 655 ++++++++++++++++++++++++++++++++++++++++ drivers/ufs/host/ufs-spacemit.h | 77 +++++ 4 files changed, 745 insertions(+)
drivers/ufs/host/Kconfig +12 -0
@@ -132,6 +132,18 @@ config SCSI_UFS_VARIABLE_SG_ENTRY_SIZE bool default y if SCSI_UFS_EXYNOS && SCSI_UFS_CRYPTO +config SCSI_UFS_SPACEMIT + tristate "SpacemiT UFS controller driver" + depends on SCSI_UFSHCD_PLATFORM && (ARCH_SPACEMIT || COMPILE_TEST) + help + This selects the SpacemiT specific additions to UFSHCD platform driver. + UFS host on SpacemiT needs some vendor specific configuration before + accessing the hardware which includes PHY configuration and vendor + specific registers. + + Select this if you have UFS controller on SpacemiT chipset. + If unsure, say N. + config SCSI_UFS_SPRD tristate "Unisoc specific hooks to UFS controller platform driver" depends on SCSI_UFSHCD_PLATFORM && (ARCH_SPRD || COMPILE_TEST)
drivers/ufs/host/Makefile +1 -0
@@ -13,6 +13,7 @@ obj-$(CONFIG_SCSI_UFS_HISI) += ufs-hisi.o obj-$(CONFIG_SCSI_UFS_MEDIATEK) += ufs-mediatek.o obj-$(CONFIG_SCSI_UFS_RENESAS) += ufs-renesas.o obj-$(CONFIG_SCSI_UFS_ROCKCHIP) += ufs-rockchip.o +obj-$(CONFIG_SCSI_UFS_SPACEMIT) += ufs-spacemit.o obj-$(CONFIG_SCSI_UFS_SPRD) += ufs-sprd.o obj-$(CONFIG_SCSI_UFS_TI_J721E) += ti-j721e-ufs.o obj-$(CONFIG_SCSI_UFS_AMD_VERSAL2) += ufs-amd-versal2.o ufshcd-dwc.o
drivers/ufs/host/ufs-spacemit.c new file +655 -0
655 lines not on this page · raw message
drivers/ufs/host/ufs-spacemit.h new file +77 -0
77 lines not on this page · raw message
Signature · 1 line
2.56.0
[email protected]
AI reviewRe: [PATCH v8 2/2] scsi: ufs: spacemit: k3: Add UFS Host Controller driver
Thank you for your contribution! Sashiko AI review found 5 potential issues to consider: - [High] scsi: ufs: spacemit: clocks not enabled and sys1clk rate always 0 without OPP/freq-table - [Medium]…
Thank you for your contribution! Sashiko AI review found 5 potential issues to consider:
- [High] scsi: ufs: spacemit: clocks not enabled and sys1clk rate always 0 without OPP/freq-table
- [Medium] scsi: ufs: spacemit: zero ref_clk gating delay in ufs_spacemit_post_hibern8() on UFS 2.x
- [Low] scsi: ufs: spacemit: ufs_spacemit_event_notify() logs cleared hba->errors on UFS_EVT_ABORT
- [Low] scsi: ufs: spacemit: duplicated ufshcd_init_host_params() and unused definitions
- [Low] scsi: ufs: spacemit: positive UIC error codes ignored in DME error checks
--
commit 893661ab0d45a5f00a091213a0890aea0386b457
Author: Yixun Lan <[email protected]>
scsi: ufs: spacemit: k3: Add UFS Host Controller driver
This commit adds a UFS host controller platform driver for the SpacemiT K3 SoC, supporting JEDEC UFS 2.2, MIPI UniPro v1.61, and M-PHY v3.0.
Quoted 5 lines
drivers/ufs/host/ufs-spacemit.c new file +0
-0
[ ... ]
Quoted 13 lines
drivers/ufs/host/ufs-spacemit.c new file +13
-0+static u32 ufs_spacemit_get_sys1clk_1us (struct ufs_hba *hba) +{ +struct ufs_clk_info *clki, *clka =NULL ; +struct list_head *head = &hba->clk_list_head; +unsigned long rate_hz =0 ; + +if (!list_empty (head)) { +list_for_each_entry (clki, head, list) { +if (clki->name && !strcmp (clki->name,"axi" ) && clki->clk) { + clka = clki; +break ; + } + }
drivers/ufs/host/ufs-spacemit.c line 122
Quoted 10 lines
drivers/ufs/host/ufs-spacemit.c new file +10
-0+ } + +if (clka && clka->clk) + rate_hz =clk_get_rate (clka->clk); + +if (!rate_hz) +return 0 ; + +return DIV_ROUND_CLOSEST (rate_hz,1000000 ); +}
[Severity: High]
Does hba->clk_list_head remain empty when the Device Tree node has neither freq-table-hz nor operating-points-v2?
ufshcd_parse_clock_info() returns early without parsing clock-names when freq-table-hz is absent, and ufshcd_parse_operating_points() does the same when operating-points-v2 is absent:
drivers/ufs/host/ufshcd-pltfrm.c:ufshcd_parse_clock_info() {
...
sz = of_property_count_u32_elems(np, "freq-table-hz");
if (sz <= 0) {
dev_info(dev, "freq-table-hz property not specified\n");
goto out;
}
...
}Since the spacemit,k3-ufshc binding omits both properties and ufs_spacemit_init() does not populate hba->clk_list_head or acquire the clocks itself, ufshcd_init_clocks() and ufshcd_setup_clocks() never enable the axi or ref_clk clocks (leaving them subject to clk_disable_unused or unclocked MMIO access if not enabled by firmware), hba->dev_ref_clk_freq is never parsed from ref_clk, and ufs_spacemit_get_sys1clk_1us() always returns 0 so ufs_spacemit_link_startup_pre_change() always falls back to UFS_AXI_CLK_LOW_FREQ_HZ (409.6 MHz).
[ ... ]
Quoted 9 lines
drivers/ufs/host/ufs-spacemit.c new file +9
-0+static void ufs_spacemit_set_dev_cap (struct ufs_host_params *host_params,u32 pwr_hs) +{ +if (!host_params) +return ; + +memset (host_params,0 ,sizeof (struct ufs_host_params )); + host_params->tx_lanes =UFS_SPACEMIT_K3_LIMIT_NUM_LANES_TX ; + host_params->rx_lanes =UFS_SPACEMIT_K3_LIMIT_NUM_LANES_RX ; + host_params->hs_rx_gear =UFS_SPACEMIT_K3_LIMIT_HSGEAR_RX ;
drivers/ufs/host/ufs-spacemit.c line 253
Quoted 10 lines
drivers/ufs/host/ufs-spacemit.c new file +10
-0+ host_params->hs_tx_gear =UFS_SPACEMIT_K3_LIMIT_HSGEAR_TX ; + host_params->pwm_rx_gear =UFS_SPACEMIT_K3_LIMIT_PWMGEAR_RX ; + host_params->pwm_tx_gear =UFS_SPACEMIT_K3_LIMIT_PWMGEAR_TX ; + host_params->rx_pwr_pwm =UFS_SPACEMIT_K3_LIMIT_RX_PWR_PWM ; + host_params->tx_pwr_pwm =UFS_SPACEMIT_K3_LIMIT_TX_PWR_PWM ; + host_params->rx_pwr_hs = pwr_hs; + host_params->tx_pwr_hs = pwr_hs; + host_params->hs_rate =UFS_SPACEMIT_K3_LIMIT_HS_RATE ; + host_params->desired_working_mode =UFS_HS_MODE ; +}
[Severity: Low]
This isn't a bug, but ufs_spacemit_set_dev_cap() and the UFS_SPACEMIT_K3_LIMIT_* macros set the exact same defaults as the exported ufshcd_init_host_params() helper in drivers/ufs/host/ufshcd-pltfrm.c.
In addition, ufs_spacemit_init() allocates struct ufs_spacemit_host and stores it with ufshcd_set_variant(), but the variant pointer is never retrieved anywhere in the driver. MPHY_TX_FSM_STATE is also defined in both ufs-spacemit.h and ufs-spacemit.c, ANA_EQ_CTRL_REG_ATTR and MPHY_PU_WITH_HB8_RESET are defined in ufs-spacemit.c while raw literals 0x00CD and 0xb7f are still used in ufs_spacemit_uniprov1p6_init() and ufs_spacemit_mphy_init(), and MPHY_RX_FSM_STATE along with several headers and macros in ufs-spacemit.h are unused.
Quoted 13 lines
drivers/ufs/host/ufs-spacemit.c new file +13
-0+ +static int ufs_spacemit_link_startup_pre_change (struct ufs_hba *hba) +{ +u32 value, sys1clk_1us; +int err; + + err =ufs_spacemit_mphy_init (hba); +if (err <0 ) +return err; + + err =ufs_spacemit_uniprov1p6_init (hba); +if (err <0 ) +return err;
[ ... ]
Quoted 18 lines
drivers/ufs/host/ufs-spacemit.c new file +18
-0+static int ufs_spacemit_apply_dev_quirks (struct ufs_hba *hba) +{ +static const struct ufshcd_dme_attr_val setup_attrs[] = { +/* LCC_DISABLE */ + {UIC_ARG_MIB_SEL (TX_LCC_ENABLE ,UIC_ARG_MPHY_TX_GEN_SEL_INDEX (0 )),0 }, + {UIC_ARG_MIB_SEL (TX_LCC_ENABLE ,UIC_ARG_MPHY_TX_GEN_SEL_INDEX (1 )),0 }, +/* TX_Min_ActivateTime */ + {UIC_ARG_MIB_SEL (TX_MIN_ACTIVATETIME ,UIC_ARG_MPHY_TX_GEN_SEL_INDEX (0 )),0x0 }, + {UIC_ARG_MIB_SEL (TX_MIN_ACTIVATETIME ,UIC_ARG_MPHY_TX_GEN_SEL_INDEX (1 )),0x0 }, + {UIC_ARG_MIB (ANA_HSGEAR_CTRL_ATTR ),0x25 }, + }; +int err; + +if (hba->dev_quirks &UFS_DEVICE_QUIRK_HOST_PA_SAVECONFIGTIME ) { + err =ufs_spacemit_quirk_host_pa_saveconfigtime (hba); +if (err <0 ) +return err; + }
drivers/ufs/host/ufs-spacemit.c line 417
Quoted 10 lines
drivers/ufs/host/ufs-spacemit.c new file +10
-0+ +if (hba->dev_info.wmanufacturerid ==UFS_VENDOR_WDC ) + hba->dev_quirks |=UFS_DEVICE_QUIRK_HOST_PA_TACTIVATE ; + + err =ufs_spacemit_dme_set (hba, setup_attrs,ARRAY_SIZE (setup_attrs)); +if (err <0 ) +return err; + +return ufs_spacemit_wait_mphy_pll_lock (hba); +}
[Severity: Low]
As reported by Troy Mitchell on v6 [1], can positive UIC error codes bypass the "if (err < 0)" checks in ufs_spacemit_link_startup_pre_change() and ufs_spacemit_apply_dev_quirks()?
ufshcd_dme_get() and ufshcd_dme_set() return positive 8-bit UIC command result codes (0x01..0xFF) when a DME command fails at the UniPro layer. Checking "if (err < 0)" misses those positive error codes and allows both functions to continue past failed DME operations instead of aborting early.
[ ... ]
Quoted 12 lines
drivers/ufs/host/ufs-spacemit.c new file +12
-0+static void ufs_spacemit_event_notify (struct ufs_hba *hba,enum ufs_event_type evt,void *data) +{ +switch (evt) { +case UFS_EVT_PA_ERR : +if (data) +dev_warn (hba->dev,"PA error event, INT errors:0x%x, PA_ERR_CODE:0x%x\n" , + hba->errors, *(u32 *)data); + +break ; +case UFS_EVT_DL_ERR : +if (data) + dev_warn(hba->dev, "DL error event, INT errors:0x%x, DL_ERR:0x%x\n",
drivers/ufs/host/ufs-spacemit.c line 518
Quoted 10 lines
drivers/ufs/host/ufs-spacemit.c new file +10
-0+ hba->errors, *(u32 *)data); + +break ; +case UFS_EVT_ABORT : +dev_warn (hba->dev,"Abort event, INT errors:0x%x\n" , hba->errors); +break ; +default : +break ; + } +}
[Severity: Low]
Does the UFS_EVT_ABORT case in ufs_spacemit_event_notify() always log hba->errors as 0x0?
ufshcd_check_errors() clears hba->errors back to 0 before the interrupt handler returns (saving sticky bits in hba->saved_err), while UFS_EVT_ABORT is only emitted later from ufshcd_abort() in SCSI error-handler context with the aborted tag or LUN passed via data.
[ ... ]
Quoted 21 lines
drivers/ufs/host/ufs-spacemit.c new file +21
-0+static void ufs_spacemit_post_hibern8 (struct ufs_hba *hba,enum uic_cmd_dme cmd) +{ +static const struct ufshcd_dme_attr_val setup_attrs[] = { + {UIC_ARG_MIB_SEL (0xf1 ,UIC_ARG_MPHY_RX_GEN_SEL_INDEX (0 )),0x84 }, + {UIC_ARG_MIB_SEL (0xf1 ,UIC_ARG_MPHY_RX_GEN_SEL_INDEX (1 )),0x84 }, + {UIC_ARG_MIB_SEL (0xf1 ,UIC_ARG_MPHY_RX_GEN_SEL_INDEX (0 )),0x80 }, + {UIC_ARG_MIB_SEL (0xf1 ,UIC_ARG_MPHY_RX_GEN_SEL_INDEX (1 )),0x80 }, + {UIC_ARG_MIB (0xdd ),0x57 }, + {UIC_ARG_MIB (0xdd ),0xd7 }, + {UIC_ARG_MIB (0xe8 ),0x57 }, + {UIC_ARG_MIB (0xe8 ),0xd7 }, + }; +int err; + +if (cmd ==UIC_CMD_DME_HIBER_ENTER ) { + err =ufs_spacemit_check_hibern8 (hba); +if (err) +dev_err (hba->dev,"ufs_spacemit_check_hibern8 error\n" ); + +ufs_spacemit_dme_set (hba, setup_attrs,ARRAY_SIZE (setup_attrs)); +
drivers/ufs/host/ufs-spacemit.c line 588
Quoted 10 lines
drivers/ufs/host/ufs-spacemit.c new file +10
-0+/* Power down M-PHY */ +ufshcd_writel (hba,0x0 ,UFS_PHY_MNG_BASE +UFS_MPHY_PU_CTRL ); + +fsleep (hba->dev_info.clk_gating_wait_us); + +/* Disable reference clock, keep device reset deasserted */ +ufshcd_writel (hba,MPHY_DEVICE_HW_RESET , +UFS_PHY_MNG_BASE +UFS_DEVICE_IO_CTRL ); + } +}
[Severity: Medium]
Does fsleep(hba->dev_info.clk_gating_wait_us) gate the device reference clock with zero delay on UFS 2.x devices?
ufshcd_get_ref_clk_gating_wait() only reads bRefClkGatingWaitTime and sets hba->dev_info.clk_gating_wait_us when hba->dev_info.wspecversion >= 0x300. On UFS 2.x devices (or if Hibern8 is entered before ufshcd_device_params_init() runs), clk_gating_wait_us remains 0, so ufs_spacemit_post_hibern8() calls fsleep(0) and disables MPHY_DEVICE_REFCLK_OE immediately after powering down the M-PHY without satisfying the reference clock hold time.
[1] https://lore.kernel.org/r/[email protected]
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Re: [PATCH v8 2/2] scsi: ufs: spacemit: k3: Add UFS Host Controller driver
In reply to Yixun LanHi Yixun,
Quoted 8 lines · Yixun Lan
SpacemiT K3 SoC consist of UFS (Universal Flash Storage) Host Controller which has features compatible with JEDEC UFS 2.2, MIPI UniPro v1.61 and M-PHY v3.0 standard.
Tested-by Aurelien Jarno <[email protected]>Tested-by Anirudh Srinivasan <[email protected]>Tested-by Trevor Gamblin <[email protected]>Signed-off-by Yixun Lan <[email protected]>
Quoted 6 lines
--- drivers/ufs/host/Kconfig | 12 + drivers/ufs/host/Makefile | 1 + drivers/ufs/host/ufs-spacemit.c | 655 ++++++++++++++++++++++++++++++++++++++++ drivers/ufs/host/ufs-spacemit.h | 77 +++++ 4 files changed, 745 insertions(+)
Thanks for this new version. I have tested it on top of 7.3.4, after renaming ref into ref_clk in the dts file, and I confirm it works as expected.
Regards
Aurelien
Signature · 2 lines
Aurelien Jarno GPG: 4096R/1DDD8C9B [email protected] http://aurel32.net
Hi Yixun,
Quoted 95 lines · Yixun Lan
This series try to add UFS support for SpacemiT K3 SoC, the controller components consists of System Bus Interface Unit, UFS Host Controller Interface, UFS Transport Protocol Layer, UFS Host Registers, Device Management Entity (DME), Transport Layer, Network Layer, Data Link Layer, PHY Adapter Layer, and M-PHY Interface. A more detail functional block diagram can be found in SpacemiT website, chapter 9.7.3 [1]
The DTS patch has been dropped in this series [2], and will send in separate series once this patch accepted. For people who want to test UFS driver, please grab the DT patch from version v5 [3].
Enable
UFSHCD_CAP_KEEP_AUTO_BKOPS_ENABLED_EXCEPT_SUSPEND, This allows the device auto-bkops to be always enabled except during suspend (both runtime and suspend), with this feature, the BKOPS interrupt (log below) isn't reported anymore.[ 806.710763] ufshcd-spacemit c0e00000.ufshc: ufshcd_bkops_exception_event_handler: device raised urgent BKOPS exception for bkops status 1Signed-off-by Yixun Lan <[email protected]>---
Changes in v8:
- enableUFSHCD_CAP_KEEP_AUTO_BKOPS_ENABLED_EXCEPT_SUSPEND
- rename to "ref_clk", see explanation in patch
- add delay between enable clk & deassert reset
- respect bRefClkGatingWaitTime, add wait delay
- drop comment ofufs_hba_spacemit_vops, which got CI complaint
- rebase to v7.4-rc1
- Link to v7: https://patch.msgid.link/[email protected]Changes in v7:
- check err return value ofufs_spacemit_quirk_host_pa_saveconfigtime()
- Link to v6: https://patch.msgid.link/[email protected]Changes in v6:
- drop unused macro anddev_req_params
- use globalPX_xxmacros
- fix axi clock name
- drop dts patch
- collect tags
- Link to v5: https://patch.msgid.link/[email protected]Changes in v5:
- adjust clock names
- add runtime power support
- collect tags
- Link to v4: https://patch.msgid.link/[email protected]Changes in v4:
- fix clock and reset settings
- drop function which retrieve value oftx_lanes
- propagate return error ofufs_spacemit_dme_set()
- check return valueufs_spacemit_check_hibern8()
- drop call toufshcd_vops_phy_initialization()
- handle compiling warning ifCONFIG_OFnot enabled
add__maybe_unusedtoufs_spacemit_of_match
- Link to v3: https://patch.msgid.link/[email protected]Changes in v3:
- collect tags
- fix dt-binding warning reported-by sashiko
- fix low freq in opp-2 table
- fix err checking incheck_hibern8()
- propagate err code inlink_startup_notify()
- update documents forevent_notify()
- ufs clock driver is merged into v7.3-rc1, update cover letter
- Link to v2: https://patch.msgid.link/[email protected]Changes in v2:
- fix missing interrupts property
- move ufs node tok3-com260.dtsi
- convert freq-table-hz to operating-points-v2
- reworkreset_control, fix header and drop global variable
- dropdump_host_regs()debug interface
- converge and refactordme_set()operations
- massive reduce of busydelay()loops
- drop vendor specifichce_enable_notify(), fallback to default
- drop unused member from structufs_spacemit_host
- addCOMPILE_TESTsupport toKconfig
- comment style fix
- Link to v1: https://patch.msgid.link/[email protected]---
Yixun Lan (2):
scsi: ufs: spacemit: dt-bindings: Add UFS controller for K3 SoC
scsi: ufs: spacemit: k3: Add UFS Host Controller driver.../devicetree/bindings/ufs/spacemit,k3-ufshc.yaml | 56 ++ drivers/ufs/host/Kconfig | 12 + drivers/ufs/host/Makefile | 1 + drivers/ufs/host/ufs-spacemit.c | 655 +++++++++++++++++++++ drivers/ufs/host/ufs-spacemit.h | 77 +++ 5 files changed, 801 insertions(+)
Quoted 13 lines
---
base-commit:6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
change-id: 20260605-08-k3-ufs-support-c8b308e415e2Best regards,
Signature · 7 lines
Yixun Lan <[email protected]> _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv
Tested v7 and v8 successfully on Sipeed K3 Pico-ITX (32GiB DRAM / 128GiB UFS model). Build and test methodology:
### build chimera debian-installer with patched mainline kernel ### assume fresh Debian testing "forky" build environment
apt update
apt install -y b4 bc bison ca-certificates cpio \
crossbuild-essential-riscv64 curl debhelper fakeroot flex kmod \
libdw-dev libssl-dev libssl-dev:riscv64 linux-config-7.2:riscv64 \
python3 rsync
curl -L \
https://git.kernel.org/torvalds/t/linux-7.4-rc3.tar.gz \
| tar xz
pushd linux-7.4-rc3
b4 am -v1 -o- \
https://lore.kernel.org/all/[email protected]/ \
| patch -p1
b4 am -v5 -P3 -o- \
https://lore.kernel.org/all/[email protected]/ \
| patch -p1
b4 am -v8 -P1,2 -o- \
https://lore.kernel.org/linux-riscv/[email protected]/ \
| patch -p1
xzcat /usr/src/linux-config-7.2/config.riscv64_none_riscv64.xz \
Quoted 1 line
.config
scripts/config \
--module SCSI_UFS_SPACEMIT \
--module SCSI_UFSHCD_PLATFORM \
--module CONFIG_PHY_SPACEMIT_K3_COMBO_PHY \
--enable DEBUG_INFO_NONE \
--undefine CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
make ARCH=riscv olddefconfig
make ARCH=riscv KDEB_CHANGELOG_DIST=unreleased LOCALVERSION=-k3ufs \
-j$(nproc) bindeb-pkg
popd
curl -L \
https://d-i.debian.org/daily-images/riscv64/daily/netboot/netboot.tar.gz \
| tar xz ./debian-installer
fakeroot # enter fakeroot environment to preserve initrd permissions
gzip -dc debian-installer/riscv64/initrd.gz \
| cpio -id --directory=initrd
dpkg -x linux-image-*k3ufs*_riscv64.deb initrd/custom gzip -dc initrd/custom/boot/vmlinuz-* \
Quoted 1 line
debian-installer/riscv64/linux-custom
mv initrd/lib/modules initrd/custom/
mv initrd/custom/lib/modules initrd/lib/
mv initrd/custom/usr/lib/* debian-installer/device-tree-custom find initrd -path initrd/custom -prune -o -printf '%P\0' \
| cpio -0oH newc --directory=initrd \
| gzip -c > debian-installer/riscv64/initrd-custom.gz
exit # leave fakeroot environment
pushd debian-installer
tar -czf ../debian-installer-k3ufs.tar.gz \
--transform 's~^~debian-installer-k3ufs/~' \
device-tree-custom \
riscv64/linux-custom \
riscv64/initrd-custom.gz \
../linux-image-*k3ufs*_riscv64.deb
popd
### end (build chimera debian-installer with patched mainline kernel)
Then follow mainline U-Boot/OpenSBI build guide at:
https://lore.kernel.org/u-boot/[email protected]/
with "python3 -m http.server 8000" to serve the files:
u-boot> env set autoload no
u-boot> dhcp
u-boot> wget $kernel_addr_r http://host:8000/riscv64/linux-custom
u-boot> wget $fdt_addr_r
http://host:8000/device-tree-custom/spacemit/k3-pico-itx.dtb
u-boot> wget $ramdisk_addr_r http://host:8000/riscv64/initrd-custom.gz
u-boot> env set bootargs 'console=ttyS0,115200 debug rootwait earlycon=sbi' u-boot> bootefi $kernel_addr_r $ramdisk_addr_r:$filesize $fdt_addr_r
before the very last step of debian-installer to reboot, go to console screen and use chroot to install the patched kernel to target and copy out the necessary files
for i in /dev /dev/pts /proc /run /sys /tmp ; do mount -o bind $i /target$i ; done
chroot /target sh -c 'scp user@host:/path/to/debian-installer-k3ufs/linux-image-*k3ufs*.deb /tmp' chroot /target sh -c 'dpkg -i /tmp/linux-image-*k3ufs*.deb' chroot /target sh -c 'scp /boot/initrd.img-*k3ufs user@host:/path/to/installed-debiank3'
chroot /target sh -c 'scp /boot/vmlinuz-*k3ufs user@host:/path/to/installed-debiank3'
chroot /target sh -c 'scp /lib/linux-image-*k3ufs/spacemit/k3-pico-itx.dtb user@host:/path/to/installed-debiank3'
chroot /target sh -c 'scp /boot/grub/grub.cfg user@host:/path/to/installed-debiank3'
for i in /dev/pts /dev /proc /run /sys /tmp ; do umount /target$i ; done
... over network to some host later used to serve the bootloader these files via "python -m http.server 8000"
u-boot> env set autoload no
u-boot> dhcp
u-boot> wget $kernel_addr_r http://host:8000/vmlinux-7.4.0-rc3-k3ufs
u-boot> wget $fdt_addr_r http://host:8000/k3-pico-itx.dtb
u-boot> wget $ramdisk_addr_r http://host:8000/initrd.img-7.4.0-rc3-k3ufs
u-boot> env set bootargs 'root=UUID=<place UUID here from grub.cfg> ro quiet'
u-boot> bootefi $kernel_addr_r $ramdisk_addr_r:$filesize $fdt_addr_r
Workload for testing is to repeat the above build steps on-device from UFS-backed root filesystem. In v7 there would be the occasional BKOPS warnings, and v8 here now no such BKOPS warnings.
I do notice some UFS-related warnings and errors in dmesg:
journalctl --dmesg | grep ufshcd
ufshcd-spacemit c0e00000.ufshc: freq-table-hz property not specified ufshcd-spacemit c0e00000.ufshc: ufshcd_populate_vreg: Unable to find vdd-hba-supply regulator, assuming enabled
ufshcd-spacemit c0e00000.ufshc: ufshcd_populate_vreg: Unable to find vcc-supply regulator, assuming enabled
ufshcd-spacemit c0e00000.ufshc: ufshcd_populate_vreg: Unable to find vccq-supply regulator, assuming enabled
ufshcd-spacemit c0e00000.ufshc: ufshcd_populate_vreg: Unable to find vccq2-supply regulator, assuming enabled
scsi host0: ufshcd
ufshcd-spacemit c0e00000.ufshc: ufshcd_scsi_add_wlus: BOOT WLUN not found ufshcd-spacemit c0e00000.ufshc: DL error event, INT errors:0x4, DL_ERR:0x80000020
-E
Yixun Lan
maintainerHi E Shattow,
Thanks for testing
Quoted 128 lines · E Shattow
Hi Yixun,
Quoted 95 lines · Yixun Lan
This series try to add UFS support for SpacemiT K3 SoC, the controller components consists of System Bus Interface Unit, UFS Host Controller Interface, UFS Transport Protocol Layer, UFS Host Registers, Device Management Entity (DME), Transport Layer, Network Layer, Data Link Layer, PHY Adapter Layer, and M-PHY Interface. A more detail functional block diagram can be found in SpacemiT website, chapter 9.7.3 [1]
The DTS patch has been dropped in this series [2], and will send in separate series once this patch accepted. For people who want to test UFS driver, please grab the DT patch from version v5 [3].
Enable
UFSHCD_CAP_KEEP_AUTO_BKOPS_ENABLED_EXCEPT_SUSPEND, This allows the device auto-bkops to be always enabled except during suspend (both runtime and suspend), with this feature, the BKOPS interrupt (log below) isn't reported anymore.[ 806.710763] ufshcd-spacemit c0e00000.ufshc: ufshcd_bkops_exception_event_handler: device raised urgent BKOPS exception for bkops status 1Signed-off-by Yixun Lan <[email protected]>---
Changes in v8:
- enableUFSHCD_CAP_KEEP_AUTO_BKOPS_ENABLED_EXCEPT_SUSPEND
- rename to "ref_clk", see explanation in patch
- add delay between enable clk & deassert reset
- respect bRefClkGatingWaitTime, add wait delay
- drop comment ofufs_hba_spacemit_vops, which got CI complaint
- rebase to v7.4-rc1
- Link to v7: https://patch.msgid.link/[email protected]Changes in v7:
- check err return value ofufs_spacemit_quirk_host_pa_saveconfigtime()
- Link to v6: https://patch.msgid.link/[email protected]Changes in v6:
- drop unused macro anddev_req_params
- use globalPX_xxmacros
- fix axi clock name
- drop dts patch
- collect tags
- Link to v5: https://patch.msgid.link/[email protected]Changes in v5:
- adjust clock names
- add runtime power support
- collect tags
- Link to v4: https://patch.msgid.link/[email protected]Changes in v4:
- fix clock and reset settings
- drop function which retrieve value oftx_lanes
- propagate return error ofufs_spacemit_dme_set()
- check return valueufs_spacemit_check_hibern8()
- drop call toufshcd_vops_phy_initialization()
- handle compiling warning ifCONFIG_OFnot enabled
add__maybe_unusedtoufs_spacemit_of_match
- Link to v3: https://patch.msgid.link/[email protected]Changes in v3:
- collect tags
- fix dt-binding warning reported-by sashiko
- fix low freq in opp-2 table
- fix err checking incheck_hibern8()
- propagate err code inlink_startup_notify()
- update documents forevent_notify()
- ufs clock driver is merged into v7.3-rc1, update cover letter
- Link to v2: https://patch.msgid.link/[email protected]Changes in v2:
- fix missing interrupts property
- move ufs node tok3-com260.dtsi
- convert freq-table-hz to operating-points-v2
- reworkreset_control, fix header and drop global variable
- dropdump_host_regs()debug interface
- converge and refactordme_set()operations
- massive reduce of busydelay()loops
- drop vendor specifichce_enable_notify(), fallback to default
- drop unused member from structufs_spacemit_host
- addCOMPILE_TESTsupport toKconfig
- comment style fix
- Link to v1: https://patch.msgid.link/[email protected]---
Yixun Lan (2):
scsi: ufs: spacemit: dt-bindings: Add UFS controller for K3 SoC
scsi: ufs: spacemit: k3: Add UFS Host Controller driver.../devicetree/bindings/ufs/spacemit,k3-ufshc.yaml | 56 ++ drivers/ufs/host/Kconfig | 12 + drivers/ufs/host/Makefile | 1 + drivers/ufs/host/ufs-spacemit.c | 655 +++++++++++++++++++++ drivers/ufs/host/ufs-spacemit.h | 77 +++ 5 files changed, 801 insertions(+)Quoted 13 lines
---
base-commit:6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
change-id: 20260605-08-k3-ufs-support-c8b308e415e2Best regards,
Signature · 7 lines
Yixun Lan <[email protected]> _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscvTested v7 and v8 successfully on Sipeed K3 Pico-ITX (32GiB DRAM / 128GiB UFS model). Build and test methodology:
### build chimera debian-installer with patched mainline kernel ### assume fresh Debian testing "forky" build environment
apt update
apt install -y b4 bc bison ca-certificates cpio \
crossbuild-essential-riscv64 curl debhelper fakeroot flex kmod \
libdw-dev libssl-dev libssl-dev:riscv64 linux-config-7.2:riscv64 \
python3 rsynccurl -L \
https://git.kernel.org/torvalds/t/linux-7.4-rc3.tar.gz \
| tar xz
Quoted 7 lines
pushd linux-7.4-rc3
b4 am -v1 -o- \
https://lore.kernel.org/all/[email protected]/ \
| patch -p1
b4 am -v5 -P3 -o- \
https://lore.kernel.org/all/[email protected]/ \
| patch -p1
Did you rename clock name from "ref" to "ref_clk"? see my comment in patch 1
Quoted 3 lines
b4 am -v8 -P1,2 -o- \
https://lore.kernel.org/linux-riscv/[email protected]/ \
| patch -p1
[...]
Quoted 7 lines
Workload for testing is to repeat the above build steps on-device from UFS-backed root filesystem. In v7 there would be the occasional BKOPS warnings, and v8 here now no such BKOPS warnings.
I do notice some UFS-related warnings and errors in dmesg:
Quoted 12 lines
journalctl --dmesg | grep ufshcd
ufshcd-spacemit c0e00000.ufshc: freq-table-hz property not specified ufshcd-spacemit c0e00000.ufshc:ufshcd_populate_vreg: Unable to find vdd-hba-supply regulator, assuming enabled
ufshcd-spacemit c0e00000.ufshc:ufshcd_populate_vreg: Unable to find vcc-supply regulator, assuming enabled
ufshcd-spacemit c0e00000.ufshc:ufshcd_populate_vreg: Unable to find vccq-supply regulator, assuming enabled
ufshcd-spacemit c0e00000.ufshc:ufshcd_populate_vreg: Unable to find vccq2-supply regulator, assuming enabled
scsi host0: ufshcd
ufshcd-spacemit c0e00000.ufshc:ufshcd_scsi_add_wlus: BOOT WLUN not found
Let's ignore the warning message for now, those shouldn't cause problem
Quoted 3 lines
ufshcd-spacemit c0e00000.ufshc: DL error event, INT errors:0x4, DL_ERR:0x80000020
Seems relate to Data link error, I will see if I can replicate this ..
Signature · 1 line
Yixun Lan (dlan)
Hi,
Quoted 128 lines · E Shattow
Hi Yixun,
Quoted 95 lines · Yixun Lan
This series try to add UFS support for SpacemiT K3 SoC, the controller components consists of System Bus Interface Unit, UFS Host Controller Interface, UFS Transport Protocol Layer, UFS Host Registers, Device Management Entity (DME), Transport Layer, Network Layer, Data Link Layer, PHY Adapter Layer, and M-PHY Interface. A more detail functional block diagram can be found in SpacemiT website, chapter 9.7.3 [1]
The DTS patch has been dropped in this series [2], and will send in separate series once this patch accepted. For people who want to test UFS driver, please grab the DT patch from version v5 [3].
Enable
UFSHCD_CAP_KEEP_AUTO_BKOPS_ENABLED_EXCEPT_SUSPEND, This allows the device auto-bkops to be always enabled except during suspend (both runtime and suspend), with this feature, the BKOPS interrupt (log below) isn't reported anymore.[ 806.710763] ufshcd-spacemit c0e00000.ufshc: ufshcd_bkops_exception_event_handler: device raised urgent BKOPS exception for bkops status 1Signed-off-by Yixun Lan <[email protected]>---
Changes in v8:
- enableUFSHCD_CAP_KEEP_AUTO_BKOPS_ENABLED_EXCEPT_SUSPEND
- rename to "ref_clk", see explanation in patch
- add delay between enable clk & deassert reset
- respect bRefClkGatingWaitTime, add wait delay
- drop comment ofufs_hba_spacemit_vops, which got CI complaint
- rebase to v7.4-rc1
- Link to v7: https://patch.msgid.link/[email protected]Changes in v7:
- check err return value ofufs_spacemit_quirk_host_pa_saveconfigtime()
- Link to v6: https://patch.msgid.link/[email protected]Changes in v6:
- drop unused macro anddev_req_params
- use globalPX_xxmacros
- fix axi clock name
- drop dts patch
- collect tags
- Link to v5: https://patch.msgid.link/[email protected]Changes in v5:
- adjust clock names
- add runtime power support
- collect tags
- Link to v4: https://patch.msgid.link/[email protected]Changes in v4:
- fix clock and reset settings
- drop function which retrieve value oftx_lanes
- propagate return error ofufs_spacemit_dme_set()
- check return valueufs_spacemit_check_hibern8()
- drop call toufshcd_vops_phy_initialization()
- handle compiling warning ifCONFIG_OFnot enabled
add__maybe_unusedtoufs_spacemit_of_match
- Link to v3: https://patch.msgid.link/[email protected]Changes in v3:
- collect tags
- fix dt-binding warning reported-by sashiko
- fix low freq in opp-2 table
- fix err checking incheck_hibern8()
- propagate err code inlink_startup_notify()
- update documents forevent_notify()
- ufs clock driver is merged into v7.3-rc1, update cover letter
- Link to v2: https://patch.msgid.link/[email protected]Changes in v2:
- fix missing interrupts property
- move ufs node tok3-com260.dtsi
- convert freq-table-hz to operating-points-v2
- reworkreset_control, fix header and drop global variable
- dropdump_host_regs()debug interface
- converge and refactordme_set()operations
- massive reduce of busydelay()loops
- drop vendor specifichce_enable_notify(), fallback to default
- drop unused member from structufs_spacemit_host
- addCOMPILE_TESTsupport toKconfig
- comment style fix
- Link to v1: https://patch.msgid.link/[email protected]---
Yixun Lan (2):
scsi: ufs: spacemit: dt-bindings: Add UFS controller for K3 SoC
scsi: ufs: spacemit: k3: Add UFS Host Controller driver.../devicetree/bindings/ufs/spacemit,k3-ufshc.yaml | 56 ++ drivers/ufs/host/Kconfig | 12 + drivers/ufs/host/Makefile | 1 + drivers/ufs/host/ufs-spacemit.c | 655 +++++++++++++++++++++ drivers/ufs/host/ufs-spacemit.h | 77 +++ 5 files changed, 801 insertions(+)Quoted 13 lines
---
base-commit:6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
change-id: 20260605-08-k3-ufs-support-c8b308e415e2Best regards,
Signature · 7 lines
Yixun Lan <[email protected]> _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscvTested v7 and v8 successfully on Sipeed K3 Pico-ITX (32GiB DRAM / 128GiB UFS model). Build and test methodology:
### build chimera debian-installer with patched mainline kernel ### assume fresh Debian testing "forky" build environment
apt update
apt install -y b4 bc bison ca-certificates cpio \
crossbuild-essential-riscv64 curl debhelper fakeroot flex kmod \
libdw-dev libssl-dev libssl-dev:riscv64 linux-config-7.2:riscv64 \
python3 rsynccurl -L \
https://git.kernel.org/torvalds/t/linux-7.4-rc3.tar.gz \
| tar xz
Quoted 7 lines
pushd linux-7.4-rc3
b4 am -v1 -o- \
https://lore.kernel.org/all/[email protected]/ \
| patch -p1
b4 am -v5 -P3 -o- \
https://lore.kernel.org/all/[email protected]/ \
| patch -p1
After applying that patch, you also need to change:
clock-names = "axi", "ref";
into
clock-names = "axi", "ref_clk";
to match the change done in the code in v8.
[...]
Quoted 14 lines
I do notice some UFS-related warnings and errors in dmesg:
journalctl --dmesg | grep ufshcd
ufshcd-spacemit c0e00000.ufshc: freq-table-hz property not specified ufshcd-spacemit c0e00000.ufshc:ufshcd_populate_vreg: Unable to find vdd-hba-supply regulator, assuming enabled
ufshcd-spacemit c0e00000.ufshc:ufshcd_populate_vreg: Unable to find vcc-supply regulator, assuming enabled
ufshcd-spacemit c0e00000.ufshc:ufshcd_populate_vreg: Unable to find vccq-supply regulator, assuming enabled
ufshcd-spacemit c0e00000.ufshc:ufshcd_populate_vreg: Unable to find vccq2-supply regulator, assuming enabled
scsi host0: ufshcd
ufshcd-spacemit c0e00000.ufshc:ufshcd_scsi_add_wlus: BOOT WLUN not found
I do have all those messages, I think they are just harmless.
Quoted 2 lines
ufshcd-spacemit c0e00000.ufshc: DL error event, INT errors:0x4, DL_ERR:0x80000020
This one looks more worrying. I do not have it when testing. Does it happens immediately or after a while? under load?
Regards
Aurelien
Signature · 2 lines
Aurelien Jarno GPG: 4096R/1DDD8C9B [email protected] http://aurel32.net
Hi Yixun, and Aurelien,
Quoted 139 lines · Aurelien Jarno
Hi,
Quoted 128 lines · E Shattow
Hi Yixun,
Quoted 95 lines · Yixun Lan
This series try to add UFS support for SpacemiT K3 SoC, the controller components consists of System Bus Interface Unit, UFS Host Controller Interface, UFS Transport Protocol Layer, UFS Host Registers, Device Management Entity (DME), Transport Layer, Network Layer, Data Link Layer, PHY Adapter Layer, and M-PHY Interface. A more detail functional block diagram can be found in SpacemiT website, chapter 9.7.3 [1]
The DTS patch has been dropped in this series [2], and will send in separate series once this patch accepted. For people who want to test UFS driver, please grab the DT patch from version v5 [3].
Enable
UFSHCD_CAP_KEEP_AUTO_BKOPS_ENABLED_EXCEPT_SUSPEND, This allows the device auto-bkops to be always enabled except during suspend (both runtime and suspend), with this feature, the BKOPS interrupt (log below) isn't reported anymore.[ 806.710763] ufshcd-spacemit c0e00000.ufshc: ufshcd_bkops_exception_event_handler: device raised urgent BKOPS exception for bkops status 1Signed-off-by Yixun Lan <[email protected]>---
Changes in v8:
- enableUFSHCD_CAP_KEEP_AUTO_BKOPS_ENABLED_EXCEPT_SUSPEND
- rename to "ref_clk", see explanation in patch
- add delay between enable clk & deassert reset
- respect bRefClkGatingWaitTime, add wait delay
- drop comment ofufs_hba_spacemit_vops, which got CI complaint
- rebase to v7.4-rc1
- Link to v7: https://patch.msgid.link/[email protected]Changes in v7:
- check err return value ofufs_spacemit_quirk_host_pa_saveconfigtime()
- Link to v6: https://patch.msgid.link/[email protected]Changes in v6:
- drop unused macro anddev_req_params
- use globalPX_xxmacros
- fix axi clock name
- drop dts patch
- collect tags
- Link to v5: https://patch.msgid.link/[email protected]Changes in v5:
- adjust clock names
- add runtime power support
- collect tags
- Link to v4: https://patch.msgid.link/[email protected]Changes in v4:
- fix clock and reset settings
- drop function which retrieve value oftx_lanes
- propagate return error ofufs_spacemit_dme_set()
- check return valueufs_spacemit_check_hibern8()
- drop call toufshcd_vops_phy_initialization()
- handle compiling warning ifCONFIG_OFnot enabled
add__maybe_unusedtoufs_spacemit_of_match
- Link to v3: https://patch.msgid.link/[email protected]Changes in v3:
- collect tags
- fix dt-binding warning reported-by sashiko
- fix low freq in opp-2 table
- fix err checking incheck_hibern8()
- propagate err code inlink_startup_notify()
- update documents forevent_notify()
- ufs clock driver is merged into v7.3-rc1, update cover letter
- Link to v2: https://patch.msgid.link/[email protected]Changes in v2:
- fix missing interrupts property
- move ufs node tok3-com260.dtsi
- convert freq-table-hz to operating-points-v2
- reworkreset_control, fix header and drop global variable
- dropdump_host_regs()debug interface
- converge and refactordme_set()operations
- massive reduce of busydelay()loops
- drop vendor specifichce_enable_notify(), fallback to default
- drop unused member from structufs_spacemit_host
- addCOMPILE_TESTsupport toKconfig
- comment style fix
- Link to v1: https://patch.msgid.link/[email protected]---
Yixun Lan (2):
scsi: ufs: spacemit: dt-bindings: Add UFS controller for K3 SoC
scsi: ufs: spacemit: k3: Add UFS Host Controller driver.../devicetree/bindings/ufs/spacemit,k3-ufshc.yaml | 56 ++ drivers/ufs/host/Kconfig | 12 + drivers/ufs/host/Makefile | 1 + drivers/ufs/host/ufs-spacemit.c | 655 +++++++++++++++++++++ drivers/ufs/host/ufs-spacemit.h | 77 +++ 5 files changed, 801 insertions(+)Quoted 13 lines
---
base-commit:6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
change-id: 20260605-08-k3-ufs-support-c8b308e415e2Best regards,
Signature · 7 lines
Yixun Lan <[email protected]> _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscvTested v7 and v8 successfully on Sipeed K3 Pico-ITX (32GiB DRAM / 128GiB UFS model). Build and test methodology:
### build chimera debian-installer with patched mainline kernel ### assume fresh Debian testing "forky" build environment
apt update
apt install -y b4 bc bison ca-certificates cpio \
crossbuild-essential-riscv64 curl debhelper fakeroot flex kmod \
libdw-dev libssl-dev libssl-dev:riscv64 linux-config-7.2:riscv64 \
python3 rsynccurl -L \
https://git.kernel.org/torvalds/t/linux-7.4-rc3.tar.gz \
| tar xzQuoted 7 lines
pushd linux-7.4-rc3
b4 am -v1 -o- \
https://lore.kernel.org/all/[email protected]/ \
| patch -p1
b4 am -v5 -P3 -o- \
https://lore.kernel.org/all/[email protected]/ \
| patch -p1
Quoted 8 lines
After applying that patch, you also need to change:
clock-names = "axi", "ref";
into
clock-names = "axi", "ref_clk";
to match the change done in the code in v8.[...]
I was missing this detail previously. For testing again of v8 I have now inserted a sed pipe to change this as suggested for the dts application step of the build procedure:
b4 am -v5 -P3 -o- \
https://lore.kernel.org/all/[email protected]/ \
| sed -z 's%\(clock-names = "axi", "\)ref\(";\)%\1ref_clk\2%' \
| patch -p1
Additionally to the build procedure, since Debian testing now features linux-config-7.3 and no longer linux-config-7.2, I now substitute accordingly from linux-config-7.2 to linux-config-7.3
Quoted 17 lines
Quoted 14 lines
I do notice some UFS-related warnings and errors in dmesg:
journalctl --dmesg | grep ufshcd
ufshcd-spacemit c0e00000.ufshc: freq-table-hz property not specified ufshcd-spacemit c0e00000.ufshc:ufshcd_populate_vreg: Unable to find vdd-hba-supply regulator, assuming enabled
ufshcd-spacemit c0e00000.ufshc:ufshcd_populate_vreg: Unable to find vcc-supply regulator, assuming enabled
ufshcd-spacemit c0e00000.ufshc:ufshcd_populate_vreg: Unable to find vccq-supply regulator, assuming enabled
ufshcd-spacemit c0e00000.ufshc:ufshcd_populate_vreg: Unable to find vccq2-supply regulator, assuming enabled
scsi host0: ufshcd
ufshcd-spacemit c0e00000.ufshc:ufshcd_scsi_add_wlus: BOOT WLUN not foundI do have all those messages, I think they are just harmless.
Quoted 9 lines
Quoted 2 lines
ufshcd-spacemit c0e00000.ufshc: DL error event, INT errors:0x4, DL_ERR:0x80000020
This one looks more worrying. I do not have it when testing. Does it happens immediately or after a while? under load?
Regards
Aurelien
$ journalctl --dmesg | grep ufshcd ufshcd-spacemit c0e00000.ufshc: freq-table-hz property not specified ufshcd-spacemit c0e00000.ufshc: ufshcd_populate_vreg: Unable to find vdd-hba-supply regulator, assuming enabled ufshcd-spacemit c0e00000.ufshc: ufshcd_populate_vreg: Unable to find vcc-supply regulator, assuming enabled ufshcd-spacemit c0e00000.ufshc: ufshcd_populate_vreg: Unable to find vccq-supply regulator, assuming enabled ufshcd-spacemit c0e00000.ufshc: ufshcd_populate_vreg: Unable to find vccq2-supply regulator, assuming enabled scsi host0: ufshcd ufshcd-spacemit c0e00000.ufshc: ufshcd_scsi_add_wlus: BOOT WLUN not found
I did not again see the DL error event. However, the first attempt to build Linux does fail:
make[7]: *** [scripts/Makefile.build:572: drivers/gpu/drm] Error 2 make[6]: *** [scripts/Makefile.build:572: drivers/gpu] Error 2
...
make[5]: *** [scripts/Makefile.build:572: drivers] Error 2 make[4]: *** [Makefile:2244: .] Error 2
make[3]: *** [debian/rules:80: build-arch] Error 2
dpkg-buildpackage: error: make -f debian/rules binary subprocess failed with exit status 2
make[2]: *** [scripts/Makefile.package:126: bindeb-pkg] Error 2 make[1]: *** [/home/es/linux-7.4-rc3/Makefile:1852: bindeb-pkg] Error 2
make: *** [Makefile:248: __sub-make] Error 2
real 188m48.844s user 1415m17.363s sys 66m11.932s
Linux is running on the K3 SoC here without clocks preparation from the bootloader; it is quite slow by comparison to a Linux kernel that follows clock preparations by the vendor BSP bootloader. Simply re-running the same "make ..." build command is successful in the same system without any changes:
DEPMOD debian/linux-image-7.4.0-rc3-k3ufs/lib/modules/7.4.0-rc3-k3ufs
...
dpkg-deb: building package 'linux-image-7.4.0-rc3-k3ufs' in '../linux-image-7.4.0-rc3-k3ufs_7.4.0~rc3-2_riscv64.deb'.
...
real 34m56.794s user 241m15.511s sys 18m4.532s
Similar build failures occasionally happen when the root filesystem is on USB microSD adapter-connected microSD storage. I assume the build failures with default clocks configuration are not constrained to just the UFS support series here.
-E
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Hi,
Quoted 12 lines · E Shattow
I was missing this detail previously. For testing again of v8 I have now inserted a sed pipe to change this as suggested for the dts application step of the build procedure:
b4 am -v5 -P3 -o- \
https://lore.kernel.org/all/[email protected]/ \
| sed -z 's%\(clock-names = "axi", "\)ref\(";\)%\1ref_clk\2%' \
| patch -p1Additionally to the build procedure, since Debian testing now features linux-config-7.3 and no longer linux-config-7.2, I now substitute accordingly from linux-config-7.2 to linux-config-7.3
[...]
Quoted 4 lines
$ journalctl --dmesg | grep ufshcd ufshcd-spacemit c0e00000.ufshc: freq-table-hz property not specified ufshcd-spacemit c0e00000.ufshc: ufshcd_populate_vreg: Unable to find vdd-hba-supply regulator, assuming enabled
Quoted 8 lines
ufshcd-spacemit c0e00000.ufshc: ufshcd_populate_vreg: Unable to find vcc-supply regulator, assuming enabled ufshcd-spacemit c0e00000.ufshc: ufshcd_populate_vreg: Unable to find vccq-supply regulator, assuming enabled ufshcd-spacemit c0e00000.ufshc: ufshcd_populate_vreg: Unable to find vccq2-supply regulator, assuming enabled scsi host0: ufshcd ufshcd-spacemit c0e00000.ufshc: ufshcd_scsi_add_wlus: BOOT WLUN not found
All those are expected, so it's great that the issue you reported is fixed.
Quoted 15 lines
I did not again see the DL error event. However, the first attempt to build Linux does fail:
make[7]: *** [
scripts/Makefile.build:572:drivers/gpu/drm] Error 2 make[6]: *** [scripts/Makefile.build:572:drivers/gpu] Error 2
...
make[5]: *** [scripts/Makefile.build:572: drivers] Error 2 make[4]: *** [Makefile:2244: .] Error 2
make[3]: *** [debian/rules:80: build-arch] Error 2
dpkg-buildpackage: error: make -f debian/rules binary subprocess failed with exit status 2
make[2]: *** [scripts/Makefile.package:126: bindeb-pkg] Error 2 make[1]: *** [/home/es/linux-7.4-rc3/Makefile:1852: bindeb-pkg] Error 2
make: *** [Makefile:248: __sub-make] Error 2
Quoted 3 lines
real 188m48.844s user 1415m17.363s sys 66m11.932s
I guess the error is some GCC ICE.
Quoted 11 lines
Linux is running on the K3 SoC here without clocks preparation from the bootloader; it is quite slow by comparison to a Linux kernel that follows clock preparations by the vendor BSP bootloader. Simply re-running the same "make ..." build command is successful in the same system without any changes:
DEPMOD debian/linux-image-7.4.0-rc3-k3ufs/lib/modules/7.4.0-rc3-k3ufs
...
dpkg-deb: building package 'linux-image-7.4.0-rc3-k3ufs' in '../linux-image-7.4.0-rc3-k3ufs_7.4.0~rc3-2_riscv64.deb'.
...
Quoted 8 lines
real 34m56.794s user 241m15.511s sys 18m4.532sSimilar build failures occasionally happen when the root filesystem is on USB microSD adapter-connected microSD storage. I assume the build failures with default clocks configuration are not constrained to just the UFS support series here.
Yes, this is a known issue, unfortunately the K3 does not run stable under load. See this thread (although it seems at the end the K1 and K3 issues are different ones):
https://lore.kernel.org/linux-riscv/[email protected]/
Also see this Fedora issue:
https://forge.fedoraproject.org/riscv/planning/issues/36
Regards
Aurelien
Signature · 2 lines
Aurelien Jarno GPG: 4096R/1DDD8C9B [email protected] http://aurel32.net