mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] mfd: lpc_ich: Do not touch SPI-NOR write protection bit on Haswell/Broadwell
@ 2017-07-28 10:50 Mika Westerberg
  2017-08-08  7:29 ` Lee Jones
  0 siblings, 1 reply; 2+ messages in thread
From: Mika Westerberg @ 2017-07-28 10:50 UTC (permalink / raw)
  To: linux-kernel; +Cc: Lee Jones, Peter Tyser, abdo.roig, Mika Westerberg

At least on Lenovo Thinkpad Yoga, the BIOS seems to monitor the SPI-NOR
write protection bit and if it is flipped to read/write it assumes the
BIOS configuration was changed on next reboot. It then, for unknown
reasons, resets the BIOS settings back to default.

We can prevent this by just leaving the write protection bit intact and
let the SPI-NOR driver know whether the device is writable or not. In
case of this particular Lenovo the SPI-NOR flash will be exposed as
read-only.

Fixes: ff00d7a32a1b ("mfd: lpc_ich: Add support for SPI serial flash host controller")
Link: https://bugzilla.kernel.org/show_bug.cgi?id=195951
Reported-by: Abdó Roig-Marange <abdo.roig@gmail.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/mfd/lpc_ich.c | 10 ----------
 1 file changed, 10 deletions(-)

diff --git a/drivers/mfd/lpc_ich.c b/drivers/mfd/lpc_ich.c
index 773f1554d2f9..450ae36645aa 100644
--- a/drivers/mfd/lpc_ich.c
+++ b/drivers/mfd/lpc_ich.c
@@ -1119,17 +1119,7 @@ static int lpc_ich_init_spi(struct pci_dev *dev)
 			res->start = spi_base + SPIBASE_LPT;
 			res->end = res->start + SPIBASE_LPT_SZ - 1;
 
-			/*
-			 * Try to make the flash chip writeable now by
-			 * setting BCR_WPD. It it fails we tell the driver
-			 * that it can only read the chip.
-			 */
 			pci_read_config_dword(dev, BCR, &bcr);
-			if (!(bcr & BCR_WPD)) {
-				bcr |= BCR_WPD;
-				pci_write_config_dword(dev, BCR, bcr);
-				pci_read_config_dword(dev, BCR, &bcr);
-			}
 			info->writeable = !!(bcr & BCR_WPD);
 		}
 		break;
-- 
2.13.2

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] mfd: lpc_ich: Do not touch SPI-NOR write protection bit on Haswell/Broadwell
  2017-07-28 10:50 [PATCH] mfd: lpc_ich: Do not touch SPI-NOR write protection bit on Haswell/Broadwell Mika Westerberg
@ 2017-08-08  7:29 ` Lee Jones
  0 siblings, 0 replies; 2+ messages in thread
From: Lee Jones @ 2017-08-08  7:29 UTC (permalink / raw)
  To: Mika Westerberg; +Cc: linux-kernel, Peter Tyser, abdo.roig

On Fri, 28 Jul 2017, Mika Westerberg wrote:

> At least on Lenovo Thinkpad Yoga, the BIOS seems to monitor the SPI-NOR
> write protection bit and if it is flipped to read/write it assumes the
> BIOS configuration was changed on next reboot. It then, for unknown
> reasons, resets the BIOS settings back to default.
> 
> We can prevent this by just leaving the write protection bit intact and
> let the SPI-NOR driver know whether the device is writable or not. In
> case of this particular Lenovo the SPI-NOR flash will be exposed as
> read-only.
> 
> Fixes: ff00d7a32a1b ("mfd: lpc_ich: Add support for SPI serial flash host controller")
> Link: https://bugzilla.kernel.org/show_bug.cgi?id=195951
> Reported-by: Abdó Roig-Marange <abdo.roig@gmail.com>
> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
> ---
>  drivers/mfd/lpc_ich.c | 10 ----------
>  1 file changed, 10 deletions(-)

Applied, thanks.

> diff --git a/drivers/mfd/lpc_ich.c b/drivers/mfd/lpc_ich.c
> index 773f1554d2f9..450ae36645aa 100644
> --- a/drivers/mfd/lpc_ich.c
> +++ b/drivers/mfd/lpc_ich.c
> @@ -1119,17 +1119,7 @@ static int lpc_ich_init_spi(struct pci_dev *dev)
>  			res->start = spi_base + SPIBASE_LPT;
>  			res->end = res->start + SPIBASE_LPT_SZ - 1;
>  
> -			/*
> -			 * Try to make the flash chip writeable now by
> -			 * setting BCR_WPD. It it fails we tell the driver
> -			 * that it can only read the chip.
> -			 */
>  			pci_read_config_dword(dev, BCR, &bcr);
> -			if (!(bcr & BCR_WPD)) {
> -				bcr |= BCR_WPD;
> -				pci_write_config_dword(dev, BCR, bcr);
> -				pci_read_config_dword(dev, BCR, &bcr);
> -			}
>  			info->writeable = !!(bcr & BCR_WPD);
>  		}
>  		break;

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-08-08  7:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-28 10:50 [PATCH] mfd: lpc_ich: Do not touch SPI-NOR write protection bit on Haswell/Broadwell Mika Westerberg
2017-08-08  7:29 ` Lee Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®