public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] unicore32 framebuffer driver fix: make videomemory kmalloc-ed and floatable
@ 2011-03-29 14:37 Guan Xuetao
  2011-03-29 14:42 ` Arnd Bergmann
  0 siblings, 1 reply; 7+ messages in thread
From: Guan Xuetao @ 2011-03-29 14:37 UTC (permalink / raw)
  To: Paul Mundt
  Cc: Arnd Bergmann, 'Guan Xuetao', linux-kernel, linux-fbdev


1. make videomemory kmalloc-ed in fb-puv3.c
2. remove resource reservation for old fixed UNIGFX_MMAP & UVC_MMAP space
3. remove unused 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.c

Signed-off-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
---
 arch/unicore32/include/mach/PKUnity.h |   10 ----------
 arch/unicore32/include/mach/memory.h  |    1 -
 arch/unicore32/kernel/puv3-core.c     |    5 -----
 arch/unicore32/kernel/setup.c         |   15 ++-------------
 arch/unicore32/mm/mmu.c               |   20 --------------------
 drivers/video/fb-puv3.c               |   27 ++++++++++++++++-----------
 6 files changed, 18 insertions(+), 60 deletions(-)

diff --git a/arch/unicore32/include/mach/PKUnity.h b/arch/unicore32/include/mach/PKUnity.h
index a18bdc3..8040d57 100644
--- a/arch/unicore32/include/mach/PKUnity.h
+++ b/arch/unicore32/include/mach/PKUnity.h
@@ -24,16 +24,6 @@
 #define PKUNITY_MMIO_BASE		0x80000000 /* 0x80000000 - 0xFFFFFFFF 2GB */
 
 /*
- * PKUNITY Memory Map Addresses: 0x0D000000 - 0x0EFFFFFF (32MB)
- *	0x0D000000 - 0x0DFFFFFF 16MB: for UVC
- *	0x0E000000 - 0x0EFFFFFF 16MB: for UNIGFX
- */
-#define PKUNITY_UVC_MMAP_BASE		0x0D000000
-#define PKUNITY_UVC_MMAP_SIZE		0x01000000 /* 16MB */
-#define PKUNITY_UNIGFX_MMAP_BASE        0x0E000000
-#define PKUNITY_UNIGFX_MMAP_SIZE        0x01000000 /* 16MB */
-
-/*
  * PKUNITY System Bus Addresses (PCI): 0x80000000 - 0xBFFFFFFF (1GB)
  * 0x80000000 - 0x8000000B 12B    PCI Configuration regs
  * 0x80010000 - 0x80010250 592B   PCI Bridge Base
diff --git a/arch/unicore32/include/mach/memory.h b/arch/unicore32/include/mach/memory.h
index 0bf21c9..4be72c2 100644
--- a/arch/unicore32/include/mach/memory.h
+++ b/arch/unicore32/include/mach/memory.h
@@ -50,7 +50,6 @@ void puv3_pci_adjust_zones(unsigned long *size, unsigned long *holes);
 
 /* kuser area */
 #define KUSER_VECPAGE_BASE	(KUSER_BASE + UL(0x3fff0000))
-#define KUSER_UNIGFX_BASE	(PAGE_OFFSET + PKUNITY_UNIGFX_MMAP_BASE)
 /* kuser_vecpage (0xbfff0000) is ro, and vectors page (0xffff0000) is rw */
 #define kuser_vecpage_to_vectors(x)	((x) - (KUSER_VECPAGE_BASE)	\
 					+ (VECTORS_BASE))
diff --git a/arch/unicore32/kernel/puv3-core.c b/arch/unicore32/kernel/puv3-core.c
index 8b1b6be..1a505a7 100644
--- a/arch/unicore32/kernel/puv3-core.c
+++ b/arch/unicore32/kernel/puv3-core.c
@@ -99,11 +99,6 @@ static struct resource puv3_unigfx_resources[] = {
 		.end	= io_v2p(PKUNITY_UNIGFX_BASE) + 0xfff,
 		.flags	= IORESOURCE_MEM,
 	},
-	[1] = {
-		.start	= PKUNITY_UNIGFX_MMAP_BASE,
-		.end	= PKUNITY_UNIGFX_MMAP_BASE + PKUNITY_UNIGFX_MMAP_SIZE,
-		.flags	= IORESOURCE_MEM,
-	},
 };
 
 static struct resource puv3_rtc_resources[] = {
diff --git a/arch/unicore32/kernel/setup.c b/arch/unicore32/kernel/setup.c
index 1e175a8..471b6bc 100644
--- a/arch/unicore32/kernel/setup.c
+++ b/arch/unicore32/kernel/setup.c
@@ -64,12 +64,6 @@ static char default_command_line[COMMAND_LINE_SIZE] __initdata = CONFIG_CMDLINE;
  */
 static struct resource mem_res[] = {
 	{
-		.name = "Video RAM",
-		.start = 0,
-		.end = 0,
-		.flags = IORESOURCE_MEM
-	},
-	{
 		.name = "Kernel text",
 		.start = 0,
 		.end = 0,
@@ -83,9 +77,8 @@ static struct resource mem_res[] = {
 	}
 };
 
-#define video_ram   mem_res[0]
-#define kernel_code mem_res[1]
-#define kernel_data mem_res[2]
+#define kernel_code mem_res[0]
+#define kernel_data mem_res[1]
 
 /*
  * These functions re-use the assembly code in head.S, which
@@ -224,10 +217,6 @@ request_standard_resources(struct meminfo *mi)
 		    kernel_data.end <= res->end)
 			request_resource(res, &kernel_data);
 	}
-
-	video_ram.start = PKUNITY_UNIGFX_MMAP_BASE;
-	video_ram.end   = PKUNITY_UNIGFX_MMAP_BASE + PKUNITY_UNIGFX_MMAP_SIZE;
-	request_resource(&iomem_resource, &video_ram);
 }
 
 static void (*init_machine)(void) __initdata;
diff --git a/arch/unicore32/mm/mmu.c b/arch/unicore32/mm/mmu.c
index 7bf3d58..db2d334 100644
--- a/arch/unicore32/mm/mmu.c
+++ b/arch/unicore32/mm/mmu.c
@@ -338,15 +338,6 @@ void __init uc32_mm_memblock_reserve(void)
 	 * and can only be in node 0.
 	 */
 	memblock_reserve(__pa(swapper_pg_dir), PTRS_PER_PGD * sizeof(pgd_t));
-
-#ifdef CONFIG_PUV3_UNIGFX
-	/*
-	 * These should likewise go elsewhere.  They pre-reserve the
-	 * screen/video memory region at the 48M~64M of main system memory.
-	 */
-	memblock_reserve(PKUNITY_UNIGFX_MMAP_BASE, PKUNITY_UNIGFX_MMAP_SIZE);
-	memblock_reserve(PKUNITY_UVC_MMAP_BASE, PKUNITY_UVC_MMAP_SIZE);
-#endif
 }
 
 /*
@@ -371,17 +362,6 @@ static void __init devicemaps_init(void)
 		pmd_clear(pmd_off_k(addr));
 
 	/*
-	 * Create a mapping for UniGFX VRAM
-	 */
-#ifdef CONFIG_PUV3_UNIGFX
-	map.pfn = __phys_to_pfn(PKUNITY_UNIGFX_MMAP_BASE);
-	map.virtual = KUSER_UNIGFX_BASE;
-	map.length = PKUNITY_UNIGFX_MMAP_SIZE;
-	map.type = MT_KUSER;
-	create_mapping(&map);
-#endif
-
-	/*
 	 * Create a mapping for the machine vectors at the high-vectors
 	 * location (0xffff0000).  If we aren't using high-vectors, also
 	 * create a mapping at the low-vectors virtual address.
diff --git a/drivers/video/fb-puv3.c b/drivers/video/fb-puv3.c
index dbd2dc4..286e295 100644
--- a/drivers/video/fb-puv3.c
+++ b/drivers/video/fb-puv3.c
@@ -13,7 +13,6 @@
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
-#include <linux/vmalloc.h>
 #include <linux/platform_device.h>
 #include <linux/clk.h>
 #include <linux/fb.h>
@@ -531,7 +530,7 @@ static int unifb_set_par(struct fb_info *info)
 		return -EINVAL;
 	}
 
-	writel(PKUNITY_UNIGFX_MMAP_BASE, UDE_FSA);
+	writel(info->fix.smem_start, UDE_FSA);
 	writel(info->var.yres, UDE_LS);
 	writel(get_line_length(info->var.xres,
 			info->var.bits_per_pixel) >> 3, UDE_PS);
@@ -680,13 +679,26 @@ static int unifb_probe(struct platform_device *dev)
 	struct fb_info *info;
 	u32 unifb_regs[UNIFB_REGS_NUM];
 	int retval = -ENOMEM;
-	struct resource *iomem, *mapmem;
+	struct resource *iomem;
+	void *videomemory;
+
+	videomemory = kmalloc(UNIFB_MEMSIZE, GFP_KERNEL);
+	if (!videomemory)
+		goto err;
+
+	memset(videomemory, 0, UNIFB_MEMSIZE);
+
+	unifb_fix.smem_start = virt_to_phys(videomemory);
+	unifb_fix.smem_len = UNIFB_MEMSIZE;
+
+	iomem = platform_get_resource(dev, IORESOURCE_MEM, 0);
+	unifb_fix.mmio_start = iomem->start;
 
 	info = framebuffer_alloc(sizeof(u32)*256, &dev->dev);
 	if (!info)
 		goto err;
 
-	info->screen_base = (char __iomem *)KUSER_UNIGFX_BASE;
+	info->screen_base = (char __iomem *)videomemory;
 	info->fbops = &unifb_ops;
 
 	retval = fb_find_mode(&info->var, info, NULL,
@@ -695,13 +707,6 @@ static int unifb_probe(struct platform_device *dev)
 	if (!retval || (retval == 4))
 		info->var = unifb_default;
 
-	iomem = platform_get_resource(dev, IORESOURCE_MEM, 0);
-	unifb_fix.mmio_start = iomem->start;
-
-	mapmem = platform_get_resource(dev, IORESOURCE_MEM, 1);
-	unifb_fix.smem_start = mapmem->start;
-	unifb_fix.smem_len = UNIFB_MEMSIZE;
-
 	info->fix = unifb_fix;
 	info->pseudo_palette = info->par;
 	info->par = NULL;
-- 
1.6.2.2



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] unicore32 framebuffer driver fix: make videomemory kmalloc-ed and floatable
  2011-03-29 14:37 [PATCH] unicore32 framebuffer driver fix: make videomemory kmalloc-ed and floatable Guan Xuetao
@ 2011-03-29 14:42 ` Arnd Bergmann
  2011-03-29 14:54   ` Guan Xuetao
  2011-03-30  1:39   ` Guan Xuetao
  0 siblings, 2 replies; 7+ messages in thread
From: Arnd Bergmann @ 2011-03-29 14:42 UTC (permalink / raw)
  To: Guan Xuetao; +Cc: Paul Mundt, linux-kernel, linux-fbdev

On Tuesday 29 March 2011, Guan Xuetao wrote:
> 
> 1. make videomemory kmalloc-ed in fb-puv3.c
> 2. remove resource reservation for old fixed UNIGFX_MMAP & UVC_MMAP space
> 3. remove unused 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.c
> 
> Signed-off-by: Guan Xuetao <gxt@mprc.pku.edu.cn>

How does this work? UNIFB_MEMSIZE seems to be 4 MB, much more than the
maximum of 128 KB that kmalloc can allocate.

Shouldn't this use get_free_pages() instead of kmalloc?

	Arnd

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [PATCH] unicore32 framebuffer driver fix: make videomemory kmalloc-ed and floatable
  2011-03-29 14:42 ` Arnd Bergmann
@ 2011-03-29 14:54   ` Guan Xuetao
  2011-03-30  1:39   ` Guan Xuetao
  1 sibling, 0 replies; 7+ messages in thread
From: Guan Xuetao @ 2011-03-29 14:54 UTC (permalink / raw)
  To: 'Arnd Bergmann'; +Cc: 'Paul Mundt', linux-kernel, linux-fbdev



> -----Original Message-----
> From: Arnd Bergmann [mailto:arnd@arndb.de]
> Sent: Tuesday, March 29, 2011 10:43 PM
> To: Guan Xuetao
> Cc: Paul Mundt; linux-kernel@vger.kernel.org; linux-fbdev@vger.kernel.org
> Subject: Re: [PATCH] unicore32 framebuffer driver fix: make videomemory kmalloc-ed and floatable
> 
> On Tuesday 29 March 2011, Guan Xuetao wrote:
> >
> > 1. make videomemory kmalloc-ed in fb-puv3.c
> > 2. remove resource reservation for old fixed UNIGFX_MMAP & UVC_MMAP space
> > 3. remove unused 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.c
> >
> > Signed-off-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
> 
> How does this work? UNIFB_MEMSIZE seems to be 4 MB, much more than the
> maximum of 128 KB that kmalloc can allocate.
I'm surprised. But kmalloc() returns success with 0xc7000000.

> 
> Shouldn't this use get_free_pages() instead of kmalloc?

I will check and correct it.

> 
> 	Arnd

Thanks.

Guan Xuetao


^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [PATCH] unicore32 framebuffer driver fix: make videomemory kmalloc-ed and floatable
  2011-03-29 14:42 ` Arnd Bergmann
  2011-03-29 14:54   ` Guan Xuetao
@ 2011-03-30  1:39   ` Guan Xuetao
  2011-03-30  6:54     ` Arnd Bergmann
  1 sibling, 1 reply; 7+ messages in thread
From: Guan Xuetao @ 2011-03-30  1:39 UTC (permalink / raw)
  To: 'Arnd Bergmann'; +Cc: 'Paul Mundt', linux-kernel, linux-fbdev



> -----Original Message-----
> From: Arnd Bergmann [mailto:arnd@arndb.de]
> Sent: Tuesday, March 29, 2011 10:43 PM
> To: Guan Xuetao
> Cc: Paul Mundt; linux-kernel@vger.kernel.org; linux-fbdev@vger.kernel.org
> Subject: Re: [PATCH] unicore32 framebuffer driver fix: make videomemory kmalloc-ed and floatable
> 
> On Tuesday 29 March 2011, Guan Xuetao wrote:
> >
> > 1. make videomemory kmalloc-ed in fb-puv3.c
> > 2. remove resource reservation for old fixed UNIGFX_MMAP & UVC_MMAP space
> > 3. remove unused 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.c
> >
> > Signed-off-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
> 
> How does this work? UNIFB_MEMSIZE seems to be 4 MB, much more than the
> maximum of 128 KB that kmalloc can allocate.
> 
> Shouldn't this use get_free_pages() instead of kmalloc?
> 
> 	Arnd

When using SLUB allocator, if required memory size  is larger than 2*PAGE_SIZE, kmalloc_large is called,
and eventually __get_free_pages will  be called.
So,  it would be the same as __get_free_pages.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] unicore32 framebuffer driver fix: make videomemory kmalloc-ed and floatable
  2011-03-30  1:39   ` Guan Xuetao
@ 2011-03-30  6:54     ` Arnd Bergmann
  2011-03-30  8:43       ` Guan Xuetao
  0 siblings, 1 reply; 7+ messages in thread
From: Arnd Bergmann @ 2011-03-30  6:54 UTC (permalink / raw)
  To: Guan Xuetao; +Cc: 'Paul Mundt', linux-kernel, linux-fbdev

On Wednesday 30 March 2011 03:39:26 Guan Xuetao wrote:
> > How does this work? UNIFB_MEMSIZE seems to be 4 MB, much more than the
> > maximum of 128 KB that kmalloc can allocate.
> > 
> > Shouldn't this use get_free_pages() instead of kmalloc?
> > 
> 
> When using SLUB allocator, if required memory size  is larger
> than 2*PAGE_SIZE, kmalloc_large is called,
> and eventually __get_free_pages will  be called.
> So,  it would be the same as __get_free_pages.

Ok, I see. It's probably still better to use __get_free_pages directly,
because it's possible to select a different allocator that does not
do this itself.

	Arnd

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [PATCH] unicore32 framebuffer driver fix: make videomemory kmalloc-ed and floatable
  2011-03-30  6:54     ` Arnd Bergmann
@ 2011-03-30  8:43       ` Guan Xuetao
  2011-03-30 10:55         ` Arnd Bergmann
  0 siblings, 1 reply; 7+ messages in thread
From: Guan Xuetao @ 2011-03-30  8:43 UTC (permalink / raw)
  To: 'Arnd Bergmann'; +Cc: 'Paul Mundt', linux-kernel, linux-fbdev



> -----Original Message-----
> From: Arnd Bergmann [mailto:arnd@arndb.de]
> Sent: Wednesday, March 30, 2011 2:54 PM
> To: Guan Xuetao
> Cc: 'Paul Mundt'; linux-kernel@vger.kernel.org; linux-fbdev@vger.kernel.org
> Subject: Re: [PATCH] unicore32 framebuffer driver fix: make videomemory kmalloc-ed and floatable
> 
> On Wednesday 30 March 2011 03:39:26 Guan Xuetao wrote:
> > > How does this work? UNIFB_MEMSIZE seems to be 4 MB, much more than the
> > > maximum of 128 KB that kmalloc can allocate.
> > >
> > > Shouldn't this use get_free_pages() instead of kmalloc?
> > >
> >
> > When using SLUB allocator, if required memory size  is larger
> > than 2*PAGE_SIZE, kmalloc_large is called,
> > and eventually __get_free_pages will  be called.
> > So,  it would be the same as __get_free_pages.
> 
> Ok, I see. It's probably still better to use __get_free_pages directly,
> because it's possible to select a different allocator that does not
> do this itself.
> 
> 	Arnd
Is it appropriate to using __get_free_pages in framebuffer driver?
And both SLAB and SLUB allocators support 4MB request.

Thanks & Regards.

Guan Xuetao



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] unicore32 framebuffer driver fix: make videomemory kmalloc-ed and floatable
  2011-03-30  8:43       ` Guan Xuetao
@ 2011-03-30 10:55         ` Arnd Bergmann
  0 siblings, 0 replies; 7+ messages in thread
From: Arnd Bergmann @ 2011-03-30 10:55 UTC (permalink / raw)
  To: Guan Xuetao; +Cc: 'Paul Mundt', linux-kernel, linux-fbdev

On Wednesday 30 March 2011, Guan Xuetao wrote:
> Is it appropriate to using __get_free_pages in framebuffer driver?

Yes, it is appropriate, and it is also more efficient than using
kmalloc.

> And both SLAB and SLUB allocators support 4MB request.

Ok, I did not know that, but I see now how the maximum size is computed.
The limit was 128 KB for a long time, but has apparently changed.

	Arnd

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-03-30 10:55 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-29 14:37 [PATCH] unicore32 framebuffer driver fix: make videomemory kmalloc-ed and floatable Guan Xuetao
2011-03-29 14:42 ` Arnd Bergmann
2011-03-29 14:54   ` Guan Xuetao
2011-03-30  1:39   ` Guan Xuetao
2011-03-30  6:54     ` Arnd Bergmann
2011-03-30  8:43       ` Guan Xuetao
2011-03-30 10:55         ` Arnd Bergmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox