From: Andrew Gabbasov <andrew_gabbasov-nmGgyN9QBj3QT0dZR+AlfA@public.gmane.org>
To: 'Mark Brown' <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: <linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: RE: [PATCH] spi: Fix per-page mapping of unaligned vmalloc-ed buffer
Date: Tue, 30 Jun 2015 18:37:07 +0300 [thread overview]
Message-ID: <000601d0b34a$9fa42170$deec6450$@mentor.com> (raw)
In-Reply-To: <20150626114622.GW14071-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
Hi Mark,
> -----Original Message-----
> From: Mark Brown [mailto:broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org]
> Sent: Friday, June 26, 2015 2:46 PM
> To: Gabbasov, Andrew
> Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> Subject: Re: [PATCH] spi: Fix per-page mapping of unaligned vmalloc-ed
buffer
>
> On Thu, Jun 25, 2015 at 11:40:15AM -0500, Andrew Gabbasov wrote:
> > spi_map_buf() processes mapping of vmalloc-ed buffers in a special
> > way, making mapping of every page separately. However, if the buffer
> > is not aligned to page boundary (e.g. sub-array in a vmalloc-ed
> > array), it fills the scatter table with page-size unaligned pieces,
> > that cross page boundaries. This is incorrect and can, for example,
> > cause memory corruption and various crashes when working with ubifs on
spi-
> nor chips.
>
> The caller is supposed to be providing us with aligned memory here.
> However it could be helpful to do this so...
Well, actually the rest of spi code does not rely on having a transfer
buffer
page-aligned. And I don't see any reason to make such an assumption here.
Especially that it is not fulfilled, at least by ubifs code.
Anyway, this fix seems to be useful indeed.
> > - const int sgs = DIV_ROUND_UP(len, desc_len);
> > + const int sgs = DIV_ROUND_UP(vmalloced_buf ?
> > + len + offset_in_page(buf) : len,
> > + desc_len);
>
> No, please write this legibly without the ternery operator.
OK, I'll try to make this piece of code more distinct.
I'm submitting v2 of the patch.
Thanks.
Best regards,
Andrew
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" 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:[~2015-06-30 15:37 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-25 16:40 [PATCH] spi: Fix per-page mapping of unaligned vmalloc-ed buffer Andrew Gabbasov
[not found] ` <1435250415-9147-1-git-send-email-andrew_gabbasov-nmGgyN9QBj3QT0dZR+AlfA@public.gmane.org>
2015-06-26 11:46 ` Mark Brown
[not found] ` <20150626114622.GW14071-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2015-06-30 15:37 ` Andrew Gabbasov [this message]
2015-06-30 16:02 ` Mark Brown
[not found] ` <20150630160237.GR11162-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2015-06-30 16:21 ` Andrew Gabbasov
-- strict thread matches above, loose matches on Subject: below --
2015-06-25 16:08 Andrew Gabbasov
2015-06-15 6:59 Andrew Gabbasov
[not found] ` <1434351560-29463-1-git-send-email-andrew_gabbasov-nmGgyN9QBj3QT0dZR+AlfA@public.gmane.org>
2015-06-25 11:27 ` Andrew Gabbasov
2015-06-25 14:00 ` Mark Brown
[not found] ` <20150625140054.GM14071-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2015-06-25 15:57 ` Gabbasov, Andrew
[not found] ` <6C5EA58090A5ED459815C4D04C2B466FF82082B4-Codg+kbhZ4/nlEkxMdpx1dQH9K4/4qFeAL8bYrjMMd8@public.gmane.org>
2015-06-25 16:12 ` Mark Brown
2015-06-01 10:14 Andrew Gabbasov
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='000601d0b34a$9fa42170$deec6450$@mentor.com' \
--to=andrew_gabbasov-nmggyn9qbj3qt0dzr+alfa@public.gmane.org \
--cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=linux-spi-u79uwXL29TY76Z2rM5mHXA@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).