@@ -1303,7 +1303,7 @@ static u32 ufshcd_pending_cmds(struct ufs_hba *hba)
1303
1303
*
1304
1304
* Return: 0 upon success; -EBUSY upon timeout.
1305
1305
*/
1306
- static int ufshcd_wait_for_doorbell_clr (struct ufs_hba * hba ,
1306
+ static int ufshcd_wait_for_pending_cmds (struct ufs_hba * hba ,
1307
1307
u64 wait_timeout_us )
1308
1308
{
1309
1309
int ret = 0 ;
@@ -1431,7 +1431,7 @@ static int ufshcd_clock_scaling_prepare(struct ufs_hba *hba, u64 timeout_us)
1431
1431
down_write (& hba -> clk_scaling_lock );
1432
1432
1433
1433
if (!hba -> clk_scaling .is_allowed ||
1434
- ufshcd_wait_for_doorbell_clr (hba , timeout_us )) {
1434
+ ufshcd_wait_for_pending_cmds (hba , timeout_us )) {
1435
1435
ret = - EBUSY ;
1436
1436
up_write (& hba -> clk_scaling_lock );
1437
1437
mutex_unlock (& hba -> wb_mutex );
@@ -3199,7 +3199,8 @@ ufshcd_dev_cmd_completion(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
3199
3199
}
3200
3200
3201
3201
/*
3202
- * Return: 0 upon success; < 0 upon failure.
3202
+ * Return: 0 upon success; > 0 in case the UFS device reported an OCS error;
3203
+ * < 0 if another error occurred.
3203
3204
*/
3204
3205
static int ufshcd_wait_for_dev_cmd (struct ufs_hba * hba ,
3205
3206
struct ufshcd_lrb * lrbp , int max_timeout )
@@ -3275,7 +3276,6 @@ static int ufshcd_wait_for_dev_cmd(struct ufs_hba *hba,
3275
3276
}
3276
3277
}
3277
3278
3278
- WARN_ONCE (err > 0 , "Incorrect return value %d > 0\n" , err );
3279
3279
return err ;
3280
3280
}
3281
3281
@@ -3294,7 +3294,8 @@ static void ufshcd_dev_man_unlock(struct ufs_hba *hba)
3294
3294
}
3295
3295
3296
3296
/*
3297
- * Return: 0 upon success; < 0 upon failure.
3297
+ * Return: 0 upon success; > 0 in case the UFS device reported an OCS error;
3298
+ * < 0 if another error occurred.
3298
3299
*/
3299
3300
static int ufshcd_issue_dev_cmd (struct ufs_hba * hba , struct ufshcd_lrb * lrbp ,
3300
3301
const u32 tag , int timeout )
@@ -3317,7 +3318,8 @@ static int ufshcd_issue_dev_cmd(struct ufs_hba *hba, struct ufshcd_lrb *lrbp,
3317
3318
* @cmd_type: specifies the type (NOP, Query...)
3318
3319
* @timeout: timeout in milliseconds
3319
3320
*
3320
- * Return: 0 upon success; < 0 upon failure.
3321
+ * Return: 0 upon success; > 0 in case the UFS device reported an OCS error;
3322
+ * < 0 if another error occurred.
3321
3323
*
3322
3324
* NOTE: Since there is only one available tag for device management commands,
3323
3325
* it is expected you hold the hba->dev_cmd.lock mutex.
@@ -3363,6 +3365,10 @@ static inline void ufshcd_init_query(struct ufs_hba *hba,
3363
3365
(* request )-> upiu_req .selector = selector ;
3364
3366
}
3365
3367
3368
+ /*
3369
+ * Return: 0 upon success; > 0 in case the UFS device reported an OCS error;
3370
+ * < 0 if another error occurred.
3371
+ */
3366
3372
static int ufshcd_query_flag_retry (struct ufs_hba * hba ,
3367
3373
enum query_opcode opcode , enum flag_idn idn , u8 index , bool * flag_res )
3368
3374
{
@@ -3383,7 +3389,6 @@ static int ufshcd_query_flag_retry(struct ufs_hba *hba,
3383
3389
dev_err (hba -> dev ,
3384
3390
"%s: query flag, opcode %d, idn %d, failed with error %d after %d retries\n" ,
3385
3391
__func__ , opcode , idn , ret , retries );
3386
- WARN_ONCE (ret > 0 , "Incorrect return value %d > 0\n" , ret );
3387
3392
return ret ;
3388
3393
}
3389
3394
@@ -3395,7 +3400,8 @@ static int ufshcd_query_flag_retry(struct ufs_hba *hba,
3395
3400
* @index: flag index to access
3396
3401
* @flag_res: the flag value after the query request completes
3397
3402
*
3398
- * Return: 0 for success; < 0 upon failure.
3403
+ * Return: 0 upon success; > 0 in case the UFS device reported an OCS error;
3404
+ * < 0 if another error occurred.
3399
3405
*/
3400
3406
int ufshcd_query_flag (struct ufs_hba * hba , enum query_opcode opcode ,
3401
3407
enum flag_idn idn , u8 index , bool * flag_res )
@@ -3451,7 +3457,6 @@ int ufshcd_query_flag(struct ufs_hba *hba, enum query_opcode opcode,
3451
3457
3452
3458
out_unlock :
3453
3459
ufshcd_dev_man_unlock (hba );
3454
- WARN_ONCE (err > 0 , "Incorrect return value %d > 0\n" , err );
3455
3460
return err ;
3456
3461
}
3457
3462
@@ -3464,8 +3469,9 @@ int ufshcd_query_flag(struct ufs_hba *hba, enum query_opcode opcode,
3464
3469
* @selector: selector field
3465
3470
* @attr_val: the attribute value after the query request completes
3466
3471
*
3467
- * Return: 0 upon success; < 0 upon failure.
3468
- */
3472
+ * Return: 0 upon success; > 0 in case the UFS device reported an OCS error;
3473
+ * < 0 if another error occurred.
3474
+ */
3469
3475
int ufshcd_query_attr (struct ufs_hba * hba , enum query_opcode opcode ,
3470
3476
enum attr_idn idn , u8 index , u8 selector , u32 * attr_val )
3471
3477
{
@@ -3513,7 +3519,6 @@ int ufshcd_query_attr(struct ufs_hba *hba, enum query_opcode opcode,
3513
3519
3514
3520
out_unlock :
3515
3521
ufshcd_dev_man_unlock (hba );
3516
- WARN_ONCE (err > 0 , "Incorrect return value %d > 0\n" , err );
3517
3522
return err ;
3518
3523
}
3519
3524
@@ -3528,8 +3533,9 @@ int ufshcd_query_attr(struct ufs_hba *hba, enum query_opcode opcode,
3528
3533
* @attr_val: the attribute value after the query request
3529
3534
* completes
3530
3535
*
3531
- * Return: 0 for success; < 0 upon failure.
3532
- */
3536
+ * Return: 0 upon success; > 0 in case the UFS device reported an OCS error;
3537
+ * < 0 if another error occurred.
3538
+ */
3533
3539
int ufshcd_query_attr_retry (struct ufs_hba * hba ,
3534
3540
enum query_opcode opcode , enum attr_idn idn , u8 index , u8 selector ,
3535
3541
u32 * attr_val )
@@ -3551,12 +3557,12 @@ int ufshcd_query_attr_retry(struct ufs_hba *hba,
3551
3557
dev_err (hba -> dev ,
3552
3558
"%s: query attribute, idn %d, failed with error %d after %d retries\n" ,
3553
3559
__func__ , idn , ret , QUERY_REQ_RETRIES );
3554
- WARN_ONCE (ret > 0 , "Incorrect return value %d > 0\n" , ret );
3555
3560
return ret ;
3556
3561
}
3557
3562
3558
3563
/*
3559
- * Return: 0 if successful; < 0 upon failure.
3564
+ * Return: 0 upon success; > 0 in case the UFS device reported an OCS error;
3565
+ * < 0 if another error occurred.
3560
3566
*/
3561
3567
static int __ufshcd_query_descriptor (struct ufs_hba * hba ,
3562
3568
enum query_opcode opcode , enum desc_idn idn , u8 index ,
@@ -3615,7 +3621,6 @@ static int __ufshcd_query_descriptor(struct ufs_hba *hba,
3615
3621
out_unlock :
3616
3622
hba -> dev_cmd .query .descriptor = NULL ;
3617
3623
ufshcd_dev_man_unlock (hba );
3618
- WARN_ONCE (err > 0 , "Incorrect return value %d > 0\n" , err );
3619
3624
return err ;
3620
3625
}
3621
3626
@@ -3632,7 +3637,8 @@ static int __ufshcd_query_descriptor(struct ufs_hba *hba,
3632
3637
* The buf_len parameter will contain, on return, the length parameter
3633
3638
* received on the response.
3634
3639
*
3635
- * Return: 0 for success; < 0 upon failure.
3640
+ * Return: 0 upon success; > 0 in case the UFS device reported an OCS error;
3641
+ * < 0 if another error occurred.
3636
3642
*/
3637
3643
int ufshcd_query_descriptor_retry (struct ufs_hba * hba ,
3638
3644
enum query_opcode opcode ,
@@ -3650,7 +3656,6 @@ int ufshcd_query_descriptor_retry(struct ufs_hba *hba,
3650
3656
break ;
3651
3657
}
3652
3658
3653
- WARN_ONCE (err > 0 , "Incorrect return value %d > 0\n" , err );
3654
3659
return err ;
3655
3660
}
3656
3661
@@ -3663,7 +3668,8 @@ int ufshcd_query_descriptor_retry(struct ufs_hba *hba,
3663
3668
* @param_read_buf: pointer to buffer where parameter would be read
3664
3669
* @param_size: sizeof(param_read_buf)
3665
3670
*
3666
- * Return: 0 in case of success; < 0 upon failure.
3671
+ * Return: 0 upon success; > 0 in case the UFS device reported an OCS error;
3672
+ * < 0 if another error occurred.
3667
3673
*/
3668
3674
int ufshcd_read_desc_param (struct ufs_hba * hba ,
3669
3675
enum desc_idn desc_id ,
@@ -3730,7 +3736,6 @@ int ufshcd_read_desc_param(struct ufs_hba *hba,
3730
3736
out :
3731
3737
if (is_kmalloc )
3732
3738
kfree (desc_buf );
3733
- WARN_ONCE (ret > 0 , "Incorrect return value %d > 0\n" , ret );
3734
3739
return ret ;
3735
3740
}
3736
3741
@@ -4781,7 +4786,8 @@ EXPORT_SYMBOL_GPL(ufshcd_config_pwr_mode);
4781
4786
*
4782
4787
* Set fDeviceInit flag and poll until device toggles it.
4783
4788
*
4784
- * Return: 0 upon success; < 0 upon failure.
4789
+ * Return: 0 upon success; > 0 in case the UFS device reported an OCS error;
4790
+ * < 0 if another error occurred.
4785
4791
*/
4786
4792
static int ufshcd_complete_dev_init (struct ufs_hba * hba )
4787
4793
{
@@ -5135,7 +5141,8 @@ static int ufshcd_link_startup(struct ufs_hba *hba)
5135
5141
* not respond with NOP IN UPIU within timeout of %NOP_OUT_TIMEOUT
5136
5142
* and we retry sending NOP OUT for %NOP_OUT_RETRIES iterations.
5137
5143
*
5138
- * Return: 0 upon success; < 0 upon failure.
5144
+ * Return: 0 upon success; > 0 in case the UFS device reported an OCS error;
5145
+ * < 0 if another error occurred.
5139
5146
*/
5140
5147
static int ufshcd_verify_dev_init (struct ufs_hba * hba )
5141
5148
{
@@ -5559,9 +5566,9 @@ static irqreturn_t ufshcd_uic_cmd_compl(struct ufs_hba *hba, u32 intr_status)
5559
5566
irqreturn_t retval = IRQ_NONE ;
5560
5567
struct uic_command * cmd ;
5561
5568
5562
- spin_lock (hba -> host -> host_lock );
5569
+ guard ( spinlock_irqsave ) (hba -> host -> host_lock );
5563
5570
cmd = hba -> active_uic_cmd ;
5564
- if (WARN_ON_ONCE ( !cmd ) )
5571
+ if (!cmd )
5565
5572
goto unlock ;
5566
5573
5567
5574
if (ufshcd_is_auto_hibern8_error (hba , intr_status ))
@@ -5586,8 +5593,6 @@ static irqreturn_t ufshcd_uic_cmd_compl(struct ufs_hba *hba, u32 intr_status)
5586
5593
ufshcd_add_uic_command_trace (hba , cmd , UFS_CMD_COMP );
5587
5594
5588
5595
unlock :
5589
- spin_unlock (hba -> host -> host_lock );
5590
-
5591
5596
return retval ;
5592
5597
}
5593
5598
@@ -5869,7 +5874,8 @@ static inline int ufshcd_enable_ee(struct ufs_hba *hba, u16 mask)
5869
5874
* as the device is allowed to manage its own way of handling background
5870
5875
* operations.
5871
5876
*
5872
- * Return: zero on success, non-zero on failure.
5877
+ * Return: 0 upon success; > 0 in case the UFS device reported an OCS error;
5878
+ * < 0 if another error occurred.
5873
5879
*/
5874
5880
static int ufshcd_enable_auto_bkops (struct ufs_hba * hba )
5875
5881
{
@@ -5908,7 +5914,8 @@ static int ufshcd_enable_auto_bkops(struct ufs_hba *hba)
5908
5914
* host is idle so that BKOPS are managed effectively without any negative
5909
5915
* impacts.
5910
5916
*
5911
- * Return: zero on success, non-zero on failure.
5917
+ * Return: 0 upon success; > 0 in case the UFS device reported an OCS error;
5918
+ * < 0 if another error occurred.
5912
5919
*/
5913
5920
static int ufshcd_disable_auto_bkops (struct ufs_hba * hba )
5914
5921
{
@@ -6058,6 +6065,10 @@ static void ufshcd_bkops_exception_event_handler(struct ufs_hba *hba)
6058
6065
__func__ , err );
6059
6066
}
6060
6067
6068
+ /*
6069
+ * Return: 0 upon success; > 0 in case the UFS device reported an OCS error;
6070
+ * < 0 if another error occurred.
6071
+ */
6061
6072
int ufshcd_read_device_lvl_exception_id (struct ufs_hba * hba , u64 * exception_id )
6062
6073
{
6063
6074
struct utp_upiu_query_v4_0 * upiu_resp ;
@@ -6920,7 +6931,7 @@ static irqreturn_t ufshcd_check_errors(struct ufs_hba *hba, u32 intr_status)
6920
6931
bool queue_eh_work = false;
6921
6932
irqreturn_t retval = IRQ_NONE ;
6922
6933
6923
- spin_lock (hba -> host -> host_lock );
6934
+ guard ( spinlock_irqsave ) (hba -> host -> host_lock );
6924
6935
hba -> errors |= UFSHCD_ERROR_MASK & intr_status ;
6925
6936
6926
6937
if (hba -> errors & INT_FATAL_ERRORS ) {
@@ -6979,7 +6990,7 @@ static irqreturn_t ufshcd_check_errors(struct ufs_hba *hba, u32 intr_status)
6979
6990
*/
6980
6991
hba -> errors = 0 ;
6981
6992
hba -> uic_error = 0 ;
6982
- spin_unlock ( hba -> host -> host_lock );
6993
+
6983
6994
return retval ;
6984
6995
}
6985
6996
@@ -7454,7 +7465,8 @@ int ufshcd_exec_raw_upiu_cmd(struct ufs_hba *hba,
7454
7465
* @sg_list: Pointer to SG list when DATA IN/OUT UPIU is required in ARPMB operation
7455
7466
* @dir: DMA direction
7456
7467
*
7457
- * Return: zero on success, non-zero on failure.
7468
+ * Return: 0 upon success; > 0 in case the UFS device reported an OCS error;
7469
+ * < 0 if another error occurred.
7458
7470
*/
7459
7471
int ufshcd_advanced_rpmb_req_handler (struct ufs_hba * hba , struct utp_upiu_req * req_upiu ,
7460
7472
struct utp_upiu_req * rsp_upiu , struct ufs_ehs * req_ehs ,
0 commit comments