Skip to contentSkip to conversation

video: cfb_console: flush dcache for frame buffer in DRAM

PATCH New Anatolij Gustschin 6 participants 16 messages Apr 28, 2012 – Jul 19, 2012 Framebuffer layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 video: cfb_console: flush dcache for frame buffer in DRAM

Data cache flushing is required for frame buffer in RAM to fix the distorted console text output. Currently this text distortion is observed with cfb on beageboard and N900 when running with data cache enabled.

---
 drivers/video/cfb_console.c |   35 +++++++++++++++++++++++++++++++++++
 1 files changed, 35 insertions(+), 0 deletions(-)
drivers/video/cfb_console.c +35 -0
index 904caf7..dd7ccb7 100644
@@ -360,6 +360,8 @@ void console_cursor(int state);
 extern void video_get_info_str(int line_number,	char *info);
 #endif
 
+DECLARE_GLOBAL_DATA_PTR;
+
 /* Locals */
 static GraphicDevice *pGD;	/* Pointer to Graphic array */
 
@@ -377,6 +379,8 @@ static int console_row;		/* cursor row */
 
 static u32 eorx, fgx, bgx;	/* color pats */
 
+static int cfb_do_flush_cache;
+
 static const int video_font_draw_table8[] = {
 	0x00000000, 0x000000ff, 0x0000ff00, 0x0000ffff,
 	0x00ff0000, 0x00ff00ff, 0x00ffff00, 0x00ffffff,
@@ -553,6 +557,8 @@ static void video_drawchars(int xx, int yy, unsigned char *s, int count)
 					SWAP32((video_font_draw_table32
 						[bits & 15][3] & eorx) ^ bgx);
 			}
+			if (cfb_do_flush_cache)
+				flush_cache((ulong)dest0, 32);
 			dest0 += VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE;
 			s++;
 		}
@@ -621,6 +627,8 @@ static void video_invertchar(int xx, int yy)
 		for (x = firstx; x < lastx; x++) {
 			u8 *dest = (u8 *)(video_fb_address) + x + y;
 			*dest = ~*dest;
+			if (cfb_do_flush_cache)
+				flush_cache((ulong)dest, 4);
 		}
 	}
 }
@@ -717,6 +725,8 @@ static void console_scrollup(void)
 #else
 	memsetl(CONSOLE_ROW_LAST, CONSOLE_ROW_SIZE >> 2, CONSOLE_BG_COL);
 #endif
+	if (cfb_do_flush_cache)
+		flush_cache((ulong)CONSOLE_ROW_FIRST, CONSOLE_SIZE);
 }
 
 static void console_back(void)
@@ -1651,6 +1661,29 @@ static void *video_logo(void)
 }
 #endif
 
+static int cfb_fb_is_in_dram(void)
+{
+	bd_t *bd = gd->bd;
+	ulong start, end;
+	int i;
+
+	for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
+#if defined(CONFIG_ARM) || defined(CONFIG_AVR32) || defined(COFNIG_NDS32) || \
+defined(CONFIG_SANDBOX) || defined(CONFIG_X86)
+		start = bd->bi_dram[i].start;
+		end = bd->bi_dram[i].start + bd->bi_dram[i].size - 1;
+#else
+		start = bd->bi_memstart;
+		end = bd->bi_memsize;
+#endif
+
+		if ((ulong)video_fb_address >= start &&
+		    (ulong)video_fb_address < end)
+			return 1;
+	}
+	return 0;
+}
+
 static int video_init(void)
 {
 	unsigned char color8;
@@ -1664,6 +1697,8 @@ static int video_init(void)
 	video_init_hw_cursor(VIDEO_FONT_WIDTH, VIDEO_FONT_HEIGHT);
 #endif
 
+	cfb_do_flush_cache = cfb_fb_is_in_dram() && dcache_status();
+
 	/* Init drawing pats */
 	switch (VIDEO_DATA_FORMAT) {
 	case GDF__8BIT_INDEX:
Signature · 1 line
1.7.1
#1 lore raw

PATCH 1/1 video: cfb_console: flush dcache for frame buffer in DRAM

Quoted 7 lines · On Saturday 28 April 2012 17:04:07 you wrote:

Data cache flushing is required for frame buffer in RAM to fix the distorted console text output. Currently this text distortion is observed with cfb on beageboard and N900 when running with data cache enabled.

Signature · 9 lines
Pali Roh?r
pali.rohar at gmail.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120428/488c868f/attachment.pgp>
#2 lore raw

PATCH 1/1 video: cfb_console: flush dcache for frame buffer in DRAM

In reply to Anatolij Gustschin
Quoted 12 lines · On Saturday 28 April 2012 11:04:07 Anatolij Gustschin wrote:
drivers/video/cfb_console.c +8 -0
+static int cfb_fb_is_in_dram(void)
+{
+	bd_t *bd = gd->bd;
+	ulong start, end;
+	int i;
+
+	for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
+#if defined(CONFIG_ARM) || defined(CONFIG_AVR32) || defined(COFNIG_NDS32)

|| \ +defined(CONFIG_SANDBOX) || defined(CONFIG_X86)

drivers/video/cfb_console.c +3 -0
+		start = bd->bi_dram[i].start;
+		end = bd->bi_dram[i].start + bd->bi_dram[i].size - 1;
+#else

drivers/video/cfb_console.c static void *video_logo(void) · line 1685

Quoted 10 lines
drivers/video/cfb_console.c +10 -0
+		start = bd->bi_memstart;
+		end = bd->bi_memsize;
+#endif
+
+		if ((ulong)video_fb_address >= start &&
+		    (ulong)video_fb_address < end)
+			return 1;
+	}
+	return 0;
+}

is this necessary ? the cache funcs should take care of this automatically. -mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120428/455ca8c1/attachment.pgp>

#3 lore raw

PATCH 1/1 video: cfb_console: flush dcache for frame buffer in DRAM

Hi Mike,

Quoted 17 lines · On Sat, 28 Apr 2012 14:16:39 -0400 Mike Frysinger <[email protected]> wrote:
Quoted 16 lines · On Saturday 28 April 2012 11:04:07 Anatolij Gustschin wrote:
drivers/video/cfb_console.c +8 -0
+static int cfb_fb_is_in_dram(void)
+{
+	bd_t *bd = gd->bd;
+	ulong start, end;
+	int i;
+
+	for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
+#if defined(CONFIG_ARM) || defined(CONFIG_AVR32) || defined(COFNIG_NDS32)

|| \ +defined(CONFIG_SANDBOX) || defined(CONFIG_X86)

drivers/video/cfb_console.c +7 -0
+		start = bd->bi_dram[i].start;
+		end = bd->bi_dram[i].start + bd->bi_dram[i].size - 1;
+#else
+		start = bd->bi_memstart;
+		end = bd->bi_memsize;
+#endif
+
Quoted 8 lines

drivers/video/cfb_console.c static void *video_logo(void) · line 1685

Quoted 6 lines
drivers/video/cfb_console.c +6 -0
+		if ((ulong)video_fb_address >= start &&
+		    (ulong)video_fb_address < end)
+			return 1;
+	}
+	return 0;
+}

is this necessary ? the cache funcs should take care of this automatically.

Currently they don't, or at least on some architectures. Or did you mean that the cache instructions should take care of this?

Thanks,
Anatolij

#4 lore raw

PATCH 1/1 video: cfb_console: flush dcache for frame buffer in DRAM

Quoted 31 lines · On Monday 30 April 2012 11:32:21 Anatolij Gustschin wrote:
Quoted 13 lines · On Sat, 28 Apr 2012 14:16:39 -0400 Mike Frysinger wrote:
Quoted 12 lines · On Saturday 28 April 2012 11:04:07 Anatolij Gustschin wrote:
drivers/video/cfb_console.c +8 -0
+static int cfb_fb_is_in_dram(void)
+{
+	bd_t *bd = gd->bd;
+	ulong start, end;
+	int i;
+
+	for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
+#if defined(CONFIG_ARM) || defined(CONFIG_AVR32) ||

defined(COFNIG_NDS32)

|| \ +defined(CONFIG_SANDBOX) || defined(CONFIG_X86)

Quoted 16 lines

drivers/video/cfb_console.c static void *video_logo(void) · line 1685

Quoted 13 lines
drivers/video/cfb_console.c +13 -0
+		start = bd->bi_dram[i].start;
+		end = bd->bi_dram[i].start + bd->bi_dram[i].size - 1;
+#else
+		start = bd->bi_memstart;
+		end = bd->bi_memsize;
+#endif
+
+		if ((ulong)video_fb_address >= start &&
+		    (ulong)video_fb_address < end)
+			return 1;
+	}
+	return 0;
+}

is this necessary ? the cache funcs should take care of this automatically.

Quoted 2 lines

Currently they don't, or at least on some architectures. Or did you mean that the cache instructions should take care of this?

imo, cache flush functions should be safe to call on any memory address (where there is data that could be dma-ed from). this is how Linux works.

otherwise, this function ends up getting duplicated in many places and i can't possibly see how that's an improvement.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120501/ae23042e/attachment.pgp>

#5 lore raw

PATCH 1/1 video: cfb_console: flush dcache for frame buffer in DRAM

In reply to Anatolij Gustschin

Dear Anatolij Gustschin,

Quoted 4 lines

Data cache flushing is required for frame buffer in RAM to fix the distorted console text output. Currently this text distortion is observed with cfb on beageboard and N900 when running with data cache enabled.

beagleboard ;-)

Quoted 31 lines
---
 drivers/video/cfb_console.c |   35 +++++++++++++++++++++++++++++++++++
 1 files changed, 35 insertions(+), 0 deletions(-)
drivers/video/cfb_console.c +4 -0
index 904caf7..dd7ccb7 100644
@@ -360,6 +360,8 @@ void console_cursor(int state);
 extern void video_get_info_str(int line_number,	char *info);
 #endif
 
+DECLARE_GLOBAL_DATA_PTR;
+
 /* Locals */
 static GraphicDevice *pGD;	/* Pointer to Graphic array */
 
@@ -377,6 +379,8 @@ static int console_row;		/* cursor row */
 
 static u32 eorx, fgx, bgx;	/* color pats */
 
+static int cfb_do_flush_cache;
+
 static const int video_font_draw_table8[] = {
 	0x00000000, 0x000000ff, 0x0000ff00, 0x0000ffff,
 	0x00ff0000, 0x00ff00ff, 0x00ffff00, 0x00ffffff,
@@ -553,6 +557,8 @@ static void video_drawchars(int xx, int yy, unsigned

char *s, int count) SWAP32((video_font_draw_table32

drivers/video/cfb_console.c static void video_drawchars(int xx, int yy, unsigned char *s, int count) · line 561

Quoted 4 lines
drivers/video/cfb_console.c +2 -0
 						[bits & 15][3] & eorx) ^ bgx);
 			}
+			if (cfb_do_flush_cache)
+				flush_cache((ulong)dest0, 32);

flush_dcache_range() ?

drivers/video/cfb_console.c static void video_invertchar(int xx, int yy) · line 631

Quoted 9 lines
drivers/video/cfb_console.c +2 -0
 			dest0 += VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE;
 			s++;
 		}
@@ -621,6 +627,8 @@ static void video_invertchar(int xx, int yy)
 		for (x = firstx; x < lastx; x++) {
 			u8 *dest = (u8 *)(video_fb_address) + x + y;
 			*dest = ~*dest;
+			if (cfb_do_flush_cache)
+				flush_cache((ulong)dest, 4);

DTTO

Quoted 28 lines
drivers/video/cfb_console.c +13 -0
 		}
 	}
 }
@@ -717,6 +725,8 @@ static void console_scrollup(void)
 #else
 	memsetl(CONSOLE_ROW_LAST, CONSOLE_ROW_SIZE >> 2, CONSOLE_BG_COL);
 #endif
+	if (cfb_do_flush_cache)
+		flush_cache((ulong)CONSOLE_ROW_FIRST, CONSOLE_SIZE);
 }
 
 static void console_back(void)
@@ -1651,6 +1661,29 @@ static void *video_logo(void)
 }
 #endif
 
+static int cfb_fb_is_in_dram(void)
+{
+	bd_t *bd = gd->bd;
+	ulong start, end;
+	int i;
+
+	for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
+#if defined(CONFIG_ARM) || defined(CONFIG_AVR32) || defined(COFNIG_NDS32)
 || \ +defined(CONFIG_SANDBOX) || defined(CONFIG_X86)
+		start = bd->bi_dram[i].start;
+		end = bd->bi_dram[i].start + bd->bi_dram[i].size - 1;
+#else

drivers/video/cfb_console.c static void *video_logo(void) · line 1685

Quoted 10 lines
drivers/video/cfb_console.c +10 -0
+		start = bd->bi_memstart;
+		end = bd->bi_memsize;
+#endif
+
+		if ((ulong)video_fb_address >= start &&
+		    (ulong)video_fb_address < end)
+			return 1;
+	}
+	return 0;
+}

Can't you have SRAM cached too? ;-)

Quoted 13 lines
drivers/video/cfb_console.c +3 -0
+
 static int video_init(void)
 {
 	unsigned char color8;
@@ -1664,6 +1697,8 @@ static int video_init(void)
 	video_init_hw_cursor(VIDEO_FONT_WIDTH, VIDEO_FONT_HEIGHT);
 #endif
 
+	cfb_do_flush_cache = cfb_fb_is_in_dram() && dcache_status();
+
 	/* Init drawing pats */
 	switch (VIDEO_DATA_FORMAT) {
 	case GDF__8BIT_INDEX:
#6 lore raw

PATCH 1/1 video: cfb_console: flush dcache for frame buffer in DRAM

Hi,

Quoted 9 lines · Marek Vasut

Dear Anatolij Gustschin,

Quoted 4 lines

Data cache flushing is required for frame buffer in RAM to fix the distorted console text output. Currently this text distortion is observed with cfb on beageboard and N900 when running with data cache enabled.

beagleboard ;-)

Regarding this patch, can I suggest also looking at this possibly more generic patch that I originally did for Tegra? The series is here:

http://patchwork.ozlabs.org/user/bundle/2869/

and in particular these patches from the series:

arm: Add control over cachability of memory regions
lcd: Add CONFIG_ALIGN_LCD_TO_SECTION to align lcd for MMU
lcd: Add support for flushing LCD fb from dcache after update
tegra: Align LCD frame buffer to section boundary
tegra: Support control of cache settings for LCD
tegra: fdt: Add LCD definitions for Seaboard
lcd: Add CONSOLE_SCROLL_LINES option to speed console

Regards,
Simon

Quoted 112 lines
Quoted 32 lines
---
 drivers/video/cfb_console.c |   35 +++++++++++++++++++++++++++++++++++
 1 files changed, 35 insertions(+), 0 deletions(-)
drivers/video/cfb_console.c +4 -0
index 904caf7..dd7ccb7 100644
@@ -360,6 +360,8 @@ void console_cursor(int state);
 extern void video_get_info_str(int line_number,      char *info);
 #endif
 
+DECLARE_GLOBAL_DATA_PTR;
+
 /* Locals */
 static GraphicDevice *pGD;   /* Pointer to Graphic array */
 
@@ -377,6 +379,8 @@ static int console_row;           /* cursor row */
 
 static u32 eorx, fgx, bgx;   /* color pats */
 
+static int cfb_do_flush_cache;
+
 static const int video_font_draw_table8[] = {
      0x00000000, 0x000000ff, 0x0000ff00, 0x0000ffff,
      0x00ff0000, 0x00ff00ff, 0x00ffff00, 0x00ffffff,
@@ -553,6 +557,8 @@ static void video_drawchars(int xx, int yy, unsigned

char *s, int count) SWAP32((video_font_draw_table32

Quoted 1 line
                                              [bits & 15][3] & eorx) ^

bgx);

drivers/video/cfb_console.c static void video_drawchars(int xx, int yy, unsigned char *s, int count) · line 561

Quoted 3 lines
                      }
drivers/video/cfb_console.c +2 -0
+                     if (cfb_do_flush_cache)
+                             flush_cache((ulong)dest0, 32);

flush_dcache_range() ?

drivers/video/cfb_console.c static void video_invertchar(int xx, int yy) · line 631

Quoted 9 lines
                      dest0 += VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE;
                      s++;
              }
drivers/video/cfb_console.c +2 -0
@@ -621,6 +627,8 @@ static void video_invertchar(int xx, int yy)
              for (x = firstx; x < lastx; x++) {
                      u8 *dest = (u8 *)(video_fb_address) + x + y;
                      *dest = ~*dest;
+                     if (cfb_do_flush_cache)
+                             flush_cache((ulong)dest, 4);

DTTO

Quoted 14 lines
drivers/video/cfb_console.c +2 -0
              }
      }
 }
@@ -717,6 +725,8 @@ static void console_scrollup(void)
 #else
      memsetl(CONSOLE_ROW_LAST, CONSOLE_ROW_SIZE >> 2, CONSOLE_BG_COL);
 #endif
+     if (cfb_do_flush_cache)
+             flush_cache((ulong)CONSOLE_ROW_FIRST, CONSOLE_SIZE);
 }
 
 static void console_back(void)
@@ -1651,6 +1661,29 @@ static void *video_logo(void)
 }

drivers/video/cfb_console.c static void *video_logo(void) · line 1671

Quoted 10 lines
drivers/video/cfb_console.c +8 -0
 #endif
 
+static int cfb_fb_is_in_dram(void)
+{
+     bd_t *bd = gd->bd;
+     ulong start, end;
+     int i;
+
+     for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
+#if defined(CONFIG_ARM) || defined(CONFIG_AVR32) ||

defined(COFNIG_NDS32)

Quoted 4 lines
drivers/video/cfb_console.c +3 -0
 || \ +defined(CONFIG_SANDBOX) || defined(CONFIG_X86)
+             start = bd->bi_dram[i].start;
+             end = bd->bi_dram[i].start + bd->bi_dram[i].size - 1;
+#else

drivers/video/cfb_console.c static void *video_logo(void) · line 1685

Quoted 10 lines
drivers/video/cfb_console.c +10 -0
+             start = bd->bi_memstart;
+             end = bd->bi_memsize;
+#endif
+
+             if ((ulong)video_fb_address >= start &&
+                 (ulong)video_fb_address < end)
+                     return 1;
+     }
+     return 0;
+}

Can't you have SRAM cached too? ;-)

drivers/video/cfb_console.c static int video_init(void) · line 1704

Quoted 13 lines
drivers/video/cfb_console.c +3 -0
+
 static int video_init(void)
 {
      unsigned char color8;
@@ -1664,6 +1697,8 @@ static int video_init(void)
      video_init_hw_cursor(VIDEO_FONT_WIDTH, VIDEO_FONT_HEIGHT);
 #endif
 
+     cfb_do_flush_cache = cfb_fb_is_in_dram() && dcache_status();
+
      /* Init drawing pats */
      switch (VIDEO_DATA_FORMAT) {
      case GDF__8BIT_INDEX:

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

#7 lore raw

PATCH 1/1 video: cfb_console: flush dcache for frame buffer in DRAM

Hi Simon,

On Sun, 29 Apr 2012 22:56:01 -0700
Simon Glass <[email protected]> wrote:
...

Quoted 7 lines

Regarding this patch, can I suggest also looking at this possibly more generic patch that I originally did for Tegra? The series is here:

http://patchwork.ozlabs.org/user/bundle/2869/

and in particular these patches from the series:

Quoted 7 lines

arm: Add control over cachability of memory regions
lcd: Add CONFIG_ALIGN_LCD_TO_SECTION to align lcd for MMU
lcd: Add support for flushing LCD fb from dcache after update
tegra: Align LCD frame buffer to section boundary
tegra: Support control of cache settings for LCD
tegra: fdt: Add LCD definitions for Seaboard
lcd: Add CONSOLE_SCROLL_LINES option to speed console

Thanks for the reminder, I completely forgot about these LCD patches. I'll look at them soon.

Thanks,
Anatolij

#8 lore raw

PATCH 1/1 video: cfb_console: flush dcache for frame buffer in DRAM

In reply to Marek Vasut

Hi,

On Mon, 30 Apr 2012 04:25:50 +0200
Marek Vasut <[email protected]> wrote:
...

Quoted 4 lines
Quoted 2 lines

observed with cfb on beageboard and N900 when running with data cache enabled.

beagleboard ;-)

Thanks for catching that!!

...

Quoted 8 lines

drivers/video/cfb_console.c static void video_drawchars(int xx, int yy, unsigned char *s, int count) · line 561

Quoted 6 lines
(quoted diff) +0 -0
@@ -553,6 +557,8 @@ static void video_drawchars(int xx, int yy, unsigned

char *s, int count) SWAP32((video_font_draw_table32

drivers/video/cfb_console.c +2 -0
 						[bits & 15][3] & eorx) ^ bgx);
 			}
+			if (cfb_do_flush_cache)
+				flush_cache((ulong)dest0, 32);

flush_dcache_range() ?

I would have to calculate the end address, then. flush_cache() already does it for me :-)

...

Quoted 20 lines
Quoted 20 lines
drivers/video/cfb_console.c +15 -0
@@ -1651,6 +1661,29 @@ static void *video_logo(void)
 }
 #endif
 
+static int cfb_fb_is_in_dram(void)
+{
+	bd_t *bd = gd->bd;
+	ulong start, end;
+	int i;
+
+	for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
+#if defined(CONFIG_ARM) || defined(CONFIG_AVR32) || defined(COFNIG_NDS32)
 || \ +defined(CONFIG_SANDBOX) || defined(CONFIG_X86)
+		start = bd->bi_dram[i].start;
+		end = bd->bi_dram[i].start + bd->bi_dram[i].size - 1;
+#else
+		start = bd->bi_memstart;
+		end = bd->bi_memsize;
+#endif
+
Quoted 8 lines

drivers/video/cfb_console.c static void *video_logo(void) · line 1685

Quoted 6 lines
drivers/video/cfb_console.c +6 -0
+		if ((ulong)video_fb_address >= start &&
+		    (ulong)video_fb_address < end)
+			return 1;
+	}
+	return 0;
+}

Can't you have SRAM cached too? ;-)

I do not know. But who will put the framebuffer into SRAM? It is not big enough.

Thanks,
Anatolij

#9 lore raw

PATCH 1/1 video: cfb_console: flush dcache for frame buffer in DRAM

Dear Anatolij Gustschin,

Quoted 22 lines

Hi,

On Mon, 30 Apr 2012 04:25:50 +0200
Marek Vasut <[email protected]> wrote:
...

Quoted 4 lines
Quoted 2 lines

observed with cfb on beageboard and N900 when running with data cache enabled.

beagleboard ;-)

Thanks for catching that!!

...

Quoted 7 lines
Quoted 7 lines
(quoted diff) +0 -0
@@ -553,6 +557,8 @@ static void video_drawchars(int xx, int yy,

unsigned char *s, int count) SWAP32((video_font_draw_table32

drivers/video/cfb_console.c +0 -0
 						[bits & 15][3] & eorx) ^ bgx);
 
 			}
Quoted 7 lines
Quoted 4 lines

drivers/video/cfb_console.c static void video_drawchars(int xx, int yy, unsigned char *s, int count) · line 561

Quoted 2 lines
drivers/video/cfb_console.c +2 -0
+			if (cfb_do_flush_cache)
+				flush_cache((ulong)dest0, 32);

flush_dcache_range() ?

I would have to calculate the end address, then. flush_cache() already does it for me :-)

Well ... that's correct. Maybe someone should rename it to flush_dcache_size() or something ...

Quoted 36 lines

...

Quoted 17 lines
Quoted 17 lines
drivers/video/cfb_console.c +8 -0
@@ -1651,6 +1661,29 @@ static void *video_logo(void)
 
 }
 #endif
 
+static int cfb_fb_is_in_dram(void)
+{
+	bd_t *bd = gd->bd;
+	ulong start, end;
+	int i;
+
+	for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
+#if defined(CONFIG_ARM) || defined(CONFIG_AVR32) ||
 defined(COFNIG_NDS32)
 

|| \ +defined(CONFIG_SANDBOX) || defined(CONFIG_X86)

Quoted 15 lines

drivers/video/cfb_console.c static void *video_logo(void) · line 1685

Quoted 13 lines
drivers/video/cfb_console.c +13 -0
+		start = bd->bi_dram[i].start;
+		end = bd->bi_dram[i].start + bd->bi_dram[i].size - 1;
+#else
+		start = bd->bi_memstart;
+		end = bd->bi_memsize;
+#endif
+
+		if ((ulong)video_fb_address >= start &&
+		    (ulong)video_fb_address < end)
+			return 1;
+	}
+	return 0;
+}

Can't you have SRAM cached too? ;-)

Quoted 2 lines

I do not know. But who will put the framebuffer into SRAM? It is not big enough.

Someone who has small LCD and wants to save dram bandwidth (oh, this sentence sounds stupid on its own). But maybe if you want to use LCD in SPL?

Quoted 3 lines

Thanks,
Anatolij

Best regards,
Marek Vasut

#10 lore raw

PATCH 1/1 video: cfb_console: flush dcache for frame buffer in DRAM

Hi,

On Mon, 30 Apr 2012 17:21:51 +0200
Marek Vasut <[email protected]> wrote:
...

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Can't you have SRAM cached too? ;-)

I do not know. But who will put the framebuffer into SRAM? It is not big enough.

Someone who has small LCD and wants to save dram bandwidth (oh, this sentence sounds stupid on its own). But maybe if you want to use LCD in SPL?

If someone really needs it, he can always add it later :-)

Thanks,
Anatolij

#11 lore raw

PATCH 1/1 video: cfb_console: flush dcache for frame buffer in DRAM

Dear Anatolij Gustschin,

Quoted 8 lines

Hi,

On Mon, 30 Apr 2012 17:21:51 +0200
Marek Vasut <[email protected]> wrote:
...

Quoted 2 lines
Quoted 2 lines
Quoted 1 line

Can't you have SRAM cached too? ;-)

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

I do not know. But who will put the framebuffer into SRAM? It is not big enough.

Someone who has small LCD and wants to save dram bandwidth (oh, this sentence sounds stupid on its own). But maybe if you want to use LCD in SPL?

If someone really needs it, he can always add it later :-)

I won't argue further :-)

Quoted 2 lines

Thanks,
Anatolij

Best regards,
Marek Vasut

#12 lore raw

PATCH 1/1 video: cfb_console: flush dcache for frame buffer in DRAM

In reply to Anatolij Gustschin
Quoted 10 lines · On Sat, 28 Apr 2012 17:04:07 +0200 Anatolij Gustschin <[email protected]> wrote:

Data cache flushing is required for frame buffer in RAM to fix the distorted console text output. Currently this text distortion is observed with cfb on beageboard and N900 when running with data cache enabled.

---
 drivers/video/cfb_console.c |   35 +++++++++++++++++++++++++++++++++++
 1 files changed, 35 insertions(+), 0 deletions(-)

Applied to u-boot-video/master after rebasing and fixing commit log.

Anatolij

#13 lore raw

PATCH 1/1 video: cfb_console: flush dcache for frame buffer in DRAM

Quoted 7 lines · On Tuesday 05 June 2012 03:28:40 Anatolij Gustschin wrote:
Quoted 4 lines · On Sat, 28 Apr 2012 17:04:07 +0200 Anatolij Gustschin wrote:

Data cache flushing is required for frame buffer in RAM to fix the distorted console text output. Currently this text distortion is observed with cfb on beageboard and N900 when running with data cache enabled.

Applied to u-boot-video/master after rebasing and fixing commit log.

this patch is still wrong for the reasons i cited earlier. your cache functions are broken, not the driver.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120719/a4f51a6b/attachment.pgp>

#14 lore raw

PATCH 1/1 video: cfb_console: flush dcache for frame buffer in DRAM

Dear Mike Frysinger,

Quoted 11 lines · On Tuesday 05 June 2012 03:28:40 Anatolij Gustschin wrote:
Quoted 7 lines · On Sat, 28 Apr 2012 17:04:07 +0200 Anatolij Gustschin wrote:
Quoted 4 lines

Data cache flushing is required for frame buffer in RAM to fix the distorted console text output. Currently this text distortion is observed with cfb on beageboard and N900 when running with data cache enabled.

Applied to u-boot-video/master after rebasing and fixing commit log.

this patch is still wrong for the reasons i cited earlier. your cache functions are broken, not the driver.

The cache stuff is completely borked on ARM, I have no idea why people enable it.

Best regards,
Marek Vasut

#15 lore raw

PATCH 1/1 video: cfb_console: flush dcache for frame buffer in DRAM

Quoted 8 lines · On Thursday 19 July 2012 11:49:20 Marek Vasut wrote:

Dear Mike Frysinger,

Quoted 7 lines · On Tuesday 05 June 2012 03:28:40 Anatolij Gustschin wrote:
Quoted 6 lines · On Sat, 28 Apr 2012 17:04:07 +0200 Anatolij Gustschin wrote:
Quoted 4 lines

Data cache flushing is required for frame buffer in RAM to fix the distorted console text output. Currently this text distortion is observed with cfb on beageboard and N900 when running with data cache enabled.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Applied to u-boot-video/master after rebasing and fixing commit log.

this patch is still wrong for the reasons i cited earlier. your cache functions are broken, not the driver.

The cache stuff is completely borked on ARM, I have no idea why people enable it.

in this case, it's making it worse for other arches, and setting bad precedents in the process

i think Simon's solution is a good middle ground:
lcd: Add support for flushing LCD fb from dcache after update
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120719/4e88e505/attachment.pgp>