From: Boris Brezillon <boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
To: Jiancheng Xue <xuejiancheng-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
Cc: Marek Vasut <marex-ynQEQJNshbs@public.gmane.org>,
Brian Norris
<computersforpeace-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org,
juhosg-p3rKhJxN3npAfugRpC6u6w@public.gmane.org,
furquan-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org,
suwenping-C8/M+/jPZTeaMJb+Lgu22Q@public.gmane.org,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
yanhaifeng-C8/M+/jPZTeaMJb+Lgu22Q@public.gmane.org,
raojun-C8/M+/jPZTeaMJb+Lgu22Q@public.gmane.org,
xuejiancheng-C8/M+/jPZTeaMJb+Lgu22Q@public.gmane.org,
ml.yang-C8/M+/jPZTeaMJb+Lgu22Q@public.gmane.org,
gaofei-C8/M+/jPZTeaMJb+Lgu22Q@public.gmane.org,
yanghongwei-C8/M+/jPZTeaMJb+Lgu22Q@public.gmane.org,
zhangzhenxing-C8/M+/jPZTeaMJb+Lgu22Q@public.gmane.org,
jalen.hsu-C8/M+/jPZTeaMJb+Lgu22Q@public.gmane.org,
Russell King - ARM Linux
<linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org>
Subject: Re: [RESEND PATCH v9] mtd: spi-nor: add hisilicon spi-nor flash controller driver
Date: Tue, 12 Apr 2016 11:44:33 +0200 [thread overview]
Message-ID: <20160412114433.069b388e@bbrezillon> (raw)
In-Reply-To: <570CC098.9070606-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
+Russell
Hi Jiancheng,
On Tue, 12 Apr 2016 17:32:08 +0800
Jiancheng Xue <xuejiancheng-hv44wF8Li93QT0dZR+AlfA@public.gmane.org> wrote:
> Hi Marek,
>
> On 2016/4/12 3:21, Marek Vasut wrote:
> > On 04/11/2016 03:28 AM, Jiancheng Xue wrote:
> >> Hi,
> >>
> >> On 2016/4/8 18:04, Marek Vasut wrote:
> >>> On 04/08/2016 10:26 AM, Jiancheng Xue wrote:
> >>>> Hi,
> >>>>
> >>>> On 2016/4/7 10:28, Marek Vasut wrote:
> >>>>> On 04/07/2016 04:10 AM, Jiancheng Xue wrote:
> >>>>>> Hi Brian,
> >>>>>> Thank you very much for your comments. I'll fix these issues in next version.
> >>>>>> In addition, for easy understanding I'd like to rewrite hisi_spi_nor_write and
> >>>>>> hisi_spi_nor_read. Your comments on these modifications will be highly appreciated.
> >>>>>
> >>>>> Would you please stop top-posting ? It rubs some people the wrong way.
> >>>>>
> >>>> I feel very sorry about that. I have read the etiquette and won't make the same mistake again.
> >>>>
> >>>>>> static int hisi_spi_nor_read(struct spi_nor *nor, loff_t from, size_t len,
> >>>>>> size_t *retlen, u_char *read_buf)
> >>>>>> {
> >>>>>> struct hifmc_priv *priv = nor->priv;
> >>>>>> struct hifmc_host *host = priv->host;
> >>>>>> int i;
> >>>>>>
> >>>>>> /* read all bytes in only one time */
> >>>>>> if (len <= HIFMC_DMA_MAX_LEN) {
> >>>>>> hisi_spi_nor_dma_transfer(nor, from, host->dma_buffer,
> >>>>>> len, FMC_OP_READ);
> >>>>>> memcpy(read_buf, host->buffer, len);
> >>>>>
> >>>>> Is all the ad-hoc memcpying necessary? I think you can use
> >>>>> dma_map_single() and co to obtain DMAble memory for your
> >>>>> controller's use and then you can probably get rid of most
> >>>>> of this stuff.
> >>>>>
> >>>> Considering read_buf >= high_mem case, I think it is also complicated to use dma_map_*
> >>>> and the DMA buffer allocated by the driver is still needed. But I am not sure about
> >>>> this. Please let me know if I am wrong. Thank you!
> >>>
> >>> Does your controller/DMA have a limitation where it's buffers must be in
> >>> the bottom 4GiB range ? The DMA framework should be able to take care of
> >>> such platform limitations.
> >>>
> >> When read_buf is allocated by vmalloc, the underlying physical memory may be not contiguous.
> >> In this case, dma_map_single can't be used directly. I think inner DMA buffer and memcpy are still
> >> needed. Am I right?
> >
> > Take a look at drivers/spi/spi-mxs.c , look for "vmalloc" , does that
> > solution help you in any way ?
> >
> No. I think this solution just processes the buffer within only one page.
> I had referred to drivers/mtd/onenand/samsung.c and other files.
> The corresponding code segment is as follows:
> static int s5pc110_read_bufferram(struct mtd_info *mtd, int area,
> unsigned char *buffer, int offset, size_t count)
> {
> void *buf = (void *) buffer;
> dma_addr_t dma_src, dma_dst;
> ...
> /* Handle vmalloc address */
> if (buf >= high_memory) {
> struct page *page;
>
> if (((size_t) buf & PAGE_MASK) !=
> ((size_t) (buf + count - 1) & PAGE_MASK))
> goto normal;
> page = vmalloc_to_page(buf);
> if (!page)
> goto normal;
>
> ...
> } else {
> ...
> }
>
> normal:
> ...
> memcpy(buffer, p, count);
>
> return 0;
> }
> I think memcpy in "normal" clause can't be removed. So I'd like to keep my original
> implementation if it is also OK. What's your opinion?
You might want to have a look at this series [1], and particularly at
Russell's answers regarding DMA operations on non-lowmem memory.
Best Regards,
Boris
[1]http://thread.gmane.org/gmane.linux.kernel.mm/149015
--
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2016-04-12 9:44 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-26 8:11 [RESEND PATCH v9] mtd: spi-nor: add hisilicon spi-nor flash controller driver Jiancheng Xue
2016-03-27 1:47 ` Marek Vasut
2016-03-28 9:15 ` Jiancheng Xue
[not found] ` <56F8F630.5050008-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2016-04-04 6:44 ` Brian Norris
2016-04-07 2:10 ` Jiancheng Xue
[not found] ` <5705C17F.9030904-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2016-04-07 2:28 ` Marek Vasut
[not found] ` <5705C5E2.6070206-ynQEQJNshbs@public.gmane.org>
2016-04-08 8:26 ` Jiancheng Xue
2016-04-08 10:04 ` Marek Vasut
[not found] ` <5707821F.4020300-ynQEQJNshbs@public.gmane.org>
2016-04-11 1:28 ` Jiancheng Xue
[not found] ` <570AFDAF.9050607-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2016-04-11 19:21 ` Marek Vasut
[not found] ` <570BF933.2000607-ynQEQJNshbs@public.gmane.org>
2016-04-12 9:32 ` Jiancheng Xue
[not found] ` <570CC098.9070606-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2016-04-12 9:44 ` Boris Brezillon [this message]
2016-04-13 9:24 ` Jiancheng Xue
[not found] ` <1458979861-3619-1-git-send-email-xuejiancheng-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2016-03-31 7:24 ` Jiancheng Xue
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=20160412114433.069b388e@bbrezillon \
--to=boris.brezillon-wi1+55scjutkeb57/3fjtnbpr1lh4cv8@public.gmane.org \
--cc=computersforpeace-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org \
--cc=furquan-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
--cc=gaofei-C8/M+/jPZTeaMJb+Lgu22Q@public.gmane.org \
--cc=jalen.hsu-C8/M+/jPZTeaMJb+Lgu22Q@public.gmane.org \
--cc=juhosg-p3rKhJxN3npAfugRpC6u6w@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org \
--cc=linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=marex-ynQEQJNshbs@public.gmane.org \
--cc=ml.yang-C8/M+/jPZTeaMJb+Lgu22Q@public.gmane.org \
--cc=raojun-C8/M+/jPZTeaMJb+Lgu22Q@public.gmane.org \
--cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=suwenping-C8/M+/jPZTeaMJb+Lgu22Q@public.gmane.org \
--cc=xuejiancheng-C8/M+/jPZTeaMJb+Lgu22Q@public.gmane.org \
--cc=xuejiancheng-hv44wF8Li93QT0dZR+AlfA@public.gmane.org \
--cc=yanghongwei-C8/M+/jPZTeaMJb+Lgu22Q@public.gmane.org \
--cc=yanhaifeng-C8/M+/jPZTeaMJb+Lgu22Q@public.gmane.org \
--cc=zhangzhenxing-C8/M+/jPZTeaMJb+Lgu22Q@public.gmane.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).