devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Hui-Ping Chen <hpchen0nvt@gmail.com>
Cc: richard@nod.at, vigneshr@ti.com, robh@kernel.org,
	krzk+dt@kernel.org, conor+dt@kernel.org,
	nikita.shubin@maquefel.me, arnd@arndb.de, vkoul@kernel.org,
	esben@geanix.com, linux-arm-kernel@lists.infradead.org,
	linux-mtd@lists.infradead.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v6 2/2] mtd: rawnand: nuvoton: add new driver for the Nuvoton MA35 SoC
Date: Wed, 9 Oct 2024 10:04:50 +0200	[thread overview]
Message-ID: <20241009100450.362e3556@xps-13> (raw)
In-Reply-To: <02098767-19ce-407e-88be-24c6259c4053@gmail.com>

Hi Hui-Ping,

> >>>> +		return 0;
> >>>> +	}
> >>>> +
> >>>> +	ma35_nand_dmac_init(nand);
> >>>> +
> >>>> +	writel(mtd->oobsize, nand->regs + MA35_NFI_REG_NANDRACTL);
> >>>> +
> >>>> +	/* setup and start DMA using dma_addr */
> >>>> +	dma_addr = dma_map_single(nand->dev, (void *)addr, len, DMA_FROM_DEVICE);
> >>>> +	ret = dma_mapping_error(nand->dev, dma_addr);
> >>>> +	if (ret) {
> >>>> +		dev_err(nand->dev, "dma mapping error\n");
> >>>> +		return -EINVAL;
> >>>> +	}
> >>>> +
> >>>> +	writel((unsigned long)dma_addr, nand->regs + MA35_NFI_REG_DMASA);  
> >>> Please enforce a dma mask of 32 (even though it might be the fault).  
> >> I will change it to dma_addr & 0xffffffff.  
> > That's not what I mean, I believe you should use the dma API to ask for
> > a mapping within the accessible 32-bit address range. The
> > dma_mapping_error() check should return an error if that's not the
> > case. Then you can safely write the value.  
> 
> Here is my misunderstanding: just fill in the dma_addr directly,
> 
> no type conversion is needed. I have already tested it.

FYI, it only works because the default DMA mask for your device is gonna
be 32 bits. If the reality (what your peripheral DMA can do) was
different than this, you would have to set a different mask explicitly
to make sure the dma-mapping step would not provide buffers which are
out of reach.

Thanks,
Miquèl

  reply	other threads:[~2024-10-09  8:04 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-27  2:07 [PATCH v6 0/2] Add support for nuvoton ma35 nand controller Hui-Ping Chen
2024-09-27  2:07 ` [PATCH v6 1/2] dt-bindings: mtd: nuvoton,ma35d1-nand: add new bindings Hui-Ping Chen
2024-10-01 10:19   ` Miquel Raynal
2024-10-08  2:30     ` Hui-Ping Chen
2024-09-27  2:07 ` [PATCH v6 2/2] mtd: rawnand: nuvoton: add new driver for the Nuvoton MA35 SoC Hui-Ping Chen
2024-10-01 19:57   ` Miquel Raynal
2024-10-08  3:19     ` Hui-Ping Chen
2024-10-08  8:52       ` Miquel Raynal
2024-10-09  0:55         ` Hui-Ping Chen
2024-10-09  8:04           ` Miquel Raynal [this message]
2024-10-11  0:31             ` Hui-Ping Chen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241009100450.362e3556@xps-13 \
    --to=miquel.raynal@bootlin.com \
    --cc=arnd@arndb.de \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=esben@geanix.com \
    --cc=hpchen0nvt@gmail.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=nikita.shubin@maquefel.me \
    --cc=richard@nod.at \
    --cc=robh@kernel.org \
    --cc=vigneshr@ti.com \
    --cc=vkoul@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).