Skip to contentSkip to conversation

Patch "spi: bcm2835: BUG: fix wrong use of PAGE_MASK" has been added to the 4.2-stable tree

PATCH [email protected] 1 participant 1 message Oct 17, 2015

Subsystems (4)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

spi: bcm2835: BUG: fix wrong use of PAGE_MASK

to the 4.2-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:

     spi-bcm2835-bug-fix-wrong-use-of-page_mask.patch

and it can be found in the queue-4.2 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From 2a3fffd45822070309bcf0b1e1dae624d633824a Mon Sep 17 00:00:00 2001

From: Martin Sperl <[email protected]>
Date: Thu, 10 Sep 2015 09:32:14 +0000
Subject: spi: bcm2835: BUG: fix wrong use of PAGE_MASK

From: Martin Sperl <[email protected]>

commit 2a3fffd45822070309bcf0b1e1dae624d633824a upstream.

There is a bug in the alignment checking of transfers, that results in DMA not being used for un-aligned transfers that do not cross page-boundries, which is valid.

This is due to a missconception of the meaning PAGE_MASK when implementing that check originally - (PAGE_SIZE - 1) should have been used instead.

Also fixes a copy/paste error.

---
 drivers/spi/spi-bcm2835.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/spi/spi-bcm2835.c +3 -3
@@ -386,14 +386,14 @@ static bool bcm2835_spi_can_dma(struct s
 	/* otherwise we only allow transfers within the same page
 	 * to avoid wasting time on dma_mapping when it is not practical
 	 */
-	if (((size_t)tfr->tx_buf & PAGE_MASK) + tfr->len > PAGE_SIZE) {
+	if (((size_t)tfr->tx_buf & (PAGE_SIZE - 1)) + tfr->len > PAGE_SIZE) {
 		dev_warn_once(&spi->dev,
 			      "Unaligned spi tx-transfer bridging page\n");
 		return false;
 	}
-	if (((size_t)tfr->rx_buf & PAGE_MASK) + tfr->len > PAGE_SIZE) {
+	if (((size_t)tfr->rx_buf & (PAGE_SIZE - 1)) + tfr->len > PAGE_SIZE) {
 		dev_warn_once(&spi->dev,
-			      "Unaligned spi tx-transfer bridging page\n");
+			      "Unaligned spi rx-transfer bridging page\n");
 		return false;
 	}
 

Patches currently in stable-queue which might be from [email protected] are

queue-4.2/spi-bcm2835-bug-fix-wrong-use-of-page_mask.patch