* [PATCH 1/3] MIPS: add hook for platforms to register CMA memory
@ 2015-10-06 16:23 Manuel Lauss
2015-10-06 16:23 ` [PATCH 2/3] MIPS: Alchemy: devboards: register CMA memory for Au1200 framebuffer Manuel Lauss
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Manuel Lauss @ 2015-10-06 16:23 UTC (permalink / raw)
To: Linux-MIPS; +Cc: 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 <manuel.lauss@gmail.com>
---
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(+)
diff --git a/arch/mips/include/asm/bootinfo.h b/arch/mips/include/asm/bootinfo.h
index b603804..1fc1f67 100644
--- a/arch/mips/include/asm/bootinfo.h
+++ b/arch/mips/include/asm/bootinfo.h
@@ -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().
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index 35b8316..2b56885 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -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)
--
2.5.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/3] MIPS: Alchemy: devboards: register CMA memory for Au1200 framebuffer
2015-10-06 16:23 [PATCH 1/3] MIPS: add hook for platforms to register CMA memory Manuel Lauss
@ 2015-10-06 16:23 ` Manuel Lauss
2015-10-06 16:23 ` [PATCH 3/3] video: fbdev: au1200fb: alloc mem from coherent pool/CMA Manuel Lauss
2016-02-10 23:09 ` [PATCH 1/3] MIPS: add hook for platforms to register CMA memory Florian Fainelli
2 siblings, 0 replies; 4+ messages in thread
From: Manuel Lauss @ 2015-10-06 16:23 UTC (permalink / raw)
To: Linux-MIPS; +Cc: Manuel Lauss
Use the newly introduced CMA memory setup hook to register a few
megabytes for the Au1200/Au1300 framebuffer.
Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
---
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(-)
diff --git a/arch/mips/alchemy/devboards/db1200.c b/arch/mips/alchemy/devboards/db1200.c
index bfc2797..eb46676 100644
--- a/arch/mips/alchemy/devboards/db1200.c
+++ b/arch/mips/alchemy/devboards/db1200.c
@@ -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;
+}
diff --git a/arch/mips/alchemy/devboards/db1300.c b/arch/mips/alchemy/devboards/db1300.c
index 751a1e2..a844c04 100644
--- a/arch/mips/alchemy/devboards/db1300.c
+++ b/arch/mips/alchemy/devboards/db1300.c
@@ -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;
}
--
2.5.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/3] video: fbdev: au1200fb: alloc mem from coherent pool/CMA
2015-10-06 16:23 [PATCH 1/3] MIPS: add hook for platforms to register CMA memory Manuel Lauss
2015-10-06 16:23 ` [PATCH 2/3] MIPS: Alchemy: devboards: register CMA memory for Au1200 framebuffer Manuel Lauss
@ 2015-10-06 16:23 ` Manuel Lauss
2016-02-10 23:09 ` [PATCH 1/3] MIPS: add hook for platforms to register CMA memory Florian Fainelli
2 siblings, 0 replies; 4+ messages in thread
From: Manuel Lauss @ 2015-10-06 16:23 UTC (permalink / raw)
To: Linux-MIPS; +Cc: Manuel Lauss, linux-fbdev
Change 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.
Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
Cc: linux-fbdev <linux-fbdev@vger.kernel.org>
---
Tested on Db1200 and Db1300 boards, with no issues
drivers/video/fbdev/au1200fb.c | 13 +------------
1 file changed, 1 insertion(+), 12 deletions(-)
diff --git a/drivers/video/fbdev/au1200fb.c b/drivers/video/fbdev/au1200fb.c
index f9507b1..0884197 100644
--- a/drivers/video/fbdev/au1200fb.c
+++ b/drivers/video/fbdev/au1200fb.c
@@ -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);
--
2.5.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/3] MIPS: add hook for platforms to register CMA memory
2015-10-06 16:23 [PATCH 1/3] MIPS: add hook for platforms to register CMA memory Manuel Lauss
2015-10-06 16:23 ` [PATCH 2/3] MIPS: Alchemy: devboards: register CMA memory for Au1200 framebuffer Manuel Lauss
2015-10-06 16:23 ` [PATCH 3/3] video: fbdev: au1200fb: alloc mem from coherent pool/CMA Manuel Lauss
@ 2016-02-10 23:09 ` Florian Fainelli
2 siblings, 0 replies; 4+ messages in thread
From: Florian Fainelli @ 2016-02-10 23:09 UTC (permalink / raw)
To: Manuel Lauss, Linux-MIPS
On 06/10/15 09:23, Manuel Lauss wrote:
> 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 <manuel.lauss@gmail.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
This is also useful for BMIPS_GENERIC platforms where we may need to do
custom memory reservations.
Thanks!
> ---
> 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(+)
>
> diff --git a/arch/mips/include/asm/bootinfo.h b/arch/mips/include/asm/bootinfo.h
> index b603804..1fc1f67 100644
> --- a/arch/mips/include/asm/bootinfo.h
> +++ b/arch/mips/include/asm/bootinfo.h
> @@ -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().
> diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
> index 35b8316..2b56885 100644
> --- a/arch/mips/kernel/setup.c
> +++ b/arch/mips/kernel/setup.c
> @@ -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)
>
--
Florian
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-02-10 23:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-06 16:23 [PATCH 1/3] MIPS: add hook for platforms to register CMA memory Manuel Lauss
2015-10-06 16:23 ` [PATCH 2/3] MIPS: Alchemy: devboards: register CMA memory for Au1200 framebuffer Manuel Lauss
2015-10-06 16:23 ` [PATCH 3/3] video: fbdev: au1200fb: alloc mem from coherent pool/CMA Manuel Lauss
2016-02-10 23:09 ` [PATCH 1/3] MIPS: add hook for platforms to register CMA memory Florian Fainelli
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox