linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Boris Brezillon <boris.brezillon@free-electrons.com>
To: Richard Weinberger <richard.weinberger@gmail.com>
Cc: Richard Weinberger <richard@nod.at>,
	Brian Norris <computersforpeace@gmail.com>,
	"linux-mtd@lists.infradead.org" <linux-mtd@lists.infradead.org>
Subject: Re: Race-free NAND device removal
Date: Mon, 4 Jul 2016 14:02:26 +0200	[thread overview]
Message-ID: <20160704140226.0646bd73@bbrezillon> (raw)
In-Reply-To: <CAFLxGvzOgisiSbvSSjWmbMvZ=tU180iMzdV2HZD_FShCvo9sgA@mail.gmail.com>

On Mon, 4 Jul 2016 13:11:09 +0200
Richard Weinberger <richard.weinberger@gmail.com> wrote:

> On Mon, Jul 4, 2016 at 1:02 PM, Richard Weinberger <richard@nod.at> wrote:
> > Am 04.07.2016 um 12:06 schrieb Boris Brezillon:  
> >>> $ nandsimctl --backend file /home/rw/work/XXX/broken_mtd.raw --id-bytes 0x....
> >>>
> >>> While getting this race free I found that issue.  
> >>
> >> Okay, so you modified nandsim code to check nand_release() return code,
> >> right? Maybe you can send this change in your nandsim rework series
> >> then.  
> >
> > Yep. My code checks the result of nand_release().
> > I'll carry it in my series.
> >
> > BTW: There is more fun:
> > When we look into mtdcore.c
> > int mtd_device_unregister(struct mtd_info *master)
> > {
> >         int err;
> >
> >         if (master->_reboot)
> >                 unregister_reboot_notifier(&master->reboot_notifier);
> >
> >         err = del_mtd_partitions(master);
> >         if (err)
> >                 return err;
> >
> >         if (!device_is_registered(&master->dev))
> >                 return 0;
> >
> >         return del_mtd_device(master);
> > }
> > EXPORT_SYMBOL_GPL(mtd_device_unregister);
> >
> > Either del_mtd_partitions() or del_mtd_device() will notice that the MTD usage count is > 0 and
> > return -EBUSY.
> > But at this stage we've already executed the reboot notifier. Bug or feature? ;-)  
> 
> Should be read removed the...

Probably a bug.

> 
> > I'm also not sure about the printk in del_mtd_device():
> >         if (mtd->usecount) {
> >                 printk(KERN_NOTICE "Removing MTD device #%d (%s) with use count %d\n",
> >                        mtd->index, mtd->name, mtd->usecount);
> >                 ret = -EBUSY;
> >         } else {
> >
> > Why do you have to warn the user? Is this 100% a legit use case or is the printk here to warn
> > that a driver is buggy?
> > At least with the existing UBI glubi driver you can hit this code path.
> > Same for the upcoming nandsim changes.
> >
> > Thanks,
> > //richard
> >
> > ______________________________________________________
> > Linux MTD discussion mailing list
> > http://lists.infradead.org/mailman/listinfo/linux-mtd/  
> 
> 
> 

  reply	other threads:[~2016-07-04 12:02 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-03 13:38 Race-free NAND device removal Richard Weinberger
2016-07-04  9:16 ` Boris Brezillon
2016-07-04  9:44   ` Richard Weinberger
2016-07-04 10:06     ` Boris Brezillon
2016-07-04 11:02       ` Richard Weinberger
2016-07-04 11:11         ` Richard Weinberger
2016-07-04 12:02           ` Boris Brezillon [this message]
2016-07-04 21:34   ` 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=20160704140226.0646bd73@bbrezillon \
    --to=boris.brezillon@free-electrons.com \
    --cc=computersforpeace@gmail.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=richard.weinberger@gmail.com \
    --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).