[Xorg] OT: radeon questions
Gene Heskett
gene.heskett at verizon.net
Mon Jul 12 03:01:55 PDT 2004
On Monday 12 July 2004 05:46, Torgeir Veimo wrote:
>On Mon, 2004-07-12 at 05:06 -0400, Gene Heskett wrote:
>> Greetings;
>>
>> A patch for the kernels radeonfb just went by on lkml, and I've
>> applied it and am rebuilding 2.6.8-rc1.
>
>Do you have an exact link? I don't monitor that ml. Does it still
> use macmodes.h?
Here it is:
From eger at havoc.gtf.org Mon Jul 12 02:22:36 2004
[...]
From: David Eger <eger at havoc.gtf.org>
To: akpm at osdl.org
Cc: benh at kernel.crashing.org,
linux-kernel at vger.kernel.org
Subject: [PATCH] radeonfb: cleanup and little fixes
[...]
Dear Andrew, Please apply.
radeonfb: cleanup and little fixes
Very similar to François Romieu's fixes for cirrusfb, here we:
* Provide meaningful error values from radeonfb_pci_register()
* Fix unbalanced pci_enable_device()
* Fix unbalanced fb_alloc_cmap()
* Fix a failure-case bug where we accidentally memset_io(0, 0, size);
* Use pci_request_regions() instead of request_mem_region()
Signed-off-by: David Eger <eger at havoc.gtf.org>
diff -Nru a/drivers/video/aty/radeon_base.c
b/drivers/video/aty/radeon_base.c
--- a/drivers/video/aty/radeon_base.c 2004-07-12 07:58:26 +02:00
+++ b/drivers/video/aty/radeon_base.c 2004-07-12 07:58:26 +02:00
@@ -2069,19 +2069,22 @@
struct fb_info *info;
struct radeonfb_info *rinfo;
u32 tmp;
+ int ret;
RTRACE("radeonfb_pci_register BEGIN\n");
/* Enable device in PCI config */
- if (pci_enable_device(pdev) != 0) {
+ ret = pci_enable_device(pdev);
+ if (ret < 0) {
printk(KERN_ERR "radeonfb: Cannot enable PCI device\n");
- return -ENODEV;
+ goto err_out;
}
info = framebuffer_alloc(sizeof(struct radeonfb_info), &pdev->dev);
if (!info) {
printk (KERN_ERR "radeonfb: could not allocate memory\n");
- return -ENODEV;
+ ret = -ENOMEM;
+ goto err_disable;
}
rinfo = info->par;
rinfo->info = info;
@@ -2106,23 +2109,19 @@
rinfo->mmio_base_phys = pci_resource_start (pdev, 2);
/* request the mem regions */
- if (!request_mem_region (rinfo->fb_base_phys,
- pci_resource_len(pdev, 0), "radeonfb")) {
- printk (KERN_ERR "radeonfb: cannot reserve FB region\n");
- goto free_rinfo;
- }
-
- if (!request_mem_region (rinfo->mmio_base_phys,
- pci_resource_len(pdev, 2), "radeonfb")) {
- printk (KERN_ERR "radeonfb: cannot reserve MMIO region\n");
- goto release_fb;
+ ret = pci_request_regions(pdev, "radeonfb");
+ if (ret < 0) {
+ printk( KERN_ERR "radeonfb: cannot reserve PCI regions."
+ " Someone already got them?\n");
+ goto err_release_fb;
}
/* map the regions */
- rinfo->mmio_base = (unsigned long) ioremap (rinfo->mmio_base_phys,
RADEON_REGSIZE);
+ rinfo->mmio_base = (unsigned long) ioremap(rinfo->mmio_base_phys,
RADEON_REGSIZE);
if (!rinfo->mmio_base) {
- printk (KERN_ERR "radeonfb: cannot map MMIO\n");
- goto release_mmio;
+ printk(KERN_ERR "radeonfb: cannot map MMIO\n");
+ ret = -EIO;
+ goto err_release_pci;
}
/* On PPC, the firmware sets up a memory mapping that tends
@@ -2226,23 +2225,20 @@
RTRACE("radeonfb: probed %s %ldk videoram\n", (rinfo->ram_type),
(rinfo->video_ram/1024));
- rinfo->mapped_vram = MAX_MAPPED_VRAM;
- if (rinfo->video_ram < rinfo->mapped_vram)
- rinfo->mapped_vram = rinfo->video_ram;
- for (;;) {
+ rinfo->mapped_vram = min_t(unsigned long, MAX_MAPPED_VRAM,
rinfo->video_ram);
+
+ do {
rinfo->fb_base = (unsigned long) ioremap (rinfo->fb_base_phys,
rinfo->mapped_vram);
- if (rinfo->fb_base == 0 && rinfo->mapped_vram > MIN_MAPPED_VRAM) {
- rinfo->mapped_vram /= 2;
- continue;
- }
- memset_io(rinfo->fb_base, 0, rinfo->mapped_vram);
- break;
- }
+ } while ( rinfo->fb_base == 0 &&
+ ((rinfo->mapped_vram /=2) >= MIN_MAPPED_VRAM) );
- if (!rinfo->fb_base) {
+ if (rinfo->fb_base)
+ memset_io(rinfo->fb_base, 0, rinfo->mapped_vram);
+ else {
printk (KERN_ERR "radeonfb: cannot map FB\n");
- goto unmap_rom;
+ ret = -EIO;
+ goto err_unmap_rom;
}
RTRACE("radeonfb: mapped %ldk videoram\n", rinfo->mapped_vram/1024);
@@ -2329,10 +2325,11 @@
radeon_pm_enable_dynamic_mode(rinfo);
printk("radeonfb: Power Management enabled for Mobility
chipsets\n");
}
-
- if (register_framebuffer(info) < 0) {
+
+ ret = register_framebuffer(info);
+ if (ret < 0) {
printk (KERN_ERR "radeonfb: could not register framebuffer\n");
- goto unmap_fb;
+ goto err_unmap_fb;
}
#ifdef CONFIG_MTRR
@@ -2358,30 +2355,30 @@
RTRACE("radeonfb_pci_register END\n");
return 0;
-unmap_fb:
+err_unmap_fb:
iounmap ((void*)rinfo->fb_base);
-unmap_rom:
+err_unmap_rom:
if (rinfo->mon1_EDID)
kfree(rinfo->mon1_EDID);
if (rinfo->mon2_EDID)
kfree(rinfo->mon2_EDID);
if (rinfo->mon1_modedb)
fb_destroy_modedb(rinfo->mon1_modedb);
+ fb_dealloc_cmap(&info->cmap);
#ifdef CONFIG_FB_RADEON_I2C
radeon_delete_i2c_busses(rinfo);
#endif
if (rinfo->bios_seg)
radeon_unmap_ROM(rinfo, pdev);
iounmap ((void*)rinfo->mmio_base);
-release_mmio:
- release_mem_region (rinfo->mmio_base_phys,
- pci_resource_len(pdev, 2));
-release_fb:
- release_mem_region (rinfo->fb_base_phys,
- pci_resource_len(pdev, 0));
-free_rinfo:
+err_release_pci:
+ pci_release_regions(pdev);
+err_release_fb:
framebuffer_release(info);
- return -ENODEV;
+err_disable:
+ pci_disable_device(pdev);
+err_out:
+ return ret;
}
@@ -2413,10 +2410,7 @@
iounmap ((void*)rinfo->mmio_base);
iounmap ((void*)rinfo->fb_base);
- release_mem_region (rinfo->mmio_base_phys,
- pci_resource_len(pdev, 2));
- release_mem_region (rinfo->fb_base_phys,
- pci_resource_len(pdev, 0));
+ pci_release_regions(pdev);
if (rinfo->mon1_EDID)
kfree(rinfo->mon1_EDID);
@@ -2427,7 +2421,9 @@
#ifdef CONFIG_FB_RADEON_I2C
radeon_delete_i2c_busses(rinfo);
#endif
+ fb_dealloc_cmap(&info->cmap);
framebuffer_release(info);
+ pci_disable_device(pdev);
}
-
It compiled ok here & I'm running that kernel now, but its not showing
a link count if I load it.
--
Cheers, Gene
There are 4 boxes to be used in defense of liberty.
Soap, ballot, jury, and ammo.
Please use in that order, starting now. -Ed Howdershelt, Author
Additions to this message made by Gene Heskett are Copyright 2004,
Maurice E. Heskett, all rights reserved.
More information about the xorg
mailing list