spi-nor: sfdp: Allow configuring unknown flashes using SFDP
Subsystems (3)
PATCH 1/1 spi-nor: sfdp: Allow configuring unknown flashes using SFDP
This change allows adding a support for flashes with correct SFDP without recompilation of the kernel by setting sfdp-compatible property in their node. Alternatively, sfdp_compatible module option can be used to list JEDEC IDs of flashes, whose SFDP can be trusted. Star "*" can be used to match all JEDEC IDs.
--- .../devicetree/bindings/mtd/jedec,spi-nor.txt | 3 + drivers/mtd/spi-nor/core.c | 86 +++++++++++-------- drivers/mtd/spi-nor/core.h | 4 + drivers/mtd/spi-nor/sfdp.c | 66 ++++++++++++++ drivers/mtd/spi-nor/sfdp.h | 2 + 5 files changed, 126 insertions(+), 35 deletions(-)
Documentation/devicetree/bindings/mtd/jedec,spi-nor.txt +3 -0
@@ -78,6 +78,9 @@ Optional properties: cannot reboot properly if the flash is left in the "wrong" state. This boolean flag can be used on such systems, to denote the absence of a reliable reset mechanism. +- sfdp-compatible : Trust information in SFDP and instantiate the device even if + its JEDEC ID isn't known to the driver. All the configuration + is read from SFDP and no workarounds are applied. Example:
drivers/mtd/spi-nor/core.c +51 -35
139 lines not on this page · raw message
drivers/mtd/spi-nor/core.h +4 -0
@@ -338,6 +338,10 @@ struct flash_info {* protection bits. Usually these will * power-up in a write-protected state. */ +#define SPI_NOR_SFDP_AUTODETECT BIT(23)/* +* Flashinfo was dynamically created and +* all parameters come from SFDP +*/ /* Part specific fixup hooks. */ const struct spi_nor_fixups *fixups;
drivers/mtd/spi-nor/sfdp.c +66 -0
75 lines not on this page · raw message
drivers/mtd/spi-nor/sfdp.h +2 -0
@@ -110,4 +110,6 @@ struct sfdp_parameter_header {int spi_nor_parse_sfdp (struct spi_nor *nor,struct spi_nor_flash_parameter *params); +struct flash_info *spi_nor_sfdp_generic_info (struct spi_nor *nor,const u8 *id); +#endif /* __LINUX_MTD_SFDP_H */
Signature · 6 lines
2.20.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Quoted 5 lines · Petr Malat
This change allows adding a support for flashes with correct SFDP without recompilation of the kernel by setting sfdp-compatible property in their node. Alternatively,
sfdp_compatiblemodule option can be used to list JEDEC IDs of flashes, whose SFDP can be trusted. Star "*" can be used to match all JEDEC IDs.
I have skimmed through the patch. Before I look at it more closely, I want to understand the use case for this patch. Why would you not want to recompile the kernel when adding support for new hardware? Do you want the ability to support flashes on devices that have already been deployed in the field? Is it something that comes up frequently?
Then comes the question of how do you get the flash to probe if it is not present in device tree? And if you are able to update the device tree then you should also be able to update the kernel.
Have you tested this with any flash? If so, with which one?
Quoted 4 lines
Signed-off-by Petr Malat <[email protected]>--- .../devicetree/bindings/mtd/jedec,spi-nor.txt | 3 +
This file has been converted to yaml since at least 5.12-rc1. Please update your kernel sources and rebase your patches.
Quoted 5 lines
drivers/mtd/spi-nor/core.c | 86 +++++++++++-------- drivers/mtd/spi-nor/core.h | 4 + drivers/mtd/spi-nor/sfdp.c | 66 ++++++++++++++ drivers/mtd/spi-nor/sfdp.h | 2 + 5 files changed, 126 insertions(+), 35 deletions(-)
Signature · 7 lines
Regards, Pratyush Yadav Texas Instruments Inc. ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Hi!
Quoted 7 lines · Pratyush Yadav
Quoted 5 lines · Petr Malat
This change allows adding a support for flashes with correct SFDP without recompilation of the kernel by setting sfdp-compatible property in their node. Alternatively,
sfdp_compatiblemodule option can be used to list JEDEC IDs of flashes, whose SFDP can be trusted. Star "*" can be used to match all JEDEC IDs.
Quoted 5 lines
I have skimmed through the patch. Before I look at it more closely, I want to understand the use case for this patch. Why would you not want to recompile the kernel when adding support for new hardware? Do you want the ability to support flashes on devices that have already been deployed in the field? Is it something that comes up frequently?
In my case the kernel is loaded from a USB mass storage device, which can be preproduced and on stock (with the kernel already on it). With my patch I can change the flash vendor without the need of updating the image on already existing USB mass storage devices.
The patch is also useful for people who use distribution kernel as they will not have to wait until (and if) the distribution updates it.
Quoted 3 lines
Then comes the question of how do you get the flash to probe if it is not present in device tree? And if you are able to update the device tree then you should also be able to update the kernel.
If one sets sfdp-compatible flag in the device tree and replaces one flash with another, he doesn't need to update the device tree. It extends what is already possible now - if I make "jedec,spi-nor" node and the JEDEC ID is known to the driver I can replace the flash with a different one whose JEDEC ID is known as well and it will work without touching the device tree.
Quoted 1 line
Have you tested this with any flash? If so, with which one?
I have tested it with n25q128a11 by removing it from the driver.
Quoted 7 lines
Quoted 4 lines
Signed-off-by Petr Malat <[email protected]>--- .../devicetree/bindings/mtd/jedec,spi-nor.txt | 3 +This file has been converted to yaml since at least 5.12-rc1. Please update your kernel sources and rebase your patches.
OK, I will rebase.
Petr
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Vignesh Raghavendra
maintainerQuoted 14 lines · Petr Malat
Hi!
Quoted 7 lines · Pratyush Yadav
Quoted 5 lines · Petr Malat
This change allows adding a support for flashes with correct SFDP without recompilation of the kernel by setting sfdp-compatible property in their node. Alternatively,
sfdp_compatiblemodule option can be used to list JEDEC IDs of flashes, whose SFDP can be trusted. Star "*" can be used to match all JEDEC IDs.Quoted 5 lines
I have skimmed through the patch. Before I look at it more closely, I want to understand the use case for this patch. Why would you not want to recompile the kernel when adding support for new hardware? Do you want the ability to support flashes on devices that have already been deployed in the field? Is it something that comes up frequently?
Quoted 7 lines
In my case the kernel is loaded from a USB mass storage device, which can be preproduced and on stock (with the kernel already on it). With my patch I can change the flash vendor without the need of updating the image on already existing USB mass storage devices.
The patch is also useful for people who use distribution kernel as they will not have to wait until (and if) the distribution updates it.
Don't need separate DT property or cmdline argument. There is no way to know if the SFDP tables are 100% valid when kernel is working with a "generic flash".
Flashes are often replaced with newer revisions of the part that may/may not have valid SFDP tables.
So just rely on SFDP, when no valid entry is found in the manufacturer's flash_info[] while printing out a warning to user that this is just best effort support.
Regards
Vignesh
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Quoted 31 lines · Vignesh Raghavendra
Quoted 14 lines · Petr Malat
Hi!
Quoted 7 lines · Pratyush Yadav
Quoted 5 lines · Petr Malat
This change allows adding a support for flashes with correct SFDP without recompilation of the kernel by setting sfdp-compatible property in their node. Alternatively,
sfdp_compatiblemodule option can be used to list JEDEC IDs of flashes, whose SFDP can be trusted. Star "*" can be used to match all JEDEC IDs.Quoted 5 lines
I have skimmed through the patch. Before I look at it more closely, I want to understand the use case for this patch. Why would you not want to recompile the kernel when adding support for new hardware? Do you want the ability to support flashes on devices that have already been deployed in the field? Is it something that comes up frequently?
Quoted 7 lines
In my case the kernel is loaded from a USB mass storage device, which can be preproduced and on stock (with the kernel already on it). With my patch I can change the flash vendor without the need of updating the image on already existing USB mass storage devices.
The patch is also useful for people who use distribution kernel as they will not have to wait until (and if) the distribution updates it.
Don't need separate DT property or cmdline argument. There is no way to know if the SFDP tables are 100% valid when kernel is working with a "generic flash".
Flashes are often replaced with newer revisions of the part that may/may not have valid SFDP tables.
Quoted 3 lines
So just rely on SFDP, when no valid entry is found in the manufacturer's flash_info[] while printing out a warning to user that this is just best effort support.
+1
Signature · 7 lines
Regards, Pratyush Yadav Texas Instruments Inc. ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Quoted 25 lines · Vignesh Raghavendra
Quoted 11 lines
Quoted 11 lines
Quoted 5 lines
This change allows adding a support for flashes with correct SFDP without recompilation of the kernel by setting sfdp-compatible property in their node. Alternatively,
sfdp_compatiblemodule option can be used to list JEDEC IDs of flashes, whose SFDP can be trusted. Star "*" can be used to match all JEDEC IDs.I have skimmed through the patch. Before I look at it more closely, I want to understand the use case for this patch. Why would you not want to recompile the kernel when adding support for new hardware? Do you want the ability to support flashes on devices that have already been deployed in the field? Is it something that comes up frequently?
Quoted 7 lines
In my case the kernel is loaded from a USB mass storage device, which can be preproduced and on stock (with the kernel already on it). With my patch I can change the flash vendor without the need of updating the image on already existing USB mass storage devices.
The patch is also useful for people who use distribution kernel as they will not have to wait until (and if) the distribution updates it.
Don't need separate DT property or cmdline argument. There is no way to know if the SFDP tables are 100% valid when kernel is working with a "generic flash".
Flashes are often replaced with newer revisions of the part that may/may not have valid SFDP tables.
Quoted 3 lines
So just rely on SFDP, when no valid entry is found in the manufacturer's flash_info[] while printing out a warning to user that this is just best effort support.
OK, I will rework it to fallback to SFDP by default. I put the safeguard there to avoid a case when one has a flash requiring workarounds and then does a kernel downgrade to a release where the flash is not known and uses it. Should I make an opposite flag sfdp-incompatible or do we consider this a theoretical scenario not worth of addressing in the code?
Petr
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Vignesh Raghavendra
maintainerQuoted 30 lines · Petr Malat
Quoted 25 lines · Vignesh Raghavendra
Quoted 11 lines
Quoted 11 lines
Quoted 5 lines
This change allows adding a support for flashes with correct SFDP without recompilation of the kernel by setting sfdp-compatible property in their node. Alternatively,
sfdp_compatiblemodule option can be used to list JEDEC IDs of flashes, whose SFDP can be trusted. Star "*" can be used to match all JEDEC IDs.I have skimmed through the patch. Before I look at it more closely, I want to understand the use case for this patch. Why would you not want to recompile the kernel when adding support for new hardware? Do you want the ability to support flashes on devices that have already been deployed in the field? Is it something that comes up frequently?
Quoted 7 lines
In my case the kernel is loaded from a USB mass storage device, which can be preproduced and on stock (with the kernel already on it). With my patch I can change the flash vendor without the need of updating the image on already existing USB mass storage devices.
The patch is also useful for people who use distribution kernel as they will not have to wait until (and if) the distribution updates it.
Don't need separate DT property or cmdline argument. There is no way to know if the SFDP tables are 100% valid when kernel is working with a "generic flash".
Flashes are often replaced with newer revisions of the part that may/may not have valid SFDP tables.Quoted 3 lines
So just rely on SFDP, when no valid entry is found in the manufacturer's flash_info[] while printing out a warning to user that this is just best effort support.
Quoted 6 lines
OK, I will rework it to fallback to SFDP by default. I put the safeguard there to avoid a case when one has a flash requiring workarounds and then does a kernel downgrade to a release where the flash is not known and uses it. Should I make an opposite flag sfdp-incompatible or do we consider this a theoretical scenario not worth of addressing in the code?
We can guarantee new kernels don't regress wrt older version on upgrading. But anyone downgrading kernel should expect some HW support to be missing (not just SPI flash but many other things in general). I don't see a need to work about such scenario
Regards
Vignesh
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/