public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] spi-nor: intel-spi: Avoid crossing 4K address boundary on read/write
@ 2019-02-26 11:23 Sverdlin, Alexander (Nokia - DE/Ulm)
  2019-02-26 11:31 ` Mika Westerberg
  2019-02-27  9:57 ` [PATCH v2] " Sverdlin, Alexander (Nokia - DE/Ulm)
  0 siblings, 2 replies; 5+ messages in thread
From: Sverdlin, Alexander (Nokia - DE/Ulm) @ 2019-02-26 11:23 UTC (permalink / raw)
  To: linux-mtd@lists.infradead.org
  Cc: Sverdlin, Alexander (Nokia - DE/Ulm), Marek Vasut, Tudor Ambarus,
	David Woodhouse, Brian Norris, Boris Brezillon,
	Richard Weinberger, Bin Meng, Mika Westerberg,
	Porte, Romain (Nokia - FR/Paris-Saclay),
	Fabreges, Pascal (Nokia - FR/Paris-Saclay),
	stable@vger.kernel.org

It was observed that reads crossing 4K address boundary are failing.

This limitation is mentioned in Intel documents:

Intel(R) 9 Series Chipset Family Platform Controller Hub (PCH) Datasheet:

"5.26.3 Flash Access
Program Register Access:
* Program Register Accesses are not allowed to cross a 4 KB boundary..."

Enhanced Serial Peripheral Interface (eSPI)
Interface Base Specification (for Client and Server Platforms):

"5.1.4 Address
For other memory transactions, the address may start or end at any byte
boundary. However, the address and payload length combination must not
cross the naturally aligned address boundary of the corresponding Maximum
Payload Size. It must not cross a 4 KB address boundary."

Avoid this by splitting an operation crossing the boundary into two
operations.

Cc: stable@vger.kernel.org
Reported-by: Romain Porte <romain.porte@nokia.com>
Tested-by: Pascal Fabreges <pascal.fabreges@nokia.com>
Signed-off-by: Alexander Sverdlin <alexander.sverdlin@nokia.com>
---
 drivers/mtd/spi-nor/intel-spi.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/mtd/spi-nor/intel-spi.c b/drivers/mtd/spi-nor/intel-spi.c
index af0a220..b83ea79 100644
--- a/drivers/mtd/spi-nor/intel-spi.c
+++ b/drivers/mtd/spi-nor/intel-spi.c
@@ -632,6 +632,10 @@ static ssize_t intel_spi_read(struct spi_nor *nor, loff_t from, size_t len,
 	while (len > 0) {
 		block_size = min_t(size_t, len, INTEL_SPI_FIFO_SZ);
 
+		/* Read cannot cross 4K boundary */
+		if ((from ^ (from + block_size - 1)) & ~(SZ_4K - 1LL))
+			block_size -= (from + block_size) & (SZ_4K - 1);
+
 		writel(from, ispi->base + FADDR);
 
 		val = readl(ispi->base + HSFSTS_CTL);
@@ -685,6 +689,10 @@ static ssize_t intel_spi_write(struct spi_nor *nor, loff_t to, size_t len,
 	while (len > 0) {
 		block_size = min_t(size_t, len, INTEL_SPI_FIFO_SZ);
 
+		/* Write cannot cross 4K boundary */
+		if ((to ^ (to + block_size - 1)) & ~(SZ_4K - 1LL))
+			block_size -= (to + block_size) & (SZ_4K - 1);
+
 		writel(to, ispi->base + FADDR);
 
 		val = readl(ispi->base + HSFSTS_CTL);
-- 
2.4.6


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

end of thread, other threads:[~2019-02-27 13:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-26 11:23 [PATCH] spi-nor: intel-spi: Avoid crossing 4K address boundary on read/write Sverdlin, Alexander (Nokia - DE/Ulm)
2019-02-26 11:31 ` Mika Westerberg
2019-02-27  9:57 ` [PATCH v2] " Sverdlin, Alexander (Nokia - DE/Ulm)
2019-02-27 10:27   ` Mika Westerberg
2019-02-27 13:29     ` Sverdlin, Alexander (Nokia - DE/Ulm)

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