All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marek Vasut <marek.vasut@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] NAND: Allow per-buffer allocation
Date: Wed, 10 Aug 2011 01:15:19 +0200	[thread overview]
Message-ID: <201108100115.19953.marek.vasut@gmail.com> (raw)
In-Reply-To: <4E41B6A9.1030701@freescale.com>

On Wednesday, August 10, 2011 12:37:29 AM Scott Wood wrote:
> On 08/09/2011 04:54 PM, Marek Vasut wrote:
> > Don't allocate NAND buffers as one block, but allocate them separately.
> > This allows systems where DMA to buffers happen to allocate these
> > buffers properly aligned.
> > 
> > Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
> 
> That second sentence is hard to parse -- I think you mean something
> like, "This accommodates drivers which DMA to the buffers and have
> alignment constraints."

Yes, something like that. Sorry, it's 1.14 PM here.

> 
> Will a similar change be needed in Linux?

I'm not sure how much in sync we are with linux here. It'd be worth looking at.

> 
> >  int nand_scan_tail(struct mtd_info *mtd)
> >  {
> > 
> > -	int i;
> > +	int i, bufsize;
> > +	uint8_t *buf;
> > 
> >  	struct nand_chip *chip = mtd->priv;
> > 
> > -	if (!(chip->options & NAND_OWN_BUFFERS))
> > -		chip->buffers = kmalloc(sizeof(*chip->buffers), GFP_KERNEL);
> > -	if (!chip->buffers)
> > +	if (!(chip->options & NAND_OWN_BUFFERS)) {
> > +		chip->buffers = malloc(sizeof(struct nand_buffers));
> > +		if (!chip->buffers)
> > +			return -ENOMEM;
> 
> Why does the struct itself need to be dynamically allocated?

That was in the NOTE: ... to avoid breaking drivers. We can have that changed, 
but that'd be much more intrussive.
> 
> > +
> > +		bufsize = NAND_MAX_PAGESIZE + (3 * NAND_MAX_OOBSIZE);
> > +		buf = malloc(bufsize);
> > +
> > +		chip->buffers->buffer = (struct nand_buffers *)buf;
> > +		chip->buffers->ecccalc = buf;
> > +		chip->buffers->ecccode = buf + NAND_MAX_OOBSIZE;
> > +		chip->buffers->databuf = buf + (2 * NAND_MAX_OOBSIZE);
> > +	}
> > +
> > +	if (!chip->buffers->buffer)
> > 
> >  		return -ENOMEM;
> 
> What does "buffer" mean now?  What would a driver that supplies its own
> completely separate ecccalc/ecccode/databuf buffers put in "buffer"?

Maybe that condition should go also into the if() statement above. What do you 
think ?

> 
> -Scott

      reply	other threads:[~2011-08-09 23:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-09 21:54 [U-Boot] [PATCH] NAND: Allow per-buffer allocation Marek Vasut
2011-08-09 22:37 ` Scott Wood
2011-08-09 23:15   ` Marek Vasut [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=201108100115.19953.marek.vasut@gmail.com \
    --to=marek.vasut@gmail.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.