Skip to contentSkip to conversation

mmc: mmci: Fix PIO read for small SDIO packets

PATCH New Stefan Nilsson XK 1 participant 2 messages Oct 26, 2011 – Nov 14, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mmc: mmci: Fix PIO read for small SDIO packets

Corrects a bug in MMCI host driver which silently causes small reads (< 4 bytes as only used in SDIO) from PL-18X to fail.

---
 drivers/mmc/host/mmci.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)
drivers/mmc/host/mmci.c +12 -1
index 56e9a41..5c3a517 100644
@@ -776,7 +776,18 @@ static int mmci_pio_read(struct mmci_host *host, char *buffer, unsigned int rema
 		if (count <= 0)
 			break;
 
-		readsl(base + MMCIFIFO, ptr, count >> 2);
+		/*
+		 * SDIO especially may want to send something that is
+		 * not divisible by 4 (as opposed to card sectors
+		 * etc). Therefore make sure to to always read the last bytes
+		 * while only doing full 32-bit reads towards the FIFO.
+		 */
+		if (count < 4) {
+			unsigned char buf[4];
+			readsl(base + MMCIFIFO, buf, 1);
+			memcpy(ptr, buf, count);
+		} else
+			readsl(base + MMCIFIFO, ptr, count >> 2);
 
 		ptr += count;
 		remain -= count;
Signature · 1 line
1.7.7
#1 lore raw

PATCH 1/1 mmc: mmci: Fix PIO read for small SDIO packets

Any comments on this new version of this patch?
Can it be merged?

Best Regards

Stefan Nilsson

Quoted 34 lines · On 10/26/2011 10:45 AM, Stefan NILSSON9 wrote:

Corrects a bug in MMCI host driver which silently causes small reads (< 4 bytes as only used in SDIO) from PL-18X to fail.

---
  drivers/mmc/host/mmci.c |   13 ++++++++++++-
  1 files changed, 12 insertions(+), 1 deletions(-)
drivers/mmc/host/mmci.c +12 -1
index 56e9a41..5c3a517 100644
@@ -776,7 +776,18 @@ static int mmci_pio_read(struct mmci_host *host, char *buffer, unsigned int rema
  		if (count<= 0)
  			break;
 
-		readsl(base + MMCIFIFO, ptr, count>>  2);
+		/*
+		 * SDIO especially may want to send something that is
+		 * not divisible by 4 (as opposed to card sectors
+		 * etc). Therefore make sure to to always read the last bytes
+		 * while only doing full 32-bit reads towards the FIFO.
+		 */
+		if (count<  4) {
+			unsigned char buf[4];
+			readsl(base + MMCIFIFO, buf, 1);
+			memcpy(ptr, buf, count);
+		} else
+			readsl(base + MMCIFIFO, ptr, count>>  2);
 
  		ptr += count;
  		remain -= count;