From: Jan Kiszka <jan.kiszka@siemens.com>
To: Michael Walle <michael@walle.cc>
Cc: Tom Rini <trini@konsulko.com>,
Jagan Teki <jagan@amarulasolutions.com>,
<chaochao2021666@163.com>, <Tudor.Ambarus@microchip.com>,
<vigneshr@ti.com>, <baocheng.su@siemens.com>,
<le.jin@siemens.com>, <u-boot@lists.denx.de>,
"chao zeng" <chao.zeng@siemens.com>
Subject: Re: [PATCH v4] sf: Query write-protection status before operating the flash
Date: Wed, 2 Feb 2022 10:57:00 +0100 [thread overview]
Message-ID: <b0ef084d-8548-5dec-2a12-35ef45bfcb3f@siemens.com> (raw)
In-Reply-To: <1f466f11-6c3b-d1ce-800c-a171482abd2b@siemens.com>
On 02.02.22 10:38, Jan Kiszka wrote:
> On 02.02.22 09:21, Michael Walle wrote:
>> Am 2022-02-02 07:35, schrieb Jan Kiszka:
>>> From: Jan Kiszka <jan.kiszka@siemens.com>
>>>
>>> Do not suggest successful operation if a flash area to be changed is
>>> actually locked, thus will not execute the request. Rather report an
>>> error and bail out. That's way more user-friendly than asking them to
>>> manually check for this case.
>>>
>>> Derived from original patch by Chao Zeng.
>>>
>>> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
>>> ---
>>>
>>> This is the successor of "[PATCH V3] sf: Querying write-protect status
>>> before operating the flash", moving the test into the CLI API, see
>>> https://lore.kernel.org/u-boot/20220117175628.GQ2631111@bill-the-cat/.
>>>
>>> cmd/sf.c | 12 ++++++++++++
>>> 1 file changed, 12 insertions(+)
>>>
>>> diff --git a/cmd/sf.c b/cmd/sf.c
>>> index 8bdebd9fd8f..a24e04c690b 100644
>>> --- a/cmd/sf.c
>>> +++ b/cmd/sf.c
>>> @@ -287,6 +287,12 @@ static int do_spi_flash_read_write(int argc, char
>>> *const argv[])
>>> return 1;
>>> }
>>>
>>> + if (strncmp(argv[0], "read", 4) != 0 && flash->flash_is_locked &&
>>> + flash->flash_is_locked(flash, offset, len)) {
>>> + printf("ERROR: flash area is locked\n");
>>> + return 1;
>>> + }
>>
>> Much better to handle it here. But I'm not sure if this is doing
>> the right thing:
>>
>> Eventually, this function is called:
>>
>> /*
>> * Return 1 if the entire region is locked (if @locked is true) or
>> unlocked (if
>> * @locked is false); 0 otherwise
>> */
>> static int stm_check_lock_status_sr(struct spi_nor *nor, loff_t ofs, u64
>> len,
>> u8 sr, bool locked)
>>
>> So I'd guess if you try to write to an area of the flash where only parts
>> are locked, you still see it as unlocked and thus there will be no error.
>> Which IMHO is even more confusing for a user.
>
> I suppose this is why the original patch was placed way more down the
> call chain... Back to square #1? Or can/should we split the request into
> blocks?
Hmm, no, the other versions should have had the same problem.
What about also exposing a "is_unlocked" service? Seems that would have
the semantic we need, and there is at least already stm_is_unlocked_sr.
But no sst26_is_unlocked.
Jan
--
Siemens AG, Technology
Competence Center Embedded Linux
next prev parent reply other threads:[~2022-02-02 9:57 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-02 6:35 [PATCH v4] sf: Query write-protection status before operating the flash Jan Kiszka
2022-02-02 8:21 ` Michael Walle
2022-02-02 9:38 ` Jan Kiszka
2022-02-02 9:55 ` Michael Walle
2022-02-02 9:57 ` Jan Kiszka [this message]
2022-02-04 12:55 ` Jan Kiszka
2022-02-07 12:43 ` Michael Walle
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=b0ef084d-8548-5dec-2a12-35ef45bfcb3f@siemens.com \
--to=jan.kiszka@siemens.com \
--cc=Tudor.Ambarus@microchip.com \
--cc=baocheng.su@siemens.com \
--cc=chao.zeng@siemens.com \
--cc=chaochao2021666@163.com \
--cc=jagan@amarulasolutions.com \
--cc=le.jin@siemens.com \
--cc=michael@walle.cc \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
--cc=vigneshr@ti.com \
/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