@@ -776,12 +776,17 @@ static inline bool ufshcd_is_device_present(struct ufs_hba *hba)
776
776
/**
777
777
* ufshcd_get_tr_ocs - Get the UTRD Overall Command Status
778
778
* @lrbp: pointer to local command reference block
779
+ * @cqe: pointer to the completion queue entry
779
780
*
780
781
* This function is used to get the OCS field from UTRD
781
782
* Returns the OCS field in the UTRD
782
783
*/
783
- static enum utp_ocs ufshcd_get_tr_ocs (struct ufshcd_lrb * lrbp )
784
+ static enum utp_ocs ufshcd_get_tr_ocs (struct ufshcd_lrb * lrbp ,
785
+ struct cq_entry * cqe )
784
786
{
787
+ if (cqe )
788
+ return le32_to_cpu (cqe -> status ) & MASK_OCS ;
789
+
785
790
return le32_to_cpu (lrbp -> utr_descriptor_ptr -> header .dword_2 ) & MASK_OCS ;
786
791
}
787
792
@@ -3068,7 +3073,7 @@ static int ufshcd_wait_for_dev_cmd(struct ufs_hba *hba,
3068
3073
* not trigger any race conditions.
3069
3074
*/
3070
3075
hba -> dev_cmd .complete = NULL ;
3071
- err = ufshcd_get_tr_ocs (lrbp );
3076
+ err = ufshcd_get_tr_ocs (lrbp , hba -> dev_cmd . cqe );
3072
3077
if (!err )
3073
3078
err = ufshcd_dev_cmd_completion (hba , lrbp );
3074
3079
} else {
@@ -5202,18 +5207,20 @@ ufshcd_scsi_cmd_status(struct ufshcd_lrb *lrbp, int scsi_status)
5202
5207
* ufshcd_transfer_rsp_status - Get overall status of the response
5203
5208
* @hba: per adapter instance
5204
5209
* @lrbp: pointer to local reference block of completed command
5210
+ * @cqe: pointer to the completion queue entry
5205
5211
*
5206
5212
* Returns result of the command to notify SCSI midlayer
5207
5213
*/
5208
5214
static inline int
5209
- ufshcd_transfer_rsp_status (struct ufs_hba * hba , struct ufshcd_lrb * lrbp )
5215
+ ufshcd_transfer_rsp_status (struct ufs_hba * hba , struct ufshcd_lrb * lrbp ,
5216
+ struct cq_entry * cqe )
5210
5217
{
5211
5218
int result = 0 ;
5212
5219
int scsi_status ;
5213
5220
enum utp_ocs ocs ;
5214
5221
5215
5222
/* overall command status of utrd */
5216
- ocs = ufshcd_get_tr_ocs (lrbp );
5223
+ ocs = ufshcd_get_tr_ocs (lrbp , cqe );
5217
5224
5218
5225
if (hba -> quirks & UFSHCD_QUIRK_BROKEN_OCS_FATAL_ERROR ) {
5219
5226
if (be32_to_cpu (lrbp -> ucd_rsp_ptr -> header .dword_1 ) &
@@ -5378,42 +5385,53 @@ static void ufshcd_release_scsi_cmd(struct ufs_hba *hba,
5378
5385
}
5379
5386
5380
5387
/**
5381
- * __ufshcd_transfer_req_compl - handle SCSI and query command completion
5388
+ * ufshcd_compl_one_cqe - handle a completion queue entry
5382
5389
* @hba: per adapter instance
5383
- * @completed_reqs: bitmask that indicates which requests to complete
5390
+ * @task_tag: the task tag of the request to be completed
5391
+ * @cqe: pointer to the completion queue entry
5384
5392
*/
5385
- static void __ufshcd_transfer_req_compl (struct ufs_hba * hba ,
5386
- unsigned long completed_reqs )
5393
+ void ufshcd_compl_one_cqe (struct ufs_hba * hba , int task_tag ,
5394
+ struct cq_entry * cqe )
5387
5395
{
5388
5396
struct ufshcd_lrb * lrbp ;
5389
5397
struct scsi_cmnd * cmd ;
5390
- int index ;
5391
-
5392
- for_each_set_bit (index , & completed_reqs , hba -> nutrs ) {
5393
- lrbp = & hba -> lrb [index ];
5394
- lrbp -> compl_time_stamp = ktime_get ();
5395
- lrbp -> compl_time_stamp_local_clock = local_clock ();
5396
- cmd = lrbp -> cmd ;
5397
- if (cmd ) {
5398
- if (unlikely (ufshcd_should_inform_monitor (hba , lrbp )))
5399
- ufshcd_update_monitor (hba , lrbp );
5400
- ufshcd_add_command_trace (hba , index , UFS_CMD_COMP );
5401
- cmd -> result = ufshcd_transfer_rsp_status (hba , lrbp );
5402
- ufshcd_release_scsi_cmd (hba , lrbp );
5403
- /* Do not touch lrbp after scsi done */
5404
- scsi_done (cmd );
5405
- } else if (lrbp -> command_type == UTP_CMD_TYPE_DEV_MANAGE ||
5406
- lrbp -> command_type == UTP_CMD_TYPE_UFS_STORAGE ) {
5407
- if (hba -> dev_cmd .complete ) {
5408
- ufshcd_add_command_trace (hba , index ,
5409
- UFS_DEV_COMP );
5410
- complete (hba -> dev_cmd .complete );
5411
- ufshcd_clk_scaling_update_busy (hba );
5412
- }
5398
+
5399
+ lrbp = & hba -> lrb [task_tag ];
5400
+ lrbp -> compl_time_stamp = ktime_get ();
5401
+ cmd = lrbp -> cmd ;
5402
+ if (cmd ) {
5403
+ if (unlikely (ufshcd_should_inform_monitor (hba , lrbp )))
5404
+ ufshcd_update_monitor (hba , lrbp );
5405
+ ufshcd_add_command_trace (hba , task_tag , UFS_CMD_COMP );
5406
+ cmd -> result = ufshcd_transfer_rsp_status (hba , lrbp , cqe );
5407
+ ufshcd_release_scsi_cmd (hba , lrbp );
5408
+ /* Do not touch lrbp after scsi done */
5409
+ scsi_done (cmd );
5410
+ } else if (lrbp -> command_type == UTP_CMD_TYPE_DEV_MANAGE ||
5411
+ lrbp -> command_type == UTP_CMD_TYPE_UFS_STORAGE ) {
5412
+ if (hba -> dev_cmd .complete ) {
5413
+ hba -> dev_cmd .cqe = cqe ;
5414
+ ufshcd_add_command_trace (hba , task_tag , UFS_DEV_COMP );
5415
+ complete (hba -> dev_cmd .complete );
5416
+ ufshcd_clk_scaling_update_busy (hba );
5413
5417
}
5414
5418
}
5415
5419
}
5416
5420
5421
+ /**
5422
+ * __ufshcd_transfer_req_compl - handle SCSI and query command completion
5423
+ * @hba: per adapter instance
5424
+ * @completed_reqs: bitmask that indicates which requests to complete
5425
+ */
5426
+ static void __ufshcd_transfer_req_compl (struct ufs_hba * hba ,
5427
+ unsigned long completed_reqs )
5428
+ {
5429
+ int tag ;
5430
+
5431
+ for_each_set_bit (tag , & completed_reqs , hba -> nutrs )
5432
+ ufshcd_compl_one_cqe (hba , tag , NULL );
5433
+ }
5434
+
5417
5435
/* Any value that is not an existing queue number is fine for this constant. */
5418
5436
enum {
5419
5437
UFSHCD_POLL_FROM_INTERRUPT_CONTEXT = -1
0 commit comments