History

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

* git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6: (200 commits) [SCSI] usbstorage: use last_sector_bug flag universally [SCSI] libsas: abstract STP task status into a function [SCSI] ultrastor: clean up inline asm warnings [SCSI] aic7xxx: fix firmware build [SCSI] aacraid: fib context lock for management ioctls [SCSI] ch: remove forward declarations [SCSI] ch: fix device minor number management bug [SCSI] ch: handle class_device_create failure properly [SCSI] NCR5380: fix section mismatch [SCSI] sg: fix /proc/scsi/sg/devices when no SCSI devices [SCSI] IB/iSER: add logical unit reset support [SCSI] don't use __GFP_DMA for sense buffers if not required [SCSI] use dynamically allocated sense buffer [SCSI] scsi.h: add macro for enclosure bit of inquiry data [SCSI] sd: add fix for devices with last sector access problems [SCSI] fix pcmcia compile problem [SCSI] aacraid: add Voodoo Lite class of cards. [SCSI] aacraid: add new driver features flags [SCSI] qla2xxx: Update version number to 8.02.00-k7. [SCSI] qla2xxx: Issue correct MBC_INITIALIZE_FIRMWARE command. ...

Linus Torvalds committed 18 years ago

Commit 9b73e762 parents 50d9a12 23c3e29210 files · +10523 −9023Browse files

Unified · Split

210 files
  1. Documentation/DocBook/Makefile +1 −1
  2. Documentation/DocBook/scsi.tmpl +409 −0
  3. Documentation/dontdiff +0 −2
  4. Documentation/kernel-parameters.txt +7 −1
  5. Documentation/m68k/kernel-options.txt +0 −60
  6. Documentation/scsi/00-INDEX +0 −2
  7. Documentation/scsi/ChangeLog.megaraid_sas +159 −0
  8. Documentation/scsi/aacraid.txt +4 −0
  9. Documentation/scsi/hptiop.txt +21 −9
  10. Documentation/scsi/ncr53c7xx.txt +0 −40
  11. MAINTAINERS +4 −2
  12. block/bsg.c +12 −2
  13. block/ll_rw_blk.c +24 −0
  14. drivers/ata/libata-scsi.c +9 −2
  15. drivers/base/attribute_container.c +12 −2
  16. drivers/firewire/fw-sbp2.c +6 −0
  17. drivers/ieee1394/sbp2.c +6 −0
  18. drivers/infiniband/ulp/iser/iscsi_iser.c +7 −8
  19. drivers/infiniband/ulp/iser/iser_initiator.c +1 −3
  20. drivers/message/fusion/mptbase.c +52 −42
  21. drivers/message/fusion/mptbase.h +1 −1
  22. drivers/message/fusion/mptsas.c +2 −0
  23. drivers/message/fusion/mptscsih.c +1 −1
  24. drivers/message/i2o/i2o_scsi.c +1 −1
  25. drivers/s390/scsi/zfcp_aux.c +0 −2
  26. drivers/s390/scsi/zfcp_ccw.c +3 −0
  27. drivers/s390/scsi/zfcp_dbf.c +0 −6
  28. drivers/s390/scsi/zfcp_def.h +16 −6
  29. drivers/s390/scsi/zfcp_erp.c +7 −7
  30. drivers/s390/scsi/zfcp_fsf.c +35 −35
  31. drivers/s390/scsi/zfcp_scsi.c +11 −13
  32. drivers/scsi/.gitignore +0 −2
  33. drivers/scsi/3w-9xxx.c +1 −0
  34. drivers/scsi/53c700.c +6 −5
  35. drivers/scsi/BusLogic.c +1 −1
  36. drivers/scsi/Kconfig +3 −29
  37. drivers/scsi/Makefile +1 −4
  38. drivers/scsi/NCR5380.c +12 −11
  39. drivers/scsi/a2091.c +5 −31
  40. drivers/scsi/a3000.c +3 −12
  41. drivers/scsi/aacraid/aachba.c +215 −185
  42. drivers/scsi/aacraid/aacraid.h +174 −161
  43. drivers/scsi/aacraid/commctrl.c +58 −54
  44. drivers/scsi/aacraid/comminit.c +2 −2
  45. drivers/scsi/aacraid/commsup.c +239 −155
  46. drivers/scsi/aacraid/dpcsup.c +5 −5
  47. drivers/scsi/aacraid/linit.c +165 −77
  48. drivers/scsi/aacraid/rx.c +4 −2
  49. drivers/scsi/advansys.c +7 −7
  50. drivers/scsi/aha152x.c +8 −30
  51. drivers/scsi/aha1542.c +12 −37
  52. drivers/scsi/aha1740.c +1 −1
  53. drivers/scsi/aic7xxx/Makefile +18 −27
  54. drivers/scsi/aic7xxx/aic79xx_osm.c +3 −3
  55. drivers/scsi/aic7xxx/aic7xxx_osm.c +3 −3
  56. drivers/scsi/aic7xxx_old.c +5 −6
  57. drivers/scsi/aic94xx/aic94xx_dev.c +3 −3
  58. drivers/scsi/aic94xx/aic94xx_dump.c +2 −2
  59. drivers/scsi/aic94xx/aic94xx_hwi.c +1 −1
  60. drivers/scsi/aic94xx/aic94xx_hwi.h +3 −0
  61. drivers/scsi/aic94xx/aic94xx_init.c +187 −3
  62. drivers/scsi/aic94xx/aic94xx_scb.c +3 −3
  63. drivers/scsi/aic94xx/aic94xx_sds.c +389 −0
  64. drivers/scsi/aic94xx/aic94xx_sds.h +121 −0
  65. drivers/scsi/aic94xx/aic94xx_task.c +17 −33
  66. drivers/scsi/aic94xx/aic94xx_tmf.c +6 −6
  67. drivers/scsi/arcmsr/arcmsr_hba.c +3 −3
  68. drivers/scsi/atari_NCR5380.c +12 −12
  69. drivers/scsi/atp870u.c +17 −85
  70. drivers/scsi/ch.c +109 −106
  71. drivers/scsi/constants.c +1 −2
  72. drivers/scsi/dc395x.c +7 −9
  73. drivers/scsi/dpt_i2o.c +2 −3
  74. drivers/scsi/eata.c +2 −2
  75. drivers/scsi/eata_pio.c +6 −7
  76. drivers/scsi/fd_mcs.c +11 −25
  77. drivers/scsi/gdth.c +10 −12
  78. drivers/scsi/hosts.c +1 −3
  79. drivers/scsi/hptiop.c +464 −129
  80. drivers/scsi/hptiop.h +89 −35
  81. drivers/scsi/ibmvscsi/ibmvscsi.c +99 −56
  82. drivers/scsi/ibmvscsi/ibmvstgt.c +1 −1
  83. drivers/scsi/imm.c +5 −8
  84. drivers/scsi/in2000.c +5 −5
  85. drivers/scsi/ipr.c +1 −1
  86. drivers/scsi/ips.c +154 −172
  87. drivers/scsi/ips.h +14 −18
  88. drivers/scsi/iscsi_tcp.c +896 −1187
  89. drivers/scsi/iscsi_tcp.h +51 −83
  90. drivers/scsi/libiscsi.c +713 −378
  91. drivers/scsi/libsas/Kconfig +9 −0
  92. drivers/scsi/libsas/Makefile +3 −1
  93. drivers/scsi/libsas/sas_ata.c +1 −1
  94. drivers/scsi/libsas/sas_discover.c +1 −1
  95. drivers/scsi/libsas/sas_expander.c +26 −9
  96. drivers/scsi/libsas/sas_host_smp.c +274 −0
  97. drivers/scsi/libsas/sas_internal.h +15 −1
  98. drivers/scsi/libsas/sas_scsi_host.c +6 −3
  99. drivers/scsi/libsas/sas_task.c +36 −0
  100. drivers/scsi/libsrp.c +12 −11
  101. drivers/scsi/lpfc/lpfc.h +46 −7
  102. drivers/scsi/lpfc/lpfc_attr.c +191 −26
  103. drivers/scsi/lpfc/lpfc_crtn.h +14 −19
  104. drivers/scsi/lpfc/lpfc_ct.c +218 −86
  105. drivers/scsi/lpfc/lpfc_debugfs.c +127 −30
  106. drivers/scsi/lpfc/lpfc_disc.h +1 −1
  107. drivers/scsi/lpfc/lpfc_els.c +439 −184
  108. drivers/scsi/lpfc/lpfc_hbadisc.c +242 −130
  109. drivers/scsi/lpfc/lpfc_hw.h +99 −13
  110. drivers/scsi/lpfc/lpfc_init.c +318 −111
  111. drivers/scsi/lpfc/lpfc_logmsg.h +1 −0
  112. drivers/scsi/lpfc/lpfc_mbox.c +27 −5
  113. drivers/scsi/lpfc/lpfc_mem.c +1 −0
  114. drivers/scsi/lpfc/lpfc_nportdisc.c +132 −28
  115. drivers/scsi/lpfc/lpfc_scsi.c +37 −17
  116. drivers/scsi/lpfc/lpfc_scsi.h +1 −0
  117. drivers/scsi/lpfc/lpfc_sli.c +358 −176
  118. drivers/scsi/lpfc/lpfc_sli.h +5 −7
  119. drivers/scsi/lpfc/lpfc_version.h +3 −3
  120. drivers/scsi/lpfc/lpfc_vport.c +57 −36
  121. drivers/scsi/lpfc/lpfc_vport.h +1 −1
  122. drivers/scsi/megaraid.c +1 −1
  123. drivers/scsi/megaraid/megaraid_mbox.c +3 −3
  124. drivers/scsi/megaraid/megaraid_sas.c +448 −124
  125. drivers/scsi/megaraid/megaraid_sas.h +12 −6
  126. drivers/scsi/ncr53c8xx.c +2 −1
  127. drivers/scsi/pcmcia/Kconfig +2 −1
  128. drivers/scsi/pcmcia/nsp_cs.c +34 −20
  129. drivers/scsi/ppa.c +5 −7
  130. drivers/scsi/psi240i.c +0 −689
  131. drivers/scsi/psi240i.h +0 −315
  132. drivers/scsi/psi_chip.h +0 −195
  133. drivers/scsi/qla1280.c +2 −2
  134. drivers/scsi/qla2xxx/Makefile +1 −1
  135. drivers/scsi/qla2xxx/qla_attr.c +35 −19
  136. drivers/scsi/qla2xxx/qla_dbg.c +22 −15
  137. drivers/scsi/qla2xxx/qla_dbg.h +19 −0
  138. drivers/scsi/qla2xxx/qla_def.h +28 −24
  139. drivers/scsi/qla2xxx/qla_dfs.c +175 −0
  140. drivers/scsi/qla2xxx/qla_fw.h +24 −6
  141. drivers/scsi/qla2xxx/qla_gbl.h +21 −30
  142. drivers/scsi/qla2xxx/qla_init.c +70 −27
  143. drivers/scsi/qla2xxx/qla_isr.c +54 −66
  144. drivers/scsi/qla2xxx/qla_mbx.c +144 −286
  145. drivers/scsi/qla2xxx/qla_mid.c +20 −26
  146. drivers/scsi/qla2xxx/qla_os.c +29 −51
  147. drivers/scsi/qla2xxx/qla_sup.c +12 −6
  148. drivers/scsi/qla2xxx/qla_version.h +1 −1
  149. drivers/scsi/qla4xxx/ql4_init.c +3 −1
  150. drivers/scsi/qla4xxx/ql4_isr.c +4 −7
  151. drivers/scsi/qla4xxx/ql4_os.c +2 −5
  152. drivers/scsi/qlogicpti.c +8 −23
  153. drivers/scsi/scsi.c +168 −114
  154. drivers/scsi/scsi_debug.c +10 −27
  155. drivers/scsi/scsi_devinfo.c +15 −19
  156. drivers/scsi/scsi_error.c +64 −67
  157. drivers/scsi/scsi_ioctl.c +17 −9
  158. drivers/scsi/scsi_lib.c +72 −45
  159. drivers/scsi/scsi_netlink.c +7 −12
  160. drivers/scsi/scsi_proc.c +108 −2
  161. drivers/scsi/scsi_scan.c +23 −13
  162. drivers/scsi/scsi_sysfs.c +1 −0
  163. drivers/scsi/scsi_tgt_if.c +1 −1
  164. drivers/scsi/scsi_tgt_lib.c +13 −17
  165. drivers/scsi/scsi_transport_fc.c +46 −56
  166. drivers/scsi/scsi_transport_iscsi.c +185 −145
  167. drivers/scsi/scsi_transport_sas.c +22 −19
  168. drivers/scsi/scsi_transport_spi.c +176 −82
  169. drivers/scsi/scsi_transport_srp.c +6 −7
  170. drivers/scsi/scsicam.c +24 −11
  171. drivers/scsi/sd.c +33 −11
  172. drivers/scsi/seagate.c +0 −1667
  173. drivers/scsi/sg.c +16 −8
  174. drivers/scsi/sgiwd93.c +1 −0
  175. drivers/scsi/sr.c +24 −11
  176. drivers/scsi/sr.h +4 −0
  177. drivers/scsi/sr_ioctl.c +34 −14
  178. drivers/scsi/st.c +4 −5
  179. drivers/scsi/sun3_NCR5380.c +12 −12
  180. drivers/scsi/sym53c416.c +1 −15
  181. drivers/scsi/sym53c8xx_2/sym_glue.c +11 −11
  182. drivers/scsi/tmscsim.c +3 −3
  183. drivers/scsi/u14-34f.c +2 −2
  184. drivers/scsi/ultrastor.c +11 −4
  185. drivers/scsi/wd33c93.c +5 −5
  186. drivers/scsi/wd7000.c +6 −6
  187. drivers/usb/storage/freecom.c +6 −8
  188. drivers/usb/storage/isd200.c +46 −20
  189. drivers/usb/storage/protocol.c +53 −73
  190. drivers/usb/storage/scsiglue.c +14 −10
  191. drivers/usb/storage/sddr09.c +3 −6
  192. drivers/usb/storage/shuttle_usbat.c +26 −42
  193. drivers/usb/storage/transport.c +28 −17
  194. drivers/usb/storage/transport.h +2 −0
  195. fs/sysfs/file.c +9 −2
  196. fs/sysfs/group.c +16 −10
  197. include/linux/attribute_container.h +1 −0
  198. include/linux/blkdev.h +1 −0
  199. include/linux/sysfs.h +2 −0
  200. include/scsi/iscsi_if.h +20 −0
  201. include/scsi/iscsi_proto.h +13 −1
  202. include/scsi/libiscsi.h +65 −17
  203. include/scsi/libsas.h +14 −14
  204. include/scsi/sas.h +6 −7
  205. include/scsi/scsi_cmnd.h +1 −1
  206. include/scsi/scsi_device.h +9 −4
  207. include/scsi/scsi_transport_iscsi.h +7 −3
  208. include/scsi/scsi_transport_sas.h +5 −11
  209. include/scsi/sd.h +1 −0
  210. kernel/params.c +1 −1
Documentation/DocBook/Makefile+1−1
@@ -11,7 +11,7 @@ DOCBOOKS := wanbook.xml z8530book.xml mcabook.xml videobook.xml \ · 10 unmodified lines
1111 procfs-guide.xml writing_usb_driver.xml \
1212 kernel-api.xml filesystems.xml lsm.xml usb.xml \
1313 gadget.xml libata.xml mtdnand.xml librs.xml rapidio.xml \
14− genericirq.xml s390-drivers.xml uio-howto.xml
14+ genericirq.xml s390-drivers.xml uio-howto.xml scsi.xml
1515
1616 ###
1717 # The build process is as follows (targets):
Documentation/DocBook/scsi.tmpl+409−0
@@ -0,0 +1,409 @@
1+<?xml version="1.0" encoding="UTF-8"?>
2+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
3+ "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" []>
4+
5+<book id="scsimid">
6+ <bookinfo>
7+ <title>SCSI Interfaces Guide</title>
8+
9+ <authorgroup>
10+ <author>
11+ <firstname>James</firstname>
12+ <surname>Bottomley</surname>
13+ <affiliation>
14+ <address>
15+ <email>James.Bottomley@steeleye.com</email>
16+ </address>
17+ </affiliation>
18+ </author>
19+
20+ <author>
21+ <firstname>Rob</firstname>
22+ <surname>Landley</surname>
23+ <affiliation>
24+ <address>
25+ <email>rob@landley.net</email>
26+ </address>
27+ </affiliation>
28+ </author>
29+
30+ </authorgroup>
31+
32+ <copyright>
33+ <year>2007</year>
34+ <holder>Linux Foundation</holder>
35+ </copyright>
36+
37+ <legalnotice>
38+ <para>
39+ This documentation is free software; you can redistribute
40+ it and/or modify it under the terms of the GNU General Public
41+ License version 2.
42+ </para>
43+
44+ <para>
45+ This program is distributed in the hope that it will be
46+ useful, but WITHOUT ANY WARRANTY; without even the implied
47+ warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
48+ For more details see the file COPYING in the source
49+ distribution of Linux.
50+ </para>
51+ </legalnotice>
52+ </bookinfo>
53+
54+ <toc></toc>
55+
56+ <chapter id="intro">
57+ <title>Introduction</title>
58+ <sect1 id="protocol_vs_bus">
59+ <title>Protocol vs bus</title>
60+ <para>
61+ Once upon a time, the Small Computer Systems Interface defined both
62+ a parallel I/O bus and a data protocol to connect a wide variety of
63+ peripherals (disk drives, tape drives, modems, printers, scanners,
64+ optical drives, test equipment, and medical devices) to a host
65+ computer.
66+ </para>
67+ <para>
68+ Although the old parallel (fast/wide/ultra) SCSI bus has largely
69+ fallen out of use, the SCSI command set is more widely used than ever
70+ to communicate with devices over a number of different busses.
71+ </para>
72+ <para>
73+ The <ulink url='http://www.t10.org/scsi-3.htm'>SCSI protocol</ulink>
74+ is a big-endian peer-to-peer packet based protocol. SCSI commands
75+ are 6, 10, 12, or 16 bytes long, often followed by an associated data
76+ payload.
77+ </para>
78+ <para>
79+ SCSI commands can be transported over just about any kind of bus, and
80+ are the default protocol for storage devices attached to USB, SATA,
81+ SAS, Fibre Channel, FireWire, and ATAPI devices. SCSI packets are
82+ also commonly exchanged over Infiniband,
83+ <ulink url='http://i2o.shadowconnect.com/faq.php'>I20</ulink>, TCP/IP
84+ (<ulink url='http://en.wikipedia.org/wiki/ISCSI'>iSCSI</ulink>), even
85+ <ulink url='http://cyberelk.net/tim/parport/parscsi.html'>Parallel
86+ ports</ulink>.
87+ </para>
88+ </sect1>
89+ <sect1 id="subsystem_design">
90+ <title>Design of the Linux SCSI subsystem</title>
91+ <para>
92+ The SCSI subsystem uses a three layer design, with upper, mid, and low
93+ layers. Every operation involving the SCSI subsystem (such as reading
94+ a sector from a disk) uses one driver at each of the 3 levels: one
95+ upper layer driver, one lower layer driver, and the SCSI midlayer.
96+ </para>
97+ <para>
98+ The SCSI upper layer provides the interface between userspace and the
99+ kernel, in the form of block and char device nodes for I/O and
100+ ioctl(). The SCSI lower layer contains drivers for specific hardware
101+ devices.
102+ </para>
103+ <para>
104+ In between is the SCSI mid-layer, analogous to a network routing
105+ layer such as the IPv4 stack. The SCSI mid-layer routes a packet
106+ based data protocol between the upper layer's /dev nodes and the
107+ corresponding devices in the lower layer. It manages command queues,
108+ provides error handling and power management functions, and responds
109+ to ioctl() requests.
110+ </para>
111+ </sect1>
112+ </chapter>
113+
114+ <chapter id="upper_layer">
115+ <title>SCSI upper layer</title>
116+ <para>
117+ The upper layer supports the user-kernel interface by providing
118+ device nodes.
119+ </para>
120+ <sect1 id="sd">
121+ <title>sd (SCSI Disk)</title>
122+ <para>sd (sd_mod.o)</para>
123+<!-- !Idrivers/scsi/sd.c -->
124+ </sect1>
125+ <sect1 id="sr">
126+ <title>sr (SCSI CD-ROM)</title>
127+ <para>sr (sr_mod.o)</para>
128+ </sect1>
129+ <sect1 id="st">
130+ <title>st (SCSI Tape)</title>
131+ <para>st (st.o)</para>
132+ </sect1>
133+ <sect1 id="sg">
134+ <title>sg (SCSI Generic)</title>
135+ <para>sg (sg.o)</para>
136+ </sect1>
137+ <sect1 id="ch">
138+ <title>ch (SCSI Media Changer)</title>
139+ <para>ch (ch.c)</para>
140+ </sect1>
141+ </chapter>
142+
143+ <chapter id="mid_layer">
144+ <title>SCSI mid layer</title>
145+
146+ <sect1 id="midlayer_implementation">
147+ <title>SCSI midlayer implementation</title>
148+ <sect2 id="scsi_device.h">
149+ <title>include/scsi/scsi_device.h</title>
150+ <para>
151+ </para>
152+!Iinclude/scsi/scsi_device.h
153+ </sect2>
154+
155+ <sect2 id="scsi.c">
156+ <title>drivers/scsi/scsi.c</title>
157+ <para>Main file for the SCSI midlayer.</para>
158+!Edrivers/scsi/scsi.c
159+ </sect2>
160+ <sect2 id="scsicam.c">
161+ <title>drivers/scsi/scsicam.c</title>
162+ <para>
163+ <ulink url='http://www.t10.org/ftp/t10/drafts/cam/cam-r12b.pdf'>SCSI
164+ Common Access Method</ulink> support functions, for use with
165+ HDIO_GETGEO, etc.
166+ </para>
167+!Edrivers/scsi/scsicam.c
168+ </sect2>
169+ <sect2 id="scsi_error.c">
170+ <title>drivers/scsi/scsi_error.c</title>
171+ <para>Common SCSI error/timeout handling routines.</para>
172+!Edrivers/scsi/scsi_error.c
173+ </sect2>
174+ <sect2 id="scsi_devinfo.c">
175+ <title>drivers/scsi/scsi_devinfo.c</title>
176+ <para>
177+ Manage scsi_dev_info_list, which tracks blacklisted and whitelisted
178+ devices.
179+ </para>
180+!Idrivers/scsi/scsi_devinfo.c
181+ </sect2>
182+ <sect2 id="scsi_ioctl.c">
183+ <title>drivers/scsi/scsi_ioctl.c</title>
184+ <para>
185+ Handle ioctl() calls for SCSI devices.
186+ </para>
187+!Edrivers/scsi/scsi_ioctl.c
188+ </sect2>
189+ <sect2 id="scsi_lib.c">
190+ <title>drivers/scsi/scsi_lib.c</title>
191+ <para>
192+ SCSI queuing library.
193+ </para>
194+!Edrivers/scsi/scsi_lib.c
195+ </sect2>
196+ <sect2 id="scsi_lib_dma.c">
197+ <title>drivers/scsi/scsi_lib_dma.c</title>
198+ <para>
199+ SCSI library functions depending on DMA
200+ (map and unmap scatter-gather lists).
201+ </para>
202+!Edrivers/scsi/scsi_lib_dma.c
203+ </sect2>
204+ <sect2 id="scsi_module.c">
205+ <title>drivers/scsi/scsi_module.c</title>
206+ <para>
207+ The file drivers/scsi/scsi_module.c contains legacy support for
208+ old-style host templates. It should never be used by any new driver.
209+ </para>
210+ </sect2>
211+ <sect2 id="scsi_proc.c">
212+ <title>drivers/scsi/scsi_proc.c</title>
213+ <para>
214+ The functions in this file provide an interface between
215+ the PROC file system and the SCSI device drivers
216+ It is mainly used for debugging, statistics and to pass
217+ information directly to the lowlevel driver.
218+
219+ I.E. plumbing to manage /proc/scsi/*
220+ </para>
221+!Idrivers/scsi/scsi_proc.c
222+ </sect2>
223+ <sect2 id="scsi_netlink.c">
224+ <title>drivers/scsi/scsi_netlink.c</title>
225+ <para>
226+ Infrastructure to provide async events from transports to userspace
227+ via netlink, using a single NETLINK_SCSITRANSPORT protocol for all
228+ transports.
229+
230+ See <ulink url='http://marc.info/?l=linux-scsi&amp;m=115507374832500&amp;w=2'>the
231+ original patch submission</ulink> for more details.
232+ </para>
233+!Idrivers/scsi/scsi_netlink.c
234+ </sect2>
235+ <sect2 id="scsi_scan.c">
236+ <title>drivers/scsi/scsi_scan.c</title>
237+ <para>
238+ Scan a host to determine which (if any) devices are attached.
239+
240+ The general scanning/probing algorithm is as follows, exceptions are
241+ made to it depending on device specific flags, compilation options,
242+ and global variable (boot or module load time) settings.
243+
244+ A specific LUN is scanned via an INQUIRY command; if the LUN has a
245+ device attached, a scsi_device is allocated and setup for it.
246+
247+ For every id of every channel on the given host, start by scanning
248+ LUN 0. Skip hosts that don't respond at all to a scan of LUN 0.
249+ Otherwise, if LUN 0 has a device attached, allocate and setup a
250+ scsi_device for it. If target is SCSI-3 or up, issue a REPORT LUN,
251+ and scan all of the LUNs returned by the REPORT LUN; else,
252+ sequentially scan LUNs up until some maximum is reached, or a LUN is
253+ seen that cannot have a device attached to it.
254+ </para>
255+!Idrivers/scsi/scsi_scan.c
256+ </sect2>
257+ <sect2 id="scsi_sysctl.c">
258+ <title>drivers/scsi/scsi_sysctl.c</title>
259+ <para>
260+ Set up the sysctl entry: "/dev/scsi/logging_level"
261+ (DEV_SCSI_LOGGING_LEVEL) which sets/returns scsi_logging_level.
262+ </para>
263+ </sect2>
264+ <sect2 id="scsi_sysfs.c">
265+ <title>drivers/scsi/scsi_sysfs.c</title>
266+ <para>
267+ SCSI sysfs interface routines.
268+ </para>
269+!Edrivers/scsi/scsi_sysfs.c
270+ </sect2>
271+ <sect2 id="hosts.c">
272+ <title>drivers/scsi/hosts.c</title>
273+ <para>
274+ mid to lowlevel SCSI driver interface
275+ </para>
276+!Edrivers/scsi/hosts.c
277+ </sect2>
278+ <sect2 id="constants.c">
279+ <title>drivers/scsi/constants.c</title>
280+ <para>
281+ mid to lowlevel SCSI driver interface
282+ </para>
283+!Edrivers/scsi/constants.c
284+ </sect2>
285+ </sect1>
286+
287+ <sect1 id="Transport_classes">
288+ <title>Transport classes</title>
289+ <para>
290+ Transport classes are service libraries for drivers in the SCSI
291+ lower layer, which expose transport attributes in sysfs.
292+ </para>
293+ <sect2 id="Fibre_Channel_transport">
294+ <title>Fibre Channel transport</title>
295+ <para>
296+ The file drivers/scsi/scsi_transport_fc.c defines transport attributes
297+ for Fibre Channel.
298+ </para>
299+!Edrivers/scsi/scsi_transport_fc.c
300+ </sect2>
301+ <sect2 id="iSCSI_transport">
302+ <title>iSCSI transport class</title>
303+ <para>
304+ The file drivers/scsi/scsi_transport_iscsi.c defines transport
305+ attributes for the iSCSI class, which sends SCSI packets over TCP/IP
306+ connections.
307+ </para>
308+!Edrivers/scsi/scsi_transport_iscsi.c
309+ </sect2>
310+ <sect2 id="SAS_transport">
311+ <title>Serial Attached SCSI (SAS) transport class</title>
312+ <para>
313+ The file drivers/scsi/scsi_transport_sas.c defines transport
314+ attributes for Serial Attached SCSI, a variant of SATA aimed at
315+ large high-end systems.
316+ </para>
317+ <para>
318+ The SAS transport class contains common code to deal with SAS HBAs,
319+ an aproximated representation of SAS topologies in the driver model,
320+ and various sysfs attributes to expose these topologies and managment
321+ interfaces to userspace.
322+ </para>
323+ <para>
324+ In addition to the basic SCSI core objects this transport class
325+ introduces two additional intermediate objects: The SAS PHY
326+ as represented by struct sas_phy defines an "outgoing" PHY on
327+ a SAS HBA or Expander, and the SAS remote PHY represented by
328+ struct sas_rphy defines an "incoming" PHY on a SAS Expander or
329+ end device. Note that this is purely a software concept, the
330+ underlying hardware for a PHY and a remote PHY is the exactly
331+ the same.
332+ </para>
333+ <para>
334+ There is no concept of a SAS port in this code, users can see
335+ what PHYs form a wide port based on the port_identifier attribute,
336+ which is the same for all PHYs in a port.
337+ </para>
338+!Edrivers/scsi/scsi_transport_sas.c
339+ </sect2>
340+ <sect2 id="SATA_transport">
341+ <title>SATA transport class</title>
342+ <para>
343+ The SATA transport is handled by libata, which has its own book of
344+ documentation in this directory.
345+ </para>
346+ </sect2>
347+ <sect2 id="SPI_transport">
348+ <title>Parallel SCSI (SPI) transport class</title>
349+ <para>
350+ The file drivers/scsi/scsi_transport_spi.c defines transport
351+ attributes for traditional (fast/wide/ultra) SCSI busses.
352+ </para>
353+!Edrivers/scsi/scsi_transport_spi.c
354+ </sect2>
355+ <sect2 id="SRP_transport">
356+ <title>SCSI RDMA (SRP) transport class</title>
357+ <para>
358+ The file drivers/scsi/scsi_transport_srp.c defines transport
359+ attributes for SCSI over Remote Direct Memory Access.
360+ </para>
361+!Edrivers/scsi/scsi_transport_srp.c
362+ </sect2>
363+ </sect1>
364+
365+ </chapter>
366+
367+ <chapter id="lower_layer">
368+ <title>SCSI lower layer</title>
369+ <sect1 id="hba_drivers">
370+ <title>Host Bus Adapter transport types</title>
371+ <para>
372+ Many modern device controllers use the SCSI command set as a protocol to
373+ communicate with their devices through many different types of physical
374+ connections.
375+ </para>
376+ <para>
377+ In SCSI language a bus capable of carrying SCSI commands is
378+ called a "transport", and a controller connecting to such a bus is
379+ called a "host bus adapter" (HBA).
380+ </para>
381+ <sect2 id="scsi_debug.c">
382+ <title>Debug transport</title>
383+ <para>
384+ The file drivers/scsi/scsi_debug.c simulates a host adapter with a
385+ variable number of disks (or disk like devices) attached, sharing a
386+ common amount of RAM. Does a lot of checking to make sure that we are
387+ not getting blocks mixed up, and panics the kernel if anything out of
388+ the ordinary is seen.
389+ </para>
390+ <para>
391+ To be more realistic, the simulated devices have the transport
392+ attributes of SAS disks.
393+ </para>
394+ <para>
395+ For documentation see
396+ <ulink url='http://www.torque.net/sg/sdebug26.html'>http://www.torque.net/sg/sdebug26.html</ulink>
397+ </para>
398+<!-- !Edrivers/scsi/scsi_debug.c -->
399+ </sect2>
400+ <sect2 id="todo">
401+ <title>todo</title>
402+ <para>Parallel (fast/wide/ultra) SCSI, USB, SATA,
403+ SAS, Fibre Channel, FireWire, ATAPI devices, Infiniband,
404+ I20, iSCSI, Parallel ports, netlink...
405+ </para>
406+ </sect2>
407+ </sect1>
408+ </chapter>
409+</book>
Documentation/dontdiff+0−2
@@ -46,8 +46,6 @@ · 45 unmodified lines
4646 .mailmap
4747 .mm
4848 53c700_d.h
49−53c7xx_d.h
50−53c7xx_u.h
5149 53c8xx_d.h*
5250 BitKeeper
5351 COPYING
Documentation/kernel-parameters.txt+7−1
@@ -1598,7 +1598,13 @@ and is between 256 and 4096 characters. It is defined in the file · 1597 unmodified lines
15981598 Format: <vendor>:<model>:<flags>
15991599 (flags are integer value)
16001600
1601− scsi_logging= [SCSI]
1601+ scsi_logging_level= [SCSI] a bit mask of logging levels
1602+ See drivers/scsi/scsi_logging.h for bits. Also
1603+ settable via sysctl at dev.scsi.logging_level
1604+ (/proc/sys/dev/scsi/logging_level).
1605+ There is also a nice 'scsi_logging_level' script in the
1606+ S390-tools package, available for download at
1607+ http://www-128.ibm.com/developerworks/linux/linux390/s390-tools-1.5.4.html
16021608
16031609 scsi_mod.scan= [SCSI] sync (default) scans SCSI busses as they are
16041610 discovered. async scans them in kernel threads,
Documentation/m68k/kernel-options.txt+0−60
@@ -867,66 +867,6 @@ controller and should be autodetected by the driver. An example is the · 866 unmodified lines
867867 24 bit region which is specified by a mask of 0x00fffffe.
868868
869869
870−5.5) 53c7xx=
871−------------
872−
873−Syntax: 53c7xx=<sub-options...>
874−
875−These options affect the A4000T, A4091, WarpEngine, Blizzard 603e+,
876−and GForce 040/060 SCSI controllers on the Amiga, as well as the
877−builtin MVME 16x SCSI controller.
878−
879−The <sub-options> is a comma-separated list of the sub-options listed
880−below.
881−
882−5.5.1) nosync
883−-------------
884−
885−Syntax: nosync:0
886−
887− Disables sync negotiation for all devices. Any value after the
888− colon is acceptable (and has the same effect).
889−
890−5.5.2) noasync
891−--------------
892−
893−[OBSOLETE, REMOVED]
894−
895−5.5.3) nodisconnect
896−-------------------
897−
898−Syntax: nodisconnect:0
899−
900− Disables SCSI disconnects. Any value after the colon is acceptable
901− (and has the same effect).
902−
903−5.5.4) validids
904−---------------
905−
906−Syntax: validids:0xNN
907−
908− Specify which SCSI ids the driver should pay attention to. This is
909− a bitmask (i.e. to only pay attention to ID#4, you'd use 0x10).
910− Default is 0x7f (devices 0-6).
911−
912−5.5.5) opthi
913−5.5.6) optlo
914−------------
915−
916−Syntax: opthi:M,optlo:N
917−
918− Specify options for "hostdata->options". The acceptable definitions
919− are listed in drivers/scsi/53c7xx.h; the 32 high bits should be in
920− opthi and the 32 low bits in optlo. They must be specified in the
921− order opthi=M,optlo=N.
922−
923−5.5.7) next
924−-----------
925−
926− No argument. Used to separate blocks of keywords when there's more
927− than one 53c7xx host adapter in the system.
928−
929−
930870 /* Local Variables: */
931871 /* mode: text */
932872 /* End: */
Documentation/scsi/00-INDEX+0−2
@@ -64,8 +64,6 @@ lpfc.txt · 63 unmodified lines
6464 - LPFC driver release notes
6565 megaraid.txt
6666 - Common Management Module, shared code handling ioctls for LSI drivers
67−ncr53c7xx.txt
68− - info on driver for NCR53c7xx based adapters
6967 ncr53c8xx.txt
7068 - info on driver for NCR53c8xx based adapters
7169 osst.txt
Documentation/scsi/ChangeLog.megaraid_sas+159−0
@@ -1,3 +1,162 @@
1+1 Release Date : Thur. Nov. 07 16:30:43 PST 2007 -
2+ (emaild-id:megaraidlinux@lsi.com)
3+ Sumant Patro
4+ Bo Yang
5+
6+2 Current Version : 00.00.03.16
7+3 Older Version : 00.00.03.15
8+
9+1. Increased MFI_POLL_TIMEOUT_SECS to 60 seconds from 10. FW may take
10+ a max of 60 seconds to respond to the INIT cmd.
11+
12+1 Release Date : Fri. Sep. 07 16:30:43 PST 2007 -
13+ (emaild-id:megaraidlinux@lsi.com)
14+ Sumant Patro
15+ Bo Yang
16+
17+2 Current Version : 00.00.03.15
18+3 Older Version : 00.00.03.14
19+
20+1. Added module parameter "poll_mode_io" to support for "polling"
21+ (reduced interrupt operation). In this mode, IO completion
22+ interrupts are delayed. At the end of initiating IOs, the
23+ driver schedules for cmd completion if there are pending cmds
24+ to be completed. A timer-based interrupt has also been added
25+ to prevent IO completion processing from being delayed
26+ indefinitely in the case that no new IOs are initiated.
27+
28+1 Release Date : Fri. Sep. 07 16:30:43 PST 2007 -
29+ (emaild-id:megaraidlinux@lsi.com)
30+ Sumant Patro
31+ Bo Yang
32+
33+2 Current Version : 00.00.03.14
34+3 Older Version : 00.00.03.13
35+
36+1. Setting the max_sectors_per_req based on max SGL supported by the
37+ FW. Prior versions calculated this value from controller info
38+ (max_sectors_1, max_sectors_2). For certain controllers/FW,
39+ this was resulting in a value greater than max SGL supported
40+ by the FW. Issue was first reported by users running LUKS+XFS
41+ with megaraid_sas. Thanks to RB for providing the logs and
42+ duplication steps that helped to get to the root cause of the
43+ issue. 2. Increased MFI_POLL_TIMEOUT_SECS to 60 seconds from
44+ 10. FW may take a max of 60 seconds to respond to the INIT
45+ cmd.
46+
47+1 Release Date : Fri. June. 15 16:30:43 PST 2007 -
48+ (emaild-id:megaraidlinux@lsi.com)
49+ Sumant Patro
50+ Bo Yang
51+
52+2 Current Version : 00.00.03.13
53+3 Older Version : 00.00.03.12
54+
55+1. Added the megasas_reset_timer routine to intercept cmd timeout and throttle io.
56+
57+On Fri, 2007-03-16 at 16:44 -0600, James Bottomley wrote:
58+It looks like megaraid_sas at least needs this to throttle its commands
59+> as they begin to time out. The code keeps the existing transport
60+> template use of eh_timed_out (and allows the transport to override the
61+> host if they both have this callback).
62+>
63+> James
64+
65+1 Release Date : Sat May. 12 16:30:43 PST 2007 -
66+ (emaild-id:megaraidlinux@lsi.com)
67+ Sumant Patro
68+ Bo Yang
69+
70+2 Current Version : 00.00.03.12
71+3 Older Version : 00.00.03.11
72+
73+1. When MegaSAS driver receives reset call from OS, driver waits in reset
74+routine for max 3 minutes for all pending command completion. Now driver will
75+call completion routine every 5 seconds from the reset routine instead of
76+waiting for depending on cmd completion from isr path.
77+
78+1 Release Date : Mon Apr. 30 10:25:52 PST 2007 -
79+ (emaild-id:megaraidlinux@lsi.com)
80+ Sumant Patro
81+ Bo Yang
82+
83+2 Current Version : 00.00.03.11
84+3 Older Version : 00.00.03.09
85+
86+ 1. Memory Manager for IOCTL removed for 2.6 kernels.
87+ pci_alloc_consistent replaced by dma_alloc_coherent. With this
88+ change there is no need of memory manager in the driver code
89+
90+ On Wed, 2007-02-07 at 13:30 -0800, Andrew Morton wrote:
91+ > I suspect all this horror is due to stupidity in the DMA API.
92+ >
93+ > pci_alloc_consistent() just goes and assumes GFP_ATOMIC, whereas
94+ > the caller (megasas_mgmt_fw_ioctl) would have been perfectly happy
95+ > to use GFP_KERNEL.
96+ >
97+ > I bet this fixes it
98+
99+ It does, but the DMA API was expanded to cope with this exact case, so
100+ use dma_alloc_coherent() directly in the megaraid code instead. The dev
101+ is just &pci_dev->dev.
102+
103+ James <James.Bottomley@SteelEye.com>
104+
105+ 3. SYNCHRONIZE_CACHE is not supported by FW and thus blocked by driver.
106+ 4. Hibernation support added
107+ 5. Performing diskdump while running IO in RHEL 4 was failing. Fixed.
108+
109+1 Release Date : Fri Feb. 09 14:36:28 PST 2007 -
110+ (emaild-id:megaraidlinux@lsi.com)
111+ Sumant Patro
112+ Bo Yang
113+
114+2 Current Version : 00.00.03.09
115+3 Older Version : 00.00.03.08
116+
117+i. Under heavy IO mid-layer prints "DRIVER_TIMEOUT" errors
118+
119+ The driver now waits for 10 seconds to elapse instead of 5 (as in
120+ previous release) to resume IO.
121+
122+1 Release Date : Mon Feb. 05 11:35:24 PST 2007 -
123+ (emaild-id:megaraidlinux@lsi.com)
124+ Sumant Patro
125+ Bo Yang
126+2 Current Version : 00.00.03.08
127+3 Older Version : 00.00.03.07
128+
129+i. Under heavy IO mid-layer prints "DRIVER_TIMEOUT" errors
130+
131+ Fix: The driver is now throttling IO.
132+ Checks added in megasas_queue_command to know if FW is able to
133+ process commands within timeout period. If number of retries
134+ is 2 or greater,the driver stops sending cmd to FW temporarily. IO is
135+ resumed if pending cmd count reduces to 16 or 5 seconds has elapsed
136+ from the time cmds were last sent to FW.
137+
138+ii. FW enables WCE bit in Mode Sense cmd for drives that are configured
139+ as WriteBack. The OS may send "SYNCHRONIZE_CACHE" cmd when Logical
140+ Disks are exposed with WCE=1. User is advised to enable Write Back
141+ mode only when the controller has battery backup. At this time
142+ Synhronize cache is not supported by the FW. Driver will short-cycle
143+ the cmd and return sucess without sending down to FW.
144+
145+1 Release Date : Sun Jan. 14 11:21:32 PDT 2007 -
146+ Sumant Patro <Sumant.Patro@lsil.com>/Bo Yang
147+2 Current Version : 00.00.03.07
148+3 Older Version : 00.00.03.06
149+
150+i. bios_param entry added in scsi_host_template that returns disk geometry
151+ information.
152+
153+1 Release Date : Fri Oct 20 11:21:32 PDT 2006 - Sumant Patro <Sumant.Patro@lsil.com>/Bo Yang
154+2 Current Version : 00.00.03.06
155+3 Older Version : 00.00.03.05
156+
157+1. Added new memory management module to support the IOCTL memory allocation. For IOCTL we try to allocate from the memory pool created during driver initialization. If mem pool is empty then we allocate at run time.
158+2. Added check in megasas_queue_command and dpc/isr routine to see if we have already declared adapter dead
159+ (hw_crit_error=1). If hw_crit_error==1, now we donot accept any processing of pending cmds/accept any cmd from OS
1160
2161 1 Release Date : Mon Oct 02 11:21:32 PDT 2006 - Sumant Patro <Sumant.Patro@lsil.com>
3162 2 Current Version : 00.00.03.05
Documentation/scsi/aacraid.txt+4−0
@@ -56,6 +56,10 @@ Supported Cards/Chipsets · 55 unmodified lines
5656 9005:0285:9005:02d1 Adaptec 5405 (Voodoo40)
5757 9005:0285:15d9:02d2 SMC AOC-USAS-S8i-LP
5858 9005:0285:15d9:02d3 SMC AOC-USAS-S8iR-LP
59+ 9005:0285:9005:02d4 Adaptec 2045 (Voodoo04 Lite)
60+ 9005:0285:9005:02d5 Adaptec 2405 (Voodoo40 Lite)
61+ 9005:0285:9005:02d6 Adaptec 2445 (Voodoo44 Lite)
62+ 9005:0285:9005:02d7 Adaptec 2805 (Voodoo80 Lite)
5963 1011:0046:9005:0364 Adaptec 5400S (Mustang)
6064 9005:0287:9005:0800 Adaptec Themisto (Jupiter)
6165 9005:0200:9005:0200 Adaptec Themisto (Jupiter)
Documentation/scsi/hptiop.txt+21−9
@@ -1,9 +1,9 @@
1−HIGHPOINT ROCKETRAID 3xxx RAID DRIVER (hptiop)
1+HIGHPOINT ROCKETRAID 3xxx/4xxx ADAPTER DRIVER (hptiop)
22
33 Controller Register Map
44 -------------------------
55
6−The controller IOP is accessed via PCI BAR0.
6+For Intel IOP based adapters, the controller IOP is accessed via PCI BAR0:
77
88 BAR0 offset Register
99 0x10 Inbound Message Register 0
@@ -18,6 +18,24 @@ The controller IOP is accessed via PCI BAR0. · 8 unmodified lines
1818 0x40 Inbound Queue Port
1919 0x44 Outbound Queue Port
2020
21+For Marvell IOP based adapters, the IOP is accessed via PCI BAR0 and BAR1:
22+
23+ BAR0 offset Register
24+ 0x20400 Inbound Doorbell Register
25+ 0x20404 Inbound Interrupt Mask Register
26+ 0x20408 Outbound Doorbell Register
27+ 0x2040C Outbound Interrupt Mask Register
28+
29+ BAR1 offset Register
30+ 0x0 Inbound Queue Head Pointer
31+ 0x4 Inbound Queue Tail Pointer
32+ 0x8 Outbound Queue Head Pointer
33+ 0xC Outbound Queue Tail Pointer
34+ 0x10 Inbound Message Register
35+ 0x14 Outbound Message Register
36+ 0x40-0x1040 Inbound Queue
37+ 0x1040-0x2040 Outbound Queue
38+
2139
2240 I/O Request Workflow
2341 ----------------------
@@ -73,15 +91,9 @@ The driver exposes following sysfs attributes: · 49 unmodified lines
7391 driver-version R driver version string
7492 firmware-version R firmware version string
7593
76−The driver registers char device "hptiop" to communicate with HighPoint RAID
77−management software. Its ioctl routine acts as a general binary interface
78−between the IOP firmware and HighPoint RAID management software. New management
79−functions can be implemented in application/firmware without modification
80−in driver code.
81−
8294
8395 -----------------------------------------------------------------------------
84−Copyright (C) 2006 HighPoint Technologies, Inc. All Rights Reserved.
96+Copyright (C) 2006-2007 HighPoint Technologies, Inc. All Rights Reserved.
8597
8698 This file is distributed in the hope that it will be useful,
8799 but WITHOUT ANY WARRANTY; without even the implied warranty of
Documentation/scsi/ncr53c7xx.txt+0−40
@@ -1,40 +0,0 @@
1−README for WarpEngine/A4000T/A4091 SCSI kernels.
2−
3−Use the following options to disable options in the SCSI driver.
4−
5−Using amiboot for example.....
6−
7−To disable Synchronous Negotiation....
8−
9− amiboot -k kernel 53c7xx=nosync:0
10−
11−To disable Disconnection....
12−
13− amiboot -k kernel 53c7xx=nodisconnect:0
14−
15−To disable certain SCSI devices...
16−
17− amiboot -k kernel 53c7xx=validids:0x3F
18−
19− this allows only device ID's 0,1,2,3,4 and 5 for linux to handle.
20− (this is a bitmasked field - i.e. each bit represents a SCSI ID)
21−
22−These commands work on a per controller basis and use the option 'next' to
23−move to the next controller in the system.
24−
25−e.g.
26− amiboot -k kernel 53c7xx=nodisconnect:0,next,nosync:0
27−
28− this uses No Disconnection on the first controller and Asynchronous
29− SCSI on the second controller.
30−
31−Known Issues:
32−
33−Two devices are known not to function with the default settings of using
34−synchronous SCSI. These are the Archive Viper 150 Tape Drive and the
35−SyQuest SQ555 removeable hard drive. When using these devices on a controller
36−use the 'nosync:0' option.
37−
38−Please try these options and post any problems/successes to me.
39−
40−Alan Hourihane <alanh@fairlite.demon.co.uk>
MAINTAINERS+4−2
@@ -3269,8 +3269,10 @@ W: http://www.ibm.com/developerworks/linux/linux390/ · 3268 unmodified lines
32693269 S: Supported
32703270
32713271 S390 ZFCP DRIVER
3272−P: Swen Schillig
3273−M: swen@vnet.ibm.com
3272+P: Christof Schmitt
3273+M: christof.schmitt@de.ibm.com
3274+P: Martin Peschke
3275+M: mp3@de.ibm.com
32743276 M: linux390@de.ibm.com
32753277 L: linux-s390@vger.kernel.org
32763278 W: http://www.ibm.com/developerworks/linux/linux390/
block/bsg.c+12−2
@@ -445,6 +445,15 @@ static int blk_complete_sgv4_hdr_rq(struct request *rq, struct sg_io_v4 *hdr, · 444 unmodified lines
445445 else
446446 hdr->dout_resid = rq->data_len;
447447
448+ /*
449+ * If the request generated a negative error number, return it
450+ * (providing we aren't already returning an error); if it's
451+ * just a protocol response (i.e. non negative), that gets
452+ * processed above.
453+ */
454+ if (!ret && rq->errors < 0)
455+ ret = rq->errors;
456+
448457 blk_rq_unmap_user(bio);
449458 blk_put_request(rq);
450459
@@ -837,6 +846,7 @@ static long bsg_ioctl(struct file *file, unsigned int cmd, unsigned long arg) · 386 unmodified lines
837846 {
838847 struct bsg_device *bd = file->private_data;
839848 int __user *uarg = (int __user *) arg;
849+ int ret;
840850
841851 switch (cmd) {
842852 /*
@@ -889,12 +899,12 @@ static long bsg_ioctl(struct file *file, unsigned int cmd, unsigned long arg) · 46 unmodified lines
889899 if (rq->next_rq)
890900 bidi_bio = rq->next_rq->bio;
891901 blk_execute_rq(bd->queue, NULL, rq, 0);
892− blk_complete_sgv4_hdr_rq(rq, &hdr, bio, bidi_bio);
902+ ret = blk_complete_sgv4_hdr_rq(rq, &hdr, bio, bidi_bio);
893903
894904 if (copy_to_user(uarg, &hdr, sizeof(hdr)))
895905 return -EFAULT;
896906
897− return 0;
907+ return ret;
898908 }
899909 /*
900910 * block device ioctls
block/ll_rw_blk.c+24−0
@@ -759,6 +759,30 @@ void blk_queue_dma_alignment(struct request_queue *q, int mask) · 758 unmodified lines
759759
760760 EXPORT_SYMBOL(blk_queue_dma_alignment);
761761
762+/**
763+ * blk_queue_update_dma_alignment - update dma length and memory alignment
764+ * @q: the request queue for the device
765+ * @mask: alignment mask
766+ *
767+ * description:
768+ * update required memory and length aligment for direct dma transactions.
769+ * If the requested alignment is larger than the current alignment, then
770+ * the current queue alignment is updated to the new value, otherwise it
771+ * is left alone. The design of this is to allow multiple objects
772+ * (driver, device, transport etc) to set their respective
773+ * alignments without having them interfere.
774+ *
775+ **/
776+void blk_queue_update_dma_alignment(struct request_queue *q, int mask)
777+{
778+ BUG_ON(mask > PAGE_SIZE);
779+
780+ if (mask > q->dma_alignment)
781+ q->dma_alignment = mask;
782+}
783+
784+EXPORT_SYMBOL(blk_queue_update_dma_alignment);
785+
762786 /**
763787 * blk_queue_find_tag - find a request by its tag and queue
764788 * @q: The request queue for the device
drivers/ata/libata-scsi.c+9−2
@@ -839,7 +839,14 @@ static void ata_scsi_dev_config(struct scsi_device *sdev, · 838 unmodified lines
839839 if (dev->class == ATA_DEV_ATAPI) {
840840 struct request_queue *q = sdev->request_queue;
841841 blk_queue_max_hw_segments(q, q->max_hw_segments - 1);
842− }
842+
843+ /* set the min alignment */
844+ blk_queue_update_dma_alignment(sdev->request_queue,
845+ ATA_DMA_PAD_SZ - 1);
846+ } else
847+ /* ATA devices must be sector aligned */
848+ blk_queue_update_dma_alignment(sdev->request_queue,
849+ ATA_SECT_SIZE - 1);
843850
844851 if (dev->class == ATA_DEV_ATA)
845852 sdev->manage_start_stop = 1;
@@ -878,7 +885,7 @@ int ata_scsi_slave_config(struct scsi_device *sdev) · 32 unmodified lines
878885 if (dev)
879886 ata_scsi_dev_config(sdev, dev);
880887
881− return 0; /* scsi layer doesn't check return value, sigh */
888+ return 0;
882889 }
883890
884891 /**
drivers/base/attribute_container.c+12−2
@@ -320,9 +320,14 @@ attribute_container_add_attrs(struct class_device *classdev) · 319 unmodified lines
320320 struct class_device_attribute **attrs = cont->attrs;
321321 int i, error;
322322
323− if (!attrs)
323+ BUG_ON(attrs && cont->grp);
324+
325+ if (!attrs && !cont->grp)
324326 return 0;
325327
328+ if (cont->grp)
329+ return sysfs_create_group(&classdev->kobj, cont->grp);
330+
326331 for (i = 0; attrs[i]; i++) {
327332 error = class_device_create_file(classdev, attrs[i]);
328333 if (error)
@@ -378,9 +383,14 @@ attribute_container_remove_attrs(struct class_device *classdev) · 49 unmodified lines
378383 struct class_device_attribute **attrs = cont->attrs;
379384 int i;
380385
381− if (!attrs)
386+ if (!attrs && !cont->grp)
382387 return;
383388
389+ if (cont->grp) {
390+ sysfs_remove_group(&classdev->kobj, cont->grp);
391+ return ;
392+ }
393+
384394 for (i = 0; attrs[i]; i++)
385395 class_device_remove_file(classdev, attrs[i]);
386396 }
drivers/firewire/fw-sbp2.c+6−0
@@ -1238,6 +1238,12 @@ static int sbp2_scsi_slave_alloc(struct scsi_device *sdev) · 1237 unmodified lines
12381238
12391239 sdev->allow_restart = 1;
12401240
1241+ /*
1242+ * Update the dma alignment (minimum alignment requirements for
1243+ * start and end of DMA transfers) to be a sector
1244+ */
1245+ blk_queue_update_dma_alignment(sdev->request_queue, 511);
1246+
12411247 if (lu->tgt->workarounds & SBP2_WORKAROUND_INQUIRY_36)
12421248 sdev->inquiry_len = 36;
12431249
drivers/ieee1394/sbp2.c+6−0
@@ -1963,6 +1963,12 @@ static int sbp2scsi_slave_alloc(struct scsi_device *sdev) · 1962 unmodified lines
19631963 lu->sdev = sdev;
19641964 sdev->allow_restart = 1;
19651965
1966+ /*
1967+ * Update the dma alignment (minimum alignment requirements for
1968+ * start and end of DMA transfers) to be a sector
1969+ */
1970+ blk_queue_update_dma_alignment(sdev->request_queue, 511);
1971+
19661972 if (lu->workarounds & SBP2_WORKAROUND_INQUIRY_36)
19671973 sdev->inquiry_len = 36;
19681974 return 0;
drivers/infiniband/ulp/iser/iscsi_iser.c+7−8
@@ -129,7 +129,7 @@ error: · 128 unmodified lines
129129 * iscsi_iser_cmd_init - Initialize iSCSI SCSI_READ or SCSI_WRITE commands
130130 *
131131 **/
132−static void
132+static int
133133 iscsi_iser_cmd_init(struct iscsi_cmd_task *ctask)
134134 {
135135 struct iscsi_iser_conn *iser_conn = ctask->conn->dd_data;
@@ -138,6 +138,7 @@ iscsi_iser_cmd_init(struct iscsi_cmd_task *ctask) · 2 unmodified lines
138138 iser_ctask->command_sent = 0;
139139 iser_ctask->iser_conn = iser_conn;
140140 iser_ctask_rdma_init(iser_ctask);
141+ return 0;
141142 }
142143
143144 /**
@@ -220,12 +221,6 @@ iscsi_iser_ctask_xmit(struct iscsi_conn *conn, · 76 unmodified lines
220221 debug_scsi("ctask deq [cid %d itt 0x%x]\n",
221222 conn->id, ctask->itt);
222223
223− /*
224− * serialize with TMF AbortTask
225− */
226− if (ctask->mtask)
227− return error;
228−
229224 /* Send the cmd PDU */
230225 if (!iser_ctask->command_sent) {
231226 error = iser_send_command(conn, ctask);
@@ -406,6 +401,7 @@ iscsi_iser_session_create(struct iscsi_transport *iscsit, · 174 unmodified lines
406401 ctask = session->cmds[i];
407402 iser_ctask = ctask->dd_data;
408403 ctask->hdr = (struct iscsi_cmd *)&iser_ctask->desc.iscsi_header;
404+ ctask->hdr_max = sizeof(iser_ctask->desc.iscsi_header);
409405 }
410406
411407 for (i = 0; i < session->mgmtpool_max; i++) {
@@ -557,6 +553,7 @@ static struct scsi_host_template iscsi_iser_sht = { · 145 unmodified lines
557553 .max_sectors = 1024,
558554 .cmd_per_lun = ISCSI_MAX_CMD_PER_LUN,
559555 .eh_abort_handler = iscsi_eh_abort,
556+ .eh_device_reset_handler= iscsi_eh_device_reset,
560557 .eh_host_reset_handler = iscsi_eh_host_reset,
561558 .use_clustering = DISABLE_CLUSTERING,
562559 .proc_name = "iscsi_iser",
@@ -583,7 +580,9 @@ static struct iscsi_transport iscsi_iser_transport = { · 20 unmodified lines
583580 ISCSI_PERSISTENT_ADDRESS |
584581 ISCSI_TARGET_NAME | ISCSI_TPGT |
585582 ISCSI_USERNAME | ISCSI_PASSWORD |
586− ISCSI_USERNAME_IN | ISCSI_PASSWORD_IN,
583+ ISCSI_USERNAME_IN | ISCSI_PASSWORD_IN |
584+ ISCSI_FAST_ABORT | ISCSI_ABORT_TMO |
585+ ISCSI_PING_TMO | ISCSI_RECV_TMO,
587586 .host_param_mask = ISCSI_HOST_HWADDRESS |
588587 ISCSI_HOST_NETDEV_NAME |
589588 ISCSI_HOST_INITIATOR_NAME,
drivers/infiniband/ulp/iser/iser_initiator.c+1−3
@@ -621,9 +621,7 @@ void iser_snd_completion(struct iser_desc *tx_desc) · 620 unmodified lines
621621 struct iscsi_session *session = conn->session;
622622
623623 spin_lock(&conn->session->lock);
624− list_del(&mtask->running);
625− __kfifo_put(session->mgmtpool.queue, (void*)&mtask,
626− sizeof(void*));
624+ iscsi_free_mgmt_task(conn, mtask);
627625 spin_unlock(&session->lock);
628626 }
629627 }
drivers/message/fusion/mptbase.c+52−42
@@ -2056,7 +2056,7 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag) · 2055 unmodified lines
20562056 ddlprintk(ioc, printk(MYIOC_s_DEBUG_FMT
20572057 "mpt_upload: alt_%s has cached_fw=%p \n",
20582058 ioc->name, ioc->alt_ioc->name, ioc->alt_ioc->cached_fw));
2059− ioc->alt_ioc->cached_fw = NULL;
2059+ ioc->cached_fw = NULL;
20602060 }
20612061 } else {
20622062 printk(MYIOC_s_WARN_FMT
@@ -2262,10 +2262,12 @@ mpt_adapter_disable(MPT_ADAPTER *ioc) · 199 unmodified lines
22622262 int ret;
22632263
22642264 if (ioc->cached_fw != NULL) {
2265− ddlprintk(ioc, printk(MYIOC_s_INFO_FMT
2266− "mpt_adapter_disable: Pushing FW onto adapter\n", ioc->name));
2267− if ((ret = mpt_downloadboot(ioc, (MpiFwHeader_t *)ioc->cached_fw, NO_SLEEP)) < 0) {
2268− printk(MYIOC_s_WARN_FMT "firmware downloadboot failure (%d)!\n",
2265+ ddlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "%s: Pushing FW onto "
2266+ "adapter\n", __FUNCTION__, ioc->name));
2267+ if ((ret = mpt_downloadboot(ioc, (MpiFwHeader_t *)
2268+ ioc->cached_fw, CAN_SLEEP)) < 0) {
2269+ printk(MYIOC_s_WARN_FMT
2270+ ": firmware downloadboot failure (%d)!\n",
22692271 ioc->name, ret);
22702272 }
22712273 }
@@ -2303,13 +2305,7 @@ mpt_adapter_disable(MPT_ADAPTER *ioc) · 31 unmodified lines
23032305 ioc->alloc_total -= sz;
23042306 }
23052307
2306− if (ioc->cached_fw != NULL) {
2307− sz = ioc->facts.FWImageSize;
2308− pci_free_consistent(ioc->pcidev, sz,
2309− ioc->cached_fw, ioc->cached_fw_dma);
2310− ioc->cached_fw = NULL;
2311− ioc->alloc_total -= sz;
2312− }
2308+ mpt_free_fw_memory(ioc);
23132309
23142310 kfree(ioc->spi_data.nvram);
23152311 mpt_inactive_raid_list_free(ioc);
@@ -3047,44 +3043,62 @@ SendPortEnable(MPT_ADAPTER *ioc, int portnum, int sleepFlag) · 731 unmodified lines
30473043 *
30483044 * If memory has already been allocated, the same (cached) value
30493045 * is returned.
3050− */
3051−void
3046+ *
3047+ * Return 0 if successfull, or non-zero for failure
3048+ **/
3049+int
30523050 mpt_alloc_fw_memory(MPT_ADAPTER *ioc, int size)
30533051 {
3054− if (ioc->cached_fw)
3055− return; /* use already allocated memory */
3056− if (ioc->alt_ioc && ioc->alt_ioc->cached_fw) {
3052+ int rc;
3053+
3054+ if (ioc->cached_fw) {
3055+ rc = 0; /* use already allocated memory */
3056+ goto out;
3057+ }
3058+ else if (ioc->alt_ioc && ioc->alt_ioc->cached_fw) {
30573059 ioc->cached_fw = ioc->alt_ioc->cached_fw; /* use alt_ioc's memory */
30583060 ioc->cached_fw_dma = ioc->alt_ioc->cached_fw_dma;
3059− ioc->alloc_total += size;
3060− ioc->alt_ioc->alloc_total -= size;
3061+ rc = 0;
3062+ goto out;
3063+ }
3064+ ioc->cached_fw = pci_alloc_consistent(ioc->pcidev, size, &ioc->cached_fw_dma);
3065+ if (!ioc->cached_fw) {
3066+ printk(MYIOC_s_ERR_FMT "Unable to allocate memory for the cached firmware image!\n",
3067+ ioc->name);
3068+ rc = -1;
30613069 } else {
3062− if ( (ioc->cached_fw = pci_alloc_consistent(ioc->pcidev, size, &ioc->cached_fw_dma) ) )
3063− ioc->alloc_total += size;
3070+ dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "FW Image @ %p[%p], sz=%d[%x] bytes\n",
3071+ ioc->name, ioc->cached_fw, (void *)(ulong)ioc->cached_fw_dma, size, size));
3072+ ioc->alloc_total += size;
3073+ rc = 0;
30643074 }
3075+ out:
3076+ return rc;
30653077 }
3078+
30663079 /**
30673080 * mpt_free_fw_memory - free firmware memory
30683081 * @ioc: Pointer to MPT_ADAPTER structure
30693082 *
30703083 * If alt_img is NULL, delete from ioc structure.
30713084 * Else, delete a secondary image in same format.
3072− */
3085+ **/
30733086 void
30743087 mpt_free_fw_memory(MPT_ADAPTER *ioc)
30753088 {
30763089 int sz;
30773090
3091+ if (!ioc->cached_fw)
3092+ return;
3093+
30783094 sz = ioc->facts.FWImageSize;
3079− dinitprintk(ioc, printk(MYIOC_s_INFO_FMT "free_fw_memory: FW Image @ %p[%p], sz=%d[%x] bytes\n",
3080− ioc->name, ioc->cached_fw, (void *)(ulong)ioc->cached_fw_dma, sz, sz));
3095+ dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "free_fw_memory: FW Image @ %p[%p], sz=%d[%x] bytes\n",
3096+ ioc->name, ioc->cached_fw, (void *)(ulong)ioc->cached_fw_dma, sz, sz));
30813097 pci_free_consistent(ioc->pcidev, sz, ioc->cached_fw, ioc->cached_fw_dma);
3098+ ioc->alloc_total -= sz;
30823099 ioc->cached_fw = NULL;
3083−
3084− return;
30853100 }
30863101
3087−
30883102 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
30893103 /**
30903104 * mpt_do_upload - Construct and Send FWUpload request to MPT adapter port.
@@ -3116,17 +3130,12 @@ mpt_do_upload(MPT_ADAPTER *ioc, int sleepFlag) · 25 unmodified lines
31163130 if ((sz = ioc->facts.FWImageSize) == 0)
31173131 return 0;
31183132
3119− mpt_alloc_fw_memory(ioc, sz);
3133+ if (mpt_alloc_fw_memory(ioc, ioc->facts.FWImageSize) != 0)
3134+ return -ENOMEM;
31203135
31213136 dinitprintk(ioc, printk(MYIOC_s_INFO_FMT ": FW Image @ %p[%p], sz=%d[%x] bytes\n",
31223137 ioc->name, ioc->cached_fw, (void *)(ulong)ioc->cached_fw_dma, sz, sz));
31233138
3124− if (ioc->cached_fw == NULL) {
3125− /* Major Failure.
3126− */
3127− return -ENOMEM;
3128− }
3129−
31303139 prequest = (sleepFlag == NO_SLEEP) ? kzalloc(ioc->req_sz, GFP_ATOMIC) :
31313140 kzalloc(ioc->req_sz, GFP_KERNEL);
31323141 if (!prequest) {
@@ -3498,12 +3507,12 @@ KickStart(MPT_ADAPTER *ioc, int force, int sleepFlag) · 365 unmodified lines
34983507 static int
34993508 mpt_diag_reset(MPT_ADAPTER *ioc, int ignore, int sleepFlag)
35003509 {
3501− MPT_ADAPTER *iocp=NULL;
35023510 u32 diag0val;
35033511 u32 doorbell;
35043512 int hard_reset_done = 0;
35053513 int count = 0;
35063514 u32 diag1val = 0;
3515+ MpiFwHeader_t *cached_fw; /* Pointer to FW */
35073516
35083517 /* Clear any existing interrupts */
35093518 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0);
@@ -3635,22 +3644,24 @@ mpt_diag_reset(MPT_ADAPTER *ioc, int ignore, int sleepFlag) · 125 unmodified lines
36353644 }
36363645
36373646 if (ioc->cached_fw)
3638− iocp = ioc;
3647+ cached_fw = (MpiFwHeader_t *)ioc->cached_fw;
36393648 else if (ioc->alt_ioc && ioc->alt_ioc->cached_fw)
3640− iocp = ioc->alt_ioc;
3641− if (iocp) {
3649+ cached_fw = (MpiFwHeader_t *)ioc->alt_ioc->cached_fw;
3650+ else
3651+ cached_fw = NULL;
3652+ if (cached_fw) {
36423653 /* If the DownloadBoot operation fails, the
36433654 * IOC will be left unusable. This is a fatal error
36443655 * case. _diag_reset will return < 0
36453656 */
36463657 for (count = 0; count < 30; count ++) {
3647− diag0val = CHIPREG_READ32(&iocp->chip->Diagnostic);
3658+ diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic);
36483659 if (!(diag0val & MPI_DIAG_RESET_ADAPTER)) {
36493660 break;
36503661 }
36513662
36523663 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT "cached_fw: diag0val=%x count=%d\n",
3653− iocp->name, diag0val, count));
3664+ ioc->name, diag0val, count));
36543665 /* wait 1 sec */
36553666 if (sleepFlag == CAN_SLEEP) {
36563667 msleep (1000);
@@ -3658,8 +3669,7 @@ mpt_diag_reset(MPT_ADAPTER *ioc, int ignore, int sleepFlag) · 1 unmodified line
36583669 mdelay (1000);
36593670 }
36603671 }
3661− if ((count = mpt_downloadboot(ioc,
3662− (MpiFwHeader_t *)iocp->cached_fw, sleepFlag)) < 0) {
3672+ if ((count = mpt_downloadboot(ioc, cached_fw, sleepFlag)) < 0) {
36633673 printk(MYIOC_s_WARN_FMT
36643674 "firmware downloadboot failure (%d)!\n", ioc->name, count);
36653675 }
drivers/message/fusion/mptbase.h+1−1
@@ -907,7 +907,7 @@ extern u32 mpt_GetIocState(MPT_ADAPTER *ioc, int cooked); · 906 unmodified lines
907907 extern void mpt_print_ioc_summary(MPT_ADAPTER *ioc, char *buf, int *size, int len, int showlan);
908908 extern int mpt_HardResetHandler(MPT_ADAPTER *ioc, int sleepFlag);
909909 extern int mpt_config(MPT_ADAPTER *ioc, CONFIGPARMS *cfg);
910−extern void mpt_alloc_fw_memory(MPT_ADAPTER *ioc, int size);
910+extern int mpt_alloc_fw_memory(MPT_ADAPTER *ioc, int size);
911911 extern void mpt_free_fw_memory(MPT_ADAPTER *ioc);
912912 extern int mpt_findImVolumes(MPT_ADAPTER *ioc);
913913 extern int mptbase_sas_persist_operation(MPT_ADAPTER *ioc, u8 persist_opcode);
drivers/message/fusion/mptsas.c+2−0
@@ -1343,6 +1343,8 @@ static int mptsas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy, · 1342 unmodified lines
13431343 smprep = (SmpPassthroughReply_t *)ioc->sas_mgmt.reply;
13441344 memcpy(req->sense, smprep, sizeof(*smprep));
13451345 req->sense_len = sizeof(*smprep);
1346+ req->data_len = 0;
1347+ rsp->data_len -= smprep->ResponseDataLength;
13461348 } else {
13471349 printk(MYIOC_s_ERR_FMT "%s: smp passthru reply failed to be returned\n",
13481350 ioc->name, __FUNCTION__);
drivers/message/fusion/mptscsih.c+1−1
@@ -111,7 +111,7 @@ int mptscsih_suspend(struct pci_dev *pdev, pm_message_t state); · 110 unmodified lines
111111 int mptscsih_resume(struct pci_dev *pdev);
112112 #endif
113113
114−#define SNS_LEN(scp) sizeof((scp)->sense_buffer)
114+#define SNS_LEN(scp) SCSI_SENSE_BUFFERSIZE
115115
116116 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
117117 /**
drivers/message/i2o/i2o_scsi.c+1−1
@@ -370,7 +370,7 @@ static int i2o_scsi_reply(struct i2o_controller *c, u32 m, · 369 unmodified lines
370370 */
371371 if (cmd->result)
372372 memcpy(cmd->sense_buffer, &msg->body[3],
373− min(sizeof(cmd->sense_buffer), (size_t) 40));
373+ min(SCSI_SENSE_BUFFERSIZE, 40));
374374
375375 /* only output error code if AdapterStatus is not HBA_SUCCESS */
376376 if ((error >> 8) & 0xff)
drivers/s390/scsi/zfcp_aux.c+0−2
@@ -844,8 +844,6 @@ zfcp_unit_enqueue(struct zfcp_port *port, fcp_lun_t fcp_lun) · 843 unmodified lines
844844 unit->sysfs_device.release = zfcp_sysfs_unit_release;
845845 dev_set_drvdata(&unit->sysfs_device, unit);
846846
847− init_waitqueue_head(&unit->scsi_scan_wq);
848−
849847 /* mark unit unusable as long as sysfs registration is not complete */
850848 atomic_set_mask(ZFCP_STATUS_COMMON_REMOVE, &unit->status);
851849
drivers/s390/scsi/zfcp_ccw.c+3−0
@@ -123,6 +123,9 @@ zfcp_ccw_remove(struct ccw_device *ccw_device) · 122 unmodified lines
123123
124124 list_for_each_entry_safe(port, p, &adapter->port_remove_lh, list) {
125125 list_for_each_entry_safe(unit, u, &port->unit_remove_lh, list) {
126+ if (atomic_test_mask(ZFCP_STATUS_UNIT_REGISTERED,
127+ &unit->status))
128+ scsi_remove_device(unit->device);
126129 zfcp_unit_dequeue(unit);
127130 }
128131 zfcp_port_dequeue(port);
drivers/s390/scsi/zfcp_dbf.c+0−6
@@ -161,12 +161,6 @@ void zfcp_hba_dbf_event_fsf_response(struct zfcp_fsf_req *fsf_req) · 160 unmodified lines
161161 (fsf_req->fsf_command == FSF_QTCB_OPEN_LUN)) {
162162 strncpy(rec->tag2, "open", ZFCP_DBF_TAG_SIZE);
163163 level = 4;
164− } else if ((prot_status_qual->doubleword[0] != 0) ||
165− (prot_status_qual->doubleword[1] != 0) ||
166− (fsf_status_qual->doubleword[0] != 0) ||
167− (fsf_status_qual->doubleword[1] != 0)) {
168− strncpy(rec->tag2, "qual", ZFCP_DBF_TAG_SIZE);
169− level = 3;
170164 } else {
171165 strncpy(rec->tag2, "norm", ZFCP_DBF_TAG_SIZE);
172166 level = 6;
drivers/s390/scsi/zfcp_def.h+16−6
@@ -118,7 +118,7 @@ zfcp_address_to_sg(void *address, struct scatterlist *list, unsigned int size) · 117 unmodified lines
118118
119119 #define ZFCP_SBAL_TIMEOUT (5*HZ)
120120
121−#define ZFCP_TYPE2_RECOVERY_TIME (8*HZ)
121+#define ZFCP_TYPE2_RECOVERY_TIME 8 /* seconds */
122122
123123 /* queue polling (values in microseconds) */
124124 #define ZFCP_MAX_INPUT_THRESHOLD 5000 /* FIXME: tune */
@@ -139,7 +139,7 @@ zfcp_address_to_sg(void *address, struct scatterlist *list, unsigned int size) · 14 unmodified lines
139139 #define ZFCP_STATUS_READS_RECOM FSF_STATUS_READS_RECOM
140140
141141 /* Do 1st retry in 1 second, then double the timeout for each following retry */
142−#define ZFCP_EXCHANGE_CONFIG_DATA_FIRST_SLEEP 100
142+#define ZFCP_EXCHANGE_CONFIG_DATA_FIRST_SLEEP 1
143143 #define ZFCP_EXCHANGE_CONFIG_DATA_RETRIES 7
144144
145145 /* timeout value for "default timer" for fsf requests */
@@ -983,10 +983,6 @@ struct zfcp_unit { · 837 unmodified lines
983983 struct scsi_device *device; /* scsi device struct pointer */
984984 struct zfcp_erp_action erp_action; /* pending error recovery */
985985 atomic_t erp_counter;
986− wait_queue_head_t scsi_scan_wq; /* can be used to wait until
987− all scsi_scan_target
988− requests have been
989− completed. */
990986 };
991987
992988 /* FSF request */
@@ -1127,6 +1123,20 @@ zfcp_reqlist_find(struct zfcp_adapter *adapter, unsigned long req_id) · 134 unmodified lines
11271123 return NULL;
11281124 }
11291125
1126+static inline struct zfcp_fsf_req *
1127+zfcp_reqlist_find_safe(struct zfcp_adapter *adapter, struct zfcp_fsf_req *req)
1128+{
1129+ struct zfcp_fsf_req *request;
1130+ unsigned int idx;
1131+
1132+ for (idx = 0; idx < REQUEST_LIST_SIZE; idx++) {
1133+ list_for_each_entry(request, &adapter->req_list[idx], list)
1134+ if (request == req)
1135+ return request;
1136+ }
1137+ return NULL;
1138+}
1139+
11301140 /*
11311141 * functions needed for reference/usage counting
11321142 */
drivers/s390/scsi/zfcp_erp.c+7−7
@@ -131,7 +131,7 @@ static void zfcp_close_qdio(struct zfcp_adapter *adapter) · 130 unmodified lines
131131 debug_text_event(adapter->erp_dbf, 3, "qdio_down2a");
132132 while (qdio_shutdown(adapter->ccw_device,
133133 QDIO_FLAG_CLEANUP_USING_CLEAR) == -EINPROGRESS)
134− msleep(1000);
134+ ssleep(1);
135135 debug_text_event(adapter->erp_dbf, 3, "qdio_down2b");
136136
137137 /* cleanup used outbound sbals */
@@ -456,7 +456,7 @@ zfcp_test_link(struct zfcp_port *port) · 318 unmodified lines
456456
457457 zfcp_port_get(port);
458458 retval = zfcp_erp_adisc(port);
459− if (retval != 0) {
459+ if (retval != 0 && retval != -EBUSY) {
460460 zfcp_port_put(port);
461461 ZFCP_LOG_NORMAL("reopen needed for port 0x%016Lx "
462462 "on adapter %s\n ", port->wwpn,
@@ -846,7 +846,8 @@ zfcp_erp_strategy_check_fsfreq(struct zfcp_erp_action *erp_action) · 383 unmodified lines
846846 if (erp_action->fsf_req) {
847847 /* take lock to ensure that request is not deleted meanwhile */
848848 spin_lock(&adapter->req_list_lock);
849− if (zfcp_reqlist_find(adapter, erp_action->fsf_req->req_id)) {
849+ if (zfcp_reqlist_find_safe(adapter, erp_action->fsf_req) &&
850+ erp_action->fsf_req->erp_action == erp_action) {
850851 /* fsf_req still exists */
851852 debug_text_event(adapter->erp_dbf, 3, "a_ca_req");
852853 debug_event(adapter->erp_dbf, 3, &erp_action->fsf_req,
@@ -1609,7 +1610,6 @@ static void zfcp_erp_scsi_scan(struct work_struct *work) · 756 unmodified lines
16091610 scsi_scan_target(&rport->dev, 0, rport->scsi_target_id,
16101611 unit->scsi_lun, 0);
16111612 atomic_clear_mask(ZFCP_STATUS_UNIT_SCSI_WORK_PENDING, &unit->status);
1612− wake_up(&unit->scsi_scan_wq);
16131613 zfcp_unit_put(unit);
16141614 kfree(p);
16151615 }
@@ -1900,7 +1900,7 @@ zfcp_erp_adapter_strategy(struct zfcp_erp_action *erp_action) · 284 unmodified lines
19001900 ZFCP_LOG_INFO("Waiting to allow the adapter %s "
19011901 "to recover itself\n",
19021902 zfcp_get_busid_by_adapter(adapter));
1903− msleep(jiffies_to_msecs(ZFCP_TYPE2_RECOVERY_TIME));
1903+ ssleep(ZFCP_TYPE2_RECOVERY_TIME);
19041904 }
19051905
19061906 return retval;
@@ -2080,7 +2080,7 @@ zfcp_erp_adapter_strategy_open_qdio(struct zfcp_erp_action *erp_action) · 173 unmodified lines
20802080 debug_text_event(adapter->erp_dbf, 3, "qdio_down1a");
20812081 while (qdio_shutdown(adapter->ccw_device,
20822082 QDIO_FLAG_CLEANUP_USING_CLEAR) == -EINPROGRESS)
2083− msleep(1000);
2083+ ssleep(1);
20842084 debug_text_event(adapter->erp_dbf, 3, "qdio_down1b");
20852085
20862086 failed_qdio_establish:
@@ -2165,7 +2165,7 @@ zfcp_erp_adapter_strategy_open_fsf_xconfig(struct zfcp_erp_action *erp_action) · 78 unmodified lines
21652165 ZFCP_LOG_DEBUG("host connection still initialising... "
21662166 "waiting and retrying...\n");
21672167 /* sleep a little bit before retry */
2168− msleep(jiffies_to_msecs(sleep));
2168+ ssleep(sleep);
21692169 sleep *= 2;
21702170 }
21712171
drivers/s390/scsi/zfcp_fsf.c+35−35
@@ -1116,6 +1116,10 @@ zfcp_fsf_abort_fcp_command(unsigned long old_req_id, · 1115 unmodified lines
11161116 goto out;
11171117 }
11181118
1119+ if (unlikely(!atomic_test_mask(ZFCP_STATUS_COMMON_UNBLOCKED,
1120+ &unit->status)))
1121+ goto unit_blocked;
1122+
11191123 sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
11201124 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
11211125 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
@@ -1131,22 +1135,13 @@ zfcp_fsf_abort_fcp_command(unsigned long old_req_id, · 9 unmodified lines
11311135
11321136 zfcp_fsf_start_timer(fsf_req, ZFCP_SCSI_ER_TIMEOUT);
11331137 retval = zfcp_fsf_req_send(fsf_req);
1134− if (retval) {
1135− ZFCP_LOG_INFO("error: Failed to send abort command request "
1136− "on adapter %s, port 0x%016Lx, unit 0x%016Lx\n",
1137− zfcp_get_busid_by_adapter(adapter),
1138− unit->port->wwpn, unit->fcp_lun);
1138+ if (!retval)
1139+ goto out;
1140+
1141+ unit_blocked:
11391142 zfcp_fsf_req_free(fsf_req);
11401143 fsf_req = NULL;
1141− goto out;
1142− }
11431144
1144− ZFCP_LOG_DEBUG("Abort FCP Command request initiated "
1145− "(adapter%s, port d_id=0x%06x, "
1146− "unit x%016Lx, old_req_id=0x%lx)\n",
1147− zfcp_get_busid_by_adapter(adapter),
1148− unit->port->d_id,
1149− unit->fcp_lun, old_req_id);
11501145 out:
11511146 write_unlock_irqrestore(&adapter->request_queue.queue_lock, lock_flags);
11521147 return fsf_req;
@@ -1164,8 +1159,8 @@ zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req *new_fsf_req) · 11 unmodified lines
11641159 {
11651160 int retval = -EINVAL;
11661161 struct zfcp_unit *unit;
1167− unsigned char status_qual =
1168− new_fsf_req->qtcb->header.fsf_status_qual.word[0];
1162+ union fsf_status_qual *fsf_stat_qual =
1163+ &new_fsf_req->qtcb->header.fsf_status_qual;
11691164
11701165 if (new_fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) {
11711166 /* do not set ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED */
@@ -1178,7 +1173,7 @@ zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req *new_fsf_req) · 6 unmodified lines
11781173 switch (new_fsf_req->qtcb->header.fsf_status) {
11791174
11801175 case FSF_PORT_HANDLE_NOT_VALID:
1181− if (status_qual >> 4 != status_qual % 0xf) {
1176+ if (fsf_stat_qual->word[0] != fsf_stat_qual->word[1]) {
11821177 debug_text_event(new_fsf_req->adapter->erp_dbf, 3,
11831178 "fsf_s_phand_nv0");
11841179 /*
@@ -1207,8 +1202,7 @@ zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req *new_fsf_req) · 22 unmodified lines
12071202 break;
12081203
12091204 case FSF_LUN_HANDLE_NOT_VALID:
1210− if (status_qual >> 4 != status_qual % 0xf) {
1211− /* 2 */
1205+ if (fsf_stat_qual->word[0] != fsf_stat_qual->word[1]) {
12121206 debug_text_event(new_fsf_req->adapter->erp_dbf, 3,
12131207 "fsf_s_lhand_nv0");
12141208 /*
@@ -1674,6 +1668,12 @@ zfcp_fsf_send_els(struct zfcp_send_els *els) · 459 unmodified lines
16741668 goto failed_req;
16751669 }
16761670
1671+ if (unlikely(!atomic_test_mask(ZFCP_STATUS_COMMON_UNBLOCKED,
1672+ &els->port->status))) {
1673+ ret = -EBUSY;
1674+ goto port_blocked;
1675+ }
1676+
16771677 sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
16781678 if (zfcp_use_one_sbal(els->req, els->req_count,
16791679 els->resp, els->resp_count)){
@@ -1755,6 +1755,7 @@ zfcp_fsf_send_els(struct zfcp_send_els *els) · 75 unmodified lines
17551755 "0x%06x)\n", zfcp_get_busid_by_adapter(adapter), d_id);
17561756 goto out;
17571757
1758+ port_blocked:
17581759 failed_send:
17591760 zfcp_fsf_req_free(fsf_req);
17601761
@@ -3592,6 +3593,12 @@ zfcp_fsf_send_fcp_command_task(struct zfcp_adapter *adapter, · 1831 unmodified lines
35923593 goto failed_req_create;
35933594 }
35943595
3596+ if (unlikely(!atomic_test_mask(ZFCP_STATUS_COMMON_UNBLOCKED,
3597+ &unit->status))) {
3598+ retval = -EBUSY;
3599+ goto unit_blocked;
3600+ }
3601+
35953602 zfcp_unit_get(unit);
35963603 fsf_req->unit = unit;
35973604
@@ -3732,6 +3739,7 @@ zfcp_fsf_send_fcp_command_task(struct zfcp_adapter *adapter, · 134 unmodified lines
37323739 send_failed:
37333740 no_fit:
37343741 failed_scsi_cmnd:
3742+ unit_blocked:
37353743 zfcp_unit_put(unit);
37363744 zfcp_fsf_req_free(fsf_req);
37373745 fsf_req = NULL;
@@ -3766,6 +3774,10 @@ zfcp_fsf_send_fcp_command_task_management(struct zfcp_adapter *adapter, · 28 unmodified lines
37663774 goto out;
37673775 }
37683776
3777+ if (unlikely(!atomic_test_mask(ZFCP_STATUS_COMMON_UNBLOCKED,
3778+ &unit->status)))
3779+ goto unit_blocked;
3780+
37693781 /*
37703782 * Used to decide on proper handler in the return path,
37713783 * could be either zfcp_fsf_send_fcp_command_task_handler or
@@ -3799,25 +3811,13 @@ zfcp_fsf_send_fcp_command_task_management(struct zfcp_adapter *adapter, · 27 unmodified lines
37993811
38003812 zfcp_fsf_start_timer(fsf_req, ZFCP_SCSI_ER_TIMEOUT);
38013813 retval = zfcp_fsf_req_send(fsf_req);
3802− if (retval) {
3803− ZFCP_LOG_INFO("error: Could not send an FCP-command (task "
3804− "management) on adapter %s, port 0x%016Lx for "
3805− "unit LUN 0x%016Lx\n",
3806− zfcp_get_busid_by_adapter(adapter),
3807− unit->port->wwpn,
3808− unit->fcp_lun);
3809− zfcp_fsf_req_free(fsf_req);
3810− fsf_req = NULL;
3814+ if (!retval)
38113815 goto out;
3812− }
38133816
3814− ZFCP_LOG_TRACE("Send FCP Command (task management function) initiated "
3815− "(adapter %s, port 0x%016Lx, unit 0x%016Lx, "
3816− "tm_flags=0x%x)\n",
3817− zfcp_get_busid_by_adapter(adapter),
3818− unit->port->wwpn,
3819− unit->fcp_lun,
3820− tm_flags);
3817+ unit_blocked:
3818+ zfcp_fsf_req_free(fsf_req);
3819+ fsf_req = NULL;
3820+
38213821 out:
38223822 write_unlock_irqrestore(&adapter->request_queue.queue_lock, lock_flags);
38233823 return fsf_req;
drivers/s390/scsi/zfcp_scsi.c+11−13
@@ -51,7 +51,6 @@ struct zfcp_data zfcp_data = { · 50 unmodified lines
5151 .queuecommand = zfcp_scsi_queuecommand,
5252 .eh_abort_handler = zfcp_scsi_eh_abort_handler,
5353 .eh_device_reset_handler = zfcp_scsi_eh_device_reset_handler,
54− .eh_bus_reset_handler = zfcp_scsi_eh_host_reset_handler,
5554 .eh_host_reset_handler = zfcp_scsi_eh_host_reset_handler,
5655 .can_queue = 4096,
5756 .this_id = -1,
@@ -181,9 +180,6 @@ static void zfcp_scsi_slave_destroy(struct scsi_device *sdpnt) · 123 unmodified lines
181180
182181 if (unit) {
183182 zfcp_erp_wait(unit->port->adapter);
184− wait_event(unit->scsi_scan_wq,
185− atomic_test_mask(ZFCP_STATUS_UNIT_SCSI_WORK_PENDING,
186− &unit->status) == 0);
187183 atomic_clear_mask(ZFCP_STATUS_UNIT_REGISTERED, &unit->status);
188184 sdpnt->hostdata = NULL;
189185 unit->device = NULL;
@@ -262,8 +258,9 @@ zfcp_scsi_command_async(struct zfcp_adapter *adapter, struct zfcp_unit *unit, · 72 unmodified lines
262258 goto out;
263259 }
264260
265− if (unlikely(
266− !atomic_test_mask(ZFCP_STATUS_COMMON_UNBLOCKED, &unit->status))) {
261+ tmp = zfcp_fsf_send_fcp_command_task(adapter, unit, scpnt, use_timer,
262+ ZFCP_REQ_AUTO_CLEANUP);
263+ if (unlikely(tmp == -EBUSY)) {
267264 ZFCP_LOG_DEBUG("adapter %s not ready or unit 0x%016Lx "
268265 "on port 0x%016Lx in recovery\n",
269266 zfcp_get_busid_by_unit(unit),
@@ -272,9 +269,6 @@ zfcp_scsi_command_async(struct zfcp_adapter *adapter, struct zfcp_unit *unit, · 2 unmodified lines
272269 goto out;
273270 }
274271
275− tmp = zfcp_fsf_send_fcp_command_task(adapter, unit, scpnt, use_timer,
276− ZFCP_REQ_AUTO_CLEANUP);
277−
278272 if (unlikely(tmp < 0)) {
279273 ZFCP_LOG_DEBUG("error: initiation of Send FCP Cmnd failed\n");
280274 retval = SCSI_MLQUEUE_HOST_BUSY;
@@ -459,7 +453,9 @@ zfcp_scsi_eh_device_reset_handler(struct scsi_cmnd *scpnt) · 178 unmodified lines
459453 retval = SUCCESS;
460454 goto out;
461455 }
462− ZFCP_LOG_NORMAL("resetting unit 0x%016Lx\n", unit->fcp_lun);
456+ ZFCP_LOG_NORMAL("resetting unit 0x%016Lx on port 0x%016Lx, adapter %s\n",
457+ unit->fcp_lun, unit->port->wwpn,
458+ zfcp_get_busid_by_adapter(unit->port->adapter));
463459
464460 /*
465461 * If we do not know whether the unit supports 'logical unit reset'
@@ -542,7 +538,7 @@ zfcp_task_management_function(struct zfcp_unit *unit, u8 tm_flags, · 76 unmodified lines
542538 }
543539
544540 /**
545− * zfcp_scsi_eh_host_reset_handler - handler for host and bus reset
541+ * zfcp_scsi_eh_host_reset_handler - handler for host reset
546542 */
547543 static int zfcp_scsi_eh_host_reset_handler(struct scsi_cmnd *scpnt)
548544 {
@@ -552,8 +548,10 @@ static int zfcp_scsi_eh_host_reset_handler(struct scsi_cmnd *scpnt) · 3 unmodified lines
552548 unit = (struct zfcp_unit*) scpnt->device->hostdata;
553549 adapter = unit->port->adapter;
554550
555− ZFCP_LOG_NORMAL("host/bus reset because of problems with "
556− "unit 0x%016Lx\n", unit->fcp_lun);
551+ ZFCP_LOG_NORMAL("host reset because of problems with "
552+ "unit 0x%016Lx on port 0x%016Lx, adapter %s\n",
553+ unit->fcp_lun, unit->port->wwpn,
554+ zfcp_get_busid_by_adapter(unit->port->adapter));
557555
558556 zfcp_erp_adapter_reopen(adapter, 0);
559557 zfcp_erp_wait(adapter);
drivers/scsi/.gitignore+0−2
@@ -1,3 +1 @@
11 53c700_d.h
2−53c7xx_d.h
3−53c7xx_u.h
drivers/scsi/3w-9xxx.c+1−0
@@ -2010,6 +2010,7 @@ static int __devinit twa_probe(struct pci_dev *pdev, const struct pci_device_id · 2009 unmodified lines
20102010 }
20112011
20122012 pci_set_master(pdev);
2013+ pci_try_set_mwi(pdev);
20132014
20142015 if (pci_set_dma_mask(pdev, DMA_64BIT_MASK)
20152016 || pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK))
drivers/scsi/53c700.c+6−5
@@ -608,7 +608,8 @@ NCR_700_scsi_done(struct NCR_700_Host_Parameters *hostdata, · 607 unmodified lines
608608 scsi_print_sense("53c700", SCp);
609609
610610 #endif
611− dma_unmap_single(hostdata->dev, slot->dma_handle, sizeof(SCp->sense_buffer), DMA_FROM_DEVICE);
611+ dma_unmap_single(hostdata->dev, slot->dma_handle,
612+ SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE);
612613 /* restore the old result if the request sense was
613614 * successful */
614615 if (result == 0)
@@ -1010,7 +1011,7 @@ process_script_interrupt(__u32 dsps, __u32 dsp, struct scsi_cmnd *SCp, · 395 unmodified lines
10101011 cmnd[1] = (SCp->device->lun & 0x7) << 5;
10111012 cmnd[2] = 0;
10121013 cmnd[3] = 0;
1013− cmnd[4] = sizeof(SCp->sense_buffer);
1014+ cmnd[4] = SCSI_SENSE_BUFFERSIZE;
10141015 cmnd[5] = 0;
10151016 /* Here's a quiet hack: the
10161017 * REQUEST_SENSE command is six bytes,
@@ -1024,14 +1025,14 @@ process_script_interrupt(__u32 dsps, __u32 dsp, struct scsi_cmnd *SCp, · 7 unmodified lines
10241025 SCp->cmd_len = 6; /* command length for
10251026 * REQUEST_SENSE */
10261027 slot->pCmd = dma_map_single(hostdata->dev, cmnd, MAX_COMMAND_SIZE, DMA_TO_DEVICE);
1027− slot->dma_handle = dma_map_single(hostdata->dev, SCp->sense_buffer, sizeof(SCp->sense_buffer), DMA_FROM_DEVICE);
1028− slot->SG[0].ins = bS_to_host(SCRIPT_MOVE_DATA_IN | sizeof(SCp->sense_buffer));
1028+ slot->dma_handle = dma_map_single(hostdata->dev, SCp->sense_buffer, SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE);
1029+ slot->SG[0].ins = bS_to_host(SCRIPT_MOVE_DATA_IN | SCSI_SENSE_BUFFERSIZE);
10291030 slot->SG[0].pAddr = bS_to_host(slot->dma_handle);
10301031 slot->SG[1].ins = bS_to_host(SCRIPT_RETURN);
10311032 slot->SG[1].pAddr = 0;
10321033 slot->resume_offset = hostdata->pScript;
10331034 dma_cache_sync(hostdata->dev, slot->SG, sizeof(slot->SG[0])*2, DMA_TO_DEVICE);
1034− dma_cache_sync(hostdata->dev, SCp->sense_buffer, sizeof(SCp->sense_buffer), DMA_FROM_DEVICE);
1035+ dma_cache_sync(hostdata->dev, SCp->sense_buffer, SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE);
10351036
10361037 /* queue the command for reissue */
10371038 slot->state = NCR_700_SLOT_QUEUED;
drivers/scsi/BusLogic.c+1−1
@@ -2947,7 +2947,7 @@ static int BusLogic_QueueCommand(struct scsi_cmnd *Command, void (*CompletionRou · 2946 unmodified lines
29472947 }
29482948 }
29492949 memcpy(CCB->CDB, CDB, CDB_Length);
2950− CCB->SenseDataLength = sizeof(Command->sense_buffer);
2950+ CCB->SenseDataLength = SCSI_SENSE_BUFFERSIZE;
29512951 CCB->SenseDataPointer = pci_map_single(HostAdapter->PCI_Device, Command->sense_buffer, CCB->SenseDataLength, PCI_DMA_FROMDEVICE);
29522952 CCB->Command = Command;
29532953 Command->scsi_done = CompletionRoutine;
drivers/scsi/Kconfig+3−29
@@ -341,7 +341,7 @@ config ISCSI_TCP · 340 unmodified lines
341341 The userspace component needed to initialize the driver, documentation,
342342 and sample configuration files can be found here:
343343
344− http://linux-iscsi.sf.net
344+ http://open-iscsi.org
345345
346346 config SGIWD93_SCSI
347347 tristate "SGI WD93C93 SCSI Driver"
@@ -573,10 +573,10 @@ config SCSI_ARCMSR_AER · 225 unmodified lines
573573 source "drivers/scsi/megaraid/Kconfig.megaraid"
574574
575575 config SCSI_HPTIOP
576− tristate "HighPoint RocketRAID 3xxx Controller support"
576+ tristate "HighPoint RocketRAID 3xxx/4xxx Controller support"
577577 depends on SCSI && PCI
578578 help
579− This option enables support for HighPoint RocketRAID 3xxx
579+ This option enables support for HighPoint RocketRAID 3xxx/4xxx
580580 controllers.
581581
582582 To compile this driver as a module, choose M here; the module
@@ -1288,17 +1288,6 @@ config SCSI_PAS16 · 705 unmodified lines
12881288 To compile this driver as a module, choose M here: the
12891289 module will be called pas16.
12901290
1291−config SCSI_PSI240I
1292− tristate "PSI240i support"
1293− depends on ISA && SCSI
1294− help
1295− This is support for the PSI240i EIDE interface card which acts as a
1296− SCSI host adapter. Please read the SCSI-HOWTO, available from
1297− <http://www.tldp.org/docs.html#howto>.
1298−
1299− To compile this driver as a module, choose M here: the
1300− module will be called psi240i.
1301−
13021291 config SCSI_QLOGIC_FAS
13031292 tristate "Qlogic FAS SCSI support"
13041293 depends on ISA && SCSI
@@ -1359,21 +1348,6 @@ config SCSI_LPFC · 54 unmodified lines
13591348 This lpfc driver supports the Emulex LightPulse
13601349 Family of Fibre Channel PCI host adapters.
13611350
1362−config SCSI_SEAGATE
1363− tristate "Seagate ST-02 and Future Domain TMC-8xx SCSI support"
1364− depends on X86 && ISA && SCSI
1365− select CHECK_SIGNATURE
1366− ---help---
1367− These are 8-bit SCSI controllers; the ST-01 is also supported by
1368− this driver. It is explained in section 3.9 of the SCSI-HOWTO,
1369− available from <http://www.tldp.org/docs.html#howto>. If it
1370− doesn't work out of the box, you may have to change some macros at
1371− compiletime, which are described in <file:drivers/scsi/seagate.c>.
1372−
1373− To compile this driver as a module, choose M here: the
1374− module will be called seagate.
1375−
1376−# definitely looks not 64bit safe:
13771351 config SCSI_SIM710
13781352 tristate "Simple 53c710 SCSI support (Compaq, NCR machines)"
13791353 depends on (EISA || MCA) && SCSI
drivers/scsi/Makefile+1−4
@@ -16,9 +16,8 @@ · 15 unmodified lines
1616
1717 CFLAGS_aha152x.o = -DAHA152X_STAT -DAUTOCONF
1818 CFLAGS_gdth.o = # -DDEBUG_GDTH=2 -D__SERIAL__ -D__COM2__ -DGDTH_STATISTICS
19−CFLAGS_seagate.o = -DARBITRATE -DPARITY -DSEAGATE_USE_ASM
2019
21−subdir-$(CONFIG_PCMCIA) += pcmcia
20+obj-$(CONFIG_PCMCIA) += pcmcia/
2221
2322 obj-$(CONFIG_SCSI) += scsi_mod.o
2423 obj-$(CONFIG_SCSI_TGT) += scsi_tgt.o
@@ -59,7 +58,6 @@ obj-$(CONFIG_MVME16x_SCSI) += 53c700.o mvme16x_scsi.o · 34 unmodified lines
5958 obj-$(CONFIG_BVME6000_SCSI) += 53c700.o bvme6000_scsi.o
6059 obj-$(CONFIG_SCSI_SIM710) += 53c700.o sim710.o
6160 obj-$(CONFIG_SCSI_ADVANSYS) += advansys.o
62−obj-$(CONFIG_SCSI_PSI240I) += psi240i.o
6361 obj-$(CONFIG_SCSI_BUSLOGIC) += BusLogic.o
6462 obj-$(CONFIG_SCSI_DPT_I2O) += dpt_i2o.o
6563 obj-$(CONFIG_SCSI_U14_34F) += u14-34f.o
@@ -90,7 +88,6 @@ obj-$(CONFIG_SCSI_QLA_FC) += qla2xxx/ · 24 unmodified lines
9088 obj-$(CONFIG_SCSI_QLA_ISCSI) += qla4xxx/
9189 obj-$(CONFIG_SCSI_LPFC) += lpfc/
9290 obj-$(CONFIG_SCSI_PAS16) += pas16.o
93−obj-$(CONFIG_SCSI_SEAGATE) += seagate.o
9491 obj-$(CONFIG_SCSI_T128) += t128.o
9592 obj-$(CONFIG_SCSI_DMX3191D) += dmx3191d.o
9693 obj-$(CONFIG_SCSI_DTC3280) += dtc.o
drivers/scsi/NCR5380.c+12−11
@@ -295,16 +295,16 @@ static __inline__ void initialize_SCp(Scsi_Cmnd * cmd) · 294 unmodified lines
295295 * various queues are valid.
296296 */
297297
298− if (cmd->use_sg) {
299− cmd->SCp.buffer = (struct scatterlist *) cmd->request_buffer;
300− cmd->SCp.buffers_residual = cmd->use_sg - 1;
298+ if (scsi_bufflen(cmd)) {
299+ cmd->SCp.buffer = scsi_sglist(cmd);
300+ cmd->SCp.buffers_residual = scsi_sg_count(cmd) - 1;
301301 cmd->SCp.ptr = sg_virt(cmd->SCp.buffer);
302302 cmd->SCp.this_residual = cmd->SCp.buffer->length;
303303 } else {
304304 cmd->SCp.buffer = NULL;
305305 cmd->SCp.buffers_residual = 0;
306− cmd->SCp.ptr = (char *) cmd->request_buffer;
307− cmd->SCp.this_residual = cmd->request_bufflen;
306+ cmd->SCp.ptr = NULL;
307+ cmd->SCp.this_residual = 0;
308308 }
309309 }
310310
@@ -932,7 +932,7 @@ static int __devinit NCR5380_init(struct Scsi_Host *instance, int flags) · 621 unmodified lines
932932 * @instance: adapter to remove
933933 */
934934
935−static void __devexit NCR5380_exit(struct Scsi_Host *instance)
935+static void NCR5380_exit(struct Scsi_Host *instance)
936936 {
937937 struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) instance->hostdata;
938938
@@ -975,14 +975,14 @@ static int NCR5380_queue_command(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *)) · 36 unmodified lines
975975 case WRITE_6:
976976 case WRITE_10:
977977 hostdata->time_write[cmd->device->id] -= (jiffies - hostdata->timebase);
978− hostdata->bytes_write[cmd->device->id] += cmd->request_bufflen;
978+ hostdata->bytes_write[cmd->device->id] += scsi_bufflen(cmd);
979979 hostdata->pendingw++;
980980 break;
981981 case READ:
982982 case READ_6:
983983 case READ_10:
984984 hostdata->time_read[cmd->device->id] -= (jiffies - hostdata->timebase);
985− hostdata->bytes_read[cmd->device->id] += cmd->request_bufflen;
985+ hostdata->bytes_read[cmd->device->id] += scsi_bufflen(cmd);
986986 hostdata->pendingr++;
987987 break;
988988 }
@@ -1157,16 +1157,17 @@ static void NCR5380_main(struct work_struct *work) · 168 unmodified lines
11571157 * Locks: takes the needed instance locks
11581158 */
11591159
1160−static irqreturn_t NCR5380_intr(int irq, void *dev_id)
1160+static irqreturn_t NCR5380_intr(int dummy, void *dev_id)
11611161 {
11621162 NCR5380_local_declare();
1163− struct Scsi_Host *instance = (struct Scsi_Host *)dev_id;
1163+ struct Scsi_Host *instance = dev_id;
11641164 struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) instance->hostdata;
11651165 int done;
11661166 unsigned char basr;
11671167 unsigned long flags;
11681168
1169− dprintk(NDEBUG_INTR, ("scsi : NCR5380 irq %d triggered\n", irq));
1169+ dprintk(NDEBUG_INTR, ("scsi : NCR5380 irq %d triggered\n",
1170+ instance->irq));
11701171
11711172 do {
11721173 done = 1;
drivers/scsi/a2091.c+5−31
@@ -73,18 +73,9 @@ static int dma_setup(struct scsi_cmnd *cmd, int dir_in) · 72 unmodified lines
7373 }
7474
7575 if (!dir_in) {
76− /* copy to bounce buffer for a write */
77− if (cmd->use_sg)
78−#if 0
79− panic ("scsi%ddma: incomplete s/g support",
80− instance->host_no);
81−#else
76+ /* copy to bounce buffer for a write */
8277 memcpy (HDATA(instance)->dma_bounce_buffer,
8378 cmd->SCp.ptr, cmd->SCp.this_residual);
84−#endif
85− else
86− memcpy (HDATA(instance)->dma_bounce_buffer,
87− cmd->request_buffer, cmd->request_bufflen);
8879 }
8980 }
9081
@@ -144,30 +135,13 @@ static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt, · 53 unmodified lines
144135
145136 /* copy from a bounce buffer, if necessary */
146137 if (status && HDATA(instance)->dma_bounce_buffer) {
147− if (SCpnt && SCpnt->use_sg) {
148−#if 0
149− panic ("scsi%d: incomplete s/g support",
150− instance->host_no);
151−#else
152− if( HDATA(instance)->dma_dir )
138+ if( HDATA(instance)->dma_dir )
153139 memcpy (SCpnt->SCp.ptr,
154140 HDATA(instance)->dma_bounce_buffer,
155141 SCpnt->SCp.this_residual);
156− kfree (HDATA(instance)->dma_bounce_buffer);
157− HDATA(instance)->dma_bounce_buffer = NULL;
158− HDATA(instance)->dma_bounce_len = 0;
159−
160−#endif
161− } else {
162− if (HDATA(instance)->dma_dir && SCpnt)
163− memcpy (SCpnt->request_buffer,
164− HDATA(instance)->dma_bounce_buffer,
165− SCpnt->request_bufflen);
166−
167− kfree (HDATA(instance)->dma_bounce_buffer);
168− HDATA(instance)->dma_bounce_buffer = NULL;
169− HDATA(instance)->dma_bounce_len = 0;
170− }
142+ kfree (HDATA(instance)->dma_bounce_buffer);
143+ HDATA(instance)->dma_bounce_buffer = NULL;
144+ HDATA(instance)->dma_bounce_len = 0;
171145 }
172146 }
173147
drivers/scsi/a3000.c+3−12
@@ -70,12 +70,8 @@ static int dma_setup(struct scsi_cmnd *cmd, int dir_in) · 69 unmodified lines
7070
7171 if (!dir_in) {
7272 /* copy to bounce buffer for a write */
73− if (cmd->use_sg) {
74− memcpy (HDATA(a3000_host)->dma_bounce_buffer,
75− cmd->SCp.ptr, cmd->SCp.this_residual);
76− } else
77− memcpy (HDATA(a3000_host)->dma_bounce_buffer,
78− cmd->request_buffer, cmd->request_bufflen);
73+ memcpy (HDATA(a3000_host)->dma_bounce_buffer,
74+ cmd->SCp.ptr, cmd->SCp.this_residual);
7975 }
8076
8177 addr = virt_to_bus(HDATA(a3000_host)->dma_bounce_buffer);
@@ -146,7 +142,7 @@ static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt, · 64 unmodified lines
146142
147143 /* copy from a bounce buffer, if necessary */
148144 if (status && HDATA(instance)->dma_bounce_buffer) {
149− if (SCpnt && SCpnt->use_sg) {
145+ if (SCpnt) {
150146 if (HDATA(instance)->dma_dir && SCpnt)
151147 memcpy (SCpnt->SCp.ptr,
152148 HDATA(instance)->dma_bounce_buffer,
@@ -155,11 +151,6 @@ static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt, · 2 unmodified lines
155151 HDATA(instance)->dma_bounce_buffer = NULL;
156152 HDATA(instance)->dma_bounce_len = 0;
157153 } else {
158− if (HDATA(instance)->dma_dir && SCpnt)
159− memcpy (SCpnt->request_buffer,
160− HDATA(instance)->dma_bounce_buffer,
161− SCpnt->request_bufflen);
162−
163154 kfree (HDATA(instance)->dma_bounce_buffer);
164155 HDATA(instance)->dma_bounce_buffer = NULL;
165156 HDATA(instance)->dma_bounce_len = 0;
drivers/scsi/aacraid/aachba.c+215−185
@@ -31,9 +31,9 @@ · 30 unmodified lines
3131 #include <linux/slab.h>
3232 #include <linux/completion.h>
3333 #include <linux/blkdev.h>
34−#include <linux/dma-mapping.h>
3534 #include <asm/semaphore.h>
3635 #include <asm/uaccess.h>
36+#include <linux/highmem.h> /* For flush_kernel_dcache_page */
3737
3838 #include <scsi/scsi.h>
3939 #include <scsi/scsi_cmnd.h>
@@ -56,54 +56,54 @@ · 16 unmodified lines
5656 /*
5757 * Sense codes
5858 */
59−
60−#define SENCODE_NO_SENSE 0x00
61−#define SENCODE_END_OF_DATA 0x00
62−#define SENCODE_BECOMING_READY 0x04
63−#define SENCODE_INIT_CMD_REQUIRED 0x04
64−#define SENCODE_PARAM_LIST_LENGTH_ERROR 0x1A
65−#define SENCODE_INVALID_COMMAND 0x20
66−#define SENCODE_LBA_OUT_OF_RANGE 0x21
67−#define SENCODE_INVALID_CDB_FIELD 0x24
68−#define SENCODE_LUN_NOT_SUPPORTED 0x25
69−#define SENCODE_INVALID_PARAM_FIELD 0x26
70−#define SENCODE_PARAM_NOT_SUPPORTED 0x26
71−#define SENCODE_PARAM_VALUE_INVALID 0x26
72−#define SENCODE_RESET_OCCURRED 0x29
73−#define SENCODE_LUN_NOT_SELF_CONFIGURED_YET 0x3E
74−#define SENCODE_INQUIRY_DATA_CHANGED 0x3F
75−#define SENCODE_SAVING_PARAMS_NOT_SUPPORTED 0x39
76−#define SENCODE_DIAGNOSTIC_FAILURE 0x40
77−#define SENCODE_INTERNAL_TARGET_FAILURE 0x44
78−#define SENCODE_INVALID_MESSAGE_ERROR 0x49
79−#define SENCODE_LUN_FAILED_SELF_CONFIG 0x4c
80−#define SENCODE_OVERLAPPED_COMMAND 0x4E
59+
60+#define SENCODE_NO_SENSE 0x00
61+#define SENCODE_END_OF_DATA 0x00
62+#define SENCODE_BECOMING_READY 0x04
63+#define SENCODE_INIT_CMD_REQUIRED 0x04
64+#define SENCODE_PARAM_LIST_LENGTH_ERROR 0x1A
65+#define SENCODE_INVALID_COMMAND 0x20
66+#define SENCODE_LBA_OUT_OF_RANGE 0x21
67+#define SENCODE_INVALID_CDB_FIELD 0x24
68+#define SENCODE_LUN_NOT_SUPPORTED 0x25
69+#define SENCODE_INVALID_PARAM_FIELD 0x26
70+#define SENCODE_PARAM_NOT_SUPPORTED 0x26
71+#define SENCODE_PARAM_VALUE_INVALID 0x26
72+#define SENCODE_RESET_OCCURRED 0x29
73+#define SENCODE_LUN_NOT_SELF_CONFIGURED_YET 0x3E
74+#define SENCODE_INQUIRY_DATA_CHANGED 0x3F
75+#define SENCODE_SAVING_PARAMS_NOT_SUPPORTED 0x39
76+#define SENCODE_DIAGNOSTIC_FAILURE 0x40
77+#define SENCODE_INTERNAL_TARGET_FAILURE 0x44
78+#define SENCODE_INVALID_MESSAGE_ERROR 0x49
79+#define SENCODE_LUN_FAILED_SELF_CONFIG 0x4c
80+#define SENCODE_OVERLAPPED_COMMAND 0x4E
8181
8282 /*
8383 * Additional sense codes
8484 */
85−
86−#define ASENCODE_NO_SENSE 0x00
87−#define ASENCODE_END_OF_DATA 0x05
88−#define ASENCODE_BECOMING_READY 0x01
89−#define ASENCODE_INIT_CMD_REQUIRED 0x02
90−#define ASENCODE_PARAM_LIST_LENGTH_ERROR 0x00
91−#define ASENCODE_INVALID_COMMAND 0x00
92−#define ASENCODE_LBA_OUT_OF_RANGE 0x00
93−#define ASENCODE_INVALID_CDB_FIELD 0x00
94−#define ASENCODE_LUN_NOT_SUPPORTED 0x00
95−#define ASENCODE_INVALID_PARAM_FIELD 0x00
96−#define ASENCODE_PARAM_NOT_SUPPORTED 0x01
97−#define ASENCODE_PARAM_VALUE_INVALID 0x02
98−#define ASENCODE_RESET_OCCURRED 0x00
99−#define ASENCODE_LUN_NOT_SELF_CONFIGURED_YET 0x00
100−#define ASENCODE_INQUIRY_DATA_CHANGED 0x03
101−#define ASENCODE_SAVING_PARAMS_NOT_SUPPORTED 0x00
102−#define ASENCODE_DIAGNOSTIC_FAILURE 0x80
103−#define ASENCODE_INTERNAL_TARGET_FAILURE 0x00
104−#define ASENCODE_INVALID_MESSAGE_ERROR 0x00
105−#define ASENCODE_LUN_FAILED_SELF_CONFIG 0x00
106−#define ASENCODE_OVERLAPPED_COMMAND 0x00
85+
86+#define ASENCODE_NO_SENSE 0x00
87+#define ASENCODE_END_OF_DATA 0x05
88+#define ASENCODE_BECOMING_READY 0x01
89+#define ASENCODE_INIT_CMD_REQUIRED 0x02
90+#define ASENCODE_PARAM_LIST_LENGTH_ERROR 0x00
91+#define ASENCODE_INVALID_COMMAND 0x00
92+#define ASENCODE_LBA_OUT_OF_RANGE 0x00
93+#define ASENCODE_INVALID_CDB_FIELD 0x00
94+#define ASENCODE_LUN_NOT_SUPPORTED 0x00
95+#define ASENCODE_INVALID_PARAM_FIELD 0x00
96+#define ASENCODE_PARAM_NOT_SUPPORTED 0x01
97+#define ASENCODE_PARAM_VALUE_INVALID 0x02
98+#define ASENCODE_RESET_OCCURRED 0x00
99+#define ASENCODE_LUN_NOT_SELF_CONFIGURED_YET 0x00
100+#define ASENCODE_INQUIRY_DATA_CHANGED 0x03
101+#define ASENCODE_SAVING_PARAMS_NOT_SUPPORTED 0x00
102+#define ASENCODE_DIAGNOSTIC_FAILURE 0x80
103+#define ASENCODE_INTERNAL_TARGET_FAILURE 0x00
104+#define ASENCODE_INVALID_MESSAGE_ERROR 0x00
105+#define ASENCODE_LUN_FAILED_SELF_CONFIG 0x00
106+#define ASENCODE_OVERLAPPED_COMMAND 0x00
107107
108108 #define BYTE0(x) (unsigned char)(x)
109109 #define BYTE1(x) (unsigned char)((x) >> 8)
@@ -115,8 +115,8 @@ · 5 unmodified lines
115115 *----------------------------------------------------------------------------*/
116116 /* SCSI inquiry data */
117117 struct inquiry_data {
118− u8 inqd_pdt; /* Peripheral qualifier | Peripheral Device Type */
119− u8 inqd_dtq; /* RMB | Device Type Qualifier */
118+ u8 inqd_pdt; /* Peripheral qualifier | Peripheral Device Type */
119+ u8 inqd_dtq; /* RMB | Device Type Qualifier */
120120 u8 inqd_ver; /* ISO version | ECMA version | ANSI-approved version */
121121 u8 inqd_rdf; /* AENC | TrmIOP | Response data format */
122122 u8 inqd_len; /* Additional length (n-4) */
@@ -130,7 +130,7 @@ struct inquiry_data { · 7 unmodified lines
130130 /*
131131 * M O D U L E G L O B A L S
132132 */
133−
133+
134134 static unsigned long aac_build_sg(struct scsi_cmnd* scsicmd, struct sgmap* sgmap);
135135 static unsigned long aac_build_sg64(struct scsi_cmnd* scsicmd, struct sgmap64* psg);
136136 static unsigned long aac_build_sgraw(struct scsi_cmnd* scsicmd, struct sgmapraw* psg);
@@ -141,9 +141,10 @@ static char *aac_get_status_string(u32 status); · 4 unmodified lines
141141
142142 /*
143143 * Non dasd selection is handled entirely in aachba now
144− */
145−
144+ */
145+
146146 static int nondasd = -1;
147+static int aac_cache = 0;
147148 static int dacmode = -1;
148149
149150 int aac_commit = -1;
@@ -152,6 +153,8 @@ int aif_timeout = 120; · 2 unmodified lines
152153
153154 module_param(nondasd, int, S_IRUGO|S_IWUSR);
154155 MODULE_PARM_DESC(nondasd, "Control scanning of hba for nondasd devices. 0=off, 1=on");
156+module_param_named(cache, aac_cache, int, S_IRUGO|S_IWUSR);
157+MODULE_PARM_DESC(cache, "Disable Queue Flush commands:\n\tbit 0 - Disable FUA in WRITE SCSI commands\n\tbit 1 - Disable SYNCHRONIZE_CACHE SCSI command\n\tbit 2 - Disable only if Battery not protecting Cache");
155158 module_param(dacmode, int, S_IRUGO|S_IWUSR);
156159 MODULE_PARM_DESC(dacmode, "Control whether dma addressing is using 64 bit DAC. 0=off, 1=on");
157160 module_param_named(commit, aac_commit, int, S_IRUGO|S_IWUSR);
@@ -179,7 +182,7 @@ MODULE_PARM_DESC(check_interval, "Interval in seconds between adapter health che · 21 unmodified lines
179182
180183 int aac_check_reset = 1;
181184 module_param_named(check_reset, aac_check_reset, int, S_IRUGO|S_IWUSR);
182−MODULE_PARM_DESC(aac_check_reset, "If adapter fails health check, reset the adapter.");
185+MODULE_PARM_DESC(aac_check_reset, "If adapter fails health check, reset the adapter. a value of -1 forces the reset to adapters programmed to ignore it.");
183186
184187 int expose_physicals = -1;
185188 module_param(expose_physicals, int, S_IRUGO|S_IWUSR);
@@ -193,12 +196,12 @@ static inline int aac_valid_context(struct scsi_cmnd *scsicmd, · 7 unmodified lines
193196 struct fib *fibptr) {
194197 struct scsi_device *device;
195198
196− if (unlikely(!scsicmd || !scsicmd->scsi_done )) {
199+ if (unlikely(!scsicmd || !scsicmd->scsi_done)) {
197200 dprintk((KERN_WARNING "aac_valid_context: scsi command corrupt\n"));
198− aac_fib_complete(fibptr);
199− aac_fib_free(fibptr);
200− return 0;
201− }
201+ aac_fib_complete(fibptr);
202+ aac_fib_free(fibptr);
203+ return 0;
204+ }
202205 scsicmd->SCp.phase = AAC_OWNER_MIDLEVEL;
203206 device = scsicmd->device;
204207 if (unlikely(!device || !scsi_device_online(device))) {
@@ -240,7 +243,7 @@ int aac_get_config_status(struct aac_dev *dev, int commit_flag) · 35 unmodified lines
240243 FsaNormal,
241244 1, 1,
242245 NULL, NULL);
243− if (status < 0 ) {
246+ if (status < 0) {
244247 printk(KERN_WARNING "aac_get_config_status: SendFIB failed.\n");
245248 } else {
246249 struct aac_get_config_status_resp *reply
@@ -264,10 +267,10 @@ int aac_get_config_status(struct aac_dev *dev, int commit_flag) · 17 unmodified lines
264267 struct aac_commit_config * dinfo;
265268 aac_fib_init(fibptr);
266269 dinfo = (struct aac_commit_config *) fib_data(fibptr);
267−
270+
268271 dinfo->command = cpu_to_le32(VM_ContainerConfig);
269272 dinfo->type = cpu_to_le32(CT_COMMIT_CONFIG);
270−
273+
271274 status = aac_fib_send(ContainerCommand,
272275 fibptr,
273276 sizeof (struct aac_commit_config),
@@ -293,7 +296,7 @@ int aac_get_config_status(struct aac_dev *dev, int commit_flag) · 19 unmodified lines
293296 int aac_get_containers(struct aac_dev *dev)
294297 {
295298 struct fsa_dev_info *fsa_dev_ptr;
296− u32 index;
299+ u32 index;
297300 int status = 0;
298301 struct fib * fibptr;
299302 struct aac_get_container_count *dinfo;
@@ -363,6 +366,7 @@ static void aac_internal_transfer(struct scsi_cmnd *scsicmd, void *data, unsigne · 63 unmodified lines
363366 if (buf && transfer_len > 0)
364367 memcpy(buf + offset, data, transfer_len);
365368
369+ flush_kernel_dcache_page(kmap_atomic_to_page(buf - sg->offset));
366370 kunmap_atomic(buf - sg->offset, KM_IRQ0);
367371
368372 }
@@ -395,7 +399,7 @@ static void get_container_name_callback(void *context, struct fib * fibptr) · 26 unmodified lines
395399 do {
396400 *dp++ = (*sp) ? *sp++ : ' ';
397401 } while (--count > 0);
398− aac_internal_transfer(scsicmd, d,
402+ aac_internal_transfer(scsicmd, d,
399403 offsetof(struct inquiry_data, inqd_pid), sizeof(d));
400404 }
401405 }
@@ -431,13 +435,13 @@ static int aac_get_container_name(struct scsi_cmnd * scsicmd) · 29 unmodified lines
431435 dinfo->count = cpu_to_le32(sizeof(((struct aac_get_name_resp *)NULL)->data));
432436
433437 status = aac_fib_send(ContainerCommand,
434− cmd_fibcontext,
438+ cmd_fibcontext,
435439 sizeof (struct aac_get_name),
436− FsaNormal,
437− 0, 1,
438− (fib_callback) get_container_name_callback,
440+ FsaNormal,
441+ 0, 1,
442+ (fib_callback)get_container_name_callback,
439443 (void *) scsicmd);
440−
444+
441445 /*
442446 * Check that the command queued to the controller
443447 */
@@ -445,7 +449,7 @@ static int aac_get_container_name(struct scsi_cmnd * scsicmd) · 1 unmodified line
445449 scsicmd->SCp.phase = AAC_OWNER_FIRMWARE;
446450 return 0;
447451 }
448−
452+
449453 printk(KERN_WARNING "aac_get_container_name: aac_fib_send failed with status: %d.\n", status);
450454 aac_fib_complete(cmd_fibcontext);
451455 aac_fib_free(cmd_fibcontext);
@@ -652,42 +656,47 @@ struct scsi_inq { · 200 unmodified lines
652656 * @a: string to copy from
653657 * @b: string to copy to
654658 *
655− * Copy a String from one location to another
659+ * Copy a String from one location to another
656660 * without copying \0
657661 */
658662
659663 static void inqstrcpy(char *a, char *b)
660664 {
661665
662− while(*a != (char)0)
666+ while (*a != (char)0)
663667 *b++ = *a++;
664668 }
665669
666670 static char *container_types[] = {
667− "None",
668− "Volume",
669− "Mirror",
670− "Stripe",
671− "RAID5",
672− "SSRW",
673− "SSRO",
674− "Morph",
675− "Legacy",
676− "RAID4",
677− "RAID10",
678− "RAID00",
679− "V-MIRRORS",
680− "PSEUDO R4",
671+ "None",
672+ "Volume",
673+ "Mirror",
674+ "Stripe",
675+ "RAID5",
676+ "SSRW",
677+ "SSRO",
678+ "Morph",
679+ "Legacy",
680+ "RAID4",
681+ "RAID10",
682+ "RAID00",
683+ "V-MIRRORS",
684+ "PSEUDO R4",
681685 "RAID50",
682686 "RAID5D",
683687 "RAID5D0",
684688 "RAID1E",
685689 "RAID6",
686690 "RAID60",
687− "Unknown"
691+ "Unknown"
688692 };
689693
690−
694+char * get_container_type(unsigned tindex)
695+{
696+ if (tindex >= ARRAY_SIZE(container_types))
697+ tindex = ARRAY_SIZE(container_types) - 1;
698+ return container_types[tindex];
699+}
691700
692701 /* Function: setinqstr
693702 *
@@ -707,16 +716,21 @@ static void setinqstr(struct aac_dev *dev, void *data, int tindex) · 13 unmodified lines
707716
708717 if (dev->supplement_adapter_info.AdapterTypeText[0]) {
709718 char * cp = dev->supplement_adapter_info.AdapterTypeText;
710− int c = sizeof(str->vid);
711− while (*cp && *cp != ' ' && --c)
712− ++cp;
713− c = *cp;
714− *cp = '\0';
715− inqstrcpy (dev->supplement_adapter_info.AdapterTypeText,
716− str->vid);
717− *cp = c;
718− while (*cp && *cp != ' ')
719− ++cp;
719+ int c;
720+ if ((cp[0] == 'A') && (cp[1] == 'O') && (cp[2] == 'C'))
721+ inqstrcpy("SMC", str->vid);
722+ else {
723+ c = sizeof(str->vid);
724+ while (*cp && *cp != ' ' && --c)
725+ ++cp;
726+ c = *cp;
727+ *cp = '\0';
728+ inqstrcpy (dev->supplement_adapter_info.AdapterTypeText,
729+ str->vid);
730+ *cp = c;
731+ while (*cp && *cp != ' ')
732+ ++cp;
733+ }
720734 while (*cp == ' ')
721735 ++cp;
722736 /* last six chars reserved for vol type */
@@ -898,9 +912,8 @@ static int aac_bounds_32(struct aac_dev * dev, struct scsi_cmnd * cmd, u64 lba) · 175 unmodified lines
898912 ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0,
899913 0, 0);
900914 memcpy(cmd->sense_buffer, &dev->fsa_dev[cid].sense_data,
901− (sizeof(dev->fsa_dev[cid].sense_data) > sizeof(cmd->sense_buffer))
902− ? sizeof(cmd->sense_buffer)
903− : sizeof(dev->fsa_dev[cid].sense_data));
915+ min_t(size_t, sizeof(dev->fsa_dev[cid].sense_data),
916+ SCSI_SENSE_BUFFERSIZE));
904917 cmd->scsi_done(cmd);
905918 return 1;
906919 }
@@ -981,7 +994,7 @@ static int aac_read_block(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u32 · 74 unmodified lines
981994 aac_fib_init(fib);
982995 readcmd = (struct aac_read *) fib_data(fib);
983996 readcmd->command = cpu_to_le32(VM_CtBlockRead);
984− readcmd->cid = cpu_to_le16(scmd_id(cmd));
997+ readcmd->cid = cpu_to_le32(scmd_id(cmd));
985998 readcmd->block = cpu_to_le32((u32)(lba&0xffffffff));
986999 readcmd->count = cpu_to_le32(count * 512);
9871000
@@ -1013,7 +1026,8 @@ static int aac_write_raw_io(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u · 25 unmodified lines
10131026 writecmd->block[1] = cpu_to_le32((u32)((lba&0xffffffff00000000LL)>>32));
10141027 writecmd->count = cpu_to_le32(count<<9);
10151028 writecmd->cid = cpu_to_le16(scmd_id(cmd));
1016− writecmd->flags = fua ?
1029+ writecmd->flags = (fua && ((aac_cache & 5) != 1) &&
1030+ (((aac_cache & 5) != 5) || !fib->dev->cache_protected)) ?
10171031 cpu_to_le16(IO_TYPE_WRITE|IO_SUREWRITE) :
10181032 cpu_to_le16(IO_TYPE_WRITE);
10191033 writecmd->bpTotal = 0;
@@ -1072,7 +1086,7 @@ static int aac_write_block(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u3 · 52 unmodified lines
10721086 aac_fib_init(fib);
10731087 writecmd = (struct aac_write *) fib_data(fib);
10741088 writecmd->command = cpu_to_le32(VM_CtBlockWrite);
1075− writecmd->cid = cpu_to_le16(scmd_id(cmd));
1089+ writecmd->cid = cpu_to_le32(scmd_id(cmd));
10761090 writecmd->block = cpu_to_le32((u32)(lba&0xffffffff));
10771091 writecmd->count = cpu_to_le32(count * 512);
10781092 writecmd->sg.count = cpu_to_le32(1);
@@ -1190,6 +1204,15 @@ static int aac_scsi_32(struct fib * fib, struct scsi_cmnd * cmd) · 111 unmodified lines
11901204 (fib_callback) aac_srb_callback, (void *) cmd);
11911205 }
11921206
1207+static int aac_scsi_32_64(struct fib * fib, struct scsi_cmnd * cmd)
1208+{
1209+ if ((sizeof(dma_addr_t) > 4) &&
1210+ (num_physpages > (0xFFFFFFFFULL >> PAGE_SHIFT)) &&
1211+ (fib->dev->adapter_info.options & AAC_OPT_SGMAP_HOST64))
1212+ return FAILED;
1213+ return aac_scsi_32(fib, cmd);
1214+}
1215+
11931216 int aac_get_adapter_info(struct aac_dev* dev)
11941217 {
11951218 struct fib* fibptr;
@@ -1207,11 +1230,11 @@ int aac_get_adapter_info(struct aac_dev* dev) · 11 unmodified lines
12071230 memset(info,0,sizeof(*info));
12081231
12091232 rcode = aac_fib_send(RequestAdapterInfo,
1210− fibptr,
1233+ fibptr,
12111234 sizeof(*info),
1212− FsaNormal,
1235+ FsaNormal,
12131236 -1, 1, /* First `interrupt' command uses special wait */
1214− NULL,
1237+ NULL,
12151238 NULL);
12161239
12171240 if (rcode < 0) {
@@ -1222,29 +1245,29 @@ int aac_get_adapter_info(struct aac_dev* dev) · 4 unmodified lines
12221245 memcpy(&dev->adapter_info, info, sizeof(*info));
12231246
12241247 if (dev->adapter_info.options & AAC_OPT_SUPPLEMENT_ADAPTER_INFO) {
1225− struct aac_supplement_adapter_info * info;
1248+ struct aac_supplement_adapter_info * sinfo;
12261249
12271250 aac_fib_init(fibptr);
12281251
1229− info = (struct aac_supplement_adapter_info *) fib_data(fibptr);
1252+ sinfo = (struct aac_supplement_adapter_info *) fib_data(fibptr);
12301253
1231− memset(info,0,sizeof(*info));
1254+ memset(sinfo,0,sizeof(*sinfo));
12321255
12331256 rcode = aac_fib_send(RequestSupplementAdapterInfo,
12341257 fibptr,
1235− sizeof(*info),
1258+ sizeof(*sinfo),
12361259 FsaNormal,
12371260 1, 1,
12381261 NULL,
12391262 NULL);
12401263
12411264 if (rcode >= 0)
1242− memcpy(&dev->supplement_adapter_info, info, sizeof(*info));
1265+ memcpy(&dev->supplement_adapter_info, sinfo, sizeof(*sinfo));
12431266 }
12441267
12451268
1246− /*
1247− * GetBusInfo
1269+ /*
1270+ * GetBusInfo
12481271 */
12491272
12501273 aac_fib_init(fibptr);
@@ -1267,6 +1290,8 @@ int aac_get_adapter_info(struct aac_dev* dev) · 16 unmodified lines
12671290 1, 1,
12681291 NULL, NULL);
12691292
1293+ /* reasoned default */
1294+ dev->maximum_num_physicals = 16;
12701295 if (rcode >= 0 && le32_to_cpu(bus_info->Status) == ST_OK) {
12711296 dev->maximum_num_physicals = le32_to_cpu(bus_info->TargetsPerBus);
12721297 dev->maximum_num_channels = le32_to_cpu(bus_info->BusCount);
@@ -1276,7 +1301,7 @@ int aac_get_adapter_info(struct aac_dev* dev) · 3 unmodified lines
12761301 char buffer[16];
12771302 tmp = le32_to_cpu(dev->adapter_info.kernelrev);
12781303 printk(KERN_INFO "%s%d: kernel %d.%d-%d[%d] %.*s\n",
1279− dev->name,
1304+ dev->name,
12801305 dev->id,
12811306 tmp>>24,
12821307 (tmp>>16)&0xff,
@@ -1305,19 +1330,21 @@ int aac_get_adapter_info(struct aac_dev* dev) · 22 unmodified lines
13051330 (int)sizeof(dev->supplement_adapter_info.VpdInfo.Tsid),
13061331 dev->supplement_adapter_info.VpdInfo.Tsid);
13071332 }
1308− if (!aac_check_reset ||
1333+ if (!aac_check_reset || ((aac_check_reset != 1) &&
13091334 (dev->supplement_adapter_info.SupportedOptions2 &
1310− le32_to_cpu(AAC_OPTION_IGNORE_RESET))) {
1335+ AAC_OPTION_IGNORE_RESET))) {
13111336 printk(KERN_INFO "%s%d: Reset Adapter Ignored\n",
13121337 dev->name, dev->id);
13131338 }
13141339 }
13151340
1341+ dev->cache_protected = 0;
1342+ dev->jbod = ((dev->supplement_adapter_info.FeatureBits &
1343+ AAC_FEATURE_JBOD) != 0);
13161344 dev->nondasd_support = 0;
13171345 dev->raid_scsi_mode = 0;
1318− if(dev->adapter_info.options & AAC_OPT_NONDASD){
1346+ if(dev->adapter_info.options & AAC_OPT_NONDASD)
13191347 dev->nondasd_support = 1;
1320− }
13211348
13221349 /*
13231350 * If the firmware supports ROMB RAID/SCSI mode and we are currently
@@ -1338,11 +1365,10 @@ int aac_get_adapter_info(struct aac_dev* dev) · 14 unmodified lines
13381365 if (dev->raid_scsi_mode != 0)
13391366 printk(KERN_INFO "%s%d: ROMB RAID/SCSI mode enabled\n",
13401367 dev->name, dev->id);
1341−
1342− if(nondasd != -1) {
1368+
1369+ if (nondasd != -1)
13431370 dev->nondasd_support = (nondasd!=0);
1344− }
1345− if(dev->nondasd_support != 0){
1371+ if(dev->nondasd_support != 0) {
13461372 printk(KERN_INFO "%s%d: Non-DASD support enabled.\n",dev->name, dev->id);
13471373 }
13481374
@@ -1371,12 +1397,14 @@ int aac_get_adapter_info(struct aac_dev* dev) · 22 unmodified lines
13711397 rcode = -ENOMEM;
13721398 }
13731399 }
1374− /*
1400+ /*
13751401 * Deal with configuring for the individualized limits of each packet
13761402 * interface.
13771403 */
13781404 dev->a_ops.adapter_scsi = (dev->dac_support)
1379− ? aac_scsi_64
1405+ ? ((aac_get_driver_ident(dev->cardtype)->quirks & AAC_QUIRK_SCSI_32)
1406+ ? aac_scsi_32_64
1407+ : aac_scsi_64)
13801408 : aac_scsi_32;
13811409 if (dev->raw_io_interface) {
13821410 dev->a_ops.adapter_bounds = (dev->raw_io_64)
@@ -1393,8 +1421,8 @@ int aac_get_adapter_info(struct aac_dev* dev) · 10 unmodified lines
13931421 if (dev->dac_support) {
13941422 dev->a_ops.adapter_read = aac_read_block64;
13951423 dev->a_ops.adapter_write = aac_write_block64;
1396− /*
1397− * 38 scatter gather elements
1424+ /*
1425+ * 38 scatter gather elements
13981426 */
13991427 dev->scsi_host_ptr->sg_tablesize =
14001428 (dev->max_fib_size -
@@ -1498,9 +1526,8 @@ static void io_callback(void *context, struct fib * fibptr) · 97 unmodified lines
14981526 ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0,
14991527 0, 0);
15001528 memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data,
1501− (sizeof(dev->fsa_dev[cid].sense_data) > sizeof(scsicmd->sense_buffer))
1502− ? sizeof(scsicmd->sense_buffer)
1503− : sizeof(dev->fsa_dev[cid].sense_data));
1529+ min_t(size_t, sizeof(dev->fsa_dev[cid].sense_data),
1530+ SCSI_SENSE_BUFFERSIZE));
15041531 }
15051532 aac_fib_complete(fibptr);
15061533 aac_fib_free(fibptr);
@@ -1524,7 +1551,7 @@ static int aac_read(struct scsi_cmnd * scsicmd) · 17 unmodified lines
15241551 case READ_6:
15251552 dprintk((KERN_DEBUG "aachba: received a read(6) command on id %d.\n", scmd_id(scsicmd)));
15261553
1527− lba = ((scsicmd->cmnd[1] & 0x1F) << 16) |
1554+ lba = ((scsicmd->cmnd[1] & 0x1F) << 16) |
15281555 (scsicmd->cmnd[2] << 8) | scsicmd->cmnd[3];
15291556 count = scsicmd->cmnd[4];
15301557
@@ -1534,32 +1561,32 @@ static int aac_read(struct scsi_cmnd * scsicmd) · 3 unmodified lines
15341561 case READ_16:
15351562 dprintk((KERN_DEBUG "aachba: received a read(16) command on id %d.\n", scmd_id(scsicmd)));
15361563
1537− lba = ((u64)scsicmd->cmnd[2] << 56) |
1538− ((u64)scsicmd->cmnd[3] << 48) |
1564+ lba = ((u64)scsicmd->cmnd[2] << 56) |
1565+ ((u64)scsicmd->cmnd[3] << 48) |
15391566 ((u64)scsicmd->cmnd[4] << 40) |
15401567 ((u64)scsicmd->cmnd[5] << 32) |
1541− ((u64)scsicmd->cmnd[6] << 24) |
1568+ ((u64)scsicmd->cmnd[6] << 24) |
15421569 (scsicmd->cmnd[7] << 16) |
15431570 (scsicmd->cmnd[8] << 8) | scsicmd->cmnd[9];
1544− count = (scsicmd->cmnd[10] << 24) |
1571+ count = (scsicmd->cmnd[10] << 24) |
15451572 (scsicmd->cmnd[11] << 16) |
15461573 (scsicmd->cmnd[12] << 8) | scsicmd->cmnd[13];
15471574 break;
15481575 case READ_12:
15491576 dprintk((KERN_DEBUG "aachba: received a read(12) command on id %d.\n", scmd_id(scsicmd)));
15501577
1551− lba = ((u64)scsicmd->cmnd[2] << 24) |
1578+ lba = ((u64)scsicmd->cmnd[2] << 24) |
15521579 (scsicmd->cmnd[3] << 16) |
1553− (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5];
1554− count = (scsicmd->cmnd[6] << 24) |
1580+ (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5];
1581+ count = (scsicmd->cmnd[6] << 24) |
15551582 (scsicmd->cmnd[7] << 16) |
1556− (scsicmd->cmnd[8] << 8) | scsicmd->cmnd[9];
1583+ (scsicmd->cmnd[8] << 8) | scsicmd->cmnd[9];
15571584 break;
15581585 default:
15591586 dprintk((KERN_DEBUG "aachba: received a read(10) command on id %d.\n", scmd_id(scsicmd)));
15601587
1561− lba = ((u64)scsicmd->cmnd[2] << 24) |
1562− (scsicmd->cmnd[3] << 16) |
1588+ lba = ((u64)scsicmd->cmnd[2] << 24) |
1589+ (scsicmd->cmnd[3] << 16) |
15631590 (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5];
15641591 count = (scsicmd->cmnd[7] << 8) | scsicmd->cmnd[8];
15651592 break;
@@ -1584,7 +1611,7 @@ static int aac_read(struct scsi_cmnd * scsicmd) · 18 unmodified lines
15841611 scsicmd->SCp.phase = AAC_OWNER_FIRMWARE;
15851612 return 0;
15861613 }
1587−
1614+
15881615 printk(KERN_WARNING "aac_read: aac_fib_send failed with status: %d.\n", status);
15891616 /*
15901617 * For some reason, the Fib didn't queue, return QUEUE_FULL
@@ -1619,11 +1646,11 @@ static int aac_write(struct scsi_cmnd * scsicmd) · 28 unmodified lines
16191646 } else if (scsicmd->cmnd[0] == WRITE_16) { /* 16 byte command */
16201647 dprintk((KERN_DEBUG "aachba: received a write(16) command on id %d.\n", scmd_id(scsicmd)));
16211648
1622− lba = ((u64)scsicmd->cmnd[2] << 56) |
1649+ lba = ((u64)scsicmd->cmnd[2] << 56) |
16231650 ((u64)scsicmd->cmnd[3] << 48) |
16241651 ((u64)scsicmd->cmnd[4] << 40) |
16251652 ((u64)scsicmd->cmnd[5] << 32) |
1626− ((u64)scsicmd->cmnd[6] << 24) |
1653+ ((u64)scsicmd->cmnd[6] << 24) |
16271654 (scsicmd->cmnd[7] << 16) |
16281655 (scsicmd->cmnd[8] << 8) | scsicmd->cmnd[9];
16291656 count = (scsicmd->cmnd[10] << 24) | (scsicmd->cmnd[11] << 16) |
@@ -1712,8 +1739,8 @@ static void synchronize_callback(void *context, struct fib *fibptr) · 82 unmodified lines
17121739 ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0,
17131740 0, 0);
17141741 memcpy(cmd->sense_buffer, &dev->fsa_dev[cid].sense_data,
1715− min(sizeof(dev->fsa_dev[cid].sense_data),
1716− sizeof(cmd->sense_buffer)));
1742+ min_t(size_t, sizeof(dev->fsa_dev[cid].sense_data),
1743+ SCSI_SENSE_BUFFERSIZE));
17171744 }
17181745
17191746 aac_fib_complete(fibptr);
@@ -1798,7 +1825,7 @@ static int aac_synchronize(struct scsi_cmnd *scsicmd) · 78 unmodified lines
17981825 if (active)
17991826 return SCSI_MLQUEUE_DEVICE_BUSY;
18001827
1801− aac = (struct aac_dev *)scsicmd->device->host->hostdata;
1828+ aac = (struct aac_dev *)sdev->host->hostdata;
18021829 if (aac->in_reset)
18031830 return SCSI_MLQUEUE_HOST_BUSY;
18041831
@@ -1850,14 +1877,14 @@ static int aac_synchronize(struct scsi_cmnd *scsicmd) · 45 unmodified lines
18501877 * Emulate a SCSI command and queue the required request for the
18511878 * aacraid firmware.
18521879 */
1853−
1880+
18541881 int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
18551882 {
18561883 u32 cid;
18571884 struct Scsi_Host *host = scsicmd->device->host;
18581885 struct aac_dev *dev = (struct aac_dev *)host->hostdata;
18591886 struct fsa_dev_info *fsa_dev_ptr = dev->fsa_dev;
1860−
1887+
18611888 if (fsa_dev_ptr == NULL)
18621889 return -1;
18631890 /*
@@ -1898,7 +1925,8 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd) · 34 unmodified lines
18981925 }
18991926 }
19001927 } else { /* check for physical non-dasd devices */
1901− if ((dev->nondasd_support == 1) || expose_physicals) {
1928+ if (dev->nondasd_support || expose_physicals ||
1929+ dev->jbod) {
19021930 if (dev->in_reset)
19031931 return -1;
19041932 return aac_send_srb_fib(scsicmd);
@@ -1913,7 +1941,7 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd) · 8 unmodified lines
19131941 * else Command for the controller itself
19141942 */
19151943 else if ((scsicmd->cmnd[0] != INQUIRY) && /* only INQUIRY & TUR cmnd supported for controller */
1916− (scsicmd->cmnd[0] != TEST_UNIT_READY))
1944+ (scsicmd->cmnd[0] != TEST_UNIT_READY))
19171945 {
19181946 dprintk((KERN_WARNING "Only INQUIRY & TUR command supported for controller, rcvd = 0x%x.\n", scsicmd->cmnd[0]));
19191947 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION;
@@ -1922,9 +1950,8 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd) · 2 unmodified lines
19221950 SENCODE_INVALID_COMMAND,
19231951 ASENCODE_INVALID_COMMAND, 0, 0, 0, 0);
19241952 memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data,
1925− (sizeof(dev->fsa_dev[cid].sense_data) > sizeof(scsicmd->sense_buffer))
1926− ? sizeof(scsicmd->sense_buffer)
1927− : sizeof(dev->fsa_dev[cid].sense_data));
1953+ min_t(size_t, sizeof(dev->fsa_dev[cid].sense_data),
1954+ SCSI_SENSE_BUFFERSIZE));
19281955 scsicmd->scsi_done(scsicmd);
19291956 return 0;
19301957 }
@@ -1939,7 +1966,7 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd) · 8 unmodified lines
19391966 dprintk((KERN_DEBUG "INQUIRY command, ID: %d.\n", cid));
19401967 memset(&inq_data, 0, sizeof (struct inquiry_data));
19411968
1942− if (scsicmd->cmnd[1] & 0x1 ) {
1969+ if (scsicmd->cmnd[1] & 0x1) {
19431970 char *arr = (char *)&inq_data;
19441971
19451972 /* EVPD bit set */
@@ -1974,10 +2001,9 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd) · 28 unmodified lines
19742001 ASENCODE_NO_SENSE, 0, 7, 2, 0);
19752002 memcpy(scsicmd->sense_buffer,
19762003 &dev->fsa_dev[cid].sense_data,
1977− (sizeof(dev->fsa_dev[cid].sense_data) >
1978− sizeof(scsicmd->sense_buffer))
1979− ? sizeof(scsicmd->sense_buffer)
1980− : sizeof(dev->fsa_dev[cid].sense_data));
2004+ min_t(size_t,
2005+ sizeof(dev->fsa_dev[cid].sense_data),
2006+ SCSI_SENSE_BUFFERSIZE));
19812007 }
19822008 scsicmd->scsi_done(scsicmd);
19832009 return 0;
@@ -2092,7 +2118,7 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd) · 108 unmodified lines
20922118 mode_buf[2] = 0; /* Device-specific param,
20932119 bit 8: 0/1 = write enabled/protected
20942120 bit 4: 0/1 = FUA enabled */
2095− if (dev->raw_io_interface)
2121+ if (dev->raw_io_interface && ((aac_cache & 5) != 1))
20962122 mode_buf[2] = 0x10;
20972123 mode_buf[3] = 0; /* Block descriptor length */
20982124 if (((scsicmd->cmnd[2] & 0x3f) == 8) ||
@@ -2100,7 +2126,8 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd) · 1 unmodified line
21002126 mode_buf[0] = 6;
21012127 mode_buf[4] = 8;
21022128 mode_buf[5] = 1;
2103− mode_buf[6] = 0x04; /* WCE */
2129+ mode_buf[6] = ((aac_cache & 6) == 2)
2130+ ? 0 : 0x04; /* WCE */
21042131 mode_buf_length = 7;
21052132 if (mode_buf_length > scsicmd->cmnd[4])
21062133 mode_buf_length = scsicmd->cmnd[4];
@@ -2123,7 +2150,7 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd) · 16 unmodified lines
21232150 mode_buf[3] = 0; /* Device-specific param,
21242151 bit 8: 0/1 = write enabled/protected
21252152 bit 4: 0/1 = FUA enabled */
2126− if (dev->raw_io_interface)
2153+ if (dev->raw_io_interface && ((aac_cache & 5) != 1))
21272154 mode_buf[3] = 0x10;
21282155 mode_buf[4] = 0; /* reserved */
21292156 mode_buf[5] = 0; /* reserved */
@@ -2134,7 +2161,8 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd) · 4 unmodified lines
21342161 mode_buf[1] = 9;
21352162 mode_buf[8] = 8;
21362163 mode_buf[9] = 1;
2137− mode_buf[10] = 0x04; /* WCE */
2164+ mode_buf[10] = ((aac_cache & 6) == 2)
2165+ ? 0 : 0x04; /* WCE */
21382166 mode_buf_length = 11;
21392167 if (mode_buf_length > scsicmd->cmnd[8])
21402168 mode_buf_length = scsicmd->cmnd[8];
@@ -2179,7 +2207,7 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd) · 38 unmodified lines
21792207 return 0;
21802208 }
21812209
2182− switch (scsicmd->cmnd[0])
2210+ switch (scsicmd->cmnd[0])
21832211 {
21842212 case READ_6:
21852213 case READ_10:
@@ -2192,11 +2220,11 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd) · 6 unmodified lines
21922220 * corresponds to a container. Needed to convert
21932221 * containers to /dev/sd device names
21942222 */
2195−
2223+
21962224 if (scsicmd->request->rq_disk)
21972225 strlcpy(fsa_dev_ptr[cid].devname,
21982226 scsicmd->request->rq_disk->disk_name,
2199− min(sizeof(fsa_dev_ptr[cid].devname),
2227+ min(sizeof(fsa_dev_ptr[cid].devname),
22002228 sizeof(scsicmd->request->rq_disk->disk_name) + 1));
22012229
22022230 return aac_read(scsicmd);
@@ -2210,9 +2238,16 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd) · 7 unmodified lines
22102238 return aac_write(scsicmd);
22112239
22122240 case SYNCHRONIZE_CACHE:
2241+ if (((aac_cache & 6) == 6) && dev->cache_protected) {
2242+ scsicmd->result = DID_OK << 16 |
2243+ COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
2244+ scsicmd->scsi_done(scsicmd);
2245+ return 0;
2246+ }
22132247 /* Issue FIB to tell Firmware to flush it's cache */
2214− return aac_synchronize(scsicmd);
2215−
2248+ if ((aac_cache & 6) != 2)
2249+ return aac_synchronize(scsicmd);
2250+ /* FALLTHRU */
22162251 default:
22172252 /*
22182253 * Unhandled commands
@@ -2223,9 +2258,9 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd) · 4 unmodified lines
22232258 ILLEGAL_REQUEST, SENCODE_INVALID_COMMAND,
22242259 ASENCODE_INVALID_COMMAND, 0, 0, 0, 0);
22252260 memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data,
2226− (sizeof(dev->fsa_dev[cid].sense_data) > sizeof(scsicmd->sense_buffer))
2227− ? sizeof(scsicmd->sense_buffer)
2228− : sizeof(dev->fsa_dev[cid].sense_data));
2261+ min_t(size_t,
2262+ sizeof(dev->fsa_dev[cid].sense_data),
2263+ SCSI_SENSE_BUFFERSIZE));
22292264 scsicmd->scsi_done(scsicmd);
22302265 return 0;
22312266 }
@@ -2243,7 +2278,7 @@ static int query_disk(struct aac_dev *dev, void __user *arg) · 11 unmodified lines
22432278 return -EFAULT;
22442279 if (qd.cnum == -1)
22452280 qd.cnum = qd.id;
2246− else if ((qd.bus == -1) && (qd.id == -1) && (qd.lun == -1))
2281+ else if ((qd.bus == -1) && (qd.id == -1) && (qd.lun == -1))
22472282 {
22482283 if (qd.cnum < 0 || qd.cnum >= dev->maximum_num_containers)
22492284 return -EINVAL;
@@ -2370,7 +2405,7 @@ static void aac_srb_callback(void *context, struct fib * fibptr) · 120 unmodified lines
23702405
23712406 scsicmd->sense_buffer[0] = '\0'; /* Initialize sense valid flag to false */
23722407 /*
2373− * Calculate resid for sg
2408+ * Calculate resid for sg
23742409 */
23752410
23762411 scsi_set_resid(scsicmd, scsi_bufflen(scsicmd)
@@ -2385,10 +2420,8 @@ static void aac_srb_callback(void *context, struct fib * fibptr) · 8 unmodified lines
23852420 if (le32_to_cpu(srbreply->status) != ST_OK){
23862421 int len;
23872422 printk(KERN_WARNING "aac_srb_callback: srb failed, status = %d\n", le32_to_cpu(srbreply->status));
2388− len = (le32_to_cpu(srbreply->sense_data_size) >
2389− sizeof(scsicmd->sense_buffer)) ?
2390− sizeof(scsicmd->sense_buffer) :
2391− le32_to_cpu(srbreply->sense_data_size);
2423+ len = min_t(u32, le32_to_cpu(srbreply->sense_data_size),
2424+ SCSI_SENSE_BUFFERSIZE);
23922425 scsicmd->result = DID_ERROR << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION;
23932426 memcpy(scsicmd->sense_buffer, srbreply->sense_data, len);
23942427 }
@@ -2412,7 +2445,7 @@ static void aac_srb_callback(void *context, struct fib * fibptr) · 17 unmodified lines
24122445 case WRITE_12:
24132446 case READ_16:
24142447 case WRITE_16:
2415− if(le32_to_cpu(srbreply->data_xfer_length) < scsicmd->underflow ) {
2448+ if (le32_to_cpu(srbreply->data_xfer_length) < scsicmd->underflow) {
24162449 printk(KERN_WARNING"aacraid: SCSI CMD underflow\n");
24172450 } else {
24182451 printk(KERN_WARNING"aacraid: SCSI CMD Data Overrun\n");
@@ -2481,26 +2514,23 @@ static void aac_srb_callback(void *context, struct fib * fibptr) · 62 unmodified lines
24812514 printk("aacraid: SRB ERROR(%u) %s scsi cmd 0x%x - scsi status 0x%x\n",
24822515 le32_to_cpu(srbreply->srb_status) & 0x3F,
24832516 aac_get_status_string(
2484− le32_to_cpu(srbreply->srb_status) & 0x3F),
2485− scsicmd->cmnd[0],
2517+ le32_to_cpu(srbreply->srb_status) & 0x3F),
2518+ scsicmd->cmnd[0],
24862519 le32_to_cpu(srbreply->scsi_status));
24872520 #endif
24882521 scsicmd->result = DID_ERROR << 16 | COMMAND_COMPLETE << 8;
24892522 break;
24902523 }
2491− if (le32_to_cpu(srbreply->scsi_status) == 0x02 ){ // Check Condition
2524+ if (le32_to_cpu(srbreply->scsi_status) == SAM_STAT_CHECK_CONDITION) {
24922525 int len;
24932526 scsicmd->result |= SAM_STAT_CHECK_CONDITION;
2494− len = (le32_to_cpu(srbreply->sense_data_size) >
2495− sizeof(scsicmd->sense_buffer)) ?
2496− sizeof(scsicmd->sense_buffer) :
2497− le32_to_cpu(srbreply->sense_data_size);
2527+ len = min_t(u32, le32_to_cpu(srbreply->sense_data_size),
2528+ SCSI_SENSE_BUFFERSIZE);
24982529 #ifdef AAC_DETAILED_STATUS_INFO
24992530 printk(KERN_WARNING "aac_srb_callback: check condition, status = %d len=%d\n",
25002531 le32_to_cpu(srbreply->status), len);
25012532 #endif
25022533 memcpy(scsicmd->sense_buffer, srbreply->sense_data, len);
2503−
25042534 }
25052535 /*
25062536 * OR in the scsi status (already shifted up a bit)
@@ -2517,7 +2547,7 @@ static void aac_srb_callback(void *context, struct fib * fibptr) · 10 unmodified lines
25172547 * aac_send_scb_fib
25182548 * @scsicmd: the scsi command block
25192549 *
2520− * This routine will form a FIB and fill in the aac_srb from the
2550+ * This routine will form a FIB and fill in the aac_srb from the
25212551 * scsicmd passed in.
25222552 */
25232553
@@ -2731,7 +2761,7 @@ static struct aac_srb_status_info srb_status_info[] = { · 207 unmodified lines
27312761 { SRB_STATUS_ERROR_RECOVERY, "Error Recovery"},
27322762 { SRB_STATUS_NOT_STARTED, "Not Started"},
27332763 { SRB_STATUS_NOT_IN_USE, "Not In Use"},
2734− { SRB_STATUS_FORCE_ABORT, "Force Abort"},
2764+ { SRB_STATUS_FORCE_ABORT, "Force Abort"},
27352765 { SRB_STATUS_DOMAIN_VALIDATION_FAIL,"Domain Validation Failure"},
27362766 { 0xff, "Unknown Error"}
27372767 };
drivers/scsi/aacraid/aacraid.h+174−161
@@ -1,4 +1,4 @@
1−#if (!defined(dprintk))
1+#ifndef dprintk
22 # define dprintk(x)
33 #endif
44 /* eg: if (nblank(dprintk(x))) */
@@ -12,7 +12,7 @@ · 7 unmodified lines
1212 *----------------------------------------------------------------------------*/
1313
1414 #ifndef AAC_DRIVER_BUILD
15−# define AAC_DRIVER_BUILD 2449
15+# define AAC_DRIVER_BUILD 2455
1616 # define AAC_DRIVER_BRANCH "-ms"
1717 #endif
1818 #define MAXIMUM_NUM_CONTAINERS 32
@@ -50,9 +50,9 @@ struct diskparm · 31 unmodified lines
5050 /*
5151 * Firmware constants
5252 */
53−
53+
5454 #define CT_NONE 0
55−#define CT_OK 218
55+#define CT_OK 218
5656 #define FT_FILESYS 8 /* ADAPTEC's "FSA"(tm) filesystem */
5757 #define FT_DRIVE 9 /* physical disk - addressable in scsi by bus/id/lun */
5858
@@ -107,12 +107,12 @@ struct user_sgentryraw { · 48 unmodified lines
107107
108108 struct sgmap {
109109 __le32 count;
110− struct sgentry sg[1];
110+ struct sgentry sg[1];
111111 };
112112
113113 struct user_sgmap {
114114 u32 count;
115− struct user_sgentry sg[1];
115+ struct user_sgentry sg[1];
116116 };
117117
118118 struct sgmap64 {
@@ -137,18 +137,18 @@ struct user_sgmapraw { · 18 unmodified lines
137137
138138 struct creation_info
139139 {
140− u8 buildnum; /* e.g., 588 */
141− u8 usec; /* e.g., 588 */
142− u8 via; /* e.g., 1 = FSU,
143− * 2 = API
140+ u8 buildnum; /* e.g., 588 */
141+ u8 usec; /* e.g., 588 */
142+ u8 via; /* e.g., 1 = FSU,
143+ * 2 = API
144144 */
145− u8 year; /* e.g., 1997 = 97 */
145+ u8 year; /* e.g., 1997 = 97 */
146146 __le32 date; /*
147− * unsigned Month :4; // 1 - 12
148− * unsigned Day :6; // 1 - 32
149− * unsigned Hour :6; // 0 - 23
150− * unsigned Minute :6; // 0 - 60
151− * unsigned Second :6; // 0 - 60
147+ * unsigned Month :4; // 1 - 12
148+ * unsigned Day :6; // 1 - 32
149+ * unsigned Hour :6; // 0 - 23
150+ * unsigned Minute :6; // 0 - 60
151+ * unsigned Second :6; // 0 - 60
152152 */
153153 __le32 serial[2]; /* e.g., 0x1DEADB0BFAFAF001 */
154154 };
@@ -184,7 +184,7 @@ struct creation_info · 29 unmodified lines
184184 /*
185185 * Set the queues on a 16 byte alignment
186186 */
187−
187+
188188 #define QUEUE_ALIGNMENT 16
189189
190190 /*
@@ -203,9 +203,9 @@ struct aac_entry { · 12 unmodified lines
203203 * The adapter assumes the ProducerIndex and ConsumerIndex are grouped
204204 * adjacently and in that order.
205205 */
206−
206+
207207 struct aac_qhdr {
208− __le64 header_addr;/* Address to hand the adapter to access
208+ __le64 header_addr;/* Address to hand the adapter to access
209209 to this queue head */
210210 __le32 *producer; /* The producer index for this queue (host address) */
211211 __le32 *consumer; /* The consumer index for this queue (host address) */
@@ -215,7 +215,7 @@ struct aac_qhdr { · 3 unmodified lines
215215 * Define all the events which the adapter would like to notify
216216 * the host of.
217217 */
218−
218+
219219 #define HostNormCmdQue 1 /* Change in host normal priority command queue */
220220 #define HostHighCmdQue 2 /* Change in host high priority command queue */
221221 #define HostNormRespQue 3 /* Change in host normal priority response queue */
@@ -286,17 +286,17 @@ struct aac_fibhdr { · 64 unmodified lines
286286 u8 StructType; /* Type FIB */
287287 u8 Flags; /* Flags for FIB */
288288 __le16 Size; /* Size of this FIB in bytes */
289− __le16 SenderSize; /* Size of the FIB in the sender
289+ __le16 SenderSize; /* Size of the FIB in the sender
290290 (for response sizing) */
291291 __le32 SenderFibAddress; /* Host defined data in the FIB */
292− __le32 ReceiverFibAddress;/* Logical address of this FIB for
292+ __le32 ReceiverFibAddress;/* Logical address of this FIB for
293293 the adapter */
294294 u32 SenderData; /* Place holder for the sender to store data */
295295 union {
296296 struct {
297− __le32 _ReceiverTimeStart; /* Timestamp for
297+ __le32 _ReceiverTimeStart; /* Timestamp for
298298 receipt of fib */
299− __le32 _ReceiverTimeDone; /* Timestamp for
299+ __le32 _ReceiverTimeDone; /* Timestamp for
300300 completion of fib */
301301 } _s;
302302 } _u;
@@ -311,7 +311,7 @@ struct hw_fib { · 8 unmodified lines
311311 * FIB commands
312312 */
313313
314−#define TestCommandResponse 1
314+#define TestCommandResponse 1
315315 #define TestAdapterCommand 2
316316 /*
317317 * Lowlevel and comm commands
@@ -349,10 +349,6 @@ struct hw_fib { · 31 unmodified lines
349349 #define ContainerCommand 500
350350 #define ContainerCommand64 501
351351 #define ContainerRawIo 502
352−/*
353− * Cluster Commands
354− */
355−#define ClusterCommand 550
356352 /*
357353 * Scsi Port commands (scsi passthrough)
358354 */
@@ -375,19 +371,19 @@ struct hw_fib { · 16 unmodified lines
375371 */
376372
377373 enum fib_xfer_state {
378− HostOwned = (1<<0),
379− AdapterOwned = (1<<1),
380− FibInitialized = (1<<2),
381− FibEmpty = (1<<3),
382− AllocatedFromPool = (1<<4),
383− SentFromHost = (1<<5),
384− SentFromAdapter = (1<<6),
385− ResponseExpected = (1<<7),
386− NoResponseExpected = (1<<8),
387− AdapterProcessed = (1<<9),
388− HostProcessed = (1<<10),
389− HighPriority = (1<<11),
390− NormalPriority = (1<<12),
374+ HostOwned = (1<<0),
375+ AdapterOwned = (1<<1),
376+ FibInitialized = (1<<2),
377+ FibEmpty = (1<<3),
378+ AllocatedFromPool = (1<<4),
379+ SentFromHost = (1<<5),
380+ SentFromAdapter = (1<<6),
381+ ResponseExpected = (1<<7),
382+ NoResponseExpected = (1<<8),
383+ AdapterProcessed = (1<<9),
384+ HostProcessed = (1<<10),
385+ HighPriority = (1<<11),
386+ NormalPriority = (1<<12),
391387 Async = (1<<13),
392388 AsyncIo = (1<<13), // rpbfix: remove with new regime
393389 PageFileIo = (1<<14), // rpbfix: remove with new regime
@@ -420,7 +416,7 @@ struct aac_init · 26 unmodified lines
420416 __le32 AdapterFibAlign;
421417 __le32 printfbuf;
422418 __le32 printfbufsiz;
423− __le32 HostPhysMemPages; /* number of 4k pages of host
419+ __le32 HostPhysMemPages; /* number of 4k pages of host
424420 physical memory */
425421 __le32 HostElapsedSeconds; /* number of seconds since 1970. */
426422 /*
@@ -481,7 +477,7 @@ struct adapter_ops · 54 unmodified lines
481477
482478 struct aac_driver_ident
483479 {
484− int (*init)(struct aac_dev *dev);
480+ int (*init)(struct aac_dev *dev);
485481 char * name;
486482 char * vname;
487483 char * model;
@@ -489,7 +485,7 @@ struct aac_driver_ident · 1 unmodified line
489485 int quirks;
490486 };
491487 /*
492− * Some adapter firmware needs communication memory
488+ * Some adapter firmware needs communication memory
493489 * below 2gig. This tells the init function to set the
494490 * dma mask such that fib memory will be allocated where the
495491 * adapter firmware can get to it.
@@ -520,34 +516,40 @@ struct aac_driver_ident · 24 unmodified lines
520516 */
521517 #define AAC_QUIRK_17SG 0x0010
522518
519+/*
520+ * Some adapter firmware does not support 64 bit scsi passthrough
521+ * commands.
522+ */
523+#define AAC_QUIRK_SCSI_32 0x0020
524+
523525 /*
524526 * The adapter interface specs all queues to be located in the same
525527 * physically contigous block. The host structure that defines the
526528 * commuication queues will assume they are each a separate physically
527529 * contigous memory region that will support them all being one big
528− * contigous block.
530+ * contigous block.
529531 * There is a command and response queue for each level and direction of
530532 * commuication. These regions are accessed by both the host and adapter.
531533 */
532−
534+
533535 struct aac_queue {
534− u64 logical; /*address we give the adapter */
536+ u64 logical; /*address we give the adapter */
535537 struct aac_entry *base; /*system virtual address */
536− struct aac_qhdr headers; /*producer,consumer q headers*/
537− u32 entries; /*Number of queue entries */
538+ struct aac_qhdr headers; /*producer,consumer q headers*/
539+ u32 entries; /*Number of queue entries */
538540 wait_queue_head_t qfull; /*Event to wait on if q full */
539541 wait_queue_head_t cmdready; /*Cmd ready from the adapter */
540− /* This is only valid for adapter to host command queues. */
541− spinlock_t *lock; /* Spinlock for this queue must take this lock before accessing the lock */
542+ /* This is only valid for adapter to host command queues. */
543+ spinlock_t *lock; /* Spinlock for this queue must take this lock before accessing the lock */
542544 spinlock_t lockdata; /* Actual lock (used only on one side of the lock) */
543− struct list_head cmdq; /* A queue of FIBs which need to be prcessed by the FS thread. This is */
544− /* only valid for command queues which receive entries from the adapter. */
545+ struct list_head cmdq; /* A queue of FIBs which need to be prcessed by the FS thread. This is */
546+ /* only valid for command queues which receive entries from the adapter. */
545547 u32 numpending; /* Number of entries on outstanding queue. */
546548 struct aac_dev * dev; /* Back pointer to adapter structure */
547549 };
548550
549551 /*
550− * Message queues. The order here is important, see also the
552+ * Message queues. The order here is important, see also the
551553 * queue type ordering
552554 */
553555
@@ -559,12 +561,12 @@ struct aac_queue_block · 5 unmodified lines
559561 /*
560562 * SaP1 Message Unit Registers
561563 */
562−
564+
563565 struct sa_drawbridge_CSR {
564− /* Offset | Name */
566+ /* Offset | Name */
565567 __le32 reserved[10]; /* 00h-27h | Reserved */
566568 u8 LUT_Offset; /* 28h | Lookup Table Offset */
567− u8 reserved1[3]; /* 29h-2bh | Reserved */
569+ u8 reserved1[3]; /* 29h-2bh | Reserved */
568570 __le32 LUT_Data; /* 2ch | Looup Table Data */
569571 __le32 reserved2[26]; /* 30h-97h | Reserved */
570572 __le16 PRICLEARIRQ; /* 98h | Primary Clear Irq */
@@ -583,8 +585,8 @@ struct sa_drawbridge_CSR { · 12 unmodified lines
583585 __le32 MAILBOX5; /* bch | Scratchpad 5 */
584586 __le32 MAILBOX6; /* c0h | Scratchpad 6 */
585587 __le32 MAILBOX7; /* c4h | Scratchpad 7 */
586− __le32 ROM_Setup_Data; /* c8h | Rom Setup and Data */
587− __le32 ROM_Control_Addr;/* cch | Rom Control and Address */
588+ __le32 ROM_Setup_Data; /* c8h | Rom Setup and Data */
589+ __le32 ROM_Control_Addr;/* cch | Rom Control and Address */
588590 __le32 reserved3[12]; /* d0h-ffh | reserved */
589591 __le32 LUT[64]; /* 100h-1ffh | Lookup Table Entries */
590592 };
@@ -597,7 +599,7 @@ struct sa_drawbridge_CSR { · 6 unmodified lines
597599 #define Mailbox5 SaDbCSR.MAILBOX5
598600 #define Mailbox6 SaDbCSR.MAILBOX6
599601 #define Mailbox7 SaDbCSR.MAILBOX7
600−
602+
601603 #define DoorbellReg_p SaDbCSR.PRISETIRQ
602604 #define DoorbellReg_s SaDbCSR.SECSETIRQ
603605 #define DoorbellClrReg_p SaDbCSR.PRICLEARIRQ
@@ -611,19 +613,19 @@ struct sa_drawbridge_CSR { · 7 unmodified lines
611613 #define DOORBELL_5 0x0020
612614 #define DOORBELL_6 0x0040
613615
614−
616+
615617 #define PrintfReady DOORBELL_5
616618 #define PrintfDone DOORBELL_5
617−
619+
618620 struct sa_registers {
619621 struct sa_drawbridge_CSR SaDbCSR; /* 98h - c4h */
620622 };
621−
623+
622624
623625 #define Sa_MINIPORT_REVISION 1
624626
625627 #define sa_readw(AEP, CSR) readl(&((AEP)->regs.sa->CSR))
626−#define sa_readl(AEP, CSR) readl(&((AEP)->regs.sa->CSR))
628+#define sa_readl(AEP, CSR) readl(&((AEP)->regs.sa->CSR))
627629 #define sa_writew(AEP, CSR, value) writew(value, &((AEP)->regs.sa->CSR))
628630 #define sa_writel(AEP, CSR, value) writel(value, &((AEP)->regs.sa->CSR))
629631
@@ -640,21 +642,21 @@ struct rx_mu_registers { · 10 unmodified lines
640642 __le32 IMRx[2]; /* 1310h | 10h | Inbound Message Registers */
641643 __le32 OMRx[2]; /* 1318h | 18h | Outbound Message Registers */
642644 __le32 IDR; /* 1320h | 20h | Inbound Doorbell Register */
643− __le32 IISR; /* 1324h | 24h | Inbound Interrupt
645+ __le32 IISR; /* 1324h | 24h | Inbound Interrupt
644646 Status Register */
645− __le32 IIMR; /* 1328h | 28h | Inbound Interrupt
646− Mask Register */
647+ __le32 IIMR; /* 1328h | 28h | Inbound Interrupt
648+ Mask Register */
647649 __le32 ODR; /* 132Ch | 2Ch | Outbound Doorbell Register */
648− __le32 OISR; /* 1330h | 30h | Outbound Interrupt
650+ __le32 OISR; /* 1330h | 30h | Outbound Interrupt
649651 Status Register */
650− __le32 OIMR; /* 1334h | 34h | Outbound Interrupt
652+ __le32 OIMR; /* 1334h | 34h | Outbound Interrupt
651653 Mask Register */
652654 __le32 reserved2; /* 1338h | 38h | Reserved */
653655 __le32 reserved3; /* 133Ch | 3Ch | Reserved */
654656 __le32 InboundQueue;/* 1340h | 40h | Inbound Queue Port relative to firmware */
655657 __le32 OutboundQueue;/*1344h | 44h | Outbound Queue Port relative to firmware */
656− /* * Must access through ATU Inbound
657− Translation Window */
658+ /* * Must access through ATU Inbound
659+ Translation Window */
658660 };
659661
660662 struct rx_inbound {
@@ -710,12 +712,12 @@ struct rkt_registers { · 49 unmodified lines
710712 typedef void (*fib_callback)(void *ctxt, struct fib *fibctx);
711713
712714 struct aac_fib_context {
713− s16 type; // used for verification of structure
714− s16 size;
715+ s16 type; // used for verification of structure
716+ s16 size;
715717 u32 unique; // unique value representing this context
716718 ulong jiffies; // used for cleanup - dmb changed to ulong
717719 struct list_head next; // used to link context's into a linked list
718− struct semaphore wait_sem; // this is used to wait for the next fib to arrive.
720+ struct semaphore wait_sem; // this is used to wait for the next fib to arrive.
719721 int wait; // Set to true when thread is in WaitForSingleObject
720722 unsigned long count; // total number of FIBs on FibList
721723 struct list_head fib_list; // this holds fibs and their attachd hw_fibs
@@ -734,9 +736,9 @@ struct sense_data { · 12 unmodified lines
734736 u8 EOM:1; /* End Of Medium - reserved for random access devices */
735737 u8 filemark:1; /* Filemark - reserved for random access devices */
736738
737− u8 information[4]; /* for direct-access devices, contains the unsigned
738− * logical block address or residue associated with
739− * the sense key
739+ u8 information[4]; /* for direct-access devices, contains the unsigned
740+ * logical block address or residue associated with
741+ * the sense key
740742 */
741743 u8 add_sense_len; /* number of additional sense bytes to follow this field */
742744 u8 cmnd_info[4]; /* not used */
@@ -746,7 +748,7 @@ struct sense_data { · 3 unmodified lines
746748 u8 bit_ptr:3; /* indicates which byte of the CDB or parameter data
747749 * was in error
748750 */
749− u8 BPV:1; /* bit pointer valid (BPV): 1- indicates that
751+ u8 BPV:1; /* bit pointer valid (BPV): 1- indicates that
750752 * the bit_ptr field has valid value
751753 */
752754 u8 reserved2:2;
@@ -780,24 +782,24 @@ struct fib { · 27 unmodified lines
780782 /*
781783 * The Adapter that this I/O is destined for.
782784 */
783− struct aac_dev *dev;
785+ struct aac_dev *dev;
784786 /*
785787 * This is the event the sendfib routine will wait on if the
786788 * caller did not pass one and this is synch io.
787789 */
788− struct semaphore event_wait;
790+ struct semaphore event_wait;
789791 spinlock_t event_lock;
790792
791793 u32 done; /* gets set to 1 when fib is complete */
792− fib_callback callback;
793− void *callback_data;
794+ fib_callback callback;
795+ void *callback_data;
794796 u32 flags; // u32 dmb was ulong
795797 /*
796798 * And for the internal issue/reply queues (we may be able
797799 * to merge these two)
798800 */
799801 struct list_head fiblink;
800− void *data;
802+ void *data;
801803 struct hw_fib *hw_fib_va; /* Actual shared object */
802804 dma_addr_t hw_fib_pa; /* physical address of hw_fib*/
803805 };
@@ -807,7 +809,7 @@ struct fib { · 3 unmodified lines
807809 *
808810 * This is returned by the RequestAdapterInfo block
809811 */
810−
812+
811813 struct aac_adapter_info
812814 {
813815 __le32 platform;
@@ -826,7 +828,7 @@ struct aac_adapter_info · 12 unmodified lines
826828 __le32 biosrev;
827829 __le32 biosbuild;
828830 __le32 cluster;
829− __le32 clusterchannelmask;
831+ __le32 clusterchannelmask;
830832 __le32 serial[2];
831833 __le32 battery;
832834 __le32 options;
@@ -863,9 +865,10 @@ struct aac_supplement_adapter_info · 30 unmodified lines
863865 __le32 SupportedOptions2;
864866 __le32 ReservedGrowth[1];
865867 };
866−#define AAC_FEATURE_FALCON 0x00000010
867−#define AAC_OPTION_MU_RESET 0x00000001
868−#define AAC_OPTION_IGNORE_RESET 0x00000002
868+#define AAC_FEATURE_FALCON cpu_to_le32(0x00000010)
869+#define AAC_FEATURE_JBOD cpu_to_le32(0x08000000)
870+#define AAC_OPTION_MU_RESET cpu_to_le32(0x00000001)
871+#define AAC_OPTION_IGNORE_RESET cpu_to_le32(0x00000002)
869872 #define AAC_SIS_VERSION_V3 3
870873 #define AAC_SIS_SLOT_UNKNOWN 0xFF
871874
@@ -916,13 +919,13 @@ struct aac_bus_info_response { · 44 unmodified lines
916919 #define AAC_OPT_HOST_TIME_FIB cpu_to_le32(1<<4)
917920 #define AAC_OPT_RAID50 cpu_to_le32(1<<5)
918921 #define AAC_OPT_4GB_WINDOW cpu_to_le32(1<<6)
919−#define AAC_OPT_SCSI_UPGRADEABLE cpu_to_le32(1<<7)
922+#define AAC_OPT_SCSI_UPGRADEABLE cpu_to_le32(1<<7)
920923 #define AAC_OPT_SOFT_ERR_REPORT cpu_to_le32(1<<8)
921−#define AAC_OPT_SUPPORTED_RECONDITION cpu_to_le32(1<<9)
924+#define AAC_OPT_SUPPORTED_RECONDITION cpu_to_le32(1<<9)
922925 #define AAC_OPT_SGMAP_HOST64 cpu_to_le32(1<<10)
923926 #define AAC_OPT_ALARM cpu_to_le32(1<<11)
924927 #define AAC_OPT_NONDASD cpu_to_le32(1<<12)
925−#define AAC_OPT_SCSI_MANAGED cpu_to_le32(1<<13)
928+#define AAC_OPT_SCSI_MANAGED cpu_to_le32(1<<13)
926929 #define AAC_OPT_RAID_SCSI_MODE cpu_to_le32(1<<14)
927930 #define AAC_OPT_SUPPLEMENT_ADAPTER_INFO cpu_to_le32(1<<16)
928931 #define AAC_OPT_NEW_COMM cpu_to_le32(1<<17)
@@ -942,7 +945,7 @@ struct aac_dev · 13 unmodified lines
942945
943946 /*
944947 * Map for 128 fib objects (64k)
945− */
948+ */
946949 dma_addr_t hw_fib_pa;
947950 struct hw_fib *hw_fib_va;
948951 struct hw_fib *aif_base_va;
@@ -953,24 +956,24 @@ struct aac_dev · 4 unmodified lines
953956
954957 struct fib *free_fib;
955958 spinlock_t fib_lock;
956−
959+
957960 struct aac_queue_block *queues;
958961 /*
959962 * The user API will use an IOCTL to register itself to receive
960963 * FIBs from the adapter. The following list is used to keep
961964 * track of all the threads that have requested these FIBs. The
962− * mutex is used to synchronize access to all data associated
965+ * mutex is used to synchronize access to all data associated
963966 * with the adapter fibs.
964967 */
965968 struct list_head fib_list;
966969
967970 struct adapter_ops a_ops;
968971 unsigned long fsrev; /* Main driver's revision number */
969−
972+
970973 unsigned base_size; /* Size of mapped in region */
971974 struct aac_init *init; /* Holds initialization info to communicate with adapter */
972− dma_addr_t init_pa; /* Holds physical address of the init struct */
973−
975+ dma_addr_t init_pa; /* Holds physical address of the init struct */
976+
974977 struct pci_dev *pdev; /* Our PCI interface */
975978 void * printfbuf; /* pointer to buffer used for printf's from the adapter */
976979 void * comm_addr; /* Base address of Comm area */
@@ -984,11 +987,11 @@ struct aac_dev · 7 unmodified lines
984987 struct fsa_dev_info *fsa_dev;
985988 struct task_struct *thread;
986989 int cardtype;
987−
990+
988991 /*
989992 * The following is the device specific extension.
990993 */
991−#if (!defined(AAC_MIN_FOOTPRINT_SIZE))
994+#ifndef AAC_MIN_FOOTPRINT_SIZE
992995 # define AAC_MIN_FOOTPRINT_SIZE 8192
993996 #endif
994997 union
@@ -1009,7 +1012,9 @@ struct aac_dev · 14 unmodified lines
10091012 /* These are in adapter info but they are in the io flow so
10101013 * lets break them out so we don't have to do an AND to check them
10111014 */
1012− u8 nondasd_support;
1015+ u8 nondasd_support;
1016+ u8 jbod;
1017+ u8 cache_protected;
10131018 u8 dac_support;
10141019 u8 raid_scsi_mode;
10151020 u8 comm_interface;
@@ -1066,18 +1071,19 @@ struct aac_dev · 50 unmodified lines
10661071 (dev)->a_ops.adapter_comm(dev, comm)
10671072
10681073 #define FIB_CONTEXT_FLAG_TIMED_OUT (0x00000001)
1074+#define FIB_CONTEXT_FLAG (0x00000002)
10691075
10701076 /*
10711077 * Define the command values
10721078 */
1073−
1079+
10741080 #define Null 0
1075−#define GetAttributes 1
1076−#define SetAttributes 2
1077−#define Lookup 3
1078−#define ReadLink 4
1079−#define Read 5
1080−#define Write 6
1081+#define GetAttributes 1
1082+#define SetAttributes 2
1083+#define Lookup 3
1084+#define ReadLink 4
1085+#define Read 5
1086+#define Write 6
10811087 #define Create 7
10821088 #define MakeDirectory 8
10831089 #define SymbolicLink 9
@@ -1173,19 +1179,19 @@ struct aac_dev · 89 unmodified lines
11731179
11741180 struct aac_read
11751181 {
1176− __le32 command;
1177− __le32 cid;
1178− __le32 block;
1179− __le32 count;
1182+ __le32 command;
1183+ __le32 cid;
1184+ __le32 block;
1185+ __le32 count;
11801186 struct sgmap sg; // Must be last in struct because it is variable
11811187 };
11821188
11831189 struct aac_read64
11841190 {
1185− __le32 command;
1186− __le16 cid;
1187− __le16 sector_count;
1188− __le32 block;
1191+ __le32 command;
1192+ __le16 cid;
1193+ __le16 sector_count;
1194+ __le32 block;
11891195 __le16 pad;
11901196 __le16 flags;
11911197 struct sgmap64 sg; // Must be last in struct because it is variable
@@ -1193,26 +1199,26 @@ struct aac_read64 · 1 unmodified line
11931199
11941200 struct aac_read_reply
11951201 {
1196− __le32 status;
1197− __le32 count;
1202+ __le32 status;
1203+ __le32 count;
11981204 };
11991205
12001206 struct aac_write
12011207 {
12021208 __le32 command;
1203− __le32 cid;
1204− __le32 block;
1205− __le32 count;
1206− __le32 stable; // Not used
1209+ __le32 cid;
1210+ __le32 block;
1211+ __le32 count;
1212+ __le32 stable; // Not used
12071213 struct sgmap sg; // Must be last in struct because it is variable
12081214 };
12091215
12101216 struct aac_write64
12111217 {
1212− __le32 command;
1213− __le16 cid;
1214− __le16 sector_count;
1215− __le32 block;
1218+ __le32 command;
1219+ __le16 cid;
1220+ __le16 sector_count;
1221+ __le32 block;
12161222 __le16 pad;
12171223 __le16 flags;
12181224 #define IO_TYPE_WRITE 0x00000000
@@ -1223,7 +1229,7 @@ struct aac_write64 · 4 unmodified lines
12231229 struct aac_write_reply
12241230 {
12251231 __le32 status;
1226− __le32 count;
1232+ __le32 count;
12271233 __le32 committed;
12281234 };
12291235
@@ -1326,10 +1332,10 @@ struct aac_srb_reply · 96 unmodified lines
13261332 #define SRB_NoDataXfer 0x0000
13271333 #define SRB_DisableDisconnect 0x0004
13281334 #define SRB_DisableSynchTransfer 0x0008
1329−#define SRB_BypassFrozenQueue 0x0010
1335+#define SRB_BypassFrozenQueue 0x0010
13301336 #define SRB_DisableAutosense 0x0020
13311337 #define SRB_DataIn 0x0040
1332−#define SRB_DataOut 0x0080
1338+#define SRB_DataOut 0x0080
13331339
13341340 /*
13351341 * SRB Functions - set in aac_srb->function
@@ -1352,7 +1358,7 @@ struct aac_srb_reply · 16 unmodified lines
13521358 #define SRBF_RemoveDevice 0x0016
13531359 #define SRBF_DomainValidation 0x0017
13541360
1355−/*
1361+/*
13561362 * SRB SCSI Status - set in aac_srb->scsi_status
13571363 */
13581364 #define SRB_STATUS_PENDING 0x00
@@ -1511,17 +1517,17 @@ struct aac_get_container_count_resp { · 152 unmodified lines
15111517 */
15121518
15131519 struct aac_mntent {
1514− __le32 oid;
1520+ __le32 oid;
15151521 u8 name[16]; /* if applicable */
15161522 struct creation_info create_info; /* if applicable */
15171523 __le32 capacity;
1518− __le32 vol; /* substrate structure */
1519− __le32 obj; /* FT_FILESYS, etc. */
1520− __le32 state; /* unready for mounting,
1524+ __le32 vol; /* substrate structure */
1525+ __le32 obj; /* FT_FILESYS, etc. */
1526+ __le32 state; /* unready for mounting,
15211527 readonly, etc. */
1522− union aac_contentinfo fileinfo; /* Info specific to content
1528+ union aac_contentinfo fileinfo; /* Info specific to content
15231529 manager (eg, filesystem) */
1524− __le32 altoid; /* != oid <==> snapshot or
1530+ __le32 altoid; /* != oid <==> snapshot or
15251531 broken mirror exists */
15261532 __le32 capacityhigh;
15271533 };
@@ -1538,7 +1544,7 @@ struct aac_query_mount { · 10 unmodified lines
15381544
15391545 struct aac_mount {
15401546 __le32 status;
1541− __le32 type; /* should be same as that requested */
1547+ __le32 type; /* should be same as that requested */
15421548 __le32 count;
15431549 struct aac_mntent mnt[1];
15441550 };
@@ -1608,7 +1614,7 @@ struct aac_delete_disk { · 63 unmodified lines
16081614 u32 disknum;
16091615 u32 cnum;
16101616 };
1611−
1617+
16121618 struct fib_ioctl
16131619 {
16141620 u32 fibctx;
@@ -1622,10 +1628,10 @@ struct revision · 7 unmodified lines
16221628 __le32 version;
16231629 __le32 build;
16241630 };
1625−
1631+
16261632
16271633 /*
1628− * Ugly - non Linux like ioctl coding for back compat.
1634+ * Ugly - non Linux like ioctl coding for back compat.
16291635 */
16301636
16311637 #define CTL_CODE(function, method) ( \
@@ -1633,7 +1639,7 @@ struct revision · 1 unmodified line
16331639 )
16341640
16351641 /*
1636− * Define the method codes for how buffers are passed for I/O and FS
1642+ * Define the method codes for how buffers are passed for I/O and FS
16371643 * controls
16381644 */
16391645
@@ -1644,15 +1650,15 @@ struct revision · 4 unmodified lines
16441650 * Filesystem ioctls
16451651 */
16461652
1647−#define FSACTL_SENDFIB CTL_CODE(2050, METHOD_BUFFERED)
1648−#define FSACTL_SEND_RAW_SRB CTL_CODE(2067, METHOD_BUFFERED)
1653+#define FSACTL_SENDFIB CTL_CODE(2050, METHOD_BUFFERED)
1654+#define FSACTL_SEND_RAW_SRB CTL_CODE(2067, METHOD_BUFFERED)
16491655 #define FSACTL_DELETE_DISK 0x163
16501656 #define FSACTL_QUERY_DISK 0x173
16511657 #define FSACTL_OPEN_GET_ADAPTER_FIB CTL_CODE(2100, METHOD_BUFFERED)
16521658 #define FSACTL_GET_NEXT_ADAPTER_FIB CTL_CODE(2101, METHOD_BUFFERED)
16531659 #define FSACTL_CLOSE_GET_ADAPTER_FIB CTL_CODE(2102, METHOD_BUFFERED)
16541660 #define FSACTL_MINIPORT_REV_CHECK CTL_CODE(2107, METHOD_BUFFERED)
1655−#define FSACTL_GET_PCI_INFO CTL_CODE(2119, METHOD_BUFFERED)
1661+#define FSACTL_GET_PCI_INFO CTL_CODE(2119, METHOD_BUFFERED)
16561662 #define FSACTL_FORCE_DELETE_DISK CTL_CODE(2120, METHOD_NEITHER)
16571663 #define FSACTL_GET_CONTAINERS 2131
16581664 #define FSACTL_SEND_LARGE_FIB CTL_CODE(2138, METHOD_BUFFERED)
@@ -1661,7 +1667,7 @@ struct revision · 2 unmodified lines
16611667 struct aac_common
16621668 {
16631669 /*
1664− * If this value is set to 1 then interrupt moderation will occur
1670+ * If this value is set to 1 then interrupt moderation will occur
16651671 * in the base commuication support.
16661672 */
16671673 u32 irq_mod;
@@ -1690,11 +1696,11 @@ extern struct aac_common aac_config; · 22 unmodified lines
16901696 * The following macro is used when sending and receiving FIBs. It is
16911697 * only used for debugging.
16921698 */
1693−
1699+
16941700 #ifdef DBG
16951701 #define FIB_COUNTER_INCREMENT(counter) (counter)++
16961702 #else
1697−#define FIB_COUNTER_INCREMENT(counter)
1703+#define FIB_COUNTER_INCREMENT(counter)
16981704 #endif
16991705
17001706 /*
@@ -1726,17 +1732,17 @@ extern struct aac_common aac_config; · 25 unmodified lines
17261732 *
17271733 * The adapter reports is present state through the phase. Only
17281734 * a single phase should be ever be set. Each phase can have multiple
1729− * phase status bits to provide more detailed information about the
1730− * state of the board. Care should be taken to ensure that any phase
1735+ * phase status bits to provide more detailed information about the
1736+ * state of the board. Care should be taken to ensure that any phase
17311737 * status bits that are set when changing the phase are also valid
17321738 * for the new phase or be cleared out. Adapter software (monitor,
1733− * iflash, kernel) is responsible for properly maintining the phase
1739+ * iflash, kernel) is responsible for properly maintining the phase
17341740 * status mailbox when it is running.
1735− *
1736− * MONKER_API Phases
17371741 *
1738− * Phases are bit oriented. It is NOT valid to have multiple bits set
1739− */
1742+ * MONKER_API Phases
1743+ *
1744+ * Phases are bit oriented. It is NOT valid to have multiple bits set
1745+ */
17401746
17411747 #define SELF_TEST_FAILED 0x00000004
17421748 #define MONITOR_PANIC 0x00000020
@@ -1759,16 +1765,22 @@ extern struct aac_common aac_config; · 16 unmodified lines
17591765 * For FIB communication, we need all of the following things
17601766 * to send back to the user.
17611767 */
1762−
1763−#define AifCmdEventNotify 1 /* Notify of event */
1768+
1769+#define AifCmdEventNotify 1 /* Notify of event */
17641770 #define AifEnConfigChange 3 /* Adapter configuration change */
17651771 #define AifEnContainerChange 4 /* Container configuration change */
17661772 #define AifEnDeviceFailure 5 /* SCSI device failed */
1773+#define AifEnEnclosureManagement 13 /* EM_DRIVE_* */
1774+#define EM_DRIVE_INSERTION 31
1775+#define EM_DRIVE_REMOVAL 32
1776+#define AifEnBatteryEvent 14 /* Change in Battery State */
17671777 #define AifEnAddContainer 15 /* A new array was created */
17681778 #define AifEnDeleteContainer 16 /* A container was deleted */
17691779 #define AifEnExpEvent 23 /* Firmware Event Log */
17701780 #define AifExeFirmwarePanic 3 /* Firmware Event Panic */
17711781 #define AifHighPriority 3 /* Highest Priority Event */
1782+#define AifEnAddJBOD 30 /* JBOD created */
1783+#define AifEnDeleteJBOD 31 /* JBOD deleted */
17721784
17731785 #define AifCmdJobProgress 2 /* Progress report */
17741786 #define AifJobCtrZero 101 /* Array Zero progress */
@@ -1780,11 +1792,11 @@ extern struct aac_common aac_config; · 5 unmodified lines
17801792 #define AifDenVolumeExtendComplete 201 /* A volume extend completed */
17811793 #define AifReqJobList 100 /* Gets back complete job list */
17821794 #define AifReqJobsForCtr 101 /* Gets back jobs for specific container */
1783−#define AifReqJobsForScsi 102 /* Gets back jobs for specific SCSI device */
1784−#define AifReqJobReport 103 /* Gets back a specific job report or list of them */
1795+#define AifReqJobsForScsi 102 /* Gets back jobs for specific SCSI device */
1796+#define AifReqJobReport 103 /* Gets back a specific job report or list of them */
17851797 #define AifReqTerminateJob 104 /* Terminates job */
17861798 #define AifReqSuspendJob 105 /* Suspends a job */
1787−#define AifReqResumeJob 106 /* Resumes a job */
1799+#define AifReqResumeJob 106 /* Resumes a job */
17881800 #define AifReqSendAPIReport 107 /* API generic report requests */
17891801 #define AifReqAPIJobStart 108 /* Start a job from the API */
17901802 #define AifReqAPIJobUpdate 109 /* Update a job report from the API */
@@ -1803,8 +1815,8 @@ struct aac_aifcmd { · 12 unmodified lines
18031815 };
18041816
18051817 /**
1806− * Convert capacity to cylinders
1807− * accounting for the fact capacity could be a 64 bit value
1818+ * Convert capacity to cylinders
1819+ * accounting for the fact capacity could be a 64 bit value
18081820 *
18091821 */
18101822 static inline unsigned int cap_to_cyls(sector_t capacity, unsigned divisor)
@@ -1861,6 +1873,7 @@ int aac_probe_container(struct aac_dev *dev, int cid); · 50 unmodified lines
18611873 int _aac_rx_init(struct aac_dev *dev);
18621874 int aac_rx_select_comm(struct aac_dev *dev, int comm);
18631875 int aac_rx_deliver_producer(struct fib * fib);
1876+char * get_container_type(unsigned type);
18641877 extern int numacb;
18651878 extern int acbsize;
18661879 extern char aac_driver_version[];
drivers/scsi/aacraid/commctrl.c+58−54
@@ -48,13 +48,13 @@ · 47 unmodified lines
4848 * ioctl_send_fib - send a FIB from userspace
4949 * @dev: adapter is being processed
5050 * @arg: arguments to the ioctl call
51− *
51+ *
5252 * This routine sends a fib to the adapter on behalf of a user level
5353 * program.
5454 */
5555 # define AAC_DEBUG_PREAMBLE KERN_INFO
5656 # define AAC_DEBUG_POSTAMBLE
57−
57+
5858 static int ioctl_send_fib(struct aac_dev * dev, void __user *arg)
5959 {
6060 struct hw_fib * kfib;
@@ -71,7 +71,7 @@ static int ioctl_send_fib(struct aac_dev * dev, void __user *arg) · 10 unmodified lines
7171 if(fibptr == NULL) {
7272 return -ENOMEM;
7373 }
74−
74+
7575 kfib = fibptr->hw_fib_va;
7676 /*
7777 * First copy in the header so that we can check the size field.
@@ -109,7 +109,7 @@ static int ioctl_send_fib(struct aac_dev * dev, void __user *arg) · 31 unmodified lines
109109 if (kfib->header.Command == cpu_to_le16(TakeABreakPt)) {
110110 aac_adapter_interrupt(dev);
111111 /*
112− * Since we didn't really send a fib, zero out the state to allow
112+ * Since we didn't really send a fib, zero out the state to allow
113113 * cleanup code not to assert.
114114 */
115115 kfib->header.XferState = 0;
@@ -169,7 +169,7 @@ static int open_getadapter_fib(struct aac_dev * dev, void __user *arg) · 53 unmodified lines
169169
170170 fibctx->type = FSAFS_NTC_GET_ADAPTER_FIB_CONTEXT;
171171 fibctx->size = sizeof(struct aac_fib_context);
172− /*
172+ /*
173173 * Yes yes, I know this could be an index, but we have a
174174 * better guarantee of uniqueness for the locked loop below.
175175 * Without the aid of a persistent history, this also helps
@@ -189,7 +189,7 @@ static int open_getadapter_fib(struct aac_dev * dev, void __user *arg) · 13 unmodified lines
189189 INIT_LIST_HEAD(&fibctx->fib_list);
190190 fibctx->jiffies = jiffies/HZ;
191191 /*
192− * Now add this context onto the adapter's
192+ * Now add this context onto the adapter's
193193 * AdapterFibContext list.
194194 */
195195 spin_lock_irqsave(&dev->fib_lock, flags);
@@ -207,12 +207,12 @@ static int open_getadapter_fib(struct aac_dev * dev, void __user *arg) · 11 unmodified lines
207207 }
208208 list_add_tail(&fibctx->next, &dev->fib_list);
209209 spin_unlock_irqrestore(&dev->fib_lock, flags);
210− if (copy_to_user(arg, &fibctx->unique,
210+ if (copy_to_user(arg, &fibctx->unique,
211211 sizeof(fibctx->unique))) {
212212 status = -EFAULT;
213213 } else {
214214 status = 0;
215− }
215+ }
216216 }
217217 return status;
218218 }
@@ -221,8 +221,8 @@ static int open_getadapter_fib(struct aac_dev * dev, void __user *arg) · 2 unmodified lines
221221 * next_getadapter_fib - get the next fib
222222 * @dev: adapter to use
223223 * @arg: ioctl argument
224− *
225− * This routine will get the next Fib, if available, from the AdapterFibContext
224+ *
225+ * This routine will get the next Fib, if available, from the AdapterFibContext
226226 * passed in from the user.
227227 */
228228
@@ -234,7 +234,7 @@ static int next_getadapter_fib(struct aac_dev * dev, void __user *arg) · 5 unmodified lines
234234 int status;
235235 struct list_head * entry;
236236 unsigned long flags;
237−
237+
238238 if(copy_from_user((void *)&f, arg, sizeof(struct fib_ioctl)))
239239 return -EFAULT;
240240 /*
@@ -243,6 +243,7 @@ static int next_getadapter_fib(struct aac_dev * dev, void __user *arg) · 2 unmodified lines
243243 * Search the list of AdapterFibContext addresses on the adapter
244244 * to be sure this is a valid address
245245 */
246+ spin_lock_irqsave(&dev->fib_lock, flags);
246247 entry = dev->fib_list.next;
247248 fibctx = NULL;
248249
@@ -251,37 +252,37 @@ static int next_getadapter_fib(struct aac_dev * dev, void __user *arg) · 2 unmodified lines
251252 /*
252253 * Extract the AdapterFibContext from the Input parameters.
253254 */
254− if (fibctx->unique == f.fibctx) { /* We found a winner */
255+ if (fibctx->unique == f.fibctx) { /* We found a winner */
255256 break;
256257 }
257258 entry = entry->next;
258259 fibctx = NULL;
259260 }
260261 if (!fibctx) {
262+ spin_unlock_irqrestore(&dev->fib_lock, flags);
261263 dprintk ((KERN_INFO "Fib Context not found\n"));
262264 return -EINVAL;
263265 }
264266
265267 if((fibctx->type != FSAFS_NTC_GET_ADAPTER_FIB_CONTEXT) ||
266268 (fibctx->size != sizeof(struct aac_fib_context))) {
269+ spin_unlock_irqrestore(&dev->fib_lock, flags);
267270 dprintk ((KERN_INFO "Fib Context corrupt?\n"));
268271 return -EINVAL;
269272 }
270273 status = 0;
271− spin_lock_irqsave(&dev->fib_lock, flags);
272274 /*
273275 * If there are no fibs to send back, then either wait or return
274276 * -EAGAIN
275277 */
276278 return_fib:
277279 if (!list_empty(&fibctx->fib_list)) {
278− struct list_head * entry;
279280 /*
280281 * Pull the next fib from the fibs
281282 */
282283 entry = fibctx->fib_list.next;
283284 list_del(entry);
284−
285+
285286 fib = list_entry(entry, struct fib, fiblink);
286287 fibctx->count--;
287288 spin_unlock_irqrestore(&dev->fib_lock, flags);
@@ -289,7 +290,7 @@ return_fib: · 1 unmodified line
289290 kfree(fib->hw_fib_va);
290291 kfree(fib);
291292 return -EFAULT;
292− }
293+ }
293294 /*
294295 * Free the space occupied by this copy of the fib.
295296 */
@@ -318,7 +319,7 @@ return_fib: · 22 unmodified lines
318319 }
319320 } else {
320321 status = -EAGAIN;
321− }
322+ }
322323 }
323324 fibctx->jiffies = jiffies/HZ;
324325 return status;
@@ -327,7 +328,9 @@ return_fib: · 2 unmodified lines
327328 int aac_close_fib_context(struct aac_dev * dev, struct aac_fib_context * fibctx)
328329 {
329330 struct fib *fib;
331+ unsigned long flags;
330332
333+ spin_lock_irqsave(&dev->fib_lock, flags);
331334 /*
332335 * First free any FIBs that have not been consumed.
333336 */
@@ -350,6 +353,7 @@ int aac_close_fib_context(struct aac_dev * dev, struct aac_fib_context * fibctx) · 16 unmodified lines
350353 * Remove the Context from the AdapterFibContext List
351354 */
352355 list_del(&fibctx->next);
356+ spin_unlock_irqrestore(&dev->fib_lock, flags);
353357 /*
354358 * Invalidate context
355359 */
@@ -368,7 +372,7 @@ int aac_close_fib_context(struct aac_dev * dev, struct aac_fib_context * fibctx) · 12 unmodified lines
368372 *
369373 * This routine will close down the fibctx passed in from the user.
370374 */
371−
375+
372376 static int close_getadapter_fib(struct aac_dev * dev, void __user *arg)
373377 {
374378 struct aac_fib_context *fibctx;
@@ -415,8 +419,8 @@ static int close_getadapter_fib(struct aac_dev * dev, void __user *arg) · 40 unmodified lines
415419 * @arg: ioctl arguments
416420 *
417421 * This routine returns the driver version.
418− * Under Linux, there have been no version incompatibilities, so this is
419− * simple!
422+ * Under Linux, there have been no version incompatibilities, so this is
423+ * simple!
420424 */
421425
422426 static int check_revision(struct aac_dev *dev, void __user *arg)
@@ -426,12 +430,12 @@ static int check_revision(struct aac_dev *dev, void __user *arg) · 3 unmodified lines
426430 u32 version;
427431
428432 response.compat = 1;
429− version = (simple_strtol(driver_version,
433+ version = (simple_strtol(driver_version,
430434 &driver_version, 10) << 24) | 0x00000400;
431435 version += simple_strtol(driver_version + 1, &driver_version, 10) << 16;
432436 version += simple_strtol(driver_version + 1, NULL, 10);
433437 response.version = cpu_to_le32(version);
434−# if (defined(AAC_DRIVER_BUILD))
438+# ifdef AAC_DRIVER_BUILD
435439 response.build = cpu_to_le32(AAC_DRIVER_BUILD);
436440 # else
437441 response.build = cpu_to_le32(9999);
@@ -464,7 +468,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) · 26 unmodified lines
464468 u32 data_dir;
465469 void __user *sg_user[32];
466470 void *sg_list[32];
467− u32 sg_indx = 0;
471+ u32 sg_indx = 0;
468472 u32 byte_count = 0;
469473 u32 actual_fibsize64, actual_fibsize = 0;
470474 int i;
@@ -475,7 +479,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) · 4 unmodified lines
475479 return -EBUSY;
476480 }
477481 if (!capable(CAP_SYS_ADMIN)){
478− dprintk((KERN_DEBUG"aacraid: No permission to send raw srb\n"));
482+ dprintk((KERN_DEBUG"aacraid: No permission to send raw srb\n"));
479483 return -EPERM;
480484 }
481485 /*
@@ -490,7 +494,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) · 8 unmodified lines
490494
491495 memset(sg_list, 0, sizeof(sg_list)); /* cleanup may take issue */
492496 if(copy_from_user(&fibsize, &user_srb->count,sizeof(u32))){
493− dprintk((KERN_DEBUG"aacraid: Could not copy data size from user\n"));
497+ dprintk((KERN_DEBUG"aacraid: Could not copy data size from user\n"));
494498 rcode = -EFAULT;
495499 goto cleanup;
496500 }
@@ -507,7 +511,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) · 10 unmodified lines
507511 goto cleanup;
508512 }
509513 if(copy_from_user(user_srbcmd, user_srb,fibsize)){
510− dprintk((KERN_DEBUG"aacraid: Could not copy srb from user\n"));
514+ dprintk((KERN_DEBUG"aacraid: Could not copy srb from user\n"));
511515 rcode = -EFAULT;
512516 goto cleanup;
513517 }
@@ -518,15 +522,15 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) · 4 unmodified lines
518522 // Fix up srb for endian and force some values
519523
520524 srbcmd->function = cpu_to_le32(SRBF_ExecuteScsi); // Force this
521− srbcmd->channel = cpu_to_le32(user_srbcmd->channel);
525+ srbcmd->channel = cpu_to_le32(user_srbcmd->channel);
522526 srbcmd->id = cpu_to_le32(user_srbcmd->id);
523− srbcmd->lun = cpu_to_le32(user_srbcmd->lun);
524− srbcmd->timeout = cpu_to_le32(user_srbcmd->timeout);
525− srbcmd->flags = cpu_to_le32(flags);
527+ srbcmd->lun = cpu_to_le32(user_srbcmd->lun);
528+ srbcmd->timeout = cpu_to_le32(user_srbcmd->timeout);
529+ srbcmd->flags = cpu_to_le32(flags);
526530 srbcmd->retry_limit = 0; // Obsolete parameter
527531 srbcmd->cdb_size = cpu_to_le32(user_srbcmd->cdb_size);
528532 memcpy(srbcmd->cdb, user_srbcmd->cdb, sizeof(srbcmd->cdb));
529−
533+
530534 switch (flags & (SRB_DataIn | SRB_DataOut)) {
531535 case SRB_DataOut:
532536 data_dir = DMA_TO_DEVICE;
@@ -582,7 +586,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) · 49 unmodified lines
582586 void* p;
583587 /* Does this really need to be GFP_DMA? */
584588 p = kmalloc(upsg->sg[i].count,GFP_KERNEL|__GFP_DMA);
585− if(p == 0) {
589+ if(!p) {
586590 dprintk((KERN_DEBUG"aacraid: Could not allocate SG buffer - size = %d buffer number %d of %d\n",
587591 upsg->sg[i].count,i,upsg->count));
588592 rcode = -ENOMEM;
@@ -594,7 +598,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) · 5 unmodified lines
594598 sg_list[i] = p; // save so we can clean up later
595599 sg_indx = i;
596600
597− if( flags & SRB_DataOut ){
601+ if (flags & SRB_DataOut) {
598602 if(copy_from_user(p,sg_user[i],upsg->sg[i].count)){
599603 dprintk((KERN_DEBUG"aacraid: Could not copy sg data from user\n"));
600604 rcode = -EFAULT;
@@ -626,7 +630,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) · 25 unmodified lines
626630 void* p;
627631 /* Does this really need to be GFP_DMA? */
628632 p = kmalloc(usg->sg[i].count,GFP_KERNEL|__GFP_DMA);
629− if(p == 0) {
633+ if(!p) {
630634 kfree (usg);
631635 dprintk((KERN_DEBUG"aacraid: Could not allocate SG buffer - size = %d buffer number %d of %d\n",
632636 usg->sg[i].count,i,usg->count));
@@ -637,7 +641,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) · 4 unmodified lines
637641 sg_list[i] = p; // save so we can clean up later
638642 sg_indx = i;
639643
640− if( flags & SRB_DataOut ){
644+ if (flags & SRB_DataOut) {
641645 if(copy_from_user(p,sg_user[i],upsg->sg[i].count)){
642646 kfree (usg);
643647 dprintk((KERN_DEBUG"aacraid: Could not copy sg data from user\n"));
@@ -668,7 +672,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) · 24 unmodified lines
668672 void* p;
669673 /* Does this really need to be GFP_DMA? */
670674 p = kmalloc(usg->sg[i].count,GFP_KERNEL|__GFP_DMA);
671− if(p == 0) {
675+ if(!p) {
672676 dprintk((KERN_DEBUG"aacraid: Could not allocate SG buffer - size = %d buffer number %d of %d\n",
673677 usg->sg[i].count,i,usg->count));
674678 rcode = -ENOMEM;
@@ -680,7 +684,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) · 5 unmodified lines
680684 sg_list[i] = p; // save so we can clean up later
681685 sg_indx = i;
682686
683− if( flags & SRB_DataOut ){
687+ if (flags & SRB_DataOut) {
684688 if(copy_from_user(p,sg_user[i],usg->sg[i].count)){
685689 dprintk((KERN_DEBUG"aacraid: Could not copy sg data from user\n"));
686690 rcode = -EFAULT;
@@ -698,7 +702,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) · 11 unmodified lines
698702 dma_addr_t addr;
699703 void* p;
700704 p = kmalloc(upsg->sg[i].count, GFP_KERNEL);
701− if(p == 0) {
705+ if (!p) {
702706 dprintk((KERN_DEBUG"aacraid: Could not allocate SG buffer - size = %d buffer number %d of %d\n",
703707 upsg->sg[i].count, i, upsg->count));
704708 rcode = -ENOMEM;
@@ -708,7 +712,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) · 3 unmodified lines
708712 sg_list[i] = p; // save so we can clean up later
709713 sg_indx = i;
710714
711− if( flags & SRB_DataOut ){
715+ if (flags & SRB_DataOut) {
712716 if(copy_from_user(p, sg_user[i],
713717 upsg->sg[i].count)) {
714718 dprintk((KERN_DEBUG"aacraid: Could not copy sg data from user\n"));
@@ -734,19 +738,19 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) · 19 unmodified lines
734738 }
735739
736740 if (status != 0){
737− dprintk((KERN_DEBUG"aacraid: Could not send raw srb fib to hba\n"));
741+ dprintk((KERN_DEBUG"aacraid: Could not send raw srb fib to hba\n"));
738742 rcode = -ENXIO;
739743 goto cleanup;
740744 }
741745
742− if( flags & SRB_DataIn ) {
746+ if (flags & SRB_DataIn) {
743747 for(i = 0 ; i <= sg_indx; i++){
744748 byte_count = le32_to_cpu(
745749 (dev->adapter_info.options & AAC_OPT_SGMAP_HOST64)
746750 ? ((struct sgmap64*)&srbcmd->sg)->sg[i].count
747751 : srbcmd->sg.sg[i].count);
748752 if(copy_to_user(sg_user[i], sg_list[i], byte_count)){
749− dprintk((KERN_DEBUG"aacraid: Could not copy sg data to user\n"));
753+ dprintk((KERN_DEBUG"aacraid: Could not copy sg data to user\n"));
750754 rcode = -EFAULT;
751755 goto cleanup;
752756
@@ -756,7 +760,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) · 3 unmodified lines
756760
757761 reply = (struct aac_srb_reply *) fib_data(srbfib);
758762 if(copy_to_user(user_reply,reply,sizeof(struct aac_srb_reply))){
759− dprintk((KERN_DEBUG"aacraid: Could not copy reply to user\n"));
763+ dprintk((KERN_DEBUG"aacraid: Could not copy reply to user\n"));
760764 rcode = -EFAULT;
761765 goto cleanup;
762766 }
@@ -775,34 +779,34 @@ cleanup: · 12 unmodified lines
775779 }
776780
777781 struct aac_pci_info {
778− u32 bus;
779− u32 slot;
782+ u32 bus;
783+ u32 slot;
780784 };
781785
782786
783787 static int aac_get_pci_info(struct aac_dev* dev, void __user *arg)
784788 {
785− struct aac_pci_info pci_info;
789+ struct aac_pci_info pci_info;
786790
787791 pci_info.bus = dev->pdev->bus->number;
788792 pci_info.slot = PCI_SLOT(dev->pdev->devfn);
789793
790− if (copy_to_user(arg, &pci_info, sizeof(struct aac_pci_info))) {
791− dprintk((KERN_DEBUG "aacraid: Could not copy pci info\n"));
792− return -EFAULT;
794+ if (copy_to_user(arg, &pci_info, sizeof(struct aac_pci_info))) {
795+ dprintk((KERN_DEBUG "aacraid: Could not copy pci info\n"));
796+ return -EFAULT;
793797 }
794− return 0;
798+ return 0;
795799 }
796−
800+
797801
798802 int aac_do_ioctl(struct aac_dev * dev, int cmd, void __user *arg)
799803 {
800804 int status;
801−
805+
802806 /*
803807 * HBA gets first crack
804808 */
805−
809+
806810 status = aac_dev_ioctl(dev, cmd, arg);
807811 if(status != -ENOTTY)
808812 return status;
@@ -832,7 +836,7 @@ int aac_do_ioctl(struct aac_dev * dev, int cmd, void __user *arg) · 23 unmodified lines
832836 break;
833837 default:
834838 status = -ENOTTY;
835− break;
839+ break;
836840 }
837841 return status;
838842 }
drivers/scsi/aacraid/comminit.c+2−2
@@ -301,10 +301,10 @@ struct aac_dev *aac_init_adapter(struct aac_dev *dev) · 300 unmodified lines
301301 if ((!aac_adapter_sync_cmd(dev, GET_ADAPTER_PROPERTIES,
302302 0, 0, 0, 0, 0, 0, status+0, status+1, status+2, NULL, NULL)) &&
303303 (status[0] == 0x00000001)) {
304− if (status[1] & AAC_OPT_NEW_COMM_64)
304+ if (status[1] & le32_to_cpu(AAC_OPT_NEW_COMM_64))
305305 dev->raw_io_64 = 1;
306306 if (dev->a_ops.adapter_comm &&
307− (status[1] & AAC_OPT_NEW_COMM))
307+ (status[1] & le32_to_cpu(AAC_OPT_NEW_COMM)))
308308 dev->comm_interface = AAC_COMM_MESSAGE;
309309 if ((dev->comm_interface == AAC_COMM_MESSAGE) &&
310310 (status[2] > dev->base_size)) {
drivers/scsi/aacraid/commsup.c+239−155
@@ -56,7 +56,7 @@ · 55 unmodified lines
5656 * Allocate and map the shared PCI space for the FIB blocks used to
5757 * talk to the Adaptec firmware.
5858 */
59−
59+
6060 static int fib_map_alloc(struct aac_dev *dev)
6161 {
6262 dprintk((KERN_INFO
@@ -109,14 +109,16 @@ int aac_fib_setup(struct aac_dev * dev) · 46 unmodified lines
109109 }
110110 if (i<0)
111111 return -ENOMEM;
112−
112+
113113 hw_fib = dev->hw_fib_va;
114114 hw_fib_pa = dev->hw_fib_pa;
115115 memset(hw_fib, 0, dev->max_fib_size * (dev->scsi_host_ptr->can_queue + AAC_NUM_MGT_FIB));
116116 /*
117117 * Initialise the fibs
118118 */
119− for (i = 0, fibptr = &dev->fibs[i]; i < (dev->scsi_host_ptr->can_queue + AAC_NUM_MGT_FIB); i++, fibptr++)
119+ for (i = 0, fibptr = &dev->fibs[i];
120+ i < (dev->scsi_host_ptr->can_queue + AAC_NUM_MGT_FIB);
121+ i++, fibptr++)
120122 {
121123 fibptr->dev = dev;
122124 fibptr->hw_fib_va = hw_fib;
@@ -148,13 +150,13 @@ int aac_fib_setup(struct aac_dev * dev) · 25 unmodified lines
148150 * Allocate a fib from the adapter fib pool. If the pool is empty we
149151 * return NULL.
150152 */
151−
153+
152154 struct fib *aac_fib_alloc(struct aac_dev *dev)
153155 {
154156 struct fib * fibptr;
155157 unsigned long flags;
156158 spin_lock_irqsave(&dev->fib_lock, flags);
157− fibptr = dev->free_fib;
159+ fibptr = dev->free_fib;
158160 if(!fibptr){
159161 spin_unlock_irqrestore(&dev->fib_lock, flags);
160162 return fibptr;
@@ -171,6 +173,7 @@ struct fib *aac_fib_alloc(struct aac_dev *dev) · 10 unmodified lines
171173 * each I/O
172174 */
173175 fibptr->hw_fib_va->header.XferState = 0;
176+ fibptr->flags = 0;
174177 fibptr->callback = NULL;
175178 fibptr->callback_data = NULL;
176179
@@ -183,7 +186,7 @@ struct fib *aac_fib_alloc(struct aac_dev *dev) · 6 unmodified lines
183186 *
184187 * Frees up a fib and places it on the appropriate queue
185188 */
186−
189+
187190 void aac_fib_free(struct fib *fibptr)
188191 {
189192 unsigned long flags;
@@ -204,10 +207,10 @@ void aac_fib_free(struct fib *fibptr) · 14 unmodified lines
204207 /**
205208 * aac_fib_init - initialise a fib
206209 * @fibptr: The fib to initialize
207− *
210+ *
208211 * Set up the generic fib fields ready for use
209212 */
210−
213+
211214 void aac_fib_init(struct fib *fibptr)
212215 {
213216 struct hw_fib *hw_fib = fibptr->hw_fib_va;
@@ -227,12 +230,12 @@ void aac_fib_init(struct fib *fibptr) · 13 unmodified lines
227230 * Will deallocate and return to the free pool the FIB pointed to by the
228231 * caller.
229232 */
230−
233+
231234 static void fib_dealloc(struct fib * fibptr)
232235 {
233236 struct hw_fib *hw_fib = fibptr->hw_fib_va;
234237 BUG_ON(hw_fib->header.StructType != FIB_MAGIC);
235− hw_fib->header.XferState = 0;
238+ hw_fib->header.XferState = 0;
236239 }
237240
238241 /*
@@ -241,7 +244,7 @@ static void fib_dealloc(struct fib * fibptr) · 2 unmodified lines
241244 * these routines and are the only routines which have a knowledge of the
242245 * how these queues are implemented.
243246 */
244−
247+
245248 /**
246249 * aac_get_entry - get a queue entry
247250 * @dev: Adapter
@@ -254,7 +257,7 @@ static void fib_dealloc(struct fib * fibptr) · 6 unmodified lines
254257 * is full(no free entries) than no entry is returned and the function returns 0 otherwise 1 is
255258 * returned.
256259 */
257−
260+
258261 static int aac_get_entry (struct aac_dev * dev, u32 qid, struct aac_entry **entry, u32 * index, unsigned long *nonotify)
259262 {
260263 struct aac_queue * q;
@@ -279,26 +282,27 @@ static int aac_get_entry (struct aac_dev * dev, u32 qid, struct aac_entry **entr · 18 unmodified lines
279282 idx = ADAP_NORM_RESP_ENTRIES;
280283 }
281284 if (idx != le32_to_cpu(*(q->headers.consumer)))
282− *nonotify = 1;
285+ *nonotify = 1;
283286 }
284287
285288 if (qid == AdapNormCmdQueue) {
286− if (*index >= ADAP_NORM_CMD_ENTRIES)
289+ if (*index >= ADAP_NORM_CMD_ENTRIES)
287290 *index = 0; /* Wrap to front of the Producer Queue. */
288291 } else {
289− if (*index >= ADAP_NORM_RESP_ENTRIES)
292+ if (*index >= ADAP_NORM_RESP_ENTRIES)
290293 *index = 0; /* Wrap to front of the Producer Queue. */
291294 }
292295
293− if ((*index + 1) == le32_to_cpu(*(q->headers.consumer))) { /* Queue is full */
296+ /* Queue is full */
297+ if ((*index + 1) == le32_to_cpu(*(q->headers.consumer))) {
294298 printk(KERN_WARNING "Queue %d full, %u outstanding.\n",
295299 qid, q->numpending);
296300 return 0;
297301 } else {
298− *entry = q->base + *index;
302+ *entry = q->base + *index;
299303 return 1;
300304 }
301−}
305+}
302306
303307 /**
304308 * aac_queue_get - get the next free QE
@@ -320,31 +324,29 @@ int aac_queue_get(struct aac_dev * dev, u32 * index, u32 qid, struct hw_fib * hw · 15 unmodified lines
320324 {
321325 struct aac_entry * entry = NULL;
322326 int map = 0;
323−
327+
324328 if (qid == AdapNormCmdQueue) {
325329 /* if no entries wait for some if caller wants to */
326− while (!aac_get_entry(dev, qid, &entry, index, nonotify))
327− {
330+ while (!aac_get_entry(dev, qid, &entry, index, nonotify)) {
328331 printk(KERN_ERR "GetEntries failed\n");
329332 }
330− /*
331− * Setup queue entry with a command, status and fib mapped
332− */
333− entry->size = cpu_to_le32(le16_to_cpu(hw_fib->header.Size));
334− map = 1;
333+ /*
334+ * Setup queue entry with a command, status and fib mapped
335+ */
336+ entry->size = cpu_to_le32(le16_to_cpu(hw_fib->header.Size));
337+ map = 1;
335338 } else {
336− while(!aac_get_entry(dev, qid, &entry, index, nonotify))
337− {
339+ while (!aac_get_entry(dev, qid, &entry, index, nonotify)) {
338340 /* if no entries wait for some if caller wants to */
339341 }
340− /*
341− * Setup queue entry with command, status and fib mapped
342− */
343− entry->size = cpu_to_le32(le16_to_cpu(hw_fib->header.Size));
344− entry->addr = hw_fib->header.SenderFibAddress;
345− /* Restore adapters pointer to the FIB */
342+ /*
343+ * Setup queue entry with command, status and fib mapped
344+ */
345+ entry->size = cpu_to_le32(le16_to_cpu(hw_fib->header.Size));
346+ entry->addr = hw_fib->header.SenderFibAddress;
347+ /* Restore adapters pointer to the FIB */
346348 hw_fib->header.ReceiverFibAddress = hw_fib->header.SenderFibAddress; /* Let the adapter now where to find its data */
347− map = 0;
349+ map = 0;
348350 }
349351 /*
350352 * If MapFib is true than we need to map the Fib and put pointers
@@ -356,8 +358,8 @@ int aac_queue_get(struct aac_dev * dev, u32 * index, u32 qid, struct hw_fib * hw · 5 unmodified lines
356358 }
357359
358360 /*
359− * Define the highest level of host to adapter communication routines.
360− * These routines will support host to adapter FS commuication. These
361+ * Define the highest level of host to adapter communication routines.
362+ * These routines will support host to adapter FS commuication. These
361363 * routines have no knowledge of the commuication method used. This level
362364 * sends and receives FIBs. This level has no knowledge of how these FIBs
363365 * get passed back and forth.
@@ -379,7 +381,7 @@ int aac_queue_get(struct aac_dev * dev, u32 * index, u32 qid, struct hw_fib * hw · 15 unmodified lines
379381 * an event to wait on must be supplied. This event will be set when a
380382 * response FIB is received from the adapter.
381383 */
382−
384+
383385 int aac_fib_send(u16 command, struct fib *fibptr, unsigned long size,
384386 int priority, int wait, int reply, fib_callback callback,
385387 void *callback_data)
@@ -392,16 +394,17 @@ int aac_fib_send(u16 command, struct fib *fibptr, unsigned long size, · 6 unmodified lines
392394 if (!(hw_fib->header.XferState & cpu_to_le32(HostOwned)))
393395 return -EBUSY;
394396 /*
395− * There are 5 cases with the wait and reponse requested flags.
397+ * There are 5 cases with the wait and reponse requested flags.
396398 * The only invalid cases are if the caller requests to wait and
397399 * does not request a response and if the caller does not want a
398400 * response and the Fib is not allocated from pool. If a response
399401 * is not requesed the Fib will just be deallocaed by the DPC
400402 * routine when the response comes back from the adapter. No
401− * further processing will be done besides deleting the Fib. We
403+ * further processing will be done besides deleting the Fib. We
402404 * will have a debug mode where the adapter can notify the host
403405 * it had a problem and the host can log that fact.
404406 */
407+ fibptr->flags = 0;
405408 if (wait && !reply) {
406409 return -EINVAL;
407410 } else if (!wait && reply) {
@@ -413,7 +416,7 @@ int aac_fib_send(u16 command, struct fib *fibptr, unsigned long size, · 5 unmodified lines
413416 } else if (wait && reply) {
414417 hw_fib->header.XferState |= cpu_to_le32(ResponseExpected);
415418 FIB_COUNTER_INCREMENT(aac_config.NormalSent);
416− }
419+ }
417420 /*
418421 * Map the fib into 32bits by using the fib number
419422 */
@@ -436,7 +439,7 @@ int aac_fib_send(u16 command, struct fib *fibptr, unsigned long size, · 16 unmodified lines
436439 hw_fib->header.Size = cpu_to_le16(sizeof(struct aac_fibhdr) + size);
437440 if (le16_to_cpu(hw_fib->header.Size) > le16_to_cpu(hw_fib->header.SenderSize)) {
438441 return -EMSGSIZE;
439− }
442+ }
440443 /*
441444 * Get a queue entry connect the FIB to it and send an notify
442445 * the adapter a command is ready.
@@ -450,10 +453,10 @@ int aac_fib_send(u16 command, struct fib *fibptr, unsigned long size, · 7 unmodified lines
450453 if (!wait) {
451454 fibptr->callback = callback;
452455 fibptr->callback_data = callback_data;
456+ fibptr->flags = FIB_CONTEXT_FLAG;
453457 }
454458
455459 fibptr->done = 0;
456− fibptr->flags = 0;
457460
458461 FIB_COUNTER_INCREMENT(aac_config.FibsSent);
459462
@@ -473,9 +476,9 @@ int aac_fib_send(u16 command, struct fib *fibptr, unsigned long size, · 13 unmodified lines
473476 aac_adapter_deliver(fibptr);
474477
475478 /*
476− * If the caller wanted us to wait for response wait now.
479+ * If the caller wanted us to wait for response wait now.
477480 */
478−
481+
479482 if (wait) {
480483 spin_unlock_irqrestore(&fibptr->event_lock, flags);
481484 /* Only set for first known interruptable command */
@@ -522,7 +525,7 @@ int aac_fib_send(u16 command, struct fib *fibptr, unsigned long size, · 40 unmodified lines
522525 }
523526 spin_unlock_irqrestore(&fibptr->event_lock, flags);
524527 BUG_ON(fibptr->done == 0);
525−
528+
526529 if(unlikely(fibptr->flags & FIB_CONTEXT_FLAG_TIMED_OUT))
527530 return -ETIMEDOUT;
528531 return 0;
@@ -537,15 +540,15 @@ int aac_fib_send(u16 command, struct fib *fibptr, unsigned long size, · 8 unmodified lines
537540 return 0;
538541 }
539542
540−/**
543+/**
541544 * aac_consumer_get - get the top of the queue
542545 * @dev: Adapter
543546 * @q: Queue
544547 * @entry: Return entry
545548 *
546549 * Will return a pointer to the entry on the top of the queue requested that
547− * we are a consumer of, and return the address of the queue entry. It does
548− * not change the state of the queue.
550+ * we are a consumer of, and return the address of the queue entry. It does
551+ * not change the state of the queue.
549552 */
550553
551554 int aac_consumer_get(struct aac_dev * dev, struct aac_queue * q, struct aac_entry **entry)
@@ -560,10 +563,10 @@ int aac_consumer_get(struct aac_dev * dev, struct aac_queue * q, struct aac_entr · 8 unmodified lines
560563 * the end of the queue, else we just use the entry
561564 * pointed to by the header index
562565 */
563− if (le32_to_cpu(*q->headers.consumer) >= q->entries)
564− index = 0;
566+ if (le32_to_cpu(*q->headers.consumer) >= q->entries)
567+ index = 0;
565568 else
566− index = le32_to_cpu(*q->headers.consumer);
569+ index = le32_to_cpu(*q->headers.consumer);
567570 *entry = q->base + index;
568571 status = 1;
569572 }
@@ -587,12 +590,12 @@ void aac_consumer_free(struct aac_dev * dev, struct aac_queue *q, u32 qid) · 17 unmodified lines
587590
588591 if ((le32_to_cpu(*q->headers.producer)+1) == le32_to_cpu(*q->headers.consumer))
589592 wasfull = 1;
590−
593+
591594 if (le32_to_cpu(*q->headers.consumer) >= q->entries)
592595 *q->headers.consumer = cpu_to_le32(1);
593596 else
594597 *q->headers.consumer = cpu_to_le32(le32_to_cpu(*q->headers.consumer)+1);
595−
598+
596599 if (wasfull) {
597600 switch (qid) {
598601
@@ -608,7 +611,7 @@ void aac_consumer_free(struct aac_dev * dev, struct aac_queue *q, u32 qid) · 9 unmodified lines
608611 }
609612 aac_adapter_notify(dev, notify);
610613 }
611−}
614+}
612615
613616 /**
614617 * aac_fib_adapter_complete - complete adapter issued fib
@@ -630,32 +633,32 @@ int aac_fib_adapter_complete(struct fib *fibptr, unsigned short size) · 15 unmodified lines
630633 if (hw_fib->header.XferState == 0) {
631634 if (dev->comm_interface == AAC_COMM_MESSAGE)
632635 kfree (hw_fib);
633− return 0;
636+ return 0;
634637 }
635638 /*
636639 * If we plan to do anything check the structure type first.
637− */
638− if ( hw_fib->header.StructType != FIB_MAGIC ) {
640+ */
641+ if (hw_fib->header.StructType != FIB_MAGIC) {
639642 if (dev->comm_interface == AAC_COMM_MESSAGE)
640643 kfree (hw_fib);
641− return -EINVAL;
644+ return -EINVAL;
642645 }
643646 /*
644647 * This block handles the case where the adapter had sent us a
645648 * command and we have finished processing the command. We
646− * call completeFib when we are done processing the command
647− * and want to send a response back to the adapter. This will
649+ * call completeFib when we are done processing the command
650+ * and want to send a response back to the adapter. This will
648651 * send the completed cdb to the adapter.
649652 */
650653 if (hw_fib->header.XferState & cpu_to_le32(SentFromAdapter)) {
651654 if (dev->comm_interface == AAC_COMM_MESSAGE) {
652655 kfree (hw_fib);
653656 } else {
654− u32 index;
655− hw_fib->header.XferState |= cpu_to_le32(HostProcessed);
657+ u32 index;
658+ hw_fib->header.XferState |= cpu_to_le32(HostProcessed);
656659 if (size) {
657660 size += sizeof(struct aac_fibhdr);
658− if (size > le16_to_cpu(hw_fib->header.SenderSize))
661+ if (size > le16_to_cpu(hw_fib->header.SenderSize))
659662 return -EMSGSIZE;
660663 hw_fib->header.Size = cpu_to_le16(size);
661664 }
@@ -667,12 +670,11 @@ int aac_fib_adapter_complete(struct fib *fibptr, unsigned short size) · 5 unmodified lines
667670 if (!(nointr & (int)aac_config.irq_mod))
668671 aac_adapter_notify(dev, AdapNormRespQueue);
669672 }
673+ } else {
674+ printk(KERN_WARNING "aac_fib_adapter_complete: "
675+ "Unknown xferstate detected.\n");
676+ BUG();
670677 }
671− else
672− {
673− printk(KERN_WARNING "aac_fib_adapter_complete: Unknown xferstate detected.\n");
674− BUG();
675− }
676678 return 0;
677679 }
678680
@@ -682,7 +684,7 @@ int aac_fib_adapter_complete(struct fib *fibptr, unsigned short size) · 3 unmodified lines
682684 *
683685 * Will do all necessary work to complete a FIB.
684686 */
685−
687+
686688 int aac_fib_complete(struct fib *fibptr)
687689 {
688690 struct hw_fib * hw_fib = fibptr->hw_fib_va;
@@ -692,15 +694,15 @@ int aac_fib_complete(struct fib *fibptr) · 3 unmodified lines
692694 */
693695
694696 if (hw_fib->header.XferState == 0)
695− return 0;
697+ return 0;
696698 /*
697699 * If we plan to do anything check the structure type first.
698− */
700+ */
699701
700702 if (hw_fib->header.StructType != FIB_MAGIC)
701− return -EINVAL;
703+ return -EINVAL;
702704 /*
703− * This block completes a cdb which orginated on the host and we
705+ * This block completes a cdb which orginated on the host and we
704706 * just need to deallocate the cdb or reinit it. At this point the
705707 * command is complete that we had sent to the adapter and this
706708 * cdb could be reused.
@@ -721,7 +723,7 @@ int aac_fib_complete(struct fib *fibptr) · 14 unmodified lines
721723 fib_dealloc(fibptr);
722724 } else {
723725 BUG();
724− }
726+ }
725727 return 0;
726728 }
727729
@@ -741,7 +743,7 @@ void aac_printf(struct aac_dev *dev, u32 val) · 13 unmodified lines
741743 {
742744 int length = val & 0xffff;
743745 int level = (val >> 16) & 0xffff;
744−
746+
745747 /*
746748 * The size of the printfbuf is set in port.c
747749 * There is no variable or define for it
@@ -755,7 +757,7 @@ void aac_printf(struct aac_dev *dev, u32 val) · 7 unmodified lines
755757 else
756758 printk(KERN_INFO "%s:%s", dev->name, cp);
757759 }
758− memset(cp, 0, 256);
760+ memset(cp, 0, 256);
759761 }
760762
761763
@@ -773,20 +775,20 @@ static void aac_handle_aif(struct aac_dev * dev, struct fib * fibptr) · 11 unmodified lines
773775 {
774776 struct hw_fib * hw_fib = fibptr->hw_fib_va;
775777 struct aac_aifcmd * aifcmd = (struct aac_aifcmd *)hw_fib->data;
776− u32 container;
778+ u32 channel, id, lun, container;
777779 struct scsi_device *device;
778780 enum {
779781 NOTHING,
780782 DELETE,
781783 ADD,
782784 CHANGE
783− } device_config_needed;
785+ } device_config_needed = NOTHING;
784786
785787 /* Sniff for container changes */
786788
787789 if (!dev || !dev->fsa_dev)
788790 return;
789− container = (u32)-1;
791+ container = channel = id = lun = (u32)-1;
790792
791793 /*
792794 * We have set this up to try and minimize the number of
@@ -796,13 +798,13 @@ static void aac_handle_aif(struct aac_dev * dev, struct fib * fibptr) · 3 unmodified lines
796798 */
797799 switch (le32_to_cpu(aifcmd->command)) {
798800 case AifCmdDriverNotify:
799− switch (le32_to_cpu(((u32 *)aifcmd->data)[0])) {
801+ switch (le32_to_cpu(((__le32 *)aifcmd->data)[0])) {
800802 /*
801803 * Morph or Expand complete
802804 */
803805 case AifDenMorphComplete:
804806 case AifDenVolumeExtendComplete:
805− container = le32_to_cpu(((u32 *)aifcmd->data)[1]);
807+ container = le32_to_cpu(((__le32 *)aifcmd->data)[1]);
806808 if (container >= dev->maximum_num_containers)
807809 break;
808810
@@ -814,9 +816,9 @@ static void aac_handle_aif(struct aac_dev * dev, struct fib * fibptr) · 5 unmodified lines
814816 */
815817
816818 if ((dev != NULL) && (dev->scsi_host_ptr != NULL)) {
817− device = scsi_device_lookup(dev->scsi_host_ptr,
818− CONTAINER_TO_CHANNEL(container),
819− CONTAINER_TO_ID(container),
819+ device = scsi_device_lookup(dev->scsi_host_ptr,
820+ CONTAINER_TO_CHANNEL(container),
821+ CONTAINER_TO_ID(container),
820822 CONTAINER_TO_LUN(container));
821823 if (device) {
822824 dev->fsa_dev[container].config_needed = CHANGE;
@@ -835,25 +837,29 @@ static void aac_handle_aif(struct aac_dev * dev, struct fib * fibptr) · 12 unmodified lines
835837 if (container >= dev->maximum_num_containers)
836838 break;
837839 if ((dev->fsa_dev[container].config_waiting_on ==
838− le32_to_cpu(*(u32 *)aifcmd->data)) &&
840+ le32_to_cpu(*(__le32 *)aifcmd->data)) &&
839841 time_before(jiffies, dev->fsa_dev[container].config_waiting_stamp + AIF_SNIFF_TIMEOUT))
840842 dev->fsa_dev[container].config_waiting_on = 0;
841843 } else for (container = 0;
842844 container < dev->maximum_num_containers; ++container) {
843845 if ((dev->fsa_dev[container].config_waiting_on ==
844− le32_to_cpu(*(u32 *)aifcmd->data)) &&
846+ le32_to_cpu(*(__le32 *)aifcmd->data)) &&
845847 time_before(jiffies, dev->fsa_dev[container].config_waiting_stamp + AIF_SNIFF_TIMEOUT))
846848 dev->fsa_dev[container].config_waiting_on = 0;
847849 }
848850 break;
849851
850852 case AifCmdEventNotify:
851− switch (le32_to_cpu(((u32 *)aifcmd->data)[0])) {
853+ switch (le32_to_cpu(((__le32 *)aifcmd->data)[0])) {
854+ case AifEnBatteryEvent:
855+ dev->cache_protected =
856+ (((__le32 *)aifcmd->data)[1] == cpu_to_le32(3));
857+ break;
852858 /*
853859 * Add an Array.
854860 */
855861 case AifEnAddContainer:
856− container = le32_to_cpu(((u32 *)aifcmd->data)[1]);
862+ container = le32_to_cpu(((__le32 *)aifcmd->data)[1]);
857863 if (container >= dev->maximum_num_containers)
858864 break;
859865 dev->fsa_dev[container].config_needed = ADD;
@@ -866,7 +872,7 @@ static void aac_handle_aif(struct aac_dev * dev, struct fib * fibptr) · 6 unmodified lines
866872 * Delete an Array.
867873 */
868874 case AifEnDeleteContainer:
869− container = le32_to_cpu(((u32 *)aifcmd->data)[1]);
875+ container = le32_to_cpu(((__le32 *)aifcmd->data)[1]);
870876 if (container >= dev->maximum_num_containers)
871877 break;
872878 dev->fsa_dev[container].config_needed = DELETE;
@@ -880,7 +886,7 @@ static void aac_handle_aif(struct aac_dev * dev, struct fib * fibptr) · 7 unmodified lines
880886 * waiting on something else, setup to wait on a Config Change.
881887 */
882888 case AifEnContainerChange:
883− container = le32_to_cpu(((u32 *)aifcmd->data)[1]);
889+ container = le32_to_cpu(((__le32 *)aifcmd->data)[1]);
884890 if (container >= dev->maximum_num_containers)
885891 break;
886892 if (dev->fsa_dev[container].config_waiting_on &&
@@ -895,6 +901,60 @@ static void aac_handle_aif(struct aac_dev * dev, struct fib * fibptr) · 8 unmodified lines
895901 case AifEnConfigChange:
896902 break;
897903
904+ case AifEnAddJBOD:
905+ case AifEnDeleteJBOD:
906+ container = le32_to_cpu(((__le32 *)aifcmd->data)[1]);
907+ if ((container >> 28))
908+ break;
909+ channel = (container >> 24) & 0xF;
910+ if (channel >= dev->maximum_num_channels)
911+ break;
912+ id = container & 0xFFFF;
913+ if (id >= dev->maximum_num_physicals)
914+ break;
915+ lun = (container >> 16) & 0xFF;
916+ channel = aac_phys_to_logical(channel);
917+ device_config_needed =
918+ (((__le32 *)aifcmd->data)[0] ==
919+ cpu_to_le32(AifEnAddJBOD)) ? ADD : DELETE;
920+ break;
921+
922+ case AifEnEnclosureManagement:
923+ /*
924+ * If in JBOD mode, automatic exposure of new
925+ * physical target to be suppressed until configured.
926+ */
927+ if (dev->jbod)
928+ break;
929+ switch (le32_to_cpu(((__le32 *)aifcmd->data)[3])) {
930+ case EM_DRIVE_INSERTION:
931+ case EM_DRIVE_REMOVAL:
932+ container = le32_to_cpu(
933+ ((__le32 *)aifcmd->data)[2]);
934+ if ((container >> 28))
935+ break;
936+ channel = (container >> 24) & 0xF;
937+ if (channel >= dev->maximum_num_channels)
938+ break;
939+ id = container & 0xFFFF;
940+ lun = (container >> 16) & 0xFF;
941+ if (id >= dev->maximum_num_physicals) {
942+ /* legacy dev_t ? */
943+ if ((0x2000 <= id) || lun || channel ||
944+ ((channel = (id >> 7) & 0x3F) >=
945+ dev->maximum_num_channels))
946+ break;
947+ lun = (id >> 4) & 7;
948+ id &= 0xF;
949+ }
950+ channel = aac_phys_to_logical(channel);
951+ device_config_needed =
952+ (((__le32 *)aifcmd->data)[3]
953+ == cpu_to_le32(EM_DRIVE_INSERTION)) ?
954+ ADD : DELETE;
955+ break;
956+ }
957+ break;
898958 }
899959
900960 /*
@@ -905,13 +965,13 @@ static void aac_handle_aif(struct aac_dev * dev, struct fib * fibptr) · 4 unmodified lines
905965 if (container >= dev->maximum_num_containers)
906966 break;
907967 if ((dev->fsa_dev[container].config_waiting_on ==
908− le32_to_cpu(*(u32 *)aifcmd->data)) &&
968+ le32_to_cpu(*(__le32 *)aifcmd->data)) &&
909969 time_before(jiffies, dev->fsa_dev[container].config_waiting_stamp + AIF_SNIFF_TIMEOUT))
910970 dev->fsa_dev[container].config_waiting_on = 0;
911971 } else for (container = 0;
912972 container < dev->maximum_num_containers; ++container) {
913973 if ((dev->fsa_dev[container].config_waiting_on ==
914− le32_to_cpu(*(u32 *)aifcmd->data)) &&
974+ le32_to_cpu(*(__le32 *)aifcmd->data)) &&
915975 time_before(jiffies, dev->fsa_dev[container].config_waiting_stamp + AIF_SNIFF_TIMEOUT))
916976 dev->fsa_dev[container].config_waiting_on = 0;
917977 }
@@ -926,9 +986,9 @@ static void aac_handle_aif(struct aac_dev * dev, struct fib * fibptr) · 8 unmodified lines
926986 * wait for a container change.
927987 */
928988
929− if ((((u32 *)aifcmd->data)[1] == cpu_to_le32(AifJobCtrZero))
930− && ((((u32 *)aifcmd->data)[6] == ((u32 *)aifcmd->data)[5])
931− || (((u32 *)aifcmd->data)[4] == cpu_to_le32(AifJobStsSuccess)))) {
989+ if (((__le32 *)aifcmd->data)[1] == cpu_to_le32(AifJobCtrZero) &&
990+ (((__le32 *)aifcmd->data)[6] == ((__le32 *)aifcmd->data)[5] ||
991+ ((__le32 *)aifcmd->data)[4] == cpu_to_le32(AifJobStsSuccess))) {
932992 for (container = 0;
933993 container < dev->maximum_num_containers;
934994 ++container) {
@@ -943,9 +1003,9 @@ static void aac_handle_aif(struct aac_dev * dev, struct fib * fibptr) · 8 unmodified lines
9431003 jiffies;
9441004 }
9451005 }
946− if ((((u32 *)aifcmd->data)[1] == cpu_to_le32(AifJobCtrZero))
947− && (((u32 *)aifcmd->data)[6] == 0)
948− && (((u32 *)aifcmd->data)[4] == cpu_to_le32(AifJobStsRunning))) {
1006+ if (((__le32 *)aifcmd->data)[1] == cpu_to_le32(AifJobCtrZero) &&
1007+ ((__le32 *)aifcmd->data)[6] == 0 &&
1008+ ((__le32 *)aifcmd->data)[4] == cpu_to_le32(AifJobStsRunning)) {
9491009 for (container = 0;
9501010 container < dev->maximum_num_containers;
9511011 ++container) {
@@ -963,7 +1023,7 @@ static void aac_handle_aif(struct aac_dev * dev, struct fib * fibptr) · 11 unmodified lines
9631023 break;
9641024 }
9651025
966− device_config_needed = NOTHING;
1026+ if (device_config_needed == NOTHING)
9671027 for (container = 0; container < dev->maximum_num_containers;
9681028 ++container) {
9691029 if ((dev->fsa_dev[container].config_waiting_on == 0) &&
@@ -972,6 +1032,9 @@ static void aac_handle_aif(struct aac_dev * dev, struct fib * fibptr) · 2 unmodified lines
9721032 device_config_needed =
9731033 dev->fsa_dev[container].config_needed;
9741034 dev->fsa_dev[container].config_needed = NOTHING;
1035+ channel = CONTAINER_TO_CHANNEL(container);
1036+ id = CONTAINER_TO_ID(container);
1037+ lun = CONTAINER_TO_LUN(container);
9751038 break;
9761039 }
9771040 }
@@ -995,34 +1058,56 @@ static void aac_handle_aif(struct aac_dev * dev, struct fib * fibptr) · 17 unmodified lines
9951058 /*
9961059 * force reload of disk info via aac_probe_container
9971060 */
998− if ((device_config_needed == CHANGE)
999− && (dev->fsa_dev[container].valid == 1))
1000− dev->fsa_dev[container].valid = 2;
1001− if ((device_config_needed == CHANGE) ||
1002− (device_config_needed == ADD))
1061+ if ((channel == CONTAINER_CHANNEL) &&
1062+ (device_config_needed != NOTHING)) {
1063+ if (dev->fsa_dev[container].valid == 1)
1064+ dev->fsa_dev[container].valid = 2;
10031065 aac_probe_container(dev, container);
1004− device = scsi_device_lookup(dev->scsi_host_ptr,
1005− CONTAINER_TO_CHANNEL(container),
1006− CONTAINER_TO_ID(container),
1007− CONTAINER_TO_LUN(container));
1066+ }
1067+ device = scsi_device_lookup(dev->scsi_host_ptr, channel, id, lun);
10081068 if (device) {
10091069 switch (device_config_needed) {
10101070 case DELETE:
1071+ if (scsi_device_online(device)) {
1072+ scsi_device_set_state(device, SDEV_OFFLINE);
1073+ sdev_printk(KERN_INFO, device,
1074+ "Device offlined - %s\n",
1075+ (channel == CONTAINER_CHANNEL) ?
1076+ "array deleted" :
1077+ "enclosure services event");
1078+ }
1079+ break;
1080+ case ADD:
1081+ if (!scsi_device_online(device)) {
1082+ sdev_printk(KERN_INFO, device,
1083+ "Device online - %s\n",
1084+ (channel == CONTAINER_CHANNEL) ?
1085+ "array created" :
1086+ "enclosure services event");
1087+ scsi_device_set_state(device, SDEV_RUNNING);
1088+ }
1089+ /* FALLTHRU */
10111090 case CHANGE:
1091+ if ((channel == CONTAINER_CHANNEL)
1092+ && (!dev->fsa_dev[container].valid)) {
1093+ if (!scsi_device_online(device))
1094+ break;
1095+ scsi_device_set_state(device, SDEV_OFFLINE);
1096+ sdev_printk(KERN_INFO, device,
1097+ "Device offlined - %s\n",
1098+ "array failed");
1099+ break;
1100+ }
10121101 scsi_rescan_device(&device->sdev_gendev);
10131102
10141103 default:
10151104 break;
10161105 }
10171106 scsi_device_put(device);
1107+ device_config_needed = NOTHING;
10181108 }
1019− if (device_config_needed == ADD) {
1020− scsi_add_device(dev->scsi_host_ptr,
1021− CONTAINER_TO_CHANNEL(container),
1022− CONTAINER_TO_ID(container),
1023− CONTAINER_TO_LUN(container));
1024− }
1025−
1109+ if (device_config_needed == ADD)
1110+ scsi_add_device(dev->scsi_host_ptr, channel, id, lun);
10261111 }
10271112
10281113 static int _aac_reset_adapter(struct aac_dev *aac, int forced)
@@ -1099,7 +1184,8 @@ static int _aac_reset_adapter(struct aac_dev *aac, int forced) · 70 unmodified lines
10991184 free_irq(aac->pdev->irq, aac);
11001185 kfree(aac->fsa_dev);
11011186 aac->fsa_dev = NULL;
1102− if (aac_get_driver_ident(index)->quirks & AAC_QUIRK_31BIT) {
1187+ quirks = aac_get_driver_ident(index)->quirks;
1188+ if (quirks & AAC_QUIRK_31BIT) {
11031189 if (((retval = pci_set_dma_mask(aac->pdev, DMA_31BIT_MASK))) ||
11041190 ((retval = pci_set_consistent_dma_mask(aac->pdev, DMA_31BIT_MASK))))
11051191 goto out;
@@ -1110,7 +1196,7 @@ static int _aac_reset_adapter(struct aac_dev *aac, int forced) · 4 unmodified lines
11101196 }
11111197 if ((retval = (*(aac_get_driver_ident(index)->init))(aac)))
11121198 goto out;
1113− if (aac_get_driver_ident(index)->quirks & AAC_QUIRK_31BIT)
1199+ if (quirks & AAC_QUIRK_31BIT)
11141200 if ((retval = pci_set_dma_mask(aac->pdev, DMA_32BIT_MASK)))
11151201 goto out;
11161202 if (jafo) {
@@ -1121,15 +1207,14 @@ static int _aac_reset_adapter(struct aac_dev *aac, int forced) · 4 unmodified lines
11211207 }
11221208 }
11231209 (void)aac_get_adapter_info(aac);
1124− quirks = aac_get_driver_ident(index)->quirks;
11251210 if ((quirks & AAC_QUIRK_34SG) && (host->sg_tablesize > 34)) {
1126− host->sg_tablesize = 34;
1127− host->max_sectors = (host->sg_tablesize * 8) + 112;
1128− }
1129− if ((quirks & AAC_QUIRK_17SG) && (host->sg_tablesize > 17)) {
1130− host->sg_tablesize = 17;
1131− host->max_sectors = (host->sg_tablesize * 8) + 112;
1132− }
1211+ host->sg_tablesize = 34;
1212+ host->max_sectors = (host->sg_tablesize * 8) + 112;
1213+ }
1214+ if ((quirks & AAC_QUIRK_17SG) && (host->sg_tablesize > 17)) {
1215+ host->sg_tablesize = 17;
1216+ host->max_sectors = (host->sg_tablesize * 8) + 112;
1217+ }
11331218 aac_get_config_status(aac, 1);
11341219 aac_get_containers(aac);
11351220 /*
@@ -1217,12 +1302,13 @@ int aac_reset_adapter(struct aac_dev * aac, int forced) · 81 unmodified lines
12171302 }
12181303
12191304 /* Quiesce build, flush cache, write through mode */
1220− aac_send_shutdown(aac);
1305+ if (forced < 2)
1306+ aac_send_shutdown(aac);
12211307 spin_lock_irqsave(host->host_lock, flagv);
1222− retval = _aac_reset_adapter(aac, forced);
1308+ retval = _aac_reset_adapter(aac, forced ? forced : ((aac_check_reset != 0) && (aac_check_reset != 1)));
12231309 spin_unlock_irqrestore(host->host_lock, flagv);
12241310
1225− if (retval == -ENODEV) {
1311+ if ((forced < 2) && (retval == -ENODEV)) {
12261312 /* Unwind aac_send_shutdown() IOP_RESET unsupported/disabled */
12271313 struct fib * fibctx = aac_fib_alloc(aac);
12281314 if (fibctx) {
@@ -1338,11 +1424,11 @@ int aac_check_health(struct aac_dev * aac) · 109 unmodified lines
13381424 fib->data = hw_fib->data;
13391425 aif = (struct aac_aifcmd *)hw_fib->data;
13401426 aif->command = cpu_to_le32(AifCmdEventNotify);
1341− aif->seqnum = cpu_to_le32(0xFFFFFFFF);
1342− aif->data[0] = AifEnExpEvent;
1343− aif->data[1] = AifExeFirmwarePanic;
1344− aif->data[2] = AifHighPriority;
1345− aif->data[3] = BlinkLED;
1427+ aif->seqnum = cpu_to_le32(0xFFFFFFFF);
1428+ ((__le32 *)aif->data)[0] = cpu_to_le32(AifEnExpEvent);
1429+ ((__le32 *)aif->data)[1] = cpu_to_le32(AifExeFirmwarePanic);
1430+ ((__le32 *)aif->data)[2] = cpu_to_le32(AifHighPriority);
1431+ ((__le32 *)aif->data)[3] = cpu_to_le32(BlinkLED);
13461432
13471433 /*
13481434 * Put the FIB onto the
@@ -1372,14 +1458,14 @@ int aac_check_health(struct aac_dev * aac) · 23 unmodified lines
13721458
13731459 printk(KERN_ERR "%s: Host adapter BLINK LED 0x%x\n", aac->name, BlinkLED);
13741460
1375− if (!aac_check_reset ||
1461+ if (!aac_check_reset || ((aac_check_reset != 1) &&
13761462 (aac->supplement_adapter_info.SupportedOptions2 &
1377− le32_to_cpu(AAC_OPTION_IGNORE_RESET)))
1463+ AAC_OPTION_IGNORE_RESET)))
13781464 goto out;
13791465 host = aac->scsi_host_ptr;
13801466 if (aac->thread->pid != current->pid)
13811467 spin_lock_irqsave(host->host_lock, flagv);
1382− BlinkLED = _aac_reset_adapter(aac, 0);
1468+ BlinkLED = _aac_reset_adapter(aac, aac_check_reset != 1);
13831469 if (aac->thread->pid != current->pid)
13841470 spin_unlock_irqrestore(host->host_lock, flagv);
13851471 return BlinkLED;
@@ -1399,7 +1485,7 @@ out: · 13 unmodified lines
13991485 * until the queue is empty. When the queue is empty it will wait for
14001486 * more FIBs.
14011487 */
1402−
1488+
14031489 int aac_command_thread(void *data)
14041490 {
14051491 struct aac_dev *dev = data;
@@ -1425,30 +1511,29 @@ int aac_command_thread(void *data) · 19 unmodified lines
14251511 add_wait_queue(&dev->queues->queue[HostNormCmdQueue].cmdready, &wait);
14261512 set_current_state(TASK_INTERRUPTIBLE);
14271513 dprintk ((KERN_INFO "aac_command_thread start\n"));
1428− while(1)
1429− {
1514+ while (1) {
14301515 spin_lock_irqsave(dev->queues->queue[HostNormCmdQueue].lock, flags);
14311516 while(!list_empty(&(dev->queues->queue[HostNormCmdQueue].cmdq))) {
14321517 struct list_head *entry;
14331518 struct aac_aifcmd * aifcmd;
14341519
14351520 set_current_state(TASK_RUNNING);
1436−
1521+
14371522 entry = dev->queues->queue[HostNormCmdQueue].cmdq.next;
14381523 list_del(entry);
1439−
1524+
14401525 spin_unlock_irqrestore(dev->queues->queue[HostNormCmdQueue].lock, flags);
14411526 fib = list_entry(entry, struct fib, fiblink);
14421527 /*
1443− * We will process the FIB here or pass it to a
1444− * worker thread that is TBD. We Really can't
1528+ * We will process the FIB here or pass it to a
1529+ * worker thread that is TBD. We Really can't
14451530 * do anything at this point since we don't have
14461531 * anything defined for this thread to do.
14471532 */
14481533 hw_fib = fib->hw_fib_va;
14491534 memset(fib, 0, sizeof(struct fib));
14501535 fib->type = FSAFS_NTC_FIB_CONTEXT;
1451− fib->size = sizeof( struct fib );
1536+ fib->size = sizeof(struct fib);
14521537 fib->hw_fib_va = hw_fib;
14531538 fib->data = hw_fib->data;
14541539 fib->dev = dev;
@@ -1462,20 +1547,19 @@ int aac_command_thread(void *data) · 7 unmodified lines
14621547 *(__le32 *)hw_fib->data = cpu_to_le32(ST_OK);
14631548 aac_fib_adapter_complete(fib, (u16)sizeof(u32));
14641549 } else {
1465− struct list_head *entry;
14661550 /* The u32 here is important and intended. We are using
14671551 32bit wrapping time to fit the adapter field */
1468−
1552+
14691553 u32 time_now, time_last;
14701554 unsigned long flagv;
14711555 unsigned num;
14721556 struct hw_fib ** hw_fib_pool, ** hw_fib_p;
14731557 struct fib ** fib_pool, ** fib_p;
1474−
1558+
14751559 /* Sniff events */
1476− if ((aifcmd->command ==
1560+ if ((aifcmd->command ==
14771561 cpu_to_le32(AifCmdEventNotify)) ||
1478− (aifcmd->command ==
1562+ (aifcmd->command ==
14791563 cpu_to_le32(AifCmdJobProgress))) {
14801564 aac_handle_aif(dev, fib);
14811565 }
@@ -1527,7 +1611,7 @@ int aac_command_thread(void *data) · 45 unmodified lines
15271611 spin_lock_irqsave(&dev->fib_lock, flagv);
15281612 entry = dev->fib_list.next;
15291613 /*
1530− * For each Context that is on the
1614+ * For each Context that is on the
15311615 * fibctxList, make a copy of the
15321616 * fib, and then set the event to wake up the
15331617 * thread that is waiting for it.
@@ -1552,7 +1636,7 @@ int aac_command_thread(void *data) · 18 unmodified lines
15521636 */
15531637 time_last = fibctx->jiffies;
15541638 /*
1555− * Has it been > 2 minutes
1639+ * Has it been > 2 minutes
15561640 * since the last read off
15571641 * the queue?
15581642 */
@@ -1583,7 +1667,7 @@ int aac_command_thread(void *data) · 24 unmodified lines
15831667 */
15841668 list_add_tail(&newfib->fiblink, &fibctx->fib_list);
15851669 fibctx->count++;
1586− /*
1670+ /*
15871671 * Set the event to wake up the
15881672 * thread that is waiting.
15891673 */
@@ -1655,11 +1739,11 @@ int aac_command_thread(void *data) · 65 unmodified lines
16551739 struct fib *fibptr;
16561740
16571741 if ((fibptr = aac_fib_alloc(dev))) {
1658− u32 * info;
1742+ __le32 *info;
16591743
16601744 aac_fib_init(fibptr);
16611745
1662− info = (u32 *) fib_data(fibptr);
1746+ info = (__le32 *) fib_data(fibptr);
16631747 if (now.tv_usec > 500000)
16641748 ++now.tv_sec;
16651749
drivers/scsi/aacraid/dpcsup.c+5−5
@@ -120,6 +120,7 @@ unsigned int aac_response_normal(struct aac_queue * q) · 119 unmodified lines
120120 * NOTE: we cannot touch the fib after this
121121 * call, because it may have been deallocated.
122122 */
123+ fib->flags = 0;
123124 fib->callback(fib->callback_data, fib);
124125 } else {
125126 unsigned long flagv;
@@ -229,11 +230,9 @@ unsigned int aac_command_normal(struct aac_queue *q) · 103 unmodified lines
229230 * all QE there are and wake up all the waiters before exiting.
230231 */
231232
232−unsigned int aac_intr_normal(struct aac_dev * dev, u32 Index)
233+unsigned int aac_intr_normal(struct aac_dev * dev, u32 index)
233234 {
234− u32 index = le32_to_cpu(Index);
235−
236− dprintk((KERN_INFO "aac_intr_normal(%p,%x)\n", dev, Index));
235+ dprintk((KERN_INFO "aac_intr_normal(%p,%x)\n", dev, index));
237236 if ((index & 0x00000002L)) {
238237 struct hw_fib * hw_fib;
239238 struct fib * fib;
@@ -301,7 +300,7 @@ unsigned int aac_intr_normal(struct aac_dev * dev, u32 Index) · 61 unmodified lines
301300
302301 if (hwfib->header.Command == cpu_to_le16(NuFileSystem))
303302 {
304− u32 *pstatus = (u32 *)hwfib->data;
303+ __le32 *pstatus = (__le32 *)hwfib->data;
305304 if (*pstatus & cpu_to_le32(0xffff0000))
306305 *pstatus = cpu_to_le32(ST_OK);
307306 }
@@ -315,6 +314,7 @@ unsigned int aac_intr_normal(struct aac_dev * dev, u32 Index) · 7 unmodified lines
315314 * NOTE: we cannot touch the fib after this
316315 * call, because it may have been deallocated.
317316 */
317+ fib->flags = 0;
318318 fib->callback(fib->callback_data, fib);
319319 } else {
320320 unsigned long flagv;
drivers/scsi/aacraid/linit.c+165−77
@@ -159,27 +159,27 @@ static struct pci_device_id aac_pci_tbl[] = { · 158 unmodified lines
159159 MODULE_DEVICE_TABLE(pci, aac_pci_tbl);
160160
161161 /*
162− * dmb - For now we add the number of channels to this structure.
162+ * dmb - For now we add the number of channels to this structure.
163163 * In the future we should add a fib that reports the number of channels
164164 * for the card. At that time we can remove the channels from here
165165 */
166166 static struct aac_driver_ident aac_drivers[] = {
167− { aac_rx_init, "percraid", "DELL ", "PERCRAID ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG }, /* PERC 2/Si (Iguana/PERC2Si) */
168− { aac_rx_init, "percraid", "DELL ", "PERCRAID ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG }, /* PERC 3/Di (Opal/PERC3Di) */
169− { aac_rx_init, "percraid", "DELL ", "PERCRAID ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG }, /* PERC 3/Si (SlimFast/PERC3Si */
170− { aac_rx_init, "percraid", "DELL ", "PERCRAID ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG }, /* PERC 3/Di (Iguana FlipChip/PERC3DiF */
171− { aac_rx_init, "percraid", "DELL ", "PERCRAID ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG }, /* PERC 3/Di (Viper/PERC3DiV) */
172− { aac_rx_init, "percraid", "DELL ", "PERCRAID ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG }, /* PERC 3/Di (Lexus/PERC3DiL) */
173− { aac_rx_init, "percraid", "DELL ", "PERCRAID ", 1, AAC_QUIRK_31BIT | AAC_QUIRK_34SG }, /* PERC 3/Di (Jaguar/PERC3DiJ) */
174− { aac_rx_init, "percraid", "DELL ", "PERCRAID ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG }, /* PERC 3/Di (Dagger/PERC3DiD) */
175− { aac_rx_init, "percraid", "DELL ", "PERCRAID ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG }, /* PERC 3/Di (Boxster/PERC3DiB) */
176− { aac_rx_init, "aacraid", "ADAPTEC ", "catapult ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG }, /* catapult */
177− { aac_rx_init, "aacraid", "ADAPTEC ", "tomcat ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG }, /* tomcat */
178− { aac_rx_init, "aacraid", "ADAPTEC ", "Adaptec 2120S ", 1, AAC_QUIRK_31BIT | AAC_QUIRK_34SG }, /* Adaptec 2120S (Crusader) */
179− { aac_rx_init, "aacraid", "ADAPTEC ", "Adaptec 2200S ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG }, /* Adaptec 2200S (Vulcan) */
180− { aac_rx_init, "aacraid", "ADAPTEC ", "Adaptec 2200S ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG }, /* Adaptec 2200S (Vulcan-2m) */
181− { aac_rx_init, "aacraid", "Legend ", "Legend S220 ", 1, AAC_QUIRK_31BIT | AAC_QUIRK_34SG }, /* Legend S220 (Legend Crusader) */
182− { aac_rx_init, "aacraid", "Legend ", "Legend S230 ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG }, /* Legend S230 (Legend Vulcan) */
167+ { aac_rx_init, "percraid", "DELL ", "PERCRAID ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG | AAC_QUIRK_SCSI_32 }, /* PERC 2/Si (Iguana/PERC2Si) */
168+ { aac_rx_init, "percraid", "DELL ", "PERCRAID ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG | AAC_QUIRK_SCSI_32 }, /* PERC 3/Di (Opal/PERC3Di) */
169+ { aac_rx_init, "percraid", "DELL ", "PERCRAID ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG | AAC_QUIRK_SCSI_32 }, /* PERC 3/Si (SlimFast/PERC3Si */
170+ { aac_rx_init, "percraid", "DELL ", "PERCRAID ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG | AAC_QUIRK_SCSI_32 }, /* PERC 3/Di (Iguana FlipChip/PERC3DiF */
171+ { aac_rx_init, "percraid", "DELL ", "PERCRAID ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG | AAC_QUIRK_SCSI_32 }, /* PERC 3/Di (Viper/PERC3DiV) */
172+ { aac_rx_init, "percraid", "DELL ", "PERCRAID ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG | AAC_QUIRK_SCSI_32 }, /* PERC 3/Di (Lexus/PERC3DiL) */
173+ { aac_rx_init, "percraid", "DELL ", "PERCRAID ", 1, AAC_QUIRK_31BIT | AAC_QUIRK_34SG | AAC_QUIRK_SCSI_32 }, /* PERC 3/Di (Jaguar/PERC3DiJ) */
174+ { aac_rx_init, "percraid", "DELL ", "PERCRAID ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG | AAC_QUIRK_SCSI_32 }, /* PERC 3/Di (Dagger/PERC3DiD) */
175+ { aac_rx_init, "percraid", "DELL ", "PERCRAID ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG | AAC_QUIRK_SCSI_32 }, /* PERC 3/Di (Boxster/PERC3DiB) */
176+ { aac_rx_init, "aacraid", "ADAPTEC ", "catapult ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG | AAC_QUIRK_SCSI_32 }, /* catapult */
177+ { aac_rx_init, "aacraid", "ADAPTEC ", "tomcat ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG | AAC_QUIRK_SCSI_32 }, /* tomcat */
178+ { aac_rx_init, "aacraid", "ADAPTEC ", "Adaptec 2120S ", 1, AAC_QUIRK_31BIT | AAC_QUIRK_34SG | AAC_QUIRK_SCSI_32 }, /* Adaptec 2120S (Crusader) */
179+ { aac_rx_init, "aacraid", "ADAPTEC ", "Adaptec 2200S ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG | AAC_QUIRK_SCSI_32 }, /* Adaptec 2200S (Vulcan) */
180+ { aac_rx_init, "aacraid", "ADAPTEC ", "Adaptec 2200S ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG | AAC_QUIRK_SCSI_32 }, /* Adaptec 2200S (Vulcan-2m) */
181+ { aac_rx_init, "aacraid", "Legend ", "Legend S220 ", 1, AAC_QUIRK_31BIT | AAC_QUIRK_34SG | AAC_QUIRK_SCSI_32 }, /* Legend S220 (Legend Crusader) */
182+ { aac_rx_init, "aacraid", "Legend ", "Legend S230 ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG | AAC_QUIRK_SCSI_32 }, /* Legend S230 (Legend Vulcan) */
183183
184184 { aac_rx_init, "aacraid", "ADAPTEC ", "Adaptec 3230S ", 2 }, /* Adaptec 3230S (Harrier) */
185185 { aac_rx_init, "aacraid", "ADAPTEC ", "Adaptec 3240S ", 2 }, /* Adaptec 3240S (Tornado) */
@@ -224,8 +224,8 @@ static struct aac_driver_ident aac_drivers[] = { · 38 unmodified lines
224224 { aac_sa_init, "percraid", "DELL ", "PERCRAID ", 4, AAC_QUIRK_34SG }, /* Dell PERC2/QC */
225225 { aac_sa_init, "hpnraid", "HP ", "NetRAID ", 4, AAC_QUIRK_34SG }, /* HP NetRAID-4M */
226226
227− { aac_rx_init, "aacraid", "DELL ", "RAID ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG }, /* Dell Catchall */
228− { aac_rx_init, "aacraid", "Legend ", "RAID ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG }, /* Legend Catchall */
227+ { aac_rx_init, "aacraid", "DELL ", "RAID ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG | AAC_QUIRK_SCSI_32 }, /* Dell Catchall */
228+ { aac_rx_init, "aacraid", "Legend ", "RAID ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG | AAC_QUIRK_SCSI_32 }, /* Legend Catchall */
229229 { aac_rx_init, "aacraid", "ADAPTEC ", "RAID ", 2 }, /* Adaptec Catch All */
230230 { aac_rkt_init, "aacraid", "ADAPTEC ", "RAID ", 2 }, /* Adaptec Rocket Catch All */
231231 { aac_nark_init, "aacraid", "ADAPTEC ", "RAID ", 2 } /* Adaptec NEMER/ARK Catch All */
@@ -239,7 +239,7 @@ static struct aac_driver_ident aac_drivers[] = { · 7 unmodified lines
239239 * Queues a command for execution by the associated Host Adapter.
240240 *
241241 * TODO: unify with aac_scsi_cmd().
242− */
242+ */
243243
244244 static int aac_queuecommand(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
245245 {
@@ -258,7 +258,7 @@ static int aac_queuecommand(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd · 12 unmodified lines
258258 }
259259 cmd->SCp.phase = AAC_OWNER_LOWLEVEL;
260260 return (aac_scsi_cmd(cmd) ? FAILED : 0);
261−}
261+}
262262
263263 /**
264264 * aac_info - Returns the host adapter name
@@ -292,21 +292,21 @@ struct aac_driver_ident* aac_get_driver_ident(int devtype) · 27 unmodified lines
292292 * @capacity: the sector capacity of the disk
293293 * @geom: geometry block to fill in
294294 *
295− * Return the Heads/Sectors/Cylinders BIOS Disk Parameters for Disk.
296− * The default disk geometry is 64 heads, 32 sectors, and the appropriate
297− * number of cylinders so as not to exceed drive capacity. In order for
295+ * Return the Heads/Sectors/Cylinders BIOS Disk Parameters for Disk.
296+ * The default disk geometry is 64 heads, 32 sectors, and the appropriate
297+ * number of cylinders so as not to exceed drive capacity. In order for
298298 * disks equal to or larger than 1 GB to be addressable by the BIOS
299− * without exceeding the BIOS limitation of 1024 cylinders, Extended
300− * Translation should be enabled. With Extended Translation enabled,
301− * drives between 1 GB inclusive and 2 GB exclusive are given a disk
302− * geometry of 128 heads and 32 sectors, and drives above 2 GB inclusive
303− * are given a disk geometry of 255 heads and 63 sectors. However, if
304− * the BIOS detects that the Extended Translation setting does not match
305− * the geometry in the partition table, then the translation inferred
306− * from the partition table will be used by the BIOS, and a warning may
299+ * without exceeding the BIOS limitation of 1024 cylinders, Extended
300+ * Translation should be enabled. With Extended Translation enabled,
301+ * drives between 1 GB inclusive and 2 GB exclusive are given a disk
302+ * geometry of 128 heads and 32 sectors, and drives above 2 GB inclusive
303+ * are given a disk geometry of 255 heads and 63 sectors. However, if
304+ * the BIOS detects that the Extended Translation setting does not match
305+ * the geometry in the partition table, then the translation inferred
306+ * from the partition table will be used by the BIOS, and a warning may
307307 * be displayed.
308308 */
309−
309+
310310 static int aac_biosparm(struct scsi_device *sdev, struct block_device *bdev,
311311 sector_t capacity, int *geom)
312312 {
@@ -333,10 +333,10 @@ static int aac_biosparm(struct scsi_device *sdev, struct block_device *bdev, · 20 unmodified lines
333333
334334 param->cylinders = cap_to_cyls(capacity, param->heads * param->sectors);
335335
336− /*
336+ /*
337337 * Read the first 1024 bytes from the disk device, if the boot
338338 * sector partition table is valid, search for a partition table
339− * entry whose end_head matches one of the standard geometry
339+ * entry whose end_head matches one of the standard geometry
340340 * translations ( 64/32, 128/32, 255/63 ).
341341 */
342342 buf = scsi_bios_ptable(bdev);
@@ -401,30 +401,44 @@ static int aac_biosparm(struct scsi_device *sdev, struct block_device *bdev, · 58 unmodified lines
401401
402402 static int aac_slave_configure(struct scsi_device *sdev)
403403 {
404+ struct aac_dev *aac = (struct aac_dev *)sdev->host->hostdata;
404405 if ((sdev->type == TYPE_DISK) &&
405− (sdev_channel(sdev) != CONTAINER_CHANNEL)) {
406+ (sdev_channel(sdev) != CONTAINER_CHANNEL) &&
407+ (!aac->jbod || sdev->inq_periph_qual) &&
408+ (!aac->raid_scsi_mode || (sdev_channel(sdev) != 2))) {
406409 if (expose_physicals == 0)
407410 return -ENXIO;
408− if (expose_physicals < 0) {
409− struct aac_dev *aac =
410− (struct aac_dev *)sdev->host->hostdata;
411− if (!aac->raid_scsi_mode || (sdev_channel(sdev) != 2))
412− sdev->no_uld_attach = 1;
413− }
411+ if (expose_physicals < 0)
412+ sdev->no_uld_attach = 1;
414413 }
415414 if (sdev->tagged_supported && (sdev->type == TYPE_DISK) &&
416− (sdev_channel(sdev) == CONTAINER_CHANNEL)) {
415+ (!aac->raid_scsi_mode || (sdev_channel(sdev) != 2)) &&
416+ !sdev->no_uld_attach) {
417417 struct scsi_device * dev;
418418 struct Scsi_Host *host = sdev->host;
419419 unsigned num_lsu = 0;
420420 unsigned num_one = 0;
421421 unsigned depth;
422+ unsigned cid;
422423
424+ /*
425+ * Firmware has an individual device recovery time typically
426+ * of 35 seconds, give us a margin.
427+ */
428+ if (sdev->timeout < (45 * HZ))
429+ sdev->timeout = 45 * HZ;
430+ for (cid = 0; cid < aac->maximum_num_containers; ++cid)
431+ if (aac->fsa_dev[cid].valid)
432+ ++num_lsu;
423433 __shost_for_each_device(dev, host) {
424434 if (dev->tagged_supported && (dev->type == TYPE_DISK) &&
425− (sdev_channel(dev) == CONTAINER_CHANNEL))
426− ++num_lsu;
427− else
435+ (!aac->raid_scsi_mode ||
436+ (sdev_channel(sdev) != 2)) &&
437+ !dev->no_uld_attach) {
438+ if ((sdev_channel(dev) != CONTAINER_CHANNEL)
439+ || !aac->fsa_dev[sdev_id(dev)].valid)
440+ ++num_lsu;
441+ } else
428442 ++num_one;
429443 }
430444 if (num_lsu == 0)
@@ -481,9 +495,35 @@ static int aac_change_queue_depth(struct scsi_device *sdev, int depth) · 50 unmodified lines
481495 return sdev->queue_depth;
482496 }
483497
498+static ssize_t aac_show_raid_level(struct device *dev, struct device_attribute *attr, char *buf)
499+{
500+ struct scsi_device * sdev = to_scsi_device(dev);
501+ if (sdev_channel(sdev) != CONTAINER_CHANNEL)
502+ return snprintf(buf, PAGE_SIZE, sdev->no_uld_attach
503+ ? "Hidden\n" : "JBOD");
504+ return snprintf(buf, PAGE_SIZE, "%s\n",
505+ get_container_type(((struct aac_dev *)(sdev->host->hostdata))
506+ ->fsa_dev[sdev_id(sdev)].type));
507+}
508+
509+static struct device_attribute aac_raid_level_attr = {
510+ .attr = {
511+ .name = "level",
512+ .mode = S_IRUGO,
513+ },
514+ .show = aac_show_raid_level
515+};
516+
517+static struct device_attribute *aac_dev_attrs[] = {
518+ &aac_raid_level_attr,
519+ NULL,
520+};
521+
484522 static int aac_ioctl(struct scsi_device *sdev, int cmd, void __user * arg)
485523 {
486524 struct aac_dev *dev = (struct aac_dev *)sdev->host->hostdata;
525+ if (!capable(CAP_SYS_RAWIO))
526+ return -EPERM;
487527 return aac_do_ioctl(dev, cmd, arg);
488528 }
489529
@@ -506,17 +546,33 @@ static int aac_eh_abort(struct scsi_cmnd* cmd) · 16 unmodified lines
506546 break;
507547 case INQUIRY:
508548 case READ_CAPACITY:
509− case TEST_UNIT_READY:
510549 /* Mark associated FIB to not complete, eh handler does this */
511550 for (count = 0; count < (host->can_queue + AAC_NUM_MGT_FIB); ++count) {
512551 struct fib * fib = &aac->fibs[count];
513552 if (fib->hw_fib_va->header.XferState &&
553+ (fib->flags & FIB_CONTEXT_FLAG) &&
514554 (fib->callback_data == cmd)) {
515555 fib->flags |= FIB_CONTEXT_FLAG_TIMED_OUT;
516556 cmd->SCp.phase = AAC_OWNER_ERROR_HANDLER;
517557 ret = SUCCESS;
518558 }
519559 }
560+ break;
561+ case TEST_UNIT_READY:
562+ /* Mark associated FIB to not complete, eh handler does this */
563+ for (count = 0; count < (host->can_queue + AAC_NUM_MGT_FIB); ++count) {
564+ struct scsi_cmnd * command;
565+ struct fib * fib = &aac->fibs[count];
566+ if ((fib->hw_fib_va->header.XferState & cpu_to_le32(Async | NoResponseExpected)) &&
567+ (fib->flags & FIB_CONTEXT_FLAG) &&
568+ ((command = fib->callback_data)) &&
569+ (command->device == cmd->device)) {
570+ fib->flags |= FIB_CONTEXT_FLAG_TIMED_OUT;
571+ command->SCp.phase = AAC_OWNER_ERROR_HANDLER;
572+ if (command == cmd)
573+ ret = SUCCESS;
574+ }
575+ }
520576 }
521577 return ret;
522578 }
@@ -539,12 +595,13 @@ static int aac_eh_reset(struct scsi_cmnd* cmd) · 16 unmodified lines
539595 for (count = 0; count < (host->can_queue + AAC_NUM_MGT_FIB); ++count) {
540596 struct fib * fib = &aac->fibs[count];
541597 if (fib->hw_fib_va->header.XferState &&
598+ (fib->flags & FIB_CONTEXT_FLAG) &&
542599 (fib->callback_data == cmd)) {
543600 fib->flags |= FIB_CONTEXT_FLAG_TIMED_OUT;
544601 cmd->SCp.phase = AAC_OWNER_ERROR_HANDLER;
545602 }
546603 }
547− printk(KERN_ERR "%s: Host adapter reset request. SCSI hang ?\n",
604+ printk(KERN_ERR "%s: Host adapter reset request. SCSI hang ?\n",
548605 AAC_DRIVERNAME);
549606
550607 if ((count = aac_check_health(aac)))
@@ -584,8 +641,11 @@ static int aac_eh_reset(struct scsi_cmnd* cmd) · 33 unmodified lines
584641 * support a register, instead of a commanded, reset.
585642 */
586643 if ((aac->supplement_adapter_info.SupportedOptions2 &
587− le32_to_cpu(AAC_OPTION_MU_RESET|AAC_OPTION_IGNORE_RESET)) ==
588− le32_to_cpu(AAC_OPTION_MU_RESET))
644+ AAC_OPTION_MU_RESET) &&
645+ aac_check_reset &&
646+ ((aac_check_reset != 1) ||
647+ (aac->supplement_adapter_info.SupportedOptions2 &
648+ AAC_OPTION_IGNORE_RESET)))
589649 aac_reset_adapter(aac, 2); /* Bypass wait for command quiesce */
590650 return SUCCESS; /* Cause an immediate retry of the command with a ten second delay after successful tur */
591651 }
@@ -632,8 +692,8 @@ static int aac_cfg_open(struct inode *inode, struct file *file) · 40 unmodified lines
632692 * Bugs: Needs locking against parallel ioctls lower down
633693 * Bugs: Needs to handle hot plugging
634694 */
635−
636−static int aac_cfg_ioctl(struct inode *inode, struct file *file,
695+
696+static int aac_cfg_ioctl(struct inode *inode, struct file *file,
637697 unsigned int cmd, unsigned long arg)
638698 {
639699 if (!capable(CAP_SYS_RAWIO))
@@ -646,7 +706,7 @@ static long aac_compat_do_ioctl(struct aac_dev *dev, unsigned cmd, unsigned long · 6 unmodified lines
646706 {
647707 long ret;
648708 lock_kernel();
649− switch (cmd) {
709+ switch (cmd) {
650710 case FSACTL_MINIPORT_REV_CHECK:
651711 case FSACTL_SENDFIB:
652712 case FSACTL_OPEN_GET_ADAPTER_FIB:
@@ -656,14 +716,14 @@ static long aac_compat_do_ioctl(struct aac_dev *dev, unsigned cmd, unsigned long · 3 unmodified lines
656716 case FSACTL_QUERY_DISK:
657717 case FSACTL_DELETE_DISK:
658718 case FSACTL_FORCE_DELETE_DISK:
659− case FSACTL_GET_CONTAINERS:
719+ case FSACTL_GET_CONTAINERS:
660720 case FSACTL_SEND_LARGE_FIB:
661721 ret = aac_do_ioctl(dev, cmd, (void __user *)arg);
662722 break;
663723
664724 case FSACTL_GET_NEXT_ADAPTER_FIB: {
665725 struct fib_ioctl __user *f;
666−
726+
667727 f = compat_alloc_user_space(sizeof(*f));
668728 ret = 0;
669729 if (clear_user(f, sizeof(*f)))
@@ -676,9 +736,9 @@ static long aac_compat_do_ioctl(struct aac_dev *dev, unsigned cmd, unsigned long · 6 unmodified lines
676736 }
677737
678738 default:
679− ret = -ENOIOCTLCMD;
739+ ret = -ENOIOCTLCMD;
680740 break;
681− }
741+ }
682742 unlock_kernel();
683743 return ret;
684744 }
@@ -735,6 +795,25 @@ static ssize_t aac_show_vendor(struct class_device *class_dev, · 50 unmodified lines
735795 return len;
736796 }
737797
798+static ssize_t aac_show_flags(struct class_device *class_dev, char *buf)
799+{
800+ int len = 0;
801+ struct aac_dev *dev = (struct aac_dev*)class_to_shost(class_dev)->hostdata;
802+
803+ if (nblank(dprintk(x)))
804+ len = snprintf(buf, PAGE_SIZE, "dprintk\n");
805+#ifdef AAC_DETAILED_STATUS_INFO
806+ len += snprintf(buf + len, PAGE_SIZE - len,
807+ "AAC_DETAILED_STATUS_INFO\n");
808+#endif
809+ if (dev->raw_io_interface && dev->raw_io_64)
810+ len += snprintf(buf + len, PAGE_SIZE - len,
811+ "SAI_READ_CAPACITY_16\n");
812+ if (dev->jbod)
813+ len += snprintf(buf + len, PAGE_SIZE - len, "SUPPORTED_JBOD\n");
814+ return len;
815+}
816+
738817 static ssize_t aac_show_kernel_version(struct class_device *class_dev,
739818 char *buf)
740819 {
@@ -742,7 +821,7 @@ static ssize_t aac_show_kernel_version(struct class_device *class_dev, · 1 unmodified line
742821 int len, tmp;
743822
744823 tmp = le32_to_cpu(dev->adapter_info.kernelrev);
745− len = snprintf(buf, PAGE_SIZE, "%d.%d-%d[%d]\n",
824+ len = snprintf(buf, PAGE_SIZE, "%d.%d-%d[%d]\n",
746825 tmp >> 24, (tmp >> 16) & 0xff, tmp & 0xff,
747826 le32_to_cpu(dev->adapter_info.kernelbuild));
748827 return len;
@@ -755,7 +834,7 @@ static ssize_t aac_show_monitor_version(struct class_device *class_dev, · 6 unmodified lines
755834 int len, tmp;
756835
757836 tmp = le32_to_cpu(dev->adapter_info.monitorrev);
758− len = snprintf(buf, PAGE_SIZE, "%d.%d-%d[%d]\n",
837+ len = snprintf(buf, PAGE_SIZE, "%d.%d-%d[%d]\n",
759838 tmp >> 24, (tmp >> 16) & 0xff, tmp & 0xff,
760839 le32_to_cpu(dev->adapter_info.monitorbuild));
761840 return len;
@@ -768,7 +847,7 @@ static ssize_t aac_show_bios_version(struct class_device *class_dev, · 6 unmodified lines
768847 int len, tmp;
769848
770849 tmp = le32_to_cpu(dev->adapter_info.biosrev);
771− len = snprintf(buf, PAGE_SIZE, "%d.%d-%d[%d]\n",
850+ len = snprintf(buf, PAGE_SIZE, "%d.%d-%d[%d]\n",
772851 tmp >> 24, (tmp >> 16) & 0xff, tmp & 0xff,
773852 le32_to_cpu(dev->adapter_info.biosbuild));
774853 return len;
@@ -844,6 +923,13 @@ static struct class_device_attribute aac_vendor = { · 69 unmodified lines
844923 },
845924 .show = aac_show_vendor,
846925 };
926+static struct class_device_attribute aac_flags = {
927+ .attr = {
928+ .name = "flags",
929+ .mode = S_IRUGO,
930+ },
931+ .show = aac_show_flags,
932+};
847933 static struct class_device_attribute aac_kernel_version = {
848934 .attr = {
849935 .name = "hba_kernel_version",
@@ -898,6 +984,7 @@ static struct class_device_attribute aac_reset = { · 48 unmodified lines
898984 static struct class_device_attribute *aac_attrs[] = {
899985 &aac_model,
900986 &aac_vendor,
987+ &aac_flags,
901988 &aac_kernel_version,
902989 &aac_monitor_version,
903990 &aac_bios_version,
@@ -928,21 +1015,22 @@ static struct scsi_host_template aac_driver_template = { · 24 unmodified lines
9281015 .compat_ioctl = aac_compat_ioctl,
9291016 #endif
9301017 .queuecommand = aac_queuecommand,
931− .bios_param = aac_biosparm,
1018+ .bios_param = aac_biosparm,
9321019 .shost_attrs = aac_attrs,
9331020 .slave_configure = aac_slave_configure,
9341021 .change_queue_depth = aac_change_queue_depth,
1022+ .sdev_attrs = aac_dev_attrs,
9351023 .eh_abort_handler = aac_eh_abort,
9361024 .eh_host_reset_handler = aac_eh_reset,
937− .can_queue = AAC_NUM_IO_FIB,
1025+ .can_queue = AAC_NUM_IO_FIB,
9381026 .this_id = MAXIMUM_NUM_CONTAINERS,
9391027 .sg_tablesize = 16,
9401028 .max_sectors = 128,
9411029 #if (AAC_NUM_IO_FIB > 256)
9421030 .cmd_per_lun = 256,
943−#else
944− .cmd_per_lun = AAC_NUM_IO_FIB,
945−#endif
1031+#else
1032+ .cmd_per_lun = AAC_NUM_IO_FIB,
1033+#endif
9461034 .use_clustering = ENABLE_CLUSTERING,
9471035 .use_sg_chaining = ENABLE_SG_CHAINING,
9481036 .emulated = 1,
@@ -979,18 +1067,18 @@ static int __devinit aac_probe_one(struct pci_dev *pdev, · 30 unmodified lines
9791067 goto out;
9801068 error = -ENODEV;
9811069
982− if (pci_set_dma_mask(pdev, DMA_32BIT_MASK) ||
1070+ if (pci_set_dma_mask(pdev, DMA_32BIT_MASK) ||
9831071 pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK))
9841072 goto out_disable_pdev;
9851073 /*
9861074 * If the quirk31 bit is set, the adapter needs adapter
9871075 * to driver communication memory to be allocated below 2gig
9881076 */
989− if (aac_drivers[index].quirks & AAC_QUIRK_31BIT)
1077+ if (aac_drivers[index].quirks & AAC_QUIRK_31BIT)
9901078 if (pci_set_dma_mask(pdev, DMA_31BIT_MASK) ||
9911079 pci_set_consistent_dma_mask(pdev, DMA_31BIT_MASK))
9921080 goto out_disable_pdev;
993−
1081+
9941082 pci_set_master(pdev);
9951083
9961084 shost = scsi_host_alloc(&aac_driver_template, sizeof(struct aac_dev));
@@ -1003,7 +1091,7 @@ static int __devinit aac_probe_one(struct pci_dev *pdev, · 6 unmodified lines
10031091 shost->max_cmd_len = 16;
10041092
10051093 aac = (struct aac_dev *)shost->hostdata;
1006− aac->scsi_host_ptr = shost;
1094+ aac->scsi_host_ptr = shost;
10071095 aac->pdev = pdev;
10081096 aac->name = aac_driver_template.name;
10091097 aac->id = shost->unique_id;
@@ -1040,7 +1128,7 @@ static int __devinit aac_probe_one(struct pci_dev *pdev, · 30 unmodified lines
10401128 if (aac_drivers[index].quirks & AAC_QUIRK_31BIT)
10411129 if (pci_set_dma_mask(pdev, DMA_32BIT_MASK))
10421130 goto out_deinit;
1043−
1131+
10441132 aac->maximum_num_channels = aac_drivers[index].channels;
10451133 error = aac_get_adapter_info(aac);
10461134 if (error < 0)
@@ -1049,7 +1137,7 @@ static int __devinit aac_probe_one(struct pci_dev *pdev, · 2 unmodified lines
10491137 /*
10501138 * Lets override negotiations and drop the maximum SG limit to 34
10511139 */
1052− if ((aac_drivers[index].quirks & AAC_QUIRK_34SG) &&
1140+ if ((aac_drivers[index].quirks & AAC_QUIRK_34SG) &&
10531141 (aac->scsi_host_ptr->sg_tablesize > 34)) {
10541142 aac->scsi_host_ptr->sg_tablesize = 34;
10551143 aac->scsi_host_ptr->max_sectors
@@ -1066,17 +1154,17 @@ static int __devinit aac_probe_one(struct pci_dev *pdev, · 10 unmodified lines
10661154 /*
10671155 * Firware printf works only with older firmware.
10681156 */
1069− if (aac_drivers[index].quirks & AAC_QUIRK_34SG)
1157+ if (aac_drivers[index].quirks & AAC_QUIRK_34SG)
10701158 aac->printf_enabled = 1;
10711159 else
10721160 aac->printf_enabled = 0;
1073−
1161+
10741162 /*
10751163 * max channel will be the physical channels plus 1 virtual channel
10761164 * all containers are on the virtual channel 0 (CONTAINER_CHANNEL)
10771165 * physical channels are address by their actual physical number+1
10781166 */
1079− if ((aac->nondasd_support == 1) || expose_physicals)
1167+ if (aac->nondasd_support || expose_physicals || aac->jbod)
10801168 shost->max_channel = aac->maximum_num_channels;
10811169 else
10821170 shost->max_channel = 0;
@@ -1148,10 +1236,10 @@ static void __devexit aac_remove_one(struct pci_dev *pdev) · 65 unmodified lines
11481236 kfree(aac->queues);
11491237
11501238 aac_adapter_ioremap(aac, 0);
1151−
1239+
11521240 kfree(aac->fibs);
11531241 kfree(aac->fsa_dev);
1154−
1242+
11551243 list_del(&aac->entry);
11561244 scsi_host_put(shost);
11571245 pci_disable_device(pdev);
@@ -1172,7 +1260,7 @@ static struct pci_driver aac_pci_driver = { · 14 unmodified lines
11721260 static int __init aac_init(void)
11731261 {
11741262 int error;
1175−
1263+
11761264 printk(KERN_INFO "Adaptec %s driver %s\n",
11771265 AAC_DRIVERNAME, aac_driver_version);
11781266
drivers/scsi/aacraid/rx.c+4−2
@@ -465,7 +465,7 @@ static int aac_rx_restart_adapter(struct aac_dev *dev, int bled) · 464 unmodified lines
465465 u32 var;
466466
467467 if (!(dev->supplement_adapter_info.SupportedOptions2 &
468− le32_to_cpu(AAC_OPTION_MU_RESET)) || (bled >= 0) || (bled == -2)) {
468+ AAC_OPTION_MU_RESET) || (bled >= 0) || (bled == -2)) {
469469 if (bled)
470470 printk(KERN_ERR "%s%d: adapter kernel panic'd %x.\n",
471471 dev->name, dev->id, bled);
@@ -549,7 +549,9 @@ int _aac_rx_init(struct aac_dev *dev) · 77 unmodified lines
549549 dev->OIMR = status = rx_readb (dev, MUnit.OIMR);
550550 if ((((status & 0x0c) != 0x0c) || aac_reset_devices || reset_devices) &&
551551 !aac_rx_restart_adapter(dev, 0))
552− ++restart;
552+ /* Make sure the Hardware FIFO is empty */
553+ while ((++restart < 512) &&
554+ (rx_readl(dev, MUnit.OutboundQueue) != 0xFFFFFFFFL));
553555 /*
554556 * Check to see if the board panic'd while booting.
555557 */
drivers/scsi/advansys.c+7−7
@@ -8233,7 +8233,7 @@ static void adv_isr_callback(ADV_DVC_VAR *adv_dvc_varp, ADV_SCSI_REQ_Q *scsiqp) · 8232 unmodified lines
82338233 if (scsiqp->scsi_status == SAM_STAT_CHECK_CONDITION) {
82348234 ASC_DBG(2, "SAM_STAT_CHECK_CONDITION\n");
82358235 ASC_DBG_PRT_SENSE(2, scp->sense_buffer,
8236− sizeof(scp->sense_buffer));
8236+ SCSI_SENSE_BUFFERSIZE);
82378237 /*
82388238 * Note: The 'status_byte()' macro used by
82398239 * target drivers defined in scsi.h shifts the
@@ -9136,7 +9136,7 @@ static void asc_isr_callback(ASC_DVC_VAR *asc_dvc_varp, ASC_QDONE_INFO *qdonep) · 896 unmodified lines
91369136 BUG_ON(asc_dvc_varp != &boardp->dvc_var.asc_dvc_var);
91379137
91389138 dma_unmap_single(boardp->dev, scp->SCp.dma_handle,
9139− sizeof(scp->sense_buffer), DMA_FROM_DEVICE);
9139+ SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE);
91409140 /*
91419141 * 'qdonep' contains the command's ending status.
91429142 */
@@ -9166,7 +9166,7 @@ static void asc_isr_callback(ASC_DVC_VAR *asc_dvc_varp, ASC_QDONE_INFO *qdonep) · 23 unmodified lines
91669166 if (qdonep->d3.scsi_stat == SAM_STAT_CHECK_CONDITION) {
91679167 ASC_DBG(2, "SAM_STAT_CHECK_CONDITION\n");
91689168 ASC_DBG_PRT_SENSE(2, scp->sense_buffer,
9169− sizeof(scp->sense_buffer));
9169+ SCSI_SENSE_BUFFERSIZE);
91709170 /*
91719171 * Note: The 'status_byte()' macro used by
91729172 * target drivers defined in scsi.h shifts the
@@ -9881,9 +9881,9 @@ static __le32 advansys_get_sense_buffer_dma(struct scsi_cmnd *scp) · 708 unmodified lines
98819881 {
98829882 struct asc_board *board = shost_priv(scp->device->host);
98839883 scp->SCp.dma_handle = dma_map_single(board->dev, scp->sense_buffer,
9884− sizeof(scp->sense_buffer), DMA_FROM_DEVICE);
9884+ SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE);
98859885 dma_cache_sync(board->dev, scp->sense_buffer,
9886− sizeof(scp->sense_buffer), DMA_FROM_DEVICE);
9886+ SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE);
98879887 return cpu_to_le32(scp->SCp.dma_handle);
98889888 }
98899889
@@ -9914,7 +9914,7 @@ static int asc_build_req(struct asc_board *boardp, struct scsi_cmnd *scp, · 24 unmodified lines
99149914 asc_scsi_q->q2.target_ix =
99159915 ASC_TIDLUN_TO_IX(scp->device->id, scp->device->lun);
99169916 asc_scsi_q->q1.sense_addr = advansys_get_sense_buffer_dma(scp);
9917− asc_scsi_q->q1.sense_len = sizeof(scp->sense_buffer);
9917+ asc_scsi_q->q1.sense_len = SCSI_SENSE_BUFFERSIZE;
99189918
99199919 /*
99209920 * If there are any outstanding requests for the current target,
@@ -10173,7 +10173,7 @@ adv_build_req(struct asc_board *boardp, struct scsi_cmnd *scp, · 252 unmodified lines
1017310173 scsiqp->target_lun = scp->device->lun;
1017410174
1017510175 scsiqp->sense_addr = cpu_to_le32(virt_to_bus(&scp->sense_buffer[0]));
10176− scsiqp->sense_len = sizeof(scp->sense_buffer);
10176+ scsiqp->sense_len = SCSI_SENSE_BUFFERSIZE;
1017710177
1017810178 /* Build ADV_SCSI_REQ_Q */
1017910179
drivers/scsi/aha152x.c+8−30
@@ -260,6 +260,7 @@ · 259 unmodified lines
260260 #include <scsi/scsi_dbg.h>
261261 #include <scsi/scsi_host.h>
262262 #include <scsi/scsi_transport_spi.h>
263+#include <scsi/scsi_eh.h>
263264 #include "aha152x.h"
264265
265266 static LIST_HEAD(aha152x_host_list);
@@ -558,9 +559,7 @@ struct aha152x_hostdata { · 292 unmodified lines
558559 struct aha152x_scdata {
559560 Scsi_Cmnd *next; /* next sc in queue */
560561 struct completion *done;/* semaphore to block on */
561− unsigned char aha_orig_cmd_len;
562− unsigned char aha_orig_cmnd[MAX_COMMAND_SIZE];
563− int aha_orig_resid;
562+ struct scsi_eh_save ses;
564563 };
565564
566565 /* access macros for hostdata */
@@ -1017,16 +1016,10 @@ static int aha152x_internal_queue(Scsi_Cmnd *SCpnt, struct completion *complete, · 450 unmodified lines
10171016 SCp.buffers_residual : left buffers in list
10181017 SCp.phase : current state of the command */
10191018
1020− if ((phase & (check_condition|resetting)) || !scsi_sglist(SCpnt)) {
1021− if (phase & check_condition) {
1022− SCpnt->SCp.ptr = SCpnt->sense_buffer;
1023− SCpnt->SCp.this_residual = sizeof(SCpnt->sense_buffer);
1024− scsi_set_resid(SCpnt, sizeof(SCpnt->sense_buffer));
1025− } else {
1026− SCpnt->SCp.ptr = NULL;
1027− SCpnt->SCp.this_residual = 0;
1028− scsi_set_resid(SCpnt, 0);
1029− }
1019+ if ((phase & resetting) || !scsi_sglist(SCpnt)) {
1020+ SCpnt->SCp.ptr = NULL;
1021+ SCpnt->SCp.this_residual = 0;
1022+ scsi_set_resid(SCpnt, 0);
10301023 SCpnt->SCp.buffer = NULL;
10311024 SCpnt->SCp.buffers_residual = 0;
10321025 } else {
@@ -1561,10 +1554,7 @@ static void busfree_run(struct Scsi_Host *shpnt) · 528 unmodified lines
15611554 }
15621555 #endif
15631556
1564− /* restore old command */
1565− memcpy(cmd->cmnd, sc->aha_orig_cmnd, sizeof(cmd->cmnd));
1566− cmd->cmd_len = sc->aha_orig_cmd_len;
1567− scsi_set_resid(cmd, sc->aha_orig_resid);
1557+ scsi_eh_restore_cmnd(cmd, &sc->ses);
15681558
15691559 cmd->SCp.Status = SAM_STAT_CHECK_CONDITION;
15701560
@@ -1587,22 +1577,10 @@ static void busfree_run(struct Scsi_Host *shpnt) · 16 unmodified lines
15871577 DPRINTK(debug_eh, ERR_LEAD "requesting sense\n", CMDINFO(ptr));
15881578 #endif
15891579
1590− /* save old command */
15911580 sc = SCDATA(ptr);
15921581 /* It was allocated in aha152x_internal_queue? */
15931582 BUG_ON(!sc);
1594− memcpy(sc->aha_orig_cmnd, ptr->cmnd,
1595− sizeof(ptr->cmnd));
1596− sc->aha_orig_cmd_len = ptr->cmd_len;
1597− sc->aha_orig_resid = scsi_get_resid(ptr);
1598−
1599− ptr->cmnd[0] = REQUEST_SENSE;
1600− ptr->cmnd[1] = 0;
1601− ptr->cmnd[2] = 0;
1602− ptr->cmnd[3] = 0;
1603− ptr->cmnd[4] = sizeof(ptr->sense_buffer);
1604− ptr->cmnd[5] = 0;
1605− ptr->cmd_len = 6;
1583+ scsi_eh_prep_cmnd(ptr, &sc->ses, NULL, 0, ~0);
16061584
16071585 DO_UNLOCK(flags);
16081586 aha152x_internal_queue(ptr, NULL, check_condition, ptr->scsi_done);
drivers/scsi/aha1542.c+12−37
@@ -51,15 +51,6 @@ · 50 unmodified lines
5151 #define SCSI_BUF_PA(address) isa_virt_to_bus(address)
5252 #define SCSI_SG_PA(sgent) (isa_page_to_bus(sg_page((sgent))) + (sgent)->offset)
5353
54−static void BAD_DMA(void *address, unsigned int length)
55−{
56− printk(KERN_CRIT "buf vaddress %p paddress 0x%lx length %d\n",
57− address,
58− SCSI_BUF_PA(address),
59− length);
60− panic("Buffer at physical address > 16Mb used for aha1542");
61−}
62−
6354 static void BAD_SG_DMA(Scsi_Cmnd * SCpnt,
6455 struct scatterlist *sgp,
6556 int nseg,
@@ -545,7 +536,7 @@ static void aha1542_intr_handle(struct Scsi_Host *shost, void *dev_id) · 479 unmodified lines
545536 we will still have it in the cdb when we come back */
546537 if (ccb[mbo].tarstat == 2)
547538 memcpy(SCtmp->sense_buffer, &ccb[mbo].cdb[ccb[mbo].cdblen],
548− sizeof(SCtmp->sense_buffer));
539+ SCSI_SENSE_BUFFERSIZE);
549540
550541
551542 /* is there mail :-) */
@@ -597,8 +588,7 @@ static int aha1542_queuecommand(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *)) · 45 unmodified lines
597588 unchar target = SCpnt->device->id;
598589 unchar lun = SCpnt->device->lun;
599590 unsigned long flags;
600− void *buff = SCpnt->request_buffer;
601− int bufflen = SCpnt->request_bufflen;
591+ int bufflen = scsi_bufflen(SCpnt);
602592 int mbo;
603593 struct mailbox *mb;
604594 struct ccb *ccb;
@@ -619,7 +609,7 @@ static int aha1542_queuecommand(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *)) · 14 unmodified lines
619609 #if 0
620610 /* scsi_request_sense() provides a buffer of size 256,
621611 so there is no reason to expect equality */
622− if (bufflen != sizeof(SCpnt->sense_buffer))
612+ if (bufflen != SCSI_SENSE_BUFFERSIZE)
623613 printk(KERN_CRIT "aha1542: Wrong buffer length supplied "
624614 "for request sense (%d)\n", bufflen);
625615 #endif
@@ -689,42 +679,29 @@ static int aha1542_queuecommand(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *)) · 63 unmodified lines
689679
690680 memcpy(ccb[mbo].cdb, cmd, ccb[mbo].cdblen);
691681
692− if (SCpnt->use_sg) {
682+ if (bufflen) {
693683 struct scatterlist *sg;
694684 struct chain *cptr;
695685 #ifdef DEBUG
696686 unsigned char *ptr;
697687 #endif
698− int i;
688+ int i, sg_count = scsi_sg_count(SCpnt);
699689 ccb[mbo].op = 2; /* SCSI Initiator Command w/scatter-gather */
700− SCpnt->host_scribble = kmalloc(512, GFP_KERNEL | GFP_DMA);
690+ SCpnt->host_scribble = kmalloc(sizeof(*cptr)*sg_count,
691+ GFP_KERNEL | GFP_DMA);
701692 cptr = (struct chain *) SCpnt->host_scribble;
702693 if (cptr == NULL) {
703694 /* free the claimed mailbox slot */
704695 HOSTDATA(SCpnt->device->host)->SCint[mbo] = NULL;
705696 return SCSI_MLQUEUE_HOST_BUSY;
706697 }
707− scsi_for_each_sg(SCpnt, sg, SCpnt->use_sg, i) {
708− if (sg->length == 0 || SCpnt->use_sg > 16 ||
709− (((int) sg->offset) & 1) || (sg->length & 1)) {
710− unsigned char *ptr;
711− printk(KERN_CRIT "Bad segment list supplied to aha1542.c (%d, %d)\n", SCpnt->use_sg, i);
712− scsi_for_each_sg(SCpnt, sg, SCpnt->use_sg, i) {
713− printk(KERN_CRIT "%d: %p %d\n", i,
714− sg_virt(sg), sg->length);
715− };
716− printk(KERN_CRIT "cptr %x: ", (unsigned int) cptr);
717− ptr = (unsigned char *) &cptr[i];
718− for (i = 0; i < 18; i++)
719− printk("%02x ", ptr[i]);
720− panic("Foooooooood fight!");
721− };
698+ scsi_for_each_sg(SCpnt, sg, sg_count, i) {
722699 any2scsi(cptr[i].dataptr, SCSI_SG_PA(sg));
723700 if (SCSI_SG_PA(sg) + sg->length - 1 > ISA_DMA_THRESHOLD)
724− BAD_SG_DMA(SCpnt, sg, SCpnt->use_sg, i);
701+ BAD_SG_DMA(SCpnt, scsi_sglist(SCpnt), sg_count, i);
725702 any2scsi(cptr[i].datalen, sg->length);
726703 };
727− any2scsi(ccb[mbo].datalen, SCpnt->use_sg * sizeof(struct chain));
704+ any2scsi(ccb[mbo].datalen, sg_count * sizeof(struct chain));
728705 any2scsi(ccb[mbo].dataptr, SCSI_BUF_PA(cptr));
729706 #ifdef DEBUG
730707 printk("cptr %x: ", cptr);
@@ -735,10 +712,8 @@ static int aha1542_queuecommand(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *)) · 4 unmodified lines
735712 } else {
736713 ccb[mbo].op = 0; /* SCSI Initiator Command */
737714 SCpnt->host_scribble = NULL;
738− any2scsi(ccb[mbo].datalen, bufflen);
739− if (buff && SCSI_BUF_PA(buff + bufflen - 1) > ISA_DMA_THRESHOLD)
740− BAD_DMA(buff, bufflen);
741− any2scsi(ccb[mbo].dataptr, SCSI_BUF_PA(buff));
715+ any2scsi(ccb[mbo].datalen, 0);
716+ any2scsi(ccb[mbo].dataptr, 0);
742717 };
743718 ccb[mbo].idlun = (target & 7) << 5 | direction | (lun & 7); /*SCSI Target Id */
744719 ccb[mbo].rsalen = 16;
drivers/scsi/aha1740.c+1−1
@@ -286,7 +286,7 @@ static irqreturn_t aha1740_intr_handle(int irq, void *dev_id) · 285 unmodified lines
286286 cdb when we come back */
287287 if ( (adapstat & G2INTST_MASK) == G2INTST_CCBERROR ) {
288288 memcpy(SCtmp->sense_buffer, ecbptr->sense,
289− sizeof(SCtmp->sense_buffer));
289+ SCSI_SENSE_BUFFERSIZE);
290290 errstatus = aha1740_makecode(ecbptr->sense,ecbptr->status);
291291 } else
292292 errstatus = 0;
drivers/scsi/aic7xxx/Makefile+18−27
@@ -33,11 +33,10 @@ aic79xx-y += aic79xx_osm.o \ · 32 unmodified lines
3333 aic79xx_proc.o \
3434 aic79xx_osm_pci.o
3535
36−EXTRA_CFLAGS += -Idrivers/scsi
36+ccflags-y += -Idrivers/scsi
3737 ifdef WARNINGS_BECOME_ERRORS
38−EXTRA_CFLAGS += -Werror
38+ccflags-y += -Werror
3939 endif
40−#EXTRA_CFLAGS += -g
4140
4241 # Files generated that shall be removed upon make clean
4342 clean-files := aic7xxx_seq.h aic7xxx_reg.h aic7xxx_reg_print.c
@@ -46,53 +45,45 @@ clean-files += aic79xx_seq.h aic79xx_reg.h aic79xx_reg_print.c · 2 unmodified lines
4645 # Dependencies for generated files need to be listed explicitly
4746
4847 $(obj)/aic7xxx_core.o: $(obj)/aic7xxx_seq.h
48+$(obj)/aic7xxx_core.o: $(obj)/aic7xxx_reg.h
4949 $(obj)/aic79xx_core.o: $(obj)/aic79xx_seq.h
50−$(obj)/aic79xx_reg_print.c: $(src)/aic79xx_reg_print.c_shipped
51−$(obj)/aic7xxx_reg_print.c: $(src)/aic7xxx_reg_print.c_shipped
50+$(obj)/aic79xx_core.o: $(obj)/aic79xx_reg.h
5251
53−$(addprefix $(obj)/,$(aic7xxx-y)): $(obj)/aic7xxx_reg.h
54−$(addprefix $(obj)/,$(aic79xx-y)): $(obj)/aic79xx_reg.h
52+$(addprefix $(obj)/,$(aic7xxx-y)): $(obj)/aic7xxx_seq.h
53+$(addprefix $(obj)/,$(aic79xx-y)): $(obj)/aic79xx_seq.h
5554
56−aic7xxx-gen-$(CONFIG_AIC7XXX_BUILD_FIRMWARE) := $(obj)/aic7xxx_seq.h \
57− $(obj)/aic7xxx_reg.h
55+aic7xxx-gen-$(CONFIG_AIC7XXX_BUILD_FIRMWARE) := $(obj)/aic7xxx_reg.h
5856 aic7xxx-gen-$(CONFIG_AIC7XXX_REG_PRETTY_PRINT) += $(obj)/aic7xxx_reg_print.c
5957
6058 aicasm-7xxx-opts-$(CONFIG_AIC7XXX_REG_PRETTY_PRINT) := \
6159 -p $(obj)/aic7xxx_reg_print.c -i aic7xxx_osm.h
6260
6361 ifeq ($(CONFIG_AIC7XXX_BUILD_FIRMWARE),y)
64−# Create a dependency chain in generated files
65−# to avoid concurrent invocations of the single
66−# rule that builds them all.
67−aic7xxx_seq.h: aic7xxx_reg.h
68−ifeq ($(CONFIG_AIC7XXX_REG_PRETTY_PRINT),y)
69−aic7xxx_reg.h: aic7xxx_reg_print.c
70−endif
71−$(aic7xxx-gen-y): $(src)/aic7xxx.seq $(src)/aic7xxx.reg $(obj)/aicasm/aicasm
62+$(obj)/aic7xxx_seq.h: $(src)/aic7xxx.seq $(src)/aic7xxx.reg $(obj)/aicasm/aicasm
7263 $(obj)/aicasm/aicasm -I$(src) -r $(obj)/aic7xxx_reg.h \
7364 $(aicasm-7xxx-opts-y) -o $(obj)/aic7xxx_seq.h \
7465 $(src)/aic7xxx.seq
66+
67+$(aic7xxx-gen-y): $(obj)/aic7xxx_seq.h
68+else
69+$(obj)/aic7xxx_reg_print.c: $(src)/aic7xxx_reg_print.c_shipped
7570 endif
7671
77−aic79xx-gen-$(CONFIG_AIC79XX_BUILD_FIRMWARE) := $(obj)/aic79xx_seq.h \
78− $(obj)/aic79xx_reg.h
72+aic79xx-gen-$(CONFIG_AIC79XX_BUILD_FIRMWARE) := $(obj)/aic79xx_reg.h
7973 aic79xx-gen-$(CONFIG_AIC79XX_REG_PRETTY_PRINT) += $(obj)/aic79xx_reg_print.c
8074
8175 aicasm-79xx-opts-$(CONFIG_AIC79XX_REG_PRETTY_PRINT) := \
8276 -p $(obj)/aic79xx_reg_print.c -i aic79xx_osm.h
8377
8478 ifeq ($(CONFIG_AIC79XX_BUILD_FIRMWARE),y)
85−# Create a dependency chain in generated files
86−# to avoid concurrent invocations of the single
87−# rule that builds them all.
88−aic79xx_seq.h: aic79xx_reg.h
89−ifeq ($(CONFIG_AIC79XX_REG_PRETTY_PRINT),y)
90−aic79xx_reg.h: aic79xx_reg_print.c
91−endif
92−$(aic79xx-gen-y): $(src)/aic79xx.seq $(src)/aic79xx.reg $(obj)/aicasm/aicasm
79+$(obj)/aic79xx_seq.h: $(src)/aic79xx.seq $(src)/aic79xx.reg $(obj)/aicasm/aicasm
9380 $(obj)/aicasm/aicasm -I$(src) -r $(obj)/aic79xx_reg.h \
9481 $(aicasm-79xx-opts-y) -o $(obj)/aic79xx_seq.h \
9582 $(src)/aic79xx.seq
83+
84+$(aic79xx-gen-y): $(obj)/aic79xx_seq.h
85+else
86+$(obj)/aic79xx_reg_print.c: $(src)/aic79xx_reg_print.c_shipped
9687 endif
9788
9889 $(obj)/aicasm/aicasm: $(src)/aicasm/*.[chyl]
drivers/scsi/aic7xxx/aic79xx_osm.c+3−3
@@ -1784,7 +1784,7 @@ ahd_linux_handle_scsi_status(struct ahd_softc *ahd, · 1783 unmodified lines
17841784 if (scb->flags & SCB_SENSE) {
17851785 sense_size = min(sizeof(struct scsi_sense_data)
17861786 - ahd_get_sense_residual(scb),
1787− (u_long)sizeof(cmd->sense_buffer));
1787+ (u_long)SCSI_SENSE_BUFFERSIZE);
17881788 sense_offset = 0;
17891789 } else {
17901790 /*
@@ -1795,11 +1795,11 @@ ahd_linux_handle_scsi_status(struct ahd_softc *ahd, · 4 unmodified lines
17951795 scb->sense_data;
17961796 sense_size = min_t(size_t,
17971797 scsi_4btoul(siu->sense_length),
1798− sizeof(cmd->sense_buffer));
1798+ SCSI_SENSE_BUFFERSIZE);
17991799 sense_offset = SIU_SENSE_OFFSET(siu);
18001800 }
18011801
1802− memset(cmd->sense_buffer, 0, sizeof(cmd->sense_buffer));
1802+ memset(cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
18031803 memcpy(cmd->sense_buffer,
18041804 ahd_get_sense_buf(ahd, scb)
18051805 + sense_offset, sense_size);
drivers/scsi/aic7xxx/aic7xxx_osm.c+3−3
@@ -1801,12 +1801,12 @@ ahc_linux_handle_scsi_status(struct ahc_softc *ahc, · 1800 unmodified lines
18011801
18021802 sense_size = min(sizeof(struct scsi_sense_data)
18031803 - ahc_get_sense_residual(scb),
1804− (u_long)sizeof(cmd->sense_buffer));
1804+ (u_long)SCSI_SENSE_BUFFERSIZE);
18051805 memcpy(cmd->sense_buffer,
18061806 ahc_get_sense_buf(ahc, scb), sense_size);
1807− if (sense_size < sizeof(cmd->sense_buffer))
1807+ if (sense_size < SCSI_SENSE_BUFFERSIZE)
18081808 memset(&cmd->sense_buffer[sense_size], 0,
1809− sizeof(cmd->sense_buffer) - sense_size);
1809+ SCSI_SENSE_BUFFERSIZE - sense_size);
18101810 cmd->result |= (DRIVER_SENSE << 24);
18111811 #ifdef AHC_DEBUG
18121812 if (ahc_debug & AHC_SHOW_SENSE) {
drivers/scsi/aic7xxx_old.c+5−6
@@ -2696,7 +2696,7 @@ aic7xxx_done(struct aic7xxx_host *p, struct aic7xxx_scb *scb) · 2695 unmodified lines
26962696 {
26972697 pci_unmap_single(p->pdev,
26982698 le32_to_cpu(scb->sg_list[0].address),
2699− sizeof(cmd->sense_buffer),
2699+ SCSI_SENSE_BUFFERSIZE,
27002700 PCI_DMA_FROMDEVICE);
27012701 }
27022702 if (scb->flags & SCB_RECOVERY_SCB)
@@ -4267,13 +4267,13 @@ aic7xxx_handle_seqint(struct aic7xxx_host *p, unsigned char intstat) · 1564 unmodified lines
42674267 sizeof(generic_sense));
42684268
42694269 scb->sense_cmd[1] = (cmd->device->lun << 5);
4270− scb->sense_cmd[4] = sizeof(cmd->sense_buffer);
4270+ scb->sense_cmd[4] = SCSI_SENSE_BUFFERSIZE;
42714271
42724272 scb->sg_list[0].length =
4273− cpu_to_le32(sizeof(cmd->sense_buffer));
4273+ cpu_to_le32(SCSI_SENSE_BUFFERSIZE);
42744274 scb->sg_list[0].address =
42754275 cpu_to_le32(pci_map_single(p->pdev, cmd->sense_buffer,
4276− sizeof(cmd->sense_buffer),
4276+ SCSI_SENSE_BUFFERSIZE,
42774277 PCI_DMA_FROMDEVICE));
42784278
42794279 /*
@@ -4296,7 +4296,7 @@ aic7xxx_handle_seqint(struct aic7xxx_host *p, unsigned char intstat) · 16 unmodified lines
42964296 hscb->residual_data_count[2] = 0;
42974297
42984298 scb->sg_count = hscb->SG_segment_count = 1;
4299− scb->sg_length = sizeof(cmd->sense_buffer);
4299+ scb->sg_length = SCSI_SENSE_BUFFERSIZE;
43004300 scb->tag_action = 0;
43014301 scb->flags |= SCB_SENSE;
43024302 /*
@@ -10293,7 +10293,6 @@ static int aic7xxx_queue(struct scsi_cmnd *cmd, void (*fn)(struct scsi_cmnd *)) · 5990 unmodified lines
1029310293 aic7xxx_position(cmd) = scb->hscb->tag;
1029410294 cmd->scsi_done = fn;
1029510295 cmd->result = DID_OK;
10296− memset(cmd->sense_buffer, 0, sizeof(cmd->sense_buffer));
1029710296 aic7xxx_error(cmd) = DID_OK;
1029810297 aic7xxx_status(cmd) = 0;
1029910298 cmd->host_scribble = NULL;
drivers/scsi/aic94xx/aic94xx_dev.c+3−3
@@ -165,7 +165,7 @@ static int asd_init_target_ddb(struct domain_device *dev) · 164 unmodified lines
165165 if (dev->port->oob_mode != SATA_OOB_MODE) {
166166 flags |= OPEN_REQUIRED;
167167 if ((dev->dev_type == SATA_DEV) ||
168− (dev->tproto & SAS_PROTO_STP)) {
168+ (dev->tproto & SAS_PROTOCOL_STP)) {
169169 struct smp_resp *rps_resp = &dev->sata_dev.rps_resp;
170170 if (rps_resp->frame_type == SMP_RESPONSE &&
171171 rps_resp->function == SMP_REPORT_PHY_SATA &&
@@ -193,7 +193,7 @@ static int asd_init_target_ddb(struct domain_device *dev) · 21 unmodified lines
193193 asd_ddbsite_write_byte(asd_ha, ddb, DDB_TARG_FLAGS, flags);
194194
195195 flags = 0;
196− if (dev->tproto & SAS_PROTO_STP)
196+ if (dev->tproto & SAS_PROTOCOL_STP)
197197 flags |= STP_CL_POL_NO_TX;
198198 asd_ddbsite_write_byte(asd_ha, ddb, DDB_TARG_FLAGS2, flags);
199199
@@ -201,7 +201,7 @@ static int asd_init_target_ddb(struct domain_device *dev) · 1 unmodified line
201201 asd_ddbsite_write_word(asd_ha, ddb, SEND_QUEUE_TAIL, 0xFFFF);
202202 asd_ddbsite_write_word(asd_ha, ddb, SISTER_DDB, 0xFFFF);
203203
204− if (dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTO_STP)) {
204+ if (dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_STP)) {
205205 i = asd_init_sata(dev);
206206 if (i < 0) {
207207 asd_free_ddb(asd_ha, ddb);
drivers/scsi/aic94xx/aic94xx_dump.c+2−2
@@ -903,11 +903,11 @@ void asd_dump_frame_rcvd(struct asd_phy *phy, · 902 unmodified lines
903903 int i;
904904
905905 switch ((dl->status_block[1] & 0x70) >> 3) {
906− case SAS_PROTO_STP:
906+ case SAS_PROTOCOL_STP:
907907 ASD_DPRINTK("STP proto device-to-host FIS:\n");
908908 break;
909909 default:
910− case SAS_PROTO_SSP:
910+ case SAS_PROTOCOL_SSP:
911911 ASD_DPRINTK("SAS proto IDENTIFY:\n");
912912 break;
913913 }
drivers/scsi/aic94xx/aic94xx_hwi.c+1−1
@@ -91,7 +91,7 @@ static int asd_init_phy(struct asd_phy *phy) · 90 unmodified lines
9191
9292 sas_phy->enabled = 1;
9393 sas_phy->class = SAS;
94− sas_phy->iproto = SAS_PROTO_ALL;
94+ sas_phy->iproto = SAS_PROTOCOL_ALL;
9595 sas_phy->tproto = 0;
9696 sas_phy->type = PHY_TYPE_PHYSICAL;
9797 sas_phy->role = PHY_ROLE_INITIATOR;
drivers/scsi/aic94xx/aic94xx_hwi.h+3−0
@@ -72,6 +72,7 @@ struct flash_struct { · 71 unmodified lines
7272 u8 manuf;
7373 u8 dev_id;
7474 u8 sec_prot;
75+ u8 method;
7576
7677 u32 dir_offs;
7778 };
@@ -216,6 +217,8 @@ struct asd_ha_struct { · 138 unmodified lines
216217 struct dma_pool *scb_pool;
217218
218219 struct asd_seq_data seq; /* sequencer related */
220+ u32 bios_status;
221+ const struct firmware *bios_image;
219222 };
220223
221224 /* ---------- Common macros ---------- */
drivers/scsi/aic94xx/aic94xx_init.c+187−3
@@ -29,6 +29,7 @@ · 28 unmodified lines
2929 #include <linux/kernel.h>
3030 #include <linux/pci.h>
3131 #include <linux/delay.h>
32+#include <linux/firmware.h>
3233
3334 #include <scsi/scsi_host.h>
3435
@@ -36,6 +37,7 @@ · 1 unmodified line
3637 #include "aic94xx_reg.h"
3738 #include "aic94xx_hwi.h"
3839 #include "aic94xx_seq.h"
40+#include "aic94xx_sds.h"
3941
4042 /* The format is "version.release.patchlevel" */
4143 #define ASD_DRIVER_VERSION "1.0.3"
@@ -134,7 +136,7 @@ Err: · 92 unmodified lines
134136 return err;
135137 }
136138
137−static void __devexit asd_unmap_memio(struct asd_ha_struct *asd_ha)
139+static void asd_unmap_memio(struct asd_ha_struct *asd_ha)
138140 {
139141 struct asd_ha_addrspace *io_handle;
140142
@@ -171,7 +173,7 @@ static int __devinit asd_map_ioport(struct asd_ha_struct *asd_ha) · 30 unmodified lines
171173 return err;
172174 }
173175
174−static void __devexit asd_unmap_ioport(struct asd_ha_struct *asd_ha)
176+static void asd_unmap_ioport(struct asd_ha_struct *asd_ha)
175177 {
176178 pci_release_region(asd_ha->pcidev, PCI_IOBAR_OFFSET);
177179 }
@@ -208,7 +210,7 @@ Err: · 30 unmodified lines
208210 return err;
209211 }
210212
211−static void __devexit asd_unmap_ha(struct asd_ha_struct *asd_ha)
213+static void asd_unmap_ha(struct asd_ha_struct *asd_ha)
212214 {
213215 if (asd_ha->iospace)
214216 asd_unmap_ioport(asd_ha);
@@ -313,6 +315,181 @@ static ssize_t asd_show_dev_pcba_sn(struct device *dev, · 98 unmodified lines
313315 }
314316 static DEVICE_ATTR(pcba_sn, S_IRUGO, asd_show_dev_pcba_sn, NULL);
315317
318+#define FLASH_CMD_NONE 0x00
319+#define FLASH_CMD_UPDATE 0x01
320+#define FLASH_CMD_VERIFY 0x02
321+
322+struct flash_command {
323+ u8 command[8];
324+ int code;
325+};
326+
327+static struct flash_command flash_command_table[] =
328+{
329+ {"verify", FLASH_CMD_VERIFY},
330+ {"update", FLASH_CMD_UPDATE},
331+ {"", FLASH_CMD_NONE} /* Last entry should be NULL. */
332+};
333+
334+struct error_bios {
335+ char *reason;
336+ int err_code;
337+};
338+
339+static struct error_bios flash_error_table[] =
340+{
341+ {"Failed to open bios image file", FAIL_OPEN_BIOS_FILE},
342+ {"PCI ID mismatch", FAIL_CHECK_PCI_ID},
343+ {"Checksum mismatch", FAIL_CHECK_SUM},
344+ {"Unknown Error", FAIL_UNKNOWN},
345+ {"Failed to verify.", FAIL_VERIFY},
346+ {"Failed to reset flash chip.", FAIL_RESET_FLASH},
347+ {"Failed to find flash chip type.", FAIL_FIND_FLASH_ID},
348+ {"Failed to erash flash chip.", FAIL_ERASE_FLASH},
349+ {"Failed to program flash chip.", FAIL_WRITE_FLASH},
350+ {"Flash in progress", FLASH_IN_PROGRESS},
351+ {"Image file size Error", FAIL_FILE_SIZE},
352+ {"Input parameter error", FAIL_PARAMETERS},
353+ {"Out of memory", FAIL_OUT_MEMORY},
354+ {"OK", 0} /* Last entry err_code = 0. */
355+};
356+
357+static ssize_t asd_store_update_bios(struct device *dev,
358+ struct device_attribute *attr,
359+ const char *buf, size_t count)
360+{
361+ struct asd_ha_struct *asd_ha = dev_to_asd_ha(dev);
362+ char *cmd_ptr, *filename_ptr;
363+ struct bios_file_header header, *hdr_ptr;
364+ int res, i;
365+ u32 csum = 0;
366+ int flash_command = FLASH_CMD_NONE;
367+ int err = 0;
368+
369+ cmd_ptr = kzalloc(count*2, GFP_KERNEL);
370+
371+ if (!cmd_ptr) {
372+ err = FAIL_OUT_MEMORY;
373+ goto out;
374+ }
375+
376+ filename_ptr = cmd_ptr + count;
377+ res = sscanf(buf, "%s %s", cmd_ptr, filename_ptr);
378+ if (res != 2) {
379+ err = FAIL_PARAMETERS;
380+ goto out1;
381+ }
382+
383+ for (i = 0; flash_command_table[i].code != FLASH_CMD_NONE; i++) {
384+ if (!memcmp(flash_command_table[i].command,
385+ cmd_ptr, strlen(cmd_ptr))) {
386+ flash_command = flash_command_table[i].code;
387+ break;
388+ }
389+ }
390+ if (flash_command == FLASH_CMD_NONE) {
391+ err = FAIL_PARAMETERS;
392+ goto out1;
393+ }
394+
395+ if (asd_ha->bios_status == FLASH_IN_PROGRESS) {
396+ err = FLASH_IN_PROGRESS;
397+ goto out1;
398+ }
399+ err = request_firmware(&asd_ha->bios_image,
400+ filename_ptr,
401+ &asd_ha->pcidev->dev);
402+ if (err) {
403+ asd_printk("Failed to load bios image file %s, error %d\n",
404+ filename_ptr, err);
405+ err = FAIL_OPEN_BIOS_FILE;
406+ goto out1;
407+ }
408+
409+ hdr_ptr = (struct bios_file_header *)asd_ha->bios_image->data;
410+
411+ if ((hdr_ptr->contrl_id.vendor != asd_ha->pcidev->vendor ||
412+ hdr_ptr->contrl_id.device != asd_ha->pcidev->device) &&
413+ (hdr_ptr->contrl_id.sub_vendor != asd_ha->pcidev->vendor ||
414+ hdr_ptr->contrl_id.sub_device != asd_ha->pcidev->device)) {
415+
416+ ASD_DPRINTK("The PCI vendor or device id does not match\n");
417+ ASD_DPRINTK("vendor=%x dev=%x sub_vendor=%x sub_dev=%x"
418+ " pci vendor=%x pci dev=%x\n",
419+ hdr_ptr->contrl_id.vendor,
420+ hdr_ptr->contrl_id.device,
421+ hdr_ptr->contrl_id.sub_vendor,
422+ hdr_ptr->contrl_id.sub_device,
423+ asd_ha->pcidev->vendor,
424+ asd_ha->pcidev->device);
425+ err = FAIL_CHECK_PCI_ID;
426+ goto out2;
427+ }
428+
429+ if (hdr_ptr->filelen != asd_ha->bios_image->size) {
430+ err = FAIL_FILE_SIZE;
431+ goto out2;
432+ }
433+
434+ /* calculate checksum */
435+ for (i = 0; i < hdr_ptr->filelen; i++)
436+ csum += asd_ha->bios_image->data[i];
437+
438+ if ((csum & 0x0000ffff) != hdr_ptr->checksum) {
439+ ASD_DPRINTK("BIOS file checksum mismatch\n");
440+ err = FAIL_CHECK_SUM;
441+ goto out2;
442+ }
443+ if (flash_command == FLASH_CMD_UPDATE) {
444+ asd_ha->bios_status = FLASH_IN_PROGRESS;
445+ err = asd_write_flash_seg(asd_ha,
446+ &asd_ha->bios_image->data[sizeof(*hdr_ptr)],
447+ 0, hdr_ptr->filelen-sizeof(*hdr_ptr));
448+ if (!err)
449+ err = asd_verify_flash_seg(asd_ha,
450+ &asd_ha->bios_image->data[sizeof(*hdr_ptr)],
451+ 0, hdr_ptr->filelen-sizeof(*hdr_ptr));
452+ } else {
453+ asd_ha->bios_status = FLASH_IN_PROGRESS;
454+ err = asd_verify_flash_seg(asd_ha,
455+ &asd_ha->bios_image->data[sizeof(header)],
456+ 0, hdr_ptr->filelen-sizeof(header));
457+ }
458+
459+out2:
460+ release_firmware(asd_ha->bios_image);
461+out1:
462+ kfree(cmd_ptr);
463+out:
464+ asd_ha->bios_status = err;
465+
466+ if (!err)
467+ return count;
468+ else
469+ return -err;
470+}
471+
472+static ssize_t asd_show_update_bios(struct device *dev,
473+ struct device_attribute *attr, char *buf)
474+{
475+ int i;
476+ struct asd_ha_struct *asd_ha = dev_to_asd_ha(dev);
477+
478+ for (i = 0; flash_error_table[i].err_code != 0; i++) {
479+ if (flash_error_table[i].err_code == asd_ha->bios_status)
480+ break;
481+ }
482+ if (asd_ha->bios_status != FLASH_IN_PROGRESS)
483+ asd_ha->bios_status = FLASH_OK;
484+
485+ return snprintf(buf, PAGE_SIZE, "status=%x %s\n",
486+ flash_error_table[i].err_code,
487+ flash_error_table[i].reason);
488+}
489+
490+static DEVICE_ATTR(update_bios, S_IRUGO|S_IWUGO,
491+ asd_show_update_bios, asd_store_update_bios);
492+
316493 static int asd_create_dev_attrs(struct asd_ha_struct *asd_ha)
317494 {
318495 int err;
@@ -328,9 +505,14 @@ static int asd_create_dev_attrs(struct asd_ha_struct *asd_ha) · 9 unmodified lines
328505 err = device_create_file(&asd_ha->pcidev->dev, &dev_attr_pcba_sn);
329506 if (err)
330507 goto err_biosb;
508+ err = device_create_file(&asd_ha->pcidev->dev, &dev_attr_update_bios);
509+ if (err)
510+ goto err_update_bios;
331511
332512 return 0;
333513
514+err_update_bios:
515+ device_remove_file(&asd_ha->pcidev->dev, &dev_attr_pcba_sn);
334516 err_biosb:
335517 device_remove_file(&asd_ha->pcidev->dev, &dev_attr_bios_build);
336518 err_rev:
@@ -343,6 +525,7 @@ static void asd_remove_dev_attrs(struct asd_ha_struct *asd_ha) · 6 unmodified lines
343525 device_remove_file(&asd_ha->pcidev->dev, &dev_attr_revision);
344526 device_remove_file(&asd_ha->pcidev->dev, &dev_attr_bios_build);
345527 device_remove_file(&asd_ha->pcidev->dev, &dev_attr_pcba_sn);
528+ device_remove_file(&asd_ha->pcidev->dev, &dev_attr_update_bios);
346529 }
347530
348531 /* The first entry, 0, is used for dynamic ids, the rest for devices
@@ -589,6 +772,7 @@ static int __devinit asd_pci_probe(struct pci_dev *dev, · 240 unmodified lines
589772 asd_ha->sas_ha.dev = &asd_ha->pcidev->dev;
590773 asd_ha->sas_ha.lldd_ha = asd_ha;
591774
775+ asd_ha->bios_status = FLASH_OK;
592776 asd_ha->name = asd_dev->name;
593777 asd_printk("found %s, device %s\n", asd_ha->name, pci_name(dev));
594778
drivers/scsi/aic94xx/aic94xx_scb.c+3−3
@@ -788,12 +788,12 @@ void asd_build_control_phy(struct asd_ascb *ascb, int phy_id, u8 subfunc) · 787 unmodified lines
788788
789789 /* initiator port settings are in the hi nibble */
790790 if (phy->sas_phy.role == PHY_ROLE_INITIATOR)
791− control_phy->port_type = SAS_PROTO_ALL << 4;
791+ control_phy->port_type = SAS_PROTOCOL_ALL << 4;
792792 else if (phy->sas_phy.role == PHY_ROLE_TARGET)
793− control_phy->port_type = SAS_PROTO_ALL;
793+ control_phy->port_type = SAS_PROTOCOL_ALL;
794794 else
795795 control_phy->port_type =
796− (SAS_PROTO_ALL << 4) | SAS_PROTO_ALL;
796+ (SAS_PROTOCOL_ALL << 4) | SAS_PROTOCOL_ALL;
797797
798798 /* link reset retries, this should be nominal */
799799 control_phy->link_reset_retries = 10;
drivers/scsi/aic94xx/aic94xx_sds.c+389−0
@@ -30,6 +30,7 @@ · 29 unmodified lines
3030
3131 #include "aic94xx.h"
3232 #include "aic94xx_reg.h"
33+#include "aic94xx_sds.h"
3334
3435 /* ---------- OCM stuff ---------- */
3536
@@ -1083,3 +1084,391 @@ out: · 1047 unmodified lines
10831084 kfree(flash_dir);
10841085 return err;
10851086 }
1087+
1088+/**
1089+ * asd_verify_flash_seg - verify data with flash memory
1090+ * @asd_ha: pointer to the host adapter structure
1091+ * @src: pointer to the source data to be verified
1092+ * @dest_offset: offset from flash memory
1093+ * @bytes_to_verify: total bytes to verify
1094+ */
1095+int asd_verify_flash_seg(struct asd_ha_struct *asd_ha,
1096+ void *src, u32 dest_offset, u32 bytes_to_verify)
1097+{
1098+ u8 *src_buf;
1099+ u8 flash_char;
1100+ int err;
1101+ u32 nv_offset, reg, i;
1102+
1103+ reg = asd_ha->hw_prof.flash.bar;
1104+ src_buf = NULL;
1105+
1106+ err = FLASH_OK;
1107+ nv_offset = dest_offset;
1108+ src_buf = (u8 *)src;
1109+ for (i = 0; i < bytes_to_verify; i++) {
1110+ flash_char = asd_read_reg_byte(asd_ha, reg + nv_offset + i);
1111+ if (flash_char != src_buf[i]) {
1112+ err = FAIL_VERIFY;
1113+ break;
1114+ }
1115+ }
1116+ return err;
1117+}
1118+
1119+/**
1120+ * asd_write_flash_seg - write data into flash memory
1121+ * @asd_ha: pointer to the host adapter structure
1122+ * @src: pointer to the source data to be written
1123+ * @dest_offset: offset from flash memory
1124+ * @bytes_to_write: total bytes to write
1125+ */
1126+int asd_write_flash_seg(struct asd_ha_struct *asd_ha,
1127+ void *src, u32 dest_offset, u32 bytes_to_write)
1128+{
1129+ u8 *src_buf;
1130+ u32 nv_offset, reg, i;
1131+ int err;
1132+
1133+ reg = asd_ha->hw_prof.flash.bar;
1134+ src_buf = NULL;
1135+
1136+ err = asd_check_flash_type(asd_ha);
1137+ if (err) {
1138+ ASD_DPRINTK("couldn't find the type of flash. err=%d\n", err);
1139+ return err;
1140+ }
1141+
1142+ nv_offset = dest_offset;
1143+ err = asd_erase_nv_sector(asd_ha, nv_offset, bytes_to_write);
1144+ if (err) {
1145+ ASD_DPRINTK("Erase failed at offset:0x%x\n",
1146+ nv_offset);
1147+ return err;
1148+ }
1149+
1150+ err = asd_reset_flash(asd_ha);
1151+ if (err) {
1152+ ASD_DPRINTK("couldn't reset flash. err=%d\n", err);
1153+ return err;
1154+ }
1155+
1156+ src_buf = (u8 *)src;
1157+ for (i = 0; i < bytes_to_write; i++) {
1158+ /* Setup program command sequence */
1159+ switch (asd_ha->hw_prof.flash.method) {
1160+ case FLASH_METHOD_A:
1161+ {
1162+ asd_write_reg_byte(asd_ha,
1163+ (reg + 0xAAA), 0xAA);
1164+ asd_write_reg_byte(asd_ha,
1165+ (reg + 0x555), 0x55);
1166+ asd_write_reg_byte(asd_ha,
1167+ (reg + 0xAAA), 0xA0);
1168+ asd_write_reg_byte(asd_ha,
1169+ (reg + nv_offset + i),
1170+ (*(src_buf + i)));
1171+ break;
1172+ }
1173+ case FLASH_METHOD_B:
1174+ {
1175+ asd_write_reg_byte(asd_ha,
1176+ (reg + 0x555), 0xAA);
1177+ asd_write_reg_byte(asd_ha,
1178+ (reg + 0x2AA), 0x55);
1179+ asd_write_reg_byte(asd_ha,
1180+ (reg + 0x555), 0xA0);
1181+ asd_write_reg_byte(asd_ha,
1182+ (reg + nv_offset + i),
1183+ (*(src_buf + i)));
1184+ break;
1185+ }
1186+ default:
1187+ break;
1188+ }
1189+ if (asd_chk_write_status(asd_ha,
1190+ (nv_offset + i), 0) != 0) {
1191+ ASD_DPRINTK("aicx: Write failed at offset:0x%x\n",
1192+ reg + nv_offset + i);
1193+ return FAIL_WRITE_FLASH;
1194+ }
1195+ }
1196+
1197+ err = asd_reset_flash(asd_ha);
1198+ if (err) {
1199+ ASD_DPRINTK("couldn't reset flash. err=%d\n", err);
1200+ return err;
1201+ }
1202+ return 0;
1203+}
1204+
1205+int asd_chk_write_status(struct asd_ha_struct *asd_ha,
1206+ u32 sector_addr, u8 erase_flag)
1207+{
1208+ u32 reg;
1209+ u32 loop_cnt;
1210+ u8 nv_data1, nv_data2;
1211+ u8 toggle_bit1;
1212+
1213+ /*
1214+ * Read from DQ2 requires sector address
1215+ * while it's dont care for DQ6
1216+ */
1217+ reg = asd_ha->hw_prof.flash.bar;
1218+
1219+ for (loop_cnt = 0; loop_cnt < 50000; loop_cnt++) {
1220+ nv_data1 = asd_read_reg_byte(asd_ha, reg);
1221+ nv_data2 = asd_read_reg_byte(asd_ha, reg);
1222+
1223+ toggle_bit1 = ((nv_data1 & FLASH_STATUS_BIT_MASK_DQ6)
1224+ ^ (nv_data2 & FLASH_STATUS_BIT_MASK_DQ6));
1225+
1226+ if (toggle_bit1 == 0) {
1227+ return 0;
1228+ } else {
1229+ if (nv_data2 & FLASH_STATUS_BIT_MASK_DQ5) {
1230+ nv_data1 = asd_read_reg_byte(asd_ha,
1231+ reg);
1232+ nv_data2 = asd_read_reg_byte(asd_ha,
1233+ reg);
1234+ toggle_bit1 =
1235+ ((nv_data1 & FLASH_STATUS_BIT_MASK_DQ6)
1236+ ^ (nv_data2 & FLASH_STATUS_BIT_MASK_DQ6));
1237+
1238+ if (toggle_bit1 == 0)
1239+ return 0;
1240+ }
1241+ }
1242+
1243+ /*
1244+ * ERASE is a sector-by-sector operation and requires
1245+ * more time to finish while WRITE is byte-byte-byte
1246+ * operation and takes lesser time to finish.
1247+ *
1248+ * For some strange reason a reduced ERASE delay gives different
1249+ * behaviour across different spirit boards. Hence we set
1250+ * a optimum balance of 50mus for ERASE which works well
1251+ * across all boards.
1252+ */
1253+ if (erase_flag) {
1254+ udelay(FLASH_STATUS_ERASE_DELAY_COUNT);
1255+ } else {
1256+ udelay(FLASH_STATUS_WRITE_DELAY_COUNT);
1257+ }
1258+ }
1259+ return -1;
1260+}
1261+
1262+/**
1263+ * asd_hwi_erase_nv_sector - Erase the flash memory sectors.
1264+ * @asd_ha: pointer to the host adapter structure
1265+ * @flash_addr: pointer to offset from flash memory
1266+ * @size: total bytes to erase.
1267+ */
1268+int asd_erase_nv_sector(struct asd_ha_struct *asd_ha, u32 flash_addr, u32 size)
1269+{
1270+ u32 reg;
1271+ u32 sector_addr;
1272+
1273+ reg = asd_ha->hw_prof.flash.bar;
1274+
1275+ /* sector staring address */
1276+ sector_addr = flash_addr & FLASH_SECTOR_SIZE_MASK;
1277+
1278+ /*
1279+ * Erasing an flash sector needs to be done in six consecutive
1280+ * write cyles.
1281+ */
1282+ while (sector_addr < flash_addr+size) {
1283+ switch (asd_ha->hw_prof.flash.method) {
1284+ case FLASH_METHOD_A:
1285+ asd_write_reg_byte(asd_ha, (reg + 0xAAA), 0xAA);
1286+ asd_write_reg_byte(asd_ha, (reg + 0x555), 0x55);
1287+ asd_write_reg_byte(asd_ha, (reg + 0xAAA), 0x80);
1288+ asd_write_reg_byte(asd_ha, (reg + 0xAAA), 0xAA);
1289+ asd_write_reg_byte(asd_ha, (reg + 0x555), 0x55);
1290+ asd_write_reg_byte(asd_ha, (reg + sector_addr), 0x30);
1291+ break;
1292+ case FLASH_METHOD_B:
1293+ asd_write_reg_byte(asd_ha, (reg + 0x555), 0xAA);
1294+ asd_write_reg_byte(asd_ha, (reg + 0x2AA), 0x55);
1295+ asd_write_reg_byte(asd_ha, (reg + 0x555), 0x80);
1296+ asd_write_reg_byte(asd_ha, (reg + 0x555), 0xAA);
1297+ asd_write_reg_byte(asd_ha, (reg + 0x2AA), 0x55);
1298+ asd_write_reg_byte(asd_ha, (reg + sector_addr), 0x30);
1299+ break;
1300+ default:
1301+ break;
1302+ }
1303+
1304+ if (asd_chk_write_status(asd_ha, sector_addr, 1) != 0)
1305+ return FAIL_ERASE_FLASH;
1306+
1307+ sector_addr += FLASH_SECTOR_SIZE;
1308+ }
1309+
1310+ return 0;
1311+}
1312+
1313+int asd_check_flash_type(struct asd_ha_struct *asd_ha)
1314+{
1315+ u8 manuf_id;
1316+ u8 dev_id;
1317+ u8 sec_prot;
1318+ u32 inc;
1319+ u32 reg;
1320+ int err;
1321+
1322+ /* get Flash memory base address */
1323+ reg = asd_ha->hw_prof.flash.bar;
1324+
1325+ /* Determine flash info */
1326+ err = asd_reset_flash(asd_ha);
1327+ if (err) {
1328+ ASD_DPRINTK("couldn't reset flash. err=%d\n", err);
1329+ return err;
1330+ }
1331+
1332+ asd_ha->hw_prof.flash.method = FLASH_METHOD_UNKNOWN;
1333+ asd_ha->hw_prof.flash.manuf = FLASH_MANUF_ID_UNKNOWN;
1334+ asd_ha->hw_prof.flash.dev_id = FLASH_DEV_ID_UNKNOWN;
1335+
1336+ /* Get flash info. This would most likely be AMD Am29LV family flash.
1337+ * First try the sequence for word mode. It is the same as for
1338+ * 008B (byte mode only), 160B (word mode) and 800D (word mode).
1339+ */
1340+ inc = asd_ha->hw_prof.flash.wide ? 2 : 1;
1341+ asd_write_reg_byte(asd_ha, reg + 0xAAA, 0xAA);
1342+ asd_write_reg_byte(asd_ha, reg + 0x555, 0x55);
1343+ asd_write_reg_byte(asd_ha, reg + 0xAAA, 0x90);
1344+ manuf_id = asd_read_reg_byte(asd_ha, reg);
1345+ dev_id = asd_read_reg_byte(asd_ha, reg + inc);
1346+ sec_prot = asd_read_reg_byte(asd_ha, reg + inc + inc);
1347+ /* Get out of autoselect mode. */
1348+ err = asd_reset_flash(asd_ha);
1349+ if (err) {
1350+ ASD_DPRINTK("couldn't reset flash. err=%d\n", err);
1351+ return err;
1352+ }
1353+ ASD_DPRINTK("Flash MethodA manuf_id(0x%x) dev_id(0x%x) "
1354+ "sec_prot(0x%x)\n", manuf_id, dev_id, sec_prot);
1355+ err = asd_reset_flash(asd_ha);
1356+ if (err != 0)
1357+ return err;
1358+
1359+ switch (manuf_id) {
1360+ case FLASH_MANUF_ID_AMD:
1361+ switch (sec_prot) {
1362+ case FLASH_DEV_ID_AM29LV800DT:
1363+ case FLASH_DEV_ID_AM29LV640MT:
1364+ case FLASH_DEV_ID_AM29F800B:
1365+ asd_ha->hw_prof.flash.method = FLASH_METHOD_A;
1366+ break;
1367+ default:
1368+ break;
1369+ }
1370+ break;
1371+ case FLASH_MANUF_ID_ST:
1372+ switch (sec_prot) {
1373+ case FLASH_DEV_ID_STM29W800DT:
1374+ case FLASH_DEV_ID_STM29LV640:
1375+ asd_ha->hw_prof.flash.method = FLASH_METHOD_A;
1376+ break;
1377+ default:
1378+ break;
1379+ }
1380+ break;
1381+ case FLASH_MANUF_ID_FUJITSU:
1382+ switch (sec_prot) {
1383+ case FLASH_DEV_ID_MBM29LV800TE:
1384+ case FLASH_DEV_ID_MBM29DL800TA:
1385+ asd_ha->hw_prof.flash.method = FLASH_METHOD_A;
1386+ break;
1387+ }
1388+ break;
1389+ case FLASH_MANUF_ID_MACRONIX:
1390+ switch (sec_prot) {
1391+ case FLASH_DEV_ID_MX29LV800BT:
1392+ asd_ha->hw_prof.flash.method = FLASH_METHOD_A;
1393+ break;
1394+ }
1395+ break;
1396+ }
1397+
1398+ if (asd_ha->hw_prof.flash.method == FLASH_METHOD_UNKNOWN) {
1399+ err = asd_reset_flash(asd_ha);
1400+ if (err) {
1401+ ASD_DPRINTK("couldn't reset flash. err=%d\n", err);
1402+ return err;
1403+ }
1404+
1405+ /* Issue Unlock sequence for AM29LV008BT */
1406+ asd_write_reg_byte(asd_ha, (reg + 0x555), 0xAA);
1407+ asd_write_reg_byte(asd_ha, (reg + 0x2AA), 0x55);
1408+ asd_write_reg_byte(asd_ha, (reg + 0x555), 0x90);
1409+ manuf_id = asd_read_reg_byte(asd_ha, reg);
1410+ dev_id = asd_read_reg_byte(asd_ha, reg + inc);
1411+ sec_prot = asd_read_reg_byte(asd_ha, reg + inc + inc);
1412+
1413+ ASD_DPRINTK("Flash MethodB manuf_id(0x%x) dev_id(0x%x) sec_prot"
1414+ "(0x%x)\n", manuf_id, dev_id, sec_prot);
1415+
1416+ err = asd_reset_flash(asd_ha);
1417+ if (err != 0) {
1418+ ASD_DPRINTK("couldn't reset flash. err=%d\n", err);
1419+ return err;
1420+ }
1421+
1422+ switch (manuf_id) {
1423+ case FLASH_MANUF_ID_AMD:
1424+ switch (dev_id) {
1425+ case FLASH_DEV_ID_AM29LV008BT:
1426+ asd_ha->hw_prof.flash.method = FLASH_METHOD_B;
1427+ break;
1428+ default:
1429+ break;
1430+ }
1431+ break;
1432+ case FLASH_MANUF_ID_ST:
1433+ switch (dev_id) {
1434+ case FLASH_DEV_ID_STM29008:
1435+ asd_ha->hw_prof.flash.method = FLASH_METHOD_B;
1436+ break;
1437+ default:
1438+ break;
1439+ }
1440+ break;
1441+ case FLASH_MANUF_ID_FUJITSU:
1442+ switch (dev_id) {
1443+ case FLASH_DEV_ID_MBM29LV008TA:
1444+ asd_ha->hw_prof.flash.method = FLASH_METHOD_B;
1445+ break;
1446+ }
1447+ break;
1448+ case FLASH_MANUF_ID_INTEL:
1449+ switch (dev_id) {
1450+ case FLASH_DEV_ID_I28LV00TAT:
1451+ asd_ha->hw_prof.flash.method = FLASH_METHOD_B;
1452+ break;
1453+ }
1454+ break;
1455+ case FLASH_MANUF_ID_MACRONIX:
1456+ switch (dev_id) {
1457+ case FLASH_DEV_ID_I28LV00TAT:
1458+ asd_ha->hw_prof.flash.method = FLASH_METHOD_B;
1459+ break;
1460+ }
1461+ break;
1462+ default:
1463+ return FAIL_FIND_FLASH_ID;
1464+ }
1465+ }
1466+
1467+ if (asd_ha->hw_prof.flash.method == FLASH_METHOD_UNKNOWN)
1468+ return FAIL_FIND_FLASH_ID;
1469+
1470+ asd_ha->hw_prof.flash.manuf = manuf_id;
1471+ asd_ha->hw_prof.flash.dev_id = dev_id;
1472+ asd_ha->hw_prof.flash.sec_prot = sec_prot;
1473+ return 0;
1474+}
drivers/scsi/aic94xx/aic94xx_sds.h+121−0
@@ -0,0 +1,121 @@
1+/*
2+ * Aic94xx SAS/SATA driver hardware interface header file.
3+ *
4+ * Copyright (C) 2005 Adaptec, Inc. All rights reserved.
5+ * Copyright (C) 2005 Gilbert Wu <gilbert_wu@adaptec.com>
6+ *
7+ * This file is licensed under GPLv2.
8+ *
9+ * This file is part of the aic94xx driver.
10+ *
11+ * The aic94xx driver is free software; you can redistribute it and/or
12+ * modify it under the terms of the GNU General Public License as
13+ * published by the Free Software Foundation; version 2 of the
14+ * License.
15+ *
16+ * The aic94xx driver is distributed in the hope that it will be useful,
17+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
18+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19+ * General Public License for more details.
20+ *
21+ * You should have received a copy of the GNU General Public License
22+ * along with the aic94xx driver; if not, write to the Free Software
23+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24+ *
25+ */
26+#ifndef _AIC94XX_SDS_H_
27+#define _AIC94XX_SDS_H_
28+
29+enum {
30+ FLASH_METHOD_UNKNOWN,
31+ FLASH_METHOD_A,
32+ FLASH_METHOD_B
33+};
34+
35+#define FLASH_MANUF_ID_AMD 0x01
36+#define FLASH_MANUF_ID_ST 0x20
37+#define FLASH_MANUF_ID_FUJITSU 0x04
38+#define FLASH_MANUF_ID_MACRONIX 0xC2
39+#define FLASH_MANUF_ID_INTEL 0x89
40+#define FLASH_MANUF_ID_UNKNOWN 0xFF
41+
42+#define FLASH_DEV_ID_AM29LV008BT 0x3E
43+#define FLASH_DEV_ID_AM29LV800DT 0xDA
44+#define FLASH_DEV_ID_STM29W800DT 0xD7
45+#define FLASH_DEV_ID_STM29LV640 0xDE
46+#define FLASH_DEV_ID_STM29008 0xEA
47+#define FLASH_DEV_ID_MBM29LV800TE 0xDA
48+#define FLASH_DEV_ID_MBM29DL800TA 0x4A
49+#define FLASH_DEV_ID_MBM29LV008TA 0x3E
50+#define FLASH_DEV_ID_AM29LV640MT 0x7E
51+#define FLASH_DEV_ID_AM29F800B 0xD6
52+#define FLASH_DEV_ID_MX29LV800BT 0xDA
53+#define FLASH_DEV_ID_MX29LV008CT 0xDA
54+#define FLASH_DEV_ID_I28LV00TAT 0x3E
55+#define FLASH_DEV_ID_UNKNOWN 0xFF
56+
57+/* status bit mask values */
58+#define FLASH_STATUS_BIT_MASK_DQ6 0x40
59+#define FLASH_STATUS_BIT_MASK_DQ5 0x20
60+#define FLASH_STATUS_BIT_MASK_DQ2 0x04
61+
62+/* minimum value in micro seconds needed for checking status */
63+#define FLASH_STATUS_ERASE_DELAY_COUNT 50
64+#define FLASH_STATUS_WRITE_DELAY_COUNT 25
65+
66+#define FLASH_SECTOR_SIZE 0x010000
67+#define FLASH_SECTOR_SIZE_MASK 0xffff0000
68+
69+#define FLASH_OK 0x000000
70+#define FAIL_OPEN_BIOS_FILE 0x000100
71+#define FAIL_CHECK_PCI_ID 0x000200
72+#define FAIL_CHECK_SUM 0x000300
73+#define FAIL_UNKNOWN 0x000400
74+#define FAIL_VERIFY 0x000500
75+#define FAIL_RESET_FLASH 0x000600
76+#define FAIL_FIND_FLASH_ID 0x000700
77+#define FAIL_ERASE_FLASH 0x000800
78+#define FAIL_WRITE_FLASH 0x000900
79+#define FAIL_FILE_SIZE 0x000a00
80+#define FAIL_PARAMETERS 0x000b00
81+#define FAIL_OUT_MEMORY 0x000c00
82+#define FLASH_IN_PROGRESS 0x001000
83+
84+struct controller_id {
85+ u32 vendor; /* PCI Vendor ID */
86+ u32 device; /* PCI Device ID */
87+ u32 sub_vendor; /* PCI Subvendor ID */
88+ u32 sub_device; /* PCI Subdevice ID */
89+};
90+
91+struct image_info {
92+ u32 ImageId; /* Identifies the image */
93+ u32 ImageOffset; /* Offset the beginning of the file */
94+ u32 ImageLength; /* length of the image */
95+ u32 ImageChecksum; /* Image checksum */
96+ u32 ImageVersion; /* Version of the image, could be build number */
97+};
98+
99+struct bios_file_header {
100+ u8 signature[32]; /* Signature/Cookie to identify the file */
101+ u32 checksum; /*Entire file checksum with this field zero */
102+ u32 antidote; /* Entire file checksum with this field 0xFFFFFFFF */
103+ struct controller_id contrl_id; /*PCI id to identify the controller */
104+ u32 filelen; /*Length of the entire file*/
105+ u32 chunk_num; /*The chunk/part number for multiple Image files */
106+ u32 total_chunks; /*Total number of chunks/parts in the image file */
107+ u32 num_images; /* Number of images in the file */
108+ u32 build_num; /* Build number of this image */
109+ struct image_info image_header;
110+};
111+
112+int asd_verify_flash_seg(struct asd_ha_struct *asd_ha,
113+ void *src, u32 dest_offset, u32 bytes_to_verify);
114+int asd_write_flash_seg(struct asd_ha_struct *asd_ha,
115+ void *src, u32 dest_offset, u32 bytes_to_write);
116+int asd_chk_write_status(struct asd_ha_struct *asd_ha,
117+ u32 sector_addr, u8 erase_flag);
118+int asd_check_flash_type(struct asd_ha_struct *asd_ha);
119+int asd_erase_nv_sector(struct asd_ha_struct *asd_ha,
120+ u32 flash_addr, u32 size);
121+#endif
drivers/scsi/aic94xx/aic94xx_task.c+17−33
@@ -187,29 +187,13 @@ static void asd_get_response_tasklet(struct asd_ascb *ascb, · 186 unmodified lines
187187 ts->buf_valid_size = 0;
188188 edb = asd_ha->seq.edb_arr[edb_id + escb->edb_index];
189189 r = edb->vaddr;
190− if (task->task_proto == SAS_PROTO_SSP) {
190+ if (task->task_proto == SAS_PROTOCOL_SSP) {
191191 struct ssp_response_iu *iu =
192192 r + 16 + sizeof(struct ssp_frame_hdr);
193193
194194 ts->residual = le32_to_cpu(*(__le32 *)r);
195− ts->resp = SAS_TASK_COMPLETE;
196− if (iu->datapres == 0)
197− ts->stat = iu->status;
198− else if (iu->datapres == 1)
199− ts->stat = iu->resp_data[3];
200− else if (iu->datapres == 2) {
201− ts->stat = SAM_CHECK_COND;
202− ts->buf_valid_size = min((u32) SAS_STATUS_BUF_SIZE,
203− be32_to_cpu(iu->sense_data_len));
204− memcpy(ts->buf, iu->sense_data, ts->buf_valid_size);
205− if (iu->status != SAM_CHECK_COND) {
206− ASD_DPRINTK("device %llx sent sense data, but "
207− "stat(0x%x) is not CHECK_CONDITION"
208− "\n",
209− SAS_ADDR(task->dev->sas_addr),
210− iu->status);
211− }
212− }
195+
196+ sas_ssp_task_response(&asd_ha->pcidev->dev, task, iu);
213197 } else {
214198 struct ata_task_resp *resp = (void *) &ts->buf[0];
215199
@@ -341,14 +325,14 @@ Again: · 125 unmodified lines
341325 }
342326
343327 switch (task->task_proto) {
344− case SATA_PROTO:
345− case SAS_PROTO_STP:
328+ case SAS_PROTOCOL_SATA:
329+ case SAS_PROTOCOL_STP:
346330 asd_unbuild_ata_ascb(ascb);
347331 break;
348− case SAS_PROTO_SMP:
332+ case SAS_PROTOCOL_SMP:
349333 asd_unbuild_smp_ascb(ascb);
350334 break;
351− case SAS_PROTO_SSP:
335+ case SAS_PROTOCOL_SSP:
352336 asd_unbuild_ssp_ascb(ascb);
353337 default:
354338 break;
@@ -586,17 +570,17 @@ int asd_execute_task(struct sas_task *task, const int num, · 231 unmodified lines
586570 list_for_each_entry(a, &alist, list) {
587571 t = a->uldd_task;
588572 a->uldd_timer = 1;
589− if (t->task_proto & SAS_PROTO_STP)
590− t->task_proto = SAS_PROTO_STP;
573+ if (t->task_proto & SAS_PROTOCOL_STP)
574+ t->task_proto = SAS_PROTOCOL_STP;
591575 switch (t->task_proto) {
592− case SATA_PROTO:
593− case SAS_PROTO_STP:
576+ case SAS_PROTOCOL_SATA:
577+ case SAS_PROTOCOL_STP:
594578 res = asd_build_ata_ascb(a, t, gfp_flags);
595579 break;
596− case SAS_PROTO_SMP:
580+ case SAS_PROTOCOL_SMP:
597581 res = asd_build_smp_ascb(a, t, gfp_flags);
598582 break;
599− case SAS_PROTO_SSP:
583+ case SAS_PROTOCOL_SSP:
600584 res = asd_build_ssp_ascb(a, t, gfp_flags);
601585 break;
602586 default:
@@ -633,14 +617,14 @@ out_err_unmap: · 30 unmodified lines
633617 t->task_state_flags &= ~SAS_TASK_AT_INITIATOR;
634618 spin_unlock_irqrestore(&t->task_state_lock, flags);
635619 switch (t->task_proto) {
636− case SATA_PROTO:
637− case SAS_PROTO_STP:
620+ case SAS_PROTOCOL_SATA:
621+ case SAS_PROTOCOL_STP:
638622 asd_unbuild_ata_ascb(a);
639623 break;
640− case SAS_PROTO_SMP:
624+ case SAS_PROTOCOL_SMP:
641625 asd_unbuild_smp_ascb(a);
642626 break;
643− case SAS_PROTO_SSP:
627+ case SAS_PROTOCOL_SSP:
644628 asd_unbuild_ssp_ascb(a);
645629 default:
646630 break;
drivers/scsi/aic94xx/aic94xx_tmf.c+6−6
@@ -372,21 +372,21 @@ int asd_abort_task(struct sas_task *task) · 371 unmodified lines
372372 scb->header.opcode = ABORT_TASK;
373373
374374 switch (task->task_proto) {
375− case SATA_PROTO:
376− case SAS_PROTO_STP:
375+ case SAS_PROTOCOL_SATA:
376+ case SAS_PROTOCOL_STP:
377377 scb->abort_task.proto_conn_rate = (1 << 5); /* STP */
378378 break;
379− case SAS_PROTO_SSP:
379+ case SAS_PROTOCOL_SSP:
380380 scb->abort_task.proto_conn_rate = (1 << 4); /* SSP */
381381 scb->abort_task.proto_conn_rate |= task->dev->linkrate;
382382 break;
383− case SAS_PROTO_SMP:
383+ case SAS_PROTOCOL_SMP:
384384 break;
385385 default:
386386 break;
387387 }
388388
389− if (task->task_proto == SAS_PROTO_SSP) {
389+ if (task->task_proto == SAS_PROTOCOL_SSP) {
390390 scb->abort_task.ssp_frame.frame_type = SSP_TASK;
391391 memcpy(scb->abort_task.ssp_frame.hashed_dest_addr,
392392 task->dev->hashed_sas_addr, HASHED_SAS_ADDR_SIZE);
@@ -512,7 +512,7 @@ static int asd_initiate_ssp_tmf(struct domain_device *dev, u8 *lun, · 119 unmodified lines
512512 int res = 1;
513513 struct scb *scb;
514514
515− if (!(dev->tproto & SAS_PROTO_SSP))
515+ if (!(dev->tproto & SAS_PROTOCOL_SSP))
516516 return TMF_RESP_FUNC_ESUPP;
517517
518518 ascb = asd_ascb_alloc_list(asd_ha, &res, GFP_KERNEL);
drivers/scsi/arcmsr/arcmsr_hba.c+3−3
@@ -634,9 +634,9 @@ static void arcmsr_report_sense_info(struct CommandControlBlock *ccb) · 633 unmodified lines
634634 pcmd->result = DID_OK << 16;
635635 if (sensebuffer) {
636636 int sense_data_length =
637− sizeof(struct SENSE_DATA) < sizeof(pcmd->sense_buffer)
638− ? sizeof(struct SENSE_DATA) : sizeof(pcmd->sense_buffer);
639− memset(sensebuffer, 0, sizeof(pcmd->sense_buffer));
637+ sizeof(struct SENSE_DATA) < SCSI_SENSE_BUFFERSIZE
638+ ? sizeof(struct SENSE_DATA) : SCSI_SENSE_BUFFERSIZE;
639+ memset(sensebuffer, 0, SCSI_SENSE_BUFFERSIZE);
640640 memcpy(sensebuffer, ccb->arcmsr_cdb.SenseData, sense_data_length);
641641 sensebuffer->ErrorCode = SCSI_SENSE_CURRENT_ERRORS;
642642 sensebuffer->Valid = 1;
drivers/scsi/atari_NCR5380.c+12−12
@@ -511,9 +511,9 @@ static inline void initialize_SCp(Scsi_Cmnd *cmd) · 510 unmodified lines
511511 * various queues are valid.
512512 */
513513
514− if (cmd->use_sg) {
515− cmd->SCp.buffer = (struct scatterlist *)cmd->request_buffer;
516− cmd->SCp.buffers_residual = cmd->use_sg - 1;
514+ if (scsi_bufflen(cmd)) {
515+ cmd->SCp.buffer = scsi_sglist(cmd);
516+ cmd->SCp.buffers_residual = scsi_sg_count(cmd) - 1;
517517 cmd->SCp.ptr = sg_virt(cmd->SCp.buffer);
518518 cmd->SCp.this_residual = cmd->SCp.buffer->length;
519519 /* ++roman: Try to merge some scatter-buffers if they are at
@@ -523,8 +523,8 @@ static inline void initialize_SCp(Scsi_Cmnd *cmd) · 3 unmodified lines
523523 } else {
524524 cmd->SCp.buffer = NULL;
525525 cmd->SCp.buffers_residual = 0;
526− cmd->SCp.ptr = (char *)cmd->request_buffer;
527− cmd->SCp.this_residual = cmd->request_bufflen;
526+ cmd->SCp.ptr = NULL;
527+ cmd->SCp.this_residual = 0;
528528 }
529529 }
530530
@@ -936,21 +936,21 @@ static int NCR5380_queue_command(Scsi_Cmnd *cmd, void (*done)(Scsi_Cmnd *)) · 405 unmodified lines
936936 }
937937 # endif
938938 # ifdef NCR5380_STAT_LIMIT
939− if (cmd->request_bufflen > NCR5380_STAT_LIMIT)
939+ if (scsi_bufflen(cmd) > NCR5380_STAT_LIMIT)
940940 # endif
941941 switch (cmd->cmnd[0]) {
942942 case WRITE:
943943 case WRITE_6:
944944 case WRITE_10:
945945 hostdata->time_write[cmd->device->id] -= (jiffies - hostdata->timebase);
946− hostdata->bytes_write[cmd->device->id] += cmd->request_bufflen;
946+ hostdata->bytes_write[cmd->device->id] += scsi_bufflen(cmd);
947947 hostdata->pendingw++;
948948 break;
949949 case READ:
950950 case READ_6:
951951 case READ_10:
952952 hostdata->time_read[cmd->device->id] -= (jiffies - hostdata->timebase);
953− hostdata->bytes_read[cmd->device->id] += cmd->request_bufflen;
953+ hostdata->bytes_read[cmd->device->id] += scsi_bufflen(cmd);
954954 hostdata->pendingr++;
955955 break;
956956 }
@@ -1352,21 +1352,21 @@ static irqreturn_t NCR5380_intr(int irq, void *dev_id) · 395 unmodified lines
13521352 static void collect_stats(struct NCR5380_hostdata* hostdata, Scsi_Cmnd *cmd)
13531353 {
13541354 # ifdef NCR5380_STAT_LIMIT
1355− if (cmd->request_bufflen > NCR5380_STAT_LIMIT)
1355+ if (scsi_bufflen(cmd) > NCR5380_STAT_LIMIT)
13561356 # endif
13571357 switch (cmd->cmnd[0]) {
13581358 case WRITE:
13591359 case WRITE_6:
13601360 case WRITE_10:
13611361 hostdata->time_write[cmd->device->id] += (jiffies - hostdata->timebase);
1362− /*hostdata->bytes_write[cmd->device->id] += cmd->request_bufflen;*/
1362+ /*hostdata->bytes_write[cmd->device->id] += scsi_bufflen(cmd);*/
13631363 hostdata->pendingw--;
13641364 break;
13651365 case READ:
13661366 case READ_6:
13671367 case READ_10:
13681368 hostdata->time_read[cmd->device->id] += (jiffies - hostdata->timebase);
1369− /*hostdata->bytes_read[cmd->device->id] += cmd->request_bufflen;*/
1369+ /*hostdata->bytes_read[cmd->device->id] += scsi_bufflen(cmd);*/
13701370 hostdata->pendingr--;
13711371 break;
13721372 }
@@ -1868,7 +1868,7 @@ static int do_abort(struct Scsi_Host *host) · 495 unmodified lines
18681868 * the target sees, so we just handshake.
18691869 */
18701870
1871− while (!(tmp = NCR5380_read(STATUS_REG)) & SR_REQ)
1871+ while (!((tmp = NCR5380_read(STATUS_REG)) & SR_REQ))
18721872 ;
18731873
18741874 NCR5380_write(TARGET_COMMAND_REG, PHASE_SR_TO_TCR(tmp));
drivers/scsi/atp870u.c+17−85
@@ -471,18 +471,8 @@ go_42: · 470 unmodified lines
471471 /*
472472 * Complete the command
473473 */
474− if (workreq->use_sg) {
475− pci_unmap_sg(dev->pdev,
476− (struct scatterlist *)workreq->request_buffer,
477− workreq->use_sg,
478− workreq->sc_data_direction);
479− } else if (workreq->request_bufflen &&
480− workreq->sc_data_direction != DMA_NONE) {
481− pci_unmap_single(dev->pdev,
482− workreq->SCp.dma_handle,
483− workreq->request_bufflen,
484− workreq->sc_data_direction);
485− }
474+ scsi_dma_unmap(workreq);
475+
486476 spin_lock_irqsave(dev->host->host_lock, flags);
487477 (*workreq->scsi_done) (workreq);
488478 #ifdef ED_DBGP
@@ -624,7 +614,7 @@ static int atp870u_queuecommand(struct scsi_cmnd * req_p, · 135 unmodified lines
624614
625615 c = scmd_channel(req_p);
626616 req_p->sense_buffer[0]=0;
627− req_p->resid = 0;
617+ scsi_set_resid(req_p, 0);
628618 if (scmd_channel(req_p) > 1) {
629619 req_p->result = 0x00040000;
630620 done(req_p);
@@ -722,7 +712,6 @@ static void send_s870(struct atp_unit *dev,unsigned char c) · 91 unmodified lines
722712 unsigned short int tmpcip, w;
723713 unsigned long l, bttl = 0;
724714 unsigned int workport;
725− struct scatterlist *sgpnt;
726715 unsigned long sg_count;
727716
728717 if (dev->in_snd[c] != 0) {
@@ -793,6 +782,8 @@ oktosend: · 64 unmodified lines
793782 }
794783 printk("\n");
795784 #endif
785+ l = scsi_bufflen(workreq);
786+
796787 if (dev->dev_id == ATP885_DEVID) {
797788 j = inb(dev->baseport + 0x29) & 0xfe;
798789 outb(j, dev->baseport + 0x29);
@@ -800,12 +791,11 @@ oktosend: · 1 unmodified line
800791 }
801792
802793 if (workreq->cmnd[0] == READ_CAPACITY) {
803− if (workreq->request_bufflen > 8) {
804− workreq->request_bufflen = 0x08;
805− }
794+ if (l > 8)
795+ l = 8;
806796 }
807797 if (workreq->cmnd[0] == 0x00) {
808− workreq->request_bufflen = 0;
798+ l = 0;
809799 }
810800
811801 tmport = workport + 0x1b;
@@ -852,40 +842,8 @@ oktosend: · 40 unmodified lines
852842 #ifdef ED_DBGP
853843 printk("dev->id[%d][%d].devsp = %2x\n",c,target_id,dev->id[c][target_id].devsp);
854844 #endif
855− /*
856− * Figure out the transfer size
857− */
858− if (workreq->use_sg) {
859−#ifdef ED_DBGP
860− printk("Using SGL\n");
861−#endif
862− l = 0;
863−
864− sgpnt = (struct scatterlist *) workreq->request_buffer;
865− sg_count = pci_map_sg(dev->pdev, sgpnt, workreq->use_sg,
866− workreq->sc_data_direction);
867−
868− for (i = 0; i < workreq->use_sg; i++) {
869− if (sgpnt[i].length == 0 || workreq->use_sg > ATP870U_SCATTER) {
870− panic("Foooooooood fight!");
871− }
872− l += sgpnt[i].length;
873− }
874−#ifdef ED_DBGP
875− printk( "send_s870: workreq->use_sg %d, sg_count %d l %8ld\n", workreq->use_sg, sg_count, l);
876−#endif
877− } else if(workreq->request_bufflen && workreq->sc_data_direction != PCI_DMA_NONE) {
878−#ifdef ED_DBGP
879− printk("Not using SGL\n");
880−#endif
881− workreq->SCp.dma_handle = pci_map_single(dev->pdev, workreq->request_buffer,
882− workreq->request_bufflen,
883− workreq->sc_data_direction);
884− l = workreq->request_bufflen;
885−#ifdef ED_DBGP
886− printk( "send_s870: workreq->use_sg %d, l %8ld\n", workreq->use_sg, l);
887−#endif
888− } else l = 0;
845+
846+ sg_count = scsi_dma_map(workreq);
889847 /*
890848 * Write transfer size
891849 */
@@ -938,16 +896,16 @@ oktosend: · 46 unmodified lines
938896 * a linear chain.
939897 */
940898
941− if (workreq->use_sg) {
942− sgpnt = (struct scatterlist *) workreq->request_buffer;
899+ if (l) {
900+ struct scatterlist *sgpnt;
943901 i = 0;
944− for (j = 0; j < workreq->use_sg; j++) {
945− bttl = sg_dma_address(&sgpnt[j]);
946− l=sg_dma_len(&sgpnt[j]);
902+ scsi_for_each_sg(workreq, sgpnt, sg_count, j) {
903+ bttl = sg_dma_address(sgpnt);
904+ l=sg_dma_len(sgpnt);
947905 #ifdef ED_DBGP
948− printk("1. bttl %x, l %x\n",bttl, l);
906+ printk("1. bttl %x, l %x\n",bttl, l);
949907 #endif
950− while (l > 0x10000) {
908+ while (l > 0x10000) {
951909 (((u16 *) (prd))[i + 3]) = 0x0000;
952910 (((u16 *) (prd))[i + 2]) = 0x0000;
953911 (((u32 *) (prd))[i >> 1]) = cpu_to_le32(bttl);
@@ -965,32 +923,6 @@ oktosend: · 11 unmodified lines
965923 printk("prd %4x %4x %4x %4x\n",(((unsigned short int *)prd)[0]),(((unsigned short int *)prd)[1]),(((unsigned short int *)prd)[2]),(((unsigned short int *)prd)[3]));
966924 printk("2. bttl %x, l %x\n",bttl, l);
967925 #endif
968− } else {
969− /*
970− * For a linear request write a chain of blocks
971− */
972− bttl = workreq->SCp.dma_handle;
973− l = workreq->request_bufflen;
974− i = 0;
975−#ifdef ED_DBGP
976− printk("3. bttl %x, l %x\n",bttl, l);
977−#endif
978− while (l > 0x10000) {
979− (((u16 *) (prd))[i + 3]) = 0x0000;
980− (((u16 *) (prd))[i + 2]) = 0x0000;
981− (((u32 *) (prd))[i >> 1]) = cpu_to_le32(bttl);
982− l -= 0x10000;
983− bttl += 0x10000;
984− i += 0x04;
985− }
986− (((u16 *) (prd))[i + 3]) = cpu_to_le16(0x8000);
987− (((u16 *) (prd))[i + 2]) = cpu_to_le16(l);
988− (((u32 *) (prd))[i >> 1]) = cpu_to_le32(bttl);
989−#ifdef ED_DBGP
990− printk("prd %4x %4x %4x %4x\n",(((unsigned short int *)prd)[0]),(((unsigned short int *)prd)[1]),(((unsigned short int *)prd)[2]),(((unsigned short int *)prd)[3]));
991− printk("4. bttl %x, l %x\n",bttl, l);
992−#endif
993−
994926 }
995927 tmpcip += 4;
996928 #ifdef ED_DBGP
drivers/scsi/ch.c+109−106
@@ -21,6 +21,7 @@ · 20 unmodified lines
2121 #include <linux/compat.h>
2222 #include <linux/chio.h> /* here are all the ioctls */
2323 #include <linux/mutex.h>
24+#include <linux/idr.h>
2425
2526 #include <scsi/scsi.h>
2627 #include <scsi/scsi_cmnd.h>
@@ -33,6 +34,7 @@ · 6 unmodified lines
3334
3435 #define CH_DT_MAX 16
3536 #define CH_TYPES 8
37+#define CH_MAX_DEVS 128
3638
3739 MODULE_DESCRIPTION("device driver for scsi media changer devices");
3840 MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org>");
@@ -88,17 +90,6 @@ static const char * vendor_labels[CH_TYPES-4] = { · 49 unmodified lines
8890
8991 #define MAX_RETRIES 1
9092
91−static int ch_probe(struct device *);
92−static int ch_remove(struct device *);
93−static int ch_open(struct inode * inode, struct file * filp);
94−static int ch_release(struct inode * inode, struct file * filp);
95−static int ch_ioctl(struct inode * inode, struct file * filp,
96− unsigned int cmd, unsigned long arg);
97−#ifdef CONFIG_COMPAT
98−static long ch_ioctl_compat(struct file * filp,
99− unsigned int cmd, unsigned long arg);
100−#endif
101−
10293 static struct class * ch_sysfs_class;
10394
10495 typedef struct {
@@ -114,30 +105,8 @@ typedef struct { · 9 unmodified lines
114105 struct mutex lock;
115106 } scsi_changer;
116107
117−static LIST_HEAD(ch_devlist);
118−static DEFINE_SPINLOCK(ch_devlist_lock);
119−static int ch_devcount;
120−
121−static struct scsi_driver ch_template =
122−{
123− .owner = THIS_MODULE,
124− .gendrv = {
125− .name = "ch",
126− .probe = ch_probe,
127− .remove = ch_remove,
128− },
129−};
130−
131−static const struct file_operations changer_fops =
132−{
133− .owner = THIS_MODULE,
134− .open = ch_open,
135− .release = ch_release,
136− .ioctl = ch_ioctl,
137−#ifdef CONFIG_COMPAT
138− .compat_ioctl = ch_ioctl_compat,
139−#endif
140−};
108+static DEFINE_IDR(ch_index_idr);
109+static DEFINE_SPINLOCK(ch_index_lock);
141110
142111 static const struct {
143112 unsigned char sense;
@@ -207,7 +176,7 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd, · 63 unmodified lines
207176 {
208177 int errno, retries = 0, timeout, result;
209178 struct scsi_sense_hdr sshdr;
210−
179+
211180 timeout = (cmd[0] == INITIALIZE_ELEMENT_STATUS)
212181 ? timeout_init : timeout_move;
213182
@@ -245,7 +214,7 @@ static int · 31 unmodified lines
245214 ch_elem_to_typecode(scsi_changer *ch, u_int elem)
246215 {
247216 int i;
248−
217+
249218 for (i = 0; i < CH_TYPES; i++) {
250219 if (elem >= ch->firsts[i] &&
251220 elem < ch->firsts[i] +
@@ -261,15 +230,15 @@ ch_read_element_status(scsi_changer *ch, u_int elem, char *data) · 9 unmodified lines
261230 u_char cmd[12];
262231 u_char *buffer;
263232 int result;
264−
233+
265234 buffer = kmalloc(512, GFP_KERNEL | GFP_DMA);
266235 if(!buffer)
267236 return -ENOMEM;
268−
237+
269238 retry:
270239 memset(cmd,0,sizeof(cmd));
271240 cmd[0] = READ_ELEMENT_STATUS;
272− cmd[1] = (ch->device->lun << 5) |
241+ cmd[1] = (ch->device->lun << 5) |
273242 (ch->voltags ? 0x10 : 0) |
274243 ch_elem_to_typecode(ch,elem);
275244 cmd[2] = (elem >> 8) & 0xff;
@@ -296,7 +265,7 @@ ch_read_element_status(scsi_changer *ch, u_int elem, char *data) · 20 unmodified lines
296265 return result;
297266 }
298267
299−static int
268+static int
300269 ch_init_elem(scsi_changer *ch)
301270 {
302271 int err;
@@ -322,7 +291,7 @@ ch_readconfig(scsi_changer *ch) · 19 unmodified lines
322291 buffer = kzalloc(512, GFP_KERNEL | GFP_DMA);
323292 if (!buffer)
324293 return -ENOMEM;
325−
294+
326295 memset(cmd,0,sizeof(cmd));
327296 cmd[0] = MODE_SENSE;
328297 cmd[1] = ch->device->lun << 5;
@@ -365,7 +334,7 @@ ch_readconfig(scsi_changer *ch) · 36 unmodified lines
365334 } else {
366335 vprintk("reading element address assigment page failed!\n");
367336 }
368−
337+
369338 /* vendor specific element types */
370339 for (i = 0; i < 4; i++) {
371340 if (0 == vendor_counts[i])
@@ -443,7 +412,7 @@ static int · 71 unmodified lines
443412 ch_position(scsi_changer *ch, u_int trans, u_int elem, int rotate)
444413 {
445414 u_char cmd[10];
446−
415+
447416 dprintk("position: 0x%x\n",elem);
448417 if (0 == trans)
449418 trans = ch->firsts[CHET_MT];
@@ -462,7 +431,7 @@ static int · 12 unmodified lines
462431 ch_move(scsi_changer *ch, u_int trans, u_int src, u_int dest, int rotate)
463432 {
464433 u_char cmd[12];
465−
434+
466435 dprintk("move: 0x%x => 0x%x\n",src,dest);
467436 if (0 == trans)
468437 trans = ch->firsts[CHET_MT];
@@ -484,7 +453,7 @@ ch_exchange(scsi_changer *ch, u_int trans, u_int src, · 15 unmodified lines
484453 u_int dest1, u_int dest2, int rotate1, int rotate2)
485454 {
486455 u_char cmd[12];
487−
456+
488457 dprintk("exchange: 0x%x => 0x%x => 0x%x\n",
489458 src,dest1,dest2);
490459 if (0 == trans)
@@ -501,7 +470,7 @@ ch_exchange(scsi_changer *ch, u_int trans, u_int src, · 10 unmodified lines
501470 cmd[8] = (dest2 >> 8) & 0xff;
502471 cmd[9] = dest2 & 0xff;
503472 cmd[10] = (rotate1 ? 1 : 0) | (rotate2 ? 2 : 0);
504−
473+
505474 return ch_do_scsi(ch, cmd, NULL,0, DMA_NONE);
506475 }
507476
@@ -539,14 +508,14 @@ ch_set_voltag(scsi_changer *ch, u_int elem, · 31 unmodified lines
539508 elem, tag);
540509 memset(cmd,0,sizeof(cmd));
541510 cmd[0] = SEND_VOLUME_TAG;
542− cmd[1] = (ch->device->lun << 5) |
511+ cmd[1] = (ch->device->lun << 5) |
543512 ch_elem_to_typecode(ch,elem);
544513 cmd[2] = (elem >> 8) & 0xff;
545514 cmd[3] = elem & 0xff;
546515 cmd[5] = clear
547516 ? (alternate ? 0x0d : 0x0c)
548517 : (alternate ? 0x0b : 0x0a);
549−
518+
550519 cmd[9] = 255;
551520
552521 memcpy(buffer,tag,32);
@@ -562,7 +531,7 @@ static int ch_gstatus(scsi_changer *ch, int type, unsigned char __user *dest) · 9 unmodified lines
562531 int retval = 0;
563532 u_char data[16];
564533 unsigned int i;
565−
534+
566535 mutex_lock(&ch->lock);
567536 for (i = 0; i < ch->counts[type]; i++) {
568537 if (0 != ch_read_element_status
@@ -599,20 +568,17 @@ ch_release(struct inode *inode, struct file *file) · 30 unmodified lines
599568 static int
600569 ch_open(struct inode *inode, struct file *file)
601570 {
602− scsi_changer *tmp, *ch;
571+ scsi_changer *ch;
603572 int minor = iminor(inode);
604573
605− spin_lock(&ch_devlist_lock);
606− ch = NULL;
607− list_for_each_entry(tmp,&ch_devlist,list) {
608− if (tmp->minor == minor)
609− ch = tmp;
610− }
574+ spin_lock(&ch_index_lock);
575+ ch = idr_find(&ch_index_idr, minor);
576+
611577 if (NULL == ch || scsi_device_get(ch->device)) {
612− spin_unlock(&ch_devlist_lock);
578+ spin_unlock(&ch_index_lock);
613579 return -ENXIO;
614580 }
615− spin_unlock(&ch_devlist_lock);
581+ spin_unlock(&ch_index_lock);
616582
617583 file->private_data = ch;
618584 return 0;
@@ -626,24 +592,24 @@ ch_checkrange(scsi_changer *ch, unsigned int type, unsigned int unit) · 7 unmodified lines
626592 return 0;
627593 }
628594
629−static int ch_ioctl(struct inode * inode, struct file * file,
595+static long ch_ioctl(struct file *file,
630596 unsigned int cmd, unsigned long arg)
631597 {
632598 scsi_changer *ch = file->private_data;
633599 int retval;
634600 void __user *argp = (void __user *)arg;
635−
601+
636602 switch (cmd) {
637603 case CHIOGPARAMS:
638604 {
639605 struct changer_params params;
640−
606+
641607 params.cp_curpicker = 0;
642608 params.cp_npickers = ch->counts[CHET_MT];
643609 params.cp_nslots = ch->counts[CHET_ST];
644610 params.cp_nportals = ch->counts[CHET_IE];
645611 params.cp_ndrives = ch->counts[CHET_DT];
646−
612+
647613 if (copy_to_user(argp, &params, sizeof(params)))
648614 return -EFAULT;
649615 return 0;
@@ -673,11 +639,11 @@ static int ch_ioctl(struct inode * inode, struct file * file, · 23 unmodified lines
673639 return -EFAULT;
674640 return 0;
675641 }
676−
642+
677643 case CHIOPOSITION:
678644 {
679645 struct changer_position pos;
680−
646+
681647 if (copy_from_user(&pos, argp, sizeof (pos)))
682648 return -EFAULT;
683649
@@ -692,7 +658,7 @@ static int ch_ioctl(struct inode * inode, struct file * file, · 8 unmodified lines
692658 mutex_unlock(&ch->lock);
693659 return retval;
694660 }
695−
661+
696662 case CHIOMOVE:
697663 {
698664 struct changer_move mv;
@@ -705,7 +671,7 @@ static int ch_ioctl(struct inode * inode, struct file * file, · 6 unmodified lines
705671 dprintk("CHIOMOVE: invalid parameter\n");
706672 return -EBADSLT;
707673 }
708−
674+
709675 mutex_lock(&ch->lock);
710676 retval = ch_move(ch,0,
711677 ch->firsts[mv.cm_fromtype] + mv.cm_fromunit,
@@ -718,7 +684,7 @@ static int ch_ioctl(struct inode * inode, struct file * file, · 6 unmodified lines
718684 case CHIOEXCHANGE:
719685 {
720686 struct changer_exchange mv;
721−
687+
722688 if (copy_from_user(&mv, argp, sizeof (mv)))
723689 return -EFAULT;
724690
@@ -728,7 +694,7 @@ static int ch_ioctl(struct inode * inode, struct file * file, · 3 unmodified lines
728694 dprintk("CHIOEXCHANGE: invalid parameter\n");
729695 return -EBADSLT;
730696 }
731−
697+
732698 mutex_lock(&ch->lock);
733699 retval = ch_exchange
734700 (ch,0,
@@ -743,7 +709,7 @@ static int ch_ioctl(struct inode * inode, struct file * file, · 8 unmodified lines
743709 case CHIOGSTATUS:
744710 {
745711 struct changer_element_status ces;
746−
712+
747713 if (copy_from_user(&ces, argp, sizeof (ces)))
748714 return -EFAULT;
749715 if (ces.ces_type < 0 || ces.ces_type >= CH_TYPES)
@@ -759,19 +725,19 @@ static int ch_ioctl(struct inode * inode, struct file * file, · 9 unmodified lines
759725 u_char *buffer;
760726 unsigned int elem;
761727 int result,i;
762−
728+
763729 if (copy_from_user(&cge, argp, sizeof (cge)))
764730 return -EFAULT;
765731
766732 if (0 != ch_checkrange(ch, cge.cge_type, cge.cge_unit))
767733 return -EINVAL;
768734 elem = ch->firsts[cge.cge_type] + cge.cge_unit;
769−
735+
770736 buffer = kmalloc(512, GFP_KERNEL | GFP_DMA);
771737 if (!buffer)
772738 return -ENOMEM;
773739 mutex_lock(&ch->lock);
774−
740+
775741 voltag_retry:
776742 memset(cmd,0,sizeof(cmd));
777743 cmd[0] = READ_ELEMENT_STATUS;
@@ -782,7 +748,7 @@ static int ch_ioctl(struct inode * inode, struct file * file, · 4 unmodified lines
782748 cmd[3] = elem & 0xff;
783749 cmd[5] = 1;
784750 cmd[9] = 255;
785−
751+
786752 if (0 == (result = ch_do_scsi(ch, cmd, buffer, 256, DMA_FROM_DEVICE))) {
787753 cge.cge_status = buffer[18];
788754 cge.cge_flags = 0;
@@ -822,7 +788,7 @@ static int ch_ioctl(struct inode * inode, struct file * file, · 33 unmodified lines
822788 }
823789 kfree(buffer);
824790 mutex_unlock(&ch->lock);
825−
791+
826792 if (copy_to_user(argp, &cge, sizeof (cge)))
827793 return -EFAULT;
828794 return result;
@@ -835,7 +801,7 @@ static int ch_ioctl(struct inode * inode, struct file * file, · 6 unmodified lines
835801 mutex_unlock(&ch->lock);
836802 return retval;
837803 }
838−
804+
839805 case CHIOSVOLTAG:
840806 {
841807 struct changer_set_voltag csv;
@@ -876,7 +842,7 @@ static long ch_ioctl_compat(struct file * file, · 34 unmodified lines
876842 unsigned int cmd, unsigned long arg)
877843 {
878844 scsi_changer *ch = file->private_data;
879−
845+
880846 switch (cmd) {
881847 case CHIOGPARAMS:
882848 case CHIOGVPARAMS:
@@ -887,13 +853,12 @@ static long ch_ioctl_compat(struct file * file, · 4 unmodified lines
887853 case CHIOINITELEM:
888854 case CHIOSVOLTAG:
889855 /* compatible */
890− return ch_ioctl(NULL /* inode, unused */,
891− file, cmd, arg);
856+ return ch_ioctl(file, cmd, arg);
892857 case CHIOGSTATUS32:
893858 {
894859 struct changer_element_status32 ces32;
895860 unsigned char __user *data;
896−
861+
897862 if (copy_from_user(&ces32, (void __user *)arg, sizeof (ces32)))
898863 return -EFAULT;
899864 if (ces32.ces_type < 0 || ces32.ces_type >= CH_TYPES)
@@ -915,63 +880,100 @@ static long ch_ioctl_compat(struct file * file, · 15 unmodified lines
915880 static int ch_probe(struct device *dev)
916881 {
917882 struct scsi_device *sd = to_scsi_device(dev);
883+ struct class_device *class_dev;
884+ int minor, ret = -ENOMEM;
918885 scsi_changer *ch;
919−
886+
920887 if (sd->type != TYPE_MEDIUM_CHANGER)
921888 return -ENODEV;
922−
889+
923890 ch = kzalloc(sizeof(*ch), GFP_KERNEL);
924891 if (NULL == ch)
925892 return -ENOMEM;
926893
927− ch->minor = ch_devcount;
894+ if (!idr_pre_get(&ch_index_idr, GFP_KERNEL))
895+ goto free_ch;
896+
897+ spin_lock(&ch_index_lock);
898+ ret = idr_get_new(&ch_index_idr, ch, &minor);
899+ spin_unlock(&ch_index_lock);
900+
901+ if (ret)
902+ goto free_ch;
903+
904+ if (minor > CH_MAX_DEVS) {
905+ ret = -ENODEV;
906+ goto remove_idr;
907+ }
908+
909+ ch->minor = minor;
928910 sprintf(ch->name,"ch%d",ch->minor);
911+
912+ class_dev = class_device_create(ch_sysfs_class, NULL,
913+ MKDEV(SCSI_CHANGER_MAJOR, ch->minor),
914+ dev, "s%s", ch->name);
915+ if (IS_ERR(class_dev)) {
916+ printk(KERN_WARNING "ch%d: class_device_create failed\n",
917+ ch->minor);
918+ ret = PTR_ERR(class_dev);
919+ goto remove_idr;
920+ }
921+
929922 mutex_init(&ch->lock);
930923 ch->device = sd;
931924 ch_readconfig(ch);
932925 if (init)
933926 ch_init_elem(ch);
934927
935− class_device_create(ch_sysfs_class, NULL,
936− MKDEV(SCSI_CHANGER_MAJOR,ch->minor),
937− dev, "s%s", ch->name);
938−
928+ dev_set_drvdata(dev, ch);
939929 sdev_printk(KERN_INFO, sd, "Attached scsi changer %s\n", ch->name);
940−
941− spin_lock(&ch_devlist_lock);
942− list_add_tail(&ch->list,&ch_devlist);
943− ch_devcount++;
944− spin_unlock(&ch_devlist_lock);
930+
945931 return 0;
932+remove_idr:
933+ idr_remove(&ch_index_idr, minor);
934+free_ch:
935+ kfree(ch);
936+ return ret;
946937 }
947938
948939 static int ch_remove(struct device *dev)
949940 {
950− struct scsi_device *sd = to_scsi_device(dev);
951− scsi_changer *tmp, *ch;
941+ scsi_changer *ch = dev_get_drvdata(dev);
952942
953− spin_lock(&ch_devlist_lock);
954− ch = NULL;
955− list_for_each_entry(tmp,&ch_devlist,list) {
956− if (tmp->device == sd)
957− ch = tmp;
958− }
959− BUG_ON(NULL == ch);
960− list_del(&ch->list);
961− spin_unlock(&ch_devlist_lock);
943+ spin_lock(&ch_index_lock);
944+ idr_remove(&ch_index_idr, ch->minor);
945+ spin_unlock(&ch_index_lock);
962946
963947 class_device_destroy(ch_sysfs_class,
964948 MKDEV(SCSI_CHANGER_MAJOR,ch->minor));
965949 kfree(ch->dt);
966950 kfree(ch);
967− ch_devcount--;
968951 return 0;
969952 }
970953
954+static struct scsi_driver ch_template = {
955+ .owner = THIS_MODULE,
956+ .gendrv = {
957+ .name = "ch",
958+ .probe = ch_probe,
959+ .remove = ch_remove,
960+ },
961+};
962+
963+static const struct file_operations changer_fops = {
964+ .owner = THIS_MODULE,
965+ .open = ch_open,
966+ .release = ch_release,
967+ .unlocked_ioctl = ch_ioctl,
968+#ifdef CONFIG_COMPAT
969+ .compat_ioctl = ch_ioctl_compat,
970+#endif
971+};
972+
971973 static int __init init_ch_module(void)
972974 {
973975 int rc;
974−
976+
975977 printk(KERN_INFO "SCSI Media Changer driver v" VERSION " \n");
976978 ch_sysfs_class = class_create(THIS_MODULE, "scsi_changer");
977979 if (IS_ERR(ch_sysfs_class)) {
@@ -996,11 +998,12 @@ static int __init init_ch_module(void) · 18 unmodified lines
996998 return rc;
997999 }
9981000
999−static void __exit exit_ch_module(void)
1001+static void __exit exit_ch_module(void)
10001002 {
10011003 scsi_unregister_driver(&ch_template.gendrv);
10021004 unregister_chrdev(SCSI_CHANGER_MAJOR, "ch");
10031005 class_destroy(ch_sysfs_class);
1006+ idr_destroy(&ch_index_idr);
10041007 }
10051008
10061009 module_init(init_ch_module);
drivers/scsi/constants.c+1−2
@@ -362,7 +362,6 @@ void scsi_print_command(struct scsi_cmnd *cmd) · 361 unmodified lines
362362 EXPORT_SYMBOL(scsi_print_command);
363363
364364 /**
365− *
366365 * scsi_print_status - print scsi status description
367366 * @scsi_status: scsi status value
368367 *
@@ -1369,7 +1368,7 @@ EXPORT_SYMBOL(scsi_print_sense); · 1000 unmodified lines
13691368 static const char * const hostbyte_table[]={
13701369 "DID_OK", "DID_NO_CONNECT", "DID_BUS_BUSY", "DID_TIME_OUT", "DID_BAD_TARGET",
13711370 "DID_ABORT", "DID_PARITY", "DID_ERROR", "DID_RESET", "DID_BAD_INTR",
1372−"DID_PASSTHROUGH", "DID_SOFT_ERROR", "DID_IMM_RETRY"};
1371+"DID_PASSTHROUGH", "DID_SOFT_ERROR", "DID_IMM_RETRY", "DID_REQUEUE"};
13731372 #define NUM_HOSTBYTE_STRS ARRAY_SIZE(hostbyte_table)
13741373
13751374 static const char * const driverbyte_table[]={
drivers/scsi/dc395x.c+7−9
@@ -1629,8 +1629,7 @@ static u8 start_scsi(struct AdapterCtlBlk* acb, struct DeviceCtlBlk* dcb, · 1628 unmodified lines
16291629 DC395x_write8(acb, TRM_S1040_SCSI_FIFO, (dcb->target_lun << 5));
16301630 DC395x_write8(acb, TRM_S1040_SCSI_FIFO, 0);
16311631 DC395x_write8(acb, TRM_S1040_SCSI_FIFO, 0);
1632− DC395x_write8(acb, TRM_S1040_SCSI_FIFO,
1633− sizeof(srb->cmd->sense_buffer));
1632+ DC395x_write8(acb, TRM_S1040_SCSI_FIFO, SCSI_SENSE_BUFFERSIZE);
16341633 DC395x_write8(acb, TRM_S1040_SCSI_FIFO, 0);
16351634 } else {
16361635 ptr = (u8 *)srb->cmd->cmnd;
@@ -1915,8 +1914,7 @@ static void command_phase1(struct AdapterCtlBlk *acb, struct ScsiReqBlk *srb, · 278 unmodified lines
19151914 DC395x_write8(acb, TRM_S1040_SCSI_FIFO, (dcb->target_lun << 5));
19161915 DC395x_write8(acb, TRM_S1040_SCSI_FIFO, 0);
19171916 DC395x_write8(acb, TRM_S1040_SCSI_FIFO, 0);
1918− DC395x_write8(acb, TRM_S1040_SCSI_FIFO,
1919− sizeof(srb->cmd->sense_buffer));
1917+ DC395x_write8(acb, TRM_S1040_SCSI_FIFO, SCSI_SENSE_BUFFERSIZE);
19201918 DC395x_write8(acb, TRM_S1040_SCSI_FIFO, 0);
19211919 }
19221920 srb->state |= SRB_COMMAND;
@@ -3685,7 +3683,7 @@ static void request_sense(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb, · 1762 unmodified lines
36853683 srb->target_status = 0;
36863684
36873685 /* KG: Can this prevent crap sense data ? */
3688− memset(cmd->sense_buffer, 0, sizeof(cmd->sense_buffer));
3686+ memset(cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
36893687
36903688 /* Save some data */
36913689 srb->segment_x[DC395x_MAX_SG_LISTENTRY - 1].address =
@@ -3694,15 +3692,15 @@ static void request_sense(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb, · 2 unmodified lines
36943692 srb->segment_x[0].length;
36953693 srb->xferred = srb->total_xfer_length;
36963694 /* srb->segment_x : a one entry of S/G list table */
3697− srb->total_xfer_length = sizeof(cmd->sense_buffer);
3698− srb->segment_x[0].length = sizeof(cmd->sense_buffer);
3695+ srb->total_xfer_length = SCSI_SENSE_BUFFERSIZE;
3696+ srb->segment_x[0].length = SCSI_SENSE_BUFFERSIZE;
36993697 /* Map sense buffer */
37003698 srb->segment_x[0].address =
37013699 pci_map_single(acb->dev, cmd->sense_buffer,
3702− sizeof(cmd->sense_buffer), PCI_DMA_FROMDEVICE);
3700+ SCSI_SENSE_BUFFERSIZE, PCI_DMA_FROMDEVICE);
37033701 dprintkdbg(DBG_SG, "request_sense: map buffer %p->%08x(%05x)\n",
37043702 cmd->sense_buffer, srb->segment_x[0].address,
3705− sizeof(cmd->sense_buffer));
3703+ SCSI_SENSE_BUFFERSIZE);
37063704 srb->sg_count = 1;
37073705 srb->sg_index = 0;
37083706
drivers/scsi/dpt_i2o.c+2−3
@@ -2296,9 +2296,8 @@ static s32 adpt_i2o_to_scsi(void __iomem *reply, struct scsi_cmnd* cmd) · 2295 unmodified lines
22962296
22972297 // copy over the request sense data if it was a check
22982298 // condition status
2299− if(dev_status == 0x02 /*CHECK_CONDITION*/) {
2300− u32 len = sizeof(cmd->sense_buffer);
2301− len = (len > 40) ? 40 : len;
2299+ if (dev_status == SAM_STAT_CHECK_CONDITION) {
2300+ u32 len = min(SCSI_SENSE_BUFFERSIZE, 40);
23022301 // Copy over the sense data
23032302 memcpy_fromio(cmd->sense_buffer, (reply+28) , len);
23042303 if(cmd->sense_buffer[0] == 0x70 /* class 7 */ &&
drivers/scsi/eata.c+2−2
@@ -1623,9 +1623,9 @@ static void map_dma(unsigned int i, struct hostdata *ha) · 1622 unmodified lines
16231623 if (SCpnt->sense_buffer)
16241624 cpp->sense_addr =
16251625 H2DEV(pci_map_single(ha->pdev, SCpnt->sense_buffer,
1626− sizeof SCpnt->sense_buffer, PCI_DMA_FROMDEVICE));
1626+ SCSI_SENSE_BUFFERSIZE, PCI_DMA_FROMDEVICE));
16271627
1628− cpp->sense_len = sizeof SCpnt->sense_buffer;
1628+ cpp->sense_len = SCSI_SENSE_BUFFERSIZE;
16291629
16301630 count = scsi_dma_map(SCpnt);
16311631 BUG_ON(count < 0);
drivers/scsi/eata_pio.c+6−7
@@ -369,7 +369,6 @@ static int eata_pio_queue(struct scsi_cmnd *cmd, · 368 unmodified lines
369369 cp = &hd->ccb[y];
370370
371371 memset(cp, 0, sizeof(struct eata_ccb));
372− memset(cmd->sense_buffer, 0, sizeof(cmd->sense_buffer));
373372
374373 cp->status = USED; /* claim free slot */
375374
@@ -385,7 +384,7 @@ static int eata_pio_queue(struct scsi_cmnd *cmd, · 9 unmodified lines
385384 cp->DataIn = 0; /* Input mode */
386385
387386 cp->Interpret = (cmd->device->id == hd->hostid);
388− cp->cp_datalen = cpu_to_be32(cmd->request_bufflen);
387+ cp->cp_datalen = cpu_to_be32(scsi_bufflen(cmd));
389388 cp->Auto_Req_Sen = 0;
390389 cp->cp_reqDMA = 0;
391390 cp->reqlen = 0;
@@ -402,14 +401,14 @@ static int eata_pio_queue(struct scsi_cmnd *cmd, · 10 unmodified lines
402401 cp->cmd = cmd;
403402 cmd->host_scribble = (char *) &hd->ccb[y];
404403
405− if (cmd->use_sg == 0) {
404+ if (!scsi_bufflen(cmd)) {
406405 cmd->SCp.buffers_residual = 1;
407− cmd->SCp.ptr = cmd->request_buffer;
408− cmd->SCp.this_residual = cmd->request_bufflen;
406+ cmd->SCp.ptr = NULL;
407+ cmd->SCp.this_residual = 0;
409408 cmd->SCp.buffer = NULL;
410409 } else {
411− cmd->SCp.buffer = cmd->request_buffer;
412− cmd->SCp.buffers_residual = cmd->use_sg;
410+ cmd->SCp.buffer = scsi_sglist(cmd);
411+ cmd->SCp.buffers_residual = scsi_sg_count(cmd);
413412 cmd->SCp.ptr = sg_virt(cmd->SCp.buffer);
414413 cmd->SCp.this_residual = cmd->SCp.buffer->length;
415414 }
drivers/scsi/fd_mcs.c+11−25
@@ -1017,24 +1017,6 @@ static irqreturn_t fd_mcs_intr(int irq, void *dev_id) · 1016 unmodified lines
10171017 printk(" ** IN DONE %d ** ", current_SC->SCp.have_data_in);
10181018 #endif
10191019
1020−#if ERRORS_ONLY
1021− if (current_SC->cmnd[0] == REQUEST_SENSE && !current_SC->SCp.Status) {
1022− if ((unsigned char) (*((char *) current_SC->request_buffer + 2)) & 0x0f) {
1023− unsigned char key;
1024− unsigned char code;
1025− unsigned char qualifier;
1026−
1027− key = (unsigned char) (*((char *) current_SC->request_buffer + 2)) & 0x0f;
1028− code = (unsigned char) (*((char *) current_SC->request_buffer + 12));
1029− qualifier = (unsigned char) (*((char *) current_SC->request_buffer + 13));
1030−
1031− if (key != UNIT_ATTENTION && !(key == NOT_READY && code == 0x04 && (!qualifier || qualifier == 0x02 || qualifier == 0x01))
1032− && !(key == ILLEGAL_REQUEST && (code == 0x25 || code == 0x24 || !code)))
1033−
1034− printk("fd_mcs: REQUEST SENSE " "Key = %x, Code = %x, Qualifier = %x\n", key, code, qualifier);
1035− }
1036− }
1037−#endif
10381020 #if EVERY_ACCESS
10391021 printk("BEFORE MY_DONE. . .");
10401022 #endif
@@ -1097,7 +1079,9 @@ static int fd_mcs_queue(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *)) · 56 unmodified lines
10971079 panic("fd_mcs: fd_mcs_queue() NOT REENTRANT!\n");
10981080 }
10991081 #if EVERY_ACCESS
1100− printk("queue: target = %d cmnd = 0x%02x pieces = %d size = %u\n", SCpnt->target, *(unsigned char *) SCpnt->cmnd, SCpnt->use_sg, SCpnt->request_bufflen);
1082+ printk("queue: target = %d cmnd = 0x%02x pieces = %d size = %u\n",
1083+ SCpnt->target, *(unsigned char *) SCpnt->cmnd,
1084+ scsi_sg_count(SCpnt), scsi_bufflen(SCpnt));
11011085 #endif
11021086
11031087 fd_mcs_make_bus_idle(shpnt);
@@ -1107,14 +1091,14 @@ static int fd_mcs_queue(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *)) · 3 unmodified lines
11071091
11081092 /* Initialize static data */
11091093
1110− if (current_SC->use_sg) {
1111− current_SC->SCp.buffer = (struct scatterlist *) current_SC->request_buffer;
1094+ if (scsi_bufflen(current_SC)) {
1095+ current_SC->SCp.buffer = scsi_sglist(current_SC);
11121096 current_SC->SCp.ptr = sg_virt(current_SC->SCp.buffer);
11131097 current_SC->SCp.this_residual = current_SC->SCp.buffer->length;
1114− current_SC->SCp.buffers_residual = current_SC->use_sg - 1;
1098+ current_SC->SCp.buffers_residual = scsi_sg_count(current_SC) - 1;
11151099 } else {
1116− current_SC->SCp.ptr = (char *) current_SC->request_buffer;
1117− current_SC->SCp.this_residual = current_SC->request_bufflen;
1100+ current_SC->SCp.ptr = NULL;
1101+ current_SC->SCp.this_residual = 0;
11181102 current_SC->SCp.buffer = NULL;
11191103 current_SC->SCp.buffers_residual = 0;
11201104 }
@@ -1166,7 +1150,9 @@ static void fd_mcs_print_info(Scsi_Cmnd * SCpnt) · 45 unmodified lines
11661150 break;
11671151 }
11681152
1169− printk("(%d), target = %d cmnd = 0x%02x pieces = %d size = %u\n", SCpnt->SCp.phase, SCpnt->device->id, *(unsigned char *) SCpnt->cmnd, SCpnt->use_sg, SCpnt->request_bufflen);
1153+ printk("(%d), target = %d cmnd = 0x%02x pieces = %d size = %u\n",
1154+ SCpnt->SCp.phase, SCpnt->device->id, *(unsigned char *) SCpnt->cmnd,
1155+ scsi_sg_count(SCpnt), scsi_bufflen(SCpnt));
11701156 printk("sent_command = %d, have_data_in = %d, timeout = %d\n", SCpnt->SCp.sent_command, SCpnt->SCp.have_data_in, SCpnt->timeout);
11711157 #if DEBUG_RACE
11721158 printk("in_interrupt_flag = %d\n", in_interrupt_flag);
drivers/scsi/gdth.c+10−12
@@ -141,7 +141,7 @@ · 140 unmodified lines
141141 static void gdth_delay(int milliseconds);
142142 static void gdth_eval_mapping(ulong32 size, ulong32 *cyls, int *heads, int *secs);
143143 static irqreturn_t gdth_interrupt(int irq, void *dev_id);
144−static irqreturn_t __gdth_interrupt(gdth_ha_str *ha, int irq,
144+static irqreturn_t __gdth_interrupt(gdth_ha_str *ha,
145145 int gdth_from_wait, int* pIndex);
146146 static int gdth_sync_event(gdth_ha_str *ha, int service, unchar index,
147147 Scsi_Cmnd *scp);
@@ -165,7 +165,6 @@ static int gdth_internal_cache_cmd(gdth_ha_str *ha, Scsi_Cmnd *scp); · 17 unmodified lines
165165 static int gdth_fill_cache_cmd(gdth_ha_str *ha, Scsi_Cmnd *scp, ushort hdrive);
166166
167167 static void gdth_enable_int(gdth_ha_str *ha);
168−static unchar gdth_get_status(gdth_ha_str *ha, int irq);
169168 static int gdth_test_busy(gdth_ha_str *ha);
170169 static int gdth_get_cmd_index(gdth_ha_str *ha);
171170 static void gdth_release_event(gdth_ha_str *ha);
@@ -1334,14 +1333,12 @@ static void __init gdth_enable_int(gdth_ha_str *ha) · 1162 unmodified lines
13341333 }
13351334
13361335 /* return IStatus if interrupt was from this card else 0 */
1337−static unchar gdth_get_status(gdth_ha_str *ha, int irq)
1336+static unchar gdth_get_status(gdth_ha_str *ha)
13381337 {
13391338 unchar IStatus = 0;
13401339
1341− TRACE(("gdth_get_status() irq %d ctr_count %d\n", irq, gdth_ctr_count));
1340+ TRACE(("gdth_get_status() irq %d ctr_count %d\n", ha->irq, gdth_ctr_count));
13421341
1343− if (ha->irq != (unchar)irq) /* check IRQ */
1344− return false;
13451342 if (ha->type == GDT_EISA)
13461343 IStatus = inb((ushort)ha->bmic + EDOORREG);
13471344 else if (ha->type == GDT_ISA)
@@ -1523,7 +1520,7 @@ static int gdth_wait(gdth_ha_str *ha, int index, ulong32 time) · 175 unmodified lines
15231520 return 1; /* no wait required */
15241521
15251522 do {
1526− __gdth_interrupt(ha, (int)ha->irq, true, &wait_index);
1523+ __gdth_interrupt(ha, true, &wait_index);
15271524 if (wait_index == index) {
15281525 answer_found = TRUE;
15291526 break;
@@ -3036,7 +3033,7 @@ static void gdth_clear_events(void) · 1506 unmodified lines
30363033
30373034 /* SCSI interface functions */
30383035
3039−static irqreturn_t __gdth_interrupt(gdth_ha_str *ha, int irq,
3036+static irqreturn_t __gdth_interrupt(gdth_ha_str *ha,
30403037 int gdth_from_wait, int* pIndex)
30413038 {
30423039 gdt6m_dpram_str __iomem *dp6m_ptr = NULL;
@@ -3054,7 +3051,7 @@ static irqreturn_t __gdth_interrupt(gdth_ha_str *ha, int irq, · 11 unmodified lines
30543051 int act_int_coal = 0;
30553052 #endif
30563053
3057− TRACE(("gdth_interrupt() IRQ %d\n",irq));
3054+ TRACE(("gdth_interrupt() IRQ %d\n", ha->irq));
30583055
30593056 /* if polling and not from gdth_wait() -> return */
30603057 if (gdth_polling) {
@@ -3067,7 +3064,8 @@ static irqreturn_t __gdth_interrupt(gdth_ha_str *ha, int irq, · 6 unmodified lines
30673064 spin_lock_irqsave(&ha->smp_lock, flags);
30683065
30693066 /* search controller */
3070− if (0 == (IStatus = gdth_get_status(ha, irq))) {
3067+ IStatus = gdth_get_status(ha);
3068+ if (IStatus == 0) {
30713069 /* spurious interrupt */
30723070 if (!gdth_polling)
30733071 spin_unlock_irqrestore(&ha->smp_lock, flags);
@@ -3294,9 +3292,9 @@ static irqreturn_t __gdth_interrupt(gdth_ha_str *ha, int irq, · 220 unmodified lines
32943292
32953293 static irqreturn_t gdth_interrupt(int irq, void *dev_id)
32963294 {
3297− gdth_ha_str *ha = (gdth_ha_str *)dev_id;
3295+ gdth_ha_str *ha = dev_id;
32983296
3299− return __gdth_interrupt(ha, irq, false, NULL);
3297+ return __gdth_interrupt(ha, false, NULL);
33003298 }
33013299
33023300 static int gdth_sync_event(gdth_ha_str *ha, int service, unchar index,
drivers/scsi/hosts.c+1−3
@@ -54,8 +54,7 @@ static struct class shost_class = { · 53 unmodified lines
5454 };
5555
5656 /**
57− * scsi_host_set_state - Take the given host through the host
58− * state model.
57+ * scsi_host_set_state - Take the given host through the host state model.
5958 * @shost: scsi host to change the state of.
6059 * @state: state to change to.
6160 *
@@ -440,7 +439,6 @@ static int __scsi_host_match(struct class_device *cdev, void *data) · 378 unmodified lines
440439
441440 /**
442441 * scsi_host_lookup - get a reference to a Scsi_Host by host no
443− *
444442 * @hostnum: host number to locate
445443 *
446444 * Return value:
drivers/scsi/hptiop.c+464−129
@@ -1,5 +1,5 @@
11 /*
2− * HighPoint RR3xxx controller driver for Linux
2+ * HighPoint RR3xxx/4xxx controller driver for Linux
33 * Copyright (C) 2006-2007 HighPoint Technologies, Inc. All Rights Reserved.
44 *
55 * This program is free software; you can redistribute it and/or modify
@@ -38,80 +38,84 @@ · 32 unmodified lines
3838 #include "hptiop.h"
3939
4040 MODULE_AUTHOR("HighPoint Technologies, Inc.");
41−MODULE_DESCRIPTION("HighPoint RocketRAID 3xxx SATA Controller Driver");
41+MODULE_DESCRIPTION("HighPoint RocketRAID 3xxx/4xxx Controller Driver");
4242
4343 static char driver_name[] = "hptiop";
44−static const char driver_name_long[] = "RocketRAID 3xxx SATA Controller driver";
45−static const char driver_ver[] = "v1.2 (070830)";
46−
47−static void hptiop_host_request_callback(struct hptiop_hba *hba, u32 tag);
48−static void hptiop_iop_request_callback(struct hptiop_hba *hba, u32 tag);
44+static const char driver_name_long[] = "RocketRAID 3xxx/4xxx Controller driver";
45+static const char driver_ver[] = "v1.3 (071203)";
46+
47+static int iop_send_sync_msg(struct hptiop_hba *hba, u32 msg, u32 millisec);
48+static void hptiop_finish_scsi_req(struct hptiop_hba *hba, u32 tag,
49+ struct hpt_iop_request_scsi_command *req);
50+static void hptiop_host_request_callback_itl(struct hptiop_hba *hba, u32 tag);
51+static void hptiop_iop_request_callback_itl(struct hptiop_hba *hba, u32 tag);
4952 static void hptiop_message_callback(struct hptiop_hba *hba, u32 msg);
5053
51−static inline void hptiop_pci_posting_flush(struct hpt_iopmu __iomem *iop)
52−{
53− readl(&iop->outbound_intstatus);
54−}
55−
56−static int iop_wait_ready(struct hpt_iopmu __iomem *iop, u32 millisec)
54+static int iop_wait_ready_itl(struct hptiop_hba *hba, u32 millisec)
5755 {
5856 u32 req = 0;
5957 int i;
6058
6159 for (i = 0; i < millisec; i++) {
62− req = readl(&iop->inbound_queue);
60+ req = readl(&hba->u.itl.iop->inbound_queue);
6361 if (req != IOPMU_QUEUE_EMPTY)
6462 break;
6563 msleep(1);
6664 }
6765
6866 if (req != IOPMU_QUEUE_EMPTY) {
69− writel(req, &iop->outbound_queue);
70− hptiop_pci_posting_flush(iop);
67+ writel(req, &hba->u.itl.iop->outbound_queue);
68+ readl(&hba->u.itl.iop->outbound_intstatus);
7169 return 0;
7270 }
7371
7472 return -1;
7573 }
7674
77−static void hptiop_request_callback(struct hptiop_hba *hba, u32 tag)
75+static int iop_wait_ready_mv(struct hptiop_hba *hba, u32 millisec)
76+{
77+ return iop_send_sync_msg(hba, IOPMU_INBOUND_MSG0_NOP, millisec);
78+}
79+
80+static void hptiop_request_callback_itl(struct hptiop_hba *hba, u32 tag)
7881 {
7982 if (tag & IOPMU_QUEUE_ADDR_HOST_BIT)
80− return hptiop_host_request_callback(hba,
83+ hptiop_host_request_callback_itl(hba,
8184 tag & ~IOPMU_QUEUE_ADDR_HOST_BIT);
8285 else
83− return hptiop_iop_request_callback(hba, tag);
86+ hptiop_iop_request_callback_itl(hba, tag);
8487 }
8588
86−static inline void hptiop_drain_outbound_queue(struct hptiop_hba *hba)
89+static void hptiop_drain_outbound_queue_itl(struct hptiop_hba *hba)
8790 {
8891 u32 req;
8992
90− while ((req = readl(&hba->iop->outbound_queue)) != IOPMU_QUEUE_EMPTY) {
93+ while ((req = readl(&hba->u.itl.iop->outbound_queue)) !=
94+ IOPMU_QUEUE_EMPTY) {
9195
9296 if (req & IOPMU_QUEUE_MASK_HOST_BITS)
93− hptiop_request_callback(hba, req);
97+ hptiop_request_callback_itl(hba, req);
9498 else {
9599 struct hpt_iop_request_header __iomem * p;
96100
97101 p = (struct hpt_iop_request_header __iomem *)
98− ((char __iomem *)hba->iop + req);
102+ ((char __iomem *)hba->u.itl.iop + req);
99103
100104 if (readl(&p->flags) & IOP_REQUEST_FLAG_SYNC_REQUEST) {
101105 if (readl(&p->context))
102− hptiop_request_callback(hba, req);
106+ hptiop_request_callback_itl(hba, req);
103107 else
104108 writel(1, &p->context);
105109 }
106110 else
107− hptiop_request_callback(hba, req);
111+ hptiop_request_callback_itl(hba, req);
108112 }
109113 }
110114 }
111115
112−static int __iop_intr(struct hptiop_hba *hba)
116+static int iop_intr_itl(struct hptiop_hba *hba)
113117 {
114− struct hpt_iopmu __iomem *iop = hba->iop;
118+ struct hpt_iopmu_itl __iomem *iop = hba->u.itl.iop;
115119 u32 status;
116120 int ret = 0;
117121
@@ -119,6 +123,7 @@ static int __iop_intr(struct hptiop_hba *hba) · 1 unmodified line
119123
120124 if (status & IOPMU_OUTBOUND_INT_MSG0) {
121125 u32 msg = readl(&iop->outbound_msgaddr0);
126+
122127 dprintk("received outbound msg %x\n", msg);
123128 writel(IOPMU_OUTBOUND_INT_MSG0, &iop->outbound_intstatus);
124129 hptiop_message_callback(hba, msg);
@@ -126,31 +131,115 @@ static int __iop_intr(struct hptiop_hba *hba) · 1 unmodified line
126131 }
127132
128133 if (status & IOPMU_OUTBOUND_INT_POSTQUEUE) {
129− hptiop_drain_outbound_queue(hba);
134+ hptiop_drain_outbound_queue_itl(hba);
135+ ret = 1;
136+ }
137+
138+ return ret;
139+}
140+
141+static u64 mv_outbound_read(struct hpt_iopmu_mv __iomem *mu)
142+{
143+ u32 outbound_tail = readl(&mu->outbound_tail);
144+ u32 outbound_head = readl(&mu->outbound_head);
145+
146+ if (outbound_tail != outbound_head) {
147+ u64 p;
148+
149+ memcpy_fromio(&p, &mu->outbound_q[mu->outbound_tail], 8);
150+ outbound_tail++;
151+
152+ if (outbound_tail == MVIOP_QUEUE_LEN)
153+ outbound_tail = 0;
154+ writel(outbound_tail, &mu->outbound_tail);
155+ return p;
156+ } else
157+ return 0;
158+}
159+
160+static void mv_inbound_write(u64 p, struct hptiop_hba *hba)
161+{
162+ u32 inbound_head = readl(&hba->u.mv.mu->inbound_head);
163+ u32 head = inbound_head + 1;
164+
165+ if (head == MVIOP_QUEUE_LEN)
166+ head = 0;
167+
168+ memcpy_toio(&hba->u.mv.mu->inbound_q[inbound_head], &p, 8);
169+ writel(head, &hba->u.mv.mu->inbound_head);
170+ writel(MVIOP_MU_INBOUND_INT_POSTQUEUE,
171+ &hba->u.mv.regs->inbound_doorbell);
172+}
173+
174+static void hptiop_request_callback_mv(struct hptiop_hba *hba, u64 tag)
175+{
176+ u32 req_type = (tag >> 5) & 0x7;
177+ struct hpt_iop_request_scsi_command *req;
178+
179+ dprintk("hptiop_request_callback_mv: tag=%llx\n", tag);
180+
181+ BUG_ON((tag & MVIOP_MU_QUEUE_REQUEST_RETURN_CONTEXT) == 0);
182+
183+ switch (req_type) {
184+ case IOP_REQUEST_TYPE_GET_CONFIG:
185+ case IOP_REQUEST_TYPE_SET_CONFIG:
186+ hba->msg_done = 1;
187+ break;
188+
189+ case IOP_REQUEST_TYPE_SCSI_COMMAND:
190+ req = hba->reqs[tag >> 8].req_virt;
191+ if (likely(tag & MVIOP_MU_QUEUE_REQUEST_RESULT_BIT))
192+ req->header.result = cpu_to_le32(IOP_RESULT_SUCCESS);
193+
194+ hptiop_finish_scsi_req(hba, tag>>8, req);
195+ break;
196+
197+ default:
198+ break;
199+ }
200+}
201+
202+static int iop_intr_mv(struct hptiop_hba *hba)
203+{
204+ u32 status;
205+ int ret = 0;
206+
207+ status = readl(&hba->u.mv.regs->outbound_doorbell);
208+ writel(~status, &hba->u.mv.regs->outbound_doorbell);
209+
210+ if (status & MVIOP_MU_OUTBOUND_INT_MSG) {
211+ u32 msg;
212+ msg = readl(&hba->u.mv.mu->outbound_msg);
213+ dprintk("received outbound msg %x\n", msg);
214+ hptiop_message_callback(hba, msg);
215+ ret = 1;
216+ }
217+
218+ if (status & MVIOP_MU_OUTBOUND_INT_POSTQUEUE) {
219+ u64 tag;
220+
221+ while ((tag = mv_outbound_read(hba->u.mv.mu)))
222+ hptiop_request_callback_mv(hba, tag);
130223 ret = 1;
131224 }
132225
133226 return ret;
134227 }
135228
136−static int iop_send_sync_request(struct hptiop_hba *hba,
229+static int iop_send_sync_request_itl(struct hptiop_hba *hba,
137230 void __iomem *_req, u32 millisec)
138231 {
139232 struct hpt_iop_request_header __iomem *req = _req;
140233 u32 i;
141234
142− writel(readl(&req->flags) | IOP_REQUEST_FLAG_SYNC_REQUEST,
143− &req->flags);
144−
235+ writel(readl(&req->flags) | IOP_REQUEST_FLAG_SYNC_REQUEST, &req->flags);
145236 writel(0, &req->context);
146−
147− writel((unsigned long)req - (unsigned long)hba->iop,
148− &hba->iop->inbound_queue);
149−
150− hptiop_pci_posting_flush(hba->iop);
237+ writel((unsigned long)req - (unsigned long)hba->u.itl.iop,
238+ &hba->u.itl.iop->inbound_queue);
239+ readl(&hba->u.itl.iop->outbound_intstatus);
151240
152241 for (i = 0; i < millisec; i++) {
153− __iop_intr(hba);
242+ iop_intr_itl(hba);
154243 if (readl(&req->context))
155244 return 0;
156245 msleep(1);
@@ -159,19 +248,49 @@ static int iop_send_sync_request(struct hptiop_hba *hba, · 2 unmodified lines
159248 return -1;
160249 }
161250
162−static int iop_send_sync_msg(struct hptiop_hba *hba, u32 msg, u32 millisec)
251+static int iop_send_sync_request_mv(struct hptiop_hba *hba,
252+ u32 size_bits, u32 millisec)
163253 {
254+ struct hpt_iop_request_header *reqhdr = hba->u.mv.internal_req;
164255 u32 i;
165256
166257 hba->msg_done = 0;
258+ reqhdr->flags |= cpu_to_le32(IOP_REQUEST_FLAG_SYNC_REQUEST);
259+ mv_inbound_write(hba->u.mv.internal_req_phy |
260+ MVIOP_MU_QUEUE_ADDR_HOST_BIT | size_bits, hba);
261+
262+ for (i = 0; i < millisec; i++) {
263+ iop_intr_mv(hba);
264+ if (hba->msg_done)
265+ return 0;
266+ msleep(1);
267+ }
268+ return -1;
269+}
270+
271+static void hptiop_post_msg_itl(struct hptiop_hba *hba, u32 msg)
272+{
273+ writel(msg, &hba->u.itl.iop->inbound_msgaddr0);
274+ readl(&hba->u.itl.iop->outbound_intstatus);
275+}
276+
277+static void hptiop_post_msg_mv(struct hptiop_hba *hba, u32 msg)
278+{
279+ writel(msg, &hba->u.mv.mu->inbound_msg);
280+ writel(MVIOP_MU_INBOUND_INT_MSG, &hba->u.mv.regs->inbound_doorbell);
281+ readl(&hba->u.mv.regs->inbound_doorbell);
282+}
167283
168− writel(msg, &hba->iop->inbound_msgaddr0);
284+static int iop_send_sync_msg(struct hptiop_hba *hba, u32 msg, u32 millisec)
285+{
286+ u32 i;
169287
170− hptiop_pci_posting_flush(hba->iop);
288+ hba->msg_done = 0;
289+ hba->ops->post_msg(hba, msg);
171290
172291 for (i = 0; i < millisec; i++) {
173292 spin_lock_irq(hba->host->host_lock);
174− __iop_intr(hba);
293+ hba->ops->iop_intr(hba);
175294 spin_unlock_irq(hba->host->host_lock);
176295 if (hba->msg_done)
177296 break;
@@ -181,46 +300,67 @@ static int iop_send_sync_msg(struct hptiop_hba *hba, u32 msg, u32 millisec) · 3 unmodified lines
181300 return hba->msg_done? 0 : -1;
182301 }
183302
184−static int iop_get_config(struct hptiop_hba *hba,
303+static int iop_get_config_itl(struct hptiop_hba *hba,
185304 struct hpt_iop_request_get_config *config)
186305 {
187306 u32 req32;
188307 struct hpt_iop_request_get_config __iomem *req;
189308
190− req32 = readl(&hba->iop->inbound_queue);
309+ req32 = readl(&hba->u.itl.iop->inbound_queue);
191310 if (req32 == IOPMU_QUEUE_EMPTY)
192311 return -1;
193312
194313 req = (struct hpt_iop_request_get_config __iomem *)
195− ((unsigned long)hba->iop + req32);
314+ ((unsigned long)hba->u.itl.iop + req32);
196315
197316 writel(0, &req->header.flags);
198317 writel(IOP_REQUEST_TYPE_GET_CONFIG, &req->header.type);
199318 writel(sizeof(struct hpt_iop_request_get_config), &req->header.size);
200319 writel(IOP_RESULT_PENDING, &req->header.result);
201320
202− if (iop_send_sync_request(hba, req, 20000)) {
321+ if (iop_send_sync_request_itl(hba, req, 20000)) {
203322 dprintk("Get config send cmd failed\n");
204323 return -1;
205324 }
206325
207326 memcpy_fromio(config, req, sizeof(*config));
208− writel(req32, &hba->iop->outbound_queue);
327+ writel(req32, &hba->u.itl.iop->outbound_queue);
328+ return 0;
329+}
330+
331+static int iop_get_config_mv(struct hptiop_hba *hba,
332+ struct hpt_iop_request_get_config *config)
333+{
334+ struct hpt_iop_request_get_config *req = hba->u.mv.internal_req;
335+
336+ req->header.flags = cpu_to_le32(IOP_REQUEST_FLAG_OUTPUT_CONTEXT);
337+ req->header.type = cpu_to_le32(IOP_REQUEST_TYPE_GET_CONFIG);
338+ req->header.size =
339+ cpu_to_le32(sizeof(struct hpt_iop_request_get_config));
340+ req->header.result = cpu_to_le32(IOP_RESULT_PENDING);
341+ req->header.context = cpu_to_le64(IOP_REQUEST_TYPE_GET_CONFIG<<5);
342+
343+ if (iop_send_sync_request_mv(hba, 0, 20000)) {
344+ dprintk("Get config send cmd failed\n");
345+ return -1;
346+ }
347+
348+ memcpy(config, req, sizeof(struct hpt_iop_request_get_config));
209349 return 0;
210350 }
211351
212−static int iop_set_config(struct hptiop_hba *hba,
352+static int iop_set_config_itl(struct hptiop_hba *hba,
213353 struct hpt_iop_request_set_config *config)
214354 {
215355 u32 req32;
216356 struct hpt_iop_request_set_config __iomem *req;
217357
218− req32 = readl(&hba->iop->inbound_queue);
358+ req32 = readl(&hba->u.itl.iop->inbound_queue);
219359 if (req32 == IOPMU_QUEUE_EMPTY)
220360 return -1;
221361
222362 req = (struct hpt_iop_request_set_config __iomem *)
223− ((unsigned long)hba->iop + req32);
363+ ((unsigned long)hba->u.itl.iop + req32);
224364
225365 memcpy_toio((u8 __iomem *)req + sizeof(struct hpt_iop_request_header),
226366 (u8 *)config + sizeof(struct hpt_iop_request_header),
@@ -232,22 +372,52 @@ static int iop_set_config(struct hptiop_hba *hba, · 5 unmodified lines
232372 writel(sizeof(struct hpt_iop_request_set_config), &req->header.size);
233373 writel(IOP_RESULT_PENDING, &req->header.result);
234374
235− if (iop_send_sync_request(hba, req, 20000)) {
375+ if (iop_send_sync_request_itl(hba, req, 20000)) {
236376 dprintk("Set config send cmd failed\n");
237377 return -1;
238378 }
239379
240− writel(req32, &hba->iop->outbound_queue);
380+ writel(req32, &hba->u.itl.iop->outbound_queue);
241381 return 0;
242382 }
243383
244−static int hptiop_initialize_iop(struct hptiop_hba *hba)
384+static int iop_set_config_mv(struct hptiop_hba *hba,
385+ struct hpt_iop_request_set_config *config)
245386 {
246− struct hpt_iopmu __iomem *iop = hba->iop;
387+ struct hpt_iop_request_set_config *req = hba->u.mv.internal_req;
247388
248− /* enable interrupts */
389+ memcpy(req, config, sizeof(struct hpt_iop_request_set_config));
390+ req->header.flags = cpu_to_le32(IOP_REQUEST_FLAG_OUTPUT_CONTEXT);
391+ req->header.type = cpu_to_le32(IOP_REQUEST_TYPE_SET_CONFIG);
392+ req->header.size =
393+ cpu_to_le32(sizeof(struct hpt_iop_request_set_config));
394+ req->header.result = cpu_to_le32(IOP_RESULT_PENDING);
395+ req->header.context = cpu_to_le64(IOP_REQUEST_TYPE_SET_CONFIG<<5);
396+
397+ if (iop_send_sync_request_mv(hba, 0, 20000)) {
398+ dprintk("Set config send cmd failed\n");
399+ return -1;
400+ }
401+
402+ return 0;
403+}
404+
405+static void hptiop_enable_intr_itl(struct hptiop_hba *hba)
406+{
249407 writel(~(IOPMU_OUTBOUND_INT_POSTQUEUE | IOPMU_OUTBOUND_INT_MSG0),
250− &iop->outbound_intmask);
408+ &hba->u.itl.iop->outbound_intmask);
409+}
410+
411+static void hptiop_enable_intr_mv(struct hptiop_hba *hba)
412+{
413+ writel(MVIOP_MU_OUTBOUND_INT_POSTQUEUE | MVIOP_MU_OUTBOUND_INT_MSG,
414+ &hba->u.mv.regs->outbound_intmask);
415+}
416+
417+static int hptiop_initialize_iop(struct hptiop_hba *hba)
418+{
419+ /* enable interrupts */
420+ hba->ops->enable_intr(hba);
251421
252422 hba->initialized = 1;
253423
@@ -261,37 +431,74 @@ static int hptiop_initialize_iop(struct hptiop_hba *hba) · 7 unmodified lines
261431 return 0;
262432 }
263433
264−static int hptiop_map_pci_bar(struct hptiop_hba *hba)
434+static void __iomem *hptiop_map_pci_bar(struct hptiop_hba *hba, int index)
265435 {
266436 u32 mem_base_phy, length;
267437 void __iomem *mem_base_virt;
438+
268439 struct pci_dev *pcidev = hba->pcidev;
269440
270− if (!(pci_resource_flags(pcidev, 0) & IORESOURCE_MEM)) {
441+
442+ if (!(pci_resource_flags(pcidev, index) & IORESOURCE_MEM)) {
271443 printk(KERN_ERR "scsi%d: pci resource invalid\n",
272444 hba->host->host_no);
273− return -1;
445+ return 0;
274446 }
275447
276− mem_base_phy = pci_resource_start(pcidev, 0);
277− length = pci_resource_len(pcidev, 0);
448+ mem_base_phy = pci_resource_start(pcidev, index);
449+ length = pci_resource_len(pcidev, index);
278450 mem_base_virt = ioremap(mem_base_phy, length);
279451
280452 if (!mem_base_virt) {
281453 printk(KERN_ERR "scsi%d: Fail to ioremap memory space\n",
282454 hba->host->host_no);
455+ return 0;
456+ }
457+ return mem_base_virt;
458+}
459+
460+static int hptiop_map_pci_bar_itl(struct hptiop_hba *hba)
461+{
462+ hba->u.itl.iop = hptiop_map_pci_bar(hba, 0);
463+ if (hba->u.itl.iop)
464+ return 0;
465+ else
466+ return -1;
467+}
468+
469+static void hptiop_unmap_pci_bar_itl(struct hptiop_hba *hba)
470+{
471+ iounmap(hba->u.itl.iop);
472+}
473+
474+static int hptiop_map_pci_bar_mv(struct hptiop_hba *hba)
475+{
476+ hba->u.mv.regs = hptiop_map_pci_bar(hba, 0);
477+ if (hba->u.mv.regs == 0)
478+ return -1;
479+
480+ hba->u.mv.mu = hptiop_map_pci_bar(hba, 2);
481+ if (hba->u.mv.mu == 0) {
482+ iounmap(hba->u.mv.regs);
283483 return -1;
284484 }
285485
286− hba->iop = mem_base_virt;
287− dprintk("hptiop_map_pci_bar: iop=%p\n", hba->iop);
288486 return 0;
289487 }
290488
489+static void hptiop_unmap_pci_bar_mv(struct hptiop_hba *hba)
490+{
491+ iounmap(hba->u.mv.regs);
492+ iounmap(hba->u.mv.mu);
493+}
494+
291495 static void hptiop_message_callback(struct hptiop_hba *hba, u32 msg)
292496 {
293497 dprintk("iop message 0x%x\n", msg);
294498
499+ if (msg == IOPMU_INBOUND_MSG0_NOP)
500+ hba->msg_done = 1;
501+
295502 if (!hba->initialized)
296503 return;
297504
@@ -303,7 +510,7 @@ static void hptiop_message_callback(struct hptiop_hba *hba, u32 msg) · 5 unmodified lines
303510 hba->msg_done = 1;
304511 }
305512
306−static inline struct hptiop_request *get_req(struct hptiop_hba *hba)
513+static struct hptiop_request *get_req(struct hptiop_hba *hba)
307514 {
308515 struct hptiop_request *ret;
309516
@@ -316,30 +523,19 @@ static inline struct hptiop_request *get_req(struct hptiop_hba *hba) · 6 unmodified lines
316523 return ret;
317524 }
318525
319−static inline void free_req(struct hptiop_hba *hba, struct hptiop_request *req)
526+static void free_req(struct hptiop_hba *hba, struct hptiop_request *req)
320527 {
321528 dprintk("free_req(%d, %p)\n", req->index, req);
322529 req->next = hba->req_list;
323530 hba->req_list = req;
324531 }
325532
326−static void hptiop_host_request_callback(struct hptiop_hba *hba, u32 _tag)
533+static void hptiop_finish_scsi_req(struct hptiop_hba *hba, u32 tag,
534+ struct hpt_iop_request_scsi_command *req)
327535 {
328− struct hpt_iop_request_scsi_command *req;
329536 struct scsi_cmnd *scp;
330− u32 tag;
331−
332− if (hba->iopintf_v2) {
333− tag = _tag & ~ IOPMU_QUEUE_REQUEST_RESULT_BIT;
334− req = hba->reqs[tag].req_virt;
335− if (likely(_tag & IOPMU_QUEUE_REQUEST_RESULT_BIT))
336− req->header.result = IOP_RESULT_SUCCESS;
337− } else {
338− tag = _tag;
339− req = hba->reqs[tag].req_virt;
340− }
341537
342− dprintk("hptiop_host_request_callback: req=%p, type=%d, "
538+ dprintk("hptiop_finish_scsi_req: req=%p, type=%d, "
343539 "result=%d, context=0x%x tag=%d\n",
344540 req, req->header.type, req->header.result,
345541 req->header.context, tag);
@@ -354,6 +550,8 @@ static void hptiop_host_request_callback(struct hptiop_hba *hba, u32 _tag) · 8 unmodified lines
354550
355551 switch (le32_to_cpu(req->header.result)) {
356552 case IOP_RESULT_SUCCESS:
553+ scsi_set_resid(scp,
554+ scsi_bufflen(scp) - le32_to_cpu(req->dataxfer_length));
357555 scp->result = (DID_OK<<16);
358556 break;
359557 case IOP_RESULT_BAD_TARGET:
@@ -371,12 +569,12 @@ static void hptiop_host_request_callback(struct hptiop_hba *hba, u32 _tag) · 11 unmodified lines
371569 case IOP_RESULT_INVALID_REQUEST:
372570 scp->result = (DID_ABORT<<16);
373571 break;
374− case IOP_RESULT_MODE_SENSE_CHECK_CONDITION:
572+ case IOP_RESULT_CHECK_CONDITION:
573+ scsi_set_resid(scp,
574+ scsi_bufflen(scp) - le32_to_cpu(req->dataxfer_length));
375575 scp->result = SAM_STAT_CHECK_CONDITION;
376− memset(&scp->sense_buffer,
377− 0, sizeof(scp->sense_buffer));
378576 memcpy(&scp->sense_buffer, &req->sg_list,
379− min(sizeof(scp->sense_buffer),
577+ min_t(size_t, SCSI_SENSE_BUFFERSIZE,
380578 le32_to_cpu(req->dataxfer_length)));
381579 break;
382580
@@ -391,15 +589,33 @@ static void hptiop_host_request_callback(struct hptiop_hba *hba, u32 _tag) · 8 unmodified lines
391589 free_req(hba, &hba->reqs[tag]);
392590 }
393591
394−void hptiop_iop_request_callback(struct hptiop_hba *hba, u32 tag)
592+static void hptiop_host_request_callback_itl(struct hptiop_hba *hba, u32 _tag)
593+{
594+ struct hpt_iop_request_scsi_command *req;
595+ u32 tag;
596+
597+ if (hba->iopintf_v2) {
598+ tag = _tag & ~IOPMU_QUEUE_REQUEST_RESULT_BIT;
599+ req = hba->reqs[tag].req_virt;
600+ if (likely(_tag & IOPMU_QUEUE_REQUEST_RESULT_BIT))
601+ req->header.result = cpu_to_le32(IOP_RESULT_SUCCESS);
602+ } else {
603+ tag = _tag;
604+ req = hba->reqs[tag].req_virt;
605+ }
606+
607+ hptiop_finish_scsi_req(hba, tag, req);
608+}
609+
610+void hptiop_iop_request_callback_itl(struct hptiop_hba *hba, u32 tag)
395611 {
396612 struct hpt_iop_request_header __iomem *req;
397613 struct hpt_iop_request_ioctl_command __iomem *p;
398614 struct hpt_ioctl_k *arg;
399615
400616 req = (struct hpt_iop_request_header __iomem *)
401− ((unsigned long)hba->iop + tag);
402− dprintk("hptiop_iop_request_callback: req=%p, type=%d, "
617+ ((unsigned long)hba->u.itl.iop + tag);
618+ dprintk("hptiop_iop_request_callback_itl: req=%p, type=%d, "
403619 "result=%d, context=0x%x tag=%d\n",
404620 req, readl(&req->type), readl(&req->result),
405621 readl(&req->context), tag);
@@ -427,7 +643,7 @@ void hptiop_iop_request_callback(struct hptiop_hba *hba, u32 tag) · 21 unmodified lines
427643 arg->result = HPT_IOCTL_RESULT_FAILED;
428644
429645 arg->done(arg);
430− writel(tag, &hba->iop->outbound_queue);
646+ writel(tag, &hba->u.itl.iop->outbound_queue);
431647 }
432648
433649 static irqreturn_t hptiop_intr(int irq, void *dev_id)
@@ -437,7 +653,7 @@ static irqreturn_t hptiop_intr(int irq, void *dev_id) · 3 unmodified lines
437653 unsigned long flags;
438654
439655 spin_lock_irqsave(hba->host->host_lock, flags);
440− handled = __iop_intr(hba);
656+ handled = hba->ops->iop_intr(hba);
441657 spin_unlock_irqrestore(hba->host->host_lock, flags);
442658
443659 return handled;
@@ -469,6 +685,57 @@ static int hptiop_buildsgl(struct scsi_cmnd *scp, struct hpt_iopsg *psg) · 25 unmodified lines
469685 return HPT_SCP(scp)->sgcnt;
470686 }
471687
688+static void hptiop_post_req_itl(struct hptiop_hba *hba,
689+ struct hptiop_request *_req)
690+{
691+ struct hpt_iop_request_header *reqhdr = _req->req_virt;
692+
693+ reqhdr->context = cpu_to_le32(IOPMU_QUEUE_ADDR_HOST_BIT |
694+ (u32)_req->index);
695+ reqhdr->context_hi32 = 0;
696+
697+ if (hba->iopintf_v2) {
698+ u32 size, size_bits;
699+
700+ size = le32_to_cpu(reqhdr->size);
701+ if (size < 256)
702+ size_bits = IOPMU_QUEUE_REQUEST_SIZE_BIT;
703+ else if (size < 512)
704+ size_bits = IOPMU_QUEUE_ADDR_HOST_BIT;
705+ else
706+ size_bits = IOPMU_QUEUE_REQUEST_SIZE_BIT |
707+ IOPMU_QUEUE_ADDR_HOST_BIT;
708+ writel(_req->req_shifted_phy | size_bits,
709+ &hba->u.itl.iop->inbound_queue);
710+ } else
711+ writel(_req->req_shifted_phy | IOPMU_QUEUE_ADDR_HOST_BIT,
712+ &hba->u.itl.iop->inbound_queue);
713+}
714+
715+static void hptiop_post_req_mv(struct hptiop_hba *hba,
716+ struct hptiop_request *_req)
717+{
718+ struct hpt_iop_request_header *reqhdr = _req->req_virt;
719+ u32 size, size_bit;
720+
721+ reqhdr->context = cpu_to_le32(_req->index<<8 |
722+ IOP_REQUEST_TYPE_SCSI_COMMAND<<5);
723+ reqhdr->context_hi32 = 0;
724+ size = le32_to_cpu(reqhdr->size);
725+
726+ if (size <= 256)
727+ size_bit = 0;
728+ else if (size <= 256*2)
729+ size_bit = 1;
730+ else if (size <= 256*3)
731+ size_bit = 2;
732+ else
733+ size_bit = 3;
734+
735+ mv_inbound_write((_req->req_shifted_phy << 5) |
736+ MVIOP_MU_QUEUE_ADDR_HOST_BIT | size_bit, hba);
737+}
738+
472739 static int hptiop_queuecommand(struct scsi_cmnd *scp,
473740 void (*done)(struct scsi_cmnd *))
474741 {
@@ -518,9 +785,6 @@ static int hptiop_queuecommand(struct scsi_cmnd *scp, · 43 unmodified lines
518785 req->header.flags = cpu_to_le32(IOP_REQUEST_FLAG_OUTPUT_CONTEXT);
519786 req->header.type = cpu_to_le32(IOP_REQUEST_TYPE_SCSI_COMMAND);
520787 req->header.result = cpu_to_le32(IOP_RESULT_PENDING);
521− req->header.context = cpu_to_le32(IOPMU_QUEUE_ADDR_HOST_BIT |
522− (u32)_req->index);
523− req->header.context_hi32 = 0;
524788 req->dataxfer_length = cpu_to_le32(scsi_bufflen(scp));
525789 req->channel = scp->device->channel;
526790 req->target = scp->device->id;
@@ -531,21 +795,7 @@ static int hptiop_queuecommand(struct scsi_cmnd *scp, · 4 unmodified lines
531795 + sg_count * sizeof(struct hpt_iopsg));
532796
533797 memcpy(req->cdb, scp->cmnd, sizeof(req->cdb));
534−
535− if (hba->iopintf_v2) {
536− u32 size_bits;
537− if (req->header.size < 256)
538− size_bits = IOPMU_QUEUE_REQUEST_SIZE_BIT;
539− else if (req->header.size < 512)
540− size_bits = IOPMU_QUEUE_ADDR_HOST_BIT;
541− else
542− size_bits = IOPMU_QUEUE_REQUEST_SIZE_BIT |
543− IOPMU_QUEUE_ADDR_HOST_BIT;
544− writel(_req->req_shifted_phy | size_bits, &hba->iop->inbound_queue);
545− } else
546− writel(_req->req_shifted_phy | IOPMU_QUEUE_ADDR_HOST_BIT,
547− &hba->iop->inbound_queue);
548−
798+ hba->ops->post_req(hba, _req);
549799 return 0;
550800
551801 cmd_done:
@@ -563,9 +813,7 @@ static int hptiop_reset_hba(struct hptiop_hba *hba) · 11 unmodified lines
563813 {
564814 if (atomic_xchg(&hba->resetting, 1) == 0) {
565815 atomic_inc(&hba->reset_count);
566− writel(IOPMU_INBOUND_MSG0_RESET,
567− &hba->iop->inbound_msgaddr0);
568− hptiop_pci_posting_flush(hba->iop);
816+ hba->ops->post_msg(hba, IOPMU_INBOUND_MSG0_RESET);
569817 }
570818
571819 wait_event_timeout(hba->reset_wq,
@@ -601,8 +849,10 @@ static int hptiop_reset(struct scsi_cmnd *scp) · 29 unmodified lines
601849 static int hptiop_adjust_disk_queue_depth(struct scsi_device *sdev,
602850 int queue_depth)
603851 {
604− if(queue_depth > 256)
605− queue_depth = 256;
852+ struct hptiop_hba *hba = (struct hptiop_hba *)sdev->host->hostdata;
853+
854+ if (queue_depth > hba->max_requests)
855+ queue_depth = hba->max_requests;
606856 scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG, queue_depth);
607857 return queue_depth;
608858 }
@@ -663,6 +913,26 @@ static struct scsi_host_template driver_template = { · 54 unmodified lines
663913 .change_queue_depth = hptiop_adjust_disk_queue_depth,
664914 };
665915
916+static int hptiop_internal_memalloc_mv(struct hptiop_hba *hba)
917+{
918+ hba->u.mv.internal_req = dma_alloc_coherent(&hba->pcidev->dev,
919+ 0x800, &hba->u.mv.internal_req_phy, GFP_KERNEL);
920+ if (hba->u.mv.internal_req)
921+ return 0;
922+ else
923+ return -1;
924+}
925+
926+static int hptiop_internal_memfree_mv(struct hptiop_hba *hba)
927+{
928+ if (hba->u.mv.internal_req) {
929+ dma_free_coherent(&hba->pcidev->dev, 0x800,
930+ hba->u.mv.internal_req, hba->u.mv.internal_req_phy);
931+ return 0;
932+ } else
933+ return -1;
934+}
935+
666936 static int __devinit hptiop_probe(struct pci_dev *pcidev,
667937 const struct pci_device_id *id)
668938 {
@@ -708,6 +978,7 @@ static int __devinit hptiop_probe(struct pci_dev *pcidev, · 39 unmodified lines
708978
709979 hba = (struct hptiop_hba *)host->hostdata;
710980
981+ hba->ops = (struct hptiop_adapter_ops *)id->driver_data;
711982 hba->pcidev = pcidev;
712983 hba->host = host;
713984 hba->initialized = 0;
@@ -725,16 +996,24 @@ static int __devinit hptiop_probe(struct pci_dev *pcidev, · 11 unmodified lines
725996 host->n_io_port = 0;
726997 host->irq = pcidev->irq;
727998
728− if (hptiop_map_pci_bar(hba))
999+ if (hba->ops->map_pci_bar(hba))
7291000 goto free_scsi_host;
7301001
731− if (iop_wait_ready(hba->iop, 20000)) {
1002+ if (hba->ops->iop_wait_ready(hba, 20000)) {
7321003 printk(KERN_ERR "scsi%d: firmware not ready\n",
7331004 hba->host->host_no);
7341005 goto unmap_pci_bar;
7351006 }
7361007
737− if (iop_get_config(hba, &iop_config)) {
1008+ if (hba->ops->internal_memalloc) {
1009+ if (hba->ops->internal_memalloc(hba)) {
1010+ printk(KERN_ERR "scsi%d: internal_memalloc failed\n",
1011+ hba->host->host_no);
1012+ goto unmap_pci_bar;
1013+ }
1014+ }
1015+
1016+ if (hba->ops->get_config(hba, &iop_config)) {
7381017 printk(KERN_ERR "scsi%d: get config failed\n",
7391018 hba->host->host_no);
7401019 goto unmap_pci_bar;
@@ -770,7 +1049,7 @@ static int __devinit hptiop_probe(struct pci_dev *pcidev, · 29 unmodified lines
7701049 set_config.vbus_id = cpu_to_le16(host->host_no);
7711050 set_config.max_host_request_size = cpu_to_le16(req_size);
7721051
773− if (iop_set_config(hba, &set_config)) {
1052+ if (hba->ops->set_config(hba, &set_config)) {
7741053 printk(KERN_ERR "scsi%d: set config failed\n",
7751054 hba->host->host_no);
7761055 goto unmap_pci_bar;
@@ -839,21 +1118,24 @@ static int __devinit hptiop_probe(struct pci_dev *pcidev, · 62 unmodified lines
8391118
8401119 free_request_mem:
8411120 dma_free_coherent(&hba->pcidev->dev,
842− hba->req_size*hba->max_requests + 0x20,
1121+ hba->req_size * hba->max_requests + 0x20,
8431122 hba->dma_coherent, hba->dma_coherent_handle);
8441123
8451124 free_request_irq:
8461125 free_irq(hba->pcidev->irq, hba);
8471126
8481127 unmap_pci_bar:
849− iounmap(hba->iop);
1128+ if (hba->ops->internal_memfree)
1129+ hba->ops->internal_memfree(hba);
8501130
851−free_pci_regions:
852− pci_release_regions(pcidev) ;
1131+ hba->ops->unmap_pci_bar(hba);
8531132
8541133 free_scsi_host:
8551134 scsi_host_put(host);
8561135
1136+free_pci_regions:
1137+ pci_release_regions(pcidev);
1138+
8571139 disable_pci_device:
8581140 pci_disable_device(pcidev);
8591141
@@ -865,8 +1147,6 @@ static void hptiop_shutdown(struct pci_dev *pcidev) · 5 unmodified lines
8651147 {
8661148 struct Scsi_Host *host = pci_get_drvdata(pcidev);
8671149 struct hptiop_hba *hba = (struct hptiop_hba *)host->hostdata;
868− struct hpt_iopmu __iomem *iop = hba->iop;
869− u32 int_mask;
8701150
8711151 dprintk("hptiop_shutdown(%p)\n", hba);
8721152
@@ -876,11 +1156,24 @@ static void hptiop_shutdown(struct pci_dev *pcidev) · 3 unmodified lines
8761156 hba->host->host_no);
8771157
8781158 /* disable all outbound interrupts */
879− int_mask = readl(&iop->outbound_intmask);
1159+ hba->ops->disable_intr(hba);
1160+}
1161+
1162+static void hptiop_disable_intr_itl(struct hptiop_hba *hba)
1163+{
1164+ u32 int_mask;
1165+
1166+ int_mask = readl(&hba->u.itl.iop->outbound_intmask);
8801167 writel(int_mask |
8811168 IOPMU_OUTBOUND_INT_MSG0 | IOPMU_OUTBOUND_INT_POSTQUEUE,
882− &iop->outbound_intmask);
883− hptiop_pci_posting_flush(iop);
1169+ &hba->u.itl.iop->outbound_intmask);
1170+ readl(&hba->u.itl.iop->outbound_intmask);
1171+}
1172+
1173+static void hptiop_disable_intr_mv(struct hptiop_hba *hba)
1174+{
1175+ writel(0, &hba->u.mv.regs->outbound_intmask);
1176+ readl(&hba->u.mv.regs->outbound_intmask);
8841177 }
8851178
8861179 static void hptiop_remove(struct pci_dev *pcidev)
@@ -901,7 +1194,10 @@ static void hptiop_remove(struct pci_dev *pcidev) · 14 unmodified lines
9011194 hba->dma_coherent,
9021195 hba->dma_coherent_handle);
9031196
904− iounmap(hba->iop);
1197+ if (hba->ops->internal_memfree)
1198+ hba->ops->internal_memfree(hba);
1199+
1200+ hba->ops->unmap_pci_bar(hba);
9051201
9061202 pci_release_regions(hba->pcidev);
9071203 pci_set_drvdata(hba->pcidev, NULL);
@@ -910,11 +1206,50 @@ static void hptiop_remove(struct pci_dev *pcidev) · 2 unmodified lines
9101206 scsi_host_put(host);
9111207 }
9121208
1209+static struct hptiop_adapter_ops hptiop_itl_ops = {
1210+ .iop_wait_ready = iop_wait_ready_itl,
1211+ .internal_memalloc = 0,
1212+ .internal_memfree = 0,
1213+ .map_pci_bar = hptiop_map_pci_bar_itl,
1214+ .unmap_pci_bar = hptiop_unmap_pci_bar_itl,
1215+ .enable_intr = hptiop_enable_intr_itl,
1216+ .disable_intr = hptiop_disable_intr_itl,
1217+ .get_config = iop_get_config_itl,
1218+ .set_config = iop_set_config_itl,
1219+ .iop_intr = iop_intr_itl,
1220+ .post_msg = hptiop_post_msg_itl,
1221+ .post_req = hptiop_post_req_itl,
1222+};
1223+
1224+static struct hptiop_adapter_ops hptiop_mv_ops = {
1225+ .iop_wait_ready = iop_wait_ready_mv,
1226+ .internal_memalloc = hptiop_internal_memalloc_mv,
1227+ .internal_memfree = hptiop_internal_memfree_mv,
1228+ .map_pci_bar = hptiop_map_pci_bar_mv,
1229+ .unmap_pci_bar = hptiop_unmap_pci_bar_mv,
1230+ .enable_intr = hptiop_enable_intr_mv,
1231+ .disable_intr = hptiop_disable_intr_mv,
1232+ .get_config = iop_get_config_mv,
1233+ .set_config = iop_set_config_mv,
1234+ .iop_intr = iop_intr_mv,
1235+ .post_msg = hptiop_post_msg_mv,
1236+ .post_req = hptiop_post_req_mv,
1237+};
1238+
9131239 static struct pci_device_id hptiop_id_table[] = {
914− { PCI_VDEVICE(TTI, 0x3220) },
915− { PCI_VDEVICE(TTI, 0x3320) },
916− { PCI_VDEVICE(TTI, 0x3520) },
917− { PCI_VDEVICE(TTI, 0x4320) },
1240+ { PCI_VDEVICE(TTI, 0x3220), (kernel_ulong_t)&hptiop_itl_ops },
1241+ { PCI_VDEVICE(TTI, 0x3320), (kernel_ulong_t)&hptiop_itl_ops },
1242+ { PCI_VDEVICE(TTI, 0x3520), (kernel_ulong_t)&hptiop_itl_ops },
1243+ { PCI_VDEVICE(TTI, 0x4320), (kernel_ulong_t)&hptiop_itl_ops },
1244+ { PCI_VDEVICE(TTI, 0x3510), (kernel_ulong_t)&hptiop_itl_ops },
1245+ { PCI_VDEVICE(TTI, 0x3511), (kernel_ulong_t)&hptiop_itl_ops },
1246+ { PCI_VDEVICE(TTI, 0x3521), (kernel_ulong_t)&hptiop_itl_ops },
1247+ { PCI_VDEVICE(TTI, 0x3522), (kernel_ulong_t)&hptiop_itl_ops },
1248+ { PCI_VDEVICE(TTI, 0x3410), (kernel_ulong_t)&hptiop_itl_ops },
1249+ { PCI_VDEVICE(TTI, 0x3540), (kernel_ulong_t)&hptiop_itl_ops },
1250+ { PCI_VDEVICE(TTI, 0x3120), (kernel_ulong_t)&hptiop_mv_ops },
1251+ { PCI_VDEVICE(TTI, 0x3122), (kernel_ulong_t)&hptiop_mv_ops },
1252+ { PCI_VDEVICE(TTI, 0x3020), (kernel_ulong_t)&hptiop_mv_ops },
9181253 {},
9191254 };
9201255
drivers/scsi/hptiop.h+89−35
@@ -1,5 +1,5 @@
11 /*
2− * HighPoint RR3xxx controller driver for Linux
2+ * HighPoint RR3xxx/4xxx controller driver for Linux
33 * Copyright (C) 2006-2007 HighPoint Technologies, Inc. All Rights Reserved.
44 *
55 * This program is free software; you can redistribute it and/or modify
@@ -18,8 +18,7 @@ · 12 unmodified lines
1818 #ifndef _HPTIOP_H_
1919 #define _HPTIOP_H_
2020
21−struct hpt_iopmu
22−{
21+struct hpt_iopmu_itl {
2322 __le32 resrved0[4];
2423 __le32 inbound_msgaddr0;
2524 __le32 inbound_msgaddr1;
@@ -54,6 +53,40 @@ struct hpt_iopmu · 28 unmodified lines
5453 #define IOPMU_INBOUND_INT_ERROR 8
5554 #define IOPMU_INBOUND_INT_POSTQUEUE 0x10
5655
56+#define MVIOP_QUEUE_LEN 512
57+
58+struct hpt_iopmu_mv {
59+ __le32 inbound_head;
60+ __le32 inbound_tail;
61+ __le32 outbound_head;
62+ __le32 outbound_tail;
63+ __le32 inbound_msg;
64+ __le32 outbound_msg;
65+ __le32 reserve[10];
66+ __le64 inbound_q[MVIOP_QUEUE_LEN];
67+ __le64 outbound_q[MVIOP_QUEUE_LEN];
68+};
69+
70+struct hpt_iopmv_regs {
71+ __le32 reserved[0x20400 / 4];
72+ __le32 inbound_doorbell;
73+ __le32 inbound_intmask;
74+ __le32 outbound_doorbell;
75+ __le32 outbound_intmask;
76+};
77+
78+#define MVIOP_MU_QUEUE_ADDR_HOST_MASK (~(0x1full))
79+#define MVIOP_MU_QUEUE_ADDR_HOST_BIT 4
80+
81+#define MVIOP_MU_QUEUE_ADDR_IOP_HIGH32 0xffffffff
82+#define MVIOP_MU_QUEUE_REQUEST_RESULT_BIT 1
83+#define MVIOP_MU_QUEUE_REQUEST_RETURN_CONTEXT 2
84+
85+#define MVIOP_MU_INBOUND_INT_MSG 1
86+#define MVIOP_MU_INBOUND_INT_POSTQUEUE 2
87+#define MVIOP_MU_OUTBOUND_INT_MSG 1
88+#define MVIOP_MU_OUTBOUND_INT_POSTQUEUE 2
89+
5790 enum hpt_iopmu_message {
5891 /* host-to-iop messages */
5992 IOPMU_INBOUND_MSG0_NOP = 0,
@@ -72,8 +105,7 @@ enum hpt_iopmu_message { · 12 unmodified lines
72105 IOPMU_OUTBOUND_MSG0_REVALIDATE_DEVICE_MAX = 0x3ff,
73106 };
74107
75−struct hpt_iop_request_header
76−{
108+struct hpt_iop_request_header {
77109 __le32 size;
78110 __le32 type;
79111 __le32 flags;
@@ -104,11 +136,10 @@ enum hpt_iop_result_type { · 24 unmodified lines
104136 IOP_RESULT_RESET,
105137 IOP_RESULT_INVALID_REQUEST,
106138 IOP_RESULT_BAD_TARGET,
107− IOP_RESULT_MODE_SENSE_CHECK_CONDITION,
139+ IOP_RESULT_CHECK_CONDITION,
108140 };
109141
110−struct hpt_iop_request_get_config
111−{
142+struct hpt_iop_request_get_config {
112143 struct hpt_iop_request_header header;
113144 __le32 interface_version;
114145 __le32 firmware_version;
@@ -121,8 +152,7 @@ struct hpt_iop_request_get_config · 6 unmodified lines
121152 __le32 sdram_size;
122153 };
123154
124−struct hpt_iop_request_set_config
125−{
155+struct hpt_iop_request_set_config {
126156 struct hpt_iop_request_header header;
127157 __le32 iop_id;
128158 __le16 vbus_id;
@@ -130,15 +160,13 @@ struct hpt_iop_request_set_config · 1 unmodified line
130160 __le32 reserve[6];
131161 };
132162
133−struct hpt_iopsg
134−{
163+struct hpt_iopsg {
135164 __le32 size;
136165 __le32 eot; /* non-zero: end of table */
137166 __le64 pci_address;
138167 };
139168
140−struct hpt_iop_request_block_command
141−{
169+struct hpt_iop_request_block_command {
142170 struct hpt_iop_request_header header;
143171 u8 channel;
144172 u8 target;
@@ -156,8 +184,7 @@ struct hpt_iop_request_block_command · 11 unmodified lines
156184 #define IOP_BLOCK_COMMAND_FLUSH 4
157185 #define IOP_BLOCK_COMMAND_SHUTDOWN 5
158186
159−struct hpt_iop_request_scsi_command
160−{
187+struct hpt_iop_request_scsi_command {
161188 struct hpt_iop_request_header header;
162189 u8 channel;
163190 u8 target;
@@ -168,8 +195,7 @@ struct hpt_iop_request_scsi_command · 4 unmodified lines
168195 struct hpt_iopsg sg_list[1];
169196 };
170197
171−struct hpt_iop_request_ioctl_command
172−{
198+struct hpt_iop_request_ioctl_command {
173199 struct hpt_iop_request_header header;
174200 __le32 ioctl_code;
175201 __le32 inbuf_size;
@@ -182,11 +208,11 @@ struct hpt_iop_request_ioctl_command · 6 unmodified lines
182208 #define HPTIOP_MAX_REQUESTS 256u
183209
184210 struct hptiop_request {
185− struct hptiop_request * next;
186− void * req_virt;
187− u32 req_shifted_phy;
188− struct scsi_cmnd * scp;
189− int index;
211+ struct hptiop_request *next;
212+ void *req_virt;
213+ u32 req_shifted_phy;
214+ struct scsi_cmnd *scp;
215+ int index;
190216 };
191217
192218 struct hpt_scsi_pointer {
@@ -198,9 +224,21 @@ struct hpt_scsi_pointer { · 5 unmodified lines
198224 #define HPT_SCP(scp) ((struct hpt_scsi_pointer *)&(scp)->SCp)
199225
200226 struct hptiop_hba {
201− struct hpt_iopmu __iomem * iop;
202− struct Scsi_Host * host;
203− struct pci_dev * pcidev;
227+ struct hptiop_adapter_ops *ops;
228+ union {
229+ struct {
230+ struct hpt_iopmu_itl __iomem *iop;
231+ } itl;
232+ struct {
233+ struct hpt_iopmv_regs *regs;
234+ struct hpt_iopmu_mv __iomem *mu;
235+ void *internal_req;
236+ dma_addr_t internal_req_phy;
237+ } mv;
238+ } u;
239+
240+ struct Scsi_Host *host;
241+ struct pci_dev *pcidev;
204242
205243 /* IOP config info */
206244 u32 interface_version;
@@ -213,15 +251,15 @@ struct hptiop_hba { · 6 unmodified lines
213251
214252 u32 req_size; /* host-allocated request buffer size */
215253
216− int iopintf_v2: 1;
217− int initialized: 1;
218− int msg_done: 1;
254+ u32 iopintf_v2: 1;
255+ u32 initialized: 1;
256+ u32 msg_done: 1;
219257
220258 struct hptiop_request * req_list;
221259 struct hptiop_request reqs[HPTIOP_MAX_REQUESTS];
222260
223261 /* used to free allocated dma area */
224− void * dma_coherent;
262+ void *dma_coherent;
225263 dma_addr_t dma_coherent_handle;
226264
227265 atomic_t reset_count;
@@ -231,19 +269,35 @@ struct hptiop_hba { · 3 unmodified lines
231269 wait_queue_head_t ioctl_wq;
232270 };
233271
234−struct hpt_ioctl_k
235−{
272+struct hpt_ioctl_k {
236273 struct hptiop_hba * hba;
237274 u32 ioctl_code;
238275 u32 inbuf_size;
239276 u32 outbuf_size;
240− void * inbuf;
241− void * outbuf;
242− u32 * bytes_returned;
277+ void *inbuf;
278+ void *outbuf;
279+ u32 *bytes_returned;
243280 void (*done)(struct hpt_ioctl_k *);
244281 int result; /* HPT_IOCTL_RESULT_ */
245282 };
246283
284+struct hptiop_adapter_ops {
285+ int (*iop_wait_ready)(struct hptiop_hba *hba, u32 millisec);
286+ int (*internal_memalloc)(struct hptiop_hba *hba);
287+ int (*internal_memfree)(struct hptiop_hba *hba);
288+ int (*map_pci_bar)(struct hptiop_hba *hba);
289+ void (*unmap_pci_bar)(struct hptiop_hba *hba);
290+ void (*enable_intr)(struct hptiop_hba *hba);
291+ void (*disable_intr)(struct hptiop_hba *hba);
292+ int (*get_config)(struct hptiop_hba *hba,
293+ struct hpt_iop_request_get_config *config);
294+ int (*set_config)(struct hptiop_hba *hba,
295+ struct hpt_iop_request_set_config *config);
296+ int (*iop_intr)(struct hptiop_hba *hba);
297+ void (*post_msg)(struct hptiop_hba *hba, u32 msg);
298+ void (*post_req)(struct hptiop_hba *hba, struct hptiop_request *_req);
299+};
300+
247301 #define HPT_IOCTL_RESULT_OK 0
248302 #define HPT_IOCTL_RESULT_FAILED (-1)
249303
drivers/scsi/ibmvscsi/ibmvscsi.c+99−56
@@ -629,6 +629,16 @@ static int ibmvscsi_send_srp_event(struct srp_event_struct *evt_struct, · 628 unmodified lines
629629 list_del(&evt_struct->list);
630630 del_timer(&evt_struct->timer);
631631
632+ /* If send_crq returns H_CLOSED, return SCSI_MLQUEUE_HOST_BUSY.
633+ * Firmware will send a CRQ with a transport event (0xFF) to
634+ * tell this client what has happened to the transport. This
635+ * will be handled in ibmvscsi_handle_crq()
636+ */
637+ if (rc == H_CLOSED) {
638+ dev_warn(hostdata->dev, "send warning. "
639+ "Receive queue closed, will retry.\n");
640+ goto send_busy;
641+ }
632642 dev_err(hostdata->dev, "send error %d\n", rc);
633643 atomic_inc(&hostdata->request_limit);
634644 goto send_error;
@@ -976,58 +986,74 @@ static int ibmvscsi_eh_abort_handler(struct scsi_cmnd *cmd) · 341 unmodified lines
976986 int rsp_rc;
977987 unsigned long flags;
978988 u16 lun = lun_from_dev(cmd->device);
989+ unsigned long wait_switch = 0;
979990
980991 /* First, find this command in our sent list so we can figure
981992 * out the correct tag
982993 */
983994 spin_lock_irqsave(hostdata->host->host_lock, flags);
984− found_evt = NULL;
985− list_for_each_entry(tmp_evt, &hostdata->sent, list) {
986− if (tmp_evt->cmnd == cmd) {
987− found_evt = tmp_evt;
988− break;
995+ wait_switch = jiffies + (init_timeout * HZ);
996+ do {
997+ found_evt = NULL;
998+ list_for_each_entry(tmp_evt, &hostdata->sent, list) {
999+ if (tmp_evt->cmnd == cmd) {
1000+ found_evt = tmp_evt;
1001+ break;
1002+ }
9891003 }
990− }
9911004
992− if (!found_evt) {
993− spin_unlock_irqrestore(hostdata->host->host_lock, flags);
994− return SUCCESS;
995− }
1005+ if (!found_evt) {
1006+ spin_unlock_irqrestore(hostdata->host->host_lock, flags);
1007+ return SUCCESS;
1008+ }
9961009
997− evt = get_event_struct(&hostdata->pool);
998− if (evt == NULL) {
999− spin_unlock_irqrestore(hostdata->host->host_lock, flags);
1000− sdev_printk(KERN_ERR, cmd->device, "failed to allocate abort event\n");
1001− return FAILED;
1002− }
1010+ evt = get_event_struct(&hostdata->pool);
1011+ if (evt == NULL) {
1012+ spin_unlock_irqrestore(hostdata->host->host_lock, flags);
1013+ sdev_printk(KERN_ERR, cmd->device,
1014+ "failed to allocate abort event\n");
1015+ return FAILED;
1016+ }
10031017
1004− init_event_struct(evt,
1005− sync_completion,
1006− VIOSRP_SRP_FORMAT,
1007− init_timeout);
1018+ init_event_struct(evt,
1019+ sync_completion,
1020+ VIOSRP_SRP_FORMAT,
1021+ init_timeout);
10081022
1009− tsk_mgmt = &evt->iu.srp.tsk_mgmt;
1023+ tsk_mgmt = &evt->iu.srp.tsk_mgmt;
10101024
1011− /* Set up an abort SRP command */
1012− memset(tsk_mgmt, 0x00, sizeof(*tsk_mgmt));
1013− tsk_mgmt->opcode = SRP_TSK_MGMT;
1014− tsk_mgmt->lun = ((u64) lun) << 48;
1015− tsk_mgmt->tsk_mgmt_func = SRP_TSK_ABORT_TASK;
1016− tsk_mgmt->task_tag = (u64) found_evt;
1017−
1018− sdev_printk(KERN_INFO, cmd->device, "aborting command. lun 0x%lx, tag 0x%lx\n",
1019− tsk_mgmt->lun, tsk_mgmt->task_tag);
1020−
1021− evt->sync_srp = &srp_rsp;
1022− init_completion(&evt->comp);
1023− rsp_rc = ibmvscsi_send_srp_event(evt, hostdata, init_timeout * 2);
1025+ /* Set up an abort SRP command */
1026+ memset(tsk_mgmt, 0x00, sizeof(*tsk_mgmt));
1027+ tsk_mgmt->opcode = SRP_TSK_MGMT;
1028+ tsk_mgmt->lun = ((u64) lun) << 48;
1029+ tsk_mgmt->tsk_mgmt_func = SRP_TSK_ABORT_TASK;
1030+ tsk_mgmt->task_tag = (u64) found_evt;
1031+
1032+ evt->sync_srp = &srp_rsp;
1033+
1034+ init_completion(&evt->comp);
1035+ rsp_rc = ibmvscsi_send_srp_event(evt, hostdata, init_timeout * 2);
1036+
1037+ if (rsp_rc != SCSI_MLQUEUE_HOST_BUSY)
1038+ break;
1039+
1040+ spin_unlock_irqrestore(hostdata->host->host_lock, flags);
1041+ msleep(10);
1042+ spin_lock_irqsave(hostdata->host->host_lock, flags);
1043+ } while (time_before(jiffies, wait_switch));
1044+
10241045 spin_unlock_irqrestore(hostdata->host->host_lock, flags);
1046+
10251047 if (rsp_rc != 0) {
10261048 sdev_printk(KERN_ERR, cmd->device,
10271049 "failed to send abort() event. rc=%d\n", rsp_rc);
10281050 return FAILED;
10291051 }
10301052
1053+ sdev_printk(KERN_INFO, cmd->device,
1054+ "aborting command. lun 0x%lx, tag 0x%lx\n",
1055+ (((u64) lun) << 48), (u64) found_evt);
1056+
10311057 wait_for_completion(&evt->comp);
10321058
10331059 /* make sure we got a good response */
@@ -1099,41 +1125,56 @@ static int ibmvscsi_eh_device_reset_handler(struct scsi_cmnd *cmd) · 65 unmodified lines
10991125 int rsp_rc;
11001126 unsigned long flags;
11011127 u16 lun = lun_from_dev(cmd->device);
1128+ unsigned long wait_switch = 0;
11021129
11031130 spin_lock_irqsave(hostdata->host->host_lock, flags);
1104− evt = get_event_struct(&hostdata->pool);
1105− if (evt == NULL) {
1106− spin_unlock_irqrestore(hostdata->host->host_lock, flags);
1107− sdev_printk(KERN_ERR, cmd->device, "failed to allocate reset event\n");
1108− return FAILED;
1109− }
1131+ wait_switch = jiffies + (init_timeout * HZ);
1132+ do {
1133+ evt = get_event_struct(&hostdata->pool);
1134+ if (evt == NULL) {
1135+ spin_unlock_irqrestore(hostdata->host->host_lock, flags);
1136+ sdev_printk(KERN_ERR, cmd->device,
1137+ "failed to allocate reset event\n");
1138+ return FAILED;
1139+ }
11101140
1111− init_event_struct(evt,
1112− sync_completion,
1113− VIOSRP_SRP_FORMAT,
1114− init_timeout);
1141+ init_event_struct(evt,
1142+ sync_completion,
1143+ VIOSRP_SRP_FORMAT,
1144+ init_timeout);
11151145
1116− tsk_mgmt = &evt->iu.srp.tsk_mgmt;
1146+ tsk_mgmt = &evt->iu.srp.tsk_mgmt;
11171147
1118− /* Set up a lun reset SRP command */
1119− memset(tsk_mgmt, 0x00, sizeof(*tsk_mgmt));
1120− tsk_mgmt->opcode = SRP_TSK_MGMT;
1121− tsk_mgmt->lun = ((u64) lun) << 48;
1122− tsk_mgmt->tsk_mgmt_func = SRP_TSK_LUN_RESET;
1148+ /* Set up a lun reset SRP command */
1149+ memset(tsk_mgmt, 0x00, sizeof(*tsk_mgmt));
1150+ tsk_mgmt->opcode = SRP_TSK_MGMT;
1151+ tsk_mgmt->lun = ((u64) lun) << 48;
1152+ tsk_mgmt->tsk_mgmt_func = SRP_TSK_LUN_RESET;
11231153
1124− sdev_printk(KERN_INFO, cmd->device, "resetting device. lun 0x%lx\n",
1125− tsk_mgmt->lun);
1154+ evt->sync_srp = &srp_rsp;
1155+
1156+ init_completion(&evt->comp);
1157+ rsp_rc = ibmvscsi_send_srp_event(evt, hostdata, init_timeout * 2);
1158+
1159+ if (rsp_rc != SCSI_MLQUEUE_HOST_BUSY)
1160+ break;
1161+
1162+ spin_unlock_irqrestore(hostdata->host->host_lock, flags);
1163+ msleep(10);
1164+ spin_lock_irqsave(hostdata->host->host_lock, flags);
1165+ } while (time_before(jiffies, wait_switch));
11261166
1127− evt->sync_srp = &srp_rsp;
1128− init_completion(&evt->comp);
1129− rsp_rc = ibmvscsi_send_srp_event(evt, hostdata, init_timeout * 2);
11301167 spin_unlock_irqrestore(hostdata->host->host_lock, flags);
1168+
11311169 if (rsp_rc != 0) {
11321170 sdev_printk(KERN_ERR, cmd->device,
11331171 "failed to send reset event. rc=%d\n", rsp_rc);
11341172 return FAILED;
11351173 }
11361174
1175+ sdev_printk(KERN_INFO, cmd->device, "resetting device. lun 0x%lx\n",
1176+ (((u64) lun) << 48));
1177+
11371178 wait_for_completion(&evt->comp);
11381179
11391180 /* make sure we got a good response */
@@ -1386,8 +1427,10 @@ static int ibmvscsi_slave_configure(struct scsi_device *sdev) · 246 unmodified lines
13861427 unsigned long lock_flags = 0;
13871428
13881429 spin_lock_irqsave(shost->host_lock, lock_flags);
1389− if (sdev->type == TYPE_DISK)
1430+ if (sdev->type == TYPE_DISK) {
13901431 sdev->allow_restart = 1;
1432+ sdev->timeout = 60 * HZ;
1433+ }
13911434 scsi_adjust_queue_depth(sdev, 0, shost->cmd_per_lun);
13921435 spin_unlock_irqrestore(shost->host_lock, lock_flags);
13931436 return 0;
drivers/scsi/ibmvscsi/ibmvstgt.c+1−1
@@ -292,7 +292,7 @@ static int ibmvstgt_cmd_done(struct scsi_cmnd *sc, · 291 unmodified lines
292292 dprintk("%p %p %x %u\n", iue, target, vio_iu(iue)->srp.cmd.cdb[0],
293293 cmd->usg_sg);
294294
295− if (sc->use_sg)
295+ if (scsi_sg_count(sc))
296296 err = srp_transfer_data(sc, &vio_iu(iue)->srp.cmd, ibmvstgt_rdma, 1, 1);
297297
298298 spin_lock_irqsave(&target->lock, flags);
drivers/scsi/imm.c+5−8
@@ -837,19 +837,16 @@ static int imm_engine(imm_struct *dev, struct scsi_cmnd *cmd) · 836 unmodified lines
837837
838838 /* Phase 4 - Setup scatter/gather buffers */
839839 case 4:
840− if (cmd->use_sg) {
841− /* if many buffers are available, start filling the first */
842− cmd->SCp.buffer =
843− (struct scatterlist *) cmd->request_buffer;
840+ if (scsi_bufflen(cmd)) {
841+ cmd->SCp.buffer = scsi_sglist(cmd);
844842 cmd->SCp.this_residual = cmd->SCp.buffer->length;
845843 cmd->SCp.ptr = sg_virt(cmd->SCp.buffer);
846844 } else {
847− /* else fill the only available buffer */
848845 cmd->SCp.buffer = NULL;
849− cmd->SCp.this_residual = cmd->request_bufflen;
850− cmd->SCp.ptr = cmd->request_buffer;
846+ cmd->SCp.this_residual = 0;
847+ cmd->SCp.ptr = NULL;
851848 }
852− cmd->SCp.buffers_residual = cmd->use_sg - 1;
849+ cmd->SCp.buffers_residual = scsi_sg_count(cmd) - 1;
853850 cmd->SCp.phase++;
854851 if (cmd->SCp.this_residual & 0x01)
855852 cmd->SCp.this_residual++;
drivers/scsi/in2000.c+5−5
@@ -369,16 +369,16 @@ static int in2000_queuecommand(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *)) · 368 unmodified lines
369369 * - SCp.phase records this command's SRCID_ER bit setting
370370 */
371371
372− if (cmd->use_sg) {
373− cmd->SCp.buffer = (struct scatterlist *) cmd->request_buffer;
374− cmd->SCp.buffers_residual = cmd->use_sg - 1;
372+ if (scsi_bufflen(cmd)) {
373+ cmd->SCp.buffer = scsi_sglist(cmd);
374+ cmd->SCp.buffers_residual = scsi_sg_count(cmd) - 1;
375375 cmd->SCp.ptr = sg_virt(cmd->SCp.buffer);
376376 cmd->SCp.this_residual = cmd->SCp.buffer->length;
377377 } else {
378378 cmd->SCp.buffer = NULL;
379379 cmd->SCp.buffers_residual = 0;
380− cmd->SCp.ptr = (char *) cmd->request_buffer;
381− cmd->SCp.this_residual = cmd->request_bufflen;
380+ cmd->SCp.ptr = NULL;
381+ cmd->SCp.this_residual = 0;
382382 }
383383 cmd->SCp.have_data_in = 0;
384384
drivers/scsi/ipr.c+1−1
@@ -84,7 +84,7 @@ · 83 unmodified lines
8484 /*
8585 * Global Data
8686 */
87−static struct list_head ipr_ioa_head = LIST_HEAD_INIT(ipr_ioa_head);
87+static LIST_HEAD(ipr_ioa_head);
8888 static unsigned int ipr_log_level = IPR_DEFAULT_LOG_LEVEL;
8989 static unsigned int ipr_max_speed = 1;
9090 static int ipr_testmode = 0;
drivers/scsi/ips.c+154−172
@@ -389,17 +389,17 @@ static struct pci_device_id ips_pci_table[] = { · 388 unmodified lines
389389 MODULE_DEVICE_TABLE( pci, ips_pci_table );
390390
391391 static char ips_hot_plug_name[] = "ips";
392−
392+
393393 static int __devinit ips_insert_device(struct pci_dev *pci_dev, const struct pci_device_id *ent);
394394 static void __devexit ips_remove_device(struct pci_dev *pci_dev);
395−
395+
396396 static struct pci_driver ips_pci_driver = {
397397 .name = ips_hot_plug_name,
398398 .id_table = ips_pci_table,
399399 .probe = ips_insert_device,
400400 .remove = __devexit_p(ips_remove_device),
401401 };
402−
402+
403403
404404 /*
405405 * Necessary forward function protoypes
@@ -587,7 +587,7 @@ static void · 181 unmodified lines
587587 ips_setup_funclist(ips_ha_t * ha)
588588 {
589589
590− /*
590+ /*
591591 * Setup Functions
592592 */
593593 if (IPS_IS_MORPHEUS(ha) || IPS_IS_MARCO(ha)) {
@@ -702,12 +702,8 @@ ips_release(struct Scsi_Host *sh) · 108 unmodified lines
702702 /* free extra memory */
703703 ips_free(ha);
704704
705− /* Free I/O Region */
706− if (ha->io_addr)
707− release_region(ha->io_addr, ha->io_len);
708−
709705 /* free IRQ */
710− free_irq(ha->irq, ha);
706+ free_irq(ha->pcidev->irq, ha);
711707
712708 scsi_host_put(sh);
713709
@@ -1637,7 +1633,7 @@ ips_make_passthru(ips_ha_t *ha, struct scsi_cmnd *SC, ips_scb_t *scb, int intr) · 923 unmodified lines
16371633 return (IPS_FAILURE);
16381634 }
16391635
1640− if (ha->device_id == IPS_DEVICEID_COPPERHEAD &&
1636+ if (ha->pcidev->device == IPS_DEVICEID_COPPERHEAD &&
16411637 pt->CoppCP.cmd.flashfw.op_code ==
16421638 IPS_CMD_RW_BIOSFW) {
16431639 ret = ips_flash_copperhead(ha, pt, scb);
@@ -2021,7 +2017,7 @@ ips_cleanup_passthru(ips_ha_t * ha, ips_scb_t * scb) · 377 unmodified lines
20212017 pt->ExtendedStatus = scb->extended_status;
20222018 pt->AdapterType = ha->ad_type;
20232019
2024− if (ha->device_id == IPS_DEVICEID_COPPERHEAD &&
2020+ if (ha->pcidev->device == IPS_DEVICEID_COPPERHEAD &&
20252021 (scb->cmd.flashfw.op_code == IPS_CMD_DOWNLOAD ||
20262022 scb->cmd.flashfw.op_code == IPS_CMD_RW_BIOSFW))
20272023 ips_free_flash_copperhead(ha);
@@ -2075,13 +2071,13 @@ ips_host_info(ips_ha_t * ha, char *ptr, off_t offset, int len) · 47 unmodified lines
20752071 ha->mem_ptr);
20762072 }
20772073
2078− copy_info(&info, "\tIRQ number : %d\n", ha->irq);
2074+ copy_info(&info, "\tIRQ number : %d\n", ha->pcidev->irq);
20792075
20802076 /* For the Next 3 lines Check for Binary 0 at the end and don't include it if it's there. */
20812077 /* That keeps everything happy for "text" operations on the proc file. */
20822078
20832079 if (le32_to_cpu(ha->nvram->signature) == IPS_NVRAM_P5_SIG) {
2084− if (ha->nvram->bios_low[3] == 0) {
2080+ if (ha->nvram->bios_low[3] == 0) {
20852081 copy_info(&info,
20862082 "\tBIOS Version : %c%c%c%c%c%c%c\n",
20872083 ha->nvram->bios_high[0], ha->nvram->bios_high[1],
@@ -2232,31 +2228,31 @@ ips_identify_controller(ips_ha_t * ha) · 144 unmodified lines
22322228 {
22332229 METHOD_TRACE("ips_identify_controller", 1);
22342230
2235− switch (ha->device_id) {
2231+ switch (ha->pcidev->device) {
22362232 case IPS_DEVICEID_COPPERHEAD:
2237− if (ha->revision_id <= IPS_REVID_SERVERAID) {
2233+ if (ha->pcidev->revision <= IPS_REVID_SERVERAID) {
22382234 ha->ad_type = IPS_ADTYPE_SERVERAID;
2239− } else if (ha->revision_id == IPS_REVID_SERVERAID2) {
2235+ } else if (ha->pcidev->revision == IPS_REVID_SERVERAID2) {
22402236 ha->ad_type = IPS_ADTYPE_SERVERAID2;
2241− } else if (ha->revision_id == IPS_REVID_NAVAJO) {
2237+ } else if (ha->pcidev->revision == IPS_REVID_NAVAJO) {
22422238 ha->ad_type = IPS_ADTYPE_NAVAJO;
2243− } else if ((ha->revision_id == IPS_REVID_SERVERAID2)
2239+ } else if ((ha->pcidev->revision == IPS_REVID_SERVERAID2)
22442240 && (ha->slot_num == 0)) {
22452241 ha->ad_type = IPS_ADTYPE_KIOWA;
2246− } else if ((ha->revision_id >= IPS_REVID_CLARINETP1) &&
2247− (ha->revision_id <= IPS_REVID_CLARINETP3)) {
2242+ } else if ((ha->pcidev->revision >= IPS_REVID_CLARINETP1) &&
2243+ (ha->pcidev->revision <= IPS_REVID_CLARINETP3)) {
22482244 if (ha->enq->ucMaxPhysicalDevices == 15)
22492245 ha->ad_type = IPS_ADTYPE_SERVERAID3L;
22502246 else
22512247 ha->ad_type = IPS_ADTYPE_SERVERAID3;
2252− } else if ((ha->revision_id >= IPS_REVID_TROMBONE32) &&
2253− (ha->revision_id <= IPS_REVID_TROMBONE64)) {
2248+ } else if ((ha->pcidev->revision >= IPS_REVID_TROMBONE32) &&
2249+ (ha->pcidev->revision <= IPS_REVID_TROMBONE64)) {
22542250 ha->ad_type = IPS_ADTYPE_SERVERAID4H;
22552251 }
22562252 break;
22572253
22582254 case IPS_DEVICEID_MORPHEUS:
2259− switch (ha->subdevice_id) {
2255+ switch (ha->pcidev->subsystem_device) {
22602256 case IPS_SUBDEVICEID_4L:
22612257 ha->ad_type = IPS_ADTYPE_SERVERAID4L;
22622258 break;
@@ -2285,7 +2281,7 @@ ips_identify_controller(ips_ha_t * ha) · 22 unmodified lines
22852281 break;
22862282
22872283 case IPS_DEVICEID_MARCO:
2288− switch (ha->subdevice_id) {
2284+ switch (ha->pcidev->subsystem_device) {
22892285 case IPS_SUBDEVICEID_6M:
22902286 ha->ad_type = IPS_ADTYPE_SERVERAID6M;
22912287 break;
@@ -2332,20 +2328,20 @@ ips_get_bios_version(ips_ha_t * ha, int intr) · 40 unmodified lines
23322328
23332329 strncpy(ha->bios_version, " ?", 8);
23342330
2335− if (ha->device_id == IPS_DEVICEID_COPPERHEAD) {
2331+ if (ha->pcidev->device == IPS_DEVICEID_COPPERHEAD) {
23362332 if (IPS_USE_MEMIO(ha)) {
23372333 /* Memory Mapped I/O */
23382334
23392335 /* test 1st byte */
23402336 writel(0, ha->mem_ptr + IPS_REG_FLAP);
2341− if (ha->revision_id == IPS_REVID_TROMBONE64)
2337+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
23422338 udelay(25); /* 25 us */
23432339
23442340 if (readb(ha->mem_ptr + IPS_REG_FLDP) != 0x55)
23452341 return;
23462342
23472343 writel(1, ha->mem_ptr + IPS_REG_FLAP);
2348− if (ha->revision_id == IPS_REVID_TROMBONE64)
2344+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
23492345 udelay(25); /* 25 us */
23502346
23512347 if (readb(ha->mem_ptr + IPS_REG_FLDP) != 0xAA)
@@ -2353,20 +2349,20 @@ ips_get_bios_version(ips_ha_t * ha, int intr) · 1 unmodified line
23532349
23542350 /* Get Major version */
23552351 writel(0x1FF, ha->mem_ptr + IPS_REG_FLAP);
2356− if (ha->revision_id == IPS_REVID_TROMBONE64)
2352+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
23572353 udelay(25); /* 25 us */
23582354
23592355 major = readb(ha->mem_ptr + IPS_REG_FLDP);
23602356
23612357 /* Get Minor version */
23622358 writel(0x1FE, ha->mem_ptr + IPS_REG_FLAP);
2363− if (ha->revision_id == IPS_REVID_TROMBONE64)
2359+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
23642360 udelay(25); /* 25 us */
23652361 minor = readb(ha->mem_ptr + IPS_REG_FLDP);
23662362
23672363 /* Get SubMinor version */
23682364 writel(0x1FD, ha->mem_ptr + IPS_REG_FLAP);
2369− if (ha->revision_id == IPS_REVID_TROMBONE64)
2365+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
23702366 udelay(25); /* 25 us */
23712367 subminor = readb(ha->mem_ptr + IPS_REG_FLDP);
23722368
@@ -2375,14 +2371,14 @@ ips_get_bios_version(ips_ha_t * ha, int intr) · 2 unmodified lines
23752371
23762372 /* test 1st byte */
23772373 outl(0, ha->io_addr + IPS_REG_FLAP);
2378− if (ha->revision_id == IPS_REVID_TROMBONE64)
2374+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
23792375 udelay(25); /* 25 us */
23802376
23812377 if (inb(ha->io_addr + IPS_REG_FLDP) != 0x55)
23822378 return;
23832379
23842380 outl(cpu_to_le32(1), ha->io_addr + IPS_REG_FLAP);
2385− if (ha->revision_id == IPS_REVID_TROMBONE64)
2381+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
23862382 udelay(25); /* 25 us */
23872383
23882384 if (inb(ha->io_addr + IPS_REG_FLDP) != 0xAA)
@@ -2390,21 +2386,21 @@ ips_get_bios_version(ips_ha_t * ha, int intr) · 1 unmodified line
23902386
23912387 /* Get Major version */
23922388 outl(cpu_to_le32(0x1FF), ha->io_addr + IPS_REG_FLAP);
2393− if (ha->revision_id == IPS_REVID_TROMBONE64)
2389+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
23942390 udelay(25); /* 25 us */
23952391
23962392 major = inb(ha->io_addr + IPS_REG_FLDP);
23972393
23982394 /* Get Minor version */
23992395 outl(cpu_to_le32(0x1FE), ha->io_addr + IPS_REG_FLAP);
2400− if (ha->revision_id == IPS_REVID_TROMBONE64)
2396+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
24012397 udelay(25); /* 25 us */
24022398
24032399 minor = inb(ha->io_addr + IPS_REG_FLDP);
24042400
24052401 /* Get SubMinor version */
24062402 outl(cpu_to_le32(0x1FD), ha->io_addr + IPS_REG_FLAP);
2407− if (ha->revision_id == IPS_REVID_TROMBONE64)
2403+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
24082404 udelay(25); /* 25 us */
24092405
24102406 subminor = inb(ha->io_addr + IPS_REG_FLDP);
@@ -2740,8 +2736,6 @@ ips_next(ips_ha_t * ha, int intr) · 329 unmodified lines
27402736 SC->result = DID_OK;
27412737 SC->host_scribble = NULL;
27422738
2743− memset(SC->sense_buffer, 0, sizeof (SC->sense_buffer));
2744−
27452739 scb->target_id = SC->device->id;
27462740 scb->lun = SC->device->lun;
27472741 scb->bus = SC->device->channel;
@@ -2780,10 +2774,11 @@ ips_next(ips_ha_t * ha, int intr) · 32 unmodified lines
27802774 scb->dcdb.cmd_attribute =
27812775 ips_command_direction[scb->scsi_cmd->cmnd[0]];
27822776
2783− /* Allow a WRITE BUFFER Command to Have no Data */
2784− /* This is Used by Tape Flash Utilites */
2785− if ((scb->scsi_cmd->cmnd[0] == WRITE_BUFFER) && (scb->data_len == 0))
2786− scb->dcdb.cmd_attribute = 0;
2777+ /* Allow a WRITE BUFFER Command to Have no Data */
2778+ /* This is Used by Tape Flash Utilites */
2779+ if ((scb->scsi_cmd->cmnd[0] == WRITE_BUFFER) &&
2780+ (scb->data_len == 0))
2781+ scb->dcdb.cmd_attribute = 0;
27872782
27882783 if (!(scb->dcdb.cmd_attribute & 0x3))
27892784 scb->dcdb.transfer_length = 0;
@@ -3404,7 +3399,7 @@ ips_map_status(ips_ha_t * ha, ips_scb_t * scb, ips_stat_t * sp) · 614 unmodified lines
34043399
34053400 /* Restrict access to physical DASD */
34063401 if (scb->scsi_cmd->cmnd[0] == INQUIRY) {
3407− ips_scmd_buf_read(scb->scsi_cmd,
3402+ ips_scmd_buf_read(scb->scsi_cmd,
34083403 &inquiryData, sizeof (inquiryData));
34093404 if ((inquiryData.DeviceType & 0x1f) == TYPE_DISK) {
34103405 errcode = DID_TIME_OUT;
@@ -3438,13 +3433,11 @@ ips_map_status(ips_ha_t * ha, ips_scb_t * scb, ips_stat_t * sp) · 27 unmodified lines
34383433 (IPS_DCDB_TABLE_TAPE *) & scb->dcdb;
34393434 memcpy(scb->scsi_cmd->sense_buffer,
34403435 tapeDCDB->sense_info,
3441− sizeof (scb->scsi_cmd->
3442− sense_buffer));
3436+ SCSI_SENSE_BUFFERSIZE);
34433437 } else {
34443438 memcpy(scb->scsi_cmd->sense_buffer,
34453439 scb->dcdb.sense_info,
3446− sizeof (scb->scsi_cmd->
3447− sense_buffer));
3440+ SCSI_SENSE_BUFFERSIZE);
34483441 }
34493442 device_error = 2; /* check condition */
34503443 }
@@ -3824,7 +3817,6 @@ ips_send_cmd(ips_ha_t * ha, ips_scb_t * scb) · 373 unmodified lines
38243817 /* attempted, a Check Condition occurred, and Sense */
38253818 /* Data indicating an Invalid CDB OpCode is returned. */
38263819 sp = (char *) scb->scsi_cmd->sense_buffer;
3827− memset(sp, 0, sizeof (scb->scsi_cmd->sense_buffer));
38283820
38293821 sp[0] = 0x70; /* Error Code */
38303822 sp[2] = ILLEGAL_REQUEST; /* Sense Key 5 Illegal Req. */
@@ -4090,10 +4082,10 @@ ips_chkstatus(ips_ha_t * ha, IPS_STATUS * pstatus) · 259 unmodified lines
40904082 scb->scsi_cmd->result = errcode << 16;
40914083 } else { /* bus == 0 */
40924084 /* restrict access to physical drives */
4093− if (scb->scsi_cmd->cmnd[0] == INQUIRY) {
4094− ips_scmd_buf_read(scb->scsi_cmd,
4085+ if (scb->scsi_cmd->cmnd[0] == INQUIRY) {
4086+ ips_scmd_buf_read(scb->scsi_cmd,
40954087 &inquiryData, sizeof (inquiryData));
4096− if ((inquiryData.DeviceType & 0x1f) == TYPE_DISK)
4088+ if ((inquiryData.DeviceType & 0x1f) == TYPE_DISK)
40974089 scb->scsi_cmd->result = DID_TIME_OUT << 16;
40984090 }
40994091 } /* else */
@@ -4393,8 +4385,6 @@ ips_free(ips_ha_t * ha) · 293 unmodified lines
43934385 ha->mem_ptr = NULL;
43944386 }
43954387
4396− if (ha->mem_addr)
4397− release_mem_region(ha->mem_addr, ha->mem_len);
43984388 ha->mem_addr = 0;
43994389
44004390 }
@@ -4661,8 +4651,8 @@ ips_isinit_morpheus(ips_ha_t * ha) · 260 unmodified lines
46614651 uint32_t bits;
46624652
46634653 METHOD_TRACE("ips_is_init_morpheus", 1);
4664−
4665− if (ips_isintr_morpheus(ha))
4654+
4655+ if (ips_isintr_morpheus(ha))
46664656 ips_flush_and_reset(ha);
46674657
46684658 post = readl(ha->mem_ptr + IPS_REG_I960_MSG0);
@@ -4686,7 +4676,7 @@ ips_isinit_morpheus(ips_ha_t * ha) · 17 unmodified lines
46864676 /* state ( was trying to INIT and an interrupt was already pending ) ... */
46874677 /* */
46884678 /****************************************************************************/
4689−static void
4679+static void
46904680 ips_flush_and_reset(ips_ha_t *ha)
46914681 {
46924682 ips_scb_t *scb;
@@ -4718,9 +4708,9 @@ ips_flush_and_reset(ips_ha_t *ha) · 25 unmodified lines
47184708 if (ret == IPS_SUCCESS) {
47194709 time = 60 * IPS_ONE_SEC; /* Max Wait time is 60 seconds */
47204710 done = 0;
4721−
4711+
47224712 while ((time > 0) && (!done)) {
4723− done = ips_poll_for_flush_complete(ha);
4713+ done = ips_poll_for_flush_complete(ha);
47244714 /* This may look evil, but it's only done during extremely rare start-up conditions ! */
47254715 udelay(1000);
47264716 time--;
@@ -4749,17 +4739,17 @@ static int · 22 unmodified lines
47494739 ips_poll_for_flush_complete(ips_ha_t * ha)
47504740 {
47514741 IPS_STATUS cstatus;
4752−
4742+
47534743 while (TRUE) {
47544744 cstatus.value = (*ha->func.statupd) (ha);
47554745
47564746 if (cstatus.value == 0xffffffff) /* If No Interrupt to process */
47574747 break;
4758−
4748+
47594749 /* Success is when we see the Flush Command ID */
4760− if (cstatus.fields.command_id == IPS_MAX_CMDS )
4750+ if (cstatus.fields.command_id == IPS_MAX_CMDS)
47614751 return 1;
4762− }
4752+ }
47634753
47644754 return 0;
47654755 }
@@ -4903,7 +4893,7 @@ ips_init_copperhead(ips_ha_t * ha) · 137 unmodified lines
49034893 /* Enable busmastering */
49044894 outb(IPS_BIT_EBM, ha->io_addr + IPS_REG_SCPR);
49054895
4906− if (ha->revision_id == IPS_REVID_TROMBONE64)
4896+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
49074897 /* fix for anaconda64 */
49084898 outl(0, ha->io_addr + IPS_REG_NDAE);
49094899
@@ -4997,7 +4987,7 @@ ips_init_copperhead_memio(ips_ha_t * ha) · 87 unmodified lines
49974987 /* Enable busmastering */
49984988 writeb(IPS_BIT_EBM, ha->mem_ptr + IPS_REG_SCPR);
49994989
5000− if (ha->revision_id == IPS_REVID_TROMBONE64)
4990+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
50014991 /* fix for anaconda64 */
50024992 writel(0, ha->mem_ptr + IPS_REG_NDAE);
50034993
@@ -5142,7 +5132,7 @@ ips_reset_copperhead(ips_ha_t * ha) · 138 unmodified lines
51425132 METHOD_TRACE("ips_reset_copperhead", 1);
51435133
51445134 DEBUG_VAR(1, "(%s%d) ips_reset_copperhead: io addr: %x, irq: %d",
5145− ips_name, ha->host_num, ha->io_addr, ha->irq);
5135+ ips_name, ha->host_num, ha->io_addr, ha->pcidev->irq);
51465136
51475137 reset_counter = 0;
51485138
@@ -5187,7 +5177,7 @@ ips_reset_copperhead_memio(ips_ha_t * ha) · 38 unmodified lines
51875177 METHOD_TRACE("ips_reset_copperhead_memio", 1);
51885178
51895179 DEBUG_VAR(1, "(%s%d) ips_reset_copperhead_memio: mem addr: %x, irq: %d",
5190− ips_name, ha->host_num, ha->mem_addr, ha->irq);
5180+ ips_name, ha->host_num, ha->mem_addr, ha->pcidev->irq);
51915181
51925182 reset_counter = 0;
51935183
@@ -5233,7 +5223,7 @@ ips_reset_morpheus(ips_ha_t * ha) · 39 unmodified lines
52335223 METHOD_TRACE("ips_reset_morpheus", 1);
52345224
52355225 DEBUG_VAR(1, "(%s%d) ips_reset_morpheus: mem addr: %x, irq: %d",
5236− ips_name, ha->host_num, ha->mem_addr, ha->irq);
5226+ ips_name, ha->host_num, ha->mem_addr, ha->pcidev->irq);
52375227
52385228 reset_counter = 0;
52395229
@@ -5920,7 +5910,7 @@ ips_read_config(ips_ha_t * ha, int intr) · 680 unmodified lines
59205910
59215911 return (0);
59225912 }
5923−
5913+
59245914 memcpy(ha->conf, ha->ioctl_data, sizeof(*ha->conf));
59255915 return (1);
59265916 }
@@ -5959,7 +5949,7 @@ ips_readwrite_page5(ips_ha_t * ha, int write, int intr) · 32 unmodified lines
59595949 scb->cmd.nvram.buffer_addr = ha->ioctl_busaddr;
59605950 if (write)
59615951 memcpy(ha->ioctl_data, ha->nvram, sizeof(*ha->nvram));
5962−
5952+
59635953 /* issue the command */
59645954 if (((ret =
59655955 ips_send_wait(ha, scb, ips_cmd_timeout, intr)) == IPS_FAILURE)
@@ -6196,32 +6186,32 @@ ips_erase_bios(ips_ha_t * ha) · 230 unmodified lines
61966186
61976187 /* Clear the status register */
61986188 outl(0, ha->io_addr + IPS_REG_FLAP);
6199− if (ha->revision_id == IPS_REVID_TROMBONE64)
6189+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
62006190 udelay(25); /* 25 us */
62016191
62026192 outb(0x50, ha->io_addr + IPS_REG_FLDP);
6203− if (ha->revision_id == IPS_REVID_TROMBONE64)
6193+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
62046194 udelay(25); /* 25 us */
62056195
62066196 /* Erase Setup */
62076197 outb(0x20, ha->io_addr + IPS_REG_FLDP);
6208− if (ha->revision_id == IPS_REVID_TROMBONE64)
6198+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
62096199 udelay(25); /* 25 us */
62106200
62116201 /* Erase Confirm */
62126202 outb(0xD0, ha->io_addr + IPS_REG_FLDP);
6213− if (ha->revision_id == IPS_REVID_TROMBONE64)
6203+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
62146204 udelay(25); /* 25 us */
62156205
62166206 /* Erase Status */
62176207 outb(0x70, ha->io_addr + IPS_REG_FLDP);
6218− if (ha->revision_id == IPS_REVID_TROMBONE64)
6208+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
62196209 udelay(25); /* 25 us */
62206210
62216211 timeout = 80000; /* 80 seconds */
62226212
62236213 while (timeout > 0) {
6224− if (ha->revision_id == IPS_REVID_TROMBONE64) {
6214+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64) {
62256215 outl(0, ha->io_addr + IPS_REG_FLAP);
62266216 udelay(25); /* 25 us */
62276217 }
@@ -6241,13 +6231,13 @@ ips_erase_bios(ips_ha_t * ha) · 13 unmodified lines
62416231
62426232 /* try to suspend the erase */
62436233 outb(0xB0, ha->io_addr + IPS_REG_FLDP);
6244− if (ha->revision_id == IPS_REVID_TROMBONE64)
6234+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
62456235 udelay(25); /* 25 us */
62466236
62476237 /* wait for 10 seconds */
62486238 timeout = 10000;
62496239 while (timeout > 0) {
6250− if (ha->revision_id == IPS_REVID_TROMBONE64) {
6240+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64) {
62516241 outl(0, ha->io_addr + IPS_REG_FLAP);
62526242 udelay(25); /* 25 us */
62536243 }
@@ -6277,12 +6267,12 @@ ips_erase_bios(ips_ha_t * ha) · 23 unmodified lines
62776267 /* Otherwise, we were successful */
62786268 /* clear status */
62796269 outb(0x50, ha->io_addr + IPS_REG_FLDP);
6280− if (ha->revision_id == IPS_REVID_TROMBONE64)
6270+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
62816271 udelay(25); /* 25 us */
62826272
62836273 /* enable reads */
62846274 outb(0xFF, ha->io_addr + IPS_REG_FLDP);
6285− if (ha->revision_id == IPS_REVID_TROMBONE64)
6275+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
62866276 udelay(25); /* 25 us */
62876277
62886278 return (0);
@@ -6308,32 +6298,32 @@ ips_erase_bios_memio(ips_ha_t * ha) · 19 unmodified lines
63086298
63096299 /* Clear the status register */
63106300 writel(0, ha->mem_ptr + IPS_REG_FLAP);
6311− if (ha->revision_id == IPS_REVID_TROMBONE64)
6301+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
63126302 udelay(25); /* 25 us */
63136303
63146304 writeb(0x50, ha->mem_ptr + IPS_REG_FLDP);
6315− if (ha->revision_id == IPS_REVID_TROMBONE64)
6305+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
63166306 udelay(25); /* 25 us */
63176307
63186308 /* Erase Setup */
63196309 writeb(0x20, ha->mem_ptr + IPS_REG_FLDP);
6320− if (ha->revision_id == IPS_REVID_TROMBONE64)
6310+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
63216311 udelay(25); /* 25 us */
63226312
63236313 /* Erase Confirm */
63246314 writeb(0xD0, ha->mem_ptr + IPS_REG_FLDP);
6325− if (ha->revision_id == IPS_REVID_TROMBONE64)
6315+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
63266316 udelay(25); /* 25 us */
63276317
63286318 /* Erase Status */
63296319 writeb(0x70, ha->mem_ptr + IPS_REG_FLDP);
6330− if (ha->revision_id == IPS_REVID_TROMBONE64)
6320+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
63316321 udelay(25); /* 25 us */
63326322
63336323 timeout = 80000; /* 80 seconds */
63346324
63356325 while (timeout > 0) {
6336− if (ha->revision_id == IPS_REVID_TROMBONE64) {
6326+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64) {
63376327 writel(0, ha->mem_ptr + IPS_REG_FLAP);
63386328 udelay(25); /* 25 us */
63396329 }
@@ -6353,13 +6343,13 @@ ips_erase_bios_memio(ips_ha_t * ha) · 13 unmodified lines
63536343
63546344 /* try to suspend the erase */
63556345 writeb(0xB0, ha->mem_ptr + IPS_REG_FLDP);
6356− if (ha->revision_id == IPS_REVID_TROMBONE64)
6346+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
63576347 udelay(25); /* 25 us */
63586348
63596349 /* wait for 10 seconds */
63606350 timeout = 10000;
63616351 while (timeout > 0) {
6362− if (ha->revision_id == IPS_REVID_TROMBONE64) {
6352+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64) {
63636353 writel(0, ha->mem_ptr + IPS_REG_FLAP);
63646354 udelay(25); /* 25 us */
63656355 }
@@ -6389,12 +6379,12 @@ ips_erase_bios_memio(ips_ha_t * ha) · 23 unmodified lines
63896379 /* Otherwise, we were successful */
63906380 /* clear status */
63916381 writeb(0x50, ha->mem_ptr + IPS_REG_FLDP);
6392− if (ha->revision_id == IPS_REVID_TROMBONE64)
6382+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
63936383 udelay(25); /* 25 us */
63946384
63956385 /* enable reads */
63966386 writeb(0xFF, ha->mem_ptr + IPS_REG_FLDP);
6397− if (ha->revision_id == IPS_REVID_TROMBONE64)
6387+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
63986388 udelay(25); /* 25 us */
63996389
64006390 return (0);
@@ -6423,21 +6413,21 @@ ips_program_bios(ips_ha_t * ha, char *buffer, uint32_t buffersize, · 22 unmodified lines
64236413 for (i = 0; i < buffersize; i++) {
64246414 /* write a byte */
64256415 outl(cpu_to_le32(i + offset), ha->io_addr + IPS_REG_FLAP);
6426− if (ha->revision_id == IPS_REVID_TROMBONE64)
6416+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
64276417 udelay(25); /* 25 us */
64286418
64296419 outb(0x40, ha->io_addr + IPS_REG_FLDP);
6430− if (ha->revision_id == IPS_REVID_TROMBONE64)
6420+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
64316421 udelay(25); /* 25 us */
64326422
64336423 outb(buffer[i], ha->io_addr + IPS_REG_FLDP);
6434− if (ha->revision_id == IPS_REVID_TROMBONE64)
6424+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
64356425 udelay(25); /* 25 us */
64366426
64376427 /* wait up to one second */
64386428 timeout = 1000;
64396429 while (timeout > 0) {
6440− if (ha->revision_id == IPS_REVID_TROMBONE64) {
6430+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64) {
64416431 outl(0, ha->io_addr + IPS_REG_FLAP);
64426432 udelay(25); /* 25 us */
64436433 }
@@ -6454,11 +6444,11 @@ ips_program_bios(ips_ha_t * ha, char *buffer, uint32_t buffersize, · 10 unmodified lines
64546444 if (timeout == 0) {
64556445 /* timeout error */
64566446 outl(0, ha->io_addr + IPS_REG_FLAP);
6457− if (ha->revision_id == IPS_REVID_TROMBONE64)
6447+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
64586448 udelay(25); /* 25 us */
64596449
64606450 outb(0xFF, ha->io_addr + IPS_REG_FLDP);
6461− if (ha->revision_id == IPS_REVID_TROMBONE64)
6451+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
64626452 udelay(25); /* 25 us */
64636453
64646454 return (1);
@@ -6468,11 +6458,11 @@ ips_program_bios(ips_ha_t * ha, char *buffer, uint32_t buffersize, · 3 unmodified lines
64686458 if (status & 0x18) {
64696459 /* programming error */
64706460 outl(0, ha->io_addr + IPS_REG_FLAP);
6471− if (ha->revision_id == IPS_REVID_TROMBONE64)
6461+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
64726462 udelay(25); /* 25 us */
64736463
64746464 outb(0xFF, ha->io_addr + IPS_REG_FLDP);
6475− if (ha->revision_id == IPS_REVID_TROMBONE64)
6465+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
64766466 udelay(25); /* 25 us */
64776467
64786468 return (1);
@@ -6481,11 +6471,11 @@ ips_program_bios(ips_ha_t * ha, char *buffer, uint32_t buffersize, · 2 unmodified lines
64816471
64826472 /* Enable reading */
64836473 outl(0, ha->io_addr + IPS_REG_FLAP);
6484− if (ha->revision_id == IPS_REVID_TROMBONE64)
6474+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
64856475 udelay(25); /* 25 us */
64866476
64876477 outb(0xFF, ha->io_addr + IPS_REG_FLDP);
6488− if (ha->revision_id == IPS_REVID_TROMBONE64)
6478+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
64896479 udelay(25); /* 25 us */
64906480
64916481 return (0);
@@ -6514,21 +6504,21 @@ ips_program_bios_memio(ips_ha_t * ha, char *buffer, uint32_t buffersize, · 22 unmodified lines
65146504 for (i = 0; i < buffersize; i++) {
65156505 /* write a byte */
65166506 writel(i + offset, ha->mem_ptr + IPS_REG_FLAP);
6517− if (ha->revision_id == IPS_REVID_TROMBONE64)
6507+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
65186508 udelay(25); /* 25 us */
65196509
65206510 writeb(0x40, ha->mem_ptr + IPS_REG_FLDP);
6521− if (ha->revision_id == IPS_REVID_TROMBONE64)
6511+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
65226512 udelay(25); /* 25 us */
65236513
65246514 writeb(buffer[i], ha->mem_ptr + IPS_REG_FLDP);
6525− if (ha->revision_id == IPS_REVID_TROMBONE64)
6515+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
65266516 udelay(25); /* 25 us */
65276517
65286518 /* wait up to one second */
65296519 timeout = 1000;
65306520 while (timeout > 0) {
6531− if (ha->revision_id == IPS_REVID_TROMBONE64) {
6521+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64) {
65326522 writel(0, ha->mem_ptr + IPS_REG_FLAP);
65336523 udelay(25); /* 25 us */
65346524 }
@@ -6545,11 +6535,11 @@ ips_program_bios_memio(ips_ha_t * ha, char *buffer, uint32_t buffersize, · 10 unmodified lines
65456535 if (timeout == 0) {
65466536 /* timeout error */
65476537 writel(0, ha->mem_ptr + IPS_REG_FLAP);
6548− if (ha->revision_id == IPS_REVID_TROMBONE64)
6538+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
65496539 udelay(25); /* 25 us */
65506540
65516541 writeb(0xFF, ha->mem_ptr + IPS_REG_FLDP);
6552− if (ha->revision_id == IPS_REVID_TROMBONE64)
6542+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
65536543 udelay(25); /* 25 us */
65546544
65556545 return (1);
@@ -6559,11 +6549,11 @@ ips_program_bios_memio(ips_ha_t * ha, char *buffer, uint32_t buffersize, · 3 unmodified lines
65596549 if (status & 0x18) {
65606550 /* programming error */
65616551 writel(0, ha->mem_ptr + IPS_REG_FLAP);
6562− if (ha->revision_id == IPS_REVID_TROMBONE64)
6552+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
65636553 udelay(25); /* 25 us */
65646554
65656555 writeb(0xFF, ha->mem_ptr + IPS_REG_FLDP);
6566− if (ha->revision_id == IPS_REVID_TROMBONE64)
6556+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
65676557 udelay(25); /* 25 us */
65686558
65696559 return (1);
@@ -6572,11 +6562,11 @@ ips_program_bios_memio(ips_ha_t * ha, char *buffer, uint32_t buffersize, · 2 unmodified lines
65726562
65736563 /* Enable reading */
65746564 writel(0, ha->mem_ptr + IPS_REG_FLAP);
6575− if (ha->revision_id == IPS_REVID_TROMBONE64)
6565+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
65766566 udelay(25); /* 25 us */
65776567
65786568 writeb(0xFF, ha->mem_ptr + IPS_REG_FLDP);
6579− if (ha->revision_id == IPS_REVID_TROMBONE64)
6569+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
65806570 udelay(25); /* 25 us */
65816571
65826572 return (0);
@@ -6601,14 +6591,14 @@ ips_verify_bios(ips_ha_t * ha, char *buffer, uint32_t buffersize, · 18 unmodified lines
66016591
66026592 /* test 1st byte */
66036593 outl(0, ha->io_addr + IPS_REG_FLAP);
6604− if (ha->revision_id == IPS_REVID_TROMBONE64)
6594+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
66056595 udelay(25); /* 25 us */
66066596
66076597 if (inb(ha->io_addr + IPS_REG_FLDP) != 0x55)
66086598 return (1);
66096599
66106600 outl(cpu_to_le32(1), ha->io_addr + IPS_REG_FLAP);
6611− if (ha->revision_id == IPS_REVID_TROMBONE64)
6601+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
66126602 udelay(25); /* 25 us */
66136603 if (inb(ha->io_addr + IPS_REG_FLDP) != 0xAA)
66146604 return (1);
@@ -6617,7 +6607,7 @@ ips_verify_bios(ips_ha_t * ha, char *buffer, uint32_t buffersize, · 2 unmodified lines
66176607 for (i = 2; i < buffersize; i++) {
66186608
66196609 outl(cpu_to_le32(i + offset), ha->io_addr + IPS_REG_FLAP);
6620− if (ha->revision_id == IPS_REVID_TROMBONE64)
6610+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
66216611 udelay(25); /* 25 us */
66226612
66236613 checksum = (uint8_t) checksum + inb(ha->io_addr + IPS_REG_FLDP);
@@ -6650,14 +6640,14 @@ ips_verify_bios_memio(ips_ha_t * ha, char *buffer, uint32_t buffersize, · 26 unmodified lines
66506640
66516641 /* test 1st byte */
66526642 writel(0, ha->mem_ptr + IPS_REG_FLAP);
6653− if (ha->revision_id == IPS_REVID_TROMBONE64)
6643+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
66546644 udelay(25); /* 25 us */
66556645
66566646 if (readb(ha->mem_ptr + IPS_REG_FLDP) != 0x55)
66576647 return (1);
66586648
66596649 writel(1, ha->mem_ptr + IPS_REG_FLAP);
6660− if (ha->revision_id == IPS_REVID_TROMBONE64)
6650+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
66616651 udelay(25); /* 25 us */
66626652 if (readb(ha->mem_ptr + IPS_REG_FLDP) != 0xAA)
66636653 return (1);
@@ -6666,7 +6656,7 @@ ips_verify_bios_memio(ips_ha_t * ha, char *buffer, uint32_t buffersize, · 2 unmodified lines
66666656 for (i = 2; i < buffersize; i++) {
66676657
66686658 writel(i + offset, ha->mem_ptr + IPS_REG_FLAP);
6669− if (ha->revision_id == IPS_REVID_TROMBONE64)
6659+ if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
66706660 udelay(25); /* 25 us */
66716661
66726662 checksum =
@@ -6837,24 +6827,18 @@ ips_register_scsi(int index) · 164 unmodified lines
68376827 }
68386828 ha = IPS_HA(sh);
68396829 memcpy(ha, oldha, sizeof (ips_ha_t));
6840− free_irq(oldha->irq, oldha);
6830+ free_irq(oldha->pcidev->irq, oldha);
68416831 /* Install the interrupt handler with the new ha */
6842− if (request_irq(ha->irq, do_ipsintr, IRQF_SHARED, ips_name, ha)) {
6832+ if (request_irq(ha->pcidev->irq, do_ipsintr, IRQF_SHARED, ips_name, ha)) {
68436833 IPS_PRINTK(KERN_WARNING, ha->pcidev,
68446834 "Unable to install interrupt handler\n");
6845− scsi_host_put(sh);
6846− return -1;
6835+ goto err_out_sh;
68476836 }
68486837
68496838 kfree(oldha);
6850− ips_sh[index] = sh;
6851− ips_ha[index] = ha;
68526839
68536840 /* Store away needed values for later use */
6854− sh->io_port = ha->io_addr;
6855− sh->n_io_port = ha->io_addr ? 255 : 0;
68566841 sh->unique_id = (ha->io_addr) ? ha->io_addr : ha->mem_addr;
6857− sh->irq = ha->irq;
68586842 sh->sg_tablesize = sh->hostt->sg_tablesize;
68596843 sh->can_queue = sh->hostt->can_queue;
68606844 sh->cmd_per_lun = sh->hostt->cmd_per_lun;
@@ -6867,10 +6851,21 @@ ips_register_scsi(int index) · 6 unmodified lines
68676851 sh->max_channel = ha->nbus - 1;
68686852 sh->can_queue = ha->max_cmds - 1;
68696853
6870− scsi_add_host(sh, NULL);
6854+ if (scsi_add_host(sh, &ha->pcidev->dev))
6855+ goto err_out;
6856+
6857+ ips_sh[index] = sh;
6858+ ips_ha[index] = ha;
6859+
68716860 scsi_scan_host(sh);
68726861
68736862 return 0;
6863+
6864+err_out:
6865+ free_irq(ha->pcidev->irq, ha);
6866+err_out_sh:
6867+ scsi_host_put(sh);
6868+ return -1;
68746869 }
68756870
68766871 /*---------------------------------------------------------------------------*/
@@ -6882,20 +6877,14 @@ ips_register_scsi(int index) · 5 unmodified lines
68826877 static void __devexit
68836878 ips_remove_device(struct pci_dev *pci_dev)
68846879 {
6885− int i;
6886− struct Scsi_Host *sh;
6887− ips_ha_t *ha;
6880+ struct Scsi_Host *sh = pci_get_drvdata(pci_dev);
68886881
6889− for (i = 0; i < IPS_MAX_ADAPTERS; i++) {
6890− ha = ips_ha[i];
6891− if (ha) {
6892− if ((pci_dev->bus->number == ha->pcidev->bus->number) &&
6893− (pci_dev->devfn == ha->pcidev->devfn)) {
6894− sh = ips_sh[i];
6895− ips_release(sh);
6896− }
6897− }
6898− }
6882+ pci_set_drvdata(pci_dev, NULL);
6883+
6884+ ips_release(sh);
6885+
6886+ pci_release_regions(pci_dev);
6887+ pci_disable_device(pci_dev);
68996888 }
69006889
69016890 /****************************************************************************/
@@ -6949,12 +6938,17 @@ module_exit(ips_module_exit); · 47 unmodified lines
69496938 static int __devinit
69506939 ips_insert_device(struct pci_dev *pci_dev, const struct pci_device_id *ent)
69516940 {
6952− int uninitialized_var(index);
6941+ int index = -1;
69536942 int rc;
69546943
69556944 METHOD_TRACE("ips_insert_device", 1);
6956− if (pci_enable_device(pci_dev))
6957− return -1;
6945+ rc = pci_enable_device(pci_dev);
6946+ if (rc)
6947+ return rc;
6948+
6949+ rc = pci_request_regions(pci_dev, "ips");
6950+ if (rc)
6951+ goto err_out;
69586952
69596953 rc = ips_init_phase1(pci_dev, &index);
69606954 if (rc == SUCCESS)
@@ -6970,6 +6964,19 @@ ips_insert_device(struct pci_dev *pci_dev, const struct pci_device_id *ent) · 9 unmodified lines
69706964 ips_num_controllers++;
69716965
69726966 ips_next_controller = ips_num_controllers;
6967+
6968+ if (rc < 0) {
6969+ rc = -ENODEV;
6970+ goto err_out_regions;
6971+ }
6972+
6973+ pci_set_drvdata(pci_dev, ips_sh[index]);
6974+ return 0;
6975+
6976+err_out_regions:
6977+ pci_release_regions(pci_dev);
6978+err_out:
6979+ pci_disable_device(pci_dev);
69736980 return rc;
69746981 }
69756982
@@ -6992,8 +6999,6 @@ ips_init_phase1(struct pci_dev *pci_dev, int *indexPtr) · 16 unmodified lines
69926999 uint32_t mem_len;
69937000 uint8_t bus;
69947001 uint8_t func;
6995− uint8_t irq;
6996− uint16_t subdevice_id;
69977002 int j;
69987003 int index;
69997004 dma_addr_t dma_address;
@@ -7004,7 +7009,7 @@ ips_init_phase1(struct pci_dev *pci_dev, int *indexPtr) · 4 unmodified lines
70047009 METHOD_TRACE("ips_init_phase1", 1);
70057010 index = IPS_MAX_ADAPTERS;
70067011 for (j = 0; j < IPS_MAX_ADAPTERS; j++) {
7007− if (ips_ha[j] == 0) {
7012+ if (ips_ha[j] == NULL) {
70087013 index = j;
70097014 break;
70107015 }
@@ -7014,7 +7019,6 @@ ips_init_phase1(struct pci_dev *pci_dev, int *indexPtr) · 3 unmodified lines
70147019 return -1;
70157020
70167021 /* stuff that we get in dev */
7017− irq = pci_dev->irq;
70187022 bus = pci_dev->bus->number;
70197023 func = pci_dev->devfn;
70207024
@@ -7042,34 +7046,17 @@ ips_init_phase1(struct pci_dev *pci_dev, int *indexPtr) · 21 unmodified lines
70427046 uint32_t base;
70437047 uint32_t offs;
70447048
7045− if (!request_mem_region(mem_addr, mem_len, "ips")) {
7046− IPS_PRINTK(KERN_WARNING, pci_dev,
7047− "Couldn't allocate IO Memory space %x len %d.\n",
7048− mem_addr, mem_len);
7049− return -1;
7050− }
7051−
70527049 base = mem_addr & PAGE_MASK;
70537050 offs = mem_addr - base;
70547051 ioremap_ptr = ioremap(base, PAGE_SIZE);
7052+ if (!ioremap_ptr)
7053+ return -1;
70557054 mem_ptr = ioremap_ptr + offs;
70567055 } else {
70577056 ioremap_ptr = NULL;
70587057 mem_ptr = NULL;
70597058 }
70607059
7061− /* setup I/O mapped area (if applicable) */
7062− if (io_addr) {
7063− if (!request_region(io_addr, io_len, "ips")) {
7064− IPS_PRINTK(KERN_WARNING, pci_dev,
7065− "Couldn't allocate IO space %x len %d.\n",
7066− io_addr, io_len);
7067− return -1;
7068− }
7069− }
7070−
7071− subdevice_id = pci_dev->subsystem_device;
7072−
70737060 /* found a controller */
70747061 ha = kzalloc(sizeof (ips_ha_t), GFP_KERNEL);
70757062 if (ha == NULL) {
@@ -7078,13 +7065,11 @@ ips_init_phase1(struct pci_dev *pci_dev, int *indexPtr) · 2 unmodified lines
70787065 return -1;
70797066 }
70807067
7081−
70827068 ips_sh[index] = NULL;
70837069 ips_ha[index] = ha;
70847070 ha->active = 1;
70857071
70867072 /* Store info in HA structure */
7087− ha->irq = irq;
70887073 ha->io_addr = io_addr;
70897074 ha->io_len = io_len;
70907075 ha->mem_addr = mem_addr;
@@ -7092,10 +7077,7 @@ ips_init_phase1(struct pci_dev *pci_dev, int *indexPtr) · 1 unmodified line
70927077 ha->mem_ptr = mem_ptr;
70937078 ha->ioremap_ptr = ioremap_ptr;
70947079 ha->host_num = (uint32_t) index;
7095− ha->revision_id = pci_dev->revision;
70967080 ha->slot_num = PCI_SLOT(pci_dev->devfn);
7097− ha->device_id = pci_dev->device;
7098− ha->subdevice_id = subdevice_id;
70997081 ha->pcidev = pci_dev;
71007082
71017083 /*
@@ -7240,7 +7222,7 @@ ips_init_phase2(int index) · 138 unmodified lines
72407222 }
72417223
72427224 /* Install the interrupt handler */
7243− if (request_irq(ha->irq, do_ipsintr, IRQF_SHARED, ips_name, ha)) {
7225+ if (request_irq(ha->pcidev->irq, do_ipsintr, IRQF_SHARED, ips_name, ha)) {
72447226 IPS_PRINTK(KERN_WARNING, ha->pcidev,
72457227 "Unable to install interrupt handler\n");
72467228 return ips_abort_init(ha, index);
@@ -7253,14 +7235,14 @@ ips_init_phase2(int index) · 6 unmodified lines
72537235 if (!ips_allocatescbs(ha)) {
72547236 IPS_PRINTK(KERN_WARNING, ha->pcidev,
72557237 "Unable to allocate a CCB\n");
7256− free_irq(ha->irq, ha);
7238+ free_irq(ha->pcidev->irq, ha);
72577239 return ips_abort_init(ha, index);
72587240 }
72597241
72607242 if (!ips_hainit(ha)) {
72617243 IPS_PRINTK(KERN_WARNING, ha->pcidev,
72627244 "Unable to initialize controller\n");
7263− free_irq(ha->irq, ha);
7245+ free_irq(ha->pcidev->irq, ha);
72647246 return ips_abort_init(ha, index);
72657247 }
72667248 /* Free the temporary SCB */
@@ -7270,7 +7252,7 @@ ips_init_phase2(int index) · 3 unmodified lines
72707252 if (!ips_allocatescbs(ha)) {
72717253 IPS_PRINTK(KERN_WARNING, ha->pcidev,
72727254 "Unable to allocate CCBs\n");
7273− free_irq(ha->irq, ha);
7255+ free_irq(ha->pcidev->irq, ha);
72747256 return ips_abort_init(ha, index);
72757257 }
72767258
drivers/scsi/ips.h+14−18
@@ -60,14 +60,14 @@ · 59 unmodified lines
6060 */
6161 #define IPS_HA(x) ((ips_ha_t *) x->hostdata)
6262 #define IPS_COMMAND_ID(ha, scb) (int) (scb - ha->scbs)
63− #define IPS_IS_TROMBONE(ha) (((ha->device_id == IPS_DEVICEID_COPPERHEAD) && \
64− (ha->revision_id >= IPS_REVID_TROMBONE32) && \
65− (ha->revision_id <= IPS_REVID_TROMBONE64)) ? 1 : 0)
66− #define IPS_IS_CLARINET(ha) (((ha->device_id == IPS_DEVICEID_COPPERHEAD) && \
67− (ha->revision_id >= IPS_REVID_CLARINETP1) && \
68− (ha->revision_id <= IPS_REVID_CLARINETP3)) ? 1 : 0)
69− #define IPS_IS_MORPHEUS(ha) (ha->device_id == IPS_DEVICEID_MORPHEUS)
70− #define IPS_IS_MARCO(ha) (ha->device_id == IPS_DEVICEID_MARCO)
63+ #define IPS_IS_TROMBONE(ha) (((ha->pcidev->device == IPS_DEVICEID_COPPERHEAD) && \
64+ (ha->pcidev->revision >= IPS_REVID_TROMBONE32) && \
65+ (ha->pcidev->revision <= IPS_REVID_TROMBONE64)) ? 1 : 0)
66+ #define IPS_IS_CLARINET(ha) (((ha->pcidev->device == IPS_DEVICEID_COPPERHEAD) && \
67+ (ha->pcidev->revision >= IPS_REVID_CLARINETP1) && \
68+ (ha->pcidev->revision <= IPS_REVID_CLARINETP3)) ? 1 : 0)
69+ #define IPS_IS_MORPHEUS(ha) (ha->pcidev->device == IPS_DEVICEID_MORPHEUS)
70+ #define IPS_IS_MARCO(ha) (ha->pcidev->device == IPS_DEVICEID_MARCO)
7171 #define IPS_USE_I2O_DELIVER(ha) ((IPS_IS_MORPHEUS(ha) || \
7272 (IPS_IS_TROMBONE(ha) && \
7373 (ips_force_i2o))) ? 1 : 0)
@@ -92,7 +92,7 @@ · 18 unmodified lines
9292 #ifndef min
9393 #define min(x,y) ((x) < (y) ? x : y)
9494 #endif
95−
95+
9696 #ifndef __iomem /* For clean compiles in earlier kernels without __iomem annotations */
9797 #define __iomem
9898 #endif
@@ -171,7 +171,7 @@ · 72 unmodified lines
171171 #define IPS_CMD_DOWNLOAD 0x20
172172 #define IPS_CMD_RW_BIOSFW 0x22
173173 #define IPS_CMD_GET_VERSION_INFO 0xC6
174− #define IPS_CMD_RESET_CHANNEL 0x1A
174+ #define IPS_CMD_RESET_CHANNEL 0x1A
175175
176176 /*
177177 * Adapter Equates
@@ -458,7 +458,7 @@ typedef struct { · 280 unmodified lines
458458 uint32_t reserved3;
459459 uint32_t buffer_addr;
460460 uint32_t reserved4;
461−} IPS_IOCTL_CMD, *PIPS_IOCTL_CMD;
461+} IPS_IOCTL_CMD, *PIPS_IOCTL_CMD;
462462
463463 typedef struct {
464464 uint8_t op_code;
@@ -552,7 +552,7 @@ typedef struct { · 87 unmodified lines
552552 uint32_t cccr;
553553 } IPS_NVRAM_CMD, *PIPS_NVRAM_CMD;
554554
555−typedef struct
555+typedef struct
556556 {
557557 uint8_t op_code;
558558 uint8_t command_id;
@@ -650,7 +650,7 @@ typedef struct { · 91 unmodified lines
650650 uint8_t device_address;
651651 uint8_t cmd_attribute;
652652 uint8_t cdb_length;
653− uint8_t reserved_for_LUN;
653+ uint8_t reserved_for_LUN;
654654 uint32_t transfer_length;
655655 uint32_t buffer_pointer;
656656 uint16_t sg_count;
@@ -790,7 +790,7 @@ typedef struct { · 133 unmodified lines
790790 /* SubSystem Parameter[4] */
791791 #define IPS_GET_VERSION_SUPPORT 0x00018000 /* Mask for Versioning Support */
792792
793−typedef struct
793+typedef struct
794794 {
795795 uint32_t revision;
796796 uint8_t bootBlkVersion[32];
@@ -1034,7 +1034,6 @@ typedef struct ips_ha { · 237 unmodified lines
10341034 uint8_t ha_id[IPS_MAX_CHANNELS+1];
10351035 uint32_t dcdb_active[IPS_MAX_CHANNELS];
10361036 uint32_t io_addr; /* Base I/O address */
1037− uint8_t irq; /* IRQ for adapter */
10381037 uint8_t ntargets; /* Number of targets */
10391038 uint8_t nbus; /* Number of buses */
10401039 uint8_t nlun; /* Number of Luns */
@@ -1066,10 +1065,7 @@ typedef struct ips_ha { · 25 unmodified lines
10661065 int ioctl_reset; /* IOCTL Requested Reset Flag */
10671066 uint16_t reset_count; /* number of resets */
10681067 time_t last_ffdc; /* last time we sent ffdc info*/
1069− uint8_t revision_id; /* Revision level */
1070− uint16_t device_id; /* PCI device ID */
10711068 uint8_t slot_num; /* PCI Slot Number */
1072− uint16_t subdevice_id; /* Subsystem device ID */
10731069 int ioctl_len; /* size of ioctl buffer */
10741070 dma_addr_t ioctl_busaddr; /* dma address of ioctl buffer*/
10751071 uint8_t bios_version[8]; /* BIOS Revision */
drivers/scsi/iscsi_tcp.c+896−1187
@@ -48,7 +48,7 @@ MODULE_AUTHOR("Dmitry Yusupov <dmitry_yus@yahoo.com>, " · 47 unmodified lines
4848 "Alex Aizman <itn780@yahoo.com>");
4949 MODULE_DESCRIPTION("iSCSI/TCP data-path");
5050 MODULE_LICENSE("GPL");
51−/* #define DEBUG_TCP */
51+#undef DEBUG_TCP
5252 #define DEBUG_ASSERT
5353
5454 #ifdef DEBUG_TCP
@@ -67,115 +67,429 @@ MODULE_LICENSE("GPL"); · 12 unmodified lines
6767 static unsigned int iscsi_max_lun = 512;
6868 module_param_named(max_lun, iscsi_max_lun, uint, S_IRUGO);
6969
70+static int iscsi_tcp_hdr_recv_done(struct iscsi_tcp_conn *tcp_conn,
71+ struct iscsi_segment *segment);
72+
73+/*
74+ * Scatterlist handling: inside the iscsi_segment, we
75+ * remember an index into the scatterlist, and set data/size
76+ * to the current scatterlist entry. For highmem pages, we
77+ * kmap as needed.
78+ *
79+ * Note that the page is unmapped when we return from
80+ * TCP's data_ready handler, so we may end up mapping and
81+ * unmapping the same page repeatedly. The whole reason
82+ * for this is that we shouldn't keep the page mapped
83+ * outside the softirq.
84+ */
85+
86+/**
87+ * iscsi_tcp_segment_init_sg - init indicated scatterlist entry
88+ * @segment: the buffer object
89+ * @sg: scatterlist
90+ * @offset: byte offset into that sg entry
91+ *
92+ * This function sets up the segment so that subsequent
93+ * data is copied to the indicated sg entry, at the given
94+ * offset.
95+ */
7096 static inline void
71−iscsi_buf_init_iov(struct iscsi_buf *ibuf, char *vbuf, int size)
97+iscsi_tcp_segment_init_sg(struct iscsi_segment *segment,
98+ struct scatterlist *sg, unsigned int offset)
7299 {
73− sg_init_one(&ibuf->sg, vbuf, size);
74− ibuf->sent = 0;
75− ibuf->use_sendmsg = 1;
100+ segment->sg = sg;
101+ segment->sg_offset = offset;
102+ segment->size = min(sg->length - offset,
103+ segment->total_size - segment->total_copied);
104+ segment->data = NULL;
76105 }
77106
107+/**
108+ * iscsi_tcp_segment_map - map the current S/G page
109+ * @segment: iscsi_segment
110+ * @recv: 1 if called from recv path
111+ *
112+ * We only need to possibly kmap data if scatter lists are being used,
113+ * because the iscsi passthrough and internal IO paths will never use high
114+ * mem pages.
115+ */
78116 static inline void
79−iscsi_buf_init_sg(struct iscsi_buf *ibuf, struct scatterlist *sg)
117+iscsi_tcp_segment_map(struct iscsi_segment *segment, int recv)
80118 {
81− sg_init_table(&ibuf->sg, 1);
82− sg_set_page(&ibuf->sg, sg_page(sg), sg->length, sg->offset);
119+ struct scatterlist *sg;
120+
121+ if (segment->data != NULL || !segment->sg)
122+ return;
123+
124+ sg = segment->sg;
125+ BUG_ON(segment->sg_mapped);
126+ BUG_ON(sg->length == 0);
127+
83128 /*
84− * Fastpath: sg element fits into single page
129+ * If the page count is greater than one it is ok to send
130+ * to the network layer's zero copy send path. If not we
131+ * have to go the slow sendmsg path. We always map for the
132+ * recv path.
85133 */
86− if (sg->length + sg->offset <= PAGE_SIZE && !PageSlab(sg_page(sg)))
87− ibuf->use_sendmsg = 0;
88− else
89− ibuf->use_sendmsg = 1;
90− ibuf->sent = 0;
134+ if (page_count(sg_page(sg)) >= 1 && !recv)
135+ return;
136+
137+ debug_tcp("iscsi_tcp_segment_map %s %p\n", recv ? "recv" : "xmit",
138+ segment);
139+ segment->sg_mapped = kmap_atomic(sg_page(sg), KM_SOFTIRQ0);
140+ segment->data = segment->sg_mapped + sg->offset + segment->sg_offset;
91141 }
92142
93−static inline int
94−iscsi_buf_left(struct iscsi_buf *ibuf)
143+static inline void
144+iscsi_tcp_segment_unmap(struct iscsi_segment *segment)
95145 {
96− int rc;
146+ debug_tcp("iscsi_tcp_segment_unmap %p\n", segment);
97147
98− rc = ibuf->sg.length - ibuf->sent;
99− BUG_ON(rc < 0);
100− return rc;
148+ if (segment->sg_mapped) {
149+ debug_tcp("iscsi_tcp_segment_unmap valid\n");
150+ kunmap_atomic(segment->sg_mapped, KM_SOFTIRQ0);
151+ segment->sg_mapped = NULL;
152+ segment->data = NULL;
153+ }
101154 }
102155
156+/*
157+ * Splice the digest buffer into the buffer
158+ */
103159 static inline void
104−iscsi_hdr_digest(struct iscsi_conn *conn, struct iscsi_buf *buf,
105− u8* crc)
160+iscsi_tcp_segment_splice_digest(struct iscsi_segment *segment, void *digest)
106161 {
107− struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
108−
109− crypto_hash_digest(&tcp_conn->tx_hash, &buf->sg, buf->sg.length, crc);
110− buf->sg.length += sizeof(u32);
162+ segment->data = digest;
163+ segment->digest_len = ISCSI_DIGEST_SIZE;
164+ segment->total_size += ISCSI_DIGEST_SIZE;
165+ segment->size = ISCSI_DIGEST_SIZE;
166+ segment->copied = 0;
167+ segment->sg = NULL;
168+ segment->hash = NULL;
111169 }
112170
171+/**
172+ * iscsi_tcp_segment_done - check whether the segment is complete
173+ * @segment: iscsi segment to check
174+ * @recv: set to one of this is called from the recv path
175+ * @copied: number of bytes copied
176+ *
177+ * Check if we're done receiving this segment. If the receive
178+ * buffer is full but we expect more data, move on to the
179+ * next entry in the scatterlist.
180+ *
181+ * If the amount of data we received isn't a multiple of 4,
182+ * we will transparently receive the pad bytes, too.
183+ *
184+ * This function must be re-entrant.
185+ */
113186 static inline int
114−iscsi_hdr_extract(struct iscsi_tcp_conn *tcp_conn)
187+iscsi_tcp_segment_done(struct iscsi_segment *segment, int recv, unsigned copied)
115188 {
116− struct sk_buff *skb = tcp_conn->in.skb;
117−
118− tcp_conn->in.zero_copy_hdr = 0;
189+ static unsigned char padbuf[ISCSI_PAD_LEN];
190+ struct scatterlist sg;
191+ unsigned int pad;
119192
120− if (tcp_conn->in.copy >= tcp_conn->hdr_size &&
121− tcp_conn->in_progress == IN_PROGRESS_WAIT_HEADER) {
193+ debug_tcp("copied %u %u size %u %s\n", segment->copied, copied,
194+ segment->size, recv ? "recv" : "xmit");
195+ if (segment->hash && copied) {
122196 /*
123− * Zero-copy PDU Header: using connection context
124− * to store header pointer.
197+ * If a segment is kmapd we must unmap it before sending
198+ * to the crypto layer since that will try to kmap it again.
125199 */
126− if (skb_shinfo(skb)->frag_list == NULL &&
127− !skb_shinfo(skb)->nr_frags) {
128− tcp_conn->in.hdr = (struct iscsi_hdr *)
129− ((char*)skb->data + tcp_conn->in.offset);
130− tcp_conn->in.zero_copy_hdr = 1;
200+ iscsi_tcp_segment_unmap(segment);
201+
202+ if (!segment->data) {
203+ sg_init_table(&sg, 1);
204+ sg_set_page(&sg, sg_page(segment->sg), copied,
205+ segment->copied + segment->sg_offset +
206+ segment->sg->offset);
207+ } else
208+ sg_init_one(&sg, segment->data + segment->copied,
209+ copied);
210+ crypto_hash_update(segment->hash, &sg, copied);
211+ }
212+
213+ segment->copied += copied;
214+ if (segment->copied < segment->size) {
215+ iscsi_tcp_segment_map(segment, recv);
216+ return 0;
217+ }
218+
219+ segment->total_copied += segment->copied;
220+ segment->copied = 0;
221+ segment->size = 0;
222+
223+ /* Unmap the current scatterlist page, if there is one. */
224+ iscsi_tcp_segment_unmap(segment);
225+
226+ /* Do we have more scatterlist entries? */
227+ debug_tcp("total copied %u total size %u\n", segment->total_copied,
228+ segment->total_size);
229+ if (segment->total_copied < segment->total_size) {
230+ /* Proceed to the next entry in the scatterlist. */
231+ iscsi_tcp_segment_init_sg(segment, sg_next(segment->sg),
232+ 0);
233+ iscsi_tcp_segment_map(segment, recv);
234+ BUG_ON(segment->size == 0);
235+ return 0;
236+ }
237+
238+ /* Do we need to handle padding? */
239+ pad = iscsi_padding(segment->total_copied);
240+ if (pad != 0) {
241+ debug_tcp("consume %d pad bytes\n", pad);
242+ segment->total_size += pad;
243+ segment->size = pad;
244+ segment->data = padbuf;
245+ return 0;
246+ }
247+
248+ /*
249+ * Set us up for transferring the data digest. hdr digest
250+ * is completely handled in hdr done function.
251+ */
252+ if (segment->hash) {
253+ crypto_hash_final(segment->hash, segment->digest);
254+ iscsi_tcp_segment_splice_digest(segment,
255+ recv ? segment->recv_digest : segment->digest);
256+ return 0;
257+ }
258+
259+ return 1;
260+}
261+
262+/**
263+ * iscsi_tcp_xmit_segment - transmit segment
264+ * @tcp_conn: the iSCSI TCP connection
265+ * @segment: the buffer to transmnit
266+ *
267+ * This function transmits as much of the buffer as
268+ * the network layer will accept, and returns the number of
269+ * bytes transmitted.
270+ *
271+ * If CRC hashing is enabled, the function will compute the
272+ * hash as it goes. When the entire segment has been transmitted,
273+ * it will retrieve the hash value and send it as well.
274+ */
275+static int
276+iscsi_tcp_xmit_segment(struct iscsi_tcp_conn *tcp_conn,
277+ struct iscsi_segment *segment)
278+{
279+ struct socket *sk = tcp_conn->sock;
280+ unsigned int copied = 0;
281+ int r = 0;
282+
283+ while (!iscsi_tcp_segment_done(segment, 0, r)) {
284+ struct scatterlist *sg;
285+ unsigned int offset, copy;
286+ int flags = 0;
287+
288+ r = 0;
289+ offset = segment->copied;
290+ copy = segment->size - offset;
291+
292+ if (segment->total_copied + segment->size < segment->total_size)
293+ flags |= MSG_MORE;
294+
295+ /* Use sendpage if we can; else fall back to sendmsg */
296+ if (!segment->data) {
297+ sg = segment->sg;
298+ offset += segment->sg_offset + sg->offset;
299+ r = tcp_conn->sendpage(sk, sg_page(sg), offset, copy,
300+ flags);
131301 } else {
132− /* ignoring return code since we checked
133− * in.copy before */
134− skb_copy_bits(skb, tcp_conn->in.offset,
135− &tcp_conn->hdr, tcp_conn->hdr_size);
136− tcp_conn->in.hdr = &tcp_conn->hdr;
302+ struct msghdr msg = { .msg_flags = flags };
303+ struct kvec iov = {
304+ .iov_base = segment->data + offset,
305+ .iov_len = copy
306+ };
307+
308+ r = kernel_sendmsg(sk, &msg, &iov, 1, copy);
137309 }
138− tcp_conn->in.offset += tcp_conn->hdr_size;
139− tcp_conn->in.copy -= tcp_conn->hdr_size;
140− } else {
141− int hdr_remains;
142− int copylen;
143310
144− /*
145− * PDU header scattered across SKB's,
146− * copying it... This'll happen quite rarely.
147− */
311+ if (r < 0) {
312+ iscsi_tcp_segment_unmap(segment);
313+ if (copied || r == -EAGAIN)
314+ break;
315+ return r;
316+ }
317+ copied += r;
318+ }
319+ return copied;
320+}
321+
322+/**
323+ * iscsi_tcp_segment_recv - copy data to segment
324+ * @tcp_conn: the iSCSI TCP connection
325+ * @segment: the buffer to copy to
326+ * @ptr: data pointer
327+ * @len: amount of data available
328+ *
329+ * This function copies up to @len bytes to the
330+ * given buffer, and returns the number of bytes
331+ * consumed, which can actually be less than @len.
332+ *
333+ * If hash digest is enabled, the function will update the
334+ * hash while copying.
335+ * Combining these two operations doesn't buy us a lot (yet),
336+ * but in the future we could implement combined copy+crc,
337+ * just way we do for network layer checksums.
338+ */
339+static int
340+iscsi_tcp_segment_recv(struct iscsi_tcp_conn *tcp_conn,
341+ struct iscsi_segment *segment, const void *ptr,
342+ unsigned int len)
343+{
344+ unsigned int copy = 0, copied = 0;
148345
149− if (tcp_conn->in_progress == IN_PROGRESS_WAIT_HEADER)
150− tcp_conn->in.hdr_offset = 0;
346+ while (!iscsi_tcp_segment_done(segment, 1, copy)) {
347+ if (copied == len) {
348+ debug_tcp("iscsi_tcp_segment_recv copied %d bytes\n",
349+ len);
350+ break;
351+ }
151352
152− hdr_remains = tcp_conn->hdr_size - tcp_conn->in.hdr_offset;
153− BUG_ON(hdr_remains <= 0);
353+ copy = min(len - copied, segment->size - segment->copied);
354+ debug_tcp("iscsi_tcp_segment_recv copying %d\n", copy);
355+ memcpy(segment->data + segment->copied, ptr + copied, copy);
356+ copied += copy;
357+ }
358+ return copied;
359+}
154360
155− copylen = min(tcp_conn->in.copy, hdr_remains);
156− skb_copy_bits(skb, tcp_conn->in.offset,
157− (char*)&tcp_conn->hdr + tcp_conn->in.hdr_offset,
158− copylen);
361+static inline void
362+iscsi_tcp_dgst_header(struct hash_desc *hash, const void *hdr, size_t hdrlen,
363+ unsigned char digest[ISCSI_DIGEST_SIZE])
364+{
365+ struct scatterlist sg;
366+
367+ sg_init_one(&sg, hdr, hdrlen);
368+ crypto_hash_digest(hash, &sg, hdrlen, digest);
369+}
159370
160− debug_tcp("PDU gather offset %d bytes %d in.offset %d "
161− "in.copy %d\n", tcp_conn->in.hdr_offset, copylen,
162− tcp_conn->in.offset, tcp_conn->in.copy);
371+static inline int
372+iscsi_tcp_dgst_verify(struct iscsi_tcp_conn *tcp_conn,
373+ struct iscsi_segment *segment)
374+{
375+ if (!segment->digest_len)
376+ return 1;
163377
164− tcp_conn->in.offset += copylen;
165− tcp_conn->in.copy -= copylen;
166− if (copylen < hdr_remains) {
167− tcp_conn->in_progress = IN_PROGRESS_HEADER_GATHER;
168− tcp_conn->in.hdr_offset += copylen;
169− return -EAGAIN;
378+ if (memcmp(segment->recv_digest, segment->digest,
379+ segment->digest_len)) {
380+ debug_scsi("digest mismatch\n");
381+ return 0;
382+ }
383+
384+ return 1;
385+}
386+
387+/*
388+ * Helper function to set up segment buffer
389+ */
390+static inline void
391+__iscsi_segment_init(struct iscsi_segment *segment, size_t size,
392+ iscsi_segment_done_fn_t *done, struct hash_desc *hash)
393+{
394+ memset(segment, 0, sizeof(*segment));
395+ segment->total_size = size;
396+ segment->done = done;
397+
398+ if (hash) {
399+ segment->hash = hash;
400+ crypto_hash_init(hash);
401+ }
402+}
403+
404+static inline void
405+iscsi_segment_init_linear(struct iscsi_segment *segment, void *data,
406+ size_t size, iscsi_segment_done_fn_t *done,
407+ struct hash_desc *hash)
408+{
409+ __iscsi_segment_init(segment, size, done, hash);
410+ segment->data = data;
411+ segment->size = size;
412+}
413+
414+static inline int
415+iscsi_segment_seek_sg(struct iscsi_segment *segment,
416+ struct scatterlist *sg_list, unsigned int sg_count,
417+ unsigned int offset, size_t size,
418+ iscsi_segment_done_fn_t *done, struct hash_desc *hash)
419+{
420+ struct scatterlist *sg;
421+ unsigned int i;
422+
423+ debug_scsi("iscsi_segment_seek_sg offset %u size %llu\n",
424+ offset, size);
425+ __iscsi_segment_init(segment, size, done, hash);
426+ for_each_sg(sg_list, sg, sg_count, i) {
427+ debug_scsi("sg %d, len %u offset %u\n", i, sg->length,
428+ sg->offset);
429+ if (offset < sg->length) {
430+ iscsi_tcp_segment_init_sg(segment, sg, offset);
431+ return 0;
170432 }
171− tcp_conn->in.hdr = &tcp_conn->hdr;
172− tcp_conn->discontiguous_hdr_cnt++;
173− tcp_conn->in_progress = IN_PROGRESS_WAIT_HEADER;
433+ offset -= sg->length;
174434 }
175435
436+ return ISCSI_ERR_DATA_OFFSET;
437+}
438+
439+/**
440+ * iscsi_tcp_hdr_recv_prep - prep segment for hdr reception
441+ * @tcp_conn: iscsi connection to prep for
442+ *
443+ * This function always passes NULL for the hash argument, because when this
444+ * function is called we do not yet know the final size of the header and want
445+ * to delay the digest processing until we know that.
446+ */
447+static void
448+iscsi_tcp_hdr_recv_prep(struct iscsi_tcp_conn *tcp_conn)
449+{
450+ debug_tcp("iscsi_tcp_hdr_recv_prep(%p%s)\n", tcp_conn,
451+ tcp_conn->iscsi_conn->hdrdgst_en ? ", digest enabled" : "");
452+ iscsi_segment_init_linear(&tcp_conn->in.segment,
453+ tcp_conn->in.hdr_buf, sizeof(struct iscsi_hdr),
454+ iscsi_tcp_hdr_recv_done, NULL);
455+}
456+
457+/*
458+ * Handle incoming reply to any other type of command
459+ */
460+static int
461+iscsi_tcp_data_recv_done(struct iscsi_tcp_conn *tcp_conn,
462+ struct iscsi_segment *segment)
463+{
464+ struct iscsi_conn *conn = tcp_conn->iscsi_conn;
465+ int rc = 0;
466+
467+ if (!iscsi_tcp_dgst_verify(tcp_conn, segment))
468+ return ISCSI_ERR_DATA_DGST;
469+
470+ rc = iscsi_complete_pdu(conn, tcp_conn->in.hdr,
471+ conn->data, tcp_conn->in.datalen);
472+ if (rc)
473+ return rc;
474+
475+ iscsi_tcp_hdr_recv_prep(tcp_conn);
176476 return 0;
177477 }
178478
479+static void
480+iscsi_tcp_data_recv_prep(struct iscsi_tcp_conn *tcp_conn)
481+{
482+ struct iscsi_conn *conn = tcp_conn->iscsi_conn;
483+ struct hash_desc *rx_hash = NULL;
484+
485+ if (conn->datadgst_en)
486+ rx_hash = &tcp_conn->rx_hash;
487+
488+ iscsi_segment_init_linear(&tcp_conn->in.segment,
489+ conn->data, tcp_conn->in.datalen,
490+ iscsi_tcp_data_recv_done, rx_hash);
491+}
492+
179493 /*
180494 * must be called with session lock
181495 */
@@ -184,7 +498,6 @@ iscsi_tcp_cleanup_ctask(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask) · 2 unmodified lines
184498 {
185499 struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data;
186500 struct iscsi_r2t_info *r2t;
187− struct scsi_cmnd *sc;
188501
189502 /* flush ctask's r2t queues */
190503 while (__kfifo_get(tcp_ctask->r2tqueue, (void*)&r2t, sizeof(void*))) {
@@ -193,12 +506,12 @@ iscsi_tcp_cleanup_ctask(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask) · 2 unmodified lines
193506 debug_scsi("iscsi_tcp_cleanup_ctask pending r2t dropped\n");
194507 }
195508
196− sc = ctask->sc;
197− if (unlikely(!sc))
198− return;
199−
200− tcp_ctask->xmstate = XMSTATE_VALUE_IDLE;
201− tcp_ctask->r2t = NULL;
509+ r2t = tcp_ctask->r2t;
510+ if (r2t != NULL) {
511+ __kfifo_put(tcp_ctask->r2tpool.queue, (void*)&r2t,
512+ sizeof(void*));
513+ tcp_ctask->r2t = NULL;
514+ }
202515 }
203516
204517 /**
@@ -217,11 +530,6 @@ iscsi_data_rsp(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask) · 12 unmodified lines
217530 int datasn = be32_to_cpu(rhdr->datasn);
218531
219532 iscsi_update_cmdsn(session, (struct iscsi_nopin*)rhdr);
220− /*
221− * setup Data-In byte counter (gets decremented..)
222− */
223− ctask->data_count = tcp_conn->in.datalen;
224−
225533 if (tcp_conn->in.datalen == 0)
226534 return 0;
227535
@@ -242,22 +550,20 @@ iscsi_data_rsp(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask) · 14 unmodified lines
242550 }
243551
244552 if (rhdr->flags & ISCSI_FLAG_DATA_STATUS) {
553+ sc->result = (DID_OK << 16) | rhdr->cmd_status;
245554 conn->exp_statsn = be32_to_cpu(rhdr->statsn) + 1;
246− if (rhdr->flags & ISCSI_FLAG_DATA_UNDERFLOW) {
555+ if (rhdr->flags & (ISCSI_FLAG_DATA_UNDERFLOW |
556+ ISCSI_FLAG_DATA_OVERFLOW)) {
247557 int res_count = be32_to_cpu(rhdr->residual_count);
248558
249559 if (res_count > 0 &&
250− res_count <= scsi_bufflen(sc)) {
560+ (rhdr->flags & ISCSI_FLAG_CMD_OVERFLOW ||
561+ res_count <= scsi_bufflen(sc)))
251562 scsi_set_resid(sc, res_count);
252− sc->result = (DID_OK << 16) | rhdr->cmd_status;
253− } else
563+ else
254564 sc->result = (DID_BAD_TARGET << 16) |
255565 rhdr->cmd_status;
256− } else if (rhdr->flags & ISCSI_FLAG_DATA_OVERFLOW) {
257− scsi_set_resid(sc, be32_to_cpu(rhdr->residual_count));
258− sc->result = (DID_OK << 16) | rhdr->cmd_status;
259− } else
260− sc->result = (DID_OK << 16) | rhdr->cmd_status;
566+ }
261567 }
262568
263569 conn->datain_pdus_cnt++;
@@ -281,9 +587,6 @@ iscsi_solicit_data_init(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask, · 17 unmodified lines
281587 struct iscsi_r2t_info *r2t)
282588 {
283589 struct iscsi_data *hdr;
284− struct scsi_cmnd *sc = ctask->sc;
285− int i, sg_count = 0;
286− struct scatterlist *sg;
287590
288591 hdr = &r2t->dtask.hdr;
289592 memset(hdr, 0, sizeof(struct iscsi_data));
@@ -307,34 +610,6 @@ iscsi_solicit_data_init(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask, · 17 unmodified lines
307610 conn->dataout_pdus_cnt++;
308611
309612 r2t->sent = 0;
310−
311− iscsi_buf_init_iov(&r2t->headbuf, (char*)hdr,
312− sizeof(struct iscsi_hdr));
313−
314− sg = scsi_sglist(sc);
315− r2t->sg = NULL;
316− for (i = 0; i < scsi_sg_count(sc); i++, sg += 1) {
317− /* FIXME: prefetch ? */
318− if (sg_count + sg->length > r2t->data_offset) {
319− int page_offset;
320−
321− /* sg page found! */
322−
323− /* offset within this page */
324− page_offset = r2t->data_offset - sg_count;
325−
326− /* fill in this buffer */
327− iscsi_buf_init_sg(&r2t->sendbuf, sg);
328− r2t->sendbuf.sg.offset += page_offset;
329− r2t->sendbuf.sg.length -= page_offset;
330−
331− /* xmit logic will continue with next one */
332− r2t->sg = sg + 1;
333− break;
334− }
335− sg_count += sg->length;
336− }
337− BUG_ON(r2t->sg == NULL);
338613 }
339614
340615 /**
@@ -366,14 +641,11 @@ iscsi_r2t_rsp(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask) · 25 unmodified lines
366641 }
367642
368643 /* fill-in new R2T associated with the task */
369− spin_lock(&session->lock);
370644 iscsi_update_cmdsn(session, (struct iscsi_nopin*)rhdr);
371645
372− if (!ctask->sc || ctask->mtask ||
373− session->state != ISCSI_STATE_LOGGED_IN) {
646+ if (!ctask->sc || session->state != ISCSI_STATE_LOGGED_IN) {
374647 printk(KERN_INFO "iscsi_tcp: dropping R2T itt %d in "
375648 "recovery...\n", ctask->itt);
376− spin_unlock(&session->lock);
377649 return 0;
378650 }
379651
@@ -384,7 +656,8 @@ iscsi_r2t_rsp(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask) · 4 unmodified lines
384656 r2t->data_length = be32_to_cpu(rhdr->data_length);
385657 if (r2t->data_length == 0) {
386658 printk(KERN_ERR "iscsi_tcp: invalid R2T with zero data len\n");
387− spin_unlock(&session->lock);
659+ __kfifo_put(tcp_ctask->r2tpool.queue, (void*)&r2t,
660+ sizeof(void*));
388661 return ISCSI_ERR_DATALEN;
389662 }
390663
@@ -395,10 +668,11 @@ iscsi_r2t_rsp(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask) · 4 unmodified lines
395668
396669 r2t->data_offset = be32_to_cpu(rhdr->data_offset);
397670 if (r2t->data_offset + r2t->data_length > scsi_bufflen(ctask->sc)) {
398− spin_unlock(&session->lock);
399671 printk(KERN_ERR "iscsi_tcp: invalid R2T with data len %u at "
400672 "offset %u and total length %d\n", r2t->data_length,
401673 r2t->data_offset, scsi_bufflen(ctask->sc));
674+ __kfifo_put(tcp_ctask->r2tpool.queue, (void*)&r2t,
675+ sizeof(void*));
402676 return ISCSI_ERR_DATALEN;
403677 }
404678
@@ -409,26 +683,55 @@ iscsi_r2t_rsp(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask) · 4 unmodified lines
409683
410684 tcp_ctask->exp_datasn = r2tsn + 1;
411685 __kfifo_put(tcp_ctask->r2tqueue, (void*)&r2t, sizeof(void*));
412− set_bit(XMSTATE_BIT_SOL_HDR_INIT, &tcp_ctask->xmstate);
413− list_move_tail(&ctask->running, &conn->xmitqueue);
414−
415− scsi_queue_work(session->host, &conn->xmitwork);
416686 conn->r2t_pdus_cnt++;
417− spin_unlock(&session->lock);
418687
688+ iscsi_requeue_ctask(ctask);
419689 return 0;
420690 }
421691
692+/*
693+ * Handle incoming reply to DataIn command
694+ */
422695 static int
423−iscsi_tcp_hdr_recv(struct iscsi_conn *conn)
696+iscsi_tcp_process_data_in(struct iscsi_tcp_conn *tcp_conn,
697+ struct iscsi_segment *segment)
698+{
699+ struct iscsi_conn *conn = tcp_conn->iscsi_conn;
700+ struct iscsi_hdr *hdr = tcp_conn->in.hdr;
701+ int rc;
702+
703+ if (!iscsi_tcp_dgst_verify(tcp_conn, segment))
704+ return ISCSI_ERR_DATA_DGST;
705+
706+ /* check for non-exceptional status */
707+ if (hdr->flags & ISCSI_FLAG_DATA_STATUS) {
708+ rc = iscsi_complete_pdu(conn, tcp_conn->in.hdr, NULL, 0);
709+ if (rc)
710+ return rc;
711+ }
712+
713+ iscsi_tcp_hdr_recv_prep(tcp_conn);
714+ return 0;
715+}
716+
717+/**
718+ * iscsi_tcp_hdr_dissect - process PDU header
719+ * @conn: iSCSI connection
720+ * @hdr: PDU header
721+ *
722+ * This function analyzes the header of the PDU received,
723+ * and performs several sanity checks. If the PDU is accompanied
724+ * by data, the receive buffer is set up to copy the incoming data
725+ * to the correct location.
726+ */
727+static int
728+iscsi_tcp_hdr_dissect(struct iscsi_conn *conn, struct iscsi_hdr *hdr)
424729 {
425730 int rc = 0, opcode, ahslen;
426− struct iscsi_hdr *hdr;
427731 struct iscsi_session *session = conn->session;
428732 struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
429− uint32_t cdgst, rdgst = 0, itt;
430−
431− hdr = tcp_conn->in.hdr;
733+ struct iscsi_cmd_task *ctask;
734+ uint32_t itt;
432735
433736 /* verify PDU length */
434737 tcp_conn->in.datalen = ntoh24(hdr->dlength);
@@ -437,78 +740,73 @@ iscsi_tcp_hdr_recv(struct iscsi_conn *conn) · 2 unmodified lines
437740 tcp_conn->in.datalen, conn->max_recv_dlength);
438741 return ISCSI_ERR_DATALEN;
439742 }
440− tcp_conn->data_copied = 0;
441743
442− /* read AHS */
744+ /* Additional header segments. So far, we don't
745+ * process additional headers.
746+ */
443747 ahslen = hdr->hlength << 2;
444− tcp_conn->in.offset += ahslen;
445− tcp_conn->in.copy -= ahslen;
446− if (tcp_conn->in.copy < 0) {
447− printk(KERN_ERR "iscsi_tcp: can't handle AHS with length "
448− "%d bytes\n", ahslen);
449− return ISCSI_ERR_AHSLEN;
450− }
451−
452− /* calculate read padding */
453− tcp_conn->in.padding = tcp_conn->in.datalen & (ISCSI_PAD_LEN-1);
454− if (tcp_conn->in.padding) {
455− tcp_conn->in.padding = ISCSI_PAD_LEN - tcp_conn->in.padding;
456− debug_scsi("read padding %d bytes\n", tcp_conn->in.padding);
457− }
458−
459− if (conn->hdrdgst_en) {
460− struct scatterlist sg;
461−
462− sg_init_one(&sg, (u8 *)hdr,
463− sizeof(struct iscsi_hdr) + ahslen);
464− crypto_hash_digest(&tcp_conn->rx_hash, &sg, sg.length,
465− (u8 *)&cdgst);
466− rdgst = *(uint32_t*)((char*)hdr + sizeof(struct iscsi_hdr) +
467− ahslen);
468− if (cdgst != rdgst) {
469− printk(KERN_ERR "iscsi_tcp: hdrdgst error "
470− "recv 0x%x calc 0x%x\n", rdgst, cdgst);
471− return ISCSI_ERR_HDR_DGST;
472− }
473− }
474748
475749 opcode = hdr->opcode & ISCSI_OPCODE_MASK;
476750 /* verify itt (itt encoding: age+cid+itt) */
477751 rc = iscsi_verify_itt(conn, hdr, &itt);
478− if (rc == ISCSI_ERR_NO_SCSI_CMD) {
479− tcp_conn->in.datalen = 0; /* force drop */
480− return 0;
481− } else if (rc)
752+ if (rc)
482753 return rc;
483754
484− debug_tcp("opcode 0x%x offset %d copy %d ahslen %d datalen %d\n",
485− opcode, tcp_conn->in.offset, tcp_conn->in.copy,
486− ahslen, tcp_conn->in.datalen);
755+ debug_tcp("opcode 0x%x ahslen %d datalen %d\n",
756+ opcode, ahslen, tcp_conn->in.datalen);
487757
488758 switch(opcode) {
489759 case ISCSI_OP_SCSI_DATA_IN:
490− tcp_conn->in.ctask = session->cmds[itt];
491− rc = iscsi_data_rsp(conn, tcp_conn->in.ctask);
760+ ctask = session->cmds[itt];
761+ spin_lock(&conn->session->lock);
762+ rc = iscsi_data_rsp(conn, ctask);
763+ spin_unlock(&conn->session->lock);
492764 if (rc)
493765 return rc;
766+ if (tcp_conn->in.datalen) {
767+ struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data;
768+ struct hash_desc *rx_hash = NULL;
769+
770+ /*
771+ * Setup copy of Data-In into the Scsi_Cmnd
772+ * Scatterlist case:
773+ * We set up the iscsi_segment to point to the next
774+ * scatterlist entry to copy to. As we go along,
775+ * we move on to the next scatterlist entry and
776+ * update the digest per-entry.
777+ */
778+ if (conn->datadgst_en)
779+ rx_hash = &tcp_conn->rx_hash;
780+
781+ debug_tcp("iscsi_tcp_begin_data_in(%p, offset=%d, "
782+ "datalen=%d)\n", tcp_conn,
783+ tcp_ctask->data_offset,
784+ tcp_conn->in.datalen);
785+ return iscsi_segment_seek_sg(&tcp_conn->in.segment,
786+ scsi_sglist(ctask->sc),
787+ scsi_sg_count(ctask->sc),
788+ tcp_ctask->data_offset,
789+ tcp_conn->in.datalen,
790+ iscsi_tcp_process_data_in,
791+ rx_hash);
792+ }
494793 /* fall through */
495794 case ISCSI_OP_SCSI_CMD_RSP:
496− tcp_conn->in.ctask = session->cmds[itt];
497− if (tcp_conn->in.datalen)
498− goto copy_hdr;
499−
500− spin_lock(&session->lock);
501− rc = __iscsi_complete_pdu(conn, hdr, NULL, 0);
502− spin_unlock(&session->lock);
795+ if (tcp_conn->in.datalen) {
796+ iscsi_tcp_data_recv_prep(tcp_conn);
797+ return 0;
798+ }
799+ rc = iscsi_complete_pdu(conn, hdr, NULL, 0);
503800 break;
504801 case ISCSI_OP_R2T:
505− tcp_conn->in.ctask = session->cmds[itt];
802+ ctask = session->cmds[itt];
506803 if (ahslen)
507804 rc = ISCSI_ERR_AHSLEN;
508− else if (tcp_conn->in.ctask->sc->sc_data_direction ==
509− DMA_TO_DEVICE)
510− rc = iscsi_r2t_rsp(conn, tcp_conn->in.ctask);
511− else
805+ else if (ctask->sc->sc_data_direction == DMA_TO_DEVICE) {
806+ spin_lock(&session->lock);
807+ rc = iscsi_r2t_rsp(conn, ctask);
808+ spin_unlock(&session->lock);
809+ } else
512810 rc = ISCSI_ERR_PROTO;
513811 break;
514812 case ISCSI_OP_LOGIN_RSP:
@@ -520,8 +818,7 @@ iscsi_tcp_hdr_recv(struct iscsi_conn *conn) · 5 unmodified lines
520818 * than 8K, but there are no targets that currently do this.
521819 * For now we fail until we find a vendor that needs it
522820 */
523− if (ISCSI_DEF_MAX_RECV_SEG_LEN <
524− tcp_conn->in.datalen) {
821+ if (ISCSI_DEF_MAX_RECV_SEG_LEN < tcp_conn->in.datalen) {
525822 printk(KERN_ERR "iscsi_tcp: received buffer of len %u "
526823 "but conn buffer is only %u (opcode %0x)\n",
527824 tcp_conn->in.datalen,
@@ -530,8 +827,13 @@ iscsi_tcp_hdr_recv(struct iscsi_conn *conn) · 2 unmodified lines
530827 break;
531828 }
532829
533− if (tcp_conn->in.datalen)
534− goto copy_hdr;
830+ /* If there's data coming in with the response,
831+ * receive it to the connection's buffer.
832+ */
833+ if (tcp_conn->in.datalen) {
834+ iscsi_tcp_data_recv_prep(tcp_conn);
835+ return 0;
836+ }
535837 /* fall through */
536838 case ISCSI_OP_LOGOUT_RSP:
537839 case ISCSI_OP_NOOP_IN:
@@ -543,461 +845,161 @@ iscsi_tcp_hdr_recv(struct iscsi_conn *conn) · 5 unmodified lines
543845 break;
544846 }
545847
546− return rc;
547−
548−copy_hdr:
549− /*
550− * if we did zero copy for the header but we will need multiple
551− * skbs to complete the command then we have to copy the header
552− * for later use
553− */
554− if (tcp_conn->in.zero_copy_hdr && tcp_conn->in.copy <=
555− (tcp_conn->in.datalen + tcp_conn->in.padding +
556− (conn->datadgst_en ? 4 : 0))) {
557− debug_tcp("Copying header for later use. in.copy %d in.datalen"
558− " %d\n", tcp_conn->in.copy, tcp_conn->in.datalen);
559− memcpy(&tcp_conn->hdr, tcp_conn->in.hdr,
560− sizeof(struct iscsi_hdr));
561− tcp_conn->in.hdr = &tcp_conn->hdr;
562− tcp_conn->in.zero_copy_hdr = 0;
563− }
564− return 0;
565−}
566−
567−/**
568− * iscsi_ctask_copy - copy skb bits to the destanation cmd task
569− * @conn: iscsi tcp connection
570− * @ctask: scsi command task
571− * @buf: buffer to copy to
572− * @buf_size: size of buffer
573− * @offset: offset within the buffer
574− *
575− * Notes:
576− * The function calls skb_copy_bits() and updates per-connection and
577− * per-cmd byte counters.
578− *
579− * Read counters (in bytes):
580− *
581− * conn->in.offset offset within in progress SKB
582− * conn->in.copy left to copy from in progress SKB
583− * including padding
584− * conn->in.copied copied already from in progress SKB
585− * conn->data_copied copied already from in progress buffer
586− * ctask->sent total bytes sent up to the MidLayer
587− * ctask->data_count left to copy from in progress Data-In
588− * buf_left left to copy from in progress buffer
589− **/
590−static inline int
591−iscsi_ctask_copy(struct iscsi_tcp_conn *tcp_conn, struct iscsi_cmd_task *ctask,
592− void *buf, int buf_size, int offset)
593−{
594− struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data;
595− int buf_left = buf_size - (tcp_conn->data_copied + offset);
596− unsigned size = min(tcp_conn->in.copy, buf_left);
597− int rc;
598−
599− size = min(size, ctask->data_count);
600−
601− debug_tcp("ctask_copy %d bytes at offset %d copied %d\n",
602− size, tcp_conn->in.offset, tcp_conn->in.copied);
603−
604− BUG_ON(size <= 0);
605− BUG_ON(tcp_ctask->sent + size > scsi_bufflen(ctask->sc));
606−
607− rc = skb_copy_bits(tcp_conn->in.skb, tcp_conn->in.offset,
608− (char*)buf + (offset + tcp_conn->data_copied), size);
609− /* must fit into skb->len */
610− BUG_ON(rc);
611−
612− tcp_conn->in.offset += size;
613− tcp_conn->in.copy -= size;
614− tcp_conn->in.copied += size;
615− tcp_conn->data_copied += size;
616− tcp_ctask->sent += size;
617− ctask->data_count -= size;
618−
619− BUG_ON(tcp_conn->in.copy < 0);
620− BUG_ON(ctask->data_count < 0);
621−
622− if (buf_size != (tcp_conn->data_copied + offset)) {
623− if (!ctask->data_count) {
624− BUG_ON(buf_size - tcp_conn->data_copied < 0);
625− /* done with this PDU */
626− return buf_size - tcp_conn->data_copied;
627− }
628− return -EAGAIN;
848+ if (rc == 0) {
849+ /* Anything that comes with data should have
850+ * been handled above. */
851+ if (tcp_conn->in.datalen)
852+ return ISCSI_ERR_PROTO;
853+ iscsi_tcp_hdr_recv_prep(tcp_conn);
629854 }
630855
631− /* done with this buffer or with both - PDU and buffer */
632− tcp_conn->data_copied = 0;
633− return 0;
856+ return rc;
634857 }
635858
636859 /**
637− * iscsi_tcp_copy - copy skb bits to the destanation buffer
638− * @conn: iscsi tcp connection
860+ * iscsi_tcp_hdr_recv_done - process PDU header
639861 *
640− * Notes:
641− * The function calls skb_copy_bits() and updates per-connection
642− * byte counters.
643− **/
644−static inline int
645−iscsi_tcp_copy(struct iscsi_conn *conn, int buf_size)
646−{
647− struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
648− int buf_left = buf_size - tcp_conn->data_copied;
649− int size = min(tcp_conn->in.copy, buf_left);
650− int rc;
651−
652− debug_tcp("tcp_copy %d bytes at offset %d copied %d\n",
653− size, tcp_conn->in.offset, tcp_conn->data_copied);
654− BUG_ON(size <= 0);
655−
656− rc = skb_copy_bits(tcp_conn->in.skb, tcp_conn->in.offset,
657− (char*)conn->data + tcp_conn->data_copied, size);
658− BUG_ON(rc);
659−
660− tcp_conn->in.offset += size;
661− tcp_conn->in.copy -= size;
662− tcp_conn->in.copied += size;
663− tcp_conn->data_copied += size;
664−
665− if (buf_size != tcp_conn->data_copied)
666− return -EAGAIN;
667−
668− return 0;
669−}
670−
671−static inline void
672−partial_sg_digest_update(struct hash_desc *desc, struct scatterlist *sg,
673− int offset, int length)
674−{
675− struct scatterlist temp;
676−
677− sg_init_table(&temp, 1);
678− sg_set_page(&temp, sg_page(sg), length, offset);
679− crypto_hash_update(desc, &temp, length);
680−}
681−
682−static void
683−iscsi_recv_digest_update(struct iscsi_tcp_conn *tcp_conn, char* buf, int len)
684−{
685− struct scatterlist tmp;
686−
687− sg_init_one(&tmp, buf, len);
688− crypto_hash_update(&tcp_conn->rx_hash, &tmp, len);
689−}
690−
691−static int iscsi_scsi_data_in(struct iscsi_conn *conn)
862+ * This is the callback invoked when the PDU header has
863+ * been received. If the header is followed by additional
864+ * header segments, we go back for more data.
865+ */
866+static int
867+iscsi_tcp_hdr_recv_done(struct iscsi_tcp_conn *tcp_conn,
868+ struct iscsi_segment *segment)
692869 {
693− struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
694− struct iscsi_cmd_task *ctask = tcp_conn->in.ctask;
695− struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data;
696− struct scsi_cmnd *sc = ctask->sc;
697− struct scatterlist *sg;
698− int i, offset, rc = 0;
699−
700− BUG_ON((void*)ctask != sc->SCp.ptr);
701−
702− offset = tcp_ctask->data_offset;
703− sg = scsi_sglist(sc);
704−
705− if (tcp_ctask->data_offset)
706− for (i = 0; i < tcp_ctask->sg_count; i++)
707− offset -= sg[i].length;
708− /* we've passed through partial sg*/
709− if (offset < 0)
710− offset = 0;
711−
712− for (i = tcp_ctask->sg_count; i < scsi_sg_count(sc); i++) {
713− char *dest;
714−
715− dest = kmap_atomic(sg_page(&sg[i]), KM_SOFTIRQ0);
716− rc = iscsi_ctask_copy(tcp_conn, ctask, dest + sg[i].offset,
717− sg[i].length, offset);
718− kunmap_atomic(dest, KM_SOFTIRQ0);
719− if (rc == -EAGAIN)
720− /* continue with the next SKB/PDU */
721− return rc;
722− if (!rc) {
723− if (conn->datadgst_en) {
724− if (!offset)
725− crypto_hash_update(
726− &tcp_conn->rx_hash,
727− &sg[i], sg[i].length);
728− else
729− partial_sg_digest_update(
730− &tcp_conn->rx_hash,
731− &sg[i],
732− sg[i].offset + offset,
733− sg[i].length - offset);
734− }
735− offset = 0;
736− tcp_ctask->sg_count++;
737− }
738−
739− if (!ctask->data_count) {
740− if (rc && conn->datadgst_en)
741− /*
742− * data-in is complete, but buffer not...
743− */
744− partial_sg_digest_update(&tcp_conn->rx_hash,
745− &sg[i],
746− sg[i].offset,
747− sg[i].length-rc);
748− rc = 0;
749− break;
750− }
751−
752− if (!tcp_conn->in.copy)
753− return -EAGAIN;
754− }
755− BUG_ON(ctask->data_count);
870+ struct iscsi_conn *conn = tcp_conn->iscsi_conn;
871+ struct iscsi_hdr *hdr;
756872
757− /* check for non-exceptional status */
758− if (tcp_conn->in.hdr->flags & ISCSI_FLAG_DATA_STATUS) {
759− debug_scsi("done [sc %lx res %d itt 0x%x flags 0x%x]\n",
760− (long)sc, sc->result, ctask->itt,
761− tcp_conn->in.hdr->flags);
762− spin_lock(&conn->session->lock);
763− __iscsi_complete_pdu(conn, tcp_conn->in.hdr, NULL, 0);
764− spin_unlock(&conn->session->lock);
873+ /* Check if there are additional header segments
874+ * *prior* to computing the digest, because we
875+ * may need to go back to the caller for more.
876+ */
877+ hdr = (struct iscsi_hdr *) tcp_conn->in.hdr_buf;
878+ if (segment->copied == sizeof(struct iscsi_hdr) && hdr->hlength) {
879+ /* Bump the header length - the caller will
880+ * just loop around and get the AHS for us, and
881+ * call again. */
882+ unsigned int ahslen = hdr->hlength << 2;
883+
884+ /* Make sure we don't overflow */
885+ if (sizeof(*hdr) + ahslen > sizeof(tcp_conn->in.hdr_buf))
886+ return ISCSI_ERR_AHSLEN;
887+
888+ segment->total_size += ahslen;
889+ segment->size += ahslen;
890+ return 0;
765891 }
766892
767− return rc;
768−}
769−
770−static int
771−iscsi_data_recv(struct iscsi_conn *conn)
772−{
773− struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
774− int rc = 0, opcode;
775−
776− opcode = tcp_conn->in.hdr->opcode & ISCSI_OPCODE_MASK;
777− switch (opcode) {
778− case ISCSI_OP_SCSI_DATA_IN:
779− rc = iscsi_scsi_data_in(conn);
780− break;
781− case ISCSI_OP_SCSI_CMD_RSP:
782− case ISCSI_OP_TEXT_RSP:
783− case ISCSI_OP_LOGIN_RSP:
784− case ISCSI_OP_ASYNC_EVENT:
785− case ISCSI_OP_REJECT:
786− /*
787− * Collect data segment to the connection's data
788− * placeholder
789− */
790− if (iscsi_tcp_copy(conn, tcp_conn->in.datalen)) {
791− rc = -EAGAIN;
792− goto exit;
893+ /* We're done processing the header. See if we're doing
894+ * header digests; if so, set up the recv_digest buffer
895+ * and go back for more. */
896+ if (conn->hdrdgst_en) {
897+ if (segment->digest_len == 0) {
898+ iscsi_tcp_segment_splice_digest(segment,
899+ segment->recv_digest);
900+ return 0;
793901 }
902+ iscsi_tcp_dgst_header(&tcp_conn->rx_hash, hdr,
903+ segment->total_copied - ISCSI_DIGEST_SIZE,
904+ segment->digest);
794905
795− rc = iscsi_complete_pdu(conn, tcp_conn->in.hdr, conn->data,
796− tcp_conn->in.datalen);
797− if (!rc && conn->datadgst_en && opcode != ISCSI_OP_LOGIN_RSP)
798− iscsi_recv_digest_update(tcp_conn, conn->data,
799− tcp_conn->in.datalen);
800− break;
801− default:
802− BUG_ON(1);
906+ if (!iscsi_tcp_dgst_verify(tcp_conn, segment))
907+ return ISCSI_ERR_HDR_DGST;
803908 }
804−exit:
805− return rc;
909+
910+ tcp_conn->in.hdr = hdr;
911+ return iscsi_tcp_hdr_dissect(conn, hdr);
806912 }
807913
808914 /**
809− * iscsi_tcp_data_recv - TCP receive in sendfile fashion
915+ * iscsi_tcp_recv - TCP receive in sendfile fashion
810916 * @rd_desc: read descriptor
811917 * @skb: socket buffer
812918 * @offset: offset in skb
813919 * @len: skb->len - offset
814920 **/
815921 static int
816−iscsi_tcp_data_recv(read_descriptor_t *rd_desc, struct sk_buff *skb,
817− unsigned int offset, size_t len)
922+iscsi_tcp_recv(read_descriptor_t *rd_desc, struct sk_buff *skb,
923+ unsigned int offset, size_t len)
818924 {
819− int rc;
820925 struct iscsi_conn *conn = rd_desc->arg.data;
821926 struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
822− int processed;
823− char pad[ISCSI_PAD_LEN];
824− struct scatterlist sg;
825−
826− /*
827− * Save current SKB and its offset in the corresponding
828− * connection context.
829− */
830− tcp_conn->in.copy = skb->len - offset;
831− tcp_conn->in.offset = offset;
832− tcp_conn->in.skb = skb;
833− tcp_conn->in.len = tcp_conn->in.copy;
834− BUG_ON(tcp_conn->in.copy <= 0);
835− debug_tcp("in %d bytes\n", tcp_conn->in.copy);
927+ struct iscsi_segment *segment = &tcp_conn->in.segment;
928+ struct skb_seq_state seq;
929+ unsigned int consumed = 0;
930+ int rc = 0;
836931
837−more:
838− tcp_conn->in.copied = 0;
839− rc = 0;
932+ debug_tcp("in %d bytes\n", skb->len - offset);
840933
841934 if (unlikely(conn->suspend_rx)) {
842935 debug_tcp("conn %d Rx suspended!\n", conn->id);
843936 return 0;
844937 }
845938
846− if (tcp_conn->in_progress == IN_PROGRESS_WAIT_HEADER ||
847− tcp_conn->in_progress == IN_PROGRESS_HEADER_GATHER) {
848− rc = iscsi_hdr_extract(tcp_conn);
849− if (rc) {
850− if (rc == -EAGAIN)
851− goto nomore;
852− else {
853− iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
854− return 0;
855− }
856− }
939+ skb_prepare_seq_read(skb, offset, skb->len, &seq);
940+ while (1) {
941+ unsigned int avail;
942+ const u8 *ptr;
857943
858− /*
859− * Verify and process incoming PDU header.
860− */
861− rc = iscsi_tcp_hdr_recv(conn);
862− if (!rc && tcp_conn->in.datalen) {
863− if (conn->datadgst_en)
864− crypto_hash_init(&tcp_conn->rx_hash);
865− tcp_conn->in_progress = IN_PROGRESS_DATA_RECV;
866− } else if (rc) {
867− iscsi_conn_failure(conn, rc);
868− return 0;
944+ avail = skb_seq_read(consumed, &ptr, &seq);
945+ if (avail == 0) {
946+ debug_tcp("no more data avail. Consumed %d\n",
947+ consumed);
948+ break;
869949 }
870− }
871−
872− if (tcp_conn->in_progress == IN_PROGRESS_DDIGEST_RECV &&
873− tcp_conn->in.copy) {
874− uint32_t recv_digest;
875−
876− debug_tcp("extra data_recv offset %d copy %d\n",
877− tcp_conn->in.offset, tcp_conn->in.copy);
878−
879− if (!tcp_conn->data_copied) {
880− if (tcp_conn->in.padding) {
881− debug_tcp("padding -> %d\n",
882− tcp_conn->in.padding);
883− memset(pad, 0, tcp_conn->in.padding);
884− sg_init_one(&sg, pad, tcp_conn->in.padding);
885− crypto_hash_update(&tcp_conn->rx_hash,
886− &sg, sg.length);
950+ BUG_ON(segment->copied >= segment->size);
951+
952+ debug_tcp("skb %p ptr=%p avail=%u\n", skb, ptr, avail);
953+ rc = iscsi_tcp_segment_recv(tcp_conn, segment, ptr, avail);
954+ BUG_ON(rc == 0);
955+ consumed += rc;
956+
957+ if (segment->total_copied >= segment->total_size) {
958+ debug_tcp("segment done\n");
959+ rc = segment->done(tcp_conn, segment);
960+ if (rc != 0) {
961+ skb_abort_seq_read(&seq);
962+ goto error;
887963 }
888− crypto_hash_final(&tcp_conn->rx_hash,
889− (u8 *) &tcp_conn->in.datadgst);
890− debug_tcp("rx digest 0x%x\n", tcp_conn->in.datadgst);
891− }
892964
893− rc = iscsi_tcp_copy(conn, sizeof(uint32_t));
894− if (rc) {
895− if (rc == -EAGAIN)
896− goto again;
897− iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
898− return 0;
899− }
900−
901− memcpy(&recv_digest, conn->data, sizeof(uint32_t));
902− if (recv_digest != tcp_conn->in.datadgst) {
903− debug_tcp("iscsi_tcp: data digest error!"
904− "0x%x != 0x%x\n", recv_digest,
905− tcp_conn->in.datadgst);
906− iscsi_conn_failure(conn, ISCSI_ERR_DATA_DGST);
907− return 0;
908− } else {
909− debug_tcp("iscsi_tcp: data digest match!"
910− "0x%x == 0x%x\n", recv_digest,
911− tcp_conn->in.datadgst);
912− tcp_conn->in_progress = IN_PROGRESS_WAIT_HEADER;
965+ /* The done() functions sets up the
966+ * next segment. */
913967 }
914968 }
969+ skb_abort_seq_read(&seq);
970+ conn->rxdata_octets += consumed;
971+ return consumed;
915972
916− if (tcp_conn->in_progress == IN_PROGRESS_DATA_RECV &&
917− tcp_conn->in.copy) {
918− debug_tcp("data_recv offset %d copy %d\n",
919− tcp_conn->in.offset, tcp_conn->in.copy);
920−
921− rc = iscsi_data_recv(conn);
922− if (rc) {
923− if (rc == -EAGAIN)
924− goto again;
925− iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
926− return 0;
927− }
928−
929− if (tcp_conn->in.padding)
930− tcp_conn->in_progress = IN_PROGRESS_PAD_RECV;
931− else if (conn->datadgst_en)
932− tcp_conn->in_progress = IN_PROGRESS_DDIGEST_RECV;
933− else
934− tcp_conn->in_progress = IN_PROGRESS_WAIT_HEADER;
935− tcp_conn->data_copied = 0;
936− }
937−
938− if (tcp_conn->in_progress == IN_PROGRESS_PAD_RECV &&
939− tcp_conn->in.copy) {
940− int copylen = min(tcp_conn->in.padding - tcp_conn->data_copied,
941− tcp_conn->in.copy);
942−
943− tcp_conn->in.copy -= copylen;
944− tcp_conn->in.offset += copylen;
945− tcp_conn->data_copied += copylen;
946−
947− if (tcp_conn->data_copied != tcp_conn->in.padding)
948− tcp_conn->in_progress = IN_PROGRESS_PAD_RECV;
949− else if (conn->datadgst_en)
950− tcp_conn->in_progress = IN_PROGRESS_DDIGEST_RECV;
951− else
952− tcp_conn->in_progress = IN_PROGRESS_WAIT_HEADER;
953− tcp_conn->data_copied = 0;
954− }
955−
956− debug_tcp("f, processed %d from out of %d padding %d\n",
957− tcp_conn->in.offset - offset, (int)len, tcp_conn->in.padding);
958− BUG_ON(tcp_conn->in.offset - offset > len);
959−
960− if (tcp_conn->in.offset - offset != len) {
961− debug_tcp("continue to process %d bytes\n",
962− (int)len - (tcp_conn->in.offset - offset));
963− goto more;
964− }
965−
966−nomore:
967− processed = tcp_conn->in.offset - offset;
968− BUG_ON(processed == 0);
969− return processed;
970−
971−again:
972− processed = tcp_conn->in.offset - offset;
973− debug_tcp("c, processed %d from out of %d rd_desc_cnt %d\n",
974− processed, (int)len, (int)rd_desc->count);
975− BUG_ON(processed == 0);
976− BUG_ON(processed > len);
977−
978− conn->rxdata_octets += processed;
979− return processed;
973+error:
974+ debug_tcp("Error receiving PDU, errno=%d\n", rc);
975+ iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
976+ return 0;
980977 }
981978
982979 static void
983980 iscsi_tcp_data_ready(struct sock *sk, int flag)
984981 {
985982 struct iscsi_conn *conn = sk->sk_user_data;
983+ struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
986984 read_descriptor_t rd_desc;
987985
988986 read_lock(&sk->sk_callback_lock);
989987
990988 /*
991− * Use rd_desc to pass 'conn' to iscsi_tcp_data_recv.
989+ * Use rd_desc to pass 'conn' to iscsi_tcp_recv.
992990 * We set count to 1 because we want the network layer to
993− * hand us all the skbs that are available. iscsi_tcp_data_recv
991+ * hand us all the skbs that are available. iscsi_tcp_recv
994992 * handled pdus that cross buffers or pdus that still need data.
995993 */
996994 rd_desc.arg.data = conn;
997995 rd_desc.count = 1;
998− tcp_read_sock(sk, &rd_desc, iscsi_tcp_data_recv);
996+ tcp_read_sock(sk, &rd_desc, iscsi_tcp_recv);
999997
1000998 read_unlock(&sk->sk_callback_lock);
999+
1000+ /* If we had to (atomically) map a highmem page,
1001+ * unmap it now. */
1002+ iscsi_tcp_segment_unmap(&tcp_conn->in.segment);
10011003 }
10021004
10031005 static void
@@ -1077,121 +1079,173 @@ iscsi_conn_restore_callbacks(struct iscsi_tcp_conn *tcp_conn) · 73 unmodified lines
10771079 }
10781080
10791081 /**
1080− * iscsi_send - generic send routine
1081− * @sk: kernel's socket
1082− * @buf: buffer to write from
1083− * @size: actual size to write
1084− * @flags: socket's flags
1082+ * iscsi_xmit - TCP transmit
1083+ **/
1084+static int
1085+iscsi_xmit(struct iscsi_conn *conn)
1086+{
1087+ struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
1088+ struct iscsi_segment *segment = &tcp_conn->out.segment;
1089+ unsigned int consumed = 0;
1090+ int rc = 0;
1091+
1092+ while (1) {
1093+ rc = iscsi_tcp_xmit_segment(tcp_conn, segment);
1094+ if (rc < 0)
1095+ goto error;
1096+ if (rc == 0)
1097+ break;
1098+
1099+ consumed += rc;
1100+
1101+ if (segment->total_copied >= segment->total_size) {
1102+ if (segment->done != NULL) {
1103+ rc = segment->done(tcp_conn, segment);
1104+ if (rc < 0)
1105+ goto error;
1106+ }
1107+ }
1108+ }
1109+
1110+ debug_tcp("xmit %d bytes\n", consumed);
1111+
1112+ conn->txdata_octets += consumed;
1113+ return consumed;
1114+
1115+error:
1116+ /* Transmit error. We could initiate error recovery
1117+ * here. */
1118+ debug_tcp("Error sending PDU, errno=%d\n", rc);
1119+ iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
1120+ return rc;
1121+}
1122+
1123+/**
1124+ * iscsi_tcp_xmit_qlen - return the number of bytes queued for xmit
10851125 */
10861126 static inline int
1087−iscsi_send(struct iscsi_conn *conn, struct iscsi_buf *buf, int size, int flags)
1127+iscsi_tcp_xmit_qlen(struct iscsi_conn *conn)
10881128 {
10891129 struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
1090− struct socket *sk = tcp_conn->sock;
1091− int offset = buf->sg.offset + buf->sent, res;
1130+ struct iscsi_segment *segment = &tcp_conn->out.segment;
10921131
1093− /*
1094− * if we got use_sg=0 or are sending something we kmallocd
1095− * then we did not have to do kmap (kmap returns page_address)
1096− *
1097− * if we got use_sg > 0, but had to drop down, we do not
1098− * set clustering so this should only happen for that
1099− * slab case.
1132+ return segment->total_copied - segment->total_size;
1133+}
1134+
1135+static inline int
1136+iscsi_tcp_flush(struct iscsi_conn *conn)
1137+{
1138+ int rc;
1139+
1140+ while (iscsi_tcp_xmit_qlen(conn)) {
1141+ rc = iscsi_xmit(conn);
1142+ if (rc == 0)
1143+ return -EAGAIN;
1144+ if (rc < 0)
1145+ return rc;
1146+ }
1147+
1148+ return 0;
1149+}
1150+
1151+/*
1152+ * This is called when we're done sending the header.
1153+ * Simply copy the data_segment to the send segment, and return.
1154+ */
1155+static int
1156+iscsi_tcp_send_hdr_done(struct iscsi_tcp_conn *tcp_conn,
1157+ struct iscsi_segment *segment)
1158+{
1159+ tcp_conn->out.segment = tcp_conn->out.data_segment;
1160+ debug_tcp("Header done. Next segment size %u total_size %u\n",
1161+ tcp_conn->out.segment.size, tcp_conn->out.segment.total_size);
1162+ return 0;
1163+}
1164+
1165+static void
1166+iscsi_tcp_send_hdr_prep(struct iscsi_conn *conn, void *hdr, size_t hdrlen)
1167+{
1168+ struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
1169+
1170+ debug_tcp("%s(%p%s)\n", __FUNCTION__, tcp_conn,
1171+ conn->hdrdgst_en? ", digest enabled" : "");
1172+
1173+ /* Clear the data segment - needs to be filled in by the
1174+ * caller using iscsi_tcp_send_data_prep() */
1175+ memset(&tcp_conn->out.data_segment, 0, sizeof(struct iscsi_segment));
1176+
1177+ /* If header digest is enabled, compute the CRC and
1178+ * place the digest into the same buffer. We make
1179+ * sure that both iscsi_tcp_ctask and mtask have
1180+ * sufficient room.
11001181 */
1101− if (buf->use_sendmsg)
1102− res = sock_no_sendpage(sk, sg_page(&buf->sg), offset, size, flags);
1103− else
1104− res = tcp_conn->sendpage(sk, sg_page(&buf->sg), offset, size, flags);
1105−
1106− if (res >= 0) {
1107− conn->txdata_octets += res;
1108− buf->sent += res;
1109− return res;
1182+ if (conn->hdrdgst_en) {
1183+ iscsi_tcp_dgst_header(&tcp_conn->tx_hash, hdr, hdrlen,
1184+ hdr + hdrlen);
1185+ hdrlen += ISCSI_DIGEST_SIZE;
11101186 }
11111187
1112− tcp_conn->sendpage_failures_cnt++;
1113− if (res == -EAGAIN)
1114− res = -ENOBUFS;
1115− else
1116− iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
1117− return res;
1188+ /* Remember header pointer for later, when we need
1189+ * to decide whether there's a payload to go along
1190+ * with the header. */
1191+ tcp_conn->out.hdr = hdr;
1192+
1193+ iscsi_segment_init_linear(&tcp_conn->out.segment, hdr, hdrlen,
1194+ iscsi_tcp_send_hdr_done, NULL);
11181195 }
11191196
1120−/**
1121− * iscsi_sendhdr - send PDU Header via tcp_sendpage()
1122− * @conn: iscsi connection
1123− * @buf: buffer to write from
1124− * @datalen: lenght of data to be sent after the header
1125− *
1126− * Notes:
1127− * (Tx, Fast Path)
1128− **/
1129−static inline int
1130−iscsi_sendhdr(struct iscsi_conn *conn, struct iscsi_buf *buf, int datalen)
1197+/*
1198+ * Prepare the send buffer for the payload data.
1199+ * Padding and checksumming will all be taken care
1200+ * of by the iscsi_segment routines.
1201+ */
1202+static int
1203+iscsi_tcp_send_data_prep(struct iscsi_conn *conn, struct scatterlist *sg,
1204+ unsigned int count, unsigned int offset,
1205+ unsigned int len)
11311206 {
1132− int flags = 0; /* MSG_DONTWAIT; */
1133− int res, size;
1134−
1135− size = buf->sg.length - buf->sent;
1136− BUG_ON(buf->sent + size > buf->sg.length);
1137− if (buf->sent + size != buf->sg.length || datalen)
1138− flags |= MSG_MORE;
1139−
1140− res = iscsi_send(conn, buf, size, flags);
1141− debug_tcp("sendhdr %d bytes, sent %d res %d\n", size, buf->sent, res);
1142− if (res >= 0) {
1143− if (size != res)
1144− return -EAGAIN;
1145− return 0;
1146− }
1207+ struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
1208+ struct hash_desc *tx_hash = NULL;
1209+ unsigned int hdr_spec_len;
11471210
1148− return res;
1149−}
1211+ debug_tcp("%s(%p, offset=%d, datalen=%d%s)\n", __FUNCTION__,
1212+ tcp_conn, offset, len,
1213+ conn->datadgst_en? ", digest enabled" : "");
11501214
1151−/**
1152− * iscsi_sendpage - send one page of iSCSI Data-Out.
1153− * @conn: iscsi connection
1154− * @buf: buffer to write from
1155− * @count: remaining data
1156− * @sent: number of bytes sent
1157− *
1158− * Notes:
1159− * (Tx, Fast Path)
1160− **/
1161−static inline int
1162−iscsi_sendpage(struct iscsi_conn *conn, struct iscsi_buf *buf,
1163− int *count, int *sent)
1164−{
1165− int flags = 0; /* MSG_DONTWAIT; */
1166− int res, size;
1167−
1168− size = buf->sg.length - buf->sent;
1169− BUG_ON(buf->sent + size > buf->sg.length);
1170− if (size > *count)
1171− size = *count;
1172− if (buf->sent + size != buf->sg.length || *count != size)
1173− flags |= MSG_MORE;
1174−
1175− res = iscsi_send(conn, buf, size, flags);
1176− debug_tcp("sendpage: %d bytes, sent %d left %d sent %d res %d\n",
1177− size, buf->sent, *count, *sent, res);
1178− if (res >= 0) {
1179− *count -= res;
1180− *sent += res;
1181− if (size != res)
1182− return -EAGAIN;
1183− return 0;
1184− }
1215+ /* Make sure the datalen matches what the caller
1216+ said he would send. */
1217+ hdr_spec_len = ntoh24(tcp_conn->out.hdr->dlength);
1218+ WARN_ON(iscsi_padded(len) != iscsi_padded(hdr_spec_len));
1219+
1220+ if (conn->datadgst_en)
1221+ tx_hash = &tcp_conn->tx_hash;
11851222
1186− return res;
1223+ return iscsi_segment_seek_sg(&tcp_conn->out.data_segment,
1224+ sg, count, offset, len,
1225+ NULL, tx_hash);
11871226 }
11881227
1189−static inline void
1190−iscsi_data_digest_init(struct iscsi_tcp_conn *tcp_conn,
1191− struct iscsi_tcp_cmd_task *tcp_ctask)
1228+static void
1229+iscsi_tcp_send_linear_data_prepare(struct iscsi_conn *conn, void *data,
1230+ size_t len)
11921231 {
1193− crypto_hash_init(&tcp_conn->tx_hash);
1194− tcp_ctask->digest_count = 4;
1232+ struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
1233+ struct hash_desc *tx_hash = NULL;
1234+ unsigned int hdr_spec_len;
1235+
1236+ debug_tcp("%s(%p, datalen=%d%s)\n", __FUNCTION__, tcp_conn, len,
1237+ conn->datadgst_en? ", digest enabled" : "");
1238+
1239+ /* Make sure the datalen matches what the caller
1240+ said he would send. */
1241+ hdr_spec_len = ntoh24(tcp_conn->out.hdr->dlength);
1242+ WARN_ON(iscsi_padded(len) != iscsi_padded(hdr_spec_len));
1243+
1244+ if (conn->datadgst_en)
1245+ tx_hash = &tcp_conn->tx_hash;
1246+
1247+ iscsi_segment_init_linear(&tcp_conn->out.data_segment,
1248+ data, len, NULL, tx_hash);
11951249 }
11961250
11971251 /**
@@ -1207,12 +1261,17 @@ iscsi_data_digest_init(struct iscsi_tcp_conn *tcp_conn, · 9 unmodified lines
12071261 *
12081262 * Called under connection lock.
12091263 **/
1210−static void
1264+static int
12111265 iscsi_solicit_data_cont(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask,
1212− struct iscsi_r2t_info *r2t, int left)
1266+ struct iscsi_r2t_info *r2t)
12131267 {
12141268 struct iscsi_data *hdr;
1215− int new_offset;
1269+ int new_offset, left;
1270+
1271+ BUG_ON(r2t->data_length - r2t->sent < 0);
1272+ left = r2t->data_length - r2t->sent;
1273+ if (left == 0)
1274+ return 0;
12161275
12171276 hdr = &r2t->dtask.hdr;
12181277 memset(hdr, 0, sizeof(struct iscsi_data));
@@ -1233,43 +1292,46 @@ iscsi_solicit_data_cont(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask, · 14 unmodified lines
12331292 r2t->data_count = left;
12341293 hdr->flags = ISCSI_FLAG_CMD_FINAL;
12351294 }
1236− conn->dataout_pdus_cnt++;
1237−
1238− iscsi_buf_init_iov(&r2t->headbuf, (char*)hdr,
1239− sizeof(struct iscsi_hdr));
1240−
1241− if (iscsi_buf_left(&r2t->sendbuf))
1242− return;
1243−
1244− iscsi_buf_init_sg(&r2t->sendbuf, r2t->sg);
1245− r2t->sg += 1;
1246−}
1247−
1248−static void iscsi_set_padding(struct iscsi_tcp_cmd_task *tcp_ctask,
1249− unsigned long len)
1250−{
1251− tcp_ctask->pad_count = len & (ISCSI_PAD_LEN - 1);
1252− if (!tcp_ctask->pad_count)
1253− return;
12541295
1255− tcp_ctask->pad_count = ISCSI_PAD_LEN - tcp_ctask->pad_count;
1256− debug_scsi("write padding %d bytes\n", tcp_ctask->pad_count);
1257− set_bit(XMSTATE_BIT_W_PAD, &tcp_ctask->xmstate);
1296+ conn->dataout_pdus_cnt++;
1297+ return 1;
12581298 }
12591299
12601300 /**
1261− * iscsi_tcp_cmd_init - Initialize iSCSI SCSI_READ or SCSI_WRITE commands
1301+ * iscsi_tcp_ctask - Initialize iSCSI SCSI_READ or SCSI_WRITE commands
12621302 * @conn: iscsi connection
12631303 * @ctask: scsi command task
12641304 * @sc: scsi command
12651305 **/
1266−static void
1267−iscsi_tcp_cmd_init(struct iscsi_cmd_task *ctask)
1306+static int
1307+iscsi_tcp_ctask_init(struct iscsi_cmd_task *ctask)
12681308 {
12691309 struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data;
1310+ struct iscsi_conn *conn = ctask->conn;
1311+ struct scsi_cmnd *sc = ctask->sc;
1312+ int err;
12701313
12711314 BUG_ON(__kfifo_len(tcp_ctask->r2tqueue));
1272− tcp_ctask->xmstate = 1 << XMSTATE_BIT_CMD_HDR_INIT;
1315+ tcp_ctask->sent = 0;
1316+ tcp_ctask->exp_datasn = 0;
1317+
1318+ /* Prepare PDU, optionally w/ immediate data */
1319+ debug_scsi("ctask deq [cid %d itt 0x%x imm %d unsol %d]\n",
1320+ conn->id, ctask->itt, ctask->imm_count,
1321+ ctask->unsol_count);
1322+ iscsi_tcp_send_hdr_prep(conn, ctask->hdr, ctask->hdr_len);
1323+
1324+ if (!ctask->imm_count)
1325+ return 0;
1326+
1327+ /* If we have immediate data, attach a payload */
1328+ err = iscsi_tcp_send_data_prep(conn, scsi_sglist(sc), scsi_sg_count(sc),
1329+ 0, ctask->imm_count);
1330+ if (err)
1331+ return err;
1332+ tcp_ctask->sent += ctask->imm_count;
1333+ ctask->imm_count = 0;
1334+ return 0;
12731335 }
12741336
12751337 /**
@@ -1281,484 +1343,130 @@ iscsi_tcp_cmd_init(struct iscsi_cmd_task *ctask) · 5 unmodified lines
12811343 * The function can return -EAGAIN in which case caller must
12821344 * call it again later, or recover. '0' return code means successful
12831345 * xmit.
1284− *
1285− * Management xmit state machine consists of these states:
1286− * XMSTATE_BIT_IMM_HDR_INIT - calculate digest of PDU Header
1287− * XMSTATE_BIT_IMM_HDR - PDU Header xmit in progress
1288− * XMSTATE_BIT_IMM_DATA - PDU Data xmit in progress
1289− * XMSTATE_VALUE_IDLE - management PDU is done
12901346 **/
12911347 static int
12921348 iscsi_tcp_mtask_xmit(struct iscsi_conn *conn, struct iscsi_mgmt_task *mtask)
12931349 {
1294− struct iscsi_tcp_mgmt_task *tcp_mtask = mtask->dd_data;
12951350 int rc;
12961351
1297− debug_scsi("mtask deq [cid %d state %x itt 0x%x]\n",
1298− conn->id, tcp_mtask->xmstate, mtask->itt);
1299−
1300− if (test_bit(XMSTATE_BIT_IMM_HDR_INIT, &tcp_mtask->xmstate)) {
1301− iscsi_buf_init_iov(&tcp_mtask->headbuf, (char*)mtask->hdr,
1302− sizeof(struct iscsi_hdr));
1303−
1304− if (mtask->data_count) {
1305− set_bit(XMSTATE_BIT_IMM_DATA, &tcp_mtask->xmstate);
1306− iscsi_buf_init_iov(&tcp_mtask->sendbuf,
1307− (char*)mtask->data,
1308− mtask->data_count);
1309− }
1310−
1311− if (conn->c_stage != ISCSI_CONN_INITIAL_STAGE &&
1312− conn->stop_stage != STOP_CONN_RECOVER &&
1313− conn->hdrdgst_en)
1314− iscsi_hdr_digest(conn, &tcp_mtask->headbuf,
1315− (u8*)tcp_mtask->hdrext);
1316−
1317− tcp_mtask->sent = 0;
1318− clear_bit(XMSTATE_BIT_IMM_HDR_INIT, &tcp_mtask->xmstate);
1319− set_bit(XMSTATE_BIT_IMM_HDR, &tcp_mtask->xmstate);
1320− }
1321−
1322− if (test_bit(XMSTATE_BIT_IMM_HDR, &tcp_mtask->xmstate)) {
1323− rc = iscsi_sendhdr(conn, &tcp_mtask->headbuf,
1324− mtask->data_count);
1325− if (rc)
1326− return rc;
1327− clear_bit(XMSTATE_BIT_IMM_HDR, &tcp_mtask->xmstate);
1328− }
1329−
1330− if (test_and_clear_bit(XMSTATE_BIT_IMM_DATA, &tcp_mtask->xmstate)) {
1331− BUG_ON(!mtask->data_count);
1332− /* FIXME: implement.
1333− * Virtual buffer could be spreaded across multiple pages...
1334− */
1335− do {
1336− int rc;
1337−
1338− rc = iscsi_sendpage(conn, &tcp_mtask->sendbuf,
1339− &mtask->data_count, &tcp_mtask->sent);
1340− if (rc) {
1341− set_bit(XMSTATE_BIT_IMM_DATA, &tcp_mtask->xmstate);
1342− return rc;
1343− }
1344− } while (mtask->data_count);
1345− }
1352+ /* Flush any pending data first. */
1353+ rc = iscsi_tcp_flush(conn);
1354+ if (rc < 0)
1355+ return rc;
13461356
1347− BUG_ON(tcp_mtask->xmstate != XMSTATE_VALUE_IDLE);
13481357 if (mtask->hdr->itt == RESERVED_ITT) {
13491358 struct iscsi_session *session = conn->session;
13501359
13511360 spin_lock_bh(&session->lock);
1352− list_del(&conn->mtask->running);
1353− __kfifo_put(session->mgmtpool.queue, (void*)&conn->mtask,
1354− sizeof(void*));
1361+ iscsi_free_mgmt_task(conn, mtask);
13551362 spin_unlock_bh(&session->lock);
13561363 }
1364+
13571365 return 0;
13581366 }
13591367
1368+/*
1369+ * iscsi_tcp_ctask_xmit - xmit normal PDU task
1370+ * @conn: iscsi connection
1371+ * @ctask: iscsi command task
1372+ *
1373+ * We're expected to return 0 when everything was transmitted succesfully,
1374+ * -EAGAIN if there's still data in the queue, or != 0 for any other kind
1375+ * of error.
1376+ */
13601377 static int
1361−iscsi_send_cmd_hdr(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)
1378+iscsi_tcp_ctask_xmit(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)
13621379 {
1363− struct scsi_cmnd *sc = ctask->sc;
13641380 struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data;
1381+ struct scsi_cmnd *sc = ctask->sc;
13651382 int rc = 0;
13661383
1367− if (test_bit(XMSTATE_BIT_CMD_HDR_INIT, &tcp_ctask->xmstate)) {
1368− tcp_ctask->sent = 0;
1369− tcp_ctask->sg_count = 0;
1370− tcp_ctask->exp_datasn = 0;
1371−
1372− if (sc->sc_data_direction == DMA_TO_DEVICE) {
1373− struct scatterlist *sg = scsi_sglist(sc);
1374−
1375− iscsi_buf_init_sg(&tcp_ctask->sendbuf, sg);
1376− tcp_ctask->sg = sg + 1;
1377− tcp_ctask->bad_sg = sg + scsi_sg_count(sc);
1378−
1379− debug_scsi("cmd [itt 0x%x total %d imm_data %d "
1380− "unsol count %d, unsol offset %d]\n",
1381− ctask->itt, scsi_bufflen(sc),
1382− ctask->imm_count, ctask->unsol_count,
1383− ctask->unsol_offset);
1384− }
1385−
1386− iscsi_buf_init_iov(&tcp_ctask->headbuf, (char*)ctask->hdr,
1387− sizeof(struct iscsi_hdr));
1388−
1389− if (conn->hdrdgst_en)
1390− iscsi_hdr_digest(conn, &tcp_ctask->headbuf,
1391− (u8*)tcp_ctask->hdrext);
1392− clear_bit(XMSTATE_BIT_CMD_HDR_INIT, &tcp_ctask->xmstate);
1393− set_bit(XMSTATE_BIT_CMD_HDR_XMIT, &tcp_ctask->xmstate);
1394− }
1395−
1396− if (test_bit(XMSTATE_BIT_CMD_HDR_XMIT, &tcp_ctask->xmstate)) {
1397− rc = iscsi_sendhdr(conn, &tcp_ctask->headbuf, ctask->imm_count);
1398− if (rc)
1399− return rc;
1400− clear_bit(XMSTATE_BIT_CMD_HDR_XMIT, &tcp_ctask->xmstate);
1401−
1402− if (sc->sc_data_direction != DMA_TO_DEVICE)
1403− return 0;
1404−
1405− if (ctask->imm_count) {
1406− set_bit(XMSTATE_BIT_IMM_DATA, &tcp_ctask->xmstate);
1407− iscsi_set_padding(tcp_ctask, ctask->imm_count);
1408−
1409− if (ctask->conn->datadgst_en) {
1410− iscsi_data_digest_init(ctask->conn->dd_data,
1411− tcp_ctask);
1412− tcp_ctask->immdigest = 0;
1413− }
1414− }
1415−
1416− if (ctask->unsol_count) {
1417− set_bit(XMSTATE_BIT_UNS_HDR, &tcp_ctask->xmstate);
1418− set_bit(XMSTATE_BIT_UNS_INIT, &tcp_ctask->xmstate);
1419− }
1420− }
1421− return rc;
1422−}
1423−
1424−static int
1425−iscsi_send_padding(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)
1426−{
1427− struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data;
1428− struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
1429− int sent = 0, rc;
1430−
1431− if (test_bit(XMSTATE_BIT_W_PAD, &tcp_ctask->xmstate)) {
1432− iscsi_buf_init_iov(&tcp_ctask->sendbuf, (char*)&tcp_ctask->pad,
1433− tcp_ctask->pad_count);
1434− if (conn->datadgst_en)
1435− crypto_hash_update(&tcp_conn->tx_hash,
1436− &tcp_ctask->sendbuf.sg,
1437− tcp_ctask->sendbuf.sg.length);
1438− } else if (!test_bit(XMSTATE_BIT_W_RESEND_PAD, &tcp_ctask->xmstate))
1439− return 0;
1440−
1441− clear_bit(XMSTATE_BIT_W_PAD, &tcp_ctask->xmstate);
1442− clear_bit(XMSTATE_BIT_W_RESEND_PAD, &tcp_ctask->xmstate);
1443− debug_scsi("sending %d pad bytes for itt 0x%x\n",
1444− tcp_ctask->pad_count, ctask->itt);
1445− rc = iscsi_sendpage(conn, &tcp_ctask->sendbuf, &tcp_ctask->pad_count,
1446− &sent);
1447− if (rc) {
1448− debug_scsi("padding send failed %d\n", rc);
1449− set_bit(XMSTATE_BIT_W_RESEND_PAD, &tcp_ctask->xmstate);
1450− }
1451− return rc;
1452−}
1453−
1454−static int
1455−iscsi_send_digest(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask,
1456− struct iscsi_buf *buf, uint32_t *digest)
1457−{
1458− struct iscsi_tcp_cmd_task *tcp_ctask;
1459− struct iscsi_tcp_conn *tcp_conn;
1460− int rc, sent = 0;
1461−
1462− if (!conn->datadgst_en)
1463− return 0;
1464−
1465− tcp_ctask = ctask->dd_data;
1466− tcp_conn = conn->dd_data;
1467−
1468− if (!test_bit(XMSTATE_BIT_W_RESEND_DATA_DIGEST, &tcp_ctask->xmstate)) {
1469− crypto_hash_final(&tcp_conn->tx_hash, (u8*)digest);
1470− iscsi_buf_init_iov(buf, (char*)digest, 4);
1471− }
1472− clear_bit(XMSTATE_BIT_W_RESEND_DATA_DIGEST, &tcp_ctask->xmstate);
1473−
1474− rc = iscsi_sendpage(conn, buf, &tcp_ctask->digest_count, &sent);
1475− if (!rc)
1476− debug_scsi("sent digest 0x%x for itt 0x%x\n", *digest,
1477− ctask->itt);
1478− else {
1479− debug_scsi("sending digest 0x%x failed for itt 0x%x!\n",
1480− *digest, ctask->itt);
1481− set_bit(XMSTATE_BIT_W_RESEND_DATA_DIGEST, &tcp_ctask->xmstate);
1482− }
1483− return rc;
1484−}
1485−
1486−static int
1487−iscsi_send_data(struct iscsi_cmd_task *ctask, struct iscsi_buf *sendbuf,
1488− struct scatterlist **sg, int *sent, int *count,
1489− struct iscsi_buf *digestbuf, uint32_t *digest)
1490−{
1491− struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data;
1492− struct iscsi_conn *conn = ctask->conn;
1493− struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
1494− int rc, buf_sent, offset;
1495−
1496− while (*count) {
1497− buf_sent = 0;
1498− offset = sendbuf->sent;
1499−
1500− rc = iscsi_sendpage(conn, sendbuf, count, &buf_sent);
1501− *sent = *sent + buf_sent;
1502− if (buf_sent && conn->datadgst_en)
1503− partial_sg_digest_update(&tcp_conn->tx_hash,
1504− &sendbuf->sg, sendbuf->sg.offset + offset,
1505− buf_sent);
1506− if (!iscsi_buf_left(sendbuf) && *sg != tcp_ctask->bad_sg) {
1507− iscsi_buf_init_sg(sendbuf, *sg);
1508− *sg = *sg + 1;
1509− }
1510−
1511− if (rc)
1512− return rc;
1513− }
1514−
1515− rc = iscsi_send_padding(conn, ctask);
1516− if (rc)
1384+flush:
1385+ /* Flush any pending data first. */
1386+ rc = iscsi_tcp_flush(conn);
1387+ if (rc < 0)
15171388 return rc;
15181389
1519− return iscsi_send_digest(conn, ctask, digestbuf, digest);
1520−}
1521−
1522−static int
1523−iscsi_send_unsol_hdr(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)
1524−{
1525− struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data;
1526− struct iscsi_data_task *dtask;
1527− int rc;
1528−
1529− set_bit(XMSTATE_BIT_UNS_DATA, &tcp_ctask->xmstate);
1530− if (test_bit(XMSTATE_BIT_UNS_INIT, &tcp_ctask->xmstate)) {
1531− dtask = &tcp_ctask->unsol_dtask;
1532−
1533− iscsi_prep_unsolicit_data_pdu(ctask, &dtask->hdr);
1534− iscsi_buf_init_iov(&tcp_ctask->headbuf, (char*)&dtask->hdr,
1535− sizeof(struct iscsi_hdr));
1536− if (conn->hdrdgst_en)
1537− iscsi_hdr_digest(conn, &tcp_ctask->headbuf,
1538− (u8*)dtask->hdrext);
1539−
1540− clear_bit(XMSTATE_BIT_UNS_INIT, &tcp_ctask->xmstate);
1541− iscsi_set_padding(tcp_ctask, ctask->data_count);
1542− }
1543−
1544− rc = iscsi_sendhdr(conn, &tcp_ctask->headbuf, ctask->data_count);
1545− if (rc) {
1546− clear_bit(XMSTATE_BIT_UNS_DATA, &tcp_ctask->xmstate);
1547− set_bit(XMSTATE_BIT_UNS_HDR, &tcp_ctask->xmstate);
1548− return rc;
1549− }
1390+ /* Are we done already? */
1391+ if (sc->sc_data_direction != DMA_TO_DEVICE)
1392+ return 0;
15501393
1551− if (conn->datadgst_en) {
1552− dtask = &tcp_ctask->unsol_dtask;
1553− iscsi_data_digest_init(ctask->conn->dd_data, tcp_ctask);
1554− dtask->digest = 0;
1555− }
1394+ if (ctask->unsol_count != 0) {
1395+ struct iscsi_data *hdr = &tcp_ctask->unsol_dtask.hdr;
15561396
1557− debug_scsi("uns dout [itt 0x%x dlen %d sent %d]\n",
1558− ctask->itt, ctask->unsol_count, tcp_ctask->sent);
1559− return 0;
1560−}
1397+ /* Prepare a header for the unsolicited PDU.
1398+ * The amount of data we want to send will be
1399+ * in ctask->data_count.
1400+ * FIXME: return the data count instead.
1401+ */
1402+ iscsi_prep_unsolicit_data_pdu(ctask, hdr);
15611403
1562−static int
1563−iscsi_send_unsol_pdu(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)
1564−{
1565− struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data;
1566− int rc;
1404+ debug_tcp("unsol dout [itt 0x%x doff %d dlen %d]\n",
1405+ ctask->itt, tcp_ctask->sent, ctask->data_count);
15671406
1568− if (test_and_clear_bit(XMSTATE_BIT_UNS_HDR, &tcp_ctask->xmstate)) {
1569− BUG_ON(!ctask->unsol_count);
1570−send_hdr:
1571− rc = iscsi_send_unsol_hdr(conn, ctask);
1407+ iscsi_tcp_send_hdr_prep(conn, hdr, sizeof(*hdr));
1408+ rc = iscsi_tcp_send_data_prep(conn, scsi_sglist(sc),
1409+ scsi_sg_count(sc),
1410+ tcp_ctask->sent,
1411+ ctask->data_count);
15721412 if (rc)
1573− return rc;
1574− }
1575−
1576− if (test_bit(XMSTATE_BIT_UNS_DATA, &tcp_ctask->xmstate)) {
1577− struct iscsi_data_task *dtask = &tcp_ctask->unsol_dtask;
1578− int start = tcp_ctask->sent;
1413+ goto fail;
1414+ tcp_ctask->sent += ctask->data_count;
1415+ ctask->unsol_count -= ctask->data_count;
1416+ goto flush;
1417+ } else {
1418+ struct iscsi_session *session = conn->session;
1419+ struct iscsi_r2t_info *r2t;
15791420
1580− rc = iscsi_send_data(ctask, &tcp_ctask->sendbuf, &tcp_ctask->sg,
1581− &tcp_ctask->sent, &ctask->data_count,
1582− &dtask->digestbuf, &dtask->digest);
1583− ctask->unsol_count -= tcp_ctask->sent - start;
1584− if (rc)
1585− return rc;
1586− clear_bit(XMSTATE_BIT_UNS_DATA, &tcp_ctask->xmstate);
1587− /*
1588− * Done with the Data-Out. Next, check if we need
1589− * to send another unsolicited Data-Out.
1421+ /* All unsolicited PDUs sent. Check for solicited PDUs.
15901422 */
1591− if (ctask->unsol_count) {
1592− debug_scsi("sending more uns\n");
1593− set_bit(XMSTATE_BIT_UNS_INIT, &tcp_ctask->xmstate);
1594− goto send_hdr;
1423+ spin_lock_bh(&session->lock);
1424+ r2t = tcp_ctask->r2t;
1425+ if (r2t != NULL) {
1426+ /* Continue with this R2T? */
1427+ if (!iscsi_solicit_data_cont(conn, ctask, r2t)) {
1428+ debug_scsi(" done with r2t %p\n", r2t);
1429+
1430+ __kfifo_put(tcp_ctask->r2tpool.queue,
1431+ (void*)&r2t, sizeof(void*));
1432+ tcp_ctask->r2t = r2t = NULL;
1433+ }
15951434 }
1596− }
1597− return 0;
1598−}
1599−
1600−static int iscsi_send_sol_pdu(struct iscsi_conn *conn,
1601− struct iscsi_cmd_task *ctask)
1602−{
1603− struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data;
1604− struct iscsi_session *session = conn->session;
1605− struct iscsi_r2t_info *r2t;
1606− struct iscsi_data_task *dtask;
1607− int left, rc;
16081435
1609− if (test_bit(XMSTATE_BIT_SOL_HDR_INIT, &tcp_ctask->xmstate)) {
1610− if (!tcp_ctask->r2t) {
1611− spin_lock_bh(&session->lock);
1436+ if (r2t == NULL) {
16121437 __kfifo_get(tcp_ctask->r2tqueue, (void*)&tcp_ctask->r2t,
16131438 sizeof(void*));
1614− spin_unlock_bh(&session->lock);
1439+ r2t = tcp_ctask->r2t;
16151440 }
1616−send_hdr:
1617− r2t = tcp_ctask->r2t;
1618− dtask = &r2t->dtask;
1619−
1620− if (conn->hdrdgst_en)
1621− iscsi_hdr_digest(conn, &r2t->headbuf,
1622− (u8*)dtask->hdrext);
1623− clear_bit(XMSTATE_BIT_SOL_HDR_INIT, &tcp_ctask->xmstate);
1624− set_bit(XMSTATE_BIT_SOL_HDR, &tcp_ctask->xmstate);
1625− }
1626−
1627− if (test_bit(XMSTATE_BIT_SOL_HDR, &tcp_ctask->xmstate)) {
1628− r2t = tcp_ctask->r2t;
1629− dtask = &r2t->dtask;
1630−
1631− rc = iscsi_sendhdr(conn, &r2t->headbuf, r2t->data_count);
1632− if (rc)
1633− return rc;
1634− clear_bit(XMSTATE_BIT_SOL_HDR, &tcp_ctask->xmstate);
1635− set_bit(XMSTATE_BIT_SOL_DATA, &tcp_ctask->xmstate);
1441+ spin_unlock_bh(&session->lock);
16361442
1637− if (conn->datadgst_en) {
1638− iscsi_data_digest_init(conn->dd_data, tcp_ctask);
1639− dtask->digest = 0;
1443+ /* Waiting for more R2Ts to arrive. */
1444+ if (r2t == NULL) {
1445+ debug_tcp("no R2Ts yet\n");
1446+ return 0;
16401447 }
16411448
1642− iscsi_set_padding(tcp_ctask, r2t->data_count);
1643− debug_scsi("sol dout [dsn %d itt 0x%x dlen %d sent %d]\n",
1644− r2t->solicit_datasn - 1, ctask->itt, r2t->data_count,
1645− r2t->sent);
1646− }
1449+ debug_scsi("sol dout %p [dsn %d itt 0x%x doff %d dlen %d]\n",
1450+ r2t, r2t->solicit_datasn - 1, ctask->itt,
1451+ r2t->data_offset + r2t->sent, r2t->data_count);
16471452
1648− if (test_bit(XMSTATE_BIT_SOL_DATA, &tcp_ctask->xmstate)) {
1649− r2t = tcp_ctask->r2t;
1650− dtask = &r2t->dtask;
1453+ iscsi_tcp_send_hdr_prep(conn, &r2t->dtask.hdr,
1454+ sizeof(struct iscsi_hdr));
16511455
1652− rc = iscsi_send_data(ctask, &r2t->sendbuf, &r2t->sg,
1653− &r2t->sent, &r2t->data_count,
1654− &dtask->digestbuf, &dtask->digest);
1456+ rc = iscsi_tcp_send_data_prep(conn, scsi_sglist(sc),
1457+ scsi_sg_count(sc),
1458+ r2t->data_offset + r2t->sent,
1459+ r2t->data_count);
16551460 if (rc)
1656− return rc;
1657− clear_bit(XMSTATE_BIT_SOL_DATA, &tcp_ctask->xmstate);
1658−
1659− /*
1660− * Done with this Data-Out. Next, check if we have
1661− * to send another Data-Out for this R2T.
1662− */
1663− BUG_ON(r2t->data_length - r2t->sent < 0);
1664− left = r2t->data_length - r2t->sent;
1665− if (left) {
1666− iscsi_solicit_data_cont(conn, ctask, r2t, left);
1667− goto send_hdr;
1668− }
1669−
1670− /*
1671− * Done with this R2T. Check if there are more
1672− * outstanding R2Ts ready to be processed.
1673− */
1674− spin_lock_bh(&session->lock);
1675− tcp_ctask->r2t = NULL;
1676− __kfifo_put(tcp_ctask->r2tpool.queue, (void*)&r2t,
1677− sizeof(void*));
1678− if (__kfifo_get(tcp_ctask->r2tqueue, (void*)&r2t,
1679− sizeof(void*))) {
1680− tcp_ctask->r2t = r2t;
1681− spin_unlock_bh(&session->lock);
1682− goto send_hdr;
1683− }
1684− spin_unlock_bh(&session->lock);
1461+ goto fail;
1462+ tcp_ctask->sent += r2t->data_count;
1463+ r2t->sent += r2t->data_count;
1464+ goto flush;
16851465 }
16861466 return 0;
1687−}
1688−
1689−/**
1690− * iscsi_tcp_ctask_xmit - xmit normal PDU task
1691− * @conn: iscsi connection
1692− * @ctask: iscsi command task
1693− *
1694− * Notes:
1695− * The function can return -EAGAIN in which case caller must
1696− * call it again later, or recover. '0' return code means successful
1697− * xmit.
1698− * The function is devided to logical helpers (above) for the different
1699− * xmit stages.
1700− *
1701− *iscsi_send_cmd_hdr()
1702− * XMSTATE_BIT_CMD_HDR_INIT - prepare Header and Data buffers Calculate
1703− * Header Digest
1704− * XMSTATE_BIT_CMD_HDR_XMIT - Transmit header in progress
1705− *
1706− *iscsi_send_padding
1707− * XMSTATE_BIT_W_PAD - Prepare and send pading
1708− * XMSTATE_BIT_W_RESEND_PAD - retry send pading
1709− *
1710− *iscsi_send_digest
1711− * XMSTATE_BIT_W_RESEND_DATA_DIGEST - Finalize and send Data Digest
1712− * XMSTATE_BIT_W_RESEND_DATA_DIGEST - retry sending digest
1713− *
1714− *iscsi_send_unsol_hdr
1715− * XMSTATE_BIT_UNS_INIT - prepare un-solicit data header and digest
1716− * XMSTATE_BIT_UNS_HDR - send un-solicit header
1717− *
1718− *iscsi_send_unsol_pdu
1719− * XMSTATE_BIT_UNS_DATA - send un-solicit data in progress
1720− *
1721− *iscsi_send_sol_pdu
1722− * XMSTATE_BIT_SOL_HDR_INIT - solicit data header and digest initialize
1723− * XMSTATE_BIT_SOL_HDR - send solicit header
1724− * XMSTATE_BIT_SOL_DATA - send solicit data
1725− *
1726− *iscsi_tcp_ctask_xmit
1727− * XMSTATE_BIT_IMM_DATA - xmit managment data (??)
1728− **/
1729−static int
1730−iscsi_tcp_ctask_xmit(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)
1731−{
1732− struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data;
1733− int rc = 0;
1734−
1735− debug_scsi("ctask deq [cid %d xmstate %x itt 0x%x]\n",
1736− conn->id, tcp_ctask->xmstate, ctask->itt);
1737−
1738− rc = iscsi_send_cmd_hdr(conn, ctask);
1739− if (rc)
1740− return rc;
1741− if (ctask->sc->sc_data_direction != DMA_TO_DEVICE)
1742− return 0;
1743−
1744− if (test_bit(XMSTATE_BIT_IMM_DATA, &tcp_ctask->xmstate)) {
1745− rc = iscsi_send_data(ctask, &tcp_ctask->sendbuf, &tcp_ctask->sg,
1746− &tcp_ctask->sent, &ctask->imm_count,
1747− &tcp_ctask->immbuf, &tcp_ctask->immdigest);
1748− if (rc)
1749− return rc;
1750− clear_bit(XMSTATE_BIT_IMM_DATA, &tcp_ctask->xmstate);
1751− }
1752−
1753− rc = iscsi_send_unsol_pdu(conn, ctask);
1754− if (rc)
1755− return rc;
1756−
1757− rc = iscsi_send_sol_pdu(conn, ctask);
1758− if (rc)
1759− return rc;
1760−
1761− return rc;
1467+fail:
1468+ iscsi_conn_failure(conn, rc);
1469+ return -EIO;
17621470 }
17631471
17641472 static struct iscsi_cls_conn *
@@ -1784,9 +1492,6 @@ iscsi_tcp_conn_create(struct iscsi_cls_session *cls_session, uint32_t conn_idx) · 19 unmodified lines
17841492
17851493 conn->dd_data = tcp_conn;
17861494 tcp_conn->iscsi_conn = conn;
1787− tcp_conn->in_progress = IN_PROGRESS_WAIT_HEADER;
1788− /* initial operational parameters */
1789− tcp_conn->hdr_size = sizeof(struct iscsi_hdr);
17901495
17911496 tcp_conn->tx_hash.tfm = crypto_alloc_hash("crc32c", 0,
17921497 CRYPTO_ALG_ASYNC);
@@ -1863,11 +1568,9 @@ static void · 70 unmodified lines
18631568 iscsi_tcp_conn_stop(struct iscsi_cls_conn *cls_conn, int flag)
18641569 {
18651570 struct iscsi_conn *conn = cls_conn->dd_data;
1866− struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
18671571
18681572 iscsi_conn_stop(cls_conn, flag);
18691573 iscsi_tcp_release_conn(conn);
1870− tcp_conn->hdr_size = sizeof(struct iscsi_hdr);
18711574 }
18721575
18731576 static int iscsi_tcp_get_addr(struct iscsi_conn *conn, struct socket *sock,
@@ -1967,7 +1670,7 @@ iscsi_tcp_conn_bind(struct iscsi_cls_session *cls_session, · 93 unmodified lines
19671670 /*
19681671 * set receive state machine into initial state
19691672 */
1970− tcp_conn->in_progress = IN_PROGRESS_WAIT_HEADER;
1673+ iscsi_tcp_hdr_recv_prep(tcp_conn);
19711674 return 0;
19721675
19731676 free_socket:
@@ -1977,10 +1680,17 @@ free_socket: · 3 unmodified lines
19771680
19781681 /* called with host lock */
19791682 static void
1980−iscsi_tcp_mgmt_init(struct iscsi_conn *conn, struct iscsi_mgmt_task *mtask)
1683+iscsi_tcp_mtask_init(struct iscsi_conn *conn, struct iscsi_mgmt_task *mtask)
19811684 {
1982− struct iscsi_tcp_mgmt_task *tcp_mtask = mtask->dd_data;
1983− tcp_mtask->xmstate = 1 << XMSTATE_BIT_IMM_HDR_INIT;
1685+ debug_scsi("mtask deq [cid %d itt 0x%x]\n", conn->id, mtask->itt);
1686+
1687+ /* Prepare PDU, optionally w/ immediate data */
1688+ iscsi_tcp_send_hdr_prep(conn, mtask->hdr, sizeof(*mtask->hdr));
1689+
1690+ /* If we have immediate data, attach a payload */
1691+ if (mtask->data_count)
1692+ iscsi_tcp_send_linear_data_prepare(conn, mtask->data,
1693+ mtask->data_count);
19841694 }
19851695
19861696 static int
@@ -2003,8 +1713,7 @@ iscsi_r2tpool_alloc(struct iscsi_session *session) · 16 unmodified lines
20031713 */
20041714
20051715 /* R2T pool */
2006− if (iscsi_pool_init(&tcp_ctask->r2tpool, session->max_r2t * 4,
2007− (void***)&tcp_ctask->r2ts,
1716+ if (iscsi_pool_init(&tcp_ctask->r2tpool, session->max_r2t * 4, NULL,
20081717 sizeof(struct iscsi_r2t_info))) {
20091718 goto r2t_alloc_fail;
20101719 }
@@ -2013,8 +1722,7 @@ iscsi_r2tpool_alloc(struct iscsi_session *session) · 2 unmodified lines
20131722 tcp_ctask->r2tqueue = kfifo_alloc(
20141723 session->max_r2t * 4 * sizeof(void*), GFP_KERNEL, NULL);
20151724 if (tcp_ctask->r2tqueue == ERR_PTR(-ENOMEM)) {
2016− iscsi_pool_free(&tcp_ctask->r2tpool,
2017− (void**)tcp_ctask->r2ts);
1725+ iscsi_pool_free(&tcp_ctask->r2tpool);
20181726 goto r2t_alloc_fail;
20191727 }
20201728 }
@@ -2027,8 +1735,7 @@ r2t_alloc_fail: · 6 unmodified lines
20271735 struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data;
20281736
20291737 kfifo_free(tcp_ctask->r2tqueue);
2030− iscsi_pool_free(&tcp_ctask->r2tpool,
2031− (void**)tcp_ctask->r2ts);
1738+ iscsi_pool_free(&tcp_ctask->r2tpool);
20321739 }
20331740 return -ENOMEM;
20341741 }
@@ -2043,8 +1750,7 @@ iscsi_r2tpool_free(struct iscsi_session *session) · 8 unmodified lines
20431750 struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data;
20441751
20451752 kfifo_free(tcp_ctask->r2tqueue);
2046− iscsi_pool_free(&tcp_ctask->r2tpool,
2047− (void**)tcp_ctask->r2ts);
1753+ iscsi_pool_free(&tcp_ctask->r2tpool);
20481754 }
20491755 }
20501756
@@ -2060,9 +1766,6 @@ iscsi_conn_set_param(struct iscsi_cls_conn *cls_conn, enum iscsi_param param, · 9 unmodified lines
20601766 switch(param) {
20611767 case ISCSI_PARAM_HDRDGST_EN:
20621768 iscsi_set_param(cls_conn, param, buf, buflen);
2063− tcp_conn->hdr_size = sizeof(struct iscsi_hdr);
2064− if (conn->hdrdgst_en)
2065− tcp_conn->hdr_size += sizeof(__u32);
20661769 break;
20671770 case ISCSI_PARAM_DATADGST_EN:
20681771 iscsi_set_param(cls_conn, param, buf, buflen);
@@ -2071,12 +1774,12 @@ iscsi_conn_set_param(struct iscsi_cls_conn *cls_conn, enum iscsi_param param, · 2 unmodified lines
20711774 break;
20721775 case ISCSI_PARAM_MAX_R2T:
20731776 sscanf(buf, "%d", &value);
2074− if (session->max_r2t == roundup_pow_of_two(value))
1777+ if (value <= 0 || !is_power_of_2(value))
1778+ return -EINVAL;
1779+ if (session->max_r2t == value)
20751780 break;
20761781 iscsi_r2tpool_free(session);
20771782 iscsi_set_param(cls_conn, param, buf, buflen);
2078− if (session->max_r2t & (session->max_r2t - 1))
2079− session->max_r2t = roundup_pow_of_two(session->max_r2t);
20801783 if (iscsi_r2tpool_alloc(session))
20811784 return -ENOMEM;
20821785 break;
@@ -2183,14 +1886,15 @@ iscsi_tcp_session_create(struct iscsi_transport *iscsit, · 100 unmodified lines
21831886 struct iscsi_cmd_task *ctask = session->cmds[cmd_i];
21841887 struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data;
21851888
2186− ctask->hdr = &tcp_ctask->hdr;
1889+ ctask->hdr = &tcp_ctask->hdr.cmd_hdr;
1890+ ctask->hdr_max = sizeof(tcp_ctask->hdr) - ISCSI_DIGEST_SIZE;
21871891 }
21881892
21891893 for (cmd_i = 0; cmd_i < session->mgmtpool_max; cmd_i++) {
21901894 struct iscsi_mgmt_task *mtask = session->mgmt_cmds[cmd_i];
21911895 struct iscsi_tcp_mgmt_task *tcp_mtask = mtask->dd_data;
21921896
2193− mtask->hdr = &tcp_mtask->hdr;
1897+ mtask->hdr = (struct iscsi_hdr *) &tcp_mtask->hdr;
21941898 }
21951899
21961900 if (iscsi_r2tpool_alloc(class_to_transport_session(cls_session)))
@@ -2222,12 +1926,14 @@ static struct scsi_host_template iscsi_sht = { · 25 unmodified lines
22221926 .queuecommand = iscsi_queuecommand,
22231927 .change_queue_depth = iscsi_change_queue_depth,
22241928 .can_queue = ISCSI_DEF_XMIT_CMDS_MAX - 1,
2225− .sg_tablesize = ISCSI_SG_TABLESIZE,
1929+ .sg_tablesize = 4096,
22261930 .max_sectors = 0xFFFF,
22271931 .cmd_per_lun = ISCSI_DEF_CMD_PER_LUN,
22281932 .eh_abort_handler = iscsi_eh_abort,
1933+ .eh_device_reset_handler= iscsi_eh_device_reset,
22291934 .eh_host_reset_handler = iscsi_eh_host_reset,
22301935 .use_clustering = DISABLE_CLUSTERING,
1936+ .use_sg_chaining = ENABLE_SG_CHAINING,
22311937 .slave_configure = iscsi_tcp_slave_configure,
22321938 .proc_name = "iscsi_tcp",
22331939 .this_id = -1,
@@ -2257,14 +1963,17 @@ static struct iscsi_transport iscsi_tcp_transport = { · 23 unmodified lines
22571963 ISCSI_PERSISTENT_ADDRESS |
22581964 ISCSI_TARGET_NAME | ISCSI_TPGT |
22591965 ISCSI_USERNAME | ISCSI_PASSWORD |
2260− ISCSI_USERNAME_IN | ISCSI_PASSWORD_IN,
1966+ ISCSI_USERNAME_IN | ISCSI_PASSWORD_IN |
1967+ ISCSI_FAST_ABORT | ISCSI_ABORT_TMO |
1968+ ISCSI_LU_RESET_TMO |
1969+ ISCSI_PING_TMO | ISCSI_RECV_TMO,
22611970 .host_param_mask = ISCSI_HOST_HWADDRESS | ISCSI_HOST_IPADDRESS |
22621971 ISCSI_HOST_INITIATOR_NAME |
22631972 ISCSI_HOST_NETDEV_NAME,
22641973 .host_template = &iscsi_sht,
22651974 .conndata_size = sizeof(struct iscsi_conn),
22661975 .max_conn = 1,
2267− .max_cmd_len = ISCSI_TCP_MAX_CMD_LEN,
1976+ .max_cmd_len = 16,
22681977 /* session management */
22691978 .create_session = iscsi_tcp_session_create,
22701979 .destroy_session = iscsi_tcp_session_destroy,
@@ -2283,8 +1992,8 @@ static struct iscsi_transport iscsi_tcp_transport = { · 12 unmodified lines
22831992 /* IO */
22841993 .send_pdu = iscsi_conn_send_pdu,
22851994 .get_stats = iscsi_conn_get_stats,
2286− .init_cmd_task = iscsi_tcp_cmd_init,
2287− .init_mgmt_task = iscsi_tcp_mgmt_init,
1995+ .init_cmd_task = iscsi_tcp_ctask_init,
1996+ .init_mgmt_task = iscsi_tcp_mtask_init,
22881997 .xmit_cmd_task = iscsi_tcp_ctask_xmit,
22891998 .xmit_mgmt_task = iscsi_tcp_mtask_xmit,
22901999 .cleanup_cmd_task = iscsi_tcp_cleanup_ctask,
drivers/scsi/iscsi_tcp.h+51−83
@@ -24,71 +24,61 @@ · 23 unmodified lines
2424
2525 #include <scsi/libiscsi.h>
2626
27−/* Socket's Receive state machine */
28−#define IN_PROGRESS_WAIT_HEADER 0x0
29−#define IN_PROGRESS_HEADER_GATHER 0x1
30−#define IN_PROGRESS_DATA_RECV 0x2
31−#define IN_PROGRESS_DDIGEST_RECV 0x3
32−#define IN_PROGRESS_PAD_RECV 0x4
33−
34−/* xmit state machine */
35−#define XMSTATE_VALUE_IDLE 0
36−#define XMSTATE_BIT_CMD_HDR_INIT 0
37−#define XMSTATE_BIT_CMD_HDR_XMIT 1
38−#define XMSTATE_BIT_IMM_HDR 2
39−#define XMSTATE_BIT_IMM_DATA 3
40−#define XMSTATE_BIT_UNS_INIT 4
41−#define XMSTATE_BIT_UNS_HDR 5
42−#define XMSTATE_BIT_UNS_DATA 6
43−#define XMSTATE_BIT_SOL_HDR 7
44−#define XMSTATE_BIT_SOL_DATA 8
45−#define XMSTATE_BIT_W_PAD 9
46−#define XMSTATE_BIT_W_RESEND_PAD 10
47−#define XMSTATE_BIT_W_RESEND_DATA_DIGEST 11
48−#define XMSTATE_BIT_IMM_HDR_INIT 12
49−#define XMSTATE_BIT_SOL_HDR_INIT 13
50−
51−#define ISCSI_PAD_LEN 4
52−#define ISCSI_SG_TABLESIZE SG_ALL
53−#define ISCSI_TCP_MAX_CMD_LEN 16
54−
5527 struct crypto_hash;
5628 struct socket;
29+struct iscsi_tcp_conn;
30+struct iscsi_segment;
31+
32+typedef int iscsi_segment_done_fn_t(struct iscsi_tcp_conn *,
33+ struct iscsi_segment *);
34+
35+struct iscsi_segment {
36+ unsigned char *data;
37+ unsigned int size;
38+ unsigned int copied;
39+ unsigned int total_size;
40+ unsigned int total_copied;
41+
42+ struct hash_desc *hash;
43+ unsigned char recv_digest[ISCSI_DIGEST_SIZE];
44+ unsigned char digest[ISCSI_DIGEST_SIZE];
45+ unsigned int digest_len;
46+
47+ struct scatterlist *sg;
48+ void *sg_mapped;
49+ unsigned int sg_offset;
50+
51+ iscsi_segment_done_fn_t *done;
52+};
5753
5854 /* Socket connection recieve helper */
5955 struct iscsi_tcp_recv {
6056 struct iscsi_hdr *hdr;
61− struct sk_buff *skb;
62− int offset;
63− int len;
64− int hdr_offset;
65− int copy;
66− int copied;
67− int padding;
68− struct iscsi_cmd_task *ctask; /* current cmd in progress */
57+ struct iscsi_segment segment;
58+
59+ /* Allocate buffer for BHS + AHS */
60+ uint32_t hdr_buf[64];
6961
7062 /* copied and flipped values */
7163 int datalen;
72− int datadgst;
73− char zero_copy_hdr;
64+};
65+
66+/* Socket connection send helper */
67+struct iscsi_tcp_send {
68+ struct iscsi_hdr *hdr;
69+ struct iscsi_segment segment;
70+ struct iscsi_segment data_segment;
7471 };
7572
7673 struct iscsi_tcp_conn {
7774 struct iscsi_conn *iscsi_conn;
7875 struct socket *sock;
79− struct iscsi_hdr hdr; /* header placeholder */
80− char hdrext[4*sizeof(__u16) +
81− sizeof(__u32)];
82− int data_copied;
8376 int stop_stage; /* conn_stop() flag: *
8477 * stop to recover, *
8578 * stop to terminate */
86− /* iSCSI connection-wide sequencing */
87− int hdr_size; /* PDU header size */
88−
8979 /* control data */
9080 struct iscsi_tcp_recv in; /* TCP receive context */
91− int in_progress; /* connection state machine */
81+ struct iscsi_tcp_send out; /* TCP send context */
9282
9383 /* old values for socket callbacks */
9484 void (*old_data_ready)(struct sock *, int);
@@ -103,29 +93,19 @@ struct iscsi_tcp_conn { · 8 unmodified lines
10393 uint32_t sendpage_failures_cnt;
10494 uint32_t discontiguous_hdr_cnt;
10595
106− ssize_t (*sendpage)(struct socket *, struct page *, int, size_t, int);
107−};
96+ int error;
10897
109−struct iscsi_buf {
110− struct scatterlist sg;
111− unsigned int sent;
112− char use_sendmsg;
98+ ssize_t (*sendpage)(struct socket *, struct page *, int, size_t, int);
11399 };
114100
115101 struct iscsi_data_task {
116102 struct iscsi_data hdr; /* PDU */
117− char hdrext[sizeof(__u32)]; /* Header-Digest */
118− struct iscsi_buf digestbuf; /* digest buffer */
119− uint32_t digest; /* data digest */
103+ char hdrext[ISCSI_DIGEST_SIZE];/* Header-Digest */
120104 };
121105
122106 struct iscsi_tcp_mgmt_task {
123107 struct iscsi_hdr hdr;
124− char hdrext[sizeof(__u32)]; /* Header-Digest */
125− unsigned long xmstate; /* mgmt xmit progress */
126− struct iscsi_buf headbuf; /* header buffer */
127− struct iscsi_buf sendbuf; /* in progress buffer */
128− int sent;
108+ char hdrext[ISCSI_DIGEST_SIZE]; /* Header-Digest */
129109 };
130110
131111 struct iscsi_r2t_info {
@@ -133,38 +113,26 @@ struct iscsi_r2t_info { · 1 unmodified line
133113 __be32 exp_statsn; /* copied from R2T */
134114 uint32_t data_length; /* copied from R2T */
135115 uint32_t data_offset; /* copied from R2T */
136− struct iscsi_buf headbuf; /* Data-Out Header Buffer */
137− struct iscsi_buf sendbuf; /* Data-Out in progress buffer*/
138116 int sent; /* R2T sequence progress */
139117 int data_count; /* DATA-Out payload progress */
140− struct scatterlist *sg; /* per-R2T SG list */
141118 int solicit_datasn;
142− struct iscsi_data_task dtask; /* which data task */
119+ struct iscsi_data_task dtask; /* Data-Out header buf */
143120 };
144121
145122 struct iscsi_tcp_cmd_task {
146− struct iscsi_cmd hdr;
147− char hdrext[4*sizeof(__u16)+ /* AHS */
148− sizeof(__u32)]; /* HeaderDigest */
149− char pad[ISCSI_PAD_LEN];
150− int pad_count; /* padded bytes */
151− struct iscsi_buf headbuf; /* header buf (xmit) */
152− struct iscsi_buf sendbuf; /* in progress buffer*/
153− unsigned long xmstate; /* xmit xtate machine */
123+ struct iscsi_hdr_buff {
124+ struct iscsi_cmd cmd_hdr;
125+ char hdrextbuf[ISCSI_MAX_AHS_SIZE +
126+ ISCSI_DIGEST_SIZE];
127+ } hdr;
128+
154129 int sent;
155− struct scatterlist *sg; /* per-cmd SG list */
156− struct scatterlist *bad_sg; /* assert statement */
157− int sg_count; /* SG's to process */
158− uint32_t exp_datasn; /* expected target's R2TSN/DataSN */
130+ uint32_t exp_datasn; /* expected target's R2TSN/DataSN */
159131 int data_offset;
160− struct iscsi_r2t_info *r2t; /* in progress R2T */
161− struct iscsi_queue r2tpool;
132+ struct iscsi_r2t_info *r2t; /* in progress R2T */
133+ struct iscsi_pool r2tpool;
162134 struct kfifo *r2tqueue;
163− struct iscsi_r2t_info **r2ts;
164− int digest_count;
165− uint32_t immdigest; /* for imm data */
166− struct iscsi_buf immbuf; /* for imm data digest */
167− struct iscsi_data_task unsol_dtask; /* unsol data task */
135+ struct iscsi_data_task unsol_dtask; /* Data-Out header buf */
168136 };
169137
170138 #endif /* ISCSI_H */
drivers/scsi/libiscsi.c+713−378
@@ -24,6 +24,7 @@ · 23 unmodified lines
2424 #include <linux/types.h>
2525 #include <linux/kfifo.h>
2626 #include <linux/delay.h>
27+#include <linux/log2.h>
2728 #include <asm/unaligned.h>
2829 #include <net/tcp.h>
2930 #include <scsi/scsi_cmnd.h>
@@ -86,7 +87,7 @@ iscsi_update_cmdsn(struct iscsi_session *session, struct iscsi_nopin *hdr) · 56 unmodified lines
8687 * xmit thread
8788 */
8889 if (!list_empty(&session->leadconn->xmitqueue) ||
89− __kfifo_len(session->leadconn->mgmtqueue))
90+ !list_empty(&session->leadconn->mgmtqueue))
9091 scsi_queue_work(session->host,
9192 &session->leadconn->xmitwork);
9293 }
@@ -122,6 +123,20 @@ void iscsi_prep_unsolicit_data_pdu(struct iscsi_cmd_task *ctask, · 29 unmodified lines
122123 }
123124 EXPORT_SYMBOL_GPL(iscsi_prep_unsolicit_data_pdu);
124125
126+static int iscsi_add_hdr(struct iscsi_cmd_task *ctask, unsigned len)
127+{
128+ unsigned exp_len = ctask->hdr_len + len;
129+
130+ if (exp_len > ctask->hdr_max) {
131+ WARN_ON(1);
132+ return -EINVAL;
133+ }
134+
135+ WARN_ON(len & (ISCSI_PAD_LEN - 1)); /* caller must pad the AHS */
136+ ctask->hdr_len = exp_len;
137+ return 0;
138+}
139+
125140 /**
126141 * iscsi_prep_scsi_cmd_pdu - prep iscsi scsi cmd pdu
127142 * @ctask: iscsi cmd task
@@ -129,27 +144,32 @@ EXPORT_SYMBOL_GPL(iscsi_prep_unsolicit_data_pdu); · 1 unmodified line
129144 * Prep basic iSCSI PDU fields for a scsi cmd pdu. The LLD should set
130145 * fields like dlength or final based on how much data it sends
131146 */
132−static void iscsi_prep_scsi_cmd_pdu(struct iscsi_cmd_task *ctask)
147+static int iscsi_prep_scsi_cmd_pdu(struct iscsi_cmd_task *ctask)
133148 {
134149 struct iscsi_conn *conn = ctask->conn;
135150 struct iscsi_session *session = conn->session;
136151 struct iscsi_cmd *hdr = ctask->hdr;
137152 struct scsi_cmnd *sc = ctask->sc;
153+ unsigned hdrlength;
154+ int rc;
138155
139− hdr->opcode = ISCSI_OP_SCSI_CMD;
140− hdr->flags = ISCSI_ATTR_SIMPLE;
141− int_to_scsilun(sc->device->lun, (struct scsi_lun *)hdr->lun);
142− hdr->itt = build_itt(ctask->itt, conn->id, session->age);
143− hdr->data_length = cpu_to_be32(scsi_bufflen(sc));
144− hdr->cmdsn = cpu_to_be32(session->cmdsn);
145− session->cmdsn++;
146− hdr->exp_statsn = cpu_to_be32(conn->exp_statsn);
147− memcpy(hdr->cdb, sc->cmnd, sc->cmd_len);
156+ ctask->hdr_len = 0;
157+ rc = iscsi_add_hdr(ctask, sizeof(*hdr));
158+ if (rc)
159+ return rc;
160+ hdr->opcode = ISCSI_OP_SCSI_CMD;
161+ hdr->flags = ISCSI_ATTR_SIMPLE;
162+ int_to_scsilun(sc->device->lun, (struct scsi_lun *)hdr->lun);
163+ hdr->itt = build_itt(ctask->itt, conn->id, session->age);
164+ hdr->data_length = cpu_to_be32(scsi_bufflen(sc));
165+ hdr->cmdsn = cpu_to_be32(session->cmdsn);
166+ session->cmdsn++;
167+ hdr->exp_statsn = cpu_to_be32(conn->exp_statsn);
168+ memcpy(hdr->cdb, sc->cmnd, sc->cmd_len);
148169 if (sc->cmd_len < MAX_COMMAND_SIZE)
149170 memset(&hdr->cdb[sc->cmd_len], 0,
150171 MAX_COMMAND_SIZE - sc->cmd_len);
151172
152− ctask->data_count = 0;
153173 ctask->imm_count = 0;
154174 if (sc->sc_data_direction == DMA_TO_DEVICE) {
155175 hdr->flags |= ISCSI_FLAG_CMD_WRITE;
@@ -178,9 +198,9 @@ static void iscsi_prep_scsi_cmd_pdu(struct iscsi_cmd_task *ctask) · 22 unmodified lines
178198 else
179199 ctask->imm_count = min(scsi_bufflen(sc),
180200 conn->max_xmit_dlength);
181− hton24(ctask->hdr->dlength, ctask->imm_count);
201+ hton24(hdr->dlength, ctask->imm_count);
182202 } else
183− zero_data(ctask->hdr->dlength);
203+ zero_data(hdr->dlength);
184204
185205 if (!session->initial_r2t_en) {
186206 ctask->unsol_count = min((session->first_burst),
@@ -190,7 +210,7 @@ static void iscsi_prep_scsi_cmd_pdu(struct iscsi_cmd_task *ctask) · 3 unmodified lines
190210
191211 if (!ctask->unsol_count)
192212 /* No unsolicit Data-Out's */
193− ctask->hdr->flags |= ISCSI_FLAG_CMD_FINAL;
213+ hdr->flags |= ISCSI_FLAG_CMD_FINAL;
194214 } else {
195215 hdr->flags |= ISCSI_FLAG_CMD_FINAL;
196216 zero_data(hdr->dlength);
@@ -199,13 +219,25 @@ static void iscsi_prep_scsi_cmd_pdu(struct iscsi_cmd_task *ctask) · 2 unmodified lines
199219 hdr->flags |= ISCSI_FLAG_CMD_READ;
200220 }
201221
202− conn->scsicmd_pdus_cnt++;
222+ /* calculate size of additional header segments (AHSs) */
223+ hdrlength = ctask->hdr_len - sizeof(*hdr);
224+
225+ WARN_ON(hdrlength & (ISCSI_PAD_LEN-1));
226+ hdrlength /= ISCSI_PAD_LEN;
227+
228+ WARN_ON(hdrlength >= 256);
229+ hdr->hlength = hdrlength & 0xFF;
230+
231+ if (conn->session->tt->init_cmd_task(conn->ctask))
232+ return EIO;
203233
204− debug_scsi("iscsi prep [%s cid %d sc %p cdb 0x%x itt 0x%x len %d "
234+ conn->scsicmd_pdus_cnt++;
235+ debug_scsi("iscsi prep [%s cid %d sc %p cdb 0x%x itt 0x%x len %d "
205236 "cmdsn %d win %d]\n",
206− sc->sc_data_direction == DMA_TO_DEVICE ? "write" : "read",
237+ sc->sc_data_direction == DMA_TO_DEVICE ? "write" : "read",
207238 conn->id, sc, sc->cmnd[0], ctask->itt, scsi_bufflen(sc),
208− session->cmdsn, session->max_cmdsn - session->exp_cmdsn + 1);
239+ session->cmdsn, session->max_cmdsn - session->exp_cmdsn + 1);
240+ return 0;
209241 }
210242
211243 /**
@@ -218,13 +250,16 @@ static void iscsi_prep_scsi_cmd_pdu(struct iscsi_cmd_task *ctask) · 6 unmodified lines
218250 */
219251 static void iscsi_complete_command(struct iscsi_cmd_task *ctask)
220252 {
221− struct iscsi_session *session = ctask->conn->session;
253+ struct iscsi_conn *conn = ctask->conn;
254+ struct iscsi_session *session = conn->session;
222255 struct scsi_cmnd *sc = ctask->sc;
223256
224257 ctask->state = ISCSI_TASK_COMPLETED;
225258 ctask->sc = NULL;
226259 /* SCSI eh reuses commands to verify us */
227260 sc->SCp.ptr = NULL;
261+ if (conn->ctask == ctask)
262+ conn->ctask = NULL;
228263 list_del_init(&ctask->running);
229264 __kfifo_put(session->cmdpool.queue, (void*)&ctask, sizeof(void*));
230265 sc->scsi_done(sc);
@@ -241,6 +276,112 @@ static void __iscsi_put_ctask(struct iscsi_cmd_task *ctask) · 10 unmodified lines
241276 iscsi_complete_command(ctask);
242277 }
243278
279+/*
280+ * session lock must be held
281+ */
282+static void fail_command(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask,
283+ int err)
284+{
285+ struct scsi_cmnd *sc;
286+
287+ sc = ctask->sc;
288+ if (!sc)
289+ return;
290+
291+ if (ctask->state == ISCSI_TASK_PENDING)
292+ /*
293+ * cmd never made it to the xmit thread, so we should not count
294+ * the cmd in the sequencing
295+ */
296+ conn->session->queued_cmdsn--;
297+ else
298+ conn->session->tt->cleanup_cmd_task(conn, ctask);
299+
300+ sc->result = err;
301+ scsi_set_resid(sc, scsi_bufflen(sc));
302+ if (conn->ctask == ctask)
303+ conn->ctask = NULL;
304+ /* release ref from queuecommand */
305+ __iscsi_put_ctask(ctask);
306+}
307+
308+/**
309+ * iscsi_free_mgmt_task - return mgmt task back to pool
310+ * @conn: iscsi connection
311+ * @mtask: mtask
312+ *
313+ * Must be called with session lock.
314+ */
315+void iscsi_free_mgmt_task(struct iscsi_conn *conn,
316+ struct iscsi_mgmt_task *mtask)
317+{
318+ list_del_init(&mtask->running);
319+ if (conn->login_mtask == mtask)
320+ return;
321+
322+ if (conn->ping_mtask == mtask)
323+ conn->ping_mtask = NULL;
324+ __kfifo_put(conn->session->mgmtpool.queue,
325+ (void*)&mtask, sizeof(void*));
326+}
327+EXPORT_SYMBOL_GPL(iscsi_free_mgmt_task);
328+
329+static struct iscsi_mgmt_task *
330+__iscsi_conn_send_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
331+ char *data, uint32_t data_size)
332+{
333+ struct iscsi_session *session = conn->session;
334+ struct iscsi_mgmt_task *mtask;
335+
336+ if (session->state == ISCSI_STATE_TERMINATE)
337+ return NULL;
338+
339+ if (hdr->opcode == (ISCSI_OP_LOGIN | ISCSI_OP_IMMEDIATE) ||
340+ hdr->opcode == (ISCSI_OP_TEXT | ISCSI_OP_IMMEDIATE))
341+ /*
342+ * Login and Text are sent serially, in
343+ * request-followed-by-response sequence.
344+ * Same mtask can be used. Same ITT must be used.
345+ * Note that login_mtask is preallocated at conn_create().
346+ */
347+ mtask = conn->login_mtask;
348+ else {
349+ BUG_ON(conn->c_stage == ISCSI_CONN_INITIAL_STAGE);
350+ BUG_ON(conn->c_stage == ISCSI_CONN_STOPPED);
351+
352+ if (!__kfifo_get(session->mgmtpool.queue,
353+ (void*)&mtask, sizeof(void*)))
354+ return NULL;
355+ }
356+
357+ if (data_size) {
358+ memcpy(mtask->data, data, data_size);
359+ mtask->data_count = data_size;
360+ } else
361+ mtask->data_count = 0;
362+
363+ memcpy(mtask->hdr, hdr, sizeof(struct iscsi_hdr));
364+ INIT_LIST_HEAD(&mtask->running);
365+ list_add_tail(&mtask->running, &conn->mgmtqueue);
366+ return mtask;
367+}
368+
369+int iscsi_conn_send_pdu(struct iscsi_cls_conn *cls_conn, struct iscsi_hdr *hdr,
370+ char *data, uint32_t data_size)
371+{
372+ struct iscsi_conn *conn = cls_conn->dd_data;
373+ struct iscsi_session *session = conn->session;
374+ int err = 0;
375+
376+ spin_lock_bh(&session->lock);
377+ if (!__iscsi_conn_send_pdu(conn, hdr, data, data_size))
378+ err = -EPERM;
379+ spin_unlock_bh(&session->lock);
380+ scsi_queue_work(session->host, &conn->xmitwork);
381+ return err;
382+}
383+EXPORT_SYMBOL_GPL(iscsi_conn_send_pdu);
384+
244385 /**
245386 * iscsi_cmd_rsp - SCSI Command Response processing
246387 * @conn: iscsi connection
@@ -291,17 +432,19 @@ invalid_datalen: · 44 unmodified lines
291432 min_t(uint16_t, senselen, SCSI_SENSE_BUFFERSIZE));
292433 }
293434
294− if (rhdr->flags & ISCSI_FLAG_CMD_UNDERFLOW) {
435+ if (rhdr->flags & (ISCSI_FLAG_CMD_UNDERFLOW |
436+ ISCSI_FLAG_CMD_OVERFLOW)) {
295437 int res_count = be32_to_cpu(rhdr->residual_count);
296438
297− if (res_count > 0 && res_count <= scsi_bufflen(sc))
439+ if (res_count > 0 &&
440+ (rhdr->flags & ISCSI_FLAG_CMD_OVERFLOW ||
441+ res_count <= scsi_bufflen(sc)))
298442 scsi_set_resid(sc, res_count);
299443 else
300444 sc->result = (DID_BAD_TARGET << 16) | rhdr->cmd_status;
301− } else if (rhdr->flags & ISCSI_FLAG_CMD_BIDI_UNDERFLOW)
445+ } else if (rhdr->flags & (ISCSI_FLAG_CMD_BIDI_UNDERFLOW |
446+ ISCSI_FLAG_CMD_BIDI_OVERFLOW))
302447 sc->result = (DID_BAD_TARGET << 16) | rhdr->cmd_status;
303− else if (rhdr->flags & ISCSI_FLAG_CMD_OVERFLOW)
304− scsi_set_resid(sc, be32_to_cpu(rhdr->residual_count));
305448
306449 out:
307450 debug_scsi("done [sc %lx res %d itt 0x%x]\n",
@@ -318,18 +461,51 @@ static void iscsi_tmf_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr) · 10 unmodified lines
318461 conn->exp_statsn = be32_to_cpu(hdr->statsn) + 1;
319462 conn->tmfrsp_pdus_cnt++;
320463
321− if (conn->tmabort_state != TMABORT_INITIAL)
464+ if (conn->tmf_state != TMF_QUEUED)
322465 return;
323466
324467 if (tmf->response == ISCSI_TMF_RSP_COMPLETE)
325− conn->tmabort_state = TMABORT_SUCCESS;
468+ conn->tmf_state = TMF_SUCCESS;
326469 else if (tmf->response == ISCSI_TMF_RSP_NO_TASK)
327− conn->tmabort_state = TMABORT_NOT_FOUND;
470+ conn->tmf_state = TMF_NOT_FOUND;
328471 else
329− conn->tmabort_state = TMABORT_FAILED;
472+ conn->tmf_state = TMF_FAILED;
330473 wake_up(&conn->ehwait);
331474 }
332475
476+static void iscsi_send_nopout(struct iscsi_conn *conn, struct iscsi_nopin *rhdr)
477+{
478+ struct iscsi_nopout hdr;
479+ struct iscsi_mgmt_task *mtask;
480+
481+ if (!rhdr && conn->ping_mtask)
482+ return;
483+
484+ memset(&hdr, 0, sizeof(struct iscsi_nopout));
485+ hdr.opcode = ISCSI_OP_NOOP_OUT | ISCSI_OP_IMMEDIATE;
486+ hdr.flags = ISCSI_FLAG_CMD_FINAL;
487+
488+ if (rhdr) {
489+ memcpy(hdr.lun, rhdr->lun, 8);
490+ hdr.ttt = rhdr->ttt;
491+ hdr.itt = RESERVED_ITT;
492+ } else
493+ hdr.ttt = RESERVED_ITT;
494+
495+ mtask = __iscsi_conn_send_pdu(conn, (struct iscsi_hdr *)&hdr, NULL, 0);
496+ if (!mtask) {
497+ printk(KERN_ERR "Could not send nopout\n");
498+ return;
499+ }
500+
501+ /* only track our nops */
502+ if (!rhdr) {
503+ conn->ping_mtask = mtask;
504+ conn->last_ping = jiffies;
505+ }
506+ scsi_queue_work(conn->session->host, &conn->xmitwork);
507+}
508+
333509 static int iscsi_handle_reject(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
334510 char *data, int datalen)
335511 {
@@ -374,6 +550,7 @@ int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr, · 38 unmodified lines
374550 struct iscsi_mgmt_task *mtask;
375551 uint32_t itt;
376552
553+ conn->last_recv = jiffies;
377554 if (hdr->itt != RESERVED_ITT)
378555 itt = get_itt(hdr->itt);
379556 else
@@ -429,10 +606,7 @@ int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr, · 49 unmodified lines
429606 */
430607 if (iscsi_recv_pdu(conn->cls_conn, hdr, data, datalen))
431608 rc = ISCSI_ERR_CONN_FAILED;
432− list_del(&mtask->running);
433− if (conn->login_mtask != mtask)
434− __kfifo_put(session->mgmtpool.queue,
435− (void*)&mtask, sizeof(void*));
609+ iscsi_free_mgmt_task(conn, mtask);
436610 break;
437611 case ISCSI_OP_SCSI_TMFUNC_RSP:
438612 if (datalen) {
@@ -441,20 +615,26 @@ int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr, · 2 unmodified lines
441615 }
442616
443617 iscsi_tmf_rsp(conn, hdr);
618+ iscsi_free_mgmt_task(conn, mtask);
444619 break;
445620 case ISCSI_OP_NOOP_IN:
446− if (hdr->ttt != cpu_to_be32(ISCSI_RESERVED_TAG) || datalen) {
621+ if (hdr->ttt != cpu_to_be32(ISCSI_RESERVED_TAG) ||
622+ datalen) {
447623 rc = ISCSI_ERR_PROTO;
448624 break;
449625 }
450626 conn->exp_statsn = be32_to_cpu(hdr->statsn) + 1;
451627
452− if (iscsi_recv_pdu(conn->cls_conn, hdr, data, datalen))
453− rc = ISCSI_ERR_CONN_FAILED;
454− list_del(&mtask->running);
455− if (conn->login_mtask != mtask)
456− __kfifo_put(session->mgmtpool.queue,
457− (void*)&mtask, sizeof(void*));
628+ if (conn->ping_mtask != mtask) {
629+ /*
630+ * If this is not in response to one of our
631+ * nops then it must be from userspace.
632+ */
633+ if (iscsi_recv_pdu(conn->cls_conn, hdr, data,
634+ datalen))
635+ rc = ISCSI_ERR_CONN_FAILED;
636+ }
637+ iscsi_free_mgmt_task(conn, mtask);
458638 break;
459639 default:
460640 rc = ISCSI_ERR_BAD_OPCODE;
@@ -473,8 +653,7 @@ int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr, · 12 unmodified lines
473653 if (hdr->ttt == cpu_to_be32(ISCSI_RESERVED_TAG))
474654 break;
475655
476− if (iscsi_recv_pdu(conn->cls_conn, hdr, NULL, 0))
477− rc = ISCSI_ERR_CONN_FAILED;
656+ iscsi_send_nopout(conn, (struct iscsi_nopin*)hdr);
478657 break;
479658 case ISCSI_OP_REJECT:
480659 rc = iscsi_handle_reject(conn, hdr, data, datalen);
@@ -609,20 +788,19 @@ static void iscsi_prep_mtask(struct iscsi_conn *conn, · 128 unmodified lines
609788 session->tt->init_mgmt_task(conn, mtask);
610789
611790 debug_scsi("mgmtpdu [op 0x%x hdr->itt 0x%x datalen %d]\n",
612− hdr->opcode, hdr->itt, mtask->data_count);
791+ hdr->opcode & ISCSI_OPCODE_MASK, hdr->itt,
792+ mtask->data_count);
613793 }
614794
615795 static int iscsi_xmit_mtask(struct iscsi_conn *conn)
616796 {
617797 struct iscsi_hdr *hdr = conn->mtask->hdr;
618− int rc, was_logout = 0;
798+ int rc;
619799
800+ if ((hdr->opcode & ISCSI_OPCODE_MASK) == ISCSI_OP_LOGOUT)
801+ conn->session->state = ISCSI_STATE_LOGGING_OUT;
620802 spin_unlock_bh(&conn->session->lock);
621− if ((hdr->opcode & ISCSI_OPCODE_MASK) == ISCSI_OP_LOGOUT) {
622− conn->session->state = ISCSI_STATE_IN_RECOVERY;
623− iscsi_block_session(session_to_cls(conn->session));
624− was_logout = 1;
625− }
803+
626804 rc = conn->session->tt->xmit_mgmt_task(conn, conn->mtask);
627805 spin_lock_bh(&conn->session->lock);
628806 if (rc)
@@ -630,11 +808,6 @@ static int iscsi_xmit_mtask(struct iscsi_conn *conn) · 1 unmodified line
630808
631809 /* done with this in-progress mtask */
632810 conn->mtask = NULL;
633−
634− if (was_logout) {
635− set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx);
636− return -ENODATA;
637− }
638811 return 0;
639812 }
640813
@@ -658,27 +831,35 @@ static int iscsi_check_cmdsn_window_closed(struct iscsi_conn *conn) · 17 unmodified lines
658831 static int iscsi_xmit_ctask(struct iscsi_conn *conn)
659832 {
660833 struct iscsi_cmd_task *ctask = conn->ctask;
661− int rc = 0;
662−
663− /*
664− * serialize with TMF AbortTask
665− */
666− if (ctask->state == ISCSI_TASK_ABORTING)
667− goto done;
834+ int rc;
668835
669836 __iscsi_get_ctask(ctask);
670837 spin_unlock_bh(&conn->session->lock);
671838 rc = conn->session->tt->xmit_cmd_task(conn, ctask);
672839 spin_lock_bh(&conn->session->lock);
673840 __iscsi_put_ctask(ctask);
674−
675−done:
676841 if (!rc)
677842 /* done with this ctask */
678843 conn->ctask = NULL;
679844 return rc;
680845 }
681846
847+/**
848+ * iscsi_requeue_ctask - requeue ctask to run from session workqueue
849+ * @ctask: ctask to requeue
850+ *
851+ * LLDs that need to run a ctask from the session workqueue should call
852+ * this. The session lock must be held.
853+ */
854+void iscsi_requeue_ctask(struct iscsi_cmd_task *ctask)
855+{
856+ struct iscsi_conn *conn = ctask->conn;
857+
858+ list_move_tail(&ctask->running, &conn->requeue);
859+ scsi_queue_work(conn->session->host, &conn->xmitwork);
860+}
861+EXPORT_SYMBOL_GPL(iscsi_requeue_ctask);
862+
682863 /**
683864 * iscsi_data_xmit - xmit any command into the scheduled connection
684865 * @conn: iscsi connection
@@ -717,36 +898,40 @@ static int iscsi_data_xmit(struct iscsi_conn *conn) · 32 unmodified lines
717898 * overflow us with nop-ins
718899 */
719900 check_mgmt:
720− while (__kfifo_get(conn->mgmtqueue, (void*)&conn->mtask,
721− sizeof(void*))) {
901+ while (!list_empty(&conn->mgmtqueue)) {
902+ conn->mtask = list_entry(conn->mgmtqueue.next,
903+ struct iscsi_mgmt_task, running);
904+ if (conn->session->state == ISCSI_STATE_LOGGING_OUT) {
905+ iscsi_free_mgmt_task(conn, conn->mtask);
906+ conn->mtask = NULL;
907+ continue;
908+ }
909+
722910 iscsi_prep_mtask(conn, conn->mtask);
723− list_add_tail(&conn->mtask->running, &conn->mgmt_run_list);
911+ list_move_tail(conn->mgmtqueue.next, &conn->mgmt_run_list);
724912 rc = iscsi_xmit_mtask(conn);
725913 if (rc)
726914 goto again;
727915 }
728916
729− /* process command queue */
917+ /* process pending command queue */
730918 while (!list_empty(&conn->xmitqueue)) {
731− /*
732− * iscsi tcp may readd the task to the xmitqueue to send
733− * write data
734− */
919+ if (conn->tmf_state == TMF_QUEUED)
920+ break;
921+
735922 conn->ctask = list_entry(conn->xmitqueue.next,
736923 struct iscsi_cmd_task, running);
737− switch (conn->ctask->state) {
738− case ISCSI_TASK_ABORTING:
739− break;
740− case ISCSI_TASK_PENDING:
741− iscsi_prep_scsi_cmd_pdu(conn->ctask);
742− conn->session->tt->init_cmd_task(conn->ctask);
743− /* fall through */
744− default:
745− conn->ctask->state = ISCSI_TASK_RUNNING;
746− break;
924+ if (conn->session->state == ISCSI_STATE_LOGGING_OUT) {
925+ fail_command(conn, conn->ctask, DID_IMM_RETRY << 16);
926+ continue;
927+ }
928+ if (iscsi_prep_scsi_cmd_pdu(conn->ctask)) {
929+ fail_command(conn, conn->ctask, DID_ABORT << 16);
930+ continue;
747931 }
748− list_move_tail(conn->xmitqueue.next, &conn->run_list);
749932
933+ conn->ctask->state = ISCSI_TASK_RUNNING;
934+ list_move_tail(conn->xmitqueue.next, &conn->run_list);
750935 rc = iscsi_xmit_ctask(conn);
751936 if (rc)
752937 goto again;
@@ -755,7 +940,28 @@ check_mgmt: · 2 unmodified lines
755940 * we need to check the mgmt queue for nops that need to
756941 * be sent to aviod starvation
757942 */
758− if (__kfifo_len(conn->mgmtqueue))
943+ if (!list_empty(&conn->mgmtqueue))
944+ goto check_mgmt;
945+ }
946+
947+ while (!list_empty(&conn->requeue)) {
948+ if (conn->session->fast_abort && conn->tmf_state != TMF_INITIAL)
949+ break;
950+
951+ /*
952+ * we always do fastlogout - conn stop code will clean up.
953+ */
954+ if (conn->session->state == ISCSI_STATE_LOGGING_OUT)
955+ break;
956+
957+ conn->ctask = list_entry(conn->requeue.next,
958+ struct iscsi_cmd_task, running);
959+ conn->ctask->state = ISCSI_TASK_RUNNING;
960+ list_move_tail(conn->requeue.next, &conn->run_list);
961+ rc = iscsi_xmit_ctask(conn);
962+ if (rc)
963+ goto again;
964+ if (!list_empty(&conn->mgmtqueue))
759965 goto check_mgmt;
760966 }
761967 spin_unlock_bh(&conn->session->lock);
@@ -790,6 +996,7 @@ enum { · 28 unmodified lines
790996 FAILURE_SESSION_TERMINATE,
791997 FAILURE_SESSION_IN_RECOVERY,
792998 FAILURE_SESSION_RECOVERY_TIMEOUT,
999+ FAILURE_SESSION_LOGGING_OUT,
7931000 };
7941001
7951002 int iscsi_queuecommand(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *))
@@ -805,8 +1012,9 @@ int iscsi_queuecommand(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *)) · 9 unmodified lines
8051012 sc->SCp.ptr = NULL;
8061013
8071014 host = sc->device->host;
808− session = iscsi_hostdata(host->hostdata);
1015+ spin_unlock(host->host_lock);
8091016
1017+ session = iscsi_hostdata(host->hostdata);
8101018 spin_lock(&session->lock);
8111019
8121020 /*
@@ -822,17 +1030,22 @@ int iscsi_queuecommand(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *)) · 9 unmodified lines
8221030 * be entering our queuecommand while a block is starting
8231031 * up because the block code is not locked)
8241032 */
825− if (session->state == ISCSI_STATE_IN_RECOVERY) {
1033+ switch (session->state) {
1034+ case ISCSI_STATE_IN_RECOVERY:
8261035 reason = FAILURE_SESSION_IN_RECOVERY;
8271036 goto reject;
828− }
829−
830− if (session->state == ISCSI_STATE_RECOVERY_FAILED)
1037+ case ISCSI_STATE_LOGGING_OUT:
1038+ reason = FAILURE_SESSION_LOGGING_OUT;
1039+ goto reject;
1040+ case ISCSI_STATE_RECOVERY_FAILED:
8311041 reason = FAILURE_SESSION_RECOVERY_TIMEOUT;
832− else if (session->state == ISCSI_STATE_TERMINATE)
1042+ break;
1043+ case ISCSI_STATE_TERMINATE:
8331044 reason = FAILURE_SESSION_TERMINATE;
834− else
1045+ break;
1046+ default:
8351047 reason = FAILURE_SESSION_FREED;
1048+ }
8361049 goto fault;
8371050 }
8381051
@@ -859,7 +1072,6 @@ int iscsi_queuecommand(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *)) · 20 unmodified lines
8591072
8601073 atomic_set(&ctask->refcount, 1);
8611074 ctask->state = ISCSI_TASK_PENDING;
862− ctask->mtask = NULL;
8631075 ctask->conn = conn;
8641076 ctask->sc = sc;
8651077 INIT_LIST_HEAD(&ctask->running);
@@ -868,11 +1080,13 @@ int iscsi_queuecommand(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *)) · 2 unmodified lines
8681080 spin_unlock(&session->lock);
8691081
8701082 scsi_queue_work(host, &conn->xmitwork);
1083+ spin_lock(host->host_lock);
8711084 return 0;
8721085
8731086 reject:
8741087 spin_unlock(&session->lock);
8751088 debug_scsi("cmd 0x%x rejected (%d)\n", sc->cmnd[0], reason);
1089+ spin_lock(host->host_lock);
8761090 return SCSI_MLQUEUE_HOST_BUSY;
8771091
8781092 fault:
@@ -882,6 +1096,7 @@ fault: · 3 unmodified lines
8821096 sc->result = (DID_NO_CONNECT << 16);
8831097 scsi_set_resid(sc, scsi_bufflen(sc));
8841098 sc->scsi_done(sc);
1099+ spin_lock(host->host_lock);
8851100 return 0;
8861101 }
8871102 EXPORT_SYMBOL_GPL(iscsi_queuecommand);
@@ -895,72 +1110,15 @@ int iscsi_change_queue_depth(struct scsi_device *sdev, int depth) · 7 unmodified lines
8951110 }
8961111 EXPORT_SYMBOL_GPL(iscsi_change_queue_depth);
8971112
898−static struct iscsi_mgmt_task *
899−__iscsi_conn_send_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
900− char *data, uint32_t data_size)
901−{
902− struct iscsi_session *session = conn->session;
903− struct iscsi_mgmt_task *mtask;
904−
905− if (session->state == ISCSI_STATE_TERMINATE)
906− return NULL;
907−
908− if (hdr->opcode == (ISCSI_OP_LOGIN | ISCSI_OP_IMMEDIATE) ||
909− hdr->opcode == (ISCSI_OP_TEXT | ISCSI_OP_IMMEDIATE))
910− /*
911− * Login and Text are sent serially, in
912− * request-followed-by-response sequence.
913− * Same mtask can be used. Same ITT must be used.
914− * Note that login_mtask is preallocated at conn_create().
915− */
916− mtask = conn->login_mtask;
917− else {
918− BUG_ON(conn->c_stage == ISCSI_CONN_INITIAL_STAGE);
919− BUG_ON(conn->c_stage == ISCSI_CONN_STOPPED);
920−
921− if (!__kfifo_get(session->mgmtpool.queue,
922− (void*)&mtask, sizeof(void*)))
923− return NULL;
924− }
925−
926− if (data_size) {
927− memcpy(mtask->data, data, data_size);
928− mtask->data_count = data_size;
929− } else
930− mtask->data_count = 0;
931−
932− INIT_LIST_HEAD(&mtask->running);
933− memcpy(mtask->hdr, hdr, sizeof(struct iscsi_hdr));
934− __kfifo_put(conn->mgmtqueue, (void*)&mtask, sizeof(void*));
935− return mtask;
936−}
937−
938−int iscsi_conn_send_pdu(struct iscsi_cls_conn *cls_conn, struct iscsi_hdr *hdr,
939− char *data, uint32_t data_size)
940−{
941− struct iscsi_conn *conn = cls_conn->dd_data;
942− struct iscsi_session *session = conn->session;
943− int err = 0;
944−
945− spin_lock_bh(&session->lock);
946− if (!__iscsi_conn_send_pdu(conn, hdr, data, data_size))
947− err = -EPERM;
948− spin_unlock_bh(&session->lock);
949− scsi_queue_work(session->host, &conn->xmitwork);
950− return err;
951−}
952−EXPORT_SYMBOL_GPL(iscsi_conn_send_pdu);
953−
9541113 void iscsi_session_recovery_timedout(struct iscsi_cls_session *cls_session)
9551114 {
9561115 struct iscsi_session *session = class_to_transport_session(cls_session);
957− struct iscsi_conn *conn = session->leadconn;
9581116
9591117 spin_lock_bh(&session->lock);
9601118 if (session->state != ISCSI_STATE_LOGGED_IN) {
9611119 session->state = ISCSI_STATE_RECOVERY_FAILED;
962− if (conn)
963− wake_up(&conn->ehwait);
1120+ if (session->leadconn)
1121+ wake_up(&session->leadconn->ehwait);
9641122 }
9651123 spin_unlock_bh(&session->lock);
9661124 }
@@ -971,30 +1129,25 @@ int iscsi_eh_host_reset(struct scsi_cmnd *sc) · 4 unmodified lines
9711129 struct Scsi_Host *host = sc->device->host;
9721130 struct iscsi_session *session = iscsi_hostdata(host->hostdata);
9731131 struct iscsi_conn *conn = session->leadconn;
974− int fail_session = 0;
9751132
1133+ mutex_lock(&session->eh_mutex);
9761134 spin_lock_bh(&session->lock);
9771135 if (session->state == ISCSI_STATE_TERMINATE) {
9781136 failed:
9791137 debug_scsi("failing host reset: session terminated "
9801138 "[CID %d age %d]\n", conn->id, session->age);
9811139 spin_unlock_bh(&session->lock);
1140+ mutex_unlock(&session->eh_mutex);
9821141 return FAILED;
9831142 }
9841143
985− if (sc->SCp.phase == session->age) {
986− debug_scsi("failing connection CID %d due to SCSI host reset\n",
987− conn->id);
988− fail_session = 1;
989− }
9901144 spin_unlock_bh(&session->lock);
991−
1145+ mutex_unlock(&session->eh_mutex);
9921146 /*
9931147 * we drop the lock here but the leadconn cannot be destoyed while
9941148 * we are in the scsi eh
9951149 */
996− if (fail_session)
997− iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
1150+ iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
9981151
9991152 debug_scsi("iscsi_eh_host_reset wait for relogin\n");
10001153 wait_event_interruptible(conn->ehwait,
@@ -1004,73 +1157,56 @@ failed: · 3 unmodified lines
10041157 if (signal_pending(current))
10051158 flush_signals(current);
10061159
1160+ mutex_lock(&session->eh_mutex);
10071161 spin_lock_bh(&session->lock);
10081162 if (session->state == ISCSI_STATE_LOGGED_IN)
10091163 printk(KERN_INFO "iscsi: host reset succeeded\n");
10101164 else
10111165 goto failed;
10121166 spin_unlock_bh(&session->lock);
1013−
1167+ mutex_unlock(&session->eh_mutex);
10141168 return SUCCESS;
10151169 }
10161170 EXPORT_SYMBOL_GPL(iscsi_eh_host_reset);
10171171
1018−static void iscsi_tmabort_timedout(unsigned long data)
1172+static void iscsi_tmf_timedout(unsigned long data)
10191173 {
1020− struct iscsi_cmd_task *ctask = (struct iscsi_cmd_task *)data;
1021− struct iscsi_conn *conn = ctask->conn;
1174+ struct iscsi_conn *conn = (struct iscsi_conn *)data;
10221175 struct iscsi_session *session = conn->session;
10231176
10241177 spin_lock(&session->lock);
1025− if (conn->tmabort_state == TMABORT_INITIAL) {
1026− conn->tmabort_state = TMABORT_TIMEDOUT;
1027− debug_scsi("tmabort timedout [sc %p itt 0x%x]\n",
1028− ctask->sc, ctask->itt);
1178+ if (conn->tmf_state == TMF_QUEUED) {
1179+ conn->tmf_state = TMF_TIMEDOUT;
1180+ debug_scsi("tmf timedout\n");
10291181 /* unblock eh_abort() */
10301182 wake_up(&conn->ehwait);
10311183 }
10321184 spin_unlock(&session->lock);
10331185 }
10341186
1035−static int iscsi_exec_abort_task(struct scsi_cmnd *sc,
1036− struct iscsi_cmd_task *ctask)
1187+static int iscsi_exec_task_mgmt_fn(struct iscsi_conn *conn,
1188+ struct iscsi_tm *hdr, int age,
1189+ int timeout)
10371190 {
1038− struct iscsi_conn *conn = ctask->conn;
10391191 struct iscsi_session *session = conn->session;
1040− struct iscsi_tm *hdr = &conn->tmhdr;
1041−
1042− /*
1043− * ctask timed out but session is OK requests must be serialized.
1044− */
1045− memset(hdr, 0, sizeof(struct iscsi_tm));
1046− hdr->opcode = ISCSI_OP_SCSI_TMFUNC | ISCSI_OP_IMMEDIATE;
1047− hdr->flags = ISCSI_TM_FUNC_ABORT_TASK;
1048− hdr->flags |= ISCSI_FLAG_CMD_FINAL;
1049− memcpy(hdr->lun, ctask->hdr->lun, sizeof(hdr->lun));
1050− hdr->rtt = ctask->hdr->itt;
1051− hdr->refcmdsn = ctask->hdr->cmdsn;
1192+ struct iscsi_mgmt_task *mtask;
10521193
1053− ctask->mtask = __iscsi_conn_send_pdu(conn, (struct iscsi_hdr *)hdr,
1054− NULL, 0);
1055− if (!ctask->mtask) {
1194+ mtask = __iscsi_conn_send_pdu(conn, (struct iscsi_hdr *)hdr,
1195+ NULL, 0);
1196+ if (!mtask) {
10561197 spin_unlock_bh(&session->lock);
10571198 iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
1058− spin_lock_bh(&session->lock)
1059− debug_scsi("abort sent failure [itt 0x%x]\n", ctask->itt);
1199+ spin_lock_bh(&session->lock);
1200+ debug_scsi("tmf exec failure\n");
10601201 return -EPERM;
10611202 }
1062− ctask->state = ISCSI_TASK_ABORTING;
1203+ conn->tmfcmd_pdus_cnt++;
1204+ conn->tmf_timer.expires = timeout * HZ + jiffies;
1205+ conn->tmf_timer.function = iscsi_tmf_timedout;
1206+ conn->tmf_timer.data = (unsigned long)conn;
1207+ add_timer(&conn->tmf_timer);
1208+ debug_scsi("tmf set timeout\n");
10631209
1064− debug_scsi("abort sent [itt 0x%x]\n", ctask->itt);
1065−
1066− if (conn->tmabort_state == TMABORT_INITIAL) {
1067− conn->tmfcmd_pdus_cnt++;
1068− conn->tmabort_timer.expires = 20*HZ + jiffies;
1069− conn->tmabort_timer.function = iscsi_tmabort_timedout;
1070− conn->tmabort_timer.data = (unsigned long)ctask;
1071− add_timer(&conn->tmabort_timer);
1072− debug_scsi("abort set timeout [itt 0x%x]\n", ctask->itt);
1073− }
10741210 spin_unlock_bh(&session->lock);
10751211 mutex_unlock(&session->eh_mutex);
10761212 scsi_queue_work(session->host, &conn->xmitwork);
@@ -1078,113 +1214,197 @@ static int iscsi_exec_abort_task(struct scsi_cmnd *sc, · 1 unmodified line
10781214 /*
10791215 * block eh thread until:
10801216 *
1081− * 1) abort response
1082− * 2) abort timeout
1217+ * 1) tmf response
1218+ * 2) tmf timeout
10831219 * 3) session is terminated or restarted or userspace has
10841220 * given up on recovery
10851221 */
1086− wait_event_interruptible(conn->ehwait,
1087− sc->SCp.phase != session->age ||
1222+ wait_event_interruptible(conn->ehwait, age != session->age ||
10881223 session->state != ISCSI_STATE_LOGGED_IN ||
1089− conn->tmabort_state != TMABORT_INITIAL);
1224+ conn->tmf_state != TMF_QUEUED);
10901225 if (signal_pending(current))
10911226 flush_signals(current);
1092− del_timer_sync(&conn->tmabort_timer);
1227+ del_timer_sync(&conn->tmf_timer);
1228+
10931229 mutex_lock(&session->eh_mutex);
10941230 spin_lock_bh(&session->lock);
1231+ /* if the session drops it will clean up the mtask */
1232+ if (age != session->age ||
1233+ session->state != ISCSI_STATE_LOGGED_IN)
1234+ return -ENOTCONN;
10951235 return 0;
10961236 }
10971237
10981238 /*
1099− * session lock must be held
1239+ * Fail commands. session lock held and recv side suspended and xmit
1240+ * thread flushed
11001241 */
1101−static struct iscsi_mgmt_task *
1102−iscsi_remove_mgmt_task(struct kfifo *fifo, uint32_t itt)
1242+static void fail_all_commands(struct iscsi_conn *conn, unsigned lun)
11031243 {
1104− int i, nr_tasks = __kfifo_len(fifo) / sizeof(void*);
1105− struct iscsi_mgmt_task *task;
1244+ struct iscsi_cmd_task *ctask, *tmp;
11061245
1107− debug_scsi("searching %d tasks\n", nr_tasks);
1246+ if (conn->ctask && (conn->ctask->sc->device->lun == lun || lun == -1))
1247+ conn->ctask = NULL;
11081248
1109− for (i = 0; i < nr_tasks; i++) {
1110− __kfifo_get(fifo, (void*)&task, sizeof(void*));
1111− debug_scsi("check task %u\n", task->itt);
1249+ /* flush pending */
1250+ list_for_each_entry_safe(ctask, tmp, &conn->xmitqueue, running) {
1251+ if (lun == ctask->sc->device->lun || lun == -1) {
1252+ debug_scsi("failing pending sc %p itt 0x%x\n",
1253+ ctask->sc, ctask->itt);
1254+ fail_command(conn, ctask, DID_BUS_BUSY << 16);
1255+ }
1256+ }
11121257
1113− if (task->itt == itt) {
1114− debug_scsi("matched task\n");
1115− return task;
1258+ list_for_each_entry_safe(ctask, tmp, &conn->requeue, running) {
1259+ if (lun == ctask->sc->device->lun || lun == -1) {
1260+ debug_scsi("failing requeued sc %p itt 0x%x\n",
1261+ ctask->sc, ctask->itt);
1262+ fail_command(conn, ctask, DID_BUS_BUSY << 16);
11161263 }
1264+ }
11171265
1118− __kfifo_put(fifo, (void*)&task, sizeof(void*));
1266+ /* fail all other running */
1267+ list_for_each_entry_safe(ctask, tmp, &conn->run_list, running) {
1268+ if (lun == ctask->sc->device->lun || lun == -1) {
1269+ debug_scsi("failing in progress sc %p itt 0x%x\n",
1270+ ctask->sc, ctask->itt);
1271+ fail_command(conn, ctask, DID_BUS_BUSY << 16);
1272+ }
11191273 }
1120− return NULL;
11211274 }
11221275
1123−static int iscsi_ctask_mtask_cleanup(struct iscsi_cmd_task *ctask)
1276+static void iscsi_suspend_tx(struct iscsi_conn *conn)
11241277 {
1125− struct iscsi_conn *conn = ctask->conn;
1126− struct iscsi_session *session = conn->session;
1127−
1128− if (!ctask->mtask)
1129− return -EINVAL;
1278+ set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx);
1279+ scsi_flush_work(conn->session->host);
1280+}
11301281
1131− if (!iscsi_remove_mgmt_task(conn->mgmtqueue, ctask->mtask->itt))
1132− list_del(&ctask->mtask->running);
1133− __kfifo_put(session->mgmtpool.queue, (void*)&ctask->mtask,
1134− sizeof(void*));
1135− ctask->mtask = NULL;
1136− return 0;
1282+static void iscsi_start_tx(struct iscsi_conn *conn)
1283+{
1284+ clear_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx);
1285+ scsi_queue_work(conn->session->host, &conn->xmitwork);
11371286 }
11381287
1139−/*
1140− * session lock must be held
1141− */
1142−static void fail_command(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask,
1143− int err)
1288+static enum scsi_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *scmd)
11441289 {
1145− struct scsi_cmnd *sc;
1290+ struct iscsi_cls_session *cls_session;
1291+ struct iscsi_session *session;
1292+ struct iscsi_conn *conn;
1293+ enum scsi_eh_timer_return rc = EH_NOT_HANDLED;
11461294
1147− sc = ctask->sc;
1148− if (!sc)
1149− return;
1295+ cls_session = starget_to_session(scsi_target(scmd->device));
1296+ session = class_to_transport_session(cls_session);
11501297
1151− if (ctask->state == ISCSI_TASK_PENDING)
1298+ debug_scsi("scsi cmd %p timedout\n", scmd);
1299+
1300+ spin_lock(&session->lock);
1301+ if (session->state != ISCSI_STATE_LOGGED_IN) {
11521302 /*
1153− * cmd never made it to the xmit thread, so we should not count
1154− * the cmd in the sequencing
1303+ * We are probably in the middle of iscsi recovery so let
1304+ * that complete and handle the error.
11551305 */
1156− conn->session->queued_cmdsn--;
1157− else
1158− conn->session->tt->cleanup_cmd_task(conn, ctask);
1159− iscsi_ctask_mtask_cleanup(ctask);
1306+ rc = EH_RESET_TIMER;
1307+ goto done;
1308+ }
11601309
1161− sc->result = err;
1162− scsi_set_resid(sc, scsi_bufflen(sc));
1163− if (conn->ctask == ctask)
1164− conn->ctask = NULL;
1165− /* release ref from queuecommand */
1166− __iscsi_put_ctask(ctask);
1310+ conn = session->leadconn;
1311+ if (!conn) {
1312+ /* In the middle of shuting down */
1313+ rc = EH_RESET_TIMER;
1314+ goto done;
1315+ }
1316+
1317+ if (!conn->recv_timeout && !conn->ping_timeout)
1318+ goto done;
1319+ /*
1320+ * if the ping timedout then we are in the middle of cleaning up
1321+ * and can let the iscsi eh handle it
1322+ */
1323+ if (time_before_eq(conn->last_recv + (conn->recv_timeout * HZ) +
1324+ (conn->ping_timeout * HZ), jiffies))
1325+ rc = EH_RESET_TIMER;
1326+ /*
1327+ * if we are about to check the transport then give the command
1328+ * more time
1329+ */
1330+ if (time_before_eq(conn->last_recv + (conn->recv_timeout * HZ),
1331+ jiffies))
1332+ rc = EH_RESET_TIMER;
1333+ /* if in the middle of checking the transport then give us more time */
1334+ if (conn->ping_mtask)
1335+ rc = EH_RESET_TIMER;
1336+done:
1337+ spin_unlock(&session->lock);
1338+ debug_scsi("return %s\n", rc == EH_RESET_TIMER ? "timer reset" : "nh");
1339+ return rc;
11671340 }
11681341
1169−static void iscsi_suspend_tx(struct iscsi_conn *conn)
1342+static void iscsi_check_transport_timeouts(unsigned long data)
11701343 {
1171− set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx);
1172− scsi_flush_work(conn->session->host);
1344+ struct iscsi_conn *conn = (struct iscsi_conn *)data;
1345+ struct iscsi_session *session = conn->session;
1346+ unsigned long timeout, next_timeout = 0, last_recv;
1347+
1348+ spin_lock(&session->lock);
1349+ if (session->state != ISCSI_STATE_LOGGED_IN)
1350+ goto done;
1351+
1352+ timeout = conn->recv_timeout;
1353+ if (!timeout)
1354+ goto done;
1355+
1356+ timeout *= HZ;
1357+ last_recv = conn->last_recv;
1358+ if (time_before_eq(last_recv + timeout + (conn->ping_timeout * HZ),
1359+ jiffies)) {
1360+ printk(KERN_ERR "ping timeout of %d secs expired, "
1361+ "last rx %lu, last ping %lu, now %lu\n",
1362+ conn->ping_timeout, last_recv,
1363+ conn->last_ping, jiffies);
1364+ spin_unlock(&session->lock);
1365+ iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
1366+ return;
1367+ }
1368+
1369+ if (time_before_eq(last_recv + timeout, jiffies)) {
1370+ if (time_before_eq(conn->last_ping, last_recv)) {
1371+ /* send a ping to try to provoke some traffic */
1372+ debug_scsi("Sending nopout as ping on conn %p\n", conn);
1373+ iscsi_send_nopout(conn, NULL);
1374+ }
1375+ next_timeout = last_recv + timeout + (conn->ping_timeout * HZ);
1376+ } else {
1377+ next_timeout = last_recv + timeout;
1378+ }
1379+
1380+ if (next_timeout) {
1381+ debug_scsi("Setting next tmo %lu\n", next_timeout);
1382+ mod_timer(&conn->transport_timer, next_timeout);
1383+ }
1384+done:
1385+ spin_unlock(&session->lock);
11731386 }
11741387
1175−static void iscsi_start_tx(struct iscsi_conn *conn)
1388+static void iscsi_prep_abort_task_pdu(struct iscsi_cmd_task *ctask,
1389+ struct iscsi_tm *hdr)
11761390 {
1177− clear_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx);
1178− scsi_queue_work(conn->session->host, &conn->xmitwork);
1391+ memset(hdr, 0, sizeof(*hdr));
1392+ hdr->opcode = ISCSI_OP_SCSI_TMFUNC | ISCSI_OP_IMMEDIATE;
1393+ hdr->flags = ISCSI_TM_FUNC_ABORT_TASK & ISCSI_FLAG_TM_FUNC_MASK;
1394+ hdr->flags |= ISCSI_FLAG_CMD_FINAL;
1395+ memcpy(hdr->lun, ctask->hdr->lun, sizeof(hdr->lun));
1396+ hdr->rtt = ctask->hdr->itt;
1397+ hdr->refcmdsn = ctask->hdr->cmdsn;
11791398 }
11801399
11811400 int iscsi_eh_abort(struct scsi_cmnd *sc)
11821401 {
11831402 struct Scsi_Host *host = sc->device->host;
11841403 struct iscsi_session *session = iscsi_hostdata(host->hostdata);
1185− struct iscsi_cmd_task *ctask;
11861404 struct iscsi_conn *conn;
1187− int rc;
1405+ struct iscsi_cmd_task *ctask;
1406+ struct iscsi_tm *hdr;
1407+ int rc, age;
11881408
11891409 mutex_lock(&session->eh_mutex);
11901410 spin_lock_bh(&session->lock);
@@ -1199,19 +1419,23 @@ int iscsi_eh_abort(struct scsi_cmnd *sc) · 8 unmodified lines
11991419 return SUCCESS;
12001420 }
12011421
1202− ctask = (struct iscsi_cmd_task *)sc->SCp.ptr;
1203− conn = ctask->conn;
1204−
1205− conn->eh_abort_cnt++;
1206− debug_scsi("aborting [sc %p itt 0x%x]\n", sc, ctask->itt);
1207−
12081422 /*
12091423 * If we are not logged in or we have started a new session
12101424 * then let the host reset code handle this
12111425 */
1212− if (session->state != ISCSI_STATE_LOGGED_IN ||
1213− sc->SCp.phase != session->age)
1214− goto failed;
1426+ if (!session->leadconn || session->state != ISCSI_STATE_LOGGED_IN ||
1427+ sc->SCp.phase != session->age) {
1428+ spin_unlock_bh(&session->lock);
1429+ mutex_unlock(&session->eh_mutex);
1430+ return FAILED;
1431+ }
1432+
1433+ conn = session->leadconn;
1434+ conn->eh_abort_cnt++;
1435+ age = session->age;
1436+
1437+ ctask = (struct iscsi_cmd_task *)sc->SCp.ptr;
1438+ debug_scsi("aborting [sc %p itt 0x%x]\n", sc, ctask->itt);
12151439
12161440 /* ctask completed before time out */
12171441 if (!ctask->sc) {
@@ -1219,27 +1443,26 @@ int iscsi_eh_abort(struct scsi_cmnd *sc) · 1 unmodified line
12191443 goto success;
12201444 }
12211445
1222− /* what should we do here ? */
1223− if (conn->ctask == ctask) {
1224− printk(KERN_INFO "iscsi: sc %p itt 0x%x partially sent. "
1225− "Failing abort\n", sc, ctask->itt);
1226− goto failed;
1227− }
1228−
12291446 if (ctask->state == ISCSI_TASK_PENDING) {
12301447 fail_command(conn, ctask, DID_ABORT << 16);
12311448 goto success;
12321449 }
12331450
1234− conn->tmabort_state = TMABORT_INITIAL;
1235− rc = iscsi_exec_abort_task(sc, ctask);
1236− if (rc || sc->SCp.phase != session->age ||
1237− session->state != ISCSI_STATE_LOGGED_IN)
1451+ /* only have one tmf outstanding at a time */
1452+ if (conn->tmf_state != TMF_INITIAL)
1453+ goto failed;
1454+ conn->tmf_state = TMF_QUEUED;
1455+
1456+ hdr = &conn->tmhdr;
1457+ iscsi_prep_abort_task_pdu(ctask, hdr);
1458+
1459+ if (iscsi_exec_task_mgmt_fn(conn, hdr, age, session->abort_timeout)) {
1460+ rc = FAILED;
12381461 goto failed;
1239− iscsi_ctask_mtask_cleanup(ctask);
1462+ }
12401463
1241− switch (conn->tmabort_state) {
1242− case TMABORT_SUCCESS:
1464+ switch (conn->tmf_state) {
1465+ case TMF_SUCCESS:
12431466 spin_unlock_bh(&session->lock);
12441467 iscsi_suspend_tx(conn);
12451468 /*
@@ -1248,22 +1471,26 @@ int iscsi_eh_abort(struct scsi_cmnd *sc) · 2 unmodified lines
12481471 write_lock_bh(conn->recv_lock);
12491472 spin_lock(&session->lock);
12501473 fail_command(conn, ctask, DID_ABORT << 16);
1474+ conn->tmf_state = TMF_INITIAL;
12511475 spin_unlock(&session->lock);
12521476 write_unlock_bh(conn->recv_lock);
12531477 iscsi_start_tx(conn);
12541478 goto success_unlocked;
1255− case TMABORT_NOT_FOUND:
1256− if (!ctask->sc) {
1479+ case TMF_TIMEDOUT:
1480+ spin_unlock_bh(&session->lock);
1481+ iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
1482+ goto failed_unlocked;
1483+ case TMF_NOT_FOUND:
1484+ if (!sc->SCp.ptr) {
1485+ conn->tmf_state = TMF_INITIAL;
12571486 /* ctask completed before tmf abort response */
12581487 debug_scsi("sc completed while abort in progress\n");
12591488 goto success;
12601489 }
12611490 /* fall through */
12621491 default:
1263− /* timedout or failed */
1264− spin_unlock_bh(&session->lock);
1265− iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
1266− goto failed_unlocked;
1492+ conn->tmf_state = TMF_INITIAL;
1493+ goto failed;
12671494 }
12681495
12691496 success:
@@ -1276,65 +1503,152 @@ success_unlocked: · 6 unmodified lines
12761503 failed:
12771504 spin_unlock_bh(&session->lock);
12781505 failed_unlocked:
1279− debug_scsi("abort failed [sc %lx itt 0x%x]\n", (long)sc, ctask->itt);
1506+ debug_scsi("abort failed [sc %p itt 0x%x]\n", sc,
1507+ ctask ? ctask->itt : 0);
12801508 mutex_unlock(&session->eh_mutex);
12811509 return FAILED;
12821510 }
12831511 EXPORT_SYMBOL_GPL(iscsi_eh_abort);
12841512
1513+static void iscsi_prep_lun_reset_pdu(struct scsi_cmnd *sc, struct iscsi_tm *hdr)
1514+{
1515+ memset(hdr, 0, sizeof(*hdr));
1516+ hdr->opcode = ISCSI_OP_SCSI_TMFUNC | ISCSI_OP_IMMEDIATE;
1517+ hdr->flags = ISCSI_TM_FUNC_LOGICAL_UNIT_RESET & ISCSI_FLAG_TM_FUNC_MASK;
1518+ hdr->flags |= ISCSI_FLAG_CMD_FINAL;
1519+ int_to_scsilun(sc->device->lun, (struct scsi_lun *)hdr->lun);
1520+ hdr->rtt = RESERVED_ITT;
1521+}
1522+
1523+int iscsi_eh_device_reset(struct scsi_cmnd *sc)
1524+{
1525+ struct Scsi_Host *host = sc->device->host;
1526+ struct iscsi_session *session = iscsi_hostdata(host->hostdata);
1527+ struct iscsi_conn *conn;
1528+ struct iscsi_tm *hdr;
1529+ int rc = FAILED;
1530+
1531+ debug_scsi("LU Reset [sc %p lun %u]\n", sc, sc->device->lun);
1532+
1533+ mutex_lock(&session->eh_mutex);
1534+ spin_lock_bh(&session->lock);
1535+ /*
1536+ * Just check if we are not logged in. We cannot check for
1537+ * the phase because the reset could come from a ioctl.
1538+ */
1539+ if (!session->leadconn || session->state != ISCSI_STATE_LOGGED_IN)
1540+ goto unlock;
1541+ conn = session->leadconn;
1542+
1543+ /* only have one tmf outstanding at a time */
1544+ if (conn->tmf_state != TMF_INITIAL)
1545+ goto unlock;
1546+ conn->tmf_state = TMF_QUEUED;
1547+
1548+ hdr = &conn->tmhdr;
1549+ iscsi_prep_lun_reset_pdu(sc, hdr);
1550+
1551+ if (iscsi_exec_task_mgmt_fn(conn, hdr, session->age,
1552+ session->lu_reset_timeout)) {
1553+ rc = FAILED;
1554+ goto unlock;
1555+ }
1556+
1557+ switch (conn->tmf_state) {
1558+ case TMF_SUCCESS:
1559+ break;
1560+ case TMF_TIMEDOUT:
1561+ spin_unlock_bh(&session->lock);
1562+ iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
1563+ goto done;
1564+ default:
1565+ conn->tmf_state = TMF_INITIAL;
1566+ goto unlock;
1567+ }
1568+
1569+ rc = SUCCESS;
1570+ spin_unlock_bh(&session->lock);
1571+
1572+ iscsi_suspend_tx(conn);
1573+ /* need to grab the recv lock then session lock */
1574+ write_lock_bh(conn->recv_lock);
1575+ spin_lock(&session->lock);
1576+ fail_all_commands(conn, sc->device->lun);
1577+ conn->tmf_state = TMF_INITIAL;
1578+ spin_unlock(&session->lock);
1579+ write_unlock_bh(conn->recv_lock);
1580+
1581+ iscsi_start_tx(conn);
1582+ goto done;
1583+
1584+unlock:
1585+ spin_unlock_bh(&session->lock);
1586+done:
1587+ debug_scsi("iscsi_eh_device_reset %s\n",
1588+ rc == SUCCESS ? "SUCCESS" : "FAILED");
1589+ mutex_unlock(&session->eh_mutex);
1590+ return rc;
1591+}
1592+EXPORT_SYMBOL_GPL(iscsi_eh_device_reset);
1593+
1594+/*
1595+ * Pre-allocate a pool of @max items of @item_size. By default, the pool
1596+ * should be accessed via kfifo_{get,put} on q->queue.
1597+ * Optionally, the caller can obtain the array of object pointers
1598+ * by passing in a non-NULL @items pointer
1599+ */
12851600 int
1286−iscsi_pool_init(struct iscsi_queue *q, int max, void ***items, int item_size)
1601+iscsi_pool_init(struct iscsi_pool *q, int max, void ***items, int item_size)
12871602 {
1288− int i;
1603+ int i, num_arrays = 1;
12891604
1290− *items = kmalloc(max * sizeof(void*), GFP_KERNEL);
1291− if (*items == NULL)
1292− return -ENOMEM;
1605+ memset(q, 0, sizeof(*q));
12931606
12941607 q->max = max;
1295− q->pool = kmalloc(max * sizeof(void*), GFP_KERNEL);
1296− if (q->pool == NULL) {
1297− kfree(*items);
1298− return -ENOMEM;
1299− }
1608+
1609+ /* If the user passed an items pointer, he wants a copy of
1610+ * the array. */
1611+ if (items)
1612+ num_arrays++;
1613+ q->pool = kzalloc(num_arrays * max * sizeof(void*), GFP_KERNEL);
1614+ if (q->pool == NULL)
1615+ goto enomem;
13001616
13011617 q->queue = kfifo_init((void*)q->pool, max * sizeof(void*),
13021618 GFP_KERNEL, NULL);
1303− if (q->queue == ERR_PTR(-ENOMEM)) {
1304− kfree(q->pool);
1305− kfree(*items);
1306− return -ENOMEM;
1307− }
1619+ if (q->queue == ERR_PTR(-ENOMEM))
1620+ goto enomem;
13081621
13091622 for (i = 0; i < max; i++) {
1310− q->pool[i] = kmalloc(item_size, GFP_KERNEL);
1623+ q->pool[i] = kzalloc(item_size, GFP_KERNEL);
13111624 if (q->pool[i] == NULL) {
1312− int j;
1313−
1314− for (j = 0; j < i; j++)
1315− kfree(q->pool[j]);
1316−
1317− kfifo_free(q->queue);
1318− kfree(q->pool);
1319− kfree(*items);
1320− return -ENOMEM;
1625+ q->max = i;
1626+ goto enomem;
13211627 }
1322− memset(q->pool[i], 0, item_size);
1323− (*items)[i] = q->pool[i];
13241628 __kfifo_put(q->queue, (void*)&q->pool[i], sizeof(void*));
13251629 }
1630+
1631+ if (items) {
1632+ *items = q->pool + max;
1633+ memcpy(*items, q->pool, max * sizeof(void *));
1634+ }
1635+
13261636 return 0;
1637+
1638+enomem:
1639+ iscsi_pool_free(q);
1640+ return -ENOMEM;
13271641 }
13281642 EXPORT_SYMBOL_GPL(iscsi_pool_init);
13291643
1330−void iscsi_pool_free(struct iscsi_queue *q, void **items)
1644+void iscsi_pool_free(struct iscsi_pool *q)
13311645 {
13321646 int i;
13331647
13341648 for (i = 0; i < q->max; i++)
1335− kfree(items[i]);
1336− kfree(q->pool);
1337− kfree(items);
1649+ kfree(q->pool[i]);
1650+ if (q->pool)
1651+ kfree(q->pool);
13381652 }
13391653 EXPORT_SYMBOL_GPL(iscsi_pool_free);
13401654
@@ -1387,7 +1701,7 @@ iscsi_session_setup(struct iscsi_transport *iscsit, · 46 unmodified lines
13871701 qdepth = ISCSI_DEF_CMD_PER_LUN;
13881702 }
13891703
1390− if (cmds_max < 2 || (cmds_max & (cmds_max - 1)) ||
1704+ if (!is_power_of_2(cmds_max) ||
13911705 cmds_max >= ISCSI_MGMT_ITT_OFFSET) {
13921706 if (cmds_max != 0)
13931707 printk(KERN_ERR "iscsi: invalid can_queue of %d. "
@@ -1411,12 +1725,16 @@ iscsi_session_setup(struct iscsi_transport *iscsit, · 17 unmodified lines
14111725 shost->max_cmd_len = iscsit->max_cmd_len;
14121726 shost->transportt = scsit;
14131727 shost->transportt->create_work_queue = 1;
1728+ shost->transportt->eh_timed_out = iscsi_eh_cmd_timed_out;
14141729 *hostno = shost->host_no;
14151730
14161731 session = iscsi_hostdata(shost->hostdata);
14171732 memset(session, 0, sizeof(struct iscsi_session));
14181733 session->host = shost;
14191734 session->state = ISCSI_STATE_FREE;
1735+ session->fast_abort = 1;
1736+ session->lu_reset_timeout = 15;
1737+ session->abort_timeout = 10;
14201738 session->mgmtpool_max = ISCSI_MGMT_CMDS_MAX;
14211739 session->cmds_max = cmds_max;
14221740 session->queued_cmdsn = session->cmdsn = initial_cmdsn;
@@ -1479,9 +1797,9 @@ module_put: · 56 unmodified lines
14791797 cls_session_fail:
14801798 scsi_remove_host(shost);
14811799 add_host_fail:
1482− iscsi_pool_free(&session->mgmtpool, (void**)session->mgmt_cmds);
1800+ iscsi_pool_free(&session->mgmtpool);
14831801 mgmtpool_alloc_fail:
1484− iscsi_pool_free(&session->cmdpool, (void**)session->cmds);
1802+ iscsi_pool_free(&session->cmdpool);
14851803 cmdpool_alloc_fail:
14861804 scsi_host_put(shost);
14871805 return NULL;
@@ -1501,11 +1819,11 @@ void iscsi_session_teardown(struct iscsi_cls_session *cls_session) · 13 unmodified lines
15011819 struct iscsi_session *session = iscsi_hostdata(shost->hostdata);
15021820 struct module *owner = cls_session->transport->owner;
15031821
1504− iscsi_unblock_session(cls_session);
1822+ iscsi_remove_session(cls_session);
15051823 scsi_remove_host(shost);
15061824
1507− iscsi_pool_free(&session->mgmtpool, (void**)session->mgmt_cmds);
1508− iscsi_pool_free(&session->cmdpool, (void**)session->cmds);
1825+ iscsi_pool_free(&session->mgmtpool);
1826+ iscsi_pool_free(&session->cmdpool);
15091827
15101828 kfree(session->password);
15111829 kfree(session->password_in);
@@ -1516,7 +1834,7 @@ void iscsi_session_teardown(struct iscsi_cls_session *cls_session) · 4 unmodified lines
15161834 kfree(session->hwaddress);
15171835 kfree(session->initiatorname);
15181836
1519− iscsi_destroy_session(cls_session);
1837+ iscsi_free_session(cls_session);
15201838 scsi_host_put(shost);
15211839 module_put(owner);
15221840 }
@@ -1546,17 +1864,17 @@ iscsi_conn_setup(struct iscsi_cls_session *cls_session, uint32_t conn_idx) · 23 unmodified lines
15461864 conn->c_stage = ISCSI_CONN_INITIAL_STAGE;
15471865 conn->id = conn_idx;
15481866 conn->exp_statsn = 0;
1549− conn->tmabort_state = TMABORT_INITIAL;
1867+ conn->tmf_state = TMF_INITIAL;
1868+
1869+ init_timer(&conn->transport_timer);
1870+ conn->transport_timer.data = (unsigned long)conn;
1871+ conn->transport_timer.function = iscsi_check_transport_timeouts;
1872+
15501873 INIT_LIST_HEAD(&conn->run_list);
15511874 INIT_LIST_HEAD(&conn->mgmt_run_list);
1875+ INIT_LIST_HEAD(&conn->mgmtqueue);
15521876 INIT_LIST_HEAD(&conn->xmitqueue);
1553−
1554− /* initialize general immediate & non-immediate PDU commands queue */
1555− conn->mgmtqueue = kfifo_alloc(session->mgmtpool_max * sizeof(void*),
1556− GFP_KERNEL, NULL);
1557− if (conn->mgmtqueue == ERR_PTR(-ENOMEM))
1558− goto mgmtqueue_alloc_fail;
1559−
1877+ INIT_LIST_HEAD(&conn->requeue);
15601878 INIT_WORK(&conn->xmitwork, iscsi_xmitworker);
15611879
15621880 /* allocate login_mtask used for the login/text sequences */
@@ -1574,7 +1892,7 @@ iscsi_conn_setup(struct iscsi_cls_session *cls_session, uint32_t conn_idx) · 11 unmodified lines
15741892 goto login_mtask_data_alloc_fail;
15751893 conn->login_mtask->data = conn->data = data;
15761894
1577− init_timer(&conn->tmabort_timer);
1895+ init_timer(&conn->tmf_timer);
15781896 init_waitqueue_head(&conn->ehwait);
15791897
15801898 return cls_conn;
@@ -1583,8 +1901,6 @@ login_mtask_data_alloc_fail: · 2 unmodified lines
15831901 __kfifo_put(session->mgmtpool.queue, (void*)&conn->login_mtask,
15841902 sizeof(void*));
15851903 login_mtask_alloc_fail:
1586− kfifo_free(conn->mgmtqueue);
1587−mgmtqueue_alloc_fail:
15881904 iscsi_destroy_conn(cls_conn);
15891905 return NULL;
15901906 }
@@ -1603,8 +1919,9 @@ void iscsi_conn_teardown(struct iscsi_cls_conn *cls_conn) · 12 unmodified lines
16031919 struct iscsi_session *session = conn->session;
16041920 unsigned long flags;
16051921
1922+ del_timer_sync(&conn->transport_timer);
1923+
16061924 spin_lock_bh(&session->lock);
1607− set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx);
16081925 conn->c_stage = ISCSI_CONN_CLEANUP_WAIT;
16091926 if (session->leadconn == conn) {
16101927 /*
@@ -1637,7 +1954,7 @@ void iscsi_conn_teardown(struct iscsi_cls_conn *cls_conn) · 26 unmodified lines
16371954 }
16381955
16391956 /* flush queued up work because we free the connection below */
1640− scsi_flush_work(session->host);
1957+ iscsi_suspend_tx(conn);
16411958
16421959 spin_lock_bh(&session->lock);
16431960 kfree(conn->data);
@@ -1648,8 +1965,6 @@ void iscsi_conn_teardown(struct iscsi_cls_conn *cls_conn) · 4 unmodified lines
16481965 session->leadconn = NULL;
16491966 spin_unlock_bh(&session->lock);
16501967
1651− kfifo_free(conn->mgmtqueue);
1652−
16531968 iscsi_destroy_conn(cls_conn);
16541969 }
16551970 EXPORT_SYMBOL_GPL(iscsi_conn_teardown);
@@ -1672,11 +1987,29 @@ int iscsi_conn_start(struct iscsi_cls_conn *cls_conn) · 16 unmodified lines
16721987 return -EINVAL;
16731988 }
16741989
1990+ if (conn->ping_timeout && !conn->recv_timeout) {
1991+ printk(KERN_ERR "iscsi: invalid recv timeout of zero "
1992+ "Using 5 seconds\n.");
1993+ conn->recv_timeout = 5;
1994+ }
1995+
1996+ if (conn->recv_timeout && !conn->ping_timeout) {
1997+ printk(KERN_ERR "iscsi: invalid ping timeout of zero "
1998+ "Using 5 seconds.\n");
1999+ conn->ping_timeout = 5;
2000+ }
2001+
16752002 spin_lock_bh(&session->lock);
16762003 conn->c_stage = ISCSI_CONN_STARTED;
16772004 session->state = ISCSI_STATE_LOGGED_IN;
16782005 session->queued_cmdsn = session->cmdsn;
16792006
2007+ conn->last_recv = jiffies;
2008+ conn->last_ping = jiffies;
2009+ if (conn->recv_timeout && conn->ping_timeout)
2010+ mod_timer(&conn->transport_timer,
2011+ jiffies + (conn->recv_timeout * HZ));
2012+
16802013 switch(conn->stop_stage) {
16812014 case STOP_CONN_RECOVER:
16822015 /*
@@ -1684,7 +2017,7 @@ int iscsi_conn_start(struct iscsi_cls_conn *cls_conn) · 1 unmodified line
16842017 * commands after successful recovery
16852018 */
16862019 conn->stop_stage = 0;
1687− conn->tmabort_state = TMABORT_INITIAL;
2020+ conn->tmf_state = TMF_INITIAL;
16882021 session->age++;
16892022 spin_unlock_bh(&session->lock);
16902023
@@ -1709,55 +2042,27 @@ flush_control_queues(struct iscsi_session *session, struct iscsi_conn *conn) · 18 unmodified lines
17092042 struct iscsi_mgmt_task *mtask, *tmp;
17102043
17112044 /* handle pending */
1712− while (__kfifo_get(conn->mgmtqueue, (void*)&mtask, sizeof(void*))) {
1713− if (mtask == conn->login_mtask)
1714− continue;
2045+ list_for_each_entry_safe(mtask, tmp, &conn->mgmtqueue, running) {
17152046 debug_scsi("flushing pending mgmt task itt 0x%x\n", mtask->itt);
1716− __kfifo_put(session->mgmtpool.queue, (void*)&mtask,
1717− sizeof(void*));
2047+ iscsi_free_mgmt_task(conn, mtask);
17182048 }
17192049
17202050 /* handle running */
17212051 list_for_each_entry_safe(mtask, tmp, &conn->mgmt_run_list, running) {
17222052 debug_scsi("flushing running mgmt task itt 0x%x\n", mtask->itt);
1723− list_del(&mtask->running);
1724−
1725− if (mtask == conn->login_mtask)
1726− continue;
1727− __kfifo_put(session->mgmtpool.queue, (void*)&mtask,
1728− sizeof(void*));
2053+ iscsi_free_mgmt_task(conn, mtask);
17292054 }
17302055
17312056 conn->mtask = NULL;
17322057 }
17332058
1734−/* Fail commands. Mutex and session lock held and recv side suspended */
1735−static void fail_all_commands(struct iscsi_conn *conn)
1736−{
1737− struct iscsi_cmd_task *ctask, *tmp;
1738−
1739− /* flush pending */
1740− list_for_each_entry_safe(ctask, tmp, &conn->xmitqueue, running) {
1741− debug_scsi("failing pending sc %p itt 0x%x\n", ctask->sc,
1742− ctask->itt);
1743− fail_command(conn, ctask, DID_BUS_BUSY << 16);
1744− }
1745−
1746− /* fail all other running */
1747− list_for_each_entry_safe(ctask, tmp, &conn->run_list, running) {
1748− debug_scsi("failing in progress sc %p itt 0x%x\n",
1749− ctask->sc, ctask->itt);
1750− fail_command(conn, ctask, DID_BUS_BUSY << 16);
1751− }
1752−
1753− conn->ctask = NULL;
1754−}
1755−
17562059 static void iscsi_start_session_recovery(struct iscsi_session *session,
17572060 struct iscsi_conn *conn, int flag)
17582061 {
17592062 int old_stop_stage;
17602063
2064+ del_timer_sync(&conn->transport_timer);
2065+
17612066 mutex_lock(&session->eh_mutex);
17622067 spin_lock_bh(&session->lock);
17632068 if (conn->stop_stage == STOP_CONN_TERM) {
@@ -1818,7 +2123,7 @@ static void iscsi_start_session_recovery(struct iscsi_session *session, · 54 unmodified lines
18182123 * flush queues.
18192124 */
18202125 spin_lock_bh(&session->lock);
1821− fail_all_commands(conn);
2126+ fail_all_commands(conn, -1);
18222127 flush_control_queues(session, conn);
18232128 spin_unlock_bh(&session->lock);
18242129 mutex_unlock(&session->eh_mutex);
@@ -1869,6 +2174,21 @@ int iscsi_set_param(struct iscsi_cls_conn *cls_conn, · 44 unmodified lines
18692174 uint32_t value;
18702175
18712176 switch(param) {
2177+ case ISCSI_PARAM_FAST_ABORT:
2178+ sscanf(buf, "%d", &session->fast_abort);
2179+ break;
2180+ case ISCSI_PARAM_ABORT_TMO:
2181+ sscanf(buf, "%d", &session->abort_timeout);
2182+ break;
2183+ case ISCSI_PARAM_LU_RESET_TMO:
2184+ sscanf(buf, "%d", &session->lu_reset_timeout);
2185+ break;
2186+ case ISCSI_PARAM_PING_TMO:
2187+ sscanf(buf, "%d", &conn->ping_timeout);
2188+ break;
2189+ case ISCSI_PARAM_RECV_TMO:
2190+ sscanf(buf, "%d", &conn->recv_timeout);
2191+ break;
18722192 case ISCSI_PARAM_MAX_RECV_DLENGTH:
18732193 sscanf(buf, "%d", &conn->max_recv_dlength);
18742194 break;
@@ -1983,6 +2303,15 @@ int iscsi_session_get_param(struct iscsi_cls_session *cls_session, · 108 unmodified lines
19832303 int len;
19842304
19852305 switch(param) {
2306+ case ISCSI_PARAM_FAST_ABORT:
2307+ len = sprintf(buf, "%d\n", session->fast_abort);
2308+ break;
2309+ case ISCSI_PARAM_ABORT_TMO:
2310+ len = sprintf(buf, "%d\n", session->abort_timeout);
2311+ break;
2312+ case ISCSI_PARAM_LU_RESET_TMO:
2313+ len = sprintf(buf, "%d\n", session->lu_reset_timeout);
2314+ break;
19862315 case ISCSI_PARAM_INITIAL_R2T_EN:
19872316 len = sprintf(buf, "%d\n", session->initial_r2t_en);
19882317 break;
@@ -2040,6 +2369,12 @@ int iscsi_conn_get_param(struct iscsi_cls_conn *cls_conn, · 51 unmodified lines
20402369 int len;
20412370
20422371 switch(param) {
2372+ case ISCSI_PARAM_PING_TMO:
2373+ len = sprintf(buf, "%u\n", conn->ping_timeout);
2374+ break;
2375+ case ISCSI_PARAM_RECV_TMO:
2376+ len = sprintf(buf, "%u\n", conn->recv_timeout);
2377+ break;
20432378 case ISCSI_PARAM_MAX_RECV_DLENGTH:
20442379 len = sprintf(buf, "%u\n", conn->max_recv_dlength);
20452380 break;
drivers/scsi/libsas/Kconfig+9−0
@@ -38,6 +38,15 @@ config SCSI_SAS_ATA · 37 unmodified lines
3838 Builds in ATA support into libsas. Will necessitate
3939 the loading of libata along with libsas.
4040
41+config SCSI_SAS_HOST_SMP
42+ bool "Support for SMP interpretation for SAS hosts"
43+ default y
44+ depends on SCSI_SAS_LIBSAS
45+ help
46+ Allows sas hosts to receive SMP frames. Selecting this
47+ option builds an SMP interpreter into libsas. Say
48+ N here if you want to save the few kb this consumes.
49+
4150 config SCSI_SAS_LIBSAS_DEBUG
4251 bool "Compile the SAS Domain Transport Attributes in debug mode"
4352 default y
drivers/scsi/libsas/Makefile+3−1
@@ -33,5 +33,7 @@ libsas-y += sas_init.o \ · 32 unmodified lines
3333 sas_dump.o \
3434 sas_discover.o \
3535 sas_expander.o \
36− sas_scsi_host.o
36+ sas_scsi_host.o \
37+ sas_task.o
3738 libsas-$(CONFIG_SCSI_SAS_ATA) += sas_ata.o
39+libsas-$(CONFIG_SCSI_SAS_HOST_SMP) += sas_host_smp.o
drivers/scsi/libsas/sas_ata.c+1−1
@@ -498,7 +498,7 @@ static int sas_execute_task(struct sas_task *task, void *buffer, int size, · 497 unmodified lines
498498 goto ex_err;
499499 }
500500 wait_for_completion(&task->completion);
501− res = -ETASK;
501+ res = -ECOMM;
502502 if (task->task_state_flags & SAS_TASK_STATE_ABORTED) {
503503 int res2;
504504 SAS_DPRINTK("task aborted, flags:0x%x\n",
drivers/scsi/libsas/sas_discover.c+1−1
@@ -98,7 +98,7 @@ static int sas_get_port_device(struct asd_sas_port *port) · 97 unmodified lines
9898 dev->dev_type = SATA_PM;
9999 else
100100 dev->dev_type = SATA_DEV;
101− dev->tproto = SATA_PROTO;
101+ dev->tproto = SAS_PROTOCOL_SATA;
102102 } else {
103103 struct sas_identify_frame *id =
104104 (struct sas_identify_frame *) dev->frame_rcvd;
drivers/scsi/libsas/sas_expander.c+26−9
@@ -96,7 +96,7 @@ static int smp_execute_task(struct domain_device *dev, void *req, int req_size, · 95 unmodified lines
9696 }
9797
9898 wait_for_completion(&task->completion);
99− res = -ETASK;
99+ res = -ECOMM;
100100 if ((task->task_state_flags & SAS_TASK_STATE_ABORTED)) {
101101 SAS_DPRINTK("smp task timed out or aborted\n");
102102 i->dft->lldd_abort_task(task);
@@ -109,6 +109,16 @@ static int smp_execute_task(struct domain_device *dev, void *req, int req_size, · 6 unmodified lines
109109 task->task_status.stat == SAM_GOOD) {
110110 res = 0;
111111 break;
112+ } if (task->task_status.resp == SAS_TASK_COMPLETE &&
113+ task->task_status.stat == SAS_DATA_UNDERRUN) {
114+ /* no error, but return the number of bytes of
115+ * underrun */
116+ res = task->task_status.residual;
117+ break;
118+ } if (task->task_status.resp == SAS_TASK_COMPLETE &&
119+ task->task_status.stat == SAS_DATA_OVERRUN) {
120+ res = -EMSGSIZE;
121+ break;
112122 } else {
113123 SAS_DPRINTK("%s: task to dev %016llx response: 0x%x "
114124 "status 0x%x\n", __FUNCTION__,
@@ -656,9 +666,9 @@ static struct domain_device *sas_ex_discover_end_dev( · 541 unmodified lines
656666 sas_ex_get_linkrate(parent, child, phy);
657667
658668 #ifdef CONFIG_SCSI_SAS_ATA
659− if ((phy->attached_tproto & SAS_PROTO_STP) || phy->attached_sata_dev) {
669+ if ((phy->attached_tproto & SAS_PROTOCOL_STP) || phy->attached_sata_dev) {
660670 child->dev_type = SATA_DEV;
661− if (phy->attached_tproto & SAS_PROTO_STP)
671+ if (phy->attached_tproto & SAS_PROTOCOL_STP)
662672 child->tproto = phy->attached_tproto;
663673 if (phy->attached_sata_dev)
664674 child->tproto |= SATA_DEV;
@@ -695,7 +705,7 @@ static struct domain_device *sas_ex_discover_end_dev( · 30 unmodified lines
695705 }
696706 } else
697707 #endif
698− if (phy->attached_tproto & SAS_PROTO_SSP) {
708+ if (phy->attached_tproto & SAS_PROTOCOL_SSP) {
699709 child->dev_type = SAS_END_DEV;
700710 rphy = sas_end_device_alloc(phy->port);
701711 /* FIXME: error handling */
@@ -1896,11 +1906,9 @@ int sas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy, · 1194 unmodified lines
18961906 }
18971907
18981908 /* no rphy means no smp target support (ie aic94xx host) */
1899− if (!rphy) {
1900− printk("%s: can we send a smp request to a host?\n",
1901− __FUNCTION__);
1902− return -EINVAL;
1903− }
1909+ if (!rphy)
1910+ return sas_smp_host_handler(shost, req, rsp);
1911+
19041912 type = rphy->identify.device_type;
19051913
19061914 if (type != SAS_EDGE_EXPANDER_DEVICE &&
@@ -1926,6 +1934,15 @@ int sas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy, · 19 unmodified lines
19261934
19271935 ret = smp_execute_task(dev, bio_data(req->bio), req->data_len,
19281936 bio_data(rsp->bio), rsp->data_len);
1937+ if (ret > 0) {
1938+ /* positive number is the untransferred residual */
1939+ rsp->data_len = ret;
1940+ req->data_len = 0;
1941+ ret = 0;
1942+ } else if (ret == 0) {
1943+ rsp->data_len = 0;
1944+ req->data_len = 0;
1945+ }
19291946
19301947 return ret;
19311948 }
drivers/scsi/libsas/sas_host_smp.c+274−0
@@ -0,0 +1,274 @@
1+/*
2+ * Serial Attached SCSI (SAS) Expander discovery and configuration
3+ *
4+ * Copyright (C) 2007 James E.J. Bottomley
5+ * <James.Bottomley@HansenPartnership.com>
6+ *
7+ * This program is free software; you can redistribute it and/or
8+ * modify it under the terms of the GNU General Public License as
9+ * published by the Free Software Foundation; version 2 only.
10+ */
11+#include <linux/scatterlist.h>
12+#include <linux/blkdev.h>
13+
14+#include "sas_internal.h"
15+
16+#include <scsi/scsi_transport.h>
17+#include <scsi/scsi_transport_sas.h>
18+#include "../scsi_sas_internal.h"
19+
20+static void sas_host_smp_discover(struct sas_ha_struct *sas_ha, u8 *resp_data,
21+ u8 phy_id)
22+{
23+ struct sas_phy *phy;
24+ struct sas_rphy *rphy;
25+
26+ if (phy_id >= sas_ha->num_phys) {
27+ resp_data[2] = SMP_RESP_NO_PHY;
28+ return;
29+ }
30+ resp_data[2] = SMP_RESP_FUNC_ACC;
31+
32+ phy = sas_ha->sas_phy[phy_id]->phy;
33+ resp_data[9] = phy_id;
34+ resp_data[13] = phy->negotiated_linkrate;
35+ memcpy(resp_data + 16, sas_ha->sas_addr, SAS_ADDR_SIZE);
36+ memcpy(resp_data + 24, sas_ha->sas_phy[phy_id]->attached_sas_addr,
37+ SAS_ADDR_SIZE);
38+ resp_data[40] = (phy->minimum_linkrate << 4) |
39+ phy->minimum_linkrate_hw;
40+ resp_data[41] = (phy->maximum_linkrate << 4) |
41+ phy->maximum_linkrate_hw;
42+
43+ if (!sas_ha->sas_phy[phy_id]->port ||
44+ !sas_ha->sas_phy[phy_id]->port->port_dev)
45+ return;
46+
47+ rphy = sas_ha->sas_phy[phy_id]->port->port_dev->rphy;
48+ resp_data[12] = rphy->identify.device_type << 4;
49+ resp_data[14] = rphy->identify.initiator_port_protocols;
50+ resp_data[15] = rphy->identify.target_port_protocols;
51+}
52+
53+static void sas_report_phy_sata(struct sas_ha_struct *sas_ha, u8 *resp_data,
54+ u8 phy_id)
55+{
56+ struct sas_rphy *rphy;
57+ struct dev_to_host_fis *fis;
58+ int i;
59+
60+ if (phy_id >= sas_ha->num_phys) {
61+ resp_data[2] = SMP_RESP_NO_PHY;
62+ return;
63+ }
64+
65+ resp_data[2] = SMP_RESP_PHY_NO_SATA;
66+
67+ if (!sas_ha->sas_phy[phy_id]->port)
68+ return;
69+
70+ rphy = sas_ha->sas_phy[phy_id]->port->port_dev->rphy;
71+ fis = (struct dev_to_host_fis *)
72+ sas_ha->sas_phy[phy_id]->port->port_dev->frame_rcvd;
73+ if (rphy->identify.target_port_protocols != SAS_PROTOCOL_SATA)
74+ return;
75+
76+ resp_data[2] = SMP_RESP_FUNC_ACC;
77+ resp_data[9] = phy_id;
78+ memcpy(resp_data + 16, sas_ha->sas_phy[phy_id]->attached_sas_addr,
79+ SAS_ADDR_SIZE);
80+
81+ /* check to see if we have a valid d2h fis */
82+ if (fis->fis_type != 0x34)
83+ return;
84+
85+ /* the d2h fis is required by the standard to be in LE format */
86+ for (i = 0; i < 20; i += 4) {
87+ u8 *dst = resp_data + 24 + i, *src =
88+ &sas_ha->sas_phy[phy_id]->port->port_dev->frame_rcvd[i];
89+ dst[0] = src[3];
90+ dst[1] = src[2];
91+ dst[2] = src[1];
92+ dst[3] = src[0];
93+ }
94+}
95+
96+static void sas_phy_control(struct sas_ha_struct *sas_ha, u8 phy_id,
97+ u8 phy_op, enum sas_linkrate min,
98+ enum sas_linkrate max, u8 *resp_data)
99+{
100+ struct sas_internal *i =
101+ to_sas_internal(sas_ha->core.shost->transportt);
102+ struct sas_phy_linkrates rates;
103+
104+ if (phy_id >= sas_ha->num_phys) {
105+ resp_data[2] = SMP_RESP_NO_PHY;
106+ return;
107+ }
108+ switch (phy_op) {
109+ case PHY_FUNC_NOP:
110+ case PHY_FUNC_LINK_RESET:
111+ case PHY_FUNC_HARD_RESET:
112+ case PHY_FUNC_DISABLE:
113+ case PHY_FUNC_CLEAR_ERROR_LOG:
114+ case PHY_FUNC_CLEAR_AFFIL:
115+ case PHY_FUNC_TX_SATA_PS_SIGNAL:
116+ break;
117+
118+ default:
119+ resp_data[2] = SMP_RESP_PHY_UNK_OP;
120+ return;
121+ }
122+
123+ rates.minimum_linkrate = min;
124+ rates.maximum_linkrate = max;
125+
126+ if (i->dft->lldd_control_phy(sas_ha->sas_phy[phy_id], phy_op, &rates))
127+ resp_data[2] = SMP_RESP_FUNC_FAILED;
128+ else
129+ resp_data[2] = SMP_RESP_FUNC_ACC;
130+}
131+
132+int sas_smp_host_handler(struct Scsi_Host *shost, struct request *req,
133+ struct request *rsp)
134+{
135+ u8 *req_data = NULL, *resp_data = NULL, *buf;
136+ struct sas_ha_struct *sas_ha = SHOST_TO_SAS_HA(shost);
137+ int error = -EINVAL, resp_data_len = rsp->data_len;
138+
139+ /* eight is the minimum size for request and response frames */
140+ if (req->data_len < 8 || rsp->data_len < 8)
141+ goto out;
142+
143+ if (bio_offset(req->bio) + req->data_len > PAGE_SIZE ||
144+ bio_offset(rsp->bio) + rsp->data_len > PAGE_SIZE) {
145+ shost_printk(KERN_ERR, shost,
146+ "SMP request/response frame crosses page boundary");
147+ goto out;
148+ }
149+
150+ req_data = kzalloc(req->data_len, GFP_KERNEL);
151+
152+ /* make sure frame can always be built ... we copy
153+ * back only the requested length */
154+ resp_data = kzalloc(max(rsp->data_len, 128U), GFP_KERNEL);
155+
156+ if (!req_data || !resp_data) {
157+ error = -ENOMEM;
158+ goto out;
159+ }
160+
161+ local_irq_disable();
162+ buf = kmap_atomic(bio_page(req->bio), KM_USER0) + bio_offset(req->bio);
163+ memcpy(req_data, buf, req->data_len);
164+ kunmap_atomic(buf - bio_offset(req->bio), KM_USER0);
165+ local_irq_enable();
166+
167+ if (req_data[0] != SMP_REQUEST)
168+ goto out;
169+
170+ /* always succeeds ... even if we can't process the request
171+ * the result is in the response frame */
172+ error = 0;
173+
174+ /* set up default don't know response */
175+ resp_data[0] = SMP_RESPONSE;
176+ resp_data[1] = req_data[1];
177+ resp_data[2] = SMP_RESP_FUNC_UNK;
178+
179+ switch (req_data[1]) {
180+ case SMP_REPORT_GENERAL:
181+ req->data_len -= 8;
182+ resp_data_len -= 32;
183+ resp_data[2] = SMP_RESP_FUNC_ACC;
184+ resp_data[9] = sas_ha->num_phys;
185+ break;
186+
187+ case SMP_REPORT_MANUF_INFO:
188+ req->data_len -= 8;
189+ resp_data_len -= 64;
190+ resp_data[2] = SMP_RESP_FUNC_ACC;
191+ memcpy(resp_data + 12, shost->hostt->name,
192+ SAS_EXPANDER_VENDOR_ID_LEN);
193+ memcpy(resp_data + 20, "libsas virt phy",
194+ SAS_EXPANDER_PRODUCT_ID_LEN);
195+ break;
196+
197+ case SMP_READ_GPIO_REG:
198+ /* FIXME: need GPIO support in the transport class */
199+ break;
200+
201+ case SMP_DISCOVER:
202+ req->data_len =- 16;
203+ if (req->data_len < 0) {
204+ req->data_len = 0;
205+ error = -EINVAL;
206+ goto out;
207+ }
208+ resp_data_len -= 56;
209+ sas_host_smp_discover(sas_ha, resp_data, req_data[9]);
210+ break;
211+
212+ case SMP_REPORT_PHY_ERR_LOG:
213+ /* FIXME: could implement this with additional
214+ * libsas callbacks providing the HW supports it */
215+ break;
216+
217+ case SMP_REPORT_PHY_SATA:
218+ req->data_len =- 16;
219+ if (req->data_len < 0) {
220+ req->data_len = 0;
221+ error = -EINVAL;
222+ goto out;
223+ }
224+ resp_data_len -= 60;
225+ sas_report_phy_sata(sas_ha, resp_data, req_data[9]);
226+ break;
227+
228+ case SMP_REPORT_ROUTE_INFO:
229+ /* Can't implement; hosts have no routes */
230+ break;
231+
232+ case SMP_WRITE_GPIO_REG:
233+ /* FIXME: need GPIO support in the transport class */
234+ break;
235+
236+ case SMP_CONF_ROUTE_INFO:
237+ /* Can't implement; hosts have no routes */
238+ break;
239+
240+ case SMP_PHY_CONTROL:
241+ req->data_len =- 44;
242+ if (req->data_len < 0) {
243+ req->data_len = 0;
244+ error = -EINVAL;
245+ goto out;
246+ }
247+ resp_data_len -= 8;
248+ sas_phy_control(sas_ha, req_data[9], req_data[10],
249+ req_data[32] >> 4, req_data[33] >> 4,
250+ resp_data);
251+ break;
252+
253+ case SMP_PHY_TEST_FUNCTION:
254+ /* FIXME: should this be implemented? */
255+ break;
256+
257+ default:
258+ /* probably a 2.0 function */
259+ break;
260+ }
261+
262+ local_irq_disable();
263+ buf = kmap_atomic(bio_page(rsp->bio), KM_USER0) + bio_offset(rsp->bio);
264+ memcpy(buf, resp_data, rsp->data_len);
265+ flush_kernel_dcache_page(bio_page(rsp->bio));
266+ kunmap_atomic(buf - bio_offset(rsp->bio), KM_USER0);
267+ local_irq_enable();
268+ rsp->data_len = resp_data_len;
269+
270+ out:
271+ kfree(req_data);
272+ kfree(resp_data);
273+ return error;
274+}
drivers/scsi/libsas/sas_internal.h+15−1
@@ -45,7 +45,7 @@ · 44 unmodified lines
4545 void sas_scsi_recover_host(struct Scsi_Host *shost);
4646
4747 int sas_show_class(enum sas_class class, char *buf);
48−int sas_show_proto(enum sas_proto proto, char *buf);
48+int sas_show_proto(enum sas_protocol proto, char *buf);
4949 int sas_show_linkrate(enum sas_linkrate linkrate, char *buf);
5050 int sas_show_oob_mode(enum sas_oob_mode oob_mode, char *buf);
5151
@@ -80,6 +80,20 @@ struct domain_device *sas_find_dev_by_rphy(struct sas_rphy *rphy); · 28 unmodified lines
8080
8181 void sas_hae_reset(struct work_struct *work);
8282
83+#ifdef CONFIG_SCSI_SAS_HOST_SMP
84+extern int sas_smp_host_handler(struct Scsi_Host *shost, struct request *req,
85+ struct request *rsp);
86+#else
87+static inline int sas_smp_host_handler(struct Scsi_Host *shost,
88+ struct request *req,
89+ struct request *rsp)
90+{
91+ shost_printk(KERN_ERR, shost,
92+ "Cannot send SMP to a sas host (not enabled in CONFIG)\n");
93+ return -EINVAL;
94+}
95+#endif
96+
8397 static inline void sas_queue_event(int event, spinlock_t *lock,
8498 unsigned long *pending,
8599 struct work_struct *work,
drivers/scsi/libsas/sas_scsi_host.c+6−3
@@ -108,7 +108,7 @@ static void sas_scsi_task_done(struct sas_task *task) · 107 unmodified lines
108108 break;
109109 case SAM_CHECK_COND:
110110 memcpy(sc->sense_buffer, ts->buf,
111− max(SCSI_SENSE_BUFFERSIZE, ts->buf_valid_size));
111+ min(SCSI_SENSE_BUFFERSIZE, ts->buf_valid_size));
112112 stat = SAM_CHECK_COND;
113113 break;
114114 default:
@@ -148,7 +148,6 @@ static struct sas_task *sas_create_task(struct scsi_cmnd *cmd, · 33 unmodified lines
148148 if (!task)
149149 return NULL;
150150
151− *(u32 *)cmd->sense_buffer = 0;
152151 task->uldd_task = cmd;
153152 ASSIGN_SAS_TASK(cmd, task);
154153
@@ -200,6 +199,10 @@ int sas_queue_up(struct sas_task *task) · 45 unmodified lines
200199 */
201200 int sas_queuecommand(struct scsi_cmnd *cmd,
202201 void (*scsi_done)(struct scsi_cmnd *))
202+ __releases(host->host_lock)
203+ __acquires(dev->sata_dev.ap->lock)
204+ __releases(dev->sata_dev.ap->lock)
205+ __acquires(host->host_lock)
203206 {
204207 int res = 0;
205208 struct domain_device *dev = cmd_to_domain_dev(cmd);
@@ -410,7 +413,7 @@ static int sas_recover_I_T(struct domain_device *dev) · 204 unmodified lines
410413 }
411414
412415 /* Find the sas_phy that's attached to this device */
413−struct sas_phy *find_local_sas_phy(struct domain_device *dev)
416+static struct sas_phy *find_local_sas_phy(struct domain_device *dev)
414417 {
415418 struct domain_device *pdev = dev->parent;
416419 struct ex_phy *exphy = NULL;
drivers/scsi/libsas/sas_task.c+36−0
@@ -0,0 +1,36 @@
1+#include <linux/kernel.h>
2+#include <scsi/sas.h>
3+#include <scsi/libsas.h>
4+
5+/* fill task_status_struct based on SSP response frame */
6+void sas_ssp_task_response(struct device *dev, struct sas_task *task,
7+ struct ssp_response_iu *iu)
8+{
9+ struct task_status_struct *tstat = &task->task_status;
10+
11+ tstat->resp = SAS_TASK_COMPLETE;
12+
13+ if (iu->datapres == 0)
14+ tstat->stat = iu->status;
15+ else if (iu->datapres == 1)
16+ tstat->stat = iu->resp_data[3];
17+ else if (iu->datapres == 2) {
18+ tstat->stat = SAM_CHECK_COND;
19+ tstat->buf_valid_size =
20+ min_t(int, SAS_STATUS_BUF_SIZE,
21+ be32_to_cpu(iu->sense_data_len));
22+ memcpy(tstat->buf, iu->sense_data, tstat->buf_valid_size);
23+
24+ if (iu->status != SAM_CHECK_COND)
25+ dev_printk(KERN_WARNING, dev,
26+ "dev %llx sent sense data, but "
27+ "stat(%x) is not CHECK CONDITION\n",
28+ SAS_ADDR(task->dev->sas_addr),
29+ iu->status);
30+ }
31+ else
32+ /* when datapres contains corrupt/unknown value... */
33+ tstat->stat = SAM_CHECK_COND;
34+}
35+EXPORT_SYMBOL_GPL(sas_ssp_task_response);
36+
drivers/scsi/libsrp.c+12−11
@@ -192,18 +192,18 @@ static int srp_direct_data(struct scsi_cmnd *sc, struct srp_direct_buf *md, · 191 unmodified lines
192192
193193 if (dma_map) {
194194 iue = (struct iu_entry *) sc->SCp.ptr;
195− sg = sc->request_buffer;
195+ sg = scsi_sglist(sc);
196196
197− dprintk("%p %u %u %d\n", iue, sc->request_bufflen,
198− md->len, sc->use_sg);
197+ dprintk("%p %u %u %d\n", iue, scsi_bufflen(sc),
198+ md->len, scsi_sg_count(sc));
199199
200− nsg = dma_map_sg(iue->target->dev, sg, sc->use_sg,
200+ nsg = dma_map_sg(iue->target->dev, sg, scsi_sg_count(sc),
201201 DMA_BIDIRECTIONAL);
202202 if (!nsg) {
203− printk("fail to map %p %d\n", iue, sc->use_sg);
203+ printk("fail to map %p %d\n", iue, scsi_sg_count(sc));
204204 return 0;
205205 }
206− len = min(sc->request_bufflen, md->len);
206+ len = min(scsi_bufflen(sc), md->len);
207207 } else
208208 len = md->len;
209209
@@ -229,10 +229,10 @@ static int srp_indirect_data(struct scsi_cmnd *sc, struct srp_cmd *cmd, · 19 unmodified lines
229229
230230 if (dma_map || ext_desc) {
231231 iue = (struct iu_entry *) sc->SCp.ptr;
232− sg = sc->request_buffer;
232+ sg = scsi_sglist(sc);
233233
234234 dprintk("%p %u %u %d %d\n",
235− iue, sc->request_bufflen, id->len,
235+ iue, scsi_bufflen(sc), id->len,
236236 cmd->data_in_desc_cnt, cmd->data_out_desc_cnt);
237237 }
238238
@@ -268,13 +268,14 @@ static int srp_indirect_data(struct scsi_cmnd *sc, struct srp_cmd *cmd, · 29 unmodified lines
268268
269269 rdma:
270270 if (dma_map) {
271− nsg = dma_map_sg(iue->target->dev, sg, sc->use_sg, DMA_BIDIRECTIONAL);
271+ nsg = dma_map_sg(iue->target->dev, sg, scsi_sg_count(sc),
272+ DMA_BIDIRECTIONAL);
272273 if (!nsg) {
273− eprintk("fail to map %p %d\n", iue, sc->use_sg);
274+ eprintk("fail to map %p %d\n", iue, scsi_sg_count(sc));
274275 err = -EIO;
275276 goto free_mem;
276277 }
277− len = min(sc->request_bufflen, id->len);
278+ len = min(scsi_bufflen(sc), id->len);
278279 } else
279280 len = id->len;
280281
drivers/scsi/lpfc/lpfc.h+46−7
@@ -29,7 +29,8 @@ struct lpfc_sli2_slim; · 28 unmodified lines
2929 #define LPFC_MAX_NS_RETRY 3 /* Number of retry attempts to contact
3030 the NameServer before giving up. */
3131 #define LPFC_CMD_PER_LUN 3 /* max outstanding cmds per lun */
32−#define LPFC_SG_SEG_CNT 64 /* sg element count per scsi cmnd */
32+#define LPFC_DEFAULT_SG_SEG_CNT 64 /* sg element count per scsi cmnd */
33+#define LPFC_MAX_SG_SEG_CNT 256 /* sg element count per scsi cmnd */
3334 #define LPFC_IOCB_LIST_CNT 2250 /* list of IOCBs for fast-path usage. */
3435 #define LPFC_Q_RAMP_UP_INTERVAL 120 /* lun q_depth ramp up interval */
3536
@@ -68,6 +69,7 @@ struct lpfc_dmabuf { · 32 unmodified lines
6869 struct list_head list;
6970 void *virt; /* virtual address ptr */
7071 dma_addr_t phys; /* mapped address */
72+ uint32_t buffer_tag; /* used for tagged queue ring */
7173 };
7274
7375 struct lpfc_dma_pool {
@@ -272,10 +274,16 @@ struct lpfc_vport { · 198 unmodified lines
272274 #define FC_ABORT_DISCOVERY 0x8000 /* we want to abort discovery */
273275 #define FC_NDISC_ACTIVE 0x10000 /* NPort discovery active */
274276 #define FC_BYPASSED_MODE 0x20000 /* NPort is in bypassed mode */
275−#define FC_RFF_NOT_SUPPORTED 0x40000 /* RFF_ID was rejected by switch */
276277 #define FC_VPORT_NEEDS_REG_VPI 0x80000 /* Needs to have its vpi registered */
277278 #define FC_RSCN_DEFERRED 0x100000 /* A deferred RSCN being processed */
278279
280+ uint32_t ct_flags;
281+#define FC_CT_RFF_ID 0x1 /* RFF_ID accepted by switch */
282+#define FC_CT_RNN_ID 0x2 /* RNN_ID accepted by switch */
283+#define FC_CT_RSNN_NN 0x4 /* RSNN_NN accepted by switch */
284+#define FC_CT_RSPN_ID 0x8 /* RSPN_ID accepted by switch */
285+#define FC_CT_RFT_ID 0x10 /* RFT_ID accepted by switch */
286+
279287 struct list_head fc_nodes;
280288
281289 /* Keep counters for the number of entries in each list. */
@@ -344,6 +352,7 @@ struct lpfc_vport { · 62 unmodified lines
344352 uint32_t cfg_discovery_threads;
345353 uint32_t cfg_log_verbose;
346354 uint32_t cfg_max_luns;
355+ uint32_t cfg_enable_da_id;
347356
348357 uint32_t dev_loss_tmo_changed;
349358
@@ -360,6 +369,7 @@ struct lpfc_vport { · 10 unmodified lines
360369
361370 struct hbq_s {
362371 uint16_t entry_count; /* Current number of HBQ slots */
372+ uint16_t buffer_count; /* Current number of buffers posted */
363373 uint32_t next_hbqPutIdx; /* Index to next HBQ slot to use */
364374 uint32_t hbqPutIdx; /* HBQ slot to use */
365375 uint32_t local_hbqGetIdx; /* Local copy of Get index from Port */
@@ -377,6 +387,11 @@ struct hbq_s { · 11 unmodified lines
377387 #define LPFC_ELS_HBQ 0
378388 #define LPFC_EXTRA_HBQ 1
379389
390+enum hba_temp_state {
391+ HBA_NORMAL_TEMP,
392+ HBA_OVER_TEMP
393+};
394+
380395 struct lpfc_hba {
381396 struct lpfc_sli sli;
382397 uint32_t sli_rev; /* SLI2 or SLI3 */
@@ -457,7 +472,8 @@ struct lpfc_hba { · 74 unmodified lines
457472 uint64_t cfg_soft_wwnn;
458473 uint64_t cfg_soft_wwpn;
459474 uint32_t cfg_hba_queue_depth;
460−
475+ uint32_t cfg_enable_hba_reset;
476+ uint32_t cfg_enable_hba_heartbeat;
461477
462478 lpfc_vpd_t vpd; /* vital product data */
463479
@@ -544,8 +560,7 @@ struct lpfc_hba { · 80 unmodified lines
544560 struct list_head port_list;
545561 struct lpfc_vport *pport; /* physical lpfc_vport pointer */
546562 uint16_t max_vpi; /* Maximum virtual nports */
547−#define LPFC_MAX_VPI 100 /* Max number of VPI supported */
548−#define LPFC_MAX_VPORTS (LPFC_MAX_VPI+1)/* Max number of VPorts supported */
563+#define LPFC_MAX_VPI 0xFFFF /* Max number of VPI supported */
549564 unsigned long *vpi_bmask; /* vpi allocation table */
550565
551566 /* Data structure used by fabric iocb scheduler */
@@ -563,16 +578,30 @@ struct lpfc_hba { · 11 unmodified lines
563578 struct dentry *hba_debugfs_root;
564579 atomic_t debugfs_vport_count;
565580 struct dentry *debug_hbqinfo;
566− struct dentry *debug_dumpslim;
581+ struct dentry *debug_dumpHostSlim;
582+ struct dentry *debug_dumpHBASlim;
567583 struct dentry *debug_slow_ring_trc;
568584 struct lpfc_debugfs_trc *slow_ring_trc;
569585 atomic_t slow_ring_trc_cnt;
570586 #endif
571587
588+ /* Used for deferred freeing of ELS data buffers */
589+ struct list_head elsbuf;
590+ int elsbuf_cnt;
591+ int elsbuf_prev_cnt;
592+
593+ uint8_t temp_sensor_support;
572594 /* Fields used for heart beat. */
573595 unsigned long last_completion_time;
574596 struct timer_list hb_tmofunc;
575597 uint8_t hb_outstanding;
598+ /*
599+ * Following bit will be set for all buffer tags which are not
600+ * associated with any HBQ.
601+ */
602+#define QUE_BUFTAG_BIT (1<<31)
603+ uint32_t buffer_tag_count;
604+ enum hba_temp_state over_temp_state;
576605 };
577606
578607 static inline struct Scsi_Host *
@@ -598,5 +627,15 @@ lpfc_is_link_up(struct lpfc_hba *phba) · 19 unmodified lines
598627 phba->link_state == LPFC_HBA_READY;
599628 }
600629
601−#define FC_REG_DUMP_EVENT 0x10 /* Register for Dump events */
630+#define FC_REG_DUMP_EVENT 0x10 /* Register for Dump events */
631+#define FC_REG_TEMPERATURE_EVENT 0x20 /* Register for temperature
632+ event */
602633
634+struct temp_event {
635+ uint32_t event_type;
636+ uint32_t event_code;
637+ uint32_t data;
638+};
639+#define LPFC_CRIT_TEMP 0x1
640+#define LPFC_THRESHOLD_TEMP 0x2
641+#define LPFC_NORMAL_TEMP 0x3
drivers/scsi/lpfc/lpfc_attr.c+191−26
@@ -1,7 +1,7 @@
11 /*******************************************************************
22 * This file is part of the Emulex Linux Device Driver for *
33 * Fibre Channel Host Bus Adapters. *
4− * Copyright (C) 2004-2007 Emulex. All rights reserved. *
4+ * Copyright (C) 2004-2008 Emulex. All rights reserved. *
55 * EMULEX and SLI are trademarks of Emulex. *
66 * www.emulex.com *
77 * Portions Copyright (C) 2004-2005 Christoph Hellwig *
@@ -45,6 +45,10 @@ · 37 unmodified lines
4545 #define LPFC_MIN_DEVLOSS_TMO 1
4646 #define LPFC_MAX_DEVLOSS_TMO 255
4747
48+#define LPFC_MAX_LINK_SPEED 8
49+#define LPFC_LINK_SPEED_BITMAP 0x00000117
50+#define LPFC_LINK_SPEED_STRING "0, 1, 2, 4, 8"
51+
4852 static void
4953 lpfc_jedec_to_ascii(int incr, char hdw[])
5054 {
@@ -85,6 +89,15 @@ lpfc_serialnum_show(struct class_device *cdev, char *buf) · 34 unmodified lines
8589 return snprintf(buf, PAGE_SIZE, "%s\n",phba->SerialNumber);
8690 }
8791
92+static ssize_t
93+lpfc_temp_sensor_show(struct class_device *cdev, char *buf)
94+{
95+ struct Scsi_Host *shost = class_to_shost(cdev);
96+ struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
97+ struct lpfc_hba *phba = vport->phba;
98+ return snprintf(buf, PAGE_SIZE, "%d\n",phba->temp_sensor_support);
99+}
100+
88101 static ssize_t
89102 lpfc_modeldesc_show(struct class_device *cdev, char *buf)
90103 {
@@ -178,12 +191,9 @@ lpfc_state_show(struct class_device *cdev, char *buf) · 87 unmodified lines
178191 case LPFC_LINK_UP:
179192 case LPFC_CLEAR_LA:
180193 case LPFC_HBA_READY:
181− len += snprintf(buf + len, PAGE_SIZE-len, "Link Up - \n");
194+ len += snprintf(buf + len, PAGE_SIZE-len, "Link Up - ");
182195
183196 switch (vport->port_state) {
184− len += snprintf(buf + len, PAGE_SIZE-len,
185− "initializing\n");
186− break;
187197 case LPFC_LOCAL_CFG_LINK:
188198 len += snprintf(buf + len, PAGE_SIZE-len,
189199 "Configuring Link\n");
@@ -252,8 +262,7 @@ lpfc_issue_lip(struct Scsi_Host *shost) · 62 unmodified lines
252262 int mbxstatus = MBXERR_ERROR;
253263
254264 if ((vport->fc_flag & FC_OFFLINE_MODE) ||
255− (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) ||
256− (vport->port_state != LPFC_VPORT_READY))
265+ (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO))
257266 return -EPERM;
258267
259268 pmboxq = mempool_alloc(phba->mbox_mem_pool,GFP_KERNEL);
@@ -305,12 +314,14 @@ lpfc_do_offline(struct lpfc_hba *phba, uint32_t type) · 45 unmodified lines
305314
306315 psli = &phba->sli;
307316
317+ /* Wait a little for things to settle down, but not
318+ * long enough for dev loss timeout to expire.
319+ */
308320 for (i = 0; i < psli->num_rings; i++) {
309321 pring = &psli->ring[i];
310− /* The linkdown event takes 30 seconds to timeout. */
311322 while (pring->txcmplq_cnt) {
312323 msleep(10);
313− if (cnt++ > 3000) {
324+ if (cnt++ > 500) { /* 5 secs */
314325 lpfc_printf_log(phba,
315326 KERN_WARNING, LOG_INIT,
316327 "0466 Outstanding IO when "
@@ -336,6 +347,9 @@ lpfc_selective_reset(struct lpfc_hba *phba) · 19 unmodified lines
336347 struct completion online_compl;
337348 int status = 0;
338349
350+ if (!phba->cfg_enable_hba_reset)
351+ return -EIO;
352+
339353 status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE);
340354
341355 if (status != 0)
@@ -409,6 +423,8 @@ lpfc_board_mode_store(struct class_device *cdev, const char *buf, size_t count) · 67 unmodified lines
409423 struct completion online_compl;
410424 int status=0;
411425
426+ if (!phba->cfg_enable_hba_reset)
427+ return -EACCES;
412428 init_completion(&online_compl);
413429
414430 if(strncmp(buf, "online", sizeof("online") - 1) == 0) {
@@ -908,6 +924,8 @@ static CLASS_DEVICE_ATTR(used_rpi, S_IRUGO, lpfc_used_rpi_show, NULL); · 493 unmodified lines
908924 static CLASS_DEVICE_ATTR(max_xri, S_IRUGO, lpfc_max_xri_show, NULL);
909925 static CLASS_DEVICE_ATTR(used_xri, S_IRUGO, lpfc_used_xri_show, NULL);
910926 static CLASS_DEVICE_ATTR(npiv_info, S_IRUGO, lpfc_npiv_info_show, NULL);
927+static CLASS_DEVICE_ATTR(lpfc_temp_sensor, S_IRUGO, lpfc_temp_sensor_show,
928+ NULL);
911929
912930
913931 static char *lpfc_soft_wwn_key = "C99G71SL8032A";
@@ -971,6 +989,14 @@ lpfc_soft_wwpn_store(struct class_device *cdev, const char *buf, size_t count) · 57 unmodified lines
971989 unsigned int i, j, cnt=count;
972990 u8 wwpn[8];
973991
992+ if (!phba->cfg_enable_hba_reset)
993+ return -EACCES;
994+ spin_lock_irq(&phba->hbalock);
995+ if (phba->over_temp_state == HBA_OVER_TEMP) {
996+ spin_unlock_irq(&phba->hbalock);
997+ return -EACCES;
998+ }
999+ spin_unlock_irq(&phba->hbalock);
9741000 /* count may include a LF at end of string */
9751001 if (buf[cnt-1] == '\n')
9761002 cnt--;
@@ -1102,7 +1128,13 @@ MODULE_PARM_DESC(lpfc_sli_mode, "SLI mode selector:" · 125 unmodified lines
11021128 " 2 - select SLI-2 even on SLI-3 capable HBAs,"
11031129 " 3 - select SLI-3");
11041130
1105−LPFC_ATTR_R(enable_npiv, 0, 0, 1, "Enable NPIV functionality");
1131+int lpfc_enable_npiv = 0;
1132+module_param(lpfc_enable_npiv, int, 0);
1133+MODULE_PARM_DESC(lpfc_enable_npiv, "Enable NPIV functionality");
1134+lpfc_param_show(enable_npiv);
1135+lpfc_param_init(enable_npiv, 0, 0, 1);
1136+static CLASS_DEVICE_ATTR(lpfc_enable_npiv, S_IRUGO,
1137+ lpfc_enable_npiv_show, NULL);
11061138
11071139 /*
11081140 # lpfc_nodev_tmo: If set, it will hold all I/O errors on devices that disappear
@@ -1247,6 +1279,13 @@ static CLASS_DEVICE_ATTR(lpfc_devloss_tmo, S_IRUGO | S_IWUSR, · 138 unmodified lines
12471279 LPFC_VPORT_ATTR_HEX_RW(log_verbose, 0x0, 0x0, 0xffff,
12481280 "Verbose logging bit-mask");
12491281
1282+/*
1283+# lpfc_enable_da_id: This turns on the DA_ID CT command that deregisters
1284+# objects that have been registered with the nameserver after login.
1285+*/
1286+LPFC_VPORT_ATTR_R(enable_da_id, 0, 0, 1,
1287+ "Deregister nameserver objects before LOGO");
1288+
12501289 /*
12511290 # lun_queue_depth: This parameter is used to limit the number of outstanding
12521291 # commands per FCP LUN. Value range is [1,128]. Default value is 30.
@@ -1369,7 +1408,33 @@ LPFC_VPORT_ATTR_R(scan_down, 1, 0, 1, · 116 unmodified lines
13691408 # Set loop mode if you want to run as an NL_Port. Value range is [0,0x6].
13701409 # Default value is 0.
13711410 */
1372−LPFC_ATTR_RW(topology, 0, 0, 6, "Select Fibre Channel topology");
1411+static int
1412+lpfc_topology_set(struct lpfc_hba *phba, int val)
1413+{
1414+ int err;
1415+ uint32_t prev_val;
1416+ if (val >= 0 && val <= 6) {
1417+ prev_val = phba->cfg_topology;
1418+ phba->cfg_topology = val;
1419+ err = lpfc_issue_lip(lpfc_shost_from_vport(phba->pport));
1420+ if (err)
1421+ phba->cfg_topology = prev_val;
1422+ return err;
1423+ }
1424+ lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
1425+ "%d:0467 lpfc_topology attribute cannot be set to %d, "
1426+ "allowed range is [0, 6]\n",
1427+ phba->brd_no, val);
1428+ return -EINVAL;
1429+}
1430+static int lpfc_topology = 0;
1431+module_param(lpfc_topology, int, 0);
1432+MODULE_PARM_DESC(lpfc_topology, "Select Fibre Channel topology");
1433+lpfc_param_show(topology)
1434+lpfc_param_init(topology, 0, 0, 6)
1435+lpfc_param_store(topology)
1436+static CLASS_DEVICE_ATTR(lpfc_topology, S_IRUGO | S_IWUSR,
1437+ lpfc_topology_show, lpfc_topology_store);
13731438
13741439 /*
13751440 # lpfc_link_speed: Link speed selection for initializing the Fibre Channel
@@ -1381,7 +1446,59 @@ LPFC_ATTR_RW(topology, 0, 0, 6, "Select Fibre Channel topology"); · 5 unmodified lines
13811446 # 8 = 8 Gigabaud
13821447 # Value range is [0,8]. Default value is 0.
13831448 */
1384−LPFC_ATTR_R(link_speed, 0, 0, 8, "Select link speed");
1449+static int
1450+lpfc_link_speed_set(struct lpfc_hba *phba, int val)
1451+{
1452+ int err;
1453+ uint32_t prev_val;
1454+
1455+ if (((val == LINK_SPEED_1G) && !(phba->lmt & LMT_1Gb)) ||
1456+ ((val == LINK_SPEED_2G) && !(phba->lmt & LMT_2Gb)) ||
1457+ ((val == LINK_SPEED_4G) && !(phba->lmt & LMT_4Gb)) ||
1458+ ((val == LINK_SPEED_8G) && !(phba->lmt & LMT_8Gb)) ||
1459+ ((val == LINK_SPEED_10G) && !(phba->lmt & LMT_10Gb)))
1460+ return -EINVAL;
1461+
1462+ if ((val >= 0 && val <= LPFC_MAX_LINK_SPEED)
1463+ && (LPFC_LINK_SPEED_BITMAP & (1 << val))) {
1464+ prev_val = phba->cfg_link_speed;
1465+ phba->cfg_link_speed = val;
1466+ err = lpfc_issue_lip(lpfc_shost_from_vport(phba->pport));
1467+ if (err)
1468+ phba->cfg_link_speed = prev_val;
1469+ return err;
1470+ }
1471+
1472+ lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
1473+ "%d:0469 lpfc_link_speed attribute cannot be set to %d, "
1474+ "allowed range is [0, 8]\n",
1475+ phba->brd_no, val);
1476+ return -EINVAL;
1477+}
1478+
1479+static int lpfc_link_speed = 0;
1480+module_param(lpfc_link_speed, int, 0);
1481+MODULE_PARM_DESC(lpfc_link_speed, "Select link speed");
1482+lpfc_param_show(link_speed)
1483+static int
1484+lpfc_link_speed_init(struct lpfc_hba *phba, int val)
1485+{
1486+ if ((val >= 0 && val <= LPFC_MAX_LINK_SPEED)
1487+ && (LPFC_LINK_SPEED_BITMAP & (1 << val))) {
1488+ phba->cfg_link_speed = val;
1489+ return 0;
1490+ }
1491+ lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
1492+ "0454 lpfc_link_speed attribute cannot "
1493+ "be set to %d, allowed values are "
1494+ "["LPFC_LINK_SPEED_STRING"]\n", val);
1495+ phba->cfg_link_speed = 0;
1496+ return -EINVAL;
1497+}
1498+
1499+lpfc_param_store(link_speed)
1500+static CLASS_DEVICE_ATTR(lpfc_link_speed, S_IRUGO | S_IWUSR,
1501+ lpfc_link_speed_show, lpfc_link_speed_store);
13851502
13861503 /*
13871504 # lpfc_fcp_class: Determines FC class to use for the FCP protocol.
@@ -1479,7 +1596,30 @@ LPFC_ATTR_RW(poll_tmo, 10, 1, 255, · 91 unmodified lines
14791596 */
14801597 LPFC_ATTR_R(use_msi, 0, 0, 1, "Use Message Signaled Interrupts, if possible");
14811598
1599+/*
1600+# lpfc_enable_hba_reset: Allow or prevent HBA resets to the hardware.
1601+# 0 = HBA resets disabled
1602+# 1 = HBA resets enabled (default)
1603+# Value range is [0,1]. Default value is 1.
1604+*/
1605+LPFC_ATTR_R(enable_hba_reset, 1, 0, 1, "Enable HBA resets from the driver.");
1606+
1607+/*
1608+# lpfc_enable_hba_heartbeat: Enable HBA heartbeat timer..
1609+# 0 = HBA Heartbeat disabled
1610+# 1 = HBA Heartbeat enabled (default)
1611+# Value range is [0,1]. Default value is 1.
1612+*/
1613+LPFC_ATTR_R(enable_hba_heartbeat, 1, 0, 1, "Enable HBA Heartbeat.");
14821614
1615+/*
1616+ * lpfc_sg_seg_cnt: Initial Maximum DMA Segment Count
1617+ * This value can be set to values between 64 and 256. The default value is
1618+ * 64, but may be increased to allow for larger Max I/O sizes. The scsi layer
1619+ * will be allowed to request I/Os of sizes up to (MAX_SEG_COUNT * SEG_SIZE).
1620+ */
1621+LPFC_ATTR_R(sg_seg_cnt, LPFC_DEFAULT_SG_SEG_CNT, LPFC_DEFAULT_SG_SEG_CNT,
1622+ LPFC_MAX_SG_SEG_CNT, "Max Scatter Gather Segment Count");
14831623
14841624 struct class_device_attribute *lpfc_hba_attrs[] = {
14851625 &class_device_attr_info,
@@ -1494,6 +1634,7 @@ struct class_device_attribute *lpfc_hba_attrs[] = { · 8 unmodified lines
14941634 &class_device_attr_state,
14951635 &class_device_attr_num_discovered_ports,
14961636 &class_device_attr_lpfc_drvr_version,
1637+ &class_device_attr_lpfc_temp_sensor,
14971638 &class_device_attr_lpfc_log_verbose,
14981639 &class_device_attr_lpfc_lun_queue_depth,
14991640 &class_device_attr_lpfc_hba_queue_depth,
@@ -1530,6 +1671,9 @@ struct class_device_attribute *lpfc_hba_attrs[] = { · 30 unmodified lines
15301671 &class_device_attr_lpfc_soft_wwnn,
15311672 &class_device_attr_lpfc_soft_wwpn,
15321673 &class_device_attr_lpfc_soft_wwn_enable,
1674+ &class_device_attr_lpfc_enable_hba_reset,
1675+ &class_device_attr_lpfc_enable_hba_heartbeat,
1676+ &class_device_attr_lpfc_sg_seg_cnt,
15331677 NULL,
15341678 };
15351679
@@ -1552,6 +1696,7 @@ struct class_device_attribute *lpfc_vport_attrs[] = { · 16 unmodified lines
15521696 &class_device_attr_lpfc_max_luns,
15531697 &class_device_attr_nport_evt_cnt,
15541698 &class_device_attr_npiv_info,
1699+ &class_device_attr_lpfc_enable_da_id,
15551700 NULL,
15561701 };
15571702
@@ -1727,13 +1872,18 @@ sysfs_mbox_read(struct kobject *kobj, struct bin_attribute *bin_attr, · 169 unmodified lines
17271872
17281873 spin_lock_irq(&phba->hbalock);
17291874
1875+ if (phba->over_temp_state == HBA_OVER_TEMP) {
1876+ sysfs_mbox_idle(phba);
1877+ spin_unlock_irq(&phba->hbalock);
1878+ return -EACCES;
1879+ }
1880+
17301881 if (off == 0 &&
17311882 phba->sysfs_mbox.state == SMBOX_WRITING &&
17321883 phba->sysfs_mbox.offset >= 2 * sizeof(uint32_t)) {
17331884
17341885 switch (phba->sysfs_mbox.mbox->mb.mbxCommand) {
17351886 /* Offline only */
1736− case MBX_WRITE_NV:
17371887 case MBX_INIT_LINK:
17381888 case MBX_DOWN_LINK:
17391889 case MBX_CONFIG_LINK:
@@ -1744,9 +1894,7 @@ sysfs_mbox_read(struct kobject *kobj, struct bin_attribute *bin_attr, · 4 unmodified lines
17441894 case MBX_DUMP_CONTEXT:
17451895 case MBX_RUN_DIAGS:
17461896 case MBX_RESTART:
1747− case MBX_FLASH_WR_ULA:
17481897 case MBX_SET_MASK:
1749− case MBX_SET_SLIM:
17501898 case MBX_SET_DEBUG:
17511899 if (!(vport->fc_flag & FC_OFFLINE_MODE)) {
17521900 printk(KERN_WARNING "mbox_read:Command 0x%x "
@@ -1756,6 +1904,8 @@ sysfs_mbox_read(struct kobject *kobj, struct bin_attribute *bin_attr, · 3 unmodified lines
17561904 spin_unlock_irq(&phba->hbalock);
17571905 return -EPERM;
17581906 }
1907+ case MBX_WRITE_NV:
1908+ case MBX_WRITE_VPARMS:
17591909 case MBX_LOAD_SM:
17601910 case MBX_READ_NV:
17611911 case MBX_READ_CONFIG:
@@ -1772,6 +1922,8 @@ sysfs_mbox_read(struct kobject *kobj, struct bin_attribute *bin_attr, · 10 unmodified lines
17721922 case MBX_LOAD_EXP_ROM:
17731923 case MBX_BEACON:
17741924 case MBX_DEL_LD_ENTRY:
1925+ case MBX_SET_VARIABLE:
1926+ case MBX_WRITE_WWN:
17751927 break;
17761928 case MBX_READ_SPARM64:
17771929 case MBX_READ_LA:
@@ -1793,6 +1945,17 @@ sysfs_mbox_read(struct kobject *kobj, struct bin_attribute *bin_attr, · 15 unmodified lines
17931945 return -EPERM;
17941946 }
17951947
1948+ /* If HBA encountered an error attention, allow only DUMP
1949+ * mailbox command until the HBA is restarted.
1950+ */
1951+ if ((phba->pport->stopped) &&
1952+ (phba->sysfs_mbox.mbox->mb.mbxCommand
1953+ != MBX_DUMP_MEMORY)) {
1954+ sysfs_mbox_idle(phba);
1955+ spin_unlock_irq(&phba->hbalock);
1956+ return -EPERM;
1957+ }
1958+
17961959 phba->sysfs_mbox.mbox->vport = vport;
17971960
17981961 if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) {
@@ -1993,7 +2156,8 @@ lpfc_get_host_speed(struct Scsi_Host *shost) · 194 unmodified lines
19932156 fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN;
19942157 break;
19952158 }
1996− }
2159+ } else
2160+ fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN;
19972161
19982162 spin_unlock_irq(shost->host_lock);
19992163 }
@@ -2013,7 +2177,7 @@ lpfc_get_host_fabric_name (struct Scsi_Host *shost) · 13 unmodified lines
20132177 node_name = wwn_to_u64(phba->fc_fabparam.nodeName.u.wwn);
20142178 else
20152179 /* fabric is local port if there is no F/FL_Port */
2016− node_name = wwn_to_u64(vport->fc_nodename.u.wwn);
2180+ node_name = 0;
20172181
20182182 spin_unlock_irq(shost->host_lock);
20192183
@@ -2337,8 +2501,6 @@ struct fc_function_template lpfc_transport_functions = { · 317 unmodified lines
23372501 .dev_loss_tmo_callbk = lpfc_dev_loss_tmo_callbk,
23382502 .terminate_rport_io = lpfc_terminate_rport_io,
23392503
2340− .vport_create = lpfc_vport_create,
2341− .vport_delete = lpfc_vport_delete,
23422504 .dd_fcvport_size = sizeof(struct lpfc_vport *),
23432505 };
23442506
@@ -2414,21 +2576,23 @@ lpfc_get_cfgparam(struct lpfc_hba *phba) · 69 unmodified lines
24142576 lpfc_poll_tmo_init(phba, lpfc_poll_tmo);
24152577 lpfc_enable_npiv_init(phba, lpfc_enable_npiv);
24162578 lpfc_use_msi_init(phba, lpfc_use_msi);
2579+ lpfc_enable_hba_reset_init(phba, lpfc_enable_hba_reset);
2580+ lpfc_enable_hba_heartbeat_init(phba, lpfc_enable_hba_heartbeat);
24172581 phba->cfg_poll = lpfc_poll;
24182582 phba->cfg_soft_wwnn = 0L;
24192583 phba->cfg_soft_wwpn = 0L;
2420− /*
2421− * The total number of segments is the configuration value plus 2
2422− * since the IOCB need a command and response bde.
2423− */
2424− phba->cfg_sg_seg_cnt = LPFC_SG_SEG_CNT + 2;
2584+ lpfc_sg_seg_cnt_init(phba, lpfc_sg_seg_cnt);
2585+ /* Also reinitialize the host templates with new values. */
2586+ lpfc_vport_template.sg_tablesize = phba->cfg_sg_seg_cnt;
2587+ lpfc_template.sg_tablesize = phba->cfg_sg_seg_cnt;
24252588 /*
24262589 * Since the sg_tablesize is module parameter, the sg_dma_buf_size
2427− * used to create the sg_dma_buf_pool must be dynamically calculated
2590+ * used to create the sg_dma_buf_pool must be dynamically calculated.
2591+ * 2 segments are added since the IOCB needs a command and response bde.
24282592 */
24292593 phba->cfg_sg_dma_buf_size = sizeof(struct fcp_cmnd) +
24302594 sizeof(struct fcp_rsp) +
2431− (phba->cfg_sg_seg_cnt * sizeof(struct ulp_bde64));
2595+ ((phba->cfg_sg_seg_cnt + 2) * sizeof(struct ulp_bde64));
24322596 lpfc_hba_queue_depth_init(phba, lpfc_hba_queue_depth);
24332597 return;
24342598 }
@@ -2448,5 +2612,6 @@ lpfc_get_vport_cfgparam(struct lpfc_vport *vport) · 13 unmodified lines
24482612 lpfc_discovery_threads_init(vport, lpfc_discovery_threads);
24492613 lpfc_max_luns_init(vport, lpfc_max_luns);
24502614 lpfc_scan_down_init(vport, lpfc_scan_down);
2615+ lpfc_enable_da_id_init(vport, lpfc_enable_da_id);
24512616 return;
24522617 }
drivers/scsi/lpfc/lpfc_crtn.h+14−19
@@ -23,6 +23,8 @@ typedef int (*node_filter)(struct lpfc_nodelist *ndlp, void *param); · 22 unmodified lines
2323 struct fc_rport;
2424 void lpfc_dump_mem(struct lpfc_hba *, LPFC_MBOXQ_t *, uint16_t);
2525 void lpfc_read_nv(struct lpfc_hba *, LPFC_MBOXQ_t *);
26+void lpfc_config_async(struct lpfc_hba *, LPFC_MBOXQ_t *, uint32_t);
27+
2628 void lpfc_heart_beat(struct lpfc_hba *, LPFC_MBOXQ_t *);
2729 int lpfc_read_la(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb,
2830 struct lpfc_dmabuf *mp);
@@ -43,9 +45,9 @@ void lpfc_init_link(struct lpfc_hba *, LPFC_MBOXQ_t *, uint32_t, uint32_t); · 14 unmodified lines
4345 struct lpfc_vport *lpfc_find_vport_by_did(struct lpfc_hba *, uint32_t);
4446 void lpfc_cleanup_rpis(struct lpfc_vport *vport, int remove);
4547 int lpfc_linkdown(struct lpfc_hba *);
48+void lpfc_port_link_failure(struct lpfc_vport *);
4649 void lpfc_mbx_cmpl_read_la(struct lpfc_hba *, LPFC_MBOXQ_t *);
4750
48−void lpfc_mbx_cmpl_clear_la(struct lpfc_hba *, LPFC_MBOXQ_t *);
4951 void lpfc_mbx_cmpl_reg_login(struct lpfc_hba *, LPFC_MBOXQ_t *);
5052 void lpfc_mbx_cmpl_dflt_rpi(struct lpfc_hba *, LPFC_MBOXQ_t *);
5153 void lpfc_mbx_cmpl_fabric_reg_login(struct lpfc_hba *, LPFC_MBOXQ_t *);
@@ -66,15 +68,15 @@ int lpfc_check_sli_ndlp(struct lpfc_hba *, struct lpfc_sli_ring *, · 14 unmodified lines
6668 void lpfc_nlp_init(struct lpfc_vport *, struct lpfc_nodelist *, uint32_t);
6769 struct lpfc_nodelist *lpfc_nlp_get(struct lpfc_nodelist *);
6870 int lpfc_nlp_put(struct lpfc_nodelist *);
71+int lpfc_nlp_not_used(struct lpfc_nodelist *ndlp);
6972 struct lpfc_nodelist *lpfc_setup_disc_node(struct lpfc_vport *, uint32_t);
7073 void lpfc_disc_list_loopmap(struct lpfc_vport *);
7174 void lpfc_disc_start(struct lpfc_vport *);
72−void lpfc_disc_flush_list(struct lpfc_vport *);
7375 void lpfc_cleanup_discovery_resources(struct lpfc_vport *);
76+void lpfc_cleanup(struct lpfc_vport *);
7477 void lpfc_disc_timeout(unsigned long);
7578
7679 struct lpfc_nodelist *__lpfc_findnode_rpi(struct lpfc_vport *, uint16_t);
77−struct lpfc_nodelist *lpfc_findnode_rpi(struct lpfc_vport *, uint16_t);
7880
7981 void lpfc_worker_wake_up(struct lpfc_hba *);
8082 int lpfc_workq_post_event(struct lpfc_hba *, void *, void *, uint32_t);
@@ -82,17 +84,17 @@ int lpfc_do_work(void *); · 1 unmodified line
8284 int lpfc_disc_state_machine(struct lpfc_vport *, struct lpfc_nodelist *, void *,
8385 uint32_t);
8486
85−void lpfc_register_new_vport(struct lpfc_hba *, struct lpfc_vport *,
86− struct lpfc_nodelist *);
8787 void lpfc_do_scr_ns_plogi(struct lpfc_hba *, struct lpfc_vport *);
8888 int lpfc_check_sparm(struct lpfc_vport *, struct lpfc_nodelist *,
8989 struct serv_parm *, uint32_t);
9090 int lpfc_els_abort(struct lpfc_hba *, struct lpfc_nodelist *);
91+void lpfc_more_plogi(struct lpfc_vport *);
92+void lpfc_more_adisc(struct lpfc_vport *);
93+void lpfc_end_rscn(struct lpfc_vport *);
9194 int lpfc_els_chk_latt(struct lpfc_vport *);
9295 int lpfc_els_abort_flogi(struct lpfc_hba *);
9396 int lpfc_initial_flogi(struct lpfc_vport *);
9497 int lpfc_initial_fdisc(struct lpfc_vport *);
95−int lpfc_issue_els_fdisc(struct lpfc_vport *, struct lpfc_nodelist *, uint8_t);
9698 int lpfc_issue_els_plogi(struct lpfc_vport *, uint32_t, uint8_t);
9799 int lpfc_issue_els_prli(struct lpfc_vport *, struct lpfc_nodelist *, uint8_t);
98100 int lpfc_issue_els_adisc(struct lpfc_vport *, struct lpfc_nodelist *, uint8_t);
@@ -112,7 +114,6 @@ int lpfc_els_rsp_prli_acc(struct lpfc_vport *, struct lpfc_iocbq *, · 13 unmodified lines
112114 void lpfc_cancel_retry_delay_tmo(struct lpfc_vport *, struct lpfc_nodelist *);
113115 void lpfc_els_retry_delay(unsigned long);
114116 void lpfc_els_retry_delay_handler(struct lpfc_nodelist *);
115−void lpfc_dev_loss_tmo_handler(struct lpfc_nodelist *);
116117 void lpfc_els_unsol_event(struct lpfc_hba *, struct lpfc_sli_ring *,
117118 struct lpfc_iocbq *);
118119 int lpfc_els_handle_rscn(struct lpfc_vport *);
@@ -124,7 +125,6 @@ int lpfc_els_disc_adisc(struct lpfc_vport *); · 5 unmodified lines
124125 int lpfc_els_disc_plogi(struct lpfc_vport *);
125126 void lpfc_els_timeout(unsigned long);
126127 void lpfc_els_timeout_handler(struct lpfc_vport *);
127−void lpfc_hb_timeout(unsigned long);
128128 void lpfc_hb_timeout_handler(struct lpfc_hba *);
129129
130130 void lpfc_ct_unsol_event(struct lpfc_hba *, struct lpfc_sli_ring *,
@@ -142,7 +142,6 @@ void lpfc_hba_init(struct lpfc_hba *, uint32_t *); · 11 unmodified lines
142142 int lpfc_post_buffer(struct lpfc_hba *, struct lpfc_sli_ring *, int, int);
143143 void lpfc_decode_firmware_rev(struct lpfc_hba *, char *, int);
144144 int lpfc_online(struct lpfc_hba *);
145−void lpfc_block_mgmt_io(struct lpfc_hba *);
146145 void lpfc_unblock_mgmt_io(struct lpfc_hba *);
147146 void lpfc_offline_prep(struct lpfc_hba *);
148147 void lpfc_offline(struct lpfc_hba *);
@@ -165,7 +164,6 @@ int lpfc_mbox_tmo_val(struct lpfc_hba *, int); · 16 unmodified lines
165164
166165 void lpfc_config_hbq(struct lpfc_hba *, uint32_t, struct lpfc_hbq_init *,
167166 uint32_t , LPFC_MBOXQ_t *);
168−struct lpfc_hbq_entry * lpfc_sli_next_hbq_slot(struct lpfc_hba *, uint32_t);
169167 struct hbq_dmabuf *lpfc_els_hbq_alloc(struct lpfc_hba *);
170168 void lpfc_els_hbq_free(struct lpfc_hba *, struct hbq_dmabuf *);
171169
@@ -178,7 +176,6 @@ void lpfc_poll_start_timer(struct lpfc_hba * phba); · 6 unmodified lines
178176 void lpfc_sli_poll_fcp_ring(struct lpfc_hba * hba);
179177 struct lpfc_iocbq * lpfc_sli_get_iocbq(struct lpfc_hba *);
180178 void lpfc_sli_release_iocbq(struct lpfc_hba * phba, struct lpfc_iocbq * iocb);
181−void __lpfc_sli_release_iocbq(struct lpfc_hba * phba, struct lpfc_iocbq * iocb);
182179 uint16_t lpfc_sli_next_iotag(struct lpfc_hba * phba, struct lpfc_iocbq * iocb);
183180
184181 void lpfc_reset_barrier(struct lpfc_hba * phba);
@@ -204,11 +201,14 @@ int lpfc_sli_ringpostbuf_put(struct lpfc_hba *, struct lpfc_sli_ring *, · 19 unmodified lines
204201 struct lpfc_dmabuf *lpfc_sli_ringpostbuf_get(struct lpfc_hba *,
205202 struct lpfc_sli_ring *,
206203 dma_addr_t);
204+
205+uint32_t lpfc_sli_get_buffer_tag(struct lpfc_hba *);
206+struct lpfc_dmabuf * lpfc_sli_ring_taggedbuf_get(struct lpfc_hba *,
207+ struct lpfc_sli_ring *, uint32_t );
208+
207209 int lpfc_sli_hbq_count(void);
208−int lpfc_sli_hbqbuf_init_hbqs(struct lpfc_hba *, uint32_t);
209210 int lpfc_sli_hbqbuf_add_hbqs(struct lpfc_hba *, uint32_t);
210211 void lpfc_sli_hbqbuf_free_all(struct lpfc_hba *);
211−struct hbq_dmabuf *lpfc_sli_hbqbuf_find(struct lpfc_hba *, uint32_t);
212212 int lpfc_sli_hbq_size(void);
213213 int lpfc_sli_issue_abort_iotag(struct lpfc_hba *, struct lpfc_sli_ring *,
214214 struct lpfc_iocbq *);
@@ -219,9 +219,6 @@ int lpfc_sli_abort_iocb(struct lpfc_vport *, struct lpfc_sli_ring *, uint16_t, · 4 unmodified lines
219219 void lpfc_mbox_timeout(unsigned long);
220220 void lpfc_mbox_timeout_handler(struct lpfc_hba *);
221221
222−struct lpfc_nodelist *__lpfc_find_node(struct lpfc_vport *, node_filter,
223− void *);
224−struct lpfc_nodelist *lpfc_find_node(struct lpfc_vport *, node_filter, void *);
225222 struct lpfc_nodelist *lpfc_findnode_did(struct lpfc_vport *, uint32_t);
226223 struct lpfc_nodelist *lpfc_findnode_wwpn(struct lpfc_vport *,
227224 struct lpfc_name *);
@@ -260,6 +257,7 @@ extern struct scsi_host_template lpfc_vport_template; · 32 unmodified lines
260257 extern struct fc_function_template lpfc_transport_functions;
261258 extern struct fc_function_template lpfc_vport_transport_functions;
262259 extern int lpfc_sli_mode;
260+extern int lpfc_enable_npiv;
263261
264262 int lpfc_vport_symbolic_node_name(struct lpfc_vport *, char *, size_t);
265263 void lpfc_terminate_rport_io(struct fc_rport *);
@@ -281,11 +279,8 @@ extern void lpfc_debugfs_slow_ring_trc(struct lpfc_hba *, char *, uint32_t, · 15 unmodified lines
281279 extern struct lpfc_hbq_init *lpfc_hbq_defs[];
282280
283281 /* Interface exported by fabric iocb scheduler */
284−int lpfc_issue_fabric_iocb(struct lpfc_hba *, struct lpfc_iocbq *);
285−void lpfc_fabric_abort_vport(struct lpfc_vport *);
286282 void lpfc_fabric_abort_nport(struct lpfc_nodelist *);
287283 void lpfc_fabric_abort_hba(struct lpfc_hba *);
288−void lpfc_fabric_abort_flogi(struct lpfc_hba *);
289284 void lpfc_fabric_block_timeout(unsigned long);
290285 void lpfc_unblock_fabric_iocbs(struct lpfc_hba *);
291286 void lpfc_adjust_queue_depth(struct lpfc_hba *);
drivers/scsi/lpfc/lpfc_ct.c+218−86
@@ -19,7 +19,7 @@ · 18 unmodified lines
1919 *******************************************************************/
2020
2121 /*
22− * Fibre Channel SCSI LAN Device Driver CT support
22+ * Fibre Channel SCSI LAN Device Driver CT support: FC Generic Services FC-GS
2323 */
2424
2525 #include <linux/blkdev.h>
@@ -57,45 +57,27 @@ · 31 unmodified lines
5757
5858 static char *lpfc_release_version = LPFC_DRIVER_VERSION;
5959
60−/*
61− * lpfc_ct_unsol_event
62− */
6360 static void
64−lpfc_ct_unsol_buffer(struct lpfc_hba *phba, struct lpfc_iocbq *piocbq,
65− struct lpfc_dmabuf *mp, uint32_t size)
61+lpfc_ct_ignore_hbq_buffer(struct lpfc_hba *phba, struct lpfc_iocbq *piocbq,
62+ struct lpfc_dmabuf *mp, uint32_t size)
6663 {
6764 if (!mp) {
68− printk(KERN_ERR "%s (%d): Unsolited CT, no buffer, "
69− "piocbq = %p, status = x%x, mp = %p, size = %d\n",
70− __FUNCTION__, __LINE__,
71− piocbq, piocbq->iocb.ulpStatus, mp, size);
65+ lpfc_printf_log(phba, KERN_INFO, LOG_ELS,
66+ "0146 Ignoring unsolicted CT No HBQ "
67+ "status = x%x\n",
68+ piocbq->iocb.ulpStatus);
7269 }
73−
74− printk(KERN_ERR "%s (%d): Ignoring unsolicted CT piocbq = %p, "
75− "buffer = %p, size = %d, status = x%x\n",
76− __FUNCTION__, __LINE__,
77− piocbq, mp, size,
78− piocbq->iocb.ulpStatus);
79−
70+ lpfc_printf_log(phba, KERN_INFO, LOG_ELS,
71+ "0145 Ignoring unsolicted CT HBQ Size:%d "
72+ "status = x%x\n",
73+ size, piocbq->iocb.ulpStatus);
8074 }
8175
8276 static void
83−lpfc_ct_ignore_hbq_buffer(struct lpfc_hba *phba, struct lpfc_iocbq *piocbq,
84− struct lpfc_dmabuf *mp, uint32_t size)
77+lpfc_ct_unsol_buffer(struct lpfc_hba *phba, struct lpfc_iocbq *piocbq,
78+ struct lpfc_dmabuf *mp, uint32_t size)
8579 {
86− if (!mp) {
87− printk(KERN_ERR "%s (%d): Unsolited CT, no "
88− "HBQ buffer, piocbq = %p, status = x%x\n",
89− __FUNCTION__, __LINE__,
90− piocbq, piocbq->iocb.ulpStatus);
91− } else {
92− lpfc_ct_unsol_buffer(phba, piocbq, mp, size);
93− printk(KERN_ERR "%s (%d): Ignoring unsolicted CT "
94− "piocbq = %p, buffer = %p, size = %d, "
95− "status = x%x\n",
96− __FUNCTION__, __LINE__,
97− piocbq, mp, size, piocbq->iocb.ulpStatus);
98− }
80+ lpfc_ct_ignore_hbq_buffer(phba, piocbq, mp, size);
9981 }
10082
10183 void
@@ -109,11 +91,8 @@ lpfc_ct_unsol_event(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 7 unmodified lines
10991 struct lpfc_iocbq *iocbq;
11092 dma_addr_t paddr;
11193 uint32_t size;
112− struct lpfc_dmabuf *bdeBuf1 = piocbq->context2;
113− struct lpfc_dmabuf *bdeBuf2 = piocbq->context3;
114−
115− piocbq->context2 = NULL;
116− piocbq->context3 = NULL;
94+ struct list_head head;
95+ struct lpfc_dmabuf *bdeBuf;
11796
11897 if (unlikely(icmd->ulpStatus == IOSTAT_NEED_BUFFER)) {
11998 lpfc_sli_hbqbuf_add_hbqs(phba, LPFC_ELS_HBQ);
@@ -122,7 +101,7 @@ lpfc_ct_unsol_event(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 2 unmodified lines
122101 /* Not enough posted buffers; Try posting more buffers */
123102 phba->fc_stat.NoRcvBuf++;
124103 if (!(phba->sli3_options & LPFC_SLI3_HBQ_ENABLED))
125− lpfc_post_buffer(phba, pring, 0, 1);
104+ lpfc_post_buffer(phba, pring, 2, 1);
126105 return;
127106 }
128107
@@ -133,38 +112,34 @@ lpfc_ct_unsol_event(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 4 unmodified lines
133112 return;
134113
135114 if (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) {
136− list_for_each_entry(iocbq, &piocbq->list, list) {
115+ INIT_LIST_HEAD(&head);
116+ list_add_tail(&head, &piocbq->list);
117+ list_for_each_entry(iocbq, &head, list) {
137118 icmd = &iocbq->iocb;
138− if (icmd->ulpBdeCount == 0) {
139− printk(KERN_ERR "%s (%d): Unsolited CT, no "
140− "BDE, iocbq = %p, status = x%x\n",
141− __FUNCTION__, __LINE__,
142− iocbq, iocbq->iocb.ulpStatus);
119+ if (icmd->ulpBdeCount == 0)
143120 continue;
144− }
145−
121+ bdeBuf = iocbq->context2;
122+ iocbq->context2 = NULL;
146123 size = icmd->un.cont64[0].tus.f.bdeSize;
147− lpfc_ct_ignore_hbq_buffer(phba, piocbq, bdeBuf1, size);
148− lpfc_in_buf_free(phba, bdeBuf1);
124+ lpfc_ct_unsol_buffer(phba, piocbq, bdeBuf, size);
125+ lpfc_in_buf_free(phba, bdeBuf);
149126 if (icmd->ulpBdeCount == 2) {
150− lpfc_ct_ignore_hbq_buffer(phba, piocbq, bdeBuf2,
151− size);
152− lpfc_in_buf_free(phba, bdeBuf2);
127+ bdeBuf = iocbq->context3;
128+ iocbq->context3 = NULL;
129+ size = icmd->unsli3.rcvsli3.bde2.tus.f.bdeSize;
130+ lpfc_ct_unsol_buffer(phba, piocbq, bdeBuf,
131+ size);
132+ lpfc_in_buf_free(phba, bdeBuf);
153133 }
154134 }
135+ list_del(&head);
155136 } else {
156137 struct lpfc_iocbq *next;
157138
158139 list_for_each_entry_safe(iocbq, next, &piocbq->list, list) {
159140 icmd = &iocbq->iocb;
160− if (icmd->ulpBdeCount == 0) {
161− printk(KERN_ERR "%s (%d): Unsolited CT, no "
162− "BDE, iocbq = %p, status = x%x\n",
163− __FUNCTION__, __LINE__,
164− iocbq, iocbq->iocb.ulpStatus);
165− continue;
166− }
167−
141+ if (icmd->ulpBdeCount == 0)
142+ lpfc_ct_unsol_buffer(phba, piocbq, NULL, 0);
168143 for (i = 0; i < icmd->ulpBdeCount; i++) {
169144 paddr = getPaddr(icmd->un.cont64[i].addrHigh,
170145 icmd->un.cont64[i].addrLow);
@@ -176,6 +151,7 @@ lpfc_ct_unsol_event(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 5 unmodified lines
176151 }
177152 list_del(&iocbq->list);
178153 lpfc_sli_release_iocbq(phba, iocbq);
154+ lpfc_post_buffer(phba, pring, i, 1);
179155 }
180156 }
181157 }
@@ -203,7 +179,7 @@ lpfc_alloc_ct_rsp(struct lpfc_hba *phba, int cmdcode, struct ulp_bde64 *bpl, · 21 unmodified lines
203179 struct lpfc_dmabuf *mp;
204180 int cnt, i = 0;
205181
206− /* We get chucks of FCELSSIZE */
182+ /* We get chunks of FCELSSIZE */
207183 cnt = size > FCELSSIZE ? FCELSSIZE: size;
208184
209185 while (size) {
@@ -426,6 +402,7 @@ lpfc_ns_rsp(struct lpfc_vport *vport, struct lpfc_dmabuf *mp, uint32_t Size) · 216 unmodified lines
426402
427403 lpfc_set_disctmo(vport);
428404 vport->num_disc_nodes = 0;
405+ vport->fc_ns_retry = 0;
429406
430407
431408 list_add_tail(&head, &mp->list);
@@ -458,7 +435,7 @@ lpfc_ns_rsp(struct lpfc_vport *vport, struct lpfc_dmabuf *mp, uint32_t Size) · 26 unmodified lines
458435 ((lpfc_find_vport_by_did(phba, Did) == NULL) ||
459436 vport->cfg_peer_port_login)) {
460437 if ((vport->port_type != LPFC_NPIV_PORT) ||
461− (vport->fc_flag & FC_RFF_NOT_SUPPORTED) ||
438+ (!(vport->ct_flags & FC_CT_RFF_ID)) ||
462439 (!vport->cfg_restrict_login)) {
463440 ndlp = lpfc_setup_disc_node(vport, Did);
464441 if (ndlp) {
@@ -506,7 +483,17 @@ lpfc_ns_rsp(struct lpfc_vport *vport, struct lpfc_dmabuf *mp, uint32_t Size) · 41 unmodified lines
506483 Did, vport->fc_flag,
507484 vport->fc_rscn_id_cnt);
508485
509− if (lpfc_ns_cmd(vport,
486+ /* This NPortID was previously
487+ * a FCP target, * Don't even
488+ * bother to send GFF_ID.
489+ */
490+ ndlp = lpfc_findnode_did(vport,
491+ Did);
492+ if (ndlp && (ndlp->nlp_type &
493+ NLP_FCP_TARGET))
494+ lpfc_setup_disc_node
495+ (vport, Did);
496+ else if (lpfc_ns_cmd(vport,
510497 SLI_CTNS_GFF_ID,
511498 0, Did) == 0)
512499 vport->num_disc_nodes++;
@@ -554,7 +541,7 @@ lpfc_cmpl_ct_cmd_gid_ft(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 41 unmodified lines
554541 struct lpfc_dmabuf *outp;
555542 struct lpfc_sli_ct_request *CTrsp;
556543 struct lpfc_nodelist *ndlp;
557− int rc;
544+ int rc, retry;
558545
559546 /* First save ndlp, before we overwrite it */
560547 ndlp = cmdiocb->context_un.ndlp;
@@ -574,7 +561,6 @@ lpfc_cmpl_ct_cmd_gid_ft(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 13 unmodified lines
574561 if (vport->load_flag & FC_UNLOADING)
575562 goto out;
576563
577−
578564 if (lpfc_els_chk_latt(vport) || lpfc_error_lost_link(irsp)) {
579565 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
580566 "0216 Link event during NS query\n");
@@ -585,14 +571,35 @@ lpfc_cmpl_ct_cmd_gid_ft(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 4 unmodified lines
585571 if (irsp->ulpStatus) {
586572 /* Check for retry */
587573 if (vport->fc_ns_retry < LPFC_MAX_NS_RETRY) {
588− if ((irsp->ulpStatus != IOSTAT_LOCAL_REJECT) ||
589− (irsp->un.ulpWord[4] != IOERR_NO_RESOURCES))
574+ retry = 1;
575+ if (irsp->ulpStatus == IOSTAT_LOCAL_REJECT) {
576+ switch (irsp->un.ulpWord[4]) {
577+ case IOERR_NO_RESOURCES:
578+ /* We don't increment the retry
579+ * count for this case.
580+ */
581+ break;
582+ case IOERR_LINK_DOWN:
583+ case IOERR_SLI_ABORTED:
584+ case IOERR_SLI_DOWN:
585+ retry = 0;
586+ break;
587+ default:
588+ vport->fc_ns_retry++;
589+ }
590+ }
591+ else
590592 vport->fc_ns_retry++;
591− /* CT command is being retried */
592− rc = lpfc_ns_cmd(vport, SLI_CTNS_GID_FT,
593+
594+ if (retry) {
595+ /* CT command is being retried */
596+ rc = lpfc_ns_cmd(vport, SLI_CTNS_GID_FT,
593597 vport->fc_ns_retry, 0);
594− if (rc == 0)
595− goto out;
598+ if (rc == 0) {
599+ /* success */
600+ goto out;
601+ }
602+ }
596603 }
597604 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
598605 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
@@ -698,7 +705,7 @@ lpfc_cmpl_ct_cmd_gff_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 99 unmodified lines
698705 struct lpfc_dmabuf *inp = (struct lpfc_dmabuf *) cmdiocb->context1;
699706 struct lpfc_dmabuf *outp = (struct lpfc_dmabuf *) cmdiocb->context2;
700707 struct lpfc_sli_ct_request *CTrsp;
701− int did;
708+ int did, rc, retry;
702709 uint8_t fbits;
703710 struct lpfc_nodelist *ndlp;
704711
@@ -729,6 +736,39 @@ lpfc_cmpl_ct_cmd_gff_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 24 unmodified lines
729736 }
730737 }
731738 else {
739+ /* Check for retry */
740+ if (cmdiocb->retry < LPFC_MAX_NS_RETRY) {
741+ retry = 1;
742+ if (irsp->ulpStatus == IOSTAT_LOCAL_REJECT) {
743+ switch (irsp->un.ulpWord[4]) {
744+ case IOERR_NO_RESOURCES:
745+ /* We don't increment the retry
746+ * count for this case.
747+ */
748+ break;
749+ case IOERR_LINK_DOWN:
750+ case IOERR_SLI_ABORTED:
751+ case IOERR_SLI_DOWN:
752+ retry = 0;
753+ break;
754+ default:
755+ cmdiocb->retry++;
756+ }
757+ }
758+ else
759+ cmdiocb->retry++;
760+
761+ if (retry) {
762+ /* CT command is being retried */
763+ rc = lpfc_ns_cmd(vport, SLI_CTNS_GFF_ID,
764+ cmdiocb->retry, did);
765+ if (rc == 0) {
766+ /* success */
767+ lpfc_ct_free_iocb(phba, cmdiocb);
768+ return;
769+ }
770+ }
771+ }
732772 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
733773 "0267 NameServer GFF Rsp "
734774 "x%x Error (%d %d) Data: x%x x%x\n",
@@ -778,8 +818,8 @@ out: · 43 unmodified lines
778818
779819
780820 static void
781−lpfc_cmpl_ct_cmd_rft_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
782− struct lpfc_iocbq *rspiocb)
821+lpfc_cmpl_ct(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
822+ struct lpfc_iocbq *rspiocb)
783823 {
784824 struct lpfc_vport *vport = cmdiocb->vport;
785825 struct lpfc_dmabuf *inp;
@@ -809,7 +849,7 @@ lpfc_cmpl_ct_cmd_rft_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 23 unmodified lines
809849
810850 /* RFT request completes status <ulpStatus> CmdRsp <CmdRsp> */
811851 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
812− "0209 RFT request completes, latt %d, "
852+ "0209 CT Request completes, latt %d, "
813853 "ulpStatus x%x CmdRsp x%x, Context x%x, Tag x%x\n",
814854 latt, irsp->ulpStatus,
815855 CTrsp->CommandResponse.bits.CmdRsp,
@@ -847,11 +887,45 @@ out: · 31 unmodified lines
847887 return;
848888 }
849889
890+static void
891+lpfc_cmpl_ct_cmd_rft_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
892+ struct lpfc_iocbq *rspiocb)
893+{
894+ IOCB_t *irsp = &rspiocb->iocb;
895+ struct lpfc_vport *vport = cmdiocb->vport;
896+
897+ if (irsp->ulpStatus == IOSTAT_SUCCESS) {
898+ struct lpfc_dmabuf *outp;
899+ struct lpfc_sli_ct_request *CTrsp;
900+
901+ outp = (struct lpfc_dmabuf *) cmdiocb->context2;
902+ CTrsp = (struct lpfc_sli_ct_request *) outp->virt;
903+ if (CTrsp->CommandResponse.bits.CmdRsp ==
904+ be16_to_cpu(SLI_CT_RESPONSE_FS_ACC))
905+ vport->ct_flags |= FC_CT_RFT_ID;
906+ }
907+ lpfc_cmpl_ct(phba, cmdiocb, rspiocb);
908+ return;
909+}
910+
850911 static void
851912 lpfc_cmpl_ct_cmd_rnn_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
852913 struct lpfc_iocbq *rspiocb)
853914 {
854− lpfc_cmpl_ct_cmd_rft_id(phba, cmdiocb, rspiocb);
915+ IOCB_t *irsp = &rspiocb->iocb;
916+ struct lpfc_vport *vport = cmdiocb->vport;
917+
918+ if (irsp->ulpStatus == IOSTAT_SUCCESS) {
919+ struct lpfc_dmabuf *outp;
920+ struct lpfc_sli_ct_request *CTrsp;
921+
922+ outp = (struct lpfc_dmabuf *) cmdiocb->context2;
923+ CTrsp = (struct lpfc_sli_ct_request *) outp->virt;
924+ if (CTrsp->CommandResponse.bits.CmdRsp ==
925+ be16_to_cpu(SLI_CT_RESPONSE_FS_ACC))
926+ vport->ct_flags |= FC_CT_RNN_ID;
927+ }
928+ lpfc_cmpl_ct(phba, cmdiocb, rspiocb);
855929 return;
856930 }
857931
@@ -859,7 +933,20 @@ static void · 1 unmodified line
859933 lpfc_cmpl_ct_cmd_rspn_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
860934 struct lpfc_iocbq *rspiocb)
861935 {
862− lpfc_cmpl_ct_cmd_rft_id(phba, cmdiocb, rspiocb);
936+ IOCB_t *irsp = &rspiocb->iocb;
937+ struct lpfc_vport *vport = cmdiocb->vport;
938+
939+ if (irsp->ulpStatus == IOSTAT_SUCCESS) {
940+ struct lpfc_dmabuf *outp;
941+ struct lpfc_sli_ct_request *CTrsp;
942+
943+ outp = (struct lpfc_dmabuf *) cmdiocb->context2;
944+ CTrsp = (struct lpfc_sli_ct_request *) outp->virt;
945+ if (CTrsp->CommandResponse.bits.CmdRsp ==
946+ be16_to_cpu(SLI_CT_RESPONSE_FS_ACC))
947+ vport->ct_flags |= FC_CT_RSPN_ID;
948+ }
949+ lpfc_cmpl_ct(phba, cmdiocb, rspiocb);
863950 return;
864951 }
865952
@@ -867,7 +954,32 @@ static void · 1 unmodified line
867954 lpfc_cmpl_ct_cmd_rsnn_nn(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
868955 struct lpfc_iocbq *rspiocb)
869956 {
870− lpfc_cmpl_ct_cmd_rft_id(phba, cmdiocb, rspiocb);
957+ IOCB_t *irsp = &rspiocb->iocb;
958+ struct lpfc_vport *vport = cmdiocb->vport;
959+
960+ if (irsp->ulpStatus == IOSTAT_SUCCESS) {
961+ struct lpfc_dmabuf *outp;
962+ struct lpfc_sli_ct_request *CTrsp;
963+
964+ outp = (struct lpfc_dmabuf *) cmdiocb->context2;
965+ CTrsp = (struct lpfc_sli_ct_request *) outp->virt;
966+ if (CTrsp->CommandResponse.bits.CmdRsp ==
967+ be16_to_cpu(SLI_CT_RESPONSE_FS_ACC))
968+ vport->ct_flags |= FC_CT_RSNN_NN;
969+ }
970+ lpfc_cmpl_ct(phba, cmdiocb, rspiocb);
971+ return;
972+}
973+
974+static void
975+lpfc_cmpl_ct_cmd_da_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
976+ struct lpfc_iocbq *rspiocb)
977+{
978+ struct lpfc_vport *vport = cmdiocb->vport;
979+
980+ /* even if it fails we will act as though it succeeded. */
981+ vport->ct_flags = 0;
982+ lpfc_cmpl_ct(phba, cmdiocb, rspiocb);
871983 return;
872984 }
873985
@@ -878,10 +990,17 @@ lpfc_cmpl_ct_cmd_rff_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 4 unmodified lines
878990 IOCB_t *irsp = &rspiocb->iocb;
879991 struct lpfc_vport *vport = cmdiocb->vport;
880992
881− if (irsp->ulpStatus != IOSTAT_SUCCESS)
882− vport->fc_flag |= FC_RFF_NOT_SUPPORTED;
993+ if (irsp->ulpStatus == IOSTAT_SUCCESS) {
994+ struct lpfc_dmabuf *outp;
995+ struct lpfc_sli_ct_request *CTrsp;
883996
884− lpfc_cmpl_ct_cmd_rft_id(phba, cmdiocb, rspiocb);
997+ outp = (struct lpfc_dmabuf *) cmdiocb->context2;
998+ CTrsp = (struct lpfc_sli_ct_request *) outp->virt;
999+ if (CTrsp->CommandResponse.bits.CmdRsp ==
1000+ be16_to_cpu(SLI_CT_RESPONSE_FS_ACC))
1001+ vport->ct_flags |= FC_CT_RFF_ID;
1002+ }
1003+ lpfc_cmpl_ct(phba, cmdiocb, rspiocb);
8851004 return;
8861005 }
8871006
@@ -1001,6 +1120,8 @@ lpfc_ns_cmd(struct lpfc_vport *vport, int cmdcode, · 113 unmodified lines
10011120 bpl->tus.f.bdeSize = RSPN_REQUEST_SZ;
10021121 else if (cmdcode == SLI_CTNS_RSNN_NN)
10031122 bpl->tus.f.bdeSize = RSNN_REQUEST_SZ;
1123+ else if (cmdcode == SLI_CTNS_DA_ID)
1124+ bpl->tus.f.bdeSize = DA_ID_REQUEST_SZ;
10041125 else if (cmdcode == SLI_CTNS_RFF_ID)
10051126 bpl->tus.f.bdeSize = RFF_REQUEST_SZ;
10061127 else
@@ -1029,31 +1150,34 @@ lpfc_ns_cmd(struct lpfc_vport *vport, int cmdcode, · 22 unmodified lines
10291150 case SLI_CTNS_GFF_ID:
10301151 CtReq->CommandResponse.bits.CmdRsp =
10311152 be16_to_cpu(SLI_CTNS_GFF_ID);
1032− CtReq->un.gff.PortId = be32_to_cpu(context);
1153+ CtReq->un.gff.PortId = cpu_to_be32(context);
10331154 cmpl = lpfc_cmpl_ct_cmd_gff_id;
10341155 break;
10351156
10361157 case SLI_CTNS_RFT_ID:
1158+ vport->ct_flags &= ~FC_CT_RFT_ID;
10371159 CtReq->CommandResponse.bits.CmdRsp =
10381160 be16_to_cpu(SLI_CTNS_RFT_ID);
1039− CtReq->un.rft.PortId = be32_to_cpu(vport->fc_myDID);
1161+ CtReq->un.rft.PortId = cpu_to_be32(vport->fc_myDID);
10401162 CtReq->un.rft.fcpReg = 1;
10411163 cmpl = lpfc_cmpl_ct_cmd_rft_id;
10421164 break;
10431165
10441166 case SLI_CTNS_RNN_ID:
1167+ vport->ct_flags &= ~FC_CT_RNN_ID;
10451168 CtReq->CommandResponse.bits.CmdRsp =
10461169 be16_to_cpu(SLI_CTNS_RNN_ID);
1047− CtReq->un.rnn.PortId = be32_to_cpu(vport->fc_myDID);
1170+ CtReq->un.rnn.PortId = cpu_to_be32(vport->fc_myDID);
10481171 memcpy(CtReq->un.rnn.wwnn, &vport->fc_nodename,
10491172 sizeof (struct lpfc_name));
10501173 cmpl = lpfc_cmpl_ct_cmd_rnn_id;
10511174 break;
10521175
10531176 case SLI_CTNS_RSPN_ID:
1177+ vport->ct_flags &= ~FC_CT_RSPN_ID;
10541178 CtReq->CommandResponse.bits.CmdRsp =
10551179 be16_to_cpu(SLI_CTNS_RSPN_ID);
1056− CtReq->un.rspn.PortId = be32_to_cpu(vport->fc_myDID);
1180+ CtReq->un.rspn.PortId = cpu_to_be32(vport->fc_myDID);
10571181 size = sizeof(CtReq->un.rspn.symbname);
10581182 CtReq->un.rspn.len =
10591183 lpfc_vport_symbolic_port_name(vport,
@@ -1061,6 +1185,7 @@ lpfc_ns_cmd(struct lpfc_vport *vport, int cmdcode, · 1 unmodified line
10611185 cmpl = lpfc_cmpl_ct_cmd_rspn_id;
10621186 break;
10631187 case SLI_CTNS_RSNN_NN:
1188+ vport->ct_flags &= ~FC_CT_RSNN_NN;
10641189 CtReq->CommandResponse.bits.CmdRsp =
10651190 be16_to_cpu(SLI_CTNS_RSNN_NN);
10661191 memcpy(CtReq->un.rsnn.wwnn, &vport->fc_nodename,
@@ -1071,11 +1196,18 @@ lpfc_ns_cmd(struct lpfc_vport *vport, int cmdcode, · 4 unmodified lines
10711196 CtReq->un.rsnn.symbname, size);
10721197 cmpl = lpfc_cmpl_ct_cmd_rsnn_nn;
10731198 break;
1199+ case SLI_CTNS_DA_ID:
1200+ /* Implement DA_ID Nameserver request */
1201+ CtReq->CommandResponse.bits.CmdRsp =
1202+ be16_to_cpu(SLI_CTNS_DA_ID);
1203+ CtReq->un.da_id.port_id = cpu_to_be32(vport->fc_myDID);
1204+ cmpl = lpfc_cmpl_ct_cmd_da_id;
1205+ break;
10741206 case SLI_CTNS_RFF_ID:
1075− vport->fc_flag &= ~FC_RFF_NOT_SUPPORTED;
1207+ vport->ct_flags &= ~FC_CT_RFF_ID;
10761208 CtReq->CommandResponse.bits.CmdRsp =
10771209 be16_to_cpu(SLI_CTNS_RFF_ID);
1078− CtReq->un.rff.PortId = be32_to_cpu(vport->fc_myDID);;
1210+ CtReq->un.rff.PortId = cpu_to_be32(vport->fc_myDID);;
10791211 CtReq->un.rff.fbits = FC4_FEATURE_INIT;
10801212 CtReq->un.rff.type_code = FC_FCP_DATA;
10811213 cmpl = lpfc_cmpl_ct_cmd_rff_id;
drivers/scsi/lpfc/lpfc_debugfs.c+127−30
@@ -43,6 +43,7 @@ · 42 unmodified lines
4343 #include "lpfc_crtn.h"
4444 #include "lpfc_vport.h"
4545 #include "lpfc_version.h"
46+#include "lpfc_compat.h"
4647 #include "lpfc_debugfs.h"
4748
4849 #ifdef CONFIG_LPFC_DEBUG_FS
@@ -75,18 +76,18 @@ module_param(lpfc_debugfs_enable, int, 0); · 26 unmodified lines
7576 MODULE_PARM_DESC(lpfc_debugfs_enable, "Enable debugfs services");
7677
7778 /* This MUST be a power of 2 */
78−static int lpfc_debugfs_max_disc_trc = 0;
79+static int lpfc_debugfs_max_disc_trc;
7980 module_param(lpfc_debugfs_max_disc_trc, int, 0);
8081 MODULE_PARM_DESC(lpfc_debugfs_max_disc_trc,
8182 "Set debugfs discovery trace depth");
8283
8384 /* This MUST be a power of 2 */
84−static int lpfc_debugfs_max_slow_ring_trc = 0;
85+static int lpfc_debugfs_max_slow_ring_trc;
8586 module_param(lpfc_debugfs_max_slow_ring_trc, int, 0);
8687 MODULE_PARM_DESC(lpfc_debugfs_max_slow_ring_trc,
8788 "Set debugfs slow ring trace depth");
8889
89−static int lpfc_debugfs_mask_disc_trc = 0;
90+int lpfc_debugfs_mask_disc_trc;
9091 module_param(lpfc_debugfs_mask_disc_trc, int, 0);
9192 MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
9293 "Set debugfs discovery trace mask");
@@ -100,8 +101,11 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc, · 7 unmodified lines
100101 #define LPFC_NODELIST_SIZE 8192
101102 #define LPFC_NODELIST_ENTRY_SIZE 120
102103
103−/* dumpslim output buffer size */
104−#define LPFC_DUMPSLIM_SIZE 4096
104+/* dumpHBASlim output buffer size */
105+#define LPFC_DUMPHBASLIM_SIZE 4096
106+
107+/* dumpHostSlim output buffer size */
108+#define LPFC_DUMPHOSTSLIM_SIZE 4096
105109
106110 /* hbqinfo output buffer size */
107111 #define LPFC_HBQINFO_SIZE 8192
@@ -243,16 +247,17 @@ lpfc_debugfs_hbqinfo_data(struct lpfc_hba *phba, char *buf, int size) · 135 unmodified lines
243247 raw_index = phba->hbq_get[i];
244248 getidx = le32_to_cpu(raw_index);
245249 len += snprintf(buf+len, size-len,
246− "entrys:%d Put:%d nPut:%d localGet:%d hbaGet:%d\n",
247− hbqs->entry_count, hbqs->hbqPutIdx, hbqs->next_hbqPutIdx,
248− hbqs->local_hbqGetIdx, getidx);
250+ "entrys:%d bufcnt:%d Put:%d nPut:%d localGet:%d hbaGet:%d\n",
251+ hbqs->entry_count, hbqs->buffer_count, hbqs->hbqPutIdx,
252+ hbqs->next_hbqPutIdx, hbqs->local_hbqGetIdx, getidx);
249253
250254 hbqe = (struct lpfc_hbq_entry *) phba->hbqs[i].hbq_virt;
251255 for (j=0; j<hbqs->entry_count; j++) {
252256 len += snprintf(buf+len, size-len,
253257 "%03d: %08x %04x %05x ", j,
254− hbqe->bde.addrLow, hbqe->bde.tus.w, hbqe->buffer_tag);
255−
258+ le32_to_cpu(hbqe->bde.addrLow),
259+ le32_to_cpu(hbqe->bde.tus.w),
260+ le32_to_cpu(hbqe->buffer_tag));
256261 i = 0;
257262 found = 0;
258263
@@ -276,7 +281,7 @@ lpfc_debugfs_hbqinfo_data(struct lpfc_hba *phba, char *buf, int size) · 17 unmodified lines
276281 list_for_each_entry(d_buf, &hbqs->hbq_buffer_list, list) {
277282 hbq_buf = container_of(d_buf, struct hbq_dmabuf, dbuf);
278283 phys = ((uint64_t)hbq_buf->dbuf.phys & 0xffffffff);
279− if (phys == hbqe->bde.addrLow) {
284+ if (phys == le32_to_cpu(hbqe->bde.addrLow)) {
280285 len += snprintf(buf+len, size-len,
281286 "Buf%d: %p %06x\n", i,
282287 hbq_buf->dbuf.virt, hbq_buf->tag);
@@ -297,18 +302,58 @@ skipit: · 14 unmodified lines
297302 return len;
298303 }
299304
305+static int lpfc_debugfs_last_hba_slim_off;
306+
307+static int
308+lpfc_debugfs_dumpHBASlim_data(struct lpfc_hba *phba, char *buf, int size)
309+{
310+ int len = 0;
311+ int i, off;
312+ uint32_t *ptr;
313+ char buffer[1024];
314+
315+ off = 0;
316+ spin_lock_irq(&phba->hbalock);
317+
318+ len += snprintf(buf+len, size-len, "HBA SLIM\n");
319+ lpfc_memcpy_from_slim(buffer,
320+ ((uint8_t *)phba->MBslimaddr) + lpfc_debugfs_last_hba_slim_off,
321+ 1024);
322+
323+ ptr = (uint32_t *)&buffer[0];
324+ off = lpfc_debugfs_last_hba_slim_off;
325+
326+ /* Set it up for the next time */
327+ lpfc_debugfs_last_hba_slim_off += 1024;
328+ if (lpfc_debugfs_last_hba_slim_off >= 4096)
329+ lpfc_debugfs_last_hba_slim_off = 0;
330+
331+ i = 1024;
332+ while (i > 0) {
333+ len += snprintf(buf+len, size-len,
334+ "%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",
335+ off, *ptr, *(ptr+1), *(ptr+2), *(ptr+3), *(ptr+4),
336+ *(ptr+5), *(ptr+6), *(ptr+7));
337+ ptr += 8;
338+ i -= (8 * sizeof(uint32_t));
339+ off += (8 * sizeof(uint32_t));
340+ }
341+
342+ spin_unlock_irq(&phba->hbalock);
343+ return len;
344+}
345+
300346 static int
301−lpfc_debugfs_dumpslim_data(struct lpfc_hba *phba, char *buf, int size)
347+lpfc_debugfs_dumpHostSlim_data(struct lpfc_hba *phba, char *buf, int size)
302348 {
303349 int len = 0;
304− int cnt, i, off;
350+ int i, off;
305351 uint32_t word0, word1, word2, word3;
306352 uint32_t *ptr;
307353 struct lpfc_pgp *pgpp;
308354 struct lpfc_sli *psli = &phba->sli;
309355 struct lpfc_sli_ring *pring;
310356
311− cnt = LPFC_DUMPSLIM_SIZE;
312357 off = 0;
313358 spin_lock_irq(&phba->hbalock);
314359
@@ -620,7 +665,34 @@ out: · 305 unmodified lines
620665 }
621666
622667 static int
623−lpfc_debugfs_dumpslim_open(struct inode *inode, struct file *file)
668+lpfc_debugfs_dumpHBASlim_open(struct inode *inode, struct file *file)
669+{
670+ struct lpfc_hba *phba = inode->i_private;
671+ struct lpfc_debug *debug;
672+ int rc = -ENOMEM;
673+
674+ debug = kmalloc(sizeof(*debug), GFP_KERNEL);
675+ if (!debug)
676+ goto out;
677+
678+ /* Round to page boundry */
679+ debug->buffer = kmalloc(LPFC_DUMPHBASLIM_SIZE, GFP_KERNEL);
680+ if (!debug->buffer) {
681+ kfree(debug);
682+ goto out;
683+ }
684+
685+ debug->len = lpfc_debugfs_dumpHBASlim_data(phba, debug->buffer,
686+ LPFC_DUMPHBASLIM_SIZE);
687+ file->private_data = debug;
688+
689+ rc = 0;
690+out:
691+ return rc;
692+}
693+
694+static int
695+lpfc_debugfs_dumpHostSlim_open(struct inode *inode, struct file *file)
624696 {
625697 struct lpfc_hba *phba = inode->i_private;
626698 struct lpfc_debug *debug;
@@ -631,14 +703,14 @@ lpfc_debugfs_dumpslim_open(struct inode *inode, struct file *file) · 4 unmodified lines
631703 goto out;
632704
633705 /* Round to page boundry */
634− debug->buffer = kmalloc(LPFC_DUMPSLIM_SIZE, GFP_KERNEL);
706+ debug->buffer = kmalloc(LPFC_DUMPHOSTSLIM_SIZE, GFP_KERNEL);
635707 if (!debug->buffer) {
636708 kfree(debug);
637709 goto out;
638710 }
639711
640− debug->len = lpfc_debugfs_dumpslim_data(phba, debug->buffer,
641− LPFC_DUMPSLIM_SIZE);
712+ debug->len = lpfc_debugfs_dumpHostSlim_data(phba, debug->buffer,
713+ LPFC_DUMPHOSTSLIM_SIZE);
642714 file->private_data = debug;
643715
644716 rc = 0;
@@ -741,10 +813,19 @@ static struct file_operations lpfc_debugfs_op_hbqinfo = { · 96 unmodified lines
741813 .release = lpfc_debugfs_release,
742814 };
743815
744−#undef lpfc_debugfs_op_dumpslim
745−static struct file_operations lpfc_debugfs_op_dumpslim = {
816+#undef lpfc_debugfs_op_dumpHBASlim
817+static struct file_operations lpfc_debugfs_op_dumpHBASlim = {
818+ .owner = THIS_MODULE,
819+ .open = lpfc_debugfs_dumpHBASlim_open,
820+ .llseek = lpfc_debugfs_lseek,
821+ .read = lpfc_debugfs_read,
822+ .release = lpfc_debugfs_release,
823+};
824+
825+#undef lpfc_debugfs_op_dumpHostSlim
826+static struct file_operations lpfc_debugfs_op_dumpHostSlim = {
746827 .owner = THIS_MODULE,
747− .open = lpfc_debugfs_dumpslim_open,
828+ .open = lpfc_debugfs_dumpHostSlim_open,
748829 .llseek = lpfc_debugfs_lseek,
749830 .read = lpfc_debugfs_read,
750831 .release = lpfc_debugfs_release,
@@ -812,15 +893,27 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport) · 61 unmodified lines
812893 goto debug_failed;
813894 }
814895
815− /* Setup dumpslim */
816− snprintf(name, sizeof(name), "dumpslim");
817− phba->debug_dumpslim =
896+ /* Setup dumpHBASlim */
897+ snprintf(name, sizeof(name), "dumpHBASlim");
898+ phba->debug_dumpHBASlim =
899+ debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
900+ phba->hba_debugfs_root,
901+ phba, &lpfc_debugfs_op_dumpHBASlim);
902+ if (!phba->debug_dumpHBASlim) {
903+ lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
904+ "0409 Cannot create debugfs dumpHBASlim\n");
905+ goto debug_failed;
906+ }
907+
908+ /* Setup dumpHostSlim */
909+ snprintf(name, sizeof(name), "dumpHostSlim");
910+ phba->debug_dumpHostSlim =
818911 debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
819912 phba->hba_debugfs_root,
820− phba, &lpfc_debugfs_op_dumpslim);
821− if (!phba->debug_dumpslim) {
913+ phba, &lpfc_debugfs_op_dumpHostSlim);
914+ if (!phba->debug_dumpHostSlim) {
822915 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
823− "0409 Cannot create debugfs dumpslim\n");
916+ "0409 Cannot create debugfs dumpHostSlim\n");
824917 goto debug_failed;
825918 }
826919
@@ -970,9 +1063,13 @@ lpfc_debugfs_terminate(struct lpfc_vport *vport) · 143 unmodified lines
9701063 debugfs_remove(phba->debug_hbqinfo); /* hbqinfo */
9711064 phba->debug_hbqinfo = NULL;
9721065 }
973− if (phba->debug_dumpslim) {
974− debugfs_remove(phba->debug_dumpslim); /* dumpslim */
975− phba->debug_dumpslim = NULL;
1066+ if (phba->debug_dumpHBASlim) {
1067+ debugfs_remove(phba->debug_dumpHBASlim); /* HBASlim */
1068+ phba->debug_dumpHBASlim = NULL;
1069+ }
1070+ if (phba->debug_dumpHostSlim) {
1071+ debugfs_remove(phba->debug_dumpHostSlim); /* HostSlim */
1072+ phba->debug_dumpHostSlim = NULL;
9761073 }
9771074 if (phba->slow_ring_trc) {
9781075 kfree(phba->slow_ring_trc);
drivers/scsi/lpfc/lpfc_disc.h+1−1
@@ -36,7 +36,6 @@ enum lpfc_work_type { · 35 unmodified lines
3636 LPFC_EVT_WARM_START,
3737 LPFC_EVT_KILL,
3838 LPFC_EVT_ELS_RETRY,
39− LPFC_EVT_DEV_LOSS_DELAY,
4039 LPFC_EVT_DEV_LOSS,
4140 };
4241
@@ -92,6 +91,7 @@ struct lpfc_nodelist { · 49 unmodified lines
9291 #define NLP_LOGO_SND 0x100 /* sent LOGO request for this entry */
9392 #define NLP_RNID_SND 0x400 /* sent RNID request for this entry */
9493 #define NLP_ELS_SND_MASK 0x7e0 /* sent ELS request for this entry */
94+#define NLP_DEFER_RM 0x10000 /* Remove this ndlp if no longer used */
9595 #define NLP_DELAY_TMO 0x20000 /* delay timeout is running for node */
9696 #define NLP_NPR_2B_DISC 0x40000 /* node is included in num_disc_nodes */
9797 #define NLP_RCV_PLOGI 0x80000 /* Rcv'ed PLOGI from remote system */
drivers/scsi/lpfc/lpfc_els.c+439−184
@@ -18,7 +18,7 @@ · 17 unmodified lines
1818 * more details, a copy of which can be found in the file COPYING *
1919 * included with this package. *
2020 *******************************************************************/
21−
21+/* See Fibre Channel protocol T11 FC-LS for details */
2222 #include <linux/blkdev.h>
2323 #include <linux/pci.h>
2424 #include <linux/interrupt.h>
@@ -42,6 +42,14 @@ static int lpfc_els_retry(struct lpfc_hba *, struct lpfc_iocbq *, · 17 unmodified lines
4242 struct lpfc_iocbq *);
4343 static void lpfc_cmpl_fabric_iocb(struct lpfc_hba *, struct lpfc_iocbq *,
4444 struct lpfc_iocbq *);
45+static void lpfc_fabric_abort_vport(struct lpfc_vport *vport);
46+static int lpfc_issue_els_fdisc(struct lpfc_vport *vport,
47+ struct lpfc_nodelist *ndlp, uint8_t retry);
48+static int lpfc_issue_fabric_iocb(struct lpfc_hba *phba,
49+ struct lpfc_iocbq *iocb);
50+static void lpfc_register_new_vport(struct lpfc_hba *phba,
51+ struct lpfc_vport *vport,
52+ struct lpfc_nodelist *ndlp);
4553
4654 static int lpfc_max_els_tries = 3;
4755
@@ -109,14 +117,11 @@ lpfc_prep_els_iocb(struct lpfc_vport *vport, uint8_t expectRsp, · 61 unmodified lines
109117
110118 /* fill in BDEs for command */
111119 /* Allocate buffer for command payload */
112− if (((pcmd = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL)) == 0) ||
113− ((pcmd->virt = lpfc_mbuf_alloc(phba,
114− MEM_PRI, &(pcmd->phys))) == 0)) {
115− kfree(pcmd);
116−
117− lpfc_sli_release_iocbq(phba, elsiocb);
118− return NULL;
119− }
120+ pcmd = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL);
121+ if (pcmd)
122+ pcmd->virt = lpfc_mbuf_alloc(phba, MEM_PRI, &pcmd->phys);
123+ if (!pcmd || !pcmd->virt)
124+ goto els_iocb_free_pcmb_exit;
120125
121126 INIT_LIST_HEAD(&pcmd->list);
122127
@@ -126,13 +131,8 @@ lpfc_prep_els_iocb(struct lpfc_vport *vport, uint8_t expectRsp, · 3 unmodified lines
126131 if (prsp)
127132 prsp->virt = lpfc_mbuf_alloc(phba, MEM_PRI,
128133 &prsp->phys);
129− if (prsp == 0 || prsp->virt == 0) {
130− kfree(prsp);
131− lpfc_mbuf_free(phba, pcmd->virt, pcmd->phys);
132− kfree(pcmd);
133− lpfc_sli_release_iocbq(phba, elsiocb);
134− return NULL;
135− }
134+ if (!prsp || !prsp->virt)
135+ goto els_iocb_free_prsp_exit;
136136 INIT_LIST_HEAD(&prsp->list);
137137 } else {
138138 prsp = NULL;
@@ -143,15 +143,8 @@ lpfc_prep_els_iocb(struct lpfc_vport *vport, uint8_t expectRsp, · 4 unmodified lines
143143 if (pbuflist)
144144 pbuflist->virt = lpfc_mbuf_alloc(phba, MEM_PRI,
145145 &pbuflist->phys);
146− if (pbuflist == 0 || pbuflist->virt == 0) {
147− lpfc_sli_release_iocbq(phba, elsiocb);
148− lpfc_mbuf_free(phba, pcmd->virt, pcmd->phys);
149− lpfc_mbuf_free(phba, prsp->virt, prsp->phys);
150− kfree(pcmd);
151− kfree(prsp);
152− kfree(pbuflist);
153− return NULL;
154− }
146+ if (!pbuflist || !pbuflist->virt)
147+ goto els_iocb_free_pbuf_exit;
155148
156149 INIT_LIST_HEAD(&pbuflist->list);
157150
@@ -196,7 +189,10 @@ lpfc_prep_els_iocb(struct lpfc_vport *vport, uint8_t expectRsp, · 38 unmodified lines
196189 bpl->tus.w = le32_to_cpu(bpl->tus.w);
197190 }
198191
192+ /* prevent preparing iocb with NULL ndlp reference */
199193 elsiocb->context1 = lpfc_nlp_get(ndlp);
194+ if (!elsiocb->context1)
195+ goto els_iocb_free_pbuf_exit;
200196 elsiocb->context2 = pcmd;
201197 elsiocb->context3 = pbuflist;
202198 elsiocb->retry = retry;
@@ -222,8 +218,20 @@ lpfc_prep_els_iocb(struct lpfc_vport *vport, uint8_t expectRsp, · 19 unmodified lines
222218 cmdSize);
223219 }
224220 return elsiocb;
225−}
226221
222+els_iocb_free_pbuf_exit:
223+ lpfc_mbuf_free(phba, prsp->virt, prsp->phys);
224+ kfree(pbuflist);
225+
226+els_iocb_free_prsp_exit:
227+ lpfc_mbuf_free(phba, pcmd->virt, pcmd->phys);
228+ kfree(prsp);
229+
230+els_iocb_free_pcmb_exit:
231+ kfree(pcmd);
232+ lpfc_sli_release_iocbq(phba, elsiocb);
233+ return NULL;
234+}
227235
228236 static int
229237 lpfc_issue_fabric_reglogin(struct lpfc_vport *vport)
@@ -234,40 +242,53 @@ lpfc_issue_fabric_reglogin(struct lpfc_vport *vport) · 4 unmodified lines
234242 struct lpfc_nodelist *ndlp;
235243 struct serv_parm *sp;
236244 int rc;
245+ int err = 0;
237246
238247 sp = &phba->fc_fabparam;
239248 ndlp = lpfc_findnode_did(vport, Fabric_DID);
240− if (!ndlp)
249+ if (!ndlp) {
250+ err = 1;
241251 goto fail;
252+ }
242253
243254 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
244− if (!mbox)
255+ if (!mbox) {
256+ err = 2;
245257 goto fail;
258+ }
246259
247260 vport->port_state = LPFC_FABRIC_CFG_LINK;
248261 lpfc_config_link(phba, mbox);
249262 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
250263 mbox->vport = vport;
251264
252− rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT | MBX_STOP_IOCB);
253− if (rc == MBX_NOT_FINISHED)
265+ rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT);
266+ if (rc == MBX_NOT_FINISHED) {
267+ err = 3;
254268 goto fail_free_mbox;
269+ }
255270
256271 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
257− if (!mbox)
272+ if (!mbox) {
273+ err = 4;
258274 goto fail;
275+ }
259276 rc = lpfc_reg_login(phba, vport->vpi, Fabric_DID, (uint8_t *)sp, mbox,
260277 0);
261− if (rc)
278+ if (rc) {
279+ err = 5;
262280 goto fail_free_mbox;
281+ }
263282
264283 mbox->mbox_cmpl = lpfc_mbx_cmpl_fabric_reg_login;
265284 mbox->vport = vport;
266285 mbox->context2 = lpfc_nlp_get(ndlp);
267286
268− rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT | MBX_STOP_IOCB);
269− if (rc == MBX_NOT_FINISHED)
287+ rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT);
288+ if (rc == MBX_NOT_FINISHED) {
289+ err = 6;
270290 goto fail_issue_reg_login;
291+ }
271292
272293 return 0;
273294
@@ -282,7 +303,7 @@ fail_free_mbox: · 8 unmodified lines
282303 fail:
283304 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
284305 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
285− "0249 Cannot issue Register Fabric login\n");
306+ "0249 Cannot issue Register Fabric login: Err %d\n", err);
286307 return -ENXIO;
287308 }
288309
@@ -370,11 +391,12 @@ lpfc_cmpl_els_flogi_fabric(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 81 unmodified lines
370391 }
371392 if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) {
372393 lpfc_mbx_unreg_vpi(vport);
394+ spin_lock_irq(shost->host_lock);
373395 vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI;
396+ spin_unlock_irq(shost->host_lock);
374397 }
375398 }
376399
377− ndlp->nlp_sid = irsp->un.ulpWord[4] & Mask_DID;
378400 lpfc_nlp_set_state(vport, ndlp, NLP_STE_REG_LOGIN_ISSUE);
379401
380402 if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED &&
@@ -429,8 +451,7 @@ lpfc_cmpl_els_flogi_nport(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 48 unmodified lines
429451
430452 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
431453 mbox->vport = vport;
432− rc = lpfc_sli_issue_mbox(phba, mbox,
433− MBX_NOWAIT | MBX_STOP_IOCB);
454+ rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT);
434455 if (rc == MBX_NOT_FINISHED) {
435456 mempool_free(mbox, phba->mbox_mem_pool);
436457 goto fail;
@@ -463,6 +484,9 @@ lpfc_cmpl_els_flogi_nport(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 26 unmodified lines
463484 lpfc_nlp_put(ndlp);
464485 }
465486
487+ /* If we are pt2pt with another NPort, force NPIV off! */
488+ phba->sli3_options &= ~LPFC_SLI3_NPIV_ENABLED;
489+
466490 spin_lock_irq(shost->host_lock);
467491 vport->fc_flag |= FC_PT2PT;
468492 spin_unlock_irq(shost->host_lock);
@@ -488,6 +512,9 @@ lpfc_cmpl_els_flogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 19 unmodified lines
488512
489513 /* Check to see if link went down during discovery */
490514 if (lpfc_els_chk_latt(vport)) {
515+ /* One additional decrement on node reference count to
516+ * trigger the release of the node
517+ */
491518 lpfc_nlp_put(ndlp);
492519 goto out;
493520 }
@@ -562,8 +589,13 @@ flogifail: · 68 unmodified lines
562589
563590 /* Start discovery */
564591 lpfc_disc_start(vport);
592+ } else if (((irsp->ulpStatus != IOSTAT_LOCAL_REJECT) ||
593+ ((irsp->un.ulpWord[4] != IOERR_SLI_ABORTED) &&
594+ (irsp->un.ulpWord[4] != IOERR_SLI_DOWN))) &&
595+ (phba->link_state != LPFC_CLEAR_LA)) {
596+ /* If FLOGI failed enable link interrupt. */
597+ lpfc_issue_clear_la(phba, vport);
565598 }
566−
567599 out:
568600 lpfc_els_free_iocb(phba, cmdiocb);
569601 }
@@ -685,6 +717,9 @@ lpfc_initial_flogi(struct lpfc_vport *vport) · 115 unmodified lines
685717 struct lpfc_hba *phba = vport->phba;
686718 struct lpfc_nodelist *ndlp;
687719
720+ vport->port_state = LPFC_FLOGI;
721+ lpfc_set_disctmo(vport);
722+
688723 /* First look for the Fabric ndlp */
689724 ndlp = lpfc_findnode_did(vport, Fabric_DID);
690725 if (!ndlp) {
@@ -696,7 +731,11 @@ lpfc_initial_flogi(struct lpfc_vport *vport) · 5 unmodified lines
696731 } else {
697732 lpfc_dequeue_node(vport, ndlp);
698733 }
734+
699735 if (lpfc_issue_els_flogi(vport, ndlp, 0)) {
736+ /* This decrement of reference count to node shall kick off
737+ * the release of the node.
738+ */
700739 lpfc_nlp_put(ndlp);
701740 }
702741 return 1;
@@ -720,11 +759,16 @@ lpfc_initial_fdisc(struct lpfc_vport *vport) · 17 unmodified lines
720759 lpfc_dequeue_node(vport, ndlp);
721760 }
722761 if (lpfc_issue_els_fdisc(vport, ndlp, 0)) {
762+ /* decrement node reference count to trigger the release of
763+ * the node.
764+ */
723765 lpfc_nlp_put(ndlp);
766+ return 0;
724767 }
725768 return 1;
726769 }
727−static void
770+
771+void
728772 lpfc_more_plogi(struct lpfc_vport *vport)
729773 {
730774 int sentplogi;
@@ -752,6 +796,8 @@ lpfc_plogi_confirm_nport(struct lpfc_hba *phba, uint32_t *prsp, · 21 unmodified lines
752796 {
753797 struct lpfc_vport *vport = ndlp->vport;
754798 struct lpfc_nodelist *new_ndlp;
799+ struct lpfc_rport_data *rdata;
800+ struct fc_rport *rport;
755801 struct serv_parm *sp;
756802 uint8_t name[sizeof(struct lpfc_name)];
757803 uint32_t rc;
@@ -788,11 +834,34 @@ lpfc_plogi_confirm_nport(struct lpfc_hba *phba, uint32_t *prsp, · 30 unmodified lines
788834 lpfc_unreg_rpi(vport, new_ndlp);
789835 new_ndlp->nlp_DID = ndlp->nlp_DID;
790836 new_ndlp->nlp_prev_state = ndlp->nlp_prev_state;
837+
838+ if (ndlp->nlp_flag & NLP_NPR_2B_DISC)
839+ new_ndlp->nlp_flag |= NLP_NPR_2B_DISC;
840+ ndlp->nlp_flag &= ~NLP_NPR_2B_DISC;
841+
791842 lpfc_nlp_set_state(vport, new_ndlp, ndlp->nlp_state);
792843
793844 /* Move this back to NPR state */
794− if (memcmp(&ndlp->nlp_portname, name, sizeof(struct lpfc_name)) == 0)
845+ if (memcmp(&ndlp->nlp_portname, name, sizeof(struct lpfc_name)) == 0) {
846+ /* The new_ndlp is replacing ndlp totally, so we need
847+ * to put ndlp on UNUSED list and try to free it.
848+ */
849+
850+ /* Fix up the rport accordingly */
851+ rport = ndlp->rport;
852+ if (rport) {
853+ rdata = rport->dd_data;
854+ if (rdata->pnode == ndlp) {
855+ lpfc_nlp_put(ndlp);
856+ ndlp->rport = NULL;
857+ rdata->pnode = lpfc_nlp_get(new_ndlp);
858+ new_ndlp->rport = rport;
859+ }
860+ new_ndlp->nlp_type = ndlp->nlp_type;
861+ }
862+
795863 lpfc_drop_node(vport, ndlp);
864+ }
796865 else {
797866 lpfc_unreg_rpi(vport, ndlp);
798867 ndlp->nlp_DID = 0; /* Two ndlps cannot have the same did */
@@ -801,6 +870,27 @@ lpfc_plogi_confirm_nport(struct lpfc_hba *phba, uint32_t *prsp, · 2 unmodified lines
801870 return new_ndlp;
802871 }
803872
873+void
874+lpfc_end_rscn(struct lpfc_vport *vport)
875+{
876+ struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
877+
878+ if (vport->fc_flag & FC_RSCN_MODE) {
879+ /*
880+ * Check to see if more RSCNs came in while we were
881+ * processing this one.
882+ */
883+ if (vport->fc_rscn_id_cnt ||
884+ (vport->fc_flag & FC_RSCN_DISCOVERY) != 0)
885+ lpfc_els_handle_rscn(vport);
886+ else {
887+ spin_lock_irq(shost->host_lock);
888+ vport->fc_flag &= ~FC_RSCN_MODE;
889+ spin_unlock_irq(shost->host_lock);
890+ }
891+ }
892+}
893+
804894 static void
805895 lpfc_cmpl_els_plogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
806896 struct lpfc_iocbq *rspiocb)
@@ -871,13 +961,6 @@ lpfc_cmpl_els_plogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 64 unmodified lines
871961 goto out;
872962 }
873963 /* PLOGI failed */
874− if (ndlp->nlp_DID == NameServer_DID) {
875− lpfc_vport_set_state(vport, FC_VPORT_FAILED);
876− lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
877− "0250 Nameserver login error: "
878− "0x%x / 0x%x\n",
879− irsp->ulpStatus, irsp->un.ulpWord[4]);
880− }
881964 /* Do not call DSM for lpfc_els_abort'ed ELS cmds */
882965 if (lpfc_error_lost_link(irsp)) {
883966 rc = NLP_STE_FREED_NODE;
@@ -905,20 +988,7 @@ lpfc_cmpl_els_plogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 21 unmodified lines
905988 spin_unlock_irq(shost->host_lock);
906989
907990 lpfc_can_disctmo(vport);
908− if (vport->fc_flag & FC_RSCN_MODE) {
909− /*
910− * Check to see if more RSCNs came in while
911− * we were processing this one.
912− */
913− if ((vport->fc_rscn_id_cnt == 0) &&
914− (!(vport->fc_flag & FC_RSCN_DISCOVERY))) {
915− spin_lock_irq(shost->host_lock);
916− vport->fc_flag &= ~FC_RSCN_MODE;
917− spin_unlock_irq(shost->host_lock);
918− } else {
919− lpfc_els_handle_rscn(vport);
920− }
921− }
991+ lpfc_end_rscn(vport);
922992 }
923993 }
924994
@@ -933,6 +1003,7 @@ lpfc_issue_els_plogi(struct lpfc_vport *vport, uint32_t did, uint8_t retry) · 8 unmodified lines
9331003 struct lpfc_hba *phba = vport->phba;
9341004 struct serv_parm *sp;
9351005 IOCB_t *icmd;
1006+ struct lpfc_nodelist *ndlp;
9361007 struct lpfc_iocbq *elsiocb;
9371008 struct lpfc_sli_ring *pring;
9381009 struct lpfc_sli *psli;
@@ -943,8 +1014,11 @@ lpfc_issue_els_plogi(struct lpfc_vport *vport, uint32_t did, uint8_t retry) · 4 unmodified lines
9431014 psli = &phba->sli;
9441015 pring = &psli->ring[LPFC_ELS_RING]; /* ELS ring */
9451016
1017+ ndlp = lpfc_findnode_did(vport, did);
1018+ /* If ndlp if not NULL, we will bump the reference count on it */
1019+
9461020 cmdsize = (sizeof(uint32_t) + sizeof(struct serv_parm));
947− elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, NULL, did,
1021+ elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp, did,
9481022 ELS_CMD_PLOGI);
9491023 if (!elsiocb)
9501024 return 1;
@@ -1109,7 +1183,7 @@ lpfc_issue_els_prli(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 158 unmodified lines
11091183 return 0;
11101184 }
11111185
1112−static void
1186+void
11131187 lpfc_more_adisc(struct lpfc_vport *vport)
11141188 {
11151189 int sentadisc;
@@ -1134,8 +1208,6 @@ lpfc_more_adisc(struct lpfc_vport *vport) · 18 unmodified lines
11341208 static void
11351209 lpfc_rscn_disc(struct lpfc_vport *vport)
11361210 {
1137− struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1138−
11391211 lpfc_can_disctmo(vport);
11401212
11411213 /* RSCN discovery */
@@ -1144,19 +1216,7 @@ lpfc_rscn_disc(struct lpfc_vport *vport) · 2 unmodified lines
11441216 if (lpfc_els_disc_plogi(vport))
11451217 return;
11461218
1147− if (vport->fc_flag & FC_RSCN_MODE) {
1148− /* Check to see if more RSCNs came in while we were
1149− * processing this one.
1150− */
1151− if ((vport->fc_rscn_id_cnt == 0) &&
1152− (!(vport->fc_flag & FC_RSCN_DISCOVERY))) {
1153− spin_lock_irq(shost->host_lock);
1154− vport->fc_flag &= ~FC_RSCN_MODE;
1155− spin_unlock_irq(shost->host_lock);
1156− } else {
1157− lpfc_els_handle_rscn(vport);
1158− }
1159− }
1219+ lpfc_end_rscn(vport);
11601220 }
11611221
11621222 static void
@@ -1413,6 +1473,13 @@ lpfc_issue_els_logo(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 250 unmodified lines
14131473 psli = &phba->sli;
14141474 pring = &psli->ring[LPFC_ELS_RING];
14151475
1476+ spin_lock_irq(shost->host_lock);
1477+ if (ndlp->nlp_flag & NLP_LOGO_SND) {
1478+ spin_unlock_irq(shost->host_lock);
1479+ return 0;
1480+ }
1481+ spin_unlock_irq(shost->host_lock);
1482+
14161483 cmdsize = (2 * sizeof(uint32_t)) + sizeof(struct lpfc_name);
14171484 elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp,
14181485 ndlp->nlp_DID, ELS_CMD_LOGO);
@@ -1499,6 +1566,9 @@ lpfc_issue_els_scr(struct lpfc_vport *vport, uint32_t nportid, uint8_t retry) · 80 unmodified lines
14991566 ndlp->nlp_DID, ELS_CMD_SCR);
15001567
15011568 if (!elsiocb) {
1569+ /* This will trigger the release of the node just
1570+ * allocated
1571+ */
15021572 lpfc_nlp_put(ndlp);
15031573 return 1;
15041574 }
@@ -1520,10 +1590,17 @@ lpfc_issue_els_scr(struct lpfc_vport *vport, uint32_t nportid, uint8_t retry) · 15 unmodified lines
15201590 phba->fc_stat.elsXmitSCR++;
15211591 elsiocb->iocb_cmpl = lpfc_cmpl_els_cmd;
15221592 if (lpfc_sli_issue_iocb(phba, pring, elsiocb, 0) == IOCB_ERROR) {
1593+ /* The additional lpfc_nlp_put will cause the following
1594+ * lpfc_els_free_iocb routine to trigger the rlease of
1595+ * the node.
1596+ */
15231597 lpfc_nlp_put(ndlp);
15241598 lpfc_els_free_iocb(phba, elsiocb);
15251599 return 1;
15261600 }
1601+ /* This will cause the callback-function lpfc_cmpl_els_cmd to
1602+ * trigger the release of node.
1603+ */
15271604 lpfc_nlp_put(ndlp);
15281605 return 0;
15291606 }
@@ -1555,6 +1632,9 @@ lpfc_issue_els_farpr(struct lpfc_vport *vport, uint32_t nportid, uint8_t retry) · 25 unmodified lines
15551632 elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp,
15561633 ndlp->nlp_DID, ELS_CMD_RNID);
15571634 if (!elsiocb) {
1635+ /* This will trigger the release of the node just
1636+ * allocated
1637+ */
15581638 lpfc_nlp_put(ndlp);
15591639 return 1;
15601640 }
@@ -1591,35 +1671,21 @@ lpfc_issue_els_farpr(struct lpfc_vport *vport, uint32_t nportid, uint8_t retry) · 30 unmodified lines
15911671 phba->fc_stat.elsXmitFARPR++;
15921672 elsiocb->iocb_cmpl = lpfc_cmpl_els_cmd;
15931673 if (lpfc_sli_issue_iocb(phba, pring, elsiocb, 0) == IOCB_ERROR) {
1674+ /* The additional lpfc_nlp_put will cause the following
1675+ * lpfc_els_free_iocb routine to trigger the release of
1676+ * the node.
1677+ */
15941678 lpfc_nlp_put(ndlp);
15951679 lpfc_els_free_iocb(phba, elsiocb);
15961680 return 1;
15971681 }
1682+ /* This will cause the callback-function lpfc_cmpl_els_cmd to
1683+ * trigger the release of the node.
1684+ */
15981685 lpfc_nlp_put(ndlp);
15991686 return 0;
16001687 }
16011688
1602−static void
1603−lpfc_end_rscn(struct lpfc_vport *vport)
1604−{
1605− struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1606−
1607− if (vport->fc_flag & FC_RSCN_MODE) {
1608− /*
1609− * Check to see if more RSCNs came in while we were
1610− * processing this one.
1611− */
1612− if (vport->fc_rscn_id_cnt ||
1613− (vport->fc_flag & FC_RSCN_DISCOVERY) != 0)
1614− lpfc_els_handle_rscn(vport);
1615− else {
1616− spin_lock_irq(shost->host_lock);
1617− vport->fc_flag &= ~FC_RSCN_MODE;
1618− spin_unlock_irq(shost->host_lock);
1619− }
1620− }
1621−}
1622−
16231689 void
16241690 lpfc_cancel_retry_delay_tmo(struct lpfc_vport *vport, struct lpfc_nodelist *nlp)
16251691 {
@@ -1675,7 +1741,10 @@ lpfc_els_retry_delay(unsigned long ptr) · 49 unmodified lines
16751741 return;
16761742 }
16771743
1678− evtp->evt_arg1 = ndlp;
1744+ /* We need to hold the node by incrementing the reference
1745+ * count until the queued work is done
1746+ */
1747+ evtp->evt_arg1 = lpfc_nlp_get(ndlp);
16791748 evtp->evt = LPFC_EVT_ELS_RETRY;
16801749 list_add_tail(&evtp->evt_listp, &phba->work_list);
16811750 if (phba->work_wait)
@@ -1759,6 +1828,7 @@ lpfc_els_retry(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 77 unmodified lines
17591828 uint32_t *elscmd;
17601829 struct ls_rjt stat;
17611830 int retry = 0, maxretry = lpfc_max_els_tries, delay = 0;
1831+ int logerr = 0;
17621832 uint32_t cmd = 0;
17631833 uint32_t did;
17641834
@@ -1815,6 +1885,7 @@ lpfc_els_retry(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 50 unmodified lines
18151885 break;
18161886
18171887 case IOERR_NO_RESOURCES:
1888+ logerr = 1; /* HBA out of resources */
18181889 retry = 1;
18191890 if (cmdiocb->retry > 100)
18201891 delay = 100;
@@ -1843,6 +1914,7 @@ lpfc_els_retry(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 22 unmodified lines
18431914
18441915 case IOSTAT_NPORT_BSY:
18451916 case IOSTAT_FABRIC_BSY:
1917+ logerr = 1; /* Fabric / Remote NPort out of resources */
18461918 retry = 1;
18471919 break;
18481920
@@ -1923,6 +1995,15 @@ lpfc_els_retry(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 74 unmodified lines
19231995 if (did == FDMI_DID)
19241996 retry = 1;
19251997
1998+ if ((cmd == ELS_CMD_FLOGI) &&
1999+ (phba->fc_topology != TOPOLOGY_LOOP)) {
2000+ /* FLOGI retry policy */
2001+ retry = 1;
2002+ maxretry = 48;
2003+ if (cmdiocb->retry >= 32)
2004+ delay = 1000;
2005+ }
2006+
19262007 if ((++cmdiocb->retry) >= maxretry) {
19272008 phba->fc_stat.elsRetryExceeded++;
19282009 retry = 0;
@@ -2006,11 +2087,46 @@ lpfc_els_retry(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 77 unmodified lines
20062087 }
20072088 }
20082089 /* No retry ELS command <elsCmd> to remote NPORT <did> */
2009− lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
2090+ if (logerr) {
2091+ lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
2092+ "0137 No retry ELS command x%x to remote "
2093+ "NPORT x%x: Out of Resources: Error:x%x/%x\n",
2094+ cmd, did, irsp->ulpStatus,
2095+ irsp->un.ulpWord[4]);
2096+ }
2097+ else {
2098+ lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
20102099 "0108 No retry ELS command x%x to remote "
20112100 "NPORT x%x Retried:%d Error:x%x/%x\n",
20122101 cmd, did, cmdiocb->retry, irsp->ulpStatus,
20132102 irsp->un.ulpWord[4]);
2103+ }
2104+ return 0;
2105+}
2106+
2107+static int
2108+lpfc_els_free_data(struct lpfc_hba *phba, struct lpfc_dmabuf *buf_ptr1)
2109+{
2110+ struct lpfc_dmabuf *buf_ptr;
2111+
2112+ /* Free the response before processing the command. */
2113+ if (!list_empty(&buf_ptr1->list)) {
2114+ list_remove_head(&buf_ptr1->list, buf_ptr,
2115+ struct lpfc_dmabuf,
2116+ list);
2117+ lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys);
2118+ kfree(buf_ptr);
2119+ }
2120+ lpfc_mbuf_free(phba, buf_ptr1->virt, buf_ptr1->phys);
2121+ kfree(buf_ptr1);
2122+ return 0;
2123+}
2124+
2125+static int
2126+lpfc_els_free_bpl(struct lpfc_hba *phba, struct lpfc_dmabuf *buf_ptr)
2127+{
2128+ lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys);
2129+ kfree(buf_ptr);
20142130 return 0;
20152131 }
20162132
@@ -2018,30 +2134,63 @@ int · 1 unmodified line
20182134 lpfc_els_free_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *elsiocb)
20192135 {
20202136 struct lpfc_dmabuf *buf_ptr, *buf_ptr1;
2137+ struct lpfc_nodelist *ndlp;
20212138
2022− if (elsiocb->context1) {
2023− lpfc_nlp_put(elsiocb->context1);
2139+ ndlp = (struct lpfc_nodelist *)elsiocb->context1;
2140+ if (ndlp) {
2141+ if (ndlp->nlp_flag & NLP_DEFER_RM) {
2142+ lpfc_nlp_put(ndlp);
2143+
2144+ /* If the ndlp is not being used by another discovery
2145+ * thread, free it.
2146+ */
2147+ if (!lpfc_nlp_not_used(ndlp)) {
2148+ /* If ndlp is being used by another discovery
2149+ * thread, just clear NLP_DEFER_RM
2150+ */
2151+ ndlp->nlp_flag &= ~NLP_DEFER_RM;
2152+ }
2153+ }
2154+ else
2155+ lpfc_nlp_put(ndlp);
20242156 elsiocb->context1 = NULL;
20252157 }
20262158 /* context2 = cmd, context2->next = rsp, context3 = bpl */
20272159 if (elsiocb->context2) {
2028− buf_ptr1 = (struct lpfc_dmabuf *) elsiocb->context2;
2029− /* Free the response before processing the command. */
2030− if (!list_empty(&buf_ptr1->list)) {
2031− list_remove_head(&buf_ptr1->list, buf_ptr,
2032− struct lpfc_dmabuf,
2033− list);
2034− lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys);
2035− kfree(buf_ptr);
2160+ if (elsiocb->iocb_flag & LPFC_DELAY_MEM_FREE) {
2161+ /* Firmware could still be in progress of DMAing
2162+ * payload, so don't free data buffer till after
2163+ * a hbeat.
2164+ */
2165+ elsiocb->iocb_flag &= ~LPFC_DELAY_MEM_FREE;
2166+ buf_ptr = elsiocb->context2;
2167+ elsiocb->context2 = NULL;
2168+ if (buf_ptr) {
2169+ buf_ptr1 = NULL;
2170+ spin_lock_irq(&phba->hbalock);
2171+ if (!list_empty(&buf_ptr->list)) {
2172+ list_remove_head(&buf_ptr->list,
2173+ buf_ptr1, struct lpfc_dmabuf,
2174+ list);
2175+ INIT_LIST_HEAD(&buf_ptr1->list);
2176+ list_add_tail(&buf_ptr1->list,
2177+ &phba->elsbuf);
2178+ phba->elsbuf_cnt++;
2179+ }
2180+ INIT_LIST_HEAD(&buf_ptr->list);
2181+ list_add_tail(&buf_ptr->list, &phba->elsbuf);
2182+ phba->elsbuf_cnt++;
2183+ spin_unlock_irq(&phba->hbalock);
2184+ }
2185+ } else {
2186+ buf_ptr1 = (struct lpfc_dmabuf *) elsiocb->context2;
2187+ lpfc_els_free_data(phba, buf_ptr1);
20362188 }
2037− lpfc_mbuf_free(phba, buf_ptr1->virt, buf_ptr1->phys);
2038− kfree(buf_ptr1);
20392189 }
20402190
20412191 if (elsiocb->context3) {
20422192 buf_ptr = (struct lpfc_dmabuf *) elsiocb->context3;
2043− lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys);
2044− kfree(buf_ptr);
2193+ lpfc_els_free_bpl(phba, buf_ptr);
20452194 }
20462195 lpfc_sli_release_iocbq(phba, elsiocb);
20472196 return 0;
@@ -2065,15 +2214,20 @@ lpfc_cmpl_els_logo_acc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 17 unmodified lines
20652214 "Data: x%x x%x x%x\n",
20662215 ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state,
20672216 ndlp->nlp_rpi);
2068− switch (ndlp->nlp_state) {
2069− case NLP_STE_UNUSED_NODE: /* node is just allocated */
2070− lpfc_drop_node(vport, ndlp);
2071− break;
2072− case NLP_STE_NPR_NODE: /* NPort Recovery mode */
2073− lpfc_unreg_rpi(vport, ndlp);
2074− break;
2075− default:
2076− break;
2217+
2218+ if (ndlp->nlp_state == NLP_STE_NPR_NODE) {
2219+ /* NPort Recovery mode or node is just allocated */
2220+ if (!lpfc_nlp_not_used(ndlp)) {
2221+ /* If the ndlp is being used by another discovery
2222+ * thread, just unregister the RPI.
2223+ */
2224+ lpfc_unreg_rpi(vport, ndlp);
2225+ } else {
2226+ /* Indicate the node has already released, should
2227+ * not reference to it from within lpfc_els_free_iocb.
2228+ */
2229+ cmdiocb->context1 = NULL;
2230+ }
20772231 }
20782232 lpfc_els_free_iocb(phba, cmdiocb);
20792233 return;
@@ -2089,7 +2243,14 @@ lpfc_mbx_cmpl_dflt_rpi(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 9 unmodified lines
20892243 lpfc_mbuf_free(phba, mp->virt, mp->phys);
20902244 kfree(mp);
20912245 mempool_free(pmb, phba->mbox_mem_pool);
2092− lpfc_nlp_put(ndlp);
2246+ if (ndlp) {
2247+ lpfc_nlp_put(ndlp);
2248+ /* This is the end of the default RPI cleanup logic for this
2249+ * ndlp. If no other discovery threads are using this ndlp.
2250+ * we should free all resources associated with it.
2251+ */
2252+ lpfc_nlp_not_used(ndlp);
2253+ }
20932254 return;
20942255 }
20952256
@@ -2100,15 +2261,29 @@ lpfc_cmpl_els_rsp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 4 unmodified lines
21002261 struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) cmdiocb->context1;
21012262 struct lpfc_vport *vport = ndlp ? ndlp->vport : NULL;
21022263 struct Scsi_Host *shost = vport ? lpfc_shost_from_vport(vport) : NULL;
2103− IOCB_t *irsp;
2264+ IOCB_t *irsp;
2265+ uint8_t *pcmd;
21042266 LPFC_MBOXQ_t *mbox = NULL;
21052267 struct lpfc_dmabuf *mp = NULL;
2268+ uint32_t ls_rjt = 0;
21062269
21072270 irsp = &rspiocb->iocb;
21082271
21092272 if (cmdiocb->context_un.mbox)
21102273 mbox = cmdiocb->context_un.mbox;
21112274
2275+ /* First determine if this is a LS_RJT cmpl. Note, this callback
2276+ * function can have cmdiocb->contest1 (ndlp) field set to NULL.
2277+ */
2278+ pcmd = (uint8_t *) (((struct lpfc_dmabuf *) cmdiocb->context2)->virt);
2279+ if (ndlp && (*((uint32_t *) (pcmd)) == ELS_CMD_LS_RJT)) {
2280+ /* A LS_RJT associated with Default RPI cleanup has its own
2281+ * seperate code path.
2282+ */
2283+ if (!(ndlp->nlp_flag & NLP_RM_DFLT_RPI))
2284+ ls_rjt = 1;
2285+ }
2286+
21122287 /* Check to see if link went down during discovery */
21132288 if (!ndlp || lpfc_els_chk_latt(vport)) {
21142289 if (mbox) {
@@ -2119,6 +2294,15 @@ lpfc_cmpl_els_rsp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 4 unmodified lines
21192294 }
21202295 mempool_free(mbox, phba->mbox_mem_pool);
21212296 }
2297+ if (ndlp && (ndlp->nlp_flag & NLP_RM_DFLT_RPI))
2298+ if (lpfc_nlp_not_used(ndlp)) {
2299+ ndlp = NULL;
2300+ /* Indicate the node has already released,
2301+ * should not reference to it from within
2302+ * the routine lpfc_els_free_iocb.
2303+ */
2304+ cmdiocb->context1 = NULL;
2305+ }
21222306 goto out;
21232307 }
21242308
@@ -2150,20 +2334,39 @@ lpfc_cmpl_els_rsp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 25 unmodified lines
21502334 lpfc_nlp_set_state(vport, ndlp,
21512335 NLP_STE_REG_LOGIN_ISSUE);
21522336 }
2153− if (lpfc_sli_issue_mbox(phba, mbox,
2154− (MBX_NOWAIT | MBX_STOP_IOCB))
2337+ if (lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT)
21552338 != MBX_NOT_FINISHED) {
21562339 goto out;
21572340 }
2158− lpfc_nlp_put(ndlp);
2159− /* NOTE: we should have messages for unsuccessful
2160− reglogin */
2341+
2342+ /* ELS rsp: Cannot issue reg_login for <NPortid> */
2343+ lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
2344+ "0138 ELS rsp: Cannot issue reg_login for x%x "
2345+ "Data: x%x x%x x%x\n",
2346+ ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state,
2347+ ndlp->nlp_rpi);
2348+
2349+ if (lpfc_nlp_not_used(ndlp)) {
2350+ ndlp = NULL;
2351+ /* Indicate node has already been released,
2352+ * should not reference to it from within
2353+ * the routine lpfc_els_free_iocb.
2354+ */
2355+ cmdiocb->context1 = NULL;
2356+ }
21612357 } else {
21622358 /* Do not drop node for lpfc_els_abort'ed ELS cmds */
21632359 if (!lpfc_error_lost_link(irsp) &&
21642360 ndlp->nlp_flag & NLP_ACC_REGLOGIN) {
2165− lpfc_drop_node(vport, ndlp);
2166− ndlp = NULL;
2361+ if (lpfc_nlp_not_used(ndlp)) {
2362+ ndlp = NULL;
2363+ /* Indicate node has already been
2364+ * released, should not reference
2365+ * to it from within the routine
2366+ * lpfc_els_free_iocb.
2367+ */
2368+ cmdiocb->context1 = NULL;
2369+ }
21672370 }
21682371 }
21692372 mp = (struct lpfc_dmabuf *) mbox->context1;
@@ -2178,7 +2381,21 @@ out: · 8 unmodified lines
21782381 spin_lock_irq(shost->host_lock);
21792382 ndlp->nlp_flag &= ~(NLP_ACC_REGLOGIN | NLP_RM_DFLT_RPI);
21802383 spin_unlock_irq(shost->host_lock);
2384+
2385+ /* If the node is not being used by another discovery thread,
2386+ * and we are sending a reject, we are done with it.
2387+ * Release driver reference count here and free associated
2388+ * resources.
2389+ */
2390+ if (ls_rjt)
2391+ if (lpfc_nlp_not_used(ndlp))
2392+ /* Indicate node has already been released,
2393+ * should not reference to it from within
2394+ * the routine lpfc_els_free_iocb.
2395+ */
2396+ cmdiocb->context1 = NULL;
21812397 }
2398+
21822399 lpfc_els_free_iocb(phba, cmdiocb);
21832400 return;
21842401 }
@@ -2349,14 +2566,6 @@ lpfc_els_rsp_reject(struct lpfc_vport *vport, uint32_t rejectError, · 164 unmodified lines
23492566 elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp;
23502567 rc = lpfc_sli_issue_iocb(phba, pring, elsiocb, 0);
23512568
2352− /* If the node is in the UNUSED state, and we are sending
2353− * a reject, we are done with it. Release driver reference
2354− * count here. The outstanding els will release its reference on
2355− * completion and the node can be freed then.
2356− */
2357− if (ndlp->nlp_state == NLP_STE_UNUSED_NODE)
2358− lpfc_nlp_put(ndlp);
2359−
23602569 if (rc == IOCB_ERROR) {
23612570 lpfc_els_free_iocb(phba, elsiocb);
23622571 return 1;
@@ -2642,7 +2851,10 @@ lpfc_els_disc_plogi(struct lpfc_vport *vport) · 279 unmodified lines
26422851 }
26432852 }
26442853 }
2645− if (sentplogi == 0) {
2854+ if (sentplogi) {
2855+ lpfc_set_disctmo(vport);
2856+ }
2857+ else {
26462858 spin_lock_irq(shost->host_lock);
26472859 vport->fc_flag &= ~FC_NLP_MORE;
26482860 spin_unlock_irq(shost->host_lock);
@@ -2830,10 +3042,10 @@ lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 181 unmodified lines
28303042 "RCV RSCN defer: did:x%x/ste:x%x flg:x%x",
28313043 ndlp->nlp_DID, vport->port_state, ndlp->nlp_flag);
28323044
3045+ spin_lock_irq(shost->host_lock);
28333046 vport->fc_flag |= FC_RSCN_DEFERRED;
28343047 if ((rscn_cnt < FC_MAX_HOLD_RSCN) &&
28353048 !(vport->fc_flag & FC_RSCN_DISCOVERY)) {
2836− spin_lock_irq(shost->host_lock);
28373049 vport->fc_flag |= FC_RSCN_MODE;
28383050 spin_unlock_irq(shost->host_lock);
28393051 if (rscn_cnt) {
@@ -2862,7 +3074,6 @@ lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 22 unmodified lines
28623074 vport->fc_rscn_id_cnt, vport->fc_flag,
28633075 vport->port_state);
28643076 } else {
2865− spin_lock_irq(shost->host_lock);
28663077 vport->fc_flag |= FC_RSCN_DISCOVERY;
28673078 spin_unlock_irq(shost->host_lock);
28683079 /* ReDiscovery RSCN */
@@ -2877,7 +3088,9 @@ lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 8 unmodified lines
28773088
28783089 /* send RECOVERY event for ALL nodes that match RSCN payload */
28793090 lpfc_rscn_recovery_check(vport);
3091+ spin_lock_irq(shost->host_lock);
28803092 vport->fc_flag &= ~FC_RSCN_DEFERRED;
3093+ spin_unlock_irq(shost->host_lock);
28813094 return 0;
28823095 }
28833096
@@ -2929,6 +3142,8 @@ lpfc_els_handle_rscn(struct lpfc_vport *vport) · 45 unmodified lines
29293142
29303143 /* To process RSCN, first compare RSCN data with NameServer */
29313144 vport->fc_ns_retry = 0;
3145+ vport->num_disc_nodes = 0;
3146+
29323147 ndlp = lpfc_findnode_did(vport, NameServer_DID);
29333148 if (ndlp && ndlp->nlp_state == NLP_STE_UNMAPPED_NODE) {
29343149 /* Good ndlp, issue CT Request to NameServer */
@@ -3022,8 +3237,7 @@ lpfc_els_rcv_flogi(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 87 unmodified lines
30223237 mbox->mb.un.varInitLnk.lipsr_AL_PA = 0;
30233238 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
30243239 mbox->vport = vport;
3025− rc = lpfc_sli_issue_mbox
3026− (phba, mbox, (MBX_NOWAIT | MBX_STOP_IOCB));
3240+ rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT);
30273241 lpfc_set_loopback_flag(phba);
30283242 if (rc == MBX_NOT_FINISHED) {
30293243 mempool_free(mbox, phba->mbox_mem_pool);
@@ -3140,7 +3354,10 @@ lpfc_els_rsp_rps_acc(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 110 unmodified lines
31403354 elsiocb = lpfc_prep_els_iocb(phba->pport, 0, cmdsize,
31413355 lpfc_max_els_tries, ndlp,
31423356 ndlp->nlp_DID, ELS_CMD_ACC);
3357+
3358+ /* Decrement the ndlp reference count from previous mbox command */
31433359 lpfc_nlp_put(ndlp);
3360+
31443361 if (!elsiocb)
31453362 return;
31463363
@@ -3160,13 +3377,13 @@ lpfc_els_rsp_rps_acc(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 13 unmodified lines
31603377 status |= 0x4;
31613378
31623379 rps_rsp->rsvd1 = 0;
3163− rps_rsp->portStatus = be16_to_cpu(status);
3164− rps_rsp->linkFailureCnt = be32_to_cpu(mb->un.varRdLnk.linkFailureCnt);
3165− rps_rsp->lossSyncCnt = be32_to_cpu(mb->un.varRdLnk.lossSyncCnt);
3166− rps_rsp->lossSignalCnt = be32_to_cpu(mb->un.varRdLnk.lossSignalCnt);
3167− rps_rsp->primSeqErrCnt = be32_to_cpu(mb->un.varRdLnk.primSeqErrCnt);
3168− rps_rsp->invalidXmitWord = be32_to_cpu(mb->un.varRdLnk.invalidXmitWord);
3169− rps_rsp->crcCnt = be32_to_cpu(mb->un.varRdLnk.crcCnt);
3380+ rps_rsp->portStatus = cpu_to_be16(status);
3381+ rps_rsp->linkFailureCnt = cpu_to_be32(mb->un.varRdLnk.linkFailureCnt);
3382+ rps_rsp->lossSyncCnt = cpu_to_be32(mb->un.varRdLnk.lossSyncCnt);
3383+ rps_rsp->lossSignalCnt = cpu_to_be32(mb->un.varRdLnk.lossSignalCnt);
3384+ rps_rsp->primSeqErrCnt = cpu_to_be32(mb->un.varRdLnk.primSeqErrCnt);
3385+ rps_rsp->invalidXmitWord = cpu_to_be32(mb->un.varRdLnk.invalidXmitWord);
3386+ rps_rsp->crcCnt = cpu_to_be32(mb->un.varRdLnk.crcCnt);
31703387 /* Xmit ELS RPS ACC response tag <ulpIoTag> */
31713388 lpfc_printf_vlog(ndlp->vport, KERN_INFO, LOG_ELS,
31723389 "0118 Xmit ELS RPS ACC response tag x%x xri x%x, "
@@ -3223,11 +3440,13 @@ lpfc_els_rcv_rps(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 50 unmodified lines
32233440 mbox->context2 = lpfc_nlp_get(ndlp);
32243441 mbox->vport = vport;
32253442 mbox->mbox_cmpl = lpfc_els_rsp_rps_acc;
3226− if (lpfc_sli_issue_mbox (phba, mbox,
3227− (MBX_NOWAIT | MBX_STOP_IOCB)) != MBX_NOT_FINISHED)
3443+ if (lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT)
3444+ != MBX_NOT_FINISHED)
32283445 /* Mbox completion will send ELS Response */
32293446 return 0;
3230−
3447+ /* Decrement reference count used for the failed mbox
3448+ * command.
3449+ */
32313450 lpfc_nlp_put(ndlp);
32323451 mempool_free(mbox, phba->mbox_mem_pool);
32333452 }
@@ -3461,6 +3680,7 @@ lpfc_els_rcv_fan(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 227 unmodified lines
34613680 * other NLP_FABRIC logins
34623681 */
34633682 lpfc_drop_node(vport, ndlp);
3683+
34643684 } else if (!(ndlp->nlp_flag & NLP_NPR_ADISC)) {
34653685 /* Fail outstanding I/O now since this
34663686 * device is marked for PLOGI
@@ -3469,8 +3689,6 @@ lpfc_els_rcv_fan(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 2 unmodified lines
34693689 }
34703690 }
34713691
3472− vport->port_state = LPFC_FLOGI;
3473− lpfc_set_disctmo(vport);
34743692 lpfc_initial_flogi(vport);
34753693 return 0;
34763694 }
@@ -3711,6 +3929,7 @@ static void · 234 unmodified lines
37113929 lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
37123930 struct lpfc_vport *vport, struct lpfc_iocbq *elsiocb)
37133931 {
3932+ struct Scsi_Host *shost;
37143933 struct lpfc_nodelist *ndlp;
37153934 struct ls_rjt stat;
37163935 uint32_t *payload;
@@ -3750,11 +3969,19 @@ lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 33 unmodified lines
37503969 goto dropit;
37513970
37523971 lpfc_nlp_init(vport, ndlp, did);
3972+ lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
37533973 newnode = 1;
37543974 if ((did & Fabric_DID_MASK) == Fabric_DID_MASK) {
37553975 ndlp->nlp_type |= NLP_FABRIC;
37563976 }
3757− lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNUSED_NODE);
3977+ }
3978+ else {
3979+ if (ndlp->nlp_state == NLP_STE_UNUSED_NODE) {
3980+ /* This is simular to the new node path */
3981+ lpfc_nlp_get(ndlp);
3982+ lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
3983+ newnode = 1;
3984+ }
37583985 }
37593986
37603987 phba->fc_stat.elsRcvFrame++;
@@ -3783,6 +4010,12 @@ lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 22 unmodified lines
37834010 rjt_err = LSRJT_UNABLE_TPC;
37844011 break;
37854012 }
4013+
4014+ shost = lpfc_shost_from_vport(vport);
4015+ spin_lock_irq(shost->host_lock);
4016+ ndlp->nlp_flag &= ~NLP_TARGET_REMOVE;
4017+ spin_unlock_irq(shost->host_lock);
4018+
37864019 lpfc_disc_state_machine(vport, ndlp, elsiocb,
37874020 NLP_EVT_RCV_PLOGI);
37884021
@@ -3795,7 +4028,7 @@ lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 6 unmodified lines
37954028 phba->fc_stat.elsRcvFLOGI++;
37964029 lpfc_els_rcv_flogi(vport, elsiocb, ndlp);
37974030 if (newnode)
3798− lpfc_drop_node(vport, ndlp);
4031+ lpfc_nlp_put(ndlp);
37994032 break;
38004033 case ELS_CMD_LOGO:
38014034 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
@@ -3825,7 +4058,7 @@ lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 23 unmodified lines
38254058 phba->fc_stat.elsRcvRSCN++;
38264059 lpfc_els_rcv_rscn(vport, elsiocb, ndlp);
38274060 if (newnode)
3828− lpfc_drop_node(vport, ndlp);
4061+ lpfc_nlp_put(ndlp);
38294062 break;
38304063 case ELS_CMD_ADISC:
38314064 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
@@ -3897,7 +4130,7 @@ lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 65 unmodified lines
38974130 phba->fc_stat.elsRcvLIRR++;
38984131 lpfc_els_rcv_lirr(vport, elsiocb, ndlp);
38994132 if (newnode)
3900− lpfc_drop_node(vport, ndlp);
4133+ lpfc_nlp_put(ndlp);
39014134 break;
39024135 case ELS_CMD_RPS:
39034136 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
@@ -3907,7 +4140,7 @@ lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 3 unmodified lines
39074140 phba->fc_stat.elsRcvRPS++;
39084141 lpfc_els_rcv_rps(vport, elsiocb, ndlp);
39094142 if (newnode)
3910− lpfc_drop_node(vport, ndlp);
4143+ lpfc_nlp_put(ndlp);
39114144 break;
39124145 case ELS_CMD_RPL:
39134146 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
@@ -3917,7 +4150,7 @@ lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 3 unmodified lines
39174150 phba->fc_stat.elsRcvRPL++;
39184151 lpfc_els_rcv_rpl(vport, elsiocb, ndlp);
39194152 if (newnode)
3920− lpfc_drop_node(vport, ndlp);
4153+ lpfc_nlp_put(ndlp);
39214154 break;
39224155 case ELS_CMD_RNID:
39234156 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
@@ -3927,7 +4160,7 @@ lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 3 unmodified lines
39274160 phba->fc_stat.elsRcvRNID++;
39284161 lpfc_els_rcv_rnid(vport, elsiocb, ndlp);
39294162 if (newnode)
3930− lpfc_drop_node(vport, ndlp);
4163+ lpfc_nlp_put(ndlp);
39314164 break;
39324165 default:
39334166 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
@@ -3942,7 +4175,7 @@ lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 8 unmodified lines
39424175 "0115 Unknown ELS command x%x "
39434176 "received from NPORT x%x\n", cmd, did);
39444177 if (newnode)
3945− lpfc_drop_node(vport, ndlp);
4178+ lpfc_nlp_put(ndlp);
39464179 break;
39474180 }
39484181
@@ -3958,10 +4191,11 @@ lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 9 unmodified lines
39584191 return;
39594192
39604193 dropit:
3961− lpfc_printf_log(phba, KERN_ERR, LOG_ELS,
4194+ if (vport && !(vport->load_flag & FC_UNLOADING))
4195+ lpfc_printf_log(phba, KERN_ERR, LOG_ELS,
39624196 "(%d):0111 Dropping received ELS cmd "
39634197 "Data: x%x x%x x%x\n",
3964− vport ? vport->vpi : 0xffff, icmd->ulpStatus,
4198+ vport->vpi, icmd->ulpStatus,
39654199 icmd->un.ulpWord[4], icmd->ulpTimeout);
39664200 phba->fc_stat.elsRcvDrop++;
39674201 }
@@ -4114,8 +4348,9 @@ lpfc_cmpl_reg_new_vport(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 146 unmodified lines
41144348 struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) pmb->context2;
41154349 MAILBOX_t *mb = &pmb->mb;
41164350
4351+ spin_lock_irq(shost->host_lock);
41174352 vport->fc_flag &= ~FC_VPORT_NEEDS_REG_VPI;
4118− lpfc_nlp_put(ndlp);
4353+ spin_unlock_irq(shost->host_lock);
41194354
41204355 if (mb->mbxStatus) {
41214356 lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX,
@@ -4135,7 +4370,9 @@ lpfc_cmpl_reg_new_vport(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 13 unmodified lines
41354370 default:
41364371 /* Try to recover from this error */
41374372 lpfc_mbx_unreg_vpi(vport);
4373+ spin_lock_irq(shost->host_lock);
41384374 vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI;
4375+ spin_unlock_irq(shost->host_lock);
41394376 lpfc_initial_fdisc(vport);
41404377 break;
41414378 }
@@ -4146,14 +4383,21 @@ lpfc_cmpl_reg_new_vport(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 4 unmodified lines
41464383 else
41474384 lpfc_do_scr_ns_plogi(phba, vport);
41484385 }
4386+
4387+ /* Now, we decrement the ndlp reference count held for this
4388+ * callback function
4389+ */
4390+ lpfc_nlp_put(ndlp);
4391+
41494392 mempool_free(pmb, phba->mbox_mem_pool);
41504393 return;
41514394 }
41524395
4153−void
4396+static void
41544397 lpfc_register_new_vport(struct lpfc_hba *phba, struct lpfc_vport *vport,
41554398 struct lpfc_nodelist *ndlp)
41564399 {
4400+ struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
41574401 LPFC_MBOXQ_t *mbox;
41584402
41594403 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
@@ -4162,25 +4406,31 @@ lpfc_register_new_vport(struct lpfc_hba *phba, struct lpfc_vport *vport, · 2 unmodified lines
41624406 mbox->vport = vport;
41634407 mbox->context2 = lpfc_nlp_get(ndlp);
41644408 mbox->mbox_cmpl = lpfc_cmpl_reg_new_vport;
4165− if (lpfc_sli_issue_mbox(phba, mbox,
4166− MBX_NOWAIT | MBX_STOP_IOCB)
4409+ if (lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT)
41674410 == MBX_NOT_FINISHED) {
4411+ /* mailbox command not success, decrement ndlp
4412+ * reference count for this command
4413+ */
4414+ lpfc_nlp_put(ndlp);
41684415 mempool_free(mbox, phba->mbox_mem_pool);
4169− vport->fc_flag &= ~FC_VPORT_NEEDS_REG_VPI;
41704416
4171− lpfc_vport_set_state(vport, FC_VPORT_FAILED);
41724417 lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX,
41734418 "0253 Register VPI: Can't send mbox\n");
4419+ goto mbox_err_exit;
41744420 }
41754421 } else {
4176− lpfc_vport_set_state(vport, FC_VPORT_FAILED);
4177−
41784422 lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX,
41794423 "0254 Register VPI: no memory\n");
4180−
4181− vport->fc_flag &= ~FC_VPORT_NEEDS_REG_VPI;
4182− lpfc_nlp_put(ndlp);
4424+ goto mbox_err_exit;
41834425 }
4426+ return;
4427+
4428+mbox_err_exit:
4429+ lpfc_vport_set_state(vport, FC_VPORT_FAILED);
4430+ spin_lock_irq(shost->host_lock);
4431+ vport->fc_flag &= ~FC_VPORT_NEEDS_REG_VPI;
4432+ spin_unlock_irq(shost->host_lock);
4433+ return;
41844434 }
41854435
41864436 static void
@@ -4251,7 +4501,9 @@ lpfc_cmpl_els_fdisc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 64 unmodified lines
42514501 lpfc_unreg_rpi(vport, np);
42524502 }
42534503 lpfc_mbx_unreg_vpi(vport);
4504+ spin_lock_irq(shost->host_lock);
42544505 vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI;
4506+ spin_unlock_irq(shost->host_lock);
42554507 }
42564508
42574509 if (vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)
@@ -4259,14 +4511,15 @@ lpfc_cmpl_els_fdisc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 1 unmodified line
42594511 else
42604512 lpfc_do_scr_ns_plogi(phba, vport);
42614513
4262− lpfc_nlp_put(ndlp); /* Free Fabric ndlp for vports */
4514+ /* Unconditionaly kick off releasing fabric node for vports */
4515+ lpfc_nlp_put(ndlp);
42634516 }
42644517
42654518 out:
42664519 lpfc_els_free_iocb(phba, cmdiocb);
42674520 }
42684521
4269−int
4522+static int
42704523 lpfc_issue_els_fdisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
42714524 uint8_t retry)
42724525 {
@@ -4539,7 +4792,7 @@ lpfc_cmpl_fabric_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 266 unmodified lines
45394792 }
45404793 }
45414794
4542−int
4795+static int
45434796 lpfc_issue_fabric_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *iocb)
45444797 {
45454798 unsigned long iflags;
@@ -4583,7 +4836,7 @@ lpfc_issue_fabric_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *iocb) · 37 unmodified lines
45834836 }
45844837
45854838
4586−void lpfc_fabric_abort_vport(struct lpfc_vport *vport)
4839+static void lpfc_fabric_abort_vport(struct lpfc_vport *vport)
45874840 {
45884841 LIST_HEAD(completions);
45894842 struct lpfc_hba *phba = vport->phba;
@@ -4663,6 +4916,7 @@ void lpfc_fabric_abort_hba(struct lpfc_hba *phba) · 73 unmodified lines
46634916 }
46644917
46654918
4919+#if 0
46664920 void lpfc_fabric_abort_flogi(struct lpfc_hba *phba)
46674921 {
46684922 LIST_HEAD(completions);
@@ -4693,5 +4947,6 @@ void lpfc_fabric_abort_flogi(struct lpfc_hba *phba) · 24 unmodified lines
46934947 (piocb->iocb_cmpl) (phba, piocb, piocb);
46944948 }
46954949 }
4950+#endif /* 0 */
46964951
46974952
drivers/scsi/lpfc/lpfc_hbadisc.c+242−130
@@ -57,6 +57,7 @@ static uint8_t lpfcAlpaArray[] = { · 56 unmodified lines
5757 };
5858
5959 static void lpfc_disc_timeout_handler(struct lpfc_vport *);
60+static void lpfc_disc_flush_list(struct lpfc_vport *vport);
6061
6162 void
6263 lpfc_terminate_rport_io(struct fc_rport *rport)
@@ -107,20 +108,14 @@ lpfc_dev_loss_tmo_callbk(struct fc_rport *rport) · 44 unmodified lines
107108 struct lpfc_nodelist * ndlp;
108109 struct lpfc_vport *vport;
109110 struct lpfc_hba *phba;
110− struct completion devloss_compl;
111111 struct lpfc_work_evt *evtp;
112+ int put_node;
113+ int put_rport;
112114
113115 rdata = rport->dd_data;
114116 ndlp = rdata->pnode;
115−
116− if (!ndlp) {
117− if (rport->scsi_target_id != -1) {
118− printk(KERN_ERR "Cannot find remote node"
119− " for rport in dev_loss_tmo_callbk x%x\n",
120− rport->port_id);
121− }
117+ if (!ndlp)
122118 return;
123− }
124119
125120 vport = ndlp->vport;
126121 phba = vport->phba;
@@ -129,15 +124,35 @@ lpfc_dev_loss_tmo_callbk(struct fc_rport *rport) · 2 unmodified lines
129124 "rport devlosscb: sid:x%x did:x%x flg:x%x",
130125 ndlp->nlp_sid, ndlp->nlp_DID, ndlp->nlp_flag);
131126
132− init_completion(&devloss_compl);
127+ /* Don't defer this if we are in the process of deleting the vport
128+ * or unloading the driver. The unload will cleanup the node
129+ * appropriately we just need to cleanup the ndlp rport info here.
130+ */
131+ if (vport->load_flag & FC_UNLOADING) {
132+ put_node = rdata->pnode != NULL;
133+ put_rport = ndlp->rport != NULL;
134+ rdata->pnode = NULL;
135+ ndlp->rport = NULL;
136+ if (put_node)
137+ lpfc_nlp_put(ndlp);
138+ if (put_rport)
139+ put_device(&rport->dev);
140+ return;
141+ }
142+
143+ if (ndlp->nlp_state == NLP_STE_MAPPED_NODE)
144+ return;
145+
133146 evtp = &ndlp->dev_loss_evt;
134147
135148 if (!list_empty(&evtp->evt_listp))
136149 return;
137150
138151 spin_lock_irq(&phba->hbalock);
139− evtp->evt_arg1 = ndlp;
140− evtp->evt_arg2 = &devloss_compl;
152+ /* We need to hold the node by incrementing the reference
153+ * count until this queued work is done
154+ */
155+ evtp->evt_arg1 = lpfc_nlp_get(ndlp);
141156 evtp->evt = LPFC_EVT_DEV_LOSS;
142157 list_add_tail(&evtp->evt_listp, &phba->work_list);
143158 if (phba->work_wait)
@@ -145,8 +160,6 @@ lpfc_dev_loss_tmo_callbk(struct fc_rport *rport) · 1 unmodified line
145160
146161 spin_unlock_irq(&phba->hbalock);
147162
148− wait_for_completion(&devloss_compl);
149−
150163 return;
151164 }
152165
@@ -154,7 +167,7 @@ lpfc_dev_loss_tmo_callbk(struct fc_rport *rport) · 1 unmodified line
154167 * This function is called from the worker thread when dev_loss_tmo
155168 * expire.
156169 */
157−void
170+static void
158171 lpfc_dev_loss_tmo_handler(struct lpfc_nodelist *ndlp)
159172 {
160173 struct lpfc_rport_data *rdata;
@@ -162,6 +175,8 @@ lpfc_dev_loss_tmo_handler(struct lpfc_nodelist *ndlp) · 1 unmodified line
162175 struct lpfc_vport *vport;
163176 struct lpfc_hba *phba;
164177 uint8_t *name;
178+ int put_node;
179+ int put_rport;
165180 int warn_on = 0;
166181
167182 rport = ndlp->rport;
@@ -178,14 +193,32 @@ lpfc_dev_loss_tmo_handler(struct lpfc_nodelist *ndlp) · 10 unmodified lines
178193 "rport devlosstmo:did:x%x type:x%x id:x%x",
179194 ndlp->nlp_DID, ndlp->nlp_type, rport->scsi_target_id);
180195
181− if (!(vport->load_flag & FC_UNLOADING) &&
182− ndlp->nlp_state == NLP_STE_MAPPED_NODE)
196+ /* Don't defer this if we are in the process of deleting the vport
197+ * or unloading the driver. The unload will cleanup the node
198+ * appropriately we just need to cleanup the ndlp rport info here.
199+ */
200+ if (vport->load_flag & FC_UNLOADING) {
201+ if (ndlp->nlp_sid != NLP_NO_SID) {
202+ /* flush the target */
203+ lpfc_sli_abort_iocb(vport,
204+ &phba->sli.ring[phba->sli.fcp_ring],
205+ ndlp->nlp_sid, 0, LPFC_CTX_TGT);
206+ }
207+ put_node = rdata->pnode != NULL;
208+ put_rport = ndlp->rport != NULL;
209+ rdata->pnode = NULL;
210+ ndlp->rport = NULL;
211+ if (put_node)
212+ lpfc_nlp_put(ndlp);
213+ if (put_rport)
214+ put_device(&rport->dev);
183215 return;
216+ }
184217
185− if (ndlp->nlp_type & NLP_FABRIC) {
186− int put_node;
187− int put_rport;
218+ if (ndlp->nlp_state == NLP_STE_MAPPED_NODE)
219+ return;
188220
221+ if (ndlp->nlp_type & NLP_FABRIC) {
189222 /* We will clean up these Nodes in linkup */
190223 put_node = rdata->pnode != NULL;
191224 put_rport = ndlp->rport != NULL;
@@ -227,23 +260,20 @@ lpfc_dev_loss_tmo_handler(struct lpfc_nodelist *ndlp) · 35 unmodified lines
227260 ndlp->nlp_state, ndlp->nlp_rpi);
228261 }
229262
263+ put_node = rdata->pnode != NULL;
264+ put_rport = ndlp->rport != NULL;
265+ rdata->pnode = NULL;
266+ ndlp->rport = NULL;
267+ if (put_node)
268+ lpfc_nlp_put(ndlp);
269+ if (put_rport)
270+ put_device(&rport->dev);
271+
230272 if (!(vport->load_flag & FC_UNLOADING) &&
231273 !(ndlp->nlp_flag & NLP_DELAY_TMO) &&
232274 !(ndlp->nlp_flag & NLP_NPR_2B_DISC) &&
233− (ndlp->nlp_state != NLP_STE_UNMAPPED_NODE))
275+ (ndlp->nlp_state != NLP_STE_UNMAPPED_NODE)) {
234276 lpfc_disc_state_machine(vport, ndlp, NULL, NLP_EVT_DEVICE_RM);
235− else {
236− int put_node;
237− int put_rport;
238−
239− put_node = rdata->pnode != NULL;
240− put_rport = ndlp->rport != NULL;
241− rdata->pnode = NULL;
242− ndlp->rport = NULL;
243− if (put_node)
244− lpfc_nlp_put(ndlp);
245− if (put_rport)
246− put_device(&rport->dev);
247277 }
248278 }
249279
@@ -260,7 +290,6 @@ lpfc_work_list_done(struct lpfc_hba *phba) · 10 unmodified lines
260290 {
261291 struct lpfc_work_evt *evtp = NULL;
262292 struct lpfc_nodelist *ndlp;
263− struct lpfc_vport *vport;
264293 int free_evt;
265294
266295 spin_lock_irq(&phba->hbalock);
@@ -270,35 +299,22 @@ lpfc_work_list_done(struct lpfc_hba *phba) · 3 unmodified lines
270299 spin_unlock_irq(&phba->hbalock);
271300 free_evt = 1;
272301 switch (evtp->evt) {
273− case LPFC_EVT_DEV_LOSS_DELAY:
274− free_evt = 0; /* evt is part of ndlp */
275− ndlp = (struct lpfc_nodelist *) (evtp->evt_arg1);
276− vport = ndlp->vport;
277− if (!vport)
278− break;
279−
280− lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_RPORT,
281− "rport devlossdly:did:x%x flg:x%x",
282− ndlp->nlp_DID, ndlp->nlp_flag, 0);
283−
284− if (!(vport->load_flag & FC_UNLOADING) &&
285− !(ndlp->nlp_flag & NLP_DELAY_TMO) &&
286− !(ndlp->nlp_flag & NLP_NPR_2B_DISC)) {
287− lpfc_disc_state_machine(vport, ndlp, NULL,
288− NLP_EVT_DEVICE_RM);
289− }
290− break;
291302 case LPFC_EVT_ELS_RETRY:
292303 ndlp = (struct lpfc_nodelist *) (evtp->evt_arg1);
293304 lpfc_els_retry_delay_handler(ndlp);
294305 free_evt = 0; /* evt is part of ndlp */
306+ /* decrement the node reference count held
307+ * for this queued work
308+ */
309+ lpfc_nlp_put(ndlp);
295310 break;
296311 case LPFC_EVT_DEV_LOSS:
297312 ndlp = (struct lpfc_nodelist *)(evtp->evt_arg1);
298− lpfc_nlp_get(ndlp);
299313 lpfc_dev_loss_tmo_handler(ndlp);
300314 free_evt = 0;
301− complete((struct completion *)(evtp->evt_arg2));
315+ /* decrement the node reference count held for
316+ * this queued work
317+ */
302318 lpfc_nlp_put(ndlp);
303319 break;
304320 case LPFC_EVT_ONLINE:
@@ -373,7 +389,7 @@ lpfc_work_done(struct lpfc_hba *phba) · 68 unmodified lines
373389 lpfc_handle_latt(phba);
374390 vports = lpfc_create_vport_work_array(phba);
375391 if (vports != NULL)
376− for(i = 0; i < LPFC_MAX_VPORTS; i++) {
392+ for(i = 0; i <= phba->max_vpi; i++) {
377393 /*
378394 * We could have no vports in array if unloading, so if
379395 * this happens then just use the pport
@@ -405,14 +421,14 @@ lpfc_work_done(struct lpfc_hba *phba) · 25 unmodified lines
405421 vport->work_port_events &= ~work_port_events;
406422 spin_unlock_irq(&vport->work_port_lock);
407423 }
408− lpfc_destroy_vport_work_array(vports);
424+ lpfc_destroy_vport_work_array(phba, vports);
409425
410426 pring = &phba->sli.ring[LPFC_ELS_RING];
411427 status = (ha_copy & (HA_RXMASK << (4*LPFC_ELS_RING)));
412428 status >>= (4*LPFC_ELS_RING);
413429 if ((status & HA_RXMASK)
414430 || (pring->flag & LPFC_DEFERRED_RING_EVENT)) {
415− if (pring->flag & LPFC_STOP_IOCB_MASK) {
431+ if (pring->flag & LPFC_STOP_IOCB_EVENT) {
416432 pring->flag |= LPFC_DEFERRED_RING_EVENT;
417433 } else {
418434 lpfc_sli_handle_slow_ring_event(phba, pring,
@@ -544,6 +560,7 @@ lpfc_workq_post_event(struct lpfc_hba *phba, void *arg1, void *arg2, · 125 unmodified lines
544560 void
545561 lpfc_cleanup_rpis(struct lpfc_vport *vport, int remove)
546562 {
563+ struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
547564 struct lpfc_hba *phba = vport->phba;
548565 struct lpfc_nodelist *ndlp, *next_ndlp;
549566 int rc;
@@ -552,7 +569,9 @@ lpfc_cleanup_rpis(struct lpfc_vport *vport, int remove) · 2 unmodified lines
552569 if (ndlp->nlp_state == NLP_STE_UNUSED_NODE)
553570 continue;
554571
555− if (phba->sli3_options & LPFC_SLI3_VPORT_TEARDOWN)
572+ if ((phba->sli3_options & LPFC_SLI3_VPORT_TEARDOWN) ||
573+ ((vport->port_type == LPFC_NPIV_PORT) &&
574+ (ndlp->nlp_DID == NameServer_DID)))
556575 lpfc_unreg_rpi(vport, ndlp);
557576
558577 /* Leave Fabric nodes alone on link down */
@@ -565,14 +584,30 @@ lpfc_cleanup_rpis(struct lpfc_vport *vport, int remove) · 6 unmodified lines
565584 }
566585 if (phba->sli3_options & LPFC_SLI3_VPORT_TEARDOWN) {
567586 lpfc_mbx_unreg_vpi(vport);
587+ spin_lock_irq(shost->host_lock);
568588 vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI;
589+ spin_unlock_irq(shost->host_lock);
569590 }
570591 }
571592
593+void
594+lpfc_port_link_failure(struct lpfc_vport *vport)
595+{
596+ /* Cleanup any outstanding RSCN activity */
597+ lpfc_els_flush_rscn(vport);
598+
599+ /* Cleanup any outstanding ELS commands */
600+ lpfc_els_flush_cmd(vport);
601+
602+ lpfc_cleanup_rpis(vport, 0);
603+
604+ /* Turn off discovery timer if its running */
605+ lpfc_can_disctmo(vport);
606+}
607+
572608 static void
573609 lpfc_linkdown_port(struct lpfc_vport *vport)
574610 {
575− struct lpfc_nodelist *ndlp, *next_ndlp;
576611 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
577612
578613 fc_host_post_event(shost, fc_get_event_number(), FCH_EVT_LINKDOWN, 0);
@@ -581,21 +616,8 @@ lpfc_linkdown_port(struct lpfc_vport *vport) · 2 unmodified lines
581616 "Link Down: state:x%x rtry:x%x flg:x%x",
582617 vport->port_state, vport->fc_ns_retry, vport->fc_flag);
583618
584− /* Cleanup any outstanding RSCN activity */
585− lpfc_els_flush_rscn(vport);
586−
587− /* Cleanup any outstanding ELS commands */
588− lpfc_els_flush_cmd(vport);
619+ lpfc_port_link_failure(vport);
589620
590− lpfc_cleanup_rpis(vport, 0);
591−
592− /* free any ndlp's on unused list */
593− list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp)
594− if (ndlp->nlp_state == NLP_STE_UNUSED_NODE)
595− lpfc_drop_node(vport, ndlp);
596−
597− /* Turn off discovery timer if its running */
598− lpfc_can_disctmo(vport);
599621 }
600622
601623 int
@@ -618,18 +640,18 @@ lpfc_linkdown(struct lpfc_hba *phba) · 16 unmodified lines
618640 spin_unlock_irq(&phba->hbalock);
619641 vports = lpfc_create_vport_work_array(phba);
620642 if (vports != NULL)
621− for(i = 0; i < LPFC_MAX_VPORTS && vports[i] != NULL; i++) {
643+ for(i = 0; i <= phba->max_vpi && vports[i] != NULL; i++) {
622644 /* Issue a LINK DOWN event to all nodes */
623645 lpfc_linkdown_port(vports[i]);
624646 }
625− lpfc_destroy_vport_work_array(vports);
647+ lpfc_destroy_vport_work_array(phba, vports);
626648 /* Clean up any firmware default rpi's */
627649 mb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
628650 if (mb) {
629651 lpfc_unreg_did(phba, 0xffff, 0xffffffff, mb);
630652 mb->vport = vport;
631653 mb->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
632− if (lpfc_sli_issue_mbox(phba, mb, (MBX_NOWAIT | MBX_STOP_IOCB))
654+ if (lpfc_sli_issue_mbox(phba, mb, MBX_NOWAIT)
633655 == MBX_NOT_FINISHED) {
634656 mempool_free(mb, phba->mbox_mem_pool);
635657 }
@@ -643,8 +665,7 @@ lpfc_linkdown(struct lpfc_hba *phba) · 7 unmodified lines
643665 lpfc_config_link(phba, mb);
644666 mb->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
645667 mb->vport = vport;
646− if (lpfc_sli_issue_mbox(phba, mb,
647− (MBX_NOWAIT | MBX_STOP_IOCB))
668+ if (lpfc_sli_issue_mbox(phba, mb, MBX_NOWAIT)
648669 == MBX_NOT_FINISHED) {
649670 mempool_free(mb, phba->mbox_mem_pool);
650671 }
@@ -686,7 +707,6 @@ static void · 35 unmodified lines
686707 lpfc_linkup_port(struct lpfc_vport *vport)
687708 {
688709 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
689− struct lpfc_nodelist *ndlp, *next_ndlp;
690710 struct lpfc_hba *phba = vport->phba;
691711
692712 if ((vport->load_flag & FC_UNLOADING) != 0)
@@ -713,11 +733,6 @@ lpfc_linkup_port(struct lpfc_vport *vport) · 20 unmodified lines
713733 if (vport->fc_flag & FC_LBIT)
714734 lpfc_linkup_cleanup_nodes(vport);
715735
716− /* free any ndlp's in unused state */
717− list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes,
718− nlp_listp)
719− if (ndlp->nlp_state == NLP_STE_UNUSED_NODE)
720− lpfc_drop_node(vport, ndlp);
721736 }
722737
723738 static int
@@ -734,9 +749,9 @@ lpfc_linkup(struct lpfc_hba *phba) · 10 unmodified lines
734749
735750 vports = lpfc_create_vport_work_array(phba);
736751 if (vports != NULL)
737− for(i = 0; i < LPFC_MAX_VPORTS && vports[i] != NULL; i++)
752+ for(i = 0; i <= phba->max_vpi && vports[i] != NULL; i++)
738753 lpfc_linkup_port(vports[i]);
739− lpfc_destroy_vport_work_array(vports);
754+ lpfc_destroy_vport_work_array(phba, vports);
740755 if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED)
741756 lpfc_issue_clear_la(phba, phba->pport);
742757
@@ -749,7 +764,7 @@ lpfc_linkup(struct lpfc_hba *phba) · 6 unmodified lines
749764 * as the completion routine when the command is
750765 * handed off to the SLI layer.
751766 */
752−void
767+static void
753768 lpfc_mbx_cmpl_clear_la(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
754769 {
755770 struct lpfc_vport *vport = pmb->vport;
@@ -852,8 +867,6 @@ lpfc_mbx_cmpl_local_config_link(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 96 unmodified lines
852867 * LPFC_FLOGI while waiting for FLOGI cmpl
853868 */
854869 if (vport->port_state != LPFC_FLOGI) {
855− vport->port_state = LPFC_FLOGI;
856− lpfc_set_disctmo(vport);
857870 lpfc_initial_flogi(vport);
858871 }
859872 return;
@@ -1022,8 +1035,7 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, READ_LA_VAR *la) · 162 unmodified lines
10221035 lpfc_read_sparam(phba, sparam_mbox, 0);
10231036 sparam_mbox->vport = vport;
10241037 sparam_mbox->mbox_cmpl = lpfc_mbx_cmpl_read_sparam;
1025− rc = lpfc_sli_issue_mbox(phba, sparam_mbox,
1026− (MBX_NOWAIT | MBX_STOP_IOCB));
1038+ rc = lpfc_sli_issue_mbox(phba, sparam_mbox, MBX_NOWAIT);
10271039 if (rc == MBX_NOT_FINISHED) {
10281040 mp = (struct lpfc_dmabuf *) sparam_mbox->context1;
10291041 lpfc_mbuf_free(phba, mp->virt, mp->phys);
@@ -1040,8 +1052,7 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, READ_LA_VAR *la) · 10 unmodified lines
10401052 lpfc_config_link(phba, cfglink_mbox);
10411053 cfglink_mbox->vport = vport;
10421054 cfglink_mbox->mbox_cmpl = lpfc_mbx_cmpl_local_config_link;
1043− rc = lpfc_sli_issue_mbox(phba, cfglink_mbox,
1044− (MBX_NOWAIT | MBX_STOP_IOCB));
1055+ rc = lpfc_sli_issue_mbox(phba, cfglink_mbox, MBX_NOWAIT);
10451056 if (rc != MBX_NOT_FINISHED)
10461057 return;
10471058 mempool_free(cfglink_mbox, phba->mbox_mem_pool);
@@ -1174,6 +1185,9 @@ lpfc_mbx_cmpl_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 126 unmodified lines
11741185 lpfc_mbuf_free(phba, mp->virt, mp->phys);
11751186 kfree(mp);
11761187 mempool_free(pmb, phba->mbox_mem_pool);
1188+ /* decrement the node reference count held for this callback
1189+ * function.
1190+ */
11771191 lpfc_nlp_put(ndlp);
11781192
11791193 return;
@@ -1219,7 +1233,7 @@ lpfc_mbx_unreg_vpi(struct lpfc_vport *vport) · 39 unmodified lines
12191233 lpfc_unreg_vpi(phba, vport->vpi, mbox);
12201234 mbox->vport = vport;
12211235 mbox->mbox_cmpl = lpfc_mbx_cmpl_unreg_vpi;
1222− rc = lpfc_sli_issue_mbox(phba, mbox, (MBX_NOWAIT | MBX_STOP_IOCB));
1236+ rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT);
12231237 if (rc == MBX_NOT_FINISHED) {
12241238 lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX | LOG_VPORT,
12251239 "1800 Could not issue unreg_vpi\n");
@@ -1319,7 +1333,7 @@ lpfc_mbx_cmpl_fabric_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 93 unmodified lines
13191333 vports = lpfc_create_vport_work_array(phba);
13201334 if (vports != NULL)
13211335 for(i = 0;
1322− i < LPFC_MAX_VPORTS && vports[i] != NULL;
1336+ i <= phba->max_vpi && vports[i] != NULL;
13231337 i++) {
13241338 if (vports[i]->port_type == LPFC_PHYSICAL_PORT)
13251339 continue;
@@ -1335,7 +1349,7 @@ lpfc_mbx_cmpl_fabric_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 9 unmodified lines
13351349 "Fabric support\n");
13361350 }
13371351 }
1338− lpfc_destroy_vport_work_array(vports);
1352+ lpfc_destroy_vport_work_array(phba, vports);
13391353 lpfc_do_scr_ns_plogi(phba, vport);
13401354 }
13411355
@@ -1361,11 +1375,16 @@ lpfc_mbx_cmpl_ns_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 19 unmodified lines
13611375
13621376 if (mb->mbxStatus) {
13631377 out:
1378+ /* decrement the node reference count held for this
1379+ * callback function.
1380+ */
13641381 lpfc_nlp_put(ndlp);
13651382 lpfc_mbuf_free(phba, mp->virt, mp->phys);
13661383 kfree(mp);
13671384 mempool_free(pmb, phba->mbox_mem_pool);
1368− lpfc_drop_node(vport, ndlp);
1385+
1386+ /* If no other thread is using the ndlp, free it */
1387+ lpfc_nlp_not_used(ndlp);
13691388
13701389 if (phba->fc_topology == TOPOLOGY_LOOP) {
13711390 /*
@@ -1410,6 +1429,9 @@ out: · 38 unmodified lines
14101429 goto out;
14111430 }
14121431
1432+ /* decrement the node reference count held for this
1433+ * callback function.
1434+ */
14131435 lpfc_nlp_put(ndlp);
14141436 lpfc_mbuf_free(phba, mp->virt, mp->phys);
14151437 kfree(mp);
@@ -1656,8 +1678,18 @@ lpfc_dequeue_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) · 240 unmodified lines
16561678 void
16571679 lpfc_drop_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
16581680 {
1681+ /*
1682+ * Use of lpfc_drop_node and UNUSED list: lpfc_drop_node should
1683+ * be used if we wish to issue the "last" lpfc_nlp_put() to remove
1684+ * the ndlp from the vport. The ndlp marked as UNUSED on the list
1685+ * until ALL other outstanding threads have completed. We check
1686+ * that the ndlp not already in the UNUSED state before we proceed.
1687+ */
1688+ if (ndlp->nlp_state == NLP_STE_UNUSED_NODE)
1689+ return;
16591690 lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNUSED_NODE);
16601691 lpfc_nlp_put(ndlp);
1692+ return;
16611693 }
16621694
16631695 /*
@@ -1868,8 +1900,7 @@ lpfc_unreg_rpi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) · 204 unmodified lines
18681900 lpfc_unreg_login(phba, vport->vpi, ndlp->nlp_rpi, mbox);
18691901 mbox->vport = vport;
18701902 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
1871− rc = lpfc_sli_issue_mbox(phba, mbox,
1872− (MBX_NOWAIT | MBX_STOP_IOCB));
1903+ rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT);
18731904 if (rc == MBX_NOT_FINISHED)
18741905 mempool_free(mbox, phba->mbox_mem_pool);
18751906 }
@@ -1892,8 +1923,8 @@ lpfc_unreg_all_rpis(struct lpfc_vport *vport) · 16 unmodified lines
18921923 lpfc_unreg_login(phba, vport->vpi, 0xffff, mbox);
18931924 mbox->vport = vport;
18941925 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
1895− rc = lpfc_sli_issue_mbox(phba, mbox,
1896− (MBX_NOWAIT | MBX_STOP_IOCB));
1926+ mbox->context1 = NULL;
1927+ rc = lpfc_sli_issue_mbox_wait(phba, mbox, LPFC_MBOX_TMO);
18971928 if (rc == MBX_NOT_FINISHED) {
18981929 mempool_free(mbox, phba->mbox_mem_pool);
18991930 }
@@ -1912,8 +1943,8 @@ lpfc_unreg_default_rpis(struct lpfc_vport *vport) · 12 unmodified lines
19121943 lpfc_unreg_did(phba, vport->vpi, 0xffffffff, mbox);
19131944 mbox->vport = vport;
19141945 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
1915− rc = lpfc_sli_issue_mbox(phba, mbox,
1916− (MBX_NOWAIT | MBX_STOP_IOCB));
1946+ mbox->context1 = NULL;
1947+ rc = lpfc_sli_issue_mbox_wait(phba, mbox, LPFC_MBOX_TMO);
19171948 if (rc == MBX_NOT_FINISHED) {
19181949 lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX | LOG_VPORT,
19191950 "1815 Could not issue "
@@ -1981,11 +2012,6 @@ lpfc_cleanup_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) · 61 unmodified lines
19812012 if (!list_empty(&ndlp->dev_loss_evt.evt_listp))
19822013 list_del_init(&ndlp->dev_loss_evt.evt_listp);
19832014
1984− if (!list_empty(&ndlp->dev_loss_evt.evt_listp)) {
1985− list_del_init(&ndlp->dev_loss_evt.evt_listp);
1986− complete((struct completion *)(ndlp->dev_loss_evt.evt_arg2));
1987− }
1988−
19892015 lpfc_unreg_rpi(vport, ndlp);
19902016
19912017 return 0;
@@ -1999,12 +2025,39 @@ lpfc_cleanup_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) · 7 unmodified lines
19992025 static void
20002026 lpfc_nlp_remove(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
20012027 {
2028+ struct lpfc_hba *phba = vport->phba;
20022029 struct lpfc_rport_data *rdata;
2030+ LPFC_MBOXQ_t *mbox;
2031+ int rc;
20032032
20042033 if (ndlp->nlp_flag & NLP_DELAY_TMO) {
20052034 lpfc_cancel_retry_delay_tmo(vport, ndlp);
20062035 }
20072036
2037+ if (ndlp->nlp_flag & NLP_DEFER_RM && !ndlp->nlp_rpi) {
2038+ /* For this case we need to cleanup the default rpi
2039+ * allocated by the firmware.
2040+ */
2041+ if ((mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL))
2042+ != NULL) {
2043+ rc = lpfc_reg_login(phba, vport->vpi, ndlp->nlp_DID,
2044+ (uint8_t *) &vport->fc_sparam, mbox, 0);
2045+ if (rc) {
2046+ mempool_free(mbox, phba->mbox_mem_pool);
2047+ }
2048+ else {
2049+ mbox->mbox_flag |= LPFC_MBX_IMED_UNREG;
2050+ mbox->mbox_cmpl = lpfc_mbx_cmpl_dflt_rpi;
2051+ mbox->vport = vport;
2052+ mbox->context2 = NULL;
2053+ rc =lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT);
2054+ if (rc == MBX_NOT_FINISHED) {
2055+ mempool_free(mbox, phba->mbox_mem_pool);
2056+ }
2057+ }
2058+ }
2059+ }
2060+
20082061 lpfc_cleanup_node(vport, ndlp);
20092062
20102063 /*
@@ -2132,6 +2185,12 @@ lpfc_setup_disc_node(struct lpfc_vport *vport, uint32_t did) · 121 unmodified lines
21322185 }
21332186 if (vport->fc_flag & FC_RSCN_MODE) {
21342187 if (lpfc_rscn_payload_check(vport, did)) {
2188+ /* If we've already recieved a PLOGI from this NPort
2189+ * we don't need to try to discover it again.
2190+ */
2191+ if (ndlp->nlp_flag & NLP_RCV_PLOGI)
2192+ return NULL;
2193+
21352194 spin_lock_irq(shost->host_lock);
21362195 ndlp->nlp_flag |= NLP_NPR_2B_DISC;
21372196 spin_unlock_irq(shost->host_lock);
@@ -2144,8 +2203,13 @@ lpfc_setup_disc_node(struct lpfc_vport *vport, uint32_t did) · 6 unmodified lines
21442203 } else
21452204 ndlp = NULL;
21462205 } else {
2206+ /* If we've already recieved a PLOGI from this NPort,
2207+ * or we are already in the process of discovery on it,
2208+ * we don't need to try to discover it again.
2209+ */
21472210 if (ndlp->nlp_state == NLP_STE_ADISC_ISSUE ||
2148− ndlp->nlp_state == NLP_STE_PLOGI_ISSUE)
2211+ ndlp->nlp_state == NLP_STE_PLOGI_ISSUE ||
2212+ ndlp->nlp_flag & NLP_RCV_PLOGI)
21492213 return NULL;
21502214 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
21512215 spin_lock_irq(shost->host_lock);
@@ -2220,8 +2284,7 @@ lpfc_issue_clear_la(struct lpfc_hba *phba, struct lpfc_vport *vport) · 68 unmodified lines
22202284 lpfc_clear_la(phba, mbox);
22212285 mbox->mbox_cmpl = lpfc_mbx_cmpl_clear_la;
22222286 mbox->vport = vport;
2223− rc = lpfc_sli_issue_mbox(phba, mbox, (MBX_NOWAIT |
2224− MBX_STOP_IOCB));
2287+ rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT);
22252288 if (rc == MBX_NOT_FINISHED) {
22262289 mempool_free(mbox, phba->mbox_mem_pool);
22272290 lpfc_disc_flush_list(vport);
@@ -2244,8 +2307,7 @@ lpfc_issue_reg_vpi(struct lpfc_hba *phba, struct lpfc_vport *vport) · 16 unmodified lines
22442307 lpfc_reg_vpi(phba, vport->vpi, vport->fc_myDID, regvpimbox);
22452308 regvpimbox->mbox_cmpl = lpfc_mbx_cmpl_reg_vpi;
22462309 regvpimbox->vport = vport;
2247− if (lpfc_sli_issue_mbox(phba, regvpimbox,
2248− (MBX_NOWAIT | MBX_STOP_IOCB))
2310+ if (lpfc_sli_issue_mbox(phba, regvpimbox, MBX_NOWAIT)
22492311 == MBX_NOT_FINISHED) {
22502312 mempool_free(regvpimbox, phba->mbox_mem_pool);
22512313 }
@@ -2414,7 +2476,7 @@ lpfc_free_tx(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp) · 162 unmodified lines
24142476 }
24152477 }
24162478
2417−void
2479+static void
24182480 lpfc_disc_flush_list(struct lpfc_vport *vport)
24192481 {
24202482 struct lpfc_nodelist *ndlp, *next_ndlp;
@@ -2426,7 +2488,6 @@ lpfc_disc_flush_list(struct lpfc_vport *vport) · 5 unmodified lines
24262488 if (ndlp->nlp_state == NLP_STE_PLOGI_ISSUE ||
24272489 ndlp->nlp_state == NLP_STE_ADISC_ISSUE) {
24282490 lpfc_free_tx(phba, ndlp);
2429− lpfc_nlp_put(ndlp);
24302491 }
24312492 }
24322493 }
@@ -2516,6 +2577,7 @@ lpfc_disc_timeout_handler(struct lpfc_vport *vport) · 83 unmodified lines
25162577 if (ndlp->nlp_type & NLP_FABRIC) {
25172578 /* Clean up the ndlp on Fabric connections */
25182579 lpfc_drop_node(vport, ndlp);
2580+
25192581 } else if (!(ndlp->nlp_flag & NLP_NPR_ADISC)) {
25202582 /* Fail outstanding IO now since device
25212583 * is marked for PLOGI.
@@ -2524,9 +2586,8 @@ lpfc_disc_timeout_handler(struct lpfc_vport *vport) · 2 unmodified lines
25242586 }
25252587 }
25262588 if (vport->port_state != LPFC_FLOGI) {
2527− vport->port_state = LPFC_FLOGI;
2528− lpfc_set_disctmo(vport);
25292589 lpfc_initial_flogi(vport);
2590+ return;
25302591 }
25312592 break;
25322593
@@ -2536,7 +2597,7 @@ lpfc_disc_timeout_handler(struct lpfc_vport *vport) · 3 unmodified lines
25362597 /* Initial FLOGI timeout */
25372598 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
25382599 "0222 Initial %s timeout\n",
2539− vport->vpi ? "FLOGI" : "FDISC");
2600+ vport->vpi ? "FDISC" : "FLOGI");
25402601
25412602 /* Assume no Fabric and go on with discovery.
25422603 * Check for outstanding ELS FLOGI to abort.
@@ -2558,10 +2619,10 @@ lpfc_disc_timeout_handler(struct lpfc_vport *vport) · 15 unmodified lines
25582619 /* Next look for NameServer ndlp */
25592620 ndlp = lpfc_findnode_did(vport, NameServer_DID);
25602621 if (ndlp)
2561− lpfc_nlp_put(ndlp);
2562− /* Start discovery */
2563− lpfc_disc_start(vport);
2564− break;
2622+ lpfc_els_abort(phba, ndlp);
2623+
2624+ /* ReStart discovery */
2625+ goto restart_disc;
25652626
25662627 case LPFC_NS_QRY:
25672628 /* Check for wait for NameServer Rsp timeout */
@@ -2580,6 +2641,7 @@ lpfc_disc_timeout_handler(struct lpfc_vport *vport) · 12 unmodified lines
25802641 }
25812642 vport->fc_ns_retry = 0;
25822643
2644+restart_disc:
25832645 /*
25842646 * Discovery is over.
25852647 * set port_state to PORT_READY if SLI2.
@@ -2608,8 +2670,7 @@ lpfc_disc_timeout_handler(struct lpfc_vport *vport) · 22 unmodified lines
26082670 initlinkmbox->mb.un.varInitLnk.lipsr_AL_PA = 0;
26092671 initlinkmbox->vport = vport;
26102672 initlinkmbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
2611− rc = lpfc_sli_issue_mbox(phba, initlinkmbox,
2612− (MBX_NOWAIT | MBX_STOP_IOCB));
2673+ rc = lpfc_sli_issue_mbox(phba, initlinkmbox, MBX_NOWAIT);
26132674 lpfc_set_loopback_flag(phba);
26142675 if (rc == MBX_NOT_FINISHED)
26152676 mempool_free(initlinkmbox, phba->mbox_mem_pool);
@@ -2664,12 +2725,14 @@ lpfc_disc_timeout_handler(struct lpfc_vport *vport) · 48 unmodified lines
26642725 clrlaerr = 1;
26652726 break;
26662727
2728+ case LPFC_LINK_UP:
2729+ lpfc_issue_clear_la(phba, vport);
2730+ /* Drop thru */
26672731 case LPFC_LINK_UNKNOWN:
26682732 case LPFC_WARM_START:
26692733 case LPFC_INIT_START:
26702734 case LPFC_INIT_MBX_CMDS:
26712735 case LPFC_LINK_DOWN:
2672− case LPFC_LINK_UP:
26732736 case LPFC_HBA_ERROR:
26742737 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
26752738 "0230 Unexpected timeout, hba link "
@@ -2723,7 +2786,9 @@ lpfc_mbx_cmpl_fdmi_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 47 unmodified lines
27232786 else
27242787 mod_timer(&vport->fc_fdmitmo, jiffies + HZ * 60);
27252788
2726− /* Mailbox took a reference to the node */
2789+ /* decrement the node reference count held for this callback
2790+ * function.
2791+ */
27272792 lpfc_nlp_put(ndlp);
27282793 lpfc_mbuf_free(phba, mp->virt, mp->phys);
27292794 kfree(mp);
@@ -2747,19 +2812,19 @@ lpfc_filter_by_wwpn(struct lpfc_nodelist *ndlp, void *param) · 17 unmodified lines
27472812 sizeof(ndlp->nlp_portname)) == 0;
27482813 }
27492814
2750−struct lpfc_nodelist *
2815+static struct lpfc_nodelist *
27512816 __lpfc_find_node(struct lpfc_vport *vport, node_filter filter, void *param)
27522817 {
27532818 struct lpfc_nodelist *ndlp;
27542819
27552820 list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) {
2756− if (ndlp->nlp_state != NLP_STE_UNUSED_NODE &&
2757− filter(ndlp, param))
2821+ if (filter(ndlp, param))
27582822 return ndlp;
27592823 }
27602824 return NULL;
27612825 }
27622826
2827+#if 0
27632828 /*
27642829 * Search node lists for a remote port matching filter criteria
27652830 * Caller needs to hold host_lock before calling this routine.
@@ -2775,6 +2840,7 @@ lpfc_find_node(struct lpfc_vport *vport, node_filter filter, void *param) · 9 unmodified lines
27752840 spin_unlock_irq(shost->host_lock);
27762841 return ndlp;
27772842 }
2843+#endif /* 0 */
27782844
27792845 /*
27802846 * This routine looks up the ndlp lists for the given RPI. If rpi found it
@@ -2786,6 +2852,7 @@ __lpfc_findnode_rpi(struct lpfc_vport *vport, uint16_t rpi) · 5 unmodified lines
27862852 return __lpfc_find_node(vport, lpfc_filter_by_rpi, &rpi);
27872853 }
27882854
2855+#if 0
27892856 struct lpfc_nodelist *
27902857 lpfc_findnode_rpi(struct lpfc_vport *vport, uint16_t rpi)
27912858 {
@@ -2797,6 +2864,7 @@ lpfc_findnode_rpi(struct lpfc_vport *vport, uint16_t rpi) · 5 unmodified lines
27972864 spin_unlock_irq(shost->host_lock);
27982865 return ndlp;
27992866 }
2867+#endif /* 0 */
28002868
28012869 /*
28022870 * This routine looks up the ndlp lists for the given WWPN. If WWPN found it
@@ -2837,6 +2905,9 @@ lpfc_nlp_init(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 34 unmodified lines
28372905 return;
28382906 }
28392907
2908+/* This routine releases all resources associated with a specifc NPort's ndlp
2909+ * and mempool_free's the nodelist.
2910+ */
28402911 static void
28412912 lpfc_nlp_release(struct kref *kref)
28422913 {
@@ -2851,16 +2922,57 @@ lpfc_nlp_release(struct kref *kref) · 8 unmodified lines
28512922 mempool_free(ndlp, ndlp->vport->phba->nlp_mem_pool);
28522923 }
28532924
2925+/* This routine bumps the reference count for a ndlp structure to ensure
2926+ * that one discovery thread won't free a ndlp while another discovery thread
2927+ * is using it.
2928+ */
28542929 struct lpfc_nodelist *
28552930 lpfc_nlp_get(struct lpfc_nodelist *ndlp)
28562931 {
2857− if (ndlp)
2932+ if (ndlp) {
2933+ lpfc_debugfs_disc_trc(ndlp->vport, LPFC_DISC_TRC_NODE,
2934+ "node get: did:x%x flg:x%x refcnt:x%x",
2935+ ndlp->nlp_DID, ndlp->nlp_flag,
2936+ atomic_read(&ndlp->kref.refcount));
28582937 kref_get(&ndlp->kref);
2938+ }
28592939 return ndlp;
28602940 }
28612941
2942+
2943+/* This routine decrements the reference count for a ndlp structure. If the
2944+ * count goes to 0, this indicates the the associated nodelist should be freed.
2945+ */
28622946 int
28632947 lpfc_nlp_put(struct lpfc_nodelist *ndlp)
28642948 {
2949+ if (ndlp) {
2950+ lpfc_debugfs_disc_trc(ndlp->vport, LPFC_DISC_TRC_NODE,
2951+ "node put: did:x%x flg:x%x refcnt:x%x",
2952+ ndlp->nlp_DID, ndlp->nlp_flag,
2953+ atomic_read(&ndlp->kref.refcount));
2954+ }
28652955 return ndlp ? kref_put(&ndlp->kref, lpfc_nlp_release) : 0;
28662956 }
2957+
2958+/* This routine free's the specified nodelist if it is not in use
2959+ * by any other discovery thread. This routine returns 1 if the ndlp
2960+ * is not being used by anyone and has been freed. A return value of
2961+ * 0 indicates it is being used by another discovery thread and the
2962+ * refcount is left unchanged.
2963+ */
2964+int
2965+lpfc_nlp_not_used(struct lpfc_nodelist *ndlp)
2966+{
2967+ lpfc_debugfs_disc_trc(ndlp->vport, LPFC_DISC_TRC_NODE,
2968+ "node not used: did:x%x flg:x%x refcnt:x%x",
2969+ ndlp->nlp_DID, ndlp->nlp_flag,
2970+ atomic_read(&ndlp->kref.refcount));
2971+
2972+ if (atomic_read(&ndlp->kref.refcount) == 1) {
2973+ lpfc_nlp_put(ndlp);
2974+ return 1;
2975+ }
2976+ return 0;
2977+}
2978+
drivers/scsi/lpfc/lpfc_hw.h+99−13
@@ -139,6 +139,9 @@ struct lpfc_sli_ct_request { · 138 unmodified lines
139139 uint8_t len;
140140 uint8_t symbname[255];
141141 } rsnn;
142+ struct da_id { /* For DA_ID requests */
143+ uint32_t port_id;
144+ } da_id;
142145 struct rspn { /* For RSPN_ID requests */
143146 uint32_t PortId;
144147 uint8_t len;
@@ -150,11 +153,7 @@ struct lpfc_sli_ct_request { · 5 unmodified lines
150153 struct gff_acc {
151154 uint8_t fbits[128];
152155 } gff_acc;
153−#ifdef __BIG_ENDIAN_BITFIELD
154156 #define FCP_TYPE_FEATURE_OFFSET 7
155−#else /* __LITTLE_ENDIAN_BITFIELD */
156−#define FCP_TYPE_FEATURE_OFFSET 4
157−#endif
158157 struct rff {
159158 uint32_t PortId;
160159 uint8_t reserved[2];
@@ -177,6 +176,8 @@ struct lpfc_sli_ct_request { · 16 unmodified lines
177176 sizeof(struct rnn))
178177 #define RSNN_REQUEST_SZ (offsetof(struct lpfc_sli_ct_request, un) + \
179178 sizeof(struct rsnn))
179+#define DA_ID_REQUEST_SZ (offsetof(struct lpfc_sli_ct_request, un) + \
180+ sizeof(struct da_id))
180181 #define RSPN_REQUEST_SZ (offsetof(struct lpfc_sli_ct_request, un) + \
181182 sizeof(struct rspn))
182183
@@ -1228,7 +1229,8 @@ typedef struct { /* FireFly BIU registers */ · 1045 unmodified lines
12281229 #define HS_FFER3 0x20000000 /* Bit 29 */
12291230 #define HS_FFER2 0x40000000 /* Bit 30 */
12301231 #define HS_FFER1 0x80000000 /* Bit 31 */
1231−#define HS_FFERM 0xFF000000 /* Mask for error bits 31:24 */
1232+#define HS_CRIT_TEMP 0x00000100 /* Bit 8 */
1233+#define HS_FFERM 0xFF000100 /* Mask for error bits 31:24 and 8 */
12321234
12331235 /* Host Control Register */
12341236
@@ -1277,12 +1279,14 @@ typedef struct { /* FireFly BIU registers */ · 42 unmodified lines
12771279 #define MBX_DEL_LD_ENTRY 0x1D
12781280 #define MBX_RUN_PROGRAM 0x1E
12791281 #define MBX_SET_MASK 0x20
1280−#define MBX_SET_SLIM 0x21
1282+#define MBX_SET_VARIABLE 0x21
12811283 #define MBX_UNREG_D_ID 0x23
12821284 #define MBX_KILL_BOARD 0x24
12831285 #define MBX_CONFIG_FARP 0x25
12841286 #define MBX_BEACON 0x2A
12851287 #define MBX_HEARTBEAT 0x31
1288+#define MBX_WRITE_VPARMS 0x32
1289+#define MBX_ASYNCEVT_ENABLE 0x33
12861290
12871291 #define MBX_CONFIG_HBQ 0x7C
12881292 #define MBX_LOAD_AREA 0x81
@@ -1297,7 +1301,7 @@ typedef struct { /* FireFly BIU registers */ · 8 unmodified lines
12971301 #define MBX_REG_VNPID 0x96
12981302 #define MBX_UNREG_VNPID 0x97
12991303
1300−#define MBX_FLASH_WR_ULA 0x98
1304+#define MBX_WRITE_WWN 0x98
13011305 #define MBX_SET_DEBUG 0x99
13021306 #define MBX_LOAD_EXP_ROM 0x9C
13031307
@@ -1344,6 +1348,7 @@ typedef struct { /* FireFly BIU registers */ · 40 unmodified lines
13441348
13451349 /* SLI_2 IOCB Command Set */
13461350
1351+#define CMD_ASYNC_STATUS 0x7C
13471352 #define CMD_RCV_SEQUENCE64_CX 0x81
13481353 #define CMD_XMIT_SEQUENCE64_CR 0x82
13491354 #define CMD_XMIT_SEQUENCE64_CX 0x83
@@ -1368,6 +1373,7 @@ typedef struct { /* FireFly BIU registers */ · 18 unmodified lines
13681373 #define CMD_FCP_TRECEIVE64_CX 0xA1
13691374 #define CMD_FCP_TRSP64_CX 0xA3
13701375
1376+#define CMD_QUE_XRI64_CX 0xB3
13711377 #define CMD_IOCB_RCV_SEQ64_CX 0xB5
13721378 #define CMD_IOCB_RCV_ELS64_CX 0xB7
13731379 #define CMD_IOCB_RCV_CONT64_CX 0xBB
@@ -1406,6 +1412,8 @@ typedef struct { /* FireFly BIU registers */ · 32 unmodified lines
14061412 #define MBX_BUSY 0xffffff /* Attempted cmd to busy Mailbox */
14071413 #define MBX_TIMEOUT 0xfffffe /* time-out expired waiting for */
14081414
1415+#define TEMPERATURE_OFFSET 0xB0 /* Slim offset for critical temperature event */
1416+
14091417 /*
14101418 * Begin Structure Definitions for Mailbox Commands
14111419 */
@@ -2606,6 +2614,18 @@ typedef struct { · 1194 unmodified lines
26062614 uint32_t IPAddress;
26072615 } CONFIG_FARP_VAR;
26082616
2617+/* Structure for MB Command MBX_ASYNCEVT_ENABLE (0x33) */
2618+
2619+typedef struct {
2620+#ifdef __BIG_ENDIAN_BITFIELD
2621+ uint32_t rsvd:30;
2622+ uint32_t ring:2; /* Ring for ASYNC_EVENT iocb Bits 0-1*/
2623+#else /* __LITTLE_ENDIAN */
2624+ uint32_t ring:2; /* Ring for ASYNC_EVENT iocb Bits 0-1*/
2625+ uint32_t rsvd:30;
2626+#endif
2627+} ASYNCEVT_ENABLE_VAR;
2628+
26092629 /* Union of all Mailbox Command types */
26102630 #define MAILBOX_CMD_WSIZE 32
26112631 #define MAILBOX_CMD_SIZE (MAILBOX_CMD_WSIZE * sizeof(uint32_t))
@@ -2645,6 +2665,7 @@ typedef union { · 33 unmodified lines
26452665 CONFIG_PORT_VAR varCfgPort; /* cmd = 0x88 (CONFIG_PORT) */
26462666 REG_VPI_VAR varRegVpi; /* cmd = 0x96 (REG_VPI) */
26472667 UNREG_VPI_VAR varUnregVpi; /* cmd = 0x97 (UNREG_VPI) */
2668+ ASYNCEVT_ENABLE_VAR varCfgAsyncEvent; /*cmd = x33 (CONFIG_ASYNC) */
26482669 } MAILVARIANTS;
26492670
26502671 /*
@@ -2973,6 +2994,34 @@ typedef struct { · 322 unmodified lines
29732994 #endif
29742995 } RCV_ELS_REQ64;
29752996
2997+/* IOCB Command template for RCV_SEQ64 */
2998+struct rcv_seq64 {
2999+ struct ulp_bde64 elsReq;
3000+ uint32_t hbq_1;
3001+ uint32_t parmRo;
3002+#ifdef __BIG_ENDIAN_BITFIELD
3003+ uint32_t rctl:8;
3004+ uint32_t type:8;
3005+ uint32_t dfctl:8;
3006+ uint32_t ls:1;
3007+ uint32_t fs:1;
3008+ uint32_t rsvd2:3;
3009+ uint32_t si:1;
3010+ uint32_t bc:1;
3011+ uint32_t rsvd3:1;
3012+#else /* __LITTLE_ENDIAN_BITFIELD */
3013+ uint32_t rsvd3:1;
3014+ uint32_t bc:1;
3015+ uint32_t si:1;
3016+ uint32_t rsvd2:3;
3017+ uint32_t fs:1;
3018+ uint32_t ls:1;
3019+ uint32_t dfctl:8;
3020+ uint32_t type:8;
3021+ uint32_t rctl:8;
3022+#endif
3023+};
3024+
29763025 /* IOCB Command template for all 64 bit FCP Initiator commands */
29773026 typedef struct {
29783027 ULP_BDL bdl;
@@ -2987,6 +3036,21 @@ typedef struct { · 8 unmodified lines
29873036 uint32_t fcpt_Length; /* transfer ready for IWRITE */
29883037 } FCPT_FIELDS64;
29893038
3039+/* IOCB Command template for Async Status iocb commands */
3040+typedef struct {
3041+ uint32_t rsvd[4];
3042+ uint32_t param;
3043+#ifdef __BIG_ENDIAN_BITFIELD
3044+ uint16_t evt_code; /* High order bits word 5 */
3045+ uint16_t sub_ctxt_tag; /* Low order bits word 5 */
3046+#else /* __LITTLE_ENDIAN_BITFIELD */
3047+ uint16_t sub_ctxt_tag; /* High order bits word 5 */
3048+ uint16_t evt_code; /* Low order bits word 5 */
3049+#endif
3050+} ASYNCSTAT_FIELDS;
3051+#define ASYNC_TEMP_WARN 0x100
3052+#define ASYNC_TEMP_SAFE 0x101
3053+
29903054 /* IOCB Command template for CMD_IOCB_RCV_ELS64_CX (0xB7)
29913055 or CMD_IOCB_RCV_SEQ64_CX (0xB5) */
29923056
@@ -3004,7 +3068,26 @@ struct rcv_sli3 { · 11 unmodified lines
30043068 struct ulp_bde64 bde2;
30053069 };
30063070
3071+/* Structure used for a single HBQ entry */
3072+struct lpfc_hbq_entry {
3073+ struct ulp_bde64 bde;
3074+ uint32_t buffer_tag;
3075+};
30073076
3077+/* IOCB Command template for QUE_XRI64_CX (0xB3) command */
3078+typedef struct {
3079+ struct lpfc_hbq_entry buff;
3080+ uint32_t rsvd;
3081+ uint32_t rsvd1;
3082+} QUE_XRI64_CX_FIELDS;
3083+
3084+struct que_xri64cx_ext_fields {
3085+ uint32_t iotag64_low;
3086+ uint32_t iotag64_high;
3087+ uint32_t ebde_count;
3088+ uint32_t rsvd;
3089+ struct lpfc_hbq_entry buff[5];
3090+};
30083091
30093092 typedef struct _IOCB { /* IOCB structure */
30103093 union {
@@ -3028,6 +3111,9 @@ typedef struct _IOCB { /* IOCB structure */ · 17 unmodified lines
30283111 XMT_SEQ_FIELDS64 xseq64; /* XMIT / BCAST cmd */
30293112 FCPI_FIELDS64 fcpi64; /* FCP 64 bit Initiator template */
30303113 FCPT_FIELDS64 fcpt64; /* FCP 64 bit target template */
3114+ ASYNCSTAT_FIELDS asyncstat; /* async_status iocb */
3115+ QUE_XRI64_CX_FIELDS quexri64cx; /* que_xri64_cx fields */
3116+ struct rcv_seq64 rcvseq64; /* RCV_SEQ64 and RCV_CONT64 */
30313117
30323118 uint32_t ulpWord[IOCB_WORD_SZ - 2]; /* generic 6 'words' */
30333119 } un;
@@ -3085,6 +3171,10 @@ typedef struct _IOCB { /* IOCB structure */ · 51 unmodified lines
30853171
30863172 union {
30873173 struct rcv_sli3 rcvsli3; /* words 8 - 15 */
3174+
3175+ /* words 8-31 used for que_xri_cx iocb */
3176+ struct que_xri64cx_ext_fields que_xri64cx_ext_words;
3177+
30883178 uint32_t sli3Words[24]; /* 96 extra bytes for SLI-3 */
30893179 } unsli3;
30903180
@@ -3124,12 +3214,6 @@ typedef struct _IOCB { /* IOCB structure */ · 33 unmodified lines
31243214
31253215 } IOCB_t;
31263216
3127−/* Structure used for a single HBQ entry */
3128−struct lpfc_hbq_entry {
3129− struct ulp_bde64 bde;
3130− uint32_t buffer_tag;
3131−};
3132−
31333217
31343218 #define SLI1_SLIM_SIZE (4 * 1024)
31353219
@@ -3172,6 +3256,8 @@ lpfc_is_LC_HBA(unsigned short device) · 36 unmodified lines
31723256 (device == PCI_DEVICE_ID_BSMB) ||
31733257 (device == PCI_DEVICE_ID_ZMID) ||
31743258 (device == PCI_DEVICE_ID_ZSMB) ||
3259+ (device == PCI_DEVICE_ID_SAT_MID) ||
3260+ (device == PCI_DEVICE_ID_SAT_SMB) ||
31753261 (device == PCI_DEVICE_ID_RFLY))
31763262 return 1;
31773263 else
drivers/scsi/lpfc/lpfc_init.c+318−111
@@ -212,6 +212,18 @@ out_free_mbox: · 211 unmodified lines
212212 return 0;
213213 }
214214
215+/* Completion handler for config async event mailbox command. */
216+static void
217+lpfc_config_async_cmpl(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmboxq)
218+{
219+ if (pmboxq->mb.mbxStatus == MBX_SUCCESS)
220+ phba->temp_sensor_support = 1;
221+ else
222+ phba->temp_sensor_support = 0;
223+ mempool_free(pmboxq, phba->mbox_mem_pool);
224+ return;
225+}
226+
215227 /************************************************************************/
216228 /* */
217229 /* lpfc_config_port_post */
@@ -234,6 +246,15 @@ lpfc_config_port_post(struct lpfc_hba *phba) · 16 unmodified lines
234246 int i, j;
235247 int rc;
236248
249+ spin_lock_irq(&phba->hbalock);
250+ /*
251+ * If the Config port completed correctly the HBA is not
252+ * over heated any more.
253+ */
254+ if (phba->over_temp_state == HBA_OVER_TEMP)
255+ phba->over_temp_state = HBA_NORMAL_TEMP;
256+ spin_unlock_irq(&phba->hbalock);
257+
237258 pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
238259 if (!pmb) {
239260 phba->link_state = LPFC_HBA_ERROR;
@@ -343,7 +364,7 @@ lpfc_config_port_post(struct lpfc_hba *phba) · 103 unmodified lines
343364
344365 phba->link_state = LPFC_LINK_DOWN;
345366
346− /* Only process IOCBs on ring 0 till hba_state is READY */
367+ /* Only process IOCBs on ELS ring till hba_state is READY */
347368 if (psli->ring[psli->extra_ring].cmdringaddr)
348369 psli->ring[psli->extra_ring].flag |= LPFC_STOP_IOCB_EVENT;
349370 if (psli->ring[psli->fcp_ring].cmdringaddr)
@@ -409,7 +430,21 @@ lpfc_config_port_post(struct lpfc_hba *phba) · 59 unmodified lines
409430 return -EIO;
410431 }
411432 /* MBOX buffer will be freed in mbox compl */
433+ pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
434+ lpfc_config_async(phba, pmb, LPFC_ELS_RING);
435+ pmb->mbox_cmpl = lpfc_config_async_cmpl;
436+ pmb->vport = phba->pport;
437+ rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT);
412438
439+ if ((rc != MBX_BUSY) && (rc != MBX_SUCCESS)) {
440+ lpfc_printf_log(phba,
441+ KERN_ERR,
442+ LOG_INIT,
443+ "0456 Adapter failed to issue "
444+ "ASYNCEVT_ENABLE mbox status x%x \n.",
445+ rc);
446+ mempool_free(pmb, phba->mbox_mem_pool);
447+ }
413448 return (0);
414449 }
415450
@@ -449,6 +484,9 @@ lpfc_hba_down_post(struct lpfc_hba *phba) · 33 unmodified lines
449484 struct lpfc_sli *psli = &phba->sli;
450485 struct lpfc_sli_ring *pring;
451486 struct lpfc_dmabuf *mp, *next_mp;
487+ struct lpfc_iocbq *iocb;
488+ IOCB_t *cmd = NULL;
489+ LIST_HEAD(completions);
452490 int i;
453491
454492 if (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED)
@@ -464,16 +502,42 @@ lpfc_hba_down_post(struct lpfc_hba *phba) · 9 unmodified lines
464502 }
465503 }
466504
505+ spin_lock_irq(&phba->hbalock);
467506 for (i = 0; i < psli->num_rings; i++) {
468507 pring = &psli->ring[i];
508+
509+ /* At this point in time the HBA is either reset or DOA. Either
510+ * way, nothing should be on txcmplq as it will NEVER complete.
511+ */
512+ list_splice_init(&pring->txcmplq, &completions);
513+ pring->txcmplq_cnt = 0;
514+ spin_unlock_irq(&phba->hbalock);
515+
516+ while (!list_empty(&completions)) {
517+ iocb = list_get_first(&completions, struct lpfc_iocbq,
518+ list);
519+ cmd = &iocb->iocb;
520+ list_del_init(&iocb->list);
521+
522+ if (!iocb->iocb_cmpl)
523+ lpfc_sli_release_iocbq(phba, iocb);
524+ else {
525+ cmd->ulpStatus = IOSTAT_LOCAL_REJECT;
526+ cmd->un.ulpWord[4] = IOERR_SLI_ABORTED;
527+ (iocb->iocb_cmpl) (phba, iocb, iocb);
528+ }
529+ }
530+
469531 lpfc_sli_abort_iocb_ring(phba, pring);
532+ spin_lock_irq(&phba->hbalock);
470533 }
534+ spin_unlock_irq(&phba->hbalock);
471535
472536 return 0;
473537 }
474538
475539 /* HBA heart beat timeout handler */
476−void
540+static void
477541 lpfc_hb_timeout(unsigned long ptr)
478542 {
479543 struct lpfc_hba *phba;
@@ -512,8 +576,10 @@ void · 32 unmodified lines
512576 lpfc_hb_timeout_handler(struct lpfc_hba *phba)
513577 {
514578 LPFC_MBOXQ_t *pmboxq;
579+ struct lpfc_dmabuf *buf_ptr;
515580 int retval;
516581 struct lpfc_sli *psli = &phba->sli;
582+ LIST_HEAD(completions);
517583
518584 if ((phba->link_state == LPFC_HBA_ERROR) ||
519585 (phba->pport->load_flag & FC_UNLOADING) ||
@@ -540,49 +606,88 @@ lpfc_hb_timeout_handler(struct lpfc_hba *phba) · 20 unmodified lines
540606 }
541607 spin_unlock_irq(&phba->pport->work_port_lock);
542608
543− /* If there is no heart beat outstanding, issue a heartbeat command */
544− if (!phba->hb_outstanding) {
545− pmboxq = mempool_alloc(phba->mbox_mem_pool,GFP_KERNEL);
546− if (!pmboxq) {
547− mod_timer(&phba->hb_tmofunc,
548− jiffies + HZ * LPFC_HB_MBOX_INTERVAL);
549− return;
609+ if (phba->elsbuf_cnt &&
610+ (phba->elsbuf_cnt == phba->elsbuf_prev_cnt)) {
611+ spin_lock_irq(&phba->hbalock);
612+ list_splice_init(&phba->elsbuf, &completions);
613+ phba->elsbuf_cnt = 0;
614+ phba->elsbuf_prev_cnt = 0;
615+ spin_unlock_irq(&phba->hbalock);
616+
617+ while (!list_empty(&completions)) {
618+ list_remove_head(&completions, buf_ptr,
619+ struct lpfc_dmabuf, list);
620+ lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys);
621+ kfree(buf_ptr);
550622 }
623+ }
624+ phba->elsbuf_prev_cnt = phba->elsbuf_cnt;
551625
552− lpfc_heart_beat(phba, pmboxq);
553− pmboxq->mbox_cmpl = lpfc_hb_mbox_cmpl;
554− pmboxq->vport = phba->pport;
555− retval = lpfc_sli_issue_mbox(phba, pmboxq, MBX_NOWAIT);
626+ /* If there is no heart beat outstanding, issue a heartbeat command */
627+ if (phba->cfg_enable_hba_heartbeat) {
628+ if (!phba->hb_outstanding) {
629+ pmboxq = mempool_alloc(phba->mbox_mem_pool,GFP_KERNEL);
630+ if (!pmboxq) {
631+ mod_timer(&phba->hb_tmofunc,
632+ jiffies + HZ * LPFC_HB_MBOX_INTERVAL);
633+ return;
634+ }
556635
557− if (retval != MBX_BUSY && retval != MBX_SUCCESS) {
558− mempool_free(pmboxq, phba->mbox_mem_pool);
636+ lpfc_heart_beat(phba, pmboxq);
637+ pmboxq->mbox_cmpl = lpfc_hb_mbox_cmpl;
638+ pmboxq->vport = phba->pport;
639+ retval = lpfc_sli_issue_mbox(phba, pmboxq, MBX_NOWAIT);
640+
641+ if (retval != MBX_BUSY && retval != MBX_SUCCESS) {
642+ mempool_free(pmboxq, phba->mbox_mem_pool);
643+ mod_timer(&phba->hb_tmofunc,
644+ jiffies + HZ * LPFC_HB_MBOX_INTERVAL);
645+ return;
646+ }
559647 mod_timer(&phba->hb_tmofunc,
560− jiffies + HZ * LPFC_HB_MBOX_INTERVAL);
648+ jiffies + HZ * LPFC_HB_MBOX_TIMEOUT);
649+ phba->hb_outstanding = 1;
561650 return;
651+ } else {
652+ /*
653+ * If heart beat timeout called with hb_outstanding set
654+ * we need to take the HBA offline.
655+ */
656+ lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
657+ "0459 Adapter heartbeat failure, "
658+ "taking this port offline.\n");
659+
660+ spin_lock_irq(&phba->hbalock);
661+ psli->sli_flag &= ~LPFC_SLI2_ACTIVE;
662+ spin_unlock_irq(&phba->hbalock);
663+
664+ lpfc_offline_prep(phba);
665+ lpfc_offline(phba);
666+ lpfc_unblock_mgmt_io(phba);
667+ phba->link_state = LPFC_HBA_ERROR;
668+ lpfc_hba_down_post(phba);
562669 }
563− mod_timer(&phba->hb_tmofunc,
564− jiffies + HZ * LPFC_HB_MBOX_TIMEOUT);
565− phba->hb_outstanding = 1;
566− return;
567− } else {
568− /*
569− * If heart beat timeout called with hb_outstanding set we
570− * need to take the HBA offline.
571− */
572− lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
573− "0459 Adapter heartbeat failure, taking "
574− "this port offline.\n");
670+ }
671+}
575672
576− spin_lock_irq(&phba->hbalock);
577− psli->sli_flag &= ~LPFC_SLI2_ACTIVE;
578− spin_unlock_irq(&phba->hbalock);
673+static void
674+lpfc_offline_eratt(struct lpfc_hba *phba)
675+{
676+ struct lpfc_sli *psli = &phba->sli;
579677
580− lpfc_offline_prep(phba);
581− lpfc_offline(phba);
582− lpfc_unblock_mgmt_io(phba);
583− phba->link_state = LPFC_HBA_ERROR;
584− lpfc_hba_down_post(phba);
585− }
678+ spin_lock_irq(&phba->hbalock);
679+ psli->sli_flag &= ~LPFC_SLI2_ACTIVE;
680+ spin_unlock_irq(&phba->hbalock);
681+ lpfc_offline_prep(phba);
682+
683+ lpfc_offline(phba);
684+ lpfc_reset_barrier(phba);
685+ lpfc_sli_brdreset(phba);
686+ lpfc_hba_down_post(phba);
687+ lpfc_sli_brdready(phba, HS_MBRDY);
688+ lpfc_unblock_mgmt_io(phba);
689+ phba->link_state = LPFC_HBA_ERROR;
690+ return;
586691 }
587692
588693 /************************************************************************/
@@ -601,6 +706,8 @@ lpfc_handle_eratt(struct lpfc_hba *phba) · 12 unmodified lines
601706 struct lpfc_sli_ring *pring;
602707 struct lpfc_vport **vports;
603708 uint32_t event_data;
709+ unsigned long temperature;
710+ struct temp_event temp_event_data;
604711 struct Scsi_Host *shost;
605712 int i;
606713
@@ -608,6 +715,9 @@ lpfc_handle_eratt(struct lpfc_hba *phba) · 1 unmodified line
608715 * since we cannot communicate with the pci card anyway. */
609716 if (pci_channel_offline(phba->pcidev))
610717 return;
718+ /* If resets are disabled then leave the HBA alone and return */
719+ if (!phba->cfg_enable_hba_reset)
720+ return;
611721
612722 if (phba->work_hs & HS_FFER6 ||
613723 phba->work_hs & HS_FFER5) {
@@ -620,14 +730,14 @@ lpfc_handle_eratt(struct lpfc_hba *phba) · 6 unmodified lines
620730 vports = lpfc_create_vport_work_array(phba);
621731 if (vports != NULL)
622732 for(i = 0;
623− i < LPFC_MAX_VPORTS && vports[i] != NULL;
733+ i <= phba->max_vpi && vports[i] != NULL;
624734 i++){
625735 shost = lpfc_shost_from_vport(vports[i]);
626736 spin_lock_irq(shost->host_lock);
627737 vports[i]->fc_flag |= FC_ESTABLISH_LINK;
628738 spin_unlock_irq(shost->host_lock);
629739 }
630− lpfc_destroy_vport_work_array(vports);
740+ lpfc_destroy_vport_work_array(phba, vports);
631741 spin_lock_irq(&phba->hbalock);
632742 psli->sli_flag &= ~LPFC_SLI2_ACTIVE;
633743 spin_unlock_irq(&phba->hbalock);
@@ -655,6 +765,31 @@ lpfc_handle_eratt(struct lpfc_hba *phba) · 21 unmodified lines
655765 return;
656766 }
657767 lpfc_unblock_mgmt_io(phba);
768+ } else if (phba->work_hs & HS_CRIT_TEMP) {
769+ temperature = readl(phba->MBslimaddr + TEMPERATURE_OFFSET);
770+ temp_event_data.event_type = FC_REG_TEMPERATURE_EVENT;
771+ temp_event_data.event_code = LPFC_CRIT_TEMP;
772+ temp_event_data.data = (uint32_t)temperature;
773+
774+ lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
775+ "0459 Adapter maximum temperature exceeded "
776+ "(%ld), taking this port offline "
777+ "Data: x%x x%x x%x\n",
778+ temperature, phba->work_hs,
779+ phba->work_status[0], phba->work_status[1]);
780+
781+ shost = lpfc_shost_from_vport(phba->pport);
782+ fc_host_post_vendor_event(shost, fc_get_event_number(),
783+ sizeof(temp_event_data),
784+ (char *) &temp_event_data,
785+ SCSI_NL_VID_TYPE_PCI
786+ | PCI_VENDOR_ID_EMULEX);
787+
788+ spin_lock_irq(&phba->hbalock);
789+ phba->over_temp_state = HBA_OVER_TEMP;
790+ spin_unlock_irq(&phba->hbalock);
791+ lpfc_offline_eratt(phba);
792+
658793 } else {
659794 /* The if clause above forces this code path when the status
660795 * failure is a value other than FFER6. Do not call the offline
@@ -672,14 +807,7 @@ lpfc_handle_eratt(struct lpfc_hba *phba) · 11 unmodified lines
672807 sizeof(event_data), (char *) &event_data,
673808 SCSI_NL_VID_TYPE_PCI | PCI_VENDOR_ID_EMULEX);
674809
675− spin_lock_irq(&phba->hbalock);
676− psli->sli_flag &= ~LPFC_SLI2_ACTIVE;
677− spin_unlock_irq(&phba->hbalock);
678− lpfc_offline_prep(phba);
679− lpfc_offline(phba);
680− lpfc_unblock_mgmt_io(phba);
681− phba->link_state = LPFC_HBA_ERROR;
682− lpfc_hba_down_post(phba);
810+ lpfc_offline_eratt(phba);
683811 }
684812 }
685813
@@ -699,21 +827,25 @@ lpfc_handle_latt(struct lpfc_hba *phba) · 13 unmodified lines
699827 LPFC_MBOXQ_t *pmb;
700828 volatile uint32_t control;
701829 struct lpfc_dmabuf *mp;
702− int rc = -ENOMEM;
830+ int rc = 0;
703831
704832 pmb = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
705− if (!pmb)
833+ if (!pmb) {
834+ rc = 1;
706835 goto lpfc_handle_latt_err_exit;
836+ }
707837
708838 mp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL);
709− if (!mp)
839+ if (!mp) {
840+ rc = 2;
710841 goto lpfc_handle_latt_free_pmb;
842+ }
711843
712844 mp->virt = lpfc_mbuf_alloc(phba, 0, &mp->phys);
713− if (!mp->virt)

428 more lines aren’t shown here.

drivers/scsi/lpfc/lpfc_logmsg.h+1−0

This diff is large: its 8 lines aren’t shown here.

drivers/scsi/lpfc/lpfc_mbox.c+27−5

This diff is large: its 60 lines aren’t shown here.

drivers/scsi/lpfc/lpfc_mem.c+1−0

This diff is large: its 8 lines aren’t shown here.

drivers/scsi/lpfc/lpfc_nportdisc.c+132−28

This diff is large: its 319 lines aren’t shown here.

drivers/scsi/lpfc/lpfc_scsi.c+37−17

This diff is large: its 148 lines aren’t shown here.

drivers/scsi/lpfc/lpfc_scsi.h+1−0

This diff is large: its 8 lines aren’t shown here.

drivers/scsi/lpfc/lpfc_sli.c+358−176

This diff is large: its 897 lines aren’t shown here.

drivers/scsi/lpfc/lpfc_sli.h+5−7

This diff is large: its 58 lines aren’t shown here.

drivers/scsi/lpfc/lpfc_version.h+3−3

This diff is large: its 22 lines aren’t shown here.

drivers/scsi/lpfc/lpfc_vport.c+57−36

This diff is large: its 165 lines aren’t shown here.

drivers/scsi/lpfc/lpfc_vport.h+1−1

This diff is large: its 9 lines aren’t shown here.

drivers/scsi/megaraid.c+1−1

This diff is large: its 9 lines aren’t shown here.

drivers/scsi/megaraid/megaraid_mbox.c+3−3

This diff is large: its 27 lines aren’t shown here.

drivers/scsi/megaraid/megaraid_sas.c+448−124

This diff is large: its 825 lines aren’t shown here.

drivers/scsi/megaraid/megaraid_sas.h+12−6

This diff is large: its 66 lines aren’t shown here.

drivers/scsi/ncr53c8xx.c+2−1

This diff is large: its 10 lines aren’t shown here.

drivers/scsi/pcmcia/Kconfig+2−1

This diff is large: its 10 lines aren’t shown here.

drivers/scsi/pcmcia/nsp_cs.c+34−20

This diff is large: its 145 lines aren’t shown here.

drivers/scsi/ppa.c+5−7

This diff is large: its 24 lines aren’t shown here.

drivers/scsi/psi240i.c+0−689

This diff is large: its 690 lines aren’t shown here.

drivers/scsi/psi240i.h+0−315

This diff is large: its 316 lines aren’t shown here.

drivers/scsi/psi_chip.h+0−195

This diff is large: its 196 lines aren’t shown here.

drivers/scsi/qla1280.c+2−2

This diff is large: its 18 lines aren’t shown here.

drivers/scsi/qla2xxx/Makefile+1−1

This diff is large: its 6 lines aren’t shown here.

drivers/scsi/qla2xxx/qla_attr.c+35−19

This diff is large: its 111 lines aren’t shown here.

drivers/scsi/qla2xxx/qla_dbg.c+22−15

This diff is large: its 62 lines aren’t shown here.

drivers/scsi/qla2xxx/qla_dbg.h+19−0

This diff is large: its 26 lines aren’t shown here.

drivers/scsi/qla2xxx/qla_def.h+28−24

This diff is large: its 109 lines aren’t shown here.

drivers/scsi/qla2xxx/qla_dfs.c+175−0

This diff is large: its 176 lines aren’t shown here.

drivers/scsi/qla2xxx/qla_fw.h+24−6

This diff is large: its 53 lines aren’t shown here.

drivers/scsi/qla2xxx/qla_gbl.h+21−30

This diff is large: its 133 lines aren’t shown here.

drivers/scsi/qla2xxx/qla_init.c+70−27

This diff is large: its 184 lines aren’t shown here.

drivers/scsi/qla2xxx/qla_isr.c+54−66

This diff is large: its 207 lines aren’t shown here.

drivers/scsi/qla2xxx/qla_mbx.c+144−286

This diff is large: its 683 lines aren’t shown here.

drivers/scsi/qla2xxx/qla_mid.c+20−26

This diff is large: its 123 lines aren’t shown here.

drivers/scsi/qla2xxx/qla_os.c+29−51

This diff is large: its 215 lines aren’t shown here.

drivers/scsi/qla2xxx/qla_sup.c+12−6

This diff is large: its 61 lines aren’t shown here.

drivers/scsi/qla2xxx/qla_version.h+1−1

This diff is large: its 9 lines aren’t shown here.

drivers/scsi/qla4xxx/ql4_init.c+3−1

This diff is large: its 18 lines aren’t shown here.

drivers/scsi/qla4xxx/ql4_isr.c+4−7

This diff is large: its 38 lines aren’t shown here.

drivers/scsi/qla4xxx/ql4_os.c+2−5

This diff is large: its 28 lines aren’t shown here.

drivers/scsi/qlogicpti.c+8−23

This diff is large: its 63 lines aren’t shown here.

drivers/scsi/scsi.c+168−114

This diff is large: its 535 lines aren’t shown here.

drivers/scsi/scsi_debug.c+10−27

This diff is large: its 79 lines aren’t shown here.

drivers/scsi/scsi_devinfo.c+15−19

This diff is large: its 89 lines aren’t shown here.

drivers/scsi/scsi_error.c+64−67

This diff is large: its 465 lines aren’t shown here.

drivers/scsi/scsi_ioctl.c+17−9

This diff is large: its 54 lines aren’t shown here.

drivers/scsi/scsi_lib.c+72−45

This diff is large: its 290 lines aren’t shown here.

drivers/scsi/scsi_netlink.c+7−12

This diff is large: its 49 lines aren’t shown here.

drivers/scsi/scsi_proc.c+108−2

This diff is large: its 211 lines aren’t shown here.

drivers/scsi/scsi_scan.c+23−13

This diff is large: its 113 lines aren’t shown here.

drivers/scsi/scsi_sysfs.c+1−0

This diff is large: its 8 lines aren’t shown here.

drivers/scsi/scsi_tgt_if.c+1−1

This diff is large: its 9 lines aren’t shown here.

drivers/scsi/scsi_tgt_lib.c+13−17

This diff is large: its 75 lines aren’t shown here.

drivers/scsi/scsi_transport_fc.c+46−56

This diff is large: its 338 lines aren’t shown here.

drivers/scsi/scsi_transport_iscsi.c+185−145

This diff is large: its 622 lines aren’t shown here.

drivers/scsi/scsi_transport_sas.c+22−19

This diff is large: its 188 lines aren’t shown here.

drivers/scsi/scsi_transport_spi.c+176−82

This diff is large: its 406 lines aren’t shown here.

drivers/scsi/scsi_transport_srp.c+6−7

This diff is large: its 51 lines aren’t shown here.

drivers/scsi/scsicam.c+24−11

This diff is large: its 71 lines aren’t shown here.

drivers/scsi/sd.c+33−11

This diff is large: its 87 lines aren’t shown here.

drivers/scsi/seagate.c+0−1667

This diff is large: its 1668 lines aren’t shown here.

drivers/scsi/sg.c+16−8

This diff is large: its 67 lines aren’t shown here.

drivers/scsi/sgiwd93.c+1−0

This diff is large: its 8 lines aren’t shown here.

drivers/scsi/sr.c+24−11

This diff is large: its 65 lines aren’t shown here.

drivers/scsi/sr.h+4−0

This diff is large: its 18 lines aren’t shown here.

drivers/scsi/sr_ioctl.c+34−14

This diff is large: its 68 lines aren’t shown here.

drivers/scsi/st.c+4−5

This diff is large: its 37 lines aren’t shown here.

drivers/scsi/sun3_NCR5380.c+12−12

This diff is large: its 85 lines aren’t shown here.

drivers/scsi/sym53c416.c+1−15

This diff is large: its 29 lines aren’t shown here.

drivers/scsi/sym53c8xx_2/sym_glue.c+11−11

This diff is large: its 69 lines aren’t shown here.

drivers/scsi/tmscsim.c+3−3

This diff is large: its 27 lines aren’t shown here.

drivers/scsi/u14-34f.c+2−2

This diff is large: its 12 lines aren’t shown here.

drivers/scsi/ultrastor.c+11−4

This diff is large: its 29 lines aren’t shown here.

drivers/scsi/wd33c93.c+5−5

This diff is large: its 22 lines aren’t shown here.

drivers/scsi/wd7000.c+6−6

This diff is large: its 36 lines aren’t shown here.

drivers/usb/storage/freecom.c+6−8

This diff is large: its 45 lines aren’t shown here.

drivers/usb/storage/isd200.c+46−20

This diff is large: its 191 lines aren’t shown here.

drivers/usb/storage/protocol.c+53−73

This diff is large: its 153 lines aren’t shown here.

drivers/usb/storage/scsiglue.c+14−10

This diff is large: its 45 lines aren’t shown here.

drivers/usb/storage/sddr09.c+3−6

This diff is large: its 24 lines aren’t shown here.

drivers/usb/storage/shuttle_usbat.c+26−42

This diff is large: its 215 lines aren’t shown here.

drivers/usb/storage/transport.c+28−17

This diff is large: its 129 lines aren’t shown here.

drivers/usb/storage/transport.h+2−0

This diff is large: its 9 lines aren’t shown here.

fs/sysfs/file.c+9−2

This diff is large: its 25 lines aren’t shown here.

fs/sysfs/group.c+16−10

This diff is large: its 58 lines aren’t shown here.

include/linux/attribute_container.h+1−0

This diff is large: its 8 lines aren’t shown here.

include/linux/blkdev.h+1−0

This diff is large: its 8 lines aren’t shown here.

include/linux/sysfs.h+2−0

This diff is large: its 9 lines aren’t shown here.

include/scsi/iscsi_if.h+20−0

This diff is large: its 54 lines aren’t shown here.

include/scsi/iscsi_proto.h+13−1

This diff is large: its 41 lines aren’t shown here.

include/scsi/libiscsi.h+65−17

This diff is large: its 194 lines aren’t shown here.

include/scsi/libsas.h+14−14

This diff is large: its 96 lines aren’t shown here.

include/scsi/sas.h+6−7

This diff is large: its 20 lines aren’t shown here.

include/scsi/scsi_cmnd.h+1−1

This diff is large: its 9 lines aren’t shown here.

include/scsi/scsi_device.h+9−4

This diff is large: its 48 lines aren’t shown here.

include/scsi/scsi_transport_iscsi.h+7−3

This diff is large: its 45 lines aren’t shown here.

include/scsi/scsi_transport_sas.h+5−11

This diff is large: its 29 lines aren’t shown here.

include/scsi/sd.h+1−0

This diff is large: its 8 lines aren’t shown here.

kernel/params.c+1−1

This diff is large: its 9 lines aren’t shown here.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t