From: Sascha Hauer <s.hauer@pengutronix.de>
To: Artem Bityutskiy <dedekind1@gmail.com>
Cc: linux-mtd@lists.infradead.org,
boris.brezillon@free-electrons.com,
Richard Weinberger <richard@nod.at>
Subject: Re: [PATCH v2] UBI: only read necessary size when reading the VID header
Date: Tue, 28 Jun 2016 16:05:00 +0200 [thread overview]
Message-ID: <20160628140500.GN20657@pengutronix.de> (raw)
In-Reply-To: <1467118829.2456.40.camel@gmail.com>
On Tue, Jun 28, 2016 at 04:00:29PM +0300, Artem Bityutskiy wrote:
> On Tue, 2016-06-28 at 13:51 +0200, Sascha Hauer wrote:
> > When reading the vid hdr from the device UBI always reads a whole
> > page. Instead, read only the data we actually need and speed up
> > attachment of UBI devices by potentially making use of reading
> > subpages if the NAND driver supports it.
> >
> > Since the VID header may be at offset vid_hdr_shift in the page and
> > we can only read from the beginning of a page we have to add that
> > offset to the read size.
> >
> > Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> > ---
> >
> > change since v1:
> > - properly handle vid_hdr_shift != 0
> >
> > drivers/mtd/ubi/io.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c
> > index 10cf3b5..ff8cafe 100644
> > --- a/drivers/mtd/ubi/io.c
> > +++ b/drivers/mtd/ubi/io.c
> > @@ -1019,7 +1019,7 @@ int ubi_io_read_vid_hdr(struct ubi_device *ubi,
> > int pnum,
> >
> > p = (char *)vid_hdr - ubi->vid_hdr_shift;
> > read_err = ubi_io_read(ubi, p, pnum, ubi->vid_hdr_aloffset,
> > - ubi->vid_hdr_alsize);
> > + ubi->vid_hdr_shift + UBI_VID_HDR_SIZE);
>
> There are pages and subpages underneath. Let me use old sizes. Say,
> 2KiB pages, and 512KiB subpages.
>
> If the VID header is in the first subpage, the MTD level probably needs
> to read the entire subpage anyway, because of per-subpage ECC. This is
> why we give it a buffer of subpage size.
The gpmi NAND driver allows reading subpages (NAND_SUBPAGE_READ is set), but
it does not allow writing subpages (NAND_NO_SUBPAGE_WRITE is also set).
With this mtd->subpage_sft becomes 0 and ubi->hdrs_min_io_size becomes
the full page size.
UBI does not distinguish between the minimum read size and the minimum
write size. We could pass this information from mtd to UBI, then UBI
could make use of it.
>
> Now if you give it a buffer of smaller size, say, 256 bytes, MTD will
> have to read the subpage into its own buffer first, validate ECC, then
> copy 256 bytes from the internal buffer to your buffer. Compare this
> with MTD copying data directly to your buffer.
BTW ubi_io_read_ec_hdr() also reads non subpage aligned sizes when
reading the EC header, so at least this function has the right default
for my setup ;)
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
next prev parent reply other threads:[~2016-06-28 14:05 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-28 11:51 [PATCH v2] UBI: only read necessary size when reading the VID header Sascha Hauer
2016-06-28 12:05 ` Richard Weinberger
2016-06-28 13:00 ` Artem Bityutskiy
2016-06-28 13:32 ` Richard Weinberger
2016-06-28 14:05 ` Sascha Hauer [this message]
2016-06-28 14:54 ` Artem Bityutskiy
2016-06-28 17:46 ` Brian Norris
2016-07-04 13:52 ` Boris Brezillon
2016-06-28 17:49 ` Brian Norris
2016-06-29 3:51 ` Artem Bityutskiy
2016-06-28 17:43 ` Brian Norris
2016-06-29 3:49 ` Artem Bityutskiy
2016-07-04 9:38 ` Boris Brezillon
2016-07-04 22:24 ` Richard Weinberger
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=20160628140500.GN20657@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=boris.brezillon@free-electrons.com \
--cc=dedekind1@gmail.com \
--cc=linux-mtd@lists.infradead.org \
--cc=richard@nod.at \
/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).