From 97fe41b76644a3904b13d85610c9008e0db9896c Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Wed, 24 Mar 2004 20:42:12 +0000 Subject: [PATCH] Fix malloc semantics (M_NOWAIT->M_INTWAIT/M_WAITOK). --- sys/dev/agp/agp.c | 13 +++++-------- sys/dev/agp/agp_amd.c | 27 ++++----------------------- sys/dev/agp/agp_i810.c | 10 +++------- 3 files changed, 12 insertions(+), 38 deletions(-) diff --git a/sys/dev/agp/agp.c b/sys/dev/agp/agp.c index 9b72f20740..a9623b1242 100644 --- a/sys/dev/agp/agp.c +++ b/sys/dev/agp/agp.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/pci/agp.c,v 1.3.2.4 2002/08/11 19:58:12 alc Exp $ - * $DragonFly: src/sys/dev/agp/agp.c,v 1.10 2004/03/01 06:33:13 dillon Exp $ + * $DragonFly: src/sys/dev/agp/agp.c,v 1.11 2004/03/24 20:42:12 dillon Exp $ */ #include "opt_bus.h" @@ -182,13 +182,10 @@ agp_alloc_gatt(device_t dev) return NULL; } - gatt = malloc(sizeof(struct agp_gatt), M_AGP, M_NOWAIT); - if (!gatt) - return 0; - + gatt = malloc(sizeof(struct agp_gatt), M_AGP, M_INTWAIT); gatt->ag_entries = entries; - gatt->ag_virtual = contigmalloc(entries * sizeof(u_int32_t), M_AGP, 0, - 0, ~0, PAGE_SIZE, 0); + gatt->ag_virtual = contigmalloc(entries * sizeof(u_int32_t), M_AGP, + M_WAITOK, 0, ~0, PAGE_SIZE, 0); if (!gatt->ag_virtual) { if (bootverbose) device_printf(dev, "contiguous allocation failed\n"); @@ -453,7 +450,7 @@ agp_generic_alloc_memory(device_t dev, int type, vm_size_t size) return 0; } - mem = malloc(sizeof *mem, M_AGP, M_WAITOK); + mem = malloc(sizeof *mem, M_AGP, M_INTWAIT); mem->am_id = sc->as_nextid++; mem->am_size = size; mem->am_type = 0; diff --git a/sys/dev/agp/agp_amd.c b/sys/dev/agp/agp_amd.c index 01c5b56ee9..bb1a3b1ed7 100644 --- a/sys/dev/agp/agp_amd.c +++ b/sys/dev/agp/agp_amd.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/pci/agp_amd.c,v 1.3.2.4 2002/04/25 23:41:36 cokane Exp $ - * $DragonFly: src/sys/dev/agp/agp_amd.c,v 1.4 2003/12/09 19:40:56 dillon Exp $ + * $DragonFly: src/sys/dev/agp/agp_amd.c,v 1.5 2004/03/24 20:42:12 dillon Exp $ */ #include "opt_bus.h" @@ -87,9 +87,7 @@ agp_amd_alloc_gatt(device_t dev) "allocating GATT for aperture of size %dM\n", apsize / (1024*1024)); - gatt = malloc(sizeof(struct agp_amd_gatt), M_AGP, M_NOWAIT); - if (!gatt) - return 0; + gatt = malloc(sizeof(struct agp_amd_gatt), M_AGP, M_INTWAIT); /* * The AMD751 uses a page directory to map a non-contiguous @@ -99,29 +97,12 @@ agp_amd_alloc_gatt(device_t dev) */ gatt->ag_entries = entries; gatt->ag_virtual = malloc(entries * sizeof(u_int32_t), - M_AGP, M_NOWAIT); - if (!gatt->ag_virtual) { - if (bootverbose) - device_printf(dev, "allocation failed\n"); - free(gatt, M_AGP); - return 0; - } - bzero(gatt->ag_virtual, entries * sizeof(u_int32_t)); + M_AGP, M_INTWAIT | M_ZERO); /* * Allocate the page directory. */ - gatt->ag_vdir = malloc(AGP_PAGE_SIZE, M_AGP, M_NOWAIT); - - if (!gatt->ag_vdir) { - if (bootverbose) - device_printf(dev, - "failed to allocate page directory\n"); - free(gatt->ag_virtual, M_AGP); - free(gatt, M_AGP); - return 0; - } - bzero(gatt->ag_vdir, AGP_PAGE_SIZE); + gatt->ag_vdir = malloc(AGP_PAGE_SIZE, M_AGP, M_INTWAIT | M_ZERO); gatt->ag_pdir = vtophys((vm_offset_t) gatt->ag_vdir); if(bootverbose) device_printf(dev, "gatt -> ag_pdir %8x\n", diff --git a/sys/dev/agp/agp_i810.c b/sys/dev/agp/agp_i810.c index 4879f12755..c84b4b1ca3 100644 --- a/sys/dev/agp/agp_i810.c +++ b/sys/dev/agp/agp_i810.c @@ -25,7 +25,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/pci/agp_i810.c,v 1.1.2.5 2002/09/15 08:45:41 anholt Exp $ - * $DragonFly: src/sys/dev/agp/agp_i810.c,v 1.5 2004/01/20 05:04:03 dillon Exp $ + * $DragonFly: src/sys/dev/agp/agp_i810.c,v 1.6 2004/03/24 20:42:12 dillon Exp $ */ /* @@ -244,11 +244,7 @@ agp_i810_attach(device_t dev) return ENXIO; } - gatt = malloc( sizeof(struct agp_gatt), M_AGP, M_NOWAIT); - if (!gatt) { - agp_generic_detach(dev); - return ENOMEM; - } + gatt = malloc( sizeof(struct agp_gatt), M_AGP, M_INTWAIT); sc->gatt = gatt; gatt->ag_entries = AGP_GET_APERTURE(dev) >> AGP_PAGE_SHIFT; @@ -503,7 +499,7 @@ agp_i810_alloc_memory(device_t dev, int type, vm_size_t size) return 0; } - mem = malloc(sizeof *mem, M_AGP, M_WAITOK); + mem = malloc(sizeof *mem, M_AGP, M_INTWAIT); mem->am_id = sc->agp.as_nextid++; mem->am_size = size; mem->am_type = type; -- 2.41.0