From: Gerlando Falauto <gerlando.falauto@keymile.com>
To: Austin Boyle <boyle.austin@gmail.com>,
Brian Norris <computersforpeace@gmail.com>
Cc: "linux-mtd@lists.infradead.org" <linux-mtd@lists.infradead.org>,
David Woodhouse <dwmw2@infradead.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Artem Bityutskiy <artem.bityutskiy@linux.intel.com>,
Marek Vasut <marex@denx.de>, Angus Clark <angus.clark@st.com>
Subject: Re: [PATCH] mtd: m25p80: Flash protection support for STmicro chips
Date: Mon, 10 Mar 2014 10:06:51 +0100 [thread overview]
Message-ID: <531D80AB.5010209@keymile.com> (raw)
In-Reply-To: <CADnxWiqfaaRoaL+B_WQxx38-gpSDmdFQPLN-bs-moGRECXeJxg@mail.gmail.com>
Hi Austin, Brian,
thank you for taking care of this.
On 03/08/2014 04:03 PM, Austin Boyle wrote:
[...]
>
> I don't think there is an issue with some bootloaders not supporting
> this feature, it is already optional.
What do you mean exactly by "it is optional"?
I agree with you that an explicit ioctl(MEMLOCK) is order for locking to
take place. However, this seems to be the default action for the u-boot
environment userspace tools. They will issue a MEMUNLOCK/MEMLOCK pair
when trying to write some changes to the environment, without even
checking the return value. This would of course fail silently when the
feature was not implemented (as it was the case before the original
patch was applied) and everything was working as expected.
Now linux supports this feature, and u-boot doesn't, so as soon as you
write something to the flash from userspace, it will be locked and
u-boot won't ever be able to write to it again.
In my opinion, we're breaking something here (call it userspace API or
otherwise). My suggestion would then be to make it an optional feature
to be explicitly enabled on the device tree, like Heicho did for CFI
flashes:
http://lists.infradead.org/pipermail/linux-mtd/2013-January/045536.html
Or I guess another way would be to implement the _is_locked() function,
so to have the userspace tools check the locking status before
unlocking, and only lock it again if was locked in the first place.
It wouldn't fix my issue right away (as the userspace tools don't
currenctly perform this check), but at least it would provide some way
out here without breaking compatibility with the existing u-boot.
> It is a good idea to add another flag for flash protection to be
> explicitly clear which devices support this. (I previously made the
> assumption that writing to those status bits when unused was harmless,
> from the datasheets I found they seem to be don't cares.)
Agreed.
> The following logic for calculating the block protect bits applies to
> the majority of the STmicro devices that support protection (m25p10,
> p20, p40, p80, p16, pe16, p32, p64, p128):
>
> SR_BPs| Protected (upper)| Unprotected (lower)
> =====================================================
> 0| 0/n| n - 0/n
> 1| 1/n| n - 1/n
> 2| 2/n| n - 2/n
> 3| 3/n| n - 4/n
> 4| 4/n| n - 8/n
> 5| 5/n| n - 16/n
> 6| 6/n| n - 32/n
> 7| 7/n| n - 64/n
Uhm, I believe it should read like this (unprotected portion is of
course "n - protected portion"):
SR BPs | Protected portion
---------------------------
0 | 0/n
1 | 1/n
2 | 2/n
3 | min(4,n)/n
4 | min(8,n)/n
5 | min(16,n)/n
6 | min(32,n)/n
7 | min(64,n)/n
Or at least that was my understanding.
> Where n is number of sectors if less than 64.
>
> Some special cases:
> - m25p64 has 128 sectors but only supports protection to 64 sector
> resolution.
> - m25p05 uses SR=1/2 for protect Block Erase, and SR=3 for protect Block
> Erase, Page Program, Sector Erase.
> - m25px32 has an additional bit for locking the lower sections.
>
> A patch with this implementation follows. Let me know what you think. I
> have a spreadsheet summarising the block protect bits for the STmicro
> devices I can share if it will help.
Could you please share this?
Thank you,
Gerlando
>
> Thanks,
> Austin.
next prev parent reply other threads:[~2014-03-10 9:07 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-04 0:02 [PATCH] mtd: m25p80: Flash protection support for STmicro chips Austin Boyle
2013-01-17 10:41 ` Artem Bityutskiy
2013-11-20 20:04 ` Gerlando Falauto
2014-02-27 14:34 ` Gerlando Falauto
2014-03-05 8:10 ` Brian Norris
2014-03-05 8:31 ` Brian Norris
2014-03-08 15:26 ` Austin Boyle
[not found] ` <CADnxWiqfaaRoaL+B_WQxx38-gpSDmdFQPLN-bs-moGRECXeJxg@mail.gmail.com>
2014-03-10 9:06 ` Gerlando Falauto [this message]
2014-03-13 12:57 ` Austin Boyle
2014-03-13 13:46 ` Gerlando Falauto
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=531D80AB.5010209@keymile.com \
--to=gerlando.falauto@keymile.com \
--cc=angus.clark@st.com \
--cc=artem.bityutskiy@linux.intel.com \
--cc=boyle.austin@gmail.com \
--cc=computersforpeace@gmail.com \
--cc=dwmw2@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox