Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 96a7141

Browse files
Mani-Sadhasivammartinkpetersen
authored andcommitted
scsi: ufs: core: Add support for reinitializing the UFS device
Some platforms like Qcom, requires the UFS device to be reinitialized after switching to maximum gear speed. So add support for that in UFS core by introducing a new quirk (UFSHCD_CAP_REINIT_AFTER_MAX_GEAR_SWITCH) and doing the reinitialization, if the quirk is enabled by the controller driver. Suggested-by: Can Guo <[email protected]> Tested-by: Andrew Halaney <[email protected]> # Qdrive3/sa8540p-ride Signed-off-by: Manivannan Sadhasivam <[email protected]> Reviewed-by: Bart Van Assche <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent c2c38c5 commit 96a7141

File tree

2 files changed

+53
-16
lines changed

2 files changed

+53
-16
lines changed

drivers/ufs/core/ufshcd.c

Lines changed: 47 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8231,27 +8231,18 @@ static int ufshcd_add_lus(struct ufs_hba *hba)
82318231
return ret;
82328232
}
82338233

8234-
/**
8235-
* ufshcd_probe_hba - probe hba to detect device and initialize it
8236-
* @hba: per-adapter instance
8237-
* @init_dev_params: whether or not to call ufshcd_device_params_init().
8238-
*
8239-
* Execute link-startup and verify device initialization
8240-
*/
8241-
static int ufshcd_probe_hba(struct ufs_hba *hba, bool init_dev_params)
8234+
static int ufshcd_device_init(struct ufs_hba *hba, bool init_dev_params)
82428235
{
82438236
int ret;
8244-
unsigned long flags;
8245-
ktime_t start = ktime_get();
82468237

82478238
hba->ufshcd_state = UFSHCD_STATE_RESET;
82488239

82498240
ret = ufshcd_link_startup(hba);
82508241
if (ret)
8251-
goto out;
8242+
return ret;
82528243

82538244
if (hba->quirks & UFSHCD_QUIRK_SKIP_PH_CONFIGURATION)
8254-
goto out;
8245+
return ret;
82558246

82568247
/* Debug counters initialization */
82578248
ufshcd_clear_dbg_ufs_stats(hba);
@@ -8262,12 +8253,12 @@ static int ufshcd_probe_hba(struct ufs_hba *hba, bool init_dev_params)
82628253
/* Verify device initialization by sending NOP OUT UPIU */
82638254
ret = ufshcd_verify_dev_init(hba);
82648255
if (ret)
8265-
goto out;
8256+
return ret;
82668257

82678258
/* Initiate UFS initialization, and waiting until completion */
82688259
ret = ufshcd_complete_dev_init(hba);
82698260
if (ret)
8270-
goto out;
8261+
return ret;
82718262

82728263
/*
82738264
* Initialize UFS device parameters used by driver, these
@@ -8276,7 +8267,7 @@ static int ufshcd_probe_hba(struct ufs_hba *hba, bool init_dev_params)
82768267
if (init_dev_params) {
82778268
ret = ufshcd_device_params_init(hba);
82788269
if (ret)
8279-
goto out;
8270+
return ret;
82808271
}
82818272

82828273
ufshcd_tune_unipro_params(hba);
@@ -8297,11 +8288,51 @@ static int ufshcd_probe_hba(struct ufs_hba *hba, bool init_dev_params)
82978288
if (ret) {
82988289
dev_err(hba->dev, "%s: Failed setting power mode, err = %d\n",
82998290
__func__, ret);
8291+
return ret;
8292+
}
8293+
}
8294+
8295+
return 0;
8296+
}
8297+
8298+
/**
8299+
* ufshcd_probe_hba - probe hba to detect device and initialize it
8300+
* @hba: per-adapter instance
8301+
* @init_dev_params: whether or not to call ufshcd_device_params_init().
8302+
*
8303+
* Execute link-startup and verify device initialization
8304+
*/
8305+
static int ufshcd_probe_hba(struct ufs_hba *hba, bool init_dev_params)
8306+
{
8307+
ktime_t start = ktime_get();
8308+
unsigned long flags;
8309+
int ret;
8310+
8311+
ret = ufshcd_device_init(hba, init_dev_params);
8312+
if (ret)
8313+
goto out;
8314+
8315+
if (hba->quirks & UFSHCD_QUIRK_REINIT_AFTER_MAX_GEAR_SWITCH) {
8316+
/* Reset the device and controller before doing reinit */
8317+
ufshcd_device_reset(hba);
8318+
ufshcd_hba_stop(hba);
8319+
ufshcd_vops_reinit_notify(hba);
8320+
ret = ufshcd_hba_enable(hba);
8321+
if (ret) {
8322+
dev_err(hba->dev, "Host controller enable failed\n");
8323+
ufshcd_print_evt_hist(hba);
8324+
ufshcd_print_host_state(hba);
83008325
goto out;
83018326
}
8302-
ufshcd_print_pwr_info(hba);
8327+
8328+
/* Reinit the device */
8329+
ret = ufshcd_device_init(hba, init_dev_params);
8330+
if (ret)
8331+
goto out;
83038332
}
83048333

8334+
ufshcd_print_pwr_info(hba);
8335+
83058336
/*
83068337
* bActiveICCLevel is volatile for UFS device (as per latest v2.1 spec)
83078338
* and for removable UFS card as well, hence always set the parameter.

include/ufs/ufshcd.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,12 @@ enum ufshcd_quirks {
596596
* auto-hibernate capability but it's FASTAUTO only.
597597
*/
598598
UFSHCD_QUIRK_HIBERN_FASTAUTO = 1 << 18,
599+
600+
/*
601+
* This quirk needs to be enabled if the host controller needs
602+
* to reinit the device after switching to maximum gear.
603+
*/
604+
UFSHCD_QUIRK_REINIT_AFTER_MAX_GEAR_SWITCH = 1 << 19,
599605
};
600606

601607
enum ufshcd_caps {

0 commit comments

Comments
 (0)