Skip to contentSkip to conversation

ls2085a: esdhc: flush D-cache before 'mmc read'

PATCH New Yangbo Lu 2 participants 3 messages Jun 24, 2015 – Aug 12, 2015 MMC, SD and SDIO

lore
Share & tools
lore

Yangbo Lu

author
#0 lore raw

PATCH 1/1 ls2085a: esdhc: flush D-cache before 'mmc read'

It needs to flush D-cache before 'mmc read' so that we can see the right data in DDR. And fix parameter for invalidate_dcache_range() after 'mmc read'.

---
 drivers/mmc/fsl_esdhc.c | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)
drivers/mmc/fsl_esdhc.c +15 -6
index c4719e6..3ca25bd 100644
@@ -192,6 +192,17 @@ static int esdhc_setup_data(struct mmc *mmc, struct mmc_data *data)
 	wml_value = data->blocksize/4;
 
 	if (data->flags & MMC_DATA_READ) {
+#ifndef CONFIG_SYS_FSL_ESDHC_USE_PIO
+#ifdef CONFIG_LS2085A
+		/*
+		 * It's temporary for ls2085a so that
+		 * we can see right data in DDR
+		 */
+		flush_dcache_range((ulong)data->dest,
+				   (ulong)data->dest+data->blocks
+					 *data->blocksize);
+#endif
+#endif
 		if (wml_value > WML_RD_WML_MAX)
 			wml_value = WML_RD_WML_MAX_VAL;
 
@@ -278,14 +289,9 @@ static int esdhc_setup_data(struct mmc *mmc, struct mmc_data *data)
 static void check_and_invalidate_dcache_range
 	(struct mmc_cmd *cmd,
 	 struct mmc_data *data) {
-#ifdef CONFIG_LS2085A
-	unsigned start = 0;
-#else
-	unsigned start = (unsigned)data->dest ;
-#endif
+	unsigned start, end;
 	unsigned size = roundup(ARCH_DMA_MINALIGN,
 				data->blocks*data->blocksize);
-	unsigned end = start+size ;
 #ifdef CONFIG_LS2085A
 	dma_addr_t addr;
 
@@ -294,7 +300,10 @@ static void check_and_invalidate_dcache_range
 		printf("Error found for upper 32 bits\n");
 	else
 		start = lower_32_bits(addr);
+#else
+	start = (unsigned)data->dest;
 #endif
+	end = start + size;
 	invalidate_dcache_range(start, end);
 }
 #endif
Signature · 1 line
2.1.0.27.g96db324
#1 lore raw

PATCH 1/1 ls2085a: esdhc: flush D-cache before 'mmc read'

Hi Yangbo,

Quoted 24 lines · Yangbo Lu

It needs to flush D-cache before 'mmc read' so that we can see the right data in DDR. And fix parameter for invalidate_dcache_range() after 'mmc read'.

---
drivers/mmc/fsl_esdhc.c | 21 +++++++++++++++------

1 file changed, 15 insertions(+), 6 deletions(-)
drivers/mmc/fsl_esdhc.c +4 -0
index c4719e6..3ca25bd 100644
@@ -192,6 +192,17 @@ static int esdhc_setup_data(struct mmc *mmc, struct mmc_data *data)
 	wml_value = data->blocksize/4;
 
 	if (data->flags & MMC_DATA_READ) {
+#ifndef CONFIG_SYS_FSL_ESDHC_USE_PIO
+#ifdef CONFIG_LS2085A
+		/*
+		 * It's temporary for ls2085a so that

drivers/mmc/fsl_esdhc.c static int esdhc_setup_data(struct mmc *mmc, struct mmc_data *data) · line 208

Quoted 10 lines
drivers/mmc/fsl_esdhc.c +7 -0
+		 * we can see right data in DDR
+		 */
+		flush_dcache_range((ulong)data->dest,
+				   (ulong)data->dest+data->blocks
+					 *data->blocksize);
+#endif
+#endif
 		if (wml_value > WML_RD_WML_MAX)
 			wml_value = WML_RD_WML_MAX_VAL;
 

This looks like not board/soc specific, more like whether a non-coherent architecture.

Please rework as a configuration option that?s suited for that kind of architectures.

It looks like you?re only doing this for reads? What about writes?

Quoted 30 lines
drivers/mmc/fsl_esdhc.c +0 -0
@@ -278,14 +289,9 @@ static int esdhc_setup_data(struct mmc *mmc, struct mmc_data *data)

static void check_and_invalidate_dcache_range

	(struct mmc_cmd *cmd,
	 struct mmc_data *data) {
drivers/mmc/fsl_esdhc.c +1 -5
-#ifdef CONFIG_LS2085A
-	unsigned start = 0;
-#else
-	unsigned start = (unsigned)data->dest ;
-#endif
+	unsigned start, end;
	unsigned size = roundup(ARCH_DMA_MINALIGN,
				data->blocks*data->blocksize);
drivers/mmc/fsl_esdhc.c +0 -1
-	unsigned end = start+size ;
#ifdef CONFIG_LS2085A
	dma_addr_t addr;
drivers/mmc/fsl_esdhc.c +3 -0
@@ -294,7 +300,10 @@ static void check_and_invalidate_dcache_range
 		printf("Error found for upper 32 bits\n");
 	else
 		start = lower_32_bits(addr);
+#else
+	start = (unsigned)data->dest;
 #endif
+	end = start + size;
 	invalidate_dcache_range(start, end);
 }
 #endif
Signature · 1 line
2.1.0.27.g96db324

Regards

? Pantelis

author
#2 lore raw

PATCH 1/1 ls2085a: esdhc: flush D-cache before 'mmc read'

Hi Pantelis,

Quoted 41 lines

Hi Yangbo,

drivers/mmc/fsl_esdhc.c static int esdhc_setup_data(struct mmc *mmc,

Quoted 17 lines · Yangbo Lu

It needs to flush D-cache before 'mmc read' so that we can see the right data in DDR. And fix parameter for invalidate_dcache_range() after 'mmc read'.

---
drivers/mmc/fsl_esdhc.c | 21 +++++++++++++++------

1 file changed, 15 insertions(+), 6 deletions(-)
drivers/mmc/fsl_esdhc.c index renamed from drivers/mmc/fsl_esdhc.c +0 -0

c4719e6..3ca25bd 100644

drivers/mmc/fsl_esdhc.c +0 -0
@@ -192,6 +192,17 @@ static int esdhc_setup_data(struct mmc *mmc,

struct mmc_data *data)

Quoted 7 lines
drivers/mmc/fsl_esdhc.c +4 -0
 	wml_value = data->blocksize/4;
 
 	if (data->flags & MMC_DATA_READ) {
+#ifndef CONFIG_SYS_FSL_ESDHC_USE_PIO
+#ifdef CONFIG_LS2085A
+		/*
+		 * It's temporary for ls2085a so that

drivers/mmc/fsl_esdhc.c static int esdhc_setup_data(struct mmc *mmc, struct mmc_data *data) · line 208

Quoted 10 lines
drivers/mmc/fsl_esdhc.c +7 -0
+		 * we can see right data in DDR
+		 */
+		flush_dcache_range((ulong)data->dest,
+				   (ulong)data->dest+data->blocks
+					 *data->blocksize);
+#endif
+#endif
 		if (wml_value > WML_RD_WML_MAX)
 			wml_value = WML_RD_WML_MAX_VAL;
 

This looks like not board/soc specific, more like whether a non-coherent architecture.

Quoted 4 lines

Please rework as a configuration option that?s suited for that kind of architectures.

It looks like you?re only doing this for reads? What about writes?

The LS2085A platform exists cache coherency issue now. mmc writing is normal while mmc reading should use this workaround to work fine. When cache coherency bug is fixed, this code would be removed.
Do I still need to rework as a configuration option?
Thanks a lot.

-Yangbo Lu

Quoted 35 lines
Quoted 29 lines
drivers/mmc/fsl_esdhc.c +0 -0
@@ -278,14 +289,9 @@ static int esdhc_setup_data(struct mmc *mmc,

struct mmc_data *data) static void check_and_invalidate_dcache_range

	(struct mmc_cmd *cmd,
	 struct mmc_data *data) {
drivers/mmc/fsl_esdhc.c +1 -5
-#ifdef CONFIG_LS2085A
-	unsigned start = 0;
-#else
-	unsigned start = (unsigned)data->dest ;
-#endif
+	unsigned start, end;
	unsigned size = roundup(ARCH_DMA_MINALIGN,
				data->blocks*data->blocksize);
drivers/mmc/fsl_esdhc.c +0 -1
-	unsigned end = start+size ;
#ifdef CONFIG_LS2085A
	dma_addr_t addr;
drivers/mmc/fsl_esdhc.c +3 -1
@@ -294,7 +300,10 @@ static void check_and_invalidate_dcache_range
 		printf("Error found for upper 32 bits\n");
 	else
 		start = lower_32_bits(addr);
+#else
+	start = (unsigned)data->dest;
 #endif
+	end = start + size;
 	invalidate_dcache_range(start, end);
 }
 #endif
--
Quoted 2 lines

2.1.0.27.g96db324

Regards

? Pantelis