From: Artem Bityutskiy <dedekind1@gmail.com>
To: Christian Riesch <christian.riesch@omicron.at>
Cc: kyungmin.park@samsung.com, linux-mtd@lists.infradead.org
Subject: Re: [PATCH] mtd: mtdchar: Exit write loop when hitting end of OTP memory
Date: Mon, 03 Jun 2013 12:39:38 +0300 [thread overview]
Message-ID: <1370252378.21714.28.camel@sauron.fi.intel.com> (raw)
In-Reply-To: <51A6103B.7010201@omicron.at>
On Wed, 2013-05-29 at 16:27 +0200, Christian Riesch wrote:
> [cc'ed the author of onenand otp support]
>
> On 2013-05-29 15:56, Artem Bityutskiy wrote:
> > On Wed, 2013-05-29 at 15:19 +0200, Christian Riesch wrote:
> >> The OTP code for the AMD command set in my recent patchset is modeled
> >> after the existing code in drivers/mtd/chips/cfi_cmdset_0001.c.
> >> Therefore it has a ...walk() function that walks from chip to chip and
> >> tries to write as much data as possible into the OTP memories of these
> >> chips. Until the last iteration of this loop it does not know how much
> >> OTP memory is available. Therefore, a check for insufficient OTP memory
> >> and returning an error before writing any data is not possible.
> >>
> >> Of course I could change my code to obtain the available OTP memory
> >> before writing any data. But then the code in cfi_cmdset_0001.c would
> >> still suffer from this issue.
> >
> > Could you please check OneNAND and other drivers which implement OTP and
> > see whether they check for space availability?
>
> mtd->_write_user_prot_reg is currently implemented by
> drivers/mtd/chips/cfi_cmdset_0001.c, drivers/mtd/onenand/onenand_base.c,
> and drivers/mtd/devices/mtd_dataflash.c.
>
> mtd_dataflash checks if the offset is larger than 64 and returns -EINVAL
> in this case. If offset <= 64, but offset + len > 64, len is decreased
> to fit into the OTP memory, the number of actually written bytes is
> returned. It therefore suffers from the same issue in mtdchar.c as the
> Intel command set.
>
> onenand seems to do some kind of length check (although I do not fully
> understand why it does not include the offset in 'from' in this check if
> the factory OTP is addressed), but if the data does not fit into the
> memory it returns 0 instead of an error code, resulting in an infinite
> loop as well.
Would you be able to harmonize the implementations and switch them all
to the interface which is consistent with normal read/write, i.e., has
the retlen parameter?
--
Best Regards,
Artem Bityutskiy
prev parent reply other threads:[~2013-06-03 9:36 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-26 17:56 [PATCH] mtd: mtdchar: Exit write loop when hitting end of OTP memory Christian Riesch
2013-05-29 7:08 ` Artem Bityutskiy
2013-05-29 13:19 ` Christian Riesch
2013-05-29 13:56 ` Artem Bityutskiy
2013-05-29 14:27 ` Christian Riesch
2013-06-03 9:39 ` Artem Bityutskiy [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=1370252378.21714.28.camel@sauron.fi.intel.com \
--to=dedekind1@gmail.com \
--cc=christian.riesch@omicron.at \
--cc=kyungmin.park@samsung.com \
--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