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: (87 commits)
[SCSI] fusion: fix domain validation loops
[SCSI] qla2xxx: fix regression on sparc64
[SCSI] modalias for scsi devices
[SCSI] sg: cap reserved_size values at max_sectors
[SCSI] BusLogic: stop using check_region
[SCSI] tgt: fix rdma transfer bugs
[SCSI] aacraid: fix aacraid not finding device
[SCSI] aacraid: Correct SMC products in aacraid.txt
[SCSI] scsi_error.c: Add EH Start Unit retry
[SCSI] aacraid: [Fastboot] Panics for AACRAID driver during 'insmod' for kexec test.
[SCSI] ipr: Driver version to 2.3.2
[SCSI] ipr: Faster sg list fetch
[SCSI] ipr: Return better qc_issue errors
[SCSI] ipr: Disrupt device error
[SCSI] ipr: Improve async error logging level control
[SCSI] ipr: PCI unblock config access fix
[SCSI] ipr: Fix for oops following SATA request sense
[SCSI] ipr: Log error for SAS dual path switch
[SCSI] ipr: Enable logging of debug error data for all devices
[SCSI] ipr: Add new PCI-E IDs to device table
...

+1990 -1659
+7
Documentation/scsi/aacraid.txt
··· 37 37 9005:0286:9005:029d Adaptec 2420SA (Intruder HP release) 38 38 9005:0286:9005:02ac Adaptec 1800 (Typhoon44) 39 39 9005:0285:9005:02b5 Adaptec 5445 (Voodoo44) 40 + 9005:0285:15d9:02b5 SMC AOC-USAS-S4i 41 + 9005:0285:15d9:02c9 SMC AOC-USAS-S4iR 40 42 9005:0285:9005:02b6 Adaptec 5805 (Voodoo80) 43 + 9005:0285:15d9:02b6 SMC AOC-USAS-S8i 44 + 9005:0285:15d9:02ca SMC AOC-USAS-S8iR 41 45 9005:0285:9005:02b7 Adaptec 5085 (Voodoo08) 42 46 9005:0285:9005:02bb Adaptec 3405 (Marauder40LP) 43 47 9005:0285:9005:02bc Adaptec 3805 (Marauder80LP) ··· 97 93 9005:0286:9005:02ae (Aurora Lite ARK) 98 94 9005:0285:9005:02b0 (Sunrise Lake ARK) 99 95 9005:0285:9005:02b1 Adaptec (Voodoo 8 internal 8 external) 96 + 9005:0285:108e:7aac SUN STK RAID REM (Voodoo44 Coyote) 97 + 9005:0285:108e:0286 SUN SG-XPCIESAS-R-IN (Cougar) 98 + 9005:0285:108e:0287 SUN SG-XPCIESAS-R-EX (Prometheus) 100 99 101 100 People 102 101 -------------------------
-5
Documentation/scsi/ncr53c8xx.txt
··· 562 562 support by the driver of this feature at linux start-up and enable 563 563 this feature after boot-up only for devices that support it safely. 564 564 565 - CONFIG_SCSI_NCR53C8XX_PROFILE_SUPPORT (default answer: n) 566 - This option must be set for profiling information to be gathered 567 - and printed out through the proc file system. This features may 568 - impact performances. 569 - 570 565 CONFIG_SCSI_NCR53C8XX_IOMAPPED (default answer: n) 571 566 Answer "y" if you suspect your mother board to not allow memory mapped I/O. 572 567 May slow down performance a little. This option is required by
+2
block/ll_rw_blk.c
··· 1925 1925 blk_queue_max_hw_segments(q, MAX_HW_SEGMENTS); 1926 1926 blk_queue_max_phys_segments(q, MAX_PHYS_SEGMENTS); 1927 1927 1928 + q->sg_reserved_size = INT_MAX; 1929 + 1928 1930 /* 1929 1931 * all done 1930 1932 */
+3 -1
block/scsi_ioctl.c
··· 78 78 79 79 static int sg_get_reserved_size(request_queue_t *q, int __user *p) 80 80 { 81 - return put_user(q->sg_reserved_size, p); 81 + unsigned val = min(q->sg_reserved_size, q->max_sectors << 9); 82 + 83 + return put_user(val, p); 82 84 } 83 85 84 86 static int sg_set_reserved_size(request_queue_t *q, int __user *p)
+1 -1
drivers/infiniband/ulp/iser/iser_initiator.c
··· 201 201 * what's common for both schemes is that the connection is not started 202 202 */ 203 203 if (conn->c_stage != ISCSI_CONN_STARTED) 204 - rx_data_size = DEFAULT_MAX_RECV_DATA_SEGMENT_LENGTH; 204 + rx_data_size = ISCSI_DEF_MAX_RECV_SEG_LEN; 205 205 else /* FIXME till user space sets conn->max_recv_dlength correctly */ 206 206 rx_data_size = 128; 207 207
+11 -16
drivers/message/fusion/mptbase.c
··· 1531 1531 MPT_ADAPTER *ioc = pci_get_drvdata(pdev); 1532 1532 u32 device_state = pdev->current_state; 1533 1533 int recovery_state; 1534 + int err; 1534 1535 1535 1536 printk(MYIOC_s_INFO_FMT 1536 1537 "pci-resume: pdev=0x%p, slot=%s, Previous operating state [D%d]\n", ··· 1539 1538 1540 1539 pci_set_power_state(pdev, 0); 1541 1540 pci_restore_state(pdev); 1542 - pci_enable_device(pdev); 1541 + err = pci_enable_device(pdev); 1542 + if (err) 1543 + return err; 1543 1544 1544 1545 /* enable interrupts */ 1545 1546 CHIPREG_WRITE32(&ioc->chip->IntMask, MPI_HIM_DIM); ··· 4742 4739 } 4743 4740 4744 4741 /** 4745 - * mpt_inactive_raid_list_free 4746 - * 4747 - * This clears this link list. 4748 - * 4749 - * @ioc - pointer to per adapter structure 4750 - * 4742 + * mpt_inactive_raid_list_free - This clears this link list. 4743 + * @ioc : pointer to per adapter structure 4751 4744 **/ 4752 4745 static void 4753 4746 mpt_inactive_raid_list_free(MPT_ADAPTER *ioc) ··· 4763 4764 } 4764 4765 4765 4766 /** 4766 - * mpt_inactive_raid_volumes 4767 + * mpt_inactive_raid_volumes - sets up link list of phy_disk_nums for devices belonging in an inactive volume 4767 4768 * 4768 - * This sets up link list of phy_disk_nums for devices belonging in an inactive volume 4769 - * 4770 - * @ioc - pointer to per adapter structure 4771 - * @channel - volume channel 4772 - * @id - volume target id 4773 - * 4774 - * 4769 + * @ioc : pointer to per adapter structure 4770 + * @channel : volume channel 4771 + * @id : volume target id 4775 4772 **/ 4776 4773 static void 4777 4774 mpt_inactive_raid_volumes(MPT_ADAPTER *ioc, u8 channel, u8 id) ··· 6658 6663 /** 6659 6664 * mpt_iocstatus_info_config - IOCSTATUS information for config pages 6660 6665 * @ioc: Pointer to MPT_ADAPTER structure 6661 - * ioc_status: U32 IOCStatus word from IOC 6666 + * @ioc_status: U32 IOCStatus word from IOC 6662 6667 * @mf: Pointer to MPT request frame 6663 6668 * 6664 6669 * Refer to lsi/mpi.h.
+1
drivers/message/fusion/mptbase.h
··· 994 994 int scandv_wait_done; 995 995 long last_queue_full; 996 996 u16 tm_iocstatus; 997 + u16 spi_pending; 997 998 struct list_head target_reset_list; 998 999 } MPT_SCSI_HOST; 999 1000
+12 -23
drivers/message/fusion/mptscsih.c
··· 819 819 sc->resid=0; 820 820 case MPI_IOCSTATUS_SCSI_RECOVERED_ERROR: /* 0x0040 */ 821 821 case MPI_IOCSTATUS_SUCCESS: /* 0x0000 */ 822 - if (scsi_status == MPI_SCSI_STATUS_BUSY) 823 - sc->result = (DID_BUS_BUSY << 16) | scsi_status; 824 - else 825 - sc->result = (DID_OK << 16) | scsi_status; 822 + sc->result = (DID_OK << 16) | scsi_status; 826 823 if (scsi_state == 0) { 827 824 ; 828 825 } else if (scsi_state & MPI_SCSI_STATE_AUTOSENSE_VALID) { ··· 1185 1188 int 1186 1189 mptscsih_resume(struct pci_dev *pdev) 1187 1190 { 1188 - MPT_ADAPTER *ioc = pci_get_drvdata(pdev); 1189 - struct Scsi_Host *host = ioc->sh; 1190 - MPT_SCSI_HOST *hd; 1191 - 1192 - mpt_resume(pdev); 1193 - 1194 - if(!host) 1195 - return 0; 1196 - 1197 - hd = (MPT_SCSI_HOST *)host->hostdata; 1198 - if(!hd) 1199 - return 0; 1200 - 1201 - return 0; 1191 + return mpt_resume(pdev); 1202 1192 } 1203 1193 1204 1194 #endif ··· 1521 1537 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1522 1538 /** 1523 1539 * mptscsih_TMHandler - Generic handler for SCSI Task Management. 1524 - * Fall through to mpt_HardResetHandler if: not operational, too many 1525 - * failed TM requests or handshake failure. 1526 - * 1527 - * @ioc: Pointer to MPT_ADAPTER structure 1540 + * @hd: Pointer to MPT SCSI HOST structure 1528 1541 * @type: Task Management type 1542 + * @channel: channel number for task management 1529 1543 * @id: Logical Target ID for reset (if appropriate) 1530 1544 * @lun: Logical Unit for reset (if appropriate) 1531 1545 * @ctx2abort: Context for the task to be aborted (if appropriate) 1546 + * @timeout: timeout for task management control 1547 + * 1548 + * Fall through to mpt_HardResetHandler if: not operational, too many 1549 + * failed TM requests or handshake failure. 1532 1550 * 1533 1551 * Remark: Currently invoked from a non-interrupt thread (_bh). 1534 1552 * 1535 1553 * Remark: With old EH code, at most 1 SCSI TaskMgmt function per IOC 1536 1554 * will be active. 1537 1555 * 1538 - * Returns 0 for SUCCESS, or FAILED. 1556 + * Returns 0 for SUCCESS, or %FAILED. 1539 1557 **/ 1540 1558 int 1541 1559 mptscsih_TMHandler(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 id, int lun, int ctx2abort, ulong timeout) ··· 1636 1650 * mptscsih_IssueTaskMgmt - Generic send Task Management function. 1637 1651 * @hd: Pointer to MPT_SCSI_HOST structure 1638 1652 * @type: Task Management type 1653 + * @channel: channel number for task management 1639 1654 * @id: Logical Target ID for reset (if appropriate) 1640 1655 * @lun: Logical Unit for reset (if appropriate) 1641 1656 * @ctx2abort: Context for the task to be aborted (if appropriate) 1657 + * @timeout: timeout for task management control 1642 1658 * 1643 1659 * Remark: _HardResetHandler can be invoked from an interrupt thread (timer) 1644 1660 * or a non-interrupt thread. In the former, must not call schedule(). ··· 2010 2022 /** 2011 2023 * mptscsih_tm_wait_for_completion - wait for completion of TM task 2012 2024 * @hd: Pointer to MPT host structure. 2025 + * @timeout: timeout value 2013 2026 * 2014 2027 * Returns {SUCCESS,FAILED}. 2015 2028 */
+27 -9
drivers/message/fusion/mptspi.c
··· 96 96 static int mptspiInternalCtx = -1; /* Used only for internal commands */ 97 97 98 98 /** 99 - * mptspi_setTargetNegoParms - Update the target negotiation 100 - * parameters based on the the Inquiry data, adapter capabilities, 101 - * and NVRAM settings 102 - * 99 + * mptspi_setTargetNegoParms - Update the target negotiation parameters 103 100 * @hd: Pointer to a SCSI Host Structure 104 - * @vtarget: per target private data 101 + * @target: per target private data 105 102 * @sdev: SCSI device 106 103 * 104 + * Update the target negotiation parameters based on the the Inquiry 105 + * data, adapter capabilities, and NVRAM settings. 107 106 **/ 108 107 static void 109 108 mptspi_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtTarget *target, ··· 233 234 /** 234 235 * mptspi_writeIOCPage4 - write IOC Page 4 235 236 * @hd: Pointer to a SCSI Host Structure 236 - * @channel: 237 + * @channel: channel number 237 238 * @id: write IOC Page4 for this ID & Bus 238 239 * 239 240 * Return: -EAGAIN if unable to obtain a Message Frame ··· 445 446 return 0; 446 447 } 447 448 448 - void 449 + static void 449 450 mptspi_target_destroy(struct scsi_target *starget) 450 451 { 451 452 if (starget->hostdata) ··· 676 677 return; 677 678 } 678 679 680 + hd->spi_pending |= (1 << sdev->id); 679 681 spi_dv_device(sdev); 682 + hd->spi_pending &= ~(1 << sdev->id); 680 683 681 684 if (sdev->channel == 1 && 682 685 mptscsih_quiesce_raid(hd, 0, vtarget->channel, vtarget->id) < 0) ··· 1204 1203 container_of(work, struct work_queue_wrapper, work); 1205 1204 struct _MPT_SCSI_HOST *hd = wqw->hd; 1206 1205 struct scsi_device *sdev; 1206 + struct scsi_target *starget; 1207 + struct _CONFIG_PAGE_SCSI_DEVICE_1 pg1; 1208 + u32 nego; 1207 1209 1208 1210 kfree(wqw); 1209 1211 1210 - shost_for_each_device(sdev, hd->ioc->sh) 1211 - mptspi_dv_device(hd, sdev); 1212 + if (hd->spi_pending) { 1213 + shost_for_each_device(sdev, hd->ioc->sh) { 1214 + if (hd->spi_pending & (1 << sdev->id)) 1215 + continue; 1216 + starget = scsi_target(sdev); 1217 + nego = mptspi_getRP(starget); 1218 + pg1.RequestedParameters = cpu_to_le32(nego); 1219 + pg1.Reserved = 0; 1220 + pg1.Configuration = 0; 1221 + mptspi_write_spi_device_pg1(starget, &pg1); 1222 + } 1223 + } else { 1224 + shost_for_each_device(sdev, hd->ioc->sh) 1225 + mptspi_dv_device(hd, sdev); 1226 + } 1212 1227 } 1213 1228 1214 1229 static void ··· 1470 1453 init_waitqueue_head(&hd->scandv_waitq); 1471 1454 hd->scandv_wait_done = 0; 1472 1455 hd->last_queue_full = 0; 1456 + hd->spi_pending = 0; 1473 1457 1474 1458 /* Some versions of the firmware don't support page 0; without 1475 1459 * that we can't get the parameters */
+1 -1
drivers/s390/scsi/zfcp_erp.c
··· 186 186 { 187 187 fsf_req->timer.function = zfcp_fsf_request_timeout_handler; 188 188 fsf_req->timer.data = (unsigned long) fsf_req->adapter; 189 - fsf_req->timer.expires = timeout; 189 + fsf_req->timer.expires = jiffies + timeout; 190 190 add_timer(&fsf_req->timer); 191 191 } 192 192
+6 -4
drivers/s390/scsi/zfcp_fsf.c
··· 299 299 } 300 300 301 301 /* log additional information provided by FSF (if any) */ 302 - if (unlikely(qtcb->header.log_length)) { 302 + if (likely(qtcb->header.log_length)) { 303 303 /* do not trust them ;-) */ 304 - if (qtcb->header.log_start > sizeof(struct fsf_qtcb)) { 304 + if (unlikely(qtcb->header.log_start > 305 + sizeof(struct fsf_qtcb))) { 305 306 ZFCP_LOG_NORMAL 306 307 ("bug: ULP (FSF logging) log data starts " 307 308 "beyond end of packet header. Ignored. " ··· 311 310 sizeof(struct fsf_qtcb)); 312 311 goto forget_log; 313 312 } 314 - if ((size_t) (qtcb->header.log_start + qtcb->header.log_length) 315 - > sizeof(struct fsf_qtcb)) { 313 + if (unlikely((size_t) (qtcb->header.log_start + 314 + qtcb->header.log_length) > 315 + sizeof(struct fsf_qtcb))) { 316 316 ZFCP_LOG_NORMAL("bug: ULP (FSF logging) log data ends " 317 317 "beyond end of packet header. Ignored. " 318 318 "(start=%i, length=%i, size=%li)\n",
+48 -25
drivers/scsi/BusLogic.c
··· 579 579 /* 580 580 Append the list of standard BusLogic MultiMaster ISA I/O Addresses. 581 581 */ 582 - if (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe330 : check_region(0x330, BusLogic_MultiMasterAddressCount) == 0) 582 + if (!BusLogic_ProbeOptions.LimitedProbeISA || BusLogic_ProbeOptions.Probe330) 583 583 BusLogic_AppendProbeAddressISA(0x330); 584 - if (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe334 : check_region(0x334, BusLogic_MultiMasterAddressCount) == 0) 584 + if (!BusLogic_ProbeOptions.LimitedProbeISA || BusLogic_ProbeOptions.Probe334) 585 585 BusLogic_AppendProbeAddressISA(0x334); 586 - if (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe230 : check_region(0x230, BusLogic_MultiMasterAddressCount) == 0) 586 + if (!BusLogic_ProbeOptions.LimitedProbeISA || BusLogic_ProbeOptions.Probe230) 587 587 BusLogic_AppendProbeAddressISA(0x230); 588 - if (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe234 : check_region(0x234, BusLogic_MultiMasterAddressCount) == 0) 588 + if (!BusLogic_ProbeOptions.LimitedProbeISA || BusLogic_ProbeOptions.Probe234) 589 589 BusLogic_AppendProbeAddressISA(0x234); 590 - if (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe130 : check_region(0x130, BusLogic_MultiMasterAddressCount) == 0) 590 + if (!BusLogic_ProbeOptions.LimitedProbeISA || BusLogic_ProbeOptions.Probe130) 591 591 BusLogic_AppendProbeAddressISA(0x130); 592 - if (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe134 : check_region(0x134, BusLogic_MultiMasterAddressCount) == 0) 592 + if (!BusLogic_ProbeOptions.LimitedProbeISA || BusLogic_ProbeOptions.Probe134) 593 593 BusLogic_AppendProbeAddressISA(0x134); 594 594 } 595 595 ··· 795 795 host adapters are probed. 796 796 */ 797 797 if (!BusLogic_ProbeOptions.NoProbeISA) 798 - if (PrimaryProbeInfo->IO_Address == 0 && (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe330 : check_region(0x330, BusLogic_MultiMasterAddressCount) == 0)) { 798 + if (PrimaryProbeInfo->IO_Address == 0 && 799 + (!BusLogic_ProbeOptions.LimitedProbeISA || 800 + BusLogic_ProbeOptions.Probe330)) { 799 801 PrimaryProbeInfo->HostAdapterType = BusLogic_MultiMaster; 800 802 PrimaryProbeInfo->HostAdapterBusType = BusLogic_ISA_Bus; 801 803 PrimaryProbeInfo->IO_Address = 0x330; ··· 807 805 omitting the Primary I/O Address which has already been handled. 808 806 */ 809 807 if (!BusLogic_ProbeOptions.NoProbeISA) { 810 - if (!StandardAddressSeen[1] && (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe334 : check_region(0x334, BusLogic_MultiMasterAddressCount) == 0)) 808 + if (!StandardAddressSeen[1] && 809 + (!BusLogic_ProbeOptions.LimitedProbeISA || 810 + BusLogic_ProbeOptions.Probe334)) 811 811 BusLogic_AppendProbeAddressISA(0x334); 812 - if (!StandardAddressSeen[2] && (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe230 : check_region(0x230, BusLogic_MultiMasterAddressCount) == 0)) 812 + if (!StandardAddressSeen[2] && 813 + (!BusLogic_ProbeOptions.LimitedProbeISA || 814 + BusLogic_ProbeOptions.Probe230)) 813 815 BusLogic_AppendProbeAddressISA(0x230); 814 - if (!StandardAddressSeen[3] && (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe234 : check_region(0x234, BusLogic_MultiMasterAddressCount) == 0)) 816 + if (!StandardAddressSeen[3] && 817 + (!BusLogic_ProbeOptions.LimitedProbeISA || 818 + BusLogic_ProbeOptions.Probe234)) 815 819 BusLogic_AppendProbeAddressISA(0x234); 816 - if (!StandardAddressSeen[4] && (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe130 : check_region(0x130, BusLogic_MultiMasterAddressCount) == 0)) 820 + if (!StandardAddressSeen[4] && 821 + (!BusLogic_ProbeOptions.LimitedProbeISA || 822 + BusLogic_ProbeOptions.Probe130)) 817 823 BusLogic_AppendProbeAddressISA(0x130); 818 - if (!StandardAddressSeen[5] && (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe134 : check_region(0x134, BusLogic_MultiMasterAddressCount) == 0)) 824 + if (!StandardAddressSeen[5] && 825 + (!BusLogic_ProbeOptions.LimitedProbeISA || 826 + BusLogic_ProbeOptions.Probe134)) 819 827 BusLogic_AppendProbeAddressISA(0x134); 820 828 } 821 829 /* ··· 2232 2220 HostAdapter->PCI_Device = ProbeInfo->PCI_Device; 2233 2221 HostAdapter->IRQ_Channel = ProbeInfo->IRQ_Channel; 2234 2222 HostAdapter->AddressCount = BusLogic_HostAdapterAddressCount[HostAdapter->HostAdapterType]; 2223 + 2224 + /* 2225 + Make sure region is free prior to probing. 2226 + */ 2227 + if (!request_region(HostAdapter->IO_Address, HostAdapter->AddressCount, 2228 + "BusLogic")) 2229 + continue; 2235 2230 /* 2236 2231 Probe the Host Adapter. If unsuccessful, abort further initialization. 2237 2232 */ 2238 - if (!BusLogic_ProbeHostAdapter(HostAdapter)) 2233 + if (!BusLogic_ProbeHostAdapter(HostAdapter)) { 2234 + release_region(HostAdapter->IO_Address, HostAdapter->AddressCount); 2239 2235 continue; 2236 + } 2240 2237 /* 2241 2238 Hard Reset the Host Adapter. If unsuccessful, abort further 2242 2239 initialization. 2243 2240 */ 2244 - if (!BusLogic_HardwareResetHostAdapter(HostAdapter, true)) 2241 + if (!BusLogic_HardwareResetHostAdapter(HostAdapter, true)) { 2242 + release_region(HostAdapter->IO_Address, HostAdapter->AddressCount); 2245 2243 continue; 2244 + } 2246 2245 /* 2247 2246 Check the Host Adapter. If unsuccessful, abort further initialization. 2248 2247 */ 2249 - if (!BusLogic_CheckHostAdapter(HostAdapter)) 2248 + if (!BusLogic_CheckHostAdapter(HostAdapter)) { 2249 + release_region(HostAdapter->IO_Address, HostAdapter->AddressCount); 2250 2250 continue; 2251 + } 2251 2252 /* 2252 2253 Initialize the Driver Options field if provided. 2253 2254 */ ··· 2271 2246 and Electronic Mail Address. 2272 2247 */ 2273 2248 BusLogic_AnnounceDriver(HostAdapter); 2274 - /* 2275 - Register usage of the I/O Address range. From this point onward, any 2276 - failure will be assumed to be due to a problem with the Host Adapter, 2277 - rather than due to having mistakenly identified this port as belonging 2278 - to a BusLogic Host Adapter. The I/O Address range will not be 2279 - released, thereby preventing it from being incorrectly identified as 2280 - any other type of Host Adapter. 2281 - */ 2282 - if (!request_region(HostAdapter->IO_Address, HostAdapter->AddressCount, "BusLogic")) 2283 - continue; 2284 2249 /* 2285 2250 Register the SCSI Host structure. 2286 2251 */ ··· 2295 2280 Acquire the System Resources necessary to use the Host Adapter, then 2296 2281 Create the Initial CCBs, Initialize the Host Adapter, and finally 2297 2282 perform Target Device Inquiry. 2283 + 2284 + From this point onward, any failure will be assumed to be due to a 2285 + problem with the Host Adapter, rather than due to having mistakenly 2286 + identified this port as belonging to a BusLogic Host Adapter. The 2287 + I/O Address range will not be released, thereby preventing it from 2288 + being incorrectly identified as any other type of Host Adapter. 2298 2289 */ 2299 2290 if (BusLogic_ReadHostAdapterConfiguration(HostAdapter) && 2300 2291 BusLogic_ReportHostAdapterConfiguration(HostAdapter) && ··· 3619 3598 3620 3599 __setup("BusLogic=", BusLogic_Setup); 3621 3600 3601 + #ifdef MODULE 3622 3602 static struct pci_device_id BusLogic_pci_tbl[] __devinitdata = { 3623 3603 { PCI_VENDOR_ID_BUSLOGIC, PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER, 3624 3604 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, ··· 3629 3607 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 3630 3608 { } 3631 3609 }; 3610 + #endif 3632 3611 MODULE_DEVICE_TABLE(pci, BusLogic_pci_tbl); 3633 3612 3634 3613 module_init(BusLogic_init);
+6 -16
drivers/scsi/Kconfig
··· 241 241 You can override this choice by specifying "scsi_mod.scan=sync" 242 242 or async on the kernel's command line. 243 243 244 + config SCSI_WAIT_SCAN 245 + tristate 246 + default m 247 + depends on SCSI 248 + depends on MODULES 249 + 244 250 menu "SCSI Transports" 245 251 depends on SCSI 246 252 ··· 1200 1194 There is no safe option other than using good cabling, right 1201 1195 terminations and SCSI conformant devices. 1202 1196 1203 - config SCSI_NCR53C8XX_PROFILE 1204 - bool "enable profiling" 1205 - depends on SCSI_ZALON || SCSI_NCR_Q720 1206 - help 1207 - This option allows you to enable profiling information gathering. 1208 - These statistics are not very accurate due to the low frequency 1209 - of the kernel clock (100 Hz on i386) and have performance impact 1210 - on systems that use very fast devices. 1211 - 1212 - The normal answer therefore is N. 1213 - 1214 1197 config SCSI_NCR53C8XX_NO_DISCONNECT 1215 1198 bool "not allow targets to disconnect" 1216 1199 depends on (SCSI_ZALON || SCSI_NCR_Q720) && SCSI_NCR53C8XX_DEFAULT_TAGS=0 ··· 1328 1333 This driver for NCR53c710 based SCSI host adapters. 1329 1334 1330 1335 It currently supports Compaq EISA cards and NCR MCA cards 1331 - 1332 - config 53C700_IO_MAPPED 1333 - bool 1334 - depends on SCSI_SIM710 1335 - default y 1336 1336 1337 1337 config SCSI_SYM53C416 1338 1338 tristate "Symbios 53c416 SCSI support"
+1 -1
drivers/scsi/Makefile
··· 146 146 # This goes last, so that "real" scsi devices probe earlier 147 147 obj-$(CONFIG_SCSI_DEBUG) += scsi_debug.o 148 148 149 - obj-$(CONFIG_SCSI) += scsi_wait_scan.o 149 + obj-$(CONFIG_SCSI_WAIT_SCAN) += scsi_wait_scan.o 150 150 151 151 scsi_mod-y += scsi.o hosts.o scsi_ioctl.o constants.o \ 152 152 scsicam.o scsi_error.o scsi_lib.o \
+244 -170
drivers/scsi/aacraid/aachba.c
··· 5 5 * based on the old aacraid driver that is.. 6 6 * Adaptec aacraid device driver for Linux. 7 7 * 8 - * Copyright (c) 2000 Adaptec, Inc. (aacraid@adaptec.com) 8 + * Copyright (c) 2000-2007 Adaptec, Inc. (aacraid@adaptec.com) 9 9 * 10 10 * This program is free software; you can redistribute it and/or modify 11 11 * it under the terms of the GNU General Public License as published by ··· 172 172 int expose_physicals = -1; 173 173 module_param(expose_physicals, int, S_IRUGO|S_IWUSR); 174 174 MODULE_PARM_DESC(expose_physicals, "Expose physical components of the arrays. -1=protect 0=off, 1=on"); 175 + 176 + 177 + static inline int aac_valid_context(struct scsi_cmnd *scsicmd, 178 + struct fib *fibptr) { 179 + struct scsi_device *device; 180 + 181 + if (unlikely(!scsicmd || !scsicmd->scsi_done )) { 182 + dprintk((KERN_WARNING "aac_valid_context: scsi command corrupt\n")) 183 + ; 184 + aac_fib_complete(fibptr); 185 + aac_fib_free(fibptr); 186 + return 0; 187 + } 188 + scsicmd->SCp.phase = AAC_OWNER_MIDLEVEL; 189 + device = scsicmd->device; 190 + if (unlikely(!device || !scsi_device_online(device))) { 191 + dprintk((KERN_WARNING "aac_valid_context: scsi device corrupt\n")); 192 + aac_fib_complete(fibptr); 193 + aac_fib_free(fibptr); 194 + return 0; 195 + } 196 + return 1; 197 + } 198 + 175 199 /** 176 200 * aac_get_config_status - check the adapter configuration 177 201 * @common: adapter to query ··· 282 258 u32 index; 283 259 int status = 0; 284 260 struct fib * fibptr; 285 - unsigned instance; 286 261 struct aac_get_container_count *dinfo; 287 262 struct aac_get_container_count_resp *dresp; 288 263 int maximum_num_containers = MAXIMUM_NUM_CONTAINERS; 289 - 290 - instance = dev->scsi_host_ptr->unique_id; 291 264 292 265 if (!(fibptr = aac_fib_alloc(dev))) 293 266 return -ENOMEM; ··· 305 284 maximum_num_containers = le32_to_cpu(dresp->ContainerSwitchEntries); 306 285 aac_fib_complete(fibptr); 307 286 } 287 + aac_fib_free(fibptr); 308 288 309 289 if (maximum_num_containers < MAXIMUM_NUM_CONTAINERS) 310 290 maximum_num_containers = MAXIMUM_NUM_CONTAINERS; 311 - fsa_dev_ptr = kmalloc( 312 - sizeof(*fsa_dev_ptr) * maximum_num_containers, GFP_KERNEL); 313 - if (!fsa_dev_ptr) { 314 - aac_fib_free(fibptr); 291 + fsa_dev_ptr = kmalloc(sizeof(*fsa_dev_ptr) * maximum_num_containers, 292 + GFP_KERNEL); 293 + if (!fsa_dev_ptr) 315 294 return -ENOMEM; 316 - } 317 295 memset(fsa_dev_ptr, 0, sizeof(*fsa_dev_ptr) * maximum_num_containers); 318 296 319 297 dev->fsa_dev = fsa_dev_ptr; 320 298 dev->maximum_num_containers = maximum_num_containers; 321 299 322 - for (index = 0; index < dev->maximum_num_containers; index++) { 323 - struct aac_query_mount *dinfo; 324 - struct aac_mount *dresp; 325 - 300 + for (index = 0; index < dev->maximum_num_containers; ) { 326 301 fsa_dev_ptr[index].devname[0] = '\0'; 327 302 328 - aac_fib_init(fibptr); 329 - dinfo = (struct aac_query_mount *) fib_data(fibptr); 303 + status = aac_probe_container(dev, index); 330 304 331 - dinfo->command = cpu_to_le32(VM_NameServe); 332 - dinfo->count = cpu_to_le32(index); 333 - dinfo->type = cpu_to_le32(FT_FILESYS); 334 - 335 - status = aac_fib_send(ContainerCommand, 336 - fibptr, 337 - sizeof (struct aac_query_mount), 338 - FsaNormal, 339 - 1, 1, 340 - NULL, NULL); 341 - if (status < 0 ) { 305 + if (status < 0) { 342 306 printk(KERN_WARNING "aac_get_containers: SendFIB failed.\n"); 343 307 break; 344 308 } 345 - dresp = (struct aac_mount *)fib_data(fibptr); 346 309 347 - if ((le32_to_cpu(dresp->status) == ST_OK) && 348 - (le32_to_cpu(dresp->mnt[0].vol) == CT_NONE)) { 349 - dinfo->command = cpu_to_le32(VM_NameServe64); 350 - dinfo->count = cpu_to_le32(index); 351 - dinfo->type = cpu_to_le32(FT_FILESYS); 352 - 353 - if (aac_fib_send(ContainerCommand, 354 - fibptr, 355 - sizeof(struct aac_query_mount), 356 - FsaNormal, 357 - 1, 1, 358 - NULL, NULL) < 0) 359 - continue; 360 - } else 361 - dresp->mnt[0].capacityhigh = 0; 362 - 363 - dprintk ((KERN_DEBUG 364 - "VM_NameServe cid=%d status=%d vol=%d state=%d cap=%llu\n", 365 - (int)index, (int)le32_to_cpu(dresp->status), 366 - (int)le32_to_cpu(dresp->mnt[0].vol), 367 - (int)le32_to_cpu(dresp->mnt[0].state), 368 - ((u64)le32_to_cpu(dresp->mnt[0].capacity)) + 369 - (((u64)le32_to_cpu(dresp->mnt[0].capacityhigh)) << 32))); 370 - if ((le32_to_cpu(dresp->status) == ST_OK) && 371 - (le32_to_cpu(dresp->mnt[0].vol) != CT_NONE) && 372 - (le32_to_cpu(dresp->mnt[0].state) != FSCS_HIDDEN)) { 373 - fsa_dev_ptr[index].valid = 1; 374 - fsa_dev_ptr[index].type = le32_to_cpu(dresp->mnt[0].vol); 375 - fsa_dev_ptr[index].size 376 - = ((u64)le32_to_cpu(dresp->mnt[0].capacity)) + 377 - (((u64)le32_to_cpu(dresp->mnt[0].capacityhigh)) << 32); 378 - if (le32_to_cpu(dresp->mnt[0].state) & FSCS_READONLY) 379 - fsa_dev_ptr[index].ro = 1; 380 - } 381 - aac_fib_complete(fibptr); 382 310 /* 383 311 * If there are no more containers, then stop asking. 384 312 */ 385 - if ((index + 1) >= le32_to_cpu(dresp->count)){ 313 + if (++index >= status) 386 314 break; 387 - } 388 315 } 389 - aac_fib_free(fibptr); 390 316 return status; 391 317 } 392 318 ··· 350 382 buf = scsicmd->request_buffer; 351 383 transfer_len = min(scsicmd->request_bufflen, len + offset); 352 384 } 353 - 354 - memcpy(buf + offset, data, transfer_len - offset); 385 + transfer_len -= offset; 386 + if (buf && transfer_len) 387 + memcpy(buf + offset, data, transfer_len); 355 388 356 389 if (scsicmd->use_sg) 357 390 kunmap_atomic(buf - sg->offset, KM_IRQ0); ··· 365 396 struct scsi_cmnd * scsicmd; 366 397 367 398 scsicmd = (struct scsi_cmnd *) context; 368 - scsicmd->SCp.phase = AAC_OWNER_MIDLEVEL; 399 + 400 + if (!aac_valid_context(scsicmd, fibptr)) 401 + return; 369 402 370 403 dprintk((KERN_DEBUG "get_container_name_callback[cpu %d]: t = %ld.\n", smp_processor_id(), jiffies)); 371 404 BUG_ON(fibptr == NULL); ··· 402 431 /** 403 432 * aac_get_container_name - get container name, none blocking. 404 433 */ 405 - static int aac_get_container_name(struct scsi_cmnd * scsicmd, int cid) 434 + static int aac_get_container_name(struct scsi_cmnd * scsicmd) 406 435 { 407 436 int status; 408 437 struct aac_get_name *dinfo; ··· 419 448 420 449 dinfo->command = cpu_to_le32(VM_ContainerConfig); 421 450 dinfo->type = cpu_to_le32(CT_READ_NAME); 422 - dinfo->cid = cpu_to_le32(cid); 451 + dinfo->cid = cpu_to_le32(scmd_id(scsicmd)); 423 452 dinfo->count = cpu_to_le32(sizeof(((struct aac_get_name_resp *)NULL)->data)); 424 453 425 454 status = aac_fib_send(ContainerCommand, ··· 444 473 return -1; 445 474 } 446 475 476 + static int aac_probe_container_callback2(struct scsi_cmnd * scsicmd) 477 + { 478 + struct fsa_dev_info *fsa_dev_ptr = ((struct aac_dev *)(scsicmd->device->host->hostdata))->fsa_dev; 479 + 480 + if (fsa_dev_ptr[scmd_id(scsicmd)].valid) 481 + return aac_scsi_cmd(scsicmd); 482 + 483 + scsicmd->result = DID_NO_CONNECT << 16; 484 + scsicmd->scsi_done(scsicmd); 485 + return 0; 486 + } 487 + 488 + static int _aac_probe_container2(void * context, struct fib * fibptr) 489 + { 490 + struct fsa_dev_info *fsa_dev_ptr; 491 + int (*callback)(struct scsi_cmnd *); 492 + struct scsi_cmnd * scsicmd = (struct scsi_cmnd *)context; 493 + 494 + if (!aac_valid_context(scsicmd, fibptr)) 495 + return 0; 496 + 497 + fsa_dev_ptr = ((struct aac_dev *)(scsicmd->device->host->hostdata))->fsa_dev; 498 + 499 + scsicmd->SCp.Status = 0; 500 + if (fsa_dev_ptr) { 501 + struct aac_mount * dresp = (struct aac_mount *) fib_data(fibptr); 502 + fsa_dev_ptr += scmd_id(scsicmd); 503 + 504 + if ((le32_to_cpu(dresp->status) == ST_OK) && 505 + (le32_to_cpu(dresp->mnt[0].vol) != CT_NONE) && 506 + (le32_to_cpu(dresp->mnt[0].state) != FSCS_HIDDEN)) { 507 + fsa_dev_ptr->valid = 1; 508 + fsa_dev_ptr->type = le32_to_cpu(dresp->mnt[0].vol); 509 + fsa_dev_ptr->size 510 + = ((u64)le32_to_cpu(dresp->mnt[0].capacity)) + 511 + (((u64)le32_to_cpu(dresp->mnt[0].capacityhigh)) << 32); 512 + fsa_dev_ptr->ro = ((le32_to_cpu(dresp->mnt[0].state) & FSCS_READONLY) != 0); 513 + } 514 + if ((fsa_dev_ptr->valid & 1) == 0) 515 + fsa_dev_ptr->valid = 0; 516 + scsicmd->SCp.Status = le32_to_cpu(dresp->count); 517 + } 518 + aac_fib_complete(fibptr); 519 + aac_fib_free(fibptr); 520 + callback = (int (*)(struct scsi_cmnd *))(scsicmd->SCp.ptr); 521 + scsicmd->SCp.ptr = NULL; 522 + return (*callback)(scsicmd); 523 + } 524 + 525 + static int _aac_probe_container1(void * context, struct fib * fibptr) 526 + { 527 + struct scsi_cmnd * scsicmd; 528 + struct aac_mount * dresp; 529 + struct aac_query_mount *dinfo; 530 + int status; 531 + 532 + dresp = (struct aac_mount *) fib_data(fibptr); 533 + dresp->mnt[0].capacityhigh = 0; 534 + if ((le32_to_cpu(dresp->status) != ST_OK) || 535 + (le32_to_cpu(dresp->mnt[0].vol) != CT_NONE)) 536 + return _aac_probe_container2(context, fibptr); 537 + scsicmd = (struct scsi_cmnd *) context; 538 + scsicmd->SCp.phase = AAC_OWNER_MIDLEVEL; 539 + 540 + if (!aac_valid_context(scsicmd, fibptr)) 541 + return 0; 542 + 543 + aac_fib_init(fibptr); 544 + 545 + dinfo = (struct aac_query_mount *)fib_data(fibptr); 546 + 547 + dinfo->command = cpu_to_le32(VM_NameServe64); 548 + dinfo->count = cpu_to_le32(scmd_id(scsicmd)); 549 + dinfo->type = cpu_to_le32(FT_FILESYS); 550 + 551 + status = aac_fib_send(ContainerCommand, 552 + fibptr, 553 + sizeof(struct aac_query_mount), 554 + FsaNormal, 555 + 0, 1, 556 + (fib_callback) _aac_probe_container2, 557 + (void *) scsicmd); 558 + /* 559 + * Check that the command queued to the controller 560 + */ 561 + if (status == -EINPROGRESS) { 562 + scsicmd->SCp.phase = AAC_OWNER_FIRMWARE; 563 + return 0; 564 + } 565 + if (status < 0) { 566 + /* Inherit results from VM_NameServe, if any */ 567 + dresp->status = cpu_to_le32(ST_OK); 568 + return _aac_probe_container2(context, fibptr); 569 + } 570 + return 0; 571 + } 572 + 573 + static int _aac_probe_container(struct scsi_cmnd * scsicmd, int (*callback)(struct scsi_cmnd *)) 574 + { 575 + struct fib * fibptr; 576 + int status = -ENOMEM; 577 + 578 + if ((fibptr = aac_fib_alloc((struct aac_dev *)scsicmd->device->host->hostdata))) { 579 + struct aac_query_mount *dinfo; 580 + 581 + aac_fib_init(fibptr); 582 + 583 + dinfo = (struct aac_query_mount *)fib_data(fibptr); 584 + 585 + dinfo->command = cpu_to_le32(VM_NameServe); 586 + dinfo->count = cpu_to_le32(scmd_id(scsicmd)); 587 + dinfo->type = cpu_to_le32(FT_FILESYS); 588 + scsicmd->SCp.ptr = (char *)callback; 589 + 590 + status = aac_fib_send(ContainerCommand, 591 + fibptr, 592 + sizeof(struct aac_query_mount), 593 + FsaNormal, 594 + 0, 1, 595 + (fib_callback) _aac_probe_container1, 596 + (void *) scsicmd); 597 + /* 598 + * Check that the command queued to the controller 599 + */ 600 + if (status == -EINPROGRESS) { 601 + scsicmd->SCp.phase = AAC_OWNER_FIRMWARE; 602 + return 0; 603 + } 604 + if (status < 0) { 605 + scsicmd->SCp.ptr = NULL; 606 + aac_fib_complete(fibptr); 607 + aac_fib_free(fibptr); 608 + } 609 + } 610 + if (status < 0) { 611 + struct fsa_dev_info *fsa_dev_ptr = ((struct aac_dev *)(scsicmd->device->host->hostdata))->fsa_dev; 612 + if (fsa_dev_ptr) { 613 + fsa_dev_ptr += scmd_id(scsicmd); 614 + if ((fsa_dev_ptr->valid & 1) == 0) { 615 + fsa_dev_ptr->valid = 0; 616 + return (*callback)(scsicmd); 617 + } 618 + } 619 + } 620 + return status; 621 + } 622 + 447 623 /** 448 624 * aac_probe_container - query a logical volume 449 625 * @dev: device to query ··· 599 481 * Queries the controller about the given volume. The volume information 600 482 * is updated in the struct fsa_dev_info structure rather than returned. 601 483 */ 602 - 484 + static int aac_probe_container_callback1(struct scsi_cmnd * scsicmd) 485 + { 486 + scsicmd->device = NULL; 487 + return 0; 488 + } 489 + 603 490 int aac_probe_container(struct aac_dev *dev, int cid) 604 491 { 605 - struct fsa_dev_info *fsa_dev_ptr; 492 + struct scsi_cmnd *scsicmd = kmalloc(sizeof(*scsicmd), GFP_KERNEL); 493 + struct scsi_device *scsidev = kmalloc(sizeof(*scsidev), GFP_KERNEL); 606 494 int status; 607 - struct aac_query_mount *dinfo; 608 - struct aac_mount *dresp; 609 - struct fib * fibptr; 610 - unsigned instance; 611 495 612 - fsa_dev_ptr = dev->fsa_dev; 613 - if (!fsa_dev_ptr) 496 + if (!scsicmd || !scsidev) { 497 + kfree(scsicmd); 498 + kfree(scsidev); 614 499 return -ENOMEM; 615 - instance = dev->scsi_host_ptr->unique_id; 616 - 617 - if (!(fibptr = aac_fib_alloc(dev))) 618 - return -ENOMEM; 619 - 620 - aac_fib_init(fibptr); 621 - 622 - dinfo = (struct aac_query_mount *)fib_data(fibptr); 623 - 624 - dinfo->command = cpu_to_le32(VM_NameServe); 625 - dinfo->count = cpu_to_le32(cid); 626 - dinfo->type = cpu_to_le32(FT_FILESYS); 627 - 628 - status = aac_fib_send(ContainerCommand, 629 - fibptr, 630 - sizeof(struct aac_query_mount), 631 - FsaNormal, 632 - 1, 1, 633 - NULL, NULL); 634 - if (status < 0) { 635 - printk(KERN_WARNING "aacraid: aac_probe_container query failed.\n"); 636 - goto error; 637 500 } 501 + scsicmd->list.next = NULL; 502 + scsicmd->scsi_done = (void (*)(struct scsi_cmnd*))_aac_probe_container1; 638 503 639 - dresp = (struct aac_mount *) fib_data(fibptr); 504 + scsicmd->device = scsidev; 505 + scsidev->sdev_state = 0; 506 + scsidev->id = cid; 507 + scsidev->host = dev->scsi_host_ptr; 640 508 641 - if ((le32_to_cpu(dresp->status) == ST_OK) && 642 - (le32_to_cpu(dresp->mnt[0].vol) == CT_NONE)) { 643 - dinfo->command = cpu_to_le32(VM_NameServe64); 644 - dinfo->count = cpu_to_le32(cid); 645 - dinfo->type = cpu_to_le32(FT_FILESYS); 646 - 647 - if (aac_fib_send(ContainerCommand, 648 - fibptr, 649 - sizeof(struct aac_query_mount), 650 - FsaNormal, 651 - 1, 1, 652 - NULL, NULL) < 0) 653 - goto error; 654 - } else 655 - dresp->mnt[0].capacityhigh = 0; 656 - 657 - if ((le32_to_cpu(dresp->status) == ST_OK) && 658 - (le32_to_cpu(dresp->mnt[0].vol) != CT_NONE) && 659 - (le32_to_cpu(dresp->mnt[0].state) != FSCS_HIDDEN)) { 660 - fsa_dev_ptr[cid].valid = 1; 661 - fsa_dev_ptr[cid].type = le32_to_cpu(dresp->mnt[0].vol); 662 - fsa_dev_ptr[cid].size 663 - = ((u64)le32_to_cpu(dresp->mnt[0].capacity)) + 664 - (((u64)le32_to_cpu(dresp->mnt[0].capacityhigh)) << 32); 665 - if (le32_to_cpu(dresp->mnt[0].state) & FSCS_READONLY) 666 - fsa_dev_ptr[cid].ro = 1; 667 - } 668 - 669 - error: 670 - aac_fib_complete(fibptr); 671 - aac_fib_free(fibptr); 672 - 509 + if (_aac_probe_container(scsicmd, aac_probe_container_callback1) == 0) 510 + while (scsicmd->device == scsidev) 511 + schedule(); 512 + kfree(scsidev); 513 + status = scsicmd->SCp.Status; 514 + kfree(scsicmd); 673 515 return status; 674 516 } 675 517 ··· 1193 1115 printk(KERN_INFO "%s%d: serial %x\n", 1194 1116 dev->name, dev->id, 1195 1117 le32_to_cpu(dev->adapter_info.serial[0])); 1118 + if (dev->supplement_adapter_info.VpdInfo.Tsid[0]) { 1119 + printk(KERN_INFO "%s%d: TSID %.*s\n", 1120 + dev->name, dev->id, 1121 + (int)sizeof(dev->supplement_adapter_info.VpdInfo.Tsid), 1122 + dev->supplement_adapter_info.VpdInfo.Tsid); 1123 + } 1196 1124 } 1197 1125 1198 1126 dev->nondasd_support = 0; ··· 1325 1241 u32 cid; 1326 1242 1327 1243 scsicmd = (struct scsi_cmnd *) context; 1328 - scsicmd->SCp.phase = AAC_OWNER_MIDLEVEL; 1244 + 1245 + if (!aac_valid_context(scsicmd, fibptr)) 1246 + return; 1329 1247 1330 1248 dev = (struct aac_dev *)scsicmd->device->host->hostdata; 1331 1249 cid = scmd_id(scsicmd); ··· 1403 1317 scsicmd->scsi_done(scsicmd); 1404 1318 } 1405 1319 1406 - static int aac_read(struct scsi_cmnd * scsicmd, int cid) 1320 + static int aac_read(struct scsi_cmnd * scsicmd) 1407 1321 { 1408 1322 u64 lba; 1409 1323 u32 count; ··· 1417 1331 */ 1418 1332 switch (scsicmd->cmnd[0]) { 1419 1333 case READ_6: 1420 - dprintk((KERN_DEBUG "aachba: received a read(6) command on id %d.\n", cid)); 1334 + dprintk((KERN_DEBUG "aachba: received a read(6) command on id %d.\n", scmd_id(scsicmd))); 1421 1335 1422 1336 lba = ((scsicmd->cmnd[1] & 0x1F) << 16) | 1423 1337 (scsicmd->cmnd[2] << 8) | scsicmd->cmnd[3]; ··· 1427 1341 count = 256; 1428 1342 break; 1429 1343 case READ_16: 1430 - dprintk((KERN_DEBUG "aachba: received a read(16) command on id %d.\n", cid)); 1344 + dprintk((KERN_DEBUG "aachba: received a read(16) command on id %d.\n", scmd_id(scsicmd))); 1431 1345 1432 1346 lba = ((u64)scsicmd->cmnd[2] << 56) | 1433 1347 ((u64)scsicmd->cmnd[3] << 48) | ··· 1441 1355 (scsicmd->cmnd[12] << 8) | scsicmd->cmnd[13]; 1442 1356 break; 1443 1357 case READ_12: 1444 - dprintk((KERN_DEBUG "aachba: received a read(12) command on id %d.\n", cid)); 1358 + dprintk((KERN_DEBUG "aachba: received a read(12) command on id %d.\n", scmd_id(scsicmd))); 1445 1359 1446 1360 lba = ((u64)scsicmd->cmnd[2] << 24) | 1447 1361 (scsicmd->cmnd[3] << 16) | ··· 1451 1365 (scsicmd->cmnd[8] << 8) | scsicmd->cmnd[9]; 1452 1366 break; 1453 1367 default: 1454 - dprintk((KERN_DEBUG "aachba: received a read(10) command on id %d.\n", cid)); 1368 + dprintk((KERN_DEBUG "aachba: received a read(10) command on id %d.\n", scmd_id(scsicmd))); 1455 1369 1456 1370 lba = ((u64)scsicmd->cmnd[2] << 24) | 1457 1371 (scsicmd->cmnd[3] << 16) | ··· 1491 1405 return 0; 1492 1406 } 1493 1407 1494 - static int aac_write(struct scsi_cmnd * scsicmd, int cid) 1408 + static int aac_write(struct scsi_cmnd * scsicmd) 1495 1409 { 1496 1410 u64 lba; 1497 1411 u32 count; ··· 1510 1424 if (count == 0) 1511 1425 count = 256; 1512 1426 } else if (scsicmd->cmnd[0] == WRITE_16) { /* 16 byte command */ 1513 - dprintk((KERN_DEBUG "aachba: received a write(16) command on id %d.\n", cid)); 1427 + dprintk((KERN_DEBUG "aachba: received a write(16) command on id %d.\n", scmd_id(scsicmd))); 1514 1428 1515 1429 lba = ((u64)scsicmd->cmnd[2] << 56) | 1516 1430 ((u64)scsicmd->cmnd[3] << 48) | ··· 1522 1436 count = (scsicmd->cmnd[10] << 24) | (scsicmd->cmnd[11] << 16) | 1523 1437 (scsicmd->cmnd[12] << 8) | scsicmd->cmnd[13]; 1524 1438 } else if (scsicmd->cmnd[0] == WRITE_12) { /* 12 byte command */ 1525 - dprintk((KERN_DEBUG "aachba: received a write(12) command on id %d.\n", cid)); 1439 + dprintk((KERN_DEBUG "aachba: received a write(12) command on id %d.\n", scmd_id(scsicmd))); 1526 1440 1527 1441 lba = ((u64)scsicmd->cmnd[2] << 24) | (scsicmd->cmnd[3] << 16) 1528 1442 | (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5]; 1529 1443 count = (scsicmd->cmnd[6] << 24) | (scsicmd->cmnd[7] << 16) 1530 1444 | (scsicmd->cmnd[8] << 8) | scsicmd->cmnd[9]; 1531 1445 } else { 1532 - dprintk((KERN_DEBUG "aachba: received a write(10) command on id %d.\n", cid)); 1446 + dprintk((KERN_DEBUG "aachba: received a write(10) command on id %d.\n", scmd_id(scsicmd))); 1533 1447 lba = ((u64)scsicmd->cmnd[2] << 24) | (scsicmd->cmnd[3] << 16) | (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5]; 1534 1448 count = (scsicmd->cmnd[7] << 8) | scsicmd->cmnd[8]; 1535 1449 } ··· 1574 1488 struct scsi_cmnd *cmd; 1575 1489 1576 1490 cmd = context; 1577 - cmd->SCp.phase = AAC_OWNER_MIDLEVEL; 1491 + 1492 + if (!aac_valid_context(cmd, fibptr)) 1493 + return; 1578 1494 1579 1495 dprintk((KERN_DEBUG "synchronize_callback[cpu %d]: t = %ld.\n", 1580 1496 smp_processor_id(), jiffies)); ··· 1611 1523 cmd->scsi_done(cmd); 1612 1524 } 1613 1525 1614 - static int aac_synchronize(struct scsi_cmnd *scsicmd, int cid) 1526 + static int aac_synchronize(struct scsi_cmnd *scsicmd) 1615 1527 { 1616 1528 int status; 1617 1529 struct fib *cmd_fibcontext; ··· 1656 1568 synchronizecmd = fib_data(cmd_fibcontext); 1657 1569 synchronizecmd->command = cpu_to_le32(VM_ContainerConfig); 1658 1570 synchronizecmd->type = cpu_to_le32(CT_FLUSH_CACHE); 1659 - synchronizecmd->cid = cpu_to_le32(cid); 1571 + synchronizecmd->cid = cpu_to_le32(scmd_id(scsicmd)); 1660 1572 synchronizecmd->count = 1661 1573 cpu_to_le32(sizeof(((struct aac_synchronize_reply *)NULL)->data)); 1662 1574 ··· 1734 1646 case TEST_UNIT_READY: 1735 1647 if (dev->in_reset) 1736 1648 return -1; 1737 - spin_unlock_irq(host->host_lock); 1738 - aac_probe_container(dev, cid); 1739 - if ((fsa_dev_ptr[cid].valid & 1) == 0) 1740 - fsa_dev_ptr[cid].valid = 0; 1741 - spin_lock_irq(host->host_lock); 1742 - if (fsa_dev_ptr[cid].valid == 0) { 1743 - scsicmd->result = DID_NO_CONNECT << 16; 1744 - scsicmd->scsi_done(scsicmd); 1745 - return 0; 1746 - } 1649 + return _aac_probe_container(scsicmd, 1650 + aac_probe_container_callback2); 1747 1651 default: 1748 1652 break; 1749 1653 } 1750 - } 1751 - /* 1752 - * If the target container still doesn't exist, 1753 - * return failure 1754 - */ 1755 - if (fsa_dev_ptr[cid].valid == 0) { 1756 - scsicmd->result = DID_BAD_TARGET << 16; 1757 - scsicmd->scsi_done(scsicmd); 1758 - return 0; 1759 1654 } 1760 1655 } else { /* check for physical non-dasd devices */ 1761 1656 if ((dev->nondasd_support == 1) || expose_physicals) { ··· 1804 1733 setinqstr(dev, (void *) (inq_data.inqd_vid), fsa_dev_ptr[cid].type); 1805 1734 inq_data.inqd_pdt = INQD_PDT_DA; /* Direct/random access device */ 1806 1735 aac_internal_transfer(scsicmd, &inq_data, 0, sizeof(inq_data)); 1807 - return aac_get_container_name(scsicmd, cid); 1736 + return aac_get_container_name(scsicmd); 1808 1737 } 1809 1738 case SERVICE_ACTION_IN: 1810 1739 if (!(dev->raw_io_interface) || ··· 1970 1899 min(sizeof(fsa_dev_ptr[cid].devname), 1971 1900 sizeof(scsicmd->request->rq_disk->disk_name) + 1)); 1972 1901 1973 - return aac_read(scsicmd, cid); 1902 + return aac_read(scsicmd); 1974 1903 1975 1904 case WRITE_6: 1976 1905 case WRITE_10: ··· 1978 1907 case WRITE_16: 1979 1908 if (dev->in_reset) 1980 1909 return -1; 1981 - return aac_write(scsicmd, cid); 1910 + return aac_write(scsicmd); 1982 1911 1983 1912 case SYNCHRONIZE_CACHE: 1984 1913 /* Issue FIB to tell Firmware to flush it's cache */ 1985 - return aac_synchronize(scsicmd, cid); 1914 + return aac_synchronize(scsicmd); 1986 1915 1987 1916 default: 1988 1917 /* ··· 2129 2058 struct scsi_cmnd *scsicmd; 2130 2059 2131 2060 scsicmd = (struct scsi_cmnd *) context; 2132 - scsicmd->SCp.phase = AAC_OWNER_MIDLEVEL; 2061 + 2062 + if (!aac_valid_context(scsicmd, fibptr)) 2063 + return; 2064 + 2133 2065 dev = (struct aac_dev *)scsicmd->device->host->hostdata; 2134 2066 2135 2067 BUG_ON(fibptr == NULL);
+30 -46
drivers/scsi/aacraid/aacraid.h
··· 12 12 *----------------------------------------------------------------------------*/ 13 13 14 14 #ifndef AAC_DRIVER_BUILD 15 - # define AAC_DRIVER_BUILD 2423 16 - # define AAC_DRIVER_BRANCH "-mh3" 15 + # define AAC_DRIVER_BUILD 2437 16 + # define AAC_DRIVER_BRANCH "-mh4" 17 17 #endif 18 18 #define MAXIMUM_NUM_CONTAINERS 32 19 19 ··· 48 48 49 49 50 50 /* 51 - * DON'T CHANGE THE ORDER, this is set by the firmware 51 + * Firmware constants 52 52 */ 53 53 54 54 #define CT_NONE 0 55 - #define CT_VOLUME 1 56 - #define CT_MIRROR 2 57 - #define CT_STRIPE 3 58 - #define CT_RAID5 4 59 - #define CT_SSRW 5 60 - #define CT_SSRO 6 61 - #define CT_MORPH 7 62 - #define CT_PASSTHRU 8 63 - #define CT_RAID4 9 64 - #define CT_RAID10 10 /* stripe of mirror */ 65 - #define CT_RAID00 11 /* stripe of stripe */ 66 - #define CT_VOLUME_OF_MIRRORS 12 /* volume of mirror */ 67 - #define CT_PSEUDO_RAID 13 /* really raid4 */ 68 - #define CT_LAST_VOLUME_TYPE 14 69 55 #define CT_OK 218 70 - 71 - /* 72 - * Types of objects addressable in some fashion by the client. 73 - * This is a superset of those objects handled just by the filesystem 74 - * and includes "raw" objects that an administrator would use to 75 - * configure containers and filesystems. 76 - */ 77 - 78 - #define FT_REG 1 /* regular file */ 79 - #define FT_DIR 2 /* directory */ 80 - #define FT_BLK 3 /* "block" device - reserved */ 81 - #define FT_CHR 4 /* "character special" device - reserved */ 82 - #define FT_LNK 5 /* symbolic link */ 83 - #define FT_SOCK 6 /* socket */ 84 - #define FT_FIFO 7 /* fifo */ 85 56 #define FT_FILESYS 8 /* ADAPTEC's "FSA"(tm) filesystem */ 86 57 #define FT_DRIVE 9 /* physical disk - addressable in scsi by bus/id/lun */ 87 - #define FT_SLICE 10 /* virtual disk - raw volume - slice */ 88 - #define FT_PARTITION 11 /* FSA partition - carved out of a slice - building block for containers */ 89 - #define FT_VOLUME 12 /* Container - Volume Set */ 90 - #define FT_STRIPE 13 /* Container - Stripe Set */ 91 - #define FT_MIRROR 14 /* Container - Mirror Set */ 92 - #define FT_RAID5 15 /* Container - Raid 5 Set */ 93 - #define FT_DATABASE 16 /* Storage object with "foreign" content manager */ 94 58 95 59 /* 96 60 * Host side memory scatter gather list ··· 461 497 void (*adapter_enable_int)(struct aac_dev *dev); 462 498 int (*adapter_sync_cmd)(struct aac_dev *dev, u32 command, u32 p1, u32 p2, u32 p3, u32 p4, u32 p5, u32 p6, u32 *status, u32 *r1, u32 *r2, u32 *r3, u32 *r4); 463 499 int (*adapter_check_health)(struct aac_dev *dev); 500 + int (*adapter_restart)(struct aac_dev *dev, int bled); 464 501 /* Transport operations */ 465 502 int (*adapter_ioremap)(struct aac_dev * dev, u32 size); 466 503 irqreturn_t (*adapter_intr)(int irq, void *dev_id); ··· 798 833 */ 799 834 struct list_head fiblink; 800 835 void *data; 801 - struct hw_fib *hw_fib; /* Actual shared object */ 836 + struct hw_fib *hw_fib_va; /* Actual shared object */ 802 837 dma_addr_t hw_fib_pa; /* physical address of hw_fib*/ 803 838 }; 804 839 ··· 843 878 __le32 Version; 844 879 __le32 FeatureBits; 845 880 u8 SlotNumber; 846 - u8 ReservedPad0[0]; 881 + u8 ReservedPad0[3]; 847 882 u8 BuildDate[12]; 848 883 __le32 CurrentNumberPorts; 849 - __le32 ReservedGrowth[24]; 884 + struct { 885 + u8 AssemblyPn[8]; 886 + u8 FruPn[8]; 887 + u8 BatteryFruPn[8]; 888 + u8 EcVersionString[8]; 889 + u8 Tsid[12]; 890 + } VpdInfo; 891 + __le32 FlashFirmwareRevision; 892 + __le32 FlashFirmwareBuild; 893 + __le32 RaidTypeMorphOptions; 894 + __le32 FlashFirmwareBootRevision; 895 + __le32 FlashFirmwareBootBuild; 896 + u8 MfgPcbaSerialNo[12]; 897 + u8 MfgWWNName[8]; 898 + __le32 MoreFeatureBits; 899 + __le32 ReservedGrowth[1]; 850 900 }; 851 901 #define AAC_FEATURE_FALCON 0x00000010 852 902 #define AAC_SIS_VERSION_V3 3 ··· 950 970 struct fib *fibs; 951 971 952 972 struct fib *free_fib; 953 - struct fib *timeout_fib; 954 973 spinlock_t fib_lock; 955 974 956 975 struct aac_queue_block *queues; ··· 1038 1059 1039 1060 #define aac_adapter_check_health(dev) \ 1040 1061 (dev)->a_ops.adapter_check_health(dev) 1062 + 1063 + #define aac_adapter_restart(dev,bled) \ 1064 + (dev)->a_ops.adapter_restart(dev,bled) 1041 1065 1042 1066 #define aac_adapter_ioremap(dev, size) \ 1043 1067 (dev)->a_ops.adapter_ioremap(dev, size) ··· 1498 1516 struct creation_info create_info; /* if applicable */ 1499 1517 __le32 capacity; 1500 1518 __le32 vol; /* substrate structure */ 1501 - __le32 obj; /* FT_FILESYS, 1502 - FT_DATABASE, etc. */ 1519 + __le32 obj; /* FT_FILESYS, etc. */ 1503 1520 __le32 state; /* unready for mounting, 1504 1521 readonly, etc. */ 1505 1522 union aac_contentinfo fileinfo; /* Info specific to content ··· 1798 1817 int aac_consumer_get(struct aac_dev * dev, struct aac_queue * q, struct aac_entry **entry); 1799 1818 void aac_consumer_free(struct aac_dev * dev, struct aac_queue * q, u32 qnum); 1800 1819 int aac_fib_complete(struct fib * context); 1801 - #define fib_data(fibctx) ((void *)(fibctx)->hw_fib->data) 1820 + #define fib_data(fibctx) ((void *)(fibctx)->hw_fib_va->data) 1802 1821 struct aac_dev *aac_init_adapter(struct aac_dev *dev); 1803 1822 int aac_get_config_status(struct aac_dev *dev, int commit_flag); 1804 1823 int aac_get_containers(struct aac_dev *dev); ··· 1821 1840 int aac_get_adapter_info(struct aac_dev* dev); 1822 1841 int aac_send_shutdown(struct aac_dev *dev); 1823 1842 int aac_probe_container(struct aac_dev *dev, int cid); 1843 + int _aac_rx_init(struct aac_dev *dev); 1844 + int aac_rx_select_comm(struct aac_dev *dev, int comm); 1824 1845 extern int numacb; 1825 1846 extern int acbsize; 1826 1847 extern char aac_driver_version[]; 1827 1848 extern int startup_timeout; 1828 1849 extern int aif_timeout; 1850 + extern int expose_physicals;
+172 -112
drivers/scsi/aacraid/commctrl.c
··· 5 5 * based on the old aacraid driver that is.. 6 6 * Adaptec aacraid device driver for Linux. 7 7 * 8 - * Copyright (c) 2000 Adaptec, Inc. (aacraid@adaptec.com) 8 + * Copyright (c) 2000-2007 Adaptec, Inc. (aacraid@adaptec.com) 9 9 * 10 10 * This program is free software; you can redistribute it and/or modify 11 11 * it under the terms of the GNU General Public License as published by ··· 64 64 unsigned size; 65 65 int retval; 66 66 67 + if (dev->in_reset) { 68 + return -EBUSY; 69 + } 67 70 fibptr = aac_fib_alloc(dev); 68 71 if(fibptr == NULL) { 69 72 return -ENOMEM; 70 73 } 71 74 72 - kfib = fibptr->hw_fib; 75 + kfib = fibptr->hw_fib_va; 73 76 /* 74 77 * First copy in the header so that we can check the size field. 75 78 */ ··· 94 91 goto cleanup; 95 92 } 96 93 /* Highjack the hw_fib */ 97 - hw_fib = fibptr->hw_fib; 94 + hw_fib = fibptr->hw_fib_va; 98 95 hw_fib_pa = fibptr->hw_fib_pa; 99 - fibptr->hw_fib = kfib = pci_alloc_consistent(dev->pdev, size, &fibptr->hw_fib_pa); 96 + fibptr->hw_fib_va = kfib = pci_alloc_consistent(dev->pdev, size, &fibptr->hw_fib_pa); 100 97 memset(((char *)kfib) + dev->max_fib_size, 0, size - dev->max_fib_size); 101 98 memcpy(kfib, hw_fib, dev->max_fib_size); 102 99 } ··· 140 137 if (hw_fib) { 141 138 pci_free_consistent(dev->pdev, size, kfib, fibptr->hw_fib_pa); 142 139 fibptr->hw_fib_pa = hw_fib_pa; 143 - fibptr->hw_fib = hw_fib; 140 + fibptr->hw_fib_va = hw_fib; 144 141 } 145 142 if (retval != -EINTR) 146 143 aac_fib_free(fibptr); ··· 285 282 fib = list_entry(entry, struct fib, fiblink); 286 283 fibctx->count--; 287 284 spin_unlock_irqrestore(&dev->fib_lock, flags); 288 - if (copy_to_user(f.fib, fib->hw_fib, sizeof(struct hw_fib))) { 289 - kfree(fib->hw_fib); 285 + if (copy_to_user(f.fib, fib->hw_fib_va, sizeof(struct hw_fib))) { 286 + kfree(fib->hw_fib_va); 290 287 kfree(fib); 291 288 return -EFAULT; 292 289 } 293 290 /* 294 291 * Free the space occupied by this copy of the fib. 295 292 */ 296 - kfree(fib->hw_fib); 293 + kfree(fib->hw_fib_va); 297 294 kfree(fib); 298 295 status = 0; 299 296 } else { ··· 343 340 /* 344 341 * Free the space occupied by this copy of the fib. 345 342 */ 346 - kfree(fib->hw_fib); 343 + kfree(fib->hw_fib_va); 347 344 kfree(fib); 348 345 } 349 346 /* ··· 391 388 /* 392 389 * Extract the fibctx from the input parameters 393 390 */ 394 - if (fibctx->unique == (u32)(unsigned long)arg) { 395 - /* We found a winner */ 391 + if (fibctx->unique == (u32)(ptrdiff_t)arg) /* We found a winner */ 396 392 break; 397 - } 398 393 entry = entry->next; 399 394 fibctx = NULL; 400 395 } ··· 466 465 void *sg_list[32]; 467 466 u32 sg_indx = 0; 468 467 u32 byte_count = 0; 469 - u32 actual_fibsize = 0; 468 + u32 actual_fibsize64, actual_fibsize = 0; 470 469 int i; 471 470 472 471 472 + if (dev->in_reset) { 473 + dprintk((KERN_DEBUG"aacraid: send raw srb -EBUSY\n")); 474 + return -EBUSY; 475 + } 473 476 if (!capable(CAP_SYS_ADMIN)){ 474 477 dprintk((KERN_DEBUG"aacraid: No permission to send raw srb\n")); 475 478 return -EPERM; 476 479 } 477 480 /* 478 - * Allocate and initialize a Fib then setup a BlockWrite command 481 + * Allocate and initialize a Fib then setup a SRB command 479 482 */ 480 483 if (!(srbfib = aac_fib_alloc(dev))) { 481 484 return -ENOMEM; ··· 546 541 rcode = -EINVAL; 547 542 goto cleanup; 548 543 } 549 - if (dev->dac_support == 1) { 544 + actual_fibsize = sizeof(struct aac_srb) - sizeof(struct sgentry) + 545 + ((user_srbcmd->sg.count & 0xff) * sizeof(struct sgentry)); 546 + actual_fibsize64 = actual_fibsize + (user_srbcmd->sg.count & 0xff) * 547 + (sizeof(struct sgentry64) - sizeof(struct sgentry)); 548 + /* User made a mistake - should not continue */ 549 + if ((actual_fibsize != fibsize) && (actual_fibsize64 != fibsize)) { 550 + dprintk((KERN_DEBUG"aacraid: Bad Size specified in " 551 + "Raw SRB command calculated fibsize=%lu;%lu " 552 + "user_srbcmd->sg.count=%d aac_srb=%lu sgentry=%lu;%lu " 553 + "issued fibsize=%d\n", 554 + actual_fibsize, actual_fibsize64, user_srbcmd->sg.count, 555 + sizeof(struct aac_srb), sizeof(struct sgentry), 556 + sizeof(struct sgentry64), fibsize)); 557 + rcode = -EINVAL; 558 + goto cleanup; 559 + } 560 + if ((data_dir == DMA_NONE) && user_srbcmd->sg.count) { 561 + dprintk((KERN_DEBUG"aacraid: SG with no direction specified in Raw SRB command\n")); 562 + rcode = -EINVAL; 563 + goto cleanup; 564 + } 565 + byte_count = 0; 566 + if (dev->adapter_info.options & AAC_OPT_SGMAP_HOST64) { 550 567 struct user_sgmap64* upsg = (struct user_sgmap64*)&user_srbcmd->sg; 551 568 struct sgmap64* psg = (struct sgmap64*)&srbcmd->sg; 552 - struct user_sgmap* usg; 553 - byte_count = 0; 554 569 555 570 /* 556 571 * This should also catch if user used the 32 bit sgmap 557 572 */ 558 - actual_fibsize = sizeof(struct aac_srb) - 559 - sizeof(struct sgentry) + 560 - ((upsg->count & 0xff) * 561 - sizeof(struct sgentry)); 562 - if(actual_fibsize != fibsize){ // User made a mistake - should not continue 563 - dprintk((KERN_DEBUG"aacraid: Bad Size specified in Raw SRB command\n")); 564 - rcode = -EINVAL; 565 - goto cleanup; 566 - } 567 - usg = kmalloc(actual_fibsize - sizeof(struct aac_srb) 568 - + sizeof(struct sgmap), GFP_KERNEL); 569 - if (!usg) { 570 - dprintk((KERN_DEBUG"aacraid: Allocation error in Raw SRB command\n")); 571 - rcode = -ENOMEM; 572 - goto cleanup; 573 - } 574 - memcpy (usg, upsg, actual_fibsize - sizeof(struct aac_srb) 575 - + sizeof(struct sgmap)); 576 - actual_fibsize = sizeof(struct aac_srb) - 577 - sizeof(struct sgentry) + ((usg->count & 0xff) * 578 - sizeof(struct sgentry64)); 579 - if ((data_dir == DMA_NONE) && upsg->count) { 580 - kfree (usg); 581 - dprintk((KERN_DEBUG"aacraid: SG with no direction specified in Raw SRB command\n")); 582 - rcode = -EINVAL; 583 - goto cleanup; 584 - } 573 + if (actual_fibsize64 == fibsize) { 574 + actual_fibsize = actual_fibsize64; 575 + for (i = 0; i < upsg->count; i++) { 576 + u64 addr; 577 + void* p; 578 + /* Does this really need to be GFP_DMA? */ 579 + p = kmalloc(upsg->sg[i].count,GFP_KERNEL|__GFP_DMA); 580 + if(p == 0) { 581 + dprintk((KERN_DEBUG"aacraid: Could not allocate SG buffer - size = %d buffer number %d of %d\n", 582 + upsg->sg[i].count,i,upsg->count)); 583 + rcode = -ENOMEM; 584 + goto cleanup; 585 + } 586 + addr = (u64)upsg->sg[i].addr[0]; 587 + addr += ((u64)upsg->sg[i].addr[1]) << 32; 588 + sg_user[i] = (void __user *)(ptrdiff_t)addr; 589 + sg_list[i] = p; // save so we can clean up later 590 + sg_indx = i; 585 591 586 - for (i = 0; i < usg->count; i++) { 587 - u64 addr; 588 - void* p; 589 - /* Does this really need to be GFP_DMA? */ 590 - p = kmalloc(usg->sg[i].count,GFP_KERNEL|__GFP_DMA); 591 - if(p == 0) { 592 - kfree (usg); 593 - dprintk((KERN_DEBUG"aacraid: Could not allocate SG buffer - size = %d buffer number %d of %d\n", 594 - usg->sg[i].count,i,usg->count)); 592 + if( flags & SRB_DataOut ){ 593 + if(copy_from_user(p,sg_user[i],upsg->sg[i].count)){ 594 + dprintk((KERN_DEBUG"aacraid: Could not copy sg data from user\n")); 595 + rcode = -EFAULT; 596 + goto cleanup; 597 + } 598 + } 599 + addr = pci_map_single(dev->pdev, p, upsg->sg[i].count, data_dir); 600 + 601 + psg->sg[i].addr[0] = cpu_to_le32(addr & 0xffffffff); 602 + psg->sg[i].addr[1] = cpu_to_le32(addr>>32); 603 + byte_count += upsg->sg[i].count; 604 + psg->sg[i].count = cpu_to_le32(upsg->sg[i].count); 605 + } 606 + } else { 607 + struct user_sgmap* usg; 608 + usg = kmalloc(actual_fibsize - sizeof(struct aac_srb) 609 + + sizeof(struct sgmap), GFP_KERNEL); 610 + if (!usg) { 611 + dprintk((KERN_DEBUG"aacraid: Allocation error in Raw SRB command\n")); 595 612 rcode = -ENOMEM; 596 613 goto cleanup; 597 614 } 598 - sg_user[i] = (void __user *)(long)usg->sg[i].addr; 599 - sg_list[i] = p; // save so we can clean up later 600 - sg_indx = i; 615 + memcpy (usg, upsg, actual_fibsize - sizeof(struct aac_srb) 616 + + sizeof(struct sgmap)); 617 + actual_fibsize = actual_fibsize64; 601 618 602 - if( flags & SRB_DataOut ){ 603 - if(copy_from_user(p,sg_user[i],upsg->sg[i].count)){ 619 + for (i = 0; i < usg->count; i++) { 620 + u64 addr; 621 + void* p; 622 + /* Does this really need to be GFP_DMA? */ 623 + p = kmalloc(usg->sg[i].count,GFP_KERNEL|__GFP_DMA); 624 + if(p == 0) { 604 625 kfree (usg); 605 - dprintk((KERN_DEBUG"aacraid: Could not copy sg data from user\n")); 606 - rcode = -EFAULT; 626 + dprintk((KERN_DEBUG"aacraid: Could not allocate SG buffer - size = %d buffer number %d of %d\n", 627 + usg->sg[i].count,i,usg->count)); 628 + rcode = -ENOMEM; 607 629 goto cleanup; 608 630 } 631 + sg_user[i] = (void __user *)(ptrdiff_t)usg->sg[i].addr; 632 + sg_list[i] = p; // save so we can clean up later 633 + sg_indx = i; 634 + 635 + if( flags & SRB_DataOut ){ 636 + if(copy_from_user(p,sg_user[i],upsg->sg[i].count)){ 637 + kfree (usg); 638 + dprintk((KERN_DEBUG"aacraid: Could not copy sg data from user\n")); 639 + rcode = -EFAULT; 640 + goto cleanup; 641 + } 642 + } 643 + addr = pci_map_single(dev->pdev, p, usg->sg[i].count, data_dir); 644 + 645 + psg->sg[i].addr[0] = cpu_to_le32(addr & 0xffffffff); 646 + psg->sg[i].addr[1] = cpu_to_le32(addr>>32); 647 + byte_count += usg->sg[i].count; 648 + psg->sg[i].count = cpu_to_le32(usg->sg[i].count); 609 649 } 610 - addr = pci_map_single(dev->pdev, p, usg->sg[i].count, data_dir); 611 - 612 - psg->sg[i].addr[0] = cpu_to_le32(addr & 0xffffffff); 613 - psg->sg[i].addr[1] = cpu_to_le32(addr>>32); 614 - psg->sg[i].count = cpu_to_le32(usg->sg[i].count); 615 - byte_count += usg->sg[i].count; 650 + kfree (usg); 616 651 } 617 - kfree (usg); 618 - 619 652 srbcmd->count = cpu_to_le32(byte_count); 620 653 psg->count = cpu_to_le32(sg_indx+1); 621 654 status = aac_fib_send(ScsiPortCommand64, srbfib, actual_fibsize, FsaNormal, 1, 1,NULL,NULL); 622 655 } else { 623 656 struct user_sgmap* upsg = &user_srbcmd->sg; 624 657 struct sgmap* psg = &srbcmd->sg; 625 - byte_count = 0; 626 658 627 - actual_fibsize = sizeof (struct aac_srb) + (((user_srbcmd->sg.count & 0xff) - 1) * sizeof (struct sgentry)); 628 - if(actual_fibsize != fibsize){ // User made a mistake - should not continue 629 - dprintk((KERN_DEBUG"aacraid: Bad Size specified in " 630 - "Raw SRB command calculated fibsize=%d " 631 - "user_srbcmd->sg.count=%d aac_srb=%d sgentry=%d " 632 - "issued fibsize=%d\n", 633 - actual_fibsize, user_srbcmd->sg.count, 634 - sizeof(struct aac_srb), sizeof(struct sgentry), 635 - fibsize)); 636 - rcode = -EINVAL; 637 - goto cleanup; 638 - } 639 - if ((data_dir == DMA_NONE) && upsg->count) { 640 - dprintk((KERN_DEBUG"aacraid: SG with no direction specified in Raw SRB command\n")); 641 - rcode = -EINVAL; 642 - goto cleanup; 643 - } 644 - for (i = 0; i < upsg->count; i++) { 645 - dma_addr_t addr; 646 - void* p; 647 - p = kmalloc(upsg->sg[i].count, GFP_KERNEL); 648 - if(p == 0) { 649 - dprintk((KERN_DEBUG"aacraid: Could not allocate SG buffer - size = %d buffer number %d of %d\n", 650 - upsg->sg[i].count, i, upsg->count)); 651 - rcode = -ENOMEM; 652 - goto cleanup; 653 - } 654 - sg_user[i] = (void __user *)(long)upsg->sg[i].addr; 655 - sg_list[i] = p; // save so we can clean up later 656 - sg_indx = i; 657 - 658 - if( flags & SRB_DataOut ){ 659 - if(copy_from_user(p, sg_user[i], 660 - upsg->sg[i].count)) { 661 - dprintk((KERN_DEBUG"aacraid: Could not copy sg data from user\n")); 662 - rcode = -EFAULT; 659 + if (actual_fibsize64 == fibsize) { 660 + struct user_sgmap64* usg = (struct user_sgmap64 *)upsg; 661 + for (i = 0; i < upsg->count; i++) { 662 + u64 addr; 663 + void* p; 664 + /* Does this really need to be GFP_DMA? */ 665 + p = kmalloc(usg->sg[i].count,GFP_KERNEL|__GFP_DMA); 666 + if(p == 0) { 667 + dprintk((KERN_DEBUG"aacraid: Could not allocate SG buffer - size = %d buffer number %d of %d\n", 668 + usg->sg[i].count,i,usg->count)); 669 + rcode = -ENOMEM; 663 670 goto cleanup; 664 671 } 665 - } 666 - addr = pci_map_single(dev->pdev, p, 667 - upsg->sg[i].count, data_dir); 672 + addr = (u64)usg->sg[i].addr[0]; 673 + addr += ((u64)usg->sg[i].addr[1]) << 32; 674 + sg_user[i] = (void __user *)(ptrdiff_t)addr; 675 + sg_list[i] = p; // save so we can clean up later 676 + sg_indx = i; 668 677 669 - psg->sg[i].addr = cpu_to_le32(addr); 670 - psg->sg[i].count = cpu_to_le32(upsg->sg[i].count); 671 - byte_count += upsg->sg[i].count; 678 + if( flags & SRB_DataOut ){ 679 + if(copy_from_user(p,sg_user[i],usg->sg[i].count)){ 680 + dprintk((KERN_DEBUG"aacraid: Could not copy sg data from user\n")); 681 + rcode = -EFAULT; 682 + goto cleanup; 683 + } 684 + } 685 + addr = pci_map_single(dev->pdev, p, usg->sg[i].count, data_dir); 686 + 687 + psg->sg[i].addr = cpu_to_le32(addr & 0xffffffff); 688 + byte_count += usg->sg[i].count; 689 + psg->sg[i].count = cpu_to_le32(usg->sg[i].count); 690 + } 691 + } else { 692 + for (i = 0; i < upsg->count; i++) { 693 + dma_addr_t addr; 694 + void* p; 695 + p = kmalloc(upsg->sg[i].count, GFP_KERNEL); 696 + if(p == 0) { 697 + dprintk((KERN_DEBUG"aacraid: Could not allocate SG buffer - size = %d buffer number %d of %d\n", 698 + upsg->sg[i].count, i, upsg->count)); 699 + rcode = -ENOMEM; 700 + goto cleanup; 701 + } 702 + sg_user[i] = (void __user *)(ptrdiff_t)upsg->sg[i].addr; 703 + sg_list[i] = p; // save so we can clean up later 704 + sg_indx = i; 705 + 706 + if( flags & SRB_DataOut ){ 707 + if(copy_from_user(p, sg_user[i], 708 + upsg->sg[i].count)) { 709 + dprintk((KERN_DEBUG"aacraid: Could not copy sg data from user\n")); 710 + rcode = -EFAULT; 711 + goto cleanup; 712 + } 713 + } 714 + addr = pci_map_single(dev->pdev, p, 715 + upsg->sg[i].count, data_dir); 716 + 717 + psg->sg[i].addr = cpu_to_le32(addr); 718 + byte_count += upsg->sg[i].count; 719 + psg->sg[i].count = cpu_to_le32(upsg->sg[i].count); 720 + } 672 721 } 673 722 srbcmd->count = cpu_to_le32(byte_count); 674 723 psg->count = cpu_to_le32(sg_indx+1); ··· 741 682 742 683 if( flags & SRB_DataIn ) { 743 684 for(i = 0 ; i <= sg_indx; i++){ 744 - byte_count = le32_to_cpu((dev->dac_support == 1) 685 + byte_count = le32_to_cpu( 686 + (dev->adapter_info.options & AAC_OPT_SGMAP_HOST64) 745 687 ? ((struct sgmap64*)&srbcmd->sg)->sg[i].count 746 688 : srbcmd->sg.sg[i].count); 747 689 if(copy_to_user(sg_user[i], sg_list[i], byte_count)){
+2 -2
drivers/scsi/aacraid/comminit.c
··· 5 5 * based on the old aacraid driver that is.. 6 6 * Adaptec aacraid device driver for Linux. 7 7 * 8 - * Copyright (c) 2000 Adaptec, Inc. (aacraid@adaptec.com) 8 + * Copyright (c) 2000-2007 Adaptec, Inc. (aacraid@adaptec.com) 9 9 * 10 10 * This program is free software; you can redistribute it and/or modify 11 11 * it under the terms of the GNU General Public License as published by ··· 110 110 /* 111 111 * Align the beginning of Headers to commalign 112 112 */ 113 - align = (commalign - ((unsigned long)(base) & (commalign - 1))); 113 + align = (commalign - ((ptrdiff_t)(base) & (commalign - 1))); 114 114 base = base + align; 115 115 phys = phys + align; 116 116 /*
+47 -65
drivers/scsi/aacraid/commsup.c
··· 5 5 * based on the old aacraid driver that is.. 6 6 * Adaptec aacraid device driver for Linux. 7 7 * 8 - * Copyright (c) 2000 Adaptec, Inc. (aacraid@adaptec.com) 8 + * Copyright (c) 2000-2007 Adaptec, Inc. (aacraid@adaptec.com) 9 9 * 10 10 * This program is free software; you can redistribute it and/or modify 11 11 * it under the terms of the GNU General Public License as published by ··· 94 94 int aac_fib_setup(struct aac_dev * dev) 95 95 { 96 96 struct fib *fibptr; 97 - struct hw_fib *hw_fib_va; 97 + struct hw_fib *hw_fib; 98 98 dma_addr_t hw_fib_pa; 99 99 int i; 100 100 ··· 106 106 if (i<0) 107 107 return -ENOMEM; 108 108 109 - hw_fib_va = dev->hw_fib_va; 109 + hw_fib = dev->hw_fib_va; 110 110 hw_fib_pa = dev->hw_fib_pa; 111 - memset(hw_fib_va, 0, dev->max_fib_size * (dev->scsi_host_ptr->can_queue + AAC_NUM_MGT_FIB)); 111 + memset(hw_fib, 0, dev->max_fib_size * (dev->scsi_host_ptr->can_queue + AAC_NUM_MGT_FIB)); 112 112 /* 113 113 * Initialise the fibs 114 114 */ 115 115 for (i = 0, fibptr = &dev->fibs[i]; i < (dev->scsi_host_ptr->can_queue + AAC_NUM_MGT_FIB); i++, fibptr++) 116 116 { 117 117 fibptr->dev = dev; 118 - fibptr->hw_fib = hw_fib_va; 119 - fibptr->data = (void *) fibptr->hw_fib->data; 118 + fibptr->hw_fib_va = hw_fib; 119 + fibptr->data = (void *) fibptr->hw_fib_va->data; 120 120 fibptr->next = fibptr+1; /* Forward chain the fibs */ 121 121 init_MUTEX_LOCKED(&fibptr->event_wait); 122 122 spin_lock_init(&fibptr->event_lock); 123 - hw_fib_va->header.XferState = cpu_to_le32(0xffffffff); 124 - hw_fib_va->header.SenderSize = cpu_to_le16(dev->max_fib_size); 123 + hw_fib->header.XferState = cpu_to_le32(0xffffffff); 124 + hw_fib->header.SenderSize = cpu_to_le16(dev->max_fib_size); 125 125 fibptr->hw_fib_pa = hw_fib_pa; 126 - hw_fib_va = (struct hw_fib *)((unsigned char *)hw_fib_va + dev->max_fib_size); 126 + hw_fib = (struct hw_fib *)((unsigned char *)hw_fib + dev->max_fib_size); 127 127 hw_fib_pa = hw_fib_pa + dev->max_fib_size; 128 128 } 129 129 /* ··· 166 166 * Null out fields that depend on being zero at the start of 167 167 * each I/O 168 168 */ 169 - fibptr->hw_fib->header.XferState = 0; 169 + fibptr->hw_fib_va->header.XferState = 0; 170 170 fibptr->callback = NULL; 171 171 fibptr->callback_data = NULL; 172 172 ··· 178 178 * @fibptr: fib to free up 179 179 * 180 180 * Frees up a fib and places it on the appropriate queue 181 - * (either free or timed out) 182 181 */ 183 182 184 183 void aac_fib_free(struct fib *fibptr) ··· 185 186 unsigned long flags; 186 187 187 188 spin_lock_irqsave(&fibptr->dev->fib_lock, flags); 188 - if (fibptr->flags & FIB_CONTEXT_FLAG_TIMED_OUT) { 189 + if (unlikely(fibptr->flags & FIB_CONTEXT_FLAG_TIMED_OUT)) 189 190 aac_config.fib_timeouts++; 190 - fibptr->next = fibptr->dev->timeout_fib; 191 - fibptr->dev->timeout_fib = fibptr; 192 - } else { 193 - if (fibptr->hw_fib->header.XferState != 0) { 194 - printk(KERN_WARNING "aac_fib_free, XferState != 0, fibptr = 0x%p, XferState = 0x%x\n", 195 - (void*)fibptr, 196 - le32_to_cpu(fibptr->hw_fib->header.XferState)); 197 - } 198 - fibptr->next = fibptr->dev->free_fib; 199 - fibptr->dev->free_fib = fibptr; 200 - } 191 + if (fibptr->hw_fib_va->header.XferState != 0) { 192 + printk(KERN_WARNING "aac_fib_free, XferState != 0, fibptr = 0x%p, XferState = 0x%x\n", 193 + (void*)fibptr, 194 + le32_to_cpu(fibptr->hw_fib_va->header.XferState)); 195 + } 196 + fibptr->next = fibptr->dev->free_fib; 197 + fibptr->dev->free_fib = fibptr; 201 198 spin_unlock_irqrestore(&fibptr->dev->fib_lock, flags); 202 199 } 203 200 ··· 206 211 207 212 void aac_fib_init(struct fib *fibptr) 208 213 { 209 - struct hw_fib *hw_fib = fibptr->hw_fib; 214 + struct hw_fib *hw_fib = fibptr->hw_fib_va; 210 215 211 216 hw_fib->header.StructType = FIB_MAGIC; 212 217 hw_fib->header.Size = cpu_to_le16(fibptr->dev->max_fib_size); ··· 226 231 227 232 static void fib_dealloc(struct fib * fibptr) 228 233 { 229 - struct hw_fib *hw_fib = fibptr->hw_fib; 234 + struct hw_fib *hw_fib = fibptr->hw_fib_va; 230 235 BUG_ON(hw_fib->header.StructType != FIB_MAGIC); 231 236 hw_fib->header.XferState = 0; 232 237 } ··· 381 386 void *callback_data) 382 387 { 383 388 struct aac_dev * dev = fibptr->dev; 384 - struct hw_fib * hw_fib = fibptr->hw_fib; 389 + struct hw_fib * hw_fib = fibptr->hw_fib_va; 385 390 unsigned long flags = 0; 386 391 unsigned long qflags; 387 392 ··· 425 430 */ 426 431 hw_fib->header.Command = cpu_to_le16(command); 427 432 hw_fib->header.XferState |= cpu_to_le32(SentFromHost); 428 - fibptr->hw_fib->header.Flags = 0; /* 0 the flags field - internal only*/ 433 + fibptr->hw_fib_va->header.Flags = 0; /* 0 the flags field - internal only*/ 429 434 /* 430 435 * Set the size of the Fib we want to send to the adapter 431 436 */ ··· 457 462 dprintk((KERN_DEBUG " Command = %d.\n", le32_to_cpu(hw_fib->header.Command))); 458 463 dprintk((KERN_DEBUG " SubCommand = %d.\n", le32_to_cpu(((struct aac_query_mount *)fib_data(fibptr))->command))); 459 464 dprintk((KERN_DEBUG " XferState = %x.\n", le32_to_cpu(hw_fib->header.XferState))); 460 - dprintk((KERN_DEBUG " hw_fib va being sent=%p\n",fibptr->hw_fib)); 465 + dprintk((KERN_DEBUG " hw_fib va being sent=%p\n",fibptr->hw_fib_va)); 461 466 dprintk((KERN_DEBUG " hw_fib pa being sent=%lx\n",(ulong)fibptr->hw_fib_pa)); 462 467 dprintk((KERN_DEBUG " fib being sent=%p\n",fibptr)); 463 468 ··· 508 513 } 509 514 udelay(5); 510 515 } 511 - } else if (down_interruptible(&fibptr->event_wait)) { 512 - spin_lock_irqsave(&fibptr->event_lock, flags); 513 - if (fibptr->done == 0) { 514 - fibptr->done = 2; /* Tell interrupt we aborted */ 515 - spin_unlock_irqrestore(&fibptr->event_lock, flags); 516 - return -EINTR; 517 - } 516 + } else 517 + (void)down_interruptible(&fibptr->event_wait); 518 + spin_lock_irqsave(&fibptr->event_lock, flags); 519 + if (fibptr->done == 0) { 520 + fibptr->done = 2; /* Tell interrupt we aborted */ 518 521 spin_unlock_irqrestore(&fibptr->event_lock, flags); 522 + return -EINTR; 519 523 } 524 + spin_unlock_irqrestore(&fibptr->event_lock, flags); 520 525 BUG_ON(fibptr->done == 0); 521 526 522 - if((fibptr->flags & FIB_CONTEXT_FLAG_TIMED_OUT)){ 527 + if(unlikely(fibptr->flags & FIB_CONTEXT_FLAG_TIMED_OUT)) 523 528 return -ETIMEDOUT; 524 - } else { 525 - return 0; 526 - } 529 + return 0; 527 530 } 528 531 /* 529 532 * If the user does not want a response than return success otherwise ··· 617 624 618 625 int aac_fib_adapter_complete(struct fib *fibptr, unsigned short size) 619 626 { 620 - struct hw_fib * hw_fib = fibptr->hw_fib; 627 + struct hw_fib * hw_fib = fibptr->hw_fib_va; 621 628 struct aac_dev * dev = fibptr->dev; 622 629 struct aac_queue * q; 623 630 unsigned long nointr = 0; ··· 681 688 682 689 int aac_fib_complete(struct fib *fibptr) 683 690 { 684 - struct hw_fib * hw_fib = fibptr->hw_fib; 691 + struct hw_fib * hw_fib = fibptr->hw_fib_va; 685 692 686 693 /* 687 694 * Check for a fib which has already been completed ··· 767 774 #define AIF_SNIFF_TIMEOUT (30*HZ) 768 775 static void aac_handle_aif(struct aac_dev * dev, struct fib * fibptr) 769 776 { 770 - struct hw_fib * hw_fib = fibptr->hw_fib; 777 + struct hw_fib * hw_fib = fibptr->hw_fib_va; 771 778 struct aac_aifcmd * aifcmd = (struct aac_aifcmd *)hw_fib->data; 772 - int busy; 773 779 u32 container; 774 780 struct scsi_device *device; 775 781 enum { ··· 980 988 * behind you. 981 989 */ 982 990 983 - busy = 0; 984 - 985 - 986 991 /* 987 992 * Find the scsi_device associated with the SCSI address, 988 993 * and mark it as changed, invalidating the cache. This deals ··· 1024 1035 static int _aac_reset_adapter(struct aac_dev *aac) 1025 1036 { 1026 1037 int index, quirks; 1027 - u32 ret; 1028 1038 int retval; 1029 1039 struct Scsi_Host *host; 1030 1040 struct scsi_device *dev; ··· 1047 1059 * If a positive health, means in a known DEAD PANIC 1048 1060 * state and the adapter could be reset to `try again'. 1049 1061 */ 1050 - retval = aac_adapter_check_health(aac); 1051 - if (retval == 0) 1052 - retval = aac_adapter_sync_cmd(aac, IOP_RESET_ALWAYS, 1053 - 0, 0, 0, 0, 0, 0, &ret, NULL, NULL, NULL, NULL); 1054 - if (retval) 1055 - retval = aac_adapter_sync_cmd(aac, IOP_RESET, 1056 - 0, 0, 0, 0, 0, 0, &ret, NULL, NULL, NULL, NULL); 1062 + retval = aac_adapter_restart(aac, aac_adapter_check_health(aac)); 1057 1063 1058 1064 if (retval) 1059 1065 goto out; 1060 - if (ret != 0x00000001) { 1061 - retval = -ENODEV; 1062 - goto out; 1063 - } 1064 1066 1065 1067 /* 1066 1068 * Loop through the fibs, close the synchronous FIBS 1067 1069 */ 1068 - for (index = 0; index < (aac->scsi_host_ptr->can_queue + AAC_NUM_MGT_FIB); index++) { 1070 + for (retval = 1, index = 0; index < (aac->scsi_host_ptr->can_queue + AAC_NUM_MGT_FIB); index++) { 1069 1071 struct fib *fib = &aac->fibs[index]; 1070 - if (!(fib->hw_fib->header.XferState & cpu_to_le32(NoResponseExpected | Async)) && 1071 - (fib->hw_fib->header.XferState & cpu_to_le32(ResponseExpected))) { 1072 + if (!(fib->hw_fib_va->header.XferState & cpu_to_le32(NoResponseExpected | Async)) && 1073 + (fib->hw_fib_va->header.XferState & cpu_to_le32(ResponseExpected))) { 1072 1074 unsigned long flagv; 1073 1075 spin_lock_irqsave(&fib->event_lock, flagv); 1074 1076 up(&fib->event_wait); 1075 1077 spin_unlock_irqrestore(&fib->event_lock, flagv); 1076 1078 schedule(); 1079 + retval = 0; 1077 1080 } 1078 1081 } 1082 + /* Give some extra time for ioctls to complete. */ 1083 + if (retval == 0) 1084 + ssleep(2); 1079 1085 index = aac->cardtype; 1080 1086 1081 1087 /* ··· 1230 1248 1231 1249 memset(hw_fib, 0, sizeof(struct hw_fib)); 1232 1250 memset(fib, 0, sizeof(struct fib)); 1233 - fib->hw_fib = hw_fib; 1251 + fib->hw_fib_va = hw_fib; 1234 1252 fib->dev = aac; 1235 1253 aac_fib_init(fib); 1236 1254 fib->type = FSAFS_NTC_FIB_CONTEXT; ··· 1336 1354 * do anything at this point since we don't have 1337 1355 * anything defined for this thread to do. 1338 1356 */ 1339 - hw_fib = fib->hw_fib; 1357 + hw_fib = fib->hw_fib_va; 1340 1358 memset(fib, 0, sizeof(struct fib)); 1341 1359 fib->type = FSAFS_NTC_FIB_CONTEXT; 1342 1360 fib->size = sizeof( struct fib ); 1343 - fib->hw_fib = hw_fib; 1361 + fib->hw_fib_va = hw_fib; 1344 1362 fib->data = hw_fib->data; 1345 1363 fib->dev = dev; 1346 1364 /* ··· 1467 1485 */ 1468 1486 memcpy(hw_newfib, hw_fib, sizeof(struct hw_fib)); 1469 1487 memcpy(newfib, fib, sizeof(struct fib)); 1470 - newfib->hw_fib = hw_newfib; 1488 + newfib->hw_fib_va = hw_newfib; 1471 1489 /* 1472 1490 * Put the FIB onto the 1473 1491 * fibctx's fibs
+19 -16
drivers/scsi/aacraid/dpcsup.c
··· 5 5 * based on the old aacraid driver that is.. 6 6 * Adaptec aacraid device driver for Linux. 7 7 * 8 - * Copyright (c) 2000 Adaptec, Inc. (aacraid@adaptec.com) 8 + * Copyright (c) 2000-2007 Adaptec, Inc. (aacraid@adaptec.com) 9 9 * 10 10 * This program is free software; you can redistribute it and/or modify 11 11 * it under the terms of the GNU General Public License as published by ··· 72 72 u32 index = le32_to_cpu(entry->addr); 73 73 fast = index & 0x01; 74 74 fib = &dev->fibs[index >> 2]; 75 - hwfib = fib->hw_fib; 75 + hwfib = fib->hw_fib_va; 76 76 77 77 aac_consumer_free(dev, q, HostNormRespQueue); 78 78 /* ··· 83 83 * continue. The caller has already been notified that 84 84 * the fib timed out. 85 85 */ 86 - if (!(fib->flags & FIB_CONTEXT_FLAG_TIMED_OUT)) 87 - dev->queues->queue[AdapNormCmdQueue].numpending--; 88 - else { 89 - printk(KERN_WARNING "aacraid: FIB timeout (%x).\n", fib->flags); 90 - printk(KERN_DEBUG"aacraid: hwfib=%p fib index=%i fib=%p\n",hwfib, hwfib->header.SenderData,fib); 86 + dev->queues->queue[AdapNormCmdQueue].numpending--; 87 + 88 + if (unlikely(fib->flags & FIB_CONTEXT_FLAG_TIMED_OUT)) { 89 + spin_unlock_irqrestore(q->lock, flags); 90 + aac_fib_complete(fib); 91 + aac_fib_free(fib); 92 + spin_lock_irqsave(q->lock, flags); 91 93 continue; 92 94 } 93 95 spin_unlock_irqrestore(q->lock, flags); ··· 194 192 INIT_LIST_HEAD(&fib->fiblink); 195 193 fib->type = FSAFS_NTC_FIB_CONTEXT; 196 194 fib->size = sizeof(struct fib); 197 - fib->hw_fib = hw_fib; 195 + fib->hw_fib_va = hw_fib; 198 196 fib->data = hw_fib->data; 199 197 fib->dev = dev; 200 198 ··· 255 253 return 1; 256 254 } 257 255 memset(hw_fib, 0, sizeof(struct hw_fib)); 258 - memcpy(hw_fib, (struct hw_fib *)(((unsigned long)(dev->regs.sa)) + (index & ~0x00000002L)), sizeof(struct hw_fib)); 256 + memcpy(hw_fib, (struct hw_fib *)(((ptrdiff_t)(dev->regs.sa)) + 257 + (index & ~0x00000002L)), sizeof(struct hw_fib)); 259 258 memset(fib, 0, sizeof(struct fib)); 260 259 INIT_LIST_HEAD(&fib->fiblink); 261 260 fib->type = FSAFS_NTC_FIB_CONTEXT; 262 261 fib->size = sizeof(struct fib); 263 - fib->hw_fib = hw_fib; 262 + fib->hw_fib_va = hw_fib; 264 263 fib->data = hw_fib->data; 265 264 fib->dev = dev; 266 265 ··· 273 270 } else { 274 271 int fast = index & 0x01; 275 272 struct fib * fib = &dev->fibs[index >> 2]; 276 - struct hw_fib * hwfib = fib->hw_fib; 273 + struct hw_fib * hwfib = fib->hw_fib_va; 277 274 278 275 /* 279 276 * Remove this fib from the Outstanding I/O queue. ··· 283 280 * continue. The caller has already been notified that 284 281 * the fib timed out. 285 282 */ 286 - if ((fib->flags & FIB_CONTEXT_FLAG_TIMED_OUT)) { 287 - printk(KERN_WARNING "aacraid: FIB timeout (%x).\n", fib->flags); 288 - printk(KERN_DEBUG"aacraid: hwfib=%p index=%i fib=%p\n",hwfib, hwfib->header.SenderData,fib); 283 + dev->queues->queue[AdapNormCmdQueue].numpending--; 284 + 285 + if (unlikely(fib->flags & FIB_CONTEXT_FLAG_TIMED_OUT)) { 286 + aac_fib_complete(fib); 287 + aac_fib_free(fib); 289 288 return 0; 290 289 } 291 - 292 - dev->queues->queue[AdapNormCmdQueue].numpending--; 293 290 294 291 if (fast) { 295 292 /*
+59 -6
drivers/scsi/aacraid/linit.c
··· 5 5 * based on the old aacraid driver that is.. 6 6 * Adaptec aacraid device driver for Linux. 7 7 * 8 - * Copyright (c) 2000 Adaptec, Inc. (aacraid@adaptec.com) 8 + * Copyright (c) 2000-2007 Adaptec, Inc. (aacraid@adaptec.com) 9 9 * 10 10 * This program is free software; you can redistribute it and/or modify 11 11 * it under the terms of the GNU General Public License as published by ··· 81 81 static LIST_HEAD(aac_devices); 82 82 static int aac_cfg_major = -1; 83 83 char aac_driver_version[] = AAC_DRIVER_FULL_VERSION; 84 - 85 - extern int expose_physicals; 86 84 87 85 /* 88 86 * Because of the way Linux names scsi devices, the order in this table has ··· 245 247 246 248 static int aac_queuecommand(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)) 247 249 { 250 + struct Scsi_Host *host = cmd->device->host; 251 + struct aac_dev *dev = (struct aac_dev *)host->hostdata; 252 + u32 count = 0; 248 253 cmd->scsi_done = done; 254 + for (; count < (host->can_queue + AAC_NUM_MGT_FIB); ++count) { 255 + struct fib * fib = &dev->fibs[count]; 256 + struct scsi_cmnd * command; 257 + if (fib->hw_fib_va->header.XferState && 258 + ((command = fib->callback_data)) && 259 + (command == cmd) && 260 + (cmd->SCp.phase == AAC_OWNER_FIRMWARE)) 261 + return 0; /* Already owned by Adapter */ 262 + } 249 263 cmd->SCp.phase = AAC_OWNER_LOWLEVEL; 250 264 return (aac_scsi_cmd(cmd) ? FAILED : 0); 251 265 } ··· 456 446 return aac_do_ioctl(dev, cmd, arg); 457 447 } 458 448 449 + static int aac_eh_abort(struct scsi_cmnd* cmd) 450 + { 451 + struct scsi_device * dev = cmd->device; 452 + struct Scsi_Host * host = dev->host; 453 + struct aac_dev * aac = (struct aac_dev *)host->hostdata; 454 + int count; 455 + int ret = FAILED; 456 + 457 + printk(KERN_ERR "%s: Host adapter abort request (%d,%d,%d,%d)\n", 458 + AAC_DRIVERNAME, 459 + host->host_no, sdev_channel(dev), sdev_id(dev), dev->lun); 460 + switch (cmd->cmnd[0]) { 461 + case SERVICE_ACTION_IN: 462 + if (!(aac->raw_io_interface) || 463 + !(aac->raw_io_64) || 464 + ((cmd->cmnd[1] & 0x1f) != SAI_READ_CAPACITY_16)) 465 + break; 466 + case INQUIRY: 467 + case READ_CAPACITY: 468 + case TEST_UNIT_READY: 469 + /* Mark associated FIB to not complete, eh handler does this */ 470 + for (count = 0; count < (host->can_queue + AAC_NUM_MGT_FIB); ++count) { 471 + struct fib * fib = &aac->fibs[count]; 472 + if (fib->hw_fib_va->header.XferState && 473 + (fib->callback_data == cmd)) { 474 + fib->flags |= FIB_CONTEXT_FLAG_TIMED_OUT; 475 + cmd->SCp.phase = AAC_OWNER_ERROR_HANDLER; 476 + ret = SUCCESS; 477 + } 478 + } 479 + } 480 + return ret; 481 + } 482 + 459 483 /* 460 484 * aac_eh_reset - Reset command handling 461 485 * @scsi_cmd: SCSI command block causing the reset ··· 501 457 struct Scsi_Host * host = dev->host; 502 458 struct scsi_cmnd * command; 503 459 int count; 504 - struct aac_dev * aac; 460 + struct aac_dev * aac = (struct aac_dev *)host->hostdata; 505 461 unsigned long flags; 506 462 463 + /* Mark the associated FIB to not complete, eh handler does this */ 464 + for (count = 0; count < (host->can_queue + AAC_NUM_MGT_FIB); ++count) { 465 + struct fib * fib = &aac->fibs[count]; 466 + if (fib->hw_fib_va->header.XferState && 467 + (fib->callback_data == cmd)) { 468 + fib->flags |= FIB_CONTEXT_FLAG_TIMED_OUT; 469 + cmd->SCp.phase = AAC_OWNER_ERROR_HANDLER; 470 + } 471 + } 507 472 printk(KERN_ERR "%s: Host adapter reset request. SCSI hang ?\n", 508 473 AAC_DRIVERNAME); 509 - aac = (struct aac_dev *)host->hostdata; 510 474 511 475 if ((count = aac_check_health(aac))) 512 476 return count; ··· 548 496 ssleep(1); 549 497 } 550 498 printk(KERN_ERR "%s: SCSI bus appears hung\n", AAC_DRIVERNAME); 551 - return -ETIMEDOUT; 499 + return SUCCESS; /* Cause an immediate retry of the command with a ten second delay after successful tur */ 552 500 } 553 501 554 502 /** ··· 848 796 .bios_param = aac_biosparm, 849 797 .shost_attrs = aac_attrs, 850 798 .slave_configure = aac_slave_configure, 799 + .eh_abort_handler = aac_eh_abort, 851 800 .eh_host_reset_handler = aac_eh_reset, 852 801 .can_queue = AAC_NUM_IO_FIB, 853 802 .this_id = MAXIMUM_NUM_CONTAINERS,
-3
drivers/scsi/aacraid/nark.c
··· 74 74 75 75 int aac_nark_init(struct aac_dev * dev) 76 76 { 77 - extern int _aac_rx_init(struct aac_dev *dev); 78 - extern int aac_rx_select_comm(struct aac_dev *dev, int comm); 79 - 80 77 /* 81 78 * Fill in the function dispatch table. 82 79 */
-3
drivers/scsi/aacraid/rkt.c
··· 45 45 static int aac_rkt_select_comm(struct aac_dev *dev, int comm) 46 46 { 47 47 int retval; 48 - extern int aac_rx_select_comm(struct aac_dev *dev, int comm); 49 48 retval = aac_rx_select_comm(dev, comm); 50 49 if (comm == AAC_COMM_MESSAGE) { 51 50 /* ··· 96 97 97 98 int aac_rkt_init(struct aac_dev *dev) 98 99 { 99 - extern int _aac_rx_init(struct aac_dev *dev); 100 - 101 100 /* 102 101 * Fill in the function dispatch table. 103 102 */
+71 -42
drivers/scsi/aacraid/rx.c
··· 5 5 * based on the old aacraid driver that is.. 6 6 * Adaptec aacraid device driver for Linux. 7 7 * 8 - * Copyright (c) 2000 Adaptec, Inc. (aacraid@adaptec.com) 8 + * Copyright (c) 2000-2007 Adaptec, Inc. (aacraid@adaptec.com) 9 9 * 10 10 * This program is free software; you can redistribute it and/or modify 11 11 * it under the terms of the GNU General Public License as published by ··· 57 57 * been enabled. 58 58 * Check to see if this is our interrupt. If it isn't just return 59 59 */ 60 - if (intstat & ~(dev->OIMR)) { 60 + if (likely(intstat & ~(dev->OIMR))) { 61 61 bellbits = rx_readl(dev, OutboundDoorbellReg); 62 - if (bellbits & DoorBellPrintfReady) { 62 + if (unlikely(bellbits & DoorBellPrintfReady)) { 63 63 aac_printf(dev, readl (&dev->IndexRegs->Mailbox[5])); 64 64 rx_writel(dev, MUnit.ODR,DoorBellPrintfReady); 65 65 rx_writel(dev, InboundDoorbellReg,DoorBellPrintfDone); 66 66 } 67 - else if (bellbits & DoorBellAdapterNormCmdReady) { 67 + else if (unlikely(bellbits & DoorBellAdapterNormCmdReady)) { 68 68 rx_writel(dev, MUnit.ODR, DoorBellAdapterNormCmdReady); 69 69 aac_command_normal(&dev->queues->queue[HostNormCmdQueue]); 70 70 } 71 - else if (bellbits & DoorBellAdapterNormRespReady) { 71 + else if (likely(bellbits & DoorBellAdapterNormRespReady)) { 72 72 rx_writel(dev, MUnit.ODR,DoorBellAdapterNormRespReady); 73 73 aac_response_normal(&dev->queues->queue[HostNormRespQueue]); 74 74 } 75 - else if (bellbits & DoorBellAdapterNormCmdNotFull) { 75 + else if (unlikely(bellbits & DoorBellAdapterNormCmdNotFull)) { 76 76 rx_writel(dev, MUnit.ODR, DoorBellAdapterNormCmdNotFull); 77 77 } 78 - else if (bellbits & DoorBellAdapterNormRespNotFull) { 78 + else if (unlikely(bellbits & DoorBellAdapterNormRespNotFull)) { 79 79 rx_writel(dev, MUnit.ODR, DoorBellAdapterNormCmdNotFull); 80 80 rx_writel(dev, MUnit.ODR, DoorBellAdapterNormRespNotFull); 81 81 } ··· 88 88 { 89 89 struct aac_dev *dev = dev_id; 90 90 u32 Index = rx_readl(dev, MUnit.OutboundQueue); 91 - if (Index == 0xFFFFFFFFL) 91 + if (unlikely(Index == 0xFFFFFFFFL)) 92 92 Index = rx_readl(dev, MUnit.OutboundQueue); 93 - if (Index != 0xFFFFFFFFL) { 93 + if (likely(Index != 0xFFFFFFFFL)) { 94 94 do { 95 - if (aac_intr_normal(dev, Index)) { 95 + if (unlikely(aac_intr_normal(dev, Index))) { 96 96 rx_writel(dev, MUnit.OutboundQueue, Index); 97 97 rx_writel(dev, MUnit.ODR, DoorBellAdapterNormRespReady); 98 98 } ··· 204 204 */ 205 205 msleep(1); 206 206 } 207 - if (ok != 1) { 207 + if (unlikely(ok != 1)) { 208 208 /* 209 209 * Restore interrupt mask even though we timed out 210 210 */ ··· 294 294 * Start up processing on an i960 based AAC adapter 295 295 */ 296 296 297 - void aac_rx_start_adapter(struct aac_dev *dev) 297 + static void aac_rx_start_adapter(struct aac_dev *dev) 298 298 { 299 299 struct aac_init *init; 300 300 ··· 319 319 /* 320 320 * Check to see if the board failed any self tests. 321 321 */ 322 - if (status & SELF_TEST_FAILED) 322 + if (unlikely(status & SELF_TEST_FAILED)) 323 323 return -1; 324 324 /* 325 325 * Check to see if the board panic'd. 326 326 */ 327 - if (status & KERNEL_PANIC) { 327 + if (unlikely(status & KERNEL_PANIC)) { 328 328 char * buffer; 329 329 struct POSTSTATUS { 330 330 __le32 Post_Command; ··· 333 333 dma_addr_t paddr, baddr; 334 334 int ret; 335 335 336 - if ((status & 0xFF000000L) == 0xBC000000L) 336 + if (likely((status & 0xFF000000L) == 0xBC000000L)) 337 337 return (status >> 16) & 0xFF; 338 338 buffer = pci_alloc_consistent(dev->pdev, 512, &baddr); 339 339 ret = -2; 340 - if (buffer == NULL) 340 + if (unlikely(buffer == NULL)) 341 341 return ret; 342 342 post = pci_alloc_consistent(dev->pdev, 343 343 sizeof(struct POSTSTATUS), &paddr); 344 - if (post == NULL) { 344 + if (unlikely(post == NULL)) { 345 345 pci_free_consistent(dev->pdev, 512, buffer, baddr); 346 346 return ret; 347 347 } ··· 353 353 NULL, NULL, NULL, NULL, NULL); 354 354 pci_free_consistent(dev->pdev, sizeof(struct POSTSTATUS), 355 355 post, paddr); 356 - if ((buffer[0] == '0') && ((buffer[1] == 'x') || (buffer[1] == 'X'))) { 356 + if (likely((buffer[0] == '0') && ((buffer[1] == 'x') || (buffer[1] == 'X')))) { 357 357 ret = (buffer[2] <= '9') ? (buffer[2] - '0') : (buffer[2] - 'A' + 10); 358 358 ret <<= 4; 359 359 ret += (buffer[3] <= '9') ? (buffer[3] - '0') : (buffer[3] - 'A' + 10); ··· 364 364 /* 365 365 * Wait for the adapter to be up and running. 366 366 */ 367 - if (!(status & KERNEL_UP_AND_RUNNING)) 367 + if (unlikely(!(status & KERNEL_UP_AND_RUNNING))) 368 368 return -3; 369 369 /* 370 370 * Everything is OK ··· 387 387 unsigned long nointr = 0; 388 388 389 389 spin_lock_irqsave(q->lock, qflags); 390 - aac_queue_get( dev, &Index, AdapNormCmdQueue, fib->hw_fib, 1, fib, &nointr); 390 + aac_queue_get( dev, &Index, AdapNormCmdQueue, fib->hw_fib_va, 1, fib, &nointr); 391 391 392 392 q->numpending++; 393 393 *(q->headers.producer) = cpu_to_le32(Index + 1); ··· 419 419 spin_unlock_irqrestore(q->lock, qflags); 420 420 for(;;) { 421 421 Index = rx_readl(dev, MUnit.InboundQueue); 422 - if (Index == 0xFFFFFFFFL) 422 + if (unlikely(Index == 0xFFFFFFFFL)) 423 423 Index = rx_readl(dev, MUnit.InboundQueue); 424 - if (Index != 0xFFFFFFFFL) 424 + if (likely(Index != 0xFFFFFFFFL)) 425 425 break; 426 426 if (--count == 0) { 427 427 spin_lock_irqsave(q->lock, qflags); ··· 437 437 device += sizeof(u32); 438 438 writel((u32)(addr >> 32), device); 439 439 device += sizeof(u32); 440 - writel(le16_to_cpu(fib->hw_fib->header.Size), device); 440 + writel(le16_to_cpu(fib->hw_fib_va->header.Size), device); 441 441 rx_writel(dev, MUnit.InboundQueue, Index); 442 442 return 0; 443 443 } ··· 460 460 return 0; 461 461 } 462 462 463 - static int aac_rx_restart_adapter(struct aac_dev *dev) 463 + static int aac_rx_restart_adapter(struct aac_dev *dev, int bled) 464 464 { 465 465 u32 var; 466 466 467 - printk(KERN_ERR "%s%d: adapter kernel panic'd.\n", 468 - dev->name, dev->id); 467 + if (bled) 468 + printk(KERN_ERR "%s%d: adapter kernel panic'd %x.\n", 469 + dev->name, dev->id, bled); 470 + else { 471 + bled = aac_adapter_sync_cmd(dev, IOP_RESET_ALWAYS, 472 + 0, 0, 0, 0, 0, 0, &var, NULL, NULL, NULL, NULL); 473 + if (!bled && (var != 0x00000001)) 474 + bled = -EINVAL; 475 + } 476 + if (bled && (bled != -ETIMEDOUT)) 477 + bled = aac_adapter_sync_cmd(dev, IOP_RESET, 478 + 0, 0, 0, 0, 0, 0, &var, NULL, NULL, NULL, NULL); 469 479 470 - if (aac_rx_check_health(dev) <= 0) 471 - return 1; 472 - if (rx_sync_cmd(dev, IOP_RESET, 0, 0, 0, 0, 0, 0, 473 - &var, NULL, NULL, NULL, NULL)) 474 - return 1; 480 + if (bled && (bled != -ETIMEDOUT)) 481 + return -EINVAL; 482 + if (bled || (var == 0x3803000F)) { /* USE_OTHER_METHOD */ 483 + rx_writel(dev, MUnit.reserved2, 3); 484 + msleep(5000); /* Delay 5 seconds */ 485 + var = 0x00000001; 486 + } 475 487 if (var != 0x00000001) 476 - return 1; 488 + return -EINVAL; 477 489 if (rx_readl(dev, MUnit.OMRx[0]) & KERNEL_PANIC) 478 - return 1; 490 + return -ENODEV; 479 491 return 0; 480 492 } 481 493 ··· 529 517 { 530 518 unsigned long start; 531 519 unsigned long status; 532 - int instance; 533 - const char * name; 534 - 535 - instance = dev->id; 536 - name = dev->name; 520 + int restart = 0; 521 + int instance = dev->id; 522 + const char * name = dev->name; 537 523 538 524 if (aac_adapter_ioremap(dev, dev->base_size)) { 539 525 printk(KERN_WARNING "%s: unable to map adapter.\n", name); 540 526 goto error_iounmap; 541 527 } 542 528 529 + /* Failure to reset here is an option ... */ 530 + dev->OIMR = status = rx_readb (dev, MUnit.OIMR); 531 + if ((((status & 0xff) != 0xff) || reset_devices) && 532 + !aac_rx_restart_adapter(dev, 0)) 533 + ++restart; 543 534 /* 544 535 * Check to see if the board panic'd while booting. 545 536 */ 546 537 status = rx_readl(dev, MUnit.OMRx[0]); 547 - if (status & KERNEL_PANIC) 548 - if (aac_rx_restart_adapter(dev)) 538 + if (status & KERNEL_PANIC) { 539 + if (aac_rx_restart_adapter(dev, aac_rx_check_health(dev))) 549 540 goto error_iounmap; 541 + ++restart; 542 + } 550 543 /* 551 544 * Check to see if the board failed any self tests. 552 545 */ ··· 573 556 */ 574 557 while (!((status = rx_readl(dev, MUnit.OMRx[0])) & KERNEL_UP_AND_RUNNING)) 575 558 { 576 - if(time_after(jiffies, start+startup_timeout*HZ)) 577 - { 559 + if ((restart && 560 + (status & (KERNEL_PANIC|SELF_TEST_FAILED|MONITOR_PANIC))) || 561 + time_after(jiffies, start+HZ*startup_timeout)) { 578 562 printk(KERN_ERR "%s%d: adapter kernel failed to start, init status = %lx.\n", 579 563 dev->name, instance, status); 580 564 goto error_iounmap; 565 + } 566 + if (!restart && 567 + ((status & (KERNEL_PANIC|SELF_TEST_FAILED|MONITOR_PANIC)) || 568 + time_after(jiffies, start + HZ * 569 + ((startup_timeout > 60) 570 + ? (startup_timeout - 60) 571 + : (startup_timeout / 2))))) { 572 + if (likely(!aac_rx_restart_adapter(dev, aac_rx_check_health(dev)))) 573 + start = jiffies; 574 + ++restart; 581 575 } 582 576 msleep(1); 583 577 } ··· 600 572 dev->a_ops.adapter_notify = aac_rx_notify_adapter; 601 573 dev->a_ops.adapter_sync_cmd = rx_sync_cmd; 602 574 dev->a_ops.adapter_check_health = aac_rx_check_health; 575 + dev->a_ops.adapter_restart = aac_rx_restart_adapter; 603 576 604 577 /* 605 578 * First clear out all interrupts. Then enable the one's that we
-12
drivers/scsi/aic7xxx/Kconfig.aic79xx
··· 57 57 or modify the assembler Makefile or the files it includes if your 58 58 build environment is different than that of the author. 59 59 60 - config AIC79XX_ENABLE_RD_STRM 61 - bool "Enable Read Streaming for All Targets" 62 - depends on SCSI_AIC79XX 63 - default n 64 - help 65 - Read Streaming is a U320 protocol option that should enhance 66 - performance. Early U320 drive firmware actually performs slower 67 - with read streaming enabled so it is disabled by default. Read 68 - Streaming can be configured in much the same way as tagged queueing 69 - using the "rd_strm" command line option. See 70 - drivers/scsi/aic7xxx/README.aic79xx for details. 71 - 72 60 config AIC79XX_DEBUG_ENABLE 73 61 bool "Compile in Debugging Code" 74 62 depends on SCSI_AIC79XX
-10
drivers/scsi/aic7xxx/Kconfig.aic7xxx
··· 50 50 51 51 Default: 5000 (5 seconds) 52 52 53 - config AIC7XXX_PROBE_EISA_VL 54 - bool "Probe for EISA and VL AIC7XXX Adapters" 55 - depends on SCSI_AIC7XXX && EISA 56 - help 57 - Probe for EISA and VLB Aic7xxx controllers. In many newer systems, 58 - the invasive probes necessary to detect these controllers can cause 59 - other devices to fail. For this reason, the non-PCI probe code is 60 - disabled by default. The current value of this option can be "toggled" 61 - via the no_probe kernel command line option. 62 - 63 53 config AIC7XXX_BUILD_FIRMWARE 64 54 bool "Build Adapter Firmware with Kernel Build" 65 55 depends on SCSI_AIC7XXX && !PREVENT_FIRMWARE_BUILD
+4 -2
drivers/scsi/aic7xxx/aic79xx_osm.c
··· 363 363 struct scsi_cmnd *); 364 364 static void ahd_linux_setup_tag_info_global(char *p); 365 365 static int aic79xx_setup(char *c); 366 + static void ahd_freeze_simq(struct ahd_softc *ahd); 367 + static void ahd_release_simq(struct ahd_softc *ahd); 366 368 367 369 static int ahd_linux_unit; 368 370 ··· 2018 2016 cmd->scsi_done(cmd); 2019 2017 } 2020 2018 2021 - void 2019 + static void 2022 2020 ahd_freeze_simq(struct ahd_softc *ahd) 2023 2021 { 2024 2022 scsi_block_requests(ahd->platform_data->host); 2025 2023 } 2026 2024 2027 - void 2025 + static void 2028 2026 ahd_release_simq(struct ahd_softc *ahd) 2029 2027 { 2030 2028 scsi_unblock_requests(ahd->platform_data->host);
-2
drivers/scsi/aic7xxx/aic79xx_osm.h
··· 837 837 void ahd_platform_free(struct ahd_softc *ahd); 838 838 void ahd_platform_init(struct ahd_softc *ahd); 839 839 void ahd_platform_freeze_devq(struct ahd_softc *ahd, struct scb *scb); 840 - void ahd_freeze_simq(struct ahd_softc *ahd); 841 - void ahd_release_simq(struct ahd_softc *ahd); 842 840 843 841 static __inline void 844 842 ahd_freeze_scb(struct scb *scb)
-5
drivers/scsi/aic7xxx/aic7xxx.h
··· 1278 1278 AHC_QUEUE_TAGGED 1279 1279 } ahc_queue_alg; 1280 1280 1281 - void ahc_set_tags(struct ahc_softc *ahc, 1282 - struct scsi_cmnd *cmd, 1283 - struct ahc_devinfo *devinfo, 1284 - ahc_queue_alg alg); 1285 - 1286 1281 /**************************** Target Mode *************************************/ 1287 1282 #ifdef AHC_TARGET_MODE 1288 1283 void ahc_send_lstate_events(struct ahc_softc *,
+1 -1
drivers/scsi/aic7xxx/aic7xxx_core.c
··· 2073 2073 /* 2074 2074 * Update the current state of tagged queuing for a given target. 2075 2075 */ 2076 - void 2076 + static void 2077 2077 ahc_set_tags(struct ahc_softc *ahc, struct scsi_cmnd *cmd, 2078 2078 struct ahc_devinfo *devinfo, ahc_queue_alg alg) 2079 2079 {
+151 -123
drivers/scsi/constants.c
··· 202 202 } 203 203 204 204 /* attempt to guess cdb length if cdb_len==0 . No trailing linefeed. */ 205 - static void print_opcode_name(unsigned char * cdbp, int cdb_len, 206 - int start_of_line) 205 + static void print_opcode_name(unsigned char * cdbp, int cdb_len) 207 206 { 208 207 int sa, len, cdb0; 209 208 const char * name; 210 - const char * leadin = start_of_line ? KERN_INFO : ""; 211 209 212 210 cdb0 = cdbp[0]; 213 211 switch(cdb0) { 214 212 case VARIABLE_LENGTH_CMD: 215 213 len = cdbp[7] + 8; 216 214 if (len < 10) { 217 - printk("%sshort variable length command, " 218 - "len=%d ext_len=%d", leadin, len, cdb_len); 215 + printk("short variable length command, " 216 + "len=%d ext_len=%d", len, cdb_len); 219 217 break; 220 218 } 221 219 sa = (cdbp[8] << 8) + cdbp[9]; 222 220 name = get_sa_name(maint_in_arr, MAINT_IN_SZ, sa); 223 221 if (name) { 224 - printk("%s%s", leadin, name); 222 + printk("%s", name); 225 223 if ((cdb_len > 0) && (len != cdb_len)) 226 224 printk(", in_cdb_len=%d, ext_len=%d", 227 225 len, cdb_len); 228 226 } else { 229 - printk("%scdb[0]=0x%x, sa=0x%x", leadin, cdb0, sa); 227 + printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa); 230 228 if ((cdb_len > 0) && (len != cdb_len)) 231 229 printk(", in_cdb_len=%d, ext_len=%d", 232 230 len, cdb_len); ··· 234 236 sa = cdbp[1] & 0x1f; 235 237 name = get_sa_name(maint_in_arr, MAINT_IN_SZ, sa); 236 238 if (name) 237 - printk("%s%s", leadin, name); 239 + printk("%s", name); 238 240 else 239 - printk("%scdb[0]=0x%x, sa=0x%x", leadin, cdb0, sa); 241 + printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa); 240 242 break; 241 243 case MAINTENANCE_OUT: 242 244 sa = cdbp[1] & 0x1f; 243 245 name = get_sa_name(maint_out_arr, MAINT_OUT_SZ, sa); 244 246 if (name) 245 - printk("%s%s", leadin, name); 247 + printk("%s", name); 246 248 else 247 - printk("%scdb[0]=0x%x, sa=0x%x", leadin, cdb0, sa); 249 + printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa); 248 250 break; 249 251 case SERVICE_ACTION_IN_12: 250 252 sa = cdbp[1] & 0x1f; 251 253 name = get_sa_name(serv_in12_arr, SERV_IN12_SZ, sa); 252 254 if (name) 253 - printk("%s%s", leadin, name); 255 + printk("%s", name); 254 256 else 255 - printk("%scdb[0]=0x%x, sa=0x%x", leadin, cdb0, sa); 257 + printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa); 256 258 break; 257 259 case SERVICE_ACTION_OUT_12: 258 260 sa = cdbp[1] & 0x1f; 259 261 name = get_sa_name(serv_out12_arr, SERV_OUT12_SZ, sa); 260 262 if (name) 261 - printk("%s%s", leadin, name); 263 + printk("%s", name); 262 264 else 263 - printk("%scdb[0]=0x%x, sa=0x%x", leadin, cdb0, sa); 265 + printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa); 264 266 break; 265 267 case SERVICE_ACTION_IN_16: 266 268 sa = cdbp[1] & 0x1f; 267 269 name = get_sa_name(serv_in16_arr, SERV_IN16_SZ, sa); 268 270 if (name) 269 - printk("%s%s", leadin, name); 271 + printk("%s", name); 270 272 else 271 - printk("%scdb[0]=0x%x, sa=0x%x", leadin, cdb0, sa); 273 + printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa); 272 274 break; 273 275 case SERVICE_ACTION_OUT_16: 274 276 sa = cdbp[1] & 0x1f; 275 277 name = get_sa_name(serv_out16_arr, SERV_OUT16_SZ, sa); 276 278 if (name) 277 - printk("%s%s", leadin, name); 279 + printk("%s", name); 278 280 else 279 - printk("%scdb[0]=0x%x, sa=0x%x", leadin, cdb0, sa); 281 + printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa); 280 282 break; 281 283 default: 282 284 if (cdb0 < 0xc0) { 283 285 name = cdb_byte0_names[cdb0]; 284 286 if (name) 285 - printk("%s%s", leadin, name); 287 + printk("%s", name); 286 288 else 287 - printk("%scdb[0]=0x%x (reserved)", 288 - leadin, cdb0); 289 + printk("cdb[0]=0x%x (reserved)", cdb0); 289 290 } else 290 - printk("%scdb[0]=0x%x (vendor)", leadin, cdb0); 291 + printk("cdb[0]=0x%x (vendor)", cdb0); 291 292 break; 292 293 } 293 294 } 294 295 295 296 #else /* ifndef CONFIG_SCSI_CONSTANTS */ 296 297 297 - static void print_opcode_name(unsigned char * cdbp, int cdb_len, 298 - int start_of_line) 298 + static void print_opcode_name(unsigned char * cdbp, int cdb_len) 299 299 { 300 300 int sa, len, cdb0; 301 - const char * leadin = start_of_line ? KERN_INFO : ""; 302 301 303 302 cdb0 = cdbp[0]; 304 303 switch(cdb0) { 305 304 case VARIABLE_LENGTH_CMD: 306 305 len = cdbp[7] + 8; 307 306 if (len < 10) { 308 - printk("%sshort opcode=0x%x command, len=%d " 309 - "ext_len=%d", leadin, cdb0, len, cdb_len); 307 + printk("short opcode=0x%x command, len=%d " 308 + "ext_len=%d", cdb0, len, cdb_len); 310 309 break; 311 310 } 312 311 sa = (cdbp[8] << 8) + cdbp[9]; 313 - printk("%scdb[0]=0x%x, sa=0x%x", leadin, cdb0, sa); 312 + printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa); 314 313 if (len != cdb_len) 315 314 printk(", in_cdb_len=%d, ext_len=%d", len, cdb_len); 316 315 break; ··· 318 323 case SERVICE_ACTION_IN_16: 319 324 case SERVICE_ACTION_OUT_16: 320 325 sa = cdbp[1] & 0x1f; 321 - printk("%scdb[0]=0x%x, sa=0x%x", leadin, cdb0, sa); 326 + printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa); 322 327 break; 323 328 default: 324 329 if (cdb0 < 0xc0) 325 - printk("%scdb[0]=0x%x", leadin, cdb0); 330 + printk("cdb[0]=0x%x", cdb0); 326 331 else 327 - printk("%scdb[0]=0x%x (vendor)", leadin, cdb0); 332 + printk("cdb[0]=0x%x (vendor)", cdb0); 328 333 break; 329 334 } 330 335 } 331 336 #endif 332 337 333 - void __scsi_print_command(unsigned char *command) 338 + void __scsi_print_command(unsigned char *cdb) 334 339 { 335 340 int k, len; 336 341 337 - print_opcode_name(command, 0, 1); 338 - if (VARIABLE_LENGTH_CMD == command[0]) 339 - len = command[7] + 8; 342 + print_opcode_name(cdb, 0); 343 + if (VARIABLE_LENGTH_CMD == cdb[0]) 344 + len = cdb[7] + 8; 340 345 else 341 - len = COMMAND_SIZE(command[0]); 346 + len = COMMAND_SIZE(cdb[0]); 342 347 /* print out all bytes in cdb */ 343 348 for (k = 0; k < len; ++k) 344 - printk(" %02x", command[k]); 349 + printk(" %02x", cdb[k]); 345 350 printk("\n"); 346 351 } 347 352 EXPORT_SYMBOL(__scsi_print_command); 348 353 349 - /* This function (perhaps with the addition of peripheral device type) 350 - * is more approriate than __scsi_print_command(). Perhaps that static 351 - * can be dropped later if it replaces the __scsi_print_command version. 352 - */ 353 - static void scsi_print_cdb(unsigned char *cdb, int cdb_len, int start_of_line) 354 + void scsi_print_command(struct scsi_cmnd *cmd) 354 355 { 355 356 int k; 356 357 357 - print_opcode_name(cdb, cdb_len, start_of_line); 358 + scmd_printk(KERN_INFO, cmd, "CDB: "); 359 + print_opcode_name(cmd->cmnd, cmd->cmd_len); 360 + 358 361 /* print out all bytes in cdb */ 359 362 printk(":"); 360 - for (k = 0; k < cdb_len; ++k) 361 - printk(" %02x", cdb[k]); 363 + for (k = 0; k < cmd->cmd_len; ++k) 364 + printk(" %02x", cmd->cmnd[k]); 362 365 printk("\n"); 363 366 } 367 + EXPORT_SYMBOL(scsi_print_command); 364 368 365 369 /** 366 370 * ··· 404 410 const char * text; 405 411 }; 406 412 407 - static struct error_info additional[] = 413 + /* 414 + * The canonical list of T10 Additional Sense Codes is available at: 415 + * http://www.t10.org/lists/asc-num.txt 416 + */ 417 + static const struct error_info additional[] = 408 418 { 409 419 {0x0000, "No additional sense information"}, 410 420 {0x0001, "Filemark detected"}, ··· 712 714 713 715 {0x2F00, "Commands cleared by another initiator"}, 714 716 {0x2F01, "Commands cleared by power loss notification"}, 717 + {0x2F02, "Commands cleared by device server"}, 715 718 716 719 {0x3000, "Incompatible medium installed"}, 717 720 {0x3001, "Cannot read medium - unknown format"}, ··· 1175 1176 } 1176 1177 EXPORT_SYMBOL(scsi_extd_sense_format); 1177 1178 1178 - /* Print extended sense information; no leadin, no linefeed */ 1179 - static void 1179 + void 1180 1180 scsi_show_extd_sense(unsigned char asc, unsigned char ascq) 1181 1181 { 1182 - const char *extd_sense_fmt = scsi_extd_sense_format(asc, ascq); 1182 + const char *extd_sense_fmt = scsi_extd_sense_format(asc, ascq); 1183 1183 1184 1184 if (extd_sense_fmt) { 1185 1185 if (strstr(extd_sense_fmt, "%x")) { 1186 - printk("Additional sense: "); 1186 + printk("Add. Sense: "); 1187 1187 printk(extd_sense_fmt, ascq); 1188 1188 } else 1189 - printk("Additional sense: %s", extd_sense_fmt); 1189 + printk("Add. Sense: %s", extd_sense_fmt); 1190 1190 } else { 1191 1191 if (asc >= 0x80) 1192 - printk("<<vendor>> ASC=0x%x ASCQ=0x%x", asc, ascq); 1192 + printk("<<vendor>> ASC=0x%x ASCQ=0x%x", asc, 1193 + ascq); 1193 1194 if (ascq >= 0x80) 1194 - printk("ASC=0x%x <<vendor>> ASCQ=0x%x", asc, ascq); 1195 + printk("ASC=0x%x <<vendor>> ASCQ=0x%x", asc, 1196 + ascq); 1195 1197 else 1196 1198 printk("ASC=0x%x ASCQ=0x%x", asc, ascq); 1197 1199 } 1200 + 1201 + printk("\n"); 1198 1202 } 1203 + EXPORT_SYMBOL(scsi_show_extd_sense); 1199 1204 1200 1205 void 1201 - scsi_print_sense_hdr(const char *name, struct scsi_sense_hdr *sshdr) 1206 + scsi_show_sense_hdr(struct scsi_sense_hdr *sshdr) 1202 1207 { 1203 1208 const char *sense_txt; 1204 - /* An example of deferred is when an earlier write to disk cache 1205 - * succeeded, but now the disk discovers that it cannot write the 1206 - * data to the magnetic media. 1207 - */ 1208 - const char *error = scsi_sense_is_deferred(sshdr) ? 1209 - "<<DEFERRED>>" : "Current"; 1210 - printk(KERN_INFO "%s: %s", name, error); 1211 - if (sshdr->response_code >= 0x72) 1212 - printk(" [descriptor]"); 1213 1209 1214 1210 sense_txt = scsi_sense_key_string(sshdr->sense_key); 1215 1211 if (sense_txt) 1216 - printk(": sense key: %s\n", sense_txt); 1212 + printk("Sense Key : %s ", sense_txt); 1217 1213 else 1218 - printk(": sense key=0x%x\n", sshdr->sense_key); 1219 - printk(KERN_INFO " "); 1220 - scsi_show_extd_sense(sshdr->asc, sshdr->ascq); 1214 + printk("Sense Key : 0x%x ", sshdr->sense_key); 1215 + 1216 + printk("%s", scsi_sense_is_deferred(sshdr) ? "[deferred] " : 1217 + "[current] "); 1218 + 1219 + if (sshdr->response_code >= 0x72) 1220 + printk("[descriptor]"); 1221 + 1221 1222 printk("\n"); 1223 + } 1224 + EXPORT_SYMBOL(scsi_show_sense_hdr); 1225 + 1226 + /* 1227 + * Print normalized SCSI sense header with a prefix. 1228 + */ 1229 + void 1230 + scsi_print_sense_hdr(const char *name, struct scsi_sense_hdr *sshdr) 1231 + { 1232 + printk(KERN_INFO "%s: ", name); 1233 + scsi_show_sense_hdr(sshdr); 1234 + printk(KERN_INFO "%s: ", name); 1235 + scsi_show_extd_sense(sshdr->asc, sshdr->ascq); 1222 1236 } 1223 1237 EXPORT_SYMBOL(scsi_print_sense_hdr); 1224 1238 1225 - /* Print sense information */ 1226 1239 void 1227 - __scsi_print_sense(const char *name, const unsigned char *sense_buffer, 1228 - int sense_len) 1240 + scsi_decode_sense_buffer(const unsigned char *sense_buffer, int sense_len, 1241 + struct scsi_sense_hdr *sshdr) 1229 1242 { 1230 1243 int k, num, res; 1231 - unsigned int info; 1232 - struct scsi_sense_hdr ssh; 1233 1244 1234 - res = scsi_normalize_sense(sense_buffer, sense_len, &ssh); 1245 + res = scsi_normalize_sense(sense_buffer, sense_len, sshdr); 1235 1246 if (0 == res) { 1236 1247 /* this may be SCSI-1 sense data */ 1237 1248 num = (sense_len < 32) ? sense_len : 32; 1238 - printk(KERN_INFO "Unrecognized sense data (in hex):"); 1249 + printk("Unrecognized sense data (in hex):"); 1239 1250 for (k = 0; k < num; ++k) { 1240 1251 if (0 == (k % 16)) { 1241 1252 printk("\n"); ··· 1256 1247 printk("\n"); 1257 1248 return; 1258 1249 } 1259 - scsi_print_sense_hdr(name, &ssh); 1260 - if (ssh.response_code < 0x72) { 1250 + } 1251 + 1252 + void 1253 + scsi_decode_sense_extras(const unsigned char *sense_buffer, int sense_len, 1254 + struct scsi_sense_hdr *sshdr) 1255 + { 1256 + int k, num, res; 1257 + 1258 + if (sshdr->response_code < 0x72) 1259 + { 1261 1260 /* only decode extras for "fixed" format now */ 1262 1261 char buff[80]; 1263 1262 int blen, fixed_valid; 1263 + unsigned int info; 1264 1264 1265 1265 fixed_valid = sense_buffer[0] & 0x80; 1266 1266 info = ((sense_buffer[3] << 24) | (sense_buffer[4] << 16) | ··· 1299 1281 res += snprintf(buff + res, blen - res, "ILI"); 1300 1282 } 1301 1283 if (res > 0) 1302 - printk(KERN_INFO "%s\n", buff); 1303 - } else if (ssh.additional_length > 0) { 1284 + printk("%s\n", buff); 1285 + } else if (sshdr->additional_length > 0) { 1304 1286 /* descriptor format with sense descriptors */ 1305 - num = 8 + ssh.additional_length; 1287 + num = 8 + sshdr->additional_length; 1306 1288 num = (sense_len < num) ? sense_len : num; 1307 - printk(KERN_INFO "Descriptor sense data with sense " 1308 - "descriptors (in hex):"); 1289 + printk("Descriptor sense data with sense descriptors " 1290 + "(in hex):"); 1309 1291 for (k = 0; k < num; ++k) { 1310 1292 if (0 == (k % 16)) { 1311 1293 printk("\n"); ··· 1313 1295 } 1314 1296 printk("%02x ", sense_buffer[k]); 1315 1297 } 1298 + 1316 1299 printk("\n"); 1317 1300 } 1301 + 1302 + } 1303 + 1304 + /* Normalize and print sense buffer with name prefix */ 1305 + void __scsi_print_sense(const char *name, const unsigned char *sense_buffer, 1306 + int sense_len) 1307 + { 1308 + struct scsi_sense_hdr sshdr; 1309 + 1310 + printk(KERN_INFO "%s: ", name); 1311 + scsi_decode_sense_buffer(sense_buffer, sense_len, &sshdr); 1312 + scsi_show_sense_hdr(&sshdr); 1313 + scsi_decode_sense_extras(sense_buffer, sense_len, &sshdr); 1314 + printk(KERN_INFO "%s: ", name); 1315 + scsi_show_extd_sense(sshdr.asc, sshdr.ascq); 1318 1316 } 1319 1317 EXPORT_SYMBOL(__scsi_print_sense); 1320 1318 1321 - void scsi_print_sense(const char *devclass, struct scsi_cmnd *cmd) 1319 + /* Normalize and print sense buffer in SCSI command */ 1320 + void scsi_print_sense(char *name, struct scsi_cmnd *cmd) 1322 1321 { 1323 - const char *name = devclass; 1322 + struct scsi_sense_hdr sshdr; 1324 1323 1325 - if (cmd->request->rq_disk) 1326 - name = cmd->request->rq_disk->disk_name; 1327 - __scsi_print_sense(name, cmd->sense_buffer, SCSI_SENSE_BUFFERSIZE); 1324 + scmd_printk(KERN_INFO, cmd, ""); 1325 + scsi_decode_sense_buffer(cmd->sense_buffer, SCSI_SENSE_BUFFERSIZE, 1326 + &sshdr); 1327 + scsi_show_sense_hdr(&sshdr); 1328 + scsi_decode_sense_extras(cmd->sense_buffer, SCSI_SENSE_BUFFERSIZE, 1329 + &sshdr); 1330 + scmd_printk(KERN_INFO, cmd, ""); 1331 + scsi_show_extd_sense(sshdr.asc, sshdr.ascq); 1328 1332 } 1329 1333 EXPORT_SYMBOL(scsi_print_sense); 1330 - 1331 - void scsi_print_command(struct scsi_cmnd *cmd) 1332 - { 1333 - /* Assume appended output (i.e. not at start of line) */ 1334 - sdev_printk("", cmd->device, "\n"); 1335 - printk(KERN_INFO " command: "); 1336 - scsi_print_cdb(cmd->cmnd, cmd->cmd_len, 0); 1337 - } 1338 - EXPORT_SYMBOL(scsi_print_command); 1339 1334 1340 1335 #ifdef CONFIG_SCSI_CONSTANTS 1341 1336 ··· 1357 1326 "DID_ABORT", "DID_PARITY", "DID_ERROR", "DID_RESET", "DID_BAD_INTR", 1358 1327 "DID_PASSTHROUGH", "DID_SOFT_ERROR", "DID_IMM_RETRY"}; 1359 1328 #define NUM_HOSTBYTE_STRS ARRAY_SIZE(hostbyte_table) 1360 - 1361 - void scsi_print_hostbyte(int scsiresult) 1362 - { 1363 - int hb = host_byte(scsiresult); 1364 - 1365 - printk("Hostbyte=0x%02x", hb); 1366 - if (hb < NUM_HOSTBYTE_STRS) 1367 - printk("(%s) ", hostbyte_table[hb]); 1368 - else 1369 - printk("is invalid "); 1370 - } 1371 - #else 1372 - void scsi_print_hostbyte(int scsiresult) 1373 - { 1374 - printk("Hostbyte=0x%02x ", host_byte(scsiresult)); 1375 - } 1376 - #endif 1377 - 1378 - #ifdef CONFIG_SCSI_CONSTANTS 1379 1329 1380 1330 static const char * const driverbyte_table[]={ 1381 1331 "DRIVER_OK", "DRIVER_BUSY", "DRIVER_SOFT", "DRIVER_MEDIA", "DRIVER_ERROR", ··· 1368 1356 "SUGGEST_5", "SUGGEST_6", "SUGGEST_7", "SUGGEST_SENSE"}; 1369 1357 #define NUM_SUGGEST_STRS ARRAY_SIZE(driversuggest_table) 1370 1358 1371 - void scsi_print_driverbyte(int scsiresult) 1359 + void scsi_show_result(int result) 1372 1360 { 1373 - int dr = (driver_byte(scsiresult) & DRIVER_MASK); 1374 - int su = ((driver_byte(scsiresult) & SUGGEST_MASK) >> 4); 1361 + int hb = host_byte(result); 1362 + int db = (driver_byte(result) & DRIVER_MASK); 1363 + int su = ((driver_byte(result) & SUGGEST_MASK) >> 4); 1375 1364 1376 - printk("Driverbyte=0x%02x ", driver_byte(scsiresult)); 1377 - printk("(%s,%s) ", 1378 - (dr < NUM_DRIVERBYTE_STRS ? driverbyte_table[dr] : "invalid"), 1365 + printk("Result: hostbyte=%s driverbyte=%s,%s\n", 1366 + (hb < NUM_HOSTBYTE_STRS ? hostbyte_table[hb] : "invalid"), 1367 + (db < NUM_DRIVERBYTE_STRS ? driverbyte_table[db] : "invalid"), 1379 1368 (su < NUM_SUGGEST_STRS ? driversuggest_table[su] : "invalid")); 1380 1369 } 1370 + 1381 1371 #else 1382 - void scsi_print_driverbyte(int scsiresult) 1372 + 1373 + void scsi_show_result(int result) 1383 1374 { 1384 - printk("Driverbyte=0x%02x ", driver_byte(scsiresult)); 1375 + printk("Result: hostbyte=0x%02x driverbyte=0x%02x\n", 1376 + host_byte(result), driver_byte(result)); 1385 1377 } 1378 + 1386 1379 #endif 1380 + EXPORT_SYMBOL(scsi_show_result); 1381 + 1382 + 1383 + void scsi_print_result(struct scsi_cmnd *cmd) 1384 + { 1385 + scmd_printk(KERN_INFO, cmd, ""); 1386 + scsi_show_result(cmd->result); 1387 + } 1388 + EXPORT_SYMBOL(scsi_print_result); 1389 + 1390 +
+24 -24
drivers/scsi/dpt/dpti_i2o.h
··· 31 31 * Tunable parameters first 32 32 */ 33 33 34 - /* How many different OSM's are we allowing */ 34 + /* How many different OSM's are we allowing */ 35 35 #define MAX_I2O_MODULES 64 36 36 37 37 #define I2O_EVT_CAPABILITY_OTHER 0x01 ··· 63 63 u16 size; 64 64 u32 target_tid:12; 65 65 u32 init_tid:12; 66 - u32 function:8; 66 + u32 function:8; 67 67 u32 initiator_context; 68 68 /* List follows */ 69 69 }; ··· 77 77 78 78 char dev_name[8]; /* linux /dev name if available */ 79 79 i2o_lct_entry lct_data;/* Device LCT information */ 80 - u32 flags; 80 + u32 flags; 81 81 struct proc_dir_entry* proc_entry; /* /proc dir */ 82 82 struct adpt_device *owner; 83 83 struct _adpt_hba *controller; /* Controlling IOP */ ··· 86 86 /* 87 87 * Each I2O controller has one of these objects 88 88 */ 89 - 89 + 90 90 struct i2o_controller 91 91 { 92 92 char name[16]; ··· 111 111 u32 iop_id:12; 112 112 u32 reserved2:20; 113 113 u16 seg_num:12; 114 - u16 i2o_version:4; 115 - u8 iop_state; 116 - u8 msg_type; 114 + u16 i2o_version:4; 115 + u8 iop_state; 116 + u8 msg_type; 117 117 u16 frame_size; 118 118 u16 reserved3; 119 119 u32 last_changed; ··· 124 124 125 125 struct i2o_sys_tbl 126 126 { 127 - u8 num_entries; 128 - u8 version; 129 - u16 reserved1; 127 + u8 num_entries; 128 + u8 version; 129 + u16 reserved1; 130 130 u32 change_ind; 131 131 u32 reserved2; 132 132 u32 reserved3; 133 133 struct i2o_sys_tbl_entry iops[0]; 134 - }; 134 + }; 135 135 136 136 /* 137 137 * I2O classes / subclasses ··· 146 146 /* Class code names 147 147 * (from v1.5 Table 6-1 Class Code Assignments.) 148 148 */ 149 - 149 + 150 150 #define I2O_CLASS_EXECUTIVE 0x000 151 151 #define I2O_CLASS_DDM 0x001 152 152 #define I2O_CLASS_RANDOM_BLOCK_STORAGE 0x010 ··· 166 166 167 167 /* Rest of 0x092 - 0x09f reserved for peer-to-peer classes 168 168 */ 169 - 169 + 170 170 #define I2O_CLASS_MATCH_ANYCLASS 0xffffffff 171 171 172 172 /* Subclasses ··· 175 175 #define I2O_SUBCLASS_i960 0x001 176 176 #define I2O_SUBCLASS_HDM 0x020 177 177 #define I2O_SUBCLASS_ISM 0x021 178 - 178 + 179 179 /* Operation functions */ 180 180 181 181 #define I2O_PARAMS_FIELD_GET 0x0001 ··· 219 219 /* 220 220 * Messaging API values 221 221 */ 222 - 222 + 223 223 #define I2O_CMD_ADAPTER_ASSIGN 0xB3 224 224 #define I2O_CMD_ADAPTER_READ 0xB2 225 225 #define I2O_CMD_ADAPTER_RELEASE 0xB5 ··· 284 284 #define I2O_PRIVATE_MSG 0xFF 285 285 286 286 /* 287 - * Init Outbound Q status 287 + * Init Outbound Q status 288 288 */ 289 - 289 + 290 290 #define I2O_CMD_OUTBOUND_INIT_IN_PROGRESS 0x01 291 291 #define I2O_CMD_OUTBOUND_INIT_REJECTED 0x02 292 292 #define I2O_CMD_OUTBOUND_INIT_FAILED 0x03 293 293 #define I2O_CMD_OUTBOUND_INIT_COMPLETE 0x04 294 294 295 295 /* 296 - * I2O Get Status State values 296 + * I2O Get Status State values 297 297 */ 298 298 299 299 #define ADAPTER_STATE_INITIALIZING 0x01 ··· 303 303 #define ADAPTER_STATE_OPERATIONAL 0x08 304 304 #define ADAPTER_STATE_FAILED 0x10 305 305 #define ADAPTER_STATE_FAULTED 0x11 306 - 306 + 307 307 /* I2O API function return values */ 308 308 309 309 #define I2O_RTN_NO_ERROR 0 ··· 321 321 322 322 /* Reply message status defines for all messages */ 323 323 324 - #define I2O_REPLY_STATUS_SUCCESS 0x00 325 - #define I2O_REPLY_STATUS_ABORT_DIRTY 0x01 326 - #define I2O_REPLY_STATUS_ABORT_NO_DATA_TRANSFER 0x02 324 + #define I2O_REPLY_STATUS_SUCCESS 0x00 325 + #define I2O_REPLY_STATUS_ABORT_DIRTY 0x01 326 + #define I2O_REPLY_STATUS_ABORT_NO_DATA_TRANSFER 0x02 327 327 #define I2O_REPLY_STATUS_ABORT_PARTIAL_TRANSFER 0x03 328 328 #define I2O_REPLY_STATUS_ERROR_DIRTY 0x04 329 329 #define I2O_REPLY_STATUS_ERROR_NO_DATA_TRANSFER 0x05 ··· 338 338 339 339 #define I2O_PARAMS_STATUS_SUCCESS 0x00 340 340 #define I2O_PARAMS_STATUS_BAD_KEY_ABORT 0x01 341 - #define I2O_PARAMS_STATUS_BAD_KEY_CONTINUE 0x02 341 + #define I2O_PARAMS_STATUS_BAD_KEY_CONTINUE 0x02 342 342 #define I2O_PARAMS_STATUS_BUFFER_FULL 0x03 343 343 #define I2O_PARAMS_STATUS_BUFFER_TOO_SMALL 0x04 344 344 #define I2O_PARAMS_STATUS_FIELD_UNREADABLE 0x05 ··· 390 390 #define I2O_CLAIM_MANAGEMENT 0x02000000 391 391 #define I2O_CLAIM_AUTHORIZED 0x03000000 392 392 #define I2O_CLAIM_SECONDARY 0x04000000 393 - 393 + 394 394 /* Message header defines for VersionOffset */ 395 395 #define I2OVER15 0x0001 396 396 #define I2OVER20 0x0002
+1 -1
drivers/scsi/dpt/dpti_ioctl.h
··· 99 99 uCHAR eataVersion; /* EATA Version */ 100 100 uLONG cpLength; /* EATA Command Packet Length */ 101 101 uLONG spLength; /* EATA Status Packet Length */ 102 - uCHAR drqNum; /* DRQ Index (0,5,6,7) */ 102 + uCHAR drqNum; /* DRQ Index (0,5,6,7) */ 103 103 uCHAR flag1; /* EATA Flags 1 (Byte 9) */ 104 104 uCHAR flag2; /* EATA Flags 2 (Byte 30) */ 105 105 } CtrlInfo;
+2 -2
drivers/scsi/dpt/dptsig.h
··· 145 145 #define FT_LOGGER 12 /* Event Logger */ 146 146 #define FT_INSTALL 13 /* An Install Program */ 147 147 #define FT_LIBRARY 14 /* Storage Manager Real-Mode Calls */ 148 - #define FT_RESOURCE 15 /* Storage Manager Resource File */ 149 - #define FT_MODEM_DB 16 /* Storage Manager Modem Database */ 148 + #define FT_RESOURCE 15 /* Storage Manager Resource File */ 149 + #define FT_MODEM_DB 16 /* Storage Manager Modem Database */ 150 150 151 151 /* Filetype flags - sigBYTE dsFiletypeFlags; FLAG BITS */ 152 152 /* ------------------------------------------------------------------ */
-2
drivers/scsi/dpt_i2o.c
··· 195 195 pci_dev_get(pDev); 196 196 } 197 197 } 198 - if (pDev) 199 - pci_dev_put(pDev); 200 198 201 199 /* In INIT state, Activate IOPs */ 202 200 for (pHba = hba_chain; pHba; pHba = pHba->next) {
-7
drivers/scsi/eata_generic.h
··· 18 18 * Misc. definitions * 19 19 *********************************************/ 20 20 21 - #ifndef TRUE 22 - #define TRUE 1 23 - #endif 24 - #ifndef FALSE 25 - #define FALSE 0 26 - #endif 27 - 28 21 #define R_LIMIT 0x20000 29 22 30 23 #define MAXISA 4
+60 -20
drivers/scsi/ibmvscsi/ibmvscsi.c
··· 85 85 static int max_id = 64; 86 86 static int max_channel = 3; 87 87 static int init_timeout = 5; 88 - static int max_requests = 50; 88 + static int max_requests = IBMVSCSI_MAX_REQUESTS_DEFAULT; 89 89 90 90 #define IBMVSCSI_VERSION "1.5.8" 91 91 ··· 538 538 int request_status; 539 539 int rc; 540 540 541 - /* If we have exhausted our request limit, just fail this request. 541 + /* If we have exhausted our request limit, just fail this request, 542 + * unless it is for a reset or abort. 542 543 * Note that there are rare cases involving driver generated requests 543 544 * (such as task management requests) that the mid layer may think we 544 545 * can handle more requests (can_queue) when we actually can't ··· 552 551 */ 553 552 if (request_status < -1) 554 553 goto send_error; 555 - /* Otherwise, if we have run out of requests */ 556 - else if (request_status < 0) 557 - goto send_busy; 554 + /* Otherwise, we may have run out of requests. */ 555 + /* Abort and reset calls should make it through. 556 + * Nothing except abort and reset should use the last two 557 + * slots unless we had two or less to begin with. 558 + */ 559 + else if (request_status < 2 && 560 + evt_struct->iu.srp.cmd.opcode != SRP_TSK_MGMT) { 561 + /* In the case that we have less than two requests 562 + * available, check the server limit as a combination 563 + * of the request limit and the number of requests 564 + * in-flight (the size of the send list). If the 565 + * server limit is greater than 2, return busy so 566 + * that the last two are reserved for reset and abort. 567 + */ 568 + int server_limit = request_status; 569 + struct srp_event_struct *tmp_evt; 570 + 571 + list_for_each_entry(tmp_evt, &hostdata->sent, list) { 572 + server_limit++; 573 + } 574 + 575 + if (server_limit > 2) 576 + goto send_busy; 577 + } 558 578 } 559 579 560 580 /* Copy the IU into the transfer area */ ··· 594 572 595 573 printk(KERN_ERR "ibmvscsi: send error %d\n", 596 574 rc); 575 + atomic_inc(&hostdata->request_limit); 597 576 goto send_error; 598 577 } 599 578 ··· 604 581 unmap_cmd_data(&evt_struct->iu.srp.cmd, evt_struct, hostdata->dev); 605 582 606 583 free_event_struct(&hostdata->pool, evt_struct); 607 - return SCSI_MLQUEUE_HOST_BUSY; 584 + atomic_inc(&hostdata->request_limit); 585 + return SCSI_MLQUEUE_HOST_BUSY; 608 586 609 587 send_error: 610 588 unmap_cmd_data(&evt_struct->iu.srp.cmd, evt_struct, hostdata->dev); ··· 855 831 856 832 printk(KERN_INFO "ibmvscsi: SRP_LOGIN succeeded\n"); 857 833 858 - if (evt_struct->xfer_iu->srp.login_rsp.req_lim_delta > 859 - (max_requests - 2)) 860 - evt_struct->xfer_iu->srp.login_rsp.req_lim_delta = 861 - max_requests - 2; 834 + if (evt_struct->xfer_iu->srp.login_rsp.req_lim_delta < 0) 835 + printk(KERN_ERR "ibmvscsi: Invalid request_limit.\n"); 862 836 863 - /* Now we know what the real request-limit is */ 837 + /* Now we know what the real request-limit is. 838 + * This value is set rather than added to request_limit because 839 + * request_limit could have been set to -1 by this client. 840 + */ 864 841 atomic_set(&hostdata->request_limit, 865 842 evt_struct->xfer_iu->srp.login_rsp.req_lim_delta); 866 - 867 - hostdata->host->can_queue = 868 - evt_struct->xfer_iu->srp.login_rsp.req_lim_delta - 2; 869 - 870 - if (hostdata->host->can_queue < 1) { 871 - printk(KERN_ERR "ibmvscsi: Invalid request_limit_delta\n"); 872 - return; 873 - } 874 843 875 844 /* If we had any pending I/Os, kick them */ 876 845 scsi_unblock_requests(hostdata->host); ··· 1354 1337 return rc; 1355 1338 } 1356 1339 1340 + /** 1341 + * ibmvscsi_slave_configure: Set the "allow_restart" flag for each disk. 1342 + * @sdev: struct scsi_device device to configure 1343 + * 1344 + * Enable allow_restart for a device if it is a disk. Adjust the 1345 + * queue_depth here also as is required by the documentation for 1346 + * struct scsi_host_template. 1347 + */ 1348 + static int ibmvscsi_slave_configure(struct scsi_device *sdev) 1349 + { 1350 + struct Scsi_Host *shost = sdev->host; 1351 + unsigned long lock_flags = 0; 1352 + 1353 + spin_lock_irqsave(shost->host_lock, lock_flags); 1354 + if (sdev->type == TYPE_DISK) 1355 + sdev->allow_restart = 1; 1356 + scsi_adjust_queue_depth(sdev, 0, shost->cmd_per_lun); 1357 + spin_unlock_irqrestore(shost->host_lock, lock_flags); 1358 + return 0; 1359 + } 1360 + 1357 1361 /* ------------------------------------------------------------ 1358 1362 * sysfs attributes 1359 1363 */ ··· 1520 1482 .queuecommand = ibmvscsi_queuecommand, 1521 1483 .eh_abort_handler = ibmvscsi_eh_abort_handler, 1522 1484 .eh_device_reset_handler = ibmvscsi_eh_device_reset_handler, 1485 + .slave_configure = ibmvscsi_slave_configure, 1523 1486 .cmd_per_lun = 16, 1524 - .can_queue = 1, /* Updated after SRP_LOGIN */ 1487 + .can_queue = IBMVSCSI_MAX_REQUESTS_DEFAULT, 1525 1488 .this_id = -1, 1526 1489 .sg_tablesize = SG_ALL, 1527 1490 .use_clustering = ENABLE_CLUSTERING, ··· 1542 1503 1543 1504 vdev->dev.driver_data = NULL; 1544 1505 1506 + driver_template.can_queue = max_requests; 1545 1507 host = scsi_host_alloc(&driver_template, sizeof(*hostdata)); 1546 1508 if (!host) { 1547 1509 printk(KERN_ERR "ibmvscsi: couldn't allocate host data\n");
+2
drivers/scsi/ibmvscsi/ibmvscsi.h
··· 44 44 */ 45 45 #define MAX_INDIRECT_BUFS 10 46 46 47 + #define IBMVSCSI_MAX_REQUESTS_DEFAULT 100 48 + 47 49 /* ------------------------------------------------------------ 48 50 * Data Structures 49 51 */
+13 -24
drivers/scsi/ibmvscsi/ibmvstgt.c
··· 35 35 #include "ibmvscsi.h" 36 36 37 37 #define INITIAL_SRP_LIMIT 16 38 - #define DEFAULT_MAX_SECTORS 512 38 + #define DEFAULT_MAX_SECTORS 256 39 39 40 40 #define TGT_NAME "ibmvstgt" 41 41 ··· 248 248 md[i].va + mdone); 249 249 250 250 if (err != H_SUCCESS) { 251 - eprintk("rdma error %d %d\n", dir, slen); 252 - goto out; 251 + eprintk("rdma error %d %d %ld\n", dir, slen, err); 252 + return -EIO; 253 253 } 254 254 255 255 mlen -= slen; ··· 265 265 if (sidx > nsg) { 266 266 eprintk("out of sg %p %d %d\n", 267 267 iue, sidx, nsg); 268 - goto out; 268 + return -EIO; 269 269 } 270 270 } 271 271 }; 272 272 273 273 rest -= mlen; 274 274 } 275 - out: 276 - 277 275 return 0; 278 - } 279 - 280 - static int ibmvstgt_transfer_data(struct scsi_cmnd *sc, 281 - void (*done)(struct scsi_cmnd *)) 282 - { 283 - struct iu_entry *iue = (struct iu_entry *) sc->SCp.ptr; 284 - int err; 285 - 286 - err = srp_transfer_data(sc, &vio_iu(iue)->srp.cmd, ibmvstgt_rdma, 1, 1); 287 - 288 - done(sc); 289 - 290 - return err; 291 276 } 292 277 293 278 static int ibmvstgt_cmd_done(struct scsi_cmnd *sc, ··· 281 296 unsigned long flags; 282 297 struct iu_entry *iue = (struct iu_entry *) sc->SCp.ptr; 283 298 struct srp_target *target = iue->target; 299 + int err = 0; 284 300 285 - dprintk("%p %p %x\n", iue, target, vio_iu(iue)->srp.cmd.cdb[0]); 301 + dprintk("%p %p %x %u\n", iue, target, vio_iu(iue)->srp.cmd.cdb[0], 302 + cmd->usg_sg); 303 + 304 + if (sc->use_sg) 305 + err = srp_transfer_data(sc, &vio_iu(iue)->srp.cmd, ibmvstgt_rdma, 1, 1); 286 306 287 307 spin_lock_irqsave(&target->lock, flags); 288 308 list_del(&iue->ilist); 289 309 spin_unlock_irqrestore(&target->lock, flags); 290 310 291 - if (sc->result != SAM_STAT_GOOD) { 311 + if (err|| sc->result != SAM_STAT_GOOD) { 292 312 eprintk("operation failed %p %d %x\n", 293 313 iue, sc->result, vio_iu(iue)->srp.cmd.cdb[0]); 294 314 send_rsp(iue, sc, HARDWARE_ERROR, 0x00); ··· 493 503 { 494 504 struct vio_port *vport = target_to_port(target); 495 505 struct iu_entry *iue; 496 - long err, done; 506 + long err; 507 + int done = 1; 497 508 498 509 iue = srp_iu_get(target); 499 510 if (!iue) { ··· 509 518 510 519 if (err != H_SUCCESS) { 511 520 eprintk("%ld transferring data error %p\n", err, iue); 512 - done = 1; 513 521 goto out; 514 522 } 515 523 ··· 784 794 .use_clustering = DISABLE_CLUSTERING, 785 795 .max_sectors = DEFAULT_MAX_SECTORS, 786 796 .transfer_response = ibmvstgt_cmd_done, 787 - .transfer_data = ibmvstgt_transfer_data, 788 797 .eh_abort_handler = ibmvstgt_eh_abort_handler, 789 798 .tsk_mgmt_response = ibmvstgt_tsk_mgmt_response, 790 799 .shost_attrs = ibmvstgt_attrs,
+169 -121
drivers/scsi/ipr.c
··· 89 89 static unsigned int ipr_max_speed = 1; 90 90 static int ipr_testmode = 0; 91 91 static unsigned int ipr_fastfail = 0; 92 - static unsigned int ipr_transop_timeout = IPR_OPERATIONAL_TIMEOUT; 92 + static unsigned int ipr_transop_timeout = 0; 93 93 static unsigned int ipr_enable_cache = 1; 94 94 static unsigned int ipr_debug = 0; 95 - static int ipr_auto_create = 1; 96 95 static DEFINE_SPINLOCK(ipr_driver_lock); 97 96 98 97 /* This table describes the differences between DMA controller chips */ ··· 158 159 MODULE_PARM_DESC(enable_cache, "Enable adapter's non-volatile write cache (default: 1)"); 159 160 module_param_named(debug, ipr_debug, int, 0); 160 161 MODULE_PARM_DESC(debug, "Enable device driver debugging logging. Set to 1 to enable. (default: 0)"); 161 - module_param_named(auto_create, ipr_auto_create, int, 0); 162 - MODULE_PARM_DESC(auto_create, "Auto-create single device RAID 0 arrays when initialized (default: 1)"); 163 162 MODULE_LICENSE("GPL"); 164 163 MODULE_VERSION(IPR_DRIVER_VERSION); 165 164 166 165 /* A constant array of IOASCs/URCs/Error Messages */ 167 166 static const 168 167 struct ipr_error_table_t ipr_error_table[] = { 169 - {0x00000000, 1, 1, 168 + {0x00000000, 1, IPR_DEFAULT_LOG_LEVEL, 170 169 "8155: An unknown error was received"}, 171 170 {0x00330000, 0, 0, 172 171 "Soft underlength error"}, ··· 172 175 "Command to be cancelled not found"}, 173 176 {0x00808000, 0, 0, 174 177 "Qualified success"}, 175 - {0x01080000, 1, 1, 178 + {0x01080000, 1, IPR_DEFAULT_LOG_LEVEL, 176 179 "FFFE: Soft device bus error recovered by the IOA"}, 177 - {0x01088100, 0, 1, 180 + {0x01088100, 0, IPR_DEFAULT_LOG_LEVEL, 178 181 "4101: Soft device bus fabric error"}, 179 - {0x01170600, 0, 1, 182 + {0x01170600, 0, IPR_DEFAULT_LOG_LEVEL, 180 183 "FFF9: Device sector reassign successful"}, 181 - {0x01170900, 0, 1, 184 + {0x01170900, 0, IPR_DEFAULT_LOG_LEVEL, 182 185 "FFF7: Media error recovered by device rewrite procedures"}, 183 - {0x01180200, 0, 1, 186 + {0x01180200, 0, IPR_DEFAULT_LOG_LEVEL, 184 187 "7001: IOA sector reassignment successful"}, 185 - {0x01180500, 0, 1, 188 + {0x01180500, 0, IPR_DEFAULT_LOG_LEVEL, 186 189 "FFF9: Soft media error. Sector reassignment recommended"}, 187 - {0x01180600, 0, 1, 190 + {0x01180600, 0, IPR_DEFAULT_LOG_LEVEL, 188 191 "FFF7: Media error recovered by IOA rewrite procedures"}, 189 - {0x01418000, 0, 1, 192 + {0x01418000, 0, IPR_DEFAULT_LOG_LEVEL, 190 193 "FF3D: Soft PCI bus error recovered by the IOA"}, 191 - {0x01440000, 1, 1, 194 + {0x01440000, 1, IPR_DEFAULT_LOG_LEVEL, 192 195 "FFF6: Device hardware error recovered by the IOA"}, 193 - {0x01448100, 0, 1, 196 + {0x01448100, 0, IPR_DEFAULT_LOG_LEVEL, 194 197 "FFF6: Device hardware error recovered by the device"}, 195 - {0x01448200, 1, 1, 198 + {0x01448200, 1, IPR_DEFAULT_LOG_LEVEL, 196 199 "FF3D: Soft IOA error recovered by the IOA"}, 197 - {0x01448300, 0, 1, 200 + {0x01448300, 0, IPR_DEFAULT_LOG_LEVEL, 198 201 "FFFA: Undefined device response recovered by the IOA"}, 199 - {0x014A0000, 1, 1, 202 + {0x014A0000, 1, IPR_DEFAULT_LOG_LEVEL, 200 203 "FFF6: Device bus error, message or command phase"}, 201 - {0x014A8000, 0, 1, 204 + {0x014A8000, 0, IPR_DEFAULT_LOG_LEVEL, 202 205 "FFFE: Task Management Function failed"}, 203 - {0x015D0000, 0, 1, 206 + {0x015D0000, 0, IPR_DEFAULT_LOG_LEVEL, 204 207 "FFF6: Failure prediction threshold exceeded"}, 205 - {0x015D9200, 0, 1, 208 + {0x015D9200, 0, IPR_DEFAULT_LOG_LEVEL, 206 209 "8009: Impending cache battery pack failure"}, 207 210 {0x02040400, 0, 0, 208 211 "34FF: Disk device format in progress"}, ··· 212 215 "No ready, IOA shutdown"}, 213 216 {0x025A0000, 0, 0, 214 217 "Not ready, IOA has been shutdown"}, 215 - {0x02670100, 0, 1, 218 + {0x02670100, 0, IPR_DEFAULT_LOG_LEVEL, 216 219 "3020: Storage subsystem configuration error"}, 217 220 {0x03110B00, 0, 0, 218 221 "FFF5: Medium error, data unreadable, recommend reassign"}, 219 222 {0x03110C00, 0, 0, 220 223 "7000: Medium error, data unreadable, do not reassign"}, 221 - {0x03310000, 0, 1, 224 + {0x03310000, 0, IPR_DEFAULT_LOG_LEVEL, 222 225 "FFF3: Disk media format bad"}, 223 - {0x04050000, 0, 1, 226 + {0x04050000, 0, IPR_DEFAULT_LOG_LEVEL, 224 227 "3002: Addressed device failed to respond to selection"}, 225 - {0x04080000, 1, 1, 228 + {0x04080000, 1, IPR_DEFAULT_LOG_LEVEL, 226 229 "3100: Device bus error"}, 227 - {0x04080100, 0, 1, 230 + {0x04080100, 0, IPR_DEFAULT_LOG_LEVEL, 228 231 "3109: IOA timed out a device command"}, 229 232 {0x04088000, 0, 0, 230 233 "3120: SCSI bus is not operational"}, 231 - {0x04088100, 0, 1, 234 + {0x04088100, 0, IPR_DEFAULT_LOG_LEVEL, 232 235 "4100: Hard device bus fabric error"}, 233 - {0x04118000, 0, 1, 236 + {0x04118000, 0, IPR_DEFAULT_LOG_LEVEL, 234 237 "9000: IOA reserved area data check"}, 235 - {0x04118100, 0, 1, 238 + {0x04118100, 0, IPR_DEFAULT_LOG_LEVEL, 236 239 "9001: IOA reserved area invalid data pattern"}, 237 - {0x04118200, 0, 1, 240 + {0x04118200, 0, IPR_DEFAULT_LOG_LEVEL, 238 241 "9002: IOA reserved area LRC error"}, 239 - {0x04320000, 0, 1, 242 + {0x04320000, 0, IPR_DEFAULT_LOG_LEVEL, 240 243 "102E: Out of alternate sectors for disk storage"}, 241 - {0x04330000, 1, 1, 244 + {0x04330000, 1, IPR_DEFAULT_LOG_LEVEL, 242 245 "FFF4: Data transfer underlength error"}, 243 - {0x04338000, 1, 1, 246 + {0x04338000, 1, IPR_DEFAULT_LOG_LEVEL, 244 247 "FFF4: Data transfer overlength error"}, 245 - {0x043E0100, 0, 1, 248 + {0x043E0100, 0, IPR_DEFAULT_LOG_LEVEL, 246 249 "3400: Logical unit failure"}, 247 - {0x04408500, 0, 1, 250 + {0x04408500, 0, IPR_DEFAULT_LOG_LEVEL, 248 251 "FFF4: Device microcode is corrupt"}, 249 - {0x04418000, 1, 1, 252 + {0x04418000, 1, IPR_DEFAULT_LOG_LEVEL, 250 253 "8150: PCI bus error"}, 251 254 {0x04430000, 1, 0, 252 255 "Unsupported device bus message received"}, 253 - {0x04440000, 1, 1, 256 + {0x04440000, 1, IPR_DEFAULT_LOG_LEVEL, 254 257 "FFF4: Disk device problem"}, 255 - {0x04448200, 1, 1, 258 + {0x04448200, 1, IPR_DEFAULT_LOG_LEVEL, 256 259 "8150: Permanent IOA failure"}, 257 - {0x04448300, 0, 1, 260 + {0x04448300, 0, IPR_DEFAULT_LOG_LEVEL, 258 261 "3010: Disk device returned wrong response to IOA"}, 259 - {0x04448400, 0, 1, 262 + {0x04448400, 0, IPR_DEFAULT_LOG_LEVEL, 260 263 "8151: IOA microcode error"}, 261 264 {0x04448500, 0, 0, 262 265 "Device bus status error"}, 263 - {0x04448600, 0, 1, 266 + {0x04448600, 0, IPR_DEFAULT_LOG_LEVEL, 264 267 "8157: IOA error requiring IOA reset to recover"}, 265 268 {0x04448700, 0, 0, 266 269 "ATA device status error"}, 267 270 {0x04490000, 0, 0, 268 271 "Message reject received from the device"}, 269 - {0x04449200, 0, 1, 272 + {0x04449200, 0, IPR_DEFAULT_LOG_LEVEL, 270 273 "8008: A permanent cache battery pack failure occurred"}, 271 - {0x0444A000, 0, 1, 274 + {0x0444A000, 0, IPR_DEFAULT_LOG_LEVEL, 272 275 "9090: Disk unit has been modified after the last known status"}, 273 - {0x0444A200, 0, 1, 276 + {0x0444A200, 0, IPR_DEFAULT_LOG_LEVEL, 274 277 "9081: IOA detected device error"}, 275 - {0x0444A300, 0, 1, 278 + {0x0444A300, 0, IPR_DEFAULT_LOG_LEVEL, 276 279 "9082: IOA detected device error"}, 277 - {0x044A0000, 1, 1, 280 + {0x044A0000, 1, IPR_DEFAULT_LOG_LEVEL, 278 281 "3110: Device bus error, message or command phase"}, 279 - {0x044A8000, 1, 1, 282 + {0x044A8000, 1, IPR_DEFAULT_LOG_LEVEL, 280 283 "3110: SAS Command / Task Management Function failed"}, 281 - {0x04670400, 0, 1, 284 + {0x04670400, 0, IPR_DEFAULT_LOG_LEVEL, 282 285 "9091: Incorrect hardware configuration change has been detected"}, 283 - {0x04678000, 0, 1, 286 + {0x04678000, 0, IPR_DEFAULT_LOG_LEVEL, 284 287 "9073: Invalid multi-adapter configuration"}, 285 - {0x04678100, 0, 1, 288 + {0x04678100, 0, IPR_DEFAULT_LOG_LEVEL, 286 289 "4010: Incorrect connection between cascaded expanders"}, 287 - {0x04678200, 0, 1, 290 + {0x04678200, 0, IPR_DEFAULT_LOG_LEVEL, 288 291 "4020: Connections exceed IOA design limits"}, 289 - {0x04678300, 0, 1, 292 + {0x04678300, 0, IPR_DEFAULT_LOG_LEVEL, 290 293 "4030: Incorrect multipath connection"}, 291 - {0x04679000, 0, 1, 294 + {0x04679000, 0, IPR_DEFAULT_LOG_LEVEL, 292 295 "4110: Unsupported enclosure function"}, 293 - {0x046E0000, 0, 1, 296 + {0x046E0000, 0, IPR_DEFAULT_LOG_LEVEL, 294 297 "FFF4: Command to logical unit failed"}, 295 298 {0x05240000, 1, 0, 296 299 "Illegal request, invalid request type or request packet"}, ··· 310 313 "Illegal request, command sequence error"}, 311 314 {0x052C8000, 1, 0, 312 315 "Illegal request, dual adapter support not enabled"}, 313 - {0x06040500, 0, 1, 316 + {0x06040500, 0, IPR_DEFAULT_LOG_LEVEL, 314 317 "9031: Array protection temporarily suspended, protection resuming"}, 315 - {0x06040600, 0, 1, 318 + {0x06040600, 0, IPR_DEFAULT_LOG_LEVEL, 316 319 "9040: Array protection temporarily suspended, protection resuming"}, 317 - {0x06288000, 0, 1, 320 + {0x06288000, 0, IPR_DEFAULT_LOG_LEVEL, 318 321 "3140: Device bus not ready to ready transition"}, 319 - {0x06290000, 0, 1, 322 + {0x06290000, 0, IPR_DEFAULT_LOG_LEVEL, 320 323 "FFFB: SCSI bus was reset"}, 321 324 {0x06290500, 0, 0, 322 325 "FFFE: SCSI bus transition to single ended"}, 323 326 {0x06290600, 0, 0, 324 327 "FFFE: SCSI bus transition to LVD"}, 325 - {0x06298000, 0, 1, 328 + {0x06298000, 0, IPR_DEFAULT_LOG_LEVEL, 326 329 "FFFB: SCSI bus was reset by another initiator"}, 327 - {0x063F0300, 0, 1, 330 + {0x063F0300, 0, IPR_DEFAULT_LOG_LEVEL, 328 331 "3029: A device replacement has occurred"}, 329 - {0x064C8000, 0, 1, 332 + {0x064C8000, 0, IPR_DEFAULT_LOG_LEVEL, 330 333 "9051: IOA cache data exists for a missing or failed device"}, 331 - {0x064C8100, 0, 1, 334 + {0x064C8100, 0, IPR_DEFAULT_LOG_LEVEL, 332 335 "9055: Auxiliary cache IOA contains cache data needed by the primary IOA"}, 333 - {0x06670100, 0, 1, 336 + {0x06670100, 0, IPR_DEFAULT_LOG_LEVEL, 334 337 "9025: Disk unit is not supported at its physical location"}, 335 - {0x06670600, 0, 1, 338 + {0x06670600, 0, IPR_DEFAULT_LOG_LEVEL, 336 339 "3020: IOA detected a SCSI bus configuration error"}, 337 - {0x06678000, 0, 1, 340 + {0x06678000, 0, IPR_DEFAULT_LOG_LEVEL, 338 341 "3150: SCSI bus configuration error"}, 339 - {0x06678100, 0, 1, 342 + {0x06678100, 0, IPR_DEFAULT_LOG_LEVEL, 340 343 "9074: Asymmetric advanced function disk configuration"}, 341 - {0x06678300, 0, 1, 344 + {0x06678300, 0, IPR_DEFAULT_LOG_LEVEL, 342 345 "4040: Incomplete multipath connection between IOA and enclosure"}, 343 - {0x06678400, 0, 1, 346 + {0x06678400, 0, IPR_DEFAULT_LOG_LEVEL, 344 347 "4041: Incomplete multipath connection between enclosure and device"}, 345 - {0x06678500, 0, 1, 348 + {0x06678500, 0, IPR_DEFAULT_LOG_LEVEL, 346 349 "9075: Incomplete multipath connection between IOA and remote IOA"}, 347 - {0x06678600, 0, 1, 350 + {0x06678600, 0, IPR_DEFAULT_LOG_LEVEL, 348 351 "9076: Configuration error, missing remote IOA"}, 349 - {0x06679100, 0, 1, 352 + {0x06679100, 0, IPR_DEFAULT_LOG_LEVEL, 350 353 "4050: Enclosure does not support a required multipath function"}, 351 - {0x06690200, 0, 1, 354 + {0x06690200, 0, IPR_DEFAULT_LOG_LEVEL, 352 355 "9041: Array protection temporarily suspended"}, 353 - {0x06698200, 0, 1, 356 + {0x06698200, 0, IPR_DEFAULT_LOG_LEVEL, 354 357 "9042: Corrupt array parity detected on specified device"}, 355 - {0x066B0200, 0, 1, 358 + {0x066B0200, 0, IPR_DEFAULT_LOG_LEVEL, 356 359 "9030: Array no longer protected due to missing or failed disk unit"}, 357 - {0x066B8000, 0, 1, 360 + {0x066B8000, 0, IPR_DEFAULT_LOG_LEVEL, 358 361 "9071: Link operational transition"}, 359 - {0x066B8100, 0, 1, 362 + {0x066B8100, 0, IPR_DEFAULT_LOG_LEVEL, 360 363 "9072: Link not operational transition"}, 361 - {0x066B8200, 0, 1, 364 + {0x066B8200, 0, IPR_DEFAULT_LOG_LEVEL, 362 365 "9032: Array exposed but still protected"}, 363 - {0x066B9100, 0, 1, 366 + {0x066B8300, 0, IPR_DEFAULT_LOG_LEVEL + 1, 367 + "70DD: Device forced failed by disrupt device command"}, 368 + {0x066B9100, 0, IPR_DEFAULT_LOG_LEVEL, 364 369 "4061: Multipath redundancy level got better"}, 365 - {0x066B9200, 0, 1, 370 + {0x066B9200, 0, IPR_DEFAULT_LOG_LEVEL, 366 371 "4060: Multipath redundancy level got worse"}, 367 372 {0x07270000, 0, 0, 368 373 "Failure due to other device"}, 369 - {0x07278000, 0, 1, 374 + {0x07278000, 0, IPR_DEFAULT_LOG_LEVEL, 370 375 "9008: IOA does not support functions expected by devices"}, 371 - {0x07278100, 0, 1, 376 + {0x07278100, 0, IPR_DEFAULT_LOG_LEVEL, 372 377 "9010: Cache data associated with attached devices cannot be found"}, 373 - {0x07278200, 0, 1, 378 + {0x07278200, 0, IPR_DEFAULT_LOG_LEVEL, 374 379 "9011: Cache data belongs to devices other than those attached"}, 375 - {0x07278400, 0, 1, 380 + {0x07278400, 0, IPR_DEFAULT_LOG_LEVEL, 376 381 "9020: Array missing 2 or more devices with only 1 device present"}, 377 - {0x07278500, 0, 1, 382 + {0x07278500, 0, IPR_DEFAULT_LOG_LEVEL, 378 383 "9021: Array missing 2 or more devices with 2 or more devices present"}, 379 - {0x07278600, 0, 1, 384 + {0x07278600, 0, IPR_DEFAULT_LOG_LEVEL, 380 385 "9022: Exposed array is missing a required device"}, 381 - {0x07278700, 0, 1, 386 + {0x07278700, 0, IPR_DEFAULT_LOG_LEVEL, 382 387 "9023: Array member(s) not at required physical locations"}, 383 - {0x07278800, 0, 1, 388 + {0x07278800, 0, IPR_DEFAULT_LOG_LEVEL, 384 389 "9024: Array not functional due to present hardware configuration"}, 385 - {0x07278900, 0, 1, 390 + {0x07278900, 0, IPR_DEFAULT_LOG_LEVEL, 386 391 "9026: Array not functional due to present hardware configuration"}, 387 - {0x07278A00, 0, 1, 392 + {0x07278A00, 0, IPR_DEFAULT_LOG_LEVEL, 388 393 "9027: Array is missing a device and parity is out of sync"}, 389 - {0x07278B00, 0, 1, 394 + {0x07278B00, 0, IPR_DEFAULT_LOG_LEVEL, 390 395 "9028: Maximum number of arrays already exist"}, 391 - {0x07278C00, 0, 1, 396 + {0x07278C00, 0, IPR_DEFAULT_LOG_LEVEL, 392 397 "9050: Required cache data cannot be located for a disk unit"}, 393 - {0x07278D00, 0, 1, 398 + {0x07278D00, 0, IPR_DEFAULT_LOG_LEVEL, 394 399 "9052: Cache data exists for a device that has been modified"}, 395 - {0x07278F00, 0, 1, 400 + {0x07278F00, 0, IPR_DEFAULT_LOG_LEVEL, 396 401 "9054: IOA resources not available due to previous problems"}, 397 - {0x07279100, 0, 1, 402 + {0x07279100, 0, IPR_DEFAULT_LOG_LEVEL, 398 403 "9092: Disk unit requires initialization before use"}, 399 - {0x07279200, 0, 1, 404 + {0x07279200, 0, IPR_DEFAULT_LOG_LEVEL, 400 405 "9029: Incorrect hardware configuration change has been detected"}, 401 - {0x07279600, 0, 1, 406 + {0x07279600, 0, IPR_DEFAULT_LOG_LEVEL, 402 407 "9060: One or more disk pairs are missing from an array"}, 403 - {0x07279700, 0, 1, 408 + {0x07279700, 0, IPR_DEFAULT_LOG_LEVEL, 404 409 "9061: One or more disks are missing from an array"}, 405 - {0x07279800, 0, 1, 410 + {0x07279800, 0, IPR_DEFAULT_LOG_LEVEL, 406 411 "9062: One or more disks are missing from an array"}, 407 - {0x07279900, 0, 1, 412 + {0x07279900, 0, IPR_DEFAULT_LOG_LEVEL, 408 413 "9063: Maximum number of functional arrays has been exceeded"}, 409 414 {0x0B260000, 0, 0, 410 415 "Aborted command, invalid descriptor"}, ··· 480 481 { 481 482 struct ipr_ioarcb *ioarcb = &ipr_cmd->ioarcb; 482 483 struct ipr_ioasa *ioasa = &ipr_cmd->ioasa; 484 + dma_addr_t dma_addr = be32_to_cpu(ioarcb->ioarcb_host_pci_addr); 483 485 484 486 memset(&ioarcb->cmd_pkt, 0, sizeof(struct ipr_cmd_pkt)); 485 487 ioarcb->write_data_transfer_length = 0; 486 488 ioarcb->read_data_transfer_length = 0; 487 489 ioarcb->write_ioadl_len = 0; 488 490 ioarcb->read_ioadl_len = 0; 491 + ioarcb->write_ioadl_addr = 492 + cpu_to_be32(dma_addr + offsetof(struct ipr_cmnd, ioadl)); 493 + ioarcb->read_ioadl_addr = ioarcb->write_ioadl_addr; 489 494 ioasa->ioasc = 0; 490 495 ioasa->residual_data_len = 0; 491 496 ioasa->u.gata.status = 0; ··· 1613 1610 /* Set indication we have logged an error */ 1614 1611 ioa_cfg->errors_logged++; 1615 1612 1616 - if (ioa_cfg->log_level < IPR_DEFAULT_LOG_LEVEL) 1613 + if (ioa_cfg->log_level < ipr_error_table[error_index].log_hcam) 1617 1614 return; 1618 1615 if (be32_to_cpu(hostrcb->hcam.length) > sizeof(hostrcb->hcam.u.raw)) 1619 1616 hostrcb->hcam.length = cpu_to_be32(sizeof(hostrcb->hcam.u.raw)); ··· 3853 3850 if (ipr_cmd->ioarcb.res_handle == res->cfgte.res_handle) { 3854 3851 if (ipr_cmd->scsi_cmd) 3855 3852 ipr_cmd->done = ipr_scsi_eh_done; 3853 + if (ipr_cmd->qc) 3854 + ipr_cmd->done = ipr_sata_eh_done; 3856 3855 if (ipr_cmd->qc && !(ipr_cmd->qc->flags & ATA_QCFLAG_FAILED)) { 3857 3856 ipr_cmd->qc->err_mask |= AC_ERR_TIMEOUT; 3858 3857 ipr_cmd->qc->flags |= ATA_QCFLAG_FAILED; ··· 4235 4230 4236 4231 sglist = scsi_cmd->request_buffer; 4237 4232 4233 + if (ipr_cmd->dma_use_sg <= ARRAY_SIZE(ioarcb->add_data.u.ioadl)) { 4234 + ioadl = ioarcb->add_data.u.ioadl; 4235 + ioarcb->write_ioadl_addr = 4236 + cpu_to_be32(be32_to_cpu(ioarcb->ioarcb_host_pci_addr) + 4237 + offsetof(struct ipr_ioarcb, add_data)); 4238 + ioarcb->read_ioadl_addr = ioarcb->write_ioadl_addr; 4239 + } 4240 + 4238 4241 for (i = 0; i < ipr_cmd->dma_use_sg; i++) { 4239 4242 ioadl[i].flags_and_data_len = 4240 4243 cpu_to_be32(ioadl_flags | sg_dma_len(&sglist[i])); ··· 4273 4260 scsi_cmd->sc_data_direction); 4274 4261 4275 4262 if (likely(!pci_dma_mapping_error(ipr_cmd->dma_handle))) { 4263 + ioadl = ioarcb->add_data.u.ioadl; 4264 + ioarcb->write_ioadl_addr = 4265 + cpu_to_be32(be32_to_cpu(ioarcb->ioarcb_host_pci_addr) + 4266 + offsetof(struct ipr_ioarcb, add_data)); 4267 + ioarcb->read_ioadl_addr = ioarcb->write_ioadl_addr; 4276 4268 ipr_cmd->dma_use_sg = 1; 4277 4269 ioadl[0].flags_and_data_len = 4278 4270 cpu_to_be32(ioadl_flags | length | IPR_IOADL_FLAGS_LAST); ··· 4364 4346 **/ 4365 4347 static void ipr_reinit_ipr_cmnd_for_erp(struct ipr_cmnd *ipr_cmd) 4366 4348 { 4367 - struct ipr_ioarcb *ioarcb; 4368 - struct ipr_ioasa *ioasa; 4369 - 4370 - ioarcb = &ipr_cmd->ioarcb; 4371 - ioasa = &ipr_cmd->ioasa; 4349 + struct ipr_ioarcb *ioarcb = &ipr_cmd->ioarcb; 4350 + struct ipr_ioasa *ioasa = &ipr_cmd->ioasa; 4351 + dma_addr_t dma_addr = be32_to_cpu(ioarcb->ioarcb_host_pci_addr); 4372 4352 4373 4353 memset(&ioarcb->cmd_pkt, 0, sizeof(struct ipr_cmd_pkt)); 4374 4354 ioarcb->write_data_transfer_length = 0; ··· 4375 4359 ioarcb->read_ioadl_len = 0; 4376 4360 ioasa->ioasc = 0; 4377 4361 ioasa->residual_data_len = 0; 4362 + ioarcb->write_ioadl_addr = 4363 + cpu_to_be32(dma_addr + offsetof(struct ipr_cmnd, ioadl)); 4364 + ioarcb->read_ioadl_addr = ioarcb->write_ioadl_addr; 4378 4365 } 4379 4366 4380 4367 /** ··· 4476 4457 { 4477 4458 int i; 4478 4459 u16 data_len; 4479 - u32 ioasc; 4460 + u32 ioasc, fd_ioasc; 4480 4461 struct ipr_ioasa *ioasa = &ipr_cmd->ioasa; 4481 4462 __be32 *ioasa_data = (__be32 *)ioasa; 4482 4463 int error_index; 4483 4464 4484 4465 ioasc = be32_to_cpu(ioasa->ioasc) & IPR_IOASC_IOASC_MASK; 4466 + fd_ioasc = be32_to_cpu(ioasa->fd_ioasc) & IPR_IOASC_IOASC_MASK; 4485 4467 4486 4468 if (0 == ioasc) 4487 4469 return; ··· 4490 4470 if (ioa_cfg->log_level < IPR_DEFAULT_LOG_LEVEL) 4491 4471 return; 4492 4472 4493 - error_index = ipr_get_error(ioasc); 4473 + if (ioasc == IPR_IOASC_BUS_WAS_RESET && fd_ioasc) 4474 + error_index = ipr_get_error(fd_ioasc); 4475 + else 4476 + error_index = ipr_get_error(ioasc); 4494 4477 4495 4478 if (ioa_cfg->log_level < IPR_MAX_LOG_LEVEL) { 4496 4479 /* Don't log an error if the IOA already logged one */ 4497 4480 if (ioasa->ilid != 0) 4481 + return; 4482 + 4483 + if (!ipr_is_gscsi(res)) 4498 4484 return; 4499 4485 4500 4486 if (ipr_error_table[error_index].log_ioasa == 0) ··· 4662 4636 return; 4663 4637 } 4664 4638 4665 - if (ipr_is_gscsi(res)) 4666 - ipr_dump_ioasa(ioa_cfg, ipr_cmd, res); 4667 - else 4639 + if (!ipr_is_gscsi(res)) 4668 4640 ipr_gen_sense(ipr_cmd); 4641 + 4642 + ipr_dump_ioasa(ioa_cfg, ipr_cmd, res); 4669 4643 4670 4644 switch (ioasc & IPR_IOASC_IOASC_MASK) { 4671 4645 case IPR_IOASC_ABORTED_CMD_TERM_BY_HOST: ··· 5147 5121 struct ipr_ioarcb_ata_regs *regs; 5148 5122 5149 5123 if (unlikely(!ioa_cfg->allow_cmds || ioa_cfg->ioa_is_dead)) 5150 - return -EIO; 5124 + return AC_ERR_SYSTEM; 5151 5125 5152 5126 ipr_cmd = ipr_get_free_ipr_cmnd(ioa_cfg); 5153 5127 ioarcb = &ipr_cmd->ioarcb; ··· 5192 5166 5193 5167 default: 5194 5168 WARN_ON(1); 5195 - return -1; 5169 + return AC_ERR_INVALID; 5196 5170 } 5197 5171 5198 5172 mb(); ··· 6214 6188 dev_info(&ioa_cfg->pdev->dev, "Initializing IOA.\n"); 6215 6189 6216 6190 ipr_cmd->timer.data = (unsigned long) ipr_cmd; 6217 - ipr_cmd->timer.expires = jiffies + (ipr_transop_timeout * HZ); 6191 + ipr_cmd->timer.expires = jiffies + (ioa_cfg->transop_timeout * HZ); 6218 6192 ipr_cmd->timer.function = (void (*)(unsigned long))ipr_oper_timeout; 6219 6193 ipr_cmd->done = ipr_reset_ioa_job; 6220 6194 add_timer(&ipr_cmd->timer); ··· 6411 6385 rc = pci_write_config_byte(ioa_cfg->pdev, PCI_BIST, PCI_BIST_START); 6412 6386 6413 6387 if (rc != PCIBIOS_SUCCESSFUL) { 6388 + pci_unblock_user_cfg_access(ipr_cmd->ioa_cfg->pdev); 6414 6389 ipr_cmd->ioasa.ioasc = cpu_to_be32(IPR_IOASC_PCI_ACCESS_ERROR); 6415 6390 rc = IPR_RC_JOB_CONTINUE; 6416 6391 } else { ··· 7144 7117 ioa_cfg->pdev = pdev; 7145 7118 ioa_cfg->log_level = ipr_log_level; 7146 7119 ioa_cfg->doorbell = IPR_DOORBELL; 7147 - if (!ipr_auto_create) 7148 - ioa_cfg->doorbell |= IPR_RUNTIME_RESET; 7149 7120 sprintf(ioa_cfg->eye_catcher, IPR_EYECATCHER); 7150 7121 sprintf(ioa_cfg->trace_start, IPR_TRACE_START_LABEL); 7151 7122 sprintf(ioa_cfg->ipr_free_label, IPR_FREEQ_LABEL); ··· 7257 7232 dev_id->vendor, dev_id->device); 7258 7233 goto out_scsi_host_put; 7259 7234 } 7235 + 7236 + if (ipr_transop_timeout) 7237 + ioa_cfg->transop_timeout = ipr_transop_timeout; 7238 + else if (dev_id->driver_data & IPR_USE_LONG_TRANSOP_TIMEOUT) 7239 + ioa_cfg->transop_timeout = IPR_LONG_OPERATIONAL_TIMEOUT; 7240 + else 7241 + ioa_cfg->transop_timeout = IPR_OPERATIONAL_TIMEOUT; 7260 7242 7261 7243 ipr_regs_pci = pci_resource_start(pdev, 0); 7262 7244 ··· 7572 7540 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CITRINE, 7573 7541 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_571A, 0, 0, 0 }, 7574 7542 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CITRINE, 7575 - PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_575B, 0, 0, 0 }, 7543 + PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_575B, 0, 0, 7544 + IPR_USE_LONG_TRANSOP_TIMEOUT }, 7576 7545 { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_OBSIDIAN, 7577 7546 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_572A, 0, 0, 0 }, 7578 7547 { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_OBSIDIAN, 7579 7548 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_572B, 0, 0, 0 }, 7580 7549 { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_OBSIDIAN, 7581 - PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_575C, 0, 0, 0 }, 7550 + PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_575C, 0, 0, 7551 + IPR_USE_LONG_TRANSOP_TIMEOUT }, 7582 7552 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN, 7583 7553 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_572A, 0, 0, 0 }, 7584 7554 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN, 7585 7555 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_572B, 0, 0, 0 }, 7586 7556 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN, 7587 - PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_575C, 0, 0, 0 }, 7557 + PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_575C, 0, 0, 7558 + IPR_USE_LONG_TRANSOP_TIMEOUT }, 7588 7559 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN_E, 7589 - PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_57B7, 0, 0, 0 }, 7560 + PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_574E, 0, 0, 0 }, 7561 + { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN_E, 7562 + PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_575D, 0, 0, 7563 + IPR_USE_LONG_TRANSOP_TIMEOUT }, 7564 + { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN_E, 7565 + PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_57B3, 0, 0, 0 }, 7566 + { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN_E, 7567 + PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_57B7, 0, 0, 7568 + IPR_USE_LONG_TRANSOP_TIMEOUT }, 7590 7569 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_SNIPE, 7591 7570 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_2780, 0, 0, 0 }, 7592 7571 { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_SCAMP, 7593 7572 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_571E, 0, 0, 0 }, 7594 7573 { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_SCAMP, 7595 - PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_571F, 0, 0, 0 }, 7574 + PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_571F, 0, 0, 7575 + IPR_USE_LONG_TRANSOP_TIMEOUT }, 7596 7576 { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_SCAMP, 7597 - PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_572F, 0, 0, 0 }, 7577 + PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_572F, 0, 0, 7578 + IPR_USE_LONG_TRANSOP_TIMEOUT }, 7579 + { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_SCAMP_E, 7580 + PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_574D, 0, 0, 7581 + IPR_USE_LONG_TRANSOP_TIMEOUT }, 7598 7582 { } 7599 7583 }; 7600 7584 MODULE_DEVICE_TABLE(pci, ipr_pci_table);
+28 -17
drivers/scsi/ipr.h
··· 37 37 /* 38 38 * Literals 39 39 */ 40 - #define IPR_DRIVER_VERSION "2.3.1" 41 - #define IPR_DRIVER_DATE "(January 23, 2007)" 40 + #define IPR_DRIVER_VERSION "2.3.2" 41 + #define IPR_DRIVER_DATE "(March 23, 2007)" 42 42 43 43 /* 44 44 * IPR_MAX_CMD_PER_LUN: This defines the maximum number of outstanding ··· 55 55 #define IPR_NUM_BASE_CMD_BLKS 100 56 56 57 57 #define PCI_DEVICE_ID_IBM_OBSIDIAN_E 0x0339 58 + #define PCI_DEVICE_ID_IBM_SCAMP_E 0x034A 58 59 59 60 #define IPR_SUBS_DEV_ID_2780 0x0264 60 61 #define IPR_SUBS_DEV_ID_5702 0x0266 ··· 70 69 #define IPR_SUBS_DEV_ID_572A 0x02C1 71 70 #define IPR_SUBS_DEV_ID_572B 0x02C2 72 71 #define IPR_SUBS_DEV_ID_572F 0x02C3 72 + #define IPR_SUBS_DEV_ID_574D 0x030B 73 + #define IPR_SUBS_DEV_ID_574E 0x030A 73 74 #define IPR_SUBS_DEV_ID_575B 0x030D 74 75 #define IPR_SUBS_DEV_ID_575C 0x0338 76 + #define IPR_SUBS_DEV_ID_575D 0x033E 77 + #define IPR_SUBS_DEV_ID_57B3 0x033A 75 78 #define IPR_SUBS_DEV_ID_57B7 0x0360 76 79 #define IPR_SUBS_DEV_ID_57B8 0x02C2 77 80 ··· 108 103 #define IPR_FIRST_DRIVER_IOASC 0x10000000 109 104 #define IPR_IOASC_IOA_WAS_RESET 0x10000001 110 105 #define IPR_IOASC_PCI_ACCESS_ERROR 0x10000002 106 + 107 + /* Driver data flags */ 108 + #define IPR_USE_LONG_TRANSOP_TIMEOUT 0x00000001 111 109 112 110 #define IPR_DEFAULT_MAX_ERROR_DUMP 984 113 111 #define IPR_NUM_LOG_HCAMS 2 ··· 187 179 #define IPR_SET_SUP_DEVICE_TIMEOUT (2 * 60 * HZ) 188 180 #define IPR_REQUEST_SENSE_TIMEOUT (10 * HZ) 189 181 #define IPR_OPERATIONAL_TIMEOUT (5 * 60) 182 + #define IPR_LONG_OPERATIONAL_TIMEOUT (12 * 60) 190 183 #define IPR_WAIT_FOR_RESET_TIMEOUT (2 * HZ) 191 184 #define IPR_CHECK_FOR_RESET_TIMEOUT (HZ / 10) 192 185 #define IPR_WAIT_FOR_BIST_TIMEOUT (2 * HZ) ··· 422 413 u8 ctl; 423 414 }__attribute__ ((packed, aligned(4))); 424 415 416 + struct ipr_ioadl_desc { 417 + __be32 flags_and_data_len; 418 + #define IPR_IOADL_FLAGS_MASK 0xff000000 419 + #define IPR_IOADL_GET_FLAGS(x) (be32_to_cpu(x) & IPR_IOADL_FLAGS_MASK) 420 + #define IPR_IOADL_DATA_LEN_MASK 0x00ffffff 421 + #define IPR_IOADL_GET_DATA_LEN(x) (be32_to_cpu(x) & IPR_IOADL_DATA_LEN_MASK) 422 + #define IPR_IOADL_FLAGS_READ 0x48000000 423 + #define IPR_IOADL_FLAGS_READ_LAST 0x49000000 424 + #define IPR_IOADL_FLAGS_WRITE 0x68000000 425 + #define IPR_IOADL_FLAGS_WRITE_LAST 0x69000000 426 + #define IPR_IOADL_FLAGS_LAST 0x01000000 427 + 428 + __be32 address; 429 + }__attribute__((packed, aligned (8))); 430 + 425 431 struct ipr_ioarcb_add_data { 426 432 union { 427 433 struct ipr_ioarcb_ata_regs regs; 434 + struct ipr_ioadl_desc ioadl[5]; 428 435 __be32 add_cmd_parms[10]; 429 436 }u; 430 437 }__attribute__ ((packed, aligned(4))); ··· 471 446 __be32 add_cmd_parms_len; 472 447 struct ipr_ioarcb_add_data add_data; 473 448 }__attribute__((packed, aligned (4))); 474 - 475 - struct ipr_ioadl_desc { 476 - __be32 flags_and_data_len; 477 - #define IPR_IOADL_FLAGS_MASK 0xff000000 478 - #define IPR_IOADL_GET_FLAGS(x) (be32_to_cpu(x) & IPR_IOADL_FLAGS_MASK) 479 - #define IPR_IOADL_DATA_LEN_MASK 0x00ffffff 480 - #define IPR_IOADL_GET_DATA_LEN(x) (be32_to_cpu(x) & IPR_IOADL_DATA_LEN_MASK) 481 - #define IPR_IOADL_FLAGS_READ 0x48000000 482 - #define IPR_IOADL_FLAGS_READ_LAST 0x49000000 483 - #define IPR_IOADL_FLAGS_WRITE 0x68000000 484 - #define IPR_IOADL_FLAGS_WRITE_LAST 0x69000000 485 - #define IPR_IOADL_FLAGS_LAST 0x01000000 486 - 487 - __be32 address; 488 - }__attribute__((packed, aligned (8))); 489 449 490 450 struct ipr_ioasa_vset { 491 451 __be32 failing_lba_hi; ··· 1129 1119 1130 1120 struct ipr_bus_attributes bus_attr[IPR_MAX_NUM_BUSES]; 1131 1121 1122 + unsigned int transop_timeout; 1132 1123 const struct ipr_chip_cfg_t *chip_cfg; 1133 1124 1134 1125 void __iomem *hdw_dma_regs; /* iomapped PCI memory space */
+16 -5
drivers/scsi/iscsi_tcp.c
··· 527 527 * than 8K, but there are no targets that currently do this. 528 528 * For now we fail until we find a vendor that needs it 529 529 */ 530 - if (DEFAULT_MAX_RECV_DATA_SEGMENT_LENGTH < 530 + if (ISCSI_DEF_MAX_RECV_SEG_LEN < 531 531 tcp_conn->in.datalen) { 532 532 printk(KERN_ERR "iscsi_tcp: received buffer of len %u " 533 533 "but conn buffer is only %u (opcode %0x)\n", 534 534 tcp_conn->in.datalen, 535 - DEFAULT_MAX_RECV_DATA_SEGMENT_LENGTH, opcode); 535 + ISCSI_DEF_MAX_RECV_SEG_LEN, opcode); 536 536 rc = ISCSI_ERR_PROTO; 537 537 break; 538 538 } ··· 1762 1762 * due to strange issues with iser these are not set 1763 1763 * in iscsi_conn_setup 1764 1764 */ 1765 - conn->max_recv_dlength = DEFAULT_MAX_RECV_DATA_SEGMENT_LENGTH; 1765 + conn->max_recv_dlength = ISCSI_DEF_MAX_RECV_SEG_LEN; 1766 1766 1767 1767 tcp_conn = kzalloc(sizeof(*tcp_conn), GFP_KERNEL); 1768 1768 if (!tcp_conn) ··· 1777 1777 tcp_conn->tx_hash.tfm = crypto_alloc_hash("crc32c", 0, 1778 1778 CRYPTO_ALG_ASYNC); 1779 1779 tcp_conn->tx_hash.flags = 0; 1780 - if (IS_ERR(tcp_conn->tx_hash.tfm)) 1780 + if (IS_ERR(tcp_conn->tx_hash.tfm)) { 1781 + printk(KERN_ERR "Could not create connection due to crc32c " 1782 + "loading error %ld. Make sure the crc32c module is " 1783 + "built as a module or into the kernel\n", 1784 + PTR_ERR(tcp_conn->tx_hash.tfm)); 1781 1785 goto free_tcp_conn; 1786 + } 1782 1787 1783 1788 tcp_conn->rx_hash.tfm = crypto_alloc_hash("crc32c", 0, 1784 1789 CRYPTO_ALG_ASYNC); 1785 1790 tcp_conn->rx_hash.flags = 0; 1786 - if (IS_ERR(tcp_conn->rx_hash.tfm)) 1791 + if (IS_ERR(tcp_conn->rx_hash.tfm)) { 1792 + printk(KERN_ERR "Could not create connection due to crc32c " 1793 + "loading error %ld. Make sure the crc32c module is " 1794 + "built as a module or into the kernel\n", 1795 + PTR_ERR(tcp_conn->rx_hash.tfm)); 1787 1796 goto free_tx_tfm; 1797 + } 1788 1798 1789 1799 return cls_conn; 1790 1800 ··· 2148 2138 .change_queue_depth = iscsi_change_queue_depth, 2149 2139 .can_queue = ISCSI_XMIT_CMDS_MAX - 1, 2150 2140 .sg_tablesize = ISCSI_SG_TABLESIZE, 2141 + .max_sectors = 0xFFFF, 2151 2142 .cmd_per_lun = ISCSI_DEF_CMD_PER_LUN, 2152 2143 .eh_abort_handler = iscsi_eh_abort, 2153 2144 .eh_host_reset_handler = iscsi_eh_host_reset,
+15 -14
drivers/scsi/libiscsi.c
··· 25 25 #include <linux/mutex.h> 26 26 #include <linux/kfifo.h> 27 27 #include <linux/delay.h> 28 + #include <asm/unaligned.h> 28 29 #include <net/tcp.h> 29 30 #include <scsi/scsi_cmnd.h> 30 31 #include <scsi/scsi_device.h> ··· 270 269 goto out; 271 270 } 272 271 273 - senselen = be16_to_cpu(*(__be16 *)data); 272 + senselen = be16_to_cpu(get_unaligned((__be16 *) data)); 274 273 if (datalen < senselen) 275 274 goto invalid_datalen; 276 275 277 276 memcpy(sc->sense_buffer, data + 2, 278 277 min_t(uint16_t, senselen, SCSI_SENSE_BUFFERSIZE)); 279 278 debug_scsi("copied %d bytes of sense\n", 280 - min(senselen, SCSI_SENSE_BUFFERSIZE)); 279 + min_t(uint16_t, senselen, SCSI_SENSE_BUFFERSIZE)); 281 280 } 282 281 283 282 if (sc->sc_data_direction == DMA_TO_DEVICE) ··· 578 577 } 579 578 EXPORT_SYMBOL_GPL(iscsi_conn_failure); 580 579 581 - static int iscsi_xmit_imm_task(struct iscsi_conn *conn) 580 + static int iscsi_xmit_mtask(struct iscsi_conn *conn) 582 581 { 583 582 struct iscsi_hdr *hdr = conn->mtask->hdr; 584 583 int rc, was_logout = 0; ··· 591 590 rc = conn->session->tt->xmit_mgmt_task(conn, conn->mtask); 592 591 if (rc) 593 592 return rc; 593 + 594 + /* done with this in-progress mtask */ 595 + conn->mtask = NULL; 594 596 595 597 if (was_logout) { 596 598 set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx); ··· 647 643 conn->ctask = NULL; 648 644 } 649 645 if (conn->mtask) { 650 - rc = iscsi_xmit_imm_task(conn); 646 + rc = iscsi_xmit_mtask(conn); 651 647 if (rc) 652 648 goto again; 653 - /* done with this in-progress mtask */ 654 - conn->mtask = NULL; 655 649 } 656 650 657 651 /* process immediate first */ ··· 660 658 list_add_tail(&conn->mtask->running, 661 659 &conn->mgmt_run_list); 662 660 spin_unlock_bh(&conn->session->lock); 663 - rc = iscsi_xmit_imm_task(conn); 661 + rc = iscsi_xmit_mtask(conn); 664 662 if (rc) 665 663 goto again; 666 664 } 667 - /* done with this mtask */ 668 - conn->mtask = NULL; 669 665 } 670 666 671 667 /* process command queue */ ··· 701 701 list_add_tail(&conn->mtask->running, 702 702 &conn->mgmt_run_list); 703 703 spin_unlock_bh(&conn->session->lock); 704 - rc = tt->xmit_mgmt_task(conn, conn->mtask); 705 - if (rc) 704 + rc = iscsi_xmit_mtask(conn); 705 + if (rc) 706 706 goto again; 707 707 } 708 - /* done with this mtask */ 709 - conn->mtask = NULL; 710 708 } 711 709 712 710 return -ENODATA; ··· 1521 1523 } 1522 1524 spin_unlock_bh(&session->lock); 1523 1525 1524 - data = kmalloc(DEFAULT_MAX_RECV_DATA_SEGMENT_LENGTH, GFP_KERNEL); 1526 + data = kmalloc(ISCSI_DEF_MAX_RECV_SEG_LEN, GFP_KERNEL); 1525 1527 if (!data) 1526 1528 goto login_mtask_data_alloc_fail; 1527 1529 conn->login_mtask->data = conn->data = data; ··· 1594 1596 */ 1595 1597 wake_up(&conn->ehwait); 1596 1598 } 1599 + 1600 + /* flush queued up work because we free the connection below */ 1601 + scsi_flush_work(session->host); 1597 1602 1598 1603 spin_lock_bh(&session->lock); 1599 1604 kfree(conn->data);
+6 -6
drivers/scsi/libsrp.c
··· 224 224 struct srp_direct_buf *md = NULL; 225 225 struct scatterlist dummy, *sg = NULL; 226 226 dma_addr_t token = 0; 227 - long err; 228 - unsigned int done = 0; 227 + int err = 0; 229 228 int nmd, nsg = 0, len; 230 229 231 230 if (dma_map || ext_desc) { ··· 256 257 sg_dma_address(&dummy) = token; 257 258 err = rdma_io(sc, &dummy, 1, &id->table_desc, 1, DMA_TO_DEVICE, 258 259 id->table_desc.len); 259 - if (err < 0) { 260 - eprintk("Error copying indirect table %ld\n", err); 260 + if (err) { 261 + eprintk("Error copying indirect table %d\n", err); 261 262 goto free_mem; 262 263 } 263 264 } else { ··· 270 271 nsg = dma_map_sg(iue->target->dev, sg, sc->use_sg, DMA_BIDIRECTIONAL); 271 272 if (!nsg) { 272 273 eprintk("fail to map %p %d\n", iue, sc->use_sg); 274 + err = -EIO; 273 275 goto free_mem; 274 276 } 275 277 len = min(sc->request_bufflen, id->len); ··· 286 286 if (token && dma_map) 287 287 dma_free_coherent(iue->target->dev, id->table_desc.len, md, token); 288 288 289 - return done; 289 + return err; 290 290 } 291 291 292 292 static int data_out_desc_size(struct srp_cmd *cmd) ··· 351 351 break; 352 352 default: 353 353 eprintk("Unknown format %d %x\n", dir, format); 354 - break; 354 + err = -EINVAL; 355 355 } 356 356 357 357 return err;
+1 -1
drivers/scsi/lpfc/lpfc_init.c
··· 671 671 lpfc_parse_vpd(struct lpfc_hba * phba, uint8_t * vpd, int len) 672 672 { 673 673 uint8_t lenlo, lenhi; 674 - uint32_t Length; 674 + int Length; 675 675 int i, j; 676 676 int finished = 0; 677 677 int index = 0;
+1
drivers/scsi/osst.c
··· 87 87 MODULE_DESCRIPTION("OnStream {DI-|FW-|SC-|USB}{30|50} Tape Driver"); 88 88 MODULE_LICENSE("GPL"); 89 89 MODULE_ALIAS_CHARDEV_MAJOR(OSST_MAJOR); 90 + MODULE_ALIAS_SCSI_DEVICE(TYPE_TAPE); 90 91 91 92 module_param(max_dev, int, 0444); 92 93 MODULE_PARM_DESC(max_dev, "Maximum number of OnStream Tape Drives to attach (4)");
-197
drivers/scsi/pci2000.h
··· 1 - /**************************************************************************** 2 - * Perceptive Solutions, Inc. PCI-2000 device driver for Linux. 3 - * 4 - * pci2000.h - Linux Host Driver for PCI-2000 IntelliCache SCSI Adapters 5 - * 6 - * Copyright (c) 1997-1999 Perceptive Solutions, Inc. 7 - * All Rights Reserved. 8 - * 9 - * Redistribution and use in source and binary forms, with or without 10 - * modification, are permitted provided that redistributions of source 11 - * code retain the above copyright notice and this comment without 12 - * modification. 13 - * 14 - * Technical updates and product information at: 15 - * http://www.psidisk.com 16 - * 17 - * Please send questions, comments, bug reports to: 18 - * tech@psidisk.com Technical Support 19 - * 20 - ****************************************************************************/ 21 - #ifndef _PCI2000_H 22 - #define _PCI2000_H 23 - 24 - #include <linux/types.h> 25 - 26 - #ifndef PSI_EIDE_SCSIOP 27 - #define PSI_EIDE_SCSIOP 1 28 - 29 - #define LINUXVERSION(v,p,s) (((v)<<16) + ((p)<<8) + (s)) 30 - 31 - /************************************************/ 32 - /* definition of standard data types */ 33 - /************************************************/ 34 - #define CHAR char 35 - #define UCHAR unsigned char 36 - #define SHORT short 37 - #define USHORT unsigned short 38 - #define BOOL long 39 - #define LONG long 40 - #define ULONG unsigned long 41 - #define VOID void 42 - 43 - typedef CHAR *PCHAR; 44 - typedef UCHAR *PUCHAR; 45 - typedef SHORT *PSHORT; 46 - typedef USHORT *PUSHORT; 47 - typedef BOOL *PBOOL; 48 - typedef LONG *PLONG; 49 - typedef ULONG *PULONG; 50 - typedef VOID *PVOID; 51 - 52 - 53 - /************************************************/ 54 - /* Misc. macros */ 55 - /************************************************/ 56 - #define ANY2SCSI(up, p) \ 57 - ((UCHAR *)up)[0] = (((ULONG)(p)) >> 8); \ 58 - ((UCHAR *)up)[1] = ((ULONG)(p)); 59 - 60 - #define SCSI2LONG(up) \ 61 - ( (((long)*(((UCHAR *)up))) << 16) \ 62 - + (((long)(((UCHAR *)up)[1])) << 8) \ 63 - + ((long)(((UCHAR *)up)[2])) ) 64 - 65 - #define XANY2SCSI(up, p) \ 66 - ((UCHAR *)up)[0] = ((long)(p)) >> 24; \ 67 - ((UCHAR *)up)[1] = ((long)(p)) >> 16; \ 68 - ((UCHAR *)up)[2] = ((long)(p)) >> 8; \ 69 - ((UCHAR *)up)[3] = ((long)(p)); 70 - 71 - #define XSCSI2LONG(up) \ 72 - ( (((long)(((UCHAR *)up)[0])) << 24) \ 73 - + (((long)(((UCHAR *)up)[1])) << 16) \ 74 - + (((long)(((UCHAR *)up)[2])) << 8) \ 75 - + ((long)(((UCHAR *)up)[3])) ) 76 - 77 - /************************************************/ 78 - /* SCSI CDB operation codes */ 79 - /************************************************/ 80 - #define SCSIOP_TEST_UNIT_READY 0x00 81 - #define SCSIOP_REZERO_UNIT 0x01 82 - #define SCSIOP_REWIND 0x01 83 - #define SCSIOP_REQUEST_BLOCK_ADDR 0x02 84 - #define SCSIOP_REQUEST_SENSE 0x03 85 - #define SCSIOP_FORMAT_UNIT 0x04 86 - #define SCSIOP_READ_BLOCK_LIMITS 0x05 87 - #define SCSIOP_REASSIGN_BLOCKS 0x07 88 - #define SCSIOP_READ6 0x08 89 - #define SCSIOP_RECEIVE 0x08 90 - #define SCSIOP_WRITE6 0x0A 91 - #define SCSIOP_PRINT 0x0A 92 - #define SCSIOP_SEND 0x0A 93 - #define SCSIOP_SEEK6 0x0B 94 - #define SCSIOP_TRACK_SELECT 0x0B 95 - #define SCSIOP_SLEW_PRINT 0x0B 96 - #define SCSIOP_SEEK_BLOCK 0x0C 97 - #define SCSIOP_PARTITION 0x0D 98 - #define SCSIOP_READ_REVERSE 0x0F 99 - #define SCSIOP_WRITE_FILEMARKS 0x10 100 - #define SCSIOP_FLUSH_BUFFER 0x10 101 - #define SCSIOP_SPACE 0x11 102 - #define SCSIOP_INQUIRY 0x12 103 - #define SCSIOP_VERIFY6 0x13 104 - #define SCSIOP_RECOVER_BUF_DATA 0x14 105 - #define SCSIOP_MODE_SELECT 0x15 106 - #define SCSIOP_RESERVE_UNIT 0x16 107 - #define SCSIOP_RELEASE_UNIT 0x17 108 - #define SCSIOP_COPY 0x18 109 - #define SCSIOP_ERASE 0x19 110 - #define SCSIOP_MODE_SENSE 0x1A 111 - #define SCSIOP_START_STOP_UNIT 0x1B 112 - #define SCSIOP_STOP_PRINT 0x1B 113 - #define SCSIOP_LOAD_UNLOAD 0x1B 114 - #define SCSIOP_RECEIVE_DIAGNOSTIC 0x1C 115 - #define SCSIOP_SEND_DIAGNOSTIC 0x1D 116 - #define SCSIOP_MEDIUM_REMOVAL 0x1E 117 - #define SCSIOP_READ_CAPACITY 0x25 118 - #define SCSIOP_READ 0x28 119 - #define SCSIOP_WRITE 0x2A 120 - #define SCSIOP_SEEK 0x2B 121 - #define SCSIOP_LOCATE 0x2B 122 - #define SCSIOP_WRITE_VERIFY 0x2E 123 - #define SCSIOP_VERIFY 0x2F 124 - #define SCSIOP_SEARCH_DATA_HIGH 0x30 125 - #define SCSIOP_SEARCH_DATA_EQUAL 0x31 126 - #define SCSIOP_SEARCH_DATA_LOW 0x32 127 - #define SCSIOP_SET_LIMITS 0x33 128 - #define SCSIOP_READ_POSITION 0x34 129 - #define SCSIOP_SYNCHRONIZE_CACHE 0x35 130 - #define SCSIOP_COMPARE 0x39 131 - #define SCSIOP_COPY_COMPARE 0x3A 132 - #define SCSIOP_WRITE_DATA_BUFF 0x3B 133 - #define SCSIOP_READ_DATA_BUFF 0x3C 134 - #define SCSIOP_CHANGE_DEFINITION 0x40 135 - #define SCSIOP_READ_SUB_CHANNEL 0x42 136 - #define SCSIOP_READ_TOC 0x43 137 - #define SCSIOP_READ_HEADER 0x44 138 - #define SCSIOP_PLAY_AUDIO 0x45 139 - #define SCSIOP_PLAY_AUDIO_MSF 0x47 140 - #define SCSIOP_PLAY_TRACK_INDEX 0x48 141 - #define SCSIOP_PLAY_TRACK_RELATIVE 0x49 142 - #define SCSIOP_PAUSE_RESUME 0x4B 143 - #define SCSIOP_LOG_SELECT 0x4C 144 - #define SCSIOP_LOG_SENSE 0x4D 145 - #define SCSIOP_MODE_SELECT10 0x55 146 - #define SCSIOP_MODE_SENSE10 0x5A 147 - #define SCSIOP_LOAD_UNLOAD_SLOT 0xA6 148 - #define SCSIOP_MECHANISM_STATUS 0xBD 149 - #define SCSIOP_READ_CD 0xBE 150 - 151 - // SCSI read capacity structure 152 - typedef struct _READ_CAPACITY_DATA 153 - { 154 - ULONG blks; /* total blocks (converted to little endian) */ 155 - ULONG blksiz; /* size of each (converted to little endian) */ 156 - } READ_CAPACITY_DATA, *PREAD_CAPACITY_DATA; 157 - 158 - // SCSI inquiry data 159 - typedef struct _INQUIRYDATA 160 - { 161 - UCHAR DeviceType :5; 162 - UCHAR DeviceTypeQualifier :3; 163 - UCHAR DeviceTypeModifier :7; 164 - UCHAR RemovableMedia :1; 165 - UCHAR Versions; 166 - UCHAR ResponseDataFormat; 167 - UCHAR AdditionalLength; 168 - UCHAR Reserved[2]; 169 - UCHAR SoftReset :1; 170 - UCHAR CommandQueue :1; 171 - UCHAR Reserved2 :1; 172 - UCHAR LinkedCommands :1; 173 - UCHAR Synchronous :1; 174 - UCHAR Wide16Bit :1; 175 - UCHAR Wide32Bit :1; 176 - UCHAR RelativeAddressing :1; 177 - UCHAR VendorId[8]; 178 - UCHAR ProductId[16]; 179 - UCHAR ProductRevisionLevel[4]; 180 - UCHAR VendorSpecific[20]; 181 - UCHAR Reserved3[40]; 182 - } INQUIRYDATA, *PINQUIRYDATA; 183 - 184 - #endif 185 - 186 - // function prototypes 187 - int Pci2000_Detect (struct scsi_host_template *tpnt); 188 - int Pci2000_Command (Scsi_Cmnd *SCpnt); 189 - int Pci2000_QueueCommand (Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *)); 190 - int Pci2000_Abort (Scsi_Cmnd *SCpnt); 191 - int Pci2000_Reset (Scsi_Cmnd *SCpnt, unsigned int flags); 192 - int Pci2000_Release (struct Scsi_Host *pshost); 193 - int Pci2000_BiosParam (struct scsi_device *sdev, 194 - struct block_device *bdev, 195 - sector_t capacity, int geom[]); 196 - 197 - #endif
+3 -6
drivers/scsi/pcmcia/Kconfig
··· 3 3 # 4 4 5 5 menu "PCMCIA SCSI adapter support" 6 - depends on SCSI!=n && PCMCIA!=n && MODULES 6 + depends on SCSI!=n && PCMCIA!=n 7 7 8 8 config PCMCIA_AHA152X 9 9 tristate "Adaptec AHA152X PCMCIA support" 10 - depends on m && !64BIT 10 + depends on !64BIT 11 11 select SCSI_SPI_ATTRS 12 12 help 13 13 Say Y here if you intend to attach this type of PCMCIA SCSI host ··· 18 18 19 19 config PCMCIA_FDOMAIN 20 20 tristate "Future Domain PCMCIA support" 21 - depends on m 22 21 help 23 22 Say Y here if you intend to attach this type of PCMCIA SCSI host 24 23 adapter to your computer. ··· 27 28 28 29 config PCMCIA_NINJA_SCSI 29 30 tristate "NinjaSCSI-3 / NinjaSCSI-32Bi (16bit) PCMCIA support" 30 - depends on m && !64BIT 31 + depends on !64BIT 31 32 help 32 33 If you intend to attach this type of PCMCIA SCSI host adapter to 33 34 your computer, say Y here and read ··· 61 62 62 63 config PCMCIA_QLOGIC 63 64 tristate "Qlogic PCMCIA support" 64 - depends on m 65 65 help 66 66 Say Y here if you intend to attach this type of PCMCIA SCSI host 67 67 adapter to your computer. ··· 70 72 71 73 config PCMCIA_SYM53C500 72 74 tristate "Symbios 53c500 PCMCIA support" 73 - depends on m 74 75 help 75 76 Say Y here if you have a New Media Bus Toaster or other PCMCIA 76 77 SCSI adapter based on the Symbios 53c500 controller.
+8 -5
drivers/scsi/qla2xxx/qla_def.h
··· 1478 1478 uint32_t b24 : 24; 1479 1479 1480 1480 struct { 1481 - uint8_t d_id[3]; 1482 - uint8_t rsvd_1; 1483 - } r; 1484 - 1485 - struct { 1481 + #ifdef __BIG_ENDIAN 1482 + uint8_t domain; 1483 + uint8_t area; 1484 + uint8_t al_pa; 1485 + #elif __LITTLE_ENDIAN 1486 1486 uint8_t al_pa; 1487 1487 uint8_t area; 1488 1488 uint8_t domain; 1489 + #else 1490 + #error "__BIG_ENDIAN or __LITTLE_ENDIAN must be defined!" 1491 + #endif 1489 1492 uint8_t rsvd_1; 1490 1493 } b; 1491 1494 } port_id_t;
+163 -14
drivers/scsi/qla2xxx/qla_init.c
··· 11 11 12 12 #include "qla_devtbl.h" 13 13 14 + #ifdef CONFIG_SPARC 15 + #include <asm/prom.h> 16 + #include <asm/pbm.h> 17 + #endif 18 + 14 19 /* XXX(hch): this is ugly, but we don't want to pull in exioctl.h */ 15 20 #ifndef EXT_IS_LUN_BIT_SET 16 21 #define EXT_IS_LUN_BIT_SET(P,L) \ ··· 93 88 94 89 qla_printk(KERN_INFO, ha, "Configure NVRAM parameters...\n"); 95 90 96 - rval = ha->isp_ops.nvram_config(ha); 97 - if (rval) { 98 - DEBUG2(printk("scsi(%ld): Unable to verify NVRAM data.\n", 99 - ha->host_no)); 100 - return rval; 101 - } 91 + ha->isp_ops.nvram_config(ha); 102 92 103 93 if (ha->flags.disable_serdes) { 104 94 /* Mask HBA via NVRAM settings? */ ··· 1393 1393 } 1394 1394 } 1395 1395 1396 + /* On sparc systems, obtain port and node WWN from firmware 1397 + * properties. 1398 + */ 1399 + static void qla2xxx_nvram_wwn_from_ofw(scsi_qla_host_t *ha, nvram_t *nv) 1400 + { 1401 + #ifdef CONFIG_SPARC 1402 + struct pci_dev *pdev = ha->pdev; 1403 + struct pcidev_cookie *pcp = pdev->sysdata; 1404 + struct device_node *dp = pcp->prom_node; 1405 + u8 *val; 1406 + int len; 1407 + 1408 + val = of_get_property(dp, "port-wwn", &len); 1409 + if (val && len >= WWN_SIZE) 1410 + memcpy(nv->port_name, val, WWN_SIZE); 1411 + 1412 + val = of_get_property(dp, "node-wwn", &len); 1413 + if (val && len >= WWN_SIZE) 1414 + memcpy(nv->node_name, val, WWN_SIZE); 1415 + #endif 1416 + } 1417 + 1396 1418 /* 1397 1419 * NVRAM configuration for ISP 2xxx 1398 1420 * ··· 1431 1409 int 1432 1410 qla2x00_nvram_config(scsi_qla_host_t *ha) 1433 1411 { 1412 + int rval; 1434 1413 uint8_t chksum = 0; 1435 1414 uint16_t cnt; 1436 1415 uint8_t *dptr1, *dptr2; ··· 1439 1416 nvram_t *nv = (nvram_t *)ha->request_ring; 1440 1417 uint8_t *ptr = (uint8_t *)ha->request_ring; 1441 1418 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; 1419 + 1420 + rval = QLA_SUCCESS; 1442 1421 1443 1422 /* Determine NVRAM starting address. */ 1444 1423 ha->nvram_size = sizeof(nvram_t); ··· 1465 1440 qla_printk(KERN_WARNING, ha, "Inconsistent NVRAM detected: " 1466 1441 "checksum=0x%x id=%c version=0x%x.\n", chksum, nv->id[0], 1467 1442 nv->nvram_version); 1468 - return QLA_FUNCTION_FAILED; 1443 + qla_printk(KERN_WARNING, ha, "Falling back to functioning (yet " 1444 + "invalid -- WWPN) defaults.\n"); 1445 + 1446 + /* 1447 + * Set default initialization control block. 1448 + */ 1449 + memset(nv, 0, ha->nvram_size); 1450 + nv->parameter_block_version = ICB_VERSION; 1451 + 1452 + if (IS_QLA23XX(ha)) { 1453 + nv->firmware_options[0] = BIT_2 | BIT_1; 1454 + nv->firmware_options[1] = BIT_7 | BIT_5; 1455 + nv->add_firmware_options[0] = BIT_5; 1456 + nv->add_firmware_options[1] = BIT_5 | BIT_4; 1457 + nv->frame_payload_size = __constant_cpu_to_le16(2048); 1458 + nv->special_options[1] = BIT_7; 1459 + } else if (IS_QLA2200(ha)) { 1460 + nv->firmware_options[0] = BIT_2 | BIT_1; 1461 + nv->firmware_options[1] = BIT_7 | BIT_5; 1462 + nv->add_firmware_options[0] = BIT_5; 1463 + nv->add_firmware_options[1] = BIT_5 | BIT_4; 1464 + nv->frame_payload_size = __constant_cpu_to_le16(1024); 1465 + } else if (IS_QLA2100(ha)) { 1466 + nv->firmware_options[0] = BIT_3 | BIT_1; 1467 + nv->firmware_options[1] = BIT_5; 1468 + nv->frame_payload_size = __constant_cpu_to_le16(1024); 1469 + } 1470 + 1471 + nv->max_iocb_allocation = __constant_cpu_to_le16(256); 1472 + nv->execution_throttle = __constant_cpu_to_le16(16); 1473 + nv->retry_count = 8; 1474 + nv->retry_delay = 1; 1475 + 1476 + nv->port_name[0] = 33; 1477 + nv->port_name[3] = 224; 1478 + nv->port_name[4] = 139; 1479 + 1480 + qla2xxx_nvram_wwn_from_ofw(ha, nv); 1481 + 1482 + nv->login_timeout = 4; 1483 + 1484 + /* 1485 + * Set default host adapter parameters 1486 + */ 1487 + nv->host_p[1] = BIT_2; 1488 + nv->reset_delay = 5; 1489 + nv->port_down_retry_count = 8; 1490 + nv->max_luns_per_target = __constant_cpu_to_le16(8); 1491 + nv->link_down_timeout = 60; 1492 + 1493 + rval = 1; 1469 1494 } 1470 1495 1471 1496 #if defined(CONFIG_IA64_GENERIC) || defined(CONFIG_IA64_SGI_SN2) ··· 1728 1653 } 1729 1654 } 1730 1655 1731 - return QLA_SUCCESS; 1656 + if (rval) { 1657 + DEBUG2_3(printk(KERN_WARNING 1658 + "scsi(%ld): NVRAM configuration failed!\n", ha->host_no)); 1659 + } 1660 + return (rval); 1732 1661 } 1733 1662 1734 1663 static void ··· 3150 3071 3151 3072 ha->isp_ops.get_flash_version(ha, ha->request_ring); 3152 3073 3153 - rval = ha->isp_ops.nvram_config(ha); 3154 - if (rval) 3155 - goto isp_abort_retry; 3074 + ha->isp_ops.nvram_config(ha); 3156 3075 3157 3076 if (!qla2x00_restart_isp(ha)) { 3158 3077 clear_bit(RESET_MARKER_NEEDED, &ha->dpc_flags); ··· 3180 3103 } 3181 3104 } 3182 3105 } else { /* failed the ISP abort */ 3183 - isp_abort_retry: 3184 3106 ha->flags.online = 1; 3185 3107 if (test_bit(ISP_ABORT_RETRY, &ha->dpc_flags)) { 3186 3108 if (ha->isp_abort_cnt == 0) { ··· 3366 3290 spin_unlock_irqrestore(&ha->hardware_lock, flags); 3367 3291 } 3368 3292 3293 + /* On sparc systems, obtain port and node WWN from firmware 3294 + * properties. 3295 + */ 3296 + static void qla24xx_nvram_wwn_from_ofw(scsi_qla_host_t *ha, struct nvram_24xx *nv) 3297 + { 3298 + #ifdef CONFIG_SPARC 3299 + struct pci_dev *pdev = ha->pdev; 3300 + struct pcidev_cookie *pcp = pdev->sysdata; 3301 + struct device_node *dp = pcp->prom_node; 3302 + u8 *val; 3303 + int len; 3304 + 3305 + val = of_get_property(dp, "port-wwn", &len); 3306 + if (val && len >= WWN_SIZE) 3307 + memcpy(nv->port_name, val, WWN_SIZE); 3308 + 3309 + val = of_get_property(dp, "node-wwn", &len); 3310 + if (val && len >= WWN_SIZE) 3311 + memcpy(nv->node_name, val, WWN_SIZE); 3312 + #endif 3313 + } 3314 + 3369 3315 int 3370 3316 qla24xx_nvram_config(scsi_qla_host_t *ha) 3371 3317 { 3318 + int rval; 3372 3319 struct init_cb_24xx *icb; 3373 3320 struct nvram_24xx *nv; 3374 3321 uint32_t *dptr; ··· 3399 3300 uint32_t chksum; 3400 3301 uint16_t cnt; 3401 3302 3303 + rval = QLA_SUCCESS; 3402 3304 icb = (struct init_cb_24xx *)ha->init_cb; 3403 3305 nv = (struct nvram_24xx *)ha->request_ring; 3404 3306 ··· 3432 3332 qla_printk(KERN_WARNING, ha, "Inconsistent NVRAM detected: " 3433 3333 "checksum=0x%x id=%c version=0x%x.\n", chksum, nv->id[0], 3434 3334 le16_to_cpu(nv->nvram_version)); 3435 - return QLA_FUNCTION_FAILED; 3335 + qla_printk(KERN_WARNING, ha, "Falling back to functioning (yet " 3336 + "invalid -- WWPN) defaults.\n"); 3337 + 3338 + /* 3339 + * Set default initialization control block. 3340 + */ 3341 + memset(nv, 0, ha->nvram_size); 3342 + nv->nvram_version = __constant_cpu_to_le16(ICB_VERSION); 3343 + nv->version = __constant_cpu_to_le16(ICB_VERSION); 3344 + nv->frame_payload_size = __constant_cpu_to_le16(2048); 3345 + nv->execution_throttle = __constant_cpu_to_le16(0xFFFF); 3346 + nv->exchange_count = __constant_cpu_to_le16(0); 3347 + nv->hard_address = __constant_cpu_to_le16(124); 3348 + nv->port_name[0] = 0x21; 3349 + nv->port_name[1] = 0x00 + PCI_FUNC(ha->pdev->devfn); 3350 + nv->port_name[2] = 0x00; 3351 + nv->port_name[3] = 0xe0; 3352 + nv->port_name[4] = 0x8b; 3353 + nv->port_name[5] = 0x1c; 3354 + nv->port_name[6] = 0x55; 3355 + nv->port_name[7] = 0x86; 3356 + nv->node_name[0] = 0x20; 3357 + nv->node_name[1] = 0x00; 3358 + nv->node_name[2] = 0x00; 3359 + nv->node_name[3] = 0xe0; 3360 + nv->node_name[4] = 0x8b; 3361 + nv->node_name[5] = 0x1c; 3362 + nv->node_name[6] = 0x55; 3363 + nv->node_name[7] = 0x86; 3364 + qla24xx_nvram_wwn_from_ofw(ha, nv); 3365 + nv->login_retry_count = __constant_cpu_to_le16(8); 3366 + nv->interrupt_delay_timer = __constant_cpu_to_le16(0); 3367 + nv->login_timeout = __constant_cpu_to_le16(0); 3368 + nv->firmware_options_1 = 3369 + __constant_cpu_to_le32(BIT_14|BIT_13|BIT_2|BIT_1); 3370 + nv->firmware_options_2 = __constant_cpu_to_le32(2 << 4); 3371 + nv->firmware_options_2 |= __constant_cpu_to_le32(BIT_12); 3372 + nv->firmware_options_3 = __constant_cpu_to_le32(2 << 13); 3373 + nv->host_p = __constant_cpu_to_le32(BIT_11|BIT_10); 3374 + nv->efi_parameters = __constant_cpu_to_le32(0); 3375 + nv->reset_delay = 5; 3376 + nv->max_luns_per_target = __constant_cpu_to_le16(128); 3377 + nv->port_down_retry_count = __constant_cpu_to_le16(30); 3378 + nv->link_down_timeout = __constant_cpu_to_le16(30); 3379 + 3380 + rval = 1; 3436 3381 } 3437 3382 3438 3383 /* Reset Initialization control block */ ··· 3624 3479 ha->flags.process_response_queue = 1; 3625 3480 } 3626 3481 3627 - return QLA_SUCCESS; 3482 + if (rval) { 3483 + DEBUG2_3(printk(KERN_WARNING 3484 + "scsi(%ld): NVRAM configuration failed!\n", ha->host_no)); 3485 + } 3486 + return (rval); 3628 3487 } 3629 3488 3630 3489 static int
+8 -8
drivers/scsi/qla2xxx/qla_mbx.c
··· 1280 1280 } else { 1281 1281 if (name != NULL) { 1282 1282 /* This function returns name in big endian. */ 1283 - name[0] = LSB(mcp->mb[2]); 1284 - name[1] = MSB(mcp->mb[2]); 1285 - name[2] = LSB(mcp->mb[3]); 1286 - name[3] = MSB(mcp->mb[3]); 1287 - name[4] = LSB(mcp->mb[6]); 1288 - name[5] = MSB(mcp->mb[6]); 1289 - name[6] = LSB(mcp->mb[7]); 1290 - name[7] = MSB(mcp->mb[7]); 1283 + name[0] = MSB(mcp->mb[2]); 1284 + name[1] = LSB(mcp->mb[2]); 1285 + name[2] = MSB(mcp->mb[3]); 1286 + name[3] = LSB(mcp->mb[3]); 1287 + name[4] = MSB(mcp->mb[6]); 1288 + name[5] = LSB(mcp->mb[6]); 1289 + name[6] = MSB(mcp->mb[7]); 1290 + name[7] = LSB(mcp->mb[7]); 1291 1291 } 1292 1292 1293 1293 DEBUG11(printk("qla2x00_get_port_name(%ld): done.\n",
+4 -3
drivers/scsi/qla2xxx/qla_os.c
··· 62 62 "vary by ISP type. Default is 1 - allocate memory."); 63 63 64 64 int ql2xextended_error_logging; 65 - module_param(ql2xextended_error_logging, int, S_IRUGO|S_IRUSR); 65 + module_param(ql2xextended_error_logging, int, S_IRUGO|S_IWUSR); 66 66 MODULE_PARM_DESC(ql2xextended_error_logging, 67 67 "Option to enable extended error logging, " 68 68 "Default is 0 - no logging. 1 - log errors."); ··· 157 157 158 158 .slave_alloc = qla2xxx_slave_alloc, 159 159 .slave_destroy = qla2xxx_slave_destroy, 160 + .scan_finished = qla2xxx_scan_finished, 161 + .scan_start = qla2xxx_scan_start, 160 162 .change_queue_depth = qla2x00_change_queue_depth, 161 163 .change_queue_type = qla2x00_change_queue_type, 162 164 .this_id = -1, ··· 1707 1705 1708 1706 scsi_host_put(ha->host); 1709 1707 1708 + pci_disable_device(pdev); 1710 1709 pci_set_drvdata(pdev, NULL); 1711 1710 } 1712 1711 ··· 1750 1747 if (ha->iobase) 1751 1748 iounmap(ha->iobase); 1752 1749 pci_release_regions(ha->pdev); 1753 - 1754 - pci_disable_device(ha->pdev); 1755 1750 } 1756 1751 1757 1752 static inline void
+5 -6
drivers/scsi/qla2xxx/qla_sup.c
··· 466 466 udelay(10); 467 467 else 468 468 rval = QLA_FUNCTION_TIMEOUT; 469 + cond_resched(); 469 470 } 470 471 471 472 /* TODO: What happens if we time out? */ ··· 509 508 udelay(10); 510 509 else 511 510 rval = QLA_FUNCTION_TIMEOUT; 511 + cond_resched(); 512 512 } 513 513 return rval; 514 514 } ··· 1257 1255 } 1258 1256 udelay(10); 1259 1257 barrier(); 1258 + cond_resched(); 1260 1259 } 1261 1260 return status; 1262 1261 } ··· 1406 1403 if (saddr % 100) 1407 1404 udelay(10); 1408 1405 *tmp_buf = data; 1406 + cond_resched(); 1409 1407 } 1410 1408 } 1411 1409 ··· 1453 1449 qla2x00_read_optrom_data(struct scsi_qla_host *ha, uint8_t *buf, 1454 1450 uint32_t offset, uint32_t length) 1455 1451 { 1456 - unsigned long flags; 1457 1452 uint32_t addr, midpoint; 1458 1453 uint8_t *data; 1459 1454 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; ··· 1461 1458 qla2x00_suspend_hba(ha); 1462 1459 1463 1460 /* Go with read. */ 1464 - spin_lock_irqsave(&ha->hardware_lock, flags); 1465 1461 midpoint = ha->optrom_size / 2; 1466 1462 1467 1463 qla2x00_flash_enable(ha); ··· 1475 1473 *data = qla2x00_read_flash_byte(ha, addr); 1476 1474 } 1477 1475 qla2x00_flash_disable(ha); 1478 - spin_unlock_irqrestore(&ha->hardware_lock, flags); 1479 1476 1480 1477 /* Resume HBA. */ 1481 1478 qla2x00_resume_hba(ha); ··· 1488 1487 { 1489 1488 1490 1489 int rval; 1491 - unsigned long flags; 1492 1490 uint8_t man_id, flash_id, sec_number, data; 1493 1491 uint16_t wd; 1494 1492 uint32_t addr, liter, sec_mask, rest_addr; ··· 1500 1500 sec_number = 0; 1501 1501 1502 1502 /* Reset ISP chip. */ 1503 - spin_lock_irqsave(&ha->hardware_lock, flags); 1504 1503 WRT_REG_WORD(&reg->ctrl_status, CSR_ISP_SOFT_RESET); 1505 1504 pci_read_config_word(ha->pdev, PCI_COMMAND, &wd); 1506 1505 ··· 1688 1689 rval = QLA_FUNCTION_FAILED; 1689 1690 break; 1690 1691 } 1692 + cond_resched(); 1691 1693 } 1692 1694 } while (0); 1693 1695 qla2x00_flash_disable(ha); 1694 - spin_unlock_irqrestore(&ha->hardware_lock, flags); 1695 1696 1696 1697 /* Resume HBA. */ 1697 1698 qla2x00_resume_hba(ha);
+1 -1
drivers/scsi/qla2xxx/qla_version.h
··· 7 7 /* 8 8 * Driver version 9 9 */ 10 - #define QLA2XXX_VERSION "8.01.07-k5" 10 + #define QLA2XXX_VERSION "8.01.07-k6" 11 11 12 12 #define QLA_DRIVER_MAJOR_VER 8 13 13 #define QLA_DRIVER_MINOR_VER 1
+17 -30
drivers/scsi/scsi.c
··· 344 344 void scsi_log_send(struct scsi_cmnd *cmd) 345 345 { 346 346 unsigned int level; 347 - struct scsi_device *sdev; 348 347 349 348 /* 350 349 * If ML QUEUE log level is greater than or equal to: ··· 360 361 level = SCSI_LOG_LEVEL(SCSI_LOG_MLQUEUE_SHIFT, 361 362 SCSI_LOG_MLQUEUE_BITS); 362 363 if (level > 1) { 363 - sdev = cmd->device; 364 - sdev_printk(KERN_INFO, sdev, "send "); 364 + scmd_printk(KERN_INFO, cmd, "Send: "); 365 365 if (level > 2) 366 366 printk("0x%p ", cmd); 367 - /* 368 - * spaces to match disposition and cmd->result 369 - * output in scsi_log_completion. 370 - */ 371 - printk(" "); 367 + printk("\n"); 372 368 scsi_print_command(cmd); 373 369 if (level > 3) { 374 370 printk(KERN_INFO "buffer = 0x%p, bufflen = %d," 375 371 " done = 0x%p, queuecommand 0x%p\n", 376 372 cmd->request_buffer, cmd->request_bufflen, 377 373 cmd->done, 378 - sdev->host->hostt->queuecommand); 374 + cmd->device->host->hostt->queuecommand); 379 375 380 376 } 381 377 } ··· 380 386 void scsi_log_completion(struct scsi_cmnd *cmd, int disposition) 381 387 { 382 388 unsigned int level; 383 - struct scsi_device *sdev; 384 389 385 390 /* 386 391 * If ML COMPLETE log level is greater than or equal to: ··· 398 405 SCSI_LOG_MLCOMPLETE_BITS); 399 406 if (((level > 0) && (cmd->result || disposition != SUCCESS)) || 400 407 (level > 1)) { 401 - sdev = cmd->device; 402 - sdev_printk(KERN_INFO, sdev, "done "); 408 + scmd_printk(KERN_INFO, cmd, "Done: "); 403 409 if (level > 2) 404 410 printk("0x%p ", cmd); 405 411 /* ··· 407 415 */ 408 416 switch (disposition) { 409 417 case SUCCESS: 410 - printk("SUCCESS"); 418 + printk("SUCCESS\n"); 411 419 break; 412 420 case NEEDS_RETRY: 413 - printk("RETRY "); 421 + printk("RETRY\n"); 414 422 break; 415 423 case ADD_TO_MLQUEUE: 416 - printk("MLQUEUE"); 424 + printk("MLQUEUE\n"); 417 425 break; 418 426 case FAILED: 419 - printk("FAILED "); 427 + printk("FAILED\n"); 420 428 break; 421 429 case TIMEOUT_ERROR: 422 430 /* 423 431 * If called via scsi_times_out. 424 432 */ 425 - printk("TIMEOUT"); 433 + printk("TIMEOUT\n"); 426 434 break; 427 435 default: 428 - printk("UNKNOWN"); 436 + printk("UNKNOWN\n"); 429 437 } 430 - printk(" %8x ", cmd->result); 438 + scsi_print_result(cmd); 431 439 scsi_print_command(cmd); 432 - if (status_byte(cmd->result) & CHECK_CONDITION) { 433 - /* 434 - * XXX The scsi_print_sense formatting/prefix 435 - * doesn't match this function. 436 - */ 440 + if (status_byte(cmd->result) & CHECK_CONDITION) 437 441 scsi_print_sense("", cmd); 438 - } 439 - if (level > 3) { 440 - printk(KERN_INFO "scsi host busy %d failed %d\n", 441 - sdev->host->host_busy, 442 - sdev->host->host_failed); 443 - } 442 + if (level > 3) 443 + scmd_printk(KERN_INFO, cmd, 444 + "scsi host busy %d failed %d\n", 445 + cmd->device->host->host_busy, 446 + cmd->device->host->host_failed); 444 447 } 445 448 } 446 449 }
+15 -4
drivers/scsi/scsi_error.c
··· 184 184 **/ 185 185 void scsi_times_out(struct scsi_cmnd *scmd) 186 186 { 187 + enum scsi_eh_timer_return (* eh_timed_out)(struct scsi_cmnd *); 188 + 187 189 scsi_log_completion(scmd, TIMEOUT_ERROR); 188 190 189 191 if (scmd->device->host->transportt->eh_timed_out) 190 - switch (scmd->device->host->transportt->eh_timed_out(scmd)) { 192 + eh_timed_out = scmd->device->host->transportt->eh_timed_out; 193 + else if (scmd->device->host->hostt->eh_timed_out) 194 + eh_timed_out = scmd->device->host->hostt->eh_timed_out; 195 + else 196 + eh_timed_out = NULL; 197 + 198 + if (eh_timed_out) 199 + switch (eh_timed_out(scmd)) { 191 200 case EH_HANDLED: 192 201 __scsi_done(scmd); 193 202 return; ··· 932 923 static unsigned char stu_command[6] = {START_STOP, 0, 0, 0, 1, 0}; 933 924 934 925 if (scmd->device->allow_restart) { 935 - int rtn; 926 + int i, rtn = NEEDS_RETRY; 936 927 937 - rtn = scsi_send_eh_cmnd(scmd, stu_command, 6, 938 - START_UNIT_TIMEOUT, 0); 928 + for (i = 0; rtn == NEEDS_RETRY && i < 2; i++) 929 + rtn = scsi_send_eh_cmnd(scmd, stu_command, 6, 930 + START_UNIT_TIMEOUT, 0); 931 + 939 932 if (rtn == SUCCESS) 940 933 return 0; 941 934 }
+3 -5
drivers/scsi/scsi_lib.c
··· 848 848 memcpy(req->sense, cmd->sense_buffer, len); 849 849 req->sense_len = len; 850 850 } 851 - } else 852 - req->data_len = cmd->resid; 851 + } 852 + req->data_len = cmd->resid; 853 853 } 854 854 855 855 /* ··· 968 968 } 969 969 if (result) { 970 970 if (!(req->cmd_flags & REQ_QUIET)) { 971 - scmd_printk(KERN_INFO, cmd, 972 - "SCSI error: return code = 0x%08x\n", 973 - result); 971 + scsi_print_result(cmd); 974 972 if (driver_byte(result) & DRIVER_SENSE) 975 973 scsi_print_sense("", cmd); 976 974 }
-2
drivers/scsi/scsi_scan.c
··· 181 181 return 0; 182 182 } 183 183 184 - #ifdef MODULE 185 184 /* Only exported for the benefit of scsi_wait_scan */ 186 185 EXPORT_SYMBOL_GPL(scsi_complete_async_scans); 187 - #endif 188 186 189 187 /** 190 188 * scsi_unlock_floptical - unlock device via a special MODE SENSE command
+51 -5
drivers/scsi/scsi_sysfs.c
··· 276 276 return (sdp->inq_periph_qual == SCSI_INQ_PQ_CON)? 1: 0; 277 277 } 278 278 279 + static int scsi_bus_uevent(struct device *dev, char **envp, int num_envp, 280 + char *buffer, int buffer_size) 281 + { 282 + struct scsi_device *sdev = to_scsi_device(dev); 283 + int i = 0; 284 + int length = 0; 285 + 286 + add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length, 287 + "MODALIAS=" SCSI_DEVICE_MODALIAS_FMT, sdev->type); 288 + envp[i] = NULL; 289 + return 0; 290 + } 291 + 279 292 static int scsi_bus_suspend(struct device * dev, pm_message_t state) 280 293 { 294 + struct device_driver *drv = dev->driver; 281 295 struct scsi_device *sdev = to_scsi_device(dev); 282 296 struct scsi_host_template *sht = sdev->host->hostt; 283 297 int err; ··· 300 286 if (err) 301 287 return err; 302 288 303 - if (sht->suspend) 304 - err = sht->suspend(sdev, state); 289 + /* call HLD suspend first */ 290 + if (drv && drv->suspend) { 291 + err = drv->suspend(dev, state); 292 + if (err) 293 + return err; 294 + } 305 295 306 - return err; 296 + /* then, call host suspend */ 297 + if (sht->suspend) { 298 + err = sht->suspend(sdev, state); 299 + if (err) { 300 + if (drv && drv->resume) 301 + drv->resume(dev); 302 + return err; 303 + } 304 + } 305 + 306 + return 0; 307 307 } 308 308 309 309 static int scsi_bus_resume(struct device * dev) 310 310 { 311 + struct device_driver *drv = dev->driver; 311 312 struct scsi_device *sdev = to_scsi_device(dev); 312 313 struct scsi_host_template *sht = sdev->host->hostt; 313 - int err = 0; 314 + int err = 0, err2 = 0; 314 315 316 + /* call host resume first */ 315 317 if (sht->resume) 316 318 err = sht->resume(sdev); 317 319 320 + /* then, call HLD resume */ 321 + if (drv && drv->resume) 322 + err2 = drv->resume(dev); 323 + 318 324 scsi_device_resume(sdev); 319 - return err; 325 + 326 + /* favor LLD failure */ 327 + return err ? err : err2;; 320 328 } 321 329 322 330 struct bus_type scsi_bus_type = { 323 331 .name = "scsi", 324 332 .match = scsi_bus_match, 333 + .uevent = scsi_bus_uevent, 325 334 .suspend = scsi_bus_suspend, 326 335 .resume = scsi_bus_resume, 327 336 }; ··· 584 547 show_sdev_iostat(iodone_cnt); 585 548 show_sdev_iostat(ioerr_cnt); 586 549 550 + static ssize_t 551 + sdev_show_modalias(struct device *dev, struct device_attribute *attr, char *buf) 552 + { 553 + struct scsi_device *sdev; 554 + sdev = to_scsi_device(dev); 555 + return snprintf (buf, 20, SCSI_DEVICE_MODALIAS_FMT "\n", sdev->type); 556 + } 557 + static DEVICE_ATTR(modalias, S_IRUGO, sdev_show_modalias, NULL); 587 558 588 559 /* Default template for device attributes. May NOT be modified */ 589 560 static struct device_attribute *scsi_sysfs_sdev_attrs[] = { ··· 611 566 &dev_attr_iorequest_cnt, 612 567 &dev_attr_iodone_cnt, 613 568 &dev_attr_ioerr_cnt, 569 + &dev_attr_modalias, 614 570 NULL 615 571 }; 616 572
+4 -2
drivers/scsi/scsi_tgt_if.c
··· 179 179 switch (ev->hdr.type) { 180 180 case TGT_UEVENT_CMD_RSP: 181 181 err = scsi_tgt_kspace_exec(ev->p.cmd_rsp.host_no, 182 - ev->p.cmd_rsp.tag, 183 182 ev->p.cmd_rsp.result, 184 - ev->p.cmd_rsp.len, 183 + ev->p.cmd_rsp.tag, 185 184 ev->p.cmd_rsp.uaddr, 185 + ev->p.cmd_rsp.len, 186 + ev->p.cmd_rsp.sense_uaddr, 187 + ev->p.cmd_rsp.sense_len, 186 188 ev->p.cmd_rsp.rw); 187 189 break; 188 190 case TGT_UEVENT_TSK_MGMT_RSP:
+69 -192
drivers/scsi/scsi_tgt_lib.c
··· 28 28 #include <scsi/scsi_device.h> 29 29 #include <scsi/scsi_host.h> 30 30 #include <scsi/scsi_tgt.h> 31 - #include <../drivers/md/dm-bio-list.h> 32 31 33 32 #include "scsi_tgt_priv.h" 34 33 ··· 41 42 struct scsi_tgt_cmd { 42 43 /* TODO replace work with James b's code */ 43 44 struct work_struct work; 44 - /* TODO replace the lists with a large bio */ 45 - struct bio_list xfer_done_list; 46 - struct bio_list xfer_list; 45 + /* TODO fix limits of some drivers */ 46 + struct bio *bio; 47 47 48 48 struct list_head hash_list; 49 49 struct request *rq; 50 50 u64 tag; 51 - 52 - void *buffer; 53 - unsigned bufflen; 54 51 }; 55 52 56 53 #define TGT_HASH_ORDER 4 ··· 88 93 if (!tcmd) 89 94 goto put_dev; 90 95 91 - rq = blk_get_request(shost->uspace_req_q, write, gfp_mask); 96 + /* 97 + * The blk helpers are used to the READ/WRITE requests 98 + * transfering data from a initiator point of view. Since 99 + * we are in target mode we want the opposite. 100 + */ 101 + rq = blk_get_request(shost->uspace_req_q, !write, gfp_mask); 92 102 if (!rq) 93 103 goto free_tcmd; 94 104 ··· 111 111 rq->cmd_flags |= REQ_TYPE_BLOCK_PC; 112 112 rq->end_io_data = tcmd; 113 113 114 - bio_list_init(&tcmd->xfer_list); 115 - bio_list_init(&tcmd->xfer_done_list); 116 114 tcmd->rq = rq; 117 115 118 116 return cmd; ··· 155 157 } 156 158 EXPORT_SYMBOL_GPL(scsi_host_put_command); 157 159 158 - static void scsi_unmap_user_pages(struct scsi_tgt_cmd *tcmd) 159 - { 160 - struct bio *bio; 161 - 162 - /* must call bio_endio in case bio was bounced */ 163 - while ((bio = bio_list_pop(&tcmd->xfer_done_list))) { 164 - bio_endio(bio, bio->bi_size, 0); 165 - bio_unmap_user(bio); 166 - } 167 - 168 - while ((bio = bio_list_pop(&tcmd->xfer_list))) { 169 - bio_endio(bio, bio->bi_size, 0); 170 - bio_unmap_user(bio); 171 - } 172 - } 173 - 174 160 static void cmd_hashlist_del(struct scsi_cmnd *cmd) 175 161 { 176 162 struct request_queue *q = cmd->request->q; ··· 167 185 spin_unlock_irqrestore(&qdata->cmd_hash_lock, flags); 168 186 } 169 187 188 + static void scsi_unmap_user_pages(struct scsi_tgt_cmd *tcmd) 189 + { 190 + blk_rq_unmap_user(tcmd->bio); 191 + } 192 + 170 193 static void scsi_tgt_cmd_destroy(struct work_struct *work) 171 194 { 172 195 struct scsi_tgt_cmd *tcmd = ··· 180 193 181 194 dprintk("cmd %p %d %lu\n", cmd, cmd->sc_data_direction, 182 195 rq_data_dir(cmd->request)); 183 - /* 184 - * We fix rq->cmd_flags here since when we told bio_map_user 185 - * to write vm for WRITE commands, blk_rq_bio_prep set 186 - * rq_data_dir the flags to READ. 187 - */ 188 - if (cmd->sc_data_direction == DMA_TO_DEVICE) 189 - cmd->request->cmd_flags |= REQ_RW; 190 - else 191 - cmd->request->cmd_flags &= ~REQ_RW; 192 - 193 196 scsi_unmap_user_pages(tcmd); 194 197 scsi_host_put_command(scsi_tgt_cmd_to_host(cmd), cmd); 195 198 } ··· 192 215 struct list_head *head; 193 216 194 217 tcmd->tag = tag; 218 + tcmd->bio = NULL; 195 219 INIT_WORK(&tcmd->work, scsi_tgt_cmd_destroy); 196 220 spin_lock_irqsave(&qdata->cmd_hash_lock, flags); 197 221 head = &qdata->cmd_hash[cmd_hashfn(tag)]; ··· 327 349 dprintk("cmd %p %lu\n", cmd, rq_data_dir(cmd->request)); 328 350 329 351 scsi_tgt_uspace_send_status(cmd, tcmd->tag); 352 + 353 + if (cmd->request_buffer) 354 + scsi_free_sgtable(cmd->request_buffer, cmd->sglist_len); 355 + 330 356 queue_work(scsi_tgtd, &tcmd->work); 331 357 } 332 358 333 - static int __scsi_tgt_transfer_response(struct scsi_cmnd *cmd) 359 + static int scsi_tgt_transfer_response(struct scsi_cmnd *cmd) 334 360 { 335 361 struct Scsi_Host *shost = scsi_tgt_cmd_to_host(cmd); 336 362 int err; ··· 347 365 case SCSI_MLQUEUE_DEVICE_BUSY: 348 366 return -EAGAIN; 349 367 } 350 - 351 368 return 0; 352 - } 353 - 354 - static void scsi_tgt_transfer_response(struct scsi_cmnd *cmd) 355 - { 356 - struct scsi_tgt_cmd *tcmd = cmd->request->end_io_data; 357 - int err; 358 - 359 - err = __scsi_tgt_transfer_response(cmd); 360 - if (!err) 361 - return; 362 - 363 - cmd->result = DID_BUS_BUSY << 16; 364 - err = scsi_tgt_uspace_send_status(cmd, tcmd->tag); 365 - if (err <= 0) 366 - /* the eh will have to pick this up */ 367 - printk(KERN_ERR "Could not send cmd %p status\n", cmd); 368 369 } 369 370 370 371 static int scsi_tgt_init_cmd(struct scsi_cmnd *cmd, gfp_t gfp_mask) 371 372 { 372 373 struct request *rq = cmd->request; 373 - struct scsi_tgt_cmd *tcmd = rq->end_io_data; 374 374 int count; 375 375 376 376 cmd->use_sg = rq->nr_phys_segments; ··· 362 398 363 399 cmd->request_bufflen = rq->data_len; 364 400 365 - dprintk("cmd %p addr %p cnt %d %lu\n", cmd, tcmd->buffer, cmd->use_sg, 366 - rq_data_dir(rq)); 401 + dprintk("cmd %p cnt %d %lu\n", cmd, cmd->use_sg, rq_data_dir(rq)); 367 402 count = blk_rq_map_sg(rq->q, rq, cmd->request_buffer); 368 403 if (likely(count <= cmd->use_sg)) { 369 404 cmd->use_sg = count; 370 405 return 0; 371 406 } 372 407 373 - eprintk("cmd %p addr %p cnt %d\n", cmd, tcmd->buffer, cmd->use_sg); 408 + eprintk("cmd %p cnt %d\n", cmd, cmd->use_sg); 374 409 scsi_free_sgtable(cmd->request_buffer, cmd->sglist_len); 375 410 return -EINVAL; 376 411 } 377 412 378 413 /* TODO: test this crap and replace bio_map_user with new interface maybe */ 379 414 static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd, 380 - int rw) 415 + unsigned long uaddr, unsigned int len, int rw) 381 416 { 382 417 struct request_queue *q = cmd->request->q; 383 418 struct request *rq = cmd->request; 384 - void *uaddr = tcmd->buffer; 385 - unsigned int len = tcmd->bufflen; 386 - struct bio *bio; 387 419 int err; 388 420 389 - while (len > 0) { 390 - dprintk("%lx %u\n", (unsigned long) uaddr, len); 391 - bio = bio_map_user(q, NULL, (unsigned long) uaddr, len, rw); 392 - if (IS_ERR(bio)) { 393 - err = PTR_ERR(bio); 394 - dprintk("fail to map %lx %u %d %x\n", 395 - (unsigned long) uaddr, len, err, cmd->cmnd[0]); 396 - goto unmap_bios; 397 - } 398 - 399 - uaddr += bio->bi_size; 400 - len -= bio->bi_size; 401 - 421 + dprintk("%lx %u\n", uaddr, len); 422 + err = blk_rq_map_user(q, rq, (void *)uaddr, len); 423 + if (err) { 402 424 /* 403 - * The first bio is added and merged. We could probably 404 - * try to add others using scsi_merge_bio() but for now 405 - * we keep it simple. The first bio should be pretty large 406 - * (either hitting the 1 MB bio pages limit or a queue limit) 407 - * already but for really large IO we may want to try and 408 - * merge these. 425 + * TODO: need to fixup sg_tablesize, max_segment_size, 426 + * max_sectors, etc for modern HW and software drivers 427 + * where this value is bogus. 428 + * 429 + * TODO2: we can alloc a reserve buffer of max size 430 + * we can handle and do the slow copy path for really large 431 + * IO. 409 432 */ 410 - if (!rq->bio) { 411 - blk_rq_bio_prep(q, rq, bio); 412 - rq->data_len = bio->bi_size; 413 - } else 414 - /* put list of bios to transfer in next go around */ 415 - bio_list_add(&tcmd->xfer_list, bio); 433 + eprintk("Could not handle request of size %u.\n", len); 434 + return err; 416 435 } 417 436 418 - cmd->offset = 0; 437 + tcmd->bio = rq->bio; 419 438 err = scsi_tgt_init_cmd(cmd, GFP_KERNEL); 420 439 if (err) 421 - goto unmap_bios; 440 + goto unmap_rq; 422 441 423 442 return 0; 424 443 425 - unmap_bios: 426 - if (rq->bio) { 427 - bio_unmap_user(rq->bio); 428 - while ((bio = bio_list_pop(&tcmd->xfer_list))) 429 - bio_unmap_user(bio); 430 - } 431 - 444 + unmap_rq: 445 + scsi_unmap_user_pages(tcmd); 432 446 return err; 433 - } 434 - 435 - static int scsi_tgt_transfer_data(struct scsi_cmnd *); 436 - 437 - static void scsi_tgt_data_transfer_done(struct scsi_cmnd *cmd) 438 - { 439 - struct scsi_tgt_cmd *tcmd = cmd->request->end_io_data; 440 - struct bio *bio; 441 - int err; 442 - 443 - /* should we free resources here on error ? */ 444 - if (cmd->result) { 445 - send_uspace_err: 446 - err = scsi_tgt_uspace_send_status(cmd, tcmd->tag); 447 - if (err <= 0) 448 - /* the tgt uspace eh will have to pick this up */ 449 - printk(KERN_ERR "Could not send cmd %p status\n", cmd); 450 - return; 451 - } 452 - 453 - dprintk("cmd %p request_bufflen %u bufflen %u\n", 454 - cmd, cmd->request_bufflen, tcmd->bufflen); 455 - 456 - scsi_free_sgtable(cmd->request_buffer, cmd->sglist_len); 457 - bio_list_add(&tcmd->xfer_done_list, cmd->request->bio); 458 - 459 - tcmd->buffer += cmd->request_bufflen; 460 - cmd->offset += cmd->request_bufflen; 461 - 462 - if (!tcmd->xfer_list.head) { 463 - scsi_tgt_transfer_response(cmd); 464 - return; 465 - } 466 - 467 - dprintk("cmd2 %p request_bufflen %u bufflen %u\n", 468 - cmd, cmd->request_bufflen, tcmd->bufflen); 469 - 470 - bio = bio_list_pop(&tcmd->xfer_list); 471 - BUG_ON(!bio); 472 - 473 - blk_rq_bio_prep(cmd->request->q, cmd->request, bio); 474 - cmd->request->data_len = bio->bi_size; 475 - err = scsi_tgt_init_cmd(cmd, GFP_ATOMIC); 476 - if (err) { 477 - cmd->result = DID_ERROR << 16; 478 - goto send_uspace_err; 479 - } 480 - 481 - if (scsi_tgt_transfer_data(cmd)) { 482 - cmd->result = DID_NO_CONNECT << 16; 483 - goto send_uspace_err; 484 - } 485 - } 486 - 487 - static int scsi_tgt_transfer_data(struct scsi_cmnd *cmd) 488 - { 489 - int err; 490 - struct Scsi_Host *host = scsi_tgt_cmd_to_host(cmd); 491 - 492 - err = host->hostt->transfer_data(cmd, scsi_tgt_data_transfer_done); 493 - switch (err) { 494 - case SCSI_MLQUEUE_HOST_BUSY: 495 - case SCSI_MLQUEUE_DEVICE_BUSY: 496 - return -EAGAIN; 497 - default: 498 - return 0; 499 - } 500 447 } 501 448 502 449 static int scsi_tgt_copy_sense(struct scsi_cmnd *cmd, unsigned long uaddr, ··· 459 584 return rq; 460 585 } 461 586 462 - int scsi_tgt_kspace_exec(int host_no, u64 tag, int result, u32 len, 463 - unsigned long uaddr, u8 rw) 587 + int scsi_tgt_kspace_exec(int host_no, int result, u64 tag, 588 + unsigned long uaddr, u32 len, unsigned long sense_uaddr, 589 + u32 sense_len, u8 rw) 464 590 { 465 591 struct Scsi_Host *shost; 466 592 struct scsi_cmnd *cmd; ··· 493 617 } 494 618 cmd = rq->special; 495 619 496 - dprintk("cmd %p result %d len %d bufflen %u %lu %x\n", cmd, 497 - result, len, cmd->request_bufflen, rq_data_dir(rq), cmd->cmnd[0]); 620 + dprintk("cmd %p scb %x result %d len %d bufflen %u %lu %x\n", 621 + cmd, cmd->cmnd[0], result, len, cmd->request_bufflen, 622 + rq_data_dir(rq), cmd->cmnd[0]); 498 623 499 624 if (result == TASK_ABORTED) { 500 625 scsi_tgt_abort_cmd(shost, cmd); ··· 506 629 * in the request_* values 507 630 */ 508 631 tcmd = cmd->request->end_io_data; 509 - tcmd->buffer = (void *)uaddr; 510 - tcmd->bufflen = len; 511 632 cmd->result = result; 512 633 513 - if (!tcmd->bufflen || cmd->request_buffer) { 514 - err = __scsi_tgt_transfer_response(cmd); 515 - goto done; 516 - } 634 + if (cmd->result == SAM_STAT_CHECK_CONDITION) 635 + scsi_tgt_copy_sense(cmd, sense_uaddr, sense_len); 517 636 518 - /* 519 - * TODO: Do we need to handle case where request does not 520 - * align with LLD. 521 - */ 522 - err = scsi_map_user_pages(rq->end_io_data, cmd, rw); 523 - if (err) { 524 - eprintk("%p %d\n", cmd, err); 525 - err = -EAGAIN; 526 - goto done; 527 - } 637 + if (len) { 638 + err = scsi_map_user_pages(rq->end_io_data, cmd, uaddr, len, rw); 639 + if (err) { 640 + /* 641 + * user-space daemon bugs or OOM 642 + * TODO: we can do better for OOM. 643 + */ 644 + struct scsi_tgt_queuedata *qdata; 645 + struct list_head *head; 646 + unsigned long flags; 528 647 529 - /* userspace failure */ 530 - if (cmd->result) { 531 - if (status_byte(cmd->result) == CHECK_CONDITION) 532 - scsi_tgt_copy_sense(cmd, uaddr, len); 533 - err = __scsi_tgt_transfer_response(cmd); 534 - goto done; 535 - } 536 - /* ask the target LLD to transfer the data to the buffer */ 537 - err = scsi_tgt_transfer_data(cmd); 648 + eprintk("cmd %p ret %d uaddr %lx len %d rw %d\n", 649 + cmd, err, uaddr, len, rw); 538 650 651 + qdata = shost->uspace_req_q->queuedata; 652 + head = &qdata->cmd_hash[cmd_hashfn(tcmd->tag)]; 653 + 654 + spin_lock_irqsave(&qdata->cmd_hash_lock, flags); 655 + list_add(&tcmd->hash_list, head); 656 + spin_unlock_irqrestore(&qdata->cmd_hash_lock, flags); 657 + 658 + goto done; 659 + } 660 + } 661 + err = scsi_tgt_transfer_response(cmd); 539 662 done: 540 663 scsi_host_put(shost); 541 664 return err;
+3 -2
drivers/scsi/scsi_tgt_priv.h
··· 18 18 extern int scsi_tgt_uspace_send_cmd(struct scsi_cmnd *cmd, struct scsi_lun *lun, 19 19 u64 tag); 20 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); 21 + extern int scsi_tgt_kspace_exec(int host_no, int result, u64 tag, 22 + unsigned long uaddr, u32 len, unsigned long sense_uaddr, 23 + u32 sense_len, u8 rw); 23 24 extern int scsi_tgt_uspace_send_tsk_mgmt(int host_no, int function, u64 tag, 24 25 struct scsi_lun *scsilun, void *data); 25 26 extern int scsi_tgt_kspace_tsk_mgmt(int host_no, u64 mid, int result);
+2
drivers/scsi/scsi_transport_fc.c
··· 200 200 { FC_PORTSPEED_2GBIT, "2 Gbit" }, 201 201 { FC_PORTSPEED_4GBIT, "4 Gbit" }, 202 202 { FC_PORTSPEED_10GBIT, "10 Gbit" }, 203 + { FC_PORTSPEED_8GBIT, "8 Gbit" }, 204 + { FC_PORTSPEED_16GBIT, "16 Gbit" }, 203 205 { FC_PORTSPEED_NOT_NEGOTIATED, "Not Negotiated" }, 204 206 }; 205 207 fc_bitfield_name_search(port_speed, fc_port_speed_names)
+4 -2
drivers/scsi/scsi_transport_iscsi.c
··· 49 49 struct class_device_attribute *session_attrs[ISCSI_SESSION_ATTRS + 1]; 50 50 }; 51 51 52 - static int iscsi_session_nr; /* sysfs session id for next new session */ 52 + static atomic_t iscsi_session_nr; /* sysfs session id for next new session */ 53 53 54 54 /* 55 55 * list of registered transports and lock that must ··· 300 300 int err; 301 301 302 302 ihost = shost->shost_data; 303 - session->sid = iscsi_session_nr++; 303 + session->sid = atomic_add_return(1, &iscsi_session_nr); 304 304 session->target_id = target_id; 305 305 306 306 snprintf(session->dev.bus_id, BUS_ID_SIZE, "session%u", ··· 1418 1418 1419 1419 printk(KERN_INFO "Loading iSCSI transport class v%s.\n", 1420 1420 ISCSI_TRANSPORT_VERSION); 1421 + 1422 + atomic_set(&iscsi_session_nr, 0); 1421 1423 1422 1424 err = class_register(&iscsi_transport_class); 1423 1425 if (err)
+225 -180
drivers/scsi/sd.c
··· 58 58 #include <scsi/scsi_host.h> 59 59 #include <scsi/scsi_ioctl.h> 60 60 #include <scsi/scsicam.h> 61 + #include <scsi/sd.h> 61 62 62 63 #include "scsi_logging.h" 63 - 64 - /* 65 - * More than enough for everybody ;) The huge number of majors 66 - * is a leftover from 16bit dev_t days, we don't really need that 67 - * much numberspace. 68 - */ 69 - #define SD_MAJORS 16 70 64 71 65 MODULE_AUTHOR("Eric Youngdale"); 72 66 MODULE_DESCRIPTION("SCSI disk (sd) driver"); ··· 82 88 MODULE_ALIAS_BLOCKDEV_MAJOR(SCSI_DISK13_MAJOR); 83 89 MODULE_ALIAS_BLOCKDEV_MAJOR(SCSI_DISK14_MAJOR); 84 90 MODULE_ALIAS_BLOCKDEV_MAJOR(SCSI_DISK15_MAJOR); 85 - 86 - /* 87 - * This is limited by the naming scheme enforced in sd_probe, 88 - * add another character to it if you really need more disks. 89 - */ 90 - #define SD_MAX_DISKS (((26 * 26) + 26 + 1) * 26) 91 - 92 - /* 93 - * Time out in seconds for disks and Magneto-opticals (which are slower). 94 - */ 95 - #define SD_TIMEOUT (30 * HZ) 96 - #define SD_MOD_TIMEOUT (75 * HZ) 97 - 98 - /* 99 - * Number of allowed retries 100 - */ 101 - #define SD_MAX_RETRIES 5 102 - #define SD_PASSTHROUGH_RETRIES 1 103 - 104 - /* 105 - * Size of the initial data buffer for mode and read capacity data 106 - */ 107 - #define SD_BUF_SIZE 512 108 - 109 - struct scsi_disk { 110 - struct scsi_driver *driver; /* always &sd_template */ 111 - struct scsi_device *device; 112 - struct class_device cdev; 113 - struct gendisk *disk; 114 - unsigned int openers; /* protected by BKL for now, yuck */ 115 - sector_t capacity; /* size in 512-byte sectors */ 116 - u32 index; 117 - u8 media_present; 118 - u8 write_prot; 119 - unsigned WCE : 1; /* state of disk WCE bit */ 120 - unsigned RCD : 1; /* state of disk RCD bit, unused */ 121 - unsigned DPOFUA : 1; /* state of disk DPOFUA bit */ 122 - }; 123 - #define to_scsi_disk(obj) container_of(obj,struct scsi_disk,cdev) 91 + MODULE_ALIAS_SCSI_DEVICE(TYPE_DISK); 92 + MODULE_ALIAS_SCSI_DEVICE(TYPE_MOD); 93 + MODULE_ALIAS_SCSI_DEVICE(TYPE_RBC); 124 94 125 95 static DEFINE_IDR(sd_index_idr); 126 96 static DEFINE_SPINLOCK(sd_index_lock); ··· 93 135 * face of object destruction (i.e. we can't allow a get on an 94 136 * object after last put) */ 95 137 static DEFINE_MUTEX(sd_ref_mutex); 96 - 97 - static int sd_revalidate_disk(struct gendisk *disk); 98 - static void sd_rw_intr(struct scsi_cmnd * SCpnt); 99 - 100 - static int sd_probe(struct device *); 101 - static int sd_remove(struct device *); 102 - static void sd_shutdown(struct device *dev); 103 - static void sd_rescan(struct device *); 104 - static int sd_init_command(struct scsi_cmnd *); 105 - static int sd_issue_flush(struct device *, sector_t *); 106 - static void sd_prepare_flush(request_queue_t *, struct request *); 107 - static void sd_read_capacity(struct scsi_disk *sdkp, char *diskname, 108 - unsigned char *buffer); 109 - static void scsi_disk_release(struct class_device *cdev); 110 138 111 139 static const char *sd_cache_types[] = { 112 140 "write through", "none", "write back", ··· 143 199 if (scsi_mode_select(sdp, 1, sp, 8, buffer_data, len, SD_TIMEOUT, 144 200 SD_MAX_RETRIES, &data, &sshdr)) { 145 201 if (scsi_sense_valid(&sshdr)) 146 - scsi_print_sense_hdr(sdkp->disk->disk_name, &sshdr); 202 + sd_print_sense_hdr(sdkp, &sshdr); 147 203 return -EINVAL; 148 204 } 149 205 sd_revalidate_disk(sdkp->disk); 206 + return count; 207 + } 208 + 209 + static ssize_t sd_store_manage_start_stop(struct class_device *cdev, 210 + const char *buf, size_t count) 211 + { 212 + struct scsi_disk *sdkp = to_scsi_disk(cdev); 213 + struct scsi_device *sdp = sdkp->device; 214 + 215 + if (!capable(CAP_SYS_ADMIN)) 216 + return -EACCES; 217 + 218 + sdp->manage_start_stop = simple_strtoul(buf, NULL, 10); 219 + 150 220 return count; 151 221 } 152 222 ··· 196 238 return snprintf(buf, 20, "%u\n", sdkp->DPOFUA); 197 239 } 198 240 241 + static ssize_t sd_show_manage_start_stop(struct class_device *cdev, char *buf) 242 + { 243 + struct scsi_disk *sdkp = to_scsi_disk(cdev); 244 + struct scsi_device *sdp = sdkp->device; 245 + 246 + return snprintf(buf, 20, "%u\n", sdp->manage_start_stop); 247 + } 248 + 199 249 static ssize_t sd_show_allow_restart(struct class_device *cdev, char *buf) 200 250 { 201 251 struct scsi_disk *sdkp = to_scsi_disk(cdev); ··· 217 251 __ATTR(FUA, S_IRUGO, sd_show_fua, NULL), 218 252 __ATTR(allow_restart, S_IRUGO|S_IWUSR, sd_show_allow_restart, 219 253 sd_store_allow_restart), 254 + __ATTR(manage_start_stop, S_IRUGO|S_IWUSR, sd_show_manage_start_stop, 255 + sd_store_manage_start_stop), 220 256 __ATTR_NULL, 221 257 }; 222 258 ··· 235 267 .name = "sd", 236 268 .probe = sd_probe, 237 269 .remove = sd_remove, 270 + .suspend = sd_suspend, 271 + .resume = sd_resume, 238 272 .shutdown = sd_shutdown, 239 273 }, 240 274 .rescan = sd_rescan, ··· 341 371 unsigned int this_count = SCpnt->request_bufflen >> 9; 342 372 unsigned int timeout = sdp->timeout; 343 373 344 - SCSI_LOG_HLQUEUE(1, printk("sd_init_command: disk=%s, block=%llu, " 345 - "count=%d\n", disk->disk_name, 346 - (unsigned long long)block, this_count)); 374 + SCSI_LOG_HLQUEUE(1, scmd_printk(KERN_INFO, SCpnt, 375 + "sd_init_command: block=%llu, " 376 + "count=%d\n", 377 + (unsigned long long)block, 378 + this_count)); 347 379 348 380 if (!sdp || !scsi_device_online(sdp) || 349 381 block + rq->nr_sectors > get_capacity(disk)) { 350 - SCSI_LOG_HLQUEUE(2, printk("Finishing %ld sectors\n", 351 - rq->nr_sectors)); 352 - SCSI_LOG_HLQUEUE(2, printk("Retry with 0x%p\n", SCpnt)); 382 + SCSI_LOG_HLQUEUE(2, scmd_printk(KERN_INFO, SCpnt, 383 + "Finishing %ld sectors\n", 384 + rq->nr_sectors)); 385 + SCSI_LOG_HLQUEUE(2, scmd_printk(KERN_INFO, SCpnt, 386 + "Retry with 0x%p\n", SCpnt)); 353 387 return 0; 354 388 } 355 389 ··· 365 391 /* printk("SCSI disk has been changed. Prohibiting further I/O.\n"); */ 366 392 return 0; 367 393 } 368 - SCSI_LOG_HLQUEUE(2, printk("%s : block=%llu\n", 369 - disk->disk_name, (unsigned long long)block)); 394 + SCSI_LOG_HLQUEUE(2, scmd_printk(KERN_INFO, SCpnt, "block=%llu\n", 395 + (unsigned long long)block)); 370 396 371 397 /* 372 398 * If we have a 1K hardware sectorsize, prevent access to single ··· 381 407 */ 382 408 if (sdp->sector_size == 1024) { 383 409 if ((block & 1) || (rq->nr_sectors & 1)) { 384 - printk(KERN_ERR "sd: Bad block number requested"); 410 + scmd_printk(KERN_ERR, SCpnt, 411 + "Bad block number requested\n"); 385 412 return 0; 386 413 } else { 387 414 block = block >> 1; ··· 391 416 } 392 417 if (sdp->sector_size == 2048) { 393 418 if ((block & 3) || (rq->nr_sectors & 3)) { 394 - printk(KERN_ERR "sd: Bad block number requested"); 419 + scmd_printk(KERN_ERR, SCpnt, 420 + "Bad block number requested\n"); 395 421 return 0; 396 422 } else { 397 423 block = block >> 2; ··· 401 425 } 402 426 if (sdp->sector_size == 4096) { 403 427 if ((block & 7) || (rq->nr_sectors & 7)) { 404 - printk(KERN_ERR "sd: Bad block number requested"); 428 + scmd_printk(KERN_ERR, SCpnt, 429 + "Bad block number requested\n"); 405 430 return 0; 406 431 } else { 407 432 block = block >> 3; ··· 419 442 SCpnt->cmnd[0] = READ_6; 420 443 SCpnt->sc_data_direction = DMA_FROM_DEVICE; 421 444 } else { 422 - printk(KERN_ERR "sd: Unknown command %x\n", rq->cmd_flags); 445 + scmd_printk(KERN_ERR, SCpnt, "Unknown command %x\n", rq->cmd_flags); 423 446 return 0; 424 447 } 425 448 426 - SCSI_LOG_HLQUEUE(2, printk("%s : %s %d/%ld 512 byte blocks.\n", 427 - disk->disk_name, (rq_data_dir(rq) == WRITE) ? 428 - "writing" : "reading", this_count, rq->nr_sectors)); 449 + SCSI_LOG_HLQUEUE(2, scmd_printk(KERN_INFO, SCpnt, 450 + "%s %d/%ld 512 byte blocks.\n", 451 + (rq_data_dir(rq) == WRITE) ? 452 + "writing" : "reading", this_count, 453 + rq->nr_sectors)); 429 454 430 455 SCpnt->cmnd[1] = 0; 431 456 ··· 469 490 * during operation and thus turned off 470 491 * use_10_for_rw. 471 492 */ 472 - printk(KERN_ERR "sd: FUA write on READ/WRITE(6) drive\n"); 493 + scmd_printk(KERN_ERR, SCpnt, 494 + "FUA write on READ/WRITE(6) drive\n"); 473 495 return 0; 474 496 } 475 497 ··· 529 549 return -ENXIO; 530 550 531 551 532 - SCSI_LOG_HLQUEUE(3, printk("sd_open: disk=%s\n", disk->disk_name)); 552 + SCSI_LOG_HLQUEUE(3, sd_printk(KERN_INFO, sdkp, "sd_open\n")); 533 553 534 554 sdev = sdkp->device; 535 555 ··· 599 619 struct scsi_disk *sdkp = scsi_disk(disk); 600 620 struct scsi_device *sdev = sdkp->device; 601 621 602 - SCSI_LOG_HLQUEUE(3, printk("sd_release: disk=%s\n", disk->disk_name)); 622 + SCSI_LOG_HLQUEUE(3, sd_printk(KERN_INFO, sdkp, "sd_release\n")); 603 623 604 624 if (!--sdkp->openers && sdev->removable) { 605 625 if (scsi_block_when_processing_errors(sdev)) ··· 712 732 struct scsi_device *sdp = sdkp->device; 713 733 int retval; 714 734 715 - SCSI_LOG_HLQUEUE(3, printk("sd_media_changed: disk=%s\n", 716 - disk->disk_name)); 735 + SCSI_LOG_HLQUEUE(3, sd_printk(KERN_INFO, sdkp, "sd_media_changed\n")); 717 736 718 737 if (!sdp->removable) 719 738 return 0; ··· 765 786 return 1; 766 787 } 767 788 768 - static int sd_sync_cache(struct scsi_device *sdp) 789 + static int sd_sync_cache(struct scsi_disk *sdkp) 769 790 { 770 791 int retries, res; 792 + struct scsi_device *sdp = sdkp->device; 771 793 struct scsi_sense_hdr sshdr; 772 794 773 795 if (!scsi_device_online(sdp)) ··· 789 809 break; 790 810 } 791 811 792 - if (res) { printk(KERN_WARNING "FAILED\n status = %x, message = %02x, " 793 - "host = %d, driver = %02x\n ", 794 - status_byte(res), msg_byte(res), 795 - host_byte(res), driver_byte(res)); 796 - if (driver_byte(res) & DRIVER_SENSE) 797 - scsi_print_sense_hdr("sd", &sshdr); 812 + if (res) { 813 + sd_print_result(sdkp, res); 814 + if (driver_byte(res) & DRIVER_SENSE) 815 + sd_print_sense_hdr(sdkp, &sshdr); 798 816 } 799 817 800 - return res; 818 + if (res) 819 + return -EIO; 820 + return 0; 801 821 } 802 822 803 823 static int sd_issue_flush(struct device *dev, sector_t *error_sector) 804 824 { 805 825 int ret = 0; 806 - struct scsi_device *sdp = to_scsi_device(dev); 807 826 struct scsi_disk *sdkp = scsi_disk_get_from_dev(dev); 808 827 809 828 if (!sdkp) 810 829 return -ENODEV; 811 830 812 831 if (sdkp->WCE) 813 - ret = sd_sync_cache(sdp); 832 + ret = sd_sync_cache(sdkp); 814 833 scsi_disk_put(sdkp); 815 834 return ret; 816 835 } ··· 907 928 sense_deferred = scsi_sense_is_deferred(&sshdr); 908 929 } 909 930 #ifdef CONFIG_SCSI_LOGGING 910 - SCSI_LOG_HLCOMPLETE(1, printk("sd_rw_intr: %s: res=0x%x\n", 911 - SCpnt->request->rq_disk->disk_name, result)); 931 + SCSI_LOG_HLCOMPLETE(1, scsi_print_result(SCpnt)); 912 932 if (sense_valid) { 913 - SCSI_LOG_HLCOMPLETE(1, printk("sd_rw_intr: sb[respc,sk,asc," 914 - "ascq]=%x,%x,%x,%x\n", sshdr.response_code, 915 - sshdr.sense_key, sshdr.asc, sshdr.ascq)); 933 + SCSI_LOG_HLCOMPLETE(1, scmd_printk(KERN_INFO, SCpnt, 934 + "sd_rw_intr: sb[respc,sk,asc," 935 + "ascq]=%x,%x,%x,%x\n", 936 + sshdr.response_code, 937 + sshdr.sense_key, sshdr.asc, 938 + sshdr.ascq)); 916 939 } 917 940 #endif 918 941 if (driver_byte(result) != DRIVER_SENSE && ··· 1006 1025 * spinup disk - called only in sd_revalidate_disk() 1007 1026 */ 1008 1027 static void 1009 - sd_spinup_disk(struct scsi_disk *sdkp, char *diskname) 1028 + sd_spinup_disk(struct scsi_disk *sdkp) 1010 1029 { 1011 1030 unsigned char cmd[10]; 1012 1031 unsigned long spintime_expire = 0; ··· 1050 1069 if ((driver_byte(the_result) & DRIVER_SENSE) == 0) { 1051 1070 /* no sense, TUR either succeeded or failed 1052 1071 * with a status error */ 1053 - if(!spintime && !scsi_status_is_good(the_result)) 1054 - printk(KERN_NOTICE "%s: Unit Not Ready, " 1055 - "error = 0x%x\n", diskname, the_result); 1072 + if(!spintime && !scsi_status_is_good(the_result)) { 1073 + sd_printk(KERN_NOTICE, sdkp, "Unit Not Ready\n"); 1074 + sd_print_result(sdkp, the_result); 1075 + } 1056 1076 break; 1057 1077 } 1058 1078 ··· 1078 1096 */ 1079 1097 } else if (sense_valid && sshdr.sense_key == NOT_READY) { 1080 1098 if (!spintime) { 1081 - printk(KERN_NOTICE "%s: Spinning up disk...", 1082 - diskname); 1099 + sd_printk(KERN_NOTICE, sdkp, "Spinning up disk..."); 1083 1100 cmd[0] = START_STOP; 1084 1101 cmd[1] = 1; /* Return immediately */ 1085 1102 memset((void *) &cmd[2], 0, 8); ··· 1111 1130 /* we don't understand the sense code, so it's 1112 1131 * probably pointless to loop */ 1113 1132 if(!spintime) { 1114 - printk(KERN_NOTICE "%s: Unit Not Ready, " 1115 - "sense:\n", diskname); 1116 - scsi_print_sense_hdr("", &sshdr); 1133 + sd_printk(KERN_NOTICE, sdkp, "Unit Not Ready\n"); 1134 + sd_print_sense_hdr(sdkp, &sshdr); 1117 1135 } 1118 1136 break; 1119 1137 } ··· 1131 1151 * read disk capacity 1132 1152 */ 1133 1153 static void 1134 - sd_read_capacity(struct scsi_disk *sdkp, char *diskname, 1135 - unsigned char *buffer) 1154 + sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer) 1136 1155 { 1137 1156 unsigned char cmd[16]; 1138 1157 int the_result, retries; ··· 1170 1191 } while (the_result && retries); 1171 1192 1172 1193 if (the_result && !longrc) { 1173 - printk(KERN_NOTICE "%s : READ CAPACITY failed.\n" 1174 - "%s : status=%x, message=%02x, host=%d, driver=%02x \n", 1175 - diskname, diskname, 1176 - status_byte(the_result), 1177 - msg_byte(the_result), 1178 - host_byte(the_result), 1179 - driver_byte(the_result)); 1180 - 1194 + sd_printk(KERN_NOTICE, sdkp, "READ CAPACITY failed\n"); 1195 + sd_print_result(sdkp, the_result); 1181 1196 if (driver_byte(the_result) & DRIVER_SENSE) 1182 - scsi_print_sense_hdr("sd", &sshdr); 1197 + sd_print_sense_hdr(sdkp, &sshdr); 1183 1198 else 1184 - printk("%s : sense not available. \n", diskname); 1199 + sd_printk(KERN_NOTICE, sdkp, "Sense not available.\n"); 1185 1200 1186 1201 /* Set dirty bit for removable devices if not ready - 1187 1202 * sometimes drives will not report this properly. */ ··· 1191 1218 return; 1192 1219 } else if (the_result && longrc) { 1193 1220 /* READ CAPACITY(16) has been failed */ 1194 - printk(KERN_NOTICE "%s : READ CAPACITY(16) failed.\n" 1195 - "%s : status=%x, message=%02x, host=%d, driver=%02x \n", 1196 - diskname, diskname, 1197 - status_byte(the_result), 1198 - msg_byte(the_result), 1199 - host_byte(the_result), 1200 - driver_byte(the_result)); 1201 - printk(KERN_NOTICE "%s : use 0xffffffff as device size\n", 1202 - diskname); 1203 - 1221 + sd_printk(KERN_NOTICE, sdkp, "READ CAPACITY(16) failed\n"); 1222 + sd_print_result(sdkp, the_result); 1223 + sd_printk(KERN_NOTICE, sdkp, "Use 0xffffffff as device size\n"); 1224 + 1204 1225 sdkp->capacity = 1 + (sector_t) 0xffffffff; 1205 1226 goto got_data; 1206 1227 } ··· 1205 1238 if (buffer[0] == 0xff && buffer[1] == 0xff && 1206 1239 buffer[2] == 0xff && buffer[3] == 0xff) { 1207 1240 if(sizeof(sdkp->capacity) > 4) { 1208 - printk(KERN_NOTICE "%s : very big device. try to use" 1209 - " READ CAPACITY(16).\n", diskname); 1241 + sd_printk(KERN_NOTICE, sdkp, "Very big device. " 1242 + "Trying to use READ CAPACITY(16).\n"); 1210 1243 longrc = 1; 1211 1244 goto repeat; 1212 1245 } 1213 - printk(KERN_ERR "%s: too big for this kernel. Use a " 1214 - "kernel compiled with support for large block " 1215 - "devices.\n", diskname); 1246 + sd_printk(KERN_ERR, sdkp, "Too big for this kernel. Use " 1247 + "a kernel compiled with support for large " 1248 + "block devices.\n"); 1216 1249 sdkp->capacity = 0; 1217 1250 goto got_data; 1218 1251 } ··· 1251 1284 got_data: 1252 1285 if (sector_size == 0) { 1253 1286 sector_size = 512; 1254 - printk(KERN_NOTICE "%s : sector size 0 reported, " 1255 - "assuming 512.\n", diskname); 1287 + sd_printk(KERN_NOTICE, sdkp, "Sector size 0 reported, " 1288 + "assuming 512.\n"); 1256 1289 } 1257 1290 1258 1291 if (sector_size != 512 && ··· 1260 1293 sector_size != 2048 && 1261 1294 sector_size != 4096 && 1262 1295 sector_size != 256) { 1263 - printk(KERN_NOTICE "%s : unsupported sector size " 1264 - "%d.\n", diskname, sector_size); 1296 + sd_printk(KERN_NOTICE, sdkp, "Unsupported sector size %d.\n", 1297 + sector_size); 1265 1298 /* 1266 1299 * The user might want to re-format the drive with 1267 1300 * a supported sectorsize. Once this happens, it ··· 1294 1327 mb -= sz - 974; 1295 1328 sector_div(mb, 1950); 1296 1329 1297 - printk(KERN_NOTICE "SCSI device %s: " 1298 - "%llu %d-byte hdwr sectors (%llu MB)\n", 1299 - diskname, (unsigned long long)sdkp->capacity, 1300 - hard_sector, (unsigned long long)mb); 1330 + sd_printk(KERN_NOTICE, sdkp, 1331 + "%llu %d-byte hardware sectors (%llu MB)\n", 1332 + (unsigned long long)sdkp->capacity, 1333 + hard_sector, (unsigned long long)mb); 1301 1334 } 1302 1335 1303 1336 /* Rescale capacity to 512-byte units */ ··· 1329 1362 * called with buffer of length SD_BUF_SIZE 1330 1363 */ 1331 1364 static void 1332 - sd_read_write_protect_flag(struct scsi_disk *sdkp, char *diskname, 1333 - unsigned char *buffer) 1365 + sd_read_write_protect_flag(struct scsi_disk *sdkp, unsigned char *buffer) 1334 1366 { 1335 1367 int res; 1336 1368 struct scsi_device *sdp = sdkp->device; ··· 1337 1371 1338 1372 set_disk_ro(sdkp->disk, 0); 1339 1373 if (sdp->skip_ms_page_3f) { 1340 - printk(KERN_NOTICE "%s: assuming Write Enabled\n", diskname); 1374 + sd_printk(KERN_NOTICE, sdkp, "Assuming Write Enabled\n"); 1341 1375 return; 1342 1376 } 1343 1377 ··· 1369 1403 } 1370 1404 1371 1405 if (!scsi_status_is_good(res)) { 1372 - printk(KERN_WARNING 1373 - "%s: test WP failed, assume Write Enabled\n", diskname); 1406 + sd_printk(KERN_WARNING, sdkp, 1407 + "Test WP failed, assume Write Enabled\n"); 1374 1408 } else { 1375 1409 sdkp->write_prot = ((data.device_specific & 0x80) != 0); 1376 1410 set_disk_ro(sdkp->disk, sdkp->write_prot); 1377 - printk(KERN_NOTICE "%s: Write Protect is %s\n", diskname, 1378 - sdkp->write_prot ? "on" : "off"); 1379 - printk(KERN_DEBUG "%s: Mode Sense: %02x %02x %02x %02x\n", 1380 - diskname, buffer[0], buffer[1], buffer[2], buffer[3]); 1411 + sd_printk(KERN_NOTICE, sdkp, "Write Protect is %s\n", 1412 + sdkp->write_prot ? "on" : "off"); 1413 + sd_printk(KERN_DEBUG, sdkp, 1414 + "Mode Sense: %02x %02x %02x %02x\n", 1415 + buffer[0], buffer[1], buffer[2], buffer[3]); 1381 1416 } 1382 1417 } 1383 1418 ··· 1387 1420 * called with buffer of length SD_BUF_SIZE 1388 1421 */ 1389 1422 static void 1390 - sd_read_cache_type(struct scsi_disk *sdkp, char *diskname, 1391 - unsigned char *buffer) 1423 + sd_read_cache_type(struct scsi_disk *sdkp, unsigned char *buffer) 1392 1424 { 1393 1425 int len = 0, res; 1394 1426 struct scsi_device *sdp = sdkp->device; ··· 1416 1450 1417 1451 if (!data.header_length) { 1418 1452 modepage = 6; 1419 - printk(KERN_ERR "%s: missing header in MODE_SENSE response\n", 1420 - diskname); 1453 + sd_printk(KERN_ERR, sdkp, "Missing header in MODE_SENSE response\n"); 1421 1454 } 1422 1455 1423 1456 /* that went OK, now ask for the proper length */ ··· 1443 1478 int offset = data.header_length + data.block_descriptor_length; 1444 1479 1445 1480 if (offset >= SD_BUF_SIZE - 2) { 1446 - printk(KERN_ERR "%s: malformed MODE SENSE response", 1447 - diskname); 1481 + sd_printk(KERN_ERR, sdkp, "Malformed MODE SENSE response\n"); 1448 1482 goto defaults; 1449 1483 } 1450 1484 1451 1485 if ((buffer[offset] & 0x3f) != modepage) { 1452 - printk(KERN_ERR "%s: got wrong page\n", diskname); 1486 + sd_printk(KERN_ERR, sdkp, "Got wrong page\n"); 1453 1487 goto defaults; 1454 1488 } 1455 1489 ··· 1462 1498 1463 1499 sdkp->DPOFUA = (data.device_specific & 0x10) != 0; 1464 1500 if (sdkp->DPOFUA && !sdkp->device->use_10_for_rw) { 1465 - printk(KERN_NOTICE "SCSI device %s: uses " 1466 - "READ/WRITE(6), disabling FUA\n", diskname); 1501 + sd_printk(KERN_NOTICE, sdkp, 1502 + "Uses READ/WRITE(6), disabling FUA\n"); 1467 1503 sdkp->DPOFUA = 0; 1468 1504 } 1469 1505 1470 - printk(KERN_NOTICE "SCSI device %s: " 1471 - "write cache: %s, read cache: %s, %s\n", 1472 - diskname, 1506 + sd_printk(KERN_NOTICE, sdkp, 1507 + "Write cache: %s, read cache: %s, %s\n", 1473 1508 sdkp->WCE ? "enabled" : "disabled", 1474 1509 sdkp->RCD ? "disabled" : "enabled", 1475 1510 sdkp->DPOFUA ? "supports DPO and FUA" ··· 1481 1518 if (scsi_sense_valid(&sshdr) && 1482 1519 sshdr.sense_key == ILLEGAL_REQUEST && 1483 1520 sshdr.asc == 0x24 && sshdr.ascq == 0x0) 1484 - printk(KERN_NOTICE "%s: cache data unavailable\n", 1485 - diskname); /* Invalid field in CDB */ 1521 + /* Invalid field in CDB */ 1522 + sd_printk(KERN_NOTICE, sdkp, "Cache data unavailable\n"); 1486 1523 else 1487 - printk(KERN_ERR "%s: asking for cache data failed\n", 1488 - diskname); 1524 + sd_printk(KERN_ERR, sdkp, "Asking for cache data failed\n"); 1489 1525 1490 1526 defaults: 1491 - printk(KERN_ERR "%s: assuming drive cache: write through\n", 1492 - diskname); 1527 + sd_printk(KERN_ERR, sdkp, "Assuming drive cache: write through\n"); 1493 1528 sdkp->WCE = 0; 1494 1529 sdkp->RCD = 0; 1495 1530 sdkp->DPOFUA = 0; ··· 1505 1544 unsigned char *buffer; 1506 1545 unsigned ordered; 1507 1546 1508 - SCSI_LOG_HLQUEUE(3, printk("sd_revalidate_disk: disk=%s\n", disk->disk_name)); 1547 + SCSI_LOG_HLQUEUE(3, sd_printk(KERN_INFO, sdkp, 1548 + "sd_revalidate_disk\n")); 1509 1549 1510 1550 /* 1511 1551 * If the device is offline, don't try and read capacity or any ··· 1517 1555 1518 1556 buffer = kmalloc(SD_BUF_SIZE, GFP_KERNEL | __GFP_DMA); 1519 1557 if (!buffer) { 1520 - printk(KERN_WARNING "(sd_revalidate_disk:) Memory allocation " 1521 - "failure.\n"); 1558 + sd_printk(KERN_WARNING, sdkp, "sd_revalidate_disk: Memory " 1559 + "allocation failure.\n"); 1522 1560 goto out; 1523 1561 } 1524 1562 ··· 1530 1568 sdkp->WCE = 0; 1531 1569 sdkp->RCD = 0; 1532 1570 1533 - sd_spinup_disk(sdkp, disk->disk_name); 1571 + sd_spinup_disk(sdkp); 1534 1572 1535 1573 /* 1536 1574 * Without media there is no reason to ask; moreover, some devices 1537 1575 * react badly if we do. 1538 1576 */ 1539 1577 if (sdkp->media_present) { 1540 - sd_read_capacity(sdkp, disk->disk_name, buffer); 1541 - sd_read_write_protect_flag(sdkp, disk->disk_name, buffer); 1542 - sd_read_cache_type(sdkp, disk->disk_name, buffer); 1578 + sd_read_capacity(sdkp, buffer); 1579 + sd_read_write_protect_flag(sdkp, buffer); 1580 + sd_read_cache_type(sdkp, buffer); 1543 1581 } 1544 1582 1545 1583 /* ··· 1671 1709 dev_set_drvdata(dev, sdkp); 1672 1710 add_disk(gd); 1673 1711 1674 - sdev_printk(KERN_NOTICE, sdp, "Attached scsi %sdisk %s\n", 1675 - sdp->removable ? "removable " : "", gd->disk_name); 1712 + sd_printk(KERN_NOTICE, sdkp, "Attached SCSI %sdisk\n", 1713 + sdp->removable ? "removable " : ""); 1676 1714 1677 1715 return 0; 1678 1716 ··· 1736 1774 kfree(sdkp); 1737 1775 } 1738 1776 1777 + static int sd_start_stop_device(struct scsi_disk *sdkp, int start) 1778 + { 1779 + unsigned char cmd[6] = { START_STOP }; /* START_VALID */ 1780 + struct scsi_sense_hdr sshdr; 1781 + struct scsi_device *sdp = sdkp->device; 1782 + int res; 1783 + 1784 + if (start) 1785 + cmd[4] |= 1; /* START */ 1786 + 1787 + if (!scsi_device_online(sdp)) 1788 + return -ENODEV; 1789 + 1790 + res = scsi_execute_req(sdp, cmd, DMA_NONE, NULL, 0, &sshdr, 1791 + SD_TIMEOUT, SD_MAX_RETRIES); 1792 + if (res) { 1793 + sd_printk(KERN_WARNING, sdkp, "START_STOP FAILED\n"); 1794 + sd_print_result(sdkp, res); 1795 + if (driver_byte(res) & DRIVER_SENSE) 1796 + sd_print_sense_hdr(sdkp, &sshdr); 1797 + } 1798 + 1799 + return res; 1800 + } 1801 + 1739 1802 /* 1740 1803 * Send a SYNCHRONIZE CACHE instruction down to the device through 1741 1804 * the normal SCSI command structure. Wait for the command to ··· 1768 1781 */ 1769 1782 static void sd_shutdown(struct device *dev) 1770 1783 { 1771 - struct scsi_device *sdp = to_scsi_device(dev); 1772 1784 struct scsi_disk *sdkp = scsi_disk_get_from_dev(dev); 1773 1785 1774 1786 if (!sdkp) 1775 1787 return; /* this can happen */ 1776 1788 1777 1789 if (sdkp->WCE) { 1778 - printk(KERN_NOTICE "Synchronizing SCSI cache for disk %s: \n", 1779 - sdkp->disk->disk_name); 1780 - sd_sync_cache(sdp); 1790 + sd_printk(KERN_NOTICE, sdkp, "Synchronizing SCSI cache\n"); 1791 + sd_sync_cache(sdkp); 1781 1792 } 1793 + 1794 + if (system_state != SYSTEM_RESTART && sdkp->device->manage_start_stop) { 1795 + sd_printk(KERN_NOTICE, sdkp, "Stopping disk\n"); 1796 + sd_start_stop_device(sdkp, 0); 1797 + } 1798 + 1782 1799 scsi_disk_put(sdkp); 1800 + } 1801 + 1802 + static int sd_suspend(struct device *dev, pm_message_t mesg) 1803 + { 1804 + struct scsi_disk *sdkp = scsi_disk_get_from_dev(dev); 1805 + int ret; 1806 + 1807 + if (!sdkp) 1808 + return 0; /* this can happen */ 1809 + 1810 + if (sdkp->WCE) { 1811 + sd_printk(KERN_NOTICE, sdkp, "Synchronizing SCSI cache\n"); 1812 + ret = sd_sync_cache(sdkp); 1813 + if (ret) 1814 + return ret; 1815 + } 1816 + 1817 + if (mesg.event == PM_EVENT_SUSPEND && 1818 + sdkp->device->manage_start_stop) { 1819 + sd_printk(KERN_NOTICE, sdkp, "Stopping disk\n"); 1820 + ret = sd_start_stop_device(sdkp, 0); 1821 + if (ret) 1822 + return ret; 1823 + } 1824 + 1825 + return 0; 1826 + } 1827 + 1828 + static int sd_resume(struct device *dev) 1829 + { 1830 + struct scsi_disk *sdkp = scsi_disk_get_from_dev(dev); 1831 + 1832 + if (!sdkp->device->manage_start_stop) 1833 + return 0; 1834 + 1835 + sd_printk(KERN_NOTICE, sdkp, "Starting disk\n"); 1836 + 1837 + return sd_start_stop_device(sdkp, 1); 1783 1838 } 1784 1839 1785 1840 /** ··· 1881 1852 1882 1853 module_init(init_sd); 1883 1854 module_exit(exit_sd); 1855 + 1856 + static void sd_print_sense_hdr(struct scsi_disk *sdkp, 1857 + struct scsi_sense_hdr *sshdr) 1858 + { 1859 + sd_printk(KERN_INFO, sdkp, ""); 1860 + scsi_show_sense_hdr(sshdr); 1861 + sd_printk(KERN_INFO, sdkp, ""); 1862 + scsi_show_extd_sense(sshdr->asc, sshdr->ascq); 1863 + } 1864 + 1865 + static void sd_print_result(struct scsi_disk *sdkp, int result) 1866 + { 1867 + sd_printk(KERN_INFO, sdkp, ""); 1868 + scsi_show_result(result); 1869 + } 1870 +
+11 -2
drivers/scsi/sg.c
··· 917 917 return result; 918 918 if (val < 0) 919 919 return -EINVAL; 920 + val = min_t(int, val, 921 + sdp->device->request_queue->max_sectors * 512); 920 922 if (val != sfp->reserve.bufflen) { 921 923 if (sg_res_in_use(sfp) || sfp->mmap_called) 922 924 return -EBUSY; ··· 927 925 } 928 926 return 0; 929 927 case SG_GET_RESERVED_SIZE: 930 - val = (int) sfp->reserve.bufflen; 928 + val = min_t(int, sfp->reserve.bufflen, 929 + sdp->device->request_queue->max_sectors * 512); 931 930 return put_user(val, ip); 932 931 case SG_SET_COMMAND_Q: 933 932 result = get_user(val, ip); ··· 1064 1061 if (sdp->detached) 1065 1062 return -ENODEV; 1066 1063 return scsi_ioctl(sdp->device, cmd_in, p); 1064 + case BLKSECTGET: 1065 + return put_user(sdp->device->request_queue->max_sectors * 512, 1066 + ip); 1067 1067 default: 1068 1068 if (read_only) 1069 1069 return -EPERM; /* don't know so take safe approach */ ··· 2345 2339 { 2346 2340 Sg_fd *sfp; 2347 2341 unsigned long iflags; 2342 + int bufflen; 2348 2343 2349 2344 sfp = kzalloc(sizeof(*sfp), GFP_ATOMIC | __GFP_NOWARN); 2350 2345 if (!sfp) ··· 2376 2369 if (unlikely(sg_big_buff != def_reserved_size)) 2377 2370 sg_big_buff = def_reserved_size; 2378 2371 2379 - sg_build_reserve(sfp, sg_big_buff); 2372 + bufflen = min_t(int, sg_big_buff, 2373 + sdp->device->request_queue->max_sectors * 512); 2374 + sg_build_reserve(sfp, bufflen); 2380 2375 SCSI_LOG_TIMEOUT(3, printk("sg_add_sfp: bufflen=%d, k_use_sg=%d\n", 2381 2376 sfp->reserve.bufflen, sfp->reserve.k_use_sg)); 2382 2377 return sfp;
+2
drivers/scsi/sr.c
··· 62 62 MODULE_DESCRIPTION("SCSI cdrom (sr) driver"); 63 63 MODULE_LICENSE("GPL"); 64 64 MODULE_ALIAS_BLOCKDEV_MAJOR(SCSI_CDROM_MAJOR); 65 + MODULE_ALIAS_SCSI_DEVICE(TYPE_ROM); 66 + MODULE_ALIAS_SCSI_DEVICE(TYPE_WORM); 65 67 66 68 #define SR_DISKS 256 67 69
+1
drivers/scsi/st.c
··· 89 89 MODULE_DESCRIPTION("SCSI tape (st) driver"); 90 90 MODULE_LICENSE("GPL"); 91 91 MODULE_ALIAS_CHARDEV_MAJOR(SCSI_TAPE_MAJOR); 92 + MODULE_ALIAS_SCSI_DEVICE(TYPE_TAPE); 92 93 93 94 /* Set 'perm' (4th argument) to 0 to disable module_param's definition 94 95 * of sysfs parameters (which module_param doesn't yet support).
+11 -1
include/scsi/iscsi_proto.h
··· 588 588 #define VALUE_MAXLEN 255 589 589 #define TARGET_NAME_MAXLEN VALUE_MAXLEN 590 590 591 - #define DEFAULT_MAX_RECV_DATA_SEGMENT_LENGTH 8192 591 + #define ISCSI_DEF_MAX_RECV_SEG_LEN 8192 592 + #define ISCSI_MIN_MAX_RECV_SEG_LEN 512 593 + #define ISCSI_MAX_MAX_RECV_SEG_LEN 16777215 594 + 595 + #define ISCSI_DEF_FIRST_BURST_LEN 65536 596 + #define ISCSI_MIN_FIRST_BURST_LEN 512 597 + #define ISCSI_MAX_FIRST_BURST_LEN 16777215 598 + 599 + #define ISCSI_DEF_MAX_BURST_LEN 262144 600 + #define ISCSI_MIN_MAX_BURST_LEN 512 601 + #define ISCSI_MAX_MAX_BURST_LEN 16777215 592 602 593 603 /************************* RFC 3720 End *****************************/ 594 604
+1
include/scsi/scsi.h
··· 203 203 204 204 /* 205 205 * DEVICE TYPES 206 + * Please keep them in 0x%02x format for $MODALIAS to work 206 207 */ 207 208 208 209 #define TYPE_DISK 0x00
-3
include/scsi/scsi_cmnd.h
··· 73 73 unsigned short use_sg; /* Number of pieces of scatter-gather */ 74 74 unsigned short sglist_len; /* size of malloc'd scatter-gather list */ 75 75 76 - /* offset in cmd we are at (for multi-transfer tgt cmds) */ 77 - unsigned offset; 78 - 79 76 unsigned underflow; /* Return error if less than 80 77 this amount is transferred */ 81 78
+6 -4
include/scsi/scsi_dbg.h
··· 5 5 struct scsi_sense_hdr; 6 6 7 7 extern void scsi_print_command(struct scsi_cmnd *); 8 - extern void scsi_print_sense_hdr(const char *, struct scsi_sense_hdr *); 9 8 extern void __scsi_print_command(unsigned char *); 10 - extern void scsi_print_sense(const char *, struct scsi_cmnd *); 9 + extern void scsi_show_extd_sense(unsigned char, unsigned char); 10 + extern void scsi_show_sense_hdr(struct scsi_sense_hdr *); 11 + extern void scsi_print_sense_hdr(const char *, struct scsi_sense_hdr *); 12 + extern void scsi_print_sense(char *, struct scsi_cmnd *); 11 13 extern void __scsi_print_sense(const char *name, 12 14 const unsigned char *sense_buffer, 13 15 int sense_len); 14 - extern void scsi_print_driverbyte(int); 15 - extern void scsi_print_hostbyte(int); 16 + extern void scsi_show_result(int); 17 + extern void scsi_print_result(struct scsi_cmnd *); 16 18 extern void scsi_print_status(unsigned char); 17 19 extern const char *scsi_sense_key_string(unsigned char); 18 20 extern const char *scsi_extd_sense_format(unsigned char, unsigned char);
+12 -2
include/scsi/scsi_device.h
··· 5 5 #include <linux/list.h> 6 6 #include <linux/spinlock.h> 7 7 #include <linux/workqueue.h> 8 + #include <linux/blkdev.h> 8 9 #include <asm/atomic.h> 9 10 10 11 struct request_queue; ··· 120 119 unsigned use_192_bytes_for_3f:1; /* ask for 192 bytes from page 0x3f */ 121 120 unsigned no_start_on_add:1; /* do not issue start on add */ 122 121 unsigned allow_restart:1; /* issue START_UNIT in error handler */ 122 + unsigned manage_start_stop:1; /* Let HLD (sd) manage start/stop */ 123 123 unsigned no_uld_attach:1; /* disable connecting to upper level drivers */ 124 124 unsigned select_no_atn:1; 125 125 unsigned fix_capacity:1; /* READ_CAPACITY is too high by 1 */ ··· 156 154 #define sdev_printk(prefix, sdev, fmt, a...) \ 157 155 dev_printk(prefix, &(sdev)->sdev_gendev, fmt, ##a) 158 156 159 - #define scmd_printk(prefix, scmd, fmt, a...) \ 160 - dev_printk(prefix, &(scmd)->device->sdev_gendev, fmt, ##a) 157 + #define scmd_printk(prefix, scmd, fmt, a...) \ 158 + (scmd)->request->rq_disk ? \ 159 + sdev_printk(prefix, (scmd)->device, "[%s] " fmt, \ 160 + (scmd)->request->rq_disk->disk_name, ##a) : \ 161 + sdev_printk(prefix, (scmd)->device, fmt, ##a) 161 162 162 163 enum scsi_target_state { 163 164 STARGET_RUNNING = 1, ··· 358 353 return 0; 359 354 return sdev->inquiry[56] & 0x02; 360 355 } 356 + 357 + #define MODULE_ALIAS_SCSI_DEVICE(type) \ 358 + MODULE_ALIAS("scsi:t-" __stringify(type) "*") 359 + #define SCSI_DEVICE_MODALIAS_FMT "scsi:t-0x%02x" 360 + 361 361 #endif /* _SCSI_SCSI_DEVICE_H */
+18 -14
include/scsi/scsi_host.h
··· 129 129 * the LLD. When the driver is finished processing the command 130 130 * the done callback is invoked. 131 131 * 132 + * This is called to inform the LLD to transfer 133 + * cmd->request_bufflen bytes. The cmd->use_sg speciefies the 134 + * number of scatterlist entried in the command and 135 + * cmd->request_buffer contains the scatterlist. 136 + * 132 137 * return values: see queuecommand 133 138 * 134 139 * If the LLD accepts the cmd, it should set the result to an ··· 144 139 /* TODO: rename */ 145 140 int (* transfer_response)(struct scsi_cmnd *, 146 141 void (*done)(struct scsi_cmnd *)); 147 - /* 148 - * This is called to inform the LLD to transfer cmd->request_bufflen 149 - * bytes of the cmd at cmd->offset in the cmd. The cmd->use_sg 150 - * speciefies the number of scatterlist entried in the command 151 - * and cmd->request_buffer contains the scatterlist. 152 - * 153 - * If the command cannot be processed in one transfer_data call 154 - * becuase a scatterlist within the LLD's limits cannot be 155 - * created then transfer_data will be called multiple times. 156 - * It is initially called from process context, and later 157 - * calls are from the interrup context. 158 - */ 159 - int (* transfer_data)(struct scsi_cmnd *, 160 - void (*done)(struct scsi_cmnd *)); 161 142 162 143 /* Used as callback for the completion of task management request. */ 163 144 int (* tsk_mgmt_response)(u64 mid, int result); ··· 324 333 * Status: OBSOLETE 325 334 */ 326 335 int (*proc_info)(struct Scsi_Host *, char *, char **, off_t, int, int); 336 + 337 + /* 338 + * This is an optional routine that allows the transport to become 339 + * involved when a scsi io timer fires. The return value tells the 340 + * timer routine how to finish the io timeout handling: 341 + * EH_HANDLED: I fixed the error, please complete the command 342 + * EH_RESET_TIMER: I need more time, reset the timer and 343 + * begin counting again 344 + * EH_NOT_HANDLED Begin normal error recovery 345 + * 346 + * Status: OPTIONAL 347 + */ 348 + enum scsi_eh_timer_return (* eh_timed_out)(struct scsi_cmnd *); 327 349 328 350 /* 329 351 * suspend support
+5 -3
include/scsi/scsi_tgt_if.h
··· 45 45 /* user-> kernel */ 46 46 struct { 47 47 int host_no; 48 - uint32_t len; 49 48 int result; 50 - aligned_u64 uaddr; 51 - uint8_t rw; 52 49 aligned_u64 tag; 50 + aligned_u64 uaddr; 51 + aligned_u64 sense_uaddr; 52 + uint32_t len; 53 + uint32_t sense_len; 54 + uint8_t rw; 53 55 } cmd_rsp; 54 56 struct { 55 57 int host_no;
+2
include/scsi/scsi_transport_fc.h
··· 108 108 #define FC_PORTSPEED_2GBIT 2 109 109 #define FC_PORTSPEED_4GBIT 4 110 110 #define FC_PORTSPEED_10GBIT 8 111 + #define FC_PORTSPEED_8GBIT 0x10 112 + #define FC_PORTSPEED_16GBIT 0x20 111 113 #define FC_PORTSPEED_NOT_NEGOTIATED (1 << 15) /* Speed not established */ 112 114 113 115 /*
+72
include/scsi/sd.h
··· 1 + #ifndef _SCSI_DISK_H 2 + #define _SCSI_DISK_H 3 + 4 + /* 5 + * More than enough for everybody ;) The huge number of majors 6 + * is a leftover from 16bit dev_t days, we don't really need that 7 + * much numberspace. 8 + */ 9 + #define SD_MAJORS 16 10 + 11 + /* 12 + * This is limited by the naming scheme enforced in sd_probe, 13 + * add another character to it if you really need more disks. 14 + */ 15 + #define SD_MAX_DISKS (((26 * 26) + 26 + 1) * 26) 16 + 17 + /* 18 + * Time out in seconds for disks and Magneto-opticals (which are slower). 19 + */ 20 + #define SD_TIMEOUT (30 * HZ) 21 + #define SD_MOD_TIMEOUT (75 * HZ) 22 + 23 + /* 24 + * Number of allowed retries 25 + */ 26 + #define SD_MAX_RETRIES 5 27 + #define SD_PASSTHROUGH_RETRIES 1 28 + 29 + /* 30 + * Size of the initial data buffer for mode and read capacity data 31 + */ 32 + #define SD_BUF_SIZE 512 33 + 34 + struct scsi_disk { 35 + struct scsi_driver *driver; /* always &sd_template */ 36 + struct scsi_device *device; 37 + struct class_device cdev; 38 + struct gendisk *disk; 39 + unsigned int openers; /* protected by BKL for now, yuck */ 40 + sector_t capacity; /* size in 512-byte sectors */ 41 + u32 index; 42 + u8 media_present; 43 + u8 write_prot; 44 + unsigned WCE : 1; /* state of disk WCE bit */ 45 + unsigned RCD : 1; /* state of disk RCD bit, unused */ 46 + unsigned DPOFUA : 1; /* state of disk DPOFUA bit */ 47 + }; 48 + #define to_scsi_disk(obj) container_of(obj,struct scsi_disk,cdev) 49 + 50 + static int sd_revalidate_disk(struct gendisk *disk); 51 + static void sd_rw_intr(struct scsi_cmnd * SCpnt); 52 + static int sd_probe(struct device *); 53 + static int sd_remove(struct device *); 54 + static void sd_shutdown(struct device *dev); 55 + static int sd_suspend(struct device *dev, pm_message_t state); 56 + static int sd_resume(struct device *dev); 57 + static void sd_rescan(struct device *); 58 + static int sd_init_command(struct scsi_cmnd *); 59 + static int sd_issue_flush(struct device *, sector_t *); 60 + static void sd_prepare_flush(request_queue_t *, struct request *); 61 + static void sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer); 62 + static void scsi_disk_release(struct class_device *cdev); 63 + static void sd_print_sense_hdr(struct scsi_disk *, struct scsi_sense_hdr *); 64 + static void sd_print_result(struct scsi_disk *, int); 65 + 66 + #define sd_printk(prefix, sdsk, fmt, a...) \ 67 + (sdsk)->disk ? \ 68 + sdev_printk(prefix, (sdsk)->device, "[%s] " fmt, \ 69 + (sdsk)->disk->disk_name, ##a) : \ 70 + sdev_printk(prefix, (sdsk)->device, fmt, ##a) 71 + 72 + #endif /* _SCSI_DISK_H */