diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2011-04-03 17:04:20 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2011-04-03 17:04:20 +0000 |
commit | c7b32dccc9b9e1c3e841938bc4d8cdd005be31de (patch) | |
tree | 32197abe7e2d32ea876265be43b182fa54fba7fe | |
parent | b37645ee58d04ccbc44eef24cadee005f9208de0 (diff) |
Another driver made safer for big mem by dma_alloc/dma_free'ing
memory used for i/o.
ok dlg@ deraadt@
-rw-r--r-- | sys/dev/pci/ahci.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/sys/dev/pci/ahci.c b/sys/dev/pci/ahci.c index f3f9566a135..ffe4e968d28 100644 --- a/sys/dev/pci/ahci.c +++ b/sys/dev/pci/ahci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ahci.c,v 1.172 2011/01/28 06:32:31 dlg Exp $ */ +/* $OpenBSD: ahci.c,v 1.173 2011/04/03 17:04:19 krw Exp $ */ /* * Copyright (c) 2006 David Gwynne <dlg@openbsd.org> @@ -27,6 +27,7 @@ #include <sys/timeout.h> #include <sys/queue.h> #include <sys/mutex.h> +#include <sys/pool.h> #include <machine/bus.h> @@ -391,7 +392,7 @@ struct ahci_port { u_int32_t ap_err_saved_active; u_int32_t ap_err_saved_active_cnt; - u_int8_t ap_err_scratch[512]; + u_int8_t *ap_err_scratch; #ifdef AHCI_DEBUG char ap_name[16]; @@ -1094,6 +1095,12 @@ ahci_port_alloc(struct ahci_softc *sc, u_int port) DEVNAME(sc), port); goto reterr; } + ap->ap_err_scratch = dma_alloc(DEV_BSIZE, PR_NOWAIT | PR_ZERO); + if (ap->ap_err_scratch == NULL) { + printf("%s: unable to allocate DMA scratch buf for port %d\n", + DEVNAME(sc), port); + goto freeport; + } #ifdef AHCI_DEBUG snprintf(ap->ap_name, sizeof(ap->ap_name), "%s.%d", @@ -1318,6 +1325,8 @@ ahci_port_free(struct ahci_softc *sc, u_int port) ahci_dmamem_free(sc, ap->ap_dmamem_rfis); if (ap->ap_dmamem_cmd_table) ahci_dmamem_free(sc, ap->ap_dmamem_cmd_table); + if (ap->ap_err_scratch) + dma_free(ap->ap_err_scratch, DEV_BSIZE); /* bus_space(9) says we dont free the subregions handle */ |