From: Can Guo <cang@codeaurora.org>
To: Adrian Hunter <adrian.hunter@intel.com>
Cc: "Martin K . Petersen" <martin.petersen@oracle.com>,
"James E . J . Bottomley" <jejb@linux.ibm.com>,
linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
Alim Akhtar <alim.akhtar@samsung.com>,
Avri Altman <avri.altman@wdc.com>, Bean Huo <huobean@gmail.com>,
Stanley Chu <stanley.chu@mediatek.com>
Subject: Re: [PATCH V4 2/2] scsi: ufs: Allow an error return value from ->device_reset()
Date: Wed, 04 Nov 2020 16:05:21 +0800 [thread overview]
Message-ID: <fc28a4a01f1376f72df03f0ce4c254f4@codeaurora.org> (raw)
In-Reply-To: <20201103141403.2142-3-adrian.hunter@intel.com>
On 2020-11-03 22:14, Adrian Hunter wrote:
> It is simpler for drivers to provide a ->device_reset() callback
> irrespective of whether the GPIO, or firmware interface necessary to do
> the
> reset, is discovered during probe.
>
> Change ->device_reset() to return an error code. Drivers that provide
> the callback, but do not do the reset operation should return
> -EOPNOTSUPP.
>
> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Reviewed-by: Can Guo <cang@codeaurora.org>
> ---
> drivers/scsi/ufs/ufs-mediatek.c | 4 +++-
> drivers/scsi/ufs/ufs-qcom.c | 6 ++++--
> drivers/scsi/ufs/ufshcd.h | 11 +++++++----
> 3 files changed, 14 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/scsi/ufs/ufs-mediatek.c
> b/drivers/scsi/ufs/ufs-mediatek.c
> index 8df73bc2f8cb..914a827a93ee 100644
> --- a/drivers/scsi/ufs/ufs-mediatek.c
> +++ b/drivers/scsi/ufs/ufs-mediatek.c
> @@ -743,7 +743,7 @@ static int ufs_mtk_link_startup_notify(struct
> ufs_hba *hba,
> return ret;
> }
>
> -static void ufs_mtk_device_reset(struct ufs_hba *hba)
> +static int ufs_mtk_device_reset(struct ufs_hba *hba)
> {
> struct arm_smccc_res res;
>
> @@ -764,6 +764,8 @@ static void ufs_mtk_device_reset(struct ufs_hba
> *hba)
> usleep_range(10000, 15000);
>
> dev_info(hba->dev, "device reset done\n");
> +
> + return 0;
> }
>
> static int ufs_mtk_link_set_hpm(struct ufs_hba *hba)
> diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c
> index 9a19c6d15d3b..357c3b49321d 100644
> --- a/drivers/scsi/ufs/ufs-qcom.c
> +++ b/drivers/scsi/ufs/ufs-qcom.c
> @@ -1422,13 +1422,13 @@ static void ufs_qcom_dump_dbg_regs(struct
> ufs_hba *hba)
> *
> * Toggles the (optional) reset line to reset the attached device.
> */
> -static void ufs_qcom_device_reset(struct ufs_hba *hba)
> +static int ufs_qcom_device_reset(struct ufs_hba *hba)
> {
> struct ufs_qcom_host *host = ufshcd_get_variant(hba);
>
> /* reset gpio is optional */
> if (!host->device_reset)
> - return;
> + return -EOPNOTSUPP;
>
> /*
> * The UFS device shall detect reset pulses of 1us, sleep for 10us to
> @@ -1439,6 +1439,8 @@ static void ufs_qcom_device_reset(struct ufs_hba
> *hba)
>
> gpiod_set_value_cansleep(host->device_reset, 0);
> usleep_range(10, 15);
> +
> + return 0;
> }
>
> #if IS_ENABLED(CONFIG_DEVFREQ_GOV_SIMPLE_ONDEMAND)
> diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
> index 213be0667b59..5191d87f6263 100644
> --- a/drivers/scsi/ufs/ufshcd.h
> +++ b/drivers/scsi/ufs/ufshcd.h
> @@ -323,7 +323,7 @@ struct ufs_hba_variant_ops {
> int (*resume)(struct ufs_hba *, enum ufs_pm_op);
> void (*dbg_register_dump)(struct ufs_hba *hba);
> int (*phy_initialization)(struct ufs_hba *);
> - void (*device_reset)(struct ufs_hba *hba);
> + int (*device_reset)(struct ufs_hba *hba);
> void (*config_scaling_param)(struct ufs_hba *hba,
> struct devfreq_dev_profile *profile,
> void *data);
> @@ -1207,9 +1207,12 @@ static inline void
> ufshcd_vops_dbg_register_dump(struct ufs_hba *hba)
> static inline void ufshcd_vops_device_reset(struct ufs_hba *hba)
> {
> if (hba->vops && hba->vops->device_reset) {
> - hba->vops->device_reset(hba);
> - ufshcd_set_ufs_dev_active(hba);
> - ufshcd_update_reg_hist(&hba->ufs_stats.dev_reset, 0);
> + int err = hba->vops->device_reset(hba);
> +
> + if (!err)
> + ufshcd_set_ufs_dev_active(hba);
> + if (err != -EOPNOTSUPP)
> + ufshcd_update_reg_hist(&hba->ufs_stats.dev_reset, err);
> }
> }
next prev parent reply other threads:[~2020-11-04 8:05 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-03 14:14 [PATCH V4 0/2] scsi: ufs: Add DeepSleep feature Adrian Hunter
2020-11-03 14:14 ` [PATCH V4 1/2] " Adrian Hunter
2020-11-04 8:04 ` Can Guo
2020-11-04 8:29 ` Can Guo
2020-11-04 8:37 ` Adrian Hunter
2020-11-04 9:03 ` Can Guo
2020-11-04 10:57 ` Bean Huo
2020-11-04 11:55 ` Adrian Hunter
2020-11-04 13:19 ` Bean Huo
2020-11-04 16:35 ` Asutosh Das (asd)
2020-11-05 1:42 ` Stanley Chu
2020-11-03 14:14 ` [PATCH V4 2/2] scsi: ufs: Allow an error return value from ->device_reset() Adrian Hunter
2020-11-04 2:55 ` Stanley Chu
2020-11-04 8:05 ` Can Guo [this message]
2020-11-04 8:44 ` Bean Huo
2020-11-04 16:35 ` Asutosh Das (asd)
2020-11-05 4:06 ` [PATCH V4 0/2] scsi: ufs: Add DeepSleep feature Martin K. Petersen
2020-11-11 2:58 ` 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=fc28a4a01f1376f72df03f0ce4c254f4@codeaurora.org \
--to=cang@codeaurora.org \
--cc=adrian.hunter@intel.com \
--cc=alim.akhtar@samsung.com \
--cc=avri.altman@wdc.com \
--cc=huobean@gmail.com \
--cc=jejb@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=stanley.chu@mediatek.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