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

Commit eea6e4b

Browse files
committed
Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
Pull SCSI fixes from James Bottomley: "Four driver fixes in UFS, mostly to do with power management" * tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: scsi: ufs: qcom: Power down the controller/device during system suspend for SM8550/SM8650 SoCs scsi: ufs: qcom: Allow passing platform specific OF data scsi: ufs: core: Honor runtime/system PM levels if set by host controller drivers scsi: ufs: qcom: Power off the PHY if it was already powered on in ufs_qcom_power_up_sequence()
2 parents 0b7958f + 3b2f568 commit eea6e4b

File tree

5 files changed

+30
-24
lines changed

5 files changed

+30
-24
lines changed

drivers/ufs/core/ufshcd-priv.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -237,12 +237,6 @@ static inline void ufshcd_vops_config_scaling_param(struct ufs_hba *hba,
237237
hba->vops->config_scaling_param(hba, p, data);
238238
}
239239

240-
static inline void ufshcd_vops_reinit_notify(struct ufs_hba *hba)
241-
{
242-
if (hba->vops && hba->vops->reinit_notify)
243-
hba->vops->reinit_notify(hba);
244-
}
245-
246240
static inline int ufshcd_vops_mcq_config_resource(struct ufs_hba *hba)
247241
{
248242
if (hba->vops && hba->vops->mcq_config_resource)

drivers/ufs/core/ufshcd.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8858,7 +8858,6 @@ static int ufshcd_probe_hba(struct ufs_hba *hba, bool init_dev_params)
88588858
ufshcd_device_reset(hba);
88598859
ufs_put_device_desc(hba);
88608860
ufshcd_hba_stop(hba);
8861-
ufshcd_vops_reinit_notify(hba);
88628861
ret = ufshcd_hba_enable(hba);
88638862
if (ret) {
88648863
dev_err(hba->dev, "Host controller enable failed\n");
@@ -10591,14 +10590,17 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
1059110590
}
1059210591

1059310592
/*
10594-
* Set the default power management level for runtime and system PM.
10593+
* Set the default power management level for runtime and system PM if
10594+
* not set by the host controller drivers.
1059510595
* Default power saving mode is to keep UFS link in Hibern8 state
1059610596
* and UFS device in sleep state.
1059710597
*/
10598-
hba->rpm_lvl = ufs_get_desired_pm_lvl_for_dev_link_state(
10598+
if (!hba->rpm_lvl)
10599+
hba->rpm_lvl = ufs_get_desired_pm_lvl_for_dev_link_state(
1059910600
UFS_SLEEP_PWR_MODE,
1060010601
UIC_LINK_HIBERN8_STATE);
10601-
hba->spm_lvl = ufs_get_desired_pm_lvl_for_dev_link_state(
10602+
if (!hba->spm_lvl)
10603+
hba->spm_lvl = ufs_get_desired_pm_lvl_for_dev_link_state(
1060210604
UFS_SLEEP_PWR_MODE,
1060310605
UIC_LINK_HIBERN8_STATE);
1060410606

drivers/ufs/host/ufs-qcom.c

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,11 @@ static int ufs_qcom_power_up_sequence(struct ufs_hba *hba)
368368
if (ret)
369369
return ret;
370370

371+
if (phy->power_count) {
372+
phy_power_off(phy);
373+
phy_exit(phy);
374+
}
375+
371376
/* phy initialization - calibrate the phy */
372377
ret = phy_init(phy);
373378
if (ret) {
@@ -866,6 +871,7 @@ static u32 ufs_qcom_get_ufs_hci_version(struct ufs_hba *hba)
866871
*/
867872
static void ufs_qcom_advertise_quirks(struct ufs_hba *hba)
868873
{
874+
const struct ufs_qcom_drvdata *drvdata = of_device_get_match_data(hba->dev);
869875
struct ufs_qcom_host *host = ufshcd_get_variant(hba);
870876

871877
if (host->hw_ver.major == 0x2)
@@ -874,9 +880,8 @@ static void ufs_qcom_advertise_quirks(struct ufs_hba *hba)
874880
if (host->hw_ver.major > 0x3)
875881
hba->quirks |= UFSHCD_QUIRK_REINIT_AFTER_MAX_GEAR_SWITCH;
876882

877-
if (of_device_is_compatible(hba->dev->of_node, "qcom,sm8550-ufshc") ||
878-
of_device_is_compatible(hba->dev->of_node, "qcom,sm8650-ufshc"))
879-
hba->quirks |= UFSHCD_QUIRK_BROKEN_LSDBS_CAP;
883+
if (drvdata && drvdata->quirks)
884+
hba->quirks |= drvdata->quirks;
880885
}
881886

882887
static void ufs_qcom_set_phy_gear(struct ufs_qcom_host *host)
@@ -1064,6 +1069,7 @@ static int ufs_qcom_init(struct ufs_hba *hba)
10641069
struct device *dev = hba->dev;
10651070
struct ufs_qcom_host *host;
10661071
struct ufs_clk_info *clki;
1072+
const struct ufs_qcom_drvdata *drvdata = of_device_get_match_data(hba->dev);
10671073

10681074
host = devm_kzalloc(dev, sizeof(*host), GFP_KERNEL);
10691075
if (!host)
@@ -1143,6 +1149,9 @@ static int ufs_qcom_init(struct ufs_hba *hba)
11431149
dev_warn(dev, "%s: failed to configure the testbus %d\n",
11441150
__func__, err);
11451151

1152+
if (drvdata && drvdata->no_phy_retention)
1153+
hba->spm_lvl = UFS_PM_LVL_5;
1154+
11461155
return 0;
11471156

11481157
out_variant_clear:
@@ -1579,13 +1588,6 @@ static void ufs_qcom_config_scaling_param(struct ufs_hba *hba,
15791588
}
15801589
#endif
15811590

1582-
static void ufs_qcom_reinit_notify(struct ufs_hba *hba)
1583-
{
1584-
struct ufs_qcom_host *host = ufshcd_get_variant(hba);
1585-
1586-
phy_power_off(host->generic_phy);
1587-
}
1588-
15891591
/* Resources */
15901592
static const struct ufshcd_res_info ufs_res_info[RES_MAX] = {
15911593
{.name = "ufs_mem",},
@@ -1825,7 +1827,6 @@ static const struct ufs_hba_variant_ops ufs_hba_qcom_vops = {
18251827
.device_reset = ufs_qcom_device_reset,
18261828
.config_scaling_param = ufs_qcom_config_scaling_param,
18271829
.program_key = ufs_qcom_ice_program_key,
1828-
.reinit_notify = ufs_qcom_reinit_notify,
18291830
.mcq_config_resource = ufs_qcom_mcq_config_resource,
18301831
.get_hba_mac = ufs_qcom_get_hba_mac,
18311832
.op_runtime_config = ufs_qcom_op_runtime_config,
@@ -1868,9 +1869,15 @@ static void ufs_qcom_remove(struct platform_device *pdev)
18681869
platform_device_msi_free_irqs_all(hba->dev);
18691870
}
18701871

1872+
static const struct ufs_qcom_drvdata ufs_qcom_sm8550_drvdata = {
1873+
.quirks = UFSHCD_QUIRK_BROKEN_LSDBS_CAP,
1874+
.no_phy_retention = true,
1875+
};
1876+
18711877
static const struct of_device_id ufs_qcom_of_match[] __maybe_unused = {
18721878
{ .compatible = "qcom,ufshc" },
1873-
{ .compatible = "qcom,sm8550-ufshc" },
1879+
{ .compatible = "qcom,sm8550-ufshc", .data = &ufs_qcom_sm8550_drvdata },
1880+
{ .compatible = "qcom,sm8650-ufshc", .data = &ufs_qcom_sm8550_drvdata },
18741881
{},
18751882
};
18761883
MODULE_DEVICE_TABLE(of, ufs_qcom_of_match);

drivers/ufs/host/ufs-qcom.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,11 @@ struct ufs_qcom_host {
217217
bool esi_enabled;
218218
};
219219

220+
struct ufs_qcom_drvdata {
221+
enum ufshcd_quirks quirks;
222+
bool no_phy_retention;
223+
};
224+
220225
static inline u32
221226
ufs_qcom_get_debug_reg_offset(struct ufs_qcom_host *host, u32 reg)
222227
{

include/ufs/ufshcd.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,6 @@ struct ufs_pwr_mode_info {
329329
* @program_key: program or evict an inline encryption key
330330
* @fill_crypto_prdt: initialize crypto-related fields in the PRDT
331331
* @event_notify: called to notify important events
332-
* @reinit_notify: called to notify reinit of UFSHCD during max gear switch
333332
* @mcq_config_resource: called to configure MCQ platform resources
334333
* @get_hba_mac: reports maximum number of outstanding commands supported by
335334
* the controller. Should be implemented for UFSHCI 4.0 or later
@@ -381,7 +380,6 @@ struct ufs_hba_variant_ops {
381380
void *prdt, unsigned int num_segments);
382381
void (*event_notify)(struct ufs_hba *hba,
383382
enum ufs_event_type evt, void *data);
384-
void (*reinit_notify)(struct ufs_hba *);
385383
int (*mcq_config_resource)(struct ufs_hba *hba);
386384
int (*get_hba_mac)(struct ufs_hba *hba);
387385
int (*op_runtime_config)(struct ufs_hba *hba);

0 commit comments

Comments
 (0)