public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Boris Brezillon <bbrezillon@kernel.org>
Cc: Tudor Ambarus <Tudor.Ambarus@microchip.com>,
	Richard Weinberger <richard@nod.at>,
	Marek Vasut <marek.vasut@gmail.com>,
	linux-mtd@lists.infradead.org,
	Brian Norris <computersforpeace@gmail.com>,
	David Woodhouse <dwmw2@infradead.org>
Subject: Re: [PATCH v2] mtd: rework partitions handling
Date: Tue, 22 Jan 2019 12:37:02 +0100	[thread overview]
Message-ID: <20190122123702.384736ac@xps13> (raw)
In-Reply-To: <20190121095120.5d7850cb@bbrezillon>

Hi Boris,

Boris Brezillon <bbrezillon@kernel.org> wrote on Mon, 21 Jan 2019
09:51:20 +0100:

> On Wed, 16 Jan 2019 17:21:44 +0100
> Miquel Raynal <miquel.raynal@bootlin.com> wrote:
> 
> > @@ -457,13 +525,31 @@ int mtd_block_markbad(struct mtd_info *mtd, loff_t ofs);
> >  
> >  static inline int mtd_suspend(struct mtd_info *mtd)
> >  {
> > -	return mtd->_suspend ? mtd->_suspend(mtd) : 0;
> > +	struct mtd_info *master = mtd_get_master(mtd);
> > +	int ret;
> > +
> > +	if (master->suspended)
> > +		return 0;
> > +
> > +	ret = master->_suspend ? master->_suspend(master) : 0;
> > +	if (ret)
> > +		return ret;
> > +
> > +	master->suspended = 1;  
> 
> It's not entirely clear to me whether dev->suspend() hooks can be
> called simultaneously on several CPUs or not, if that's the case, we
> should use an atomic_t for the ->suspended field and use the
> atomic_add_unless() function when manipulating it.
> 
> 	if (!atomic_add_unless(&master->suspended, 1, 1))
> 		return 0;
> 
> 	ret = master->_suspend ? master->_suspend(master) : 0;
> 	if (ret) {
> 		atomic_dec(&master->suspended);
> 		return ret;
> 	}
> 
> > +	return 0;
> >  }
> >  
> >  static inline void mtd_resume(struct mtd_info *mtd)
> >  {
> > -	if (mtd->_resume)
> > -		mtd->_resume(mtd);
> > +	struct mtd_info *master = mtd_get_master(mtd);
> > +
> > +	if (!master->suspended)
> > +		return;
> > +
> > +	if (master->_resume)
> > +		master->_resume(master);
> > +
> > +	master->suspended = 0;  
> 
> Same here:
> 
> 	if (!atomic_add_unless(&master->suspended, -1, 0))
> 		return;
> 
> 	if (master->_resume)
> 		master->_resume(master);
> >  }  

I don't know if this is necessary but I made the changes.

I also had to change "suspended" type from unsigned int bitfield to
atomic_t.


Thanks,
Miquèl

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

      reply	other threads:[~2019-01-22 11:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-16 16:21 [PATCH v2] mtd: rework partitions handling Miquel Raynal
2019-01-16 17:23 ` Boris Brezillon
2019-01-21  8:51 ` Boris Brezillon
2019-01-22 11:37   ` Miquel Raynal [this message]

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=20190122123702.384736ac@xps13 \
    --to=miquel.raynal@bootlin.com \
    --cc=Tudor.Ambarus@microchip.com \
    --cc=bbrezillon@kernel.org \
    --cc=computersforpeace@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=marek.vasut@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