* [PATCH v2 01/11] scsi: ufs: exynos: Allow UFS Gear 4
2024-10-25 13:14 [PATCH v2 00/11] UFS cleanups and enhancements to ufs-exynos for gs101 Peter Griffin
@ 2024-10-25 13:14 ` Peter Griffin
2024-10-30 8:04 ` Tudor Ambarus
2024-10-25 13:14 ` [PATCH v2 02/11] scsi: ufs: exynos: add check inside exynos_ufs_config_smu() Peter Griffin
` (9 subsequent siblings)
10 siblings, 1 reply; 29+ messages in thread
From: Peter Griffin @ 2024-10-25 13:14 UTC (permalink / raw)
To: alim.akhtar, James.Bottomley, martin.petersen, avri.altman,
bvanassche, krzk
Cc: tudor.ambarus, andre.draszik, kernel-team, willmcvicker,
linux-scsi, devicetree, linux-arm-kernel, linux-samsung-soc,
linux-kernel, ebiggers, Peter Griffin
UFS Gear 4 offers faster speeds, and better power usage so lets
enable it.
Currently ufshcd_init_host_params() sets UFS_HS_G3 as a default,
so even if the device supports G4 we end up negotiating down to
G3.
For SoCs like gs101 which have a UFS major controller version
of 3 or above advertise Gear 4. This then allows a Gear 4 link
on Pixel 6.
For earlier controller versions keep the current default behaviour
of reporting G3.
Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
---
drivers/ufs/host/ufs-exynos.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/drivers/ufs/host/ufs-exynos.c b/drivers/ufs/host/ufs-exynos.c
index 9ec318ef52bf..e25de4b86ac0 100644
--- a/drivers/ufs/host/ufs-exynos.c
+++ b/drivers/ufs/host/ufs-exynos.c
@@ -771,6 +771,21 @@ static void exynos_ufs_config_sync_pattern_mask(struct exynos_ufs *ufs,
exynos_ufs_disable_ov_tm(hba);
}
+#define UFS_HW_VER_MAJOR_MASK GENMASK(15, 8)
+
+static u32 exynos_ufs_get_hs_gear(struct ufs_hba *hba)
+{
+ u8 major;
+
+ major = FIELD_GET(UFS_HW_VER_MAJOR_MASK, hba->ufs_version);
+
+ if (major >= 3)
+ return UFS_HS_G4;
+
+ /* Default is HS-G3 */
+ return UFS_HS_G3;
+}
+
static int exynos_ufs_pre_pwr_mode(struct ufs_hba *hba,
struct ufs_pa_layer_attr *dev_max_params,
struct ufs_pa_layer_attr *dev_req_params)
@@ -787,6 +802,8 @@ static int exynos_ufs_pre_pwr_mode(struct ufs_hba *hba,
}
ufshcd_init_host_params(&host_params);
+ /* This driver only support symmetric gear setting e.g. hs_tx_gear == hs_rx_gear */
+ host_params.hs_tx_gear = host_params.hs_rx_gear = exynos_ufs_get_hs_gear(hba);
ret = ufshcd_negotiate_pwr_params(&host_params, dev_max_params, dev_req_params);
if (ret) {
--
2.47.0.163.g1226f6d8fa-goog
^ permalink raw reply related [flat|nested] 29+ messages in thread
* Re: [PATCH v2 01/11] scsi: ufs: exynos: Allow UFS Gear 4
2024-10-25 13:14 ` [PATCH v2 01/11] scsi: ufs: exynos: Allow UFS Gear 4 Peter Griffin
@ 2024-10-30 8:04 ` Tudor Ambarus
2024-10-30 12:05 ` Peter Griffin
0 siblings, 1 reply; 29+ messages in thread
From: Tudor Ambarus @ 2024-10-30 8:04 UTC (permalink / raw)
To: Peter Griffin, alim.akhtar, James.Bottomley, martin.petersen,
avri.altman, bvanassche, krzk
Cc: andre.draszik, kernel-team, willmcvicker, linux-scsi, devicetree,
linux-arm-kernel, linux-samsung-soc, linux-kernel, ebiggers
On 10/25/24 2:14 PM, Peter Griffin wrote:
> UFS Gear 4 offers faster speeds, and better power usage so lets
> enable it.
>
> Currently ufshcd_init_host_params() sets UFS_HS_G3 as a default,
> so even if the device supports G4 we end up negotiating down to
> G3.
>
> For SoCs like gs101 which have a UFS major controller version
> of 3 or above advertise Gear 4. This then allows a Gear 4 link
> on Pixel 6.
>
> For earlier controller versions keep the current default behaviour
> of reporting G3.
>
> Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
Reviewed-by: Tudor Ambarus <tudor.ambarus@linaro.org>
some nits/personal preferences below, no need to address them
> ---
> drivers/ufs/host/ufs-exynos.c | 17 +++++++++++++++++
> 1 file changed, 17 insertions(+)
>
> diff --git a/drivers/ufs/host/ufs-exynos.c b/drivers/ufs/host/ufs-exynos.c
> index 9ec318ef52bf..e25de4b86ac0 100644
> --- a/drivers/ufs/host/ufs-exynos.c
> +++ b/drivers/ufs/host/ufs-exynos.c
> @@ -771,6 +771,21 @@ static void exynos_ufs_config_sync_pattern_mask(struct exynos_ufs *ufs,
> exynos_ufs_disable_ov_tm(hba);
> }
>
> +#define UFS_HW_VER_MAJOR_MASK GENMASK(15, 8)
> +
> +static u32 exynos_ufs_get_hs_gear(struct ufs_hba *hba)
> +{
> + u8 major;
> +
> + major = FIELD_GET(UFS_HW_VER_MAJOR_MASK, hba->ufs_version);
> +
> + if (major >= 3)
> + return UFS_HS_G4;
> +
> + /* Default is HS-G3 */
> + return UFS_HS_G3;
> +}
> +
> static int exynos_ufs_pre_pwr_mode(struct ufs_hba *hba,
> struct ufs_pa_layer_attr *dev_max_params,
> struct ufs_pa_layer_attr *dev_req_params)
> @@ -787,6 +802,8 @@ static int exynos_ufs_pre_pwr_mode(struct ufs_hba *hba,
> }
>
> ufshcd_init_host_params(&host_params);
blank line
> + /* This driver only support symmetric gear setting e.g. hs_tx_gear == hs_rx_gear */
> + host_params.hs_tx_gear = host_params.hs_rx_gear = exynos_ufs_get_hs_gear(hba);
I find it easier to read if you split inits on their own line:
host_params.hs_tx_gear = exynos_ufs_get_hs_gear(hba);
host_params.hs_rx_gear = exynos_ufs_get_hs_gear(hba);
>
> ret = ufshcd_negotiate_pwr_params(&host_params, dev_max_params, dev_req_params);
> if (ret) {
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH v2 01/11] scsi: ufs: exynos: Allow UFS Gear 4
2024-10-30 8:04 ` Tudor Ambarus
@ 2024-10-30 12:05 ` Peter Griffin
0 siblings, 0 replies; 29+ messages in thread
From: Peter Griffin @ 2024-10-30 12:05 UTC (permalink / raw)
To: Tudor Ambarus
Cc: alim.akhtar, James.Bottomley, martin.petersen, avri.altman,
bvanassche, krzk, andre.draszik, kernel-team, willmcvicker,
linux-scsi, devicetree, linux-arm-kernel, linux-samsung-soc,
linux-kernel, ebiggers
Hi Tudor,
On Wed, 30 Oct 2024 at 08:04, Tudor Ambarus <tudor.ambarus@linaro.org> wrote:
>
>
>
> On 10/25/24 2:14 PM, Peter Griffin wrote:
> > UFS Gear 4 offers faster speeds, and better power usage so lets
> > enable it.
> >
> > Currently ufshcd_init_host_params() sets UFS_HS_G3 as a default,
> > so even if the device supports G4 we end up negotiating down to
> > G3.
> >
> > For SoCs like gs101 which have a UFS major controller version
> > of 3 or above advertise Gear 4. This then allows a Gear 4 link
> > on Pixel 6.
> >
> > For earlier controller versions keep the current default behaviour
> > of reporting G3.
> >
> > Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
>
> Reviewed-by: Tudor Ambarus <tudor.ambarus@linaro.org>
>
> some nits/personal preferences below, no need to address them
As I'm re-spinning anyways I'll update it like you suggest.
Peter.
^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH v2 02/11] scsi: ufs: exynos: add check inside exynos_ufs_config_smu()
2024-10-25 13:14 [PATCH v2 00/11] UFS cleanups and enhancements to ufs-exynos for gs101 Peter Griffin
2024-10-25 13:14 ` [PATCH v2 01/11] scsi: ufs: exynos: Allow UFS Gear 4 Peter Griffin
@ 2024-10-25 13:14 ` Peter Griffin
2024-10-30 8:12 ` Tudor Ambarus
2024-10-25 13:14 ` [PATCH v2 03/11] scsi: ufs: exynos: gs101: remove EXYNOS_UFS_OPT_BROKEN_AUTO_CLK_CTRL Peter Griffin
` (8 subsequent siblings)
10 siblings, 1 reply; 29+ messages in thread
From: Peter Griffin @ 2024-10-25 13:14 UTC (permalink / raw)
To: alim.akhtar, James.Bottomley, martin.petersen, avri.altman,
bvanassche, krzk
Cc: tudor.ambarus, andre.draszik, kernel-team, willmcvicker,
linux-scsi, devicetree, linux-arm-kernel, linux-samsung-soc,
linux-kernel, ebiggers, Peter Griffin
Move the EXYNOS_UFS_OPT_UFSPR_SECURE check inside exynos_ufs_config_smu().
This way all call sites will benefit from the check. This fixes a bug
currently in the exynos_ufs_resume() path on gs101 which will cause
a serror.
Fixes: d11e0a318df8 ("scsi: ufs: exynos: Add support for Tensor gs101 SoC")
Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
---
drivers/ufs/host/ufs-exynos.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/ufs/host/ufs-exynos.c b/drivers/ufs/host/ufs-exynos.c
index e25de4b86ac0..939d08bce545 100644
--- a/drivers/ufs/host/ufs-exynos.c
+++ b/drivers/ufs/host/ufs-exynos.c
@@ -724,6 +724,9 @@ static void exynos_ufs_config_smu(struct exynos_ufs *ufs)
{
u32 reg, val;
+ if (ufs->opts & EXYNOS_UFS_OPT_UFSPR_SECURE)
+ return;
+
exynos_ufs_disable_auto_ctrl_hcc_save(ufs, &val);
/* make encryption disabled by default */
@@ -1457,8 +1460,8 @@ static int exynos_ufs_init(struct ufs_hba *hba)
if (ret)
goto out;
exynos_ufs_specify_phy_time_attr(ufs);
- if (!(ufs->opts & EXYNOS_UFS_OPT_UFSPR_SECURE))
- exynos_ufs_config_smu(ufs);
+
+ exynos_ufs_config_smu(ufs);
hba->host->dma_alignment = DATA_UNIT_SIZE - 1;
return 0;
--
2.47.0.163.g1226f6d8fa-goog
^ permalink raw reply related [flat|nested] 29+ messages in thread
* Re: [PATCH v2 02/11] scsi: ufs: exynos: add check inside exynos_ufs_config_smu()
2024-10-25 13:14 ` [PATCH v2 02/11] scsi: ufs: exynos: add check inside exynos_ufs_config_smu() Peter Griffin
@ 2024-10-30 8:12 ` Tudor Ambarus
0 siblings, 0 replies; 29+ messages in thread
From: Tudor Ambarus @ 2024-10-30 8:12 UTC (permalink / raw)
To: Peter Griffin, alim.akhtar, James.Bottomley, martin.petersen,
avri.altman, bvanassche, krzk
Cc: andre.draszik, kernel-team, willmcvicker, linux-scsi, devicetree,
linux-arm-kernel, linux-samsung-soc, linux-kernel, ebiggers
On 10/25/24 2:14 PM, Peter Griffin wrote:
> Move the EXYNOS_UFS_OPT_UFSPR_SECURE check inside exynos_ufs_config_smu().
>
> This way all call sites will benefit from the check. This fixes a bug
> currently in the exynos_ufs_resume() path on gs101 which will cause
> a serror.
because resume() calls exynos_ufs_config_smu() and we ended up accessing
register fields that we shouldn't have.
>
> Fixes: d11e0a318df8 ("scsi: ufs: exynos: Add support for Tensor gs101 SoC")
Cc: stable@vger.kernel.org
Reviewed-by: Tudor Ambarus <tudor.ambarus@linaro.org>
> Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
> ---
> drivers/ufs/host/ufs-exynos.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/ufs/host/ufs-exynos.c b/drivers/ufs/host/ufs-exynos.c
> index e25de4b86ac0..939d08bce545 100644
> --- a/drivers/ufs/host/ufs-exynos.c
> +++ b/drivers/ufs/host/ufs-exynos.c
> @@ -724,6 +724,9 @@ static void exynos_ufs_config_smu(struct exynos_ufs *ufs)
> {
> u32 reg, val;
>
> + if (ufs->opts & EXYNOS_UFS_OPT_UFSPR_SECURE)
> + return;
> +
> exynos_ufs_disable_auto_ctrl_hcc_save(ufs, &val);
>
> /* make encryption disabled by default */
> @@ -1457,8 +1460,8 @@ static int exynos_ufs_init(struct ufs_hba *hba)
> if (ret)
> goto out;
> exynos_ufs_specify_phy_time_attr(ufs);
> - if (!(ufs->opts & EXYNOS_UFS_OPT_UFSPR_SECURE))
> - exynos_ufs_config_smu(ufs);
> +
> + exynos_ufs_config_smu(ufs);
>
> hba->host->dma_alignment = DATA_UNIT_SIZE - 1;
> return 0;
^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH v2 03/11] scsi: ufs: exynos: gs101: remove EXYNOS_UFS_OPT_BROKEN_AUTO_CLK_CTRL
2024-10-25 13:14 [PATCH v2 00/11] UFS cleanups and enhancements to ufs-exynos for gs101 Peter Griffin
2024-10-25 13:14 ` [PATCH v2 01/11] scsi: ufs: exynos: Allow UFS Gear 4 Peter Griffin
2024-10-25 13:14 ` [PATCH v2 02/11] scsi: ufs: exynos: add check inside exynos_ufs_config_smu() Peter Griffin
@ 2024-10-25 13:14 ` Peter Griffin
2024-10-30 8:24 ` Tudor Ambarus
2024-10-25 13:14 ` [PATCH v2 04/11] scsi: ufs: exynos: Add EXYNOS_UFS_OPT_SKIP_CONFIG_PHY_ATTR check Peter Griffin
` (7 subsequent siblings)
10 siblings, 1 reply; 29+ messages in thread
From: Peter Griffin @ 2024-10-25 13:14 UTC (permalink / raw)
To: alim.akhtar, James.Bottomley, martin.petersen, avri.altman,
bvanassche, krzk
Cc: tudor.ambarus, andre.draszik, kernel-team, willmcvicker,
linux-scsi, devicetree, linux-arm-kernel, linux-samsung-soc,
linux-kernel, ebiggers, Peter Griffin
This flag is not required for gs101 SoC.
Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
---
drivers/ufs/host/ufs-exynos.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/ufs/host/ufs-exynos.c b/drivers/ufs/host/ufs-exynos.c
index 939d08bce545..d685d3e93ea1 100644
--- a/drivers/ufs/host/ufs-exynos.c
+++ b/drivers/ufs/host/ufs-exynos.c
@@ -2142,8 +2142,7 @@ static const struct exynos_ufs_drv_data gs101_ufs_drvs = {
UFSHCD_QUIRK_BROKEN_OCS_FATAL_ERROR |
UFSHCI_QUIRK_SKIP_MANUAL_WB_FLUSH_CTRL |
UFSHCD_QUIRK_SKIP_DEF_UNIPRO_TIMEOUT_SETTING,
- .opts = EXYNOS_UFS_OPT_BROKEN_AUTO_CLK_CTRL |
- EXYNOS_UFS_OPT_SKIP_CONFIG_PHY_ATTR |
+ .opts = EXYNOS_UFS_OPT_SKIP_CONFIG_PHY_ATTR |
EXYNOS_UFS_OPT_UFSPR_SECURE |
EXYNOS_UFS_OPT_TIMER_TICK_SELECT,
.drv_init = exynosauto_ufs_drv_init,
--
2.47.0.163.g1226f6d8fa-goog
^ permalink raw reply related [flat|nested] 29+ messages in thread
* Re: [PATCH v2 03/11] scsi: ufs: exynos: gs101: remove EXYNOS_UFS_OPT_BROKEN_AUTO_CLK_CTRL
2024-10-25 13:14 ` [PATCH v2 03/11] scsi: ufs: exynos: gs101: remove EXYNOS_UFS_OPT_BROKEN_AUTO_CLK_CTRL Peter Griffin
@ 2024-10-30 8:24 ` Tudor Ambarus
0 siblings, 0 replies; 29+ messages in thread
From: Tudor Ambarus @ 2024-10-30 8:24 UTC (permalink / raw)
To: Peter Griffin, alim.akhtar, James.Bottomley, martin.petersen,
avri.altman, bvanassche, krzk
Cc: andre.draszik, kernel-team, willmcvicker, linux-scsi, devicetree,
linux-arm-kernel, linux-samsung-soc, linux-kernel, ebiggers
On 10/25/24 2:14 PM, Peter Griffin wrote:
> This flag is not required for gs101 SoC.
>
nitpick, use imperative
Auto clk control works fine for gs101, remove
EXYNOS_UFS_OPT_BROKEN_AUTO_CLK_CTRL flag.
(or something along these lines)
Reviewed-by: Tudor Ambarus <tudor.ambarus@linaro.org>
> Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
> ---
> drivers/ufs/host/ufs-exynos.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/ufs/host/ufs-exynos.c b/drivers/ufs/host/ufs-exynos.c
> index 939d08bce545..d685d3e93ea1 100644
> --- a/drivers/ufs/host/ufs-exynos.c
> +++ b/drivers/ufs/host/ufs-exynos.c
> @@ -2142,8 +2142,7 @@ static const struct exynos_ufs_drv_data gs101_ufs_drvs = {
> UFSHCD_QUIRK_BROKEN_OCS_FATAL_ERROR |
> UFSHCI_QUIRK_SKIP_MANUAL_WB_FLUSH_CTRL |
> UFSHCD_QUIRK_SKIP_DEF_UNIPRO_TIMEOUT_SETTING,
> - .opts = EXYNOS_UFS_OPT_BROKEN_AUTO_CLK_CTRL |
> - EXYNOS_UFS_OPT_SKIP_CONFIG_PHY_ATTR |
> + .opts = EXYNOS_UFS_OPT_SKIP_CONFIG_PHY_ATTR |
> EXYNOS_UFS_OPT_UFSPR_SECURE |
> EXYNOS_UFS_OPT_TIMER_TICK_SELECT,
> .drv_init = exynosauto_ufs_drv_init,
^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH v2 04/11] scsi: ufs: exynos: Add EXYNOS_UFS_OPT_SKIP_CONFIG_PHY_ATTR check
2024-10-25 13:14 [PATCH v2 00/11] UFS cleanups and enhancements to ufs-exynos for gs101 Peter Griffin
` (2 preceding siblings ...)
2024-10-25 13:14 ` [PATCH v2 03/11] scsi: ufs: exynos: gs101: remove EXYNOS_UFS_OPT_BROKEN_AUTO_CLK_CTRL Peter Griffin
@ 2024-10-25 13:14 ` Peter Griffin
2024-10-30 8:56 ` Tudor Ambarus
2024-10-25 13:14 ` [PATCH v2 05/11] scsi: ufs: exynos: gs101: remove unused phy attribute fields Peter Griffin
` (6 subsequent siblings)
10 siblings, 1 reply; 29+ messages in thread
From: Peter Griffin @ 2024-10-25 13:14 UTC (permalink / raw)
To: alim.akhtar, James.Bottomley, martin.petersen, avri.altman,
bvanassche, krzk
Cc: tudor.ambarus, andre.draszik, kernel-team, willmcvicker,
linux-scsi, devicetree, linux-arm-kernel, linux-samsung-soc,
linux-kernel, ebiggers, Peter Griffin
The values calculated in exynos_ufs_specify_phy_time_attr() are only used
in exynos_ufs_config_phy_time_attr() and exynos_ufs_config_phy_cap_attr()
if EXYNOS_UFS_OPT_SKIP_CONFIG_PHY_ATTR flag is not set.
Add a check for this flag to exynos_ufs_specify_phy_time_attr() and
return for platforms that don't set it.
Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
---
drivers/ufs/host/ufs-exynos.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/ufs/host/ufs-exynos.c b/drivers/ufs/host/ufs-exynos.c
index d685d3e93ea1..a1a2fdcb8a40 100644
--- a/drivers/ufs/host/ufs-exynos.c
+++ b/drivers/ufs/host/ufs-exynos.c
@@ -546,6 +546,9 @@ static void exynos_ufs_specify_phy_time_attr(struct exynos_ufs *ufs)
struct exynos_ufs_uic_attr *attr = ufs->drv_data->uic_attr;
struct ufs_phy_time_cfg *t_cfg = &ufs->t_cfg;
+ if (ufs->opts & EXYNOS_UFS_OPT_SKIP_CONFIG_PHY_ATTR)
+ return;
+
t_cfg->tx_linereset_p =
exynos_ufs_calc_time_cntr(ufs, attr->tx_dif_p_nsec);
t_cfg->tx_linereset_n =
--
2.47.0.163.g1226f6d8fa-goog
^ permalink raw reply related [flat|nested] 29+ messages in thread
* Re: [PATCH v2 04/11] scsi: ufs: exynos: Add EXYNOS_UFS_OPT_SKIP_CONFIG_PHY_ATTR check
2024-10-25 13:14 ` [PATCH v2 04/11] scsi: ufs: exynos: Add EXYNOS_UFS_OPT_SKIP_CONFIG_PHY_ATTR check Peter Griffin
@ 2024-10-30 8:56 ` Tudor Ambarus
2024-10-30 13:29 ` Tudor Ambarus
2024-10-31 11:18 ` Peter Griffin
0 siblings, 2 replies; 29+ messages in thread
From: Tudor Ambarus @ 2024-10-30 8:56 UTC (permalink / raw)
To: Peter Griffin, alim.akhtar, James.Bottomley, martin.petersen,
avri.altman, bvanassche, krzk
Cc: andre.draszik, kernel-team, willmcvicker, linux-scsi, devicetree,
linux-arm-kernel, linux-samsung-soc, linux-kernel, ebiggers
On 10/25/24 2:14 PM, Peter Griffin wrote:
> The values calculated in exynos_ufs_specify_phy_time_attr() are only used
> in exynos_ufs_config_phy_time_attr() and exynos_ufs_config_phy_cap_attr()
all values set in exynos_ufs_specify_phy_time_attr() are used *only* in
exynos_ufs_config_phy_time_attr(). Or did I miss something?
> if EXYNOS_UFS_OPT_SKIP_CONFIG_PHY_ATTR flag is not set.
yep, wonderful.
>
> Add a check for this flag to exynos_ufs_specify_phy_time_attr() and
> return for platforms that don't set it.
>
> Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
> ---
> drivers/ufs/host/ufs-exynos.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/ufs/host/ufs-exynos.c b/drivers/ufs/host/ufs-exynos.c
> index d685d3e93ea1..a1a2fdcb8a40 100644
> --- a/drivers/ufs/host/ufs-exynos.c
> +++ b/drivers/ufs/host/ufs-exynos.c
> @@ -546,6 +546,9 @@ static void exynos_ufs_specify_phy_time_attr(struct exynos_ufs *ufs)
> struct exynos_ufs_uic_attr *attr = ufs->drv_data->uic_attr;
> struct ufs_phy_time_cfg *t_cfg = &ufs->t_cfg;
>
> + if (ufs->opts & EXYNOS_UFS_OPT_SKIP_CONFIG_PHY_ATTR)
> + return;
> +
> t_cfg->tx_linereset_p =
> exynos_ufs_calc_time_cntr(ufs, attr->tx_dif_p_nsec);
> t_cfg->tx_linereset_n =
tx_linereset_n, rx_hibern8_wait is set but not used anywhere. Can we
remove it? Not related to this patch though.
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH v2 04/11] scsi: ufs: exynos: Add EXYNOS_UFS_OPT_SKIP_CONFIG_PHY_ATTR check
2024-10-30 8:56 ` Tudor Ambarus
@ 2024-10-30 13:29 ` Tudor Ambarus
2024-10-31 11:18 ` Peter Griffin
1 sibling, 0 replies; 29+ messages in thread
From: Tudor Ambarus @ 2024-10-30 13:29 UTC (permalink / raw)
To: Peter Griffin, alim.akhtar, James.Bottomley, martin.petersen,
avri.altman, bvanassche, krzk
Cc: andre.draszik, kernel-team, willmcvicker, linux-scsi, devicetree,
linux-arm-kernel, linux-samsung-soc, linux-kernel, ebiggers
On 10/30/24 8:56 AM, Tudor Ambarus wrote:
> tx_linereset_n, rx_hibern8_wait is set but not used anywhere. Can we
> remove it? Not related to this patch though.
Sent patches to remove these fields at:
https://lore.kernel.org/linux-scsi/20241030132649.3575865-1-tudor.ambarus@linaro.org/
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH v2 04/11] scsi: ufs: exynos: Add EXYNOS_UFS_OPT_SKIP_CONFIG_PHY_ATTR check
2024-10-30 8:56 ` Tudor Ambarus
2024-10-30 13:29 ` Tudor Ambarus
@ 2024-10-31 11:18 ` Peter Griffin
1 sibling, 0 replies; 29+ messages in thread
From: Peter Griffin @ 2024-10-31 11:18 UTC (permalink / raw)
To: Tudor Ambarus
Cc: alim.akhtar, James.Bottomley, martin.petersen, avri.altman,
bvanassche, krzk, andre.draszik, kernel-team, willmcvicker,
linux-scsi, devicetree, linux-arm-kernel, linux-samsung-soc,
linux-kernel, ebiggers
Hi Tudor,
On Wed, 30 Oct 2024 at 08:56, Tudor Ambarus <tudor.ambarus@linaro.org> wrote:
>
>
>
> On 10/25/24 2:14 PM, Peter Griffin wrote:
> > The values calculated in exynos_ufs_specify_phy_time_attr() are only used
> > in exynos_ufs_config_phy_time_attr() and exynos_ufs_config_phy_cap_attr()
>
> all values set in exynos_ufs_specify_phy_time_attr() are used *only* in
> exynos_ufs_config_phy_time_attr(). Or did I miss something?
Yes you're right, I'll update the commit message.
>
> > if EXYNOS_UFS_OPT_SKIP_CONFIG_PHY_ATTR flag is not set.
>
> yep, wonderful.
>
> >
> > Add a check for this flag to exynos_ufs_specify_phy_time_attr() and
> > return for platforms that don't set it.
> >
> > Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
> > ---
> > drivers/ufs/host/ufs-exynos.c | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> > diff --git a/drivers/ufs/host/ufs-exynos.c b/drivers/ufs/host/ufs-exynos.c
> > index d685d3e93ea1..a1a2fdcb8a40 100644
> > --- a/drivers/ufs/host/ufs-exynos.c
> > +++ b/drivers/ufs/host/ufs-exynos.c
> > @@ -546,6 +546,9 @@ static void exynos_ufs_specify_phy_time_attr(struct exynos_ufs *ufs)
> > struct exynos_ufs_uic_attr *attr = ufs->drv_data->uic_attr;
> > struct ufs_phy_time_cfg *t_cfg = &ufs->t_cfg;
> >
> > + if (ufs->opts & EXYNOS_UFS_OPT_SKIP_CONFIG_PHY_ATTR)
> > + return;
> > +
> > t_cfg->tx_linereset_p =
> > exynos_ufs_calc_time_cntr(ufs, attr->tx_dif_p_nsec);
> > t_cfg->tx_linereset_n =
>
> tx_linereset_n, rx_hibern8_wait is set but not used anywhere. Can we
> remove it? Not related to this patch though.
Yes they can be removed if they are unused.
Peter
^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH v2 05/11] scsi: ufs: exynos: gs101: remove unused phy attribute fields
2024-10-25 13:14 [PATCH v2 00/11] UFS cleanups and enhancements to ufs-exynos for gs101 Peter Griffin
` (3 preceding siblings ...)
2024-10-25 13:14 ` [PATCH v2 04/11] scsi: ufs: exynos: Add EXYNOS_UFS_OPT_SKIP_CONFIG_PHY_ATTR check Peter Griffin
@ 2024-10-25 13:14 ` Peter Griffin
2024-10-30 9:08 ` Tudor Ambarus
2024-10-25 13:14 ` [PATCH v2 06/11] scsi: ufs: exynos: remove tx_dif_p_nsec from exynosauto_ufs_drv_init() Peter Griffin
` (5 subsequent siblings)
10 siblings, 1 reply; 29+ messages in thread
From: Peter Griffin @ 2024-10-25 13:14 UTC (permalink / raw)
To: alim.akhtar, James.Bottomley, martin.petersen, avri.altman,
bvanassche, krzk
Cc: tudor.ambarus, andre.draszik, kernel-team, willmcvicker,
linux-scsi, devicetree, linux-arm-kernel, linux-samsung-soc,
linux-kernel, ebiggers, Peter Griffin
Now that exynos_ufs_specify_phy_time_attr() checks the appropriate
EXYNOS_UFS_OPT_SKIP_CONFIG_PHY_ATTR flag. Remove the unused fields
in gs101_uic_attr.
Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
---
drivers/ufs/host/ufs-exynos.c | 20 --------------------
1 file changed, 20 deletions(-)
diff --git a/drivers/ufs/host/ufs-exynos.c b/drivers/ufs/host/ufs-exynos.c
index a1a2fdcb8a40..9d668d13fe94 100644
--- a/drivers/ufs/host/ufs-exynos.c
+++ b/drivers/ufs/host/ufs-exynos.c
@@ -2068,26 +2068,6 @@ static const struct exynos_ufs_drv_data exynos_ufs_drvs = {
static struct exynos_ufs_uic_attr gs101_uic_attr = {
.tx_trailingclks = 0xff,
- .tx_dif_p_nsec = 3000000, /* unit: ns */
- .tx_dif_n_nsec = 1000000, /* unit: ns */
- .tx_high_z_cnt_nsec = 20000, /* unit: ns */
- .tx_base_unit_nsec = 100000, /* unit: ns */
- .tx_gran_unit_nsec = 4000, /* unit: ns */
- .tx_sleep_cnt = 1000, /* unit: ns */
- .tx_min_activatetime = 0xa,
- .rx_filler_enable = 0x2,
- .rx_dif_p_nsec = 1000000, /* unit: ns */
- .rx_hibern8_wait_nsec = 4000000, /* unit: ns */
- .rx_base_unit_nsec = 100000, /* unit: ns */
- .rx_gran_unit_nsec = 4000, /* unit: ns */
- .rx_sleep_cnt = 1280, /* unit: ns */
- .rx_stall_cnt = 320, /* unit: ns */
- .rx_hs_g1_sync_len_cap = SYNC_LEN_COARSE(0xf),
- .rx_hs_g2_sync_len_cap = SYNC_LEN_COARSE(0xf),
- .rx_hs_g3_sync_len_cap = SYNC_LEN_COARSE(0xf),
- .rx_hs_g1_prep_sync_len_cap = PREP_LEN(0xf),
- .rx_hs_g2_prep_sync_len_cap = PREP_LEN(0xf),
- .rx_hs_g3_prep_sync_len_cap = PREP_LEN(0xf),
.pa_dbg_opt_suite1_val = 0x90913C1C,
.pa_dbg_opt_suite1_off = PA_GS101_DBG_OPTION_SUITE1,
.pa_dbg_opt_suite2_val = 0xE01C115F,
--
2.47.0.163.g1226f6d8fa-goog
^ permalink raw reply related [flat|nested] 29+ messages in thread
* Re: [PATCH v2 05/11] scsi: ufs: exynos: gs101: remove unused phy attribute fields
2024-10-25 13:14 ` [PATCH v2 05/11] scsi: ufs: exynos: gs101: remove unused phy attribute fields Peter Griffin
@ 2024-10-30 9:08 ` Tudor Ambarus
0 siblings, 0 replies; 29+ messages in thread
From: Tudor Ambarus @ 2024-10-30 9:08 UTC (permalink / raw)
To: Peter Griffin, alim.akhtar, James.Bottomley, martin.petersen,
avri.altman, bvanassche, krzk
Cc: andre.draszik, kernel-team, willmcvicker, linux-scsi, devicetree,
linux-arm-kernel, linux-samsung-soc, linux-kernel, ebiggers
On 10/25/24 2:14 PM, Peter Griffin wrote:
> Now that exynos_ufs_specify_phy_time_attr() checks the appropriate
> EXYNOS_UFS_OPT_SKIP_CONFIG_PHY_ATTR flag. Remove the unused fields
> in gs101_uic_attr.
>
> Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
Reviewed-by: Tudor Ambarus <tudor.ambarus@linaro.org>
> ---
> drivers/ufs/host/ufs-exynos.c | 20 --------------------
> 1 file changed, 20 deletions(-)
>
> diff --git a/drivers/ufs/host/ufs-exynos.c b/drivers/ufs/host/ufs-exynos.c
> index a1a2fdcb8a40..9d668d13fe94 100644
> --- a/drivers/ufs/host/ufs-exynos.c
> +++ b/drivers/ufs/host/ufs-exynos.c
> @@ -2068,26 +2068,6 @@ static const struct exynos_ufs_drv_data exynos_ufs_drvs = {
>
> static struct exynos_ufs_uic_attr gs101_uic_attr = {
> .tx_trailingclks = 0xff,
> - .tx_dif_p_nsec = 3000000, /* unit: ns */
> - .tx_dif_n_nsec = 1000000, /* unit: ns */
> - .tx_high_z_cnt_nsec = 20000, /* unit: ns */
> - .tx_base_unit_nsec = 100000, /* unit: ns */
> - .tx_gran_unit_nsec = 4000, /* unit: ns */
> - .tx_sleep_cnt = 1000, /* unit: ns */
Okay with the removal of the above. All are set in
exynos_ufs_specify_phy_time_attr(), which returns early if
EXYNOS_UFS_OPT_SKIP_CONFIG_PHY_ATTR is set.
> - .tx_min_activatetime = 0xa,
> - .rx_filler_enable = 0x2,
Okay with these. They are used just in exynos_ufs_config_phy_time_attr
which is guarded by EXYNOS_UFS_OPT_SKIP_CONFIG_PHY_ATTR.
> - .rx_dif_p_nsec = 1000000, /* unit: ns */
> - .rx_hibern8_wait_nsec = 4000000, /* unit: ns */
> - .rx_base_unit_nsec = 100000, /* unit: ns */
> - .rx_gran_unit_nsec = 4000, /* unit: ns */
> - .rx_sleep_cnt = 1280, /* unit: ns */
> - .rx_stall_cnt = 320, /* unit: ns */
Okay with the removal of the above. All are set in
exynos_ufs_specify_phy_time_attr(), which returns early if
EXYNOS_UFS_OPT_SKIP_CONFIG_PHY_ATTR is set.
> - .rx_hs_g1_sync_len_cap = SYNC_LEN_COARSE(0xf),
> - .rx_hs_g2_sync_len_cap = SYNC_LEN_COARSE(0xf),
> - .rx_hs_g3_sync_len_cap = SYNC_LEN_COARSE(0xf),
> - .rx_hs_g1_prep_sync_len_cap = PREP_LEN(0xf),
> - .rx_hs_g2_prep_sync_len_cap = PREP_LEN(0xf),
> - .rx_hs_g3_prep_sync_len_cap = PREP_LEN(0xf),
Okay for these as well, all are set in exynos_ufs_config_phy_cap_attr()
which is guarded by EXYNOS_UFS_OPT_SKIP_CONFIG_PHY_ATTR.
> .pa_dbg_opt_suite1_val = 0x90913C1C,
> .pa_dbg_opt_suite1_off = PA_GS101_DBG_OPTION_SUITE1,
> .pa_dbg_opt_suite2_val = 0xE01C115F,
^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH v2 06/11] scsi: ufs: exynos: remove tx_dif_p_nsec from exynosauto_ufs_drv_init()
2024-10-25 13:14 [PATCH v2 00/11] UFS cleanups and enhancements to ufs-exynos for gs101 Peter Griffin
` (4 preceding siblings ...)
2024-10-25 13:14 ` [PATCH v2 05/11] scsi: ufs: exynos: gs101: remove unused phy attribute fields Peter Griffin
@ 2024-10-25 13:14 ` Peter Griffin
2024-10-30 9:39 ` Tudor Ambarus
2024-10-25 13:14 ` [PATCH v2 07/11] scsi: ufs: exynos: add gs101_ufs_drv_init() hook and enable WriteBooster Peter Griffin
` (4 subsequent siblings)
10 siblings, 1 reply; 29+ messages in thread
From: Peter Griffin @ 2024-10-25 13:14 UTC (permalink / raw)
To: alim.akhtar, James.Bottomley, martin.petersen, avri.altman,
bvanassche, krzk
Cc: tudor.ambarus, andre.draszik, kernel-team, willmcvicker,
linux-scsi, devicetree, linux-arm-kernel, linux-samsung-soc,
linux-kernel, ebiggers, Peter Griffin
Firstly exynosauto sets EXYNOS_UFS_OPT_SKIP_CONFIG_PHY_ATTR so setting
tx_dif_p_nsec has no effect.
Secondly this assignment can't get executed as samsung,sysreg dt property
is provided in for this platform. Meaning the execution flow will return on
regmap_update_bits call above.
Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
---
drivers/ufs/host/ufs-exynos.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/drivers/ufs/host/ufs-exynos.c b/drivers/ufs/host/ufs-exynos.c
index 9d668d13fe94..d4e786afbbbc 100644
--- a/drivers/ufs/host/ufs-exynos.c
+++ b/drivers/ufs/host/ufs-exynos.c
@@ -205,8 +205,6 @@ static int exynos7_ufs_drv_init(struct device *dev, struct exynos_ufs *ufs)
static int exynosauto_ufs_drv_init(struct device *dev, struct exynos_ufs *ufs)
{
- struct exynos_ufs_uic_attr *attr = ufs->drv_data->uic_attr;
-
/* IO Coherency setting */
if (ufs->sysreg) {
return regmap_update_bits(ufs->sysreg,
@@ -214,8 +212,6 @@ static int exynosauto_ufs_drv_init(struct device *dev, struct exynos_ufs *ufs)
UFS_SHARABLE, UFS_SHARABLE);
}
- attr->tx_dif_p_nsec = 3200000;
-
return 0;
}
--
2.47.0.163.g1226f6d8fa-goog
^ permalink raw reply related [flat|nested] 29+ messages in thread
* Re: [PATCH v2 06/11] scsi: ufs: exynos: remove tx_dif_p_nsec from exynosauto_ufs_drv_init()
2024-10-25 13:14 ` [PATCH v2 06/11] scsi: ufs: exynos: remove tx_dif_p_nsec from exynosauto_ufs_drv_init() Peter Griffin
@ 2024-10-30 9:39 ` Tudor Ambarus
0 siblings, 0 replies; 29+ messages in thread
From: Tudor Ambarus @ 2024-10-30 9:39 UTC (permalink / raw)
To: Peter Griffin, alim.akhtar, James.Bottomley, martin.petersen,
avri.altman, bvanassche, krzk
Cc: andre.draszik, kernel-team, willmcvicker, linux-scsi, devicetree,
linux-arm-kernel, linux-samsung-soc, linux-kernel, ebiggers
On 10/25/24 2:14 PM, Peter Griffin wrote:
> Firstly exynosauto sets EXYNOS_UFS_OPT_SKIP_CONFIG_PHY_ATTR so setting
exynosauto and gs101, the users of exynosauto_ufs_drv_init().
> tx_dif_p_nsec has no effect.
Both set EXYNOS_UFS_OPT_SKIP_CONFIG_PHY_ATTR, the conclusion is correct
for gs101 as well.
With this addressed:
Reviewed-by: Tudor Ambarus <tudor.ambarus@linaro.org>
nitpick/personal preference: I wouldn't use the commit body as a
continuation of the subject. I would specify what the commit does in the
body as well. No need to address.
Also, as a side note, I thought of removing tx_dif_p_nsec from
exynos7_uic_attr, but it seems that this struct is used by
exynos_ufs_drvs as well, which don't set
EXYNOS_UFS_OPT_SKIP_CONFIG_PHY_ATTR. That's a little confusing, I guess
it's more clear if each driver has its own required settings specified.
^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH v2 07/11] scsi: ufs: exynos: add gs101_ufs_drv_init() hook and enable WriteBooster
2024-10-25 13:14 [PATCH v2 00/11] UFS cleanups and enhancements to ufs-exynos for gs101 Peter Griffin
` (5 preceding siblings ...)
2024-10-25 13:14 ` [PATCH v2 06/11] scsi: ufs: exynos: remove tx_dif_p_nsec from exynosauto_ufs_drv_init() Peter Griffin
@ 2024-10-25 13:14 ` Peter Griffin
2024-10-30 10:32 ` Tudor Ambarus
2024-10-25 13:14 ` [PATCH v2 08/11] scsi: ufs: exynos: enable write line unique transactions on gs101 Peter Griffin
` (3 subsequent siblings)
10 siblings, 1 reply; 29+ messages in thread
From: Peter Griffin @ 2024-10-25 13:14 UTC (permalink / raw)
To: alim.akhtar, James.Bottomley, martin.petersen, avri.altman,
bvanassche, krzk
Cc: tudor.ambarus, andre.draszik, kernel-team, willmcvicker,
linux-scsi, devicetree, linux-arm-kernel, linux-samsung-soc,
linux-kernel, ebiggers, Peter Griffin
Factor out the common code into a new exynos_ufs_shareability() function
and provide a dedicated gs101_drv_init() hook.
This allows us to enable WriteBooster capability (UFSHCD_CAP_WB_EN) in a
way that doesn't effect other SoCs supported in this driver.
WriteBooster improves write speeds by enabling a pseudo SLC cache. Using
the `fio seqwrite` test we can achieve speeds of 945MB/s with this feature
enabled (until the cache is exhausted) before dropping back to ~260MB/s
(which are the speeds we see without the WriteBooster feature enabled).
Assuming the UFSHCD_CAP_WB_EN capability is set by the host then
WriteBooster can also be enabled and disabled via sysfs so it is possible
for the system to only enable it when extra write performance is required.
Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
---
drivers/ufs/host/ufs-exynos.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/drivers/ufs/host/ufs-exynos.c b/drivers/ufs/host/ufs-exynos.c
index d4e786afbbbc..40b2563fe011 100644
--- a/drivers/ufs/host/ufs-exynos.c
+++ b/drivers/ufs/host/ufs-exynos.c
@@ -203,7 +203,7 @@ static int exynos7_ufs_drv_init(struct device *dev, struct exynos_ufs *ufs)
return 0;
}
-static int exynosauto_ufs_drv_init(struct device *dev, struct exynos_ufs *ufs)
+static int exynos_ufs_shareability(struct exynos_ufs *ufs)
{
/* IO Coherency setting */
if (ufs->sysreg) {
@@ -215,6 +215,21 @@ static int exynosauto_ufs_drv_init(struct device *dev, struct exynos_ufs *ufs)
return 0;
}
+static int gs101_ufs_drv_init(struct device *dev, struct exynos_ufs *ufs)
+{
+ struct ufs_hba *hba = ufs->hba;
+
+ /* Enable WriteBooster */
+ hba->caps |= UFSHCD_CAP_WB_EN;
+
+ return exynos_ufs_shareability(ufs);
+}
+
+static int exynosauto_ufs_drv_init(struct device *dev, struct exynos_ufs *ufs)
+{
+ return exynos_ufs_shareability(ufs);
+}
+
static int exynosauto_ufs_post_hce_enable(struct exynos_ufs *ufs)
{
struct ufs_hba *hba = ufs->hba;
@@ -2124,7 +2139,7 @@ static const struct exynos_ufs_drv_data gs101_ufs_drvs = {
.opts = EXYNOS_UFS_OPT_SKIP_CONFIG_PHY_ATTR |
EXYNOS_UFS_OPT_UFSPR_SECURE |
EXYNOS_UFS_OPT_TIMER_TICK_SELECT,
- .drv_init = exynosauto_ufs_drv_init,
+ .drv_init = gs101_ufs_drv_init,
.pre_link = gs101_ufs_pre_link,
.post_link = gs101_ufs_post_link,
.pre_pwr_change = gs101_ufs_pre_pwr_change,
--
2.47.0.163.g1226f6d8fa-goog
^ permalink raw reply related [flat|nested] 29+ messages in thread
* Re: [PATCH v2 07/11] scsi: ufs: exynos: add gs101_ufs_drv_init() hook and enable WriteBooster
2024-10-25 13:14 ` [PATCH v2 07/11] scsi: ufs: exynos: add gs101_ufs_drv_init() hook and enable WriteBooster Peter Griffin
@ 2024-10-30 10:32 ` Tudor Ambarus
0 siblings, 0 replies; 29+ messages in thread
From: Tudor Ambarus @ 2024-10-30 10:32 UTC (permalink / raw)
To: Peter Griffin, alim.akhtar, James.Bottomley, martin.petersen,
avri.altman, bvanassche, krzk
Cc: andre.draszik, kernel-team, willmcvicker, linux-scsi, devicetree,
linux-arm-kernel, linux-samsung-soc, linux-kernel, ebiggers
On 10/25/24 2:14 PM, Peter Griffin wrote:
> Factor out the common code into a new exynos_ufs_shareability() function
> and provide a dedicated gs101_drv_init() hook.
>
> This allows us to enable WriteBooster capability (UFSHCD_CAP_WB_EN) in a
> way that doesn't effect other SoCs supported in this driver.
>
> WriteBooster improves write speeds by enabling a pseudo SLC cache. Using
> the `fio seqwrite` test we can achieve speeds of 945MB/s with this feature
> enabled (until the cache is exhausted) before dropping back to ~260MB/s
> (which are the speeds we see without the WriteBooster feature enabled).
>
> Assuming the UFSHCD_CAP_WB_EN capability is set by the host then
> WriteBooster can also be enabled and disabled via sysfs so it is possible
> for the system to only enable it when extra write performance is required.
>
> Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
Reviewed-by: Tudor Ambarus <tudor.ambarus@linaro.org>
While reviewing this patch I noticed few cleanups can be made. I sent
them here:
https://lore.kernel.org/linux-scsi/20241030102715.3312308-1-tudor.ambarus@linaro.org/
Feel free to include them in your set if you're going to respin. Or not,
if you don't want to tie your head with cleanup patches. I can respin
them on top of yours later on.
^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH v2 08/11] scsi: ufs: exynos: enable write line unique transactions on gs101
2024-10-25 13:14 [PATCH v2 00/11] UFS cleanups and enhancements to ufs-exynos for gs101 Peter Griffin
` (6 preceding siblings ...)
2024-10-25 13:14 ` [PATCH v2 07/11] scsi: ufs: exynos: add gs101_ufs_drv_init() hook and enable WriteBooster Peter Griffin
@ 2024-10-25 13:14 ` Peter Griffin
2024-10-30 11:25 ` Tudor Ambarus
2024-10-25 13:14 ` [PATCH v2 09/11] scsi: ufs: exynos: set ACG to be controlled by UFS_ACG_DISABLE Peter Griffin
` (2 subsequent siblings)
10 siblings, 1 reply; 29+ messages in thread
From: Peter Griffin @ 2024-10-25 13:14 UTC (permalink / raw)
To: alim.akhtar, James.Bottomley, martin.petersen, avri.altman,
bvanassche, krzk
Cc: tudor.ambarus, andre.draszik, kernel-team, willmcvicker,
linux-scsi, devicetree, linux-arm-kernel, linux-samsung-soc,
linux-kernel, ebiggers, Peter Griffin
Previously just AXIDMA_RWDATA_BURST_LEN[3:0] field was set to 8.
To enable WLU transaction additionally we need to set Write Line
Unique enable [31], Write Line Unique Burst Length [30:27] and
AXIDMA_RWDATA_BURST_LEN[3:0].
To support WLU transaction, both burth length fields need to be 0x3.
Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
---
drivers/ufs/host/ufs-exynos.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/ufs/host/ufs-exynos.c b/drivers/ufs/host/ufs-exynos.c
index 40b2563fe011..b0cbb147c7a1 100644
--- a/drivers/ufs/host/ufs-exynos.c
+++ b/drivers/ufs/host/ufs-exynos.c
@@ -48,6 +48,8 @@
#define HCI_UNIPRO_APB_CLK_CTRL 0x68
#define UNIPRO_APB_CLK(v, x) (((v) & ~0xF) | ((x) & 0xF))
#define HCI_AXIDMA_RWDATA_BURST_LEN 0x6C
+#define WLU_EN BIT(31)
+#define WLU_BURST_LEN(x) ((x) << 27 | ((x) & 0xF))
#define HCI_GPIO_OUT 0x70
#define HCI_ERR_EN_PA_LAYER 0x78
#define HCI_ERR_EN_DL_LAYER 0x7C
@@ -1925,6 +1927,12 @@ static int gs101_ufs_post_link(struct exynos_ufs *ufs)
{
struct ufs_hba *hba = ufs->hba;
+ /*
+ * Enable Write Line Unique. This field has to be 0x3
+ * to support Write Line Unique transaction on gs101.
+ */
+ hci_writel(ufs, WLU_EN | WLU_BURST_LEN(3), HCI_AXIDMA_RWDATA_BURST_LEN);
+
exynos_ufs_enable_dbg_mode(hba);
ufshcd_dme_set(hba, UIC_ARG_MIB(PA_SAVECONFIGTIME), 0x3e8);
exynos_ufs_disable_dbg_mode(hba);
--
2.47.0.163.g1226f6d8fa-goog
^ permalink raw reply related [flat|nested] 29+ messages in thread
* Re: [PATCH v2 08/11] scsi: ufs: exynos: enable write line unique transactions on gs101
2024-10-25 13:14 ` [PATCH v2 08/11] scsi: ufs: exynos: enable write line unique transactions on gs101 Peter Griffin
@ 2024-10-30 11:25 ` Tudor Ambarus
2024-10-30 11:32 ` Peter Griffin
0 siblings, 1 reply; 29+ messages in thread
From: Tudor Ambarus @ 2024-10-30 11:25 UTC (permalink / raw)
To: Peter Griffin, alim.akhtar, James.Bottomley, martin.petersen,
avri.altman, bvanassche, krzk
Cc: andre.draszik, kernel-team, willmcvicker, linux-scsi, devicetree,
linux-arm-kernel, linux-samsung-soc, linux-kernel, ebiggers
On 10/25/24 2:14 PM, Peter Griffin wrote:
> Previously just AXIDMA_RWDATA_BURST_LEN[3:0] field was set to 8.
where was this set?
>
> To enable WLU transaction additionally we need to set Write Line
> Unique enable [31], Write Line Unique Burst Length [30:27] and
> AXIDMA_RWDATA_BURST_LEN[3:0].
>
> To support WLU transaction, both burth length fields need to be 0x3.
>
typo, s/burth/burst
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH v2 08/11] scsi: ufs: exynos: enable write line unique transactions on gs101
2024-10-30 11:25 ` Tudor Ambarus
@ 2024-10-30 11:32 ` Peter Griffin
2024-10-30 12:36 ` Tudor Ambarus
0 siblings, 1 reply; 29+ messages in thread
From: Peter Griffin @ 2024-10-30 11:32 UTC (permalink / raw)
To: Tudor Ambarus
Cc: alim.akhtar, James.Bottomley, martin.petersen, avri.altman,
bvanassche, krzk, andre.draszik, kernel-team, willmcvicker,
linux-scsi, devicetree, linux-arm-kernel, linux-samsung-soc,
linux-kernel, ebiggers
Hi Tudor,
On Wed, 30 Oct 2024 at 11:25, Tudor Ambarus <tudor.ambarus@linaro.org> wrote:
>
>
>
> On 10/25/24 2:14 PM, Peter Griffin wrote:
> > Previously just AXIDMA_RWDATA_BURST_LEN[3:0] field was set to 8.
>
> where was this set?
It is set to 0xf in exynos_ufs_post_link() function, see the following line
hci_writel(ufs, 0xf, HCI_AXIDMA_RWDATA_BURST_LEN);
As all other SoCs expect the current value, I've left that assignment
in the common function, and we update it in the gs101_ufs_post_link()
specific hook.
>
> >
> > To enable WLU transaction additionally we need to set Write Line
> > Unique enable [31], Write Line Unique Burst Length [30:27] and
> > AXIDMA_RWDATA_BURST_LEN[3:0].
> >
> > To support WLU transaction, both burth length fields need to be 0x3.
> >
>
> typo, s/burth/burst
Will fix.
Peter
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH v2 08/11] scsi: ufs: exynos: enable write line unique transactions on gs101
2024-10-30 11:32 ` Peter Griffin
@ 2024-10-30 12:36 ` Tudor Ambarus
0 siblings, 0 replies; 29+ messages in thread
From: Tudor Ambarus @ 2024-10-30 12:36 UTC (permalink / raw)
To: Peter Griffin
Cc: alim.akhtar, James.Bottomley, martin.petersen, avri.altman,
bvanassche, krzk, andre.draszik, kernel-team, willmcvicker,
linux-scsi, devicetree, linux-arm-kernel, linux-samsung-soc,
linux-kernel, ebiggers
On 10/30/24 11:32 AM, Peter Griffin wrote:
>>> Previously just AXIDMA_RWDATA_BURST_LEN[3:0] field was set to 8.
>> where was this set?
> It is set to 0xf in exynos_ufs_post_link() function, see the following line
> hci_writel(ufs, 0xf, HCI_AXIDMA_RWDATA_BURST_LEN);
>
> As all other SoCs expect the current value, I've left that assignment
> in the common function, and we update it in the gs101_ufs_post_link()
> specific hook.
>
oh yes, as a driver quirk.
Reviewed-by: Tudor Ambarus <tudor.ambarus@linaro.org>
^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH v2 09/11] scsi: ufs: exynos: set ACG to be controlled by UFS_ACG_DISABLE
2024-10-25 13:14 [PATCH v2 00/11] UFS cleanups and enhancements to ufs-exynos for gs101 Peter Griffin
` (7 preceding siblings ...)
2024-10-25 13:14 ` [PATCH v2 08/11] scsi: ufs: exynos: enable write line unique transactions on gs101 Peter Griffin
@ 2024-10-25 13:14 ` Peter Griffin
2024-10-30 11:45 ` Tudor Ambarus
2024-10-25 13:14 ` [PATCH v2 10/11] scsi: ufs: exynos: fix hibern8 notify callbacks Peter Griffin
2024-10-25 13:14 ` [PATCH v2 11/11] scsi: ufs: exynos: gs101: enable clock gating with hibern8 Peter Griffin
10 siblings, 1 reply; 29+ messages in thread
From: Peter Griffin @ 2024-10-25 13:14 UTC (permalink / raw)
To: alim.akhtar, James.Bottomley, martin.petersen, avri.altman,
bvanassche, krzk
Cc: tudor.ambarus, andre.draszik, kernel-team, willmcvicker,
linux-scsi, devicetree, linux-arm-kernel, linux-samsung-soc,
linux-kernel, ebiggers, Peter Griffin
HCI_IOP_ACG_DISABLE is an undocumented register in the TRM but the
downstream driver sets this register so we follow suit here.
The register is already 0 presumed to be set by the bootloader as
the comment downstream implies the reset state is 1. So whilst this
is a nop currently, it should help with suspend/resume.
Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
---
drivers/ufs/host/ufs-exynos.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/ufs/host/ufs-exynos.c b/drivers/ufs/host/ufs-exynos.c
index b0cbb147c7a1..fa4e61f152c4 100644
--- a/drivers/ufs/host/ufs-exynos.c
+++ b/drivers/ufs/host/ufs-exynos.c
@@ -76,6 +76,10 @@
#define CLK_CTRL_EN_MASK (REFCLK_CTRL_EN |\
UNIPRO_PCLK_CTRL_EN |\
UNIPRO_MCLK_CTRL_EN)
+
+#define HCI_IOP_ACG_DISABLE 0x100
+#define HCI_IOP_ACG_DISABLE_EN BIT(0)
+
/* Device fatal error */
#define DFES_ERR_EN BIT(31)
#define DFES_DEF_L2_ERRS (UIC_DATA_LINK_LAYER_ERROR_RX_BUF_OF |\
@@ -220,10 +224,15 @@ static int exynos_ufs_shareability(struct exynos_ufs *ufs)
static int gs101_ufs_drv_init(struct device *dev, struct exynos_ufs *ufs)
{
struct ufs_hba *hba = ufs->hba;
+ u32 reg;
/* Enable WriteBooster */
hba->caps |= UFSHCD_CAP_WB_EN;
+ /* set ACG to be controlled by UFS_ACG_DISABLE */
+ reg = hci_readl(ufs, HCI_IOP_ACG_DISABLE);
+ hci_writel(ufs, reg & (~HCI_IOP_ACG_DISABLE_EN), HCI_IOP_ACG_DISABLE);
+
return exynos_ufs_shareability(ufs);
}
--
2.47.0.163.g1226f6d8fa-goog
^ permalink raw reply related [flat|nested] 29+ messages in thread
* Re: [PATCH v2 09/11] scsi: ufs: exynos: set ACG to be controlled by UFS_ACG_DISABLE
2024-10-25 13:14 ` [PATCH v2 09/11] scsi: ufs: exynos: set ACG to be controlled by UFS_ACG_DISABLE Peter Griffin
@ 2024-10-30 11:45 ` Tudor Ambarus
0 siblings, 0 replies; 29+ messages in thread
From: Tudor Ambarus @ 2024-10-30 11:45 UTC (permalink / raw)
To: Peter Griffin, alim.akhtar, James.Bottomley, martin.petersen,
avri.altman, bvanassche, krzk
Cc: andre.draszik, kernel-team, willmcvicker, linux-scsi, devicetree,
linux-arm-kernel, linux-samsung-soc, linux-kernel, ebiggers
On 10/25/24 2:14 PM, Peter Griffin wrote:
> HCI_IOP_ACG_DISABLE is an undocumented register in the TRM but the
> downstream driver sets this register so we follow suit here.
>
> The register is already 0 presumed to be set by the bootloader as
> the comment downstream implies the reset state is 1. So whilst this
> is a nop currently, it should help with suspend/resume.
It should help in case the bootloader changes I assume. I see
gs101_ufs_drv_init() gets called only at probe time, via
ufshcd_pltfrm_init().
>
> Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
Reviewed-by: Tudor Ambarus <tudor.ambarus@linaro.org>
> ---
> drivers/ufs/host/ufs-exynos.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/drivers/ufs/host/ufs-exynos.c b/drivers/ufs/host/ufs-exynos.c
> index b0cbb147c7a1..fa4e61f152c4 100644
> --- a/drivers/ufs/host/ufs-exynos.c
> +++ b/drivers/ufs/host/ufs-exynos.c
> @@ -76,6 +76,10 @@
> #define CLK_CTRL_EN_MASK (REFCLK_CTRL_EN |\
> UNIPRO_PCLK_CTRL_EN |\
> UNIPRO_MCLK_CTRL_EN)
> +
> +#define HCI_IOP_ACG_DISABLE 0x100
> +#define HCI_IOP_ACG_DISABLE_EN BIT(0)
> +
> /* Device fatal error */
> #define DFES_ERR_EN BIT(31)
> #define DFES_DEF_L2_ERRS (UIC_DATA_LINK_LAYER_ERROR_RX_BUF_OF |\
> @@ -220,10 +224,15 @@ static int exynos_ufs_shareability(struct exynos_ufs *ufs)
> static int gs101_ufs_drv_init(struct device *dev, struct exynos_ufs *ufs)
> {
> struct ufs_hba *hba = ufs->hba;
> + u32 reg;
>
> /* Enable WriteBooster */
> hba->caps |= UFSHCD_CAP_WB_EN;
>
> + /* set ACG to be controlled by UFS_ACG_DISABLE */
> + reg = hci_readl(ufs, HCI_IOP_ACG_DISABLE);
> + hci_writel(ufs, reg & (~HCI_IOP_ACG_DISABLE_EN), HCI_IOP_ACG_DISABLE);
> +
> return exynos_ufs_shareability(ufs);
> }
>
^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH v2 10/11] scsi: ufs: exynos: fix hibern8 notify callbacks
2024-10-25 13:14 [PATCH v2 00/11] UFS cleanups and enhancements to ufs-exynos for gs101 Peter Griffin
` (8 preceding siblings ...)
2024-10-25 13:14 ` [PATCH v2 09/11] scsi: ufs: exynos: set ACG to be controlled by UFS_ACG_DISABLE Peter Griffin
@ 2024-10-25 13:14 ` Peter Griffin
2024-10-30 12:00 ` Tudor Ambarus
2024-10-25 13:14 ` [PATCH v2 11/11] scsi: ufs: exynos: gs101: enable clock gating with hibern8 Peter Griffin
10 siblings, 1 reply; 29+ messages in thread
From: Peter Griffin @ 2024-10-25 13:14 UTC (permalink / raw)
To: alim.akhtar, James.Bottomley, martin.petersen, avri.altman,
bvanassche, krzk
Cc: tudor.ambarus, andre.draszik, kernel-team, willmcvicker,
linux-scsi, devicetree, linux-arm-kernel, linux-samsung-soc,
linux-kernel, ebiggers, Peter Griffin
v1 of the patch which introduced the ufshcd_vops_hibern8_notify() callback
used a bool instead of an enum. In v2 this was updated to an enum based on
the review feedback in [1].
ufs-exynos hibernate calls have always been broken upstream as it follows
the v1 bool implementation.
[1] https://patchwork.kernel.org/project/linux-scsi/patch/001f01d23994$719997c0$54ccc740$@samsung.com/
Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
---
---
drivers/ufs/host/ufs-exynos.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/ufs/host/ufs-exynos.c b/drivers/ufs/host/ufs-exynos.c
index fa4e61f152c4..3bbb71f7bae7 100644
--- a/drivers/ufs/host/ufs-exynos.c
+++ b/drivers/ufs/host/ufs-exynos.c
@@ -1529,12 +1529,12 @@ static void exynos_ufs_dev_hw_reset(struct ufs_hba *hba)
hci_writel(ufs, 1 << 0, HCI_GPIO_OUT);
}
-static void exynos_ufs_pre_hibern8(struct ufs_hba *hba, u8 enter)
+static void exynos_ufs_pre_hibern8(struct ufs_hba *hba, enum uic_cmd_dme cmd)
{
struct exynos_ufs *ufs = ufshcd_get_variant(hba);
struct exynos_ufs_uic_attr *attr = ufs->drv_data->uic_attr;
- if (!enter) {
+ if (cmd == UIC_CMD_DME_HIBER_EXIT) {
if (ufs->opts & EXYNOS_UFS_OPT_BROKEN_AUTO_CLK_CTRL)
exynos_ufs_disable_auto_ctrl_hcc(ufs);
exynos_ufs_ungate_clks(ufs);
@@ -1562,11 +1562,11 @@ static void exynos_ufs_pre_hibern8(struct ufs_hba *hba, u8 enter)
}
}
-static void exynos_ufs_post_hibern8(struct ufs_hba *hba, u8 enter)
+static void exynos_ufs_post_hibern8(struct ufs_hba *hba, enum uic_cmd_dme cmd)
{
struct exynos_ufs *ufs = ufshcd_get_variant(hba);
- if (!enter) {
+ if (cmd == UIC_CMD_DME_HIBER_EXIT) {
u32 cur_mode = 0;
u32 pwrmode;
@@ -1585,7 +1585,7 @@ static void exynos_ufs_post_hibern8(struct ufs_hba *hba, u8 enter)
if (!(ufs->opts & EXYNOS_UFS_OPT_SKIP_CONNECTION_ESTAB))
exynos_ufs_establish_connt(ufs);
- } else {
+ } else if (cmd == UIC_CMD_DME_HIBER_ENTER) {
ufs->entry_hibern8_t = ktime_get();
exynos_ufs_gate_clks(ufs);
if (ufs->opts & EXYNOS_UFS_OPT_BROKEN_AUTO_CLK_CTRL)
@@ -1672,15 +1672,15 @@ static int exynos_ufs_pwr_change_notify(struct ufs_hba *hba,
}
static void exynos_ufs_hibern8_notify(struct ufs_hba *hba,
- enum uic_cmd_dme enter,
+ enum uic_cmd_dme cmd,
enum ufs_notify_change_status notify)
{
switch ((u8)notify) {
case PRE_CHANGE:
- exynos_ufs_pre_hibern8(hba, enter);
+ exynos_ufs_pre_hibern8(hba, cmd);
break;
case POST_CHANGE:
- exynos_ufs_post_hibern8(hba, enter);
+ exynos_ufs_post_hibern8(hba, cmd);
break;
}
}
--
2.47.0.163.g1226f6d8fa-goog
^ permalink raw reply related [flat|nested] 29+ messages in thread
* Re: [PATCH v2 10/11] scsi: ufs: exynos: fix hibern8 notify callbacks
2024-10-25 13:14 ` [PATCH v2 10/11] scsi: ufs: exynos: fix hibern8 notify callbacks Peter Griffin
@ 2024-10-30 12:00 ` Tudor Ambarus
2024-10-31 12:35 ` Peter Griffin
0 siblings, 1 reply; 29+ messages in thread
From: Tudor Ambarus @ 2024-10-30 12:00 UTC (permalink / raw)
To: Peter Griffin, alim.akhtar, James.Bottomley, martin.petersen,
avri.altman, bvanassche, krzk
Cc: andre.draszik, kernel-team, willmcvicker, linux-scsi, devicetree,
linux-arm-kernel, linux-samsung-soc, linux-kernel, ebiggers
On 10/25/24 2:14 PM, Peter Griffin wrote:
> v1 of the patch which introduced the ufshcd_vops_hibern8_notify() callback
> used a bool instead of an enum. In v2 this was updated to an enum based on
> the review feedback in [1].
>
> ufs-exynos hibernate calls have always been broken upstream as it follows
> the v1 bool implementation.
>
> [1] https://patchwork.kernel.org/project/linux-scsi/patch/001f01d23994$719997c0$54ccc740$@samsung.com/
you can use the Link tag, Link: blabla [1]
A Fixes tag and maybe Cc to stable? Or maybe you chose to not backport
it intentionally, in which case you have to add:
Cc: <stable+noautosel@kernel.org> # reason goes here, and must be present
In order to avoid scripts queuing your patch. It contains "fix" in the
subject, there's a high probability to be queued to stable.
With these addressed:
Reviewed-by: Tudor Ambarus <tudor.ambarus@linaro.org>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH v2 10/11] scsi: ufs: exynos: fix hibern8 notify callbacks
2024-10-30 12:00 ` Tudor Ambarus
@ 2024-10-31 12:35 ` Peter Griffin
0 siblings, 0 replies; 29+ messages in thread
From: Peter Griffin @ 2024-10-31 12:35 UTC (permalink / raw)
To: Tudor Ambarus
Cc: alim.akhtar, James.Bottomley, martin.petersen, avri.altman,
bvanassche, krzk, andre.draszik, kernel-team, willmcvicker,
linux-scsi, devicetree, linux-arm-kernel, linux-samsung-soc,
linux-kernel, ebiggers
Hi Tudor,
On Wed, 30 Oct 2024 at 12:00, Tudor Ambarus <tudor.ambarus@linaro.org> wrote:
>
>
>
> On 10/25/24 2:14 PM, Peter Griffin wrote:
> > v1 of the patch which introduced the ufshcd_vops_hibern8_notify() callback
> > used a bool instead of an enum. In v2 this was updated to an enum based on
> > the review feedback in [1].
> >
> > ufs-exynos hibernate calls have always been broken upstream as it follows
> > the v1 bool implementation.
> >
> > [1] https://patchwork.kernel.org/project/linux-scsi/patch/001f01d23994$719997c0$54ccc740$@samsung.com/
>
> you can use the Link tag, Link: blabla [1]
Will fix in v3
>
> A Fixes tag and maybe Cc to stable? Or maybe you chose to not backport
> it intentionally, in which case you have to add:
> Cc: <stable+noautosel@kernel.org> # reason goes here, and must be present
I'll add a cc stable tag, as there is no reason not to backport this fix.
>
> In order to avoid scripts queuing your patch. It contains "fix" in the
> subject, there's a high probability to be queued to stable.
>
> With these addressed:
> Reviewed-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Thanks for the reviews!
Peter.
^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH v2 11/11] scsi: ufs: exynos: gs101: enable clock gating with hibern8
2024-10-25 13:14 [PATCH v2 00/11] UFS cleanups and enhancements to ufs-exynos for gs101 Peter Griffin
` (9 preceding siblings ...)
2024-10-25 13:14 ` [PATCH v2 10/11] scsi: ufs: exynos: fix hibern8 notify callbacks Peter Griffin
@ 2024-10-25 13:14 ` Peter Griffin
2024-10-30 12:25 ` Tudor Ambarus
10 siblings, 1 reply; 29+ messages in thread
From: Peter Griffin @ 2024-10-25 13:14 UTC (permalink / raw)
To: alim.akhtar, James.Bottomley, martin.petersen, avri.altman,
bvanassche, krzk
Cc: tudor.ambarus, andre.draszik, kernel-team, willmcvicker,
linux-scsi, devicetree, linux-arm-kernel, linux-samsung-soc,
linux-kernel, ebiggers, Peter Griffin
Enable clock gating and hibern8 capabilities for gs101. This
leads to a significantly cooler phone when running the upstream
kernel.
The exynos_ufs_post_hibern8() hook is also updated to remove the
UIC_CMD_DME_HIBER_EXIT code path as this causes a hang on gs101.
The code path is removed rather than re-factored as no other SoC
in ufs-exynos driver sets UFSHCD_CAP_HIBERN8_WITH_CLK_GATING
capability. Additionally until the previous commit the hibern8
callbacks were broken anyway as they expected a bool.
Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
---
drivers/ufs/host/ufs-exynos.c | 24 ++++--------------------
1 file changed, 4 insertions(+), 20 deletions(-)
diff --git a/drivers/ufs/host/ufs-exynos.c b/drivers/ufs/host/ufs-exynos.c
index 3bbb71f7bae7..7c8195f27bb6 100644
--- a/drivers/ufs/host/ufs-exynos.c
+++ b/drivers/ufs/host/ufs-exynos.c
@@ -229,6 +229,9 @@ static int gs101_ufs_drv_init(struct device *dev, struct exynos_ufs *ufs)
/* Enable WriteBooster */
hba->caps |= UFSHCD_CAP_WB_EN;
+ /* Enable clock gating and hibern8 */
+ hba->caps |= UFSHCD_CAP_CLK_GATING | UFSHCD_CAP_HIBERN8_WITH_CLK_GATING;
+
/* set ACG to be controlled by UFS_ACG_DISABLE */
reg = hci_readl(ufs, HCI_IOP_ACG_DISABLE);
hci_writel(ufs, reg & (~HCI_IOP_ACG_DISABLE_EN), HCI_IOP_ACG_DISABLE);
@@ -1566,26 +1569,7 @@ static void exynos_ufs_post_hibern8(struct ufs_hba *hba, enum uic_cmd_dme cmd)
{
struct exynos_ufs *ufs = ufshcd_get_variant(hba);
- if (cmd == UIC_CMD_DME_HIBER_EXIT) {
- u32 cur_mode = 0;
- u32 pwrmode;
-
- if (ufshcd_is_hs_mode(&ufs->dev_req_params))
- pwrmode = FAST_MODE;
- else
- pwrmode = SLOW_MODE;
-
- ufshcd_dme_get(hba, UIC_ARG_MIB(PA_PWRMODE), &cur_mode);
- if (cur_mode != (pwrmode << 4 | pwrmode)) {
- dev_warn(hba->dev, "%s: power mode change\n", __func__);
- hba->pwr_info.pwr_rx = (cur_mode >> 4) & 0xf;
- hba->pwr_info.pwr_tx = cur_mode & 0xf;
- ufshcd_config_pwr_mode(hba, &hba->max_pwr_info.info);
- }
-
- if (!(ufs->opts & EXYNOS_UFS_OPT_SKIP_CONNECTION_ESTAB))
- exynos_ufs_establish_connt(ufs);
- } else if (cmd == UIC_CMD_DME_HIBER_ENTER) {
+ if (cmd == UIC_CMD_DME_HIBER_ENTER) {
ufs->entry_hibern8_t = ktime_get();
exynos_ufs_gate_clks(ufs);
if (ufs->opts & EXYNOS_UFS_OPT_BROKEN_AUTO_CLK_CTRL)
--
2.47.0.163.g1226f6d8fa-goog
^ permalink raw reply related [flat|nested] 29+ messages in thread
* Re: [PATCH v2 11/11] scsi: ufs: exynos: gs101: enable clock gating with hibern8
2024-10-25 13:14 ` [PATCH v2 11/11] scsi: ufs: exynos: gs101: enable clock gating with hibern8 Peter Griffin
@ 2024-10-30 12:25 ` Tudor Ambarus
0 siblings, 0 replies; 29+ messages in thread
From: Tudor Ambarus @ 2024-10-30 12:25 UTC (permalink / raw)
To: Peter Griffin, alim.akhtar, James.Bottomley, martin.petersen,
avri.altman, bvanassche, krzk
Cc: andre.draszik, kernel-team, willmcvicker, linux-scsi, devicetree,
linux-arm-kernel, linux-samsung-soc, linux-kernel, ebiggers
On 10/25/24 2:14 PM, Peter Griffin wrote:
> Enable clock gating and hibern8 capabilities for gs101. This
> leads to a significantly cooler phone when running the upstream
> kernel.
>
> The exynos_ufs_post_hibern8() hook is also updated to remove the
> UIC_CMD_DME_HIBER_EXIT code path as this causes a hang on gs101.
>
> The code path is removed rather than re-factored as no other SoC
> in ufs-exynos driver sets UFSHCD_CAP_HIBERN8_WITH_CLK_GATING
> capability. Additionally until the previous commit the hibern8
> callbacks were broken anyway as they expected a bool.
I think too it's fine to remove uneeded code as it was broken anyway.
>
> Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
> ---
> drivers/ufs/host/ufs-exynos.c | 24 ++++--------------------
> 1 file changed, 4 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/ufs/host/ufs-exynos.c b/drivers/ufs/host/ufs-exynos.c
> index 3bbb71f7bae7..7c8195f27bb6 100644
> --- a/drivers/ufs/host/ufs-exynos.c
> +++ b/drivers/ufs/host/ufs-exynos.c
cut
> @@ -1566,26 +1569,7 @@ static void exynos_ufs_post_hibern8(struct ufs_hba *hba, enum uic_cmd_dme cmd)
> {
cut
> + if (cmd == UIC_CMD_DME_HIBER_ENTER) {
I verified that the order of operations at hibern8_enter/exit() is sane:
Reviewed-by: Tudor Ambarus <tudor.ambarus@linaro.org>
---
hibern8_notify() gets called in ufshcd_uic_hibern8_enter/exit()
exynos_ufs_post_hibern8 disables the clocks for:
ufshcd_vops_hibern8_notify(hba, UIC_CMD_DME_HIBER_ENTER, POST_CHANGE)
exynos_ufs_pre_hibern8() enables the clocks for:
ufshcd_vops_hibern8_notify(hba, UIC_CMD_DME_HIBER_EXIT, PRE_CHANGE);
^ permalink raw reply [flat|nested] 29+ messages in thread