Re: [RFC PATCH v3 2/4] ufs: core: mcq: Adds Multi-Circular Queue support

From: Asutosh Das (asd)
Date: Wed Sep 07 2022 - 23:02:12 EST


Hello Bean
Thanks for your comments. Responses inline.

On 9/5/2022 6:48 AM, Bean Huo wrote:
On Fri, 2022-09-02 at 15:41 -0700, Asutosh Das wrote:
+/**
+ * ufshcd_mcq_decide_queue_depth - decide the queue depth
+ * @hba - per adapter instance
+ *
+ * MAC - Max. Active Command of the Host Controller (HC)
+ * HC wouldn't send more than this commands to the device.
+ * The default MAC is 32, but the max. value may vary with
+ * vendor implementation.
+ * Calculates and adjusts the queue depth based on the depth
+ * supported by the HC, ufs device and if ext_iid is supported.
+ */
+u32 ufshcd_mcq_decide_queue_depth(struct ufs_hba *hba)
+{
+       u32 qd, val;
+       int mac;
+
+       mac = ufshcd_mcq_vops_get_hba_mac(hba);
+       if (mac < 0) {
+               val = ufshcd_readl(hba, REG_UFS_MCQ_CFG);
+               mac = (val & MCQ_CFG_MAC_MASK) >> MCQ_CFG_MAC_OFFSET;
+       }
+
+       /*  MAC is a 0 based value. */
+       mac += 1;
+       qd = min_t(u32, mac, hba->dev_info.bqueuedepth);
+       if (!qd)
+               qd = mac;
+
+       /* Adjust queue depth based on ext_iid support. */
+       if (qd > 256 && (!hba->ext_iid_sup || !hba-
dev_info.b_ext_iid_en))
+               qd = 256;
+       else if (qd > 4096 && hba->ext_iid_sup && hba-
dev_info.b_ext_iid_en)
+               qd = 4096;
+

Astosh,

I don't understand here. How can qd be 4096? MAC in UFSHCI is 9 bits
width, the maximum depth will be 512, and hba->dev_info.bqueuedepth is
one byte width, maximum will be 256.

Correct. The spec is fuzzy about it. Because ext_iid provides a provision to increase the Queue depth to 2^12. Even though the parameters that you referred to don't support it now.

Will remove this part in the next version.

Kind regards,
Bean