linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Michael Walle <michael@walle.cc>
To: Vignesh Raghavendra <vigneshr@ti.com>
Cc: marex@denx.de, Tudor.Ambarus@microchip.com, richard@nod.at,
	linux-kernel@vger.kernel.org, boris.brezillon@collabora.com,
	linux-mtd@lists.infradead.org, miquel.raynal@bootlin.com
Subject: Re: [PATCH v2] mtd: spi-nor: keep lock bits if they are non-volatile
Date: Wed, 22 Jan 2020 13:44:44 +0100	[thread overview]
Message-ID: <e64cc3ac32d2b44c9e6f4b4f795354ae@walle.cc> (raw)
In-Reply-To: <990b9b16-36e5-ce73-36c7-0ebfa391c26b@ti.com>

Hi Vignesh,

Am 2020-01-22 13:10, schrieb Vignesh Raghavendra:
> On 22/01/20 12:23 am, Tudor.Ambarus@microchip.com wrote:
>> Hi, Michael, Vignesh,
>> 
>> On Sunday, January 12, 2020 12:50:57 AM EET Michael Walle wrote:
>>> EXTERNAL EMAIL: Do not click links or open attachments unless you 
>>> know the
>>> content is safe
> [...]
> 
>>>> I see three choices:
>>>> 1/ dt prop which gives a per flash granularity. The prop is related 
>>>> to
>>>> hw
>>>> protection and there might be some chances to get this accepted, 
>>>> maybe
>>>> it is
>>>> worth to involve Rob. But I tend to share Vignesh's opinion, this 
>>>> would
>>>> configure the flash and not describe it.
>>> 
>>> Still my preferred way. but also see below. But I wouldn't say it
>> 
>> Try to convince Rob.
>> 
>>> configures the
>>> flash but describe that the user want to use the write protection.
>>> 
>>>> 2/ kconfig option, the behavior would be enforced on all the 
>>>> flashes.
>>>> It would
>>>> be similar to what we have with CONFIG_MTD_SPI_NOR_USE_4K_SECTORS. I
>>>> did a
>>>> patch to address this some time ago:
>>>> https://patchwork.ozlabs.org/patch/
>>>> 1133278/
>>> 
>>> Mhh. If we would combine this with this patch that would be at least 
>>> a
>>> step into
>>> the right direction. At least a distro could enable that kernel 
>>> option
>>> without
>>> breaking old boards/flashes. Because as outlined about you need that 
>>> for
>>> flashes
>>> in category (2). Or you'd have to do a flash_unlock every time you 
>>> want
>>> to write
>>> to it. But that would be really a backwards incompatible change.. ;)
>>> 
>>>> 3/ module param, the behavior would be enforced on all the flashes.
>>>> 
>>>> Preferences or suggestions?
>>> 
>> I would go with 2/ or 3/. Vignesh, what do you prefer and why?
>> 
> 
> I dont like option 1, because I am not convinced that this is a HW
> description to be put in DT.  IIUC, problem is more of what to do with
> locking configuration that is done before Linux comes up(either in
> previous boot or by bootloader or POR default). Current code just
> discards it and unlocks entire flash.

But this is not the main problem. It is rather the intention of the
user to actually want write protect the flash (for flashes who has
proper support for them, that is the ones which have non-volatile
bits).

Flashes with volatile bits are another subject. Here it might be useful
to unlock them either at probe time or when we first write to them, so
the user doesn't need to know if its this kind of flash and he would
actually have to unlock the flash before writing. I've left the
behaviour for these flashes as it was before.

And yes, u-boot suffers from the same problem, eg. it unlocks the whole
flash too. I guess they inherited the behaviour from linux. But I
wanted to start with linux first.

> But proposal is not to touch those bits at probe time and leave this
> upto userspace to handle.

No, my proposal was to divide the flashes into two categories. The
unlocking is only done on the flashes which have volatile locking bits,
thus even when the new option is enabled it won't break access to these
flashes.

> Adding a Kconfig does not scale well for multi-platform builds. There
> would not be a way to have protection enabled on one platform but
> disabled on other. Does not scale for multiple flashes either
> 
> Option 3 sounds least bad among all. If module param can be designed to
> be a string then, we could control locking behavior to be per flash
> using flash name.

What about both? A kconfig option which defines the default for the
kernel parameter? My fear is that once it is a kernel parameter it is
easy to forget (thus having the non-volatile bits, the flash is
completely unlocked again) and it is not very handy; for proper write
protection you'd always have to have this parameter.

btw. I don't see a need to have this option per flash, because once
the user actually enables it, he is aware that its for all of his
flashes. I haven't seen flashes which has non-volatile protection bits
_and_ are protected by default. There shouldn't be a noticable
difference for the user if the option when enabled.

-michael

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

  reply	other threads:[~2020-01-22 12:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-03 22:12 [PATCH v2] mtd: spi-nor: keep lock bits if they are non-volatile Michael Walle
2020-01-11 13:46 ` Tudor.Ambarus
2020-01-11 22:50   ` Michael Walle
2020-01-21 18:53     ` Tudor.Ambarus
2020-01-22  6:58       ` Tudor.Ambarus
2020-01-22 12:10       ` Vignesh Raghavendra
2020-01-22 12:44         ` Michael Walle [this message]
2020-01-23 17:20           ` Vignesh Raghavendra
2020-03-27 14:41             ` 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=e64cc3ac32d2b44c9e6f4b4f795354ae@walle.cc \
    --to=michael@walle.cc \
    --cc=Tudor.Ambarus@microchip.com \
    --cc=boris.brezillon@collabora.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=marex@denx.de \
    --cc=miquel.raynal@bootlin.com \
    --cc=richard@nod.at \
    --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).