mbox series

[v1,0/3] ufs: host: mediatek: Provide fixes in MediaTek platforms

Message ID 20231221110416.16176-1-peter.wang@mediatek.com
Headers show
Series ufs: host: mediatek: Provide fixes in MediaTek platforms | expand

Message

Peter Wang (王信友) Dec. 21, 2023, 11:04 a.m. UTC
From: Peter Wang <peter.wang@mediatek.com>

This patch fix MediaTek platform exit hibern8 and mcq related error.

Peter Wang (3):
  ufs: host: mediatek: check link status after exit hibern8
  ufs: host: mediatek: fix mcq mode tm cmd timeout
  ufs: host: mediatek: disable mcq irq when clock off

 drivers/ufs/host/ufs-mediatek.c | 65 ++++++++++++++++++++++++++++-----
 drivers/ufs/host/ufs-mediatek.h |  1 +
 2 files changed, 57 insertions(+), 9 deletions(-)

Comments

Chun-Hung Wu (巫駿宏) Dec. 25, 2023, 7:20 a.m. UTC | #1
On Thu, 2023-12-21 at 19:04 +0800, peter.wang@mediatek.com wrote:
> From: Peter Wang <peter.wang@mediatek.com>
> 
> To prevent SSU(Active) error, check link status after exit hibern8.
> If link is not VS_LINK_UP, return error and do ufshcd_link_recovery.
> 
> Signed-off-by: Peter Wang <peter.wang@mediatek.com>
> ---
>  drivers/ufs/host/ufs-mediatek.c | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-
> mediatek.c
> index fc61790d289b..104354a4d899 100644
> --- a/drivers/ufs/host/ufs-mediatek.c
> +++ b/drivers/ufs/host/ufs-mediatek.c
> @@ -1208,11 +1208,18 @@ static int ufs_mtk_link_set_hpm(struct
> ufs_hba *hba)
>  		return err;
>  
>  	err = ufshcd_uic_hibern8_exit(hba);
> -	if (!err)
> -		ufshcd_set_link_active(hba);
> -	else
> +	if (err)
>  		return err;
>  
> +	/* Check link state to make sure exit h8 success */
> +	ufs_mtk_wait_idle_state(hba, 5);
> +	err = ufs_mtk_wait_link_state(hba, VS_LINK_UP, 100);
> +	if (err) {
> +		dev_warn(hba->dev, "exit h8 state fail, err=%d\n",
> err);
> +		return err;
> +	}
> +	ufshcd_set_link_active(hba);
> +
>  	if (!hba->mcq_enabled) {
>  		err = ufshcd_make_hba_operational(hba);
>  	} else {

Reviewed-by: Chun-Hung Wu <chun-hung.wu@mediatek.com>

Chun-Hung
Chun-Hung Wu (巫駿宏) Dec. 25, 2023, 7:22 a.m. UTC | #2
On Thu, 2023-12-21 at 19:04 +0800, peter.wang@mediatek.com wrote:
> From: Peter Wang <peter.wang@mediatek.com>
> 
> Disable mcq irq when clock off, this is same as legacy mode.
> 
> Signed-off-by: Peter Wang <peter.wang@mediatek.com>
> ---
>  drivers/ufs/host/ufs-mediatek.c | 41
> +++++++++++++++++++++++++++++++++
>  drivers/ufs/host/ufs-mediatek.h |  1 +
>  2 files changed, 42 insertions(+)
> 
> diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-
> mediatek.c
> index eb1934126c87..51f05038408a 100644
> --- a/drivers/ufs/host/ufs-mediatek.c
> +++ b/drivers/ufs/host/ufs-mediatek.c
> @@ -660,6 +660,45 @@ static void ufs_mtk_pwr_ctrl(struct ufs_hba
> *hba, bool on)
>  	}
>  }
>  
> +static void ufs_mtk_mcq_disable_irq(struct ufs_hba *hba)
> +{
> +	struct ufs_mtk_host *host = ufshcd_get_variant(hba);
> +	u32 irq, i;
> +
> +	if (!is_mcq_enabled(hba))
> +		return;
> +
> +	if (host->mcq_nr_intr == 0)
> +		return;
> +
> +	for (i = 0; i < host->mcq_nr_intr; i++) {
> +		irq = host->mcq_intr_info[i].irq;
> +		disable_irq(irq);
> +	}
> +	host->is_mcq_intr_enabled = false;
> +}
> +
> +static void ufs_mtk_mcq_enable_irq(struct ufs_hba *hba)
> +{
> +	struct ufs_mtk_host *host = ufshcd_get_variant(hba);
> +	u32 irq, i;
> +
> +	if (!is_mcq_enabled(hba))
> +		return;
> +
> +	if (host->mcq_nr_intr == 0)
> +		return;
> +
> +	if (host->is_mcq_intr_enabled == true)
> +		return;
> +
> +	for (i = 0; i < host->mcq_nr_intr; i++) {
> +		irq = host->mcq_intr_info[i].irq;
> +		enable_irq(irq);
> +	}
> +	host->is_mcq_intr_enabled = true;
> +}
> +
>  /**
>   * ufs_mtk_setup_clocks - enables/disable clocks
>   * @hba: host controller instance
> @@ -703,8 +742,10 @@ static int ufs_mtk_setup_clocks(struct ufs_hba
> *hba, bool on,
>  
>  		if (clk_pwr_off)
>  			ufs_mtk_pwr_ctrl(hba, false);
> +		ufs_mtk_mcq_disable_irq(hba);
>  	} else if (on && status == POST_CHANGE) {
>  		ufs_mtk_pwr_ctrl(hba, true);
> +		ufs_mtk_mcq_enable_irq(hba);
>  	}
>  
>  	return ret;
> diff --git a/drivers/ufs/host/ufs-mediatek.h b/drivers/ufs/host/ufs-
> mediatek.h
> index f76e80d91729..922f1e51a60c 100644
> --- a/drivers/ufs/host/ufs-mediatek.h
> +++ b/drivers/ufs/host/ufs-mediatek.h
> @@ -186,6 +186,7 @@ struct ufs_mtk_host {
>  	u32 ip_ver;
>  
>  	bool mcq_set_intr;
> +	bool is_mcq_intr_enabled;
>  	int mcq_nr_intr;
>  	struct ufs_mtk_mcq_intr_info mcq_intr_info[UFSHCD_MAX_Q_NR];
>  };

Reviewed-by: Chun-Hung Wu <chun-hung.wu@mediatek.com>

Chun-Hung
Martin K. Petersen Jan. 24, 2024, 2:06 a.m. UTC | #3
> This patch fix MediaTek platform exit hibern8 and mcq related error.

Applied to 6.9/scsi-staging, thanks!
Martin K. Petersen Jan. 30, 2024, 2:27 a.m. UTC | #4
On Thu, 21 Dec 2023 19:04:13 +0800, peter.wang@mediatek.com wrote:

> This patch fix MediaTek platform exit hibern8 and mcq related error.
> 
> Peter Wang (3):
>   ufs: host: mediatek: check link status after exit hibern8
>   ufs: host: mediatek: fix mcq mode tm cmd timeout
>   ufs: host: mediatek: disable mcq irq when clock off
> 
> [...]

Applied to 6.9/scsi-queue, thanks!

[1/3] ufs: host: mediatek: check link status after exit hibern8
      https://git.kernel.org/mkp/scsi/c/29b3a373e2df
[2/3] ufs: host: mediatek: fix mcq mode tm cmd timeout
      https://git.kernel.org/mkp/scsi/c/468b3e0a3bca
[3/3] ufs: host: mediatek: disable mcq irq when clock off
      https://git.kernel.org/mkp/scsi/c/e0dc13e5a3cb