Skip to content

Commit 86eb94b

Browse files
athierry1martinkpetersen
authored andcommitted
scsi: Revert "scsi: ufs: core: Initialize devfreq synchronously"
This reverts commit 7dafc3e. This patch introduced a regression [1] where hba->pwr_info is used before being initialized, which could create issues in ufshcd_scale_gear(). Revert it until a better solution is found. [1] https://lore.kernel.org/all/CAGaU9a_PMZhqv+YJ0r3w-hJMsR922oxW6Kg59vw+oen-NZ6Otw@mail.gmail.com Signed-off-by: Adrien Thierry <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Stanley Chu <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent d684a7a commit 86eb94b

File tree

2 files changed

+16
-32
lines changed

2 files changed

+16
-32
lines changed

drivers/ufs/core/ufshcd.c

Lines changed: 16 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1409,13 +1409,6 @@ static int ufshcd_devfreq_target(struct device *dev,
14091409
struct ufs_clk_info *clki;
14101410
unsigned long irq_flags;
14111411

1412-
/*
1413-
* Skip devfreq if UFS initialization is not finished.
1414-
* Otherwise ufs could be in a inconsistent state.
1415-
*/
1416-
if (!smp_load_acquire(&hba->logical_unit_scan_finished))
1417-
return 0;
1418-
14191412
if (!ufshcd_is_clkscaling_supported(hba))
14201413
return -EINVAL;
14211414

@@ -8399,6 +8392,22 @@ static int ufshcd_add_lus(struct ufs_hba *hba)
83998392
if (ret)
84008393
goto out;
84018394

8395+
/* Initialize devfreq after UFS device is detected */
8396+
if (ufshcd_is_clkscaling_supported(hba)) {
8397+
memcpy(&hba->clk_scaling.saved_pwr_info.info,
8398+
&hba->pwr_info,
8399+
sizeof(struct ufs_pa_layer_attr));
8400+
hba->clk_scaling.saved_pwr_info.is_valid = true;
8401+
hba->clk_scaling.is_allowed = true;
8402+
8403+
ret = ufshcd_devfreq_init(hba);
8404+
if (ret)
8405+
goto out;
8406+
8407+
hba->clk_scaling.is_enabled = true;
8408+
ufshcd_init_clk_scaling_sysfs(hba);
8409+
}
8410+
84028411
ufs_bsg_probe(hba);
84038412
ufshpb_init(hba);
84048413
scsi_scan_host(hba->host);
@@ -8670,12 +8679,6 @@ static void ufshcd_async_scan(void *data, async_cookie_t cookie)
86708679
if (ret) {
86718680
pm_runtime_put_sync(hba->dev);
86728681
ufshcd_hba_exit(hba);
8673-
} else {
8674-
/*
8675-
* Make sure that when reader code sees UFS initialization has finished,
8676-
* all initialization steps have really been executed.
8677-
*/
8678-
smp_store_release(&hba->logical_unit_scan_finished, true);
86798682
}
86808683
}
86818684

@@ -10316,30 +10319,12 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
1031610319
*/
1031710320
ufshcd_set_ufs_dev_active(hba);
1031810321

10319-
/* Initialize devfreq */
10320-
if (ufshcd_is_clkscaling_supported(hba)) {
10321-
memcpy(&hba->clk_scaling.saved_pwr_info.info,
10322-
&hba->pwr_info,
10323-
sizeof(struct ufs_pa_layer_attr));
10324-
hba->clk_scaling.saved_pwr_info.is_valid = true;
10325-
hba->clk_scaling.is_allowed = true;
10326-
10327-
err = ufshcd_devfreq_init(hba);
10328-
if (err)
10329-
goto rpm_put_sync;
10330-
10331-
hba->clk_scaling.is_enabled = true;
10332-
ufshcd_init_clk_scaling_sysfs(hba);
10333-
}
10334-
1033510322
async_schedule(ufshcd_async_scan, hba);
1033610323
ufs_sysfs_add_nodes(hba->dev);
1033710324

1033810325
device_enable_async_suspend(dev);
1033910326
return 0;
1034010327

10341-
rpm_put_sync:
10342-
pm_runtime_put_sync(dev);
1034310328
free_tmf_queue:
1034410329
blk_mq_destroy_queue(hba->tmf_queue);
1034510330
blk_put_queue(hba->tmf_queue);

include/ufs/ufshcd.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,6 @@ struct ufs_hba {
979979
struct completion *uic_async_done;
980980

981981
enum ufshcd_state ufshcd_state;
982-
bool logical_unit_scan_finished;
983982
u32 eh_flags;
984983
u32 intr_mask;
985984
u16 ee_ctrl_mask;

0 commit comments

Comments
 (0)