mtd: spi-nor: intel-spi: fix forced writable option
Subsystems (2)
PATCH 2/2 mtd: spi-nor: intel-spi: fix forced writable option
This option currently doesn't work as expected. If the BIOS has this flash as read-only there is no way to change this thru the driver. There is a parameter which allows the flash to become writable with the "writable" option to the module, but it does nothing if the BIOS has it set to read-only.
I would expect this option would make the flash writable regardless of the BIOS settings. This patch changes this option so the BIOS setting doesn't stop the writable option from enabling read write on the flash.
Original patch by Jinhua Wu <[email protected]>
--- drivers/mtd/spi-nor/controllers/intel-spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/spi-nor/controllers/intel-spi.c +1 -1
@@ -954,7 +954,7 @@ struct intel_spi *intel_spi_probe(struct device *dev,intel_spi_fill_partition (ispi, &part);/* Prevent writes if not explicitly enabled */ -if (!ispi->writeable || !writeable) +if (!ispi->writeable && !writeable) ispi->nor.mtd.flags &= ~MTD_WRITEABLE ; ret =mtd_device_register (&ispi->nor.mtd, &part,1 );
Signature · 6 lines
2.17.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Vignesh Raghavendra
maintainerQuoted 10 lines · Daniel Walker
This option currently doesn't work as expected. If the BIOS has this flash as read-only there is no way to change this thru the driver. There is a parameter which allows the flash to become writable with the "writable" option to the module, but it does nothing if the BIOS has it set to read-only.
I would expect this option would make the flash writable regardless of the BIOS settings. This patch changes this option so the BIOS setting doesn't stop the writable option from enabling read write on the flash.
I am confused you say "If the BIOS has this flash as read-only there is no way to change this thru the driver", so is it possible to override BIOS setting? If yes, where is the code in the driver?
What happens if BIOS is set to allow writes but writeable is set to 0?
Also please send patch series as thread (2/2 in reply to 1/2). You can use tool like git send-email
Quoted 15 lines
Original patch by Jinhua Wu <[email protected]>
--- drivers/mtd/spi-nor/controllers/intel-spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/mtd/spi-nor/controllers/intel-spi.c +0
-0
drivers/mtd/spi-nor/controllers/intel-spi.c struct intel_spi *intel_spi_probe(struct device *dev, · line 960
Quoted 8 lines
drivers/mtd/spi-nor/controllers/intel-spi.c +1
-1@@ -954,7 +954,7 @@ struct intel_spi *intel_spi_probe(struct device *dev,intel_spi_fill_partition (ispi, &part);/* Prevent writes if not explicitly enabled */ -if (!ispi->writeable || !writeable) +if (!ispi->writeable && !writeable) ispi->nor.mtd.flags &= ~MTD_WRITEABLE ; ret =mtd_device_register (&ispi->nor.mtd, &part,1 );
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
On 2020/5/28, 11:48 PM, "Jinhua Wu" <[email protected]> wrote:
Hi Vignesh,
BIOS just locked down parts of flash (such as, code region), others are still writeable. Once the SPI locked down,it can't be override unless platfrom reset and set WPD (write protect disable) will fail, so ispi->writeable will always be 0, then the driver will always make the whole flash read only, even if we have set the parameter writable = 1.
Now the flash is totally not writeable, just part of it is read only. Why not making 'writeable' working when explicitly enabled?
Quoted 37 lines · Vignesh Raghavendra
Quoted 10 lines · Daniel Walker
This option currently doesn't work as expected. If the BIOS has this flash as read-only there is no way to change this thru the driver. There is a parameter which allows the flash to become writable with the "writable" option to the module, but it does nothing if the BIOS has it set to read-only.
I would expect this option would make the flash writable regardless of the BIOS settings. This patch changes this option so the BIOS setting doesn't stop the writable option from enabling read write on the flash.
I am confused you say "If the BIOS has this flash as read-only there is no way to change this thru the driver", so is it possible to override BIOS setting? If yes, where is the code in the driver?
What happens if BIOS is set to allow writes but writeable is set to 0? Also please send patch series as thread (2/2 in reply to 1/2). You can use tool like git send-email > Original patch by Jinhua Wu <[email protected]> > > Cc: Jinhua Wu <[email protected]> > Cc: [email protected] > Signed-off-by: Daniel Walker <[email protected]> > --- > drivers/mtd/spi-nor/controllers/intel-spi.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/mtd/spi-nor/controllers/intel-spi.c b/drivers/mtd/spi-nor/controllers/intel-spi.c > index e5a3d51a2e4d..68a5877bfc0b 100644 > --- a/drivers/mtd/spi-nor/controllers/intel-spi.c > +++ b/drivers/mtd/spi-nor/controllers/intel-spi.c > @@ -954,7 +954,7 @@ struct intel_spi *intel_spi_probe(struct device *dev, > intel_spi_fill_partition(ispi, &part);
Quoted 8 lines
> > /* Prevent writes if not explicitly enabled */ > - if (!ispi->writeable || !writeable) > + if (!ispi->writeable && !writeable) > ispi->nor.mtd.flags &= ~MTD_WRITEABLE; > > ret = mtd_device_register(&ispi->nor.mtd, &part, 1); >
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Quoted 32 lines · Jinhua Wu (jinhwu)
On 2020/5/28, 11:48 PM, "Jinhua Wu" <[email protected]> wrote:
Hi Vignesh,
BIOS just locked down parts of flash (such as, code region), others are still writeable. Once the SPI locked down,it can't be override unless platfrom reset and set WPD (write protect disable) will fail, soispi->writeablewill always be 0, then the driver will always make the whole flash read only, even if we have set the parameter writable = 1.
Now the flash is totally not writeable, just part of it is read only. Why not making 'writeable' working when explicitly enabled?Quoted 22 lines · Vignesh Raghavendra
Quoted 10 lines · Daniel Walker
This option currently doesn't work as expected. If the BIOS has this flash as read-only there is no way to change this thru the driver. There is a parameter which allows the flash to become writable with the "writable" option to the module, but it does nothing if the BIOS has it set to read-only.
I would expect this option would make the flash writable regardless of the BIOS settings. This patch changes this option so the BIOS setting doesn't stop the writable option from enabling read write on the flash.
I am confused you say "If the BIOS has this flash as read-only there is no way to change this thru the driver", so is it possible to override BIOS setting? If yes, where is the code in the driver?
What happens if BIOS is set to allow writes but writeable is set to 0?
Also please send patch series as thread (2/2 in reply to 1/2). You can use tool like git send-email
Vignesh, do you still have concerns about this change ?
Daniel