On Fri, 2022-09-02 at 15:41 -0700, Asutosh Das wrote:min() compares variables of same type only.
+
+static void ufshcd_mcq_config_nr_queues(struct ufs_hba *hba)
+{
+ int i, rem;
+ u32 hbaq_cap, cmp;
+ struct Scsi_Host *host = hba->host;
+
+ hbaq_cap = hba->mcq_capabilities & 0xff;
+
+ rem = hbaq_cap - dev_cmd_queue;
+ /* min() compares variables of same type */
+ hba->nr_queues[HCTX_TYPE_DEFAULT] = min(hbaq_cap -
dev_cmd_queue,
hba->nr_queues[HCTX_TYPE_DEFAULT] = min(rem, num_possible_cpus());
It would be initialized to 0. But I think we should configure it as a module parameter which is missing. Let me add it in the next version.+ num_possible_cpus());
+ rem -= hba->nr_queues[HCTX_TYPE_DEFAULT];
+ if (rem <= 0)
+ goto out;
+ cmp = rem;
+ hba->nr_queues[HCTX_TYPE_POLL] = min(cmp, poll_queues);
+ rem -= hba->nr_queues[HCTX_TYPE_POLL];
+ if (rem <= 0)
+ goto out;
+ cmp = rem;
+ hba->nr_queues[HCTX_TYPE_READ] = min(cmp, read_queues);
static read_queues is not initialized.
The reason for this naming was that only SQ's tail pointer can be updated by SW. I can add a _sq_ to this function in the next version. Plmk if you prefer a better name......
+static inline void ufshcd_inc_tp(struct ufs_hw_queue *q)
+{
+ u32 mask = q->max_entries - 1;
+ u32 val;
+
+ q->sq_tp_slot = (q->sq_tp_slot + 1) & mask;
+ val = q->sq_tp_slot * sizeof(struct utp_transfer_req_desc);
+ writel(val, q->mcq_sq_tp);
+}
This function just accesses the submission queue tail pointer. The
function name should clearly explain this.