diff options
author | mjacob <mjacob@FreeBSD.org> | 2002-09-23 19:41:10 +0000 |
---|---|---|
committer | mjacob <mjacob@FreeBSD.org> | 2002-09-23 19:41:10 +0000 |
commit | 7a5bb65c8f40e51112c6edafb46f0f02786fd23b (patch) | |
tree | eb4740a4dabcf359632c49b40b4da68cefcd2ebc /sys/dev/mpt/mpt_pci.c | |
parent | ac315391ceb9f2631fcaa72a6ab3da6255a6598d (diff) | |
download | FreeBSD-src-7a5bb65c8f40e51112c6edafb46f0f02786fd23b.zip FreeBSD-src-7a5bb65c8f40e51112c6edafb46f0f02786fd23b.tar.gz |
Parameterize MPT_MAX_REQUESTS based upon device type (FC has Global Credits
of 1024- Ultra4 256). Rename 'requests' tag to 'request_pool' for clarity.
Make sure we do correct xpt_freeze_simq/CAM_RELEASE_SIMQ if we run out
of chip resources.
MFC after: 6 days
Diffstat (limited to 'sys/dev/mpt/mpt_pci.c')
-rw-r--r-- | sys/dev/mpt/mpt_pci.c | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/sys/dev/mpt/mpt_pci.c b/sys/dev/mpt/mpt_pci.c index d9e3ab6..499dc85 100644 --- a/sys/dev/mpt/mpt_pci.c +++ b/sys/dev/mpt/mpt_pci.c @@ -468,12 +468,31 @@ mpt_dma_mem_alloc(mpt_softc_t *mpt) int i, error; u_char *vptr; u_int32_t pptr, end; + size_t len; struct imush im; device_t dev = mpt->dev; /* Check if we alreay have allocated the reply memory */ - if (mpt->reply_phys != NULL) + if (mpt->reply_phys != NULL) { return 0; + } + + len = sizeof (request_t *) * MPT_REQ_MEM_SIZE(mpt); +#ifdef RELENG_4 + mpt->request_pool = (request_t *) malloc(len, M_DEVBUF, M_WAITOK); + if (mpt->request_pool == NULL) { + device_printf(dev, "cannot allocate request pool\n"); + return (1); + } + bzero(mpt->request_pool, len); +#else + mpt->request_pool = (request_t *) + malloc(len, M_DEVBUF, M_WAITOK | M_ZERO); + if (mpt->request_pool == NULL) { + device_printf(dev, "cannot allocate request pool\n"); + return (1); + } +#endif /* * Create a dma tag for this device @@ -533,7 +552,7 @@ mpt_dma_mem_alloc(mpt_softc_t *mpt) /* Create a child tag for request buffers */ if (bus_dma_tag_create(mpt->parent_dmat, PAGE_SIZE, 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, - NULL, NULL, MPT_REQ_MEM_SIZE, 1, BUS_SPACE_MAXSIZE_32BIT, 0, + NULL, NULL, MPT_REQ_MEM_SIZE(mpt), 1, BUS_SPACE_MAXSIZE_32BIT, 0, &mpt->request_dmat) != 0) { device_printf(dev, "cannot create a dma tag for requests\n"); return (1); @@ -544,7 +563,7 @@ mpt_dma_mem_alloc(mpt_softc_t *mpt) BUS_DMA_NOWAIT, &mpt->request_dmap) != 0) { device_printf(dev, "cannot allocate %d bytes of request memory\n", - MPT_REQ_MEM_SIZE); + MPT_REQ_MEM_SIZE(mpt)); return (1); } @@ -553,7 +572,7 @@ mpt_dma_mem_alloc(mpt_softc_t *mpt) /* Load and lock it into "bus space" */ bus_dmamap_load(mpt->request_dmat, mpt->request_dmap, mpt->request, - MPT_REQ_MEM_SIZE, mpt_map_rquest, &im, 0); + MPT_REQ_MEM_SIZE(mpt), mpt_map_rquest, &im, 0); if (im.error) { device_printf(dev, @@ -566,9 +585,9 @@ mpt_dma_mem_alloc(mpt_softc_t *mpt) i = 0; pptr = mpt->request_phys; vptr = mpt->request; - end = pptr + MPT_REQ_MEM_SIZE; + end = pptr + MPT_REQ_MEM_SIZE(mpt); while(pptr < end) { - request_t *req = &mpt->requests[i]; + request_t *req = &mpt->request_pool[i]; req->index = i++; /* Store location of Request Data */ @@ -607,8 +626,8 @@ mpt_dma_mem_free(mpt_softc_t *mpt) return; } - for (i = 0; i < MPT_MAX_REQUESTS; i++) { - bus_dmamap_destroy(mpt->buffer_dmat, mpt->requests[i].dmap); + for (i = 0; i < MPT_MAX_REQUESTS(mpt); i++) { + bus_dmamap_destroy(mpt->buffer_dmat, mpt->request_pool[i].dmap); } bus_dmamap_unload(mpt->request_dmat, mpt->request_dmap); bus_dmamem_free(mpt->request_dmat, mpt->request, mpt->request_dmap); @@ -619,6 +638,8 @@ mpt_dma_mem_free(mpt_softc_t *mpt) bus_dma_tag_destroy(mpt->reply_dmat); bus_dma_tag_destroy(mpt->parent_dmat); mpt->reply_dmat = 0; + free(mpt->request_pool, M_DEVBUF); + mpt->request_pool = 0; } |