Lines Matching refs:pHba

150 static inline int dpt_dma64(adpt_hba *pHba)  in dpt_dma64()  argument
152 return (sizeof(dma_addr_t) > 4 && (pHba)->dma64); in dpt_dma64()
193 adpt_hba *pHba; in adpt_detect() local
212 for (pHba = hba_chain; pHba; pHba = next) { in adpt_detect()
213 next = pHba->next; in adpt_detect()
215 if (adpt_i2o_activate_hba(pHba) < 0) { in adpt_detect()
216 adpt_i2o_delete_hba(pHba); in adpt_detect()
239 for (pHba = hba_chain; pHba; pHba = pHba->next) { in adpt_detect()
240 if (adpt_i2o_online_hba(pHba) < 0) { in adpt_detect()
241 adpt_i2o_delete_hba(pHba); in adpt_detect()
250 for (pHba = hba_chain; pHba; pHba = next) { in adpt_detect()
251 next = pHba->next; in adpt_detect()
252 printk(KERN_INFO"%s: Reading the hardware resource table.\n", pHba->name); in adpt_detect()
253 if (adpt_i2o_lct_get(pHba) < 0){ in adpt_detect()
254 adpt_i2o_delete_hba(pHba); in adpt_detect()
258 if (adpt_i2o_parse_lct(pHba) < 0){ in adpt_detect()
259 adpt_i2o_delete_hba(pHba); in adpt_detect()
262 adpt_inquiry(pHba); in adpt_detect()
271 for (pHba = hba_chain; pHba; pHba = next) { in adpt_detect()
272 next = pHba->next; in adpt_detect()
273 if (adpt_scsi_host_alloc(pHba, sht) < 0){ in adpt_detect()
274 adpt_i2o_delete_hba(pHba); in adpt_detect()
277 pHba->initialized = TRUE; in adpt_detect()
278 pHba->state &= ~DPTI_STATE_RESET; in adpt_detect()
281 NULL, MKDEV(DPTI_I2O_MAJOR, pHba->unit), NULL, in adpt_detect()
282 "dpti%d", pHba->unit); in adpt_detect()
286 pHba->unit); in adpt_detect()
302 static void adpt_release(adpt_hba *pHba) in adpt_release() argument
304 struct Scsi_Host *shost = pHba->host; in adpt_release()
308 adpt_i2o_delete_hba(pHba); in adpt_release()
313 static void adpt_inquiry(adpt_hba* pHba) in adpt_inquiry() argument
328 buf = dma_alloc_coherent(&pHba->pDev->dev, 80, &addr, GFP_KERNEL); in adpt_inquiry()
330 printk(KERN_ERR"%s: Could not allocate buffer\n",pHba->name); in adpt_inquiry()
339 if (dpt_dma64(pHba)) in adpt_inquiry()
375 if (dpt_dma64(pHba)) { in adpt_inquiry()
387 rcode = adpt_i2o_post_wait(pHba, msg, reqlen<<2, 120); in adpt_inquiry()
389 sprintf(pHba->detail, "Adaptec I2O RAID"); in adpt_inquiry()
390 printk(KERN_INFO "%s: Inquiry Error (%d)\n",pHba->name,rcode); in adpt_inquiry()
392 dma_free_coherent(&pHba->pDev->dev, 80, buf, addr); in adpt_inquiry()
394 memset(pHba->detail, 0, sizeof(pHba->detail)); in adpt_inquiry()
395 memcpy(&(pHba->detail), "Vendor: Adaptec ", 16); in adpt_inquiry()
396 memcpy(&(pHba->detail[16]), " Model: ", 8); in adpt_inquiry()
397 memcpy(&(pHba->detail[24]), (u8*) &buf[16], 16); in adpt_inquiry()
398 memcpy(&(pHba->detail[40]), " FW: ", 4); in adpt_inquiry()
399 memcpy(&(pHba->detail[44]), (u8*) &buf[32], 4); in adpt_inquiry()
400 pHba->detail[48] = '\0'; /* precautionary */ in adpt_inquiry()
401 dma_free_coherent(&pHba->pDev->dev, 80, buf, addr); in adpt_inquiry()
403 adpt_i2o_status_get(pHba); in adpt_inquiry()
421 adpt_hba* pHba = NULL; in adpt_queue_lck() local
438 pHba = (adpt_hba*)cmd->device->host->hostdata[0]; in adpt_queue_lck()
439 if (!pHba) { in adpt_queue_lck()
444 if ((pHba->state) & DPTI_STATE_RESET) in adpt_queue_lck()
455 …if ((pDev = adpt_find_device(pHba, (u32)cmd->device->channel, (u32)cmd->device->id, cmd->device->l… in adpt_queue_lck()
473 return adpt_scsi_to_i2o(pHba, cmd, pDev); in adpt_queue_lck()
532 adpt_hba* pHba; in adpt_info() local
534 pHba = (adpt_hba *) host->hostdata[0]; in adpt_info()
535 return (char *) (pHba->detail); in adpt_info()
543 adpt_hba* pHba; in adpt_show_info() local
548 for (pHba = hba_chain; pHba; pHba = pHba->next) { in adpt_show_info()
549 if (pHba->host == host) { in adpt_show_info()
554 if (pHba == NULL) { in adpt_show_info()
557 host = pHba->host; in adpt_show_info()
560 seq_printf(m, "%s\n", pHba->detail); in adpt_show_info()
562 pHba->host->host_no, pHba->name, host->irq); in adpt_show_info()
564 host->can_queue, (int) pHba->reply_fifo_size , host->sg_tablesize); in adpt_show_info()
569 d = pHba->channel[chan].device[id]; in adpt_show_info()
588 static u32 adpt_ioctl_to_context(adpt_hba * pHba, void *reply) in adpt_ioctl_to_context() argument
596 spin_lock_irqsave(pHba->host->host_lock, flags); in adpt_ioctl_to_context()
597 nr = ARRAY_SIZE(pHba->ioctl_reply_context); in adpt_ioctl_to_context()
599 if (pHba->ioctl_reply_context[i] == NULL) { in adpt_ioctl_to_context()
600 pHba->ioctl_reply_context[i] = reply; in adpt_ioctl_to_context()
604 spin_unlock_irqrestore(pHba->host->host_lock, flags); in adpt_ioctl_to_context()
607 "ioctl commands\n", pHba->name); in adpt_ioctl_to_context()
618 static void *adpt_ioctl_from_context(adpt_hba *pHba, u32 context) in adpt_ioctl_from_context() argument
623 void *p = pHba->ioctl_reply_context[context]; in adpt_ioctl_from_context()
624 pHba->ioctl_reply_context[context] = NULL; in adpt_ioctl_from_context()
637 adpt_hba* pHba = NULL; /* host bus adapter structure */ in adpt_abort() local
642 pHba = (adpt_hba*) cmd->device->host->hostdata[0]; in adpt_abort()
643 printk(KERN_INFO"%s: Trying to Abort\n",pHba->name); in adpt_abort()
645 printk(KERN_ERR "%s: Unable to abort: No device in cmnd\n",pHba->name); in adpt_abort()
656 if (pHba->host) in adpt_abort()
657 spin_lock_irq(pHba->host->host_lock); in adpt_abort()
658 rcode = adpt_i2o_post_wait(pHba, msg, sizeof(msg), FOREVER); in adpt_abort()
659 if (pHba->host) in adpt_abort()
660 spin_unlock_irq(pHba->host->host_lock); in adpt_abort()
663 printk(KERN_INFO"%s: Abort cmd not supported\n",pHba->name); in adpt_abort()
666 printk(KERN_INFO"%s: Abort failed.\n",pHba->name); in adpt_abort()
669 printk(KERN_INFO"%s: Abort complete.\n",pHba->name); in adpt_abort()
680 adpt_hba* pHba; in adpt_device_reset() local
686 pHba = (void*) cmd->device->host->hostdata[0]; in adpt_device_reset()
687 printk(KERN_INFO"%s: Trying to reset device\n",pHba->name); in adpt_device_reset()
689 printk(KERN_INFO"%s: Reset Device: Device Not found\n",pHba->name); in adpt_device_reset()
698 if (pHba->host) in adpt_device_reset()
699 spin_lock_irq(pHba->host->host_lock); in adpt_device_reset()
702 rcode = adpt_i2o_post_wait(pHba, msg,sizeof(msg), FOREVER); in adpt_device_reset()
704 if (pHba->host) in adpt_device_reset()
705 spin_unlock_irq(pHba->host->host_lock); in adpt_device_reset()
708 printk(KERN_INFO"%s: Device reset not supported\n",pHba->name); in adpt_device_reset()
711 printk(KERN_INFO"%s: Device reset failed\n",pHba->name); in adpt_device_reset()
714 printk(KERN_INFO"%s: Device reset successful\n",pHba->name); in adpt_device_reset()
724 adpt_hba* pHba; in adpt_bus_reset() local
728 pHba = (adpt_hba*)cmd->device->host->hostdata[0]; in adpt_bus_reset()
730 …printk(KERN_WARNING"%s: Bus reset: SCSI Bus %d: tid: %d\n",pHba->name, cmd->device->channel,pHba->… in adpt_bus_reset()
732 msg[1] = (I2O_HBA_BUS_RESET<<24|HOST_TID<<12|pHba->channel[cmd->device->channel].tid); in adpt_bus_reset()
735 if (pHba->host) in adpt_bus_reset()
736 spin_lock_irq(pHba->host->host_lock); in adpt_bus_reset()
737 rcode = adpt_i2o_post_wait(pHba, msg,sizeof(msg), FOREVER); in adpt_bus_reset()
738 if (pHba->host) in adpt_bus_reset()
739 spin_unlock_irq(pHba->host->host_lock); in adpt_bus_reset()
741 printk(KERN_WARNING"%s: Bus reset failed.\n",pHba->name); in adpt_bus_reset()
744 printk(KERN_WARNING"%s: Bus reset success.\n",pHba->name); in adpt_bus_reset()
752 adpt_hba* pHba; in __adpt_reset() local
756 pHba = (adpt_hba*)cmd->device->host->hostdata[0]; in __adpt_reset()
757 strncpy(name, pHba->name, sizeof(name)); in __adpt_reset()
758 …printk(KERN_WARNING"%s: Hba Reset: scsi id %d: tid: %d\n", name, cmd->device->channel, pHba->chann… in __adpt_reset()
759 rcode = adpt_hba_reset(pHba); in __adpt_reset()
781 static int adpt_hba_reset(adpt_hba* pHba) in adpt_hba_reset() argument
785 pHba->state |= DPTI_STATE_RESET; in adpt_hba_reset()
788 if ((rcode=adpt_i2o_activate_hba(pHba)) < 0) { in adpt_hba_reset()
789 printk(KERN_ERR "%s: Could not activate\n", pHba->name); in adpt_hba_reset()
790 adpt_i2o_delete_hba(pHba); in adpt_hba_reset()
795 adpt_i2o_delete_hba(pHba); in adpt_hba_reset()
798 PDEBUG("%s: in HOLD state\n",pHba->name); in adpt_hba_reset()
800 if ((rcode=adpt_i2o_online_hba(pHba)) < 0) { in adpt_hba_reset()
801 adpt_i2o_delete_hba(pHba); in adpt_hba_reset()
804 PDEBUG("%s: in OPERATIONAL state\n",pHba->name); in adpt_hba_reset()
806 if ((rcode=adpt_i2o_lct_get(pHba)) < 0){ in adpt_hba_reset()
807 adpt_i2o_delete_hba(pHba); in adpt_hba_reset()
811 if ((rcode=adpt_i2o_reparse_lct(pHba)) < 0){ in adpt_hba_reset()
812 adpt_i2o_delete_hba(pHba); in adpt_hba_reset()
815 pHba->state &= ~DPTI_STATE_RESET; in adpt_hba_reset()
817 scsi_host_complete_all_commands(pHba->host, DID_RESET); in adpt_hba_reset()
829 adpt_hba *pHba, *pNext; in adpt_i2o_sys_shutdown() local
838 for (pHba = hba_chain; pHba; pHba = pNext) { in adpt_i2o_sys_shutdown()
839 pNext = pHba->next; in adpt_i2o_sys_shutdown()
840 adpt_i2o_delete_hba(pHba); in adpt_i2o_sys_shutdown()
862 adpt_hba* pHba = NULL; in adpt_install_hba() local
958 pHba = kzalloc(sizeof(adpt_hba), GFP_KERNEL); in adpt_install_hba()
959 if (!pHba) { in adpt_install_hba()
971 p->next = pHba; in adpt_install_hba()
973 hba_chain = pHba; in adpt_install_hba()
975 pHba->next = NULL; in adpt_install_hba()
976 pHba->unit = hba_count; in adpt_install_hba()
977 sprintf(pHba->name, "dpti%d", hba_count); in adpt_install_hba()
982 pHba->pDev = pDev; in adpt_install_hba()
983 pHba->base_addr_phys = base_addr0_phys; in adpt_install_hba()
986 pHba->base_addr_virt = base_addr_virt; in adpt_install_hba()
987 pHba->msg_addr_virt = msg_addr_virt; in adpt_install_hba()
988 pHba->irq_mask = base_addr_virt+0x30; in adpt_install_hba()
989 pHba->post_port = base_addr_virt+0x40; in adpt_install_hba()
990 pHba->reply_port = base_addr_virt+0x44; in adpt_install_hba()
992 pHba->hrt = NULL; in adpt_install_hba()
993 pHba->lct = NULL; in adpt_install_hba()
994 pHba->lct_size = 0; in adpt_install_hba()
995 pHba->status_block = NULL; in adpt_install_hba()
996 pHba->post_count = 0; in adpt_install_hba()
997 pHba->state = DPTI_STATE_RESET; in adpt_install_hba()
998 pHba->pDev = pDev; in adpt_install_hba()
999 pHba->devices = NULL; in adpt_install_hba()
1000 pHba->dma64 = dma64; in adpt_install_hba()
1003 spin_lock_init(&pHba->state_lock); in adpt_install_hba()
1020 if (request_irq (pDev->irq, adpt_isr, IRQF_SHARED, pHba->name, pHba)) { in adpt_install_hba()
1021 printk(KERN_ERR"%s: Couldn't register IRQ %d\n", pHba->name, pDev->irq); in adpt_install_hba()
1022 adpt_i2o_delete_hba(pHba); in adpt_install_hba()
1030 static void adpt_i2o_delete_hba(adpt_hba* pHba) in adpt_i2o_delete_hba() argument
1043 if(pHba->host){ in adpt_i2o_delete_hba()
1044 free_irq(pHba->host->irq, pHba); in adpt_i2o_delete_hba()
1048 if(p1 == pHba) { in adpt_i2o_delete_hba()
1061 iounmap(pHba->base_addr_virt); in adpt_i2o_delete_hba()
1062 pci_release_regions(pHba->pDev); in adpt_i2o_delete_hba()
1063 if(pHba->msg_addr_virt != pHba->base_addr_virt){ in adpt_i2o_delete_hba()
1064 iounmap(pHba->msg_addr_virt); in adpt_i2o_delete_hba()
1066 if(pHba->FwDebugBuffer_P) in adpt_i2o_delete_hba()
1067 iounmap(pHba->FwDebugBuffer_P); in adpt_i2o_delete_hba()
1068 if(pHba->hrt) { in adpt_i2o_delete_hba()
1069 dma_free_coherent(&pHba->pDev->dev, in adpt_i2o_delete_hba()
1070 pHba->hrt->num_entries * pHba->hrt->entry_len << 2, in adpt_i2o_delete_hba()
1071 pHba->hrt, pHba->hrt_pa); in adpt_i2o_delete_hba()
1073 if(pHba->lct) { in adpt_i2o_delete_hba()
1074 dma_free_coherent(&pHba->pDev->dev, pHba->lct_size, in adpt_i2o_delete_hba()
1075 pHba->lct, pHba->lct_pa); in adpt_i2o_delete_hba()
1077 if(pHba->status_block) { in adpt_i2o_delete_hba()
1078 dma_free_coherent(&pHba->pDev->dev, sizeof(i2o_status_block), in adpt_i2o_delete_hba()
1079 pHba->status_block, pHba->status_block_pa); in adpt_i2o_delete_hba()
1081 if(pHba->reply_pool) { in adpt_i2o_delete_hba()
1082 dma_free_coherent(&pHba->pDev->dev, in adpt_i2o_delete_hba()
1083 pHba->reply_fifo_size * REPLY_FRAME_SIZE * 4, in adpt_i2o_delete_hba()
1084 pHba->reply_pool, pHba->reply_pool_pa); in adpt_i2o_delete_hba()
1087 for(d = pHba->devices; d ; d = next){ in adpt_i2o_delete_hba()
1091 for(i = 0 ; i < pHba->top_scsi_channel ; i++){ in adpt_i2o_delete_hba()
1093 if(pHba->channel[i].device[j] != NULL){ in adpt_i2o_delete_hba()
1094 for(pDev = pHba->channel[i].device[j]; pDev; pDev = pNext){ in adpt_i2o_delete_hba()
1101 pci_dev_put(pHba->pDev); in adpt_i2o_delete_hba()
1104 MKDEV(DPTI_I2O_MAJOR, pHba->unit)); in adpt_i2o_delete_hba()
1105 kfree(pHba); in adpt_i2o_delete_hba()
1116 static struct adpt_device* adpt_find_device(adpt_hba* pHba, u32 chan, u32 id, u64 lun) in adpt_find_device() argument
1123 d = pHba->channel[chan].device[id]; in adpt_find_device()
1143 static int adpt_i2o_post_wait(adpt_hba* pHba, u32* msg, int len, int timeout) in adpt_i2o_post_wait() argument
1180 if((status = adpt_i2o_post_this(pHba, msg, len)) == 0){ in adpt_i2o_post_wait()
1182 if(pHba->host) in adpt_i2o_post_wait()
1183 spin_unlock_irq(pHba->host->host_lock); in adpt_i2o_post_wait()
1195 if(pHba->host) in adpt_i2o_post_wait()
1196 spin_lock_irq(pHba->host->host_lock); in adpt_i2o_post_wait()
1201 printk(KERN_INFO"dpti%d: POST WAIT TIMEOUT\n",pHba->unit); in adpt_i2o_post_wait()
1230 static s32 adpt_i2o_post_this(adpt_hba* pHba, u32* data, int len) in adpt_i2o_post_this() argument
1238 m = readl(pHba->post_port); in adpt_i2o_post_this()
1243 printk(KERN_WARNING"dpti%d: Timeout waiting for message frame!\n", pHba->unit); in adpt_i2o_post_this()
1249 msg = pHba->msg_addr_virt + m; in adpt_i2o_post_this()
1254 writel(m, pHba->post_port); in adpt_i2o_post_this()
1298 static s32 adpt_i2o_reset_hba(adpt_hba* pHba) in adpt_i2o_reset_hba() argument
1306 if(pHba->initialized == FALSE) { // First time reset should be quick in adpt_i2o_reset_hba()
1309 adpt_i2o_quiesce_hba(pHba); in adpt_i2o_reset_hba()
1314 m = readl(pHba->post_port); in adpt_i2o_reset_hba()
1325 status = dma_alloc_coherent(&pHba->pDev->dev, 4, &addr, GFP_KERNEL); in adpt_i2o_reset_hba()
1327 adpt_send_nop(pHba, m); in adpt_i2o_reset_hba()
1341 memcpy_toio(pHba->msg_addr_virt+m, msg, sizeof(msg)); in adpt_i2o_reset_hba()
1343 writel(m, pHba->post_port); in adpt_i2o_reset_hba()
1348 printk(KERN_WARNING"%s: IOP Reset Timeout\n",pHba->name); in adpt_i2o_reset_hba()
1360 PDEBUG("%s: Reset in progress...\n", pHba->name); in adpt_i2o_reset_hba()
1365 m = readl(pHba->post_port); in adpt_i2o_reset_hba()
1370 printk(KERN_ERR "%s:Timeout waiting for IOP Reset.\n",pHba->name); in adpt_i2o_reset_hba()
1380 adpt_send_nop(pHba, m); in adpt_i2o_reset_hba()
1382 adpt_i2o_status_get(pHba); in adpt_i2o_reset_hba()
1384 pHba->status_block->iop_state != ADAPTER_STATE_RESET) { in adpt_i2o_reset_hba()
1386 pHba->name); in adpt_i2o_reset_hba()
1388 PDEBUG("%s: Reset completed.\n", pHba->name); in adpt_i2o_reset_hba()
1391 dma_free_coherent(&pHba->pDev->dev, 4, status, addr); in adpt_i2o_reset_hba()
1401 static int adpt_i2o_parse_lct(adpt_hba* pHba) in adpt_i2o_parse_lct() argument
1407 i2o_lct *lct = pHba->lct; in adpt_i2o_parse_lct()
1415 printk(KERN_ERR "%s: LCT is empty???\n",pHba->name); in adpt_i2o_parse_lct()
1439 if(adpt_i2o_query_scalar(pHba, tid, 0x8000, -1, buf, 32)<0) { in adpt_i2o_parse_lct()
1446 printk(KERN_WARNING"%s: Channel number %d out of range \n", pHba->name, bus_no); in adpt_i2o_parse_lct()
1450 printk(KERN_WARNING"%s: SCSI ID %d out of range \n", pHba->name, bus_no); in adpt_i2o_parse_lct()
1453 if(bus_no > pHba->top_scsi_channel){ in adpt_i2o_parse_lct()
1454 pHba->top_scsi_channel = bus_no; in adpt_i2o_parse_lct()
1456 if(scsi_id > pHba->top_scsi_id){ in adpt_i2o_parse_lct()
1457 pHba->top_scsi_id = scsi_id; in adpt_i2o_parse_lct()
1459 if(scsi_lun > pHba->top_scsi_lun){ in adpt_i2o_parse_lct()
1460 pHba->top_scsi_lun = scsi_lun; in adpt_i2o_parse_lct()
1467 printk(KERN_CRIT"%s: Out of memory for I2O device data.\n",pHba->name); in adpt_i2o_parse_lct()
1471 d->controller = pHba; in adpt_i2o_parse_lct()
1478 adpt_i2o_report_hba_unit(pHba, d); in adpt_i2o_parse_lct()
1479 adpt_i2o_install_device(pHba, d); in adpt_i2o_parse_lct()
1482 for(d = pHba->devices; d ; d = d->next) { in adpt_i2o_parse_lct()
1488 if(bus_no > pHba->top_scsi_channel){ in adpt_i2o_parse_lct()
1489 pHba->top_scsi_channel = bus_no; in adpt_i2o_parse_lct()
1491 pHba->channel[bus_no].type = d->lct_data.class_id; in adpt_i2o_parse_lct()
1492 pHba->channel[bus_no].tid = tid; in adpt_i2o_parse_lct()
1493 if(adpt_i2o_query_scalar(pHba, tid, 0x0200, -1, buf, 28)>=0) in adpt_i2o_parse_lct()
1495 pHba->channel[bus_no].scsi_id = buf[1]; in adpt_i2o_parse_lct()
1501 printk(KERN_WARNING"%s: Channel number %d out of range - LCT\n", pHba->name, bus_no); in adpt_i2o_parse_lct()
1508 for(d = pHba->devices; d ; d = d->next) { in adpt_i2o_parse_lct()
1516 if(adpt_i2o_query_scalar(pHba, tid, 0x8000, -1, buf, 32)>=0) { in adpt_i2o_parse_lct()
1526 if( pHba->channel[bus_no].device[scsi_id] == NULL){ in adpt_i2o_parse_lct()
1531 pHba->channel[bus_no].device[scsi_id] = pDev; in adpt_i2o_parse_lct()
1533 for( pDev = pHba->channel[bus_no].device[scsi_id]; in adpt_i2o_parse_lct()
1550 if(scsi_id > pHba->top_scsi_id){ in adpt_i2o_parse_lct()
1551 pHba->top_scsi_id = scsi_id; in adpt_i2o_parse_lct()
1553 if(scsi_lun > pHba->top_scsi_lun){ in adpt_i2o_parse_lct()
1554 pHba->top_scsi_lun = scsi_lun; in adpt_i2o_parse_lct()
1572 static int adpt_i2o_install_device(adpt_hba* pHba, struct i2o_device *d) in adpt_i2o_install_device() argument
1575 d->controller=pHba; in adpt_i2o_install_device()
1577 d->next=pHba->devices; in adpt_i2o_install_device()
1579 if (pHba->devices != NULL){ in adpt_i2o_install_device()
1580 pHba->devices->prev=d; in adpt_i2o_install_device()
1582 pHba->devices=d; in adpt_i2o_install_device()
1592 adpt_hba* pHba; in adpt_open() local
1603 for (pHba = hba_chain; pHba; pHba = pHba->next) { in adpt_open()
1604 if (pHba->unit == minor) { in adpt_open()
1608 if (pHba == NULL) { in adpt_open()
1619 pHba->in_use = 1; in adpt_open()
1629 adpt_hba* pHba; in adpt_close() local
1636 for (pHba = hba_chain; pHba; pHba = pHba->next) { in adpt_close()
1637 if (pHba->unit == minor) { in adpt_close()
1642 if (pHba == NULL) { in adpt_close()
1646 pHba->in_use = 0; in adpt_close()
1652 static int adpt_i2o_passthru(adpt_hba* pHba, u32 __user *arg) in adpt_i2o_passthru() argument
1695 printk(KERN_WARNING"%s: Could not allocate reply buffer\n",pHba->name); in adpt_i2o_passthru()
1700 msg[3] = adpt_ioctl_to_context(pHba, reply); in adpt_i2o_passthru()
1706 sg_list = kcalloc(pHba->sg_tablesize, sizeof(*sg_list), GFP_KERNEL); in adpt_i2o_passthru()
1715 if (sg_count > pHba->sg_tablesize){ in adpt_i2o_passthru()
1716 printk(KERN_DEBUG"%s:IOCTL SG List too large (%u)\n", pHba->name,sg_count); in adpt_i2o_passthru()
1725 printk(KERN_DEBUG"%s:Bad SG element %d - not simple (%x)\n",pHba->name,i, sg[i].flag_count); in adpt_i2o_passthru()
1731 p = dma_alloc_coherent(&pHba->pDev->dev, sg_size, &addr, GFP_KERNEL); in adpt_i2o_passthru()
1734 pHba->name,sg_size,i,sg_count); in adpt_i2o_passthru()
1743 printk(KERN_DEBUG"%s: Could not copy SG buf %d FROM user\n",pHba->name,i); in adpt_i2o_passthru()
1758 if (pHba->host) { in adpt_i2o_passthru()
1759 scsi_block_requests(pHba->host); in adpt_i2o_passthru()
1760 spin_lock_irqsave(pHba->host->host_lock, flags); in adpt_i2o_passthru()
1762 rcode = adpt_i2o_post_wait(pHba, msg, size, FOREVER); in adpt_i2o_passthru()
1766 if (pHba->host) { in adpt_i2o_passthru()
1767 spin_unlock_irqrestore(pHba->host->host_lock, flags); in adpt_i2o_passthru()
1768 scsi_unblock_requests(pHba->host); in adpt_i2o_passthru()
1811 … printk(KERN_WARNING"%s: Could not copy %p TO user %x\n",pHba->name, sg_list[j], sg[j].addr_bus); in adpt_i2o_passthru()
1823 printk(KERN_WARNING"%s: Could not copy message context FROM user\n",pHba->name); in adpt_i2o_passthru()
1827 printk(KERN_WARNING"%s: Could not copy reply TO user\n",pHba->name); in adpt_i2o_passthru()
1839 dma_free_coherent(&pHba->pDev->dev, in adpt_i2o_passthru()
1950 adpt_hba* pHba; in adpt_ioctl() local
1959 for (pHba = hba_chain; pHba; pHba = pHba->next) { in adpt_ioctl()
1960 if (pHba->unit == minor) { in adpt_ioctl()
1965 if(pHba == NULL){ in adpt_ioctl()
1969 while((volatile u32) pHba->state & DPTI_STATE_RESET ) in adpt_ioctl()
1980 return adpt_i2o_passthru(pHba, argp); in adpt_ioctl()
1989 HbaInfo.drvrHBAnum = pHba->unit; in adpt_ioctl()
1990 HbaInfo.baseAddr = (ulong) pHba->base_addr_phys; in adpt_ioctl()
1991 HbaInfo.blinkState = adpt_read_blink_led(pHba); in adpt_ioctl()
1992 HbaInfo.pciBusNum = pHba->pDev->bus->number; in adpt_ioctl()
1993 HbaInfo.pciDeviceNum=PCI_SLOT(pHba->pDev->devfn); in adpt_ioctl()
1994 HbaInfo.Interrupt = pHba->pDev->irq; in adpt_ioctl()
1997 printk(KERN_WARNING"%s: Could not copy HbaInfo TO user\n",pHba->name); in adpt_ioctl()
2006 value = (u32)adpt_read_blink_led(pHba); in adpt_ioctl()
2013 struct Scsi_Host *shost = pHba->host; in adpt_ioctl()
2017 adpt_hba_reset(pHba); in adpt_ioctl()
2023 adpt_rescan(pHba); in adpt_ioctl()
2082 adpt_hba* pHba = dev_id; in adpt_isr() local
2090 if (pHba == NULL){ in adpt_isr()
2094 if(pHba->host) in adpt_isr()
2095 spin_lock_irqsave(pHba->host->host_lock, flags); in adpt_isr()
2097 while( readl(pHba->irq_mask) & I2O_INTERRUPT_PENDING_B) { in adpt_isr()
2098 m = readl(pHba->reply_port); in adpt_isr()
2102 m = readl(pHba->reply_port); in adpt_isr()
2109 if (pHba->reply_pool_pa <= m && in adpt_isr()
2110 m < pHba->reply_pool_pa + in adpt_isr()
2111 (pHba->reply_fifo_size * REPLY_FRAME_SIZE * 4)) { in adpt_isr()
2112 reply = (u8 *)pHba->reply_pool + in adpt_isr()
2113 (m - pHba->reply_pool_pa); in adpt_isr()
2124 PDEBUG("%s: Failed message\n",pHba->name); in adpt_isr()
2126 printk(KERN_ERR"%s: Bad preserved MFA (%x)- dropping frame\n",pHba->name,old_m); in adpt_isr()
2127 writel(m,pHba->reply_port); in adpt_isr()
2131 msg = pHba->msg_addr_virt + old_m; in adpt_isr()
2134 adpt_send_nop(pHba, old_m); in adpt_isr()
2138 void *p = adpt_ioctl_from_context(pHba, readl(reply+12)); in adpt_isr()
2156 cmd = scsi_host_find_tag(pHba->host, in adpt_isr()
2159 …printk(KERN_WARNING"%s: Apparent SCSI cmd in Post Wait Context - cmd=%p context=%x\n", pHba->name,… in adpt_isr()
2168 cmd = scsi_host_find_tag(pHba->host, in adpt_isr()
2175 writel(m, pHba->reply_port); in adpt_isr()
2180 out: if(pHba->host) in adpt_isr()
2181 spin_unlock_irqrestore(pHba->host->host_lock, flags); in adpt_isr()
2185 static s32 adpt_scsi_to_i2o(adpt_hba* pHba, struct scsi_cmnd* cmd, struct adpt_device* d) in adpt_scsi_to_i2o() argument
2228 pHba->name, cmd->cmnd[0]); in adpt_scsi_to_i2o()
2257 if (dpt_dma64(pHba)) { in adpt_scsi_to_i2o()
2278 if (dpt_dma64(pHba)) in adpt_scsi_to_i2o()
2300 rcode = adpt_i2o_post_this(pHba, msg, reqlen<<2); in adpt_scsi_to_i2o()
2308 static s32 adpt_scsi_host_alloc(adpt_hba* pHba, struct scsi_host_template *sht) in adpt_scsi_host_alloc() argument
2314 printk("%s: scsi_host_alloc returned NULL\n", pHba->name); in adpt_scsi_host_alloc()
2317 host->hostdata[0] = (unsigned long)pHba; in adpt_scsi_host_alloc()
2318 pHba->host = host; in adpt_scsi_host_alloc()
2320 host->irq = pHba->pDev->irq; in adpt_scsi_host_alloc()
2329 host->max_channel = pHba->top_scsi_channel + 1; in adpt_scsi_host_alloc()
2331 host->unique_id = (u32)sys_tbl_pa + pHba->unit; in adpt_scsi_host_alloc()
2332 host->sg_tablesize = pHba->sg_tablesize; in adpt_scsi_host_alloc()
2333 host->can_queue = pHba->post_fifo_size; in adpt_scsi_host_alloc()
2341 adpt_hba* pHba; in adpt_i2o_scsi_complete() local
2355 pHba = (adpt_hba*) cmd->device->host->hostdata[0]; in adpt_i2o_scsi_complete()
2366 printk(KERN_WARNING"%s: SCSI CMD underflow\n",pHba->name); in adpt_i2o_scsi_complete()
2379pHba->name, (u32)cmd->device->channel, (u32)cmd->device->id, cmd->device->lun, hba_status, dev_sta… in adpt_i2o_scsi_complete()
2391 printk(KERN_WARNING"%s: SCSI CMD parity error\n",pHba->name); in adpt_i2o_scsi_complete()
2419pHba->name, detailed_status & I2O_SCSI_DSC_MASK, (u32)cmd->device->channel, (u32)cmd->device->id, … in adpt_i2o_scsi_complete()
2436 pHba->name, (u32)cmd->device->channel, (u32)cmd->device->id, cmd->device->lun, in adpt_i2o_scsi_complete()
2448 pHba->name, (u32)cmd->device->channel, (u32)cmd->device->id, cmd->device->lun, in adpt_i2o_scsi_complete()
2460 static s32 adpt_rescan(adpt_hba* pHba) in adpt_rescan() argument
2465 if(pHba->host) in adpt_rescan()
2466 spin_lock_irqsave(pHba->host->host_lock, flags); in adpt_rescan()
2467 if ((rcode=adpt_i2o_lct_get(pHba)) < 0) in adpt_rescan()
2469 if ((rcode=adpt_i2o_reparse_lct(pHba)) < 0) in adpt_rescan()
2472 out: if(pHba->host) in adpt_rescan()
2473 spin_unlock_irqrestore(pHba->host->host_lock, flags); in adpt_rescan()
2478 static s32 adpt_i2o_reparse_lct(adpt_hba* pHba) in adpt_i2o_reparse_lct() argument
2484 i2o_lct *lct = pHba->lct; in adpt_i2o_reparse_lct()
2493 printk(KERN_ERR "%s: LCT is empty???\n",pHba->name); in adpt_i2o_reparse_lct()
2502 for (d = pHba->devices; d; d = d->next) { in adpt_i2o_reparse_lct()
2510 printk(KERN_INFO "%s: LCT has %d entries.\n", pHba->name,max); in adpt_i2o_reparse_lct()
2521 if(adpt_i2o_query_scalar(pHba, tid, 0x8000, -1, buf, 32)<0) { in adpt_i2o_reparse_lct()
2522 printk(KERN_ERR"%s: Could not query device\n",pHba->name); in adpt_i2o_reparse_lct()
2529 pHba->name, bus_no); in adpt_i2o_reparse_lct()
2535 pDev = pHba->channel[bus_no].device[scsi_id]; in adpt_i2o_reparse_lct()
2552 d->controller = pHba; in adpt_i2o_reparse_lct()
2558 adpt_i2o_report_hba_unit(pHba, d); in adpt_i2o_reparse_lct()
2559 adpt_i2o_install_device(pHba, d); in adpt_i2o_reparse_lct()
2561 pDev = pHba->channel[bus_no].device[scsi_id]; in adpt_i2o_reparse_lct()
2569 pHba->channel[bus_no].device[scsi_id] = pDev; in adpt_i2o_reparse_lct()
2590 if(scsi_id > pHba->top_scsi_id){ in adpt_i2o_reparse_lct()
2591 pHba->top_scsi_id = scsi_id; in adpt_i2o_reparse_lct()
2593 if(scsi_lun > pHba->top_scsi_lun){ in adpt_i2o_reparse_lct()
2594 pHba->top_scsi_lun = scsi_lun; in adpt_i2o_reparse_lct()
2604 pHba->name,bus_no,scsi_id,scsi_lun); in adpt_i2o_reparse_lct()
2626 for (pI2o_dev = pHba->devices; pI2o_dev; pI2o_dev = pI2o_dev->next) { in adpt_i2o_reparse_lct()
2635 …printk(KERN_WARNING"%s: Device (%d,%d,%llu) offline\n",pHba->name,pDev->scsi_channel,pDev->scsi_id… in adpt_i2o_reparse_lct()
2654 static int adpt_i2o_activate_hba(adpt_hba* pHba) in adpt_i2o_activate_hba() argument
2658 if(pHba->initialized ) { in adpt_i2o_activate_hba()
2659 if (adpt_i2o_status_get(pHba) < 0) { in adpt_i2o_activate_hba()
2660 if((rcode = adpt_i2o_reset_hba(pHba)) != 0){ in adpt_i2o_activate_hba()
2661 printk(KERN_WARNING"%s: Could NOT reset.\n", pHba->name); in adpt_i2o_activate_hba()
2664 if (adpt_i2o_status_get(pHba) < 0) { in adpt_i2o_activate_hba()
2670 if(pHba->status_block->iop_state == ADAPTER_STATE_FAULTED) { in adpt_i2o_activate_hba()
2671 printk(KERN_CRIT "%s: hardware fault\n", pHba->name); in adpt_i2o_activate_hba()
2675 if (pHba->status_block->iop_state == ADAPTER_STATE_READY || in adpt_i2o_activate_hba()
2676 pHba->status_block->iop_state == ADAPTER_STATE_OPERATIONAL || in adpt_i2o_activate_hba()
2677 pHba->status_block->iop_state == ADAPTER_STATE_HOLD || in adpt_i2o_activate_hba()
2678 pHba->status_block->iop_state == ADAPTER_STATE_FAILED) { in adpt_i2o_activate_hba()
2679 adpt_i2o_reset_hba(pHba); in adpt_i2o_activate_hba()
2680 if (adpt_i2o_status_get(pHba) < 0 || pHba->status_block->iop_state != ADAPTER_STATE_RESET) { in adpt_i2o_activate_hba()
2681 printk(KERN_ERR "%s: Failed to initialize.\n", pHba->name); in adpt_i2o_activate_hba()
2686 if((rcode = adpt_i2o_reset_hba(pHba)) != 0){ in adpt_i2o_activate_hba()
2687 printk(KERN_WARNING"%s: Could NOT reset.\n", pHba->name); in adpt_i2o_activate_hba()
2693 if (adpt_i2o_init_outbound_q(pHba) < 0) { in adpt_i2o_activate_hba()
2699 if (adpt_i2o_hrt_get(pHba) < 0) { in adpt_i2o_activate_hba()
2710 static int adpt_i2o_online_hba(adpt_hba* pHba) in adpt_i2o_online_hba() argument
2712 if (adpt_i2o_systab_send(pHba) < 0) in adpt_i2o_online_hba()
2716 if (adpt_i2o_enable_hba(pHba) < 0) in adpt_i2o_online_hba()
2723 static s32 adpt_send_nop(adpt_hba*pHba,u32 m) in adpt_send_nop() argument
2730 m = readl(pHba->post_port); in adpt_send_nop()
2735 printk(KERN_ERR "%s: Timeout waiting for message frame!\n",pHba->name); in adpt_send_nop()
2740 msg = (u32 __iomem *)(pHba->msg_addr_virt + m); in adpt_send_nop()
2746 writel(m, pHba->post_port); in adpt_send_nop()
2751 static s32 adpt_i2o_init_outbound_q(adpt_hba* pHba) in adpt_i2o_init_outbound_q() argument
2762 m = readl(pHba->post_port); in adpt_i2o_init_outbound_q()
2768 printk(KERN_WARNING"%s: Timeout waiting for message frame\n",pHba->name); in adpt_i2o_init_outbound_q()
2774 msg=(u32 __iomem *)(pHba->msg_addr_virt+m); in adpt_i2o_init_outbound_q()
2776 status = dma_alloc_coherent(&pHba->pDev->dev, 4, &addr, GFP_KERNEL); in adpt_i2o_init_outbound_q()
2778 adpt_send_nop(pHba, m); in adpt_i2o_init_outbound_q()
2780 pHba->name); in adpt_i2o_init_outbound_q()
2793 writel(m, pHba->post_port); in adpt_i2o_init_outbound_q()
2805 printk(KERN_WARNING"%s: Timeout Initializing\n",pHba->name); in adpt_i2o_init_outbound_q()
2818 dma_free_coherent(&pHba->pDev->dev, 4, status, addr); in adpt_i2o_init_outbound_q()
2821 dma_free_coherent(&pHba->pDev->dev, 4, status, addr); in adpt_i2o_init_outbound_q()
2823 if(pHba->reply_pool != NULL) { in adpt_i2o_init_outbound_q()
2824 dma_free_coherent(&pHba->pDev->dev, in adpt_i2o_init_outbound_q()
2825 pHba->reply_fifo_size * REPLY_FRAME_SIZE * 4, in adpt_i2o_init_outbound_q()
2826 pHba->reply_pool, pHba->reply_pool_pa); in adpt_i2o_init_outbound_q()
2829 pHba->reply_pool = dma_alloc_coherent(&pHba->pDev->dev, in adpt_i2o_init_outbound_q()
2830 pHba->reply_fifo_size * REPLY_FRAME_SIZE * 4, in adpt_i2o_init_outbound_q()
2831 &pHba->reply_pool_pa, GFP_KERNEL); in adpt_i2o_init_outbound_q()
2832 if (!pHba->reply_pool) { in adpt_i2o_init_outbound_q()
2833 printk(KERN_ERR "%s: Could not allocate reply pool\n", pHba->name); in adpt_i2o_init_outbound_q()
2837 for(i = 0; i < pHba->reply_fifo_size; i++) { in adpt_i2o_init_outbound_q()
2838 writel(pHba->reply_pool_pa + (i * REPLY_FRAME_SIZE * 4), in adpt_i2o_init_outbound_q()
2839 pHba->reply_port); in adpt_i2o_init_outbound_q()
2842 adpt_i2o_status_get(pHba); in adpt_i2o_init_outbound_q()
2858 static s32 adpt_i2o_status_get(adpt_hba* pHba) in adpt_i2o_status_get() argument
2865 if(pHba->status_block == NULL) { in adpt_i2o_status_get()
2866 pHba->status_block = dma_alloc_coherent(&pHba->pDev->dev, in adpt_i2o_status_get()
2868 &pHba->status_block_pa, GFP_KERNEL); in adpt_i2o_status_get()
2869 if(pHba->status_block == NULL) { in adpt_i2o_status_get()
2872 pHba->unit); in adpt_i2o_status_get()
2876 memset(pHba->status_block, 0, sizeof(i2o_status_block)); in adpt_i2o_status_get()
2877 status_block = (u8*)(pHba->status_block); in adpt_i2o_status_get()
2881 m = readl(pHba->post_port); in adpt_i2o_status_get()
2887 pHba->name); in adpt_i2o_status_get()
2894 msg=(u32 __iomem *)(pHba->msg_addr_virt+m); in adpt_i2o_status_get()
2902 writel( dma_low(pHba->status_block_pa), &msg[6]); in adpt_i2o_status_get()
2903 writel( dma_high(pHba->status_block_pa), &msg[7]); in adpt_i2o_status_get()
2907 writel(m, pHba->post_port); in adpt_i2o_status_get()
2913 pHba->unit); in adpt_i2o_status_get()
2921 pHba->post_fifo_size = pHba->status_block->max_inbound_frames; in adpt_i2o_status_get()
2922 if (pHba->post_fifo_size > MAX_TO_IOP_MESSAGES) { in adpt_i2o_status_get()
2923 pHba->post_fifo_size = MAX_TO_IOP_MESSAGES; in adpt_i2o_status_get()
2926 pHba->reply_fifo_size = pHba->status_block->max_outbound_frames; in adpt_i2o_status_get()
2927 if (pHba->reply_fifo_size > MAX_FROM_IOP_MESSAGES) { in adpt_i2o_status_get()
2928 pHba->reply_fifo_size = MAX_FROM_IOP_MESSAGES; in adpt_i2o_status_get()
2932 if (dpt_dma64(pHba)) { in adpt_i2o_status_get()
2933 pHba->sg_tablesize in adpt_i2o_status_get()
2934 = ((pHba->status_block->inbound_frame_size * 4 in adpt_i2o_status_get()
2938 pHba->sg_tablesize in adpt_i2o_status_get()
2939 = ((pHba->status_block->inbound_frame_size * 4 in adpt_i2o_status_get()
2943 if (pHba->sg_tablesize > SG_LIST_ELEMENTS) { in adpt_i2o_status_get()
2944 pHba->sg_tablesize = SG_LIST_ELEMENTS; in adpt_i2o_status_get()
2949 printk("dpti%d: State = ",pHba->unit); in adpt_i2o_status_get()
2950 switch(pHba->status_block->iop_state) { in adpt_i2o_status_get()
2973 printk("%x (unknown!!)\n",pHba->status_block->iop_state); in adpt_i2o_status_get()
2982 static int adpt_i2o_lct_get(adpt_hba* pHba) in adpt_i2o_lct_get() argument
2988 if ((pHba->lct_size == 0) || (pHba->lct == NULL)){ in adpt_i2o_lct_get()
2989 pHba->lct_size = pHba->status_block->expected_lct_size; in adpt_i2o_lct_get()
2992 if (pHba->lct == NULL) { in adpt_i2o_lct_get()
2993 pHba->lct = dma_alloc_coherent(&pHba->pDev->dev, in adpt_i2o_lct_get()
2994 pHba->lct_size, &pHba->lct_pa, in adpt_i2o_lct_get()
2996 if(pHba->lct == NULL) { in adpt_i2o_lct_get()
2998 pHba->name); in adpt_i2o_lct_get()
3002 memset(pHba->lct, 0, pHba->lct_size); in adpt_i2o_lct_get()
3010 msg[6] = 0xD0000000|pHba->lct_size; in adpt_i2o_lct_get()
3011 msg[7] = (u32)pHba->lct_pa; in adpt_i2o_lct_get()
3013 if ((ret=adpt_i2o_post_wait(pHba, msg, sizeof(msg), 360))) { in adpt_i2o_lct_get()
3015 pHba->name, ret); in adpt_i2o_lct_get()
3020 if ((pHba->lct->table_size << 2) > pHba->lct_size) { in adpt_i2o_lct_get()
3021 pHba->lct_size = pHba->lct->table_size << 2; in adpt_i2o_lct_get()
3022 dma_free_coherent(&pHba->pDev->dev, pHba->lct_size, in adpt_i2o_lct_get()
3023 pHba->lct, pHba->lct_pa); in adpt_i2o_lct_get()
3024 pHba->lct = NULL; in adpt_i2o_lct_get()
3026 } while (pHba->lct == NULL); in adpt_i2o_lct_get()
3028 PDEBUG("%s: Hardware resource table read.\n", pHba->name); in adpt_i2o_lct_get()
3032 if(adpt_i2o_query_scalar(pHba, 0 , 0x8000, -1, buf, sizeof(buf))>=0) { in adpt_i2o_lct_get()
3033 pHba->FwDebugBufferSize = buf[1]; in adpt_i2o_lct_get()
3034 pHba->FwDebugBuffer_P = ioremap(pHba->base_addr_phys + buf[0], in adpt_i2o_lct_get()
3035 pHba->FwDebugBufferSize); in adpt_i2o_lct_get()
3036 if (pHba->FwDebugBuffer_P) { in adpt_i2o_lct_get()
3037 pHba->FwDebugFlags_P = pHba->FwDebugBuffer_P + in adpt_i2o_lct_get()
3039 pHba->FwDebugBLEDvalue_P = pHba->FwDebugBuffer_P + in adpt_i2o_lct_get()
3041 pHba->FwDebugBLEDflag_P = pHba->FwDebugBLEDvalue_P + 1; in adpt_i2o_lct_get()
3042 pHba->FwDebugStrLength_P = pHba->FwDebugBuffer_P + in adpt_i2o_lct_get()
3044 pHba->FwDebugBuffer_P += buf[2]; in adpt_i2o_lct_get()
3045 pHba->FwDebugFlags = 0; in adpt_i2o_lct_get()
3054 adpt_hba* pHba = hba_chain; in adpt_i2o_build_sys_table() local
3058 dma_free_coherent(&pHba->pDev->dev, sys_tbl_len, in adpt_i2o_build_sys_table()
3064 sys_tbl = dma_alloc_coherent(&pHba->pDev->dev, in adpt_i2o_build_sys_table()
3075 for(pHba = hba_chain; pHba; pHba = pHba->next) { in adpt_i2o_build_sys_table()
3078 if (adpt_i2o_status_get(pHba)) { in adpt_i2o_build_sys_table()
3083 sys_tbl->iops[count].org_id = pHba->status_block->org_id; in adpt_i2o_build_sys_table()
3084 sys_tbl->iops[count].iop_id = pHba->unit + 2; in adpt_i2o_build_sys_table()
3086 sys_tbl->iops[count].i2o_version = pHba->status_block->i2o_version; in adpt_i2o_build_sys_table()
3087 sys_tbl->iops[count].iop_state = pHba->status_block->iop_state; in adpt_i2o_build_sys_table()
3088 sys_tbl->iops[count].msg_type = pHba->status_block->msg_type; in adpt_i2o_build_sys_table()
3089 sys_tbl->iops[count].frame_size = pHba->status_block->inbound_frame_size; in adpt_i2o_build_sys_table()
3091 sys_tbl->iops[count].iop_capabilities = pHba->status_block->iop_capabilities; in adpt_i2o_build_sys_table()
3092 addr = pHba->base_addr_phys + 0x40; in adpt_i2o_build_sys_table()
3118 static void adpt_i2o_report_hba_unit(adpt_hba* pHba, struct i2o_device *d) in adpt_i2o_report_hba_unit() argument
3125 if(adpt_i2o_query_scalar(pHba, unit, 0xF100, 3, buf, 16)>=0) in adpt_i2o_report_hba_unit()
3130 if(adpt_i2o_query_scalar(pHba, unit, 0xF100, 4, buf, 16)>=0) in adpt_i2o_report_hba_unit()
3135 if(adpt_i2o_query_scalar(pHba, unit, 0xF100, 6, buf, 8)>=0) in adpt_i2o_report_hba_unit()
3223 static s32 adpt_i2o_hrt_get(adpt_hba* pHba) in adpt_i2o_hrt_get() argument
3229 if (pHba->hrt == NULL) { in adpt_i2o_hrt_get()
3230 pHba->hrt = dma_alloc_coherent(&pHba->pDev->dev, in adpt_i2o_hrt_get()
3231 size, &pHba->hrt_pa, GFP_KERNEL); in adpt_i2o_hrt_get()
3232 if (pHba->hrt == NULL) { in adpt_i2o_hrt_get()
3233 printk(KERN_CRIT "%s: Hrt Get failed; Out of memory.\n", pHba->name); in adpt_i2o_hrt_get()
3243 msg[5]= (u32)pHba->hrt_pa; /* Dump it here */ in adpt_i2o_hrt_get()
3245 if ((ret = adpt_i2o_post_wait(pHba, msg, sizeof(msg),20))) { in adpt_i2o_hrt_get()
3246 printk(KERN_ERR "%s: Unable to get HRT (status=%#10x)\n", pHba->name, ret); in adpt_i2o_hrt_get()
3250 if (pHba->hrt->num_entries * pHba->hrt->entry_len << 2 > size) { in adpt_i2o_hrt_get()
3251 int newsize = pHba->hrt->num_entries * pHba->hrt->entry_len << 2; in adpt_i2o_hrt_get()
3252 dma_free_coherent(&pHba->pDev->dev, size, in adpt_i2o_hrt_get()
3253 pHba->hrt, pHba->hrt_pa); in adpt_i2o_hrt_get()
3255 pHba->hrt = NULL; in adpt_i2o_hrt_get()
3257 } while(pHba->hrt == NULL); in adpt_i2o_hrt_get()
3264 static int adpt_i2o_query_scalar(adpt_hba* pHba, int tid, in adpt_i2o_query_scalar() argument
3276 resblk_va = dma_alloc_coherent(&pHba->pDev->dev, in adpt_i2o_query_scalar()
3279 printk(KERN_CRIT "%s: query scalar failed; Out of memory.\n", pHba->name); in adpt_i2o_query_scalar()
3283 opblk_va = dma_alloc_coherent(&pHba->pDev->dev, in adpt_i2o_query_scalar()
3286 dma_free_coherent(&pHba->pDev->dev, sizeof(u8) * (8+buflen), in adpt_i2o_query_scalar()
3289 pHba->name); in adpt_i2o_query_scalar()
3296 size = adpt_i2o_issue_params(I2O_CMD_UTIL_PARAMS_GET, pHba, tid, in adpt_i2o_query_scalar()
3299 dma_free_coherent(&pHba->pDev->dev, sizeof(opblk), opblk_va, opblk_pa); in adpt_i2o_query_scalar()
3301 dma_free_coherent(&pHba->pDev->dev, sizeof(u8) * (8+buflen), in adpt_i2o_query_scalar()
3303 printk(KERN_WARNING "%s: issue params failed; Timed out.\n", pHba->name); in adpt_i2o_query_scalar()
3306 dma_free_coherent(&pHba->pDev->dev, sizeof(u8) * (8+buflen), in adpt_i2o_query_scalar()
3308 printk(KERN_WARNING "%s: issue params failed; Interrupted.\n", pHba->name); in adpt_i2o_query_scalar()
3314 dma_free_coherent(&pHba->pDev->dev, sizeof(u8) * (8+buflen), in adpt_i2o_query_scalar()
3331 static int adpt_i2o_issue_params(int cmd, adpt_hba* pHba, int tid, in adpt_i2o_issue_params() argument
3349 if ((wait_status = adpt_i2o_post_wait(pHba, msg, sizeof(msg), 20))) { in adpt_i2o_issue_params()
3357 pHba->name, in adpt_i2o_issue_params()
3368 static s32 adpt_i2o_quiesce_hba(adpt_hba* pHba) in adpt_i2o_quiesce_hba() argument
3373 adpt_i2o_status_get(pHba); in adpt_i2o_quiesce_hba()
3377 if((pHba->status_block->iop_state != ADAPTER_STATE_READY) && in adpt_i2o_quiesce_hba()
3378 (pHba->status_block->iop_state != ADAPTER_STATE_OPERATIONAL)){ in adpt_i2o_quiesce_hba()
3387 if((ret = adpt_i2o_post_wait(pHba, msg, sizeof(msg), 240))) { in adpt_i2o_quiesce_hba()
3389 pHba->unit, -ret); in adpt_i2o_quiesce_hba()
3391 printk(KERN_INFO"dpti%d: Quiesced.\n",pHba->unit); in adpt_i2o_quiesce_hba()
3394 adpt_i2o_status_get(pHba); in adpt_i2o_quiesce_hba()
3402 static int adpt_i2o_enable_hba(adpt_hba* pHba) in adpt_i2o_enable_hba() argument
3407 adpt_i2o_status_get(pHba); in adpt_i2o_enable_hba()
3408 if(!pHba->status_block){ in adpt_i2o_enable_hba()
3412 if(pHba->status_block->iop_state == ADAPTER_STATE_OPERATIONAL) in adpt_i2o_enable_hba()
3415 if(pHba->status_block->iop_state != ADAPTER_STATE_READY) in adpt_i2o_enable_hba()
3423 if ((ret = adpt_i2o_post_wait(pHba, msg, sizeof(msg), 240))) { in adpt_i2o_enable_hba()
3425 pHba->name, ret); in adpt_i2o_enable_hba()
3427 PDEBUG("%s: Enabled.\n", pHba->name); in adpt_i2o_enable_hba()
3430 adpt_i2o_status_get(pHba); in adpt_i2o_enable_hba()
3435 static int adpt_i2o_systab_send(adpt_hba* pHba) in adpt_i2o_systab_send() argument
3444 msg[4] = (0<<16) | ((pHba->unit+2) << 12); /* Host 0 IOP ID (unit + 2) */ in adpt_i2o_systab_send()
3459 if ((ret=adpt_i2o_post_wait(pHba, msg, sizeof(msg), 120))) { in adpt_i2o_systab_send()
3461 pHba->name, ret); in adpt_i2o_systab_send()
3465 PINFO("%s: SysTab set.\n", pHba->name); in adpt_i2o_systab_send()
3511 adpt_hba *pHba, *next; in adpt_init() local
3521 for (pHba = hba_chain; pHba; pHba = pHba->next) { in adpt_init()
3522 error = scsi_add_host(pHba->host, &pHba->pDev->dev); in adpt_init()
3525 scsi_scan_host(pHba->host); in adpt_init()
3529 for (pHba = hba_chain; pHba; pHba = next) { in adpt_init()
3530 next = pHba->next; in adpt_init()
3531 scsi_remove_host(pHba->host); in adpt_init()
3538 adpt_hba *pHba, *next; in adpt_exit() local
3540 for (pHba = hba_chain; pHba; pHba = next) { in adpt_exit()
3541 next = pHba->next; in adpt_exit()
3542 adpt_release(pHba); in adpt_exit()