[PATCH 06/17] platinumfb: Fix resource management

Subsystems: framebuffer layer, the rest

STALE6887d

7 messages, 4 authors, 2007-10-03 · open the first message on its own page

[PATCH 06/17] platinumfb: Fix resource management

From: "Antonino A. Daplas" <adaplas@gmail.com>
Date: 2007-09-29 02:48:16

From: Benjamin Herrenschmidt <benh@kernel.crashing.org>

Current kernels have a non-working platinumfb due to some resource
management issues. This fixes it.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Antonino Daplas <adaplas@gmail.com>
---

 drivers/video/platinumfb.c |   48 ++++++++++++++++++++++++--------------------
 1 files changed, 26 insertions(+), 22 deletions(-)
diff --git a/drivers/video/platinumfb.c b/drivers/video/platinumfb.c
index 8503e73..cbe71a5 100644
--- a/drivers/video/platinumfb.c
+++ b/drivers/video/platinumfb.c
@@ -17,6 +17,8 @@
  *  more details.
  */
 
+#undef DEBUG
+
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
@@ -535,33 +537,35 @@ static int __devinit platinumfb_probe(st
 	volatile __u8		*fbuffer;
 	int			bank0, bank1, bank2, bank3, rc;
 
-	printk(KERN_INFO "platinumfb: Found Apple Platinum video hardware\n");
+	dev_info(&odev->dev, "Found Apple Platinum video hardware\n");
 
 	info = framebuffer_alloc(sizeof(*pinfo), &odev->dev);
-	if (info == NULL)
+	if (info == NULL) {
+		dev_err(&odev->dev, "Failed to allocate fbdev !\n");
 		return -ENOMEM;
+	}
 	pinfo = info->par;
 
 	if (of_address_to_resource(dp, 0, &pinfo->rsrc_reg) ||
 	    of_address_to_resource(dp, 1, &pinfo->rsrc_fb)) {
-		printk(KERN_ERR "platinumfb: Can't get resources\n");
-		framebuffer_release(info);
-		return -ENXIO;
-	}
-	if (!request_mem_region(pinfo->rsrc_reg.start,
-				pinfo->rsrc_reg.start -
-				pinfo->rsrc_reg.end + 1,
-				"platinumfb registers")) {
+		dev_err(&odev->dev, "Can't get resources\n");
 		framebuffer_release(info);
 		return -ENXIO;
 	}
+	dev_dbg(&odev->dev, " registers  : 0x%llx...0x%llx\n",
+		(unsigned long long)pinfo->rsrc_reg.start,
+		(unsigned long long)pinfo->rsrc_reg.end);
+	dev_dbg(&odev->dev, " framebuffer: 0x%llx...0x%llx\n",
+		(unsigned long long)pinfo->rsrc_fb.start,
+		(unsigned long long)pinfo->rsrc_fb.end);
+
+	/* Do not try to request register space, they overlap with the
+	 * northbridge and that can fail. Only request framebuffer
+	 */
 	if (!request_mem_region(pinfo->rsrc_fb.start,
-				pinfo->rsrc_fb.start
-				- pinfo->rsrc_fb.end + 1,
+				pinfo->rsrc_fb.end - pinfo->rsrc_fb.start + 1,
 				"platinumfb framebuffer")) {
-		release_mem_region(pinfo->rsrc_reg.start,
-				   pinfo->rsrc_reg.end -
-				   pinfo->rsrc_reg.start + 1);
+		printk(KERN_ERR "platinumfb: Can't request framebuffer !\n");
 		framebuffer_release(info);
 		return -ENXIO;
 	}
@@ -600,7 +604,8 @@ static int __devinit platinumfb_probe(st
 	bank2 = fbuffer[0x200000] == 0x56;
 	bank3 = fbuffer[0x300000] == 0x78;
 	pinfo->total_vram = (bank0 + bank1 + bank2 + bank3) * 0x100000;
-	printk(KERN_INFO "platinumfb: Total VRAM = %dMB (%d%d%d%d)\n", (int) (pinfo->total_vram / 1024 / 1024),
+	printk(KERN_INFO "platinumfb: Total VRAM = %dMB (%d%d%d%d)\n",
+	       (unsigned int) (pinfo->total_vram / 1024 / 1024),
 	       bank3, bank2, bank1, bank0);
 
 	/*
@@ -644,16 +649,15 @@ static int __devexit platinumfb_remove(s
         unregister_framebuffer (info);
 	
 	/* Unmap frame buffer and registers */
+	iounmap(pinfo->frame_buffer);
+	iounmap(pinfo->platinum_regs);
+	iounmap(pinfo->cmap_regs);
+
 	release_mem_region(pinfo->rsrc_fb.start,
 			   pinfo->rsrc_fb.end -
 			   pinfo->rsrc_fb.start + 1);
-	release_mem_region(pinfo->rsrc_reg.start,
-			   pinfo->rsrc_reg.end -
-			   pinfo->rsrc_reg.start + 1);
-	iounmap(pinfo->frame_buffer);
-	iounmap(pinfo->platinum_regs);
+
 	release_mem_region(pinfo->cmap_regs_phys, 0x1000);
-	iounmap(pinfo->cmap_regs);
 
 	framebuffer_release(info);
 


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

Re: [PATCH 06/17] platinumfb: Fix resource management

From: Geert Uytterhoeven <geert@linux-m68k.org>
Date: 2007-09-29 09:16:27

On Sat, 29 Sep 2007, Antonino A. Daplas wrote:
quoted hunk
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>

Current kernels have a non-working platinumfb due to some resource
management issues. This fixes it.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Antonino Daplas <adaplas@gmail.com>
---

 drivers/video/platinumfb.c |   48 ++++++++++++++++++++++++--------------------
 1 files changed, 26 insertions(+), 22 deletions(-)
diff --git a/drivers/video/platinumfb.c b/drivers/video/platinumfb.c
index 8503e73..cbe71a5 100644
--- a/drivers/video/platinumfb.c
+++ b/drivers/video/platinumfb.c
@@ -17,6 +17,8 @@
  *  more details.
  */
 
+#undef DEBUG
+
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
Probably scripts/checkpatch.pl should be taught to complain about
`#undef DEBUG'.

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

Re: [PATCH 06/17] platinumfb: Fix resource management

From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Date: 2007-09-29 21:53:14

Probably scripts/checkpatch.pl should be taught to complain about
`#undef DEBUG'.
Why ? Whenever I have things that are #ifdef DEBUG in the file (such as
dev_dbg statements), I always leave a #undef DEBUG statement at the top.

That way, I know I can enable debug in that file by flicking it.

Ben.



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

Re: [PATCH 06/17] platinumfb: Fix resource management

From: Geert Uytterhoeven <geert@linux-m68k.org>
Date: 2007-09-30 07:11:49

On Sun, 30 Sep 2007, Benjamin Herrenschmidt wrote:
quoted
Probably scripts/checkpatch.pl should be taught to complain about
`#undef DEBUG'.
Why ? Whenever I have things that are #ifdef DEBUG in the file (such as
dev_dbg statements), I always leave a #undef DEBUG statement at the top.
Because it overrides a -DDEBUG on the build command line.
That way, I know I can enable debug in that file by flicking it.
Just add #define DEBUG at the top?

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

Re: [PATCH 06/17] platinumfb: Fix resource management

From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Date: 2007-09-30 08:03:46

On Sun, 2007-09-30 at 09:11 +0200, Geert Uytterhoeven wrote:
On Sun, 30 Sep 2007, Benjamin Herrenschmidt wrote:
quoted
quoted
Probably scripts/checkpatch.pl should be taught to complain about
`#undef DEBUG'.
Why ? Whenever I have things that are #ifdef DEBUG in the file (such as
dev_dbg statements), I always leave a #undef DEBUG statement at the top.
Because it overrides a -DDEBUG on the build command line.
Hrm... ok, I never play with the commandline :-)
quoted
That way, I know I can enable debug in that file by flicking it.
Just add #define DEBUG at the top?
Yeah well, it's really just a reminder that there's DEBUG stuff in that
file, but feel free to send a patch removing it :-)

Ben.



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

Re: [PATCH 06/17] platinumfb: Fix resource management

From: Andrew Morton <akpm@linux-foundation.org>
Date: 2007-10-03 20:56:47

On Sat, 29 Sep 2007 09:29:53 +0800
"Antonino A. Daplas" [off-list ref] wrote:
Current kernels have a non-working platinumfb due to some resource
management issues. This fixes it.
Why isn't this 2.6.23 material?

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/

Re: [PATCH 06/17] platinumfb: Fix resource management

From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Date: 2007-10-03 21:30:13

On Wed, 2007-10-03 at 13:56 -0700, Andrew Morton wrote:
On Sat, 29 Sep 2007 09:29:53 +0800
"Antonino A. Daplas" [off-list ref] wrote:
quoted
Current kernels have a non-working platinumfb due to some resource
management issues. This fixes it.
Why isn't this 2.6.23 material?
We decided it's been broken long enough and nobody complained so it
wasn't worth pushing. I wouldn't be surprised if there weren't more than
a handful of people left with a PowerMac 7200 which is I think the only
machine using platinumfb.

Feel free to send it to Linus for .23 if you feel like it though.

Cheers,
Ben.



-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help