@@ -2416,7 +2416,17 @@ static inline int ufshcd_hba_capabilities(struct ufs_hba *hba)
24162416 return err ;
24172417 }
24182418
2419+ /*
2420+ * The UFSHCI 3.0 specification does not define MCQ_SUPPORT and
2421+ * LSDB_SUPPORT, but [31:29] as reserved bits with reset value 0s, which
2422+ * means we can simply read values regardless of version.
2423+ */
24192424 hba -> mcq_sup = FIELD_GET (MASK_MCQ_SUPPORT , hba -> capabilities );
2425+ /*
2426+ * 0h: legacy single doorbell support is available
2427+ * 1h: indicate that legacy single doorbell support has been removed
2428+ */
2429+ hba -> lsdb_sup = !FIELD_GET (MASK_LSDB_SUPPORT , hba -> capabilities );
24202430 if (!hba -> mcq_sup )
24212431 return 0 ;
24222432
@@ -6553,7 +6563,8 @@ static void ufshcd_err_handler(struct work_struct *work)
65536563 if (ufshcd_err_handling_should_stop (hba ))
65546564 goto skip_err_handling ;
65556565
6556- if (hba -> dev_quirks & UFS_DEVICE_QUIRK_RECOVERY_FROM_DL_NAC_ERRORS ) {
6566+ if ((hba -> dev_quirks & UFS_DEVICE_QUIRK_RECOVERY_FROM_DL_NAC_ERRORS ) &&
6567+ !hba -> force_reset ) {
65576568 bool ret ;
65586569
65596570 spin_unlock_irqrestore (hba -> host -> host_lock , flags );
@@ -8211,7 +8222,10 @@ static void ufshcd_update_rtc(struct ufs_hba *hba)
82118222 */
82128223 val = ts64 .tv_sec - hba -> dev_info .rtc_time_baseline ;
82138224
8214- ufshcd_rpm_get_sync (hba );
8225+ /* Skip update RTC if RPM state is not RPM_ACTIVE */
8226+ if (ufshcd_rpm_get_if_active (hba ) <= 0 )
8227+ return ;
8228+
82158229 err = ufshcd_query_attr (hba , UPIU_QUERY_OPCODE_WRITE_ATTR , QUERY_ATTR_IDN_SECONDS_PASSED ,
82168230 0 , 0 , & val );
82178231 ufshcd_rpm_put_sync (hba );
@@ -10265,9 +10279,6 @@ int ufshcd_system_restore(struct device *dev)
1026510279 */
1026610280 ufshcd_readl (hba , REG_UTP_TASK_REQ_LIST_BASE_H );
1026710281
10268- /* Resuming from hibernate, assume that link was OFF */
10269- ufshcd_set_link_off (hba );
10270-
1027110282 return 0 ;
1027210283
1027310284}
@@ -10496,6 +10507,12 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
1049610507 }
1049710508
1049810509 if (!is_mcq_supported (hba )) {
10510+ if (!hba -> lsdb_sup ) {
10511+ dev_err (hba -> dev , "%s: failed to initialize (legacy doorbell mode not supported)\n" ,
10512+ __func__ );
10513+ err = - EINVAL ;
10514+ goto out_disable ;
10515+ }
1049910516 err = scsi_add_host (host , hba -> dev );
1050010517 if (err ) {
1050110518 dev_err (hba -> dev , "scsi_add_host failed\n" );
0 commit comments