[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <473a01dc1fde$3c7df240$b579d6c0$@samsung.com>
Date: Sun, 7 Sep 2025 15:30:22 +0530
From: "Alim Akhtar" <alim.akhtar@...sung.com>
To: "'Alok Tiwari'" <alok.a.tiwari@...cle.com>, <mani@...nel.org>,
<quic_cang@...cinc.com>, <quic_asutoshd@...cinc.com>,
<peter.wang@...iatek.com>, <martin.petersen@...cle.com>,
<avri.altman@....com>, <bvanassche@....org>,
<James.Bottomley@...senPartnership.com>, <linux-scsi@...r.kernel.org>
Cc: <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH] scsi: ufs: mcq: Fix memory allocation checks for SQE
and CQE
Hi Alok
> -----Original Message-----
> From: Alok Tiwari <alok.a.tiwari@...cle.com>
> Sent: Sunday, September 7, 2025 2:06 AM
> To: mani@...nel.org; quic_cang@...cinc.com; quic_asutoshd@...cinc.com;
> peter.wang@...iatek.com; martin.petersen@...cle.com;
> alim.akhtar@...sung.com; avri.altman@....com; bvanassche@....org;
> James.Bottomley@...senPartnership.com; linux-scsi@...r.kernel.org
> Cc: alok.a.tiwari@...cle.com; linux-kernel@...r.kernel.org
> Subject: [PATCH] scsi: ufs: mcq: Fix memory allocation checks for SQE and
> CQE
>
> The previous checks incorrectly tested the DMA addresses returned by
> dmam_alloc_coherent instead of the returned virtual addresses.
> This could cause allocation failures to go unnoticed.
>
> dmam_alloc_coherent returns the CPU address, not the DMA address.
> Using DMA pointer for NULL check is incorrect.
>
Right, Zero/NULL can be a valid DMA address and NULL retuned by
dmam_alloc_coherent()
Is allocation failure.
May be rephrase your commit message to be more clearer and this patch is
good to go.
> Change checks to verify sqe_base_addr and cqe_base_addr instead of
> sqe_dma_addr and cqe_dma_addr
>
> Fixes: 4682abfae2eb ("scsi: ufs: core: mcq: Allocate memory for MCQ mode")
> Signed-off-by: Alok Tiwari <alok.a.tiwari@...cle.com>
> ---
For v2 patch, feel free to add
Reviewed-by: Alim Akhtar <alim.akhtar@...sung.com>
> drivers/ufs/core/ufs-mcq.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/ufs/core/ufs-mcq.c b/drivers/ufs/core/ufs-mcq.c index
> 1e50675772fe..cc88aaa106da 100644
> --- a/drivers/ufs/core/ufs-mcq.c
> +++ b/drivers/ufs/core/ufs-mcq.c
> @@ -243,7 +243,7 @@ int ufshcd_mcq_memory_alloc(struct ufs_hba *hba)
> hwq->sqe_base_addr = dmam_alloc_coherent(hba->dev,
> utrdl_size,
> &hwq-
> >sqe_dma_addr,
> GFP_KERNEL);
> - if (!hwq->sqe_dma_addr) {
> + if (!hwq->sqe_base_addr) {
> dev_err(hba->dev, "SQE allocation failed\n");
> return -ENOMEM;
> }
> @@ -252,7 +252,7 @@ int ufshcd_mcq_memory_alloc(struct ufs_hba *hba)
> hwq->cqe_base_addr = dmam_alloc_coherent(hba->dev,
> cqe_size,
> &hwq-
> >cqe_dma_addr,
> GFP_KERNEL);
> - if (!hwq->cqe_dma_addr) {
> + if (!hwq->cqe_base_addr) {
> dev_err(hba->dev, "CQE allocation failed\n");
> return -ENOMEM;
> }
> --
> 2.50.1
Powered by blists - more mailing lists