Skip to content

Commit e30618a

Browse files
Merge patch series "UFS patches for kernel 6.11"
Bart Van Assche <bvanassche@acm.org> says: Hi Martin, Please consider this series of UFS driver patches for the next merge window. Thank you, Bart. Link: https://lore.kernel.org/r/20240708211716.2827751-1-bvanassche@acm.org Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 parents 5e9a522 + af568c7 commit e30618a

File tree

6 files changed

+90
-87
lines changed

6 files changed

+90
-87
lines changed

drivers/ufs/core/ufs-mcq.c

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,20 +137,28 @@ EXPORT_SYMBOL_GPL(ufshcd_mcq_queue_cfg_addr);
137137
*
138138
* MAC - Max. Active Command of the Host Controller (HC)
139139
* HC wouldn't send more than this commands to the device.
140-
* It is mandatory to implement get_hba_mac() to enable MCQ mode.
141140
* Calculates and adjusts the queue depth based on the depth
142141
* supported by the HC and ufs device.
143142
*/
144143
int ufshcd_mcq_decide_queue_depth(struct ufs_hba *hba)
145144
{
146145
int mac;
147146

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);
153159
}
160+
if (mac < 0)
161+
goto err;
154162

155163
WARN_ON_ONCE(!hba->dev_info.bqueuedepth);
156164
/*
@@ -159,6 +167,10 @@ int ufshcd_mcq_decide_queue_depth(struct ufs_hba *hba)
159167
* shared queuing architecture is enabled.
160168
*/
161169
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;
162174
}
163175

164176
static int ufshcd_mcq_config_nr_queues(struct ufs_hba *hba)
@@ -415,9 +427,16 @@ EXPORT_SYMBOL_GPL(ufshcd_mcq_enable_esi);
415427
void ufshcd_mcq_enable(struct ufs_hba *hba)
416428
{
417429
ufshcd_rmwl(hba, MCQ_MODE_SELECT, MCQ_MODE_SELECT, REG_UFS_MEM_CFG);
430+
hba->mcq_enabled = true;
418431
}
419432
EXPORT_SYMBOL_GPL(ufshcd_mcq_enable);
420433

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+
421440
void ufshcd_mcq_config_esi(struct ufs_hba *hba, struct msi_msg *msg)
422441
{
423442
ufshcd_writel(hba, msg->address_lo, REG_UFS_ESILBA);

drivers/ufs/core/ufshcd-priv.h

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,11 @@ void ufshcd_auto_hibern8_update(struct ufs_hba *hba, u32 ahit);
6464
void ufshcd_compl_one_cqe(struct ufs_hba *hba, int task_tag,
6565
struct cq_entry *cqe);
6666
int ufshcd_mcq_init(struct ufs_hba *hba);
67+
void ufshcd_mcq_disable(struct ufs_hba *hba);
6768
int ufshcd_mcq_decide_queue_depth(struct ufs_hba *hba);
6869
int ufshcd_mcq_memory_alloc(struct ufs_hba *hba);
69-
void ufshcd_mcq_make_queues_operational(struct ufs_hba *hba);
70-
void ufshcd_mcq_config_mac(struct ufs_hba *hba, u32 max_active_cmds);
71-
u32 ufshcd_mcq_read_cqis(struct ufs_hba *hba, int i);
72-
void ufshcd_mcq_write_cqis(struct ufs_hba *hba, u32 val, int i);
7370
struct ufs_hw_queue *ufshcd_mcq_req_to_hwq(struct ufs_hba *hba,
7471
struct request *req);
75-
unsigned long ufshcd_mcq_poll_cqe_lock(struct ufs_hba *hba,
76-
struct ufs_hw_queue *hwq);
7772
void ufshcd_mcq_compl_all_cqes_lock(struct ufs_hba *hba,
7873
struct ufs_hw_queue *hwq);
7974
bool ufshcd_cmd_inflight(struct scsi_cmnd *cmd);
@@ -255,14 +250,6 @@ static inline int ufshcd_vops_mcq_config_resource(struct ufs_hba *hba)
255250
return -EOPNOTSUPP;
256251
}
257252

258-
static inline int ufshcd_mcq_vops_get_hba_mac(struct ufs_hba *hba)
259-
{
260-
if (hba->vops && hba->vops->get_hba_mac)
261-
return hba->vops->get_hba_mac(hba);
262-
263-
return -EOPNOTSUPP;
264-
}
265-
266253
static inline int ufshcd_mcq_vops_op_runtime_config(struct ufs_hba *hba)
267254
{
268255
if (hba->vops && hba->vops->op_runtime_config)

0 commit comments

Comments
 (0)