public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: <Takahiro.Kuwano@infineon.com>
Cc: <pratyush@kernel.org>,  <mwalle@kernel.org>,  <richard@nod.at>,
	<vigneshr@ti.com>,  <corbet@lwn.net>,  <tudor.ambarus@linaro.org>,
	<sean.anderson@linux.dev>,  <thomas.petazzoni@bootlin.com>,
	<STLin2@winbond.com>,  <linux-mtd@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>,  <linux-doc@vger.kernel.org>
Subject: Re: [PATCH v3 17/27] mtd: spi-nor: debugfs: Add locking support
Date: Fri, 03 Apr 2026 18:06:33 +0200	[thread overview]
Message-ID: <87a4vk58qe.fsf@bootlin.com> (raw)
In-Reply-To: <ee2057a104d44d3dbfbedcf5b1ed80b2@infineon.com> (Takahiro Kuwano's message of "Thu, 2 Apr 2026 05:40:55 +0000")

Hi Takahiro,

>> +u64 spi_nor_get_min_prot_length_sr(struct spi_nor *nor);
>> +void spi_nor_get_locked_range_sr(struct spi_nor *nor, const u8 *sr, loff_t *ofs, u64 *len);
>> +bool spi_nor_is_locked_sr(struct spi_nor *nor, loff_t ofs, u64 len, const u8 *sr);
>> +
>
> It would be better to have generic helper functions rather than using SR-based
> functions directly. The locking_ops is vendor/chip specific and can provide
> other locking mechanism than SR-based block protection. For instance, Infineon,
> Micron, Macronix (and maybe other vendors) offer protection mechanisms that can
> protect sectors individually with volatile or non-volatile manner.

I get what you mean, thanks for pointing this out. Unfortunately it's
not that straightforward.

As of today, there are the "default" locking ops (SR based) and a few
others, chip specific. For debugging purposes, these "other" ops do not
provide any kind of useful feedback regarding what has actually been
locked. Only SR based chips provide this, it is useful, I want to use it.

So I'm going to expose a new boolean to filter out whether we have
locking support *and* if yes, whether we can use SR based functions, this
should also address this concern:

> Don't we need to check 'SNOR_F_HAS_LOCK' flag here?

We will still need to expose the SR specific helpers, though, but at
least we will no longer get inconsistencies with chips not featuring the
default SR approach.

>> +       seq_puts(s, "\nlocked sectors\n");
>> +       seq_puts(s, " region (in hex)   | status   | #blocks\n");
>> +       seq_puts(s, " ------------------+----------+--------\n");
>> +
>> +       spi_nor_get_locked_range_sr(nor, nor->dfs_sr_cache, &lock_start, &lock_length);
>> +       if (!lock_length || lock_length == params->size) {
>> +               seq_printf(s, " %08llx-%08llx | %s | %llu\n", 0ULL, params->size - 1,
>> +                          lock_length ? "  locked" : "unlocked", params->size / min_prot_len);
>
> div_u64() is needed. 
> I got undefined reference to `__aeabi_uldivmod' for my 32-bit ARM platform.
> Same for following four seq_printf().

Good catch, I will fix this too.

Thanks,
Miquèl

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

  reply	other threads:[~2026-04-03 16:06 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-17 10:24 [PATCH v3 00/27] mtd: spi-nor: Enhance software protection Miquel Raynal
2026-03-17 10:24 ` [PATCH v3 01/27] mtd: spi-nor: Drop duplicate Kconfig dependency Miquel Raynal
2026-03-17 10:24 ` [PATCH v3 02/27] mtd: spi-nor: debugfs: Fix the flags list Miquel Raynal
2026-03-17 10:24 ` [PATCH v3 03/27] mtd: spi-nor: swp: Improve locking user experience Miquel Raynal
2026-03-17 10:24 ` [PATCH v3 04/27] mtd: spi-nor: Improve opcodes documentation Miquel Raynal
2026-03-17 10:24 ` [PATCH v3 05/27] mtd: spi-nor: debugfs: Align variable access with the rest of the file Miquel Raynal
2026-03-17 10:24 ` [PATCH v3 06/27] mtd: spi-nor: debugfs: Enhance output Miquel Raynal
2026-03-17 10:24 ` [PATCH v3 07/27] mtd: spi-nor: swp: Explain the MEMLOCK ioctl implementation behaviour Miquel Raynal
2026-03-17 10:24 ` [PATCH v3 08/27] mtd: spi-nor: swp: Clarify a comment Miquel Raynal
2026-03-17 10:24 ` [PATCH v3 09/27] mtd: spi-nor: swp: Use a pointer for SR instead of a single byte Miquel Raynal
2026-03-17 10:24 ` [PATCH v3 10/27] mtd: spi-nor: swp: Create a helper that writes SR, CR and checks Miquel Raynal
2026-03-17 10:24 ` [PATCH v3 11/27] mtd: spi-nor: swp: Rename a mask Miquel Raynal
2026-03-17 10:24 ` [PATCH v3 12/27] mtd: spi-nor: swp: Create a TB intermediate variable Miquel Raynal
2026-03-17 10:24 ` [PATCH v3 13/27] mtd: spi-nor: swp: Create helpers for building the SR register Miquel Raynal
2026-03-17 10:24 ` [PATCH v3 14/27] mtd: spi-nor: swp: Simplify checking the locked/unlocked range Miquel Raynal
2026-03-17 10:24 ` [PATCH v3 15/27] mtd: spi-nor: swp: Cosmetic changes Miquel Raynal
2026-03-17 10:24 ` [PATCH v3 16/27] mtd: spi-nor: Create a local SR cache Miquel Raynal
2026-03-17 10:24 ` [PATCH v3 17/27] mtd: spi-nor: debugfs: Add locking support Miquel Raynal
2026-04-02  5:40   ` Takahiro.Kuwano
2026-04-03 16:06     ` Miquel Raynal [this message]
2026-03-17 10:24 ` [PATCH v3 18/27] mtd: spi-nor: debugfs: Add a locked sectors map Miquel Raynal
2026-03-17 10:24 ` [PATCH v3 19/27] mtd: spi-nor: Add steps for testing locking support Miquel Raynal
2026-03-17 10:24 ` [PATCH v3 20/27] mtd: spi-nor: swp: Add support for the complement feature Miquel Raynal
2026-03-17 10:24 ` [PATCH v3 21/27] mtd: spi-nor: Add steps for testing locking with CMP Miquel Raynal
2026-03-17 10:24 ` [PATCH v3 22/27] mtd: spi-nor: winbond: Add W25H512NWxxAM CMP locking support Miquel Raynal
2026-03-17 10:24 ` [PATCH v3 23/27] mtd: spi-nor: winbond: Add W25H01NWxxAM " Miquel Raynal
2026-03-17 10:24 ` [PATCH v3 24/27] mtd: spi-nor: winbond: Add W25H02NWxxAM " Miquel Raynal
2026-03-17 10:24 ` [PATCH v3 25/27] mtd: spi-nor: winbond: Add W25H01NWxxIQ " Miquel Raynal
2026-03-17 10:24 ` [PATCH v3 26/27] mtd: spi-nor: winbond: Add W25Q01NWxxIM " Miquel Raynal
2026-03-17 10:24 ` [PATCH v3 27/27] mtd: spi-nor: winbond: Add W25Q02NWxxIM " Miquel Raynal

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=87a4vk58qe.fsf@bootlin.com \
    --to=miquel.raynal@bootlin.com \
    --cc=STLin2@winbond.com \
    --cc=Takahiro.Kuwano@infineon.com \
    --cc=corbet@lwn.net \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=mwalle@kernel.org \
    --cc=pratyush@kernel.org \
    --cc=richard@nod.at \
    --cc=sean.anderson@linux.dev \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=tudor.ambarus@linaro.org \
    --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