linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] fbdev/amifb: Correct check for video memory size
@ 2011-05-21 19:42 Geert Uytterhoeven
  2011-05-21 19:42 ` [PATCH 2/3] fbdev/amifb: Do not call panic() if there's not enough Chip RAM Geert Uytterhoeven
  2011-05-21 19:42 ` [PATCH 3/3] fbdev/amifb: Remove superfluous alignment of frame buffer memory Geert Uytterhoeven
  0 siblings, 2 replies; 4+ messages in thread
From: Geert Uytterhoeven @ 2011-05-21 19:42 UTC (permalink / raw)
  To: Paul Mundt; +Cc: linux-fbdev, linux-m68k, Geert Uytterhoeven

The check should compare the available memory size with the highest allocation
value (VIDEOMEMSIZE_*_2M), not with the lowest value (VIDEOMEMSIZE_*_1M).

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
 drivers/video/amifb.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/video/amifb.c b/drivers/video/amifb.c
index e5d6b56..603f84f 100644
--- a/drivers/video/amifb.c
+++ b/drivers/video/amifb.c
@@ -2295,7 +2295,7 @@ default_chipset:
 			    defmode = amiga_vblank = 50 ? DEFMODE_PAL
 							 : DEFMODE_NTSC;
 			if (amiga_chip_avail()-CHIPRAM_SAFETY_LIMIT >
-			    VIDEOMEMSIZE_ECS_1M)
+			    VIDEOMEMSIZE_ECS_2M)
 				fb_info.fix.smem_len = VIDEOMEMSIZE_ECS_2M;
 			else
 				fb_info.fix.smem_len = VIDEOMEMSIZE_ECS_1M;
@@ -2312,7 +2312,7 @@ default_chipset:
 			maxfmode = TAG_FMODE_4;
 			defmode = DEFMODE_AGA;
 			if (amiga_chip_avail()-CHIPRAM_SAFETY_LIMIT >
-			    VIDEOMEMSIZE_AGA_1M)
+			    VIDEOMEMSIZE_AGA_2M)
 				fb_info.fix.smem_len = VIDEOMEMSIZE_AGA_2M;
 			else
 				fb_info.fix.smem_len = VIDEOMEMSIZE_AGA_1M;
-- 
1.7.0.4


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

* [PATCH 2/3] fbdev/amifb: Do not call panic() if there's not enough Chip RAM
  2011-05-21 19:42 [PATCH 1/3] fbdev/amifb: Correct check for video memory size Geert Uytterhoeven
@ 2011-05-21 19:42 ` Geert Uytterhoeven
  2011-05-24  7:27   ` [PATCH 1/3] fbdev/amifb: Correct check for video memory size Paul Mundt
  2011-05-21 19:42 ` [PATCH 3/3] fbdev/amifb: Remove superfluous alignment of frame buffer memory Geert Uytterhoeven
  1 sibling, 1 reply; 4+ messages in thread
From: Geert Uytterhoeven @ 2011-05-21 19:42 UTC (permalink / raw)
  To: Paul Mundt; +Cc: linux-fbdev, linux-m68k, Geert Uytterhoeven

Fail gracefully instead.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
 drivers/video/amifb.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/video/amifb.c b/drivers/video/amifb.c
index 603f84f..1b0185c 100644
--- a/drivers/video/amifb.c
+++ b/drivers/video/amifb.c
@@ -2230,8 +2230,10 @@ static inline u_long __init chipalloc(u_long size)
 {
 	size += PAGE_SIZE-1;
 	if (!(unaligned_chipptr = (u_long)amiga_chip_alloc(size,
-							   "amifb [RAM]")))
-		panic("No Chip RAM for frame buffer");
+							   "amifb [RAM]"))) {
+		pr_err("amifb: No Chip RAM for frame buffer");
+		return 0;
+	}
 	memset((void *)unaligned_chipptr, 0, size);
 	return PAGE_ALIGN(unaligned_chipptr);
 }
@@ -2385,6 +2387,10 @@ default_chipset:
 	                    DUMMYSPRITEMEMSIZE+
 	                    COPINITSIZE+
 	                    4*COPLISTSIZE);
+	if (!chipptr) {
+		err = -ENOMEM;
+		goto amifb_error;
+	}
 
 	assignchunk(videomemory, u_long, chipptr, fb_info.fix.smem_len);
 	assignchunk(spritememory, u_long, chipptr, SPRITEMEMSIZE);
-- 
1.7.0.4


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

* [PATCH 3/3] fbdev/amifb: Remove superfluous alignment of frame buffer memory
  2011-05-21 19:42 [PATCH 1/3] fbdev/amifb: Correct check for video memory size Geert Uytterhoeven
  2011-05-21 19:42 ` [PATCH 2/3] fbdev/amifb: Do not call panic() if there's not enough Chip RAM Geert Uytterhoeven
@ 2011-05-21 19:42 ` Geert Uytterhoeven
  1 sibling, 0 replies; 4+ messages in thread
From: Geert Uytterhoeven @ 2011-05-21 19:42 UTC (permalink / raw)
  To: Paul Mundt; +Cc: linux-fbdev, linux-m68k, Geert Uytterhoeven

amiga_chip_alloc() already aligns to the PAGE_SIZE

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
 drivers/video/amifb.c |   15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/video/amifb.c b/drivers/video/amifb.c
index 1b0185c..5ea6596 100644
--- a/drivers/video/amifb.c
+++ b/drivers/video/amifb.c
@@ -2224,24 +2224,23 @@ static int amifb_ioctl(struct fb_info *info,
 	 * Allocate, Clear and Align a Block of Chip Memory
 	 */
 
-static u_long unaligned_chipptr = 0;
+static void *aligned_chipptr;
 
 static inline u_long __init chipalloc(u_long size)
 {
-	size += PAGE_SIZE-1;
-	if (!(unaligned_chipptr = (u_long)amiga_chip_alloc(size,
-							   "amifb [RAM]"))) {
+	aligned_chipptr = amiga_chip_alloc(size, "amifb [RAM]");
+	if (!aligned_chipptr) {
 		pr_err("amifb: No Chip RAM for frame buffer");
 		return 0;
 	}
-	memset((void *)unaligned_chipptr, 0, size);
-	return PAGE_ALIGN(unaligned_chipptr);
+	memset(aligned_chipptr, 0, size);
+	return (u_long)aligned_chipptr;
 }
 
 static inline void chipfree(void)
 {
-	if (unaligned_chipptr)
-		amiga_chip_free((void *)unaligned_chipptr);
+	if (aligned_chipptr)
+		amiga_chip_free(aligned_chipptr);
 }
 
 
-- 
1.7.0.4


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

* Re: [PATCH 1/3] fbdev/amifb: Correct check for video memory size
  2011-05-21 19:42 ` [PATCH 2/3] fbdev/amifb: Do not call panic() if there's not enough Chip RAM Geert Uytterhoeven
@ 2011-05-24  7:27   ` Paul Mundt
  0 siblings, 0 replies; 4+ messages in thread
From: Paul Mundt @ 2011-05-24  7:27 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: linux-fbdev, linux-m68k

On Sat, May 21, 2011 at 09:42:54PM +0200, Geert Uytterhoeven wrote:
> The check should compare the available memory size with the highest allocation
> value (VIDEOMEMSIZE_*_2M), not with the lowest value (VIDEOMEMSIZE_*_1M).
> 
> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>

On Sat, May 21, 2011 at 09:42:55PM +0200, Geert Uytterhoeven wrote:
> Fail gracefully instead.
> 
> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>

On Sat, May 21, 2011 at 09:42:56PM +0200, Geert Uytterhoeven wrote:
> amiga_chip_alloc() already aligns to the PAGE_SIZE
> 
> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>

All applied, thanks.

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

end of thread, other threads:[~2011-05-24  7:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-21 19:42 [PATCH 1/3] fbdev/amifb: Correct check for video memory size Geert Uytterhoeven
2011-05-21 19:42 ` [PATCH 2/3] fbdev/amifb: Do not call panic() if there's not enough Chip RAM Geert Uytterhoeven
2011-05-24  7:27   ` [PATCH 1/3] fbdev/amifb: Correct check for video memory size Paul Mundt
2011-05-21 19:42 ` [PATCH 3/3] fbdev/amifb: Remove superfluous alignment of frame buffer memory Geert Uytterhoeven

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).