2021-05-03 18:13:39

by Michael Walle

[permalink] [raw]
Subject: [PATCH v4 0/2] mtd: spi-nor: support dumping sfdp tables

Add the possibility to dump the SFDP data of a flash device.

More and more flash devices share the same flash ID and we need per device
fixups. Usually, these fixups differentiate flashes by looking at
differences in the SFDP data. Determining the difference is only possible
if we have the SFDP data for all the flashes which share a flash ID. This
will lay the foundation to dump the whole SFDP data of a flash device.

This is even more important, because some datasheets doesn't even contain
the SFDP data. Fixups for these kind of flashes are nearly impossible to
do.

I envision having a database of all the SFDP data for the flashes we
support and make it a requirement to submit it when a new flash is added.
This might or might not have legal implications. Thus I'd start with having
that database private to the SPI NOR maintainers.

Changes since v3:
- move spi-nor attributes into spi-nor/ subdirectory, suggested by
Alexander Williams.

Changes since v2:
- use .dev_groups of the driver to attach the attributes
- add manufacturer attribute
- rename attribute name to partname
- add ABI documentation

Changes since v1:
- use sysfs_emit()
- add comment about the allocation of the sfdp dwords
- free SFDP memory in the error path
- use BIN_ATTR_RO(sfdp, 0)
- use spi_nor_read_sfdp()

Changes since RFC:
- Don't read SFDP data after probe. The flash might already be switched to
8D-8D-8D mode. Instead, cache the SFDP data
- add two sysfs files: jedec-id and name
- change the file mode of the sfdp file from 0400 to 0444. There is no
hardware access anymore.


Michael Walle (2):
mtd: spi-nor: sfdp: save a copy of the SFDP data
mtd: spi-nor: add initial sysfs support

.../ABI/testing/sysfs-bus-spi-devices-spi-nor | 31 +++++++
drivers/mtd/spi-nor/Makefile | 2 +-
drivers/mtd/spi-nor/core.c | 1 +
drivers/mtd/spi-nor/core.h | 12 +++
drivers/mtd/spi-nor/sfdp.c | 58 ++++++++++++
drivers/mtd/spi-nor/sysfs.c | 93 +++++++++++++++++++
include/linux/mtd/spi-nor.h | 2 +
7 files changed, 198 insertions(+), 1 deletion(-)
create mode 100644 Documentation/ABI/testing/sysfs-bus-spi-devices-spi-nor
create mode 100644 drivers/mtd/spi-nor/sysfs.c

--
2.20.1


2021-06-18 17:45:46

by Vignesh Raghavendra

[permalink] [raw]
Subject: Re: [PATCH v4 0/2] mtd: spi-nor: support dumping sfdp tables

On Mon, 3 May 2021 17:56:49 +0200, Michael Walle wrote:
> Add the possibility to dump the SFDP data of a flash device.
>
> More and more flash devices share the same flash ID and we need per device
> fixups. Usually, these fixups differentiate flashes by looking at
> differences in the SFDP data. Determining the difference is only possible
> if we have the SFDP data for all the flashes which share a flash ID. This
> will lay the foundation to dump the whole SFDP data of a flash device.
>
> [...]

Applied to spi-nor/next, thanks!
[1/2] mtd: spi-nor: sfdp: save a copy of the SFDP data
https://git.kernel.org/mtd/c/65b6d89d45
[2/2] mtd: spi-nor: add initial sysfs support
https://git.kernel.org/mtd/c/36ac022862

--
Regards
Vignesh