linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peter Wang <peter.wang@mediatek.com>
To: Bean Huo <huobean@gmail.com>, Po-Wen Kao <powen.kao@mediatek.com>,
	"Alim Akhtar" <alim.akhtar@samsung.com>,
	Avri Altman <avri.altman@wdc.com>,
	"James E.J. Bottomley" <jejb@linux.ibm.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	Matthias Brugger <matthias.bgg@gmail.com>
Cc: <wsd_upstream@mediatek.com>, <stanley.chu@mediatek.com>,
	<alice.chao@mediatek.com>, <chun-hung.wu@mediatek.com>,
	<cc.chou@mediatek.com>, <chaotian.jing@mediatek.com>,
	<jiajie.hao@mediatek.com>, <yohan.joung@sk.com>,
	<jason.li@sk.com>, <linux-scsi@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-mediatek@lists.infradead.org>
Subject: Re: [PATCH 1/1] scsi: ufs: remove redundant HPB unmap
Date: Wed, 13 Apr 2022 11:53:49 +0800	[thread overview]
Message-ID: <7e979863-21e5-ba63-862a-8ba6a63a8ae4@mediatek.com> (raw)
In-Reply-To: <7550da4043ae45ffd58399f1ee696238a5689f25.camel@gmail.com>

Hi Bean,

How about if reset flow not clear hpb mapping?

After device is reset by RST_N pin, if the hpb mapping table still exist?

BTW, Host seem not clear region mapping table in reset flow.

Thanks.


On 4/12/22 11:20 PM, Bean Huo wrote:
> Hi, Po-Wen,
> Previous email did not properly append the patch, this one is better
> for your review and test.
>
>
>
>
> From: Bean Huo <beanhuo@micron.com>
> Date: Tue, 12 Apr 2022 16:56:34 +0200
> Subject: [PATCH] scsi: ufshpb: UFSHPB cleanup
>
> Remove redundant ufshpb_reset*, and merge into a single helper
> ufshbp_state_toggle().
>
> Delete the redundant Inactivation code of all HPB Regions in the cold
> boot stage,
> and add inactivating all HPB Regions when the HPP status changes from
> HPB_RESET
> to HBP_PRESENT.
>
> Signed-off-by: Bean Huo <beanhuo@micron.com>
> ---
>   drivers/scsi/ufs/ufshcd.c |  4 ++--
>   drivers/scsi/ufs/ufshpb.c | 38 +++++++++++++-------------------------
>   drivers/scsi/ufs/ufshpb.h |  6 ++----
>   3 files changed, 17 insertions(+), 31 deletions(-)
>
> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
> index 0899d5b8cdad..d8b59d017ce4 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -7223,7 +7223,7 @@ static int ufshcd_host_reset_and_restore(struct
> ufs_hba *hba)
>   	 * Stop the host controller and complete the requests
>   	 * cleared by h/w
>   	 */
> -	ufshpb_reset_host(hba);
> +	ufshpb_state_toggle(hba, HPB_RESET);
>   	ufshcd_hba_stop(hba);
>   	hba->silence_err_logs = true;
>   	ufshcd_complete_requests(hba);
> @@ -8184,7 +8184,7 @@ static int ufshcd_probe_hba(struct ufs_hba *hba,
> bool init_dev_params)
>   	/* Enable Auto-Hibernate if configured */
>   	ufshcd_auto_hibern8_enable(hba);
>   
> -	ufshpb_reset(hba);
> +	ufshpb_state_toggle(hba, HPB_PRESENT);
>   out:
>   	spin_lock_irqsave(hba->host->host_lock, flags);
>   	if (ret)
> diff --git a/drivers/scsi/ufs/ufshpb.c b/drivers/scsi/ufs/ufshpb.c
> index 3ca745ad616c..4ed156031413 100644
> --- a/drivers/scsi/ufs/ufshpb.c
> +++ b/drivers/scsi/ufs/ufshpb.c
> @@ -2278,39 +2278,29 @@ static bool ufshpb_check_hpb_reset_query(struct
> ufs_hba *hba)
>   	return flag_res;
>   }
>   
> -void ufshpb_reset(struct ufs_hba *hba)
> +void ufshpb_state_toggle(struct ufs_hba *hba, enum UFSHPB_STATE state)
>   {
>   	struct ufshpb_lu *hpb;
>   	struct scsi_device *sdev;
>   
>   	shost_for_each_device(sdev, hba->host) {
>   		hpb = ufshpb_get_hpb_data(sdev);
> -		if (!hpb)
> -			continue;
>   
> -		if (ufshpb_get_state(hpb) != HPB_RESET)
> +		if (!hpb || ufshpb_get_state(hpb) != state)
>   			continue;
>   
> -		ufshpb_set_state(hpb, HPB_PRESENT);
> -	}
> -}
> -
> -void ufshpb_reset_host(struct ufs_hba *hba)
> -{
> -	struct ufshpb_lu *hpb;
> -	struct scsi_device *sdev;
> -
> -	shost_for_each_device(sdev, hba->host) {
> -		hpb = ufshpb_get_hpb_data(sdev);
> -		if (!hpb)
> -			continue;
> -
> -		if (ufshpb_get_state(hpb) != HPB_PRESENT)
> -			continue;
> -		ufshpb_set_state(hpb, HPB_RESET);
> -		ufshpb_cancel_jobs(hpb);
> -		ufshpb_discard_rsp_lists(hpb);
> +		ufshpb_set_state(hpb, state);
> +		if (state == HPB_RESET) {
> +			ufshpb_cancel_jobs(hpb);
> +			ufshpb_discard_rsp_lists(hpb);
> +		}
>   	}
> +	/*
> +	 * Inactivating all HPB Region in device side in case HPB
> state changed
> +	 * from HPB_RESET to HPB_PRESENT
> +	 */
> +	if (!hpb->is_hcm && state == HPB_PRESENT)

may need check hpb is not null?

> +		ufshpb_issue_umap_all_req(hpb);
>   }
>   
>   void ufshpb_suspend(struct ufs_hba *hba)
> @@ -2456,8 +2446,6 @@ static void ufshpb_hpb_lu_prepared(struct ufs_hba
> *hba)
>   			ufshpb_set_state(hpb, HPB_PRESENT);
>   			if ((hpb->lu_pinned_end - hpb-
>> lu_pinned_start) > 0)
>   				queue_work(ufshpb_wq, &hpb->map_work);
> -			if (!hpb->is_hcm)
> -				ufshpb_issue_umap_all_req(hpb);
>   		} else {
>   			dev_err(hba->dev, "destroy HPB lu %d\n", hpb-
>> lun);
>   			ufshpb_destroy_lu(hba, sdev);
> diff --git a/drivers/scsi/ufs/ufshpb.h b/drivers/scsi/ufs/ufshpb.h
> index b475dbd78988..a130f0b16c3e 100644
> --- a/drivers/scsi/ufs/ufshpb.h
> +++ b/drivers/scsi/ufs/ufshpb.h
> @@ -288,8 +288,7 @@ static int ufshpb_prep(struct ufs_hba *hba, struct
> ufshcd_lrb *lrbp) { return 0;
>   static void ufshpb_rsp_upiu(struct ufs_hba *hba, struct ufshcd_lrb
> *lrbp) {}
>   static void ufshpb_resume(struct ufs_hba *hba) {}
>   static void ufshpb_suspend(struct ufs_hba *hba) {}
> -static void ufshpb_reset(struct ufs_hba *hba) {}
> -static void ufshpb_reset_host(struct ufs_hba *hba) {}
> +static void ufshpb_state_toggle(struct ufs_hba *hba, enum UFSHPB_STATE
> state) {}
>   static void ufshpb_init(struct ufs_hba *hba) {}
>   static void ufshpb_init_hpb_lu(struct ufs_hba *hba, struct scsi_device
> *sdev) {}
>   static void ufshpb_destroy_lu(struct ufs_hba *hba, struct scsi_device
> *sdev) {}
> @@ -303,8 +302,7 @@ int ufshpb_prep(struct ufs_hba *hba, struct
> ufshcd_lrb *lrbp);
>   void ufshpb_rsp_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp);
>   void ufshpb_resume(struct ufs_hba *hba);
>   void ufshpb_suspend(struct ufs_hba *hba);
> -void ufshpb_reset(struct ufs_hba *hba);
> -void ufshpb_reset_host(struct ufs_hba *hba);
> +void ufshpb_state_toggle(struct ufs_hba *hba, enum UFSHPB_STATE
> state);
>   void ufshpb_init(struct ufs_hba *hba);
>   void ufshpb_init_hpb_lu(struct ufs_hba *hba, struct scsi_device
> *sdev);
>   void ufshpb_destroy_lu(struct ufs_hba *hba, struct scsi_device *sdev);

  reply	other threads:[~2022-04-13  3:54 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-12  7:31 [PATCH 1/1] scsi: ufs: remove redundant HPB unmap Po-Wen Kao
2022-04-12 15:06 ` Bean Huo
2022-04-12 15:20   ` Bean Huo
2022-04-13  3:53     ` Peter Wang [this message]
2022-04-13 12:43       ` Bean Huo
2022-04-14  4:49     ` Po-Wen Kao
2022-04-14 22:07       ` Bean Huo
2022-04-13 21:29 ` Bean Huo
2022-04-26  4:00 ` Martin K. Petersen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7e979863-21e5-ba63-862a-8ba6a63a8ae4@mediatek.com \
    --to=peter.wang@mediatek.com \
    --cc=alice.chao@mediatek.com \
    --cc=alim.akhtar@samsung.com \
    --cc=avri.altman@wdc.com \
    --cc=cc.chou@mediatek.com \
    --cc=chaotian.jing@mediatek.com \
    --cc=chun-hung.wu@mediatek.com \
    --cc=huobean@gmail.com \
    --cc=jason.li@sk.com \
    --cc=jejb@linux.ibm.com \
    --cc=jiajie.hao@mediatek.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=matthias.bgg@gmail.com \
    --cc=powen.kao@mediatek.com \
    --cc=stanley.chu@mediatek.com \
    --cc=wsd_upstream@mediatek.com \
    --cc=yohan.joung@sk.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).