Commit 5633a296ebb970d0a6be839fb37eaf8a11aa35f8

Authored by Hans de Goede
1 parent 8910a7d37a

sunxi: video: Do not use CONFIG_SYS_MEM_TOP_HIDE for the framebuffer

Do not use CONFIG_SYS_MEM_TOP_HIDE for the framebuffer, instead override
board_get_usable_ram_top to make sure that u-boot is not relocated into the
area where we want to use the framebuffer, and patch the devicetree from
sunxi_simplefb_setup() to tell the kernel to not touch the framebuffer.

This makes u-boot properly see the framebuffer as dram, and initalize the
level 2 cache for it, fixing the very slow cfb scrolling problem.

As an added bonus this stops us from reserving the framebuffer when simplefb
is not used because an older kernel is booted, or hdp is used and no hdmi
cable was plugged in, freeing up the memory for kernel use in these cases.

Reported-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Ian Campbell <ijc@hellion.org.uk>

Showing 2 changed files with 24 additions and 6 deletions Side-by-side Diff

drivers/video/sunxi_display.c
... ... @@ -1060,6 +1060,11 @@
1060 1060 return NULL; /* never reached */
1061 1061 }
1062 1062  
  1063 +ulong board_get_usable_ram_top(ulong total_size)
  1064 +{
  1065 + return gd->ram_top - CONFIG_SUNXI_MAX_FB_SIZE;
  1066 +}
  1067 +
1063 1068 void *video_hw_init(void)
1064 1069 {
1065 1070 static GraphicDevice *graphic_device = &sunxi_display.graphic_device;
... ... @@ -1076,7 +1081,7 @@
1076 1081 memset(&sunxi_display, 0, sizeof(struct sunxi_display));
1077 1082  
1078 1083 printf("Reserved %dkB of RAM for Framebuffer.\n",
1079   - CONFIG_SUNXI_FB_SIZE >> 10);
  1084 + CONFIG_SUNXI_MAX_FB_SIZE >> 10);
1080 1085 gd->fb_base = gd->ram_top;
1081 1086  
1082 1087 video_get_ctfb_res_modes(RES_MODE_1024x768, 24, &mode,
... ... @@ -1194,6 +1199,7 @@
1194 1199 {
1195 1200 static GraphicDevice *graphic_device = &sunxi_display.graphic_device;
1196 1201 int offset, ret;
  1202 + u64 start, size;
1197 1203 const char *pipeline = NULL;
1198 1204  
1199 1205 #ifdef CONFIG_MACH_SUN4I
... ... @@ -1235,6 +1241,20 @@
1235 1241 if (offset < 0) {
1236 1242 eprintf("Cannot setup simplefb: node not found\n");
1237 1243 return 0; /* Keep older kernels working */
  1244 + }
  1245 +
  1246 + /*
  1247 + * Do not report the framebuffer as free RAM to the OS, note we cannot
  1248 + * use fdt_add_mem_rsv() here, because then it is still seen as RAM,
  1249 + * and e.g. Linux refuses to iomap RAM on ARM, see:
  1250 + * linux/arch/arm/mm/ioremap.c around line 301.
  1251 + */
  1252 + start = gd->bd->bi_dram[0].start;
  1253 + size = gd->bd->bi_dram[0].size - CONFIG_SUNXI_MAX_FB_SIZE;
  1254 + ret = fdt_fixup_memory_banks(blob, &start, &size, 1);
  1255 + if (ret) {
  1256 + eprintf("Cannot setup simplefb: Error reserving memory\n");
  1257 + return ret;
1238 1258 }
1239 1259  
1240 1260 ret = fdt_setup_simplefb_node(blob, offset, gd->fb_base,
include/configs/sunxi-common.h
... ... @@ -210,10 +210,10 @@
210 210  
211 211 #ifdef CONFIG_VIDEO
212 212 /*
213   - * The amount of RAM that is reserved for the FB. This will not show up as
214   - * RAM to the kernel, but will be reclaimed by a KMS driver in future.
  213 + * The amount of RAM to keep free at the top of RAM when relocating u-boot,
  214 + * to use as framebuffer. This must be a multiple of 4096.
215 215 */
216   -#define CONFIG_SUNXI_FB_SIZE (9 << 20)
  216 +#define CONFIG_SUNXI_MAX_FB_SIZE (9 << 20)
217 217  
218 218 /* Do we want to initialize a simple FB? */
219 219 #define CONFIG_VIDEO_DT_SIMPLEFB
... ... @@ -230,8 +230,6 @@
230 230 #define CONFIG_CONSOLE_MUX
231 231 /* stop x86 thinking in cfbconsole from trying to init a pc keyboard */
232 232 #define CONFIG_VGA_AS_SINGLE_DEVICE
233   -
234   -#define CONFIG_SYS_MEM_TOP_HIDE ((CONFIG_SUNXI_FB_SIZE + 0xFFF) & ~0xFFF)
235 233  
236 234 /* To be able to hook simplefb into dt */
237 235 #ifdef CONFIG_VIDEO_DT_SIMPLEFB