]> git.ipfire.org Git - thirdparty/linux.git/commit
mtd: spi-nor: debugfs: Add locking support
authorMiquel Raynal <miquel.raynal@bootlin.com>
Tue, 26 May 2026 14:56:42 +0000 (16:56 +0200)
committerPratyush Yadav <pratyush@kernel.org>
Tue, 26 May 2026 15:21:05 +0000 (17:21 +0200)
commit47eb01f46e2d0741e058006dafa1fdbbbccf9b15
treed7427981edf45c82e48ba157a63c77359874fca9
parentb7b63475903cc9967ae53c579bc1ad9ed2519080
mtd: spi-nor: debugfs: Add locking support

The ioctl output may be counter intuitive in some cases. Asking for a
"locked status" over a region that is only partially locked will return
"unlocked" whereas in practice maybe the biggest part is actually
locked.

Knowing what is the real software locking state through debugfs would be
very convenient for development/debugging purposes, hence this proposal
for adding an extra block at the end of the file: a "locked sectors"
array which lists every section, if it is locked or not, showing both
the address ranges and the sizes in numbers of "lock sectors" (which on
small density devices is typically different than erase blocks).

Here is an example of output, what is after the "sector map" is new.

$ cat /sys/kernel/debug/spi-nor/spi0.0/params
name (null)
id ef a0 20 00 00 00
size 64.0 MiB
write size 1
page size 256
address nbytes 4
flags HAS_SR_TB | 4B_OPCODES | HAS_4BAIT | HAS_LOCK | HAS_16BIT_SR | HAS_SR_TB_BIT6 | HAS_4BIT_BP | SOFT_RESET | NO_WP

opcodes
 read 0xec
  dummy cycles 6
 erase 0xdc
 program 0x34
 8D extension none

protocols
 read 1S-4S-4S
 write 1S-1S-4S
 register 1S-1S-1S

erase commands
 21 (4.00 KiB) [1]
 dc (64.0 KiB) [3]
 c7 (64.0 MiB)

sector map
 region (in hex)   | erase mask | overlaid
 ------------------+------------+---------
 00000000-03ffffff |     [   3] | no

locked sectors
 region (in hex)   | status   | #sectors
 ------------------+----------+---------
 00000000-03ffffff | unlocked | 1024

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Pratyush Yadav <pratyush@kernel.org>
drivers/mtd/spi-nor/core.h
drivers/mtd/spi-nor/debugfs.c
drivers/mtd/spi-nor/swp.c