From 538a9fd33ee6268f98c8bacaeb89121433422bae Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Sun, 1 Nov 2026 13:57:39 -0647 Subject: [PATCH 1/4] phy: samsung-ufs: Allow a delay between calibration table entries The PHY tables can only describe register writes. Tensor G4's Hibern8 exit sequence in Google's zuma calibration tables waits 10 us (COMMON_WAIT) between its write to the PMA common register 0x000 and its writes to the lane registers. Add a table entry for such a wait. Like a common block write, it runs once, on the lane 0 pass. Existing tables are unchanged. Link: https://android.googlesource.com/kernel/google-modules/soc/gs/+/204078758737776959ecc85c527a00fd2cabb62f/drivers/ufs/zuma/ufs-cal.h Link: https://android.googlesource.com/kernel/google-modules/soc/gs/+/204078758737776959ecc85c527a00fd2cabb62f/drivers/ufs/zuma/ufs-cal-if.c Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com> --- drivers/phy/samsung/phy-samsung-ufs.c | 6 ++++++ drivers/phy/samsung/phy-samsung-ufs.h | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/drivers/phy/samsung/phy-samsung-ufs.c b/drivers/phy/samsung/phy-samsung-ufs.c index 1aea9c2d6d..baa0dc60ad 100644 --- a/drivers/phy/samsung/phy-samsung-ufs.c +++ b/drivers/phy/samsung/phy-samsung-ufs.c @@ -34,6 +34,12 @@ void samsung_ufs_phy_config(struct samsung_ufs_phy *phy, { enum {LANE_0, LANE_1}; /* lane index */ + if (cfg->id == PHY_DELAY_BLK) { + if (lane == LANE_0) + udelay(cfg->val); + return; + } + switch (lane) { case LANE_0: writel(cfg->val, (phy)->reg_pma + cfg->off_0); diff --git a/drivers/phy/samsung/phy-samsung-ufs.h b/drivers/phy/samsung/phy-samsung-ufs.h index e1a41df26e..1270f5e303 100644 --- a/drivers/phy/samsung/phy-samsung-ufs.h +++ b/drivers/phy/samsung/phy-samsung-ufs.h @@ -15,6 +15,7 @@ #define PHY_COMN_BLK 1 #define PHY_TRSV_BLK 2 +#define PHY_DELAY_BLK 3 #define END_UFS_PHY_CFG { 0 } #define PHY_TRSV_CH_OFFSET 0x30 #define PHY_APB_ADDR(off) ((off) << 2) @@ -38,6 +39,12 @@ #define PHY_TRSV_REG_CFG(o, v, d) \ PHY_TRSV_REG_CFG_OFFSET(o, v, d, PHY_TRSV_CH_OFFSET) +/* Wait @us microseconds before the next entry of a table, once for all lanes. */ +#define PHY_DELAY_US_CFG(us) { \ + .val = (us), \ + .id = PHY_DELAY_BLK, \ +} + /* UFS PHY registers */ #define PHY_PLL_LOCK_STATUS 0x1e From 32334ee718cfada07f571377469150db8a1c57d6 Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Sun, 1 Nov 2026 13:58:01 -0647 Subject: [PATCH 2/4] phy: samsung-ufs: Add the Tensor G4 Hibern8 sequences Google's UFS driver runs a PMA sequence after every Hibern8 entry (ufs_cal_post_h8_enter) and another before every exit (ufs_cal_pre_h8_exit). The Tensor G4 PHY data has no cfgs_hibern8, so phy_notify_state() writes nothing and the PMA stays in its active setting while the link is in Hibern8. Add both tables from Google's zuma calibration, which the zuma and zumapro builds share (CONFIG_SOC_ZUMA). After entry: the TRSV_SQ registers 0x9f4 = 0x08 and 0xa00 = 0x3a on each lane, the common register 0x000 = 0x51, then 0xb64 = 0x30 and 0x33 on each lane. Before exit: 0x000 = 0x11, a 10 us wait, 0x9f4 = 0x00 and 0xa00 = 0x30, then 0xb64 = 0x32 and 0x22. As in the existing table, Google's byte offsets are converted to words and the lane stride is 0x800 bytes. The sequences are the same for every power mode (PMD_ALL), and Google's exit sequence has no CDR wait, so no wait_for_cdr is needed. As on gs101, the host driver runs the entry sequence after it has stopped the host clocks, where Google's runs it just before. The Pixel 8 Pro binds this data through its google,zuma-ufs-phy fallback. Its host has no idle clock gating, and runtime PM of its LUNs stays off unless userspace allows it, so it enters Hibern8 only on the way to turning the link off, at shutdown and system suspend. Google's driver runs the same entry sequence there, from the same tables. Link: https://android.googlesource.com/kernel/google-modules/soc/gs/+/204078758737776959ecc85c527a00fd2cabb62f/drivers/ufs/zuma/ufs-cal.h Link: https://android.googlesource.com/kernel/google-modules/soc/gs/+/204078758737776959ecc85c527a00fd2cabb62f/drivers/ufs/ufs-exynos.c Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com> --- drivers/phy/samsung/phy-zumapro-ufs.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/phy/samsung/phy-zumapro-ufs.c b/drivers/phy/samsung/phy-zumapro-ufs.c index 899a327f5e..195342435b 100644 --- a/drivers/phy/samsung/phy-zumapro-ufs.c +++ b/drivers/phy/samsung/phy-zumapro-ufs.c @@ -56,10 +56,36 @@ static const struct samsung_ufs_phy_cfg zumapro_pre_init[] = { END_UFS_PHY_CFG, }; +/* Google's post_h8_enter: after the link has entered Hibern8. */ +static const struct samsung_ufs_phy_cfg zumapro_post_h8_enter[] = { + PHY_TRSV_REG_CFG_OFFSET(0x27d, 0x08, PWR_MODE_ANY, 0x200), + PHY_TRSV_REG_CFG_OFFSET(0x280, 0x3a, PWR_MODE_ANY, 0x200), + PHY_COMN_REG_CFG(0x000, 0x51, PWR_MODE_ANY), + PHY_TRSV_REG_CFG_OFFSET(0x2d9, 0x30, PWR_MODE_ANY, 0x200), + PHY_TRSV_REG_CFG_OFFSET(0x2d9, 0x33, PWR_MODE_ANY, 0x200), + END_UFS_PHY_CFG, +}; + +/* Google's pre_h8_exit: before the link leaves Hibern8. */ +static const struct samsung_ufs_phy_cfg zumapro_pre_h8_exit[] = { + PHY_COMN_REG_CFG(0x000, 0x11, PWR_MODE_ANY), + PHY_DELAY_US_CFG(10), + PHY_TRSV_REG_CFG_OFFSET(0x27d, 0x00, PWR_MODE_ANY, 0x200), + PHY_TRSV_REG_CFG_OFFSET(0x280, 0x30, PWR_MODE_ANY, 0x200), + PHY_TRSV_REG_CFG_OFFSET(0x2d9, 0x32, PWR_MODE_ANY, 0x200), + PHY_TRSV_REG_CFG_OFFSET(0x2d9, 0x22, PWR_MODE_ANY, 0x200), + END_UFS_PHY_CFG, +}; + static const struct samsung_ufs_phy_cfg *zumapro_cfgs[CFG_TAG_MAX] = { [CFG_PRE_INIT] = zumapro_pre_init, }; +static const struct samsung_ufs_phy_cfg *zumapro_hibern8_cfgs[] = { + [CFG_POST_HIBERN8_ENTER] = zumapro_post_h8_enter, + [CFG_PRE_HIBERN8_EXIT] = zumapro_pre_h8_exit, +}; + static const char * const zumapro_clks[] = { "ref_clk" }; static int zumapro_wait_for_cal(struct phy *phy, u8 lane) @@ -79,6 +105,7 @@ static int zumapro_wait_for_cal(struct phy *phy, u8 lane) const struct samsung_ufs_phy_drvdata tensor_zumapro_ufs_phy = { .cfgs = zumapro_cfgs, + .cfgs_hibern8 = zumapro_hibern8_cfgs, .isol = { .offset = 0x3ec0, .mask = BIT(0), From 01f34955939b49467f05cee2e70435f7ba7a8724 Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Sun, 1 Nov 2026 13:58:38 -0647 Subject: [PATCH 3/4] scsi: ufs: exynos: Give Tensor G3 its own host data The Pixel 8 Pro's UFS host is "google,zuma-ufs", "google,zumapro-ufs", and the driver matches only the fallback, so Tensor G3 and Tensor G4 share one set of host data and anything enabled for G4 reaches G3 too. Idle Hibern8 has not been tried on G3 yet, and the next patch turns on idle clock gating with the link in Hibern8 on G4. Match "google,zuma-ufs", which the binding already documents, with a copy of today's data, and rename the shared drv_init to the SoC that keeps it. No functional change. Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com> --- drivers/ufs/host/ufs-exynos.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/drivers/ufs/host/ufs-exynos.c b/drivers/ufs/host/ufs-exynos.c index 61078ad79c..c45e64ed7c 100644 --- a/drivers/ufs/host/ufs-exynos.c +++ b/drivers/ufs/host/ufs-exynos.c @@ -266,7 +266,7 @@ static int gs201_ufs_drv_init(struct exynos_ufs *ufs) return gs101_ufs_drv_init(ufs); } -static int zumapro_ufs_drv_init(struct exynos_ufs *ufs) +static int zuma_ufs_drv_init(struct exynos_ufs *ufs) { u32 reg; @@ -2545,7 +2545,28 @@ static const struct exynos_ufs_drv_data gs201_ufs_drvs = { .suspend = gs101_ufs_suspend, }; -/* G4 shares the G2 descriptor format, but not its PHY/PCS calibration. */ +/* + * G3 and G4 share the G2 descriptor format, but not its PHY/PCS calibration. + * G3 (zuma) runs the G4 data, which its device tree names as a fallback. + */ +static const struct exynos_ufs_drv_data zuma_ufs_drvs = { + .uic_attr = &gs101_uic_attr, + .quirks = UFSHCI_QUIRK_SKIP_MANUAL_WB_FLUSH_CTRL | + UFSHCD_QUIRK_BROKEN_AUTO_HIBERN8 | + UFSHCD_QUIRK_SKIP_DEF_UNIPRO_TIMEOUT_SETTING, + .opts = EXYNOS_UFS_OPT_SKIP_CONFIG_PHY_ATTR | + EXYNOS_UFS_OPT_UFSPR_SECURE | + EXYNOS_UFS_OPT_TIMER_TICK_SELECT | + EXYNOS_UFS_OPT_CLKSTOP_PRE_CHANGE | + EXYNOS_UFS_OPT_UNGATE_POST_CHANGE, + .iocc_mask = UFS_GS101_SHARABLE, + .drv_init = zuma_ufs_drv_init, + .suspend = gs101_ufs_suspend, + .pre_link = zumapro_ufs_pre_link, + .post_link = zumapro_ufs_post_link, + .pre_pwr_change = zumapro_ufs_pre_pwr_change, +}; + static const struct exynos_ufs_drv_data zumapro_ufs_drvs = { .uic_attr = &gs101_uic_attr, .quirks = UFSHCI_QUIRK_SKIP_MANUAL_WB_FLUSH_CTRL | @@ -2557,7 +2578,7 @@ static const struct exynos_ufs_drv_data zumapro_ufs_drvs = { EXYNOS_UFS_OPT_CLKSTOP_PRE_CHANGE | EXYNOS_UFS_OPT_UNGATE_POST_CHANGE, .iocc_mask = UFS_GS101_SHARABLE, - .drv_init = zumapro_ufs_drv_init, + .drv_init = zuma_ufs_drv_init, .suspend = gs101_ufs_suspend, .pre_link = zumapro_ufs_pre_link, .post_link = zumapro_ufs_post_link, @@ -2584,6 +2605,8 @@ static const struct of_device_id exynos_ufs_of_match[] = { .data = &gs101_ufs_drvs }, { .compatible = "google,gs201-ufs", .data = &gs201_ufs_drvs }, + { .compatible = "google,zuma-ufs", + .data = &zuma_ufs_drvs }, { .compatible = "google,zumapro-ufs", .data = &zumapro_ufs_drvs }, { .compatible = "samsung,exynos7-ufs", From 5894c5287770d597c1b0a580cb8a0d5d4f693a7a Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Tue, 27 Oct 2026 14:57:47 -0647 Subject: [PATCH 4/4] scsi: ufs: exynos: zumapro: Gate the host clocks when idle zumapro set neither UFSHCD_CAP_CLK_GATING nor UFSHCD_CAP_HIBERN8_WITH_CLK_GATING, so the host clocks never went off at idle. The core also holds its CPU latency request at 0 while the clocks are on (on a host without clock scaling), so no core reached its C2 state. Gate them with the link in Hibern8 after the core's idle delay, as gs101 and gs201 do, and as Google's driver does on zumapro: its zuma-ufs.dtsi has no samsung,support-ah8, so it sets both caps. Only Tensor G4 gets this. Tensor G3 keeps its own host data, with the link active at idle, until Hibern8 has been tried there. Tested on the Pixel 9a with 7.3.0-rc6-omamobile-tegu-s2mpg15-m1-g991042e2eff3-dirty, before the PHY's Hibern8 sequences were added: clkgate_enable 1 with the 150 ms default delay, pm_qos_enable left on, /dev/cpu_dma_latency idle at the default, and in an idle minute cpu0 spent 36 s in C2, cpu4 39 s and cpu7 41 s (0 s with the clocks held on). A cold read of 20000 files under /usr and 30 fsync'd 8 MiB writes with idle gaps between them ran with no UFS errors, and the root file system has been on it since boot. Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com> --- drivers/ufs/host/ufs-exynos.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/ufs/host/ufs-exynos.c b/drivers/ufs/host/ufs-exynos.c index c45e64ed7c..5a4b13db29 100644 --- a/drivers/ufs/host/ufs-exynos.c +++ b/drivers/ufs/host/ufs-exynos.c @@ -278,6 +278,18 @@ static int zuma_ufs_drv_init(struct exynos_ufs *ufs) return exynos_ufs_shareability(ufs); } +static int zumapro_ufs_drv_init(struct exynos_ufs *ufs) +{ + /* + * Idle clock gating with the link in Hibern8, as on gs101 and gs201: + * it also drops the CPU latency request the core holds while the + * clocks are on. + */ + ufs->hba->caps |= UFSHCD_CAP_CLK_GATING | UFSHCD_CAP_HIBERN8_WITH_CLK_GATING; + + return zuma_ufs_drv_init(ufs); +} + static int exynosauto_ufs_drv_init(struct exynos_ufs *ufs) { return exynos_ufs_shareability(ufs); @@ -2578,7 +2590,7 @@ static const struct exynos_ufs_drv_data zumapro_ufs_drvs = { EXYNOS_UFS_OPT_CLKSTOP_PRE_CHANGE | EXYNOS_UFS_OPT_UNGATE_POST_CHANGE, .iocc_mask = UFS_GS101_SHARABLE, - .drv_init = zuma_ufs_drv_init, + .drv_init = zumapro_ufs_drv_init, .suspend = gs101_ufs_suspend, .pre_link = zumapro_ufs_pre_link, .post_link = zumapro_ufs_post_link,