From: Michael Walle <michael@walle.cc>
To: Vignesh Raghavendra <vigneshr@ti.com>
Cc: Tudor Ambarus <tudor.ambarus@microchip.com>,
linux-mtd@lists.infradead.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
Miquel Raynal <miquel.raynal@bootlin.com>,
Richard Weinberger <richard@nod.at>,
Rob Herring <robh+dt@kernel.org>,
Mark Rutland <mark.rutland@arm.com>
Subject: Re: [PATCH 1/2] dt-bindings: mtd: spi-nor: document new flag
Date: Fri, 20 Dec 2019 13:46:40 +0100 [thread overview]
Message-ID: <09f5f76eb49a38c4b2960abe688b2892@walle.cc> (raw)
In-Reply-To: <2dfc30a7-3261-d783-8256-f72458a0141b@ti.com>
Hi Vignesh,
Am 2019-12-19 06:33, schrieb Vignesh Raghavendra:
> Hi Michael,
>
> [...]
>>>> +- no-unlock : By default, linux unlocks the whole flash because
>>>> there
>>>> + are legacy flash devices which are locked by default
>>>> + after reset. Set this flag if you don't want linux to
>>>> + unlock the whole flash automatically. In this case you
>>>> + can control the non-volatile bits by the
>>>> + flash_lock/flash_unlock tools.
>>>>
>>>
>>> Current SPI NOR framework unconditionally unlocks entire flash which
>>> I agree is not the best thing to do, but I don't think we need
>>> new DT property here. MTD cmdline partitions and DT partitions
>>> already
>>> provide a way to specify that a partition should remain locked[1][2]
>>
>> I know that the MTD layer has the same kind of unlocking. But that
>> unlocking is done on a per mtd partition basis. Eg. consider something
>> like the following
>>
>> mtd1 bootloader (locked)
>> mtd2 firmware (locked)
>> mtd3 kernel
>> mtd4 environment
>>
>> Further assume, that the end of mtd2 aligns with one of the possible
>> locking areas which are supported by the flash chip. Eg. the first
>> quarter.
>>
>> The mtd layer would do two (or four, if "lock" property is set)
>> unlock()
>> calls, one for mtd1 and one for mtd2.
>>
>
>
>> My point here is, that the mtd partitions doesn't always map to the
>> locking regions of the SPI flash (at least if the are not merged
>> together).
>>
>
> You are right! This will be an issue if existing partitions are not
> aligned to locking regions.
>
> I take my comments back... But I am not sure if a new DT property is
> the
> needed. This does not describe HW and is specific to Linux SPI NOR
> stack. How about a module parameter instead?
> Module parameter won't provide per flash granularity in controlling
> unlocking behavior. But I don't think that matters.
I don't argue against having a kernel parameter, but just wanting to
point
out another alternative (which might be controversial):
- What is the purpose of this unlock_all() at all. Apparently there are
some flashes which have the protection bits set. Either at startup
(and then they are non-volatile) or they come in that state out of
the
factory. The latter makes little sense IMHO.
- Actually, all newer flashes we've used have these bits non-volatile
and
are unlocked by default.
So can't we have a whitelist (ie. a new flag in the spi_nor_ids) which
supresses the unlock if they haven't any block protections bit set
according to the manual? Because in this case the unlocking makes never
sense IMHO.
-michael
>
> Tudor,
>
> You had a patch doing something similar. Does module param sound good
> to
> you?
prev parent reply other threads:[~2019-12-20 12:46 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-14 19:19 [PATCH 1/2] dt-bindings: mtd: spi-nor: document new flag Michael Walle
2019-12-14 19:19 ` [PATCH 2/2] mtd: spi-nor: add option to keep lock bits Michael Walle
2019-12-16 8:54 ` [PATCH 1/2] dt-bindings: mtd: spi-nor: document new flag Vignesh Raghavendra
2019-12-16 10:29 ` Michael Walle
2019-12-19 5:33 ` Vignesh Raghavendra
2019-12-20 12:46 ` Michael Walle [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=09f5f76eb49a38c4b2960abe688b2892@walle.cc \
--to=michael@walle.cc \
--cc=devicetree@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=mark.rutland@arm.com \
--cc=miquel.raynal@bootlin.com \
--cc=richard@nod.at \
--cc=robh+dt@kernel.org \
--cc=tudor.ambarus@microchip.com \
--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;
as well as URLs for NNTP newsgroup(s).