All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ladislav Michl <ladis@linux-mips.org>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: mtd_peb_write broken on dataflash
Date: Fri, 21 Sep 2018 11:46:36 +0200	[thread overview]
Message-ID: <20180921094636.GA9954@lenoch> (raw)
In-Reply-To: <20180921071111.GW4097@pengutronix.de>

On Fri, Sep 21, 2018 at 09:11:11AM +0200, Sascha Hauer wrote:
> Hi Ladis,
> 
> On Thu, Sep 20, 2018 at 08:27:01PM +0200, Ladislav Michl wrote:
> > As mtd_peb_write checks for alignment, it fails writing to dataflash:
> > barebox$ state -s
> > ERROR: state: Failed to write PEB 0, -22
> > ERROR: state: Failed to write circular to 0 length 48, -22
> > WARNING: state: Failed to write state backend bucket, -22
> > ERROR: state: Failed to write PEB 1, -22
> > ERROR: state: Failed to write circular to 0 length 48, -22
> > WARNING: state: Failed to write state backend bucket, -22
> > ERROR: state: Failed to write PEB 2, -22
> > ERROR: state: Failed to write circular to 0 length 48, -22
> 
> How I read the code the length should be writesize aligned...

It is perfectly valid to write less to dataflash... But see bellow.

> > diff --git a/drivers/mtd/peb.c b/drivers/mtd/peb.c
> > index c35b63f2f..6035fbc45 100644
> > --- a/drivers/mtd/peb.c
> > +++ b/drivers/mtd/peb.c
> > @@ -376,7 +376,7 @@ int mtd_peb_write(struct mtd_info *mtd, const void *buf, int pnum, int offset,
> >  		return -EINVAL;
> >  	if (len <= 0)
> >  		return -EINVAL;
> > -	if (len % (mtd->writesize >> mtd->subpage_sft))
> > +	if (mtd->type != MTD_DATAFLASH && len % (mtd->writesize >> mtd->subpage_sft))
> 
> So how big is mtd->writesize here and is this value correct?

Yes, it is correct:
dataflash@00: AT45DB041x (528 KBytes) pagesize 264 bytes (OTP)

> In state_storage_mtd_buckets_init() we have:
> 
>         if (circular)
>                 writesize = meminfo->writesize;
>         else
>                 writesize = meminfo->erasesize;
> 
> How big are meminfo->writesize and meminfo->erasesize here and
> which path is chosen?

writesize: 264
erasesize: 264
subpage_sft: 0
circular: true

But later we are trying to write 48 bytes:
dataflash0.barebox-state: write 48 bytes to PEB 0:0

	ladis

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

      reply	other threads:[~2018-09-21  9:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-20 18:27 mtd_peb_write broken on dataflash Ladislav Michl
2018-09-21  7:11 ` Sascha Hauer
2018-09-21  9:46   ` Ladislav Michl [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=20180921094636.GA9954@lenoch \
    --to=ladis@linux-mips.org \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@pengutronix.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.