@@ -6386,38 +6386,34 @@ static int __ufshcd_issue_tm_cmd(struct ufs_hba *hba,
6386
6386
DECLARE_COMPLETION_ONSTACK (wait );
6387
6387
struct request * req ;
6388
6388
unsigned long flags ;
6389
- int free_slot , task_tag , err ;
6389
+ int task_tag , err ;
6390
6390
6391
6391
/*
6392
- * Get free slot, sleep if slots are unavailable.
6393
- * Even though we use wait_event() which sleeps indefinitely,
6394
- * the maximum wait time is bounded by %TM_CMD_TIMEOUT.
6392
+ * blk_get_request() is used here only to get a free tag.
6395
6393
*/
6396
6394
req = blk_get_request (q , REQ_OP_DRV_OUT , 0 );
6397
6395
if (IS_ERR (req ))
6398
6396
return PTR_ERR (req );
6399
6397
6400
6398
req -> end_io_data = & wait ;
6401
- free_slot = req -> tag ;
6402
- WARN_ON_ONCE (free_slot < 0 || free_slot >= hba -> nutmrs );
6403
6399
ufshcd_hold (hba , false);
6404
6400
6405
6401
spin_lock_irqsave (host -> host_lock , flags );
6406
- task_tag = hba -> nutrs + free_slot ;
6407
6402
blk_mq_start_request (req );
6408
6403
6404
+ task_tag = req -> tag ;
6409
6405
treq -> req_header .dword_0 |= cpu_to_be32 (task_tag );
6410
6406
6411
- memcpy (hba -> utmrdl_base_addr + free_slot , treq , sizeof (* treq ));
6412
- ufshcd_vops_setup_task_mgmt (hba , free_slot , tm_function );
6407
+ memcpy (hba -> utmrdl_base_addr + task_tag , treq , sizeof (* treq ));
6408
+ ufshcd_vops_setup_task_mgmt (hba , task_tag , tm_function );
6413
6409
6414
6410
/* send command to the controller */
6415
- __set_bit (free_slot , & hba -> outstanding_tasks );
6411
+ __set_bit (task_tag , & hba -> outstanding_tasks );
6416
6412
6417
6413
/* Make sure descriptors are ready before ringing the task doorbell */
6418
6414
wmb ();
6419
6415
6420
- ufshcd_writel (hba , 1 << free_slot , REG_UTP_TASK_REQ_DOOR_BELL );
6416
+ ufshcd_writel (hba , 1 << task_tag , REG_UTP_TASK_REQ_DOOR_BELL );
6421
6417
/* Make sure that doorbell is committed immediately */
6422
6418
wmb ();
6423
6419
@@ -6437,24 +6433,24 @@ static int __ufshcd_issue_tm_cmd(struct ufs_hba *hba,
6437
6433
ufshcd_add_tm_upiu_trace (hba , task_tag , UFS_TM_ERR );
6438
6434
dev_err (hba -> dev , "%s: task management cmd 0x%.2x timed-out\n" ,
6439
6435
__func__ , tm_function );
6440
- if (ufshcd_clear_tm_cmd (hba , free_slot ))
6441
- dev_WARN (hba -> dev , "%s: unable clear tm cmd (slot %d) after timeout\n" ,
6442
- __func__ , free_slot );
6436
+ if (ufshcd_clear_tm_cmd (hba , task_tag ))
6437
+ dev_WARN (hba -> dev , "%s: unable to clear tm cmd (slot %d) after timeout\n" ,
6438
+ __func__ , task_tag );
6443
6439
err = - ETIMEDOUT ;
6444
6440
} else {
6445
6441
err = 0 ;
6446
- memcpy (treq , hba -> utmrdl_base_addr + free_slot , sizeof (* treq ));
6442
+ memcpy (treq , hba -> utmrdl_base_addr + task_tag , sizeof (* treq ));
6447
6443
6448
6444
ufshcd_add_tm_upiu_trace (hba , task_tag , UFS_TM_COMP );
6449
6445
}
6450
6446
6451
6447
spin_lock_irqsave (hba -> host -> host_lock , flags );
6452
- __clear_bit (free_slot , & hba -> outstanding_tasks );
6448
+ __clear_bit (task_tag , & hba -> outstanding_tasks );
6453
6449
spin_unlock_irqrestore (hba -> host -> host_lock , flags );
6454
6450
6451
+ ufshcd_release (hba );
6455
6452
blk_put_request (req );
6456
6453
6457
- ufshcd_release (hba );
6458
6454
return err ;
6459
6455
}
6460
6456
0 commit comments