From: Geert U. <ge...@li...> - 2000-09-14 17:02:09
|
On Thu, 14 Sep 2000, Geert Uytterhoeven wrote: > I'll try to cook an (untested) patch... Does this sound OK? Please remove the debug code (marked with FIXME) after testing. These cases just shouldn't happen. One caveat: you must not call amiga_chip_free() for regions allocated with a static resource. --- linux-2.4.0-test8/include/asm-m68k/amigahw.h Mon Jul 17 15:13:48 2000 +++ geert-chipram-2.4.0-test8/include/asm-m68k/amigahw.h Thu Sep 14 16:31:23 2000 @@ -281,7 +281,8 @@ #define CHIP_PHYSADDR (0x000000) #define chipaddr ((unsigned long)(zTwoBase + CHIP_PHYSADDR)) void amiga_chip_init (void); -void *amiga_chip_alloc (long size, const char *name); +void *__amiga_chip_alloc (long size, const char *name, struct resource *res); +#define amiga_chip_alloc(size, name) __amiga_chip_alloc(size, name, NULL) void amiga_chip_free (void *); unsigned long amiga_chip_avail( void ); /*MILAN*/ --- linux-2.4.0-test8/arch/ppc/amiga/chipram.c Tue Jul 18 14:08:47 2000 +++ geert-chipram-2.4.0-test8/arch/ppc/amiga/chipram.c Thu Sep 14 16:34:06 2000 @@ -75,7 +75,7 @@ #endif } -void *amiga_chip_alloc(long size, const char *name) +void *__amiga_chip_alloc(long size, const char *name, struct resource *res) { /* last chunk */ struct chip_desc *dp; @@ -145,9 +145,16 @@ chipavail -= size + (2*sizeof(*dp)); /*MILAN*/ - if (!request_mem_region(ZTWO_PADDR(ptr), size, name)) - printk(KERN_WARNING "amiga_chip_alloc: region of size %ld at 0x%08lx " - "is busy\n", size, ZTWO_PADDR(ptr)); + if (res) { + res.start = ZTWO_PADDR(ptr); + res.end = res.start+size-1; + /* FIXME: remove the actual test and the printk */ + if (!request_resource(&iomem_resource, res)) + printk("amiga_chip_alloc: failed for %s [1]\n", res->name); + } else + /* FIXME: remove the actual test and the printk */ + if (!request_mem_region(ZTWO_PADDR(ptr), size, name)) + printk("amiga_chip_alloc: failed for %s [2]\n", name); return ptr; } --- linux-2.4.0-test8/arch/ppc/amiga/config.c Mon Jul 17 14:57:32 2000 +++ geert-chipram-2.4.0-test8/arch/ppc/amiga/config.c Thu Sep 14 16:35:29 2000 @@ -732,9 +732,12 @@ } } +static struct resource debug_res = { "Debug" }; + static void amiga_savekmsg_init(void) { - savekmsg = (struct savekmsg *)amiga_chip_alloc(SAVEKMSG_MAXMEM); + savekmsg = (struct savekmsg *)amiga_chip_alloc(SAVEKMSG_MAXMEM, NULL, + &debug_res); savekmsg->magic1 = SAVEKMSG_MAGIC1; savekmsg->magic2 = SAVEKMSG_MAGIC2; savekmsg->magicptr = virt_to_phys(savekmsg); --- linux-2.4.0-test8/arch/m68k/amiga/chipram.c Tue Jul 18 14:04:31 2000 +++ geert-chipram-2.4.0-test8/arch/m68k/amiga/chipram.c Thu Sep 14 16:33:18 2000 @@ -67,7 +67,7 @@ #endif } -void *amiga_chip_alloc(long size, const char *name) +void *__amiga_chip_alloc(long size, const char *name, struct resource *res) { /* last chunk */ struct chip_desc *dp; @@ -137,9 +137,16 @@ chipavail -= size + (2*sizeof(*dp)); /*MILAN*/ - if (!request_mem_region(ZTWO_PADDR(ptr), size, name)) - printk(KERN_WARNING "amiga_chip_alloc: region of size %ld at 0x%08lx " - "is busy\n", size, ZTWO_PADDR(ptr)); + if (res) { + res.start = ZTWO_PADDR(ptr); + res.end = res.start+size-1; + /* FIXME: remove the actual test and the printk */ + if (!request_resource(&iomem_resource, res)) + printk("amiga_chip_alloc: failed for %s [1]\n", res->name); + } else + /* FIXME: remove the actual test and the printk */ + if (!request_mem_region(ZTWO_PADDR(ptr), size, name)) + printk("amiga_chip_alloc: failed for %s [2]\n", name); return ptr; } --- linux-2.4.0-test8/arch/m68k/amiga/amisound.c Fri Jul 28 21:19:00 2000 +++ geert-chipram-2.4.0-test8/arch/m68k/amiga/amisound.c Thu Sep 14 16:27:21 2000 @@ -11,6 +11,7 @@ #include <linux/sched.h> #include <linux/timer.h> #include <linux/init.h> +#include <linux/ioport.h> #include <asm/system.h> #include <asm/amigahw.h> @@ -40,9 +41,11 @@ static u_long clock_constant; +static struct resource beep_res = { "Beep" }; + void __init amiga_init_sound(void) { - snd_data = amiga_chip_alloc(sizeof(sine_data), "Beep"); + snd_data = __amiga_chip_alloc(sizeof(sine_data), NULL, &beep_res); if (!snd_data) { printk (KERN_CRIT "amiga init_sound: failed to allocate chipmem\n"); return; --- linux-2.4.0-test8/arch/m68k/amiga/amiga_ksyms.c Tue Jul 18 14:04:31 2000 +++ geert-chipram-2.4.0-test8/arch/m68k/amiga/amiga_ksyms.c Thu Sep 14 16:25:15 2000 @@ -18,7 +18,7 @@ EXPORT_SYMBOL(amiga_hw_present); EXPORT_SYMBOL(amiga_eclock); EXPORT_SYMBOL(amiga_colorclock); -EXPORT_SYMBOL(amiga_chip_alloc); +EXPORT_SYMBOL(__amiga_chip_alloc); EXPORT_SYMBOL(amiga_chip_free); EXPORT_SYMBOL(amiga_chip_avail); EXPORT_SYMBOL(amiga_chip_size); --- linux-2.4.0-test8/arch/m68k/amiga/config.c Mon Jul 17 15:13:27 2000 +++ geert-chipram-2.4.0-test8/arch/m68k/amiga/config.c Thu Sep 14 16:29:34 2000 @@ -828,9 +828,12 @@ } } +static struct resource debug_res = { "Debug" }; + static void amiga_savekmsg_init(void) { - savekmsg = (struct savekmsg *)amiga_chip_alloc(SAVEKMSG_MAXMEM, "Debug"); + savekmsg = (struct savekmsg *)amiga_chip_alloc(SAVEKMSG_MAXMEM, NULL, + &debug_res); savekmsg->magic1 = SAVEKMSG_MAGIC1; savekmsg->magic2 = SAVEKMSG_MAGIC2; savekmsg->magicptr = virt_to_phys(savekmsg); Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@li... 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 |