Race-free NAND device removal

Boris Brezillon boris.brezillon at free-electrons.com
Mon Jul 4 05:02:26 PDT 2016


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

> On Mon, Jul 4, 2016 at 1:02 PM, Richard Weinberger <richard at 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/  
> 
> 
> 




More information about the linux-mtd mailing list