FreeBSD/sys/dev/mrsas/mrsas.c
/*
 * mrsas_free_mem:		Frees allocated memory
 * input:				Adapter instance soft state
 *
 * This function is called from mrsas_detach() to free previously allocated
 * memory.
 */
Frees allocated memory
input:                               Adapter instance soft state

This function is called from mrsas_detach() to free previously allocated
memory.
Frees allocated memory input : Adapter instance soft state This function is called from mrsas_detach () to free previously allocated memory .
void
mrsas_free_mem(struct mrsas_softc *sc)
{
	int i;
	u_int32_t max_cmd;
	struct mrsas_mfi_cmd *mfi_cmd;
	struct mrsas_mpt_cmd *mpt_cmd;
	for (i = 0; i < 2; i++) {
		if (sc->raidmap_phys_addr[i])
			bus_dmamap_unload(sc->raidmap_tag[i], sc->raidmap_dmamap[i]);
		if (sc->raidmap_mem[i] != NULL)
			bus_dmamem_free(sc->raidmap_tag[i], sc->raidmap_mem[i], sc->raidmap_dmamap[i]);
		if (sc->raidmap_tag[i] != NULL)
			bus_dma_tag_destroy(sc->raidmap_tag[i]);
		if (sc->ld_drv_map[i] != NULL)
			free(sc->ld_drv_map[i], M_MRSAS);
	}
	for (i = 0; i < 2; i++) {
		if (sc->jbodmap_phys_addr[i])
			bus_dmamap_unload(sc->jbodmap_tag[i], sc->jbodmap_dmamap[i]);
		if (sc->jbodmap_mem[i] != NULL)
			bus_dmamem_free(sc->jbodmap_tag[i], sc->jbodmap_mem[i], sc->jbodmap_dmamap[i]);
		if (sc->jbodmap_tag[i] != NULL)
			bus_dma_tag_destroy(sc->jbodmap_tag[i]);
	}
	if (sc->verbuf_phys_addr)
		bus_dmamap_unload(sc->verbuf_tag, sc->verbuf_dmamap);
	if (sc->verbuf_mem != NULL)
		bus_dmamem_free(sc->verbuf_tag, sc->verbuf_mem, sc->verbuf_dmamap);
	if (sc->verbuf_tag != NULL)
		bus_dma_tag_destroy(sc->verbuf_tag);
	if (sc->sense_phys_addr)
		bus_dmamap_unload(sc->sense_tag, sc->sense_dmamap);
	if (sc->sense_mem != NULL)
		bus_dmamem_free(sc->sense_tag, sc->sense_mem, sc->sense_dmamap);
	if (sc->sense_tag != NULL)
		bus_dma_tag_destroy(sc->sense_tag);
	if (sc->chain_frame_phys_addr)
		bus_dmamap_unload(sc->chain_frame_tag, sc->chain_frame_dmamap);
	if (sc->chain_frame_mem != NULL)
		bus_dmamem_free(sc->chain_frame_tag, sc->chain_frame_mem, sc->chain_frame_dmamap);
	if (sc->chain_frame_tag != NULL)
		bus_dma_tag_destroy(sc->chain_frame_tag);
	if (sc->io_request_phys_addr)
		bus_dmamap_unload(sc->io_request_tag, sc->io_request_dmamap);
	if (sc->io_request_mem != NULL)
		bus_dmamem_free(sc->io_request_tag, sc->io_request_mem, sc->io_request_dmamap);
	if (sc->io_request_tag != NULL)
		bus_dma_tag_destroy(sc->io_request_tag);
	if (sc->reply_desc_phys_addr)
		bus_dmamap_unload(sc->reply_desc_tag, sc->reply_desc_dmamap);
	if (sc->reply_desc_mem != NULL)
		bus_dmamem_free(sc->reply_desc_tag, sc->reply_desc_mem, sc->reply_desc_dmamap);
	if (sc->reply_desc_tag != NULL)
		bus_dma_tag_destroy(sc->reply_desc_tag);
	if (sc->evt_detail_phys_addr)
		bus_dmamap_unload(sc->evt_detail_tag, sc->evt_detail_dmamap);
	if (sc->evt_detail_mem != NULL)
		bus_dmamem_free(sc->evt_detail_tag, sc->evt_detail_mem, sc->evt_detail_dmamap);
	if (sc->evt_detail_tag != NULL)
		bus_dma_tag_destroy(sc->evt_detail_tag);
	if (sc->mfi_cmd_list) {
		for (i = 0; i < MRSAS_MAX_MFI_CMDS; i++) {
			mfi_cmd = sc->mfi_cmd_list[i];
			mrsas_free_frame(sc, mfi_cmd);
		}
	}
	if (sc->mficmd_frame_tag != NULL)
		bus_dma_tag_destroy(sc->mficmd_frame_tag);
	max_cmd = sc->max_fw_cmds;
	if (sc->mpt_cmd_list) {
		for (i = 0; i < max_cmd; i++) {
			mpt_cmd = sc->mpt_cmd_list[i];
			bus_dmamap_destroy(sc->data_tag, mpt_cmd->data_dmamap);
			free(sc->mpt_cmd_list[i], M_MRSAS);
		}
		free(sc->mpt_cmd_list, M_MRSAS);
		sc->mpt_cmd_list = NULL;
	}
	if (sc->mfi_cmd_list) {
		for (i = 0; i < MRSAS_MAX_MFI_CMDS; i++) {
			free(sc->mfi_cmd_list[i], M_MRSAS);
		}
		free(sc->mfi_cmd_list, M_MRSAS);
		sc->mfi_cmd_list = NULL;
	}
	free(sc->req_desc, M_MRSAS);
	sc->req_desc = NULL;
	if (sc->mrsas_parent_tag != NULL)
		bus_dma_tag_destroy(sc->mrsas_parent_tag);
	if (sc->ctrl_info != NULL)
		free(sc->ctrl_info, M_MRSAS);
}
void mrsas_free_mem ( struct mrsas_softc * sc ) { int i ; u_int32_t max_cmd ; struct mrsas_mfi_cmd * mfi_cmd ; struct mrsas_mpt_cmd * mpt_cmd ; for ( i = 0 ; i < 2 ; i ++ ) { if ( sc -> raidmap_phys_addr [ i ] ) bus_dmamap_unload ( sc -> raidmap_tag [ i ] , sc -> raidmap_dmamap [ i ] ) ; if ( sc -> raidmap_mem [ i ] != NULL ) bus_dmamem_free ( sc -> raidmap_tag [ i ] , sc -> raidmap_mem [ i ] , sc -> raidmap_dmamap [ i ] ) ; if ( sc -> raidmap_tag [ i ] != NULL ) bus_dma_tag_destroy ( sc -> raidmap_tag [ i ] ) ; if ( sc -> ld_drv_map [ i ] != NULL ) free ( sc -> ld_drv_map [ i ] , M_MRSAS ) ; } for ( i = 0 ; i < 2 ; i ++ ) { if ( sc -> jbodmap_phys_addr [ i ] ) bus_dmamap_unload ( sc -> jbodmap_tag [ i ] , sc -> jbodmap_dmamap [ i ] ) ; if ( sc -> jbodmap_mem [ i ] != NULL ) bus_dmamem_free ( sc -> jbodmap_tag [ i ] , sc -> jbodmap_mem [ i ] , sc -> jbodmap_dmamap [ i ] ) ; if ( sc -> jbodmap_tag [ i ] != NULL ) bus_dma_tag_destroy ( sc -> jbodmap_tag [ i ] ) ; } if ( sc -> verbuf_phys_addr ) bus_dmamap_unload ( sc -> verbuf_tag , sc -> verbuf_dmamap ) ; if ( sc -> verbuf_mem != NULL ) bus_dmamem_free ( sc -> verbuf_tag , sc -> verbuf_mem , sc -> verbuf_dmamap ) ; if ( sc -> verbuf_tag != NULL ) bus_dma_tag_destroy ( sc -> verbuf_tag ) ; if ( sc -> sense_phys_addr ) bus_dmamap_unload ( sc -> sense_tag , sc -> sense_dmamap ) ; if ( sc -> sense_mem != NULL ) bus_dmamem_free ( sc -> sense_tag , sc -> sense_mem , sc -> sense_dmamap ) ; if ( sc -> sense_tag != NULL ) bus_dma_tag_destroy ( sc -> sense_tag ) ; if ( sc -> chain_frame_phys_addr ) bus_dmamap_unload ( sc -> chain_frame_tag , sc -> chain_frame_dmamap ) ; if ( sc -> chain_frame_mem != NULL ) bus_dmamem_free ( sc -> chain_frame_tag , sc -> chain_frame_mem , sc -> chain_frame_dmamap ) ; if ( sc -> chain_frame_tag != NULL ) bus_dma_tag_destroy ( sc -> chain_frame_tag ) ; if ( sc -> io_request_phys_addr ) bus_dmamap_unload ( sc -> io_request_tag , sc -> io_request_dmamap ) ; if ( sc -> io_request_mem != NULL ) bus_dmamem_free ( sc -> io_request_tag , sc -> io_request_mem , sc -> io_request_dmamap ) ; if ( sc -> io_request_tag != NULL ) bus_dma_tag_destroy ( sc -> io_request_tag ) ; if ( sc -> reply_desc_phys_addr ) bus_dmamap_unload ( sc -> reply_desc_tag , sc -> reply_desc_dmamap ) ; if ( sc -> reply_desc_mem != NULL ) bus_dmamem_free ( sc -> reply_desc_tag , sc -> reply_desc_mem , sc -> reply_desc_dmamap ) ; if ( sc -> reply_desc_tag != NULL ) bus_dma_tag_destroy ( sc -> reply_desc_tag ) ; if ( sc -> evt_detail_phys_addr ) bus_dmamap_unload ( sc -> evt_detail_tag , sc -> evt_detail_dmamap ) ; if ( sc -> evt_detail_mem != NULL ) bus_dmamem_free ( sc -> evt_detail_tag , sc -> evt_detail_mem , sc -> evt_detail_dmamap ) ; if ( sc -> evt_detail_tag != NULL ) bus_dma_tag_destroy ( sc -> evt_detail_tag ) ; if ( sc -> mfi_cmd_list ) { for ( i = 0 ; i < MRSAS_MAX_MFI_CMDS ; i ++ ) { mfi_cmd = sc -> mfi_cmd_list [ i ] ; mrsas_free_frame ( sc , mfi_cmd ) ; } } if ( sc -> mficmd_frame_tag != NULL ) bus_dma_tag_destroy ( sc -> mficmd_frame_tag ) ; max_cmd = sc -> max_fw_cmds ; if ( sc -> mpt_cmd_list ) { for ( i = 0 ; i < max_cmd ; i ++ ) { mpt_cmd = sc -> mpt_cmd_list [ i ] ; bus_dmamap_destroy ( sc -> data_tag , mpt_cmd -> data_dmamap ) ; free ( sc -> mpt_cmd_list [ i ] , M_MRSAS ) ; } free ( sc -> mpt_cmd_list , M_MRSAS ) ; sc -> mpt_cmd_list = NULL ; } if ( sc -> mfi_cmd_list ) { for ( i = 0 ; i < MRSAS_MAX_MFI_CMDS ; i ++ ) { free ( sc -> mfi_cmd_list [ i ] , M_MRSAS ) ; } free ( sc -> mfi_cmd_list , M_MRSAS ) ; sc -> mfi_cmd_list = NULL ; } free ( sc -> req_desc , M_MRSAS ) ; sc -> req_desc = NULL ; if ( sc -> mrsas_parent_tag != NULL ) bus_dma_tag_destroy ( sc -> mrsas_parent_tag ) ; if ( sc -> ctrl_info != NULL ) free ( sc -> ctrl_info , M_MRSAS ) ; }
mrsas_free_mem:              Frees allocated memory
 input:                               Adapter instance soft state
mrsas_free_mem : Frees allocated memory input : Adapter instance soft state
/*
	 * Free RAID map memory
	 */ /*
	 * Free version buffer memory
	 */ /*
	 * Free sense buffer memory
	 */ /*
	 * Free chain frame memory
	 */ /*
	 * Free IO Request memory
	 */ /*
	 * Free Reply Descriptor memory
	 */ /*
	 * Free event detail memory
	 */ /*
	 * Free MFI frames
	 */ /*
	 * Free MPT internal command list
	 */ /*
	 * Free MFI internal command list
	 */ /*
	 * Free request descriptor memory
	 */ /*
	 * Destroy parent tag
	 */ /*
	 * Free ctrl_info memory
	 */