FreeBSD/sys/dev/mps/mps.c
/*
 * This is called if memory is being free (during detach for example) and when
 * buffers need to be reallocated due to a Diag Reset.
 */
This is called if memory is being free (during detach for example) and when
buffers need to be reallocated due to a Diag Reset.
This is called if memory is being free ( during detach for example ) and when buffers need to be reallocated due to a Diag Reset .
static void
mps_iocfacts_free(struct mps_softc *sc)
{
	struct mps_command *cm;
	int i;
	mps_dprint(sc, MPS_TRACE, "%s\n", __func__);
	if (sc->free_busaddr != 0)
		bus_dmamap_unload(sc->queues_dmat, sc->queues_map);
	if (sc->free_queue != NULL)
		bus_dmamem_free(sc->queues_dmat, sc->free_queue,
		    sc->queues_map);
	if (sc->queues_dmat != NULL)
		bus_dma_tag_destroy(sc->queues_dmat);
	if (sc->chain_busaddr != 0)
		bus_dmamap_unload(sc->chain_dmat, sc->chain_map);
	if (sc->chain_frames != NULL)
		bus_dmamem_free(sc->chain_dmat, sc->chain_frames,
		    sc->chain_map);
	if (sc->chain_dmat != NULL)
		bus_dma_tag_destroy(sc->chain_dmat);
	if (sc->sense_busaddr != 0)
		bus_dmamap_unload(sc->sense_dmat, sc->sense_map);
	if (sc->sense_frames != NULL)
		bus_dmamem_free(sc->sense_dmat, sc->sense_frames,
		    sc->sense_map);
	if (sc->sense_dmat != NULL)
		bus_dma_tag_destroy(sc->sense_dmat);
	if (sc->reply_busaddr != 0)
		bus_dmamap_unload(sc->reply_dmat, sc->reply_map);
	if (sc->reply_frames != NULL)
		bus_dmamem_free(sc->reply_dmat, sc->reply_frames,
		    sc->reply_map);
	if (sc->reply_dmat != NULL)
		bus_dma_tag_destroy(sc->reply_dmat);
	if (sc->req_busaddr != 0)
		bus_dmamap_unload(sc->req_dmat, sc->req_map);
	if (sc->req_frames != NULL)
		bus_dmamem_free(sc->req_dmat, sc->req_frames, sc->req_map);
	if (sc->req_dmat != NULL)
		bus_dma_tag_destroy(sc->req_dmat);
	if (sc->chains != NULL)
		free(sc->chains, M_MPT2);
	if (sc->commands != NULL) {
		for (i = 1; i < sc->num_reqs; i++) {
			cm = &sc->commands[i];
			bus_dmamap_destroy(sc->buffer_dmat, cm->cm_dmamap);
		}
		free(sc->commands, M_MPT2);
	}
	if (sc->buffer_dmat != NULL)
		bus_dma_tag_destroy(sc->buffer_dmat);
}
static void mps_iocfacts_free ( struct mps_softc * sc ) { struct mps_command * cm ; int i ; mps_dprint ( sc , MPS_TRACE , " \n " , __func__ ) ; if ( sc -> free_busaddr != 0 ) bus_dmamap_unload ( sc -> queues_dmat , sc -> queues_map ) ; if ( sc -> free_queue != NULL ) bus_dmamem_free ( sc -> queues_dmat , sc -> free_queue , sc -> queues_map ) ; if ( sc -> queues_dmat != NULL ) bus_dma_tag_destroy ( sc -> queues_dmat ) ; if ( sc -> chain_busaddr != 0 ) bus_dmamap_unload ( sc -> chain_dmat , sc -> chain_map ) ; if ( sc -> chain_frames != NULL ) bus_dmamem_free ( sc -> chain_dmat , sc -> chain_frames , sc -> chain_map ) ; if ( sc -> chain_dmat != NULL ) bus_dma_tag_destroy ( sc -> chain_dmat ) ; if ( sc -> sense_busaddr != 0 ) bus_dmamap_unload ( sc -> sense_dmat , sc -> sense_map ) ; if ( sc -> sense_frames != NULL ) bus_dmamem_free ( sc -> sense_dmat , sc -> sense_frames , sc -> sense_map ) ; if ( sc -> sense_dmat != NULL ) bus_dma_tag_destroy ( sc -> sense_dmat ) ; if ( sc -> reply_busaddr != 0 ) bus_dmamap_unload ( sc -> reply_dmat , sc -> reply_map ) ; if ( sc -> reply_frames != NULL ) bus_dmamem_free ( sc -> reply_dmat , sc -> reply_frames , sc -> reply_map ) ; if ( sc -> reply_dmat != NULL ) bus_dma_tag_destroy ( sc -> reply_dmat ) ; if ( sc -> req_busaddr != 0 ) bus_dmamap_unload ( sc -> req_dmat , sc -> req_map ) ; if ( sc -> req_frames != NULL ) bus_dmamem_free ( sc -> req_dmat , sc -> req_frames , sc -> req_map ) ; if ( sc -> req_dmat != NULL ) bus_dma_tag_destroy ( sc -> req_dmat ) ; if ( sc -> chains != NULL ) free ( sc -> chains , M_MPT2 ) ; if ( sc -> commands != NULL ) { for ( i = 1 ; i < sc -> num_reqs ; i ++ ) { cm = & sc -> commands [ i ] ; bus_dmamap_destroy ( sc -> buffer_dmat , cm -> cm_dmamap ) ; } free ( sc -> commands , M_MPT2 ) ; } if ( sc -> buffer_dmat != NULL ) bus_dma_tag_destroy ( sc -> buffer_dmat ) ; }
This is called if memory is being free (during detach for example) and when
 buffers need to be reallocated due to a Diag Reset.
This is called if memory is being free ( during detach for example ) and when buffers need to be reallocated due to a Diag Reset .