Lines Matching refs:pHba

150 static inline int dpt_dma64(adpt_hba *pHba)
152 return (sizeof(dma_addr_t) > 4 && (pHba)->dma64);
193 adpt_hba *pHba;
212 for (pHba = hba_chain; pHba; pHba = next) {
213 next = pHba->next;
215 if (adpt_i2o_activate_hba(pHba) < 0) {
216 adpt_i2o_delete_hba(pHba);
239 for (pHba = hba_chain; pHba; pHba = pHba->next) {
240 if (adpt_i2o_online_hba(pHba) < 0) {
241 adpt_i2o_delete_hba(pHba);
250 for (pHba = hba_chain; pHba; pHba = next) {
251 next = pHba->next;
252 printk(KERN_INFO"%s: Reading the hardware resource table.\n", pHba->name);
253 if (adpt_i2o_lct_get(pHba) < 0){
254 adpt_i2o_delete_hba(pHba);
258 if (adpt_i2o_parse_lct(pHba) < 0){
259 adpt_i2o_delete_hba(pHba);
262 adpt_inquiry(pHba);
271 for (pHba = hba_chain; pHba; pHba = next) {
272 next = pHba->next;
273 if (adpt_scsi_host_alloc(pHba, sht) < 0){
274 adpt_i2o_delete_hba(pHba);
277 pHba->initialized = TRUE;
278 pHba->state &= ~DPTI_STATE_RESET;
281 NULL, MKDEV(DPTI_I2O_MAJOR, pHba->unit), NULL,
282 "dpti%d", pHba->unit);
286 pHba->unit);
302 static void adpt_release(adpt_hba *pHba)
304 struct Scsi_Host *shost = pHba->host;
307 // adpt_i2o_quiesce_hba(pHba);
308 adpt_i2o_delete_hba(pHba);
313 static void adpt_inquiry(adpt_hba* pHba)
328 buf = dma_alloc_coherent(&pHba->pDev->dev, 80, &addr, GFP_KERNEL);
330 printk(KERN_ERR"%s: Could not allocate buffer\n",pHba->name);
339 if (dpt_dma64(pHba))
375 if (dpt_dma64(pHba)) {
387 rcode = adpt_i2o_post_wait(pHba, msg, reqlen<<2, 120);
389 sprintf(pHba->detail, "Adaptec I2O RAID");
390 printk(KERN_INFO "%s: Inquiry Error (%d)\n",pHba->name,rcode);
392 dma_free_coherent(&pHba->pDev->dev, 80, buf, addr);
394 memset(pHba->detail, 0, sizeof(pHba->detail));
395 memcpy(&(pHba->detail), "Vendor: Adaptec ", 16);
396 memcpy(&(pHba->detail[16]), " Model: ", 8);
397 memcpy(&(pHba->detail[24]), (u8*) &buf[16], 16);
398 memcpy(&(pHba->detail[40]), " FW: ", 4);
399 memcpy(&(pHba->detail[44]), (u8*) &buf[32], 4);
400 pHba->detail[48] = '\0'; /* precautionary */
401 dma_free_coherent(&pHba->pDev->dev, 80, buf, addr);
403 adpt_i2o_status_get(pHba);
421 adpt_hba* pHba = NULL;
438 pHba = (adpt_hba*)cmd->device->host->hostdata[0];
439 if (!pHba) {
444 if ((pHba->state) & DPTI_STATE_RESET)
455 if ((pDev = adpt_find_device(pHba, (u32)cmd->device->channel, (u32)cmd->device->id, cmd->device->lun)) == NULL) {
473 return adpt_scsi_to_i2o(pHba, cmd, pDev);
532 adpt_hba* pHba;
534 pHba = (adpt_hba *) host->hostdata[0];
535 return (char *) (pHba->detail);
543 adpt_hba* pHba;
548 for (pHba = hba_chain; pHba; pHba = pHba->next) {
549 if (pHba->host == host) {
554 if (pHba == NULL) {
557 host = pHba->host;
560 seq_printf(m, "%s\n", pHba->detail);
562 pHba->host->host_no, pHba->name, host->irq);
564 host->can_queue, (int) pHba->reply_fifo_size , host->sg_tablesize);
569 d = pHba->channel[chan].device[id];
592 adpt_hba* pHba = NULL; /* host bus adapter structure */
597 pHba = (adpt_hba*) cmd->device->host->hostdata[0];
598 printk(KERN_INFO"%s: Trying to Abort\n",pHba->name);
600 printk(KERN_ERR "%s: Unable to abort: No device in cmnd\n",pHba->name);
611 if (pHba->host)
612 spin_lock_irq(pHba->host->host_lock);
613 rcode = adpt_i2o_post_wait(pHba, msg, sizeof(msg), FOREVER);
614 if (pHba->host)
615 spin_unlock_irq(pHba->host->host_lock);
618 printk(KERN_INFO"%s: Abort cmd not supported\n",pHba->name);
621 printk(KERN_INFO"%s: Abort failed.\n",pHba->name);
624 printk(KERN_INFO"%s: Abort complete.\n",pHba->name);
635 adpt_hba* pHba;
641 pHba = (void*) cmd->device->host->hostdata[0];
642 printk(KERN_INFO"%s: Trying to reset device\n",pHba->name);
644 printk(KERN_INFO"%s: Reset Device: Device Not found\n",pHba->name);
653 if (pHba->host)
654 spin_lock_irq(pHba->host->host_lock);
657 rcode = adpt_i2o_post_wait(pHba, msg,sizeof(msg), FOREVER);
659 if (pHba->host)
660 spin_unlock_irq(pHba->host->host_lock);
663 printk(KERN_INFO"%s: Device reset not supported\n",pHba->name);
666 printk(KERN_INFO"%s: Device reset failed\n",pHba->name);
669 printk(KERN_INFO"%s: Device reset successful\n",pHba->name);
679 adpt_hba* pHba;
683 pHba = (adpt_hba*)cmd->device->host->hostdata[0];
685 printk(KERN_WARNING"%s: Bus reset: SCSI Bus %d: tid: %d\n",pHba->name, cmd->device->channel,pHba->channel[cmd->device->channel].tid );
687 msg[1] = (I2O_HBA_BUS_RESET<<24|HOST_TID<<12|pHba->channel[cmd->device->channel].tid);
690 if (pHba->host)
691 spin_lock_irq(pHba->host->host_lock);
692 rcode = adpt_i2o_post_wait(pHba, msg,sizeof(msg), FOREVER);
693 if (pHba->host)
694 spin_unlock_irq(pHba->host->host_lock);
696 printk(KERN_WARNING"%s: Bus reset failed.\n",pHba->name);
699 printk(KERN_WARNING"%s: Bus reset success.\n",pHba->name);
707 adpt_hba* pHba;
711 pHba = (adpt_hba*)cmd->device->host->hostdata[0];
712 strncpy(name, pHba->name, sizeof(name));
713 printk(KERN_WARNING"%s: Hba Reset: scsi id %d: tid: %d\n", name, cmd->device->channel, pHba->channel[cmd->device->channel].tid);
714 rcode = adpt_hba_reset(pHba);
736 static int adpt_hba_reset(adpt_hba* pHba)
740 pHba->state |= DPTI_STATE_RESET;
743 if ((rcode=adpt_i2o_activate_hba(pHba)) < 0) {
744 printk(KERN_ERR "%s: Could not activate\n", pHba->name);
745 adpt_i2o_delete_hba(pHba);
750 adpt_i2o_delete_hba(pHba);
753 PDEBUG("%s: in HOLD state\n",pHba->name);
755 if ((rcode=adpt_i2o_online_hba(pHba)) < 0) {
756 adpt_i2o_delete_hba(pHba);
759 PDEBUG("%s: in OPERATIONAL state\n",pHba->name);
761 if ((rcode=adpt_i2o_lct_get(pHba)) < 0){
762 adpt_i2o_delete_hba(pHba);
766 if ((rcode=adpt_i2o_reparse_lct(pHba)) < 0){
767 adpt_i2o_delete_hba(pHba);
770 pHba->state &= ~DPTI_STATE_RESET;
772 scsi_host_complete_all_commands(pHba->host, DID_RESET);
784 adpt_hba *pHba, *pNext;
793 for (pHba = hba_chain; pHba; pHba = pNext) {
794 pNext = pHba->next;
795 adpt_i2o_delete_hba(pHba);
817 adpt_hba* pHba = NULL;
913 pHba = kzalloc(sizeof(adpt_hba), GFP_KERNEL);
914 if (!pHba) {
926 p->next = pHba;
928 hba_chain = pHba;
930 pHba->next = NULL;
931 pHba->unit = hba_count;
932 sprintf(pHba->name, "dpti%d", hba_count);
937 pHba->pDev = pDev;
938 pHba->base_addr_phys = base_addr0_phys;
941 pHba->base_addr_virt = base_addr_virt;
942 pHba->msg_addr_virt = msg_addr_virt;
943 pHba->irq_mask = base_addr_virt+0x30;
944 pHba->post_port = base_addr_virt+0x40;
945 pHba->reply_port = base_addr_virt+0x44;
947 pHba->hrt = NULL;
948 pHba->lct = NULL;
949 pHba->lct_size = 0;
950 pHba->status_block = NULL;
951 pHba->post_count = 0;
952 pHba->state = DPTI_STATE_RESET;
953 pHba->pDev = pDev;
954 pHba->devices = NULL;
955 pHba->dma64 = dma64;
958 spin_lock_init(&pHba->state_lock);
975 if (request_irq (pDev->irq, adpt_isr, IRQF_SHARED, pHba->name, pHba)) {
976 printk(KERN_ERR"%s: Couldn't register IRQ %d\n", pHba->name, pDev->irq);
977 adpt_i2o_delete_hba(pHba);
985 static void adpt_i2o_delete_hba(adpt_hba* pHba)
998 if(pHba->host){
999 free_irq(pHba->host->irq, pHba);
1003 if(p1 == pHba) {
1016 iounmap(pHba->base_addr_virt);
1017 pci_release_regions(pHba->pDev);
1018 if(pHba->msg_addr_virt != pHba->base_addr_virt){
1019 iounmap(pHba->msg_addr_virt);
1021 if(pHba->FwDebugBuffer_P)
1022 iounmap(pHba->FwDebugBuffer_P);
1023 if(pHba->hrt) {
1024 dma_free_coherent(&pHba->pDev->dev,
1025 pHba->hrt->num_entries * pHba->hrt->entry_len << 2,
1026 pHba->hrt, pHba->hrt_pa);
1028 if(pHba->lct) {
1029 dma_free_coherent(&pHba->pDev->dev, pHba->lct_size,
1030 pHba->lct, pHba->lct_pa);
1032 if(pHba->status_block) {
1033 dma_free_coherent(&pHba->pDev->dev, sizeof(i2o_status_block),
1034 pHba->status_block, pHba->status_block_pa);
1036 if(pHba->reply_pool) {
1037 dma_free_coherent(&pHba->pDev->dev,
1038 pHba->reply_fifo_size * REPLY_FRAME_SIZE * 4,
1039 pHba->reply_pool, pHba->reply_pool_pa);
1042 for(d = pHba->devices; d ; d = next){
1046 for(i = 0 ; i < pHba->top_scsi_channel ; i++){
1048 if(pHba->channel[i].device[j] != NULL){
1049 for(pDev = pHba->channel[i].device[j]; pDev; pDev = pNext){
1056 pci_dev_put(pHba->pDev);
1059 MKDEV(DPTI_I2O_MAJOR, pHba->unit));
1060 kfree(pHba);
1071 static struct adpt_device* adpt_find_device(adpt_hba* pHba, u32 chan, u32 id, u64 lun)
1078 d = pHba->channel[chan].device[id];
1098 static int adpt_i2o_post_wait(adpt_hba* pHba, u32* msg, int len, int timeout)
1135 if((status = adpt_i2o_post_this(pHba, msg, len)) == 0){
1137 if(pHba->host)
1138 spin_unlock_irq(pHba->host->host_lock);
1150 if(pHba->host)
1151 spin_lock_irq(pHba->host->host_lock);
1156 printk(KERN_INFO"dpti%d: POST WAIT TIMEOUT\n",pHba->unit);
1185 static s32 adpt_i2o_post_this(adpt_hba* pHba, u32* data, int len)
1193 m = readl(pHba->post_port);
1198 printk(KERN_WARNING"dpti%d: Timeout waiting for message frame!\n", pHba->unit);
1204 msg = pHba->msg_addr_virt + m;
1209 writel(m, pHba->post_port);
1253 static s32 adpt_i2o_reset_hba(adpt_hba* pHba)
1261 if(pHba->initialized == FALSE) { // First time reset should be quick
1264 adpt_i2o_quiesce_hba(pHba);
1269 m = readl(pHba->post_port);
1280 status = dma_alloc_coherent(&pHba->pDev->dev, 4, &addr, GFP_KERNEL);
1282 adpt_send_nop(pHba, m);
1296 memcpy_toio(pHba->msg_addr_virt+m, msg, sizeof(msg));
1298 writel(m, pHba->post_port);
1303 printk(KERN_WARNING"%s: IOP Reset Timeout\n",pHba->name);
1307 /* dma_free_coherent(&pHba->pDev->dev, 4, buf, addr); */
1315 PDEBUG("%s: Reset in progress...\n", pHba->name);
1320 m = readl(pHba->post_port);
1325 printk(KERN_ERR "%s:Timeout waiting for IOP Reset.\n",pHba->name);
1329 /* dma_free_coherent(&pHba->pDev->dev, 4, buf, addr); */
1335 adpt_send_nop(pHba, m);
1337 adpt_i2o_status_get(pHba);
1339 pHba->status_block->iop_state != ADAPTER_STATE_RESET) {
1341 pHba->name);
1343 PDEBUG("%s: Reset completed.\n", pHba->name);
1346 dma_free_coherent(&pHba->pDev->dev, 4, status, addr);
1356 static int adpt_i2o_parse_lct(adpt_hba* pHba)
1362 i2o_lct *lct = pHba->lct;
1370 printk(KERN_ERR "%s: LCT is empty???\n",pHba->name);
1394 if(adpt_i2o_query_scalar(pHba, tid, 0x8000, -1, buf, 32)<0) {
1401 printk(KERN_WARNING"%s: Channel number %d out of range \n", pHba->name, bus_no);
1405 printk(KERN_WARNING"%s: SCSI ID %d out of range \n", pHba->name, bus_no);
1408 if(bus_no > pHba->top_scsi_channel){
1409 pHba->top_scsi_channel = bus_no;
1411 if(scsi_id > pHba->top_scsi_id){
1412 pHba->top_scsi_id = scsi_id;
1414 if(scsi_lun > pHba->top_scsi_lun){
1415 pHba->top_scsi_lun = scsi_lun;
1422 printk(KERN_CRIT"%s: Out of memory for I2O device data.\n",pHba->name);
1426 d->controller = pHba;
1433 adpt_i2o_report_hba_unit(pHba, d);
1434 adpt_i2o_install_device(pHba, d);
1437 for(d = pHba->devices; d ; d = d->next) {
1443 if(bus_no > pHba->top_scsi_channel){
1444 pHba->top_scsi_channel = bus_no;
1446 pHba->channel[bus_no].type = d->lct_data.class_id;
1447 pHba->channel[bus_no].tid = tid;
1448 if(adpt_i2o_query_scalar(pHba, tid, 0x0200, -1, buf, 28)>=0)
1450 pHba->channel[bus_no].scsi_id = buf[1];
1456 printk(KERN_WARNING"%s: Channel number %d out of range - LCT\n", pHba->name, bus_no);
1463 for(d = pHba->devices; d ; d = d->next) {
1471 if(adpt_i2o_query_scalar(pHba, tid, 0x8000, -1, buf, 32)>=0) {
1481 if( pHba->channel[bus_no].device[scsi_id] == NULL){
1486 pHba->channel[bus_no].device[scsi_id] = pDev;
1488 for( pDev = pHba->channel[bus_no].device[scsi_id];
1505 if(scsi_id > pHba->top_scsi_id){
1506 pHba->top_scsi_id = scsi_id;
1508 if(scsi_lun > pHba->top_scsi_lun){
1509 pHba->top_scsi_lun = scsi_lun;
1527 static int adpt_i2o_install_device(adpt_hba* pHba, struct i2o_device *d)
1530 d->controller=pHba;
1532 d->next=pHba->devices;
1534 if (pHba->devices != NULL){
1535 pHba->devices->prev=d;
1537 pHba->devices=d;
1547 adpt_hba* pHba;
1558 for (pHba = hba_chain; pHba; pHba = pHba->next) {
1559 if (pHba->unit == minor) {
1563 if (pHba == NULL) {
1569 // if(pHba->in_use){
1574 pHba->in_use = 1;
1584 adpt_hba* pHba;
1591 for (pHba = hba_chain; pHba; pHba = pHba->next) {
1592 if (pHba->unit == minor) {
1597 if (pHba == NULL) {
1601 pHba->in_use = 0;
1703 adpt_hba* pHba;
1712 for (pHba = hba_chain; pHba; pHba = pHba->next) {
1713 if (pHba->unit == minor) {
1718 if(pHba == NULL){
1722 while((volatile u32) pHba->state & DPTI_STATE_RESET )
1740 HbaInfo.drvrHBAnum = pHba->unit;
1741 HbaInfo.baseAddr = (ulong) pHba->base_addr_phys;
1742 HbaInfo.blinkState = adpt_read_blink_led(pHba);
1743 HbaInfo.pciBusNum = pHba->pDev->bus->number;
1744 HbaInfo.pciDeviceNum=PCI_SLOT(pHba->pDev->devfn);
1745 HbaInfo.Interrupt = pHba->pDev->irq;
1748 printk(KERN_WARNING"%s: Could not copy HbaInfo TO user\n",pHba->name);
1757 value = (u32)adpt_read_blink_led(pHba);
1764 struct Scsi_Host *shost = pHba->host;
1768 adpt_hba_reset(pHba);
1774 adpt_rescan(pHba);
1833 adpt_hba* pHba = dev_id;
1841 if (pHba == NULL){
1845 if(pHba->host)
1846 spin_lock_irqsave(pHba->host->host_lock, flags);
1848 while( readl(pHba->irq_mask) & I2O_INTERRUPT_PENDING_B) {
1849 m = readl(pHba->reply_port);
1853 m = readl(pHba->reply_port);
1860 if (pHba->reply_pool_pa <= m &&
1861 m < pHba->reply_pool_pa +
1862 (pHba->reply_fifo_size * REPLY_FRAME_SIZE * 4)) {
1863 reply = (u8 *)pHba->reply_pool +
1864 (m - pHba->reply_pool_pa);
1875 PDEBUG("%s: Failed message\n",pHba->name);
1877 printk(KERN_ERR"%s: Bad preserved MFA (%x)- dropping frame\n",pHba->name,old_m);
1878 writel(m,pHba->reply_port);
1882 msg = pHba->msg_addr_virt + old_m;
1885 adpt_send_nop(pHba, old_m);
1899 cmd = scsi_host_find_tag(pHba->host,
1902 printk(KERN_WARNING"%s: Apparent SCSI cmd in Post Wait Context - cmd=%p context=%x\n", pHba->name, cmd, context);
1910 cmd = scsi_host_find_tag(pHba->host,
1917 writel(m, pHba->reply_port);
1922 out: if(pHba->host)
1923 spin_unlock_irqrestore(pHba->host->host_lock, flags);
1927 static s32 adpt_scsi_to_i2o(adpt_hba* pHba, struct scsi_cmnd* cmd, struct adpt_device* d)
1970 pHba->name, cmd->cmnd[0]);
1999 if (dpt_dma64(pHba)) {
2020 if (dpt_dma64(pHba))
2042 rcode = adpt_i2o_post_this(pHba, msg, reqlen<<2);
2050 static s32 adpt_scsi_host_alloc(adpt_hba* pHba, struct scsi_host_template *sht)
2056 printk("%s: scsi_host_alloc returned NULL\n", pHba->name);
2059 host->hostdata[0] = (unsigned long)pHba;
2060 pHba->host = host;
2062 host->irq = pHba->pDev->irq;
2071 host->max_channel = pHba->top_scsi_channel + 1;
2073 host->unique_id = (u32)sys_tbl_pa + pHba->unit;
2074 host->sg_tablesize = pHba->sg_tablesize;
2075 host->can_queue = pHba->post_fifo_size;
2083 adpt_hba* pHba;
2097 pHba = (adpt_hba*) cmd->device->host->hostdata[0];
2108 printk(KERN_WARNING"%s: SCSI CMD underflow\n",pHba->name);
2121 pHba->name, (u32)cmd->device->channel, (u32)cmd->device->id, cmd->device->lun, hba_status, dev_status, cmd->cmnd[0]);
2133 printk(KERN_WARNING"%s: SCSI CMD parity error\n",pHba->name);
2161 pHba->name, detailed_status & I2O_SCSI_DSC_MASK, (u32)cmd->device->channel, (u32)cmd->device->id, cmd->device->lun,
2178 pHba->name, (u32)cmd->device->channel, (u32)cmd->device->id, cmd->device->lun,
2190 pHba->name, (u32)cmd->device->channel, (u32)cmd->device->id, cmd->device->lun,
2202 static s32 adpt_rescan(adpt_hba* pHba)
2207 if(pHba->host)
2208 spin_lock_irqsave(pHba->host->host_lock, flags);
2209 if ((rcode=adpt_i2o_lct_get(pHba)) < 0)
2211 if ((rcode=adpt_i2o_reparse_lct(pHba)) < 0)
2214 out: if(pHba->host)
2215 spin_unlock_irqrestore(pHba->host->host_lock, flags);
2220 static s32 adpt_i2o_reparse_lct(adpt_hba* pHba)
2226 i2o_lct *lct = pHba->lct;
2235 printk(KERN_ERR "%s: LCT is empty???\n",pHba->name);
2244 for (d = pHba->devices; d; d = d->next) {
2252 printk(KERN_INFO "%s: LCT has %d entries.\n", pHba->name,max);
2263 if(adpt_i2o_query_scalar(pHba, tid, 0x8000, -1, buf, 32)<0) {
2264 printk(KERN_ERR"%s: Could not query device\n",pHba->name);
2271 pHba->name, bus_no);
2277 pDev = pHba->channel[bus_no].device[scsi_id];
2294 d->controller = pHba;
2300 adpt_i2o_report_hba_unit(pHba, d);
2301 adpt_i2o_install_device(pHba, d);
2303 pDev = pHba->channel[bus_no].device[scsi_id];
2311 pHba->channel[bus_no].device[scsi_id] = pDev;
2332 if(scsi_id > pHba->top_scsi_id){
2333 pHba->top_scsi_id = scsi_id;
2335 if(scsi_lun > pHba->top_scsi_lun){
2336 pHba->top_scsi_lun = scsi_lun;
2346 pHba->name,bus_no,scsi_id,scsi_lun);
2368 for (pI2o_dev = pHba->devices; pI2o_dev; pI2o_dev = pI2o_dev->next) {
2377 printk(KERN_WARNING"%s: Device (%d,%d,%llu) offline\n",pHba->name,pDev->scsi_channel,pDev->scsi_id,pDev->scsi_lun);
2396 static int adpt_i2o_activate_hba(adpt_hba* pHba)
2400 if(pHba->initialized ) {
2401 if (adpt_i2o_status_get(pHba) < 0) {
2402 if((rcode = adpt_i2o_reset_hba(pHba)) != 0){
2403 printk(KERN_WARNING"%s: Could NOT reset.\n", pHba->name);
2406 if (adpt_i2o_status_get(pHba) < 0) {
2412 if(pHba->status_block->iop_state == ADAPTER_STATE_FAULTED) {
2413 printk(KERN_CRIT "%s: hardware fault\n", pHba->name);
2417 if (pHba->status_block->iop_state == ADAPTER_STATE_READY ||
2418 pHba->status_block->iop_state == ADAPTER_STATE_OPERATIONAL ||
2419 pHba->status_block->iop_state == ADAPTER_STATE_HOLD ||
2420 pHba->status_block->iop_state == ADAPTER_STATE_FAILED) {
2421 adpt_i2o_reset_hba(pHba);
2422 if (adpt_i2o_status_get(pHba) < 0 || pHba->status_block->iop_state != ADAPTER_STATE_RESET) {
2423 printk(KERN_ERR "%s: Failed to initialize.\n", pHba->name);
2428 if((rcode = adpt_i2o_reset_hba(pHba)) != 0){
2429 printk(KERN_WARNING"%s: Could NOT reset.\n", pHba->name);
2435 if (adpt_i2o_init_outbound_q(pHba) < 0) {
2441 if (adpt_i2o_hrt_get(pHba) < 0) {
2452 static int adpt_i2o_online_hba(adpt_hba* pHba)
2454 if (adpt_i2o_systab_send(pHba) < 0)
2458 if (adpt_i2o_enable_hba(pHba) < 0)
2465 static s32 adpt_send_nop(adpt_hba*pHba,u32 m)
2472 m = readl(pHba->post_port);
2477 printk(KERN_ERR "%s: Timeout waiting for message frame!\n",pHba->name);
2482 msg = (u32 __iomem *)(pHba->msg_addr_virt + m);
2488 writel(m, pHba->post_port);
2493 static s32 adpt_i2o_init_outbound_q(adpt_hba* pHba)
2504 m = readl(pHba->post_port);
2510 printk(KERN_WARNING"%s: Timeout waiting for message frame\n",pHba->name);
2516 msg=(u32 __iomem *)(pHba->msg_addr_virt+m);
2518 status = dma_alloc_coherent(&pHba->pDev->dev, 4, &addr, GFP_KERNEL);
2520 adpt_send_nop(pHba, m);
2522 pHba->name);
2535 writel(m, pHba->post_port);
2547 printk(KERN_WARNING"%s: Timeout Initializing\n",pHba->name);
2551 /* dma_free_coherent(&pHba->pDev->dev, 4, status, addr); */
2560 dma_free_coherent(&pHba->pDev->dev, 4, status, addr);
2563 dma_free_coherent(&pHba->pDev->dev, 4, status, addr);
2565 if(pHba->reply_pool != NULL) {
2566 dma_free_coherent(&pHba->pDev->dev,
2567 pHba->reply_fifo_size * REPLY_FRAME_SIZE * 4,
2568 pHba->reply_pool, pHba->reply_pool_pa);
2571 pHba->reply_pool = dma_alloc_coherent(&pHba->pDev->dev,
2572 pHba->reply_fifo_size * REPLY_FRAME_SIZE * 4,
2573 &pHba->reply_pool_pa, GFP_KERNEL);
2574 if (!pHba->reply_pool) {
2575 printk(KERN_ERR "%s: Could not allocate reply pool\n", pHba->name);
2579 for(i = 0; i < pHba->reply_fifo_size; i++) {
2580 writel(pHba->reply_pool_pa + (i * REPLY_FRAME_SIZE * 4),
2581 pHba->reply_port);
2584 adpt_i2o_status_get(pHba);
2600 static s32 adpt_i2o_status_get(adpt_hba* pHba)
2607 if(pHba->status_block == NULL) {
2608 pHba->status_block = dma_alloc_coherent(&pHba->pDev->dev,
2610 &pHba->status_block_pa, GFP_KERNEL);
2611 if(pHba->status_block == NULL) {
2614 pHba->unit);
2618 memset(pHba->status_block, 0, sizeof(i2o_status_block));
2619 status_block = (u8*)(pHba->status_block);
2623 m = readl(pHba->post_port);
2629 pHba->name);
2636 msg=(u32 __iomem *)(pHba->msg_addr_virt+m);
2644 writel( dma_low(pHba->status_block_pa), &msg[6]);
2645 writel( dma_high(pHba->status_block_pa), &msg[7]);
2649 writel(m, pHba->post_port);
2655 pHba->unit);
2663 pHba->post_fifo_size = pHba->status_block->max_inbound_frames;
2664 if (pHba->post_fifo_size > MAX_TO_IOP_MESSAGES) {
2665 pHba->post_fifo_size = MAX_TO_IOP_MESSAGES;
2668 pHba->reply_fifo_size = pHba->status_block->max_outbound_frames;
2669 if (pHba->reply_fifo_size > MAX_FROM_IOP_MESSAGES) {
2670 pHba->reply_fifo_size = MAX_FROM_IOP_MESSAGES;
2674 if (dpt_dma64(pHba)) {
2675 pHba->sg_tablesize
2676 = ((pHba->status_block->inbound_frame_size * 4
2680 pHba->sg_tablesize
2681 = ((pHba->status_block->inbound_frame_size * 4
2685 if (pHba->sg_tablesize > SG_LIST_ELEMENTS) {
2686 pHba->sg_tablesize = SG_LIST_ELEMENTS;
2691 printk("dpti%d: State = ",pHba->unit);
2692 switch(pHba->status_block->iop_state) {
2715 printk("%x (unknown!!)\n",pHba->status_block->iop_state);
2724 static int adpt_i2o_lct_get(adpt_hba* pHba)
2730 if ((pHba->lct_size == 0) || (pHba->lct == NULL)){
2731 pHba->lct_size = pHba->status_block->expected_lct_size;
2734 if (pHba->lct == NULL) {
2735 pHba->lct = dma_alloc_coherent(&pHba->pDev->dev,
2736 pHba->lct_size, &pHba->lct_pa,
2738 if(pHba->lct == NULL) {
2740 pHba->name);
2744 memset(pHba->lct, 0, pHba->lct_size);
2752 msg[6] = 0xD0000000|pHba->lct_size;
2753 msg[7] = (u32)pHba->lct_pa;
2755 if ((ret=adpt_i2o_post_wait(pHba, msg, sizeof(msg), 360))) {
2757 pHba->name, ret);
2762 if ((pHba->lct->table_size << 2) > pHba->lct_size) {
2763 pHba->lct_size = pHba->lct->table_size << 2;
2764 dma_free_coherent(&pHba->pDev->dev, pHba->lct_size,
2765 pHba->lct, pHba->lct_pa);
2766 pHba->lct = NULL;
2768 } while (pHba->lct == NULL);
2770 PDEBUG("%s: Hardware resource table read.\n", pHba->name);
2774 if(adpt_i2o_query_scalar(pHba, 0 , 0x8000, -1, buf, sizeof(buf))>=0) {
2775 pHba->FwDebugBufferSize = buf[1];
2776 pHba->FwDebugBuffer_P = ioremap(pHba->base_addr_phys + buf[0],
2777 pHba->FwDebugBufferSize);
2778 if (pHba->FwDebugBuffer_P) {
2779 pHba->FwDebugFlags_P = pHba->FwDebugBuffer_P +
2781 pHba->FwDebugBLEDvalue_P = pHba->FwDebugBuffer_P +
2783 pHba->FwDebugBLEDflag_P = pHba->FwDebugBLEDvalue_P + 1;
2784 pHba->FwDebugStrLength_P = pHba->FwDebugBuffer_P +
2786 pHba->FwDebugBuffer_P += buf[2];
2787 pHba->FwDebugFlags = 0;
2796 adpt_hba* pHba = hba_chain;
2800 dma_free_coherent(&pHba->pDev->dev, sys_tbl_len,
2806 sys_tbl = dma_alloc_coherent(&pHba->pDev->dev,
2817 for(pHba = hba_chain; pHba; pHba = pHba->next) {
2820 if (adpt_i2o_status_get(pHba)) {
2825 sys_tbl->iops[count].org_id = pHba->status_block->org_id;
2826 sys_tbl->iops[count].iop_id = pHba->unit + 2;
2828 sys_tbl->iops[count].i2o_version = pHba->status_block->i2o_version;
2829 sys_tbl->iops[count].iop_state = pHba->status_block->iop_state;
2830 sys_tbl->iops[count].msg_type = pHba->status_block->msg_type;
2831 sys_tbl->iops[count].frame_size = pHba->status_block->inbound_frame_size;
2833 sys_tbl->iops[count].iop_capabilities = pHba->status_block->iop_capabilities;
2834 addr = pHba->base_addr_phys + 0x40;
2860 static void adpt_i2o_report_hba_unit(adpt_hba* pHba, struct i2o_device *d)
2867 if(adpt_i2o_query_scalar(pHba, unit, 0xF100, 3, buf, 16)>=0)
2872 if(adpt_i2o_query_scalar(pHba, unit, 0xF100, 4, buf, 16)>=0)
2877 if(adpt_i2o_query_scalar(pHba, unit, 0xF100, 6, buf, 8)>=0)
2965 static s32 adpt_i2o_hrt_get(adpt_hba* pHba)
2971 if (pHba->hrt == NULL) {
2972 pHba->hrt = dma_alloc_coherent(&pHba->pDev->dev,
2973 size, &pHba->hrt_pa, GFP_KERNEL);
2974 if (pHba->hrt == NULL) {
2975 printk(KERN_CRIT "%s: Hrt Get failed; Out of memory.\n", pHba->name);
2985 msg[5]= (u32)pHba->hrt_pa; /* Dump it here */
2987 if ((ret = adpt_i2o_post_wait(pHba, msg, sizeof(msg),20))) {
2988 printk(KERN_ERR "%s: Unable to get HRT (status=%#10x)\n", pHba->name, ret);
2992 if (pHba->hrt->num_entries * pHba->hrt->entry_len << 2 > size) {
2993 int newsize = pHba->hrt->num_entries * pHba->hrt->entry_len << 2;
2994 dma_free_coherent(&pHba->pDev->dev, size,
2995 pHba->hrt, pHba->hrt_pa);
2997 pHba->hrt = NULL;
2999 } while(pHba->hrt == NULL);
3006 static int adpt_i2o_query_scalar(adpt_hba* pHba, int tid,
3018 resblk_va = dma_alloc_coherent(&pHba->pDev->dev,
3021 printk(KERN_CRIT "%s: query scalar failed; Out of memory.\n", pHba->name);
3025 opblk_va = dma_alloc_coherent(&pHba->pDev->dev,
3028 dma_free_coherent(&pHba->pDev->dev, sizeof(u8) * (8+buflen),
3031 pHba->name);
3038 size = adpt_i2o_issue_params(I2O_CMD_UTIL_PARAMS_GET, pHba, tid,
3041 dma_free_coherent(&pHba->pDev->dev, sizeof(opblk), opblk_va, opblk_pa);
3043 dma_free_coherent(&pHba->pDev->dev, sizeof(u8) * (8+buflen),
3045 printk(KERN_WARNING "%s: issue params failed; Timed out.\n", pHba->name);
3048 dma_free_coherent(&pHba->pDev->dev, sizeof(u8) * (8+buflen),
3050 printk(KERN_WARNING "%s: issue params failed; Interrupted.\n", pHba->name);
3056 dma_free_coherent(&pHba->pDev->dev, sizeof(u8) * (8+buflen),
3073 static int adpt_i2o_issue_params(int cmd, adpt_hba* pHba, int tid,
3091 if ((wait_status = adpt_i2o_post_wait(pHba, msg, sizeof(msg), 20))) {
3099 pHba->name,
3110 static s32 adpt_i2o_quiesce_hba(adpt_hba* pHba)
3115 adpt_i2o_status_get(pHba);
3119 if((pHba->status_block->iop_state != ADAPTER_STATE_READY) &&
3120 (pHba->status_block->iop_state != ADAPTER_STATE_OPERATIONAL)){
3129 if((ret = adpt_i2o_post_wait(pHba, msg, sizeof(msg), 240))) {
3131 pHba->unit, -ret);
3133 printk(KERN_INFO"dpti%d: Quiesced.\n",pHba->unit);
3136 adpt_i2o_status_get(pHba);
3144 static int adpt_i2o_enable_hba(adpt_hba* pHba)
3149 adpt_i2o_status_get(pHba);
3150 if(!pHba->status_block){
3154 if(pHba->status_block->iop_state == ADAPTER_STATE_OPERATIONAL)
3157 if(pHba->status_block->iop_state != ADAPTER_STATE_READY)
3165 if ((ret = adpt_i2o_post_wait(pHba, msg, sizeof(msg), 240))) {
3167 pHba->name, ret);
3169 PDEBUG("%s: Enabled.\n", pHba->name);
3172 adpt_i2o_status_get(pHba);
3177 static int adpt_i2o_systab_send(adpt_hba* pHba)
3186 msg[4] = (0<<16) | ((pHba->unit+2) << 12); /* Host 0 IOP ID (unit + 2) */
3201 if ((ret=adpt_i2o_post_wait(pHba, msg, sizeof(msg), 120))) {
3203 pHba->name, ret);
3207 PINFO("%s: SysTab set.\n", pHba->name);
3253 adpt_hba *pHba, *next;
3263 for (pHba = hba_chain; pHba; pHba = pHba->next) {
3264 error = scsi_add_host(pHba->host, &pHba->pDev->dev);
3267 scsi_scan_host(pHba->host);
3271 for (pHba = hba_chain; pHba; pHba = next) {
3272 next = pHba->next;
3273 scsi_remove_host(pHba->host);
3280 adpt_hba *pHba, *next;
3282 for (pHba = hba_chain; pHba; pHba = next) {
3283 next = pHba->next;
3284 adpt_release(pHba);