@@ -137,20 +137,28 @@ EXPORT_SYMBOL_GPL(ufshcd_mcq_queue_cfg_addr);
137
137
*
138
138
* MAC - Max. Active Command of the Host Controller (HC)
139
139
* HC wouldn't send more than this commands to the device.
140
- * It is mandatory to implement get_hba_mac() to enable MCQ mode.
141
140
* Calculates and adjusts the queue depth based on the depth
142
141
* supported by the HC and ufs device.
143
142
*/
144
143
int ufshcd_mcq_decide_queue_depth (struct ufs_hba * hba )
145
144
{
146
145
int mac ;
147
146
148
- /* Mandatory to implement get_hba_mac() */
149
- mac = ufshcd_mcq_vops_get_hba_mac (hba );
150
- if (mac < 0 ) {
151
- dev_err (hba -> dev , "Failed to get mac, err=%d\n" , mac );
152
- return mac ;
147
+ if (!hba -> vops || !hba -> vops -> get_hba_mac ) {
148
+ /*
149
+ * Extract the maximum number of active transfer tasks value
150
+ * from the host controller capabilities register. This value is
151
+ * 0-based.
152
+ */
153
+ hba -> capabilities =
154
+ ufshcd_readl (hba , REG_CONTROLLER_CAPABILITIES );
155
+ mac = hba -> capabilities & MASK_TRANSFER_REQUESTS_SLOTS_MCQ ;
156
+ mac ++ ;
157
+ } else {
158
+ mac = hba -> vops -> get_hba_mac (hba );
153
159
}
160
+ if (mac < 0 )
161
+ goto err ;
154
162
155
163
WARN_ON_ONCE (!hba -> dev_info .bqueuedepth );
156
164
/*
@@ -159,6 +167,10 @@ int ufshcd_mcq_decide_queue_depth(struct ufs_hba *hba)
159
167
* shared queuing architecture is enabled.
160
168
*/
161
169
return min_t (int , mac , hba -> dev_info .bqueuedepth );
170
+
171
+ err :
172
+ dev_err (hba -> dev , "Failed to get mac, err=%d\n" , mac );
173
+ return mac ;
162
174
}
163
175
164
176
static int ufshcd_mcq_config_nr_queues (struct ufs_hba * hba )
@@ -415,9 +427,16 @@ EXPORT_SYMBOL_GPL(ufshcd_mcq_enable_esi);
415
427
void ufshcd_mcq_enable (struct ufs_hba * hba )
416
428
{
417
429
ufshcd_rmwl (hba , MCQ_MODE_SELECT , MCQ_MODE_SELECT , REG_UFS_MEM_CFG );
430
+ hba -> mcq_enabled = true;
418
431
}
419
432
EXPORT_SYMBOL_GPL (ufshcd_mcq_enable );
420
433
434
+ void ufshcd_mcq_disable (struct ufs_hba * hba )
435
+ {
436
+ ufshcd_rmwl (hba , MCQ_MODE_SELECT , 0 , REG_UFS_MEM_CFG );
437
+ hba -> mcq_enabled = false;
438
+ }
439
+
421
440
void ufshcd_mcq_config_esi (struct ufs_hba * hba , struct msi_msg * msg )
422
441
{
423
442
ufshcd_writel (hba , msg -> address_lo , REG_UFS_ESILBA );
0 commit comments