aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-07-13 20:41:21 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-07-13 20:41:21 -0400
commit03ce3ca4b02bfc1e6567a7851ae231ad3cc9418e (patch)
treebf953469c6cac6b0a5b7d3671a27473eace144e3
parentf8acc450e10dbe7996220bac5459ee9c14a82a6a (diff)
parent622f9a8e7b8043a5ea2c7d047d65ecad01fe0f97 (diff)
Merge tag 'scsi-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
Pull final round of SCSI updates from James Bottomley: "This is the remaining set of SCSI patches for the merge window. It's mostly driver updates (scsi_debug, qla2xxx, storvsc, mp3sas). There are also several bug fixes in fcoe, libfc, and megaraid_sas. We also have a couple of core changes to try to make device destruction more deterministic" * tag 'scsi-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: (46 commits) [SCSI] scsi constants: command, sense key + additional sense strings fcoe: Reduce number of sparse warnings fcoe: Stop fc_rport_priv structure leak libfcoe: Fix meaningless log statement libfc: Differentiate echange timer cancellation debug statements libfc: Remove extra space in fc_exch_timer_cancel definition fcoe: fix the link error status block sparse warnings fcoe: Fix smatch warning in fcoe_fdmi_info function libfc: Reject PLOGI from nodes with incompatible role [SCSI] enable destruction of blocked devices which fail LUN scanning [SCSI] Fix race between starved list and device removal [SCSI] megaraid_sas: fix a bug for 64 bit arches [SCSI] scsi_debug: reduce duplication between prot_verify_read and prot_verify_write [SCSI] scsi_debug: simplify offset calculation for dif_storep [SCSI] scsi_debug: invalidate protection info for unmapped region [SCSI] scsi_debug: fix NULL pointer dereference with parameters dif=0 dix=1 [SCSI] scsi_debug: fix incorrectly nested kmap_atomic() [SCSI] scsi_debug: fix invalid address passed to kunmap_atomic() [SCSI] mpt3sas: Bump driver version to v02.100.00.00 [SCSI] mpt3sas: when async scanning is enabled then while scanning, devices are removed but their transport layer entries are not removed ...
-rw-r--r--drivers/scsi/constants.c235
-rw-r--r--drivers/scsi/fcoe/fcoe.c26
-rw-r--r--drivers/scsi/fcoe/fcoe_ctlr.c4
-rw-r--r--drivers/scsi/fcoe/fcoe_sysfs.c24
-rw-r--r--drivers/scsi/fcoe/fcoe_transport.c28
-rw-r--r--drivers/scsi/libfc/fc_exch.c4
-rw-r--r--drivers/scsi/libfc/fc_rport.c27
-rw-r--r--drivers/scsi/megaraid/megaraid_sas_base.c10
-rw-r--r--drivers/scsi/megaraid/megaraid_sas_fp.c4
-rw-r--r--drivers/scsi/mpt3sas/Kconfig2
-rw-r--r--drivers/scsi/mpt3sas/mpi/mpi2.h12
-rw-r--r--drivers/scsi/mpt3sas/mpi/mpi2_cnfg.h15
-rw-r--r--drivers/scsi/mpt3sas/mpi/mpi2_init.h2
-rw-r--r--drivers/scsi/mpt3sas/mpi/mpi2_ioc.h10
-rw-r--r--drivers/scsi/mpt3sas/mpi/mpi2_raid.h10
-rw-r--r--drivers/scsi/mpt3sas/mpi/mpi2_sas.h2
-rw-r--r--drivers/scsi/mpt3sas/mpi/mpi2_tool.h10
-rw-r--r--drivers/scsi/mpt3sas/mpi/mpi2_type.h2
-rw-r--r--drivers/scsi/mpt3sas/mpt3sas_base.c22
-rw-r--r--drivers/scsi/mpt3sas/mpt3sas_base.h8
-rw-r--r--drivers/scsi/mpt3sas/mpt3sas_config.c2
-rw-r--r--drivers/scsi/mpt3sas/mpt3sas_ctl.c2
-rw-r--r--drivers/scsi/mpt3sas/mpt3sas_ctl.h2
-rw-r--r--drivers/scsi/mpt3sas/mpt3sas_debug.h2
-rw-r--r--drivers/scsi/mpt3sas/mpt3sas_scsih.c54
-rw-r--r--drivers/scsi/mpt3sas/mpt3sas_transport.c2
-rw-r--r--drivers/scsi/mpt3sas/mpt3sas_trigger_diag.c2
-rw-r--r--drivers/scsi/mpt3sas/mpt3sas_trigger_diag.h2
-rw-r--r--drivers/scsi/pm8001/pm8001_init.c7
-rw-r--r--drivers/scsi/qla2xxx/qla_attr.c5
-rw-r--r--drivers/scsi/qla2xxx/qla_bsg.c38
-rw-r--r--drivers/scsi/qla2xxx/qla_dbg.c12
-rw-r--r--drivers/scsi/qla2xxx/qla_def.h34
-rw-r--r--drivers/scsi/qla2xxx/qla_gbl.h2
-rw-r--r--drivers/scsi/qla2xxx/qla_gs.c86
-rw-r--r--drivers/scsi/qla2xxx/qla_init.c8
-rw-r--r--drivers/scsi/qla2xxx/qla_inline.h2
-rw-r--r--drivers/scsi/qla2xxx/qla_iocb.c6
-rw-r--r--drivers/scsi/qla2xxx/qla_isr.c1
-rw-r--r--drivers/scsi/qla2xxx/qla_mbx.c16
-rw-r--r--drivers/scsi/qla2xxx/qla_mr.c167
-rw-r--r--drivers/scsi/qla2xxx/qla_mr.h98
-rw-r--r--drivers/scsi/qla2xxx/qla_os.c10
-rw-r--r--drivers/scsi/scsi_debug.c174
-rw-r--r--drivers/scsi/scsi_lib.c27
-rw-r--r--drivers/scsi/storvsc_drv.c139
46 files changed, 828 insertions, 529 deletions
diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c
index 76e4c039f0d5..d35a5d6c8d7c 100644
--- a/drivers/scsi/constants.c
+++ b/drivers/scsi/constants.c
@@ -1,10 +1,10 @@
1/* 1/*
2 * ASCII values for a number of symbolic constants, printing functions, 2 * ASCII values for a number of symbolic constants, printing functions,
3 * etc. 3 * etc.
4 * Additions for SCSI 2 and Linux 2.2.x by D. Gilbert (990422) 4 * Additions for SCSI 2 and Linux 2.2.x by D. Gilbert (990422)
5 * Additions for SCSI 3+ (SPC-3 T10/1416-D Rev 07 3 May 2002) 5 * Additions for SCSI 3+ (SPC-3 T10/1416-D Rev 07 3 May 2002)
6 * by D. Gilbert and aeb (20020609) 6 * by D. Gilbert and aeb (20020609)
7 * Update to SPC-4 T10/1713-D Rev 20, 22 May 2009, D. Gilbert 20090624 7 * Updated to SPC-4 T10/1713-D Rev 36g, D. Gilbert 20130701
8 */ 8 */
9 9
10#include <linux/blkdev.h> 10#include <linux/blkdev.h>
@@ -21,12 +21,13 @@
21 21
22 22
23/* Commands with service actions that change the command name */ 23/* Commands with service actions that change the command name */
24#define MAINTENANCE_IN 0xa3
25#define MAINTENANCE_OUT 0xa4
26#define SERVICE_ACTION_IN_12 0xab 24#define SERVICE_ACTION_IN_12 0xab
27#define SERVICE_ACTION_OUT_12 0xa9 25#define SERVICE_ACTION_OUT_12 0xa9
26#define SERVICE_ACTION_BIDIRECTIONAL 0x9d
28#define SERVICE_ACTION_IN_16 0x9e 27#define SERVICE_ACTION_IN_16 0x9e
29#define SERVICE_ACTION_OUT_16 0x9f 28#define SERVICE_ACTION_OUT_16 0x9f
29#define THIRD_PARTY_COPY_OUT 0x83
30#define THIRD_PARTY_COPY_IN 0x84
30 31
31 32
32 33
@@ -36,11 +37,11 @@ static const char * cdb_byte0_names[] = {
36/* 04-07 */ "Format Unit/Medium", "Read Block Limits", NULL, 37/* 04-07 */ "Format Unit/Medium", "Read Block Limits", NULL,
37 "Reassign Blocks", 38 "Reassign Blocks",
38/* 08-0d */ "Read(6)", NULL, "Write(6)", "Seek(6)", NULL, NULL, 39/* 08-0d */ "Read(6)", NULL, "Write(6)", "Seek(6)", NULL, NULL,
39/* 0e-12 */ NULL, "Read Reverse", "Write Filemarks", "Space", "Inquiry", 40/* 0e-12 */ NULL, "Read Reverse", "Write Filemarks", "Space", "Inquiry",
40/* 13-16 */ "Verify(6)", "Recover Buffered Data", "Mode Select(6)", 41/* 13-16 */ "Verify(6)", "Recover Buffered Data", "Mode Select(6)",
41 "Reserve(6)", 42 "Reserve(6)",
42/* 17-1a */ "Release(6)", "Copy", "Erase", "Mode Sense(6)", 43/* 17-1a */ "Release(6)", "Copy", "Erase", "Mode Sense(6)",
43/* 1b-1d */ "Start/Stop Unit", "Receive Diagnostic", "Send Diagnostic", 44/* 1b-1d */ "Start/Stop Unit", "Receive Diagnostic", "Send Diagnostic",
44/* 1e-1f */ "Prevent/Allow Medium Removal", NULL, 45/* 1e-1f */ "Prevent/Allow Medium Removal", NULL,
45/* 20-22 */ NULL, NULL, NULL, 46/* 20-22 */ NULL, NULL, NULL,
46/* 23-28 */ "Read Format Capacities", "Set Window", 47/* 23-28 */ "Read Format Capacities", "Set Window",
@@ -48,16 +49,16 @@ static const char * cdb_byte0_names[] = {
48/* 29-2d */ "Read Generation", "Write(10)", "Seek(10)", "Erase(10)", 49/* 29-2d */ "Read Generation", "Write(10)", "Seek(10)", "Erase(10)",
49 "Read updated block", 50 "Read updated block",
50/* 2e-31 */ "Write Verify(10)", "Verify(10)", "Search High", "Search Equal", 51/* 2e-31 */ "Write Verify(10)", "Verify(10)", "Search High", "Search Equal",
51/* 32-34 */ "Search Low", "Set Limits", "Prefetch/Read Position", 52/* 32-34 */ "Search Low", "Set Limits", "Prefetch/Read Position",
52/* 35-37 */ "Synchronize Cache(10)", "Lock/Unlock Cache(10)", 53/* 35-37 */ "Synchronize Cache(10)", "Lock/Unlock Cache(10)",
53 "Read Defect Data(10)", 54 "Read Defect Data(10)",
54/* 38-3c */ "Medium Scan", "Compare", "Copy Verify", "Write Buffer", 55/* 38-3c */ "Medium Scan", "Compare", "Copy Verify", "Write Buffer",
55 "Read Buffer", 56 "Read Buffer",
56/* 3d-3f */ "Update Block", "Read Long(10)", "Write Long(10)", 57/* 3d-3f */ "Update Block", "Read Long(10)", "Write Long(10)",
57/* 40-41 */ "Change Definition", "Write Same(10)", 58/* 40-41 */ "Change Definition", "Write Same(10)",
58/* 42-48 */ "Unmap/Read sub-channel", "Read TOC/PMA/ATIP", 59/* 42-48 */ "Unmap/Read sub-channel", "Read TOC/PMA/ATIP",
59 "Read density support", "Play audio(10)", "Get configuration", 60 "Read density support", "Play audio(10)", "Get configuration",
60 "Play audio msf", "Play audio track/index", 61 "Play audio msf", "Sanitize/Play audio track/index",
61/* 49-4f */ "Play track relative(10)", "Get event status notification", 62/* 49-4f */ "Play track relative(10)", "Get event status notification",
62 "Pause/resume", "Log Select", "Log Sense", "Stop play/scan", 63 "Pause/resume", "Log Select", "Log Sense", "Stop play/scan",
63 NULL, 64 NULL,
@@ -72,17 +73,17 @@ static const char * cdb_byte0_names[] = {
72/* 70-77 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 73/* 70-77 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
73/* 78-7f */ NULL, NULL, NULL, NULL, NULL, NULL, "Extended CDB", 74/* 78-7f */ NULL, NULL, NULL, NULL, NULL, NULL, "Extended CDB",
74 "Variable length", 75 "Variable length",
75/* 80-84 */ "Xdwrite(16)", "Rebuild(16)", "Regenerate(16)", "Extended copy", 76/* 80-84 */ "Xdwrite(16)", "Rebuild(16)", "Regenerate(16)",
76 "Receive copy results", 77 "Third party copy out", "Third party copy in",
77/* 85-89 */ "ATA command pass through(16)", "Access control in", 78/* 85-89 */ "ATA command pass through(16)", "Access control in",
78 "Access control out", "Read(16)", "Memory Export Out(16)", 79 "Access control out", "Read(16)", "Compare and Write",
79/* 8a-8f */ "Write(16)", "ORWrite", "Read attributes", "Write attributes", 80/* 8a-8f */ "Write(16)", "ORWrite", "Read attributes", "Write attributes",
80 "Write and verify(16)", "Verify(16)", 81 "Write and verify(16)", "Verify(16)",
81/* 90-94 */ "Pre-fetch(16)", "Synchronize cache(16)", 82/* 90-94 */ "Pre-fetch(16)", "Synchronize cache(16)",
82 "Lock/unlock cache(16)", "Write same(16)", NULL, 83 "Lock/unlock cache(16)", "Write same(16)", NULL,
83/* 95-99 */ NULL, NULL, NULL, NULL, NULL, 84/* 95-99 */ NULL, NULL, NULL, NULL, NULL,
84/* 9a-9f */ NULL, NULL, NULL, NULL, "Service action in(16)", 85/* 9a-9f */ NULL, NULL, NULL, "Service action bidirectional",
85 "Service action out(16)", 86 "Service action in(16)", "Service action out(16)",
86/* a0-a5 */ "Report luns", "ATA command pass through(12)/Blank", 87/* a0-a5 */ "Report luns", "ATA command pass through(12)/Blank",
87 "Security protocol in", "Maintenance in", "Maintenance out", 88 "Security protocol in", "Maintenance in", "Maintenance out",
88 "Move medium/play audio(12)", 89 "Move medium/play audio(12)",
@@ -122,6 +123,7 @@ static const struct value_name_pair maint_out_arr[] = {
122 {0x6, "Set identifying information"}, 123 {0x6, "Set identifying information"},
123 {0xa, "Set target port groups"}, 124 {0xa, "Set target port groups"},
124 {0xb, "Change aliases"}, 125 {0xb, "Change aliases"},
126 {0xc, "Remove I_T nexus"},
125 {0xe, "Set priority"}, 127 {0xe, "Set priority"},
126 {0xf, "Set timestamp"}, 128 {0xf, "Set timestamp"},
127 {0x10, "Management protocol out"}, 129 {0x10, "Management protocol out"},
@@ -138,10 +140,16 @@ static const struct value_name_pair serv_out12_arr[] = {
138}; 140};
139#define SERV_OUT12_SZ ARRAY_SIZE(serv_out12_arr) 141#define SERV_OUT12_SZ ARRAY_SIZE(serv_out12_arr)
140 142
143static const struct value_name_pair serv_bidi_arr[] = {
144 {-1, "dummy entry"},
145};
146#define SERV_BIDI_SZ ARRAY_SIZE(serv_bidi_arr)
147
141static const struct value_name_pair serv_in16_arr[] = { 148static const struct value_name_pair serv_in16_arr[] = {
142 {0x10, "Read capacity(16)"}, 149 {0x10, "Read capacity(16)"},
143 {0x11, "Read long(16)"}, 150 {0x11, "Read long(16)"},
144 {0x12, "Get LBA status"}, 151 {0x12, "Get LBA status"},
152 {0x13, "Report referrals"},
145}; 153};
146#define SERV_IN16_SZ ARRAY_SIZE(serv_in16_arr) 154#define SERV_IN16_SZ ARRAY_SIZE(serv_in16_arr)
147 155
@@ -151,6 +159,51 @@ static const struct value_name_pair serv_out16_arr[] = {
151}; 159};
152#define SERV_OUT16_SZ ARRAY_SIZE(serv_out16_arr) 160#define SERV_OUT16_SZ ARRAY_SIZE(serv_out16_arr)
153 161
162static const struct value_name_pair pr_in_arr[] = {
163 {0x0, "Persistent reserve in, read keys"},
164 {0x1, "Persistent reserve in, read reservation"},
165 {0x2, "Persistent reserve in, report capabilities"},
166 {0x3, "Persistent reserve in, read full status"},
167};
168#define PR_IN_SZ ARRAY_SIZE(pr_in_arr)
169
170static const struct value_name_pair pr_out_arr[] = {
171 {0x0, "Persistent reserve out, register"},
172 {0x1, "Persistent reserve out, reserve"},
173 {0x2, "Persistent reserve out, release"},
174 {0x3, "Persistent reserve out, clear"},
175 {0x4, "Persistent reserve out, preempt"},
176 {0x5, "Persistent reserve out, preempt and abort"},
177 {0x6, "Persistent reserve out, register and ignore existing key"},
178 {0x7, "Persistent reserve out, register and move"},
179};
180#define PR_OUT_SZ ARRAY_SIZE(pr_out_arr)
181
182/* SPC-4 rev 34 renamed the Extended Copy opcode to Third Party Copy Out.
183 LID1 (List Identifier length: 1 byte) is the Extended Copy found in SPC-2
184 and SPC-3 */
185static const struct value_name_pair tpc_out_arr[] = {
186 {0x0, "Extended copy(LID1)"},
187 {0x1, "Extended copy(LID4)"},
188 {0x10, "Populate token"},
189 {0x11, "Write using token"},
190 {0x1c, "Copy operation abort"},
191};
192#define TPC_OUT_SZ ARRAY_SIZE(tpc_out_arr)
193
194static const struct value_name_pair tpc_in_arr[] = {
195 {0x0, "Receive copy status(LID1)"},
196 {0x1, "Receive copy data(LID1)"},
197 {0x3, "Receive copy operating parameters"},
198 {0x4, "Receive copy failure details(LID1)"},
199 {0x5, "Receive copy status(LID4)"},
200 {0x6, "Receive copy data(LID4)"},
201 {0x7, "Receive ROD token information"},
202 {0x8, "Report all ROD tokens"},
203};
204#define TPC_IN_SZ ARRAY_SIZE(tpc_in_arr)
205
206
154static const struct value_name_pair variable_length_arr[] = { 207static const struct value_name_pair variable_length_arr[] = {
155 {0x1, "Rebuild(32)"}, 208 {0x1, "Rebuild(32)"},
156 {0x2, "Regenerate(32)"}, 209 {0x2, "Regenerate(32)"},
@@ -207,6 +260,7 @@ static const char * get_sa_name(const struct value_name_pair * arr,
207static void print_opcode_name(unsigned char * cdbp, int cdb_len) 260static void print_opcode_name(unsigned char * cdbp, int cdb_len)
208{ 261{
209 int sa, len, cdb0; 262 int sa, len, cdb0;
263 int fin_name = 0;
210 const char * name; 264 const char * name;
211 265
212 cdb0 = cdbp[0]; 266 cdb0 = cdbp[0];
@@ -219,7 +273,8 @@ static void print_opcode_name(unsigned char * cdbp, int cdb_len)
219 break; 273 break;
220 } 274 }
221 sa = (cdbp[8] << 8) + cdbp[9]; 275 sa = (cdbp[8] << 8) + cdbp[9];
222 name = get_sa_name(variable_length_arr, VARIABLE_LENGTH_SZ, sa); 276 name = get_sa_name(variable_length_arr, VARIABLE_LENGTH_SZ,
277 sa);
223 if (name) 278 if (name)
224 printk("%s", name); 279 printk("%s", name);
225 else 280 else
@@ -232,50 +287,57 @@ static void print_opcode_name(unsigned char * cdbp, int cdb_len)
232 case MAINTENANCE_IN: 287 case MAINTENANCE_IN:
233 sa = cdbp[1] & 0x1f; 288 sa = cdbp[1] & 0x1f;
234 name = get_sa_name(maint_in_arr, MAINT_IN_SZ, sa); 289 name = get_sa_name(maint_in_arr, MAINT_IN_SZ, sa);
235 if (name) 290 fin_name = 1;
236 printk("%s", name);
237 else
238 printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa);
239 break; 291 break;
240 case MAINTENANCE_OUT: 292 case MAINTENANCE_OUT:
241 sa = cdbp[1] & 0x1f; 293 sa = cdbp[1] & 0x1f;
242 name = get_sa_name(maint_out_arr, MAINT_OUT_SZ, sa); 294 name = get_sa_name(maint_out_arr, MAINT_OUT_SZ, sa);
243 if (name) 295 fin_name = 1;
244 printk("%s", name); 296 break;
245 else 297 case PERSISTENT_RESERVE_IN:
246 printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa); 298 sa = cdbp[1] & 0x1f;
299 name = get_sa_name(pr_in_arr, PR_IN_SZ, sa);
300 fin_name = 1;
301 break;
302 case PERSISTENT_RESERVE_OUT:
303 sa = cdbp[1] & 0x1f;
304 name = get_sa_name(pr_out_arr, PR_OUT_SZ, sa);
305 fin_name = 1;
247 break; 306 break;
248 case SERVICE_ACTION_IN_12: 307 case SERVICE_ACTION_IN_12:
249 sa = cdbp[1] & 0x1f; 308 sa = cdbp[1] & 0x1f;
250 name = get_sa_name(serv_in12_arr, SERV_IN12_SZ, sa); 309 name = get_sa_name(serv_in12_arr, SERV_IN12_SZ, sa);
251 if (name) 310 fin_name = 1;
252 printk("%s", name);
253 else
254 printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa);
255 break; 311 break;
256 case SERVICE_ACTION_OUT_12: 312 case SERVICE_ACTION_OUT_12:
257 sa = cdbp[1] & 0x1f; 313 sa = cdbp[1] & 0x1f;
258 name = get_sa_name(serv_out12_arr, SERV_OUT12_SZ, sa); 314 name = get_sa_name(serv_out12_arr, SERV_OUT12_SZ, sa);
259 if (name) 315 fin_name = 1;
260 printk("%s", name); 316 break;
261 else 317 case SERVICE_ACTION_BIDIRECTIONAL:
262 printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa); 318 sa = cdbp[1] & 0x1f;
319 name = get_sa_name(serv_bidi_arr, SERV_BIDI_SZ, sa);
320 fin_name = 1;
263 break; 321 break;
264 case SERVICE_ACTION_IN_16: 322 case SERVICE_ACTION_IN_16:
265 sa = cdbp[1] & 0x1f; 323 sa = cdbp[1] & 0x1f;
266 name = get_sa_name(serv_in16_arr, SERV_IN16_SZ, sa); 324 name = get_sa_name(serv_in16_arr, SERV_IN16_SZ, sa);
267 if (name) 325 fin_name = 1;
268 printk("%s", name);
269 else
270 printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa);
271 break; 326 break;
272 case SERVICE_ACTION_OUT_16: 327 case SERVICE_ACTION_OUT_16:
273 sa = cdbp[1] & 0x1f; 328 sa = cdbp[1] & 0x1f;
274 name = get_sa_name(serv_out16_arr, SERV_OUT16_SZ, sa); 329 name = get_sa_name(serv_out16_arr, SERV_OUT16_SZ, sa);
275 if (name) 330 fin_name = 1;
276 printk("%s", name); 331 break;
277 else 332 case THIRD_PARTY_COPY_IN:
278 printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa); 333 sa = cdbp[1] & 0x1f;
334 name = get_sa_name(tpc_in_arr, TPC_IN_SZ, sa);
335 fin_name = 1;
336 break;
337 case THIRD_PARTY_COPY_OUT:
338 sa = cdbp[1] & 0x1f;
339 name = get_sa_name(tpc_out_arr, TPC_OUT_SZ, sa);
340 fin_name = 1;
279 break; 341 break;
280 default: 342 default:
281 if (cdb0 < 0xc0) { 343 if (cdb0 < 0xc0) {
@@ -288,6 +350,12 @@ static void print_opcode_name(unsigned char * cdbp, int cdb_len)
288 printk("cdb[0]=0x%x (vendor)", cdb0); 350 printk("cdb[0]=0x%x (vendor)", cdb0);
289 break; 351 break;
290 } 352 }
353 if (fin_name) {
354 if (name)
355 printk("%s", name);
356 else
357 printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa);
358 }
291} 359}
292 360
293#else /* ifndef CONFIG_SCSI_CONSTANTS */ 361#else /* ifndef CONFIG_SCSI_CONSTANTS */
@@ -312,10 +380,15 @@ static void print_opcode_name(unsigned char * cdbp, int cdb_len)
312 break; 380 break;
313 case MAINTENANCE_IN: 381 case MAINTENANCE_IN:
314 case MAINTENANCE_OUT: 382 case MAINTENANCE_OUT:
383 case PERSISTENT_RESERVE_IN:
384 case PERSISTENT_RESERVE_OUT:
315 case SERVICE_ACTION_IN_12: 385 case SERVICE_ACTION_IN_12:
316 case SERVICE_ACTION_OUT_12: 386 case SERVICE_ACTION_OUT_12:
387 case SERVICE_ACTION_BIDIRECTIONAL:
317 case SERVICE_ACTION_IN_16: 388 case SERVICE_ACTION_IN_16:
318 case SERVICE_ACTION_OUT_16: 389 case SERVICE_ACTION_OUT_16:
390 case THIRD_PARTY_COPY_IN:
391 case THIRD_PARTY_COPY_OUT:
319 sa = cdbp[1] & 0x1f; 392 sa = cdbp[1] & 0x1f;
320 printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa); 393 printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa);
321 break; 394 break;
@@ -327,7 +400,7 @@ static void print_opcode_name(unsigned char * cdbp, int cdb_len)
327 break; 400 break;
328 } 401 }
329} 402}
330#endif 403#endif
331 404
332void __scsi_print_command(unsigned char *cdb) 405void __scsi_print_command(unsigned char *cdb)
333{ 406{
@@ -336,7 +409,7 @@ void __scsi_print_command(unsigned char *cdb)
336 print_opcode_name(cdb, 0); 409 print_opcode_name(cdb, 0);
337 len = scsi_command_size(cdb); 410 len = scsi_command_size(cdb);
338 /* print out all bytes in cdb */ 411 /* print out all bytes in cdb */
339 for (k = 0; k < len; ++k) 412 for (k = 0; k < len; ++k)
340 printk(" %02x", cdb[k]); 413 printk(" %02x", cdb[k]);
341 printk("\n"); 414 printk("\n");
342} 415}
@@ -404,8 +477,9 @@ struct error_info {
404 477
405/* 478/*
406 * The canonical list of T10 Additional Sense Codes is available at: 479 * The canonical list of T10 Additional Sense Codes is available at:
407 * http://www.t10.org/lists/asc-num.txt 480 * http://www.t10.org/lists/asc-num.txt [most recent: 20130605]
408 */ 481 */
482
409static const struct error_info additional[] = 483static const struct error_info additional[] =
410{ 484{
411 {0x0000, "No additional sense information"}, 485 {0x0000, "No additional sense information"},
@@ -430,6 +504,8 @@ static const struct error_info additional[] =
430 {0x001C, "Verify operation in progress"}, 504 {0x001C, "Verify operation in progress"},
431 {0x001D, "ATA pass through information available"}, 505 {0x001D, "ATA pass through information available"},
432 {0x001E, "Conflicting SA creation request"}, 506 {0x001E, "Conflicting SA creation request"},
507 {0x001F, "Logical unit transitioning to another power condition"},
508 {0x0020, "Extended copy information available"},
433 509
434 {0x0100, "No index/sector signal"}, 510 {0x0100, "No index/sector signal"},
435 511
@@ -460,6 +536,17 @@ static const struct error_info additional[] =
460 {0x0412, "Logical unit not ready, offline"}, 536 {0x0412, "Logical unit not ready, offline"},
461 {0x0413, "Logical unit not ready, SA creation in progress"}, 537 {0x0413, "Logical unit not ready, SA creation in progress"},
462 {0x0414, "Logical unit not ready, space allocation in progress"}, 538 {0x0414, "Logical unit not ready, space allocation in progress"},
539 {0x0415, "Logical unit not ready, robotics disabled"},
540 {0x0416, "Logical unit not ready, configuration required"},
541 {0x0417, "Logical unit not ready, calibration required"},
542 {0x0418, "Logical unit not ready, a door is open"},
543 {0x0419, "Logical unit not ready, operating in sequential mode"},
544 {0x041A, "Logical unit not ready, start stop unit command in "
545 "progress"},
546 {0x041B, "Logical unit not ready, sanitize in progress"},
547 {0x041C, "Logical unit not ready, additional power use not yet "
548 "granted"},
549 {0x041D, "Logical unit not ready, configuration in progress"},
463 550
464 {0x0500, "Logical unit does not respond to selection"}, 551 {0x0500, "Logical unit does not respond to selection"},
465 552
@@ -490,6 +577,7 @@ static const struct error_info additional[] =
490 {0x0B06, "Warning - non-volatile cache now volatile"}, 577 {0x0B06, "Warning - non-volatile cache now volatile"},
491 {0x0B07, "Warning - degraded power to non-volatile cache"}, 578 {0x0B07, "Warning - degraded power to non-volatile cache"},
492 {0x0B08, "Warning - power loss expected"}, 579 {0x0B08, "Warning - power loss expected"},
580 {0x0B09, "Warning - device statistics notification active"},
493 581
494 {0x0C00, "Write error"}, 582 {0x0C00, "Write error"},
495 {0x0C01, "Write error - recovered with auto reallocation"}, 583 {0x0C01, "Write error - recovered with auto reallocation"},
@@ -505,6 +593,7 @@ static const struct error_info additional[] =
505 {0x0C0B, "Auxiliary memory write error"}, 593 {0x0C0B, "Auxiliary memory write error"},
506 {0x0C0C, "Write error - unexpected unsolicited data"}, 594 {0x0C0C, "Write error - unexpected unsolicited data"},
507 {0x0C0D, "Write error - not enough unsolicited data"}, 595 {0x0C0D, "Write error - not enough unsolicited data"},
596 {0x0C0E, "Multiple write errors"},
508 {0x0C0F, "Defects in error window"}, 597 {0x0C0F, "Defects in error window"},
509 598
510 {0x0D00, "Error detected by third party temporary initiator"}, 599 {0x0D00, "Error detected by third party temporary initiator"},
@@ -523,6 +612,8 @@ static const struct error_info additional[] =
523 {0x1001, "Logical block guard check failed"}, 612 {0x1001, "Logical block guard check failed"},
524 {0x1002, "Logical block application tag check failed"}, 613 {0x1002, "Logical block application tag check failed"},
525 {0x1003, "Logical block reference tag check failed"}, 614 {0x1003, "Logical block reference tag check failed"},
615 {0x1004, "Logical block protection error on recover buffered data"},
616 {0x1005, "Logical block protection method error"},
526 617
527 {0x1100, "Unrecovered read error"}, 618 {0x1100, "Unrecovered read error"},
528 {0x1101, "Read retries exhausted"}, 619 {0x1101, "Read retries exhausted"},
@@ -545,6 +636,7 @@ static const struct error_info additional[] =
545 {0x1112, "Auxiliary memory read error"}, 636 {0x1112, "Auxiliary memory read error"},
546 {0x1113, "Read error - failed retransmission request"}, 637 {0x1113, "Read error - failed retransmission request"},
547 {0x1114, "Read error - lba marked bad by application client"}, 638 {0x1114, "Read error - lba marked bad by application client"},
639 {0x1115, "Write after sanitize required"},
548 640
549 {0x1200, "Address mark not found for id field"}, 641 {0x1200, "Address mark not found for id field"},
550 642
@@ -622,6 +714,7 @@ static const struct error_info additional[] =
622 {0x2009, "Access denied - invalid LU identifier"}, 714 {0x2009, "Access denied - invalid LU identifier"},
623 {0x200A, "Access denied - invalid proxy token"}, 715 {0x200A, "Access denied - invalid proxy token"},
624 {0x200B, "Access denied - ACL LUN conflict"}, 716 {0x200B, "Access denied - ACL LUN conflict"},
717 {0x200C, "Illegal command when not in append-only mode"},
625 718
626 {0x2100, "Logical block address out of range"}, 719 {0x2100, "Logical block address out of range"},
627 {0x2101, "Invalid element address"}, 720 {0x2101, "Invalid element address"},
@@ -630,6 +723,19 @@ static const struct error_info additional[] =
630 723
631 {0x2200, "Illegal function (use 20 00, 24 00, or 26 00)"}, 724 {0x2200, "Illegal function (use 20 00, 24 00, or 26 00)"},
632 725
726 {0x2300, "Invalid token operation, cause not reportable"},
727 {0x2301, "Invalid token operation, unsupported token type"},
728 {0x2302, "Invalid token operation, remote token usage not supported"},
729 {0x2303, "Invalid token operation, remote rod token creation not "
730 "supported"},
731 {0x2304, "Invalid token operation, token unknown"},
732 {0x2305, "Invalid token operation, token corrupt"},
733 {0x2306, "Invalid token operation, token revoked"},
734 {0x2307, "Invalid token operation, token expired"},
735 {0x2308, "Invalid token operation, token cancelled"},
736 {0x2309, "Invalid token operation, token deleted"},
737 {0x230A, "Invalid token operation, invalid token length"},
738
633 {0x2400, "Invalid field in cdb"}, 739 {0x2400, "Invalid field in cdb"},
634 {0x2401, "CDB decryption error"}, 740 {0x2401, "CDB decryption error"},
635 {0x2402, "Obsolete"}, 741 {0x2402, "Obsolete"},
@@ -705,6 +811,7 @@ static const struct error_info additional[] =
705 "event"}, 811 "event"},
706 {0x2A13, "Data encryption key instance counter has changed"}, 812 {0x2A13, "Data encryption key instance counter has changed"},
707 {0x2A14, "SA creation capabilities data has changed"}, 813 {0x2A14, "SA creation capabilities data has changed"},
814 {0x2A15, "Medium removal prevention preempted"},
708 815
709 {0x2B00, "Copy cannot execute since host cannot disconnect"}, 816 {0x2B00, "Copy cannot execute since host cannot disconnect"},
710 817
@@ -720,6 +827,7 @@ static const struct error_info additional[] =
720 {0x2C09, "Previous reservation conflict status"}, 827 {0x2C09, "Previous reservation conflict status"},
721 {0x2C0A, "Partition or collection contains user objects"}, 828 {0x2C0A, "Partition or collection contains user objects"},
722 {0x2C0B, "Not reserved"}, 829 {0x2C0B, "Not reserved"},
830 {0x2C0C, "Orwrite generation does not match"},
723 831
724 {0x2D00, "Overwrite error on update in place"}, 832 {0x2D00, "Overwrite error on update in place"},
725 833
@@ -728,6 +836,7 @@ static const struct error_info additional[] =
728 {0x2F00, "Commands cleared by another initiator"}, 836 {0x2F00, "Commands cleared by another initiator"},
729 {0x2F01, "Commands cleared by power loss notification"}, 837 {0x2F01, "Commands cleared by power loss notification"},
730 {0x2F02, "Commands cleared by device server"}, 838 {0x2F02, "Commands cleared by device server"},
839 {0x2F03, "Some commands cleared by queuing layer event"},
731 840
732 {0x3000, "Incompatible medium installed"}, 841 {0x3000, "Incompatible medium installed"},
733 {0x3001, "Cannot read medium - unknown format"}, 842 {0x3001, "Cannot read medium - unknown format"},
@@ -745,10 +854,12 @@ static const struct error_info additional[] =
745 {0x3010, "Medium not formatted"}, 854 {0x3010, "Medium not formatted"},
746 {0x3011, "Incompatible volume type"}, 855 {0x3011, "Incompatible volume type"},
747 {0x3012, "Incompatible volume qualifier"}, 856 {0x3012, "Incompatible volume qualifier"},
857 {0x3013, "Cleaning volume expired"},
748 858
749 {0x3100, "Medium format corrupted"}, 859 {0x3100, "Medium format corrupted"},
750 {0x3101, "Format command failed"}, 860 {0x3101, "Format command failed"},
751 {0x3102, "Zoned formatting failed due to spare linking"}, 861 {0x3102, "Zoned formatting failed due to spare linking"},
862 {0x3103, "Sanitize command failed"},
752 863
753 {0x3200, "No defect spare location available"}, 864 {0x3200, "No defect spare location available"},
754 {0x3201, "Defect list update failure"}, 865 {0x3201, "Defect list update failure"},
@@ -809,6 +920,8 @@ static const struct error_info additional[] =
809 {0x3B19, "Element enabled"}, 920 {0x3B19, "Element enabled"},
810 {0x3B1A, "Data transfer device removed"}, 921 {0x3B1A, "Data transfer device removed"},
811 {0x3B1B, "Data transfer device inserted"}, 922 {0x3B1B, "Data transfer device inserted"},
923 {0x3B1C, "Too many logical objects on partition to support "
924 "operation"},
812 925
813 {0x3D00, "Invalid bits in identify message"}, 926 {0x3D00, "Invalid bits in identify message"},
814 927
@@ -839,6 +952,7 @@ static const struct error_info additional[] =
839 {0x3F12, "iSCSI IP address added"}, 952 {0x3F12, "iSCSI IP address added"},
840 {0x3F13, "iSCSI IP address removed"}, 953 {0x3F13, "iSCSI IP address removed"},
841 {0x3F14, "iSCSI IP address changed"}, 954 {0x3F14, "iSCSI IP address changed"},
955 {0x3F15, "Inspect referrals sense descriptors"},
842/* 956/*
843 * {0x40NN, "Ram failure"}, 957 * {0x40NN, "Ram failure"},
844 * {0x40NN, "Diagnostic failure on component nn"}, 958 * {0x40NN, "Diagnostic failure on component nn"},
@@ -848,6 +962,7 @@ static const struct error_info additional[] =
848 {0x4300, "Message error"}, 962 {0x4300, "Message error"},
849 963
850 {0x4400, "Internal target failure"}, 964 {0x4400, "Internal target failure"},
965 {0x4401, "Persistent reservation information lost"},
851 {0x4471, "ATA device failed set features"}, 966 {0x4471, "ATA device failed set features"},
852 967
853 {0x4500, "Select or reselect failure"}, 968 {0x4500, "Select or reselect failure"},
@@ -876,6 +991,21 @@ static const struct error_info additional[] =
876 {0x4B04, "Nak received"}, 991 {0x4B04, "Nak received"},
877 {0x4B05, "Data offset error"}, 992 {0x4B05, "Data offset error"},
878 {0x4B06, "Initiator response timeout"}, 993 {0x4B06, "Initiator response timeout"},
994 {0x4B07, "Connection lost"},
995 {0x4B08, "Data-in buffer overflow - data buffer size"},
996 {0x4B09, "Data-in buffer overflow - data buffer descriptor area"},
997 {0x4B0A, "Data-in buffer error"},
998 {0x4B0B, "Data-out buffer overflow - data buffer size"},
999 {0x4B0C, "Data-out buffer overflow - data buffer descriptor area"},
1000 {0x4B0D, "Data-out buffer error"},
1001 {0x4B0E, "PCIe fabric error"},
1002 {0x4B0F, "PCIe completion timeout"},
1003 {0x4B10, "PCIe completer abort"},
1004 {0x4B11, "PCIe poisoned tlp received"},
1005 {0x4B12, "PCIe eCRC check failed"},
1006 {0x4B13, "PCIe unsupported request"},
1007 {0x4B14, "PCIe acs violation"},
1008 {0x4B15, "PCIe tlp prefix blocked"},
879 1009
880 {0x4C00, "Logical unit failed self-configuration"}, 1010 {0x4C00, "Logical unit failed self-configuration"},
881/* 1011/*
@@ -897,6 +1027,10 @@ static const struct error_info additional[] =
897 {0x5302, "Medium removal prevented"}, 1027 {0x5302, "Medium removal prevented"},
898 {0x5303, "Medium removal prevented by data transfer element"}, 1028 {0x5303, "Medium removal prevented by data transfer element"},
899 {0x5304, "Medium thread or unthread failure"}, 1029 {0x5304, "Medium thread or unthread failure"},
1030 {0x5305, "Volume identifier invalid"},
1031 {0x5306, "Volume identifier missing"},
1032 {0x5307, "Duplicate volume identifier"},
1033 {0x5308, "Element status unknown"},
900 1034
901 {0x5400, "Scsi to host system interface failure"}, 1035 {0x5400, "Scsi to host system interface failure"},
902 1036
@@ -911,6 +1045,9 @@ static const struct error_info additional[] =
911 {0x5508, "Maximum number of supplemental decryption keys exceeded"}, 1045 {0x5508, "Maximum number of supplemental decryption keys exceeded"},
912 {0x5509, "Medium auxiliary memory not accessible"}, 1046 {0x5509, "Medium auxiliary memory not accessible"},
913 {0x550A, "Data currently unavailable"}, 1047 {0x550A, "Data currently unavailable"},
1048 {0x550B, "Insufficient power for operation"},
1049 {0x550C, "Insufficient resources to create rod"},
1050 {0x550D, "Insufficient resources to create rod token"},
914 1051
915 {0x5700, "Unable to recover table-of-contents"}, 1052 {0x5700, "Unable to recover table-of-contents"},
916 1053
@@ -1069,6 +1206,7 @@ static const struct error_info additional[] =
1069 {0x670B, "ATA device feature not enabled"}, 1206 {0x670B, "ATA device feature not enabled"},
1070 1207
1071 {0x6800, "Logical unit not configured"}, 1208 {0x6800, "Logical unit not configured"},
1209 {0x6801, "Subsidiary logical unit not configured"},
1072 1210
1073 {0x6900, "Data loss on logical unit"}, 1211 {0x6900, "Data loss on logical unit"},
1074 {0x6901, "Multiple logical unit failures"}, 1212 {0x6901, "Multiple logical unit failures"},
@@ -1185,10 +1323,13 @@ static const char * const snstext[] = {
1185 "Vendor Specific(9)", 1323 "Vendor Specific(9)",
1186 "Copy Aborted", /* A: COPY or COMPARE was aborted */ 1324 "Copy Aborted", /* A: COPY or COMPARE was aborted */
1187 "Aborted Command", /* B: The target aborted the command */ 1325 "Aborted Command", /* B: The target aborted the command */
1188 "Equal", /* C: A SEARCH DATA command found data equal */ 1326 "Equal", /* C: A SEARCH DATA command found data equal,
1327 reserved in SPC-4 rev 36 */
1189 "Volume Overflow", /* D: Medium full with still data to be written */ 1328 "Volume Overflow", /* D: Medium full with still data to be written */
1190 "Miscompare", /* E: Source data and data on the medium 1329 "Miscompare", /* E: Source data and data on the medium
1191 do not agree */ 1330 do not agree */
1331 "Completed", /* F: command completed sense data reported,
1332 may occur for successful command */
1192}; 1333};
1193#endif 1334#endif
1194 1335
@@ -1306,7 +1447,7 @@ scsi_decode_sense_buffer(const unsigned char *sense_buffer, int sense_len,
1306 struct scsi_sense_hdr *sshdr) 1447 struct scsi_sense_hdr *sshdr)
1307{ 1448{
1308 int k, num, res; 1449 int k, num, res;
1309 1450
1310 res = scsi_normalize_sense(sense_buffer, sense_len, sshdr); 1451 res = scsi_normalize_sense(sense_buffer, sense_len, sshdr);
1311 if (0 == res) { 1452 if (0 == res) {
1312 /* this may be SCSI-1 sense data */ 1453 /* this may be SCSI-1 sense data */
@@ -1459,5 +1600,3 @@ void scsi_print_result(struct scsi_cmnd *cmd)
1459 scsi_show_result(cmd->result); 1600 scsi_show_result(cmd->result);
1460} 1601}
1461EXPORT_SYMBOL(scsi_print_result); 1602EXPORT_SYMBOL(scsi_print_result);
1462
1463
diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c
index 4a05d0427a9c..07453bbf05e7 100644
--- a/drivers/scsi/fcoe/fcoe.c
+++ b/drivers/scsi/fcoe/fcoe.c
@@ -774,7 +774,6 @@ static void fcoe_fdmi_info(struct fc_lport *lport, struct net_device *netdev)
774 struct fcoe_port *port; 774 struct fcoe_port *port;
775 struct net_device *realdev; 775 struct net_device *realdev;
776 int rc; 776 int rc;
777 struct netdev_fcoe_hbainfo fdmi;
778 777
779 port = lport_priv(lport); 778 port = lport_priv(lport);
780 fcoe = port->priv; 779 fcoe = port->priv;
@@ -788,9 +787,13 @@ static void fcoe_fdmi_info(struct fc_lport *lport, struct net_device *netdev)
788 return; 787 return;
789 788
790 if (realdev->netdev_ops->ndo_fcoe_get_hbainfo) { 789 if (realdev->netdev_ops->ndo_fcoe_get_hbainfo) {
791 memset(&fdmi, 0, sizeof(fdmi)); 790 struct netdev_fcoe_hbainfo *fdmi;
791 fdmi = kzalloc(sizeof(*fdmi), GFP_KERNEL);
792 if (!fdmi)
793 return;
794
792 rc = realdev->netdev_ops->ndo_fcoe_get_hbainfo(realdev, 795 rc = realdev->netdev_ops->ndo_fcoe_get_hbainfo(realdev,
793 &fdmi); 796 fdmi);
794 if (rc) { 797 if (rc) {
795 printk(KERN_INFO "fcoe: Failed to retrieve FDMI " 798 printk(KERN_INFO "fcoe: Failed to retrieve FDMI "
796 "information from netdev.\n"); 799 "information from netdev.\n");
@@ -800,38 +803,39 @@ static void fcoe_fdmi_info(struct fc_lport *lport, struct net_device *netdev)
800 snprintf(fc_host_serial_number(lport->host), 803 snprintf(fc_host_serial_number(lport->host),
801 FC_SERIAL_NUMBER_SIZE, 804 FC_SERIAL_NUMBER_SIZE,
802 "%s", 805 "%s",
803 fdmi.serial_number); 806 fdmi->serial_number);
804 snprintf(fc_host_manufacturer(lport->host), 807 snprintf(fc_host_manufacturer(lport->host),
805 FC_SERIAL_NUMBER_SIZE, 808 FC_SERIAL_NUMBER_SIZE,
806 "%s", 809 "%s",
807 fdmi.manufacturer); 810 fdmi->manufacturer);
808 snprintf(fc_host_model(lport->host), 811 snprintf(fc_host_model(lport->host),
809 FC_SYMBOLIC_NAME_SIZE, 812 FC_SYMBOLIC_NAME_SIZE,
810 "%s", 813 "%s",
811 fdmi.model); 814 fdmi->model);
812 snprintf(fc_host_model_description(lport->host), 815 snprintf(fc_host_model_description(lport->host),
813 FC_SYMBOLIC_NAME_SIZE, 816 FC_SYMBOLIC_NAME_SIZE,
814 "%s", 817 "%s",
815 fdmi.model_description); 818 fdmi->model_description);
816 snprintf(fc_host_hardware_version(lport->host), 819 snprintf(fc_host_hardware_version(lport->host),
817 FC_VERSION_STRING_SIZE, 820 FC_VERSION_STRING_SIZE,
818 "%s", 821 "%s",
819 fdmi.hardware_version); 822 fdmi->hardware_version);
820 snprintf(fc_host_driver_version(lport->host), 823 snprintf(fc_host_driver_version(lport->host),
821 FC_VERSION_STRING_SIZE, 824 FC_VERSION_STRING_SIZE,
822 "%s", 825 "%s",
823 fdmi.driver_version); 826 fdmi->driver_version);
824 snprintf(fc_host_optionrom_version(lport->host), 827 snprintf(fc_host_optionrom_version(lport->host),
825 FC_VERSION_STRING_SIZE, 828 FC_VERSION_STRING_SIZE,
826 "%s", 829 "%s",
827 fdmi.optionrom_version); 830 fdmi->optionrom_version);
828 snprintf(fc_host_firmware_version(lport->host), 831 snprintf(fc_host_firmware_version(lport->host),
829 FC_VERSION_STRING_SIZE, 832 FC_VERSION_STRING_SIZE,
830 "%s", 833 "%s",
831 fdmi.firmware_version); 834 fdmi->firmware_version);
832 835
833 /* Enable FDMI lport states */ 836 /* Enable FDMI lport states */
834 lport->fdmi_enabled = 1; 837 lport->fdmi_enabled = 1;
838 kfree(fdmi);
835 } else { 839 } else {
836 lport->fdmi_enabled = 0; 840 lport->fdmi_enabled = 0;
837 printk(KERN_INFO "fcoe: No FDMI support.\n"); 841 printk(KERN_INFO "fcoe: No FDMI support.\n");
diff --git a/drivers/scsi/fcoe/fcoe_ctlr.c b/drivers/scsi/fcoe/fcoe_ctlr.c
index 795843dde8ec..203415e02518 100644
--- a/drivers/scsi/fcoe/fcoe_ctlr.c
+++ b/drivers/scsi/fcoe/fcoe_ctlr.c
@@ -2090,7 +2090,11 @@ static struct fc_rport_operations fcoe_ctlr_vn_rport_ops = {
2090 */ 2090 */
2091static void fcoe_ctlr_disc_stop_locked(struct fc_lport *lport) 2091static void fcoe_ctlr_disc_stop_locked(struct fc_lport *lport)
2092{ 2092{
2093 struct fc_rport_priv *rdata;
2094
2093 mutex_lock(&lport->disc.disc_mutex); 2095 mutex_lock(&lport->disc.disc_mutex);
2096 list_for_each_entry_rcu(rdata, &lport->disc.rports, peers)
2097 lport->tt.rport_logoff(rdata);
2094 lport->disc.disc_callback = NULL; 2098 lport->disc.disc_callback = NULL;
2095 mutex_unlock(&lport->disc.disc_mutex); 2099 mutex_unlock(&lport->disc.disc_mutex);
2096} 2100}
diff --git a/drivers/scsi/fcoe/fcoe_sysfs.c b/drivers/scsi/fcoe/fcoe_sysfs.c
index 8c05ae017f5b..c9382d6eee78 100644
--- a/drivers/scsi/fcoe/fcoe_sysfs.c
+++ b/drivers/scsi/fcoe/fcoe_sysfs.c
@@ -507,7 +507,7 @@ static const struct attribute_group *fcoe_fcf_attr_groups[] = {
507 NULL, 507 NULL,
508}; 508};
509 509
510struct bus_type fcoe_bus_type; 510static struct bus_type fcoe_bus_type;
511 511
512static int fcoe_bus_match(struct device *dev, 512static int fcoe_bus_match(struct device *dev,
513 struct device_driver *drv) 513 struct device_driver *drv)
@@ -541,25 +541,25 @@ static void fcoe_fcf_device_release(struct device *dev)
541 kfree(fcf); 541 kfree(fcf);
542} 542}
543 543
544struct device_type fcoe_ctlr_device_type = { 544static struct device_type fcoe_ctlr_device_type = {
545 .name = "fcoe_ctlr", 545 .name = "fcoe_ctlr",
546 .groups = fcoe_ctlr_attr_groups, 546 .groups = fcoe_ctlr_attr_groups,
547 .release = fcoe_ctlr_device_release, 547 .release = fcoe_ctlr_device_release,
548}; 548};
549 549
550struct device_type fcoe_fcf_device_type = { 550static struct device_type fcoe_fcf_device_type = {
551 .name = "fcoe_fcf", 551 .name = "fcoe_fcf",
552 .groups = fcoe_fcf_attr_groups, 552 .groups = fcoe_fcf_attr_groups,
553 .release = fcoe_fcf_device_release, 553 .release = fcoe_fcf_device_release,
554}; 554};
555 555
556struct bus_attribute fcoe_bus_attr_group[] = { 556static struct bus_attribute fcoe_bus_attr_group[] = {
557 __ATTR(ctlr_create, S_IWUSR, NULL, fcoe_ctlr_create_store), 557 __ATTR(ctlr_create, S_IWUSR, NULL, fcoe_ctlr_create_store),
558 __ATTR(ctlr_destroy, S_IWUSR, NULL, fcoe_ctlr_destroy_store), 558 __ATTR(ctlr_destroy, S_IWUSR, NULL, fcoe_ctlr_destroy_store),
559 __ATTR_NULL 559 __ATTR_NULL
560}; 560};
561 561
562struct bus_type fcoe_bus_type = { 562static struct bus_type fcoe_bus_type = {
563 .name = "fcoe", 563 .name = "fcoe",
564 .match = &fcoe_bus_match, 564 .match = &fcoe_bus_match,
565 .bus_attrs = fcoe_bus_attr_group, 565 .bus_attrs = fcoe_bus_attr_group,
@@ -569,7 +569,7 @@ struct bus_type fcoe_bus_type = {
569 * fcoe_ctlr_device_flush_work() - Flush a FIP ctlr's workqueue 569 * fcoe_ctlr_device_flush_work() - Flush a FIP ctlr's workqueue
570 * @ctlr: Pointer to the FIP ctlr whose workqueue is to be flushed 570 * @ctlr: Pointer to the FIP ctlr whose workqueue is to be flushed
571 */ 571 */
572void fcoe_ctlr_device_flush_work(struct fcoe_ctlr_device *ctlr) 572static void fcoe_ctlr_device_flush_work(struct fcoe_ctlr_device *ctlr)
573{ 573{
574 if (!fcoe_ctlr_work_q(ctlr)) { 574 if (!fcoe_ctlr_work_q(ctlr)) {
575 printk(KERN_ERR 575 printk(KERN_ERR
@@ -590,8 +590,8 @@ void fcoe_ctlr_device_flush_work(struct fcoe_ctlr_device *ctlr)
590 * Return value: 590 * Return value:
591 * 1 on success / 0 already queued / < 0 for error 591 * 1 on success / 0 already queued / < 0 for error
592 */ 592 */
593int fcoe_ctlr_device_queue_work(struct fcoe_ctlr_device *ctlr, 593static int fcoe_ctlr_device_queue_work(struct fcoe_ctlr_device *ctlr,
594 struct work_struct *work) 594 struct work_struct *work)
595{ 595{
596 if (unlikely(!fcoe_ctlr_work_q(ctlr))) { 596 if (unlikely(!fcoe_ctlr_work_q(ctlr))) {
597 printk(KERN_ERR 597 printk(KERN_ERR
@@ -609,7 +609,7 @@ int fcoe_ctlr_device_queue_work(struct fcoe_ctlr_device *ctlr,
609 * fcoe_ctlr_device_flush_devloss() - Flush a FIP ctlr's devloss workqueue 609 * fcoe_ctlr_device_flush_devloss() - Flush a FIP ctlr's devloss workqueue
610 * @ctlr: Pointer to FIP ctlr whose workqueue is to be flushed 610 * @ctlr: Pointer to FIP ctlr whose workqueue is to be flushed
611 */ 611 */
612void fcoe_ctlr_device_flush_devloss(struct fcoe_ctlr_device *ctlr) 612static void fcoe_ctlr_device_flush_devloss(struct fcoe_ctlr_device *ctlr)
613{ 613{
614 if (!fcoe_ctlr_devloss_work_q(ctlr)) { 614 if (!fcoe_ctlr_devloss_work_q(ctlr)) {
615 printk(KERN_ERR 615 printk(KERN_ERR
@@ -631,9 +631,9 @@ void fcoe_ctlr_device_flush_devloss(struct fcoe_ctlr_device *ctlr)
631 * Return value: 631 * Return value:
632 * 1 on success / 0 already queued / < 0 for error 632 * 1 on success / 0 already queued / < 0 for error
633 */ 633 */
634int fcoe_ctlr_device_queue_devloss_work(struct fcoe_ctlr_device *ctlr, 634static int fcoe_ctlr_device_queue_devloss_work(struct fcoe_ctlr_device *ctlr,
635 struct delayed_work *work, 635 struct delayed_work *work,
636 unsigned long delay) 636 unsigned long delay)
637{ 637{
638 if (unlikely(!fcoe_ctlr_devloss_work_q(ctlr))) { 638 if (unlikely(!fcoe_ctlr_devloss_work_q(ctlr))) {
639 printk(KERN_ERR 639 printk(KERN_ERR
diff --git a/drivers/scsi/fcoe/fcoe_transport.c b/drivers/scsi/fcoe/fcoe_transport.c
index 01adbe0ec53b..74277c20f6a5 100644
--- a/drivers/scsi/fcoe/fcoe_transport.c
+++ b/drivers/scsi/fcoe/fcoe_transport.c
@@ -180,24 +180,10 @@ void fcoe_ctlr_get_lesb(struct fcoe_ctlr_device *ctlr_dev)
180{ 180{
181 struct fcoe_ctlr *fip = fcoe_ctlr_device_priv(ctlr_dev); 181 struct fcoe_ctlr *fip = fcoe_ctlr_device_priv(ctlr_dev);
182 struct net_device *netdev = fcoe_get_netdev(fip->lp); 182 struct net_device *netdev = fcoe_get_netdev(fip->lp);
183 struct fcoe_fc_els_lesb *fcoe_lesb; 183 struct fc_els_lesb *fc_lesb;
184 struct fc_els_lesb fc_lesb; 184
185 185 fc_lesb = (struct fc_els_lesb *)(&ctlr_dev->lesb);
186 __fcoe_get_lesb(fip->lp, &fc_lesb, netdev); 186 __fcoe_get_lesb(fip->lp, fc_lesb, netdev);
187 fcoe_lesb = (struct fcoe_fc_els_lesb *)(&fc_lesb);
188
189 ctlr_dev->lesb.lesb_link_fail =
190 ntohl(fcoe_lesb->lesb_link_fail);
191 ctlr_dev->lesb.lesb_vlink_fail =
192 ntohl(fcoe_lesb->lesb_vlink_fail);
193 ctlr_dev->lesb.lesb_miss_fka =
194 ntohl(fcoe_lesb->lesb_miss_fka);
195 ctlr_dev->lesb.lesb_symb_err =
196 ntohl(fcoe_lesb->lesb_symb_err);
197 ctlr_dev->lesb.lesb_err_block =
198 ntohl(fcoe_lesb->lesb_err_block);
199 ctlr_dev->lesb.lesb_fcs_error =
200 ntohl(fcoe_lesb->lesb_fcs_error);
201} 187}
202EXPORT_SYMBOL_GPL(fcoe_ctlr_get_lesb); 188EXPORT_SYMBOL_GPL(fcoe_ctlr_get_lesb);
203 189
@@ -721,7 +707,6 @@ ssize_t fcoe_ctlr_create_store(struct bus_type *bus,
721{ 707{
722 struct net_device *netdev = NULL; 708 struct net_device *netdev = NULL;
723 struct fcoe_transport *ft = NULL; 709 struct fcoe_transport *ft = NULL;
724 struct fcoe_ctlr_device *ctlr_dev = NULL;
725 int rc = 0; 710 int rc = 0;
726 int err; 711 int err;
727 712
@@ -768,9 +753,8 @@ ssize_t fcoe_ctlr_create_store(struct bus_type *bus,
768 goto out_putdev; 753 goto out_putdev;
769 } 754 }
770 755
771 LIBFCOE_TRANSPORT_DBG("transport %s %s to create fcoe on %s.\n", 756 LIBFCOE_TRANSPORT_DBG("transport %s succeeded to create fcoe on %s.\n",
772 ft->name, (ctlr_dev) ? "succeeded" : "failed", 757 ft->name, netdev->name);
773 netdev->name);
774 758
775out_putdev: 759out_putdev:
776 dev_put(netdev); 760 dev_put(netdev);
diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
index 8b928c67e4b9..587992952b3c 100644
--- a/drivers/scsi/libfc/fc_exch.c
+++ b/drivers/scsi/libfc/fc_exch.c
@@ -337,7 +337,7 @@ static void fc_exch_release(struct fc_exch *ep)
337 * fc_exch_timer_cancel() - cancel exch timer 337 * fc_exch_timer_cancel() - cancel exch timer
338 * @ep: The exchange whose timer to be canceled 338 * @ep: The exchange whose timer to be canceled
339 */ 339 */
340static inline void fc_exch_timer_cancel(struct fc_exch *ep) 340static inline void fc_exch_timer_cancel(struct fc_exch *ep)
341{ 341{
342 if (cancel_delayed_work(&ep->timeout_work)) { 342 if (cancel_delayed_work(&ep->timeout_work)) {
343 FC_EXCH_DBG(ep, "Exchange timer canceled\n"); 343 FC_EXCH_DBG(ep, "Exchange timer canceled\n");
@@ -1567,7 +1567,7 @@ static void fc_exch_abts_resp(struct fc_exch *ep, struct fc_frame *fp)
1567 fc_exch_rctl_name(fh->fh_r_ctl)); 1567 fc_exch_rctl_name(fh->fh_r_ctl));
1568 1568
1569 if (cancel_delayed_work_sync(&ep->timeout_work)) { 1569 if (cancel_delayed_work_sync(&ep->timeout_work)) {
1570 FC_EXCH_DBG(ep, "Exchange timer canceled\n"); 1570 FC_EXCH_DBG(ep, "Exchange timer canceled due to ABTS response\n");
1571 fc_exch_release(ep); /* release from pending timer hold */ 1571 fc_exch_release(ep); /* release from pending timer hold */
1572 } 1572 }
1573 1573
diff --git a/drivers/scsi/libfc/fc_rport.c b/drivers/scsi/libfc/fc_rport.c
index 6bbb9447b75d..c710d908fda6 100644
--- a/drivers/scsi/libfc/fc_rport.c
+++ b/drivers/scsi/libfc/fc_rport.c
@@ -926,6 +926,20 @@ err:
926 kref_put(&rdata->kref, rdata->local_port->tt.rport_destroy); 926 kref_put(&rdata->kref, rdata->local_port->tt.rport_destroy);
927} 927}
928 928
929static bool
930fc_rport_compatible_roles(struct fc_lport *lport, struct fc_rport_priv *rdata)
931{
932 if (rdata->ids.roles == FC_PORT_ROLE_UNKNOWN)
933 return true;
934 if ((rdata->ids.roles & FC_PORT_ROLE_FCP_TARGET) &&
935 (lport->service_params & FCP_SPPF_INIT_FCN))
936 return true;
937 if ((rdata->ids.roles & FC_PORT_ROLE_FCP_INITIATOR) &&
938 (lport->service_params & FCP_SPPF_TARG_FCN))
939 return true;
940 return false;
941}
942
929/** 943/**
930 * fc_rport_enter_plogi() - Send Port Login (PLOGI) request 944 * fc_rport_enter_plogi() - Send Port Login (PLOGI) request
931 * @rdata: The remote port to send a PLOGI to 945 * @rdata: The remote port to send a PLOGI to
@@ -938,6 +952,12 @@ static void fc_rport_enter_plogi(struct fc_rport_priv *rdata)
938 struct fc_lport *lport = rdata->local_port; 952 struct fc_lport *lport = rdata->local_port;
939 struct fc_frame *fp; 953 struct fc_frame *fp;
940 954
955 if (!fc_rport_compatible_roles(lport, rdata)) {
956 FC_RPORT_DBG(rdata, "PLOGI suppressed for incompatible role\n");
957 fc_rport_state_enter(rdata, RPORT_ST_PLOGI_WAIT);
958 return;
959 }
960
941 FC_RPORT_DBG(rdata, "Port entered PLOGI state from %s state\n", 961 FC_RPORT_DBG(rdata, "Port entered PLOGI state from %s state\n",
942 fc_rport_state(rdata)); 962 fc_rport_state(rdata));
943 963
@@ -1646,6 +1666,13 @@ static void fc_rport_recv_plogi_req(struct fc_lport *lport,
1646 rjt_data.explan = ELS_EXPL_NONE; 1666 rjt_data.explan = ELS_EXPL_NONE;
1647 goto reject; 1667 goto reject;
1648 } 1668 }
1669 if (!fc_rport_compatible_roles(lport, rdata)) {
1670 FC_RPORT_DBG(rdata, "Received PLOGI for incompatible role\n");
1671 mutex_unlock(&rdata->rp_mutex);
1672 rjt_data.reason = ELS_RJT_LOGIC;
1673 rjt_data.explan = ELS_EXPL_NONE;
1674 goto reject;
1675 }
1649 1676
1650 /* 1677 /*
1651 * Get session payload size from incoming PLOGI. 1678 * Get session payload size from incoming PLOGI.
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
index 6002d363c637..0177295599e0 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -4958,10 +4958,12 @@ megasas_mgmt_fw_ioctl(struct megasas_instance *instance,
4958 sense, sense_handle); 4958 sense, sense_handle);
4959 } 4959 }
4960 4960
4961 for (i = 0; i < ioc->sge_count && kbuff_arr[i]; i++) { 4961 for (i = 0; i < ioc->sge_count; i++) {
4962 dma_free_coherent(&instance->pdev->dev, 4962 if (kbuff_arr[i])
4963 kern_sge32[i].length, 4963 dma_free_coherent(&instance->pdev->dev,
4964 kbuff_arr[i], kern_sge32[i].phys_addr); 4964 kern_sge32[i].length,
4965 kbuff_arr[i],
4966 kern_sge32[i].phys_addr);
4965 } 4967 }
4966 4968
4967 megasas_return_cmd(instance, cmd); 4969 megasas_return_cmd(instance, cmd);
diff --git a/drivers/scsi/megaraid/megaraid_sas_fp.c b/drivers/scsi/megaraid/megaraid_sas_fp.c
index 8056eacba758..4f401f753f8e 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fp.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fp.c
@@ -585,7 +585,7 @@ u8 get_arm(struct megasas_instance *instance, u32 ld, u8 span, u64 stripe,
585 case 1: 585 case 1:
586 /* start with logical arm */ 586 /* start with logical arm */
587 arm = get_arm_from_strip(instance, ld, stripe, map); 587 arm = get_arm_from_strip(instance, ld, stripe, map);
588 if (arm != -1UL) 588 if (arm != -1U)
589 arm *= 2; 589 arm *= 2;
590 break; 590 break;
591 } 591 }
@@ -637,7 +637,7 @@ static u8 mr_spanset_get_phy_params(struct megasas_instance *instance, u32 ld,
637 637
638 if (raid->level == 6) { 638 if (raid->level == 6) {
639 logArm = get_arm_from_strip(instance, ld, stripRow, map); 639 logArm = get_arm_from_strip(instance, ld, stripRow, map);
640 if (logArm == -1UL) 640 if (logArm == -1U)
641 return FALSE; 641 return FALSE;
642 rowMod = mega_mod64(row, SPAN_ROW_SIZE(map, ld, span)); 642 rowMod = mega_mod64(row, SPAN_ROW_SIZE(map, ld, span));
643 armQ = SPAN_ROW_SIZE(map, ld, span) - 1 - rowMod; 643 armQ = SPAN_ROW_SIZE(map, ld, span) - 1 - rowMod;
diff --git a/drivers/scsi/mpt3sas/Kconfig b/drivers/scsi/mpt3sas/Kconfig
index 81471bf415d8..d53e1b02e893 100644
--- a/drivers/scsi/mpt3sas/Kconfig
+++ b/drivers/scsi/mpt3sas/Kconfig
@@ -2,7 +2,7 @@
2# Kernel configuration file for the MPT3SAS 2# Kernel configuration file for the MPT3SAS
3# 3#
4# This code is based on drivers/scsi/mpt3sas/Kconfig 4# This code is based on drivers/scsi/mpt3sas/Kconfig
5# Copyright (C) 2012 LSI Corporation 5# Copyright (C) 2012-2013 LSI Corporation
6# (mailto:DL-MPTFusionLinux@lsi.com) 6# (mailto:DL-MPTFusionLinux@lsi.com)
7 7
8# This program is free software; you can redistribute it and/or 8# This program is free software; you can redistribute it and/or
diff --git a/drivers/scsi/mpt3sas/mpi/mpi2.h b/drivers/scsi/mpt3sas/mpi/mpi2.h
index 03317ffea62c..20da8f907c00 100644
--- a/drivers/scsi/mpt3sas/mpi/mpi2.h
+++ b/drivers/scsi/mpt3sas/mpi/mpi2.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2000-2012 LSI Corporation. 2 * Copyright (c) 2000-2013 LSI Corporation.
3 * 3 *
4 * 4 *
5 * Name: mpi2.h 5 * Name: mpi2.h
@@ -8,7 +8,7 @@
8 * scatter/gather formats. 8 * scatter/gather formats.
9 * Creation Date: June 21, 2006 9 * Creation Date: June 21, 2006
10 * 10 *
11 * mpi2.h Version: 02.00.26 11 * mpi2.h Version: 02.00.29
12 * 12 *
13 * NOTE: Names (typedefs, defines, etc.) beginning with an MPI25 or Mpi25 13 * NOTE: Names (typedefs, defines, etc.) beginning with an MPI25 or Mpi25
14 * prefix are for use only on MPI v2.5 products, and must not be used 14 * prefix are for use only on MPI v2.5 products, and must not be used
@@ -82,6 +82,10 @@
82 * 03-29-12 02.00.25 Bumped MPI2_HEADER_VERSION_UNIT. 82 * 03-29-12 02.00.25 Bumped MPI2_HEADER_VERSION_UNIT.
83 * Added Hard Reset delay timings. 83 * Added Hard Reset delay timings.
84 * 07-10-12 02.00.26 Bumped MPI2_HEADER_VERSION_UNIT. 84 * 07-10-12 02.00.26 Bumped MPI2_HEADER_VERSION_UNIT.
85 * 07-26-12 02.00.27 Bumped MPI2_HEADER_VERSION_UNIT.
86 * 11-27-12 02.00.28 Bumped MPI2_HEADER_VERSION_UNIT.
87 * 12-20-12 02.00.29 Bumped MPI2_HEADER_VERSION_UNIT.
88 * Added MPI25_SUP_REPLY_POST_HOST_INDEX_OFFSET.
85 * -------------------------------------------------------------------------- 89 * --------------------------------------------------------------------------
86 */ 90 */
87 91
@@ -115,7 +119,7 @@
115#define MPI2_VERSION_02_05 (0x0205) 119#define MPI2_VERSION_02_05 (0x0205)
116 120
117/*Unit and Dev versioning for this MPI header set */ 121/*Unit and Dev versioning for this MPI header set */
118#define MPI2_HEADER_VERSION_UNIT (0x1A) 122#define MPI2_HEADER_VERSION_UNIT (0x1D)
119#define MPI2_HEADER_VERSION_DEV (0x00) 123#define MPI2_HEADER_VERSION_DEV (0x00)
120#define MPI2_HEADER_VERSION_UNIT_MASK (0xFF00) 124#define MPI2_HEADER_VERSION_UNIT_MASK (0xFF00)
121#define MPI2_HEADER_VERSION_UNIT_SHIFT (8) 125#define MPI2_HEADER_VERSION_UNIT_SHIFT (8)
@@ -274,6 +278,8 @@ typedef volatile struct _MPI2_SYSTEM_INTERFACE_REGS {
274#define MPI2_REPLY_POST_HOST_INDEX_MASK (0x00FFFFFF) 278#define MPI2_REPLY_POST_HOST_INDEX_MASK (0x00FFFFFF)
275#define MPI2_RPHI_MSIX_INDEX_MASK (0xFF000000) 279#define MPI2_RPHI_MSIX_INDEX_MASK (0xFF000000)
276#define MPI2_RPHI_MSIX_INDEX_SHIFT (24) 280#define MPI2_RPHI_MSIX_INDEX_SHIFT (24)
281#define MPI25_SUP_REPLY_POST_HOST_INDEX_OFFSET (0x0000030C) /*MPI v2.5 only*/
282
277 283
278/* 284/*
279 *Defines for the HCBSize and address 285 *Defines for the HCBSize and address
diff --git a/drivers/scsi/mpt3sas/mpi/mpi2_cnfg.h b/drivers/scsi/mpt3sas/mpi/mpi2_cnfg.h
index d8b2c3eedb57..889aa7067899 100644
--- a/drivers/scsi/mpt3sas/mpi/mpi2_cnfg.h
+++ b/drivers/scsi/mpt3sas/mpi/mpi2_cnfg.h
@@ -1,12 +1,12 @@
1/* 1/*
2 * Copyright (c) 2000-2011 LSI Corporation. 2 * Copyright (c) 2000-2013 LSI Corporation.
3 * 3 *
4 * 4 *
5 * Name: mpi2_cnfg.h 5 * Name: mpi2_cnfg.h
6 * Title: MPI Configuration messages and pages 6 * Title: MPI Configuration messages and pages
7 * Creation Date: November 10, 2006 7 * Creation Date: November 10, 2006
8 * 8 *
9 * mpi2_cnfg.h Version: 02.00.22 9 * mpi2_cnfg.h Version: 02.00.24
10 * 10 *
11 * NOTE: Names (typedefs, defines, etc.) beginning with an MPI25 or Mpi25 11 * NOTE: Names (typedefs, defines, etc.) beginning with an MPI25 or Mpi25
12 * prefix are for use only on MPI v2.5 products, and must not be used 12 * prefix are for use only on MPI v2.5 products, and must not be used
@@ -155,6 +155,11 @@
155 * Added UEFIVersion field to BIOS Page 1 and defined new 155 * Added UEFIVersion field to BIOS Page 1 and defined new
156 * BiosOptions bits. 156 * BiosOptions bits.
157 * Incorporating additions for MPI v2.5. 157 * Incorporating additions for MPI v2.5.
158 * 11-27-12 02.00.23 Added MPI2_MANPAGE7_FLAG_EVENTREPLAY_SLOT_ORDER.
159 * Added MPI2_BIOSPAGE1_OPTIONS_MASK_OEM_ID.
160 * 12-20-12 02.00.24 Marked MPI2_SASIOUNIT1_CONTROL_CLEAR_AFFILIATION as
161 * obsolete for MPI v2.5 and later.
162 * Added some defines for 12G SAS speeds.
158 * -------------------------------------------------------------------------- 163 * --------------------------------------------------------------------------
159 */ 164 */
160 165
@@ -714,6 +719,7 @@ typedef struct _MPI2_CONFIG_PAGE_MAN_7 {
714#define MPI2_MANUFACTURING7_PAGEVERSION (0x01) 719#define MPI2_MANUFACTURING7_PAGEVERSION (0x01)
715 720
716/*defines for the Flags field */ 721/*defines for the Flags field */
722#define MPI2_MANPAGE7_FLAG_EVENTREPLAY_SLOT_ORDER (0x00000002)
717#define MPI2_MANPAGE7_FLAG_USE_SLOT_INFO (0x00000001) 723#define MPI2_MANPAGE7_FLAG_USE_SLOT_INFO (0x00000001)
718 724
719 725
@@ -1310,6 +1316,9 @@ typedef struct _MPI2_CONFIG_PAGE_BIOS_1 {
1310#define MPI2_BIOSPAGE1_PAGEVERSION (0x05) 1316#define MPI2_BIOSPAGE1_PAGEVERSION (0x05)
1311 1317
1312/*values for BIOS Page 1 BiosOptions field */ 1318/*values for BIOS Page 1 BiosOptions field */
1319#define MPI2_BIOSPAGE1_OPTIONS_MASK_OEM_ID (0x000000F0)
1320#define MPI2_BIOSPAGE1_OPTIONS_LSI_OEM_ID (0x00000000)
1321
1313#define MPI2_BIOSPAGE1_OPTIONS_MASK_UEFI_HII_REGISTRATION (0x00000006) 1322#define MPI2_BIOSPAGE1_OPTIONS_MASK_UEFI_HII_REGISTRATION (0x00000006)
1314#define MPI2_BIOSPAGE1_OPTIONS_ENABLE_UEFI_HII (0x00000000) 1323#define MPI2_BIOSPAGE1_OPTIONS_ENABLE_UEFI_HII (0x00000000)
1315#define MPI2_BIOSPAGE1_OPTIONS_DISABLE_UEFI_HII (0x00000002) 1324#define MPI2_BIOSPAGE1_OPTIONS_DISABLE_UEFI_HII (0x00000002)
@@ -1884,6 +1893,7 @@ typedef struct _MPI2_CONFIG_PAGE_RD_PDISK_1 {
1884#define MPI2_SAS_PRATE_MAX_RATE_1_5 (0x80) 1893#define MPI2_SAS_PRATE_MAX_RATE_1_5 (0x80)
1885#define MPI2_SAS_PRATE_MAX_RATE_3_0 (0x90) 1894#define MPI2_SAS_PRATE_MAX_RATE_3_0 (0x90)
1886#define MPI2_SAS_PRATE_MAX_RATE_6_0 (0xA0) 1895#define MPI2_SAS_PRATE_MAX_RATE_6_0 (0xA0)
1896#define MPI25_SAS_PRATE_MAX_RATE_12_0 (0xB0)
1887#define MPI2_SAS_PRATE_MIN_RATE_MASK (0x0F) 1897#define MPI2_SAS_PRATE_MIN_RATE_MASK (0x0F)
1888#define MPI2_SAS_PRATE_MIN_RATE_NOT_PROGRAMMABLE (0x00) 1898#define MPI2_SAS_PRATE_MIN_RATE_NOT_PROGRAMMABLE (0x00)
1889#define MPI2_SAS_PRATE_MIN_RATE_1_5 (0x08) 1899#define MPI2_SAS_PRATE_MIN_RATE_1_5 (0x08)
@@ -1897,6 +1907,7 @@ typedef struct _MPI2_CONFIG_PAGE_RD_PDISK_1 {
1897#define MPI2_SAS_HWRATE_MAX_RATE_1_5 (0x80) 1907#define MPI2_SAS_HWRATE_MAX_RATE_1_5 (0x80)
1898#define MPI2_SAS_HWRATE_MAX_RATE_3_0 (0x90) 1908#define MPI2_SAS_HWRATE_MAX_RATE_3_0 (0x90)
1899#define MPI2_SAS_HWRATE_MAX_RATE_6_0 (0xA0) 1909#define MPI2_SAS_HWRATE_MAX_RATE_6_0 (0xA0)
1910#define MPI25_SAS_HWRATE_MAX_RATE_12_0 (0xB0)
1900#define MPI2_SAS_HWRATE_MIN_RATE_MASK (0x0F) 1911#define MPI2_SAS_HWRATE_MIN_RATE_MASK (0x0F)
1901#define MPI2_SAS_HWRATE_MIN_RATE_1_5 (0x08) 1912#define MPI2_SAS_HWRATE_MIN_RATE_1_5 (0x08)
1902#define MPI2_SAS_HWRATE_MIN_RATE_3_0 (0x09) 1913#define MPI2_SAS_HWRATE_MIN_RATE_3_0 (0x09)
diff --git a/drivers/scsi/mpt3sas/mpi/mpi2_init.h b/drivers/scsi/mpt3sas/mpi/mpi2_init.h
index a079e5242474..f7928bf66478 100644
--- a/drivers/scsi/mpt3sas/mpi/mpi2_init.h
+++ b/drivers/scsi/mpt3sas/mpi/mpi2_init.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2000-2012 LSI Corporation. 2 * Copyright (c) 2000-2013 LSI Corporation.
3 * 3 *
4 * 4 *
5 * Name: mpi2_init.h 5 * Name: mpi2_init.h
diff --git a/drivers/scsi/mpt3sas/mpi/mpi2_ioc.h b/drivers/scsi/mpt3sas/mpi/mpi2_ioc.h
index 0de425d8fd70..e2bb82143720 100644
--- a/drivers/scsi/mpt3sas/mpi/mpi2_ioc.h
+++ b/drivers/scsi/mpt3sas/mpi/mpi2_ioc.h
@@ -1,12 +1,12 @@
1/* 1/*
2 * Copyright (c) 2000-2012 LSI Corporation. 2 * Copyright (c) 2000-2013 LSI Corporation.
3 * 3 *
4 * 4 *
5 * Name: mpi2_ioc.h 5 * Name: mpi2_ioc.h
6 * Title: MPI IOC, Port, Event, FW Download, and FW Upload messages 6 * Title: MPI IOC, Port, Event, FW Download, and FW Upload messages
7 * Creation Date: October 11, 2006 7 * Creation Date: October 11, 2006
8 * 8 *
9 * mpi2_ioc.h Version: 02.00.21 9 * mpi2_ioc.h Version: 02.00.22
10 * 10 *
11 * NOTE: Names (typedefs, defines, etc.) beginning with an MPI25 or Mpi25 11 * NOTE: Names (typedefs, defines, etc.) beginning with an MPI25 or Mpi25
12 * prefix are for use only on MPI v2.5 products, and must not be used 12 * prefix are for use only on MPI v2.5 products, and must not be used
@@ -124,6 +124,9 @@
124 * Marked MPI2_PM_CONTROL_FEATURE_PCIE_LINK as obsolete. 124 * Marked MPI2_PM_CONTROL_FEATURE_PCIE_LINK as obsolete.
125 * 11-18-11 02.00.20 Incorporating additions for MPI v2.5. 125 * 11-18-11 02.00.20 Incorporating additions for MPI v2.5.
126 * 03-29-12 02.00.21 Added a product specific range to event values. 126 * 03-29-12 02.00.21 Added a product specific range to event values.
127 * 07-26-12 02.00.22 Added MPI2_IOCFACTS_EXCEPT_PARTIAL_MEMORY_FAILURE.
128 * Added ElapsedSeconds field to
129 * MPI2_EVENT_DATA_IR_OPERATION_STATUS.
127 * -------------------------------------------------------------------------- 130 * --------------------------------------------------------------------------
128 */ 131 */
129 132
@@ -283,6 +286,7 @@ typedef struct _MPI2_IOC_FACTS_REPLY {
283#define MPI2_IOCFACTS_HDRVERSION_DEV_SHIFT (0) 286#define MPI2_IOCFACTS_HDRVERSION_DEV_SHIFT (0)
284 287
285/*IOCExceptions */ 288/*IOCExceptions */
289#define MPI2_IOCFACTS_EXCEPT_PARTIAL_MEMORY_FAILURE (0x0200)
286#define MPI2_IOCFACTS_EXCEPT_IR_FOREIGN_CONFIG_MAX (0x0100) 290#define MPI2_IOCFACTS_EXCEPT_IR_FOREIGN_CONFIG_MAX (0x0100)
287 291
288#define MPI2_IOCFACTS_EXCEPT_BOOTSTAT_MASK (0x00E0) 292#define MPI2_IOCFACTS_EXCEPT_BOOTSTAT_MASK (0x00E0)
@@ -634,7 +638,7 @@ typedef struct _MPI2_EVENT_DATA_IR_OPERATION_STATUS {
634 U8 RAIDOperation; /*0x04 */ 638 U8 RAIDOperation; /*0x04 */
635 U8 PercentComplete; /*0x05 */ 639 U8 PercentComplete; /*0x05 */
636 U16 Reserved2; /*0x06 */ 640 U16 Reserved2; /*0x06 */
637 U32 Resereved3; /*0x08 */ 641 U32 ElapsedSeconds; /*0x08 */
638} MPI2_EVENT_DATA_IR_OPERATION_STATUS, 642} MPI2_EVENT_DATA_IR_OPERATION_STATUS,
639 *PTR_MPI2_EVENT_DATA_IR_OPERATION_STATUS, 643 *PTR_MPI2_EVENT_DATA_IR_OPERATION_STATUS,
640 Mpi2EventDataIrOperationStatus_t, 644 Mpi2EventDataIrOperationStatus_t,
diff --git a/drivers/scsi/mpt3sas/mpi/mpi2_raid.h b/drivers/scsi/mpt3sas/mpi/mpi2_raid.h
index d1d9866cf300..71765236afef 100644
--- a/drivers/scsi/mpt3sas/mpi/mpi2_raid.h
+++ b/drivers/scsi/mpt3sas/mpi/mpi2_raid.h
@@ -1,12 +1,12 @@
1/* 1/*
2 * Copyright (c) 2000-2012 LSI Corporation. 2 * Copyright (c) 2000-2013 LSI Corporation.
3 * 3 *
4 * 4 *
5 * Name: mpi2_raid.h 5 * Name: mpi2_raid.h
6 * Title: MPI Integrated RAID messages and structures 6 * Title: MPI Integrated RAID messages and structures
7 * Creation Date: April 26, 2007 7 * Creation Date: April 26, 2007
8 * 8 *
9 * mpi2_raid.h Version: 02.00.08 9 * mpi2_raid.h Version: 02.00.09
10 * 10 *
11 * Version History 11 * Version History
12 * --------------- 12 * ---------------
@@ -28,6 +28,8 @@
28 * Added product-specific range to RAID Action values. 28 * Added product-specific range to RAID Action values.
29 * 11-18-11 02.00.07 Incorporating additions for MPI v2.5. 29 * 11-18-11 02.00.07 Incorporating additions for MPI v2.5.
30 * 02-06-12 02.00.08 Added MPI2_RAID_ACTION_PHYSDISK_HIDDEN. 30 * 02-06-12 02.00.08 Added MPI2_RAID_ACTION_PHYSDISK_HIDDEN.
31 * 07-26-12 02.00.09 Added ElapsedSeconds field to MPI2_RAID_VOL_INDICATOR.
32 * Added MPI2_RAID_VOL_FLAGS_ELAPSED_SECONDS_VALID define.
31 * -------------------------------------------------------------------------- 33 * --------------------------------------------------------------------------
32 */ 34 */
33 35
@@ -269,10 +271,12 @@ typedef struct _MPI2_RAID_VOL_INDICATOR {
269 U64 TotalBlocks; /*0x00 */ 271 U64 TotalBlocks; /*0x00 */
270 U64 BlocksRemaining; /*0x08 */ 272 U64 BlocksRemaining; /*0x08 */
271 U32 Flags; /*0x10 */ 273 U32 Flags; /*0x10 */
274 U32 ElapsedSeconds; /* 0x14 */
272} MPI2_RAID_VOL_INDICATOR, *PTR_MPI2_RAID_VOL_INDICATOR, 275} MPI2_RAID_VOL_INDICATOR, *PTR_MPI2_RAID_VOL_INDICATOR,
273 Mpi2RaidVolIndicator_t, *pMpi2RaidVolIndicator_t; 276 Mpi2RaidVolIndicator_t, *pMpi2RaidVolIndicator_t;
274 277
275/*defines for RAID Volume Indicator Flags field */ 278/*defines for RAID Volume Indicator Flags field */
279#define MPI2_RAID_VOL_FLAGS_ELAPSED_SECONDS_VALID (0x80000000)
276#define MPI2_RAID_VOL_FLAGS_OP_MASK (0x0000000F) 280#define MPI2_RAID_VOL_FLAGS_OP_MASK (0x0000000F)
277#define MPI2_RAID_VOL_FLAGS_OP_BACKGROUND_INIT (0x00000000) 281#define MPI2_RAID_VOL_FLAGS_OP_BACKGROUND_INIT (0x00000000)
278#define MPI2_RAID_VOL_FLAGS_OP_ONLINE_CAP_EXPANSION (0x00000001) 282#define MPI2_RAID_VOL_FLAGS_OP_ONLINE_CAP_EXPANSION (0x00000001)
@@ -312,7 +316,7 @@ typedef struct _MPI2_RAID_COMPATIBILITY_RESULT_STRUCT {
312 316
313/*RAID Action Reply ActionData union */ 317/*RAID Action Reply ActionData union */
314typedef union _MPI2_RAID_ACTION_REPLY_DATA { 318typedef union _MPI2_RAID_ACTION_REPLY_DATA {
315 U32 Word[5]; 319 U32 Word[6];
316 MPI2_RAID_VOL_INDICATOR RaidVolumeIndicator; 320 MPI2_RAID_VOL_INDICATOR RaidVolumeIndicator;
317 U16 VolDevHandle; 321 U16 VolDevHandle;
318 U8 VolumeState; 322 U8 VolumeState;
diff --git a/drivers/scsi/mpt3sas/mpi/mpi2_sas.h b/drivers/scsi/mpt3sas/mpi/mpi2_sas.h
index b4e7084aba31..cba046f6a4b4 100644
--- a/drivers/scsi/mpt3sas/mpi/mpi2_sas.h
+++ b/drivers/scsi/mpt3sas/mpi/mpi2_sas.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2000-2012 LSI Corporation. 2 * Copyright (c) 2000-2013 LSI Corporation.
3 * 3 *
4 * 4 *
5 * Name: mpi2_sas.h 5 * Name: mpi2_sas.h
diff --git a/drivers/scsi/mpt3sas/mpi/mpi2_tool.h b/drivers/scsi/mpt3sas/mpi/mpi2_tool.h
index 71453d11c1c1..34e9a7ba76b0 100644
--- a/drivers/scsi/mpt3sas/mpi/mpi2_tool.h
+++ b/drivers/scsi/mpt3sas/mpi/mpi2_tool.h
@@ -1,12 +1,12 @@
1/* 1/*
2 * Copyright (c) 2000-2012 LSI Corporation. 2 * Copyright (c) 2000-2013 LSI Corporation.
3 * 3 *
4 * 4 *
5 * Name: mpi2_tool.h 5 * Name: mpi2_tool.h
6 * Title: MPI diagnostic tool structures and definitions 6 * Title: MPI diagnostic tool structures and definitions
7 * Creation Date: March 26, 2007 7 * Creation Date: March 26, 2007
8 * 8 *
9 * mpi2_tool.h Version: 02.00.09 9 * mpi2_tool.h Version: 02.00.10
10 * 10 *
11 * Version History 11 * Version History
12 * --------------- 12 * ---------------
@@ -30,6 +30,8 @@
30 * 11-18-11 02.00.08 Incorporating additions for MPI v2.5. 30 * 11-18-11 02.00.08 Incorporating additions for MPI v2.5.
31 * 07-10-12 02.00.09 Add MPI v2.5 Toolbox Diagnostic CLI Tool Request 31 * 07-10-12 02.00.09 Add MPI v2.5 Toolbox Diagnostic CLI Tool Request
32 * message. 32 * message.
33 * 07-26-12 02.00.10 Modified MPI2_TOOLBOX_DIAGNOSTIC_CLI_REQUEST so that
34 * it uses MPI Chain SGE as well as MPI Simple SGE.
33 * -------------------------------------------------------------------------- 35 * --------------------------------------------------------------------------
34 */ 36 */
35 37
@@ -279,7 +281,7 @@ typedef struct _MPI2_TOOLBOX_DIAGNOSTIC_CLI_REQUEST {
279 U16 Reserved6; /*0x0E */ 281 U16 Reserved6; /*0x0E */
280 U32 DataLength; /*0x10 */ 282 U32 DataLength; /*0x10 */
281 U8 DiagnosticCliCommand[MPI2_TOOLBOX_DIAG_CLI_CMD_LENGTH];/*0x14 */ 283 U8 DiagnosticCliCommand[MPI2_TOOLBOX_DIAG_CLI_CMD_LENGTH];/*0x14 */
282 MPI2_SGE_SIMPLE_UNION SGL; /*0x70 */ 284 MPI2_MPI_SGE_IO_UNION SGL; /*0x70 */
283} MPI2_TOOLBOX_DIAGNOSTIC_CLI_REQUEST, 285} MPI2_TOOLBOX_DIAGNOSTIC_CLI_REQUEST,
284 *PTR_MPI2_TOOLBOX_DIAGNOSTIC_CLI_REQUEST, 286 *PTR_MPI2_TOOLBOX_DIAGNOSTIC_CLI_REQUEST,
285 Mpi2ToolboxDiagnosticCliRequest_t, 287 Mpi2ToolboxDiagnosticCliRequest_t,
@@ -302,7 +304,7 @@ typedef struct _MPI25_TOOLBOX_DIAGNOSTIC_CLI_REQUEST {
302 U32 Reserved5; /*0x0C */ 304 U32 Reserved5; /*0x0C */
303 U32 DataLength; /*0x10 */ 305 U32 DataLength; /*0x10 */
304 U8 DiagnosticCliCommand[MPI2_TOOLBOX_DIAG_CLI_CMD_LENGTH];/*0x14 */ 306 U8 DiagnosticCliCommand[MPI2_TOOLBOX_DIAG_CLI_CMD_LENGTH];/*0x14 */
305 MPI25_SGE_IO_UNION SGL; /*0x70 */ 307 MPI25_SGE_IO_UNION SGL; /* 0x70 */
306} MPI25_TOOLBOX_DIAGNOSTIC_CLI_REQUEST, 308} MPI25_TOOLBOX_DIAGNOSTIC_CLI_REQUEST,
307 *PTR_MPI25_TOOLBOX_DIAGNOSTIC_CLI_REQUEST, 309 *PTR_MPI25_TOOLBOX_DIAGNOSTIC_CLI_REQUEST,
308 Mpi25ToolboxDiagnosticCliRequest_t, 310 Mpi25ToolboxDiagnosticCliRequest_t,
diff --git a/drivers/scsi/mpt3sas/mpi/mpi2_type.h b/drivers/scsi/mpt3sas/mpi/mpi2_type.h
index 516f959573f5..ba1fed50966e 100644
--- a/drivers/scsi/mpt3sas/mpi/mpi2_type.h
+++ b/drivers/scsi/mpt3sas/mpi/mpi2_type.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2000-2007 LSI Corporation. 2 * Copyright (c) 2000-2013 LSI Corporation.
3 * 3 *
4 * 4 *
5 * Name: mpi2_type.h 5 * Name: mpi2_type.h
diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c
index 18360032a520..5dc280c75325 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_base.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
@@ -3,7 +3,7 @@
3 * for access to MPT (Message Passing Technology) firmware. 3 * for access to MPT (Message Passing Technology) firmware.
4 * 4 *
5 * This code is based on drivers/scsi/mpt3sas/mpt3sas_base.c 5 * This code is based on drivers/scsi/mpt3sas/mpt3sas_base.c
6 * Copyright (C) 2012 LSI Corporation 6 * Copyright (C) 2012-2013 LSI Corporation
7 * (mailto:DL-MPTFusionLinux@lsi.com) 7 * (mailto:DL-MPTFusionLinux@lsi.com)
8 * 8 *
9 * This program is free software; you can redistribute it and/or 9 * This program is free software; you can redistribute it and/or
@@ -4090,11 +4090,15 @@ _base_diag_reset(struct MPT3SAS_ADAPTER *ioc, int sleep_flag)
4090 writel(host_diagnostic | MPI2_DIAG_RESET_ADAPTER, 4090 writel(host_diagnostic | MPI2_DIAG_RESET_ADAPTER,
4091 &ioc->chip->HostDiagnostic); 4091 &ioc->chip->HostDiagnostic);
4092 4092
4093 /* don't access any registers for 50 milliseconds */ 4093 /*This delay allows the chip PCIe hardware time to finish reset tasks*/
4094 msleep(50); 4094 if (sleep_flag == CAN_SLEEP)
4095 msleep(MPI2_HARD_RESET_PCIE_FIRST_READ_DELAY_MICRO_SEC/1000);
4096 else
4097 mdelay(MPI2_HARD_RESET_PCIE_FIRST_READ_DELAY_MICRO_SEC/1000);
4095 4098
4096 /* 300 second max wait */ 4099 /* Approximately 300 second max wait */
4097 for (count = 0; count < 3000000 ; count++) { 4100 for (count = 0; count < (300000000 /
4101 MPI2_HARD_RESET_PCIE_SECOND_READ_DELAY_MICRO_SEC); count++) {
4098 4102
4099 host_diagnostic = readl(&ioc->chip->HostDiagnostic); 4103 host_diagnostic = readl(&ioc->chip->HostDiagnostic);
4100 4104
@@ -4103,11 +4107,13 @@ _base_diag_reset(struct MPT3SAS_ADAPTER *ioc, int sleep_flag)
4103 if (!(host_diagnostic & MPI2_DIAG_RESET_ADAPTER)) 4107 if (!(host_diagnostic & MPI2_DIAG_RESET_ADAPTER))
4104 break; 4108 break;
4105 4109
4106 /* wait 1 msec */ 4110 /* Wait to pass the second read delay window */
4107 if (sleep_flag == CAN_SLEEP) 4111 if (sleep_flag == CAN_SLEEP)
4108 usleep_range(1000, 1500); 4112 msleep(MPI2_HARD_RESET_PCIE_SECOND_READ_DELAY_MICRO_SEC
4113 / 1000);
4109 else 4114 else
4110 mdelay(1); 4115 mdelay(MPI2_HARD_RESET_PCIE_SECOND_READ_DELAY_MICRO_SEC
4116 / 1000);
4111 } 4117 }
4112 4118
4113 if (host_diagnostic & MPI2_DIAG_HCB_MODE) { 4119 if (host_diagnostic & MPI2_DIAG_HCB_MODE) {
diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h b/drivers/scsi/mpt3sas/mpt3sas_base.h
index 994656cbfac9..0ebf5d913c80 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_base.h
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.h
@@ -3,7 +3,7 @@
3 * for access to MPT (Message Passing Technology) firmware. 3 * for access to MPT (Message Passing Technology) firmware.
4 * 4 *
5 * This code is based on drivers/scsi/mpt3sas/mpt3sas_base.h 5 * This code is based on drivers/scsi/mpt3sas/mpt3sas_base.h
6 * Copyright (C) 2012 LSI Corporation 6 * Copyright (C) 2012-2013 LSI Corporation
7 * (mailto:DL-MPTFusionLinux@lsi.com) 7 * (mailto:DL-MPTFusionLinux@lsi.com)
8 * 8 *
9 * This program is free software; you can redistribute it and/or 9 * This program is free software; you can redistribute it and/or
@@ -70,10 +70,10 @@
70#define MPT3SAS_DRIVER_NAME "mpt3sas" 70#define MPT3SAS_DRIVER_NAME "mpt3sas"
71#define MPT3SAS_AUTHOR "LSI Corporation <DL-MPTFusionLinux@lsi.com>" 71#define MPT3SAS_AUTHOR "LSI Corporation <DL-MPTFusionLinux@lsi.com>"
72#define MPT3SAS_DESCRIPTION "LSI MPT Fusion SAS 3.0 Device Driver" 72#define MPT3SAS_DESCRIPTION "LSI MPT Fusion SAS 3.0 Device Driver"
73#define MPT3SAS_DRIVER_VERSION "01.100.01.00" 73#define MPT3SAS_DRIVER_VERSION "02.100.00.00"
74#define MPT3SAS_MAJOR_VERSION 1 74#define MPT3SAS_MAJOR_VERSION 2
75#define MPT3SAS_MINOR_VERSION 100 75#define MPT3SAS_MINOR_VERSION 100
76#define MPT3SAS_BUILD_VERSION 1 76#define MPT3SAS_BUILD_VERSION 0
77#define MPT3SAS_RELEASE_VERSION 00 77#define MPT3SAS_RELEASE_VERSION 00
78 78
79/* 79/*
diff --git a/drivers/scsi/mpt3sas/mpt3sas_config.c b/drivers/scsi/mpt3sas/mpt3sas_config.c
index 4db0c7a18bd8..936ec0391990 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_config.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_config.c
@@ -2,7 +2,7 @@
2 * This module provides common API for accessing firmware configuration pages 2 * This module provides common API for accessing firmware configuration pages
3 * 3 *
4 * This code is based on drivers/scsi/mpt3sas/mpt3sas_base.c 4 * This code is based on drivers/scsi/mpt3sas/mpt3sas_base.c
5 * Copyright (C) 2012 LSI Corporation 5 * Copyright (C) 2012-2013 LSI Corporation
6 * (mailto:DL-MPTFusionLinux@lsi.com) 6 * (mailto:DL-MPTFusionLinux@lsi.com)
7 * 7 *
8 * This program is free software; you can redistribute it and/or 8 * This program is free software; you can redistribute it and/or
diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.c b/drivers/scsi/mpt3sas/mpt3sas_ctl.c
index 0b402b6f2d26..9b89de14a0a3 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_ctl.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.c
@@ -3,7 +3,7 @@
3 * controllers 3 * controllers
4 * 4 *
5 * This code is based on drivers/scsi/mpt3sas/mpt3sas_ctl.c 5 * This code is based on drivers/scsi/mpt3sas/mpt3sas_ctl.c
6 * Copyright (C) 2012 LSI Corporation 6 * Copyright (C) 2012-2013 LSI Corporation
7 * (mailto:DL-MPTFusionLinux@lsi.com) 7 * (mailto:DL-MPTFusionLinux@lsi.com)
8 * 8 *
9 * This program is free software; you can redistribute it and/or 9 * This program is free software; you can redistribute it and/or
diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.h b/drivers/scsi/mpt3sas/mpt3sas_ctl.h
index bd89f4f00550..53b0c480d98f 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_ctl.h
+++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.h
@@ -3,7 +3,7 @@
3 * controllers 3 * controllers
4 * 4 *
5 * This code is based on drivers/scsi/mpt3sas/mpt3sas_ctl.h 5 * This code is based on drivers/scsi/mpt3sas/mpt3sas_ctl.h
6 * Copyright (C) 2012 LSI Corporation 6 * Copyright (C) 2012-2013 LSI Corporation
7 * (mailto:DL-MPTFusionLinux@lsi.com) 7 * (mailto:DL-MPTFusionLinux@lsi.com)
8 * 8 *
9 * This program is free software; you can redistribute it and/or 9 * This program is free software; you can redistribute it and/or
diff --git a/drivers/scsi/mpt3sas/mpt3sas_debug.h b/drivers/scsi/mpt3sas/mpt3sas_debug.h
index 35405e7044f8..545b22d2cbdf 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_debug.h
+++ b/drivers/scsi/mpt3sas/mpt3sas_debug.h
@@ -2,7 +2,7 @@
2 * Logging Support for MPT (Message Passing Technology) based controllers 2 * Logging Support for MPT (Message Passing Technology) based controllers
3 * 3 *
4 * This code is based on drivers/scsi/mpt3sas/mpt3sas_debug.c 4 * This code is based on drivers/scsi/mpt3sas/mpt3sas_debug.c
5 * Copyright (C) 2012 LSI Corporation 5 * Copyright (C) 2012-2013 LSI Corporation
6 * (mailto:DL-MPTFusionLinux@lsi.com) 6 * (mailto:DL-MPTFusionLinux@lsi.com)
7 * 7 *
8 * This program is free software; you can redistribute it and/or 8 * This program is free software; you can redistribute it and/or
diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
index dcbf7c880cb2..8cbe8fd21fc4 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
@@ -2,7 +2,7 @@
2 * Scsi Host Layer for MPT (Message Passing Technology) based controllers 2 * Scsi Host Layer for MPT (Message Passing Technology) based controllers
3 * 3 *
4 * This code is based on drivers/scsi/mpt3sas/mpt3sas_scsih.c 4 * This code is based on drivers/scsi/mpt3sas/mpt3sas_scsih.c
5 * Copyright (C) 2012 LSI Corporation 5 * Copyright (C) 2012-2013 LSI Corporation
6 * (mailto:DL-MPTFusionLinux@lsi.com) 6 * (mailto:DL-MPTFusionLinux@lsi.com)
7 * 7 *
8 * This program is free software; you can redistribute it and/or 8 * This program is free software; you can redistribute it and/or
@@ -675,11 +675,12 @@ _scsih_sas_device_add(struct MPT3SAS_ADAPTER *ioc,
675 * devices while scanning is turned on due to an oops in 675 * devices while scanning is turned on due to an oops in
676 * scsi_sysfs_add_sdev()->add_device()->sysfs_addrm_start() 676 * scsi_sysfs_add_sdev()->add_device()->sysfs_addrm_start()
677 */ 677 */
678 if (!ioc->is_driver_loading) 678 if (!ioc->is_driver_loading) {
679 mpt3sas_transport_port_remove(ioc, 679 mpt3sas_transport_port_remove(ioc,
680 sas_device->sas_address, 680 sas_device->sas_address,
681 sas_device->sas_address_parent); 681 sas_device->sas_address_parent);
682 _scsih_sas_device_remove(ioc, sas_device); 682 _scsih_sas_device_remove(ioc, sas_device);
683 }
683 } 684 }
684} 685}
685 686
@@ -1273,6 +1274,7 @@ _scsih_slave_alloc(struct scsi_device *sdev)
1273 struct MPT3SAS_DEVICE *sas_device_priv_data; 1274 struct MPT3SAS_DEVICE *sas_device_priv_data;
1274 struct scsi_target *starget; 1275 struct scsi_target *starget;
1275 struct _raid_device *raid_device; 1276 struct _raid_device *raid_device;
1277 struct _sas_device *sas_device;
1276 unsigned long flags; 1278 unsigned long flags;
1277 1279
1278 sas_device_priv_data = kzalloc(sizeof(struct scsi_device), GFP_KERNEL); 1280 sas_device_priv_data = kzalloc(sizeof(struct scsi_device), GFP_KERNEL);
@@ -1301,6 +1303,19 @@ _scsih_slave_alloc(struct scsi_device *sdev)
1301 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); 1303 spin_unlock_irqrestore(&ioc->raid_device_lock, flags);
1302 } 1304 }
1303 1305
1306 if (!(sas_target_priv_data->flags & MPT_TARGET_FLAGS_VOLUME)) {
1307 spin_lock_irqsave(&ioc->sas_device_lock, flags);
1308 sas_device = mpt3sas_scsih_sas_device_find_by_sas_address(ioc,
1309 sas_target_priv_data->sas_address);
1310 if (sas_device && (sas_device->starget == NULL)) {
1311 sdev_printk(KERN_INFO, sdev,
1312 "%s : sas_device->starget set to starget @ %d\n",
1313 __func__, __LINE__);
1314 sas_device->starget = starget;
1315 }
1316 spin_unlock_irqrestore(&ioc->sas_device_lock, flags);
1317 }
1318
1304 return 0; 1319 return 0;
1305} 1320}
1306 1321
@@ -6392,7 +6407,7 @@ _scsih_search_responding_sas_devices(struct MPT3SAS_ADAPTER *ioc)
6392 handle))) { 6407 handle))) {
6393 ioc_status = le16_to_cpu(mpi_reply.IOCStatus) & 6408 ioc_status = le16_to_cpu(mpi_reply.IOCStatus) &
6394 MPI2_IOCSTATUS_MASK; 6409 MPI2_IOCSTATUS_MASK;
6395 if (ioc_status == MPI2_IOCSTATUS_CONFIG_INVALID_PAGE) 6410 if (ioc_status != MPI2_IOCSTATUS_SUCCESS)
6396 break; 6411 break;
6397 handle = le16_to_cpu(sas_device_pg0.DevHandle); 6412 handle = le16_to_cpu(sas_device_pg0.DevHandle);
6398 device_info = le32_to_cpu(sas_device_pg0.DeviceInfo); 6413 device_info = le32_to_cpu(sas_device_pg0.DeviceInfo);
@@ -6494,7 +6509,7 @@ _scsih_search_responding_raid_devices(struct MPT3SAS_ADAPTER *ioc)
6494 &volume_pg1, MPI2_RAID_VOLUME_PGAD_FORM_GET_NEXT_HANDLE, handle))) { 6509 &volume_pg1, MPI2_RAID_VOLUME_PGAD_FORM_GET_NEXT_HANDLE, handle))) {
6495 ioc_status = le16_to_cpu(mpi_reply.IOCStatus) & 6510 ioc_status = le16_to_cpu(mpi_reply.IOCStatus) &
6496 MPI2_IOCSTATUS_MASK; 6511 MPI2_IOCSTATUS_MASK;
6497 if (ioc_status == MPI2_IOCSTATUS_CONFIG_INVALID_PAGE) 6512 if (ioc_status != MPI2_IOCSTATUS_SUCCESS)
6498 break; 6513 break;
6499 handle = le16_to_cpu(volume_pg1.DevHandle); 6514 handle = le16_to_cpu(volume_pg1.DevHandle);
6500 6515
@@ -6518,7 +6533,7 @@ _scsih_search_responding_raid_devices(struct MPT3SAS_ADAPTER *ioc)
6518 phys_disk_num))) { 6533 phys_disk_num))) {
6519 ioc_status = le16_to_cpu(mpi_reply.IOCStatus) & 6534 ioc_status = le16_to_cpu(mpi_reply.IOCStatus) &
6520 MPI2_IOCSTATUS_MASK; 6535 MPI2_IOCSTATUS_MASK;
6521 if (ioc_status == MPI2_IOCSTATUS_CONFIG_INVALID_PAGE) 6536 if (ioc_status != MPI2_IOCSTATUS_SUCCESS)
6522 break; 6537 break;
6523 phys_disk_num = pd_pg0.PhysDiskNum; 6538 phys_disk_num = pd_pg0.PhysDiskNum;
6524 handle = le16_to_cpu(pd_pg0.DevHandle); 6539 handle = le16_to_cpu(pd_pg0.DevHandle);
@@ -6597,7 +6612,7 @@ _scsih_search_responding_expanders(struct MPT3SAS_ADAPTER *ioc)
6597 6612
6598 ioc_status = le16_to_cpu(mpi_reply.IOCStatus) & 6613 ioc_status = le16_to_cpu(mpi_reply.IOCStatus) &
6599 MPI2_IOCSTATUS_MASK; 6614 MPI2_IOCSTATUS_MASK;
6600 if (ioc_status == MPI2_IOCSTATUS_CONFIG_INVALID_PAGE) 6615 if (ioc_status != MPI2_IOCSTATUS_SUCCESS)
6601 break; 6616 break;
6602 6617
6603 handle = le16_to_cpu(expander_pg0.DevHandle); 6618 handle = le16_to_cpu(expander_pg0.DevHandle);
@@ -6742,8 +6757,6 @@ _scsih_scan_for_devices_after_reset(struct MPT3SAS_ADAPTER *ioc)
6742 MPI2_SAS_EXPAND_PGAD_FORM_GET_NEXT_HNDL, handle))) { 6757 MPI2_SAS_EXPAND_PGAD_FORM_GET_NEXT_HNDL, handle))) {
6743 ioc_status = le16_to_cpu(mpi_reply.IOCStatus) & 6758 ioc_status = le16_to_cpu(mpi_reply.IOCStatus) &
6744 MPI2_IOCSTATUS_MASK; 6759 MPI2_IOCSTATUS_MASK;
6745 if (ioc_status == MPI2_IOCSTATUS_CONFIG_INVALID_PAGE)
6746 break;
6747 if (ioc_status != MPI2_IOCSTATUS_SUCCESS) { 6760 if (ioc_status != MPI2_IOCSTATUS_SUCCESS) {
6748 pr_info(MPT3SAS_FMT "\tbreak from expander scan: " \ 6761 pr_info(MPT3SAS_FMT "\tbreak from expander scan: " \
6749 "ioc_status(0x%04x), loginfo(0x%08x)\n", 6762 "ioc_status(0x%04x), loginfo(0x%08x)\n",
@@ -6787,8 +6800,6 @@ _scsih_scan_for_devices_after_reset(struct MPT3SAS_ADAPTER *ioc)
6787 phys_disk_num))) { 6800 phys_disk_num))) {
6788 ioc_status = le16_to_cpu(mpi_reply.IOCStatus) & 6801 ioc_status = le16_to_cpu(mpi_reply.IOCStatus) &
6789 MPI2_IOCSTATUS_MASK; 6802 MPI2_IOCSTATUS_MASK;
6790 if (ioc_status == MPI2_IOCSTATUS_CONFIG_INVALID_PAGE)
6791 break;
6792 if (ioc_status != MPI2_IOCSTATUS_SUCCESS) { 6803 if (ioc_status != MPI2_IOCSTATUS_SUCCESS) {
6793 pr_info(MPT3SAS_FMT "\tbreak from phys disk scan: "\ 6804 pr_info(MPT3SAS_FMT "\tbreak from phys disk scan: "\
6794 "ioc_status(0x%04x), loginfo(0x%08x)\n", 6805 "ioc_status(0x%04x), loginfo(0x%08x)\n",
@@ -6854,8 +6865,6 @@ _scsih_scan_for_devices_after_reset(struct MPT3SAS_ADAPTER *ioc)
6854 &volume_pg1, MPI2_RAID_VOLUME_PGAD_FORM_GET_NEXT_HANDLE, handle))) { 6865 &volume_pg1, MPI2_RAID_VOLUME_PGAD_FORM_GET_NEXT_HANDLE, handle))) {
6855 ioc_status = le16_to_cpu(mpi_reply.IOCStatus) & 6866 ioc_status = le16_to_cpu(mpi_reply.IOCStatus) &
6856 MPI2_IOCSTATUS_MASK; 6867 MPI2_IOCSTATUS_MASK;
6857 if (ioc_status == MPI2_IOCSTATUS_CONFIG_INVALID_PAGE)
6858 break;
6859 if (ioc_status != MPI2_IOCSTATUS_SUCCESS) { 6868 if (ioc_status != MPI2_IOCSTATUS_SUCCESS) {
6860 pr_info(MPT3SAS_FMT "\tbreak from volume scan: " \ 6869 pr_info(MPT3SAS_FMT "\tbreak from volume scan: " \
6861 "ioc_status(0x%04x), loginfo(0x%08x)\n", 6870 "ioc_status(0x%04x), loginfo(0x%08x)\n",
@@ -6914,8 +6923,6 @@ _scsih_scan_for_devices_after_reset(struct MPT3SAS_ADAPTER *ioc)
6914 handle))) { 6923 handle))) {
6915 ioc_status = le16_to_cpu(mpi_reply.IOCStatus) & 6924 ioc_status = le16_to_cpu(mpi_reply.IOCStatus) &
6916 MPI2_IOCSTATUS_MASK; 6925 MPI2_IOCSTATUS_MASK;
6917 if (ioc_status == MPI2_IOCSTATUS_CONFIG_INVALID_PAGE)
6918 break;
6919 if (ioc_status != MPI2_IOCSTATUS_SUCCESS) { 6926 if (ioc_status != MPI2_IOCSTATUS_SUCCESS) {
6920 pr_info(MPT3SAS_FMT "\tbreak from end device scan:"\ 6927 pr_info(MPT3SAS_FMT "\tbreak from end device scan:"\
6921 " ioc_status(0x%04x), loginfo(0x%08x)\n", 6928 " ioc_status(0x%04x), loginfo(0x%08x)\n",
@@ -7525,10 +7532,12 @@ _scsih_probe_boot_devices(struct MPT3SAS_ADAPTER *ioc)
7525 sas_address_parent)) { 7532 sas_address_parent)) {
7526 _scsih_sas_device_remove(ioc, sas_device); 7533 _scsih_sas_device_remove(ioc, sas_device);
7527 } else if (!sas_device->starget) { 7534 } else if (!sas_device->starget) {
7528 if (!ioc->is_driver_loading) 7535 if (!ioc->is_driver_loading) {
7529 mpt3sas_transport_port_remove(ioc, sas_address, 7536 mpt3sas_transport_port_remove(ioc,
7537 sas_address,
7530 sas_address_parent); 7538 sas_address_parent);
7531 _scsih_sas_device_remove(ioc, sas_device); 7539 _scsih_sas_device_remove(ioc, sas_device);
7540 }
7532 } 7541 }
7533 } 7542 }
7534} 7543}
@@ -7584,13 +7593,14 @@ _scsih_probe_sas(struct MPT3SAS_ADAPTER *ioc)
7584 * oops in scsi_sysfs_add_sdev()->add_device()-> 7593 * oops in scsi_sysfs_add_sdev()->add_device()->
7585 * sysfs_addrm_start() 7594 * sysfs_addrm_start()
7586 */ 7595 */
7587 if (!ioc->is_driver_loading) 7596 if (!ioc->is_driver_loading) {
7588 mpt3sas_transport_port_remove(ioc, 7597 mpt3sas_transport_port_remove(ioc,
7589 sas_device->sas_address, 7598 sas_device->sas_address,
7590 sas_device->sas_address_parent); 7599 sas_device->sas_address_parent);
7591 list_del(&sas_device->list); 7600 list_del(&sas_device->list);
7592 kfree(sas_device); 7601 kfree(sas_device);
7593 continue; 7602 continue;
7603 }
7594 } 7604 }
7595 7605
7596 spin_lock_irqsave(&ioc->sas_device_lock, flags); 7606 spin_lock_irqsave(&ioc->sas_device_lock, flags);
diff --git a/drivers/scsi/mpt3sas/mpt3sas_transport.c b/drivers/scsi/mpt3sas/mpt3sas_transport.c
index 87ca2b7287c3..dcadd56860ff 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_transport.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_transport.c
@@ -2,7 +2,7 @@
2 * SAS Transport Layer for MPT (Message Passing Technology) based controllers 2 * SAS Transport Layer for MPT (Message Passing Technology) based controllers
3 * 3 *
4 * This code is based on drivers/scsi/mpt3sas/mpt3sas_transport.c 4 * This code is based on drivers/scsi/mpt3sas/mpt3sas_transport.c
5 * Copyright (C) 2012 LSI Corporation 5 * Copyright (C) 2012-2013 LSI Corporation
6 * (mailto:DL-MPTFusionLinux@lsi.com) 6 * (mailto:DL-MPTFusionLinux@lsi.com)
7 * 7 *
8 * This program is free software; you can redistribute it and/or 8 * This program is free software; you can redistribute it and/or
diff --git a/drivers/scsi/mpt3sas/mpt3sas_trigger_diag.c b/drivers/scsi/mpt3sas/mpt3sas_trigger_diag.c
index 6f8d6213040b..f6533ab20364 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_trigger_diag.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_trigger_diag.c
@@ -3,7 +3,7 @@
3 * (Message Passing Technology) based controllers 3 * (Message Passing Technology) based controllers
4 * 4 *
5 * This code is based on drivers/scsi/mpt3sas/mpt3sas_trigger_diag.c 5 * This code is based on drivers/scsi/mpt3sas/mpt3sas_trigger_diag.c
6 * Copyright (C) 2012 LSI Corporation 6 * Copyright (C) 2012-2013 LSI Corporation
7 * (mailto:DL-MPTFusionLinux@lsi.com) 7 * (mailto:DL-MPTFusionLinux@lsi.com)
8 * 8 *
9 * This program is free software; you can redistribute it and/or 9 * This program is free software; you can redistribute it and/or
diff --git a/drivers/scsi/mpt3sas/mpt3sas_trigger_diag.h b/drivers/scsi/mpt3sas/mpt3sas_trigger_diag.h
index a10c30907394..bb693923bef1 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_trigger_diag.h
+++ b/drivers/scsi/mpt3sas/mpt3sas_trigger_diag.h
@@ -4,7 +4,7 @@
4 * controllers 4 * controllers
5 * 5 *
6 * This code is based on drivers/scsi/mpt3sas/mpt3sas_base.h 6 * This code is based on drivers/scsi/mpt3sas/mpt3sas_base.h
7 * Copyright (C) 2012 LSI Corporation 7 * Copyright (C) 2012-2013 LSI Corporation
8 * (mailto:DL-MPTFusionLinux@lsi.com) 8 * (mailto:DL-MPTFusionLinux@lsi.com)
9 * 9 *
10 * This program is free software; you can redistribute it and/or 10 * This program is free software; you can redistribute it and/or
diff --git a/drivers/scsi/pm8001/pm8001_init.c b/drivers/scsi/pm8001/pm8001_init.c
index e4b9bc7f5410..3861aa1f4520 100644
--- a/drivers/scsi/pm8001/pm8001_init.c
+++ b/drivers/scsi/pm8001/pm8001_init.c
@@ -912,14 +912,13 @@ static int pm8001_pci_suspend(struct pci_dev *pdev, pm_message_t state)
912{ 912{
913 struct sas_ha_struct *sha = pci_get_drvdata(pdev); 913 struct sas_ha_struct *sha = pci_get_drvdata(pdev);
914 struct pm8001_hba_info *pm8001_ha; 914 struct pm8001_hba_info *pm8001_ha;
915 int i , pos; 915 int i;
916 u32 device_state; 916 u32 device_state;
917 pm8001_ha = sha->lldd_ha; 917 pm8001_ha = sha->lldd_ha;
918 flush_workqueue(pm8001_wq); 918 flush_workqueue(pm8001_wq);
919 scsi_block_requests(pm8001_ha->shost); 919 scsi_block_requests(pm8001_ha->shost);
920 pos = pci_find_capability(pdev, PCI_CAP_ID_PM); 920 if (!pdev->pm_cap) {
921 if (pos == 0) { 921 dev_err(&pdev->dev, " PCI PM not supported\n");
922 printk(KERN_ERR " PCI PM not supported\n");
923 return -ENODEV; 922 return -ENODEV;
924 } 923 }
925 PM8001_CHIP_DISP->interrupt_disable(pm8001_ha, 0xFF); 924 PM8001_CHIP_DISP->interrupt_disable(pm8001_ha, 0xFF);
diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index bf60c631abb5..d7a99ae7f39d 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -1691,6 +1691,9 @@ qla2x00_get_fc_host_stats(struct Scsi_Host *shost)
1691 if (unlikely(pci_channel_offline(ha->pdev))) 1691 if (unlikely(pci_channel_offline(ha->pdev)))
1692 goto done; 1692 goto done;
1693 1693
1694 if (qla2x00_reset_active(vha))
1695 goto done;
1696
1694 stats = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &stats_dma); 1697 stats = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &stats_dma);
1695 if (stats == NULL) { 1698 if (stats == NULL) {
1696 ql_log(ql_log_warn, vha, 0x707d, 1699 ql_log(ql_log_warn, vha, 0x707d,
@@ -1703,7 +1706,7 @@ qla2x00_get_fc_host_stats(struct Scsi_Host *shost)
1703 if (IS_FWI2_CAPABLE(ha)) { 1706 if (IS_FWI2_CAPABLE(ha)) {
1704 rval = qla24xx_get_isp_stats(base_vha, stats, stats_dma); 1707 rval = qla24xx_get_isp_stats(base_vha, stats, stats_dma);
1705 } else if (atomic_read(&base_vha->loop_state) == LOOP_READY && 1708 } else if (atomic_read(&base_vha->loop_state) == LOOP_READY &&
1706 !qla2x00_reset_active(vha) && !ha->dpc_active) { 1709 !ha->dpc_active) {
1707 /* Must be in a 'READY' state for statistics retrieval. */ 1710 /* Must be in a 'READY' state for statistics retrieval. */
1708 rval = qla2x00_get_link_status(base_vha, base_vha->loop_id, 1711 rval = qla2x00_get_link_status(base_vha, base_vha->loop_id,
1709 stats, stats_dma); 1712 stats, stats_dma);
diff --git a/drivers/scsi/qla2xxx/qla_bsg.c b/drivers/scsi/qla2xxx/qla_bsg.c
index 39719f892488..417eaad50ae2 100644
--- a/drivers/scsi/qla2xxx/qla_bsg.c
+++ b/drivers/scsi/qla2xxx/qla_bsg.c
@@ -269,6 +269,12 @@ qla2x00_process_els(struct fc_bsg_job *bsg_job)
269 type = "FC_BSG_HST_ELS_NOLOGIN"; 269 type = "FC_BSG_HST_ELS_NOLOGIN";
270 } 270 }
271 271
272 if (!vha->flags.online) {
273 ql_log(ql_log_warn, vha, 0x7005, "Host not online.\n");
274 rval = -EIO;
275 goto done;
276 }
277
272 /* pass through is supported only for ISP 4Gb or higher */ 278 /* pass through is supported only for ISP 4Gb or higher */
273 if (!IS_FWI2_CAPABLE(ha)) { 279 if (!IS_FWI2_CAPABLE(ha)) {
274 ql_dbg(ql_dbg_user, vha, 0x7001, 280 ql_dbg(ql_dbg_user, vha, 0x7001,
@@ -326,12 +332,6 @@ qla2x00_process_els(struct fc_bsg_job *bsg_job)
326 NPH_FABRIC_CONTROLLER : NPH_F_PORT; 332 NPH_FABRIC_CONTROLLER : NPH_F_PORT;
327 } 333 }
328 334
329 if (!vha->flags.online) {
330 ql_log(ql_log_warn, vha, 0x7005, "Host not online.\n");
331 rval = -EIO;
332 goto done;
333 }
334
335 req_sg_cnt = 335 req_sg_cnt =
336 dma_map_sg(&ha->pdev->dev, bsg_job->request_payload.sg_list, 336 dma_map_sg(&ha->pdev->dev, bsg_job->request_payload.sg_list,
337 bsg_job->request_payload.sg_cnt, DMA_TO_DEVICE); 337 bsg_job->request_payload.sg_cnt, DMA_TO_DEVICE);
@@ -399,7 +399,7 @@ done_unmap_sg:
399 goto done_free_fcport; 399 goto done_free_fcport;
400 400
401done_free_fcport: 401done_free_fcport:
402 if (bsg_job->request->msgcode == FC_BSG_HST_ELS_NOLOGIN) 402 if (bsg_job->request->msgcode == FC_BSG_RPT_ELS)
403 kfree(fcport); 403 kfree(fcport);
404done: 404done:
405 return rval; 405 return rval;
@@ -1084,14 +1084,6 @@ qla84xx_mgmt_cmd(struct fc_bsg_job *bsg_job)
1084 return -EINVAL; 1084 return -EINVAL;
1085 } 1085 }
1086 1086
1087 ql84_mgmt = (struct qla_bsg_a84_mgmt *)((char *)bsg_job->request +
1088 sizeof(struct fc_bsg_request));
1089 if (!ql84_mgmt) {
1090 ql_log(ql_log_warn, vha, 0x703b,
1091 "MGMT header not provided, exiting.\n");
1092 return -EINVAL;
1093 }
1094
1095 mn = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &mn_dma); 1087 mn = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &mn_dma);
1096 if (!mn) { 1088 if (!mn) {
1097 ql_log(ql_log_warn, vha, 0x703c, 1089 ql_log(ql_log_warn, vha, 0x703c,
@@ -1102,7 +1094,7 @@ qla84xx_mgmt_cmd(struct fc_bsg_job *bsg_job)
1102 memset(mn, 0, sizeof(struct access_chip_84xx)); 1094 memset(mn, 0, sizeof(struct access_chip_84xx));
1103 mn->entry_type = ACCESS_CHIP_IOCB_TYPE; 1095 mn->entry_type = ACCESS_CHIP_IOCB_TYPE;
1104 mn->entry_count = 1; 1096 mn->entry_count = 1;
1105 1097 ql84_mgmt = (void *)bsg_job->request + sizeof(struct fc_bsg_request);
1106 switch (ql84_mgmt->mgmt.cmd) { 1098 switch (ql84_mgmt->mgmt.cmd) {
1107 case QLA84_MGMT_READ_MEM: 1099 case QLA84_MGMT_READ_MEM:
1108 case QLA84_MGMT_GET_INFO: 1100 case QLA84_MGMT_GET_INFO:
@@ -1282,14 +1274,7 @@ qla24xx_iidma(struct fc_bsg_job *bsg_job)
1282 return -EINVAL; 1274 return -EINVAL;
1283 } 1275 }
1284 1276
1285 port_param = (struct qla_port_param *)((char *)bsg_job->request + 1277 port_param = (void *)bsg_job->request + sizeof(struct fc_bsg_request);
1286 sizeof(struct fc_bsg_request));
1287 if (!port_param) {
1288 ql_log(ql_log_warn, vha, 0x7047,
1289 "port_param header not provided.\n");
1290 return -EINVAL;
1291 }
1292
1293 if (port_param->fc_scsi_addr.dest_type != EXT_DEF_TYPE_WWPN) { 1278 if (port_param->fc_scsi_addr.dest_type != EXT_DEF_TYPE_WWPN) {
1294 ql_log(ql_log_warn, vha, 0x7048, 1279 ql_log(ql_log_warn, vha, 0x7048,
1295 "Invalid destination type.\n"); 1280 "Invalid destination type.\n");
@@ -2153,6 +2138,7 @@ qla24xx_bsg_timeout(struct fc_bsg_job *bsg_job)
2153 (sp->type == SRB_ELS_CMD_HST) || 2138 (sp->type == SRB_ELS_CMD_HST) ||
2154 (sp->type == SRB_FXIOCB_BCMD)) 2139 (sp->type == SRB_FXIOCB_BCMD))
2155 && (sp->u.bsg_job == bsg_job)) { 2140 && (sp->u.bsg_job == bsg_job)) {
2141 req->outstanding_cmds[cnt] = NULL;
2156 spin_unlock_irqrestore(&ha->hardware_lock, flags); 2142 spin_unlock_irqrestore(&ha->hardware_lock, flags);
2157 if (ha->isp_ops->abort_command(sp)) { 2143 if (ha->isp_ops->abort_command(sp)) {
2158 ql_log(ql_log_warn, vha, 0x7089, 2144 ql_log(ql_log_warn, vha, 0x7089,
@@ -2180,8 +2166,6 @@ qla24xx_bsg_timeout(struct fc_bsg_job *bsg_job)
2180 2166
2181done: 2167done:
2182 spin_unlock_irqrestore(&ha->hardware_lock, flags); 2168 spin_unlock_irqrestore(&ha->hardware_lock, flags);
2183 if (bsg_job->request->msgcode == FC_BSG_HST_CT) 2169 sp->free(vha, sp);
2184 kfree(sp->fcport);
2185 qla2x00_rel_sp(vha, sp);
2186 return 0; 2170 return 0;
2187} 2171}
diff --git a/drivers/scsi/qla2xxx/qla_dbg.c b/drivers/scsi/qla2xxx/qla_dbg.c
index cfa2a20dee97..df132fec6d86 100644
--- a/drivers/scsi/qla2xxx/qla_dbg.c
+++ b/drivers/scsi/qla2xxx/qla_dbg.c
@@ -12,9 +12,10 @@
12 * | Level | Last Value Used | Holes | 12 * | Level | Last Value Used | Holes |
13 * ---------------------------------------------------------------------- 13 * ----------------------------------------------------------------------
14 * | Module Init and Probe | 0x014f | 0x4b,0xba,0xfa | 14 * | Module Init and Probe | 0x014f | 0x4b,0xba,0xfa |
15 * | Mailbox commands | 0x1179 | 0x111a-0x111b | 15 * | Mailbox commands | 0x117a | 0x111a-0x111b |
16 * | | | 0x1155-0x1158 | 16 * | | | 0x1155-0x1158 |
17 * | Device Discovery | 0x2095 | 0x2020-0x2022, | 17 * | Device Discovery | 0x2095 | 0x2020-0x2022, |
18 * | | | 0x2011-0x2012, |
18 * | | | 0x2016 | 19 * | | | 0x2016 |
19 * | Queue Command and IO tracing | 0x3058 | 0x3006-0x300b | 20 * | Queue Command and IO tracing | 0x3058 | 0x3006-0x300b |
20 * | | | 0x3027-0x3028 | 21 * | | | 0x3027-0x3028 |
@@ -35,7 +36,8 @@
35 * | | | 0x70a5,0x70a6, | 36 * | | | 0x70a5,0x70a6, |
36 * | | | 0x70a8,0x70ab, | 37 * | | | 0x70a8,0x70ab, |
37 * | | | 0x70ad-0x70ae, | 38 * | | | 0x70ad-0x70ae, |
38 * | | | 0x70d1-0x70da | 39 * | | | 0x70d1-0x70da, |
40 * | | | 0x7047,0x703b |
39 * | Task Management | 0x803c | 0x8025-0x8026 | 41 * | Task Management | 0x803c | 0x8025-0x8026 |
40 * | | | 0x800b,0x8039 | 42 * | | | 0x800b,0x8039 |
41 * | AER/EEH | 0x9011 | | 43 * | AER/EEH | 0x9011 | |
@@ -1468,7 +1470,7 @@ qla25xx_fw_dump(scsi_qla_host_t *vha, int hardware_locked)
1468 1470
1469 nxt = qla2xxx_copy_queues(ha, nxt); 1471 nxt = qla2xxx_copy_queues(ha, nxt);
1470 1472
1471 nxt = qla24xx_copy_eft(ha, nxt); 1473 qla24xx_copy_eft(ha, nxt);
1472 1474
1473 /* Chain entries -- started with MQ. */ 1475 /* Chain entries -- started with MQ. */
1474 nxt_chain = qla25xx_copy_fce(ha, nxt_chain, &last_chain); 1476 nxt_chain = qla25xx_copy_fce(ha, nxt_chain, &last_chain);
@@ -1787,7 +1789,7 @@ qla81xx_fw_dump(scsi_qla_host_t *vha, int hardware_locked)
1787 1789
1788 nxt = qla2xxx_copy_queues(ha, nxt); 1790 nxt = qla2xxx_copy_queues(ha, nxt);
1789 1791
1790 nxt = qla24xx_copy_eft(ha, nxt); 1792 qla24xx_copy_eft(ha, nxt);
1791 1793
1792 /* Chain entries -- started with MQ. */ 1794 /* Chain entries -- started with MQ. */
1793 nxt_chain = qla25xx_copy_fce(ha, nxt_chain, &last_chain); 1795 nxt_chain = qla25xx_copy_fce(ha, nxt_chain, &last_chain);
@@ -2289,7 +2291,7 @@ qla83xx_fw_dump(scsi_qla_host_t *vha, int hardware_locked)
2289copy_queue: 2291copy_queue:
2290 nxt = qla2xxx_copy_queues(ha, nxt); 2292 nxt = qla2xxx_copy_queues(ha, nxt);
2291 2293
2292 nxt = qla24xx_copy_eft(ha, nxt); 2294 qla24xx_copy_eft(ha, nxt);
2293 2295
2294 /* Chain entries -- started with MQ. */ 2296 /* Chain entries -- started with MQ. */
2295 nxt_chain = qla25xx_copy_fce(ha, nxt_chain, &last_chain); 2297 nxt_chain = qla25xx_copy_fce(ha, nxt_chain, &last_chain);
diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index c32efc753229..95ca32a71e75 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -323,7 +323,7 @@ struct srb_iocb {
323 uint32_t lun; 323 uint32_t lun;
324 uint32_t data; 324 uint32_t data;
325 struct completion comp; 325 struct completion comp;
326 uint32_t comp_status; 326 __le16 comp_status;
327 } tmf; 327 } tmf;
328 struct { 328 struct {
329#define SRB_FXDISC_REQ_DMA_VALID BIT_0 329#define SRB_FXDISC_REQ_DMA_VALID BIT_0
@@ -338,21 +338,21 @@ struct srb_iocb {
338 void *rsp_addr; 338 void *rsp_addr;
339 dma_addr_t req_dma_handle; 339 dma_addr_t req_dma_handle;
340 dma_addr_t rsp_dma_handle; 340 dma_addr_t rsp_dma_handle;
341 uint32_t adapter_id; 341 __le32 adapter_id;
342 uint32_t adapter_id_hi; 342 __le32 adapter_id_hi;
343 uint32_t req_func_type; 343 __le16 req_func_type;
344 uint32_t req_data; 344 __le32 req_data;
345 uint32_t req_data_extra; 345 __le32 req_data_extra;
346 uint32_t result; 346 __le32 result;
347 uint32_t seq_number; 347 __le32 seq_number;
348 uint32_t fw_flags; 348 __le16 fw_flags;
349 struct completion fxiocb_comp; 349 struct completion fxiocb_comp;
350 uint32_t reserved_0; 350 __le32 reserved_0;
351 uint8_t reserved_1; 351 uint8_t reserved_1;
352 } fxiocb; 352 } fxiocb;
353 struct { 353 struct {
354 uint32_t cmd_hndl; 354 uint32_t cmd_hndl;
355 uint32_t comp_status; 355 __le16 comp_status;
356 struct completion comp; 356 struct completion comp;
357 } abt; 357 } abt;
358 } u; 358 } u;
@@ -1196,14 +1196,14 @@ typedef struct {
1196struct init_cb_fx { 1196struct init_cb_fx {
1197 uint16_t version; 1197 uint16_t version;
1198 uint16_t reserved_1[13]; 1198 uint16_t reserved_1[13];
1199 uint16_t request_q_outpointer; 1199 __le16 request_q_outpointer;
1200 uint16_t response_q_inpointer; 1200 __le16 response_q_inpointer;
1201 uint16_t reserved_2[2]; 1201 uint16_t reserved_2[2];
1202 uint16_t response_q_length; 1202 __le16 response_q_length;
1203 uint16_t request_q_length; 1203 __le16 request_q_length;
1204 uint16_t reserved_3[2]; 1204 uint16_t reserved_3[2];
1205 uint32_t request_q_address[2]; 1205 __le32 request_q_address[2];
1206 uint32_t response_q_address[2]; 1206 __le32 response_q_address[2];
1207 uint16_t reserved_4[4]; 1207 uint16_t reserved_4[4];
1208 uint8_t response_q_msivec; 1208 uint8_t response_q_msivec;
1209 uint8_t reserved_5[19]; 1209 uint8_t reserved_5[19];
diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
index 026bfde33e67..2d98232a08eb 100644
--- a/drivers/scsi/qla2xxx/qla_gbl.h
+++ b/drivers/scsi/qla2xxx/qla_gbl.h
@@ -587,7 +587,7 @@ extern int qlafx00_init_firmware(scsi_qla_host_t *, uint16_t);
587extern int qlafx00_fw_ready(scsi_qla_host_t *); 587extern int qlafx00_fw_ready(scsi_qla_host_t *);
588extern int qlafx00_configure_devices(scsi_qla_host_t *); 588extern int qlafx00_configure_devices(scsi_qla_host_t *);
589extern int qlafx00_reset_initialize(scsi_qla_host_t *); 589extern int qlafx00_reset_initialize(scsi_qla_host_t *);
590extern int qlafx00_fx_disc(scsi_qla_host_t *, fc_port_t *, uint8_t); 590extern int qlafx00_fx_disc(scsi_qla_host_t *, fc_port_t *, uint16_t);
591extern int qlafx00_process_aen(struct scsi_qla_host *, struct qla_work_evt *); 591extern int qlafx00_process_aen(struct scsi_qla_host *, struct qla_work_evt *);
592extern int qlafx00_post_aenfx_work(struct scsi_qla_host *, uint32_t, 592extern int qlafx00_post_aenfx_work(struct scsi_qla_host *, uint32_t,
593 uint32_t *, int); 593 uint32_t *, int);
diff --git a/drivers/scsi/qla2xxx/qla_gs.c b/drivers/scsi/qla2xxx/qla_gs.c
index d0ea8b921177..0926451980ed 100644
--- a/drivers/scsi/qla2xxx/qla_gs.c
+++ b/drivers/scsi/qla2xxx/qla_gs.c
@@ -99,17 +99,17 @@ qla24xx_prep_ms_iocb(scsi_qla_host_t *vha, uint32_t req_size, uint32_t rsp_size)
99 * Returns a pointer to the intitialized @ct_req. 99 * Returns a pointer to the intitialized @ct_req.
100 */ 100 */
101static inline struct ct_sns_req * 101static inline struct ct_sns_req *
102qla2x00_prep_ct_req(struct ct_sns_req *ct_req, uint16_t cmd, uint16_t rsp_size) 102qla2x00_prep_ct_req(struct ct_sns_pkt *p, uint16_t cmd, uint16_t rsp_size)
103{ 103{
104 memset(ct_req, 0, sizeof(struct ct_sns_pkt)); 104 memset(p, 0, sizeof(struct ct_sns_pkt));
105 105
106 ct_req->header.revision = 0x01; 106 p->p.req.header.revision = 0x01;
107 ct_req->header.gs_type = 0xFC; 107 p->p.req.header.gs_type = 0xFC;
108 ct_req->header.gs_subtype = 0x02; 108 p->p.req.header.gs_subtype = 0x02;
109 ct_req->command = cpu_to_be16(cmd); 109 p->p.req.command = cpu_to_be16(cmd);
110 ct_req->max_rsp_size = cpu_to_be16((rsp_size - 16) / 4); 110 p->p.req.max_rsp_size = cpu_to_be16((rsp_size - 16) / 4);
111 111
112 return (ct_req); 112 return &p->p.req;
113} 113}
114 114
115static int 115static int
@@ -188,7 +188,7 @@ qla2x00_ga_nxt(scsi_qla_host_t *vha, fc_port_t *fcport)
188 GA_NXT_RSP_SIZE); 188 GA_NXT_RSP_SIZE);
189 189
190 /* Prepare CT request */ 190 /* Prepare CT request */
191 ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GA_NXT_CMD, 191 ct_req = qla2x00_prep_ct_req(ha->ct_sns, GA_NXT_CMD,
192 GA_NXT_RSP_SIZE); 192 GA_NXT_RSP_SIZE);
193 ct_rsp = &ha->ct_sns->p.rsp; 193 ct_rsp = &ha->ct_sns->p.rsp;
194 194
@@ -284,8 +284,7 @@ qla2x00_gid_pt(scsi_qla_host_t *vha, sw_info_t *list)
284 gid_pt_rsp_size); 284 gid_pt_rsp_size);
285 285
286 /* Prepare CT request */ 286 /* Prepare CT request */
287 ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GID_PT_CMD, 287 ct_req = qla2x00_prep_ct_req(ha->ct_sns, GID_PT_CMD, gid_pt_rsp_size);
288 gid_pt_rsp_size);
289 ct_rsp = &ha->ct_sns->p.rsp; 288 ct_rsp = &ha->ct_sns->p.rsp;
290 289
291 /* Prepare CT arguments -- port_type */ 290 /* Prepare CT arguments -- port_type */
@@ -359,7 +358,7 @@ qla2x00_gpn_id(scsi_qla_host_t *vha, sw_info_t *list)
359 GPN_ID_RSP_SIZE); 358 GPN_ID_RSP_SIZE);
360 359
361 /* Prepare CT request */ 360 /* Prepare CT request */
362 ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GPN_ID_CMD, 361 ct_req = qla2x00_prep_ct_req(ha->ct_sns, GPN_ID_CMD,
363 GPN_ID_RSP_SIZE); 362 GPN_ID_RSP_SIZE);
364 ct_rsp = &ha->ct_sns->p.rsp; 363 ct_rsp = &ha->ct_sns->p.rsp;
365 364
@@ -421,7 +420,7 @@ qla2x00_gnn_id(scsi_qla_host_t *vha, sw_info_t *list)
421 GNN_ID_RSP_SIZE); 420 GNN_ID_RSP_SIZE);
422 421
423 /* Prepare CT request */ 422 /* Prepare CT request */
424 ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GNN_ID_CMD, 423 ct_req = qla2x00_prep_ct_req(ha->ct_sns, GNN_ID_CMD,
425 GNN_ID_RSP_SIZE); 424 GNN_ID_RSP_SIZE);
426 ct_rsp = &ha->ct_sns->p.rsp; 425 ct_rsp = &ha->ct_sns->p.rsp;
427 426
@@ -495,7 +494,7 @@ qla2x00_rft_id(scsi_qla_host_t *vha)
495 RFT_ID_RSP_SIZE); 494 RFT_ID_RSP_SIZE);
496 495
497 /* Prepare CT request */ 496 /* Prepare CT request */
498 ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RFT_ID_CMD, 497 ct_req = qla2x00_prep_ct_req(ha->ct_sns, RFT_ID_CMD,
499 RFT_ID_RSP_SIZE); 498 RFT_ID_RSP_SIZE);
500 ct_rsp = &ha->ct_sns->p.rsp; 499 ct_rsp = &ha->ct_sns->p.rsp;
501 500
@@ -551,7 +550,7 @@ qla2x00_rff_id(scsi_qla_host_t *vha)
551 RFF_ID_RSP_SIZE); 550 RFF_ID_RSP_SIZE);
552 551
553 /* Prepare CT request */ 552 /* Prepare CT request */
554 ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RFF_ID_CMD, 553 ct_req = qla2x00_prep_ct_req(ha->ct_sns, RFF_ID_CMD,
555 RFF_ID_RSP_SIZE); 554 RFF_ID_RSP_SIZE);
556 ct_rsp = &ha->ct_sns->p.rsp; 555 ct_rsp = &ha->ct_sns->p.rsp;
557 556
@@ -606,8 +605,7 @@ qla2x00_rnn_id(scsi_qla_host_t *vha)
606 RNN_ID_RSP_SIZE); 605 RNN_ID_RSP_SIZE);
607 606
608 /* Prepare CT request */ 607 /* Prepare CT request */
609 ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RNN_ID_CMD, 608 ct_req = qla2x00_prep_ct_req(ha->ct_sns, RNN_ID_CMD, RNN_ID_RSP_SIZE);
610 RNN_ID_RSP_SIZE);
611 ct_rsp = &ha->ct_sns->p.rsp; 609 ct_rsp = &ha->ct_sns->p.rsp;
612 610
613 /* Prepare CT arguments -- port_id, node_name */ 611 /* Prepare CT arguments -- port_id, node_name */
@@ -676,7 +674,7 @@ qla2x00_rsnn_nn(scsi_qla_host_t *vha)
676 ms_pkt = ha->isp_ops->prep_ms_iocb(vha, 0, RSNN_NN_RSP_SIZE); 674 ms_pkt = ha->isp_ops->prep_ms_iocb(vha, 0, RSNN_NN_RSP_SIZE);
677 675
678 /* Prepare CT request */ 676 /* Prepare CT request */
679 ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RSNN_NN_CMD, 677 ct_req = qla2x00_prep_ct_req(ha->ct_sns, RSNN_NN_CMD,
680 RSNN_NN_RSP_SIZE); 678 RSNN_NN_RSP_SIZE);
681 ct_rsp = &ha->ct_sns->p.rsp; 679 ct_rsp = &ha->ct_sns->p.rsp;
682 680
@@ -1262,18 +1260,18 @@ qla2x00_update_ms_fdmi_iocb(scsi_qla_host_t *vha, uint32_t req_size)
1262 * Returns a pointer to the intitialized @ct_req. 1260 * Returns a pointer to the intitialized @ct_req.
1263 */ 1261 */
1264static inline struct ct_sns_req * 1262static inline struct ct_sns_req *
1265qla2x00_prep_ct_fdmi_req(struct ct_sns_req *ct_req, uint16_t cmd, 1263qla2x00_prep_ct_fdmi_req(struct ct_sns_pkt *p, uint16_t cmd,
1266 uint16_t rsp_size) 1264 uint16_t rsp_size)
1267{ 1265{
1268 memset(ct_req, 0, sizeof(struct ct_sns_pkt)); 1266 memset(p, 0, sizeof(struct ct_sns_pkt));
1269 1267
1270 ct_req->header.revision = 0x01; 1268 p->p.req.header.revision = 0x01;
1271 ct_req->header.gs_type = 0xFA; 1269 p->p.req.header.gs_type = 0xFA;
1272 ct_req->header.gs_subtype = 0x10; 1270 p->p.req.header.gs_subtype = 0x10;
1273 ct_req->command = cpu_to_be16(cmd); 1271 p->p.req.command = cpu_to_be16(cmd);
1274 ct_req->max_rsp_size = cpu_to_be16((rsp_size - 16) / 4); 1272 p->p.req.max_rsp_size = cpu_to_be16((rsp_size - 16) / 4);
1275 1273
1276 return ct_req; 1274 return &p->p.req;
1277} 1275}
1278 1276
1279/** 1277/**
@@ -1301,8 +1299,7 @@ qla2x00_fdmi_rhba(scsi_qla_host_t *vha)
1301 ms_pkt = ha->isp_ops->prep_ms_fdmi_iocb(vha, 0, RHBA_RSP_SIZE); 1299 ms_pkt = ha->isp_ops->prep_ms_fdmi_iocb(vha, 0, RHBA_RSP_SIZE);
1302 1300
1303 /* Prepare CT request */ 1301 /* Prepare CT request */
1304 ct_req = qla2x00_prep_ct_fdmi_req(&ha->ct_sns->p.req, RHBA_CMD, 1302 ct_req = qla2x00_prep_ct_fdmi_req(ha->ct_sns, RHBA_CMD, RHBA_RSP_SIZE);
1305 RHBA_RSP_SIZE);
1306 ct_rsp = &ha->ct_sns->p.rsp; 1303 ct_rsp = &ha->ct_sns->p.rsp;
1307 1304
1308 /* Prepare FDMI command arguments -- attribute block, attributes. */ 1305 /* Prepare FDMI command arguments -- attribute block, attributes. */
@@ -1370,8 +1367,7 @@ qla2x00_fdmi_rhba(scsi_qla_host_t *vha)
1370 /* Model description. */ 1367 /* Model description. */
1371 eiter = (struct ct_fdmi_hba_attr *) (entries + size); 1368 eiter = (struct ct_fdmi_hba_attr *) (entries + size);
1372 eiter->type = __constant_cpu_to_be16(FDMI_HBA_MODEL_DESCRIPTION); 1369 eiter->type = __constant_cpu_to_be16(FDMI_HBA_MODEL_DESCRIPTION);
1373 if (ha->model_desc) 1370 strncpy(eiter->a.model_desc, ha->model_desc, 80);
1374 strncpy(eiter->a.model_desc, ha->model_desc, 80);
1375 alen = strlen(eiter->a.model_desc); 1371 alen = strlen(eiter->a.model_desc);
1376 alen += (alen & 3) ? (4 - (alen & 3)) : 4; 1372 alen += (alen & 3) ? (4 - (alen & 3)) : 4;
1377 eiter->len = cpu_to_be16(4 + alen); 1373 eiter->len = cpu_to_be16(4 + alen);
@@ -1491,8 +1487,7 @@ qla2x00_fdmi_dhba(scsi_qla_host_t *vha)
1491 DHBA_RSP_SIZE); 1487 DHBA_RSP_SIZE);
1492 1488
1493 /* Prepare CT request */ 1489 /* Prepare CT request */
1494 ct_req = qla2x00_prep_ct_fdmi_req(&ha->ct_sns->p.req, DHBA_CMD, 1490 ct_req = qla2x00_prep_ct_fdmi_req(ha->ct_sns, DHBA_CMD, DHBA_RSP_SIZE);
1495 DHBA_RSP_SIZE);
1496 ct_rsp = &ha->ct_sns->p.rsp; 1491 ct_rsp = &ha->ct_sns->p.rsp;
1497 1492
1498 /* Prepare FDMI command arguments -- portname. */ 1493 /* Prepare FDMI command arguments -- portname. */
@@ -1548,8 +1543,7 @@ qla2x00_fdmi_rpa(scsi_qla_host_t *vha)
1548 ms_pkt = ha->isp_ops->prep_ms_fdmi_iocb(vha, 0, RPA_RSP_SIZE); 1543 ms_pkt = ha->isp_ops->prep_ms_fdmi_iocb(vha, 0, RPA_RSP_SIZE);
1549 1544
1550 /* Prepare CT request */ 1545 /* Prepare CT request */
1551 ct_req = qla2x00_prep_ct_fdmi_req(&ha->ct_sns->p.req, RPA_CMD, 1546 ct_req = qla2x00_prep_ct_fdmi_req(ha->ct_sns, RPA_CMD, RPA_RSP_SIZE);
1552 RPA_RSP_SIZE);
1553 ct_rsp = &ha->ct_sns->p.rsp; 1547 ct_rsp = &ha->ct_sns->p.rsp;
1554 1548
1555 /* Prepare FDMI command arguments -- attribute block, attributes. */ 1549 /* Prepare FDMI command arguments -- attribute block, attributes. */
@@ -1776,7 +1770,7 @@ qla2x00_gfpn_id(scsi_qla_host_t *vha, sw_info_t *list)
1776 GFPN_ID_RSP_SIZE); 1770 GFPN_ID_RSP_SIZE);
1777 1771
1778 /* Prepare CT request */ 1772 /* Prepare CT request */
1779 ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GFPN_ID_CMD, 1773 ct_req = qla2x00_prep_ct_req(ha->ct_sns, GFPN_ID_CMD,
1780 GFPN_ID_RSP_SIZE); 1774 GFPN_ID_RSP_SIZE);
1781 ct_rsp = &ha->ct_sns->p.rsp; 1775 ct_rsp = &ha->ct_sns->p.rsp;
1782 1776
@@ -1843,18 +1837,18 @@ qla24xx_prep_ms_fm_iocb(scsi_qla_host_t *vha, uint32_t req_size,
1843 1837
1844 1838
1845static inline struct ct_sns_req * 1839static inline struct ct_sns_req *
1846qla24xx_prep_ct_fm_req(struct ct_sns_req *ct_req, uint16_t cmd, 1840qla24xx_prep_ct_fm_req(struct ct_sns_pkt *p, uint16_t cmd,
1847 uint16_t rsp_size) 1841 uint16_t rsp_size)
1848{ 1842{
1849 memset(ct_req, 0, sizeof(struct ct_sns_pkt)); 1843 memset(p, 0, sizeof(struct ct_sns_pkt));
1850 1844
1851 ct_req->header.revision = 0x01; 1845 p->p.req.header.revision = 0x01;
1852 ct_req->header.gs_type = 0xFA; 1846 p->p.req.header.gs_type = 0xFA;
1853 ct_req->header.gs_subtype = 0x01; 1847 p->p.req.header.gs_subtype = 0x01;
1854 ct_req->command = cpu_to_be16(cmd); 1848 p->p.req.command = cpu_to_be16(cmd);
1855 ct_req->max_rsp_size = cpu_to_be16((rsp_size - 16) / 4); 1849 p->p.req.max_rsp_size = cpu_to_be16((rsp_size - 16) / 4);
1856 1850
1857 return ct_req; 1851 return &p->p.req;
1858} 1852}
1859 1853
1860/** 1854/**
@@ -1890,8 +1884,8 @@ qla2x00_gpsc(scsi_qla_host_t *vha, sw_info_t *list)
1890 GPSC_RSP_SIZE); 1884 GPSC_RSP_SIZE);
1891 1885
1892 /* Prepare CT request */ 1886 /* Prepare CT request */
1893 ct_req = qla24xx_prep_ct_fm_req(&ha->ct_sns->p.req, 1887 ct_req = qla24xx_prep_ct_fm_req(ha->ct_sns, GPSC_CMD,
1894 GPSC_CMD, GPSC_RSP_SIZE); 1888 GPSC_RSP_SIZE);
1895 ct_rsp = &ha->ct_sns->p.rsp; 1889 ct_rsp = &ha->ct_sns->p.rsp;
1896 1890
1897 /* Prepare CT arguments -- port_name */ 1891 /* Prepare CT arguments -- port_name */
@@ -2001,7 +1995,7 @@ qla2x00_gff_id(scsi_qla_host_t *vha, sw_info_t *list)
2001 GFF_ID_RSP_SIZE); 1995 GFF_ID_RSP_SIZE);
2002 1996
2003 /* Prepare CT request */ 1997 /* Prepare CT request */
2004 ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GFF_ID_CMD, 1998 ct_req = qla2x00_prep_ct_req(ha->ct_sns, GFF_ID_CMD,
2005 GFF_ID_RSP_SIZE); 1999 GFF_ID_RSP_SIZE);
2006 ct_rsp = &ha->ct_sns->p.rsp; 2000 ct_rsp = &ha->ct_sns->p.rsp;
2007 2001
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 3565dfd8f370..f2216ed2ad8c 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -2309,14 +2309,6 @@ qla2x00_configure_hba(scsi_qla_host_t *vha)
2309 "Topology - %s, Host Loop address 0x%x.\n", 2309 "Topology - %s, Host Loop address 0x%x.\n",
2310 connect_type, vha->loop_id); 2310 connect_type, vha->loop_id);
2311 2311
2312 if (rval) {
2313 ql_log(ql_log_warn, vha, 0x2011,
2314 "%s FAILED\n", __func__);
2315 } else {
2316 ql_dbg(ql_dbg_disc, vha, 0x2012,
2317 "%s success\n", __func__);
2318 }
2319
2320 return(rval); 2312 return(rval);
2321} 2313}
2322 2314
diff --git a/drivers/scsi/qla2xxx/qla_inline.h b/drivers/scsi/qla2xxx/qla_inline.h
index 0a5c8951cebb..28c38b4929ce 100644
--- a/drivers/scsi/qla2xxx/qla_inline.h
+++ b/drivers/scsi/qla2xxx/qla_inline.h
@@ -83,7 +83,7 @@ static inline void
83host_to_adap(uint8_t *src, uint8_t *dst, uint32_t bsize) 83host_to_adap(uint8_t *src, uint8_t *dst, uint32_t bsize)
84{ 84{
85 uint32_t *isrc = (uint32_t *) src; 85 uint32_t *isrc = (uint32_t *) src;
86 uint32_t *odest = (uint32_t *) dst; 86 __le32 *odest = (__le32 *) dst;
87 uint32_t iter = bsize >> 2; 87 uint32_t iter = bsize >> 2;
88 88
89 for (; iter ; iter--) 89 for (; iter ; iter--)
diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c
index 15e4080b347c..42ef481db942 100644
--- a/drivers/scsi/qla2xxx/qla_iocb.c
+++ b/drivers/scsi/qla2xxx/qla_iocb.c
@@ -1189,7 +1189,6 @@ qla24xx_build_scsi_crc_2_iocbs(srb_t *sp, struct cmd_type_crc_2 *cmd_pkt,
1189 uint32_t *cur_dsd, *fcp_dl; 1189 uint32_t *cur_dsd, *fcp_dl;
1190 scsi_qla_host_t *vha; 1190 scsi_qla_host_t *vha;
1191 struct scsi_cmnd *cmd; 1191 struct scsi_cmnd *cmd;
1192 struct scatterlist *cur_seg;
1193 int sgc; 1192 int sgc;
1194 uint32_t total_bytes = 0; 1193 uint32_t total_bytes = 0;
1195 uint32_t data_bytes; 1194 uint32_t data_bytes;
@@ -1396,7 +1395,6 @@ qla24xx_build_scsi_crc_2_iocbs(srb_t *sp, struct cmd_type_crc_2 *cmd_pkt,
1396 1395
1397 if (bundling && tot_prot_dsds) { 1396 if (bundling && tot_prot_dsds) {
1398 /* Walks dif segments */ 1397 /* Walks dif segments */
1399 cur_seg = scsi_prot_sglist(cmd);
1400 cmd_pkt->control_flags |= 1398 cmd_pkt->control_flags |=
1401 __constant_cpu_to_le16(CF_DIF_SEG_DESCR_ENABLE); 1399 __constant_cpu_to_le16(CF_DIF_SEG_DESCR_ENABLE);
1402 cur_dsd = (uint32_t *) &crc_ctx_pkt->u.bundling.dif_address; 1400 cur_dsd = (uint32_t *) &crc_ctx_pkt->u.bundling.dif_address;
@@ -1863,8 +1861,8 @@ skip_cmd_array:
1863 pkt = req->ring_ptr; 1861 pkt = req->ring_ptr;
1864 memset(pkt, 0, REQUEST_ENTRY_SIZE); 1862 memset(pkt, 0, REQUEST_ENTRY_SIZE);
1865 if (IS_QLAFX00(ha)) { 1863 if (IS_QLAFX00(ha)) {
1866 WRT_REG_BYTE(&pkt->entry_count, req_cnt); 1864 WRT_REG_BYTE((void __iomem *)&pkt->entry_count, req_cnt);
1867 WRT_REG_WORD(&pkt->handle, handle); 1865 WRT_REG_WORD((void __iomem *)&pkt->handle, handle);
1868 } else { 1866 } else {
1869 pkt->entry_count = req_cnt; 1867 pkt->entry_count = req_cnt;
1870 pkt->handle = handle; 1868 pkt->handle = handle;
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index d2a4c75e5b8f..2d8e7b812352 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -2485,6 +2485,7 @@ qla2xxx_check_risc_status(scsi_qla_host_t *vha)
2485 if (rval == QLA_SUCCESS) 2485 if (rval == QLA_SUCCESS)
2486 goto next_test; 2486 goto next_test;
2487 2487
2488 rval = QLA_SUCCESS;
2488 WRT_REG_DWORD(&reg->iobase_window, 0x0003); 2489 WRT_REG_DWORD(&reg->iobase_window, 0x0003);
2489 for (cnt = 100; (RD_REG_DWORD(&reg->iobase_window) & BIT_0) == 0 && 2490 for (cnt = 100; (RD_REG_DWORD(&reg->iobase_window) & BIT_0) == 0 &&
2490 rval == QLA_SUCCESS; cnt--) { 2491 rval == QLA_SUCCESS; cnt--) {
diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
index 3587ec267fa6..7257c3c4f2d0 100644
--- a/drivers/scsi/qla2xxx/qla_mbx.c
+++ b/drivers/scsi/qla2xxx/qla_mbx.c
@@ -177,8 +177,14 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp)
177 WRT_REG_WORD(&reg->isp.hccr, HCCR_SET_HOST_INT); 177 WRT_REG_WORD(&reg->isp.hccr, HCCR_SET_HOST_INT);
178 spin_unlock_irqrestore(&ha->hardware_lock, flags); 178 spin_unlock_irqrestore(&ha->hardware_lock, flags);
179 179
180 wait_for_completion_timeout(&ha->mbx_intr_comp, mcp->tov * HZ); 180 if (!wait_for_completion_timeout(&ha->mbx_intr_comp,
181 181 mcp->tov * HZ)) {
182 ql_dbg(ql_dbg_mbx, vha, 0x117a,
183 "cmd=%x Timeout.\n", command);
184 spin_lock_irqsave(&ha->hardware_lock, flags);
185 clear_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags);
186 spin_unlock_irqrestore(&ha->hardware_lock, flags);
187 }
182 } else { 188 } else {
183 ql_dbg(ql_dbg_mbx, vha, 0x1011, 189 ql_dbg(ql_dbg_mbx, vha, 0x1011,
184 "Cmd=%x Polling Mode.\n", command); 190 "Cmd=%x Polling Mode.\n", command);
@@ -275,9 +281,11 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp)
275 281
276 /* 282 /*
277 * Attempt to capture a firmware dump for further analysis 283 * Attempt to capture a firmware dump for further analysis
278 * of the current firmware state 284 * of the current firmware state. We do not need to do this
285 * if we are intentionally generating a dump.
279 */ 286 */
280 ha->isp_ops->fw_dump(vha, 0); 287 if (mcp->mb[0] != MBC_GEN_SYSTEM_ERROR)
288 ha->isp_ops->fw_dump(vha, 0);
281 289
282 rval = QLA_FUNCTION_TIMEOUT; 290 rval = QLA_FUNCTION_TIMEOUT;
283 } 291 }
diff --git a/drivers/scsi/qla2xxx/qla_mr.c b/drivers/scsi/qla2xxx/qla_mr.c
index a6df55838365..d7993797f46e 100644
--- a/drivers/scsi/qla2xxx/qla_mr.c
+++ b/drivers/scsi/qla2xxx/qla_mr.c
@@ -707,7 +707,7 @@ qlafx00_tmf_iocb_timeout(void *data)
707 srb_t *sp = (srb_t *)data; 707 srb_t *sp = (srb_t *)data;
708 struct srb_iocb *tmf = &sp->u.iocb_cmd; 708 struct srb_iocb *tmf = &sp->u.iocb_cmd;
709 709
710 tmf->u.tmf.comp_status = CS_TIMEOUT; 710 tmf->u.tmf.comp_status = cpu_to_le16((uint16_t)CS_TIMEOUT);
711 complete(&tmf->u.tmf.comp); 711 complete(&tmf->u.tmf.comp);
712} 712}
713 713
@@ -1418,7 +1418,8 @@ qlafx00_init_response_q_entries(struct rsp_que *rsp)
1418 pkt = rsp->ring_ptr; 1418 pkt = rsp->ring_ptr;
1419 for (cnt = 0; cnt < rsp->length; cnt++) { 1419 for (cnt = 0; cnt < rsp->length; cnt++) {
1420 pkt->signature = RESPONSE_PROCESSED; 1420 pkt->signature = RESPONSE_PROCESSED;
1421 WRT_REG_DWORD(&pkt->signature, RESPONSE_PROCESSED); 1421 WRT_REG_DWORD((void __iomem *)&pkt->signature,
1422 RESPONSE_PROCESSED);
1422 pkt++; 1423 pkt++;
1423 } 1424 }
1424} 1425}
@@ -1733,7 +1734,7 @@ qla2x00_fxdisc_sp_done(void *data, void *ptr, int res)
1733} 1734}
1734 1735
1735int 1736int
1736qlafx00_fx_disc(scsi_qla_host_t *vha, fc_port_t *fcport, uint8_t fx_type) 1737qlafx00_fx_disc(scsi_qla_host_t *vha, fc_port_t *fcport, uint16_t fx_type)
1737{ 1738{
1738 srb_t *sp; 1739 srb_t *sp;
1739 struct srb_iocb *fdisc; 1740 struct srb_iocb *fdisc;
@@ -1759,13 +1760,13 @@ qlafx00_fx_disc(scsi_qla_host_t *vha, fc_port_t *fcport, uint8_t fx_type)
1759 fdisc->u.fxiocb.flags = 1760 fdisc->u.fxiocb.flags =
1760 SRB_FXDISC_RESP_DMA_VALID | SRB_FXDISC_REQ_DWRD_VALID; 1761 SRB_FXDISC_RESP_DMA_VALID | SRB_FXDISC_REQ_DWRD_VALID;
1761 fdisc->u.fxiocb.rsp_len = QLAFX00_PORT_DATA_INFO; 1762 fdisc->u.fxiocb.rsp_len = QLAFX00_PORT_DATA_INFO;
1762 fdisc->u.fxiocb.req_data = fcport->port_id; 1763 fdisc->u.fxiocb.req_data = cpu_to_le32(fcport->port_id);
1763 break; 1764 break;
1764 case FXDISC_GET_TGT_NODE_INFO: 1765 case FXDISC_GET_TGT_NODE_INFO:
1765 fdisc->u.fxiocb.flags = 1766 fdisc->u.fxiocb.flags =
1766 SRB_FXDISC_RESP_DMA_VALID | SRB_FXDISC_REQ_DWRD_VALID; 1767 SRB_FXDISC_RESP_DMA_VALID | SRB_FXDISC_REQ_DWRD_VALID;
1767 fdisc->u.fxiocb.rsp_len = QLAFX00_TGT_NODE_INFO; 1768 fdisc->u.fxiocb.rsp_len = QLAFX00_TGT_NODE_INFO;
1768 fdisc->u.fxiocb.req_data = fcport->tgt_id; 1769 fdisc->u.fxiocb.req_data = cpu_to_le32(fcport->tgt_id);
1769 break; 1770 break;
1770 case FXDISC_GET_TGT_NODE_LIST: 1771 case FXDISC_GET_TGT_NODE_LIST:
1771 fdisc->u.fxiocb.flags = 1772 fdisc->u.fxiocb.flags =
@@ -1851,7 +1852,7 @@ qlafx00_fx_disc(scsi_qla_host_t *vha, fc_port_t *fcport, uint8_t fx_type)
1851 sp->name = "fxdisc"; 1852 sp->name = "fxdisc";
1852 qla2x00_init_timer(sp, FXDISC_TIMEOUT); 1853 qla2x00_init_timer(sp, FXDISC_TIMEOUT);
1853 fdisc->timeout = qla2x00_fxdisc_iocb_timeout; 1854 fdisc->timeout = qla2x00_fxdisc_iocb_timeout;
1854 fdisc->u.fxiocb.req_func_type = fx_type; 1855 fdisc->u.fxiocb.req_func_type = cpu_to_le16(fx_type);
1855 sp->done = qla2x00_fxdisc_sp_done; 1856 sp->done = qla2x00_fxdisc_sp_done;
1856 1857
1857 rval = qla2x00_start_sp(sp); 1858 rval = qla2x00_start_sp(sp);
@@ -1904,7 +1905,7 @@ qlafx00_fx_disc(scsi_qla_host_t *vha, fc_port_t *fcport, uint8_t fx_type)
1904 (uint8_t *)pinfo, 16); 1905 (uint8_t *)pinfo, 16);
1905 memcpy(vha->hw->gid_list, pinfo, QLAFX00_TGT_NODE_LIST_SIZE); 1906 memcpy(vha->hw->gid_list, pinfo, QLAFX00_TGT_NODE_LIST_SIZE);
1906 } 1907 }
1907 rval = fdisc->u.fxiocb.result; 1908 rval = le32_to_cpu(fdisc->u.fxiocb.result);
1908 1909
1909done_unmap_dma: 1910done_unmap_dma:
1910 if (fdisc->u.fxiocb.rsp_addr) 1911 if (fdisc->u.fxiocb.rsp_addr)
@@ -1927,7 +1928,7 @@ qlafx00_abort_iocb_timeout(void *data)
1927 srb_t *sp = (srb_t *)data; 1928 srb_t *sp = (srb_t *)data;
1928 struct srb_iocb *abt = &sp->u.iocb_cmd; 1929 struct srb_iocb *abt = &sp->u.iocb_cmd;
1929 1930
1930 abt->u.abt.comp_status = CS_TIMEOUT; 1931 abt->u.abt.comp_status = cpu_to_le16((uint16_t)CS_TIMEOUT);
1931 complete(&abt->u.abt.comp); 1932 complete(&abt->u.abt.comp);
1932} 1933}
1933 1934
@@ -2169,14 +2170,14 @@ qlafx00_handle_sense(srb_t *sp, uint8_t *sense_data, uint32_t par_sense_len,
2169static void 2170static void
2170qlafx00_tm_iocb_entry(scsi_qla_host_t *vha, struct req_que *req, 2171qlafx00_tm_iocb_entry(scsi_qla_host_t *vha, struct req_que *req,
2171 struct tsk_mgmt_entry_fx00 *pkt, srb_t *sp, 2172 struct tsk_mgmt_entry_fx00 *pkt, srb_t *sp,
2172 uint16_t sstatus, uint16_t cpstatus) 2173 __le16 sstatus, __le16 cpstatus)
2173{ 2174{
2174 struct srb_iocb *tmf; 2175 struct srb_iocb *tmf;
2175 2176
2176 tmf = &sp->u.iocb_cmd; 2177 tmf = &sp->u.iocb_cmd;
2177 if (cpstatus != CS_COMPLETE || 2178 if (cpstatus != cpu_to_le16((uint16_t)CS_COMPLETE) ||
2178 (sstatus & SS_RESPONSE_INFO_LEN_VALID)) 2179 (sstatus & cpu_to_le16((uint16_t)SS_RESPONSE_INFO_LEN_VALID)))
2179 cpstatus = CS_INCOMPLETE; 2180 cpstatus = cpu_to_le16((uint16_t)CS_INCOMPLETE);
2180 tmf->u.tmf.comp_status = cpstatus; 2181 tmf->u.tmf.comp_status = cpstatus;
2181 sp->done(vha, sp, 0); 2182 sp->done(vha, sp, 0);
2182} 2183}
@@ -2194,7 +2195,7 @@ qlafx00_abort_iocb_entry(scsi_qla_host_t *vha, struct req_que *req,
2194 return; 2195 return;
2195 2196
2196 abt = &sp->u.iocb_cmd; 2197 abt = &sp->u.iocb_cmd;
2197 abt->u.abt.comp_status = le32_to_cpu(pkt->tgt_id_sts); 2198 abt->u.abt.comp_status = pkt->tgt_id_sts;
2198 sp->done(vha, sp, 0); 2199 sp->done(vha, sp, 0);
2199} 2200}
2200 2201
@@ -2216,12 +2217,12 @@ qlafx00_ioctl_iosb_entry(scsi_qla_host_t *vha, struct req_que *req,
2216 2217
2217 if (sp->type == SRB_FXIOCB_DCMD) { 2218 if (sp->type == SRB_FXIOCB_DCMD) {
2218 iocb_job = &sp->u.iocb_cmd; 2219 iocb_job = &sp->u.iocb_cmd;
2219 iocb_job->u.fxiocb.seq_number = le32_to_cpu(pkt->seq_no); 2220 iocb_job->u.fxiocb.seq_number = pkt->seq_no;
2220 iocb_job->u.fxiocb.fw_flags = le32_to_cpu(pkt->fw_iotcl_flags); 2221 iocb_job->u.fxiocb.fw_flags = pkt->fw_iotcl_flags;
2221 iocb_job->u.fxiocb.result = le32_to_cpu(pkt->status); 2222 iocb_job->u.fxiocb.result = pkt->status;
2222 if (iocb_job->u.fxiocb.flags & SRB_FXDISC_RSP_DWRD_VALID) 2223 if (iocb_job->u.fxiocb.flags & SRB_FXDISC_RSP_DWRD_VALID)
2223 iocb_job->u.fxiocb.req_data = 2224 iocb_job->u.fxiocb.req_data =
2224 le32_to_cpu(pkt->dataword_r); 2225 pkt->dataword_r;
2225 } else { 2226 } else {
2226 bsg_job = sp->u.bsg_job; 2227 bsg_job = sp->u.bsg_job;
2227 2228
@@ -2275,10 +2276,10 @@ qlafx00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt)
2275 fc_port_t *fcport; 2276 fc_port_t *fcport;
2276 struct scsi_cmnd *cp; 2277 struct scsi_cmnd *cp;
2277 struct sts_entry_fx00 *sts; 2278 struct sts_entry_fx00 *sts;
2278 uint16_t comp_status; 2279 __le16 comp_status;
2279 uint16_t scsi_status; 2280 __le16 scsi_status;
2280 uint16_t ox_id; 2281 uint16_t ox_id;
2281 uint8_t lscsi_status; 2282 __le16 lscsi_status;
2282 int32_t resid; 2283 int32_t resid;
2283 uint32_t sense_len, par_sense_len, rsp_info_len, resid_len, 2284 uint32_t sense_len, par_sense_len, rsp_info_len, resid_len,
2284 fw_resid_len; 2285 fw_resid_len;
@@ -2292,8 +2293,8 @@ qlafx00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt)
2292 2293
2293 sts = (struct sts_entry_fx00 *) pkt; 2294 sts = (struct sts_entry_fx00 *) pkt;
2294 2295
2295 comp_status = le16_to_cpu(sts->comp_status); 2296 comp_status = sts->comp_status;
2296 scsi_status = le16_to_cpu(sts->scsi_status) & SS_MASK; 2297 scsi_status = sts->scsi_status & cpu_to_le16((uint16_t)SS_MASK);
2297 hindex = sts->handle; 2298 hindex = sts->handle;
2298 handle = LSW(hindex); 2299 handle = LSW(hindex);
2299 2300
@@ -2339,38 +2340,40 @@ qlafx00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt)
2339 return; 2340 return;
2340 } 2341 }
2341 2342
2342 lscsi_status = scsi_status & STATUS_MASK; 2343 lscsi_status = scsi_status & cpu_to_le16((uint16_t)STATUS_MASK);
2343 2344
2344 fcport = sp->fcport; 2345 fcport = sp->fcport;
2345 2346
2346 ox_id = 0; 2347 ox_id = 0;
2347 sense_len = par_sense_len = rsp_info_len = resid_len = 2348 sense_len = par_sense_len = rsp_info_len = resid_len =
2348 fw_resid_len = 0; 2349 fw_resid_len = 0;
2349 if (scsi_status & SS_SENSE_LEN_VALID) 2350 if (scsi_status & cpu_to_le16((uint16_t)SS_SENSE_LEN_VALID))
2350 sense_len = le32_to_cpu(sts->sense_len); 2351 sense_len = sts->sense_len;
2351 if (scsi_status & (SS_RESIDUAL_UNDER | SS_RESIDUAL_OVER)) 2352 if (scsi_status & cpu_to_le16(((uint16_t)SS_RESIDUAL_UNDER
2353 | (uint16_t)SS_RESIDUAL_OVER)))
2352 resid_len = le32_to_cpu(sts->residual_len); 2354 resid_len = le32_to_cpu(sts->residual_len);
2353 if (comp_status == CS_DATA_UNDERRUN) 2355 if (comp_status == cpu_to_le16((uint16_t)CS_DATA_UNDERRUN))
2354 fw_resid_len = le32_to_cpu(sts->residual_len); 2356 fw_resid_len = le32_to_cpu(sts->residual_len);
2355 rsp_info = sense_data = sts->data; 2357 rsp_info = sense_data = sts->data;
2356 par_sense_len = sizeof(sts->data); 2358 par_sense_len = sizeof(sts->data);
2357 2359
2358 /* Check for overrun. */ 2360 /* Check for overrun. */
2359 if (comp_status == CS_COMPLETE && 2361 if (comp_status == CS_COMPLETE &&
2360 scsi_status & SS_RESIDUAL_OVER) 2362 scsi_status & cpu_to_le16((uint16_t)SS_RESIDUAL_OVER))
2361 comp_status = CS_DATA_OVERRUN; 2363 comp_status = cpu_to_le16((uint16_t)CS_DATA_OVERRUN);
2362 2364
2363 /* 2365 /*
2364 * Based on Host and scsi status generate status code for Linux 2366 * Based on Host and scsi status generate status code for Linux
2365 */ 2367 */
2366 switch (comp_status) { 2368 switch (le16_to_cpu(comp_status)) {
2367 case CS_COMPLETE: 2369 case CS_COMPLETE:
2368 case CS_QUEUE_FULL: 2370 case CS_QUEUE_FULL:
2369 if (scsi_status == 0) { 2371 if (scsi_status == 0) {
2370 res = DID_OK << 16; 2372 res = DID_OK << 16;
2371 break; 2373 break;
2372 } 2374 }
2373 if (scsi_status & (SS_RESIDUAL_UNDER | SS_RESIDUAL_OVER)) { 2375 if (scsi_status & cpu_to_le16(((uint16_t)SS_RESIDUAL_UNDER
2376 | (uint16_t)SS_RESIDUAL_OVER))) {
2374 resid = resid_len; 2377 resid = resid_len;
2375 scsi_set_resid(cp, resid); 2378 scsi_set_resid(cp, resid);
2376 2379
@@ -2386,19 +2389,20 @@ qlafx00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt)
2386 break; 2389 break;
2387 } 2390 }
2388 } 2391 }
2389 res = DID_OK << 16 | lscsi_status; 2392 res = DID_OK << 16 | le16_to_cpu(lscsi_status);
2390 2393
2391 if (lscsi_status == SAM_STAT_TASK_SET_FULL) { 2394 if (lscsi_status ==
2395 cpu_to_le16((uint16_t)SAM_STAT_TASK_SET_FULL)) {
2392 ql_dbg(ql_dbg_io, fcport->vha, 0x3051, 2396 ql_dbg(ql_dbg_io, fcport->vha, 0x3051,
2393 "QUEUE FULL detected.\n"); 2397 "QUEUE FULL detected.\n");
2394 break; 2398 break;
2395 } 2399 }
2396 logit = 0; 2400 logit = 0;
2397 if (lscsi_status != SS_CHECK_CONDITION) 2401 if (lscsi_status != cpu_to_le16((uint16_t)SS_CHECK_CONDITION))
2398 break; 2402 break;
2399 2403
2400 memset(cp->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); 2404 memset(cp->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
2401 if (!(scsi_status & SS_SENSE_LEN_VALID)) 2405 if (!(scsi_status & cpu_to_le16((uint16_t)SS_SENSE_LEN_VALID)))
2402 break; 2406 break;
2403 2407
2404 qlafx00_handle_sense(sp, sense_data, par_sense_len, sense_len, 2408 qlafx00_handle_sense(sp, sense_data, par_sense_len, sense_len,
@@ -2412,7 +2416,7 @@ qlafx00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt)
2412 else 2416 else
2413 resid = resid_len; 2417 resid = resid_len;
2414 scsi_set_resid(cp, resid); 2418 scsi_set_resid(cp, resid);
2415 if (scsi_status & SS_RESIDUAL_UNDER) { 2419 if (scsi_status & cpu_to_le16((uint16_t)SS_RESIDUAL_UNDER)) {
2416 if ((IS_FWI2_CAPABLE(ha) || IS_QLAFX00(ha)) 2420 if ((IS_FWI2_CAPABLE(ha) || IS_QLAFX00(ha))
2417 && fw_resid_len != resid_len) { 2421 && fw_resid_len != resid_len) {
2418 ql_dbg(ql_dbg_io, fcport->vha, 0x3052, 2422 ql_dbg(ql_dbg_io, fcport->vha, 0x3052,
@@ -2420,7 +2424,8 @@ qlafx00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt)
2420 "(0x%x of 0x%x bytes).\n", 2424 "(0x%x of 0x%x bytes).\n",
2421 resid, scsi_bufflen(cp)); 2425 resid, scsi_bufflen(cp));
2422 2426
2423 res = DID_ERROR << 16 | lscsi_status; 2427 res = DID_ERROR << 16 |
2428 le16_to_cpu(lscsi_status);
2424 goto check_scsi_status; 2429 goto check_scsi_status;
2425 } 2430 }
2426 2431
@@ -2436,8 +2441,9 @@ qlafx00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt)
2436 res = DID_ERROR << 16; 2441 res = DID_ERROR << 16;
2437 break; 2442 break;
2438 } 2443 }
2439 } else if (lscsi_status != SAM_STAT_TASK_SET_FULL && 2444 } else if (lscsi_status !=
2440 lscsi_status != SAM_STAT_BUSY) { 2445 cpu_to_le16((uint16_t)SAM_STAT_TASK_SET_FULL) &&
2446 lscsi_status != cpu_to_le16((uint16_t)SAM_STAT_BUSY)) {
2441 /* 2447 /*
2442 * scsi status of task set and busy are considered 2448 * scsi status of task set and busy are considered
2443 * to be task not completed. 2449 * to be task not completed.
@@ -2448,7 +2454,7 @@ qlafx00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt)
2448 "of 0x%x bytes).\n", resid, 2454 "of 0x%x bytes).\n", resid,
2449 scsi_bufflen(cp)); 2455 scsi_bufflen(cp));
2450 2456
2451 res = DID_ERROR << 16 | lscsi_status; 2457 res = DID_ERROR << 16 | le16_to_cpu(lscsi_status);
2452 goto check_scsi_status; 2458 goto check_scsi_status;
2453 } else { 2459 } else {
2454 ql_dbg(ql_dbg_io, fcport->vha, 0x3055, 2460 ql_dbg(ql_dbg_io, fcport->vha, 0x3055,
@@ -2456,7 +2462,7 @@ qlafx00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt)
2456 scsi_status, lscsi_status); 2462 scsi_status, lscsi_status);
2457 } 2463 }
2458 2464
2459 res = DID_OK << 16 | lscsi_status; 2465 res = DID_OK << 16 | le16_to_cpu(lscsi_status);
2460 logit = 0; 2466 logit = 0;
2461 2467
2462check_scsi_status: 2468check_scsi_status:
@@ -2465,17 +2471,20 @@ check_scsi_status:
2465 * Status. 2471 * Status.
2466 */ 2472 */
2467 if (lscsi_status != 0) { 2473 if (lscsi_status != 0) {
2468 if (lscsi_status == SAM_STAT_TASK_SET_FULL) { 2474 if (lscsi_status ==
2475 cpu_to_le16((uint16_t)SAM_STAT_TASK_SET_FULL)) {
2469 ql_dbg(ql_dbg_io, fcport->vha, 0x3056, 2476 ql_dbg(ql_dbg_io, fcport->vha, 0x3056,
2470 "QUEUE FULL detected.\n"); 2477 "QUEUE FULL detected.\n");
2471 logit = 1; 2478 logit = 1;
2472 break; 2479 break;
2473 } 2480 }
2474 if (lscsi_status != SS_CHECK_CONDITION) 2481 if (lscsi_status !=
2482 cpu_to_le16((uint16_t)SS_CHECK_CONDITION))
2475 break; 2483 break;
2476 2484
2477 memset(cp->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); 2485 memset(cp->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
2478 if (!(scsi_status & SS_SENSE_LEN_VALID)) 2486 if (!(scsi_status &
2487 cpu_to_le16((uint16_t)SS_SENSE_LEN_VALID)))
2479 break; 2488 break;
2480 2489
2481 qlafx00_handle_sense(sp, sense_data, par_sense_len, 2490 qlafx00_handle_sense(sp, sense_data, par_sense_len,
@@ -2629,7 +2638,7 @@ qlafx00_multistatus_entry(struct scsi_qla_host *vha,
2629 uint32_t handle, hindex, handle_count, i; 2638 uint32_t handle, hindex, handle_count, i;
2630 uint16_t que; 2639 uint16_t que;
2631 struct req_que *req; 2640 struct req_que *req;
2632 uint32_t *handle_ptr; 2641 __le32 *handle_ptr;
2633 2642
2634 stsmfx = (struct multi_sts_entry_fx00 *) pkt; 2643 stsmfx = (struct multi_sts_entry_fx00 *) pkt;
2635 2644
@@ -2643,7 +2652,7 @@ qlafx00_multistatus_entry(struct scsi_qla_host *vha,
2643 return; 2652 return;
2644 } 2653 }
2645 2654
2646 handle_ptr = (uint32_t *) &stsmfx->handles[0]; 2655 handle_ptr = &stsmfx->handles[0];
2647 2656
2648 for (i = 0; i < handle_count; i++) { 2657 for (i = 0; i < handle_count; i++) {
2649 hindex = le32_to_cpu(*handle_ptr); 2658 hindex = le32_to_cpu(*handle_ptr);
@@ -2714,10 +2723,11 @@ qlafx00_process_response_queue(struct scsi_qla_host *vha,
2714 if (!vha->flags.online) 2723 if (!vha->flags.online)
2715 return; 2724 return;
2716 2725
2717 while (RD_REG_DWORD(&(rsp->ring_ptr->signature)) != 2726 while (RD_REG_DWORD((void __iomem *)&(rsp->ring_ptr->signature)) !=
2718 RESPONSE_PROCESSED) { 2727 RESPONSE_PROCESSED) {
2719 lptr = rsp->ring_ptr; 2728 lptr = rsp->ring_ptr;
2720 memcpy_fromio(rsp->rsp_pkt, lptr, sizeof(rsp->rsp_pkt)); 2729 memcpy_fromio(rsp->rsp_pkt, (void __iomem *)lptr,
2730 sizeof(rsp->rsp_pkt));
2721 pkt = (struct sts_entry_fx00 *)rsp->rsp_pkt; 2731 pkt = (struct sts_entry_fx00 *)rsp->rsp_pkt;
2722 2732
2723 rsp->ring_index++; 2733 rsp->ring_index++;
@@ -2768,7 +2778,8 @@ qlafx00_process_response_queue(struct scsi_qla_host *vha,
2768 break; 2778 break;
2769 } 2779 }
2770next_iter: 2780next_iter:
2771 WRT_REG_DWORD(&lptr->signature, RESPONSE_PROCESSED); 2781 WRT_REG_DWORD((void __iomem *)&lptr->signature,
2782 RESPONSE_PROCESSED);
2772 wmb(); 2783 wmb();
2773 } 2784 }
2774 2785
@@ -2958,8 +2969,7 @@ qlafx00_prep_cont_type1_iocb(struct req_que *req,
2958 cont_pkt = (cont_a64_entry_t *)req->ring_ptr; 2969 cont_pkt = (cont_a64_entry_t *)req->ring_ptr;
2959 2970
2960 /* Load packet defaults. */ 2971 /* Load packet defaults. */
2961 *((uint32_t *)(&lcont_pkt->entry_type)) = 2972 lcont_pkt->entry_type = CONTINUE_A64_TYPE_FX00;
2962 __constant_cpu_to_le32(CONTINUE_A64_TYPE_FX00);
2963 2973
2964 return cont_pkt; 2974 return cont_pkt;
2965} 2975}
@@ -2969,7 +2979,7 @@ qlafx00_build_scsi_iocbs(srb_t *sp, struct cmd_type_7_fx00 *cmd_pkt,
2969 uint16_t tot_dsds, struct cmd_type_7_fx00 *lcmd_pkt) 2979 uint16_t tot_dsds, struct cmd_type_7_fx00 *lcmd_pkt)
2970{ 2980{
2971 uint16_t avail_dsds; 2981 uint16_t avail_dsds;
2972 uint32_t *cur_dsd; 2982 __le32 *cur_dsd;
2973 scsi_qla_host_t *vha; 2983 scsi_qla_host_t *vha;
2974 struct scsi_cmnd *cmd; 2984 struct scsi_cmnd *cmd;
2975 struct scatterlist *sg; 2985 struct scatterlist *sg;
@@ -2986,8 +2996,7 @@ qlafx00_build_scsi_iocbs(srb_t *sp, struct cmd_type_7_fx00 *cmd_pkt,
2986 cont_pkt = NULL; 2996 cont_pkt = NULL;
2987 2997
2988 /* Update entry type to indicate Command Type 3 IOCB */ 2998 /* Update entry type to indicate Command Type 3 IOCB */
2989 *((uint32_t *)(&lcmd_pkt->entry_type)) = 2999 lcmd_pkt->entry_type = FX00_COMMAND_TYPE_7;
2990 __constant_cpu_to_le32(FX00_COMMAND_TYPE_7);
2991 3000
2992 /* No data transfer */ 3001 /* No data transfer */
2993 if (!scsi_bufflen(cmd) || cmd->sc_data_direction == DMA_NONE) { 3002 if (!scsi_bufflen(cmd) || cmd->sc_data_direction == DMA_NONE) {
@@ -3006,7 +3015,7 @@ qlafx00_build_scsi_iocbs(srb_t *sp, struct cmd_type_7_fx00 *cmd_pkt,
3006 3015
3007 /* One DSD is available in the Command Type 3 IOCB */ 3016 /* One DSD is available in the Command Type 3 IOCB */
3008 avail_dsds = 1; 3017 avail_dsds = 1;
3009 cur_dsd = (uint32_t *)&lcmd_pkt->dseg_0_address; 3018 cur_dsd = (__le32 *)&lcmd_pkt->dseg_0_address;
3010 3019
3011 /* Load data segments */ 3020 /* Load data segments */
3012 scsi_for_each_sg(cmd, sg, tot_dsds, i) { 3021 scsi_for_each_sg(cmd, sg, tot_dsds, i) {
@@ -3021,7 +3030,7 @@ qlafx00_build_scsi_iocbs(srb_t *sp, struct cmd_type_7_fx00 *cmd_pkt,
3021 memset(&lcont_pkt, 0, REQUEST_ENTRY_SIZE); 3030 memset(&lcont_pkt, 0, REQUEST_ENTRY_SIZE);
3022 cont_pkt = 3031 cont_pkt =
3023 qlafx00_prep_cont_type1_iocb(req, &lcont_pkt); 3032 qlafx00_prep_cont_type1_iocb(req, &lcont_pkt);
3024 cur_dsd = (uint32_t *)lcont_pkt.dseg_0_address; 3033 cur_dsd = (__le32 *)lcont_pkt.dseg_0_address;
3025 avail_dsds = 5; 3034 avail_dsds = 5;
3026 cont = 1; 3035 cont = 1;
3027 } 3036 }
@@ -3224,13 +3233,13 @@ qlafx00_tm_iocb(srb_t *sp, struct tsk_mgmt_entry_fx00 *ptm_iocb)
3224 tm_iocb.timeout = cpu_to_le16(qla2x00_get_async_timeout(vha) + 2); 3233 tm_iocb.timeout = cpu_to_le16(qla2x00_get_async_timeout(vha) + 2);
3225 tm_iocb.tgt_id = cpu_to_le16(sp->fcport->tgt_id); 3234 tm_iocb.tgt_id = cpu_to_le16(sp->fcport->tgt_id);
3226 tm_iocb.control_flags = cpu_to_le32(fxio->u.tmf.flags); 3235 tm_iocb.control_flags = cpu_to_le32(fxio->u.tmf.flags);
3227 if (tm_iocb.control_flags == TCF_LUN_RESET) { 3236 if (tm_iocb.control_flags == cpu_to_le32((uint32_t)TCF_LUN_RESET)) {
3228 int_to_scsilun(fxio->u.tmf.lun, &llun); 3237 int_to_scsilun(fxio->u.tmf.lun, &llun);
3229 host_to_adap((uint8_t *)&llun, (uint8_t *)&tm_iocb.lun, 3238 host_to_adap((uint8_t *)&llun, (uint8_t *)&tm_iocb.lun,
3230 sizeof(struct scsi_lun)); 3239 sizeof(struct scsi_lun));
3231 } 3240 }
3232 3241
3233 memcpy((void __iomem *)ptm_iocb, &tm_iocb, 3242 memcpy((void *)ptm_iocb, &tm_iocb,
3234 sizeof(struct tsk_mgmt_entry_fx00)); 3243 sizeof(struct tsk_mgmt_entry_fx00));
3235 wmb(); 3244 wmb();
3236} 3245}
@@ -3252,7 +3261,7 @@ qlafx00_abort_iocb(srb_t *sp, struct abort_iocb_entry_fx00 *pabt_iocb)
3252 abt_iocb.tgt_id_sts = cpu_to_le16(sp->fcport->tgt_id); 3261 abt_iocb.tgt_id_sts = cpu_to_le16(sp->fcport->tgt_id);
3253 abt_iocb.req_que_no = cpu_to_le16(req->id); 3262 abt_iocb.req_que_no = cpu_to_le16(req->id);
3254 3263
3255 memcpy((void __iomem *)pabt_iocb, &abt_iocb, 3264 memcpy((void *)pabt_iocb, &abt_iocb,
3256 sizeof(struct abort_iocb_entry_fx00)); 3265 sizeof(struct abort_iocb_entry_fx00));
3257 wmb(); 3266 wmb();
3258} 3267}
@@ -3273,13 +3282,12 @@ qlafx00_fxdisc_iocb(srb_t *sp, struct fxdisc_entry_fx00 *pfxiocb)
3273 3282
3274 if (sp->type == SRB_FXIOCB_DCMD) { 3283 if (sp->type == SRB_FXIOCB_DCMD) {
3275 fx_iocb.func_num = 3284 fx_iocb.func_num =
3276 cpu_to_le16(sp->u.iocb_cmd.u.fxiocb.req_func_type); 3285 sp->u.iocb_cmd.u.fxiocb.req_func_type;
3277 fx_iocb.adapid = cpu_to_le32(fxio->u.fxiocb.adapter_id); 3286 fx_iocb.adapid = fxio->u.fxiocb.adapter_id;
3278 fx_iocb.adapid_hi = cpu_to_le32(fxio->u.fxiocb.adapter_id_hi); 3287 fx_iocb.adapid_hi = fxio->u.fxiocb.adapter_id_hi;
3279 fx_iocb.reserved_0 = cpu_to_le32(fxio->u.fxiocb.reserved_0); 3288 fx_iocb.reserved_0 = fxio->u.fxiocb.reserved_0;
3280 fx_iocb.reserved_1 = cpu_to_le32(fxio->u.fxiocb.reserved_1); 3289 fx_iocb.reserved_1 = fxio->u.fxiocb.reserved_1;
3281 fx_iocb.dataword_extra = 3290 fx_iocb.dataword_extra = fxio->u.fxiocb.req_data_extra;
3282 cpu_to_le32(fxio->u.fxiocb.req_data_extra);
3283 3291
3284 if (fxio->u.fxiocb.flags & SRB_FXDISC_REQ_DMA_VALID) { 3292 if (fxio->u.fxiocb.flags & SRB_FXDISC_REQ_DMA_VALID) {
3285 fx_iocb.req_dsdcnt = cpu_to_le16(1); 3293 fx_iocb.req_dsdcnt = cpu_to_le16(1);
@@ -3306,8 +3314,7 @@ qlafx00_fxdisc_iocb(srb_t *sp, struct fxdisc_entry_fx00 *pfxiocb)
3306 } 3314 }
3307 3315
3308 if (fxio->u.fxiocb.flags & SRB_FXDISC_REQ_DWRD_VALID) { 3316 if (fxio->u.fxiocb.flags & SRB_FXDISC_REQ_DWRD_VALID) {
3309 fx_iocb.dataword = 3317 fx_iocb.dataword = fxio->u.fxiocb.req_data;
3310 cpu_to_le32(fxio->u.fxiocb.req_data);
3311 } 3318 }
3312 fx_iocb.flags = fxio->u.fxiocb.flags; 3319 fx_iocb.flags = fxio->u.fxiocb.flags;
3313 } else { 3320 } else {
@@ -3323,21 +3330,21 @@ qlafx00_fxdisc_iocb(srb_t *sp, struct fxdisc_entry_fx00 *pfxiocb)
3323 fx_iocb.reserved_1 = piocb_rqst->reserved_1; 3330 fx_iocb.reserved_1 = piocb_rqst->reserved_1;
3324 fx_iocb.dataword_extra = piocb_rqst->dataword_extra; 3331 fx_iocb.dataword_extra = piocb_rqst->dataword_extra;
3325 fx_iocb.dataword = piocb_rqst->dataword; 3332 fx_iocb.dataword = piocb_rqst->dataword;
3326 fx_iocb.req_xfrcnt = cpu_to_le16(piocb_rqst->req_len); 3333 fx_iocb.req_xfrcnt = piocb_rqst->req_len;
3327 fx_iocb.rsp_xfrcnt = cpu_to_le16(piocb_rqst->rsp_len); 3334 fx_iocb.rsp_xfrcnt = piocb_rqst->rsp_len;
3328 3335
3329 if (piocb_rqst->flags & SRB_FXDISC_REQ_DMA_VALID) { 3336 if (piocb_rqst->flags & SRB_FXDISC_REQ_DMA_VALID) {
3330 int avail_dsds, tot_dsds; 3337 int avail_dsds, tot_dsds;
3331 cont_a64_entry_t lcont_pkt; 3338 cont_a64_entry_t lcont_pkt;
3332 cont_a64_entry_t *cont_pkt = NULL; 3339 cont_a64_entry_t *cont_pkt = NULL;
3333 uint32_t *cur_dsd; 3340 __le32 *cur_dsd;
3334 int index = 0, cont = 0; 3341 int index = 0, cont = 0;
3335 3342
3336 fx_iocb.req_dsdcnt = 3343 fx_iocb.req_dsdcnt =
3337 cpu_to_le16(bsg_job->request_payload.sg_cnt); 3344 cpu_to_le16(bsg_job->request_payload.sg_cnt);
3338 tot_dsds = 3345 tot_dsds =
3339 cpu_to_le32(bsg_job->request_payload.sg_cnt); 3346 bsg_job->request_payload.sg_cnt;
3340 cur_dsd = (uint32_t *)&fx_iocb.dseg_rq_address[0]; 3347 cur_dsd = (__le32 *)&fx_iocb.dseg_rq_address[0];
3341 avail_dsds = 1; 3348 avail_dsds = 1;
3342 for_each_sg(bsg_job->request_payload.sg_list, sg, 3349 for_each_sg(bsg_job->request_payload.sg_list, sg,
3343 tot_dsds, index) { 3350 tot_dsds, index) {
@@ -3355,7 +3362,7 @@ qlafx00_fxdisc_iocb(srb_t *sp, struct fxdisc_entry_fx00 *pfxiocb)
3355 qlafx00_prep_cont_type1_iocb( 3362 qlafx00_prep_cont_type1_iocb(
3356 sp->fcport->vha->req, 3363 sp->fcport->vha->req,
3357 &lcont_pkt); 3364 &lcont_pkt);
3358 cur_dsd = (uint32_t *) 3365 cur_dsd = (__le32 *)
3359 lcont_pkt.dseg_0_address; 3366 lcont_pkt.dseg_0_address;
3360 avail_dsds = 5; 3367 avail_dsds = 5;
3361 cont = 1; 3368 cont = 1;
@@ -3393,13 +3400,13 @@ qlafx00_fxdisc_iocb(srb_t *sp, struct fxdisc_entry_fx00 *pfxiocb)
3393 int avail_dsds, tot_dsds; 3400 int avail_dsds, tot_dsds;
3394 cont_a64_entry_t lcont_pkt; 3401 cont_a64_entry_t lcont_pkt;
3395 cont_a64_entry_t *cont_pkt = NULL; 3402 cont_a64_entry_t *cont_pkt = NULL;
3396 uint32_t *cur_dsd; 3403 __le32 *cur_dsd;
3397 int index = 0, cont = 0; 3404 int index = 0, cont = 0;
3398 3405
3399 fx_iocb.rsp_dsdcnt = 3406 fx_iocb.rsp_dsdcnt =
3400 cpu_to_le16(bsg_job->reply_payload.sg_cnt); 3407 cpu_to_le16(bsg_job->reply_payload.sg_cnt);
3401 tot_dsds = cpu_to_le32(bsg_job->reply_payload.sg_cnt); 3408 tot_dsds = bsg_job->reply_payload.sg_cnt;
3402 cur_dsd = (uint32_t *)&fx_iocb.dseg_rsp_address[0]; 3409 cur_dsd = (__le32 *)&fx_iocb.dseg_rsp_address[0];
3403 avail_dsds = 1; 3410 avail_dsds = 1;
3404 3411
3405 for_each_sg(bsg_job->reply_payload.sg_list, sg, 3412 for_each_sg(bsg_job->reply_payload.sg_list, sg,
@@ -3418,7 +3425,7 @@ qlafx00_fxdisc_iocb(srb_t *sp, struct fxdisc_entry_fx00 *pfxiocb)
3418 qlafx00_prep_cont_type1_iocb( 3425 qlafx00_prep_cont_type1_iocb(
3419 sp->fcport->vha->req, 3426 sp->fcport->vha->req,
3420 &lcont_pkt); 3427 &lcont_pkt);
3421 cur_dsd = (uint32_t *) 3428 cur_dsd = (__le32 *)
3422 lcont_pkt.dseg_0_address; 3429 lcont_pkt.dseg_0_address;
3423 avail_dsds = 5; 3430 avail_dsds = 5;
3424 cont = 1; 3431 cont = 1;
@@ -3453,7 +3460,7 @@ qlafx00_fxdisc_iocb(srb_t *sp, struct fxdisc_entry_fx00 *pfxiocb)
3453 } 3460 }
3454 3461
3455 if (piocb_rqst->flags & SRB_FXDISC_REQ_DWRD_VALID) 3462 if (piocb_rqst->flags & SRB_FXDISC_REQ_DWRD_VALID)
3456 fx_iocb.dataword = cpu_to_le32(piocb_rqst->dataword); 3463 fx_iocb.dataword = piocb_rqst->dataword;
3457 fx_iocb.flags = piocb_rqst->flags; 3464 fx_iocb.flags = piocb_rqst->flags;
3458 fx_iocb.entry_count = entry_cnt; 3465 fx_iocb.entry_count = entry_cnt;
3459 } 3466 }
@@ -3462,7 +3469,7 @@ qlafx00_fxdisc_iocb(srb_t *sp, struct fxdisc_entry_fx00 *pfxiocb)
3462 sp->fcport->vha, 0x3047, 3469 sp->fcport->vha, 0x3047,
3463 (uint8_t *)&fx_iocb, sizeof(struct fxdisc_entry_fx00)); 3470 (uint8_t *)&fx_iocb, sizeof(struct fxdisc_entry_fx00));
3464 3471
3465 memcpy((void __iomem *)pfxiocb, &fx_iocb, 3472 memcpy((void *)pfxiocb, &fx_iocb,
3466 sizeof(struct fxdisc_entry_fx00)); 3473 sizeof(struct fxdisc_entry_fx00));
3467 wmb(); 3474 wmb();
3468} 3475}
diff --git a/drivers/scsi/qla2xxx/qla_mr.h b/drivers/scsi/qla2xxx/qla_mr.h
index cc327dc2fd10..1a092af0e2c3 100644
--- a/drivers/scsi/qla2xxx/qla_mr.h
+++ b/drivers/scsi/qla2xxx/qla_mr.h
@@ -24,10 +24,10 @@ struct cmd_type_7_fx00 {
24 uint32_t handle; /* System handle. */ 24 uint32_t handle; /* System handle. */
25 uint32_t handle_hi; 25 uint32_t handle_hi;
26 26
27 uint16_t tgt_idx; /* Target Idx. */ 27 __le16 tgt_idx; /* Target Idx. */
28 uint16_t timeout; /* Command timeout. */ 28 uint16_t timeout; /* Command timeout. */
29 29
30 uint16_t dseg_count; /* Data segment count. */ 30 __le16 dseg_count; /* Data segment count. */
31 uint16_t scsi_rsp_dsd_len; 31 uint16_t scsi_rsp_dsd_len;
32 32
33 struct scsi_lun lun; /* LUN (LE). */ 33 struct scsi_lun lun; /* LUN (LE). */
@@ -41,7 +41,7 @@ struct cmd_type_7_fx00 {
41 uint8_t crn; 41 uint8_t crn;
42 42
43 uint8_t fcp_cdb[MAX_CMDSZ]; /* SCSI command words. */ 43 uint8_t fcp_cdb[MAX_CMDSZ]; /* SCSI command words. */
44 uint32_t byte_count; /* Total byte count. */ 44 __le32 byte_count; /* Total byte count. */
45 45
46 uint32_t dseg_0_address[2]; /* Data segment 0 address. */ 46 uint32_t dseg_0_address[2]; /* Data segment 0 address. */
47 uint32_t dseg_0_len; /* Data segment 0 length. */ 47 uint32_t dseg_0_len; /* Data segment 0 length. */
@@ -81,16 +81,16 @@ struct sts_entry_fx00 {
81 uint32_t handle; /* System handle. */ 81 uint32_t handle; /* System handle. */
82 uint32_t handle_hi; /* System handle. */ 82 uint32_t handle_hi; /* System handle. */
83 83
84 uint16_t comp_status; /* Completion status. */ 84 __le16 comp_status; /* Completion status. */
85 uint16_t reserved_0; /* OX_ID used by the firmware. */ 85 uint16_t reserved_0; /* OX_ID used by the firmware. */
86 86
87 uint32_t residual_len; /* FW calc residual transfer length. */ 87 __le32 residual_len; /* FW calc residual transfer length. */
88 88
89 uint16_t reserved_1; 89 uint16_t reserved_1;
90 uint16_t state_flags; /* State flags. */ 90 uint16_t state_flags; /* State flags. */
91 91
92 uint16_t reserved_2; 92 uint16_t reserved_2;
93 uint16_t scsi_status; /* SCSI status. */ 93 __le16 scsi_status; /* SCSI status. */
94 94
95 uint32_t sense_len; /* FCP SENSE length. */ 95 uint32_t sense_len; /* FCP SENSE length. */
96 uint8_t data[32]; /* FCP response/sense information. */ 96 uint8_t data[32]; /* FCP response/sense information. */
@@ -106,7 +106,7 @@ struct multi_sts_entry_fx00 {
106 uint8_t handle_count; 106 uint8_t handle_count;
107 uint8_t entry_status; 107 uint8_t entry_status;
108 108
109 uint32_t handles[MAX_HANDLE_COUNT]; 109 __le32 handles[MAX_HANDLE_COUNT];
110}; 110};
111 111
112#define TSK_MGMT_IOCB_TYPE_FX00 0x05 112#define TSK_MGMT_IOCB_TYPE_FX00 0x05
@@ -116,21 +116,21 @@ struct tsk_mgmt_entry_fx00 {
116 uint8_t sys_define; 116 uint8_t sys_define;
117 uint8_t entry_status; /* Entry Status. */ 117 uint8_t entry_status; /* Entry Status. */
118 118
119 uint32_t handle; /* System handle. */ 119 __le32 handle; /* System handle. */
120 120
121 uint32_t handle_hi; /* System handle. */ 121 uint32_t handle_hi; /* System handle. */
122 122
123 uint16_t tgt_id; /* Target Idx. */ 123 __le16 tgt_id; /* Target Idx. */
124 124
125 uint16_t reserved_1; 125 uint16_t reserved_1;
126 126
127 uint16_t delay; /* Activity delay in seconds. */ 127 uint16_t delay; /* Activity delay in seconds. */
128 128
129 uint16_t timeout; /* Command timeout. */ 129 __le16 timeout; /* Command timeout. */
130 130
131 struct scsi_lun lun; /* LUN (LE). */ 131 struct scsi_lun lun; /* LUN (LE). */
132 132
133 uint32_t control_flags; /* Control Flags. */ 133 __le32 control_flags; /* Control Flags. */
134 134
135 uint8_t reserved_2[32]; 135 uint8_t reserved_2[32];
136}; 136};
@@ -143,16 +143,16 @@ struct abort_iocb_entry_fx00 {
143 uint8_t sys_define; /* System defined. */ 143 uint8_t sys_define; /* System defined. */
144 uint8_t entry_status; /* Entry Status. */ 144 uint8_t entry_status; /* Entry Status. */
145 145
146 uint32_t handle; /* System handle. */ 146 __le32 handle; /* System handle. */
147 uint32_t handle_hi; /* System handle. */ 147 __le32 handle_hi; /* System handle. */
148 148
149 uint16_t tgt_id_sts; /* Completion status. */ 149 __le16 tgt_id_sts; /* Completion status. */
150 uint16_t options; 150 __le16 options;
151 151
152 uint32_t abort_handle; /* System handle. */ 152 __le32 abort_handle; /* System handle. */
153 uint32_t abort_handle_hi; /* System handle. */ 153 __le32 abort_handle_hi; /* System handle. */
154 154
155 uint16_t req_que_no; 155 __le16 req_que_no;
156 uint8_t reserved_1[38]; 156 uint8_t reserved_1[38];
157}; 157};
158 158
@@ -167,17 +167,17 @@ struct ioctl_iocb_entry_fx00 {
167 uint32_t reserved_0; /* System handle. */ 167 uint32_t reserved_0; /* System handle. */
168 168
169 uint16_t comp_func_num; 169 uint16_t comp_func_num;
170 uint16_t fw_iotcl_flags; 170 __le16 fw_iotcl_flags;
171 171
172 uint32_t dataword_r; /* Data word returned */ 172 __le32 dataword_r; /* Data word returned */
173 uint32_t adapid; /* Adapter ID */ 173 uint32_t adapid; /* Adapter ID */
174 uint32_t adapid_hi; /* Adapter ID high */ 174 uint32_t adapid_hi; /* Adapter ID high */
175 uint32_t reserved_1; 175 uint32_t reserved_1;
176 176
177 uint32_t seq_no; 177 __le32 seq_no;
178 uint8_t reserved_2[20]; 178 uint8_t reserved_2[20];
179 uint32_t residuallen; 179 uint32_t residuallen;
180 uint32_t status; 180 __le32 status;
181}; 181};
182 182
183#define STATUS_CONT_TYPE_FX00 0x04 183#define STATUS_CONT_TYPE_FX00 0x04
@@ -189,26 +189,26 @@ struct fxdisc_entry_fx00 {
189 uint8_t sys_define; /* System Defined. */ 189 uint8_t sys_define; /* System Defined. */
190 uint8_t entry_status; /* Entry Status. */ 190 uint8_t entry_status; /* Entry Status. */
191 191
192 uint32_t handle; /* System handle. */ 192 __le32 handle; /* System handle. */
193 uint32_t reserved_0; /* System handle. */ 193 __le32 reserved_0; /* System handle. */
194 194
195 uint16_t func_num; 195 __le16 func_num;
196 uint16_t req_xfrcnt; 196 __le16 req_xfrcnt;
197 uint16_t req_dsdcnt; 197 __le16 req_dsdcnt;
198 uint16_t rsp_xfrcnt; 198 __le16 rsp_xfrcnt;
199 uint16_t rsp_dsdcnt; 199 __le16 rsp_dsdcnt;
200 uint8_t flags; 200 uint8_t flags;
201 uint8_t reserved_1; 201 uint8_t reserved_1;
202 202
203 uint32_t dseg_rq_address[2]; /* Data segment 0 address. */ 203 __le32 dseg_rq_address[2]; /* Data segment 0 address. */
204 uint32_t dseg_rq_len; /* Data segment 0 length. */ 204 __le32 dseg_rq_len; /* Data segment 0 length. */
205 uint32_t dseg_rsp_address[2]; /* Data segment 1 address. */ 205 __le32 dseg_rsp_address[2]; /* Data segment 1 address. */
206 uint32_t dseg_rsp_len; /* Data segment 1 length. */ 206 __le32 dseg_rsp_len; /* Data segment 1 length. */
207 207
208 uint32_t dataword; 208 __le32 dataword;
209 uint32_t adapid; 209 __le32 adapid;
210 uint32_t adapid_hi; 210 __le32 adapid_hi;
211 uint32_t dataword_extra; 211 __le32 dataword_extra;
212}; 212};
213 213
214struct qlafx00_tgt_node_info { 214struct qlafx00_tgt_node_info {
@@ -421,43 +421,43 @@ struct config_info_data {
421 WRT_REG_DWORD((ha)->cregbase + off, val) 421 WRT_REG_DWORD((ha)->cregbase + off, val)
422 422
423struct qla_mt_iocb_rqst_fx00 { 423struct qla_mt_iocb_rqst_fx00 {
424 uint32_t reserved_0; 424 __le32 reserved_0;
425 425
426 uint16_t func_type; 426 __le16 func_type;
427 uint8_t flags; 427 uint8_t flags;
428 uint8_t reserved_1; 428 uint8_t reserved_1;
429 429
430 uint32_t dataword; 430 __le32 dataword;
431 431
432 uint32_t adapid; 432 __le32 adapid;
433 uint32_t adapid_hi; 433 __le32 adapid_hi;
434 434
435 uint32_t dataword_extra; 435 __le32 dataword_extra;
436 436
437 uint32_t req_len; 437 __le32 req_len;
438 438
439 uint32_t rsp_len; 439 __le32 rsp_len;
440}; 440};
441 441
442struct qla_mt_iocb_rsp_fx00 { 442struct qla_mt_iocb_rsp_fx00 {
443 uint32_t reserved_1; 443 uint32_t reserved_1;
444 444
445 uint16_t func_type; 445 uint16_t func_type;
446 uint16_t ioctl_flags; 446 __le16 ioctl_flags;
447 447
448 uint32_t ioctl_data; 448 __le32 ioctl_data;
449 449
450 uint32_t adapid; 450 uint32_t adapid;
451 uint32_t adapid_hi; 451 uint32_t adapid_hi;
452 452
453 uint32_t reserved_2; 453 uint32_t reserved_2;
454 uint32_t seq_number; 454 __le32 seq_number;
455 455
456 uint8_t reserved_3[20]; 456 uint8_t reserved_3[20];
457 457
458 int32_t res_count; 458 int32_t res_count;
459 459
460 uint32_t status; 460 __le32 status;
461}; 461};
462 462
463 463
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index ad72c1d85111..3e21e9fc9d91 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -104,8 +104,6 @@ MODULE_PARM_DESC(ql2xshiftctondsd,
104 "Set to control shifting of command type processing " 104 "Set to control shifting of command type processing "
105 "based on total number of SG elements."); 105 "based on total number of SG elements.");
106 106
107static void qla2x00_free_device(scsi_qla_host_t *);
108
109int ql2xfdmienable=1; 107int ql2xfdmienable=1;
110module_param(ql2xfdmienable, int, S_IRUGO); 108module_param(ql2xfdmienable, int, S_IRUGO);
111MODULE_PARM_DESC(ql2xfdmienable, 109MODULE_PARM_DESC(ql2xfdmienable,
@@ -237,6 +235,7 @@ static int qla2xxx_eh_host_reset(struct scsi_cmnd *);
237 235
238static int qla2x00_change_queue_depth(struct scsi_device *, int, int); 236static int qla2x00_change_queue_depth(struct scsi_device *, int, int);
239static int qla2x00_change_queue_type(struct scsi_device *, int); 237static int qla2x00_change_queue_type(struct scsi_device *, int);
238static void qla2x00_free_device(scsi_qla_host_t *);
240 239
241struct scsi_host_template qla2xxx_driver_template = { 240struct scsi_host_template qla2xxx_driver_template = {
242 .module = THIS_MODULE, 241 .module = THIS_MODULE,
@@ -2840,8 +2839,7 @@ skip_dpc:
2840 qla2x00_dfs_setup(base_vha); 2839 qla2x00_dfs_setup(base_vha);
2841 2840
2842 ql_log(ql_log_info, base_vha, 0x00fb, 2841 ql_log(ql_log_info, base_vha, 0x00fb,
2843 "QLogic %s - %s.\n", 2842 "QLogic %s - %s.\n", ha->model_number, ha->model_desc);
2844 ha->model_number, ha->model_desc ? ha->model_desc : "");
2845 ql_log(ql_log_info, base_vha, 0x00fc, 2843 ql_log(ql_log_info, base_vha, 0x00fc,
2846 "ISP%04X: %s @ %s hdma%c host#=%ld fw=%s.\n", 2844 "ISP%04X: %s @ %s hdma%c host#=%ld fw=%s.\n",
2847 pdev->device, ha->isp_ops->pci_info_str(base_vha, pci_info), 2845 pdev->device, ha->isp_ops->pci_info_str(base_vha, pci_info),
@@ -2981,14 +2979,12 @@ qla2x00_remove_one(struct pci_dev *pdev)
2981 set_bit(UNLOADING, &base_vha->dpc_flags); 2979 set_bit(UNLOADING, &base_vha->dpc_flags);
2982 mutex_lock(&ha->vport_lock); 2980 mutex_lock(&ha->vport_lock);
2983 while (ha->cur_vport_count) { 2981 while (ha->cur_vport_count) {
2984 struct Scsi_Host *scsi_host;
2985
2986 spin_lock_irqsave(&ha->vport_slock, flags); 2982 spin_lock_irqsave(&ha->vport_slock, flags);
2987 2983
2988 BUG_ON(base_vha->list.next == &ha->vp_list); 2984 BUG_ON(base_vha->list.next == &ha->vp_list);
2989 /* This assumes first entry in ha->vp_list is always base vha */ 2985 /* This assumes first entry in ha->vp_list is always base vha */
2990 vha = list_first_entry(&base_vha->list, scsi_qla_host_t, list); 2986 vha = list_first_entry(&base_vha->list, scsi_qla_host_t, list);
2991 scsi_host = scsi_host_get(vha->host); 2987 scsi_host_get(vha->host);
2992 2988
2993 spin_unlock_irqrestore(&ha->vport_slock, flags); 2989 spin_unlock_irqrestore(&ha->vport_slock, flags);
2994 mutex_unlock(&ha->vport_lock); 2990 mutex_unlock(&ha->vport_lock);
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index d055450c2a4a..cb4fefa1bfba 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -258,7 +258,7 @@ struct sdebug_queued_cmd {
258static struct sdebug_queued_cmd queued_arr[SCSI_DEBUG_CANQUEUE]; 258static struct sdebug_queued_cmd queued_arr[SCSI_DEBUG_CANQUEUE];
259 259
260static unsigned char * fake_storep; /* ramdisk storage */ 260static unsigned char * fake_storep; /* ramdisk storage */
261static unsigned char *dif_storep; /* protection info */ 261static struct sd_dif_tuple *dif_storep; /* protection info */
262static void *map_storep; /* provisioning map */ 262static void *map_storep; /* provisioning map */
263 263
264static unsigned long map_size; 264static unsigned long map_size;
@@ -277,11 +277,6 @@ static char sdebug_proc_name[] = "scsi_debug";
277 277
278static struct bus_type pseudo_lld_bus; 278static struct bus_type pseudo_lld_bus;
279 279
280static inline sector_t dif_offset(sector_t sector)
281{
282 return sector << 3;
283}
284
285static struct device_driver sdebug_driverfs_driver = { 280static struct device_driver sdebug_driverfs_driver = {
286 .name = sdebug_proc_name, 281 .name = sdebug_proc_name,
287 .bus = &pseudo_lld_bus, 282 .bus = &pseudo_lld_bus,
@@ -1736,6 +1731,50 @@ static int do_device_access(struct scsi_cmnd *scmd,
1736 return ret; 1731 return ret;
1737} 1732}
1738 1733
1734static u16 dif_compute_csum(const void *buf, int len)
1735{
1736 u16 csum;
1737
1738 switch (scsi_debug_guard) {
1739 case 1:
1740 csum = ip_compute_csum(buf, len);
1741 break;
1742 case 0:
1743 csum = cpu_to_be16(crc_t10dif(buf, len));
1744 break;
1745 }
1746 return csum;
1747}
1748
1749static int dif_verify(struct sd_dif_tuple *sdt, const void *data,
1750 sector_t sector, u32 ei_lba)
1751{
1752 u16 csum = dif_compute_csum(data, scsi_debug_sector_size);
1753
1754 if (sdt->guard_tag != csum) {
1755 pr_err("%s: GUARD check failed on sector %lu rcvd 0x%04x, data 0x%04x\n",
1756 __func__,
1757 (unsigned long)sector,
1758 be16_to_cpu(sdt->guard_tag),
1759 be16_to_cpu(csum));
1760 return 0x01;
1761 }
1762 if (scsi_debug_dif == SD_DIF_TYPE1_PROTECTION &&
1763 be32_to_cpu(sdt->ref_tag) != (sector & 0xffffffff)) {
1764 pr_err("%s: REF check failed on sector %lu\n",
1765 __func__, (unsigned long)sector);
1766 return 0x03;
1767 }
1768 if (scsi_debug_dif == SD_DIF_TYPE2_PROTECTION &&
1769 be32_to_cpu(sdt->ref_tag) != ei_lba) {
1770 pr_err("%s: REF check failed on sector %lu\n",
1771 __func__, (unsigned long)sector);
1772 dif_errors++;
1773 return 0x03;
1774 }
1775 return 0;
1776}
1777
1739static int prot_verify_read(struct scsi_cmnd *SCpnt, sector_t start_sec, 1778static int prot_verify_read(struct scsi_cmnd *SCpnt, sector_t start_sec,
1740 unsigned int sectors, u32 ei_lba) 1779 unsigned int sectors, u32 ei_lba)
1741{ 1780{
@@ -1748,71 +1787,38 @@ static int prot_verify_read(struct scsi_cmnd *SCpnt, sector_t start_sec,
1748 1787
1749 start_sec = do_div(tmp_sec, sdebug_store_sectors); 1788 start_sec = do_div(tmp_sec, sdebug_store_sectors);
1750 1789
1751 sdt = (struct sd_dif_tuple *)(dif_storep + dif_offset(start_sec)); 1790 sdt = dif_storep + start_sec;
1752 1791
1753 for (i = 0 ; i < sectors ; i++) { 1792 for (i = 0 ; i < sectors ; i++) {
1754 u16 csum; 1793 int ret;
1755 1794
1756 if (sdt[i].app_tag == 0xffff) 1795 if (sdt[i].app_tag == 0xffff)
1757 continue; 1796 continue;
1758 1797
1759 sector = start_sec + i; 1798 sector = start_sec + i;
1760 1799
1761 switch (scsi_debug_guard) { 1800 ret = dif_verify(&sdt[i],
1762 case 1: 1801 fake_storep + sector * scsi_debug_sector_size,
1763 csum = ip_compute_csum(fake_storep + 1802 sector, ei_lba);
1764 sector * scsi_debug_sector_size, 1803 if (ret) {
1765 scsi_debug_sector_size);
1766 break;
1767 case 0:
1768 csum = crc_t10dif(fake_storep +
1769 sector * scsi_debug_sector_size,
1770 scsi_debug_sector_size);
1771 csum = cpu_to_be16(csum);
1772 break;
1773 default:
1774 BUG();
1775 }
1776
1777 if (sdt[i].guard_tag != csum) {
1778 printk(KERN_ERR "%s: GUARD check failed on sector %lu" \
1779 " rcvd 0x%04x, data 0x%04x\n", __func__,
1780 (unsigned long)sector,
1781 be16_to_cpu(sdt[i].guard_tag),
1782 be16_to_cpu(csum));
1783 dif_errors++;
1784 return 0x01;
1785 }
1786
1787 if (scsi_debug_dif == SD_DIF_TYPE1_PROTECTION &&
1788 be32_to_cpu(sdt[i].ref_tag) != (sector & 0xffffffff)) {
1789 printk(KERN_ERR "%s: REF check failed on sector %lu\n",
1790 __func__, (unsigned long)sector);
1791 dif_errors++; 1804 dif_errors++;
1792 return 0x03; 1805 return ret;
1793 }
1794
1795 if (scsi_debug_dif == SD_DIF_TYPE2_PROTECTION &&
1796 be32_to_cpu(sdt[i].ref_tag) != ei_lba) {
1797 printk(KERN_ERR "%s: REF check failed on sector %lu\n",
1798 __func__, (unsigned long)sector);
1799 dif_errors++;
1800 return 0x03;
1801 } 1806 }
1802 1807
1803 ei_lba++; 1808 ei_lba++;
1804 } 1809 }
1805 1810
1806 resid = sectors * 8; /* Bytes of protection data to copy into sgl */ 1811 /* Bytes of protection data to copy into sgl */
1812 resid = sectors * sizeof(*dif_storep);
1807 sector = start_sec; 1813 sector = start_sec;
1808 1814
1809 scsi_for_each_prot_sg(SCpnt, psgl, scsi_prot_sg_count(SCpnt), i) { 1815 scsi_for_each_prot_sg(SCpnt, psgl, scsi_prot_sg_count(SCpnt), i) {
1810 int len = min(psgl->length, resid); 1816 int len = min(psgl->length, resid);
1811 1817
1812 paddr = kmap_atomic(sg_page(psgl)) + psgl->offset; 1818 paddr = kmap_atomic(sg_page(psgl)) + psgl->offset;
1813 memcpy(paddr, dif_storep + dif_offset(sector), len); 1819 memcpy(paddr, dif_storep + sector, len);
1814 1820
1815 sector += len >> 3; 1821 sector += len / sizeof(*dif_storep);
1816 if (sector >= sdebug_store_sectors) { 1822 if (sector >= sdebug_store_sectors) {
1817 /* Force wrap */ 1823 /* Force wrap */
1818 tmp_sec = sector; 1824 tmp_sec = sector;
@@ -1910,22 +1916,21 @@ static int prot_verify_write(struct scsi_cmnd *SCpnt, sector_t start_sec,
1910 sector_t tmp_sec = start_sec; 1916 sector_t tmp_sec = start_sec;
1911 sector_t sector; 1917 sector_t sector;
1912 int ppage_offset; 1918 int ppage_offset;
1913 unsigned short csum;
1914 1919
1915 sector = do_div(tmp_sec, sdebug_store_sectors); 1920 sector = do_div(tmp_sec, sdebug_store_sectors);
1916 1921
1917 BUG_ON(scsi_sg_count(SCpnt) == 0); 1922 BUG_ON(scsi_sg_count(SCpnt) == 0);
1918 BUG_ON(scsi_prot_sg_count(SCpnt) == 0); 1923 BUG_ON(scsi_prot_sg_count(SCpnt) == 0);
1919 1924
1920 paddr = kmap_atomic(sg_page(psgl)) + psgl->offset;
1921 ppage_offset = 0; 1925 ppage_offset = 0;
1922 1926
1923 /* For each data page */ 1927 /* For each data page */
1924 scsi_for_each_sg(SCpnt, dsgl, scsi_sg_count(SCpnt), i) { 1928 scsi_for_each_sg(SCpnt, dsgl, scsi_sg_count(SCpnt), i) {
1925 daddr = kmap_atomic(sg_page(dsgl)) + dsgl->offset; 1929 daddr = kmap_atomic(sg_page(dsgl)) + dsgl->offset;
1930 paddr = kmap_atomic(sg_page(psgl)) + psgl->offset;
1926 1931
1927 /* For each sector-sized chunk in data page */ 1932 /* For each sector-sized chunk in data page */
1928 for (j = 0 ; j < dsgl->length ; j += scsi_debug_sector_size) { 1933 for (j = 0; j < dsgl->length; j += scsi_debug_sector_size) {
1929 1934
1930 /* If we're at the end of the current 1935 /* If we're at the end of the current
1931 * protection page advance to the next one 1936 * protection page advance to the next one
@@ -1941,51 +1946,9 @@ static int prot_verify_write(struct scsi_cmnd *SCpnt, sector_t start_sec,
1941 1946
1942 sdt = paddr + ppage_offset; 1947 sdt = paddr + ppage_offset;
1943 1948
1944 switch (scsi_debug_guard) { 1949 ret = dif_verify(sdt, daddr + j, start_sec, ei_lba);
1945 case 1: 1950 if (ret) {
1946 csum = ip_compute_csum(daddr, 1951 dump_sector(daddr + j, scsi_debug_sector_size);
1947 scsi_debug_sector_size);
1948 break;
1949 case 0:
1950 csum = cpu_to_be16(crc_t10dif(daddr,
1951 scsi_debug_sector_size));
1952 break;
1953 default:
1954 BUG();
1955 ret = 0;
1956 goto out;
1957 }
1958
1959 if (sdt->guard_tag != csum) {
1960 printk(KERN_ERR
1961 "%s: GUARD check failed on sector %lu " \
1962 "rcvd 0x%04x, calculated 0x%04x\n",
1963 __func__, (unsigned long)sector,
1964 be16_to_cpu(sdt->guard_tag),
1965 be16_to_cpu(csum));
1966 ret = 0x01;
1967 dump_sector(daddr, scsi_debug_sector_size);
1968 goto out;
1969 }
1970
1971 if (scsi_debug_dif == SD_DIF_TYPE1_PROTECTION &&
1972 be32_to_cpu(sdt->ref_tag)
1973 != (start_sec & 0xffffffff)) {
1974 printk(KERN_ERR
1975 "%s: REF check failed on sector %lu\n",
1976 __func__, (unsigned long)sector);
1977 ret = 0x03;
1978 dump_sector(daddr, scsi_debug_sector_size);
1979 goto out;
1980 }
1981
1982 if (scsi_debug_dif == SD_DIF_TYPE2_PROTECTION &&
1983 be32_to_cpu(sdt->ref_tag) != ei_lba) {
1984 printk(KERN_ERR
1985 "%s: REF check failed on sector %lu\n",
1986 __func__, (unsigned long)sector);
1987 ret = 0x03;
1988 dump_sector(daddr, scsi_debug_sector_size);
1989 goto out; 1952 goto out;
1990 } 1953 }
1991 1954
@@ -1994,7 +1957,7 @@ static int prot_verify_write(struct scsi_cmnd *SCpnt, sector_t start_sec,
1994 * correctness we need to verify each sector 1957 * correctness we need to verify each sector
1995 * before writing it to "stable" storage 1958 * before writing it to "stable" storage
1996 */ 1959 */
1997 memcpy(dif_storep + dif_offset(sector), sdt, 8); 1960 memcpy(dif_storep + sector, sdt, sizeof(*sdt));
1998 1961
1999 sector++; 1962 sector++;
2000 1963
@@ -2003,23 +1966,21 @@ static int prot_verify_write(struct scsi_cmnd *SCpnt, sector_t start_sec,
2003 1966
2004 start_sec++; 1967 start_sec++;
2005 ei_lba++; 1968 ei_lba++;
2006 daddr += scsi_debug_sector_size;
2007 ppage_offset += sizeof(struct sd_dif_tuple); 1969 ppage_offset += sizeof(struct sd_dif_tuple);
2008 } 1970 }
2009 1971
1972 kunmap_atomic(paddr);
2010 kunmap_atomic(daddr); 1973 kunmap_atomic(daddr);
2011 } 1974 }
2012 1975
2013 kunmap_atomic(paddr);
2014
2015 dix_writes++; 1976 dix_writes++;
2016 1977
2017 return 0; 1978 return 0;
2018 1979
2019out: 1980out:
2020 dif_errors++; 1981 dif_errors++;
2021 kunmap_atomic(daddr);
2022 kunmap_atomic(paddr); 1982 kunmap_atomic(paddr);
1983 kunmap_atomic(daddr);
2023 return ret; 1984 return ret;
2024} 1985}
2025 1986
@@ -2092,6 +2053,11 @@ static void unmap_region(sector_t lba, unsigned int len)
2092 scsi_debug_sector_size * 2053 scsi_debug_sector_size *
2093 scsi_debug_unmap_granularity); 2054 scsi_debug_unmap_granularity);
2094 } 2055 }
2056 if (dif_storep) {
2057 memset(dif_storep + lba, 0xff,
2058 sizeof(*dif_storep) *
2059 scsi_debug_unmap_granularity);
2060 }
2095 } 2061 }
2096 lba = map_index_to_lba(index + 1); 2062 lba = map_index_to_lba(index + 1);
2097 } 2063 }
@@ -3400,7 +3366,7 @@ static int __init scsi_debug_init(void)
3400 if (scsi_debug_num_parts > 0) 3366 if (scsi_debug_num_parts > 0)
3401 sdebug_build_parts(fake_storep, sz); 3367 sdebug_build_parts(fake_storep, sz);
3402 3368
3403 if (scsi_debug_dif) { 3369 if (scsi_debug_dix) {
3404 int dif_size; 3370 int dif_size;
3405 3371
3406 dif_size = sdebug_store_sectors * sizeof(struct sd_dif_tuple); 3372 dif_size = sdebug_store_sectors * sizeof(struct sd_dif_tuple);
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 86d522004a20..124392f3091e 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -434,6 +434,8 @@ static void scsi_run_queue(struct request_queue *q)
434 list_splice_init(&shost->starved_list, &starved_list); 434 list_splice_init(&shost->starved_list, &starved_list);
435 435
436 while (!list_empty(&starved_list)) { 436 while (!list_empty(&starved_list)) {
437 struct request_queue *slq;
438
437 /* 439 /*
438 * As long as shost is accepting commands and we have 440 * As long as shost is accepting commands and we have
439 * starved queues, call blk_run_queue. scsi_request_fn 441 * starved queues, call blk_run_queue. scsi_request_fn
@@ -456,11 +458,25 @@ static void scsi_run_queue(struct request_queue *q)
456 continue; 458 continue;
457 } 459 }
458 460
459 spin_unlock(shost->host_lock); 461 /*
460 spin_lock(sdev->request_queue->queue_lock); 462 * Once we drop the host lock, a racing scsi_remove_device()
461 __blk_run_queue(sdev->request_queue); 463 * call may remove the sdev from the starved list and destroy
462 spin_unlock(sdev->request_queue->queue_lock); 464 * it and the queue. Mitigate by taking a reference to the
463 spin_lock(shost->host_lock); 465 * queue and never touching the sdev again after we drop the
466 * host lock. Note: if __scsi_remove_device() invokes
467 * blk_cleanup_queue() before the queue is run from this
468 * function then blk_run_queue() will return immediately since
469 * blk_cleanup_queue() marks the queue with QUEUE_FLAG_DYING.
470 */
471 slq = sdev->request_queue;
472 if (!blk_get_queue(slq))
473 continue;
474 spin_unlock_irqrestore(shost->host_lock, flags);
475
476 blk_run_queue(slq);
477 blk_put_queue(slq);
478
479 spin_lock_irqsave(shost->host_lock, flags);
464 } 480 }
465 /* put any unprocessed entries back */ 481 /* put any unprocessed entries back */
466 list_splice(&starved_list, &shost->starved_list); 482 list_splice(&starved_list, &shost->starved_list);
@@ -2177,6 +2193,7 @@ scsi_device_set_state(struct scsi_device *sdev, enum scsi_device_state state)
2177 case SDEV_OFFLINE: 2193 case SDEV_OFFLINE:
2178 case SDEV_TRANSPORT_OFFLINE: 2194 case SDEV_TRANSPORT_OFFLINE:
2179 case SDEV_CANCEL: 2195 case SDEV_CANCEL:
2196 case SDEV_CREATED_BLOCK:
2180 break; 2197 break;
2181 default: 2198 default:
2182 goto illegal; 2199 goto illegal;
diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
index 945198910460..83ec1aa85964 100644
--- a/drivers/scsi/storvsc_drv.c
+++ b/drivers/scsi/storvsc_drv.c
@@ -326,7 +326,9 @@ MODULE_PARM_DESC(storvsc_ringbuffer_size, "Ring buffer size (bytes)");
326 */ 326 */
327static int storvsc_timeout = 180; 327static int storvsc_timeout = 180;
328 328
329#define STORVSC_MAX_IO_REQUESTS 128 329#define STORVSC_MAX_IO_REQUESTS 200
330
331static void storvsc_on_channel_callback(void *context);
330 332
331/* 333/*
332 * In Hyper-V, each port/path/target maps to 1 scsi host adapter. In 334 * In Hyper-V, each port/path/target maps to 1 scsi host adapter. In
@@ -364,6 +366,7 @@ struct storvsc_device {
364 366
365 bool destroy; 367 bool destroy;
366 bool drain_notify; 368 bool drain_notify;
369 bool open_sub_channel;
367 atomic_t num_outstanding_req; 370 atomic_t num_outstanding_req;
368 struct Scsi_Host *host; 371 struct Scsi_Host *host;
369 372
@@ -755,12 +758,104 @@ static unsigned int copy_to_bounce_buffer(struct scatterlist *orig_sgl,
755 return total_copied; 758 return total_copied;
756} 759}
757 760
761static void handle_sc_creation(struct vmbus_channel *new_sc)
762{
763 struct hv_device *device = new_sc->primary_channel->device_obj;
764 struct storvsc_device *stor_device;
765 struct vmstorage_channel_properties props;
766
767 stor_device = get_out_stor_device(device);
768 if (!stor_device)
769 return;
770
771 if (stor_device->open_sub_channel == false)
772 return;
773
774 memset(&props, 0, sizeof(struct vmstorage_channel_properties));
775
776 vmbus_open(new_sc,
777 storvsc_ringbuffer_size,
778 storvsc_ringbuffer_size,
779 (void *)&props,
780 sizeof(struct vmstorage_channel_properties),
781 storvsc_on_channel_callback, new_sc);
782}
783
784static void handle_multichannel_storage(struct hv_device *device, int max_chns)
785{
786 struct storvsc_device *stor_device;
787 int num_cpus = num_online_cpus();
788 int num_sc;
789 struct storvsc_cmd_request *request;
790 struct vstor_packet *vstor_packet;
791 int ret, t;
792
793 num_sc = ((max_chns > num_cpus) ? num_cpus : max_chns);
794 stor_device = get_out_stor_device(device);
795 if (!stor_device)
796 return;
797
798 request = &stor_device->init_request;
799 vstor_packet = &request->vstor_packet;
800
801 stor_device->open_sub_channel = true;
802 /*
803 * Establish a handler for dealing with subchannels.
804 */
805 vmbus_set_sc_create_callback(device->channel, handle_sc_creation);
806
807 /*
808 * Check to see if sub-channels have already been created. This
809 * can happen when this driver is re-loaded after unloading.
810 */
811
812 if (vmbus_are_subchannels_present(device->channel))
813 return;
814
815 stor_device->open_sub_channel = false;
816 /*
817 * Request the host to create sub-channels.
818 */
819 memset(request, 0, sizeof(struct storvsc_cmd_request));
820 init_completion(&request->wait_event);
821 vstor_packet->operation = VSTOR_OPERATION_CREATE_SUB_CHANNELS;
822 vstor_packet->flags = REQUEST_COMPLETION_FLAG;
823 vstor_packet->sub_channel_count = num_sc;
824
825 ret = vmbus_sendpacket(device->channel, vstor_packet,
826 (sizeof(struct vstor_packet) -
827 vmscsi_size_delta),
828 (unsigned long)request,
829 VM_PKT_DATA_INBAND,
830 VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
831
832 if (ret != 0)
833 return;
834
835 t = wait_for_completion_timeout(&request->wait_event, 10*HZ);
836 if (t == 0)
837 return;
838
839 if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO ||
840 vstor_packet->status != 0)
841 return;
842
843 /*
844 * Now that we created the sub-channels, invoke the check; this
845 * may trigger the callback.
846 */
847 stor_device->open_sub_channel = true;
848 vmbus_are_subchannels_present(device->channel);
849}
850
758static int storvsc_channel_init(struct hv_device *device) 851static int storvsc_channel_init(struct hv_device *device)
759{ 852{
760 struct storvsc_device *stor_device; 853 struct storvsc_device *stor_device;
761 struct storvsc_cmd_request *request; 854 struct storvsc_cmd_request *request;
762 struct vstor_packet *vstor_packet; 855 struct vstor_packet *vstor_packet;
763 int ret, t; 856 int ret, t;
857 int max_chns;
858 bool process_sub_channels = false;
764 859
765 stor_device = get_out_stor_device(device); 860 stor_device = get_out_stor_device(device);
766 if (!stor_device) 861 if (!stor_device)
@@ -855,6 +950,19 @@ static int storvsc_channel_init(struct hv_device *device)
855 vstor_packet->status != 0) 950 vstor_packet->status != 0)
856 goto cleanup; 951 goto cleanup;
857 952
953 /*
954 * Check to see if multi-channel support is there.
955 * Hosts that implement protocol version of 5.1 and above
956 * support multi-channel.
957 */
958 max_chns = vstor_packet->storage_channel_properties.max_channel_cnt;
959 if ((vmbus_proto_version != VERSION_WIN7) &&
960 (vmbus_proto_version != VERSION_WS2008)) {
961 if (vstor_packet->storage_channel_properties.flags &
962 STORAGE_CHANNEL_SUPPORTS_MULTI_CHANNEL)
963 process_sub_channels = true;
964 }
965
858 memset(vstor_packet, 0, sizeof(struct vstor_packet)); 966 memset(vstor_packet, 0, sizeof(struct vstor_packet));
859 vstor_packet->operation = VSTOR_OPERATION_END_INITIALIZATION; 967 vstor_packet->operation = VSTOR_OPERATION_END_INITIALIZATION;
860 vstor_packet->flags = REQUEST_COMPLETION_FLAG; 968 vstor_packet->flags = REQUEST_COMPLETION_FLAG;
@@ -879,6 +987,9 @@ static int storvsc_channel_init(struct hv_device *device)
879 vstor_packet->status != 0) 987 vstor_packet->status != 0)
880 goto cleanup; 988 goto cleanup;
881 989
990 if (process_sub_channels)
991 handle_multichannel_storage(device, max_chns);
992
882 993
883cleanup: 994cleanup:
884 return ret; 995 return ret;
@@ -1100,7 +1211,8 @@ static void storvsc_on_receive(struct hv_device *device,
1100 1211
1101static void storvsc_on_channel_callback(void *context) 1212static void storvsc_on_channel_callback(void *context)
1102{ 1213{
1103 struct hv_device *device = (struct hv_device *)context; 1214 struct vmbus_channel *channel = (struct vmbus_channel *)context;
1215 struct hv_device *device;
1104 struct storvsc_device *stor_device; 1216 struct storvsc_device *stor_device;
1105 u32 bytes_recvd; 1217 u32 bytes_recvd;
1106 u64 request_id; 1218 u64 request_id;
@@ -1108,13 +1220,17 @@ static void storvsc_on_channel_callback(void *context)
1108 struct storvsc_cmd_request *request; 1220 struct storvsc_cmd_request *request;
1109 int ret; 1221 int ret;
1110 1222
1223 if (channel->primary_channel != NULL)
1224 device = channel->primary_channel->device_obj;
1225 else
1226 device = channel->device_obj;
1111 1227
1112 stor_device = get_in_stor_device(device); 1228 stor_device = get_in_stor_device(device);
1113 if (!stor_device) 1229 if (!stor_device)
1114 return; 1230 return;
1115 1231
1116 do { 1232 do {
1117 ret = vmbus_recvpacket(device->channel, packet, 1233 ret = vmbus_recvpacket(channel, packet,
1118 ALIGN((sizeof(struct vstor_packet) - 1234 ALIGN((sizeof(struct vstor_packet) -
1119 vmscsi_size_delta), 8), 1235 vmscsi_size_delta), 8),
1120 &bytes_recvd, &request_id); 1236 &bytes_recvd, &request_id);
@@ -1155,7 +1271,7 @@ static int storvsc_connect_to_vsp(struct hv_device *device, u32 ring_size)
1155 ring_size, 1271 ring_size,
1156 (void *)&props, 1272 (void *)&props,
1157 sizeof(struct vmstorage_channel_properties), 1273 sizeof(struct vmstorage_channel_properties),
1158 storvsc_on_channel_callback, device); 1274 storvsc_on_channel_callback, device->channel);
1159 1275
1160 if (ret != 0) 1276 if (ret != 0)
1161 return ret; 1277 return ret;
@@ -1207,6 +1323,7 @@ static int storvsc_do_io(struct hv_device *device,
1207{ 1323{
1208 struct storvsc_device *stor_device; 1324 struct storvsc_device *stor_device;
1209 struct vstor_packet *vstor_packet; 1325 struct vstor_packet *vstor_packet;
1326 struct vmbus_channel *outgoing_channel;
1210 int ret = 0; 1327 int ret = 0;
1211 1328
1212 vstor_packet = &request->vstor_packet; 1329 vstor_packet = &request->vstor_packet;
@@ -1217,6 +1334,11 @@ static int storvsc_do_io(struct hv_device *device,
1217 1334
1218 1335
1219 request->device = device; 1336 request->device = device;
1337 /*
1338 * Select an an appropriate channel to send the request out.
1339 */
1340
1341 outgoing_channel = vmbus_get_outgoing_channel(device->channel);
1220 1342
1221 1343
1222 vstor_packet->flags |= REQUEST_COMPLETION_FLAG; 1344 vstor_packet->flags |= REQUEST_COMPLETION_FLAG;
@@ -1234,7 +1356,7 @@ static int storvsc_do_io(struct hv_device *device,
1234 vstor_packet->operation = VSTOR_OPERATION_EXECUTE_SRB; 1356 vstor_packet->operation = VSTOR_OPERATION_EXECUTE_SRB;
1235 1357
1236 if (request->data_buffer.len) { 1358 if (request->data_buffer.len) {
1237 ret = vmbus_sendpacket_multipagebuffer(device->channel, 1359 ret = vmbus_sendpacket_multipagebuffer(outgoing_channel,
1238 &request->data_buffer, 1360 &request->data_buffer,
1239 vstor_packet, 1361 vstor_packet,
1240 (sizeof(struct vstor_packet) - 1362 (sizeof(struct vstor_packet) -
@@ -1580,6 +1702,7 @@ static struct scsi_host_template scsi_driver = {
1580enum { 1702enum {
1581 SCSI_GUID, 1703 SCSI_GUID,
1582 IDE_GUID, 1704 IDE_GUID,
1705 SFC_GUID,
1583}; 1706};
1584 1707
1585static const struct hv_vmbus_device_id id_table[] = { 1708static const struct hv_vmbus_device_id id_table[] = {
@@ -1591,6 +1714,11 @@ static const struct hv_vmbus_device_id id_table[] = {
1591 { HV_IDE_GUID, 1714 { HV_IDE_GUID,
1592 .driver_data = IDE_GUID 1715 .driver_data = IDE_GUID
1593 }, 1716 },
1717 /* Fibre Channel GUID */
1718 {
1719 HV_SYNTHFC_GUID,
1720 .driver_data = SFC_GUID
1721 },
1594 { }, 1722 { },
1595}; 1723};
1596 1724
@@ -1643,6 +1771,7 @@ static int storvsc_probe(struct hv_device *device,
1643 } 1771 }
1644 1772
1645 stor_device->destroy = false; 1773 stor_device->destroy = false;
1774 stor_device->open_sub_channel = false;
1646 init_waitqueue_head(&stor_device->waiting_to_drain); 1775 init_waitqueue_head(&stor_device->waiting_to_drain);
1647 stor_device->device = device; 1776 stor_device->device = device;
1648 stor_device->host = host; 1777 stor_device->host = host;