aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/scsi/aacraid.txt108
-rw-r--r--drivers/message/fusion/Kconfig1
-rw-r--r--drivers/message/fusion/lsi/mpi.h10
-rw-r--r--drivers/message/fusion/lsi/mpi_cnfg.h158
-rw-r--r--drivers/message/fusion/lsi/mpi_history.txt77
-rw-r--r--drivers/message/fusion/lsi/mpi_init.h8
-rw-r--r--drivers/message/fusion/lsi/mpi_ioc.h122
-rw-r--r--drivers/message/fusion/lsi/mpi_log_fc.h89
-rw-r--r--drivers/message/fusion/lsi/mpi_log_sas.h162
-rw-r--r--drivers/message/fusion/lsi/mpi_sas.h30
-rw-r--r--drivers/message/fusion/mptbase.c48
-rw-r--r--drivers/message/fusion/mptbase.h34
-rw-r--r--drivers/message/fusion/mptctl.c12
-rw-r--r--drivers/message/fusion/mptfc.c579
-rw-r--r--drivers/message/fusion/mptlan.c14
-rw-r--r--drivers/message/fusion/mptsas.c404
-rw-r--r--drivers/message/fusion/mptscsih.c34
-rw-r--r--drivers/message/fusion/mptspi.c26
-rw-r--r--drivers/message/i2o/pci.c10
-rw-r--r--drivers/s390/scsi/zfcp_aux.c2
-rw-r--r--drivers/s390/scsi/zfcp_def.h4
-rw-r--r--drivers/s390/scsi/zfcp_erp.c2
-rw-r--r--drivers/s390/scsi/zfcp_fsf.c84
-rw-r--r--drivers/s390/scsi/zfcp_fsf.h13
-rw-r--r--drivers/s390/scsi/zfcp_scsi.c188
-rw-r--r--drivers/s390/scsi/zfcp_sysfs_adapter.c15
-rw-r--r--drivers/s390/scsi/zfcp_sysfs_port.c4
-rw-r--r--drivers/s390/scsi/zfcp_sysfs_unit.c2
-rw-r--r--drivers/scsi/3w-9xxx.c7
-rw-r--r--drivers/scsi/3w-9xxx.h2
-rw-r--r--drivers/scsi/3w-xxxx.c7
-rw-r--r--drivers/scsi/3w-xxxx.h2
-rw-r--r--drivers/scsi/BusLogic.c3
-rw-r--r--drivers/scsi/Makefile2
-rw-r--r--drivers/scsi/aacraid/README74
-rw-r--r--drivers/scsi/aacraid/aacraid.h7
-rw-r--r--drivers/scsi/aacraid/commctrl.c4
-rw-r--r--drivers/scsi/aacraid/linit.c35
-rw-r--r--drivers/scsi/aic7xxx/Kconfig.aic7xxx4
-rw-r--r--drivers/scsi/aic7xxx/aic79xx.h39
-rw-r--r--drivers/scsi/aic7xxx/aic79xx.reg60
-rw-r--r--drivers/scsi/aic7xxx/aic79xx.seq241
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_core.c771
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_inline.h38
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_osm.c62
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_osm.h2
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_pci.c24
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_pci.h5
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_reg.h_shipped646
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_reg_print.c_shipped507
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_seq.h_shipped1250
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_osm.c28
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_osm.h25
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_pci.c24
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_pci.h1
-rw-r--r--drivers/scsi/ch.c33
-rw-r--r--drivers/scsi/dpt_i2o.c45
-rw-r--r--drivers/scsi/hosts.c8
-rw-r--r--drivers/scsi/ips.c3
-rw-r--r--drivers/scsi/iscsi_tcp.c303
-rw-r--r--drivers/scsi/iscsi_tcp.h6
-rw-r--r--drivers/scsi/lpfc/lpfc_scsi.c2
-rw-r--r--drivers/scsi/megaraid.c6
-rw-r--r--drivers/scsi/megaraid.h4
-rw-r--r--drivers/scsi/megaraid/megaraid_sas.c7
-rw-r--r--drivers/scsi/qla2xxx/Kconfig24
-rw-r--r--drivers/scsi/qla2xxx/Makefile2
-rw-r--r--drivers/scsi/qla2xxx/qla_attr.c4
-rw-r--r--drivers/scsi/qla2xxx/qla_dbg.c105
-rw-r--r--drivers/scsi/qla2xxx/qla_dbg.h4
-rw-r--r--drivers/scsi/qla2xxx/qla_gbl.h6
-rw-r--r--drivers/scsi/qla2xxx/qla_gs.c8
-rw-r--r--drivers/scsi/qla2xxx/qla_init.c24
-rw-r--r--drivers/scsi/qla2xxx/qla_isr.c14
-rw-r--r--drivers/scsi/qla2xxx/qla_mbx.c107
-rw-r--r--drivers/scsi/qla2xxx/qla_os.c6
-rw-r--r--drivers/scsi/qla2xxx/qla_sup.c3
-rw-r--r--drivers/scsi/qla2xxx/qla_version.h4
-rw-r--r--drivers/scsi/raid_class.c2
-rw-r--r--drivers/scsi/scsi.c13
-rw-r--r--drivers/scsi/scsi_lib.c16
-rw-r--r--drivers/scsi/scsi_priv.h6
-rw-r--r--drivers/scsi/scsi_proc.c17
-rw-r--r--drivers/scsi/scsi_scan.c32
-rw-r--r--drivers/scsi/scsi_sysfs.c9
-rw-r--r--drivers/scsi/scsi_transport_fc.c26
-rw-r--r--drivers/scsi/scsi_transport_iscsi.c859
-rw-r--r--drivers/scsi/scsi_transport_sas.c58
-rw-r--r--drivers/scsi/scsi_transport_spi.c12
-rw-r--r--drivers/scsi/sd.c63
-rw-r--r--drivers/scsi/sr.c43
-rw-r--r--drivers/scsi/sr_ioctl.c202
-rw-r--r--drivers/scsi/st.c42
-rw-r--r--include/linux/pci_ids.h1
-rw-r--r--include/linux/raid_class.h2
-rw-r--r--include/scsi/iscsi_if.h6
-rw-r--r--include/scsi/scsi.h6
-rw-r--r--include/scsi/scsi_cmnd.h1
-rw-r--r--include/scsi/scsi_host.h3
-rw-r--r--include/scsi/scsi_transport.h7
-rw-r--r--include/scsi/scsi_transport_fc.h4
-rw-r--r--include/scsi/scsi_transport_iscsi.h75
-rw-r--r--include/scsi/scsi_transport_spi.h2
103 files changed, 5109 insertions, 3236 deletions
diff --git a/Documentation/scsi/aacraid.txt b/Documentation/scsi/aacraid.txt
new file mode 100644
index 000000000000..820fd0793502
--- /dev/null
+++ b/Documentation/scsi/aacraid.txt
@@ -0,0 +1,108 @@
1AACRAID Driver for Linux (take two)
2
3Introduction
4-------------------------
5The aacraid driver adds support for Adaptec (http://www.adaptec.com)
6RAID controllers. This is a major rewrite from the original
7Adaptec supplied driver. It has signficantly cleaned up both the code
8and the running binary size (the module is less than half the size of
9the original).
10
11Supported Cards/Chipsets
12-------------------------
13 PCI ID (pci.ids) OEM Product
14 9005:0285:9005:028a Adaptec 2020ZCR (Skyhawk)
15 9005:0285:9005:028e Adaptec 2020SA (Skyhawk)
16 9005:0285:9005:028b Adaptec 2025ZCR (Terminator)
17 9005:0285:9005:028f Adaptec 2025SA (Terminator)
18 9005:0285:9005:0286 Adaptec 2120S (Crusader)
19 9005:0286:9005:028d Adaptec 2130S (Lancer)
20 9005:0285:9005:0285 Adaptec 2200S (Vulcan)
21 9005:0285:9005:0287 Adaptec 2200S (Vulcan-2m)
22 9005:0286:9005:028c Adaptec 2230S (Lancer)
23 9005:0286:9005:028c Adaptec 2230SLP (Lancer)
24 9005:0285:9005:0296 Adaptec 2240S (SabreExpress)
25 9005:0285:9005:0290 Adaptec 2410SA (Jaguar)
26 9005:0285:9005:0293 Adaptec 21610SA (Corsair-16)
27 9005:0285:103c:3227 Adaptec 2610SA (Bearcat)
28 9005:0285:9005:0292 Adaptec 2810SA (Corsair-8)
29 9005:0285:9005:0294 Adaptec Prowler
30 9005:0286:9005:029d Adaptec 2420SA (Intruder)
31 9005:0286:9005:029c Adaptec 2620SA (Intruder)
32 9005:0286:9005:029b Adaptec 2820SA (Intruder)
33 9005:0286:9005:02a7 Adaptec 2830SA (Skyray)
34 9005:0286:9005:02a8 Adaptec 2430SA (Skyray)
35 9005:0285:9005:0288 Adaptec 3230S (Harrier)
36 9005:0285:9005:0289 Adaptec 3240S (Tornado)
37 9005:0285:9005:0298 Adaptec 4000SAS (BlackBird)
38 9005:0285:9005:0297 Adaptec 4005SAS (AvonPark)
39 9005:0285:9005:0299 Adaptec 4800SAS (Marauder-X)
40 9005:0285:9005:029a Adaptec 4805SAS (Marauder-E)
41 9005:0286:9005:02a2 Adaptec 4810SAS (Hurricane)
42 1011:0046:9005:0364 Adaptec 5400S (Mustang)
43 1011:0046:9005:0365 Adaptec 5400S (Mustang)
44 9005:0283:9005:0283 Adaptec Catapult (3210S with arc firmware)
45 9005:0284:9005:0284 Adaptec Tomcat (3410S with arc firmware)
46 9005:0287:9005:0800 Adaptec Themisto (Jupiter)
47 9005:0200:9005:0200 Adaptec Themisto (Jupiter)
48 9005:0286:9005:0800 Adaptec Callisto (Jupiter)
49 1011:0046:9005:1364 Dell PERC 2/QC (Quad Channel, Mustang)
50 1028:0001:1028:0001 Dell PERC 2/Si (Iguana)
51 1028:0003:1028:0003 Dell PERC 3/Si (SlimFast)
52 1028:0002:1028:0002 Dell PERC 3/Di (Opal)
53 1028:0004:1028:0004 Dell PERC 3/DiF (Iguana)
54 1028:0002:1028:00d1 Dell PERC 3/DiV (Viper)
55 1028:0002:1028:00d9 Dell PERC 3/DiL (Lexus)
56 1028:000a:1028:0106 Dell PERC 3/DiJ (Jaguar)
57 1028:000a:1028:011b Dell PERC 3/DiD (Dagger)
58 1028:000a:1028:0121 Dell PERC 3/DiB (Boxster)
59 9005:0285:1028:0287 Dell PERC 320/DC (Vulcan)
60 9005:0285:1028:0291 Dell CERC 2 (DellCorsair)
61 1011:0046:103c:10c2 HP NetRAID-4M (Mustang)
62 9005:0285:17aa:0286 Legend S220 (Crusader)
63 9005:0285:17aa:0287 Legend S230 (Vulcan)
64 9005:0285:9005:0290 IBM ServeRAID 7t (Jaguar)
65 9005:0285:1014:02F2 IBM ServeRAID 8i (AvonPark)
66 9005:0285:1014:0312 IBM ServeRAID 8i (AvonParkLite)
67 9005:0286:1014:9580 IBM ServeRAID 8k/8k-l8 (Aurora)
68 9005:0286:1014:9540 IBM ServeRAID 8k/8k-l4 (AuroraLite)
69 9005:0286:9005:029f ICP ICP9014R0 (Lancer)
70 9005:0286:9005:029e ICP ICP9024R0 (Lancer)
71 9005:0286:9005:02a0 ICP ICP9047MA (Lancer)
72 9005:0286:9005:02a1 ICP ICP9087MA (Lancer)
73 9005:0286:9005:02a4 ICP ICP9085LI (Marauder-X)
74 9005:0286:9005:02a5 ICP ICP5085BR (Marauder-E)
75 9005:0286:9005:02a3 ICP ICP5085AU (Hurricane)
76 9005:0286:9005:02a6 ICP ICP9067MA (Intruder-6)
77 9005:0286:9005:02a9 ICP ICP5087AU (Skyray)
78 9005:0286:9005:02aa ICP ICP5047AU (Skyray)
79
80People
81-------------------------
82Alan Cox <alan@redhat.com>
83Christoph Hellwig <hch@infradead.org> (updates for new-style PCI probing and SCSI host registration,
84 small cleanups/fixes)
85Matt Domsch <matt_domsch@dell.com> (revision ioctl, adapter messages)
86Deanna Bonds (non-DASD support, PAE fibs and 64 bit, added new adaptec controllers
87 added new ioctls, changed scsi interface to use new error handler,
88 increased the number of fibs and outstanding commands to a container)
89
90 (fixed 64bit and 64G memory model, changed confusing naming convention
91 where fibs that go to the hardware are consistently called hw_fibs and
92 not just fibs like the name of the driver tracking structure)
93Mark Salyzyn <Mark_Salyzyn@adaptec.com> Fixed panic issues and added some new product ids for upcoming hbas. Performance tuning, card failover and bug mitigations.
94
95Original Driver
96-------------------------
97Adaptec Unix OEM Product Group
98
99Mailing List
100-------------------------
101linux-scsi@vger.kernel.org (Interested parties troll here)
102Also note this is very different to Brian's original driver
103so don't expect him to support it.
104Adaptec does support this driver. Contact Adaptec tech support or
105aacraid@adaptec.com
106
107Original by Brian Boerner February 2001
108Rewritten by Alan Cox, November 2001
diff --git a/drivers/message/fusion/Kconfig b/drivers/message/fusion/Kconfig
index 1883d22cffeb..e67cf15e9c39 100644
--- a/drivers/message/fusion/Kconfig
+++ b/drivers/message/fusion/Kconfig
@@ -23,6 +23,7 @@ config FUSION_FC
23 tristate "Fusion MPT ScsiHost drivers for FC" 23 tristate "Fusion MPT ScsiHost drivers for FC"
24 depends on PCI && SCSI 24 depends on PCI && SCSI
25 select FUSION 25 select FUSION
26 select SCSI_FC_ATTRS
26 ---help--- 27 ---help---
27 SCSI HOST support for a Fiber Channel host adapters. 28 SCSI HOST support for a Fiber Channel host adapters.
28 29
diff --git a/drivers/message/fusion/lsi/mpi.h b/drivers/message/fusion/lsi/mpi.h
index b61e3d175070..02cdc840a06b 100644
--- a/drivers/message/fusion/lsi/mpi.h
+++ b/drivers/message/fusion/lsi/mpi.h
@@ -6,7 +6,7 @@
6 * Title: MPI Message independent structures and definitions 6 * Title: MPI Message independent structures and definitions
7 * Creation Date: July 27, 2000 7 * Creation Date: July 27, 2000
8 * 8 *
9 * mpi.h Version: 01.05.08 9 * mpi.h Version: 01.05.10
10 * 10 *
11 * Version History 11 * Version History
12 * --------------- 12 * ---------------
@@ -74,6 +74,8 @@
74 * 06-24-05 01.05.08 Added function codes for SCSI IO 32 and 74 * 06-24-05 01.05.08 Added function codes for SCSI IO 32 and
75 * TargetAssistExtended requests. 75 * TargetAssistExtended requests.
76 * Added EEDP IOCStatus codes. 76 * Added EEDP IOCStatus codes.
77 * 08-03-05 01.05.09 Bumped MPI_HEADER_VERSION_UNIT.
78 * 08-30-05 01.05.10 Added 2 new IOCStatus codes for Target.
77 * -------------------------------------------------------------------------- 79 * --------------------------------------------------------------------------
78 */ 80 */
79 81
@@ -104,7 +106,7 @@
104/* Note: The major versions of 0xe0 through 0xff are reserved */ 106/* Note: The major versions of 0xe0 through 0xff are reserved */
105 107
106/* versioning for this MPI header set */ 108/* versioning for this MPI header set */
107#define MPI_HEADER_VERSION_UNIT (0x0A) 109#define MPI_HEADER_VERSION_UNIT (0x0C)
108#define MPI_HEADER_VERSION_DEV (0x00) 110#define MPI_HEADER_VERSION_DEV (0x00)
109#define MPI_HEADER_VERSION_UNIT_MASK (0xFF00) 111#define MPI_HEADER_VERSION_UNIT_MASK (0xFF00)
110#define MPI_HEADER_VERSION_UNIT_SHIFT (8) 112#define MPI_HEADER_VERSION_UNIT_SHIFT (8)
@@ -711,6 +713,8 @@ typedef struct _MSG_DEFAULT_REPLY
711#define MPI_IOCSTATUS_TARGET_DATA_OFFSET_ERROR (0x006D) 713#define MPI_IOCSTATUS_TARGET_DATA_OFFSET_ERROR (0x006D)
712#define MPI_IOCSTATUS_TARGET_TOO_MUCH_WRITE_DATA (0x006E) 714#define MPI_IOCSTATUS_TARGET_TOO_MUCH_WRITE_DATA (0x006E)
713#define MPI_IOCSTATUS_TARGET_IU_TOO_SHORT (0x006F) 715#define MPI_IOCSTATUS_TARGET_IU_TOO_SHORT (0x006F)
716#define MPI_IOCSTATUS_TARGET_ACK_NAK_TIMEOUT (0x0070)
717#define MPI_IOCSTATUS_TARGET_NAK_RECEIVED (0x0071)
714 718
715/****************************************************************************/ 719/****************************************************************************/
716/* Additional FCP target values (obsolete) */ 720/* Additional FCP target values (obsolete) */
@@ -745,7 +749,7 @@ typedef struct _MSG_DEFAULT_REPLY
745#define MPI_IOCSTATUS_LAN_CANCELED (0x0087) 749#define MPI_IOCSTATUS_LAN_CANCELED (0x0087)
746 750
747/****************************************************************************/ 751/****************************************************************************/
748/* Serial Attached SCSI values */ 752/* Serial Attached SCSI values */
749/****************************************************************************/ 753/****************************************************************************/
750 754
751#define MPI_IOCSTATUS_SAS_SMP_REQUEST_FAILED (0x0090) 755#define MPI_IOCSTATUS_SAS_SMP_REQUEST_FAILED (0x0090)
diff --git a/drivers/message/fusion/lsi/mpi_cnfg.h b/drivers/message/fusion/lsi/mpi_cnfg.h
index d8339896f734..b1becec27e1b 100644
--- a/drivers/message/fusion/lsi/mpi_cnfg.h
+++ b/drivers/message/fusion/lsi/mpi_cnfg.h
@@ -6,7 +6,7 @@
6 * Title: MPI Config message, structures, and Pages 6 * Title: MPI Config message, structures, and Pages
7 * Creation Date: July 27, 2000 7 * Creation Date: July 27, 2000
8 * 8 *
9 * mpi_cnfg.h Version: 01.05.09 9 * mpi_cnfg.h Version: 01.05.11
10 * 10 *
11 * Version History 11 * Version History
12 * --------------- 12 * ---------------
@@ -249,6 +249,23 @@
249 * Added OwnerDevHandle and Flags field to SAS PHY Page 0. 249 * Added OwnerDevHandle and Flags field to SAS PHY Page 0.
250 * Added IOC GPIO Flags define to SAS Enclosure Page 0. 250 * Added IOC GPIO Flags define to SAS Enclosure Page 0.
251 * Fixed the value for MPI_SAS_IOUNIT1_CONTROL_DEV_SATA_SUPPORT. 251 * Fixed the value for MPI_SAS_IOUNIT1_CONTROL_DEV_SATA_SUPPORT.
252 * 08-03-05 01.05.10 Removed ISDataScrubRate and ISResyncRate from
253 * Manufacturing Page 4.
254 * Added MPI_IOUNITPAGE1_SATA_WRITE_CACHE_DISABLE bit.
255 * Added NumDevsPerEnclosure field to SAS IO Unit page 2.
256 * Added MPI_SAS_IOUNIT2_FLAGS_HOST_ASSIGNED_PHYS_MAP
257 * define.
258 * Added EnclosureHandle field to SAS Expander page 0.
259 * Removed redundant NumTableEntriesProg field from SAS
260 * Expander Page 1.
261 * 08-30-05 01.05.11 Added DeviceID for FC949E and changed the DeviceID for
262 * SAS1078.
263 * Added more defines for Manufacturing Page 4 Flags field.
264 * Added more defines for IOCSettings and added
265 * ExpanderSpinup field to Bios Page 1.
266 * Added postpone SATA Init bit to SAS IO Unit Page 1
267 * ControlFlags.
268 * Changed LogEntry format for Log Page 0.
252 * -------------------------------------------------------------------------- 269 * --------------------------------------------------------------------------
253 */ 270 */
254 271
@@ -494,7 +511,7 @@ typedef struct _MSG_CONFIG_REPLY
494#define MPI_MANUFACTPAGE_DEVICEID_FC929X (0x0626) 511#define MPI_MANUFACTPAGE_DEVICEID_FC929X (0x0626)
495#define MPI_MANUFACTPAGE_DEVICEID_FC939X (0x0642) 512#define MPI_MANUFACTPAGE_DEVICEID_FC939X (0x0642)
496#define MPI_MANUFACTPAGE_DEVICEID_FC949X (0x0640) 513#define MPI_MANUFACTPAGE_DEVICEID_FC949X (0x0640)
497#define MPI_MANUFACTPAGE_DEVICEID_FC949ES (0x0646) 514#define MPI_MANUFACTPAGE_DEVICEID_FC949E (0x0646)
498/* SCSI */ 515/* SCSI */
499#define MPI_MANUFACTPAGE_DEVID_53C1030 (0x0030) 516#define MPI_MANUFACTPAGE_DEVID_53C1030 (0x0030)
500#define MPI_MANUFACTPAGE_DEVID_53C1030ZC (0x0031) 517#define MPI_MANUFACTPAGE_DEVID_53C1030ZC (0x0031)
@@ -510,7 +527,7 @@ typedef struct _MSG_CONFIG_REPLY
510#define MPI_MANUFACTPAGE_DEVID_SAS1066E (0x005A) 527#define MPI_MANUFACTPAGE_DEVID_SAS1066E (0x005A)
511#define MPI_MANUFACTPAGE_DEVID_SAS1068 (0x0054) 528#define MPI_MANUFACTPAGE_DEVID_SAS1068 (0x0054)
512#define MPI_MANUFACTPAGE_DEVID_SAS1068E (0x0058) 529#define MPI_MANUFACTPAGE_DEVID_SAS1068E (0x0058)
513#define MPI_MANUFACTPAGE_DEVID_SAS1078 (0x0060) 530#define MPI_MANUFACTPAGE_DEVID_SAS1078 (0x0062)
514 531
515 532
516typedef struct _CONFIG_PAGE_MANUFACTURING_0 533typedef struct _CONFIG_PAGE_MANUFACTURING_0
@@ -602,9 +619,7 @@ typedef struct _CONFIG_PAGE_MANUFACTURING_4
602 U32 IMVolumeSettings; /* 50h */ 619 U32 IMVolumeSettings; /* 50h */
603 U32 Reserved3; /* 54h */ 620 U32 Reserved3; /* 54h */
604 U32 Reserved4; /* 58h */ 621 U32 Reserved4; /* 58h */
605 U8 ISDataScrubRate; /* 5Ch */ 622 U32 Reserved5; /* 5Ch */
606 U8 ISResyncRate; /* 5Dh */
607 U16 Reserved5; /* 5Eh */
608 U8 IMEDataScrubRate; /* 60h */ 623 U8 IMEDataScrubRate; /* 60h */
609 U8 IMEResyncRate; /* 61h */ 624 U8 IMEResyncRate; /* 61h */
610 U16 Reserved6; /* 62h */ 625 U16 Reserved6; /* 62h */
@@ -616,9 +631,14 @@ typedef struct _CONFIG_PAGE_MANUFACTURING_4
616} CONFIG_PAGE_MANUFACTURING_4, MPI_POINTER PTR_CONFIG_PAGE_MANUFACTURING_4, 631} CONFIG_PAGE_MANUFACTURING_4, MPI_POINTER PTR_CONFIG_PAGE_MANUFACTURING_4,
617 ManufacturingPage4_t, MPI_POINTER pManufacturingPage4_t; 632 ManufacturingPage4_t, MPI_POINTER pManufacturingPage4_t;
618 633
619#define MPI_MANUFACTURING4_PAGEVERSION (0x02) 634#define MPI_MANUFACTURING4_PAGEVERSION (0x03)
620 635
621/* defines for the Flags field */ 636/* defines for the Flags field */
637#define MPI_MANPAGE4_IME_DISABLE (0x20)
638#define MPI_MANPAGE4_IM_DISABLE (0x10)
639#define MPI_MANPAGE4_IS_DISABLE (0x08)
640#define MPI_MANPAGE4_IR_MODEPAGE8_DISABLE (0x04)
641#define MPI_MANPAGE4_IM_RESYNC_CACHE_ENABLE (0x02)
622#define MPI_MANPAGE4_IR_NO_MIX_SAS_SATA (0x01) 642#define MPI_MANPAGE4_IR_NO_MIX_SAS_SATA (0x01)
623 643
624 644
@@ -669,7 +689,7 @@ typedef struct _CONFIG_PAGE_IO_UNIT_1
669} CONFIG_PAGE_IO_UNIT_1, MPI_POINTER PTR_CONFIG_PAGE_IO_UNIT_1, 689} CONFIG_PAGE_IO_UNIT_1, MPI_POINTER PTR_CONFIG_PAGE_IO_UNIT_1,
670 IOUnitPage1_t, MPI_POINTER pIOUnitPage1_t; 690 IOUnitPage1_t, MPI_POINTER pIOUnitPage1_t;
671 691
672#define MPI_IOUNITPAGE1_PAGEVERSION (0x01) 692#define MPI_IOUNITPAGE1_PAGEVERSION (0x02)
673 693
674/* IO Unit Page 1 Flags defines */ 694/* IO Unit Page 1 Flags defines */
675#define MPI_IOUNITPAGE1_MULTI_FUNCTION (0x00000000) 695#define MPI_IOUNITPAGE1_MULTI_FUNCTION (0x00000000)
@@ -681,7 +701,7 @@ typedef struct _CONFIG_PAGE_IO_UNIT_1
681#define MPI_IOUNITPAGE1_DISABLE_IR (0x00000040) 701#define MPI_IOUNITPAGE1_DISABLE_IR (0x00000040)
682#define MPI_IOUNITPAGE1_FORCE_32 (0x00000080) 702#define MPI_IOUNITPAGE1_FORCE_32 (0x00000080)
683#define MPI_IOUNITPAGE1_NATIVE_COMMAND_Q_DISABLE (0x00000100) 703#define MPI_IOUNITPAGE1_NATIVE_COMMAND_Q_DISABLE (0x00000100)
684 704#define MPI_IOUNITPAGE1_SATA_WRITE_CACHE_DISABLE (0x00000200)
685 705
686typedef struct _MPI_ADAPTER_INFO 706typedef struct _MPI_ADAPTER_INFO
687{ 707{
@@ -968,7 +988,8 @@ typedef struct _CONFIG_PAGE_BIOS_1
968 U32 Reserved1; /* 0Ch */ 988 U32 Reserved1; /* 0Ch */
969 U32 DeviceSettings; /* 10h */ 989 U32 DeviceSettings; /* 10h */
970 U16 NumberOfDevices; /* 14h */ 990 U16 NumberOfDevices; /* 14h */
971 U16 Reserved2; /* 16h */ 991 U8 ExpanderSpinup; /* 16h */
992 U8 Reserved2; /* 17h */
972 U16 IOTimeoutBlockDevicesNonRM; /* 18h */ 993 U16 IOTimeoutBlockDevicesNonRM; /* 18h */
973 U16 IOTimeoutSequential; /* 1Ah */ 994 U16 IOTimeoutSequential; /* 1Ah */
974 U16 IOTimeoutOther; /* 1Ch */ 995 U16 IOTimeoutOther; /* 1Ch */
@@ -976,7 +997,7 @@ typedef struct _CONFIG_PAGE_BIOS_1
976} CONFIG_PAGE_BIOS_1, MPI_POINTER PTR_CONFIG_PAGE_BIOS_1, 997} CONFIG_PAGE_BIOS_1, MPI_POINTER PTR_CONFIG_PAGE_BIOS_1,
977 BIOSPage1_t, MPI_POINTER pBIOSPage1_t; 998 BIOSPage1_t, MPI_POINTER pBIOSPage1_t;
978 999
979#define MPI_BIOSPAGE1_PAGEVERSION (0x02) 1000#define MPI_BIOSPAGE1_PAGEVERSION (0x03)
980 1001
981/* values for the BiosOptions field */ 1002/* values for the BiosOptions field */
982#define MPI_BIOSPAGE1_OPTIONS_SPI_ENABLE (0x00000400) 1003#define MPI_BIOSPAGE1_OPTIONS_SPI_ENABLE (0x00000400)
@@ -985,8 +1006,15 @@ typedef struct _CONFIG_PAGE_BIOS_1
985#define MPI_BIOSPAGE1_OPTIONS_DISABLE_BIOS (0x00000001) 1006#define MPI_BIOSPAGE1_OPTIONS_DISABLE_BIOS (0x00000001)
986 1007
987/* values for the IOCSettings field */ 1008/* values for the IOCSettings field */
1009#define MPI_BIOSPAGE1_IOCSET_MASK_INITIAL_SPINUP_DELAY (0x0F000000)
1010#define MPI_BIOSPAGE1_IOCSET_SHIFT_INITIAL_SPINUP_DELAY (24)
1011
988#define MPI_BIOSPAGE1_IOCSET_MASK_PORT_ENABLE_DELAY (0x00F00000) 1012#define MPI_BIOSPAGE1_IOCSET_MASK_PORT_ENABLE_DELAY (0x00F00000)
989#define MPI_BIOSPAGE1_IOCSET_SHIFT_PORT_ENABLE_DELAY (20) 1013#define MPI_BIOSPAGE1_IOCSET_SHIFT_PORT_ENABLE_DELAY (20)
1014
1015#define MPI_BIOSPAGE1_IOCSET_AUTO_PORT_ENABLE (0x00080000)
1016#define MPI_BIOSPAGE1_IOCSET_DIRECT_ATTACH_SPINUP_MODE (0x00040000)
1017
990#define MPI_BIOSPAGE1_IOCSET_MASK_BOOT_PREFERENCE (0x00030000) 1018#define MPI_BIOSPAGE1_IOCSET_MASK_BOOT_PREFERENCE (0x00030000)
991#define MPI_BIOSPAGE1_IOCSET_ENCLOSURE_SLOT_BOOT (0x00000000) 1019#define MPI_BIOSPAGE1_IOCSET_ENCLOSURE_SLOT_BOOT (0x00000000)
992#define MPI_BIOSPAGE1_IOCSET_SAS_ADDRESS_BOOT (0x00010000) 1020#define MPI_BIOSPAGE1_IOCSET_SAS_ADDRESS_BOOT (0x00010000)
@@ -1016,6 +1044,11 @@ typedef struct _CONFIG_PAGE_BIOS_1
1016#define MPI_BIOSPAGE1_DEVSET_DISABLE_NON_RM_LUN (0x00000002) 1044#define MPI_BIOSPAGE1_DEVSET_DISABLE_NON_RM_LUN (0x00000002)
1017#define MPI_BIOSPAGE1_DEVSET_DISABLE_OTHER_LUN (0x00000001) 1045#define MPI_BIOSPAGE1_DEVSET_DISABLE_OTHER_LUN (0x00000001)
1018 1046
1047/* defines for the ExpanderSpinup field */
1048#define MPI_BIOSPAGE1_EXPSPINUP_MASK_MAX_TARGET (0xF0)
1049#define MPI_BIOSPAGE1_EXPSPINUP_SHIFT_MAX_TARGET (4)
1050#define MPI_BIOSPAGE1_EXPSPINUP_MASK_DELAY (0x0F)
1051
1019typedef struct _MPI_BOOT_DEVICE_ADAPTER_ORDER 1052typedef struct _MPI_BOOT_DEVICE_ADAPTER_ORDER
1020{ 1053{
1021 U32 Reserved1; /* 00h */ 1054 U32 Reserved1; /* 00h */
@@ -1233,13 +1266,13 @@ typedef struct _CONFIG_PAGE_SCSI_PORT_0
1233 1266
1234#define MPI_SCSIPORTPAGE0_CAP_SHIFT_MIN_SYNC_PERIOD (8) 1267#define MPI_SCSIPORTPAGE0_CAP_SHIFT_MIN_SYNC_PERIOD (8)
1235#define MPI_SCSIPORTPAGE0_CAP_GET_MIN_SYNC_PERIOD(Cap) \ 1268#define MPI_SCSIPORTPAGE0_CAP_GET_MIN_SYNC_PERIOD(Cap) \
1236 ( ((Cap) & MPI_SCSIPORTPAGE0_CAP_MASK_MIN_SYNC_PERIOD) \ 1269 ( ((Cap) & MPI_SCSIPORTPAGE0_CAP_MIN_SYNC_PERIOD_MASK) \
1237 >> MPI_SCSIPORTPAGE0_CAP_SHIFT_MIN_SYNC_PERIOD \ 1270 >> MPI_SCSIPORTPAGE0_CAP_SHIFT_MIN_SYNC_PERIOD \
1238 ) 1271 )
1239#define MPI_SCSIPORTPAGE0_CAP_MAX_SYNC_OFFSET_MASK (0x00FF0000) 1272#define MPI_SCSIPORTPAGE0_CAP_MAX_SYNC_OFFSET_MASK (0x00FF0000)
1240#define MPI_SCSIPORTPAGE0_CAP_SHIFT_MAX_SYNC_OFFSET (16) 1273#define MPI_SCSIPORTPAGE0_CAP_SHIFT_MAX_SYNC_OFFSET (16)
1241#define MPI_SCSIPORTPAGE0_CAP_GET_MAX_SYNC_OFFSET(Cap) \ 1274#define MPI_SCSIPORTPAGE0_CAP_GET_MAX_SYNC_OFFSET(Cap) \
1242 ( ((Cap) & MPI_SCSIPORTPAGE0_CAP_MASK_MAX_SYNC_OFFSET) \ 1275 ( ((Cap) & MPI_SCSIPORTPAGE0_CAP_MAX_SYNC_OFFSET_MASK) \
1243 >> MPI_SCSIPORTPAGE0_CAP_SHIFT_MAX_SYNC_OFFSET \ 1276 >> MPI_SCSIPORTPAGE0_CAP_SHIFT_MAX_SYNC_OFFSET \
1244 ) 1277 )
1245#define MPI_SCSIPORTPAGE0_CAP_IDP (0x08000000) 1278#define MPI_SCSIPORTPAGE0_CAP_IDP (0x08000000)
@@ -2370,47 +2403,48 @@ typedef struct _CONFIG_PAGE_SAS_IO_UNIT_1
2370} CONFIG_PAGE_SAS_IO_UNIT_1, MPI_POINTER PTR_CONFIG_PAGE_SAS_IO_UNIT_1, 2403} CONFIG_PAGE_SAS_IO_UNIT_1, MPI_POINTER PTR_CONFIG_PAGE_SAS_IO_UNIT_1,
2371 SasIOUnitPage1_t, MPI_POINTER pSasIOUnitPage1_t; 2404 SasIOUnitPage1_t, MPI_POINTER pSasIOUnitPage1_t;
2372 2405
2373#define MPI_SASIOUNITPAGE1_PAGEVERSION (0x04) 2406#define MPI_SASIOUNITPAGE1_PAGEVERSION (0x05)
2374 2407
2375/* values for SAS IO Unit Page 1 ControlFlags */ 2408/* values for SAS IO Unit Page 1 ControlFlags */
2376#define MPI_SAS_IOUNIT1_CONTROL_DEVICE_SELF_TEST (0x8000) 2409#define MPI_SAS_IOUNIT1_CONTROL_DEVICE_SELF_TEST (0x8000)
2377#define MPI_SAS_IOUNIT1_CONTROL_SATA_3_0_MAX (0x4000) 2410#define MPI_SAS_IOUNIT1_CONTROL_SATA_3_0_MAX (0x4000)
2378#define MPI_SAS_IOUNIT1_CONTROL_SATA_1_5_MAX (0x2000) 2411#define MPI_SAS_IOUNIT1_CONTROL_SATA_1_5_MAX (0x2000)
2379#define MPI_SAS_IOUNIT1_CONTROL_SATA_SW_PRESERVE (0x1000) 2412#define MPI_SAS_IOUNIT1_CONTROL_SATA_SW_PRESERVE (0x1000)
2380#define MPI_SAS_IOUNIT1_CONTROL_DISABLE_SAS_HASH (0x0800) 2413#define MPI_SAS_IOUNIT1_CONTROL_DISABLE_SAS_HASH (0x0800)
2381 2414
2382#define MPI_SAS_IOUNIT1_CONTROL_MASK_DEV_SUPPORT (0x0600) 2415#define MPI_SAS_IOUNIT1_CONTROL_MASK_DEV_SUPPORT (0x0600)
2383#define MPI_SAS_IOUNIT1_CONTROL_SHIFT_DEV_SUPPORT (9) 2416#define MPI_SAS_IOUNIT1_CONTROL_SHIFT_DEV_SUPPORT (9)
2384#define MPI_SAS_IOUNIT1_CONTROL_DEV_SUPPORT_BOTH (0x00) 2417#define MPI_SAS_IOUNIT1_CONTROL_DEV_SUPPORT_BOTH (0x00)
2385#define MPI_SAS_IOUNIT1_CONTROL_DEV_SAS_SUPPORT (0x01) 2418#define MPI_SAS_IOUNIT1_CONTROL_DEV_SAS_SUPPORT (0x01)
2386#define MPI_SAS_IOUNIT1_CONTROL_DEV_SATA_SUPPORT (0x02) 2419#define MPI_SAS_IOUNIT1_CONTROL_DEV_SATA_SUPPORT (0x02)
2387 2420
2388#define MPI_SAS_IOUNIT1_CONTROL_SATA_48BIT_LBA_REQUIRED (0x0080) 2421#define MPI_SAS_IOUNIT1_CONTROL_POSTPONE_SATA_INIT (0x0100)
2389#define MPI_SAS_IOUNIT1_CONTROL_SATA_SMART_REQUIRED (0x0040) 2422#define MPI_SAS_IOUNIT1_CONTROL_SATA_48BIT_LBA_REQUIRED (0x0080)
2390#define MPI_SAS_IOUNIT1_CONTROL_SATA_NCQ_REQUIRED (0x0020) 2423#define MPI_SAS_IOUNIT1_CONTROL_SATA_SMART_REQUIRED (0x0040)
2391#define MPI_SAS_IOUNIT1_CONTROL_SATA_FUA_REQUIRED (0x0010) 2424#define MPI_SAS_IOUNIT1_CONTROL_SATA_NCQ_REQUIRED (0x0020)
2392#define MPI_SAS_IOUNIT1_CONTROL_PHY_ENABLE_ORDER_HIGH (0x0008) 2425#define MPI_SAS_IOUNIT1_CONTROL_SATA_FUA_REQUIRED (0x0010)
2393#define MPI_SAS_IOUNIT1_CONTROL_SUBTRACTIVE_ILLEGAL (0x0004) 2426#define MPI_SAS_IOUNIT1_CONTROL_PHY_ENABLE_ORDER_HIGH (0x0008)
2394#define MPI_SAS_IOUNIT1_CONTROL_FIRST_LVL_DISC_ONLY (0x0002) 2427#define MPI_SAS_IOUNIT1_CONTROL_SUBTRACTIVE_ILLEGAL (0x0004)
2395#define MPI_SAS_IOUNIT1_CONTROL_CLEAR_AFFILIATION (0x0001) 2428#define MPI_SAS_IOUNIT1_CONTROL_FIRST_LVL_DISC_ONLY (0x0002)
2429#define MPI_SAS_IOUNIT1_CONTROL_CLEAR_AFFILIATION (0x0001)
2396 2430
2397/* values for SAS IO Unit Page 1 PortFlags */ 2431/* values for SAS IO Unit Page 1 PortFlags */
2398#define MPI_SAS_IOUNIT1_PORT_FLAGS_0_TARGET_IOC_NUM (0x00) 2432#define MPI_SAS_IOUNIT1_PORT_FLAGS_0_TARGET_IOC_NUM (0x00)
2399#define MPI_SAS_IOUNIT1_PORT_FLAGS_1_TARGET_IOC_NUM (0x04) 2433#define MPI_SAS_IOUNIT1_PORT_FLAGS_1_TARGET_IOC_NUM (0x04)
2400#define MPI_SAS_IOUNIT1_PORT_FLAGS_AUTO_PORT_CONFIG (0x01) 2434#define MPI_SAS_IOUNIT1_PORT_FLAGS_AUTO_PORT_CONFIG (0x01)
2401 2435
2402/* values for SAS IO Unit Page 0 PhyFlags */ 2436/* values for SAS IO Unit Page 0 PhyFlags */
2403#define MPI_SAS_IOUNIT1_PHY_FLAGS_PHY_DISABLE (0x04) 2437#define MPI_SAS_IOUNIT1_PHY_FLAGS_PHY_DISABLE (0x04)
2404#define MPI_SAS_IOUNIT1_PHY_FLAGS_TX_INVERT (0x02) 2438#define MPI_SAS_IOUNIT1_PHY_FLAGS_TX_INVERT (0x02)
2405#define MPI_SAS_IOUNIT1_PHY_FLAGS_RX_INVERT (0x01) 2439#define MPI_SAS_IOUNIT1_PHY_FLAGS_RX_INVERT (0x01)
2406 2440
2407/* values for SAS IO Unit Page 0 MaxMinLinkRate */ 2441/* values for SAS IO Unit Page 0 MaxMinLinkRate */
2408#define MPI_SAS_IOUNIT1_MAX_RATE_MASK (0xF0) 2442#define MPI_SAS_IOUNIT1_MAX_RATE_MASK (0xF0)
2409#define MPI_SAS_IOUNIT1_MAX_RATE_1_5 (0x80) 2443#define MPI_SAS_IOUNIT1_MAX_RATE_1_5 (0x80)
2410#define MPI_SAS_IOUNIT1_MAX_RATE_3_0 (0x90) 2444#define MPI_SAS_IOUNIT1_MAX_RATE_3_0 (0x90)
2411#define MPI_SAS_IOUNIT1_MIN_RATE_MASK (0x0F) 2445#define MPI_SAS_IOUNIT1_MIN_RATE_MASK (0x0F)
2412#define MPI_SAS_IOUNIT1_MIN_RATE_1_5 (0x08) 2446#define MPI_SAS_IOUNIT1_MIN_RATE_1_5 (0x08)
2413#define MPI_SAS_IOUNIT1_MIN_RATE_3_0 (0x09) 2447#define MPI_SAS_IOUNIT1_MIN_RATE_3_0 (0x09)
2414 2448
2415/* see mpi_sas.h for values for SAS IO Unit Page 1 ControllerPhyDeviceInfo values */ 2449/* see mpi_sas.h for values for SAS IO Unit Page 1 ControllerPhyDeviceInfo values */
2416 2450
@@ -2418,16 +2452,18 @@ typedef struct _CONFIG_PAGE_SAS_IO_UNIT_1
2418typedef struct _CONFIG_PAGE_SAS_IO_UNIT_2 2452typedef struct _CONFIG_PAGE_SAS_IO_UNIT_2
2419{ 2453{
2420 CONFIG_EXTENDED_PAGE_HEADER Header; /* 00h */ 2454 CONFIG_EXTENDED_PAGE_HEADER Header; /* 00h */
2421 U32 Reserved1; /* 08h */ 2455 U8 NumDevsPerEnclosure; /* 08h */
2456 U8 Reserved1; /* 09h */
2457 U16 Reserved2; /* 0Ah */
2422 U16 MaxPersistentIDs; /* 0Ch */ 2458 U16 MaxPersistentIDs; /* 0Ch */
2423 U16 NumPersistentIDsUsed; /* 0Eh */ 2459 U16 NumPersistentIDsUsed; /* 0Eh */
2424 U8 Status; /* 10h */ 2460 U8 Status; /* 10h */
2425 U8 Flags; /* 11h */ 2461 U8 Flags; /* 11h */
2426 U16 MaxNumPhysicalMappedIDs;/* 12h */ /* 12h */ 2462 U16 MaxNumPhysicalMappedIDs;/* 12h */
2427} CONFIG_PAGE_SAS_IO_UNIT_2, MPI_POINTER PTR_CONFIG_PAGE_SAS_IO_UNIT_2, 2463} CONFIG_PAGE_SAS_IO_UNIT_2, MPI_POINTER PTR_CONFIG_PAGE_SAS_IO_UNIT_2,
2428 SasIOUnitPage2_t, MPI_POINTER pSasIOUnitPage2_t; 2464 SasIOUnitPage2_t, MPI_POINTER pSasIOUnitPage2_t;
2429 2465
2430#define MPI_SASIOUNITPAGE2_PAGEVERSION (0x04) 2466#define MPI_SASIOUNITPAGE2_PAGEVERSION (0x05)
2431 2467
2432/* values for SAS IO Unit Page 2 Status field */ 2468/* values for SAS IO Unit Page 2 Status field */
2433#define MPI_SAS_IOUNIT2_STATUS_DISABLED_PERSISTENT_MAPPINGS (0x02) 2469#define MPI_SAS_IOUNIT2_STATUS_DISABLED_PERSISTENT_MAPPINGS (0x02)
@@ -2441,6 +2477,7 @@ typedef struct _CONFIG_PAGE_SAS_IO_UNIT_2
2441#define MPI_SAS_IOUNIT2_FLAGS_NO_PHYS_MAP (0x00) 2477#define MPI_SAS_IOUNIT2_FLAGS_NO_PHYS_MAP (0x00)
2442#define MPI_SAS_IOUNIT2_FLAGS_DIRECT_ATTACH_PHYS_MAP (0x01) 2478#define MPI_SAS_IOUNIT2_FLAGS_DIRECT_ATTACH_PHYS_MAP (0x01)
2443#define MPI_SAS_IOUNIT2_FLAGS_ENCLOSURE_SLOT_PHYS_MAP (0x02) 2479#define MPI_SAS_IOUNIT2_FLAGS_ENCLOSURE_SLOT_PHYS_MAP (0x02)
2480#define MPI_SAS_IOUNIT2_FLAGS_HOST_ASSIGNED_PHYS_MAP (0x07)
2444 2481
2445#define MPI_SAS_IOUNIT2_FLAGS_RESERVE_ID_0_FOR_BOOT (0x10) 2482#define MPI_SAS_IOUNIT2_FLAGS_RESERVE_ID_0_FOR_BOOT (0x10)
2446#define MPI_SAS_IOUNIT2_FLAGS_DA_STARTING_SLOT (0x20) 2483#define MPI_SAS_IOUNIT2_FLAGS_DA_STARTING_SLOT (0x20)
@@ -2473,7 +2510,7 @@ typedef struct _CONFIG_PAGE_SAS_EXPANDER_0
2473 CONFIG_EXTENDED_PAGE_HEADER Header; /* 00h */ 2510 CONFIG_EXTENDED_PAGE_HEADER Header; /* 00h */
2474 U8 PhysicalPort; /* 08h */ 2511 U8 PhysicalPort; /* 08h */
2475 U8 Reserved1; /* 09h */ 2512 U8 Reserved1; /* 09h */
2476 U16 Reserved2; /* 0Ah */ 2513 U16 EnclosureHandle; /* 0Ah */
2477 U64 SASAddress; /* 0Ch */ 2514 U64 SASAddress; /* 0Ch */
2478 U32 DiscoveryStatus; /* 14h */ 2515 U32 DiscoveryStatus; /* 14h */
2479 U16 DevHandle; /* 18h */ 2516 U16 DevHandle; /* 18h */
@@ -2487,7 +2524,7 @@ typedef struct _CONFIG_PAGE_SAS_EXPANDER_0
2487} CONFIG_PAGE_SAS_EXPANDER_0, MPI_POINTER PTR_CONFIG_PAGE_SAS_EXPANDER_0, 2524} CONFIG_PAGE_SAS_EXPANDER_0, MPI_POINTER PTR_CONFIG_PAGE_SAS_EXPANDER_0,
2488 SasExpanderPage0_t, MPI_POINTER pSasExpanderPage0_t; 2525 SasExpanderPage0_t, MPI_POINTER pSasExpanderPage0_t;
2489 2526
2490#define MPI_SASEXPANDER0_PAGEVERSION (0x02) 2527#define MPI_SASEXPANDER0_PAGEVERSION (0x03)
2491 2528
2492/* values for SAS Expander Page 0 DiscoveryStatus field */ 2529/* values for SAS Expander Page 0 DiscoveryStatus field */
2493#define MPI_SAS_EXPANDER0_DS_LOOP_DETECTED (0x00000001) 2530#define MPI_SAS_EXPANDER0_DS_LOOP_DETECTED (0x00000001)
@@ -2527,9 +2564,9 @@ typedef struct _CONFIG_PAGE_SAS_EXPANDER_1
2527 U8 NegotiatedLinkRate; /* 1Fh */ 2564 U8 NegotiatedLinkRate; /* 1Fh */
2528 U8 PhyIdentifier; /* 20h */ 2565 U8 PhyIdentifier; /* 20h */
2529 U8 AttachedPhyIdentifier; /* 21h */ 2566 U8 AttachedPhyIdentifier; /* 21h */
2530 U8 NumTableEntriesProg; /* 22h */ 2567 U8 Reserved3; /* 22h */
2531 U8 DiscoveryInfo; /* 23h */ 2568 U8 DiscoveryInfo; /* 23h */
2532 U32 Reserved3; /* 24h */ 2569 U32 Reserved4; /* 24h */
2533} CONFIG_PAGE_SAS_EXPANDER_1, MPI_POINTER PTR_CONFIG_PAGE_SAS_EXPANDER_1, 2570} CONFIG_PAGE_SAS_EXPANDER_1, MPI_POINTER PTR_CONFIG_PAGE_SAS_EXPANDER_1,
2534 SasExpanderPage1_t, MPI_POINTER pSasExpanderPage1_t; 2571 SasExpanderPage1_t, MPI_POINTER pSasExpanderPage1_t;
2535 2572
@@ -2766,16 +2803,15 @@ typedef struct _CONFIG_PAGE_SAS_ENCLOSURE_0
2766#define MPI_LOG_0_NUM_LOG_ENTRIES (1) 2803#define MPI_LOG_0_NUM_LOG_ENTRIES (1)
2767#endif 2804#endif
2768 2805
2769#define MPI_LOG_0_LOG_DATA_LENGTH (20) 2806#define MPI_LOG_0_LOG_DATA_LENGTH (0x1C)
2770 2807
2771typedef struct _MPI_LOG_0_ENTRY 2808typedef struct _MPI_LOG_0_ENTRY
2772{ 2809{
2773 U64 WWID; /* 00h */ 2810 U32 TimeStamp; /* 00h */
2774 U32 TimeStamp; /* 08h */ 2811 U32 Reserved1; /* 04h */
2775 U32 Reserved1; /* 0Ch */ 2812 U16 LogSequence; /* 08h */
2776 U16 LogSequence; /* 10h */ 2813 U16 LogEntryQualifier; /* 0Ah */
2777 U16 LogEntryQualifier; /* 12h */ 2814 U8 LogData[MPI_LOG_0_LOG_DATA_LENGTH]; /* 0Ch */
2778 U8 LogData[MPI_LOG_0_LOG_DATA_LENGTH]; /* 14h */
2779} MPI_LOG_0_ENTRY, MPI_POINTER PTR_MPI_LOG_0_ENTRY, 2815} MPI_LOG_0_ENTRY, MPI_POINTER PTR_MPI_LOG_0_ENTRY,
2780 MpiLog0Entry_t, MPI_POINTER pMpiLog0Entry_t; 2816 MpiLog0Entry_t, MPI_POINTER pMpiLog0Entry_t;
2781 2817
@@ -2794,7 +2830,7 @@ typedef struct _CONFIG_PAGE_LOG_0
2794} CONFIG_PAGE_LOG_0, MPI_POINTER PTR_CONFIG_PAGE_LOG_0, 2830} CONFIG_PAGE_LOG_0, MPI_POINTER PTR_CONFIG_PAGE_LOG_0,
2795 LogPage0_t, MPI_POINTER pLogPage0_t; 2831 LogPage0_t, MPI_POINTER pLogPage0_t;
2796 2832
2797#define MPI_LOG_0_PAGEVERSION (0x00) 2833#define MPI_LOG_0_PAGEVERSION (0x01)
2798 2834
2799 2835
2800#endif 2836#endif
diff --git a/drivers/message/fusion/lsi/mpi_history.txt b/drivers/message/fusion/lsi/mpi_history.txt
index 1a30ef16adb4..4a5f8dd1d766 100644
--- a/drivers/message/fusion/lsi/mpi_history.txt
+++ b/drivers/message/fusion/lsi/mpi_history.txt
@@ -6,25 +6,25 @@
6 Copyright (c) 2000-2005 LSI Logic Corporation. 6 Copyright (c) 2000-2005 LSI Logic Corporation.
7 7
8 --------------------------------------- 8 ---------------------------------------
9 Header Set Release Version: 01.05.10 9 Header Set Release Version: 01.05.12
10 Header Set Release Date: 03-11-05 10 Header Set Release Date: 08-30-05
11 --------------------------------------- 11 ---------------------------------------
12 12
13 Filename Current version Prior version 13 Filename Current version Prior version
14 ---------- --------------- ------------- 14 ---------- --------------- -------------
15 mpi.h 01.05.08 01.05.07 15 mpi.h 01.05.10 01.05.09
16 mpi_ioc.h 01.05.09 01.05.08 16 mpi_ioc.h 01.05.10 01.05.09
17 mpi_cnfg.h 01.05.09 01.05.08 17 mpi_cnfg.h 01.05.11 01.05.10
18 mpi_init.h 01.05.05 01.05.04 18 mpi_init.h 01.05.06 01.05.06
19 mpi_targ.h 01.05.05 01.05.04 19 mpi_targ.h 01.05.05 01.05.05
20 mpi_fc.h 01.05.01 01.05.01 20 mpi_fc.h 01.05.01 01.05.01
21 mpi_lan.h 01.05.01 01.05.01 21 mpi_lan.h 01.05.01 01.05.01
22 mpi_raid.h 01.05.02 01.05.02 22 mpi_raid.h 01.05.02 01.05.02
23 mpi_tool.h 01.05.03 01.05.03 23 mpi_tool.h 01.05.03 01.05.03
24 mpi_inb.h 01.05.01 01.05.01 24 mpi_inb.h 01.05.01 01.05.01
25 mpi_sas.h 01.05.01 01.05.01 25 mpi_sas.h 01.05.02 01.05.01
26 mpi_type.h 01.05.01 01.05.01 26 mpi_type.h 01.05.02 01.05.01
27 mpi_history.txt 01.05.09 01.05.09 27 mpi_history.txt 01.05.12 01.05.11
28 28
29 29
30 * Date Version Description 30 * Date Version Description
@@ -91,6 +91,8 @@ mpi.h
91 * 06-24-05 01.05.08 Added function codes for SCSI IO 32 and 91 * 06-24-05 01.05.08 Added function codes for SCSI IO 32 and
92 * TargetAssistExtended requests. 92 * TargetAssistExtended requests.
93 * Added EEDP IOCStatus codes. 93 * Added EEDP IOCStatus codes.
94 * 08-03-05 01.05.09 Bumped MPI_HEADER_VERSION_UNIT.
95 * 08-30-05 01.05.10 Added 2 new IOCStatus codes for Target.
94 * -------------------------------------------------------------------------- 96 * --------------------------------------------------------------------------
95 97
96mpi_ioc.h 98mpi_ioc.h
@@ -164,6 +166,10 @@ mpi_ioc.h
164 * Removed IOCFacts Reply EEDP Capability bit. 166 * Removed IOCFacts Reply EEDP Capability bit.
165 * 06-24-05 01.05.09 Added 5 new IOCFacts Reply IOCCapabilities bits. 167 * 06-24-05 01.05.09 Added 5 new IOCFacts Reply IOCCapabilities bits.
166 * Added Max SATA Targets to SAS Discovery Error event. 168 * Added Max SATA Targets to SAS Discovery Error event.
169 * 08-30-05 01.05.10 Added 4 new events and their event data structures.
170 * Added new ReasonCode value for SAS Device Status Change
171 * event.
172 * Added new family code for FC949E.
167 * -------------------------------------------------------------------------- 173 * --------------------------------------------------------------------------
168 174
169mpi_cnfg.h 175mpi_cnfg.h
@@ -402,6 +408,23 @@ mpi_cnfg.h
402 * Added OwnerDevHandle and Flags field to SAS PHY Page 0. 408 * Added OwnerDevHandle and Flags field to SAS PHY Page 0.
403 * Added IOC GPIO Flags define to SAS Enclosure Page 0. 409 * Added IOC GPIO Flags define to SAS Enclosure Page 0.
404 * Fixed the value for MPI_SAS_IOUNIT1_CONTROL_DEV_SATA_SUPPORT. 410 * Fixed the value for MPI_SAS_IOUNIT1_CONTROL_DEV_SATA_SUPPORT.
411 * 08-03-05 01.05.10 Removed ISDataScrubRate and ISResyncRate from
412 * Manufacturing Page 4.
413 * Added MPI_IOUNITPAGE1_SATA_WRITE_CACHE_DISABLE bit.
414 * Added NumDevsPerEnclosure field to SAS IO Unit page 2.
415 * Added MPI_SAS_IOUNIT2_FLAGS_HOST_ASSIGNED_PHYS_MAP
416 * define.
417 * Added EnclosureHandle field to SAS Expander page 0.
418 * Removed redundant NumTableEntriesProg field from SAS
419 * Expander Page 1.
420 * 08-30-05 01.05.11 Added DeviceID for FC949E and changed the DeviceID for
421 * SAS1078.
422 * Added more defines for Manufacturing Page 4 Flags field.
423 * Added more defines for IOCSettings and added
424 * ExpanderSpinup field to Bios Page 1.
425 * Added postpone SATA Init bit to SAS IO Unit Page 1
426 * ControlFlags.
427 * Changed LogEntry format for Log Page 0.
405 * -------------------------------------------------------------------------- 428 * --------------------------------------------------------------------------
406 429
407mpi_init.h 430mpi_init.h
@@ -442,6 +465,8 @@ mpi_init.h
442 * addressing. 465 * addressing.
443 * 06-24-05 01.05.05 Added SCSI IO 32 structures and defines. 466 * 06-24-05 01.05.05 Added SCSI IO 32 structures and defines.
444 * Added four new defines for SEP SlotStatus. 467 * Added four new defines for SEP SlotStatus.
468 * 08-03-05 01.05.06 Fixed some MPI_SCSIIO32_MSGFLGS_ defines to make them
469 * unique in the first 32 characters.
445 * -------------------------------------------------------------------------- 470 * --------------------------------------------------------------------------
446 471
447mpi_targ.h 472mpi_targ.h
@@ -582,6 +607,9 @@ mpi_inb.h
582 607
583mpi_sas.h 608mpi_sas.h
584 * 08-19-04 01.05.01 Original release. 609 * 08-19-04 01.05.01 Original release.
610 * 08-30-05 01.05.02 Added DeviceInfo bit for SEP.
611 * Added PrimFlags and Primitive field to SAS IO Unit
612 * Control request, and added a new operation code.
585 * -------------------------------------------------------------------------- 613 * --------------------------------------------------------------------------
586 614
587mpi_type.h 615mpi_type.h
@@ -592,24 +620,25 @@ mpi_type.h
592 * 08-08-01 01.02.01 Original release for v1.2 work. 620 * 08-08-01 01.02.01 Original release for v1.2 work.
593 * 05-11-04 01.03.01 Original release for MPI v1.3. 621 * 05-11-04 01.03.01 Original release for MPI v1.3.
594 * 08-19-04 01.05.01 Original release for MPI v1.5. 622 * 08-19-04 01.05.01 Original release for MPI v1.5.
623 * 08-30-05 01.05.02 Added PowerPC option to #ifdef's.
595 * -------------------------------------------------------------------------- 624 * --------------------------------------------------------------------------
596 625
597mpi_history.txt Parts list history 626mpi_history.txt Parts list history
598 627
599Filename 01.05.10 01.05.09 628Filename 01.05.12 01.05.11 01.05.10 01.05.09
600---------- -------- -------- 629---------- -------- -------- -------- --------
601mpi.h 01.05.08 01.05.07 630mpi.h 01.05.10 01.05.09 01.05.08 01.05.07
602mpi_ioc.h 01.05.09 01.05.08 631mpi_ioc.h 01.05.10 01.05.09 01.05.09 01.05.08
603mpi_cnfg.h 01.05.09 01.05.08 632mpi_cnfg.h 01.05.11 01.05.10 01.05.09 01.05.08
604mpi_init.h 01.05.05 01.05.04 633mpi_init.h 01.05.06 01.05.06 01.05.05 01.05.04
605mpi_targ.h 01.05.05 01.05.04 634mpi_targ.h 01.05.05 01.05.05 01.05.05 01.05.04
606mpi_fc.h 01.05.01 01.05.01 635mpi_fc.h 01.05.01 01.05.01 01.05.01 01.05.01
607mpi_lan.h 01.05.01 01.05.01 636mpi_lan.h 01.05.01 01.05.01 01.05.01 01.05.01
608mpi_raid.h 01.05.02 01.05.02 637mpi_raid.h 01.05.02 01.05.02 01.05.02 01.05.02
609mpi_tool.h 01.05.03 01.05.03 638mpi_tool.h 01.05.03 01.05.03 01.05.03 01.05.03
610mpi_inb.h 01.05.01 01.05.01 639mpi_inb.h 01.05.01 01.05.01 01.05.01 01.05.01
611mpi_sas.h 01.05.01 01.05.01 640mpi_sas.h 01.05.02 01.05.01 01.05.01 01.05.01
612mpi_type.h 01.05.01 01.05.01 641mpi_type.h 01.05.02 01.05.01 01.05.01 01.05.01
613 642
614Filename 01.05.08 01.05.07 01.05.06 01.05.05 01.05.04 01.05.03 643Filename 01.05.08 01.05.07 01.05.06 01.05.05 01.05.04 01.05.03
615---------- -------- -------- -------- -------- -------- -------- 644---------- -------- -------- -------- -------- -------- --------
diff --git a/drivers/message/fusion/lsi/mpi_init.h b/drivers/message/fusion/lsi/mpi_init.h
index d5af75afbd94..68941f459ca3 100644
--- a/drivers/message/fusion/lsi/mpi_init.h
+++ b/drivers/message/fusion/lsi/mpi_init.h
@@ -6,7 +6,7 @@
6 * Title: MPI initiator mode messages and structures 6 * Title: MPI initiator mode messages and structures
7 * Creation Date: June 8, 2000 7 * Creation Date: June 8, 2000
8 * 8 *
9 * mpi_init.h Version: 01.05.05 9 * mpi_init.h Version: 01.05.06
10 * 10 *
11 * Version History 11 * Version History
12 * --------------- 12 * ---------------
@@ -50,6 +50,8 @@
50 * addressing. 50 * addressing.
51 * 06-24-05 01.05.05 Added SCSI IO 32 structures and defines. 51 * 06-24-05 01.05.05 Added SCSI IO 32 structures and defines.
52 * Added four new defines for SEP SlotStatus. 52 * Added four new defines for SEP SlotStatus.
53 * 08-03-05 01.05.06 Fixed some MPI_SCSIIO32_MSGFLGS_ defines to make them
54 * unique in the first 32 characters.
53 * -------------------------------------------------------------------------- 55 * --------------------------------------------------------------------------
54 */ 56 */
55 57
@@ -290,8 +292,8 @@ typedef struct _MSG_SCSI_IO32_REQUEST
290 292
291/* SCSI IO 32 MsgFlags bits */ 293/* SCSI IO 32 MsgFlags bits */
292#define MPI_SCSIIO32_MSGFLGS_SENSE_WIDTH (0x01) 294#define MPI_SCSIIO32_MSGFLGS_SENSE_WIDTH (0x01)
293#define MPI_SCSIIO32_MSGFLGS_SENSE_WIDTH_32 (0x00) 295#define MPI_SCSIIO32_MSGFLGS_32_SENSE_WIDTH (0x00)
294#define MPI_SCSIIO32_MSGFLGS_SENSE_WIDTH_64 (0x01) 296#define MPI_SCSIIO32_MSGFLGS_64_SENSE_WIDTH (0x01)
295 297
296#define MPI_SCSIIO32_MSGFLGS_SENSE_LOCATION (0x02) 298#define MPI_SCSIIO32_MSGFLGS_SENSE_LOCATION (0x02)
297#define MPI_SCSIIO32_MSGFLGS_SENSE_LOC_HOST (0x00) 299#define MPI_SCSIIO32_MSGFLGS_SENSE_LOC_HOST (0x00)
diff --git a/drivers/message/fusion/lsi/mpi_ioc.h b/drivers/message/fusion/lsi/mpi_ioc.h
index 93b70e2b4266..2c5f43fa7c73 100644
--- a/drivers/message/fusion/lsi/mpi_ioc.h
+++ b/drivers/message/fusion/lsi/mpi_ioc.h
@@ -6,7 +6,7 @@
6 * Title: MPI IOC, Port, Event, FW Download, and FW Upload messages 6 * Title: MPI IOC, Port, Event, FW Download, and FW Upload messages
7 * Creation Date: August 11, 2000 7 * Creation Date: August 11, 2000
8 * 8 *
9 * mpi_ioc.h Version: 01.05.09 9 * mpi_ioc.h Version: 01.05.10
10 * 10 *
11 * Version History 11 * Version History
12 * --------------- 12 * ---------------
@@ -83,6 +83,10 @@
83 * Removed IOCFacts Reply EEDP Capability bit. 83 * Removed IOCFacts Reply EEDP Capability bit.
84 * 06-24-05 01.05.09 Added 5 new IOCFacts Reply IOCCapabilities bits. 84 * 06-24-05 01.05.09 Added 5 new IOCFacts Reply IOCCapabilities bits.
85 * Added Max SATA Targets to SAS Discovery Error event. 85 * Added Max SATA Targets to SAS Discovery Error event.
86 * 08-30-05 01.05.10 Added 4 new events and their event data structures.
87 * Added new ReasonCode value for SAS Device Status Change
88 * event.
89 * Added new family code for FC949E.
86 * -------------------------------------------------------------------------- 90 * --------------------------------------------------------------------------
87 */ 91 */
88 92
@@ -464,6 +468,10 @@ typedef struct _MSG_EVENT_ACK_REPLY
464#define MPI_EVENT_PERSISTENT_TABLE_FULL (0x00000011) 468#define MPI_EVENT_PERSISTENT_TABLE_FULL (0x00000011)
465#define MPI_EVENT_SAS_PHY_LINK_STATUS (0x00000012) 469#define MPI_EVENT_SAS_PHY_LINK_STATUS (0x00000012)
466#define MPI_EVENT_SAS_DISCOVERY_ERROR (0x00000013) 470#define MPI_EVENT_SAS_DISCOVERY_ERROR (0x00000013)
471#define MPI_EVENT_IR_RESYNC_UPDATE (0x00000014)
472#define MPI_EVENT_IR2 (0x00000015)
473#define MPI_EVENT_SAS_DISCOVERY (0x00000016)
474#define MPI_EVENT_LOG_ENTRY_ADDED (0x00000021)
467 475
468/* AckRequired field values */ 476/* AckRequired field values */
469 477
@@ -480,6 +488,29 @@ typedef struct _EVENT_DATA_EVENT_CHANGE
480} EVENT_DATA_EVENT_CHANGE, MPI_POINTER PTR_EVENT_DATA_EVENT_CHANGE, 488} EVENT_DATA_EVENT_CHANGE, MPI_POINTER PTR_EVENT_DATA_EVENT_CHANGE,
481 EventDataEventChange_t, MPI_POINTER pEventDataEventChange_t; 489 EventDataEventChange_t, MPI_POINTER pEventDataEventChange_t;
482 490
491/* LogEntryAdded Event data */
492
493/* this structure matches MPI_LOG_0_ENTRY in mpi_cnfg.h */
494#define MPI_EVENT_DATA_LOG_ENTRY_DATA_LENGTH (0x1C)
495typedef struct _EVENT_DATA_LOG_ENTRY
496{
497 U32 TimeStamp; /* 00h */
498 U32 Reserved1; /* 04h */
499 U16 LogSequence; /* 08h */
500 U16 LogEntryQualifier; /* 0Ah */
501 U8 LogData[MPI_EVENT_DATA_LOG_ENTRY_DATA_LENGTH]; /* 0Ch */
502} EVENT_DATA_LOG_ENTRY, MPI_POINTER PTR_EVENT_DATA_LOG_ENTRY,
503 MpiEventDataLogEntry_t, MPI_POINTER pMpiEventDataLogEntry_t;
504
505typedef struct _EVENT_DATA_LOG_ENTRY_ADDED
506{
507 U16 LogSequence; /* 00h */
508 U16 Reserved1; /* 02h */
509 U32 Reserved2; /* 04h */
510 EVENT_DATA_LOG_ENTRY LogEntry; /* 08h */
511} EVENT_DATA_LOG_ENTRY_ADDED, MPI_POINTER PTR_EVENT_DATA_LOG_ENTRY_ADDED,
512 MpiEventDataLogEntryAdded_t, MPI_POINTER pMpiEventDataLogEntryAdded_t;
513
483/* SCSI Event data for Port, Bus and Device forms */ 514/* SCSI Event data for Port, Bus and Device forms */
484 515
485typedef struct _EVENT_DATA_SCSI 516typedef struct _EVENT_DATA_SCSI
@@ -538,6 +569,7 @@ typedef struct _EVENT_DATA_SAS_DEVICE_STATUS_CHANGE
538#define MPI_EVENT_SAS_DEV_STAT_RC_SMART_DATA (0x05) 569#define MPI_EVENT_SAS_DEV_STAT_RC_SMART_DATA (0x05)
539#define MPI_EVENT_SAS_DEV_STAT_RC_NO_PERSIST_ADDED (0x06) 570#define MPI_EVENT_SAS_DEV_STAT_RC_NO_PERSIST_ADDED (0x06)
540#define MPI_EVENT_SAS_DEV_STAT_RC_UNSUPPORTED (0x07) 571#define MPI_EVENT_SAS_DEV_STAT_RC_UNSUPPORTED (0x07)
572#define MPI_EVENT_SAS_DEV_STAT_RC_INTERNAL_DEVICE_RESET (0x08)
541 573
542 574
543/* SCSI Event data for Queue Full event */ 575/* SCSI Event data for Queue Full event */
@@ -579,6 +611,79 @@ typedef struct _EVENT_DATA_RAID
579#define MPI_EVENT_RAID_RC_SMART_DATA (0x0A) 611#define MPI_EVENT_RAID_RC_SMART_DATA (0x0A)
580#define MPI_EVENT_RAID_RC_REPLACE_ACTION_STARTED (0x0B) 612#define MPI_EVENT_RAID_RC_REPLACE_ACTION_STARTED (0x0B)
581 613
614
615/* MPI Integrated RAID Resync Update Event data */
616
617typedef struct _MPI_EVENT_DATA_IR_RESYNC_UPDATE
618{
619 U8 VolumeID; /* 00h */
620 U8 VolumeBus; /* 01h */
621 U8 ResyncComplete; /* 02h */
622 U8 Reserved1; /* 03h */
623 U32 Reserved2; /* 04h */
624} MPI_EVENT_DATA_IR_RESYNC_UPDATE,
625 MPI_POINTER PTR_MPI_EVENT_DATA_IR_RESYNC_UPDATE,
626 MpiEventDataIrResyncUpdate_t, MPI_POINTER pMpiEventDataIrResyncUpdate_t;
627
628/* MPI IR2 Event data */
629
630/* MPI_LD_STATE or MPI_PD_STATE */
631typedef struct _IR2_STATE_CHANGED
632{
633 U16 PreviousState; /* 00h */
634 U16 NewState; /* 02h */
635} IR2_STATE_CHANGED, MPI_POINTER PTR_IR2_STATE_CHANGED;
636
637typedef struct _IR2_PD_INFO
638{
639 U16 DeviceHandle; /* 00h */
640 U8 TruncEnclosureHandle; /* 02h */
641 U8 TruncatedSlot; /* 03h */
642} IR2_PD_INFO, MPI_POINTER PTR_IR2_PD_INFO;
643
644typedef union _MPI_IR2_RC_EVENT_DATA
645{
646 IR2_STATE_CHANGED StateChanged;
647 U32 Lba;
648 IR2_PD_INFO PdInfo;
649} MPI_IR2_RC_EVENT_DATA, MPI_POINTER PTR_MPI_IR2_RC_EVENT_DATA;
650
651typedef struct _MPI_EVENT_DATA_IR2
652{
653 U8 TargetID; /* 00h */
654 U8 Bus; /* 01h */
655 U8 ReasonCode; /* 02h */
656 U8 PhysDiskNum; /* 03h */
657 MPI_IR2_RC_EVENT_DATA IR2EventData; /* 04h */
658} MPI_EVENT_DATA_IR2, MPI_POINTER PTR_MPI_EVENT_DATA_IR2,
659 MpiEventDataIR2_t, MPI_POINTER pMpiEventDataIR2_t;
660
661/* MPI IR2 Event data ReasonCode values */
662#define MPI_EVENT_IR2_RC_LD_STATE_CHANGED (0x01)
663#define MPI_EVENT_IR2_RC_PD_STATE_CHANGED (0x02)
664#define MPI_EVENT_IR2_RC_BAD_BLOCK_TABLE_FULL (0x03)
665#define MPI_EVENT_IR2_RC_PD_INSERTED (0x04)
666#define MPI_EVENT_IR2_RC_PD_REMOVED (0x05)
667#define MPI_EVENT_IR2_RC_FOREIGN_CFG_DETECTED (0x06)
668#define MPI_EVENT_IR2_RC_REBUILD_MEDIUM_ERROR (0x07)
669
670/* defines for logical disk states */
671#define MPI_LD_STATE_OPTIMAL (0x00)
672#define MPI_LD_STATE_DEGRADED (0x01)
673#define MPI_LD_STATE_FAILED (0x02)
674#define MPI_LD_STATE_MISSING (0x03)
675#define MPI_LD_STATE_OFFLINE (0x04)
676
677/* defines for physical disk states */
678#define MPI_PD_STATE_ONLINE (0x00)
679#define MPI_PD_STATE_MISSING (0x01)
680#define MPI_PD_STATE_NOT_COMPATIBLE (0x02)
681#define MPI_PD_STATE_FAILED (0x03)
682#define MPI_PD_STATE_INITIALIZING (0x04)
683#define MPI_PD_STATE_OFFLINE_AT_HOST_REQUEST (0x05)
684#define MPI_PD_STATE_FAILED_AT_HOST_REQUEST (0x06)
685#define MPI_PD_STATE_OFFLINE_FOR_ANOTHER_REASON (0xFF)
686
582/* MPI Link Status Change Event data */ 687/* MPI Link Status Change Event data */
583 688
584typedef struct _EVENT_DATA_LINK_STATUS 689typedef struct _EVENT_DATA_LINK_STATUS
@@ -660,6 +765,20 @@ typedef struct _EVENT_DATA_SAS_PHY_LINK_STATUS
660#define MPI_EVENT_SAS_PLS_LR_RATE_1_5 (0x08) 765#define MPI_EVENT_SAS_PLS_LR_RATE_1_5 (0x08)
661#define MPI_EVENT_SAS_PLS_LR_RATE_3_0 (0x09) 766#define MPI_EVENT_SAS_PLS_LR_RATE_3_0 (0x09)
662 767
768/* SAS Discovery Event data */
769
770typedef struct _EVENT_DATA_SAS_DISCOVERY
771{
772 U32 DiscoveryStatus; /* 00h */
773 U32 Reserved1; /* 04h */
774} EVENT_DATA_SAS_DISCOVERY, MPI_POINTER PTR_EVENT_DATA_SAS_DISCOVERY,
775 EventDataSasDiscovery_t, MPI_POINTER pEventDataSasDiscovery_t;
776
777#define MPI_EVENT_SAS_DSCVRY_COMPLETE (0x00000000)
778#define MPI_EVENT_SAS_DSCVRY_IN_PROGRESS (0x00000001)
779#define MPI_EVENT_SAS_DSCVRY_PHY_BITS_MASK (0xFFFF0000)
780#define MPI_EVENT_SAS_DSCVRY_PHY_BITS_SHIFT (16)
781
663/* SAS Discovery Errror Event data */ 782/* SAS Discovery Errror Event data */
664 783
665typedef struct _EVENT_DATA_DISCOVERY_ERROR 784typedef struct _EVENT_DATA_DISCOVERY_ERROR
@@ -869,6 +988,7 @@ typedef struct _MPI_FW_HEADER
869#define MPI_FW_HEADER_PID_FAMILY_919XL_FC (0x0003) /* 919XL and 929XL */ 988#define MPI_FW_HEADER_PID_FAMILY_919XL_FC (0x0003) /* 919XL and 929XL */
870#define MPI_FW_HEADER_PID_FAMILY_939X_FC (0x0004) /* 939X and 949X */ 989#define MPI_FW_HEADER_PID_FAMILY_939X_FC (0x0004) /* 939X and 949X */
871#define MPI_FW_HEADER_PID_FAMILY_959_FC (0x0005) 990#define MPI_FW_HEADER_PID_FAMILY_959_FC (0x0005)
991#define MPI_FW_HEADER_PID_FAMILY_949E_FC (0x0006)
872/* SAS */ 992/* SAS */
873#define MPI_FW_HEADER_PID_FAMILY_1064_SAS (0x0001) 993#define MPI_FW_HEADER_PID_FAMILY_1064_SAS (0x0001)
874#define MPI_FW_HEADER_PID_FAMILY_1068_SAS (0x0002) 994#define MPI_FW_HEADER_PID_FAMILY_1068_SAS (0x0002)
diff --git a/drivers/message/fusion/lsi/mpi_log_fc.h b/drivers/message/fusion/lsi/mpi_log_fc.h
new file mode 100644
index 000000000000..dc98d46f9071
--- /dev/null
+++ b/drivers/message/fusion/lsi/mpi_log_fc.h
@@ -0,0 +1,89 @@
1/*
2 * Copyright (c) 2000-2001 LSI Logic Corporation. All rights reserved.
3 *
4 * NAME: fc_log.h
5 * SUMMARY: MPI IocLogInfo definitions for the SYMFC9xx chips
6 * DESCRIPTION: Contains the enumerated list of values that may be returned
7 * in the IOCLogInfo field of a MPI Default Reply Message.
8 *
9 * CREATION DATE: 6/02/2000
10 * ID: $Id: fc_log.h,v 4.6 2001/07/26 14:41:33 sschremm Exp $
11 */
12
13
14/*
15 * MpiIocLogInfo_t enum
16 *
17 * These 32 bit values are used in the IOCLogInfo field of the MPI reply
18 * messages.
19 * The value is 0xabcccccc where
20 * a = The type of log info as per the MPI spec. Since these codes are
21 * all for Fibre Channel this value will always be 2.
22 * b = Specifies a subclass of the firmware where
23 * 0 = FCP Initiator
24 * 1 = FCP Target
25 * 2 = LAN
26 * 3 = MPI Message Layer
27 * 4 = FC Link
28 * 5 = Context Manager
29 * 6 = Invalid Field Offset
30 * 7 = State Change Info
31 * all others are reserved for future use
32 * c = A specific value within the subclass.
33 *
34 * NOTE: Any new values should be added to the end of each subclass so that the
35 * codes remain consistent across firmware releases.
36 */
37typedef enum _MpiIocLogInfoFc
38{
39 MPI_IOCLOGINFO_FC_INIT_BASE = 0x20000000,
40 MPI_IOCLOGINFO_FC_INIT_ERROR_OUT_OF_ORDER_FRAME = 0x20000001, /* received an out of order frame - unsupported */
41 MPI_IOCLOGINFO_FC_INIT_ERROR_BAD_START_OF_FRAME = 0x20000002, /* Bad Rx Frame, bad start of frame primative */
42 MPI_IOCLOGINFO_FC_INIT_ERROR_BAD_END_OF_FRAME = 0x20000003, /* Bad Rx Frame, bad end of frame primative */
43 MPI_IOCLOGINFO_FC_INIT_ERROR_OVER_RUN = 0x20000004, /* Bad Rx Frame, overrun */
44 MPI_IOCLOGINFO_FC_INIT_ERROR_RX_OTHER = 0x20000005, /* Other errors caught by IOC which require retries */
45 MPI_IOCLOGINFO_FC_INIT_ERROR_SUBPROC_DEAD = 0x20000006, /* Main processor could not initialize sub-processor */
46 MPI_IOCLOGINFO_FC_INIT_ERROR_RX_OVERRUN = 0x20000007, /* Scatter Gather overrun */
47 MPI_IOCLOGINFO_FC_INIT_ERROR_RX_BAD_STATUS = 0x20000008, /* Receiver detected context mismatch via invalid header */
48 MPI_IOCLOGINFO_FC_INIT_ERROR_RX_UNEXPECTED_FRAME= 0x20000009, /* CtxMgr detected unsupported frame type */
49 MPI_IOCLOGINFO_FC_INIT_ERROR_LINK_FAILURE = 0x2000000A, /* Link failure occurred */
50 MPI_IOCLOGINFO_FC_INIT_ERROR_TX_TIMEOUT = 0x2000000B, /* Transmitter timeout error */
51
52 MPI_IOCLOGINFO_FC_TARGET_BASE = 0x21000000,
53 MPI_IOCLOGINFO_FC_TARGET_NO_PDISC = 0x21000001, /* not sent because we are waiting for a PDISC from the initiator */
54 MPI_IOCLOGINFO_FC_TARGET_NO_LOGIN = 0x21000002, /* not sent because we are not logged in to the remote node */
55 MPI_IOCLOGINFO_FC_TARGET_DOAR_KILLED_BY_LIP = 0x21000003, /* Data Out, Auto Response, not sent due to a LIP */
56 MPI_IOCLOGINFO_FC_TARGET_DIAR_KILLED_BY_LIP = 0x21000004, /* Data In, Auto Response, not sent due to a LIP */
57 MPI_IOCLOGINFO_FC_TARGET_DIAR_MISSING_DATA = 0x21000005, /* Data In, Auto Response, missing data frames */
58 MPI_IOCLOGINFO_FC_TARGET_DONR_KILLED_BY_LIP = 0x21000006, /* Data Out, No Response, not sent due to a LIP */
59 MPI_IOCLOGINFO_FC_TARGET_WRSP_KILLED_BY_LIP = 0x21000007, /* Auto-response after a write not sent due to a LIP */
60 MPI_IOCLOGINFO_FC_TARGET_DINR_KILLED_BY_LIP = 0x21000008, /* Data In, No Response, not completed due to a LIP */
61 MPI_IOCLOGINFO_FC_TARGET_DINR_MISSING_DATA = 0x21000009, /* Data In, No Response, missing data frames */
62 MPI_IOCLOGINFO_FC_TARGET_MRSP_KILLED_BY_LIP = 0x2100000a, /* Manual Response not sent due to a LIP */
63 MPI_IOCLOGINFO_FC_TARGET_NO_CLASS_3 = 0x2100000b, /* not sent because remote node does not support Class 3 */
64 MPI_IOCLOGINFO_FC_TARGET_LOGIN_NOT_VALID = 0x2100000c, /* not sent because login to remote node not validated */
65 MPI_IOCLOGINFO_FC_TARGET_FROM_OUTBOUND = 0x2100000e, /* cleared from the outbound queue after a logout */
66 MPI_IOCLOGINFO_FC_TARGET_WAITING_FOR_DATA_IN = 0x2100000f, /* cleared waiting for data after a logout */
67
68 MPI_IOCLOGINFO_FC_LAN_BASE = 0x22000000,
69 MPI_IOCLOGINFO_FC_LAN_TRANS_SGL_MISSING = 0x22000001, /* Transaction Context Sgl Missing */
70 MPI_IOCLOGINFO_FC_LAN_TRANS_WRONG_PLACE = 0x22000002, /* Transaction Context found before an EOB */
71 MPI_IOCLOGINFO_FC_LAN_TRANS_RES_BITS_SET = 0x22000003, /* Transaction Context value has reserved bits set */
72 MPI_IOCLOGINFO_FC_LAN_WRONG_SGL_FLAG = 0x22000004, /* Invalid SGL Flags */
73
74 MPI_IOCLOGINFO_FC_MSG_BASE = 0x23000000,
75
76 MPI_IOCLOGINFO_FC_LINK_BASE = 0x24000000,
77 MPI_IOCLOGINFO_FC_LINK_LOOP_INIT_TIMEOUT = 0x24000001, /* Loop initialization timed out */
78 MPI_IOCLOGINFO_FC_LINK_ALREADY_INITIALIZED = 0x24000002, /* Another system controller already initialized the loop */
79 MPI_IOCLOGINFO_FC_LINK_LINK_NOT_ESTABLISHED = 0x24000003, /* Not synchronized to signal or still negotiating (possible cable problem) */
80 MPI_IOCLOGINFO_FC_LINK_CRC_ERROR = 0x24000004, /* CRC check detected error on received frame */
81
82 MPI_IOCLOGINFO_FC_CTX_BASE = 0x25000000,
83
84 MPI_IOCLOGINFO_FC_INVALID_FIELD_BYTE_OFFSET = 0x26000000, /* The lower 24 bits give the byte offset of the field in the request message that is invalid */
85 MPI_IOCLOGINFO_FC_INVALID_FIELD_MAX_OFFSET = 0x26ffffff,
86
87 MPI_IOCLOGINFO_FC_STATE_CHANGE = 0x27000000 /* The lower 24 bits give additional information concerning state change */
88
89} MpiIocLogInfoFc_t;
diff --git a/drivers/message/fusion/lsi/mpi_log_sas.h b/drivers/message/fusion/lsi/mpi_log_sas.h
new file mode 100644
index 000000000000..9259d1ad6e6e
--- /dev/null
+++ b/drivers/message/fusion/lsi/mpi_log_sas.h
@@ -0,0 +1,162 @@
1
2/***************************************************************************
3 * *
4 * Copyright 2003 LSI Logic Corporation. All rights reserved. *
5 * *
6 * This file is confidential and a trade secret of LSI Logic. The *
7 * receipt of or possession of this file does not convey any rights to *
8 * reproduce or disclose its contents or to manufacture, use, or sell *
9 * anything it may describe, in whole, or in part, without the specific *
10 * written consent of LSI Logic Corporation. *
11 * *
12 ***************************************************************************
13 *
14 * Name: iopiIocLogInfo.h
15 * Title: SAS Firmware IOP Interface IOC Log Info Definitions
16 * Programmer: Guy Kendall
17 * Creation Date: September 24, 2003
18 *
19 * Version History
20 * ---------------
21 *
22 * Last Updated
23 * -------------
24 * Version %version: 22 %
25 * Date Updated %date_modified: %
26 * Programmer %created_by: nperucca %
27 *
28 * Date Who Description
29 * -------- --- -------------------------------------------------------
30 * 09/24/03 GWK Initial version
31 *
32 *
33 * Description
34 * ------------
35 * This include file contains SAS firmware interface IOC Log Info codes
36 *
37 *-------------------------------------------------------------------------
38 */
39
40#ifndef IOPI_IOCLOGINFO_H_INCLUDED
41#define IOPI_IOCLOGINFO_H_INCLUDED
42
43
44/****************************************************************************/
45/* IOC LOGINFO defines, 0x00000000 - 0x0FFFFFFF */
46/* Format: */
47/* Bits 31-28: MPI_IOCLOGINFO_TYPE_SAS (3) */
48/* Bits 27-24: IOC_LOGINFO_ORIGINATOR: 0=IOP, 1=PL, 2=IR */
49/* Bits 23-16: LOGINFO_CODE */
50/* Bits 15-0: LOGINFO_CODE Specific */
51/****************************************************************************/
52
53/****************************************************************************/
54/* IOC_LOGINFO_ORIGINATOR defines */
55/****************************************************************************/
56#define IOC_LOGINFO_ORIGINATOR_IOP (0x00000000)
57#define IOC_LOGINFO_ORIGINATOR_PL (0x01000000)
58#define IOC_LOGINFO_ORIGINATOR_IR (0x02000000)
59
60/****************************************************************************/
61/* LOGINFO_CODE defines */
62/****************************************************************************/
63#define IOC_LOGINFO_CODE_MASK (0x00FF0000)
64#define IOC_LOGINFO_CODE_SHIFT (16)
65
66/****************************************************************************/
67/* IOP LOGINFO_CODE defines, valid if IOC_LOGINFO_ORIGINATOR = IOP */
68/****************************************************************************/
69#define IOP_LOGINFO_CODE_INVALID_SAS_ADDRESS (0x00010000)
70#define IOP_LOGINFO_CODE_UNUSED2 (0x00020000)
71#define IOP_LOGINFO_CODE_CONFIG_INVALID_PAGE (0x00030000)
72#define IOP_LOGINFO_CODE_CONFIG_INVALID_PAGE_RT (0x00030100) /* Route Table Entry not found */
73#define IOP_LOGINFO_CODE_CONFIG_INVALID_PAGE_PN (0x00030200) /* Invalid Page Number */
74#define IOP_LOGINFO_CODE_CONFIG_INVALID_PAGE_FORM (0x00030300) /* Invalid FORM */
75#define IOP_LOGINFO_CODE_CONFIG_INVALID_PAGE_PT (0x00030400) /* Invalid Page Type */
76#define IOP_LOGINFO_CODE_CONFIG_INVALID_PAGE_DNM (0x00030500) /* Device Not Mapped */
77#define IOP_LOGINFO_CODE_CONFIG_INVALID_PAGE_PERSIST (0x00030600) /* Persistent Page not found */
78#define IOP_LOGINFO_CODE_CONFIG_INVALID_PAGE_DEFAULT (0x00030700) /* Default Page not found */
79#define IOP_LOGINFO_CODE_TASK_TERMINATED (0x00050000)
80
81
82/****************************************************************************/
83/* PL LOGINFO_CODE defines, valid if IOC_LOGINFO_ORIGINATOR = PL */
84/****************************************************************************/
85#define PL_LOGINFO_CODE_OPEN_FAILURE (0x00010000)
86#define PL_LOGINFO_CODE_INVALID_SGL (0x00020000)
87#define PL_LOGINFO_CODE_WRONG_REL_OFF_OR_FRAME_LENGTH (0x00030000)
88#define PL_LOGINFO_CODE_FRAME_XFER_ERROR (0x00040000)
89#define PL_LOGINFO_CODE_TX_FM_CONNECTED_LOW (0x00050000)
90#define PL_LOGINFO_CODE_SATA_NON_NCQ_RW_ERR_BIT_SET (0x00060000)
91#define PL_LOGINFO_CODE_SATA_READ_LOG_RECEIVE_DATA_ERR (0x00070000)
92#define PL_LOGINFO_CODE_SATA_NCQ_FAIL_ALL_CMDS_AFTR_ERR (0x00080000)
93#define PL_LOGINFO_CODE_SATA_ERR_IN_RCV_SET_DEV_BIT_FIS (0x00090000)
94#define PL_LOGINFO_CODE_RX_FM_INVALID_MESSAGE (0x000A0000)
95#define PL_LOGINFO_CODE_RX_CTX_MESSAGE_VALID_ERROR (0x000B0000)
96#define PL_LOGINFO_CODE_RX_FM_CURRENT_FRAME_ERROR (0x000C0000)
97#define PL_LOGINFO_CODE_SATA_LINK_DOWN (0x000D0000)
98#define PL_LOGINFO_CODE_DISCOVERY_SATA_INIT_W_IOS (0x000E0000)
99#define PL_LOGINFO_CODE_CONFIG_INVALID_PAGE (0x000F0000)
100#define PL_LOGINFO_CODE_CONFIG_INVALID_PAGE_PT (0x000F0100) /* Invalid Page Type */
101#define PL_LOGINFO_CODE_CONFIG_INVALID_PAGE_NUM_PHYS (0x000F0200) /* Invalid Number of Phys */
102#define PL_LOGINFO_CODE_CONFIG_INVALID_PAGE_NOT_IMP (0x000F0300) /* Case Not Handled */
103#define PL_LOGINFO_CODE_CONFIG_INVALID_PAGE_NO_DEV (0x000F0400) /* No Device Found */
104#define PL_LOGINFO_CODE_CONFIG_INVALID_PAGE_FORM (0x000F0500) /* Invalid FORM */
105#define PL_LOGINFO_CODE_CONFIG_INVALID_PAGE_PHY (0x000F0600) /* Invalid Phy */
106#define PL_LOGINFO_CODE_CONFIG_INVALID_PAGE_NO_OWNER (0x000F0700) /* No Owner Found */
107#define PL_LOGINFO_CODE_DSCVRY_SATA_INIT_TIMEOUT (0x00100000)
108#define PL_LOGINFO_CODE_RESET (0x00110000)
109#define PL_LOGINFO_CODE_ABORT (0x00120000)
110#define PL_LOGINFO_CODE_IO_NOT_YET_EXECUTED (0x00130000)
111#define PL_LOGINFO_CODE_IO_EXECUTED (0x00140000)
112#define PL_LOGINFO_SUB_CODE_OPEN_FAILURE (0x00000100)
113#define PL_LOGINFO_SUB_CODE_INVALID_SGL (0x00000200)
114#define PL_LOGINFO_SUB_CODE_WRONG_REL_OFF_OR_FRAME_LENGTH (0x00000300)
115#define PL_LOGINFO_SUB_CODE_FRAME_XFER_ERROR (0x00000400)
116#define PL_LOGINFO_SUB_CODE_TX_FM_CONNECTED_LOW (0x00000500)
117#define PL_LOGINFO_SUB_CODE_SATA_NON_NCQ_RW_ERR_BIT_SET (0x00000600)
118#define PL_LOGINFO_SUB_CODE_SATA_READ_LOG_RECEIVE_DATA_ERR (0x00000700)
119#define PL_LOGINFO_SUB_CODE_SATA_NCQ_FAIL_ALL_CMDS_AFTR_ERR (0x00000800)
120#define PL_LOGINFO_SUB_CODE_SATA_ERR_IN_RCV_SET_DEV_BIT_FIS (0x00000900)
121#define PL_LOGINFO_SUB_CODE_RX_FM_INVALID_MESSAGE (0x00000A00)
122#define PL_LOGINFO_SUB_CODE_RX_CTX_MESSAGE_VALID_ERROR (0x00000B00)
123#define PL_LOGINFO_SUB_CODE_RX_FM_CURRENT_FRAME_ERROR (0x00000C00)
124#define PL_LOGINFO_SUB_CODE_SATA_LINK_DOWN (0x00000D00)
125#define PL_LOGINFO_SUB_CODE_DISCOVERY_SATA_INIT_W_IOS (0x00000E00)
126#define PL_LOGINFO_SUB_CODE_DSCVRY_SATA_INIT_TIMEOUT (0x00001000)
127
128
129#define PL_LOGINFO_CODE_ENCL_MGMT_SMP_FRAME_FAILURE (0x00200000) /* Can't get SMP Frame */
130#define PL_LOGINFO_CODE_ENCL_MGMT_SMP_READ_ERROR (0x00200001) /* Error occured on SMP Read */
131#define PL_LOGINFO_CODE_ENCL_MGMT_SMP_WRITE_ERROR (0x00200002) /* Error occured on SMP Write */
132#define PL_LOGINFO_CODE_ENCL_MGMT_NOT_SUPPORTED_ON_ENCL (0x00200004) /* Encl Mgmt services not available for this WWID */
133#define PL_LOGINFO_CODE_ENCL_MGMT_ADDR_MODE_NOT_SUPPORTED (0x00200005) /* Address Mode not suppored */
134#define PL_LOGINFO_CODE_ENCL_MGMT_BAD_SLOT_NUM (0x00200006) /* Invalid Slot Number in SEP Msg */
135#define PL_LOGINFO_CODE_ENCL_MGMT_SGPIO_NOT_PRESENT (0x00200007) /* SGPIO not present/enabled */
136
137#define PL_LOGINFO_DA_SEP_NOT_PRESENT (0x00200100) /* SEP not present when msg received */
138#define PL_LOGINFO_DA_SEP_SINGLE_THREAD_ERROR (0x00200101) /* Can only accept 1 msg at a time */
139#define PL_LOGINFO_DA_SEP_ISTWI_INTR_IN_IDLE_STATE (0x00200102) /* ISTWI interrupt recvd. while IDLE */
140#define PL_LOGINFO_DA_SEP_RECEIVED_NACK_FROM_SLAVE (0x00200103) /* SEP NACK'd, it is busy */
141#define PL_LOGINFO_DA_SEP_BAD_STATUS_HDR_CHKSUM (0x00200104) /* SEP stopped or sent bad chksum in Hdr */
142#define PL_LOGINFO_DA_SEP_UNSUPPORTED_SCSI_STATUS_1 (0x00200105) /* SEP returned unknown scsi status */
143#define PL_LOGINFO_DA_SEP_UNSUPPORTED_SCSI_STATUS_2 (0x00200106) /* SEP returned unknown scsi status */
144#define PL_LOGINFO_DA_SEP_CHKSUM_ERROR_AFTER_STOP (0x00200107) /* SEP returned bad chksum after STOP */
145#define PL_LOGINFO_DA_SEP_CHKSUM_ERROR_AFTER_STOP_GETDATA (0x00200108) /* SEP returned bad chksum after STOP while gettin data*/
146
147
148/****************************************************************************/
149/* IR LOGINFO_CODE defines, valid if IOC_LOGINFO_ORIGINATOR = IR */
150/****************************************************************************/
151#define IR_LOGINFO_CODE_UNUSED1 (0x00010000)
152#define IR_LOGINFO_CODE_UNUSED2 (0x00020000)
153
154/****************************************************************************/
155/* Defines for convienence */
156/****************************************************************************/
157#define IOC_LOGINFO_PREFIX_IOP ((MPI_IOCLOGINFO_TYPE_SAS << MPI_IOCLOGINFO_TYPE_SHIFT) | IOC_LOGINFO_ORIGINATOR_IOP)
158#define IOC_LOGINFO_PREFIX_PL ((MPI_IOCLOGINFO_TYPE_SAS << MPI_IOCLOGINFO_TYPE_SHIFT) | IOC_LOGINFO_ORIGINATOR_PL)
159#define IOC_LOGINFO_PREFIX_IR ((MPI_IOCLOGINFO_TYPE_SAS << MPI_IOCLOGINFO_TYPE_SHIFT) | IOC_LOGINFO_ORIGINATOR_IR)
160
161#endif /* end of file */
162
diff --git a/drivers/message/fusion/lsi/mpi_sas.h b/drivers/message/fusion/lsi/mpi_sas.h
index 230fa69b5353..70514867bddf 100644
--- a/drivers/message/fusion/lsi/mpi_sas.h
+++ b/drivers/message/fusion/lsi/mpi_sas.h
@@ -6,7 +6,7 @@
6 * Title: MPI Serial Attached SCSI structures and definitions 6 * Title: MPI Serial Attached SCSI structures and definitions
7 * Creation Date: August 19, 2004 7 * Creation Date: August 19, 2004
8 * 8 *
9 * mpi_sas.h Version: 01.05.01 9 * mpi_sas.h Version: 01.05.02
10 * 10 *
11 * Version History 11 * Version History
12 * --------------- 12 * ---------------
@@ -14,6 +14,9 @@
14 * Date Version Description 14 * Date Version Description
15 * -------- -------- ------------------------------------------------------ 15 * -------- -------- ------------------------------------------------------
16 * 08-19-04 01.05.01 Original release. 16 * 08-19-04 01.05.01 Original release.
17 * 08-30-05 01.05.02 Added DeviceInfo bit for SEP.
18 * Added PrimFlags and Primitive field to SAS IO Unit
19 * Control request, and added a new operation code.
17 * -------------------------------------------------------------------------- 20 * --------------------------------------------------------------------------
18 */ 21 */
19 22
@@ -51,6 +54,7 @@
51 * Values for the SAS DeviceInfo field used in SAS Device Status Change Event 54 * Values for the SAS DeviceInfo field used in SAS Device Status Change Event
52 * data and SAS IO Unit Configuration pages. 55 * data and SAS IO Unit Configuration pages.
53 */ 56 */
57#define MPI_SAS_DEVICE_INFO_SEP (0x00004000)
54#define MPI_SAS_DEVICE_INFO_ATAPI_DEVICE (0x00002000) 58#define MPI_SAS_DEVICE_INFO_ATAPI_DEVICE (0x00002000)
55#define MPI_SAS_DEVICE_INFO_LSI_DEVICE (0x00001000) 59#define MPI_SAS_DEVICE_INFO_LSI_DEVICE (0x00001000)
56#define MPI_SAS_DEVICE_INFO_DIRECT_ATTACH (0x00000800) 60#define MPI_SAS_DEVICE_INFO_DIRECT_ATTACH (0x00000800)
@@ -212,20 +216,26 @@ typedef struct _MSG_SAS_IOUNIT_CONTROL_REQUEST
212 U8 TargetID; /* 0Ch */ 216 U8 TargetID; /* 0Ch */
213 U8 Bus; /* 0Dh */ 217 U8 Bus; /* 0Dh */
214 U8 PhyNum; /* 0Eh */ 218 U8 PhyNum; /* 0Eh */
215 U8 Reserved4; /* 0Fh */ 219 U8 PrimFlags; /* 0Fh */
216 U32 Reserved5; /* 10h */ 220 U32 Primitive; /* 10h */
217 U64 SASAddress; /* 14h */ 221 U64 SASAddress; /* 14h */
218 U32 Reserved6; /* 1Ch */ 222 U32 Reserved4; /* 1Ch */
219} MSG_SAS_IOUNIT_CONTROL_REQUEST, MPI_POINTER PTR_MSG_SAS_IOUNIT_CONTROL_REQUEST, 223} MSG_SAS_IOUNIT_CONTROL_REQUEST, MPI_POINTER PTR_MSG_SAS_IOUNIT_CONTROL_REQUEST,
220 SasIoUnitControlRequest_t, MPI_POINTER pSasIoUnitControlRequest_t; 224 SasIoUnitControlRequest_t, MPI_POINTER pSasIoUnitControlRequest_t;
221 225
222/* values for the Operation field */ 226/* values for the Operation field */
223#define MPI_SAS_OP_CLEAR_NOT_PRESENT (0x01) 227#define MPI_SAS_OP_CLEAR_NOT_PRESENT (0x01)
224#define MPI_SAS_OP_CLEAR_ALL_PERSISTENT (0x02) 228#define MPI_SAS_OP_CLEAR_ALL_PERSISTENT (0x02)
225#define MPI_SAS_OP_PHY_LINK_RESET (0x06) 229#define MPI_SAS_OP_PHY_LINK_RESET (0x06)
226#define MPI_SAS_OP_PHY_HARD_RESET (0x07) 230#define MPI_SAS_OP_PHY_HARD_RESET (0x07)
227#define MPI_SAS_OP_PHY_CLEAR_ERROR_LOG (0x08) 231#define MPI_SAS_OP_PHY_CLEAR_ERROR_LOG (0x08)
228#define MPI_SAS_OP_MAP_CURRENT (0x09) 232#define MPI_SAS_OP_MAP_CURRENT (0x09)
233#define MPI_SAS_OP_SEND_PRIMITIVE (0x0A)
234
235/* values for the PrimFlags field */
236#define MPI_SAS_PRIMFLAGS_SINGLE (0x08)
237#define MPI_SAS_PRIMFLAGS_TRIPLE (0x02)
238#define MPI_SAS_PRIMFLAGS_REDUNDANT (0x01)
229 239
230 240
231/* SAS IO Unit Control Reply */ 241/* SAS IO Unit Control Reply */
diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index 537836068c49..d890b2b8a93e 100644
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -148,7 +148,6 @@ static int WaitForDoorbellAck(MPT_ADAPTER *ioc, int howlong, int sleepFlag);
148static int WaitForDoorbellInt(MPT_ADAPTER *ioc, int howlong, int sleepFlag); 148static int WaitForDoorbellInt(MPT_ADAPTER *ioc, int howlong, int sleepFlag);
149static int WaitForDoorbellReply(MPT_ADAPTER *ioc, int howlong, int sleepFlag); 149static int WaitForDoorbellReply(MPT_ADAPTER *ioc, int howlong, int sleepFlag);
150static int GetLanConfigPages(MPT_ADAPTER *ioc); 150static int GetLanConfigPages(MPT_ADAPTER *ioc);
151static int GetFcPortPage0(MPT_ADAPTER *ioc, int portnum);
152static int GetIoUnitPage2(MPT_ADAPTER *ioc); 151static int GetIoUnitPage2(MPT_ADAPTER *ioc);
153int mptbase_sas_persist_operation(MPT_ADAPTER *ioc, u8 persist_opcode); 152int mptbase_sas_persist_operation(MPT_ADAPTER *ioc, u8 persist_opcode);
154static int mpt_GetScsiPortSettings(MPT_ADAPTER *ioc, int portnum); 153static int mpt_GetScsiPortSettings(MPT_ADAPTER *ioc, int portnum);
@@ -1232,12 +1231,11 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1232 dprintk((KERN_INFO MYNAM 1231 dprintk((KERN_INFO MYNAM
1233 ": Not using 64 bit consistent mask\n")); 1232 ": Not using 64 bit consistent mask\n"));
1234 1233
1235 ioc = kmalloc(sizeof(MPT_ADAPTER), GFP_ATOMIC); 1234 ioc = kzalloc(sizeof(MPT_ADAPTER), GFP_ATOMIC);
1236 if (ioc == NULL) { 1235 if (ioc == NULL) {
1237 printk(KERN_ERR MYNAM ": ERROR - Insufficient memory to add adapter!\n"); 1236 printk(KERN_ERR MYNAM ": ERROR - Insufficient memory to add adapter!\n");
1238 return -ENOMEM; 1237 return -ENOMEM;
1239 } 1238 }
1240 memset(ioc, 0, sizeof(MPT_ADAPTER));
1241 ioc->alloc_total = sizeof(MPT_ADAPTER); 1239 ioc->alloc_total = sizeof(MPT_ADAPTER);
1242 ioc->req_sz = MPT_DEFAULT_FRAME_SIZE; /* avoid div by zero! */ 1240 ioc->req_sz = MPT_DEFAULT_FRAME_SIZE; /* avoid div by zero! */
1243 ioc->reply_sz = MPT_REPLY_FRAME_SIZE; 1241 ioc->reply_sz = MPT_REPLY_FRAME_SIZE;
@@ -1245,6 +1243,8 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1245 ioc->pcidev = pdev; 1243 ioc->pcidev = pdev;
1246 ioc->diagPending = 0; 1244 ioc->diagPending = 0;
1247 spin_lock_init(&ioc->diagLock); 1245 spin_lock_init(&ioc->diagLock);
1246 spin_lock_init(&ioc->fc_rescan_work_lock);
1247 spin_lock_init(&ioc->fc_rport_lock);
1248 spin_lock_init(&ioc->initializing_hba_lock); 1248 spin_lock_init(&ioc->initializing_hba_lock);
1249 1249
1250 /* Initialize the event logging. 1250 /* Initialize the event logging.
@@ -1268,6 +1268,10 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1268 */ 1268 */
1269 INIT_LIST_HEAD(&ioc->configQ); 1269 INIT_LIST_HEAD(&ioc->configQ);
1270 1270
1271 /* Initialize the fc rport list head.
1272 */
1273 INIT_LIST_HEAD(&ioc->fc_rports);
1274
1271 /* Find lookup slot. */ 1275 /* Find lookup slot. */
1272 INIT_LIST_HEAD(&ioc->list); 1276 INIT_LIST_HEAD(&ioc->list);
1273 ioc->id = mpt_ids++; 1277 ioc->id = mpt_ids++;
@@ -1374,6 +1378,10 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1374 ioc->bus_type = FC; 1378 ioc->bus_type = FC;
1375 ioc->errata_flag_1064 = 1; 1379 ioc->errata_flag_1064 = 1;
1376 } 1380 }
1381 else if (pdev->device == MPI_MANUFACTPAGE_DEVICEID_FC949E) {
1382 ioc->prod_name = "LSIFC949E";
1383 ioc->bus_type = FC;
1384 }
1377 else if (pdev->device == MPI_MANUFACTPAGE_DEVID_53C1030) { 1385 else if (pdev->device == MPI_MANUFACTPAGE_DEVID_53C1030) {
1378 ioc->prod_name = "LSI53C1030"; 1386 ioc->prod_name = "LSI53C1030";
1379 ioc->bus_type = SPI; 1387 ioc->bus_type = SPI;
@@ -1622,7 +1630,7 @@ mpt_resume(struct pci_dev *pdev)
1622 pci_enable_device(pdev); 1630 pci_enable_device(pdev);
1623 1631
1624 /* enable interrupts */ 1632 /* enable interrupts */
1625 CHIPREG_WRITE32(&ioc->chip->IntMask, ~(MPI_HIM_RIM)); 1633 CHIPREG_WRITE32(&ioc->chip->IntMask, MPI_HIM_DIM);
1626 ioc->active = 1; 1634 ioc->active = 1;
1627 1635
1628 /* F/W not running */ 1636 /* F/W not running */
@@ -1715,7 +1723,7 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
1715 /* (re)Enable alt-IOC! (reply interrupt, FreeQ) */ 1723 /* (re)Enable alt-IOC! (reply interrupt, FreeQ) */
1716 dprintk((KERN_INFO MYNAM ": alt-%s reply irq re-enabled\n", 1724 dprintk((KERN_INFO MYNAM ": alt-%s reply irq re-enabled\n",
1717 ioc->alt_ioc->name)); 1725 ioc->alt_ioc->name));
1718 CHIPREG_WRITE32(&ioc->alt_ioc->chip->IntMask, ~(MPI_HIM_RIM)); 1726 CHIPREG_WRITE32(&ioc->alt_ioc->chip->IntMask, MPI_HIM_DIM);
1719 ioc->alt_ioc->active = 1; 1727 ioc->alt_ioc->active = 1;
1720 } 1728 }
1721 1729
@@ -1831,7 +1839,7 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
1831 1839
1832 if (ret == 0) { 1840 if (ret == 0) {
1833 /* Enable! (reply interrupt) */ 1841 /* Enable! (reply interrupt) */
1834 CHIPREG_WRITE32(&ioc->chip->IntMask, ~(MPI_HIM_RIM)); 1842 CHIPREG_WRITE32(&ioc->chip->IntMask, MPI_HIM_DIM);
1835 ioc->active = 1; 1843 ioc->active = 1;
1836 } 1844 }
1837 1845
@@ -1839,7 +1847,7 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
1839 /* (re)Enable alt-IOC! (reply interrupt) */ 1847 /* (re)Enable alt-IOC! (reply interrupt) */
1840 dinitprintk((KERN_INFO MYNAM ": alt-%s reply irq re-enabled\n", 1848 dinitprintk((KERN_INFO MYNAM ": alt-%s reply irq re-enabled\n",
1841 ioc->alt_ioc->name)); 1849 ioc->alt_ioc->name));
1842 CHIPREG_WRITE32(&ioc->alt_ioc->chip->IntMask, ~(MPI_HIM_RIM)); 1850 CHIPREG_WRITE32(&ioc->alt_ioc->chip->IntMask, MPI_HIM_DIM);
1843 ioc->alt_ioc->active = 1; 1851 ioc->alt_ioc->active = 1;
1844 } 1852 }
1845 1853
@@ -1880,7 +1888,7 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
1880 * (FCPortPage0_t stuff) 1888 * (FCPortPage0_t stuff)
1881 */ 1889 */
1882 for (ii=0; ii < ioc->facts.NumberOfPorts; ii++) { 1890 for (ii=0; ii < ioc->facts.NumberOfPorts; ii++) {
1883 (void) GetFcPortPage0(ioc, ii); 1891 (void) mptbase_GetFcPortPage0(ioc, ii);
1884 } 1892 }
1885 1893
1886 if ((ioc->pfacts[0].ProtocolFlags & MPI_PORTFACTS_PROTOCOL_LAN) && 1894 if ((ioc->pfacts[0].ProtocolFlags & MPI_PORTFACTS_PROTOCOL_LAN) &&
@@ -4199,7 +4207,7 @@ GetLanConfigPages(MPT_ADAPTER *ioc)
4199 4207
4200/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 4208/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
4201/* 4209/*
4202 * GetFcPortPage0 - Fetch FCPort config Page0. 4210 * mptbase_GetFcPortPage0 - Fetch FCPort config Page0.
4203 * @ioc: Pointer to MPT_ADAPTER structure 4211 * @ioc: Pointer to MPT_ADAPTER structure
4204 * @portnum: IOC Port number 4212 * @portnum: IOC Port number
4205 * 4213 *
@@ -4209,8 +4217,8 @@ GetLanConfigPages(MPT_ADAPTER *ioc)
4209 * -EAGAIN if no msg frames currently available 4217 * -EAGAIN if no msg frames currently available
4210 * -EFAULT for non-successful reply or no reply (timeout) 4218 * -EFAULT for non-successful reply or no reply (timeout)
4211 */ 4219 */
4212static int 4220int
4213GetFcPortPage0(MPT_ADAPTER *ioc, int portnum) 4221mptbase_GetFcPortPage0(MPT_ADAPTER *ioc, int portnum)
4214{ 4222{
4215 ConfigPageHeader_t hdr; 4223 ConfigPageHeader_t hdr;
4216 CONFIGPARMS cfg; 4224 CONFIGPARMS cfg;
@@ -4220,6 +4228,8 @@ GetFcPortPage0(MPT_ADAPTER *ioc, int portnum)
4220 int data_sz; 4228 int data_sz;
4221 int copy_sz; 4229 int copy_sz;
4222 int rc; 4230 int rc;
4231 int count = 400;
4232
4223 4233
4224 /* Get FCPort Page 0 header */ 4234 /* Get FCPort Page 0 header */
4225 hdr.PageVersion = 0; 4235 hdr.PageVersion = 0;
@@ -4243,6 +4253,8 @@ GetFcPortPage0(MPT_ADAPTER *ioc, int portnum)
4243 rc = -ENOMEM; 4253 rc = -ENOMEM;
4244 ppage0_alloc = (FCPortPage0_t *) pci_alloc_consistent(ioc->pcidev, data_sz, &page0_dma); 4254 ppage0_alloc = (FCPortPage0_t *) pci_alloc_consistent(ioc->pcidev, data_sz, &page0_dma);
4245 if (ppage0_alloc) { 4255 if (ppage0_alloc) {
4256
4257 try_again:
4246 memset((u8 *)ppage0_alloc, 0, data_sz); 4258 memset((u8 *)ppage0_alloc, 0, data_sz);
4247 cfg.physAddr = page0_dma; 4259 cfg.physAddr = page0_dma;
4248 cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT; 4260 cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT;
@@ -4274,6 +4286,19 @@ GetFcPortPage0(MPT_ADAPTER *ioc, int portnum)
4274 pp0dest->DiscoveredPortsCount = le32_to_cpu(pp0dest->DiscoveredPortsCount); 4286 pp0dest->DiscoveredPortsCount = le32_to_cpu(pp0dest->DiscoveredPortsCount);
4275 pp0dest->MaxInitiators = le32_to_cpu(pp0dest->MaxInitiators); 4287 pp0dest->MaxInitiators = le32_to_cpu(pp0dest->MaxInitiators);
4276 4288
4289 /*
4290 * if still doing discovery,
4291 * hang loose a while until finished
4292 */
4293 if (pp0dest->PortState == MPI_FCPORTPAGE0_PORTSTATE_UNKNOWN) {
4294 if (count-- > 0) {
4295 msleep_interruptible(100);
4296 goto try_again;
4297 }
4298 printk(MYIOC_s_INFO_FMT "Firmware discovery not"
4299 " complete.\n",
4300 ioc->name);
4301 }
4277 } 4302 }
4278 4303
4279 pci_free_consistent(ioc->pcidev, data_sz, (u8 *) ppage0_alloc, page0_dma); 4304 pci_free_consistent(ioc->pcidev, data_sz, (u8 *) ppage0_alloc, page0_dma);
@@ -6358,6 +6383,7 @@ EXPORT_SYMBOL(mpt_alloc_fw_memory);
6358EXPORT_SYMBOL(mpt_free_fw_memory); 6383EXPORT_SYMBOL(mpt_free_fw_memory);
6359EXPORT_SYMBOL(mptbase_sas_persist_operation); 6384EXPORT_SYMBOL(mptbase_sas_persist_operation);
6360EXPORT_SYMBOL(mpt_alt_ioc_wait); 6385EXPORT_SYMBOL(mpt_alt_ioc_wait);
6386EXPORT_SYMBOL(mptbase_GetFcPortPage0);
6361 6387
6362 6388
6363/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 6389/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
diff --git a/drivers/message/fusion/mptbase.h b/drivers/message/fusion/mptbase.h
index 6c48d1f54ac9..47053ac65068 100644
--- a/drivers/message/fusion/mptbase.h
+++ b/drivers/message/fusion/mptbase.h
@@ -76,8 +76,8 @@
76#define COPYRIGHT "Copyright (c) 1999-2005 " MODULEAUTHOR 76#define COPYRIGHT "Copyright (c) 1999-2005 " MODULEAUTHOR
77#endif 77#endif
78 78
79#define MPT_LINUX_VERSION_COMMON "3.03.05" 79#define MPT_LINUX_VERSION_COMMON "3.03.06"
80#define MPT_LINUX_PACKAGE_NAME "@(#)mptlinux-3.03.05" 80#define MPT_LINUX_PACKAGE_NAME "@(#)mptlinux-3.03.06"
81#define WHAT_MAGIC_STRING "@" "(" "#" ")" 81#define WHAT_MAGIC_STRING "@" "(" "#" ")"
82 82
83#define show_mptmod_ver(s,ver) \ 83#define show_mptmod_ver(s,ver) \
@@ -413,7 +413,7 @@ typedef struct _MPT_IOCTL {
413 u8 status; /* current command status */ 413 u8 status; /* current command status */
414 u8 reset; /* 1 if bus reset allowed */ 414 u8 reset; /* 1 if bus reset allowed */
415 u8 target; /* target for reset */ 415 u8 target; /* target for reset */
416 struct semaphore sem_ioc; 416 struct mutex ioctl_mutex;
417} MPT_IOCTL; 417} MPT_IOCTL;
418 418
419#define MPT_SAS_MGMT_STATUS_RF_VALID 0x02 /* The Reply Frame is VALID */ 419#define MPT_SAS_MGMT_STATUS_RF_VALID 0x02 /* The Reply Frame is VALID */
@@ -421,7 +421,7 @@ typedef struct _MPT_IOCTL {
421#define MPT_SAS_MGMT_STATUS_TM_FAILED 0x40 /* User TM request failed */ 421#define MPT_SAS_MGMT_STATUS_TM_FAILED 0x40 /* User TM request failed */
422 422
423typedef struct _MPT_SAS_MGMT { 423typedef struct _MPT_SAS_MGMT {
424 struct semaphore mutex; 424 struct mutex mutex;
425 struct completion done; 425 struct completion done;
426 u8 reply[MPT_DEFAULT_FRAME_SIZE]; /* reply frame data */ 426 u8 reply[MPT_DEFAULT_FRAME_SIZE]; /* reply frame data */
427 u8 status; /* current command status */ 427 u8 status; /* current command status */
@@ -499,6 +499,22 @@ typedef struct _RaidCfgData {
499 int isRaid; /* bit field, 1 if RAID */ 499 int isRaid; /* bit field, 1 if RAID */
500}RaidCfgData; 500}RaidCfgData;
501 501
502#define MPT_RPORT_INFO_FLAGS_REGISTERED 0x01 /* rport registered */
503#define MPT_RPORT_INFO_FLAGS_MISSING 0x02 /* missing from DevPage0 scan */
504#define MPT_RPORT_INFO_FLAGS_MAPPED_VDEV 0x04 /* target mapped in vdev */
505
506/*
507 * data allocated for each fc rport device
508 */
509struct mptfc_rport_info
510{
511 struct list_head list;
512 struct fc_rport *rport;
513 VirtDevice *vdev;
514 FCDevicePage0_t pg0;
515 u8 flags;
516};
517
502/* 518/*
503 * Adapter Structure - pci_dev specific. Maximum: MPT_MAX_ADAPTERS 519 * Adapter Structure - pci_dev specific. Maximum: MPT_MAX_ADAPTERS
504 */ 520 */
@@ -612,7 +628,16 @@ typedef struct _MPT_ADAPTER
612 struct list_head list; 628 struct list_head list;
613 struct net_device *netdev; 629 struct net_device *netdev;
614 struct list_head sas_topology; 630 struct list_head sas_topology;
631 struct mutex sas_topology_mutex;
615 MPT_SAS_MGMT sas_mgmt; 632 MPT_SAS_MGMT sas_mgmt;
633 int num_ports;
634
635 struct list_head fc_rports;
636 spinlock_t fc_rport_lock; /* list and ri flags */
637 spinlock_t fc_rescan_work_lock;
638 int fc_rescan_work_count;
639 struct work_struct fc_rescan_work;
640
616} MPT_ADAPTER; 641} MPT_ADAPTER;
617 642
618/* 643/*
@@ -999,6 +1024,7 @@ extern void mpt_free_fw_memory(MPT_ADAPTER *ioc);
999extern int mpt_findImVolumes(MPT_ADAPTER *ioc); 1024extern int mpt_findImVolumes(MPT_ADAPTER *ioc);
1000extern int mpt_read_ioc_pg_3(MPT_ADAPTER *ioc); 1025extern int mpt_read_ioc_pg_3(MPT_ADAPTER *ioc);
1001extern int mptbase_sas_persist_operation(MPT_ADAPTER *ioc, u8 persist_opcode); 1026extern int mptbase_sas_persist_operation(MPT_ADAPTER *ioc, u8 persist_opcode);
1027extern int mptbase_GetFcPortPage0(MPT_ADAPTER *ioc, int portnum);
1002extern int mpt_alt_ioc_wait(MPT_ADAPTER *ioc); 1028extern int mpt_alt_ioc_wait(MPT_ADAPTER *ioc);
1003 1029
1004/* 1030/*
diff --git a/drivers/message/fusion/mptctl.c b/drivers/message/fusion/mptctl.c
index 7c340240a50e..bdf709987982 100644
--- a/drivers/message/fusion/mptctl.c
+++ b/drivers/message/fusion/mptctl.c
@@ -177,10 +177,10 @@ mptctl_syscall_down(MPT_ADAPTER *ioc, int nonblock)
177 dctlprintk((KERN_INFO MYNAM "::mptctl_syscall_down(%p,%d) called\n", ioc, nonblock)); 177 dctlprintk((KERN_INFO MYNAM "::mptctl_syscall_down(%p,%d) called\n", ioc, nonblock));
178 178
179 if (nonblock) { 179 if (nonblock) {
180 if (down_trylock(&ioc->ioctl->sem_ioc)) 180 if (!mutex_trylock(&ioc->ioctl->ioctl_mutex))
181 rc = -EAGAIN; 181 rc = -EAGAIN;
182 } else { 182 } else {
183 if (down_interruptible(&ioc->ioctl->sem_ioc)) 183 if (mutex_lock_interruptible(&ioc->ioctl->ioctl_mutex))
184 rc = -ERESTARTSYS; 184 rc = -ERESTARTSYS;
185 } 185 }
186 dctlprintk((KERN_INFO MYNAM "::mptctl_syscall_down return %d\n", rc)); 186 dctlprintk((KERN_INFO MYNAM "::mptctl_syscall_down return %d\n", rc));
@@ -557,7 +557,7 @@ __mptctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
557 else 557 else
558 ret = -EINVAL; 558 ret = -EINVAL;
559 559
560 up(&iocp->ioctl->sem_ioc); 560 mutex_unlock(&iocp->ioctl->ioctl_mutex);
561 561
562 return ret; 562 return ret;
563} 563}
@@ -2619,7 +2619,7 @@ compat_mptfwxfer_ioctl(struct file *filp, unsigned int cmd,
2619 2619
2620 ret = mptctl_do_fw_download(kfw.iocnum, kfw.bufp, kfw.fwlen); 2620 ret = mptctl_do_fw_download(kfw.iocnum, kfw.bufp, kfw.fwlen);
2621 2621
2622 up(&iocp->ioctl->sem_ioc); 2622 mutex_unlock(&iocp->ioctl->ioctl_mutex);
2623 2623
2624 return ret; 2624 return ret;
2625} 2625}
@@ -2673,7 +2673,7 @@ compat_mpt_command(struct file *filp, unsigned int cmd,
2673 */ 2673 */
2674 ret = mptctl_do_mpt_command (karg, &uarg->MF); 2674 ret = mptctl_do_mpt_command (karg, &uarg->MF);
2675 2675
2676 up(&iocp->ioctl->sem_ioc); 2676 mutex_unlock(&iocp->ioctl->ioctl_mutex);
2677 2677
2678 return ret; 2678 return ret;
2679} 2679}
@@ -2743,7 +2743,7 @@ mptctl_probe(struct pci_dev *pdev, const struct pci_device_id *id)
2743 memset(mem, 0, sz); 2743 memset(mem, 0, sz);
2744 ioc->ioctl = (MPT_IOCTL *) mem; 2744 ioc->ioctl = (MPT_IOCTL *) mem;
2745 ioc->ioctl->ioc = ioc; 2745 ioc->ioctl->ioc = ioc;
2746 sema_init(&ioc->ioctl->sem_ioc, 1); 2746 mutex_init(&ioc->ioctl->ioctl_mutex);
2747 return 0; 2747 return 0;
2748 2748
2749out_fail: 2749out_fail:
diff --git a/drivers/message/fusion/mptfc.c b/drivers/message/fusion/mptfc.c
index ba61e1828858..b102c7666d0e 100644
--- a/drivers/message/fusion/mptfc.c
+++ b/drivers/message/fusion/mptfc.c
@@ -55,12 +55,14 @@
55#include <linux/reboot.h> /* notifier code */ 55#include <linux/reboot.h> /* notifier code */
56#include <linux/sched.h> 56#include <linux/sched.h>
57#include <linux/workqueue.h> 57#include <linux/workqueue.h>
58#include <linux/sort.h>
58 59
59#include <scsi/scsi.h> 60#include <scsi/scsi.h>
60#include <scsi/scsi_cmnd.h> 61#include <scsi/scsi_cmnd.h>
61#include <scsi/scsi_device.h> 62#include <scsi/scsi_device.h>
62#include <scsi/scsi_host.h> 63#include <scsi/scsi_host.h>
63#include <scsi/scsi_tcq.h> 64#include <scsi/scsi_tcq.h>
65#include <scsi/scsi_transport_fc.h>
64 66
65#include "mptbase.h" 67#include "mptbase.h"
66#include "mptscsih.h" 68#include "mptscsih.h"
@@ -79,19 +81,34 @@ static int mpt_pq_filter = 0;
79module_param(mpt_pq_filter, int, 0); 81module_param(mpt_pq_filter, int, 0);
80MODULE_PARM_DESC(mpt_pq_filter, " Enable peripheral qualifier filter: enable=1 (default=0)"); 82MODULE_PARM_DESC(mpt_pq_filter, " Enable peripheral qualifier filter: enable=1 (default=0)");
81 83
84#define MPTFC_DEV_LOSS_TMO (60)
85static int mptfc_dev_loss_tmo = MPTFC_DEV_LOSS_TMO; /* reasonable default */
86module_param(mptfc_dev_loss_tmo, int, 0);
87MODULE_PARM_DESC(mptfc_dev_loss_tmo, " Initial time the driver programs the "
88 " transport to wait for an rport to "
89 " return following a device loss event."
90 " Default=60.");
91
82static int mptfcDoneCtx = -1; 92static int mptfcDoneCtx = -1;
83static int mptfcTaskCtx = -1; 93static int mptfcTaskCtx = -1;
84static int mptfcInternalCtx = -1; /* Used only for internal commands */ 94static int mptfcInternalCtx = -1; /* Used only for internal commands */
85 95
96int mptfc_slave_alloc(struct scsi_device *device);
97static int mptfc_qcmd(struct scsi_cmnd *SCpnt,
98 void (*done)(struct scsi_cmnd *));
99
100static void mptfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout);
101static void __devexit mptfc_remove(struct pci_dev *pdev);
102
86static struct scsi_host_template mptfc_driver_template = { 103static struct scsi_host_template mptfc_driver_template = {
87 .module = THIS_MODULE, 104 .module = THIS_MODULE,
88 .proc_name = "mptfc", 105 .proc_name = "mptfc",
89 .proc_info = mptscsih_proc_info, 106 .proc_info = mptscsih_proc_info,
90 .name = "MPT FC Host", 107 .name = "MPT FC Host",
91 .info = mptscsih_info, 108 .info = mptscsih_info,
92 .queuecommand = mptscsih_qcmd, 109 .queuecommand = mptfc_qcmd,
93 .target_alloc = mptscsih_target_alloc, 110 .target_alloc = mptscsih_target_alloc,
94 .slave_alloc = mptscsih_slave_alloc, 111 .slave_alloc = mptfc_slave_alloc,
95 .slave_configure = mptscsih_slave_configure, 112 .slave_configure = mptscsih_slave_configure,
96 .target_destroy = mptscsih_target_destroy, 113 .target_destroy = mptscsih_target_destroy,
97 .slave_destroy = mptscsih_slave_destroy, 114 .slave_destroy = mptscsih_slave_destroy,
@@ -128,19 +145,478 @@ static struct pci_device_id mptfc_pci_table[] = {
128 PCI_ANY_ID, PCI_ANY_ID }, 145 PCI_ANY_ID, PCI_ANY_ID },
129 { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_FC949X, 146 { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_FC949X,
130 PCI_ANY_ID, PCI_ANY_ID }, 147 PCI_ANY_ID, PCI_ANY_ID },
148 { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_FC949ES,
149 PCI_ANY_ID, PCI_ANY_ID },
131 {0} /* Terminating entry */ 150 {0} /* Terminating entry */
132}; 151};
133MODULE_DEVICE_TABLE(pci, mptfc_pci_table); 152MODULE_DEVICE_TABLE(pci, mptfc_pci_table);
134 153
135/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 154static struct scsi_transport_template *mptfc_transport_template = NULL;
136/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 155
156struct fc_function_template mptfc_transport_functions = {
157 .dd_fcrport_size = 8,
158 .show_host_node_name = 1,
159 .show_host_port_name = 1,
160 .show_host_supported_classes = 1,
161 .show_host_port_id = 1,
162 .show_rport_supported_classes = 1,
163 .show_starget_node_name = 1,
164 .show_starget_port_name = 1,
165 .show_starget_port_id = 1,
166 .set_rport_dev_loss_tmo = mptfc_set_rport_loss_tmo,
167 .show_rport_dev_loss_tmo = 1,
168
169};
170
171/* FIXME! values controlling firmware RESCAN event
172 * need to be set low to allow dev_loss_tmo to
173 * work as expected. Currently, firmware doesn't
174 * notify driver of RESCAN event until some number
175 * of seconds elapse. This value can be set via
176 * lsiutil.
177 */
178static void
179mptfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout)
180{
181 if (timeout > 0)
182 rport->dev_loss_tmo = timeout;
183 else
184 rport->dev_loss_tmo = mptfc_dev_loss_tmo;
185}
186
187static int
188mptfc_FcDevPage0_cmp_func(const void *a, const void *b)
189{
190 FCDevicePage0_t **aa = (FCDevicePage0_t **)a;
191 FCDevicePage0_t **bb = (FCDevicePage0_t **)b;
192
193 if ((*aa)->CurrentBus == (*bb)->CurrentBus) {
194 if ((*aa)->CurrentTargetID == (*bb)->CurrentTargetID)
195 return 0;
196 if ((*aa)->CurrentTargetID < (*bb)->CurrentTargetID)
197 return -1;
198 return 1;
199 }
200 if ((*aa)->CurrentBus < (*bb)->CurrentBus)
201 return -1;
202 return 1;
203}
204
205static int
206mptfc_GetFcDevPage0(MPT_ADAPTER *ioc, int ioc_port,
207 void(*func)(MPT_ADAPTER *ioc,int channel, FCDevicePage0_t *arg))
208{
209 ConfigPageHeader_t hdr;
210 CONFIGPARMS cfg;
211 FCDevicePage0_t *ppage0_alloc, *fc;
212 dma_addr_t page0_dma;
213 int data_sz;
214 int ii;
215
216 FCDevicePage0_t *p0_array=NULL, *p_p0;
217 FCDevicePage0_t **pp0_array=NULL, **p_pp0;
218
219 int rc = -ENOMEM;
220 U32 port_id = 0xffffff;
221 int num_targ = 0;
222 int max_bus = ioc->facts.MaxBuses;
223 int max_targ = ioc->facts.MaxDevices;
224
225 if (max_bus == 0 || max_targ == 0)
226 goto out;
227
228 data_sz = sizeof(FCDevicePage0_t) * max_bus * max_targ;
229 p_p0 = p0_array = kzalloc(data_sz, GFP_KERNEL);
230 if (!p0_array)
231 goto out;
232
233 data_sz = sizeof(FCDevicePage0_t *) * max_bus * max_targ;
234 p_pp0 = pp0_array = kzalloc(data_sz, GFP_KERNEL);
235 if (!pp0_array)
236 goto out;
237
238 do {
239 /* Get FC Device Page 0 header */
240 hdr.PageVersion = 0;
241 hdr.PageLength = 0;
242 hdr.PageNumber = 0;
243 hdr.PageType = MPI_CONFIG_PAGETYPE_FC_DEVICE;
244 cfg.cfghdr.hdr = &hdr;
245 cfg.physAddr = -1;
246 cfg.action = MPI_CONFIG_ACTION_PAGE_HEADER;
247 cfg.dir = 0;
248 cfg.pageAddr = port_id;
249 cfg.timeout = 0;
250
251 if ((rc = mpt_config(ioc, &cfg)) != 0)
252 break;
253
254 if (hdr.PageLength <= 0)
255 break;
256
257 data_sz = hdr.PageLength * 4;
258 ppage0_alloc = pci_alloc_consistent(ioc->pcidev, data_sz,
259 &page0_dma);
260 rc = -ENOMEM;
261 if (!ppage0_alloc)
262 break;
263
264 cfg.physAddr = page0_dma;
265 cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT;
266
267 if ((rc = mpt_config(ioc, &cfg)) == 0) {
268 ppage0_alloc->PortIdentifier =
269 le32_to_cpu(ppage0_alloc->PortIdentifier);
270
271 ppage0_alloc->WWNN.Low =
272 le32_to_cpu(ppage0_alloc->WWNN.Low);
273
274 ppage0_alloc->WWNN.High =
275 le32_to_cpu(ppage0_alloc->WWNN.High);
276
277 ppage0_alloc->WWPN.Low =
278 le32_to_cpu(ppage0_alloc->WWPN.Low);
279
280 ppage0_alloc->WWPN.High =
281 le32_to_cpu(ppage0_alloc->WWPN.High);
282
283 ppage0_alloc->BBCredit =
284 le16_to_cpu(ppage0_alloc->BBCredit);
285
286 ppage0_alloc->MaxRxFrameSize =
287 le16_to_cpu(ppage0_alloc->MaxRxFrameSize);
288
289 port_id = ppage0_alloc->PortIdentifier;
290 num_targ++;
291 *p_p0 = *ppage0_alloc; /* save data */
292 *p_pp0++ = p_p0++; /* save addr */
293 }
294 pci_free_consistent(ioc->pcidev, data_sz,
295 (u8 *) ppage0_alloc, page0_dma);
296 if (rc != 0)
297 break;
298
299 } while (port_id <= 0xff0000);
300
301 if (num_targ) {
302 /* sort array */
303 if (num_targ > 1)
304 sort (pp0_array, num_targ, sizeof(FCDevicePage0_t *),
305 mptfc_FcDevPage0_cmp_func, NULL);
306 /* call caller's func for each targ */
307 for (ii = 0; ii < num_targ; ii++) {
308 fc = *(pp0_array+ii);
309 func(ioc, ioc_port, fc);
310 }
311 }
312
313 out:
314 if (pp0_array)
315 kfree(pp0_array);
316 if (p0_array)
317 kfree(p0_array);
318 return rc;
319}
320
321static int
322mptfc_generate_rport_ids(FCDevicePage0_t *pg0, struct fc_rport_identifiers *rid)
323{
324 /* not currently usable */
325 if (pg0->Flags & (MPI_FC_DEVICE_PAGE0_FLAGS_PLOGI_INVALID |
326 MPI_FC_DEVICE_PAGE0_FLAGS_PRLI_INVALID))
327 return -1;
328
329 if (!(pg0->Flags & MPI_FC_DEVICE_PAGE0_FLAGS_TARGETID_BUS_VALID))
330 return -1;
331
332 if (!(pg0->Protocol & MPI_FC_DEVICE_PAGE0_PROT_FCP_TARGET))
333 return -1;
334
335 /*
336 * board data structure already normalized to platform endianness
337 * shifted to avoid unaligned access on 64 bit architecture
338 */
339 rid->node_name = ((u64)pg0->WWNN.High) << 32 | (u64)pg0->WWNN.Low;
340 rid->port_name = ((u64)pg0->WWPN.High) << 32 | (u64)pg0->WWPN.Low;
341 rid->port_id = pg0->PortIdentifier;
342 rid->roles = FC_RPORT_ROLE_UNKNOWN;
343 rid->roles |= FC_RPORT_ROLE_FCP_TARGET;
344 if (pg0->Protocol & MPI_FC_DEVICE_PAGE0_PROT_FCP_INITIATOR)
345 rid->roles |= FC_RPORT_ROLE_FCP_INITIATOR;
346
347 return 0;
348}
349
350static void
351mptfc_register_dev(MPT_ADAPTER *ioc, int channel, FCDevicePage0_t *pg0)
352{
353 struct fc_rport_identifiers rport_ids;
354 struct fc_rport *rport;
355 struct mptfc_rport_info *ri;
356 int match = 0;
357 u64 port_name;
358 unsigned long flags;
359
360 if (mptfc_generate_rport_ids(pg0, &rport_ids) < 0)
361 return;
362
363 /* scan list looking for a match */
364 spin_lock_irqsave(&ioc->fc_rport_lock, flags);
365 list_for_each_entry(ri, &ioc->fc_rports, list) {
366 port_name = (u64)ri->pg0.WWPN.High << 32 | (u64)ri->pg0.WWPN.Low;
367 if (port_name == rport_ids.port_name) { /* match */
368 list_move_tail(&ri->list, &ioc->fc_rports);
369 match = 1;
370 break;
371 }
372 }
373 if (!match) { /* allocate one */
374 spin_unlock_irqrestore(&ioc->fc_rport_lock, flags);
375 ri = kzalloc(sizeof(struct mptfc_rport_info), GFP_KERNEL);
376 if (!ri)
377 return;
378 spin_lock_irqsave(&ioc->fc_rport_lock, flags);
379 list_add_tail(&ri->list, &ioc->fc_rports);
380 }
381
382 ri->pg0 = *pg0; /* add/update pg0 data */
383 ri->flags &= ~MPT_RPORT_INFO_FLAGS_MISSING;
384
385 if (!(ri->flags & MPT_RPORT_INFO_FLAGS_REGISTERED)) {
386 ri->flags |= MPT_RPORT_INFO_FLAGS_REGISTERED;
387 spin_unlock_irqrestore(&ioc->fc_rport_lock, flags);
388 rport = fc_remote_port_add(ioc->sh,channel, &rport_ids);
389 spin_lock_irqsave(&ioc->fc_rport_lock, flags);
390 if (rport) {
391 if (*((struct mptfc_rport_info **)rport->dd_data) != ri) {
392 ri->flags &= ~MPT_RPORT_INFO_FLAGS_MAPPED_VDEV;
393 ri->vdev = NULL;
394 ri->rport = rport;
395 *((struct mptfc_rport_info **)rport->dd_data) = ri;
396 }
397 rport->dev_loss_tmo = mptfc_dev_loss_tmo;
398 /*
399 * if already mapped, remap here. If not mapped,
400 * slave_alloc will allocate vdev and map
401 */
402 if (ri->flags & MPT_RPORT_INFO_FLAGS_MAPPED_VDEV) {
403 ri->vdev->target_id = ri->pg0.CurrentTargetID;
404 ri->vdev->bus_id = ri->pg0.CurrentBus;
405 ri->vdev->vtarget->target_id = ri->vdev->target_id;
406 ri->vdev->vtarget->bus_id = ri->vdev->bus_id;
407 }
408 #ifdef MPT_DEBUG
409 printk ("mptfc_reg_dev.%d: %x, %llx / %llx, tid %d, "
410 "rport tid %d, tmo %d\n",
411 ioc->sh->host_no,
412 pg0->PortIdentifier,
413 pg0->WWNN,
414 pg0->WWPN,
415 pg0->CurrentTargetID,
416 ri->rport->scsi_target_id,
417 ri->rport->dev_loss_tmo);
418 #endif
419 } else {
420 list_del(&ri->list);
421 kfree(ri);
422 ri = NULL;
423 }
424 }
425 spin_unlock_irqrestore(&ioc->fc_rport_lock,flags);
426
427}
428
137/* 429/*
138 * mptfc_probe - Installs scsi devices per bus. 430 * OS entry point to allow host driver to alloc memory
139 * @pdev: Pointer to pci_dev structure 431 * for each scsi device. Called once per device the bus scan.
140 * 432 * Return non-zero if allocation fails.
141 * Returns 0 for success, non-zero for failure. 433 * Init memory once per LUN.
142 *
143 */ 434 */
435int
436mptfc_slave_alloc(struct scsi_device *sdev)
437{
438 MPT_SCSI_HOST *hd;
439 VirtTarget *vtarget;
440 VirtDevice *vdev;
441 struct scsi_target *starget;
442 struct fc_rport *rport;
443 struct mptfc_rport_info *ri;
444 unsigned long flags;
445
446
447 rport = starget_to_rport(scsi_target(sdev));
448
449 if (!rport || fc_remote_port_chkready(rport))
450 return -ENXIO;
451
452 hd = (MPT_SCSI_HOST *)sdev->host->hostdata;
453
454 vdev = kmalloc(sizeof(VirtDevice), GFP_KERNEL);
455 if (!vdev) {
456 printk(MYIOC_s_ERR_FMT "slave_alloc kmalloc(%zd) FAILED!\n",
457 hd->ioc->name, sizeof(VirtDevice));
458 return -ENOMEM;
459 }
460 memset(vdev, 0, sizeof(VirtDevice));
461
462 spin_lock_irqsave(&hd->ioc->fc_rport_lock,flags);
463
464 if (!(ri = *((struct mptfc_rport_info **)rport->dd_data))) {
465 spin_unlock_irqrestore(&hd->ioc->fc_rport_lock,flags);
466 kfree(vdev);
467 return -ENODEV;
468 }
469
470 sdev->hostdata = vdev;
471 starget = scsi_target(sdev);
472 vtarget = starget->hostdata;
473 if (vtarget->num_luns == 0) {
474 vtarget->tflags = MPT_TARGET_FLAGS_Q_YES |
475 MPT_TARGET_FLAGS_VALID_INQUIRY;
476 hd->Targets[sdev->id] = vtarget;
477 }
478
479 vtarget->target_id = vdev->target_id;
480 vtarget->bus_id = vdev->bus_id;
481
482 vdev->vtarget = vtarget;
483 vdev->ioc_id = hd->ioc->id;
484 vdev->lun = sdev->lun;
485 vdev->target_id = ri->pg0.CurrentTargetID;
486 vdev->bus_id = ri->pg0.CurrentBus;
487
488 ri->flags |= MPT_RPORT_INFO_FLAGS_MAPPED_VDEV;
489 ri->vdev = vdev;
490
491 spin_unlock_irqrestore(&hd->ioc->fc_rport_lock,flags);
492
493 vtarget->num_luns++;
494
495#ifdef MPT_DEBUG
496 printk ("mptfc_slv_alloc.%d: num_luns %d, sdev.id %d, "
497 "CurrentTargetID %d, %x %llx %llx\n",
498 sdev->host->host_no,
499 vtarget->num_luns,
500 sdev->id, ri->pg0.CurrentTargetID,
501 ri->pg0.PortIdentifier, ri->pg0.WWPN, ri->pg0.WWNN);
502#endif
503
504 return 0;
505}
506
507static int
508mptfc_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
509{
510 struct fc_rport *rport = starget_to_rport(scsi_target(SCpnt->device));
511 int err;
512
513 err = fc_remote_port_chkready(rport);
514 if (unlikely(err)) {
515 SCpnt->result = err;
516 done(SCpnt);
517 return 0;
518 }
519 return mptscsih_qcmd(SCpnt,done);
520}
521
522static void
523mptfc_init_host_attr(MPT_ADAPTER *ioc,int portnum)
524{
525 unsigned class = 0, cos = 0;
526
527 /* don't know what to do as only one scsi (fc) host was allocated */
528 if (portnum != 0)
529 return;
530
531 class = ioc->fc_port_page0[portnum].SupportedServiceClass;
532 if (class & MPI_FCPORTPAGE0_SUPPORT_CLASS_1)
533 cos |= FC_COS_CLASS1;
534 if (class & MPI_FCPORTPAGE0_SUPPORT_CLASS_2)
535 cos |= FC_COS_CLASS2;
536 if (class & MPI_FCPORTPAGE0_SUPPORT_CLASS_3)
537 cos |= FC_COS_CLASS3;
538
539 fc_host_node_name(ioc->sh) =
540 (u64)ioc->fc_port_page0[portnum].WWNN.High << 32
541 | (u64)ioc->fc_port_page0[portnum].WWNN.Low;
542
543 fc_host_port_name(ioc->sh) =
544 (u64)ioc->fc_port_page0[portnum].WWPN.High << 32
545 | (u64)ioc->fc_port_page0[portnum].WWPN.Low;
546
547 fc_host_port_id(ioc->sh) = ioc->fc_port_page0[portnum].PortIdentifier;
548
549 fc_host_supported_classes(ioc->sh) = cos;
550
551 fc_host_tgtid_bind_type(ioc->sh) = FC_TGTID_BIND_BY_WWPN;
552}
553
554static void
555mptfc_rescan_devices(void *arg)
556{
557 MPT_ADAPTER *ioc = (MPT_ADAPTER *)arg;
558 int ii;
559 int work_to_do;
560 unsigned long flags;
561 struct mptfc_rport_info *ri;
562
563 do {
564 /* start by tagging all ports as missing */
565 spin_lock_irqsave(&ioc->fc_rport_lock,flags);
566 list_for_each_entry(ri, &ioc->fc_rports, list) {
567 if (ri->flags & MPT_RPORT_INFO_FLAGS_REGISTERED) {
568 ri->flags |= MPT_RPORT_INFO_FLAGS_MISSING;
569 }
570 }
571 spin_unlock_irqrestore(&ioc->fc_rport_lock,flags);
572
573 /*
574 * now rescan devices known to adapter,
575 * will reregister existing rports
576 */
577 for (ii=0; ii < ioc->facts.NumberOfPorts; ii++) {
578 (void) mptbase_GetFcPortPage0(ioc, ii);
579 mptfc_init_host_attr(ioc,ii); /* refresh */
580 mptfc_GetFcDevPage0(ioc,ii,mptfc_register_dev);
581 }
582
583 /* delete devices still missing */
584 spin_lock_irqsave(&ioc->fc_rport_lock, flags);
585 list_for_each_entry(ri, &ioc->fc_rports, list) {
586 /* if newly missing, delete it */
587 if ((ri->flags & (MPT_RPORT_INFO_FLAGS_REGISTERED |
588 MPT_RPORT_INFO_FLAGS_MISSING))
589 == (MPT_RPORT_INFO_FLAGS_REGISTERED |
590 MPT_RPORT_INFO_FLAGS_MISSING)) {
591
592 ri->flags &= ~(MPT_RPORT_INFO_FLAGS_REGISTERED|
593 MPT_RPORT_INFO_FLAGS_MISSING);
594 fc_remote_port_delete(ri->rport);
595 /*
596 * remote port not really deleted 'cause
597 * binding is by WWPN and driver only
598 * registers FCP_TARGETs
599 */
600 #ifdef MPT_DEBUG
601 printk ("mptfc_rescan.%d: %llx deleted\n",
602 ioc->sh->host_no, ri->pg0.WWPN);
603 #endif
604 }
605 }
606 spin_unlock_irqrestore(&ioc->fc_rport_lock,flags);
607
608 /*
609 * allow multiple passes as target state
610 * might have changed during scan
611 */
612 spin_lock_irqsave(&ioc->fc_rescan_work_lock, flags);
613 if (ioc->fc_rescan_work_count > 2) /* only need one more */
614 ioc->fc_rescan_work_count = 2;
615 work_to_do = --ioc->fc_rescan_work_count;
616 spin_unlock_irqrestore(&ioc->fc_rescan_work_lock, flags);
617 } while (work_to_do);
618}
619
144static int 620static int
145mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id) 621mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id)
146{ 622{
@@ -148,17 +624,16 @@ mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id)
148 MPT_SCSI_HOST *hd; 624 MPT_SCSI_HOST *hd;
149 MPT_ADAPTER *ioc; 625 MPT_ADAPTER *ioc;
150 unsigned long flags; 626 unsigned long flags;
151 int sz, ii; 627 int ii;
152 int numSGE = 0; 628 int numSGE = 0;
153 int scale; 629 int scale;
154 int ioc_cap; 630 int ioc_cap;
155 u8 *mem;
156 int error=0; 631 int error=0;
157 int r; 632 int r;
158 633
159 if ((r = mpt_attach(pdev,id)) != 0) 634 if ((r = mpt_attach(pdev,id)) != 0)
160 return r; 635 return r;
161 636
162 ioc = pci_get_drvdata(pdev); 637 ioc = pci_get_drvdata(pdev);
163 ioc->DoneCtx = mptfcDoneCtx; 638 ioc->DoneCtx = mptfcDoneCtx;
164 ioc->TaskCtx = mptfcTaskCtx; 639 ioc->TaskCtx = mptfcTaskCtx;
@@ -194,7 +669,7 @@ mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id)
194 printk(MYIOC_s_WARN_FMT 669 printk(MYIOC_s_WARN_FMT
195 "Skipping ioc=%p because SCSI Initiator mode is NOT enabled!\n", 670 "Skipping ioc=%p because SCSI Initiator mode is NOT enabled!\n",
196 ioc->name, ioc); 671 ioc->name, ioc);
197 return 0; 672 return -ENODEV;
198 } 673 }
199 674
200 sh = scsi_host_alloc(&mptfc_driver_template, sizeof(MPT_SCSI_HOST)); 675 sh = scsi_host_alloc(&mptfc_driver_template, sizeof(MPT_SCSI_HOST));
@@ -207,6 +682,8 @@ mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id)
207 goto out_mptfc_probe; 682 goto out_mptfc_probe;
208 } 683 }
209 684
685 INIT_WORK(&ioc->fc_rescan_work, mptfc_rescan_devices,(void *)ioc);
686
210 spin_lock_irqsave(&ioc->FreeQlock, flags); 687 spin_lock_irqsave(&ioc->FreeQlock, flags);
211 688
212 /* Attach the SCSI Host to the IOC structure 689 /* Attach the SCSI Host to the IOC structure
@@ -268,36 +745,27 @@ mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id)
268 /* SCSI needs scsi_cmnd lookup table! 745 /* SCSI needs scsi_cmnd lookup table!
269 * (with size equal to req_depth*PtrSz!) 746 * (with size equal to req_depth*PtrSz!)
270 */ 747 */
271 sz = ioc->req_depth * sizeof(void *); 748 hd->ScsiLookup = kcalloc(ioc->req_depth, sizeof(void *), GFP_ATOMIC);
272 mem = kmalloc(sz, GFP_ATOMIC); 749 if (!hd->ScsiLookup) {
273 if (mem == NULL) {
274 error = -ENOMEM; 750 error = -ENOMEM;
275 goto out_mptfc_probe; 751 goto out_mptfc_probe;
276 } 752 }
277 753
278 memset(mem, 0, sz); 754 dprintk((MYIOC_s_INFO_FMT "ScsiLookup @ %p\n",
279 hd->ScsiLookup = (struct scsi_cmnd **) mem; 755 ioc->name, hd->ScsiLookup));
280
281 dprintk((MYIOC_s_INFO_FMT "ScsiLookup @ %p, sz=%d\n",
282 ioc->name, hd->ScsiLookup, sz));
283 756
284 /* Allocate memory for the device structures. 757 /* Allocate memory for the device structures.
285 * A non-Null pointer at an offset 758 * A non-Null pointer at an offset
286 * indicates a device exists. 759 * indicates a device exists.
287 * max_id = 1 + maximum id (hosts.h) 760 * max_id = 1 + maximum id (hosts.h)
288 */ 761 */
289 sz = sh->max_id * sizeof(void *); 762 hd->Targets = kcalloc(sh->max_id, sizeof(void *), GFP_ATOMIC);
290 mem = kmalloc(sz, GFP_ATOMIC); 763 if (!hd->Targets) {
291 if (mem == NULL) {
292 error = -ENOMEM; 764 error = -ENOMEM;
293 goto out_mptfc_probe; 765 goto out_mptfc_probe;
294 } 766 }
295 767
296 memset(mem, 0, sz); 768 dprintk((KERN_INFO " vdev @ %p\n", hd->Targets));
297 hd->Targets = (VirtTarget **) mem;
298
299 dprintk((KERN_INFO
300 " vdev @ %p, sz=%d\n", hd->Targets, sz));
301 769
302 /* Clear the TM flags 770 /* Clear the TM flags
303 */ 771 */
@@ -332,6 +800,7 @@ mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id)
332 hd->scandv_wait_done = 0; 800 hd->scandv_wait_done = 0;
333 hd->last_queue_full = 0; 801 hd->last_queue_full = 0;
334 802
803 sh->transportt = mptfc_transport_template;
335 error = scsi_add_host (sh, &ioc->pcidev->dev); 804 error = scsi_add_host (sh, &ioc->pcidev->dev);
336 if(error) { 805 if(error) {
337 dprintk((KERN_ERR MYNAM 806 dprintk((KERN_ERR MYNAM
@@ -339,7 +808,11 @@ mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id)
339 goto out_mptfc_probe; 808 goto out_mptfc_probe;
340 } 809 }
341 810
342 scsi_scan_host(sh); 811 for (ii=0; ii < ioc->facts.NumberOfPorts; ii++) {
812 mptfc_init_host_attr(ioc,ii);
813 mptfc_GetFcDevPage0(ioc,ii,mptfc_register_dev);
814 }
815
343 return 0; 816 return 0;
344 817
345out_mptfc_probe: 818out_mptfc_probe:
@@ -352,7 +825,7 @@ static struct pci_driver mptfc_driver = {
352 .name = "mptfc", 825 .name = "mptfc",
353 .id_table = mptfc_pci_table, 826 .id_table = mptfc_pci_table,
354 .probe = mptfc_probe, 827 .probe = mptfc_probe,
355 .remove = __devexit_p(mptscsih_remove), 828 .remove = __devexit_p(mptfc_remove),
356 .shutdown = mptscsih_shutdown, 829 .shutdown = mptscsih_shutdown,
357#ifdef CONFIG_PM 830#ifdef CONFIG_PM
358 .suspend = mptscsih_suspend, 831 .suspend = mptscsih_suspend,
@@ -370,9 +843,20 @@ static struct pci_driver mptfc_driver = {
370static int __init 843static int __init
371mptfc_init(void) 844mptfc_init(void)
372{ 845{
846 int error;
373 847
374 show_mptmod_ver(my_NAME, my_VERSION); 848 show_mptmod_ver(my_NAME, my_VERSION);
375 849
850 /* sanity check module parameter */
851 if (mptfc_dev_loss_tmo == 0)
852 mptfc_dev_loss_tmo = MPTFC_DEV_LOSS_TMO;
853
854 mptfc_transport_template =
855 fc_attach_transport(&mptfc_transport_functions);
856
857 if (!mptfc_transport_template)
858 return -ENODEV;
859
376 mptfcDoneCtx = mpt_register(mptscsih_io_done, MPTFC_DRIVER); 860 mptfcDoneCtx = mpt_register(mptscsih_io_done, MPTFC_DRIVER);
377 mptfcTaskCtx = mpt_register(mptscsih_taskmgmt_complete, MPTFC_DRIVER); 861 mptfcTaskCtx = mpt_register(mptscsih_taskmgmt_complete, MPTFC_DRIVER);
378 mptfcInternalCtx = mpt_register(mptscsih_scandv_complete, MPTFC_DRIVER); 862 mptfcInternalCtx = mpt_register(mptscsih_scandv_complete, MPTFC_DRIVER);
@@ -387,7 +871,33 @@ mptfc_init(void)
387 ": Registered for IOC reset notifications\n")); 871 ": Registered for IOC reset notifications\n"));
388 } 872 }
389 873
390 return pci_register_driver(&mptfc_driver); 874 error = pci_register_driver(&mptfc_driver);
875 if (error) {
876 fc_release_transport(mptfc_transport_template);
877 }
878
879 return error;
880}
881
882/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
883/**
884 * mptfc_remove - Removed fc infrastructure for devices
885 * @pdev: Pointer to pci_dev structure
886 *
887 */
888static void __devexit mptfc_remove(struct pci_dev *pdev)
889{
890 MPT_ADAPTER *ioc = pci_get_drvdata(pdev);
891 struct mptfc_rport_info *p, *n;
892
893 fc_remove_host(ioc->sh);
894
895 list_for_each_entry_safe(p, n, &ioc->fc_rports, list) {
896 list_del(&p->list);
897 kfree(p);
898 }
899
900 mptscsih_remove(pdev);
391} 901}
392 902
393/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 903/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
@@ -400,7 +910,8 @@ static void __exit
400mptfc_exit(void) 910mptfc_exit(void)
401{ 911{
402 pci_unregister_driver(&mptfc_driver); 912 pci_unregister_driver(&mptfc_driver);
403 913 fc_release_transport(mptfc_transport_template);
914
404 mpt_reset_deregister(mptfcDoneCtx); 915 mpt_reset_deregister(mptfcDoneCtx);
405 dprintk((KERN_INFO MYNAM 916 dprintk((KERN_INFO MYNAM
406 ": Deregistered for IOC reset notifications\n")); 917 ": Deregistered for IOC reset notifications\n"));
diff --git a/drivers/message/fusion/mptlan.c b/drivers/message/fusion/mptlan.c
index 014085d8ec85..0b1b72825ae2 100644
--- a/drivers/message/fusion/mptlan.c
+++ b/drivers/message/fusion/mptlan.c
@@ -411,14 +411,12 @@ mpt_lan_open(struct net_device *dev)
411 goto out; 411 goto out;
412 priv->mpt_txfidx_tail = -1; 412 priv->mpt_txfidx_tail = -1;
413 413
414 priv->SendCtl = kmalloc(priv->tx_max_out * sizeof(struct BufferControl), 414 priv->SendCtl = kcalloc(priv->tx_max_out, sizeof(struct BufferControl),
415 GFP_KERNEL); 415 GFP_KERNEL);
416 if (priv->SendCtl == NULL) 416 if (priv->SendCtl == NULL)
417 goto out_mpt_txfidx; 417 goto out_mpt_txfidx;
418 for (i = 0; i < priv->tx_max_out; i++) { 418 for (i = 0; i < priv->tx_max_out; i++)
419 memset(&priv->SendCtl[i], 0, sizeof(struct BufferControl));
420 priv->mpt_txfidx[++priv->mpt_txfidx_tail] = i; 419 priv->mpt_txfidx[++priv->mpt_txfidx_tail] = i;
421 }
422 420
423 dlprintk((KERN_INFO MYNAM "@lo: Finished initializing SendCtl\n")); 421 dlprintk((KERN_INFO MYNAM "@lo: Finished initializing SendCtl\n"));
424 422
@@ -428,15 +426,13 @@ mpt_lan_open(struct net_device *dev)
428 goto out_SendCtl; 426 goto out_SendCtl;
429 priv->mpt_rxfidx_tail = -1; 427 priv->mpt_rxfidx_tail = -1;
430 428
431 priv->RcvCtl = kmalloc(priv->max_buckets_out * 429 priv->RcvCtl = kcalloc(priv->max_buckets_out,
432 sizeof(struct BufferControl), 430 sizeof(struct BufferControl),
433 GFP_KERNEL); 431 GFP_KERNEL);
434 if (priv->RcvCtl == NULL) 432 if (priv->RcvCtl == NULL)
435 goto out_mpt_rxfidx; 433 goto out_mpt_rxfidx;
436 for (i = 0; i < priv->max_buckets_out; i++) { 434 for (i = 0; i < priv->max_buckets_out; i++)
437 memset(&priv->RcvCtl[i], 0, sizeof(struct BufferControl));
438 priv->mpt_rxfidx[++priv->mpt_rxfidx_tail] = i; 435 priv->mpt_rxfidx[++priv->mpt_rxfidx_tail] = i;
439 }
440 436
441/**/ dlprintk((KERN_INFO MYNAM "/lo: txfidx contains - ")); 437/**/ dlprintk((KERN_INFO MYNAM "/lo: txfidx contains - "));
442/**/ for (i = 0; i < priv->tx_max_out; i++) 438/**/ for (i = 0; i < priv->tx_max_out; i++)
diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
index 17e9757e728b..5a06d8d8694e 100644
--- a/drivers/message/fusion/mptsas.c
+++ b/drivers/message/fusion/mptsas.c
@@ -5,7 +5,7 @@
5 * 5 *
6 * Copyright (c) 1999-2005 LSI Logic Corporation 6 * Copyright (c) 1999-2005 LSI Logic Corporation
7 * (mailto:mpt_linux_developer@lsil.com) 7 * (mailto:mpt_linux_developer@lsil.com)
8 * Copyright (c) 2005 Dell 8 * Copyright (c) 2005-2006 Dell
9 */ 9 */
10/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 10/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
11/* 11/*
@@ -86,6 +86,24 @@ static int mptsasInternalCtx = -1; /* Used only for internal commands */
86static int mptsasMgmtCtx = -1; 86static int mptsasMgmtCtx = -1;
87 87
88 88
89enum mptsas_hotplug_action {
90 MPTSAS_ADD_DEVICE,
91 MPTSAS_DEL_DEVICE,
92};
93
94struct mptsas_hotplug_event {
95 struct work_struct work;
96 MPT_ADAPTER *ioc;
97 enum mptsas_hotplug_action event_type;
98 u64 sas_address;
99 u32 channel;
100 u32 id;
101 u32 device_info;
102 u16 handle;
103 u16 parent_handle;
104 u8 phy_id;
105};
106
89/* 107/*
90 * SAS topology structures 108 * SAS topology structures
91 * 109 *
@@ -99,8 +117,8 @@ struct mptsas_devinfo {
99 u8 phy_id; /* phy number of parent device */ 117 u8 phy_id; /* phy number of parent device */
100 u8 port_id; /* sas physical port this device 118 u8 port_id; /* sas physical port this device
101 is assoc'd with */ 119 is assoc'd with */
102 u8 target; /* logical target id of this device */ 120 u8 id; /* logical target id of this device */
103 u8 bus; /* logical bus number of this device */ 121 u8 channel; /* logical bus number of this device */
104 u64 sas_address; /* WWN of this device, 122 u64 sas_address; /* WWN of this device,
105 SATA is assigned by HBA,expander */ 123 SATA is assigned by HBA,expander */
106 u32 device_info; /* bitfield detailed info about this device */ 124 u32 device_info; /* bitfield detailed info about this device */
@@ -114,6 +132,7 @@ struct mptsas_phyinfo {
114 u8 programmed_link_rate; /* programmed max/min phy link rate */ 132 u8 programmed_link_rate; /* programmed max/min phy link rate */
115 struct mptsas_devinfo identify; /* point to phy device info */ 133 struct mptsas_devinfo identify; /* point to phy device info */
116 struct mptsas_devinfo attached; /* point to attached device info */ 134 struct mptsas_devinfo attached; /* point to attached device info */
135 struct sas_phy *phy;
117 struct sas_rphy *rphy; 136 struct sas_rphy *rphy;
118}; 137};
119 138
@@ -239,13 +258,12 @@ mptsas_slave_alloc(struct scsi_device *sdev)
239 struct scsi_target *starget; 258 struct scsi_target *starget;
240 int i; 259 int i;
241 260
242 vdev = kmalloc(sizeof(VirtDevice), GFP_KERNEL); 261 vdev = kzalloc(sizeof(VirtDevice), GFP_KERNEL);
243 if (!vdev) { 262 if (!vdev) {
244 printk(MYIOC_s_ERR_FMT "slave_alloc kmalloc(%zd) FAILED!\n", 263 printk(MYIOC_s_ERR_FMT "slave_alloc kmalloc(%zd) FAILED!\n",
245 hd->ioc->name, sizeof(VirtDevice)); 264 hd->ioc->name, sizeof(VirtDevice));
246 return -ENOMEM; 265 return -ENOMEM;
247 } 266 }
248 memset(vdev, 0, sizeof(VirtDevice));
249 vdev->ioc_id = hd->ioc->id; 267 vdev->ioc_id = hd->ioc->id;
250 sdev->hostdata = vdev; 268 sdev->hostdata = vdev;
251 starget = scsi_target(sdev); 269 starget = scsi_target(sdev);
@@ -256,19 +274,32 @@ mptsas_slave_alloc(struct scsi_device *sdev)
256 hd->Targets[sdev->id] = vtarget; 274 hd->Targets[sdev->id] = vtarget;
257 } 275 }
258 276
277 /*
278 RAID volumes placed beyond the last expected port.
279 */
280 if (sdev->channel == hd->ioc->num_ports) {
281 vdev->target_id = sdev->id;
282 vdev->bus_id = 0;
283 vdev->lun = 0;
284 goto out;
285 }
286
259 rphy = dev_to_rphy(sdev->sdev_target->dev.parent); 287 rphy = dev_to_rphy(sdev->sdev_target->dev.parent);
288 mutex_lock(&hd->ioc->sas_topology_mutex);
260 list_for_each_entry(p, &hd->ioc->sas_topology, list) { 289 list_for_each_entry(p, &hd->ioc->sas_topology, list) {
261 for (i = 0; i < p->num_phys; i++) { 290 for (i = 0; i < p->num_phys; i++) {
262 if (p->phy_info[i].attached.sas_address == 291 if (p->phy_info[i].attached.sas_address ==
263 rphy->identify.sas_address) { 292 rphy->identify.sas_address) {
264 vdev->target_id = 293 vdev->target_id =
265 p->phy_info[i].attached.target; 294 p->phy_info[i].attached.id;
266 vdev->bus_id = p->phy_info[i].attached.bus; 295 vdev->bus_id = p->phy_info[i].attached.channel;
267 vdev->lun = sdev->lun; 296 vdev->lun = sdev->lun;
297 mutex_unlock(&hd->ioc->sas_topology_mutex);
268 goto out; 298 goto out;
269 } 299 }
270 } 300 }
271 } 301 }
302 mutex_unlock(&hd->ioc->sas_topology_mutex);
272 303
273 printk("No matching SAS device found!!\n"); 304 printk("No matching SAS device found!!\n");
274 kfree(vdev); 305 kfree(vdev);
@@ -282,6 +313,42 @@ mptsas_slave_alloc(struct scsi_device *sdev)
282 return 0; 313 return 0;
283} 314}
284 315
316static void
317mptsas_slave_destroy(struct scsi_device *sdev)
318{
319 struct Scsi_Host *host = sdev->host;
320 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata;
321 struct sas_rphy *rphy;
322 struct mptsas_portinfo *p;
323 int i;
324
325 /*
326 * Handle hotplug removal case.
327 * We need to clear out attached data structure.
328 */
329 rphy = dev_to_rphy(sdev->sdev_target->dev.parent);
330
331 mutex_lock(&hd->ioc->sas_topology_mutex);
332 list_for_each_entry(p, &hd->ioc->sas_topology, list) {
333 for (i = 0; i < p->num_phys; i++) {
334 if (p->phy_info[i].attached.sas_address ==
335 rphy->identify.sas_address) {
336 memset(&p->phy_info[i].attached, 0,
337 sizeof(struct mptsas_devinfo));
338 p->phy_info[i].rphy = NULL;
339 goto out;
340 }
341 }
342 }
343
344 out:
345 mutex_unlock(&hd->ioc->sas_topology_mutex);
346 /*
347 * TODO: Issue target reset to flush firmware outstanding commands.
348 */
349 mptscsih_slave_destroy(sdev);
350}
351
285static struct scsi_host_template mptsas_driver_template = { 352static struct scsi_host_template mptsas_driver_template = {
286 .module = THIS_MODULE, 353 .module = THIS_MODULE,
287 .proc_name = "mptsas", 354 .proc_name = "mptsas",
@@ -293,7 +360,7 @@ static struct scsi_host_template mptsas_driver_template = {
293 .slave_alloc = mptsas_slave_alloc, 360 .slave_alloc = mptsas_slave_alloc,
294 .slave_configure = mptscsih_slave_configure, 361 .slave_configure = mptscsih_slave_configure,
295 .target_destroy = mptscsih_target_destroy, 362 .target_destroy = mptscsih_target_destroy,
296 .slave_destroy = mptscsih_slave_destroy, 363 .slave_destroy = mptsas_slave_destroy,
297 .change_queue_depth = mptscsih_change_queue_depth, 364 .change_queue_depth = mptscsih_change_queue_depth,
298 .eh_abort_handler = mptscsih_abort, 365 .eh_abort_handler = mptscsih_abort,
299 .eh_device_reset_handler = mptscsih_dev_reset, 366 .eh_device_reset_handler = mptscsih_dev_reset,
@@ -399,7 +466,7 @@ static int mptsas_phy_reset(struct sas_phy *phy, int hard_reset)
399 if (phy->identify.target_port_protocols & SAS_PROTOCOL_SMP) 466 if (phy->identify.target_port_protocols & SAS_PROTOCOL_SMP)
400 return -ENXIO; 467 return -ENXIO;
401 468
402 if (down_interruptible(&ioc->sas_mgmt.mutex)) 469 if (mutex_lock_interruptible(&ioc->sas_mgmt.mutex))
403 goto out; 470 goto out;
404 471
405 mf = mpt_get_msg_frame(mptsasMgmtCtx, ioc); 472 mf = mpt_get_msg_frame(mptsasMgmtCtx, ioc);
@@ -450,7 +517,7 @@ static int mptsas_phy_reset(struct sas_phy *phy, int hard_reset)
450 error = 0; 517 error = 0;
451 518
452 out_unlock: 519 out_unlock:
453 up(&ioc->sas_mgmt.mutex); 520 mutex_unlock(&ioc->sas_mgmt.mutex);
454 out: 521 out:
455 return error; 522 return error;
456} 523}
@@ -649,8 +716,8 @@ mptsas_sas_device_pg0(MPT_ADAPTER *ioc, struct mptsas_devinfo *device_info,
649 device_info->handle = le16_to_cpu(buffer->DevHandle); 716 device_info->handle = le16_to_cpu(buffer->DevHandle);
650 device_info->phy_id = buffer->PhyNum; 717 device_info->phy_id = buffer->PhyNum;
651 device_info->port_id = buffer->PhysicalPort; 718 device_info->port_id = buffer->PhysicalPort;
652 device_info->target = buffer->TargetID; 719 device_info->id = buffer->TargetID;
653 device_info->bus = buffer->Bus; 720 device_info->channel = buffer->Bus;
654 memcpy(&sas_address, &buffer->SASAddress, sizeof(__le64)); 721 memcpy(&sas_address, &buffer->SASAddress, sizeof(__le64));
655 device_info->sas_address = le64_to_cpu(sas_address); 722 device_info->sas_address = le64_to_cpu(sas_address);
656 device_info->device_info = 723 device_info->device_info =
@@ -858,36 +925,36 @@ mptsas_parse_device_info(struct sas_identify *identify,
858static int mptsas_probe_one_phy(struct device *dev, 925static int mptsas_probe_one_phy(struct device *dev,
859 struct mptsas_phyinfo *phy_info, int index, int local) 926 struct mptsas_phyinfo *phy_info, int index, int local)
860{ 927{
861 struct sas_phy *port; 928 struct sas_phy *phy;
862 int error; 929 int error;
863 930
864 port = sas_phy_alloc(dev, index); 931 phy = sas_phy_alloc(dev, index);
865 if (!port) 932 if (!phy)
866 return -ENOMEM; 933 return -ENOMEM;
867 934
868 port->port_identifier = phy_info->port_id; 935 phy->port_identifier = phy_info->port_id;
869 mptsas_parse_device_info(&port->identify, &phy_info->identify); 936 mptsas_parse_device_info(&phy->identify, &phy_info->identify);
870 937
871 /* 938 /*
872 * Set Negotiated link rate. 939 * Set Negotiated link rate.
873 */ 940 */
874 switch (phy_info->negotiated_link_rate) { 941 switch (phy_info->negotiated_link_rate) {
875 case MPI_SAS_IOUNIT0_RATE_PHY_DISABLED: 942 case MPI_SAS_IOUNIT0_RATE_PHY_DISABLED:
876 port->negotiated_linkrate = SAS_PHY_DISABLED; 943 phy->negotiated_linkrate = SAS_PHY_DISABLED;
877 break; 944 break;
878 case MPI_SAS_IOUNIT0_RATE_FAILED_SPEED_NEGOTIATION: 945 case MPI_SAS_IOUNIT0_RATE_FAILED_SPEED_NEGOTIATION:
879 port->negotiated_linkrate = SAS_LINK_RATE_FAILED; 946 phy->negotiated_linkrate = SAS_LINK_RATE_FAILED;
880 break; 947 break;
881 case MPI_SAS_IOUNIT0_RATE_1_5: 948 case MPI_SAS_IOUNIT0_RATE_1_5:
882 port->negotiated_linkrate = SAS_LINK_RATE_1_5_GBPS; 949 phy->negotiated_linkrate = SAS_LINK_RATE_1_5_GBPS;
883 break; 950 break;
884 case MPI_SAS_IOUNIT0_RATE_3_0: 951 case MPI_SAS_IOUNIT0_RATE_3_0:
885 port->negotiated_linkrate = SAS_LINK_RATE_3_0_GBPS; 952 phy->negotiated_linkrate = SAS_LINK_RATE_3_0_GBPS;
886 break; 953 break;
887 case MPI_SAS_IOUNIT0_RATE_SATA_OOB_COMPLETE: 954 case MPI_SAS_IOUNIT0_RATE_SATA_OOB_COMPLETE:
888 case MPI_SAS_IOUNIT0_RATE_UNKNOWN: 955 case MPI_SAS_IOUNIT0_RATE_UNKNOWN:
889 default: 956 default:
890 port->negotiated_linkrate = SAS_LINK_RATE_UNKNOWN; 957 phy->negotiated_linkrate = SAS_LINK_RATE_UNKNOWN;
891 break; 958 break;
892 } 959 }
893 960
@@ -896,10 +963,10 @@ static int mptsas_probe_one_phy(struct device *dev,
896 */ 963 */
897 switch (phy_info->hw_link_rate & MPI_SAS_PHY0_PRATE_MAX_RATE_MASK) { 964 switch (phy_info->hw_link_rate & MPI_SAS_PHY0_PRATE_MAX_RATE_MASK) {
898 case MPI_SAS_PHY0_HWRATE_MAX_RATE_1_5: 965 case MPI_SAS_PHY0_HWRATE_MAX_RATE_1_5:
899 port->maximum_linkrate_hw = SAS_LINK_RATE_1_5_GBPS; 966 phy->maximum_linkrate_hw = SAS_LINK_RATE_1_5_GBPS;
900 break; 967 break;
901 case MPI_SAS_PHY0_PRATE_MAX_RATE_3_0: 968 case MPI_SAS_PHY0_PRATE_MAX_RATE_3_0:
902 port->maximum_linkrate_hw = SAS_LINK_RATE_3_0_GBPS; 969 phy->maximum_linkrate_hw = SAS_LINK_RATE_3_0_GBPS;
903 break; 970 break;
904 default: 971 default:
905 break; 972 break;
@@ -911,10 +978,10 @@ static int mptsas_probe_one_phy(struct device *dev,
911 switch (phy_info->programmed_link_rate & 978 switch (phy_info->programmed_link_rate &
912 MPI_SAS_PHY0_PRATE_MAX_RATE_MASK) { 979 MPI_SAS_PHY0_PRATE_MAX_RATE_MASK) {
913 case MPI_SAS_PHY0_PRATE_MAX_RATE_1_5: 980 case MPI_SAS_PHY0_PRATE_MAX_RATE_1_5:
914 port->maximum_linkrate = SAS_LINK_RATE_1_5_GBPS; 981 phy->maximum_linkrate = SAS_LINK_RATE_1_5_GBPS;
915 break; 982 break;
916 case MPI_SAS_PHY0_PRATE_MAX_RATE_3_0: 983 case MPI_SAS_PHY0_PRATE_MAX_RATE_3_0:
917 port->maximum_linkrate = SAS_LINK_RATE_3_0_GBPS; 984 phy->maximum_linkrate = SAS_LINK_RATE_3_0_GBPS;
918 break; 985 break;
919 default: 986 default:
920 break; 987 break;
@@ -925,10 +992,10 @@ static int mptsas_probe_one_phy(struct device *dev,
925 */ 992 */
926 switch (phy_info->hw_link_rate & MPI_SAS_PHY0_HWRATE_MIN_RATE_MASK) { 993 switch (phy_info->hw_link_rate & MPI_SAS_PHY0_HWRATE_MIN_RATE_MASK) {
927 case MPI_SAS_PHY0_HWRATE_MIN_RATE_1_5: 994 case MPI_SAS_PHY0_HWRATE_MIN_RATE_1_5:
928 port->minimum_linkrate_hw = SAS_LINK_RATE_1_5_GBPS; 995 phy->minimum_linkrate_hw = SAS_LINK_RATE_1_5_GBPS;
929 break; 996 break;
930 case MPI_SAS_PHY0_PRATE_MIN_RATE_3_0: 997 case MPI_SAS_PHY0_PRATE_MIN_RATE_3_0:
931 port->minimum_linkrate_hw = SAS_LINK_RATE_3_0_GBPS; 998 phy->minimum_linkrate_hw = SAS_LINK_RATE_3_0_GBPS;
932 break; 999 break;
933 default: 1000 default:
934 break; 1001 break;
@@ -940,28 +1007,29 @@ static int mptsas_probe_one_phy(struct device *dev,
940 switch (phy_info->programmed_link_rate & 1007 switch (phy_info->programmed_link_rate &
941 MPI_SAS_PHY0_PRATE_MIN_RATE_MASK) { 1008 MPI_SAS_PHY0_PRATE_MIN_RATE_MASK) {
942 case MPI_SAS_PHY0_PRATE_MIN_RATE_1_5: 1009 case MPI_SAS_PHY0_PRATE_MIN_RATE_1_5:
943 port->minimum_linkrate = SAS_LINK_RATE_1_5_GBPS; 1010 phy->minimum_linkrate = SAS_LINK_RATE_1_5_GBPS;
944 break; 1011 break;
945 case MPI_SAS_PHY0_PRATE_MIN_RATE_3_0: 1012 case MPI_SAS_PHY0_PRATE_MIN_RATE_3_0:
946 port->minimum_linkrate = SAS_LINK_RATE_3_0_GBPS; 1013 phy->minimum_linkrate = SAS_LINK_RATE_3_0_GBPS;
947 break; 1014 break;
948 default: 1015 default:
949 break; 1016 break;
950 } 1017 }
951 1018
952 if (local) 1019 if (local)
953 port->local_attached = 1; 1020 phy->local_attached = 1;
954 1021
955 error = sas_phy_add(port); 1022 error = sas_phy_add(phy);
956 if (error) { 1023 if (error) {
957 sas_phy_free(port); 1024 sas_phy_free(phy);
958 return error; 1025 return error;
959 } 1026 }
1027 phy_info->phy = phy;
960 1028
961 if (phy_info->attached.handle) { 1029 if (phy_info->attached.handle) {
962 struct sas_rphy *rphy; 1030 struct sas_rphy *rphy;
963 1031
964 rphy = sas_rphy_alloc(port); 1032 rphy = sas_rphy_alloc(phy);
965 if (!rphy) 1033 if (!rphy)
966 return 0; /* non-fatal: an rphy can be added later */ 1034 return 0; /* non-fatal: an rphy can be added later */
967 1035
@@ -985,16 +1053,19 @@ mptsas_probe_hba_phys(MPT_ADAPTER *ioc, int *index)
985 u32 handle = 0xFFFF; 1053 u32 handle = 0xFFFF;
986 int error = -ENOMEM, i; 1054 int error = -ENOMEM, i;
987 1055
988 port_info = kmalloc(sizeof(*port_info), GFP_KERNEL); 1056 port_info = kzalloc(sizeof(*port_info), GFP_KERNEL);
989 if (!port_info) 1057 if (!port_info)
990 goto out; 1058 goto out;
991 memset(port_info, 0, sizeof(*port_info));
992 1059
993 error = mptsas_sas_io_unit_pg0(ioc, port_info); 1060 error = mptsas_sas_io_unit_pg0(ioc, port_info);
994 if (error) 1061 if (error)
995 goto out_free_port_info; 1062 goto out_free_port_info;
996 1063
1064 ioc->num_ports = port_info->num_phys;
1065 mutex_lock(&ioc->sas_topology_mutex);
997 list_add_tail(&port_info->list, &ioc->sas_topology); 1066 list_add_tail(&port_info->list, &ioc->sas_topology);
1067 mutex_unlock(&ioc->sas_topology_mutex);
1068
998 for (i = 0; i < port_info->num_phys; i++) { 1069 for (i = 0; i < port_info->num_phys; i++) {
999 mptsas_sas_phy_pg0(ioc, &port_info->phy_info[i], 1070 mptsas_sas_phy_pg0(ioc, &port_info->phy_info[i],
1000 (MPI_SAS_PHY_PGAD_FORM_PHY_NUMBER << 1071 (MPI_SAS_PHY_PGAD_FORM_PHY_NUMBER <<
@@ -1034,10 +1105,9 @@ mptsas_probe_expander_phys(MPT_ADAPTER *ioc, u32 *handle, int *index)
1034 struct mptsas_portinfo *port_info, *p; 1105 struct mptsas_portinfo *port_info, *p;
1035 int error = -ENOMEM, i, j; 1106 int error = -ENOMEM, i, j;
1036 1107
1037 port_info = kmalloc(sizeof(*port_info), GFP_KERNEL); 1108 port_info = kzalloc(sizeof(*port_info), GFP_KERNEL);
1038 if (!port_info) 1109 if (!port_info)
1039 goto out; 1110 goto out;
1040 memset(port_info, 0, sizeof(*port_info));
1041 1111
1042 error = mptsas_sas_expander_pg0(ioc, port_info, 1112 error = mptsas_sas_expander_pg0(ioc, port_info,
1043 (MPI_SAS_EXPAND_PGAD_FORM_GET_NEXT_HANDLE << 1113 (MPI_SAS_EXPAND_PGAD_FORM_GET_NEXT_HANDLE <<
@@ -1047,7 +1117,10 @@ mptsas_probe_expander_phys(MPT_ADAPTER *ioc, u32 *handle, int *index)
1047 1117
1048 *handle = port_info->handle; 1118 *handle = port_info->handle;
1049 1119
1120 mutex_lock(&ioc->sas_topology_mutex);
1050 list_add_tail(&port_info->list, &ioc->sas_topology); 1121 list_add_tail(&port_info->list, &ioc->sas_topology);
1122 mutex_unlock(&ioc->sas_topology_mutex);
1123
1051 for (i = 0; i < port_info->num_phys; i++) { 1124 for (i = 0; i < port_info->num_phys; i++) {
1052 struct device *parent; 1125 struct device *parent;
1053 1126
@@ -1079,6 +1152,7 @@ mptsas_probe_expander_phys(MPT_ADAPTER *ioc, u32 *handle, int *index)
1079 * HBA phys. 1152 * HBA phys.
1080 */ 1153 */
1081 parent = &ioc->sh->shost_gendev; 1154 parent = &ioc->sh->shost_gendev;
1155 mutex_lock(&ioc->sas_topology_mutex);
1082 list_for_each_entry(p, &ioc->sas_topology, list) { 1156 list_for_each_entry(p, &ioc->sas_topology, list) {
1083 for (j = 0; j < p->num_phys; j++) { 1157 for (j = 0; j < p->num_phys; j++) {
1084 if (port_info->phy_info[i].identify.handle == 1158 if (port_info->phy_info[i].identify.handle ==
@@ -1086,6 +1160,7 @@ mptsas_probe_expander_phys(MPT_ADAPTER *ioc, u32 *handle, int *index)
1086 parent = &p->phy_info[j].rphy->dev; 1160 parent = &p->phy_info[j].rphy->dev;
1087 } 1161 }
1088 } 1162 }
1163 mutex_unlock(&ioc->sas_topology_mutex);
1089 1164
1090 mptsas_probe_one_phy(parent, &port_info->phy_info[i], 1165 mptsas_probe_one_phy(parent, &port_info->phy_info[i],
1091 *index, 0); 1166 *index, 0);
@@ -1111,6 +1186,211 @@ mptsas_scan_sas_topology(MPT_ADAPTER *ioc)
1111 ; 1186 ;
1112} 1187}
1113 1188
1189static struct mptsas_phyinfo *
1190mptsas_find_phyinfo_by_parent(MPT_ADAPTER *ioc, u16 parent_handle, u8 phy_id)
1191{
1192 struct mptsas_portinfo *port_info;
1193 struct mptsas_devinfo device_info;
1194 struct mptsas_phyinfo *phy_info = NULL;
1195 int i, error;
1196
1197 /*
1198 * Retrieve the parent sas_address
1199 */
1200 error = mptsas_sas_device_pg0(ioc, &device_info,
1201 (MPI_SAS_DEVICE_PGAD_FORM_HANDLE <<
1202 MPI_SAS_DEVICE_PGAD_FORM_SHIFT),
1203 parent_handle);
1204 if (error) {
1205 printk("mptsas: failed to retrieve device page\n");
1206 return NULL;
1207 }
1208
1209 /*
1210 * The phy_info structures are never deallocated during lifetime of
1211 * a host, so the code below is safe without additional refcounting.
1212 */
1213 mutex_lock(&ioc->sas_topology_mutex);
1214 list_for_each_entry(port_info, &ioc->sas_topology, list) {
1215 for (i = 0; i < port_info->num_phys; i++) {
1216 if (port_info->phy_info[i].identify.sas_address ==
1217 device_info.sas_address &&
1218 port_info->phy_info[i].phy_id == phy_id) {
1219 phy_info = &port_info->phy_info[i];
1220 break;
1221 }
1222 }
1223 }
1224 mutex_unlock(&ioc->sas_topology_mutex);
1225
1226 return phy_info;
1227}
1228
1229static struct mptsas_phyinfo *
1230mptsas_find_phyinfo_by_handle(MPT_ADAPTER *ioc, u16 handle)
1231{
1232 struct mptsas_portinfo *port_info;
1233 struct mptsas_phyinfo *phy_info = NULL;
1234 int i;
1235
1236 /*
1237 * The phy_info structures are never deallocated during lifetime of
1238 * a host, so the code below is safe without additional refcounting.
1239 */
1240 mutex_lock(&ioc->sas_topology_mutex);
1241 list_for_each_entry(port_info, &ioc->sas_topology, list) {
1242 for (i = 0; i < port_info->num_phys; i++) {
1243 if (port_info->phy_info[i].attached.handle == handle) {
1244 phy_info = &port_info->phy_info[i];
1245 break;
1246 }
1247 }
1248 }
1249 mutex_unlock(&ioc->sas_topology_mutex);
1250
1251 return phy_info;
1252}
1253
1254static void
1255mptsas_hotplug_work(void *arg)
1256{
1257 struct mptsas_hotplug_event *ev = arg;
1258 MPT_ADAPTER *ioc = ev->ioc;
1259 struct mptsas_phyinfo *phy_info;
1260 struct sas_rphy *rphy;
1261 char *ds = NULL;
1262
1263 if (ev->device_info & MPI_SAS_DEVICE_INFO_SSP_TARGET)
1264 ds = "ssp";
1265 if (ev->device_info & MPI_SAS_DEVICE_INFO_STP_TARGET)
1266 ds = "stp";
1267 if (ev->device_info & MPI_SAS_DEVICE_INFO_SATA_DEVICE)
1268 ds = "sata";
1269
1270 switch (ev->event_type) {
1271 case MPTSAS_DEL_DEVICE:
1272 printk(MYIOC_s_INFO_FMT
1273 "removing %s device, channel %d, id %d, phy %d\n",
1274 ioc->name, ds, ev->channel, ev->id, ev->phy_id);
1275
1276 phy_info = mptsas_find_phyinfo_by_handle(ioc, ev->handle);
1277 if (!phy_info) {
1278 printk("mptsas: remove event for non-existant PHY.\n");
1279 break;
1280 }
1281
1282 if (phy_info->rphy) {
1283 sas_rphy_delete(phy_info->rphy);
1284 phy_info->rphy = NULL;
1285 }
1286 break;
1287 case MPTSAS_ADD_DEVICE:
1288 printk(MYIOC_s_INFO_FMT
1289 "attaching %s device, channel %d, id %d, phy %d\n",
1290 ioc->name, ds, ev->channel, ev->id, ev->phy_id);
1291
1292 phy_info = mptsas_find_phyinfo_by_parent(ioc,
1293 ev->parent_handle, ev->phy_id);
1294 if (!phy_info) {
1295 printk("mptsas: add event for non-existant PHY.\n");
1296 break;
1297 }
1298
1299 if (phy_info->rphy) {
1300 printk("mptsas: trying to add existing device.\n");
1301 break;
1302 }
1303
1304 /* fill attached info */
1305 phy_info->attached.handle = ev->handle;
1306 phy_info->attached.phy_id = ev->phy_id;
1307 phy_info->attached.port_id = phy_info->identify.port_id;
1308 phy_info->attached.id = ev->id;
1309 phy_info->attached.channel = ev->channel;
1310 phy_info->attached.sas_address = ev->sas_address;
1311 phy_info->attached.device_info = ev->device_info;
1312
1313 rphy = sas_rphy_alloc(phy_info->phy);
1314 if (!rphy)
1315 break; /* non-fatal: an rphy can be added later */
1316
1317 mptsas_parse_device_info(&rphy->identify, &phy_info->attached);
1318 if (sas_rphy_add(rphy)) {
1319 sas_rphy_free(rphy);
1320 break;
1321 }
1322
1323 phy_info->rphy = rphy;
1324 break;
1325 }
1326
1327 kfree(ev);
1328}
1329
1330static void
1331mptscsih_send_sas_event(MPT_ADAPTER *ioc,
1332 EVENT_DATA_SAS_DEVICE_STATUS_CHANGE *sas_event_data)
1333{
1334 struct mptsas_hotplug_event *ev;
1335 u32 device_info = le32_to_cpu(sas_event_data->DeviceInfo);
1336 __le64 sas_address;
1337
1338 if ((device_info &
1339 (MPI_SAS_DEVICE_INFO_SSP_TARGET |
1340 MPI_SAS_DEVICE_INFO_STP_TARGET |
1341 MPI_SAS_DEVICE_INFO_SATA_DEVICE )) == 0)
1342 return;
1343
1344 if ((sas_event_data->ReasonCode &
1345 (MPI_EVENT_SAS_DEV_STAT_RC_ADDED |
1346 MPI_EVENT_SAS_DEV_STAT_RC_NOT_RESPONDING)) == 0)
1347 return;
1348
1349 ev = kmalloc(sizeof(*ev), GFP_ATOMIC);
1350 if (!ev) {
1351 printk(KERN_WARNING "mptsas: lost hotplug event\n");
1352 return;
1353 }
1354
1355
1356 INIT_WORK(&ev->work, mptsas_hotplug_work, ev);
1357 ev->ioc = ioc;
1358 ev->handle = le16_to_cpu(sas_event_data->DevHandle);
1359 ev->parent_handle = le16_to_cpu(sas_event_data->ParentDevHandle);
1360 ev->channel = sas_event_data->Bus;
1361 ev->id = sas_event_data->TargetID;
1362 ev->phy_id = sas_event_data->PhyNum;
1363 memcpy(&sas_address, &sas_event_data->SASAddress, sizeof(__le64));
1364 ev->sas_address = le64_to_cpu(sas_address);
1365 ev->device_info = device_info;
1366
1367 if (sas_event_data->ReasonCode & MPI_EVENT_SAS_DEV_STAT_RC_ADDED)
1368 ev->event_type = MPTSAS_ADD_DEVICE;
1369 else
1370 ev->event_type = MPTSAS_DEL_DEVICE;
1371
1372 schedule_work(&ev->work);
1373}
1374
1375static int
1376mptsas_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *reply)
1377{
1378 u8 event = le32_to_cpu(reply->Event) & 0xFF;
1379
1380 if (!ioc->sh)
1381 return 1;
1382
1383 switch (event) {
1384 case MPI_EVENT_SAS_DEVICE_STATUS_CHANGE:
1385 mptscsih_send_sas_event(ioc,
1386 (EVENT_DATA_SAS_DEVICE_STATUS_CHANGE *)reply->Data);
1387 return 1; /* currently means nothing really */
1388
1389 default:
1390 return mptscsih_event_process(ioc, reply);
1391 }
1392}
1393
1114static int 1394static int
1115mptsas_probe(struct pci_dev *pdev, const struct pci_device_id *id) 1395mptsas_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1116{ 1396{
@@ -1118,11 +1398,10 @@ mptsas_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1118 MPT_SCSI_HOST *hd; 1398 MPT_SCSI_HOST *hd;
1119 MPT_ADAPTER *ioc; 1399 MPT_ADAPTER *ioc;
1120 unsigned long flags; 1400 unsigned long flags;
1121 int sz, ii; 1401 int ii;
1122 int numSGE = 0; 1402 int numSGE = 0;
1123 int scale; 1403 int scale;
1124 int ioc_cap; 1404 int ioc_cap;
1125 u8 *mem;
1126 int error=0; 1405 int error=0;
1127 int r; 1406 int r;
1128 1407
@@ -1203,7 +1482,9 @@ mptsas_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1203 sh->unique_id = ioc->id; 1482 sh->unique_id = ioc->id;
1204 1483
1205 INIT_LIST_HEAD(&ioc->sas_topology); 1484 INIT_LIST_HEAD(&ioc->sas_topology);
1206 init_MUTEX(&ioc->sas_mgmt.mutex); 1485 mutex_init(&ioc->sas_topology_mutex);
1486
1487 mutex_init(&ioc->sas_mgmt.mutex);
1207 init_completion(&ioc->sas_mgmt.done); 1488 init_completion(&ioc->sas_mgmt.done);
1208 1489
1209 /* Verify that we won't exceed the maximum 1490 /* Verify that we won't exceed the maximum
@@ -1244,36 +1525,27 @@ mptsas_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1244 /* SCSI needs scsi_cmnd lookup table! 1525 /* SCSI needs scsi_cmnd lookup table!
1245 * (with size equal to req_depth*PtrSz!) 1526 * (with size equal to req_depth*PtrSz!)
1246 */ 1527 */
1247 sz = ioc->req_depth * sizeof(void *); 1528 hd->ScsiLookup = kcalloc(ioc->req_depth, sizeof(void *), GFP_ATOMIC);
1248 mem = kmalloc(sz, GFP_ATOMIC); 1529 if (!hd->ScsiLookup) {
1249 if (mem == NULL) {
1250 error = -ENOMEM; 1530 error = -ENOMEM;
1251 goto out_mptsas_probe; 1531 goto out_mptsas_probe;
1252 } 1532 }
1253 1533
1254 memset(mem, 0, sz); 1534 dprintk((MYIOC_s_INFO_FMT "ScsiLookup @ %p\n",
1255 hd->ScsiLookup = (struct scsi_cmnd **) mem; 1535 ioc->name, hd->ScsiLookup));
1256
1257 dprintk((MYIOC_s_INFO_FMT "ScsiLookup @ %p, sz=%d\n",
1258 ioc->name, hd->ScsiLookup, sz));
1259 1536
1260 /* Allocate memory for the device structures. 1537 /* Allocate memory for the device structures.
1261 * A non-Null pointer at an offset 1538 * A non-Null pointer at an offset
1262 * indicates a device exists. 1539 * indicates a device exists.
1263 * max_id = 1 + maximum id (hosts.h) 1540 * max_id = 1 + maximum id (hosts.h)
1264 */ 1541 */
1265 sz = sh->max_id * sizeof(void *); 1542 hd->Targets = kcalloc(sh->max_id, sizeof(void *), GFP_ATOMIC);
1266 mem = kmalloc(sz, GFP_ATOMIC); 1543 if (!hd->Targets) {
1267 if (mem == NULL) {
1268 error = -ENOMEM; 1544 error = -ENOMEM;
1269 goto out_mptsas_probe; 1545 goto out_mptsas_probe;
1270 } 1546 }
1271 1547
1272 memset(mem, 0, sz); 1548 dprintk((KERN_INFO " vtarget @ %p\n", hd->Targets));
1273 hd->Targets = (VirtTarget **) mem;
1274
1275 dprintk((KERN_INFO
1276 " vtarget @ %p, sz=%d\n", hd->Targets, sz));
1277 1549
1278 /* Clear the TM flags 1550 /* Clear the TM flags
1279 */ 1551 */
@@ -1324,6 +1596,20 @@ mptsas_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1324 1596
1325 mptsas_scan_sas_topology(ioc); 1597 mptsas_scan_sas_topology(ioc);
1326 1598
1599 /*
1600 Reporting RAID volumes.
1601 */
1602 if (!ioc->raid_data.pIocPg2)
1603 return 0;
1604 if (!ioc->raid_data.pIocPg2->NumActiveVolumes)
1605 return 0;
1606 for (ii=0;ii<ioc->raid_data.pIocPg2->NumActiveVolumes;ii++) {
1607 scsi_add_device(sh,
1608 ioc->num_ports,
1609 ioc->raid_data.pIocPg2->RaidVolume[ii].VolumeID,
1610 0);
1611 }
1612
1327 return 0; 1613 return 0;
1328 1614
1329out_mptsas_probe: 1615out_mptsas_probe:
@@ -1339,10 +1625,12 @@ static void __devexit mptsas_remove(struct pci_dev *pdev)
1339 1625
1340 sas_remove_host(ioc->sh); 1626 sas_remove_host(ioc->sh);
1341 1627
1628 mutex_lock(&ioc->sas_topology_mutex);
1342 list_for_each_entry_safe(p, n, &ioc->sas_topology, list) { 1629 list_for_each_entry_safe(p, n, &ioc->sas_topology, list) {
1343 list_del(&p->list); 1630 list_del(&p->list);
1344 kfree(p); 1631 kfree(p);
1345 } 1632 }
1633 mutex_unlock(&ioc->sas_topology_mutex);
1346 1634
1347 mptscsih_remove(pdev); 1635 mptscsih_remove(pdev);
1348} 1636}
@@ -1393,7 +1681,7 @@ mptsas_init(void)
1393 mpt_register(mptscsih_scandv_complete, MPTSAS_DRIVER); 1681 mpt_register(mptscsih_scandv_complete, MPTSAS_DRIVER);
1394 mptsasMgmtCtx = mpt_register(mptsas_mgmt_done, MPTSAS_DRIVER); 1682 mptsasMgmtCtx = mpt_register(mptsas_mgmt_done, MPTSAS_DRIVER);
1395 1683
1396 if (mpt_event_register(mptsasDoneCtx, mptscsih_event_process) == 0) { 1684 if (mpt_event_register(mptsasDoneCtx, mptsas_event_process) == 0) {
1397 devtprintk((KERN_INFO MYNAM 1685 devtprintk((KERN_INFO MYNAM
1398 ": Registered for IOC event notifications\n")); 1686 ": Registered for IOC event notifications\n"));
1399 } 1687 }
diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
index 93a16fa3c4ba..cdac5578fdf2 100644
--- a/drivers/message/fusion/mptscsih.c
+++ b/drivers/message/fusion/mptscsih.c
@@ -893,6 +893,7 @@ mptscsih_flush_running_cmds(MPT_SCSI_HOST *hd)
893 * when a lun is disable by mid-layer. 893 * when a lun is disable by mid-layer.
894 * Do NOT access the referenced scsi_cmnd structure or 894 * Do NOT access the referenced scsi_cmnd structure or
895 * members. Will cause either a paging or NULL ptr error. 895 * members. Will cause either a paging or NULL ptr error.
896 * (BUT, BUT, BUT, the code does reference it! - mdr)
896 * @hd: Pointer to a SCSI HOST structure 897 * @hd: Pointer to a SCSI HOST structure
897 * @vdevice: per device private data 898 * @vdevice: per device private data
898 * 899 *
@@ -2162,10 +2163,9 @@ mptscsih_target_alloc(struct scsi_target *starget)
2162{ 2163{
2163 VirtTarget *vtarget; 2164 VirtTarget *vtarget;
2164 2165
2165 vtarget = kmalloc(sizeof(VirtTarget), GFP_KERNEL); 2166 vtarget = kzalloc(sizeof(VirtTarget), GFP_KERNEL);
2166 if (!vtarget) 2167 if (!vtarget)
2167 return -ENOMEM; 2168 return -ENOMEM;
2168 memset(vtarget, 0, sizeof(VirtTarget));
2169 starget->hostdata = vtarget; 2169 starget->hostdata = vtarget;
2170 return 0; 2170 return 0;
2171} 2171}
@@ -2185,14 +2185,13 @@ mptscsih_slave_alloc(struct scsi_device *sdev)
2185 VirtDevice *vdev; 2185 VirtDevice *vdev;
2186 struct scsi_target *starget; 2186 struct scsi_target *starget;
2187 2187
2188 vdev = kmalloc(sizeof(VirtDevice), GFP_KERNEL); 2188 vdev = kzalloc(sizeof(VirtDevice), GFP_KERNEL);
2189 if (!vdev) { 2189 if (!vdev) {
2190 printk(MYIOC_s_ERR_FMT "slave_alloc kmalloc(%zd) FAILED!\n", 2190 printk(MYIOC_s_ERR_FMT "slave_alloc kmalloc(%zd) FAILED!\n",
2191 hd->ioc->name, sizeof(VirtDevice)); 2191 hd->ioc->name, sizeof(VirtDevice));
2192 return -ENOMEM; 2192 return -ENOMEM;
2193 } 2193 }
2194 2194
2195 memset(vdev, 0, sizeof(VirtDevice));
2196 vdev->ioc_id = hd->ioc->id; 2195 vdev->ioc_id = hd->ioc->id;
2197 vdev->target_id = sdev->id; 2196 vdev->target_id = sdev->id;
2198 vdev->bus_id = sdev->channel; 2197 vdev->bus_id = sdev->channel;
@@ -2559,13 +2558,25 @@ mptscsih_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
2559 hd->cmdPtr = NULL; 2558 hd->cmdPtr = NULL;
2560 } 2559 }
2561 2560
2562 /* 7. Set flag to force DV and re-read IOC Page 3 2561 /* 7. SPI: Set flag to force DV and re-read IOC Page 3
2563 */ 2562 */
2564 if (ioc->bus_type == SPI) { 2563 if (ioc->bus_type == SPI) {
2565 ioc->spi_data.forceDv = MPT_SCSICFG_NEED_DV | MPT_SCSICFG_RELOAD_IOC_PG3; 2564 ioc->spi_data.forceDv = MPT_SCSICFG_NEED_DV | MPT_SCSICFG_RELOAD_IOC_PG3;
2566 ddvtprintk(("Set reload IOC Pg3 Flag\n")); 2565 ddvtprintk(("Set reload IOC Pg3 Flag\n"));
2567 } 2566 }
2568 2567
2568 /* 7. FC: Rescan for blocked rports which might have returned.
2569 */
2570 else if (ioc->bus_type == FC) {
2571 int work_count;
2572 unsigned long flags;
2573
2574 spin_lock_irqsave(&ioc->fc_rescan_work_lock, flags);
2575 work_count = ++ioc->fc_rescan_work_count;
2576 spin_unlock_irqrestore(&ioc->fc_rescan_work_lock, flags);
2577 if (work_count == 1)
2578 schedule_work(&ioc->fc_rescan_work);
2579 }
2569 dtmprintk((MYIOC_s_WARN_FMT "Post-Reset complete.\n", ioc->name)); 2580 dtmprintk((MYIOC_s_WARN_FMT "Post-Reset complete.\n", ioc->name));
2570 2581
2571 } 2582 }
@@ -2589,6 +2600,8 @@ mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply)
2589{ 2600{
2590 MPT_SCSI_HOST *hd; 2601 MPT_SCSI_HOST *hd;
2591 u8 event = le32_to_cpu(pEvReply->Event) & 0xFF; 2602 u8 event = le32_to_cpu(pEvReply->Event) & 0xFF;
2603 int work_count;
2604 unsigned long flags;
2592 2605
2593 devtprintk((MYIOC_s_INFO_FMT "MPT event (=%02Xh) routed to SCSI host driver!\n", 2606 devtprintk((MYIOC_s_INFO_FMT "MPT event (=%02Xh) routed to SCSI host driver!\n",
2594 ioc->name, event)); 2607 ioc->name, event));
@@ -2610,11 +2623,18 @@ mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply)
2610 /* FIXME! */ 2623 /* FIXME! */
2611 break; 2624 break;
2612 2625
2626 case MPI_EVENT_RESCAN: /* 06 */
2627 spin_lock_irqsave(&ioc->fc_rescan_work_lock, flags);
2628 work_count = ++ioc->fc_rescan_work_count;
2629 spin_unlock_irqrestore(&ioc->fc_rescan_work_lock, flags);
2630 if (work_count == 1)
2631 schedule_work(&ioc->fc_rescan_work);
2632 break;
2633
2613 /* 2634 /*
2614 * CHECKME! Don't think we need to do 2635 * CHECKME! Don't think we need to do
2615 * anything for these, but... 2636 * anything for these, but...
2616 */ 2637 */
2617 case MPI_EVENT_RESCAN: /* 06 */
2618 case MPI_EVENT_LINK_STATUS_CHANGE: /* 07 */ 2638 case MPI_EVENT_LINK_STATUS_CHANGE: /* 07 */
2619 case MPI_EVENT_LOOP_STATE_CHANGE: /* 08 */ 2639 case MPI_EVENT_LOOP_STATE_CHANGE: /* 08 */
2620 /* 2640 /*
@@ -3954,8 +3974,6 @@ mptscsih_synchronize_cache(MPT_SCSI_HOST *hd, VirtDevice *vdevice)
3954 3974
3955/* Search IOC page 3 to determine if this is hidden physical disk 3975/* Search IOC page 3 to determine if this is hidden physical disk
3956 */ 3976 */
3957/* Search IOC page 3 to determine if this is hidden physical disk
3958 */
3959static int 3977static int
3960mptscsih_is_phys_disk(MPT_ADAPTER *ioc, int id) 3978mptscsih_is_phys_disk(MPT_ADAPTER *ioc, int id)
3961{ 3979{
diff --git a/drivers/message/fusion/mptspi.c b/drivers/message/fusion/mptspi.c
index ce332a6085e5..7dce29277cb7 100644
--- a/drivers/message/fusion/mptspi.c
+++ b/drivers/message/fusion/mptspi.c
@@ -158,11 +158,10 @@ mptspi_probe(struct pci_dev *pdev, const struct pci_device_id *id)
158 MPT_SCSI_HOST *hd; 158 MPT_SCSI_HOST *hd;
159 MPT_ADAPTER *ioc; 159 MPT_ADAPTER *ioc;
160 unsigned long flags; 160 unsigned long flags;
161 int sz, ii; 161 int ii;
162 int numSGE = 0; 162 int numSGE = 0;
163 int scale; 163 int scale;
164 int ioc_cap; 164 int ioc_cap;
165 u8 *mem;
166 int error=0; 165 int error=0;
167 int r; 166 int r;
168 167
@@ -288,36 +287,27 @@ mptspi_probe(struct pci_dev *pdev, const struct pci_device_id *id)
288 /* SCSI needs scsi_cmnd lookup table! 287 /* SCSI needs scsi_cmnd lookup table!
289 * (with size equal to req_depth*PtrSz!) 288 * (with size equal to req_depth*PtrSz!)
290 */ 289 */
291 sz = ioc->req_depth * sizeof(void *); 290 hd->ScsiLookup = kcalloc(ioc->req_depth, sizeof(void *), GFP_ATOMIC);
292 mem = kmalloc(sz, GFP_ATOMIC); 291 if (!hd->ScsiLookup) {
293 if (mem == NULL) {
294 error = -ENOMEM; 292 error = -ENOMEM;
295 goto out_mptspi_probe; 293 goto out_mptspi_probe;
296 } 294 }
297 295
298 memset(mem, 0, sz); 296 dprintk((MYIOC_s_INFO_FMT "ScsiLookup @ %p\n",
299 hd->ScsiLookup = (struct scsi_cmnd **) mem; 297 ioc->name, hd->ScsiLookup));
300
301 dprintk((MYIOC_s_INFO_FMT "ScsiLookup @ %p, sz=%d\n",
302 ioc->name, hd->ScsiLookup, sz));
303 298
304 /* Allocate memory for the device structures. 299 /* Allocate memory for the device structures.
305 * A non-Null pointer at an offset 300 * A non-Null pointer at an offset
306 * indicates a device exists. 301 * indicates a device exists.
307 * max_id = 1 + maximum id (hosts.h) 302 * max_id = 1 + maximum id (hosts.h)
308 */ 303 */
309 sz = sh->max_id * sizeof(void *); 304 hd->Targets = kcalloc(sh->max_id, sizeof(void *), GFP_ATOMIC);
310 mem = kmalloc(sz, GFP_ATOMIC); 305 if (!hd->Targets) {
311 if (mem == NULL) {
312 error = -ENOMEM; 306 error = -ENOMEM;
313 goto out_mptspi_probe; 307 goto out_mptspi_probe;
314 } 308 }
315 309
316 memset(mem, 0, sz); 310 dprintk((KERN_INFO " vdev @ %p\n", hd->Targets));
317 hd->Targets = (VirtTarget **) mem;
318
319 dprintk((KERN_INFO
320 " vdev @ %p, sz=%d\n", hd->Targets, sz));
321 311
322 /* Clear the TM flags 312 /* Clear the TM flags
323 */ 313 */
diff --git a/drivers/message/i2o/pci.c b/drivers/message/i2o/pci.c
index c5b656cdea7c..d698d7709c31 100644
--- a/drivers/message/i2o/pci.c
+++ b/drivers/message/i2o/pci.c
@@ -88,11 +88,6 @@ static int __devinit i2o_pci_alloc(struct i2o_controller *c)
88 struct device *dev = &pdev->dev; 88 struct device *dev = &pdev->dev;
89 int i; 89 int i;
90 90
91 if (pci_request_regions(pdev, OSM_DESCRIPTION)) {
92 printk(KERN_ERR "%s: device already claimed\n", c->name);
93 return -ENODEV;
94 }
95
96 for (i = 0; i < 6; i++) { 91 for (i = 0; i < 6; i++) {
97 /* Skip I/O spaces */ 92 /* Skip I/O spaces */
98 if (!(pci_resource_flags(pdev, i) & IORESOURCE_IO)) { 93 if (!(pci_resource_flags(pdev, i) & IORESOURCE_IO)) {
@@ -319,6 +314,11 @@ static int __devinit i2o_pci_probe(struct pci_dev *pdev,
319 return rc; 314 return rc;
320 } 315 }
321 316
317 if (pci_request_regions(pdev, OSM_DESCRIPTION)) {
318 printk(KERN_ERR "i2o: device already claimed\n");
319 return -ENODEV;
320 }
321
322 if (pci_set_dma_mask(pdev, DMA_32BIT_MASK)) { 322 if (pci_set_dma_mask(pdev, DMA_32BIT_MASK)) {
323 printk(KERN_WARNING "i2o: no suitable DMA found for %s\n", 323 printk(KERN_WARNING "i2o: no suitable DMA found for %s\n",
324 pci_name(pdev)); 324 pci_name(pdev));
diff --git a/drivers/s390/scsi/zfcp_aux.c b/drivers/s390/scsi/zfcp_aux.c
index 5e84c5aa7779..167fef39d8a7 100644
--- a/drivers/s390/scsi/zfcp_aux.c
+++ b/drivers/s390/scsi/zfcp_aux.c
@@ -1125,6 +1125,8 @@ zfcp_adapter_dequeue(struct zfcp_adapter *adapter)
1125 zfcp_free_low_mem_buffers(adapter); 1125 zfcp_free_low_mem_buffers(adapter);
1126 /* free memory of adapter data structure and queues */ 1126 /* free memory of adapter data structure and queues */
1127 zfcp_qdio_free_queues(adapter); 1127 zfcp_qdio_free_queues(adapter);
1128 kfree(adapter->fc_stats);
1129 kfree(adapter->stats_reset_data);
1128 ZFCP_LOG_TRACE("freeing adapter structure\n"); 1130 ZFCP_LOG_TRACE("freeing adapter structure\n");
1129 kfree(adapter); 1131 kfree(adapter);
1130 out: 1132 out:
diff --git a/drivers/s390/scsi/zfcp_def.h b/drivers/s390/scsi/zfcp_def.h
index d81b737d68cc..9bb511083a26 100644
--- a/drivers/s390/scsi/zfcp_def.h
+++ b/drivers/s390/scsi/zfcp_def.h
@@ -921,7 +921,6 @@ struct zfcp_adapter {
921 u32 physical_s_id; /* local FC port ID */ 921 u32 physical_s_id; /* local FC port ID */
922 struct ccw_device *ccw_device; /* S/390 ccw device */ 922 struct ccw_device *ccw_device; /* S/390 ccw device */
923 u8 fc_service_class; 923 u8 fc_service_class;
924 u32 fc_topology; /* FC topology */
925 u32 hydra_version; /* Hydra version */ 924 u32 hydra_version; /* Hydra version */
926 u32 fsf_lic_version; 925 u32 fsf_lic_version;
927 u32 adapter_features; /* FCP channel features */ 926 u32 adapter_features; /* FCP channel features */
@@ -978,6 +977,9 @@ struct zfcp_adapter {
978 struct zfcp_adapter_mempool pool; /* Adapter memory pools */ 977 struct zfcp_adapter_mempool pool; /* Adapter memory pools */
979 struct qdio_initialize qdio_init_data; /* for qdio_establish */ 978 struct qdio_initialize qdio_init_data; /* for qdio_establish */
980 struct device generic_services; /* directory for WKA ports */ 979 struct device generic_services; /* directory for WKA ports */
980 struct fc_host_statistics *fc_stats;
981 struct fsf_qtcb_bottom_port *stats_reset_data;
982 unsigned long stats_reset;
981}; 983};
982 984
983/* 985/*
diff --git a/drivers/s390/scsi/zfcp_erp.c b/drivers/s390/scsi/zfcp_erp.c
index ee7314d8c2da..7bdb00b5aeb2 100644
--- a/drivers/s390/scsi/zfcp_erp.c
+++ b/drivers/s390/scsi/zfcp_erp.c
@@ -2613,7 +2613,7 @@ zfcp_erp_port_strategy_open_common(struct zfcp_erp_action *erp_action)
2613 case ZFCP_ERP_STEP_UNINITIALIZED: 2613 case ZFCP_ERP_STEP_UNINITIALIZED:
2614 case ZFCP_ERP_STEP_PHYS_PORT_CLOSING: 2614 case ZFCP_ERP_STEP_PHYS_PORT_CLOSING:
2615 case ZFCP_ERP_STEP_PORT_CLOSING: 2615 case ZFCP_ERP_STEP_PORT_CLOSING:
2616 if (adapter->fc_topology == FSF_TOPO_P2P) { 2616 if (fc_host_port_type(adapter->scsi_host) == FC_PORTTYPE_PTP) {
2617 if (port->wwpn != adapter->peer_wwpn) { 2617 if (port->wwpn != adapter->peer_wwpn) {
2618 ZFCP_LOG_NORMAL("Failed to open port 0x%016Lx " 2618 ZFCP_LOG_NORMAL("Failed to open port 0x%016Lx "
2619 "on adapter %s.\nPeer WWPN " 2619 "on adapter %s.\nPeer WWPN "
diff --git a/drivers/s390/scsi/zfcp_fsf.c b/drivers/s390/scsi/zfcp_fsf.c
index 59587951c847..cbfab09899c8 100644
--- a/drivers/s390/scsi/zfcp_fsf.c
+++ b/drivers/s390/scsi/zfcp_fsf.c
@@ -964,6 +964,40 @@ zfcp_fsf_status_read_handler(struct zfcp_fsf_req *fsf_req)
964 | ZFCP_STATUS_COMMON_ERP_FAILED); 964 | ZFCP_STATUS_COMMON_ERP_FAILED);
965 break; 965 break;
966 966
967 case FSF_STATUS_READ_NOTIFICATION_LOST:
968 ZFCP_LOG_NORMAL("Unsolicited status notification(s) lost: "
969 "adapter %s%s%s%s%s%s%s%s%s\n",
970 zfcp_get_busid_by_adapter(adapter),
971 (status_buffer->status_subtype &
972 FSF_STATUS_READ_SUB_INCOMING_ELS) ?
973 ", incoming ELS" : "",
974 (status_buffer->status_subtype &
975 FSF_STATUS_READ_SUB_SENSE_DATA) ?
976 ", sense data" : "",
977 (status_buffer->status_subtype &
978 FSF_STATUS_READ_SUB_LINK_STATUS) ?
979 ", link status change" : "",
980 (status_buffer->status_subtype &
981 FSF_STATUS_READ_SUB_PORT_CLOSED) ?
982 ", port close" : "",
983 (status_buffer->status_subtype &
984 FSF_STATUS_READ_SUB_BIT_ERROR_THRESHOLD) ?
985 ", bit error exception" : "",
986 (status_buffer->status_subtype &
987 FSF_STATUS_READ_SUB_ACT_UPDATED) ?
988 ", ACT update" : "",
989 (status_buffer->status_subtype &
990 FSF_STATUS_READ_SUB_ACT_HARDENED) ?
991 ", ACT hardening" : "",
992 (status_buffer->status_subtype &
993 FSF_STATUS_READ_SUB_FEATURE_UPDATE_ALERT) ?
994 ", adapter feature change" : "");
995
996 if (status_buffer->status_subtype &
997 FSF_STATUS_READ_SUB_ACT_UPDATED)
998 zfcp_erp_adapter_access_changed(adapter);
999 break;
1000
967 case FSF_STATUS_READ_CFDC_UPDATED: 1001 case FSF_STATUS_READ_CFDC_UPDATED:
968 ZFCP_LOG_NORMAL("CFDC has been updated on the adapter %s\n", 1002 ZFCP_LOG_NORMAL("CFDC has been updated on the adapter %s\n",
969 zfcp_get_busid_by_adapter(adapter)); 1003 zfcp_get_busid_by_adapter(adapter));
@@ -1954,6 +1988,7 @@ zfcp_fsf_exchange_config_data(struct zfcp_erp_action *erp_action)
1954 erp_action->fsf_req->qtcb->bottom.config.feature_selection = 1988 erp_action->fsf_req->qtcb->bottom.config.feature_selection =
1955 FSF_FEATURE_CFDC | 1989 FSF_FEATURE_CFDC |
1956 FSF_FEATURE_LUN_SHARING | 1990 FSF_FEATURE_LUN_SHARING |
1991 FSF_FEATURE_NOTIFICATION_LOST |
1957 FSF_FEATURE_UPDATE_ALERT; 1992 FSF_FEATURE_UPDATE_ALERT;
1958 1993
1959 /* start QDIO request for this FSF request */ 1994 /* start QDIO request for this FSF request */
@@ -2008,27 +2043,30 @@ zfcp_fsf_exchange_config_evaluate(struct zfcp_fsf_req *fsf_req, int xchg_ok)
2008 fc_host_port_id(shost) = bottom->s_id & ZFCP_DID_MASK; 2043 fc_host_port_id(shost) = bottom->s_id & ZFCP_DID_MASK;
2009 fc_host_speed(shost) = bottom->fc_link_speed; 2044 fc_host_speed(shost) = bottom->fc_link_speed;
2010 fc_host_supported_classes(shost) = FC_COS_CLASS2 | FC_COS_CLASS3; 2045 fc_host_supported_classes(shost) = FC_COS_CLASS2 | FC_COS_CLASS3;
2011 adapter->fc_topology = bottom->fc_topology;
2012 adapter->hydra_version = bottom->adapter_type; 2046 adapter->hydra_version = bottom->adapter_type;
2013 if (adapter->physical_wwpn == 0) 2047 if (fc_host_permanent_port_name(shost) == -1)
2014 adapter->physical_wwpn = fc_host_port_name(shost); 2048 fc_host_permanent_port_name(shost) =
2015 if (adapter->physical_s_id == 0) 2049 fc_host_port_name(shost);
2016 adapter->physical_s_id = fc_host_port_id(shost); 2050 if (bottom->fc_topology == FSF_TOPO_P2P) {
2051 adapter->peer_d_id = bottom->peer_d_id & ZFCP_DID_MASK;
2052 adapter->peer_wwpn = bottom->plogi_payload.wwpn;
2053 adapter->peer_wwnn = bottom->plogi_payload.wwnn;
2054 fc_host_port_type(shost) = FC_PORTTYPE_PTP;
2055 } else if (bottom->fc_topology == FSF_TOPO_FABRIC)
2056 fc_host_port_type(shost) = FC_PORTTYPE_NPORT;
2057 else if (bottom->fc_topology == FSF_TOPO_AL)
2058 fc_host_port_type(shost) = FC_PORTTYPE_NLPORT;
2059 else
2060 fc_host_port_type(shost) = FC_PORTTYPE_UNKNOWN;
2017 } else { 2061 } else {
2018 fc_host_node_name(shost) = 0; 2062 fc_host_node_name(shost) = 0;
2019 fc_host_port_name(shost) = 0; 2063 fc_host_port_name(shost) = 0;
2020 fc_host_port_id(shost) = 0; 2064 fc_host_port_id(shost) = 0;
2021 fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN; 2065 fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN;
2022 adapter->fc_topology = 0; 2066 fc_host_port_type(shost) = FC_PORTTYPE_UNKNOWN;
2023 adapter->hydra_version = 0; 2067 adapter->hydra_version = 0;
2024 } 2068 }
2025 2069
2026 if (adapter->fc_topology == FSF_TOPO_P2P) {
2027 adapter->peer_d_id = bottom->peer_d_id & ZFCP_DID_MASK;
2028 adapter->peer_wwpn = bottom->plogi_payload.wwpn;
2029 adapter->peer_wwnn = bottom->plogi_payload.wwnn;
2030 }
2031
2032 if (adapter->adapter_features & FSF_FEATURE_HBAAPI_MANAGEMENT) { 2070 if (adapter->adapter_features & FSF_FEATURE_HBAAPI_MANAGEMENT) {
2033 adapter->hardware_version = bottom->hardware_version; 2071 adapter->hardware_version = bottom->hardware_version;
2034 memcpy(fc_host_serial_number(shost), bottom->serial_number, 2072 memcpy(fc_host_serial_number(shost), bottom->serial_number,
@@ -2097,8 +2135,8 @@ zfcp_fsf_exchange_config_data_handler(struct zfcp_fsf_req *fsf_req)
2097 if (zfcp_fsf_exchange_config_evaluate(fsf_req, 1)) 2135 if (zfcp_fsf_exchange_config_evaluate(fsf_req, 1))
2098 return -EIO; 2136 return -EIO;
2099 2137
2100 switch (adapter->fc_topology) { 2138 switch (fc_host_port_type(adapter->scsi_host)) {
2101 case FSF_TOPO_P2P: 2139 case FC_PORTTYPE_PTP:
2102 ZFCP_LOG_NORMAL("Point-to-Point fibrechannel " 2140 ZFCP_LOG_NORMAL("Point-to-Point fibrechannel "
2103 "configuration detected at adapter %s\n" 2141 "configuration detected at adapter %s\n"
2104 "Peer WWNN 0x%016llx, " 2142 "Peer WWNN 0x%016llx, "
@@ -2111,7 +2149,7 @@ zfcp_fsf_exchange_config_data_handler(struct zfcp_fsf_req *fsf_req)
2111 debug_text_event(fsf_req->adapter->erp_dbf, 0, 2149 debug_text_event(fsf_req->adapter->erp_dbf, 0,
2112 "top-p-to-p"); 2150 "top-p-to-p");
2113 break; 2151 break;
2114 case FSF_TOPO_AL: 2152 case FC_PORTTYPE_NLPORT:
2115 ZFCP_LOG_NORMAL("error: Arbitrated loop fibrechannel " 2153 ZFCP_LOG_NORMAL("error: Arbitrated loop fibrechannel "
2116 "topology detected at adapter %s " 2154 "topology detected at adapter %s "
2117 "unsupported, shutting down adapter\n", 2155 "unsupported, shutting down adapter\n",
@@ -2120,7 +2158,7 @@ zfcp_fsf_exchange_config_data_handler(struct zfcp_fsf_req *fsf_req)
2120 "top-al"); 2158 "top-al");
2121 zfcp_erp_adapter_shutdown(adapter, 0); 2159 zfcp_erp_adapter_shutdown(adapter, 0);
2122 return -EIO; 2160 return -EIO;
2123 case FSF_TOPO_FABRIC: 2161 case FC_PORTTYPE_NPORT:
2124 ZFCP_LOG_NORMAL("Switched fabric fibrechannel " 2162 ZFCP_LOG_NORMAL("Switched fabric fibrechannel "
2125 "network detected at adapter %s.\n", 2163 "network detected at adapter %s.\n",
2126 zfcp_get_busid_by_adapter(adapter)); 2164 zfcp_get_busid_by_adapter(adapter));
@@ -2133,7 +2171,6 @@ zfcp_fsf_exchange_config_data_handler(struct zfcp_fsf_req *fsf_req)
2133 "of a type known to the zfcp " 2171 "of a type known to the zfcp "
2134 "driver, shutting down adapter\n", 2172 "driver, shutting down adapter\n",
2135 zfcp_get_busid_by_adapter(adapter)); 2173 zfcp_get_busid_by_adapter(adapter));
2136 adapter->fc_topology = FSF_TOPO_ERROR;
2137 debug_text_exception(fsf_req->adapter->erp_dbf, 0, 2174 debug_text_exception(fsf_req->adapter->erp_dbf, 0,
2138 "unknown-topo"); 2175 "unknown-topo");
2139 zfcp_erp_adapter_shutdown(adapter, 0); 2176 zfcp_erp_adapter_shutdown(adapter, 0);
@@ -2293,14 +2330,13 @@ zfcp_fsf_exchange_port_data_handler(struct zfcp_fsf_req *fsf_req)
2293 data = (struct fsf_qtcb_bottom_port*) fsf_req->data; 2330 data = (struct fsf_qtcb_bottom_port*) fsf_req->data;
2294 if (data) 2331 if (data)
2295 memcpy(data, bottom, sizeof(struct fsf_qtcb_bottom_port)); 2332 memcpy(data, bottom, sizeof(struct fsf_qtcb_bottom_port));
2296 if (adapter->connection_features & FSF_FEATURE_NPIV_MODE) { 2333 if (adapter->connection_features & FSF_FEATURE_NPIV_MODE)
2297 adapter->physical_wwpn = bottom->wwpn; 2334 fc_host_permanent_port_name(shost) = bottom->wwpn;
2298 adapter->physical_s_id = bottom->fc_port_id; 2335 else
2299 } else { 2336 fc_host_permanent_port_name(shost) =
2300 adapter->physical_wwpn = fc_host_port_name(shost); 2337 fc_host_port_name(shost);
2301 adapter->physical_s_id = fc_host_port_id(shost);
2302 }
2303 fc_host_maxframe_size(shost) = bottom->maximum_frame_size; 2338 fc_host_maxframe_size(shost) = bottom->maximum_frame_size;
2339 fc_host_supported_speeds(shost) = bottom->supported_speed;
2304 break; 2340 break;
2305 2341
2306 case FSF_EXCHANGE_CONFIG_DATA_INCOMPLETE: 2342 case FSF_EXCHANGE_CONFIG_DATA_INCOMPLETE:
diff --git a/drivers/s390/scsi/zfcp_fsf.h b/drivers/s390/scsi/zfcp_fsf.h
index 48719f055952..e734415cae6d 100644
--- a/drivers/s390/scsi/zfcp_fsf.h
+++ b/drivers/s390/scsi/zfcp_fsf.h
@@ -166,6 +166,7 @@
166#define FSF_STATUS_READ_BIT_ERROR_THRESHOLD 0x00000004 166#define FSF_STATUS_READ_BIT_ERROR_THRESHOLD 0x00000004
167#define FSF_STATUS_READ_LINK_DOWN 0x00000005 167#define FSF_STATUS_READ_LINK_DOWN 0x00000005
168#define FSF_STATUS_READ_LINK_UP 0x00000006 168#define FSF_STATUS_READ_LINK_UP 0x00000006
169#define FSF_STATUS_READ_NOTIFICATION_LOST 0x00000009
169#define FSF_STATUS_READ_CFDC_UPDATED 0x0000000A 170#define FSF_STATUS_READ_CFDC_UPDATED 0x0000000A
170#define FSF_STATUS_READ_CFDC_HARDENED 0x0000000B 171#define FSF_STATUS_READ_CFDC_HARDENED 0x0000000B
171#define FSF_STATUS_READ_FEATURE_UPDATE_ALERT 0x0000000C 172#define FSF_STATUS_READ_FEATURE_UPDATE_ALERT 0x0000000C
@@ -179,6 +180,16 @@
179#define FSF_STATUS_READ_SUB_FDISC_FAILED 0x00000001 180#define FSF_STATUS_READ_SUB_FDISC_FAILED 0x00000001
180#define FSF_STATUS_READ_SUB_FIRMWARE_UPDATE 0x00000002 181#define FSF_STATUS_READ_SUB_FIRMWARE_UPDATE 0x00000002
181 182
183/* status subtypes for unsolicited status notification lost */
184#define FSF_STATUS_READ_SUB_INCOMING_ELS 0x00000001
185#define FSF_STATUS_READ_SUB_SENSE_DATA 0x00000002
186#define FSF_STATUS_READ_SUB_LINK_STATUS 0x00000004
187#define FSF_STATUS_READ_SUB_PORT_CLOSED 0x00000008
188#define FSF_STATUS_READ_SUB_BIT_ERROR_THRESHOLD 0x00000010
189#define FSF_STATUS_READ_SUB_ACT_UPDATED 0x00000020
190#define FSF_STATUS_READ_SUB_ACT_HARDENED 0x00000040
191#define FSF_STATUS_READ_SUB_FEATURE_UPDATE_ALERT 0x00000080
192
182/* status subtypes for CFDC */ 193/* status subtypes for CFDC */
183#define FSF_STATUS_READ_SUB_CFDC_HARDENED_ON_SE 0x00000002 194#define FSF_STATUS_READ_SUB_CFDC_HARDENED_ON_SE 0x00000002
184#define FSF_STATUS_READ_SUB_CFDC_HARDENED_ON_SE2 0x0000000F 195#define FSF_STATUS_READ_SUB_CFDC_HARDENED_ON_SE2 0x0000000F
@@ -188,7 +199,6 @@
188#define FSF_TOPO_P2P 0x00000001 199#define FSF_TOPO_P2P 0x00000001
189#define FSF_TOPO_FABRIC 0x00000002 200#define FSF_TOPO_FABRIC 0x00000002
190#define FSF_TOPO_AL 0x00000003 201#define FSF_TOPO_AL 0x00000003
191#define FSF_TOPO_FABRIC_VIRT 0x00000004
192 202
193/* data direction for FCP commands */ 203/* data direction for FCP commands */
194#define FSF_DATADIR_WRITE 0x00000001 204#define FSF_DATADIR_WRITE 0x00000001
@@ -211,6 +221,7 @@
211/* channel features */ 221/* channel features */
212#define FSF_FEATURE_CFDC 0x00000002 222#define FSF_FEATURE_CFDC 0x00000002
213#define FSF_FEATURE_LUN_SHARING 0x00000004 223#define FSF_FEATURE_LUN_SHARING 0x00000004
224#define FSF_FEATURE_NOTIFICATION_LOST 0x00000008
214#define FSF_FEATURE_HBAAPI_MANAGEMENT 0x00000010 225#define FSF_FEATURE_HBAAPI_MANAGEMENT 0x00000010
215#define FSF_FEATURE_ELS_CT_CHAINED_SBALS 0x00000020 226#define FSF_FEATURE_ELS_CT_CHAINED_SBALS 0x00000020
216#define FSF_FEATURE_UPDATE_ALERT 0x00000100 227#define FSF_FEATURE_UPDATE_ALERT 0x00000100
diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c
index 66608d13a634..3c2cbcccbf54 100644
--- a/drivers/s390/scsi/zfcp_scsi.c
+++ b/drivers/s390/scsi/zfcp_scsi.c
@@ -49,8 +49,6 @@ static int zfcp_task_management_function(struct zfcp_unit *, u8,
49 49
50static struct zfcp_unit *zfcp_unit_lookup(struct zfcp_adapter *, int, scsi_id_t, 50static struct zfcp_unit *zfcp_unit_lookup(struct zfcp_adapter *, int, scsi_id_t,
51 scsi_lun_t); 51 scsi_lun_t);
52static struct zfcp_port *zfcp_port_lookup(struct zfcp_adapter *, int,
53 scsi_id_t);
54 52
55static struct device_attribute *zfcp_sysfs_sdev_attrs[]; 53static struct device_attribute *zfcp_sysfs_sdev_attrs[];
56 54
@@ -406,18 +404,6 @@ zfcp_unit_lookup(struct zfcp_adapter *adapter, int channel, scsi_id_t id,
406 return retval; 404 return retval;
407} 405}
408 406
409static struct zfcp_port *
410zfcp_port_lookup(struct zfcp_adapter *adapter, int channel, scsi_id_t id)
411{
412 struct zfcp_port *port;
413
414 list_for_each_entry(port, &adapter->port_list_head, list) {
415 if (port->rport && (id == port->rport->scsi_target_id))
416 return port;
417 }
418 return (struct zfcp_port *) NULL;
419}
420
421/** 407/**
422 * zfcp_scsi_eh_abort_handler - abort the specified SCSI command 408 * zfcp_scsi_eh_abort_handler - abort the specified SCSI command
423 * @scpnt: pointer to scsi_cmnd to be aborted 409 * @scpnt: pointer to scsi_cmnd to be aborted
@@ -731,70 +717,164 @@ zfcp_fsf_start_scsi_er_timer(struct zfcp_adapter *adapter)
731/* 717/*
732 * Support functions for FC transport class 718 * Support functions for FC transport class
733 */ 719 */
734static void 720static struct fc_host_statistics*
735zfcp_get_port_id(struct scsi_target *starget) 721zfcp_init_fc_host_stats(struct zfcp_adapter *adapter)
736{ 722{
737 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); 723 struct fc_host_statistics *fc_stats;
738 struct zfcp_adapter *adapter = (struct zfcp_adapter *)shost->hostdata[0];
739 struct zfcp_port *port;
740 unsigned long flags;
741 724
742 read_lock_irqsave(&zfcp_data.config_lock, flags); 725 if (!adapter->fc_stats) {
743 port = zfcp_port_lookup(adapter, starget->channel, starget->id); 726 fc_stats = kmalloc(sizeof(*fc_stats), GFP_KERNEL);
744 if (port) 727 if (!fc_stats)
745 fc_starget_port_id(starget) = port->d_id; 728 return NULL;
746 else 729 adapter->fc_stats = fc_stats; /* freed in adater_dequeue */
747 fc_starget_port_id(starget) = -1; 730 }
748 read_unlock_irqrestore(&zfcp_data.config_lock, flags); 731 memset(adapter->fc_stats, 0, sizeof(*adapter->fc_stats));
732 return adapter->fc_stats;
749} 733}
750 734
751static void 735static void
752zfcp_get_port_name(struct scsi_target *starget) 736zfcp_adjust_fc_host_stats(struct fc_host_statistics *fc_stats,
737 struct fsf_qtcb_bottom_port *data,
738 struct fsf_qtcb_bottom_port *old)
753{ 739{
754 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); 740 fc_stats->seconds_since_last_reset = data->seconds_since_last_reset -
755 struct zfcp_adapter *adapter = (struct zfcp_adapter *)shost->hostdata[0]; 741 old->seconds_since_last_reset;
756 struct zfcp_port *port; 742 fc_stats->tx_frames = data->tx_frames - old->tx_frames;
757 unsigned long flags; 743 fc_stats->tx_words = data->tx_words - old->tx_words;
744 fc_stats->rx_frames = data->rx_frames - old->rx_frames;
745 fc_stats->rx_words = data->rx_words - old->rx_words;
746 fc_stats->lip_count = data->lip - old->lip;
747 fc_stats->nos_count = data->nos - old->nos;
748 fc_stats->error_frames = data->error_frames - old->error_frames;
749 fc_stats->dumped_frames = data->dumped_frames - old->dumped_frames;
750 fc_stats->link_failure_count = data->link_failure - old->link_failure;
751 fc_stats->loss_of_sync_count = data->loss_of_sync - old->loss_of_sync;
752 fc_stats->loss_of_signal_count = data->loss_of_signal -
753 old->loss_of_signal;
754 fc_stats->prim_seq_protocol_err_count = data->psp_error_counts -
755 old->psp_error_counts;
756 fc_stats->invalid_tx_word_count = data->invalid_tx_words -
757 old->invalid_tx_words;
758 fc_stats->invalid_crc_count = data->invalid_crcs - old->invalid_crcs;
759 fc_stats->fcp_input_requests = data->input_requests -
760 old->input_requests;
761 fc_stats->fcp_output_requests = data->output_requests -
762 old->output_requests;
763 fc_stats->fcp_control_requests = data->control_requests -
764 old->control_requests;
765 fc_stats->fcp_input_megabytes = data->input_mb - old->input_mb;
766 fc_stats->fcp_output_megabytes = data->output_mb - old->output_mb;
767}
758 768
759 read_lock_irqsave(&zfcp_data.config_lock, flags); 769static void
760 port = zfcp_port_lookup(adapter, starget->channel, starget->id); 770zfcp_set_fc_host_stats(struct fc_host_statistics *fc_stats,
761 if (port) 771 struct fsf_qtcb_bottom_port *data)
762 fc_starget_port_name(starget) = port->wwpn; 772{
763 else 773 fc_stats->seconds_since_last_reset = data->seconds_since_last_reset;
764 fc_starget_port_name(starget) = -1; 774 fc_stats->tx_frames = data->tx_frames;
765 read_unlock_irqrestore(&zfcp_data.config_lock, flags); 775 fc_stats->tx_words = data->tx_words;
776 fc_stats->rx_frames = data->rx_frames;
777 fc_stats->rx_words = data->rx_words;
778 fc_stats->lip_count = data->lip;
779 fc_stats->nos_count = data->nos;
780 fc_stats->error_frames = data->error_frames;
781 fc_stats->dumped_frames = data->dumped_frames;
782 fc_stats->link_failure_count = data->link_failure;
783 fc_stats->loss_of_sync_count = data->loss_of_sync;
784 fc_stats->loss_of_signal_count = data->loss_of_signal;
785 fc_stats->prim_seq_protocol_err_count = data->psp_error_counts;
786 fc_stats->invalid_tx_word_count = data->invalid_tx_words;
787 fc_stats->invalid_crc_count = data->invalid_crcs;
788 fc_stats->fcp_input_requests = data->input_requests;
789 fc_stats->fcp_output_requests = data->output_requests;
790 fc_stats->fcp_control_requests = data->control_requests;
791 fc_stats->fcp_input_megabytes = data->input_mb;
792 fc_stats->fcp_output_megabytes = data->output_mb;
793}
794
795/**
796 * zfcp_get_fc_host_stats - provide fc_host_statistics for scsi_transport_fc
797 *
798 * assumption: scsi_transport_fc synchronizes calls of
799 * get_fc_host_stats and reset_fc_host_stats
800 * (XXX to be checked otherwise introduce locking)
801 */
802static struct fc_host_statistics *
803zfcp_get_fc_host_stats(struct Scsi_Host *shost)
804{
805 struct zfcp_adapter *adapter;
806 struct fc_host_statistics *fc_stats;
807 struct fsf_qtcb_bottom_port *data;
808 int ret;
809
810 adapter = (struct zfcp_adapter *)shost->hostdata[0];
811 fc_stats = zfcp_init_fc_host_stats(adapter);
812 if (!fc_stats)
813 return NULL;
814
815 data = kmalloc(sizeof(*data), GFP_KERNEL);
816 if (!data)
817 return NULL;
818 memset(data, 0, sizeof(*data));
819
820 ret = zfcp_fsf_exchange_port_data(NULL, adapter, data);
821 if (ret) {
822 kfree(data);
823 return NULL; /* XXX return zeroed fc_stats? */
824 }
825
826 if (adapter->stats_reset &&
827 ((jiffies/HZ - adapter->stats_reset) <
828 data->seconds_since_last_reset)) {
829 zfcp_adjust_fc_host_stats(fc_stats, data,
830 adapter->stats_reset_data);
831 } else
832 zfcp_set_fc_host_stats(fc_stats, data);
833
834 kfree(data);
835 return fc_stats;
766} 836}
767 837
768static void 838static void
769zfcp_get_node_name(struct scsi_target *starget) 839zfcp_reset_fc_host_stats(struct Scsi_Host *shost)
770{ 840{
771 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); 841 struct zfcp_adapter *adapter;
772 struct zfcp_adapter *adapter = (struct zfcp_adapter *)shost->hostdata[0]; 842 struct fsf_qtcb_bottom_port *data, *old_data;
773 struct zfcp_port *port; 843 int ret;
774 unsigned long flags;
775 844
776 read_lock_irqsave(&zfcp_data.config_lock, flags); 845 adapter = (struct zfcp_adapter *)shost->hostdata[0];
777 port = zfcp_port_lookup(adapter, starget->channel, starget->id); 846 data = kmalloc(sizeof(*data), GFP_KERNEL);
778 if (port) 847 if (!data)
779 fc_starget_node_name(starget) = port->wwnn; 848 return;
780 else 849 memset(data, 0, sizeof(*data));
781 fc_starget_node_name(starget) = -1; 850
782 read_unlock_irqrestore(&zfcp_data.config_lock, flags); 851 ret = zfcp_fsf_exchange_port_data(NULL, adapter, data);
852 if (ret == 0) {
853 adapter->stats_reset = jiffies/HZ;
854 old_data = adapter->stats_reset_data;
855 adapter->stats_reset_data = data; /* finally freed in
856 adater_dequeue */
857 kfree(old_data);
858 }
783} 859}
784 860
785struct fc_function_template zfcp_transport_functions = { 861struct fc_function_template zfcp_transport_functions = {
786 .get_starget_port_id = zfcp_get_port_id,
787 .get_starget_port_name = zfcp_get_port_name,
788 .get_starget_node_name = zfcp_get_node_name,
789 .show_starget_port_id = 1, 862 .show_starget_port_id = 1,
790 .show_starget_port_name = 1, 863 .show_starget_port_name = 1,
791 .show_starget_node_name = 1, 864 .show_starget_node_name = 1,
792 .show_rport_supported_classes = 1, 865 .show_rport_supported_classes = 1,
793 .show_host_node_name = 1, 866 .show_host_node_name = 1,
794 .show_host_port_name = 1, 867 .show_host_port_name = 1,
868 .show_host_permanent_port_name = 1,
795 .show_host_supported_classes = 1, 869 .show_host_supported_classes = 1,
870 .show_host_supported_speeds = 1,
796 .show_host_maxframe_size = 1, 871 .show_host_maxframe_size = 1,
797 .show_host_serial_number = 1, 872 .show_host_serial_number = 1,
873 .get_fc_host_stats = zfcp_get_fc_host_stats,
874 .reset_fc_host_stats = zfcp_reset_fc_host_stats,
875 /* no functions registered for following dynamic attributes but
876 directly set by LLDD */
877 .show_host_port_type = 1,
798 .show_host_speed = 1, 878 .show_host_speed = 1,
799 .show_host_port_id = 1, 879 .show_host_port_id = 1,
800}; 880};
diff --git a/drivers/s390/scsi/zfcp_sysfs_adapter.c b/drivers/s390/scsi/zfcp_sysfs_adapter.c
index 0cd435280e7d..9f262250043a 100644
--- a/drivers/s390/scsi/zfcp_sysfs_adapter.c
+++ b/drivers/s390/scsi/zfcp_sysfs_adapter.c
@@ -33,14 +33,6 @@
33 33
34#define ZFCP_LOG_AREA ZFCP_LOG_AREA_CONFIG 34#define ZFCP_LOG_AREA ZFCP_LOG_AREA_CONFIG
35 35
36static const char fc_topologies[5][25] = {
37 "<error>",
38 "point-to-point",
39 "fabric",
40 "arbitrated loop",
41 "fabric (virt. adapter)"
42};
43
44/** 36/**
45 * ZFCP_DEFINE_ADAPTER_ATTR 37 * ZFCP_DEFINE_ADAPTER_ATTR
46 * @_name: name of show attribute 38 * @_name: name of show attribute
@@ -69,12 +61,8 @@ ZFCP_DEFINE_ADAPTER_ATTR(physical_wwpn, "0x%016llx\n", adapter->physical_wwpn);
69ZFCP_DEFINE_ADAPTER_ATTR(physical_s_id, "0x%06x\n", adapter->physical_s_id); 61ZFCP_DEFINE_ADAPTER_ATTR(physical_s_id, "0x%06x\n", adapter->physical_s_id);
70ZFCP_DEFINE_ADAPTER_ATTR(card_version, "0x%04x\n", adapter->hydra_version); 62ZFCP_DEFINE_ADAPTER_ATTR(card_version, "0x%04x\n", adapter->hydra_version);
71ZFCP_DEFINE_ADAPTER_ATTR(lic_version, "0x%08x\n", adapter->fsf_lic_version); 63ZFCP_DEFINE_ADAPTER_ATTR(lic_version, "0x%08x\n", adapter->fsf_lic_version);
72ZFCP_DEFINE_ADAPTER_ATTR(fc_service_class, "%d\n", adapter->fc_service_class);
73ZFCP_DEFINE_ADAPTER_ATTR(fc_topology, "%s\n",
74 fc_topologies[adapter->fc_topology]);
75ZFCP_DEFINE_ADAPTER_ATTR(hardware_version, "0x%08x\n", 64ZFCP_DEFINE_ADAPTER_ATTR(hardware_version, "0x%08x\n",
76 adapter->hardware_version); 65 adapter->hardware_version);
77ZFCP_DEFINE_ADAPTER_ATTR(scsi_host_no, "0x%x\n", adapter->scsi_host_no);
78ZFCP_DEFINE_ADAPTER_ATTR(in_recovery, "%d\n", atomic_test_mask 66ZFCP_DEFINE_ADAPTER_ATTR(in_recovery, "%d\n", atomic_test_mask
79 (ZFCP_STATUS_COMMON_ERP_INUSE, &adapter->status)); 67 (ZFCP_STATUS_COMMON_ERP_INUSE, &adapter->status));
80 68
@@ -259,9 +247,6 @@ static struct attribute *zfcp_adapter_attrs[] = {
259 &dev_attr_physical_s_id.attr, 247 &dev_attr_physical_s_id.attr,
260 &dev_attr_card_version.attr, 248 &dev_attr_card_version.attr,
261 &dev_attr_lic_version.attr, 249 &dev_attr_lic_version.attr,
262 &dev_attr_fc_service_class.attr,
263 &dev_attr_fc_topology.attr,
264 &dev_attr_scsi_host_no.attr,
265 &dev_attr_status.attr, 250 &dev_attr_status.attr,
266 &dev_attr_hardware_version.attr, 251 &dev_attr_hardware_version.attr,
267 NULL 252 NULL
diff --git a/drivers/s390/scsi/zfcp_sysfs_port.c b/drivers/s390/scsi/zfcp_sysfs_port.c
index c55e82d91deb..3924eb38805c 100644
--- a/drivers/s390/scsi/zfcp_sysfs_port.c
+++ b/drivers/s390/scsi/zfcp_sysfs_port.c
@@ -65,8 +65,6 @@ static ssize_t zfcp_sysfs_port_##_name##_show(struct device *dev, struct device_
65static DEVICE_ATTR(_name, S_IRUGO, zfcp_sysfs_port_##_name##_show, NULL); 65static DEVICE_ATTR(_name, S_IRUGO, zfcp_sysfs_port_##_name##_show, NULL);
66 66
67ZFCP_DEFINE_PORT_ATTR(status, "0x%08x\n", atomic_read(&port->status)); 67ZFCP_DEFINE_PORT_ATTR(status, "0x%08x\n", atomic_read(&port->status));
68ZFCP_DEFINE_PORT_ATTR(wwnn, "0x%016llx\n", port->wwnn);
69ZFCP_DEFINE_PORT_ATTR(d_id, "0x%06x\n", port->d_id);
70ZFCP_DEFINE_PORT_ATTR(in_recovery, "%d\n", atomic_test_mask 68ZFCP_DEFINE_PORT_ATTR(in_recovery, "%d\n", atomic_test_mask
71 (ZFCP_STATUS_COMMON_ERP_INUSE, &port->status)); 69 (ZFCP_STATUS_COMMON_ERP_INUSE, &port->status));
72ZFCP_DEFINE_PORT_ATTR(access_denied, "%d\n", atomic_test_mask 70ZFCP_DEFINE_PORT_ATTR(access_denied, "%d\n", atomic_test_mask
@@ -245,8 +243,6 @@ static struct attribute *zfcp_port_common_attrs[] = {
245 &dev_attr_failed.attr, 243 &dev_attr_failed.attr,
246 &dev_attr_in_recovery.attr, 244 &dev_attr_in_recovery.attr,
247 &dev_attr_status.attr, 245 &dev_attr_status.attr,
248 &dev_attr_wwnn.attr,
249 &dev_attr_d_id.attr,
250 &dev_attr_access_denied.attr, 246 &dev_attr_access_denied.attr,
251 NULL 247 NULL
252}; 248};
diff --git a/drivers/s390/scsi/zfcp_sysfs_unit.c b/drivers/s390/scsi/zfcp_sysfs_unit.c
index 0556642c9e1d..2f50815f65c7 100644
--- a/drivers/s390/scsi/zfcp_sysfs_unit.c
+++ b/drivers/s390/scsi/zfcp_sysfs_unit.c
@@ -65,7 +65,6 @@ static ssize_t zfcp_sysfs_unit_##_name##_show(struct device *dev, struct device_
65static DEVICE_ATTR(_name, S_IRUGO, zfcp_sysfs_unit_##_name##_show, NULL); 65static DEVICE_ATTR(_name, S_IRUGO, zfcp_sysfs_unit_##_name##_show, NULL);
66 66
67ZFCP_DEFINE_UNIT_ATTR(status, "0x%08x\n", atomic_read(&unit->status)); 67ZFCP_DEFINE_UNIT_ATTR(status, "0x%08x\n", atomic_read(&unit->status));
68ZFCP_DEFINE_UNIT_ATTR(scsi_lun, "0x%x\n", unit->scsi_lun);
69ZFCP_DEFINE_UNIT_ATTR(in_recovery, "%d\n", atomic_test_mask 68ZFCP_DEFINE_UNIT_ATTR(in_recovery, "%d\n", atomic_test_mask
70 (ZFCP_STATUS_COMMON_ERP_INUSE, &unit->status)); 69 (ZFCP_STATUS_COMMON_ERP_INUSE, &unit->status));
71ZFCP_DEFINE_UNIT_ATTR(access_denied, "%d\n", atomic_test_mask 70ZFCP_DEFINE_UNIT_ATTR(access_denied, "%d\n", atomic_test_mask
@@ -138,7 +137,6 @@ static DEVICE_ATTR(failed, S_IWUSR | S_IRUGO, zfcp_sysfs_unit_failed_show,
138 zfcp_sysfs_unit_failed_store); 137 zfcp_sysfs_unit_failed_store);
139 138
140static struct attribute *zfcp_unit_attrs[] = { 139static struct attribute *zfcp_unit_attrs[] = {
141 &dev_attr_scsi_lun.attr,
142 &dev_attr_failed.attr, 140 &dev_attr_failed.attr,
143 &dev_attr_in_recovery.attr, 141 &dev_attr_in_recovery.attr,
144 &dev_attr_status.attr, 142 &dev_attr_status.attr,
diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
index 3ff74f472249..31c497542272 100644
--- a/drivers/scsi/3w-9xxx.c
+++ b/drivers/scsi/3w-9xxx.c
@@ -73,6 +73,7 @@
73#include <linux/delay.h> 73#include <linux/delay.h>
74#include <linux/pci.h> 74#include <linux/pci.h>
75#include <linux/time.h> 75#include <linux/time.h>
76#include <linux/mutex.h>
76#include <asm/io.h> 77#include <asm/io.h>
77#include <asm/irq.h> 78#include <asm/irq.h>
78#include <asm/uaccess.h> 79#include <asm/uaccess.h>
@@ -615,7 +616,7 @@ static int twa_chrdev_ioctl(struct inode *inode, struct file *file, unsigned int
615 void __user *argp = (void __user *)arg; 616 void __user *argp = (void __user *)arg;
616 617
617 /* Only let one of these through at a time */ 618 /* Only let one of these through at a time */
618 if (down_interruptible(&tw_dev->ioctl_sem)) { 619 if (mutex_lock_interruptible(&tw_dev->ioctl_lock)) {
619 retval = TW_IOCTL_ERROR_OS_EINTR; 620 retval = TW_IOCTL_ERROR_OS_EINTR;
620 goto out; 621 goto out;
621 } 622 }
@@ -852,7 +853,7 @@ out3:
852 /* Now free ioctl buf memory */ 853 /* Now free ioctl buf memory */
853 dma_free_coherent(&tw_dev->tw_pci_dev->dev, data_buffer_length_adjusted+sizeof(TW_Ioctl_Buf_Apache) - 1, cpu_addr, dma_handle); 854 dma_free_coherent(&tw_dev->tw_pci_dev->dev, data_buffer_length_adjusted+sizeof(TW_Ioctl_Buf_Apache) - 1, cpu_addr, dma_handle);
854out2: 855out2:
855 up(&tw_dev->ioctl_sem); 856 mutex_unlock(&tw_dev->ioctl_lock);
856out: 857out:
857 return retval; 858 return retval;
858} /* End twa_chrdev_ioctl() */ 859} /* End twa_chrdev_ioctl() */
@@ -1182,7 +1183,7 @@ static int twa_initialize_device_extension(TW_Device_Extension *tw_dev)
1182 tw_dev->error_sequence_id = 1; 1183 tw_dev->error_sequence_id = 1;
1183 tw_dev->chrdev_request_id = TW_IOCTL_CHRDEV_FREE; 1184 tw_dev->chrdev_request_id = TW_IOCTL_CHRDEV_FREE;
1184 1185
1185 init_MUTEX(&tw_dev->ioctl_sem); 1186 mutex_init(&tw_dev->ioctl_lock);
1186 init_waitqueue_head(&tw_dev->ioctl_wqueue); 1187 init_waitqueue_head(&tw_dev->ioctl_wqueue);
1187 1188
1188 retval = 0; 1189 retval = 0;
diff --git a/drivers/scsi/3w-9xxx.h b/drivers/scsi/3w-9xxx.h
index 46f22cdc8298..1b16d57f0314 100644
--- a/drivers/scsi/3w-9xxx.h
+++ b/drivers/scsi/3w-9xxx.h
@@ -672,7 +672,7 @@ typedef struct TAG_TW_Device_Extension {
672 u32 ioctl_msec; 672 u32 ioctl_msec;
673 int chrdev_request_id; 673 int chrdev_request_id;
674 wait_queue_head_t ioctl_wqueue; 674 wait_queue_head_t ioctl_wqueue;
675 struct semaphore ioctl_sem; 675 struct mutex ioctl_lock;
676 char aen_clobber; 676 char aen_clobber;
677 unsigned short working_srl; 677 unsigned short working_srl;
678 unsigned short working_branch; 678 unsigned short working_branch;
diff --git a/drivers/scsi/3w-xxxx.c b/drivers/scsi/3w-xxxx.c
index 283f6d25892b..25f678d0780b 100644
--- a/drivers/scsi/3w-xxxx.c
+++ b/drivers/scsi/3w-xxxx.c
@@ -203,6 +203,7 @@
203#include <linux/delay.h> 203#include <linux/delay.h>
204#include <linux/pci.h> 204#include <linux/pci.h>
205#include <linux/time.h> 205#include <linux/time.h>
206#include <linux/mutex.h>
206#include <asm/io.h> 207#include <asm/io.h>
207#include <asm/irq.h> 208#include <asm/irq.h>
208#include <asm/uaccess.h> 209#include <asm/uaccess.h>
@@ -888,7 +889,7 @@ static int tw_chrdev_ioctl(struct inode *inode, struct file *file, unsigned int
888 dprintk(KERN_WARNING "3w-xxxx: tw_chrdev_ioctl()\n"); 889 dprintk(KERN_WARNING "3w-xxxx: tw_chrdev_ioctl()\n");
889 890
890 /* Only let one of these through at a time */ 891 /* Only let one of these through at a time */
891 if (down_interruptible(&tw_dev->ioctl_sem)) 892 if (mutex_lock_interruptible(&tw_dev->ioctl_lock))
892 return -EINTR; 893 return -EINTR;
893 894
894 /* First copy down the buffer length */ 895 /* First copy down the buffer length */
@@ -1029,7 +1030,7 @@ out2:
1029 /* Now free ioctl buf memory */ 1030 /* Now free ioctl buf memory */
1030 dma_free_coherent(&tw_dev->tw_pci_dev->dev, data_buffer_length_adjusted+sizeof(TW_New_Ioctl) - 1, cpu_addr, dma_handle); 1031 dma_free_coherent(&tw_dev->tw_pci_dev->dev, data_buffer_length_adjusted+sizeof(TW_New_Ioctl) - 1, cpu_addr, dma_handle);
1031out: 1032out:
1032 up(&tw_dev->ioctl_sem); 1033 mutex_unlock(&tw_dev->ioctl_lock);
1033 return retval; 1034 return retval;
1034} /* End tw_chrdev_ioctl() */ 1035} /* End tw_chrdev_ioctl() */
1035 1036
@@ -1270,7 +1271,7 @@ static int tw_initialize_device_extension(TW_Device_Extension *tw_dev)
1270 tw_dev->pending_tail = TW_Q_START; 1271 tw_dev->pending_tail = TW_Q_START;
1271 tw_dev->chrdev_request_id = TW_IOCTL_CHRDEV_FREE; 1272 tw_dev->chrdev_request_id = TW_IOCTL_CHRDEV_FREE;
1272 1273
1273 init_MUTEX(&tw_dev->ioctl_sem); 1274 mutex_init(&tw_dev->ioctl_lock);
1274 init_waitqueue_head(&tw_dev->ioctl_wqueue); 1275 init_waitqueue_head(&tw_dev->ioctl_wqueue);
1275 1276
1276 return 0; 1277 return 0;
diff --git a/drivers/scsi/3w-xxxx.h b/drivers/scsi/3w-xxxx.h
index 4f81fc39ec57..31fe5ea15920 100644
--- a/drivers/scsi/3w-xxxx.h
+++ b/drivers/scsi/3w-xxxx.h
@@ -420,7 +420,7 @@ typedef struct TAG_TW_Device_Extension {
420 u32 max_sector_count; 420 u32 max_sector_count;
421 u32 aen_count; 421 u32 aen_count;
422 struct Scsi_Host *host; 422 struct Scsi_Host *host;
423 struct semaphore ioctl_sem; 423 struct mutex ioctl_lock;
424 unsigned short aen_queue[TW_Q_LENGTH]; 424 unsigned short aen_queue[TW_Q_LENGTH];
425 unsigned char aen_head; 425 unsigned char aen_head;
426 unsigned char aen_tail; 426 unsigned char aen_tail;
diff --git a/drivers/scsi/BusLogic.c b/drivers/scsi/BusLogic.c
index 9d6040bfa064..1c459343292b 100644
--- a/drivers/scsi/BusLogic.c
+++ b/drivers/scsi/BusLogic.c
@@ -2216,6 +2216,7 @@ static int __init BusLogic_init(void)
2216 HostAdapter->PCI_Address = ProbeInfo->PCI_Address; 2216 HostAdapter->PCI_Address = ProbeInfo->PCI_Address;
2217 HostAdapter->Bus = ProbeInfo->Bus; 2217 HostAdapter->Bus = ProbeInfo->Bus;
2218 HostAdapter->Device = ProbeInfo->Device; 2218 HostAdapter->Device = ProbeInfo->Device;
2219 HostAdapter->PCI_Device = ProbeInfo->PCI_Device;
2219 HostAdapter->IRQ_Channel = ProbeInfo->IRQ_Channel; 2220 HostAdapter->IRQ_Channel = ProbeInfo->IRQ_Channel;
2220 HostAdapter->AddressCount = BusLogic_HostAdapterAddressCount[HostAdapter->HostAdapterType]; 2221 HostAdapter->AddressCount = BusLogic_HostAdapterAddressCount[HostAdapter->HostAdapterType];
2221 /* 2222 /*
@@ -2296,7 +2297,7 @@ static int __init BusLogic_init(void)
2296 scsi_host_put(Host); 2297 scsi_host_put(Host);
2297 } else { 2298 } else {
2298 BusLogic_InitializeHostStructure(HostAdapter, Host); 2299 BusLogic_InitializeHostStructure(HostAdapter, Host);
2299 scsi_add_host(Host, NULL); 2300 scsi_add_host(Host, HostAdapter->PCI_Device ? &HostAdapter->PCI_Device->dev : NULL);
2300 scsi_scan_host(Host); 2301 scsi_scan_host(Host);
2301 BusLogicHostAdapterCount++; 2302 BusLogicHostAdapterCount++;
2302 } 2303 }
diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile
index 6e0c059df6a5..320e765fa0cd 100644
--- a/drivers/scsi/Makefile
+++ b/drivers/scsi/Makefile
@@ -80,7 +80,7 @@ obj-$(CONFIG_SCSI_QLOGIC_FAS) += qlogicfas408.o qlogicfas.o
80obj-$(CONFIG_PCMCIA_QLOGIC) += qlogicfas408.o 80obj-$(CONFIG_PCMCIA_QLOGIC) += qlogicfas408.o
81obj-$(CONFIG_SCSI_QLOGIC_FC) += qlogicfc.o 81obj-$(CONFIG_SCSI_QLOGIC_FC) += qlogicfc.o
82obj-$(CONFIG_SCSI_QLOGIC_1280) += qla1280.o 82obj-$(CONFIG_SCSI_QLOGIC_1280) += qla1280.o
83obj-$(CONFIG_SCSI_QLA2XXX) += qla2xxx/ 83obj-$(CONFIG_SCSI_QLA_FC) += qla2xxx/
84obj-$(CONFIG_SCSI_LPFC) += lpfc/ 84obj-$(CONFIG_SCSI_LPFC) += lpfc/
85obj-$(CONFIG_SCSI_PAS16) += pas16.o 85obj-$(CONFIG_SCSI_PAS16) += pas16.o
86obj-$(CONFIG_SCSI_SEAGATE) += seagate.o 86obj-$(CONFIG_SCSI_SEAGATE) += seagate.o
diff --git a/drivers/scsi/aacraid/README b/drivers/scsi/aacraid/README
deleted file mode 100644
index 4193865d419c..000000000000
--- a/drivers/scsi/aacraid/README
+++ /dev/null
@@ -1,74 +0,0 @@
1AACRAID Driver for Linux (take two)
2
3Introduction
4-------------------------
5The aacraid driver adds support for Adaptec (http://www.adaptec.com)
6RAID controllers. This is a major rewrite from the original
7Adaptec supplied driver. It has signficantly cleaned up both the code
8and the running binary size (the module is less than half the size of
9the original).
10
11Supported Cards/Chipsets
12-------------------------
13 Adaptec 2020S
14 Adaptec 2025S
15 Adaptec 2120S
16 Adaptec 2130S
17 Adaptec 2200S
18 Adaptec 2230S
19 Adaptec 2240S
20 Adaptec 2410SA
21 Adaptec 2610SA
22 Adaptec 2810SA
23 Adaptec 21610SA
24 Adaptec 3230S
25 Adaptec 3240S
26 Adaptec 4000SAS
27 Adaptec 4005SAS
28 Adaptec 4800SAS
29 Adaptec 4805SAS
30 Adaptec 5400S
31 Dell PERC 2 Quad Channel
32 Dell PERC 2/Si
33 Dell PERC 3/Si
34 Dell PERC 3/Di
35 Dell CERC 2
36 HP NetRAID-4M
37 Legend S220
38 Legend S230
39 IBM ServeRAID 8i
40 ICP 9014R0
41 ICP 9024R0
42 ICP 9047MA
43 ICP 9087MA
44 ICP 9085LI
45 ICP 5085AU
46
47People
48-------------------------
49Alan Cox <alan@redhat.com>
50Christoph Hellwig <hch@infradead.org> (updates for new-style PCI probing and SCSI host registration,
51 small cleanups/fixes)
52Matt Domsch <matt_domsch@dell.com> (revision ioctl, adapter messages)
53Deanna Bonds (non-DASD support, PAE fibs and 64 bit, added new adaptec controllers
54 added new ioctls, changed scsi interface to use new error handler,
55 increased the number of fibs and outstanding commands to a container)
56
57 (fixed 64bit and 64G memory model, changed confusing naming convention
58 where fibs that go to the hardware are consistently called hw_fibs and
59 not just fibs like the name of the driver tracking structure)
60Mark Salyzyn <Mark_Salyzyn@adaptec.com> Fixed panic issues and added some new product ids for upcoming hbas. Performance tuning, card failover and bug mitigations.
61
62Original Driver
63-------------------------
64Adaptec Unix OEM Product Group
65
66Mailing List
67-------------------------
68linux-scsi@vger.kernel.org (Interested parties troll here)
69Also note this is very different to Brian's original driver
70so don't expect him to support it.
71Adaptec does support this driver. Contact either tech support or Mark Salyzyn.
72
73Original by Brian Boerner February 2001
74Rewritten by Alan Cox, November 2001
diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h
index 30fd8d6e3f31..66dbb6d2c506 100644
--- a/drivers/scsi/aacraid/aacraid.h
+++ b/drivers/scsi/aacraid/aacraid.h
@@ -532,6 +532,13 @@ struct aac_driver_ident
532#define AAC_QUIRK_MASTER 0x0008 532#define AAC_QUIRK_MASTER 0x0008
533 533
534/* 534/*
535 * Some adapter firmware perform poorly when it must split up scatter gathers
536 * in order to deal with the limits of the underlying CHIM. This limit in this
537 * class of adapters is 17 scatter gather elements.
538 */
539#define AAC_QUIRK_17SG 0x0010
540
541/*
535 * The adapter interface specs all queues to be located in the same 542 * The adapter interface specs all queues to be located in the same
536 * physically contigous block. The host structure that defines the 543 * physically contigous block. The host structure that defines the
537 * commuication queues will assume they are each a separate physically 544 * commuication queues will assume they are each a separate physically
diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c
index ef623bd965f5..4fe79cd7c957 100644
--- a/drivers/scsi/aacraid/commctrl.c
+++ b/drivers/scsi/aacraid/commctrl.c
@@ -85,6 +85,10 @@ static int ioctl_send_fib(struct aac_dev * dev, void __user *arg)
85 if (size < le16_to_cpu(kfib->header.SenderSize)) 85 if (size < le16_to_cpu(kfib->header.SenderSize))
86 size = le16_to_cpu(kfib->header.SenderSize); 86 size = le16_to_cpu(kfib->header.SenderSize);
87 if (size > dev->max_fib_size) { 87 if (size > dev->max_fib_size) {
88 if (size > 2048) {
89 retval = -EINVAL;
90 goto cleanup;
91 }
88 /* Highjack the hw_fib */ 92 /* Highjack the hw_fib */
89 hw_fib = fibptr->hw_fib; 93 hw_fib = fibptr->hw_fib;
90 hw_fib_pa = fibptr->hw_fib_pa; 94 hw_fib_pa = fibptr->hw_fib_pa;
diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c
index 9b9062f02462..0bf5f9a943e8 100644
--- a/drivers/scsi/aacraid/linit.c
+++ b/drivers/scsi/aacraid/linit.c
@@ -200,10 +200,10 @@ static struct aac_driver_ident aac_drivers[] = {
200 { aac_rkt_init, "aacraid", "ADAPTEC ", "Callisto ", 2, AAC_QUIRK_MASTER }, /* Jupiter Platform */ 200 { aac_rkt_init, "aacraid", "ADAPTEC ", "Callisto ", 2, AAC_QUIRK_MASTER }, /* Jupiter Platform */
201 { aac_rx_init, "aacraid", "ADAPTEC ", "ASR-2020SA ", 1 }, /* ASR-2020SA SATA PCI-X ZCR (Skyhawk) */ 201 { aac_rx_init, "aacraid", "ADAPTEC ", "ASR-2020SA ", 1 }, /* ASR-2020SA SATA PCI-X ZCR (Skyhawk) */
202 { aac_rx_init, "aacraid", "ADAPTEC ", "ASR-2025SA ", 1 }, /* ASR-2025SA SATA SO-DIMM PCI-X ZCR (Terminator) */ 202 { aac_rx_init, "aacraid", "ADAPTEC ", "ASR-2025SA ", 1 }, /* ASR-2025SA SATA SO-DIMM PCI-X ZCR (Terminator) */
203 { aac_rx_init, "aacraid", "ADAPTEC ", "AAR-2410SA SATA ", 1 }, /* AAR-2410SA PCI SATA 4ch (Jaguar II) */ 203 { aac_rx_init, "aacraid", "ADAPTEC ", "AAR-2410SA SATA ", 1, AAC_QUIRK_17SG }, /* AAR-2410SA PCI SATA 4ch (Jaguar II) */
204 { aac_rx_init, "aacraid", "DELL ", "CERC SR2 ", 1 }, /* CERC SATA RAID 2 PCI SATA 6ch (DellCorsair) */ 204 { aac_rx_init, "aacraid", "DELL ", "CERC SR2 ", 1, AAC_QUIRK_17SG }, /* CERC SATA RAID 2 PCI SATA 6ch (DellCorsair) */
205 { aac_rx_init, "aacraid", "ADAPTEC ", "AAR-2810SA SATA ", 1 }, /* AAR-2810SA PCI SATA 8ch (Corsair-8) */ 205 { aac_rx_init, "aacraid", "ADAPTEC ", "AAR-2810SA SATA ", 1, AAC_QUIRK_17SG }, /* AAR-2810SA PCI SATA 8ch (Corsair-8) */
206 { aac_rx_init, "aacraid", "ADAPTEC ", "AAR-21610SA SATA", 1 }, /* AAR-21610SA PCI SATA 16ch (Corsair-16) */ 206 { aac_rx_init, "aacraid", "ADAPTEC ", "AAR-21610SA SATA", 1, AAC_QUIRK_17SG }, /* AAR-21610SA PCI SATA 16ch (Corsair-16) */
207 { aac_rx_init, "aacraid", "ADAPTEC ", "ASR-2026ZCR ", 1 }, /* ESD SO-DIMM PCI-X SATA ZCR (Prowler) */ 207 { aac_rx_init, "aacraid", "ADAPTEC ", "ASR-2026ZCR ", 1 }, /* ESD SO-DIMM PCI-X SATA ZCR (Prowler) */
208 { aac_rx_init, "aacraid", "ADAPTEC ", "AAR-2610SA ", 1 }, /* SATA 6Ch (Bearcat) */ 208 { aac_rx_init, "aacraid", "ADAPTEC ", "AAR-2610SA ", 1 }, /* SATA 6Ch (Bearcat) */
209 { aac_rx_init, "aacraid", "ADAPTEC ", "ASR-2240S ", 1 }, /* ASR-2240S (SabreExpress) */ 209 { aac_rx_init, "aacraid", "ADAPTEC ", "ASR-2240S ", 1 }, /* ASR-2240S (SabreExpress) */
@@ -574,7 +574,15 @@ static ssize_t aac_show_model(struct class_device *class_dev,
574 struct aac_dev *dev = (struct aac_dev*)class_to_shost(class_dev)->hostdata; 574 struct aac_dev *dev = (struct aac_dev*)class_to_shost(class_dev)->hostdata;
575 int len; 575 int len;
576 576
577 len = snprintf(buf, PAGE_SIZE, "%s\n", 577 if (dev->supplement_adapter_info.AdapterTypeText[0]) {
578 char * cp = dev->supplement_adapter_info.AdapterTypeText;
579 while (*cp && *cp != ' ')
580 ++cp;
581 while (*cp == ' ')
582 ++cp;
583 len = snprintf(buf, PAGE_SIZE, "%s\n", cp);
584 } else
585 len = snprintf(buf, PAGE_SIZE, "%s\n",
578 aac_drivers[dev->cardtype].model); 586 aac_drivers[dev->cardtype].model);
579 return len; 587 return len;
580} 588}
@@ -585,7 +593,15 @@ static ssize_t aac_show_vendor(struct class_device *class_dev,
585 struct aac_dev *dev = (struct aac_dev*)class_to_shost(class_dev)->hostdata; 593 struct aac_dev *dev = (struct aac_dev*)class_to_shost(class_dev)->hostdata;
586 int len; 594 int len;
587 595
588 len = snprintf(buf, PAGE_SIZE, "%s\n", 596 if (dev->supplement_adapter_info.AdapterTypeText[0]) {
597 char * cp = dev->supplement_adapter_info.AdapterTypeText;
598 while (*cp && *cp != ' ')
599 ++cp;
600 len = snprintf(buf, PAGE_SIZE, "%.*s\n",
601 (int)(cp - (char *)dev->supplement_adapter_info.AdapterTypeText),
602 dev->supplement_adapter_info.AdapterTypeText);
603 } else
604 len = snprintf(buf, PAGE_SIZE, "%s\n",
589 aac_drivers[dev->cardtype].vname); 605 aac_drivers[dev->cardtype].vname);
590 return len; 606 return len;
591} 607}
@@ -837,6 +853,13 @@ static int __devinit aac_probe_one(struct pci_dev *pdev,
837 = (aac->scsi_host_ptr->sg_tablesize * 8) + 112; 853 = (aac->scsi_host_ptr->sg_tablesize * 8) + 112;
838 } 854 }
839 855
856 if ((aac_drivers[index].quirks & AAC_QUIRK_17SG) &&
857 (aac->scsi_host_ptr->sg_tablesize > 17)) {
858 aac->scsi_host_ptr->sg_tablesize = 17;
859 aac->scsi_host_ptr->max_sectors
860 = (aac->scsi_host_ptr->sg_tablesize * 8) + 112;
861 }
862
840 /* 863 /*
841 * Firware printf works only with older firmware. 864 * Firware printf works only with older firmware.
842 */ 865 */
diff --git a/drivers/scsi/aic7xxx/Kconfig.aic7xxx b/drivers/scsi/aic7xxx/Kconfig.aic7xxx
index ac8de03c9fa2..6c2c395554ff 100644
--- a/drivers/scsi/aic7xxx/Kconfig.aic7xxx
+++ b/drivers/scsi/aic7xxx/Kconfig.aic7xxx
@@ -42,13 +42,13 @@ config AIC7XXX_CMDS_PER_DEVICE
42config AIC7XXX_RESET_DELAY_MS 42config AIC7XXX_RESET_DELAY_MS
43 int "Initial bus reset delay in milli-seconds" 43 int "Initial bus reset delay in milli-seconds"
44 depends on SCSI_AIC7XXX 44 depends on SCSI_AIC7XXX
45 default "15000" 45 default "5000"
46 ---help--- 46 ---help---
47 The number of milliseconds to delay after an initial bus reset. 47 The number of milliseconds to delay after an initial bus reset.
48 The bus settle delay following all error recovery actions is 48 The bus settle delay following all error recovery actions is
49 dictated by the SCSI layer and is not affected by this value. 49 dictated by the SCSI layer and is not affected by this value.
50 50
51 Default: 15000 (15 seconds) 51 Default: 5000 (5 seconds)
52 52
53config AIC7XXX_PROBE_EISA_VL 53config AIC7XXX_PROBE_EISA_VL
54 bool "Probe for EISA and VL AIC7XXX Adapters" 54 bool "Probe for EISA and VL AIC7XXX Adapters"
diff --git a/drivers/scsi/aic7xxx/aic79xx.h b/drivers/scsi/aic7xxx/aic79xx.h
index 653fb0b42aea..2cfdbef447db 100644
--- a/drivers/scsi/aic7xxx/aic79xx.h
+++ b/drivers/scsi/aic7xxx/aic79xx.h
@@ -37,7 +37,7 @@
37 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 37 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38 * POSSIBILITY OF SUCH DAMAGES. 38 * POSSIBILITY OF SUCH DAMAGES.
39 * 39 *
40 * $Id: //depot/aic7xxx/aic7xxx/aic79xx.h#95 $ 40 * $Id: //depot/aic7xxx/aic7xxx/aic79xx.h#108 $
41 * 41 *
42 * $FreeBSD$ 42 * $FreeBSD$
43 */ 43 */
@@ -75,8 +75,7 @@ struct scb_platform_data;
75#define INITIATOR_WILDCARD (~0) 75#define INITIATOR_WILDCARD (~0)
76#define SCB_LIST_NULL 0xFF00 76#define SCB_LIST_NULL 0xFF00
77#define SCB_LIST_NULL_LE (ahd_htole16(SCB_LIST_NULL)) 77#define SCB_LIST_NULL_LE (ahd_htole16(SCB_LIST_NULL))
78#define QOUTFIFO_ENTRY_VALID 0x8000 78#define QOUTFIFO_ENTRY_VALID 0x80
79#define QOUTFIFO_ENTRY_VALID_LE (ahd_htole16(0x8000))
80#define SCBID_IS_NULL(scbid) (((scbid) & 0xFF00 ) == SCB_LIST_NULL) 79#define SCBID_IS_NULL(scbid) (((scbid) & 0xFF00 ) == SCB_LIST_NULL)
81 80
82#define SCSIID_TARGET(ahd, scsiid) \ 81#define SCSIID_TARGET(ahd, scsiid) \
@@ -1053,6 +1052,13 @@ typedef uint8_t ahd_mode_state;
1053 1052
1054typedef void ahd_callback_t (void *); 1053typedef void ahd_callback_t (void *);
1055 1054
1055struct ahd_completion
1056{
1057 uint16_t tag;
1058 uint8_t sg_status;
1059 uint8_t valid_tag;
1060};
1061
1056struct ahd_softc { 1062struct ahd_softc {
1057 bus_space_tag_t tags[2]; 1063 bus_space_tag_t tags[2];
1058 bus_space_handle_t bshs[2]; 1064 bus_space_handle_t bshs[2];
@@ -1062,6 +1068,7 @@ struct ahd_softc {
1062 struct scb_data scb_data; 1068 struct scb_data scb_data;
1063 1069
1064 struct hardware_scb *next_queued_hscb; 1070 struct hardware_scb *next_queued_hscb;
1071 struct map_node *next_queued_hscb_map;
1065 1072
1066 /* 1073 /*
1067 * SCBs that have been sent to the controller 1074 * SCBs that have been sent to the controller
@@ -1140,16 +1147,23 @@ struct ahd_softc {
1140 ahd_flag flags; 1147 ahd_flag flags;
1141 struct seeprom_config *seep_config; 1148 struct seeprom_config *seep_config;
1142 1149
1143 /* Values to store in the SEQCTL register for pause and unpause */
1144 uint8_t unpause;
1145 uint8_t pause;
1146
1147 /* Command Queues */ 1150 /* Command Queues */
1151 struct ahd_completion *qoutfifo;
1148 uint16_t qoutfifonext; 1152 uint16_t qoutfifonext;
1149 uint16_t qoutfifonext_valid_tag; 1153 uint16_t qoutfifonext_valid_tag;
1150 uint16_t qinfifonext; 1154 uint16_t qinfifonext;
1151 uint16_t qinfifo[AHD_SCB_MAX]; 1155 uint16_t qinfifo[AHD_SCB_MAX];
1152 uint16_t *qoutfifo; 1156
1157 /*
1158 * Our qfreeze count. The sequencer compares
1159 * this value with its own counter to determine
1160 * whether to allow selections to occur.
1161 */
1162 uint16_t qfreeze_cnt;
1163
1164 /* Values to store in the SEQCTL register for pause and unpause */
1165 uint8_t unpause;
1166 uint8_t pause;
1153 1167
1154 /* Critical Section Data */ 1168 /* Critical Section Data */
1155 struct cs *critical_sections; 1169 struct cs *critical_sections;
@@ -1197,8 +1211,7 @@ struct ahd_softc {
1197 */ 1211 */
1198 bus_dma_tag_t parent_dmat; 1212 bus_dma_tag_t parent_dmat;
1199 bus_dma_tag_t shared_data_dmat; 1213 bus_dma_tag_t shared_data_dmat;
1200 bus_dmamap_t shared_data_dmamap; 1214 struct map_node shared_data_map;
1201 dma_addr_t shared_data_busaddr;
1202 1215
1203 /* Information saved through suspend/resume cycles */ 1216 /* Information saved through suspend/resume cycles */
1204 struct ahd_suspend_state suspend_state; 1217 struct ahd_suspend_state suspend_state;
@@ -1296,9 +1309,9 @@ struct ahd_devinfo {
1296}; 1309};
1297 1310
1298/****************************** PCI Structures ********************************/ 1311/****************************** PCI Structures ********************************/
1299#define AHD_PCI_IOADDR0 PCIR_MAPS /* I/O BAR*/ 1312#define AHD_PCI_IOADDR0 PCIR_BAR(0) /* I/O BAR*/
1300#define AHD_PCI_MEMADDR (PCIR_MAPS + 4) /* Memory BAR */ 1313#define AHD_PCI_MEMADDR PCIR_BAR(1) /* Memory BAR */
1301#define AHD_PCI_IOADDR1 (PCIR_MAPS + 12)/* Second I/O BAR */ 1314#define AHD_PCI_IOADDR1 PCIR_BAR(3) /* Second I/O BAR */
1302 1315
1303typedef int (ahd_device_setup_t)(struct ahd_softc *); 1316typedef int (ahd_device_setup_t)(struct ahd_softc *);
1304 1317
diff --git a/drivers/scsi/aic7xxx/aic79xx.reg b/drivers/scsi/aic7xxx/aic79xx.reg
index cca58edc8648..3a3204703b15 100644
--- a/drivers/scsi/aic7xxx/aic79xx.reg
+++ b/drivers/scsi/aic7xxx/aic79xx.reg
@@ -39,7 +39,7 @@
39 * 39 *
40 * $FreeBSD$ 40 * $FreeBSD$
41 */ 41 */
42VERSION = "$Id: //depot/aic7xxx/aic7xxx/aic79xx.reg#70 $" 42VERSION = "$Id: //depot/aic7xxx/aic7xxx/aic79xx.reg#76 $"
43 43
44/* 44/*
45 * This file is processed by the aic7xxx_asm utility for use in assembling 45 * This file is processed by the aic7xxx_asm utility for use in assembling
@@ -65,13 +65,6 @@ VERSION = "$Id: //depot/aic7xxx/aic7xxx/aic79xx.reg#70 $"
65 mvi MODE_PTR, MK_MODE(src, dst); \ 65 mvi MODE_PTR, MK_MODE(src, dst); \
66 } 66 }
67 67
68#define TOGGLE_DFF_MODE \
69 if ((ahd->bugs & AHD_SET_MODE_BUG) != 0) { \
70 call toggle_dff_mode_work_around; \
71 } else { \
72 xor MODE_PTR, MK_MODE(M_DFF1, M_DFF1); \
73 }
74
75#define RESTORE_MODE(mode) \ 68#define RESTORE_MODE(mode) \
76 if ((ahd->bugs & AHD_SET_MODE_BUG) != 0) { \ 69 if ((ahd->bugs & AHD_SET_MODE_BUG) != 0) { \
77 mov mode call set_mode_work_around; \ 70 mov mode call set_mode_work_around; \
@@ -1199,7 +1192,7 @@ register TARGPCISTAT {
1199 1192
1200/* 1193/*
1201 * LQ Packet In 1194 * LQ Packet In
1202 * The last LQ Packet received 1195 * The last LQ Packet recieved
1203 */ 1196 */
1204register LQIN { 1197register LQIN {
1205 address 0x020 1198 address 0x020
@@ -3542,10 +3535,34 @@ scratch_ram {
3542 COMPLETE_DMA_SCB_HEAD { 3535 COMPLETE_DMA_SCB_HEAD {
3543 size 2 3536 size 2
3544 } 3537 }
3545 /* Counting semaphore to prevent new select-outs */ 3538 /*
3539 * tail of list of SCBs that have
3540 * completed but need to be uploaded
3541 * to the host prior to being completed.
3542 */
3543 COMPLETE_DMA_SCB_TAIL {
3544 size 2
3545 }
3546 /*
3547 * head of list of SCBs that have
3548 * been uploaded to the host, but cannot
3549 * be completed until the QFREEZE is in
3550 * full effect (i.e. no selections pending).
3551 */
3552 COMPLETE_ON_QFREEZE_HEAD {
3553 size 2
3554 }
3555 /*
3556 * Counting semaphore to prevent new select-outs
3557 * The queue is frozen so long as the sequencer
3558 * and kernel freeze counts differ.
3559 */
3546 QFREEZE_COUNT { 3560 QFREEZE_COUNT {
3547 size 2 3561 size 2
3548 } 3562 }
3563 KERNEL_QFREEZE_COUNT {
3564 size 2
3565 }
3549 /* 3566 /*
3550 * Mode to restore on legacy idle loop exit. 3567 * Mode to restore on legacy idle loop exit.
3551 */ 3568 */
@@ -3625,6 +3642,17 @@ scratch_ram {
3625 size 1 3642 size 1
3626 } 3643 }
3627 /* 3644 /*
3645 * Kernel and sequencer offsets into the queue of
3646 * incoming target mode command descriptors. The
3647 * queue is full when the KERNEL_TQINPOS == TQINPOS.
3648 */
3649 KERNEL_TQINPOS {
3650 size 1
3651 }
3652 TQINPOS {
3653 size 1
3654 }
3655 /*
3628 * Base address of our shared data with the kernel driver in host 3656 * Base address of our shared data with the kernel driver in host
3629 * memory. This includes the qoutfifo and target mode 3657 * memory. This includes the qoutfifo and target mode
3630 * incoming command queue. 3658 * incoming command queue.
@@ -3639,17 +3667,6 @@ scratch_ram {
3639 QOUTFIFO_NEXT_ADDR { 3667 QOUTFIFO_NEXT_ADDR {
3640 size 4 3668 size 4
3641 } 3669 }
3642 /*
3643 * Kernel and sequencer offsets into the queue of
3644 * incoming target mode command descriptors. The
3645 * queue is full when the KERNEL_TQINPOS == TQINPOS.
3646 */
3647 KERNEL_TQINPOS {
3648 size 1
3649 }
3650 TQINPOS {
3651 size 1
3652 }
3653 ARG_1 { 3670 ARG_1 {
3654 size 1 3671 size 1
3655 mask SEND_MSG 0x80 3672 mask SEND_MSG 0x80
@@ -3951,6 +3968,7 @@ const SG_PREFETCH_ADDR_MASK download
3951const SG_SIZEOF download 3968const SG_SIZEOF download
3952const PKT_OVERRUN_BUFOFFSET download 3969const PKT_OVERRUN_BUFOFFSET download
3953const SCB_TRANSFER_SIZE download 3970const SCB_TRANSFER_SIZE download
3971const CACHELINE_MASK download
3954 3972
3955/* 3973/*
3956 * BIOS SCB offsets 3974 * BIOS SCB offsets
diff --git a/drivers/scsi/aic7xxx/aic79xx.seq b/drivers/scsi/aic7xxx/aic79xx.seq
index 65339bc1ca99..bef1f9d369b6 100644
--- a/drivers/scsi/aic7xxx/aic79xx.seq
+++ b/drivers/scsi/aic7xxx/aic79xx.seq
@@ -40,7 +40,7 @@
40 * $FreeBSD$ 40 * $FreeBSD$
41 */ 41 */
42 42
43VERSION = "$Id: //depot/aic7xxx/aic7xxx/aic79xx.seq#99 $" 43VERSION = "$Id: //depot/aic7xxx/aic7xxx/aic79xx.seq#119 $"
44PATCH_ARG_LIST = "struct ahd_softc *ahd" 44PATCH_ARG_LIST = "struct ahd_softc *ahd"
45PREFIX = "ahd_" 45PREFIX = "ahd_"
46 46
@@ -68,13 +68,47 @@ no_error_set:
68 } 68 }
69 SET_MODE(M_SCSI, M_SCSI) 69 SET_MODE(M_SCSI, M_SCSI)
70 test SCSISEQ0, ENSELO|ENARBO jnz idle_loop_checkbus; 70 test SCSISEQ0, ENSELO|ENARBO jnz idle_loop_checkbus;
71 test SEQ_FLAGS2, SELECTOUT_QFROZEN jnz idle_loop_checkbus; 71 test SEQ_FLAGS2, SELECTOUT_QFROZEN jz check_waiting_list;
72 /*
73 * If the kernel has caught up with us, thaw the queue.
74 */
75 mov A, KERNEL_QFREEZE_COUNT;
76 cmp QFREEZE_COUNT, A jne check_frozen_completions;
77 mov A, KERNEL_QFREEZE_COUNT[1];
78 cmp QFREEZE_COUNT[1], A jne check_frozen_completions;
79 and SEQ_FLAGS2, ~SELECTOUT_QFROZEN;
80 jmp check_waiting_list;
81check_frozen_completions:
82 test SSTAT0, SELDO|SELINGO jnz idle_loop_checkbus;
83BEGIN_CRITICAL;
84 /*
85 * If we have completions stalled waiting for the qfreeze
86 * to take effect, move them over to the complete_scb list
87 * now that no selections are pending.
88 */
89 cmp COMPLETE_ON_QFREEZE_HEAD[1],SCB_LIST_NULL je idle_loop_checkbus;
90 /*
91 * Find the end of the qfreeze list. The first element has
92 * to be treated specially.
93 */
94 bmov SCBPTR, COMPLETE_ON_QFREEZE_HEAD, 2;
95 cmp SCB_NEXT_COMPLETE[1], SCB_LIST_NULL je join_lists;
96 /*
97 * Now the normal loop.
98 */
99 bmov SCBPTR, SCB_NEXT_COMPLETE, 2;
100 cmp SCB_NEXT_COMPLETE[1], SCB_LIST_NULL jne . - 1;
101join_lists:
102 bmov SCB_NEXT_COMPLETE, COMPLETE_SCB_HEAD, 2;
103 bmov COMPLETE_SCB_HEAD, COMPLETE_ON_QFREEZE_HEAD, 2;
104 mvi COMPLETE_ON_QFREEZE_HEAD[1], SCB_LIST_NULL;
105 jmp idle_loop_checkbus;
106check_waiting_list:
72 cmp WAITING_TID_HEAD[1], SCB_LIST_NULL je idle_loop_checkbus; 107 cmp WAITING_TID_HEAD[1], SCB_LIST_NULL je idle_loop_checkbus;
73 /* 108 /*
74 * ENSELO is cleared by a SELDO, so we must test for SELDO 109 * ENSELO is cleared by a SELDO, so we must test for SELDO
75 * one last time. 110 * one last time.
76 */ 111 */
77BEGIN_CRITICAL;
78 test SSTAT0, SELDO jnz select_out; 112 test SSTAT0, SELDO jnz select_out;
79END_CRITICAL; 113END_CRITICAL;
80 call start_selection; 114 call start_selection;
@@ -90,6 +124,13 @@ idle_loop_check_nonpackreq:
90 test SSTAT2, NONPACKREQ jz . + 2; 124 test SSTAT2, NONPACKREQ jz . + 2;
91 call unexpected_nonpkt_phase_find_ctxt; 125 call unexpected_nonpkt_phase_find_ctxt;
92 if ((ahd->bugs & AHD_FAINT_LED_BUG) != 0) { 126 if ((ahd->bugs & AHD_FAINT_LED_BUG) != 0) {
127 /*
128 * On Rev A. hardware, the busy LED is only
129 * turned on automaically during selections
130 * and re-selections. Make the LED status
131 * more useful by forcing it to be on so
132 * long as one of our data FIFOs is active.
133 */
93 and A, FIFO0FREE|FIFO1FREE, DFFSTAT; 134 and A, FIFO0FREE|FIFO1FREE, DFFSTAT;
94 cmp A, FIFO0FREE|FIFO1FREE jne . + 3; 135 cmp A, FIFO0FREE|FIFO1FREE jne . + 3;
95 and SBLKCTL, ~DIAGLEDEN|DIAGLEDON; 136 and SBLKCTL, ~DIAGLEDEN|DIAGLEDON;
@@ -101,9 +142,9 @@ idle_loop_check_nonpackreq:
101 call idle_loop_cchan; 142 call idle_loop_cchan;
102 jmp idle_loop; 143 jmp idle_loop;
103 144
104BEGIN_CRITICAL;
105idle_loop_gsfifo: 145idle_loop_gsfifo:
106 SET_MODE(M_SCSI, M_SCSI) 146 SET_MODE(M_SCSI, M_SCSI)
147BEGIN_CRITICAL;
107idle_loop_gsfifo_in_scsi_mode: 148idle_loop_gsfifo_in_scsi_mode:
108 test LQISTAT2, LQIGSAVAIL jz return; 149 test LQISTAT2, LQIGSAVAIL jz return;
109 /* 150 /*
@@ -152,11 +193,15 @@ END_CRITICAL;
152 193
153idle_loop_service_fifos: 194idle_loop_service_fifos:
154 SET_MODE(M_DFF0, M_DFF0) 195 SET_MODE(M_DFF0, M_DFF0)
196BEGIN_CRITICAL;
155 test LONGJMP_ADDR[1], INVALID_ADDR jnz idle_loop_next_fifo; 197 test LONGJMP_ADDR[1], INVALID_ADDR jnz idle_loop_next_fifo;
156 call longjmp; 198 call longjmp;
199END_CRITICAL;
157idle_loop_next_fifo: 200idle_loop_next_fifo:
158 SET_MODE(M_DFF1, M_DFF1) 201 SET_MODE(M_DFF1, M_DFF1)
202BEGIN_CRITICAL;
159 test LONGJMP_ADDR[1], INVALID_ADDR jz longjmp; 203 test LONGJMP_ADDR[1], INVALID_ADDR jz longjmp;
204END_CRITICAL;
160return: 205return:
161 ret; 206 ret;
162 207
@@ -170,7 +215,6 @@ BEGIN_CRITICAL;
170 test CCSCBCTL, CCARREN|CCSCBEN jz scbdma_idle; 215 test CCSCBCTL, CCARREN|CCSCBEN jz scbdma_idle;
171 test CCSCBCTL, CCSCBDIR jnz fetch_new_scb_inprog; 216 test CCSCBCTL, CCSCBDIR jnz fetch_new_scb_inprog;
172 test CCSCBCTL, CCSCBDONE jz return; 217 test CCSCBCTL, CCSCBDONE jz return;
173END_CRITICAL;
174 /* FALLTHROUGH */ 218 /* FALLTHROUGH */
175scbdma_tohost_done: 219scbdma_tohost_done:
176 test CCSCBCTL, CCARREN jz fill_qoutfifo_dmadone; 220 test CCSCBCTL, CCARREN jz fill_qoutfifo_dmadone;
@@ -180,26 +224,18 @@ scbdma_tohost_done:
180 * bad SCSI status (currently only for underruns), we 224 * bad SCSI status (currently only for underruns), we
181 * queue the SCB for normal completion. Otherwise, we 225 * queue the SCB for normal completion. Otherwise, we
182 * wait until any select-out activity has halted, and 226 * wait until any select-out activity has halted, and
183 * then notify the host so that the transaction can be 227 * then queue the completion.
184 * dealt with.
185 */ 228 */
186 test SCB_SCSI_STATUS, 0xff jnz scbdma_notify_host;
187 and CCSCBCTL, ~(CCARREN|CCSCBEN); 229 and CCSCBCTL, ~(CCARREN|CCSCBEN);
188 bmov COMPLETE_DMA_SCB_HEAD, SCB_NEXT_COMPLETE, 2; 230 bmov COMPLETE_DMA_SCB_HEAD, SCB_NEXT_COMPLETE, 2;
231 cmp SCB_NEXT_COMPLETE[1], SCB_LIST_NULL jne . + 2;
232 mvi COMPLETE_DMA_SCB_TAIL[1], SCB_LIST_NULL;
233 test SCB_SCSI_STATUS, 0xff jz scbdma_queue_completion;
234 bmov SCB_NEXT_COMPLETE, COMPLETE_ON_QFREEZE_HEAD, 2;
235 bmov COMPLETE_ON_QFREEZE_HEAD, SCBPTR, 2 ret;
236scbdma_queue_completion:
189 bmov SCB_NEXT_COMPLETE, COMPLETE_SCB_HEAD, 2; 237 bmov SCB_NEXT_COMPLETE, COMPLETE_SCB_HEAD, 2;
190 bmov COMPLETE_SCB_HEAD, SCBPTR, 2 ret; 238 bmov COMPLETE_SCB_HEAD, SCBPTR, 2 ret;
191scbdma_notify_host:
192 SET_MODE(M_SCSI, M_SCSI)
193 test SCSISEQ0, ENSELO jnz return;
194 test SSTAT0, (SELDO|SELINGO) jnz return;
195 SET_MODE(M_CCHAN, M_CCHAN)
196 /*
197 * Remove SCB and notify host.
198 */
199 and CCSCBCTL, ~(CCARREN|CCSCBEN);
200 bmov COMPLETE_DMA_SCB_HEAD, SCB_NEXT_COMPLETE, 2;
201 SET_SEQINTCODE(BAD_SCB_STATUS)
202 ret;
203fill_qoutfifo_dmadone: 239fill_qoutfifo_dmadone:
204 and CCSCBCTL, ~(CCARREN|CCSCBEN); 240 and CCSCBCTL, ~(CCARREN|CCSCBEN);
205 call qoutfifo_updated; 241 call qoutfifo_updated;
@@ -208,6 +244,7 @@ fill_qoutfifo_dmadone:
208 test QOFF_CTLSTA, SDSCB_ROLLOVR jz return; 244 test QOFF_CTLSTA, SDSCB_ROLLOVR jz return;
209 bmov QOUTFIFO_NEXT_ADDR, SHARED_DATA_ADDR, 4; 245 bmov QOUTFIFO_NEXT_ADDR, SHARED_DATA_ADDR, 4;
210 xor QOUTFIFO_ENTRY_VALID_TAG, QOUTFIFO_ENTRY_VALID_TOGGLE ret; 246 xor QOUTFIFO_ENTRY_VALID_TAG, QOUTFIFO_ENTRY_VALID_TOGGLE ret;
247END_CRITICAL;
211 248
212qoutfifo_updated: 249qoutfifo_updated:
213 /* 250 /*
@@ -324,14 +361,15 @@ fill_qoutfifo:
324 * Keep track of the SCBs we are dmaing just 361 * Keep track of the SCBs we are dmaing just
325 * in case the DMA fails or is aborted. 362 * in case the DMA fails or is aborted.
326 */ 363 */
327 mov A, QOUTFIFO_ENTRY_VALID_TAG;
328 bmov COMPLETE_SCB_DMAINPROG_HEAD, COMPLETE_SCB_HEAD, 2; 364 bmov COMPLETE_SCB_DMAINPROG_HEAD, COMPLETE_SCB_HEAD, 2;
329 mvi CCSCBCTL, CCSCBRESET; 365 mvi CCSCBCTL, CCSCBRESET;
330 bmov SCBHADDR, QOUTFIFO_NEXT_ADDR, 4; 366 bmov SCBHADDR, QOUTFIFO_NEXT_ADDR, 4;
367 mov A, QOUTFIFO_NEXT_ADDR;
331 bmov SCBPTR, COMPLETE_SCB_HEAD, 2; 368 bmov SCBPTR, COMPLETE_SCB_HEAD, 2;
332fill_qoutfifo_loop: 369fill_qoutfifo_loop:
333 mov CCSCBRAM, SCBPTR; 370 bmov CCSCBRAM, SCBPTR, 2;
334 or CCSCBRAM, A, SCBPTR[1]; 371 mov CCSCBRAM, SCB_SGPTR[0];
372 mov CCSCBRAM, QOUTFIFO_ENTRY_VALID_TAG;
335 mov NONE, SDSCB_QOFF; 373 mov NONE, SDSCB_QOFF;
336 inc INT_COALESCING_CMDCOUNT; 374 inc INT_COALESCING_CMDCOUNT;
337 add CMDS_PENDING, -1; 375 add CMDS_PENDING, -1;
@@ -339,6 +377,18 @@ fill_qoutfifo_loop:
339 cmp SCB_NEXT_COMPLETE[1], SCB_LIST_NULL je fill_qoutfifo_done; 377 cmp SCB_NEXT_COMPLETE[1], SCB_LIST_NULL je fill_qoutfifo_done;
340 cmp CCSCBADDR, CCSCBADDR_MAX je fill_qoutfifo_done; 378 cmp CCSCBADDR, CCSCBADDR_MAX je fill_qoutfifo_done;
341 test QOFF_CTLSTA, SDSCB_ROLLOVR jnz fill_qoutfifo_done; 379 test QOFF_CTLSTA, SDSCB_ROLLOVR jnz fill_qoutfifo_done;
380 /*
381 * Don't cross an ADB or Cachline boundary when DMA'ing
382 * completion entries. In PCI mode, at least in 32/33
383 * configurations, the SCB DMA engine may lose its place
384 * in the data-stream should the target force a retry on
385 * something other than an 8byte aligned boundary. In
386 * PCI-X mode, we do this to avoid split transactions since
387 * many chipsets seem to be unable to format proper split
388 * completions to continue the data transfer.
389 */
390 add SINDEX, A, CCSCBADDR;
391 test SINDEX, CACHELINE_MASK jz fill_qoutfifo_done;
342 bmov SCBPTR, SCB_NEXT_COMPLETE, 2; 392 bmov SCBPTR, SCB_NEXT_COMPLETE, 2;
343 jmp fill_qoutfifo_loop; 393 jmp fill_qoutfifo_loop;
344fill_qoutfifo_done: 394fill_qoutfifo_done:
@@ -354,7 +404,6 @@ dma_complete_scb:
354 bmov SCBPTR, COMPLETE_DMA_SCB_HEAD, 2; 404 bmov SCBPTR, COMPLETE_DMA_SCB_HEAD, 2;
355 bmov SCBHADDR, SCB_BUSADDR, 4; 405 bmov SCBHADDR, SCB_BUSADDR, 4;
356 mvi CCARREN|CCSCBEN|CCSCBRESET jmp dma_scb; 406 mvi CCARREN|CCSCBEN|CCSCBRESET jmp dma_scb;
357END_CRITICAL;
358 407
359/* 408/*
360 * Either post or fetch an SCB from host memory. The caller 409 * Either post or fetch an SCB from host memory. The caller
@@ -371,9 +420,19 @@ dma_scb:
371 mvi SCBHCNT, SCB_TRANSFER_SIZE; 420 mvi SCBHCNT, SCB_TRANSFER_SIZE;
372 mov CCSCBCTL, SINDEX ret; 421 mov CCSCBCTL, SINDEX ret;
373 422
374BEGIN_CRITICAL;
375setjmp: 423setjmp:
376 bmov LONGJMP_ADDR, STACK, 2 ret; 424 /*
425 * At least on the A, a return in the same
426 * instruction as the bmov results in a return
427 * to the caller, not to the new address at the
428 * top of the stack. Since we want the latter
429 * (we use setjmp to register a handler from an
430 * interrupt context but not invoke that handler
431 * until we return to our idle loop), use a
432 * separate ret instruction.
433 */
434 bmov LONGJMP_ADDR, STACK, 2;
435 ret;
377setjmp_inline: 436setjmp_inline:
378 bmov LONGJMP_ADDR, STACK, 2; 437 bmov LONGJMP_ADDR, STACK, 2;
379longjmp: 438longjmp:
@@ -392,11 +451,6 @@ set_mode_work_around:
392 mvi SEQINTCTL, INTVEC1DSL; 451 mvi SEQINTCTL, INTVEC1DSL;
393 mov MODE_PTR, SINDEX; 452 mov MODE_PTR, SINDEX;
394 clr SEQINTCTL ret; 453 clr SEQINTCTL ret;
395
396toggle_dff_mode_work_around:
397 mvi SEQINTCTL, INTVEC1DSL;
398 xor MODE_PTR, MK_MODE(M_DFF1, M_DFF1);
399 clr SEQINTCTL ret;
400} 454}
401 455
402 456
@@ -490,6 +544,21 @@ allocate_fifo1:
490SET_SRC_MODE M_SCSI; 544SET_SRC_MODE M_SCSI;
491SET_DST_MODE M_SCSI; 545SET_DST_MODE M_SCSI;
492select_in: 546select_in:
547 if ((ahd->bugs & AHD_FAINT_LED_BUG) != 0) {
548 /*
549 * On Rev A. hardware, the busy LED is only
550 * turned on automaically during selections
551 * and re-selections. Make the LED status
552 * more useful by forcing it to be on from
553 * the point of selection until our idle
554 * loop determines that neither of our FIFOs
555 * are busy. This handles the non-packetized
556 * case nicely as we will not return to the
557 * idle loop until the busfree at the end of
558 * each transaction.
559 */
560 or SBLKCTL, DIAGLEDEN|DIAGLEDON;
561 }
493 if ((ahd->bugs & AHD_BUSFREEREV_BUG) != 0) { 562 if ((ahd->bugs & AHD_BUSFREEREV_BUG) != 0) {
494 /* 563 /*
495 * Test to ensure that the bus has not 564 * Test to ensure that the bus has not
@@ -528,6 +597,21 @@ SET_SRC_MODE M_SCSI;
528SET_DST_MODE M_SCSI; 597SET_DST_MODE M_SCSI;
529select_out: 598select_out:
530BEGIN_CRITICAL; 599BEGIN_CRITICAL;
600 if ((ahd->bugs & AHD_FAINT_LED_BUG) != 0) {
601 /*
602 * On Rev A. hardware, the busy LED is only
603 * turned on automaically during selections
604 * and re-selections. Make the LED status
605 * more useful by forcing it to be on from
606 * the point of re-selection until our idle
607 * loop determines that neither of our FIFOs
608 * are busy. This handles the non-packetized
609 * case nicely as we will not return to the
610 * idle loop until the busfree at the end of
611 * each transaction.
612 */
613 or SBLKCTL, DIAGLEDEN|DIAGLEDON;
614 }
531 /* Clear out all SCBs that have been successfully sent. */ 615 /* Clear out all SCBs that have been successfully sent. */
532 if ((ahd->bugs & AHD_SENT_SCB_UPDATE_BUG) != 0) { 616 if ((ahd->bugs & AHD_SENT_SCB_UPDATE_BUG) != 0) {
533 /* 617 /*
@@ -1000,15 +1084,9 @@ not_found_ITloop:
1000/* 1084/*
1001 * We received a "command complete" message. Put the SCB on the complete 1085 * We received a "command complete" message. Put the SCB on the complete
1002 * queue and trigger a completion interrupt via the idle loop. Before doing 1086 * queue and trigger a completion interrupt via the idle loop. Before doing
1003 * so, check to see if there 1087 * so, check to see if there is a residual or the status byte is something
1004 * is a residual or the status byte is something other than STATUS_GOOD (0). 1088 * other than STATUS_GOOD (0). In either of these conditions, we upload the
1005 * In either of these conditions, we upload the SCB back to the host so it can 1089 * SCB back to the host so it can process this information.
1006 * process this information. In the case of a non zero status byte, we
1007 * additionally interrupt the kernel driver synchronously, allowing it to
1008 * decide if sense should be retrieved. If the kernel driver wishes to request
1009 * sense, it will fill the kernel SCB with a request sense command, requeue
1010 * it to the QINFIFO and tell us not to post to the QOUTFIFO by setting
1011 * RETURN_1 to SEND_SENSE.
1012 */ 1090 */
1013mesgin_complete: 1091mesgin_complete:
1014 1092
@@ -1053,6 +1131,7 @@ complete_nomsg:
1053 call queue_scb_completion; 1131 call queue_scb_completion;
1054 jmp await_busfree; 1132 jmp await_busfree;
1055 1133
1134BEGIN_CRITICAL;
1056freeze_queue: 1135freeze_queue:
1057 /* Cancel any pending select-out. */ 1136 /* Cancel any pending select-out. */
1058 test SSTAT0, SELDO|SELINGO jnz . + 2; 1137 test SSTAT0, SELDO|SELINGO jnz . + 2;
@@ -1063,6 +1142,7 @@ freeze_queue:
1063 adc QFREEZE_COUNT[1], A; 1142 adc QFREEZE_COUNT[1], A;
1064 or SEQ_FLAGS2, SELECTOUT_QFROZEN; 1143 or SEQ_FLAGS2, SELECTOUT_QFROZEN;
1065 mov A, ACCUM_SAVE ret; 1144 mov A, ACCUM_SAVE ret;
1145END_CRITICAL;
1066 1146
1067/* 1147/*
1068 * Complete the current FIFO's SCB if data for this same 1148 * Complete the current FIFO's SCB if data for this same
@@ -1085,8 +1165,10 @@ queue_scb_completion:
1085 test SCB_SGPTR, SG_FULL_RESID jnz upload_scb;/* Never xfered */ 1165 test SCB_SGPTR, SG_FULL_RESID jnz upload_scb;/* Never xfered */
1086 test SCB_RESIDUAL_SGPTR, SG_LIST_NULL jz upload_scb; 1166 test SCB_RESIDUAL_SGPTR, SG_LIST_NULL jz upload_scb;
1087complete: 1167complete:
1168BEGIN_CRITICAL;
1088 bmov SCB_NEXT_COMPLETE, COMPLETE_SCB_HEAD, 2; 1169 bmov SCB_NEXT_COMPLETE, COMPLETE_SCB_HEAD, 2;
1089 bmov COMPLETE_SCB_HEAD, SCBPTR, 2 ret; 1170 bmov COMPLETE_SCB_HEAD, SCBPTR, 2 ret;
1171END_CRITICAL;
1090bad_status: 1172bad_status:
1091 cmp SCB_SCSI_STATUS, STATUS_PKT_SENSE je upload_scb; 1173 cmp SCB_SCSI_STATUS, STATUS_PKT_SENSE je upload_scb;
1092 call freeze_queue; 1174 call freeze_queue;
@@ -1097,9 +1179,18 @@ upload_scb:
1097 * it on the host. 1179 * it on the host.
1098 */ 1180 */
1099 bmov SCB_TAG, SCBPTR, 2; 1181 bmov SCB_TAG, SCBPTR, 2;
1100 bmov SCB_NEXT_COMPLETE, COMPLETE_DMA_SCB_HEAD, 2; 1182BEGIN_CRITICAL;
1183 or SCB_SGPTR, SG_STATUS_VALID;
1184 mvi SCB_NEXT_COMPLETE[1], SCB_LIST_NULL;
1185 cmp COMPLETE_DMA_SCB_HEAD[1], SCB_LIST_NULL jne add_dma_scb_tail;
1101 bmov COMPLETE_DMA_SCB_HEAD, SCBPTR, 2; 1186 bmov COMPLETE_DMA_SCB_HEAD, SCBPTR, 2;
1102 or SCB_SGPTR, SG_STATUS_VALID ret; 1187 bmov COMPLETE_DMA_SCB_TAIL, SCBPTR, 2 ret;
1188add_dma_scb_tail:
1189 bmov REG0, SCBPTR, 2;
1190 bmov SCBPTR, COMPLETE_DMA_SCB_TAIL, 2;
1191 bmov SCB_NEXT_COMPLETE, REG0, 2;
1192 bmov COMPLETE_DMA_SCB_TAIL, REG0, 2 ret;
1193END_CRITICAL;
1103 1194
1104/* 1195/*
1105 * Is it a disconnect message? Set a flag in the SCB to remind us 1196 * Is it a disconnect message? Set a flag in the SCB to remind us
@@ -1146,8 +1237,18 @@ SET_DST_MODE M_DFF1;
1146await_busfree_clrchn: 1237await_busfree_clrchn:
1147 mvi DFFSXFRCTL, CLRCHN; 1238 mvi DFFSXFRCTL, CLRCHN;
1148await_busfree_not_m_dff: 1239await_busfree_not_m_dff:
1149 call clear_target_state; 1240 /* clear target specific flags */
1241 mvi SEQ_FLAGS, NOT_IDENTIFIED|NO_CDB_SENT;
1150 test SSTAT1,REQINIT|BUSFREE jz .; 1242 test SSTAT1,REQINIT|BUSFREE jz .;
1243 /*
1244 * We only set BUSFREE status once either a new
1245 * phase has been detected or we are really
1246 * BUSFREE. This allows the driver to know
1247 * that we are active on the bus even though
1248 * no identified transaction exists should a
1249 * timeout occur while awaiting busfree.
1250 */
1251 mvi LASTPHASE, P_BUSFREE;
1151 test SSTAT1, BUSFREE jnz idle_loop; 1252 test SSTAT1, BUSFREE jnz idle_loop;
1152 SET_SEQINTCODE(MISSED_BUSFREE) 1253 SET_SEQINTCODE(MISSED_BUSFREE)
1153 1254
@@ -1202,11 +1303,6 @@ msgin_rdptrs_get_fifo:
1202 call allocate_fifo; 1303 call allocate_fifo;
1203 jmp mesgin_done; 1304 jmp mesgin_done;
1204 1305
1205clear_target_state:
1206 mvi LASTPHASE, P_BUSFREE;
1207 /* clear target specific flags */
1208 mvi SEQ_FLAGS, NOT_IDENTIFIED|NO_CDB_SENT ret;
1209
1210phase_lock: 1306phase_lock:
1211 if ((ahd->bugs & AHD_EARLY_REQ_BUG) != 0) { 1307 if ((ahd->bugs & AHD_EARLY_REQ_BUG) != 0) {
1212 /* 1308 /*
@@ -1298,6 +1394,47 @@ service_fifo:
1298 test CCSGCTL, CCSGENACK jnz return; 1394 test CCSGCTL, CCSGENACK jnz return;
1299 1395
1300 /* 1396 /*
1397 * Should the other FIFO get the S/G cache first? If
1398 * both FIFOs have been allocated since we last checked
1399 * any FIFO, it is important that we service a FIFO
1400 * that is not actively on the bus first. This guarantees
1401 * that a FIFO will be freed to handle snapshot requests for
1402 * any FIFO that is still on the bus. Chips with RTI do not
1403 * perform snapshots, so don't bother with this test there.
1404 */
1405 if ((ahd->features & AHD_RTI) == 0) {
1406 /*
1407 * If we're not still receiving SCSI data,
1408 * it is safe to allocate the S/G cache to
1409 * this FIFO.
1410 */
1411 test DFCNTRL, SCSIEN jz idle_sgfetch_start;
1412
1413 /*
1414 * Switch to the other FIFO. Non-RTI chips
1415 * also have the "set mode" bug, so we must
1416 * disable interrupts during the switch.
1417 */
1418 mvi SEQINTCTL, INTVEC1DSL;
1419 xor MODE_PTR, MK_MODE(M_DFF1, M_DFF1);
1420
1421 /*
1422 * If the other FIFO needs loading, then it
1423 * must not have claimed the S/G cache yet
1424 * (SG_CACHE_AVAIL would have been cleared in
1425 * the orginal FIFO mode and we test this above).
1426 * Return to the idle loop so we can process the
1427 * FIFO not currently on the bus first.
1428 */
1429 test SG_STATE, LOADING_NEEDED jz idle_sgfetch_okay;
1430 clr SEQINTCTL ret;
1431idle_sgfetch_okay:
1432 xor MODE_PTR, MK_MODE(M_DFF1, M_DFF1);
1433 clr SEQINTCTL;
1434 }
1435
1436idle_sgfetch_start:
1437 /*
1301 * We fetch a "cacheline aligned" and sized amount of data 1438 * We fetch a "cacheline aligned" and sized amount of data
1302 * so we don't end up referencing a non-existant page. 1439 * so we don't end up referencing a non-existant page.
1303 * Cacheline aligned is in quotes because the kernel will 1440 * Cacheline aligned is in quotes because the kernel will
@@ -1308,7 +1445,7 @@ service_fifo:
1308 mvi SGHCNT, SG_PREFETCH_CNT; 1445 mvi SGHCNT, SG_PREFETCH_CNT;
1309 if ((ahd->bugs & AHD_REG_SLOW_SETTLE_BUG) != 0) { 1446 if ((ahd->bugs & AHD_REG_SLOW_SETTLE_BUG) != 0) {
1310 /* 1447 /*
1311 * Need two instruction between "touches" of SGHADDR. 1448 * Need two instructions between "touches" of SGHADDR.
1312 */ 1449 */
1313 nop; 1450 nop;
1314 } 1451 }
@@ -1658,7 +1795,7 @@ export seq_isr:
1658 * savepointer in the current FIFO. We do this so that 1795 * savepointer in the current FIFO. We do this so that
1659 * a pending CTXTDONE or SAVEPTR is visible in the active 1796 * a pending CTXTDONE or SAVEPTR is visible in the active
1660 * FIFO. This status is the only way we can detect if we 1797 * FIFO. This status is the only way we can detect if we
1661 * have lost the race (e.g. host paused us) and our attepts 1798 * have lost the race (e.g. host paused us) and our attempts
1662 * to disable the channel occurred after all REQs were 1799 * to disable the channel occurred after all REQs were
1663 * already seen and acked (REQINIT never comes true). 1800 * already seen and acked (REQINIT never comes true).
1664 */ 1801 */
@@ -1667,7 +1804,7 @@ export seq_isr:
1667 test DFCNTRL, DIRECTION jz interrupt_return; 1804 test DFCNTRL, DIRECTION jz interrupt_return;
1668 and DFCNTRL, ~SCSIEN; 1805 and DFCNTRL, ~SCSIEN;
1669snapshot_wait_data_valid: 1806snapshot_wait_data_valid:
1670 test SEQINTSRC, (CTXTDONE|SAVEPTRS) jnz snapshot_data_valid; 1807 test SEQINTSRC, (CTXTDONE|SAVEPTRS) jnz interrupt_return;
1671 test SSTAT1, REQINIT jz snapshot_wait_data_valid; 1808 test SSTAT1, REQINIT jz snapshot_wait_data_valid;
1672snapshot_data_valid: 1809snapshot_data_valid:
1673 or DFCNTRL, SCSIEN; 1810 or DFCNTRL, SCSIEN;
@@ -1834,7 +1971,6 @@ pkt_saveptrs_check_status:
1834 dec SCB_FIFO_USE_COUNT; 1971 dec SCB_FIFO_USE_COUNT;
1835 test SCB_CONTROL, STATUS_RCVD jnz pkt_complete_scb_if_fifos_idle; 1972 test SCB_CONTROL, STATUS_RCVD jnz pkt_complete_scb_if_fifos_idle;
1836 mvi DFFSXFRCTL, CLRCHN ret; 1973 mvi DFFSXFRCTL, CLRCHN ret;
1837END_CRITICAL;
1838 1974
1839/* 1975/*
1840 * LAST_SEG_DONE status has been seen in the current FIFO. 1976 * LAST_SEG_DONE status has been seen in the current FIFO.
@@ -1843,7 +1979,6 @@ END_CRITICAL;
1843 * Check for overrun and see if we can complete this command. 1979 * Check for overrun and see if we can complete this command.
1844 */ 1980 */
1845pkt_last_seg_done: 1981pkt_last_seg_done:
1846BEGIN_CRITICAL;
1847 /* 1982 /*
1848 * Mark transfer as completed. 1983 * Mark transfer as completed.
1849 */ 1984 */
diff --git a/drivers/scsi/aic7xxx/aic79xx_core.c b/drivers/scsi/aic7xxx/aic79xx_core.c
index 4e8f00df978d..db8f5ce99ee3 100644
--- a/drivers/scsi/aic7xxx/aic79xx_core.c
+++ b/drivers/scsi/aic7xxx/aic79xx_core.c
@@ -37,9 +37,7 @@
37 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 37 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38 * POSSIBILITY OF SUCH DAMAGES. 38 * POSSIBILITY OF SUCH DAMAGES.
39 * 39 *
40 * $Id: //depot/aic7xxx/aic7xxx/aic79xx.c#202 $ 40 * $Id: //depot/aic7xxx/aic7xxx/aic79xx.c#247 $
41 *
42 * $FreeBSD$
43 */ 41 */
44 42
45#ifdef __linux__ 43#ifdef __linux__
@@ -332,6 +330,14 @@ ahd_restart(struct ahd_softc *ahd)
332 ahd_outb(ahd, SCSISEQ1, 330 ahd_outb(ahd, SCSISEQ1,
333 ahd_inb(ahd, SCSISEQ_TEMPLATE) & (ENSELI|ENRSELI|ENAUTOATNP)); 331 ahd_inb(ahd, SCSISEQ_TEMPLATE) & (ENSELI|ENRSELI|ENAUTOATNP));
334 ahd_set_modes(ahd, AHD_MODE_CCHAN, AHD_MODE_CCHAN); 332 ahd_set_modes(ahd, AHD_MODE_CCHAN, AHD_MODE_CCHAN);
333
334 /*
335 * Clear any pending sequencer interrupt. It is no
336 * longer relevant since we're resetting the Program
337 * Counter.
338 */
339 ahd_outb(ahd, CLRINT, CLRSEQINT);
340
335 ahd_outb(ahd, SEQCTL0, FASTMODE|SEQRESET); 341 ahd_outb(ahd, SEQCTL0, FASTMODE|SEQRESET);
336 ahd_unpause(ahd); 342 ahd_unpause(ahd);
337} 343}
@@ -373,13 +379,7 @@ ahd_flush_qoutfifo(struct ahd_softc *ahd)
373 saved_modes = ahd_save_modes(ahd); 379 saved_modes = ahd_save_modes(ahd);
374 380
375 /* 381 /*
376 * Complete any SCBs that just finished being 382 * Flush the good status FIFO for completed packetized commands.
377 * DMA'ed into the qoutfifo.
378 */
379 ahd_run_qoutfifo(ahd);
380
381 /*
382 * Flush the good status FIFO for compelted packetized commands.
383 */ 383 */
384 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); 384 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
385 saved_scbptr = ahd_get_scbptr(ahd); 385 saved_scbptr = ahd_get_scbptr(ahd);
@@ -387,8 +387,7 @@ ahd_flush_qoutfifo(struct ahd_softc *ahd)
387 u_int fifo_mode; 387 u_int fifo_mode;
388 u_int i; 388 u_int i;
389 389
390 scbid = (ahd_inb(ahd, GSFIFO+1) << 8) 390 scbid = ahd_inw(ahd, GSFIFO);
391 | ahd_inb(ahd, GSFIFO);
392 scb = ahd_lookup_scb(ahd, scbid); 391 scb = ahd_lookup_scb(ahd, scbid);
393 if (scb == NULL) { 392 if (scb == NULL) {
394 printf("%s: Warning - GSFIFO SCB %d invalid\n", 393 printf("%s: Warning - GSFIFO SCB %d invalid\n",
@@ -401,22 +400,33 @@ ahd_flush_qoutfifo(struct ahd_softc *ahd)
401 * the host before completing the command. 400 * the host before completing the command.
402 */ 401 */
403 fifo_mode = 0; 402 fifo_mode = 0;
403rescan_fifos:
404 for (i = 0; i < 2; i++) { 404 for (i = 0; i < 2; i++) {
405 /* Toggle to the other mode. */ 405 /* Toggle to the other mode. */
406 fifo_mode ^= 1; 406 fifo_mode ^= 1;
407 ahd_set_modes(ahd, fifo_mode, fifo_mode); 407 ahd_set_modes(ahd, fifo_mode, fifo_mode);
408
408 if (ahd_scb_active_in_fifo(ahd, scb) == 0) 409 if (ahd_scb_active_in_fifo(ahd, scb) == 0)
409 continue; 410 continue;
410 411
411 ahd_run_data_fifo(ahd, scb); 412 ahd_run_data_fifo(ahd, scb);
412 413
413 /* 414 /*
414 * Clearing this transaction in this FIFO may 415 * Running this FIFO may cause a CFG4DATA for
415 * cause a CFG4DATA for this same transaction 416 * this same transaction to assert in the other
416 * to assert in the other FIFO. Make sure we 417 * FIFO or a new snapshot SAVEPTRS interrupt
417 * loop one more time and check the other FIFO. 418 * in this FIFO. Even running a FIFO may not
419 * clear the transaction if we are still waiting
420 * for data to drain to the host. We must loop
421 * until the transaction is not active in either
422 * FIFO just to be sure. Reset our loop counter
423 * so we will visit both FIFOs again before
424 * declaring this transaction finished. We
425 * also delay a bit so that status has a chance
426 * to change before we look at this FIFO again.
418 */ 427 */
419 i = 0; 428 ahd_delay(200);
429 goto rescan_fifos;
420 } 430 }
421 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); 431 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
422 ahd_set_scbptr(ahd, scbid); 432 ahd_set_scbptr(ahd, scbid);
@@ -429,19 +439,28 @@ ahd_flush_qoutfifo(struct ahd_softc *ahd)
429 /* 439 /*
430 * The transfer completed with a residual. 440 * The transfer completed with a residual.
431 * Place this SCB on the complete DMA list 441 * Place this SCB on the complete DMA list
432 * so that we Update our in-core copy of the 442 * so that we update our in-core copy of the
433 * SCB before completing the command. 443 * SCB before completing the command.
434 */ 444 */
435 ahd_outb(ahd, SCB_SCSI_STATUS, 0); 445 ahd_outb(ahd, SCB_SCSI_STATUS, 0);
436 ahd_outb(ahd, SCB_SGPTR, 446 ahd_outb(ahd, SCB_SGPTR,
437 ahd_inb_scbram(ahd, SCB_SGPTR) 447 ahd_inb_scbram(ahd, SCB_SGPTR)
438 | SG_STATUS_VALID); 448 | SG_STATUS_VALID);
439 ahd_outw(ahd, SCB_TAG, SCB_GET_TAG(scb)); 449 ahd_outw(ahd, SCB_TAG, scbid);
450 ahd_outw(ahd, SCB_NEXT_COMPLETE, SCB_LIST_NULL);
440 comp_head = ahd_inw(ahd, COMPLETE_DMA_SCB_HEAD); 451 comp_head = ahd_inw(ahd, COMPLETE_DMA_SCB_HEAD);
441 ahd_outw(ahd, SCB_NEXT_COMPLETE, comp_head); 452 if (SCBID_IS_NULL(comp_head)) {
442 if (SCBID_IS_NULL(comp_head)) 453 ahd_outw(ahd, COMPLETE_DMA_SCB_HEAD, scbid);
443 ahd_outw(ahd, COMPLETE_DMA_SCB_HEAD, 454 ahd_outw(ahd, COMPLETE_DMA_SCB_TAIL, scbid);
444 SCB_GET_TAG(scb)); 455 } else {
456 u_int tail;
457
458 tail = ahd_inw(ahd, COMPLETE_DMA_SCB_TAIL);
459 ahd_set_scbptr(ahd, tail);
460 ahd_outw(ahd, SCB_NEXT_COMPLETE, scbid);
461 ahd_outw(ahd, COMPLETE_DMA_SCB_TAIL, scbid);
462 ahd_set_scbptr(ahd, scbid);
463 }
445 } else 464 } else
446 ahd_complete_scb(ahd, scb); 465 ahd_complete_scb(ahd, scb);
447 } 466 }
@@ -465,9 +484,22 @@ ahd_flush_qoutfifo(struct ahd_softc *ahd)
465 break; 484 break;
466 ahd_delay(200); 485 ahd_delay(200);
467 } 486 }
468 if ((ccscbctl & CCSCBDIR) != 0) 487 /*
488 * We leave the sequencer to cleanup in the case of DMA's to
489 * update the qoutfifo. In all other cases (DMA's to the
490 * chip or a push of an SCB from the COMPLETE_DMA_SCB list),
491 * we disable the DMA engine so that the sequencer will not
492 * attempt to handle the DMA completion.
493 */
494 if ((ccscbctl & CCSCBDIR) != 0 || (ccscbctl & ARRDONE) != 0)
469 ahd_outb(ahd, CCSCBCTL, ccscbctl & ~(CCARREN|CCSCBEN)); 495 ahd_outb(ahd, CCSCBCTL, ccscbctl & ~(CCARREN|CCSCBEN));
470 496
497 /*
498 * Complete any SCBs that just finished
499 * being DMA'ed into the qoutfifo.
500 */
501 ahd_run_qoutfifo(ahd);
502
471 saved_scbptr = ahd_get_scbptr(ahd); 503 saved_scbptr = ahd_get_scbptr(ahd);
472 /* 504 /*
473 * Manually update/complete any completed SCBs that are waiting to be 505 * Manually update/complete any completed SCBs that are waiting to be
@@ -494,6 +526,24 @@ ahd_flush_qoutfifo(struct ahd_softc *ahd)
494 scbid = next_scbid; 526 scbid = next_scbid;
495 } 527 }
496 ahd_outw(ahd, COMPLETE_DMA_SCB_HEAD, SCB_LIST_NULL); 528 ahd_outw(ahd, COMPLETE_DMA_SCB_HEAD, SCB_LIST_NULL);
529 ahd_outw(ahd, COMPLETE_DMA_SCB_TAIL, SCB_LIST_NULL);
530
531 scbid = ahd_inw(ahd, COMPLETE_ON_QFREEZE_HEAD);
532 while (!SCBID_IS_NULL(scbid)) {
533
534 ahd_set_scbptr(ahd, scbid);
535 next_scbid = ahd_inw_scbram(ahd, SCB_NEXT_COMPLETE);
536 scb = ahd_lookup_scb(ahd, scbid);
537 if (scb == NULL) {
538 printf("%s: Warning - Complete Qfrz SCB %d invalid\n",
539 ahd_name(ahd), scbid);
540 continue;
541 }
542
543 ahd_complete_scb(ahd, scb);
544 scbid = next_scbid;
545 }
546 ahd_outw(ahd, COMPLETE_ON_QFREEZE_HEAD, SCB_LIST_NULL);
497 547
498 scbid = ahd_inw(ahd, COMPLETE_SCB_HEAD); 548 scbid = ahd_inw(ahd, COMPLETE_SCB_HEAD);
499 while (!SCBID_IS_NULL(scbid)) { 549 while (!SCBID_IS_NULL(scbid)) {
@@ -558,150 +608,146 @@ ahd_run_data_fifo(struct ahd_softc *ahd, struct scb *scb)
558{ 608{
559 u_int seqintsrc; 609 u_int seqintsrc;
560 610
561 while (1) { 611 seqintsrc = ahd_inb(ahd, SEQINTSRC);
562 seqintsrc = ahd_inb(ahd, SEQINTSRC); 612 if ((seqintsrc & CFG4DATA) != 0) {
563 if ((seqintsrc & CFG4DATA) != 0) { 613 uint32_t datacnt;
564 uint32_t datacnt; 614 uint32_t sgptr;
565 uint32_t sgptr;
566
567 /*
568 * Clear full residual flag.
569 */
570 sgptr = ahd_inl_scbram(ahd, SCB_SGPTR) & ~SG_FULL_RESID;
571 ahd_outb(ahd, SCB_SGPTR, sgptr);
572 615
573 /* 616 /*
574 * Load datacnt and address. 617 * Clear full residual flag.
575 */ 618 */
576 datacnt = ahd_inl_scbram(ahd, SCB_DATACNT); 619 sgptr = ahd_inl_scbram(ahd, SCB_SGPTR) & ~SG_FULL_RESID;
577 if ((datacnt & AHD_DMA_LAST_SEG) != 0) { 620 ahd_outb(ahd, SCB_SGPTR, sgptr);
578 sgptr |= LAST_SEG;
579 ahd_outb(ahd, SG_STATE, 0);
580 } else
581 ahd_outb(ahd, SG_STATE, LOADING_NEEDED);
582 ahd_outq(ahd, HADDR, ahd_inq_scbram(ahd, SCB_DATAPTR));
583 ahd_outl(ahd, HCNT, datacnt & AHD_SG_LEN_MASK);
584 ahd_outb(ahd, SG_CACHE_PRE, sgptr);
585 ahd_outb(ahd, DFCNTRL, PRELOADEN|SCSIEN|HDMAEN);
586 621
587 /* 622 /*
588 * Initialize Residual Fields. 623 * Load datacnt and address.
589 */ 624 */
590 ahd_outb(ahd, SCB_RESIDUAL_DATACNT+3, datacnt >> 24); 625 datacnt = ahd_inl_scbram(ahd, SCB_DATACNT);
591 ahd_outl(ahd, SCB_RESIDUAL_SGPTR, sgptr & SG_PTR_MASK); 626 if ((datacnt & AHD_DMA_LAST_SEG) != 0) {
627 sgptr |= LAST_SEG;
628 ahd_outb(ahd, SG_STATE, 0);
629 } else
630 ahd_outb(ahd, SG_STATE, LOADING_NEEDED);
631 ahd_outq(ahd, HADDR, ahd_inq_scbram(ahd, SCB_DATAPTR));
632 ahd_outl(ahd, HCNT, datacnt & AHD_SG_LEN_MASK);
633 ahd_outb(ahd, SG_CACHE_PRE, sgptr);
634 ahd_outb(ahd, DFCNTRL, PRELOADEN|SCSIEN|HDMAEN);
592 635
593 /* 636 /*
594 * Mark the SCB as having a FIFO in use. 637 * Initialize Residual Fields.
595 */ 638 */
596 ahd_outb(ahd, SCB_FIFO_USE_COUNT, 639 ahd_outb(ahd, SCB_RESIDUAL_DATACNT+3, datacnt >> 24);
597 ahd_inb_scbram(ahd, SCB_FIFO_USE_COUNT) + 1); 640 ahd_outl(ahd, SCB_RESIDUAL_SGPTR, sgptr & SG_PTR_MASK);
598 641
599 /* 642 /*
600 * Install a "fake" handler for this FIFO. 643 * Mark the SCB as having a FIFO in use.
601 */ 644 */
602 ahd_outw(ahd, LONGJMP_ADDR, 0); 645 ahd_outb(ahd, SCB_FIFO_USE_COUNT,
646 ahd_inb_scbram(ahd, SCB_FIFO_USE_COUNT) + 1);
603 647
604 /* 648 /*
605 * Notify the hardware that we have satisfied 649 * Install a "fake" handler for this FIFO.
606 * this sequencer interrupt. 650 */
607 */ 651 ahd_outw(ahd, LONGJMP_ADDR, 0);
608 ahd_outb(ahd, CLRSEQINTSRC, CLRCFG4DATA);
609 } else if ((seqintsrc & SAVEPTRS) != 0) {
610 uint32_t sgptr;
611 uint32_t resid;
612 652
613 if ((ahd_inb(ahd, LONGJMP_ADDR+1)&INVALID_ADDR) != 0) { 653 /*
614 /* 654 * Notify the hardware that we have satisfied
615 * Snapshot Save Pointers. Clear 655 * this sequencer interrupt.
616 * the snapshot and continue. 656 */
617 */ 657 ahd_outb(ahd, CLRSEQINTSRC, CLRCFG4DATA);
618 ahd_outb(ahd, DFFSXFRCTL, CLRCHN); 658 } else if ((seqintsrc & SAVEPTRS) != 0) {
619 continue; 659 uint32_t sgptr;
620 } 660 uint32_t resid;
621 661
662 if ((ahd_inb(ahd, LONGJMP_ADDR+1)&INVALID_ADDR) != 0) {
622 /* 663 /*
623 * Disable S/G fetch so the DMA engine 664 * Snapshot Save Pointers. All that
624 * is available to future users. 665 * is necessary to clear the snapshot
666 * is a CLRCHN.
625 */ 667 */
626 if ((ahd_inb(ahd, SG_STATE) & FETCH_INPROG) != 0) 668 goto clrchn;
627 ahd_outb(ahd, CCSGCTL, 0); 669 }
628 ahd_outb(ahd, SG_STATE, 0);
629 670
630 /* 671 /*
631 * Flush the data FIFO. Strickly only 672 * Disable S/G fetch so the DMA engine
632 * necessary for Rev A parts. 673 * is available to future users.
633 */ 674 */
634 ahd_outb(ahd, DFCNTRL, 675 if ((ahd_inb(ahd, SG_STATE) & FETCH_INPROG) != 0)
635 ahd_inb(ahd, DFCNTRL) | FIFOFLUSH); 676 ahd_outb(ahd, CCSGCTL, 0);
677 ahd_outb(ahd, SG_STATE, 0);
636 678
637 /* 679 /*
638 * Calculate residual. 680 * Flush the data FIFO. Strickly only
639 */ 681 * necessary for Rev A parts.
640 sgptr = ahd_inl_scbram(ahd, SCB_RESIDUAL_SGPTR); 682 */
641 resid = ahd_inl(ahd, SHCNT); 683 ahd_outb(ahd, DFCNTRL, ahd_inb(ahd, DFCNTRL) | FIFOFLUSH);
642 resid |=
643 ahd_inb_scbram(ahd, SCB_RESIDUAL_DATACNT+3) << 24;
644 ahd_outl(ahd, SCB_RESIDUAL_DATACNT, resid);
645 if ((ahd_inb(ahd, SG_CACHE_SHADOW) & LAST_SEG) == 0) {
646 /*
647 * Must back up to the correct S/G element.
648 * Typically this just means resetting our
649 * low byte to the offset in the SG_CACHE,
650 * but if we wrapped, we have to correct
651 * the other bytes of the sgptr too.
652 */
653 if ((ahd_inb(ahd, SG_CACHE_SHADOW) & 0x80) != 0
654 && (sgptr & 0x80) == 0)
655 sgptr -= 0x100;
656 sgptr &= ~0xFF;
657 sgptr |= ahd_inb(ahd, SG_CACHE_SHADOW)
658 & SG_ADDR_MASK;
659 ahd_outl(ahd, SCB_RESIDUAL_SGPTR, sgptr);
660 ahd_outb(ahd, SCB_RESIDUAL_DATACNT + 3, 0);
661 } else if ((resid & AHD_SG_LEN_MASK) == 0) {
662 ahd_outb(ahd, SCB_RESIDUAL_SGPTR,
663 sgptr | SG_LIST_NULL);
664 }
665 /*
666 * Save Pointers.
667 */
668 ahd_outq(ahd, SCB_DATAPTR, ahd_inq(ahd, SHADDR));
669 ahd_outl(ahd, SCB_DATACNT, resid);
670 ahd_outl(ahd, SCB_SGPTR, sgptr);
671 ahd_outb(ahd, CLRSEQINTSRC, CLRSAVEPTRS);
672 ahd_outb(ahd, SEQIMODE,
673 ahd_inb(ahd, SEQIMODE) | ENSAVEPTRS);
674 /*
675 * If the data is to the SCSI bus, we are
676 * done, otherwise wait for FIFOEMP.
677 */
678 if ((ahd_inb(ahd, DFCNTRL) & DIRECTION) != 0)
679 break;
680 } else if ((ahd_inb(ahd, SG_STATE) & LOADING_NEEDED) != 0) {
681 uint32_t sgptr;
682 uint64_t data_addr;
683 uint32_t data_len;
684 u_int dfcntrl;
685 684
685 /*
686 * Calculate residual.
687 */
688 sgptr = ahd_inl_scbram(ahd, SCB_RESIDUAL_SGPTR);
689 resid = ahd_inl(ahd, SHCNT);
690 resid |= ahd_inb_scbram(ahd, SCB_RESIDUAL_DATACNT+3) << 24;
691 ahd_outl(ahd, SCB_RESIDUAL_DATACNT, resid);
692 if ((ahd_inb(ahd, SG_CACHE_SHADOW) & LAST_SEG) == 0) {
686 /* 693 /*
687 * Disable S/G fetch so the DMA engine 694 * Must back up to the correct S/G element.
688 * is available to future users. 695 * Typically this just means resetting our
696 * low byte to the offset in the SG_CACHE,
697 * but if we wrapped, we have to correct
698 * the other bytes of the sgptr too.
689 */ 699 */
690 if ((ahd_inb(ahd, SG_STATE) & FETCH_INPROG) != 0) { 700 if ((ahd_inb(ahd, SG_CACHE_SHADOW) & 0x80) != 0
691 ahd_outb(ahd, CCSGCTL, 0); 701 && (sgptr & 0x80) == 0)
692 ahd_outb(ahd, SG_STATE, LOADING_NEEDED); 702 sgptr -= 0x100;
693 } 703 sgptr &= ~0xFF;
704 sgptr |= ahd_inb(ahd, SG_CACHE_SHADOW)
705 & SG_ADDR_MASK;
706 ahd_outl(ahd, SCB_RESIDUAL_SGPTR, sgptr);
707 ahd_outb(ahd, SCB_RESIDUAL_DATACNT + 3, 0);
708 } else if ((resid & AHD_SG_LEN_MASK) == 0) {
709 ahd_outb(ahd, SCB_RESIDUAL_SGPTR,
710 sgptr | SG_LIST_NULL);
711 }
712 /*
713 * Save Pointers.
714 */
715 ahd_outq(ahd, SCB_DATAPTR, ahd_inq(ahd, SHADDR));
716 ahd_outl(ahd, SCB_DATACNT, resid);
717 ahd_outl(ahd, SCB_SGPTR, sgptr);
718 ahd_outb(ahd, CLRSEQINTSRC, CLRSAVEPTRS);
719 ahd_outb(ahd, SEQIMODE,
720 ahd_inb(ahd, SEQIMODE) | ENSAVEPTRS);
721 /*
722 * If the data is to the SCSI bus, we are
723 * done, otherwise wait for FIFOEMP.
724 */
725 if ((ahd_inb(ahd, DFCNTRL) & DIRECTION) != 0)
726 goto clrchn;
727 } else if ((ahd_inb(ahd, SG_STATE) & LOADING_NEEDED) != 0) {
728 uint32_t sgptr;
729 uint64_t data_addr;
730 uint32_t data_len;
731 u_int dfcntrl;
694 732
695 /* 733 /*
696 * Wait for the DMA engine to notice that the 734 * Disable S/G fetch so the DMA engine
697 * host transfer is enabled and that there is 735 * is available to future users. We won't
698 * space in the S/G FIFO for new segments before 736 * be using the DMA engine to load segments.
699 * loading more segments. 737 */
700 */ 738 if ((ahd_inb(ahd, SG_STATE) & FETCH_INPROG) != 0) {
701 if ((ahd_inb(ahd, DFSTATUS) & PRELOAD_AVAIL) == 0) 739 ahd_outb(ahd, CCSGCTL, 0);
702 continue; 740 ahd_outb(ahd, SG_STATE, LOADING_NEEDED);
703 if ((ahd_inb(ahd, DFCNTRL) & HDMAENACK) == 0) 741 }
704 continue; 742
743 /*
744 * Wait for the DMA engine to notice that the
745 * host transfer is enabled and that there is
746 * space in the S/G FIFO for new segments before
747 * loading more segments.
748 */
749 if ((ahd_inb(ahd, DFSTATUS) & PRELOAD_AVAIL) != 0
750 && (ahd_inb(ahd, DFCNTRL) & HDMAENACK) != 0) {
705 751
706 /* 752 /*
707 * Determine the offset of the next S/G 753 * Determine the offset of the next S/G
@@ -748,7 +794,7 @@ ahd_run_data_fifo(struct ahd_softc *ahd, struct scb *scb)
748 * Advertise the segment to the hardware. 794 * Advertise the segment to the hardware.
749 */ 795 */
750 dfcntrl = ahd_inb(ahd, DFCNTRL)|PRELOADEN|HDMAEN; 796 dfcntrl = ahd_inb(ahd, DFCNTRL)|PRELOADEN|HDMAEN;
751 if ((ahd->features & AHD_NEW_DFCNTRL_OPTS)!=0) { 797 if ((ahd->features & AHD_NEW_DFCNTRL_OPTS) != 0) {
752 /* 798 /*
753 * Use SCSIENWRDIS so that SCSIEN 799 * Use SCSIENWRDIS so that SCSIEN
754 * is never modified by this 800 * is never modified by this
@@ -757,35 +803,44 @@ ahd_run_data_fifo(struct ahd_softc *ahd, struct scb *scb)
757 dfcntrl |= SCSIENWRDIS; 803 dfcntrl |= SCSIENWRDIS;
758 } 804 }
759 ahd_outb(ahd, DFCNTRL, dfcntrl); 805 ahd_outb(ahd, DFCNTRL, dfcntrl);
760 } else if ((ahd_inb(ahd, SG_CACHE_SHADOW)
761 & LAST_SEG_DONE) != 0) {
762
763 /*
764 * Transfer completed to the end of SG list
765 * and has flushed to the host.
766 */
767 ahd_outb(ahd, SCB_SGPTR,
768 ahd_inb_scbram(ahd, SCB_SGPTR) | SG_LIST_NULL);
769 break;
770 } else if ((ahd_inb(ahd, DFSTATUS) & FIFOEMP) != 0) {
771 break;
772 } 806 }
773 ahd_delay(200); 807 } else if ((ahd_inb(ahd, SG_CACHE_SHADOW) & LAST_SEG_DONE) != 0) {
808
809 /*
810 * Transfer completed to the end of SG list
811 * and has flushed to the host.
812 */
813 ahd_outb(ahd, SCB_SGPTR,
814 ahd_inb_scbram(ahd, SCB_SGPTR) | SG_LIST_NULL);
815 goto clrchn;
816 } else if ((ahd_inb(ahd, DFSTATUS) & FIFOEMP) != 0) {
817clrchn:
818 /*
819 * Clear any handler for this FIFO, decrement
820 * the FIFO use count for the SCB, and release
821 * the FIFO.
822 */
823 ahd_outb(ahd, LONGJMP_ADDR + 1, INVALID_ADDR);
824 ahd_outb(ahd, SCB_FIFO_USE_COUNT,
825 ahd_inb_scbram(ahd, SCB_FIFO_USE_COUNT) - 1);
826 ahd_outb(ahd, DFFSXFRCTL, CLRCHN);
774 } 827 }
775 /*
776 * Clear any handler for this FIFO, decrement
777 * the FIFO use count for the SCB, and release
778 * the FIFO.
779 */
780 ahd_outb(ahd, LONGJMP_ADDR + 1, INVALID_ADDR);
781 ahd_outb(ahd, SCB_FIFO_USE_COUNT,
782 ahd_inb_scbram(ahd, SCB_FIFO_USE_COUNT) - 1);
783 ahd_outb(ahd, DFFSXFRCTL, CLRCHN);
784} 828}
785 829
830/*
831 * Look for entries in the QoutFIFO that have completed.
832 * The valid_tag completion field indicates the validity
833 * of the entry - the valid value toggles each time through
834 * the queue. We use the sg_status field in the completion
835 * entry to avoid referencing the hscb if the completion
836 * occurred with no errors and no residual. sg_status is
837 * a copy of the first byte (little endian) of the sgptr
838 * hscb field.
839 */
786void 840void
787ahd_run_qoutfifo(struct ahd_softc *ahd) 841ahd_run_qoutfifo(struct ahd_softc *ahd)
788{ 842{
843 struct ahd_completion *completion;
789 struct scb *scb; 844 struct scb *scb;
790 u_int scb_index; 845 u_int scb_index;
791 846
@@ -793,11 +848,13 @@ ahd_run_qoutfifo(struct ahd_softc *ahd)
793 panic("ahd_run_qoutfifo recursion"); 848 panic("ahd_run_qoutfifo recursion");
794 ahd->flags |= AHD_RUNNING_QOUTFIFO; 849 ahd->flags |= AHD_RUNNING_QOUTFIFO;
795 ahd_sync_qoutfifo(ahd, BUS_DMASYNC_POSTREAD); 850 ahd_sync_qoutfifo(ahd, BUS_DMASYNC_POSTREAD);
796 while ((ahd->qoutfifo[ahd->qoutfifonext] 851 for (;;) {
797 & QOUTFIFO_ENTRY_VALID_LE) == ahd->qoutfifonext_valid_tag) { 852 completion = &ahd->qoutfifo[ahd->qoutfifonext];
798 853
799 scb_index = ahd_le16toh(ahd->qoutfifo[ahd->qoutfifonext] 854 if (completion->valid_tag != ahd->qoutfifonext_valid_tag)
800 & ~QOUTFIFO_ENTRY_VALID_LE); 855 break;
856
857 scb_index = ahd_le16toh(completion->tag);
801 scb = ahd_lookup_scb(ahd, scb_index); 858 scb = ahd_lookup_scb(ahd, scb_index);
802 if (scb == NULL) { 859 if (scb == NULL) {
803 printf("%s: WARNING no command for scb %d " 860 printf("%s: WARNING no command for scb %d "
@@ -805,12 +862,15 @@ ahd_run_qoutfifo(struct ahd_softc *ahd)
805 ahd_name(ahd), scb_index, 862 ahd_name(ahd), scb_index,
806 ahd->qoutfifonext); 863 ahd->qoutfifonext);
807 ahd_dump_card_state(ahd); 864 ahd_dump_card_state(ahd);
808 } else 865 } else if ((completion->sg_status & SG_STATUS_VALID) != 0) {
809 ahd_complete_scb(ahd, scb); 866 ahd_handle_scb_status(ahd, scb);
867 } else {
868 ahd_done(ahd, scb);
869 }
810 870
811 ahd->qoutfifonext = (ahd->qoutfifonext+1) & (AHD_QOUT_SIZE-1); 871 ahd->qoutfifonext = (ahd->qoutfifonext+1) & (AHD_QOUT_SIZE-1);
812 if (ahd->qoutfifonext == 0) 872 if (ahd->qoutfifonext == 0)
813 ahd->qoutfifonext_valid_tag ^= QOUTFIFO_ENTRY_VALID_LE; 873 ahd->qoutfifonext_valid_tag ^= QOUTFIFO_ENTRY_VALID;
814 } 874 }
815 ahd->flags &= ~AHD_RUNNING_QOUTFIFO; 875 ahd->flags &= ~AHD_RUNNING_QOUTFIFO;
816} 876}
@@ -876,26 +936,6 @@ ahd_handle_seqint(struct ahd_softc *ahd, u_int intstat)
876 ahd_name(ahd), seqintcode); 936 ahd_name(ahd), seqintcode);
877#endif 937#endif
878 switch (seqintcode) { 938 switch (seqintcode) {
879 case BAD_SCB_STATUS:
880 {
881 struct scb *scb;
882 u_int scbid;
883 int cmds_pending;
884
885 scbid = ahd_get_scbptr(ahd);
886 scb = ahd_lookup_scb(ahd, scbid);
887 if (scb != NULL) {
888 ahd_complete_scb(ahd, scb);
889 } else {
890 printf("%s: WARNING no command for scb %d "
891 "(bad status)\n", ahd_name(ahd), scbid);
892 ahd_dump_card_state(ahd);
893 }
894 cmds_pending = ahd_inw(ahd, CMDS_PENDING);
895 if (cmds_pending > 0)
896 ahd_outw(ahd, CMDS_PENDING, cmds_pending - 1);
897 break;
898 }
899 case ENTERING_NONPACK: 939 case ENTERING_NONPACK:
900 { 940 {
901 struct scb *scb; 941 struct scb *scb;
@@ -1060,7 +1100,7 @@ ahd_handle_seqint(struct ahd_softc *ahd, u_int intstat)
1060 ahd_outb(ahd, SAVED_LUN, 0); 1100 ahd_outb(ahd, SAVED_LUN, 0);
1061 ahd_outb(ahd, SEQ_FLAGS, 0); 1101 ahd_outb(ahd, SEQ_FLAGS, 0);
1062 ahd_assert_atn(ahd); 1102 ahd_assert_atn(ahd);
1063 scb->flags &= ~(SCB_PACKETIZED); 1103 scb->flags &= ~SCB_PACKETIZED;
1064 scb->flags |= SCB_ABORT|SCB_CMDPHASE_ABORT; 1104 scb->flags |= SCB_ABORT|SCB_CMDPHASE_ABORT;
1065 ahd_freeze_devq(ahd, scb); 1105 ahd_freeze_devq(ahd, scb);
1066 ahd_set_transaction_status(scb, CAM_REQUEUE_REQ); 1106 ahd_set_transaction_status(scb, CAM_REQUEUE_REQ);
@@ -1503,9 +1543,6 @@ ahd_handle_scsiint(struct ahd_softc *ahd, u_int intstat)
1503 && (ahd_inb(ahd, SEQ_FLAGS) & NOT_IDENTIFIED) != 0) 1543 && (ahd_inb(ahd, SEQ_FLAGS) & NOT_IDENTIFIED) != 0)
1504 scb = NULL; 1544 scb = NULL;
1505 1545
1506 /* Make sure the sequencer is in a safe location. */
1507 ahd_clear_critical_section(ahd);
1508
1509 if ((status0 & IOERR) != 0) { 1546 if ((status0 & IOERR) != 0) {
1510 u_int now_lvd; 1547 u_int now_lvd;
1511 1548
@@ -1521,26 +1558,35 @@ ahd_handle_scsiint(struct ahd_softc *ahd, u_int intstat)
1521 ahd_setup_iocell_workaround(ahd); 1558 ahd_setup_iocell_workaround(ahd);
1522 ahd_unpause(ahd); 1559 ahd_unpause(ahd);
1523 } else if ((status0 & OVERRUN) != 0) { 1560 } else if ((status0 & OVERRUN) != 0) {
1561
1524 printf("%s: SCSI offset overrun detected. Resetting bus.\n", 1562 printf("%s: SCSI offset overrun detected. Resetting bus.\n",
1525 ahd_name(ahd)); 1563 ahd_name(ahd));
1526 ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE); 1564 ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE);
1527 } else if ((status & SCSIRSTI) != 0) { 1565 } else if ((status & SCSIRSTI) != 0) {
1566
1528 printf("%s: Someone reset channel A\n", ahd_name(ahd)); 1567 printf("%s: Someone reset channel A\n", ahd_name(ahd));
1529 ahd_reset_channel(ahd, 'A', /*Initiate Reset*/FALSE); 1568 ahd_reset_channel(ahd, 'A', /*Initiate Reset*/FALSE);
1530 } else if ((status & SCSIPERR) != 0) { 1569 } else if ((status & SCSIPERR) != 0) {
1570
1571 /* Make sure the sequencer is in a safe location. */
1572 ahd_clear_critical_section(ahd);
1573
1531 ahd_handle_transmission_error(ahd); 1574 ahd_handle_transmission_error(ahd);
1532 } else if (lqostat0 != 0) { 1575 } else if (lqostat0 != 0) {
1576
1533 printf("%s: lqostat0 == 0x%x!\n", ahd_name(ahd), lqostat0); 1577 printf("%s: lqostat0 == 0x%x!\n", ahd_name(ahd), lqostat0);
1534 ahd_outb(ahd, CLRLQOINT0, lqostat0); 1578 ahd_outb(ahd, CLRLQOINT0, lqostat0);
1535 if ((ahd->bugs & AHD_CLRLQO_AUTOCLR_BUG) != 0) { 1579 if ((ahd->bugs & AHD_CLRLQO_AUTOCLR_BUG) != 0)
1536 ahd_outb(ahd, CLRLQOINT1, 0); 1580 ahd_outb(ahd, CLRLQOINT1, 0);
1537 }
1538 } else if ((status & SELTO) != 0) { 1581 } else if ((status & SELTO) != 0) {
1539 u_int scbid; 1582 u_int scbid;
1540 1583
1541 /* Stop the selection */ 1584 /* Stop the selection */
1542 ahd_outb(ahd, SCSISEQ0, 0); 1585 ahd_outb(ahd, SCSISEQ0, 0);
1543 1586
1587 /* Make sure the sequencer is in a safe location. */
1588 ahd_clear_critical_section(ahd);
1589
1544 /* No more pending messages */ 1590 /* No more pending messages */
1545 ahd_clear_msg_state(ahd); 1591 ahd_clear_msg_state(ahd);
1546 1592
@@ -1573,24 +1619,27 @@ ahd_handle_scsiint(struct ahd_softc *ahd, u_int intstat)
1573 scbid); 1619 scbid);
1574 } 1620 }
1575#endif 1621#endif
1576 /*
1577 * Force a renegotiation with this target just in
1578 * case the cable was pulled and will later be
1579 * re-attached. The target may forget its negotiation
1580 * settings with us should it attempt to reselect
1581 * during the interruption. The target will not issue
1582 * a unit attention in this case, so we must always
1583 * renegotiate.
1584 */
1585 ahd_scb_devinfo(ahd, &devinfo, scb); 1622 ahd_scb_devinfo(ahd, &devinfo, scb);
1586 ahd_force_renegotiation(ahd, &devinfo);
1587 ahd_set_transaction_status(scb, CAM_SEL_TIMEOUT); 1623 ahd_set_transaction_status(scb, CAM_SEL_TIMEOUT);
1588 ahd_freeze_devq(ahd, scb); 1624 ahd_freeze_devq(ahd, scb);
1625
1626 /*
1627 * Cancel any pending transactions on the device
1628 * now that it seems to be missing. This will
1629 * also revert us to async/narrow transfers until
1630 * we can renegotiate with the device.
1631 */
1632 ahd_handle_devreset(ahd, &devinfo,
1633 CAM_LUN_WILDCARD,
1634 CAM_SEL_TIMEOUT,
1635 "Selection Timeout",
1636 /*verbose_level*/1);
1589 } 1637 }
1590 ahd_outb(ahd, CLRINT, CLRSCSIINT); 1638 ahd_outb(ahd, CLRINT, CLRSCSIINT);
1591 ahd_iocell_first_selection(ahd); 1639 ahd_iocell_first_selection(ahd);
1592 ahd_unpause(ahd); 1640 ahd_unpause(ahd);
1593 } else if ((status0 & (SELDI|SELDO)) != 0) { 1641 } else if ((status0 & (SELDI|SELDO)) != 0) {
1642
1594 ahd_iocell_first_selection(ahd); 1643 ahd_iocell_first_selection(ahd);
1595 ahd_unpause(ahd); 1644 ahd_unpause(ahd);
1596 } else if (status3 != 0) { 1645 } else if (status3 != 0) {
@@ -1598,6 +1647,10 @@ ahd_handle_scsiint(struct ahd_softc *ahd, u_int intstat)
1598 ahd_name(ahd), status3); 1647 ahd_name(ahd), status3);
1599 ahd_outb(ahd, CLRSINT3, status3); 1648 ahd_outb(ahd, CLRSINT3, status3);
1600 } else if ((lqistat1 & (LQIPHASE_LQ|LQIPHASE_NLQ)) != 0) { 1649 } else if ((lqistat1 & (LQIPHASE_LQ|LQIPHASE_NLQ)) != 0) {
1650
1651 /* Make sure the sequencer is in a safe location. */
1652 ahd_clear_critical_section(ahd);
1653
1601 ahd_handle_lqiphase_error(ahd, lqistat1); 1654 ahd_handle_lqiphase_error(ahd, lqistat1);
1602 } else if ((lqistat1 & LQICRCI_NLQ) != 0) { 1655 } else if ((lqistat1 & LQICRCI_NLQ) != 0) {
1603 /* 1656 /*
@@ -1622,6 +1675,9 @@ ahd_handle_scsiint(struct ahd_softc *ahd, u_int intstat)
1622 */ 1675 */
1623 ahd_outb(ahd, SCSISEQ0, 0); 1676 ahd_outb(ahd, SCSISEQ0, 0);
1624 1677
1678 /* Make sure the sequencer is in a safe location. */
1679 ahd_clear_critical_section(ahd);
1680
1625 /* 1681 /*
1626 * Determine what we were up to at the time of 1682 * Determine what we were up to at the time of
1627 * the busfree. 1683 * the busfree.
@@ -1659,7 +1715,16 @@ ahd_handle_scsiint(struct ahd_softc *ahd, u_int intstat)
1659 clear_fifo = 0; 1715 clear_fifo = 0;
1660 packetized = (lqostat1 & LQOBUSFREE) != 0; 1716 packetized = (lqostat1 & LQOBUSFREE) != 0;
1661 if (!packetized 1717 if (!packetized
1662 && ahd_inb(ahd, LASTPHASE) == P_BUSFREE) 1718 && ahd_inb(ahd, LASTPHASE) == P_BUSFREE
1719 && (ahd_inb(ahd, SSTAT0) & SELDI) == 0
1720 && ((ahd_inb(ahd, SSTAT0) & SELDO) == 0
1721 || (ahd_inb(ahd, SCSISEQ0) & ENSELO) == 0))
1722 /*
1723 * Assume packetized if we are not
1724 * on the bus in a non-packetized
1725 * capacity and any pending selection
1726 * was a packetized selection.
1727 */
1663 packetized = 1; 1728 packetized = 1;
1664 break; 1729 break;
1665 } 1730 }
@@ -2310,8 +2375,7 @@ ahd_handle_nonpkt_busfree(struct ahd_softc *ahd)
2310 "PRGMCNT == 0x%x\n", 2375 "PRGMCNT == 0x%x\n",
2311 ahd_lookup_phase_entry(lastphase)->phasemsg, 2376 ahd_lookup_phase_entry(lastphase)->phasemsg,
2312 aborted, 2377 aborted,
2313 ahd_inb(ahd, PRGMCNT) 2378 ahd_inw(ahd, PRGMCNT));
2314 | (ahd_inb(ahd, PRGMCNT+1) << 8));
2315 ahd_dump_card_state(ahd); 2379 ahd_dump_card_state(ahd);
2316 } 2380 }
2317 /* Always restart the sequencer. */ 2381 /* Always restart the sequencer. */
@@ -2474,8 +2538,7 @@ ahd_clear_critical_section(struct ahd_softc *ahd)
2474 u_int i; 2538 u_int i;
2475 2539
2476 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); 2540 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
2477 seqaddr = ahd_inb(ahd, CURADDR) 2541 seqaddr = ahd_inw(ahd, CURADDR);
2478 | (ahd_inb(ahd, CURADDR+1) << 8);
2479 2542
2480 cs = ahd->critical_sections; 2543 cs = ahd->critical_sections;
2481 for (i = 0; i < ahd->num_critical_sections; i++, cs++) { 2544 for (i = 0; i < ahd->num_critical_sections; i++, cs++) {
@@ -3196,14 +3259,25 @@ ahd_update_neg_table(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
3196 iocell_opts[AHD_PRECOMP_SLEW_INDEX] &= ~AHD_PRECOMP_MASK; 3259 iocell_opts[AHD_PRECOMP_SLEW_INDEX] &= ~AHD_PRECOMP_MASK;
3197 3260
3198 if ((ahd->features & AHD_NEW_IOCELL_OPTS) != 0 3261 if ((ahd->features & AHD_NEW_IOCELL_OPTS) != 0
3199 && (ppr_opts & MSG_EXT_PPR_DT_REQ) != 0) { 3262 && (ppr_opts & MSG_EXT_PPR_DT_REQ) != 0
3263 && (ppr_opts & MSG_EXT_PPR_IU_REQ) == 0) {
3200 /* 3264 /*
3201 * Slow down our CRC interval to be 3265 * Slow down our CRC interval to be
3202 * compatible with devices that can't 3266 * compatible with non-packetized
3203 * handle a CRC at full speed. 3267 * U160 devices that can't handle a
3268 * CRC at full speed.
3204 */ 3269 */
3205 con_opts |= ENSLOWCRC; 3270 con_opts |= ENSLOWCRC;
3206 } 3271 }
3272
3273 if ((ahd->bugs & AHD_PACED_NEGTABLE_BUG) != 0) {
3274 /*
3275 * On H2A4, revert to a slower slewrate
3276 * on non-paced transfers.
3277 */
3278 iocell_opts[AHD_PRECOMP_SLEW_INDEX] &=
3279 ~AHD_SLEWRATE_MASK;
3280 }
3207 } 3281 }
3208 3282
3209 ahd_outb(ahd, ANNEXCOL, AHD_ANNEXCOL_PRECOMP_SLEW); 3283 ahd_outb(ahd, ANNEXCOL, AHD_ANNEXCOL_PRECOMP_SLEW);
@@ -3292,11 +3366,15 @@ ahd_update_pending_scbs(struct ahd_softc *ahd)
3292 * Force the sequencer to reinitialize the selection for 3366 * Force the sequencer to reinitialize the selection for
3293 * the command at the head of the execution queue if it 3367 * the command at the head of the execution queue if it
3294 * has already been setup. The negotiation changes may 3368 * has already been setup. The negotiation changes may
3295 * effect whether we select-out with ATN. 3369 * effect whether we select-out with ATN. It is only
3370 * safe to clear ENSELO when the bus is not free and no
3371 * selection is in progres or completed.
3296 */ 3372 */
3297 saved_modes = ahd_save_modes(ahd); 3373 saved_modes = ahd_save_modes(ahd);
3298 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); 3374 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
3299 ahd_outb(ahd, SCSISEQ0, ahd_inb(ahd, SCSISEQ0) & ~ENSELO); 3375 if ((ahd_inb(ahd, SCSISIGI) & BSYI) != 0
3376 && (ahd_inb(ahd, SSTAT0) & (SELDO|SELINGO)) == 0)
3377 ahd_outb(ahd, SCSISEQ0, ahd_inb(ahd, SCSISEQ0) & ~ENSELO);
3300 saved_scbptr = ahd_get_scbptr(ahd); 3378 saved_scbptr = ahd_get_scbptr(ahd);
3301 /* Ensure that the hscbs down on the card match the new information */ 3379 /* Ensure that the hscbs down on the card match the new information */
3302 for (scb_tag = 0; scb_tag < ahd->scb_data.maxhscbs; scb_tag++) { 3380 for (scb_tag = 0; scb_tag < ahd->scb_data.maxhscbs; scb_tag++) {
@@ -4909,10 +4987,7 @@ ahd_reinitialize_dataptrs(struct ahd_softc *ahd)
4909 * Determine initial values for data_addr and data_cnt 4987 * Determine initial values for data_addr and data_cnt
4910 * for resuming the data phase. 4988 * for resuming the data phase.
4911 */ 4989 */
4912 sgptr = (ahd_inb_scbram(ahd, SCB_RESIDUAL_SGPTR + 3) << 24) 4990 sgptr = ahd_inl_scbram(ahd, SCB_RESIDUAL_SGPTR);
4913 | (ahd_inb_scbram(ahd, SCB_RESIDUAL_SGPTR + 2) << 16)
4914 | (ahd_inb_scbram(ahd, SCB_RESIDUAL_SGPTR + 1) << 8)
4915 | ahd_inb_scbram(ahd, SCB_RESIDUAL_SGPTR);
4916 sgptr &= SG_PTR_MASK; 4991 sgptr &= SG_PTR_MASK;
4917 4992
4918 resid = (ahd_inb_scbram(ahd, SCB_RESIDUAL_DATACNT + 2) << 16) 4993 resid = (ahd_inb_scbram(ahd, SCB_RESIDUAL_DATACNT + 2) << 16)
@@ -4930,10 +5005,7 @@ ahd_reinitialize_dataptrs(struct ahd_softc *ahd)
4930 dataptr = ahd_le64toh(sg->addr) 5005 dataptr = ahd_le64toh(sg->addr)
4931 + (ahd_le32toh(sg->len) & AHD_SG_LEN_MASK) 5006 + (ahd_le32toh(sg->len) & AHD_SG_LEN_MASK)
4932 - resid; 5007 - resid;
4933 ahd_outb(ahd, HADDR + 7, dataptr >> 56); 5008 ahd_outl(ahd, HADDR + 4, dataptr >> 32);
4934 ahd_outb(ahd, HADDR + 6, dataptr >> 48);
4935 ahd_outb(ahd, HADDR + 5, dataptr >> 40);
4936 ahd_outb(ahd, HADDR + 4, dataptr >> 32);
4937 } else { 5009 } else {
4938 struct ahd_dma_seg *sg; 5010 struct ahd_dma_seg *sg;
4939 5011
@@ -4948,10 +5020,7 @@ ahd_reinitialize_dataptrs(struct ahd_softc *ahd)
4948 ahd_outb(ahd, HADDR + 4, 5020 ahd_outb(ahd, HADDR + 4,
4949 (ahd_le32toh(sg->len) & ~AHD_SG_LEN_MASK) >> 24); 5021 (ahd_le32toh(sg->len) & ~AHD_SG_LEN_MASK) >> 24);
4950 } 5022 }
4951 ahd_outb(ahd, HADDR + 3, dataptr >> 24); 5023 ahd_outl(ahd, HADDR, dataptr);
4952 ahd_outb(ahd, HADDR + 2, dataptr >> 16);
4953 ahd_outb(ahd, HADDR + 1, dataptr >> 8);
4954 ahd_outb(ahd, HADDR, dataptr);
4955 ahd_outb(ahd, HCNT + 2, resid >> 16); 5024 ahd_outb(ahd, HCNT + 2, resid >> 16);
4956 ahd_outb(ahd, HCNT + 1, resid >> 8); 5025 ahd_outb(ahd, HCNT + 1, resid >> 8);
4957 ahd_outb(ahd, HCNT, resid); 5026 ahd_outb(ahd, HCNT, resid);
@@ -5011,13 +5080,14 @@ ahd_handle_devreset(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
5011 ahd_set_width(ahd, devinfo, MSG_EXT_WDTR_BUS_8_BIT, 5080 ahd_set_width(ahd, devinfo, MSG_EXT_WDTR_BUS_8_BIT,
5012 AHD_TRANS_CUR, /*paused*/TRUE); 5081 AHD_TRANS_CUR, /*paused*/TRUE);
5013 ahd_set_syncrate(ahd, devinfo, /*period*/0, /*offset*/0, 5082 ahd_set_syncrate(ahd, devinfo, /*period*/0, /*offset*/0,
5014 /*ppr_options*/0, AHD_TRANS_CUR, /*paused*/TRUE); 5083 /*ppr_options*/0, AHD_TRANS_CUR,
5084 /*paused*/TRUE);
5015 5085
5016 ahd_send_async(ahd, devinfo->channel, devinfo->target, 5086 if (status != CAM_SEL_TIMEOUT)
5017 lun, AC_SENT_BDR, NULL); 5087 ahd_send_async(ahd, devinfo->channel, devinfo->target,
5088 CAM_LUN_WILDCARD, AC_SENT_BDR, NULL);
5018 5089
5019 if (message != NULL 5090 if (message != NULL && bootverbose)
5020 && (verbose_level <= bootverbose))
5021 printf("%s: %s on %c:%d. %d SCBs aborted\n", ahd_name(ahd), 5091 printf("%s: %s on %c:%d. %d SCBs aborted\n", ahd_name(ahd),
5022 message, devinfo->channel, devinfo->target, found); 5092 message, devinfo->channel, devinfo->target, found);
5023} 5093}
@@ -5203,13 +5273,13 @@ ahd_free(struct ahd_softc *ahd)
5203 /* FALLTHROUGH */ 5273 /* FALLTHROUGH */
5204 case 4: 5274 case 4:
5205 ahd_dmamap_unload(ahd, ahd->shared_data_dmat, 5275 ahd_dmamap_unload(ahd, ahd->shared_data_dmat,
5206 ahd->shared_data_dmamap); 5276 ahd->shared_data_map.dmamap);
5207 /* FALLTHROUGH */ 5277 /* FALLTHROUGH */
5208 case 3: 5278 case 3:
5209 ahd_dmamem_free(ahd, ahd->shared_data_dmat, ahd->qoutfifo, 5279 ahd_dmamem_free(ahd, ahd->shared_data_dmat, ahd->qoutfifo,
5210 ahd->shared_data_dmamap); 5280 ahd->shared_data_map.dmamap);
5211 ahd_dmamap_destroy(ahd, ahd->shared_data_dmat, 5281 ahd_dmamap_destroy(ahd, ahd->shared_data_dmat,
5212 ahd->shared_data_dmamap); 5282 ahd->shared_data_map.dmamap);
5213 /* FALLTHROUGH */ 5283 /* FALLTHROUGH */
5214 case 2: 5284 case 2:
5215 ahd_dma_tag_destroy(ahd, ahd->shared_data_dmat); 5285 ahd_dma_tag_destroy(ahd, ahd->shared_data_dmat);
@@ -5975,16 +6045,13 @@ ahd_alloc_scbs(struct ahd_softc *ahd)
5975 newcount = MIN(scb_data->sense_left, scb_data->scbs_left); 6045 newcount = MIN(scb_data->sense_left, scb_data->scbs_left);
5976 newcount = MIN(newcount, scb_data->sgs_left); 6046 newcount = MIN(newcount, scb_data->sgs_left);
5977 newcount = MIN(newcount, (AHD_SCB_MAX_ALLOC - scb_data->numscbs)); 6047 newcount = MIN(newcount, (AHD_SCB_MAX_ALLOC - scb_data->numscbs));
5978 scb_data->sense_left -= newcount;
5979 scb_data->scbs_left -= newcount;
5980 scb_data->sgs_left -= newcount;
5981 for (i = 0; i < newcount; i++) { 6048 for (i = 0; i < newcount; i++) {
5982 u_int col_tag;
5983
5984 struct scb_platform_data *pdata; 6049 struct scb_platform_data *pdata;
6050 u_int col_tag;
5985#ifndef __linux__ 6051#ifndef __linux__
5986 int error; 6052 int error;
5987#endif 6053#endif
6054
5988 next_scb = (struct scb *)malloc(sizeof(*next_scb), 6055 next_scb = (struct scb *)malloc(sizeof(*next_scb),
5989 M_DEVBUF, M_NOWAIT); 6056 M_DEVBUF, M_NOWAIT);
5990 if (next_scb == NULL) 6057 if (next_scb == NULL)
@@ -6041,6 +6108,9 @@ ahd_alloc_scbs(struct ahd_softc *ahd)
6041 sense_data += AHD_SENSE_BUFSIZE; 6108 sense_data += AHD_SENSE_BUFSIZE;
6042 sense_busaddr += AHD_SENSE_BUFSIZE; 6109 sense_busaddr += AHD_SENSE_BUFSIZE;
6043 scb_data->numscbs++; 6110 scb_data->numscbs++;
6111 scb_data->sense_left--;
6112 scb_data->scbs_left--;
6113 scb_data->sgs_left--;
6044 } 6114 }
6045} 6115}
6046 6116
@@ -6088,7 +6158,6 @@ static const char *termstat_strings[] = {
6088int 6158int
6089ahd_init(struct ahd_softc *ahd) 6159ahd_init(struct ahd_softc *ahd)
6090{ 6160{
6091 uint8_t *base_vaddr;
6092 uint8_t *next_vaddr; 6161 uint8_t *next_vaddr;
6093 dma_addr_t next_baddr; 6162 dma_addr_t next_baddr;
6094 size_t driver_data_size; 6163 size_t driver_data_size;
@@ -6156,7 +6225,7 @@ ahd_init(struct ahd_softc *ahd)
6156 * for the target mode role, we must additionally provide space for 6225 * for the target mode role, we must additionally provide space for
6157 * the incoming target command fifo. 6226 * the incoming target command fifo.
6158 */ 6227 */
6159 driver_data_size = AHD_SCB_MAX * sizeof(uint16_t) 6228 driver_data_size = AHD_SCB_MAX * sizeof(*ahd->qoutfifo)
6160 + sizeof(struct hardware_scb); 6229 + sizeof(struct hardware_scb);
6161 if ((ahd->features & AHD_TARGETMODE) != 0) 6230 if ((ahd->features & AHD_TARGETMODE) != 0)
6162 driver_data_size += AHD_TMODE_CMDS * sizeof(struct target_cmd); 6231 driver_data_size += AHD_TMODE_CMDS * sizeof(struct target_cmd);
@@ -6178,20 +6247,23 @@ ahd_init(struct ahd_softc *ahd)
6178 6247
6179 /* Allocation of driver data */ 6248 /* Allocation of driver data */
6180 if (ahd_dmamem_alloc(ahd, ahd->shared_data_dmat, 6249 if (ahd_dmamem_alloc(ahd, ahd->shared_data_dmat,
6181 (void **)&base_vaddr, 6250 (void **)&ahd->shared_data_map.vaddr,
6182 BUS_DMA_NOWAIT, &ahd->shared_data_dmamap) != 0) { 6251 BUS_DMA_NOWAIT,
6252 &ahd->shared_data_map.dmamap) != 0) {
6183 return (ENOMEM); 6253 return (ENOMEM);
6184 } 6254 }
6185 6255
6186 ahd->init_level++; 6256 ahd->init_level++;
6187 6257
6188 /* And permanently map it in */ 6258 /* And permanently map it in */
6189 ahd_dmamap_load(ahd, ahd->shared_data_dmat, ahd->shared_data_dmamap, 6259 ahd_dmamap_load(ahd, ahd->shared_data_dmat, ahd->shared_data_map.dmamap,
6190 base_vaddr, driver_data_size, ahd_dmamap_cb, 6260 ahd->shared_data_map.vaddr, driver_data_size,
6191 &ahd->shared_data_busaddr, /*flags*/0); 6261 ahd_dmamap_cb, &ahd->shared_data_map.physaddr,
6192 ahd->qoutfifo = (uint16_t *)base_vaddr; 6262 /*flags*/0);
6263 ahd->qoutfifo = (struct ahd_completion *)ahd->shared_data_map.vaddr;
6193 next_vaddr = (uint8_t *)&ahd->qoutfifo[AHD_QOUT_SIZE]; 6264 next_vaddr = (uint8_t *)&ahd->qoutfifo[AHD_QOUT_SIZE];
6194 next_baddr = ahd->shared_data_busaddr + AHD_QOUT_SIZE*sizeof(uint16_t); 6265 next_baddr = ahd->shared_data_map.physaddr
6266 + AHD_QOUT_SIZE*sizeof(struct ahd_completion);
6195 if ((ahd->features & AHD_TARGETMODE) != 0) { 6267 if ((ahd->features & AHD_TARGETMODE) != 0) {
6196 ahd->targetcmds = (struct target_cmd *)next_vaddr; 6268 ahd->targetcmds = (struct target_cmd *)next_vaddr;
6197 next_vaddr += AHD_TMODE_CMDS * sizeof(struct target_cmd); 6269 next_vaddr += AHD_TMODE_CMDS * sizeof(struct target_cmd);
@@ -6212,6 +6284,7 @@ ahd_init(struct ahd_softc *ahd)
6212 * specially from the DMA safe memory chunk used for the QOUTFIFO. 6284 * specially from the DMA safe memory chunk used for the QOUTFIFO.
6213 */ 6285 */
6214 ahd->next_queued_hscb = (struct hardware_scb *)next_vaddr; 6286 ahd->next_queued_hscb = (struct hardware_scb *)next_vaddr;
6287 ahd->next_queued_hscb_map = &ahd->shared_data_map;
6215 ahd->next_queued_hscb->hscb_busaddr = ahd_htole32(next_baddr); 6288 ahd->next_queued_hscb->hscb_busaddr = ahd_htole32(next_baddr);
6216 6289
6217 ahd->init_level++; 6290 ahd->init_level++;
@@ -6517,10 +6590,10 @@ ahd_chip_init(struct ahd_softc *ahd)
6517 6590
6518 /* All of our queues are empty */ 6591 /* All of our queues are empty */
6519 ahd->qoutfifonext = 0; 6592 ahd->qoutfifonext = 0;
6520 ahd->qoutfifonext_valid_tag = QOUTFIFO_ENTRY_VALID_LE; 6593 ahd->qoutfifonext_valid_tag = QOUTFIFO_ENTRY_VALID;
6521 ahd_outb(ahd, QOUTFIFO_ENTRY_VALID_TAG, QOUTFIFO_ENTRY_VALID >> 8); 6594 ahd_outb(ahd, QOUTFIFO_ENTRY_VALID_TAG, QOUTFIFO_ENTRY_VALID);
6522 for (i = 0; i < AHD_QOUT_SIZE; i++) 6595 for (i = 0; i < AHD_QOUT_SIZE; i++)
6523 ahd->qoutfifo[i] = 0; 6596 ahd->qoutfifo[i].valid_tag = 0;
6524 ahd_sync_qoutfifo(ahd, BUS_DMASYNC_PREREAD); 6597 ahd_sync_qoutfifo(ahd, BUS_DMASYNC_PREREAD);
6525 6598
6526 ahd->qinfifonext = 0; 6599 ahd->qinfifonext = 0;
@@ -6553,24 +6626,22 @@ ahd_chip_init(struct ahd_softc *ahd)
6553 ahd_outw(ahd, COMPLETE_SCB_HEAD, SCB_LIST_NULL); 6626 ahd_outw(ahd, COMPLETE_SCB_HEAD, SCB_LIST_NULL);
6554 ahd_outw(ahd, COMPLETE_SCB_DMAINPROG_HEAD, SCB_LIST_NULL); 6627 ahd_outw(ahd, COMPLETE_SCB_DMAINPROG_HEAD, SCB_LIST_NULL);
6555 ahd_outw(ahd, COMPLETE_DMA_SCB_HEAD, SCB_LIST_NULL); 6628 ahd_outw(ahd, COMPLETE_DMA_SCB_HEAD, SCB_LIST_NULL);
6629 ahd_outw(ahd, COMPLETE_DMA_SCB_TAIL, SCB_LIST_NULL);
6630 ahd_outw(ahd, COMPLETE_ON_QFREEZE_HEAD, SCB_LIST_NULL);
6556 6631
6557 /* 6632 /*
6558 * The Freeze Count is 0. 6633 * The Freeze Count is 0.
6559 */ 6634 */
6635 ahd->qfreeze_cnt = 0;
6560 ahd_outw(ahd, QFREEZE_COUNT, 0); 6636 ahd_outw(ahd, QFREEZE_COUNT, 0);
6637 ahd_outw(ahd, KERNEL_QFREEZE_COUNT, 0);
6561 6638
6562 /* 6639 /*
6563 * Tell the sequencer where it can find our arrays in memory. 6640 * Tell the sequencer where it can find our arrays in memory.
6564 */ 6641 */
6565 busaddr = ahd->shared_data_busaddr; 6642 busaddr = ahd->shared_data_map.physaddr;
6566 ahd_outb(ahd, SHARED_DATA_ADDR, busaddr & 0xFF); 6643 ahd_outl(ahd, SHARED_DATA_ADDR, busaddr);
6567 ahd_outb(ahd, SHARED_DATA_ADDR + 1, (busaddr >> 8) & 0xFF); 6644 ahd_outl(ahd, QOUTFIFO_NEXT_ADDR, busaddr);
6568 ahd_outb(ahd, SHARED_DATA_ADDR + 2, (busaddr >> 16) & 0xFF);
6569 ahd_outb(ahd, SHARED_DATA_ADDR + 3, (busaddr >> 24) & 0xFF);
6570 ahd_outb(ahd, QOUTFIFO_NEXT_ADDR, busaddr & 0xFF);
6571 ahd_outb(ahd, QOUTFIFO_NEXT_ADDR + 1, (busaddr >> 8) & 0xFF);
6572 ahd_outb(ahd, QOUTFIFO_NEXT_ADDR + 2, (busaddr >> 16) & 0xFF);
6573 ahd_outb(ahd, QOUTFIFO_NEXT_ADDR + 3, (busaddr >> 24) & 0xFF);
6574 6645
6575 /* 6646 /*
6576 * Setup the allowed SCSI Sequences based on operational mode. 6647 * Setup the allowed SCSI Sequences based on operational mode.
@@ -6619,10 +6690,7 @@ ahd_chip_init(struct ahd_softc *ahd)
6619 * Tell the sequencer which SCB will be the next one it receives. 6690 * Tell the sequencer which SCB will be the next one it receives.
6620 */ 6691 */
6621 busaddr = ahd_le32toh(ahd->next_queued_hscb->hscb_busaddr); 6692 busaddr = ahd_le32toh(ahd->next_queued_hscb->hscb_busaddr);
6622 ahd_outb(ahd, NEXT_QUEUED_SCB_ADDR + 0, busaddr & 0xFF); 6693 ahd_outl(ahd, NEXT_QUEUED_SCB_ADDR, busaddr);
6623 ahd_outb(ahd, NEXT_QUEUED_SCB_ADDR + 1, (busaddr >> 8) & 0xFF);
6624 ahd_outb(ahd, NEXT_QUEUED_SCB_ADDR + 2, (busaddr >> 16) & 0xFF);
6625 ahd_outb(ahd, NEXT_QUEUED_SCB_ADDR + 3, (busaddr >> 24) & 0xFF);
6626 6694
6627 /* 6695 /*
6628 * Default to coalescing disabled. 6696 * Default to coalescing disabled.
@@ -6926,43 +6994,34 @@ ahd_pause_and_flushwork(struct ahd_softc *ahd)
6926{ 6994{
6927 u_int intstat; 6995 u_int intstat;
6928 u_int maxloops; 6996 u_int maxloops;
6929 u_int qfreeze_cnt;
6930 6997
6931 maxloops = 1000; 6998 maxloops = 1000;
6932 ahd->flags |= AHD_ALL_INTERRUPTS; 6999 ahd->flags |= AHD_ALL_INTERRUPTS;
6933 ahd_pause(ahd); 7000 ahd_pause(ahd);
6934 /* 7001 /*
6935 * Increment the QFreeze Count so that the sequencer 7002 * Freeze the outgoing selections. We do this only
6936 * will not start new selections. We do this only
6937 * until we are safely paused without further selections 7003 * until we are safely paused without further selections
6938 * pending. 7004 * pending.
6939 */ 7005 */
6940 ahd_outw(ahd, QFREEZE_COUNT, ahd_inw(ahd, QFREEZE_COUNT) + 1); 7006 ahd->qfreeze_cnt--;
7007 ahd_outw(ahd, KERNEL_QFREEZE_COUNT, ahd->qfreeze_cnt);
6941 ahd_outb(ahd, SEQ_FLAGS2, ahd_inb(ahd, SEQ_FLAGS2) | SELECTOUT_QFROZEN); 7008 ahd_outb(ahd, SEQ_FLAGS2, ahd_inb(ahd, SEQ_FLAGS2) | SELECTOUT_QFROZEN);
6942 do { 7009 do {
6943 struct scb *waiting_scb;
6944 7010
6945 ahd_unpause(ahd); 7011 ahd_unpause(ahd);
7012 /*
7013 * Give the sequencer some time to service
7014 * any active selections.
7015 */
7016 ahd_delay(500);
7017
6946 ahd_intr(ahd); 7018 ahd_intr(ahd);
6947 ahd_pause(ahd); 7019 ahd_pause(ahd);
6948 ahd_clear_critical_section(ahd);
6949 intstat = ahd_inb(ahd, INTSTAT); 7020 intstat = ahd_inb(ahd, INTSTAT);
6950 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); 7021 if ((intstat & INT_PEND) == 0) {
6951 if ((ahd_inb(ahd, SSTAT0) & (SELDO|SELINGO)) == 0) 7022 ahd_clear_critical_section(ahd);
6952 ahd_outb(ahd, SCSISEQ0, 7023 intstat = ahd_inb(ahd, INTSTAT);
6953 ahd_inb(ahd, SCSISEQ0) & ~ENSELO); 7024 }
6954 /*
6955 * In the non-packetized case, the sequencer (for Rev A),
6956 * relies on ENSELO remaining set after SELDO. The hardware
6957 * auto-clears ENSELO in the packetized case.
6958 */
6959 waiting_scb = ahd_lookup_scb(ahd,
6960 ahd_inw(ahd, WAITING_TID_HEAD));
6961 if (waiting_scb != NULL
6962 && (waiting_scb->flags & SCB_PACKETIZED) == 0
6963 && (ahd_inb(ahd, SSTAT0) & (SELDO|SELINGO)) != 0)
6964 ahd_outb(ahd, SCSISEQ0,
6965 ahd_inb(ahd, SCSISEQ0) | ENSELO);
6966 } while (--maxloops 7025 } while (--maxloops
6967 && (intstat != 0xFF || (ahd->features & AHD_REMOVABLE) == 0) 7026 && (intstat != 0xFF || (ahd->features & AHD_REMOVABLE) == 0)
6968 && ((intstat & INT_PEND) != 0 7027 && ((intstat & INT_PEND) != 0
@@ -6973,17 +7032,8 @@ ahd_pause_and_flushwork(struct ahd_softc *ahd)
6973 printf("Infinite interrupt loop, INTSTAT = %x", 7032 printf("Infinite interrupt loop, INTSTAT = %x",
6974 ahd_inb(ahd, INTSTAT)); 7033 ahd_inb(ahd, INTSTAT));
6975 } 7034 }
6976 qfreeze_cnt = ahd_inw(ahd, QFREEZE_COUNT); 7035 ahd->qfreeze_cnt++;
6977 if (qfreeze_cnt == 0) { 7036 ahd_outw(ahd, KERNEL_QFREEZE_COUNT, ahd->qfreeze_cnt);
6978 printf("%s: ahd_pause_and_flushwork with 0 qfreeze count!\n",
6979 ahd_name(ahd));
6980 } else {
6981 qfreeze_cnt--;
6982 }
6983 ahd_outw(ahd, QFREEZE_COUNT, qfreeze_cnt);
6984 if (qfreeze_cnt == 0)
6985 ahd_outb(ahd, SEQ_FLAGS2,
6986 ahd_inb(ahd, SEQ_FLAGS2) & ~SELECTOUT_QFROZEN);
6987 7037
6988 ahd_flush_qoutfifo(ahd); 7038 ahd_flush_qoutfifo(ahd);
6989 7039
@@ -7155,10 +7205,7 @@ ahd_qinfifo_requeue(struct ahd_softc *ahd, struct scb *prev_scb,
7155 uint32_t busaddr; 7205 uint32_t busaddr;
7156 7206
7157 busaddr = ahd_le32toh(scb->hscb->hscb_busaddr); 7207 busaddr = ahd_le32toh(scb->hscb->hscb_busaddr);
7158 ahd_outb(ahd, NEXT_QUEUED_SCB_ADDR + 0, busaddr & 0xFF); 7208 ahd_outl(ahd, NEXT_QUEUED_SCB_ADDR, busaddr);
7159 ahd_outb(ahd, NEXT_QUEUED_SCB_ADDR + 1, (busaddr >> 8) & 0xFF);
7160 ahd_outb(ahd, NEXT_QUEUED_SCB_ADDR + 2, (busaddr >> 16) & 0xFF);
7161 ahd_outb(ahd, NEXT_QUEUED_SCB_ADDR + 3, (busaddr >> 24) & 0xFF);
7162 } else { 7209 } else {
7163 prev_scb->hscb->next_hscb_busaddr = scb->hscb->hscb_busaddr; 7210 prev_scb->hscb->next_hscb_busaddr = scb->hscb->hscb_busaddr;
7164 ahd_sync_scb(ahd, prev_scb, 7211 ahd_sync_scb(ahd, prev_scb,
@@ -7265,10 +7312,7 @@ ahd_search_qinfifo(struct ahd_softc *ahd, int target, char channel,
7265 */ 7312 */
7266 ahd->qinfifonext = qinstart; 7313 ahd->qinfifonext = qinstart;
7267 busaddr = ahd_le32toh(ahd->next_queued_hscb->hscb_busaddr); 7314 busaddr = ahd_le32toh(ahd->next_queued_hscb->hscb_busaddr);
7268 ahd_outb(ahd, NEXT_QUEUED_SCB_ADDR + 0, busaddr & 0xFF); 7315 ahd_outl(ahd, NEXT_QUEUED_SCB_ADDR, busaddr);
7269 ahd_outb(ahd, NEXT_QUEUED_SCB_ADDR + 1, (busaddr >> 8) & 0xFF);
7270 ahd_outb(ahd, NEXT_QUEUED_SCB_ADDR + 2, (busaddr >> 16) & 0xFF);
7271 ahd_outb(ahd, NEXT_QUEUED_SCB_ADDR + 3, (busaddr >> 24) & 0xFF);
7272 7316
7273 while (qinpos != qintail) { 7317 while (qinpos != qintail) {
7274 scb = ahd_lookup_scb(ahd, ahd->qinfifo[qinpos]); 7318 scb = ahd_lookup_scb(ahd, ahd->qinfifo[qinpos]);
@@ -7330,6 +7374,7 @@ ahd_search_qinfifo(struct ahd_softc *ahd, int target, char channel,
7330 * appropriate, traverse the SCBs of each "their id" 7374 * appropriate, traverse the SCBs of each "their id"
7331 * looking for matches. 7375 * looking for matches.
7332 */ 7376 */
7377 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
7333 savedscbptr = ahd_get_scbptr(ahd); 7378 savedscbptr = ahd_get_scbptr(ahd);
7334 tid_next = ahd_inw(ahd, WAITING_TID_HEAD); 7379 tid_next = ahd_inw(ahd, WAITING_TID_HEAD);
7335 tid_prev = SCB_LIST_NULL; 7380 tid_prev = SCB_LIST_NULL;
@@ -7399,7 +7444,7 @@ ahd_search_scb_list(struct ahd_softc *ahd, int target, char channel,
7399 u_int prev; 7444 u_int prev;
7400 int found; 7445 int found;
7401 7446
7402 AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK); 7447 AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
7403 found = 0; 7448 found = 0;
7404 prev = SCB_LIST_NULL; 7449 prev = SCB_LIST_NULL;
7405 next = *list_head; 7450 next = *list_head;
@@ -7466,7 +7511,7 @@ static void
7466ahd_stitch_tid_list(struct ahd_softc *ahd, u_int tid_prev, 7511ahd_stitch_tid_list(struct ahd_softc *ahd, u_int tid_prev,
7467 u_int tid_cur, u_int tid_next) 7512 u_int tid_cur, u_int tid_next)
7468{ 7513{
7469 AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK); 7514 AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
7470 7515
7471 if (SCBID_IS_NULL(tid_cur)) { 7516 if (SCBID_IS_NULL(tid_cur)) {
7472 7517
@@ -7506,7 +7551,7 @@ ahd_rem_wscb(struct ahd_softc *ahd, u_int scbid,
7506{ 7551{
7507 u_int tail_offset; 7552 u_int tail_offset;
7508 7553
7509 AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK); 7554 AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
7510 if (!SCBID_IS_NULL(prev)) { 7555 if (!SCBID_IS_NULL(prev)) {
7511 ahd_set_scbptr(ahd, prev); 7556 ahd_set_scbptr(ahd, prev);
7512 ahd_outw(ahd, SCB_NEXT, next); 7557 ahd_outw(ahd, SCB_NEXT, next);
@@ -7739,7 +7784,7 @@ ahd_reset_channel(struct ahd_softc *ahd, char channel, int initiate_reset)
7739 */ 7784 */
7740 ahd_clear_msg_state(ahd); 7785 ahd_clear_msg_state(ahd);
7741 ahd_outb(ahd, SIMODE1, 7786 ahd_outb(ahd, SIMODE1,
7742 ahd_inb(ahd, SIMODE1) & ~(ENBUSFREE|ENSCSIRST|ENBUSFREE)); 7787 ahd_inb(ahd, SIMODE1) & ~(ENBUSFREE|ENSCSIRST));
7743 7788
7744 if (initiate_reset) 7789 if (initiate_reset)
7745 ahd_reset_current_bus(ahd); 7790 ahd_reset_current_bus(ahd);
@@ -7910,30 +7955,35 @@ ahd_handle_scb_status(struct ahd_softc *ahd, struct scb *scb)
7910void 7955void
7911ahd_handle_scsi_status(struct ahd_softc *ahd, struct scb *scb) 7956ahd_handle_scsi_status(struct ahd_softc *ahd, struct scb *scb)
7912{ 7957{
7913 struct hardware_scb *hscb; 7958 struct hardware_scb *hscb;
7914 u_int qfreeze_cnt; 7959 int paused;
7915 7960
7916 /* 7961 /*
7917 * The sequencer freezes its select-out queue 7962 * The sequencer freezes its select-out queue
7918 * anytime a SCSI status error occurs. We must 7963 * anytime a SCSI status error occurs. We must
7919 * handle the error and decrement the QFREEZE count 7964 * handle the error and increment our qfreeze count
7920 * to allow the sequencer to continue. 7965 * to allow the sequencer to continue. We don't
7966 * bother clearing critical sections here since all
7967 * operations are on data structures that the sequencer
7968 * is not touching once the queue is frozen.
7921 */ 7969 */
7922 hscb = scb->hscb; 7970 hscb = scb->hscb;
7923 7971
7972 if (ahd_is_paused(ahd)) {
7973 paused = 1;
7974 } else {
7975 paused = 0;
7976 ahd_pause(ahd);
7977 }
7978
7924 /* Freeze the queue until the client sees the error. */ 7979 /* Freeze the queue until the client sees the error. */
7925 ahd_freeze_devq(ahd, scb); 7980 ahd_freeze_devq(ahd, scb);
7926 ahd_freeze_scb(scb); 7981 ahd_freeze_scb(scb);
7927 qfreeze_cnt = ahd_inw(ahd, QFREEZE_COUNT); 7982 ahd->qfreeze_cnt++;
7928 if (qfreeze_cnt == 0) { 7983 ahd_outw(ahd, KERNEL_QFREEZE_COUNT, ahd->qfreeze_cnt);
7929 printf("%s: Bad status with 0 qfreeze count!\n", ahd_name(ahd)); 7984
7930 } else { 7985 if (paused == 0)
7931 qfreeze_cnt--; 7986 ahd_unpause(ahd);
7932 ahd_outw(ahd, QFREEZE_COUNT, qfreeze_cnt);
7933 }
7934 if (qfreeze_cnt == 0)
7935 ahd_outb(ahd, SEQ_FLAGS2,
7936 ahd_inb(ahd, SEQ_FLAGS2) & ~SELECTOUT_QFROZEN);
7937 7987
7938 /* Don't want to clobber the original sense code */ 7988 /* Don't want to clobber the original sense code */
7939 if ((scb->flags & SCB_SENSE) != 0) { 7989 if ((scb->flags & SCB_SENSE) != 0) {
@@ -8317,8 +8367,7 @@ ahd_dumpseq(struct ahd_softc* ahd)
8317 max_prog = 2048; 8367 max_prog = 2048;
8318 8368
8319 ahd_outb(ahd, SEQCTL0, PERRORDIS|FAILDIS|FASTMODE|LOADRAM); 8369 ahd_outb(ahd, SEQCTL0, PERRORDIS|FAILDIS|FASTMODE|LOADRAM);
8320 ahd_outb(ahd, PRGMCNT, 0); 8370 ahd_outw(ahd, PRGMCNT, 0);
8321 ahd_outb(ahd, PRGMCNT+1, 0);
8322 for (i = 0; i < max_prog; i++) { 8371 for (i = 0; i < max_prog; i++) {
8323 uint8_t ins_bytes[4]; 8372 uint8_t ins_bytes[4];
8324 8373
@@ -8347,13 +8396,14 @@ ahd_loadseq(struct ahd_softc *ahd)
8347 u_int sg_prefetch_cnt_limit; 8396 u_int sg_prefetch_cnt_limit;
8348 u_int sg_prefetch_align; 8397 u_int sg_prefetch_align;
8349 u_int sg_size; 8398 u_int sg_size;
8399 u_int cacheline_mask;
8350 uint8_t download_consts[DOWNLOAD_CONST_COUNT]; 8400 uint8_t download_consts[DOWNLOAD_CONST_COUNT];
8351 8401
8352 if (bootverbose) 8402 if (bootverbose)
8353 printf("%s: Downloading Sequencer Program...", 8403 printf("%s: Downloading Sequencer Program...",
8354 ahd_name(ahd)); 8404 ahd_name(ahd));
8355 8405
8356#if DOWNLOAD_CONST_COUNT != 7 8406#if DOWNLOAD_CONST_COUNT != 8
8357#error "Download Const Mismatch" 8407#error "Download Const Mismatch"
8358#endif 8408#endif
8359 /* 8409 /*
@@ -8389,6 +8439,9 @@ ahd_loadseq(struct ahd_softc *ahd)
8389 /* Round down to the nearest power of 2. */ 8439 /* Round down to the nearest power of 2. */
8390 while (powerof2(sg_prefetch_align) == 0) 8440 while (powerof2(sg_prefetch_align) == 0)
8391 sg_prefetch_align--; 8441 sg_prefetch_align--;
8442
8443 cacheline_mask = sg_prefetch_align - 1;
8444
8392 /* 8445 /*
8393 * If the cacheline boundary is greater than half our prefetch RAM 8446 * If the cacheline boundary is greater than half our prefetch RAM
8394 * we risk not being able to fetch even a single complete S/G 8447 * we risk not being able to fetch even a single complete S/G
@@ -8429,12 +8482,12 @@ ahd_loadseq(struct ahd_softc *ahd)
8429 download_consts[PKT_OVERRUN_BUFOFFSET] = 8482 download_consts[PKT_OVERRUN_BUFOFFSET] =
8430 (ahd->overrun_buf - (uint8_t *)ahd->qoutfifo) / 256; 8483 (ahd->overrun_buf - (uint8_t *)ahd->qoutfifo) / 256;
8431 download_consts[SCB_TRANSFER_SIZE] = SCB_TRANSFER_SIZE_1BYTE_LUN; 8484 download_consts[SCB_TRANSFER_SIZE] = SCB_TRANSFER_SIZE_1BYTE_LUN;
8485 download_consts[CACHELINE_MASK] = cacheline_mask;
8432 cur_patch = patches; 8486 cur_patch = patches;
8433 downloaded = 0; 8487 downloaded = 0;
8434 skip_addr = 0; 8488 skip_addr = 0;
8435 ahd_outb(ahd, SEQCTL0, PERRORDIS|FAILDIS|FASTMODE|LOADRAM); 8489 ahd_outb(ahd, SEQCTL0, PERRORDIS|FAILDIS|FASTMODE|LOADRAM);
8436 ahd_outb(ahd, PRGMCNT, 0); 8490 ahd_outw(ahd, PRGMCNT, 0);
8437 ahd_outb(ahd, PRGMCNT+1, 0);
8438 8491
8439 for (i = 0; i < sizeof(seqprog)/4; i++) { 8492 for (i = 0; i < sizeof(seqprog)/4; i++) {
8440 if (ahd_check_patch(ahd, &cur_patch, i, &skip_addr) == 0) { 8493 if (ahd_check_patch(ahd, &cur_patch, i, &skip_addr) == 0) {
@@ -8727,7 +8780,7 @@ ahd_dump_card_state(struct ahd_softc *ahd)
8727 printf(">>>>>>>>>>>>>>>>>> Dump Card State Begins <<<<<<<<<<<<<<<<<\n" 8780 printf(">>>>>>>>>>>>>>>>>> Dump Card State Begins <<<<<<<<<<<<<<<<<\n"
8728 "%s: Dumping Card State at program address 0x%x Mode 0x%x\n", 8781 "%s: Dumping Card State at program address 0x%x Mode 0x%x\n",
8729 ahd_name(ahd), 8782 ahd_name(ahd),
8730 ahd_inb(ahd, CURADDR) | (ahd_inb(ahd, CURADDR+1) << 8), 8783 ahd_inw(ahd, CURADDR),
8731 ahd_build_mode_state(ahd, ahd->saved_src_mode, 8784 ahd_build_mode_state(ahd, ahd->saved_src_mode,
8732 ahd->saved_dst_mode)); 8785 ahd->saved_dst_mode));
8733 if (paused) 8786 if (paused)
@@ -8843,6 +8896,15 @@ ahd_dump_card_state(struct ahd_softc *ahd)
8843 scb_index = ahd_inw_scbram(ahd, SCB_NEXT_COMPLETE); 8896 scb_index = ahd_inw_scbram(ahd, SCB_NEXT_COMPLETE);
8844 } 8897 }
8845 printf("\n"); 8898 printf("\n");
8899 printf("Sequencer On QFreeze and Complete list: ");
8900 scb_index = ahd_inw(ahd, COMPLETE_ON_QFREEZE_HEAD);
8901 i = 0;
8902 while (!SCBID_IS_NULL(scb_index) && i++ < AHD_SCB_MAX) {
8903 ahd_set_scbptr(ahd, scb_index);
8904 printf("%d ", scb_index);
8905 scb_index = ahd_inw_scbram(ahd, SCB_NEXT_COMPLETE);
8906 }
8907 printf("\n");
8846 ahd_set_scbptr(ahd, saved_scb_index); 8908 ahd_set_scbptr(ahd, saved_scb_index);
8847 dffstat = ahd_inb(ahd, DFFSTAT); 8909 dffstat = ahd_inb(ahd, DFFSTAT);
8848 for (i = 0; i < 2; i++) { 8910 for (i = 0; i < 2; i++) {
@@ -9077,7 +9139,7 @@ ahd_wait_seeprom(struct ahd_softc *ahd)
9077{ 9139{
9078 int cnt; 9140 int cnt;
9079 9141
9080 cnt = 20; 9142 cnt = 5000;
9081 while ((ahd_inb(ahd, SEESTAT) & (SEEARBACK|SEEBUSY)) != 0 && --cnt) 9143 while ((ahd_inb(ahd, SEESTAT) & (SEEARBACK|SEEBUSY)) != 0 && --cnt)
9082 ahd_delay(5); 9144 ahd_delay(5);
9083 9145
@@ -9423,13 +9485,9 @@ ahd_handle_en_lun(struct ahd_softc *ahd, struct cam_sim *sim, union ccb *ccb)
9423 if ((ahd->features & AHD_MULTI_TID) != 0) { 9485 if ((ahd->features & AHD_MULTI_TID) != 0) {
9424 u_int targid_mask; 9486 u_int targid_mask;
9425 9487
9426 targid_mask = ahd_inb(ahd, TARGID) 9488 targid_mask = ahd_inw(ahd, TARGID);
9427 | (ahd_inb(ahd, TARGID + 1) << 8);
9428
9429 targid_mask |= target_mask; 9489 targid_mask |= target_mask;
9430 ahd_outb(ahd, TARGID, targid_mask); 9490 ahd_outw(ahd, TARGID, targid_mask);
9431 ahd_outb(ahd, TARGID+1, (targid_mask >> 8));
9432
9433 ahd_update_scsiid(ahd, targid_mask); 9491 ahd_update_scsiid(ahd, targid_mask);
9434 } else { 9492 } else {
9435 u_int our_id; 9493 u_int our_id;
@@ -9543,14 +9601,9 @@ ahd_handle_en_lun(struct ahd_softc *ahd, struct cam_sim *sim, union ccb *ccb)
9543 if (ahd->features & AHD_MULTI_TID) { 9601 if (ahd->features & AHD_MULTI_TID) {
9544 u_int targid_mask; 9602 u_int targid_mask;
9545 9603
9546 targid_mask = ahd_inb(ahd, TARGID) 9604 targid_mask = ahd_inw(ahd, TARGID);
9547 | (ahd_inb(ahd, TARGID + 1)
9548 << 8);
9549
9550 targid_mask &= ~target_mask; 9605 targid_mask &= ~target_mask;
9551 ahd_outb(ahd, TARGID, targid_mask); 9606 ahd_outw(ahd, TARGID, targid_mask);
9552 ahd_outb(ahd, TARGID+1,
9553 (targid_mask >> 8));
9554 ahd_update_scsiid(ahd, targid_mask); 9607 ahd_update_scsiid(ahd, targid_mask);
9555 } 9608 }
9556 } 9609 }
@@ -9651,7 +9704,7 @@ ahd_run_tqinfifo(struct ahd_softc *ahd, int paused)
9651 9704
9652 cmd->cmd_valid = 0; 9705 cmd->cmd_valid = 0;
9653 ahd_dmamap_sync(ahd, ahd->shared_data_dmat, 9706 ahd_dmamap_sync(ahd, ahd->shared_data_dmat,
9654 ahd->shared_data_dmamap, 9707 ahd->shared_data_map.dmamap,
9655 ahd_targetcmd_offset(ahd, ahd->tqinfifonext), 9708 ahd_targetcmd_offset(ahd, ahd->tqinfifonext),
9656 sizeof(struct target_cmd), 9709 sizeof(struct target_cmd),
9657 BUS_DMASYNC_PREREAD); 9710 BUS_DMASYNC_PREREAD);
diff --git a/drivers/scsi/aic7xxx/aic79xx_inline.h b/drivers/scsi/aic7xxx/aic79xx_inline.h
index d80bc5161fb1..91c4f7f484b1 100644
--- a/drivers/scsi/aic7xxx/aic79xx_inline.h
+++ b/drivers/scsi/aic7xxx/aic79xx_inline.h
@@ -37,7 +37,7 @@
37 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 37 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38 * POSSIBILITY OF SUCH DAMAGES. 38 * POSSIBILITY OF SUCH DAMAGES.
39 * 39 *
40 * $Id: //depot/aic7xxx/aic7xxx/aic79xx_inline.h#51 $ 40 * $Id: //depot/aic7xxx/aic7xxx/aic79xx_inline.h#58 $
41 * 41 *
42 * $FreeBSD$ 42 * $FreeBSD$
43 */ 43 */
@@ -522,12 +522,21 @@ do { \
522static __inline uint16_t 522static __inline uint16_t
523ahd_inw(struct ahd_softc *ahd, u_int port) 523ahd_inw(struct ahd_softc *ahd, u_int port)
524{ 524{
525 /*
526 * Read high byte first as some registers increment
527 * or have other side effects when the low byte is
528 * read.
529 */
525 return ((ahd_inb(ahd, port+1) << 8) | ahd_inb(ahd, port)); 530 return ((ahd_inb(ahd, port+1) << 8) | ahd_inb(ahd, port));
526} 531}
527 532
528static __inline void 533static __inline void
529ahd_outw(struct ahd_softc *ahd, u_int port, u_int value) 534ahd_outw(struct ahd_softc *ahd, u_int port, u_int value)
530{ 535{
536 /*
537 * Write low byte first to accomodate registers
538 * such as PRGMCNT where the order maters.
539 */
531 ahd_outb(ahd, port, value & 0xFF); 540 ahd_outb(ahd, port, value & 0xFF);
532 ahd_outb(ahd, port+1, (value >> 8) & 0xFF); 541 ahd_outb(ahd, port+1, (value >> 8) & 0xFF);
533} 542}
@@ -684,7 +693,7 @@ ahd_inb_scbram(struct ahd_softc *ahd, u_int offset)
684 * Razor #528 693 * Razor #528
685 */ 694 */
686 value = ahd_inb(ahd, offset); 695 value = ahd_inb(ahd, offset);
687 if ((ahd->flags & AHD_PCIX_SCBRAM_RD_BUG) != 0) 696 if ((ahd->bugs & AHD_PCIX_SCBRAM_RD_BUG) != 0)
688 ahd_inb(ahd, MODE_PTR); 697 ahd_inb(ahd, MODE_PTR);
689 return (value); 698 return (value);
690} 699}
@@ -727,7 +736,8 @@ ahd_lookup_scb(struct ahd_softc *ahd, u_int tag)
727static __inline void 736static __inline void
728ahd_swap_with_next_hscb(struct ahd_softc *ahd, struct scb *scb) 737ahd_swap_with_next_hscb(struct ahd_softc *ahd, struct scb *scb)
729{ 738{
730 struct hardware_scb *q_hscb; 739 struct hardware_scb *q_hscb;
740 struct map_node *q_hscb_map;
731 uint32_t saved_hscb_busaddr; 741 uint32_t saved_hscb_busaddr;
732 742
733 /* 743 /*
@@ -743,6 +753,7 @@ ahd_swap_with_next_hscb(struct ahd_softc *ahd, struct scb *scb)
743 * locate the correct SCB by SCB_TAG. 753 * locate the correct SCB by SCB_TAG.
744 */ 754 */
745 q_hscb = ahd->next_queued_hscb; 755 q_hscb = ahd->next_queued_hscb;
756 q_hscb_map = ahd->next_queued_hscb_map;
746 saved_hscb_busaddr = q_hscb->hscb_busaddr; 757 saved_hscb_busaddr = q_hscb->hscb_busaddr;
747 memcpy(q_hscb, scb->hscb, sizeof(*scb->hscb)); 758 memcpy(q_hscb, scb->hscb, sizeof(*scb->hscb));
748 q_hscb->hscb_busaddr = saved_hscb_busaddr; 759 q_hscb->hscb_busaddr = saved_hscb_busaddr;
@@ -750,7 +761,9 @@ ahd_swap_with_next_hscb(struct ahd_softc *ahd, struct scb *scb)
750 761
751 /* Now swap HSCB pointers. */ 762 /* Now swap HSCB pointers. */
752 ahd->next_queued_hscb = scb->hscb; 763 ahd->next_queued_hscb = scb->hscb;
764 ahd->next_queued_hscb_map = scb->hscb_map;
753 scb->hscb = q_hscb; 765 scb->hscb = q_hscb;
766 scb->hscb_map = q_hscb_map;
754 767
755 /* Now define the mapping from tag to SCB in the scbindex */ 768 /* Now define the mapping from tag to SCB in the scbindex */
756 ahd->scb_data.scbindex[SCB_GET_TAG(scb)] = scb; 769 ahd->scb_data.scbindex[SCB_GET_TAG(scb)] = scb;
@@ -824,8 +837,9 @@ static __inline int ahd_intr(struct ahd_softc *ahd);
824static __inline void 837static __inline void
825ahd_sync_qoutfifo(struct ahd_softc *ahd, int op) 838ahd_sync_qoutfifo(struct ahd_softc *ahd, int op)
826{ 839{
827 ahd_dmamap_sync(ahd, ahd->shared_data_dmat, ahd->shared_data_dmamap, 840 ahd_dmamap_sync(ahd, ahd->shared_data_dmat, ahd->shared_data_map.dmamap,
828 /*offset*/0, /*len*/AHC_SCB_MAX * sizeof(uint16_t), op); 841 /*offset*/0,
842 /*len*/AHD_SCB_MAX * sizeof(struct ahd_completion), op);
829} 843}
830 844
831static __inline void 845static __inline void
@@ -834,7 +848,7 @@ ahd_sync_tqinfifo(struct ahd_softc *ahd, int op)
834#ifdef AHD_TARGET_MODE 848#ifdef AHD_TARGET_MODE
835 if ((ahd->flags & AHD_TARGETROLE) != 0) { 849 if ((ahd->flags & AHD_TARGETROLE) != 0) {
836 ahd_dmamap_sync(ahd, ahd->shared_data_dmat, 850 ahd_dmamap_sync(ahd, ahd->shared_data_dmat,
837 ahd->shared_data_dmamap, 851 ahd->shared_data_map.dmamap,
838 ahd_targetcmd_offset(ahd, 0), 852 ahd_targetcmd_offset(ahd, 0),
839 sizeof(struct target_cmd) * AHD_TMODE_CMDS, 853 sizeof(struct target_cmd) * AHD_TMODE_CMDS,
840 op); 854 op);
@@ -854,17 +868,17 @@ ahd_check_cmdcmpltqueues(struct ahd_softc *ahd)
854 u_int retval; 868 u_int retval;
855 869
856 retval = 0; 870 retval = 0;
857 ahd_dmamap_sync(ahd, ahd->shared_data_dmat, ahd->shared_data_dmamap, 871 ahd_dmamap_sync(ahd, ahd->shared_data_dmat, ahd->shared_data_map.dmamap,
858 /*offset*/ahd->qoutfifonext, /*len*/2, 872 /*offset*/ahd->qoutfifonext * sizeof(*ahd->qoutfifo),
859 BUS_DMASYNC_POSTREAD); 873 /*len*/sizeof(*ahd->qoutfifo), BUS_DMASYNC_POSTREAD);
860 if ((ahd->qoutfifo[ahd->qoutfifonext] 874 if (ahd->qoutfifo[ahd->qoutfifonext].valid_tag
861 & QOUTFIFO_ENTRY_VALID_LE) == ahd->qoutfifonext_valid_tag) 875 == ahd->qoutfifonext_valid_tag)
862 retval |= AHD_RUN_QOUTFIFO; 876 retval |= AHD_RUN_QOUTFIFO;
863#ifdef AHD_TARGET_MODE 877#ifdef AHD_TARGET_MODE
864 if ((ahd->flags & AHD_TARGETROLE) != 0 878 if ((ahd->flags & AHD_TARGETROLE) != 0
865 && (ahd->flags & AHD_TQINFIFO_BLOCKED) == 0) { 879 && (ahd->flags & AHD_TQINFIFO_BLOCKED) == 0) {
866 ahd_dmamap_sync(ahd, ahd->shared_data_dmat, 880 ahd_dmamap_sync(ahd, ahd->shared_data_dmat,
867 ahd->shared_data_dmamap, 881 ahd->shared_data_map.dmamap,
868 ahd_targetcmd_offset(ahd, ahd->tqinfifofnext), 882 ahd_targetcmd_offset(ahd, ahd->tqinfifofnext),
869 /*len*/sizeof(struct target_cmd), 883 /*len*/sizeof(struct target_cmd),
870 BUS_DMASYNC_POSTREAD); 884 BUS_DMASYNC_POSTREAD);
diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c
index 1c8f872e2dd4..2567e29960bd 100644
--- a/drivers/scsi/aic7xxx/aic79xx_osm.c
+++ b/drivers/scsi/aic7xxx/aic79xx_osm.c
@@ -1468,6 +1468,30 @@ ahd_linux_run_command(struct ahd_softc *ahd, struct ahd_linux_device *dev,
1468 if ((tstate->auto_negotiate & mask) != 0) { 1468 if ((tstate->auto_negotiate & mask) != 0) {
1469 scb->flags |= SCB_AUTO_NEGOTIATE; 1469 scb->flags |= SCB_AUTO_NEGOTIATE;
1470 scb->hscb->control |= MK_MESSAGE; 1470 scb->hscb->control |= MK_MESSAGE;
1471 } else if (cmd->cmnd[0] == INQUIRY
1472 && (tinfo->curr.offset != 0
1473 || tinfo->curr.width != MSG_EXT_WDTR_BUS_8_BIT
1474 || tinfo->curr.ppr_options != 0)
1475 && (tinfo->curr.ppr_options & MSG_EXT_PPR_IU_REQ)==0) {
1476 /*
1477 * The SCSI spec requires inquiry
1478 * commands to complete without
1479 * reporting unit attention conditions.
1480 * Because of this, an inquiry command
1481 * that occurs just after a device is
1482 * reset will result in a data phase
1483 * with mismatched negotiated rates.
1484 * The core already forces a renegotiation
1485 * for reset events that are visible to
1486 * our controller or that we initiate,
1487 * but a third party device reset or a
1488 * hot-plug insertion can still cause this
1489 * issue. Therefore, we force a re-negotiation
1490 * for every inquiry command unless we
1491 * are async.
1492 */
1493 scb->flags |= SCB_NEGOTIATE;
1494 scb->hscb->control |= MK_MESSAGE;
1471 } 1495 }
1472 1496
1473 if ((dev->flags & (AHD_DEV_Q_TAGGED|AHD_DEV_Q_BASIC)) != 0) { 1497 if ((dev->flags & (AHD_DEV_Q_TAGGED|AHD_DEV_Q_BASIC)) != 0) {
@@ -2058,6 +2082,7 @@ ahd_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag)
2058 int paused; 2082 int paused;
2059 int wait; 2083 int wait;
2060 int disconnected; 2084 int disconnected;
2085 int found;
2061 ahd_mode_state saved_modes; 2086 ahd_mode_state saved_modes;
2062 unsigned long flags; 2087 unsigned long flags;
2063 2088
@@ -2176,7 +2201,8 @@ ahd_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag)
2176 last_phase = ahd_inb(ahd, LASTPHASE); 2201 last_phase = ahd_inb(ahd, LASTPHASE);
2177 saved_scbptr = ahd_get_scbptr(ahd); 2202 saved_scbptr = ahd_get_scbptr(ahd);
2178 active_scbptr = saved_scbptr; 2203 active_scbptr = saved_scbptr;
2179 if (disconnected && (ahd_inb(ahd, SEQ_FLAGS) & NOT_IDENTIFIED) == 0) { 2204 if (disconnected && ((last_phase != P_BUSFREE) ||
2205 (ahd_inb(ahd, SEQ_FLAGS) & NOT_IDENTIFIED) == 0)) {
2180 struct scb *bus_scb; 2206 struct scb *bus_scb;
2181 2207
2182 bus_scb = ahd_lookup_scb(ahd, active_scbptr); 2208 bus_scb = ahd_lookup_scb(ahd, active_scbptr);
@@ -2194,28 +2220,41 @@ ahd_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag)
2194 * bus or is in the disconnected state. 2220 * bus or is in the disconnected state.
2195 */ 2221 */
2196 saved_scsiid = ahd_inb(ahd, SAVED_SCSIID); 2222 saved_scsiid = ahd_inb(ahd, SAVED_SCSIID);
2197 if (last_phase != P_BUSFREE 2223 if (SCB_GET_TAG(pending_scb) == active_scbptr
2198 && (SCB_GET_TAG(pending_scb) == active_scbptr
2199 || (flag == SCB_DEVICE_RESET 2224 || (flag == SCB_DEVICE_RESET
2200 && SCSIID_TARGET(ahd, saved_scsiid) == scmd_id(cmd)))) { 2225 && SCSIID_TARGET(ahd, saved_scsiid) == scmd_id(cmd))) {
2201 2226
2202 /* 2227 /*
2203 * We're active on the bus, so assert ATN 2228 * We're active on the bus, so assert ATN
2204 * and hope that the target responds. 2229 * and hope that the target responds.
2205 */ 2230 */
2206 pending_scb = ahd_lookup_scb(ahd, active_scbptr); 2231 pending_scb = ahd_lookup_scb(ahd, active_scbptr);
2207 pending_scb->flags |= SCB_RECOVERY_SCB|flag; 2232 pending_scb->flags |= SCB_RECOVERY_SCB|SCB_DEVICE_RESET;
2208 ahd_outb(ahd, MSG_OUT, HOST_MSG); 2233 ahd_outb(ahd, MSG_OUT, HOST_MSG);
2209 ahd_outb(ahd, SCSISIGO, last_phase|ATNO); 2234 ahd_outb(ahd, SCSISIGO, last_phase|ATNO);
2210 scmd_printk(KERN_INFO, cmd, "Device is active, asserting ATN\n"); 2235 scmd_printk(KERN_INFO, cmd, "BDR message in message buffer\n");
2211 wait = TRUE; 2236 wait = TRUE;
2237 } else if (last_phase != P_BUSFREE
2238 && ahd_inb(ahd, SCSIPHASE) == 0) {
2239 /*
2240 * SCB is not identified, there
2241 * is no pending REQ, and the sequencer
2242 * has not seen a busfree. Looks like
2243 * a stuck connection waiting to
2244 * go busfree. Reset the bus.
2245 */
2246 found = ahd_reset_channel(ahd, cmd->device->channel + 'A',
2247 /*Initiate Reset*/TRUE);
2248 printf("%s: Issued Channel %c Bus Reset. "
2249 "%d SCBs aborted\n", ahd_name(ahd),
2250 cmd->device->channel + 'A', found);
2212 } else if (disconnected) { 2251 } else if (disconnected) {
2213 2252
2214 /* 2253 /*
2215 * Actually re-queue this SCB in an attempt 2254 * Actually re-queue this SCB in an attempt
2216 * to select the device before it reconnects. 2255 * to select the device before it reconnects.
2217 */ 2256 */
2218 pending_scb->flags |= SCB_RECOVERY_SCB|SCB_ABORT; 2257 pending_scb->flags |= SCB_RECOVERY_SCB|flag;
2219 ahd_set_scbptr(ahd, SCB_GET_TAG(pending_scb)); 2258 ahd_set_scbptr(ahd, SCB_GET_TAG(pending_scb));
2220 pending_scb->hscb->cdb_len = 0; 2259 pending_scb->hscb->cdb_len = 0;
2221 pending_scb->hscb->task_attribute = 0; 2260 pending_scb->hscb->task_attribute = 0;
@@ -2296,16 +2335,17 @@ done:
2296 timer.expires = jiffies + (5 * HZ); 2335 timer.expires = jiffies + (5 * HZ);
2297 timer.function = ahd_linux_sem_timeout; 2336 timer.function = ahd_linux_sem_timeout;
2298 add_timer(&timer); 2337 add_timer(&timer);
2299 printf("Recovery code sleeping\n"); 2338 printf("%s: Recovery code sleeping\n", ahd_name(ahd));
2300 down(&ahd->platform_data->eh_sem); 2339 down(&ahd->platform_data->eh_sem);
2301 printf("Recovery code awake\n"); 2340 printf("%s: Recovery code awake\n", ahd_name(ahd));
2302 ret = del_timer_sync(&timer); 2341 ret = del_timer_sync(&timer);
2303 if (ret == 0) { 2342 if (ret == 0) {
2304 printf("Timer Expired\n"); 2343 printf("%s: Timer Expired (active %d)\n",
2344 ahd_name(ahd), dev->active);
2305 retval = FAILED; 2345 retval = FAILED;
2306 } 2346 }
2307 } 2347 }
2308 ahd_unlock(ahd, &flags); 2348 ahd_unlock(ahd, &flags);
2309 return (retval); 2349 return (retval);
2310} 2350}
2311 2351
diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.h b/drivers/scsi/aic7xxx/aic79xx_osm.h
index bc44222d6cc3..cb74fccc8100 100644
--- a/drivers/scsi/aic7xxx/aic79xx_osm.h
+++ b/drivers/scsi/aic7xxx/aic79xx_osm.h
@@ -252,7 +252,7 @@ ahd_scb_timer_reset(struct scb *scb, u_int usec)
252/***************************** SMP support ************************************/ 252/***************************** SMP support ************************************/
253#include <linux/spinlock.h> 253#include <linux/spinlock.h>
254 254
255#define AIC79XX_DRIVER_VERSION "1.3.11" 255#define AIC79XX_DRIVER_VERSION "3.0"
256 256
257/*************************** Device Data Structures ***************************/ 257/*************************** Device Data Structures ***************************/
258/* 258/*
diff --git a/drivers/scsi/aic7xxx/aic79xx_pci.c b/drivers/scsi/aic7xxx/aic79xx_pci.c
index 2131db60018a..196a6344b037 100644
--- a/drivers/scsi/aic7xxx/aic79xx_pci.c
+++ b/drivers/scsi/aic7xxx/aic79xx_pci.c
@@ -38,9 +38,7 @@
38 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
39 * POSSIBILITY OF SUCH DAMAGES. 39 * POSSIBILITY OF SUCH DAMAGES.
40 * 40 *
41 * $Id: //depot/aic7xxx/aic7xxx/aic79xx_pci.c#77 $ 41 * $Id: //depot/aic7xxx/aic7xxx/aic79xx_pci.c#89 $
42 *
43 * $FreeBSD$
44 */ 42 */
45 43
46#ifdef __linux__ 44#ifdef __linux__
@@ -114,6 +112,13 @@ struct ahd_pci_identity ahd_pci_ident_table [] =
114 "Adaptec 29320ALP Ultra320 SCSI adapter", 112 "Adaptec 29320ALP Ultra320 SCSI adapter",
115 ahd_aic7901_setup 113 ahd_aic7901_setup
116 }, 114 },
115 /* aic7901A based controllers */
116 {
117 ID_AHA_29320LP,
118 ID_ALL_MASK,
119 "Adaptec 29320LP Ultra320 SCSI adapter",
120 ahd_aic7901A_setup
121 },
117 /* aic7902 based controllers */ 122 /* aic7902 based controllers */
118 { 123 {
119 ID_AHA_29320, 124 ID_AHA_29320,
@@ -128,12 +133,6 @@ struct ahd_pci_identity ahd_pci_ident_table [] =
128 ahd_aic7902_setup 133 ahd_aic7902_setup
129 }, 134 },
130 { 135 {
131 ID_AHA_29320LP,
132 ID_ALL_MASK,
133 "Adaptec 29320LP Ultra320 SCSI adapter",
134 ahd_aic7901A_setup
135 },
136 {
137 ID_AHA_39320, 136 ID_AHA_39320,
138 ID_ALL_MASK, 137 ID_ALL_MASK,
139 "Adaptec 39320 Ultra320 SCSI adapter", 138 "Adaptec 39320 Ultra320 SCSI adapter",
@@ -146,6 +145,12 @@ struct ahd_pci_identity ahd_pci_ident_table [] =
146 ahd_aic7902_setup 145 ahd_aic7902_setup
147 }, 146 },
148 { 147 {
148 ID_AHA_39320_B_DELL,
149 ID_ALL_MASK,
150 "Adaptec (Dell OEM) 39320 Ultra320 SCSI adapter",
151 ahd_aic7902_setup
152 },
153 {
149 ID_AHA_39320A, 154 ID_AHA_39320A,
150 ID_ALL_MASK, 155 ID_ALL_MASK,
151 "Adaptec 39320A Ultra320 SCSI adapter", 156 "Adaptec 39320A Ultra320 SCSI adapter",
@@ -668,6 +673,7 @@ ahd_configure_termination(struct ahd_softc *ahd, u_int adapter_control)
668 * Now set the termination based on what we found. 673 * Now set the termination based on what we found.
669 */ 674 */
670 sxfrctl1 = ahd_inb(ahd, SXFRCTL1) & ~STPWEN; 675 sxfrctl1 = ahd_inb(ahd, SXFRCTL1) & ~STPWEN;
676 ahd->flags &= ~AHD_TERM_ENB_A;
671 if ((termctl & FLX_TERMCTL_ENPRILOW) != 0) { 677 if ((termctl & FLX_TERMCTL_ENPRILOW) != 0) {
672 ahd->flags |= AHD_TERM_ENB_A; 678 ahd->flags |= AHD_TERM_ENB_A;
673 sxfrctl1 |= STPWEN; 679 sxfrctl1 |= STPWEN;
diff --git a/drivers/scsi/aic7xxx/aic79xx_pci.h b/drivers/scsi/aic7xxx/aic79xx_pci.h
index b5cfeabdfecf..da45153668c7 100644
--- a/drivers/scsi/aic7xxx/aic79xx_pci.h
+++ b/drivers/scsi/aic7xxx/aic79xx_pci.h
@@ -53,14 +53,15 @@
53#define ID_AHA_29320ALP 0x8017900500449005ull 53#define ID_AHA_29320ALP 0x8017900500449005ull
54 54
55#define ID_AIC7901A 0x801E9005FFFF9005ull 55#define ID_AIC7901A 0x801E9005FFFF9005ull
56#define ID_AHA_29320 0x8012900500429005ull
57#define ID_AHA_29320B 0x8013900500439005ull
58#define ID_AHA_29320LP 0x8014900500449005ull 56#define ID_AHA_29320LP 0x8014900500449005ull
59 57
60#define ID_AIC7902 0x801F9005FFFF9005ull 58#define ID_AIC7902 0x801F9005FFFF9005ull
61#define ID_AIC7902_B 0x801D9005FFFF9005ull 59#define ID_AIC7902_B 0x801D9005FFFF9005ull
62#define ID_AHA_39320 0x8010900500409005ull 60#define ID_AHA_39320 0x8010900500409005ull
61#define ID_AHA_29320 0x8012900500429005ull
62#define ID_AHA_29320B 0x8013900500439005ull
63#define ID_AHA_39320_B 0x8015900500409005ull 63#define ID_AHA_39320_B 0x8015900500409005ull
64#define ID_AHA_39320_B_DELL 0x8015900501681028ull
64#define ID_AHA_39320A 0x8016900500409005ull 65#define ID_AHA_39320A 0x8016900500409005ull
65#define ID_AHA_39320D 0x8011900500419005ull 66#define ID_AHA_39320D 0x8011900500419005ull
66#define ID_AHA_39320D_B 0x801C900500419005ull 67#define ID_AHA_39320D_B 0x801C900500419005ull
diff --git a/drivers/scsi/aic7xxx/aic79xx_reg.h_shipped b/drivers/scsi/aic7xxx/aic79xx_reg.h_shipped
index c01ac39090d9..8763b158856b 100644
--- a/drivers/scsi/aic7xxx/aic79xx_reg.h_shipped
+++ b/drivers/scsi/aic7xxx/aic79xx_reg.h_shipped
@@ -2,8 +2,8 @@
2 * DO NOT EDIT - This file is automatically generated 2 * DO NOT EDIT - This file is automatically generated
3 * from the following source files: 3 * from the following source files:
4 * 4 *
5 * $Id: //depot/aic7xxx/aic7xxx/aic79xx.seq#94 $ 5 * $Id: //depot/aic7xxx/aic7xxx/aic79xx.seq#119 $
6 * $Id: //depot/aic7xxx/aic7xxx/aic79xx.reg#70 $ 6 * $Id: //depot/aic7xxx/aic7xxx/aic79xx.reg#76 $
7 */ 7 */
8typedef int (ahd_reg_print_t)(u_int, u_int *, u_int); 8typedef int (ahd_reg_print_t)(u_int, u_int *, u_int);
9typedef struct ahd_reg_parse_entry { 9typedef struct ahd_reg_parse_entry {
@@ -83,17 +83,17 @@ ahd_reg_print_t ahd_hs_mailbox_print;
83#endif 83#endif
84 84
85#if AIC_DEBUG_REGISTERS 85#if AIC_DEBUG_REGISTERS
86ahd_reg_print_t ahd_clrseqintstat_print; 86ahd_reg_print_t ahd_seqintstat_print;
87#else 87#else
88#define ahd_clrseqintstat_print(regvalue, cur_col, wrap) \ 88#define ahd_seqintstat_print(regvalue, cur_col, wrap) \
89 ahd_print_register(NULL, 0, "CLRSEQINTSTAT", 0x0c, regvalue, cur_col, wrap) 89 ahd_print_register(NULL, 0, "SEQINTSTAT", 0x0c, regvalue, cur_col, wrap)
90#endif 90#endif
91 91
92#if AIC_DEBUG_REGISTERS 92#if AIC_DEBUG_REGISTERS
93ahd_reg_print_t ahd_seqintstat_print; 93ahd_reg_print_t ahd_clrseqintstat_print;
94#else 94#else
95#define ahd_seqintstat_print(regvalue, cur_col, wrap) \ 95#define ahd_clrseqintstat_print(regvalue, cur_col, wrap) \
96 ahd_print_register(NULL, 0, "SEQINTSTAT", 0x0c, regvalue, cur_col, wrap) 96 ahd_print_register(NULL, 0, "CLRSEQINTSTAT", 0x0c, regvalue, cur_col, wrap)
97#endif 97#endif
98 98
99#if AIC_DEBUG_REGISTERS 99#if AIC_DEBUG_REGISTERS
@@ -412,17 +412,17 @@ ahd_reg_print_t ahd_sxfrctl0_print;
412#endif 412#endif
413 413
414#if AIC_DEBUG_REGISTERS 414#if AIC_DEBUG_REGISTERS
415ahd_reg_print_t ahd_businitid_print; 415ahd_reg_print_t ahd_dlcount_print;
416#else 416#else
417#define ahd_businitid_print(regvalue, cur_col, wrap) \ 417#define ahd_dlcount_print(regvalue, cur_col, wrap) \
418 ahd_print_register(NULL, 0, "BUSINITID", 0x3c, regvalue, cur_col, wrap) 418 ahd_print_register(NULL, 0, "DLCOUNT", 0x3c, regvalue, cur_col, wrap)
419#endif 419#endif
420 420
421#if AIC_DEBUG_REGISTERS 421#if AIC_DEBUG_REGISTERS
422ahd_reg_print_t ahd_dlcount_print; 422ahd_reg_print_t ahd_businitid_print;
423#else 423#else
424#define ahd_dlcount_print(regvalue, cur_col, wrap) \ 424#define ahd_businitid_print(regvalue, cur_col, wrap) \
425 ahd_print_register(NULL, 0, "DLCOUNT", 0x3c, regvalue, cur_col, wrap) 425 ahd_print_register(NULL, 0, "BUSINITID", 0x3c, regvalue, cur_col, wrap)
426#endif 426#endif
427 427
428#if AIC_DEBUG_REGISTERS 428#if AIC_DEBUG_REGISTERS
@@ -517,13 +517,6 @@ ahd_reg_print_t ahd_selid_print;
517#endif 517#endif
518 518
519#if AIC_DEBUG_REGISTERS 519#if AIC_DEBUG_REGISTERS
520ahd_reg_print_t ahd_sblkctl_print;
521#else
522#define ahd_sblkctl_print(regvalue, cur_col, wrap) \
523 ahd_print_register(NULL, 0, "SBLKCTL", 0x4a, regvalue, cur_col, wrap)
524#endif
525
526#if AIC_DEBUG_REGISTERS
527ahd_reg_print_t ahd_optionmode_print; 520ahd_reg_print_t ahd_optionmode_print;
528#else 521#else
529#define ahd_optionmode_print(regvalue, cur_col, wrap) \ 522#define ahd_optionmode_print(regvalue, cur_col, wrap) \
@@ -531,10 +524,10 @@ ahd_reg_print_t ahd_optionmode_print;
531#endif 524#endif
532 525
533#if AIC_DEBUG_REGISTERS 526#if AIC_DEBUG_REGISTERS
534ahd_reg_print_t ahd_sstat0_print; 527ahd_reg_print_t ahd_sblkctl_print;
535#else 528#else
536#define ahd_sstat0_print(regvalue, cur_col, wrap) \ 529#define ahd_sblkctl_print(regvalue, cur_col, wrap) \
537 ahd_print_register(NULL, 0, "SSTAT0", 0x4b, regvalue, cur_col, wrap) 530 ahd_print_register(NULL, 0, "SBLKCTL", 0x4a, regvalue, cur_col, wrap)
538#endif 531#endif
539 532
540#if AIC_DEBUG_REGISTERS 533#if AIC_DEBUG_REGISTERS
@@ -545,6 +538,13 @@ ahd_reg_print_t ahd_clrsint0_print;
545#endif 538#endif
546 539
547#if AIC_DEBUG_REGISTERS 540#if AIC_DEBUG_REGISTERS
541ahd_reg_print_t ahd_sstat0_print;
542#else
543#define ahd_sstat0_print(regvalue, cur_col, wrap) \
544 ahd_print_register(NULL, 0, "SSTAT0", 0x4b, regvalue, cur_col, wrap)
545#endif
546
547#if AIC_DEBUG_REGISTERS
548ahd_reg_print_t ahd_simode0_print; 548ahd_reg_print_t ahd_simode0_print;
549#else 549#else
550#define ahd_simode0_print(regvalue, cur_col, wrap) \ 550#define ahd_simode0_print(regvalue, cur_col, wrap) \
@@ -573,17 +573,17 @@ ahd_reg_print_t ahd_sstat2_print;
573#endif 573#endif
574 574
575#if AIC_DEBUG_REGISTERS 575#if AIC_DEBUG_REGISTERS
576ahd_reg_print_t ahd_clrsint2_print; 576ahd_reg_print_t ahd_simode2_print;
577#else 577#else
578#define ahd_clrsint2_print(regvalue, cur_col, wrap) \ 578#define ahd_simode2_print(regvalue, cur_col, wrap) \
579 ahd_print_register(NULL, 0, "CLRSINT2", 0x4d, regvalue, cur_col, wrap) 579 ahd_print_register(NULL, 0, "SIMODE2", 0x4d, regvalue, cur_col, wrap)
580#endif 580#endif
581 581
582#if AIC_DEBUG_REGISTERS 582#if AIC_DEBUG_REGISTERS
583ahd_reg_print_t ahd_simode2_print; 583ahd_reg_print_t ahd_clrsint2_print;
584#else 584#else
585#define ahd_simode2_print(regvalue, cur_col, wrap) \ 585#define ahd_clrsint2_print(regvalue, cur_col, wrap) \
586 ahd_print_register(NULL, 0, "SIMODE2", 0x4d, regvalue, cur_col, wrap) 586 ahd_print_register(NULL, 0, "CLRSINT2", 0x4d, regvalue, cur_col, wrap)
587#endif 587#endif
588 588
589#if AIC_DEBUG_REGISTERS 589#if AIC_DEBUG_REGISTERS
@@ -685,13 +685,6 @@ ahd_reg_print_t ahd_clrsint3_print;
685#endif 685#endif
686 686
687#if AIC_DEBUG_REGISTERS 687#if AIC_DEBUG_REGISTERS
688ahd_reg_print_t ahd_lqomode0_print;
689#else
690#define ahd_lqomode0_print(regvalue, cur_col, wrap) \
691 ahd_print_register(NULL, 0, "LQOMODE0", 0x54, regvalue, cur_col, wrap)
692#endif
693
694#if AIC_DEBUG_REGISTERS
695ahd_reg_print_t ahd_lqostat0_print; 688ahd_reg_print_t ahd_lqostat0_print;
696#else 689#else
697#define ahd_lqostat0_print(regvalue, cur_col, wrap) \ 690#define ahd_lqostat0_print(regvalue, cur_col, wrap) \
@@ -706,6 +699,20 @@ ahd_reg_print_t ahd_clrlqoint0_print;
706#endif 699#endif
707 700
708#if AIC_DEBUG_REGISTERS 701#if AIC_DEBUG_REGISTERS
702ahd_reg_print_t ahd_lqomode0_print;
703#else
704#define ahd_lqomode0_print(regvalue, cur_col, wrap) \
705 ahd_print_register(NULL, 0, "LQOMODE0", 0x54, regvalue, cur_col, wrap)
706#endif
707
708#if AIC_DEBUG_REGISTERS
709ahd_reg_print_t ahd_lqomode1_print;
710#else
711#define ahd_lqomode1_print(regvalue, cur_col, wrap) \
712 ahd_print_register(NULL, 0, "LQOMODE1", 0x55, regvalue, cur_col, wrap)
713#endif
714
715#if AIC_DEBUG_REGISTERS
709ahd_reg_print_t ahd_lqostat1_print; 716ahd_reg_print_t ahd_lqostat1_print;
710#else 717#else
711#define ahd_lqostat1_print(regvalue, cur_col, wrap) \ 718#define ahd_lqostat1_print(regvalue, cur_col, wrap) \
@@ -720,13 +727,6 @@ ahd_reg_print_t ahd_clrlqoint1_print;
720#endif 727#endif
721 728
722#if AIC_DEBUG_REGISTERS 729#if AIC_DEBUG_REGISTERS
723ahd_reg_print_t ahd_lqomode1_print;
724#else
725#define ahd_lqomode1_print(regvalue, cur_col, wrap) \
726 ahd_print_register(NULL, 0, "LQOMODE1", 0x55, regvalue, cur_col, wrap)
727#endif
728
729#if AIC_DEBUG_REGISTERS
730ahd_reg_print_t ahd_lqostat2_print; 730ahd_reg_print_t ahd_lqostat2_print;
731#else 731#else
732#define ahd_lqostat2_print(regvalue, cur_col, wrap) \ 732#define ahd_lqostat2_print(regvalue, cur_col, wrap) \
@@ -909,17 +909,17 @@ ahd_reg_print_t ahd_annexcol_print;
909#endif 909#endif
910 910
911#if AIC_DEBUG_REGISTERS 911#if AIC_DEBUG_REGISTERS
912ahd_reg_print_t ahd_scschkn_print; 912ahd_reg_print_t ahd_annexdat_print;
913#else 913#else
914#define ahd_scschkn_print(regvalue, cur_col, wrap) \ 914#define ahd_annexdat_print(regvalue, cur_col, wrap) \
915 ahd_print_register(NULL, 0, "SCSCHKN", 0x66, regvalue, cur_col, wrap) 915 ahd_print_register(NULL, 0, "ANNEXDAT", 0x66, regvalue, cur_col, wrap)
916#endif 916#endif
917 917
918#if AIC_DEBUG_REGISTERS 918#if AIC_DEBUG_REGISTERS
919ahd_reg_print_t ahd_annexdat_print; 919ahd_reg_print_t ahd_scschkn_print;
920#else 920#else
921#define ahd_annexdat_print(regvalue, cur_col, wrap) \ 921#define ahd_scschkn_print(regvalue, cur_col, wrap) \
922 ahd_print_register(NULL, 0, "ANNEXDAT", 0x66, regvalue, cur_col, wrap) 922 ahd_print_register(NULL, 0, "SCSCHKN", 0x66, regvalue, cur_col, wrap)
923#endif 923#endif
924 924
925#if AIC_DEBUG_REGISTERS 925#if AIC_DEBUG_REGISTERS
@@ -1000,17 +1000,17 @@ ahd_reg_print_t ahd_pll400ctl1_print;
1000#endif 1000#endif
1001 1001
1002#if AIC_DEBUG_REGISTERS 1002#if AIC_DEBUG_REGISTERS
1003ahd_reg_print_t ahd_pll400cnt0_print; 1003ahd_reg_print_t ahd_unfairness_print;
1004#else 1004#else
1005#define ahd_pll400cnt0_print(regvalue, cur_col, wrap) \ 1005#define ahd_unfairness_print(regvalue, cur_col, wrap) \
1006 ahd_print_register(NULL, 0, "PLL400CNT0", 0x6e, regvalue, cur_col, wrap) 1006 ahd_print_register(NULL, 0, "UNFAIRNESS", 0x6e, regvalue, cur_col, wrap)
1007#endif 1007#endif
1008 1008
1009#if AIC_DEBUG_REGISTERS 1009#if AIC_DEBUG_REGISTERS
1010ahd_reg_print_t ahd_unfairness_print; 1010ahd_reg_print_t ahd_pll400cnt0_print;
1011#else 1011#else
1012#define ahd_unfairness_print(regvalue, cur_col, wrap) \ 1012#define ahd_pll400cnt0_print(regvalue, cur_col, wrap) \
1013 ahd_print_register(NULL, 0, "UNFAIRNESS", 0x6e, regvalue, cur_col, wrap) 1013 ahd_print_register(NULL, 0, "PLL400CNT0", 0x6e, regvalue, cur_col, wrap)
1014#endif 1014#endif
1015 1015
1016#if AIC_DEBUG_REGISTERS 1016#if AIC_DEBUG_REGISTERS
@@ -1056,13 +1056,6 @@ ahd_reg_print_t ahd_hodmaen_print;
1056#endif 1056#endif
1057 1057
1058#if AIC_DEBUG_REGISTERS 1058#if AIC_DEBUG_REGISTERS
1059ahd_reg_print_t ahd_sghaddr_print;
1060#else
1061#define ahd_sghaddr_print(regvalue, cur_col, wrap) \
1062 ahd_print_register(NULL, 0, "SGHADDR", 0x7c, regvalue, cur_col, wrap)
1063#endif
1064
1065#if AIC_DEBUG_REGISTERS
1066ahd_reg_print_t ahd_scbhaddr_print; 1059ahd_reg_print_t ahd_scbhaddr_print;
1067#else 1060#else
1068#define ahd_scbhaddr_print(regvalue, cur_col, wrap) \ 1061#define ahd_scbhaddr_print(regvalue, cur_col, wrap) \
@@ -1070,10 +1063,10 @@ ahd_reg_print_t ahd_scbhaddr_print;
1070#endif 1063#endif
1071 1064
1072#if AIC_DEBUG_REGISTERS 1065#if AIC_DEBUG_REGISTERS
1073ahd_reg_print_t ahd_sghcnt_print; 1066ahd_reg_print_t ahd_sghaddr_print;
1074#else 1067#else
1075#define ahd_sghcnt_print(regvalue, cur_col, wrap) \ 1068#define ahd_sghaddr_print(regvalue, cur_col, wrap) \
1076 ahd_print_register(NULL, 0, "SGHCNT", 0x84, regvalue, cur_col, wrap) 1069 ahd_print_register(NULL, 0, "SGHADDR", 0x7c, regvalue, cur_col, wrap)
1077#endif 1070#endif
1078 1071
1079#if AIC_DEBUG_REGISTERS 1072#if AIC_DEBUG_REGISTERS
@@ -1084,6 +1077,13 @@ ahd_reg_print_t ahd_scbhcnt_print;
1084#endif 1077#endif
1085 1078
1086#if AIC_DEBUG_REGISTERS 1079#if AIC_DEBUG_REGISTERS
1080ahd_reg_print_t ahd_sghcnt_print;
1081#else
1082#define ahd_sghcnt_print(regvalue, cur_col, wrap) \
1083 ahd_print_register(NULL, 0, "SGHCNT", 0x84, regvalue, cur_col, wrap)
1084#endif
1085
1086#if AIC_DEBUG_REGISTERS
1087ahd_reg_print_t ahd_dff_thrsh_print; 1087ahd_reg_print_t ahd_dff_thrsh_print;
1088#else 1088#else
1089#define ahd_dff_thrsh_print(regvalue, cur_col, wrap) \ 1089#define ahd_dff_thrsh_print(regvalue, cur_col, wrap) \
@@ -1154,13 +1154,6 @@ ahd_reg_print_t ahd_nsenable_print;
1154#endif 1154#endif
1155 1155
1156#if AIC_DEBUG_REGISTERS 1156#if AIC_DEBUG_REGISTERS
1157ahd_reg_print_t ahd_dchrxmsg1_print;
1158#else
1159#define ahd_dchrxmsg1_print(regvalue, cur_col, wrap) \
1160 ahd_print_register(NULL, 0, "DCHRXMSG1", 0x91, regvalue, cur_col, wrap)
1161#endif
1162
1163#if AIC_DEBUG_REGISTERS
1164ahd_reg_print_t ahd_cmcrxmsg1_print; 1157ahd_reg_print_t ahd_cmcrxmsg1_print;
1165#else 1158#else
1166#define ahd_cmcrxmsg1_print(regvalue, cur_col, wrap) \ 1159#define ahd_cmcrxmsg1_print(regvalue, cur_col, wrap) \
@@ -1168,17 +1161,17 @@ ahd_reg_print_t ahd_cmcrxmsg1_print;
1168#endif 1161#endif
1169 1162
1170#if AIC_DEBUG_REGISTERS 1163#if AIC_DEBUG_REGISTERS
1171ahd_reg_print_t ahd_dchrxmsg2_print; 1164ahd_reg_print_t ahd_dchrxmsg1_print;
1172#else 1165#else
1173#define ahd_dchrxmsg2_print(regvalue, cur_col, wrap) \ 1166#define ahd_dchrxmsg1_print(regvalue, cur_col, wrap) \
1174 ahd_print_register(NULL, 0, "DCHRXMSG2", 0x92, regvalue, cur_col, wrap) 1167 ahd_print_register(NULL, 0, "DCHRXMSG1", 0x91, regvalue, cur_col, wrap)
1175#endif 1168#endif
1176 1169
1177#if AIC_DEBUG_REGISTERS 1170#if AIC_DEBUG_REGISTERS
1178ahd_reg_print_t ahd_ovlyrxmsg2_print; 1171ahd_reg_print_t ahd_dchrxmsg2_print;
1179#else 1172#else
1180#define ahd_ovlyrxmsg2_print(regvalue, cur_col, wrap) \ 1173#define ahd_dchrxmsg2_print(regvalue, cur_col, wrap) \
1181 ahd_print_register(NULL, 0, "OVLYRXMSG2", 0x92, regvalue, cur_col, wrap) 1174 ahd_print_register(NULL, 0, "DCHRXMSG2", 0x92, regvalue, cur_col, wrap)
1182#endif 1175#endif
1183 1176
1184#if AIC_DEBUG_REGISTERS 1177#if AIC_DEBUG_REGISTERS
@@ -1196,6 +1189,13 @@ ahd_reg_print_t ahd_ost_print;
1196#endif 1189#endif
1197 1190
1198#if AIC_DEBUG_REGISTERS 1191#if AIC_DEBUG_REGISTERS
1192ahd_reg_print_t ahd_ovlyrxmsg2_print;
1193#else
1194#define ahd_ovlyrxmsg2_print(regvalue, cur_col, wrap) \
1195 ahd_print_register(NULL, 0, "OVLYRXMSG2", 0x92, regvalue, cur_col, wrap)
1196#endif
1197
1198#if AIC_DEBUG_REGISTERS
1199ahd_reg_print_t ahd_dchrxmsg3_print; 1199ahd_reg_print_t ahd_dchrxmsg3_print;
1200#else 1200#else
1201#define ahd_dchrxmsg3_print(regvalue, cur_col, wrap) \ 1201#define ahd_dchrxmsg3_print(regvalue, cur_col, wrap) \
@@ -1203,6 +1203,13 @@ ahd_reg_print_t ahd_dchrxmsg3_print;
1203#endif 1203#endif
1204 1204
1205#if AIC_DEBUG_REGISTERS 1205#if AIC_DEBUG_REGISTERS
1206ahd_reg_print_t ahd_ovlyrxmsg3_print;
1207#else
1208#define ahd_ovlyrxmsg3_print(regvalue, cur_col, wrap) \
1209 ahd_print_register(NULL, 0, "OVLYRXMSG3", 0x93, regvalue, cur_col, wrap)
1210#endif
1211
1212#if AIC_DEBUG_REGISTERS
1206ahd_reg_print_t ahd_cmcrxmsg3_print; 1213ahd_reg_print_t ahd_cmcrxmsg3_print;
1207#else 1214#else
1208#define ahd_cmcrxmsg3_print(regvalue, cur_col, wrap) \ 1215#define ahd_cmcrxmsg3_print(regvalue, cur_col, wrap) \
@@ -1217,13 +1224,6 @@ ahd_reg_print_t ahd_pcixctl_print;
1217#endif 1224#endif
1218 1225
1219#if AIC_DEBUG_REGISTERS 1226#if AIC_DEBUG_REGISTERS
1220ahd_reg_print_t ahd_ovlyrxmsg3_print;
1221#else
1222#define ahd_ovlyrxmsg3_print(regvalue, cur_col, wrap) \
1223 ahd_print_register(NULL, 0, "OVLYRXMSG3", 0x93, regvalue, cur_col, wrap)
1224#endif
1225
1226#if AIC_DEBUG_REGISTERS
1227ahd_reg_print_t ahd_ovlyseqbcnt_print; 1227ahd_reg_print_t ahd_ovlyseqbcnt_print;
1228#else 1228#else
1229#define ahd_ovlyseqbcnt_print(regvalue, cur_col, wrap) \ 1229#define ahd_ovlyseqbcnt_print(regvalue, cur_col, wrap) \
@@ -1231,13 +1231,6 @@ ahd_reg_print_t ahd_ovlyseqbcnt_print;
1231#endif 1231#endif
1232 1232
1233#if AIC_DEBUG_REGISTERS 1233#if AIC_DEBUG_REGISTERS
1234ahd_reg_print_t ahd_cmcseqbcnt_print;
1235#else
1236#define ahd_cmcseqbcnt_print(regvalue, cur_col, wrap) \
1237 ahd_print_register(NULL, 0, "CMCSEQBCNT", 0x94, regvalue, cur_col, wrap)
1238#endif
1239
1240#if AIC_DEBUG_REGISTERS
1241ahd_reg_print_t ahd_dchseqbcnt_print; 1234ahd_reg_print_t ahd_dchseqbcnt_print;
1242#else 1235#else
1243#define ahd_dchseqbcnt_print(regvalue, cur_col, wrap) \ 1236#define ahd_dchseqbcnt_print(regvalue, cur_col, wrap) \
@@ -1245,17 +1238,17 @@ ahd_reg_print_t ahd_dchseqbcnt_print;
1245#endif 1238#endif
1246 1239
1247#if AIC_DEBUG_REGISTERS 1240#if AIC_DEBUG_REGISTERS
1248ahd_reg_print_t ahd_cmcspltstat0_print; 1241ahd_reg_print_t ahd_cmcseqbcnt_print;
1249#else 1242#else
1250#define ahd_cmcspltstat0_print(regvalue, cur_col, wrap) \ 1243#define ahd_cmcseqbcnt_print(regvalue, cur_col, wrap) \
1251 ahd_print_register(NULL, 0, "CMCSPLTSTAT0", 0x96, regvalue, cur_col, wrap) 1244 ahd_print_register(NULL, 0, "CMCSEQBCNT", 0x94, regvalue, cur_col, wrap)
1252#endif 1245#endif
1253 1246
1254#if AIC_DEBUG_REGISTERS 1247#if AIC_DEBUG_REGISTERS
1255ahd_reg_print_t ahd_ovlyspltstat0_print; 1248ahd_reg_print_t ahd_cmcspltstat0_print;
1256#else 1249#else
1257#define ahd_ovlyspltstat0_print(regvalue, cur_col, wrap) \ 1250#define ahd_cmcspltstat0_print(regvalue, cur_col, wrap) \
1258 ahd_print_register(NULL, 0, "OVLYSPLTSTAT0", 0x96, regvalue, cur_col, wrap) 1251 ahd_print_register(NULL, 0, "CMCSPLTSTAT0", 0x96, regvalue, cur_col, wrap)
1259#endif 1252#endif
1260 1253
1261#if AIC_DEBUG_REGISTERS 1254#if AIC_DEBUG_REGISTERS
@@ -1266,10 +1259,10 @@ ahd_reg_print_t ahd_dchspltstat0_print;
1266#endif 1259#endif
1267 1260
1268#if AIC_DEBUG_REGISTERS 1261#if AIC_DEBUG_REGISTERS
1269ahd_reg_print_t ahd_dchspltstat1_print; 1262ahd_reg_print_t ahd_ovlyspltstat0_print;
1270#else 1263#else
1271#define ahd_dchspltstat1_print(regvalue, cur_col, wrap) \ 1264#define ahd_ovlyspltstat0_print(regvalue, cur_col, wrap) \
1272 ahd_print_register(NULL, 0, "DCHSPLTSTAT1", 0x97, regvalue, cur_col, wrap) 1265 ahd_print_register(NULL, 0, "OVLYSPLTSTAT0", 0x96, regvalue, cur_col, wrap)
1273#endif 1266#endif
1274 1267
1275#if AIC_DEBUG_REGISTERS 1268#if AIC_DEBUG_REGISTERS
@@ -1287,6 +1280,13 @@ ahd_reg_print_t ahd_ovlyspltstat1_print;
1287#endif 1280#endif
1288 1281
1289#if AIC_DEBUG_REGISTERS 1282#if AIC_DEBUG_REGISTERS
1283ahd_reg_print_t ahd_dchspltstat1_print;
1284#else
1285#define ahd_dchspltstat1_print(regvalue, cur_col, wrap) \
1286 ahd_print_register(NULL, 0, "DCHSPLTSTAT1", 0x97, regvalue, cur_col, wrap)
1287#endif
1288
1289#if AIC_DEBUG_REGISTERS
1290ahd_reg_print_t ahd_sgrxmsg0_print; 1290ahd_reg_print_t ahd_sgrxmsg0_print;
1291#else 1291#else
1292#define ahd_sgrxmsg0_print(regvalue, cur_col, wrap) \ 1292#define ahd_sgrxmsg0_print(regvalue, cur_col, wrap) \
@@ -1378,17 +1378,17 @@ ahd_reg_print_t ahd_sgspltstat0_print;
1378#endif 1378#endif
1379 1379
1380#if AIC_DEBUG_REGISTERS 1380#if AIC_DEBUG_REGISTERS
1381ahd_reg_print_t ahd_sfunct_print; 1381ahd_reg_print_t ahd_sgspltstat1_print;
1382#else 1382#else
1383#define ahd_sfunct_print(regvalue, cur_col, wrap) \ 1383#define ahd_sgspltstat1_print(regvalue, cur_col, wrap) \
1384 ahd_print_register(NULL, 0, "SFUNCT", 0x9f, regvalue, cur_col, wrap) 1384 ahd_print_register(NULL, 0, "SGSPLTSTAT1", 0x9f, regvalue, cur_col, wrap)
1385#endif 1385#endif
1386 1386
1387#if AIC_DEBUG_REGISTERS 1387#if AIC_DEBUG_REGISTERS
1388ahd_reg_print_t ahd_sgspltstat1_print; 1388ahd_reg_print_t ahd_sfunct_print;
1389#else 1389#else
1390#define ahd_sgspltstat1_print(regvalue, cur_col, wrap) \ 1390#define ahd_sfunct_print(regvalue, cur_col, wrap) \
1391 ahd_print_register(NULL, 0, "SGSPLTSTAT1", 0x9f, regvalue, cur_col, wrap) 1391 ahd_print_register(NULL, 0, "SFUNCT", 0x9f, regvalue, cur_col, wrap)
1392#endif 1392#endif
1393 1393
1394#if AIC_DEBUG_REGISTERS 1394#if AIC_DEBUG_REGISTERS
@@ -1504,17 +1504,17 @@ ahd_reg_print_t ahd_ccsgaddr_print;
1504#endif 1504#endif
1505 1505
1506#if AIC_DEBUG_REGISTERS 1506#if AIC_DEBUG_REGISTERS
1507ahd_reg_print_t ahd_ccscbaddr_print; 1507ahd_reg_print_t ahd_ccscbadr_bk_print;
1508#else 1508#else
1509#define ahd_ccscbaddr_print(regvalue, cur_col, wrap) \ 1509#define ahd_ccscbadr_bk_print(regvalue, cur_col, wrap) \
1510 ahd_print_register(NULL, 0, "CCSCBADDR", 0xac, regvalue, cur_col, wrap) 1510 ahd_print_register(NULL, 0, "CCSCBADR_BK", 0xac, regvalue, cur_col, wrap)
1511#endif 1511#endif
1512 1512
1513#if AIC_DEBUG_REGISTERS 1513#if AIC_DEBUG_REGISTERS
1514ahd_reg_print_t ahd_ccscbadr_bk_print; 1514ahd_reg_print_t ahd_ccscbaddr_print;
1515#else 1515#else
1516#define ahd_ccscbadr_bk_print(regvalue, cur_col, wrap) \ 1516#define ahd_ccscbaddr_print(regvalue, cur_col, wrap) \
1517 ahd_print_register(NULL, 0, "CCSCBADR_BK", 0xac, regvalue, cur_col, wrap) 1517 ahd_print_register(NULL, 0, "CCSCBADDR", 0xac, regvalue, cur_col, wrap)
1518#endif 1518#endif
1519 1519
1520#if AIC_DEBUG_REGISTERS 1520#if AIC_DEBUG_REGISTERS
@@ -1525,17 +1525,17 @@ ahd_reg_print_t ahd_cmc_rambist_print;
1525#endif 1525#endif
1526 1526
1527#if AIC_DEBUG_REGISTERS 1527#if AIC_DEBUG_REGISTERS
1528ahd_reg_print_t ahd_ccsgctl_print; 1528ahd_reg_print_t ahd_ccscbctl_print;
1529#else 1529#else
1530#define ahd_ccsgctl_print(regvalue, cur_col, wrap) \ 1530#define ahd_ccscbctl_print(regvalue, cur_col, wrap) \
1531 ahd_print_register(NULL, 0, "CCSGCTL", 0xad, regvalue, cur_col, wrap) 1531 ahd_print_register(NULL, 0, "CCSCBCTL", 0xad, regvalue, cur_col, wrap)
1532#endif 1532#endif
1533 1533
1534#if AIC_DEBUG_REGISTERS 1534#if AIC_DEBUG_REGISTERS
1535ahd_reg_print_t ahd_ccscbctl_print; 1535ahd_reg_print_t ahd_ccsgctl_print;
1536#else 1536#else
1537#define ahd_ccscbctl_print(regvalue, cur_col, wrap) \ 1537#define ahd_ccsgctl_print(regvalue, cur_col, wrap) \
1538 ahd_print_register(NULL, 0, "CCSCBCTL", 0xad, regvalue, cur_col, wrap) 1538 ahd_print_register(NULL, 0, "CCSGCTL", 0xad, regvalue, cur_col, wrap)
1539#endif 1539#endif
1540 1540
1541#if AIC_DEBUG_REGISTERS 1541#if AIC_DEBUG_REGISTERS
@@ -1707,13 +1707,6 @@ ahd_reg_print_t ahd_wrtbiascalc_print;
1707#endif 1707#endif
1708 1708
1709#if AIC_DEBUG_REGISTERS 1709#if AIC_DEBUG_REGISTERS
1710ahd_reg_print_t ahd_dfptrs_print;
1711#else
1712#define ahd_dfptrs_print(regvalue, cur_col, wrap) \
1713 ahd_print_register(NULL, 0, "DFPTRS", 0xc8, regvalue, cur_col, wrap)
1714#endif
1715
1716#if AIC_DEBUG_REGISTERS
1717ahd_reg_print_t ahd_rcvrbiascalc_print; 1710ahd_reg_print_t ahd_rcvrbiascalc_print;
1718#else 1711#else
1719#define ahd_rcvrbiascalc_print(regvalue, cur_col, wrap) \ 1712#define ahd_rcvrbiascalc_print(regvalue, cur_col, wrap) \
@@ -1721,10 +1714,10 @@ ahd_reg_print_t ahd_rcvrbiascalc_print;
1721#endif 1714#endif
1722 1715
1723#if AIC_DEBUG_REGISTERS 1716#if AIC_DEBUG_REGISTERS
1724ahd_reg_print_t ahd_dfbkptr_print; 1717ahd_reg_print_t ahd_dfptrs_print;
1725#else 1718#else
1726#define ahd_dfbkptr_print(regvalue, cur_col, wrap) \ 1719#define ahd_dfptrs_print(regvalue, cur_col, wrap) \
1727 ahd_print_register(NULL, 0, "DFBKPTR", 0xc9, regvalue, cur_col, wrap) 1720 ahd_print_register(NULL, 0, "DFPTRS", 0xc8, regvalue, cur_col, wrap)
1728#endif 1721#endif
1729 1722
1730#if AIC_DEBUG_REGISTERS 1723#if AIC_DEBUG_REGISTERS
@@ -1735,6 +1728,13 @@ ahd_reg_print_t ahd_skewcalc_print;
1735#endif 1728#endif
1736 1729
1737#if AIC_DEBUG_REGISTERS 1730#if AIC_DEBUG_REGISTERS
1731ahd_reg_print_t ahd_dfbkptr_print;
1732#else
1733#define ahd_dfbkptr_print(regvalue, cur_col, wrap) \
1734 ahd_print_register(NULL, 0, "DFBKPTR", 0xc9, regvalue, cur_col, wrap)
1735#endif
1736
1737#if AIC_DEBUG_REGISTERS
1738ahd_reg_print_t ahd_dfdbctl_print; 1738ahd_reg_print_t ahd_dfdbctl_print;
1739#else 1739#else
1740#define ahd_dfdbctl_print(regvalue, cur_col, wrap) \ 1740#define ahd_dfdbctl_print(regvalue, cur_col, wrap) \
@@ -1826,17 +1826,17 @@ ahd_reg_print_t ahd_dindex_print;
1826#endif 1826#endif
1827 1827
1828#if AIC_DEBUG_REGISTERS 1828#if AIC_DEBUG_REGISTERS
1829ahd_reg_print_t ahd_brkaddr1_print; 1829ahd_reg_print_t ahd_brkaddr0_print;
1830#else 1830#else
1831#define ahd_brkaddr1_print(regvalue, cur_col, wrap) \ 1831#define ahd_brkaddr0_print(regvalue, cur_col, wrap) \
1832 ahd_print_register(NULL, 0, "BRKADDR1", 0xe6, regvalue, cur_col, wrap) 1832 ahd_print_register(NULL, 0, "BRKADDR0", 0xe6, regvalue, cur_col, wrap)
1833#endif 1833#endif
1834 1834
1835#if AIC_DEBUG_REGISTERS 1835#if AIC_DEBUG_REGISTERS
1836ahd_reg_print_t ahd_brkaddr0_print; 1836ahd_reg_print_t ahd_brkaddr1_print;
1837#else 1837#else
1838#define ahd_brkaddr0_print(regvalue, cur_col, wrap) \ 1838#define ahd_brkaddr1_print(regvalue, cur_col, wrap) \
1839 ahd_print_register(NULL, 0, "BRKADDR0", 0xe6, regvalue, cur_col, wrap) 1839 ahd_print_register(NULL, 0, "BRKADDR1", 0xe6, regvalue, cur_col, wrap)
1840#endif 1840#endif
1841 1841
1842#if AIC_DEBUG_REGISTERS 1842#if AIC_DEBUG_REGISTERS
@@ -1889,13 +1889,6 @@ ahd_reg_print_t ahd_stack_print;
1889#endif 1889#endif
1890 1890
1891#if AIC_DEBUG_REGISTERS 1891#if AIC_DEBUG_REGISTERS
1892ahd_reg_print_t ahd_curaddr_print;
1893#else
1894#define ahd_curaddr_print(regvalue, cur_col, wrap) \
1895 ahd_print_register(NULL, 0, "CURADDR", 0xf4, regvalue, cur_col, wrap)
1896#endif
1897
1898#if AIC_DEBUG_REGISTERS
1899ahd_reg_print_t ahd_intvec1_addr_print; 1892ahd_reg_print_t ahd_intvec1_addr_print;
1900#else 1893#else
1901#define ahd_intvec1_addr_print(regvalue, cur_col, wrap) \ 1894#define ahd_intvec1_addr_print(regvalue, cur_col, wrap) \
@@ -1903,10 +1896,10 @@ ahd_reg_print_t ahd_intvec1_addr_print;
1903#endif 1896#endif
1904 1897
1905#if AIC_DEBUG_REGISTERS 1898#if AIC_DEBUG_REGISTERS
1906ahd_reg_print_t ahd_intvec2_addr_print; 1899ahd_reg_print_t ahd_curaddr_print;
1907#else 1900#else
1908#define ahd_intvec2_addr_print(regvalue, cur_col, wrap) \ 1901#define ahd_curaddr_print(regvalue, cur_col, wrap) \
1909 ahd_print_register(NULL, 0, "INTVEC2_ADDR", 0xf6, regvalue, cur_col, wrap) 1902 ahd_print_register(NULL, 0, "CURADDR", 0xf4, regvalue, cur_col, wrap)
1910#endif 1903#endif
1911 1904
1912#if AIC_DEBUG_REGISTERS 1905#if AIC_DEBUG_REGISTERS
@@ -1917,6 +1910,13 @@ ahd_reg_print_t ahd_lastaddr_print;
1917#endif 1910#endif
1918 1911
1919#if AIC_DEBUG_REGISTERS 1912#if AIC_DEBUG_REGISTERS
1913ahd_reg_print_t ahd_intvec2_addr_print;
1914#else
1915#define ahd_intvec2_addr_print(regvalue, cur_col, wrap) \
1916 ahd_print_register(NULL, 0, "INTVEC2_ADDR", 0xf6, regvalue, cur_col, wrap)
1917#endif
1918
1919#if AIC_DEBUG_REGISTERS
1920ahd_reg_print_t ahd_longjmp_addr_print; 1920ahd_reg_print_t ahd_longjmp_addr_print;
1921#else 1921#else
1922#define ahd_longjmp_addr_print(regvalue, cur_col, wrap) \ 1922#define ahd_longjmp_addr_print(regvalue, cur_col, wrap) \
@@ -1994,192 +1994,213 @@ ahd_reg_print_t ahd_complete_dma_scb_head_print;
1994#endif 1994#endif
1995 1995
1996#if AIC_DEBUG_REGISTERS 1996#if AIC_DEBUG_REGISTERS
1997ahd_reg_print_t ahd_complete_dma_scb_tail_print;
1998#else
1999#define ahd_complete_dma_scb_tail_print(regvalue, cur_col, wrap) \
2000 ahd_print_register(NULL, 0, "COMPLETE_DMA_SCB_TAIL", 0x12e, regvalue, cur_col, wrap)
2001#endif
2002
2003#if AIC_DEBUG_REGISTERS
2004ahd_reg_print_t ahd_complete_on_qfreeze_head_print;
2005#else
2006#define ahd_complete_on_qfreeze_head_print(regvalue, cur_col, wrap) \
2007 ahd_print_register(NULL, 0, "COMPLETE_ON_QFREEZE_HEAD", 0x130, regvalue, cur_col, wrap)
2008#endif
2009
2010#if AIC_DEBUG_REGISTERS
1997ahd_reg_print_t ahd_qfreeze_count_print; 2011ahd_reg_print_t ahd_qfreeze_count_print;
1998#else 2012#else
1999#define ahd_qfreeze_count_print(regvalue, cur_col, wrap) \ 2013#define ahd_qfreeze_count_print(regvalue, cur_col, wrap) \
2000 ahd_print_register(NULL, 0, "QFREEZE_COUNT", 0x12e, regvalue, cur_col, wrap) 2014 ahd_print_register(NULL, 0, "QFREEZE_COUNT", 0x132, regvalue, cur_col, wrap)
2015#endif
2016
2017#if AIC_DEBUG_REGISTERS
2018ahd_reg_print_t ahd_kernel_qfreeze_count_print;
2019#else
2020#define ahd_kernel_qfreeze_count_print(regvalue, cur_col, wrap) \
2021 ahd_print_register(NULL, 0, "KERNEL_QFREEZE_COUNT", 0x134, regvalue, cur_col, wrap)
2001#endif 2022#endif
2002 2023
2003#if AIC_DEBUG_REGISTERS 2024#if AIC_DEBUG_REGISTERS
2004ahd_reg_print_t ahd_saved_mode_print; 2025ahd_reg_print_t ahd_saved_mode_print;
2005#else 2026#else
2006#define ahd_saved_mode_print(regvalue, cur_col, wrap) \ 2027#define ahd_saved_mode_print(regvalue, cur_col, wrap) \
2007 ahd_print_register(NULL, 0, "SAVED_MODE", 0x130, regvalue, cur_col, wrap) 2028 ahd_print_register(NULL, 0, "SAVED_MODE", 0x136, regvalue, cur_col, wrap)
2008#endif 2029#endif
2009 2030
2010#if AIC_DEBUG_REGISTERS 2031#if AIC_DEBUG_REGISTERS
2011ahd_reg_print_t ahd_msg_out_print; 2032ahd_reg_print_t ahd_msg_out_print;
2012#else 2033#else
2013#define ahd_msg_out_print(regvalue, cur_col, wrap) \ 2034#define ahd_msg_out_print(regvalue, cur_col, wrap) \
2014 ahd_print_register(NULL, 0, "MSG_OUT", 0x131, regvalue, cur_col, wrap) 2035 ahd_print_register(NULL, 0, "MSG_OUT", 0x137, regvalue, cur_col, wrap)
2015#endif 2036#endif
2016 2037
2017#if AIC_DEBUG_REGISTERS 2038#if AIC_DEBUG_REGISTERS
2018ahd_reg_print_t ahd_dmaparams_print; 2039ahd_reg_print_t ahd_dmaparams_print;
2019#else 2040#else
2020#define ahd_dmaparams_print(regvalue, cur_col, wrap) \ 2041#define ahd_dmaparams_print(regvalue, cur_col, wrap) \
2021 ahd_print_register(NULL, 0, "DMAPARAMS", 0x132, regvalue, cur_col, wrap) 2042 ahd_print_register(NULL, 0, "DMAPARAMS", 0x138, regvalue, cur_col, wrap)
2022#endif 2043#endif
2023 2044
2024#if AIC_DEBUG_REGISTERS 2045#if AIC_DEBUG_REGISTERS
2025ahd_reg_print_t ahd_seq_flags_print; 2046ahd_reg_print_t ahd_seq_flags_print;
2026#else 2047#else
2027#define ahd_seq_flags_print(regvalue, cur_col, wrap) \ 2048#define ahd_seq_flags_print(regvalue, cur_col, wrap) \
2028 ahd_print_register(NULL, 0, "SEQ_FLAGS", 0x133, regvalue, cur_col, wrap) 2049 ahd_print_register(NULL, 0, "SEQ_FLAGS", 0x139, regvalue, cur_col, wrap)
2029#endif 2050#endif
2030 2051
2031#if AIC_DEBUG_REGISTERS 2052#if AIC_DEBUG_REGISTERS
2032ahd_reg_print_t ahd_saved_scsiid_print; 2053ahd_reg_print_t ahd_saved_scsiid_print;
2033#else 2054#else
2034#define ahd_saved_scsiid_print(regvalue, cur_col, wrap) \ 2055#define ahd_saved_scsiid_print(regvalue, cur_col, wrap) \
2035 ahd_print_register(NULL, 0, "SAVED_SCSIID", 0x134, regvalue, cur_col, wrap) 2056 ahd_print_register(NULL, 0, "SAVED_SCSIID", 0x13a, regvalue, cur_col, wrap)
2036#endif 2057#endif
2037 2058
2038#if AIC_DEBUG_REGISTERS 2059#if AIC_DEBUG_REGISTERS
2039ahd_reg_print_t ahd_saved_lun_print; 2060ahd_reg_print_t ahd_saved_lun_print;
2040#else 2061#else
2041#define ahd_saved_lun_print(regvalue, cur_col, wrap) \ 2062#define ahd_saved_lun_print(regvalue, cur_col, wrap) \
2042 ahd_print_register(NULL, 0, "SAVED_LUN", 0x135, regvalue, cur_col, wrap) 2063 ahd_print_register(NULL, 0, "SAVED_LUN", 0x13b, regvalue, cur_col, wrap)
2043#endif 2064#endif
2044 2065
2045#if AIC_DEBUG_REGISTERS 2066#if AIC_DEBUG_REGISTERS
2046ahd_reg_print_t ahd_lastphase_print; 2067ahd_reg_print_t ahd_lastphase_print;
2047#else 2068#else
2048#define ahd_lastphase_print(regvalue, cur_col, wrap) \ 2069#define ahd_lastphase_print(regvalue, cur_col, wrap) \
2049 ahd_print_register(NULL, 0, "LASTPHASE", 0x136, regvalue, cur_col, wrap) 2070 ahd_print_register(NULL, 0, "LASTPHASE", 0x13c, regvalue, cur_col, wrap)
2050#endif 2071#endif
2051 2072
2052#if AIC_DEBUG_REGISTERS 2073#if AIC_DEBUG_REGISTERS
2053ahd_reg_print_t ahd_qoutfifo_entry_valid_tag_print; 2074ahd_reg_print_t ahd_qoutfifo_entry_valid_tag_print;
2054#else 2075#else
2055#define ahd_qoutfifo_entry_valid_tag_print(regvalue, cur_col, wrap) \ 2076#define ahd_qoutfifo_entry_valid_tag_print(regvalue, cur_col, wrap) \
2056 ahd_print_register(NULL, 0, "QOUTFIFO_ENTRY_VALID_TAG", 0x137, regvalue, cur_col, wrap) 2077 ahd_print_register(NULL, 0, "QOUTFIFO_ENTRY_VALID_TAG", 0x13d, regvalue, cur_col, wrap)
2057#endif 2078#endif
2058 2079
2059#if AIC_DEBUG_REGISTERS 2080#if AIC_DEBUG_REGISTERS
2060ahd_reg_print_t ahd_shared_data_addr_print; 2081ahd_reg_print_t ahd_kernel_tqinpos_print;
2061#else 2082#else
2062#define ahd_shared_data_addr_print(regvalue, cur_col, wrap) \ 2083#define ahd_kernel_tqinpos_print(regvalue, cur_col, wrap) \
2063 ahd_print_register(NULL, 0, "SHARED_DATA_ADDR", 0x138, regvalue, cur_col, wrap) 2084 ahd_print_register(NULL, 0, "KERNEL_TQINPOS", 0x13e, regvalue, cur_col, wrap)
2064#endif 2085#endif
2065 2086
2066#if AIC_DEBUG_REGISTERS 2087#if AIC_DEBUG_REGISTERS
2067ahd_reg_print_t ahd_qoutfifo_next_addr_print; 2088ahd_reg_print_t ahd_tqinpos_print;
2068#else 2089#else
2069#define ahd_qoutfifo_next_addr_print(regvalue, cur_col, wrap) \ 2090#define ahd_tqinpos_print(regvalue, cur_col, wrap) \
2070 ahd_print_register(NULL, 0, "QOUTFIFO_NEXT_ADDR", 0x13c, regvalue, cur_col, wrap) 2091 ahd_print_register(NULL, 0, "TQINPOS", 0x13f, regvalue, cur_col, wrap)
2071#endif 2092#endif
2072 2093
2073#if AIC_DEBUG_REGISTERS 2094#if AIC_DEBUG_REGISTERS
2074ahd_reg_print_t ahd_kernel_tqinpos_print; 2095ahd_reg_print_t ahd_shared_data_addr_print;
2075#else 2096#else
2076#define ahd_kernel_tqinpos_print(regvalue, cur_col, wrap) \ 2097#define ahd_shared_data_addr_print(regvalue, cur_col, wrap) \
2077 ahd_print_register(NULL, 0, "KERNEL_TQINPOS", 0x140, regvalue, cur_col, wrap) 2098 ahd_print_register(NULL, 0, "SHARED_DATA_ADDR", 0x140, regvalue, cur_col, wrap)
2078#endif 2099#endif
2079 2100
2080#if AIC_DEBUG_REGISTERS 2101#if AIC_DEBUG_REGISTERS
2081ahd_reg_print_t ahd_tqinpos_print; 2102ahd_reg_print_t ahd_qoutfifo_next_addr_print;
2082#else 2103#else
2083#define ahd_tqinpos_print(regvalue, cur_col, wrap) \ 2104#define ahd_qoutfifo_next_addr_print(regvalue, cur_col, wrap) \
2084 ahd_print_register(NULL, 0, "TQINPOS", 0x141, regvalue, cur_col, wrap) 2105 ahd_print_register(NULL, 0, "QOUTFIFO_NEXT_ADDR", 0x144, regvalue, cur_col, wrap)
2085#endif 2106#endif
2086 2107
2087#if AIC_DEBUG_REGISTERS 2108#if AIC_DEBUG_REGISTERS
2088ahd_reg_print_t ahd_arg_1_print; 2109ahd_reg_print_t ahd_arg_1_print;
2089#else 2110#else
2090#define ahd_arg_1_print(regvalue, cur_col, wrap) \ 2111#define ahd_arg_1_print(regvalue, cur_col, wrap) \
2091 ahd_print_register(NULL, 0, "ARG_1", 0x142, regvalue, cur_col, wrap) 2112 ahd_print_register(NULL, 0, "ARG_1", 0x148, regvalue, cur_col, wrap)
2092#endif 2113#endif
2093 2114
2094#if AIC_DEBUG_REGISTERS 2115#if AIC_DEBUG_REGISTERS
2095ahd_reg_print_t ahd_arg_2_print; 2116ahd_reg_print_t ahd_arg_2_print;
2096#else 2117#else
2097#define ahd_arg_2_print(regvalue, cur_col, wrap) \ 2118#define ahd_arg_2_print(regvalue, cur_col, wrap) \
2098 ahd_print_register(NULL, 0, "ARG_2", 0x143, regvalue, cur_col, wrap) 2119 ahd_print_register(NULL, 0, "ARG_2", 0x149, regvalue, cur_col, wrap)
2099#endif 2120#endif
2100 2121
2101#if AIC_DEBUG_REGISTERS 2122#if AIC_DEBUG_REGISTERS
2102ahd_reg_print_t ahd_last_msg_print; 2123ahd_reg_print_t ahd_last_msg_print;
2103#else 2124#else
2104#define ahd_last_msg_print(regvalue, cur_col, wrap) \ 2125#define ahd_last_msg_print(regvalue, cur_col, wrap) \
2105 ahd_print_register(NULL, 0, "LAST_MSG", 0x144, regvalue, cur_col, wrap) 2126 ahd_print_register(NULL, 0, "LAST_MSG", 0x14a, regvalue, cur_col, wrap)
2106#endif 2127#endif
2107 2128
2108#if AIC_DEBUG_REGISTERS 2129#if AIC_DEBUG_REGISTERS
2109ahd_reg_print_t ahd_scsiseq_template_print; 2130ahd_reg_print_t ahd_scsiseq_template_print;
2110#else 2131#else
2111#define ahd_scsiseq_template_print(regvalue, cur_col, wrap) \ 2132#define ahd_scsiseq_template_print(regvalue, cur_col, wrap) \
2112 ahd_print_register(NULL, 0, "SCSISEQ_TEMPLATE", 0x145, regvalue, cur_col, wrap) 2133 ahd_print_register(NULL, 0, "SCSISEQ_TEMPLATE", 0x14b, regvalue, cur_col, wrap)
2113#endif 2134#endif
2114 2135
2115#if AIC_DEBUG_REGISTERS 2136#if AIC_DEBUG_REGISTERS
2116ahd_reg_print_t ahd_initiator_tag_print; 2137ahd_reg_print_t ahd_initiator_tag_print;
2117#else 2138#else
2118#define ahd_initiator_tag_print(regvalue, cur_col, wrap) \ 2139#define ahd_initiator_tag_print(regvalue, cur_col, wrap) \
2119 ahd_print_register(NULL, 0, "INITIATOR_TAG", 0x146, regvalue, cur_col, wrap) 2140 ahd_print_register(NULL, 0, "INITIATOR_TAG", 0x14c, regvalue, cur_col, wrap)
2120#endif 2141#endif
2121 2142
2122#if AIC_DEBUG_REGISTERS 2143#if AIC_DEBUG_REGISTERS
2123ahd_reg_print_t ahd_seq_flags2_print; 2144ahd_reg_print_t ahd_seq_flags2_print;
2124#else 2145#else
2125#define ahd_seq_flags2_print(regvalue, cur_col, wrap) \ 2146#define ahd_seq_flags2_print(regvalue, cur_col, wrap) \
2126 ahd_print_register(NULL, 0, "SEQ_FLAGS2", 0x147, regvalue, cur_col, wrap) 2147 ahd_print_register(NULL, 0, "SEQ_FLAGS2", 0x14d, regvalue, cur_col, wrap)
2127#endif 2148#endif
2128 2149
2129#if AIC_DEBUG_REGISTERS 2150#if AIC_DEBUG_REGISTERS
2130ahd_reg_print_t ahd_allocfifo_scbptr_print; 2151ahd_reg_print_t ahd_allocfifo_scbptr_print;
2131#else 2152#else
2132#define ahd_allocfifo_scbptr_print(regvalue, cur_col, wrap) \ 2153#define ahd_allocfifo_scbptr_print(regvalue, cur_col, wrap) \
2133 ahd_print_register(NULL, 0, "ALLOCFIFO_SCBPTR", 0x148, regvalue, cur_col, wrap) 2154 ahd_print_register(NULL, 0, "ALLOCFIFO_SCBPTR", 0x14e, regvalue, cur_col, wrap)
2134#endif 2155#endif
2135 2156
2136#if AIC_DEBUG_REGISTERS 2157#if AIC_DEBUG_REGISTERS
2137ahd_reg_print_t ahd_int_coalescing_timer_print; 2158ahd_reg_print_t ahd_int_coalescing_timer_print;
2138#else 2159#else
2139#define ahd_int_coalescing_timer_print(regvalue, cur_col, wrap) \ 2160#define ahd_int_coalescing_timer_print(regvalue, cur_col, wrap) \
2140 ahd_print_register(NULL, 0, "INT_COALESCING_TIMER", 0x14a, regvalue, cur_col, wrap) 2161 ahd_print_register(NULL, 0, "INT_COALESCING_TIMER", 0x150, regvalue, cur_col, wrap)
2141#endif 2162#endif
2142 2163
2143#if AIC_DEBUG_REGISTERS 2164#if AIC_DEBUG_REGISTERS
2144ahd_reg_print_t ahd_int_coalescing_maxcmds_print; 2165ahd_reg_print_t ahd_int_coalescing_maxcmds_print;
2145#else 2166#else
2146#define ahd_int_coalescing_maxcmds_print(regvalue, cur_col, wrap) \ 2167#define ahd_int_coalescing_maxcmds_print(regvalue, cur_col, wrap) \
2147 ahd_print_register(NULL, 0, "INT_COALESCING_MAXCMDS", 0x14c, regvalue, cur_col, wrap) 2168 ahd_print_register(NULL, 0, "INT_COALESCING_MAXCMDS", 0x152, regvalue, cur_col, wrap)
2148#endif 2169#endif
2149 2170
2150#if AIC_DEBUG_REGISTERS 2171#if AIC_DEBUG_REGISTERS
2151ahd_reg_print_t ahd_int_coalescing_mincmds_print; 2172ahd_reg_print_t ahd_int_coalescing_mincmds_print;
2152#else 2173#else
2153#define ahd_int_coalescing_mincmds_print(regvalue, cur_col, wrap) \ 2174#define ahd_int_coalescing_mincmds_print(regvalue, cur_col, wrap) \
2154 ahd_print_register(NULL, 0, "INT_COALESCING_MINCMDS", 0x14d, regvalue, cur_col, wrap) 2175 ahd_print_register(NULL, 0, "INT_COALESCING_MINCMDS", 0x153, regvalue, cur_col, wrap)
2155#endif 2176#endif
2156 2177
2157#if AIC_DEBUG_REGISTERS 2178#if AIC_DEBUG_REGISTERS
2158ahd_reg_print_t ahd_cmds_pending_print; 2179ahd_reg_print_t ahd_cmds_pending_print;
2159#else 2180#else
2160#define ahd_cmds_pending_print(regvalue, cur_col, wrap) \ 2181#define ahd_cmds_pending_print(regvalue, cur_col, wrap) \
2161 ahd_print_register(NULL, 0, "CMDS_PENDING", 0x14e, regvalue, cur_col, wrap) 2182 ahd_print_register(NULL, 0, "CMDS_PENDING", 0x154, regvalue, cur_col, wrap)
2162#endif 2183#endif
2163 2184
2164#if AIC_DEBUG_REGISTERS 2185#if AIC_DEBUG_REGISTERS
2165ahd_reg_print_t ahd_int_coalescing_cmdcount_print; 2186ahd_reg_print_t ahd_int_coalescing_cmdcount_print;
2166#else 2187#else
2167#define ahd_int_coalescing_cmdcount_print(regvalue, cur_col, wrap) \ 2188#define ahd_int_coalescing_cmdcount_print(regvalue, cur_col, wrap) \
2168 ahd_print_register(NULL, 0, "INT_COALESCING_CMDCOUNT", 0x150, regvalue, cur_col, wrap) 2189 ahd_print_register(NULL, 0, "INT_COALESCING_CMDCOUNT", 0x156, regvalue, cur_col, wrap)
2169#endif 2190#endif
2170 2191
2171#if AIC_DEBUG_REGISTERS 2192#if AIC_DEBUG_REGISTERS
2172ahd_reg_print_t ahd_local_hs_mailbox_print; 2193ahd_reg_print_t ahd_local_hs_mailbox_print;
2173#else 2194#else
2174#define ahd_local_hs_mailbox_print(regvalue, cur_col, wrap) \ 2195#define ahd_local_hs_mailbox_print(regvalue, cur_col, wrap) \
2175 ahd_print_register(NULL, 0, "LOCAL_HS_MAILBOX", 0x151, regvalue, cur_col, wrap) 2196 ahd_print_register(NULL, 0, "LOCAL_HS_MAILBOX", 0x157, regvalue, cur_col, wrap)
2176#endif 2197#endif
2177 2198
2178#if AIC_DEBUG_REGISTERS 2199#if AIC_DEBUG_REGISTERS
2179ahd_reg_print_t ahd_cmdsize_table_print; 2200ahd_reg_print_t ahd_cmdsize_table_print;
2180#else 2201#else
2181#define ahd_cmdsize_table_print(regvalue, cur_col, wrap) \ 2202#define ahd_cmdsize_table_print(regvalue, cur_col, wrap) \
2182 ahd_print_register(NULL, 0, "CMDSIZE_TABLE", 0x152, regvalue, cur_col, wrap) 2203 ahd_print_register(NULL, 0, "CMDSIZE_TABLE", 0x158, regvalue, cur_col, wrap)
2183#endif 2204#endif
2184 2205
2185#if AIC_DEBUG_REGISTERS 2206#if AIC_DEBUG_REGISTERS
@@ -2434,13 +2455,6 @@ ahd_reg_print_t ahd_scb_disconnected_lists_print;
2434#define HOST_TQINPOS 0x80 2455#define HOST_TQINPOS 0x80
2435#define ENINT_COALESCE 0x40 2456#define ENINT_COALESCE 0x40
2436 2457
2437#define CLRSEQINTSTAT 0x0c
2438#define CLRSEQ_SWTMRTO 0x10
2439#define CLRSEQ_SEQINT 0x08
2440#define CLRSEQ_SCSIINT 0x04
2441#define CLRSEQ_PCIINT 0x02
2442#define CLRSEQ_SPLTINT 0x01
2443
2444#define SEQINTSTAT 0x0c 2458#define SEQINTSTAT 0x0c
2445#define SEQ_SWTMRTO 0x10 2459#define SEQ_SWTMRTO 0x10
2446#define SEQ_SEQINT 0x08 2460#define SEQ_SEQINT 0x08
@@ -2448,6 +2462,13 @@ ahd_reg_print_t ahd_scb_disconnected_lists_print;
2448#define SEQ_PCIINT 0x02 2462#define SEQ_PCIINT 0x02
2449#define SEQ_SPLTINT 0x01 2463#define SEQ_SPLTINT 0x01
2450 2464
2465#define CLRSEQINTSTAT 0x0c
2466#define CLRSEQ_SWTMRTO 0x10
2467#define CLRSEQ_SEQINT 0x08
2468#define CLRSEQ_SCSIINT 0x04
2469#define CLRSEQ_PCIINT 0x02
2470#define CLRSEQ_SPLTINT 0x01
2471
2451#define SWTIMER 0x0e 2472#define SWTIMER 0x0e
2452 2473
2453#define SNSCB_QOFF 0x10 2474#define SNSCB_QOFF 0x10
@@ -2623,10 +2644,10 @@ ahd_reg_print_t ahd_scb_disconnected_lists_print;
2623#define BIOSCANCELEN 0x10 2644#define BIOSCANCELEN 0x10
2624#define SPIOEN 0x08 2645#define SPIOEN 0x08
2625 2646
2626#define BUSINITID 0x3c
2627
2628#define DLCOUNT 0x3c 2647#define DLCOUNT 0x3c
2629 2648
2649#define BUSINITID 0x3c
2650
2630#define SXFRCTL1 0x3d 2651#define SXFRCTL1 0x3d
2631#define BITBUCKET 0x80 2652#define BITBUCKET 0x80
2632#define ENSACHK 0x40 2653#define ENSACHK 0x40
@@ -2693,13 +2714,6 @@ ahd_reg_print_t ahd_scb_disconnected_lists_print;
2693#define SELID_MASK 0xf0 2714#define SELID_MASK 0xf0
2694#define ONEBIT 0x08 2715#define ONEBIT 0x08
2695 2716
2696#define SBLKCTL 0x4a
2697#define DIAGLEDEN 0x80
2698#define DIAGLEDON 0x40
2699#define ENAB40 0x08
2700#define ENAB20 0x04
2701#define SELWIDE 0x02
2702
2703#define OPTIONMODE 0x4a 2717#define OPTIONMODE 0x4a
2704#define OPTIONMODE_DEFAULTS 0x02 2718#define OPTIONMODE_DEFAULTS 0x02
2705#define BIOSCANCTL 0x80 2719#define BIOSCANCTL 0x80
@@ -2709,15 +2723,12 @@ ahd_reg_print_t ahd_scb_disconnected_lists_print;
2709#define ENDGFORMCHK 0x04 2723#define ENDGFORMCHK 0x04
2710#define AUTO_MSGOUT_DE 0x02 2724#define AUTO_MSGOUT_DE 0x02
2711 2725
2712#define SSTAT0 0x4b 2726#define SBLKCTL 0x4a
2713#define TARGET 0x80 2727#define DIAGLEDEN 0x80
2714#define SELDO 0x40 2728#define DIAGLEDON 0x40
2715#define SELDI 0x20 2729#define ENAB40 0x08
2716#define SELINGO 0x10 2730#define ENAB20 0x04
2717#define IOERR 0x08 2731#define SELWIDE 0x02
2718#define OVERRUN 0x04
2719#define SPIORDY 0x02
2720#define ARBDO 0x01
2721 2732
2722#define CLRSINT0 0x4b 2733#define CLRSINT0 0x4b
2723#define CLRSELDO 0x40 2734#define CLRSELDO 0x40
@@ -2728,6 +2739,16 @@ ahd_reg_print_t ahd_scb_disconnected_lists_print;
2728#define CLRSPIORDY 0x02 2739#define CLRSPIORDY 0x02
2729#define CLRARBDO 0x01 2740#define CLRARBDO 0x01
2730 2741
2742#define SSTAT0 0x4b
2743#define TARGET 0x80
2744#define SELDO 0x40
2745#define SELDI 0x20
2746#define SELINGO 0x10
2747#define IOERR 0x08
2748#define OVERRUN 0x04
2749#define SPIORDY 0x02
2750#define ARBDO 0x01
2751
2731#define SIMODE0 0x4b 2752#define SIMODE0 0x4b
2732#define ENSELDO 0x40 2753#define ENSELDO 0x40
2733#define ENSELDI 0x20 2754#define ENSELDI 0x20
@@ -2768,17 +2789,17 @@ ahd_reg_print_t ahd_scb_disconnected_lists_print;
2768#define BUSFREE_DFF0 0x80 2789#define BUSFREE_DFF0 0x80
2769#define BUSFREE_LQO 0x40 2790#define BUSFREE_LQO 0x40
2770 2791
2792#define SIMODE2 0x4d
2793#define ENWIDE_RES 0x04
2794#define ENSDONE 0x02
2795#define ENDMADONE 0x01
2796
2771#define CLRSINT2 0x4d 2797#define CLRSINT2 0x4d
2772#define CLRNONPACKREQ 0x20 2798#define CLRNONPACKREQ 0x20
2773#define CLRWIDE_RES 0x04 2799#define CLRWIDE_RES 0x04
2774#define CLRSDONE 0x02 2800#define CLRSDONE 0x02
2775#define CLRDMADONE 0x01 2801#define CLRDMADONE 0x01
2776 2802
2777#define SIMODE2 0x4d
2778#define ENWIDE_RES 0x04
2779#define ENSDONE 0x02
2780#define ENDMADONE 0x01
2781
2782#define PERRDIAG 0x4e 2803#define PERRDIAG 0x4e
2783#define HIZERO 0x80 2804#define HIZERO 0x80
2784#define HIPERR 0x40 2805#define HIPERR 0x40
@@ -2871,13 +2892,6 @@ ahd_reg_print_t ahd_scb_disconnected_lists_print;
2871#define CLRNTRAMPERR 0x02 2892#define CLRNTRAMPERR 0x02
2872#define CLROSRAMPERR 0x01 2893#define CLROSRAMPERR 0x01
2873 2894
2874#define LQOMODE0 0x54
2875#define ENLQOTARGSCBPERR 0x10
2876#define ENLQOSTOPT2 0x08
2877#define ENLQOATNLQ 0x04
2878#define ENLQOATNPKT 0x02
2879#define ENLQOTCRC 0x01
2880
2881#define LQOSTAT0 0x54 2895#define LQOSTAT0 0x54
2882#define LQOTARGSCBPERR 0x10 2896#define LQOTARGSCBPERR 0x10
2883#define LQOSTOPT2 0x08 2897#define LQOSTOPT2 0x08
@@ -2892,6 +2906,20 @@ ahd_reg_print_t ahd_scb_disconnected_lists_print;
2892#define CLRLQOATNPKT 0x02 2906#define CLRLQOATNPKT 0x02
2893#define CLRLQOTCRC 0x01 2907#define CLRLQOTCRC 0x01
2894 2908
2909#define LQOMODE0 0x54
2910#define ENLQOTARGSCBPERR 0x10
2911#define ENLQOSTOPT2 0x08
2912#define ENLQOATNLQ 0x04
2913#define ENLQOATNPKT 0x02
2914#define ENLQOTCRC 0x01
2915
2916#define LQOMODE1 0x55
2917#define ENLQOINITSCBPERR 0x10
2918#define ENLQOSTOPI2 0x08
2919#define ENLQOBADQAS 0x04
2920#define ENLQOBUSFREE 0x02
2921#define ENLQOPHACHGINPKT 0x01
2922
2895#define LQOSTAT1 0x55 2923#define LQOSTAT1 0x55
2896#define LQOINITSCBPERR 0x10 2924#define LQOINITSCBPERR 0x10
2897#define LQOSTOPI2 0x08 2925#define LQOSTOPI2 0x08
@@ -2906,13 +2934,6 @@ ahd_reg_print_t ahd_scb_disconnected_lists_print;
2906#define CLRLQOBUSFREE 0x02 2934#define CLRLQOBUSFREE 0x02
2907#define CLRLQOPHACHGINPKT 0x01 2935#define CLRLQOPHACHGINPKT 0x01
2908 2936
2909#define LQOMODE1 0x55
2910#define ENLQOINITSCBPERR 0x10
2911#define ENLQOSTOPI2 0x08
2912#define ENLQOBADQAS 0x04
2913#define ENLQOBUSFREE 0x02
2914#define ENLQOPHACHGINPKT 0x01
2915
2916#define LQOSTAT2 0x56 2937#define LQOSTAT2 0x56
2917#define LQOPKT 0xe0 2938#define LQOPKT 0xe0
2918#define LQOWAITFIFO 0x10 2939#define LQOWAITFIFO 0x10
@@ -3028,6 +3049,8 @@ ahd_reg_print_t ahd_scb_disconnected_lists_print;
3028 3049
3029#define ANNEXCOL 0x65 3050#define ANNEXCOL 0x65
3030 3051
3052#define ANNEXDAT 0x66
3053
3031#define SCSCHKN 0x66 3054#define SCSCHKN 0x66
3032#define STSELSKIDDIS 0x40 3055#define STSELSKIDDIS 0x40
3033#define CURRFIFODEF 0x20 3056#define CURRFIFODEF 0x20
@@ -3037,8 +3060,6 @@ ahd_reg_print_t ahd_scb_disconnected_lists_print;
3037#define SHVALIDSTDIS 0x02 3060#define SHVALIDSTDIS 0x02
3038#define LSTSGCLRDIS 0x01 3061#define LSTSGCLRDIS 0x01
3039 3062
3040#define ANNEXDAT 0x66
3041
3042#define IOWNID 0x67 3063#define IOWNID 0x67
3043 3064
3044#define PLL960CTL0 0x68 3065#define PLL960CTL0 0x68
@@ -3071,10 +3092,10 @@ ahd_reg_print_t ahd_scb_disconnected_lists_print;
3071#define PLL_CNTCLR 0x40 3092#define PLL_CNTCLR 0x40
3072#define PLL_RST 0x01 3093#define PLL_RST 0x01
3073 3094
3074#define PLL400CNT0 0x6e
3075
3076#define UNFAIRNESS 0x6e 3095#define UNFAIRNESS 0x6e
3077 3096
3097#define PLL400CNT0 0x6e
3098
3078#define HADDR 0x70 3099#define HADDR 0x70
3079 3100
3080#define PLLDELAY 0x70 3101#define PLLDELAY 0x70
@@ -3088,14 +3109,14 @@ ahd_reg_print_t ahd_scb_disconnected_lists_print;
3088 3109
3089#define HODMAEN 0x7a 3110#define HODMAEN 0x7a
3090 3111
3091#define SGHADDR 0x7c
3092
3093#define SCBHADDR 0x7c 3112#define SCBHADDR 0x7c
3094 3113
3095#define SGHCNT 0x84 3114#define SGHADDR 0x7c
3096 3115
3097#define SCBHCNT 0x84 3116#define SCBHCNT 0x84
3098 3117
3118#define SGHCNT 0x84
3119
3099#define DFF_THRSH 0x88 3120#define DFF_THRSH 0x88
3100#define WR_DFTHRSH 0x70 3121#define WR_DFTHRSH 0x70
3101#define RD_DFTHRSH 0x07 3122#define RD_DFTHRSH 0x07
@@ -3113,8 +3134,8 @@ ahd_reg_print_t ahd_scb_disconnected_lists_print;
3113#define RD_DFTHRSH_63 0x03 3134#define RD_DFTHRSH_63 0x03
3114#define RD_DFTHRSH_50 0x02 3135#define RD_DFTHRSH_50 0x02
3115#define RD_DFTHRSH_25 0x01 3136#define RD_DFTHRSH_25 0x01
3116#define WR_DFTHRSH_MIN 0x00
3117#define RD_DFTHRSH_MIN 0x00 3137#define RD_DFTHRSH_MIN 0x00
3138#define WR_DFTHRSH_MIN 0x00
3118 3139
3119#define ROMADDR 0x8a 3140#define ROMADDR 0x8a
3120 3141
@@ -3150,20 +3171,22 @@ ahd_reg_print_t ahd_scb_disconnected_lists_print;
3150#define DCH1NSEN 0x02 3171#define DCH1NSEN 0x02
3151#define DCH0NSEN 0x01 3172#define DCH0NSEN 0x01
3152 3173
3153#define DCHRXMSG1 0x91
3154
3155#define CMCRXMSG1 0x91 3174#define CMCRXMSG1 0x91
3156 3175
3157#define DCHRXMSG2 0x92 3176#define DCHRXMSG1 0x91
3158 3177
3159#define OVLYRXMSG2 0x92 3178#define DCHRXMSG2 0x92
3160 3179
3161#define CMCRXMSG2 0x92 3180#define CMCRXMSG2 0x92
3162 3181
3163#define OST 0x92 3182#define OST 0x92
3164 3183
3184#define OVLYRXMSG2 0x92
3185
3165#define DCHRXMSG3 0x93 3186#define DCHRXMSG3 0x93
3166 3187
3188#define OVLYRXMSG3 0x93
3189
3167#define CMCRXMSG3 0x93 3190#define CMCRXMSG3 0x93
3168 3191
3169#define PCIXCTL 0x93 3192#define PCIXCTL 0x93
@@ -3175,26 +3198,24 @@ ahd_reg_print_t ahd_scb_disconnected_lists_print;
3175#define TSCSERREN 0x02 3198#define TSCSERREN 0x02
3176#define CMPABCDIS 0x01 3199#define CMPABCDIS 0x01
3177 3200
3178#define OVLYRXMSG3 0x93
3179
3180#define OVLYSEQBCNT 0x94 3201#define OVLYSEQBCNT 0x94
3181 3202
3182#define CMCSEQBCNT 0x94
3183
3184#define DCHSEQBCNT 0x94 3203#define DCHSEQBCNT 0x94
3185 3204
3186#define CMCSPLTSTAT0 0x96 3205#define CMCSEQBCNT 0x94
3187 3206
3188#define OVLYSPLTSTAT0 0x96 3207#define CMCSPLTSTAT0 0x96
3189 3208
3190#define DCHSPLTSTAT0 0x96 3209#define DCHSPLTSTAT0 0x96
3191 3210
3192#define DCHSPLTSTAT1 0x97 3211#define OVLYSPLTSTAT0 0x96
3193 3212
3194#define CMCSPLTSTAT1 0x97 3213#define CMCSPLTSTAT1 0x97
3195 3214
3196#define OVLYSPLTSTAT1 0x97 3215#define OVLYSPLTSTAT1 0x97
3197 3216
3217#define DCHSPLTSTAT1 0x97
3218
3198#define SGRXMSG0 0x98 3219#define SGRXMSG0 0x98
3199#define CDNUM 0xf8 3220#define CDNUM 0xf8
3200#define CFNUM 0x07 3221#define CFNUM 0x07
@@ -3244,13 +3265,13 @@ ahd_reg_print_t ahd_scb_disconnected_lists_print;
3244#define RXSCEMSG 0x02 3265#define RXSCEMSG 0x02
3245#define RXSPLTRSP 0x01 3266#define RXSPLTRSP 0x01
3246 3267
3268#define SGSPLTSTAT1 0x9f
3269#define RXDATABUCKET 0x01
3270
3247#define SFUNCT 0x9f 3271#define SFUNCT 0x9f
3248#define TEST_GROUP 0xf0 3272#define TEST_GROUP 0xf0
3249#define TEST_NUM 0x0f 3273#define TEST_NUM 0x0f
3250 3274
3251#define SGSPLTSTAT1 0x9f
3252#define RXDATABUCKET 0x01
3253
3254#define DF0PCISTAT 0xa0 3275#define DF0PCISTAT 0xa0
3255 3276
3256#define REG0 0xa0 3277#define REG0 0xa0
@@ -3299,10 +3320,10 @@ ahd_reg_print_t ahd_scb_disconnected_lists_print;
3299 3320
3300#define CCSGADDR 0xac 3321#define CCSGADDR 0xac
3301 3322
3302#define CCSCBADDR 0xac
3303
3304#define CCSCBADR_BK 0xac 3323#define CCSCBADR_BK 0xac
3305 3324
3325#define CCSCBADDR 0xac
3326
3306#define CMC_RAMBIST 0xad 3327#define CMC_RAMBIST 0xad
3307#define SG_ELEMENT_SIZE 0x80 3328#define SG_ELEMENT_SIZE 0x80
3308#define SCBRAMBIST_FAIL 0x40 3329#define SCBRAMBIST_FAIL 0x40
@@ -3311,14 +3332,6 @@ ahd_reg_print_t ahd_scb_disconnected_lists_print;
3311#define CMC_BUFFER_BIST_FAIL 0x02 3332#define CMC_BUFFER_BIST_FAIL 0x02
3312#define CMC_BUFFER_BIST_EN 0x01 3333#define CMC_BUFFER_BIST_EN 0x01
3313 3334
3314#define CCSGCTL 0xad
3315#define CCSGEN 0x0c
3316#define CCSGDONE 0x80
3317#define SG_CACHE_AVAIL 0x10
3318#define CCSGENACK 0x08
3319#define SG_FETCH_REQ 0x02
3320#define CCSGRESET 0x01
3321
3322#define CCSCBCTL 0xad 3335#define CCSCBCTL 0xad
3323#define CCSCBDONE 0x80 3336#define CCSCBDONE 0x80
3324#define ARRDONE 0x40 3337#define ARRDONE 0x40
@@ -3327,6 +3340,14 @@ ahd_reg_print_t ahd_scb_disconnected_lists_print;
3327#define CCSCBDIR 0x04 3340#define CCSCBDIR 0x04
3328#define CCSCBRESET 0x01 3341#define CCSCBRESET 0x01
3329 3342
3343#define CCSGCTL 0xad
3344#define CCSGEN 0x0c
3345#define CCSGDONE 0x80
3346#define SG_CACHE_AVAIL 0x10
3347#define CCSGENACK 0x08
3348#define SG_FETCH_REQ 0x02
3349#define CCSGRESET 0x01
3350
3330#define CCSGRAM 0xb0 3351#define CCSGRAM 0xb0
3331 3352
3332#define FLEXADR 0xb0 3353#define FLEXADR 0xb0
@@ -3356,8 +3377,8 @@ ahd_reg_print_t ahd_scb_disconnected_lists_print;
3356#define SEEDAT 0xbc 3377#define SEEDAT 0xbc
3357 3378
3358#define SEECTL 0xbe 3379#define SEECTL 0xbe
3359#define SEEOP_EWEN 0x40
3360#define SEEOP_WALL 0x40 3380#define SEEOP_WALL 0x40
3381#define SEEOP_EWEN 0x40
3361#define SEEOP_EWDS 0x40 3382#define SEEOP_EWDS 0x40
3362#define SEEOPCODE 0x70 3383#define SEEOPCODE 0x70
3363#define SEERST 0x02 3384#define SEERST 0x02
@@ -3414,14 +3435,14 @@ ahd_reg_print_t ahd_scb_disconnected_lists_print;
3414 3435
3415#define WRTBIASCALC 0xc7 3436#define WRTBIASCALC 0xc7
3416 3437
3417#define DFPTRS 0xc8
3418
3419#define RCVRBIASCALC 0xc8 3438#define RCVRBIASCALC 0xc8
3420 3439
3421#define DFBKPTR 0xc9 3440#define DFPTRS 0xc8
3422 3441
3423#define SKEWCALC 0xc9 3442#define SKEWCALC 0xc9
3424 3443
3444#define DFBKPTR 0xc9
3445
3425#define DFDBCTL 0xcb 3446#define DFDBCTL 0xcb
3426#define DFF_CIO_WR_RDY 0x20 3447#define DFF_CIO_WR_RDY 0x20
3427#define DFF_CIO_RD_RDY 0x10 3448#define DFF_CIO_RD_RDY 0x10
@@ -3475,11 +3496,11 @@ ahd_reg_print_t ahd_scb_disconnected_lists_print;
3475 3496
3476#define DINDEX 0xe4 3497#define DINDEX 0xe4
3477 3498
3499#define BRKADDR0 0xe6
3500
3478#define BRKADDR1 0xe6 3501#define BRKADDR1 0xe6
3479#define BRKDIS 0x80 3502#define BRKDIS 0x80
3480 3503
3481#define BRKADDR0 0xe6
3482
3483#define ALLONES 0xe8 3504#define ALLONES 0xe8
3484 3505
3485#define ALLZEROS 0xea 3506#define ALLZEROS 0xea
@@ -3494,14 +3515,14 @@ ahd_reg_print_t ahd_scb_disconnected_lists_print;
3494 3515
3495#define STACK 0xf2 3516#define STACK 0xf2
3496 3517
3497#define CURADDR 0xf4
3498
3499#define INTVEC1_ADDR 0xf4 3518#define INTVEC1_ADDR 0xf4
3500 3519
3501#define INTVEC2_ADDR 0xf6 3520#define CURADDR 0xf4
3502 3521
3503#define LASTADDR 0xf6 3522#define LASTADDR 0xf6
3504 3523
3524#define INTVEC2_ADDR 0xf6
3525
3505#define LONGJMP_ADDR 0xf8 3526#define LONGJMP_ADDR 0xf8
3506 3527
3507#define ACCUM_SAVE 0xfa 3528#define ACCUM_SAVE 0xfa
@@ -3524,25 +3545,31 @@ ahd_reg_print_t ahd_scb_disconnected_lists_print;
3524 3545
3525#define COMPLETE_DMA_SCB_HEAD 0x12c 3546#define COMPLETE_DMA_SCB_HEAD 0x12c
3526 3547
3527#define QFREEZE_COUNT 0x12e 3548#define COMPLETE_DMA_SCB_TAIL 0x12e
3549
3550#define COMPLETE_ON_QFREEZE_HEAD 0x130
3551
3552#define QFREEZE_COUNT 0x132
3528 3553
3529#define SAVED_MODE 0x130 3554#define KERNEL_QFREEZE_COUNT 0x134
3530 3555
3531#define MSG_OUT 0x131 3556#define SAVED_MODE 0x136
3532 3557
3533#define DMAPARAMS 0x132 3558#define MSG_OUT 0x137
3559
3560#define DMAPARAMS 0x138
3534#define PRELOADEN 0x80 3561#define PRELOADEN 0x80
3535#define WIDEODD 0x40 3562#define WIDEODD 0x40
3536#define SCSIEN 0x20 3563#define SCSIEN 0x20
3537#define SDMAEN 0x10 3564#define SDMAEN 0x10
3538#define SDMAENACK 0x10 3565#define SDMAENACK 0x10
3539#define HDMAENACK 0x08
3540#define HDMAEN 0x08 3566#define HDMAEN 0x08
3567#define HDMAENACK 0x08
3541#define DIRECTION 0x04 3568#define DIRECTION 0x04
3542#define FIFOFLUSH 0x02 3569#define FIFOFLUSH 0x02
3543#define FIFORESET 0x01 3570#define FIFORESET 0x01
3544 3571
3545#define SEQ_FLAGS 0x133 3572#define SEQ_FLAGS 0x139
3546#define NOT_IDENTIFIED 0x80 3573#define NOT_IDENTIFIED 0x80
3547#define NO_CDB_SENT 0x40 3574#define NO_CDB_SENT 0x40
3548#define TARGET_CMD_IS_TAGGED 0x40 3575#define TARGET_CMD_IS_TAGGED 0x40
@@ -3553,11 +3580,11 @@ ahd_reg_print_t ahd_scb_disconnected_lists_print;
3553#define SPHASE_PENDING 0x02 3580#define SPHASE_PENDING 0x02
3554#define NO_DISCONNECT 0x01 3581#define NO_DISCONNECT 0x01
3555 3582
3556#define SAVED_SCSIID 0x134 3583#define SAVED_SCSIID 0x13a
3557 3584
3558#define SAVED_LUN 0x135 3585#define SAVED_LUN 0x13b
3559 3586
3560#define LASTPHASE 0x136 3587#define LASTPHASE 0x13c
3561#define PHASE_MASK 0xe0 3588#define PHASE_MASK 0xe0
3562#define CDI 0x80 3589#define CDI 0x80
3563#define IOI 0x40 3590#define IOI 0x40
@@ -3572,18 +3599,18 @@ ahd_reg_print_t ahd_scb_disconnected_lists_print;
3572#define P_DATAOUT_DT 0x20 3599#define P_DATAOUT_DT 0x20
3573#define P_DATAOUT 0x00 3600#define P_DATAOUT 0x00
3574 3601
3575#define QOUTFIFO_ENTRY_VALID_TAG 0x137 3602#define QOUTFIFO_ENTRY_VALID_TAG 0x13d
3576 3603
3577#define SHARED_DATA_ADDR 0x138 3604#define KERNEL_TQINPOS 0x13e
3578 3605
3579#define QOUTFIFO_NEXT_ADDR 0x13c 3606#define TQINPOS 0x13f
3580 3607
3581#define KERNEL_TQINPOS 0x140 3608#define SHARED_DATA_ADDR 0x140
3582 3609
3583#define TQINPOS 0x141 3610#define QOUTFIFO_NEXT_ADDR 0x144
3584 3611
3585#define ARG_1 0x142 3612#define ARG_1 0x148
3586#define RETURN_1 0x142 3613#define RETURN_1 0x148
3587#define SEND_MSG 0x80 3614#define SEND_MSG 0x80
3588#define SEND_SENSE 0x40 3615#define SEND_SENSE 0x40
3589#define SEND_REJ 0x20 3616#define SEND_REJ 0x20
@@ -3593,12 +3620,12 @@ ahd_reg_print_t ahd_scb_disconnected_lists_print;
3593#define CONT_MSG_LOOP_READ 0x03 3620#define CONT_MSG_LOOP_READ 0x03
3594#define CONT_MSG_LOOP_TARG 0x02 3621#define CONT_MSG_LOOP_TARG 0x02
3595 3622
3596#define ARG_2 0x143 3623#define ARG_2 0x149
3597#define RETURN_2 0x143 3624#define RETURN_2 0x149
3598 3625
3599#define LAST_MSG 0x144 3626#define LAST_MSG 0x14a
3600 3627
3601#define SCSISEQ_TEMPLATE 0x145 3628#define SCSISEQ_TEMPLATE 0x14b
3602#define MANUALCTL 0x40 3629#define MANUALCTL 0x40
3603#define ENSELI 0x20 3630#define ENSELI 0x20
3604#define ENRSELI 0x10 3631#define ENRSELI 0x10
@@ -3606,27 +3633,27 @@ ahd_reg_print_t ahd_scb_disconnected_lists_print;
3606#define ENAUTOATNP 0x02 3633#define ENAUTOATNP 0x02
3607#define ALTSTIM 0x01 3634#define ALTSTIM 0x01
3608 3635
3609#define INITIATOR_TAG 0x146 3636#define INITIATOR_TAG 0x14c
3610 3637
3611#define SEQ_FLAGS2 0x147 3638#define SEQ_FLAGS2 0x14d
3612#define SELECTOUT_QFROZEN 0x04 3639#define SELECTOUT_QFROZEN 0x04
3613#define TARGET_MSG_PENDING 0x02 3640#define TARGET_MSG_PENDING 0x02
3614 3641
3615#define ALLOCFIFO_SCBPTR 0x148 3642#define ALLOCFIFO_SCBPTR 0x14e
3616 3643
3617#define INT_COALESCING_TIMER 0x14a 3644#define INT_COALESCING_TIMER 0x150
3618 3645
3619#define INT_COALESCING_MAXCMDS 0x14c 3646#define INT_COALESCING_MAXCMDS 0x152
3620 3647
3621#define INT_COALESCING_MINCMDS 0x14d 3648#define INT_COALESCING_MINCMDS 0x153
3622 3649
3623#define CMDS_PENDING 0x14e 3650#define CMDS_PENDING 0x154
3624 3651
3625#define INT_COALESCING_CMDCOUNT 0x150 3652#define INT_COALESCING_CMDCOUNT 0x156
3626 3653
3627#define LOCAL_HS_MAILBOX 0x151 3654#define LOCAL_HS_MAILBOX 0x157
3628 3655
3629#define CMDSIZE_TABLE 0x152 3656#define CMDSIZE_TABLE 0x158
3630 3657
3631#define SCB_BASE 0x180 3658#define SCB_BASE 0x180
3632 3659
@@ -3701,6 +3728,16 @@ ahd_reg_print_t ahd_scb_disconnected_lists_print;
3701#define SCB_DISCONNECTED_LISTS 0x1b8 3728#define SCB_DISCONNECTED_LISTS 0x1b8
3702 3729
3703 3730
3731#define AHD_TIMER_MAX_US 0x18ffe7
3732#define AHD_TIMER_MAX_TICKS 0xffff
3733#define AHD_SENSE_BUFSIZE 0x100
3734#define BUS_8_BIT 0x00
3735#define TARGET_CMD_CMPLT 0xfe
3736#define SEEOP_WRAL_ADDR 0x40
3737#define AHD_AMPLITUDE_DEF 0x07
3738#define AHD_PRECOMP_CUTBACK_37 0x07
3739#define AHD_PRECOMP_SHIFT 0x00
3740#define AHD_ANNEXCOL_PRECOMP_SLEW 0x04
3704#define AHD_TIMER_US_PER_TICK 0x19 3741#define AHD_TIMER_US_PER_TICK 0x19
3705#define SCB_TRANSFER_SIZE_FULL_LUN 0x38 3742#define SCB_TRANSFER_SIZE_FULL_LUN 0x38
3706#define STATUS_QUEUE_FULL 0x28 3743#define STATUS_QUEUE_FULL 0x28
@@ -3724,28 +3761,18 @@ ahd_reg_print_t ahd_scb_disconnected_lists_print;
3724#define B_CURRFIFO_0 0x02 3761#define B_CURRFIFO_0 0x02
3725#define LUNLEN_SINGLE_LEVEL_LUN 0x0f 3762#define LUNLEN_SINGLE_LEVEL_LUN 0x0f
3726#define NVRAM_SCB_OFFSET 0x2c 3763#define NVRAM_SCB_OFFSET 0x2c
3727#define AHD_TIMER_MAX_US 0x18ffe7
3728#define AHD_TIMER_MAX_TICKS 0xffff
3729#define STATUS_PKT_SENSE 0xff 3764#define STATUS_PKT_SENSE 0xff
3730#define CMD_GROUP_CODE_SHIFT 0x05 3765#define CMD_GROUP_CODE_SHIFT 0x05
3731#define AHD_SENSE_BUFSIZE 0x100
3732#define MAX_OFFSET_PACED_BUG 0x7f 3766#define MAX_OFFSET_PACED_BUG 0x7f
3733#define BUS_8_BIT 0x00
3734#define STIMESEL_BUG_ADJ 0x08 3767#define STIMESEL_BUG_ADJ 0x08
3735#define STIMESEL_MIN 0x18 3768#define STIMESEL_MIN 0x18
3736#define STIMESEL_SHIFT 0x03 3769#define STIMESEL_SHIFT 0x03
3737#define CCSGRAM_MAXSEGS 0x10 3770#define CCSGRAM_MAXSEGS 0x10
3738#define INVALID_ADDR 0x80 3771#define INVALID_ADDR 0x80
3739#define TARGET_CMD_CMPLT 0xfe
3740#define SEEOP_WRAL_ADDR 0x40
3741#define SEEOP_ERAL_ADDR 0x80 3772#define SEEOP_ERAL_ADDR 0x80
3742#define AHD_AMPLITUDE_DEF 0x07
3743#define AHD_SLEWRATE_DEF_REVB 0x08 3773#define AHD_SLEWRATE_DEF_REVB 0x08
3744#define AHD_PRECOMP_CUTBACK_37 0x07
3745#define AHD_PRECOMP_CUTBACK_17 0x04 3774#define AHD_PRECOMP_CUTBACK_17 0x04
3746#define AHD_PRECOMP_SHIFT 0x00
3747#define AHD_PRECOMP_MASK 0x07 3775#define AHD_PRECOMP_MASK 0x07
3748#define AHD_ANNEXCOL_PRECOMP_SLEW 0x04
3749#define SRC_MODE_SHIFT 0x00 3776#define SRC_MODE_SHIFT 0x00
3750#define PKT_OVERRUN_BUFSIZE 0x200 3777#define PKT_OVERRUN_BUFSIZE 0x200
3751#define SCB_TRANSFER_SIZE_1BYTE_LUN 0x30 3778#define SCB_TRANSFER_SIZE_1BYTE_LUN 0x30
@@ -3761,6 +3788,7 @@ ahd_reg_print_t ahd_scb_disconnected_lists_print;
3761 3788
3762 3789
3763/* Downloaded Constant Definitions */ 3790/* Downloaded Constant Definitions */
3791#define CACHELINE_MASK 0x07
3764#define SCB_TRANSFER_SIZE 0x06 3792#define SCB_TRANSFER_SIZE 0x06
3765#define PKT_OVERRUN_BUFOFFSET 0x05 3793#define PKT_OVERRUN_BUFOFFSET 0x05
3766#define SG_SIZEOF 0x04 3794#define SG_SIZEOF 0x04
@@ -3768,9 +3796,9 @@ ahd_reg_print_t ahd_scb_disconnected_lists_print;
3768#define SG_PREFETCH_ALIGN_MASK 0x02 3796#define SG_PREFETCH_ALIGN_MASK 0x02
3769#define SG_PREFETCH_CNT_LIMIT 0x01 3797#define SG_PREFETCH_CNT_LIMIT 0x01
3770#define SG_PREFETCH_CNT 0x00 3798#define SG_PREFETCH_CNT 0x00
3771#define DOWNLOAD_CONST_COUNT 0x07 3799#define DOWNLOAD_CONST_COUNT 0x08
3772 3800
3773 3801
3774/* Exported Labels */ 3802/* Exported Labels */
3775#define LABEL_seq_isr 0x269 3803#define LABEL_seq_isr 0x285
3776#define LABEL_timer_isr 0x265 3804#define LABEL_timer_isr 0x281
diff --git a/drivers/scsi/aic7xxx/aic79xx_reg_print.c_shipped b/drivers/scsi/aic7xxx/aic79xx_reg_print.c_shipped
index 3098a757e3d7..a4137c985376 100644
--- a/drivers/scsi/aic7xxx/aic79xx_reg_print.c_shipped
+++ b/drivers/scsi/aic7xxx/aic79xx_reg_print.c_shipped
@@ -2,8 +2,8 @@
2 * DO NOT EDIT - This file is automatically generated 2 * DO NOT EDIT - This file is automatically generated
3 * from the following source files: 3 * from the following source files:
4 * 4 *
5 * $Id: //depot/aic7xxx/aic7xxx/aic79xx.seq#94 $ 5 * $Id: //depot/aic7xxx/aic7xxx/aic79xx.seq#118 $
6 * $Id: //depot/aic7xxx/aic7xxx/aic79xx.reg#70 $ 6 * $Id: //depot/aic7xxx/aic7xxx/aic79xx.reg#75 $
7 */ 7 */
8 8
9#include "aic79xx_osm.h" 9#include "aic79xx_osm.h"
@@ -172,21 +172,6 @@ ahd_hs_mailbox_print(u_int regvalue, u_int *cur_col, u_int wrap)
172 0x0b, regvalue, cur_col, wrap)); 172 0x0b, regvalue, cur_col, wrap));
173} 173}
174 174
175static ahd_reg_parse_entry_t CLRSEQINTSTAT_parse_table[] = {
176 { "CLRSEQ_SPLTINT", 0x01, 0x01 },
177 { "CLRSEQ_PCIINT", 0x02, 0x02 },
178 { "CLRSEQ_SCSIINT", 0x04, 0x04 },
179 { "CLRSEQ_SEQINT", 0x08, 0x08 },
180 { "CLRSEQ_SWTMRTO", 0x10, 0x10 }
181};
182
183int
184ahd_clrseqintstat_print(u_int regvalue, u_int *cur_col, u_int wrap)
185{
186 return (ahd_print_register(CLRSEQINTSTAT_parse_table, 5, "CLRSEQINTSTAT",
187 0x0c, regvalue, cur_col, wrap));
188}
189
190static ahd_reg_parse_entry_t SEQINTSTAT_parse_table[] = { 175static ahd_reg_parse_entry_t SEQINTSTAT_parse_table[] = {
191 { "SEQ_SPLTINT", 0x01, 0x01 }, 176 { "SEQ_SPLTINT", 0x01, 0x01 },
192 { "SEQ_PCIINT", 0x02, 0x02 }, 177 { "SEQ_PCIINT", 0x02, 0x02 },
@@ -202,6 +187,21 @@ ahd_seqintstat_print(u_int regvalue, u_int *cur_col, u_int wrap)
202 0x0c, regvalue, cur_col, wrap)); 187 0x0c, regvalue, cur_col, wrap));
203} 188}
204 189
190static ahd_reg_parse_entry_t CLRSEQINTSTAT_parse_table[] = {
191 { "CLRSEQ_SPLTINT", 0x01, 0x01 },
192 { "CLRSEQ_PCIINT", 0x02, 0x02 },
193 { "CLRSEQ_SCSIINT", 0x04, 0x04 },
194 { "CLRSEQ_SEQINT", 0x08, 0x08 },
195 { "CLRSEQ_SWTMRTO", 0x10, 0x10 }
196};
197
198int
199ahd_clrseqintstat_print(u_int regvalue, u_int *cur_col, u_int wrap)
200{
201 return (ahd_print_register(CLRSEQINTSTAT_parse_table, 5, "CLRSEQINTSTAT",
202 0x0c, regvalue, cur_col, wrap));
203}
204
205int 205int
206ahd_swtimer_print(u_int regvalue, u_int *cur_col, u_int wrap) 206ahd_swtimer_print(u_int regvalue, u_int *cur_col, u_int wrap)
207{ 207{
@@ -670,16 +670,16 @@ ahd_sxfrctl0_print(u_int regvalue, u_int *cur_col, u_int wrap)
670} 670}
671 671
672int 672int
673ahd_businitid_print(u_int regvalue, u_int *cur_col, u_int wrap) 673ahd_dlcount_print(u_int regvalue, u_int *cur_col, u_int wrap)
674{ 674{
675 return (ahd_print_register(NULL, 0, "BUSINITID", 675 return (ahd_print_register(NULL, 0, "DLCOUNT",
676 0x3c, regvalue, cur_col, wrap)); 676 0x3c, regvalue, cur_col, wrap));
677} 677}
678 678
679int 679int
680ahd_dlcount_print(u_int regvalue, u_int *cur_col, u_int wrap) 680ahd_businitid_print(u_int regvalue, u_int *cur_col, u_int wrap)
681{ 681{
682 return (ahd_print_register(NULL, 0, "DLCOUNT", 682 return (ahd_print_register(NULL, 0, "BUSINITID",
683 0x3c, regvalue, cur_col, wrap)); 683 0x3c, regvalue, cur_col, wrap));
684} 684}
685 685
@@ -859,21 +859,6 @@ ahd_selid_print(u_int regvalue, u_int *cur_col, u_int wrap)
859 0x49, regvalue, cur_col, wrap)); 859 0x49, regvalue, cur_col, wrap));
860} 860}
861 861
862static ahd_reg_parse_entry_t SBLKCTL_parse_table[] = {
863 { "SELWIDE", 0x02, 0x02 },
864 { "ENAB20", 0x04, 0x04 },
865 { "ENAB40", 0x08, 0x08 },
866 { "DIAGLEDON", 0x40, 0x40 },
867 { "DIAGLEDEN", 0x80, 0x80 }
868};
869
870int
871ahd_sblkctl_print(u_int regvalue, u_int *cur_col, u_int wrap)
872{
873 return (ahd_print_register(SBLKCTL_parse_table, 5, "SBLKCTL",
874 0x4a, regvalue, cur_col, wrap));
875}
876
877static ahd_reg_parse_entry_t OPTIONMODE_parse_table[] = { 862static ahd_reg_parse_entry_t OPTIONMODE_parse_table[] = {
878 { "AUTO_MSGOUT_DE", 0x02, 0x02 }, 863 { "AUTO_MSGOUT_DE", 0x02, 0x02 },
879 { "ENDGFORMCHK", 0x04, 0x04 }, 864 { "ENDGFORMCHK", 0x04, 0x04 },
@@ -891,22 +876,19 @@ ahd_optionmode_print(u_int regvalue, u_int *cur_col, u_int wrap)
891 0x4a, regvalue, cur_col, wrap)); 876 0x4a, regvalue, cur_col, wrap));
892} 877}
893 878
894static ahd_reg_parse_entry_t SSTAT0_parse_table[] = { 879static ahd_reg_parse_entry_t SBLKCTL_parse_table[] = {
895 { "ARBDO", 0x01, 0x01 }, 880 { "SELWIDE", 0x02, 0x02 },
896 { "SPIORDY", 0x02, 0x02 }, 881 { "ENAB20", 0x04, 0x04 },
897 { "OVERRUN", 0x04, 0x04 }, 882 { "ENAB40", 0x08, 0x08 },
898 { "IOERR", 0x08, 0x08 }, 883 { "DIAGLEDON", 0x40, 0x40 },
899 { "SELINGO", 0x10, 0x10 }, 884 { "DIAGLEDEN", 0x80, 0x80 }
900 { "SELDI", 0x20, 0x20 },
901 { "SELDO", 0x40, 0x40 },
902 { "TARGET", 0x80, 0x80 }
903}; 885};
904 886
905int 887int
906ahd_sstat0_print(u_int regvalue, u_int *cur_col, u_int wrap) 888ahd_sblkctl_print(u_int regvalue, u_int *cur_col, u_int wrap)
907{ 889{
908 return (ahd_print_register(SSTAT0_parse_table, 8, "SSTAT0", 890 return (ahd_print_register(SBLKCTL_parse_table, 5, "SBLKCTL",
909 0x4b, regvalue, cur_col, wrap)); 891 0x4a, regvalue, cur_col, wrap));
910} 892}
911 893
912static ahd_reg_parse_entry_t CLRSINT0_parse_table[] = { 894static ahd_reg_parse_entry_t CLRSINT0_parse_table[] = {
@@ -926,6 +908,24 @@ ahd_clrsint0_print(u_int regvalue, u_int *cur_col, u_int wrap)
926 0x4b, regvalue, cur_col, wrap)); 908 0x4b, regvalue, cur_col, wrap));
927} 909}
928 910
911static ahd_reg_parse_entry_t SSTAT0_parse_table[] = {
912 { "ARBDO", 0x01, 0x01 },
913 { "SPIORDY", 0x02, 0x02 },
914 { "OVERRUN", 0x04, 0x04 },
915 { "IOERR", 0x08, 0x08 },
916 { "SELINGO", 0x10, 0x10 },
917 { "SELDI", 0x20, 0x20 },
918 { "SELDO", 0x40, 0x40 },
919 { "TARGET", 0x80, 0x80 }
920};
921
922int
923ahd_sstat0_print(u_int regvalue, u_int *cur_col, u_int wrap)
924{
925 return (ahd_print_register(SSTAT0_parse_table, 8, "SSTAT0",
926 0x4b, regvalue, cur_col, wrap));
927}
928
929static ahd_reg_parse_entry_t SIMODE0_parse_table[] = { 929static ahd_reg_parse_entry_t SIMODE0_parse_table[] = {
930 { "ENARBDO", 0x01, 0x01 }, 930 { "ENARBDO", 0x01, 0x01 },
931 { "ENSPIORDY", 0x02, 0x02 }, 931 { "ENSPIORDY", 0x02, 0x02 },
@@ -998,30 +998,30 @@ ahd_sstat2_print(u_int regvalue, u_int *cur_col, u_int wrap)
998 0x4d, regvalue, cur_col, wrap)); 998 0x4d, regvalue, cur_col, wrap));
999} 999}
1000 1000
1001static ahd_reg_parse_entry_t CLRSINT2_parse_table[] = { 1001static ahd_reg_parse_entry_t SIMODE2_parse_table[] = {
1002 { "CLRDMADONE", 0x01, 0x01 }, 1002 { "ENDMADONE", 0x01, 0x01 },
1003 { "CLRSDONE", 0x02, 0x02 }, 1003 { "ENSDONE", 0x02, 0x02 },
1004 { "CLRWIDE_RES", 0x04, 0x04 }, 1004 { "ENWIDE_RES", 0x04, 0x04 }
1005 { "CLRNONPACKREQ", 0x20, 0x20 }
1006}; 1005};
1007 1006
1008int 1007int
1009ahd_clrsint2_print(u_int regvalue, u_int *cur_col, u_int wrap) 1008ahd_simode2_print(u_int regvalue, u_int *cur_col, u_int wrap)
1010{ 1009{
1011 return (ahd_print_register(CLRSINT2_parse_table, 4, "CLRSINT2", 1010 return (ahd_print_register(SIMODE2_parse_table, 3, "SIMODE2",
1012 0x4d, regvalue, cur_col, wrap)); 1011 0x4d, regvalue, cur_col, wrap));
1013} 1012}
1014 1013
1015static ahd_reg_parse_entry_t SIMODE2_parse_table[] = { 1014static ahd_reg_parse_entry_t CLRSINT2_parse_table[] = {
1016 { "ENDMADONE", 0x01, 0x01 }, 1015 { "CLRDMADONE", 0x01, 0x01 },
1017 { "ENSDONE", 0x02, 0x02 }, 1016 { "CLRSDONE", 0x02, 0x02 },
1018 { "ENWIDE_RES", 0x04, 0x04 } 1017 { "CLRWIDE_RES", 0x04, 0x04 },
1018 { "CLRNONPACKREQ", 0x20, 0x20 }
1019}; 1019};
1020 1020
1021int 1021int
1022ahd_simode2_print(u_int regvalue, u_int *cur_col, u_int wrap) 1022ahd_clrsint2_print(u_int regvalue, u_int *cur_col, u_int wrap)
1023{ 1023{
1024 return (ahd_print_register(SIMODE2_parse_table, 3, "SIMODE2", 1024 return (ahd_print_register(CLRSINT2_parse_table, 4, "CLRSINT2",
1025 0x4d, regvalue, cur_col, wrap)); 1025 0x4d, regvalue, cur_col, wrap));
1026} 1026}
1027 1027
@@ -1220,21 +1220,6 @@ ahd_clrsint3_print(u_int regvalue, u_int *cur_col, u_int wrap)
1220 0x53, regvalue, cur_col, wrap)); 1220 0x53, regvalue, cur_col, wrap));
1221} 1221}
1222 1222
1223static ahd_reg_parse_entry_t LQOMODE0_parse_table[] = {
1224 { "ENLQOTCRC", 0x01, 0x01 },
1225 { "ENLQOATNPKT", 0x02, 0x02 },
1226 { "ENLQOATNLQ", 0x04, 0x04 },
1227 { "ENLQOSTOPT2", 0x08, 0x08 },
1228 { "ENLQOTARGSCBPERR", 0x10, 0x10 }
1229};
1230
1231int
1232ahd_lqomode0_print(u_int regvalue, u_int *cur_col, u_int wrap)
1233{
1234 return (ahd_print_register(LQOMODE0_parse_table, 5, "LQOMODE0",
1235 0x54, regvalue, cur_col, wrap));
1236}
1237
1238static ahd_reg_parse_entry_t LQOSTAT0_parse_table[] = { 1223static ahd_reg_parse_entry_t LQOSTAT0_parse_table[] = {
1239 { "LQOTCRC", 0x01, 0x01 }, 1224 { "LQOTCRC", 0x01, 0x01 },
1240 { "LQOATNPKT", 0x02, 0x02 }, 1225 { "LQOATNPKT", 0x02, 0x02 },
@@ -1265,6 +1250,36 @@ ahd_clrlqoint0_print(u_int regvalue, u_int *cur_col, u_int wrap)
1265 0x54, regvalue, cur_col, wrap)); 1250 0x54, regvalue, cur_col, wrap));
1266} 1251}
1267 1252
1253static ahd_reg_parse_entry_t LQOMODE0_parse_table[] = {
1254 { "ENLQOTCRC", 0x01, 0x01 },
1255 { "ENLQOATNPKT", 0x02, 0x02 },
1256 { "ENLQOATNLQ", 0x04, 0x04 },
1257 { "ENLQOSTOPT2", 0x08, 0x08 },
1258 { "ENLQOTARGSCBPERR", 0x10, 0x10 }
1259};
1260
1261int
1262ahd_lqomode0_print(u_int regvalue, u_int *cur_col, u_int wrap)
1263{
1264 return (ahd_print_register(LQOMODE0_parse_table, 5, "LQOMODE0",
1265 0x54, regvalue, cur_col, wrap));
1266}
1267
1268static ahd_reg_parse_entry_t LQOMODE1_parse_table[] = {
1269 { "ENLQOPHACHGINPKT", 0x01, 0x01 },
1270 { "ENLQOBUSFREE", 0x02, 0x02 },
1271 { "ENLQOBADQAS", 0x04, 0x04 },
1272 { "ENLQOSTOPI2", 0x08, 0x08 },
1273 { "ENLQOINITSCBPERR", 0x10, 0x10 }
1274};
1275
1276int
1277ahd_lqomode1_print(u_int regvalue, u_int *cur_col, u_int wrap)
1278{
1279 return (ahd_print_register(LQOMODE1_parse_table, 5, "LQOMODE1",
1280 0x55, regvalue, cur_col, wrap));
1281}
1282
1268static ahd_reg_parse_entry_t LQOSTAT1_parse_table[] = { 1283static ahd_reg_parse_entry_t LQOSTAT1_parse_table[] = {
1269 { "LQOPHACHGINPKT", 0x01, 0x01 }, 1284 { "LQOPHACHGINPKT", 0x01, 0x01 },
1270 { "LQOBUSFREE", 0x02, 0x02 }, 1285 { "LQOBUSFREE", 0x02, 0x02 },
@@ -1295,21 +1310,6 @@ ahd_clrlqoint1_print(u_int regvalue, u_int *cur_col, u_int wrap)
1295 0x55, regvalue, cur_col, wrap)); 1310 0x55, regvalue, cur_col, wrap));
1296} 1311}
1297 1312
1298static ahd_reg_parse_entry_t LQOMODE1_parse_table[] = {
1299 { "ENLQOPHACHGINPKT", 0x01, 0x01 },
1300 { "ENLQOBUSFREE", 0x02, 0x02 },
1301 { "ENLQOBADQAS", 0x04, 0x04 },
1302 { "ENLQOSTOPI2", 0x08, 0x08 },
1303 { "ENLQOINITSCBPERR", 0x10, 0x10 }
1304};
1305
1306int
1307ahd_lqomode1_print(u_int regvalue, u_int *cur_col, u_int wrap)
1308{
1309 return (ahd_print_register(LQOMODE1_parse_table, 5, "LQOMODE1",
1310 0x55, regvalue, cur_col, wrap));
1311}
1312
1313static ahd_reg_parse_entry_t LQOSTAT2_parse_table[] = { 1313static ahd_reg_parse_entry_t LQOSTAT2_parse_table[] = {
1314 { "LQOSTOP0", 0x01, 0x01 }, 1314 { "LQOSTOP0", 0x01, 0x01 },
1315 { "LQOPHACHGOUTPKT", 0x02, 0x02 }, 1315 { "LQOPHACHGOUTPKT", 0x02, 0x02 },
@@ -1594,6 +1594,13 @@ ahd_annexcol_print(u_int regvalue, u_int *cur_col, u_int wrap)
1594 0x65, regvalue, cur_col, wrap)); 1594 0x65, regvalue, cur_col, wrap));
1595} 1595}
1596 1596
1597int
1598ahd_annexdat_print(u_int regvalue, u_int *cur_col, u_int wrap)
1599{
1600 return (ahd_print_register(NULL, 0, "ANNEXDAT",
1601 0x66, regvalue, cur_col, wrap));
1602}
1603
1597static ahd_reg_parse_entry_t SCSCHKN_parse_table[] = { 1604static ahd_reg_parse_entry_t SCSCHKN_parse_table[] = {
1598 { "LSTSGCLRDIS", 0x01, 0x01 }, 1605 { "LSTSGCLRDIS", 0x01, 0x01 },
1599 { "SHVALIDSTDIS", 0x02, 0x02 }, 1606 { "SHVALIDSTDIS", 0x02, 0x02 },
@@ -1612,13 +1619,6 @@ ahd_scschkn_print(u_int regvalue, u_int *cur_col, u_int wrap)
1612} 1619}
1613 1620
1614int 1621int
1615ahd_annexdat_print(u_int regvalue, u_int *cur_col, u_int wrap)
1616{
1617 return (ahd_print_register(NULL, 0, "ANNEXDAT",
1618 0x66, regvalue, cur_col, wrap));
1619}
1620
1621int
1622ahd_iownid_print(u_int regvalue, u_int *cur_col, u_int wrap) 1622ahd_iownid_print(u_int regvalue, u_int *cur_col, u_int wrap)
1623{ 1623{
1624 return (ahd_print_register(NULL, 0, "IOWNID", 1624 return (ahd_print_register(NULL, 0, "IOWNID",
@@ -1728,16 +1728,16 @@ ahd_pll400ctl1_print(u_int regvalue, u_int *cur_col, u_int wrap)
1728} 1728}
1729 1729
1730int 1730int
1731ahd_pll400cnt0_print(u_int regvalue, u_int *cur_col, u_int wrap) 1731ahd_unfairness_print(u_int regvalue, u_int *cur_col, u_int wrap)
1732{ 1732{
1733 return (ahd_print_register(NULL, 0, "PLL400CNT0", 1733 return (ahd_print_register(NULL, 0, "UNFAIRNESS",
1734 0x6e, regvalue, cur_col, wrap)); 1734 0x6e, regvalue, cur_col, wrap));
1735} 1735}
1736 1736
1737int 1737int
1738ahd_unfairness_print(u_int regvalue, u_int *cur_col, u_int wrap) 1738ahd_pll400cnt0_print(u_int regvalue, u_int *cur_col, u_int wrap)
1739{ 1739{
1740 return (ahd_print_register(NULL, 0, "UNFAIRNESS", 1740 return (ahd_print_register(NULL, 0, "PLL400CNT0",
1741 0x6e, regvalue, cur_col, wrap)); 1741 0x6e, regvalue, cur_col, wrap));
1742} 1742}
1743 1743
@@ -1788,30 +1788,30 @@ ahd_hodmaen_print(u_int regvalue, u_int *cur_col, u_int wrap)
1788} 1788}
1789 1789
1790int 1790int
1791ahd_sghaddr_print(u_int regvalue, u_int *cur_col, u_int wrap) 1791ahd_scbhaddr_print(u_int regvalue, u_int *cur_col, u_int wrap)
1792{ 1792{
1793 return (ahd_print_register(NULL, 0, "SGHADDR", 1793 return (ahd_print_register(NULL, 0, "SCBHADDR",
1794 0x7c, regvalue, cur_col, wrap)); 1794 0x7c, regvalue, cur_col, wrap));
1795} 1795}
1796 1796
1797int 1797int
1798ahd_scbhaddr_print(u_int regvalue, u_int *cur_col, u_int wrap) 1798ahd_sghaddr_print(u_int regvalue, u_int *cur_col, u_int wrap)
1799{ 1799{
1800 return (ahd_print_register(NULL, 0, "SCBHADDR", 1800 return (ahd_print_register(NULL, 0, "SGHADDR",
1801 0x7c, regvalue, cur_col, wrap)); 1801 0x7c, regvalue, cur_col, wrap));
1802} 1802}
1803 1803
1804int 1804int
1805ahd_sghcnt_print(u_int regvalue, u_int *cur_col, u_int wrap) 1805ahd_scbhcnt_print(u_int regvalue, u_int *cur_col, u_int wrap)
1806{ 1806{
1807 return (ahd_print_register(NULL, 0, "SGHCNT", 1807 return (ahd_print_register(NULL, 0, "SCBHCNT",
1808 0x84, regvalue, cur_col, wrap)); 1808 0x84, regvalue, cur_col, wrap));
1809} 1809}
1810 1810
1811int 1811int
1812ahd_scbhcnt_print(u_int regvalue, u_int *cur_col, u_int wrap) 1812ahd_sghcnt_print(u_int regvalue, u_int *cur_col, u_int wrap)
1813{ 1813{
1814 return (ahd_print_register(NULL, 0, "SCBHCNT", 1814 return (ahd_print_register(NULL, 0, "SGHCNT",
1815 0x84, regvalue, cur_col, wrap)); 1815 0x84, regvalue, cur_col, wrap));
1816} 1816}
1817 1817
@@ -1950,25 +1950,25 @@ ahd_nsenable_print(u_int regvalue, u_int *cur_col, u_int wrap)
1950 0x91, regvalue, cur_col, wrap)); 1950 0x91, regvalue, cur_col, wrap));
1951} 1951}
1952 1952
1953static ahd_reg_parse_entry_t DCHRXMSG1_parse_table[] = { 1953static ahd_reg_parse_entry_t CMCRXMSG1_parse_table[] = {
1954 { "CBNUM", 0xff, 0xff } 1954 { "CBNUM", 0xff, 0xff }
1955}; 1955};
1956 1956
1957int 1957int
1958ahd_dchrxmsg1_print(u_int regvalue, u_int *cur_col, u_int wrap) 1958ahd_cmcrxmsg1_print(u_int regvalue, u_int *cur_col, u_int wrap)
1959{ 1959{
1960 return (ahd_print_register(DCHRXMSG1_parse_table, 1, "DCHRXMSG1", 1960 return (ahd_print_register(CMCRXMSG1_parse_table, 1, "CMCRXMSG1",
1961 0x91, regvalue, cur_col, wrap)); 1961 0x91, regvalue, cur_col, wrap));
1962} 1962}
1963 1963
1964static ahd_reg_parse_entry_t CMCRXMSG1_parse_table[] = { 1964static ahd_reg_parse_entry_t DCHRXMSG1_parse_table[] = {
1965 { "CBNUM", 0xff, 0xff } 1965 { "CBNUM", 0xff, 0xff }
1966}; 1966};
1967 1967
1968int 1968int
1969ahd_cmcrxmsg1_print(u_int regvalue, u_int *cur_col, u_int wrap) 1969ahd_dchrxmsg1_print(u_int regvalue, u_int *cur_col, u_int wrap)
1970{ 1970{
1971 return (ahd_print_register(CMCRXMSG1_parse_table, 1, "CMCRXMSG1", 1971 return (ahd_print_register(DCHRXMSG1_parse_table, 1, "DCHRXMSG1",
1972 0x91, regvalue, cur_col, wrap)); 1972 0x91, regvalue, cur_col, wrap));
1973} 1973}
1974 1974
@@ -1983,17 +1983,6 @@ ahd_dchrxmsg2_print(u_int regvalue, u_int *cur_col, u_int wrap)
1983 0x92, regvalue, cur_col, wrap)); 1983 0x92, regvalue, cur_col, wrap));
1984} 1984}
1985 1985
1986static ahd_reg_parse_entry_t OVLYRXMSG2_parse_table[] = {
1987 { "MINDEX", 0xff, 0xff }
1988};
1989
1990int
1991ahd_ovlyrxmsg2_print(u_int regvalue, u_int *cur_col, u_int wrap)
1992{
1993 return (ahd_print_register(OVLYRXMSG2_parse_table, 1, "OVLYRXMSG2",
1994 0x92, regvalue, cur_col, wrap));
1995}
1996
1997static ahd_reg_parse_entry_t CMCRXMSG2_parse_table[] = { 1986static ahd_reg_parse_entry_t CMCRXMSG2_parse_table[] = {
1998 { "MINDEX", 0xff, 0xff } 1987 { "MINDEX", 0xff, 0xff }
1999}; 1988};
@@ -2012,6 +2001,17 @@ ahd_ost_print(u_int regvalue, u_int *cur_col, u_int wrap)
2012 0x92, regvalue, cur_col, wrap)); 2001 0x92, regvalue, cur_col, wrap));
2013} 2002}
2014 2003
2004static ahd_reg_parse_entry_t OVLYRXMSG2_parse_table[] = {
2005 { "MINDEX", 0xff, 0xff }
2006};
2007
2008int
2009ahd_ovlyrxmsg2_print(u_int regvalue, u_int *cur_col, u_int wrap)
2010{
2011 return (ahd_print_register(OVLYRXMSG2_parse_table, 1, "OVLYRXMSG2",
2012 0x92, regvalue, cur_col, wrap));
2013}
2014
2015static ahd_reg_parse_entry_t DCHRXMSG3_parse_table[] = { 2015static ahd_reg_parse_entry_t DCHRXMSG3_parse_table[] = {
2016 { "MCLASS", 0x0f, 0x0f } 2016 { "MCLASS", 0x0f, 0x0f }
2017}; 2017};
@@ -2023,6 +2023,17 @@ ahd_dchrxmsg3_print(u_int regvalue, u_int *cur_col, u_int wrap)
2023 0x93, regvalue, cur_col, wrap)); 2023 0x93, regvalue, cur_col, wrap));
2024} 2024}
2025 2025
2026static ahd_reg_parse_entry_t OVLYRXMSG3_parse_table[] = {
2027 { "MCLASS", 0x0f, 0x0f }
2028};
2029
2030int
2031ahd_ovlyrxmsg3_print(u_int regvalue, u_int *cur_col, u_int wrap)
2032{
2033 return (ahd_print_register(OVLYRXMSG3_parse_table, 1, "OVLYRXMSG3",
2034 0x93, regvalue, cur_col, wrap));
2035}
2036
2026static ahd_reg_parse_entry_t CMCRXMSG3_parse_table[] = { 2037static ahd_reg_parse_entry_t CMCRXMSG3_parse_table[] = {
2027 { "MCLASS", 0x0f, 0x0f } 2038 { "MCLASS", 0x0f, 0x0f }
2028}; 2039};
@@ -2051,17 +2062,6 @@ ahd_pcixctl_print(u_int regvalue, u_int *cur_col, u_int wrap)
2051 0x93, regvalue, cur_col, wrap)); 2062 0x93, regvalue, cur_col, wrap));
2052} 2063}
2053 2064
2054static ahd_reg_parse_entry_t OVLYRXMSG3_parse_table[] = {
2055 { "MCLASS", 0x0f, 0x0f }
2056};
2057
2058int
2059ahd_ovlyrxmsg3_print(u_int regvalue, u_int *cur_col, u_int wrap)
2060{
2061 return (ahd_print_register(OVLYRXMSG3_parse_table, 1, "OVLYRXMSG3",
2062 0x93, regvalue, cur_col, wrap));
2063}
2064
2065int 2065int
2066ahd_ovlyseqbcnt_print(u_int regvalue, u_int *cur_col, u_int wrap) 2066ahd_ovlyseqbcnt_print(u_int regvalue, u_int *cur_col, u_int wrap)
2067{ 2067{
@@ -2070,16 +2070,16 @@ ahd_ovlyseqbcnt_print(u_int regvalue, u_int *cur_col, u_int wrap)
2070} 2070}
2071 2071
2072int 2072int
2073ahd_cmcseqbcnt_print(u_int regvalue, u_int *cur_col, u_int wrap) 2073ahd_dchseqbcnt_print(u_int regvalue, u_int *cur_col, u_int wrap)
2074{ 2074{
2075 return (ahd_print_register(NULL, 0, "CMCSEQBCNT", 2075 return (ahd_print_register(NULL, 0, "DCHSEQBCNT",
2076 0x94, regvalue, cur_col, wrap)); 2076 0x94, regvalue, cur_col, wrap));
2077} 2077}
2078 2078
2079int 2079int
2080ahd_dchseqbcnt_print(u_int regvalue, u_int *cur_col, u_int wrap) 2080ahd_cmcseqbcnt_print(u_int regvalue, u_int *cur_col, u_int wrap)
2081{ 2081{
2082 return (ahd_print_register(NULL, 0, "DCHSEQBCNT", 2082 return (ahd_print_register(NULL, 0, "CMCSEQBCNT",
2083 0x94, regvalue, cur_col, wrap)); 2083 0x94, regvalue, cur_col, wrap));
2084} 2084}
2085 2085
@@ -2101,7 +2101,7 @@ ahd_cmcspltstat0_print(u_int regvalue, u_int *cur_col, u_int wrap)
2101 0x96, regvalue, cur_col, wrap)); 2101 0x96, regvalue, cur_col, wrap));
2102} 2102}
2103 2103
2104static ahd_reg_parse_entry_t OVLYSPLTSTAT0_parse_table[] = { 2104static ahd_reg_parse_entry_t DCHSPLTSTAT0_parse_table[] = {
2105 { "RXSPLTRSP", 0x01, 0x01 }, 2105 { "RXSPLTRSP", 0x01, 0x01 },
2106 { "RXSCEMSG", 0x02, 0x02 }, 2106 { "RXSCEMSG", 0x02, 0x02 },
2107 { "RXOVRUN", 0x04, 0x04 }, 2107 { "RXOVRUN", 0x04, 0x04 },
@@ -2113,13 +2113,13 @@ static ahd_reg_parse_entry_t OVLYSPLTSTAT0_parse_table[] = {
2113}; 2113};
2114 2114
2115int 2115int
2116ahd_ovlyspltstat0_print(u_int regvalue, u_int *cur_col, u_int wrap) 2116ahd_dchspltstat0_print(u_int regvalue, u_int *cur_col, u_int wrap)
2117{ 2117{
2118 return (ahd_print_register(OVLYSPLTSTAT0_parse_table, 8, "OVLYSPLTSTAT0", 2118 return (ahd_print_register(DCHSPLTSTAT0_parse_table, 8, "DCHSPLTSTAT0",
2119 0x96, regvalue, cur_col, wrap)); 2119 0x96, regvalue, cur_col, wrap));
2120} 2120}
2121 2121
2122static ahd_reg_parse_entry_t DCHSPLTSTAT0_parse_table[] = { 2122static ahd_reg_parse_entry_t OVLYSPLTSTAT0_parse_table[] = {
2123 { "RXSPLTRSP", 0x01, 0x01 }, 2123 { "RXSPLTRSP", 0x01, 0x01 },
2124 { "RXSCEMSG", 0x02, 0x02 }, 2124 { "RXSCEMSG", 0x02, 0x02 },
2125 { "RXOVRUN", 0x04, 0x04 }, 2125 { "RXOVRUN", 0x04, 0x04 },
@@ -2131,42 +2131,42 @@ static ahd_reg_parse_entry_t DCHSPLTSTAT0_parse_table[] = {
2131}; 2131};
2132 2132
2133int 2133int
2134ahd_dchspltstat0_print(u_int regvalue, u_int *cur_col, u_int wrap) 2134ahd_ovlyspltstat0_print(u_int regvalue, u_int *cur_col, u_int wrap)
2135{ 2135{
2136 return (ahd_print_register(DCHSPLTSTAT0_parse_table, 8, "DCHSPLTSTAT0", 2136 return (ahd_print_register(OVLYSPLTSTAT0_parse_table, 8, "OVLYSPLTSTAT0",
2137 0x96, regvalue, cur_col, wrap)); 2137 0x96, regvalue, cur_col, wrap));
2138} 2138}
2139 2139
2140static ahd_reg_parse_entry_t DCHSPLTSTAT1_parse_table[] = { 2140static ahd_reg_parse_entry_t CMCSPLTSTAT1_parse_table[] = {
2141 { "RXDATABUCKET", 0x01, 0x01 } 2141 { "RXDATABUCKET", 0x01, 0x01 }
2142}; 2142};
2143 2143
2144int 2144int
2145ahd_dchspltstat1_print(u_int regvalue, u_int *cur_col, u_int wrap) 2145ahd_cmcspltstat1_print(u_int regvalue, u_int *cur_col, u_int wrap)
2146{ 2146{
2147 return (ahd_print_register(DCHSPLTSTAT1_parse_table, 1, "DCHSPLTSTAT1", 2147 return (ahd_print_register(CMCSPLTSTAT1_parse_table, 1, "CMCSPLTSTAT1",
2148 0x97, regvalue, cur_col, wrap)); 2148 0x97, regvalue, cur_col, wrap));
2149} 2149}
2150 2150
2151static ahd_reg_parse_entry_t CMCSPLTSTAT1_parse_table[] = { 2151static ahd_reg_parse_entry_t OVLYSPLTSTAT1_parse_table[] = {
2152 { "RXDATABUCKET", 0x01, 0x01 } 2152 { "RXDATABUCKET", 0x01, 0x01 }
2153}; 2153};
2154 2154
2155int 2155int
2156ahd_cmcspltstat1_print(u_int regvalue, u_int *cur_col, u_int wrap) 2156ahd_ovlyspltstat1_print(u_int regvalue, u_int *cur_col, u_int wrap)
2157{ 2157{
2158 return (ahd_print_register(CMCSPLTSTAT1_parse_table, 1, "CMCSPLTSTAT1", 2158 return (ahd_print_register(OVLYSPLTSTAT1_parse_table, 1, "OVLYSPLTSTAT1",
2159 0x97, regvalue, cur_col, wrap)); 2159 0x97, regvalue, cur_col, wrap));
2160} 2160}
2161 2161
2162static ahd_reg_parse_entry_t OVLYSPLTSTAT1_parse_table[] = { 2162static ahd_reg_parse_entry_t DCHSPLTSTAT1_parse_table[] = {
2163 { "RXDATABUCKET", 0x01, 0x01 } 2163 { "RXDATABUCKET", 0x01, 0x01 }
2164}; 2164};
2165 2165
2166int 2166int
2167ahd_ovlyspltstat1_print(u_int regvalue, u_int *cur_col, u_int wrap) 2167ahd_dchspltstat1_print(u_int regvalue, u_int *cur_col, u_int wrap)
2168{ 2168{
2169 return (ahd_print_register(OVLYSPLTSTAT1_parse_table, 1, "OVLYSPLTSTAT1", 2169 return (ahd_print_register(DCHSPLTSTAT1_parse_table, 1, "DCHSPLTSTAT1",
2170 0x97, regvalue, cur_col, wrap)); 2170 0x97, regvalue, cur_col, wrap));
2171} 2171}
2172 2172
@@ -2320,26 +2320,26 @@ ahd_sgspltstat0_print(u_int regvalue, u_int *cur_col, u_int wrap)
2320 0x9e, regvalue, cur_col, wrap)); 2320 0x9e, regvalue, cur_col, wrap));
2321} 2321}
2322 2322
2323static ahd_reg_parse_entry_t SFUNCT_parse_table[] = { 2323static ahd_reg_parse_entry_t SGSPLTSTAT1_parse_table[] = {
2324 { "TEST_NUM", 0x0f, 0x0f }, 2324 { "RXDATABUCKET", 0x01, 0x01 }
2325 { "TEST_GROUP", 0xf0, 0xf0 }
2326}; 2325};
2327 2326
2328int 2327int
2329ahd_sfunct_print(u_int regvalue, u_int *cur_col, u_int wrap) 2328ahd_sgspltstat1_print(u_int regvalue, u_int *cur_col, u_int wrap)
2330{ 2329{
2331 return (ahd_print_register(SFUNCT_parse_table, 2, "SFUNCT", 2330 return (ahd_print_register(SGSPLTSTAT1_parse_table, 1, "SGSPLTSTAT1",
2332 0x9f, regvalue, cur_col, wrap)); 2331 0x9f, regvalue, cur_col, wrap));
2333} 2332}
2334 2333
2335static ahd_reg_parse_entry_t SGSPLTSTAT1_parse_table[] = { 2334static ahd_reg_parse_entry_t SFUNCT_parse_table[] = {
2336 { "RXDATABUCKET", 0x01, 0x01 } 2335 { "TEST_NUM", 0x0f, 0x0f },
2336 { "TEST_GROUP", 0xf0, 0xf0 }
2337}; 2337};
2338 2338
2339int 2339int
2340ahd_sgspltstat1_print(u_int regvalue, u_int *cur_col, u_int wrap) 2340ahd_sfunct_print(u_int regvalue, u_int *cur_col, u_int wrap)
2341{ 2341{
2342 return (ahd_print_register(SGSPLTSTAT1_parse_table, 1, "SGSPLTSTAT1", 2342 return (ahd_print_register(SFUNCT_parse_table, 2, "SFUNCT",
2343 0x9f, regvalue, cur_col, wrap)); 2343 0x9f, regvalue, cur_col, wrap));
2344} 2344}
2345 2345
@@ -2537,16 +2537,16 @@ ahd_ccsgaddr_print(u_int regvalue, u_int *cur_col, u_int wrap)
2537} 2537}
2538 2538
2539int 2539int
2540ahd_ccscbaddr_print(u_int regvalue, u_int *cur_col, u_int wrap) 2540ahd_ccscbadr_bk_print(u_int regvalue, u_int *cur_col, u_int wrap)
2541{ 2541{
2542 return (ahd_print_register(NULL, 0, "CCSCBADDR", 2542 return (ahd_print_register(NULL, 0, "CCSCBADR_BK",
2543 0xac, regvalue, cur_col, wrap)); 2543 0xac, regvalue, cur_col, wrap));
2544} 2544}
2545 2545
2546int 2546int
2547ahd_ccscbadr_bk_print(u_int regvalue, u_int *cur_col, u_int wrap) 2547ahd_ccscbaddr_print(u_int regvalue, u_int *cur_col, u_int wrap)
2548{ 2548{
2549 return (ahd_print_register(NULL, 0, "CCSCBADR_BK", 2549 return (ahd_print_register(NULL, 0, "CCSCBADDR",
2550 0xac, regvalue, cur_col, wrap)); 2550 0xac, regvalue, cur_col, wrap));
2551} 2551}
2552 2552
@@ -2566,22 +2566,6 @@ ahd_cmc_rambist_print(u_int regvalue, u_int *cur_col, u_int wrap)
2566 0xad, regvalue, cur_col, wrap)); 2566 0xad, regvalue, cur_col, wrap));
2567} 2567}
2568 2568
2569static ahd_reg_parse_entry_t CCSGCTL_parse_table[] = {
2570 { "CCSGRESET", 0x01, 0x01 },
2571 { "SG_FETCH_REQ", 0x02, 0x02 },
2572 { "CCSGENACK", 0x08, 0x08 },
2573 { "SG_CACHE_AVAIL", 0x10, 0x10 },
2574 { "CCSGDONE", 0x80, 0x80 },
2575 { "CCSGEN", 0x0c, 0x0c }
2576};
2577
2578int
2579ahd_ccsgctl_print(u_int regvalue, u_int *cur_col, u_int wrap)
2580{
2581 return (ahd_print_register(CCSGCTL_parse_table, 6, "CCSGCTL",
2582 0xad, regvalue, cur_col, wrap));
2583}
2584
2585static ahd_reg_parse_entry_t CCSCBCTL_parse_table[] = { 2569static ahd_reg_parse_entry_t CCSCBCTL_parse_table[] = {
2586 { "CCSCBRESET", 0x01, 0x01 }, 2570 { "CCSCBRESET", 0x01, 0x01 },
2587 { "CCSCBDIR", 0x04, 0x04 }, 2571 { "CCSCBDIR", 0x04, 0x04 },
@@ -2598,6 +2582,22 @@ ahd_ccscbctl_print(u_int regvalue, u_int *cur_col, u_int wrap)
2598 0xad, regvalue, cur_col, wrap)); 2582 0xad, regvalue, cur_col, wrap));
2599} 2583}
2600 2584
2585static ahd_reg_parse_entry_t CCSGCTL_parse_table[] = {
2586 { "CCSGRESET", 0x01, 0x01 },
2587 { "SG_FETCH_REQ", 0x02, 0x02 },
2588 { "CCSGENACK", 0x08, 0x08 },
2589 { "SG_CACHE_AVAIL", 0x10, 0x10 },
2590 { "CCSGDONE", 0x80, 0x80 },
2591 { "CCSGEN", 0x0c, 0x0c }
2592};
2593
2594int
2595ahd_ccsgctl_print(u_int regvalue, u_int *cur_col, u_int wrap)
2596{
2597 return (ahd_print_register(CCSGCTL_parse_table, 6, "CCSGCTL",
2598 0xad, regvalue, cur_col, wrap));
2599}
2600
2601int 2601int
2602ahd_ccsgram_print(u_int regvalue, u_int *cur_col, u_int wrap) 2602ahd_ccsgram_print(u_int regvalue, u_int *cur_col, u_int wrap)
2603{ 2603{
@@ -2841,30 +2841,30 @@ ahd_wrtbiascalc_print(u_int regvalue, u_int *cur_col, u_int wrap)
2841} 2841}
2842 2842
2843int 2843int
2844ahd_dfptrs_print(u_int regvalue, u_int *cur_col, u_int wrap) 2844ahd_rcvrbiascalc_print(u_int regvalue, u_int *cur_col, u_int wrap)
2845{ 2845{
2846 return (ahd_print_register(NULL, 0, "DFPTRS", 2846 return (ahd_print_register(NULL, 0, "RCVRBIASCALC",
2847 0xc8, regvalue, cur_col, wrap)); 2847 0xc8, regvalue, cur_col, wrap));
2848} 2848}
2849 2849
2850int 2850int
2851ahd_rcvrbiascalc_print(u_int regvalue, u_int *cur_col, u_int wrap) 2851ahd_dfptrs_print(u_int regvalue, u_int *cur_col, u_int wrap)
2852{ 2852{
2853 return (ahd_print_register(NULL, 0, "RCVRBIASCALC", 2853 return (ahd_print_register(NULL, 0, "DFPTRS",
2854 0xc8, regvalue, cur_col, wrap)); 2854 0xc8, regvalue, cur_col, wrap));
2855} 2855}
2856 2856
2857int 2857int
2858ahd_dfbkptr_print(u_int regvalue, u_int *cur_col, u_int wrap) 2858ahd_skewcalc_print(u_int regvalue, u_int *cur_col, u_int wrap)
2859{ 2859{
2860 return (ahd_print_register(NULL, 0, "DFBKPTR", 2860 return (ahd_print_register(NULL, 0, "SKEWCALC",
2861 0xc9, regvalue, cur_col, wrap)); 2861 0xc9, regvalue, cur_col, wrap));
2862} 2862}
2863 2863
2864int 2864int
2865ahd_skewcalc_print(u_int regvalue, u_int *cur_col, u_int wrap) 2865ahd_dfbkptr_print(u_int regvalue, u_int *cur_col, u_int wrap)
2866{ 2866{
2867 return (ahd_print_register(NULL, 0, "SKEWCALC", 2867 return (ahd_print_register(NULL, 0, "DFBKPTR",
2868 0xc9, regvalue, cur_col, wrap)); 2868 0xc9, regvalue, cur_col, wrap));
2869} 2869}
2870 2870
@@ -3001,6 +3001,13 @@ ahd_dindex_print(u_int regvalue, u_int *cur_col, u_int wrap)
3001 0xe4, regvalue, cur_col, wrap)); 3001 0xe4, regvalue, cur_col, wrap));
3002} 3002}
3003 3003
3004int
3005ahd_brkaddr0_print(u_int regvalue, u_int *cur_col, u_int wrap)
3006{
3007 return (ahd_print_register(NULL, 0, "BRKADDR0",
3008 0xe6, regvalue, cur_col, wrap));
3009}
3010
3004static ahd_reg_parse_entry_t BRKADDR1_parse_table[] = { 3011static ahd_reg_parse_entry_t BRKADDR1_parse_table[] = {
3005 { "BRKDIS", 0x80, 0x80 } 3012 { "BRKDIS", 0x80, 0x80 }
3006}; 3013};
@@ -3013,13 +3020,6 @@ ahd_brkaddr1_print(u_int regvalue, u_int *cur_col, u_int wrap)
3013} 3020}
3014 3021
3015int 3022int
3016ahd_brkaddr0_print(u_int regvalue, u_int *cur_col, u_int wrap)
3017{
3018 return (ahd_print_register(NULL, 0, "BRKADDR0",
3019 0xe6, regvalue, cur_col, wrap));
3020}
3021
3022int
3023ahd_allones_print(u_int regvalue, u_int *cur_col, u_int wrap) 3023ahd_allones_print(u_int regvalue, u_int *cur_col, u_int wrap)
3024{ 3024{
3025 return (ahd_print_register(NULL, 0, "ALLONES", 3025 return (ahd_print_register(NULL, 0, "ALLONES",
@@ -3069,30 +3069,30 @@ ahd_stack_print(u_int regvalue, u_int *cur_col, u_int wrap)
3069} 3069}
3070 3070
3071int 3071int
3072ahd_curaddr_print(u_int regvalue, u_int *cur_col, u_int wrap) 3072ahd_intvec1_addr_print(u_int regvalue, u_int *cur_col, u_int wrap)
3073{ 3073{
3074 return (ahd_print_register(NULL, 0, "CURADDR", 3074 return (ahd_print_register(NULL, 0, "INTVEC1_ADDR",
3075 0xf4, regvalue, cur_col, wrap)); 3075 0xf4, regvalue, cur_col, wrap));
3076} 3076}
3077 3077
3078int 3078int
3079ahd_intvec1_addr_print(u_int regvalue, u_int *cur_col, u_int wrap) 3079ahd_curaddr_print(u_int regvalue, u_int *cur_col, u_int wrap)
3080{ 3080{
3081 return (ahd_print_register(NULL, 0, "INTVEC1_ADDR", 3081 return (ahd_print_register(NULL, 0, "CURADDR",
3082 0xf4, regvalue, cur_col, wrap)); 3082 0xf4, regvalue, cur_col, wrap));
3083} 3083}
3084 3084
3085int 3085int
3086ahd_intvec2_addr_print(u_int regvalue, u_int *cur_col, u_int wrap) 3086ahd_lastaddr_print(u_int regvalue, u_int *cur_col, u_int wrap)
3087{ 3087{
3088 return (ahd_print_register(NULL, 0, "INTVEC2_ADDR", 3088 return (ahd_print_register(NULL, 0, "LASTADDR",
3089 0xf6, regvalue, cur_col, wrap)); 3089 0xf6, regvalue, cur_col, wrap));
3090} 3090}
3091 3091
3092int 3092int
3093ahd_lastaddr_print(u_int regvalue, u_int *cur_col, u_int wrap) 3093ahd_intvec2_addr_print(u_int regvalue, u_int *cur_col, u_int wrap)
3094{ 3094{
3095 return (ahd_print_register(NULL, 0, "LASTADDR", 3095 return (ahd_print_register(NULL, 0, "INTVEC2_ADDR",
3096 0xf6, regvalue, cur_col, wrap)); 3096 0xf6, regvalue, cur_col, wrap));
3097} 3097}
3098 3098
@@ -3174,24 +3174,45 @@ ahd_complete_dma_scb_head_print(u_int regvalue, u_int *cur_col, u_int wrap)
3174} 3174}
3175 3175
3176int 3176int
3177ahd_complete_dma_scb_tail_print(u_int regvalue, u_int *cur_col, u_int wrap)
3178{
3179 return (ahd_print_register(NULL, 0, "COMPLETE_DMA_SCB_TAIL",
3180 0x12e, regvalue, cur_col, wrap));
3181}
3182
3183int
3184ahd_complete_on_qfreeze_head_print(u_int regvalue, u_int *cur_col, u_int wrap)
3185{
3186 return (ahd_print_register(NULL, 0, "COMPLETE_ON_QFREEZE_HEAD",
3187 0x130, regvalue, cur_col, wrap));
3188}
3189
3190int
3177ahd_qfreeze_count_print(u_int regvalue, u_int *cur_col, u_int wrap) 3191ahd_qfreeze_count_print(u_int regvalue, u_int *cur_col, u_int wrap)
3178{ 3192{
3179 return (ahd_print_register(NULL, 0, "QFREEZE_COUNT", 3193 return (ahd_print_register(NULL, 0, "QFREEZE_COUNT",
3180 0x12e, regvalue, cur_col, wrap)); 3194 0x132, regvalue, cur_col, wrap));
3195}
3196
3197int
3198ahd_kernel_qfreeze_count_print(u_int regvalue, u_int *cur_col, u_int wrap)
3199{
3200 return (ahd_print_register(NULL, 0, "KERNEL_QFREEZE_COUNT",
3201 0x134, regvalue, cur_col, wrap));
3181} 3202}
3182 3203
3183int 3204int
3184ahd_saved_mode_print(u_int regvalue, u_int *cur_col, u_int wrap) 3205ahd_saved_mode_print(u_int regvalue, u_int *cur_col, u_int wrap)
3185{ 3206{
3186 return (ahd_print_register(NULL, 0, "SAVED_MODE", 3207 return (ahd_print_register(NULL, 0, "SAVED_MODE",
3187 0x130, regvalue, cur_col, wrap)); 3208 0x136, regvalue, cur_col, wrap));
3188} 3209}
3189 3210
3190int 3211int
3191ahd_msg_out_print(u_int regvalue, u_int *cur_col, u_int wrap) 3212ahd_msg_out_print(u_int regvalue, u_int *cur_col, u_int wrap)
3192{ 3213{
3193 return (ahd_print_register(NULL, 0, "MSG_OUT", 3214 return (ahd_print_register(NULL, 0, "MSG_OUT",
3194 0x131, regvalue, cur_col, wrap)); 3215 0x137, regvalue, cur_col, wrap));
3195} 3216}
3196 3217
3197static ahd_reg_parse_entry_t DMAPARAMS_parse_table[] = { 3218static ahd_reg_parse_entry_t DMAPARAMS_parse_table[] = {
@@ -3211,7 +3232,7 @@ int
3211ahd_dmaparams_print(u_int regvalue, u_int *cur_col, u_int wrap) 3232ahd_dmaparams_print(u_int regvalue, u_int *cur_col, u_int wrap)
3212{ 3233{
3213 return (ahd_print_register(DMAPARAMS_parse_table, 10, "DMAPARAMS", 3234 return (ahd_print_register(DMAPARAMS_parse_table, 10, "DMAPARAMS",
3214 0x132, regvalue, cur_col, wrap)); 3235 0x138, regvalue, cur_col, wrap));
3215} 3236}
3216 3237
3217static ahd_reg_parse_entry_t SEQ_FLAGS_parse_table[] = { 3238static ahd_reg_parse_entry_t SEQ_FLAGS_parse_table[] = {
@@ -3230,21 +3251,21 @@ int
3230ahd_seq_flags_print(u_int regvalue, u_int *cur_col, u_int wrap) 3251ahd_seq_flags_print(u_int regvalue, u_int *cur_col, u_int wrap)
3231{ 3252{
3232 return (ahd_print_register(SEQ_FLAGS_parse_table, 9, "SEQ_FLAGS", 3253 return (ahd_print_register(SEQ_FLAGS_parse_table, 9, "SEQ_FLAGS",
3233 0x133, regvalue, cur_col, wrap)); 3254 0x139, regvalue, cur_col, wrap));
3234} 3255}
3235 3256
3236int 3257int
3237ahd_saved_scsiid_print(u_int regvalue, u_int *cur_col, u_int wrap) 3258ahd_saved_scsiid_print(u_int regvalue, u_int *cur_col, u_int wrap)
3238{ 3259{
3239 return (ahd_print_register(NULL, 0, "SAVED_SCSIID", 3260 return (ahd_print_register(NULL, 0, "SAVED_SCSIID",
3240 0x134, regvalue, cur_col, wrap)); 3261 0x13a, regvalue, cur_col, wrap));
3241} 3262}
3242 3263
3243int 3264int
3244ahd_saved_lun_print(u_int regvalue, u_int *cur_col, u_int wrap) 3265ahd_saved_lun_print(u_int regvalue, u_int *cur_col, u_int wrap)
3245{ 3266{
3246 return (ahd_print_register(NULL, 0, "SAVED_LUN", 3267 return (ahd_print_register(NULL, 0, "SAVED_LUN",
3247 0x135, regvalue, cur_col, wrap)); 3268 0x13b, regvalue, cur_col, wrap));
3248} 3269}
3249 3270
3250static ahd_reg_parse_entry_t LASTPHASE_parse_table[] = { 3271static ahd_reg_parse_entry_t LASTPHASE_parse_table[] = {
@@ -3267,42 +3288,42 @@ int
3267ahd_lastphase_print(u_int regvalue, u_int *cur_col, u_int wrap) 3288ahd_lastphase_print(u_int regvalue, u_int *cur_col, u_int wrap)
3268{ 3289{
3269 return (ahd_print_register(LASTPHASE_parse_table, 13, "LASTPHASE", 3290 return (ahd_print_register(LASTPHASE_parse_table, 13, "LASTPHASE",
3270 0x136, regvalue, cur_col, wrap)); 3291 0x13c, regvalue, cur_col, wrap));
3271} 3292}
3272 3293
3273int 3294int
3274ahd_qoutfifo_entry_valid_tag_print(u_int regvalue, u_int *cur_col, u_int wrap) 3295ahd_qoutfifo_entry_valid_tag_print(u_int regvalue, u_int *cur_col, u_int wrap)
3275{ 3296{
3276 return (ahd_print_register(NULL, 0, "QOUTFIFO_ENTRY_VALID_TAG", 3297 return (ahd_print_register(NULL, 0, "QOUTFIFO_ENTRY_VALID_TAG",
3277 0x137, regvalue, cur_col, wrap)); 3298 0x13d, regvalue, cur_col, wrap));
3278} 3299}
3279 3300
3280int 3301int
3281ahd_shared_data_addr_print(u_int regvalue, u_int *cur_col, u_int wrap) 3302ahd_kernel_tqinpos_print(u_int regvalue, u_int *cur_col, u_int wrap)
3282{ 3303{
3283 return (ahd_print_register(NULL, 0, "SHARED_DATA_ADDR", 3304 return (ahd_print_register(NULL, 0, "KERNEL_TQINPOS",
3284 0x138, regvalue, cur_col, wrap)); 3305 0x13e, regvalue, cur_col, wrap));
3285} 3306}
3286 3307
3287int 3308int
3288ahd_qoutfifo_next_addr_print(u_int regvalue, u_int *cur_col, u_int wrap) 3309ahd_tqinpos_print(u_int regvalue, u_int *cur_col, u_int wrap)
3289{ 3310{
3290 return (ahd_print_register(NULL, 0, "QOUTFIFO_NEXT_ADDR", 3311 return (ahd_print_register(NULL, 0, "TQINPOS",
3291 0x13c, regvalue, cur_col, wrap)); 3312 0x13f, regvalue, cur_col, wrap));
3292} 3313}
3293 3314
3294int 3315int
3295ahd_kernel_tqinpos_print(u_int regvalue, u_int *cur_col, u_int wrap) 3316ahd_shared_data_addr_print(u_int regvalue, u_int *cur_col, u_int wrap)
3296{ 3317{
3297 return (ahd_print_register(NULL, 0, "KERNEL_TQINPOS", 3318 return (ahd_print_register(NULL, 0, "SHARED_DATA_ADDR",
3298 0x140, regvalue, cur_col, wrap)); 3319 0x140, regvalue, cur_col, wrap));
3299} 3320}
3300 3321
3301int 3322int
3302ahd_tqinpos_print(u_int regvalue, u_int *cur_col, u_int wrap) 3323ahd_qoutfifo_next_addr_print(u_int regvalue, u_int *cur_col, u_int wrap)
3303{ 3324{
3304 return (ahd_print_register(NULL, 0, "TQINPOS", 3325 return (ahd_print_register(NULL, 0, "QOUTFIFO_NEXT_ADDR",
3305 0x141, regvalue, cur_col, wrap)); 3326 0x144, regvalue, cur_col, wrap));
3306} 3327}
3307 3328
3308static ahd_reg_parse_entry_t ARG_1_parse_table[] = { 3329static ahd_reg_parse_entry_t ARG_1_parse_table[] = {
@@ -3320,21 +3341,21 @@ int
3320ahd_arg_1_print(u_int regvalue, u_int *cur_col, u_int wrap) 3341ahd_arg_1_print(u_int regvalue, u_int *cur_col, u_int wrap)
3321{ 3342{
3322 return (ahd_print_register(ARG_1_parse_table, 8, "ARG_1", 3343 return (ahd_print_register(ARG_1_parse_table, 8, "ARG_1",
3323 0x142, regvalue, cur_col, wrap)); 3344 0x148, regvalue, cur_col, wrap));
3324} 3345}
3325 3346
3326int 3347int
3327ahd_arg_2_print(u_int regvalue, u_int *cur_col, u_int wrap) 3348ahd_arg_2_print(u_int regvalue, u_int *cur_col, u_int wrap)
3328{ 3349{
3329 return (ahd_print_register(NULL, 0, "ARG_2", 3350 return (ahd_print_register(NULL, 0, "ARG_2",
3330 0x143, regvalue, cur_col, wrap)); 3351 0x149, regvalue, cur_col, wrap));
3331} 3352}
3332 3353
3333int 3354int
3334ahd_last_msg_print(u_int regvalue, u_int *cur_col, u_int wrap) 3355ahd_last_msg_print(u_int regvalue, u_int *cur_col, u_int wrap)
3335{ 3356{
3336 return (ahd_print_register(NULL, 0, "LAST_MSG", 3357 return (ahd_print_register(NULL, 0, "LAST_MSG",
3337 0x144, regvalue, cur_col, wrap)); 3358 0x14a, regvalue, cur_col, wrap));
3338} 3359}
3339 3360
3340static ahd_reg_parse_entry_t SCSISEQ_TEMPLATE_parse_table[] = { 3361static ahd_reg_parse_entry_t SCSISEQ_TEMPLATE_parse_table[] = {
@@ -3350,14 +3371,14 @@ int
3350ahd_scsiseq_template_print(u_int regvalue, u_int *cur_col, u_int wrap) 3371ahd_scsiseq_template_print(u_int regvalue, u_int *cur_col, u_int wrap)
3351{ 3372{
3352 return (ahd_print_register(SCSISEQ_TEMPLATE_parse_table, 6, "SCSISEQ_TEMPLATE", 3373 return (ahd_print_register(SCSISEQ_TEMPLATE_parse_table, 6, "SCSISEQ_TEMPLATE",
3353 0x145, regvalue, cur_col, wrap)); 3374 0x14b, regvalue, cur_col, wrap));
3354} 3375}
3355 3376
3356int 3377int
3357ahd_initiator_tag_print(u_int regvalue, u_int *cur_col, u_int wrap) 3378ahd_initiator_tag_print(u_int regvalue, u_int *cur_col, u_int wrap)
3358{ 3379{
3359 return (ahd_print_register(NULL, 0, "INITIATOR_TAG", 3380 return (ahd_print_register(NULL, 0, "INITIATOR_TAG",
3360 0x146, regvalue, cur_col, wrap)); 3381 0x14c, regvalue, cur_col, wrap));
3361} 3382}
3362 3383
3363static ahd_reg_parse_entry_t SEQ_FLAGS2_parse_table[] = { 3384static ahd_reg_parse_entry_t SEQ_FLAGS2_parse_table[] = {
@@ -3369,63 +3390,63 @@ int
3369ahd_seq_flags2_print(u_int regvalue, u_int *cur_col, u_int wrap) 3390ahd_seq_flags2_print(u_int regvalue, u_int *cur_col, u_int wrap)
3370{ 3391{
3371 return (ahd_print_register(SEQ_FLAGS2_parse_table, 2, "SEQ_FLAGS2", 3392 return (ahd_print_register(SEQ_FLAGS2_parse_table, 2, "SEQ_FLAGS2",
3372 0x147, regvalue, cur_col, wrap)); 3393 0x14d, regvalue, cur_col, wrap));
3373} 3394}
3374 3395
3375int 3396int
3376ahd_allocfifo_scbptr_print(u_int regvalue, u_int *cur_col, u_int wrap) 3397ahd_allocfifo_scbptr_print(u_int regvalue, u_int *cur_col, u_int wrap)
3377{ 3398{
3378 return (ahd_print_register(NULL, 0, "ALLOCFIFO_SCBPTR", 3399 return (ahd_print_register(NULL, 0, "ALLOCFIFO_SCBPTR",
3379 0x148, regvalue, cur_col, wrap)); 3400 0x14e, regvalue, cur_col, wrap));
3380} 3401}
3381 3402
3382int 3403int
3383ahd_int_coalescing_timer_print(u_int regvalue, u_int *cur_col, u_int wrap) 3404ahd_int_coalescing_timer_print(u_int regvalue, u_int *cur_col, u_int wrap)
3384{ 3405{
3385 return (ahd_print_register(NULL, 0, "INT_COALESCING_TIMER", 3406 return (ahd_print_register(NULL, 0, "INT_COALESCING_TIMER",
3386 0x14a, regvalue, cur_col, wrap)); 3407 0x150, regvalue, cur_col, wrap));
3387} 3408}
3388 3409
3389int 3410int
3390ahd_int_coalescing_maxcmds_print(u_int regvalue, u_int *cur_col, u_int wrap) 3411ahd_int_coalescing_maxcmds_print(u_int regvalue, u_int *cur_col, u_int wrap)
3391{ 3412{
3392 return (ahd_print_register(NULL, 0, "INT_COALESCING_MAXCMDS", 3413 return (ahd_print_register(NULL, 0, "INT_COALESCING_MAXCMDS",
3393 0x14c, regvalue, cur_col, wrap)); 3414 0x152, regvalue, cur_col, wrap));
3394} 3415}
3395 3416
3396int 3417int
3397ahd_int_coalescing_mincmds_print(u_int regvalue, u_int *cur_col, u_int wrap) 3418ahd_int_coalescing_mincmds_print(u_int regvalue, u_int *cur_col, u_int wrap)
3398{ 3419{
3399 return (ahd_print_register(NULL, 0, "INT_COALESCING_MINCMDS", 3420 return (ahd_print_register(NULL, 0, "INT_COALESCING_MINCMDS",
3400 0x14d, regvalue, cur_col, wrap)); 3421 0x153, regvalue, cur_col, wrap));
3401} 3422}
3402 3423
3403int 3424int
3404ahd_cmds_pending_print(u_int regvalue, u_int *cur_col, u_int wrap) 3425ahd_cmds_pending_print(u_int regvalue, u_int *cur_col, u_int wrap)
3405{ 3426{
3406 return (ahd_print_register(NULL, 0, "CMDS_PENDING", 3427 return (ahd_print_register(NULL, 0, "CMDS_PENDING",
3407 0x14e, regvalue, cur_col, wrap)); 3428 0x154, regvalue, cur_col, wrap));
3408} 3429}
3409 3430
3410int 3431int
3411ahd_int_coalescing_cmdcount_print(u_int regvalue, u_int *cur_col, u_int wrap) 3432ahd_int_coalescing_cmdcount_print(u_int regvalue, u_int *cur_col, u_int wrap)
3412{ 3433{
3413 return (ahd_print_register(NULL, 0, "INT_COALESCING_CMDCOUNT", 3434 return (ahd_print_register(NULL, 0, "INT_COALESCING_CMDCOUNT",
3414 0x150, regvalue, cur_col, wrap)); 3435 0x156, regvalue, cur_col, wrap));
3415} 3436}
3416 3437
3417int 3438int
3418ahd_local_hs_mailbox_print(u_int regvalue, u_int *cur_col, u_int wrap) 3439ahd_local_hs_mailbox_print(u_int regvalue, u_int *cur_col, u_int wrap)
3419{ 3440{
3420 return (ahd_print_register(NULL, 0, "LOCAL_HS_MAILBOX", 3441 return (ahd_print_register(NULL, 0, "LOCAL_HS_MAILBOX",
3421 0x151, regvalue, cur_col, wrap)); 3442 0x157, regvalue, cur_col, wrap));
3422} 3443}
3423 3444
3424int 3445int
3425ahd_cmdsize_table_print(u_int regvalue, u_int *cur_col, u_int wrap) 3446ahd_cmdsize_table_print(u_int regvalue, u_int *cur_col, u_int wrap)
3426{ 3447{
3427 return (ahd_print_register(NULL, 0, "CMDSIZE_TABLE", 3448 return (ahd_print_register(NULL, 0, "CMDSIZE_TABLE",
3428 0x152, regvalue, cur_col, wrap)); 3449 0x158, regvalue, cur_col, wrap));
3429} 3450}
3430 3451
3431int 3452int
diff --git a/drivers/scsi/aic7xxx/aic79xx_seq.h_shipped b/drivers/scsi/aic7xxx/aic79xx_seq.h_shipped
index 77c471f934e0..b1e5365be230 100644
--- a/drivers/scsi/aic7xxx/aic79xx_seq.h_shipped
+++ b/drivers/scsi/aic7xxx/aic79xx_seq.h_shipped
@@ -2,215 +2,228 @@
2 * DO NOT EDIT - This file is automatically generated 2 * DO NOT EDIT - This file is automatically generated
3 * from the following source files: 3 * from the following source files:
4 * 4 *
5 * $Id: //depot/aic7xxx/aic7xxx/aic79xx.seq#94 $ 5 * $Id: //depot/aic7xxx/aic7xxx/aic79xx.seq#119 $
6 * $Id: //depot/aic7xxx/aic7xxx/aic79xx.reg#70 $ 6 * $Id: //depot/aic7xxx/aic7xxx/aic79xx.reg#76 $
7 */ 7 */
8static uint8_t seqprog[] = { 8static uint8_t seqprog[] = {
9 0xff, 0x02, 0x06, 0x78, 9 0xff, 0x02, 0x06, 0x78,
10 0x00, 0xea, 0x50, 0x59, 10 0x00, 0xea, 0x64, 0x59,
11 0x01, 0xea, 0x04, 0x30, 11 0x01, 0xea, 0x04, 0x30,
12 0xff, 0x04, 0x0c, 0x78, 12 0xff, 0x04, 0x0c, 0x78,
13 0x19, 0xea, 0x50, 0x59, 13 0x19, 0xea, 0x64, 0x59,
14 0x19, 0xea, 0x04, 0x00, 14 0x19, 0xea, 0x04, 0x00,
15 0x33, 0xea, 0x44, 0x59, 15 0x33, 0xea, 0x5e, 0x59,
16 0x33, 0xea, 0x00, 0x00, 16 0x33, 0xea, 0x00, 0x00,
17 0x60, 0x3a, 0x1a, 0x68, 17 0x60, 0x3a, 0x3a, 0x68,
18 0x04, 0x47, 0x1b, 0x68, 18 0x04, 0x4d, 0x35, 0x78,
19 0xff, 0x21, 0x1b, 0x70, 19 0x01, 0x34, 0xc1, 0x31,
20 0x40, 0x4b, 0x92, 0x69, 20 0x00, 0x32, 0x21, 0x60,
21 0x00, 0xe2, 0x54, 0x59, 21 0x01, 0x35, 0xc1, 0x31,
22 0x40, 0x4b, 0x92, 0x69, 22 0x00, 0x33, 0x21, 0x60,
23 0x20, 0x4b, 0x82, 0x69, 23 0xfb, 0x4d, 0x9b, 0x0a,
24 0xfc, 0x42, 0x24, 0x78, 24 0x00, 0xe2, 0x34, 0x40,
25 0x10, 0x40, 0x24, 0x78, 25 0x50, 0x4b, 0x3a, 0x68,
26 0x00, 0xe2, 0xc4, 0x5d, 26 0xff, 0x31, 0x3b, 0x70,
27 0x20, 0x4d, 0x28, 0x78, 27 0x02, 0x30, 0x51, 0x31,
28 0x00, 0xe2, 0xc4, 0x5d, 28 0xff, 0x8d, 0x2d, 0x70,
29 0x02, 0x8c, 0x51, 0x31,
30 0xff, 0x8d, 0x29, 0x60,
31 0x02, 0x28, 0x19, 0x33,
32 0x02, 0x30, 0x51, 0x32,
33 0xff, 0xea, 0x62, 0x02,
34 0x00, 0xe2, 0x3a, 0x40,
35 0xff, 0x21, 0x3b, 0x70,
36 0x40, 0x4b, 0xaa, 0x69,
37 0x00, 0xe2, 0x68, 0x59,
38 0x40, 0x4b, 0xaa, 0x69,
39 0x20, 0x4b, 0x96, 0x69,
40 0xfc, 0x42, 0x44, 0x78,
41 0x10, 0x40, 0x44, 0x78,
42 0x00, 0xe2, 0xfc, 0x5d,
43 0x20, 0x4d, 0x48, 0x78,
44 0x00, 0xe2, 0xfc, 0x5d,
29 0x30, 0x3f, 0xc0, 0x09, 45 0x30, 0x3f, 0xc0, 0x09,
30 0x30, 0xe0, 0x30, 0x60, 46 0x30, 0xe0, 0x50, 0x60,
31 0x7f, 0x4a, 0x94, 0x08, 47 0x7f, 0x4a, 0x94, 0x08,
32 0x00, 0xe2, 0x32, 0x40, 48 0x00, 0xe2, 0x52, 0x40,
33 0xc0, 0x4a, 0x94, 0x00, 49 0xc0, 0x4a, 0x94, 0x00,
34 0x00, 0xe2, 0x3e, 0x58, 50 0x00, 0xe2, 0x5e, 0x58,
35 0x00, 0xe2, 0x56, 0x58, 51 0x00, 0xe2, 0x76, 0x58,
36 0x00, 0xe2, 0x66, 0x58, 52 0x00, 0xe2, 0x86, 0x58,
37 0x00, 0xe2, 0x06, 0x40, 53 0x00, 0xe2, 0x06, 0x40,
38 0x33, 0xea, 0x44, 0x59, 54 0x33, 0xea, 0x5e, 0x59,
39 0x33, 0xea, 0x00, 0x00, 55 0x33, 0xea, 0x00, 0x00,
40 0x01, 0x52, 0x64, 0x78, 56 0x01, 0x52, 0x84, 0x78,
41 0x02, 0x58, 0x50, 0x31, 57 0x02, 0x58, 0x50, 0x31,
42 0xff, 0xea, 0x10, 0x0b, 58 0xff, 0xea, 0x10, 0x0b,
43 0xff, 0x97, 0x4f, 0x78, 59 0xff, 0x97, 0x6f, 0x78,
44 0x50, 0x4b, 0x4a, 0x68, 60 0x50, 0x4b, 0x6a, 0x68,
45 0xbf, 0x3a, 0x74, 0x08, 61 0xbf, 0x3a, 0x74, 0x08,
46 0x14, 0xea, 0x50, 0x59, 62 0x14, 0xea, 0x64, 0x59,
47 0x14, 0xea, 0x04, 0x00, 63 0x14, 0xea, 0x04, 0x00,
48 0x08, 0x92, 0x25, 0x03, 64 0x08, 0x92, 0x25, 0x03,
49 0xff, 0x90, 0x3f, 0x68, 65 0xff, 0x90, 0x5f, 0x68,
50 0x00, 0xe2, 0x56, 0x5b, 66 0x00, 0xe2, 0x76, 0x5b,
51 0x00, 0xe2, 0x3e, 0x40, 67 0x00, 0xe2, 0x5e, 0x40,
52 0x00, 0xea, 0x44, 0x59, 68 0x00, 0xea, 0x5e, 0x59,
53 0x01, 0xea, 0x00, 0x30, 69 0x01, 0xea, 0x00, 0x30,
54 0x80, 0xf9, 0x5e, 0x68, 70 0x80, 0xf9, 0x7e, 0x68,
55 0x00, 0xe2, 0x42, 0x59, 71 0x00, 0xe2, 0x5c, 0x59,
56 0x11, 0xea, 0x44, 0x59, 72 0x11, 0xea, 0x5e, 0x59,
57 0x11, 0xea, 0x00, 0x00, 73 0x11, 0xea, 0x00, 0x00,
58 0x80, 0xf9, 0x42, 0x79, 74 0x80, 0xf9, 0x5c, 0x79,
59 0xff, 0xea, 0xd4, 0x0d, 75 0xff, 0xea, 0xd4, 0x0d,
60 0x22, 0xea, 0x44, 0x59, 76 0x22, 0xea, 0x5e, 0x59,
61 0x22, 0xea, 0x00, 0x00, 77 0x22, 0xea, 0x00, 0x00,
62 0x10, 0x16, 0x70, 0x78, 78 0x10, 0x16, 0x90, 0x78,
63 0x01, 0x0b, 0xa2, 0x32,
64 0x10, 0x16, 0x2c, 0x00, 79 0x10, 0x16, 0x2c, 0x00,
65 0x18, 0xad, 0x00, 0x79, 80 0x01, 0x0b, 0xae, 0x32,
66 0x04, 0xad, 0xca, 0x68, 81 0x18, 0xad, 0x12, 0x79,
67 0x80, 0xad, 0x64, 0x78, 82 0x04, 0xad, 0xdc, 0x68,
68 0x10, 0xad, 0x98, 0x78, 83 0x80, 0xad, 0x84, 0x78,
69 0xff, 0x88, 0x83, 0x68, 84 0x10, 0xad, 0xaa, 0x78,
70 0xe7, 0xad, 0x5a, 0x09, 85 0xe7, 0xad, 0x5a, 0x09,
71 0x02, 0x8c, 0x59, 0x32, 86 0x02, 0x8c, 0x59, 0x32,
87 0xff, 0x8d, 0xa1, 0x60,
88 0xff, 0xea, 0x5e, 0x02,
89 0xff, 0x88, 0xa7, 0x78,
90 0x02, 0x30, 0x19, 0x33,
91 0x02, 0xa8, 0x60, 0x36,
72 0x02, 0x28, 0x19, 0x33, 92 0x02, 0x28, 0x19, 0x33,
73 0x02, 0xa8, 0x50, 0x36, 93 0x02, 0xa8, 0x50, 0x36,
74 0x33, 0xea, 0x44, 0x59,
75 0x33, 0xea, 0x00, 0x00,
76 0x40, 0x3a, 0x64, 0x68,
77 0x50, 0x4b, 0x64, 0x68,
78 0x22, 0xea, 0x44, 0x59,
79 0x22, 0xea, 0x00, 0x00,
80 0xe7, 0xad, 0x5a, 0x09,
81 0x02, 0x8c, 0x59, 0x32,
82 0x1a, 0xea, 0x50, 0x59,
83 0x1a, 0xea, 0x04, 0x00,
84 0xff, 0xea, 0xd4, 0x0d,
85 0xe7, 0xad, 0x5a, 0x09, 94 0xe7, 0xad, 0x5a, 0x09,
86 0x00, 0xe2, 0xa6, 0x58, 95 0x00, 0xe2, 0xb8, 0x58,
87 0xff, 0xea, 0x56, 0x02, 96 0xff, 0xea, 0x56, 0x02,
88 0x04, 0x7c, 0x78, 0x32, 97 0x04, 0x7c, 0x88, 0x32,
89 0x20, 0x16, 0x64, 0x78, 98 0x20, 0x16, 0x84, 0x78,
90 0x04, 0x38, 0x79, 0x32, 99 0x04, 0x40, 0x89, 0x32,
91 0x80, 0x37, 0x6f, 0x16, 100 0x80, 0x3d, 0x7b, 0x16,
92 0xff, 0x2d, 0xb5, 0x60, 101 0xff, 0x2d, 0xc7, 0x60,
93 0xff, 0x29, 0xb5, 0x60, 102 0xff, 0x29, 0xc7, 0x60,
94 0x40, 0x51, 0xc5, 0x78, 103 0x40, 0x57, 0xd7, 0x78,
95 0xff, 0x4f, 0xb5, 0x68, 104 0xff, 0x55, 0xc7, 0x68,
96 0xff, 0x4d, 0xc1, 0x19, 105 0xff, 0x53, 0xc1, 0x19,
97 0x00, 0x4e, 0xd5, 0x19, 106 0x00, 0x54, 0xd5, 0x19,
98 0x00, 0xe2, 0xc4, 0x50, 107 0x00, 0xe2, 0xd6, 0x50,
99 0x01, 0x4c, 0xc1, 0x31, 108 0x01, 0x52, 0xc1, 0x31,
100 0x00, 0x50, 0xd5, 0x19, 109 0x00, 0x56, 0xd5, 0x19,
101 0x00, 0xe2, 0xc4, 0x48, 110 0x00, 0xe2, 0xd6, 0x48,
102 0x80, 0x18, 0x64, 0x78, 111 0x80, 0x18, 0x84, 0x78,
103 0x02, 0x4a, 0x1d, 0x30, 112 0x02, 0x50, 0x1d, 0x30,
104 0x10, 0xea, 0x18, 0x00, 113 0x10, 0xea, 0x18, 0x00,
105 0x60, 0x18, 0x30, 0x00, 114 0x60, 0x18, 0x30, 0x00,
106 0x7f, 0x18, 0x30, 0x0c, 115 0x7f, 0x18, 0x30, 0x0c,
107 0x02, 0xea, 0x02, 0x00, 116 0x02, 0xea, 0x02, 0x00,
108 0xff, 0xea, 0xa0, 0x0a, 117 0xff, 0xea, 0xac, 0x0a,
109 0x80, 0x18, 0x30, 0x04, 118 0x80, 0x18, 0x30, 0x04,
110 0x40, 0xad, 0x64, 0x78, 119 0x40, 0xad, 0x84, 0x78,
111 0xe7, 0xad, 0x5a, 0x09, 120 0xe7, 0xad, 0x5a, 0x09,
112 0x02, 0xa8, 0x40, 0x31, 121 0x02, 0xa8, 0x40, 0x31,
113 0xff, 0xea, 0xc0, 0x09, 122 0xff, 0xea, 0xc0, 0x09,
114 0x01, 0x4e, 0x9d, 0x1a, 123 0x01, 0x54, 0xa9, 0x1a,
115 0x00, 0x4f, 0x9f, 0x22, 124 0x00, 0x55, 0xab, 0x22,
116 0x01, 0x94, 0x6d, 0x33, 125 0x01, 0x94, 0x6d, 0x33,
117 0x01, 0xea, 0x20, 0x33, 126 0xff, 0xea, 0x20, 0x0b,
118 0x04, 0xac, 0x49, 0x32, 127 0x04, 0xac, 0x49, 0x32,
119 0xff, 0xea, 0x5a, 0x03, 128 0xff, 0xea, 0x5a, 0x03,
120 0xff, 0xea, 0x5e, 0x03, 129 0xff, 0xea, 0x5e, 0x03,
121 0x01, 0x10, 0xd4, 0x31, 130 0x01, 0x10, 0xd4, 0x31,
122 0x10, 0x92, 0xf5, 0x68, 131 0x10, 0x92, 0x07, 0x69,
123 0x3d, 0x93, 0xc5, 0x29, 132 0x3d, 0x93, 0xc5, 0x29,
124 0xfe, 0xe2, 0xc4, 0x09, 133 0xfe, 0xe2, 0xc4, 0x09,
125 0x01, 0xea, 0xc6, 0x01, 134 0x01, 0xea, 0xc6, 0x01,
126 0x02, 0xe2, 0xc8, 0x31, 135 0x02, 0xe2, 0xc8, 0x31,
127 0x02, 0xec, 0x50, 0x31, 136 0x02, 0xec, 0x50, 0x31,
128 0x02, 0xa0, 0xda, 0x31, 137 0x02, 0xa0, 0xda, 0x31,
129 0xff, 0xa9, 0xf4, 0x70, 138 0xff, 0xa9, 0x06, 0x71,
130 0x02, 0xa0, 0x58, 0x37, 139 0x02, 0xa0, 0x58, 0x37,
131 0xff, 0x21, 0xfd, 0x70, 140 0xff, 0x21, 0x0f, 0x71,
132 0x02, 0x22, 0x51, 0x31, 141 0x02, 0x22, 0x51, 0x31,
133 0x02, 0xa0, 0x5c, 0x33, 142 0x02, 0xa0, 0x5c, 0x33,
134 0x02, 0xa0, 0x44, 0x36, 143 0x02, 0xa0, 0x44, 0x36,
135 0x02, 0xa0, 0x40, 0x32, 144 0x02, 0xa0, 0x40, 0x32,
136 0x02, 0xa0, 0x44, 0x36, 145 0x02, 0xa0, 0x44, 0x36,
137 0x04, 0x47, 0x05, 0x69, 146 0x04, 0x4d, 0x17, 0x69,
138 0x40, 0x16, 0x30, 0x69, 147 0x40, 0x16, 0x48, 0x69,
139 0xff, 0x2d, 0x35, 0x61, 148 0xff, 0x2d, 0x4d, 0x61,
140 0xff, 0x29, 0x65, 0x70, 149 0xff, 0x29, 0x85, 0x70,
141 0x01, 0x37, 0xc1, 0x31,
142 0x02, 0x28, 0x55, 0x32, 150 0x02, 0x28, 0x55, 0x32,
143 0x01, 0xea, 0x5a, 0x01, 151 0x01, 0xea, 0x5a, 0x01,
144 0x04, 0x3c, 0xf9, 0x30, 152 0x04, 0x44, 0xf9, 0x30,
153 0x01, 0x44, 0xc1, 0x31,
145 0x02, 0x28, 0x51, 0x31, 154 0x02, 0x28, 0x51, 0x31,
146 0x01, 0xa8, 0x60, 0x31, 155 0x02, 0xa8, 0x60, 0x31,
147 0x00, 0xa9, 0x60, 0x01, 156 0x01, 0xa4, 0x61, 0x31,
157 0x01, 0x3d, 0x61, 0x31,
148 0x01, 0x14, 0xd4, 0x31, 158 0x01, 0x14, 0xd4, 0x31,
149 0x01, 0x50, 0xa1, 0x1a, 159 0x01, 0x56, 0xad, 0x1a,
150 0xff, 0x4e, 0x9d, 0x1a, 160 0xff, 0x54, 0xa9, 0x1a,
151 0xff, 0x4f, 0x9f, 0x22, 161 0xff, 0x55, 0xab, 0x22,
152 0xff, 0x8d, 0x29, 0x71, 162 0xff, 0x8d, 0x41, 0x71,
153 0x80, 0xac, 0x28, 0x71, 163 0x80, 0xac, 0x40, 0x71,
154 0x20, 0x16, 0x28, 0x69, 164 0x20, 0x16, 0x40, 0x69,
165 0x00, 0xac, 0xc4, 0x19,
166 0x07, 0xe2, 0x40, 0xf9,
155 0x02, 0x8c, 0x51, 0x31, 167 0x02, 0x8c, 0x51, 0x31,
156 0x00, 0xe2, 0x12, 0x41, 168 0x00, 0xe2, 0x24, 0x41,
157 0x01, 0xac, 0x08, 0x31, 169 0x01, 0xac, 0x08, 0x31,
158 0x09, 0xea, 0x5a, 0x01, 170 0x09, 0xea, 0x5a, 0x01,
159 0x02, 0x8c, 0x51, 0x32, 171 0x02, 0x8c, 0x51, 0x32,
160 0xff, 0xea, 0x1a, 0x07, 172 0xff, 0xea, 0x1a, 0x07,
161 0x04, 0x24, 0xf9, 0x30, 173 0x04, 0x24, 0xf9, 0x30,
162 0x1d, 0xea, 0x3a, 0x41, 174 0x1d, 0xea, 0x52, 0x41,
163 0x02, 0x2c, 0x51, 0x31, 175 0x02, 0x2c, 0x51, 0x31,
164 0x04, 0xa8, 0xf9, 0x30, 176 0x04, 0xa8, 0xf9, 0x30,
165 0x19, 0xea, 0x3a, 0x41, 177 0x19, 0xea, 0x52, 0x41,
166 0x06, 0xea, 0x08, 0x81, 178 0x06, 0xea, 0x08, 0x81,
167 0x01, 0xe2, 0x5a, 0x35, 179 0x01, 0xe2, 0x5a, 0x35,
168 0x02, 0xf2, 0xf0, 0x35, 180 0x02, 0xf2, 0xf0, 0x31,
181 0xff, 0xea, 0xd4, 0x0d,
169 0x02, 0xf2, 0xf0, 0x31, 182 0x02, 0xf2, 0xf0, 0x31,
170 0x02, 0xf8, 0xe4, 0x35, 183 0x02, 0xf8, 0xe4, 0x35,
171 0x80, 0xea, 0xb2, 0x01, 184 0x80, 0xea, 0xb2, 0x01,
172 0x01, 0xe2, 0x00, 0x30, 185 0x01, 0xe2, 0x00, 0x30,
173 0xff, 0xea, 0xb2, 0x0d, 186 0xff, 0xea, 0xb2, 0x0d,
174 0x80, 0xea, 0xb2, 0x01,
175 0x11, 0x00, 0x00, 0x10,
176 0xff, 0xea, 0xb2, 0x0d,
177 0x01, 0xe2, 0x04, 0x30, 187 0x01, 0xe2, 0x04, 0x30,
178 0x01, 0xea, 0x04, 0x34, 188 0x01, 0xea, 0x04, 0x34,
179 0x02, 0x20, 0xbd, 0x30, 189 0x02, 0x20, 0xbd, 0x30,
180 0x02, 0x20, 0xb9, 0x30, 190 0x02, 0x20, 0xb9, 0x30,
181 0x02, 0x20, 0x51, 0x31, 191 0x02, 0x20, 0x51, 0x31,
182 0x4c, 0x93, 0xd7, 0x28, 192 0x4c, 0x93, 0xd7, 0x28,
183 0x10, 0x92, 0x63, 0x79, 193 0x10, 0x92, 0x77, 0x79,
184 0x01, 0x6b, 0xc0, 0x30, 194 0x01, 0x6b, 0xc0, 0x30,
185 0x02, 0x64, 0xc8, 0x00, 195 0x02, 0x64, 0xc8, 0x00,
186 0x40, 0x3a, 0x74, 0x04, 196 0x40, 0x3a, 0x74, 0x04,
187 0x00, 0xe2, 0x56, 0x58, 197 0x00, 0xe2, 0x76, 0x58,
188 0x33, 0xea, 0x44, 0x59, 198 0x33, 0xea, 0x5e, 0x59,
189 0x33, 0xea, 0x00, 0x00, 199 0x33, 0xea, 0x00, 0x00,
190 0x30, 0x3f, 0xc0, 0x09, 200 0x30, 0x3f, 0xc0, 0x09,
191 0x30, 0xe0, 0x64, 0x61, 201 0x30, 0xe0, 0x78, 0x61,
192 0x20, 0x3f, 0x7a, 0x69, 202 0x20, 0x3f, 0x8e, 0x69,
193 0x10, 0x3f, 0x64, 0x79, 203 0x10, 0x3f, 0x78, 0x79,
194 0x02, 0xea, 0x7e, 0x00, 204 0x02, 0xea, 0x7e, 0x00,
195 0x00, 0xea, 0x44, 0x59, 205 0x00, 0xea, 0x5e, 0x59,
196 0x01, 0xea, 0x00, 0x30, 206 0x01, 0xea, 0x00, 0x30,
197 0x02, 0x48, 0x51, 0x35, 207 0x02, 0x4e, 0x51, 0x35,
198 0x01, 0xea, 0x7e, 0x00, 208 0x01, 0xea, 0x7e, 0x00,
199 0x11, 0xea, 0x44, 0x59, 209 0x11, 0xea, 0x5e, 0x59,
200 0x11, 0xea, 0x00, 0x00, 210 0x11, 0xea, 0x00, 0x00,
201 0x02, 0x48, 0x51, 0x35, 211 0x02, 0x4e, 0x51, 0x35,
212 0xc0, 0x4a, 0x94, 0x00,
213 0x04, 0x41, 0x9c, 0x79,
202 0x08, 0xea, 0x98, 0x00, 214 0x08, 0xea, 0x98, 0x00,
203 0x08, 0x57, 0xae, 0x00, 215 0x08, 0x57, 0xae, 0x00,
204 0x08, 0x3c, 0x78, 0x00, 216 0x08, 0x3c, 0x78, 0x00,
205 0xf0, 0x49, 0x68, 0x0a, 217 0xf0, 0x49, 0x74, 0x0a,
206 0x0f, 0x67, 0xc0, 0x09, 218 0x0f, 0x67, 0xc0, 0x09,
207 0x00, 0x34, 0x69, 0x02, 219 0x00, 0x3a, 0x75, 0x02,
208 0x20, 0xea, 0x96, 0x00, 220 0x20, 0xea, 0x96, 0x00,
209 0x00, 0xe2, 0xf8, 0x41, 221 0x00, 0xe2, 0x14, 0x42,
210 0x40, 0x3a, 0xae, 0x69, 222 0xc0, 0x4a, 0x94, 0x00,
223 0x40, 0x3a, 0xc8, 0x69,
211 0x02, 0x55, 0x06, 0x68, 224 0x02, 0x55, 0x06, 0x68,
212 0x02, 0x56, 0xae, 0x69, 225 0x02, 0x56, 0xc8, 0x69,
213 0xff, 0x5b, 0xae, 0x61, 226 0xff, 0x5b, 0xc8, 0x61,
214 0x02, 0x20, 0x51, 0x31, 227 0x02, 0x20, 0x51, 0x31,
215 0x80, 0xea, 0xb2, 0x01, 228 0x80, 0xea, 0xb2, 0x01,
216 0x44, 0xea, 0x00, 0x00, 229 0x44, 0xea, 0x00, 0x00,
@@ -218,237 +231,246 @@ static uint8_t seqprog[] = {
218 0x33, 0xea, 0x00, 0x00, 231 0x33, 0xea, 0x00, 0x00,
219 0xff, 0xea, 0xb2, 0x09, 232 0xff, 0xea, 0xb2, 0x09,
220 0xff, 0xe0, 0xc0, 0x19, 233 0xff, 0xe0, 0xc0, 0x19,
221 0xff, 0xe0, 0xb0, 0x79, 234 0xff, 0xe0, 0xca, 0x79,
222 0x02, 0xac, 0x51, 0x31, 235 0x02, 0xac, 0x51, 0x31,
223 0x00, 0xe2, 0xa6, 0x41, 236 0x00, 0xe2, 0xc0, 0x41,
224 0x02, 0x5e, 0x50, 0x31, 237 0x02, 0x5e, 0x50, 0x31,
225 0x02, 0xa8, 0xb8, 0x30, 238 0x02, 0xa8, 0xb8, 0x30,
226 0x02, 0x5c, 0x50, 0x31, 239 0x02, 0x5c, 0x50, 0x31,
227 0xff, 0xad, 0xc1, 0x71, 240 0xff, 0xad, 0xdb, 0x71,
228 0x02, 0xac, 0x41, 0x31, 241 0x02, 0xac, 0x41, 0x31,
229 0x02, 0x22, 0x51, 0x31, 242 0x02, 0x22, 0x51, 0x31,
230 0x02, 0xa0, 0x5c, 0x33, 243 0x02, 0xa0, 0x5c, 0x33,
231 0x02, 0xa0, 0x44, 0x32, 244 0x02, 0xa0, 0x44, 0x32,
232 0x00, 0xe2, 0xca, 0x41, 245 0x00, 0xe2, 0xe4, 0x41,
233 0x10, 0x92, 0xcb, 0x69, 246 0x10, 0x92, 0xe5, 0x69,
234 0x3d, 0x93, 0xc9, 0x29, 247 0x3d, 0x93, 0xc9, 0x29,
235 0x01, 0xe4, 0xc8, 0x01, 248 0x01, 0xe4, 0xc8, 0x01,
236 0x01, 0xea, 0xca, 0x01, 249 0x01, 0xea, 0xca, 0x01,
237 0xff, 0xea, 0xda, 0x01, 250 0xff, 0xea, 0xda, 0x01,
238 0x02, 0x20, 0x51, 0x31, 251 0x02, 0x20, 0x51, 0x31,
239 0x02, 0xae, 0x41, 0x32, 252 0x02, 0xae, 0x41, 0x32,
240 0xff, 0x21, 0xd3, 0x61, 253 0xff, 0x21, 0xed, 0x61,
241 0xff, 0xea, 0x46, 0x02, 254 0xff, 0xea, 0x46, 0x02,
242 0x02, 0x5c, 0x50, 0x31, 255 0x02, 0x5c, 0x50, 0x31,
243 0x40, 0xea, 0x96, 0x00, 256 0x40, 0xea, 0x96, 0x00,
244 0x02, 0x56, 0xcc, 0x6d, 257 0x02, 0x56, 0x04, 0x6e,
245 0x01, 0x55, 0xcc, 0x6d, 258 0x01, 0x55, 0x04, 0x6e,
246 0x10, 0x92, 0xdf, 0x79, 259 0x10, 0x92, 0xf9, 0x79,
247 0x10, 0x40, 0xe8, 0x69, 260 0x10, 0x40, 0x02, 0x6a,
248 0x01, 0x56, 0xe8, 0x79, 261 0x01, 0x56, 0x02, 0x7a,
249 0xff, 0x97, 0x07, 0x78, 262 0xff, 0x97, 0x07, 0x78,
250 0x13, 0xea, 0x50, 0x59, 263 0x13, 0xea, 0x64, 0x59,
251 0x13, 0xea, 0x04, 0x00, 264 0x13, 0xea, 0x04, 0x00,
252 0x00, 0xe2, 0x06, 0x40, 265 0x00, 0xe2, 0x06, 0x40,
253 0xbf, 0x3a, 0x74, 0x08, 266 0xbf, 0x3a, 0x74, 0x08,
267 0x04, 0x41, 0x08, 0x7a,
254 0x08, 0xea, 0x98, 0x00, 268 0x08, 0xea, 0x98, 0x00,
255 0x08, 0x57, 0xae, 0x00, 269 0x08, 0x57, 0xae, 0x00,
256 0x01, 0x93, 0x69, 0x32, 270 0x01, 0x93, 0x75, 0x32,
257 0x01, 0x94, 0x6b, 0x32, 271 0x01, 0x94, 0x77, 0x32,
258 0x40, 0xea, 0x66, 0x02, 272 0x40, 0xea, 0x72, 0x02,
259 0x08, 0x3c, 0x78, 0x00, 273 0x08, 0x3c, 0x78, 0x00,
260 0x80, 0xea, 0x62, 0x02, 274 0x80, 0xea, 0x6e, 0x02,
261 0x00, 0xe2, 0xb8, 0x5b, 275 0x00, 0xe2, 0xe2, 0x5b,
262 0x01, 0x36, 0xc1, 0x31, 276 0x01, 0x3c, 0xc1, 0x31,
263 0x9f, 0xe0, 0x4c, 0x7c, 277 0x9f, 0xe0, 0x84, 0x7c,
264 0x80, 0xe0, 0x0c, 0x72, 278 0x80, 0xe0, 0x28, 0x72,
265 0xa0, 0xe0, 0x44, 0x72, 279 0xa0, 0xe0, 0x64, 0x72,
266 0xc0, 0xe0, 0x3a, 0x72, 280 0xc0, 0xe0, 0x5a, 0x72,
267 0xe0, 0xe0, 0x74, 0x72, 281 0xe0, 0xe0, 0x94, 0x72,
268 0x01, 0xea, 0x50, 0x59, 282 0x01, 0xea, 0x64, 0x59,
269 0x01, 0xea, 0x04, 0x00, 283 0x01, 0xea, 0x04, 0x00,
270 0x00, 0xe2, 0xf8, 0x41, 284 0x00, 0xe2, 0x14, 0x42,
271 0x80, 0x33, 0x13, 0x7a, 285 0x80, 0x39, 0x2f, 0x7a,
272 0x03, 0xea, 0x50, 0x59, 286 0x03, 0xea, 0x64, 0x59,
273 0x03, 0xea, 0x04, 0x00, 287 0x03, 0xea, 0x04, 0x00,
274 0xee, 0x00, 0x1a, 0x6a, 288 0xee, 0x00, 0x36, 0x6a,
275 0x05, 0xea, 0xb4, 0x00, 289 0x05, 0xea, 0xb4, 0x00,
276 0x33, 0xea, 0x44, 0x59, 290 0x33, 0xea, 0x5e, 0x59,
277 0x33, 0xea, 0x00, 0x00, 291 0x33, 0xea, 0x00, 0x00,
278 0x02, 0xa8, 0x90, 0x32, 292 0x02, 0xa8, 0x9c, 0x32,
279 0x00, 0xe2, 0x6a, 0x59, 293 0x00, 0xe2, 0x7e, 0x59,
280 0xef, 0x96, 0xd5, 0x19, 294 0xef, 0x96, 0xd5, 0x19,
281 0x00, 0xe2, 0x2a, 0x52, 295 0x00, 0xe2, 0x46, 0x52,
282 0x09, 0x80, 0xe1, 0x30, 296 0x09, 0x80, 0xe1, 0x30,
283 0x02, 0xea, 0x36, 0x00, 297 0x02, 0xea, 0x36, 0x00,
284 0xa8, 0xea, 0x32, 0x00, 298 0xa8, 0xea, 0x32, 0x00,
285 0x00, 0xe2, 0x30, 0x42, 299 0x00, 0xe2, 0x4c, 0x42,
286 0x01, 0x96, 0xd1, 0x30, 300 0x01, 0x96, 0xd1, 0x30,
287 0x10, 0x80, 0x89, 0x31, 301 0x10, 0x80, 0x89, 0x31,
288 0x20, 0xea, 0x32, 0x00, 302 0x20, 0xea, 0x32, 0x00,
289 0xbf, 0x33, 0x67, 0x0a, 303 0xbf, 0x39, 0x73, 0x0a,
290 0x20, 0x19, 0x32, 0x6a, 304 0x10, 0x4c, 0x56, 0x6a,
291 0x02, 0x4d, 0xf8, 0x69, 305 0x20, 0x19, 0x4e, 0x6a,
292 0x40, 0x33, 0x67, 0x02, 306 0x20, 0x19, 0x52, 0x6a,
293 0x00, 0xe2, 0xf8, 0x41, 307 0x02, 0x4d, 0x14, 0x6a,
294 0x80, 0x33, 0xb5, 0x6a, 308 0x40, 0x39, 0x73, 0x02,
309 0x00, 0xe2, 0x14, 0x42,
310 0x80, 0x39, 0xd5, 0x6a,
295 0x01, 0x44, 0x10, 0x33, 311 0x01, 0x44, 0x10, 0x33,
296 0x08, 0x92, 0x25, 0x03, 312 0x08, 0x92, 0x25, 0x03,
297 0x00, 0xe2, 0xf8, 0x41, 313 0x00, 0xe2, 0x14, 0x42,
298 0x10, 0xea, 0x80, 0x00, 314 0x10, 0xea, 0x80, 0x00,
299 0x01, 0x31, 0xc5, 0x31, 315 0x01, 0x37, 0xc5, 0x31,
300 0x80, 0xe2, 0x60, 0x62, 316 0x80, 0xe2, 0x80, 0x62,
301 0x10, 0x92, 0x85, 0x6a, 317 0x10, 0x92, 0xa5, 0x6a,
302 0xc0, 0x94, 0xc5, 0x01, 318 0xc0, 0x94, 0xc5, 0x01,
303 0x40, 0x92, 0x51, 0x6a, 319 0x40, 0x92, 0x71, 0x6a,
304 0xbf, 0xe2, 0xc4, 0x09, 320 0xbf, 0xe2, 0xc4, 0x09,
305 0x20, 0x92, 0x65, 0x7a, 321 0x20, 0x92, 0x85, 0x7a,
306 0x01, 0xe2, 0x88, 0x30, 322 0x01, 0xe2, 0x88, 0x30,
307 0x00, 0xe2, 0xb8, 0x5b, 323 0x00, 0xe2, 0xe2, 0x5b,
308 0xa0, 0x36, 0x6d, 0x62, 324 0xa0, 0x3c, 0x8d, 0x62,
309 0x23, 0x92, 0x89, 0x08, 325 0x23, 0x92, 0x89, 0x08,
310 0x00, 0xe2, 0xb8, 0x5b, 326 0x00, 0xe2, 0xe2, 0x5b,
311 0xa0, 0x36, 0x6d, 0x62, 327 0xa0, 0x3c, 0x8d, 0x62,
312 0x00, 0xa8, 0x64, 0x42, 328 0x00, 0xa8, 0x84, 0x42,
313 0xff, 0xe2, 0x64, 0x62, 329 0xff, 0xe2, 0x84, 0x62,
314 0x00, 0xe2, 0x84, 0x42, 330 0x00, 0xe2, 0xa4, 0x42,
315 0x40, 0xea, 0x98, 0x00, 331 0x40, 0xea, 0x98, 0x00,
316 0x01, 0xe2, 0x88, 0x30, 332 0x01, 0xe2, 0x88, 0x30,
317 0x00, 0xe2, 0xb8, 0x5b, 333 0x00, 0xe2, 0xe2, 0x5b,
318 0xa0, 0x36, 0x43, 0x72, 334 0xa0, 0x3c, 0x63, 0x72,
319 0x40, 0xea, 0x98, 0x00, 335 0x40, 0xea, 0x98, 0x00,
320 0x01, 0x31, 0x89, 0x32, 336 0x01, 0x37, 0x95, 0x32,
321 0x08, 0xea, 0x62, 0x02, 337 0x08, 0xea, 0x6e, 0x02,
322 0x00, 0xe2, 0xf8, 0x41, 338 0x00, 0xe2, 0x14, 0x42,
323 0xe0, 0xea, 0xd4, 0x5b, 339 0xe0, 0xea, 0xfe, 0x5b,
324 0x80, 0xe0, 0xc0, 0x6a, 340 0x80, 0xe0, 0xe0, 0x6a,
325 0x04, 0xe0, 0x66, 0x73, 341 0x04, 0xe0, 0x92, 0x73,
326 0x02, 0xe0, 0x96, 0x73, 342 0x02, 0xe0, 0xc4, 0x73,
327 0x00, 0xea, 0x1e, 0x73, 343 0x00, 0xea, 0x3e, 0x73,
328 0x03, 0xe0, 0xa6, 0x73, 344 0x03, 0xe0, 0xd4, 0x73,
329 0x23, 0xe0, 0x96, 0x72, 345 0x23, 0xe0, 0xb6, 0x72,
330 0x08, 0xe0, 0xbc, 0x72, 346 0x08, 0xe0, 0xdc, 0x72,
331 0x00, 0xe2, 0xb8, 0x5b, 347 0x00, 0xe2, 0xe2, 0x5b,
332 0x07, 0xea, 0x50, 0x59, 348 0x07, 0xea, 0x64, 0x59,
333 0x07, 0xea, 0x04, 0x00, 349 0x07, 0xea, 0x04, 0x00,
334 0x08, 0x42, 0xf9, 0x71, 350 0x08, 0x48, 0x15, 0x72,
335 0x04, 0x42, 0x93, 0x62, 351 0x04, 0x48, 0xb3, 0x62,
336 0x01, 0x43, 0x89, 0x30, 352 0x01, 0x49, 0x89, 0x30,
337 0x00, 0xe2, 0x84, 0x42, 353 0x00, 0xe2, 0xa4, 0x42,
338 0x01, 0x44, 0xd4, 0x31, 354 0x01, 0x44, 0xd4, 0x31,
339 0x00, 0xe2, 0x84, 0x42, 355 0x00, 0xe2, 0xa4, 0x42,
340 0x01, 0x00, 0x60, 0x32, 356 0x01, 0x00, 0x6c, 0x32,
341 0x33, 0xea, 0x44, 0x59, 357 0x33, 0xea, 0x5e, 0x59,
342 0x33, 0xea, 0x00, 0x00, 358 0x33, 0xea, 0x00, 0x00,
343 0x4c, 0x34, 0xc1, 0x28, 359 0x4c, 0x3a, 0xc1, 0x28,
344 0x01, 0x64, 0xc0, 0x31, 360 0x01, 0x64, 0xc0, 0x31,
345 0x00, 0x30, 0x45, 0x59, 361 0x00, 0x36, 0x5f, 0x59,
346 0x01, 0x30, 0x01, 0x30, 362 0x01, 0x36, 0x01, 0x30,
347 0x01, 0xe0, 0xba, 0x7a, 363 0x01, 0xe0, 0xda, 0x7a,
348 0xa0, 0xea, 0xca, 0x5b, 364 0xa0, 0xea, 0xf4, 0x5b,
349 0x01, 0xa0, 0xba, 0x62, 365 0x01, 0xa0, 0xda, 0x62,
350 0x01, 0x84, 0xaf, 0x7a, 366 0x01, 0x84, 0xcf, 0x7a,
351 0x01, 0x95, 0xbd, 0x6a, 367 0x01, 0x95, 0xdd, 0x6a,
352 0x05, 0xea, 0x50, 0x59, 368 0x05, 0xea, 0x64, 0x59,
353 0x05, 0xea, 0x04, 0x00, 369 0x05, 0xea, 0x04, 0x00,
354 0x00, 0xe2, 0xbc, 0x42, 370 0x00, 0xe2, 0xdc, 0x42,
355 0x03, 0xea, 0x50, 0x59, 371 0x03, 0xea, 0x64, 0x59,
356 0x03, 0xea, 0x04, 0x00, 372 0x03, 0xea, 0x04, 0x00,
357 0x00, 0xe2, 0xbc, 0x42, 373 0x00, 0xe2, 0xdc, 0x42,
358 0x07, 0xea, 0xdc, 0x5b, 374 0x07, 0xea, 0x06, 0x5c,
359 0x01, 0x44, 0xd4, 0x31, 375 0x01, 0x44, 0xd4, 0x31,
360 0x00, 0xe2, 0xf8, 0x41, 376 0x00, 0xe2, 0x14, 0x42,
361 0x3f, 0xe0, 0x6a, 0x0a, 377 0x3f, 0xe0, 0x76, 0x0a,
362 0xc0, 0x34, 0xc1, 0x09, 378 0xc0, 0x3a, 0xc1, 0x09,
363 0x00, 0x35, 0x51, 0x01, 379 0x00, 0x3b, 0x51, 0x01,
364 0xff, 0xea, 0x52, 0x09, 380 0xff, 0xea, 0x52, 0x09,
365 0x30, 0x34, 0xc5, 0x09, 381 0x30, 0x3a, 0xc5, 0x09,
366 0x3d, 0xe2, 0xc4, 0x29, 382 0x3d, 0xe2, 0xc4, 0x29,
367 0xb8, 0xe2, 0xc4, 0x19, 383 0xb8, 0xe2, 0xc4, 0x19,
368 0x01, 0xea, 0xc6, 0x01, 384 0x01, 0xea, 0xc6, 0x01,
369 0x02, 0xe2, 0xc8, 0x31, 385 0x02, 0xe2, 0xc8, 0x31,
370 0x02, 0xec, 0x40, 0x31, 386 0x02, 0xec, 0x40, 0x31,
371 0xff, 0xa1, 0xdc, 0x72, 387 0xff, 0xa1, 0xfc, 0x72,
372 0x02, 0xe8, 0xda, 0x31, 388 0x02, 0xe8, 0xda, 0x31,
373 0x02, 0xa0, 0x50, 0x31, 389 0x02, 0xa0, 0x50, 0x31,
374 0x00, 0xe2, 0xfe, 0x42, 390 0x00, 0xe2, 0x1e, 0x43,
375 0x80, 0x33, 0x67, 0x02, 391 0x80, 0x39, 0x73, 0x02,
376 0x01, 0x44, 0xd4, 0x31, 392 0x01, 0x44, 0xd4, 0x31,
377 0x00, 0xe2, 0xb8, 0x5b, 393 0x00, 0xe2, 0xe2, 0x5b,
378 0x01, 0x33, 0x67, 0x02, 394 0x01, 0x39, 0x73, 0x02,
379 0xe0, 0x36, 0x19, 0x63, 395 0xe0, 0x3c, 0x39, 0x63,
380 0x02, 0x33, 0x67, 0x02, 396 0x02, 0x39, 0x73, 0x02,
381 0x20, 0x46, 0x12, 0x63, 397 0x20, 0x46, 0x32, 0x63,
382 0xff, 0xea, 0x52, 0x09, 398 0xff, 0xea, 0x52, 0x09,
383 0xa8, 0xea, 0xca, 0x5b, 399 0xa8, 0xea, 0xf4, 0x5b,
384 0x04, 0x92, 0xf9, 0x7a, 400 0x04, 0x92, 0x19, 0x7b,
385 0x01, 0x34, 0xc1, 0x31, 401 0x01, 0x3a, 0xc1, 0x31,
386 0x00, 0x93, 0xf9, 0x62, 402 0x00, 0x93, 0x19, 0x63,
387 0x01, 0x35, 0xc1, 0x31, 403 0x01, 0x3b, 0xc1, 0x31,
388 0x00, 0x94, 0x03, 0x73, 404 0x00, 0x94, 0x23, 0x73,
389 0x01, 0xa9, 0x52, 0x11, 405 0x01, 0xa9, 0x52, 0x11,
390 0xff, 0xa9, 0xee, 0x6a, 406 0xff, 0xa9, 0x0e, 0x6b,
391 0x00, 0xe2, 0x12, 0x43, 407 0x00, 0xe2, 0x32, 0x43,
392 0x10, 0x33, 0x67, 0x02, 408 0x10, 0x39, 0x73, 0x02,
393 0x04, 0x92, 0x13, 0x7b, 409 0x04, 0x92, 0x33, 0x7b,
394 0xfb, 0x92, 0x25, 0x0b, 410 0xfb, 0x92, 0x25, 0x0b,
395 0xff, 0xea, 0x66, 0x0a, 411 0xff, 0xea, 0x72, 0x0a,
396 0x01, 0xa4, 0x0d, 0x6b, 412 0x01, 0xa4, 0x2d, 0x6b,
397 0x02, 0xa8, 0x90, 0x32, 413 0x02, 0xa8, 0x9c, 0x32,
398 0x00, 0xe2, 0x6a, 0x59, 414 0x00, 0xe2, 0x7e, 0x59,
399 0x10, 0x92, 0xbd, 0x7a, 415 0x10, 0x92, 0xdd, 0x7a,
400 0xff, 0xea, 0xdc, 0x5b, 416 0xff, 0xea, 0x06, 0x5c,
401 0x00, 0xe2, 0xbc, 0x42, 417 0x00, 0xe2, 0xdc, 0x42,
402 0x04, 0xea, 0x50, 0x59, 418 0x04, 0xea, 0x64, 0x59,
403 0x04, 0xea, 0x04, 0x00, 419 0x04, 0xea, 0x04, 0x00,
404 0x00, 0xe2, 0xbc, 0x42, 420 0x00, 0xe2, 0xdc, 0x42,
405 0x04, 0xea, 0x50, 0x59, 421 0x04, 0xea, 0x64, 0x59,
406 0x04, 0xea, 0x04, 0x00, 422 0x04, 0xea, 0x04, 0x00,
407 0x00, 0xe2, 0xf8, 0x41, 423 0x00, 0xe2, 0x14, 0x42,
408 0x08, 0x92, 0xb5, 0x7a, 424 0x08, 0x92, 0xd5, 0x7a,
409 0xc0, 0x33, 0x29, 0x7b, 425 0xc0, 0x39, 0x49, 0x7b,
410 0x80, 0x33, 0xb5, 0x6a, 426 0x80, 0x39, 0xd5, 0x6a,
411 0xff, 0x88, 0x29, 0x6b, 427 0xff, 0x88, 0x49, 0x6b,
412 0x40, 0x33, 0xb5, 0x6a, 428 0x40, 0x39, 0xd5, 0x6a,
413 0x10, 0x92, 0x2f, 0x7b, 429 0x10, 0x92, 0x4f, 0x7b,
414 0x0a, 0xea, 0x50, 0x59, 430 0x0a, 0xea, 0x64, 0x59,
415 0x0a, 0xea, 0x04, 0x00, 431 0x0a, 0xea, 0x04, 0x00,
416 0x00, 0xe2, 0x4e, 0x5b, 432 0x00, 0xe2, 0x6e, 0x5b,
417 0x00, 0xe2, 0x82, 0x43, 433 0x00, 0xe2, 0xae, 0x43,
418 0x50, 0x4b, 0x36, 0x6b, 434 0x50, 0x4b, 0x56, 0x6b,
419 0xbf, 0x3a, 0x74, 0x08, 435 0xbf, 0x3a, 0x74, 0x08,
420 0x01, 0xe0, 0xf4, 0x31, 436 0x01, 0xe0, 0xf4, 0x31,
421 0xff, 0xea, 0xc0, 0x09, 437 0xff, 0xea, 0xc0, 0x09,
422 0x01, 0x2e, 0x5d, 0x1a, 438 0x01, 0x32, 0x65, 0x1a,
423 0x00, 0x2f, 0x5f, 0x22, 439 0x00, 0x33, 0x67, 0x22,
424 0x04, 0x47, 0x8f, 0x02, 440 0x04, 0x4d, 0x9b, 0x02,
425 0x01, 0xfa, 0xc0, 0x35, 441 0x01, 0xfa, 0xc0, 0x35,
426 0x02, 0xa8, 0x84, 0x32, 442 0x02, 0xa8, 0x90, 0x32,
427 0x02, 0xea, 0xb4, 0x00, 443 0x02, 0xea, 0xb4, 0x00,
428 0x33, 0xea, 0x44, 0x59, 444 0x33, 0xea, 0x5e, 0x59,
429 0x33, 0xea, 0x00, 0x00, 445 0x33, 0xea, 0x00, 0x00,
430 0x02, 0x42, 0x51, 0x31, 446 0x02, 0x48, 0x51, 0x31,
431 0xff, 0x90, 0x65, 0x68, 447 0xff, 0x90, 0x85, 0x68,
432 0xff, 0x88, 0x5b, 0x6b, 448 0xff, 0x88, 0x7b, 0x6b,
433 0x01, 0xa4, 0x57, 0x6b, 449 0x01, 0xa4, 0x77, 0x6b,
434 0x02, 0xa4, 0x5f, 0x6b, 450 0x02, 0xa4, 0x7f, 0x6b,
435 0x01, 0x84, 0x5f, 0x7b, 451 0x01, 0x84, 0x7f, 0x7b,
436 0x02, 0x28, 0x19, 0x33, 452 0x02, 0x28, 0x19, 0x33,
437 0x02, 0xa8, 0x50, 0x36, 453 0x02, 0xa8, 0x50, 0x36,
438 0xff, 0x88, 0x5f, 0x73, 454 0xff, 0x88, 0x7f, 0x73,
439 0x00, 0xe2, 0x32, 0x5b, 455 0x00, 0xe2, 0x52, 0x5b,
440 0x02, 0xa8, 0x20, 0x33, 456 0x02, 0xa8, 0x20, 0x33,
441 0x02, 0x2c, 0x19, 0x33, 457 0x04, 0xa4, 0x49, 0x03,
458 0xff, 0xea, 0x1a, 0x03,
459 0xff, 0x2d, 0x8b, 0x63,
442 0x02, 0xa8, 0x58, 0x32, 460 0x02, 0xa8, 0x58, 0x32,
443 0x04, 0xa4, 0x49, 0x07, 461 0x02, 0xa8, 0x5c, 0x36,
444 0xc0, 0x33, 0xb5, 0x6a, 462 0x02, 0xa8, 0x40, 0x31,
463 0x02, 0x2e, 0x51, 0x31,
464 0x02, 0xa0, 0x18, 0x33,
465 0x02, 0xa0, 0x5c, 0x36,
466 0xc0, 0x39, 0xd5, 0x6a,
445 0x04, 0x92, 0x25, 0x03, 467 0x04, 0x92, 0x25, 0x03,
446 0x20, 0x92, 0x83, 0x6b, 468 0x20, 0x92, 0xaf, 0x6b,
447 0x02, 0xa8, 0x40, 0x31, 469 0x02, 0xa8, 0x40, 0x31,
448 0xc0, 0x34, 0xc1, 0x09, 470 0xc0, 0x3a, 0xc1, 0x09,
449 0x00, 0x35, 0x51, 0x01, 471 0x00, 0x3b, 0x51, 0x01,
450 0xff, 0xea, 0x52, 0x09, 472 0xff, 0xea, 0x52, 0x09,
451 0x30, 0x34, 0xc5, 0x09, 473 0x30, 0x3a, 0xc5, 0x09,
452 0x3d, 0xe2, 0xc4, 0x29, 474 0x3d, 0xe2, 0xc4, 0x29,
453 0xb8, 0xe2, 0xc4, 0x19, 475 0xb8, 0xe2, 0xc4, 0x19,
454 0x01, 0xea, 0xc6, 0x01, 476 0x01, 0xea, 0xc6, 0x01,
@@ -458,69 +480,75 @@ static uint8_t seqprog[] = {
458 0xf7, 0x57, 0xae, 0x08, 480 0xf7, 0x57, 0xae, 0x08,
459 0x08, 0xea, 0x98, 0x00, 481 0x08, 0xea, 0x98, 0x00,
460 0x01, 0x44, 0xd4, 0x31, 482 0x01, 0x44, 0xd4, 0x31,
461 0xee, 0x00, 0x8c, 0x6b, 483 0xee, 0x00, 0xb8, 0x6b,
462 0x02, 0xea, 0xb4, 0x00, 484 0x02, 0xea, 0xb4, 0x00,
463 0x00, 0xe2, 0xb4, 0x5b, 485 0xc0, 0xea, 0x72, 0x02,
464 0x09, 0x4c, 0x8e, 0x7b, 486 0x09, 0x4c, 0xba, 0x7b,
487 0x01, 0xea, 0x78, 0x02,
465 0x08, 0x4c, 0x06, 0x68, 488 0x08, 0x4c, 0x06, 0x68,
466 0x0b, 0xea, 0x50, 0x59, 489 0x0b, 0xea, 0x64, 0x59,
467 0x0b, 0xea, 0x04, 0x00, 490 0x0b, 0xea, 0x04, 0x00,
468 0x01, 0x44, 0xd4, 0x31, 491 0x01, 0x44, 0xd4, 0x31,
469 0x20, 0x33, 0xf9, 0x79, 492 0x20, 0x39, 0x15, 0x7a,
470 0x00, 0xe2, 0x9e, 0x5b, 493 0x00, 0xe2, 0xcc, 0x5b,
471 0x00, 0xe2, 0xf8, 0x41, 494 0x00, 0xe2, 0x14, 0x42,
472 0x01, 0x84, 0xa3, 0x7b, 495 0x01, 0x84, 0xd1, 0x7b,
473 0x01, 0xa4, 0x49, 0x07, 496 0x01, 0xa4, 0x49, 0x07,
474 0x08, 0x60, 0x30, 0x33, 497 0x08, 0x60, 0x30, 0x33,
475 0x08, 0x80, 0x41, 0x37, 498 0x08, 0x80, 0x41, 0x37,
476 0xdf, 0x33, 0x67, 0x0a, 499 0xdf, 0x39, 0x73, 0x0a,
477 0xee, 0x00, 0xb0, 0x6b, 500 0xee, 0x00, 0xde, 0x6b,
478 0x05, 0xea, 0xb4, 0x00, 501 0x05, 0xea, 0xb4, 0x00,
479 0x33, 0xea, 0x44, 0x59, 502 0x33, 0xea, 0x5e, 0x59,
480 0x33, 0xea, 0x00, 0x00, 503 0x33, 0xea, 0x00, 0x00,
481 0x00, 0xe2, 0x6a, 0x59, 504 0x00, 0xe2, 0x7e, 0x59,
482 0x00, 0xe2, 0xbc, 0x42, 505 0x00, 0xe2, 0xdc, 0x42,
483 0x01, 0xea, 0x6c, 0x02, 506 0xff, 0x42, 0xee, 0x6b,
484 0xc0, 0xea, 0x66, 0x06, 507 0x01, 0x41, 0xe2, 0x6b,
485 0xff, 0x42, 0xc4, 0x6b, 508 0x02, 0x41, 0xe2, 0x7b,
486 0x01, 0x41, 0xb8, 0x6b, 509 0xff, 0x42, 0xee, 0x6b,
487 0x02, 0x41, 0xb8, 0x7b, 510 0x01, 0x41, 0xe2, 0x6b,
488 0xff, 0x42, 0xc4, 0x6b, 511 0x02, 0x41, 0xe2, 0x7b,
489 0x01, 0x41, 0xb8, 0x6b, 512 0xff, 0x42, 0xee, 0x7b,
490 0x02, 0x41, 0xb8, 0x7b, 513 0x04, 0x4c, 0xe2, 0x6b,
491 0xff, 0x42, 0xc4, 0x7b, 514 0xe0, 0x41, 0x78, 0x0e,
492 0x04, 0x4c, 0xb8, 0x6b,
493 0xe0, 0x41, 0x6c, 0x0e,
494 0x01, 0x44, 0xd4, 0x31, 515 0x01, 0x44, 0xd4, 0x31,
495 0xff, 0x42, 0xcc, 0x7b, 516 0xff, 0x42, 0xf6, 0x7b,
496 0x04, 0x4c, 0xcc, 0x6b, 517 0x04, 0x4c, 0xf6, 0x6b,
497 0xe0, 0x41, 0x6c, 0x0a, 518 0xe0, 0x41, 0x78, 0x0a,
498 0xe0, 0x36, 0xf9, 0x61, 519 0xe0, 0x3c, 0x15, 0x62,
499 0xff, 0xea, 0xca, 0x09, 520 0xff, 0xea, 0xca, 0x09,
500 0x01, 0xe2, 0xc8, 0x31, 521 0x01, 0xe2, 0xc8, 0x31,
501 0x01, 0x46, 0xda, 0x35, 522 0x01, 0x46, 0xda, 0x35,
502 0x01, 0x44, 0xd4, 0x35, 523 0x01, 0x44, 0xd4, 0x35,
503 0x10, 0xea, 0x80, 0x00, 524 0x10, 0xea, 0x80, 0x00,
504 0x01, 0xe2, 0x62, 0x36, 525 0x01, 0xe2, 0x6e, 0x36,
505 0x04, 0xa6, 0xe4, 0x7b, 526 0x04, 0xa6, 0x0e, 0x7c,
506 0xff, 0xea, 0x5a, 0x09, 527 0xff, 0xea, 0x5a, 0x09,
507 0xff, 0xea, 0x4c, 0x0d, 528 0xff, 0xea, 0x4c, 0x0d,
508 0x01, 0xa6, 0x02, 0x6c, 529 0x01, 0xa6, 0x3a, 0x6c,
509 0x10, 0xad, 0x64, 0x78, 530 0x10, 0xad, 0x84, 0x78,
510 0x80, 0xad, 0xfa, 0x6b, 531 0x80, 0xad, 0x32, 0x6c,
511 0x08, 0xad, 0x64, 0x68, 532 0x08, 0xad, 0x84, 0x68,
533 0x20, 0x19, 0x26, 0x7c,
534 0x80, 0xea, 0xb2, 0x01,
535 0x11, 0x00, 0x00, 0x10,
536 0x02, 0xa6, 0x22, 0x7c,
537 0xff, 0xea, 0xb2, 0x0d,
538 0x11, 0x00, 0x00, 0x10,
539 0xff, 0xea, 0xb2, 0x09,
512 0x04, 0x84, 0xf9, 0x30, 540 0x04, 0x84, 0xf9, 0x30,
513 0x00, 0xea, 0x08, 0x81, 541 0x00, 0xea, 0x08, 0x81,
514 0xff, 0xea, 0xd4, 0x09, 542 0xff, 0xea, 0xd4, 0x09,
515 0x02, 0x84, 0xf9, 0x88, 543 0x02, 0x84, 0xf9, 0x88,
516 0x0d, 0xea, 0x5a, 0x01, 544 0x0d, 0xea, 0x5a, 0x01,
517 0x04, 0xa6, 0x4c, 0x05, 545 0x04, 0xa6, 0x4c, 0x05,
518 0x04, 0xa6, 0x64, 0x78, 546 0x04, 0xa6, 0x84, 0x78,
519 0xff, 0xea, 0x5a, 0x09, 547 0xff, 0xea, 0x5a, 0x09,
520 0x03, 0x84, 0x59, 0x89, 548 0x03, 0x84, 0x59, 0x89,
521 0x03, 0xea, 0x4c, 0x01, 549 0x03, 0xea, 0x4c, 0x01,
522 0x80, 0x1a, 0x64, 0x78, 550 0x80, 0x1a, 0x84, 0x78,
523 0x08, 0x19, 0x64, 0x78, 551 0x08, 0x19, 0x84, 0x78,
524 0x08, 0xb0, 0xe0, 0x30, 552 0x08, 0xb0, 0xe0, 0x30,
525 0x04, 0xb0, 0xe0, 0x30, 553 0x04, 0xb0, 0xe0, 0x30,
526 0x03, 0xb0, 0xf0, 0x30, 554 0x03, 0xb0, 0xf0, 0x30,
@@ -533,259 +561,259 @@ static uint8_t seqprog[] = {
533 0x00, 0x86, 0x0d, 0x23, 561 0x00, 0x86, 0x0d, 0x23,
534 0x00, 0x87, 0x0f, 0x23, 562 0x00, 0x87, 0x0f, 0x23,
535 0x01, 0x84, 0xc5, 0x31, 563 0x01, 0x84, 0xc5, 0x31,
536 0x80, 0x83, 0x25, 0x7c, 564 0x80, 0x83, 0x5d, 0x7c,
537 0x02, 0xe2, 0xc4, 0x01, 565 0x02, 0xe2, 0xc4, 0x01,
538 0xff, 0xea, 0x4c, 0x09, 566 0xff, 0xea, 0x4c, 0x09,
539 0x01, 0xe2, 0x36, 0x30, 567 0x01, 0xe2, 0x36, 0x30,
540 0xc8, 0x19, 0x32, 0x00, 568 0xc8, 0x19, 0x32, 0x00,
541 0x88, 0x19, 0x32, 0x00, 569 0x88, 0x19, 0x32, 0x00,
542 0x01, 0xac, 0xd4, 0x99, 570 0x01, 0xac, 0xd4, 0x99,
543 0x00, 0xe2, 0x64, 0x50, 571 0x00, 0xe2, 0x84, 0x50,
544 0xfe, 0xa6, 0x4c, 0x0d, 572 0xfe, 0xa6, 0x4c, 0x0d,
545 0x0b, 0x98, 0xe1, 0x30, 573 0x0b, 0x98, 0xe1, 0x30,
546 0xfd, 0xa4, 0x49, 0x09, 574 0xfd, 0xa4, 0x49, 0x09,
547 0x80, 0xa3, 0x39, 0x7c, 575 0x80, 0xa3, 0x71, 0x7c,
548 0x02, 0xa4, 0x48, 0x01, 576 0x02, 0xa4, 0x48, 0x01,
549 0x01, 0xa4, 0x36, 0x30, 577 0x01, 0xa4, 0x36, 0x30,
550 0xa8, 0xea, 0x32, 0x00, 578 0xa8, 0xea, 0x32, 0x00,
551 0xfd, 0xa4, 0x49, 0x0b, 579 0xfd, 0xa4, 0x49, 0x0b,
552 0x05, 0xa3, 0x07, 0x33, 580 0x05, 0xa3, 0x07, 0x33,
553 0x80, 0x83, 0x45, 0x6c, 581 0x80, 0x83, 0x7d, 0x6c,
554 0x02, 0xea, 0x4c, 0x05, 582 0x02, 0xea, 0x4c, 0x05,
555 0xff, 0xea, 0x4c, 0x0d, 583 0xff, 0xea, 0x4c, 0x0d,
556 0x00, 0xe2, 0x3e, 0x59, 584 0x00, 0xe2, 0x56, 0x59,
557 0x02, 0xa6, 0xe6, 0x6b, 585 0x02, 0xa6, 0x10, 0x6c,
558 0x80, 0xf9, 0xf2, 0x05, 586 0x80, 0xf9, 0xf2, 0x05,
559 0xc0, 0x33, 0x53, 0x7c, 587 0xc0, 0x39, 0x8b, 0x7c,
560 0x03, 0xea, 0x50, 0x59, 588 0x03, 0xea, 0x64, 0x59,
561 0x03, 0xea, 0x04, 0x00, 589 0x03, 0xea, 0x04, 0x00,
562 0x20, 0x33, 0x77, 0x7c, 590 0x20, 0x39, 0xaf, 0x7c,
563 0x01, 0x84, 0x5d, 0x6c, 591 0x01, 0x84, 0x95, 0x6c,
564 0x06, 0xea, 0x50, 0x59, 592 0x06, 0xea, 0x64, 0x59,
565 0x06, 0xea, 0x04, 0x00, 593 0x06, 0xea, 0x04, 0x00,
566 0x00, 0xe2, 0x7a, 0x44, 594 0x00, 0xe2, 0xb2, 0x44,
567 0x01, 0x00, 0x60, 0x32, 595 0x01, 0x00, 0x6c, 0x32,
568 0xee, 0x00, 0x66, 0x6c, 596 0xee, 0x00, 0x9e, 0x6c,
569 0x05, 0xea, 0xb4, 0x00, 597 0x05, 0xea, 0xb4, 0x00,
570 0x33, 0xea, 0x44, 0x59, 598 0x33, 0xea, 0x5e, 0x59,
571 0x33, 0xea, 0x00, 0x00, 599 0x33, 0xea, 0x00, 0x00,
572 0x80, 0x3d, 0x7a, 0x00, 600 0x80, 0x3d, 0x7a, 0x00,
573 0xfc, 0x42, 0x68, 0x7c, 601 0xfc, 0x42, 0xa0, 0x7c,
574 0x7f, 0x3d, 0x7a, 0x08, 602 0x7f, 0x3d, 0x7a, 0x08,
575 0x00, 0x30, 0x45, 0x59, 603 0x00, 0x36, 0x5f, 0x59,
576 0x01, 0x30, 0x01, 0x30, 604 0x01, 0x36, 0x01, 0x30,
577 0x09, 0xea, 0x50, 0x59, 605 0x09, 0xea, 0x64, 0x59,
578 0x09, 0xea, 0x04, 0x00, 606 0x09, 0xea, 0x04, 0x00,
579 0x00, 0xe2, 0xf8, 0x41, 607 0x00, 0xe2, 0x14, 0x42,
580 0x01, 0xa4, 0x5d, 0x6c, 608 0x01, 0xa4, 0x95, 0x6c,
581 0x00, 0xe2, 0x30, 0x5c, 609 0x00, 0xe2, 0x68, 0x5c,
582 0x20, 0x33, 0x67, 0x02, 610 0x20, 0x39, 0x73, 0x02,
583 0x01, 0x00, 0x60, 0x32, 611 0x01, 0x00, 0x6c, 0x32,
584 0x02, 0xa6, 0x82, 0x7c, 612 0x02, 0xa6, 0xba, 0x7c,
585 0x00, 0xe2, 0x46, 0x5c, 613 0x00, 0xe2, 0x7e, 0x5c,
586 0x00, 0xe2, 0x56, 0x58, 614 0x00, 0xe2, 0x76, 0x58,
587 0x00, 0xe2, 0x66, 0x58, 615 0x00, 0xe2, 0x86, 0x58,
588 0x00, 0xe2, 0x3a, 0x58, 616 0x00, 0xe2, 0x5a, 0x58,
589 0x00, 0x30, 0x45, 0x59, 617 0x00, 0x36, 0x5f, 0x59,
590 0x01, 0x30, 0x01, 0x30, 618 0x01, 0x36, 0x01, 0x30,
591 0x20, 0x19, 0x82, 0x6c, 619 0x20, 0x19, 0xba, 0x6c,
592 0x00, 0xe2, 0xb2, 0x5c, 620 0x00, 0xe2, 0xea, 0x5c,
593 0x04, 0x19, 0x9c, 0x6c, 621 0x04, 0x19, 0xd4, 0x6c,
594 0x02, 0x19, 0x32, 0x00, 622 0x02, 0x19, 0x32, 0x00,
595 0x01, 0x84, 0x9d, 0x7c, 623 0x01, 0x84, 0xd5, 0x7c,
596 0x01, 0x1b, 0x96, 0x7c, 624 0x01, 0x1b, 0xce, 0x7c,
597 0x01, 0x1a, 0x9c, 0x6c, 625 0x01, 0x1a, 0xd4, 0x6c,
598 0x00, 0xe2, 0x4c, 0x44, 626 0x00, 0xe2, 0x84, 0x44,
599 0x80, 0x4b, 0xa2, 0x6c, 627 0x80, 0x4b, 0xda, 0x6c,
600 0x01, 0x4c, 0x9e, 0x7c, 628 0x01, 0x4c, 0xd6, 0x7c,
601 0x03, 0x42, 0x4c, 0x6c, 629 0x03, 0x42, 0x84, 0x6c,
602 0x00, 0xe2, 0xe0, 0x5b, 630 0x00, 0xe2, 0x0a, 0x5c,
603 0x80, 0xf9, 0xf2, 0x01, 631 0x80, 0xf9, 0xf2, 0x01,
604 0x04, 0x33, 0xf9, 0x79, 632 0x04, 0x39, 0x15, 0x7a,
605 0x00, 0xe2, 0xf8, 0x41, 633 0x00, 0xe2, 0x14, 0x42,
606 0x08, 0x5d, 0xba, 0x6c, 634 0x08, 0x5d, 0xf2, 0x6c,
607 0x00, 0xe2, 0x56, 0x58, 635 0x00, 0xe2, 0x76, 0x58,
608 0x00, 0x30, 0x45, 0x59, 636 0x00, 0x36, 0x5f, 0x59,
609 0x01, 0x30, 0x01, 0x30, 637 0x01, 0x36, 0x01, 0x30,
610 0x02, 0x1b, 0xaa, 0x7c, 638 0x02, 0x1b, 0xe2, 0x7c,
611 0x08, 0x5d, 0xb8, 0x7c, 639 0x08, 0x5d, 0xf0, 0x7c,
612 0x03, 0x68, 0x00, 0x37, 640 0x03, 0x68, 0x00, 0x37,
613 0x01, 0x84, 0x09, 0x07, 641 0x01, 0x84, 0x09, 0x07,
614 0x80, 0x1b, 0xc4, 0x7c, 642 0x80, 0x1b, 0xfc, 0x7c,
615 0x80, 0x84, 0xc5, 0x6c, 643 0x80, 0x84, 0xfd, 0x6c,
616 0xff, 0x85, 0x0b, 0x1b, 644 0xff, 0x85, 0x0b, 0x1b,
617 0xff, 0x86, 0x0d, 0x23, 645 0xff, 0x86, 0x0d, 0x23,
618 0xff, 0x87, 0x0f, 0x23, 646 0xff, 0x87, 0x0f, 0x23,
619 0xf8, 0x1b, 0x08, 0x0b, 647 0xf8, 0x1b, 0x08, 0x0b,
620 0xff, 0xea, 0x06, 0x0b, 648 0xff, 0xea, 0x06, 0x0b,
621 0x03, 0x68, 0x00, 0x37, 649 0x03, 0x68, 0x00, 0x37,
622 0x00, 0xe2, 0xc4, 0x58, 650 0x00, 0xe2, 0xd6, 0x58,
623 0x10, 0xea, 0x18, 0x00, 651 0x10, 0xea, 0x18, 0x00,
624 0xf9, 0xd9, 0xb2, 0x0d, 652 0xf9, 0xd9, 0xb2, 0x0d,
625 0x01, 0xd9, 0xb2, 0x05, 653 0x01, 0xd9, 0xb2, 0x05,
626 0x01, 0x52, 0x48, 0x31, 654 0x01, 0x52, 0x48, 0x31,
627 0x20, 0xa4, 0xee, 0x7c, 655 0x20, 0xa4, 0x26, 0x7d,
628 0x20, 0x5b, 0xee, 0x7c, 656 0x20, 0x5b, 0x26, 0x7d,
629 0x80, 0xf9, 0xfc, 0x7c, 657 0x80, 0xf9, 0x34, 0x7d,
630 0x02, 0xea, 0xb4, 0x00, 658 0x02, 0xea, 0xb4, 0x00,
631 0x11, 0x00, 0x00, 0x10, 659 0x11, 0x00, 0x00, 0x10,
632 0x04, 0x19, 0x08, 0x7d, 660 0x04, 0x19, 0x40, 0x7d,
633 0xdf, 0x19, 0x32, 0x08, 661 0xdf, 0x19, 0x32, 0x08,
634 0x60, 0x5b, 0xe6, 0x6c, 662 0x60, 0x5b, 0x40, 0x6d,
635 0x01, 0x4c, 0xe2, 0x7c, 663 0x01, 0x4c, 0x1a, 0x7d,
636 0x20, 0x19, 0x32, 0x00, 664 0x20, 0x19, 0x32, 0x00,
637 0x01, 0xd9, 0xb2, 0x05, 665 0x01, 0xd9, 0xb2, 0x05,
638 0x02, 0xea, 0xb4, 0x00, 666 0x02, 0xea, 0xb4, 0x00,
639 0x01, 0xd9, 0xb2, 0x05, 667 0x01, 0xd9, 0xb2, 0x05,
640 0x10, 0x5b, 0x00, 0x6d, 668 0x10, 0x5b, 0x38, 0x6d,
641 0x08, 0x5b, 0x0a, 0x6d, 669 0x08, 0x5b, 0x42, 0x6d,
642 0x20, 0x5b, 0xfa, 0x6c, 670 0x20, 0x5b, 0x32, 0x6d,
643 0x02, 0x5b, 0x2a, 0x6d, 671 0x02, 0x5b, 0x62, 0x6d,
644 0x0e, 0xea, 0x50, 0x59, 672 0x0e, 0xea, 0x64, 0x59,
645 0x0e, 0xea, 0x04, 0x00, 673 0x0e, 0xea, 0x04, 0x00,
646 0x80, 0xf9, 0xea, 0x6c, 674 0x80, 0xf9, 0x22, 0x6d,
647 0xdf, 0x5c, 0xb8, 0x08, 675 0xdf, 0x5c, 0xb8, 0x08,
648 0x01, 0xd9, 0xb2, 0x05, 676 0x01, 0xd9, 0xb2, 0x05,
649 0x01, 0xa4, 0xe5, 0x6d, 677 0x01, 0xa4, 0x1d, 0x6e,
650 0x00, 0xe2, 0x30, 0x5c, 678 0x00, 0xe2, 0x68, 0x5c,
651 0x00, 0xe2, 0x34, 0x5d, 679 0x00, 0xe2, 0x6c, 0x5d,
652 0x01, 0x90, 0x21, 0x1b, 680 0x01, 0x90, 0x21, 0x1b,
653 0x01, 0xd9, 0xb2, 0x05, 681 0x01, 0xd9, 0xb2, 0x05,
654 0x00, 0xe2, 0x32, 0x5b, 682 0x00, 0xe2, 0x52, 0x5b,
655 0xf3, 0x96, 0xd5, 0x19, 683 0xf3, 0x96, 0xd5, 0x19,
656 0x00, 0xe2, 0x18, 0x55, 684 0x00, 0xe2, 0x50, 0x55,
657 0x80, 0x96, 0x19, 0x6d, 685 0x80, 0x96, 0x51, 0x6d,
658 0x0f, 0xea, 0x50, 0x59, 686 0x0f, 0xea, 0x64, 0x59,
659 0x0f, 0xea, 0x04, 0x00, 687 0x0f, 0xea, 0x04, 0x00,
660 0x00, 0xe2, 0x20, 0x45, 688 0x00, 0xe2, 0x58, 0x45,
661 0x04, 0x8c, 0xe1, 0x30, 689 0x04, 0x8c, 0xe1, 0x30,
662 0x01, 0xea, 0xf2, 0x00, 690 0x01, 0xea, 0xf2, 0x00,
663 0x02, 0xea, 0x36, 0x00, 691 0x02, 0xea, 0x36, 0x00,
664 0xa8, 0xea, 0x32, 0x00, 692 0xa8, 0xea, 0x32, 0x00,
665 0xff, 0x97, 0x27, 0x7d, 693 0xff, 0x97, 0x5f, 0x7d,
666 0x14, 0xea, 0x50, 0x59, 694 0x14, 0xea, 0x64, 0x59,
667 0x14, 0xea, 0x04, 0x00, 695 0x14, 0xea, 0x04, 0x00,
668 0x00, 0xe2, 0x96, 0x5d, 696 0x00, 0xe2, 0xce, 0x5d,
669 0x01, 0xd9, 0xb2, 0x05, 697 0x01, 0xd9, 0xb2, 0x05,
670 0x09, 0x80, 0xe1, 0x30, 698 0x09, 0x80, 0xe1, 0x30,
671 0x02, 0xea, 0x36, 0x00, 699 0x02, 0xea, 0x36, 0x00,
672 0xa8, 0xea, 0x32, 0x00, 700 0xa8, 0xea, 0x32, 0x00,
673 0x00, 0xe2, 0x8e, 0x5d, 701 0x00, 0xe2, 0xc6, 0x5d,
674 0x01, 0xd9, 0xb2, 0x05, 702 0x01, 0xd9, 0xb2, 0x05,
675 0x02, 0xa6, 0x44, 0x7d, 703 0x02, 0xa6, 0x7c, 0x7d,
676 0x00, 0xe2, 0x3e, 0x59, 704 0x00, 0xe2, 0x56, 0x59,
677 0x20, 0x5b, 0x52, 0x6d, 705 0x20, 0x5b, 0x8a, 0x6d,
678 0xfc, 0x42, 0x3e, 0x7d, 706 0xfc, 0x42, 0x76, 0x7d,
679 0x10, 0x40, 0x40, 0x6d, 707 0x10, 0x40, 0x78, 0x6d,
680 0x20, 0x4d, 0x42, 0x7d, 708 0x20, 0x4d, 0x7a, 0x7d,
681 0x08, 0x5d, 0x52, 0x6d, 709 0x08, 0x5d, 0x8a, 0x6d,
682 0x02, 0xa6, 0xe6, 0x6b, 710 0x02, 0xa6, 0x10, 0x6c,
683 0x00, 0xe2, 0x3e, 0x59, 711 0x00, 0xe2, 0x56, 0x59,
684 0x20, 0x5b, 0x52, 0x6d, 712 0x20, 0x5b, 0x8a, 0x6d,
685 0x01, 0x1b, 0x72, 0x6d, 713 0x01, 0x1b, 0xaa, 0x6d,
686 0xfc, 0x42, 0x4e, 0x7d, 714 0xfc, 0x42, 0x86, 0x7d,
687 0x10, 0x40, 0x50, 0x6d, 715 0x10, 0x40, 0x88, 0x6d,
688 0x20, 0x4d, 0x64, 0x78, 716 0x20, 0x4d, 0x84, 0x78,
689 0x08, 0x5d, 0x64, 0x78, 717 0x08, 0x5d, 0x84, 0x78,
690 0x02, 0x19, 0x32, 0x00, 718 0x02, 0x19, 0x32, 0x00,
691 0x01, 0x5b, 0x40, 0x31, 719 0x01, 0x5b, 0x40, 0x31,
692 0x00, 0xe2, 0xb2, 0x5c, 720 0x00, 0xe2, 0xea, 0x5c,
693 0x00, 0xe2, 0x9e, 0x5b, 721 0x00, 0xe2, 0xcc, 0x5b,
694 0x20, 0xea, 0xb6, 0x00, 722 0x20, 0xea, 0xb6, 0x00,
695 0x00, 0xe2, 0xe0, 0x5b, 723 0x00, 0xe2, 0x0a, 0x5c,
696 0x20, 0x5c, 0xb8, 0x00, 724 0x20, 0x5c, 0xb8, 0x00,
697 0x04, 0x19, 0x68, 0x6d, 725 0x04, 0x19, 0xa0, 0x6d,
698 0x01, 0x1a, 0x68, 0x6d, 726 0x01, 0x1a, 0xa0, 0x6d,
699 0x00, 0xe2, 0x3e, 0x59, 727 0x00, 0xe2, 0x56, 0x59,
700 0x01, 0x1a, 0x64, 0x78, 728 0x01, 0x1a, 0x84, 0x78,
701 0x80, 0xf9, 0xf2, 0x01, 729 0x80, 0xf9, 0xf2, 0x01,
702 0x20, 0xa0, 0xcc, 0x7d, 730 0x20, 0xa0, 0x04, 0x7e,
703 0xff, 0x90, 0x21, 0x1b, 731 0xff, 0x90, 0x21, 0x1b,
704 0x08, 0x92, 0x43, 0x6b, 732 0x08, 0x92, 0x63, 0x6b,
705 0x02, 0xea, 0xb4, 0x04, 733 0x02, 0xea, 0xb4, 0x04,
706 0x01, 0xa4, 0x49, 0x03, 734 0x01, 0xa4, 0x49, 0x03,
707 0x40, 0x5b, 0x82, 0x6d, 735 0x40, 0x5b, 0xba, 0x6d,
708 0x00, 0xe2, 0x3e, 0x59, 736 0x00, 0xe2, 0x56, 0x59,
709 0x40, 0x5b, 0x82, 0x6d, 737 0x40, 0x5b, 0xba, 0x6d,
710 0x04, 0x5d, 0xe6, 0x7d, 738 0x04, 0x5d, 0x1e, 0x7e,
711 0x01, 0x1a, 0xe6, 0x7d, 739 0x01, 0x1a, 0x1e, 0x7e,
712 0x20, 0x4d, 0x64, 0x78, 740 0x20, 0x4d, 0x84, 0x78,
713 0x40, 0x5b, 0xcc, 0x7d, 741 0x40, 0x5b, 0x04, 0x7e,
714 0x04, 0x5d, 0xe6, 0x7d, 742 0x04, 0x5d, 0x1e, 0x7e,
715 0x01, 0x1a, 0xe6, 0x7d, 743 0x01, 0x1a, 0x1e, 0x7e,
716 0x80, 0xf9, 0xf2, 0x01, 744 0x80, 0xf9, 0xf2, 0x01,
717 0xff, 0x90, 0x21, 0x1b, 745 0xff, 0x90, 0x21, 0x1b,
718 0x08, 0x92, 0x43, 0x6b, 746 0x08, 0x92, 0x63, 0x6b,
719 0x02, 0xea, 0xb4, 0x04, 747 0x02, 0xea, 0xb4, 0x04,
720 0x00, 0xe2, 0x3e, 0x59, 748 0x00, 0xe2, 0x56, 0x59,
721 0x01, 0x1b, 0x64, 0x78, 749 0x01, 0x1b, 0x84, 0x78,
722 0x80, 0xf9, 0xf2, 0x01, 750 0x80, 0xf9, 0xf2, 0x01,
723 0x02, 0xea, 0xb4, 0x04, 751 0x02, 0xea, 0xb4, 0x04,
724 0x00, 0xe2, 0x3e, 0x59, 752 0x00, 0xe2, 0x56, 0x59,
725 0x01, 0x1b, 0xaa, 0x6d, 753 0x01, 0x1b, 0xe2, 0x6d,
726 0x40, 0x5b, 0xb8, 0x7d, 754 0x40, 0x5b, 0xf0, 0x7d,
727 0x01, 0x1b, 0xaa, 0x6d, 755 0x01, 0x1b, 0xe2, 0x6d,
728 0x02, 0x19, 0x32, 0x00, 756 0x02, 0x19, 0x32, 0x00,
729 0x01, 0x1a, 0x64, 0x78, 757 0x01, 0x1a, 0x84, 0x78,
730 0x80, 0xf9, 0xf2, 0x01, 758 0x80, 0xf9, 0xf2, 0x01,
731 0xff, 0xea, 0x10, 0x03, 759 0xff, 0xea, 0x10, 0x03,
732 0x08, 0x92, 0x25, 0x03, 760 0x08, 0x92, 0x25, 0x03,
733 0x00, 0xe2, 0x42, 0x43, 761 0x00, 0xe2, 0x62, 0x43,
734 0x01, 0x1a, 0xb4, 0x7d, 762 0x01, 0x1a, 0xec, 0x7d,
735 0x40, 0x5b, 0xb0, 0x7d, 763 0x40, 0x5b, 0xe8, 0x7d,
736 0x01, 0x1a, 0x9e, 0x6d, 764 0x01, 0x1a, 0xd6, 0x6d,
737 0xfc, 0x42, 0x64, 0x78, 765 0xfc, 0x42, 0x84, 0x78,
738 0x01, 0x1a, 0xb8, 0x6d, 766 0x01, 0x1a, 0xf0, 0x6d,
739 0x10, 0xea, 0x50, 0x59, 767 0x10, 0xea, 0x64, 0x59,
740 0x10, 0xea, 0x04, 0x00, 768 0x10, 0xea, 0x04, 0x00,
741 0xfc, 0x42, 0x64, 0x78, 769 0xfc, 0x42, 0x84, 0x78,
742 0x10, 0x40, 0xbe, 0x6d, 770 0x10, 0x40, 0xf6, 0x6d,
743 0x20, 0x4d, 0x64, 0x78, 771 0x20, 0x4d, 0x84, 0x78,
744 0x40, 0x5b, 0x9e, 0x6d, 772 0x40, 0x5b, 0xd6, 0x6d,
745 0x01, 0x1a, 0x64, 0x78, 773 0x01, 0x1a, 0x84, 0x78,
746 0x01, 0x90, 0x21, 0x1b, 774 0x01, 0x90, 0x21, 0x1b,
747 0x30, 0x3f, 0xc0, 0x09, 775 0x30, 0x3f, 0xc0, 0x09,
748 0x30, 0xe0, 0x64, 0x60, 776 0x30, 0xe0, 0x84, 0x60,
749 0x40, 0x4b, 0x64, 0x68, 777 0x40, 0x4b, 0x84, 0x68,
750 0xff, 0xea, 0x52, 0x01, 778 0xff, 0xea, 0x52, 0x01,
751 0xee, 0x00, 0xd2, 0x6d, 779 0xee, 0x00, 0x0c, 0x6e,
752 0x80, 0xf9, 0xf2, 0x01, 780 0x80, 0xf9, 0xf2, 0x01,
753 0xff, 0x90, 0x21, 0x1b, 781 0xff, 0x90, 0x21, 0x1b,
754 0x02, 0xea, 0xb4, 0x00, 782 0x02, 0xea, 0xb4, 0x00,
755 0x20, 0xea, 0x9a, 0x00, 783 0x20, 0xea, 0x9a, 0x00,
756 0xf3, 0x42, 0xde, 0x6d, 784 0xf3, 0x42, 0x16, 0x6e,
757 0x12, 0xea, 0x50, 0x59, 785 0x12, 0xea, 0x64, 0x59,
758 0x12, 0xea, 0x04, 0x00, 786 0x12, 0xea, 0x04, 0x00,
759 0x00, 0xe2, 0xf8, 0x41, 787 0x00, 0xe2, 0x14, 0x42,
760 0x0d, 0xea, 0x50, 0x59, 788 0x0d, 0xea, 0x64, 0x59,
761 0x0d, 0xea, 0x04, 0x00, 789 0x0d, 0xea, 0x04, 0x00,
762 0x00, 0xe2, 0xf8, 0x41, 790 0x00, 0xe2, 0x14, 0x42,
763 0x01, 0x90, 0x21, 0x1b, 791 0x01, 0x90, 0x21, 0x1b,
764 0x11, 0xea, 0x50, 0x59, 792 0x11, 0xea, 0x64, 0x59,
765 0x11, 0xea, 0x04, 0x00, 793 0x11, 0xea, 0x04, 0x00,
766 0x00, 0xe2, 0x32, 0x5b, 794 0x00, 0xe2, 0x52, 0x5b,
767 0x08, 0x5a, 0xb4, 0x00, 795 0x08, 0x5a, 0xb4, 0x00,
768 0x00, 0xe2, 0x0c, 0x5e, 796 0x00, 0xe2, 0x44, 0x5e,
769 0xa8, 0xea, 0x32, 0x00, 797 0xa8, 0xea, 0x32, 0x00,
770 0x00, 0xe2, 0x3e, 0x59, 798 0x00, 0xe2, 0x56, 0x59,
771 0x80, 0x1a, 0xfa, 0x7d, 799 0x80, 0x1a, 0x32, 0x7e,
772 0x00, 0xe2, 0x0c, 0x5e, 800 0x00, 0xe2, 0x44, 0x5e,
773 0x80, 0x19, 0x32, 0x00, 801 0x80, 0x19, 0x32, 0x00,
774 0x40, 0x5b, 0x00, 0x6e, 802 0x40, 0x5b, 0x38, 0x6e,
775 0x08, 0x5a, 0x00, 0x7e, 803 0x08, 0x5a, 0x38, 0x7e,
776 0x20, 0x4d, 0x64, 0x78, 804 0x20, 0x4d, 0x84, 0x78,
777 0x02, 0x84, 0x09, 0x03, 805 0x02, 0x84, 0x09, 0x03,
778 0x40, 0x5b, 0xcc, 0x7d, 806 0x40, 0x5b, 0x04, 0x7e,
779 0xff, 0x90, 0x21, 0x1b, 807 0xff, 0x90, 0x21, 0x1b,
780 0x80, 0xf9, 0xf2, 0x01, 808 0x80, 0xf9, 0xf2, 0x01,
781 0x08, 0x92, 0x43, 0x6b, 809 0x08, 0x92, 0x63, 0x6b,
782 0x02, 0xea, 0xb4, 0x04, 810 0x02, 0xea, 0xb4, 0x04,
783 0x01, 0x38, 0xe1, 0x30, 811 0x01, 0x40, 0xe1, 0x30,
784 0x05, 0x39, 0xe3, 0x98, 812 0x05, 0x41, 0xe3, 0x98,
785 0x01, 0xe0, 0xf4, 0x31, 813 0x01, 0xe0, 0xf4, 0x31,
786 0xff, 0xea, 0xc0, 0x09, 814 0xff, 0xea, 0xc0, 0x09,
787 0x00, 0x3a, 0xe5, 0x20, 815 0x00, 0x42, 0xe5, 0x20,
788 0x00, 0x3b, 0xe7, 0x20, 816 0x00, 0x43, 0xe7, 0x20,
789 0x01, 0xfa, 0xc0, 0x31, 817 0x01, 0xfa, 0xc0, 0x31,
790 0x04, 0xea, 0xe8, 0x30, 818 0x04, 0xea, 0xe8, 0x30,
791 0xff, 0xea, 0xf0, 0x08, 819 0xff, 0xea, 0xf0, 0x08,
@@ -794,12 +822,20 @@ static uint8_t seqprog[] = {
794}; 822};
795 823
796typedef int ahd_patch_func_t (struct ahd_softc *ahd); 824typedef int ahd_patch_func_t (struct ahd_softc *ahd);
825static ahd_patch_func_t ahd_patch23_func;
826
827static int
828ahd_patch23_func(struct ahd_softc *ahd)
829{
830 return ((ahd->bugs & AHD_PKT_BITBUCKET_BUG) != 0);
831}
832
797static ahd_patch_func_t ahd_patch22_func; 833static ahd_patch_func_t ahd_patch22_func;
798 834
799static int 835static int
800ahd_patch22_func(struct ahd_softc *ahd) 836ahd_patch22_func(struct ahd_softc *ahd)
801{ 837{
802 return ((ahd->bugs & AHD_PKT_BITBUCKET_BUG) != 0); 838 return ((ahd->bugs & AHD_PKT_BITBUCKET_BUG) == 0);
803} 839}
804 840
805static ahd_patch_func_t ahd_patch21_func; 841static ahd_patch_func_t ahd_patch21_func;
@@ -807,7 +843,7 @@ static ahd_patch_func_t ahd_patch21_func;
807static int 843static int
808ahd_patch21_func(struct ahd_softc *ahd) 844ahd_patch21_func(struct ahd_softc *ahd)
809{ 845{
810 return ((ahd->bugs & AHD_PKT_BITBUCKET_BUG) == 0); 846 return ((ahd->flags & AHD_INITIATORROLE) != 0);
811} 847}
812 848
813static ahd_patch_func_t ahd_patch20_func; 849static ahd_patch_func_t ahd_patch20_func;
@@ -815,7 +851,7 @@ static ahd_patch_func_t ahd_patch20_func;
815static int 851static int
816ahd_patch20_func(struct ahd_softc *ahd) 852ahd_patch20_func(struct ahd_softc *ahd)
817{ 853{
818 return ((ahd->features & AHD_RTI) == 0); 854 return ((ahd->flags & AHD_TARGETROLE) != 0);
819} 855}
820 856
821static ahd_patch_func_t ahd_patch19_func; 857static ahd_patch_func_t ahd_patch19_func;
@@ -823,7 +859,7 @@ static ahd_patch_func_t ahd_patch19_func;
823static int 859static int
824ahd_patch19_func(struct ahd_softc *ahd) 860ahd_patch19_func(struct ahd_softc *ahd)
825{ 861{
826 return ((ahd->flags & AHD_INITIATORROLE) != 0); 862 return ((ahd->bugs & AHD_AUTOFLUSH_BUG) != 0);
827} 863}
828 864
829static ahd_patch_func_t ahd_patch18_func; 865static ahd_patch_func_t ahd_patch18_func;
@@ -831,7 +867,7 @@ static ahd_patch_func_t ahd_patch18_func;
831static int 867static int
832ahd_patch18_func(struct ahd_softc *ahd) 868ahd_patch18_func(struct ahd_softc *ahd)
833{ 869{
834 return ((ahd->flags & AHD_TARGETROLE) != 0); 870 return ((ahd->features & AHD_NEW_DFCNTRL_OPTS) != 0);
835} 871}
836 872
837static ahd_patch_func_t ahd_patch17_func; 873static ahd_patch_func_t ahd_patch17_func;
@@ -839,7 +875,7 @@ static ahd_patch_func_t ahd_patch17_func;
839static int 875static int
840ahd_patch17_func(struct ahd_softc *ahd) 876ahd_patch17_func(struct ahd_softc *ahd)
841{ 877{
842 return ((ahd->bugs & AHD_AUTOFLUSH_BUG) != 0); 878 return ((ahd->flags & AHD_39BIT_ADDRESSING) != 0);
843} 879}
844 880
845static ahd_patch_func_t ahd_patch16_func; 881static ahd_patch_func_t ahd_patch16_func;
@@ -847,7 +883,7 @@ static ahd_patch_func_t ahd_patch16_func;
847static int 883static int
848ahd_patch16_func(struct ahd_softc *ahd) 884ahd_patch16_func(struct ahd_softc *ahd)
849{ 885{
850 return ((ahd->features & AHD_NEW_DFCNTRL_OPTS) != 0); 886 return ((ahd->flags & AHD_64BIT_ADDRESSING) != 0);
851} 887}
852 888
853static ahd_patch_func_t ahd_patch15_func; 889static ahd_patch_func_t ahd_patch15_func;
@@ -855,7 +891,7 @@ static ahd_patch_func_t ahd_patch15_func;
855static int 891static int
856ahd_patch15_func(struct ahd_softc *ahd) 892ahd_patch15_func(struct ahd_softc *ahd)
857{ 893{
858 return ((ahd->flags & AHD_39BIT_ADDRESSING) != 0); 894 return ((ahd->features & AHD_NEW_DFCNTRL_OPTS) == 0);
859} 895}
860 896
861static ahd_patch_func_t ahd_patch14_func; 897static ahd_patch_func_t ahd_patch14_func;
@@ -863,7 +899,7 @@ static ahd_patch_func_t ahd_patch14_func;
863static int 899static int
864ahd_patch14_func(struct ahd_softc *ahd) 900ahd_patch14_func(struct ahd_softc *ahd)
865{ 901{
866 return ((ahd->flags & AHD_64BIT_ADDRESSING) != 0); 902 return ((ahd->bugs & AHD_REG_SLOW_SETTLE_BUG) != 0);
867} 903}
868 904
869static ahd_patch_func_t ahd_patch13_func; 905static ahd_patch_func_t ahd_patch13_func;
@@ -871,7 +907,7 @@ static ahd_patch_func_t ahd_patch13_func;
871static int 907static int
872ahd_patch13_func(struct ahd_softc *ahd) 908ahd_patch13_func(struct ahd_softc *ahd)
873{ 909{
874 return ((ahd->features & AHD_NEW_DFCNTRL_OPTS) == 0); 910 return ((ahd->features & AHD_RTI) == 0);
875} 911}
876 912
877static ahd_patch_func_t ahd_patch12_func; 913static ahd_patch_func_t ahd_patch12_func;
@@ -879,7 +915,7 @@ static ahd_patch_func_t ahd_patch12_func;
879static int 915static int
880ahd_patch12_func(struct ahd_softc *ahd) 916ahd_patch12_func(struct ahd_softc *ahd)
881{ 917{
882 return ((ahd->bugs & AHD_REG_SLOW_SETTLE_BUG) != 0); 918 return ((ahd->bugs & AHD_EARLY_REQ_BUG) != 0);
883} 919}
884 920
885static ahd_patch_func_t ahd_patch11_func; 921static ahd_patch_func_t ahd_patch11_func;
@@ -887,7 +923,7 @@ static ahd_patch_func_t ahd_patch11_func;
887static int 923static int
888ahd_patch11_func(struct ahd_softc *ahd) 924ahd_patch11_func(struct ahd_softc *ahd)
889{ 925{
890 return ((ahd->bugs & AHD_EARLY_REQ_BUG) != 0); 926 return ((ahd->bugs & AHD_BUSFREEREV_BUG) == 0);
891} 927}
892 928
893static ahd_patch_func_t ahd_patch10_func; 929static ahd_patch_func_t ahd_patch10_func;
@@ -895,7 +931,7 @@ static ahd_patch_func_t ahd_patch10_func;
895static int 931static int
896ahd_patch10_func(struct ahd_softc *ahd) 932ahd_patch10_func(struct ahd_softc *ahd)
897{ 933{
898 return ((ahd->bugs & AHD_BUSFREEREV_BUG) == 0); 934 return ((ahd->flags & AHD_SEQUENCER_DEBUG) != 0);
899} 935}
900 936
901static ahd_patch_func_t ahd_patch9_func; 937static ahd_patch_func_t ahd_patch9_func;
@@ -903,7 +939,7 @@ static ahd_patch_func_t ahd_patch9_func;
903static int 939static int
904ahd_patch9_func(struct ahd_softc *ahd) 940ahd_patch9_func(struct ahd_softc *ahd)
905{ 941{
906 return ((ahd->flags & AHD_SEQUENCER_DEBUG) != 0); 942 return ((ahd->features & AHD_FAST_CDB_DELIVERY) != 0);
907} 943}
908 944
909static ahd_patch_func_t ahd_patch8_func; 945static ahd_patch_func_t ahd_patch8_func;
@@ -992,147 +1028,149 @@ static struct patch {
992 { ahd_patch0_func, 5, 1, 1 }, 1028 { ahd_patch0_func, 5, 1, 1 },
993 { ahd_patch2_func, 6, 1, 2 }, 1029 { ahd_patch2_func, 6, 1, 2 },
994 { ahd_patch0_func, 7, 1, 1 }, 1030 { ahd_patch0_func, 7, 1, 1 },
995 { ahd_patch3_func, 20, 5, 1 }, 1031 { ahd_patch3_func, 36, 5, 1 },
996 { ahd_patch2_func, 29, 1, 2 }, 1032 { ahd_patch2_func, 45, 1, 2 },
997 { ahd_patch0_func, 30, 1, 1 }, 1033 { ahd_patch0_func, 46, 1, 1 },
998 { ahd_patch1_func, 37, 1, 2 }, 1034 { ahd_patch1_func, 53, 1, 2 },
999 { ahd_patch0_func, 38, 1, 1 }, 1035 { ahd_patch0_func, 54, 1, 1 },
1000 { ahd_patch2_func, 43, 1, 2 }, 1036 { ahd_patch2_func, 59, 1, 2 },
1001 { ahd_patch0_func, 44, 1, 1 }, 1037 { ahd_patch0_func, 60, 1, 1 },
1002 { ahd_patch2_func, 47, 1, 2 }, 1038 { ahd_patch2_func, 63, 1, 2 },
1003 { ahd_patch0_func, 48, 1, 1 }, 1039 { ahd_patch0_func, 64, 1, 1 },
1004 { ahd_patch2_func, 51, 1, 2 }, 1040 { ahd_patch2_func, 67, 1, 2 },
1005 { ahd_patch0_func, 52, 1, 1 }, 1041 { ahd_patch0_func, 68, 1, 1 },
1006 { ahd_patch2_func, 65, 1, 2 }, 1042 { ahd_patch4_func, 116, 1, 1 },
1007 { ahd_patch0_func, 66, 1, 1 }, 1043 { ahd_patch2_func, 175, 3, 1 },
1008 { ahd_patch2_func, 69, 1, 2 }, 1044 { ahd_patch1_func, 178, 2, 1 },
1009 { ahd_patch0_func, 70, 1, 1 }, 1045 { ahd_patch5_func, 180, 1, 1 },
1010 { ahd_patch1_func, 73, 1, 2 }, 1046 { ahd_patch2_func, 189, 1, 2 },
1011 { ahd_patch0_func, 74, 1, 1 }, 1047 { ahd_patch0_func, 190, 1, 1 },
1012 { ahd_patch4_func, 107, 1, 1 }, 1048 { ahd_patch6_func, 191, 2, 2 },
1013 { ahd_patch2_func, 162, 6, 1 }, 1049 { ahd_patch0_func, 193, 6, 3 },
1014 { ahd_patch1_func, 168, 2, 1 }, 1050 { ahd_patch2_func, 196, 1, 2 },
1015 { ahd_patch5_func, 170, 1, 1 }, 1051 { ahd_patch0_func, 197, 1, 1 },
1016 { ahd_patch2_func, 179, 1, 2 }, 1052 { ahd_patch2_func, 200, 1, 2 },
1017 { ahd_patch0_func, 180, 1, 1 }, 1053 { ahd_patch0_func, 201, 1, 1 },
1018 { ahd_patch6_func, 181, 2, 2 }, 1054 { ahd_patch3_func, 203, 1, 1 },
1019 { ahd_patch0_func, 183, 6, 3 }, 1055 { ahd_patch7_func, 204, 3, 1 },
1020 { ahd_patch2_func, 186, 1, 2 }, 1056 { ahd_patch3_func, 213, 1, 1 },
1021 { ahd_patch0_func, 187, 1, 1 }, 1057 { ahd_patch5_func, 214, 16, 2 },
1022 { ahd_patch2_func, 190, 1, 2 }, 1058 { ahd_patch0_func, 230, 1, 1 },
1023 { ahd_patch0_func, 191, 1, 1 }, 1059 { ahd_patch8_func, 250, 2, 1 },
1024 { ahd_patch7_func, 193, 2, 1 }, 1060 { ahd_patch1_func, 254, 1, 2 },
1025 { ahd_patch5_func, 201, 16, 2 }, 1061 { ahd_patch0_func, 255, 1, 1 },
1026 { ahd_patch0_func, 217, 1, 1 }, 1062 { ahd_patch7_func, 258, 3, 1 },
1027 { ahd_patch8_func, 237, 2, 1 }, 1063 { ahd_patch1_func, 273, 1, 2 },
1028 { ahd_patch1_func, 241, 1, 2 }, 1064 { ahd_patch0_func, 274, 1, 1 },
1029 { ahd_patch0_func, 242, 1, 1 }, 1065 { ahd_patch1_func, 277, 1, 2 },
1030 { ahd_patch7_func, 245, 2, 1 }, 1066 { ahd_patch0_func, 278, 1, 1 },
1031 { ahd_patch1_func, 259, 1, 2 }, 1067 { ahd_patch2_func, 281, 1, 2 },
1032 { ahd_patch0_func, 260, 1, 1 }, 1068 { ahd_patch0_func, 282, 1, 1 },
1033 { ahd_patch1_func, 263, 1, 2 }, 1069 { ahd_patch9_func, 295, 2, 2 },
1034 { ahd_patch0_func, 264, 1, 1 }, 1070 { ahd_patch0_func, 297, 1, 1 },
1035 { ahd_patch2_func, 267, 1, 2 }, 1071 { ahd_patch1_func, 339, 1, 2 },
1036 { ahd_patch0_func, 268, 1, 1 }, 1072 { ahd_patch0_func, 340, 1, 1 },
1037 { ahd_patch1_func, 323, 1, 2 }, 1073 { ahd_patch2_func, 348, 1, 2 },
1038 { ahd_patch0_func, 324, 1, 1 }, 1074 { ahd_patch0_func, 349, 1, 1 },
1039 { ahd_patch2_func, 332, 1, 2 }, 1075 { ahd_patch2_func, 352, 1, 2 },
1040 { ahd_patch0_func, 333, 1, 1 }, 1076 { ahd_patch0_func, 353, 1, 1 },
1041 { ahd_patch2_func, 336, 1, 2 }, 1077 { ahd_patch1_func, 359, 1, 2 },
1042 { ahd_patch0_func, 337, 1, 1 }, 1078 { ahd_patch0_func, 360, 1, 1 },
1043 { ahd_patch1_func, 343, 1, 2 }, 1079 { ahd_patch1_func, 362, 1, 2 },
1044 { ahd_patch0_func, 344, 1, 1 }, 1080 { ahd_patch0_func, 363, 1, 1 },
1045 { ahd_patch1_func, 346, 1, 2 }, 1081 { ahd_patch10_func, 382, 1, 1 },
1046 { ahd_patch0_func, 347, 1, 1 }, 1082 { ahd_patch10_func, 385, 1, 1 },
1047 { ahd_patch9_func, 366, 1, 1 }, 1083 { ahd_patch10_func, 387, 1, 1 },
1048 { ahd_patch9_func, 369, 1, 1 }, 1084 { ahd_patch10_func, 399, 1, 1 },
1049 { ahd_patch9_func, 371, 1, 1 }, 1085 { ahd_patch1_func, 409, 1, 2 },
1050 { ahd_patch9_func, 383, 1, 1 }, 1086 { ahd_patch0_func, 410, 1, 1 },
1051 { ahd_patch1_func, 393, 1, 2 }, 1087 { ahd_patch1_func, 412, 1, 2 },
1052 { ahd_patch0_func, 394, 1, 1 }, 1088 { ahd_patch0_func, 413, 1, 1 },
1053 { ahd_patch1_func, 396, 1, 2 }, 1089 { ahd_patch1_func, 421, 1, 2 },
1054 { ahd_patch0_func, 397, 1, 1 }, 1090 { ahd_patch0_func, 422, 1, 1 },
1055 { ahd_patch1_func, 405, 1, 2 }, 1091 { ahd_patch2_func, 435, 1, 2 },
1056 { ahd_patch0_func, 406, 1, 1 }, 1092 { ahd_patch0_func, 436, 1, 1 },
1057 { ahd_patch2_func, 419, 1, 2 }, 1093 { ahd_patch11_func, 472, 1, 1 },
1058 { ahd_patch0_func, 420, 1, 1 }, 1094 { ahd_patch1_func, 480, 1, 2 },
1059 { ahd_patch10_func, 450, 1, 1 }, 1095 { ahd_patch0_func, 481, 1, 1 },
1060 { ahd_patch1_func, 457, 1, 2 }, 1096 { ahd_patch2_func, 493, 1, 2 },
1061 { ahd_patch0_func, 458, 1, 1 }, 1097 { ahd_patch0_func, 494, 1, 1 },
1062 { ahd_patch2_func, 470, 1, 2 }, 1098 { ahd_patch12_func, 497, 6, 2 },
1063 { ahd_patch0_func, 471, 1, 1 }, 1099 { ahd_patch0_func, 503, 1, 1 },
1064 { ahd_patch11_func, 476, 6, 2 }, 1100 { ahd_patch13_func, 524, 7, 1 },
1065 { ahd_patch0_func, 482, 1, 1 }, 1101 { ahd_patch14_func, 533, 1, 1 },
1066 { ahd_patch12_func, 505, 1, 1 }, 1102 { ahd_patch15_func, 542, 1, 1 },
1067 { ahd_patch13_func, 514, 1, 1 }, 1103 { ahd_patch16_func, 543, 1, 2 },
1068 { ahd_patch14_func, 515, 1, 2 }, 1104 { ahd_patch0_func, 544, 1, 1 },
1069 { ahd_patch0_func, 516, 1, 1 }, 1105 { ahd_patch17_func, 547, 1, 1 },
1070 { ahd_patch15_func, 519, 1, 1 }, 1106 { ahd_patch16_func, 548, 1, 1 },
1071 { ahd_patch14_func, 520, 1, 1 }, 1107 { ahd_patch18_func, 559, 1, 2 },
1072 { ahd_patch16_func, 531, 1, 2 }, 1108 { ahd_patch0_func, 560, 1, 1 },
1073 { ahd_patch0_func, 532, 1, 1 }, 1109 { ahd_patch1_func, 579, 1, 2 },
1074 { ahd_patch1_func, 551, 1, 2 }, 1110 { ahd_patch0_func, 580, 1, 1 },
1075 { ahd_patch0_func, 552, 1, 1 }, 1111 { ahd_patch1_func, 583, 1, 2 },
1076 { ahd_patch1_func, 555, 1, 2 }, 1112 { ahd_patch0_func, 584, 1, 1 },
1077 { ahd_patch0_func, 556, 1, 1 }, 1113 { ahd_patch2_func, 589, 1, 2 },
1078 { ahd_patch2_func, 561, 1, 2 }, 1114 { ahd_patch0_func, 590, 1, 1 },
1079 { ahd_patch0_func, 562, 1, 1 }, 1115 { ahd_patch2_func, 594, 1, 2 },
1080 { ahd_patch2_func, 566, 1, 2 }, 1116 { ahd_patch0_func, 595, 1, 1 },
1081 { ahd_patch0_func, 567, 1, 1 }, 1117 { ahd_patch1_func, 596, 1, 2 },
1082 { ahd_patch1_func, 568, 1, 2 }, 1118 { ahd_patch0_func, 597, 1, 1 },
1083 { ahd_patch0_func, 569, 1, 1 }, 1119 { ahd_patch2_func, 608, 1, 2 },
1084 { ahd_patch2_func, 580, 1, 2 }, 1120 { ahd_patch0_func, 609, 1, 1 },
1085 { ahd_patch0_func, 581, 1, 1 }, 1121 { ahd_patch19_func, 613, 1, 1 },
1086 { ahd_patch17_func, 585, 1, 1 }, 1122 { ahd_patch20_func, 618, 1, 1 },
1087 { ahd_patch18_func, 590, 1, 1 }, 1123 { ahd_patch21_func, 619, 2, 1 },
1088 { ahd_patch19_func, 591, 2, 1 }, 1124 { ahd_patch20_func, 623, 1, 2 },
1089 { ahd_patch18_func, 595, 1, 2 }, 1125 { ahd_patch0_func, 624, 1, 1 },
1090 { ahd_patch0_func, 596, 1, 1 }, 1126 { ahd_patch2_func, 627, 1, 2 },
1091 { ahd_patch2_func, 599, 1, 2 }, 1127 { ahd_patch0_func, 628, 1, 1 },
1092 { ahd_patch0_func, 600, 1, 1 }, 1128 { ahd_patch2_func, 643, 1, 2 },
1093 { ahd_patch2_func, 615, 1, 2 }, 1129 { ahd_patch0_func, 644, 1, 1 },
1094 { ahd_patch0_func, 616, 1, 1 }, 1130 { ahd_patch13_func, 645, 14, 1 },
1095 { ahd_patch20_func, 617, 14, 1 }, 1131 { ahd_patch1_func, 663, 1, 2 },
1096 { ahd_patch1_func, 635, 1, 2 }, 1132 { ahd_patch0_func, 664, 1, 1 },
1097 { ahd_patch0_func, 636, 1, 1 }, 1133 { ahd_patch13_func, 665, 1, 1 },
1098 { ahd_patch20_func, 637, 1, 1 }, 1134 { ahd_patch1_func, 677, 1, 2 },
1099 { ahd_patch1_func, 649, 1, 2 }, 1135 { ahd_patch0_func, 678, 1, 1 },
1100 { ahd_patch0_func, 650, 1, 1 }, 1136 { ahd_patch1_func, 685, 1, 2 },
1101 { ahd_patch1_func, 657, 1, 2 }, 1137 { ahd_patch0_func, 686, 1, 1 },
1102 { ahd_patch0_func, 658, 1, 1 }, 1138 { ahd_patch19_func, 709, 1, 1 },
1103 { ahd_patch17_func, 681, 1, 1 }, 1139 { ahd_patch19_func, 747, 1, 1 },
1104 { ahd_patch17_func, 719, 1, 1 }, 1140 { ahd_patch1_func, 758, 1, 2 },
1105 { ahd_patch1_func, 730, 1, 2 }, 1141 { ahd_patch0_func, 759, 1, 1 },
1106 { ahd_patch0_func, 731, 1, 1 }, 1142 { ahd_patch1_func, 776, 1, 2 },
1107 { ahd_patch1_func, 748, 1, 2 }, 1143 { ahd_patch0_func, 777, 1, 1 },
1108 { ahd_patch0_func, 749, 1, 1 }, 1144 { ahd_patch1_func, 779, 1, 2 },
1109 { ahd_patch1_func, 751, 1, 2 }, 1145 { ahd_patch0_func, 780, 1, 1 },
1110 { ahd_patch0_func, 752, 1, 1 }, 1146 { ahd_patch1_func, 783, 1, 2 },
1111 { ahd_patch1_func, 755, 1, 2 }, 1147 { ahd_patch0_func, 784, 1, 1 },
1112 { ahd_patch0_func, 756, 1, 1 }, 1148 { ahd_patch22_func, 786, 1, 2 },
1113 { ahd_patch21_func, 758, 1, 2 }, 1149 { ahd_patch0_func, 787, 2, 1 },
1114 { ahd_patch0_func, 759, 2, 1 }, 1150 { ahd_patch23_func, 790, 4, 2 },
1115 { ahd_patch22_func, 762, 4, 2 }, 1151 { ahd_patch0_func, 794, 1, 1 },
1116 { ahd_patch0_func, 766, 1, 1 }, 1152 { ahd_patch23_func, 802, 11, 1 }
1117 { ahd_patch22_func, 774, 11, 1 }
1118}; 1153};
1119 1154
1120static struct cs { 1155static struct cs {
1121 uint16_t begin; 1156 uint16_t begin;
1122 uint16_t end; 1157 uint16_t end;
1123} critical_sections[] = { 1158} critical_sections[] = {
1124 { 11, 12 }, 1159 { 17, 28 },
1125 { 13, 14 }, 1160 { 29, 30 },
1126 { 29, 42 }, 1161 { 47, 58 },
1127 { 56, 59 }, 1162 { 61, 63 },
1128 { 101, 128 }, 1163 { 65, 66 },
1129 { 129, 157 }, 1164 { 72, 92 },
1130 { 159, 162 }, 1165 { 110, 137 },
1131 { 170, 178 }, 1166 { 138, 175 },
1132 { 201, 250 }, 1167 { 180, 188 },
1133 { 681, 697 }, 1168 { 213, 264 },
1134 { 697, 711 }, 1169 { 425, 433 },
1135 { 721, 725 } 1170 { 443, 445 },
1171 { 448, 457 },
1172 { 709, 739 },
1173 { 749, 753 }
1136}; 1174};
1137 1175
1138static const int num_critical_sections = sizeof(critical_sections) 1176static const int num_critical_sections = sizeof(critical_sections)
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.c b/drivers/scsi/aic7xxx/aic7xxx_osm.c
index fd389e9f9460..051970efba68 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_osm.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c
@@ -375,7 +375,7 @@ static void ahc_linux_queue_cmd_complete(struct ahc_softc *ahc,
375 struct scsi_cmnd *cmd); 375 struct scsi_cmnd *cmd);
376static void ahc_linux_sem_timeout(u_long arg); 376static void ahc_linux_sem_timeout(u_long arg);
377static void ahc_linux_freeze_simq(struct ahc_softc *ahc); 377static void ahc_linux_freeze_simq(struct ahc_softc *ahc);
378static void ahc_linux_release_simq(u_long arg); 378static void ahc_linux_release_simq(struct ahc_softc *ahc);
379static int ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag); 379static int ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag);
380static void ahc_linux_initialize_scsi_bus(struct ahc_softc *ahc); 380static void ahc_linux_initialize_scsi_bus(struct ahc_softc *ahc);
381static u_int ahc_linux_user_tagdepth(struct ahc_softc *ahc, 381static u_int ahc_linux_user_tagdepth(struct ahc_softc *ahc,
@@ -1073,7 +1073,6 @@ ahc_linux_register_host(struct ahc_softc *ahc, struct scsi_host_template *templa
1073 return (ENOMEM); 1073 return (ENOMEM);
1074 1074
1075 *((struct ahc_softc **)host->hostdata) = ahc; 1075 *((struct ahc_softc **)host->hostdata) = ahc;
1076 ahc_lock(ahc, &s);
1077 ahc->platform_data->host = host; 1076 ahc->platform_data->host = host;
1078 host->can_queue = AHC_MAX_QUEUE; 1077 host->can_queue = AHC_MAX_QUEUE;
1079 host->cmd_per_lun = 2; 1078 host->cmd_per_lun = 2;
@@ -1084,7 +1083,9 @@ ahc_linux_register_host(struct ahc_softc *ahc, struct scsi_host_template *templa
1084 host->max_lun = AHC_NUM_LUNS; 1083 host->max_lun = AHC_NUM_LUNS;
1085 host->max_channel = (ahc->features & AHC_TWIN) ? 1 : 0; 1084 host->max_channel = (ahc->features & AHC_TWIN) ? 1 : 0;
1086 host->sg_tablesize = AHC_NSEG; 1085 host->sg_tablesize = AHC_NSEG;
1086 ahc_lock(ahc, &s);
1087 ahc_set_unit(ahc, ahc_linux_unit++); 1087 ahc_set_unit(ahc, ahc_linux_unit++);
1088 ahc_unlock(ahc, &s);
1088 sprintf(buf, "scsi%d", host->host_no); 1089 sprintf(buf, "scsi%d", host->host_no);
1089 new_name = malloc(strlen(buf) + 1, M_DEVBUF, M_NOWAIT); 1090 new_name = malloc(strlen(buf) + 1, M_DEVBUF, M_NOWAIT);
1090 if (new_name != NULL) { 1091 if (new_name != NULL) {
@@ -1094,7 +1095,6 @@ ahc_linux_register_host(struct ahc_softc *ahc, struct scsi_host_template *templa
1094 host->unique_id = ahc->unit; 1095 host->unique_id = ahc->unit;
1095 ahc_linux_initialize_scsi_bus(ahc); 1096 ahc_linux_initialize_scsi_bus(ahc);
1096 ahc_intr_enable(ahc, TRUE); 1097 ahc_intr_enable(ahc, TRUE);
1097 ahc_unlock(ahc, &s);
1098 1098
1099 host->transportt = ahc_linux_transport_template; 1099 host->transportt = ahc_linux_transport_template;
1100 1100
@@ -1120,10 +1120,13 @@ ahc_linux_initialize_scsi_bus(struct ahc_softc *ahc)
1120{ 1120{
1121 int i; 1121 int i;
1122 int numtarg; 1122 int numtarg;
1123 unsigned long s;
1123 1124
1124 i = 0; 1125 i = 0;
1125 numtarg = 0; 1126 numtarg = 0;
1126 1127
1128 ahc_lock(ahc, &s);
1129
1127 if (aic7xxx_no_reset != 0) 1130 if (aic7xxx_no_reset != 0)
1128 ahc->flags &= ~(AHC_RESET_BUS_A|AHC_RESET_BUS_B); 1131 ahc->flags &= ~(AHC_RESET_BUS_A|AHC_RESET_BUS_B);
1129 1132
@@ -1170,16 +1173,12 @@ ahc_linux_initialize_scsi_bus(struct ahc_softc *ahc)
1170 ahc_update_neg_request(ahc, &devinfo, tstate, 1173 ahc_update_neg_request(ahc, &devinfo, tstate,
1171 tinfo, AHC_NEG_ALWAYS); 1174 tinfo, AHC_NEG_ALWAYS);
1172 } 1175 }
1176 ahc_unlock(ahc, &s);
1173 /* Give the bus some time to recover */ 1177 /* Give the bus some time to recover */
1174 if ((ahc->flags & (AHC_RESET_BUS_A|AHC_RESET_BUS_B)) != 0) { 1178 if ((ahc->flags & (AHC_RESET_BUS_A|AHC_RESET_BUS_B)) != 0) {
1175 ahc_linux_freeze_simq(ahc); 1179 ahc_linux_freeze_simq(ahc);
1176 init_timer(&ahc->platform_data->reset_timer); 1180 msleep(AIC7XXX_RESET_DELAY);
1177 ahc->platform_data->reset_timer.data = (u_long)ahc; 1181 ahc_linux_release_simq(ahc);
1178 ahc->platform_data->reset_timer.expires =
1179 jiffies + (AIC7XXX_RESET_DELAY * HZ)/1000;
1180 ahc->platform_data->reset_timer.function =
1181 ahc_linux_release_simq;
1182 add_timer(&ahc->platform_data->reset_timer);
1183 } 1182 }
1184} 1183}
1185 1184
@@ -2059,6 +2058,9 @@ ahc_linux_sem_timeout(u_long arg)
2059static void 2058static void
2060ahc_linux_freeze_simq(struct ahc_softc *ahc) 2059ahc_linux_freeze_simq(struct ahc_softc *ahc)
2061{ 2060{
2061 unsigned long s;
2062
2063 ahc_lock(ahc, &s);
2062 ahc->platform_data->qfrozen++; 2064 ahc->platform_data->qfrozen++;
2063 if (ahc->platform_data->qfrozen == 1) { 2065 if (ahc->platform_data->qfrozen == 1) {
2064 scsi_block_requests(ahc->platform_data->host); 2066 scsi_block_requests(ahc->platform_data->host);
@@ -2068,17 +2070,15 @@ ahc_linux_freeze_simq(struct ahc_softc *ahc)
2068 CAM_LUN_WILDCARD, SCB_LIST_NULL, 2070 CAM_LUN_WILDCARD, SCB_LIST_NULL,
2069 ROLE_INITIATOR, CAM_REQUEUE_REQ); 2071 ROLE_INITIATOR, CAM_REQUEUE_REQ);
2070 } 2072 }
2073 ahc_unlock(ahc, &s);
2071} 2074}
2072 2075
2073static void 2076static void
2074ahc_linux_release_simq(u_long arg) 2077ahc_linux_release_simq(struct ahc_softc *ahc)
2075{ 2078{
2076 struct ahc_softc *ahc;
2077 u_long s; 2079 u_long s;
2078 int unblock_reqs; 2080 int unblock_reqs;
2079 2081
2080 ahc = (struct ahc_softc *)arg;
2081
2082 unblock_reqs = 0; 2082 unblock_reqs = 0;
2083 ahc_lock(ahc, &s); 2083 ahc_lock(ahc, &s);
2084 if (ahc->platform_data->qfrozen > 0) 2084 if (ahc->platform_data->qfrozen > 0)
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.h b/drivers/scsi/aic7xxx/aic7xxx_osm.h
index f2a95447142c..e0edacae895f 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_osm.h
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm.h
@@ -223,9 +223,6 @@ int ahc_dmamap_unload(struct ahc_softc *, bus_dma_tag_t, bus_dmamap_t);
223 */ 223 */
224#define ahc_dmamap_sync(ahc, dma_tag, dmamap, offset, len, op) 224#define ahc_dmamap_sync(ahc, dma_tag, dmamap, offset, len, op)
225 225
226/************************** Timer DataStructures ******************************/
227typedef struct timer_list ahc_timer_t;
228
229/********************************** Includes **********************************/ 226/********************************** Includes **********************************/
230#ifdef CONFIG_AIC7XXX_REG_PRETTY_PRINT 227#ifdef CONFIG_AIC7XXX_REG_PRETTY_PRINT
231#define AIC_DEBUG_REGISTERS 1 228#define AIC_DEBUG_REGISTERS 1
@@ -235,30 +232,9 @@ typedef struct timer_list ahc_timer_t;
235#include "aic7xxx.h" 232#include "aic7xxx.h"
236 233
237/***************************** Timer Facilities *******************************/ 234/***************************** Timer Facilities *******************************/
238#define ahc_timer_init init_timer
239#define ahc_timer_stop del_timer_sync
240typedef void ahc_linux_callback_t (u_long);
241static __inline void ahc_timer_reset(ahc_timer_t *timer, int usec,
242 ahc_callback_t *func, void *arg);
243static __inline void ahc_scb_timer_reset(struct scb *scb, u_int usec);
244
245static __inline void
246ahc_timer_reset(ahc_timer_t *timer, int usec, ahc_callback_t *func, void *arg)
247{
248 struct ahc_softc *ahc;
249
250 ahc = (struct ahc_softc *)arg;
251 del_timer(timer);
252 timer->data = (u_long)arg;
253 timer->expires = jiffies + (usec * HZ)/1000000;
254 timer->function = (ahc_linux_callback_t*)func;
255 add_timer(timer);
256}
257
258static __inline void 235static __inline void
259ahc_scb_timer_reset(struct scb *scb, u_int usec) 236ahc_scb_timer_reset(struct scb *scb, u_int usec)
260{ 237{
261 mod_timer(&scb->io_ctx->eh_timeout, jiffies + (usec * HZ)/1000000);
262} 238}
263 239
264/***************************** SMP support ************************************/ 240/***************************** SMP support ************************************/
@@ -393,7 +369,6 @@ struct ahc_platform_data {
393 369
394 spinlock_t spin_lock; 370 spinlock_t spin_lock;
395 u_int qfrozen; 371 u_int qfrozen;
396 struct timer_list reset_timer;
397 struct semaphore eh_sem; 372 struct semaphore eh_sem;
398 struct Scsi_Host *host; /* pointer to scsi host */ 373 struct Scsi_Host *host; /* pointer to scsi host */
399#define AHC_LINUX_NOIRQ ((uint32_t)~0) 374#define AHC_LINUX_NOIRQ ((uint32_t)~0)
diff --git a/drivers/scsi/aic7xxx/aic7xxx_pci.c b/drivers/scsi/aic7xxx/aic7xxx_pci.c
index b3b2e2237eb3..5f586140e057 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_pci.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_pci.c
@@ -39,9 +39,7 @@
39 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 39 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
40 * POSSIBILITY OF SUCH DAMAGES. 40 * POSSIBILITY OF SUCH DAMAGES.
41 * 41 *
42 * $Id: //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#69 $ 42 * $Id: //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#79 $
43 *
44 * $FreeBSD$
45 */ 43 */
46 44
47#ifdef __linux__ 45#ifdef __linux__
@@ -393,6 +391,12 @@ struct ahc_pci_identity ahc_pci_ident_table [] =
393 "Adaptec aic7892 Ultra160 SCSI adapter (ARO)", 391 "Adaptec aic7892 Ultra160 SCSI adapter (ARO)",
394 ahc_aic7892_setup 392 ahc_aic7892_setup
395 }, 393 },
394 {
395 ID_AHA_2915_30LP,
396 ID_ALL_MASK,
397 "Adaptec 2915/30LP Ultra160 SCSI adapter",
398 ahc_aic7892_setup
399 },
396 /* aic7895 based controllers */ 400 /* aic7895 based controllers */
397 { 401 {
398 ID_AHA_2940U_DUAL, 402 ID_AHA_2940U_DUAL,
@@ -1193,9 +1197,19 @@ ahc_pci_test_register_access(struct ahc_softc *ahc)
1193 * use for this test. 1197 * use for this test.
1194 */ 1198 */
1195 hcntrl = ahc_inb(ahc, HCNTRL); 1199 hcntrl = ahc_inb(ahc, HCNTRL);
1200
1196 if (hcntrl == 0xFF) 1201 if (hcntrl == 0xFF)
1197 goto fail; 1202 goto fail;
1198 1203
1204 if ((hcntrl & CHIPRST) != 0) {
1205 /*
1206 * The chip has not been initialized since
1207 * PCI/EISA/VLB bus reset. Don't trust
1208 * "left over BIOS data".
1209 */
1210 ahc->flags |= AHC_NO_BIOS_INIT;
1211 }
1212
1199 /* 1213 /*
1200 * Next create a situation where write combining 1214 * Next create a situation where write combining
1201 * or read prefetching could be initiated by the 1215 * or read prefetching could be initiated by the
@@ -1307,6 +1321,10 @@ check_extport(struct ahc_softc *ahc, u_int *sxfrctl1)
1307 sd.sd_chip = C56_66; 1321 sd.sd_chip = C56_66;
1308 } 1322 }
1309 ahc_release_seeprom(&sd); 1323 ahc_release_seeprom(&sd);
1324
1325 /* Remember the SEEPROM type for later */
1326 if (sd.sd_chip == C56_66)
1327 ahc->flags |= AHC_LARGE_SEEPROM;
1310 } 1328 }
1311 1329
1312 if (!have_seeprom) { 1330 if (!have_seeprom) {
diff --git a/drivers/scsi/aic7xxx/aic7xxx_pci.h b/drivers/scsi/aic7xxx/aic7xxx_pci.h
index be27fcb20346..263f85da405e 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_pci.h
+++ b/drivers/scsi/aic7xxx/aic7xxx_pci.h
@@ -105,6 +105,7 @@
105#define ID_AHA_29160C 0x0080900562209005ull 105#define ID_AHA_29160C 0x0080900562209005ull
106#define ID_AHA_29160B 0x00809005E2209005ull 106#define ID_AHA_29160B 0x00809005E2209005ull
107#define ID_AHA_19160B 0x0081900562A19005ull 107#define ID_AHA_19160B 0x0081900562A19005ull
108#define ID_AHA_2915_30LP 0x0082900502109005ull
108 109
109#define ID_AIC7896 0x005F9005FFFF9005ull 110#define ID_AIC7896 0x005F9005FFFF9005ull
110#define ID_AIC7896_ARO 0x00539005FFFF9005ull 111#define ID_AIC7896_ARO 0x00539005FFFF9005ull
diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c
index 4299fabca554..c3f27285db1b 100644
--- a/drivers/scsi/ch.c
+++ b/drivers/scsi/ch.c
@@ -22,6 +22,7 @@
22#include <linux/completion.h> 22#include <linux/completion.h>
23#include <linux/compat.h> 23#include <linux/compat.h>
24#include <linux/chio.h> /* here are all the ioctls */ 24#include <linux/chio.h> /* here are all the ioctls */
25#include <linux/mutex.h>
25 26
26#include <scsi/scsi.h> 27#include <scsi/scsi.h>
27#include <scsi/scsi_cmnd.h> 28#include <scsi/scsi_cmnd.h>
@@ -111,7 +112,7 @@ typedef struct {
111 u_int counts[CH_TYPES]; 112 u_int counts[CH_TYPES];
112 u_int unit_attention; 113 u_int unit_attention;
113 u_int voltags; 114 u_int voltags;
114 struct semaphore lock; 115 struct mutex lock;
115} scsi_changer; 116} scsi_changer;
116 117
117static LIST_HEAD(ch_devlist); 118static LIST_HEAD(ch_devlist);
@@ -565,7 +566,7 @@ static int ch_gstatus(scsi_changer *ch, int type, unsigned char __user *dest)
565 u_char data[16]; 566 u_char data[16];
566 unsigned int i; 567 unsigned int i;
567 568
568 down(&ch->lock); 569 mutex_lock(&ch->lock);
569 for (i = 0; i < ch->counts[type]; i++) { 570 for (i = 0; i < ch->counts[type]; i++) {
570 if (0 != ch_read_element_status 571 if (0 != ch_read_element_status
571 (ch, ch->firsts[type]+i,data)) { 572 (ch, ch->firsts[type]+i,data)) {
@@ -582,7 +583,7 @@ static int ch_gstatus(scsi_changer *ch, int type, unsigned char __user *dest)
582 if (0 != retval) 583 if (0 != retval)
583 break; 584 break;
584 } 585 }
585 up(&ch->lock); 586 mutex_unlock(&ch->lock);
586 return retval; 587 return retval;
587} 588}
588 589
@@ -687,11 +688,11 @@ static int ch_ioctl(struct inode * inode, struct file * file,
687 dprintk("CHIOPOSITION: invalid parameter\n"); 688 dprintk("CHIOPOSITION: invalid parameter\n");
688 return -EBADSLT; 689 return -EBADSLT;
689 } 690 }
690 down(&ch->lock); 691 mutex_lock(&ch->lock);
691 retval = ch_position(ch,0, 692 retval = ch_position(ch,0,
692 ch->firsts[pos.cp_type] + pos.cp_unit, 693 ch->firsts[pos.cp_type] + pos.cp_unit,
693 pos.cp_flags & CP_INVERT); 694 pos.cp_flags & CP_INVERT);
694 up(&ch->lock); 695 mutex_unlock(&ch->lock);
695 return retval; 696 return retval;
696 } 697 }
697 698
@@ -708,12 +709,12 @@ static int ch_ioctl(struct inode * inode, struct file * file,
708 return -EBADSLT; 709 return -EBADSLT;
709 } 710 }
710 711
711 down(&ch->lock); 712 mutex_lock(&ch->lock);
712 retval = ch_move(ch,0, 713 retval = ch_move(ch,0,
713 ch->firsts[mv.cm_fromtype] + mv.cm_fromunit, 714 ch->firsts[mv.cm_fromtype] + mv.cm_fromunit,
714 ch->firsts[mv.cm_totype] + mv.cm_tounit, 715 ch->firsts[mv.cm_totype] + mv.cm_tounit,
715 mv.cm_flags & CM_INVERT); 716 mv.cm_flags & CM_INVERT);
716 up(&ch->lock); 717 mutex_unlock(&ch->lock);
717 return retval; 718 return retval;
718 } 719 }
719 720
@@ -731,14 +732,14 @@ static int ch_ioctl(struct inode * inode, struct file * file,
731 return -EBADSLT; 732 return -EBADSLT;
732 } 733 }
733 734
734 down(&ch->lock); 735 mutex_lock(&ch->lock);
735 retval = ch_exchange 736 retval = ch_exchange
736 (ch,0, 737 (ch,0,
737 ch->firsts[mv.ce_srctype] + mv.ce_srcunit, 738 ch->firsts[mv.ce_srctype] + mv.ce_srcunit,
738 ch->firsts[mv.ce_fdsttype] + mv.ce_fdstunit, 739 ch->firsts[mv.ce_fdsttype] + mv.ce_fdstunit,
739 ch->firsts[mv.ce_sdsttype] + mv.ce_sdstunit, 740 ch->firsts[mv.ce_sdsttype] + mv.ce_sdstunit,
740 mv.ce_flags & CE_INVERT1, mv.ce_flags & CE_INVERT2); 741 mv.ce_flags & CE_INVERT1, mv.ce_flags & CE_INVERT2);
741 up(&ch->lock); 742 mutex_unlock(&ch->lock);
742 return retval; 743 return retval;
743 } 744 }
744 745
@@ -772,7 +773,7 @@ static int ch_ioctl(struct inode * inode, struct file * file,
772 buffer = kmalloc(512, GFP_KERNEL | GFP_DMA); 773 buffer = kmalloc(512, GFP_KERNEL | GFP_DMA);
773 if (!buffer) 774 if (!buffer)
774 return -ENOMEM; 775 return -ENOMEM;
775 down(&ch->lock); 776 mutex_lock(&ch->lock);
776 777
777 voltag_retry: 778 voltag_retry:
778 memset(cmd,0,sizeof(cmd)); 779 memset(cmd,0,sizeof(cmd));
@@ -823,7 +824,7 @@ static int ch_ioctl(struct inode * inode, struct file * file,
823 goto voltag_retry; 824 goto voltag_retry;
824 } 825 }
825 kfree(buffer); 826 kfree(buffer);
826 up(&ch->lock); 827 mutex_unlock(&ch->lock);
827 828
828 if (copy_to_user(argp, &cge, sizeof (cge))) 829 if (copy_to_user(argp, &cge, sizeof (cge)))
829 return -EFAULT; 830 return -EFAULT;
@@ -832,9 +833,9 @@ static int ch_ioctl(struct inode * inode, struct file * file,
832 833
833 case CHIOINITELEM: 834 case CHIOINITELEM:
834 { 835 {
835 down(&ch->lock); 836 mutex_lock(&ch->lock);
836 retval = ch_init_elem(ch); 837 retval = ch_init_elem(ch);
837 up(&ch->lock); 838 mutex_unlock(&ch->lock);
838 return retval; 839 return retval;
839 } 840 }
840 841
@@ -851,12 +852,12 @@ static int ch_ioctl(struct inode * inode, struct file * file,
851 return -EBADSLT; 852 return -EBADSLT;
852 } 853 }
853 elem = ch->firsts[csv.csv_type] + csv.csv_unit; 854 elem = ch->firsts[csv.csv_type] + csv.csv_unit;
854 down(&ch->lock); 855 mutex_lock(&ch->lock);
855 retval = ch_set_voltag(ch, elem, 856 retval = ch_set_voltag(ch, elem,
856 csv.csv_flags & CSV_AVOLTAG, 857 csv.csv_flags & CSV_AVOLTAG,
857 csv.csv_flags & CSV_CLEARTAG, 858 csv.csv_flags & CSV_CLEARTAG,
858 csv.csv_voltag); 859 csv.csv_voltag);
859 up(&ch->lock); 860 mutex_unlock(&ch->lock);
860 return retval; 861 return retval;
861 } 862 }
862 863
@@ -929,7 +930,7 @@ static int ch_probe(struct device *dev)
929 memset(ch,0,sizeof(*ch)); 930 memset(ch,0,sizeof(*ch));
930 ch->minor = ch_devcount; 931 ch->minor = ch_devcount;
931 sprintf(ch->name,"ch%d",ch->minor); 932 sprintf(ch->name,"ch%d",ch->minor);
932 init_MUTEX(&ch->lock); 933 mutex_init(&ch->lock);
933 ch->device = sd; 934 ch->device = sd;
934 ch_readconfig(ch); 935 ch_readconfig(ch);
935 if (init) 936 if (init)
diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
index 6252b9ddc01e..6e6b293dcb28 100644
--- a/drivers/scsi/dpt_i2o.c
+++ b/drivers/scsi/dpt_i2o.c
@@ -61,6 +61,7 @@ MODULE_DESCRIPTION("Adaptec I2O RAID Driver");
61#include <linux/timer.h> 61#include <linux/timer.h>
62#include <linux/string.h> 62#include <linux/string.h>
63#include <linux/ioport.h> 63#include <linux/ioport.h>
64#include <linux/mutex.h>
64 65
65#include <asm/processor.h> /* for boot_cpu_data */ 66#include <asm/processor.h> /* for boot_cpu_data */
66#include <asm/pgtable.h> 67#include <asm/pgtable.h>
@@ -106,7 +107,7 @@ static dpt_sig_S DPTI_sig = {
106 *============================================================================ 107 *============================================================================
107 */ 108 */
108 109
109static DECLARE_MUTEX(adpt_configuration_lock); 110static DEFINE_MUTEX(adpt_configuration_lock);
110 111
111static struct i2o_sys_tbl *sys_tbl = NULL; 112static struct i2o_sys_tbl *sys_tbl = NULL;
112static int sys_tbl_ind = 0; 113static int sys_tbl_ind = 0;
@@ -537,13 +538,13 @@ static int adpt_proc_info(struct Scsi_Host *host, char *buffer, char **start, of
537 */ 538 */
538 539
539 // Find HBA (host bus adapter) we are looking for 540 // Find HBA (host bus adapter) we are looking for
540 down(&adpt_configuration_lock); 541 mutex_lock(&adpt_configuration_lock);
541 for (pHba = hba_chain; pHba; pHba = pHba->next) { 542 for (pHba = hba_chain; pHba; pHba = pHba->next) {
542 if (pHba->host == host) { 543 if (pHba->host == host) {
543 break; /* found adapter */ 544 break; /* found adapter */
544 } 545 }
545 } 546 }
546 up(&adpt_configuration_lock); 547 mutex_unlock(&adpt_configuration_lock);
547 if (pHba == NULL) { 548 if (pHba == NULL) {
548 return 0; 549 return 0;
549 } 550 }
@@ -898,6 +899,12 @@ static int adpt_install_hba(struct scsi_host_template* sht, struct pci_dev* pDev
898 if(pci_enable_device(pDev)) { 899 if(pci_enable_device(pDev)) {
899 return -EINVAL; 900 return -EINVAL;
900 } 901 }
902
903 if (pci_request_regions(pDev, "dpt_i2o")) {
904 PERROR("dpti: adpt_config_hba: pci request region failed\n");
905 return -EINVAL;
906 }
907
901 pci_set_master(pDev); 908 pci_set_master(pDev);
902 if (pci_set_dma_mask(pDev, 0xffffffffffffffffULL) && 909 if (pci_set_dma_mask(pDev, 0xffffffffffffffffULL) &&
903 pci_set_dma_mask(pDev, 0xffffffffULL)) 910 pci_set_dma_mask(pDev, 0xffffffffULL))
@@ -923,10 +930,6 @@ static int adpt_install_hba(struct scsi_host_template* sht, struct pci_dev* pDev
923 raptorFlag = TRUE; 930 raptorFlag = TRUE;
924 } 931 }
925 932
926 if (pci_request_regions(pDev, "dpt_i2o")) {
927 PERROR("dpti: adpt_config_hba: pci request region failed\n");
928 return -EINVAL;
929 }
930 base_addr_virt = ioremap(base_addr0_phys,hba_map0_area_size); 933 base_addr_virt = ioremap(base_addr0_phys,hba_map0_area_size);
931 if (!base_addr_virt) { 934 if (!base_addr_virt) {
932 pci_release_regions(pDev); 935 pci_release_regions(pDev);
@@ -958,7 +961,7 @@ static int adpt_install_hba(struct scsi_host_template* sht, struct pci_dev* pDev
958 } 961 }
959 memset(pHba, 0, sizeof(adpt_hba)); 962 memset(pHba, 0, sizeof(adpt_hba));
960 963
961 down(&adpt_configuration_lock); 964 mutex_lock(&adpt_configuration_lock);
962 965
963 if(hba_chain != NULL){ 966 if(hba_chain != NULL){
964 for(p = hba_chain; p->next; p = p->next); 967 for(p = hba_chain; p->next; p = p->next);
@@ -971,7 +974,7 @@ static int adpt_install_hba(struct scsi_host_template* sht, struct pci_dev* pDev
971 sprintf(pHba->name, "dpti%d", hba_count); 974 sprintf(pHba->name, "dpti%d", hba_count);
972 hba_count++; 975 hba_count++;
973 976
974 up(&adpt_configuration_lock); 977 mutex_unlock(&adpt_configuration_lock);
975 978
976 pHba->pDev = pDev; 979 pHba->pDev = pDev;
977 pHba->base_addr_phys = base_addr0_phys; 980 pHba->base_addr_phys = base_addr0_phys;
@@ -1027,7 +1030,7 @@ static void adpt_i2o_delete_hba(adpt_hba* pHba)
1027 struct adpt_device* pNext; 1030 struct adpt_device* pNext;
1028 1031
1029 1032
1030 down(&adpt_configuration_lock); 1033 mutex_lock(&adpt_configuration_lock);
1031 // scsi_unregister calls our adpt_release which 1034 // scsi_unregister calls our adpt_release which
1032 // does a quiese 1035 // does a quiese
1033 if(pHba->host){ 1036 if(pHba->host){
@@ -1046,7 +1049,7 @@ static void adpt_i2o_delete_hba(adpt_hba* pHba)
1046 } 1049 }
1047 1050
1048 hba_count--; 1051 hba_count--;
1049 up(&adpt_configuration_lock); 1052 mutex_unlock(&adpt_configuration_lock);
1050 1053
1051 iounmap(pHba->base_addr_virt); 1054 iounmap(pHba->base_addr_virt);
1052 pci_release_regions(pHba->pDev); 1055 pci_release_regions(pHba->pDev);
@@ -1549,7 +1552,7 @@ static int adpt_i2o_parse_lct(adpt_hba* pHba)
1549 1552
1550static int adpt_i2o_install_device(adpt_hba* pHba, struct i2o_device *d) 1553static int adpt_i2o_install_device(adpt_hba* pHba, struct i2o_device *d)
1551{ 1554{
1552 down(&adpt_configuration_lock); 1555 mutex_lock(&adpt_configuration_lock);
1553 d->controller=pHba; 1556 d->controller=pHba;
1554 d->owner=NULL; 1557 d->owner=NULL;
1555 d->next=pHba->devices; 1558 d->next=pHba->devices;
@@ -1560,7 +1563,7 @@ static int adpt_i2o_install_device(adpt_hba* pHba, struct i2o_device *d)
1560 pHba->devices=d; 1563 pHba->devices=d;
1561 *d->dev_name = 0; 1564 *d->dev_name = 0;
1562 1565
1563 up(&adpt_configuration_lock); 1566 mutex_unlock(&adpt_configuration_lock);
1564 return 0; 1567 return 0;
1565} 1568}
1566 1569
@@ -1575,24 +1578,24 @@ static int adpt_open(struct inode *inode, struct file *file)
1575 if (minor >= hba_count) { 1578 if (minor >= hba_count) {
1576 return -ENXIO; 1579 return -ENXIO;
1577 } 1580 }
1578 down(&adpt_configuration_lock); 1581 mutex_lock(&adpt_configuration_lock);
1579 for (pHba = hba_chain; pHba; pHba = pHba->next) { 1582 for (pHba = hba_chain; pHba; pHba = pHba->next) {
1580 if (pHba->unit == minor) { 1583 if (pHba->unit == minor) {
1581 break; /* found adapter */ 1584 break; /* found adapter */
1582 } 1585 }
1583 } 1586 }
1584 if (pHba == NULL) { 1587 if (pHba == NULL) {
1585 up(&adpt_configuration_lock); 1588 mutex_unlock(&adpt_configuration_lock);
1586 return -ENXIO; 1589 return -ENXIO;
1587 } 1590 }
1588 1591
1589// if(pHba->in_use){ 1592// if(pHba->in_use){
1590 // up(&adpt_configuration_lock); 1593 // mutex_unlock(&adpt_configuration_lock);
1591// return -EBUSY; 1594// return -EBUSY;
1592// } 1595// }
1593 1596
1594 pHba->in_use = 1; 1597 pHba->in_use = 1;
1595 up(&adpt_configuration_lock); 1598 mutex_unlock(&adpt_configuration_lock);
1596 1599
1597 return 0; 1600 return 0;
1598} 1601}
@@ -1606,13 +1609,13 @@ static int adpt_close(struct inode *inode, struct file *file)
1606 if (minor >= hba_count) { 1609 if (minor >= hba_count) {
1607 return -ENXIO; 1610 return -ENXIO;
1608 } 1611 }
1609 down(&adpt_configuration_lock); 1612 mutex_lock(&adpt_configuration_lock);
1610 for (pHba = hba_chain; pHba; pHba = pHba->next) { 1613 for (pHba = hba_chain; pHba; pHba = pHba->next) {
1611 if (pHba->unit == minor) { 1614 if (pHba->unit == minor) {
1612 break; /* found adapter */ 1615 break; /* found adapter */
1613 } 1616 }
1614 } 1617 }
1615 up(&adpt_configuration_lock); 1618 mutex_unlock(&adpt_configuration_lock);
1616 if (pHba == NULL) { 1619 if (pHba == NULL) {
1617 return -ENXIO; 1620 return -ENXIO;
1618 } 1621 }
@@ -1910,13 +1913,13 @@ static int adpt_ioctl(struct inode *inode, struct file *file, uint cmd,
1910 if (minor >= DPTI_MAX_HBA){ 1913 if (minor >= DPTI_MAX_HBA){
1911 return -ENXIO; 1914 return -ENXIO;
1912 } 1915 }
1913 down(&adpt_configuration_lock); 1916 mutex_lock(&adpt_configuration_lock);
1914 for (pHba = hba_chain; pHba; pHba = pHba->next) { 1917 for (pHba = hba_chain; pHba; pHba = pHba->next) {
1915 if (pHba->unit == minor) { 1918 if (pHba->unit == minor) {
1916 break; /* found adapter */ 1919 break; /* found adapter */
1917 } 1920 }
1918 } 1921 }
1919 up(&adpt_configuration_lock); 1922 mutex_unlock(&adpt_configuration_lock);
1920 if(pHba == NULL){ 1923 if(pHba == NULL){
1921 return -ENXIO; 1924 return -ENXIO;
1922 } 1925 }
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index 66783c860a19..588107923499 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -156,16 +156,16 @@ EXPORT_SYMBOL(scsi_host_set_state);
156void scsi_remove_host(struct Scsi_Host *shost) 156void scsi_remove_host(struct Scsi_Host *shost)
157{ 157{
158 unsigned long flags; 158 unsigned long flags;
159 down(&shost->scan_mutex); 159 mutex_lock(&shost->scan_mutex);
160 spin_lock_irqsave(shost->host_lock, flags); 160 spin_lock_irqsave(shost->host_lock, flags);
161 if (scsi_host_set_state(shost, SHOST_CANCEL)) 161 if (scsi_host_set_state(shost, SHOST_CANCEL))
162 if (scsi_host_set_state(shost, SHOST_CANCEL_RECOVERY)) { 162 if (scsi_host_set_state(shost, SHOST_CANCEL_RECOVERY)) {
163 spin_unlock_irqrestore(shost->host_lock, flags); 163 spin_unlock_irqrestore(shost->host_lock, flags);
164 up(&shost->scan_mutex); 164 mutex_unlock(&shost->scan_mutex);
165 return; 165 return;
166 } 166 }
167 spin_unlock_irqrestore(shost->host_lock, flags); 167 spin_unlock_irqrestore(shost->host_lock, flags);
168 up(&shost->scan_mutex); 168 mutex_unlock(&shost->scan_mutex);
169 scsi_forget_host(shost); 169 scsi_forget_host(shost);
170 scsi_proc_host_rm(shost); 170 scsi_proc_host_rm(shost);
171 171
@@ -320,7 +320,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
320 INIT_LIST_HEAD(&shost->starved_list); 320 INIT_LIST_HEAD(&shost->starved_list);
321 init_waitqueue_head(&shost->host_wait); 321 init_waitqueue_head(&shost->host_wait);
322 322
323 init_MUTEX(&shost->scan_mutex); 323 mutex_init(&shost->scan_mutex);
324 324
325 shost->host_no = scsi_host_next_hn++; /* XXX(hch): still racy */ 325 shost->host_no = scsi_host_next_hn++; /* XXX(hch): still racy */
326 shost->dma_channel = 0xff; 326 shost->dma_channel = 0xff;
diff --git a/drivers/scsi/ips.c b/drivers/scsi/ips.c
index 3882d48a42bf..e5e1ca44e1ee 100644
--- a/drivers/scsi/ips.c
+++ b/drivers/scsi/ips.c
@@ -1319,6 +1319,9 @@ ips_slave_configure(struct scsi_device * SDptr)
1319 min = ha->max_cmds - 1; 1319 min = ha->max_cmds - 1;
1320 scsi_adjust_queue_depth(SDptr, MSG_ORDERED_TAG, min); 1320 scsi_adjust_queue_depth(SDptr, MSG_ORDERED_TAG, min);
1321 } 1321 }
1322
1323 SDptr->skip_ms_page_8 = 1;
1324 SDptr->skip_ms_page_3f = 1;
1322 return 0; 1325 return 0;
1323} 1326}
1324#endif 1327#endif
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
index 10bcf42cb65c..1b495afe6d17 100644
--- a/drivers/scsi/iscsi_tcp.c
+++ b/drivers/scsi/iscsi_tcp.c
@@ -33,6 +33,7 @@
33#include <linux/delay.h> 33#include <linux/delay.h>
34#include <linux/kfifo.h> 34#include <linux/kfifo.h>
35#include <linux/scatterlist.h> 35#include <linux/scatterlist.h>
36#include <linux/mutex.h>
36#include <net/tcp.h> 37#include <net/tcp.h>
37#include <scsi/scsi_cmnd.h> 38#include <scsi/scsi_cmnd.h>
38#include <scsi/scsi_device.h> 39#include <scsi/scsi_device.h>
@@ -86,35 +87,32 @@ iscsi_buf_init_virt(struct iscsi_buf *ibuf, char *vbuf, int size)
86{ 87{
87 sg_init_one(&ibuf->sg, (u8 *)vbuf, size); 88 sg_init_one(&ibuf->sg, (u8 *)vbuf, size);
88 ibuf->sent = 0; 89 ibuf->sent = 0;
90 ibuf->use_sendmsg = 0;
89} 91}
90 92
91static inline void 93static inline void
92iscsi_buf_init_iov(struct iscsi_buf *ibuf, char *vbuf, int size) 94iscsi_buf_init_iov(struct iscsi_buf *ibuf, char *vbuf, int size)
93{ 95{
94 ibuf->sg.page = (void*)vbuf; 96 ibuf->sg.page = virt_to_page(vbuf);
95 ibuf->sg.offset = (unsigned int)-1; 97 ibuf->sg.offset = offset_in_page(vbuf);
96 ibuf->sg.length = size; 98 ibuf->sg.length = size;
97 ibuf->sent = 0; 99 ibuf->sent = 0;
98} 100 ibuf->use_sendmsg = 1;
99
100static inline void*
101iscsi_buf_iov_base(struct iscsi_buf *ibuf)
102{
103 return (char*)ibuf->sg.page + ibuf->sent;
104} 101}
105 102
106static inline void 103static inline void
107iscsi_buf_init_sg(struct iscsi_buf *ibuf, struct scatterlist *sg) 104iscsi_buf_init_sg(struct iscsi_buf *ibuf, struct scatterlist *sg)
108{ 105{
106 ibuf->sg.page = sg->page;
107 ibuf->sg.offset = sg->offset;
108 ibuf->sg.length = sg->length;
109 /* 109 /*
110 * Fastpath: sg element fits into single page 110 * Fastpath: sg element fits into single page
111 */ 111 */
112 if (sg->length + sg->offset <= PAGE_SIZE && page_count(sg->page) >= 2) { 112 if (sg->length + sg->offset <= PAGE_SIZE && !PageSlab(sg->page))
113 ibuf->sg.page = sg->page; 113 ibuf->use_sendmsg = 0;
114 ibuf->sg.offset = sg->offset; 114 else
115 ibuf->sg.length = sg->length; 115 ibuf->use_sendmsg = 1;
116 } else
117 iscsi_buf_init_iov(ibuf, page_address(sg->page), sg->length);
118 ibuf->sent = 0; 116 ibuf->sent = 0;
119} 117}
120 118
@@ -356,7 +354,7 @@ iscsi_data_rsp(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)
356 struct scsi_cmnd *sc = ctask->sc; 354 struct scsi_cmnd *sc = ctask->sc;
357 355
358 conn->exp_statsn = be32_to_cpu(rhdr->statsn) + 1; 356 conn->exp_statsn = be32_to_cpu(rhdr->statsn) + 1;
359 if (rhdr->flags & ISCSI_FLAG_CMD_UNDERFLOW) { 357 if (rhdr->flags & ISCSI_FLAG_DATA_UNDERFLOW) {
360 int res_count = be32_to_cpu(rhdr->residual_count); 358 int res_count = be32_to_cpu(rhdr->residual_count);
361 359
362 if (res_count > 0 && 360 if (res_count > 0 &&
@@ -366,9 +364,7 @@ iscsi_data_rsp(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)
366 } else 364 } else
367 sc->result = (DID_BAD_TARGET << 16) | 365 sc->result = (DID_BAD_TARGET << 16) |
368 rhdr->cmd_status; 366 rhdr->cmd_status;
369 } else if (rhdr->flags & ISCSI_FLAG_CMD_BIDI_UNDERFLOW) 367 } else if (rhdr->flags & ISCSI_FLAG_DATA_OVERFLOW) {
370 sc->result = (DID_BAD_TARGET << 16) | rhdr->cmd_status;
371 else if (rhdr->flags & ISCSI_FLAG_CMD_OVERFLOW) {
372 sc->resid = be32_to_cpu(rhdr->residual_count); 368 sc->resid = be32_to_cpu(rhdr->residual_count);
373 sc->result = (DID_OK << 16) | rhdr->cmd_status; 369 sc->result = (DID_OK << 16) | rhdr->cmd_status;
374 } else 370 } else
@@ -529,7 +525,7 @@ iscsi_r2t_rsp(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)
529 __kfifo_put(ctask->r2tqueue, (void*)&r2t, sizeof(void*)); 525 __kfifo_put(ctask->r2tqueue, (void*)&r2t, sizeof(void*));
530 __kfifo_put(conn->writequeue, (void*)&ctask, sizeof(void*)); 526 __kfifo_put(conn->writequeue, (void*)&ctask, sizeof(void*));
531 527
532 schedule_work(&conn->xmitwork); 528 scsi_queue_work(session->host, &conn->xmitwork);
533 conn->r2t_pdus_cnt++; 529 conn->r2t_pdus_cnt++;
534 spin_unlock(&session->lock); 530 spin_unlock(&session->lock);
535 531
@@ -686,7 +682,7 @@ iscsi_hdr_recv(struct iscsi_conn *conn)
686 switch(conn->in.opcode) { 682 switch(conn->in.opcode) {
687 case ISCSI_OP_LOGIN_RSP: 683 case ISCSI_OP_LOGIN_RSP:
688 case ISCSI_OP_TEXT_RSP: 684 case ISCSI_OP_TEXT_RSP:
689 case ISCSI_OP_LOGOUT_RSP: 685 case ISCSI_OP_LOGOUT_RSP:
690 rc = iscsi_check_assign_cmdsn(session, 686 rc = iscsi_check_assign_cmdsn(session,
691 (struct iscsi_nopin*)hdr); 687 (struct iscsi_nopin*)hdr);
692 if (rc) 688 if (rc)
@@ -727,12 +723,12 @@ iscsi_hdr_recv(struct iscsi_conn *conn)
727 } 723 }
728 spin_unlock(&session->lock); 724 spin_unlock(&session->lock);
729 break; 725 break;
730 case ISCSI_OP_NOOP_IN: 726 case ISCSI_OP_NOOP_IN:
731 if (hdr->ttt != ISCSI_RESERVED_TAG) { 727 if (hdr->ttt != ISCSI_RESERVED_TAG) {
732 rc = ISCSI_ERR_PROTO; 728 rc = ISCSI_ERR_PROTO;
733 break; 729 break;
734 } 730 }
735 rc = iscsi_check_assign_cmdsn(session, 731 rc = iscsi_check_assign_cmdsn(session,
736 (struct iscsi_nopin*)hdr); 732 (struct iscsi_nopin*)hdr);
737 if (rc) 733 if (rc)
738 break; 734 break;
@@ -767,7 +763,7 @@ iscsi_hdr_recv(struct iscsi_conn *conn)
767 if (!rc && hdr->ttt != ISCSI_RESERVED_TAG) 763 if (!rc && hdr->ttt != ISCSI_RESERVED_TAG)
768 rc = iscsi_recv_pdu(iscsi_handle(conn), 764 rc = iscsi_recv_pdu(iscsi_handle(conn),
769 hdr, NULL, 0); 765 hdr, NULL, 0);
770 } else 766 } else
771 rc = ISCSI_ERR_PROTO; 767 rc = ISCSI_ERR_PROTO;
772 break; 768 break;
773 case ISCSI_OP_REJECT: 769 case ISCSI_OP_REJECT:
@@ -929,7 +925,7 @@ static int iscsi_scsi_data_in(struct iscsi_conn *conn)
929 sc->request_bufflen, ctask->data_offset); 925 sc->request_bufflen, ctask->data_offset);
930 if (rc == -EAGAIN) 926 if (rc == -EAGAIN)
931 return rc; 927 return rc;
932 if (conn->datadgst_en) 928 if (conn->datadgst_en)
933 iscsi_recv_digest_update(conn, sc->request_buffer, i); 929 iscsi_recv_digest_update(conn, sc->request_buffer, i);
934 rc = 0; 930 rc = 0;
935 goto done; 931 goto done;
@@ -1024,7 +1020,7 @@ iscsi_data_recv(struct iscsi_conn *conn)
1024 conn->in.hdr = &conn->hdr; 1020 conn->in.hdr = &conn->hdr;
1025 conn->senselen = (conn->data[0] << 8) | conn->data[1]; 1021 conn->senselen = (conn->data[0] << 8) | conn->data[1];
1026 rc = iscsi_cmd_rsp(conn, conn->in.ctask); 1022 rc = iscsi_cmd_rsp(conn, conn->in.ctask);
1027 if (!rc && conn->datadgst_en) 1023 if (!rc && conn->datadgst_en)
1028 iscsi_recv_digest_update(conn, conn->data, 1024 iscsi_recv_digest_update(conn, conn->data,
1029 conn->in.datalen); 1025 conn->in.datalen);
1030 } 1026 }
@@ -1051,7 +1047,7 @@ iscsi_data_recv(struct iscsi_conn *conn)
1051 rc = iscsi_recv_pdu(iscsi_handle(conn), conn->in.hdr, 1047 rc = iscsi_recv_pdu(iscsi_handle(conn), conn->in.hdr,
1052 conn->data, conn->in.datalen); 1048 conn->data, conn->in.datalen);
1053 1049
1054 if (!rc && conn->datadgst_en && 1050 if (!rc && conn->datadgst_en &&
1055 conn->in.opcode != ISCSI_OP_LOGIN_RSP) 1051 conn->in.opcode != ISCSI_OP_LOGIN_RSP)
1056 iscsi_recv_digest_update(conn, conn->data, 1052 iscsi_recv_digest_update(conn, conn->data,
1057 conn->in.datalen); 1053 conn->in.datalen);
@@ -1271,7 +1267,7 @@ iscsi_write_space(struct sock *sk)
1271 conn->old_write_space(sk); 1267 conn->old_write_space(sk);
1272 debug_tcp("iscsi_write_space: cid %d\n", conn->id); 1268 debug_tcp("iscsi_write_space: cid %d\n", conn->id);
1273 clear_bit(SUSPEND_BIT, &conn->suspend_tx); 1269 clear_bit(SUSPEND_BIT, &conn->suspend_tx);
1274 schedule_work(&conn->xmitwork); 1270 scsi_queue_work(conn->session->host, &conn->xmitwork);
1275} 1271}
1276 1272
1277static void 1273static void
@@ -1312,35 +1308,25 @@ iscsi_conn_restore_callbacks(struct iscsi_conn *conn)
1312 * @buf: buffer to write from 1308 * @buf: buffer to write from
1313 * @size: actual size to write 1309 * @size: actual size to write
1314 * @flags: socket's flags 1310 * @flags: socket's flags
1315 *
1316 * Notes:
1317 * depending on buffer will use tcp_sendpage() or tcp_sendmsg().
1318 * buf->sg.offset == -1 tells us that buffer is non S/G and forces
1319 * to use tcp_sendmsg().
1320 */ 1311 */
1321static inline int 1312static inline int
1322iscsi_send(struct socket *sk, struct iscsi_buf *buf, int size, int flags) 1313iscsi_send(struct iscsi_conn *conn, struct iscsi_buf *buf, int size, int flags)
1323{ 1314{
1324 int res; 1315 struct socket *sk = conn->sock;
1325 1316 int offset = buf->sg.offset + buf->sent;
1326 if ((int)buf->sg.offset >= 0) {
1327 int offset = buf->sg.offset + buf->sent;
1328
1329 /* tcp_sendpage */
1330 res = sk->ops->sendpage(sk, buf->sg.page, offset, size, flags);
1331 } else {
1332 struct msghdr msg;
1333
1334 buf->iov.iov_base = iscsi_buf_iov_base(buf);
1335 buf->iov.iov_len = size;
1336
1337 memset(&msg, 0, sizeof(struct msghdr));
1338
1339 /* tcp_sendmsg */
1340 res = kernel_sendmsg(sk, &msg, &buf->iov, 1, size);
1341 }
1342 1317
1343 return res; 1318 /*
1319 * if we got use_sg=0 or are sending something we kmallocd
1320 * then we did not have to do kmap (kmap returns page_address)
1321 *
1322 * if we got use_sg > 0, but had to drop down, we do not
1323 * set clustering so this should only happen for that
1324 * slab case.
1325 */
1326 if (buf->use_sendmsg)
1327 return sock_no_sendpage(sk, buf->sg.page, offset, size, flags);
1328 else
1329 return conn->sendpage(sk, buf->sg.page, offset, size, flags);
1344} 1330}
1345 1331
1346/** 1332/**
@@ -1355,7 +1341,6 @@ iscsi_send(struct socket *sk, struct iscsi_buf *buf, int size, int flags)
1355static inline int 1341static inline int
1356iscsi_sendhdr(struct iscsi_conn *conn, struct iscsi_buf *buf, int datalen) 1342iscsi_sendhdr(struct iscsi_conn *conn, struct iscsi_buf *buf, int datalen)
1357{ 1343{
1358 struct socket *sk = conn->sock;
1359 int flags = 0; /* MSG_DONTWAIT; */ 1344 int flags = 0; /* MSG_DONTWAIT; */
1360 int res, size; 1345 int res, size;
1361 1346
@@ -1364,7 +1349,7 @@ iscsi_sendhdr(struct iscsi_conn *conn, struct iscsi_buf *buf, int datalen)
1364 if (buf->sent + size != buf->sg.length || datalen) 1349 if (buf->sent + size != buf->sg.length || datalen)
1365 flags |= MSG_MORE; 1350 flags |= MSG_MORE;
1366 1351
1367 res = iscsi_send(sk, buf, size, flags); 1352 res = iscsi_send(conn, buf, size, flags);
1368 debug_tcp("sendhdr %d bytes, sent %d res %d\n", size, buf->sent, res); 1353 debug_tcp("sendhdr %d bytes, sent %d res %d\n", size, buf->sent, res);
1369 if (res >= 0) { 1354 if (res >= 0) {
1370 conn->txdata_octets += res; 1355 conn->txdata_octets += res;
@@ -1395,7 +1380,6 @@ static inline int
1395iscsi_sendpage(struct iscsi_conn *conn, struct iscsi_buf *buf, 1380iscsi_sendpage(struct iscsi_conn *conn, struct iscsi_buf *buf,
1396 int *count, int *sent) 1381 int *count, int *sent)
1397{ 1382{
1398 struct socket *sk = conn->sock;
1399 int flags = 0; /* MSG_DONTWAIT; */ 1383 int flags = 0; /* MSG_DONTWAIT; */
1400 int res, size; 1384 int res, size;
1401 1385
@@ -1406,7 +1390,7 @@ iscsi_sendpage(struct iscsi_conn *conn, struct iscsi_buf *buf,
1406 if (buf->sent + size != buf->sg.length || *count != size) 1390 if (buf->sent + size != buf->sg.length || *count != size)
1407 flags |= MSG_MORE; 1391 flags |= MSG_MORE;
1408 1392
1409 res = iscsi_send(sk, buf, size, flags); 1393 res = iscsi_send(conn, buf, size, flags);
1410 debug_tcp("sendpage: %d bytes, sent %d left %d sent %d res %d\n", 1394 debug_tcp("sendpage: %d bytes, sent %d left %d sent %d res %d\n",
1411 size, buf->sent, *count, *sent, res); 1395 size, buf->sent, *count, *sent, res);
1412 if (res >= 0) { 1396 if (res >= 0) {
@@ -1434,19 +1418,6 @@ iscsi_data_digest_init(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)
1434 ctask->digest_count = 4; 1418 ctask->digest_count = 4;
1435} 1419}
1436 1420
1437static inline void
1438iscsi_buf_data_digest_update(struct iscsi_conn *conn, struct iscsi_buf *buf)
1439{
1440 struct scatterlist sg;
1441
1442 if (buf->sg.offset != -1)
1443 crypto_digest_update(conn->data_tx_tfm, &buf->sg, 1);
1444 else {
1445 sg_init_one(&sg, (char *)buf->sg.page, buf->sg.length);
1446 crypto_digest_update(conn->data_tx_tfm, &sg, 1);
1447 }
1448}
1449
1450static inline int 1421static inline int
1451iscsi_digest_final_send(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask, 1422iscsi_digest_final_send(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask,
1452 struct iscsi_buf *buf, uint32_t *digest, int final) 1423 struct iscsi_buf *buf, uint32_t *digest, int final)
@@ -1680,7 +1651,7 @@ iscsi_cmd_init(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask,
1680 zero_data(ctask->hdr.dlength); 1651 zero_data(ctask->hdr.dlength);
1681 } 1652 }
1682 1653
1683 iscsi_buf_init_virt(&ctask->headbuf, (char*)&ctask->hdr, 1654 iscsi_buf_init_virt(&ctask->headbuf, (char*)&ctask->hdr,
1684 sizeof(struct iscsi_hdr)); 1655 sizeof(struct iscsi_hdr));
1685 conn->scsicmd_pdus_cnt++; 1656 conn->scsicmd_pdus_cnt++;
1686} 1657}
@@ -1746,7 +1717,7 @@ static inline int
1746handle_xmstate_r_hdr(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask) 1717handle_xmstate_r_hdr(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)
1747{ 1718{
1748 ctask->xmstate &= ~XMSTATE_R_HDR; 1719 ctask->xmstate &= ~XMSTATE_R_HDR;
1749 if (conn->hdrdgst_en) 1720 if (conn->hdrdgst_en)
1750 iscsi_hdr_digest(conn, &ctask->headbuf, (u8*)ctask->hdrext); 1721 iscsi_hdr_digest(conn, &ctask->headbuf, (u8*)ctask->hdrext);
1751 if (!iscsi_sendhdr(conn, &ctask->headbuf, 0)) { 1722 if (!iscsi_sendhdr(conn, &ctask->headbuf, 0)) {
1752 BUG_ON(ctask->xmstate != XMSTATE_IDLE); 1723 BUG_ON(ctask->xmstate != XMSTATE_IDLE);
@@ -1760,7 +1731,7 @@ static inline int
1760handle_xmstate_w_hdr(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask) 1731handle_xmstate_w_hdr(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)
1761{ 1732{
1762 ctask->xmstate &= ~XMSTATE_W_HDR; 1733 ctask->xmstate &= ~XMSTATE_W_HDR;
1763 if (conn->hdrdgst_en) 1734 if (conn->hdrdgst_en)
1764 iscsi_hdr_digest(conn, &ctask->headbuf, (u8*)ctask->hdrext); 1735 iscsi_hdr_digest(conn, &ctask->headbuf, (u8*)ctask->hdrext);
1765 if (iscsi_sendhdr(conn, &ctask->headbuf, ctask->imm_count)) { 1736 if (iscsi_sendhdr(conn, &ctask->headbuf, ctask->imm_count)) {
1766 ctask->xmstate |= XMSTATE_W_HDR; 1737 ctask->xmstate |= XMSTATE_W_HDR;
@@ -1809,7 +1780,8 @@ handle_xmstate_imm_data(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)
1809 return -EAGAIN; 1780 return -EAGAIN;
1810 } 1781 }
1811 if (conn->datadgst_en) 1782 if (conn->datadgst_en)
1812 iscsi_buf_data_digest_update(conn, &ctask->sendbuf); 1783 crypto_digest_update(conn->data_tx_tfm,
1784 &ctask->sendbuf.sg, 1);
1813 1785
1814 if (!ctask->imm_count) 1786 if (!ctask->imm_count)
1815 break; 1787 break;
@@ -1894,7 +1866,8 @@ handle_xmstate_uns_data(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)
1894 * so pass it 1866 * so pass it
1895 */ 1867 */
1896 if (conn->datadgst_en && ctask->sent - start > 0) 1868 if (conn->datadgst_en && ctask->sent - start > 0)
1897 iscsi_buf_data_digest_update(conn, &ctask->sendbuf); 1869 crypto_digest_update(conn->data_tx_tfm,
1870 &ctask->sendbuf.sg, 1);
1898 1871
1899 if (!ctask->data_count) 1872 if (!ctask->data_count)
1900 break; 1873 break;
@@ -1972,7 +1945,7 @@ solicit_again:
1972 1945
1973 BUG_ON(r2t->data_count < 0); 1946 BUG_ON(r2t->data_count < 0);
1974 if (conn->datadgst_en) 1947 if (conn->datadgst_en)
1975 iscsi_buf_data_digest_update(conn, &r2t->sendbuf); 1948 crypto_digest_update(conn->data_tx_tfm, &r2t->sendbuf.sg, 1);
1976 1949
1977 if (r2t->data_count) { 1950 if (r2t->data_count) {
1978 BUG_ON(ctask->sc->use_sg == 0); 1951 BUG_ON(ctask->sc->use_sg == 0);
@@ -2054,7 +2027,7 @@ handle_xmstate_w_pad(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)
2054 } 2027 }
2055 2028
2056 if (conn->datadgst_en) { 2029 if (conn->datadgst_en) {
2057 iscsi_buf_data_digest_update(conn, &ctask->sendbuf); 2030 crypto_digest_update(conn->data_tx_tfm, &ctask->sendbuf.sg, 1);
2058 /* imm data? */ 2031 /* imm data? */
2059 if (!dtask) { 2032 if (!dtask) {
2060 if (iscsi_digest_final_send(conn, ctask, &ctask->immbuf, 2033 if (iscsi_digest_final_send(conn, ctask, &ctask->immbuf,
@@ -2148,7 +2121,7 @@ unsolicit_head_again:
2148solicit_head_again: 2121solicit_head_again:
2149 r2t = ctask->r2t; 2122 r2t = ctask->r2t;
2150 if (conn->hdrdgst_en) 2123 if (conn->hdrdgst_en)
2151 iscsi_hdr_digest(conn, &r2t->headbuf, 2124 iscsi_hdr_digest(conn, &r2t->headbuf,
2152 (u8*)r2t->dtask->hdrext); 2125 (u8*)r2t->dtask->hdrext);
2153 if (iscsi_sendhdr(conn, &r2t->headbuf, r2t->data_count)) { 2126 if (iscsi_sendhdr(conn, &r2t->headbuf, r2t->data_count)) {
2154 ctask->xmstate &= ~XMSTATE_SOL_DATA; 2127 ctask->xmstate &= ~XMSTATE_SOL_DATA;
@@ -2300,10 +2273,10 @@ iscsi_xmitworker(void *data)
2300 /* 2273 /*
2301 * serialize Xmit worker on a per-connection basis. 2274 * serialize Xmit worker on a per-connection basis.
2302 */ 2275 */
2303 down(&conn->xmitsema); 2276 mutex_lock(&conn->xmitmutex);
2304 if (iscsi_data_xmit(conn)) 2277 if (iscsi_data_xmit(conn))
2305 schedule_work(&conn->xmitwork); 2278 scsi_queue_work(conn->session->host, &conn->xmitwork);
2306 up(&conn->xmitsema); 2279 mutex_unlock(&conn->xmitmutex);
2307} 2280}
2308 2281
2309#define FAILURE_BAD_HOST 1 2282#define FAILURE_BAD_HOST 1
@@ -2367,15 +2340,7 @@ iscsi_queuecommand(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *))
2367 session->cmdsn, session->max_cmdsn - session->exp_cmdsn + 1); 2340 session->cmdsn, session->max_cmdsn - session->exp_cmdsn + 1);
2368 spin_unlock(&session->lock); 2341 spin_unlock(&session->lock);
2369 2342
2370 if (!in_interrupt() && !down_trylock(&conn->xmitsema)) { 2343 scsi_queue_work(host, &conn->xmitwork);
2371 spin_unlock_irq(host->host_lock);
2372 if (iscsi_data_xmit(conn))
2373 schedule_work(&conn->xmitwork);
2374 up(&conn->xmitsema);
2375 spin_lock_irq(host->host_lock);
2376 } else
2377 schedule_work(&conn->xmitwork);
2378
2379 return 0; 2344 return 0;
2380 2345
2381reject: 2346reject:
@@ -2462,17 +2427,20 @@ iscsi_pool_free(struct iscsi_queue *q, void **items)
2462 kfree(items); 2427 kfree(items);
2463} 2428}
2464 2429
2465static iscsi_connh_t 2430static struct iscsi_cls_conn *
2466iscsi_conn_create(iscsi_sessionh_t sessionh, uint32_t conn_idx) 2431iscsi_conn_create(struct Scsi_Host *shost, uint32_t conn_idx)
2467{ 2432{
2468 struct iscsi_session *session = iscsi_ptr(sessionh); 2433 struct iscsi_session *session = iscsi_hostdata(shost->hostdata);
2469 struct iscsi_conn *conn = NULL; 2434 struct iscsi_conn *conn;
2435 struct iscsi_cls_conn *cls_conn;
2470 2436
2471 conn = kmalloc(sizeof(struct iscsi_conn), GFP_KERNEL); 2437 cls_conn = iscsi_create_conn(hostdata_session(shost->hostdata),
2472 if (conn == NULL) 2438 conn_idx);
2473 goto conn_alloc_fail; 2439 if (!cls_conn)
2474 memset(conn, 0, sizeof(struct iscsi_conn)); 2440 return NULL;
2441 conn = cls_conn->dd_data;
2475 2442
2443 memset(conn, 0, sizeof(struct iscsi_conn));
2476 conn->c_stage = ISCSI_CONN_INITIAL_STAGE; 2444 conn->c_stage = ISCSI_CONN_INITIAL_STAGE;
2477 conn->in_progress = IN_PROGRESS_WAIT_HEADER; 2445 conn->in_progress = IN_PROGRESS_WAIT_HEADER;
2478 conn->id = conn_idx; 2446 conn->id = conn_idx;
@@ -2531,10 +2499,10 @@ iscsi_conn_create(iscsi_sessionh_t sessionh, uint32_t conn_idx)
2531 goto max_recv_dlenght_alloc_fail; 2499 goto max_recv_dlenght_alloc_fail;
2532 2500
2533 init_timer(&conn->tmabort_timer); 2501 init_timer(&conn->tmabort_timer);
2534 init_MUTEX(&conn->xmitsema); 2502 mutex_init(&conn->xmitmutex);
2535 init_waitqueue_head(&conn->ehwait); 2503 init_waitqueue_head(&conn->ehwait);
2536 2504
2537 return iscsi_handle(conn); 2505 return cls_conn;
2538 2506
2539max_recv_dlenght_alloc_fail: 2507max_recv_dlenght_alloc_fail:
2540 spin_lock_bh(&session->lock); 2508 spin_lock_bh(&session->lock);
@@ -2550,18 +2518,18 @@ immqueue_alloc_fail:
2550writequeue_alloc_fail: 2518writequeue_alloc_fail:
2551 kfifo_free(conn->xmitqueue); 2519 kfifo_free(conn->xmitqueue);
2552xmitqueue_alloc_fail: 2520xmitqueue_alloc_fail:
2553 kfree(conn); 2521 iscsi_destroy_conn(cls_conn);
2554conn_alloc_fail: 2522 return NULL;
2555 return iscsi_handle(NULL);
2556} 2523}
2557 2524
2558static void 2525static void
2559iscsi_conn_destroy(iscsi_connh_t connh) 2526iscsi_conn_destroy(struct iscsi_cls_conn *cls_conn)
2560{ 2527{
2561 struct iscsi_conn *conn = iscsi_ptr(connh); 2528 struct iscsi_conn *conn = cls_conn->dd_data;
2562 struct iscsi_session *session = conn->session; 2529 struct iscsi_session *session = conn->session;
2530 unsigned long flags;
2563 2531
2564 down(&conn->xmitsema); 2532 mutex_lock(&conn->xmitmutex);
2565 set_bit(SUSPEND_BIT, &conn->suspend_tx); 2533 set_bit(SUSPEND_BIT, &conn->suspend_tx);
2566 if (conn->c_stage == ISCSI_CONN_INITIAL_STAGE && conn->sock) { 2534 if (conn->c_stage == ISCSI_CONN_INITIAL_STAGE && conn->sock) {
2567 struct sock *sk = conn->sock->sk; 2535 struct sock *sk = conn->sock->sk;
@@ -2592,19 +2560,19 @@ iscsi_conn_destroy(iscsi_connh_t connh)
2592 } 2560 }
2593 spin_unlock_bh(&session->lock); 2561 spin_unlock_bh(&session->lock);
2594 2562
2595 up(&conn->xmitsema); 2563 mutex_unlock(&conn->xmitmutex);
2596 2564
2597 /* 2565 /*
2598 * Block until all in-progress commands for this connection 2566 * Block until all in-progress commands for this connection
2599 * time out or fail. 2567 * time out or fail.
2600 */ 2568 */
2601 for (;;) { 2569 for (;;) {
2602 spin_lock_bh(&conn->lock); 2570 spin_lock_irqsave(session->host->host_lock, flags);
2603 if (!session->host->host_busy) { /* OK for ERL == 0 */ 2571 if (!session->host->host_busy) { /* OK for ERL == 0 */
2604 spin_unlock_bh(&conn->lock); 2572 spin_unlock_irqrestore(session->host->host_lock, flags);
2605 break; 2573 break;
2606 } 2574 }
2607 spin_unlock_bh(&conn->lock); 2575 spin_unlock_irqrestore(session->host->host_lock, flags);
2608 msleep_interruptible(500); 2576 msleep_interruptible(500);
2609 printk("conn_destroy(): host_busy %d host_failed %d\n", 2577 printk("conn_destroy(): host_busy %d host_failed %d\n",
2610 session->host->host_busy, session->host->host_failed); 2578 session->host->host_busy, session->host->host_failed);
@@ -2652,7 +2620,8 @@ iscsi_conn_destroy(iscsi_connh_t connh)
2652 kfifo_free(conn->writequeue); 2620 kfifo_free(conn->writequeue);
2653 kfifo_free(conn->immqueue); 2621 kfifo_free(conn->immqueue);
2654 kfifo_free(conn->mgmtqueue); 2622 kfifo_free(conn->mgmtqueue);
2655 kfree(conn); 2623
2624 iscsi_destroy_conn(cls_conn);
2656} 2625}
2657 2626
2658static int 2627static int
@@ -2713,6 +2682,8 @@ iscsi_conn_bind(iscsi_sessionh_t sessionh, iscsi_connh_t connh,
2713 */ 2682 */
2714 iscsi_conn_set_callbacks(conn); 2683 iscsi_conn_set_callbacks(conn);
2715 2684
2685 conn->sendpage = conn->sock->ops->sendpage;
2686
2716 /* 2687 /*
2717 * set receive state machine into initial state 2688 * set receive state machine into initial state
2718 */ 2689 */
@@ -2796,7 +2767,7 @@ iscsi_conn_stop(iscsi_connh_t connh, int flag)
2796 set_bit(SUSPEND_BIT, &conn->suspend_rx); 2767 set_bit(SUSPEND_BIT, &conn->suspend_rx);
2797 write_unlock_bh(&sk->sk_callback_lock); 2768 write_unlock_bh(&sk->sk_callback_lock);
2798 2769
2799 down(&conn->xmitsema); 2770 mutex_lock(&conn->xmitmutex);
2800 2771
2801 spin_lock_irqsave(session->host->host_lock, flags); 2772 spin_lock_irqsave(session->host->host_lock, flags);
2802 spin_lock(&session->lock); 2773 spin_lock(&session->lock);
@@ -2878,7 +2849,7 @@ iscsi_conn_stop(iscsi_connh_t connh, int flag)
2878 conn->datadgst_en = 0; 2849 conn->datadgst_en = 0;
2879 } 2850 }
2880 } 2851 }
2881 up(&conn->xmitsema); 2852 mutex_unlock(&conn->xmitmutex);
2882} 2853}
2883 2854
2884static int 2855static int
@@ -2963,8 +2934,7 @@ iscsi_conn_send_generic(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
2963 else 2934 else
2964 __kfifo_put(conn->mgmtqueue, (void*)&mtask, sizeof(void*)); 2935 __kfifo_put(conn->mgmtqueue, (void*)&mtask, sizeof(void*));
2965 2936
2966 schedule_work(&conn->xmitwork); 2937 scsi_queue_work(session->host, &conn->xmitwork);
2967
2968 return 0; 2938 return 0;
2969} 2939}
2970 2940
@@ -3029,12 +2999,12 @@ iscsi_eh_abort(struct scsi_cmnd *sc)
3029 * 1) connection-level failure; 2999 * 1) connection-level failure;
3030 * 2) recovery due protocol error; 3000 * 2) recovery due protocol error;
3031 */ 3001 */
3032 down(&conn->xmitsema); 3002 mutex_lock(&conn->xmitmutex);
3033 spin_lock_bh(&session->lock); 3003 spin_lock_bh(&session->lock);
3034 if (session->state != ISCSI_STATE_LOGGED_IN) { 3004 if (session->state != ISCSI_STATE_LOGGED_IN) {
3035 if (session->state == ISCSI_STATE_TERMINATE) { 3005 if (session->state == ISCSI_STATE_TERMINATE) {
3036 spin_unlock_bh(&session->lock); 3006 spin_unlock_bh(&session->lock);
3037 up(&conn->xmitsema); 3007 mutex_unlock(&conn->xmitmutex);
3038 goto failed; 3008 goto failed;
3039 } 3009 }
3040 spin_unlock_bh(&session->lock); 3010 spin_unlock_bh(&session->lock);
@@ -3052,7 +3022,7 @@ iscsi_eh_abort(struct scsi_cmnd *sc)
3052 * 2) session was re-open during time out of ctask. 3022 * 2) session was re-open during time out of ctask.
3053 */ 3023 */
3054 spin_unlock_bh(&session->lock); 3024 spin_unlock_bh(&session->lock);
3055 up(&conn->xmitsema); 3025 mutex_unlock(&conn->xmitmutex);
3056 goto success; 3026 goto success;
3057 } 3027 }
3058 conn->tmabort_state = TMABORT_INITIAL; 3028 conn->tmabort_state = TMABORT_INITIAL;
@@ -3107,7 +3077,7 @@ iscsi_eh_abort(struct scsi_cmnd *sc)
3107 conn->tmabort_state == TMABORT_SUCCESS) { 3077 conn->tmabort_state == TMABORT_SUCCESS) {
3108 conn->tmabort_state = TMABORT_INITIAL; 3078 conn->tmabort_state = TMABORT_INITIAL;
3109 spin_unlock_bh(&session->lock); 3079 spin_unlock_bh(&session->lock);
3110 up(&conn->xmitsema); 3080 mutex_unlock(&conn->xmitmutex);
3111 goto success; 3081 goto success;
3112 } 3082 }
3113 conn->tmabort_state = TMABORT_INITIAL; 3083 conn->tmabort_state = TMABORT_INITIAL;
@@ -3116,7 +3086,7 @@ iscsi_eh_abort(struct scsi_cmnd *sc)
3116 spin_unlock_bh(&session->lock); 3086 spin_unlock_bh(&session->lock);
3117 } 3087 }
3118 } 3088 }
3119 up(&conn->xmitsema); 3089 mutex_unlock(&conn->xmitmutex);
3120 3090
3121 3091
3122 /* 3092 /*
@@ -3182,7 +3152,7 @@ failed:
3182exit: 3152exit:
3183 del_timer_sync(&conn->tmabort_timer); 3153 del_timer_sync(&conn->tmabort_timer);
3184 3154
3185 down(&conn->xmitsema); 3155 mutex_lock(&conn->xmitmutex);
3186 if (conn->sock) { 3156 if (conn->sock) {
3187 struct sock *sk = conn->sock->sk; 3157 struct sock *sk = conn->sock->sk;
3188 3158
@@ -3190,7 +3160,7 @@ exit:
3190 iscsi_ctask_cleanup(conn, ctask); 3160 iscsi_ctask_cleanup(conn, ctask);
3191 write_unlock_bh(&sk->sk_callback_lock); 3161 write_unlock_bh(&sk->sk_callback_lock);
3192 } 3162 }
3193 up(&conn->xmitsema); 3163 mutex_unlock(&conn->xmitmutex);
3194 return rc; 3164 return rc;
3195} 3165}
3196 3166
@@ -3281,17 +3251,23 @@ static struct scsi_host_template iscsi_sht = {
3281 .this_id = -1, 3251 .this_id = -1,
3282}; 3252};
3283 3253
3284static iscsi_sessionh_t 3254static struct iscsi_transport iscsi_tcp_transport;
3285iscsi_session_create(uint32_t initial_cmdsn, struct Scsi_Host *host) 3255
3256static struct Scsi_Host *
3257iscsi_session_create(struct scsi_transport_template *scsit,
3258 uint32_t initial_cmdsn)
3286{ 3259{
3287 int cmd_i; 3260 struct Scsi_Host *shost;
3288 struct iscsi_session *session; 3261 struct iscsi_session *session;
3262 int cmd_i;
3289 3263
3290 session = iscsi_hostdata(host->hostdata); 3264 shost = iscsi_transport_create_session(scsit, &iscsi_tcp_transport);
3291 memset(session, 0, sizeof(struct iscsi_session)); 3265 if (!shost)
3266 return NULL;
3292 3267
3293 session->host = host; 3268 session = iscsi_hostdata(shost->hostdata);
3294 session->id = host->host_no; 3269 memset(session, 0, sizeof(struct iscsi_session));
3270 session->host = shost;
3295 session->state = ISCSI_STATE_LOGGED_IN; 3271 session->state = ISCSI_STATE_LOGGED_IN;
3296 session->mgmtpool_max = ISCSI_MGMT_CMDS_MAX; 3272 session->mgmtpool_max = ISCSI_MGMT_CMDS_MAX;
3297 session->cmds_max = ISCSI_XMIT_CMDS_MAX; 3273 session->cmds_max = ISCSI_XMIT_CMDS_MAX;
@@ -3335,7 +3311,7 @@ iscsi_session_create(uint32_t initial_cmdsn, struct Scsi_Host *host)
3335 if (iscsi_r2tpool_alloc(session)) 3311 if (iscsi_r2tpool_alloc(session))
3336 goto r2tpool_alloc_fail; 3312 goto r2tpool_alloc_fail;
3337 3313
3338 return iscsi_handle(session); 3314 return shost;
3339 3315
3340r2tpool_alloc_fail: 3316r2tpool_alloc_fail:
3341 for (cmd_i = 0; cmd_i < session->mgmtpool_max; cmd_i++) 3317 for (cmd_i = 0; cmd_i < session->mgmtpool_max; cmd_i++)
@@ -3345,15 +3321,15 @@ immdata_alloc_fail:
3345mgmtpool_alloc_fail: 3321mgmtpool_alloc_fail:
3346 iscsi_pool_free(&session->cmdpool, (void**)session->cmds); 3322 iscsi_pool_free(&session->cmdpool, (void**)session->cmds);
3347cmdpool_alloc_fail: 3323cmdpool_alloc_fail:
3348 return iscsi_handle(NULL); 3324 return NULL;
3349} 3325}
3350 3326
3351static void 3327static void
3352iscsi_session_destroy(iscsi_sessionh_t sessionh) 3328iscsi_session_destroy(struct Scsi_Host *shost)
3353{ 3329{
3330 struct iscsi_session *session = iscsi_hostdata(shost->hostdata);
3354 int cmd_i; 3331 int cmd_i;
3355 struct iscsi_data_task *dtask, *n; 3332 struct iscsi_data_task *dtask, *n;
3356 struct iscsi_session *session = iscsi_ptr(sessionh);
3357 3333
3358 for (cmd_i = 0; cmd_i < session->cmds_max; cmd_i++) { 3334 for (cmd_i = 0; cmd_i < session->cmds_max; cmd_i++) {
3359 struct iscsi_cmd_task *ctask = session->cmds[cmd_i]; 3335 struct iscsi_cmd_task *ctask = session->cmds[cmd_i];
@@ -3369,6 +3345,8 @@ iscsi_session_destroy(iscsi_sessionh_t sessionh)
3369 iscsi_r2tpool_free(session); 3345 iscsi_r2tpool_free(session);
3370 iscsi_pool_free(&session->mgmtpool, (void**)session->mgmt_cmds); 3346 iscsi_pool_free(&session->mgmtpool, (void**)session->mgmt_cmds);
3371 iscsi_pool_free(&session->cmdpool, (void**)session->cmds); 3347 iscsi_pool_free(&session->cmdpool, (void**)session->cmds);
3348
3349 iscsi_transport_destroy_session(shost);
3372} 3350}
3373 3351
3374static int 3352static int
@@ -3467,6 +3445,8 @@ iscsi_conn_set_param(iscsi_connh_t connh, enum iscsi_param param,
3467 if (conn->data_rx_tfm) 3445 if (conn->data_rx_tfm)
3468 crypto_free_tfm(conn->data_rx_tfm); 3446 crypto_free_tfm(conn->data_rx_tfm);
3469 } 3447 }
3448 conn->sendpage = conn->datadgst_en ?
3449 sock_no_sendpage : conn->sock->ops->sendpage;
3470 break; 3450 break;
3471 case ISCSI_PARAM_INITIAL_R2T_EN: 3451 case ISCSI_PARAM_INITIAL_R2T_EN:
3472 session->initial_r2t_en = value; 3452 session->initial_r2t_en = value;
@@ -3515,25 +3495,12 @@ iscsi_conn_set_param(iscsi_connh_t connh, enum iscsi_param param,
3515} 3495}
3516 3496
3517static int 3497static int
3518iscsi_conn_get_param(iscsi_connh_t connh, enum iscsi_param param, 3498iscsi_session_get_param(struct Scsi_Host *shost,
3519 uint32_t *value) 3499 enum iscsi_param param, uint32_t *value)
3520{ 3500{
3521 struct iscsi_conn *conn = iscsi_ptr(connh); 3501 struct iscsi_session *session = iscsi_hostdata(shost->hostdata);
3522 struct iscsi_session *session = conn->session;
3523 3502
3524 switch(param) { 3503 switch(param) {
3525 case ISCSI_PARAM_MAX_RECV_DLENGTH:
3526 *value = conn->max_recv_dlength;
3527 break;
3528 case ISCSI_PARAM_MAX_XMIT_DLENGTH:
3529 *value = conn->max_xmit_dlength;
3530 break;
3531 case ISCSI_PARAM_HDRDGST_EN:
3532 *value = conn->hdrdgst_en;
3533 break;
3534 case ISCSI_PARAM_DATADGST_EN:
3535 *value = conn->datadgst_en;
3536 break;
3537 case ISCSI_PARAM_INITIAL_R2T_EN: 3504 case ISCSI_PARAM_INITIAL_R2T_EN:
3538 *value = session->initial_r2t_en; 3505 *value = session->initial_r2t_en;
3539 break; 3506 break;
@@ -3571,6 +3538,31 @@ iscsi_conn_get_param(iscsi_connh_t connh, enum iscsi_param param,
3571 return 0; 3538 return 0;
3572} 3539}
3573 3540
3541static int
3542iscsi_conn_get_param(void *data, enum iscsi_param param, uint32_t *value)
3543{
3544 struct iscsi_conn *conn = data;
3545
3546 switch(param) {
3547 case ISCSI_PARAM_MAX_RECV_DLENGTH:
3548 *value = conn->max_recv_dlength;
3549 break;
3550 case ISCSI_PARAM_MAX_XMIT_DLENGTH:
3551 *value = conn->max_xmit_dlength;
3552 break;
3553 case ISCSI_PARAM_HDRDGST_EN:
3554 *value = conn->hdrdgst_en;
3555 break;
3556 case ISCSI_PARAM_DATADGST_EN:
3557 *value = conn->datadgst_en;
3558 break;
3559 default:
3560 return ISCSI_ERR_PARAM_NOT_FOUND;
3561 }
3562
3563 return 0;
3564}
3565
3574static void 3566static void
3575iscsi_conn_get_stats(iscsi_connh_t connh, struct iscsi_stats *stats) 3567iscsi_conn_get_stats(iscsi_connh_t connh, struct iscsi_stats *stats)
3576{ 3568{
@@ -3601,9 +3593,9 @@ iscsi_conn_send_pdu(iscsi_connh_t connh, struct iscsi_hdr *hdr, char *data,
3601 struct iscsi_conn *conn = iscsi_ptr(connh); 3593 struct iscsi_conn *conn = iscsi_ptr(connh);
3602 int rc; 3594 int rc;
3603 3595
3604 down(&conn->xmitsema); 3596 mutex_lock(&conn->xmitmutex);
3605 rc = iscsi_conn_send_generic(conn, hdr, data, data_size); 3597 rc = iscsi_conn_send_generic(conn, hdr, data, data_size);
3606 up(&conn->xmitsema); 3598 mutex_unlock(&conn->xmitmutex);
3607 3599
3608 return rc; 3600 return rc;
3609} 3601}
@@ -3615,6 +3607,7 @@ static struct iscsi_transport iscsi_tcp_transport = {
3615 | CAP_DATADGST, 3607 | CAP_DATADGST,
3616 .host_template = &iscsi_sht, 3608 .host_template = &iscsi_sht,
3617 .hostdata_size = sizeof(struct iscsi_session), 3609 .hostdata_size = sizeof(struct iscsi_session),
3610 .conndata_size = sizeof(struct iscsi_conn),
3618 .max_conn = 1, 3611 .max_conn = 1,
3619 .max_cmd_len = ISCSI_TCP_MAX_CMD_LEN, 3612 .max_cmd_len = ISCSI_TCP_MAX_CMD_LEN,
3620 .create_session = iscsi_session_create, 3613 .create_session = iscsi_session_create,
@@ -3623,7 +3616,8 @@ static struct iscsi_transport iscsi_tcp_transport = {
3623 .bind_conn = iscsi_conn_bind, 3616 .bind_conn = iscsi_conn_bind,
3624 .destroy_conn = iscsi_conn_destroy, 3617 .destroy_conn = iscsi_conn_destroy,
3625 .set_param = iscsi_conn_set_param, 3618 .set_param = iscsi_conn_set_param,
3626 .get_param = iscsi_conn_get_param, 3619 .get_conn_param = iscsi_conn_get_param,
3620 .get_session_param = iscsi_session_get_param,
3627 .start_conn = iscsi_conn_start, 3621 .start_conn = iscsi_conn_start,
3628 .stop_conn = iscsi_conn_stop, 3622 .stop_conn = iscsi_conn_stop,
3629 .send_pdu = iscsi_conn_send_pdu, 3623 .send_pdu = iscsi_conn_send_pdu,
@@ -3633,8 +3627,6 @@ static struct iscsi_transport iscsi_tcp_transport = {
3633static int __init 3627static int __init
3634iscsi_tcp_init(void) 3628iscsi_tcp_init(void)
3635{ 3629{
3636 int error;
3637
3638 if (iscsi_max_lun < 1) { 3630 if (iscsi_max_lun < 1) {
3639 printk(KERN_ERR "Invalid max_lun value of %u\n", iscsi_max_lun); 3631 printk(KERN_ERR "Invalid max_lun value of %u\n", iscsi_max_lun);
3640 return -EINVAL; 3632 return -EINVAL;
@@ -3647,11 +3639,10 @@ iscsi_tcp_init(void)
3647 if (!taskcache) 3639 if (!taskcache)
3648 return -ENOMEM; 3640 return -ENOMEM;
3649 3641
3650 error = iscsi_register_transport(&iscsi_tcp_transport); 3642 if (!iscsi_register_transport(&iscsi_tcp_transport))
3651 if (error)
3652 kmem_cache_destroy(taskcache); 3643 kmem_cache_destroy(taskcache);
3653 3644
3654 return error; 3645 return 0;
3655} 3646}
3656 3647
3657static void __exit 3648static void __exit
diff --git a/drivers/scsi/iscsi_tcp.h b/drivers/scsi/iscsi_tcp.h
index 855f2dfd18af..f95e61b76f70 100644
--- a/drivers/scsi/iscsi_tcp.h
+++ b/drivers/scsi/iscsi_tcp.h
@@ -158,7 +158,7 @@ struct iscsi_conn {
158 struct kfifo *mgmtqueue; /* mgmt (control) xmit queue */ 158 struct kfifo *mgmtqueue; /* mgmt (control) xmit queue */
159 struct kfifo *xmitqueue; /* data-path cmd queue */ 159 struct kfifo *xmitqueue; /* data-path cmd queue */
160 struct work_struct xmitwork; /* per-conn. xmit workqueue */ 160 struct work_struct xmitwork; /* per-conn. xmit workqueue */
161 struct semaphore xmitsema; /* serializes connection xmit, 161 struct mutex xmitmutex; /* serializes connection xmit,
162 * access to kfifos: * 162 * access to kfifos: *
163 * xmitqueue, writequeue, * 163 * xmitqueue, writequeue, *
164 * immqueue, mgmtqueue */ 164 * immqueue, mgmtqueue */
@@ -191,6 +191,8 @@ struct iscsi_conn {
191 uint32_t sendpage_failures_cnt; 191 uint32_t sendpage_failures_cnt;
192 uint32_t discontiguous_hdr_cnt; 192 uint32_t discontiguous_hdr_cnt;
193 uint32_t eh_abort_cnt; 193 uint32_t eh_abort_cnt;
194
195 ssize_t (*sendpage)(struct socket *, struct page *, int, size_t, int);
194}; 196};
195 197
196struct iscsi_session { 198struct iscsi_session {
@@ -240,8 +242,8 @@ struct iscsi_session {
240 242
241struct iscsi_buf { 243struct iscsi_buf {
242 struct scatterlist sg; 244 struct scatterlist sg;
243 struct kvec iov;
244 unsigned int sent; 245 unsigned int sent;
246 char use_sendmsg;
245}; 247};
246 248
247struct iscsi_data_task { 249struct iscsi_data_task {
diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
index 9ee8218404c0..dafabeefc5b3 100644
--- a/drivers/scsi/lpfc/lpfc_scsi.c
+++ b/drivers/scsi/lpfc/lpfc_scsi.c
@@ -150,7 +150,7 @@ lpfc_new_scsi_buf(struct lpfc_hba * phba)
150 return psb; 150 return psb;
151} 151}
152 152
153struct lpfc_scsi_buf* 153static struct lpfc_scsi_buf*
154lpfc_get_scsi_buf(struct lpfc_hba * phba) 154lpfc_get_scsi_buf(struct lpfc_hba * phba)
155{ 155{
156 struct lpfc_scsi_buf * lpfc_cmd = NULL; 156 struct lpfc_scsi_buf * lpfc_cmd = NULL;
diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
index 4a6feb1e5e3d..d101a8a6f4e8 100644
--- a/drivers/scsi/megaraid.c
+++ b/drivers/scsi/megaraid.c
@@ -4479,7 +4479,7 @@ mega_internal_command(adapter_t *adapter, megacmd_t *mc, mega_passthru *pthru)
4479 * serialized. This is so because we want to reserve maximum number of 4479 * serialized. This is so because we want to reserve maximum number of
4480 * available command ids for the I/O commands. 4480 * available command ids for the I/O commands.
4481 */ 4481 */
4482 down(&adapter->int_mtx); 4482 mutex_lock(&adapter->int_mtx);
4483 4483
4484 scb = &adapter->int_scb; 4484 scb = &adapter->int_scb;
4485 memset(scb, 0, sizeof(scb_t)); 4485 memset(scb, 0, sizeof(scb_t));
@@ -4527,7 +4527,7 @@ mega_internal_command(adapter_t *adapter, megacmd_t *mc, mega_passthru *pthru)
4527 mc->cmd, mc->opcode, mc->subopcode, scmd->result); 4527 mc->cmd, mc->opcode, mc->subopcode, scmd->result);
4528 } 4528 }
4529 4529
4530 up(&adapter->int_mtx); 4530 mutex_unlock(&adapter->int_mtx);
4531 4531
4532 return rval; 4532 return rval;
4533} 4533}
@@ -4866,7 +4866,7 @@ megaraid_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
4866 adapter->has_64bit_addr = 0; 4866 adapter->has_64bit_addr = 0;
4867 } 4867 }
4868 4868
4869 init_MUTEX(&adapter->int_mtx); 4869 mutex_init(&adapter->int_mtx);
4870 init_completion(&adapter->int_waitq); 4870 init_completion(&adapter->int_waitq);
4871 4871
4872 adapter->this_id = DEFAULT_INITIATOR_ID; 4872 adapter->this_id = DEFAULT_INITIATOR_ID;
diff --git a/drivers/scsi/megaraid.h b/drivers/scsi/megaraid.h
index 6f9078025748..4b3e0d6e5afa 100644
--- a/drivers/scsi/megaraid.h
+++ b/drivers/scsi/megaraid.h
@@ -2,7 +2,7 @@
2#define __MEGARAID_H__ 2#define __MEGARAID_H__
3 3
4#include <linux/spinlock.h> 4#include <linux/spinlock.h>
5 5#include <linux/mutex.h>
6 6
7#define MEGARAID_VERSION \ 7#define MEGARAID_VERSION \
8 "v2.00.3 (Release Date: Wed Feb 19 08:51:30 EST 2003)\n" 8 "v2.00.3 (Release Date: Wed Feb 19 08:51:30 EST 2003)\n"
@@ -889,7 +889,7 @@ typedef struct {
889 889
890 scb_t int_scb; 890 scb_t int_scb;
891 Scsi_Cmnd int_scmd; 891 Scsi_Cmnd int_scmd;
892 struct semaphore int_mtx; /* To synchronize the internal 892 struct mutex int_mtx; /* To synchronize the internal
893 commands */ 893 commands */
894 struct completion int_waitq; /* wait queue for internal 894 struct completion int_waitq; /* wait queue for internal
895 cmds */ 895 cmds */
diff --git a/drivers/scsi/megaraid/megaraid_sas.c b/drivers/scsi/megaraid/megaraid_sas.c
index 3c32e69afcd9..c0bb8061401f 100644
--- a/drivers/scsi/megaraid/megaraid_sas.c
+++ b/drivers/scsi/megaraid/megaraid_sas.c
@@ -35,6 +35,7 @@
35#include <asm/uaccess.h> 35#include <asm/uaccess.h>
36#include <linux/fs.h> 36#include <linux/fs.h>
37#include <linux/compat.h> 37#include <linux/compat.h>
38#include <linux/mutex.h>
38 39
39#include <scsi/scsi.h> 40#include <scsi/scsi.h>
40#include <scsi/scsi_cmnd.h> 41#include <scsi/scsi_cmnd.h>
@@ -72,7 +73,7 @@ MODULE_DEVICE_TABLE(pci, megasas_pci_table);
72static int megasas_mgmt_majorno; 73static int megasas_mgmt_majorno;
73static struct megasas_mgmt_info megasas_mgmt_info; 74static struct megasas_mgmt_info megasas_mgmt_info;
74static struct fasync_struct *megasas_async_queue; 75static struct fasync_struct *megasas_async_queue;
75static DECLARE_MUTEX(megasas_async_queue_mutex); 76static DEFINE_MUTEX(megasas_async_queue_mutex);
76 77
77/** 78/**
78 * megasas_get_cmd - Get a command from the free pool 79 * megasas_get_cmd - Get a command from the free pool
@@ -2362,11 +2363,11 @@ static int megasas_mgmt_fasync(int fd, struct file *filep, int mode)
2362{ 2363{
2363 int rc; 2364 int rc;
2364 2365
2365 down(&megasas_async_queue_mutex); 2366 mutex_lock(&megasas_async_queue_mutex);
2366 2367
2367 rc = fasync_helper(fd, filep, mode, &megasas_async_queue); 2368 rc = fasync_helper(fd, filep, mode, &megasas_async_queue);
2368 2369
2369 up(&megasas_async_queue_mutex); 2370 mutex_unlock(&megasas_async_queue_mutex);
2370 2371
2371 if (rc >= 0) { 2372 if (rc >= 0) {
2372 /* For sanity check when we get ioctl */ 2373 /* For sanity check when we get ioctl */
diff --git a/drivers/scsi/qla2xxx/Kconfig b/drivers/scsi/qla2xxx/Kconfig
index 5205c4e7d6ff..5758b2566d7f 100644
--- a/drivers/scsi/qla2xxx/Kconfig
+++ b/drivers/scsi/qla2xxx/Kconfig
@@ -1,4 +1,4 @@
1config SCSI_QLA2XXX 1config SCSI_QLA_FC
2 tristate "QLogic QLA2XXX Fibre Channel Support" 2 tristate "QLogic QLA2XXX Fibre Channel Support"
3 depends on PCI && SCSI 3 depends on PCI && SCSI
4 select SCSI_FC_ATTRS 4 select SCSI_FC_ATTRS
@@ -22,49 +22,57 @@ config SCSI_QLA2XXX
22 Upon request, the driver caches the firmware image until 22 Upon request, the driver caches the firmware image until
23 the driver is unloaded. 23 the driver is unloaded.
24 24
25 Firmware images can be retrieved from:
26
27 ftp://ftp.qlogic.com/outgoing/linux/firmware/
28
25 NOTE: The original method of building firmware-loader 29 NOTE: The original method of building firmware-loader
26 modules has been deprecated as the firmware-images will 30 modules has been deprecated as the firmware-images will
27 be removed from the kernel sources. 31 be removed from the kernel sources.
28 32
29config SCSI_QLA2XXX_EMBEDDED_FIRMWARE 33config SCSI_QLA2XXX_EMBEDDED_FIRMWARE
30 bool " Use firmware-loader modules (DEPRECATED)" 34 bool " Use firmware-loader modules (DEPRECATED)"
31 depends on SCSI_QLA2XXX 35 depends on SCSI_QLA_FC
36 help
37 This option offers you the deprecated firmware-loader
38 modules that have been obsoleted by the usage of the
39 Firmware Loader interface in the qla2xxx driver.
32 40
33config SCSI_QLA21XX 41config SCSI_QLA21XX
34 tristate " Build QLogic ISP2100 firmware-module" 42 tristate " Build QLogic ISP2100 firmware-module"
35 depends on SCSI_QLA2XXX_EMBEDDED_FIRMWARE 43 depends on SCSI_QLA_FC && SCSI_QLA2XXX_EMBEDDED_FIRMWARE
36 ---help--- 44 ---help---
37 This driver supports the QLogic 21xx (ISP2100) host adapter family. 45 This driver supports the QLogic 21xx (ISP2100) host adapter family.
38 46
39config SCSI_QLA22XX 47config SCSI_QLA22XX
40 tristate " Build QLogic ISP2200 firmware-module" 48 tristate " Build QLogic ISP2200 firmware-module"
41 depends on SCSI_QLA2XXX_EMBEDDED_FIRMWARE 49 depends on SCSI_QLA_FC && SCSI_QLA2XXX_EMBEDDED_FIRMWARE
42 ---help--- 50 ---help---
43 This driver supports the QLogic 22xx (ISP2200) host adapter family. 51 This driver supports the QLogic 22xx (ISP2200) host adapter family.
44 52
45config SCSI_QLA2300 53config SCSI_QLA2300
46 tristate " Build QLogic ISP2300 firmware-module" 54 tristate " Build QLogic ISP2300 firmware-module"
47 depends on SCSI_QLA2XXX_EMBEDDED_FIRMWARE 55 depends on SCSI_QLA_FC && SCSI_QLA2XXX_EMBEDDED_FIRMWARE
48 ---help--- 56 ---help---
49 This driver supports the QLogic 2300 (ISP2300 and ISP2312) host 57 This driver supports the QLogic 2300 (ISP2300 and ISP2312) host
50 adapter family. 58 adapter family.
51 59
52config SCSI_QLA2322 60config SCSI_QLA2322
53 tristate " Build QLogic ISP2322 firmware-module" 61 tristate " Build QLogic ISP2322 firmware-module"
54 depends on SCSI_QLA2XXX_EMBEDDED_FIRMWARE 62 depends on SCSI_QLA_FC && SCSI_QLA2XXX_EMBEDDED_FIRMWARE
55 ---help--- 63 ---help---
56 This driver supports the QLogic 2322 (ISP2322) host adapter family. 64 This driver supports the QLogic 2322 (ISP2322) host adapter family.
57 65
58config SCSI_QLA6312 66config SCSI_QLA6312
59 tristate " Build QLogic ISP63xx firmware-module" 67 tristate " Build QLogic ISP63xx firmware-module"
60 depends on SCSI_QLA2XXX_EMBEDDED_FIRMWARE 68 depends on SCSI_QLA_FC && SCSI_QLA2XXX_EMBEDDED_FIRMWARE
61 ---help--- 69 ---help---
62 This driver supports the QLogic 63xx (ISP6312 and ISP6322) host 70 This driver supports the QLogic 63xx (ISP6312 and ISP6322) host
63 adapter family. 71 adapter family.
64 72
65config SCSI_QLA24XX 73config SCSI_QLA24XX
66 tristate " Build QLogic ISP24xx firmware-module" 74 tristate " Build QLogic ISP24xx firmware-module"
67 depends on SCSI_QLA2XXX_EMBEDDED_FIRMWARE 75 depends on SCSI_QLA_FC && SCSI_QLA2XXX_EMBEDDED_FIRMWARE
68 ---help--- 76 ---help---
69 This driver supports the QLogic 24xx (ISP2422 and ISP2432) host 77 This driver supports the QLogic 24xx (ISP2422 and ISP2432) host
70 adapter family. 78 adapter family.
diff --git a/drivers/scsi/qla2xxx/Makefile b/drivers/scsi/qla2xxx/Makefile
index 40c0de125889..d028bc50ccf7 100644
--- a/drivers/scsi/qla2xxx/Makefile
+++ b/drivers/scsi/qla2xxx/Makefile
@@ -3,7 +3,7 @@ EXTRA_CFLAGS += -DUNIQUE_FW_NAME
3qla2xxx-y := qla_os.o qla_init.o qla_mbx.o qla_iocb.o qla_isr.o qla_gs.o \ 3qla2xxx-y := qla_os.o qla_init.o qla_mbx.o qla_iocb.o qla_isr.o qla_gs.o \
4 qla_dbg.o qla_sup.o qla_rscn.o qla_attr.o 4 qla_dbg.o qla_sup.o qla_rscn.o qla_attr.o
5 5
6obj-$(CONFIG_SCSI_QLA2XXX) += qla2xxx.o 6obj-$(CONFIG_SCSI_QLA_FC) += qla2xxx.o
7 7
8qla2100-y := ql2100.o ql2100_fw.o 8qla2100-y := ql2100.o ql2100_fw.o
9qla2200-y := ql2200.o ql2200_fw.o 9qla2200-y := ql2200.o ql2200_fw.o
diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index 2efca52dff50..b17ee62dd1a9 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -541,7 +541,7 @@ struct fc_function_template qla2xxx_transport_functions = {
541void 541void
542qla2x00_init_host_attr(scsi_qla_host_t *ha) 542qla2x00_init_host_attr(scsi_qla_host_t *ha)
543{ 543{
544 fc_host_node_name(ha->host) = wwn_to_u64(ha->init_cb->node_name); 544 fc_host_node_name(ha->host) = wwn_to_u64(ha->node_name);
545 fc_host_port_name(ha->host) = wwn_to_u64(ha->init_cb->port_name); 545 fc_host_port_name(ha->host) = wwn_to_u64(ha->port_name);
546 fc_host_supported_classes(ha->host) = FC_COS_CLASS3; 546 fc_host_supported_classes(ha->host) = FC_COS_CLASS3;
547} 547}
diff --git a/drivers/scsi/qla2xxx/qla_dbg.c b/drivers/scsi/qla2xxx/qla_dbg.c
index 5c5d2315cfab..2d9b12ffe09c 100644
--- a/drivers/scsi/qla2xxx/qla_dbg.c
+++ b/drivers/scsi/qla2xxx/qla_dbg.c
@@ -1003,10 +1003,10 @@ qla24xx_fw_dump(scsi_qla_host_t *ha, int hardware_locked)
1003 fw = (struct qla24xx_fw_dump *) ha->fw_dump24; 1003 fw = (struct qla24xx_fw_dump *) ha->fw_dump24;
1004 1004
1005 rval = QLA_SUCCESS; 1005 rval = QLA_SUCCESS;
1006 fw->hccr = RD_REG_DWORD(&reg->hccr); 1006 fw->host_status = RD_REG_DWORD(&reg->host_status);
1007 1007
1008 /* Pause RISC. */ 1008 /* Pause RISC. */
1009 if ((fw->hccr & HCCRX_RISC_PAUSE) == 0) { 1009 if ((RD_REG_DWORD(&reg->hccr) & HCCRX_RISC_PAUSE) == 0) {
1010 WRT_REG_DWORD(&reg->hccr, HCCRX_SET_RISC_RESET | 1010 WRT_REG_DWORD(&reg->hccr, HCCRX_SET_RISC_RESET |
1011 HCCRX_CLR_HOST_INT); 1011 HCCRX_CLR_HOST_INT);
1012 RD_REG_DWORD(&reg->hccr); /* PCI Posting. */ 1012 RD_REG_DWORD(&reg->hccr); /* PCI Posting. */
@@ -1021,16 +1021,54 @@ qla24xx_fw_dump(scsi_qla_host_t *ha, int hardware_locked)
1021 } 1021 }
1022 } 1022 }
1023 1023
1024 /* Disable interrupts. */
1025 WRT_REG_DWORD(&reg->ictrl, 0);
1026 RD_REG_DWORD(&reg->ictrl);
1027
1028 if (rval == QLA_SUCCESS) { 1024 if (rval == QLA_SUCCESS) {
1029 /* Host interface registers. */ 1025 /* Host interface registers. */
1030 dmp_reg = (uint32_t __iomem *)(reg + 0); 1026 dmp_reg = (uint32_t __iomem *)(reg + 0);
1031 for (cnt = 0; cnt < sizeof(fw->host_reg) / 4; cnt++) 1027 for (cnt = 0; cnt < sizeof(fw->host_reg) / 4; cnt++)
1032 fw->host_reg[cnt] = RD_REG_DWORD(dmp_reg++); 1028 fw->host_reg[cnt] = RD_REG_DWORD(dmp_reg++);
1033 1029
1030 /* Disable interrupts. */
1031 WRT_REG_DWORD(&reg->ictrl, 0);
1032 RD_REG_DWORD(&reg->ictrl);
1033
1034 /* Shadow registers. */
1035 WRT_REG_DWORD(&reg->iobase_addr, 0x0F70);
1036 RD_REG_DWORD(&reg->iobase_addr);
1037 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xF0);
1038 WRT_REG_DWORD(dmp_reg, 0xB0000000);
1039 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xFC);
1040 fw->shadow_reg[0] = RD_REG_DWORD(dmp_reg);
1041
1042 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xF0);
1043 WRT_REG_DWORD(dmp_reg, 0xB0100000);
1044 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xFC);
1045 fw->shadow_reg[1] = RD_REG_DWORD(dmp_reg);
1046
1047 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xF0);
1048 WRT_REG_DWORD(dmp_reg, 0xB0200000);
1049 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xFC);
1050 fw->shadow_reg[2] = RD_REG_DWORD(dmp_reg);
1051
1052 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xF0);
1053 WRT_REG_DWORD(dmp_reg, 0xB0300000);
1054 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xFC);
1055 fw->shadow_reg[3] = RD_REG_DWORD(dmp_reg);
1056
1057 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xF0);
1058 WRT_REG_DWORD(dmp_reg, 0xB0400000);
1059 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xFC);
1060 fw->shadow_reg[4] = RD_REG_DWORD(dmp_reg);
1061
1062 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xF0);
1063 WRT_REG_DWORD(dmp_reg, 0xB0500000);
1064 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xFC);
1065 fw->shadow_reg[5] = RD_REG_DWORD(dmp_reg);
1066
1067 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xF0);
1068 WRT_REG_DWORD(dmp_reg, 0xB0600000);
1069 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xFC);
1070 fw->shadow_reg[6] = RD_REG_DWORD(dmp_reg);
1071
1034 /* Mailbox registers. */ 1072 /* Mailbox registers. */
1035 mbx_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80); 1073 mbx_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
1036 for (cnt = 0; cnt < sizeof(fw->mailbox_reg) / 2; cnt++) 1074 for (cnt = 0; cnt < sizeof(fw->mailbox_reg) / 2; cnt++)
@@ -1308,43 +1346,6 @@ qla24xx_fw_dump(scsi_qla_host_t *ha, int hardware_locked)
1308 for (cnt = 0; cnt < 16; cnt++) 1346 for (cnt = 0; cnt < 16; cnt++)
1309 *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1347 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1310 1348
1311 WRT_REG_DWORD(&reg->iobase_addr, 0x0F70);
1312 RD_REG_DWORD(&reg->iobase_addr);
1313 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xF0);
1314 WRT_REG_DWORD(dmp_reg, 0xB0000000);
1315 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xFC);
1316 fw->shadow_reg[0] = RD_REG_DWORD(dmp_reg);
1317
1318 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xF0);
1319 WRT_REG_DWORD(dmp_reg, 0xB0100000);
1320 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xFC);
1321 fw->shadow_reg[1] = RD_REG_DWORD(dmp_reg);
1322
1323 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xF0);
1324 WRT_REG_DWORD(dmp_reg, 0xB0200000);
1325 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xFC);
1326 fw->shadow_reg[2] = RD_REG_DWORD(dmp_reg);
1327
1328 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xF0);
1329 WRT_REG_DWORD(dmp_reg, 0xB0300000);
1330 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xFC);
1331 fw->shadow_reg[3] = RD_REG_DWORD(dmp_reg);
1332
1333 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xF0);
1334 WRT_REG_DWORD(dmp_reg, 0xB0400000);
1335 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xFC);
1336 fw->shadow_reg[4] = RD_REG_DWORD(dmp_reg);
1337
1338 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xF0);
1339 WRT_REG_DWORD(dmp_reg, 0xB0500000);
1340 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xFC);
1341 fw->shadow_reg[5] = RD_REG_DWORD(dmp_reg);
1342
1343 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xF0);
1344 WRT_REG_DWORD(dmp_reg, 0xB0600000);
1345 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xFC);
1346 fw->shadow_reg[6] = RD_REG_DWORD(dmp_reg);
1347
1348 /* Local memory controller registers. */ 1349 /* Local memory controller registers. */
1349 iter_reg = fw->lmc_reg; 1350 iter_reg = fw->lmc_reg;
1350 WRT_REG_DWORD(&reg->iobase_addr, 0x3000); 1351 WRT_REG_DWORD(&reg->iobase_addr, 0x3000);
@@ -1677,7 +1678,7 @@ qla24xx_ascii_fw_dump(scsi_qla_host_t *ha)
1677 ha->fw_major_version, ha->fw_minor_version, 1678 ha->fw_major_version, ha->fw_minor_version,
1678 ha->fw_subminor_version, ha->fw_attributes); 1679 ha->fw_subminor_version, ha->fw_attributes);
1679 1680
1680 qla_uprintf(&uiter, "\nHCCR Register\n%04x\n", fw->hccr); 1681 qla_uprintf(&uiter, "\nR2H Status Register\n%04x\n", fw->host_status);
1681 1682
1682 qla_uprintf(&uiter, "\nHost Interface Registers"); 1683 qla_uprintf(&uiter, "\nHost Interface Registers");
1683 for (cnt = 0; cnt < sizeof(fw->host_reg) / 4; cnt++) { 1684 for (cnt = 0; cnt < sizeof(fw->host_reg) / 4; cnt++) {
@@ -1687,6 +1688,14 @@ qla24xx_ascii_fw_dump(scsi_qla_host_t *ha)
1687 qla_uprintf(&uiter, "%08x ", fw->host_reg[cnt]); 1688 qla_uprintf(&uiter, "%08x ", fw->host_reg[cnt]);
1688 } 1689 }
1689 1690
1691 qla_uprintf(&uiter, "\n\nShadow Registers");
1692 for (cnt = 0; cnt < sizeof(fw->shadow_reg) / 4; cnt++) {
1693 if (cnt % 8 == 0)
1694 qla_uprintf(&uiter, "\n");
1695
1696 qla_uprintf(&uiter, "%08x ", fw->shadow_reg[cnt]);
1697 }
1698
1690 qla_uprintf(&uiter, "\n\nMailbox Registers"); 1699 qla_uprintf(&uiter, "\n\nMailbox Registers");
1691 for (cnt = 0; cnt < sizeof(fw->mailbox_reg) / 2; cnt++) { 1700 for (cnt = 0; cnt < sizeof(fw->mailbox_reg) / 2; cnt++) {
1692 if (cnt % 8 == 0) 1701 if (cnt % 8 == 0)
@@ -1855,14 +1864,6 @@ qla24xx_ascii_fw_dump(scsi_qla_host_t *ha)
1855 qla_uprintf(&uiter, "%08x ", fw->risc_gp_reg[cnt]); 1864 qla_uprintf(&uiter, "%08x ", fw->risc_gp_reg[cnt]);
1856 } 1865 }
1857 1866
1858 qla_uprintf(&uiter, "\n\nShadow Registers");
1859 for (cnt = 0; cnt < sizeof(fw->shadow_reg) / 4; cnt++) {
1860 if (cnt % 8 == 0)
1861 qla_uprintf(&uiter, "\n");
1862
1863 qla_uprintf(&uiter, "%08x ", fw->shadow_reg[cnt]);
1864 }
1865
1866 qla_uprintf(&uiter, "\n\nLMC Registers"); 1867 qla_uprintf(&uiter, "\n\nLMC Registers");
1867 for (cnt = 0; cnt < sizeof(fw->lmc_reg) / 4; cnt++) { 1868 for (cnt = 0; cnt < sizeof(fw->lmc_reg) / 4; cnt++) {
1868 if (cnt % 8 == 0) 1869 if (cnt % 8 == 0)
diff --git a/drivers/scsi/qla2xxx/qla_dbg.h b/drivers/scsi/qla2xxx/qla_dbg.h
index 935a59a8c054..ab6afeaa2f2c 100644
--- a/drivers/scsi/qla2xxx/qla_dbg.h
+++ b/drivers/scsi/qla2xxx/qla_dbg.h
@@ -227,8 +227,9 @@ struct qla2100_fw_dump {
227#define FW_DUMP_SIZE_24XX 0x2B0000 227#define FW_DUMP_SIZE_24XX 0x2B0000
228 228
229struct qla24xx_fw_dump { 229struct qla24xx_fw_dump {
230 uint32_t hccr; 230 uint32_t host_status;
231 uint32_t host_reg[32]; 231 uint32_t host_reg[32];
232 uint32_t shadow_reg[7];
232 uint16_t mailbox_reg[32]; 233 uint16_t mailbox_reg[32];
233 uint32_t xseq_gp_reg[128]; 234 uint32_t xseq_gp_reg[128];
234 uint32_t xseq_0_reg[16]; 235 uint32_t xseq_0_reg[16];
@@ -250,7 +251,6 @@ struct qla24xx_fw_dump {
250 uint32_t rcvt0_data_dma_reg[32]; 251 uint32_t rcvt0_data_dma_reg[32];
251 uint32_t rcvt1_data_dma_reg[32]; 252 uint32_t rcvt1_data_dma_reg[32];
252 uint32_t risc_gp_reg[128]; 253 uint32_t risc_gp_reg[128];
253 uint32_t shadow_reg[7];
254 uint32_t lmc_reg[112]; 254 uint32_t lmc_reg[112];
255 uint32_t fpm_hdw_reg[192]; 255 uint32_t fpm_hdw_reg[192];
256 uint32_t fb_hdw_reg[176]; 256 uint32_t fb_hdw_reg[176];
diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
index bec81adcf4fd..32be4c14cccb 100644
--- a/drivers/scsi/qla2xxx/qla_gbl.h
+++ b/drivers/scsi/qla2xxx/qla_gbl.h
@@ -62,6 +62,7 @@ extern int qlport_down_retry;
62extern int ql2xplogiabsentdevice; 62extern int ql2xplogiabsentdevice;
63extern int ql2xloginretrycount; 63extern int ql2xloginretrycount;
64extern int ql2xfdmienable; 64extern int ql2xfdmienable;
65extern int ql2xprocessrscn;
65 66
66extern void qla2x00_sp_compl(scsi_qla_host_t *, srb_t *); 67extern void qla2x00_sp_compl(scsi_qla_host_t *, srb_t *);
67 68
@@ -96,10 +97,7 @@ int __qla2x00_marker(scsi_qla_host_t *, uint16_t, uint16_t, uint8_t);
96 * Global Function Prototypes in qla_mbx.c source file. 97 * Global Function Prototypes in qla_mbx.c source file.
97 */ 98 */
98extern int 99extern int
99qla2x00_load_ram(scsi_qla_host_t *, dma_addr_t, uint16_t, uint16_t); 100qla2x00_load_ram(scsi_qla_host_t *, dma_addr_t, uint32_t, uint32_t);
100
101extern int
102qla2x00_load_ram_ext(scsi_qla_host_t *, dma_addr_t, uint32_t, uint32_t);
103 101
104extern int 102extern int
105qla2x00_execute_fw(scsi_qla_host_t *, uint32_t); 103qla2x00_execute_fw(scsi_qla_host_t *, uint32_t);
diff --git a/drivers/scsi/qla2xxx/qla_gs.c b/drivers/scsi/qla2xxx/qla_gs.c
index cd6f7c3cfe68..d620a8e8a614 100644
--- a/drivers/scsi/qla2xxx/qla_gs.c
+++ b/drivers/scsi/qla2xxx/qla_gs.c
@@ -538,6 +538,7 @@ qla2x00_rff_id(scsi_qla_host_t *ha)
538 ct_req->req.rff_id.port_id[1] = ha->d_id.b.area; 538 ct_req->req.rff_id.port_id[1] = ha->d_id.b.area;
539 ct_req->req.rff_id.port_id[2] = ha->d_id.b.al_pa; 539 ct_req->req.rff_id.port_id[2] = ha->d_id.b.al_pa;
540 540
541 ct_req->req.rff_id.fc4_feature = BIT_1;
541 ct_req->req.rff_id.fc4_type = 0x08; /* SCSI - FCP */ 542 ct_req->req.rff_id.fc4_type = 0x08; /* SCSI - FCP */
542 543
543 /* Execute MS IOCB */ 544 /* Execute MS IOCB */
@@ -1529,9 +1530,9 @@ qla2x00_fdmi_rpa(scsi_qla_host_t *ha)
1529 eiter->type = __constant_cpu_to_be16(FDMI_PORT_SUPPORT_SPEED); 1530 eiter->type = __constant_cpu_to_be16(FDMI_PORT_SUPPORT_SPEED);
1530 eiter->len = __constant_cpu_to_be16(4 + 4); 1531 eiter->len = __constant_cpu_to_be16(4 + 4);
1531 if (IS_QLA25XX(ha)) 1532 if (IS_QLA25XX(ha))
1532 eiter->a.sup_speed = __constant_cpu_to_be32(4);
1533 else if (IS_QLA24XX(ha))
1534 eiter->a.sup_speed = __constant_cpu_to_be32(8); 1533 eiter->a.sup_speed = __constant_cpu_to_be32(8);
1534 else if (IS_QLA24XX(ha))
1535 eiter->a.sup_speed = __constant_cpu_to_be32(4);
1535 else if (IS_QLA23XX(ha)) 1536 else if (IS_QLA23XX(ha))
1536 eiter->a.sup_speed = __constant_cpu_to_be32(2); 1537 eiter->a.sup_speed = __constant_cpu_to_be32(2);
1537 else 1538 else
@@ -1553,9 +1554,6 @@ qla2x00_fdmi_rpa(scsi_qla_host_t *ha)
1553 eiter->a.cur_speed = __constant_cpu_to_be32(2); 1554 eiter->a.cur_speed = __constant_cpu_to_be32(2);
1554 break; 1555 break;
1555 case 3: 1556 case 3:
1556 eiter->a.cur_speed = __constant_cpu_to_be32(8);
1557 break;
1558 case 4:
1559 eiter->a.cur_speed = __constant_cpu_to_be32(4); 1557 eiter->a.cur_speed = __constant_cpu_to_be32(4);
1560 break; 1558 break;
1561 } 1559 }
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 7d973bd9022b..a91fea69ad63 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -1014,11 +1014,13 @@ qla24xx_update_fw_options(scsi_qla_host_t *ha)
1014 int rval; 1014 int rval;
1015 1015
1016 /* Update Serial Link options. */ 1016 /* Update Serial Link options. */
1017 if ((ha->fw_seriallink_options24[0] & BIT_0) == 0) 1017 if ((le16_to_cpu(ha->fw_seriallink_options24[0]) & BIT_0) == 0)
1018 return; 1018 return;
1019 1019
1020 rval = qla2x00_set_serdes_params(ha, ha->fw_seriallink_options24[1], 1020 rval = qla2x00_set_serdes_params(ha,
1021 ha->fw_seriallink_options24[2], ha->fw_seriallink_options24[3]); 1021 le16_to_cpu(ha->fw_seriallink_options24[1]),
1022 le16_to_cpu(ha->fw_seriallink_options24[2]),
1023 le16_to_cpu(ha->fw_seriallink_options24[3]));
1022 if (rval != QLA_SUCCESS) { 1024 if (rval != QLA_SUCCESS) {
1023 qla_printk(KERN_WARNING, ha, 1025 qla_printk(KERN_WARNING, ha,
1024 "Unable to update Serial Link options (%x).\n", rval); 1026 "Unable to update Serial Link options (%x).\n", rval);
@@ -1939,6 +1941,9 @@ qla2x00_configure_local_loop(scsi_qla_host_t *ha)
1939 "information -- get_port_database=%x, " 1941 "information -- get_port_database=%x, "
1940 "loop_id=0x%04x\n", 1942 "loop_id=0x%04x\n",
1941 ha->host_no, rval2, new_fcport->loop_id)); 1943 ha->host_no, rval2, new_fcport->loop_id));
1944 DEBUG2(printk("scsi(%ld): Scheduling resync...\n",
1945 ha->host_no));
1946 set_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags);
1942 continue; 1947 continue;
1943 } 1948 }
1944 1949
@@ -2648,7 +2653,8 @@ qla2x00_device_resync(scsi_qla_host_t *ha)
2648 2653
2649 switch (format) { 2654 switch (format) {
2650 case 0: 2655 case 0:
2651 if (!IS_QLA2100(ha) && !IS_QLA2200(ha) && 2656 if (ql2xprocessrscn &&
2657 !IS_QLA2100(ha) && !IS_QLA2200(ha) &&
2652 !IS_QLA6312(ha) && !IS_QLA6322(ha) && 2658 !IS_QLA6312(ha) && !IS_QLA6322(ha) &&
2653 !IS_QLA24XX(ha) && !IS_QLA25XX(ha) && 2659 !IS_QLA24XX(ha) && !IS_QLA25XX(ha) &&
2654 ha->flags.init_done) { 2660 ha->flags.init_done) {
@@ -3402,6 +3408,8 @@ qla24xx_nvram_config(scsi_qla_host_t *ha)
3402 ha->node_name = icb->node_name; 3408 ha->node_name = icb->node_name;
3403 ha->port_name = icb->port_name; 3409 ha->port_name = icb->port_name;
3404 3410
3411 icb->execution_throttle = __constant_cpu_to_le16(0xFFFF);
3412
3405 ha->retry_count = le16_to_cpu(nv->login_retry_count); 3413 ha->retry_count = le16_to_cpu(nv->login_retry_count);
3406 3414
3407 /* Set minimum login_timeout to 4 seconds. */ 3415 /* Set minimum login_timeout to 4 seconds. */
@@ -3667,8 +3675,8 @@ qla24xx_load_risc_flash(scsi_qla_host_t *ha, uint32_t *srisc_addr)
3667 for (i = 0; i < dlen; i++) 3675 for (i = 0; i < dlen; i++)
3668 dcode[i] = swab32(dcode[i]); 3676 dcode[i] = swab32(dcode[i]);
3669 3677
3670 rval = qla2x00_load_ram_ext(ha, ha->request_dma, 3678 rval = qla2x00_load_ram(ha, ha->request_dma, risc_addr,
3671 risc_addr, dlen); 3679 dlen);
3672 if (rval) { 3680 if (rval) {
3673 DEBUG(printk("scsi(%ld):[ERROR] Failed to load " 3681 DEBUG(printk("scsi(%ld):[ERROR] Failed to load "
3674 "segment %d of firmware\n", ha->host_no, 3682 "segment %d of firmware\n", ha->host_no,
@@ -3868,8 +3876,8 @@ qla24xx_load_risc(scsi_qla_host_t *ha, uint32_t *srisc_addr)
3868 for (i = 0; i < dlen; i++) 3876 for (i = 0; i < dlen; i++)
3869 dcode[i] = swab32(fwcode[i]); 3877 dcode[i] = swab32(fwcode[i]);
3870 3878
3871 rval = qla2x00_load_ram_ext(ha, ha->request_dma, 3879 rval = qla2x00_load_ram(ha, ha->request_dma, risc_addr,
3872 risc_addr, dlen); 3880 dlen);
3873 if (rval) { 3881 if (rval) {
3874 DEBUG(printk("scsi(%ld):[ERROR] Failed to load " 3882 DEBUG(printk("scsi(%ld):[ERROR] Failed to load "
3875 "segment %d of firmware\n", ha->host_no, 3883 "segment %d of firmware\n", ha->host_no,
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index 5181d966fecb..f63af081d4ff 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -519,7 +519,8 @@ qla2x00_async_event(scsi_qla_host_t *ha, uint16_t *mb)
519 * us, create a new entry in our rscn fcports list and handle 519 * us, create a new entry in our rscn fcports list and handle
520 * the event like an RSCN. 520 * the event like an RSCN.
521 */ 521 */
522 if (!IS_QLA2100(ha) && !IS_QLA2200(ha) && !IS_QLA6312(ha) && 522 if (ql2xprocessrscn &&
523 !IS_QLA2100(ha) && !IS_QLA2200(ha) && !IS_QLA6312(ha) &&
523 !IS_QLA6322(ha) && !IS_QLA24XX(ha) && !IS_QLA25XX(ha) && 524 !IS_QLA6322(ha) && !IS_QLA24XX(ha) && !IS_QLA25XX(ha) &&
524 ha->flags.init_done && mb[1] != 0xffff && 525 ha->flags.init_done && mb[1] != 0xffff &&
525 ((ha->operating_mode == P2P && mb[1] != 0) || 526 ((ha->operating_mode == P2P && mb[1] != 0) ||
@@ -963,15 +964,16 @@ qla2x00_status_entry(scsi_qla_host_t *ha, void *pkt)
963 break; 964 break;
964 965
965 case CS_DATA_UNDERRUN: 966 case CS_DATA_UNDERRUN:
966 DEBUG2(printk(KERN_INFO
967 "scsi(%ld:%d:%d) UNDERRUN status detected 0x%x-0x%x.\n",
968 ha->host_no, cp->device->id, cp->device->lun, comp_status,
969 scsi_status));
970
971 resid = resid_len; 967 resid = resid_len;
972 if (scsi_status & SS_RESIDUAL_UNDER) { 968 if (scsi_status & SS_RESIDUAL_UNDER) {
973 cp->resid = resid; 969 cp->resid = resid;
974 CMD_RESID_LEN(cp) = resid; 970 CMD_RESID_LEN(cp) = resid;
971 } else {
972 DEBUG2(printk(KERN_INFO
973 "scsi(%ld:%d:%d) UNDERRUN status detected "
974 "0x%x-0x%x.\n", ha->host_no, cp->device->id,
975 cp->device->lun, comp_status, scsi_status));
976
975 } 977 }
976 978
977 /* 979 /*
diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
index 9746cd1e664b..3099b379de9d 100644
--- a/drivers/scsi/qla2xxx/qla_mbx.c
+++ b/drivers/scsi/qla2xxx/qla_mbx.c
@@ -196,7 +196,9 @@ qla2x00_mailbox_command(scsi_qla_host_t *ha, mbx_cmd_t *mcp)
196 /* Check for pending interrupts. */ 196 /* Check for pending interrupts. */
197 qla2x00_poll(ha); 197 qla2x00_poll(ha);
198 198
199 udelay(10); /* v4.27 */ 199 if (command != MBC_LOAD_RISC_RAM_EXTENDED &&
200 !ha->flags.mbox_int)
201 msleep(10);
200 } /* while */ 202 } /* while */
201 } 203 }
202 204
@@ -325,113 +327,30 @@ qla2x00_mailbox_command(scsi_qla_host_t *ha, mbx_cmd_t *mcp)
325 return rval; 327 return rval;
326} 328}
327 329
328/*
329 * qla2x00_load_ram
330 * Load adapter RAM using DMA.
331 *
332 * Input:
333 * ha = adapter block pointer.
334 *
335 * Returns:
336 * qla2x00 local function return status code.
337 *
338 * Context:
339 * Kernel context.
340 */
341int 330int
342qla2x00_load_ram(scsi_qla_host_t *ha, dma_addr_t req_dma, uint16_t risc_addr, 331qla2x00_load_ram(scsi_qla_host_t *ha, dma_addr_t req_dma, uint32_t risc_addr,
343 uint16_t risc_code_size) 332 uint32_t risc_code_size)
344{ 333{
345 int rval; 334 int rval;
346 mbx_cmd_t mc; 335 mbx_cmd_t mc;
347 mbx_cmd_t *mcp = &mc; 336 mbx_cmd_t *mcp = &mc;
348 uint32_t req_len;
349 dma_addr_t nml_dma;
350 uint32_t nml_len;
351 uint32_t normalized;
352
353 DEBUG11(printk("qla2x00_load_ram(%ld): entered.\n",
354 ha->host_no);)
355 337
356 req_len = risc_code_size; 338 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no));
357 nml_dma = 0;
358 nml_len = 0;
359
360 normalized = qla2x00_normalize_dma_addr(&req_dma, &req_len, &nml_dma,
361 &nml_len);
362
363 /* Load first segment */
364 mcp->mb[0] = MBC_LOAD_RISC_RAM;
365 mcp->mb[1] = risc_addr;
366 mcp->mb[2] = MSW(req_dma);
367 mcp->mb[3] = LSW(req_dma);
368 mcp->mb[4] = (uint16_t)req_len;
369 mcp->mb[6] = MSW(MSD(req_dma));
370 mcp->mb[7] = LSW(MSD(req_dma));
371 mcp->out_mb = MBX_7|MBX_6|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
372 mcp->in_mb = MBX_0;
373 mcp->tov = 30;
374 mcp->flags = 0;
375 rval = qla2x00_mailbox_command(ha, mcp);
376
377 /* Load second segment - if necessary */
378 if (normalized && (rval == QLA_SUCCESS)) {
379 mcp->mb[0] = MBC_LOAD_RISC_RAM;
380 mcp->mb[1] = risc_addr + (uint16_t)req_len;
381 mcp->mb[2] = MSW(nml_dma);
382 mcp->mb[3] = LSW(nml_dma);
383 mcp->mb[4] = (uint16_t)nml_len;
384 mcp->mb[6] = MSW(MSD(nml_dma));
385 mcp->mb[7] = LSW(MSD(nml_dma));
386 mcp->out_mb = MBX_7|MBX_6|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
387 mcp->in_mb = MBX_0;
388 mcp->tov = 30;
389 mcp->flags = 0;
390 rval = qla2x00_mailbox_command(ha, mcp);
391 }
392 339
393 if (rval == QLA_SUCCESS) { 340 if (MSW(risc_addr) || IS_QLA24XX(ha) || IS_QLA25XX(ha)) {
394 /* Empty */ 341 mcp->mb[0] = MBC_LOAD_RISC_RAM_EXTENDED;
395 DEBUG11(printk("qla2x00_load_ram(%ld): done.\n", ha->host_no);) 342 mcp->mb[8] = MSW(risc_addr);
343 mcp->out_mb = MBX_8|MBX_0;
396 } else { 344 } else {
397 /* Empty */ 345 mcp->mb[0] = MBC_LOAD_RISC_RAM;
398 DEBUG2_3_11(printk("qla2x00_load_ram(%ld): failed. rval=%x " 346 mcp->out_mb = MBX_0;
399 "mb[0]=%x.\n", ha->host_no, rval, mcp->mb[0]);)
400 } 347 }
401 return rval;
402}
403
404/*
405 * qla2x00_load_ram_ext
406 * Load adapter extended RAM using DMA.
407 *
408 * Input:
409 * ha = adapter block pointer.
410 *
411 * Returns:
412 * qla2x00 local function return status code.
413 *
414 * Context:
415 * Kernel context.
416 */
417int
418qla2x00_load_ram_ext(scsi_qla_host_t *ha, dma_addr_t req_dma,
419 uint32_t risc_addr, uint32_t risc_code_size)
420{
421 int rval;
422 mbx_cmd_t mc;
423 mbx_cmd_t *mcp = &mc;
424
425 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no));
426
427 mcp->mb[0] = MBC_LOAD_RISC_RAM_EXTENDED;
428 mcp->mb[1] = LSW(risc_addr); 348 mcp->mb[1] = LSW(risc_addr);
429 mcp->mb[2] = MSW(req_dma); 349 mcp->mb[2] = MSW(req_dma);
430 mcp->mb[3] = LSW(req_dma); 350 mcp->mb[3] = LSW(req_dma);
431 mcp->mb[6] = MSW(MSD(req_dma)); 351 mcp->mb[6] = MSW(MSD(req_dma));
432 mcp->mb[7] = LSW(MSD(req_dma)); 352 mcp->mb[7] = LSW(MSD(req_dma));
433 mcp->mb[8] = MSW(risc_addr); 353 mcp->out_mb |= MBX_7|MBX_6|MBX_3|MBX_2|MBX_1;
434 mcp->out_mb = MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
435 if (IS_QLA24XX(ha) || IS_QLA25XX(ha)) { 354 if (IS_QLA24XX(ha) || IS_QLA25XX(ha)) {
436 mcp->mb[4] = MSW(risc_code_size); 355 mcp->mb[4] = MSW(risc_code_size);
437 mcp->mb[5] = LSW(risc_code_size); 356 mcp->mb[5] = LSW(risc_code_size);
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 24304300d7b5..4916847d84ec 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -71,6 +71,12 @@ MODULE_PARM_DESC(ql2xfdmienable,
71 "Enables FDMI registratons " 71 "Enables FDMI registratons "
72 "Default is 0 - no FDMI. 1 - perfom FDMI."); 72 "Default is 0 - no FDMI. 1 - perfom FDMI.");
73 73
74int ql2xprocessrscn;
75module_param(ql2xprocessrscn, int, S_IRUGO|S_IRUSR);
76MODULE_PARM_DESC(ql2xprocessrscn,
77 "Option to enable port RSCN handling via a series of less"
78 "fabric intrusive ADISCs and PLOGIs.");
79
74/* 80/*
75 * SCSI host template entry points 81 * SCSI host template entry points
76 */ 82 */
diff --git a/drivers/scsi/qla2xxx/qla_sup.c b/drivers/scsi/qla2xxx/qla_sup.c
index d54d2a99c3d3..f4d755a643e4 100644
--- a/drivers/scsi/qla2xxx/qla_sup.c
+++ b/drivers/scsi/qla2xxx/qla_sup.c
@@ -573,6 +573,9 @@ qla24xx_write_flash_data(scsi_qla_host_t *ha, uint32_t *dwptr, uint32_t faddr,
573 } 573 }
574 } while (0); 574 } while (0);
575 575
576 /* Enable flash write-protection. */
577 qla24xx_write_flash_dword(ha, flash_conf_to_access_addr(0x101), 0x9c);
578
576 /* Disable flash write. */ 579 /* Disable flash write. */
577 WRT_REG_DWORD(&reg->ctrl_status, 580 WRT_REG_DWORD(&reg->ctrl_status,
578 RD_REG_DWORD(&reg->ctrl_status) & ~CSRX_FLASH_ENABLE); 581 RD_REG_DWORD(&reg->ctrl_status) & ~CSRX_FLASH_ENABLE);
diff --git a/drivers/scsi/qla2xxx/qla_version.h b/drivers/scsi/qla2xxx/qla_version.h
index f7937f7f9c68..d537192a1edb 100644
--- a/drivers/scsi/qla2xxx/qla_version.h
+++ b/drivers/scsi/qla2xxx/qla_version.h
@@ -7,9 +7,9 @@
7/* 7/*
8 * Driver version 8 * Driver version
9 */ 9 */
10#define QLA2XXX_VERSION "8.01.03-k" 10#define QLA2XXX_VERSION "8.01.04-k"
11 11
12#define QLA_DRIVER_MAJOR_VER 8 12#define QLA_DRIVER_MAJOR_VER 8
13#define QLA_DRIVER_MINOR_VER 1 13#define QLA_DRIVER_MINOR_VER 1
14#define QLA_DRIVER_PATCH_VER 3 14#define QLA_DRIVER_PATCH_VER 4
15#define QLA_DRIVER_BETA_VER 0 15#define QLA_DRIVER_BETA_VER 0
diff --git a/drivers/scsi/raid_class.c b/drivers/scsi/raid_class.c
index 5ec5f44602ac..50c398aab557 100644
--- a/drivers/scsi/raid_class.c
+++ b/drivers/scsi/raid_class.c
@@ -148,9 +148,11 @@ static struct {
148 { RAID_LEVEL_LINEAR, "linear" }, 148 { RAID_LEVEL_LINEAR, "linear" },
149 { RAID_LEVEL_0, "raid0" }, 149 { RAID_LEVEL_0, "raid0" },
150 { RAID_LEVEL_1, "raid1" }, 150 { RAID_LEVEL_1, "raid1" },
151 { RAID_LEVEL_10, "raid10" },
151 { RAID_LEVEL_3, "raid3" }, 152 { RAID_LEVEL_3, "raid3" },
152 { RAID_LEVEL_4, "raid4" }, 153 { RAID_LEVEL_4, "raid4" },
153 { RAID_LEVEL_5, "raid5" }, 154 { RAID_LEVEL_5, "raid5" },
155 { RAID_LEVEL_50, "raid50" },
154 { RAID_LEVEL_6, "raid6" }, 156 { RAID_LEVEL_6, "raid6" },
155}; 157};
156 158
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index ee5f4dfdab14..245ca99a641e 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -55,6 +55,7 @@
55#include <linux/interrupt.h> 55#include <linux/interrupt.h>
56#include <linux/notifier.h> 56#include <linux/notifier.h>
57#include <linux/cpu.h> 57#include <linux/cpu.h>
58#include <linux/mutex.h>
58 59
59#include <scsi/scsi.h> 60#include <scsi/scsi.h>
60#include <scsi/scsi_cmnd.h> 61#include <scsi/scsi_cmnd.h>
@@ -209,7 +210,7 @@ static struct scsi_host_cmd_pool scsi_cmd_dma_pool = {
209 .gfp_mask = __GFP_DMA, 210 .gfp_mask = __GFP_DMA,
210}; 211};
211 212
212static DECLARE_MUTEX(host_cmd_pool_mutex); 213static DEFINE_MUTEX(host_cmd_pool_mutex);
213 214
214static struct scsi_cmnd *__scsi_get_command(struct Scsi_Host *shost, 215static struct scsi_cmnd *__scsi_get_command(struct Scsi_Host *shost,
215 gfp_t gfp_mask) 216 gfp_t gfp_mask)
@@ -330,7 +331,7 @@ int scsi_setup_command_freelist(struct Scsi_Host *shost)
330 * Select a command slab for this host and create it if not 331 * Select a command slab for this host and create it if not
331 * yet existant. 332 * yet existant.
332 */ 333 */
333 down(&host_cmd_pool_mutex); 334 mutex_lock(&host_cmd_pool_mutex);
334 pool = (shost->unchecked_isa_dma ? &scsi_cmd_dma_pool : &scsi_cmd_pool); 335 pool = (shost->unchecked_isa_dma ? &scsi_cmd_dma_pool : &scsi_cmd_pool);
335 if (!pool->users) { 336 if (!pool->users) {
336 pool->slab = kmem_cache_create(pool->name, 337 pool->slab = kmem_cache_create(pool->name,
@@ -342,7 +343,7 @@ int scsi_setup_command_freelist(struct Scsi_Host *shost)
342 343
343 pool->users++; 344 pool->users++;
344 shost->cmd_pool = pool; 345 shost->cmd_pool = pool;
345 up(&host_cmd_pool_mutex); 346 mutex_unlock(&host_cmd_pool_mutex);
346 347
347 /* 348 /*
348 * Get one backup command for this host. 349 * Get one backup command for this host.
@@ -359,7 +360,7 @@ int scsi_setup_command_freelist(struct Scsi_Host *shost)
359 kmem_cache_destroy(pool->slab); 360 kmem_cache_destroy(pool->slab);
360 return -ENOMEM; 361 return -ENOMEM;
361 fail: 362 fail:
362 up(&host_cmd_pool_mutex); 363 mutex_unlock(&host_cmd_pool_mutex);
363 return -ENOMEM; 364 return -ENOMEM;
364 365
365} 366}
@@ -381,10 +382,10 @@ void scsi_destroy_command_freelist(struct Scsi_Host *shost)
381 kmem_cache_free(shost->cmd_pool->slab, cmd); 382 kmem_cache_free(shost->cmd_pool->slab, cmd);
382 } 383 }
383 384
384 down(&host_cmd_pool_mutex); 385 mutex_lock(&host_cmd_pool_mutex);
385 if (!--shost->cmd_pool->users) 386 if (!--shost->cmd_pool->users)
386 kmem_cache_destroy(shost->cmd_pool->slab); 387 kmem_cache_destroy(shost->cmd_pool->slab);
387 up(&host_cmd_pool_mutex); 388 mutex_unlock(&host_cmd_pool_mutex);
388} 389}
389 390
390#ifdef CONFIG_SCSI_LOGGING 391#ifdef CONFIG_SCSI_LOGGING
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 00c9bf383e23..3574ba935af8 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1212,7 +1212,7 @@ static int scsi_issue_flush_fn(request_queue_t *q, struct gendisk *disk,
1212 return -EOPNOTSUPP; 1212 return -EOPNOTSUPP;
1213} 1213}
1214 1214
1215static void scsi_generic_done(struct scsi_cmnd *cmd) 1215static void scsi_blk_pc_done(struct scsi_cmnd *cmd)
1216{ 1216{
1217 BUG_ON(!blk_pc_request(cmd->request)); 1217 BUG_ON(!blk_pc_request(cmd->request));
1218 /* 1218 /*
@@ -1224,7 +1224,7 @@ static void scsi_generic_done(struct scsi_cmnd *cmd)
1224 scsi_io_completion(cmd, cmd->bufflen, 0); 1224 scsi_io_completion(cmd, cmd->bufflen, 0);
1225} 1225}
1226 1226
1227void scsi_setup_blk_pc_cmnd(struct scsi_cmnd *cmd) 1227static void scsi_setup_blk_pc_cmnd(struct scsi_cmnd *cmd)
1228{ 1228{
1229 struct request *req = cmd->request; 1229 struct request *req = cmd->request;
1230 1230
@@ -1241,8 +1241,8 @@ void scsi_setup_blk_pc_cmnd(struct scsi_cmnd *cmd)
1241 cmd->transfersize = req->data_len; 1241 cmd->transfersize = req->data_len;
1242 cmd->allowed = req->retries; 1242 cmd->allowed = req->retries;
1243 cmd->timeout_per_command = req->timeout; 1243 cmd->timeout_per_command = req->timeout;
1244 cmd->done = scsi_blk_pc_done;
1244} 1245}
1245EXPORT_SYMBOL_GPL(scsi_setup_blk_pc_cmnd);
1246 1246
1247static int scsi_prep_fn(struct request_queue *q, struct request *req) 1247static int scsi_prep_fn(struct request_queue *q, struct request *req)
1248{ 1248{
@@ -1339,7 +1339,6 @@ static int scsi_prep_fn(struct request_queue *q, struct request *req)
1339 * happening now. 1339 * happening now.
1340 */ 1340 */
1341 if (req->flags & (REQ_CMD | REQ_BLOCK_PC)) { 1341 if (req->flags & (REQ_CMD | REQ_BLOCK_PC)) {
1342 struct scsi_driver *drv;
1343 int ret; 1342 int ret;
1344 1343
1345 /* 1344 /*
@@ -1371,16 +1370,17 @@ static int scsi_prep_fn(struct request_queue *q, struct request *req)
1371 /* 1370 /*
1372 * Initialize the actual SCSI command for this request. 1371 * Initialize the actual SCSI command for this request.
1373 */ 1372 */
1374 if (req->rq_disk) { 1373 if (req->flags & REQ_BLOCK_PC) {
1374 scsi_setup_blk_pc_cmnd(cmd);
1375 } else if (req->rq_disk) {
1376 struct scsi_driver *drv;
1377
1375 drv = *(struct scsi_driver **)req->rq_disk->private_data; 1378 drv = *(struct scsi_driver **)req->rq_disk->private_data;
1376 if (unlikely(!drv->init_command(cmd))) { 1379 if (unlikely(!drv->init_command(cmd))) {
1377 scsi_release_buffers(cmd); 1380 scsi_release_buffers(cmd);
1378 scsi_put_command(cmd); 1381 scsi_put_command(cmd);
1379 goto kill; 1382 goto kill;
1380 } 1383 }
1381 } else {
1382 scsi_setup_blk_pc_cmnd(cmd);
1383 cmd->done = scsi_generic_done;
1384 } 1384 }
1385 } 1385 }
1386 1386
diff --git a/drivers/scsi/scsi_priv.h b/drivers/scsi/scsi_priv.h
index 14a6198cb8d2..27c48274e8cb 100644
--- a/drivers/scsi/scsi_priv.h
+++ b/drivers/scsi/scsi_priv.h
@@ -26,12 +26,6 @@ struct Scsi_Host;
26#define SCSI_SENSE_VALID(scmd) \ 26#define SCSI_SENSE_VALID(scmd) \
27 (((scmd)->sense_buffer[0] & 0x70) == 0x70) 27 (((scmd)->sense_buffer[0] & 0x70) == 0x70)
28 28
29/*
30 * Special value for scanning to specify scanning or rescanning of all
31 * possible channels, (target) ids, or luns on a given shost.
32 */
33#define SCAN_WILD_CARD ~0
34
35/* hosts.c */ 29/* hosts.c */
36extern int scsi_init_hosts(void); 30extern int scsi_init_hosts(void);
37extern void scsi_exit_hosts(void); 31extern void scsi_exit_hosts(void);
diff --git a/drivers/scsi/scsi_proc.c b/drivers/scsi/scsi_proc.c
index a50958b1b6ee..07be62bbaaea 100644
--- a/drivers/scsi/scsi_proc.c
+++ b/drivers/scsi/scsi_proc.c
@@ -25,11 +25,13 @@
25#include <linux/errno.h> 25#include <linux/errno.h>
26#include <linux/blkdev.h> 26#include <linux/blkdev.h>
27#include <linux/seq_file.h> 27#include <linux/seq_file.h>
28#include <linux/mutex.h>
28#include <asm/uaccess.h> 29#include <asm/uaccess.h>
29 30
30#include <scsi/scsi.h> 31#include <scsi/scsi.h>
31#include <scsi/scsi_device.h> 32#include <scsi/scsi_device.h>
32#include <scsi/scsi_host.h> 33#include <scsi/scsi_host.h>
34#include <scsi/scsi_transport.h>
33 35
34#include "scsi_priv.h" 36#include "scsi_priv.h"
35#include "scsi_logging.h" 37#include "scsi_logging.h"
@@ -41,7 +43,7 @@
41static struct proc_dir_entry *proc_scsi; 43static struct proc_dir_entry *proc_scsi;
42 44
43/* Protect sht->present and sht->proc_dir */ 45/* Protect sht->present and sht->proc_dir */
44static DECLARE_MUTEX(global_host_template_sem); 46static DEFINE_MUTEX(global_host_template_mutex);
45 47
46static int proc_scsi_read(char *buffer, char **start, off_t offset, 48static int proc_scsi_read(char *buffer, char **start, off_t offset,
47 int length, int *eof, void *data) 49 int length, int *eof, void *data)
@@ -83,7 +85,7 @@ void scsi_proc_hostdir_add(struct scsi_host_template *sht)
83 if (!sht->proc_info) 85 if (!sht->proc_info)
84 return; 86 return;
85 87
86 down(&global_host_template_sem); 88 mutex_lock(&global_host_template_mutex);
87 if (!sht->present++) { 89 if (!sht->present++) {
88 sht->proc_dir = proc_mkdir(sht->proc_name, proc_scsi); 90 sht->proc_dir = proc_mkdir(sht->proc_name, proc_scsi);
89 if (!sht->proc_dir) 91 if (!sht->proc_dir)
@@ -92,7 +94,7 @@ void scsi_proc_hostdir_add(struct scsi_host_template *sht)
92 else 94 else
93 sht->proc_dir->owner = sht->module; 95 sht->proc_dir->owner = sht->module;
94 } 96 }
95 up(&global_host_template_sem); 97 mutex_unlock(&global_host_template_mutex);
96} 98}
97 99
98void scsi_proc_hostdir_rm(struct scsi_host_template *sht) 100void scsi_proc_hostdir_rm(struct scsi_host_template *sht)
@@ -100,12 +102,12 @@ void scsi_proc_hostdir_rm(struct scsi_host_template *sht)
100 if (!sht->proc_info) 102 if (!sht->proc_info)
101 return; 103 return;
102 104
103 down(&global_host_template_sem); 105 mutex_lock(&global_host_template_mutex);
104 if (!--sht->present && sht->proc_dir) { 106 if (!--sht->present && sht->proc_dir) {
105 remove_proc_entry(sht->proc_name, proc_scsi); 107 remove_proc_entry(sht->proc_name, proc_scsi);
106 sht->proc_dir = NULL; 108 sht->proc_dir = NULL;
107 } 109 }
108 up(&global_host_template_sem); 110 mutex_unlock(&global_host_template_mutex);
109} 111}
110 112
111void scsi_proc_host_add(struct Scsi_Host *shost) 113void scsi_proc_host_add(struct Scsi_Host *shost)
@@ -199,7 +201,10 @@ static int scsi_add_single_device(uint host, uint channel, uint id, uint lun)
199 if (IS_ERR(shost)) 201 if (IS_ERR(shost))
200 return PTR_ERR(shost); 202 return PTR_ERR(shost);
201 203
202 error = scsi_scan_host_selected(shost, channel, id, lun, 1); 204 if (shost->transportt->user_scan)
205 error = shost->transportt->user_scan(shost, channel, id, lun);
206 else
207 error = scsi_scan_host_selected(shost, channel, id, lun, 1);
203 scsi_host_put(shost); 208 scsi_host_put(shost);
204 return error; 209 return error;
205} 210}
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 05ebb9cef961..752fb5da3de4 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -334,19 +334,6 @@ static struct scsi_target *scsi_alloc_target(struct device *parent,
334 struct scsi_target *starget; 334 struct scsi_target *starget;
335 struct scsi_target *found_target; 335 struct scsi_target *found_target;
336 336
337 /*
338 * Obtain the real parent from the transport. The transport
339 * is allowed to fail (no error) if there is nothing at that
340 * target id.
341 */
342 if (shost->transportt->target_parent) {
343 spin_lock_irqsave(shost->host_lock, flags);
344 parent = shost->transportt->target_parent(shost, channel, id);
345 spin_unlock_irqrestore(shost->host_lock, flags);
346 if (!parent)
347 return NULL;
348 }
349
350 starget = kmalloc(size, GFP_KERNEL); 337 starget = kmalloc(size, GFP_KERNEL);
351 if (!starget) { 338 if (!starget) {
352 printk(KERN_ERR "%s: allocation failure\n", __FUNCTION__); 339 printk(KERN_ERR "%s: allocation failure\n", __FUNCTION__);
@@ -1283,20 +1270,21 @@ struct scsi_device *__scsi_add_device(struct Scsi_Host *shost, uint channel,
1283 struct scsi_device *sdev; 1270 struct scsi_device *sdev;
1284 struct device *parent = &shost->shost_gendev; 1271 struct device *parent = &shost->shost_gendev;
1285 int res; 1272 int res;
1286 struct scsi_target *starget = scsi_alloc_target(parent, channel, id); 1273 struct scsi_target *starget;
1287 1274
1275 starget = scsi_alloc_target(parent, channel, id);
1288 if (!starget) 1276 if (!starget)
1289 return ERR_PTR(-ENOMEM); 1277 return ERR_PTR(-ENOMEM);
1290 1278
1291 get_device(&starget->dev); 1279 get_device(&starget->dev);
1292 down(&shost->scan_mutex); 1280 mutex_lock(&shost->scan_mutex);
1293 if (scsi_host_scan_allowed(shost)) { 1281 if (scsi_host_scan_allowed(shost)) {
1294 res = scsi_probe_and_add_lun(starget, lun, NULL, &sdev, 1, 1282 res = scsi_probe_and_add_lun(starget, lun, NULL, &sdev, 1,
1295 hostdata); 1283 hostdata);
1296 if (res != SCSI_SCAN_LUN_PRESENT) 1284 if (res != SCSI_SCAN_LUN_PRESENT)
1297 sdev = ERR_PTR(-ENODEV); 1285 sdev = ERR_PTR(-ENODEV);
1298 } 1286 }
1299 up(&shost->scan_mutex); 1287 mutex_unlock(&shost->scan_mutex);
1300 scsi_target_reap(starget); 1288 scsi_target_reap(starget);
1301 put_device(&starget->dev); 1289 put_device(&starget->dev);
1302 1290
@@ -1404,10 +1392,10 @@ void scsi_scan_target(struct device *parent, unsigned int channel,
1404{ 1392{
1405 struct Scsi_Host *shost = dev_to_shost(parent); 1393 struct Scsi_Host *shost = dev_to_shost(parent);
1406 1394
1407 down(&shost->scan_mutex); 1395 mutex_lock(&shost->scan_mutex);
1408 if (scsi_host_scan_allowed(shost)) 1396 if (scsi_host_scan_allowed(shost))
1409 __scsi_scan_target(parent, channel, id, lun, rescan); 1397 __scsi_scan_target(parent, channel, id, lun, rescan);
1410 up(&shost->scan_mutex); 1398 mutex_unlock(&shost->scan_mutex);
1411} 1399}
1412EXPORT_SYMBOL(scsi_scan_target); 1400EXPORT_SYMBOL(scsi_scan_target);
1413 1401
@@ -1454,7 +1442,7 @@ int scsi_scan_host_selected(struct Scsi_Host *shost, unsigned int channel,
1454 ((lun != SCAN_WILD_CARD) && (lun > shost->max_lun))) 1442 ((lun != SCAN_WILD_CARD) && (lun > shost->max_lun)))
1455 return -EINVAL; 1443 return -EINVAL;
1456 1444
1457 down(&shost->scan_mutex); 1445 mutex_lock(&shost->scan_mutex);
1458 if (scsi_host_scan_allowed(shost)) { 1446 if (scsi_host_scan_allowed(shost)) {
1459 if (channel == SCAN_WILD_CARD) 1447 if (channel == SCAN_WILD_CARD)
1460 for (channel = 0; channel <= shost->max_channel; 1448 for (channel = 0; channel <= shost->max_channel;
@@ -1464,7 +1452,7 @@ int scsi_scan_host_selected(struct Scsi_Host *shost, unsigned int channel,
1464 else 1452 else
1465 scsi_scan_channel(shost, channel, id, lun, rescan); 1453 scsi_scan_channel(shost, channel, id, lun, rescan);
1466 } 1454 }
1467 up(&shost->scan_mutex); 1455 mutex_unlock(&shost->scan_mutex);
1468 1456
1469 return 0; 1457 return 0;
1470} 1458}
@@ -1522,7 +1510,7 @@ struct scsi_device *scsi_get_host_dev(struct Scsi_Host *shost)
1522 struct scsi_device *sdev = NULL; 1510 struct scsi_device *sdev = NULL;
1523 struct scsi_target *starget; 1511 struct scsi_target *starget;
1524 1512
1525 down(&shost->scan_mutex); 1513 mutex_lock(&shost->scan_mutex);
1526 if (!scsi_host_scan_allowed(shost)) 1514 if (!scsi_host_scan_allowed(shost))
1527 goto out; 1515 goto out;
1528 starget = scsi_alloc_target(&shost->shost_gendev, 0, shost->this_id); 1516 starget = scsi_alloc_target(&shost->shost_gendev, 0, shost->this_id);
@@ -1536,7 +1524,7 @@ struct scsi_device *scsi_get_host_dev(struct Scsi_Host *shost)
1536 } 1524 }
1537 put_device(&starget->dev); 1525 put_device(&starget->dev);
1538 out: 1526 out:
1539 up(&shost->scan_mutex); 1527 mutex_unlock(&shost->scan_mutex);
1540 return sdev; 1528 return sdev;
1541} 1529}
1542EXPORT_SYMBOL(scsi_get_host_dev); 1530EXPORT_SYMBOL(scsi_get_host_dev);
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index ea7f3a433572..a77b32deaf8f 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -106,7 +106,10 @@ static int scsi_scan(struct Scsi_Host *shost, const char *str)
106 return -EINVAL; 106 return -EINVAL;
107 if (check_set(&lun, s3)) 107 if (check_set(&lun, s3))
108 return -EINVAL; 108 return -EINVAL;
109 res = scsi_scan_host_selected(shost, channel, id, lun, 1); 109 if (shost->transportt->user_scan)
110 res = shost->transportt->user_scan(shost, channel, id, lun);
111 else
112 res = scsi_scan_host_selected(shost, channel, id, lun, 1);
110 return res; 113 return res;
111} 114}
112 115
@@ -745,9 +748,9 @@ void scsi_remove_device(struct scsi_device *sdev)
745{ 748{
746 struct Scsi_Host *shost = sdev->host; 749 struct Scsi_Host *shost = sdev->host;
747 750
748 down(&shost->scan_mutex); 751 mutex_lock(&shost->scan_mutex);
749 __scsi_remove_device(sdev); 752 __scsi_remove_device(sdev);
750 up(&shost->scan_mutex); 753 mutex_unlock(&shost->scan_mutex);
751} 754}
752EXPORT_SYMBOL(scsi_remove_device); 755EXPORT_SYMBOL(scsi_remove_device);
753 756
diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
index 685b997306cf..f2c9acf11bd0 100644
--- a/drivers/scsi/scsi_transport_fc.c
+++ b/drivers/scsi/scsi_transport_fc.c
@@ -295,6 +295,7 @@ static int fc_host_setup(struct transport_container *tc, struct device *dev,
295 */ 295 */
296 fc_host_node_name(shost) = -1; 296 fc_host_node_name(shost) = -1;
297 fc_host_port_name(shost) = -1; 297 fc_host_port_name(shost) = -1;
298 fc_host_permanent_port_name(shost) = -1;
298 fc_host_supported_classes(shost) = FC_COS_UNSPECIFIED; 299 fc_host_supported_classes(shost) = FC_COS_UNSPECIFIED;
299 memset(fc_host_supported_fc4s(shost), 0, 300 memset(fc_host_supported_fc4s(shost), 0,
300 sizeof(fc_host_supported_fc4s(shost))); 301 sizeof(fc_host_supported_fc4s(shost)));
@@ -795,6 +796,8 @@ static FC_CLASS_DEVICE_ATTR(host, supported_speeds, S_IRUGO,
795 796
796fc_private_host_rd_attr_cast(node_name, "0x%llx\n", 20, unsigned long long); 797fc_private_host_rd_attr_cast(node_name, "0x%llx\n", 20, unsigned long long);
797fc_private_host_rd_attr_cast(port_name, "0x%llx\n", 20, unsigned long long); 798fc_private_host_rd_attr_cast(port_name, "0x%llx\n", 20, unsigned long long);
799fc_private_host_rd_attr_cast(permanent_port_name, "0x%llx\n", 20,
800 unsigned long long);
798fc_private_host_rd_attr(symbolic_name, "%s\n", (FC_SYMBOLIC_NAME_SIZE +1)); 801fc_private_host_rd_attr(symbolic_name, "%s\n", (FC_SYMBOLIC_NAME_SIZE +1));
799fc_private_host_rd_attr(maxframe_size, "%u bytes\n", 20); 802fc_private_host_rd_attr(maxframe_size, "%u bytes\n", 20);
800fc_private_host_rd_attr(serial_number, "%s\n", (FC_SERIAL_NUMBER_SIZE +1)); 803fc_private_host_rd_attr(serial_number, "%s\n", (FC_SERIAL_NUMBER_SIZE +1));
@@ -1090,17 +1093,23 @@ static int fc_rport_match(struct attribute_container *cont,
1090/* 1093/*
1091 * Must be called with shost->host_lock held 1094 * Must be called with shost->host_lock held
1092 */ 1095 */
1093static struct device *fc_target_parent(struct Scsi_Host *shost, 1096static int fc_user_scan(struct Scsi_Host *shost, uint channel,
1094 int channel, uint id) 1097 uint id, uint lun)
1095{ 1098{
1096 struct fc_rport *rport; 1099 struct fc_rport *rport;
1097 1100
1098 list_for_each_entry(rport, &fc_host_rports(shost), peers) 1101 list_for_each_entry(rport, &fc_host_rports(shost), peers) {
1099 if ((rport->channel == channel) && 1102 if (rport->scsi_target_id == -1)
1100 (rport->scsi_target_id == id)) 1103 continue;
1101 return &rport->dev;
1102 1104
1103 return NULL; 1105 if ((channel == SCAN_WILD_CARD || channel == rport->channel) &&
1106 (id == SCAN_WILD_CARD || id == rport->scsi_target_id)) {
1107 scsi_scan_target(&rport->dev, rport->channel,
1108 rport->scsi_target_id, lun, 1);
1109 }
1110 }
1111
1112 return 0;
1104} 1113}
1105 1114
1106struct scsi_transport_template * 1115struct scsi_transport_template *
@@ -1139,7 +1148,7 @@ fc_attach_transport(struct fc_function_template *ft)
1139 /* Transport uses the shost workq for scsi scanning */ 1148 /* Transport uses the shost workq for scsi scanning */
1140 i->t.create_work_queue = 1; 1149 i->t.create_work_queue = 1;
1141 1150
1142 i->t.target_parent = fc_target_parent; 1151 i->t.user_scan = fc_user_scan;
1143 1152
1144 /* 1153 /*
1145 * Setup SCSI Target Attributes. 1154 * Setup SCSI Target Attributes.
@@ -1160,6 +1169,7 @@ fc_attach_transport(struct fc_function_template *ft)
1160 count=0; 1169 count=0;
1161 SETUP_HOST_ATTRIBUTE_RD(node_name); 1170 SETUP_HOST_ATTRIBUTE_RD(node_name);
1162 SETUP_HOST_ATTRIBUTE_RD(port_name); 1171 SETUP_HOST_ATTRIBUTE_RD(port_name);
1172 SETUP_HOST_ATTRIBUTE_RD(permanent_port_name);
1163 SETUP_HOST_ATTRIBUTE_RD(supported_classes); 1173 SETUP_HOST_ATTRIBUTE_RD(supported_classes);
1164 SETUP_HOST_ATTRIBUTE_RD(supported_fc4s); 1174 SETUP_HOST_ATTRIBUTE_RD(supported_fc4s);
1165 SETUP_HOST_ATTRIBUTE_RD(symbolic_name); 1175 SETUP_HOST_ATTRIBUTE_RD(symbolic_name);
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index e08462d50c97..59a1c9d9d3bd 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -21,11 +21,9 @@
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 */ 22 */
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/string.h>
25#include <linux/slab.h>
26#include <linux/mempool.h> 24#include <linux/mempool.h>
25#include <linux/mutex.h>
27#include <net/tcp.h> 26#include <net/tcp.h>
28
29#include <scsi/scsi.h> 27#include <scsi/scsi.h>
30#include <scsi/scsi_host.h> 28#include <scsi/scsi_host.h>
31#include <scsi/scsi_device.h> 29#include <scsi/scsi_device.h>
@@ -45,11 +43,6 @@ struct iscsi_internal {
45 */ 43 */
46 struct list_head sessions; 44 struct list_head sessions;
47 /* 45 /*
48 * lock to serialize access to the sessions list which must
49 * be taken after the rx_queue_sema
50 */
51 spinlock_t session_lock;
52 /*
53 * based on transport capabilities, at register time we set these 46 * based on transport capabilities, at register time we set these
54 * bits to tell the transport class it wants attributes displayed 47 * bits to tell the transport class it wants attributes displayed
55 * in sysfs or that it can support different iSCSI Data-Path 48 * in sysfs or that it can support different iSCSI Data-Path
@@ -70,7 +63,7 @@ struct iscsi_internal {
70/* 63/*
71 * list of registered transports and lock that must 64 * list of registered transports and lock that must
72 * be held while accessing list. The iscsi_transport_lock must 65 * be held while accessing list. The iscsi_transport_lock must
73 * be acquired after the rx_queue_sema. 66 * be acquired after the rx_queue_mutex.
74 */ 67 */
75static LIST_HEAD(iscsi_transports); 68static LIST_HEAD(iscsi_transports);
76static DEFINE_SPINLOCK(iscsi_transport_lock); 69static DEFINE_SPINLOCK(iscsi_transport_lock);
@@ -145,7 +138,7 @@ static DECLARE_TRANSPORT_CLASS(iscsi_connection_class,
145 138
146static struct sock *nls; 139static struct sock *nls;
147static int daemon_pid; 140static int daemon_pid;
148static DECLARE_MUTEX(rx_queue_sema); 141static DEFINE_MUTEX(rx_queue_mutex);
149 142
150struct mempool_zone { 143struct mempool_zone {
151 mempool_t *pool; 144 mempool_t *pool;
@@ -156,7 +149,7 @@ struct mempool_zone {
156 spinlock_t freelock; 149 spinlock_t freelock;
157}; 150};
158 151
159static struct mempool_zone z_reply; 152static struct mempool_zone *z_reply;
160 153
161/* 154/*
162 * Z_MAX_* - actual mempool size allocated at the mempool_zone_init() time 155 * Z_MAX_* - actual mempool size allocated at the mempool_zone_init() time
@@ -171,50 +164,271 @@ static struct mempool_zone z_reply;
171#define Z_MAX_ERROR 16 164#define Z_MAX_ERROR 16
172#define Z_HIWAT_ERROR 12 165#define Z_HIWAT_ERROR 12
173 166
174struct iscsi_if_conn { 167static LIST_HEAD(connlist);
175 struct list_head conn_list; /* item in connlist */ 168static DEFINE_SPINLOCK(connlock);
176 struct list_head session_list; /* item in session->connections */
177 iscsi_connh_t connh;
178 int active; /* must be accessed with the connlock */
179 struct Scsi_Host *host; /* originated shost */
180 struct device dev; /* sysfs transport/container device */
181 struct iscsi_transport *transport;
182 struct mempool_zone z_error;
183 struct mempool_zone z_pdu;
184 struct list_head freequeue;
185};
186 169
187#define iscsi_dev_to_if_conn(_dev) \ 170/*
188 container_of(_dev, struct iscsi_if_conn, dev) 171 * The following functions can be used by LLDs that allocate
172 * their own scsi_hosts or by software iscsi LLDs
173 */
174static void iscsi_session_release(struct device *dev)
175{
176 struct iscsi_cls_session *session = iscsi_dev_to_session(dev);
177 struct iscsi_transport *transport = session->transport;
178 struct Scsi_Host *shost;
189 179
190#define iscsi_cdev_to_if_conn(_cdev) \ 180 shost = iscsi_session_to_shost(session);
191 iscsi_dev_to_if_conn(_cdev->dev) 181 scsi_host_put(shost);
182 kfree(session);
183 module_put(transport->owner);
184}
192 185
193static LIST_HEAD(connlist); 186static int iscsi_is_session_dev(const struct device *dev)
194static DEFINE_SPINLOCK(connlock); 187{
188 return dev->release == iscsi_session_release;
189}
195 190
196struct iscsi_if_session { 191/**
197 struct list_head list; /* item in session_list */ 192 * iscsi_create_session - create iscsi class session
198 struct list_head connections; 193 * @shost: scsi host
199 iscsi_sessionh_t sessionh; 194 * @transport: iscsi transport
200 struct iscsi_transport *transport; 195 *
201 struct device dev; /* sysfs transport/container device */ 196 * This can be called from a LLD or iscsi_transport
202}; 197 **/
198struct iscsi_cls_session *
199iscsi_create_session(struct Scsi_Host *shost, struct iscsi_transport *transport)
200{
201 struct iscsi_cls_session *session;
202 int err;
203
204 if (!try_module_get(transport->owner))
205 return NULL;
206
207 session = kzalloc(sizeof(*session), GFP_KERNEL);
208 if (!session)
209 goto module_put;
210 session->transport = transport;
211
212 /* this is released in the dev's release function */
213 scsi_host_get(shost);
214 snprintf(session->dev.bus_id, BUS_ID_SIZE, "session%u", shost->host_no);
215 session->dev.parent = &shost->shost_gendev;
216 session->dev.release = iscsi_session_release;
217 err = device_register(&session->dev);
218 if (err) {
219 dev_printk(KERN_ERR, &session->dev, "iscsi: could not "
220 "register session's dev\n");
221 goto free_session;
222 }
223 transport_register_device(&session->dev);
224
225 return session;
226
227free_session:
228 kfree(session);
229module_put:
230 module_put(transport->owner);
231 return NULL;
232}
233
234EXPORT_SYMBOL_GPL(iscsi_create_session);
235
236/**
237 * iscsi_destroy_session - destroy iscsi session
238 * @session: iscsi_session
239 *
240 * Can be called by a LLD or iscsi_transport. There must not be
241 * any running connections.
242 **/
243int iscsi_destroy_session(struct iscsi_cls_session *session)
244{
245 transport_unregister_device(&session->dev);
246 device_unregister(&session->dev);
247 return 0;
248}
249
250EXPORT_SYMBOL_GPL(iscsi_destroy_session);
251
252static void iscsi_conn_release(struct device *dev)
253{
254 struct iscsi_cls_conn *conn = iscsi_dev_to_conn(dev);
255 struct device *parent = conn->dev.parent;
256
257 kfree(conn);
258 put_device(parent);
259}
260
261static int iscsi_is_conn_dev(const struct device *dev)
262{
263 return dev->release == iscsi_conn_release;
264}
265
266/**
267 * iscsi_create_conn - create iscsi class connection
268 * @session: iscsi cls session
269 * @cid: connection id
270 *
271 * This can be called from a LLD or iscsi_transport. The connection
272 * is child of the session so cid must be unique for all connections
273 * on the session.
274 **/
275struct iscsi_cls_conn *
276iscsi_create_conn(struct iscsi_cls_session *session, uint32_t cid)
277{
278 struct iscsi_transport *transport = session->transport;
279 struct Scsi_Host *shost = iscsi_session_to_shost(session);
280 struct iscsi_cls_conn *conn;
281 int err;
282
283 conn = kzalloc(sizeof(*conn) + transport->conndata_size, GFP_KERNEL);
284 if (!conn)
285 return NULL;
286
287 if (transport->conndata_size)
288 conn->dd_data = &conn[1];
289
290 INIT_LIST_HEAD(&conn->conn_list);
291 conn->transport = transport;
292
293 /* this is released in the dev's release function */
294 if (!get_device(&session->dev))
295 goto free_conn;
296 snprintf(conn->dev.bus_id, BUS_ID_SIZE, "connection%d:%u",
297 shost->host_no, cid);
298 conn->dev.parent = &session->dev;
299 conn->dev.release = iscsi_conn_release;
300 err = device_register(&conn->dev);
301 if (err) {
302 dev_printk(KERN_ERR, &conn->dev, "iscsi: could not register "
303 "connection's dev\n");
304 goto release_parent_ref;
305 }
306 transport_register_device(&conn->dev);
307 return conn;
308
309release_parent_ref:
310 put_device(&session->dev);
311free_conn:
312 kfree(conn);
313 return NULL;
314}
315
316EXPORT_SYMBOL_GPL(iscsi_create_conn);
317
318/**
319 * iscsi_destroy_conn - destroy iscsi class connection
320 * @session: iscsi cls session
321 *
322 * This can be called from a LLD or iscsi_transport.
323 **/
324int iscsi_destroy_conn(struct iscsi_cls_conn *conn)
325{
326 transport_unregister_device(&conn->dev);
327 device_unregister(&conn->dev);
328 return 0;
329}
330
331EXPORT_SYMBOL_GPL(iscsi_destroy_conn);
332
333/*
334 * These functions are used only by software iscsi_transports
335 * which do not allocate and more their scsi_hosts since this
336 * is initiated from userspace.
337 */
338
339/*
340 * iSCSI Session's hostdata organization:
341 *
342 * *------------------* <== hostdata_session(host->hostdata)
343 * | ptr to class sess|
344 * |------------------| <== iscsi_hostdata(host->hostdata)
345 * | transport's data |
346 * *------------------*
347 */
348
349#define hostdata_privsize(_t) (sizeof(unsigned long) + _t->hostdata_size + \
350 _t->hostdata_size % sizeof(unsigned long))
351
352#define hostdata_session(_hostdata) (iscsi_ptr(*(unsigned long *)_hostdata))
353
354/**
355 * iscsi_transport_create_session - create iscsi cls session and host
356 * scsit: scsi transport template
357 * transport: iscsi transport template
358 *
359 * This can be used by software iscsi_transports that allocate
360 * a session per scsi host.
361 **/
362struct Scsi_Host *
363iscsi_transport_create_session(struct scsi_transport_template *scsit,
364 struct iscsi_transport *transport)
365{
366 struct iscsi_cls_session *session;
367 struct Scsi_Host *shost;
368
369 shost = scsi_host_alloc(transport->host_template,
370 hostdata_privsize(transport));
371 if (!shost) {
372 printk(KERN_ERR "iscsi: can not allocate SCSI host for "
373 "session\n");
374 return NULL;
375 }
376
377 shost->max_id = 1;
378 shost->max_channel = 0;
379 shost->max_lun = transport->max_lun;
380 shost->max_cmd_len = transport->max_cmd_len;
381 shost->transportt = scsit;
382 shost->transportt->create_work_queue = 1;
383
384 if (scsi_add_host(shost, NULL))
385 goto free_host;
386
387 session = iscsi_create_session(shost, transport);
388 if (!session)
389 goto remove_host;
203 390
204#define iscsi_dev_to_if_session(_dev) \ 391 *(unsigned long*)shost->hostdata = (unsigned long)session;
205 container_of(_dev, struct iscsi_if_session, dev) 392 return shost;
393
394remove_host:
395 scsi_remove_host(shost);
396free_host:
397 scsi_host_put(shost);
398 return NULL;
399}
206 400
207#define iscsi_cdev_to_if_session(_cdev) \ 401EXPORT_SYMBOL_GPL(iscsi_transport_create_session);
208 iscsi_dev_to_if_session(_cdev->dev)
209 402
210#define iscsi_if_session_to_shost(_session) \ 403/**
211 dev_to_shost(_session->dev.parent) 404 * iscsi_transport_destroy_session - destroy session and scsi host
405 * shost: scsi host
406 *
407 * This can be used by software iscsi_transports that allocate
408 * a session per scsi host.
409 **/
410int iscsi_transport_destroy_session(struct Scsi_Host *shost)
411{
412 struct iscsi_cls_session *session;
212 413
213static struct iscsi_if_conn* 414 scsi_remove_host(shost);
415 session = hostdata_session(shost->hostdata);
416 iscsi_destroy_session(session);
417 /* ref from host alloc */
418 scsi_host_put(shost);
419 return 0;
420}
421
422EXPORT_SYMBOL_GPL(iscsi_transport_destroy_session);
423
424/*
425 * iscsi interface functions
426 */
427static struct iscsi_cls_conn*
214iscsi_if_find_conn(uint64_t key) 428iscsi_if_find_conn(uint64_t key)
215{ 429{
216 unsigned long flags; 430 unsigned long flags;
217 struct iscsi_if_conn *conn; 431 struct iscsi_cls_conn *conn;
218 432
219 spin_lock_irqsave(&connlock, flags); 433 spin_lock_irqsave(&connlock, flags);
220 list_for_each_entry(conn, &connlist, conn_list) 434 list_for_each_entry(conn, &connlist, conn_list)
@@ -249,7 +463,7 @@ static inline struct list_head *skb_to_lh(struct sk_buff *skb)
249} 463}
250 464
251static void* 465static void*
252mempool_zone_alloc_skb(gfp_t gfp_mask, void *pool_data) 466mempool_zone_alloc_skb(unsigned int gfp_mask, void *pool_data)
253{ 467{
254 struct mempool_zone *zone = pool_data; 468 struct mempool_zone *zone = pool_data;
255 469
@@ -281,14 +495,21 @@ mempool_zone_complete(struct mempool_zone *zone)
281 spin_unlock_irqrestore(&zone->freelock, flags); 495 spin_unlock_irqrestore(&zone->freelock, flags);
282} 496}
283 497
284static int 498static struct mempool_zone *
285mempool_zone_init(struct mempool_zone *zp, unsigned max, unsigned size, 499mempool_zone_init(unsigned max, unsigned size, unsigned hiwat)
286 unsigned hiwat)
287{ 500{
501 struct mempool_zone *zp;
502
503 zp = kzalloc(sizeof(*zp), GFP_KERNEL);
504 if (!zp)
505 return NULL;
506
288 zp->pool = mempool_create(max, mempool_zone_alloc_skb, 507 zp->pool = mempool_create(max, mempool_zone_alloc_skb,
289 mempool_zone_free_skb, zp); 508 mempool_zone_free_skb, zp);
290 if (!zp->pool) 509 if (!zp->pool) {
291 return -ENOMEM; 510 kfree(zp);
511 return NULL;
512 }
292 513
293 zp->size = size; 514 zp->size = size;
294 zp->hiwat = hiwat; 515 zp->hiwat = hiwat;
@@ -297,9 +518,14 @@ mempool_zone_init(struct mempool_zone *zp, unsigned max, unsigned size,
297 spin_lock_init(&zp->freelock); 518 spin_lock_init(&zp->freelock);
298 atomic_set(&zp->allocated, 0); 519 atomic_set(&zp->allocated, 0);
299 520
300 return 0; 521 return zp;
301} 522}
302 523
524static void mempool_zone_destroy(struct mempool_zone *zp)
525{
526 mempool_destroy(zp->pool);
527 kfree(zp);
528}
303 529
304static struct sk_buff* 530static struct sk_buff*
305mempool_zone_get_skb(struct mempool_zone *zone) 531mempool_zone_get_skb(struct mempool_zone *zone)
@@ -339,7 +565,7 @@ int iscsi_recv_pdu(iscsi_connh_t connh, struct iscsi_hdr *hdr,
339 struct nlmsghdr *nlh; 565 struct nlmsghdr *nlh;
340 struct sk_buff *skb; 566 struct sk_buff *skb;
341 struct iscsi_uevent *ev; 567 struct iscsi_uevent *ev;
342 struct iscsi_if_conn *conn; 568 struct iscsi_cls_conn *conn;
343 char *pdu; 569 char *pdu;
344 int len = NLMSG_SPACE(sizeof(*ev) + sizeof(struct iscsi_hdr) + 570 int len = NLMSG_SPACE(sizeof(*ev) + sizeof(struct iscsi_hdr) +
345 data_size); 571 data_size);
@@ -347,13 +573,13 @@ int iscsi_recv_pdu(iscsi_connh_t connh, struct iscsi_hdr *hdr,
347 conn = iscsi_if_find_conn(connh); 573 conn = iscsi_if_find_conn(connh);
348 BUG_ON(!conn); 574 BUG_ON(!conn);
349 575
350 mempool_zone_complete(&conn->z_pdu); 576 mempool_zone_complete(conn->z_pdu);
351 577
352 skb = mempool_zone_get_skb(&conn->z_pdu); 578 skb = mempool_zone_get_skb(conn->z_pdu);
353 if (!skb) { 579 if (!skb) {
354 iscsi_conn_error(connh, ISCSI_ERR_CONN_FAILED); 580 iscsi_conn_error(connh, ISCSI_ERR_CONN_FAILED);
355 printk(KERN_ERR "iscsi%d: can not deliver control PDU: OOM\n", 581 dev_printk(KERN_ERR, &conn->dev, "iscsi: can not deliver "
356 conn->host->host_no); 582 "control PDU: OOM\n");
357 return -ENOMEM; 583 return -ENOMEM;
358 } 584 }
359 585
@@ -362,14 +588,14 @@ int iscsi_recv_pdu(iscsi_connh_t connh, struct iscsi_hdr *hdr,
362 memset(ev, 0, sizeof(*ev)); 588 memset(ev, 0, sizeof(*ev));
363 ev->transport_handle = iscsi_handle(conn->transport); 589 ev->transport_handle = iscsi_handle(conn->transport);
364 ev->type = ISCSI_KEVENT_RECV_PDU; 590 ev->type = ISCSI_KEVENT_RECV_PDU;
365 if (atomic_read(&conn->z_pdu.allocated) >= conn->z_pdu.hiwat) 591 if (atomic_read(&conn->z_pdu->allocated) >= conn->z_pdu->hiwat)
366 ev->iferror = -ENOMEM; 592 ev->iferror = -ENOMEM;
367 ev->r.recv_req.conn_handle = connh; 593 ev->r.recv_req.conn_handle = connh;
368 pdu = (char*)ev + sizeof(*ev); 594 pdu = (char*)ev + sizeof(*ev);
369 memcpy(pdu, hdr, sizeof(struct iscsi_hdr)); 595 memcpy(pdu, hdr, sizeof(struct iscsi_hdr));
370 memcpy(pdu + sizeof(struct iscsi_hdr), data, data_size); 596 memcpy(pdu + sizeof(struct iscsi_hdr), data, data_size);
371 597
372 return iscsi_unicast_skb(&conn->z_pdu, skb); 598 return iscsi_unicast_skb(conn->z_pdu, skb);
373} 599}
374EXPORT_SYMBOL_GPL(iscsi_recv_pdu); 600EXPORT_SYMBOL_GPL(iscsi_recv_pdu);
375 601
@@ -378,18 +604,18 @@ void iscsi_conn_error(iscsi_connh_t connh, enum iscsi_err error)
378 struct nlmsghdr *nlh; 604 struct nlmsghdr *nlh;
379 struct sk_buff *skb; 605 struct sk_buff *skb;
380 struct iscsi_uevent *ev; 606 struct iscsi_uevent *ev;
381 struct iscsi_if_conn *conn; 607 struct iscsi_cls_conn *conn;
382 int len = NLMSG_SPACE(sizeof(*ev)); 608 int len = NLMSG_SPACE(sizeof(*ev));
383 609
384 conn = iscsi_if_find_conn(connh); 610 conn = iscsi_if_find_conn(connh);
385 BUG_ON(!conn); 611 BUG_ON(!conn);
386 612
387 mempool_zone_complete(&conn->z_error); 613 mempool_zone_complete(conn->z_error);
388 614
389 skb = mempool_zone_get_skb(&conn->z_error); 615 skb = mempool_zone_get_skb(conn->z_error);
390 if (!skb) { 616 if (!skb) {
391 printk(KERN_ERR "iscsi%d: gracefully ignored conn error (%d)\n", 617 dev_printk(KERN_ERR, &conn->dev, "iscsi: gracefully ignored "
392 conn->host->host_no, error); 618 "conn error (%d)\n", error);
393 return; 619 return;
394 } 620 }
395 621
@@ -397,15 +623,15 @@ void iscsi_conn_error(iscsi_connh_t connh, enum iscsi_err error)
397 ev = NLMSG_DATA(nlh); 623 ev = NLMSG_DATA(nlh);
398 ev->transport_handle = iscsi_handle(conn->transport); 624 ev->transport_handle = iscsi_handle(conn->transport);
399 ev->type = ISCSI_KEVENT_CONN_ERROR; 625 ev->type = ISCSI_KEVENT_CONN_ERROR;
400 if (atomic_read(&conn->z_error.allocated) >= conn->z_error.hiwat) 626 if (atomic_read(&conn->z_error->allocated) >= conn->z_error->hiwat)
401 ev->iferror = -ENOMEM; 627 ev->iferror = -ENOMEM;
402 ev->r.connerror.error = error; 628 ev->r.connerror.error = error;
403 ev->r.connerror.conn_handle = connh; 629 ev->r.connerror.conn_handle = connh;
404 630
405 iscsi_unicast_skb(&conn->z_error, skb); 631 iscsi_unicast_skb(conn->z_error, skb);
406 632
407 printk(KERN_INFO "iscsi%d: detected conn error (%d)\n", 633 dev_printk(KERN_INFO, &conn->dev, "iscsi: detected conn error (%d)\n",
408 conn->host->host_no, error); 634 error);
409} 635}
410EXPORT_SYMBOL_GPL(iscsi_conn_error); 636EXPORT_SYMBOL_GPL(iscsi_conn_error);
411 637
@@ -419,9 +645,9 @@ iscsi_if_send_reply(int pid, int seq, int type, int done, int multi,
419 int flags = multi ? NLM_F_MULTI : 0; 645 int flags = multi ? NLM_F_MULTI : 0;
420 int t = done ? NLMSG_DONE : type; 646 int t = done ? NLMSG_DONE : type;
421 647
422 mempool_zone_complete(&z_reply); 648 mempool_zone_complete(z_reply);
423 649
424 skb = mempool_zone_get_skb(&z_reply); 650 skb = mempool_zone_get_skb(z_reply);
425 /* 651 /*
426 * FIXME: 652 * FIXME:
427 * user is supposed to react on iferror == -ENOMEM; 653 * user is supposed to react on iferror == -ENOMEM;
@@ -432,366 +658,197 @@ iscsi_if_send_reply(int pid, int seq, int type, int done, int multi,
432 nlh = __nlmsg_put(skb, pid, seq, t, (len - sizeof(*nlh)), 0); 658 nlh = __nlmsg_put(skb, pid, seq, t, (len - sizeof(*nlh)), 0);
433 nlh->nlmsg_flags = flags; 659 nlh->nlmsg_flags = flags;
434 memcpy(NLMSG_DATA(nlh), payload, size); 660 memcpy(NLMSG_DATA(nlh), payload, size);
435 return iscsi_unicast_skb(&z_reply, skb); 661 return iscsi_unicast_skb(z_reply, skb);
436} 662}
437 663
438/* 664static int
439 * iSCSI Session's hostdata organization: 665iscsi_if_get_stats(struct iscsi_transport *transport, struct sk_buff *skb,
440 * 666 struct nlmsghdr *nlh)
441 * *------------------* <== host->hostdata 667{
442 * | transport | 668 struct iscsi_uevent *ev = NLMSG_DATA(nlh);
443 * |------------------| <== iscsi_hostdata(host->hostdata) 669 struct iscsi_stats *stats;
444 * | transport's data | 670 struct sk_buff *skbstat;
445 * |------------------| <== hostdata_session(host->hostdata) 671 struct iscsi_cls_conn *conn;
446 * | interface's data | 672 struct nlmsghdr *nlhstat;
447 * *------------------* 673 struct iscsi_uevent *evstat;
448 */ 674 int len = NLMSG_SPACE(sizeof(*ev) +
675 sizeof(struct iscsi_stats) +
676 sizeof(struct iscsi_stats_custom) *
677 ISCSI_STATS_CUSTOM_MAX);
678 int err = 0;
449 679
450#define hostdata_privsize(_t) (sizeof(unsigned long) + _t->hostdata_size + \ 680 conn = iscsi_if_find_conn(ev->u.get_stats.conn_handle);
451 _t->hostdata_size % sizeof(unsigned long) + \ 681 if (!conn)
452 sizeof(struct iscsi_if_session)) 682 return -EEXIST;
453 683
454#define hostdata_session(_hostdata) ((void*)_hostdata + sizeof(unsigned long) + \ 684 do {
455 ((struct iscsi_transport *) \ 685 int actual_size;
456 iscsi_ptr(*(uint64_t *)_hostdata))->hostdata_size)
457 686
458static void iscsi_if_session_dev_release(struct device *dev) 687 mempool_zone_complete(conn->z_pdu);
459{
460 struct iscsi_if_session *session = iscsi_dev_to_if_session(dev);
461 struct iscsi_transport *transport = session->transport;
462 struct Scsi_Host *shost = iscsi_if_session_to_shost(session);
463 struct iscsi_if_conn *conn, *tmp;
464 unsigned long flags;
465 688
466 /* now free connections */ 689 skbstat = mempool_zone_get_skb(conn->z_pdu);
467 spin_lock_irqsave(&connlock, flags); 690 if (!skbstat) {
468 list_for_each_entry_safe(conn, tmp, &session->connections, 691 dev_printk(KERN_ERR, &conn->dev, "iscsi: can not "
469 session_list) { 692 "deliver stats: OOM\n");
470 list_del(&conn->session_list); 693 return -ENOMEM;
471 mempool_destroy(conn->z_pdu.pool); 694 }
472 mempool_destroy(conn->z_error.pool); 695
473 kfree(conn); 696 nlhstat = __nlmsg_put(skbstat, daemon_pid, 0, 0,
474 } 697 (len - sizeof(*nlhstat)), 0);
475 spin_unlock_irqrestore(&connlock, flags); 698 evstat = NLMSG_DATA(nlhstat);
476 scsi_host_put(shost); 699 memset(evstat, 0, sizeof(*evstat));
477 module_put(transport->owner); 700 evstat->transport_handle = iscsi_handle(conn->transport);
701 evstat->type = nlh->nlmsg_type;
702 if (atomic_read(&conn->z_pdu->allocated) >= conn->z_pdu->hiwat)
703 evstat->iferror = -ENOMEM;
704 evstat->u.get_stats.conn_handle =
705 ev->u.get_stats.conn_handle;
706 stats = (struct iscsi_stats *)
707 ((char*)evstat + sizeof(*evstat));
708 memset(stats, 0, sizeof(*stats));
709
710 transport->get_stats(ev->u.get_stats.conn_handle, stats);
711 actual_size = NLMSG_SPACE(sizeof(struct iscsi_uevent) +
712 sizeof(struct iscsi_stats) +
713 sizeof(struct iscsi_stats_custom) *
714 stats->custom_length);
715 actual_size -= sizeof(*nlhstat);
716 actual_size = NLMSG_LENGTH(actual_size);
717 skb_trim(skb, NLMSG_ALIGN(actual_size));
718 nlhstat->nlmsg_len = actual_size;
719
720 err = iscsi_unicast_skb(conn->z_pdu, skbstat);
721 } while (err < 0 && err != -ECONNREFUSED);
722
723 return err;
478} 724}
479 725
480static int 726static int
481iscsi_if_create_session(struct iscsi_internal *priv, struct iscsi_uevent *ev) 727iscsi_if_create_session(struct iscsi_internal *priv, struct iscsi_uevent *ev)
482{ 728{
483 struct iscsi_transport *transport = priv->iscsi_transport; 729 struct iscsi_transport *transport = priv->iscsi_transport;
484 struct iscsi_if_session *session;
485 struct Scsi_Host *shost; 730 struct Scsi_Host *shost;
486 unsigned long flags;
487 int error;
488
489 if (!try_module_get(transport->owner))
490 return -EPERM;
491 731
492 shost = scsi_host_alloc(transport->host_template, 732 if (!transport->create_session)
493 hostdata_privsize(transport)); 733 return -EINVAL;
494 if (!shost) {
495 ev->r.c_session_ret.session_handle = iscsi_handle(NULL);
496 printk(KERN_ERR "iscsi: can not allocate SCSI host for "
497 "session\n");
498 error = -ENOMEM;
499 goto out_module_put;
500 }
501 shost->max_id = 1;
502 shost->max_channel = 0;
503 shost->max_lun = transport->max_lun;
504 shost->max_cmd_len = transport->max_cmd_len;
505 shost->transportt = &priv->t;
506
507 /* store struct iscsi_transport in hostdata */
508 *(uint64_t*)shost->hostdata = ev->transport_handle;
509 734
510 ev->r.c_session_ret.session_handle = transport->create_session( 735 shost = transport->create_session(&priv->t,
511 ev->u.c_session.initial_cmdsn, shost); 736 ev->u.c_session.initial_cmdsn);
512 if (ev->r.c_session_ret.session_handle == iscsi_handle(NULL)) { 737 if (!shost)
513 error = 0; 738 return -ENOMEM;
514 goto out_host_put;
515 }
516 739
517 /* host_no becomes assigned SID */ 740 ev->r.c_session_ret.session_handle = iscsi_handle(iscsi_hostdata(shost->hostdata));
518 ev->r.c_session_ret.sid = shost->host_no; 741 ev->r.c_session_ret.sid = shost->host_no;
519 /* initialize session */
520 session = hostdata_session(shost->hostdata);
521 INIT_LIST_HEAD(&session->connections);
522 INIT_LIST_HEAD(&session->list);
523 session->sessionh = ev->r.c_session_ret.session_handle;
524 session->transport = transport;
525
526 error = scsi_add_host(shost, NULL);
527 if (error)
528 goto out_destroy_session;
529
530 /*
531 * this is released in the dev's release function)
532 */
533 scsi_host_get(shost);
534 snprintf(session->dev.bus_id, BUS_ID_SIZE, "session%u", shost->host_no);
535 session->dev.parent = &shost->shost_gendev;
536 session->dev.release = iscsi_if_session_dev_release;
537 error = device_register(&session->dev);
538 if (error) {
539 printk(KERN_ERR "iscsi: could not register session%d's dev\n",
540 shost->host_no);
541 goto out_remove_host;
542 }
543 transport_register_device(&session->dev);
544
545 /* add this session to the list of active sessions */
546 spin_lock_irqsave(&priv->session_lock, flags);
547 list_add(&session->list, &priv->sessions);
548 spin_unlock_irqrestore(&priv->session_lock, flags);
549
550 return 0; 742 return 0;
551
552out_remove_host:
553 scsi_remove_host(shost);
554out_destroy_session:
555 transport->destroy_session(ev->r.c_session_ret.session_handle);
556 ev->r.c_session_ret.session_handle = iscsi_handle(NULL);
557out_host_put:
558 scsi_host_put(shost);
559out_module_put:
560 module_put(transport->owner);
561 return error;
562} 743}
563 744
564static int 745static int
565iscsi_if_destroy_session(struct iscsi_internal *priv, struct iscsi_uevent *ev) 746iscsi_if_destroy_session(struct iscsi_internal *priv, struct iscsi_uevent *ev)
566{ 747{
567 struct iscsi_transport *transport = priv->iscsi_transport; 748 struct iscsi_transport *transport = priv->iscsi_transport;
749
568 struct Scsi_Host *shost; 750 struct Scsi_Host *shost;
569 struct iscsi_if_session *session; 751
570 unsigned long flags; 752 if (!transport->destroy_session)
571 struct iscsi_if_conn *conn; 753 return -EINVAL;
572 int error = 0;
573 754
574 shost = scsi_host_lookup(ev->u.d_session.sid); 755 shost = scsi_host_lookup(ev->u.d_session.sid);
575 if (shost == ERR_PTR(-ENXIO)) 756 if (shost == ERR_PTR(-ENXIO))
576 return -EEXIST; 757 return -EEXIST;
577 session = hostdata_session(shost->hostdata);
578 758
579 /* check if we have active connections */ 759 if (transport->destroy_session)
580 spin_lock_irqsave(&connlock, flags); 760 transport->destroy_session(shost);
581 list_for_each_entry(conn, &session->connections, session_list) { 761 /* ref from host lookup */
582 if (conn->active) { 762 scsi_host_put(shost);
583 printk(KERN_ERR "iscsi%d: can not destroy session: " 763 return 0;
584 "has active connection (%p)\n",
585 shost->host_no, iscsi_ptr(conn->connh));
586 spin_unlock_irqrestore(&connlock, flags);
587 error = EIO;
588 goto out_release_ref;
589 }
590 }
591 spin_unlock_irqrestore(&connlock, flags);
592
593 scsi_remove_host(shost);
594 transport->destroy_session(ev->u.d_session.session_handle);
595 transport_unregister_device(&session->dev);
596 device_unregister(&session->dev);
597
598 /* remove this session from the list of active sessions */
599 spin_lock_irqsave(&priv->session_lock, flags);
600 list_del(&session->list);
601 spin_unlock_irqrestore(&priv->session_lock, flags);
602
603 /* ref from host alloc */
604 scsi_host_put(shost);
605out_release_ref:
606 /* ref from host lookup */
607 scsi_host_put(shost);
608 return error;
609}
610
611static void iscsi_if_conn_dev_release(struct device *dev)
612{
613 struct iscsi_if_conn *conn = iscsi_dev_to_if_conn(dev);
614 struct Scsi_Host *shost = conn->host;
615
616 scsi_host_put(shost);
617} 764}
618 765
619static int 766static int
620iscsi_if_create_conn(struct iscsi_transport *transport, struct iscsi_uevent *ev) 767iscsi_if_create_conn(struct iscsi_transport *transport, struct iscsi_uevent *ev){
621{
622 struct iscsi_if_session *session;
623 struct Scsi_Host *shost; 768 struct Scsi_Host *shost;
624 struct iscsi_if_conn *conn; 769 struct iscsi_cls_conn *conn;
625 unsigned long flags; 770 unsigned long flags;
626 int error; 771
772 if (!transport->create_conn)
773 return -EINVAL;
627 774
628 shost = scsi_host_lookup(ev->u.c_conn.sid); 775 shost = scsi_host_lookup(ev->u.c_conn.sid);
629 if (shost == ERR_PTR(-ENXIO)) 776 if (shost == ERR_PTR(-ENXIO))
630 return -EEXIST; 777 return -EEXIST;
631 session = hostdata_session(shost->hostdata);
632 778
633 conn = kmalloc(sizeof(struct iscsi_if_conn), GFP_KERNEL); 779 conn = transport->create_conn(shost, ev->u.c_conn.cid);
634 if (!conn) { 780 if (!conn)
635 error = -ENOMEM; 781 goto release_ref;
636 goto out_release_ref;
637 }
638 memset(conn, 0, sizeof(struct iscsi_if_conn));
639 INIT_LIST_HEAD(&conn->session_list);
640 INIT_LIST_HEAD(&conn->conn_list);
641 conn->host = shost;
642 conn->transport = transport;
643 782
644 error = mempool_zone_init(&conn->z_pdu, Z_MAX_PDU, 783 conn->z_pdu = mempool_zone_init(Z_MAX_PDU,
645 NLMSG_SPACE(sizeof(struct iscsi_uevent) + 784 NLMSG_SPACE(sizeof(struct iscsi_uevent) +
646 sizeof(struct iscsi_hdr) + 785 sizeof(struct iscsi_hdr) +
647 DEFAULT_MAX_RECV_DATA_SEGMENT_LENGTH), 786 DEFAULT_MAX_RECV_DATA_SEGMENT_LENGTH),
648 Z_HIWAT_PDU); 787 Z_HIWAT_PDU);
649 if (error) { 788 if (!conn->z_pdu) {
650 printk(KERN_ERR "iscsi%d: can not allocate pdu zone for new " 789 dev_printk(KERN_ERR, &conn->dev, "iscsi: can not allocate "
651 "conn\n", shost->host_no); 790 "pdu zone for new conn\n");
652 goto out_free_conn; 791 goto destroy_conn;
653 } 792 }
654 error = mempool_zone_init(&conn->z_error, Z_MAX_ERROR, 793
794 conn->z_error = mempool_zone_init(Z_MAX_ERROR,
655 NLMSG_SPACE(sizeof(struct iscsi_uevent)), 795 NLMSG_SPACE(sizeof(struct iscsi_uevent)),
656 Z_HIWAT_ERROR); 796 Z_HIWAT_ERROR);
657 if (error) { 797 if (!conn->z_error) {
658 printk(KERN_ERR "iscsi%d: can not allocate error zone for " 798 dev_printk(KERN_ERR, &conn->dev, "iscsi: can not allocate "
659 "new conn\n", shost->host_no); 799 "error zone for new conn\n");
660 goto out_free_pdu_pool; 800 goto free_pdu_pool;
661 }
662
663 ev->r.handle = transport->create_conn(ev->u.c_conn.session_handle,
664 ev->u.c_conn.cid);
665 if (!ev->r.handle) {
666 error = -ENODEV;
667 goto out_free_error_pool;
668 } 801 }
669 802
670 conn->connh = ev->r.handle; 803 ev->r.handle = conn->connh = iscsi_handle(conn->dd_data);
671
672 /*
673 * this is released in the dev's release function
674 */
675 if (!scsi_host_get(shost))
676 goto out_destroy_conn;
677 snprintf(conn->dev.bus_id, BUS_ID_SIZE, "connection%d:%u",
678 shost->host_no, ev->u.c_conn.cid);
679 conn->dev.parent = &session->dev;
680 conn->dev.release = iscsi_if_conn_dev_release;
681 error = device_register(&conn->dev);
682 if (error) {
683 printk(KERN_ERR "iscsi%d: could not register connections%u "
684 "dev\n", shost->host_no, ev->u.c_conn.cid);
685 goto out_release_parent_ref;
686 }
687 transport_register_device(&conn->dev);
688 804
689 spin_lock_irqsave(&connlock, flags); 805 spin_lock_irqsave(&connlock, flags);
690 list_add(&conn->conn_list, &connlist); 806 list_add(&conn->conn_list, &connlist);
691 list_add(&conn->session_list, &session->connections);
692 conn->active = 1; 807 conn->active = 1;
693 spin_unlock_irqrestore(&connlock, flags); 808 spin_unlock_irqrestore(&connlock, flags);
694 809
695 scsi_host_put(shost); 810 scsi_host_put(shost);
696 return 0; 811 return 0;
697 812
698out_release_parent_ref: 813free_pdu_pool:
814 mempool_zone_destroy(conn->z_pdu);
815destroy_conn:
816 if (transport->destroy_conn)
817 transport->destroy_conn(conn->dd_data);
818release_ref:
699 scsi_host_put(shost); 819 scsi_host_put(shost);
700out_destroy_conn: 820 return -ENOMEM;
701 transport->destroy_conn(ev->r.handle);
702out_free_error_pool:
703 mempool_destroy(conn->z_error.pool);
704out_free_pdu_pool:
705 mempool_destroy(conn->z_pdu.pool);
706out_free_conn:
707 kfree(conn);
708out_release_ref:
709 scsi_host_put(shost);
710 return error;
711} 821}
712 822
713static int 823static int
714iscsi_if_destroy_conn(struct iscsi_transport *transport, struct iscsi_uevent *ev) 824iscsi_if_destroy_conn(struct iscsi_transport *transport, struct iscsi_uevent *ev)
715{ 825{
716 unsigned long flags; 826 unsigned long flags;
717 struct iscsi_if_conn *conn; 827 struct iscsi_cls_conn *conn;
828 struct mempool_zone *z_error, *z_pdu;
718 829
719 conn = iscsi_if_find_conn(ev->u.d_conn.conn_handle); 830 conn = iscsi_if_find_conn(ev->u.d_conn.conn_handle);
720 if (!conn) 831 if (!conn)
721 return -EEXIST; 832 return -EEXIST;
722 833
723 transport->destroy_conn(ev->u.d_conn.conn_handle); 834 if (!transport->destroy_conn)
835 return -EINVAL;
724 836
725 spin_lock_irqsave(&connlock, flags); 837 spin_lock_irqsave(&connlock, flags);
726 conn->active = 0; 838 conn->active = 0;
727 list_del(&conn->conn_list); 839 list_del(&conn->conn_list);
728 spin_unlock_irqrestore(&connlock, flags); 840 spin_unlock_irqrestore(&connlock, flags);
729 841
730 transport_unregister_device(&conn->dev); 842 z_pdu = conn->z_pdu;
731 device_unregister(&conn->dev); 843 z_error = conn->z_error;
732 return 0;
733}
734
735static int
736iscsi_if_get_stats(struct iscsi_transport *transport, struct sk_buff *skb,
737 struct nlmsghdr *nlh)
738{
739 struct iscsi_uevent *ev = NLMSG_DATA(nlh);
740 struct iscsi_stats *stats;
741 struct sk_buff *skbstat;
742 struct iscsi_if_conn *conn;
743 struct nlmsghdr *nlhstat;
744 struct iscsi_uevent *evstat;
745 int len = NLMSG_SPACE(sizeof(*ev) +
746 sizeof(struct iscsi_stats) +
747 sizeof(struct iscsi_stats_custom) *
748 ISCSI_STATS_CUSTOM_MAX);
749 int err = 0;
750
751 conn = iscsi_if_find_conn(ev->u.get_stats.conn_handle);
752 if (!conn)
753 return -EEXIST;
754
755 do {
756 int actual_size;
757
758 mempool_zone_complete(&conn->z_pdu);
759
760 skbstat = mempool_zone_get_skb(&conn->z_pdu);
761 if (!skbstat) {
762 printk(KERN_ERR "iscsi%d: can not deliver stats: OOM\n",
763 conn->host->host_no);
764 return -ENOMEM;
765 }
766
767 nlhstat = __nlmsg_put(skbstat, daemon_pid, 0, 0,
768 (len - sizeof(*nlhstat)), 0);
769 evstat = NLMSG_DATA(nlhstat);
770 memset(evstat, 0, sizeof(*evstat));
771 evstat->transport_handle = iscsi_handle(conn->transport);
772 evstat->type = nlh->nlmsg_type;
773 if (atomic_read(&conn->z_pdu.allocated) >= conn->z_pdu.hiwat)
774 evstat->iferror = -ENOMEM;
775 evstat->u.get_stats.conn_handle =
776 ev->u.get_stats.conn_handle;
777 stats = (struct iscsi_stats *)
778 ((char*)evstat + sizeof(*evstat));
779 memset(stats, 0, sizeof(*stats));
780 844
781 transport->get_stats(ev->u.get_stats.conn_handle, stats); 845 if (transport->destroy_conn)
782 actual_size = NLMSG_SPACE(sizeof(struct iscsi_uevent) + 846 transport->destroy_conn(conn);
783 sizeof(struct iscsi_stats) +
784 sizeof(struct iscsi_stats_custom) *
785 stats->custom_length);
786 actual_size -= sizeof(*nlhstat);
787 actual_size = NLMSG_LENGTH(actual_size);
788 skb_trim(skb, NLMSG_ALIGN(actual_size));
789 nlhstat->nlmsg_len = actual_size;
790 847
791 err = iscsi_unicast_skb(&conn->z_pdu, skbstat); 848 mempool_zone_destroy(z_pdu);
792 } while (err < 0 && err != -ECONNREFUSED); 849 mempool_zone_destroy(z_error);
793 850
794 return err; 851 return 0;
795} 852}
796 853
797static int 854static int
@@ -881,7 +938,7 @@ iscsi_if_rx(struct sock *sk, int len)
881{ 938{
882 struct sk_buff *skb; 939 struct sk_buff *skb;
883 940
884 down(&rx_queue_sema); 941 mutex_lock(&rx_queue_mutex);
885 while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) { 942 while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) {
886 while (skb->len >= NLMSG_SPACE(0)) { 943 while (skb->len >= NLMSG_SPACE(0)) {
887 int err; 944 int err;
@@ -915,17 +972,20 @@ iscsi_if_rx(struct sock *sk, int len)
915 err = iscsi_if_send_reply( 972 err = iscsi_if_send_reply(
916 NETLINK_CREDS(skb)->pid, nlh->nlmsg_seq, 973 NETLINK_CREDS(skb)->pid, nlh->nlmsg_seq,
917 nlh->nlmsg_type, 0, 0, ev, sizeof(*ev)); 974 nlh->nlmsg_type, 0, 0, ev, sizeof(*ev));
918 if (atomic_read(&z_reply.allocated) >= 975 if (atomic_read(&z_reply->allocated) >=
919 z_reply.hiwat) 976 z_reply->hiwat)
920 ev->iferror = -ENOMEM; 977 ev->iferror = -ENOMEM;
921 } while (err < 0 && err != -ECONNREFUSED); 978 } while (err < 0 && err != -ECONNREFUSED);
922 skb_pull(skb, rlen); 979 skb_pull(skb, rlen);
923 } 980 }
924 kfree_skb(skb); 981 kfree_skb(skb);
925 } 982 }
926 up(&rx_queue_sema); 983 mutex_unlock(&rx_queue_mutex);
927} 984}
928 985
986#define iscsi_cdev_to_conn(_cdev) \
987 iscsi_dev_to_conn(_cdev->dev)
988
929/* 989/*
930 * iSCSI connection attrs 990 * iSCSI connection attrs
931 */ 991 */
@@ -934,12 +994,10 @@ static ssize_t \
934show_conn_int_param_##param(struct class_device *cdev, char *buf) \ 994show_conn_int_param_##param(struct class_device *cdev, char *buf) \
935{ \ 995{ \
936 uint32_t value = 0; \ 996 uint32_t value = 0; \
937 struct iscsi_if_conn *conn = iscsi_cdev_to_if_conn(cdev); \ 997 struct iscsi_cls_conn *conn = iscsi_cdev_to_conn(cdev); \
938 struct iscsi_internal *priv; \ 998 struct iscsi_transport *t = conn->transport; \
939 \ 999 \
940 priv = to_iscsi_internal(conn->host->transportt); \ 1000 t->get_conn_param(conn->dd_data, param, &value); \
941 if (priv->param_mask & (1 << param)) \
942 priv->iscsi_transport->get_param(conn->connh, param, &value); \
943 return snprintf(buf, 20, format"\n", value); \ 1001 return snprintf(buf, 20, format"\n", value); \
944} 1002}
945 1003
@@ -954,6 +1012,9 @@ iscsi_conn_int_attr(data_digest, ISCSI_PARAM_DATADGST_EN, "%d");
954iscsi_conn_int_attr(ifmarker, ISCSI_PARAM_IFMARKER_EN, "%d"); 1012iscsi_conn_int_attr(ifmarker, ISCSI_PARAM_IFMARKER_EN, "%d");
955iscsi_conn_int_attr(ofmarker, ISCSI_PARAM_OFMARKER_EN, "%d"); 1013iscsi_conn_int_attr(ofmarker, ISCSI_PARAM_OFMARKER_EN, "%d");
956 1014
1015#define iscsi_cdev_to_session(_cdev) \
1016 iscsi_dev_to_session(_cdev->dev)
1017
957/* 1018/*
958 * iSCSI session attrs 1019 * iSCSI session attrs
959 */ 1020 */
@@ -962,20 +1023,11 @@ static ssize_t \
962show_session_int_param_##param(struct class_device *cdev, char *buf) \ 1023show_session_int_param_##param(struct class_device *cdev, char *buf) \
963{ \ 1024{ \
964 uint32_t value = 0; \ 1025 uint32_t value = 0; \
965 struct iscsi_if_session *session = iscsi_cdev_to_if_session(cdev); \ 1026 struct iscsi_cls_session *session = iscsi_cdev_to_session(cdev); \
966 struct Scsi_Host *shost = iscsi_if_session_to_shost(session); \ 1027 struct Scsi_Host *shost = iscsi_session_to_shost(session); \
967 struct iscsi_internal *priv = to_iscsi_internal(shost->transportt); \ 1028 struct iscsi_transport *t = session->transport; \
968 struct iscsi_if_conn *conn = NULL; \
969 unsigned long flags; \
970 \
971 spin_lock_irqsave(&connlock, flags); \
972 if (!list_empty(&session->connections)) \
973 conn = list_entry(session->connections.next, \
974 struct iscsi_if_conn, session_list); \
975 spin_unlock_irqrestore(&connlock, flags); \
976 \ 1029 \
977 if (conn && (priv->param_mask & (1 << param))) \ 1030 t->get_session_param(shost, param, &value); \
978 priv->iscsi_transport->get_param(conn->connh, param, &value);\
979 return snprintf(buf, 20, format"\n", value); \ 1031 return snprintf(buf, 20, format"\n", value); \
980} 1032}
981 1033
@@ -1004,23 +1056,18 @@ iscsi_session_int_attr(erl, ISCSI_PARAM_ERL, "%d");
1004 count++; \ 1056 count++; \
1005 } 1057 }
1006 1058
1007static int iscsi_is_session_dev(const struct device *dev)
1008{
1009 return dev->release == iscsi_if_session_dev_release;
1010}
1011
1012static int iscsi_session_match(struct attribute_container *cont, 1059static int iscsi_session_match(struct attribute_container *cont,
1013 struct device *dev) 1060 struct device *dev)
1014{ 1061{
1015 struct iscsi_if_session *session; 1062 struct iscsi_cls_session *session;
1016 struct Scsi_Host *shost; 1063 struct Scsi_Host *shost;
1017 struct iscsi_internal *priv; 1064 struct iscsi_internal *priv;
1018 1065
1019 if (!iscsi_is_session_dev(dev)) 1066 if (!iscsi_is_session_dev(dev))
1020 return 0; 1067 return 0;
1021 1068
1022 session = iscsi_dev_to_if_session(dev); 1069 session = iscsi_dev_to_session(dev);
1023 shost = iscsi_if_session_to_shost(session); 1070 shost = iscsi_session_to_shost(session);
1024 if (!shost->transportt) 1071 if (!shost->transportt)
1025 return 0; 1072 return 0;
1026 1073
@@ -1031,23 +1078,21 @@ static int iscsi_session_match(struct attribute_container *cont,
1031 return &priv->session_cont.ac == cont; 1078 return &priv->session_cont.ac == cont;
1032} 1079}
1033 1080
1034static int iscsi_is_conn_dev(const struct device *dev)
1035{
1036 return dev->release == iscsi_if_conn_dev_release;
1037}
1038
1039static int iscsi_conn_match(struct attribute_container *cont, 1081static int iscsi_conn_match(struct attribute_container *cont,
1040 struct device *dev) 1082 struct device *dev)
1041{ 1083{
1042 struct iscsi_if_conn *conn; 1084 struct iscsi_cls_session *session;
1085 struct iscsi_cls_conn *conn;
1043 struct Scsi_Host *shost; 1086 struct Scsi_Host *shost;
1044 struct iscsi_internal *priv; 1087 struct iscsi_internal *priv;
1045 1088
1046 if (!iscsi_is_conn_dev(dev)) 1089 if (!iscsi_is_conn_dev(dev))
1047 return 0; 1090 return 0;
1048 1091
1049 conn = iscsi_dev_to_if_conn(dev); 1092 conn = iscsi_dev_to_conn(dev);
1050 shost = conn->host; 1093 session = iscsi_dev_to_session(conn->dev.parent);
1094 shost = iscsi_session_to_shost(session);
1095
1051 if (!shost->transportt) 1096 if (!shost->transportt)
1052 return 0; 1097 return 0;
1053 1098
@@ -1058,7 +1103,8 @@ static int iscsi_conn_match(struct attribute_container *cont,
1058 return &priv->conn_cont.ac == cont; 1103 return &priv->conn_cont.ac == cont;
1059} 1104}
1060 1105
1061int iscsi_register_transport(struct iscsi_transport *tt) 1106struct scsi_transport_template *
1107iscsi_register_transport(struct iscsi_transport *tt)
1062{ 1108{
1063 struct iscsi_internal *priv; 1109 struct iscsi_internal *priv;
1064 unsigned long flags; 1110 unsigned long flags;
@@ -1068,15 +1114,14 @@ int iscsi_register_transport(struct iscsi_transport *tt)
1068 1114
1069 priv = iscsi_if_transport_lookup(tt); 1115 priv = iscsi_if_transport_lookup(tt);
1070 if (priv) 1116 if (priv)
1071 return -EEXIST; 1117 return NULL;
1072 1118
1073 priv = kmalloc(sizeof(*priv), GFP_KERNEL); 1119 priv = kmalloc(sizeof(*priv), GFP_KERNEL);
1074 if (!priv) 1120 if (!priv)
1075 return -ENOMEM; 1121 return NULL;
1076 memset(priv, 0, sizeof(*priv)); 1122 memset(priv, 0, sizeof(*priv));
1077 INIT_LIST_HEAD(&priv->list); 1123 INIT_LIST_HEAD(&priv->list);
1078 INIT_LIST_HEAD(&priv->sessions); 1124 INIT_LIST_HEAD(&priv->sessions);
1079 spin_lock_init(&priv->session_lock);
1080 priv->iscsi_transport = tt; 1125 priv->iscsi_transport = tt;
1081 1126
1082 priv->cdev.class = &iscsi_transport_class; 1127 priv->cdev.class = &iscsi_transport_class;
@@ -1142,13 +1187,13 @@ int iscsi_register_transport(struct iscsi_transport *tt)
1142 spin_unlock_irqrestore(&iscsi_transport_lock, flags); 1187 spin_unlock_irqrestore(&iscsi_transport_lock, flags);
1143 1188
1144 printk(KERN_NOTICE "iscsi: registered transport (%s)\n", tt->name); 1189 printk(KERN_NOTICE "iscsi: registered transport (%s)\n", tt->name);
1145 return 0; 1190 return &priv->t;
1146 1191
1147unregister_cdev: 1192unregister_cdev:
1148 class_device_unregister(&priv->cdev); 1193 class_device_unregister(&priv->cdev);
1149free_priv: 1194free_priv:
1150 kfree(priv); 1195 kfree(priv);
1151 return err; 1196 return NULL;
1152} 1197}
1153EXPORT_SYMBOL_GPL(iscsi_register_transport); 1198EXPORT_SYMBOL_GPL(iscsi_register_transport);
1154 1199
@@ -1159,19 +1204,11 @@ int iscsi_unregister_transport(struct iscsi_transport *tt)
1159 1204
1160 BUG_ON(!tt); 1205 BUG_ON(!tt);
1161 1206
1162 down(&rx_queue_sema); 1207 mutex_lock(&rx_queue_mutex);
1163 1208
1164 priv = iscsi_if_transport_lookup(tt); 1209 priv = iscsi_if_transport_lookup(tt);
1165 BUG_ON (!priv); 1210 BUG_ON (!priv);
1166 1211
1167 spin_lock_irqsave(&priv->session_lock, flags);
1168 if (!list_empty(&priv->sessions)) {
1169 spin_unlock_irqrestore(&priv->session_lock, flags);
1170 up(&rx_queue_sema);
1171 return -EPERM;
1172 }
1173 spin_unlock_irqrestore(&priv->session_lock, flags);
1174
1175 spin_lock_irqsave(&iscsi_transport_lock, flags); 1212 spin_lock_irqsave(&iscsi_transport_lock, flags);
1176 list_del(&priv->list); 1213 list_del(&priv->list);
1177 spin_unlock_irqrestore(&iscsi_transport_lock, flags); 1214 spin_unlock_irqrestore(&iscsi_transport_lock, flags);
@@ -1181,7 +1218,7 @@ int iscsi_unregister_transport(struct iscsi_transport *tt)
1181 1218
1182 sysfs_remove_group(&priv->cdev.kobj, &iscsi_transport_group); 1219 sysfs_remove_group(&priv->cdev.kobj, &iscsi_transport_group);
1183 class_device_unregister(&priv->cdev); 1220 class_device_unregister(&priv->cdev);
1184 up(&rx_queue_sema); 1221 mutex_unlock(&rx_queue_mutex);
1185 1222
1186 return 0; 1223 return 0;
1187} 1224}
@@ -1194,14 +1231,14 @@ iscsi_rcv_nl_event(struct notifier_block *this, unsigned long event, void *ptr)
1194 1231
1195 if (event == NETLINK_URELEASE && 1232 if (event == NETLINK_URELEASE &&
1196 n->protocol == NETLINK_ISCSI && n->pid) { 1233 n->protocol == NETLINK_ISCSI && n->pid) {
1197 struct iscsi_if_conn *conn; 1234 struct iscsi_cls_conn *conn;
1198 unsigned long flags; 1235 unsigned long flags;
1199 1236
1200 mempool_zone_complete(&z_reply); 1237 mempool_zone_complete(z_reply);
1201 spin_lock_irqsave(&connlock, flags); 1238 spin_lock_irqsave(&connlock, flags);
1202 list_for_each_entry(conn, &connlist, conn_list) { 1239 list_for_each_entry(conn, &connlist, conn_list) {
1203 mempool_zone_complete(&conn->z_error); 1240 mempool_zone_complete(conn->z_error);
1204 mempool_zone_complete(&conn->z_pdu); 1241 mempool_zone_complete(conn->z_pdu);
1205 } 1242 }
1206 spin_unlock_irqrestore(&connlock, flags); 1243 spin_unlock_irqrestore(&connlock, flags);
1207 } 1244 }
@@ -1234,15 +1271,15 @@ static __init int iscsi_transport_init(void)
1234 goto unregister_session_class; 1271 goto unregister_session_class;
1235 1272
1236 nls = netlink_kernel_create(NETLINK_ISCSI, 1, iscsi_if_rx, 1273 nls = netlink_kernel_create(NETLINK_ISCSI, 1, iscsi_if_rx,
1237 THIS_MODULE); 1274 THIS_MODULE);
1238 if (!nls) { 1275 if (!nls) {
1239 err = -ENOBUFS; 1276 err = -ENOBUFS;
1240 goto unregister_notifier; 1277 goto unregister_notifier;
1241 } 1278 }
1242 1279
1243 err = mempool_zone_init(&z_reply, Z_MAX_REPLY, 1280 z_reply = mempool_zone_init(Z_MAX_REPLY,
1244 NLMSG_SPACE(sizeof(struct iscsi_uevent)), Z_HIWAT_REPLY); 1281 NLMSG_SPACE(sizeof(struct iscsi_uevent)), Z_HIWAT_REPLY);
1245 if (!err) 1282 if (z_reply)
1246 return 0; 1283 return 0;
1247 1284
1248 sock_release(nls->sk_socket); 1285 sock_release(nls->sk_socket);
@@ -1259,7 +1296,7 @@ unregister_transport_class:
1259 1296
1260static void __exit iscsi_transport_exit(void) 1297static void __exit iscsi_transport_exit(void)
1261{ 1298{
1262 mempool_destroy(z_reply.pool); 1299 mempool_zone_destroy(z_reply);
1263 sock_release(nls->sk_socket); 1300 sock_release(nls->sk_socket);
1264 netlink_unregister_notifier(&iscsi_nl_notifier); 1301 netlink_unregister_notifier(&iscsi_nl_notifier);
1265 transport_class_unregister(&iscsi_connection_class); 1302 transport_class_unregister(&iscsi_connection_class);
diff --git a/drivers/scsi/scsi_transport_sas.c b/drivers/scsi/scsi_transport_sas.c
index edabbd05d258..a3e0b7bc2d7b 100644
--- a/drivers/scsi/scsi_transport_sas.c
+++ b/drivers/scsi/scsi_transport_sas.c
@@ -29,6 +29,7 @@
29#include <linux/slab.h> 29#include <linux/slab.h>
30#include <linux/string.h> 30#include <linux/string.h>
31 31
32#include <scsi/scsi.h>
32#include <scsi/scsi_device.h> 33#include <scsi/scsi_device.h>
33#include <scsi/scsi_host.h> 34#include <scsi/scsi_host.h>
34#include <scsi/scsi_transport.h> 35#include <scsi/scsi_transport.h>
@@ -62,7 +63,7 @@ struct sas_internal {
62 63
63struct sas_host_attrs { 64struct sas_host_attrs {
64 struct list_head rphy_list; 65 struct list_head rphy_list;
65 spinlock_t lock; 66 struct mutex lock;
66 u32 next_target_id; 67 u32 next_target_id;
67}; 68};
68#define to_sas_host_attrs(host) ((struct sas_host_attrs *)(host)->shost_data) 69#define to_sas_host_attrs(host) ((struct sas_host_attrs *)(host)->shost_data)
@@ -165,7 +166,7 @@ static int sas_host_setup(struct transport_container *tc, struct device *dev,
165 struct sas_host_attrs *sas_host = to_sas_host_attrs(shost); 166 struct sas_host_attrs *sas_host = to_sas_host_attrs(shost);
166 167
167 INIT_LIST_HEAD(&sas_host->rphy_list); 168 INIT_LIST_HEAD(&sas_host->rphy_list);
168 spin_lock_init(&sas_host->lock); 169 mutex_init(&sas_host->lock);
169 sas_host->next_target_id = 0; 170 sas_host->next_target_id = 0;
170 return 0; 171 return 0;
171} 172}
@@ -626,7 +627,7 @@ int sas_rphy_add(struct sas_rphy *rphy)
626 transport_add_device(&rphy->dev); 627 transport_add_device(&rphy->dev);
627 transport_configure_device(&rphy->dev); 628 transport_configure_device(&rphy->dev);
628 629
629 spin_lock(&sas_host->lock); 630 mutex_lock(&sas_host->lock);
630 list_add_tail(&rphy->list, &sas_host->rphy_list); 631 list_add_tail(&rphy->list, &sas_host->rphy_list);
631 if (identify->device_type == SAS_END_DEVICE && 632 if (identify->device_type == SAS_END_DEVICE &&
632 (identify->target_port_protocols & 633 (identify->target_port_protocols &
@@ -634,10 +635,10 @@ int sas_rphy_add(struct sas_rphy *rphy)
634 rphy->scsi_target_id = sas_host->next_target_id++; 635 rphy->scsi_target_id = sas_host->next_target_id++;
635 else 636 else
636 rphy->scsi_target_id = -1; 637 rphy->scsi_target_id = -1;
637 spin_unlock(&sas_host->lock); 638 mutex_unlock(&sas_host->lock);
638 639
639 if (rphy->scsi_target_id != -1) { 640 if (rphy->scsi_target_id != -1) {
640 scsi_scan_target(&rphy->dev, parent->number, 641 scsi_scan_target(&rphy->dev, parent->port_identifier,
641 rphy->scsi_target_id, ~0, 0); 642 rphy->scsi_target_id, ~0, 0);
642 } 643 }
643 644
@@ -661,9 +662,9 @@ void sas_rphy_free(struct sas_rphy *rphy)
661 struct Scsi_Host *shost = dev_to_shost(rphy->dev.parent->parent); 662 struct Scsi_Host *shost = dev_to_shost(rphy->dev.parent->parent);
662 struct sas_host_attrs *sas_host = to_sas_host_attrs(shost); 663 struct sas_host_attrs *sas_host = to_sas_host_attrs(shost);
663 664
664 spin_lock(&sas_host->lock); 665 mutex_lock(&sas_host->lock);
665 list_del(&rphy->list); 666 list_del(&rphy->list);
666 spin_unlock(&sas_host->lock); 667 mutex_unlock(&sas_host->lock);
667 668
668 transport_destroy_device(&rphy->dev); 669 transport_destroy_device(&rphy->dev);
669 put_device(rphy->dev.parent); 670 put_device(rphy->dev.parent);
@@ -687,15 +688,27 @@ sas_rphy_delete(struct sas_rphy *rphy)
687 struct Scsi_Host *shost = dev_to_shost(parent->dev.parent); 688 struct Scsi_Host *shost = dev_to_shost(parent->dev.parent);
688 struct sas_host_attrs *sas_host = to_sas_host_attrs(shost); 689 struct sas_host_attrs *sas_host = to_sas_host_attrs(shost);
689 690
690 scsi_remove_target(dev); 691 switch (rphy->identify.device_type) {
692 case SAS_END_DEVICE:
693 scsi_remove_target(dev);
694 break;
695 case SAS_EDGE_EXPANDER_DEVICE:
696 case SAS_FANOUT_EXPANDER_DEVICE:
697 device_for_each_child(dev, NULL, do_sas_phy_delete);
698 break;
699 default:
700 break;
701 }
691 702
692 transport_remove_device(dev); 703 transport_remove_device(dev);
693 device_del(dev); 704 device_del(dev);
694 transport_destroy_device(dev); 705 transport_destroy_device(dev);
695 706
696 spin_lock(&sas_host->lock); 707 mutex_lock(&sas_host->lock);
697 list_del(&rphy->list); 708 list_del(&rphy->list);
698 spin_unlock(&sas_host->lock); 709 mutex_unlock(&sas_host->lock);
710
711 parent->rphy = NULL;
699 712
700 put_device(&parent->dev); 713 put_device(&parent->dev);
701} 714}
@@ -719,23 +732,28 @@ EXPORT_SYMBOL(scsi_is_sas_rphy);
719 * SCSI scan helper 732 * SCSI scan helper
720 */ 733 */
721 734
722static struct device *sas_target_parent(struct Scsi_Host *shost, 735static int sas_user_scan(struct Scsi_Host *shost, uint channel,
723 int channel, uint id) 736 uint id, uint lun)
724{ 737{
725 struct sas_host_attrs *sas_host = to_sas_host_attrs(shost); 738 struct sas_host_attrs *sas_host = to_sas_host_attrs(shost);
726 struct sas_rphy *rphy; 739 struct sas_rphy *rphy;
727 struct device *dev = NULL;
728 740
729 spin_lock(&sas_host->lock); 741 mutex_lock(&sas_host->lock);
730 list_for_each_entry(rphy, &sas_host->rphy_list, list) { 742 list_for_each_entry(rphy, &sas_host->rphy_list, list) {
731 struct sas_phy *parent = dev_to_phy(rphy->dev.parent); 743 struct sas_phy *parent = dev_to_phy(rphy->dev.parent);
732 if (parent->number == channel && 744
733 rphy->scsi_target_id == id) 745 if (rphy->scsi_target_id == -1)
734 dev = &rphy->dev; 746 continue;
747
748 if ((channel == SCAN_WILD_CARD || channel == parent->port_identifier) &&
749 (id == SCAN_WILD_CARD || id == rphy->scsi_target_id)) {
750 scsi_scan_target(&rphy->dev, parent->port_identifier,
751 rphy->scsi_target_id, lun, 1);
752 }
735 } 753 }
736 spin_unlock(&sas_host->lock); 754 mutex_unlock(&sas_host->lock);
737 755
738 return dev; 756 return 0;
739} 757}
740 758
741 759
@@ -780,7 +798,7 @@ sas_attach_transport(struct sas_function_template *ft)
780 return NULL; 798 return NULL;
781 memset(i, 0, sizeof(struct sas_internal)); 799 memset(i, 0, sizeof(struct sas_internal));
782 800
783 i->t.target_parent = sas_target_parent; 801 i->t.user_scan = sas_user_scan;
784 802
785 i->t.host_attrs.ac.attrs = &i->host_attrs[0]; 803 i->t.host_attrs.ac.attrs = &i->host_attrs[0];
786 i->t.host_attrs.ac.class = &sas_host_class.class; 804 i->t.host_attrs.ac.class = &sas_host_class.class;
diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c
index 46da6fe10ad5..7ee95eb83dda 100644
--- a/drivers/scsi/scsi_transport_spi.c
+++ b/drivers/scsi/scsi_transport_spi.c
@@ -24,7 +24,7 @@
24#include <linux/module.h> 24#include <linux/module.h>
25#include <linux/workqueue.h> 25#include <linux/workqueue.h>
26#include <linux/blkdev.h> 26#include <linux/blkdev.h>
27#include <asm/semaphore.h> 27#include <linux/mutex.h>
28#include <scsi/scsi.h> 28#include <scsi/scsi.h>
29#include "scsi_priv.h" 29#include "scsi_priv.h"
30#include <scsi/scsi_device.h> 30#include <scsi/scsi_device.h>
@@ -48,7 +48,7 @@
48 48
49/* Private data accessors (keep these out of the header file) */ 49/* Private data accessors (keep these out of the header file) */
50#define spi_dv_pending(x) (((struct spi_transport_attrs *)&(x)->starget_data)->dv_pending) 50#define spi_dv_pending(x) (((struct spi_transport_attrs *)&(x)->starget_data)->dv_pending)
51#define spi_dv_sem(x) (((struct spi_transport_attrs *)&(x)->starget_data)->dv_sem) 51#define spi_dv_mutex(x) (((struct spi_transport_attrs *)&(x)->starget_data)->dv_mutex)
52 52
53struct spi_internal { 53struct spi_internal {
54 struct scsi_transport_template t; 54 struct scsi_transport_template t;
@@ -242,7 +242,7 @@ static int spi_setup_transport_attrs(struct transport_container *tc,
242 spi_hold_mcs(starget) = 0; 242 spi_hold_mcs(starget) = 0;
243 spi_dv_pending(starget) = 0; 243 spi_dv_pending(starget) = 0;
244 spi_initial_dv(starget) = 0; 244 spi_initial_dv(starget) = 0;
245 init_MUTEX(&spi_dv_sem(starget)); 245 mutex_init(&spi_dv_mutex(starget));
246 246
247 return 0; 247 return 0;
248} 248}
@@ -915,7 +915,7 @@ spi_dv_device(struct scsi_device *sdev)
915 scsi_target_quiesce(starget); 915 scsi_target_quiesce(starget);
916 916
917 spi_dv_pending(starget) = 1; 917 spi_dv_pending(starget) = 1;
918 down(&spi_dv_sem(starget)); 918 mutex_lock(&spi_dv_mutex(starget));
919 919
920 starget_printk(KERN_INFO, starget, "Beginning Domain Validation\n"); 920 starget_printk(KERN_INFO, starget, "Beginning Domain Validation\n");
921 921
@@ -923,7 +923,7 @@ spi_dv_device(struct scsi_device *sdev)
923 923
924 starget_printk(KERN_INFO, starget, "Ending Domain Validation\n"); 924 starget_printk(KERN_INFO, starget, "Ending Domain Validation\n");
925 925
926 up(&spi_dv_sem(starget)); 926 mutex_unlock(&spi_dv_mutex(starget));
927 spi_dv_pending(starget) = 0; 927 spi_dv_pending(starget) = 0;
928 928
929 scsi_target_resume(starget); 929 scsi_target_resume(starget);
@@ -1075,7 +1075,7 @@ static const char * const extended_msgs[] = {
1075/* 0x04 */ "Parallel Protocol Request" 1075/* 0x04 */ "Parallel Protocol Request"
1076}; 1076};
1077 1077
1078void print_nego(const unsigned char *msg, int per, int off, int width) 1078static void print_nego(const unsigned char *msg, int per, int off, int width)
1079{ 1079{
1080 if (per) { 1080 if (per) {
1081 char buf[20]; 1081 char buf[20];
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 4c5127ed379c..930db398d107 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -49,6 +49,7 @@
49#include <linux/blkpg.h> 49#include <linux/blkpg.h>
50#include <linux/kref.h> 50#include <linux/kref.h>
51#include <linux/delay.h> 51#include <linux/delay.h>
52#include <linux/mutex.h>
52#include <asm/uaccess.h> 53#include <asm/uaccess.h>
53 54
54#include <scsi/scsi.h> 55#include <scsi/scsi.h>
@@ -111,7 +112,7 @@ static DEFINE_SPINLOCK(sd_index_lock);
111/* This semaphore is used to mediate the 0->1 reference get in the 112/* This semaphore is used to mediate the 0->1 reference get in the
112 * face of object destruction (i.e. we can't allow a get on an 113 * face of object destruction (i.e. we can't allow a get on an
113 * object after last put) */ 114 * object after last put) */
114static DECLARE_MUTEX(sd_ref_sem); 115static DEFINE_MUTEX(sd_ref_mutex);
115 116
116static int sd_revalidate_disk(struct gendisk *disk); 117static int sd_revalidate_disk(struct gendisk *disk);
117static void sd_rw_intr(struct scsi_cmnd * SCpnt); 118static void sd_rw_intr(struct scsi_cmnd * SCpnt);
@@ -193,9 +194,9 @@ static struct scsi_disk *scsi_disk_get(struct gendisk *disk)
193{ 194{
194 struct scsi_disk *sdkp; 195 struct scsi_disk *sdkp;
195 196
196 down(&sd_ref_sem); 197 mutex_lock(&sd_ref_mutex);
197 sdkp = __scsi_disk_get(disk); 198 sdkp = __scsi_disk_get(disk);
198 up(&sd_ref_sem); 199 mutex_unlock(&sd_ref_mutex);
199 return sdkp; 200 return sdkp;
200} 201}
201 202
@@ -203,11 +204,11 @@ static struct scsi_disk *scsi_disk_get_from_dev(struct device *dev)
203{ 204{
204 struct scsi_disk *sdkp; 205 struct scsi_disk *sdkp;
205 206
206 down(&sd_ref_sem); 207 mutex_lock(&sd_ref_mutex);
207 sdkp = dev_get_drvdata(dev); 208 sdkp = dev_get_drvdata(dev);
208 if (sdkp) 209 if (sdkp)
209 sdkp = __scsi_disk_get(sdkp->disk); 210 sdkp = __scsi_disk_get(sdkp->disk);
210 up(&sd_ref_sem); 211 mutex_unlock(&sd_ref_mutex);
211 return sdkp; 212 return sdkp;
212} 213}
213 214
@@ -215,10 +216,10 @@ static void scsi_disk_put(struct scsi_disk *sdkp)
215{ 216{
216 struct scsi_device *sdev = sdkp->device; 217 struct scsi_device *sdev = sdkp->device;
217 218
218 down(&sd_ref_sem); 219 mutex_lock(&sd_ref_mutex);
219 kref_put(&sdkp->kref, scsi_disk_release); 220 kref_put(&sdkp->kref, scsi_disk_release);
220 scsi_device_put(sdev); 221 scsi_device_put(sdev);
221 up(&sd_ref_sem); 222 mutex_unlock(&sd_ref_mutex);
222} 223}
223 224
224/** 225/**
@@ -231,34 +232,12 @@ static void scsi_disk_put(struct scsi_disk *sdkp)
231 **/ 232 **/
232static int sd_init_command(struct scsi_cmnd * SCpnt) 233static int sd_init_command(struct scsi_cmnd * SCpnt)
233{ 234{
234 unsigned int this_count, timeout;
235 struct gendisk *disk;
236 sector_t block;
237 struct scsi_device *sdp = SCpnt->device; 235 struct scsi_device *sdp = SCpnt->device;
238 struct request *rq = SCpnt->request; 236 struct request *rq = SCpnt->request;
239 237 struct gendisk *disk = rq->rq_disk;
240 timeout = sdp->timeout; 238 sector_t block = rq->sector;
241 239 unsigned int this_count = SCpnt->request_bufflen >> 9;
242 /* 240 unsigned int timeout = sdp->timeout;
243 * SG_IO from block layer already setup, just copy cdb basically
244 */
245 if (blk_pc_request(rq)) {
246 scsi_setup_blk_pc_cmnd(SCpnt);
247 if (rq->timeout)
248 timeout = rq->timeout;
249
250 goto queue;
251 }
252
253 /*
254 * we only do REQ_CMD and REQ_BLOCK_PC
255 */
256 if (!blk_fs_request(rq))
257 return 0;
258
259 disk = rq->rq_disk;
260 block = rq->sector;
261 this_count = SCpnt->request_bufflen >> 9;
262 241
263 SCSI_LOG_HLQUEUE(1, printk("sd_init_command: disk=%s, block=%llu, " 242 SCSI_LOG_HLQUEUE(1, printk("sd_init_command: disk=%s, block=%llu, "
264 "count=%d\n", disk->disk_name, 243 "count=%d\n", disk->disk_name,
@@ -401,8 +380,6 @@ static int sd_init_command(struct scsi_cmnd * SCpnt)
401 SCpnt->transfersize = sdp->sector_size; 380 SCpnt->transfersize = sdp->sector_size;
402 SCpnt->underflow = this_count << 9; 381 SCpnt->underflow = this_count << 9;
403 SCpnt->allowed = SD_MAX_RETRIES; 382 SCpnt->allowed = SD_MAX_RETRIES;
404
405queue:
406 SCpnt->timeout_per_command = timeout; 383 SCpnt->timeout_per_command = timeout;
407 384
408 /* 385 /*
@@ -836,15 +813,7 @@ static void sd_rw_intr(struct scsi_cmnd * SCpnt)
836 relatively rare error condition, no care is taken to avoid 813 relatively rare error condition, no care is taken to avoid
837 unnecessary additional work such as memcpy's that could be avoided. 814 unnecessary additional work such as memcpy's that could be avoided.
838 */ 815 */
839 816 if (driver_byte(result) != 0 &&
840 /*
841 * If SG_IO from block layer then set good_bytes to stop retries;
842 * else if errors, check them, and if necessary prepare for
843 * (partial) retries.
844 */
845 if (blk_pc_request(SCpnt->request))
846 good_bytes = this_count;
847 else if (driver_byte(result) != 0 &&
848 sense_valid && !sense_deferred) { 817 sense_valid && !sense_deferred) {
849 switch (sshdr.sense_key) { 818 switch (sshdr.sense_key) {
850 case MEDIUM_ERROR: 819 case MEDIUM_ERROR:
@@ -1635,10 +1604,10 @@ static int sd_remove(struct device *dev)
1635 del_gendisk(sdkp->disk); 1604 del_gendisk(sdkp->disk);
1636 sd_shutdown(dev); 1605 sd_shutdown(dev);
1637 1606
1638 down(&sd_ref_sem); 1607 mutex_lock(&sd_ref_mutex);
1639 dev_set_drvdata(dev, NULL); 1608 dev_set_drvdata(dev, NULL);
1640 kref_put(&sdkp->kref, scsi_disk_release); 1609 kref_put(&sdkp->kref, scsi_disk_release);
1641 up(&sd_ref_sem); 1610 mutex_unlock(&sd_ref_mutex);
1642 1611
1643 return 0; 1612 return 0;
1644} 1613}
@@ -1647,7 +1616,7 @@ static int sd_remove(struct device *dev)
1647 * scsi_disk_release - Called to free the scsi_disk structure 1616 * scsi_disk_release - Called to free the scsi_disk structure
1648 * @kref: pointer to embedded kref 1617 * @kref: pointer to embedded kref
1649 * 1618 *
1650 * sd_ref_sem must be held entering this routine. Because it is 1619 * sd_ref_mutex must be held entering this routine. Because it is
1651 * called on last put, you should always use the scsi_disk_get() 1620 * called on last put, you should always use the scsi_disk_get()
1652 * scsi_disk_put() helpers which manipulate the semaphore directly 1621 * scsi_disk_put() helpers which manipulate the semaphore directly
1653 * and never do a direct kref_put(). 1622 * and never do a direct kref_put().
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index a4d9be7c6874..dd8050392d01 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -44,6 +44,7 @@
44#include <linux/interrupt.h> 44#include <linux/interrupt.h>
45#include <linux/init.h> 45#include <linux/init.h>
46#include <linux/blkdev.h> 46#include <linux/blkdev.h>
47#include <linux/mutex.h>
47#include <asm/uaccess.h> 48#include <asm/uaccess.h>
48 49
49#include <scsi/scsi.h> 50#include <scsi/scsi.h>
@@ -90,7 +91,7 @@ static DEFINE_SPINLOCK(sr_index_lock);
90/* This semaphore is used to mediate the 0->1 reference get in the 91/* This semaphore is used to mediate the 0->1 reference get in the
91 * face of object destruction (i.e. we can't allow a get on an 92 * face of object destruction (i.e. we can't allow a get on an
92 * object after last put) */ 93 * object after last put) */
93static DECLARE_MUTEX(sr_ref_sem); 94static DEFINE_MUTEX(sr_ref_mutex);
94 95
95static int sr_open(struct cdrom_device_info *, int); 96static int sr_open(struct cdrom_device_info *, int);
96static void sr_release(struct cdrom_device_info *); 97static void sr_release(struct cdrom_device_info *);
@@ -133,7 +134,7 @@ static inline struct scsi_cd *scsi_cd_get(struct gendisk *disk)
133{ 134{
134 struct scsi_cd *cd = NULL; 135 struct scsi_cd *cd = NULL;
135 136
136 down(&sr_ref_sem); 137 mutex_lock(&sr_ref_mutex);
137 if (disk->private_data == NULL) 138 if (disk->private_data == NULL)
138 goto out; 139 goto out;
139 cd = scsi_cd(disk); 140 cd = scsi_cd(disk);
@@ -146,7 +147,7 @@ static inline struct scsi_cd *scsi_cd_get(struct gendisk *disk)
146 kref_put(&cd->kref, sr_kref_release); 147 kref_put(&cd->kref, sr_kref_release);
147 cd = NULL; 148 cd = NULL;
148 out: 149 out:
149 up(&sr_ref_sem); 150 mutex_unlock(&sr_ref_mutex);
150 return cd; 151 return cd;
151} 152}
152 153
@@ -154,10 +155,10 @@ static inline void scsi_cd_put(struct scsi_cd *cd)
154{ 155{
155 struct scsi_device *sdev = cd->device; 156 struct scsi_device *sdev = cd->device;
156 157
157 down(&sr_ref_sem); 158 mutex_lock(&sr_ref_mutex);
158 kref_put(&cd->kref, sr_kref_release); 159 kref_put(&cd->kref, sr_kref_release);
159 scsi_device_put(sdev); 160 scsi_device_put(sdev);
160 up(&sr_ref_sem); 161 mutex_unlock(&sr_ref_mutex);
161} 162}
162 163
163/* 164/*
@@ -237,8 +238,6 @@ static void rw_intr(struct scsi_cmnd * SCpnt)
237 case ILLEGAL_REQUEST: 238 case ILLEGAL_REQUEST:
238 if (!(SCpnt->sense_buffer[0] & 0x90)) 239 if (!(SCpnt->sense_buffer[0] & 0x90))
239 break; 240 break;
240 if (!blk_fs_request(SCpnt->request))
241 break;
242 error_sector = (SCpnt->sense_buffer[3] << 24) | 241 error_sector = (SCpnt->sense_buffer[3] << 24) |
243 (SCpnt->sense_buffer[4] << 16) | 242 (SCpnt->sense_buffer[4] << 16) |
244 (SCpnt->sense_buffer[5] << 8) | 243 (SCpnt->sense_buffer[5] << 8) |
@@ -317,23 +316,6 @@ static int sr_init_command(struct scsi_cmnd * SCpnt)
317 } 316 }
318 317
319 /* 318 /*
320 * these are already setup, just copy cdb basically
321 */
322 if (SCpnt->request->flags & REQ_BLOCK_PC) {
323 scsi_setup_blk_pc_cmnd(SCpnt);
324
325 if (SCpnt->timeout_per_command)
326 timeout = SCpnt->timeout_per_command;
327
328 goto queue;
329 }
330
331 if (!(SCpnt->request->flags & REQ_CMD)) {
332 blk_dump_rq_flags(SCpnt->request, "sr unsup command");
333 return 0;
334 }
335
336 /*
337 * we do lazy blocksize switching (when reading XA sectors, 319 * we do lazy blocksize switching (when reading XA sectors,
338 * see CDROMREADMODE2 ioctl) 320 * see CDROMREADMODE2 ioctl)
339 */ 321 */
@@ -421,8 +403,6 @@ static int sr_init_command(struct scsi_cmnd * SCpnt)
421 */ 403 */
422 SCpnt->transfersize = cd->device->sector_size; 404 SCpnt->transfersize = cd->device->sector_size;
423 SCpnt->underflow = this_count << 9; 405 SCpnt->underflow = this_count << 9;
424
425queue:
426 SCpnt->allowed = MAX_RETRIES; 406 SCpnt->allowed = MAX_RETRIES;
427 SCpnt->timeout_per_command = timeout; 407 SCpnt->timeout_per_command = timeout;
428 408
@@ -762,8 +742,9 @@ static void get_capabilities(struct scsi_cd *cd)
762 /* failed, drive doesn't have capabilities mode page */ 742 /* failed, drive doesn't have capabilities mode page */
763 cd->cdi.speed = 1; 743 cd->cdi.speed = 1;
764 cd->cdi.mask |= (CDC_CD_R | CDC_CD_RW | CDC_DVD_R | 744 cd->cdi.mask |= (CDC_CD_R | CDC_CD_RW | CDC_DVD_R |
765 CDC_DVD | CDC_DVD_RAM | 745 CDC_DVD | CDC_DVD_RAM |
766 CDC_SELECT_DISC | CDC_SELECT_SPEED); 746 CDC_SELECT_DISC | CDC_SELECT_SPEED |
747 CDC_MRW | CDC_MRW_W | CDC_RAM);
767 kfree(buffer); 748 kfree(buffer);
768 printk("%s: scsi-1 drive\n", cd->cdi.name); 749 printk("%s: scsi-1 drive\n", cd->cdi.name);
769 return; 750 return;
@@ -845,7 +826,7 @@ static int sr_packet(struct cdrom_device_info *cdi,
845 * sr_kref_release - Called to free the scsi_cd structure 826 * sr_kref_release - Called to free the scsi_cd structure
846 * @kref: pointer to embedded kref 827 * @kref: pointer to embedded kref
847 * 828 *
848 * sr_ref_sem must be held entering this routine. Because it is 829 * sr_ref_mutex must be held entering this routine. Because it is
849 * called on last put, you should always use the scsi_cd_get() 830 * called on last put, you should always use the scsi_cd_get()
850 * scsi_cd_put() helpers which manipulate the semaphore directly 831 * scsi_cd_put() helpers which manipulate the semaphore directly
851 * and never do a direct kref_put(). 832 * and never do a direct kref_put().
@@ -874,9 +855,9 @@ static int sr_remove(struct device *dev)
874 855
875 del_gendisk(cd->disk); 856 del_gendisk(cd->disk);
876 857
877 down(&sr_ref_sem); 858 mutex_lock(&sr_ref_mutex);
878 kref_put(&cd->kref, sr_kref_release); 859 kref_put(&cd->kref, sr_kref_release);
879 up(&sr_ref_sem); 860 mutex_unlock(&sr_ref_mutex);
880 861
881 return 0; 862 return 0;
882} 863}
diff --git a/drivers/scsi/sr_ioctl.c b/drivers/scsi/sr_ioctl.c
index 6e45ac3c43c5..5d02ff4db6cc 100644
--- a/drivers/scsi/sr_ioctl.c
+++ b/drivers/scsi/sr_ioctl.c
@@ -31,6 +31,79 @@ static int xa_test = 0;
31 31
32module_param(xa_test, int, S_IRUGO | S_IWUSR); 32module_param(xa_test, int, S_IRUGO | S_IWUSR);
33 33
34/* primitive to determine whether we need to have GFP_DMA set based on
35 * the status of the unchecked_isa_dma flag in the host structure */
36#define SR_GFP_DMA(cd) (((cd)->device->host->unchecked_isa_dma) ? GFP_DMA : 0)
37
38
39static int sr_read_tochdr(struct cdrom_device_info *cdi,
40 struct cdrom_tochdr *tochdr)
41{
42 struct scsi_cd *cd = cdi->handle;
43 struct packet_command cgc;
44 int result;
45 unsigned char *buffer;
46
47 buffer = kmalloc(32, GFP_KERNEL | SR_GFP_DMA(cd));
48 if (!buffer)
49 return -ENOMEM;
50
51 memset(&cgc, 0, sizeof(struct packet_command));
52 cgc.timeout = IOCTL_TIMEOUT;
53 cgc.cmd[0] = GPCMD_READ_TOC_PMA_ATIP;
54 cgc.cmd[8] = 12; /* LSB of length */
55 cgc.buffer = buffer;
56 cgc.buflen = 12;
57 cgc.quiet = 1;
58 cgc.data_direction = DMA_FROM_DEVICE;
59
60 result = sr_do_ioctl(cd, &cgc);
61
62 tochdr->cdth_trk0 = buffer[2];
63 tochdr->cdth_trk1 = buffer[3];
64
65 kfree(buffer);
66 return result;
67}
68
69static int sr_read_tocentry(struct cdrom_device_info *cdi,
70 struct cdrom_tocentry *tocentry)
71{
72 struct scsi_cd *cd = cdi->handle;
73 struct packet_command cgc;
74 int result;
75 unsigned char *buffer;
76
77 buffer = kmalloc(32, GFP_KERNEL | SR_GFP_DMA(cd));
78 if (!buffer)
79 return -ENOMEM;
80
81 memset(&cgc, 0, sizeof(struct packet_command));
82 cgc.timeout = IOCTL_TIMEOUT;
83 cgc.cmd[0] = GPCMD_READ_TOC_PMA_ATIP;
84 cgc.cmd[1] |= (tocentry->cdte_format == CDROM_MSF) ? 0x02 : 0;
85 cgc.cmd[6] = tocentry->cdte_track;
86 cgc.cmd[8] = 12; /* LSB of length */
87 cgc.buffer = buffer;
88 cgc.buflen = 12;
89 cgc.data_direction = DMA_FROM_DEVICE;
90
91 result = sr_do_ioctl(cd, &cgc);
92
93 tocentry->cdte_ctrl = buffer[5] & 0xf;
94 tocentry->cdte_adr = buffer[5] >> 4;
95 tocentry->cdte_datamode = (tocentry->cdte_ctrl & 0x04) ? 1 : 0;
96 if (tocentry->cdte_format == CDROM_MSF) {
97 tocentry->cdte_addr.msf.minute = buffer[9];
98 tocentry->cdte_addr.msf.second = buffer[10];
99 tocentry->cdte_addr.msf.frame = buffer[11];
100 } else
101 tocentry->cdte_addr.lba = (((((buffer[8] << 8) + buffer[9]) << 8)
102 + buffer[10]) << 8) + buffer[11];
103
104 kfree(buffer);
105 return result;
106}
34 107
35#define IOCTL_RETRIES 3 108#define IOCTL_RETRIES 3
36 109
@@ -45,7 +118,8 @@ static int sr_fake_playtrkind(struct cdrom_device_info *cdi, struct cdrom_ti *ti
45 struct packet_command cgc; 118 struct packet_command cgc;
46 int ntracks, ret; 119 int ntracks, ret;
47 120
48 if ((ret = sr_audio_ioctl(cdi, CDROMREADTOCHDR, &tochdr))) 121 ret = sr_read_tochdr(cdi, &tochdr);
122 if (ret)
49 return ret; 123 return ret;
50 124
51 ntracks = tochdr.cdth_trk1 - tochdr.cdth_trk0 + 1; 125 ntracks = tochdr.cdth_trk1 - tochdr.cdth_trk0 + 1;
@@ -60,9 +134,11 @@ static int sr_fake_playtrkind(struct cdrom_device_info *cdi, struct cdrom_ti *ti
60 trk1_te.cdte_track = ti->cdti_trk1; 134 trk1_te.cdte_track = ti->cdti_trk1;
61 trk1_te.cdte_format = CDROM_MSF; 135 trk1_te.cdte_format = CDROM_MSF;
62 136
63 if ((ret = sr_audio_ioctl(cdi, CDROMREADTOCENTRY, &trk0_te))) 137 ret = sr_read_tocentry(cdi, &trk0_te);
138 if (ret)
64 return ret; 139 return ret;
65 if ((ret = sr_audio_ioctl(cdi, CDROMREADTOCENTRY, &trk1_te))) 140 ret = sr_read_tocentry(cdi, &trk1_te);
141 if (ret)
66 return ret; 142 return ret;
67 143
68 memset(&cgc, 0, sizeof(struct packet_command)); 144 memset(&cgc, 0, sizeof(struct packet_command));
@@ -78,6 +154,30 @@ static int sr_fake_playtrkind(struct cdrom_device_info *cdi, struct cdrom_ti *ti
78 return sr_do_ioctl(cdi->handle, &cgc); 154 return sr_do_ioctl(cdi->handle, &cgc);
79} 155}
80 156
157static int sr_play_trkind(struct cdrom_device_info *cdi,
158 struct cdrom_ti *ti)
159
160{
161 struct scsi_cd *cd = cdi->handle;
162 struct packet_command cgc;
163 int result;
164
165 memset(&cgc, 0, sizeof(struct packet_command));
166 cgc.timeout = IOCTL_TIMEOUT;
167 cgc.cmd[0] = GPCMD_PLAYAUDIO_TI;
168 cgc.cmd[4] = ti->cdti_trk0;
169 cgc.cmd[5] = ti->cdti_ind0;
170 cgc.cmd[7] = ti->cdti_trk1;
171 cgc.cmd[8] = ti->cdti_ind1;
172 cgc.data_direction = DMA_NONE;
173
174 result = sr_do_ioctl(cd, &cgc);
175 if (result == -EDRIVE_CANT_DO_THIS)
176 result = sr_fake_playtrkind(cdi, ti);
177
178 return result;
179}
180
81/* We do our own retries because we want to know what the specific 181/* We do our own retries because we want to know what the specific
82 error code is. Normally the UNIT_ATTENTION code will automatically 182 error code is. Normally the UNIT_ATTENTION code will automatically
83 clear after one error */ 183 clear after one error */
@@ -229,13 +329,14 @@ int sr_disk_status(struct cdrom_device_info *cdi)
229 int i, rc, have_datatracks = 0; 329 int i, rc, have_datatracks = 0;
230 330
231 /* look for data tracks */ 331 /* look for data tracks */
232 if (0 != (rc = sr_audio_ioctl(cdi, CDROMREADTOCHDR, &toc_h))) 332 rc = sr_read_tochdr(cdi, &toc_h);
333 if (rc)
233 return (rc == -ENOMEDIUM) ? CDS_NO_DISC : CDS_NO_INFO; 334 return (rc == -ENOMEDIUM) ? CDS_NO_DISC : CDS_NO_INFO;
234 335
235 for (i = toc_h.cdth_trk0; i <= toc_h.cdth_trk1; i++) { 336 for (i = toc_h.cdth_trk0; i <= toc_h.cdth_trk1; i++) {
236 toc_e.cdte_track = i; 337 toc_e.cdte_track = i;
237 toc_e.cdte_format = CDROM_LBA; 338 toc_e.cdte_format = CDROM_LBA;
238 if (sr_audio_ioctl(cdi, CDROMREADTOCENTRY, &toc_e)) 339 if (sr_read_tocentry(cdi, &toc_e))
239 return CDS_NO_INFO; 340 return CDS_NO_INFO;
240 if (toc_e.cdte_ctrl & CDROM_DATA_TRACK) { 341 if (toc_e.cdte_ctrl & CDROM_DATA_TRACK) {
241 have_datatracks = 1; 342 have_datatracks = 1;
@@ -262,10 +363,6 @@ int sr_get_last_session(struct cdrom_device_info *cdi,
262 return 0; 363 return 0;
263} 364}
264 365
265/* primitive to determine whether we need to have GFP_DMA set based on
266 * the status of the unchecked_isa_dma flag in the host structure */
267#define SR_GFP_DMA(cd) (((cd)->device->host->unchecked_isa_dma) ? GFP_DMA : 0)
268
269int sr_get_mcn(struct cdrom_device_info *cdi, struct cdrom_mcn *mcn) 366int sr_get_mcn(struct cdrom_device_info *cdi, struct cdrom_mcn *mcn)
270{ 367{
271 Scsi_CD *cd = cdi->handle; 368 Scsi_CD *cd = cdi->handle;
@@ -329,93 +426,16 @@ int sr_select_speed(struct cdrom_device_info *cdi, int speed)
329 426
330int sr_audio_ioctl(struct cdrom_device_info *cdi, unsigned int cmd, void *arg) 427int sr_audio_ioctl(struct cdrom_device_info *cdi, unsigned int cmd, void *arg)
331{ 428{
332 Scsi_CD *cd = cdi->handle;
333 struct packet_command cgc;
334 int result;
335 unsigned char *buffer = kmalloc(32, GFP_KERNEL | SR_GFP_DMA(cd));
336
337 if (!buffer)
338 return -ENOMEM;
339
340 memset(&cgc, 0, sizeof(struct packet_command));
341 cgc.timeout = IOCTL_TIMEOUT;
342
343 switch (cmd) { 429 switch (cmd) {
344 case CDROMREADTOCHDR: 430 case CDROMREADTOCHDR:
345 { 431 return sr_read_tochdr(cdi, arg);
346 struct cdrom_tochdr *tochdr = (struct cdrom_tochdr *) arg;
347
348 cgc.cmd[0] = GPCMD_READ_TOC_PMA_ATIP;
349 cgc.cmd[8] = 12; /* LSB of length */
350 cgc.buffer = buffer;
351 cgc.buflen = 12;
352 cgc.quiet = 1;
353 cgc.data_direction = DMA_FROM_DEVICE;
354
355 result = sr_do_ioctl(cd, &cgc);
356
357 tochdr->cdth_trk0 = buffer[2];
358 tochdr->cdth_trk1 = buffer[3];
359
360 break;
361 }
362
363 case CDROMREADTOCENTRY: 432 case CDROMREADTOCENTRY:
364 { 433 return sr_read_tocentry(cdi, arg);
365 struct cdrom_tocentry *tocentry = (struct cdrom_tocentry *) arg; 434 case CDROMPLAYTRKIND:
366 435 return sr_play_trkind(cdi, arg);
367 cgc.cmd[0] = GPCMD_READ_TOC_PMA_ATIP;
368 cgc.cmd[1] |= (tocentry->cdte_format == CDROM_MSF) ? 0x02 : 0;
369 cgc.cmd[6] = tocentry->cdte_track;
370 cgc.cmd[8] = 12; /* LSB of length */
371 cgc.buffer = buffer;
372 cgc.buflen = 12;
373 cgc.data_direction = DMA_FROM_DEVICE;
374
375 result = sr_do_ioctl(cd, &cgc);
376
377 tocentry->cdte_ctrl = buffer[5] & 0xf;
378 tocentry->cdte_adr = buffer[5] >> 4;
379 tocentry->cdte_datamode = (tocentry->cdte_ctrl & 0x04) ? 1 : 0;
380 if (tocentry->cdte_format == CDROM_MSF) {
381 tocentry->cdte_addr.msf.minute = buffer[9];
382 tocentry->cdte_addr.msf.second = buffer[10];
383 tocentry->cdte_addr.msf.frame = buffer[11];
384 } else
385 tocentry->cdte_addr.lba = (((((buffer[8] << 8) + buffer[9]) << 8)
386 + buffer[10]) << 8) + buffer[11];
387
388 break;
389 }
390
391 case CDROMPLAYTRKIND: {
392 struct cdrom_ti* ti = (struct cdrom_ti*)arg;
393
394 cgc.cmd[0] = GPCMD_PLAYAUDIO_TI;
395 cgc.cmd[4] = ti->cdti_trk0;
396 cgc.cmd[5] = ti->cdti_ind0;
397 cgc.cmd[7] = ti->cdti_trk1;
398 cgc.cmd[8] = ti->cdti_ind1;
399 cgc.data_direction = DMA_NONE;
400
401 result = sr_do_ioctl(cd, &cgc);
402 if (result == -EDRIVE_CANT_DO_THIS)
403 result = sr_fake_playtrkind(cdi, ti);
404
405 break;
406 }
407
408 default: 436 default:
409 result = -EINVAL; 437 return -EINVAL;
410 } 438 }
411
412#if 0
413 if (result)
414 printk("DEBUG: sr_audio: result for ioctl %x: %x\n", cmd, result);
415#endif
416
417 kfree(buffer);
418 return result;
419} 439}
420 440
421/* ----------------------------------------------------------------------- 441/* -----------------------------------------------------------------------
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index c4aade8f5345..13b1d3aac265 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -38,6 +38,7 @@ static const char *verstr = "20050830";
38#include <linux/devfs_fs_kernel.h> 38#include <linux/devfs_fs_kernel.h>
39#include <linux/cdev.h> 39#include <linux/cdev.h>
40#include <linux/delay.h> 40#include <linux/delay.h>
41#include <linux/mutex.h>
41 42
42#include <asm/uaccess.h> 43#include <asm/uaccess.h>
43#include <asm/dma.h> 44#include <asm/dma.h>
@@ -193,7 +194,6 @@ static int sgl_unmap_user_pages(struct scatterlist *, const unsigned int, int);
193 194
194static int st_probe(struct device *); 195static int st_probe(struct device *);
195static int st_remove(struct device *); 196static int st_remove(struct device *);
196static int st_init_command(struct scsi_cmnd *);
197 197
198static void do_create_driverfs_files(void); 198static void do_create_driverfs_files(void);
199static void do_remove_driverfs_files(void); 199static void do_remove_driverfs_files(void);
@@ -206,7 +206,6 @@ static struct scsi_driver st_template = {
206 .probe = st_probe, 206 .probe = st_probe,
207 .remove = st_remove, 207 .remove = st_remove,
208 }, 208 },
209 .init_command = st_init_command,
210}; 209};
211 210
212static int st_compression(struct scsi_tape *, int); 211static int st_compression(struct scsi_tape *, int);
@@ -220,7 +219,7 @@ static void scsi_tape_release(struct kref *);
220 219
221#define to_scsi_tape(obj) container_of(obj, struct scsi_tape, kref) 220#define to_scsi_tape(obj) container_of(obj, struct scsi_tape, kref)
222 221
223static DECLARE_MUTEX(st_ref_sem); 222static DEFINE_MUTEX(st_ref_mutex);
224 223
225 224
226#include "osst_detect.h" 225#include "osst_detect.h"
@@ -237,7 +236,7 @@ static struct scsi_tape *scsi_tape_get(int dev)
237{ 236{
238 struct scsi_tape *STp = NULL; 237 struct scsi_tape *STp = NULL;
239 238
240 down(&st_ref_sem); 239 mutex_lock(&st_ref_mutex);
241 write_lock(&st_dev_arr_lock); 240 write_lock(&st_dev_arr_lock);
242 241
243 if (dev < st_dev_max && scsi_tapes != NULL) 242 if (dev < st_dev_max && scsi_tapes != NULL)
@@ -259,7 +258,7 @@ out_put:
259 STp = NULL; 258 STp = NULL;
260out: 259out:
261 write_unlock(&st_dev_arr_lock); 260 write_unlock(&st_dev_arr_lock);
262 up(&st_ref_sem); 261 mutex_unlock(&st_ref_mutex);
263 return STp; 262 return STp;
264} 263}
265 264
@@ -267,10 +266,10 @@ static void scsi_tape_put(struct scsi_tape *STp)
267{ 266{
268 struct scsi_device *sdev = STp->device; 267 struct scsi_device *sdev = STp->device;
269 268
270 down(&st_ref_sem); 269 mutex_lock(&st_ref_mutex);
271 kref_put(&STp->kref, scsi_tape_release); 270 kref_put(&STp->kref, scsi_tape_release);
272 scsi_device_put(sdev); 271 scsi_device_put(sdev);
273 up(&st_ref_sem); 272 mutex_unlock(&st_ref_mutex);
274} 273}
275 274
276struct st_reject_data { 275struct st_reject_data {
@@ -4141,9 +4140,9 @@ static int st_remove(struct device *dev)
4141 } 4140 }
4142 } 4141 }
4143 4142
4144 down(&st_ref_sem); 4143 mutex_lock(&st_ref_mutex);
4145 kref_put(&tpnt->kref, scsi_tape_release); 4144 kref_put(&tpnt->kref, scsi_tape_release);
4146 up(&st_ref_sem); 4145 mutex_unlock(&st_ref_mutex);
4147 return 0; 4146 return 0;
4148 } 4147 }
4149 } 4148 }
@@ -4156,7 +4155,7 @@ static int st_remove(struct device *dev)
4156 * scsi_tape_release - Called to free the Scsi_Tape structure 4155 * scsi_tape_release - Called to free the Scsi_Tape structure
4157 * @kref: pointer to embedded kref 4156 * @kref: pointer to embedded kref
4158 * 4157 *
4159 * st_ref_sem must be held entering this routine. Because it is 4158 * st_ref_mutex must be held entering this routine. Because it is
4160 * called on last put, you should always use the scsi_tape_get() 4159 * called on last put, you should always use the scsi_tape_get()
4161 * scsi_tape_put() helpers which manipulate the semaphore directly 4160 * scsi_tape_put() helpers which manipulate the semaphore directly
4162 * and never do a direct kref_put(). 4161 * and never do a direct kref_put().
@@ -4180,29 +4179,6 @@ static void scsi_tape_release(struct kref *kref)
4180 return; 4179 return;
4181} 4180}
4182 4181
4183static void st_intr(struct scsi_cmnd *SCpnt)
4184{
4185 /*
4186 * The caller should be checking the request's errors
4187 * value.
4188 */
4189 scsi_io_completion(SCpnt, SCpnt->bufflen, 0);
4190}
4191
4192/*
4193 * st_init_command: only called via the scsi_cmd_ioctl (block SG_IO)
4194 * interface for REQ_BLOCK_PC commands.
4195 */
4196static int st_init_command(struct scsi_cmnd *SCpnt)
4197{
4198 if (!(SCpnt->request->flags & REQ_BLOCK_PC))
4199 return 0;
4200
4201 scsi_setup_blk_pc_cmnd(SCpnt);
4202 SCpnt->done = st_intr;
4203 return 1;
4204}
4205
4206static int __init init_st(void) 4182static int __init init_st(void)
4207{ 4183{
4208 validate_options(); 4184 validate_options();
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index 7fb397e3f2d3..5403257ae3e7 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -181,6 +181,7 @@
181#define PCI_DEVICE_ID_LSI_FC929X 0x0626 181#define PCI_DEVICE_ID_LSI_FC929X 0x0626
182#define PCI_DEVICE_ID_LSI_FC939X 0x0642 182#define PCI_DEVICE_ID_LSI_FC939X 0x0642
183#define PCI_DEVICE_ID_LSI_FC949X 0x0640 183#define PCI_DEVICE_ID_LSI_FC949X 0x0640
184#define PCI_DEVICE_ID_LSI_FC949ES 0x0646
184#define PCI_DEVICE_ID_LSI_FC919X 0x0628 185#define PCI_DEVICE_ID_LSI_FC919X 0x0628
185#define PCI_DEVICE_ID_NCR_YELLOWFIN 0x0701 186#define PCI_DEVICE_ID_NCR_YELLOWFIN 0x0701
186#define PCI_DEVICE_ID_LSI_61C102 0x0901 187#define PCI_DEVICE_ID_LSI_61C102 0x0901
diff --git a/include/linux/raid_class.h b/include/linux/raid_class.h
index 48831eac2910..d0dd38b3a2fd 100644
--- a/include/linux/raid_class.h
+++ b/include/linux/raid_class.h
@@ -31,9 +31,11 @@ enum raid_level {
31 RAID_LEVEL_LINEAR, 31 RAID_LEVEL_LINEAR,
32 RAID_LEVEL_0, 32 RAID_LEVEL_0,
33 RAID_LEVEL_1, 33 RAID_LEVEL_1,
34 RAID_LEVEL_10,
34 RAID_LEVEL_3, 35 RAID_LEVEL_3,
35 RAID_LEVEL_4, 36 RAID_LEVEL_4,
36 RAID_LEVEL_5, 37 RAID_LEVEL_5,
38 RAID_LEVEL_50,
37 RAID_LEVEL_6, 39 RAID_LEVEL_6,
38}; 40};
39 41
diff --git a/include/scsi/iscsi_if.h b/include/scsi/iscsi_if.h
index be1bc792ab18..3e5cb5ab2d34 100644
--- a/include/scsi/iscsi_if.h
+++ b/include/scsi/iscsi_if.h
@@ -168,6 +168,12 @@ typedef uint64_t iscsi_connh_t; /* iSCSI Data-Path connection handle */
168 168
169#define iscsi_ptr(_handle) ((void*)(unsigned long)_handle) 169#define iscsi_ptr(_handle) ((void*)(unsigned long)_handle)
170#define iscsi_handle(_ptr) ((uint64_t)(unsigned long)_ptr) 170#define iscsi_handle(_ptr) ((uint64_t)(unsigned long)_ptr)
171#define hostdata_session(_hostdata) (iscsi_ptr(*(unsigned long *)_hostdata))
172
173/**
174 * iscsi_hostdata - get LLD hostdata from scsi_host
175 * @_hostdata: pointer to scsi host's hostdata
176 **/
171#define iscsi_hostdata(_hostdata) ((void*)_hostdata + sizeof(unsigned long)) 177#define iscsi_hostdata(_hostdata) ((void*)_hostdata + sizeof(unsigned long))
172 178
173/* 179/*
diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h
index 6cb1e2788d8b..c60b8ff2f5e4 100644
--- a/include/scsi/scsi.h
+++ b/include/scsi/scsi.h
@@ -32,6 +32,12 @@ extern const unsigned char scsi_command_size[8];
32extern const char *const scsi_device_types[MAX_SCSI_DEVICE_CODE]; 32extern const char *const scsi_device_types[MAX_SCSI_DEVICE_CODE];
33 33
34/* 34/*
35 * Special value for scanning to specify scanning or rescanning of all
36 * possible channels, (target) ids, or luns on a given shost.
37 */
38#define SCAN_WILD_CARD ~0
39
40/*
35 * SCSI opcodes 41 * SCSI opcodes
36 */ 42 */
37 43
diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
index 41cfc29be899..7529f4388bb4 100644
--- a/include/scsi/scsi_cmnd.h
+++ b/include/scsi/scsi_cmnd.h
@@ -151,6 +151,5 @@ extern struct scsi_cmnd *scsi_get_command(struct scsi_device *, gfp_t);
151extern void scsi_put_command(struct scsi_cmnd *); 151extern void scsi_put_command(struct scsi_cmnd *);
152extern void scsi_io_completion(struct scsi_cmnd *, unsigned int, unsigned int); 152extern void scsi_io_completion(struct scsi_cmnd *, unsigned int, unsigned int);
153extern void scsi_finish_command(struct scsi_cmnd *cmd); 153extern void scsi_finish_command(struct scsi_cmnd *cmd);
154extern void scsi_setup_blk_pc_cmnd(struct scsi_cmnd *cmd);
155 154
156#endif /* _SCSI_SCSI_CMND_H */ 155#endif /* _SCSI_SCSI_CMND_H */
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index 230bc55c0bfa..467274a764d1 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -5,6 +5,7 @@
5#include <linux/list.h> 5#include <linux/list.h>
6#include <linux/types.h> 6#include <linux/types.h>
7#include <linux/workqueue.h> 7#include <linux/workqueue.h>
8#include <linux/mutex.h>
8 9
9struct block_device; 10struct block_device;
10struct completion; 11struct completion;
@@ -469,7 +470,7 @@ struct Scsi_Host {
469 spinlock_t default_lock; 470 spinlock_t default_lock;
470 spinlock_t *host_lock; 471 spinlock_t *host_lock;
471 472
472 struct semaphore scan_mutex;/* serialize scanning activity */ 473 struct mutex scan_mutex;/* serialize scanning activity */
473 474
474 struct list_head eh_cmd_q; 475 struct list_head eh_cmd_q;
475 struct task_struct * ehandler; /* Error recovery thread. */ 476 struct task_struct * ehandler; /* Error recovery thread. */
diff --git a/include/scsi/scsi_transport.h b/include/scsi/scsi_transport.h
index f6e0bb484c63..e7b1054adf86 100644
--- a/include/scsi/scsi_transport.h
+++ b/include/scsi/scsi_transport.h
@@ -30,12 +30,9 @@ struct scsi_transport_template {
30 struct transport_container device_attrs; 30 struct transport_container device_attrs;
31 31
32 /* 32 /*
33 * If set, call target_parent prior to allocating a scsi_target, 33 * If set, called from sysfs and legacy procfs rescanning code.
34 * so we get the appropriate parent for the target. This function
35 * is required for transports like FC and iSCSI that do not put the
36 * scsi_target under scsi_host.
37 */ 34 */
38 struct device *(*target_parent)(struct Scsi_Host *, int, uint); 35 int (*user_scan)(struct Scsi_Host *, uint, uint, uint);
39 36
40 /* The size of the specific transport attribute structure (a 37 /* The size of the specific transport attribute structure (a
41 * space of this size will be left at the end of the 38 * space of this size will be left at the end of the
diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
index 394f14a5b7cb..cf3fec8be1e3 100644
--- a/include/scsi/scsi_transport_fc.h
+++ b/include/scsi/scsi_transport_fc.h
@@ -303,6 +303,7 @@ struct fc_host_attrs {
303 /* Fixed Attributes */ 303 /* Fixed Attributes */
304 u64 node_name; 304 u64 node_name;
305 u64 port_name; 305 u64 port_name;
306 u64 permanent_port_name;
306 u32 supported_classes; 307 u32 supported_classes;
307 u8 supported_fc4s[FC_FC4_LIST_SIZE]; 308 u8 supported_fc4s[FC_FC4_LIST_SIZE];
308 char symbolic_name[FC_SYMBOLIC_NAME_SIZE]; 309 char symbolic_name[FC_SYMBOLIC_NAME_SIZE];
@@ -338,6 +339,8 @@ struct fc_host_attrs {
338 (((struct fc_host_attrs *)(x)->shost_data)->node_name) 339 (((struct fc_host_attrs *)(x)->shost_data)->node_name)
339#define fc_host_port_name(x) \ 340#define fc_host_port_name(x) \
340 (((struct fc_host_attrs *)(x)->shost_data)->port_name) 341 (((struct fc_host_attrs *)(x)->shost_data)->port_name)
342#define fc_host_permanent_port_name(x) \
343 (((struct fc_host_attrs *)(x)->shost_data)->permanent_port_name)
341#define fc_host_supported_classes(x) \ 344#define fc_host_supported_classes(x) \
342 (((struct fc_host_attrs *)(x)->shost_data)->supported_classes) 345 (((struct fc_host_attrs *)(x)->shost_data)->supported_classes)
343#define fc_host_supported_fc4s(x) \ 346#define fc_host_supported_fc4s(x) \
@@ -426,6 +429,7 @@ struct fc_function_template {
426 /* host fixed attributes */ 429 /* host fixed attributes */
427 unsigned long show_host_node_name:1; 430 unsigned long show_host_node_name:1;
428 unsigned long show_host_port_name:1; 431 unsigned long show_host_port_name:1;
432 unsigned long show_host_permanent_port_name:1;
429 unsigned long show_host_supported_classes:1; 433 unsigned long show_host_supported_classes:1;
430 unsigned long show_host_supported_fc4s:1; 434 unsigned long show_host_supported_fc4s:1;
431 unsigned long show_host_symbolic_name:1; 435 unsigned long show_host_symbolic_name:1;
diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h
index f25041c386ec..16602a547a63 100644
--- a/include/scsi/scsi_transport_iscsi.h
+++ b/include/scsi/scsi_transport_iscsi.h
@@ -23,8 +23,14 @@
23#ifndef SCSI_TRANSPORT_ISCSI_H 23#ifndef SCSI_TRANSPORT_ISCSI_H
24#define SCSI_TRANSPORT_ISCSI_H 24#define SCSI_TRANSPORT_ISCSI_H
25 25
26#include <linux/device.h>
26#include <scsi/iscsi_if.h> 27#include <scsi/iscsi_if.h>
27 28
29struct scsi_transport_template;
30struct Scsi_Host;
31struct mempool_zone;
32struct iscsi_cls_conn;
33
28/** 34/**
29 * struct iscsi_transport - iSCSI Transport template 35 * struct iscsi_transport - iSCSI Transport template
30 * 36 *
@@ -48,23 +54,31 @@ struct iscsi_transport {
48 char *name; 54 char *name;
49 unsigned int caps; 55 unsigned int caps;
50 struct scsi_host_template *host_template; 56 struct scsi_host_template *host_template;
57 /* LLD session/scsi_host data size */
51 int hostdata_size; 58 int hostdata_size;
59 /* LLD iscsi_host data size */
60 int ihostdata_size;
61 /* LLD connection data size */
62 int conndata_size;
52 int max_lun; 63 int max_lun;
53 unsigned int max_conn; 64 unsigned int max_conn;
54 unsigned int max_cmd_len; 65 unsigned int max_cmd_len;
55 iscsi_sessionh_t (*create_session) (uint32_t initial_cmdsn, 66 struct Scsi_Host *(*create_session) (struct scsi_transport_template *t,
56 struct Scsi_Host *shost); 67 uint32_t initial_cmdsn);
57 void (*destroy_session) (iscsi_sessionh_t session); 68 void (*destroy_session) (struct Scsi_Host *shost);
58 iscsi_connh_t (*create_conn) (iscsi_sessionh_t session, uint32_t cid); 69 struct iscsi_cls_conn *(*create_conn) (struct Scsi_Host *shost,
70 uint32_t cid);
59 int (*bind_conn) (iscsi_sessionh_t session, iscsi_connh_t conn, 71 int (*bind_conn) (iscsi_sessionh_t session, iscsi_connh_t conn,
60 uint32_t transport_fd, int is_leading); 72 uint32_t transport_fd, int is_leading);
61 int (*start_conn) (iscsi_connh_t conn); 73 int (*start_conn) (iscsi_connh_t conn);
62 void (*stop_conn) (iscsi_connh_t conn, int flag); 74 void (*stop_conn) (iscsi_connh_t conn, int flag);
63 void (*destroy_conn) (iscsi_connh_t conn); 75 void (*destroy_conn) (struct iscsi_cls_conn *conn);
64 int (*set_param) (iscsi_connh_t conn, enum iscsi_param param, 76 int (*set_param) (iscsi_connh_t conn, enum iscsi_param param,
65 uint32_t value); 77 uint32_t value);
66 int (*get_param) (iscsi_connh_t conn, enum iscsi_param param, 78 int (*get_conn_param) (void *conndata, enum iscsi_param param,
67 uint32_t *value); 79 uint32_t *value);
80 int (*get_session_param) (struct Scsi_Host *shost,
81 enum iscsi_param param, uint32_t *value);
68 int (*send_pdu) (iscsi_connh_t conn, struct iscsi_hdr *hdr, 82 int (*send_pdu) (iscsi_connh_t conn, struct iscsi_hdr *hdr,
69 char *data, uint32_t data_size); 83 char *data, uint32_t data_size);
70 void (*get_stats) (iscsi_connh_t conn, struct iscsi_stats *stats); 84 void (*get_stats) (iscsi_connh_t conn, struct iscsi_stats *stats);
@@ -73,7 +87,7 @@ struct iscsi_transport {
73/* 87/*
74 * transport registration upcalls 88 * transport registration upcalls
75 */ 89 */
76extern int iscsi_register_transport(struct iscsi_transport *tt); 90extern struct scsi_transport_template *iscsi_register_transport(struct iscsi_transport *tt);
77extern int iscsi_unregister_transport(struct iscsi_transport *tt); 91extern int iscsi_unregister_transport(struct iscsi_transport *tt);
78 92
79/* 93/*
@@ -83,4 +97,49 @@ extern void iscsi_conn_error(iscsi_connh_t conn, enum iscsi_err error);
83extern int iscsi_recv_pdu(iscsi_connh_t conn, struct iscsi_hdr *hdr, 97extern int iscsi_recv_pdu(iscsi_connh_t conn, struct iscsi_hdr *hdr,
84 char *data, uint32_t data_size); 98 char *data, uint32_t data_size);
85 99
100struct iscsi_cls_conn {
101 struct list_head conn_list; /* item in connlist */
102 void *dd_data; /* LLD private data */
103 struct iscsi_transport *transport;
104 iscsi_connh_t connh;
105 int active; /* must be accessed with the connlock */
106 struct device dev; /* sysfs transport/container device */
107 struct mempool_zone *z_error;
108 struct mempool_zone *z_pdu;
109 struct list_head freequeue;
110};
111
112#define iscsi_dev_to_conn(_dev) \
113 container_of(_dev, struct iscsi_cls_conn, dev)
114
115struct iscsi_cls_session {
116 struct list_head list; /* item in session_list */
117 struct iscsi_transport *transport;
118 struct device dev; /* sysfs transport/container device */
119};
120
121#define iscsi_dev_to_session(_dev) \
122 container_of(_dev, struct iscsi_cls_session, dev)
123
124#define iscsi_session_to_shost(_session) \
125 dev_to_shost(_session->dev.parent)
126
127/*
128 * session and connection functions that can be used by HW iSCSI LLDs
129 */
130extern struct iscsi_cls_session *iscsi_create_session(struct Scsi_Host *shost,
131 struct iscsi_transport *t);
132extern int iscsi_destroy_session(struct iscsi_cls_session *session);
133extern struct iscsi_cls_conn *iscsi_create_conn(struct iscsi_cls_session *sess,
134 uint32_t cid);
135extern int iscsi_destroy_conn(struct iscsi_cls_conn *conn);
136
137/*
138 * session functions used by software iscsi
139 */
140extern struct Scsi_Host *
141iscsi_transport_create_session(struct scsi_transport_template *scsit,
142 struct iscsi_transport *transport);
143extern int iscsi_transport_destroy_session(struct Scsi_Host *shost);
144
86#endif 145#endif
diff --git a/include/scsi/scsi_transport_spi.h b/include/scsi/scsi_transport_spi.h
index 54a89611e9c5..2b5930ba69ec 100644
--- a/include/scsi/scsi_transport_spi.h
+++ b/include/scsi/scsi_transport_spi.h
@@ -54,7 +54,7 @@ struct spi_transport_attrs {
54 unsigned int support_qas; /* supports quick arbitration and selection */ 54 unsigned int support_qas; /* supports quick arbitration and selection */
55 /* Private Fields */ 55 /* Private Fields */
56 unsigned int dv_pending:1; /* Internal flag */ 56 unsigned int dv_pending:1; /* Internal flag */
57 struct semaphore dv_sem; /* semaphore to serialise dv */ 57 struct mutex dv_mutex; /* semaphore to serialise dv */
58}; 58};
59 59
60enum spi_signal_type { 60enum spi_signal_type {