@@ -2185,9 +2185,11 @@ static void ufshcd_update_monitor(struct ufs_hba *hba, const struct ufshcd_lrb *
2185
2185
* ufshcd_send_command - Send SCSI or device management commands
2186
2186
* @hba: per adapter instance
2187
2187
* @task_tag: Task tag of the command
2188
+ * @hwq: pointer to hardware queue instance
2188
2189
*/
2189
2190
static inline
2190
- void ufshcd_send_command (struct ufs_hba * hba , unsigned int task_tag )
2191
+ void ufshcd_send_command (struct ufs_hba * hba , unsigned int task_tag ,
2192
+ struct ufs_hw_queue * hwq )
2191
2193
{
2192
2194
struct ufshcd_lrb * lrbp = & hba -> lrb [task_tag ];
2193
2195
unsigned long flags ;
@@ -2201,12 +2203,24 @@ void ufshcd_send_command(struct ufs_hba *hba, unsigned int task_tag)
2201
2203
if (unlikely (ufshcd_should_inform_monitor (hba , lrbp )))
2202
2204
ufshcd_start_monitor (hba , lrbp );
2203
2205
2204
- spin_lock_irqsave (& hba -> outstanding_lock , flags );
2205
- if (hba -> vops && hba -> vops -> setup_xfer_req )
2206
- hba -> vops -> setup_xfer_req (hba , task_tag , !!lrbp -> cmd );
2207
- __set_bit (task_tag , & hba -> outstanding_reqs );
2208
- ufshcd_writel (hba , 1 << task_tag , REG_UTP_TRANSFER_REQ_DOOR_BELL );
2209
- spin_unlock_irqrestore (& hba -> outstanding_lock , flags );
2206
+ if (is_mcq_enabled (hba )) {
2207
+ int utrd_size = sizeof (struct utp_transfer_req_desc );
2208
+
2209
+ spin_lock (& hwq -> sq_lock );
2210
+ memcpy (hwq -> sqe_base_addr + (hwq -> sq_tail_slot * utrd_size ),
2211
+ lrbp -> utr_descriptor_ptr , utrd_size );
2212
+ ufshcd_inc_sq_tail (hwq );
2213
+ spin_unlock (& hwq -> sq_lock );
2214
+ } else {
2215
+ spin_lock_irqsave (& hba -> outstanding_lock , flags );
2216
+ if (hba -> vops && hba -> vops -> setup_xfer_req )
2217
+ hba -> vops -> setup_xfer_req (hba , lrbp -> task_tag ,
2218
+ !!lrbp -> cmd );
2219
+ __set_bit (lrbp -> task_tag , & hba -> outstanding_reqs );
2220
+ ufshcd_writel (hba , 1 << lrbp -> task_tag ,
2221
+ REG_UTP_TRANSFER_REQ_DOOR_BELL );
2222
+ spin_unlock_irqrestore (& hba -> outstanding_lock , flags );
2223
+ }
2210
2224
}
2211
2225
2212
2226
/**
@@ -2836,6 +2850,7 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd)
2836
2850
int tag = scsi_cmd_to_rq (cmd )-> tag ;
2837
2851
struct ufshcd_lrb * lrbp ;
2838
2852
int err = 0 ;
2853
+ struct ufs_hw_queue * hwq = NULL ;
2839
2854
2840
2855
WARN_ONCE (tag < 0 || tag >= hba -> nutrs , "Invalid tag %d\n" , tag );
2841
2856
@@ -2920,7 +2935,7 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd)
2920
2935
goto out ;
2921
2936
}
2922
2937
2923
- ufshcd_send_command (hba , tag );
2938
+ ufshcd_send_command (hba , tag , hwq );
2924
2939
2925
2940
out :
2926
2941
rcu_read_unlock ();
@@ -3121,10 +3136,11 @@ static int ufshcd_exec_dev_cmd(struct ufs_hba *hba,
3121
3136
goto out ;
3122
3137
3123
3138
hba -> dev_cmd .complete = & wait ;
3139
+ hba -> dev_cmd .cqe = NULL ;
3124
3140
3125
3141
ufshcd_add_query_upiu_trace (hba , UFS_QUERY_SEND , lrbp -> ucd_req_ptr );
3126
3142
3127
- ufshcd_send_command (hba , tag );
3143
+ ufshcd_send_command (hba , tag , hba -> dev_cmd_queue );
3128
3144
err = ufshcd_wait_for_dev_cmd (hba , lrbp , timeout );
3129
3145
ufshcd_add_query_upiu_trace (hba , err ? UFS_QUERY_ERR : UFS_QUERY_COMP ,
3130
3146
(struct utp_upiu_req * )lrbp -> ucd_rsp_ptr );
@@ -6938,7 +6954,7 @@ static int ufshcd_issue_devman_upiu_cmd(struct ufs_hba *hba,
6938
6954
6939
6955
ufshcd_add_query_upiu_trace (hba , UFS_QUERY_SEND , lrbp -> ucd_req_ptr );
6940
6956
6941
- ufshcd_send_command (hba , tag );
6957
+ ufshcd_send_command (hba , tag , hba -> dev_cmd_queue );
6942
6958
/*
6943
6959
* ignore the returning value here - ufshcd_check_query_response is
6944
6960
* bound to fail since dev_cmd.query and dev_cmd.type were left empty.
@@ -7104,7 +7120,7 @@ int ufshcd_advanced_rpmb_req_handler(struct ufs_hba *hba, struct utp_upiu_req *r
7104
7120
7105
7121
hba -> dev_cmd .complete = & wait ;
7106
7122
7107
- ufshcd_send_command (hba , tag );
7123
+ ufshcd_send_command (hba , tag , hba -> dev_cmd_queue );
7108
7124
7109
7125
err = ufshcd_wait_for_dev_cmd (hba , lrbp , ADVANCED_RPMB_REQ_TIMEOUT );
7110
7126
0 commit comments