ok On 04/04/2011, at 1:41 AM, Kenneth R Westerback wrote:
> On Sun, Apr 03, 2011 at 09:38:44AM -0400, Kenneth R Westerback wrote: >> Another allocation/memory use made big mem friendly. >> >> .... Ken > > Try to avoid allocating memory in interrupt context, as pointed out > by dlg@. > > .... Ken > > Index: ahci.c > =================================================================== > RCS file: /cvs/src/sys/dev/pci/ahci.c,v > retrieving revision 1.172 > diff -u -p -r1.172 ahci.c > --- ahci.c 28 Jan 2011 06:32:31 -0000 1.172 > +++ ahci.c 3 Apr 2011 15:33:56 -0000 > @@ -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 > 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_ > 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 */