Lines Matching +full:p1 +full:- +full:retry +full:- +full:params
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 dpti.c - description
4 -------------------
21 - Support 2.6 kernel and DMA-mapping
22 - ioctl fix for raid tools
23 - use schedule_timeout in long long loop
37 #include <linux/ioctl.h> /* For SCSI-Passthrough */
51 #include <linux/dma-mapping.h>
71 * Create a binary signature - this is read by dptsig
87 (-1),(-1),
152 return (sizeof(dma_addr_t) > 4 && (pHba)->dma64); in dpt_dma64()
167 if (host->FwDebugBLEDflag_P) { in adpt_read_blink_led()
168 if( readb(host->FwDebugBLEDflag_P) == 0xbc ){ in adpt_read_blink_led()
169 return readb(host->FwDebugBLEDvalue_P); in adpt_read_blink_led()
200 if(pDev->device == PCI_DPT_DEVICE_ID || in adpt_detect()
201 pDev->device == PCI_DPT_RAPTOR_DEVICE_ID){ in adpt_detect()
205 return hba_count-1; in adpt_detect()
213 next = pHba->next; in adpt_detect()
239 for (pHba = hba_chain; pHba; 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()
272 next = pHba->next; 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()
304 struct Scsi_Host *shost = pHba->host; in adpt_release()
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()
337 scsidir =0x40000000; // DATA IN (iop<--dev) in adpt_inquiry()
360 // Write SCSI command into the message - always 16 byte block in adpt_inquiry()
371 lenptr=mptr++; /* Remember me - fill in when we know */ 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()
391 if (rcode != -ETIME && rcode != -EINTR) 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()
410 struct Scsi_Host *host = device->host; in adpt_slave_configure()
412 if (host->can_queue && device->tagged_supported) { in adpt_slave_configure()
414 host->can_queue - 1); in adpt_slave_configure()
424 cmd->scsi_done = done; in adpt_queue_lck()
432 if ((cmd->cmnd[0] == REQUEST_SENSE) && (cmd->sense_buffer[0] != 0)) { in adpt_queue_lck()
433 cmd->result = (DID_OK << 16); in adpt_queue_lck()
434 cmd->scsi_done(cmd); in adpt_queue_lck()
438 pHba = (adpt_hba*)cmd->device->host->hostdata[0]; in adpt_queue_lck()
444 if ((pHba->state) & DPTI_STATE_RESET) in adpt_queue_lck()
447 // TODO if the cmd->device if offline then I may need to issue a bus rescan in adpt_queue_lck()
449 if((pDev = (struct adpt_device*) (cmd->device->hostdata)) == NULL) { 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()
458 cmd->result = (DID_NO_CONNECT << 16); in adpt_queue_lck()
459 cmd->scsi_done(cmd); in adpt_queue_lck()
462 cmd->device->hostdata = pDev; in adpt_queue_lck()
464 pDev->pScsi_dev = cmd->device; in adpt_queue_lck()
470 if (pDev->state & DPTI_DEV_RESET ) { in adpt_queue_lck()
481 int heads=-1; in DEF_SCSI_QCMD()
482 int sectors=-1; in DEF_SCSI_QCMD()
483 int cylinders=-1; in DEF_SCSI_QCMD()
515 if(sdev->type == 5) { // CDROM in DEF_SCSI_QCMD()
534 pHba = (adpt_hba *) host->hostdata[0]; in adpt_info()
535 return (char *) (pHba->detail); in adpt_info()
548 for (pHba = hba_chain; pHba; pHba = pHba->next) { in adpt_show_info()
549 if (pHba->host == host) { 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()
571 seq_printf(m,"\t%-24.24s", d->pScsi_dev->vendor); in adpt_show_info()
572 seq_printf(m," Rev: %-8.8s\n", d->pScsi_dev->rev); in adpt_show_info()
574 unit = d->pI2o_dev->lct_data.tid; in adpt_show_info()
576 unit, (int)d->scsi_channel, (int)d->scsi_id, d->scsi_lun, in adpt_show_info()
577 scsi_device_online(d->pScsi_dev)? "online":"offline"); in adpt_show_info()
578 d = d->next_lun; in adpt_show_info()
597 pHba = (adpt_hba*) cmd->device->host->hostdata[0]; in adpt_abort()
598 printk(KERN_INFO"%s: Trying to Abort\n",pHba->name); in adpt_abort()
599 if ((dptdevice = (void*) (cmd->device->hostdata)) == NULL) { in adpt_abort()
600 printk(KERN_ERR "%s: Unable to abort: No device in cmnd\n",pHba->name); in adpt_abort()
606 msg[1] = I2O_CMD_SCSI_ABORT<<24|HOST_TID<<12|dptdevice->tid; in adpt_abort()
610 msg[4] = cmd->request->tag + 1; in adpt_abort()
611 if (pHba->host) in adpt_abort()
612 spin_lock_irq(pHba->host->host_lock); in adpt_abort()
614 if (pHba->host) in adpt_abort()
615 spin_unlock_irq(pHba->host->host_lock); in adpt_abort()
617 if(rcode == -EOPNOTSUPP ){ in adpt_abort()
618 printk(KERN_INFO"%s: Abort cmd not supported\n",pHba->name); in adpt_abort()
621 printk(KERN_INFO"%s: Abort failed.\n",pHba->name); in adpt_abort()
624 printk(KERN_INFO"%s: Abort complete.\n",pHba->name); in adpt_abort()
639 struct adpt_device* d = cmd->device->hostdata; in adpt_device_reset()
641 pHba = (void*) cmd->device->host->hostdata[0]; in adpt_device_reset()
642 printk(KERN_INFO"%s: Trying to reset device\n",pHba->name); in adpt_device_reset()
644 printk(KERN_INFO"%s: Reset Device: Device Not found\n",pHba->name); in adpt_device_reset()
649 msg[1] = (I2O_DEVICE_RESET<<24|HOST_TID<<12|d->tid); in adpt_device_reset()
653 if (pHba->host) in adpt_device_reset()
654 spin_lock_irq(pHba->host->host_lock); in adpt_device_reset()
655 old_state = d->state; in adpt_device_reset()
656 d->state |= DPTI_DEV_RESET; in adpt_device_reset()
658 d->state = old_state; in adpt_device_reset()
659 if (pHba->host) in adpt_device_reset()
660 spin_unlock_irq(pHba->host->host_lock); in adpt_device_reset()
662 if(rcode == -EOPNOTSUPP ){ in adpt_device_reset()
663 printk(KERN_INFO"%s: Device reset not supported\n",pHba->name); in adpt_device_reset()
666 printk(KERN_INFO"%s: Device reset failed\n",pHba->name); in adpt_device_reset()
669 printk(KERN_INFO"%s: Device reset successful\n",pHba->name); in adpt_device_reset()
683 pHba = (adpt_hba*)cmd->device->host->hostdata[0]; in adpt_bus_reset()
685 …RNING"%s: Bus reset: SCSI Bus %d: tid: %d\n",pHba->name, cmd->device->channel,pHba->channel[cmd->d… in adpt_bus_reset()
687 msg[1] = (I2O_HBA_BUS_RESET<<24|HOST_TID<<12|pHba->channel[cmd->device->channel].tid); in adpt_bus_reset()
690 if (pHba->host) in adpt_bus_reset()
691 spin_lock_irq(pHba->host->host_lock); in adpt_bus_reset()
693 if (pHba->host) in adpt_bus_reset()
694 spin_unlock_irq(pHba->host->host_lock); in adpt_bus_reset()
696 printk(KERN_WARNING"%s: Bus reset failed.\n",pHba->name); in adpt_bus_reset()
699 printk(KERN_WARNING"%s: Bus reset success.\n",pHba->name); in adpt_bus_reset()
711 pHba = (adpt_hba*)cmd->device->host->hostdata[0]; in __adpt_reset()
712 strncpy(name, pHba->name, sizeof(name)); in __adpt_reset()
713 …RNING"%s: Hba Reset: scsi id %d: tid: %d\n", name, cmd->device->channel, pHba->channel[cmd->device… in __adpt_reset()
728 spin_lock_irq(cmd->device->host->host_lock); in adpt_reset()
730 spin_unlock_irq(cmd->device->host->host_lock); in adpt_reset()
740 pHba->state |= DPTI_STATE_RESET; in adpt_hba_reset()
744 printk(KERN_ERR "%s: Could not activate\n", pHba->name); in adpt_hba_reset()
753 PDEBUG("%s: in HOLD state\n",pHba->name); in adpt_hba_reset()
759 PDEBUG("%s: in OPERATIONAL state\n",pHba->name); in adpt_hba_reset()
770 pHba->state &= ~DPTI_STATE_RESET; in adpt_hba_reset()
772 scsi_host_complete_all_commands(pHba->host, DID_RESET); in adpt_hba_reset()
785 struct adpt_i2o_post_wait_data *p1, *old; in adpt_i2o_sys_shutdown() local
791 * scsi-core in adpt_i2o_sys_shutdown()
794 pNext = pHba->next; in adpt_i2o_sys_shutdown()
803 for(p1 = adpt_post_wait_queue; p1;) { in adpt_i2o_sys_shutdown()
804 old = p1; in adpt_i2o_sys_shutdown()
805 p1 = p1->next; in adpt_i2o_sys_shutdown()
830 return -EINVAL; in adpt_install_hba()
835 return -EINVAL; in adpt_install_hba()
844 dma_get_required_mask(&pDev->dev) > DMA_BIT_MASK(32) && in adpt_install_hba()
845 dma_set_mask(&pDev->dev, DMA_BIT_MASK(64)) == 0) in adpt_install_hba()
848 if (!dma64 && dma_set_mask(&pDev->dev, DMA_BIT_MASK(32)) != 0) in adpt_install_hba()
849 return -EINVAL; in adpt_install_hba()
852 dma_set_coherent_mask(&pDev->dev, DMA_BIT_MASK(32)); in adpt_install_hba()
858 if(pDev->device == PCI_DPT_DEVICE_ID){ in adpt_install_hba()
859 if(pDev->subsystem_device >=0xc032 && pDev->subsystem_device <= 0xc03b){ in adpt_install_hba()
862 } else { // Not Raptor - it is a PCI card in adpt_install_hba()
897 return -EINVAL; in adpt_install_hba()
906 return -EINVAL; in adpt_install_hba()
919 return -ENOMEM; in adpt_install_hba()
925 for(p = hba_chain; p->next; p = p->next); in adpt_install_hba()
926 p->next = pHba; in adpt_install_hba()
930 pHba->next = NULL; in adpt_install_hba()
931 pHba->unit = hba_count; in adpt_install_hba()
932 sprintf(pHba->name, "dpti%d", hba_count); in adpt_install_hba()
937 pHba->pDev = pDev; in adpt_install_hba()
938 pHba->base_addr_phys = base_addr0_phys; in adpt_install_hba()
941 pHba->base_addr_virt = base_addr_virt; in adpt_install_hba()
942 pHba->msg_addr_virt = msg_addr_virt; in adpt_install_hba()
943 pHba->irq_mask = base_addr_virt+0x30; in adpt_install_hba()
944 pHba->post_port = base_addr_virt+0x40; in adpt_install_hba()
945 pHba->reply_port = base_addr_virt+0x44; in adpt_install_hba()
947 pHba->hrt = NULL; in adpt_install_hba()
948 pHba->lct = NULL; in adpt_install_hba()
949 pHba->lct_size = 0; in adpt_install_hba()
950 pHba->status_block = NULL; in adpt_install_hba()
951 pHba->post_count = 0; in adpt_install_hba()
952 pHba->state = DPTI_STATE_RESET; in adpt_install_hba()
953 pHba->pDev = pDev; in adpt_install_hba()
954 pHba->devices = NULL; in adpt_install_hba()
955 pHba->dma64 = dma64; in adpt_install_hba()
958 spin_lock_init(&pHba->state_lock); in adpt_install_hba()
964 hba_count-1, base_addr_virt, in adpt_install_hba()
965 hba_map0_area_size, pDev->irq, in adpt_install_hba()
966 dma64 ? " (64-bit DMA)" : ""); in adpt_install_hba()
969 hba_count-1, pDev->irq, in adpt_install_hba()
970 dma64 ? " (64-bit DMA)" : ""); in adpt_install_hba()
971 printk(KERN_INFO" BAR0 %p - size= %x\n",base_addr_virt,hba_map0_area_size); in adpt_install_hba()
972 printk(KERN_INFO" BAR1 %p - size= %x\n",msg_addr_virt,hba_map1_area_size); in adpt_install_hba()
975 if (request_irq (pDev->irq, adpt_isr, IRQF_SHARED, pHba->name, pHba)) { in adpt_install_hba()
976 printk(KERN_ERR"%s: Couldn't register IRQ %d\n", pHba->name, pDev->irq); in adpt_install_hba()
978 return -EINVAL; in adpt_install_hba()
987 adpt_hba* p1; in adpt_i2o_delete_hba() local
998 if(pHba->host){ in adpt_i2o_delete_hba()
999 free_irq(pHba->host->irq, pHba); in adpt_i2o_delete_hba()
1002 for( p1 = hba_chain; p1; p2 = p1,p1=p1->next){ in adpt_i2o_delete_hba()
1003 if(p1 == pHba) { in adpt_i2o_delete_hba()
1005 p2->next = p1->next; in adpt_i2o_delete_hba()
1007 hba_chain = p1->next; in adpt_i2o_delete_hba()
1013 hba_count--; in adpt_i2o_delete_hba()
1016 iounmap(pHba->base_addr_virt); in adpt_i2o_delete_hba()
1017 pci_release_regions(pHba->pDev); in adpt_i2o_delete_hba()
1018 if(pHba->msg_addr_virt != pHba->base_addr_virt){ in adpt_i2o_delete_hba()
1019 iounmap(pHba->msg_addr_virt); in adpt_i2o_delete_hba()
1021 if(pHba->FwDebugBuffer_P) in adpt_i2o_delete_hba()
1022 iounmap(pHba->FwDebugBuffer_P); in adpt_i2o_delete_hba()
1023 if(pHba->hrt) { in adpt_i2o_delete_hba()
1024 dma_free_coherent(&pHba->pDev->dev, in adpt_i2o_delete_hba()
1025 pHba->hrt->num_entries * pHba->hrt->entry_len << 2, in adpt_i2o_delete_hba()
1026 pHba->hrt, pHba->hrt_pa); in adpt_i2o_delete_hba()
1028 if(pHba->lct) { in adpt_i2o_delete_hba()
1029 dma_free_coherent(&pHba->pDev->dev, pHba->lct_size, in adpt_i2o_delete_hba()
1030 pHba->lct, pHba->lct_pa); in adpt_i2o_delete_hba()
1032 if(pHba->status_block) { in adpt_i2o_delete_hba()
1033 dma_free_coherent(&pHba->pDev->dev, sizeof(i2o_status_block), in adpt_i2o_delete_hba()
1034 pHba->status_block, pHba->status_block_pa); in adpt_i2o_delete_hba()
1036 if(pHba->reply_pool) { in adpt_i2o_delete_hba()
1037 dma_free_coherent(&pHba->pDev->dev, in adpt_i2o_delete_hba()
1038 pHba->reply_fifo_size * REPLY_FRAME_SIZE * 4, in adpt_i2o_delete_hba()
1039 pHba->reply_pool, pHba->reply_pool_pa); in adpt_i2o_delete_hba()
1042 for(d = pHba->devices; d ; d = next){ in adpt_i2o_delete_hba()
1043 next = d->next; in adpt_i2o_delete_hba()
1046 for(i = 0 ; i < pHba->top_scsi_channel ; i++){ in adpt_i2o_delete_hba()
1048 if(pHba->channel[i].device[j] != NULL){ in adpt_i2o_delete_hba()
1049 for(pDev = pHba->channel[i].device[j]; pDev; pDev = pNext){ in adpt_i2o_delete_hba()
1050 pNext = pDev->next_lun; in adpt_i2o_delete_hba()
1056 pci_dev_put(pHba->pDev); in adpt_i2o_delete_hba()
1059 MKDEV(DPTI_I2O_MAJOR, pHba->unit)); in adpt_i2o_delete_hba()
1078 d = pHba->channel[chan].device[id]; in adpt_find_device()
1079 if(!d || d->tid == 0) { in adpt_find_device()
1084 if(d->scsi_lun == lun){ in adpt_find_device()
1089 for(d=d->next_lun ; d ; d = d->next_lun){ in adpt_find_device()
1090 if(d->scsi_lun == lun){ in adpt_find_device()
1106 struct adpt_i2o_post_wait_data *p1, *p2; in adpt_i2o_post_wait() local
1112 return -ENOMEM; in adpt_i2o_post_wait()
1121 wait_data->next = adpt_post_wait_queue; in adpt_i2o_post_wait()
1125 wait_data->id = adpt_post_wait_id; in adpt_i2o_post_wait()
1128 wait_data->wq = &adpt_wq_i2o_post; in adpt_i2o_post_wait()
1129 wait_data->status = -ETIMEDOUT; in adpt_i2o_post_wait()
1133 msg[2] |= 0x80000000 | ((u32)wait_data->id); in adpt_i2o_post_wait()
1137 if(pHba->host) in adpt_i2o_post_wait()
1138 spin_unlock_irq(pHba->host->host_lock); in adpt_i2o_post_wait()
1147 status = -ETIME; in adpt_i2o_post_wait()
1150 if(pHba->host) in adpt_i2o_post_wait()
1151 spin_lock_irq(pHba->host->host_lock); in adpt_i2o_post_wait()
1155 if(status == -ETIMEDOUT){ in adpt_i2o_post_wait()
1156 printk(KERN_INFO"dpti%d: POST WAIT TIMEOUT\n",pHba->unit); in adpt_i2o_post_wait()
1164 for(p1 = adpt_post_wait_queue; p1; p2 = p1, p1 = p1->next) { in adpt_i2o_post_wait()
1165 if(p1 == wait_data) { in adpt_i2o_post_wait()
1166 if(p1->status == I2O_DETAIL_STATUS_UNSUPPORTED_FUNCTION ) { in adpt_i2o_post_wait()
1167 status = -EOPNOTSUPP; in adpt_i2o_post_wait()
1170 p2->next = p1->next; in adpt_i2o_post_wait()
1172 adpt_post_wait_queue = p1->next; in adpt_i2o_post_wait()
1193 m = readl(pHba->post_port); in adpt_i2o_post_this()
1198 printk(KERN_WARNING"dpti%d: Timeout waiting for message frame!\n", pHba->unit); in adpt_i2o_post_this()
1199 return -ETIMEDOUT; in adpt_i2o_post_this()
1204 msg = pHba->msg_addr_virt + m; in adpt_i2o_post_this()
1209 writel(m, pHba->post_port); in adpt_i2o_post_this()
1218 struct adpt_i2o_post_wait_data *p1 = NULL; in adpt_i2o_post_wait_complete() local
1235 for(p1 = adpt_post_wait_queue; p1; p1 = p1->next) { in adpt_i2o_post_wait_complete()
1236 if(p1->id == context) { in adpt_i2o_post_wait_complete()
1237 p1->status = status; in adpt_i2o_post_wait_complete()
1239 wake_up_interruptible(p1->wq); in adpt_i2o_post_wait_complete()
1247 for(p1 = adpt_post_wait_queue; p1; p1 = p1->next) { in adpt_i2o_post_wait_complete()
1248 printk(KERN_DEBUG" %d\n",p1->id); in adpt_i2o_post_wait_complete()
1261 if(pHba->initialized == FALSE) { // First time reset should be quick in adpt_i2o_reset_hba()
1269 m = readl(pHba->post_port); in adpt_i2o_reset_hba()
1275 return -ETIMEDOUT; in adpt_i2o_reset_hba()
1280 status = dma_alloc_coherent(&pHba->pDev->dev, 4, &addr, GFP_KERNEL); in adpt_i2o_reset_hba()
1283 printk(KERN_ERR"IOP reset failed - no free memory.\n"); in adpt_i2o_reset_hba()
1284 return -ENOMEM; in adpt_i2o_reset_hba()
1296 memcpy_toio(pHba->msg_addr_virt+m, msg, sizeof(msg)); in adpt_i2o_reset_hba()
1298 writel(m, pHba->post_port); in adpt_i2o_reset_hba()
1303 printk(KERN_WARNING"%s: IOP Reset Timeout\n",pHba->name); in adpt_i2o_reset_hba()
1307 /* dma_free_coherent(&pHba->pDev->dev, 4, buf, addr); */ in adpt_i2o_reset_hba()
1308 return -ETIMEDOUT; in adpt_i2o_reset_hba()
1315 PDEBUG("%s: Reset in progress...\n", pHba->name); in adpt_i2o_reset_hba()
1320 m = readl(pHba->post_port); in adpt_i2o_reset_hba()
1325 printk(KERN_ERR "%s:Timeout waiting for IOP Reset.\n",pHba->name); in adpt_i2o_reset_hba()
1329 /* dma_free_coherent(&pHba->pDev->dev, 4, buf, addr); */ in adpt_i2o_reset_hba()
1330 return -ETIMEDOUT; in adpt_i2o_reset_hba()
1339 pHba->status_block->iop_state != ADAPTER_STATE_RESET) { in adpt_i2o_reset_hba()
1341 pHba->name); in adpt_i2o_reset_hba()
1343 PDEBUG("%s: Reset completed.\n", pHba->name); in adpt_i2o_reset_hba()
1346 dma_free_coherent(&pHba->pDev->dev, 4, status, addr); in adpt_i2o_reset_hba()
1362 i2o_lct *lct = pHba->lct; in adpt_i2o_parse_lct()
1370 printk(KERN_ERR "%s: LCT is empty???\n",pHba->name); in adpt_i2o_parse_lct()
1371 return -1; in adpt_i2o_parse_lct()
1374 max = lct->table_size; in adpt_i2o_parse_lct()
1375 max -= 3; in adpt_i2o_parse_lct()
1379 if( lct->lct_entry[i].user_tid != 0xfff){ in adpt_i2o_parse_lct()
1387 if( lct->lct_entry[i].class_id != I2O_CLASS_RANDOM_BLOCK_STORAGE && in adpt_i2o_parse_lct()
1388 lct->lct_entry[i].class_id != I2O_CLASS_SCSI_PERIPHERAL && in adpt_i2o_parse_lct()
1389 lct->lct_entry[i].class_id != I2O_CLASS_FIBRE_CHANNEL_PERIPHERAL ){ in adpt_i2o_parse_lct()
1392 tid = lct->lct_entry[i].tid; in adpt_i2o_parse_lct()
1394 if(adpt_i2o_query_scalar(pHba, tid, 0x8000, -1, buf, 32)<0) { in adpt_i2o_parse_lct()
1401 printk(KERN_WARNING"%s: Channel number %d out of range \n", pHba->name, bus_no); in adpt_i2o_parse_lct()
1405 printk(KERN_WARNING"%s: SCSI ID %d out of range \n", pHba->name, bus_no); in adpt_i2o_parse_lct()
1408 if(bus_no > pHba->top_scsi_channel){ in adpt_i2o_parse_lct()
1409 pHba->top_scsi_channel = bus_no; in adpt_i2o_parse_lct()
1411 if(scsi_id > pHba->top_scsi_id){ in adpt_i2o_parse_lct()
1412 pHba->top_scsi_id = scsi_id; in adpt_i2o_parse_lct()
1414 if(scsi_lun > pHba->top_scsi_lun){ in adpt_i2o_parse_lct()
1415 pHba->top_scsi_lun = scsi_lun; in adpt_i2o_parse_lct()
1422 printk(KERN_CRIT"%s: Out of memory for I2O device data.\n",pHba->name); in adpt_i2o_parse_lct()
1423 return -ENOMEM; in adpt_i2o_parse_lct()
1426 d->controller = pHba; in adpt_i2o_parse_lct()
1427 d->next = NULL; in adpt_i2o_parse_lct()
1429 memcpy(&d->lct_data, &lct->lct_entry[i], sizeof(i2o_lct_entry)); in adpt_i2o_parse_lct()
1431 d->flags = 0; in adpt_i2o_parse_lct()
1432 tid = d->lct_data.tid; in adpt_i2o_parse_lct()
1437 for(d = pHba->devices; d ; d = d->next) { in adpt_i2o_parse_lct()
1438 if(d->lct_data.class_id == I2O_CLASS_BUS_ADAPTER_PORT || in adpt_i2o_parse_lct()
1439 d->lct_data.class_id == I2O_CLASS_FIBRE_CHANNEL_PORT){ in adpt_i2o_parse_lct()
1440 tid = d->lct_data.tid; in adpt_i2o_parse_lct()
1441 // TODO get the bus_no from hrt-but for now they are in order in adpt_i2o_parse_lct()
1443 if(bus_no > pHba->top_scsi_channel){ in adpt_i2o_parse_lct()
1444 pHba->top_scsi_channel = bus_no; in adpt_i2o_parse_lct()
1446 pHba->channel[bus_no].type = d->lct_data.class_id; in adpt_i2o_parse_lct()
1447 pHba->channel[bus_no].tid = tid; in adpt_i2o_parse_lct()
1448 if(adpt_i2o_query_scalar(pHba, tid, 0x0200, -1, buf, 28)>=0) in adpt_i2o_parse_lct()
1450 pHba->channel[bus_no].scsi_id = buf[1]; in adpt_i2o_parse_lct()
1451 PDEBUG("Bus %d - SCSI ID %d.\n", bus_no, buf[1]); in adpt_i2o_parse_lct()
1453 // TODO remove - this is just until we get from hrt in adpt_i2o_parse_lct()
1456 printk(KERN_WARNING"%s: Channel number %d out of range - LCT\n", pHba->name, bus_no); in adpt_i2o_parse_lct()
1463 for(d = pHba->devices; d ; d = d->next) { in adpt_i2o_parse_lct()
1464 if(d->lct_data.class_id == I2O_CLASS_RANDOM_BLOCK_STORAGE || in adpt_i2o_parse_lct()
1465 d->lct_data.class_id == I2O_CLASS_SCSI_PERIPHERAL || in adpt_i2o_parse_lct()
1466 d->lct_data.class_id == I2O_CLASS_FIBRE_CHANNEL_PERIPHERAL ){ in adpt_i2o_parse_lct()
1468 tid = d->lct_data.tid; in adpt_i2o_parse_lct()
1469 scsi_id = -1; in adpt_i2o_parse_lct()
1471 if(adpt_i2o_query_scalar(pHba, tid, 0x8000, -1, buf, 32)>=0) { in adpt_i2o_parse_lct()
1481 if( pHba->channel[bus_no].device[scsi_id] == NULL){ in adpt_i2o_parse_lct()
1484 return -ENOMEM; in adpt_i2o_parse_lct()
1486 pHba->channel[bus_no].device[scsi_id] = pDev; in adpt_i2o_parse_lct()
1488 for( pDev = pHba->channel[bus_no].device[scsi_id]; in adpt_i2o_parse_lct()
1489 pDev->next_lun; pDev = pDev->next_lun){ in adpt_i2o_parse_lct()
1491 pDev->next_lun = kzalloc(sizeof(struct adpt_device),GFP_KERNEL); in adpt_i2o_parse_lct()
1492 if(pDev->next_lun == NULL) { in adpt_i2o_parse_lct()
1493 return -ENOMEM; in adpt_i2o_parse_lct()
1495 pDev = pDev->next_lun; in adpt_i2o_parse_lct()
1497 pDev->tid = tid; in adpt_i2o_parse_lct()
1498 pDev->scsi_channel = bus_no; in adpt_i2o_parse_lct()
1499 pDev->scsi_id = scsi_id; in adpt_i2o_parse_lct()
1500 pDev->scsi_lun = scsi_lun; in adpt_i2o_parse_lct()
1501 pDev->pI2o_dev = d; in adpt_i2o_parse_lct()
1502 d->owner = pDev; in adpt_i2o_parse_lct()
1503 pDev->type = (buf[0])&0xff; in adpt_i2o_parse_lct()
1504 pDev->flags = (buf[0]>>8)&0xff; in adpt_i2o_parse_lct()
1505 if(scsi_id > pHba->top_scsi_id){ in adpt_i2o_parse_lct()
1506 pHba->top_scsi_id = scsi_id; in adpt_i2o_parse_lct()
1508 if(scsi_lun > pHba->top_scsi_lun){ in adpt_i2o_parse_lct()
1509 pHba->top_scsi_lun = scsi_lun; in adpt_i2o_parse_lct()
1512 if(scsi_id == -1){ in adpt_i2o_parse_lct()
1514 d->lct_data.identity_tag); in adpt_i2o_parse_lct()
1523 * Each I2O controller has a chain of devices on it - these match
1530 d->controller=pHba; in adpt_i2o_install_device()
1531 d->owner=NULL; in adpt_i2o_install_device()
1532 d->next=pHba->devices; in adpt_i2o_install_device()
1533 d->prev=NULL; in adpt_i2o_install_device()
1534 if (pHba->devices != NULL){ in adpt_i2o_install_device()
1535 pHba->devices->prev=d; in adpt_i2o_install_device()
1537 pHba->devices=d; in adpt_i2o_install_device()
1538 *d->dev_name = 0; in adpt_i2o_install_device()
1555 return -ENXIO; in adpt_open()
1558 for (pHba = hba_chain; pHba; pHba = pHba->next) { in adpt_open()
1559 if (pHba->unit == minor) { in adpt_open()
1566 return -ENXIO; in adpt_open()
1569 // if(pHba->in_use){ in adpt_open()
1571 // return -EBUSY; in adpt_open()
1574 pHba->in_use = 1; in adpt_open()
1588 return -ENXIO; in adpt_close()
1591 for (pHba = hba_chain; pHba; pHba = pHba->next) { in adpt_close()
1592 if (pHba->unit == minor) { in adpt_close()
1598 return -ENXIO; in adpt_close()
1601 pHba->in_use = 0; in adpt_close()
1612 si->processorType = PROC_IA64; in adpt_ia64_info()
1622 si->processorType = PROC_ULTRASPARC; in adpt_sparc_info()
1631 si->processorType = PROC_ALPHA; in adpt_alpha_info()
1646 si->processorType = PROC_386; in adpt_i386_info()
1649 si->processorType = PROC_486; in adpt_i386_info()
1652 si->processorType = PROC_PENTIUM; in adpt_i386_info()
1655 si->processorType = PROC_PENTIUM; in adpt_i386_info()
1663 * any logic and if the info is wrong - it doesn't matter.
1693 return -EFAULT; in adpt_system_info()
1709 return -ENXIO; in adpt_ioctl()
1712 for (pHba = hba_chain; pHba; pHba = pHba->next) { in adpt_ioctl()
1713 if (pHba->unit == minor) { in adpt_ioctl()
1719 return -ENXIO; in adpt_ioctl()
1722 while((volatile u32) pHba->state & DPTI_STATE_RESET ) in adpt_ioctl()
1729 return -EFAULT; in adpt_ioctl()
1740 HbaInfo.drvrHBAnum = pHba->unit; in adpt_ioctl()
1741 HbaInfo.baseAddr = (ulong) pHba->base_addr_phys; in adpt_ioctl()
1743 HbaInfo.pciBusNum = pHba->pDev->bus->number; in adpt_ioctl()
1744 HbaInfo.pciDeviceNum=PCI_SLOT(pHba->pDev->devfn); in adpt_ioctl()
1745 HbaInfo.Interrupt = pHba->pDev->irq; in adpt_ioctl()
1748 printk(KERN_WARNING"%s: Could not copy HbaInfo TO user\n",pHba->name); in adpt_ioctl()
1749 return -EFAULT; in adpt_ioctl()
1759 return -EFAULT; in adpt_ioctl()
1764 struct Scsi_Host *shost = pHba->host; in adpt_ioctl()
1767 spin_lock_irqsave(shost->host_lock, flags); in adpt_ioctl()
1770 spin_unlock_irqrestore(shost->host_lock, flags); in adpt_ioctl()
1777 return -EINVAL; in adpt_ioctl()
1821 ret = -ENOIOCTLCMD; in compat_adpt_ioctl()
1845 if(pHba->host) in adpt_isr()
1846 spin_lock_irqsave(pHba->host->host_lock, flags); in adpt_isr()
1848 while( readl(pHba->irq_mask) & I2O_INTERRUPT_PENDING_B) { in adpt_isr()
1849 m = readl(pHba->reply_port); in adpt_isr()
1853 m = readl(pHba->reply_port); in adpt_isr()
1860 if (pHba->reply_pool_pa <= m && in adpt_isr()
1861 m < pHba->reply_pool_pa + in adpt_isr()
1862 (pHba->reply_fifo_size * REPLY_FRAME_SIZE * 4)) { in adpt_isr()
1863 reply = (u8 *)pHba->reply_pool + in adpt_isr()
1864 (m - pHba->reply_pool_pa); in adpt_isr()
1875 PDEBUG("%s: Failed message\n",pHba->name); in adpt_isr()
1877 printk(KERN_ERR"%s: Bad preserved MFA (%x)- dropping frame\n",pHba->name,old_m); in adpt_isr()
1878 writel(m,pHba->reply_port); in adpt_isr()
1882 msg = pHba->msg_addr_virt + old_m; in adpt_isr()
1899 cmd = scsi_host_find_tag(pHba->host, in adpt_isr()
1900 readl(reply + 12) - 1); in adpt_isr()
1902 …printk(KERN_WARNING"%s: Apparent SCSI cmd in Post Wait Context - cmd=%p context=%x\n", pHba->name,… in adpt_isr()
1910 cmd = scsi_host_find_tag(pHba->host, in adpt_isr()
1911 readl(reply + 12) - 1); in adpt_isr()
1917 writel(m, pHba->reply_port); in adpt_isr()
1922 out: if(pHba->host) in adpt_isr()
1923 spin_unlock_irqrestore(pHba->host->host_lock, flags); in adpt_isr()
1952 * cmd->cmnd[0] is an unsigned char in adpt_scsi_to_i2o()
1954 switch(cmd->sc_data_direction){ in adpt_scsi_to_i2o()
1956 scsidir =0x40000000; // DATA IN (iop<--dev) in adpt_scsi_to_i2o()
1960 scsidir =0x80000000; // DATA OUT (iop-->dev) in adpt_scsi_to_i2o()
1965 scsidir =0x40000000; // DATA IN (iop<--dev) in adpt_scsi_to_i2o()
1966 // Assume In - and continue; in adpt_scsi_to_i2o()
1970 pHba->name, cmd->cmnd[0]); in adpt_scsi_to_i2o()
1971 cmd->result = (DID_OK <<16) | (INITIATOR_ERROR << 8); in adpt_scsi_to_i2o()
1972 cmd->scsi_done(cmd); in adpt_scsi_to_i2o()
1978 msg[1] = ((0xff<<24)|(HOST_TID<<12)|d->tid); in adpt_scsi_to_i2o()
1981 msg[3] = cmd->request->tag + 1; in adpt_scsi_to_i2o()
1985 msg[5] = d->tid; in adpt_scsi_to_i2o()
1990 msg[6] = scsidir|0x20a00000|cmd->cmd_len; in adpt_scsi_to_i2o()
1994 // Write SCSI command into the message - always 16 byte block in adpt_scsi_to_i2o()
1996 memcpy(mptr, cmd->cmnd, cmd->cmd_len); in adpt_scsi_to_i2o()
1998 lenptr=mptr++; /* Remember me - fill in when we know */ in adpt_scsi_to_i2o()
2023 if (i == nseg - 1) in adpt_scsi_to_i2o()
2026 reqlen = mptr - msg; in adpt_scsi_to_i2o()
2029 if(cmd->underflow && len != cmd->underflow){ in adpt_scsi_to_i2o()
2031 len, cmd->underflow); in adpt_scsi_to_i2o()
2056 printk("%s: scsi_host_alloc returned NULL\n", pHba->name); in adpt_scsi_host_alloc()
2057 return -1; in adpt_scsi_host_alloc()
2059 host->hostdata[0] = (unsigned long)pHba; in adpt_scsi_host_alloc()
2060 pHba->host = host; in adpt_scsi_host_alloc()
2062 host->irq = pHba->pDev->irq; in adpt_scsi_host_alloc()
2063 /* no IO ports, so don't have to set host->io_port and in adpt_scsi_host_alloc()
2064 * host->n_io_port in adpt_scsi_host_alloc()
2066 host->io_port = 0; in adpt_scsi_host_alloc()
2067 host->n_io_port = 0; in adpt_scsi_host_alloc()
2069 host->max_id = 16; in adpt_scsi_host_alloc()
2070 host->max_lun = 256; in adpt_scsi_host_alloc()
2071 host->max_channel = pHba->top_scsi_channel + 1; in adpt_scsi_host_alloc()
2072 host->cmd_per_lun = 1; in adpt_scsi_host_alloc()
2073 host->unique_id = (u32)sys_tbl_pa + pHba->unit; in adpt_scsi_host_alloc()
2074 host->sg_tablesize = pHba->sg_tablesize; in adpt_scsi_host_alloc()
2075 host->can_queue = pHba->post_fifo_size; in adpt_scsi_host_alloc()
2089 // io is in 4 byte words - so I keep that model in adpt_i2o_scsi_complete()
2095 scsi_set_resid(cmd, scsi_bufflen(cmd) - readl(reply+20)); in adpt_i2o_scsi_complete()
2097 pHba = (adpt_hba*) cmd->device->host->hostdata[0]; in adpt_i2o_scsi_complete()
2099 cmd->sense_buffer[0] = '\0'; // initialize sense valid flag to false in adpt_i2o_scsi_complete()
2104 cmd->result = (DID_OK << 16); in adpt_i2o_scsi_complete()
2106 if (readl(reply+20) < cmd->underflow) { in adpt_i2o_scsi_complete()
2107 cmd->result = (DID_ERROR <<16); in adpt_i2o_scsi_complete()
2108 printk(KERN_WARNING"%s: SCSI CMD underflow\n",pHba->name); in adpt_i2o_scsi_complete()
2112 cmd->result = (DID_ABORT << 16); in adpt_i2o_scsi_complete()
2120 …printk(KERN_WARNING"%s: SCSI Timeout-Device (%d,%d,%llu) hba status=0x%x, dev status=0x%x, cmd=0x%… in adpt_i2o_scsi_complete()
2121 …pHba->name, (u32)cmd->device->channel, (u32)cmd->device->id, cmd->device->lun, hba_status, dev_sta… in adpt_i2o_scsi_complete()
2122 cmd->result = (DID_TIME_OUT << 16); in adpt_i2o_scsi_complete()
2126 cmd->result = (DID_BUS_BUSY << 16); in adpt_i2o_scsi_complete()
2130 cmd->result = (DID_RESET << 16); in adpt_i2o_scsi_complete()
2133 printk(KERN_WARNING"%s: SCSI CMD parity error\n",pHba->name); in adpt_i2o_scsi_complete()
2134 cmd->result = (DID_PARITY << 16); in adpt_i2o_scsi_complete()
2160 …printk(KERN_WARNING"%s: SCSI error %0x-Device(%d,%d,%llu) hba_status=0x%x, dev_status=0x%x, cmd=0x… in adpt_i2o_scsi_complete()
2161 …pHba->name, detailed_status & I2O_SCSI_DSC_MASK, (u32)cmd->device->channel, (u32)cmd->device->id, … in adpt_i2o_scsi_complete()
2162 hba_status, dev_status, cmd->cmnd[0]); in adpt_i2o_scsi_complete()
2163 cmd->result = (DID_ERROR << 16); in adpt_i2o_scsi_complete()
2172 memcpy_fromio(cmd->sense_buffer, (reply+28) , len); in adpt_i2o_scsi_complete()
2173 if(cmd->sense_buffer[0] == 0x70 /* class 7 */ && in adpt_i2o_scsi_complete()
2174 cmd->sense_buffer[2] == DATA_PROTECT ){ in adpt_i2o_scsi_complete()
2176 cmd->result = (DID_TIME_OUT << 16); in adpt_i2o_scsi_complete()
2177 …printk(KERN_WARNING"%s: SCSI Data Protect-Device (%d,%d,%llu) hba_status=0x%x, dev_status=0x%x, cm… in adpt_i2o_scsi_complete()
2178 pHba->name, (u32)cmd->device->channel, (u32)cmd->device->id, cmd->device->lun, in adpt_i2o_scsi_complete()
2179 hba_status, dev_status, cmd->cmnd[0]); in adpt_i2o_scsi_complete()
2185 * the card rejected it. We should signal a retry in adpt_i2o_scsi_complete()
2188 cmd->result = (DID_TIME_OUT << 16); in adpt_i2o_scsi_complete()
2189 printk(KERN_WARNING"%s: I2O MSG_FAIL - Device (%d,%d,%llu) tid=%d, cmd=0x%x\n", in adpt_i2o_scsi_complete()
2190 pHba->name, (u32)cmd->device->channel, (u32)cmd->device->id, cmd->device->lun, in adpt_i2o_scsi_complete()
2191 ((struct adpt_device*)(cmd->device->hostdata))->tid, cmd->cmnd[0]); in adpt_i2o_scsi_complete()
2194 cmd->result |= (dev_status); in adpt_i2o_scsi_complete()
2196 if(cmd->scsi_done != NULL){ in adpt_i2o_scsi_complete()
2197 cmd->scsi_done(cmd); in adpt_i2o_scsi_complete()
2207 if(pHba->host) in adpt_rescan()
2208 spin_lock_irqsave(pHba->host->host_lock, flags); in adpt_rescan()
2214 out: if(pHba->host) in adpt_rescan()
2215 spin_unlock_irqrestore(pHba->host->host_lock, flags); in adpt_rescan()
2226 i2o_lct *lct = pHba->lct; in adpt_i2o_reparse_lct()
2235 printk(KERN_ERR "%s: LCT is empty???\n",pHba->name); in adpt_i2o_reparse_lct()
2236 return -1; in adpt_i2o_reparse_lct()
2239 max = lct->table_size; in adpt_i2o_reparse_lct()
2240 max -= 3; in adpt_i2o_reparse_lct()
2244 for (d = pHba->devices; d; d = d->next) { in adpt_i2o_reparse_lct()
2245 pDev =(struct adpt_device*) d->owner; in adpt_i2o_reparse_lct()
2249 pDev->state |= DPTI_DEV_UNSCANNED; in adpt_i2o_reparse_lct()
2252 printk(KERN_INFO "%s: LCT has %d entries.\n", pHba->name,max); in adpt_i2o_reparse_lct()
2255 if( lct->lct_entry[i].user_tid != 0xfff){ in adpt_i2o_reparse_lct()
2259 if( lct->lct_entry[i].class_id == I2O_CLASS_RANDOM_BLOCK_STORAGE || in adpt_i2o_reparse_lct()
2260 lct->lct_entry[i].class_id == I2O_CLASS_SCSI_PERIPHERAL || in adpt_i2o_reparse_lct()
2261 lct->lct_entry[i].class_id == I2O_CLASS_FIBRE_CHANNEL_PERIPHERAL ){ in adpt_i2o_reparse_lct()
2262 tid = lct->lct_entry[i].tid; in adpt_i2o_reparse_lct()
2263 if(adpt_i2o_query_scalar(pHba, tid, 0x8000, -1, buf, 32)<0) { in adpt_i2o_reparse_lct()
2264 printk(KERN_ERR"%s: Could not query device\n",pHba->name); in adpt_i2o_reparse_lct()
2271 pHba->name, bus_no); in adpt_i2o_reparse_lct()
2277 pDev = pHba->channel[bus_no].device[scsi_id]; in adpt_i2o_reparse_lct()
2280 if(pDev->scsi_lun == scsi_lun) { in adpt_i2o_reparse_lct()
2283 pDev = pDev->next_lun; in adpt_i2o_reparse_lct()
2291 return -ENOMEM; in adpt_i2o_reparse_lct()
2294 d->controller = pHba; in adpt_i2o_reparse_lct()
2295 d->next = NULL; in adpt_i2o_reparse_lct()
2297 memcpy(&d->lct_data, &lct->lct_entry[i], sizeof(i2o_lct_entry)); in adpt_i2o_reparse_lct()
2299 d->flags = 0; in adpt_i2o_reparse_lct()
2303 pDev = pHba->channel[bus_no].device[scsi_id]; in adpt_i2o_reparse_lct()
2309 return -ENOMEM; in adpt_i2o_reparse_lct()
2311 pHba->channel[bus_no].device[scsi_id] = pDev; in adpt_i2o_reparse_lct()
2313 while (pDev->next_lun) { in adpt_i2o_reparse_lct()
2314 pDev = pDev->next_lun; in adpt_i2o_reparse_lct()
2316 pDev = pDev->next_lun = in adpt_i2o_reparse_lct()
2320 return -ENOMEM; in adpt_i2o_reparse_lct()
2323 pDev->tid = d->lct_data.tid; in adpt_i2o_reparse_lct()
2324 pDev->scsi_channel = bus_no; in adpt_i2o_reparse_lct()
2325 pDev->scsi_id = scsi_id; in adpt_i2o_reparse_lct()
2326 pDev->scsi_lun = scsi_lun; in adpt_i2o_reparse_lct()
2327 pDev->pI2o_dev = d; in adpt_i2o_reparse_lct()
2328 d->owner = pDev; in adpt_i2o_reparse_lct()
2329 pDev->type = (buf[0])&0xff; in adpt_i2o_reparse_lct()
2330 pDev->flags = (buf[0]>>8)&0xff; in adpt_i2o_reparse_lct()
2332 if(scsi_id > pHba->top_scsi_id){ in adpt_i2o_reparse_lct()
2333 pHba->top_scsi_id = scsi_id; in adpt_i2o_reparse_lct()
2335 if(scsi_lun > pHba->top_scsi_lun){ in adpt_i2o_reparse_lct()
2336 pHba->top_scsi_lun = scsi_lun; in adpt_i2o_reparse_lct()
2341 // We found an old device - check it in adpt_i2o_reparse_lct()
2343 if(pDev->scsi_lun == scsi_lun) { in adpt_i2o_reparse_lct()
2344 if(!scsi_device_online(pDev->pScsi_dev)) { in adpt_i2o_reparse_lct()
2346 pHba->name,bus_no,scsi_id,scsi_lun); in adpt_i2o_reparse_lct()
2347 if (pDev->pScsi_dev) { in adpt_i2o_reparse_lct()
2348 scsi_device_set_state(pDev->pScsi_dev, SDEV_RUNNING); in adpt_i2o_reparse_lct()
2351 d = pDev->pI2o_dev; in adpt_i2o_reparse_lct()
2352 if(d->lct_data.tid != tid) { // something changed in adpt_i2o_reparse_lct()
2353 pDev->tid = tid; in adpt_i2o_reparse_lct()
2354 memcpy(&d->lct_data, &lct->lct_entry[i], sizeof(i2o_lct_entry)); in adpt_i2o_reparse_lct()
2355 if (pDev->pScsi_dev) { in adpt_i2o_reparse_lct()
2356 pDev->pScsi_dev->changed = TRUE; in adpt_i2o_reparse_lct()
2357 pDev->pScsi_dev->removable = TRUE; in adpt_i2o_reparse_lct()
2360 // Found it - mark it scanned in adpt_i2o_reparse_lct()
2361 pDev->state = DPTI_DEV_ONLINE; in adpt_i2o_reparse_lct()
2364 pDev = pDev->next_lun; in adpt_i2o_reparse_lct()
2368 for (pI2o_dev = pHba->devices; pI2o_dev; pI2o_dev = pI2o_dev->next) { in adpt_i2o_reparse_lct()
2369 pDev =(struct adpt_device*) pI2o_dev->owner; in adpt_i2o_reparse_lct()
2375 if (pDev->state & DPTI_DEV_UNSCANNED){ in adpt_i2o_reparse_lct()
2376 pDev->state = DPTI_DEV_OFFLINE; in adpt_i2o_reparse_lct()
2377 …k(KERN_WARNING"%s: Device (%d,%d,%llu) offline\n",pHba->name,pDev->scsi_channel,pDev->scsi_id,pDev… in adpt_i2o_reparse_lct()
2378 if (pDev->pScsi_dev) { in adpt_i2o_reparse_lct()
2379 scsi_device_set_state(pDev->pScsi_dev, SDEV_OFFLINE); in adpt_i2o_reparse_lct()
2400 if(pHba->initialized ) { in adpt_i2o_activate_hba()
2403 printk(KERN_WARNING"%s: Could NOT reset.\n", pHba->name); in adpt_i2o_activate_hba()
2408 return -1; in adpt_i2o_activate_hba()
2412 if(pHba->status_block->iop_state == ADAPTER_STATE_FAULTED) { in adpt_i2o_activate_hba()
2413 printk(KERN_CRIT "%s: hardware fault\n", pHba->name); in adpt_i2o_activate_hba()
2414 return -1; in adpt_i2o_activate_hba()
2417 if (pHba->status_block->iop_state == ADAPTER_STATE_READY || in adpt_i2o_activate_hba()
2418 pHba->status_block->iop_state == ADAPTER_STATE_OPERATIONAL || in adpt_i2o_activate_hba()
2419 pHba->status_block->iop_state == ADAPTER_STATE_HOLD || in adpt_i2o_activate_hba()
2420 pHba->status_block->iop_state == ADAPTER_STATE_FAILED) { in adpt_i2o_activate_hba()
2422 if (adpt_i2o_status_get(pHba) < 0 || pHba->status_block->iop_state != ADAPTER_STATE_RESET) { in adpt_i2o_activate_hba()
2423 printk(KERN_ERR "%s: Failed to initialize.\n", pHba->name); in adpt_i2o_activate_hba()
2424 return -1; in adpt_i2o_activate_hba()
2429 printk(KERN_WARNING"%s: Could NOT reset.\n", pHba->name); in adpt_i2o_activate_hba()
2436 return -1; in adpt_i2o_activate_hba()
2442 return -1; in adpt_i2o_activate_hba()
2455 return -1; in adpt_i2o_online_hba()
2459 return -1; in adpt_i2o_online_hba()
2472 m = readl(pHba->post_port); in adpt_send_nop()
2477 printk(KERN_ERR "%s: Timeout waiting for message frame!\n",pHba->name); in adpt_send_nop()
2482 msg = (u32 __iomem *)(pHba->msg_addr_virt + m); in adpt_send_nop()
2488 writel(m, pHba->post_port); in adpt_send_nop()
2504 m = readl(pHba->post_port); in adpt_i2o_init_outbound_q()
2510 printk(KERN_WARNING"%s: Timeout waiting for message frame\n",pHba->name); in adpt_i2o_init_outbound_q()
2511 return -ETIMEDOUT; in adpt_i2o_init_outbound_q()
2516 msg=(u32 __iomem *)(pHba->msg_addr_virt+m); in adpt_i2o_init_outbound_q()
2518 status = dma_alloc_coherent(&pHba->pDev->dev, 4, &addr, GFP_KERNEL); in adpt_i2o_init_outbound_q()
2521 printk(KERN_WARNING"%s: IOP reset failed - no free memory.\n", in adpt_i2o_init_outbound_q()
2522 pHba->name); in adpt_i2o_init_outbound_q()
2523 return -ENOMEM; in adpt_i2o_init_outbound_q()
2535 writel(m, pHba->post_port); in adpt_i2o_init_outbound_q()
2547 printk(KERN_WARNING"%s: Timeout Initializing\n",pHba->name); in adpt_i2o_init_outbound_q()
2551 /* dma_free_coherent(&pHba->pDev->dev, 4, status, addr); */ in adpt_i2o_init_outbound_q()
2552 return -ETIMEDOUT; in adpt_i2o_init_outbound_q()
2560 dma_free_coherent(&pHba->pDev->dev, 4, status, addr); in adpt_i2o_init_outbound_q()
2561 return -2; in adpt_i2o_init_outbound_q()
2563 dma_free_coherent(&pHba->pDev->dev, 4, status, addr); in adpt_i2o_init_outbound_q()
2565 if(pHba->reply_pool != NULL) { in adpt_i2o_init_outbound_q()
2566 dma_free_coherent(&pHba->pDev->dev, in adpt_i2o_init_outbound_q()
2567 pHba->reply_fifo_size * REPLY_FRAME_SIZE * 4, in adpt_i2o_init_outbound_q()
2568 pHba->reply_pool, pHba->reply_pool_pa); in adpt_i2o_init_outbound_q()
2571 pHba->reply_pool = dma_alloc_coherent(&pHba->pDev->dev, in adpt_i2o_init_outbound_q()
2572 pHba->reply_fifo_size * REPLY_FRAME_SIZE * 4, in adpt_i2o_init_outbound_q()
2573 &pHba->reply_pool_pa, GFP_KERNEL); in adpt_i2o_init_outbound_q()
2574 if (!pHba->reply_pool) { in adpt_i2o_init_outbound_q()
2575 printk(KERN_ERR "%s: Could not allocate reply pool\n", pHba->name); in adpt_i2o_init_outbound_q()
2576 return -ENOMEM; in adpt_i2o_init_outbound_q()
2579 for(i = 0; i < pHba->reply_fifo_size; i++) { in adpt_i2o_init_outbound_q()
2580 writel(pHba->reply_pool_pa + (i * REPLY_FRAME_SIZE * 4), in adpt_i2o_init_outbound_q()
2581 pHba->reply_port); in adpt_i2o_init_outbound_q()
2607 if(pHba->status_block == NULL) { in adpt_i2o_status_get()
2608 pHba->status_block = dma_alloc_coherent(&pHba->pDev->dev, in adpt_i2o_status_get()
2610 &pHba->status_block_pa, GFP_KERNEL); in adpt_i2o_status_get()
2611 if(pHba->status_block == NULL) { in adpt_i2o_status_get()
2614 pHba->unit); in adpt_i2o_status_get()
2615 return -ENOMEM; in adpt_i2o_status_get()
2618 memset(pHba->status_block, 0, sizeof(i2o_status_block)); in adpt_i2o_status_get()
2619 status_block = (u8*)(pHba->status_block); in adpt_i2o_status_get()
2623 m = readl(pHba->post_port); in adpt_i2o_status_get()
2629 pHba->name); in adpt_i2o_status_get()
2630 return -ETIMEDOUT; in adpt_i2o_status_get()
2636 msg=(u32 __iomem *)(pHba->msg_addr_virt+m); in adpt_i2o_status_get()
2644 writel( dma_low(pHba->status_block_pa), &msg[6]); in adpt_i2o_status_get()
2645 writel( dma_high(pHba->status_block_pa), &msg[7]); in adpt_i2o_status_get()
2649 writel(m, pHba->post_port); in adpt_i2o_status_get()
2655 pHba->unit); in adpt_i2o_status_get()
2656 return -ETIMEDOUT; in adpt_i2o_status_get()
2663 pHba->post_fifo_size = pHba->status_block->max_inbound_frames; in adpt_i2o_status_get()
2664 if (pHba->post_fifo_size > MAX_TO_IOP_MESSAGES) { in adpt_i2o_status_get()
2665 pHba->post_fifo_size = MAX_TO_IOP_MESSAGES; in adpt_i2o_status_get()
2668 pHba->reply_fifo_size = pHba->status_block->max_outbound_frames; in adpt_i2o_status_get()
2669 if (pHba->reply_fifo_size > MAX_FROM_IOP_MESSAGES) { in adpt_i2o_status_get()
2670 pHba->reply_fifo_size = MAX_FROM_IOP_MESSAGES; in adpt_i2o_status_get()
2675 pHba->sg_tablesize in adpt_i2o_status_get()
2676 = ((pHba->status_block->inbound_frame_size * 4 in adpt_i2o_status_get()
2677 - 14 * sizeof(u32)) in adpt_i2o_status_get()
2680 pHba->sg_tablesize in adpt_i2o_status_get()
2681 = ((pHba->status_block->inbound_frame_size * 4 in adpt_i2o_status_get()
2682 - 12 * sizeof(u32)) in adpt_i2o_status_get()
2685 if (pHba->sg_tablesize > SG_LIST_ELEMENTS) { in adpt_i2o_status_get()
2686 pHba->sg_tablesize = SG_LIST_ELEMENTS; in adpt_i2o_status_get()
2691 printk("dpti%d: State = ",pHba->unit); in adpt_i2o_status_get()
2692 switch(pHba->status_block->iop_state) { in adpt_i2o_status_get()
2715 printk("%x (unknown!!)\n",pHba->status_block->iop_state); in adpt_i2o_status_get()
2730 if ((pHba->lct_size == 0) || (pHba->lct == NULL)){ in adpt_i2o_lct_get()
2731 pHba->lct_size = pHba->status_block->expected_lct_size; in adpt_i2o_lct_get()
2734 if (pHba->lct == NULL) { in adpt_i2o_lct_get()
2735 pHba->lct = dma_alloc_coherent(&pHba->pDev->dev, in adpt_i2o_lct_get()
2736 pHba->lct_size, &pHba->lct_pa, in adpt_i2o_lct_get()
2738 if(pHba->lct == NULL) { in adpt_i2o_lct_get()
2740 pHba->name); in adpt_i2o_lct_get()
2741 return -ENOMEM; in adpt_i2o_lct_get()
2744 memset(pHba->lct, 0, pHba->lct_size); in adpt_i2o_lct_get()
2752 msg[6] = 0xD0000000|pHba->lct_size; in adpt_i2o_lct_get()
2753 msg[7] = (u32)pHba->lct_pa; in adpt_i2o_lct_get()
2757 pHba->name, ret); in adpt_i2o_lct_get()
2762 if ((pHba->lct->table_size << 2) > pHba->lct_size) { in adpt_i2o_lct_get()
2763 pHba->lct_size = pHba->lct->table_size << 2; in adpt_i2o_lct_get()
2764 dma_free_coherent(&pHba->pDev->dev, pHba->lct_size, in adpt_i2o_lct_get()
2765 pHba->lct, pHba->lct_pa); in adpt_i2o_lct_get()
2766 pHba->lct = NULL; in adpt_i2o_lct_get()
2768 } while (pHba->lct == NULL); in adpt_i2o_lct_get()
2770 PDEBUG("%s: Hardware resource table read.\n", pHba->name); in adpt_i2o_lct_get()
2774 if(adpt_i2o_query_scalar(pHba, 0 , 0x8000, -1, buf, sizeof(buf))>=0) { in adpt_i2o_lct_get()
2775 pHba->FwDebugBufferSize = buf[1]; in adpt_i2o_lct_get()
2776 pHba->FwDebugBuffer_P = ioremap(pHba->base_addr_phys + buf[0], in adpt_i2o_lct_get()
2777 pHba->FwDebugBufferSize); in adpt_i2o_lct_get()
2778 if (pHba->FwDebugBuffer_P) { in adpt_i2o_lct_get()
2779 pHba->FwDebugFlags_P = pHba->FwDebugBuffer_P + in adpt_i2o_lct_get()
2781 pHba->FwDebugBLEDvalue_P = pHba->FwDebugBuffer_P + in adpt_i2o_lct_get()
2783 pHba->FwDebugBLEDflag_P = pHba->FwDebugBLEDvalue_P + 1; in adpt_i2o_lct_get()
2784 pHba->FwDebugStrLength_P = pHba->FwDebugBuffer_P + in adpt_i2o_lct_get()
2786 pHba->FwDebugBuffer_P += buf[2]; in adpt_i2o_lct_get()
2787 pHba->FwDebugFlags = 0; in adpt_i2o_lct_get()
2800 dma_free_coherent(&pHba->pDev->dev, sys_tbl_len, in adpt_i2o_build_sys_table()
2806 sys_tbl = dma_alloc_coherent(&pHba->pDev->dev, in adpt_i2o_build_sys_table()
2810 return -ENOMEM; in adpt_i2o_build_sys_table()
2813 sys_tbl->num_entries = hba_count; in adpt_i2o_build_sys_table()
2814 sys_tbl->version = I2OVERSION; in adpt_i2o_build_sys_table()
2815 sys_tbl->change_ind = sys_tbl_ind++; in adpt_i2o_build_sys_table()
2817 for(pHba = hba_chain; pHba; pHba = pHba->next) { in adpt_i2o_build_sys_table()
2821 sys_tbl->num_entries--; in adpt_i2o_build_sys_table()
2825 sys_tbl->iops[count].org_id = pHba->status_block->org_id; in adpt_i2o_build_sys_table()
2826 sys_tbl->iops[count].iop_id = pHba->unit + 2; in adpt_i2o_build_sys_table()
2827 sys_tbl->iops[count].seg_num = 0; in adpt_i2o_build_sys_table()
2828 sys_tbl->iops[count].i2o_version = pHba->status_block->i2o_version; in adpt_i2o_build_sys_table()
2829 sys_tbl->iops[count].iop_state = pHba->status_block->iop_state; in adpt_i2o_build_sys_table()
2830 sys_tbl->iops[count].msg_type = pHba->status_block->msg_type; in adpt_i2o_build_sys_table()
2831 sys_tbl->iops[count].frame_size = pHba->status_block->inbound_frame_size; in adpt_i2o_build_sys_table()
2832 sys_tbl->iops[count].last_changed = sys_tbl_ind - 1; // ?? in adpt_i2o_build_sys_table()
2833 sys_tbl->iops[count].iop_capabilities = pHba->status_block->iop_capabilities; in adpt_i2o_build_sys_table()
2834 addr = pHba->base_addr_phys + 0x40; in adpt_i2o_build_sys_table()
2835 sys_tbl->iops[count].inbound_low = dma_low(addr); in adpt_i2o_build_sys_table()
2836 sys_tbl->iops[count].inbound_high = dma_high(addr); in adpt_i2o_build_sys_table()
2863 int unit = d->lct_data.tid; in adpt_i2o_report_hba_unit()
2870 printk(" Vendor: %-12.12s", buf); in adpt_i2o_report_hba_unit()
2875 printk(" Device: %-12.12s", buf); in adpt_i2o_report_hba_unit()
2880 printk(" Rev: %-12.12s\n", buf); in adpt_i2o_report_hba_unit()
2883 printk(KERN_INFO "\tClass: %.21s\n", adpt_i2o_get_class_name(d->lct_data.class_id)); in adpt_i2o_report_hba_unit()
2884 printk(KERN_INFO "\tSubclass: 0x%04X\n", d->lct_data.sub_class); in adpt_i2o_report_hba_unit()
2887 if(d->lct_data.device_flags&(1<<0)) in adpt_i2o_report_hba_unit()
2889 if(d->lct_data.device_flags&(1<<1)) in adpt_i2o_report_hba_unit()
2890 printk("U"); // Multi-user capable in adpt_i2o_report_hba_unit()
2891 if(!(d->lct_data.device_flags&(1<<4))) in adpt_i2o_report_hba_unit()
2893 if(!(d->lct_data.device_flags&(1<<5))) in adpt_i2o_report_hba_unit()
2971 if (pHba->hrt == NULL) { in adpt_i2o_hrt_get()
2972 pHba->hrt = dma_alloc_coherent(&pHba->pDev->dev, in adpt_i2o_hrt_get()
2973 size, &pHba->hrt_pa, GFP_KERNEL); in adpt_i2o_hrt_get()
2974 if (pHba->hrt == NULL) { in adpt_i2o_hrt_get()
2975 printk(KERN_CRIT "%s: Hrt Get failed; Out of memory.\n", pHba->name); in adpt_i2o_hrt_get()
2976 return -ENOMEM; in adpt_i2o_hrt_get()
2985 msg[5]= (u32)pHba->hrt_pa; /* Dump it here */ in adpt_i2o_hrt_get()
2988 printk(KERN_ERR "%s: Unable to get HRT (status=%#10x)\n", pHba->name, ret); in adpt_i2o_hrt_get()
2992 if (pHba->hrt->num_entries * pHba->hrt->entry_len << 2 > size) { in adpt_i2o_hrt_get()
2993 int newsize = pHba->hrt->num_entries * pHba->hrt->entry_len << 2; in adpt_i2o_hrt_get()
2994 dma_free_coherent(&pHba->pDev->dev, size, in adpt_i2o_hrt_get()
2995 pHba->hrt, pHba->hrt_pa); in adpt_i2o_hrt_get()
2997 pHba->hrt = NULL; in adpt_i2o_hrt_get()
2999 } while(pHba->hrt == NULL); in adpt_i2o_hrt_get()
3018 resblk_va = dma_alloc_coherent(&pHba->pDev->dev, in adpt_i2o_query_scalar()
3021 printk(KERN_CRIT "%s: query scalar failed; Out of memory.\n", pHba->name); in adpt_i2o_query_scalar()
3022 return -ENOMEM; in adpt_i2o_query_scalar()
3025 opblk_va = dma_alloc_coherent(&pHba->pDev->dev, in adpt_i2o_query_scalar()
3028 dma_free_coherent(&pHba->pDev->dev, sizeof(u8) * (8+buflen), in adpt_i2o_query_scalar()
3031 pHba->name); in adpt_i2o_query_scalar()
3032 return -ENOMEM; in adpt_i2o_query_scalar()
3034 if (field == -1) /* whole group */ in adpt_i2o_query_scalar()
3035 opblk[4] = -1; in adpt_i2o_query_scalar()
3041 dma_free_coherent(&pHba->pDev->dev, sizeof(opblk), opblk_va, opblk_pa); in adpt_i2o_query_scalar()
3042 if (size == -ETIME) { in adpt_i2o_query_scalar()
3043 dma_free_coherent(&pHba->pDev->dev, sizeof(u8) * (8+buflen), in adpt_i2o_query_scalar()
3045 printk(KERN_WARNING "%s: issue params failed; Timed out.\n", pHba->name); in adpt_i2o_query_scalar()
3046 return -ETIME; in adpt_i2o_query_scalar()
3047 } else if (size == -EINTR) { in adpt_i2o_query_scalar()
3048 dma_free_coherent(&pHba->pDev->dev, sizeof(u8) * (8+buflen), in adpt_i2o_query_scalar()
3050 printk(KERN_WARNING "%s: issue params failed; Interrupted.\n", pHba->name); in adpt_i2o_query_scalar()
3051 return -EINTR; in adpt_i2o_query_scalar()
3056 dma_free_coherent(&pHba->pDev->dev, sizeof(u8) * (8+buflen), in adpt_i2o_query_scalar()
3068 * The OperationBlock is given in opblk-buffer,
3069 * and results are returned in resblk-buffer.
3093 return wait_status; /* -DetailedStatus */ in adpt_i2o_issue_params()
3097 printk(KERN_WARNING "%s: %s - Error:\n ErrorInfoSize = 0x%02x, " in adpt_i2o_issue_params()
3099 pHba->name, in adpt_i2o_issue_params()
3103 return -((res[1] >> 16) & 0xFF); /* -BlockStatus */ in adpt_i2o_issue_params()
3119 if((pHba->status_block->iop_state != ADAPTER_STATE_READY) && in adpt_i2o_quiesce_hba()
3120 (pHba->status_block->iop_state != ADAPTER_STATE_OPERATIONAL)){ in adpt_i2o_quiesce_hba()
3131 pHba->unit, -ret); in adpt_i2o_quiesce_hba()
3133 printk(KERN_INFO"dpti%d: Quiesced.\n",pHba->unit); in adpt_i2o_quiesce_hba()
3150 if(!pHba->status_block){ in adpt_i2o_enable_hba()
3151 return -ENOMEM; in adpt_i2o_enable_hba()
3154 if(pHba->status_block->iop_state == ADAPTER_STATE_OPERATIONAL) in adpt_i2o_enable_hba()
3157 if(pHba->status_block->iop_state != ADAPTER_STATE_READY) in adpt_i2o_enable_hba()
3158 return -EINVAL; in adpt_i2o_enable_hba()
3167 pHba->name, ret); in adpt_i2o_enable_hba()
3169 PDEBUG("%s: Enabled.\n", pHba->name); in adpt_i2o_enable_hba()
3186 msg[4] = (0<<16) | ((pHba->unit+2) << 12); /* Host 0 IOP ID (unit + 2) */ in adpt_i2o_systab_send()
3190 * Provide three SGL-elements: in adpt_i2o_systab_send()
3203 pHba->name, ret); in adpt_i2o_systab_send()
3207 PINFO("%s: SysTab set.\n", pHba->name); in adpt_i2o_systab_send()
3261 return -ENODEV; in adpt_init()
3263 for (pHba = hba_chain; pHba; pHba = pHba->next) { in adpt_init()
3264 error = scsi_add_host(pHba->host, &pHba->pDev->dev); in adpt_init()
3267 scsi_scan_host(pHba->host); in adpt_init()
3272 next = pHba->next; in adpt_init()
3273 scsi_remove_host(pHba->host); in adpt_init()
3283 next = pHba->next; in adpt_exit()