public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Richard Purdie <rpurdie@rpsys.net>
To: kmpark@infradead.org
Cc: 'linux-mtd' <linux-mtd@lists.infradead.org>,
	'David Woodhouse' <dwmw2@infradead.org>
Subject: RE: [RFC PATCH 3/3] Add panic_write function to the onenand driver
Date: Thu, 31 Jan 2008 10:03:34 +0000	[thread overview]
Message-ID: <1201773814.4996.9.camel@localhost.localdomain> (raw)
In-Reply-To: <003e01c863ad$ce6ef790$1fa9580a@swcenter.sec.samsung.co.kr>

On Thu, 2008-01-31 at 11:05 +0900, Kyungmin Park wrote:
> > +static void onenand_panic_wait(struct mtd_info *mtd)
> > +{
> > +	struct onenand_chip *this = mtd->priv;
> > +	unsigned int interrupt;
> > +	int i;
> > +
> > +	for (i = 0; i < 20; i++) {
> > +		interrupt = this->read_word(this->base + ONENAND_REG_INTERRUPT);
> > +		if (interrupt & ONENAND_INT_MASTER)
> > +			break;
> > +		udelay(1000);
> > +	}
> > +}
> 
> Umm it's waiting with maximum 20msec. how about the increase the index to 20*1000 and use udelay(1).
> If we use the busy-waiting, it uses the max 3msec in case of erase.

I'm ok with changing it to use udelay(10). This function is going to be
rarely called so efficiency isn't a primary concern... 

> Anyway I think you don't use the onenand_wait since it has
> cond_resched(). It's better to use the existing function in case of
> panic_write.
> Okay try to think what's the better way.

Yes, I'm avoiding onenand_wait since we can't schedule in this context.
Other ideas welcome :)

> > + */
> > +static int onenand_panic_write(struct mtd_info *mtd, loff_t to, size_t len,
> > +			 size_t *retlen, const u_char *buf)
> > +{
> > +	struct onenand_chip *this = mtd->priv;
> > +	int column, subpage;
> > +	int written = 0;
> > +	int ret = 0;
> > +
> > +	if (this->state == FL_PM_SUSPENDED)
> > +		return -EBUSY;
> > +
> > +	/* Wait for any existing operation to clear */
> > +	onenand_panic_wait(mtd);
> 
> Reasonable!
> 
> > +
> > +		this->write_bufferram(mtd, ONENAND_DATARAM, wbuf, 0, mtd->writesize);
> > +		this->write_bufferram(mtd, ONENAND_SPARERAM, ffchars, 0, mtd->oobsize);
> > +
> > +		this->command(mtd, ONENAND_CMD_PROG, to, mtd->writesize);
> > +
> > +		onenand_panic_wait(mtd);
> 
> It has to check the return value and update the bufferram. If not, we can read the wrong data later.

The key point with panic_write is there is unlikely to be any "later". I
don't mind putting the bufferram update calls back if you're happier
with that though.

Cheers,

Richard

      reply	other threads:[~2008-01-31 10:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-29 11:59 [RFC PATCH 3/3] Add panic_write function to the onenand driver Richard Purdie
2008-01-31  2:05 ` Kyungmin Park
2008-01-31 10:03   ` Richard Purdie [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=1201773814.4996.9.camel@localhost.localdomain \
    --to=rpurdie@rpsys.net \
    --cc=dwmw2@infradead.org \
    --cc=kmpark@infradead.org \
    --cc=linux-mtd@lists.infradead.org \
    /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