Skip to contentSkip to conversation

mmc: dw_mmc: fix 32bit little-endian access of des1 field

PATCH New Ben Dooks 3 participants 4 messages Jun 7, 2016 – Jun 9, 2016

Subsystems (2)
lore
Share & tools
lore

Ben Dooks

author
#0 lore raw

PATCH 1/1 mmc: dw_mmc: fix 32bit little-endian access of des1 field

The IDMAC_SET_BUFFER1_SIZE() macro modifies des1, but does not check if the value being passed is big or little endian desptire the des1 field being marked as __le32.

Fix the issue by ensuring the values are changed from the cpu endian to the descriptor endian by using cpu_to_le32.

Spotted whilst doing big endian conversion work on Exynos, and stops the mmc worker thread from stalling.

---
Cc: Matthew Leach <[email protected]>
Cc: Jaehoon Chung <[email protected]>
Cc: Ulf Hansson <[email protected]>
Cc: linux-mmc at vger.kernel.org
Cc: linux-arm-kernel at lists.infradead.org

---
 drivers/mmc/host/dw_mmc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/dw_mmc.c +1 -1
index 2cc6123..544397e 100644
@@ -92,7 +92,7 @@ struct idmac_desc {
 
 	__le32		des1;	/* Buffer sizes */
 #define IDMAC_SET_BUFFER1_SIZE(d, s) \
-	((d)->des1 = ((d)->des1 & 0x03ffe000) | ((s) & 0x1fff))
+	((d)->des1 = ((d)->des1 & cpu_to_le32(0x03ffe000)) | (cpu_to_le32((s) & 0x1fff)))
 
 	__le32		des2;	/* buffer 1 physical address */
 
Signature · 1 line
2.8.1
maintainer
#1 lore raw

PATCH 1/1 mmc: dw_mmc: fix 32bit little-endian access of des1 field

Hi Ben,

Quoted 3 lines · Ben Dooks

The IDMAC_SET_BUFFER1_SIZE() macro modifies des1, but does not check if the value being passed is big or little endian desptire the des1 field being marked as __le32.

Looks good.

Test on Rockchip platform, so

Quoted 30 lines

Fix the issue by ensuring the values are changed from the cpu endian to the descriptor endian by using cpu_to_le32.

Spotted whilst doing big endian conversion work on Exynos, and stops the mmc worker thread from stalling.

---
Cc: Matthew Leach <[email protected]>
Cc: Jaehoon Chung <[email protected]>
Cc: Ulf Hansson <[email protected]>
Cc: linux-mmc at vger.kernel.org
Cc: linux-arm-kernel at lists.infradead.org

---
  drivers/mmc/host/dw_mmc.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/dw_mmc.c +1 -1
index 2cc6123..544397e 100644
@@ -92,7 +92,7 @@ struct idmac_desc {
 
  	__le32		des1;	/* Buffer sizes */
  #define IDMAC_SET_BUFFER1_SIZE(d, s) \
-	((d)->des1 = ((d)->des1 & 0x03ffe000) | ((s) & 0x1fff))
+	((d)->des1 = ((d)->des1 & cpu_to_le32(0x03ffe000)) | (cpu_to_le32((s) & 0x1fff)))
 
  	__le32		des2;	/* buffer 1 physical address */
 
author
#2 lore raw

PATCH 1/1 mmc: dw_mmc: fix 32bit little-endian access of des1 field

Quoted 7 lines · Shawn Lin

Hi Ben,

Quoted 3 lines · Ben Dooks

The IDMAC_SET_BUFFER1_SIZE() macro modifies des1, but does not check if the value being passed is big or little endian desptire the des1 field being marked as __le32.

Quoted 7 lines

Looks good.

Test on Rockchip platform, so

Thanks, I'lkl prod matt to add his tested line.

Signature · 2 lines
Ben Dooks				http://www.codethink.co.uk/
Senior Engineer				Codethink - Providing Genius
maintainer Applied
#3 lore raw

PATCH 1/1 mmc: dw_mmc: fix 32bit little-endian access of des1 field

In reply to Ben Dooks

Hi Ben,

Quoted 9 lines · Ben Dooks

The IDMAC_SET_BUFFER1_SIZE() macro modifies des1, but does not check if the value being passed is big or little endian desptire the des1 field being marked as __le32.

Fix the issue by ensuring the values are changed from the cpu endian to the descriptor endian by using cpu_to_le32.

Spotted whilst doing big endian conversion work on Exynos, and stops the mmc worker thread from stalling.

Applied this patch. Thanks!

Best Regards,
Jaehoon Chung

Quoted 26 lines

---
Cc: Matthew Leach <[email protected]>
Cc: Jaehoon Chung <[email protected]>
Cc: Ulf Hansson <[email protected]>
Cc: linux-mmc at vger.kernel.org
Cc: linux-arm-kernel at lists.infradead.org

---
 drivers/mmc/host/dw_mmc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/dw_mmc.c +1 -1
index 2cc6123..544397e 100644
@@ -92,7 +92,7 @@ struct idmac_desc {
 
 	__le32		des1;	/* Buffer sizes */
 #define IDMAC_SET_BUFFER1_SIZE(d, s) \
-	((d)->des1 = ((d)->des1 & 0x03ffe000) | ((s) & 0x1fff))
+	((d)->des1 = ((d)->des1 & cpu_to_le32(0x03ffe000)) | (cpu_to_le32((s) & 0x1fff)))
 
 	__le32		des2;	/* buffer 1 physical address */