[PATCH v2 3/3] mtd: rawnand: cadence: fix incorrect dev context in dma_unmap_single

niravkumar.l.rabara@intel.com posted 3 patches 2 weeks, 6 days ago
[PATCH v2 3/3] mtd: rawnand: cadence: fix incorrect dev context in dma_unmap_single
Posted by niravkumar.l.rabara@intel.com 2 weeks, 6 days ago
From: Niravkumar L Rabara <niravkumar.l.rabara@intel.com>

dma_map_single is using dma_dev->dev, however dma_unmap_single
is using cdns_ctrl->dev, which is incorrect.
Used the correct device context dma_dev->dev for dma_unmap_single.

Fixes: ec4ba01e894d ("mtd: rawnand: Add new Cadence NAND driver to MTD subsystem")
Cc: stable@vger.kernel.org
Signed-off-by: Niravkumar L Rabara <niravkumar.l.rabara@intel.com>
---
 drivers/mtd/nand/raw/cadence-nand-controller.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/raw/cadence-nand-controller.c b/drivers/mtd/nand/raw/cadence-nand-controller.c
index 8281151cf869..2d50eeb902ac 100644
--- a/drivers/mtd/nand/raw/cadence-nand-controller.c
+++ b/drivers/mtd/nand/raw/cadence-nand-controller.c
@@ -1863,12 +1863,12 @@ static int cadence_nand_slave_dma_transfer(struct cdns_nand_ctrl *cdns_ctrl,
 	dma_async_issue_pending(cdns_ctrl->dmac);
 	wait_for_completion(&finished);
 
-	dma_unmap_single(cdns_ctrl->dev, buf_dma, len, dir);
+	dma_unmap_single(dma_dev->dev, buf_dma, len, dir);
 
 	return 0;
 
 err_unmap:
-	dma_unmap_single(cdns_ctrl->dev, buf_dma, len, dir);
+	dma_unmap_single(dma_dev->dev, buf_dma, len, dir);
 
 err:
 	dev_dbg(cdns_ctrl->dev, "Fall back to CPU I/O\n");
-- 
2.25.1
Re: [PATCH v2 3/3] mtd: rawnand: cadence: fix incorrect dev context in dma_unmap_single
Posted by Miquel Raynal 2 weeks, 1 day ago
Hello,

On 16/01/2025 at 11:21:54 +08, niravkumar.l.rabara@intel.com wrote:

> From: Niravkumar L Rabara <niravkumar.l.rabara@intel.com>
>
> dma_map_single is using dma_dev->dev, however dma_unmap_single
> is using cdns_ctrl->dev, which is incorrect.
> Used the correct device context dma_dev->dev for dma_unmap_single.

I guess on is the physical/bus device and the other the framework
device? It would be nice to clarify this in the commit log.

> Fixes: ec4ba01e894d ("mtd: rawnand: Add new Cadence NAND driver to MTD subsystem")
> Cc: stable@vger.kernel.org
> Signed-off-by: Niravkumar L Rabara <niravkumar.l.rabara@intel.com>

Thanks,
Miquèl
RE: [PATCH v2 3/3] mtd: rawnand: cadence: fix incorrect dev context in dma_unmap_single
Posted by Rabara, Niravkumar L 1 week ago
Hi Miquel,

> -----Original Message-----
> From: Miquel Raynal <miquel.raynal@bootlin.com>
> Sent: Tuesday, 21 January, 2025 5:55 PM
> To: Rabara, Niravkumar L <niravkumar.l.rabara@intel.com>
> Cc: Richard Weinberger <richard@nod.at>; Vignesh Raghavendra
> <vigneshr@ti.com>; linux@treblig.org; Shen Lichuan
> <shenlichuan@vivo.com>; Jinjie Ruan <ruanjinjie@huawei.com>; u.kleine-
> koenig@baylibre.com; linux-mtd@lists.infradead.org; linux-
> kernel@vger.kernel.org; stable@vger.kernel.org
> Subject: Re: [PATCH v2 3/3] mtd: rawnand: cadence: fix incorrect dev context
> in dma_unmap_single
> 
> Hello,
> 
> On 16/01/2025 at 11:21:54 +08, niravkumar.l.rabara@intel.com wrote:
> 
> > From: Niravkumar L Rabara <niravkumar.l.rabara@intel.com>
> >
> > dma_map_single is using dma_dev->dev, however dma_unmap_single is
> > using cdns_ctrl->dev, which is incorrect.
> > Used the correct device context dma_dev->dev for dma_unmap_single.
> 
> I guess on is the physical/bus device and the other the framework device? It
> would be nice to clarify this in the commit log.
> 

Noted. Is the commit message below acceptable? 

dma_map_single is using physical/bus device (DMA) but dma_unmap_single
is using framework device(NAND controller), which is incorrect.
Fixed dma_unmap_single to use correct physical/bus device.

Thanks,
Nirav
Re: [PATCH v2 3/3] mtd: rawnand: cadence: fix incorrect dev context in dma_unmap_single
Posted by Miquel Raynal 1 week ago
Hello,

>> > dma_map_single is using dma_dev->dev, however dma_unmap_single is
>> > using cdns_ctrl->dev, which is incorrect.
>> > Used the correct device context dma_dev->dev for dma_unmap_single.
>> 
>> I guess on is the physical/bus device and the other the framework device? It
>> would be nice to clarify this in the commit log.
>> 
>
> Noted. Is the commit message below acceptable? 
>
> dma_map_single is using physical/bus device (DMA) but dma_unmap_single
> is using framework device(NAND controller), which is incorrect.
> Fixed dma_unmap_single to use correct physical/bus device.

Ok for me.

Thanks,
Miquèl