Re: (2) [PATCH v2 06/17] ufs: core: mcq: Configure resource regions

Asutosh Das
2022-10-17T21:03:43Z

On Fri, Oct 07 2022 at 20:44 -0700, Daejun Park wrote:
>Hi Asutosh Das,
>
[...]
>>+        res = &hba->res[RES_MCQ];
>>+        /* Bail if NCQ resource is provided */
>Maybe MCQ?
Thanks, will fix it.

>
>>+        if (res->base)
>>+                goto out;
>>+
>>+        /* Manually allocate MCQ resource from ufs_mem */
>>+        res_mcq = res->resource;
>Why we assign the value to res_mcq?
>
Hmm, good point, will fix it.

>>+        res_mcq = devm_kzalloc(hba->dev, sizeof(*res_mcq), GFP_KERNEL);
>>+        if (!res_mcq) {
>>+                dev_err(hba->dev, "Failed to allocate MCQ resource\n");
>>+                return ret;
>>+        }
>>+
>>+        res_mcq->start = res_mem->start +
>>+                         MCQ_SQATTR_OFFSET(hba->mcq_capabilities);
>>+        res_mcq->end = res_mcq->start + hba->nr_hw_queues * MCQ_QCFG_SIZE - 1;
>>+        res_mcq->flags = res_mem->flags;
>>+        res_mcq->name = "mcq";
>>+
>>+        ret = insert_resource(&iomem_resource, res_mcq);
>>+        if (ret) {
>>+                dev_err(hba->dev, "Failed to insert MCQ resource, err=%d\n", ret);
>Should we free the res_mcq?
>
yes, will add it. Thanks.

>>+                return ret;
>>+        }
>>+
>>+        res->base = devm_ioremap_resource(hba->dev, res_mcq);
>>+        if (IS_ERR(res->base)) {
>>+                dev_err(hba->dev, "MCQ registers mapping failed, err=%d\n",
>>+                        (int)PTR_ERR(res->base));
>Should we call remove_resource and free the res_mcq?
>
I'll add the cleanup here.
>Thanks,
>Daejun