@@ -1409,13 +1409,6 @@ static int ufshcd_devfreq_target(struct device *dev,
1409
1409
struct ufs_clk_info * clki ;
1410
1410
unsigned long irq_flags ;
1411
1411
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
-
1419
1412
if (!ufshcd_is_clkscaling_supported (hba ))
1420
1413
return - EINVAL ;
1421
1414
@@ -8399,6 +8392,22 @@ static int ufshcd_add_lus(struct ufs_hba *hba)
8399
8392
if (ret )
8400
8393
goto out ;
8401
8394
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
+
8402
8411
ufs_bsg_probe (hba );
8403
8412
ufshpb_init (hba );
8404
8413
scsi_scan_host (hba -> host );
@@ -8670,12 +8679,6 @@ static void ufshcd_async_scan(void *data, async_cookie_t cookie)
8670
8679
if (ret ) {
8671
8680
pm_runtime_put_sync (hba -> dev );
8672
8681
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);
8679
8682
}
8680
8683
}
8681
8684
@@ -10316,30 +10319,12 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
10316
10319
*/
10317
10320
ufshcd_set_ufs_dev_active (hba );
10318
10321
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
-
10335
10322
async_schedule (ufshcd_async_scan , hba );
10336
10323
ufs_sysfs_add_nodes (hba -> dev );
10337
10324
10338
10325
device_enable_async_suspend (dev );
10339
10326
return 0 ;
10340
10327
10341
- rpm_put_sync :
10342
- pm_runtime_put_sync (dev );
10343
10328
free_tmf_queue :
10344
10329
blk_mq_destroy_queue (hba -> tmf_queue );
10345
10330
blk_put_queue (hba -> tmf_queue );
0 commit comments