Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

scsi: ufs: core: Rework the SCSI host queue depth calculation code

Prepare for allocating the SCSI host earlier by making the SCSI host
queue depth independent of the queue depth supported by the UFS device.
This patch may increase the queue depth of the UFS SCSI host.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Link: https://patch.msgid.link/20251031204029.2883185-18-bvanassche@acm.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Bart Van Assche and committed by
Martin K. Petersen
e8ea985a f18fac1e

+22 -22
+6 -19
drivers/ufs/core/ufs-mcq.c
··· 134 134 EXPORT_SYMBOL_GPL(ufshcd_mcq_queue_cfg_addr); 135 135 136 136 /** 137 - * ufshcd_mcq_decide_queue_depth - decide the queue depth 137 + * ufshcd_get_hba_mac - Maximum number of commands supported by the host 138 + * controller. 138 139 * @hba: per adapter instance 139 140 * 140 - * Return: queue-depth on success, non-zero on error 141 + * Return: queue depth on success; negative upon error. 141 142 * 142 - * MAC - Max. Active Command of the Host Controller (HC) 143 - * HC wouldn't send more than this commands to the device. 144 - * Calculates and adjusts the queue depth based on the depth 145 - * supported by the HC and ufs device. 143 + * MAC = Maximum number of Active Commands supported by the Host Controller. 146 144 */ 147 - int ufshcd_mcq_decide_queue_depth(struct ufs_hba *hba) 145 + int ufshcd_get_hba_mac(struct ufs_hba *hba) 148 146 { 149 147 int mac; 150 148 ··· 160 162 mac = hba->vops->get_hba_mac(hba); 161 163 } 162 164 if (mac < 0) 163 - goto err; 164 - 165 - WARN_ON_ONCE(!hba->dev_info.bqueuedepth); 166 - /* 167 - * max. value of bqueuedepth = 256, mac is host dependent. 168 - * It is mandatory for UFS device to define bQueueDepth if 169 - * shared queuing architecture is enabled. 170 - */ 171 - return min_t(int, mac, hba->dev_info.bqueuedepth); 172 - 173 - err: 174 - dev_err(hba->dev, "Failed to get mac, err=%d\n", mac); 165 + dev_err(hba->dev, "Failed to get mac, err=%d\n", mac); 175 166 return mac; 176 167 } 177 168
+1 -1
drivers/ufs/core/ufshcd-priv.h
··· 67 67 struct cq_entry *cqe); 68 68 int ufshcd_mcq_init(struct ufs_hba *hba); 69 69 void ufshcd_mcq_disable(struct ufs_hba *hba); 70 - int ufshcd_mcq_decide_queue_depth(struct ufs_hba *hba); 70 + int ufshcd_get_hba_mac(struct ufs_hba *hba); 71 71 int ufshcd_mcq_memory_alloc(struct ufs_hba *hba); 72 72 struct ufs_hw_queue *ufshcd_mcq_req_to_hwq(struct ufs_hba *hba, 73 73 struct request *req);
+15 -2
drivers/ufs/core/ufshcd.c
··· 8466 8466 8467 8467 static int ufs_get_device_desc(struct ufs_hba *hba) 8468 8468 { 8469 + struct ufs_dev_info *dev_info = &hba->dev_info; 8470 + struct Scsi_Host *shost = hba->host; 8469 8471 int err; 8470 8472 u8 model_index; 8471 8473 u8 *desc_buf; 8472 - struct ufs_dev_info *dev_info = &hba->dev_info; 8473 8474 8474 8475 desc_buf = kzalloc(QUERY_DESC_MAX_SIZE, GFP_KERNEL); 8475 8476 if (!desc_buf) { ··· 8497 8496 dev_info->wspecversion = desc_buf[DEVICE_DESC_PARAM_SPEC_VER] << 8 | 8498 8497 desc_buf[DEVICE_DESC_PARAM_SPEC_VER + 1]; 8499 8498 dev_info->bqueuedepth = desc_buf[DEVICE_DESC_PARAM_Q_DPTH]; 8499 + 8500 + /* 8501 + * According to the UFS standard, the UFS device queue depth 8502 + * (bQueueDepth) must be in the range 1..255 if the shared queueing 8503 + * architecture is supported. bQueueDepth is zero if the shared queueing 8504 + * architecture is not supported. 8505 + */ 8506 + if (dev_info->bqueuedepth) 8507 + shost->cmd_per_lun = min(hba->nutrs, dev_info->bqueuedepth) - 8508 + UFSHCD_NUM_RESERVED; 8509 + else 8510 + shost->cmd_per_lun = shost->can_queue; 8500 8511 8501 8512 dev_info->rtt_cap = desc_buf[DEVICE_DESC_PARAM_RTT_CAP]; 8502 8513 ··· 8918 8905 int ret; 8919 8906 int old_nutrs = hba->nutrs; 8920 8907 8921 - ret = ufshcd_mcq_decide_queue_depth(hba); 8908 + ret = ufshcd_get_hba_mac(hba); 8922 8909 if (ret < 0) 8923 8910 return ret; 8924 8911