Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge master.kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6

* master.kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6: (73 commits)
[SCSI] aic79xx: Add ASC-29320LPE ids to driver
[SCSI] stex: version update
[SCSI] stex: change wait loop code
[SCSI] stex: add new device type support
[SCSI] stex: update device id info
[SCSI] stex: adjust default queue length
[SCSI] stex: add value check in hard reset routine
[SCSI] stex: fix controller_info command handling
[SCSI] stex: fix biosparam calculation
[SCSI] megaraid: fix MMIO casts
[SCSI] tgt: fix undefined flush_dcache_page() problem
[SCSI] libsas: better error handling in sas_expander.c
[SCSI] lpfc 8.1.11 : Change version number to 8.1.11
[SCSI] lpfc 8.1.11 : Misc Fixes
[SCSI] lpfc 8.1.11 : Add soft_wwnn sysfs attribute, rename soft_wwn_enable
[SCSI] lpfc 8.1.11 : Removed decoding of PCI Subsystem Id
[SCSI] lpfc 8.1.11 : Add MSI (Message Signalled Interrupts) support
[SCSI] lpfc 8.1.11 : Adjust LOG_FCP logging
[SCSI] lpfc 8.1.11 : Fix Memory leaks
[SCSI] lpfc 8.1.11 : Fix lpfc_multi_ring_support
...

+4763 -1129
+5
Documentation/kernel-parameters.txt
··· 1416 1416 1417 1417 scsi_logging= [SCSI] 1418 1418 1419 + scsi_mod.scan= [SCSI] sync (default) scans SCSI busses as they are 1420 + discovered. async scans them in kernel threads, 1421 + allowing boot to proceed. none ignores them, expecting 1422 + user space to do the scan. 1423 + 1419 1424 selinux [SELINUX] Disable or enable SELinux at boot time. 1420 1425 Format: { "0" | "1" } 1421 1426 See security/selinux/Kconfig help text.
+4 -25
Documentation/scsi/scsi_mid_low_api.txt
··· 375 375 scsi_add_device - creates new scsi device (lu) instance 376 376 scsi_add_host - perform sysfs registration and set up transport class 377 377 scsi_adjust_queue_depth - change the queue depth on a SCSI device 378 - scsi_assign_lock - replace default host_lock with given lock 379 378 scsi_bios_ptable - return copy of block device's partition table 380 379 scsi_block_requests - prevent further commands being queued to given host 381 380 scsi_deactivate_tcq - turn off tag command queueing ··· 485 486 **/ 486 487 void scsi_adjust_queue_depth(struct scsi_device * sdev, int tagged, 487 488 int tags) 488 - 489 - 490 - /** 491 - * scsi_assign_lock - replace default host_lock with given lock 492 - * @shost: a pointer to a scsi host instance 493 - * @lock: pointer to lock to replace host_lock for this host 494 - * 495 - * Returns nothing 496 - * 497 - * Might block: no 498 - * 499 - * Defined in: include/scsi/scsi_host.h . 500 - **/ 501 - void scsi_assign_lock(struct Scsi_Host *shost, spinlock_t *lock) 502 489 503 490 504 491 /** ··· 1351 1366 Each struct Scsi_Host instance has a spin_lock called struct 1352 1367 Scsi_Host::default_lock which is initialized in scsi_host_alloc() [found in 1353 1368 hosts.c]. Within the same function the struct Scsi_Host::host_lock pointer 1354 - is initialized to point at default_lock with the scsi_assign_lock() function. 1355 - Thereafter lock and unlock operations performed by the mid level use the 1356 - struct Scsi_Host::host_lock pointer. 1369 + is initialized to point at default_lock. Thereafter lock and unlock 1370 + operations performed by the mid level use the struct Scsi_Host::host_lock 1371 + pointer. Previously drivers could override the host_lock pointer but 1372 + this is not allowed anymore. 1357 1373 1358 - LLDs can override the use of struct Scsi_Host::default_lock by 1359 - using scsi_assign_lock(). The earliest opportunity to do this would 1360 - be in the detect() function after it has invoked scsi_register(). It 1361 - could be replaced by a coarser grain lock (e.g. per driver) or a 1362 - lock of equal granularity (i.e. per host). Using finer grain locks 1363 - (e.g. per SCSI device) may be possible by juggling locks in 1364 - queuecommand(). 1365 1374 1366 1375 Autosense 1367 1376 =========
+1 -1
block/scsi_ioctl.c
··· 277 277 if (rq->bio) 278 278 blk_queue_bounce(q, &rq->bio); 279 279 280 - rq->timeout = (hdr->timeout * HZ) / 1000; 280 + rq->timeout = jiffies_to_msecs(hdr->timeout); 281 281 if (!rq->timeout) 282 282 rq->timeout = q->sg_timeout; 283 283 if (!rq->timeout)
+6 -1
drivers/scsi/53c700.c
··· 622 622 dma_unmap_single(hostdata->dev, slot->dma_handle, sizeof(SCp->sense_buffer), DMA_FROM_DEVICE); 623 623 /* restore the old result if the request sense was 624 624 * successful */ 625 - if(result == 0) 625 + if (result == 0) 626 626 result = cmnd[7]; 627 + /* restore the original length */ 628 + SCp->cmd_len = cmnd[8]; 627 629 } else 628 630 NCR_700_unmap(hostdata, SCp, slot); 629 631 ··· 1009 1007 * of the command */ 1010 1008 cmnd[6] = NCR_700_INTERNAL_SENSE_MAGIC; 1011 1009 cmnd[7] = hostdata->status[0]; 1010 + cmnd[8] = SCp->cmd_len; 1011 + SCp->cmd_len = 6; /* command length for 1012 + * REQUEST_SENSE */ 1012 1013 slot->pCmd = dma_map_single(hostdata->dev, cmnd, MAX_COMMAND_SIZE, DMA_TO_DEVICE); 1013 1014 slot->dma_handle = dma_map_single(hostdata->dev, SCp->sense_buffer, sizeof(SCp->sense_buffer), DMA_FROM_DEVICE); 1014 1015 slot->SG[0].ins = bS_to_host(SCRIPT_MOVE_DATA_IN | sizeof(SCp->sense_buffer));
+6 -6
drivers/scsi/BusLogic.c
··· 2186 2186 2187 2187 if (BusLogic_ProbeOptions.NoProbe) 2188 2188 return -ENODEV; 2189 - BusLogic_ProbeInfoList = (struct BusLogic_ProbeInfo *) 2190 - kmalloc(BusLogic_MaxHostAdapters * sizeof(struct BusLogic_ProbeInfo), GFP_ATOMIC); 2189 + BusLogic_ProbeInfoList = 2190 + kzalloc(BusLogic_MaxHostAdapters * sizeof(struct BusLogic_ProbeInfo), GFP_KERNEL); 2191 2191 if (BusLogic_ProbeInfoList == NULL) { 2192 2192 BusLogic_Error("BusLogic: Unable to allocate Probe Info List\n", NULL); 2193 2193 return -ENOMEM; 2194 2194 } 2195 - memset(BusLogic_ProbeInfoList, 0, BusLogic_MaxHostAdapters * sizeof(struct BusLogic_ProbeInfo)); 2196 - PrototypeHostAdapter = (struct BusLogic_HostAdapter *) 2197 - kmalloc(sizeof(struct BusLogic_HostAdapter), GFP_ATOMIC); 2195 + 2196 + PrototypeHostAdapter = 2197 + kzalloc(sizeof(struct BusLogic_HostAdapter), GFP_KERNEL); 2198 2198 if (PrototypeHostAdapter == NULL) { 2199 2199 kfree(BusLogic_ProbeInfoList); 2200 2200 BusLogic_Error("BusLogic: Unable to allocate Prototype " "Host Adapter\n", NULL); 2201 2201 return -ENOMEM; 2202 2202 } 2203 - memset(PrototypeHostAdapter, 0, sizeof(struct BusLogic_HostAdapter)); 2203 + 2204 2204 #ifdef MODULE 2205 2205 if (BusLogic != NULL) 2206 2206 BusLogic_Setup(BusLogic);
+57 -2
drivers/scsi/Kconfig
··· 29 29 However, do not compile this as a module if your root file system 30 30 (the one containing the directory /) is located on a SCSI device. 31 31 32 + config SCSI_TGT 33 + tristate "SCSI target support" 34 + depends on SCSI && EXPERIMENTAL 35 + ---help--- 36 + If you want to use SCSI target mode drivers enable this option. 37 + If you choose M, the module will be called scsi_tgt. 38 + 32 39 config SCSI_NETLINK 33 40 bool 34 41 default n ··· 222 215 problems. If you say Y here your kernel will be somewhat larger, but 223 216 there should be no noticeable performance impact as long as you have 224 217 logging turned off. 218 + 219 + config SCSI_SCAN_ASYNC 220 + bool "Asynchronous SCSI scanning" 221 + depends on SCSI 222 + help 223 + The SCSI subsystem can probe for devices while the rest of the 224 + system continues booting, and even probe devices on different 225 + busses in parallel, leading to a significant speed-up. 226 + If you have built SCSI as modules, enabling this option can 227 + be a problem as the devices may not have been found by the 228 + time your system expects them to have been. You can load the 229 + scsi_wait_scan module to ensure that all scans have completed. 230 + If you build your SCSI drivers into the kernel, then everything 231 + will work fine if you say Y here. 232 + 233 + You can override this choice by specifying scsi_mod.scan="sync" 234 + or "async" on the kernel's command line. 225 235 226 236 menu "SCSI Transports" 227 237 depends on SCSI ··· 821 797 To compile this driver as a module, choose M here: the 822 798 module will be called ibmvscsic. 823 799 800 + config SCSI_IBMVSCSIS 801 + tristate "IBM Virtual SCSI Server support" 802 + depends on PPC_PSERIES && SCSI_TGT && SCSI_SRP 803 + help 804 + This is the SRP target driver for IBM pSeries virtual environments. 805 + 806 + The userspace component needed to initialize the driver and 807 + documentation can be found: 808 + 809 + http://stgt.berlios.de/ 810 + 811 + To compile this driver as a module, choose M here: the 812 + module will be called ibmvstgt. 813 + 824 814 config SCSI_INITIO 825 815 tristate "Initio 9100U(W) support" 826 816 depends on PCI && SCSI ··· 982 944 tristate "Promise SuperTrak EX Series support" 983 945 depends on PCI && SCSI 984 946 ---help--- 985 - This driver supports Promise SuperTrak EX8350/8300/16350/16300 986 - Storage controllers. 947 + This driver supports Promise SuperTrak EX series storage controllers. 948 + 949 + Promise provides Linux RAID configuration utility for these 950 + controllers. Please visit <http://www.promise.com> to download. 951 + 952 + To compile this driver as a module, choose M here: the 953 + module will be called stex. 987 954 988 955 config SCSI_SYM53C8XX_2 989 956 tristate "SYM53C8XX Version 2 SCSI support" ··· 1069 1026 config SCSI_IPR_TRACE 1070 1027 bool "enable driver internal trace" 1071 1028 depends on SCSI_IPR 1029 + default y 1072 1030 help 1073 1031 If you say Y here, the driver will trace all commands issued 1074 1032 to the adapter. Performance impact is minimal. Trace can be ··· 1078 1034 config SCSI_IPR_DUMP 1079 1035 bool "enable adapter dump support" 1080 1036 depends on SCSI_IPR 1037 + default y 1081 1038 help 1082 1039 If you say Y here, the driver will support adapter crash dump. 1083 1040 If you enable this support, the iprdump daemon can be used ··· 1778 1733 This driver is also available as a module. This module will be 1779 1734 called zfcp. If you want to compile it as a module, say M here 1780 1735 and read <file:Documentation/modules.txt>. 1736 + 1737 + config SCSI_SRP 1738 + tristate "SCSI RDMA Protocol helper library" 1739 + depends on SCSI && PCI 1740 + select SCSI_TGT 1741 + help 1742 + If you wish to use SRP target drivers, say Y. 1743 + 1744 + To compile this driver as a module, choose M here: the 1745 + module will be called libsrp. 1781 1746 1782 1747 endmenu 1783 1748
+7
drivers/scsi/Makefile
··· 21 21 subdir-$(CONFIG_PCMCIA) += pcmcia 22 22 23 23 obj-$(CONFIG_SCSI) += scsi_mod.o 24 + obj-$(CONFIG_SCSI_TGT) += scsi_tgt.o 24 25 25 26 obj-$(CONFIG_RAID_ATTRS) += raid_class.o 26 27 ··· 126 125 obj-$(CONFIG_SCSI_LASI700) += 53c700.o lasi700.o 127 126 obj-$(CONFIG_SCSI_NSP32) += nsp32.o 128 127 obj-$(CONFIG_SCSI_IPR) += ipr.o 128 + obj-$(CONFIG_SCSI_SRP) += libsrp.o 129 129 obj-$(CONFIG_SCSI_IBMVSCSI) += ibmvscsi/ 130 + obj-$(CONFIG_SCSI_IBMVSCSIS) += ibmvscsi/ 130 131 obj-$(CONFIG_SCSI_HPTIOP) += hptiop.o 131 132 obj-$(CONFIG_SCSI_STEX) += stex.o 132 133 ··· 144 141 # This goes last, so that "real" scsi devices probe earlier 145 142 obj-$(CONFIG_SCSI_DEBUG) += scsi_debug.o 146 143 144 + obj-$(CONFIG_SCSI) += scsi_wait_scan.o 145 + 147 146 scsi_mod-y += scsi.o hosts.o scsi_ioctl.o constants.o \ 148 147 scsicam.o scsi_error.o scsi_lib.o \ 149 148 scsi_scan.o scsi_sysfs.o \ ··· 153 148 scsi_mod-$(CONFIG_SCSI_NETLINK) += scsi_netlink.o 154 149 scsi_mod-$(CONFIG_SYSCTL) += scsi_sysctl.o 155 150 scsi_mod-$(CONFIG_SCSI_PROC_FS) += scsi_proc.o 151 + 152 + scsi_tgt-y += scsi_tgt_lib.o scsi_tgt_if.o 156 153 157 154 sd_mod-objs := sd.o 158 155 sr_mod-objs := sr.o sr_ioctl.o sr_vendor.o
+5
drivers/scsi/NCR53c406a.c
··· 220 220 static unsigned short ports[] = { 0x230, 0x330, 0x280, 0x290, 0x330, 0x340, 0x300, 0x310, 0x348, 0x350 }; 221 221 #define PORT_COUNT ARRAY_SIZE(ports) 222 222 223 + #ifndef MODULE 223 224 /* possible interrupt channels */ 224 225 static unsigned short intrs[] = { 10, 11, 12, 15 }; 225 226 #define INTR_COUNT ARRAY_SIZE(intrs) 227 + #endif /* !MODULE */ 226 228 227 229 /* signatures for NCR 53c406a based controllers */ 228 230 #if USE_BIOS ··· 607 605 return 0; 608 606 } 609 607 608 + #ifndef MODULE 610 609 /* called from init/main.c */ 611 610 static int __init NCR53c406a_setup(char *str) 612 611 { ··· 663 660 } 664 661 665 662 __setup("ncr53c406a=", NCR53c406a_setup); 663 + 664 + #endif /* !MODULE */ 666 665 667 666 static const char *NCR53c406a_info(struct Scsi_Host *SChost) 668 667 {
+2 -2
drivers/scsi/aacraid/aacraid.h
··· 11 11 *----------------------------------------------------------------------------*/ 12 12 13 13 #ifndef AAC_DRIVER_BUILD 14 - # define AAC_DRIVER_BUILD 2409 15 - # define AAC_DRIVER_BRANCH "-mh2" 14 + # define AAC_DRIVER_BUILD 2423 15 + # define AAC_DRIVER_BRANCH "-mh3" 16 16 #endif 17 17 #define MAXIMUM_NUM_CONTAINERS 32 18 18
+23
drivers/scsi/aacraid/commsup.c
··· 518 518 */ 519 519 unsigned long count = 36000000L; /* 3 minutes */ 520 520 while (down_trylock(&fibptr->event_wait)) { 521 + int blink; 521 522 if (--count == 0) { 522 523 spin_lock_irqsave(q->lock, qflags); 523 524 q->numpending--; ··· 530 529 "the SAFE mode kernel options (acpi, apic etc)\n"); 531 530 } 532 531 return -ETIMEDOUT; 532 + } 533 + if ((blink = aac_adapter_check_health(dev)) > 0) { 534 + if (wait == -1) { 535 + printk(KERN_ERR "aacraid: aac_fib_send: adapter blinkLED 0x%x.\n" 536 + "Usually a result of a serious unrecoverable hardware problem\n", 537 + blink); 538 + } 539 + return -EFAULT; 533 540 } 534 541 udelay(5); 535 542 } ··· 1102 1093 goto out; 1103 1094 } 1104 1095 1096 + /* 1097 + * Loop through the fibs, close the synchronous FIBS 1098 + */ 1099 + for (index = 0; index < (aac->scsi_host_ptr->can_queue + AAC_NUM_MGT_FIB); index++) { 1100 + struct fib *fib = &aac->fibs[index]; 1101 + if (!(fib->hw_fib->header.XferState & cpu_to_le32(NoResponseExpected | Async)) && 1102 + (fib->hw_fib->header.XferState & cpu_to_le32(ResponseExpected))) { 1103 + unsigned long flagv; 1104 + spin_lock_irqsave(&fib->event_lock, flagv); 1105 + up(&fib->event_wait); 1106 + spin_unlock_irqrestore(&fib->event_lock, flagv); 1107 + schedule(); 1108 + } 1109 + } 1105 1110 index = aac->cardtype; 1106 1111 1107 1112 /*
+8 -2
drivers/scsi/aha1740.c
··· 586 586 587 587 static int aha1740_probe (struct device *dev) 588 588 { 589 - int slotbase; 589 + int slotbase, rc; 590 590 unsigned int irq_level, irq_type, translation; 591 591 struct Scsi_Host *shpnt; 592 592 struct aha1740_hostdata *host; ··· 641 641 } 642 642 643 643 eisa_set_drvdata (edev, shpnt); 644 - scsi_add_host (shpnt, dev); /* XXX handle failure */ 644 + 645 + rc = scsi_add_host (shpnt, dev); 646 + if (rc) 647 + goto err_irq; 648 + 645 649 scsi_scan_host (shpnt); 646 650 return 0; 647 651 652 + err_irq: 653 + free_irq(irq_level, shpnt); 648 654 err_unmap: 649 655 dma_unmap_single (&edev->dev, host->ecb_dma_addr, 650 656 sizeof (host->ecb), DMA_BIDIRECTIONAL);
+1
drivers/scsi/aic7xxx/aic79xx_osm_pci.c
··· 62 62 /* aic7901 based controllers */ 63 63 ID(ID_AHA_29320A), 64 64 ID(ID_AHA_29320ALP), 65 + ID(ID_AHA_29320LPE), 65 66 /* aic7902 based controllers */ 66 67 ID(ID_AHA_29320), 67 68 ID(ID_AHA_29320B),
+7 -1
drivers/scsi/aic7xxx/aic79xx_pci.c
··· 109 109 { 110 110 ID_AHA_29320ALP, 111 111 ID_ALL_MASK, 112 - "Adaptec 29320ALP Ultra320 SCSI adapter", 112 + "Adaptec 29320ALP PCIx Ultra320 SCSI adapter", 113 + ahd_aic7901_setup 114 + }, 115 + { 116 + ID_AHA_29320LPE, 117 + ID_ALL_MASK, 118 + "Adaptec 29320LPE PCIe Ultra320 SCSI adapter", 113 119 ahd_aic7901_setup 114 120 }, 115 121 /* aic7901A based controllers */
+1
drivers/scsi/aic7xxx/aic79xx_pci.h
··· 51 51 #define ID_AIC7901 0x800F9005FFFF9005ull 52 52 #define ID_AHA_29320A 0x8000900500609005ull 53 53 #define ID_AHA_29320ALP 0x8017900500449005ull 54 + #define ID_AHA_29320LPE 0x8017900500459005ull 54 55 55 56 #define ID_AIC7901A 0x801E9005FFFF9005ull 56 57 #define ID_AHA_29320LP 0x8014900500449005ull
+9
drivers/scsi/aic94xx/aic94xx_init.c
··· 724 724 725 725 list_for_each_safe(pos, n, &pending) { 726 726 struct asd_ascb *ascb = list_entry(pos, struct asd_ascb, list); 727 + /* 728 + * Delete unexpired ascb timers. This may happen if we issue 729 + * a CONTROL PHY scb to an adapter and rmmod before the scb 730 + * times out. Apparently we don't wait for the CONTROL PHY 731 + * to complete, so it doesn't matter if we kill the timer. 732 + */ 733 + del_timer_sync(&ascb->timer); 734 + WARN_ON(ascb->scb->header.opcode != CONTROL_PHY); 735 + 727 736 list_del_init(pos); 728 737 ASD_DPRINTK("freeing from pending\n"); 729 738 asd_ascb_free(ascb);
+103 -17
drivers/scsi/aic94xx/aic94xx_scb.c
··· 25 25 */ 26 26 27 27 #include <linux/pci.h> 28 + #include <scsi/scsi_host.h> 28 29 29 30 #include "aic94xx.h" 30 31 #include "aic94xx_reg.h" ··· 413 412 } 414 413 } 415 414 415 + /* hard reset a phy later */ 416 + static void do_phy_reset_later(void *data) 417 + { 418 + struct sas_phy *sas_phy = data; 419 + int error; 420 + 421 + ASD_DPRINTK("%s: About to hard reset phy %d\n", __FUNCTION__, 422 + sas_phy->identify.phy_identifier); 423 + /* Reset device port */ 424 + error = sas_phy_reset(sas_phy, 1); 425 + if (error) 426 + ASD_DPRINTK("%s: Hard reset of phy %d failed (%d).\n", 427 + __FUNCTION__, sas_phy->identify.phy_identifier, error); 428 + } 429 + 430 + static void phy_reset_later(struct sas_phy *sas_phy, struct Scsi_Host *shost) 431 + { 432 + INIT_WORK(&sas_phy->reset_work, do_phy_reset_later, sas_phy); 433 + queue_work(shost->work_q, &sas_phy->reset_work); 434 + } 435 + 436 + /* start up the ABORT TASK tmf... */ 437 + static void task_kill_later(struct asd_ascb *ascb) 438 + { 439 + struct asd_ha_struct *asd_ha = ascb->ha; 440 + struct sas_ha_struct *sas_ha = &asd_ha->sas_ha; 441 + struct Scsi_Host *shost = sas_ha->core.shost; 442 + struct sas_task *task = ascb->uldd_task; 443 + 444 + INIT_WORK(&task->abort_work, (void (*)(void *))sas_task_abort, task); 445 + queue_work(shost->work_q, &task->abort_work); 446 + } 447 + 416 448 static void escb_tasklet_complete(struct asd_ascb *ascb, 417 449 struct done_list_struct *dl) 418 450 { ··· 471 437 le64_to_cpu(ascb->scb->header.next_scb), 472 438 le16_to_cpu(ascb->scb->header.index), 473 439 ascb->scb->header.opcode); 440 + } 441 + 442 + /* Catch these before we mask off the sb_opcode bits */ 443 + switch (sb_opcode) { 444 + case REQ_TASK_ABORT: { 445 + struct asd_ascb *a, *b; 446 + u16 tc_abort; 447 + 448 + tc_abort = *((u16*)(&dl->status_block[1])); 449 + tc_abort = le16_to_cpu(tc_abort); 450 + 451 + ASD_DPRINTK("%s: REQ_TASK_ABORT, reason=0x%X\n", 452 + __FUNCTION__, dl->status_block[3]); 453 + 454 + /* Find the pending task and abort it. */ 455 + list_for_each_entry_safe(a, b, &asd_ha->seq.pend_q, list) 456 + if (a->tc_index == tc_abort) { 457 + task_kill_later(a); 458 + break; 459 + } 460 + goto out; 461 + } 462 + case REQ_DEVICE_RESET: { 463 + struct Scsi_Host *shost = sas_ha->core.shost; 464 + struct sas_phy *dev_phy; 465 + struct asd_ascb *a; 466 + u16 conn_handle; 467 + 468 + conn_handle = *((u16*)(&dl->status_block[1])); 469 + conn_handle = le16_to_cpu(conn_handle); 470 + 471 + ASD_DPRINTK("%s: REQ_DEVICE_RESET, reason=0x%X\n", __FUNCTION__, 472 + dl->status_block[3]); 473 + 474 + /* Kill all pending tasks and reset the device */ 475 + dev_phy = NULL; 476 + list_for_each_entry(a, &asd_ha->seq.pend_q, list) { 477 + struct sas_task *task; 478 + struct domain_device *dev; 479 + u16 x; 480 + 481 + task = a->uldd_task; 482 + if (!task) 483 + continue; 484 + dev = task->dev; 485 + 486 + x = (unsigned long)dev->lldd_dev; 487 + if (x == conn_handle) { 488 + dev_phy = dev->port->phy; 489 + task_kill_later(a); 490 + } 491 + } 492 + 493 + /* Reset device port */ 494 + if (!dev_phy) { 495 + ASD_DPRINTK("%s: No pending commands; can't reset.\n", 496 + __FUNCTION__); 497 + goto out; 498 + } 499 + phy_reset_later(dev_phy, shost); 500 + goto out; 501 + } 502 + case SIGNAL_NCQ_ERROR: 503 + ASD_DPRINTK("%s: SIGNAL_NCQ_ERROR\n", __FUNCTION__); 504 + goto out; 505 + case CLEAR_NCQ_ERROR: 506 + ASD_DPRINTK("%s: CLEAR_NCQ_ERROR\n", __FUNCTION__); 507 + goto out; 474 508 } 475 509 476 510 sb_opcode &= ~DL_PHY_MASK; ··· 571 469 asd_deform_port(asd_ha, phy); 572 470 sas_ha->notify_port_event(sas_phy, PORTE_TIMER_EVENT); 573 471 break; 574 - case REQ_TASK_ABORT: 575 - ASD_DPRINTK("%s: phy%d: REQ_TASK_ABORT\n", __FUNCTION__, 576 - phy_id); 577 - break; 578 - case REQ_DEVICE_RESET: 579 - ASD_DPRINTK("%s: phy%d: REQ_DEVICE_RESET\n", __FUNCTION__, 580 - phy_id); 581 - break; 582 - case SIGNAL_NCQ_ERROR: 583 - ASD_DPRINTK("%s: phy%d: SIGNAL_NCQ_ERROR\n", __FUNCTION__, 584 - phy_id); 585 - break; 586 - case CLEAR_NCQ_ERROR: 587 - ASD_DPRINTK("%s: phy%d: CLEAR_NCQ_ERROR\n", __FUNCTION__, 588 - phy_id); 589 - break; 590 472 default: 591 473 ASD_DPRINTK("%s: phy%d: unknown event:0x%x\n", __FUNCTION__, 592 474 phy_id, sb_opcode); ··· 590 504 591 505 break; 592 506 } 593 - 507 + out: 594 508 asd_invalidate_edb(ascb, edb); 595 509 } 596 510
+2
drivers/scsi/fd_mcs.c
··· 294 294 static int user_fifo_count = 0; 295 295 static int user_fifo_size = 0; 296 296 297 + #ifndef MODULE 297 298 static int __init fd_mcs_setup(char *str) 298 299 { 299 300 static int done_setup = 0; ··· 312 311 } 313 312 314 313 __setup("fd_mcs=", fd_mcs_setup); 314 + #endif /* !MODULE */ 315 315 316 316 static void print_banner(struct Scsi_Host *shpnt) 317 317 {
+6 -2
drivers/scsi/hosts.c
··· 263 263 kthread_stop(shost->ehandler); 264 264 if (shost->work_q) 265 265 destroy_workqueue(shost->work_q); 266 + if (shost->uspace_req_q) { 267 + kfree(shost->uspace_req_q->queuedata); 268 + scsi_free_queue(shost->uspace_req_q); 269 + } 266 270 267 271 scsi_destroy_command_freelist(shost); 268 272 if (shost->bqt) ··· 305 301 if (!shost) 306 302 return NULL; 307 303 308 - spin_lock_init(&shost->default_lock); 309 - scsi_assign_lock(shost, &shost->default_lock); 304 + shost->host_lock = &shost->default_lock; 305 + spin_lock_init(shost->host_lock); 310 306 shost->shost_state = SHOST_CREATED; 311 307 INIT_LIST_HEAD(&shost->__devices); 312 308 INIT_LIST_HEAD(&shost->__targets);
+2
drivers/scsi/ibmvscsi/Makefile
··· 3 3 ibmvscsic-y += ibmvscsi.o 4 4 ibmvscsic-$(CONFIG_PPC_ISERIES) += iseries_vscsi.o 5 5 ibmvscsic-$(CONFIG_PPC_PSERIES) += rpa_vscsi.o 6 + 7 + obj-$(CONFIG_SCSI_IBMVSCSIS) += ibmvstgt.o
+958
drivers/scsi/ibmvscsi/ibmvstgt.c
··· 1 + /* 2 + * IBM eServer i/pSeries Virtual SCSI Target Driver 3 + * Copyright (C) 2003-2005 Dave Boutcher (boutcher@us.ibm.com) IBM Corp. 4 + * Santiago Leon (santil@us.ibm.com) IBM Corp. 5 + * Linda Xie (lxie@us.ibm.com) IBM Corp. 6 + * 7 + * Copyright (C) 2005-2006 FUJITA Tomonori <tomof@acm.org> 8 + * 9 + * This program is free software; you can redistribute it and/or modify 10 + * it under the terms of the GNU General Public License as published by 11 + * the Free Software Foundation; either version 2 of the License, or 12 + * (at your option) any later version. 13 + * 14 + * This program is distributed in the hope that it will be useful, 15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 + * GNU General Public License for more details. 18 + * 19 + * You should have received a copy of the GNU General Public License 20 + * along with this program; if not, write to the Free Software 21 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 22 + * USA 23 + */ 24 + #include <linux/interrupt.h> 25 + #include <linux/module.h> 26 + #include <scsi/scsi.h> 27 + #include <scsi/scsi_host.h> 28 + #include <scsi/scsi_tgt.h> 29 + #include <scsi/libsrp.h> 30 + #include <asm/hvcall.h> 31 + #include <asm/iommu.h> 32 + #include <asm/prom.h> 33 + #include <asm/vio.h> 34 + 35 + #include "ibmvscsi.h" 36 + 37 + #define INITIAL_SRP_LIMIT 16 38 + #define DEFAULT_MAX_SECTORS 512 39 + 40 + #define TGT_NAME "ibmvstgt" 41 + 42 + /* 43 + * Hypervisor calls. 44 + */ 45 + #define h_copy_rdma(l, sa, sb, da, db) \ 46 + plpar_hcall_norets(H_COPY_RDMA, l, sa, sb, da, db) 47 + #define h_send_crq(ua, l, h) \ 48 + plpar_hcall_norets(H_SEND_CRQ, ua, l, h) 49 + #define h_reg_crq(ua, tok, sz)\ 50 + plpar_hcall_norets(H_REG_CRQ, ua, tok, sz); 51 + #define h_free_crq(ua) \ 52 + plpar_hcall_norets(H_FREE_CRQ, ua); 53 + 54 + /* tmp - will replace with SCSI logging stuff */ 55 + #define eprintk(fmt, args...) \ 56 + do { \ 57 + printk("%s(%d) " fmt, __FUNCTION__, __LINE__, ##args); \ 58 + } while (0) 59 + /* #define dprintk eprintk */ 60 + #define dprintk(fmt, args...) 61 + 62 + struct vio_port { 63 + struct vio_dev *dma_dev; 64 + 65 + struct crq_queue crq_queue; 66 + struct work_struct crq_work; 67 + 68 + unsigned long liobn; 69 + unsigned long riobn; 70 + }; 71 + 72 + static struct workqueue_struct *vtgtd; 73 + 74 + /* 75 + * These are fixed for the system and come from the Open Firmware device tree. 76 + * We just store them here to save getting them every time. 77 + */ 78 + static char system_id[64] = ""; 79 + static char partition_name[97] = "UNKNOWN"; 80 + static unsigned int partition_number = -1; 81 + 82 + static struct vio_port *target_to_port(struct srp_target *target) 83 + { 84 + return (struct vio_port *) target->ldata; 85 + } 86 + 87 + static inline union viosrp_iu *vio_iu(struct iu_entry *iue) 88 + { 89 + return (union viosrp_iu *) (iue->sbuf->buf); 90 + } 91 + 92 + static int send_iu(struct iu_entry *iue, uint64_t length, uint8_t format) 93 + { 94 + struct srp_target *target = iue->target; 95 + struct vio_port *vport = target_to_port(target); 96 + long rc, rc1; 97 + union { 98 + struct viosrp_crq cooked; 99 + uint64_t raw[2]; 100 + } crq; 101 + 102 + /* First copy the SRP */ 103 + rc = h_copy_rdma(length, vport->liobn, iue->sbuf->dma, 104 + vport->riobn, iue->remote_token); 105 + 106 + if (rc) 107 + eprintk("Error %ld transferring data\n", rc); 108 + 109 + crq.cooked.valid = 0x80; 110 + crq.cooked.format = format; 111 + crq.cooked.reserved = 0x00; 112 + crq.cooked.timeout = 0x00; 113 + crq.cooked.IU_length = length; 114 + crq.cooked.IU_data_ptr = vio_iu(iue)->srp.rsp.tag; 115 + 116 + if (rc == 0) 117 + crq.cooked.status = 0x99; /* Just needs to be non-zero */ 118 + else 119 + crq.cooked.status = 0x00; 120 + 121 + rc1 = h_send_crq(vport->dma_dev->unit_address, crq.raw[0], crq.raw[1]); 122 + 123 + if (rc1) { 124 + eprintk("%ld sending response\n", rc1); 125 + return rc1; 126 + } 127 + 128 + return rc; 129 + } 130 + 131 + #define SRP_RSP_SENSE_DATA_LEN 18 132 + 133 + static int send_rsp(struct iu_entry *iue, struct scsi_cmnd *sc, 134 + unsigned char status, unsigned char asc) 135 + { 136 + union viosrp_iu *iu = vio_iu(iue); 137 + uint64_t tag = iu->srp.rsp.tag; 138 + 139 + /* If the linked bit is on and status is good */ 140 + if (test_bit(V_LINKED, &iue->flags) && (status == NO_SENSE)) 141 + status = 0x10; 142 + 143 + memset(iu, 0, sizeof(struct srp_rsp)); 144 + iu->srp.rsp.opcode = SRP_RSP; 145 + iu->srp.rsp.req_lim_delta = 1; 146 + iu->srp.rsp.tag = tag; 147 + 148 + if (test_bit(V_DIOVER, &iue->flags)) 149 + iu->srp.rsp.flags |= SRP_RSP_FLAG_DIOVER; 150 + 151 + iu->srp.rsp.data_in_res_cnt = 0; 152 + iu->srp.rsp.data_out_res_cnt = 0; 153 + 154 + iu->srp.rsp.flags &= ~SRP_RSP_FLAG_RSPVALID; 155 + 156 + iu->srp.rsp.resp_data_len = 0; 157 + iu->srp.rsp.status = status; 158 + if (status) { 159 + uint8_t *sense = iu->srp.rsp.data; 160 + 161 + if (sc) { 162 + iu->srp.rsp.flags |= SRP_RSP_FLAG_SNSVALID; 163 + iu->srp.rsp.sense_data_len = SCSI_SENSE_BUFFERSIZE; 164 + memcpy(sense, sc->sense_buffer, SCSI_SENSE_BUFFERSIZE); 165 + } else { 166 + iu->srp.rsp.status = SAM_STAT_CHECK_CONDITION; 167 + iu->srp.rsp.flags |= SRP_RSP_FLAG_SNSVALID; 168 + iu->srp.rsp.sense_data_len = SRP_RSP_SENSE_DATA_LEN; 169 + 170 + /* Valid bit and 'current errors' */ 171 + sense[0] = (0x1 << 7 | 0x70); 172 + /* Sense key */ 173 + sense[2] = status; 174 + /* Additional sense length */ 175 + sense[7] = 0xa; /* 10 bytes */ 176 + /* Additional sense code */ 177 + sense[12] = asc; 178 + } 179 + } 180 + 181 + send_iu(iue, sizeof(iu->srp.rsp) + SRP_RSP_SENSE_DATA_LEN, 182 + VIOSRP_SRP_FORMAT); 183 + 184 + return 0; 185 + } 186 + 187 + static void handle_cmd_queue(struct srp_target *target) 188 + { 189 + struct Scsi_Host *shost = target->shost; 190 + struct iu_entry *iue; 191 + struct srp_cmd *cmd; 192 + unsigned long flags; 193 + int err; 194 + 195 + retry: 196 + spin_lock_irqsave(&target->lock, flags); 197 + 198 + list_for_each_entry(iue, &target->cmd_queue, ilist) { 199 + if (!test_and_set_bit(V_FLYING, &iue->flags)) { 200 + spin_unlock_irqrestore(&target->lock, flags); 201 + cmd = iue->sbuf->buf; 202 + err = srp_cmd_queue(shost, cmd, iue, 0); 203 + if (err) { 204 + eprintk("cannot queue cmd %p %d\n", cmd, err); 205 + srp_iu_put(iue); 206 + } 207 + goto retry; 208 + } 209 + } 210 + 211 + spin_unlock_irqrestore(&target->lock, flags); 212 + } 213 + 214 + static int ibmvstgt_rdma(struct scsi_cmnd *sc, struct scatterlist *sg, int nsg, 215 + struct srp_direct_buf *md, int nmd, 216 + enum dma_data_direction dir, unsigned int rest) 217 + { 218 + struct iu_entry *iue = (struct iu_entry *) sc->SCp.ptr; 219 + struct srp_target *target = iue->target; 220 + struct vio_port *vport = target_to_port(target); 221 + dma_addr_t token; 222 + long err; 223 + unsigned int done = 0; 224 + int i, sidx, soff; 225 + 226 + sidx = soff = 0; 227 + token = sg_dma_address(sg + sidx); 228 + 229 + for (i = 0; i < nmd && rest; i++) { 230 + unsigned int mdone, mlen; 231 + 232 + mlen = min(rest, md[i].len); 233 + for (mdone = 0; mlen;) { 234 + int slen = min(sg_dma_len(sg + sidx) - soff, mlen); 235 + 236 + if (dir == DMA_TO_DEVICE) 237 + err = h_copy_rdma(slen, 238 + vport->riobn, 239 + md[i].va + mdone, 240 + vport->liobn, 241 + token + soff); 242 + else 243 + err = h_copy_rdma(slen, 244 + vport->liobn, 245 + token + soff, 246 + vport->riobn, 247 + md[i].va + mdone); 248 + 249 + if (err != H_SUCCESS) { 250 + eprintk("rdma error %d %d\n", dir, slen); 251 + goto out; 252 + } 253 + 254 + mlen -= slen; 255 + mdone += slen; 256 + soff += slen; 257 + done += slen; 258 + 259 + if (soff == sg_dma_len(sg + sidx)) { 260 + sidx++; 261 + soff = 0; 262 + token = sg_dma_address(sg + sidx); 263 + 264 + if (sidx > nsg) { 265 + eprintk("out of sg %p %d %d\n", 266 + iue, sidx, nsg); 267 + goto out; 268 + } 269 + } 270 + }; 271 + 272 + rest -= mlen; 273 + } 274 + out: 275 + 276 + return 0; 277 + } 278 + 279 + static int ibmvstgt_transfer_data(struct scsi_cmnd *sc, 280 + void (*done)(struct scsi_cmnd *)) 281 + { 282 + struct iu_entry *iue = (struct iu_entry *) sc->SCp.ptr; 283 + int err; 284 + 285 + err = srp_transfer_data(sc, &vio_iu(iue)->srp.cmd, ibmvstgt_rdma, 1, 1); 286 + 287 + done(sc); 288 + 289 + return err; 290 + } 291 + 292 + static int ibmvstgt_cmd_done(struct scsi_cmnd *sc, 293 + void (*done)(struct scsi_cmnd *)) 294 + { 295 + unsigned long flags; 296 + struct iu_entry *iue = (struct iu_entry *) sc->SCp.ptr; 297 + struct srp_target *target = iue->target; 298 + 299 + dprintk("%p %p %x\n", iue, target, vio_iu(iue)->srp.cmd.cdb[0]); 300 + 301 + spin_lock_irqsave(&target->lock, flags); 302 + list_del(&iue->ilist); 303 + spin_unlock_irqrestore(&target->lock, flags); 304 + 305 + if (sc->result != SAM_STAT_GOOD) { 306 + eprintk("operation failed %p %d %x\n", 307 + iue, sc->result, vio_iu(iue)->srp.cmd.cdb[0]); 308 + send_rsp(iue, sc, HARDWARE_ERROR, 0x00); 309 + } else 310 + send_rsp(iue, sc, NO_SENSE, 0x00); 311 + 312 + done(sc); 313 + srp_iu_put(iue); 314 + return 0; 315 + } 316 + 317 + int send_adapter_info(struct iu_entry *iue, 318 + dma_addr_t remote_buffer, uint16_t length) 319 + { 320 + struct srp_target *target = iue->target; 321 + struct vio_port *vport = target_to_port(target); 322 + struct Scsi_Host *shost = target->shost; 323 + dma_addr_t data_token; 324 + struct mad_adapter_info_data *info; 325 + int err; 326 + 327 + info = dma_alloc_coherent(target->dev, sizeof(*info), &data_token, 328 + GFP_KERNEL); 329 + if (!info) { 330 + eprintk("bad dma_alloc_coherent %p\n", target); 331 + return 1; 332 + } 333 + 334 + /* Get remote info */ 335 + err = h_copy_rdma(sizeof(*info), vport->riobn, remote_buffer, 336 + vport->liobn, data_token); 337 + if (err == H_SUCCESS) { 338 + dprintk("Client connect: %s (%d)\n", 339 + info->partition_name, info->partition_number); 340 + } 341 + 342 + memset(info, 0, sizeof(*info)); 343 + 344 + strcpy(info->srp_version, "16.a"); 345 + strncpy(info->partition_name, partition_name, 346 + sizeof(info->partition_name)); 347 + info->partition_number = partition_number; 348 + info->mad_version = 1; 349 + info->os_type = 2; 350 + info->port_max_txu[0] = shost->hostt->max_sectors << 9; 351 + 352 + /* Send our info to remote */ 353 + err = h_copy_rdma(sizeof(*info), vport->liobn, data_token, 354 + vport->riobn, remote_buffer); 355 + 356 + dma_free_coherent(target->dev, sizeof(*info), info, data_token); 357 + 358 + if (err != H_SUCCESS) { 359 + eprintk("Error sending adapter info %d\n", err); 360 + return 1; 361 + } 362 + 363 + return 0; 364 + } 365 + 366 + static void process_login(struct iu_entry *iue) 367 + { 368 + union viosrp_iu *iu = vio_iu(iue); 369 + struct srp_login_rsp *rsp = &iu->srp.login_rsp; 370 + uint64_t tag = iu->srp.rsp.tag; 371 + 372 + /* TODO handle case that requested size is wrong and 373 + * buffer format is wrong 374 + */ 375 + memset(iu, 0, sizeof(struct srp_login_rsp)); 376 + rsp->opcode = SRP_LOGIN_RSP; 377 + rsp->req_lim_delta = INITIAL_SRP_LIMIT; 378 + rsp->tag = tag; 379 + rsp->max_it_iu_len = sizeof(union srp_iu); 380 + rsp->max_ti_iu_len = sizeof(union srp_iu); 381 + /* direct and indirect */ 382 + rsp->buf_fmt = SRP_BUF_FORMAT_DIRECT | SRP_BUF_FORMAT_INDIRECT; 383 + 384 + send_iu(iue, sizeof(*rsp), VIOSRP_SRP_FORMAT); 385 + } 386 + 387 + static inline void queue_cmd(struct iu_entry *iue) 388 + { 389 + struct srp_target *target = iue->target; 390 + unsigned long flags; 391 + 392 + spin_lock_irqsave(&target->lock, flags); 393 + list_add_tail(&iue->ilist, &target->cmd_queue); 394 + spin_unlock_irqrestore(&target->lock, flags); 395 + } 396 + 397 + static int process_tsk_mgmt(struct iu_entry *iue) 398 + { 399 + union viosrp_iu *iu = vio_iu(iue); 400 + int fn; 401 + 402 + dprintk("%p %u\n", iue, iu->srp.tsk_mgmt.tsk_mgmt_func); 403 + 404 + switch (iu->srp.tsk_mgmt.tsk_mgmt_func) { 405 + case SRP_TSK_ABORT_TASK: 406 + fn = ABORT_TASK; 407 + break; 408 + case SRP_TSK_ABORT_TASK_SET: 409 + fn = ABORT_TASK_SET; 410 + break; 411 + case SRP_TSK_CLEAR_TASK_SET: 412 + fn = CLEAR_TASK_SET; 413 + break; 414 + case SRP_TSK_LUN_RESET: 415 + fn = LOGICAL_UNIT_RESET; 416 + break; 417 + case SRP_TSK_CLEAR_ACA: 418 + fn = CLEAR_ACA; 419 + break; 420 + default: 421 + fn = 0; 422 + } 423 + if (fn) 424 + scsi_tgt_tsk_mgmt_request(iue->target->shost, fn, 425 + iu->srp.tsk_mgmt.task_tag, 426 + (struct scsi_lun *) &iu->srp.tsk_mgmt.lun, 427 + iue); 428 + else 429 + send_rsp(iue, NULL, ILLEGAL_REQUEST, 0x20); 430 + 431 + return !fn; 432 + } 433 + 434 + static int process_mad_iu(struct iu_entry *iue) 435 + { 436 + union viosrp_iu *iu = vio_iu(iue); 437 + struct viosrp_adapter_info *info; 438 + struct viosrp_host_config *conf; 439 + 440 + switch (iu->mad.empty_iu.common.type) { 441 + case VIOSRP_EMPTY_IU_TYPE: 442 + eprintk("%s\n", "Unsupported EMPTY MAD IU"); 443 + break; 444 + case VIOSRP_ERROR_LOG_TYPE: 445 + eprintk("%s\n", "Unsupported ERROR LOG MAD IU"); 446 + iu->mad.error_log.common.status = 1; 447 + send_iu(iue, sizeof(iu->mad.error_log), VIOSRP_MAD_FORMAT); 448 + break; 449 + case VIOSRP_ADAPTER_INFO_TYPE: 450 + info = &iu->mad.adapter_info; 451 + info->common.status = send_adapter_info(iue, info->buffer, 452 + info->common.length); 453 + send_iu(iue, sizeof(*info), VIOSRP_MAD_FORMAT); 454 + break; 455 + case VIOSRP_HOST_CONFIG_TYPE: 456 + conf = &iu->mad.host_config; 457 + conf->common.status = 1; 458 + send_iu(iue, sizeof(*conf), VIOSRP_MAD_FORMAT); 459 + break; 460 + default: 461 + eprintk("Unknown type %u\n", iu->srp.rsp.opcode); 462 + } 463 + 464 + return 1; 465 + } 466 + 467 + static int process_srp_iu(struct iu_entry *iue) 468 + { 469 + union viosrp_iu *iu = vio_iu(iue); 470 + int done = 1; 471 + u8 opcode = iu->srp.rsp.opcode; 472 + 473 + switch (opcode) { 474 + case SRP_LOGIN_REQ: 475 + process_login(iue); 476 + break; 477 + case SRP_TSK_MGMT: 478 + done = process_tsk_mgmt(iue); 479 + break; 480 + case SRP_CMD: 481 + queue_cmd(iue); 482 + done = 0; 483 + break; 484 + case SRP_LOGIN_RSP: 485 + case SRP_I_LOGOUT: 486 + case SRP_T_LOGOUT: 487 + case SRP_RSP: 488 + case SRP_CRED_REQ: 489 + case SRP_CRED_RSP: 490 + case SRP_AER_REQ: 491 + case SRP_AER_RSP: 492 + eprintk("Unsupported type %u\n", opcode); 493 + break; 494 + default: 495 + eprintk("Unknown type %u\n", opcode); 496 + } 497 + 498 + return done; 499 + } 500 + 501 + static void process_iu(struct viosrp_crq *crq, struct srp_target *target) 502 + { 503 + struct vio_port *vport = target_to_port(target); 504 + struct iu_entry *iue; 505 + long err, done; 506 + 507 + iue = srp_iu_get(target); 508 + if (!iue) { 509 + eprintk("Error getting IU from pool, %p\n", target); 510 + return; 511 + } 512 + 513 + iue->remote_token = crq->IU_data_ptr; 514 + 515 + err = h_copy_rdma(crq->IU_length, vport->riobn, 516 + iue->remote_token, vport->liobn, iue->sbuf->dma); 517 + 518 + if (err != H_SUCCESS) { 519 + eprintk("%ld transferring data error %p\n", err, iue); 520 + done = 1; 521 + goto out; 522 + } 523 + 524 + if (crq->format == VIOSRP_MAD_FORMAT) 525 + done = process_mad_iu(iue); 526 + else 527 + done = process_srp_iu(iue); 528 + out: 529 + if (done) 530 + srp_iu_put(iue); 531 + } 532 + 533 + static irqreturn_t ibmvstgt_interrupt(int irq, void *data) 534 + { 535 + struct srp_target *target = (struct srp_target *) data; 536 + struct vio_port *vport = target_to_port(target); 537 + 538 + vio_disable_interrupts(vport->dma_dev); 539 + queue_work(vtgtd, &vport->crq_work); 540 + 541 + return IRQ_HANDLED; 542 + } 543 + 544 + static int crq_queue_create(struct crq_queue *queue, struct srp_target *target) 545 + { 546 + int err; 547 + struct vio_port *vport = target_to_port(target); 548 + 549 + queue->msgs = (struct viosrp_crq *) get_zeroed_page(GFP_KERNEL); 550 + if (!queue->msgs) 551 + goto malloc_failed; 552 + queue->size = PAGE_SIZE / sizeof(*queue->msgs); 553 + 554 + queue->msg_token = dma_map_single(target->dev, queue->msgs, 555 + queue->size * sizeof(*queue->msgs), 556 + DMA_BIDIRECTIONAL); 557 + 558 + if (dma_mapping_error(queue->msg_token)) 559 + goto map_failed; 560 + 561 + err = h_reg_crq(vport->dma_dev->unit_address, queue->msg_token, 562 + PAGE_SIZE); 563 + 564 + /* If the adapter was left active for some reason (like kexec) 565 + * try freeing and re-registering 566 + */ 567 + if (err == H_RESOURCE) { 568 + do { 569 + err = h_free_crq(vport->dma_dev->unit_address); 570 + } while (err == H_BUSY || H_IS_LONG_BUSY(err)); 571 + 572 + err = h_reg_crq(vport->dma_dev->unit_address, queue->msg_token, 573 + PAGE_SIZE); 574 + } 575 + 576 + if (err != H_SUCCESS && err != 2) { 577 + eprintk("Error 0x%x opening virtual adapter\n", err); 578 + goto reg_crq_failed; 579 + } 580 + 581 + err = request_irq(vport->dma_dev->irq, &ibmvstgt_interrupt, 582 + SA_INTERRUPT, "ibmvstgt", target); 583 + if (err) 584 + goto req_irq_failed; 585 + 586 + vio_enable_interrupts(vport->dma_dev); 587 + 588 + h_send_crq(vport->dma_dev->unit_address, 0xC001000000000000, 0); 589 + 590 + queue->cur = 0; 591 + spin_lock_init(&queue->lock); 592 + 593 + return 0; 594 + 595 + req_irq_failed: 596 + do { 597 + err = h_free_crq(vport->dma_dev->unit_address); 598 + } while (err == H_BUSY || H_IS_LONG_BUSY(err)); 599 + 600 + reg_crq_failed: 601 + dma_unmap_single(target->dev, queue->msg_token, 602 + queue->size * sizeof(*queue->msgs), DMA_BIDIRECTIONAL); 603 + map_failed: 604 + free_page((unsigned long) queue->msgs); 605 + 606 + malloc_failed: 607 + return -ENOMEM; 608 + } 609 + 610 + static void crq_queue_destroy(struct srp_target *target) 611 + { 612 + struct vio_port *vport = target_to_port(target); 613 + struct crq_queue *queue = &vport->crq_queue; 614 + int err; 615 + 616 + free_irq(vport->dma_dev->irq, target); 617 + do { 618 + err = h_free_crq(vport->dma_dev->unit_address); 619 + } while (err == H_BUSY || H_IS_LONG_BUSY(err)); 620 + 621 + dma_unmap_single(target->dev, queue->msg_token, 622 + queue->size * sizeof(*queue->msgs), DMA_BIDIRECTIONAL); 623 + 624 + free_page((unsigned long) queue->msgs); 625 + } 626 + 627 + static void process_crq(struct viosrp_crq *crq, struct srp_target *target) 628 + { 629 + struct vio_port *vport = target_to_port(target); 630 + dprintk("%x %x\n", crq->valid, crq->format); 631 + 632 + switch (crq->valid) { 633 + case 0xC0: 634 + /* initialization */ 635 + switch (crq->format) { 636 + case 0x01: 637 + h_send_crq(vport->dma_dev->unit_address, 638 + 0xC002000000000000, 0); 639 + break; 640 + case 0x02: 641 + break; 642 + default: 643 + eprintk("Unknown format %u\n", crq->format); 644 + } 645 + break; 646 + case 0xFF: 647 + /* transport event */ 648 + break; 649 + case 0x80: 650 + /* real payload */ 651 + switch (crq->format) { 652 + case VIOSRP_SRP_FORMAT: 653 + case VIOSRP_MAD_FORMAT: 654 + process_iu(crq, target); 655 + break; 656 + case VIOSRP_OS400_FORMAT: 657 + case VIOSRP_AIX_FORMAT: 658 + case VIOSRP_LINUX_FORMAT: 659 + case VIOSRP_INLINE_FORMAT: 660 + eprintk("Unsupported format %u\n", crq->format); 661 + break; 662 + default: 663 + eprintk("Unknown format %u\n", crq->format); 664 + } 665 + break; 666 + default: 667 + eprintk("unknown message type 0x%02x!?\n", crq->valid); 668 + } 669 + } 670 + 671 + static inline struct viosrp_crq *next_crq(struct crq_queue *queue) 672 + { 673 + struct viosrp_crq *crq; 674 + unsigned long flags; 675 + 676 + spin_lock_irqsave(&queue->lock, flags); 677 + crq = &queue->msgs[queue->cur]; 678 + if (crq->valid & 0x80) { 679 + if (++queue->cur == queue->size) 680 + queue->cur = 0; 681 + } else 682 + crq = NULL; 683 + spin_unlock_irqrestore(&queue->lock, flags); 684 + 685 + return crq; 686 + } 687 + 688 + static void handle_crq(void *data) 689 + { 690 + struct srp_target *target = (struct srp_target *) data; 691 + struct vio_port *vport = target_to_port(target); 692 + struct viosrp_crq *crq; 693 + int done = 0; 694 + 695 + while (!done) { 696 + while ((crq = next_crq(&vport->crq_queue)) != NULL) { 697 + process_crq(crq, target); 698 + crq->valid = 0x00; 699 + } 700 + 701 + vio_enable_interrupts(vport->dma_dev); 702 + 703 + crq = next_crq(&vport->crq_queue); 704 + if (crq) { 705 + vio_disable_interrupts(vport->dma_dev); 706 + process_crq(crq, target); 707 + crq->valid = 0x00; 708 + } else 709 + done = 1; 710 + } 711 + 712 + handle_cmd_queue(target); 713 + } 714 + 715 + 716 + static int ibmvstgt_eh_abort_handler(struct scsi_cmnd *sc) 717 + { 718 + unsigned long flags; 719 + struct iu_entry *iue = (struct iu_entry *) sc->SCp.ptr; 720 + struct srp_target *target = iue->target; 721 + 722 + dprintk("%p %p %x\n", iue, target, vio_iu(iue)->srp.cmd.cdb[0]); 723 + 724 + spin_lock_irqsave(&target->lock, flags); 725 + list_del(&iue->ilist); 726 + spin_unlock_irqrestore(&target->lock, flags); 727 + 728 + srp_iu_put(iue); 729 + 730 + return 0; 731 + } 732 + 733 + static int ibmvstgt_tsk_mgmt_response(u64 mid, int result) 734 + { 735 + struct iu_entry *iue = (struct iu_entry *) ((void *) mid); 736 + union viosrp_iu *iu = vio_iu(iue); 737 + unsigned char status, asc; 738 + 739 + eprintk("%p %d\n", iue, result); 740 + status = NO_SENSE; 741 + asc = 0; 742 + 743 + switch (iu->srp.tsk_mgmt.tsk_mgmt_func) { 744 + case SRP_TSK_ABORT_TASK: 745 + asc = 0x14; 746 + if (result) 747 + status = ABORTED_COMMAND; 748 + break; 749 + default: 750 + break; 751 + } 752 + 753 + send_rsp(iue, NULL, status, asc); 754 + srp_iu_put(iue); 755 + 756 + return 0; 757 + } 758 + 759 + static ssize_t system_id_show(struct class_device *cdev, char *buf) 760 + { 761 + return snprintf(buf, PAGE_SIZE, "%s\n", system_id); 762 + } 763 + 764 + static ssize_t partition_number_show(struct class_device *cdev, char *buf) 765 + { 766 + return snprintf(buf, PAGE_SIZE, "%x\n", partition_number); 767 + } 768 + 769 + static ssize_t unit_address_show(struct class_device *cdev, char *buf) 770 + { 771 + struct Scsi_Host *shost = class_to_shost(cdev); 772 + struct srp_target *target = host_to_srp_target(shost); 773 + struct vio_port *vport = target_to_port(target); 774 + return snprintf(buf, PAGE_SIZE, "%x\n", vport->dma_dev->unit_address); 775 + } 776 + 777 + static CLASS_DEVICE_ATTR(system_id, S_IRUGO, system_id_show, NULL); 778 + static CLASS_DEVICE_ATTR(partition_number, S_IRUGO, partition_number_show, NULL); 779 + static CLASS_DEVICE_ATTR(unit_address, S_IRUGO, unit_address_show, NULL); 780 + 781 + static struct class_device_attribute *ibmvstgt_attrs[] = { 782 + &class_device_attr_system_id, 783 + &class_device_attr_partition_number, 784 + &class_device_attr_unit_address, 785 + NULL, 786 + }; 787 + 788 + static struct scsi_host_template ibmvstgt_sht = { 789 + .name = TGT_NAME, 790 + .module = THIS_MODULE, 791 + .can_queue = INITIAL_SRP_LIMIT, 792 + .sg_tablesize = SG_ALL, 793 + .use_clustering = DISABLE_CLUSTERING, 794 + .max_sectors = DEFAULT_MAX_SECTORS, 795 + .transfer_response = ibmvstgt_cmd_done, 796 + .transfer_data = ibmvstgt_transfer_data, 797 + .eh_abort_handler = ibmvstgt_eh_abort_handler, 798 + .tsk_mgmt_response = ibmvstgt_tsk_mgmt_response, 799 + .shost_attrs = ibmvstgt_attrs, 800 + .proc_name = TGT_NAME, 801 + }; 802 + 803 + static int ibmvstgt_probe(struct vio_dev *dev, const struct vio_device_id *id) 804 + { 805 + struct Scsi_Host *shost; 806 + struct srp_target *target; 807 + struct vio_port *vport; 808 + unsigned int *dma, dma_size; 809 + int err = -ENOMEM; 810 + 811 + vport = kzalloc(sizeof(struct vio_port), GFP_KERNEL); 812 + if (!vport) 813 + return err; 814 + shost = scsi_host_alloc(&ibmvstgt_sht, sizeof(struct srp_target)); 815 + if (!shost) 816 + goto free_vport; 817 + err = scsi_tgt_alloc_queue(shost); 818 + if (err) 819 + goto put_host; 820 + 821 + target = host_to_srp_target(shost); 822 + target->shost = shost; 823 + vport->dma_dev = dev; 824 + target->ldata = vport; 825 + err = srp_target_alloc(target, &dev->dev, INITIAL_SRP_LIMIT, 826 + SRP_MAX_IU_LEN); 827 + if (err) 828 + goto put_host; 829 + 830 + dma = (unsigned int *) vio_get_attribute(dev, "ibm,my-dma-window", 831 + &dma_size); 832 + if (!dma || dma_size != 40) { 833 + eprintk("Couldn't get window property %d\n", dma_size); 834 + err = -EIO; 835 + goto free_srp_target; 836 + } 837 + vport->liobn = dma[0]; 838 + vport->riobn = dma[5]; 839 + 840 + INIT_WORK(&vport->crq_work, handle_crq, target); 841 + 842 + err = crq_queue_create(&vport->crq_queue, target); 843 + if (err) 844 + goto free_srp_target; 845 + 846 + err = scsi_add_host(shost, target->dev); 847 + if (err) 848 + goto destroy_queue; 849 + return 0; 850 + 851 + destroy_queue: 852 + crq_queue_destroy(target); 853 + free_srp_target: 854 + srp_target_free(target); 855 + put_host: 856 + scsi_host_put(shost); 857 + free_vport: 858 + kfree(vport); 859 + return err; 860 + } 861 + 862 + static int ibmvstgt_remove(struct vio_dev *dev) 863 + { 864 + struct srp_target *target = (struct srp_target *) dev->dev.driver_data; 865 + struct Scsi_Host *shost = target->shost; 866 + struct vio_port *vport = target->ldata; 867 + 868 + crq_queue_destroy(target); 869 + scsi_remove_host(shost); 870 + scsi_tgt_free_queue(shost); 871 + srp_target_free(target); 872 + kfree(vport); 873 + scsi_host_put(shost); 874 + return 0; 875 + } 876 + 877 + static struct vio_device_id ibmvstgt_device_table[] __devinitdata = { 878 + {"v-scsi-host", "IBM,v-scsi-host"}, 879 + {"",""} 880 + }; 881 + 882 + MODULE_DEVICE_TABLE(vio, ibmvstgt_device_table); 883 + 884 + static struct vio_driver ibmvstgt_driver = { 885 + .id_table = ibmvstgt_device_table, 886 + .probe = ibmvstgt_probe, 887 + .remove = ibmvstgt_remove, 888 + .driver = { 889 + .name = "ibmvscsis", 890 + .owner = THIS_MODULE, 891 + } 892 + }; 893 + 894 + static int get_system_info(void) 895 + { 896 + struct device_node *rootdn; 897 + const char *id, *model, *name; 898 + unsigned int *num; 899 + 900 + rootdn = find_path_device("/"); 901 + if (!rootdn) 902 + return -ENOENT; 903 + 904 + model = get_property(rootdn, "model", NULL); 905 + id = get_property(rootdn, "system-id", NULL); 906 + if (model && id) 907 + snprintf(system_id, sizeof(system_id), "%s-%s", model, id); 908 + 909 + name = get_property(rootdn, "ibm,partition-name", NULL); 910 + if (name) 911 + strncpy(partition_name, name, sizeof(partition_name)); 912 + 913 + num = (unsigned int *) get_property(rootdn, "ibm,partition-no", NULL); 914 + if (num) 915 + partition_number = *num; 916 + 917 + return 0; 918 + } 919 + 920 + static int ibmvstgt_init(void) 921 + { 922 + int err = -ENOMEM; 923 + 924 + printk("IBM eServer i/pSeries Virtual SCSI Target Driver\n"); 925 + 926 + vtgtd = create_workqueue("ibmvtgtd"); 927 + if (!vtgtd) 928 + return err; 929 + 930 + err = get_system_info(); 931 + if (err) 932 + goto destroy_wq; 933 + 934 + err = vio_register_driver(&ibmvstgt_driver); 935 + if (err) 936 + goto destroy_wq; 937 + 938 + return 0; 939 + 940 + destroy_wq: 941 + destroy_workqueue(vtgtd); 942 + return err; 943 + } 944 + 945 + static void ibmvstgt_exit(void) 946 + { 947 + printk("Unregister IBM virtual SCSI driver\n"); 948 + 949 + destroy_workqueue(vtgtd); 950 + vio_unregister_driver(&ibmvstgt_driver); 951 + } 952 + 953 + MODULE_DESCRIPTION("IBM Virtual SCSI Target"); 954 + MODULE_AUTHOR("Santiago Leon"); 955 + MODULE_LICENSE("GPL"); 956 + 957 + module_init(ibmvstgt_init); 958 + module_exit(ibmvstgt_exit);
+1 -1
drivers/scsi/initio.c
··· 170 170 static void i91uSCBPost(BYTE * pHcb, BYTE * pScb); 171 171 172 172 /* PCI Devices supported by this driver */ 173 - static struct pci_device_id i91u_pci_devices[] __devinitdata = { 173 + static struct pci_device_id i91u_pci_devices[] = { 174 174 { PCI_VENDOR_ID_INIT, I950_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 175 175 { PCI_VENDOR_ID_INIT, I940_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 176 176 { PCI_VENDOR_ID_INIT, I935_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+261 -52
drivers/scsi/ipr.c
··· 79 79 #include <scsi/scsi_tcq.h> 80 80 #include <scsi/scsi_eh.h> 81 81 #include <scsi/scsi_cmnd.h> 82 - #include <scsi/scsi_transport.h> 83 82 #include "ipr.h" 84 83 85 84 /* ··· 97 98 98 99 /* This table describes the differences between DMA controller chips */ 99 100 static const struct ipr_chip_cfg_t ipr_chip_cfg[] = { 100 - { /* Gemstone, Citrine, and Obsidian */ 101 + { /* Gemstone, Citrine, Obsidian, and Obsidian-E */ 101 102 .mailbox = 0x0042C, 102 103 .cache_line_size = 0x20, 103 104 { ··· 134 135 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CITRINE, &ipr_chip_cfg[0] }, 135 136 { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_OBSIDIAN, &ipr_chip_cfg[0] }, 136 137 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN, &ipr_chip_cfg[0] }, 138 + { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN_E, &ipr_chip_cfg[0] }, 137 139 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_SNIPE, &ipr_chip_cfg[1] }, 138 140 { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_SCAMP, &ipr_chip_cfg[1] } 139 141 }; ··· 1249 1249 1250 1250 /** 1251 1251 * ipr_log_hex_data - Log additional hex IOA error data. 1252 + * @ioa_cfg: ioa config struct 1252 1253 * @data: IOA error data 1253 1254 * @len: data length 1254 1255 * 1255 1256 * Return value: 1256 1257 * none 1257 1258 **/ 1258 - static void ipr_log_hex_data(u32 *data, int len) 1259 + static void ipr_log_hex_data(struct ipr_ioa_cfg *ioa_cfg, u32 *data, int len) 1259 1260 { 1260 1261 int i; 1261 1262 1262 1263 if (len == 0) 1263 1264 return; 1265 + 1266 + if (ioa_cfg->log_level <= IPR_DEFAULT_LOG_LEVEL) 1267 + len = min_t(int, len, IPR_DEFAULT_MAX_ERROR_DUMP); 1264 1268 1265 1269 for (i = 0; i < len / 4; i += 4) { 1266 1270 ipr_err("%08X: %08X %08X %08X %08X\n", i*4, ··· 1294 1290 ipr_err("%s\n", error->failure_reason); 1295 1291 ipr_err("Remote Adapter VPD:\n"); 1296 1292 ipr_log_ext_vpd(&error->vpd); 1297 - ipr_log_hex_data(error->data, 1293 + ipr_log_hex_data(ioa_cfg, error->data, 1298 1294 be32_to_cpu(hostrcb->hcam.length) - 1299 1295 (offsetof(struct ipr_hostrcb_error, u) + 1300 1296 offsetof(struct ipr_hostrcb_type_17_error, data))); ··· 1319 1315 ipr_err("%s\n", error->failure_reason); 1320 1316 ipr_err("Remote Adapter VPD:\n"); 1321 1317 ipr_log_vpd(&error->vpd); 1322 - ipr_log_hex_data(error->data, 1318 + ipr_log_hex_data(ioa_cfg, error->data, 1323 1319 be32_to_cpu(hostrcb->hcam.length) - 1324 1320 (offsetof(struct ipr_hostrcb_error, u) + 1325 1321 offsetof(struct ipr_hostrcb_type_07_error, data))); 1322 + } 1323 + 1324 + static const struct { 1325 + u8 active; 1326 + char *desc; 1327 + } path_active_desc[] = { 1328 + { IPR_PATH_NO_INFO, "Path" }, 1329 + { IPR_PATH_ACTIVE, "Active path" }, 1330 + { IPR_PATH_NOT_ACTIVE, "Inactive path" } 1331 + }; 1332 + 1333 + static const struct { 1334 + u8 state; 1335 + char *desc; 1336 + } path_state_desc[] = { 1337 + { IPR_PATH_STATE_NO_INFO, "has no path state information available" }, 1338 + { IPR_PATH_HEALTHY, "is healthy" }, 1339 + { IPR_PATH_DEGRADED, "is degraded" }, 1340 + { IPR_PATH_FAILED, "is failed" } 1341 + }; 1342 + 1343 + /** 1344 + * ipr_log_fabric_path - Log a fabric path error 1345 + * @hostrcb: hostrcb struct 1346 + * @fabric: fabric descriptor 1347 + * 1348 + * Return value: 1349 + * none 1350 + **/ 1351 + static void ipr_log_fabric_path(struct ipr_hostrcb *hostrcb, 1352 + struct ipr_hostrcb_fabric_desc *fabric) 1353 + { 1354 + int i, j; 1355 + u8 path_state = fabric->path_state; 1356 + u8 active = path_state & IPR_PATH_ACTIVE_MASK; 1357 + u8 state = path_state & IPR_PATH_STATE_MASK; 1358 + 1359 + for (i = 0; i < ARRAY_SIZE(path_active_desc); i++) { 1360 + if (path_active_desc[i].active != active) 1361 + continue; 1362 + 1363 + for (j = 0; j < ARRAY_SIZE(path_state_desc); j++) { 1364 + if (path_state_desc[j].state != state) 1365 + continue; 1366 + 1367 + if (fabric->cascaded_expander == 0xff && fabric->phy == 0xff) { 1368 + ipr_hcam_err(hostrcb, "%s %s: IOA Port=%d\n", 1369 + path_active_desc[i].desc, path_state_desc[j].desc, 1370 + fabric->ioa_port); 1371 + } else if (fabric->cascaded_expander == 0xff) { 1372 + ipr_hcam_err(hostrcb, "%s %s: IOA Port=%d, Phy=%d\n", 1373 + path_active_desc[i].desc, path_state_desc[j].desc, 1374 + fabric->ioa_port, fabric->phy); 1375 + } else if (fabric->phy == 0xff) { 1376 + ipr_hcam_err(hostrcb, "%s %s: IOA Port=%d, Cascade=%d\n", 1377 + path_active_desc[i].desc, path_state_desc[j].desc, 1378 + fabric->ioa_port, fabric->cascaded_expander); 1379 + } else { 1380 + ipr_hcam_err(hostrcb, "%s %s: IOA Port=%d, Cascade=%d, Phy=%d\n", 1381 + path_active_desc[i].desc, path_state_desc[j].desc, 1382 + fabric->ioa_port, fabric->cascaded_expander, fabric->phy); 1383 + } 1384 + return; 1385 + } 1386 + } 1387 + 1388 + ipr_err("Path state=%02X IOA Port=%d Cascade=%d Phy=%d\n", path_state, 1389 + fabric->ioa_port, fabric->cascaded_expander, fabric->phy); 1390 + } 1391 + 1392 + static const struct { 1393 + u8 type; 1394 + char *desc; 1395 + } path_type_desc[] = { 1396 + { IPR_PATH_CFG_IOA_PORT, "IOA port" }, 1397 + { IPR_PATH_CFG_EXP_PORT, "Expander port" }, 1398 + { IPR_PATH_CFG_DEVICE_PORT, "Device port" }, 1399 + { IPR_PATH_CFG_DEVICE_LUN, "Device LUN" } 1400 + }; 1401 + 1402 + static const struct { 1403 + u8 status; 1404 + char *desc; 1405 + } path_status_desc[] = { 1406 + { IPR_PATH_CFG_NO_PROB, "Functional" }, 1407 + { IPR_PATH_CFG_DEGRADED, "Degraded" }, 1408 + { IPR_PATH_CFG_FAILED, "Failed" }, 1409 + { IPR_PATH_CFG_SUSPECT, "Suspect" }, 1410 + { IPR_PATH_NOT_DETECTED, "Missing" }, 1411 + { IPR_PATH_INCORRECT_CONN, "Incorrectly connected" } 1412 + }; 1413 + 1414 + static const char *link_rate[] = { 1415 + "unknown", 1416 + "disabled", 1417 + "phy reset problem", 1418 + "spinup hold", 1419 + "port selector", 1420 + "unknown", 1421 + "unknown", 1422 + "unknown", 1423 + "1.5Gbps", 1424 + "3.0Gbps", 1425 + "unknown", 1426 + "unknown", 1427 + "unknown", 1428 + "unknown", 1429 + "unknown", 1430 + "unknown" 1431 + }; 1432 + 1433 + /** 1434 + * ipr_log_path_elem - Log a fabric path element. 1435 + * @hostrcb: hostrcb struct 1436 + * @cfg: fabric path element struct 1437 + * 1438 + * Return value: 1439 + * none 1440 + **/ 1441 + static void ipr_log_path_elem(struct ipr_hostrcb *hostrcb, 1442 + struct ipr_hostrcb_config_element *cfg) 1443 + { 1444 + int i, j; 1445 + u8 type = cfg->type_status & IPR_PATH_CFG_TYPE_MASK; 1446 + u8 status = cfg->type_status & IPR_PATH_CFG_STATUS_MASK; 1447 + 1448 + if (type == IPR_PATH_CFG_NOT_EXIST) 1449 + return; 1450 + 1451 + for (i = 0; i < ARRAY_SIZE(path_type_desc); i++) { 1452 + if (path_type_desc[i].type != type) 1453 + continue; 1454 + 1455 + for (j = 0; j < ARRAY_SIZE(path_status_desc); j++) { 1456 + if (path_status_desc[j].status != status) 1457 + continue; 1458 + 1459 + if (type == IPR_PATH_CFG_IOA_PORT) { 1460 + ipr_hcam_err(hostrcb, "%s %s: Phy=%d, Link rate=%s, WWN=%08X%08X\n", 1461 + path_status_desc[j].desc, path_type_desc[i].desc, 1462 + cfg->phy, link_rate[cfg->link_rate & IPR_PHY_LINK_RATE_MASK], 1463 + be32_to_cpu(cfg->wwid[0]), be32_to_cpu(cfg->wwid[1])); 1464 + } else { 1465 + if (cfg->cascaded_expander == 0xff && cfg->phy == 0xff) { 1466 + ipr_hcam_err(hostrcb, "%s %s: Link rate=%s, WWN=%08X%08X\n", 1467 + path_status_desc[j].desc, path_type_desc[i].desc, 1468 + link_rate[cfg->link_rate & IPR_PHY_LINK_RATE_MASK], 1469 + be32_to_cpu(cfg->wwid[0]), be32_to_cpu(cfg->wwid[1])); 1470 + } else if (cfg->cascaded_expander == 0xff) { 1471 + ipr_hcam_err(hostrcb, "%s %s: Phy=%d, Link rate=%s, " 1472 + "WWN=%08X%08X\n", path_status_desc[j].desc, 1473 + path_type_desc[i].desc, cfg->phy, 1474 + link_rate[cfg->link_rate & IPR_PHY_LINK_RATE_MASK], 1475 + be32_to_cpu(cfg->wwid[0]), be32_to_cpu(cfg->wwid[1])); 1476 + } else if (cfg->phy == 0xff) { 1477 + ipr_hcam_err(hostrcb, "%s %s: Cascade=%d, Link rate=%s, " 1478 + "WWN=%08X%08X\n", path_status_desc[j].desc, 1479 + path_type_desc[i].desc, cfg->cascaded_expander, 1480 + link_rate[cfg->link_rate & IPR_PHY_LINK_RATE_MASK], 1481 + be32_to_cpu(cfg->wwid[0]), be32_to_cpu(cfg->wwid[1])); 1482 + } else { 1483 + ipr_hcam_err(hostrcb, "%s %s: Cascade=%d, Phy=%d, Link rate=%s " 1484 + "WWN=%08X%08X\n", path_status_desc[j].desc, 1485 + path_type_desc[i].desc, cfg->cascaded_expander, cfg->phy, 1486 + link_rate[cfg->link_rate & IPR_PHY_LINK_RATE_MASK], 1487 + be32_to_cpu(cfg->wwid[0]), be32_to_cpu(cfg->wwid[1])); 1488 + } 1489 + } 1490 + return; 1491 + } 1492 + } 1493 + 1494 + ipr_hcam_err(hostrcb, "Path element=%02X: Cascade=%d Phy=%d Link rate=%s " 1495 + "WWN=%08X%08X\n", cfg->type_status, cfg->cascaded_expander, cfg->phy, 1496 + link_rate[cfg->link_rate & IPR_PHY_LINK_RATE_MASK], 1497 + be32_to_cpu(cfg->wwid[0]), be32_to_cpu(cfg->wwid[1])); 1498 + } 1499 + 1500 + /** 1501 + * ipr_log_fabric_error - Log a fabric error. 1502 + * @ioa_cfg: ioa config struct 1503 + * @hostrcb: hostrcb struct 1504 + * 1505 + * Return value: 1506 + * none 1507 + **/ 1508 + static void ipr_log_fabric_error(struct ipr_ioa_cfg *ioa_cfg, 1509 + struct ipr_hostrcb *hostrcb) 1510 + { 1511 + struct ipr_hostrcb_type_20_error *error; 1512 + struct ipr_hostrcb_fabric_desc *fabric; 1513 + struct ipr_hostrcb_config_element *cfg; 1514 + int i, add_len; 1515 + 1516 + error = &hostrcb->hcam.u.error.u.type_20_error; 1517 + error->failure_reason[sizeof(error->failure_reason) - 1] = '\0'; 1518 + ipr_hcam_err(hostrcb, "%s\n", error->failure_reason); 1519 + 1520 + add_len = be32_to_cpu(hostrcb->hcam.length) - 1521 + (offsetof(struct ipr_hostrcb_error, u) + 1522 + offsetof(struct ipr_hostrcb_type_20_error, desc)); 1523 + 1524 + for (i = 0, fabric = error->desc; i < error->num_entries; i++) { 1525 + ipr_log_fabric_path(hostrcb, fabric); 1526 + for_each_fabric_cfg(fabric, cfg) 1527 + ipr_log_path_elem(hostrcb, cfg); 1528 + 1529 + add_len -= be16_to_cpu(fabric->length); 1530 + fabric = (struct ipr_hostrcb_fabric_desc *) 1531 + ((unsigned long)fabric + be16_to_cpu(fabric->length)); 1532 + } 1533 + 1534 + ipr_log_hex_data(ioa_cfg, (u32 *)fabric, add_len); 1326 1535 } 1327 1536 1328 1537 /** ··· 1549 1332 static void ipr_log_generic_error(struct ipr_ioa_cfg *ioa_cfg, 1550 1333 struct ipr_hostrcb *hostrcb) 1551 1334 { 1552 - ipr_log_hex_data(hostrcb->hcam.u.raw.data, 1335 + ipr_log_hex_data(ioa_cfg, hostrcb->hcam.u.raw.data, 1553 1336 be32_to_cpu(hostrcb->hcam.length)); 1554 1337 } 1555 1338 ··· 1611 1394 if (!ipr_error_table[error_index].log_hcam) 1612 1395 return; 1613 1396 1614 - if (ipr_is_device(&hostrcb->hcam.u.error.failing_dev_res_addr)) { 1615 - ipr_ra_err(ioa_cfg, hostrcb->hcam.u.error.failing_dev_res_addr, 1616 - "%s\n", ipr_error_table[error_index].error); 1617 - } else { 1618 - dev_err(&ioa_cfg->pdev->dev, "%s\n", 1619 - ipr_error_table[error_index].error); 1620 - } 1397 + ipr_hcam_err(hostrcb, "%s\n", ipr_error_table[error_index].error); 1621 1398 1622 1399 /* Set indication we have logged an error */ 1623 1400 ioa_cfg->errors_logged++; ··· 1647 1436 break; 1648 1437 case IPR_HOST_RCB_OVERLAY_ID_17: 1649 1438 ipr_log_enhanced_dual_ioa_error(ioa_cfg, hostrcb); 1439 + break; 1440 + case IPR_HOST_RCB_OVERLAY_ID_20: 1441 + ipr_log_fabric_error(ioa_cfg, hostrcb); 1650 1442 break; 1651 1443 case IPR_HOST_RCB_OVERLAY_ID_1: 1652 1444 case IPR_HOST_RCB_OVERLAY_ID_DEFAULT: ··· 3183 2969 struct ipr_dump *dump; 3184 2970 unsigned long lock_flags = 0; 3185 2971 3186 - ENTER; 3187 2972 dump = kzalloc(sizeof(struct ipr_dump), GFP_KERNEL); 3188 2973 3189 2974 if (!dump) { ··· 3209 2996 } 3210 2997 spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); 3211 2998 3212 - LEAVE; 3213 2999 return 0; 3214 3000 } 3215 3001 ··· 3785 3573 3786 3574 ENTER; 3787 3575 spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags); 3576 + while(ioa_cfg->in_reset_reload) { 3577 + spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); 3578 + wait_event(ioa_cfg->reset_wait_q, !ioa_cfg->in_reset_reload); 3579 + spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags); 3580 + } 3581 + 3788 3582 res = sata_port->res; 3789 3583 if (res) { 3790 3584 rc = ipr_device_reset(ioa_cfg, res); ··· 3854 3636 if (ipr_cmd->ioarcb.res_handle == res->cfgte.res_handle) { 3855 3637 if (ipr_cmd->scsi_cmd) 3856 3638 ipr_cmd->done = ipr_scsi_eh_done; 3639 + if (ipr_cmd->qc && !(ipr_cmd->qc->flags & ATA_QCFLAG_FAILED)) { 3640 + ipr_cmd->qc->err_mask |= AC_ERR_TIMEOUT; 3641 + ipr_cmd->qc->flags |= ATA_QCFLAG_FAILED; 3642 + } 3857 3643 } 3858 3644 } 3859 3645 ··· 3992 3770 */ 3993 3771 if (ioa_cfg->in_reset_reload || ioa_cfg->ioa_is_dead) 3994 3772 return FAILED; 3995 - if (!res || (!ipr_is_gscsi(res) && !ipr_is_vset_device(res))) 3773 + if (!res || !ipr_is_gscsi(res)) 3996 3774 return FAILED; 3997 3775 3998 3776 list_for_each_entry(ipr_cmd, &ioa_cfg->pending_q, queue) { ··· 4837 4615 * Return value: 4838 4616 * 0 on success / other on failure 4839 4617 **/ 4840 - int ipr_ioctl(struct scsi_device *sdev, int cmd, void __user *arg) 4618 + static int ipr_ioctl(struct scsi_device *sdev, int cmd, void __user *arg) 4841 4619 { 4842 4620 struct ipr_resource_entry *res; 4843 4621 ··· 4869 4647 4870 4648 return buffer; 4871 4649 } 4872 - 4873 - /** 4874 - * ipr_scsi_timed_out - Handle scsi command timeout 4875 - * @scsi_cmd: scsi command struct 4876 - * 4877 - * Return value: 4878 - * EH_NOT_HANDLED 4879 - **/ 4880 - enum scsi_eh_timer_return ipr_scsi_timed_out(struct scsi_cmnd *scsi_cmd) 4881 - { 4882 - struct ipr_ioa_cfg *ioa_cfg; 4883 - struct ipr_cmnd *ipr_cmd; 4884 - unsigned long flags; 4885 - 4886 - ENTER; 4887 - spin_lock_irqsave(scsi_cmd->device->host->host_lock, flags); 4888 - ioa_cfg = (struct ipr_ioa_cfg *)scsi_cmd->device->host->hostdata; 4889 - 4890 - list_for_each_entry(ipr_cmd, &ioa_cfg->pending_q, queue) { 4891 - if (ipr_cmd->qc && ipr_cmd->qc->scsicmd == scsi_cmd) { 4892 - ipr_cmd->qc->err_mask |= AC_ERR_TIMEOUT; 4893 - ipr_cmd->qc->flags |= ATA_QCFLAG_FAILED; 4894 - break; 4895 - } 4896 - } 4897 - 4898 - spin_unlock_irqrestore(scsi_cmd->device->host->host_lock, flags); 4899 - LEAVE; 4900 - return EH_NOT_HANDLED; 4901 - } 4902 - 4903 - static struct scsi_transport_template ipr_transport_template = { 4904 - .eh_timed_out = ipr_scsi_timed_out 4905 - }; 4906 4650 4907 4651 static struct scsi_host_template driver_template = { 4908 4652 .module = THIS_MODULE, ··· 4964 4776 unsigned long flags; 4965 4777 4966 4778 spin_lock_irqsave(ioa_cfg->host->host_lock, flags); 4779 + while(ioa_cfg->in_reset_reload) { 4780 + spin_unlock_irqrestore(ioa_cfg->host->host_lock, flags); 4781 + wait_event(ioa_cfg->reset_wait_q, !ioa_cfg->in_reset_reload); 4782 + spin_lock_irqsave(ioa_cfg->host->host_lock, flags); 4783 + } 4784 + 4967 4785 list_for_each_entry(ipr_cmd, &ioa_cfg->pending_q, queue) { 4968 4786 if (ipr_cmd->qc == qc) { 4969 4787 ipr_device_reset(ioa_cfg, sata_port->res); ··· 7026 6832 7027 6833 ioa_cfg->hostrcb[i]->hostrcb_dma = 7028 6834 ioa_cfg->hostrcb_dma[i] + offsetof(struct ipr_hostrcb, hcam); 6835 + ioa_cfg->hostrcb[i]->ioa_cfg = ioa_cfg; 7029 6836 list_add_tail(&ioa_cfg->hostrcb[i]->queue, &ioa_cfg->hostrcb_free_q); 7030 6837 } 7031 6838 ··· 7212 7017 7213 7018 ioa_cfg = (struct ipr_ioa_cfg *)host->hostdata; 7214 7019 memset(ioa_cfg, 0, sizeof(struct ipr_ioa_cfg)); 7215 - host->transportt = &ipr_transport_template; 7216 7020 ata_host_init(&ioa_cfg->ata_host, &pdev->dev, 7217 7021 sata_port_info.flags, &ipr_sata_ops); 7218 7022 ··· 7545 7351 { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_OBSIDIAN, 7546 7352 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_572B, 7547 7353 0, 0, (kernel_ulong_t)&ipr_chip_cfg[0] }, 7354 + { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_OBSIDIAN, 7355 + PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_575C, 7356 + 0, 0, (kernel_ulong_t)&ipr_chip_cfg[0] }, 7548 7357 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN, 7549 7358 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_572A, 7550 7359 0, 0, (kernel_ulong_t)&ipr_chip_cfg[0] }, 7551 7360 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN, 7552 7361 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_572B, 7362 + 0, 0, (kernel_ulong_t)&ipr_chip_cfg[0] }, 7363 + { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN, 7364 + PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_575C, 7365 + 0, 0, (kernel_ulong_t)&ipr_chip_cfg[0] }, 7366 + { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN, 7367 + PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_57B8, 7368 + 0, 0, (kernel_ulong_t)&ipr_chip_cfg[0] }, 7369 + { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN_E, 7370 + PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_57B7, 7553 7371 0, 0, (kernel_ulong_t)&ipr_chip_cfg[0] }, 7554 7372 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_SNIPE, 7555 7373 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_2780, ··· 7571 7365 0, 0, (kernel_ulong_t)&ipr_chip_cfg[1] }, 7572 7366 { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_SCAMP, 7573 7367 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_571F, 7368 + 0, 0, (kernel_ulong_t)&ipr_chip_cfg[1] }, 7369 + { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_SCAMP, 7370 + PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_572F, 7574 7371 0, 0, (kernel_ulong_t)&ipr_chip_cfg[1] }, 7575 7372 { } 7576 7373 };
+81 -2
drivers/scsi/ipr.h
··· 37 37 /* 38 38 * Literals 39 39 */ 40 - #define IPR_DRIVER_VERSION "2.2.0" 41 - #define IPR_DRIVER_DATE "(September 25, 2006)" 40 + #define IPR_DRIVER_VERSION "2.3.0" 41 + #define IPR_DRIVER_DATE "(November 8, 2006)" 42 42 43 43 /* 44 44 * IPR_MAX_CMD_PER_LUN: This defines the maximum number of outstanding ··· 54 54 */ 55 55 #define IPR_NUM_BASE_CMD_BLKS 100 56 56 57 + #define PCI_DEVICE_ID_IBM_OBSIDIAN_E 0x0339 58 + 57 59 #define IPR_SUBS_DEV_ID_2780 0x0264 58 60 #define IPR_SUBS_DEV_ID_5702 0x0266 59 61 #define IPR_SUBS_DEV_ID_5703 0x0278 ··· 68 66 #define IPR_SUBS_DEV_ID_571F 0x02D5 69 67 #define IPR_SUBS_DEV_ID_572A 0x02C1 70 68 #define IPR_SUBS_DEV_ID_572B 0x02C2 69 + #define IPR_SUBS_DEV_ID_572F 0x02C3 71 70 #define IPR_SUBS_DEV_ID_575B 0x030D 71 + #define IPR_SUBS_DEV_ID_575C 0x0338 72 + #define IPR_SUBS_DEV_ID_57B7 0x0360 73 + #define IPR_SUBS_DEV_ID_57B8 0x02C2 72 74 73 75 #define IPR_NAME "ipr" 74 76 ··· 104 98 #define IPR_IOASC_IOA_WAS_RESET 0x10000001 105 99 #define IPR_IOASC_PCI_ACCESS_ERROR 0x10000002 106 100 101 + #define IPR_DEFAULT_MAX_ERROR_DUMP 984 107 102 #define IPR_NUM_LOG_HCAMS 2 108 103 #define IPR_NUM_CFG_CHG_HCAMS 2 109 104 #define IPR_NUM_HCAMS (IPR_NUM_LOG_HCAMS + IPR_NUM_CFG_CHG_HCAMS) ··· 738 731 u32 data[476]; 739 732 }__attribute__((packed, aligned (4))); 740 733 734 + struct ipr_hostrcb_config_element { 735 + u8 type_status; 736 + #define IPR_PATH_CFG_TYPE_MASK 0xF0 737 + #define IPR_PATH_CFG_NOT_EXIST 0x00 738 + #define IPR_PATH_CFG_IOA_PORT 0x10 739 + #define IPR_PATH_CFG_EXP_PORT 0x20 740 + #define IPR_PATH_CFG_DEVICE_PORT 0x30 741 + #define IPR_PATH_CFG_DEVICE_LUN 0x40 742 + 743 + #define IPR_PATH_CFG_STATUS_MASK 0x0F 744 + #define IPR_PATH_CFG_NO_PROB 0x00 745 + #define IPR_PATH_CFG_DEGRADED 0x01 746 + #define IPR_PATH_CFG_FAILED 0x02 747 + #define IPR_PATH_CFG_SUSPECT 0x03 748 + #define IPR_PATH_NOT_DETECTED 0x04 749 + #define IPR_PATH_INCORRECT_CONN 0x05 750 + 751 + u8 cascaded_expander; 752 + u8 phy; 753 + u8 link_rate; 754 + #define IPR_PHY_LINK_RATE_MASK 0x0F 755 + 756 + __be32 wwid[2]; 757 + }__attribute__((packed, aligned (4))); 758 + 759 + struct ipr_hostrcb_fabric_desc { 760 + __be16 length; 761 + u8 ioa_port; 762 + u8 cascaded_expander; 763 + u8 phy; 764 + u8 path_state; 765 + #define IPR_PATH_ACTIVE_MASK 0xC0 766 + #define IPR_PATH_NO_INFO 0x00 767 + #define IPR_PATH_ACTIVE 0x40 768 + #define IPR_PATH_NOT_ACTIVE 0x80 769 + 770 + #define IPR_PATH_STATE_MASK 0x0F 771 + #define IPR_PATH_STATE_NO_INFO 0x00 772 + #define IPR_PATH_HEALTHY 0x01 773 + #define IPR_PATH_DEGRADED 0x02 774 + #define IPR_PATH_FAILED 0x03 775 + 776 + __be16 num_entries; 777 + struct ipr_hostrcb_config_element elem[1]; 778 + }__attribute__((packed, aligned (4))); 779 + 780 + #define for_each_fabric_cfg(fabric, cfg) \ 781 + for (cfg = (fabric)->elem; \ 782 + cfg < ((fabric)->elem + be16_to_cpu((fabric)->num_entries)); \ 783 + cfg++) 784 + 785 + struct ipr_hostrcb_type_20_error { 786 + u8 failure_reason[64]; 787 + u8 reserved[3]; 788 + u8 num_entries; 789 + struct ipr_hostrcb_fabric_desc desc[1]; 790 + }__attribute__((packed, aligned (4))); 791 + 741 792 struct ipr_hostrcb_error { 742 793 __be32 failing_dev_ioasc; 743 794 struct ipr_res_addr failing_dev_res_addr; ··· 812 747 struct ipr_hostrcb_type_13_error type_13_error; 813 748 struct ipr_hostrcb_type_14_error type_14_error; 814 749 struct ipr_hostrcb_type_17_error type_17_error; 750 + struct ipr_hostrcb_type_20_error type_20_error; 815 751 } u; 816 752 }__attribute__((packed, aligned (4))); 817 753 ··· 852 786 #define IPR_HOST_RCB_OVERLAY_ID_14 0x14 853 787 #define IPR_HOST_RCB_OVERLAY_ID_16 0x16 854 788 #define IPR_HOST_RCB_OVERLAY_ID_17 0x17 789 + #define IPR_HOST_RCB_OVERLAY_ID_20 0x20 855 790 #define IPR_HOST_RCB_OVERLAY_ID_DEFAULT 0xFF 856 791 857 792 u8 reserved1[3]; ··· 872 805 struct ipr_hcam hcam; 873 806 dma_addr_t hostrcb_dma; 874 807 struct list_head queue; 808 + struct ipr_ioa_cfg *ioa_cfg; 875 809 }; 876 810 877 811 /* IPR smart dump table structures */ ··· 1349 1281 ##__VA_ARGS__, (ioa_cfg)->host->host_no, \ 1350 1282 (res).bus, (res).target, (res).lun); \ 1351 1283 } \ 1284 + } 1285 + 1286 + #define ipr_hcam_err(hostrcb, fmt, ...) \ 1287 + { \ 1288 + if (ipr_is_device(&(hostrcb)->hcam.u.error.failing_dev_res_addr)) { \ 1289 + ipr_ra_err((hostrcb)->ioa_cfg, \ 1290 + (hostrcb)->hcam.u.error.failing_dev_res_addr, \ 1291 + fmt, ##__VA_ARGS__); \ 1292 + } else { \ 1293 + dev_err(&(hostrcb)->ioa_cfg->pdev->dev, fmt, ##__VA_ARGS__); \ 1294 + } \ 1352 1295 } 1353 1296 1354 1297 #define ipr_trace ipr_dbg("%s: %s: Line: %d\n",\
+14 -14
drivers/scsi/ips.c
··· 5001 5001 break; 5002 5002 5003 5003 /* Delay for 1 Second */ 5004 - msleep(IPS_ONE_SEC); 5004 + MDELAY(IPS_ONE_SEC); 5005 5005 } 5006 5006 5007 5007 if (j >= 45) ··· 5027 5027 break; 5028 5028 5029 5029 /* Delay for 1 Second */ 5030 - msleep(IPS_ONE_SEC); 5030 + MDELAY(IPS_ONE_SEC); 5031 5031 } 5032 5032 5033 5033 if (j >= 240) ··· 5045 5045 break; 5046 5046 5047 5047 /* Delay for 1 Second */ 5048 - msleep(IPS_ONE_SEC); 5048 + MDELAY(IPS_ONE_SEC); 5049 5049 } 5050 5050 5051 5051 if (i >= 240) ··· 5095 5095 break; 5096 5096 5097 5097 /* Delay for 1 Second */ 5098 - msleep(IPS_ONE_SEC); 5098 + MDELAY(IPS_ONE_SEC); 5099 5099 } 5100 5100 5101 5101 if (j >= 45) ··· 5121 5121 break; 5122 5122 5123 5123 /* Delay for 1 Second */ 5124 - msleep(IPS_ONE_SEC); 5124 + MDELAY(IPS_ONE_SEC); 5125 5125 } 5126 5126 5127 5127 if (j >= 240) ··· 5139 5139 break; 5140 5140 5141 5141 /* Delay for 1 Second */ 5142 - msleep(IPS_ONE_SEC); 5142 + MDELAY(IPS_ONE_SEC); 5143 5143 } 5144 5144 5145 5145 if (i >= 240) ··· 5191 5191 break; 5192 5192 5193 5193 /* Delay for 1 Second */ 5194 - msleep(IPS_ONE_SEC); 5194 + MDELAY(IPS_ONE_SEC); 5195 5195 } 5196 5196 5197 5197 if (i >= 45) { ··· 5217 5217 if (Post != 0x4F00) 5218 5218 break; 5219 5219 /* Delay for 1 Second */ 5220 - msleep(IPS_ONE_SEC); 5220 + MDELAY(IPS_ONE_SEC); 5221 5221 } 5222 5222 5223 5223 if (i >= 120) { ··· 5247 5247 break; 5248 5248 5249 5249 /* Delay for 1 Second */ 5250 - msleep(IPS_ONE_SEC); 5250 + MDELAY(IPS_ONE_SEC); 5251 5251 } 5252 5252 5253 5253 if (i >= 240) { ··· 5307 5307 outb(IPS_BIT_RST, ha->io_addr + IPS_REG_SCPR); 5308 5308 5309 5309 /* Delay for 1 Second */ 5310 - msleep(IPS_ONE_SEC); 5310 + MDELAY(IPS_ONE_SEC); 5311 5311 5312 5312 outb(0, ha->io_addr + IPS_REG_SCPR); 5313 5313 5314 5314 /* Delay for 1 Second */ 5315 - msleep(IPS_ONE_SEC); 5315 + MDELAY(IPS_ONE_SEC); 5316 5316 5317 5317 if ((*ha->func.init) (ha)) 5318 5318 break; ··· 5352 5352 writeb(IPS_BIT_RST, ha->mem_ptr + IPS_REG_SCPR); 5353 5353 5354 5354 /* Delay for 1 Second */ 5355 - msleep(IPS_ONE_SEC); 5355 + MDELAY(IPS_ONE_SEC); 5356 5356 5357 5357 writeb(0, ha->mem_ptr + IPS_REG_SCPR); 5358 5358 5359 5359 /* Delay for 1 Second */ 5360 - msleep(IPS_ONE_SEC); 5360 + MDELAY(IPS_ONE_SEC); 5361 5361 5362 5362 if ((*ha->func.init) (ha)) 5363 5363 break; ··· 5398 5398 writel(0x80000000, ha->mem_ptr + IPS_REG_I960_IDR); 5399 5399 5400 5400 /* Delay for 5 Seconds */ 5401 - msleep(5 * IPS_ONE_SEC); 5401 + MDELAY(5 * IPS_ONE_SEC); 5402 5402 5403 5403 /* Do a PCI config read to wait for adapter */ 5404 5404 pci_read_config_byte(ha->pcidev, 4, &junk);
+6 -3
drivers/scsi/ips.h
··· 51 51 #define _IPS_H_ 52 52 53 53 #include <linux/version.h> 54 + #include <linux/nmi.h> 54 55 #include <asm/uaccess.h> 55 56 #include <asm/io.h> 56 57 ··· 117 116 dev_printk(level , &((pcidev)->dev) , format , ## arg) 118 117 #endif 119 118 120 - #ifndef MDELAY 121 - #define MDELAY mdelay 122 - #endif 119 + #define MDELAY(n) \ 120 + do { \ 121 + mdelay(n); \ 122 + touch_nmi_watchdog(); \ 123 + } while (0) 123 124 124 125 #ifndef min 125 126 #define min(x,y) ((x) < (y) ? x : y)
+24 -12
drivers/scsi/libsas/sas_expander.c
··· 597 597 child->iproto = phy->attached_iproto; 598 598 memcpy(child->sas_addr, phy->attached_sas_addr, SAS_ADDR_SIZE); 599 599 sas_hash_addr(child->hashed_sas_addr, child->sas_addr); 600 - phy->port = sas_port_alloc(&parent->rphy->dev, phy_id); 601 - BUG_ON(!phy->port); 602 - /* FIXME: better error handling*/ 603 - BUG_ON(sas_port_add(phy->port) != 0); 600 + if (!phy->port) { 601 + phy->port = sas_port_alloc(&parent->rphy->dev, phy_id); 602 + if (unlikely(!phy->port)) 603 + goto out_err; 604 + if (unlikely(sas_port_add(phy->port) != 0)) { 605 + sas_port_free(phy->port); 606 + goto out_err; 607 + } 608 + } 604 609 sas_ex_get_linkrate(parent, child, phy); 605 610 606 611 if ((phy->attached_tproto & SAS_PROTO_STP) || phy->attached_sata_dev) { ··· 620 615 SAS_DPRINTK("report phy sata to %016llx:0x%x returned " 621 616 "0x%x\n", SAS_ADDR(parent->sas_addr), 622 617 phy_id, res); 623 - kfree(child); 624 - return NULL; 618 + goto out_free; 625 619 } 626 620 memcpy(child->frame_rcvd, &child->sata_dev.rps_resp.rps.fis, 627 621 sizeof(struct dev_to_host_fis)); ··· 631 627 "%016llx:0x%x returned 0x%x\n", 632 628 SAS_ADDR(child->sas_addr), 633 629 SAS_ADDR(parent->sas_addr), phy_id, res); 634 - kfree(child); 635 - return NULL; 630 + goto out_free; 636 631 } 637 632 } else if (phy->attached_tproto & SAS_PROTO_SSP) { 638 633 child->dev_type = SAS_END_DEV; 639 634 rphy = sas_end_device_alloc(phy->port); 640 635 /* FIXME: error handling */ 641 - BUG_ON(!rphy); 636 + if (unlikely(!rphy)) 637 + goto out_free; 642 638 child->tproto = phy->attached_tproto; 643 639 sas_init_dev(child); 644 640 ··· 655 651 "at %016llx:0x%x returned 0x%x\n", 656 652 SAS_ADDR(child->sas_addr), 657 653 SAS_ADDR(parent->sas_addr), phy_id, res); 658 - /* FIXME: this kfrees list elements without removing them */ 659 - //kfree(child); 660 - return NULL; 654 + goto out_list_del; 661 655 } 662 656 } else { 663 657 SAS_DPRINTK("target proto 0x%x at %016llx:0x%x not handled\n", ··· 665 663 666 664 list_add_tail(&child->siblings, &parent_ex->children); 667 665 return child; 666 + 667 + out_list_del: 668 + list_del(&child->dev_list_node); 669 + sas_rphy_free(rphy); 670 + out_free: 671 + sas_port_delete(phy->port); 672 + out_err: 673 + phy->port = NULL; 674 + kfree(child); 675 + return NULL; 668 676 } 669 677 670 678 static struct domain_device *sas_ex_discover_expander(
+3 -1
drivers/scsi/libsas/sas_init.c
··· 112 112 } 113 113 } 114 114 115 + INIT_LIST_HEAD(&sas_ha->eh_done_q); 116 + 115 117 return 0; 116 118 117 119 Undo_ports: ··· 144 142 return sas_smp_get_phy_events(phy); 145 143 } 146 144 147 - static int sas_phy_reset(struct sas_phy *phy, int hard_reset) 145 + int sas_phy_reset(struct sas_phy *phy, int hard_reset) 148 146 { 149 147 int ret; 150 148 enum phy_func reset_type;
+87 -5
drivers/scsi/libsas/sas_scsi_host.c
··· 29 29 #include <scsi/scsi_device.h> 30 30 #include <scsi/scsi_tcq.h> 31 31 #include <scsi/scsi.h> 32 + #include <scsi/scsi_eh.h> 32 33 #include <scsi/scsi_transport.h> 33 34 #include <scsi/scsi_transport_sas.h> 34 35 #include "../scsi_sas_internal.h" 36 + #include "../scsi_transport_api.h" 35 37 36 38 #include <linux/err.h> 37 39 #include <linux/blkdev.h> ··· 48 46 { 49 47 struct task_status_struct *ts = &task->task_status; 50 48 struct scsi_cmnd *sc = task->uldd_task; 49 + struct sas_ha_struct *sas_ha = SHOST_TO_SAS_HA(sc->device->host); 51 50 unsigned ts_flags = task->task_state_flags; 52 51 int hs = 0, stat = 0; 53 52 ··· 119 116 sas_free_task(task); 120 117 /* This is very ugly but this is how SCSI Core works. */ 121 118 if (ts_flags & SAS_TASK_STATE_ABORTED) 122 - scsi_finish_command(sc); 119 + scsi_eh_finish_cmd(sc, &sas_ha->eh_done_q); 123 120 else 124 121 sc->scsi_done(sc); 125 122 } ··· 310 307 spin_unlock_irqrestore(&core->task_queue_lock, flags); 311 308 } 312 309 310 + spin_lock_irqsave(&task->task_state_lock, flags); 311 + if (task->task_state_flags & SAS_TASK_INITIATOR_ABORTED) { 312 + spin_unlock_irqrestore(&task->task_state_lock, flags); 313 + SAS_DPRINTK("%s: task 0x%p already aborted\n", 314 + __FUNCTION__, task); 315 + return TASK_IS_ABORTED; 316 + } 317 + spin_unlock_irqrestore(&task->task_state_lock, flags); 318 + 313 319 for (i = 0; i < 5; i++) { 314 320 SAS_DPRINTK("%s: aborting task 0x%p\n", __FUNCTION__, task); 315 321 res = si->dft->lldd_abort_task(task); ··· 421 409 SAS_DPRINTK("going over list...\n"); 422 410 list_for_each_entry_safe(cmd, n, &error_q, eh_entry) { 423 411 struct sas_task *task = TO_SAS_TASK(cmd); 424 - 425 - SAS_DPRINTK("trying to find task 0x%p\n", task); 426 412 list_del_init(&cmd->eh_entry); 413 + 414 + if (!task) { 415 + SAS_DPRINTK("%s: taskless cmd?!\n", __FUNCTION__); 416 + continue; 417 + } 418 + SAS_DPRINTK("trying to find task 0x%p\n", task); 427 419 res = sas_scsi_find_task(task); 428 420 429 421 cmd->eh_eflags = 0; 430 - shost->host_failed--; 431 422 432 423 switch (res) { 433 424 case TASK_IS_DONE: ··· 506 491 } 507 492 } 508 493 out: 494 + scsi_eh_flush_done_q(&ha->eh_done_q); 509 495 SAS_DPRINTK("--- Exit %s\n", __FUNCTION__); 510 496 return; 511 497 clear_q: ··· 524 508 unsigned long flags; 525 509 526 510 if (!task) { 527 - SAS_DPRINTK("command 0x%p, task 0x%p, timed out: EH_HANDLED\n", 511 + SAS_DPRINTK("command 0x%p, task 0x%p, gone: EH_HANDLED\n", 528 512 cmd, task); 529 513 return EH_HANDLED; 530 514 } 531 515 532 516 spin_lock_irqsave(&task->task_state_lock, flags); 517 + if (task->task_state_flags & SAS_TASK_INITIATOR_ABORTED) { 518 + spin_unlock_irqrestore(&task->task_state_lock, flags); 519 + SAS_DPRINTK("command 0x%p, task 0x%p, aborted by initiator: " 520 + "EH_NOT_HANDLED\n", cmd, task); 521 + return EH_NOT_HANDLED; 522 + } 533 523 if (task->task_state_flags & SAS_TASK_STATE_DONE) { 534 524 spin_unlock_irqrestore(&task->task_state_lock, flags); 535 525 SAS_DPRINTK("command 0x%p, task 0x%p, timed out: EH_HANDLED\n", ··· 799 777 spin_unlock_irqrestore(&core->task_queue_lock, flags); 800 778 } 801 779 780 + static int do_sas_task_abort(struct sas_task *task) 781 + { 782 + struct scsi_cmnd *sc = task->uldd_task; 783 + struct sas_internal *si = 784 + to_sas_internal(task->dev->port->ha->core.shost->transportt); 785 + unsigned long flags; 786 + int res; 787 + 788 + spin_lock_irqsave(&task->task_state_lock, flags); 789 + if (task->task_state_flags & SAS_TASK_STATE_ABORTED) { 790 + spin_unlock_irqrestore(&task->task_state_lock, flags); 791 + SAS_DPRINTK("%s: Task %p already aborted.\n", __FUNCTION__, 792 + task); 793 + return 0; 794 + } 795 + 796 + task->task_state_flags |= SAS_TASK_INITIATOR_ABORTED; 797 + if (!(task->task_state_flags & SAS_TASK_STATE_DONE)) 798 + task->task_state_flags |= SAS_TASK_STATE_ABORTED; 799 + spin_unlock_irqrestore(&task->task_state_lock, flags); 800 + 801 + if (!si->dft->lldd_abort_task) 802 + return -ENODEV; 803 + 804 + res = si->dft->lldd_abort_task(task); 805 + if ((task->task_state_flags & SAS_TASK_STATE_DONE) || 806 + (res == TMF_RESP_FUNC_COMPLETE)) 807 + { 808 + /* SMP commands don't have scsi_cmds(?) */ 809 + if (!sc) { 810 + task->task_done(task); 811 + return 0; 812 + } 813 + scsi_req_abort_cmd(sc); 814 + scsi_schedule_eh(sc->device->host); 815 + return 0; 816 + } 817 + 818 + spin_lock_irqsave(&task->task_state_lock, flags); 819 + task->task_state_flags &= ~SAS_TASK_INITIATOR_ABORTED; 820 + if (!(task->task_state_flags & SAS_TASK_STATE_DONE)) 821 + task->task_state_flags &= ~SAS_TASK_STATE_ABORTED; 822 + spin_unlock_irqrestore(&task->task_state_lock, flags); 823 + 824 + return -EAGAIN; 825 + } 826 + 827 + void sas_task_abort(struct sas_task *task) 828 + { 829 + int i; 830 + 831 + for (i = 0; i < 5; i++) 832 + if (!do_sas_task_abort(task)) 833 + return; 834 + 835 + SAS_DPRINTK("%s: Could not kill task!\n", __FUNCTION__); 836 + } 837 + 802 838 EXPORT_SYMBOL_GPL(sas_queuecommand); 803 839 EXPORT_SYMBOL_GPL(sas_target_alloc); 804 840 EXPORT_SYMBOL_GPL(sas_slave_configure); ··· 864 784 EXPORT_SYMBOL_GPL(sas_change_queue_depth); 865 785 EXPORT_SYMBOL_GPL(sas_change_queue_type); 866 786 EXPORT_SYMBOL_GPL(sas_bios_param); 787 + EXPORT_SYMBOL_GPL(sas_task_abort); 788 + EXPORT_SYMBOL_GPL(sas_phy_reset);
+441
drivers/scsi/libsrp.c
··· 1 + /* 2 + * SCSI RDAM Protocol lib functions 3 + * 4 + * Copyright (C) 2006 FUJITA Tomonori <tomof@acm.org> 5 + * 6 + * This program is free software; you can redistribute it and/or 7 + * modify it under the terms of the GNU General Public License as 8 + * published by the Free Software Foundation; either version 2 of the 9 + * License, or (at your option) any later version. 10 + * 11 + * This program is distributed in the hope that it will be useful, but 12 + * WITHOUT ANY WARRANTY; without even the implied warranty of 13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 + * General Public License for more details. 15 + * 16 + * You should have received a copy of the GNU General Public License 17 + * along with this program; if not, write to the Free Software 18 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 19 + * 02110-1301 USA 20 + */ 21 + #include <linux/err.h> 22 + #include <linux/kfifo.h> 23 + #include <linux/scatterlist.h> 24 + #include <linux/dma-mapping.h> 25 + #include <linux/pci.h> 26 + #include <scsi/scsi.h> 27 + #include <scsi/scsi_cmnd.h> 28 + #include <scsi/scsi_tcq.h> 29 + #include <scsi/scsi_tgt.h> 30 + #include <scsi/srp.h> 31 + #include <scsi/libsrp.h> 32 + 33 + enum srp_task_attributes { 34 + SRP_SIMPLE_TASK = 0, 35 + SRP_HEAD_TASK = 1, 36 + SRP_ORDERED_TASK = 2, 37 + SRP_ACA_TASK = 4 38 + }; 39 + 40 + /* tmp - will replace with SCSI logging stuff */ 41 + #define eprintk(fmt, args...) \ 42 + do { \ 43 + printk("%s(%d) " fmt, __FUNCTION__, __LINE__, ##args); \ 44 + } while (0) 45 + /* #define dprintk eprintk */ 46 + #define dprintk(fmt, args...) 47 + 48 + static int srp_iu_pool_alloc(struct srp_queue *q, size_t max, 49 + struct srp_buf **ring) 50 + { 51 + int i; 52 + struct iu_entry *iue; 53 + 54 + q->pool = kcalloc(max, sizeof(struct iu_entry *), GFP_KERNEL); 55 + if (!q->pool) 56 + return -ENOMEM; 57 + q->items = kcalloc(max, sizeof(struct iu_entry), GFP_KERNEL); 58 + if (!q->items) 59 + goto free_pool; 60 + 61 + spin_lock_init(&q->lock); 62 + q->queue = kfifo_init((void *) q->pool, max * sizeof(void *), 63 + GFP_KERNEL, &q->lock); 64 + if (IS_ERR(q->queue)) 65 + goto free_item; 66 + 67 + for (i = 0, iue = q->items; i < max; i++) { 68 + __kfifo_put(q->queue, (void *) &iue, sizeof(void *)); 69 + iue->sbuf = ring[i]; 70 + iue++; 71 + } 72 + return 0; 73 + 74 + free_item: 75 + kfree(q->items); 76 + free_pool: 77 + kfree(q->pool); 78 + return -ENOMEM; 79 + } 80 + 81 + static void srp_iu_pool_free(struct srp_queue *q) 82 + { 83 + kfree(q->items); 84 + kfree(q->pool); 85 + } 86 + 87 + static struct srp_buf **srp_ring_alloc(struct device *dev, 88 + size_t max, size_t size) 89 + { 90 + int i; 91 + struct srp_buf **ring; 92 + 93 + ring = kcalloc(max, sizeof(struct srp_buf *), GFP_KERNEL); 94 + if (!ring) 95 + return NULL; 96 + 97 + for (i = 0; i < max; i++) { 98 + ring[i] = kzalloc(sizeof(struct srp_buf), GFP_KERNEL); 99 + if (!ring[i]) 100 + goto out; 101 + ring[i]->buf = dma_alloc_coherent(dev, size, &ring[i]->dma, 102 + GFP_KERNEL); 103 + if (!ring[i]->buf) 104 + goto out; 105 + } 106 + return ring; 107 + 108 + out: 109 + for (i = 0; i < max && ring[i]; i++) { 110 + if (ring[i]->buf) 111 + dma_free_coherent(dev, size, ring[i]->buf, ring[i]->dma); 112 + kfree(ring[i]); 113 + } 114 + kfree(ring); 115 + 116 + return NULL; 117 + } 118 + 119 + static void srp_ring_free(struct device *dev, struct srp_buf **ring, size_t max, 120 + size_t size) 121 + { 122 + int i; 123 + 124 + for (i = 0; i < max; i++) { 125 + dma_free_coherent(dev, size, ring[i]->buf, ring[i]->dma); 126 + kfree(ring[i]); 127 + } 128 + } 129 + 130 + int srp_target_alloc(struct srp_target *target, struct device *dev, 131 + size_t nr, size_t iu_size) 132 + { 133 + int err; 134 + 135 + spin_lock_init(&target->lock); 136 + INIT_LIST_HEAD(&target->cmd_queue); 137 + 138 + target->dev = dev; 139 + target->dev->driver_data = target; 140 + 141 + target->srp_iu_size = iu_size; 142 + target->rx_ring_size = nr; 143 + target->rx_ring = srp_ring_alloc(target->dev, nr, iu_size); 144 + if (!target->rx_ring) 145 + return -ENOMEM; 146 + err = srp_iu_pool_alloc(&target->iu_queue, nr, target->rx_ring); 147 + if (err) 148 + goto free_ring; 149 + 150 + return 0; 151 + 152 + free_ring: 153 + srp_ring_free(target->dev, target->rx_ring, nr, iu_size); 154 + return -ENOMEM; 155 + } 156 + EXPORT_SYMBOL_GPL(srp_target_alloc); 157 + 158 + void srp_target_free(struct srp_target *target) 159 + { 160 + srp_ring_free(target->dev, target->rx_ring, target->rx_ring_size, 161 + target->srp_iu_size); 162 + srp_iu_pool_free(&target->iu_queue); 163 + } 164 + EXPORT_SYMBOL_GPL(srp_target_free); 165 + 166 + struct iu_entry *srp_iu_get(struct srp_target *target) 167 + { 168 + struct iu_entry *iue = NULL; 169 + 170 + kfifo_get(target->iu_queue.queue, (void *) &iue, sizeof(void *)); 171 + if (!iue) 172 + return iue; 173 + iue->target = target; 174 + INIT_LIST_HEAD(&iue->ilist); 175 + iue->flags = 0; 176 + return iue; 177 + } 178 + EXPORT_SYMBOL_GPL(srp_iu_get); 179 + 180 + void srp_iu_put(struct iu_entry *iue) 181 + { 182 + kfifo_put(iue->target->iu_queue.queue, (void *) &iue, sizeof(void *)); 183 + } 184 + EXPORT_SYMBOL_GPL(srp_iu_put); 185 + 186 + static int srp_direct_data(struct scsi_cmnd *sc, struct srp_direct_buf *md, 187 + enum dma_data_direction dir, srp_rdma_t rdma_io, 188 + int dma_map, int ext_desc) 189 + { 190 + struct iu_entry *iue = NULL; 191 + struct scatterlist *sg = NULL; 192 + int err, nsg = 0, len; 193 + 194 + if (dma_map) { 195 + iue = (struct iu_entry *) sc->SCp.ptr; 196 + sg = sc->request_buffer; 197 + 198 + dprintk("%p %u %u %d\n", iue, sc->request_bufflen, 199 + md->len, sc->use_sg); 200 + 201 + nsg = dma_map_sg(iue->target->dev, sg, sc->use_sg, 202 + DMA_BIDIRECTIONAL); 203 + if (!nsg) { 204 + printk("fail to map %p %d\n", iue, sc->use_sg); 205 + return 0; 206 + } 207 + len = min(sc->request_bufflen, md->len); 208 + } else 209 + len = md->len; 210 + 211 + err = rdma_io(sc, sg, nsg, md, 1, dir, len); 212 + 213 + if (dma_map) 214 + dma_unmap_sg(iue->target->dev, sg, nsg, DMA_BIDIRECTIONAL); 215 + 216 + return err; 217 + } 218 + 219 + static int srp_indirect_data(struct scsi_cmnd *sc, struct srp_cmd *cmd, 220 + struct srp_indirect_buf *id, 221 + enum dma_data_direction dir, srp_rdma_t rdma_io, 222 + int dma_map, int ext_desc) 223 + { 224 + struct iu_entry *iue = NULL; 225 + struct srp_direct_buf *md = NULL; 226 + struct scatterlist dummy, *sg = NULL; 227 + dma_addr_t token = 0; 228 + long err; 229 + unsigned int done = 0; 230 + int nmd, nsg = 0, len; 231 + 232 + if (dma_map || ext_desc) { 233 + iue = (struct iu_entry *) sc->SCp.ptr; 234 + sg = sc->request_buffer; 235 + 236 + dprintk("%p %u %u %d %d\n", 237 + iue, sc->request_bufflen, id->len, 238 + cmd->data_in_desc_cnt, cmd->data_out_desc_cnt); 239 + } 240 + 241 + nmd = id->table_desc.len / sizeof(struct srp_direct_buf); 242 + 243 + if ((dir == DMA_FROM_DEVICE && nmd == cmd->data_in_desc_cnt) || 244 + (dir == DMA_TO_DEVICE && nmd == cmd->data_out_desc_cnt)) { 245 + md = &id->desc_list[0]; 246 + goto rdma; 247 + } 248 + 249 + if (ext_desc && dma_map) { 250 + md = dma_alloc_coherent(iue->target->dev, id->table_desc.len, 251 + &token, GFP_KERNEL); 252 + if (!md) { 253 + eprintk("Can't get dma memory %u\n", id->table_desc.len); 254 + return -ENOMEM; 255 + } 256 + 257 + sg_init_one(&dummy, md, id->table_desc.len); 258 + sg_dma_address(&dummy) = token; 259 + err = rdma_io(sc, &dummy, 1, &id->table_desc, 1, DMA_TO_DEVICE, 260 + id->table_desc.len); 261 + if (err < 0) { 262 + eprintk("Error copying indirect table %ld\n", err); 263 + goto free_mem; 264 + } 265 + } else { 266 + eprintk("This command uses external indirect buffer\n"); 267 + return -EINVAL; 268 + } 269 + 270 + rdma: 271 + if (dma_map) { 272 + nsg = dma_map_sg(iue->target->dev, sg, sc->use_sg, DMA_BIDIRECTIONAL); 273 + if (!nsg) { 274 + eprintk("fail to map %p %d\n", iue, sc->use_sg); 275 + goto free_mem; 276 + } 277 + len = min(sc->request_bufflen, id->len); 278 + } else 279 + len = id->len; 280 + 281 + err = rdma_io(sc, sg, nsg, md, nmd, dir, len); 282 + 283 + if (dma_map) 284 + dma_unmap_sg(iue->target->dev, sg, nsg, DMA_BIDIRECTIONAL); 285 + 286 + free_mem: 287 + if (token && dma_map) 288 + dma_free_coherent(iue->target->dev, id->table_desc.len, md, token); 289 + 290 + return done; 291 + } 292 + 293 + static int data_out_desc_size(struct srp_cmd *cmd) 294 + { 295 + int size = 0; 296 + u8 fmt = cmd->buf_fmt >> 4; 297 + 298 + switch (fmt) { 299 + case SRP_NO_DATA_DESC: 300 + break; 301 + case SRP_DATA_DESC_DIRECT: 302 + size = sizeof(struct srp_direct_buf); 303 + break; 304 + case SRP_DATA_DESC_INDIRECT: 305 + size = sizeof(struct srp_indirect_buf) + 306 + sizeof(struct srp_direct_buf) * cmd->data_out_desc_cnt; 307 + break; 308 + default: 309 + eprintk("client error. Invalid data_out_format %x\n", fmt); 310 + break; 311 + } 312 + return size; 313 + } 314 + 315 + /* 316 + * TODO: this can be called multiple times for a single command if it 317 + * has very long data. 318 + */ 319 + int srp_transfer_data(struct scsi_cmnd *sc, struct srp_cmd *cmd, 320 + srp_rdma_t rdma_io, int dma_map, int ext_desc) 321 + { 322 + struct srp_direct_buf *md; 323 + struct srp_indirect_buf *id; 324 + enum dma_data_direction dir; 325 + int offset, err = 0; 326 + u8 format; 327 + 328 + offset = cmd->add_cdb_len * 4; 329 + 330 + dir = srp_cmd_direction(cmd); 331 + if (dir == DMA_FROM_DEVICE) 332 + offset += data_out_desc_size(cmd); 333 + 334 + if (dir == DMA_TO_DEVICE) 335 + format = cmd->buf_fmt >> 4; 336 + else 337 + format = cmd->buf_fmt & ((1U << 4) - 1); 338 + 339 + switch (format) { 340 + case SRP_NO_DATA_DESC: 341 + break; 342 + case SRP_DATA_DESC_DIRECT: 343 + md = (struct srp_direct_buf *) 344 + (cmd->add_data + offset); 345 + err = srp_direct_data(sc, md, dir, rdma_io, dma_map, ext_desc); 346 + break; 347 + case SRP_DATA_DESC_INDIRECT: 348 + id = (struct srp_indirect_buf *) 349 + (cmd->add_data + offset); 350 + err = srp_indirect_data(sc, cmd, id, dir, rdma_io, dma_map, 351 + ext_desc); 352 + break; 353 + default: 354 + eprintk("Unknown format %d %x\n", dir, format); 355 + break; 356 + } 357 + 358 + return err; 359 + } 360 + EXPORT_SYMBOL_GPL(srp_transfer_data); 361 + 362 + static int vscsis_data_length(struct srp_cmd *cmd, enum dma_data_direction dir) 363 + { 364 + struct srp_direct_buf *md; 365 + struct srp_indirect_buf *id; 366 + int len = 0, offset = cmd->add_cdb_len * 4; 367 + u8 fmt; 368 + 369 + if (dir == DMA_TO_DEVICE) 370 + fmt = cmd->buf_fmt >> 4; 371 + else { 372 + fmt = cmd->buf_fmt & ((1U << 4) - 1); 373 + offset += data_out_desc_size(cmd); 374 + } 375 + 376 + switch (fmt) { 377 + case SRP_NO_DATA_DESC: 378 + break; 379 + case SRP_DATA_DESC_DIRECT: 380 + md = (struct srp_direct_buf *) (cmd->add_data + offset); 381 + len = md->len; 382 + break; 383 + case SRP_DATA_DESC_INDIRECT: 384 + id = (struct srp_indirect_buf *) (cmd->add_data + offset); 385 + len = id->len; 386 + break; 387 + default: 388 + eprintk("invalid data format %x\n", fmt); 389 + break; 390 + } 391 + return len; 392 + } 393 + 394 + int srp_cmd_queue(struct Scsi_Host *shost, struct srp_cmd *cmd, void *info, 395 + u64 addr) 396 + { 397 + enum dma_data_direction dir; 398 + struct scsi_cmnd *sc; 399 + int tag, len, err; 400 + 401 + switch (cmd->task_attr) { 402 + case SRP_SIMPLE_TASK: 403 + tag = MSG_SIMPLE_TAG; 404 + break; 405 + case SRP_ORDERED_TASK: 406 + tag = MSG_ORDERED_TAG; 407 + break; 408 + case SRP_HEAD_TASK: 409 + tag = MSG_HEAD_TAG; 410 + break; 411 + default: 412 + eprintk("Task attribute %d not supported\n", cmd->task_attr); 413 + tag = MSG_ORDERED_TAG; 414 + } 415 + 416 + dir = srp_cmd_direction(cmd); 417 + len = vscsis_data_length(cmd, dir); 418 + 419 + dprintk("%p %x %lx %d %d %d %llx\n", info, cmd->cdb[0], 420 + cmd->lun, dir, len, tag, (unsigned long long) cmd->tag); 421 + 422 + sc = scsi_host_get_command(shost, dir, GFP_KERNEL); 423 + if (!sc) 424 + return -ENOMEM; 425 + 426 + sc->SCp.ptr = info; 427 + memcpy(sc->cmnd, cmd->cdb, MAX_COMMAND_SIZE); 428 + sc->request_bufflen = len; 429 + sc->request_buffer = (void *) (unsigned long) addr; 430 + sc->tag = tag; 431 + err = scsi_tgt_queue_command(sc, (struct scsi_lun *) &cmd->lun, cmd->tag); 432 + if (err) 433 + scsi_host_put_command(shost, sc); 434 + 435 + return err; 436 + } 437 + EXPORT_SYMBOL_GPL(srp_cmd_queue); 438 + 439 + MODULE_DESCRIPTION("SCSI RDAM Protocol lib functions"); 440 + MODULE_AUTHOR("FUJITA Tomonori"); 441 + MODULE_LICENSE("GPL");
+5 -1
drivers/scsi/lpfc/lpfc.h
··· 296 296 uint32_t cfg_cr_delay; 297 297 uint32_t cfg_cr_count; 298 298 uint32_t cfg_multi_ring_support; 299 + uint32_t cfg_multi_ring_rctl; 300 + uint32_t cfg_multi_ring_type; 299 301 uint32_t cfg_fdmi_on; 300 302 uint32_t cfg_discovery_threads; 301 303 uint32_t cfg_max_luns; 302 304 uint32_t cfg_poll; 303 305 uint32_t cfg_poll_tmo; 306 + uint32_t cfg_use_msi; 304 307 uint32_t cfg_sg_seg_cnt; 305 308 uint32_t cfg_sg_dma_buf_size; 309 + uint64_t cfg_soft_wwnn; 306 310 uint64_t cfg_soft_wwpn; 307 311 308 312 uint32_t dev_loss_tmo_changed; ··· 359 355 #define VPD_PORT 0x8 /* valid vpd port data */ 360 356 #define VPD_MASK 0xf /* mask for any vpd data */ 361 357 362 - uint8_t soft_wwpn_enable; 358 + uint8_t soft_wwn_enable; 363 359 364 360 struct timer_list fcp_poll_timer; 365 361 struct timer_list els_tmofunc;
+106 -12
drivers/scsi/lpfc/lpfc_attr.c
··· 552 552 static CLASS_DEVICE_ATTR(issue_reset, S_IWUSR, NULL, lpfc_issue_reset); 553 553 554 554 555 - static char *lpfc_soft_wwpn_key = "C99G71SL8032A"; 555 + static char *lpfc_soft_wwn_key = "C99G71SL8032A"; 556 556 557 557 static ssize_t 558 - lpfc_soft_wwpn_enable_store(struct class_device *cdev, const char *buf, 558 + lpfc_soft_wwn_enable_store(struct class_device *cdev, const char *buf, 559 559 size_t count) 560 560 { 561 561 struct Scsi_Host *host = class_to_shost(cdev); ··· 579 579 if (buf[cnt-1] == '\n') 580 580 cnt--; 581 581 582 - if ((cnt != strlen(lpfc_soft_wwpn_key)) || 583 - (strncmp(buf, lpfc_soft_wwpn_key, strlen(lpfc_soft_wwpn_key)) != 0)) 582 + if ((cnt != strlen(lpfc_soft_wwn_key)) || 583 + (strncmp(buf, lpfc_soft_wwn_key, strlen(lpfc_soft_wwn_key)) != 0)) 584 584 return -EINVAL; 585 585 586 - phba->soft_wwpn_enable = 1; 586 + phba->soft_wwn_enable = 1; 587 587 return count; 588 588 } 589 - static CLASS_DEVICE_ATTR(lpfc_soft_wwpn_enable, S_IWUSR, NULL, 590 - lpfc_soft_wwpn_enable_store); 589 + static CLASS_DEVICE_ATTR(lpfc_soft_wwn_enable, S_IWUSR, NULL, 590 + lpfc_soft_wwn_enable_store); 591 591 592 592 static ssize_t 593 593 lpfc_soft_wwpn_show(struct class_device *cdev, char *buf) ··· 613 613 if (buf[cnt-1] == '\n') 614 614 cnt--; 615 615 616 - if (!phba->soft_wwpn_enable || (cnt < 16) || (cnt > 18) || 616 + if (!phba->soft_wwn_enable || (cnt < 16) || (cnt > 18) || 617 617 ((cnt == 17) && (*buf++ != 'x')) || 618 618 ((cnt == 18) && ((*buf++ != '0') || (*buf++ != 'x')))) 619 619 return -EINVAL; 620 620 621 - phba->soft_wwpn_enable = 0; 621 + phba->soft_wwn_enable = 0; 622 622 623 623 memset(wwpn, 0, sizeof(wwpn)); 624 624 ··· 639 639 } 640 640 phba->cfg_soft_wwpn = wwn_to_u64(wwpn); 641 641 fc_host_port_name(host) = phba->cfg_soft_wwpn; 642 + if (phba->cfg_soft_wwnn) 643 + fc_host_node_name(host) = phba->cfg_soft_wwnn; 642 644 643 645 dev_printk(KERN_NOTICE, &phba->pcidev->dev, 644 646 "lpfc%d: Reinitializing to use soft_wwpn\n", phba->brd_no); ··· 665 663 } 666 664 static CLASS_DEVICE_ATTR(lpfc_soft_wwpn, S_IRUGO | S_IWUSR,\ 667 665 lpfc_soft_wwpn_show, lpfc_soft_wwpn_store); 666 + 667 + static ssize_t 668 + lpfc_soft_wwnn_show(struct class_device *cdev, char *buf) 669 + { 670 + struct Scsi_Host *host = class_to_shost(cdev); 671 + struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata; 672 + return snprintf(buf, PAGE_SIZE, "0x%llx\n", 673 + (unsigned long long)phba->cfg_soft_wwnn); 674 + } 675 + 676 + 677 + static ssize_t 678 + lpfc_soft_wwnn_store(struct class_device *cdev, const char *buf, size_t count) 679 + { 680 + struct Scsi_Host *host = class_to_shost(cdev); 681 + struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata; 682 + unsigned int i, j, cnt=count; 683 + u8 wwnn[8]; 684 + 685 + /* count may include a LF at end of string */ 686 + if (buf[cnt-1] == '\n') 687 + cnt--; 688 + 689 + if (!phba->soft_wwn_enable || (cnt < 16) || (cnt > 18) || 690 + ((cnt == 17) && (*buf++ != 'x')) || 691 + ((cnt == 18) && ((*buf++ != '0') || (*buf++ != 'x')))) 692 + return -EINVAL; 693 + 694 + /* 695 + * Allow wwnn to be set many times, as long as the enable is set. 696 + * However, once the wwpn is set, everything locks. 697 + */ 698 + 699 + memset(wwnn, 0, sizeof(wwnn)); 700 + 701 + /* Validate and store the new name */ 702 + for (i=0, j=0; i < 16; i++) { 703 + if ((*buf >= 'a') && (*buf <= 'f')) 704 + j = ((j << 4) | ((*buf++ -'a') + 10)); 705 + else if ((*buf >= 'A') && (*buf <= 'F')) 706 + j = ((j << 4) | ((*buf++ -'A') + 10)); 707 + else if ((*buf >= '0') && (*buf <= '9')) 708 + j = ((j << 4) | (*buf++ -'0')); 709 + else 710 + return -EINVAL; 711 + if (i % 2) { 712 + wwnn[i/2] = j & 0xff; 713 + j = 0; 714 + } 715 + } 716 + phba->cfg_soft_wwnn = wwn_to_u64(wwnn); 717 + 718 + dev_printk(KERN_NOTICE, &phba->pcidev->dev, 719 + "lpfc%d: soft_wwnn set. Value will take effect upon " 720 + "setting of the soft_wwpn\n", phba->brd_no); 721 + 722 + return count; 723 + } 724 + static CLASS_DEVICE_ATTR(lpfc_soft_wwnn, S_IRUGO | S_IWUSR,\ 725 + lpfc_soft_wwnn_show, lpfc_soft_wwnn_store); 668 726 669 727 670 728 static int lpfc_poll = 0; ··· 864 802 # LOG_MBOX 0x4 Mailbox events 865 803 # LOG_INIT 0x8 Initialization events 866 804 # LOG_LINK_EVENT 0x10 Link events 867 - # LOG_IP 0x20 IP traffic history 868 805 # LOG_FCP 0x40 FCP traffic history 869 806 # LOG_NODE 0x80 Node table events 870 807 # LOG_MISC 0x400 Miscellaneous events 871 808 # LOG_SLI 0x800 SLI events 872 - # LOG_CHK_COND 0x1000 FCP Check condition flag 809 + # LOG_FCP_ERROR 0x1000 Only log FCP errors 873 810 # LOG_LIBDFC 0x2000 LIBDFC events 874 811 # LOG_ALL_MSG 0xffff LOG all messages 875 812 */ ··· 977 916 "SLI rings to spread IOCB entries across"); 978 917 979 918 /* 919 + # lpfc_multi_ring_rctl: If lpfc_multi_ring_support is enabled, this 920 + # identifies what rctl value to configure the additional ring for. 921 + # Value range is [1,0xff]. Default value is 4 (Unsolicated Data). 922 + */ 923 + LPFC_ATTR_R(multi_ring_rctl, FC_UNSOL_DATA, 1, 924 + 255, "Identifies RCTL for additional ring configuration"); 925 + 926 + /* 927 + # lpfc_multi_ring_type: If lpfc_multi_ring_support is enabled, this 928 + # identifies what type value to configure the additional ring for. 929 + # Value range is [1,0xff]. Default value is 5 (LLC/SNAP). 930 + */ 931 + LPFC_ATTR_R(multi_ring_type, FC_LLC_SNAP, 1, 932 + 255, "Identifies TYPE for additional ring configuration"); 933 + 934 + /* 980 935 # lpfc_fdmi_on: controls FDMI support. 981 936 # 0 = no FDMI support 982 937 # 1 = support FDMI without attribute of hostname ··· 1023 946 LPFC_ATTR_RW(poll_tmo, 10, 1, 255, 1024 947 "Milliseconds driver will wait between polling FCP ring"); 1025 948 949 + /* 950 + # lpfc_use_msi: Use MSI (Message Signaled Interrupts) in systems that 951 + # support this feature 952 + # 0 = MSI disabled (default) 953 + # 1 = MSI enabled 954 + # Value range is [0,1]. Default value is 0. 955 + */ 956 + LPFC_ATTR_R(use_msi, 0, 0, 1, "Use Message Signaled Interrupts, if possible"); 957 + 1026 958 1027 959 struct class_device_attribute *lpfc_host_attrs[] = { 1028 960 &class_device_attr_info, ··· 1060 974 &class_device_attr_lpfc_cr_delay, 1061 975 &class_device_attr_lpfc_cr_count, 1062 976 &class_device_attr_lpfc_multi_ring_support, 977 + &class_device_attr_lpfc_multi_ring_rctl, 978 + &class_device_attr_lpfc_multi_ring_type, 1063 979 &class_device_attr_lpfc_fdmi_on, 1064 980 &class_device_attr_lpfc_max_luns, 1065 981 &class_device_attr_nport_evt_cnt, ··· 1070 982 &class_device_attr_issue_reset, 1071 983 &class_device_attr_lpfc_poll, 1072 984 &class_device_attr_lpfc_poll_tmo, 985 + &class_device_attr_lpfc_use_msi, 986 + &class_device_attr_lpfc_soft_wwnn, 1073 987 &class_device_attr_lpfc_soft_wwpn, 1074 - &class_device_attr_lpfc_soft_wwpn_enable, 988 + &class_device_attr_lpfc_soft_wwn_enable, 1075 989 NULL, 1076 990 }; 1077 991 ··· 1861 1771 lpfc_cr_delay_init(phba, lpfc_cr_delay); 1862 1772 lpfc_cr_count_init(phba, lpfc_cr_count); 1863 1773 lpfc_multi_ring_support_init(phba, lpfc_multi_ring_support); 1774 + lpfc_multi_ring_rctl_init(phba, lpfc_multi_ring_rctl); 1775 + lpfc_multi_ring_type_init(phba, lpfc_multi_ring_type); 1864 1776 lpfc_lun_queue_depth_init(phba, lpfc_lun_queue_depth); 1865 1777 lpfc_fcp_class_init(phba, lpfc_fcp_class); 1866 1778 lpfc_use_adisc_init(phba, lpfc_use_adisc); ··· 1874 1782 lpfc_discovery_threads_init(phba, lpfc_discovery_threads); 1875 1783 lpfc_max_luns_init(phba, lpfc_max_luns); 1876 1784 lpfc_poll_tmo_init(phba, lpfc_poll_tmo); 1785 + lpfc_use_msi_init(phba, lpfc_use_msi); 1877 1786 lpfc_devloss_tmo_init(phba, lpfc_devloss_tmo); 1878 1787 lpfc_nodev_tmo_init(phba, lpfc_nodev_tmo); 1879 1788 phba->cfg_poll = lpfc_poll; 1789 + phba->cfg_soft_wwnn = 0L; 1880 1790 phba->cfg_soft_wwpn = 0L; 1881 1791 1882 1792 /*
+23 -1
drivers/scsi/lpfc/lpfc_ct.c
··· 558 558 return; 559 559 } 560 560 561 + static void 562 + lpfc_cmpl_ct_cmd_rff_id(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb, 563 + struct lpfc_iocbq * rspiocb) 564 + { 565 + lpfc_cmpl_ct_cmd_rft_id(phba, cmdiocb, rspiocb); 566 + return; 567 + } 568 + 561 569 void 562 570 lpfc_get_hba_sym_node_name(struct lpfc_hba * phba, uint8_t * symbp) 563 571 { ··· 637 629 bpl->tus.f.bdeSize = RNN_REQUEST_SZ; 638 630 else if (cmdcode == SLI_CTNS_RSNN_NN) 639 631 bpl->tus.f.bdeSize = RSNN_REQUEST_SZ; 632 + else if (cmdcode == SLI_CTNS_RFF_ID) 633 + bpl->tus.f.bdeSize = RFF_REQUEST_SZ; 640 634 else 641 635 bpl->tus.f.bdeSize = 0; 642 636 bpl->tus.w = le32_to_cpu(bpl->tus.w); ··· 668 658 CtReq->un.rft.PortId = be32_to_cpu(phba->fc_myDID); 669 659 CtReq->un.rft.fcpReg = 1; 670 660 cmpl = lpfc_cmpl_ct_cmd_rft_id; 661 + break; 662 + 663 + case SLI_CTNS_RFF_ID: 664 + CtReq->CommandResponse.bits.CmdRsp = 665 + be16_to_cpu(SLI_CTNS_RFF_ID); 666 + CtReq->un.rff.PortId = be32_to_cpu(phba->fc_myDID); 667 + CtReq->un.rff.feature_res = 0; 668 + CtReq->un.rff.feature_tgt = 0; 669 + CtReq->un.rff.type_code = FC_FCP_DATA; 670 + CtReq->un.rff.feature_init = 1; 671 + cmpl = lpfc_cmpl_ct_cmd_rff_id; 671 672 break; 672 673 673 674 case SLI_CTNS_RNN_ID: ··· 955 934 ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); 956 935 ae->ad.bits.AttrType = be16_to_cpu(OS_NAME_VERSION); 957 936 sprintf(ae->un.OsNameVersion, "%s %s %s", 958 - init_utsname()->sysname, init_utsname()->release, 937 + init_utsname()->sysname, 938 + init_utsname()->release, 959 939 init_utsname()->version); 960 940 len = strlen(ae->un.OsNameVersion); 961 941 len += (len & 3) ? (4 - (len & 3)) : 4;
+28 -6
drivers/scsi/lpfc/lpfc_els.c
··· 243 243 struct serv_parm *sp, IOCB_t *irsp) 244 244 { 245 245 LPFC_MBOXQ_t *mbox; 246 + struct lpfc_dmabuf *mp; 246 247 int rc; 247 248 248 249 spin_lock_irq(phba->host->host_lock); ··· 308 307 309 308 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT | MBX_STOP_IOCB); 310 309 if (rc == MBX_NOT_FINISHED) 311 - goto fail_free_mbox; 310 + goto fail_issue_reg_login; 312 311 313 312 return 0; 314 313 314 + fail_issue_reg_login: 315 + mp = (struct lpfc_dmabuf *) mbox->context1; 316 + lpfc_mbuf_free(phba, mp->virt, mp->phys); 317 + kfree(mp); 315 318 fail_free_mbox: 316 319 mempool_free(mbox, phba->mbox_mem_pool); 317 320 fail: ··· 661 656 struct serv_parm *sp; 662 657 uint8_t name[sizeof (struct lpfc_name)]; 663 658 uint32_t rc; 659 + 660 + /* Fabric nodes can have the same WWPN so we don't bother searching 661 + * by WWPN. Just return the ndlp that was given to us. 662 + */ 663 + if (ndlp->nlp_type & NLP_FABRIC) 664 + return ndlp; 664 665 665 666 lp = (uint32_t *) prsp->virt; 666 667 sp = (struct serv_parm *) ((uint8_t *) lp + sizeof (uint32_t)); ··· 1133 1122 mempool_free(mbox, 1134 1123 phba->mbox_mem_pool); 1135 1124 lpfc_disc_flush_list(phba); 1136 - psli->ring[(psli->ip_ring)]. 1125 + psli->ring[(psli->extra_ring)]. 1137 1126 flag &= 1138 1127 ~LPFC_STOP_IOCB_EVENT; 1139 1128 psli->ring[(psli->fcp_ring)]. ··· 1862 1851 IOCB_t *irsp; 1863 1852 struct lpfc_nodelist *ndlp; 1864 1853 LPFC_MBOXQ_t *mbox = NULL; 1854 + struct lpfc_dmabuf *mp; 1865 1855 1866 1856 irsp = &rspiocb->iocb; 1867 1857 ··· 1874 1862 /* Check to see if link went down during discovery */ 1875 1863 if ((lpfc_els_chk_latt(phba)) || !ndlp) { 1876 1864 if (mbox) { 1865 + mp = (struct lpfc_dmabuf *) mbox->context1; 1866 + if (mp) { 1867 + lpfc_mbuf_free(phba, mp->virt, mp->phys); 1868 + kfree(mp); 1869 + } 1877 1870 mempool_free( mbox, phba->mbox_mem_pool); 1878 1871 } 1879 1872 goto out; ··· 1910 1893 } 1911 1894 /* NOTE: we should have messages for unsuccessful 1912 1895 reglogin */ 1913 - mempool_free( mbox, phba->mbox_mem_pool); 1914 1896 } else { 1915 - mempool_free( mbox, phba->mbox_mem_pool); 1916 1897 /* Do not call NO_LIST for lpfc_els_abort'ed ELS cmds */ 1917 1898 if (!((irsp->ulpStatus == IOSTAT_LOCAL_REJECT) && 1918 1899 ((irsp->un.ulpWord[4] == IOERR_SLI_ABORTED) || ··· 1922 1907 } 1923 1908 } 1924 1909 } 1910 + mp = (struct lpfc_dmabuf *) mbox->context1; 1911 + if (mp) { 1912 + lpfc_mbuf_free(phba, mp->virt, mp->phys); 1913 + kfree(mp); 1914 + } 1915 + mempool_free(mbox, phba->mbox_mem_pool); 1925 1916 } 1926 1917 out: 1927 1918 if (ndlp) { ··· 2665 2644 ndlp->nlp_type |= NLP_FABRIC; 2666 2645 ndlp->nlp_prev_state = ndlp->nlp_state; 2667 2646 ndlp->nlp_state = NLP_STE_PLOGI_ISSUE; 2647 + lpfc_nlp_list(phba, ndlp, NLP_PLOGI_LIST); 2668 2648 lpfc_issue_els_plogi(phba, NameServer_DID, 0); 2669 2649 /* Wait for NameServer login cmpl before we can 2670 2650 continue */ ··· 3061 3039 /* FARP-REQ received from DID <did> */ 3062 3040 lpfc_printf_log(phba, 3063 3041 KERN_INFO, 3064 - LOG_IP, 3042 + LOG_ELS, 3065 3043 "%d:0601 FARP-REQ received from DID x%x\n", 3066 3044 phba->brd_no, did); 3067 3045 ··· 3123 3101 /* FARP-RSP received from DID <did> */ 3124 3102 lpfc_printf_log(phba, 3125 3103 KERN_INFO, 3126 - LOG_IP, 3104 + LOG_ELS, 3127 3105 "%d:0600 FARP-RSP received from DID x%x\n", 3128 3106 phba->brd_no, did); 3129 3107
+49 -180
drivers/scsi/lpfc/lpfc_hbadisc.c
··· 525 525 psli = &phba->sli; 526 526 mb = &pmb->mb; 527 527 /* Since we don't do discovery right now, turn these off here */ 528 - psli->ring[psli->ip_ring].flag &= ~LPFC_STOP_IOCB_EVENT; 528 + psli->ring[psli->extra_ring].flag &= ~LPFC_STOP_IOCB_EVENT; 529 529 psli->ring[psli->fcp_ring].flag &= ~LPFC_STOP_IOCB_EVENT; 530 530 psli->ring[psli->next_ring].flag &= ~LPFC_STOP_IOCB_EVENT; 531 531 ··· 641 641 if (rc == MBX_NOT_FINISHED) { 642 642 mempool_free(pmb, phba->mbox_mem_pool); 643 643 lpfc_disc_flush_list(phba); 644 - psli->ring[(psli->ip_ring)].flag &= ~LPFC_STOP_IOCB_EVENT; 644 + psli->ring[(psli->extra_ring)].flag &= ~LPFC_STOP_IOCB_EVENT; 645 645 psli->ring[(psli->fcp_ring)].flag &= ~LPFC_STOP_IOCB_EVENT; 646 646 psli->ring[(psli->next_ring)].flag &= ~LPFC_STOP_IOCB_EVENT; 647 647 phba->hba_state = LPFC_HBA_READY; ··· 672 672 673 673 memcpy((uint8_t *) & phba->fc_sparam, (uint8_t *) mp->virt, 674 674 sizeof (struct serv_parm)); 675 + if (phba->cfg_soft_wwnn) 676 + u64_to_wwn(phba->cfg_soft_wwnn, phba->fc_sparam.nodeName.u.wwn); 675 677 if (phba->cfg_soft_wwpn) 676 678 u64_to_wwn(phba->cfg_soft_wwpn, phba->fc_sparam.portName.u.wwn); 677 679 memcpy((uint8_t *) & phba->fc_nodename, ··· 698 696 == MBX_NOT_FINISHED) { 699 697 mempool_free( pmb, phba->mbox_mem_pool); 700 698 lpfc_disc_flush_list(phba); 701 - psli->ring[(psli->ip_ring)].flag &= 699 + psli->ring[(psli->extra_ring)].flag &= 702 700 ~LPFC_STOP_IOCB_EVENT; 703 701 psli->ring[(psli->fcp_ring)].flag &= 704 702 ~LPFC_STOP_IOCB_EVENT; ··· 717 715 { 718 716 int i; 719 717 LPFC_MBOXQ_t *sparam_mbox, *cfglink_mbox; 718 + struct lpfc_dmabuf *mp; 719 + int rc; 720 + 720 721 sparam_mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); 721 722 cfglink_mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); 722 723 ··· 798 793 if (sparam_mbox) { 799 794 lpfc_read_sparam(phba, sparam_mbox); 800 795 sparam_mbox->mbox_cmpl = lpfc_mbx_cmpl_read_sparam; 801 - lpfc_sli_issue_mbox(phba, sparam_mbox, 796 + rc = lpfc_sli_issue_mbox(phba, sparam_mbox, 802 797 (MBX_NOWAIT | MBX_STOP_IOCB)); 798 + if (rc == MBX_NOT_FINISHED) { 799 + mp = (struct lpfc_dmabuf *) sparam_mbox->context1; 800 + lpfc_mbuf_free(phba, mp->virt, mp->phys); 801 + kfree(mp); 802 + mempool_free(sparam_mbox, phba->mbox_mem_pool); 803 + if (cfglink_mbox) 804 + mempool_free(cfglink_mbox, phba->mbox_mem_pool); 805 + return; 806 + } 803 807 } 804 808 805 809 if (cfglink_mbox) { 806 810 phba->hba_state = LPFC_LOCAL_CFG_LINK; 807 811 lpfc_config_link(phba, cfglink_mbox); 808 812 cfglink_mbox->mbox_cmpl = lpfc_mbx_cmpl_local_config_link; 809 - lpfc_sli_issue_mbox(phba, cfglink_mbox, 813 + rc = lpfc_sli_issue_mbox(phba, cfglink_mbox, 810 814 (MBX_NOWAIT | MBX_STOP_IOCB)); 815 + if (rc == MBX_NOT_FINISHED) 816 + mempool_free(cfglink_mbox, phba->mbox_mem_pool); 811 817 } 812 818 } 813 819 ··· 1083 1067 lpfc_ns_cmd(phba, ndlp, SLI_CTNS_RNN_ID); 1084 1068 lpfc_ns_cmd(phba, ndlp, SLI_CTNS_RSNN_NN); 1085 1069 lpfc_ns_cmd(phba, ndlp, SLI_CTNS_RFT_ID); 1070 + lpfc_ns_cmd(phba, ndlp, SLI_CTNS_RFF_ID); 1086 1071 } 1087 1072 1088 1073 phba->fc_ns_retry = 0; ··· 1440 1423 if (iocb->context1 == (uint8_t *) ndlp) 1441 1424 return 1; 1442 1425 } 1443 - } else if (pring->ringno == psli->ip_ring) { 1426 + } else if (pring->ringno == psli->extra_ring) { 1444 1427 1445 1428 } else if (pring->ringno == psli->fcp_ring) { 1446 1429 /* Skip match check if waiting to relogin to FCP target */ ··· 1697 1680 struct lpfc_nodelist * 1698 1681 lpfc_findnode_did(struct lpfc_hba * phba, uint32_t order, uint32_t did) 1699 1682 { 1700 - struct lpfc_nodelist *ndlp, *next_ndlp; 1683 + struct lpfc_nodelist *ndlp; 1684 + struct list_head *lists[]={&phba->fc_nlpunmap_list, 1685 + &phba->fc_nlpmap_list, 1686 + &phba->fc_plogi_list, 1687 + &phba->fc_adisc_list, 1688 + &phba->fc_reglogin_list, 1689 + &phba->fc_prli_list, 1690 + &phba->fc_npr_list, 1691 + &phba->fc_unused_list}; 1692 + uint32_t search[]={NLP_SEARCH_UNMAPPED, 1693 + NLP_SEARCH_MAPPED, 1694 + NLP_SEARCH_PLOGI, 1695 + NLP_SEARCH_ADISC, 1696 + NLP_SEARCH_REGLOGIN, 1697 + NLP_SEARCH_PRLI, 1698 + NLP_SEARCH_NPR, 1699 + NLP_SEARCH_UNUSED}; 1700 + int i; 1701 1701 uint32_t data1; 1702 1702 1703 1703 spin_lock_irq(phba->host->host_lock); 1704 - if (order & NLP_SEARCH_UNMAPPED) { 1705 - list_for_each_entry_safe(ndlp, next_ndlp, 1706 - &phba->fc_nlpunmap_list, nlp_listp) { 1704 + for (i = 0; i < ARRAY_SIZE(lists); i++ ) { 1705 + if (!(order & search[i])) 1706 + continue; 1707 + list_for_each_entry(ndlp, lists[i], nlp_listp) { 1707 1708 if (lpfc_matchdid(phba, ndlp, did)) { 1708 1709 data1 = (((uint32_t) ndlp->nlp_state << 24) | 1709 1710 ((uint32_t) ndlp->nlp_xri << 16) | 1710 1711 ((uint32_t) ndlp->nlp_type << 8) | 1711 1712 ((uint32_t) ndlp->nlp_rpi & 0xff)); 1712 - /* FIND node DID unmapped */ 1713 1713 lpfc_printf_log(phba, KERN_INFO, LOG_NODE, 1714 - "%d:0929 FIND node DID unmapped" 1714 + "%d:0929 FIND node DID " 1715 1715 " Data: x%p x%x x%x x%x\n", 1716 1716 phba->brd_no, 1717 1717 ndlp, ndlp->nlp_DID, ··· 1738 1704 } 1739 1705 } 1740 1706 } 1741 - 1742 - if (order & NLP_SEARCH_MAPPED) { 1743 - list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_nlpmap_list, 1744 - nlp_listp) { 1745 - if (lpfc_matchdid(phba, ndlp, did)) { 1746 - 1747 - data1 = (((uint32_t) ndlp->nlp_state << 24) | 1748 - ((uint32_t) ndlp->nlp_xri << 16) | 1749 - ((uint32_t) ndlp->nlp_type << 8) | 1750 - ((uint32_t) ndlp->nlp_rpi & 0xff)); 1751 - /* FIND node DID mapped */ 1752 - lpfc_printf_log(phba, KERN_INFO, LOG_NODE, 1753 - "%d:0930 FIND node DID mapped " 1754 - "Data: x%p x%x x%x x%x\n", 1755 - phba->brd_no, 1756 - ndlp, ndlp->nlp_DID, 1757 - ndlp->nlp_flag, data1); 1758 - spin_unlock_irq(phba->host->host_lock); 1759 - return ndlp; 1760 - } 1761 - } 1762 - } 1763 - 1764 - if (order & NLP_SEARCH_PLOGI) { 1765 - list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_plogi_list, 1766 - nlp_listp) { 1767 - if (lpfc_matchdid(phba, ndlp, did)) { 1768 - 1769 - data1 = (((uint32_t) ndlp->nlp_state << 24) | 1770 - ((uint32_t) ndlp->nlp_xri << 16) | 1771 - ((uint32_t) ndlp->nlp_type << 8) | 1772 - ((uint32_t) ndlp->nlp_rpi & 0xff)); 1773 - /* LOG change to PLOGI */ 1774 - /* FIND node DID plogi */ 1775 - lpfc_printf_log(phba, KERN_INFO, LOG_NODE, 1776 - "%d:0908 FIND node DID plogi " 1777 - "Data: x%p x%x x%x x%x\n", 1778 - phba->brd_no, 1779 - ndlp, ndlp->nlp_DID, 1780 - ndlp->nlp_flag, data1); 1781 - spin_unlock_irq(phba->host->host_lock); 1782 - return ndlp; 1783 - } 1784 - } 1785 - } 1786 - 1787 - if (order & NLP_SEARCH_ADISC) { 1788 - list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_adisc_list, 1789 - nlp_listp) { 1790 - if (lpfc_matchdid(phba, ndlp, did)) { 1791 - 1792 - data1 = (((uint32_t) ndlp->nlp_state << 24) | 1793 - ((uint32_t) ndlp->nlp_xri << 16) | 1794 - ((uint32_t) ndlp->nlp_type << 8) | 1795 - ((uint32_t) ndlp->nlp_rpi & 0xff)); 1796 - /* LOG change to ADISC */ 1797 - /* FIND node DID adisc */ 1798 - lpfc_printf_log(phba, KERN_INFO, LOG_NODE, 1799 - "%d:0931 FIND node DID adisc " 1800 - "Data: x%p x%x x%x x%x\n", 1801 - phba->brd_no, 1802 - ndlp, ndlp->nlp_DID, 1803 - ndlp->nlp_flag, data1); 1804 - spin_unlock_irq(phba->host->host_lock); 1805 - return ndlp; 1806 - } 1807 - } 1808 - } 1809 - 1810 - if (order & NLP_SEARCH_REGLOGIN) { 1811 - list_for_each_entry_safe(ndlp, next_ndlp, 1812 - &phba->fc_reglogin_list, nlp_listp) { 1813 - if (lpfc_matchdid(phba, ndlp, did)) { 1814 - 1815 - data1 = (((uint32_t) ndlp->nlp_state << 24) | 1816 - ((uint32_t) ndlp->nlp_xri << 16) | 1817 - ((uint32_t) ndlp->nlp_type << 8) | 1818 - ((uint32_t) ndlp->nlp_rpi & 0xff)); 1819 - /* LOG change to REGLOGIN */ 1820 - /* FIND node DID reglogin */ 1821 - lpfc_printf_log(phba, KERN_INFO, LOG_NODE, 1822 - "%d:0901 FIND node DID reglogin" 1823 - " Data: x%p x%x x%x x%x\n", 1824 - phba->brd_no, 1825 - ndlp, ndlp->nlp_DID, 1826 - ndlp->nlp_flag, data1); 1827 - spin_unlock_irq(phba->host->host_lock); 1828 - return ndlp; 1829 - } 1830 - } 1831 - } 1832 - 1833 - if (order & NLP_SEARCH_PRLI) { 1834 - list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_prli_list, 1835 - nlp_listp) { 1836 - if (lpfc_matchdid(phba, ndlp, did)) { 1837 - 1838 - data1 = (((uint32_t) ndlp->nlp_state << 24) | 1839 - ((uint32_t) ndlp->nlp_xri << 16) | 1840 - ((uint32_t) ndlp->nlp_type << 8) | 1841 - ((uint32_t) ndlp->nlp_rpi & 0xff)); 1842 - /* LOG change to PRLI */ 1843 - /* FIND node DID prli */ 1844 - lpfc_printf_log(phba, KERN_INFO, LOG_NODE, 1845 - "%d:0902 FIND node DID prli " 1846 - "Data: x%p x%x x%x x%x\n", 1847 - phba->brd_no, 1848 - ndlp, ndlp->nlp_DID, 1849 - ndlp->nlp_flag, data1); 1850 - spin_unlock_irq(phba->host->host_lock); 1851 - return ndlp; 1852 - } 1853 - } 1854 - } 1855 - 1856 - if (order & NLP_SEARCH_NPR) { 1857 - list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_npr_list, 1858 - nlp_listp) { 1859 - if (lpfc_matchdid(phba, ndlp, did)) { 1860 - 1861 - data1 = (((uint32_t) ndlp->nlp_state << 24) | 1862 - ((uint32_t) ndlp->nlp_xri << 16) | 1863 - ((uint32_t) ndlp->nlp_type << 8) | 1864 - ((uint32_t) ndlp->nlp_rpi & 0xff)); 1865 - /* LOG change to NPR */ 1866 - /* FIND node DID npr */ 1867 - lpfc_printf_log(phba, KERN_INFO, LOG_NODE, 1868 - "%d:0903 FIND node DID npr " 1869 - "Data: x%p x%x x%x x%x\n", 1870 - phba->brd_no, 1871 - ndlp, ndlp->nlp_DID, 1872 - ndlp->nlp_flag, data1); 1873 - spin_unlock_irq(phba->host->host_lock); 1874 - return ndlp; 1875 - } 1876 - } 1877 - } 1878 - 1879 - if (order & NLP_SEARCH_UNUSED) { 1880 - list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_adisc_list, 1881 - nlp_listp) { 1882 - if (lpfc_matchdid(phba, ndlp, did)) { 1883 - 1884 - data1 = (((uint32_t) ndlp->nlp_state << 24) | 1885 - ((uint32_t) ndlp->nlp_xri << 16) | 1886 - ((uint32_t) ndlp->nlp_type << 8) | 1887 - ((uint32_t) ndlp->nlp_rpi & 0xff)); 1888 - /* LOG change to UNUSED */ 1889 - /* FIND node DID unused */ 1890 - lpfc_printf_log(phba, KERN_INFO, LOG_NODE, 1891 - "%d:0905 FIND node DID unused " 1892 - "Data: x%p x%x x%x x%x\n", 1893 - phba->brd_no, 1894 - ndlp, ndlp->nlp_DID, 1895 - ndlp->nlp_flag, data1); 1896 - spin_unlock_irq(phba->host->host_lock); 1897 - return ndlp; 1898 - } 1899 - } 1900 - } 1901 - 1902 1707 spin_unlock_irq(phba->host->host_lock); 1903 1708 1904 1709 /* FIND node did <did> NOT FOUND */ 1905 - lpfc_printf_log(phba, 1906 - KERN_INFO, 1907 - LOG_NODE, 1710 + lpfc_printf_log(phba, KERN_INFO, LOG_NODE, 1908 1711 "%d:0932 FIND node did x%x NOT FOUND Data: x%x\n", 1909 1712 phba->brd_no, did, order); 1910 - 1911 - /* no match found */ 1912 1713 return NULL; 1913 1714 } 1914 1715 ··· 1905 2036 if (rc == MBX_NOT_FINISHED) { 1906 2037 mempool_free( mbox, phba->mbox_mem_pool); 1907 2038 lpfc_disc_flush_list(phba); 1908 - psli->ring[(psli->ip_ring)].flag &= 2039 + psli->ring[(psli->extra_ring)].flag &= 1909 2040 ~LPFC_STOP_IOCB_EVENT; 1910 2041 psli->ring[(psli->fcp_ring)].flag &= 1911 2042 ~LPFC_STOP_IOCB_EVENT; ··· 2284 2415 2285 2416 if (clrlaerr) { 2286 2417 lpfc_disc_flush_list(phba); 2287 - psli->ring[(psli->ip_ring)].flag &= ~LPFC_STOP_IOCB_EVENT; 2418 + psli->ring[(psli->extra_ring)].flag &= ~LPFC_STOP_IOCB_EVENT; 2288 2419 psli->ring[(psli->fcp_ring)].flag &= ~LPFC_STOP_IOCB_EVENT; 2289 2420 psli->ring[(psli->next_ring)].flag &= ~LPFC_STOP_IOCB_EVENT; 2290 2421 phba->hba_state = LPFC_HBA_READY;
+26 -9
drivers/scsi/lpfc/lpfc_hw.h
··· 42 42 #define FCELSSIZE 1024 /* maximum ELS transfer size */ 43 43 44 44 #define LPFC_FCP_RING 0 /* ring 0 for FCP initiator commands */ 45 - #define LPFC_IP_RING 1 /* ring 1 for IP commands */ 45 + #define LPFC_EXTRA_RING 1 /* ring 1 for other protocols */ 46 46 #define LPFC_ELS_RING 2 /* ring 2 for ELS commands */ 47 47 #define LPFC_FCP_NEXT_RING 3 48 48 49 49 #define SLI2_IOCB_CMD_R0_ENTRIES 172 /* SLI-2 FCP command ring entries */ 50 50 #define SLI2_IOCB_RSP_R0_ENTRIES 134 /* SLI-2 FCP response ring entries */ 51 - #define SLI2_IOCB_CMD_R1_ENTRIES 4 /* SLI-2 IP command ring entries */ 52 - #define SLI2_IOCB_RSP_R1_ENTRIES 4 /* SLI-2 IP response ring entries */ 51 + #define SLI2_IOCB_CMD_R1_ENTRIES 4 /* SLI-2 extra command ring entries */ 52 + #define SLI2_IOCB_RSP_R1_ENTRIES 4 /* SLI-2 extra response ring entries */ 53 53 #define SLI2_IOCB_CMD_R1XTRA_ENTRIES 36 /* SLI-2 extra FCP cmd ring entries */ 54 54 #define SLI2_IOCB_RSP_R1XTRA_ENTRIES 52 /* SLI-2 extra FCP rsp ring entries */ 55 55 #define SLI2_IOCB_CMD_R2_ENTRIES 20 /* SLI-2 ELS command ring entries */ ··· 121 121 122 122 uint32_t rsvd[7]; 123 123 } rft; 124 + struct rff { 125 + uint32_t PortId; 126 + uint8_t reserved[2]; 127 + #ifdef __BIG_ENDIAN_BITFIELD 128 + uint8_t feature_res:6; 129 + uint8_t feature_init:1; 130 + uint8_t feature_tgt:1; 131 + #else /* __LITTLE_ENDIAN_BITFIELD */ 132 + uint8_t feature_tgt:1; 133 + uint8_t feature_init:1; 134 + uint8_t feature_res:6; 135 + #endif 136 + uint8_t type_code; /* type=8 for FCP */ 137 + } rff; 124 138 struct rnn { 125 139 uint32_t PortId; /* For RNN_ID requests */ 126 140 uint8_t wwnn[8]; ··· 150 136 #define SLI_CT_REVISION 1 151 137 #define GID_REQUEST_SZ (sizeof(struct lpfc_sli_ct_request) - 260) 152 138 #define RFT_REQUEST_SZ (sizeof(struct lpfc_sli_ct_request) - 228) 139 + #define RFF_REQUEST_SZ (sizeof(struct lpfc_sli_ct_request) - 235) 153 140 #define RNN_REQUEST_SZ (sizeof(struct lpfc_sli_ct_request) - 252) 154 141 #define RSNN_REQUEST_SZ (sizeof(struct lpfc_sli_ct_request)) 155 142 ··· 240 225 #define SLI_CTNS_RNN_ID 0x0213 241 226 #define SLI_CTNS_RCS_ID 0x0214 242 227 #define SLI_CTNS_RFT_ID 0x0217 228 + #define SLI_CTNS_RFF_ID 0x021F 243 229 #define SLI_CTNS_RSPN_ID 0x0218 244 230 #define SLI_CTNS_RPT_ID 0x021A 245 231 #define SLI_CTNS_RIP_NN 0x0235 ··· 1105 1089 #define PCI_DEVICE_ID_ZEPHYR_SCSP 0xfe11 1106 1090 #define PCI_DEVICE_ID_ZEPHYR_DCSP 0xfe12 1107 1091 1108 - #define PCI_SUBSYSTEM_ID_LP11000S 0xfc11 1109 - #define PCI_SUBSYSTEM_ID_LP11002S 0xfc12 1110 - #define PCI_SUBSYSTEM_ID_LPE11000S 0xfc21 1111 - #define PCI_SUBSYSTEM_ID_LPE11002S 0xfc22 1112 - #define PCI_SUBSYSTEM_ID_LPE11010S 0xfc2A 1113 - 1114 1092 #define JEDEC_ID_ADDRESS 0x0080001c 1115 1093 #define FIREFLY_JEDEC_ID 0x1ACC 1116 1094 #define SUPERFLY_JEDEC_ID 0x0020 ··· 1294 1284 #define CMD_FCP_IREAD_CX 0x1B 1295 1285 #define CMD_FCP_ICMND_CR 0x1C 1296 1286 #define CMD_FCP_ICMND_CX 0x1D 1287 + #define CMD_FCP_TSEND_CX 0x1F 1288 + #define CMD_FCP_TRECEIVE_CX 0x21 1289 + #define CMD_FCP_TRSP_CX 0x23 1290 + #define CMD_FCP_AUTO_TRSP_CX 0x29 1297 1291 1298 1292 #define CMD_ADAPTER_MSG 0x20 1299 1293 #define CMD_ADAPTER_DUMP 0x22 ··· 1324 1310 #define CMD_FCP_IREAD64_CX 0x9B 1325 1311 #define CMD_FCP_ICMND64_CR 0x9C 1326 1312 #define CMD_FCP_ICMND64_CX 0x9D 1313 + #define CMD_FCP_TSEND64_CX 0x9F 1314 + #define CMD_FCP_TRECEIVE64_CX 0xA1 1315 + #define CMD_FCP_TRSP64_CX 0xA3 1327 1316 1328 1317 #define CMD_GEN_REQUEST64_CR 0xC2 1329 1318 #define CMD_GEN_REQUEST64_CX 0xC3
+54 -82
drivers/scsi/lpfc/lpfc_init.c
··· 268 268 kfree(mp); 269 269 pmb->context1 = NULL; 270 270 271 + if (phba->cfg_soft_wwnn) 272 + u64_to_wwn(phba->cfg_soft_wwnn, phba->fc_sparam.nodeName.u.wwn); 271 273 if (phba->cfg_soft_wwpn) 272 274 u64_to_wwn(phba->cfg_soft_wwpn, phba->fc_sparam.portName.u.wwn); 273 275 memcpy(&phba->fc_nodename, &phba->fc_sparam.nodeName, ··· 351 349 phba->hba_state = LPFC_LINK_DOWN; 352 350 353 351 /* Only process IOCBs on ring 0 till hba_state is READY */ 354 - if (psli->ring[psli->ip_ring].cmdringaddr) 355 - psli->ring[psli->ip_ring].flag |= LPFC_STOP_IOCB_EVENT; 352 + if (psli->ring[psli->extra_ring].cmdringaddr) 353 + psli->ring[psli->extra_ring].flag |= LPFC_STOP_IOCB_EVENT; 356 354 if (psli->ring[psli->fcp_ring].cmdringaddr) 357 355 psli->ring[psli->fcp_ring].flag |= LPFC_STOP_IOCB_EVENT; 358 356 if (psli->ring[psli->next_ring].cmdringaddr) ··· 519 517 struct lpfc_sli_ring *pring; 520 518 uint32_t event_data; 521 519 522 - if (phba->work_hs & HS_FFER6) { 520 + if (phba->work_hs & HS_FFER6 || 521 + phba->work_hs & HS_FFER5) { 523 522 /* Re-establishing Link */ 524 523 lpfc_printf_log(phba, KERN_INFO, LOG_LINK_EVENT, 525 524 "%d:1301 Re-establishing Link " ··· 614 611 pmb->mbox_cmpl = lpfc_mbx_cmpl_read_la; 615 612 rc = lpfc_sli_issue_mbox (phba, pmb, (MBX_NOWAIT | MBX_STOP_IOCB)); 616 613 if (rc == MBX_NOT_FINISHED) 617 - goto lpfc_handle_latt_free_mp; 614 + goto lpfc_handle_latt_free_mbuf; 618 615 619 616 /* Clear Link Attention in HA REG */ 620 617 spin_lock_irq(phba->host->host_lock); ··· 624 621 625 622 return; 626 623 624 + lpfc_handle_latt_free_mbuf: 625 + lpfc_mbuf_free(phba, mp->virt, mp->phys); 627 626 lpfc_handle_latt_free_mp: 628 627 kfree(mp); 629 628 lpfc_handle_latt_free_pmb: ··· 807 802 { 808 803 lpfc_vpd_t *vp; 809 804 uint16_t dev_id = phba->pcidev->device; 810 - uint16_t dev_subid = phba->pcidev->subsystem_device; 811 - uint8_t hdrtype; 812 805 int max_speed; 813 - char * ports; 814 806 struct { 815 807 char * name; 816 808 int max_speed; 817 - char * ports; 818 809 char * bus; 819 - } m = {"<Unknown>", 0, "", ""}; 810 + } m = {"<Unknown>", 0, ""}; 820 811 821 - pci_read_config_byte(phba->pcidev, PCI_HEADER_TYPE, &hdrtype); 822 - ports = (hdrtype == 0x80) ? "2-port " : ""; 823 812 if (mdp && mdp[0] != '\0' 824 813 && descp && descp[0] != '\0') 825 814 return; ··· 833 834 834 835 switch (dev_id) { 835 836 case PCI_DEVICE_ID_FIREFLY: 836 - m = (typeof(m)){"LP6000", max_speed, "", "PCI"}; 837 + m = (typeof(m)){"LP6000", max_speed, "PCI"}; 837 838 break; 838 839 case PCI_DEVICE_ID_SUPERFLY: 839 840 if (vp->rev.biuRev >= 1 && vp->rev.biuRev <= 3) 840 - m = (typeof(m)){"LP7000", max_speed, "", "PCI"}; 841 + m = (typeof(m)){"LP7000", max_speed, "PCI"}; 841 842 else 842 - m = (typeof(m)){"LP7000E", max_speed, "", "PCI"}; 843 + m = (typeof(m)){"LP7000E", max_speed, "PCI"}; 843 844 break; 844 845 case PCI_DEVICE_ID_DRAGONFLY: 845 - m = (typeof(m)){"LP8000", max_speed, "", "PCI"}; 846 + m = (typeof(m)){"LP8000", max_speed, "PCI"}; 846 847 break; 847 848 case PCI_DEVICE_ID_CENTAUR: 848 849 if (FC_JEDEC_ID(vp->rev.biuRev) == CENTAUR_2G_JEDEC_ID) 849 - m = (typeof(m)){"LP9002", max_speed, "", "PCI"}; 850 + m = (typeof(m)){"LP9002", max_speed, "PCI"}; 850 851 else 851 - m = (typeof(m)){"LP9000", max_speed, "", "PCI"}; 852 + m = (typeof(m)){"LP9000", max_speed, "PCI"}; 852 853 break; 853 854 case PCI_DEVICE_ID_RFLY: 854 - m = (typeof(m)){"LP952", max_speed, "", "PCI"}; 855 + m = (typeof(m)){"LP952", max_speed, "PCI"}; 855 856 break; 856 857 case PCI_DEVICE_ID_PEGASUS: 857 - m = (typeof(m)){"LP9802", max_speed, "", "PCI-X"}; 858 + m = (typeof(m)){"LP9802", max_speed, "PCI-X"}; 858 859 break; 859 860 case PCI_DEVICE_ID_THOR: 860 - if (hdrtype == 0x80) 861 - m = (typeof(m)){"LP10000DC", 862 - max_speed, ports, "PCI-X"}; 863 - else 864 - m = (typeof(m)){"LP10000", 865 - max_speed, ports, "PCI-X"}; 861 + m = (typeof(m)){"LP10000", max_speed, "PCI-X"}; 866 862 break; 867 863 case PCI_DEVICE_ID_VIPER: 868 - m = (typeof(m)){"LPX1000", max_speed, "", "PCI-X"}; 864 + m = (typeof(m)){"LPX1000", max_speed, "PCI-X"}; 869 865 break; 870 866 case PCI_DEVICE_ID_PFLY: 871 - m = (typeof(m)){"LP982", max_speed, "", "PCI-X"}; 867 + m = (typeof(m)){"LP982", max_speed, "PCI-X"}; 872 868 break; 873 869 case PCI_DEVICE_ID_TFLY: 874 - if (hdrtype == 0x80) 875 - m = (typeof(m)){"LP1050DC", max_speed, ports, "PCI-X"}; 876 - else 877 - m = (typeof(m)){"LP1050", max_speed, ports, "PCI-X"}; 870 + m = (typeof(m)){"LP1050", max_speed, "PCI-X"}; 878 871 break; 879 872 case PCI_DEVICE_ID_HELIOS: 880 - if (hdrtype == 0x80) 881 - m = (typeof(m)){"LP11002", max_speed, ports, "PCI-X2"}; 882 - else 883 - m = (typeof(m)){"LP11000", max_speed, ports, "PCI-X2"}; 873 + m = (typeof(m)){"LP11000", max_speed, "PCI-X2"}; 884 874 break; 885 875 case PCI_DEVICE_ID_HELIOS_SCSP: 886 - m = (typeof(m)){"LP11000-SP", max_speed, ports, "PCI-X2"}; 876 + m = (typeof(m)){"LP11000-SP", max_speed, "PCI-X2"}; 887 877 break; 888 878 case PCI_DEVICE_ID_HELIOS_DCSP: 889 - m = (typeof(m)){"LP11002-SP", max_speed, ports, "PCI-X2"}; 879 + m = (typeof(m)){"LP11002-SP", max_speed, "PCI-X2"}; 890 880 break; 891 881 case PCI_DEVICE_ID_NEPTUNE: 892 - if (hdrtype == 0x80) 893 - m = (typeof(m)){"LPe1002", max_speed, ports, "PCIe"}; 894 - else 895 - m = (typeof(m)){"LPe1000", max_speed, ports, "PCIe"}; 882 + m = (typeof(m)){"LPe1000", max_speed, "PCIe"}; 896 883 break; 897 884 case PCI_DEVICE_ID_NEPTUNE_SCSP: 898 - m = (typeof(m)){"LPe1000-SP", max_speed, ports, "PCIe"}; 885 + m = (typeof(m)){"LPe1000-SP", max_speed, "PCIe"}; 899 886 break; 900 887 case PCI_DEVICE_ID_NEPTUNE_DCSP: 901 - m = (typeof(m)){"LPe1002-SP", max_speed, ports, "PCIe"}; 888 + m = (typeof(m)){"LPe1002-SP", max_speed, "PCIe"}; 902 889 break; 903 890 case PCI_DEVICE_ID_BMID: 904 - m = (typeof(m)){"LP1150", max_speed, ports, "PCI-X2"}; 891 + m = (typeof(m)){"LP1150", max_speed, "PCI-X2"}; 905 892 break; 906 893 case PCI_DEVICE_ID_BSMB: 907 - m = (typeof(m)){"LP111", max_speed, ports, "PCI-X2"}; 894 + m = (typeof(m)){"LP111", max_speed, "PCI-X2"}; 908 895 break; 909 896 case PCI_DEVICE_ID_ZEPHYR: 910 - if (hdrtype == 0x80) 911 - m = (typeof(m)){"LPe11002", max_speed, ports, "PCIe"}; 912 - else 913 - m = (typeof(m)){"LPe11000", max_speed, ports, "PCIe"}; 897 + m = (typeof(m)){"LPe11000", max_speed, "PCIe"}; 914 898 break; 915 899 case PCI_DEVICE_ID_ZEPHYR_SCSP: 916 - m = (typeof(m)){"LPe11000", max_speed, ports, "PCIe"}; 900 + m = (typeof(m)){"LPe11000", max_speed, "PCIe"}; 917 901 break; 918 902 case PCI_DEVICE_ID_ZEPHYR_DCSP: 919 - m = (typeof(m)){"LPe11002-SP", max_speed, ports, "PCIe"}; 903 + m = (typeof(m)){"LPe11002-SP", max_speed, "PCIe"}; 920 904 break; 921 905 case PCI_DEVICE_ID_ZMID: 922 - m = (typeof(m)){"LPe1150", max_speed, ports, "PCIe"}; 906 + m = (typeof(m)){"LPe1150", max_speed, "PCIe"}; 923 907 break; 924 908 case PCI_DEVICE_ID_ZSMB: 925 - m = (typeof(m)){"LPe111", max_speed, ports, "PCIe"}; 909 + m = (typeof(m)){"LPe111", max_speed, "PCIe"}; 926 910 break; 927 911 case PCI_DEVICE_ID_LP101: 928 - m = (typeof(m)){"LP101", max_speed, ports, "PCI-X"}; 912 + m = (typeof(m)){"LP101", max_speed, "PCI-X"}; 929 913 break; 930 914 case PCI_DEVICE_ID_LP10000S: 931 - m = (typeof(m)){"LP10000-S", max_speed, ports, "PCI"}; 915 + m = (typeof(m)){"LP10000-S", max_speed, "PCI"}; 932 916 break; 933 917 case PCI_DEVICE_ID_LP11000S: 918 + m = (typeof(m)){"LP11000-S", max_speed, 919 + "PCI-X2"}; 920 + break; 934 921 case PCI_DEVICE_ID_LPE11000S: 935 - switch (dev_subid) { 936 - case PCI_SUBSYSTEM_ID_LP11000S: 937 - m = (typeof(m)){"LP11000-S", max_speed, 938 - ports, "PCI-X2"}; 939 - break; 940 - case PCI_SUBSYSTEM_ID_LP11002S: 941 - m = (typeof(m)){"LP11002-S", max_speed, 942 - ports, "PCI-X2"}; 943 - break; 944 - case PCI_SUBSYSTEM_ID_LPE11000S: 945 - m = (typeof(m)){"LPe11000-S", max_speed, 946 - ports, "PCIe"}; 947 - break; 948 - case PCI_SUBSYSTEM_ID_LPE11002S: 949 - m = (typeof(m)){"LPe11002-S", max_speed, 950 - ports, "PCIe"}; 951 - break; 952 - case PCI_SUBSYSTEM_ID_LPE11010S: 953 - m = (typeof(m)){"LPe11010-S", max_speed, 954 - "10-port ", "PCIe"}; 955 - break; 956 - default: 957 - m = (typeof(m)){ NULL }; 958 - break; 959 - } 922 + m = (typeof(m)){"LPe11000-S", max_speed, 923 + "PCIe"}; 960 924 break; 961 925 default: 962 926 m = (typeof(m)){ NULL }; ··· 930 968 snprintf(mdp, 79,"%s", m.name); 931 969 if (descp && descp[0] == '\0') 932 970 snprintf(descp, 255, 933 - "Emulex %s %dGb %s%s Fibre Channel Adapter", 934 - m.name, m.max_speed, m.ports, m.bus); 971 + "Emulex %s %dGb %s Fibre Channel Adapter", 972 + m.name, m.max_speed, m.bus); 935 973 } 936 974 937 975 /**************************************************/ ··· 1613 1651 if (error) 1614 1652 goto out_remove_host; 1615 1653 1654 + if (phba->cfg_use_msi) { 1655 + error = pci_enable_msi(phba->pcidev); 1656 + if (error) 1657 + lpfc_printf_log(phba, KERN_INFO, LOG_INIT, "%d:0452 " 1658 + "Enable MSI failed, continuing with " 1659 + "IRQ\n", phba->brd_no); 1660 + } 1661 + 1616 1662 error = request_irq(phba->pcidev->irq, lpfc_intr_handler, IRQF_SHARED, 1617 1663 LPFC_DRIVER_NAME, phba); 1618 1664 if (error) { ··· 1700 1730 lpfc_stop_timer(phba); 1701 1731 phba->work_hba_events = 0; 1702 1732 free_irq(phba->pcidev->irq, phba); 1733 + pci_disable_msi(phba->pcidev); 1703 1734 out_free_sysfs_attr: 1704 1735 lpfc_free_sysfs_attr(phba); 1705 1736 out_remove_host: ··· 1767 1796 1768 1797 /* Release the irq reservation */ 1769 1798 free_irq(phba->pcidev->irq, phba); 1799 + pci_disable_msi(phba->pcidev); 1770 1800 1771 1801 lpfc_cleanup(phba, 0); 1772 1802 lpfc_stop_timer(phba);
+1 -1
drivers/scsi/lpfc/lpfc_logmsg.h
··· 28 28 #define LOG_NODE 0x80 /* Node table events */ 29 29 #define LOG_MISC 0x400 /* Miscellaneous events */ 30 30 #define LOG_SLI 0x800 /* SLI events */ 31 - #define LOG_CHK_COND 0x1000 /* FCP Check condition flag */ 31 + #define LOG_FCP_ERROR 0x1000 /* log errors, not underruns */ 32 32 #define LOG_LIBDFC 0x2000 /* Libdfc events */ 33 33 #define LOG_ALL_MSG 0xffff /* LOG all messages */ 34 34
+6 -3
drivers/scsi/lpfc/lpfc_nportdisc.c
··· 739 739 uint32_t evt) 740 740 { 741 741 struct lpfc_iocbq *cmdiocb, *rspiocb; 742 - struct lpfc_dmabuf *pcmd, *prsp; 742 + struct lpfc_dmabuf *pcmd, *prsp, *mp; 743 743 uint32_t *lp; 744 744 IOCB_t *irsp; 745 745 struct serv_parm *sp; ··· 829 829 NLP_REGLOGIN_LIST); 830 830 return ndlp->nlp_state; 831 831 } 832 + mp = (struct lpfc_dmabuf *)mbox->context1; 833 + lpfc_mbuf_free(phba, mp->virt, mp->phys); 834 + kfree(mp); 832 835 mempool_free(mbox, phba->mbox_mem_pool); 833 836 } else { 834 837 mempool_free(mbox, phba->mbox_mem_pool); ··· 1623 1620 * or discovery in progress for this node. Starting discovery 1624 1621 * here will affect the counting of discovery threads. 1625 1622 */ 1626 - if ((!(ndlp->nlp_flag & NLP_DELAY_TMO)) && 1627 - (ndlp->nlp_flag & NLP_NPR_2B_DISC)){ 1623 + if (!(ndlp->nlp_flag & NLP_DELAY_TMO) && 1624 + !(ndlp->nlp_flag & NLP_NPR_2B_DISC)){ 1628 1625 if (ndlp->nlp_flag & NLP_NPR_ADISC) { 1629 1626 ndlp->nlp_prev_state = NLP_STE_NPR_NODE; 1630 1627 ndlp->nlp_state = NLP_STE_ADISC_ISSUE;
+41 -15
drivers/scsi/lpfc/lpfc_scsi.c
··· 297 297 uint32_t fcpi_parm = lpfc_cmd->cur_iocbq.iocb.un.fcpi.fcpi_parm; 298 298 uint32_t resp_info = fcprsp->rspStatus2; 299 299 uint32_t scsi_status = fcprsp->rspStatus3; 300 + uint32_t *lp; 300 301 uint32_t host_status = DID_OK; 301 302 uint32_t rsplen = 0; 303 + uint32_t logit = LOG_FCP | LOG_FCP_ERROR; 302 304 303 305 /* 304 306 * If this is a task management command, there is no ··· 312 310 goto out; 313 311 } 314 312 315 - lpfc_printf_log(phba, KERN_WARNING, LOG_FCP, 316 - "%d:0730 FCP command failed: RSP " 317 - "Data: x%x x%x x%x x%x x%x x%x\n", 318 - phba->brd_no, resp_info, scsi_status, 313 + if ((resp_info & SNS_LEN_VALID) && fcprsp->rspSnsLen) { 314 + uint32_t snslen = be32_to_cpu(fcprsp->rspSnsLen); 315 + if (snslen > SCSI_SENSE_BUFFERSIZE) 316 + snslen = SCSI_SENSE_BUFFERSIZE; 317 + 318 + if (resp_info & RSP_LEN_VALID) 319 + rsplen = be32_to_cpu(fcprsp->rspRspLen); 320 + memcpy(cmnd->sense_buffer, &fcprsp->rspInfo0 + rsplen, snslen); 321 + } 322 + lp = (uint32_t *)cmnd->sense_buffer; 323 + 324 + if (!scsi_status && (resp_info & RESID_UNDER)) 325 + logit = LOG_FCP; 326 + 327 + lpfc_printf_log(phba, KERN_WARNING, logit, 328 + "%d:0730 FCP command x%x failed: x%x SNS x%x x%x " 329 + "Data: x%x x%x x%x x%x x%x\n", 330 + phba->brd_no, cmnd->cmnd[0], scsi_status, 331 + be32_to_cpu(*lp), be32_to_cpu(*(lp + 3)), resp_info, 319 332 be32_to_cpu(fcprsp->rspResId), 320 333 be32_to_cpu(fcprsp->rspSnsLen), 321 334 be32_to_cpu(fcprsp->rspRspLen), ··· 343 326 host_status = DID_ERROR; 344 327 goto out; 345 328 } 346 - } 347 - 348 - if ((resp_info & SNS_LEN_VALID) && fcprsp->rspSnsLen) { 349 - uint32_t snslen = be32_to_cpu(fcprsp->rspSnsLen); 350 - if (snslen > SCSI_SENSE_BUFFERSIZE) 351 - snslen = SCSI_SENSE_BUFFERSIZE; 352 - 353 - memcpy(cmnd->sense_buffer, &fcprsp->rspInfo0 + rsplen, snslen); 354 329 } 355 330 356 331 cmnd->resid = 0; ··· 387 378 */ 388 379 } else if ((scsi_status == SAM_STAT_GOOD) && fcpi_parm && 389 380 (cmnd->sc_data_direction == DMA_FROM_DEVICE)) { 390 - lpfc_printf_log(phba, KERN_WARNING, LOG_FCP, 381 + lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_FCP_ERROR, 391 382 "%d:0734 FCP Read Check Error Data: " 392 383 "x%x x%x x%x x%x\n", phba->brd_no, 393 384 be32_to_cpu(fcpcmd->fcpDl), ··· 678 669 struct lpfc_iocbq *iocbq; 679 670 struct lpfc_iocbq *iocbqrsp; 680 671 int ret; 672 + 673 + if (!rdata->pnode) 674 + return FAILED; 681 675 682 676 lpfc_cmd->rdata = rdata; 683 677 ret = lpfc_scsi_prep_task_mgmt_cmd(phba, lpfc_cmd, lun, ··· 988 976 989 977 lpfc_block_error_handler(cmnd); 990 978 spin_lock_irq(shost->host_lock); 979 + loopcnt = 0; 991 980 /* 992 981 * If target is not in a MAPPED state, delay the reset until 993 982 * target is rediscovered or devloss timeout expires. 994 983 */ 995 984 while ( 1 ) { 996 985 if (!pnode) 997 - break; 986 + return FAILED; 998 987 999 988 if (pnode->nlp_state != NLP_STE_MAPPED_NODE) { 1000 989 spin_unlock_irq(phba->host->host_lock); 1001 990 schedule_timeout_uninterruptible(msecs_to_jiffies(500)); 1002 991 spin_lock_irq(phba->host->host_lock); 992 + loopcnt++; 993 + rdata = cmnd->device->hostdata; 994 + if (!rdata || 995 + (loopcnt > ((phba->cfg_devloss_tmo * 2) + 1))) { 996 + lpfc_printf_log(phba, KERN_ERR, LOG_FCP, 997 + "%d:0721 LUN Reset rport failure:" 998 + " cnt x%x rdata x%p\n", 999 + phba->brd_no, loopcnt, rdata); 1000 + goto out; 1001 + } 1002 + pnode = rdata->pnode; 1003 + if (!pnode) 1004 + return FAILED; 1003 1005 } 1004 - if ((pnode) && (pnode->nlp_state == NLP_STE_MAPPED_NODE)) 1006 + if (pnode->nlp_state == NLP_STE_MAPPED_NODE) 1005 1007 break; 1006 1008 } 1007 1009
+37 -5
drivers/scsi/lpfc/lpfc_sli.c
··· 117 117 case CMD_FCP_IREAD_CX: 118 118 case CMD_FCP_ICMND_CR: 119 119 case CMD_FCP_ICMND_CX: 120 + case CMD_FCP_TSEND_CX: 121 + case CMD_FCP_TRSP_CX: 122 + case CMD_FCP_TRECEIVE_CX: 123 + case CMD_FCP_AUTO_TRSP_CX: 120 124 case CMD_ADAPTER_MSG: 121 125 case CMD_ADAPTER_DUMP: 122 126 case CMD_XMIT_SEQUENCE64_CR: ··· 135 131 case CMD_FCP_IREAD64_CX: 136 132 case CMD_FCP_ICMND64_CR: 137 133 case CMD_FCP_ICMND64_CX: 134 + case CMD_FCP_TSEND64_CX: 135 + case CMD_FCP_TRSP64_CX: 136 + case CMD_FCP_TRECEIVE64_CX: 138 137 case CMD_GEN_REQUEST64_CR: 139 138 case CMD_GEN_REQUEST64_CX: 140 139 case CMD_XMIT_ELS_RSP64_CX: ··· 1105 1098 lpfc_sli_pcimem_bcopy((uint32_t *) entry, 1106 1099 (uint32_t *) &rspiocbq.iocb, 1107 1100 sizeof (IOCB_t)); 1101 + INIT_LIST_HEAD(&(rspiocbq.list)); 1108 1102 irsp = &rspiocbq.iocb; 1109 1103 1110 1104 type = lpfc_sli_iocb_cmd_type(irsp->ulpCommand & CMD_IOCB_MASK); ··· 1156 1148 iflag); 1157 1149 } 1158 1150 } 1151 + break; 1152 + case LPFC_UNSOL_IOCB: 1153 + spin_unlock_irqrestore(phba->host->host_lock, iflag); 1154 + lpfc_sli_process_unsol_iocb(phba, pring, &rspiocbq); 1155 + spin_lock_irqsave(phba->host->host_lock, iflag); 1159 1156 break; 1160 1157 default: 1161 1158 if (irsp->ulpCommand == CMD_ADAPTER_MSG) { ··· 2485 2472 psli = &phba->sli; 2486 2473 2487 2474 /* Adjust cmd/rsp ring iocb entries more evenly */ 2475 + 2476 + /* Take some away from the FCP ring */ 2488 2477 pring = &psli->ring[psli->fcp_ring]; 2489 2478 pring->numCiocb -= SLI2_IOCB_CMD_R1XTRA_ENTRIES; 2490 2479 pring->numRiocb -= SLI2_IOCB_RSP_R1XTRA_ENTRIES; 2491 2480 pring->numCiocb -= SLI2_IOCB_CMD_R3XTRA_ENTRIES; 2492 2481 pring->numRiocb -= SLI2_IOCB_RSP_R3XTRA_ENTRIES; 2493 2482 2494 - pring = &psli->ring[1]; 2483 + /* and give them to the extra ring */ 2484 + pring = &psli->ring[psli->extra_ring]; 2485 + 2495 2486 pring->numCiocb += SLI2_IOCB_CMD_R1XTRA_ENTRIES; 2496 2487 pring->numRiocb += SLI2_IOCB_RSP_R1XTRA_ENTRIES; 2497 2488 pring->numCiocb += SLI2_IOCB_CMD_R3XTRA_ENTRIES; ··· 2505 2488 pring->iotag_max = 4096; 2506 2489 pring->num_mask = 1; 2507 2490 pring->prt[0].profile = 0; /* Mask 0 */ 2508 - pring->prt[0].rctl = FC_UNSOL_DATA; 2509 - pring->prt[0].type = 5; 2491 + pring->prt[0].rctl = phba->cfg_multi_ring_rctl; 2492 + pring->prt[0].type = phba->cfg_multi_ring_type; 2510 2493 pring->prt[0].lpfc_sli_rcv_unsol_event = NULL; 2511 2494 return 0; 2512 2495 } ··· 2522 2505 psli->sli_flag = 0; 2523 2506 psli->fcp_ring = LPFC_FCP_RING; 2524 2507 psli->next_ring = LPFC_FCP_NEXT_RING; 2525 - psli->ip_ring = LPFC_IP_RING; 2508 + psli->extra_ring = LPFC_EXTRA_RING; 2526 2509 2527 2510 psli->iocbq_lookup = NULL; 2528 2511 psli->iocbq_lookup_len = 0; ··· 2545 2528 pring->fast_iotag = pring->iotag_max; 2546 2529 pring->num_mask = 0; 2547 2530 break; 2548 - case LPFC_IP_RING: /* ring 1 - IP */ 2531 + case LPFC_EXTRA_RING: /* ring 1 - EXTRA */ 2549 2532 /* numCiocb and numRiocb are used in config_port */ 2550 2533 pring->numCiocb = SLI2_IOCB_CMD_R1_ENTRIES; 2551 2534 pring->numRiocb = SLI2_IOCB_RSP_R1_ENTRIES; ··· 3255 3238 lpfc_sli_handle_fast_ring_event(phba, 3256 3239 &phba->sli.ring[LPFC_FCP_RING], 3257 3240 status); 3241 + 3242 + if (phba->cfg_multi_ring_support == 2) { 3243 + /* 3244 + * Process all events on extra ring. Take the optimized path 3245 + * for extra ring IO. Any other IO is slow path and is handled 3246 + * by the worker thread. 3247 + */ 3248 + status = (ha_copy & (HA_RXMASK << (4*LPFC_EXTRA_RING))); 3249 + status >>= (4*LPFC_EXTRA_RING); 3250 + if (status & HA_RXATT) { 3251 + lpfc_sli_handle_fast_ring_event(phba, 3252 + &phba->sli.ring[LPFC_EXTRA_RING], 3253 + status); 3254 + } 3255 + } 3258 3256 return IRQ_HANDLED; 3259 3257 3260 3258 } /* lpfc_intr_handler */
+1 -1
drivers/scsi/lpfc/lpfc_sli.h
··· 198 198 int fcp_ring; /* ring used for FCP initiator commands */ 199 199 int next_ring; 200 200 201 - int ip_ring; /* ring used for IP network drv cmds */ 201 + int extra_ring; /* extra ring used for other protocols */ 202 202 203 203 struct lpfc_sli_stat slistat; /* SLI statistical info */ 204 204 struct list_head mboxq;
+1 -1
drivers/scsi/lpfc/lpfc_version.h
··· 18 18 * included with this package. * 19 19 *******************************************************************/ 20 20 21 - #define LPFC_DRIVER_VERSION "8.1.10" 21 + #define LPFC_DRIVER_VERSION "8.1.11" 22 22 23 23 #define LPFC_DRIVER_NAME "lpfc" 24 24
+8 -5
drivers/scsi/megaraid.c
··· 73 73 module_param(max_mbox_busy_wait, ushort, 0); 74 74 MODULE_PARM_DESC(max_mbox_busy_wait, "Maximum wait for mailbox in microseconds if busy (default=MBOX_BUSY_WAIT=10)"); 75 75 76 - #define RDINDOOR(adapter) readl((adapter)->base + 0x20) 77 - #define RDOUTDOOR(adapter) readl((adapter)->base + 0x2C) 78 - #define WRINDOOR(adapter,value) writel(value, (adapter)->base + 0x20) 79 - #define WROUTDOOR(adapter,value) writel(value, (adapter)->base + 0x2C) 76 + #define RDINDOOR(adapter) readl((adapter)->mmio_base + 0x20) 77 + #define RDOUTDOOR(adapter) readl((adapter)->mmio_base + 0x2C) 78 + #define WRINDOOR(adapter,value) writel(value, (adapter)->mmio_base + 0x20) 79 + #define WROUTDOOR(adapter,value) writel(value, (adapter)->mmio_base + 0x2C) 80 80 81 81 /* 82 82 * Global variables ··· 1386 1386 1387 1387 handled = 1; 1388 1388 1389 - while( RDINDOOR(adapter) & 0x02 ) cpu_relax(); 1389 + while( RDINDOOR(adapter) & 0x02 ) 1390 + cpu_relax(); 1390 1391 1391 1392 mega_cmd_done(adapter, completed, nstatus, status); 1392 1393 ··· 4669 4668 host->host_no, mega_baseport, irq); 4670 4669 4671 4670 adapter->base = mega_baseport; 4671 + if (flag & BOARD_MEMMAP) 4672 + adapter->mmio_base = (void __iomem *) mega_baseport; 4672 4673 4673 4674 INIT_LIST_HEAD(&adapter->free_list); 4674 4675 INIT_LIST_HEAD(&adapter->pending_list);
+2 -1
drivers/scsi/megaraid.h
··· 801 801 clustering is available */ 802 802 u32 flag; 803 803 804 - unsigned long base; 804 + unsigned long base; 805 + void __iomem *mmio_base; 805 806 806 807 /* mbox64 with mbox not aligned on 16-byte boundry */ 807 808 mbox64_t *una_mbox64;
+2 -2
drivers/scsi/megaraid/megaraid_sas.c
··· 517 517 * Returns the number of frames required for numnber of sge's (sge_count) 518 518 */ 519 519 520 - u32 megasas_get_frame_count(u8 sge_count) 520 + static u32 megasas_get_frame_count(u8 sge_count) 521 521 { 522 522 int num_cnt; 523 523 int sge_bytes; ··· 1733 1733 * 1734 1734 * Tasklet to complete cmds 1735 1735 */ 1736 - void megasas_complete_cmd_dpc(unsigned long instance_addr) 1736 + static void megasas_complete_cmd_dpc(unsigned long instance_addr) 1737 1737 { 1738 1738 u32 producer; 1739 1739 u32 consumer;
+11 -8
drivers/scsi/ncr53c8xx.c
··· 589 589 static struct ncr_driver_setup 590 590 driver_setup = SCSI_NCR_DRIVER_SETUP; 591 591 592 + #ifndef MODULE 592 593 #ifdef SCSI_NCR_BOOT_COMMAND_LINE_SUPPORT 593 594 static struct ncr_driver_setup 594 595 driver_safe_setup __initdata = SCSI_NCR_DRIVER_SAFE_SETUP; 595 596 #endif 597 + #endif /* !MODULE */ 596 598 597 599 #define initverbose (driver_setup.verbose) 598 600 #define bootverbose (np->verbose) ··· 643 641 #define OPT_IARB 26 644 642 #endif 645 643 644 + #ifdef MODULE 645 + #define ARG_SEP ' ' 646 + #else 647 + #define ARG_SEP ',' 648 + #endif 649 + 650 + #ifndef MODULE 646 651 static char setup_token[] __initdata = 647 652 "tags:" "mpar:" 648 653 "spar:" "disc:" ··· 669 660 #endif 670 661 ; /* DONNOT REMOVE THIS ';' */ 671 662 672 - #ifdef MODULE 673 - #define ARG_SEP ' ' 674 - #else 675 - #define ARG_SEP ',' 676 - #endif 677 - 678 663 static int __init get_setup_token(char *p) 679 664 { 680 665 char *cur = setup_token; ··· 684 681 } 685 682 return 0; 686 683 } 687 - 688 684 689 685 static int __init sym53c8xx__setup(char *str) 690 686 { ··· 806 804 #endif /* SCSI_NCR_BOOT_COMMAND_LINE_SUPPORT */ 807 805 return 1; 808 806 } 807 + #endif /* !MODULE */ 809 808 810 809 /*=================================================================== 811 810 ** ··· 8324 8321 module_param(ncr53c8xx, charp, 0); 8325 8322 #endif 8326 8323 8324 + #ifndef MODULE 8327 8325 static int __init ncr53c8xx_setup(char *str) 8328 8326 { 8329 8327 return sym53c8xx__setup(str); 8330 8328 } 8331 8329 8332 - #ifndef MODULE 8333 8330 __setup("ncr53c8xx=", ncr53c8xx_setup); 8334 8331 #endif 8335 8332
+1 -1
drivers/scsi/qla2xxx/qla_attr.c
··· 390 390 { "optrom_ctl", &sysfs_optrom_ctl_attr, }, 391 391 { "vpd", &sysfs_vpd_attr, 1 }, 392 392 { "sfp", &sysfs_sfp_attr, 1 }, 393 - { 0 }, 393 + { NULL }, 394 394 }; 395 395 396 396 void
+9 -85
drivers/scsi/qla2xxx/qla_init.c
··· 59 59 qla2x00_initialize_adapter(scsi_qla_host_t *ha) 60 60 { 61 61 int rval; 62 - uint8_t restart_risc = 0; 63 - uint8_t retry; 64 - uint32_t wait_time; 65 62 66 63 /* Clear adapter flags. */ 67 64 ha->flags.online = 0; ··· 101 104 102 105 qla_printk(KERN_INFO, ha, "Verifying loaded RISC code...\n"); 103 106 104 - retry = 10; 105 - /* 106 - * Try to configure the loop. 107 - */ 108 - do { 109 - restart_risc = 0; 110 - 111 - /* If firmware needs to be loaded */ 112 - if (qla2x00_isp_firmware(ha) != QLA_SUCCESS) { 113 - if ((rval = ha->isp_ops.chip_diag(ha)) == QLA_SUCCESS) { 114 - rval = qla2x00_setup_chip(ha); 115 - } 116 - } 117 - 118 - if (rval == QLA_SUCCESS && 119 - (rval = qla2x00_init_rings(ha)) == QLA_SUCCESS) { 120 - check_fw_ready_again: 121 - /* 122 - * Wait for a successful LIP up to a maximum 123 - * of (in seconds): RISC login timeout value, 124 - * RISC retry count value, and port down retry 125 - * value OR a minimum of 4 seconds OR If no 126 - * cable, only 5 seconds. 127 - */ 128 - rval = qla2x00_fw_ready(ha); 129 - if (rval == QLA_SUCCESS) { 130 - clear_bit(RESET_MARKER_NEEDED, &ha->dpc_flags); 131 - 132 - /* Issue a marker after FW becomes ready. */ 133 - qla2x00_marker(ha, 0, 0, MK_SYNC_ALL); 134 - 135 - /* 136 - * Wait at most MAX_TARGET RSCNs for a stable 137 - * link. 138 - */ 139 - wait_time = 256; 140 - do { 141 - clear_bit(LOOP_RESYNC_NEEDED, 142 - &ha->dpc_flags); 143 - rval = qla2x00_configure_loop(ha); 144 - 145 - if (test_and_clear_bit(ISP_ABORT_NEEDED, 146 - &ha->dpc_flags)) { 147 - restart_risc = 1; 148 - break; 149 - } 150 - 151 - /* 152 - * If loop state change while we were 153 - * discoverying devices then wait for 154 - * LIP to complete 155 - */ 156 - 157 - if (atomic_read(&ha->loop_state) != 158 - LOOP_READY && retry--) { 159 - goto check_fw_ready_again; 160 - } 161 - wait_time--; 162 - } while (!atomic_read(&ha->loop_down_timer) && 163 - retry && 164 - wait_time && 165 - (test_bit(LOOP_RESYNC_NEEDED, 166 - &ha->dpc_flags))); 167 - 168 - if (wait_time == 0) 169 - rval = QLA_FUNCTION_FAILED; 170 - } else if (ha->device_flags & DFLG_NO_CABLE) 171 - /* If no cable, then all is good. */ 172 - rval = QLA_SUCCESS; 173 - } 174 - } while (restart_risc && retry--); 175 - 176 - if (rval == QLA_SUCCESS) { 177 - clear_bit(RESET_MARKER_NEEDED, &ha->dpc_flags); 178 - qla2x00_marker(ha, 0, 0, MK_SYNC_ALL); 179 - ha->marker_needed = 0; 180 - 181 - ha->flags.online = 1; 182 - } else { 183 - DEBUG2_3(printk("%s(): **** FAILED ****\n", __func__)); 107 + if (qla2x00_isp_firmware(ha) != QLA_SUCCESS) { 108 + rval = ha->isp_ops.chip_diag(ha); 109 + if (rval) 110 + return (rval); 111 + rval = qla2x00_setup_chip(ha); 112 + if (rval) 113 + return (rval); 184 114 } 115 + rval = qla2x00_init_rings(ha); 185 116 186 117 return (rval); 187 118 } ··· 2133 2208 2134 2209 atomic_set(&fcport->state, FCS_ONLINE); 2135 2210 2136 - if (ha->flags.init_done) 2137 - qla2x00_reg_remote_port(ha, fcport); 2211 + qla2x00_reg_remote_port(ha, fcport); 2138 2212 } 2139 2213 2140 2214 void
+38 -28
drivers/scsi/qla2xxx/qla_os.c
··· 95 95 */ 96 96 static int qla2xxx_slave_configure(struct scsi_device * device); 97 97 static int qla2xxx_slave_alloc(struct scsi_device *); 98 + static int qla2xxx_scan_finished(struct Scsi_Host *, unsigned long time); 99 + static void qla2xxx_scan_start(struct Scsi_Host *); 98 100 static void qla2xxx_slave_destroy(struct scsi_device *); 99 101 static int qla2x00_queuecommand(struct scsi_cmnd *cmd, 100 102 void (*fn)(struct scsi_cmnd *)); ··· 126 124 127 125 .slave_alloc = qla2xxx_slave_alloc, 128 126 .slave_destroy = qla2xxx_slave_destroy, 127 + .scan_finished = qla2xxx_scan_finished, 128 + .scan_start = qla2xxx_scan_start, 129 129 .change_queue_depth = qla2x00_change_queue_depth, 130 130 .change_queue_type = qla2x00_change_queue_type, 131 131 .this_id = -1, ··· 291 287 return str; 292 288 } 293 289 294 - char * 290 + static char * 295 291 qla2x00_fw_version_str(struct scsi_qla_host *ha, char *str) 296 292 { 297 293 char un_str[10]; ··· 329 325 return (str); 330 326 } 331 327 332 - char * 328 + static char * 333 329 qla24xx_fw_version_str(struct scsi_qla_host *ha, char *str) 334 330 { 335 331 sprintf(str, "%d.%02d.%02d ", ha->fw_major_version, ··· 638 634 * Note: 639 635 * Only return FAILED if command not returned by firmware. 640 636 **************************************************************************/ 641 - int 637 + static int 642 638 qla2xxx_eh_abort(struct scsi_cmnd *cmd) 643 639 { 644 640 scsi_qla_host_t *ha = to_qla_host(cmd->device->host); ··· 775 771 * SUCCESS/FAILURE (defined as macro in scsi.h). 776 772 * 777 773 **************************************************************************/ 778 - int 774 + static int 779 775 qla2xxx_eh_device_reset(struct scsi_cmnd *cmd) 780 776 { 781 777 scsi_qla_host_t *ha = to_qla_host(cmd->device->host); ··· 906 902 * SUCCESS/FAILURE (defined as macro in scsi.h). 907 903 * 908 904 **************************************************************************/ 909 - int 905 + static int 910 906 qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd) 911 907 { 912 908 scsi_qla_host_t *ha = to_qla_host(cmd->device->host); ··· 967 963 * 968 964 * Note: 969 965 **************************************************************************/ 970 - int 966 + static int 971 967 qla2xxx_eh_host_reset(struct scsi_cmnd *cmd) 972 968 { 973 969 scsi_qla_host_t *ha = to_qla_host(cmd->device->host); ··· 1370 1366 spin_unlock_irqrestore(&ha->hardware_lock, flags); 1371 1367 } 1372 1368 1369 + static void 1370 + qla2xxx_scan_start(struct Scsi_Host *shost) 1371 + { 1372 + scsi_qla_host_t *ha = (scsi_qla_host_t *)shost->hostdata; 1373 + 1374 + set_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags); 1375 + set_bit(LOCAL_LOOP_UPDATE, &ha->dpc_flags); 1376 + set_bit(RSCN_UPDATE, &ha->dpc_flags); 1377 + } 1378 + 1379 + static int 1380 + qla2xxx_scan_finished(struct Scsi_Host *shost, unsigned long time) 1381 + { 1382 + scsi_qla_host_t *ha = (scsi_qla_host_t *)shost->hostdata; 1383 + 1384 + if (!ha->host) 1385 + return 1; 1386 + if (time > ha->loop_reset_delay * HZ) 1387 + return 1; 1388 + 1389 + return atomic_read(&ha->loop_state) == LOOP_READY; 1390 + } 1391 + 1373 1392 /* 1374 1393 * PCI driver interface 1375 1394 */ ··· 1404 1377 struct Scsi_Host *host; 1405 1378 scsi_qla_host_t *ha; 1406 1379 unsigned long flags = 0; 1407 - unsigned long wait_switch = 0; 1408 1380 char pci_info[20]; 1409 1381 char fw_str[30]; 1410 - fc_port_t *fcport; 1411 1382 struct scsi_host_template *sht; 1412 1383 1413 1384 if (pci_enable_device(pdev)) ··· 1656 1631 1657 1632 ha->isp_ops.enable_intrs(ha); 1658 1633 1659 - /* v2.19.5b6 */ 1660 - /* 1661 - * Wait around max loop_reset_delay secs for the devices to come 1662 - * on-line. We don't want Linux scanning before we are ready. 1663 - * 1664 - */ 1665 - for (wait_switch = jiffies + (ha->loop_reset_delay * HZ); 1666 - time_before(jiffies,wait_switch) && 1667 - !(ha->device_flags & (DFLG_NO_CABLE | DFLG_FABRIC_DEVICES)) 1668 - && (ha->device_flags & SWITCH_FOUND) ;) { 1669 - 1670 - qla2x00_check_fabric_devices(ha); 1671 - 1672 - msleep(10); 1673 - } 1674 - 1675 1634 pci_set_drvdata(pdev, ha); 1635 + 1676 1636 ha->flags.init_done = 1; 1637 + ha->flags.online = 1; 1638 + 1677 1639 num_hosts++; 1678 1640 1679 1641 ret = scsi_add_host(host, &pdev->dev); 1680 1642 if (ret) 1681 1643 goto probe_failed; 1644 + 1645 + scsi_scan_host(host); 1682 1646 1683 1647 qla2x00_alloc_sysfs_attr(ha); 1684 1648 ··· 1682 1668 ha->isp_ops.pci_info_str(ha, pci_info), pci_name(pdev), 1683 1669 ha->flags.enable_64bit_addressing ? '+': '-', ha->host_no, 1684 1670 ha->isp_ops.fw_version_str(ha, fw_str)); 1685 - 1686 - /* Go with fc_rport registration. */ 1687 - list_for_each_entry(fcport, &ha->fcports, list) 1688 - qla2x00_reg_remote_port(ha, fcport); 1689 1671 1690 1672 return 0; 1691 1673
+4 -4
drivers/scsi/qla2xxx/qla_sup.c
··· 449 449 return FARX_ACCESS_NVRAM_DATA | naddr; 450 450 } 451 451 452 - uint32_t 452 + static uint32_t 453 453 qla24xx_read_flash_dword(scsi_qla_host_t *ha, uint32_t addr) 454 454 { 455 455 int rval; ··· 490 490 return dwptr; 491 491 } 492 492 493 - int 493 + static int 494 494 qla24xx_write_flash_dword(scsi_qla_host_t *ha, uint32_t addr, uint32_t data) 495 495 { 496 496 int rval; ··· 512 512 return rval; 513 513 } 514 514 515 - void 515 + static void 516 516 qla24xx_get_flash_manufacturer(scsi_qla_host_t *ha, uint8_t *man_id, 517 517 uint8_t *flash_id) 518 518 { ··· 537 537 } 538 538 } 539 539 540 - int 540 + static int 541 541 qla24xx_write_flash_data(scsi_qla_host_t *ha, uint32_t *dwptr, uint32_t faddr, 542 542 uint32_t dwords) 543 543 {
+2 -2
drivers/scsi/qla4xxx/ql4_dbg.c
··· 71 71 readw(&ha->reg->u1.isp4010.nvram)); 72 72 } 73 73 74 - else if (is_qla4022(ha)) { 74 + else if (is_qla4022(ha) | is_qla4032(ha)) { 75 75 printk(KERN_INFO "0x%02X intr_mask = 0x%08X\n", 76 76 (uint8_t) offsetof(struct isp_reg, 77 77 u1.isp4022.intr_mask), ··· 119 119 readw(&ha->reg->u2.isp4010.port_err_status)); 120 120 } 121 121 122 - else if (is_qla4022(ha)) { 122 + else if (is_qla4022(ha) | is_qla4032(ha)) { 123 123 printk(KERN_INFO "Page 0 Registers:\n"); 124 124 printk(KERN_INFO "0x%02X ext_hw_conf = 0x%08X\n", 125 125 (uint8_t) offsetof(struct isp_reg,
+57 -48
drivers/scsi/qla4xxx/ql4_def.h
··· 40 40 41 41 #ifndef PCI_DEVICE_ID_QLOGIC_ISP4022 42 42 #define PCI_DEVICE_ID_QLOGIC_ISP4022 0x4022 43 - #endif /* */ 43 + #endif 44 + 45 + #ifndef PCI_DEVICE_ID_QLOGIC_ISP4032 46 + #define PCI_DEVICE_ID_QLOGIC_ISP4032 0x4032 47 + #endif 44 48 45 49 #define QLA_SUCCESS 0 46 50 #define QLA_ERROR 1 ··· 281 277 #define AF_INTERRUPTS_ON 6 /* 0x00000040 Not Used */ 282 278 #define AF_GET_CRASH_RECORD 7 /* 0x00000080 */ 283 279 #define AF_LINK_UP 8 /* 0x00000100 */ 284 - #define AF_TOPCAT_CHIP_PRESENT 9 /* 0x00000200 */ 285 280 #define AF_IRQ_ATTACHED 10 /* 0x00000400 */ 286 281 #define AF_ISNS_CMD_IN_PROCESS 12 /* 0x00001000 */ 287 282 #define AF_ISNS_CMD_DONE 13 /* 0x00002000 */ ··· 320 317 /* NVRAM registers */ 321 318 struct eeprom_data *nvram; 322 319 spinlock_t hardware_lock ____cacheline_aligned; 323 - spinlock_t list_lock; 324 320 uint32_t eeprom_cmd_data; 325 321 326 322 /* Counters for general statistics */ 323 + uint64_t isr_count; 327 324 uint64_t adapter_error_count; 328 325 uint64_t device_error_count; 329 326 uint64_t total_io_count; 330 327 uint64_t total_mbytes_xferred; 331 328 uint64_t link_failure_count; 332 329 uint64_t invalid_crc_count; 330 + uint32_t bytes_xfered; 333 331 uint32_t spurious_int_count; 334 332 uint32_t aborted_io_count; 335 333 uint32_t io_timeout_count; ··· 442 438 return ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP4022; 443 439 } 444 440 441 + static inline int is_qla4032(struct scsi_qla_host *ha) 442 + { 443 + return ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP4032; 444 + } 445 + 445 446 static inline int adapter_up(struct scsi_qla_host *ha) 446 447 { 447 448 return (test_bit(AF_ONLINE, &ha->flags) != 0) && ··· 460 451 461 452 static inline void __iomem* isp_semaphore(struct scsi_qla_host *ha) 462 453 { 463 - return (is_qla4022(ha) ? 464 - &ha->reg->u1.isp4022.semaphore : 465 - &ha->reg->u1.isp4010.nvram); 454 + return (is_qla4010(ha) ? 455 + &ha->reg->u1.isp4010.nvram : 456 + &ha->reg->u1.isp4022.semaphore); 466 457 } 467 458 468 459 static inline void __iomem* isp_nvram(struct scsi_qla_host *ha) 469 460 { 470 - return (is_qla4022(ha) ? 471 - &ha->reg->u1.isp4022.nvram : 472 - &ha->reg->u1.isp4010.nvram); 461 + return (is_qla4010(ha) ? 462 + &ha->reg->u1.isp4010.nvram : 463 + &ha->reg->u1.isp4022.nvram); 473 464 } 474 465 475 466 static inline void __iomem* isp_ext_hw_conf(struct scsi_qla_host *ha) 476 467 { 477 - return (is_qla4022(ha) ? 478 - &ha->reg->u2.isp4022.p0.ext_hw_conf : 479 - &ha->reg->u2.isp4010.ext_hw_conf); 468 + return (is_qla4010(ha) ? 469 + &ha->reg->u2.isp4010.ext_hw_conf : 470 + &ha->reg->u2.isp4022.p0.ext_hw_conf); 480 471 } 481 472 482 473 static inline void __iomem* isp_port_status(struct scsi_qla_host *ha) 483 474 { 484 - return (is_qla4022(ha) ? 485 - &ha->reg->u2.isp4022.p0.port_status : 486 - &ha->reg->u2.isp4010.port_status); 475 + return (is_qla4010(ha) ? 476 + &ha->reg->u2.isp4010.port_status : 477 + &ha->reg->u2.isp4022.p0.port_status); 487 478 } 488 479 489 480 static inline void __iomem* isp_port_ctrl(struct scsi_qla_host *ha) 490 481 { 491 - return (is_qla4022(ha) ? 492 - &ha->reg->u2.isp4022.p0.port_ctrl : 493 - &ha->reg->u2.isp4010.port_ctrl); 482 + return (is_qla4010(ha) ? 483 + &ha->reg->u2.isp4010.port_ctrl : 484 + &ha->reg->u2.isp4022.p0.port_ctrl); 494 485 } 495 486 496 487 static inline void __iomem* isp_port_error_status(struct scsi_qla_host *ha) 497 488 { 498 - return (is_qla4022(ha) ? 499 - &ha->reg->u2.isp4022.p0.port_err_status : 500 - &ha->reg->u2.isp4010.port_err_status); 489 + return (is_qla4010(ha) ? 490 + &ha->reg->u2.isp4010.port_err_status : 491 + &ha->reg->u2.isp4022.p0.port_err_status); 501 492 } 502 493 503 494 static inline void __iomem * isp_gp_out(struct scsi_qla_host *ha) 504 495 { 505 - return (is_qla4022(ha) ? 506 - &ha->reg->u2.isp4022.p0.gp_out : 507 - &ha->reg->u2.isp4010.gp_out); 496 + return (is_qla4010(ha) ? 497 + &ha->reg->u2.isp4010.gp_out : 498 + &ha->reg->u2.isp4022.p0.gp_out); 508 499 } 509 500 510 501 static inline int eeprom_ext_hw_conf_offset(struct scsi_qla_host *ha) 511 502 { 512 - return (is_qla4022(ha) ? 513 - offsetof(struct eeprom_data, isp4022.ext_hw_conf) / 2 : 514 - offsetof(struct eeprom_data, isp4010.ext_hw_conf) / 2); 503 + return (is_qla4010(ha) ? 504 + offsetof(struct eeprom_data, isp4010.ext_hw_conf) / 2 : 505 + offsetof(struct eeprom_data, isp4022.ext_hw_conf) / 2); 515 506 } 516 507 517 508 int ql4xxx_sem_spinlock(struct scsi_qla_host * ha, u32 sem_mask, u32 sem_bits); ··· 520 511 521 512 static inline int ql4xxx_lock_flash(struct scsi_qla_host *a) 522 513 { 523 - if (is_qla4022(a)) 514 + if (is_qla4010(a)) 515 + return ql4xxx_sem_spinlock(a, QL4010_FLASH_SEM_MASK, 516 + QL4010_FLASH_SEM_BITS); 517 + else 524 518 return ql4xxx_sem_spinlock(a, QL4022_FLASH_SEM_MASK, 525 519 (QL4022_RESOURCE_BITS_BASE_CODE | 526 520 (a->mac_index)) << 13); 527 - else 528 - return ql4xxx_sem_spinlock(a, QL4010_FLASH_SEM_MASK, 529 - QL4010_FLASH_SEM_BITS); 530 521 } 531 522 532 523 static inline void ql4xxx_unlock_flash(struct scsi_qla_host *a) 533 524 { 534 - if (is_qla4022(a)) 535 - ql4xxx_sem_unlock(a, QL4022_FLASH_SEM_MASK); 536 - else 525 + if (is_qla4010(a)) 537 526 ql4xxx_sem_unlock(a, QL4010_FLASH_SEM_MASK); 527 + else 528 + ql4xxx_sem_unlock(a, QL4022_FLASH_SEM_MASK); 538 529 } 539 530 540 531 static inline int ql4xxx_lock_nvram(struct scsi_qla_host *a) 541 532 { 542 - if (is_qla4022(a)) 533 + if (is_qla4010(a)) 534 + return ql4xxx_sem_spinlock(a, QL4010_NVRAM_SEM_MASK, 535 + QL4010_NVRAM_SEM_BITS); 536 + else 543 537 return ql4xxx_sem_spinlock(a, QL4022_NVRAM_SEM_MASK, 544 538 (QL4022_RESOURCE_BITS_BASE_CODE | 545 539 (a->mac_index)) << 10); 546 - else 547 - return ql4xxx_sem_spinlock(a, QL4010_NVRAM_SEM_MASK, 548 - QL4010_NVRAM_SEM_BITS); 549 540 } 550 541 551 542 static inline void ql4xxx_unlock_nvram(struct scsi_qla_host *a) 552 543 { 553 - if (is_qla4022(a)) 554 - ql4xxx_sem_unlock(a, QL4022_NVRAM_SEM_MASK); 555 - else 544 + if (is_qla4010(a)) 556 545 ql4xxx_sem_unlock(a, QL4010_NVRAM_SEM_MASK); 546 + else 547 + ql4xxx_sem_unlock(a, QL4022_NVRAM_SEM_MASK); 557 548 } 558 549 559 550 static inline int ql4xxx_lock_drvr(struct scsi_qla_host *a) 560 551 { 561 - if (is_qla4022(a)) 552 + if (is_qla4010(a)) 553 + return ql4xxx_sem_lock(a, QL4010_DRVR_SEM_MASK, 554 + QL4010_DRVR_SEM_BITS); 555 + else 562 556 return ql4xxx_sem_lock(a, QL4022_DRVR_SEM_MASK, 563 557 (QL4022_RESOURCE_BITS_BASE_CODE | 564 558 (a->mac_index)) << 1); 565 - else 566 - return ql4xxx_sem_lock(a, QL4010_DRVR_SEM_MASK, 567 - QL4010_DRVR_SEM_BITS); 568 559 } 569 560 570 561 static inline void ql4xxx_unlock_drvr(struct scsi_qla_host *a) 571 562 { 572 - if (is_qla4022(a)) 573 - ql4xxx_sem_unlock(a, QL4022_DRVR_SEM_MASK); 574 - else 563 + if (is_qla4010(a)) 575 564 ql4xxx_sem_unlock(a, QL4010_DRVR_SEM_MASK); 565 + else 566 + ql4xxx_sem_unlock(a, QL4022_DRVR_SEM_MASK); 576 567 } 577 568 578 569 /*---------------------------------------------------------------------------*/
+6 -1
drivers/scsi/qla4xxx/ql4_fw.h
··· 296 296 /* ISP Semaphore definitions */ 297 297 298 298 /* ISP General Purpose Output definitions */ 299 - #define GPOR_TOPCAT_RESET 0x00000004 300 299 301 300 /* shadow registers (DMA'd from HA to system memory. read only) */ 302 301 struct shadow_regs { ··· 338 339 /* Mailbox command definitions */ 339 340 #define MBOX_CMD_ABOUT_FW 0x0009 340 341 #define MBOX_CMD_LUN_RESET 0x0016 342 + #define MBOX_CMD_GET_MANAGEMENT_DATA 0x001E 341 343 #define MBOX_CMD_GET_FW_STATUS 0x001F 342 344 #define MBOX_CMD_SET_ISNS_SERVICE 0x0021 343 345 #define ISNS_DISABLE 0 344 346 #define ISNS_ENABLE 1 347 + #define MBOX_CMD_COPY_FLASH 0x0024 348 + #define MBOX_CMD_WRITE_FLASH 0x0025 345 349 #define MBOX_CMD_READ_FLASH 0x0026 346 350 #define MBOX_CMD_CLEAR_DATABASE_ENTRY 0x0031 347 351 #define MBOX_CMD_CONN_CLOSE_SESS_LOGOUT 0x0056 ··· 362 360 #define DDB_DS_SESSION_FAILED 0x06 363 361 #define DDB_DS_LOGIN_IN_PROCESS 0x07 364 362 #define MBOX_CMD_GET_FW_STATE 0x0069 363 + #define MBOX_CMD_GET_INIT_FW_CTRL_BLOCK_DEFAULTS 0x006A 364 + #define MBOX_CMD_RESTORE_FACTORY_DEFAULTS 0x0087 365 365 366 366 /* Mailbox 1 */ 367 367 #define FW_STATE_READY 0x0000 368 368 #define FW_STATE_CONFIG_WAIT 0x0001 369 + #define FW_STATE_WAIT_LOGIN 0x0002 369 370 #define FW_STATE_ERROR 0x0004 370 371 #define FW_STATE_DHCP_IN_PROGRESS 0x0008 371 372
+2 -1
drivers/scsi/qla4xxx/ql4_glbl.h
··· 8 8 #ifndef __QLA4x_GBL_H 9 9 #define __QLA4x_GBL_H 10 10 11 + int ql4xxx_lock_drvr_wait(struct scsi_qla_host *a); 11 12 int qla4xxx_send_tgts(struct scsi_qla_host *ha, char *ip, uint16_t port); 12 13 int qla4xxx_send_command_to_isp(struct scsi_qla_host *ha, struct srb * srb); 13 14 int qla4xxx_initialize_adapter(struct scsi_qla_host * ha, ··· 76 75 extern int ql4xextended_error_logging; 77 76 extern int ql4xdiscoverywait; 78 77 extern int ql4xdontresethba; 79 - #endif /* _QLA4x_GBL_H */ 78 + #endif /* _QLA4x_GBL_H */
+11 -36
drivers/scsi/qla4xxx/ql4_init.c
··· 259 259 "seconds expired= %d\n", ha->host_no, __func__, 260 260 ha->firmware_state, ha->addl_fw_state, 261 261 timeout_count)); 262 + if (is_qla4032(ha) && 263 + !(ha->addl_fw_state & FW_ADDSTATE_LINK_UP) && 264 + (timeout_count < ADAPTER_INIT_TOV - 5)) { 265 + break; 266 + } 267 + 262 268 msleep(1000); 263 269 } /* end of for */ 264 270 265 - if (timeout_count <= 0) 271 + if (timeout_count == 0) 266 272 DEBUG2(printk("scsi%ld: %s: FW Initialization timed out!\n", 267 273 ha->host_no, __func__)); 268 274 ··· 812 806 return QLA_SUCCESS; 813 807 } 814 808 815 - /** 816 - * qla4010_get_topcat_presence - check if it is QLA4040 TopCat Chip 817 - * @ha: Pointer to host adapter structure. 818 - * 819 - **/ 820 - static int qla4010_get_topcat_presence(struct scsi_qla_host *ha) 821 - { 822 - unsigned long flags; 823 - uint16_t topcat; 824 - 825 - if (ql4xxx_lock_nvram(ha) != QLA_SUCCESS) 826 - return QLA_ERROR; 827 - spin_lock_irqsave(&ha->hardware_lock, flags); 828 - topcat = rd_nvram_word(ha, offsetof(struct eeprom_data, 829 - isp4010.topcat)); 830 - spin_unlock_irqrestore(&ha->hardware_lock, flags); 831 - 832 - if ((topcat & TOPCAT_MASK) == TOPCAT_PRESENT) 833 - set_bit(AF_TOPCAT_CHIP_PRESENT, &ha->flags); 834 - else 835 - clear_bit(AF_TOPCAT_CHIP_PRESENT, &ha->flags); 836 - ql4xxx_unlock_nvram(ha); 837 - return QLA_SUCCESS; 838 - } 839 - 840 - 841 809 static int qla4xxx_config_nvram(struct scsi_qla_host *ha) 842 810 { 843 811 unsigned long flags; ··· 846 866 /* set defaults */ 847 867 if (is_qla4010(ha)) 848 868 extHwConfig.Asuint32_t = 0x1912; 849 - else if (is_qla4022(ha)) 869 + else if (is_qla4022(ha) | is_qla4032(ha)) 850 870 extHwConfig.Asuint32_t = 0x0023; 851 871 } 852 872 DEBUG(printk("scsi%ld: %s: Setting extHwConfig to 0xFFFF%04x\n", ··· 907 927 908 928 spin_lock_irqsave(&ha->hardware_lock, flags); 909 929 writel(jiffies, &ha->reg->mailbox[7]); 910 - if (is_qla4022(ha)) 930 + if (is_qla4022(ha) | is_qla4032(ha)) 911 931 writel(set_rmask(NVR_WRITE_ENABLE), 912 932 &ha->reg->u1.isp4022.nvram); 913 933 ··· 958 978 return status; 959 979 } 960 980 961 - static int ql4xxx_lock_drvr_wait(struct scsi_qla_host *a) 981 + int ql4xxx_lock_drvr_wait(struct scsi_qla_host *a) 962 982 { 963 983 #define QL4_LOCK_DRVR_WAIT 300 964 984 #define QL4_LOCK_DRVR_SLEEP 100 ··· 998 1018 int soft_reset = 1; 999 1019 int config_chip = 0; 1000 1020 1001 - if (is_qla4010(ha)){ 1002 - if (qla4010_get_topcat_presence(ha) != QLA_SUCCESS) 1003 - return QLA_ERROR; 1004 - } 1005 - 1006 - if (is_qla4022(ha)) 1021 + if (is_qla4022(ha) | is_qla4032(ha)) 1007 1022 ql4xxx_set_mac_number(ha); 1008 1023 1009 1024 if (ql4xxx_lock_drvr_wait(ha) != QLA_SUCCESS)
+2 -2
drivers/scsi/qla4xxx/ql4_inline.h
··· 38 38 static inline void 39 39 __qla4xxx_enable_intrs(struct scsi_qla_host *ha) 40 40 { 41 - if (is_qla4022(ha)) { 41 + if (is_qla4022(ha) | is_qla4032(ha)) { 42 42 writel(set_rmask(IMR_SCSI_INTR_ENABLE), 43 43 &ha->reg->u1.isp4022.intr_mask); 44 44 readl(&ha->reg->u1.isp4022.intr_mask); ··· 52 52 static inline void 53 53 __qla4xxx_disable_intrs(struct scsi_qla_host *ha) 54 54 { 55 - if (is_qla4022(ha)) { 55 + if (is_qla4022(ha) | is_qla4032(ha)) { 56 56 writel(clr_rmask(IMR_SCSI_INTR_ENABLE), 57 57 &ha->reg->u1.isp4022.intr_mask); 58 58 readl(&ha->reg->u1.isp4022.intr_mask);
+6
drivers/scsi/qla4xxx/ql4_iocb.c
··· 294 294 cmd_entry->control_flags = CF_WRITE; 295 295 else if (cmd->sc_data_direction == DMA_FROM_DEVICE) 296 296 cmd_entry->control_flags = CF_READ; 297 + 298 + ha->bytes_xfered += cmd->request_bufflen; 299 + if (ha->bytes_xfered & ~0xFFFFF){ 300 + ha->total_mbytes_xferred += ha->bytes_xfered >> 20; 301 + ha->bytes_xfered &= 0xFFFFF; 302 + } 297 303 } 298 304 299 305 /* Set tagged queueing control flags */
+1
drivers/scsi/qla4xxx/ql4_isr.c
··· 627 627 628 628 spin_lock_irqsave(&ha->hardware_lock, flags); 629 629 630 + ha->isr_count++; 630 631 /* 631 632 * Repeatedly service interrupts up to a maximum of 632 633 * MAX_REQS_SERVICED_PER_INTR
+39 -31
drivers/scsi/qla4xxx/ql4_nvram.c
··· 7 7 8 8 #include "ql4_def.h" 9 9 10 + static inline void eeprom_cmd(uint32_t cmd, struct scsi_qla_host *ha) 11 + { 12 + writel(cmd, isp_nvram(ha)); 13 + readl(isp_nvram(ha)); 14 + udelay(1); 15 + } 16 + 10 17 static inline int eeprom_size(struct scsi_qla_host *ha) 11 18 { 12 - return is_qla4022(ha) ? FM93C86A_SIZE_16 : FM93C66A_SIZE_16; 19 + return is_qla4010(ha) ? FM93C66A_SIZE_16 : FM93C86A_SIZE_16; 13 20 } 14 21 15 22 static inline int eeprom_no_addr_bits(struct scsi_qla_host *ha) 16 23 { 17 - return is_qla4022(ha) ? FM93C86A_NO_ADDR_BITS_16 : 18 - FM93C56A_NO_ADDR_BITS_16; 24 + return is_qla4010(ha) ? FM93C56A_NO_ADDR_BITS_16 : 25 + FM93C86A_NO_ADDR_BITS_16 ; 19 26 } 20 27 21 28 static inline int eeprom_no_data_bits(struct scsi_qla_host *ha) ··· 35 28 DEBUG5(printk(KERN_ERR "fm93c56a_select:\n")); 36 29 37 30 ha->eeprom_cmd_data = AUBURN_EEPROM_CS_1 | 0x000f0000; 38 - writel(ha->eeprom_cmd_data, isp_nvram(ha)); 39 - readl(isp_nvram(ha)); 31 + eeprom_cmd(ha->eeprom_cmd_data, ha); 40 32 return 1; 41 33 } 42 34 ··· 47 41 int previousBit; 48 42 49 43 /* Clock in a zero, then do the start bit. */ 50 - writel(ha->eeprom_cmd_data | AUBURN_EEPROM_DO_1, isp_nvram(ha)); 51 - writel(ha->eeprom_cmd_data | AUBURN_EEPROM_DO_1 | 52 - AUBURN_EEPROM_CLK_RISE, isp_nvram(ha)); 53 - writel(ha->eeprom_cmd_data | AUBURN_EEPROM_DO_1 | 54 - AUBURN_EEPROM_CLK_FALL, isp_nvram(ha)); 55 - readl(isp_nvram(ha)); 44 + eeprom_cmd(ha->eeprom_cmd_data | AUBURN_EEPROM_DO_1, ha); 45 + 46 + eeprom_cmd(ha->eeprom_cmd_data | AUBURN_EEPROM_DO_1 | 47 + AUBURN_EEPROM_CLK_RISE, ha); 48 + eeprom_cmd(ha->eeprom_cmd_data | AUBURN_EEPROM_DO_1 | 49 + AUBURN_EEPROM_CLK_FALL, ha); 50 + 56 51 mask = 1 << (FM93C56A_CMD_BITS - 1); 57 52 58 53 /* Force the previous data bit to be different. */ ··· 67 60 * If the bit changed, then change the DO state to 68 61 * match. 69 62 */ 70 - writel(ha->eeprom_cmd_data | dataBit, isp_nvram(ha)); 63 + eeprom_cmd(ha->eeprom_cmd_data | dataBit, ha); 71 64 previousBit = dataBit; 72 65 } 73 - writel(ha->eeprom_cmd_data | dataBit | 74 - AUBURN_EEPROM_CLK_RISE, isp_nvram(ha)); 75 - writel(ha->eeprom_cmd_data | dataBit | 76 - AUBURN_EEPROM_CLK_FALL, isp_nvram(ha)); 77 - readl(isp_nvram(ha)); 66 + eeprom_cmd(ha->eeprom_cmd_data | dataBit | 67 + AUBURN_EEPROM_CLK_RISE, ha); 68 + eeprom_cmd(ha->eeprom_cmd_data | dataBit | 69 + AUBURN_EEPROM_CLK_FALL, ha); 70 + 78 71 cmd = cmd << 1; 79 72 } 80 73 mask = 1 << (eeprom_no_addr_bits(ha) - 1); ··· 89 82 * If the bit changed, then change the DO state to 90 83 * match. 91 84 */ 92 - writel(ha->eeprom_cmd_data | dataBit, isp_nvram(ha)); 85 + eeprom_cmd(ha->eeprom_cmd_data | dataBit, ha); 86 + 93 87 previousBit = dataBit; 94 88 } 95 - writel(ha->eeprom_cmd_data | dataBit | 96 - AUBURN_EEPROM_CLK_RISE, isp_nvram(ha)); 97 - writel(ha->eeprom_cmd_data | dataBit | 98 - AUBURN_EEPROM_CLK_FALL, isp_nvram(ha)); 99 - readl(isp_nvram(ha)); 89 + eeprom_cmd(ha->eeprom_cmd_data | dataBit | 90 + AUBURN_EEPROM_CLK_RISE, ha); 91 + eeprom_cmd(ha->eeprom_cmd_data | dataBit | 92 + AUBURN_EEPROM_CLK_FALL, ha); 93 + 100 94 addr = addr << 1; 101 95 } 102 96 return 1; ··· 106 98 static int fm93c56a_deselect(struct scsi_qla_host * ha) 107 99 { 108 100 ha->eeprom_cmd_data = AUBURN_EEPROM_CS_0 | 0x000f0000; 109 - writel(ha->eeprom_cmd_data, isp_nvram(ha)); 110 - readl(isp_nvram(ha)); 101 + eeprom_cmd(ha->eeprom_cmd_data, ha); 111 102 return 1; 112 103 } 113 104 ··· 119 112 /* Read the data bits 120 113 * The first bit is a dummy. Clock right over it. */ 121 114 for (i = 0; i < eeprom_no_data_bits(ha); i++) { 122 - writel(ha->eeprom_cmd_data | 123 - AUBURN_EEPROM_CLK_RISE, isp_nvram(ha)); 124 - writel(ha->eeprom_cmd_data | 125 - AUBURN_EEPROM_CLK_FALL, isp_nvram(ha)); 126 - dataBit = 127 - (readw(isp_nvram(ha)) & AUBURN_EEPROM_DI_1) ? 1 : 0; 115 + eeprom_cmd(ha->eeprom_cmd_data | 116 + AUBURN_EEPROM_CLK_RISE, ha); 117 + eeprom_cmd(ha->eeprom_cmd_data | 118 + AUBURN_EEPROM_CLK_FALL, ha); 119 + 120 + dataBit = (readw(isp_nvram(ha)) & AUBURN_EEPROM_DI_1) ? 1 : 0; 121 + 128 122 data = (data << 1) | dataBit; 129 123 } 130 124
+1 -3
drivers/scsi/qla4xxx/ql4_nvram.h
··· 134 134 u16 phyConfig; /* x36 */ 135 135 #define PHY_CONFIG_PHY_ADDR_MASK 0x1f 136 136 #define PHY_CONFIG_ENABLE_FW_MANAGEMENT_MASK 0x20 137 - u16 topcat; /* x38 */ 138 - #define TOPCAT_PRESENT 0x0100 139 - #define TOPCAT_MASK 0xFF00 137 + u16 reserved_56; /* x38 */ 140 138 141 139 #define EEPROM_UNUSED_1_SIZE 2 142 140 u8 unused_1[EEPROM_UNUSED_1_SIZE]; /* x3A */
+20 -97
drivers/scsi/qla4xxx/ql4_os.c
··· 708 708 } 709 709 710 710 /** 711 - * qla4010_soft_reset - performs soft reset. 711 + * qla4xxx_soft_reset - performs soft reset. 712 712 * @ha: Pointer to host adapter structure. 713 713 **/ 714 - static int qla4010_soft_reset(struct scsi_qla_host *ha) 714 + int qla4xxx_soft_reset(struct scsi_qla_host *ha) 715 715 { 716 716 uint32_t max_wait_time; 717 717 unsigned long flags = 0; ··· 817 817 } 818 818 819 819 /** 820 - * qla4xxx_topcat_reset - performs hard reset of TopCat Chip. 821 - * @ha: Pointer to host adapter structure. 822 - **/ 823 - static int qla4xxx_topcat_reset(struct scsi_qla_host *ha) 824 - { 825 - unsigned long flags; 826 - 827 - ql4xxx_lock_nvram(ha); 828 - spin_lock_irqsave(&ha->hardware_lock, flags); 829 - writel(set_rmask(GPOR_TOPCAT_RESET), isp_gp_out(ha)); 830 - readl(isp_gp_out(ha)); 831 - mdelay(1); 832 - 833 - writel(clr_rmask(GPOR_TOPCAT_RESET), isp_gp_out(ha)); 834 - readl(isp_gp_out(ha)); 835 - spin_unlock_irqrestore(&ha->hardware_lock, flags); 836 - mdelay(2523); 837 - 838 - ql4xxx_unlock_nvram(ha); 839 - return QLA_SUCCESS; 840 - } 841 - 842 - /** 843 820 * qla4xxx_flush_active_srbs - returns all outstanding i/o requests to O.S. 844 821 * @ha: Pointer to host adapter structure. 845 822 * ··· 841 864 } 842 865 spin_unlock_irqrestore(&ha->hardware_lock, flags); 843 866 844 - } 845 - 846 - /** 847 - * qla4xxx_hard_reset - performs HBA Hard Reset 848 - * @ha: Pointer to host adapter structure. 849 - **/ 850 - static int qla4xxx_hard_reset(struct scsi_qla_host *ha) 851 - { 852 - /* The QLA4010 really doesn't have an equivalent to a hard reset */ 853 - qla4xxx_flush_active_srbs(ha); 854 - if (test_bit(AF_TOPCAT_CHIP_PRESENT, &ha->flags)) { 855 - int status = QLA_ERROR; 856 - 857 - if ((qla4010_soft_reset(ha) == QLA_SUCCESS) && 858 - (qla4xxx_topcat_reset(ha) == QLA_SUCCESS) && 859 - (qla4010_soft_reset(ha) == QLA_SUCCESS)) 860 - status = QLA_SUCCESS; 861 - return status; 862 - } else 863 - return qla4010_soft_reset(ha); 864 867 } 865 868 866 869 /** ··· 876 919 if (status == QLA_SUCCESS) { 877 920 DEBUG2(printk("scsi%ld: %s - Performing soft reset..\n", 878 921 ha->host_no, __func__)); 879 - status = qla4xxx_soft_reset(ha); 880 - } 881 - /* FIXMEkaren: Do we want to keep interrupts enabled and process 882 - AENs after soft reset */ 883 - 884 - /* If firmware (SOFT) reset failed, or if all outstanding 885 - * commands have not returned, then do a HARD reset. 886 - */ 887 - if (status == QLA_ERROR) { 888 - DEBUG2(printk("scsi%ld: %s - Performing hard reset..\n", 889 - ha->host_no, __func__)); 890 - status = qla4xxx_hard_reset(ha); 922 + qla4xxx_flush_active_srbs(ha); 923 + if (ql4xxx_lock_drvr_wait(ha) == QLA_SUCCESS) 924 + status = qla4xxx_soft_reset(ha); 925 + else 926 + status = QLA_ERROR; 891 927 } 892 928 893 929 /* Flush any pending ddb changed AENs */ ··· 966 1016 struct scsi_qla_host *ha = (struct scsi_qla_host *) data; 967 1017 struct ddb_entry *ddb_entry, *dtemp; 968 1018 969 - DEBUG2(printk("scsi%ld: %s: DPC handler waking up.\n", 970 - ha->host_no, __func__)); 971 - 972 - DEBUG2(printk("scsi%ld: %s: ha->flags = 0x%08lx\n", 973 - ha->host_no, __func__, ha->flags)); 974 - DEBUG2(printk("scsi%ld: %s: ha->dpc_flags = 0x%08lx\n", 975 - ha->host_no, __func__, ha->dpc_flags)); 1019 + DEBUG2(printk("scsi%ld: %s: DPC handler waking up." 1020 + "flags = 0x%08lx, dpc_flags = 0x%08lx\n", 1021 + ha->host_no, __func__, ha->flags, ha->dpc_flags)); 976 1022 977 1023 /* Initialization not yet finished. Don't do anything yet. */ 978 1024 if (!test_bit(AF_INIT_DONE, &ha->flags)) ··· 978 1032 test_bit(DPC_RESET_HA, &ha->dpc_flags) || 979 1033 test_bit(DPC_RESET_HA_INTR, &ha->dpc_flags) || 980 1034 test_bit(DPC_RESET_HA_DESTROY_DDB_LIST, &ha->dpc_flags)) { 981 - if (test_bit(DPC_RESET_HA_DESTROY_DDB_LIST, &ha->dpc_flags)) 982 - /* 983 - * dg 09/23 Never initialize ddb list 984 - * once we up and running 985 - * qla4xxx_recover_adapter(ha, 986 - * REBUILD_DDB_LIST); 987 - */ 988 - qla4xxx_recover_adapter(ha, PRESERVE_DDB_LIST); 989 - 990 - if (test_bit(DPC_RESET_HA, &ha->dpc_flags)) 1035 + if (test_bit(DPC_RESET_HA_DESTROY_DDB_LIST, &ha->dpc_flags) || 1036 + test_bit(DPC_RESET_HA, &ha->dpc_flags)) 991 1037 qla4xxx_recover_adapter(ha, PRESERVE_DDB_LIST); 992 1038 993 1039 if (test_and_clear_bit(DPC_RESET_HA_INTR, &ha->dpc_flags)) { ··· 1060 1122 destroy_workqueue(ha->dpc_thread); 1061 1123 1062 1124 /* Issue Soft Reset to put firmware in unknown state */ 1063 - qla4xxx_soft_reset(ha); 1125 + if (ql4xxx_lock_drvr_wait(ha) == QLA_SUCCESS) 1126 + qla4xxx_soft_reset(ha); 1064 1127 1065 1128 /* Remove timer thread, if present */ 1066 1129 if (ha->timer_active) ··· 1200 1261 init_waitqueue_head(&ha->mailbox_wait_queue); 1201 1262 1202 1263 spin_lock_init(&ha->hardware_lock); 1203 - spin_lock_init(&ha->list_lock); 1204 1264 1205 1265 /* Allocate dma buffers */ 1206 1266 if (qla4xxx_mem_alloc(ha)) { ··· 1406 1468 } 1407 1469 1408 1470 /** 1409 - * qla4xxx_soft_reset - performs a SOFT RESET of hba. 1410 - * @ha: Pointer to host adapter structure. 1411 - **/ 1412 - int qla4xxx_soft_reset(struct scsi_qla_host *ha) 1413 - { 1414 - 1415 - DEBUG2(printk(KERN_WARNING "scsi%ld: %s: chip reset!\n", ha->host_no, 1416 - __func__)); 1417 - if (test_bit(AF_TOPCAT_CHIP_PRESENT, &ha->flags)) { 1418 - int status = QLA_ERROR; 1419 - 1420 - if ((qla4010_soft_reset(ha) == QLA_SUCCESS) && 1421 - (qla4xxx_topcat_reset(ha) == QLA_SUCCESS) && 1422 - (qla4010_soft_reset(ha) == QLA_SUCCESS) ) 1423 - status = QLA_SUCCESS; 1424 - return status; 1425 - } else 1426 - return qla4010_soft_reset(ha); 1427 - } 1428 - 1429 - /** 1430 1471 * qla4xxx_eh_wait_on_command - waits for command to be returned by firmware 1431 1472 * @ha: actual ha whose done queue will contain the comd returned by firmware. 1432 1473 * @cmd: Scsi Command to wait on. ··· 1600 1683 { 1601 1684 .vendor = PCI_VENDOR_ID_QLOGIC, 1602 1685 .device = PCI_DEVICE_ID_QLOGIC_ISP4022, 1686 + .subvendor = PCI_ANY_ID, 1687 + .subdevice = PCI_ANY_ID, 1688 + }, 1689 + { 1690 + .vendor = PCI_VENDOR_ID_QLOGIC, 1691 + .device = PCI_DEVICE_ID_QLOGIC_ISP4032, 1603 1692 .subvendor = PCI_ANY_ID, 1604 1693 .subdevice = PCI_ANY_ID, 1605 1694 },
+1 -6
drivers/scsi/qla4xxx/ql4_version.h
··· 5 5 * See LICENSE.qla4xxx for copyright and licensing details. 6 6 */ 7 7 8 - #define QLA4XXX_DRIVER_VERSION "5.00.05b9-k" 9 - 10 - #define QL4_DRIVER_MAJOR_VER 5 11 - #define QL4_DRIVER_MINOR_VER 0 12 - #define QL4_DRIVER_PATCH_VER 5 13 - #define QL4_DRIVER_BETA_VER 9 8 + #define QLA4XXX_DRIVER_VERSION "5.00.07-k"
+27 -18
drivers/scsi/scsi.c
··· 156 156 157 157 static DEFINE_MUTEX(host_cmd_pool_mutex); 158 158 159 - static struct scsi_cmnd *__scsi_get_command(struct Scsi_Host *shost, 160 - gfp_t gfp_mask) 159 + struct scsi_cmnd *__scsi_get_command(struct Scsi_Host *shost, gfp_t gfp_mask) 161 160 { 162 161 struct scsi_cmnd *cmd; 163 162 ··· 177 178 178 179 return cmd; 179 180 } 181 + EXPORT_SYMBOL_GPL(__scsi_get_command); 180 182 181 183 /* 182 184 * Function: scsi_get_command() ··· 214 214 put_device(&dev->sdev_gendev); 215 215 216 216 return cmd; 217 - } 217 + } 218 218 EXPORT_SYMBOL(scsi_get_command); 219 + 220 + void __scsi_put_command(struct Scsi_Host *shost, struct scsi_cmnd *cmd, 221 + struct device *dev) 222 + { 223 + unsigned long flags; 224 + 225 + /* changing locks here, don't need to restore the irq state */ 226 + spin_lock_irqsave(&shost->free_list_lock, flags); 227 + if (unlikely(list_empty(&shost->free_list))) { 228 + list_add(&cmd->list, &shost->free_list); 229 + cmd = NULL; 230 + } 231 + spin_unlock_irqrestore(&shost->free_list_lock, flags); 232 + 233 + if (likely(cmd != NULL)) 234 + kmem_cache_free(shost->cmd_pool->slab, cmd); 235 + 236 + put_device(dev); 237 + } 238 + EXPORT_SYMBOL(__scsi_put_command); 219 239 220 240 /* 221 241 * Function: scsi_put_command() ··· 251 231 void scsi_put_command(struct scsi_cmnd *cmd) 252 232 { 253 233 struct scsi_device *sdev = cmd->device; 254 - struct Scsi_Host *shost = sdev->host; 255 234 unsigned long flags; 256 - 235 + 257 236 /* serious error if the command hasn't come from a device list */ 258 237 spin_lock_irqsave(&cmd->device->list_lock, flags); 259 238 BUG_ON(list_empty(&cmd->list)); 260 239 list_del_init(&cmd->list); 261 - spin_unlock(&cmd->device->list_lock); 262 - /* changing locks here, don't need to restore the irq state */ 263 - spin_lock(&shost->free_list_lock); 264 - if (unlikely(list_empty(&shost->free_list))) { 265 - list_add(&cmd->list, &shost->free_list); 266 - cmd = NULL; 267 - } 268 - spin_unlock_irqrestore(&shost->free_list_lock, flags); 240 + spin_unlock_irqrestore(&cmd->device->list_lock, flags); 269 241 270 - if (likely(cmd != NULL)) 271 - kmem_cache_free(shost->cmd_pool->slab, cmd); 272 - 273 - put_device(&sdev->sdev_gendev); 242 + __scsi_put_command(cmd->device->host, cmd, &sdev->sdev_gendev); 274 243 } 275 244 EXPORT_SYMBOL(scsi_put_command); 276 245 ··· 880 871 */ 881 872 void scsi_device_put(struct scsi_device *sdev) 882 873 { 874 + #ifdef CONFIG_MODULE_UNLOAD 883 875 struct module *module = sdev->host->hostt->module; 884 876 885 - #ifdef CONFIG_MODULE_UNLOAD 886 877 /* The module refcount will be zero if scsi_device_get() 887 878 * was called from a module removal routine */ 888 879 if (module && module_refcount(module) != 0)
+24 -9
drivers/scsi/scsi_error.c
··· 453 453 } 454 454 455 455 /** 456 - * scsi_send_eh_cmnd - send a cmd to a device as part of error recovery. 457 - * @scmd: SCSI Cmd to send. 458 - * @timeout: Timeout for cmd. 456 + * scsi_send_eh_cmnd - submit a scsi command as part of error recory 457 + * @scmd: SCSI command structure to hijack 458 + * @cmnd: CDB to send 459 + * @cmnd_size: size in bytes of @cmnd 460 + * @timeout: timeout for this request 461 + * @copy_sense: request sense data if set to 1 462 + * 463 + * This function is used to send a scsi command down to a target device 464 + * as part of the error recovery process. If @copy_sense is 0 the command 465 + * sent must be one that does not transfer any data. If @copy_sense is 1 466 + * the command must be REQUEST_SENSE and this functions copies out the 467 + * sense buffer it got into @scmd->sense_buffer. 459 468 * 460 469 * Return value: 461 470 * SUCCESS or FAILED or NEEDS_RETRY ··· 478 469 DECLARE_COMPLETION_ONSTACK(done); 479 470 unsigned long timeleft; 480 471 unsigned long flags; 472 + struct scatterlist sgl; 481 473 unsigned char old_cmnd[MAX_COMMAND_SIZE]; 482 474 enum dma_data_direction old_data_direction; 483 475 unsigned short old_use_sg; ··· 510 500 if (shost->hostt->unchecked_isa_dma) 511 501 gfp_mask |= __GFP_DMA; 512 502 513 - scmd->sc_data_direction = DMA_FROM_DEVICE; 514 - scmd->request_bufflen = 252; 515 - scmd->request_buffer = kzalloc(scmd->request_bufflen, gfp_mask); 516 - if (!scmd->request_buffer) 503 + sgl.page = alloc_page(gfp_mask); 504 + if (!sgl.page) 517 505 return FAILED; 506 + sgl.offset = 0; 507 + sgl.length = 252; 508 + 509 + scmd->sc_data_direction = DMA_FROM_DEVICE; 510 + scmd->request_bufflen = sgl.length; 511 + scmd->request_buffer = &sgl; 512 + scmd->use_sg = 1; 518 513 } else { 519 514 scmd->request_buffer = NULL; 520 515 scmd->request_bufflen = 0; 521 516 scmd->sc_data_direction = DMA_NONE; 517 + scmd->use_sg = 0; 522 518 } 523 519 524 520 scmd->underflow = 0; 525 - scmd->use_sg = 0; 526 521 scmd->cmd_len = COMMAND_SIZE(scmd->cmnd[0]); 527 522 528 523 if (sdev->scsi_level <= SCSI_2) ··· 598 583 memcpy(scmd->sense_buffer, scmd->request_buffer, 599 584 sizeof(scmd->sense_buffer)); 600 585 } 601 - kfree(scmd->request_buffer); 586 + __free_page(sgl.page); 602 587 } 603 588 604 589
+193 -159
drivers/scsi/scsi_lib.c
··· 704 704 return NULL; 705 705 } 706 706 707 - static struct scatterlist *scsi_alloc_sgtable(struct scsi_cmnd *cmd, gfp_t gfp_mask) 707 + struct scatterlist *scsi_alloc_sgtable(struct scsi_cmnd *cmd, gfp_t gfp_mask) 708 708 { 709 709 struct scsi_host_sg_pool *sgp; 710 710 struct scatterlist *sgl; ··· 745 745 return sgl; 746 746 } 747 747 748 - static void scsi_free_sgtable(struct scatterlist *sgl, int index) 748 + EXPORT_SYMBOL(scsi_alloc_sgtable); 749 + 750 + void scsi_free_sgtable(struct scatterlist *sgl, int index) 749 751 { 750 752 struct scsi_host_sg_pool *sgp; 751 753 ··· 756 754 sgp = scsi_sg_pools + index; 757 755 mempool_free(sgl, sgp->pool); 758 756 } 757 + 758 + EXPORT_SYMBOL(scsi_free_sgtable); 759 759 760 760 /* 761 761 * Function: scsi_release_buffers() ··· 1000 996 int count; 1001 997 1002 998 /* 1003 - * if this is a rq->data based REQ_BLOCK_PC, setup for a non-sg xfer 1004 - */ 1005 - if (blk_pc_request(req) && !req->bio) { 1006 - cmd->request_bufflen = req->data_len; 1007 - cmd->request_buffer = req->data; 1008 - req->buffer = req->data; 1009 - cmd->use_sg = 0; 1010 - return 0; 1011 - } 1012 - 1013 - /* 1014 - * we used to not use scatter-gather for single segment request, 999 + * We used to not use scatter-gather for single segment request, 1015 1000 * but now we do (it makes highmem I/O easier to support without 1016 1001 * kmapping pages) 1017 1002 */ 1018 1003 cmd->use_sg = req->nr_phys_segments; 1019 1004 1020 1005 /* 1021 - * if sg table allocation fails, requeue request later. 1006 + * If sg table allocation fails, requeue request later. 1022 1007 */ 1023 1008 sgpnt = scsi_alloc_sgtable(cmd, GFP_ATOMIC); 1024 1009 if (unlikely(!sgpnt)) { ··· 1015 1022 return BLKPREP_DEFER; 1016 1023 } 1017 1024 1025 + req->buffer = NULL; 1018 1026 cmd->request_buffer = (char *) sgpnt; 1019 - cmd->request_bufflen = req->nr_sectors << 9; 1020 1027 if (blk_pc_request(req)) 1021 1028 cmd->request_bufflen = req->data_len; 1022 - req->buffer = NULL; 1029 + else 1030 + cmd->request_bufflen = req->nr_sectors << 9; 1023 1031 1024 1032 /* 1025 1033 * Next, walk the list, and fill in the addresses and sizes of 1026 1034 * each segment. 1027 1035 */ 1028 1036 count = blk_rq_map_sg(req->q, req, cmd->request_buffer); 1029 - 1030 - /* 1031 - * mapped well, send it off 1032 - */ 1033 1037 if (likely(count <= cmd->use_sg)) { 1034 1038 cmd->use_sg = count; 1035 - return 0; 1039 + return BLKPREP_OK; 1036 1040 } 1037 1041 1038 1042 printk(KERN_ERR "Incorrect number of segments after building list\n"); ··· 1059 1069 return -EOPNOTSUPP; 1060 1070 } 1061 1071 1072 + static struct scsi_cmnd *scsi_get_cmd_from_req(struct scsi_device *sdev, 1073 + struct request *req) 1074 + { 1075 + struct scsi_cmnd *cmd; 1076 + 1077 + if (!req->special) { 1078 + cmd = scsi_get_command(sdev, GFP_ATOMIC); 1079 + if (unlikely(!cmd)) 1080 + return NULL; 1081 + req->special = cmd; 1082 + } else { 1083 + cmd = req->special; 1084 + } 1085 + 1086 + /* pull a tag out of the request if we have one */ 1087 + cmd->tag = req->tag; 1088 + cmd->request = req; 1089 + 1090 + return cmd; 1091 + } 1092 + 1062 1093 static void scsi_blk_pc_done(struct scsi_cmnd *cmd) 1063 1094 { 1064 1095 BUG_ON(!blk_pc_request(cmd->request)); ··· 1092 1081 scsi_io_completion(cmd, cmd->request_bufflen); 1093 1082 } 1094 1083 1095 - static void scsi_setup_blk_pc_cmnd(struct scsi_cmnd *cmd) 1084 + static int scsi_setup_blk_pc_cmnd(struct scsi_device *sdev, struct request *req) 1096 1085 { 1097 - struct request *req = cmd->request; 1086 + struct scsi_cmnd *cmd; 1087 + 1088 + cmd = scsi_get_cmd_from_req(sdev, req); 1089 + if (unlikely(!cmd)) 1090 + return BLKPREP_DEFER; 1091 + 1092 + /* 1093 + * BLOCK_PC requests may transfer data, in which case they must 1094 + * a bio attached to them. Or they might contain a SCSI command 1095 + * that does not transfer data, in which case they may optionally 1096 + * submit a request without an attached bio. 1097 + */ 1098 + if (req->bio) { 1099 + int ret; 1100 + 1101 + BUG_ON(!req->nr_phys_segments); 1102 + 1103 + ret = scsi_init_io(cmd); 1104 + if (unlikely(ret)) 1105 + return ret; 1106 + } else { 1107 + BUG_ON(req->data_len); 1108 + BUG_ON(req->data); 1109 + 1110 + cmd->request_bufflen = 0; 1111 + cmd->request_buffer = NULL; 1112 + cmd->use_sg = 0; 1113 + req->buffer = NULL; 1114 + } 1098 1115 1099 1116 BUILD_BUG_ON(sizeof(req->cmd) > sizeof(cmd->cmnd)); 1100 1117 memcpy(cmd->cmnd, req->cmd, sizeof(cmd->cmnd)); ··· 1138 1099 cmd->allowed = req->retries; 1139 1100 cmd->timeout_per_command = req->timeout; 1140 1101 cmd->done = scsi_blk_pc_done; 1102 + return BLKPREP_OK; 1103 + } 1104 + 1105 + /* 1106 + * Setup a REQ_TYPE_FS command. These are simple read/write request 1107 + * from filesystems that still need to be translated to SCSI CDBs from 1108 + * the ULD. 1109 + */ 1110 + static int scsi_setup_fs_cmnd(struct scsi_device *sdev, struct request *req) 1111 + { 1112 + struct scsi_cmnd *cmd; 1113 + struct scsi_driver *drv; 1114 + int ret; 1115 + 1116 + /* 1117 + * Filesystem requests must transfer data. 1118 + */ 1119 + BUG_ON(!req->nr_phys_segments); 1120 + 1121 + cmd = scsi_get_cmd_from_req(sdev, req); 1122 + if (unlikely(!cmd)) 1123 + return BLKPREP_DEFER; 1124 + 1125 + ret = scsi_init_io(cmd); 1126 + if (unlikely(ret)) 1127 + return ret; 1128 + 1129 + /* 1130 + * Initialize the actual SCSI command for this request. 1131 + */ 1132 + drv = *(struct scsi_driver **)req->rq_disk->private_data; 1133 + if (unlikely(!drv->init_command(cmd))) { 1134 + scsi_release_buffers(cmd); 1135 + scsi_put_command(cmd); 1136 + return BLKPREP_KILL; 1137 + } 1138 + 1139 + return BLKPREP_OK; 1141 1140 } 1142 1141 1143 1142 static int scsi_prep_fn(struct request_queue *q, struct request *req) 1144 1143 { 1145 1144 struct scsi_device *sdev = q->queuedata; 1146 - struct scsi_cmnd *cmd; 1147 - int specials_only = 0; 1145 + int ret = BLKPREP_OK; 1148 1146 1149 1147 /* 1150 - * Just check to see if the device is online. If it isn't, we 1151 - * refuse to process any commands. The device must be brought 1152 - * online before trying any recovery commands 1148 + * If the device is not in running state we will reject some 1149 + * or all commands. 1153 1150 */ 1154 - if (unlikely(!scsi_device_online(sdev))) { 1155 - sdev_printk(KERN_ERR, sdev, 1156 - "rejecting I/O to offline device\n"); 1157 - goto kill; 1158 - } 1159 1151 if (unlikely(sdev->sdev_state != SDEV_RUNNING)) { 1160 - /* OK, we're not in a running state don't prep 1161 - * user commands */ 1162 - if (sdev->sdev_state == SDEV_DEL) { 1163 - /* Device is fully deleted, no commands 1164 - * at all allowed down */ 1152 + switch (sdev->sdev_state) { 1153 + case SDEV_OFFLINE: 1154 + /* 1155 + * If the device is offline we refuse to process any 1156 + * commands. The device must be brought online 1157 + * before trying any recovery commands. 1158 + */ 1159 + sdev_printk(KERN_ERR, sdev, 1160 + "rejecting I/O to offline device\n"); 1161 + ret = BLKPREP_KILL; 1162 + break; 1163 + case SDEV_DEL: 1164 + /* 1165 + * If the device is fully deleted, we refuse to 1166 + * process any commands as well. 1167 + */ 1165 1168 sdev_printk(KERN_ERR, sdev, 1166 1169 "rejecting I/O to dead device\n"); 1167 - goto kill; 1170 + ret = BLKPREP_KILL; 1171 + break; 1172 + case SDEV_QUIESCE: 1173 + case SDEV_BLOCK: 1174 + /* 1175 + * If the devices is blocked we defer normal commands. 1176 + */ 1177 + if (!(req->cmd_flags & REQ_PREEMPT)) 1178 + ret = BLKPREP_DEFER; 1179 + break; 1180 + default: 1181 + /* 1182 + * For any other not fully online state we only allow 1183 + * special commands. In particular any user initiated 1184 + * command is not allowed. 1185 + */ 1186 + if (!(req->cmd_flags & REQ_PREEMPT)) 1187 + ret = BLKPREP_KILL; 1188 + break; 1168 1189 } 1169 - /* OK, we only allow special commands (i.e. not 1170 - * user initiated ones */ 1171 - specials_only = sdev->sdev_state; 1190 + 1191 + if (ret != BLKPREP_OK) 1192 + goto out; 1172 1193 } 1173 1194 1174 - /* 1175 - * Find the actual device driver associated with this command. 1176 - * The SPECIAL requests are things like character device or 1177 - * ioctls, which did not originate from ll_rw_blk. Note that 1178 - * the special field is also used to indicate the cmd for 1179 - * the remainder of a partially fulfilled request that can 1180 - * come up when there is a medium error. We have to treat 1181 - * these two cases differently. We differentiate by looking 1182 - * at request->cmd, as this tells us the real story. 1183 - */ 1184 - if (blk_special_request(req) && req->special) 1185 - cmd = req->special; 1186 - else if (blk_pc_request(req) || blk_fs_request(req)) { 1187 - if (unlikely(specials_only) && !(req->cmd_flags & REQ_PREEMPT)){ 1188 - if (specials_only == SDEV_QUIESCE || 1189 - specials_only == SDEV_BLOCK) 1190 - goto defer; 1191 - 1192 - sdev_printk(KERN_ERR, sdev, 1193 - "rejecting I/O to device being removed\n"); 1194 - goto kill; 1195 - } 1196 - 1195 + switch (req->cmd_type) { 1196 + case REQ_TYPE_BLOCK_PC: 1197 + ret = scsi_setup_blk_pc_cmnd(sdev, req); 1198 + break; 1199 + case REQ_TYPE_FS: 1200 + ret = scsi_setup_fs_cmnd(sdev, req); 1201 + break; 1202 + default: 1197 1203 /* 1198 - * Now try and find a command block that we can use. 1199 - */ 1200 - if (!req->special) { 1201 - cmd = scsi_get_command(sdev, GFP_ATOMIC); 1202 - if (unlikely(!cmd)) 1203 - goto defer; 1204 - } else 1205 - cmd = req->special; 1206 - 1207 - /* pull a tag out of the request if we have one */ 1208 - cmd->tag = req->tag; 1209 - } else { 1210 - blk_dump_rq_flags(req, "SCSI bad req"); 1211 - goto kill; 1212 - } 1213 - 1214 - /* note the overloading of req->special. When the tag 1215 - * is active it always means cmd. If the tag goes 1216 - * back for re-queueing, it may be reset */ 1217 - req->special = cmd; 1218 - cmd->request = req; 1219 - 1220 - /* 1221 - * FIXME: drop the lock here because the functions below 1222 - * expect to be called without the queue lock held. Also, 1223 - * previously, we dequeued the request before dropping the 1224 - * lock. We hope REQ_STARTED prevents anything untoward from 1225 - * happening now. 1226 - */ 1227 - if (blk_fs_request(req) || blk_pc_request(req)) { 1228 - int ret; 1229 - 1230 - /* 1231 - * This will do a couple of things: 1232 - * 1) Fill in the actual SCSI command. 1233 - * 2) Fill in any other upper-level specific fields 1234 - * (timeout). 1204 + * All other command types are not supported. 1235 1205 * 1236 - * If this returns 0, it means that the request failed 1237 - * (reading past end of disk, reading offline device, 1238 - * etc). This won't actually talk to the device, but 1239 - * some kinds of consistency checking may cause the 1240 - * request to be rejected immediately. 1206 + * Note that these days the SCSI subsystem does not use 1207 + * REQ_TYPE_SPECIAL requests anymore. These are only used 1208 + * (directly or via blk_insert_request) by non-SCSI drivers. 1241 1209 */ 1242 - 1243 - /* 1244 - * This sets up the scatter-gather table (allocating if 1245 - * required). 1246 - */ 1247 - ret = scsi_init_io(cmd); 1248 - switch(ret) { 1249 - /* For BLKPREP_KILL/DEFER the cmd was released */ 1250 - case BLKPREP_KILL: 1251 - goto kill; 1252 - case BLKPREP_DEFER: 1253 - goto defer; 1254 - } 1255 - 1256 - /* 1257 - * Initialize the actual SCSI command for this request. 1258 - */ 1259 - if (blk_pc_request(req)) { 1260 - scsi_setup_blk_pc_cmnd(cmd); 1261 - } else if (req->rq_disk) { 1262 - struct scsi_driver *drv; 1263 - 1264 - drv = *(struct scsi_driver **)req->rq_disk->private_data; 1265 - if (unlikely(!drv->init_command(cmd))) { 1266 - scsi_release_buffers(cmd); 1267 - scsi_put_command(cmd); 1268 - goto kill; 1269 - } 1270 - } 1210 + blk_dump_rq_flags(req, "SCSI bad req"); 1211 + ret = BLKPREP_KILL; 1212 + break; 1271 1213 } 1272 1214 1273 - /* 1274 - * The request is now prepped, no need to come back here 1275 - */ 1276 - req->cmd_flags |= REQ_DONTPREP; 1277 - return BLKPREP_OK; 1215 + out: 1216 + switch (ret) { 1217 + case BLKPREP_KILL: 1218 + req->errors = DID_NO_CONNECT << 16; 1219 + break; 1220 + case BLKPREP_DEFER: 1221 + /* 1222 + * If we defer, the elv_next_request() returns NULL, but the 1223 + * queue must be restarted, so we plug here if no returning 1224 + * command will automatically do that. 1225 + */ 1226 + if (sdev->device_busy == 0) 1227 + blk_plug_device(q); 1228 + break; 1229 + default: 1230 + req->cmd_flags |= REQ_DONTPREP; 1231 + } 1278 1232 1279 - defer: 1280 - /* If we defer, the elv_next_request() returns NULL, but the 1281 - * queue must be restarted, so we plug here if no returning 1282 - * command will automatically do that. */ 1283 - if (sdev->device_busy == 0) 1284 - blk_plug_device(q); 1285 - return BLKPREP_DEFER; 1286 - kill: 1287 - req->errors = DID_NO_CONNECT << 16; 1288 - return BLKPREP_KILL; 1233 + return ret; 1289 1234 } 1290 1235 1291 1236 /* ··· 1571 1548 } 1572 1549 EXPORT_SYMBOL(scsi_calculate_bounce_limit); 1573 1550 1574 - struct request_queue *scsi_alloc_queue(struct scsi_device *sdev) 1551 + struct request_queue *__scsi_alloc_queue(struct Scsi_Host *shost, 1552 + request_fn_proc *request_fn) 1575 1553 { 1576 - struct Scsi_Host *shost = sdev->host; 1577 1554 struct request_queue *q; 1578 1555 1579 - q = blk_init_queue(scsi_request_fn, NULL); 1556 + q = blk_init_queue(request_fn, NULL); 1580 1557 if (!q) 1581 1558 return NULL; 1582 - 1583 - blk_queue_prep_rq(q, scsi_prep_fn); 1584 1559 1585 1560 blk_queue_max_hw_segments(q, shost->sg_tablesize); 1586 1561 blk_queue_max_phys_segments(q, SCSI_MAX_PHYS_SEGMENTS); 1587 1562 blk_queue_max_sectors(q, shost->max_sectors); 1588 1563 blk_queue_bounce_limit(q, scsi_calculate_bounce_limit(shost)); 1589 1564 blk_queue_segment_boundary(q, shost->dma_boundary); 1590 - blk_queue_issue_flush_fn(q, scsi_issue_flush_fn); 1591 - blk_queue_softirq_done(q, scsi_softirq_done); 1592 1565 1593 1566 if (!shost->use_clustering) 1594 1567 clear_bit(QUEUE_FLAG_CLUSTER, &q->queue_flags); 1568 + return q; 1569 + } 1570 + EXPORT_SYMBOL(__scsi_alloc_queue); 1571 + 1572 + struct request_queue *scsi_alloc_queue(struct scsi_device *sdev) 1573 + { 1574 + struct request_queue *q; 1575 + 1576 + q = __scsi_alloc_queue(sdev->host, scsi_request_fn); 1577 + if (!q) 1578 + return NULL; 1579 + 1580 + blk_queue_prep_rq(q, scsi_prep_fn); 1581 + blk_queue_issue_flush_fn(q, scsi_issue_flush_fn); 1582 + blk_queue_softirq_done(q, scsi_softirq_done); 1595 1583 return q; 1596 1584 } 1597 1585
+3
drivers/scsi/scsi_priv.h
··· 39 39 { }; 40 40 #endif 41 41 42 + /* scsi_scan.c */ 43 + int scsi_complete_async_scans(void); 44 + 42 45 /* scsi_devinfo.c */ 43 46 extern int scsi_get_device_flags(struct scsi_device *sdev, 44 47 const unsigned char *vendor,
+219 -6
drivers/scsi/scsi_scan.c
··· 29 29 #include <linux/moduleparam.h> 30 30 #include <linux/init.h> 31 31 #include <linux/blkdev.h> 32 - #include <asm/semaphore.h> 32 + #include <linux/delay.h> 33 + #include <linux/kthread.h> 34 + #include <linux/spinlock.h> 33 35 34 36 #include <scsi/scsi.h> 35 37 #include <scsi/scsi_cmnd.h> ··· 89 87 MODULE_PARM_DESC(max_luns, 90 88 "last scsi LUN (should be between 1 and 2^32-1)"); 91 89 90 + #ifdef CONFIG_SCSI_SCAN_ASYNC 91 + #define SCSI_SCAN_TYPE_DEFAULT "async" 92 + #else 93 + #define SCSI_SCAN_TYPE_DEFAULT "sync" 94 + #endif 95 + 96 + static char scsi_scan_type[6] = SCSI_SCAN_TYPE_DEFAULT; 97 + 98 + module_param_string(scan, scsi_scan_type, sizeof(scsi_scan_type), S_IRUGO); 99 + MODULE_PARM_DESC(scan, "sync, async or none"); 100 + 92 101 /* 93 102 * max_scsi_report_luns: the maximum number of LUNS that will be 94 103 * returned from the REPORT LUNS command. 8 times this value must ··· 120 107 MODULE_PARM_DESC(inq_timeout, 121 108 "Timeout (in seconds) waiting for devices to answer INQUIRY." 122 109 " Default is 5. Some non-compliant devices need more."); 110 + 111 + static DEFINE_SPINLOCK(async_scan_lock); 112 + static LIST_HEAD(scanning_hosts); 113 + 114 + struct async_scan_data { 115 + struct list_head list; 116 + struct Scsi_Host *shost; 117 + struct completion prev_finished; 118 + }; 119 + 120 + /** 121 + * scsi_complete_async_scans - Wait for asynchronous scans to complete 122 + * 123 + * Asynchronous scans add themselves to the scanning_hosts list. Once 124 + * that list is empty, we know that the scans are complete. Rather than 125 + * waking up periodically to check the state of the list, we pretend to be 126 + * a scanning task by adding ourselves at the end of the list and going to 127 + * sleep. When the task before us wakes us up, we take ourselves off the 128 + * list and return. 129 + */ 130 + int scsi_complete_async_scans(void) 131 + { 132 + struct async_scan_data *data; 133 + 134 + do { 135 + if (list_empty(&scanning_hosts)) 136 + return 0; 137 + /* If we can't get memory immediately, that's OK. Just 138 + * sleep a little. Even if we never get memory, the async 139 + * scans will finish eventually. 140 + */ 141 + data = kmalloc(sizeof(*data), GFP_KERNEL); 142 + if (!data) 143 + msleep(1); 144 + } while (!data); 145 + 146 + data->shost = NULL; 147 + init_completion(&data->prev_finished); 148 + 149 + spin_lock(&async_scan_lock); 150 + /* Check that there's still somebody else on the list */ 151 + if (list_empty(&scanning_hosts)) 152 + goto done; 153 + list_add_tail(&data->list, &scanning_hosts); 154 + spin_unlock(&async_scan_lock); 155 + 156 + printk(KERN_INFO "scsi: waiting for bus probes to complete ...\n"); 157 + wait_for_completion(&data->prev_finished); 158 + 159 + spin_lock(&async_scan_lock); 160 + list_del(&data->list); 161 + done: 162 + spin_unlock(&async_scan_lock); 163 + 164 + kfree(data); 165 + return 0; 166 + } 167 + 168 + #ifdef MODULE 169 + /* Only exported for the benefit of scsi_wait_scan */ 170 + EXPORT_SYMBOL_GPL(scsi_complete_async_scans); 171 + #endif 123 172 124 173 /** 125 174 * scsi_unlock_floptical - unlock device via a special MODE SENSE command ··· 694 619 * SCSI_SCAN_LUN_PRESENT: a new scsi_device was allocated and initialized 695 620 **/ 696 621 static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result, 697 - int *bflags) 622 + int *bflags, int async) 698 623 { 699 624 /* 700 625 * XXX do not save the inquiry, since it can change underneath us, ··· 880 805 * register it and tell the rest of the kernel 881 806 * about it. 882 807 */ 883 - if (scsi_sysfs_add_sdev(sdev) != 0) 808 + if (!async && scsi_sysfs_add_sdev(sdev) != 0) 884 809 return SCSI_SCAN_NO_RESPONSE; 885 810 886 811 return SCSI_SCAN_LUN_PRESENT; ··· 1049 974 goto out_free_result; 1050 975 } 1051 976 1052 - res = scsi_add_lun(sdev, result, &bflags); 977 + res = scsi_add_lun(sdev, result, &bflags, shost->async_scan); 1053 978 if (res == SCSI_SCAN_LUN_PRESENT) { 1054 979 if (bflags & BLIST_KEY) { 1055 980 sdev->lockable = 0; ··· 1549 1474 { 1550 1475 struct Scsi_Host *shost = dev_to_shost(parent); 1551 1476 1477 + if (strncmp(scsi_scan_type, "none", 4) == 0) 1478 + return; 1479 + 1480 + if (!shost->async_scan) 1481 + scsi_complete_async_scans(); 1482 + 1552 1483 mutex_lock(&shost->scan_mutex); 1553 1484 if (scsi_host_scan_allowed(shost)) 1554 1485 __scsi_scan_target(parent, channel, id, lun, rescan); ··· 1600 1519 "%s: <%u:%u:%u>\n", 1601 1520 __FUNCTION__, channel, id, lun)); 1602 1521 1522 + if (!shost->async_scan) 1523 + scsi_complete_async_scans(); 1524 + 1603 1525 if (((channel != SCAN_WILD_CARD) && (channel > shost->max_channel)) || 1604 1526 ((id != SCAN_WILD_CARD) && (id >= shost->max_id)) || 1605 1527 ((lun != SCAN_WILD_CARD) && (lun > shost->max_lun))) ··· 1623 1539 return 0; 1624 1540 } 1625 1541 1542 + static void scsi_sysfs_add_devices(struct Scsi_Host *shost) 1543 + { 1544 + struct scsi_device *sdev; 1545 + shost_for_each_device(sdev, shost) { 1546 + if (scsi_sysfs_add_sdev(sdev) != 0) 1547 + scsi_destroy_sdev(sdev); 1548 + } 1549 + } 1550 + 1551 + /** 1552 + * scsi_prep_async_scan - prepare for an async scan 1553 + * @shost: the host which will be scanned 1554 + * Returns: a cookie to be passed to scsi_finish_async_scan() 1555 + * 1556 + * Tells the midlayer this host is going to do an asynchronous scan. 1557 + * It reserves the host's position in the scanning list and ensures 1558 + * that other asynchronous scans started after this one won't affect the 1559 + * ordering of the discovered devices. 1560 + */ 1561 + static struct async_scan_data *scsi_prep_async_scan(struct Scsi_Host *shost) 1562 + { 1563 + struct async_scan_data *data; 1564 + 1565 + if (strncmp(scsi_scan_type, "sync", 4) == 0) 1566 + return NULL; 1567 + 1568 + if (shost->async_scan) { 1569 + printk("%s called twice for host %d", __FUNCTION__, 1570 + shost->host_no); 1571 + dump_stack(); 1572 + return NULL; 1573 + } 1574 + 1575 + data = kmalloc(sizeof(*data), GFP_KERNEL); 1576 + if (!data) 1577 + goto err; 1578 + data->shost = scsi_host_get(shost); 1579 + if (!data->shost) 1580 + goto err; 1581 + init_completion(&data->prev_finished); 1582 + 1583 + spin_lock(&async_scan_lock); 1584 + shost->async_scan = 1; 1585 + if (list_empty(&scanning_hosts)) 1586 + complete(&data->prev_finished); 1587 + list_add_tail(&data->list, &scanning_hosts); 1588 + spin_unlock(&async_scan_lock); 1589 + 1590 + return data; 1591 + 1592 + err: 1593 + kfree(data); 1594 + return NULL; 1595 + } 1596 + 1597 + /** 1598 + * scsi_finish_async_scan - asynchronous scan has finished 1599 + * @data: cookie returned from earlier call to scsi_prep_async_scan() 1600 + * 1601 + * All the devices currently attached to this host have been found. 1602 + * This function announces all the devices it has found to the rest 1603 + * of the system. 1604 + */ 1605 + static void scsi_finish_async_scan(struct async_scan_data *data) 1606 + { 1607 + struct Scsi_Host *shost; 1608 + 1609 + if (!data) 1610 + return; 1611 + 1612 + shost = data->shost; 1613 + if (!shost->async_scan) { 1614 + printk("%s called twice for host %d", __FUNCTION__, 1615 + shost->host_no); 1616 + dump_stack(); 1617 + return; 1618 + } 1619 + 1620 + wait_for_completion(&data->prev_finished); 1621 + 1622 + scsi_sysfs_add_devices(shost); 1623 + 1624 + spin_lock(&async_scan_lock); 1625 + shost->async_scan = 0; 1626 + list_del(&data->list); 1627 + if (!list_empty(&scanning_hosts)) { 1628 + struct async_scan_data *next = list_entry(scanning_hosts.next, 1629 + struct async_scan_data, list); 1630 + complete(&next->prev_finished); 1631 + } 1632 + spin_unlock(&async_scan_lock); 1633 + 1634 + scsi_host_put(shost); 1635 + kfree(data); 1636 + } 1637 + 1638 + static void do_scsi_scan_host(struct Scsi_Host *shost) 1639 + { 1640 + if (shost->hostt->scan_finished) { 1641 + unsigned long start = jiffies; 1642 + if (shost->hostt->scan_start) 1643 + shost->hostt->scan_start(shost); 1644 + 1645 + while (!shost->hostt->scan_finished(shost, jiffies - start)) 1646 + msleep(10); 1647 + } else { 1648 + scsi_scan_host_selected(shost, SCAN_WILD_CARD, SCAN_WILD_CARD, 1649 + SCAN_WILD_CARD, 0); 1650 + } 1651 + } 1652 + 1653 + static int do_scan_async(void *_data) 1654 + { 1655 + struct async_scan_data *data = _data; 1656 + do_scsi_scan_host(data->shost); 1657 + scsi_finish_async_scan(data); 1658 + return 0; 1659 + } 1660 + 1626 1661 /** 1627 1662 * scsi_scan_host - scan the given adapter 1628 1663 * @shost: adapter to scan 1629 1664 **/ 1630 1665 void scsi_scan_host(struct Scsi_Host *shost) 1631 1666 { 1632 - scsi_scan_host_selected(shost, SCAN_WILD_CARD, SCAN_WILD_CARD, 1633 - SCAN_WILD_CARD, 0); 1667 + struct async_scan_data *data; 1668 + 1669 + if (strncmp(scsi_scan_type, "none", 4) == 0) 1670 + return; 1671 + 1672 + data = scsi_prep_async_scan(shost); 1673 + if (!data) { 1674 + do_scsi_scan_host(shost); 1675 + return; 1676 + } 1677 + 1678 + kthread_run(do_scan_async, data, "scsi_scan_%d", shost->host_no); 1634 1679 } 1635 1680 EXPORT_SYMBOL(scsi_scan_host); 1636 1681
+352
drivers/scsi/scsi_tgt_if.c
··· 1 + /* 2 + * SCSI target kernel/user interface functions 3 + * 4 + * Copyright (C) 2005 FUJITA Tomonori <tomof@acm.org> 5 + * Copyright (C) 2005 Mike Christie <michaelc@cs.wisc.edu> 6 + * 7 + * This program is free software; you can redistribute it and/or 8 + * modify it under the terms of the GNU General Public License as 9 + * published by the Free Software Foundation; either version 2 of the 10 + * License, or (at your option) any later version. 11 + * 12 + * This program is distributed in the hope that it will be useful, but 13 + * WITHOUT ANY WARRANTY; without even the implied warranty of 14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 + * General Public License for more details. 16 + * 17 + * You should have received a copy of the GNU General Public License 18 + * along with this program; if not, write to the Free Software 19 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 20 + * 02110-1301 USA 21 + */ 22 + #include <linux/miscdevice.h> 23 + #include <linux/file.h> 24 + #include <net/tcp.h> 25 + #include <scsi/scsi.h> 26 + #include <scsi/scsi_cmnd.h> 27 + #include <scsi/scsi_device.h> 28 + #include <scsi/scsi_host.h> 29 + #include <scsi/scsi_tgt.h> 30 + #include <scsi/scsi_tgt_if.h> 31 + 32 + #include <asm/cacheflush.h> 33 + 34 + #include "scsi_tgt_priv.h" 35 + 36 + struct tgt_ring { 37 + u32 tr_idx; 38 + unsigned long tr_pages[TGT_RING_PAGES]; 39 + spinlock_t tr_lock; 40 + }; 41 + 42 + /* tx_ring : kernel->user, rx_ring : user->kernel */ 43 + static struct tgt_ring tx_ring, rx_ring; 44 + static DECLARE_WAIT_QUEUE_HEAD(tgt_poll_wait); 45 + 46 + static inline void tgt_ring_idx_inc(struct tgt_ring *ring) 47 + { 48 + if (ring->tr_idx == TGT_MAX_EVENTS - 1) 49 + ring->tr_idx = 0; 50 + else 51 + ring->tr_idx++; 52 + } 53 + 54 + static struct tgt_event *tgt_head_event(struct tgt_ring *ring, u32 idx) 55 + { 56 + u32 pidx, off; 57 + 58 + pidx = idx / TGT_EVENT_PER_PAGE; 59 + off = idx % TGT_EVENT_PER_PAGE; 60 + 61 + return (struct tgt_event *) 62 + (ring->tr_pages[pidx] + sizeof(struct tgt_event) * off); 63 + } 64 + 65 + static int tgt_uspace_send_event(u32 type, struct tgt_event *p) 66 + { 67 + struct tgt_event *ev; 68 + struct tgt_ring *ring = &tx_ring; 69 + unsigned long flags; 70 + int err = 0; 71 + 72 + spin_lock_irqsave(&ring->tr_lock, flags); 73 + 74 + ev = tgt_head_event(ring, ring->tr_idx); 75 + if (!ev->hdr.status) 76 + tgt_ring_idx_inc(ring); 77 + else 78 + err = -BUSY; 79 + 80 + spin_unlock_irqrestore(&ring->tr_lock, flags); 81 + 82 + if (err) 83 + return err; 84 + 85 + memcpy(ev, p, sizeof(*ev)); 86 + ev->hdr.type = type; 87 + mb(); 88 + ev->hdr.status = 1; 89 + 90 + flush_dcache_page(virt_to_page(ev)); 91 + 92 + wake_up_interruptible(&tgt_poll_wait); 93 + 94 + return 0; 95 + } 96 + 97 + int scsi_tgt_uspace_send_cmd(struct scsi_cmnd *cmd, struct scsi_lun *lun, u64 tag) 98 + { 99 + struct Scsi_Host *shost = scsi_tgt_cmd_to_host(cmd); 100 + struct tgt_event ev; 101 + int err; 102 + 103 + memset(&ev, 0, sizeof(ev)); 104 + ev.p.cmd_req.host_no = shost->host_no; 105 + ev.p.cmd_req.data_len = cmd->request_bufflen; 106 + memcpy(ev.p.cmd_req.scb, cmd->cmnd, sizeof(ev.p.cmd_req.scb)); 107 + memcpy(ev.p.cmd_req.lun, lun, sizeof(ev.p.cmd_req.lun)); 108 + ev.p.cmd_req.attribute = cmd->tag; 109 + ev.p.cmd_req.tag = tag; 110 + 111 + dprintk("%p %d %u %x %llx\n", cmd, shost->host_no, 112 + ev.p.cmd_req.data_len, cmd->tag, 113 + (unsigned long long) ev.p.cmd_req.tag); 114 + 115 + err = tgt_uspace_send_event(TGT_KEVENT_CMD_REQ, &ev); 116 + if (err) 117 + eprintk("tx buf is full, could not send\n"); 118 + 119 + return err; 120 + } 121 + 122 + int scsi_tgt_uspace_send_status(struct scsi_cmnd *cmd, u64 tag) 123 + { 124 + struct Scsi_Host *shost = scsi_tgt_cmd_to_host(cmd); 125 + struct tgt_event ev; 126 + int err; 127 + 128 + memset(&ev, 0, sizeof(ev)); 129 + ev.p.cmd_done.host_no = shost->host_no; 130 + ev.p.cmd_done.tag = tag; 131 + ev.p.cmd_done.result = cmd->result; 132 + 133 + dprintk("%p %d %llu %u %x\n", cmd, shost->host_no, 134 + (unsigned long long) ev.p.cmd_req.tag, 135 + ev.p.cmd_req.data_len, cmd->tag); 136 + 137 + err = tgt_uspace_send_event(TGT_KEVENT_CMD_DONE, &ev); 138 + if (err) 139 + eprintk("tx buf is full, could not send\n"); 140 + 141 + return err; 142 + } 143 + 144 + int scsi_tgt_uspace_send_tsk_mgmt(int host_no, int function, u64 tag, 145 + struct scsi_lun *scsilun, void *data) 146 + { 147 + struct tgt_event ev; 148 + int err; 149 + 150 + memset(&ev, 0, sizeof(ev)); 151 + ev.p.tsk_mgmt_req.host_no = host_no; 152 + ev.p.tsk_mgmt_req.function = function; 153 + ev.p.tsk_mgmt_req.tag = tag; 154 + memcpy(ev.p.tsk_mgmt_req.lun, scsilun, sizeof(ev.p.tsk_mgmt_req.lun)); 155 + ev.p.tsk_mgmt_req.mid = (u64) (unsigned long) data; 156 + 157 + dprintk("%d %x %llx %llx\n", host_no, function, (unsigned long long) tag, 158 + (unsigned long long) ev.p.tsk_mgmt_req.mid); 159 + 160 + err = tgt_uspace_send_event(TGT_KEVENT_TSK_MGMT_REQ, &ev); 161 + if (err) 162 + eprintk("tx buf is full, could not send\n"); 163 + 164 + return err; 165 + } 166 + 167 + static int event_recv_msg(struct tgt_event *ev) 168 + { 169 + int err = 0; 170 + 171 + switch (ev->hdr.type) { 172 + case TGT_UEVENT_CMD_RSP: 173 + err = scsi_tgt_kspace_exec(ev->p.cmd_rsp.host_no, 174 + ev->p.cmd_rsp.tag, 175 + ev->p.cmd_rsp.result, 176 + ev->p.cmd_rsp.len, 177 + ev->p.cmd_rsp.uaddr, 178 + ev->p.cmd_rsp.rw); 179 + break; 180 + case TGT_UEVENT_TSK_MGMT_RSP: 181 + err = scsi_tgt_kspace_tsk_mgmt(ev->p.tsk_mgmt_rsp.host_no, 182 + ev->p.tsk_mgmt_rsp.mid, 183 + ev->p.tsk_mgmt_rsp.result); 184 + break; 185 + default: 186 + eprintk("unknown type %d\n", ev->hdr.type); 187 + err = -EINVAL; 188 + } 189 + 190 + return err; 191 + } 192 + 193 + static ssize_t tgt_write(struct file *file, const char __user * buffer, 194 + size_t count, loff_t * ppos) 195 + { 196 + struct tgt_event *ev; 197 + struct tgt_ring *ring = &rx_ring; 198 + 199 + while (1) { 200 + ev = tgt_head_event(ring, ring->tr_idx); 201 + /* do we need this? */ 202 + flush_dcache_page(virt_to_page(ev)); 203 + 204 + if (!ev->hdr.status) 205 + break; 206 + 207 + tgt_ring_idx_inc(ring); 208 + event_recv_msg(ev); 209 + ev->hdr.status = 0; 210 + }; 211 + 212 + return count; 213 + } 214 + 215 + static unsigned int tgt_poll(struct file * file, struct poll_table_struct *wait) 216 + { 217 + struct tgt_event *ev; 218 + struct tgt_ring *ring = &tx_ring; 219 + unsigned long flags; 220 + unsigned int mask = 0; 221 + u32 idx; 222 + 223 + poll_wait(file, &tgt_poll_wait, wait); 224 + 225 + spin_lock_irqsave(&ring->tr_lock, flags); 226 + 227 + idx = ring->tr_idx ? ring->tr_idx - 1 : TGT_MAX_EVENTS - 1; 228 + ev = tgt_head_event(ring, idx); 229 + if (ev->hdr.status) 230 + mask |= POLLIN | POLLRDNORM; 231 + 232 + spin_unlock_irqrestore(&ring->tr_lock, flags); 233 + 234 + return mask; 235 + } 236 + 237 + static int uspace_ring_map(struct vm_area_struct *vma, unsigned long addr, 238 + struct tgt_ring *ring) 239 + { 240 + int i, err; 241 + 242 + for (i = 0; i < TGT_RING_PAGES; i++) { 243 + struct page *page = virt_to_page(ring->tr_pages[i]); 244 + err = vm_insert_page(vma, addr, page); 245 + if (err) 246 + return err; 247 + addr += PAGE_SIZE; 248 + } 249 + 250 + return 0; 251 + } 252 + 253 + static int tgt_mmap(struct file *filp, struct vm_area_struct *vma) 254 + { 255 + unsigned long addr; 256 + int err; 257 + 258 + if (vma->vm_pgoff) 259 + return -EINVAL; 260 + 261 + if (vma->vm_end - vma->vm_start != TGT_RING_SIZE * 2) { 262 + eprintk("mmap size must be %lu, not %lu \n", 263 + TGT_RING_SIZE * 2, vma->vm_end - vma->vm_start); 264 + return -EINVAL; 265 + } 266 + 267 + addr = vma->vm_start; 268 + err = uspace_ring_map(vma, addr, &tx_ring); 269 + if (err) 270 + return err; 271 + err = uspace_ring_map(vma, addr + TGT_RING_SIZE, &rx_ring); 272 + 273 + return err; 274 + } 275 + 276 + static int tgt_open(struct inode *inode, struct file *file) 277 + { 278 + tx_ring.tr_idx = rx_ring.tr_idx = 0; 279 + 280 + return 0; 281 + } 282 + 283 + static struct file_operations tgt_fops = { 284 + .owner = THIS_MODULE, 285 + .open = tgt_open, 286 + .poll = tgt_poll, 287 + .write = tgt_write, 288 + .mmap = tgt_mmap, 289 + }; 290 + 291 + static struct miscdevice tgt_miscdev = { 292 + .minor = MISC_DYNAMIC_MINOR, 293 + .name = "tgt", 294 + .fops = &tgt_fops, 295 + }; 296 + 297 + static void tgt_ring_exit(struct tgt_ring *ring) 298 + { 299 + int i; 300 + 301 + for (i = 0; i < TGT_RING_PAGES; i++) 302 + free_page(ring->tr_pages[i]); 303 + } 304 + 305 + static int tgt_ring_init(struct tgt_ring *ring) 306 + { 307 + int i; 308 + 309 + spin_lock_init(&ring->tr_lock); 310 + 311 + for (i = 0; i < TGT_RING_PAGES; i++) { 312 + ring->tr_pages[i] = get_zeroed_page(GFP_KERNEL); 313 + if (!ring->tr_pages[i]) { 314 + eprintk("out of memory\n"); 315 + return -ENOMEM; 316 + } 317 + } 318 + 319 + return 0; 320 + } 321 + 322 + void scsi_tgt_if_exit(void) 323 + { 324 + tgt_ring_exit(&tx_ring); 325 + tgt_ring_exit(&rx_ring); 326 + misc_deregister(&tgt_miscdev); 327 + } 328 + 329 + int scsi_tgt_if_init(void) 330 + { 331 + int err; 332 + 333 + err = tgt_ring_init(&tx_ring); 334 + if (err) 335 + return err; 336 + 337 + err = tgt_ring_init(&rx_ring); 338 + if (err) 339 + goto free_tx_ring; 340 + 341 + err = misc_register(&tgt_miscdev); 342 + if (err) 343 + goto free_rx_ring; 344 + 345 + return 0; 346 + free_rx_ring: 347 + tgt_ring_exit(&rx_ring); 348 + free_tx_ring: 349 + tgt_ring_exit(&tx_ring); 350 + 351 + return err; 352 + }
+742
drivers/scsi/scsi_tgt_lib.c
··· 1 + /* 2 + * SCSI target lib functions 3 + * 4 + * Copyright (C) 2005 Mike Christie <michaelc@cs.wisc.edu> 5 + * Copyright (C) 2005 FUJITA Tomonori <tomof@acm.org> 6 + * 7 + * This program is free software; you can redistribute it and/or 8 + * modify it under the terms of the GNU General Public License as 9 + * published by the Free Software Foundation; either version 2 of the 10 + * License, or (at your option) any later version. 11 + * 12 + * This program is distributed in the hope that it will be useful, but 13 + * WITHOUT ANY WARRANTY; without even the implied warranty of 14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 + * General Public License for more details. 16 + * 17 + * You should have received a copy of the GNU General Public License 18 + * along with this program; if not, write to the Free Software 19 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 20 + * 02110-1301 USA 21 + */ 22 + #include <linux/blkdev.h> 23 + #include <linux/hash.h> 24 + #include <linux/module.h> 25 + #include <linux/pagemap.h> 26 + #include <scsi/scsi.h> 27 + #include <scsi/scsi_cmnd.h> 28 + #include <scsi/scsi_device.h> 29 + #include <scsi/scsi_host.h> 30 + #include <scsi/scsi_tgt.h> 31 + #include <../drivers/md/dm-bio-list.h> 32 + 33 + #include "scsi_tgt_priv.h" 34 + 35 + static struct workqueue_struct *scsi_tgtd; 36 + static kmem_cache_t *scsi_tgt_cmd_cache; 37 + 38 + /* 39 + * TODO: this struct will be killed when the block layer supports large bios 40 + * and James's work struct code is in 41 + */ 42 + struct scsi_tgt_cmd { 43 + /* TODO replace work with James b's code */ 44 + struct work_struct work; 45 + /* TODO replace the lists with a large bio */ 46 + struct bio_list xfer_done_list; 47 + struct bio_list xfer_list; 48 + 49 + struct list_head hash_list; 50 + struct request *rq; 51 + u64 tag; 52 + 53 + void *buffer; 54 + unsigned bufflen; 55 + }; 56 + 57 + #define TGT_HASH_ORDER 4 58 + #define cmd_hashfn(tag) hash_long((unsigned long) (tag), TGT_HASH_ORDER) 59 + 60 + struct scsi_tgt_queuedata { 61 + struct Scsi_Host *shost; 62 + struct list_head cmd_hash[1 << TGT_HASH_ORDER]; 63 + spinlock_t cmd_hash_lock; 64 + }; 65 + 66 + /* 67 + * Function: scsi_host_get_command() 68 + * 69 + * Purpose: Allocate and setup a scsi command block and blk request 70 + * 71 + * Arguments: shost - scsi host 72 + * data_dir - dma data dir 73 + * gfp_mask- allocator flags 74 + * 75 + * Returns: The allocated scsi command structure. 76 + * 77 + * This should be called by target LLDs to get a command. 78 + */ 79 + struct scsi_cmnd *scsi_host_get_command(struct Scsi_Host *shost, 80 + enum dma_data_direction data_dir, 81 + gfp_t gfp_mask) 82 + { 83 + int write = (data_dir == DMA_TO_DEVICE); 84 + struct request *rq; 85 + struct scsi_cmnd *cmd; 86 + struct scsi_tgt_cmd *tcmd; 87 + 88 + /* Bail if we can't get a reference to the device */ 89 + if (!get_device(&shost->shost_gendev)) 90 + return NULL; 91 + 92 + tcmd = kmem_cache_alloc(scsi_tgt_cmd_cache, GFP_ATOMIC); 93 + if (!tcmd) 94 + goto put_dev; 95 + 96 + rq = blk_get_request(shost->uspace_req_q, write, gfp_mask); 97 + if (!rq) 98 + goto free_tcmd; 99 + 100 + cmd = __scsi_get_command(shost, gfp_mask); 101 + if (!cmd) 102 + goto release_rq; 103 + 104 + memset(cmd, 0, sizeof(*cmd)); 105 + cmd->sc_data_direction = data_dir; 106 + cmd->jiffies_at_alloc = jiffies; 107 + cmd->request = rq; 108 + 109 + rq->special = cmd; 110 + rq->cmd_type = REQ_TYPE_SPECIAL; 111 + rq->cmd_flags |= REQ_TYPE_BLOCK_PC; 112 + rq->end_io_data = tcmd; 113 + 114 + bio_list_init(&tcmd->xfer_list); 115 + bio_list_init(&tcmd->xfer_done_list); 116 + tcmd->rq = rq; 117 + 118 + return cmd; 119 + 120 + release_rq: 121 + blk_put_request(rq); 122 + free_tcmd: 123 + kmem_cache_free(scsi_tgt_cmd_cache, tcmd); 124 + put_dev: 125 + put_device(&shost->shost_gendev); 126 + return NULL; 127 + 128 + } 129 + EXPORT_SYMBOL_GPL(scsi_host_get_command); 130 + 131 + /* 132 + * Function: scsi_host_put_command() 133 + * 134 + * Purpose: Free a scsi command block 135 + * 136 + * Arguments: shost - scsi host 137 + * cmd - command block to free 138 + * 139 + * Returns: Nothing. 140 + * 141 + * Notes: The command must not belong to any lists. 142 + */ 143 + void scsi_host_put_command(struct Scsi_Host *shost, struct scsi_cmnd *cmd) 144 + { 145 + struct request_queue *q = shost->uspace_req_q; 146 + struct request *rq = cmd->request; 147 + struct scsi_tgt_cmd *tcmd = rq->end_io_data; 148 + unsigned long flags; 149 + 150 + kmem_cache_free(scsi_tgt_cmd_cache, tcmd); 151 + 152 + spin_lock_irqsave(q->queue_lock, flags); 153 + __blk_put_request(q, rq); 154 + spin_unlock_irqrestore(q->queue_lock, flags); 155 + 156 + __scsi_put_command(shost, cmd, &shost->shost_gendev); 157 + } 158 + EXPORT_SYMBOL_GPL(scsi_host_put_command); 159 + 160 + static void scsi_unmap_user_pages(struct scsi_tgt_cmd *tcmd) 161 + { 162 + struct bio *bio; 163 + 164 + /* must call bio_endio in case bio was bounced */ 165 + while ((bio = bio_list_pop(&tcmd->xfer_done_list))) { 166 + bio_endio(bio, bio->bi_size, 0); 167 + bio_unmap_user(bio); 168 + } 169 + 170 + while ((bio = bio_list_pop(&tcmd->xfer_list))) { 171 + bio_endio(bio, bio->bi_size, 0); 172 + bio_unmap_user(bio); 173 + } 174 + } 175 + 176 + static void cmd_hashlist_del(struct scsi_cmnd *cmd) 177 + { 178 + struct request_queue *q = cmd->request->q; 179 + struct scsi_tgt_queuedata *qdata = q->queuedata; 180 + unsigned long flags; 181 + struct scsi_tgt_cmd *tcmd = cmd->request->end_io_data; 182 + 183 + spin_lock_irqsave(&qdata->cmd_hash_lock, flags); 184 + list_del(&tcmd->hash_list); 185 + spin_unlock_irqrestore(&qdata->cmd_hash_lock, flags); 186 + } 187 + 188 + static void scsi_tgt_cmd_destroy(void *data) 189 + { 190 + struct scsi_cmnd *cmd = data; 191 + struct scsi_tgt_cmd *tcmd = cmd->request->end_io_data; 192 + 193 + dprintk("cmd %p %d %lu\n", cmd, cmd->sc_data_direction, 194 + rq_data_dir(cmd->request)); 195 + /* 196 + * We fix rq->cmd_flags here since when we told bio_map_user 197 + * to write vm for WRITE commands, blk_rq_bio_prep set 198 + * rq_data_dir the flags to READ. 199 + */ 200 + if (cmd->sc_data_direction == DMA_TO_DEVICE) 201 + cmd->request->cmd_flags |= REQ_RW; 202 + else 203 + cmd->request->cmd_flags &= ~REQ_RW; 204 + 205 + scsi_unmap_user_pages(tcmd); 206 + scsi_host_put_command(scsi_tgt_cmd_to_host(cmd), cmd); 207 + } 208 + 209 + static void init_scsi_tgt_cmd(struct request *rq, struct scsi_tgt_cmd *tcmd, 210 + u64 tag) 211 + { 212 + struct scsi_tgt_queuedata *qdata = rq->q->queuedata; 213 + unsigned long flags; 214 + struct list_head *head; 215 + 216 + tcmd->tag = tag; 217 + spin_lock_irqsave(&qdata->cmd_hash_lock, flags); 218 + head = &qdata->cmd_hash[cmd_hashfn(tag)]; 219 + list_add(&tcmd->hash_list, head); 220 + spin_unlock_irqrestore(&qdata->cmd_hash_lock, flags); 221 + } 222 + 223 + /* 224 + * scsi_tgt_alloc_queue - setup queue used for message passing 225 + * shost: scsi host 226 + * 227 + * This should be called by the LLD after host allocation. 228 + * And will be released when the host is released. 229 + */ 230 + int scsi_tgt_alloc_queue(struct Scsi_Host *shost) 231 + { 232 + struct scsi_tgt_queuedata *queuedata; 233 + struct request_queue *q; 234 + int err, i; 235 + 236 + /* 237 + * Do we need to send a netlink event or should uspace 238 + * just respond to the hotplug event? 239 + */ 240 + q = __scsi_alloc_queue(shost, NULL); 241 + if (!q) 242 + return -ENOMEM; 243 + 244 + queuedata = kzalloc(sizeof(*queuedata), GFP_KERNEL); 245 + if (!queuedata) { 246 + err = -ENOMEM; 247 + goto cleanup_queue; 248 + } 249 + queuedata->shost = shost; 250 + q->queuedata = queuedata; 251 + 252 + /* 253 + * this is a silly hack. We should probably just queue as many 254 + * command as is recvd to userspace. uspace can then make 255 + * sure we do not overload the HBA 256 + */ 257 + q->nr_requests = shost->hostt->can_queue; 258 + /* 259 + * We currently only support software LLDs so this does 260 + * not matter for now. Do we need this for the cards we support? 261 + * If so we should make it a host template value. 262 + */ 263 + blk_queue_dma_alignment(q, 0); 264 + shost->uspace_req_q = q; 265 + 266 + for (i = 0; i < ARRAY_SIZE(queuedata->cmd_hash); i++) 267 + INIT_LIST_HEAD(&queuedata->cmd_hash[i]); 268 + spin_lock_init(&queuedata->cmd_hash_lock); 269 + 270 + return 0; 271 + 272 + cleanup_queue: 273 + blk_cleanup_queue(q); 274 + return err; 275 + } 276 + EXPORT_SYMBOL_GPL(scsi_tgt_alloc_queue); 277 + 278 + void scsi_tgt_free_queue(struct Scsi_Host *shost) 279 + { 280 + int i; 281 + unsigned long flags; 282 + struct request_queue *q = shost->uspace_req_q; 283 + struct scsi_cmnd *cmd; 284 + struct scsi_tgt_queuedata *qdata = q->queuedata; 285 + struct scsi_tgt_cmd *tcmd, *n; 286 + LIST_HEAD(cmds); 287 + 288 + spin_lock_irqsave(&qdata->cmd_hash_lock, flags); 289 + 290 + for (i = 0; i < ARRAY_SIZE(qdata->cmd_hash); i++) { 291 + list_for_each_entry_safe(tcmd, n, &qdata->cmd_hash[i], 292 + hash_list) { 293 + list_del(&tcmd->hash_list); 294 + list_add(&tcmd->hash_list, &cmds); 295 + } 296 + } 297 + 298 + spin_unlock_irqrestore(&qdata->cmd_hash_lock, flags); 299 + 300 + while (!list_empty(&cmds)) { 301 + tcmd = list_entry(cmds.next, struct scsi_tgt_cmd, hash_list); 302 + list_del(&tcmd->hash_list); 303 + cmd = tcmd->rq->special; 304 + 305 + shost->hostt->eh_abort_handler(cmd); 306 + scsi_tgt_cmd_destroy(cmd); 307 + } 308 + } 309 + EXPORT_SYMBOL_GPL(scsi_tgt_free_queue); 310 + 311 + struct Scsi_Host *scsi_tgt_cmd_to_host(struct scsi_cmnd *cmd) 312 + { 313 + struct scsi_tgt_queuedata *queue = cmd->request->q->queuedata; 314 + return queue->shost; 315 + } 316 + EXPORT_SYMBOL_GPL(scsi_tgt_cmd_to_host); 317 + 318 + /* 319 + * scsi_tgt_queue_command - queue command for userspace processing 320 + * @cmd: scsi command 321 + * @scsilun: scsi lun 322 + * @tag: unique value to identify this command for tmf 323 + */ 324 + int scsi_tgt_queue_command(struct scsi_cmnd *cmd, struct scsi_lun *scsilun, 325 + u64 tag) 326 + { 327 + struct scsi_tgt_cmd *tcmd = cmd->request->end_io_data; 328 + int err; 329 + 330 + init_scsi_tgt_cmd(cmd->request, tcmd, tag); 331 + err = scsi_tgt_uspace_send_cmd(cmd, scsilun, tag); 332 + if (err) 333 + cmd_hashlist_del(cmd); 334 + 335 + return err; 336 + } 337 + EXPORT_SYMBOL_GPL(scsi_tgt_queue_command); 338 + 339 + /* 340 + * This is run from a interrpt handler normally and the unmap 341 + * needs process context so we must queue 342 + */ 343 + static void scsi_tgt_cmd_done(struct scsi_cmnd *cmd) 344 + { 345 + struct scsi_tgt_cmd *tcmd = cmd->request->end_io_data; 346 + 347 + dprintk("cmd %p %lu\n", cmd, rq_data_dir(cmd->request)); 348 + 349 + scsi_tgt_uspace_send_status(cmd, tcmd->tag); 350 + INIT_WORK(&tcmd->work, scsi_tgt_cmd_destroy, cmd); 351 + queue_work(scsi_tgtd, &tcmd->work); 352 + } 353 + 354 + static int __scsi_tgt_transfer_response(struct scsi_cmnd *cmd) 355 + { 356 + struct Scsi_Host *shost = scsi_tgt_cmd_to_host(cmd); 357 + int err; 358 + 359 + dprintk("cmd %p %lu\n", cmd, rq_data_dir(cmd->request)); 360 + 361 + err = shost->hostt->transfer_response(cmd, scsi_tgt_cmd_done); 362 + switch (err) { 363 + case SCSI_MLQUEUE_HOST_BUSY: 364 + case SCSI_MLQUEUE_DEVICE_BUSY: 365 + return -EAGAIN; 366 + } 367 + 368 + return 0; 369 + } 370 + 371 + static void scsi_tgt_transfer_response(struct scsi_cmnd *cmd) 372 + { 373 + struct scsi_tgt_cmd *tcmd = cmd->request->end_io_data; 374 + int err; 375 + 376 + err = __scsi_tgt_transfer_response(cmd); 377 + if (!err) 378 + return; 379 + 380 + cmd->result = DID_BUS_BUSY << 16; 381 + err = scsi_tgt_uspace_send_status(cmd, tcmd->tag); 382 + if (err <= 0) 383 + /* the eh will have to pick this up */ 384 + printk(KERN_ERR "Could not send cmd %p status\n", cmd); 385 + } 386 + 387 + static int scsi_tgt_init_cmd(struct scsi_cmnd *cmd, gfp_t gfp_mask) 388 + { 389 + struct request *rq = cmd->request; 390 + struct scsi_tgt_cmd *tcmd = rq->end_io_data; 391 + int count; 392 + 393 + cmd->use_sg = rq->nr_phys_segments; 394 + cmd->request_buffer = scsi_alloc_sgtable(cmd, gfp_mask); 395 + if (!cmd->request_buffer) 396 + return -ENOMEM; 397 + 398 + cmd->request_bufflen = rq->data_len; 399 + 400 + dprintk("cmd %p addr %p cnt %d %lu\n", cmd, tcmd->buffer, cmd->use_sg, 401 + rq_data_dir(rq)); 402 + count = blk_rq_map_sg(rq->q, rq, cmd->request_buffer); 403 + if (likely(count <= cmd->use_sg)) { 404 + cmd->use_sg = count; 405 + return 0; 406 + } 407 + 408 + eprintk("cmd %p addr %p cnt %d\n", cmd, tcmd->buffer, cmd->use_sg); 409 + scsi_free_sgtable(cmd->request_buffer, cmd->sglist_len); 410 + return -EINVAL; 411 + } 412 + 413 + /* TODO: test this crap and replace bio_map_user with new interface maybe */ 414 + static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd, 415 + int rw) 416 + { 417 + struct request_queue *q = cmd->request->q; 418 + struct request *rq = cmd->request; 419 + void *uaddr = tcmd->buffer; 420 + unsigned int len = tcmd->bufflen; 421 + struct bio *bio; 422 + int err; 423 + 424 + while (len > 0) { 425 + dprintk("%lx %u\n", (unsigned long) uaddr, len); 426 + bio = bio_map_user(q, NULL, (unsigned long) uaddr, len, rw); 427 + if (IS_ERR(bio)) { 428 + err = PTR_ERR(bio); 429 + dprintk("fail to map %lx %u %d %x\n", 430 + (unsigned long) uaddr, len, err, cmd->cmnd[0]); 431 + goto unmap_bios; 432 + } 433 + 434 + uaddr += bio->bi_size; 435 + len -= bio->bi_size; 436 + 437 + /* 438 + * The first bio is added and merged. We could probably 439 + * try to add others using scsi_merge_bio() but for now 440 + * we keep it simple. The first bio should be pretty large 441 + * (either hitting the 1 MB bio pages limit or a queue limit) 442 + * already but for really large IO we may want to try and 443 + * merge these. 444 + */ 445 + if (!rq->bio) { 446 + blk_rq_bio_prep(q, rq, bio); 447 + rq->data_len = bio->bi_size; 448 + } else 449 + /* put list of bios to transfer in next go around */ 450 + bio_list_add(&tcmd->xfer_list, bio); 451 + } 452 + 453 + cmd->offset = 0; 454 + err = scsi_tgt_init_cmd(cmd, GFP_KERNEL); 455 + if (err) 456 + goto unmap_bios; 457 + 458 + return 0; 459 + 460 + unmap_bios: 461 + if (rq->bio) { 462 + bio_unmap_user(rq->bio); 463 + while ((bio = bio_list_pop(&tcmd->xfer_list))) 464 + bio_unmap_user(bio); 465 + } 466 + 467 + return err; 468 + } 469 + 470 + static int scsi_tgt_transfer_data(struct scsi_cmnd *); 471 + 472 + static void scsi_tgt_data_transfer_done(struct scsi_cmnd *cmd) 473 + { 474 + struct scsi_tgt_cmd *tcmd = cmd->request->end_io_data; 475 + struct bio *bio; 476 + int err; 477 + 478 + /* should we free resources here on error ? */ 479 + if (cmd->result) { 480 + send_uspace_err: 481 + err = scsi_tgt_uspace_send_status(cmd, tcmd->tag); 482 + if (err <= 0) 483 + /* the tgt uspace eh will have to pick this up */ 484 + printk(KERN_ERR "Could not send cmd %p status\n", cmd); 485 + return; 486 + } 487 + 488 + dprintk("cmd %p request_bufflen %u bufflen %u\n", 489 + cmd, cmd->request_bufflen, tcmd->bufflen); 490 + 491 + scsi_free_sgtable(cmd->request_buffer, cmd->sglist_len); 492 + bio_list_add(&tcmd->xfer_done_list, cmd->request->bio); 493 + 494 + tcmd->buffer += cmd->request_bufflen; 495 + cmd->offset += cmd->request_bufflen; 496 + 497 + if (!tcmd->xfer_list.head) { 498 + scsi_tgt_transfer_response(cmd); 499 + return; 500 + } 501 + 502 + dprintk("cmd2 %p request_bufflen %u bufflen %u\n", 503 + cmd, cmd->request_bufflen, tcmd->bufflen); 504 + 505 + bio = bio_list_pop(&tcmd->xfer_list); 506 + BUG_ON(!bio); 507 + 508 + blk_rq_bio_prep(cmd->request->q, cmd->request, bio); 509 + cmd->request->data_len = bio->bi_size; 510 + err = scsi_tgt_init_cmd(cmd, GFP_ATOMIC); 511 + if (err) { 512 + cmd->result = DID_ERROR << 16; 513 + goto send_uspace_err; 514 + } 515 + 516 + if (scsi_tgt_transfer_data(cmd)) { 517 + cmd->result = DID_NO_CONNECT << 16; 518 + goto send_uspace_err; 519 + } 520 + } 521 + 522 + static int scsi_tgt_transfer_data(struct scsi_cmnd *cmd) 523 + { 524 + int err; 525 + struct Scsi_Host *host = scsi_tgt_cmd_to_host(cmd); 526 + 527 + err = host->hostt->transfer_data(cmd, scsi_tgt_data_transfer_done); 528 + switch (err) { 529 + case SCSI_MLQUEUE_HOST_BUSY: 530 + case SCSI_MLQUEUE_DEVICE_BUSY: 531 + return -EAGAIN; 532 + default: 533 + return 0; 534 + } 535 + } 536 + 537 + static int scsi_tgt_copy_sense(struct scsi_cmnd *cmd, unsigned long uaddr, 538 + unsigned len) 539 + { 540 + char __user *p = (char __user *) uaddr; 541 + 542 + if (copy_from_user(cmd->sense_buffer, p, 543 + min_t(unsigned, SCSI_SENSE_BUFFERSIZE, len))) { 544 + printk(KERN_ERR "Could not copy the sense buffer\n"); 545 + return -EIO; 546 + } 547 + return 0; 548 + } 549 + 550 + static int scsi_tgt_abort_cmd(struct Scsi_Host *shost, struct scsi_cmnd *cmd) 551 + { 552 + int err; 553 + 554 + err = shost->hostt->eh_abort_handler(cmd); 555 + if (err) 556 + eprintk("fail to abort %p\n", cmd); 557 + 558 + scsi_tgt_cmd_destroy(cmd); 559 + return err; 560 + } 561 + 562 + static struct request *tgt_cmd_hash_lookup(struct request_queue *q, u64 tag) 563 + { 564 + struct scsi_tgt_queuedata *qdata = q->queuedata; 565 + struct request *rq = NULL; 566 + struct list_head *head; 567 + struct scsi_tgt_cmd *tcmd; 568 + unsigned long flags; 569 + 570 + head = &qdata->cmd_hash[cmd_hashfn(tag)]; 571 + spin_lock_irqsave(&qdata->cmd_hash_lock, flags); 572 + list_for_each_entry(tcmd, head, hash_list) { 573 + if (tcmd->tag == tag) { 574 + rq = tcmd->rq; 575 + list_del(&tcmd->hash_list); 576 + break; 577 + } 578 + } 579 + spin_unlock_irqrestore(&qdata->cmd_hash_lock, flags); 580 + 581 + return rq; 582 + } 583 + 584 + int scsi_tgt_kspace_exec(int host_no, u64 tag, int result, u32 len, 585 + unsigned long uaddr, u8 rw) 586 + { 587 + struct Scsi_Host *shost; 588 + struct scsi_cmnd *cmd; 589 + struct request *rq; 590 + struct scsi_tgt_cmd *tcmd; 591 + int err = 0; 592 + 593 + dprintk("%d %llu %d %u %lx %u\n", host_no, (unsigned long long) tag, 594 + result, len, uaddr, rw); 595 + 596 + /* TODO: replace with a O(1) alg */ 597 + shost = scsi_host_lookup(host_no); 598 + if (IS_ERR(shost)) { 599 + printk(KERN_ERR "Could not find host no %d\n", host_no); 600 + return -EINVAL; 601 + } 602 + 603 + if (!shost->uspace_req_q) { 604 + printk(KERN_ERR "Not target scsi host %d\n", host_no); 605 + goto done; 606 + } 607 + 608 + rq = tgt_cmd_hash_lookup(shost->uspace_req_q, tag); 609 + if (!rq) { 610 + printk(KERN_ERR "Could not find tag %llu\n", 611 + (unsigned long long) tag); 612 + err = -EINVAL; 613 + goto done; 614 + } 615 + cmd = rq->special; 616 + 617 + dprintk("cmd %p result %d len %d bufflen %u %lu %x\n", cmd, 618 + result, len, cmd->request_bufflen, rq_data_dir(rq), cmd->cmnd[0]); 619 + 620 + if (result == TASK_ABORTED) { 621 + scsi_tgt_abort_cmd(shost, cmd); 622 + goto done; 623 + } 624 + /* 625 + * store the userspace values here, the working values are 626 + * in the request_* values 627 + */ 628 + tcmd = cmd->request->end_io_data; 629 + tcmd->buffer = (void *)uaddr; 630 + tcmd->bufflen = len; 631 + cmd->result = result; 632 + 633 + if (!tcmd->bufflen || cmd->request_buffer) { 634 + err = __scsi_tgt_transfer_response(cmd); 635 + goto done; 636 + } 637 + 638 + /* 639 + * TODO: Do we need to handle case where request does not 640 + * align with LLD. 641 + */ 642 + err = scsi_map_user_pages(rq->end_io_data, cmd, rw); 643 + if (err) { 644 + eprintk("%p %d\n", cmd, err); 645 + err = -EAGAIN; 646 + goto done; 647 + } 648 + 649 + /* userspace failure */ 650 + if (cmd->result) { 651 + if (status_byte(cmd->result) == CHECK_CONDITION) 652 + scsi_tgt_copy_sense(cmd, uaddr, len); 653 + err = __scsi_tgt_transfer_response(cmd); 654 + goto done; 655 + } 656 + /* ask the target LLD to transfer the data to the buffer */ 657 + err = scsi_tgt_transfer_data(cmd); 658 + 659 + done: 660 + scsi_host_put(shost); 661 + return err; 662 + } 663 + 664 + int scsi_tgt_tsk_mgmt_request(struct Scsi_Host *shost, int function, u64 tag, 665 + struct scsi_lun *scsilun, void *data) 666 + { 667 + int err; 668 + 669 + /* TODO: need to retry if this fails. */ 670 + err = scsi_tgt_uspace_send_tsk_mgmt(shost->host_no, function, 671 + tag, scsilun, data); 672 + if (err < 0) 673 + eprintk("The task management request lost!\n"); 674 + return err; 675 + } 676 + EXPORT_SYMBOL_GPL(scsi_tgt_tsk_mgmt_request); 677 + 678 + int scsi_tgt_kspace_tsk_mgmt(int host_no, u64 mid, int result) 679 + { 680 + struct Scsi_Host *shost; 681 + int err = -EINVAL; 682 + 683 + dprintk("%d %d %llx\n", host_no, result, (unsigned long long) mid); 684 + 685 + shost = scsi_host_lookup(host_no); 686 + if (IS_ERR(shost)) { 687 + printk(KERN_ERR "Could not find host no %d\n", host_no); 688 + return err; 689 + } 690 + 691 + if (!shost->uspace_req_q) { 692 + printk(KERN_ERR "Not target scsi host %d\n", host_no); 693 + goto done; 694 + } 695 + 696 + err = shost->hostt->tsk_mgmt_response(mid, result); 697 + done: 698 + scsi_host_put(shost); 699 + return err; 700 + } 701 + 702 + static int __init scsi_tgt_init(void) 703 + { 704 + int err; 705 + 706 + scsi_tgt_cmd_cache = kmem_cache_create("scsi_tgt_cmd", 707 + sizeof(struct scsi_tgt_cmd), 708 + 0, 0, NULL, NULL); 709 + if (!scsi_tgt_cmd_cache) 710 + return -ENOMEM; 711 + 712 + scsi_tgtd = create_workqueue("scsi_tgtd"); 713 + if (!scsi_tgtd) { 714 + err = -ENOMEM; 715 + goto free_kmemcache; 716 + } 717 + 718 + err = scsi_tgt_if_init(); 719 + if (err) 720 + goto destroy_wq; 721 + 722 + return 0; 723 + 724 + destroy_wq: 725 + destroy_workqueue(scsi_tgtd); 726 + free_kmemcache: 727 + kmem_cache_destroy(scsi_tgt_cmd_cache); 728 + return err; 729 + } 730 + 731 + static void __exit scsi_tgt_exit(void) 732 + { 733 + destroy_workqueue(scsi_tgtd); 734 + scsi_tgt_if_exit(); 735 + kmem_cache_destroy(scsi_tgt_cmd_cache); 736 + } 737 + 738 + module_init(scsi_tgt_init); 739 + module_exit(scsi_tgt_exit); 740 + 741 + MODULE_DESCRIPTION("SCSI target core"); 742 + MODULE_LICENSE("GPL");
+25
drivers/scsi/scsi_tgt_priv.h
··· 1 + struct scsi_cmnd; 2 + struct scsi_lun; 3 + struct Scsi_Host; 4 + struct task_struct; 5 + 6 + /* tmp - will replace with SCSI logging stuff */ 7 + #define eprintk(fmt, args...) \ 8 + do { \ 9 + printk("%s(%d) " fmt, __FUNCTION__, __LINE__, ##args); \ 10 + } while (0) 11 + 12 + #define dprintk(fmt, args...) 13 + /* #define dprintk eprintk */ 14 + 15 + extern void scsi_tgt_if_exit(void); 16 + extern int scsi_tgt_if_init(void); 17 + 18 + extern int scsi_tgt_uspace_send_cmd(struct scsi_cmnd *cmd, struct scsi_lun *lun, 19 + u64 tag); 20 + extern int scsi_tgt_uspace_send_status(struct scsi_cmnd *cmd, u64 tag); 21 + extern int scsi_tgt_kspace_exec(int host_no, u64 tag, int result, u32 len, 22 + unsigned long uaddr, u8 rw); 23 + extern int scsi_tgt_uspace_send_tsk_mgmt(int host_no, int function, u64 tag, 24 + struct scsi_lun *scsilun, void *data); 25 + extern int scsi_tgt_kspace_tsk_mgmt(int host_no, u64 mid, int result);
+31
drivers/scsi/scsi_wait_scan.c
··· 1 + /* 2 + * scsi_wait_scan.c 3 + * 4 + * Copyright (C) 2006 James Bottomley <James.Bottomley@SteelEye.com> 5 + * 6 + * This is a simple module to wait until all the async scans are 7 + * complete. The idea is to use it in initrd/initramfs scripts. You 8 + * modprobe it after all the modprobes of the root SCSI drivers and it 9 + * will wait until they have all finished scanning their busses before 10 + * allowing the boot to proceed 11 + */ 12 + 13 + #include <linux/module.h> 14 + #include "scsi_priv.h" 15 + 16 + static int __init wait_scan_init(void) 17 + { 18 + scsi_complete_async_scans(); 19 + return 0; 20 + } 21 + 22 + static void __exit wait_scan_exit(void) 23 + { 24 + } 25 + 26 + MODULE_DESCRIPTION("SCSI wait for scans"); 27 + MODULE_AUTHOR("James Bottomley"); 28 + MODULE_LICENSE("GPL"); 29 + 30 + late_initcall(wait_scan_init); 31 + module_exit(wait_scan_exit);
+15 -14
drivers/scsi/sd.c
··· 1051 1051 &sshdr, SD_TIMEOUT, 1052 1052 SD_MAX_RETRIES); 1053 1053 1054 + /* 1055 + * If the drive has indicated to us that it 1056 + * doesn't have any media in it, don't bother 1057 + * with any more polling. 1058 + */ 1059 + if (media_not_present(sdkp, &sshdr)) 1060 + return; 1061 + 1054 1062 if (the_result) 1055 1063 sense_valid = scsi_sense_valid(&sshdr); 1056 1064 retries++; ··· 1066 1058 (!scsi_status_is_good(the_result) || 1067 1059 ((driver_byte(the_result) & DRIVER_SENSE) && 1068 1060 sense_valid && sshdr.sense_key == UNIT_ATTENTION))); 1069 - 1070 - /* 1071 - * If the drive has indicated to us that it doesn't have 1072 - * any media in it, don't bother with any of the rest of 1073 - * this crap. 1074 - */ 1075 - if (media_not_present(sdkp, &sshdr)) 1076 - return; 1077 1061 1078 1062 if ((driver_byte(the_result) & DRIVER_SENSE) == 0) { 1079 1063 /* no sense, TUR either succeeded or failed ··· 1467 1467 res = sd_do_mode_sense(sdp, dbd, modepage, buffer, len, &data, &sshdr); 1468 1468 1469 1469 if (scsi_status_is_good(res)) { 1470 - int ct = 0; 1471 1470 int offset = data.header_length + data.block_descriptor_length; 1472 1471 1473 1472 if (offset >= SD_BUF_SIZE - 2) { ··· 1495 1496 sdkp->DPOFUA = 0; 1496 1497 } 1497 1498 1498 - ct = sdkp->RCD + 2*sdkp->WCE; 1499 - 1500 - printk(KERN_NOTICE "SCSI device %s: drive cache: %s%s\n", 1501 - diskname, sd_cache_types[ct], 1502 - sdkp->DPOFUA ? " w/ FUA" : ""); 1499 + printk(KERN_NOTICE "SCSI device %s: " 1500 + "write cache: %s, read cache: %s, %s\n", 1501 + diskname, 1502 + sdkp->WCE ? "enabled" : "disabled", 1503 + sdkp->RCD ? "disabled" : "enabled", 1504 + sdkp->DPOFUA ? "supports DPO and FUA" 1505 + : "doesn't support DPO or FUA"); 1503 1506 1504 1507 return; 1505 1508 }
+8 -8
drivers/scsi/st.c
··· 9 9 Steve Hirsch, Andreas Koppenh"ofer, Michael Leodolter, Eyal Lebedinsky, 10 10 Michael Schaefer, J"org Weule, and Eric Youngdale. 11 11 12 - Copyright 1992 - 2005 Kai Makisara 12 + Copyright 1992 - 2006 Kai Makisara 13 13 email Kai.Makisara@kolumbus.fi 14 14 15 15 Some small formal changes - aeb, 950809 ··· 17 17 Last modified: 18-JAN-1998 Richard Gooch <rgooch@atnf.csiro.au> Devfs support 18 18 */ 19 19 20 - static const char *verstr = "20050830"; 20 + static const char *verstr = "20061107"; 21 21 22 22 #include <linux/module.h> 23 23 ··· 999 999 STp->min_block = ((STp->buffer)->b_data[4] << 8) | 1000 1000 (STp->buffer)->b_data[5]; 1001 1001 if ( DEB( debugging || ) !STp->inited) 1002 - printk(KERN_WARNING 1002 + printk(KERN_INFO 1003 1003 "%s: Block limits %d - %d bytes.\n", name, 1004 1004 STp->min_block, STp->max_block); 1005 1005 } else { ··· 1224 1224 } 1225 1225 1226 1226 DEBC( if (STp->nbr_requests) 1227 - printk(KERN_WARNING "%s: Number of r/w requests %d, dio used in %d, pages %d (%d).\n", 1227 + printk(KERN_DEBUG "%s: Number of r/w requests %d, dio used in %d, pages %d (%d).\n", 1228 1228 name, STp->nbr_requests, STp->nbr_dio, STp->nbr_pages, STp->nbr_combinable)); 1229 1229 1230 1230 if (STps->rw == ST_WRITING && !STp->pos_unknown) { ··· 4056 4056 goto out_free_tape; 4057 4057 } 4058 4058 4059 - sdev_printk(KERN_WARNING, SDp, 4059 + sdev_printk(KERN_NOTICE, SDp, 4060 4060 "Attached scsi tape %s\n", tape_name(tpnt)); 4061 - printk(KERN_WARNING "%s: try direct i/o: %s (alignment %d B)\n", 4062 - tape_name(tpnt), tpnt->try_dio ? "yes" : "no", 4063 - queue_dma_alignment(SDp->request_queue) + 1); 4061 + sdev_printk(KERN_INFO, SDp, "%s: try direct i/o: %s (alignment %d B)\n", 4062 + tape_name(tpnt), tpnt->try_dio ? "yes" : "no", 4063 + queue_dma_alignment(SDp->request_queue) + 1); 4064 4064 4065 4065 return 0; 4066 4066
+84 -46
drivers/scsi/stex.c
··· 11 11 * Written By: 12 12 * Ed Lin <promise_linux@promise.com> 13 13 * 14 - * Version: 3.0.0.1 15 - * 16 14 */ 17 15 18 16 #include <linux/init.h> ··· 35 37 #include <scsi/scsi_tcq.h> 36 38 37 39 #define DRV_NAME "stex" 38 - #define ST_DRIVER_VERSION "3.0.0.1" 40 + #define ST_DRIVER_VERSION "3.1.0.1" 39 41 #define ST_VER_MAJOR 3 40 - #define ST_VER_MINOR 0 42 + #define ST_VER_MINOR 1 41 43 #define ST_OEM 0 42 44 #define ST_BUILD_VER 1 43 45 ··· 74 76 MU_STATE_STARTED = 4, 75 77 MU_STATE_RESETTING = 5, 76 78 77 - MU_MAX_DELAY_TIME = 240000, 79 + MU_MAX_DELAY = 120, 78 80 MU_HANDSHAKE_SIGNATURE = 0x55aaaa55, 81 + MU_HANDSHAKE_SIGNATURE_HALF = 0x5a5a0000, 82 + MU_HARD_RESET_WAIT = 30000, 79 83 HMU_PARTNER_TYPE = 2, 80 84 81 85 /* firmware returned values */ ··· 120 120 121 121 st_shasta = 0, 122 122 st_vsc = 1, 123 - st_yosemite = 2, 123 + st_vsc1 = 2, 124 + st_yosemite = 3, 124 125 125 126 PASSTHRU_REQ_TYPE = 0x00000001, 126 127 PASSTHRU_REQ_NO_WAKEUP = 0x00000100, ··· 151 150 MGT_CMD_SIGNATURE = 0xba, 152 151 153 152 INQUIRY_EVPD = 0x01, 153 + 154 + ST_ADDITIONAL_MEM = 0x200000, 154 155 }; 155 156 156 157 /* SCSI inquiry data */ ··· 214 211 __le32 partner_ver_minor; 215 212 __le32 partner_ver_oem; 216 213 __le32 partner_ver_build; 217 - u32 reserved1[4]; 214 + __le32 extra_offset; /* NEW */ 215 + __le32 extra_size; /* NEW */ 216 + u32 reserved1[2]; 218 217 }; 219 218 220 219 struct req_msg { ··· 307 302 void __iomem *mmio_base; /* iomapped PCI memory space */ 308 303 void *dma_mem; 309 304 dma_addr_t dma_handle; 305 + size_t dma_size; 310 306 311 307 struct Scsi_Host *host; 312 308 struct pci_dev *pdev; ··· 513 507 size_t count = sizeof(struct st_frame); 514 508 515 509 p = hba->copy_buffer; 510 + stex_internal_copy(ccb->cmd, p, &count, ccb->sg_count, ST_FROM_CMD); 516 511 memset(p->base, 0, sizeof(u32)*6); 517 512 *(unsigned long *)(p->base) = pci_resource_start(hba->pdev, 0); 518 513 p->rom_addr = 0; ··· 908 901 void __iomem *base = hba->mmio_base; 909 902 struct handshake_frame *h; 910 903 dma_addr_t status_phys; 911 - int i; 904 + u32 data; 905 + unsigned long before; 912 906 913 907 if (readl(base + OMR0) != MU_HANDSHAKE_SIGNATURE) { 914 908 writel(MU_INBOUND_DOORBELL_HANDSHAKE, base + IDBL); 915 909 readl(base + IDBL); 916 - for (i = 0; readl(base + OMR0) != MU_HANDSHAKE_SIGNATURE 917 - && i < MU_MAX_DELAY_TIME; i++) { 910 + before = jiffies; 911 + while (readl(base + OMR0) != MU_HANDSHAKE_SIGNATURE) { 912 + if (time_after(jiffies, before + MU_MAX_DELAY * HZ)) { 913 + printk(KERN_ERR DRV_NAME 914 + "(%s): no handshake signature\n", 915 + pci_name(hba->pdev)); 916 + return -1; 917 + } 918 918 rmb(); 919 919 msleep(1); 920 - } 921 - 922 - if (i == MU_MAX_DELAY_TIME) { 923 - printk(KERN_ERR DRV_NAME 924 - "(%s): no handshake signature\n", 925 - pci_name(hba->pdev)); 926 - return -1; 927 920 } 928 921 } 929 922 930 923 udelay(10); 924 + 925 + data = readl(base + OMR1); 926 + if ((data & 0xffff0000) == MU_HANDSHAKE_SIGNATURE_HALF) { 927 + data &= 0x0000ffff; 928 + if (hba->host->can_queue > data) 929 + hba->host->can_queue = data; 930 + } 931 931 932 932 h = (struct handshake_frame *)(hba->dma_mem + MU_REQ_BUFFER_SIZE); 933 933 h->rb_phy = cpu_to_le32(hba->dma_handle); ··· 945 931 h->status_cnt = cpu_to_le16(MU_STATUS_COUNT); 946 932 stex_gettime(&h->hosttime); 947 933 h->partner_type = HMU_PARTNER_TYPE; 934 + if (hba->dma_size > STEX_BUFFER_SIZE) { 935 + h->extra_offset = cpu_to_le32(STEX_BUFFER_SIZE); 936 + h->extra_size = cpu_to_le32(ST_ADDITIONAL_MEM); 937 + } else 938 + h->extra_offset = h->extra_size = 0; 948 939 949 940 status_phys = hba->dma_handle + MU_REQ_BUFFER_SIZE; 950 941 writel(status_phys, base + IMR0); ··· 963 944 readl(base + IDBL); /* flush */ 964 945 965 946 udelay(10); 966 - for (i = 0; readl(base + OMR0) != MU_HANDSHAKE_SIGNATURE 967 - && i < MU_MAX_DELAY_TIME; i++) { 947 + before = jiffies; 948 + while (readl(base + OMR0) != MU_HANDSHAKE_SIGNATURE) { 949 + if (time_after(jiffies, before + MU_MAX_DELAY * HZ)) { 950 + printk(KERN_ERR DRV_NAME 951 + "(%s): no signature after handshake frame\n", 952 + pci_name(hba->pdev)); 953 + return -1; 954 + } 968 955 rmb(); 969 956 msleep(1); 970 - } 971 - 972 - if (i == MU_MAX_DELAY_TIME) { 973 - printk(KERN_ERR DRV_NAME 974 - "(%s): no signature after handshake frame\n", 975 - pci_name(hba->pdev)); 976 - return -1; 977 957 } 978 958 979 959 writel(0, base + IMR0); ··· 1056 1038 pci_bctl &= ~PCI_BRIDGE_CTL_BUS_RESET; 1057 1039 pci_write_config_byte(bus->self, PCI_BRIDGE_CONTROL, pci_bctl); 1058 1040 1059 - for (i = 0; i < MU_MAX_DELAY_TIME; i++) { 1041 + for (i = 0; i < MU_HARD_RESET_WAIT; i++) { 1060 1042 pci_read_config_word(hba->pdev, PCI_COMMAND, &pci_cmd); 1061 - if (pci_cmd & PCI_COMMAND_MASTER) 1043 + if (pci_cmd != 0xffff && (pci_cmd & PCI_COMMAND_MASTER)) 1062 1044 break; 1063 1045 msleep(1); 1064 1046 } ··· 1118 1100 static int stex_biosparam(struct scsi_device *sdev, 1119 1101 struct block_device *bdev, sector_t capacity, int geom[]) 1120 1102 { 1121 - int heads = 255, sectors = 63, cylinders; 1103 + int heads = 255, sectors = 63; 1122 1104 1123 1105 if (capacity < 0x200000) { 1124 1106 heads = 64; 1125 1107 sectors = 32; 1126 1108 } 1127 1109 1128 - cylinders = sector_div(capacity, heads * sectors); 1110 + sector_div(capacity, heads * sectors); 1129 1111 1130 1112 geom[0] = heads; 1131 1113 geom[1] = sectors; 1132 - geom[2] = cylinders; 1114 + geom[2] = capacity; 1133 1115 1134 1116 return 0; 1135 1117 } ··· 1211 1193 goto out_iounmap; 1212 1194 } 1213 1195 1196 + hba->cardtype = (unsigned int) id->driver_data; 1197 + if (hba->cardtype == st_vsc && (pdev->subsystem_device & 0xf) == 0x1) 1198 + hba->cardtype = st_vsc1; 1199 + hba->dma_size = (hba->cardtype == st_vsc1) ? 1200 + (STEX_BUFFER_SIZE + ST_ADDITIONAL_MEM) : (STEX_BUFFER_SIZE); 1214 1201 hba->dma_mem = dma_alloc_coherent(&pdev->dev, 1215 - STEX_BUFFER_SIZE, &hba->dma_handle, GFP_KERNEL); 1202 + hba->dma_size, &hba->dma_handle, GFP_KERNEL); 1216 1203 if (!hba->dma_mem) { 1217 1204 err = -ENOMEM; 1218 1205 printk(KERN_ERR DRV_NAME "(%s): dma mem alloc failed\n", ··· 1229 1206 (struct status_msg *)(hba->dma_mem + MU_REQ_BUFFER_SIZE); 1230 1207 hba->copy_buffer = hba->dma_mem + MU_BUFFER_SIZE; 1231 1208 hba->mu_status = MU_STATE_STARTING; 1232 - 1233 - hba->cardtype = (unsigned int) id->driver_data; 1234 1209 1235 1210 /* firmware uses id/lun pair for a logical drive, but lun would be 1236 1211 always 0 if CONFIG_SCSI_MULTI_LUN not configured, so we use ··· 1254 1233 if (err) 1255 1234 goto out_free_irq; 1256 1235 1257 - err = scsi_init_shared_tag_map(host, ST_CAN_QUEUE); 1236 + err = scsi_init_shared_tag_map(host, host->can_queue); 1258 1237 if (err) { 1259 1238 printk(KERN_ERR DRV_NAME "(%s): init shared queue failed\n", 1260 1239 pci_name(pdev)); ··· 1277 1256 out_free_irq: 1278 1257 free_irq(pdev->irq, hba); 1279 1258 out_pci_free: 1280 - dma_free_coherent(&pdev->dev, STEX_BUFFER_SIZE, 1259 + dma_free_coherent(&pdev->dev, hba->dma_size, 1281 1260 hba->dma_mem, hba->dma_handle); 1282 1261 out_iounmap: 1283 1262 iounmap(hba->mmio_base); ··· 1338 1317 1339 1318 pci_release_regions(hba->pdev); 1340 1319 1341 - dma_free_coherent(&hba->pdev->dev, STEX_BUFFER_SIZE, 1320 + dma_free_coherent(&hba->pdev->dev, hba->dma_size, 1342 1321 hba->dma_mem, hba->dma_handle); 1343 1322 } 1344 1323 ··· 1367 1346 } 1368 1347 1369 1348 static struct pci_device_id stex_pci_tbl[] = { 1370 - { 0x105a, 0x8350, PCI_ANY_ID, PCI_ANY_ID, 0, 0, st_shasta }, 1371 - { 0x105a, 0xc350, PCI_ANY_ID, PCI_ANY_ID, 0, 0, st_shasta }, 1372 - { 0x105a, 0xf350, PCI_ANY_ID, PCI_ANY_ID, 0, 0, st_shasta }, 1373 - { 0x105a, 0x4301, PCI_ANY_ID, PCI_ANY_ID, 0, 0, st_shasta }, 1374 - { 0x105a, 0x4302, PCI_ANY_ID, PCI_ANY_ID, 0, 0, st_shasta }, 1375 - { 0x105a, 0x8301, PCI_ANY_ID, PCI_ANY_ID, 0, 0, st_shasta }, 1376 - { 0x105a, 0x8302, PCI_ANY_ID, PCI_ANY_ID, 0, 0, st_shasta }, 1377 - { 0x1725, 0x7250, PCI_ANY_ID, PCI_ANY_ID, 0, 0, st_vsc }, 1378 - { 0x105a, 0x8650, PCI_ANY_ID, PCI_ANY_ID, 0, 0, st_yosemite }, 1349 + /* st_shasta */ 1350 + { 0x105a, 0x8350, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1351 + st_shasta }, /* SuperTrak EX8350/8300/16350/16300 */ 1352 + { 0x105a, 0xc350, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1353 + st_shasta }, /* SuperTrak EX12350 */ 1354 + { 0x105a, 0x4302, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1355 + st_shasta }, /* SuperTrak EX4350 */ 1356 + { 0x105a, 0xe350, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1357 + st_shasta }, /* SuperTrak EX24350 */ 1358 + 1359 + /* st_vsc */ 1360 + { 0x105a, 0x7250, PCI_ANY_ID, PCI_ANY_ID, 0, 0, st_vsc }, 1361 + 1362 + /* st_yosemite */ 1363 + { 0x105a, 0x8650, PCI_ANY_ID, 0x4600, 0, 0, 1364 + st_yosemite }, /* SuperTrak EX4650 */ 1365 + { 0x105a, 0x8650, PCI_ANY_ID, 0x4610, 0, 0, 1366 + st_yosemite }, /* SuperTrak EX4650o */ 1367 + { 0x105a, 0x8650, PCI_ANY_ID, 0x8600, 0, 0, 1368 + st_yosemite }, /* SuperTrak EX8650EL */ 1369 + { 0x105a, 0x8650, PCI_ANY_ID, 0x8601, 0, 0, 1370 + st_yosemite }, /* SuperTrak EX8650 */ 1371 + { 0x105a, 0x8650, PCI_ANY_ID, 0x8602, 0, 0, 1372 + st_yosemite }, /* SuperTrak EX8654 */ 1373 + { 0x105a, 0x8650, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1374 + st_yosemite }, /* generic st_yosemite */ 1379 1375 { } /* terminate list */ 1380 1376 }; 1381 1377 MODULE_DEVICE_TABLE(pci, stex_pci_tbl);
+20 -19
drivers/scsi/t128.h
··· 8 8 * drew@colorado.edu 9 9 * +1 (303) 440-4894 10 10 * 11 - * DISTRIBUTION RELEASE 3. 11 + * DISTRIBUTION RELEASE 3. 12 12 * 13 - * For more information, please consult 13 + * For more information, please consult 14 14 * 15 15 * Trantor Systems, Ltd. 16 16 * T128/T128F/T228 SCSI Host Adapter 17 17 * Hardware Specifications 18 - * 19 - * Trantor Systems, Ltd. 18 + * 19 + * Trantor Systems, Ltd. 20 20 * 5415 Randall Place 21 21 * Fremont, CA 94538 22 22 * 1+ (415) 770-1400, FAX 1+ (415) 770-9910 23 - * 24 - * and 23 + * 24 + * and 25 25 * 26 26 * NCR 5380 Family 27 27 * SCSI Protocol Controller ··· 48 48 #define TDEBUG_TRANSFER 0x2 49 49 50 50 /* 51 - * The trantor boards are memory mapped. They use an NCR5380 or 51 + * The trantor boards are memory mapped. They use an NCR5380 or 52 52 * equivalent (my sample board had part second sourced from ZILOG). 53 - * NCR's recommended "Pseudo-DMA" architecture is used, where 53 + * NCR's recommended "Pseudo-DMA" architecture is used, where 54 54 * a PAL drives the DMA signals on the 5380 allowing fast, blind 55 - * transfers with proper handshaking. 55 + * transfers with proper handshaking. 56 56 */ 57 57 58 58 /* 59 - * Note : a boot switch is provided for the purpose of informing the 59 + * Note : a boot switch is provided for the purpose of informing the 60 60 * firmware to boot or not boot from attached SCSI devices. So, I imagine 61 61 * there are fewer people who've yanked the ROM like they do on the Seagate 62 62 * to make bootup faster, and I'll probably use this for autodetection. ··· 92 92 #define T_DATA_REG_OFFSET 0x1e00 /* rw 512 bytes long */ 93 93 94 94 #ifndef ASM 95 - static int t128_abort(Scsi_Cmnd *); 95 + static int t128_abort(struct scsi_cmnd *); 96 96 static int t128_biosparam(struct scsi_device *, struct block_device *, 97 97 sector_t, int*); 98 98 static int t128_detect(struct scsi_host_template *); 99 - static int t128_queue_command(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *)); 100 - static int t128_bus_reset(Scsi_Cmnd *); 99 + static int t128_queue_command(struct scsi_cmnd *, 100 + void (*done)(struct scsi_cmnd *)); 101 + static int t128_bus_reset(struct scsi_cmnd *); 101 102 102 103 #ifndef CMD_PER_LUN 103 104 #define CMD_PER_LUN 2 104 105 #endif 105 106 106 107 #ifndef CAN_QUEUE 107 - #define CAN_QUEUE 32 108 + #define CAN_QUEUE 32 108 109 #endif 109 110 110 111 #ifndef HOSTS_C ··· 121 120 122 121 #define T128_address(reg) (base + T_5380_OFFSET + ((reg) * 0x20)) 123 122 124 - #if !(TDEBUG & TDEBUG_TRANSFER) 123 + #if !(TDEBUG & TDEBUG_TRANSFER) 125 124 #define NCR5380_read(reg) readb(T128_address(reg)) 126 125 #define NCR5380_write(reg, value) writeb((value),(T128_address(reg))) 127 126 #else ··· 130 129 , instance->hostno, (reg), T128_address(reg))), readb(T128_address(reg))) 131 130 132 131 #define NCR5380_write(reg, value) { \ 133 - printk("scsi%d : write %02x to register %d at address %08x\n", \ 132 + printk("scsi%d : write %02x to register %d at address %08x\n", \ 134 133 instance->hostno, (value), (reg), T128_address(reg)); \ 135 134 writeb((value), (T128_address(reg))); \ 136 135 } ··· 143 142 #define NCR5380_bus_reset t128_bus_reset 144 143 #define NCR5380_proc_info t128_proc_info 145 144 146 - /* 15 14 12 10 7 5 3 145 + /* 15 14 12 10 7 5 3 147 146 1101 0100 1010 1000 */ 148 - 149 - #define T128_IRQS 0xc4a8 147 + 148 + #define T128_IRQS 0xc4a8 150 149 151 150 #endif /* else def HOSTS_C */ 152 151 #endif /* ndef ASM */
+11 -3
include/scsi/libsas.h
··· 339 339 void (*notify_phy_event)(struct asd_sas_phy *, enum phy_event); 340 340 341 341 void *lldd_ha; /* not touched by sas class code */ 342 + 343 + struct list_head eh_done_q; 342 344 }; 343 345 344 346 #define SHOST_TO_SAS_HA(_shost) (*(struct sas_ha_struct **)(_shost)->hostdata) ··· 529 527 530 528 void *lldd_task; /* for use by LLDDs */ 531 529 void *uldd_task; 530 + 531 + struct work_struct abort_work; 532 532 }; 533 533 534 534 535 535 536 - #define SAS_TASK_STATE_PENDING 1 537 - #define SAS_TASK_STATE_DONE 2 538 - #define SAS_TASK_STATE_ABORTED 4 536 + #define SAS_TASK_STATE_PENDING 1 537 + #define SAS_TASK_STATE_DONE 2 538 + #define SAS_TASK_STATE_ABORTED 4 539 + #define SAS_TASK_INITIATOR_ABORTED 8 539 540 540 541 static inline struct sas_task *sas_alloc_task(gfp_t flags) 541 542 { ··· 598 593 extern int sas_register_ha(struct sas_ha_struct *); 599 594 extern int sas_unregister_ha(struct sas_ha_struct *); 600 595 596 + int sas_phy_reset(struct sas_phy *phy, int hard_reset); 601 597 extern int sas_queuecommand(struct scsi_cmnd *, 602 598 void (*scsi_done)(struct scsi_cmnd *)); 603 599 extern int sas_target_alloc(struct scsi_target *); ··· 630 624 void sas_unregister_dev(struct domain_device *); 631 625 632 626 void sas_init_dev(struct domain_device *); 627 + 628 + void sas_task_abort(struct sas_task *task); 633 629 634 630 #endif /* _SASLIB_H_ */
+77
include/scsi/libsrp.h
··· 1 + #ifndef __LIBSRP_H__ 2 + #define __LIBSRP_H__ 3 + 4 + #include <linux/list.h> 5 + #include <scsi/scsi_cmnd.h> 6 + #include <scsi/scsi_host.h> 7 + #include <scsi/srp.h> 8 + 9 + enum iue_flags { 10 + V_DIOVER, 11 + V_WRITE, 12 + V_LINKED, 13 + V_FLYING, 14 + }; 15 + 16 + struct srp_buf { 17 + dma_addr_t dma; 18 + void *buf; 19 + }; 20 + 21 + struct srp_queue { 22 + void *pool; 23 + void *items; 24 + struct kfifo *queue; 25 + spinlock_t lock; 26 + }; 27 + 28 + struct srp_target { 29 + struct Scsi_Host *shost; 30 + struct device *dev; 31 + 32 + spinlock_t lock; 33 + struct list_head cmd_queue; 34 + 35 + size_t srp_iu_size; 36 + struct srp_queue iu_queue; 37 + size_t rx_ring_size; 38 + struct srp_buf **rx_ring; 39 + 40 + void *ldata; 41 + }; 42 + 43 + struct iu_entry { 44 + struct srp_target *target; 45 + 46 + struct list_head ilist; 47 + dma_addr_t remote_token; 48 + unsigned long flags; 49 + 50 + struct srp_buf *sbuf; 51 + }; 52 + 53 + typedef int (srp_rdma_t)(struct scsi_cmnd *, struct scatterlist *, int, 54 + struct srp_direct_buf *, int, 55 + enum dma_data_direction, unsigned int); 56 + extern int srp_target_alloc(struct srp_target *, struct device *, size_t, size_t); 57 + extern void srp_target_free(struct srp_target *); 58 + 59 + extern struct iu_entry *srp_iu_get(struct srp_target *); 60 + extern void srp_iu_put(struct iu_entry *); 61 + 62 + extern int srp_cmd_queue(struct Scsi_Host *, struct srp_cmd *, void *, u64); 63 + extern int srp_transfer_data(struct scsi_cmnd *, struct srp_cmd *, 64 + srp_rdma_t, int, int); 65 + 66 + 67 + static inline struct srp_target *host_to_srp_target(struct Scsi_Host *host) 68 + { 69 + return (struct srp_target *) host->hostdata; 70 + } 71 + 72 + static inline int srp_cmd_direction(struct srp_cmd *cmd) 73 + { 74 + return (cmd->buf_fmt >> 4) ? DMA_TO_DEVICE : DMA_FROM_DEVICE; 75 + } 76 + 77 + #endif
+10
include/scsi/scsi_cmnd.h
··· 8 8 9 9 struct request; 10 10 struct scatterlist; 11 + struct Scsi_Host; 11 12 struct scsi_device; 12 13 13 14 ··· 73 72 unsigned short use_sg; /* Number of pieces of scatter-gather */ 74 73 unsigned short sglist_len; /* size of malloc'd scatter-gather list */ 75 74 75 + /* offset in cmd we are at (for multi-transfer tgt cmds) */ 76 + unsigned offset; 77 + 76 78 unsigned underflow; /* Return error if less than 77 79 this amount is transferred */ 78 80 ··· 123 119 }; 124 120 125 121 extern struct scsi_cmnd *scsi_get_command(struct scsi_device *, gfp_t); 122 + extern struct scsi_cmnd *__scsi_get_command(struct Scsi_Host *, gfp_t); 126 123 extern void scsi_put_command(struct scsi_cmnd *); 124 + extern void __scsi_put_command(struct Scsi_Host *, struct scsi_cmnd *, 125 + struct device *); 127 126 extern void scsi_io_completion(struct scsi_cmnd *, unsigned int); 128 127 extern void scsi_finish_command(struct scsi_cmnd *cmd); 129 128 extern void scsi_req_abort_cmd(struct scsi_cmnd *cmd); ··· 134 127 extern void *scsi_kmap_atomic_sg(struct scatterlist *sg, int sg_count, 135 128 size_t *offset, size_t *len); 136 129 extern void scsi_kunmap_atomic_sg(void *virt); 130 + 131 + extern struct scatterlist *scsi_alloc_sgtable(struct scsi_cmnd *, gfp_t); 132 + extern void scsi_free_sgtable(struct scatterlist *, int); 137 133 138 134 #endif /* _SCSI_SCSI_CMND_H */
+15 -15
include/scsi/scsi_device.h
··· 223 223 struct scsi_device *); 224 224 225 225 /** 226 - * shost_for_each_device - iterate over all devices of a host 227 - * @sdev: iterator 228 - * @host: host whiches devices we want to iterate over 226 + * shost_for_each_device - iterate over all devices of a host 227 + * @sdev: the &struct scsi_device to use as a cursor 228 + * @shost: the &struct scsi_host to iterate over 229 229 * 230 - * This traverses over each devices of @shost. The devices have 231 - * a reference that must be released by scsi_host_put when breaking 232 - * out of the loop. 230 + * Iterator that returns each device attached to @shost. This loop 231 + * takes a reference on each device and releases it at the end. If 232 + * you break out of the loop, you must call scsi_device_put(sdev). 233 233 */ 234 234 #define shost_for_each_device(sdev, shost) \ 235 235 for ((sdev) = __scsi_iterate_devices((shost), NULL); \ ··· 237 237 (sdev) = __scsi_iterate_devices((shost), (sdev))) 238 238 239 239 /** 240 - * __shost_for_each_device - iterate over all devices of a host (UNLOCKED) 241 - * @sdev: iterator 242 - * @host: host whiches devices we want to iterate over 240 + * __shost_for_each_device - iterate over all devices of a host (UNLOCKED) 241 + * @sdev: the &struct scsi_device to use as a cursor 242 + * @shost: the &struct scsi_host to iterate over 243 243 * 244 - * This traverses over each devices of @shost. It does _not_ take a 245 - * reference on the scsi_device, thus it the whole loop must be protected 246 - * by shost->host_lock. 244 + * Iterator that returns each device attached to @shost. It does _not_ 245 + * take a reference on the scsi_device, so the whole loop must be 246 + * protected by shost->host_lock. 247 247 * 248 - * Note: The only reason why drivers would want to use this is because 249 - * they're need to access the device list in irq context. Otherwise you 250 - * really want to use shost_for_each_device instead. 248 + * Note: The only reason to use this is because you need to access the 249 + * device list in interrupt context. Otherwise you really want to use 250 + * shost_for_each_device instead. 251 251 */ 252 252 #define __shost_for_each_device(sdev, shost) \ 253 253 list_for_each_entry((sdev), &((shost)->__devices), siblings)
+64 -5
include/scsi/scsi_host.h
··· 7 7 #include <linux/workqueue.h> 8 8 #include <linux/mutex.h> 9 9 10 + struct request_queue; 10 11 struct block_device; 11 12 struct completion; 12 13 struct module; ··· 125 124 void (*done)(struct scsi_cmnd *)); 126 125 127 126 /* 127 + * The transfer functions are used to queue a scsi command to 128 + * the LLD. When the driver is finished processing the command 129 + * the done callback is invoked. 130 + * 131 + * return values: see queuecommand 132 + * 133 + * If the LLD accepts the cmd, it should set the result to an 134 + * appropriate value when completed before calling the done function. 135 + * 136 + * STATUS: REQUIRED FOR TARGET DRIVERS 137 + */ 138 + /* TODO: rename */ 139 + int (* transfer_response)(struct scsi_cmnd *, 140 + void (*done)(struct scsi_cmnd *)); 141 + /* 142 + * This is called to inform the LLD to transfer cmd->request_bufflen 143 + * bytes of the cmd at cmd->offset in the cmd. The cmd->use_sg 144 + * speciefies the number of scatterlist entried in the command 145 + * and cmd->request_buffer contains the scatterlist. 146 + * 147 + * If the command cannot be processed in one transfer_data call 148 + * becuase a scatterlist within the LLD's limits cannot be 149 + * created then transfer_data will be called multiple times. 150 + * It is initially called from process context, and later 151 + * calls are from the interrup context. 152 + */ 153 + int (* transfer_data)(struct scsi_cmnd *, 154 + void (*done)(struct scsi_cmnd *)); 155 + 156 + /* Used as callback for the completion of task management request. */ 157 + int (* tsk_mgmt_response)(u64 mid, int result); 158 + 159 + /* 128 160 * This is an error handling strategy routine. You don't need to 129 161 * define one of these if you don't want to - there is a default 130 162 * routine that is present that should work in most cases. For those ··· 273 239 * Status: OPTIONAL 274 240 */ 275 241 void (* target_destroy)(struct scsi_target *); 242 + 243 + /* 244 + * If a host has the ability to discover targets on its own instead 245 + * of scanning the entire bus, it can fill in this function and 246 + * call scsi_scan_host(). This function will be called periodically 247 + * until it returns 1 with the scsi_host and the elapsed time of 248 + * the scan in jiffies. 249 + * 250 + * Status: OPTIONAL 251 + */ 252 + int (* scan_finished)(struct Scsi_Host *, unsigned long); 253 + 254 + /* 255 + * If the host wants to be called before the scan starts, but 256 + * after the midlayer has set up ready for the scan, it can fill 257 + * in this function. 258 + */ 259 + void (* scan_start)(struct Scsi_Host *); 276 260 277 261 /* 278 262 * fill in this function to allow the queue depth of this host ··· 604 552 /* task mgmt function in progress */ 605 553 unsigned tmf_in_progress:1; 606 554 555 + /* Asynchronous scan in progress */ 556 + unsigned async_scan:1; 557 + 607 558 /* 608 559 * Optional work queue to be utilized by the transport 609 560 */ ··· 622 567 * Value host_blocked counts down from 623 568 */ 624 569 unsigned int max_host_blocked; 570 + 571 + /* 572 + * q used for scsi_tgt msgs, async events or any other requests that 573 + * need to be processed in userspace 574 + */ 575 + struct request_queue *uspace_req_q; 625 576 626 577 /* legacy crap */ 627 578 unsigned long base; ··· 709 648 710 649 extern u64 scsi_calculate_bounce_limit(struct Scsi_Host *); 711 650 712 - static inline void scsi_assign_lock(struct Scsi_Host *shost, spinlock_t *lock) 713 - { 714 - shost->host_lock = lock; 715 - } 716 - 717 651 static inline struct device *scsi_get_device(struct Scsi_Host *shost) 718 652 { 719 653 return shost->shost_gendev.parent; ··· 727 671 extern void scsi_block_requests(struct Scsi_Host *); 728 672 729 673 struct class_container; 674 + 675 + extern struct request_queue *__scsi_alloc_queue(struct Scsi_Host *shost, 676 + void (*) (struct request_queue *)); 730 677 /* 731 678 * These two functions are used to allocate and free a pseudo device 732 679 * which will connect to the host adapter itself rather than any
+19
include/scsi/scsi_tgt.h
··· 1 + /* 2 + * SCSI target definitions 3 + */ 4 + 5 + #include <linux/dma-mapping.h> 6 + 7 + struct Scsi_Host; 8 + struct scsi_cmnd; 9 + struct scsi_lun; 10 + 11 + extern struct Scsi_Host *scsi_tgt_cmd_to_host(struct scsi_cmnd *); 12 + extern int scsi_tgt_alloc_queue(struct Scsi_Host *); 13 + extern void scsi_tgt_free_queue(struct Scsi_Host *); 14 + extern int scsi_tgt_queue_command(struct scsi_cmnd *, struct scsi_lun *, u64); 15 + extern int scsi_tgt_tsk_mgmt_request(struct Scsi_Host *, int, u64, struct scsi_lun *, 16 + void *); 17 + extern struct scsi_cmnd *scsi_host_get_command(struct Scsi_Host *, 18 + enum dma_data_direction, gfp_t); 19 + extern void scsi_host_put_command(struct Scsi_Host *, struct scsi_cmnd *);
+90
include/scsi/scsi_tgt_if.h
··· 1 + /* 2 + * SCSI target kernel/user interface 3 + * 4 + * Copyright (C) 2005 FUJITA Tomonori <tomof@acm.org> 5 + * Copyright (C) 2005 Mike Christie <michaelc@cs.wisc.edu> 6 + * 7 + * This program is free software; you can redistribute it and/or 8 + * modify it under the terms of the GNU General Public License as 9 + * published by the Free Software Foundation; either version 2 of the 10 + * License, or (at your option) any later version. 11 + * 12 + * This program is distributed in the hope that it will be useful, but 13 + * WITHOUT ANY WARRANTY; without even the implied warranty of 14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 + * General Public License for more details. 16 + * 17 + * You should have received a copy of the GNU General Public License 18 + * along with this program; if not, write to the Free Software 19 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 20 + * 02110-1301 USA 21 + */ 22 + #ifndef __SCSI_TARGET_IF_H 23 + #define __SCSI_TARGET_IF_H 24 + 25 + /* user -> kernel */ 26 + #define TGT_UEVENT_CMD_RSP 0x0001 27 + #define TGT_UEVENT_TSK_MGMT_RSP 0x0002 28 + 29 + /* kernel -> user */ 30 + #define TGT_KEVENT_CMD_REQ 0x1001 31 + #define TGT_KEVENT_CMD_DONE 0x1002 32 + #define TGT_KEVENT_TSK_MGMT_REQ 0x1003 33 + 34 + struct tgt_event_hdr { 35 + uint16_t version; 36 + uint16_t status; 37 + uint16_t type; 38 + uint16_t len; 39 + } __attribute__ ((aligned (sizeof(uint64_t)))); 40 + 41 + struct tgt_event { 42 + struct tgt_event_hdr hdr; 43 + 44 + union { 45 + /* user-> kernel */ 46 + struct { 47 + int host_no; 48 + uint32_t len; 49 + int result; 50 + aligned_u64 uaddr; 51 + uint8_t rw; 52 + aligned_u64 tag; 53 + } cmd_rsp; 54 + struct { 55 + int host_no; 56 + aligned_u64 mid; 57 + int result; 58 + } tsk_mgmt_rsp; 59 + 60 + 61 + /* kernel -> user */ 62 + struct { 63 + int host_no; 64 + uint32_t data_len; 65 + uint8_t scb[16]; 66 + uint8_t lun[8]; 67 + int attribute; 68 + aligned_u64 tag; 69 + } cmd_req; 70 + struct { 71 + int host_no; 72 + aligned_u64 tag; 73 + int result; 74 + } cmd_done; 75 + struct { 76 + int host_no; 77 + int function; 78 + aligned_u64 tag; 79 + uint8_t lun[8]; 80 + aligned_u64 mid; 81 + } tsk_mgmt_req; 82 + } p; 83 + } __attribute__ ((aligned (sizeof(uint64_t)))); 84 + 85 + #define TGT_RING_SIZE (1UL << 16) 86 + #define TGT_RING_PAGES (TGT_RING_SIZE >> PAGE_SHIFT) 87 + #define TGT_EVENT_PER_PAGE (PAGE_SIZE / sizeof(struct tgt_event)) 88 + #define TGT_MAX_EVENTS (TGT_EVENT_PER_PAGE * TGT_RING_PAGES) 89 + 90 + #endif
+2
include/scsi/scsi_transport_sas.h
··· 73 73 74 74 /* for the list of phys belonging to a port */ 75 75 struct list_head port_siblings; 76 + 77 + struct work_struct reset_work; 76 78 }; 77 79 78 80 #define dev_to_phy(d) \