MIPS: add hook for platforms to register CMA memory
Subsystems (2)
PATCH 3/3 video: fbdev: au1200fb: alloc mem from coherent pool/CMA
In reply to Manuel LaussChange framebuffer memory allocation to grab some memory from the coherent pool, which on MIPS causes the allocator to first try to look for CMA-reserved memory.
---
Tested on Db1200 and Db1300 boards, with no issues
drivers/video/fbdev/au1200fb.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-)
drivers/video/fbdev/au1200fb.c +1 -12
@@ -1647,7 +1647,6 @@ static int au1200fb_drv_probe(struct platform_device *dev)struct au1200fb_device *fbdev;struct au1200fb_platdata *pd;struct fb_info *fbi =NULL ; -unsigned long page;int bpp, plane, ret, irq;print_info ("" DRIVER_DESC "" );
@@ -1693,7 +1692,7 @@ static int au1200fb_drv_probe(struct platform_device *dev)/* Allocate the framebuffer to the maximum screen size */ fbdev->fb_len = (win->w[plane].xres * win->w[plane].yres * bpp) /8 ; - fbdev->fb_mem =dmam_alloc_noncoherent (&dev->dev, + fbdev->fb_mem =dmam_alloc_coherent (&dev->dev,PAGE_ALIGN (fbdev->fb_len), &fbdev->fb_phys,GFP_KERNEL );if (!fbdev->fb_mem) {
@@ -1702,16 +1701,6 @@ static int au1200fb_drv_probe(struct platform_device *dev)return -ENOMEM ; } -/* -* Set page reserved so that mmap will work. This is necessary -* since we'll be remapping normal memory. -*/ -for (page = (unsigned long )fbdev->fb_phys; - page <PAGE_ALIGN ((unsigned long )fbdev->fb_phys + - fbdev->fb_len); - page +=PAGE_SIZE ) { -SetPageReserved (pfn_to_page (page >>PAGE_SHIFT ));/* LCD DMA is NOT coherent on Au1200 */ - }print_dbg ("Framebuffer memory map at %p" , fbdev->fb_mem);print_dbg ("phys=0x%08x, size=%dK" , fbdev->fb_phys, fbdev->fb_len /1024 );
Signature · 1 line
2.5.3
PATCH 1/3 MIPS: add hook for platforms to register CMA memory
Add a hook which is called after MIPS CMA memory reservation to allow platforms to register device-specific CMA areas. I'm going to use this for the Au1200/Au1300 framebuffer initially.
---
Tested on Db1200/Db1300 and Db1500. I found that this is the only place in the initcall-chain where allocating CMA memory for devices is actually possible on MIPS/Alchemy.
arch/mips/include/asm/bootinfo.h | 5 +++++ arch/mips/kernel/setup.c | 7 +++++++ 2 files changed, 12 insertions(+)
arch/mips/include/asm/bootinfo.h +5 -0
@@ -132,6 +132,11 @@ extern unsigned long fw_arg0, fw_arg1, fw_arg2, fw_arg3;*/ extern void plat_mem_setup (void ); +/* +* optional hook to reserve CMA memory for devices +*/ +extern void (*plat_reserve_mem)(void ); +#ifdef CONFIG_SWIOTLB /* * Optional platform hook to call swiotlb_setup().
arch/mips/kernel/setup.c +7 -0
@@ -71,6 +71,8 @@ char __initdata arcs_cmdline[COMMAND_LINE_SIZE];static char __initdata builtin_cmdline[COMMAND_LINE_SIZE ] =CONFIG_CMDLINE ;#endif +void (*plat_reserve_mem)(void )__initdata =NULL ; +/* * mips_io_port_base is the begin of the address space to which x86 style * I/O ports are mapped.
@@ -678,7 +680,12 @@ static void __init arch_mem_init(char **cmdline_p)plat_swiotlb_setup ();paging_init (); +/* allocate default CMA area */ dma_contiguous_reserve (PFN_PHYS (max_low_pfn)); +/* allow platforms to reserve CMA memory for devices */ +if (plat_reserve_mem) +plat_reserve_mem (); +/* Tell bootmem about cma reserved memblock section */ for_each_memblock (reserved, reg)if (reg->size !=0 )
Signature · 1 line
2.5.3
PATCH 2/3 MIPS: Alchemy: devboards: register CMA memory for Au1200 framebuffer
Use the newly introduced CMA memory setup hook to register a few megabytes for the Au1200/Au1300 framebuffer.
---
Tested on Db1200 and Db1300.
arch/mips/alchemy/devboards/db1200.c | 62 +++++++++++++++++++++++------------- arch/mips/alchemy/devboards/db1300.c | 13 ++++++++ 2 files changed, 52 insertions(+), 23 deletions(-)
arch/mips/alchemy/devboards/db1200.c +39 -23
@@ -19,6 +19,7 @@*/ #include <linux/clk.h> +#include <linux/dma-contiguous.h> #include <linux/dma-mapping.h> #include <linux/gpio.h> #include <linux/i2c.h>
@@ -37,6 +38,7 @@#include <linux/spi/flash.h> #include <linux/smc91x.h> #include <linux/ata_platform.h> +#include <asm/bootinfo.h> /* plat_reserve_mem hook */ #include <asm/mach-au1x00/au1000.h> #include <asm/mach-au1x00/au1100_mmc.h> #include <asm/mach-au1x00/au1xxx_dbdma.h>
@@ -128,29 +130,6 @@ static int __init db1200_detect_board(void)return 1 ;/* it's neither */ } -int __init db1200_board_setup (void ) -{ -unsigned short whoami; - -if (db1200_detect_board ()) -return -ENODEV ; - - whoami =bcsr_read (BCSR_WHOAMI ); -switch (BCSR_WHOAMI_BOARD (whoami)) { -case BCSR_WHOAMI_PB1200_DDR1 : -case BCSR_WHOAMI_PB1200_DDR2 : -case BCSR_WHOAMI_DB1200 : -break ; -default : -return -ENODEV ; - } - -printk (KERN_INFO "Alchemy/AMD/RMI %s Board, CPLD Rev %d" -" Board-ID %d Daughtercard ID %d\n" ,get_system_type (), - (whoami >>4 ) &0xf , (whoami >>8 ) &0xf , whoami &0xf ); - -return 0 ; -}/******************************************************************************/
@@ -961,3 +940,40 @@ int __init db1200_dev_setup(void)return 0 ; } + +static void __init db1200_reserve_mem (void ) +{ +int ret; + +/* reserve 64MB for the framebuffer (2048x2048x32 * 4 windows) */ + ret =dma_declare_contiguous (&au1200_lcd_dev.dev,64 <<20 ,0 ,0 ); +if (ret) +pr_err ("DB1200: failed to reserve 64MB for LCD\n" ); +} + +int __init db1200_board_setup (void ) +{ +unsigned short whoami; + +if (db1200_detect_board ()) +return -ENODEV ; + + whoami =bcsr_read (BCSR_WHOAMI ); +switch (BCSR_WHOAMI_BOARD (whoami)) { +case BCSR_WHOAMI_PB1200_DDR1 : +case BCSR_WHOAMI_PB1200_DDR2 : +case BCSR_WHOAMI_DB1200 : +break ; +default : +return -ENODEV ; + } + +printk (KERN_INFO "Alchemy/AMD/RMI %s Board, CPLD Rev %d" +" Board-ID %d Daughtercard ID %d\n" ,get_system_type (), + (whoami >>4 ) &0xf , (whoami >>8 ) &0xf , whoami &0xf ); + + + plat_reserve_mem = db1200_reserve_mem; + +return 0 ; +}
arch/mips/alchemy/devboards/db1300.c +13 -0
@@ -6,6 +6,7 @@#include <linux/clk.h> #include <linux/dma-mapping.h> +#include <linux/dma-contiguous.h> #include <linux/gpio.h> #include <linux/gpio_keys.h> #include <linux/init.h>
@@ -23,6 +24,7 @@#include <linux/smsc911x.h> #include <linux/wm97xx.h> +#include <asm/bootinfo.h> /* plat_reserve_mem hook */ #include <asm/mach-au1x00/au1000.h> #include <asm/mach-au1x00/gpio-au1300.h> #include <asm/mach-au1x00/au1100_mmc.h>
@@ -841,6 +843,15 @@ int __init db1300_dev_setup(void)return platform_add_devices (db1300_dev,ARRAY_SIZE (db1300_dev)); } +static void __init db1300_reserve_mem (void ) +{ +int ret; + +/* reserve 64MB for the framebuffer (2048x2048x32 * 4 windows) */ + ret =dma_declare_contiguous (&db1300_lcd_dev.dev,64 <<20 ,0 ,0 ); +if (ret) +pr_err ("DB1300: failed to reserve 64MB for LCD\n" ); +}int __init db1300_board_setup (void ) {
@@ -865,5 +876,7 @@ int __init db1300_board_setup(void)alchemy_uart_enable (AU1300_UART1_PHYS_ADDR );alchemy_uart_enable (AU1300_UART3_PHYS_ADDR ); + plat_reserve_mem = db1300_reserve_mem; +return 0 ; }
Signature · 1 line
2.5.3
Quoted 5 lines · Manuel Lauss
Add a hook which is called after MIPS CMA memory reservation to allow platforms to register device-specific CMA areas. I'm going to use this for the Au1200/Au1300 framebuffer initially.
Signed-off-by Manuel Lauss <[email protected]>
This is also useful for BMIPS_GENERIC platforms where we may need to do custom memory reservations.
Thanks!
Quoted 52 lines
---
Tested on Db1200/Db1300 and Db1500. I found that this is the only place in the initcall-chain where allocating CMA memory for devices is actually possible on MIPS/Alchemy.arch/mips/include/asm/bootinfo.h | 5 +++++ arch/mips/kernel/setup.c | 7 +++++++ 2 files changed, 12 insertions(+)arch/mips/include/asm/bootinfo.h +5
-0@@ -132,6 +132,11 @@ extern unsigned long fw_arg0, fw_arg1, fw_arg2, fw_arg3;*/ extern void plat_mem_setup (void ); +/* +* optional hook to reserve CMA memory for devices +*/ +extern void (*plat_reserve_mem)(void ); +#ifdef CONFIG_SWIOTLB /* * Optional platform hook to call swiotlb_setup(). arch/mips/kernel/setup.c +7
-0@@ -71,6 +71,8 @@ char __initdata arcs_cmdline[COMMAND_LINE_SIZE];static char __initdata builtin_cmdline[COMMAND_LINE_SIZE ] =CONFIG_CMDLINE ;#endif +void (*plat_reserve_mem)(void )__initdata =NULL ; +/* * mips_io_port_base is the begin of the address space to which x86 style * I/O ports are mapped. @@ -678,7 +680,12 @@ static void __init arch_mem_init(char **cmdline_p)plat_swiotlb_setup ();paging_init (); +/* allocate default CMA area */ dma_contiguous_reserve (PFN_PHYS (max_low_pfn)); +/* allow platforms to reserve CMA memory for devices */ +if (plat_reserve_mem) +plat_reserve_mem (); +/* Tell bootmem about cma reserved memblock section */ for_each_memblock (reserved, reg)if (reg->size !=0 )
Signature · 1 line
Florian