/* * Uninitialize the resources used during PQI initialization. */ void pqisrc_pqi_uninit(pqisrc_softstate_t *softs) { int i; DBG_FUNC("IN\n"); if(softs->devlist_lockcreated==true){ os_uninit_spinlock(&softs->devlist_lock); softs->devlist_lockcreated = false; } for (i = 0; i < softs->num_op_raid_ibq; i++) { /* OP RAID IB Q */ if(softs->op_raid_ib_q[i].lockcreated==true){ OS_UNINIT_PQILOCK(&softs->op_raid_ib_q[i].lock); softs->op_raid_ib_q[i].lockcreated = false; } /* OP AIO IB Q */ if(softs->op_aio_ib_q[i].lockcreated==true){ OS_UNINIT_PQILOCK(&softs->op_aio_ib_q[i].lock); softs->op_aio_ib_q[i].lockcreated = false; } } /* Free Op queues */ os_dma_mem_free(softs, &softs->op_ibq_dma_mem); os_dma_mem_free(softs, &softs->op_obq_dma_mem); os_dma_mem_free(softs, &softs->event_q_dma_mem); /* Complete all pending commands. */ os_complete_outstanding_cmds_nodevice(softs); /* Free rcb */ pqisrc_free_rcb(softs, softs->max_outstanding_io + 1); /* Free request id lists */ pqisrc_destroy_taglist(softs,&softs->taglist); if(softs->admin_ib_queue.lockcreated==true){ OS_UNINIT_PQILOCK(&softs->admin_ib_queue.lock); softs->admin_ib_queue.lockcreated = false; } /* Free Admin Queue */ os_dma_mem_free(softs, &softs->admin_queue_dma_mem); /* Switch back to SIS mode */ if (pqisrc_force_sis(softs)) { DBG_ERR("Failed to switch back the adapter to SIS mode!\n"); } DBG_FUNC("OUT\n"); }
/* * Initialize the adapter with supported PQI configuration. */ int pqisrc_pqi_init(pqisrc_softstate_t *softs) { int ret = PQI_STATUS_SUCCESS; DBG_FUNC("IN\n"); /* Check the PQI signature */ ret = pqisrc_check_pqimode(softs); if(ret) { DBG_ERR("failed to switch to pqi\n"); goto err_out; } PQI_SAVE_CTRL_MODE(softs, CTRL_PQI_MODE); softs->ctrl_in_pqi_mode = true; /* Get the No. of Online CPUs,NUMA/Processor config from OS */ ret = os_get_processor_config(softs); if (ret) { DBG_ERR("Failed to get processor config from OS %d\n", ret); goto err_out; } softs->intr_type = INTR_TYPE_NONE; /* Get the interrupt count, type, priority available from OS */ ret = os_get_intr_config(softs); if (ret) { DBG_ERR("Failed to get interrupt config from OS %d\n", ret); goto err_out; } /*Enable/Set Legacy INTx Interrupt mask clear pqi register, *if allocated interrupt is legacy type. */ if (INTR_TYPE_FIXED == softs->intr_type) { pqisrc_configure_legacy_intx(softs, true); sis_enable_intx(softs); } /* Create Admin Queue pair*/ ret = pqisrc_create_admin_queue(softs); if(ret) { DBG_ERR("Failed to configure admin queue\n"); goto err_admin_queue; } /* For creating event and IO operational queues we have to submit admin IU requests.So Allocate resources for submitting IUs */ /* Allocate the request container block (rcb) */ ret = pqisrc_allocate_rcb(softs); if (ret == PQI_STATUS_FAILURE) { DBG_ERR("Failed to allocate rcb \n"); goto err_rcb; } /* Allocate & initialize request id queue */ ret = pqisrc_init_taglist(softs,&softs->taglist, softs->max_outstanding_io); if (ret) { DBG_ERR("Failed to allocate memory for request id q : %d\n", ret); goto err_taglist; } ret = pqisrc_configure_op_queues(softs); if (ret) { DBG_ERR("Failed to configure op queue\n"); goto err_config_opq; } /* Create Operational queues */ ret = pqisrc_create_op_queues(softs); if(ret) { DBG_ERR("Failed to create op queue\n"); ret = PQI_STATUS_FAILURE; goto err_create_opq; } softs->ctrl_online = true; DBG_FUNC("OUT\n"); return ret; err_create_opq: err_config_opq: pqisrc_destroy_taglist(softs,&softs->taglist); err_taglist: pqisrc_free_rcb(softs, softs->max_outstanding_io + 1); err_rcb: pqisrc_destroy_admin_queue(softs); err_admin_queue: os_free_intr_config(softs); err_out: DBG_FUNC("OUT failed\n"); return PQI_STATUS_FAILURE; }