📄 ips.c
字号:
ips_next_controller++; continue; } /* found a controller */ sh = scsi_register(SHT, sizeof(ips_ha_t)); if (sh == NULL) { printk(KERN_WARNING "(%s%d) Unable to register controller with SCSI subsystem - skipping controller\n", ips_name, ips_next_controller); ips_next_controller++; continue; } ha = IPS_HA(sh); memset(ha, 0, sizeof(ips_ha_t)); /* Initialize spin lock */ spin_lock_init(&ha->scb_lock); spin_lock_init(&ha->copp_lock); spin_lock_init(&ha->ips_lock); spin_lock_init(&ha->copp_waitlist.lock); spin_lock_init(&ha->scb_waitlist.lock); spin_lock_init(&ha->scb_activelist.lock); ips_sh[ips_next_controller] = sh; ips_ha[ips_next_controller] = ha; ips_num_controllers++; ha->active = 1; ha->enq = kmalloc(sizeof(IPS_ENQ), GFP_ATOMIC|GFP_DMA); if (!ha->enq) { printk(KERN_WARNING "(%s%d) Unable to allocate host inquiry structure - skipping contoller\n", ips_name, ips_next_controller); ha->active = 0; ips_free(ha); ips_next_controller++; ips_num_controllers--; continue; } ha->adapt = kmalloc(sizeof(IPS_ADAPTER), GFP_ATOMIC|GFP_DMA); if (!ha->adapt) { printk(KERN_WARNING "(%s%d) Unable to allocate host adapt structure - skipping controller\n", ips_name, ips_next_controller); ha->active = 0; ips_free(ha); ips_next_controller++; ips_num_controllers--; continue; } ha->conf = kmalloc(sizeof(IPS_CONF), GFP_ATOMIC|GFP_DMA); if (!ha->conf) { printk(KERN_WARNING "(%s%d) Unable to allocate host conf structure - skipping controller\n", ips_name, ips_next_controller); ha->active = 0; ips_free(ha); ips_next_controller++; ips_num_controllers--; continue; } ha->nvram = kmalloc(sizeof(IPS_NVRAM_P5), GFP_ATOMIC|GFP_DMA); if (!ha->nvram) { printk(KERN_WARNING "(%s%d) Unable to allocate host nvram structure - skipping controller\n", ips_name, ips_next_controller); ha->active = 0; ips_free(ha); ips_next_controller++; ips_num_controllers--; continue; } ha->subsys = kmalloc(sizeof(IPS_SUBSYS), GFP_ATOMIC|GFP_DMA); if (!ha->subsys) { printk(KERN_WARNING "(%s%d) Unable to allocate host subsystem structure - skipping controller\n", ips_name, ips_next_controller); ha->active = 0; ips_free(ha); ips_next_controller++; ips_num_controllers--; continue; } ha->dummy = kmalloc(sizeof(IPS_IO_CMD), GFP_ATOMIC|GFP_DMA); if (!ha->dummy) { printk(KERN_WARNING "(%s%d) Unable to allocate host dummy structure - skipping controller\n", ips_name, ips_next_controller); ha->active = 0; ips_free(ha); ips_next_controller++; ips_num_controllers--; continue; } ha->ioctl_data = kmalloc(IPS_IOCTL_SIZE, GFP_ATOMIC|GFP_DMA); ha->ioctl_datasize = IPS_IOCTL_SIZE; if (!ha->ioctl_data) { printk(KERN_WARNING "(%s%d) Unable to allocate ioctl data - skipping controller\n", ips_name, ips_next_controller); ha->active = 0; ips_free(ha); ips_next_controller++; ips_num_controllers--; continue; } /* Store away needed values for later use */ sh->io_port = io_addr; sh->n_io_port = io_addr ? 255 : 0; sh->unique_id = (io_addr) ? io_addr : mem_addr; sh->irq = irq; sh->select_queue_depths = ips_select_queue_depth; sh->sg_tablesize = sh->hostt->sg_tablesize; sh->can_queue = sh->hostt->can_queue; sh->cmd_per_lun = sh->hostt->cmd_per_lun; sh->unchecked_isa_dma = sh->hostt->unchecked_isa_dma; sh->use_clustering = sh->hostt->use_clustering;#if LINUX_VERSION_CODE < LinuxVersionCode(2,3,32) sh->wish_block = FALSE;#endif /* Store info in HA structure */ ha->irq = irq; ha->io_addr = io_addr; ha->io_len = io_len; ha->mem_addr = mem_addr; ha->mem_len = mem_len; ha->mem_ptr = mem_ptr; ha->ioremap_ptr = ioremap_ptr; ha->host_num = ips_next_controller; ha->revision_id = revision_id; ha->device_id = deviceID[i]; ha->pcidev = dev[i]; /* * Setup Functions */ if (IPS_IS_MORPHEUS(ha)) { /* morpheus */ ha->func.isintr = ips_isintr_morpheus; ha->func.isinit = ips_isinit_morpheus; ha->func.issue = ips_issue_i2o_memio; ha->func.init = ips_init_morpheus; ha->func.statupd = ips_statupd_morpheus; ha->func.reset = ips_reset_morpheus; ha->func.intr = ips_intr_morpheus; ha->func.enableint = ips_enable_int_morpheus; } else if (IPS_USE_MEMIO(ha)) { /* copperhead w/MEMIO */ ha->func.isintr = ips_isintr_copperhead_memio; ha->func.isinit = ips_isinit_copperhead_memio; ha->func.init = ips_init_copperhead_memio; ha->func.statupd = ips_statupd_copperhead_memio; ha->func.statinit = ips_statinit_memio; ha->func.reset = ips_reset_copperhead_memio; ha->func.intr = ips_intr_copperhead; ha->func.erasebios = ips_erase_bios_memio; ha->func.programbios = ips_program_bios_memio; ha->func.verifybios = ips_verify_bios_memio; ha->func.enableint = ips_enable_int_copperhead_memio; if (IPS_USE_I2O_DELIVER(ha)) ha->func.issue = ips_issue_i2o_memio; else ha->func.issue = ips_issue_copperhead_memio; } else { /* copperhead */ ha->func.isintr = ips_isintr_copperhead; ha->func.isinit = ips_isinit_copperhead; ha->func.init = ips_init_copperhead; ha->func.statupd = ips_statupd_copperhead; ha->func.statinit = ips_statinit; ha->func.reset = ips_reset_copperhead; ha->func.intr = ips_intr_copperhead; ha->func.erasebios = ips_erase_bios; ha->func.programbios = ips_program_bios; ha->func.verifybios = ips_verify_bios; ha->func.enableint = ips_enable_int_copperhead; if (IPS_USE_I2O_DELIVER(ha)) ha->func.issue = ips_issue_i2o; else ha->func.issue = ips_issue_copperhead; } /* * Initialize the card if it isn't already */ if (!(*ha->func.isinit)(ha)) { if (!(*ha->func.init)(ha)) { /* * Initialization failed */ printk(KERN_WARNING "(%s%d) unable to initialize controller - skipping controller\n", ips_name, ips_next_controller); ha->active = 0; ips_free(ha); ips_next_controller++; ips_num_controllers--; continue; } } /* install the interrupt handler */ if (request_irq(irq, do_ipsintr, SA_SHIRQ, ips_name, ha)) { printk(KERN_WARNING "(%s%d) unable to install interrupt handler - skipping controller\n", ips_name, ips_next_controller); ha->active = 0; ips_free(ha); ips_next_controller++; ips_num_controllers--; continue; } /* * Allocate a temporary SCB for initialization */ ha->scbs = (ips_scb_t *) kmalloc(sizeof(ips_scb_t), GFP_ATOMIC|GFP_DMA); if (!ha->scbs) { /* couldn't allocate a temp SCB */ printk(KERN_WARNING "(%s%d) unable to allocate CCBs - skipping contoller\n", ips_name, ips_next_controller); ha->active = 0; ips_free(ha); free_irq(ha->irq, ha); ips_next_controller++; ips_num_controllers--; continue; } memset(ha->scbs, 0, sizeof(ips_scb_t)); ha->scbs->sg_list = (IPS_SG_LIST *) kmalloc(sizeof(IPS_SG_LIST) * IPS_MAX_SG, GFP_ATOMIC|GFP_DMA); if (!ha->scbs->sg_list) { /* couldn't allocate a temp SCB S/G list */ printk(KERN_WARNING "(%s%d) unable to allocate CCBs - skipping contoller\n", ips_name, ips_next_controller); ha->active = 0; ips_free(ha); free_irq(ha->irq, ha); ips_next_controller++; ips_num_controllers--; continue; } ha->max_cmds = 1; ips_next_controller++; } while ((dev[i] = pci_find_device(IPS_VENDORID, deviceID[i], dev[i]))); } /* * Do Phase 2 Initialization * Controller init */ for (i = 0; i < ips_next_controller; i++) { ha = ips_ha[i]; sh = ips_sh[i]; if (!ha->active) { scsi_unregister(sh); ips_ha[i] = NULL; ips_sh[i] = NULL; continue; } if (!ips_hainit(ha)) { printk(KERN_WARNING "(%s%d) unable to initialize controller - skipping\n", ips_name, i); ha->active = 0; ips_free(ha); free_irq(ha->irq, ha); scsi_unregister(sh); ips_ha[i] = NULL; ips_sh[i] = NULL; ips_num_controllers--; continue; } /* * Free the temporary SCB */ kfree(ha->scbs->sg_list); kfree(ha->scbs); ha->scbs = NULL; /* allocate CCBs */ if (!ips_allocatescbs(ha)) { printk(KERN_WARNING "(%s%d) unable to allocate CCBs - skipping contoller\n", ips_name, i); ha->active = 0; ips_free(ha); free_irq(ha->irq, ha); scsi_unregister(sh); ips_ha[i] = NULL; ips_sh[i] = NULL; ips_num_controllers--; continue; } /* finish setting values */ sh->max_id = ha->ntargets; sh->max_lun = ha->nlun; sh->max_channel = ha->nbus - 1; sh->can_queue = ha->max_cmds-1; } if (ips_num_controllers > 0) register_reboot_notifier(&ips_notifier); return (ips_num_controllers);#else /* No PCI -- No ServeRAID */ return (0);#endif /* CONFIG_PCI */}/****************************************************************************//* *//* Routine Name: ips_release *//* *//* Routine Description: *//* *//* Remove a driver *//* *//****************************************************************************/intips_release(struct Scsi_Host *sh) { ips_scb_t *scb; ips_ha_t *ha; int i;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -