From 48dfa53c5c094f8a22985983b506e73f75556de2 Mon Sep 17 00:00:00 2001 From: David Gwynne Date: Sun, 21 May 2006 18:28:25 +0000 Subject: the maximum possible number of ccbs that a megaraid can use (126 of them) is preallocated in the softc, even if the driver is only ever going to use one of them when running. this allocates them separately during attach as a first step toward having the driver only allocate as many ccbs as the firmware can support. ok krw@ --- sys/dev/ic/ami.c | 13 +++++++++++-- sys/dev/ic/amivar.h | 4 ++-- 2 files changed, 13 insertions(+), 4 deletions(-) (limited to 'sys/dev') diff --git a/sys/dev/ic/ami.c b/sys/dev/ic/ami.c index 347a76c334a..a3bdda90670 100644 --- a/sys/dev/ic/ami.c +++ b/sys/dev/ic/ami.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ami.c,v 1.158 2006/05/21 03:33:53 dlg Exp $ */ +/* $OpenBSD: ami.c,v 1.159 2006/05/21 18:28:24 dlg Exp $ */ /* * Copyright (c) 2001 Michael Shalayeff @@ -315,11 +315,18 @@ ami_attach(struct ami_softc *sc) sc->sc_mbox_pa = htole32(AMIMEM_DVA(sc->sc_mbox_am)); AMI_DPRINTF(AMI_D_CMD, ("mbox_pa=%llx ", sc->sc_mbox_pa)); + sc->sc_ccbs = malloc(sizeof(struct ami_ccb) * AMI_MAXCMDS, + M_DEVBUF, M_NOWAIT); + if (sc->sc_ccbs == NULL) { + printf(": unable to allocate ccbs\n"); + goto free_mbox; + } + sc->sc_ccbmem_am = ami_allocmem(sc, sizeof(struct ami_ccbmem) * AMI_MAXCMDS); if (sc->sc_ccbmem_am == NULL) { printf(": unable to allocate ccb dmamem\n"); - goto free_mbox; + goto free_ccbs; } ccbmem = AMIMEM_KVA(sc->sc_ccbmem_am); @@ -566,6 +573,8 @@ destroy: bus_dmamap_destroy(sc->sc_dmat, ccb->ccb_dmamap); ami_freemem(sc, sc->sc_ccbmem_am); +free_ccbs: + free(sc->sc_ccbs, M_DEVBUF); free_mbox: ami_freemem(sc, sc->sc_mbox_am); free_idata: diff --git a/sys/dev/ic/amivar.h b/sys/dev/ic/amivar.h index d48b49efb68..dc861a51aa2 100644 --- a/sys/dev/ic/amivar.h +++ b/sys/dev/ic/amivar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: amivar.h,v 1.47 2006/04/20 13:02:26 dlg Exp $ */ +/* $OpenBSD: amivar.h,v 1.48 2006/05/21 18:28:24 dlg Exp $ */ /* * Copyright (c) 2001 Michael Shalayeff @@ -110,7 +110,7 @@ struct ami_softc { volatile struct ami_iocmd *sc_mbox; paddr_t sc_mbox_pa; - struct ami_ccb sc_ccbs[AMI_MAXCMDS]; + struct ami_ccb *sc_ccbs; struct ami_ccb_list sc_ccb_freeq, sc_ccb_preq, sc_ccb_runq; struct ami_mem *sc_ccbmem_am; -- cgit v1.2.3