[v1] scsi: ufs: Disable local LCC in .link_startup_notify() in Cadence UFS
diff mbox series

Message ID 20190813074250.28177-1-aniljoy@cadence.com
State Accepted
Headers show
Series
  • [v1] scsi: ufs: Disable local LCC in .link_startup_notify() in Cadence UFS
Related show

Commit Message

Anil Varughese Aug. 13, 2019, 7:42 a.m. UTC
Some UFS devices have issues if LCC is enabled. So we
are setting PA_LOCAL_TX_LCC_Enable to 0 before link
startup which will make sure that both host and device
TX LCC are disabled once link startup is completed.

Signed-off-by: Anil Varughese <aniljoy@cadence.com>
---
 drivers/scsi/ufs/cdns-pltfrm.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

Comments

Vignesh Raghavendra Aug. 26, 2019, 12:07 p.m. UTC | #1
Hi,

On 13/08/19 1:12 PM, Anil Varughese wrote:
> Some UFS devices have issues if LCC is enabled. So we
> are setting PA_LOCAL_TX_LCC_Enable to 0 before link
> startup which will make sure that both host and device
> TX LCC are disabled once link startup is completed.
> 
> Signed-off-by: Anil Varughese <aniljoy@cadence.com>> ---

Reviewed-by: Vignesh Raghavendra <vigneshr@ti.com>

Regards
Vignesh

>  drivers/scsi/ufs/cdns-pltfrm.c | 27 +++++++++++++++++++++++++++
>  1 file changed, 27 insertions(+)
> 
> diff --git a/drivers/scsi/ufs/cdns-pltfrm.c b/drivers/scsi/ufs/cdns-pltfrm.c
> index 993519080..b2af04c57 100644
> --- a/drivers/scsi/ufs/cdns-pltfrm.c
> +++ b/drivers/scsi/ufs/cdns-pltfrm.c
> @@ -77,6 +77,31 @@ static int cdns_ufs_hce_enable_notify(struct ufs_hba *hba,
>  	return cdns_ufs_set_hclkdiv(hba);
>  }
>  
> +/**
> + * Called before and after Link startup is carried out.
> + * @hba: host controller instance
> + * @status: notify stage (pre, post change)
> + *
> + * Return zero for success and non-zero for failure
> + */
> +static int cdns_ufs_link_startup_notify(struct ufs_hba *hba,
> +					enum ufs_notify_change_status status)
> +{
> +	if (status != PRE_CHANGE)
> +		return 0;
> +
> +	/*
> +	 * Some UFS devices have issues if LCC is enabled.
> +	 * So we are setting PA_Local_TX_LCC_Enable to 0
> +	 * before link startup which will make sure that both host
> +	 * and device TX LCC are disabled once link startup is
> +	 * completed.
> +	 */
> +	ufshcd_dme_set(hba, UIC_ARG_MIB(PA_LOCAL_TX_LCC_ENABLE), 0);
> +
> +	return 0;
> +}
> +
>  /**
>   * cdns_ufs_init - performs additional ufs initialization
>   * @hba: host controller instance
> @@ -114,12 +139,14 @@ static int cdns_ufs_m31_16nm_phy_initialization(struct ufs_hba *hba)
>  static const struct ufs_hba_variant_ops cdns_ufs_pltfm_hba_vops = {
>  	.name = "cdns-ufs-pltfm",
>  	.hce_enable_notify = cdns_ufs_hce_enable_notify,
> +	.link_startup_notify = cdns_ufs_link_startup_notify,
>  };
>  
>  static const struct ufs_hba_variant_ops cdns_ufs_m31_16nm_pltfm_hba_vops = {
>  	.name = "cdns-ufs-pltfm",
>  	.init = cdns_ufs_init,
>  	.hce_enable_notify = cdns_ufs_hce_enable_notify,
> +	.link_startup_notify = cdns_ufs_link_startup_notify,
>  	.phy_initialization = cdns_ufs_m31_16nm_phy_initialization,
>  };
>  
>
Martin K. Petersen Aug. 29, 2019, 9:43 p.m. UTC | #2
Anil,

> Some UFS devices have issues if LCC is enabled. So we are setting
> PA_LOCAL_TX_LCC_Enable to 0 before link startup which will make sure
> that both host and device TX LCC are disabled once link startup is
> completed.

Applied to 5.4/scsi-queue. Thanks!

Patch
diff mbox series

diff --git a/drivers/scsi/ufs/cdns-pltfrm.c b/drivers/scsi/ufs/cdns-pltfrm.c
index 993519080..b2af04c57 100644
--- a/drivers/scsi/ufs/cdns-pltfrm.c
+++ b/drivers/scsi/ufs/cdns-pltfrm.c
@@ -77,6 +77,31 @@  static int cdns_ufs_hce_enable_notify(struct ufs_hba *hba,
 	return cdns_ufs_set_hclkdiv(hba);
 }
 
+/**
+ * Called before and after Link startup is carried out.
+ * @hba: host controller instance
+ * @status: notify stage (pre, post change)
+ *
+ * Return zero for success and non-zero for failure
+ */
+static int cdns_ufs_link_startup_notify(struct ufs_hba *hba,
+					enum ufs_notify_change_status status)
+{
+	if (status != PRE_CHANGE)
+		return 0;
+
+	/*
+	 * Some UFS devices have issues if LCC is enabled.
+	 * So we are setting PA_Local_TX_LCC_Enable to 0
+	 * before link startup which will make sure that both host
+	 * and device TX LCC are disabled once link startup is
+	 * completed.
+	 */
+	ufshcd_dme_set(hba, UIC_ARG_MIB(PA_LOCAL_TX_LCC_ENABLE), 0);
+
+	return 0;
+}
+
 /**
  * cdns_ufs_init - performs additional ufs initialization
  * @hba: host controller instance
@@ -114,12 +139,14 @@  static int cdns_ufs_m31_16nm_phy_initialization(struct ufs_hba *hba)
 static const struct ufs_hba_variant_ops cdns_ufs_pltfm_hba_vops = {
 	.name = "cdns-ufs-pltfm",
 	.hce_enable_notify = cdns_ufs_hce_enable_notify,
+	.link_startup_notify = cdns_ufs_link_startup_notify,
 };
 
 static const struct ufs_hba_variant_ops cdns_ufs_m31_16nm_pltfm_hba_vops = {
 	.name = "cdns-ufs-pltfm",
 	.init = cdns_ufs_init,
 	.hce_enable_notify = cdns_ufs_hce_enable_notify,
+	.link_startup_notify = cdns_ufs_link_startup_notify,
 	.phy_initialization = cdns_ufs_m31_16nm_phy_initialization,
 };