Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

unicore32 framebuffer fix: get videomemory by __get_free_pages() and make it floatable

1. get videomemory by __get_free_pages() in fb-puv3.c
2. remove resource reservation for old fixed UNIGFX_MMAP & UVC_MMAP space
3. remove unused macros: PKUNTIY_UNIGFX_MMAP_BASE, PKUNITY_UNIGFX_MMAP_SIZE,
PKUNITY_UVC_MMAP_BASE, PKUNITY_UVC_MMAP_SIZE and KUSER_UNIGFX_BASE
4. remove unused header linux/vmalloc.h in fb-puv3.h

Signed-off-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
Acked-by: Arnd Bergmann <arnd@arndb.de>

+19 -60
-10
arch/unicore32/include/mach/PKUnity.h
··· 24 24 #define PKUNITY_MMIO_BASE 0x80000000 /* 0x80000000 - 0xFFFFFFFF 2GB */ 25 25 26 26 /* 27 - * PKUNITY Memory Map Addresses: 0x0D000000 - 0x0EFFFFFF (32MB) 28 - * 0x0D000000 - 0x0DFFFFFF 16MB: for UVC 29 - * 0x0E000000 - 0x0EFFFFFF 16MB: for UNIGFX 30 - */ 31 - #define PKUNITY_UVC_MMAP_BASE 0x0D000000 32 - #define PKUNITY_UVC_MMAP_SIZE 0x01000000 /* 16MB */ 33 - #define PKUNITY_UNIGFX_MMAP_BASE 0x0E000000 34 - #define PKUNITY_UNIGFX_MMAP_SIZE 0x01000000 /* 16MB */ 35 - 36 - /* 37 27 * PKUNITY System Bus Addresses (PCI): 0x80000000 - 0xBFFFFFFF (1GB) 38 28 * 0x80000000 - 0x8000000B 12B PCI Configuration regs 39 29 * 0x80010000 - 0x80010250 592B PCI Bridge Base
-1
arch/unicore32/include/mach/memory.h
··· 50 50 51 51 /* kuser area */ 52 52 #define KUSER_VECPAGE_BASE (KUSER_BASE + UL(0x3fff0000)) 53 - #define KUSER_UNIGFX_BASE (PAGE_OFFSET + PKUNITY_UNIGFX_MMAP_BASE) 54 53 /* kuser_vecpage (0xbfff0000) is ro, and vectors page (0xffff0000) is rw */ 55 54 #define kuser_vecpage_to_vectors(x) ((x) - (KUSER_VECPAGE_BASE) \ 56 55 + (VECTORS_BASE))
-5
arch/unicore32/kernel/puv3-core.c
··· 99 99 .end = io_v2p(PKUNITY_UNIGFX_BASE) + 0xfff, 100 100 .flags = IORESOURCE_MEM, 101 101 }, 102 - [1] = { 103 - .start = PKUNITY_UNIGFX_MMAP_BASE, 104 - .end = PKUNITY_UNIGFX_MMAP_BASE + PKUNITY_UNIGFX_MMAP_SIZE, 105 - .flags = IORESOURCE_MEM, 106 - }, 107 102 }; 108 103 109 104 static struct resource puv3_rtc_resources[] = {
+2 -13
arch/unicore32/kernel/setup.c
··· 64 64 */ 65 65 static struct resource mem_res[] = { 66 66 { 67 - .name = "Video RAM", 68 - .start = 0, 69 - .end = 0, 70 - .flags = IORESOURCE_MEM 71 - }, 72 - { 73 67 .name = "Kernel text", 74 68 .start = 0, 75 69 .end = 0, ··· 77 83 } 78 84 }; 79 85 80 - #define video_ram mem_res[0] 81 - #define kernel_code mem_res[1] 82 - #define kernel_data mem_res[2] 86 + #define kernel_code mem_res[0] 87 + #define kernel_data mem_res[1] 83 88 84 89 /* 85 90 * These functions re-use the assembly code in head.S, which ··· 217 224 kernel_data.end <= res->end) 218 225 request_resource(res, &kernel_data); 219 226 } 220 - 221 - video_ram.start = PKUNITY_UNIGFX_MMAP_BASE; 222 - video_ram.end = PKUNITY_UNIGFX_MMAP_BASE + PKUNITY_UNIGFX_MMAP_SIZE; 223 - request_resource(&iomem_resource, &video_ram); 224 227 } 225 228 226 229 static void (*init_machine)(void) __initdata;
-20
arch/unicore32/mm/mmu.c
··· 338 338 * and can only be in node 0. 339 339 */ 340 340 memblock_reserve(__pa(swapper_pg_dir), PTRS_PER_PGD * sizeof(pgd_t)); 341 - 342 - #ifdef CONFIG_PUV3_UNIGFX 343 - /* 344 - * These should likewise go elsewhere. They pre-reserve the 345 - * screen/video memory region at the 48M~64M of main system memory. 346 - */ 347 - memblock_reserve(PKUNITY_UNIGFX_MMAP_BASE, PKUNITY_UNIGFX_MMAP_SIZE); 348 - memblock_reserve(PKUNITY_UVC_MMAP_BASE, PKUNITY_UVC_MMAP_SIZE); 349 - #endif 350 341 } 351 342 352 343 /* ··· 360 369 361 370 for (addr = VMALLOC_END; addr; addr += PGDIR_SIZE) 362 371 pmd_clear(pmd_off_k(addr)); 363 - 364 - /* 365 - * Create a mapping for UniGFX VRAM 366 - */ 367 - #ifdef CONFIG_PUV3_UNIGFX 368 - map.pfn = __phys_to_pfn(PKUNITY_UNIGFX_MMAP_BASE); 369 - map.virtual = KUSER_UNIGFX_BASE; 370 - map.length = PKUNITY_UNIGFX_MMAP_SIZE; 371 - map.type = MT_KUSER; 372 - create_mapping(&map); 373 - #endif 374 372 375 373 /* 376 374 * Create a mapping for the machine vectors at the high-vectors
+17 -11
drivers/video/fb-puv3.c
··· 13 13 #include <linux/module.h> 14 14 #include <linux/kernel.h> 15 15 #include <linux/errno.h> 16 - #include <linux/vmalloc.h> 17 16 #include <linux/platform_device.h> 18 17 #include <linux/clk.h> 19 18 #include <linux/fb.h> ··· 530 531 return -EINVAL; 531 532 } 532 533 533 - writel(PKUNITY_UNIGFX_MMAP_BASE, UDE_FSA); 534 + writel(info->fix.smem_start, UDE_FSA); 534 535 writel(info->var.yres, UDE_LS); 535 536 writel(get_line_length(info->var.xres, 536 537 info->var.bits_per_pixel) >> 3, UDE_PS); ··· 679 680 struct fb_info *info; 680 681 u32 unifb_regs[UNIFB_REGS_NUM]; 681 682 int retval = -ENOMEM; 682 - struct resource *iomem, *mapmem; 683 + struct resource *iomem; 684 + void *videomemory; 685 + 686 + videomemory = (void *)__get_free_pages(GFP_KERNEL | __GFP_COMP, 687 + get_order(UNIFB_MEMSIZE)); 688 + if (!videomemory) 689 + goto err; 690 + 691 + memset(videomemory, 0, UNIFB_MEMSIZE); 692 + 693 + unifb_fix.smem_start = virt_to_phys(videomemory); 694 + unifb_fix.smem_len = UNIFB_MEMSIZE; 695 + 696 + iomem = platform_get_resource(dev, IORESOURCE_MEM, 0); 697 + unifb_fix.mmio_start = iomem->start; 683 698 684 699 info = framebuffer_alloc(sizeof(u32)*256, &dev->dev); 685 700 if (!info) 686 701 goto err; 687 702 688 - info->screen_base = (char __iomem *)KUSER_UNIGFX_BASE; 703 + info->screen_base = (char __iomem *)videomemory; 689 704 info->fbops = &unifb_ops; 690 705 691 706 retval = fb_find_mode(&info->var, info, NULL, ··· 707 694 708 695 if (!retval || (retval == 4)) 709 696 info->var = unifb_default; 710 - 711 - iomem = platform_get_resource(dev, IORESOURCE_MEM, 0); 712 - unifb_fix.mmio_start = iomem->start; 713 - 714 - mapmem = platform_get_resource(dev, IORESOURCE_MEM, 1); 715 - unifb_fix.smem_start = mapmem->start; 716 - unifb_fix.smem_len = UNIFB_MEMSIZE; 717 697 718 698 info->fix = unifb_fix; 719 699 info->pseudo_palette = info->par;