All of lore.kernel.org
 help / color / mirror / Atom feed
From: Brian Norris <computersforpeace@gmail.com>
To: Jagan Teki <jteki@openedev.com>
Cc: "linux-mtd@lists.infradead.org" <linux-mtd@lists.infradead.org>,
	Marek Vasut <marex@denx.de>
Subject: Re: [PATCH 07/10] mtd: spi-nor: add mtd_is_locked() support
Date: Mon, 12 Oct 2015 09:49:21 -0700	[thread overview]
Message-ID: <20151012164921.GK107187@google.com> (raw)
In-Reply-To: <CAD6G_RSNEgg4s8pmUk0tEywOpNB1eD5kLXfyOv9=WPjsUa-+bw@mail.gmail.com>

On Thu, Oct 01, 2015 at 02:30:40PM +0530, Jagan Teki wrote:
> On 2 September 2015 at 01:27, Brian Norris <computersforpeace@gmail.com> wrote:
> > This enables ioctl(MEMISLOCKED). Status can now be reported in the
> > mtdinfo or flash_lock utilities found in mtd-utils.
> >
> > Signed-off-by: Brian Norris <computersforpeace@gmail.com>
> > ---
> >  drivers/mtd/spi-nor/spi-nor.c | 37 ++++++++++++++++++++++++++++++++++++-
> >  include/linux/mtd/spi-nor.h   |  3 +++
> >  2 files changed, 39 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
> > index 62fa1b4ff3c0..c4fb1205f1d3 100644
> > --- a/drivers/mtd/spi-nor/spi-nor.c
> > +++ b/drivers/mtd/spi-nor/spi-nor.c
[...]
> > @@ -1151,11 +1184,13 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode)
> >         if (JEDEC_MFR(info) == SNOR_MFR_MICRON) {
> >                 nor->flash_lock = stm_lock;
> >                 nor->flash_unlock = stm_unlock;
> > +               nor->flash_is_locked = stm_is_locked;
> >         }
> >
> > -       if (nor->flash_lock && nor->flash_unlock) {
> > +       if (nor->flash_lock && nor->flash_unlock && nor->flash_is_locked) {
> >                 mtd->_lock = spi_nor_lock;
> >                 mtd->_unlock = spi_nor_unlock;
> > +               mtd->_is_locked = spi_nor_is_locked;
> 
> Need some understanding here, is this lock status call will be re-used
> at the time of _erase and _write calls for skipping locked area or
> sectors, if so how it re-used? Idea here is if user erase an area
> out-of which some part is locked and other unlocked the erase call
> should print the locked area and erase only unlocked area.

You can review the existing lock support in MTD to answer most of
this...

Currently, the lock APIs (mtd_lock(), mtd_unlock(), mtd_is_locked())
aren't automatically used for anything. They are mostly just supported
to provide an ioctl() interface, via MEMLOCK, MEMUNLOCK, MEMISLOCKED.
See mtdchar.c. These ioctls are supported in mtd-utils, so user programs
can handle the locking aspects on their own, if their system design
requires it. (e.g., this allows boot ROMs to be protected, while still
allowing unlock/reflash under specific circumstances.)

As it stands now, no one checks or reports errors if a block is locked
when the user tries to erase it. I guess it's up to the user to figure
that out right now.

I don't have a plan to change this right now, but if you had a good
proposal, then we could discuss. At first glance, I don't like the
suggestion to "print the locked area." That's not the right (primary)
way to report I/O errors. Anyway, that's all orthogonal to this patch.
The interface is already there; it's just not implemented in this
driver.

Brian

  reply	other threads:[~2015-10-12 16:49 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-01 19:57 [PATCH 00/10] mtd: spi-nor: cleanups + block protection support updates Brian Norris
2015-09-01 19:57 ` [PATCH 01/10] mtd: spi-nor: make implicit <linux/bitops.h> dependency explicit Brian Norris
2015-09-01 19:57 ` [PATCH 02/10] mtd: spi-nor: make bitfield constants more consistent Brian Norris
2015-09-01 19:57 ` [PATCH 03/10] mtd: spi-nor: add SPI NOR manufacturer IDs Brian Norris
2015-09-24 20:17   ` Jagan Teki
2015-09-28  0:46     ` Brian Norris
2015-09-28  9:12       ` Jagan Teki
2015-09-28 23:13         ` Brian Norris
2015-10-01  8:12           ` Jagan Teki
2015-10-01 18:43             ` Brian Norris
2015-09-01 19:57 ` [PATCH 04/10] mtd: spi-nor: use SNOR_MFR_* instead of CFI_MFR_* Brian Norris
2015-09-01 19:57 ` [PATCH 05/10] mtd: spi-nor: fixup kernel-doc for flash lock/unlock function pointers Brian Norris
2015-09-01 19:57 ` [PATCH 06/10] mtd: spi-nor: refactor block protection functions Brian Norris
2015-09-01 19:57 ` [PATCH 07/10] mtd: spi-nor: add mtd_is_locked() support Brian Norris
2015-09-02  9:01   ` Marek Vasut
2015-09-02 20:30     ` Brian Norris
2015-09-03  9:43       ` Marek Vasut
2015-09-03 20:29         ` Brian Norris
2015-10-01  9:00   ` Jagan Teki
2015-10-12 16:49     ` Brian Norris [this message]
2015-09-01 19:57 ` [PATCH 08/10] mtd: spi-nor: add DUAL_READ for w25q{32,64}dw Brian Norris
2015-09-01 19:57 ` [PATCH 09/10] mtd: spi-nor: support lock/unlock/is_locked for Winbond Brian Norris
2015-09-01 19:57 ` [PATCH 10/10] mtd: spi-nor: disable protection for Winbond flash at startup Brian Norris
2015-10-14  1:29 ` [PATCH 00/10] mtd: spi-nor: cleanups + block protection support updates Brian Norris

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=20151012164921.GK107187@google.com \
    --to=computersforpeace@gmail.com \
    --cc=jteki@openedev.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=marex@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.