From: Boris Brezillon <boris.brezillon@free-electrons.com>
To: David Woodhouse <dwmw2@infradead.org>,
Brian Norris <computersforpeace@gmail.com>,
Boris Brezillon <boris.brezillon@free-electrons.com>,
Marek Vasut <marek.vasut@gmail.com>,
Richard Weinberger <richard@nod.at>,
Cyrille Pitchen <cyrille.pitchen@wedev4u.fr>,
linux-mtd@lists.infradead.org
Cc: Robert Jarzmik <robert.jarzmik@free.fr>,
Kyungmin Park <kyungmin.park@samsung.com>,
Peter Pan <peterpansjtu@gmail.com>,
Frieder Schrempf <frieder.schrempf@exceet.de>,
Ladislav Michl <ladis@linux-mips.org>
Subject: Re: [PATCH v3 3/4] mtd: Stop directly calling master ->_xxx() hooks from mtdpart code
Date: Mon, 8 Jan 2018 21:46:56 +0100 [thread overview]
Message-ID: <20180108214656.35f26b27@bbrezillon> (raw)
In-Reply-To: <20171215123954.30017-4-boris.brezillon@free-electrons.com>
+Ladislav
On Fri, 15 Dec 2017 13:39:53 +0100
Boris Brezillon <boris.brezillon@free-electrons.com> wrote:
> The MTD layer provides several wrappers around mtd->_xxx() hooks. Call
> these wrappers instead of directly dereferencing the associated ->_xxx()
> pointer.
>
> This change has been motivated by another rework letting the core
> handle the case where ->_read/write_oob() are implemented but not
> ->_read/write(). In this case, we want mtd_read/write() to fall back to
> ->_read/write_oob() when ->_read/write() are NULL. The problem is,
> mtdpart is directly calling the ->_xxx() instead of using the wrappers,
> thus leading to a NULL pointer exception.
>
> Even though we only need to do the change for part_read/write(), going
> through those wrappers for all kind of part -> master operation
> propagation is a good thing, because other wrappers might become
> smarter over time, and the duplicated check overhead (parameters will
> be checked at the partition and master level instead of only at the
> partition level) should be negligible.
>
> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> ---
> Changes in v3:
> - unconditionally assign part wrappers as suggested by Brian
>
> Changes in v2:
> - new patch needed to fix a NULL pointer dereference BUG
> ---
> drivers/mtd/mtdpart.c | 141 +++++++++++++++++++-------------------------------
> 1 file changed, 53 insertions(+), 88 deletions(-)
>
> diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
> index be088bccd593..e83c9d870b11 100644
> --- a/drivers/mtd/mtdpart.c
> +++ b/drivers/mtd/mtdpart.c
> @@ -74,8 +74,7 @@ static int part_read(struct mtd_info *mtd, loff_t from, size_t len,
> int res;
>
> stats = part->parent->ecc_stats;
> - res = part->parent->_read(part->parent, from + part->offset, len,
> - retlen, buf);
> + res = mtd_read(part->parent, from + part->offset, len, retlen, buf);
This change introduced a regression (reported by Ladislav) because
mtd_read() does not return the number of bitflips and instead returns 0
if we are below ->bitflips_threshold and -EUCLEAN if we're equal
or above. That's a problem in 2 situations:
1/ when ->bitflips_threshold is customized for a specific partition,
the custom value is ignored in favor of the one set on the master MTD
device
2/ when PARTITIONED_MASTER is not defined, ->bitflip_threshold is not
initialized (->bitflip_threshold = 0), thus triggering -EUCLEAN
every time we read a page
I fear this patch might introduce other subtle regression so I plan to
drop it entirely.
Regards,
Boris
> if (unlikely(mtd_is_eccerr(res)))
> mtd->ecc_stats.failed +=
> part->parent->ecc_stats.failed - stats.failed;
next prev parent reply other threads:[~2018-01-08 20:47 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-15 12:39 [PATCH v3 0/4] mtd: Preparation patches for the SPI NAND framework Boris Brezillon
2017-12-15 12:39 ` [PATCH v3 1/4] mtd: Do not allow MTD devices with inconsistent erase properties Boris Brezillon
2017-12-15 12:39 ` [PATCH v3 2/4] mtd: Add an helper to make erase request aligned on ->erasesize Boris Brezillon
2017-12-15 12:39 ` [PATCH v3 3/4] mtd: Stop directly calling master ->_xxx() hooks from mtdpart code Boris Brezillon
2017-12-22 5:40 ` Peter Pan
2017-12-22 8:37 ` Boris Brezillon
2018-01-04 2:06 ` Peter Pan
2018-01-08 20:46 ` Boris Brezillon [this message]
2017-12-15 12:39 ` [PATCH v3 4/4] mtd: Fallback to ->_read/write_oob() when ->_read/write() is missing Boris Brezillon
2018-01-08 21:11 ` Boris Brezillon
2017-12-17 21:39 ` [PATCH v3 0/4] mtd: Preparation patches for the SPI NAND framework Miquel RAYNAL
2018-01-06 20:43 ` Boris Brezillon
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=20180108214656.35f26b27@bbrezillon \
--to=boris.brezillon@free-electrons.com \
--cc=computersforpeace@gmail.com \
--cc=cyrille.pitchen@wedev4u.fr \
--cc=dwmw2@infradead.org \
--cc=frieder.schrempf@exceet.de \
--cc=kyungmin.park@samsung.com \
--cc=ladis@linux-mips.org \
--cc=linux-mtd@lists.infradead.org \
--cc=marek.vasut@gmail.com \
--cc=peterpansjtu@gmail.com \
--cc=richard@nod.at \
--cc=robert.jarzmik@free.fr \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.