All of lore.kernel.org
 help / color / mirror / Atom feed
From: Boris Brezillon <boris.brezillon@bootlin.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 3/4] mtd: Delete partitions attached to the device when a device is deleted
Date: Mon, 19 Nov 2018 12:57:51 +0100	[thread overview]
Message-ID: <20181119125751.44feb402@bbrezillon> (raw)
In-Reply-To: <0776b30a-fce7-010f-5903-0faf9bb0d0e2@denx.de>

On Mon, 19 Nov 2018 07:16:53 +0100
Heiko Schocher <hs@denx.de> wrote:

> Hello Boris,
> 
> Am 17.11.2018 um 10:19 schrieb Boris Brezillon:
> > On Fri, 16 Nov 2018 15:40:25 +0100
> > Boris Brezillon <boris.brezillon@bootlin.com> wrote:
> >   
> >> If we don't do that, partitions might still be exposed while the
> >> underlying device is gone.
> >>
> >> Fixes: 2a74930da57f ("mtd: mtdpart: implement proper partition handling")
> >> Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
> >> ---
> >>   drivers/mtd/mtdcore.c   |  1 +
> >>   include/linux/mtd/mtd.h | 14 ++++++++++++++
> >>   2 files changed, 15 insertions(+)
> >>
> >> diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
> >> index 7a15ded8c883..46657fe7c949 100644
> >> --- a/drivers/mtd/mtdcore.c
> >> +++ b/drivers/mtd/mtdcore.c
> >> @@ -528,6 +528,7 @@ int del_mtd_device(struct mtd_info *mtd)
> >>   	struct mtd_notifier *not;
> >>   #endif
> >>   
> >> +	del_mtd_partitions(mtd);
> >>   	mutex_lock(&mtd_table_mutex);
> >>   
> >>   	if (idr_find(&mtd_idr, mtd->index) != mtd) {
> >> diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
> >> index d20ebd820289..c5b58dd3f0f7 100644
> >> --- a/include/linux/mtd/mtd.h
> >> +++ b/include/linux/mtd/mtd.h
> >> @@ -562,8 +562,22 @@ unsigned mtd_mmap_capabilities(struct mtd_info *mtd);
> >>   /* drivers/mtd/mtdcore.h */
> >>   int add_mtd_device(struct mtd_info *mtd);
> >>   int del_mtd_device(struct mtd_info *mtd);
> >> +
> >> +#ifdef CONFIG_MTD_PARTITIONS
> >>   int add_mtd_partitions(struct mtd_info *, const struct mtd_partition *, int);
> >>   int del_mtd_partitions(struct mtd_info *);
> >> +#else
> >> +static inline int add_mtd_partitions(struct mtd_info *,
> >> +				     const struct mtd_partition *, int)  
> > 
> > Args should have names.
> >   
> >> +{
> >> +	return 0;
> >> +}
> >> +
> >> +static int del_mtd_partitions(struct mtd_info *)  
> > 
> > Missing inline here.
> > 
> > I'll send a v2 fixing those 2 bugs.  
> 
> Thanks!
> 
> I tried your patchset, with them "ubi part ubi" does now work, also
> after a "sf probe" ...
> 
> There is one problem, see log [1].
> 
> If you have an ubi partition attached (In my example on the NAND),
> and issue "sf probe", the following "mtd list" shows not anymore
> the SPI NOR MTD partitions. (It prints an error message
> "Partition "ubi" already in use, aborting")
> 
> If I detach UBI from the NAND MTD partition, the MTD Partitions on
> the SPI NOR are again found after a "sf probe" before "mtd list" [2]

I sent you a new version of this patchset that should address your
issue. Note that updating parts on a device that is being used is still
forbidden, but at least it does not block updates on other devices.

Oh, and I keep thinking the spi-flash code is broken, and none of this
should happen if the spi-nor MTD devs were staying around instead of
being unregistered/registered every time sf probe is called. But I
don't intend to fix it now, as the proper solution is probably to port
the spi-nor layer we have in Linux to u-boot.

  parent reply	other threads:[~2018-11-19 11:57 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-16 14:40 [U-Boot] [PATCH 1/4] mtd: Add a function to report when the MTD dev list has been updated Boris Brezillon
2018-11-16 14:40 ` [U-Boot] [PATCH 2/4] mtd: Parse mtdparts/mtdids again when the MTD " Boris Brezillon
2018-11-16 14:40 ` [U-Boot] [PATCH 3/4] mtd: Delete partitions attached to the device when a device is deleted Boris Brezillon
2018-11-17  9:19   ` Boris Brezillon
2018-11-19  6:16     ` Heiko Schocher
2018-11-19  9:25       ` Miquel Raynal
2018-11-19 11:57       ` Boris Brezillon [this message]
2018-11-19 12:10         ` Heiko Schocher
2018-11-16 14:40 ` [U-Boot] [PATCH 4/4] mtd: sf: Make sure we don't register the same device twice 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=20181119125751.44feb402@bbrezillon \
    --to=boris.brezillon@bootlin.com \
    --cc=u-boot@lists.denx.de \
    /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.