diff options
author | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-15 11:19:33 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-15 11:19:33 -0400 |
commit | df3d80f5a5c74168be42788364d13cf6c83c7b9c (patch) | |
tree | 892a964c2fd28d028f2fb7471e8543d3f4006a58 /drivers/message/fusion | |
parent | 3d06f7a5f74a813cee817c4b30b5e6f0398da0be (diff) | |
parent | c8e91b0a8fc8493e3bf3efcb3c8f866e9453cf1c (diff) |
Merge master.kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6
* master.kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6: (207 commits)
[SCSI] gdth: fix CONFIG_ISA build failure
[SCSI] esp_scsi: remove __dev{init,exit}
[SCSI] gdth: !use_sg cleanup and use of scsi accessors
[SCSI] gdth: Move members from SCp to gdth_cmndinfo, stage 2
[SCSI] gdth: Setup proper per-command private data
[SCSI] gdth: Remove gdth_ctr_tab[]
[SCSI] gdth: switch to modern scsi host registration
[SCSI] gdth: gdth_interrupt() gdth_get_status() & gdth_wait() fixes
[SCSI] gdth: clean up host private data
[SCSI] gdth: Remove virt hosts
[SCSI] gdth: Reorder scsi_host_template intitializers
[SCSI] gdth: kill gdth_{read,write}[bwl] wrappers
[SCSI] gdth: Remove 2.4.x support, in-kernel changelog
[SCSI] gdth: split out pci probing
[SCSI] gdth: split out eisa probing
[SCSI] gdth: split out isa probing
gdth: Make one abuse of scsi_cmnd less obvious
[SCSI] NCR5380: Use scsi_eh API for REQUEST_SENSE invocation
[SCSI] usb storage: use scsi_eh API in REQUEST_SENSE execution
[SCSI] scsi_error: Refactoring scsi_error to facilitate in synchronous REQUEST_SENSE
...
Diffstat (limited to 'drivers/message/fusion')
27 files changed, 1564 insertions, 1213 deletions
diff --git a/drivers/message/fusion/Kconfig b/drivers/message/fusion/Kconfig index f55cc03a75c9..a34a11d2fef2 100644 --- a/drivers/message/fusion/Kconfig +++ b/drivers/message/fusion/Kconfig | |||
@@ -1,15 +1,19 @@ | |||
1 | 1 | ||
2 | menu "Fusion MPT device support" | 2 | menuconfig FUSION |
3 | bool "Fusion MPT device support" | ||
3 | depends on PCI | 4 | depends on PCI |
5 | ---help--- | ||
6 | Say Y here to get to see options for Fusion Message | ||
7 | Passing Technology (MPT) drivers. | ||
8 | This option alone does not add any kernel code. | ||
9 | |||
10 | If you say N, all options in this submenu will be skipped and disabled. | ||
4 | 11 | ||
5 | config FUSION | 12 | if FUSION |
6 | bool | ||
7 | default n | ||
8 | 13 | ||
9 | config FUSION_SPI | 14 | config FUSION_SPI |
10 | tristate "Fusion MPT ScsiHost drivers for SPI" | 15 | tristate "Fusion MPT ScsiHost drivers for SPI" |
11 | depends on PCI && SCSI | 16 | depends on PCI && SCSI |
12 | select FUSION | ||
13 | select SCSI_SPI_ATTRS | 17 | select SCSI_SPI_ATTRS |
14 | ---help--- | 18 | ---help--- |
15 | SCSI HOST support for a parallel SCSI host adapters. | 19 | SCSI HOST support for a parallel SCSI host adapters. |
@@ -20,11 +24,11 @@ config FUSION_SPI | |||
20 | LSI53C1020A | 24 | LSI53C1020A |
21 | LSI53C1030 | 25 | LSI53C1030 |
22 | LSI53C1035 | 26 | LSI53C1035 |
27 | ATTO UL4D | ||
23 | 28 | ||
24 | config FUSION_FC | 29 | config FUSION_FC |
25 | tristate "Fusion MPT ScsiHost drivers for FC" | 30 | tristate "Fusion MPT ScsiHost drivers for FC" |
26 | depends on PCI && SCSI | 31 | depends on PCI && SCSI |
27 | select FUSION | ||
28 | select SCSI_FC_ATTRS | 32 | select SCSI_FC_ATTRS |
29 | ---help--- | 33 | ---help--- |
30 | SCSI HOST support for a Fiber Channel host adapters. | 34 | SCSI HOST support for a Fiber Channel host adapters. |
@@ -37,12 +41,13 @@ config FUSION_FC | |||
37 | LSIFC929 | 41 | LSIFC929 |
38 | LSIFC929X | 42 | LSIFC929X |
39 | LSIFC929XL | 43 | LSIFC929XL |
44 | LSIFC949X | ||
45 | LSIFC949E | ||
40 | Brocade FC 410/420 | 46 | Brocade FC 410/420 |
41 | 47 | ||
42 | config FUSION_SAS | 48 | config FUSION_SAS |
43 | tristate "Fusion MPT ScsiHost drivers for SAS" | 49 | tristate "Fusion MPT ScsiHost drivers for SAS" |
44 | depends on PCI && SCSI | 50 | depends on PCI && SCSI |
45 | select FUSION | ||
46 | select SCSI_SAS_ATTRS | 51 | select SCSI_SAS_ATTRS |
47 | ---help--- | 52 | ---help--- |
48 | SCSI HOST support for a SAS host adapters. | 53 | SCSI HOST support for a SAS host adapters. |
@@ -53,10 +58,10 @@ config FUSION_SAS | |||
53 | LSISAS1068 | 58 | LSISAS1068 |
54 | LSISAS1064E | 59 | LSISAS1064E |
55 | LSISAS1068E | 60 | LSISAS1068E |
61 | LSISAS1078 | ||
56 | 62 | ||
57 | config FUSION_MAX_SGE | 63 | config FUSION_MAX_SGE |
58 | int "Maximum number of scatter gather entries (16 - 128)" | 64 | int "Maximum number of scatter gather entries (16 - 128)" |
59 | depends on FUSION | ||
60 | default "128" | 65 | default "128" |
61 | range 16 128 | 66 | range 16 128 |
62 | help | 67 | help |
@@ -104,7 +109,6 @@ config FUSION_LAN | |||
104 | 109 | ||
105 | config FUSION_LOGGING | 110 | config FUSION_LOGGING |
106 | bool "Fusion MPT logging facility" | 111 | bool "Fusion MPT logging facility" |
107 | depends on FUSION | ||
108 | ---help--- | 112 | ---help--- |
109 | This turns on a logging facility that can be used to debug a number | 113 | This turns on a logging facility that can be used to debug a number |
110 | of Fusion MPT related problems. | 114 | of Fusion MPT related problems. |
@@ -113,7 +117,7 @@ config FUSION_LOGGING | |||
113 | 117 | ||
114 | echo [level] > /sys/class/scsi_host/host#/debug_level | 118 | echo [level] > /sys/class/scsi_host/host#/debug_level |
115 | 119 | ||
116 | There are various debug levels that an be found in the source: | 120 | There are various debug levels that can be found in the source: |
117 | file:drivers/message/fusion/mptdebug.h | 121 | file:drivers/message/fusion/mptdebug.h |
118 | 122 | ||
119 | endmenu | 123 | endif # FUSION |
diff --git a/drivers/message/fusion/lsi/mpi.h b/drivers/message/fusion/lsi/mpi.h index 6a92e3d118fe..1acbdd61b670 100644 --- a/drivers/message/fusion/lsi/mpi.h +++ b/drivers/message/fusion/lsi/mpi.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2007 LSI Logic Corporation. | 2 | * Copyright (c) 2000-2007 LSI Corporation. |
3 | * | 3 | * |
4 | * | 4 | * |
5 | * Name: mpi.h | 5 | * Name: mpi.h |
diff --git a/drivers/message/fusion/lsi/mpi_cnfg.h b/drivers/message/fusion/lsi/mpi_cnfg.h index eda769730e39..2bd8adae0f00 100644 --- a/drivers/message/fusion/lsi/mpi_cnfg.h +++ b/drivers/message/fusion/lsi/mpi_cnfg.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2007 LSI Logic Corporation. | 2 | * Copyright (c) 2000-2007 LSI Corporation. |
3 | * | 3 | * |
4 | * | 4 | * |
5 | * Name: mpi_cnfg.h | 5 | * Name: mpi_cnfg.h |
diff --git a/drivers/message/fusion/lsi/mpi_fc.h b/drivers/message/fusion/lsi/mpi_fc.h index 51a6aeb990ba..627acfbb8623 100644 --- a/drivers/message/fusion/lsi/mpi_fc.h +++ b/drivers/message/fusion/lsi/mpi_fc.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2004 LSI Logic Corporation. | 2 | * Copyright (c) 2000-2004 LSI Corporation. |
3 | * | 3 | * |
4 | * | 4 | * |
5 | * Name: mpi_fc.h | 5 | * Name: mpi_fc.h |
diff --git a/drivers/message/fusion/lsi/mpi_history.txt b/drivers/message/fusion/lsi/mpi_history.txt index a1f479057ea3..241592ab13ad 100644 --- a/drivers/message/fusion/lsi/mpi_history.txt +++ b/drivers/message/fusion/lsi/mpi_history.txt | |||
@@ -3,7 +3,7 @@ | |||
3 | MPI Header File Change History | 3 | MPI Header File Change History |
4 | ============================== | 4 | ============================== |
5 | 5 | ||
6 | Copyright (c) 2000-2007 LSI Logic Corporation. | 6 | Copyright (c) 2000-2007 LSI Corporation. |
7 | 7 | ||
8 | --------------------------------------- | 8 | --------------------------------------- |
9 | Header Set Release Version: 01.05.16 | 9 | Header Set Release Version: 01.05.16 |
diff --git a/drivers/message/fusion/lsi/mpi_init.h b/drivers/message/fusion/lsi/mpi_init.h index 3a02615f12d6..a9e3693601a7 100644 --- a/drivers/message/fusion/lsi/mpi_init.h +++ b/drivers/message/fusion/lsi/mpi_init.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2007 LSI Logic Corporation. | 2 | * Copyright (c) 2000-2007 LSI Corporation. |
3 | * | 3 | * |
4 | * | 4 | * |
5 | * Name: mpi_init.h | 5 | * Name: mpi_init.h |
diff --git a/drivers/message/fusion/lsi/mpi_ioc.h b/drivers/message/fusion/lsi/mpi_ioc.h index b1893d185bc4..5cbb6bd048e1 100644 --- a/drivers/message/fusion/lsi/mpi_ioc.h +++ b/drivers/message/fusion/lsi/mpi_ioc.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2007 LSI Logic Corporation. | 2 | * Copyright (c) 2000-2007 LSI Corporation. |
3 | * | 3 | * |
4 | * | 4 | * |
5 | * Name: mpi_ioc.h | 5 | * Name: mpi_ioc.h |
diff --git a/drivers/message/fusion/lsi/mpi_lan.h b/drivers/message/fusion/lsi/mpi_lan.h index dc0b52ae83dd..03253b53b785 100644 --- a/drivers/message/fusion/lsi/mpi_lan.h +++ b/drivers/message/fusion/lsi/mpi_lan.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2004 LSI Logic Corporation. | 2 | * Copyright (c) 2000-2004 LSI Corporation. |
3 | * | 3 | * |
4 | * | 4 | * |
5 | * Name: mpi_lan.h | 5 | * Name: mpi_lan.h |
diff --git a/drivers/message/fusion/lsi/mpi_log_fc.h b/drivers/message/fusion/lsi/mpi_log_fc.h index dc98d46f9071..e4dafcefeecd 100644 --- a/drivers/message/fusion/lsi/mpi_log_fc.h +++ b/drivers/message/fusion/lsi/mpi_log_fc.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2001 LSI Logic Corporation. All rights reserved. | 2 | * Copyright (c) 2000-2001 LSI Corporation. All rights reserved. |
3 | * | 3 | * |
4 | * NAME: fc_log.h | 4 | * NAME: fc_log.h |
5 | * SUMMARY: MPI IocLogInfo definitions for the SYMFC9xx chips | 5 | * SUMMARY: MPI IocLogInfo definitions for the SYMFC9xx chips |
diff --git a/drivers/message/fusion/lsi/mpi_log_sas.h b/drivers/message/fusion/lsi/mpi_log_sas.h index 635bbe04513e..6be1f6b65777 100644 --- a/drivers/message/fusion/lsi/mpi_log_sas.h +++ b/drivers/message/fusion/lsi/mpi_log_sas.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * Copyright 2003 LSI Logic Corporation. All rights reserved. * | 3 | * Copyright 2003 LSI Corporation. All rights reserved. * |
4 | * * | 4 | * * |
5 | * Description * | 5 | * Description * |
6 | * ------------ * | 6 | * ------------ * |
diff --git a/drivers/message/fusion/lsi/mpi_raid.h b/drivers/message/fusion/lsi/mpi_raid.h index 32819b1ec8ec..2856108421d7 100644 --- a/drivers/message/fusion/lsi/mpi_raid.h +++ b/drivers/message/fusion/lsi/mpi_raid.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2001-2007 LSI Logic Corporation. | 2 | * Copyright (c) 2001-2007 LSI Corporation. |
3 | * | 3 | * |
4 | * | 4 | * |
5 | * Name: mpi_raid.h | 5 | * Name: mpi_raid.h |
diff --git a/drivers/message/fusion/lsi/mpi_sas.h b/drivers/message/fusion/lsi/mpi_sas.h index 8e990a0fa7a2..33fca83cefc2 100644 --- a/drivers/message/fusion/lsi/mpi_sas.h +++ b/drivers/message/fusion/lsi/mpi_sas.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2004-2006 LSI Logic Corporation. | 2 | * Copyright (c) 2004-2006 LSI Corporation. |
3 | * | 3 | * |
4 | * | 4 | * |
5 | * Name: mpi_sas.h | 5 | * Name: mpi_sas.h |
diff --git a/drivers/message/fusion/lsi/mpi_targ.h b/drivers/message/fusion/lsi/mpi_targ.h index 20b667315773..ff8c37d3fdcb 100644 --- a/drivers/message/fusion/lsi/mpi_targ.h +++ b/drivers/message/fusion/lsi/mpi_targ.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2004 LSI Logic Corporation. | 2 | * Copyright (c) 2000-2004 LSI Corporation. |
3 | * | 3 | * |
4 | * | 4 | * |
5 | * Name: mpi_targ.h | 5 | * Name: mpi_targ.h |
diff --git a/drivers/message/fusion/lsi/mpi_tool.h b/drivers/message/fusion/lsi/mpi_tool.h index aa9053da1f58..8834ae6ce0f2 100644 --- a/drivers/message/fusion/lsi/mpi_tool.h +++ b/drivers/message/fusion/lsi/mpi_tool.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2001-2005 LSI Logic Corporation. | 2 | * Copyright (c) 2001-2005 LSI Corporation. |
3 | * | 3 | * |
4 | * | 4 | * |
5 | * Name: mpi_tool.h | 5 | * Name: mpi_tool.h |
diff --git a/drivers/message/fusion/lsi/mpi_type.h b/drivers/message/fusion/lsi/mpi_type.h index 32cc9b1151b8..08dad9c1e446 100644 --- a/drivers/message/fusion/lsi/mpi_type.h +++ b/drivers/message/fusion/lsi/mpi_type.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2004 LSI Logic Corporation. | 2 | * Copyright (c) 2000-2004 LSI Corporation. |
3 | * | 3 | * |
4 | * | 4 | * |
5 | * Name: mpi_type.h | 5 | * Name: mpi_type.h |
diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c index 414c109f4cf5..52fb216dfe74 100644 --- a/drivers/message/fusion/mptbase.c +++ b/drivers/message/fusion/mptbase.c | |||
@@ -2,10 +2,10 @@ | |||
2 | * linux/drivers/message/fusion/mptbase.c | 2 | * linux/drivers/message/fusion/mptbase.c |
3 | * This is the Fusion MPT base driver which supports multiple | 3 | * This is the Fusion MPT base driver which supports multiple |
4 | * (SCSI + LAN) specialized protocol drivers. | 4 | * (SCSI + LAN) specialized protocol drivers. |
5 | * For use with LSI Logic PCI chip/adapter(s) | 5 | * For use with LSI PCI chip/adapter(s) |
6 | * running LSI Logic Fusion MPT (Message Passing Technology) firmware. | 6 | * running LSI Fusion MPT (Message Passing Technology) firmware. |
7 | * | 7 | * |
8 | * Copyright (c) 1999-2007 LSI Logic Corporation | 8 | * Copyright (c) 1999-2007 LSI Corporation |
9 | * (mailto:DL-MPTFusionLinux@lsi.com) | 9 | * (mailto:DL-MPTFusionLinux@lsi.com) |
10 | * | 10 | * |
11 | */ | 11 | */ |
@@ -102,8 +102,6 @@ static int mfcounter = 0; | |||
102 | /* | 102 | /* |
103 | * Public data... | 103 | * Public data... |
104 | */ | 104 | */ |
105 | int mpt_lan_index = -1; | ||
106 | int mpt_stm_index = -1; | ||
107 | 105 | ||
108 | struct proc_dir_entry *mpt_proc_root_dir; | 106 | struct proc_dir_entry *mpt_proc_root_dir; |
109 | 107 | ||
@@ -125,11 +123,14 @@ static MPT_EVHANDLER MptEvHandlers[MPT_MAX_PROTOCOL_DRIVERS]; | |||
125 | static MPT_RESETHANDLER MptResetHandlers[MPT_MAX_PROTOCOL_DRIVERS]; | 123 | static MPT_RESETHANDLER MptResetHandlers[MPT_MAX_PROTOCOL_DRIVERS]; |
126 | static struct mpt_pci_driver *MptDeviceDriverHandlers[MPT_MAX_PROTOCOL_DRIVERS]; | 124 | static struct mpt_pci_driver *MptDeviceDriverHandlers[MPT_MAX_PROTOCOL_DRIVERS]; |
127 | 125 | ||
128 | static int mpt_base_index = -1; | ||
129 | static int last_drv_idx = -1; | ||
130 | |||
131 | static DECLARE_WAIT_QUEUE_HEAD(mpt_waitq); | 126 | static DECLARE_WAIT_QUEUE_HEAD(mpt_waitq); |
132 | 127 | ||
128 | /* | ||
129 | * Driver Callback Index's | ||
130 | */ | ||
131 | static u8 mpt_base_index = MPT_MAX_PROTOCOL_DRIVERS; | ||
132 | static u8 last_drv_idx; | ||
133 | |||
133 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | 134 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ |
134 | /* | 135 | /* |
135 | * Forward protos... | 136 | * Forward protos... |
@@ -235,6 +236,23 @@ static int mpt_set_debug_level(const char *val, struct kernel_param *kp) | |||
235 | return 0; | 236 | return 0; |
236 | } | 237 | } |
237 | 238 | ||
239 | /** | ||
240 | * mpt_get_cb_idx - obtain cb_idx for registered driver | ||
241 | * @dclass: class driver enum | ||
242 | * | ||
243 | * Returns cb_idx, or zero means it wasn't found | ||
244 | **/ | ||
245 | static u8 | ||
246 | mpt_get_cb_idx(MPT_DRIVER_CLASS dclass) | ||
247 | { | ||
248 | u8 cb_idx; | ||
249 | |||
250 | for (cb_idx = MPT_MAX_PROTOCOL_DRIVERS-1; cb_idx; cb_idx--) | ||
251 | if (MptDriverClass[cb_idx] == dclass) | ||
252 | return cb_idx; | ||
253 | return 0; | ||
254 | } | ||
255 | |||
238 | /* | 256 | /* |
239 | * Process turbo (context) reply... | 257 | * Process turbo (context) reply... |
240 | */ | 258 | */ |
@@ -243,8 +261,8 @@ mpt_turbo_reply(MPT_ADAPTER *ioc, u32 pa) | |||
243 | { | 261 | { |
244 | MPT_FRAME_HDR *mf = NULL; | 262 | MPT_FRAME_HDR *mf = NULL; |
245 | MPT_FRAME_HDR *mr = NULL; | 263 | MPT_FRAME_HDR *mr = NULL; |
246 | int req_idx = 0; | 264 | u16 req_idx = 0; |
247 | int cb_idx; | 265 | u8 cb_idx; |
248 | 266 | ||
249 | dmfprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Got TURBO reply req_idx=%08x\n", | 267 | dmfprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Got TURBO reply req_idx=%08x\n", |
250 | ioc->name, pa)); | 268 | ioc->name, pa)); |
@@ -256,7 +274,7 @@ mpt_turbo_reply(MPT_ADAPTER *ioc, u32 pa) | |||
256 | mf = MPT_INDEX_2_MFPTR(ioc, req_idx); | 274 | mf = MPT_INDEX_2_MFPTR(ioc, req_idx); |
257 | break; | 275 | break; |
258 | case MPI_CONTEXT_REPLY_TYPE_LAN: | 276 | case MPI_CONTEXT_REPLY_TYPE_LAN: |
259 | cb_idx = mpt_lan_index; | 277 | cb_idx = mpt_get_cb_idx(MPTLAN_DRIVER); |
260 | /* | 278 | /* |
261 | * Blind set of mf to NULL here was fatal | 279 | * Blind set of mf to NULL here was fatal |
262 | * after lan_reply says "freeme" | 280 | * after lan_reply says "freeme" |
@@ -277,7 +295,7 @@ mpt_turbo_reply(MPT_ADAPTER *ioc, u32 pa) | |||
277 | mr = (MPT_FRAME_HDR *) CAST_U32_TO_PTR(pa); | 295 | mr = (MPT_FRAME_HDR *) CAST_U32_TO_PTR(pa); |
278 | break; | 296 | break; |
279 | case MPI_CONTEXT_REPLY_TYPE_SCSI_TARGET: | 297 | case MPI_CONTEXT_REPLY_TYPE_SCSI_TARGET: |
280 | cb_idx = mpt_stm_index; | 298 | cb_idx = mpt_get_cb_idx(MPTSTM_DRIVER); |
281 | mr = (MPT_FRAME_HDR *) CAST_U32_TO_PTR(pa); | 299 | mr = (MPT_FRAME_HDR *) CAST_U32_TO_PTR(pa); |
282 | break; | 300 | break; |
283 | default: | 301 | default: |
@@ -286,8 +304,8 @@ mpt_turbo_reply(MPT_ADAPTER *ioc, u32 pa) | |||
286 | } | 304 | } |
287 | 305 | ||
288 | /* Check for (valid) IO callback! */ | 306 | /* Check for (valid) IO callback! */ |
289 | if (cb_idx < 1 || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS || | 307 | if (!cb_idx || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS || |
290 | MptCallbacks[cb_idx] == NULL) { | 308 | MptCallbacks[cb_idx] == NULL) { |
291 | printk(MYIOC_s_WARN_FMT "%s: Invalid cb_idx (%d)!\n", | 309 | printk(MYIOC_s_WARN_FMT "%s: Invalid cb_idx (%d)!\n", |
292 | __FUNCTION__, ioc->name, cb_idx); | 310 | __FUNCTION__, ioc->name, cb_idx); |
293 | goto out; | 311 | goto out; |
@@ -304,8 +322,8 @@ mpt_reply(MPT_ADAPTER *ioc, u32 pa) | |||
304 | { | 322 | { |
305 | MPT_FRAME_HDR *mf; | 323 | MPT_FRAME_HDR *mf; |
306 | MPT_FRAME_HDR *mr; | 324 | MPT_FRAME_HDR *mr; |
307 | int req_idx; | 325 | u16 req_idx; |
308 | int cb_idx; | 326 | u8 cb_idx; |
309 | int freeme; | 327 | int freeme; |
310 | 328 | ||
311 | u32 reply_dma_low; | 329 | u32 reply_dma_low; |
@@ -331,7 +349,7 @@ mpt_reply(MPT_ADAPTER *ioc, u32 pa) | |||
331 | 349 | ||
332 | dmfprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Got non-TURBO reply=%p req_idx=%x cb_idx=%x Function=%x\n", | 350 | dmfprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Got non-TURBO reply=%p req_idx=%x cb_idx=%x Function=%x\n", |
333 | ioc->name, mr, req_idx, cb_idx, mr->u.hdr.Function)); | 351 | ioc->name, mr, req_idx, cb_idx, mr->u.hdr.Function)); |
334 | DBG_DUMP_REPLY_FRAME(ioc, (u32 *)mr) | 352 | DBG_DUMP_REPLY_FRAME(ioc, (u32 *)mr); |
335 | 353 | ||
336 | /* Check/log IOC log info | 354 | /* Check/log IOC log info |
337 | */ | 355 | */ |
@@ -350,8 +368,8 @@ mpt_reply(MPT_ADAPTER *ioc, u32 pa) | |||
350 | mpt_iocstatus_info(ioc, (u32)ioc_stat, mf); | 368 | mpt_iocstatus_info(ioc, (u32)ioc_stat, mf); |
351 | 369 | ||
352 | /* Check for (valid) IO callback! */ | 370 | /* Check for (valid) IO callback! */ |
353 | if (cb_idx < 1 || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS || | 371 | if (!cb_idx || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS || |
354 | MptCallbacks[cb_idx] == NULL) { | 372 | MptCallbacks[cb_idx] == NULL) { |
355 | printk(MYIOC_s_WARN_FMT "%s: Invalid cb_idx (%d)!\n", | 373 | printk(MYIOC_s_WARN_FMT "%s: Invalid cb_idx (%d)!\n", |
356 | __FUNCTION__, ioc->name, cb_idx); | 374 | __FUNCTION__, ioc->name, cb_idx); |
357 | freeme = 0; | 375 | freeme = 0; |
@@ -433,8 +451,9 @@ mpt_base_reply(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *reply) | |||
433 | #ifdef CONFIG_FUSION_LOGGING | 451 | #ifdef CONFIG_FUSION_LOGGING |
434 | if ((ioc->debug_level & MPT_DEBUG_MSG_FRAME) && | 452 | if ((ioc->debug_level & MPT_DEBUG_MSG_FRAME) && |
435 | !(reply->u.hdr.MsgFlags & MPI_MSGFLAGS_CONTINUATION_REPLY)) { | 453 | !(reply->u.hdr.MsgFlags & MPI_MSGFLAGS_CONTINUATION_REPLY)) { |
436 | dmfprintk(ioc, printk(KERN_INFO MYNAM ": Original request frame (@%p) header\n", mf)); | 454 | dmfprintk(ioc, printk(MYIOC_s_INFO_FMT ": Original request frame (@%p) header\n", |
437 | DBG_DUMP_REQUEST_FRAME_HDR(ioc, (u32 *)mf) | 455 | ioc->name, mf)); |
456 | DBG_DUMP_REQUEST_FRAME_HDR(ioc, (u32 *)mf); | ||
438 | } | 457 | } |
439 | #endif | 458 | #endif |
440 | 459 | ||
@@ -499,8 +518,8 @@ mpt_base_reply(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *reply) | |||
499 | u16 status; | 518 | u16 status; |
500 | 519 | ||
501 | status = le16_to_cpu(pReply->IOCStatus) & MPI_IOCSTATUS_MASK; | 520 | status = le16_to_cpu(pReply->IOCStatus) & MPI_IOCSTATUS_MASK; |
502 | dcprintk(ioc, printk(KERN_NOTICE " IOCStatus=%04xh, IOCLogInfo=%08xh\n", | 521 | dcprintk(ioc, printk(MYIOC_s_NOTE_FMT " IOCStatus=%04xh, IOCLogInfo=%08xh\n", |
503 | status, le32_to_cpu(pReply->IOCLogInfo))); | 522 | ioc->name, status, le32_to_cpu(pReply->IOCLogInfo))); |
504 | 523 | ||
505 | pCfg->status = status; | 524 | pCfg->status = status; |
506 | if (status == MPI_IOCSTATUS_SUCCESS) { | 525 | if (status == MPI_IOCSTATUS_SUCCESS) { |
@@ -563,28 +582,27 @@ mpt_base_reply(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *reply) | |||
563 | * in order to register separate callbacks; one for "normal" SCSI IO; | 582 | * in order to register separate callbacks; one for "normal" SCSI IO; |
564 | * one for MptScsiTaskMgmt requests; one for Scan/DV requests. | 583 | * one for MptScsiTaskMgmt requests; one for Scan/DV requests. |
565 | * | 584 | * |
566 | * Returns a positive integer valued "handle" in the | 585 | * Returns u8 valued "handle" in the range (and S.O.D. order) |
567 | * range (and S.O.D. order) {N,...,7,6,5,...,1} if successful. | 586 | * {N,...,7,6,5,...,1} if successful. |
568 | * Any non-positive return value (including zero!) should be considered | 587 | * A return value of MPT_MAX_PROTOCOL_DRIVERS (including zero!) should be |
569 | * an error by the caller. | 588 | * considered an error by the caller. |
570 | */ | 589 | */ |
571 | int | 590 | u8 |
572 | mpt_register(MPT_CALLBACK cbfunc, MPT_DRIVER_CLASS dclass) | 591 | mpt_register(MPT_CALLBACK cbfunc, MPT_DRIVER_CLASS dclass) |
573 | { | 592 | { |
574 | int i; | 593 | u8 cb_idx; |
575 | 594 | last_drv_idx = MPT_MAX_PROTOCOL_DRIVERS; | |
576 | last_drv_idx = -1; | ||
577 | 595 | ||
578 | /* | 596 | /* |
579 | * Search for empty callback slot in this order: {N,...,7,6,5,...,1} | 597 | * Search for empty callback slot in this order: {N,...,7,6,5,...,1} |
580 | * (slot/handle 0 is reserved!) | 598 | * (slot/handle 0 is reserved!) |
581 | */ | 599 | */ |
582 | for (i = MPT_MAX_PROTOCOL_DRIVERS-1; i; i--) { | 600 | for (cb_idx = MPT_MAX_PROTOCOL_DRIVERS-1; cb_idx; cb_idx--) { |
583 | if (MptCallbacks[i] == NULL) { | 601 | if (MptCallbacks[cb_idx] == NULL) { |
584 | MptCallbacks[i] = cbfunc; | 602 | MptCallbacks[cb_idx] = cbfunc; |
585 | MptDriverClass[i] = dclass; | 603 | MptDriverClass[cb_idx] = dclass; |
586 | MptEvHandlers[i] = NULL; | 604 | MptEvHandlers[cb_idx] = NULL; |
587 | last_drv_idx = i; | 605 | last_drv_idx = cb_idx; |
588 | break; | 606 | break; |
589 | } | 607 | } |
590 | } | 608 | } |
@@ -601,9 +619,9 @@ mpt_register(MPT_CALLBACK cbfunc, MPT_DRIVER_CLASS dclass) | |||
601 | * module is unloaded. | 619 | * module is unloaded. |
602 | */ | 620 | */ |
603 | void | 621 | void |
604 | mpt_deregister(int cb_idx) | 622 | mpt_deregister(u8 cb_idx) |
605 | { | 623 | { |
606 | if ((cb_idx >= 0) && (cb_idx < MPT_MAX_PROTOCOL_DRIVERS)) { | 624 | if (cb_idx && (cb_idx < MPT_MAX_PROTOCOL_DRIVERS)) { |
607 | MptCallbacks[cb_idx] = NULL; | 625 | MptCallbacks[cb_idx] = NULL; |
608 | MptDriverClass[cb_idx] = MPTUNKNOWN_DRIVER; | 626 | MptDriverClass[cb_idx] = MPTUNKNOWN_DRIVER; |
609 | MptEvHandlers[cb_idx] = NULL; | 627 | MptEvHandlers[cb_idx] = NULL; |
@@ -625,9 +643,9 @@ mpt_deregister(int cb_idx) | |||
625 | * Returns 0 for success. | 643 | * Returns 0 for success. |
626 | */ | 644 | */ |
627 | int | 645 | int |
628 | mpt_event_register(int cb_idx, MPT_EVHANDLER ev_cbfunc) | 646 | mpt_event_register(u8 cb_idx, MPT_EVHANDLER ev_cbfunc) |
629 | { | 647 | { |
630 | if (cb_idx < 1 || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS) | 648 | if (!cb_idx || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS) |
631 | return -1; | 649 | return -1; |
632 | 650 | ||
633 | MptEvHandlers[cb_idx] = ev_cbfunc; | 651 | MptEvHandlers[cb_idx] = ev_cbfunc; |
@@ -645,9 +663,9 @@ mpt_event_register(int cb_idx, MPT_EVHANDLER ev_cbfunc) | |||
645 | * or when its module is unloaded. | 663 | * or when its module is unloaded. |
646 | */ | 664 | */ |
647 | void | 665 | void |
648 | mpt_event_deregister(int cb_idx) | 666 | mpt_event_deregister(u8 cb_idx) |
649 | { | 667 | { |
650 | if (cb_idx < 1 || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS) | 668 | if (!cb_idx || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS) |
651 | return; | 669 | return; |
652 | 670 | ||
653 | MptEvHandlers[cb_idx] = NULL; | 671 | MptEvHandlers[cb_idx] = NULL; |
@@ -665,9 +683,9 @@ mpt_event_deregister(int cb_idx) | |||
665 | * Returns 0 for success. | 683 | * Returns 0 for success. |
666 | */ | 684 | */ |
667 | int | 685 | int |
668 | mpt_reset_register(int cb_idx, MPT_RESETHANDLER reset_func) | 686 | mpt_reset_register(u8 cb_idx, MPT_RESETHANDLER reset_func) |
669 | { | 687 | { |
670 | if (cb_idx < 1 || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS) | 688 | if (!cb_idx || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS) |
671 | return -1; | 689 | return -1; |
672 | 690 | ||
673 | MptResetHandlers[cb_idx] = reset_func; | 691 | MptResetHandlers[cb_idx] = reset_func; |
@@ -684,9 +702,9 @@ mpt_reset_register(int cb_idx, MPT_RESETHANDLER reset_func) | |||
684 | * or when its module is unloaded. | 702 | * or when its module is unloaded. |
685 | */ | 703 | */ |
686 | void | 704 | void |
687 | mpt_reset_deregister(int cb_idx) | 705 | mpt_reset_deregister(u8 cb_idx) |
688 | { | 706 | { |
689 | if (cb_idx < 1 || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS) | 707 | if (!cb_idx || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS) |
690 | return; | 708 | return; |
691 | 709 | ||
692 | MptResetHandlers[cb_idx] = NULL; | 710 | MptResetHandlers[cb_idx] = NULL; |
@@ -699,12 +717,12 @@ mpt_reset_deregister(int cb_idx) | |||
699 | * @cb_idx: MPT protocol driver index | 717 | * @cb_idx: MPT protocol driver index |
700 | */ | 718 | */ |
701 | int | 719 | int |
702 | mpt_device_driver_register(struct mpt_pci_driver * dd_cbfunc, int cb_idx) | 720 | mpt_device_driver_register(struct mpt_pci_driver * dd_cbfunc, u8 cb_idx) |
703 | { | 721 | { |
704 | MPT_ADAPTER *ioc; | 722 | MPT_ADAPTER *ioc; |
705 | const struct pci_device_id *id; | 723 | const struct pci_device_id *id; |
706 | 724 | ||
707 | if (cb_idx < 1 || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS) | 725 | if (!cb_idx || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS) |
708 | return -EINVAL; | 726 | return -EINVAL; |
709 | 727 | ||
710 | MptDeviceDriverHandlers[cb_idx] = dd_cbfunc; | 728 | MptDeviceDriverHandlers[cb_idx] = dd_cbfunc; |
@@ -726,12 +744,12 @@ mpt_device_driver_register(struct mpt_pci_driver * dd_cbfunc, int cb_idx) | |||
726 | * @cb_idx: MPT protocol driver index | 744 | * @cb_idx: MPT protocol driver index |
727 | */ | 745 | */ |
728 | void | 746 | void |
729 | mpt_device_driver_deregister(int cb_idx) | 747 | mpt_device_driver_deregister(u8 cb_idx) |
730 | { | 748 | { |
731 | struct mpt_pci_driver *dd_cbfunc; | 749 | struct mpt_pci_driver *dd_cbfunc; |
732 | MPT_ADAPTER *ioc; | 750 | MPT_ADAPTER *ioc; |
733 | 751 | ||
734 | if (cb_idx < 1 || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS) | 752 | if (!cb_idx || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS) |
735 | return; | 753 | return; |
736 | 754 | ||
737 | dd_cbfunc = MptDeviceDriverHandlers[cb_idx]; | 755 | dd_cbfunc = MptDeviceDriverHandlers[cb_idx]; |
@@ -749,14 +767,14 @@ mpt_device_driver_deregister(int cb_idx) | |||
749 | /** | 767 | /** |
750 | * mpt_get_msg_frame - Obtain a MPT request frame from the pool (of 1024) | 768 | * mpt_get_msg_frame - Obtain a MPT request frame from the pool (of 1024) |
751 | * allocated per MPT adapter. | 769 | * allocated per MPT adapter. |
752 | * @handle: Handle of registered MPT protocol driver | 770 | * @cb_idx: Handle of registered MPT protocol driver |
753 | * @ioc: Pointer to MPT adapter structure | 771 | * @ioc: Pointer to MPT adapter structure |
754 | * | 772 | * |
755 | * Returns pointer to a MPT request frame or %NULL if none are available | 773 | * Returns pointer to a MPT request frame or %NULL if none are available |
756 | * or IOC is not active. | 774 | * or IOC is not active. |
757 | */ | 775 | */ |
758 | MPT_FRAME_HDR* | 776 | MPT_FRAME_HDR* |
759 | mpt_get_msg_frame(int handle, MPT_ADAPTER *ioc) | 777 | mpt_get_msg_frame(u8 cb_idx, MPT_ADAPTER *ioc) |
760 | { | 778 | { |
761 | MPT_FRAME_HDR *mf; | 779 | MPT_FRAME_HDR *mf; |
762 | unsigned long flags; | 780 | unsigned long flags; |
@@ -766,7 +784,8 @@ mpt_get_msg_frame(int handle, MPT_ADAPTER *ioc) | |||
766 | 784 | ||
767 | #ifdef MFCNT | 785 | #ifdef MFCNT |
768 | if (!ioc->active) | 786 | if (!ioc->active) |
769 | printk(KERN_WARNING "IOC Not Active! mpt_get_msg_frame returning NULL!\n"); | 787 | printk(MYIOC_s_WARN_FMT "IOC Not Active! mpt_get_msg_frame " |
788 | "returning NULL!\n", ioc->name); | ||
770 | #endif | 789 | #endif |
771 | 790 | ||
772 | /* If interrupts are not attached, do not return a request frame */ | 791 | /* If interrupts are not attached, do not return a request frame */ |
@@ -781,13 +800,14 @@ mpt_get_msg_frame(int handle, MPT_ADAPTER *ioc) | |||
781 | u.frame.linkage.list); | 800 | u.frame.linkage.list); |
782 | list_del(&mf->u.frame.linkage.list); | 801 | list_del(&mf->u.frame.linkage.list); |
783 | mf->u.frame.linkage.arg1 = 0; | 802 | mf->u.frame.linkage.arg1 = 0; |
784 | mf->u.frame.hwhdr.msgctxu.fld.cb_idx = handle; /* byte */ | 803 | mf->u.frame.hwhdr.msgctxu.fld.cb_idx = cb_idx; /* byte */ |
785 | req_offset = (u8 *)mf - (u8 *)ioc->req_frames; | 804 | req_offset = (u8 *)mf - (u8 *)ioc->req_frames; |
786 | /* u16! */ | 805 | /* u16! */ |
787 | req_idx = req_offset / ioc->req_sz; | 806 | req_idx = req_offset / ioc->req_sz; |
788 | mf->u.frame.hwhdr.msgctxu.fld.req_idx = cpu_to_le16(req_idx); | 807 | mf->u.frame.hwhdr.msgctxu.fld.req_idx = cpu_to_le16(req_idx); |
789 | mf->u.frame.hwhdr.msgctxu.fld.rsvd = 0; | 808 | mf->u.frame.hwhdr.msgctxu.fld.rsvd = 0; |
790 | ioc->RequestNB[req_idx] = ioc->NB_for_64_byte_frame; /* Default, will be changed if necessary in SG generation */ | 809 | /* Default, will be changed if necessary in SG generation */ |
810 | ioc->RequestNB[req_idx] = ioc->NB_for_64_byte_frame; | ||
791 | #ifdef MFCNT | 811 | #ifdef MFCNT |
792 | ioc->mfcnt++; | 812 | ioc->mfcnt++; |
793 | #endif | 813 | #endif |
@@ -798,14 +818,17 @@ mpt_get_msg_frame(int handle, MPT_ADAPTER *ioc) | |||
798 | 818 | ||
799 | #ifdef MFCNT | 819 | #ifdef MFCNT |
800 | if (mf == NULL) | 820 | if (mf == NULL) |
801 | printk(KERN_WARNING "IOC Active. No free Msg Frames! Count 0x%x Max 0x%x\n", ioc->mfcnt, ioc->req_depth); | 821 | printk(MYIOC_s_WARN_FMT "IOC Active. No free Msg Frames! " |
822 | "Count 0x%x Max 0x%x\n", ioc->name, ioc->mfcnt, | ||
823 | ioc->req_depth); | ||
802 | mfcounter++; | 824 | mfcounter++; |
803 | if (mfcounter == PRINT_MF_COUNT) | 825 | if (mfcounter == PRINT_MF_COUNT) |
804 | printk(KERN_INFO "MF Count 0x%x Max 0x%x \n", ioc->mfcnt, ioc->req_depth); | 826 | printk(MYIOC_s_INFO_FMT "MF Count 0x%x Max 0x%x \n", ioc->name, |
827 | ioc->mfcnt, ioc->req_depth); | ||
805 | #endif | 828 | #endif |
806 | 829 | ||
807 | dmfprintk(ioc, printk(KERN_INFO MYNAM ": %s: mpt_get_msg_frame(%d,%d), got mf=%p\n", | 830 | dmfprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mpt_get_msg_frame(%d,%d), got mf=%p\n", |
808 | ioc->name, handle, ioc->id, mf)); | 831 | ioc->name, cb_idx, ioc->id, mf)); |
809 | return mf; | 832 | return mf; |
810 | } | 833 | } |
811 | 834 | ||
@@ -813,7 +836,7 @@ mpt_get_msg_frame(int handle, MPT_ADAPTER *ioc) | |||
813 | /** | 836 | /** |
814 | * mpt_put_msg_frame - Send a protocol specific MPT request frame | 837 | * mpt_put_msg_frame - Send a protocol specific MPT request frame |
815 | * to a IOC. | 838 | * to a IOC. |
816 | * @handle: Handle of registered MPT protocol driver | 839 | * @cb_idx: Handle of registered MPT protocol driver |
817 | * @ioc: Pointer to MPT adapter structure | 840 | * @ioc: Pointer to MPT adapter structure |
818 | * @mf: Pointer to MPT request frame | 841 | * @mf: Pointer to MPT request frame |
819 | * | 842 | * |
@@ -821,14 +844,14 @@ mpt_get_msg_frame(int handle, MPT_ADAPTER *ioc) | |||
821 | * specific MPT adapter. | 844 | * specific MPT adapter. |
822 | */ | 845 | */ |
823 | void | 846 | void |
824 | mpt_put_msg_frame(int handle, MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf) | 847 | mpt_put_msg_frame(u8 cb_idx, MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf) |
825 | { | 848 | { |
826 | u32 mf_dma_addr; | 849 | u32 mf_dma_addr; |
827 | int req_offset; | 850 | int req_offset; |
828 | u16 req_idx; /* Request index */ | 851 | u16 req_idx; /* Request index */ |
829 | 852 | ||
830 | /* ensure values are reset properly! */ | 853 | /* ensure values are reset properly! */ |
831 | mf->u.frame.hwhdr.msgctxu.fld.cb_idx = handle; /* byte */ | 854 | mf->u.frame.hwhdr.msgctxu.fld.cb_idx = cb_idx; /* byte */ |
832 | req_offset = (u8 *)mf - (u8 *)ioc->req_frames; | 855 | req_offset = (u8 *)mf - (u8 *)ioc->req_frames; |
833 | /* u16! */ | 856 | /* u16! */ |
834 | req_idx = req_offset / ioc->req_sz; | 857 | req_idx = req_offset / ioc->req_sz; |
@@ -838,10 +861,44 @@ mpt_put_msg_frame(int handle, MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf) | |||
838 | DBG_DUMP_PUT_MSG_FRAME(ioc, (u32 *)mf); | 861 | DBG_DUMP_PUT_MSG_FRAME(ioc, (u32 *)mf); |
839 | 862 | ||
840 | mf_dma_addr = (ioc->req_frames_low_dma + req_offset) | ioc->RequestNB[req_idx]; | 863 | mf_dma_addr = (ioc->req_frames_low_dma + req_offset) | ioc->RequestNB[req_idx]; |
841 | dsgprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mf_dma_addr=%x req_idx=%d RequestNB=%x\n", ioc->name, mf_dma_addr, req_idx, ioc->RequestNB[req_idx])); | 864 | dsgprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mf_dma_addr=%x req_idx=%d " |
865 | "RequestNB=%x\n", ioc->name, mf_dma_addr, req_idx, | ||
866 | ioc->RequestNB[req_idx])); | ||
842 | CHIPREG_WRITE32(&ioc->chip->RequestFifo, mf_dma_addr); | 867 | CHIPREG_WRITE32(&ioc->chip->RequestFifo, mf_dma_addr); |
843 | } | 868 | } |
844 | 869 | ||
870 | /** | ||
871 | * mpt_put_msg_frame_hi_pri - Send a protocol specific MPT request frame | ||
872 | * to a IOC using hi priority request queue. | ||
873 | * @cb_idx: Handle of registered MPT protocol driver | ||
874 | * @ioc: Pointer to MPT adapter structure | ||
875 | * @mf: Pointer to MPT request frame | ||
876 | * | ||
877 | * This routine posts a MPT request frame to the request post FIFO of a | ||
878 | * specific MPT adapter. | ||
879 | **/ | ||
880 | void | ||
881 | mpt_put_msg_frame_hi_pri(u8 cb_idx, MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf) | ||
882 | { | ||
883 | u32 mf_dma_addr; | ||
884 | int req_offset; | ||
885 | u16 req_idx; /* Request index */ | ||
886 | |||
887 | /* ensure values are reset properly! */ | ||
888 | mf->u.frame.hwhdr.msgctxu.fld.cb_idx = cb_idx; | ||
889 | req_offset = (u8 *)mf - (u8 *)ioc->req_frames; | ||
890 | req_idx = req_offset / ioc->req_sz; | ||
891 | mf->u.frame.hwhdr.msgctxu.fld.req_idx = cpu_to_le16(req_idx); | ||
892 | mf->u.frame.hwhdr.msgctxu.fld.rsvd = 0; | ||
893 | |||
894 | DBG_DUMP_PUT_MSG_FRAME(ioc, (u32 *)mf); | ||
895 | |||
896 | mf_dma_addr = (ioc->req_frames_low_dma + req_offset); | ||
897 | dsgprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mf_dma_addr=%x req_idx=%d\n", | ||
898 | ioc->name, mf_dma_addr, req_idx)); | ||
899 | CHIPREG_WRITE32(&ioc->chip->RequestHiPriFifo, mf_dma_addr); | ||
900 | } | ||
901 | |||
845 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | 902 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ |
846 | /** | 903 | /** |
847 | * mpt_free_msg_frame - Place MPT request frame back on FreeQ. | 904 | * mpt_free_msg_frame - Place MPT request frame back on FreeQ. |
@@ -899,7 +956,7 @@ mpt_add_sge(char *pAddr, u32 flagslength, dma_addr_t dma_addr) | |||
899 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | 956 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ |
900 | /** | 957 | /** |
901 | * mpt_send_handshake_request - Send MPT request via doorbell handshake method. | 958 | * mpt_send_handshake_request - Send MPT request via doorbell handshake method. |
902 | * @handle: Handle of registered MPT protocol driver | 959 | * @cb_idx: Handle of registered MPT protocol driver |
903 | * @ioc: Pointer to MPT adapter structure | 960 | * @ioc: Pointer to MPT adapter structure |
904 | * @reqBytes: Size of the request in bytes | 961 | * @reqBytes: Size of the request in bytes |
905 | * @req: Pointer to MPT request frame | 962 | * @req: Pointer to MPT request frame |
@@ -914,7 +971,7 @@ mpt_add_sge(char *pAddr, u32 flagslength, dma_addr_t dma_addr) | |||
914 | * Returns 0 for success, non-zero for failure. | 971 | * Returns 0 for success, non-zero for failure. |
915 | */ | 972 | */ |
916 | int | 973 | int |
917 | mpt_send_handshake_request(int handle, MPT_ADAPTER *ioc, int reqBytes, u32 *req, int sleepFlag) | 974 | mpt_send_handshake_request(u8 cb_idx, MPT_ADAPTER *ioc, int reqBytes, u32 *req, int sleepFlag) |
918 | { | 975 | { |
919 | int r = 0; | 976 | int r = 0; |
920 | u8 *req_as_bytes; | 977 | u8 *req_as_bytes; |
@@ -934,7 +991,7 @@ mpt_send_handshake_request(int handle, MPT_ADAPTER *ioc, int reqBytes, u32 *req, | |||
934 | if (reqBytes >= 12 && ii >= 0 && ii < ioc->req_depth) { | 991 | if (reqBytes >= 12 && ii >= 0 && ii < ioc->req_depth) { |
935 | MPT_FRAME_HDR *mf = (MPT_FRAME_HDR*)req; | 992 | MPT_FRAME_HDR *mf = (MPT_FRAME_HDR*)req; |
936 | mf->u.frame.hwhdr.msgctxu.fld.req_idx = cpu_to_le16(ii); | 993 | mf->u.frame.hwhdr.msgctxu.fld.req_idx = cpu_to_le16(ii); |
937 | mf->u.frame.hwhdr.msgctxu.fld.cb_idx = handle; | 994 | mf->u.frame.hwhdr.msgctxu.fld.cb_idx = cb_idx; |
938 | } | 995 | } |
939 | 996 | ||
940 | /* Make sure there are no doorbells */ | 997 | /* Make sure there are no doorbells */ |
@@ -953,7 +1010,7 @@ mpt_send_handshake_request(int handle, MPT_ADAPTER *ioc, int reqBytes, u32 *req, | |||
953 | if (!(CHIPREG_READ32(&ioc->chip->Doorbell) & MPI_DOORBELL_ACTIVE)) | 1010 | if (!(CHIPREG_READ32(&ioc->chip->Doorbell) & MPI_DOORBELL_ACTIVE)) |
954 | return -5; | 1011 | return -5; |
955 | 1012 | ||
956 | dhsprintk(ioc, printk(KERN_INFO MYNAM ": %s: mpt_send_handshake_request start, WaitCnt=%d\n", | 1013 | dhsprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mpt_send_handshake_request start, WaitCnt=%d\n", |
957 | ioc->name, ii)); | 1014 | ioc->name, ii)); |
958 | 1015 | ||
959 | CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); | 1016 | CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); |
@@ -1395,11 +1452,13 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id) | |||
1395 | { | 1452 | { |
1396 | MPT_ADAPTER *ioc; | 1453 | MPT_ADAPTER *ioc; |
1397 | u8 __iomem *mem; | 1454 | u8 __iomem *mem; |
1455 | u8 __iomem *pmem; | ||
1398 | unsigned long mem_phys; | 1456 | unsigned long mem_phys; |
1399 | unsigned long port; | 1457 | unsigned long port; |
1400 | u32 msize; | 1458 | u32 msize; |
1401 | u32 psize; | 1459 | u32 psize; |
1402 | int ii; | 1460 | int ii; |
1461 | u8 cb_idx; | ||
1403 | int r = -ENODEV; | 1462 | int r = -ENODEV; |
1404 | u8 revision; | 1463 | u8 revision; |
1405 | u8 pcixcmd; | 1464 | u8 pcixcmd; |
@@ -1408,35 +1467,39 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id) | |||
1408 | struct proc_dir_entry *dent, *ent; | 1467 | struct proc_dir_entry *dent, *ent; |
1409 | #endif | 1468 | #endif |
1410 | 1469 | ||
1470 | if (mpt_debug_level) | ||
1471 | printk(KERN_INFO MYNAM ": mpt_debug_level=%xh\n", mpt_debug_level); | ||
1472 | |||
1473 | if (pci_enable_device(pdev)) | ||
1474 | return r; | ||
1475 | |||
1411 | ioc = kzalloc(sizeof(MPT_ADAPTER), GFP_ATOMIC); | 1476 | ioc = kzalloc(sizeof(MPT_ADAPTER), GFP_ATOMIC); |
1412 | if (ioc == NULL) { | 1477 | if (ioc == NULL) { |
1413 | printk(KERN_ERR MYNAM ": ERROR - Insufficient memory to add adapter!\n"); | 1478 | printk(KERN_ERR MYNAM ": ERROR - Insufficient memory to add adapter!\n"); |
1414 | return -ENOMEM; | 1479 | return -ENOMEM; |
1415 | } | 1480 | } |
1416 | |||
1417 | ioc->debug_level = mpt_debug_level; | 1481 | ioc->debug_level = mpt_debug_level; |
1418 | if (mpt_debug_level) | 1482 | ioc->id = mpt_ids++; |
1419 | printk(KERN_INFO MYNAM ": mpt_debug_level=%xh\n", mpt_debug_level); | 1483 | sprintf(ioc->name, "ioc%d", ioc->id); |
1420 | |||
1421 | if (pci_enable_device(pdev)) | ||
1422 | return r; | ||
1423 | 1484 | ||
1424 | dinitprintk(ioc, printk(KERN_WARNING MYNAM ": mpt_adapter_install\n")); | 1485 | dinitprintk(ioc, printk(MYIOC_s_INFO_FMT ": mpt_adapter_install\n", ioc->name)); |
1425 | 1486 | ||
1426 | if (!pci_set_dma_mask(pdev, DMA_64BIT_MASK)) { | 1487 | if (!pci_set_dma_mask(pdev, DMA_64BIT_MASK)) { |
1427 | dprintk(ioc, printk(KERN_INFO MYNAM | 1488 | dprintk(ioc, printk(MYIOC_s_INFO_FMT |
1428 | ": 64 BIT PCI BUS DMA ADDRESSING SUPPORTED\n")); | 1489 | ": 64 BIT PCI BUS DMA ADDRESSING SUPPORTED\n", ioc->name)); |
1429 | } else if (pci_set_dma_mask(pdev, DMA_32BIT_MASK)) { | 1490 | } else if (pci_set_dma_mask(pdev, DMA_32BIT_MASK)) { |
1430 | printk(KERN_WARNING MYNAM ": 32 BIT PCI BUS DMA ADDRESSING NOT SUPPORTED\n"); | 1491 | printk(MYIOC_s_WARN_FMT ": 32 BIT PCI BUS DMA ADDRESSING NOT SUPPORTED\n", |
1492 | ioc->name); | ||
1493 | kfree(ioc); | ||
1431 | return r; | 1494 | return r; |
1432 | } | 1495 | } |
1433 | 1496 | ||
1434 | if (!pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK)) { | 1497 | if (!pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK)) { |
1435 | dprintk(ioc, printk(KERN_INFO MYNAM | 1498 | dprintk(ioc, printk(MYIOC_s_INFO_FMT |
1436 | ": Using 64 bit consistent mask\n")); | 1499 | ": Using 64 bit consistent mask\n", ioc->name)); |
1437 | } else { | 1500 | } else { |
1438 | dprintk(ioc, printk(KERN_INFO MYNAM | 1501 | dprintk(ioc, printk(MYIOC_s_INFO_FMT |
1439 | ": Not using 64 bit consistent mask\n")); | 1502 | ": Not using 64 bit consistent mask\n", ioc->name)); |
1440 | } | 1503 | } |
1441 | 1504 | ||
1442 | ioc->alloc_total = sizeof(MPT_ADAPTER); | 1505 | ioc->alloc_total = sizeof(MPT_ADAPTER); |
@@ -1475,7 +1538,6 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id) | |||
1475 | 1538 | ||
1476 | /* Find lookup slot. */ | 1539 | /* Find lookup slot. */ |
1477 | INIT_LIST_HEAD(&ioc->list); | 1540 | INIT_LIST_HEAD(&ioc->list); |
1478 | ioc->id = mpt_ids++; | ||
1479 | 1541 | ||
1480 | mem_phys = msize = 0; | 1542 | mem_phys = msize = 0; |
1481 | port = psize = 0; | 1543 | port = psize = 0; |
@@ -1501,25 +1563,23 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id) | |||
1501 | /*mem = ioremap(mem_phys, msize);*/ | 1563 | /*mem = ioremap(mem_phys, msize);*/ |
1502 | mem = ioremap(mem_phys, msize); | 1564 | mem = ioremap(mem_phys, msize); |
1503 | if (mem == NULL) { | 1565 | if (mem == NULL) { |
1504 | printk(KERN_ERR MYNAM ": ERROR - Unable to map adapter memory!\n"); | 1566 | printk(MYIOC_s_ERR_FMT "Unable to map adapter memory!\n", ioc->name); |
1505 | kfree(ioc); | 1567 | kfree(ioc); |
1506 | return -EINVAL; | 1568 | return -EINVAL; |
1507 | } | 1569 | } |
1508 | ioc->memmap = mem; | 1570 | ioc->memmap = mem; |
1509 | dinitprintk(ioc, printk(KERN_INFO MYNAM ": mem = %p, mem_phys = %lx\n", mem, mem_phys)); | 1571 | dinitprintk(ioc, printk(MYIOC_s_INFO_FMT "mem = %p, mem_phys = %lx\n", ioc->name, mem, mem_phys)); |
1510 | 1572 | ||
1511 | dinitprintk(ioc, printk(KERN_INFO MYNAM ": facts @ %p, pfacts[0] @ %p\n", | 1573 | dinitprintk(ioc, printk(MYIOC_s_INFO_FMT "facts @ %p, pfacts[0] @ %p\n", |
1512 | &ioc->facts, &ioc->pfacts[0])); | 1574 | ioc->name, &ioc->facts, &ioc->pfacts[0])); |
1513 | 1575 | ||
1514 | ioc->mem_phys = mem_phys; | 1576 | ioc->mem_phys = mem_phys; |
1515 | ioc->chip = (SYSIF_REGS __iomem *)mem; | 1577 | ioc->chip = (SYSIF_REGS __iomem *)mem; |
1516 | 1578 | ||
1517 | /* Save Port IO values in case we need to do downloadboot */ | 1579 | /* Save Port IO values in case we need to do downloadboot */ |
1518 | { | 1580 | ioc->pio_mem_phys = port; |
1519 | u8 *pmem = (u8*)port; | 1581 | pmem = (u8 __iomem *)port; |
1520 | ioc->pio_mem_phys = port; | 1582 | ioc->pio_chip = (SYSIF_REGS __iomem *)pmem; |
1521 | ioc->pio_chip = (SYSIF_REGS __iomem *)pmem; | ||
1522 | } | ||
1523 | 1583 | ||
1524 | pci_read_config_byte(pdev, PCI_CLASS_REVISION, &revision); | 1584 | pci_read_config_byte(pdev, PCI_CLASS_REVISION, &revision); |
1525 | mpt_get_product_name(pdev->vendor, pdev->device, revision, ioc->prod_name); | 1585 | mpt_get_product_name(pdev->vendor, pdev->device, revision, ioc->prod_name); |
@@ -1591,8 +1651,6 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id) | |||
1591 | if (ioc->errata_flag_1064) | 1651 | if (ioc->errata_flag_1064) |
1592 | pci_disable_io_access(pdev); | 1652 | pci_disable_io_access(pdev); |
1593 | 1653 | ||
1594 | sprintf(ioc->name, "ioc%d", ioc->id); | ||
1595 | |||
1596 | spin_lock_init(&ioc->FreeQlock); | 1654 | spin_lock_init(&ioc->FreeQlock); |
1597 | 1655 | ||
1598 | /* Disable all! */ | 1656 | /* Disable all! */ |
@@ -1609,9 +1667,8 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id) | |||
1609 | 1667 | ||
1610 | if ((r = mpt_do_ioc_recovery(ioc, MPT_HOSTEVENT_IOC_BRINGUP, | 1668 | if ((r = mpt_do_ioc_recovery(ioc, MPT_HOSTEVENT_IOC_BRINGUP, |
1611 | CAN_SLEEP)) != 0){ | 1669 | CAN_SLEEP)) != 0){ |
1612 | printk(KERN_WARNING MYNAM | 1670 | printk(MYIOC_s_ERR_FMT "didn't initialize properly! (%d)\n", |
1613 | ": WARNING - %s did not initialize properly! (%d)\n", | 1671 | ioc->name, r); |
1614 | ioc->name, r); | ||
1615 | 1672 | ||
1616 | list_del(&ioc->list); | 1673 | list_del(&ioc->list); |
1617 | if (ioc->alt_ioc) | 1674 | if (ioc->alt_ioc) |
@@ -1623,10 +1680,10 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id) | |||
1623 | } | 1680 | } |
1624 | 1681 | ||
1625 | /* call per device driver probe entry point */ | 1682 | /* call per device driver probe entry point */ |
1626 | for(ii=0; ii<MPT_MAX_PROTOCOL_DRIVERS; ii++) { | 1683 | for(cb_idx = 0; cb_idx < MPT_MAX_PROTOCOL_DRIVERS; cb_idx++) { |
1627 | if(MptDeviceDriverHandlers[ii] && | 1684 | if(MptDeviceDriverHandlers[cb_idx] && |
1628 | MptDeviceDriverHandlers[ii]->probe) { | 1685 | MptDeviceDriverHandlers[cb_idx]->probe) { |
1629 | MptDeviceDriverHandlers[ii]->probe(pdev,id); | 1686 | MptDeviceDriverHandlers[cb_idx]->probe(pdev,id); |
1630 | } | 1687 | } |
1631 | } | 1688 | } |
1632 | 1689 | ||
@@ -1663,7 +1720,7 @@ mpt_detach(struct pci_dev *pdev) | |||
1663 | { | 1720 | { |
1664 | MPT_ADAPTER *ioc = pci_get_drvdata(pdev); | 1721 | MPT_ADAPTER *ioc = pci_get_drvdata(pdev); |
1665 | char pname[32]; | 1722 | char pname[32]; |
1666 | int ii; | 1723 | u8 cb_idx; |
1667 | 1724 | ||
1668 | sprintf(pname, MPT_PROCFS_MPTBASEDIR "/%s/summary", ioc->name); | 1725 | sprintf(pname, MPT_PROCFS_MPTBASEDIR "/%s/summary", ioc->name); |
1669 | remove_proc_entry(pname, NULL); | 1726 | remove_proc_entry(pname, NULL); |
@@ -1673,10 +1730,10 @@ mpt_detach(struct pci_dev *pdev) | |||
1673 | remove_proc_entry(pname, NULL); | 1730 | remove_proc_entry(pname, NULL); |
1674 | 1731 | ||
1675 | /* call per device driver remove entry point */ | 1732 | /* call per device driver remove entry point */ |
1676 | for(ii=0; ii<MPT_MAX_PROTOCOL_DRIVERS; ii++) { | 1733 | for(cb_idx = 0; cb_idx < MPT_MAX_PROTOCOL_DRIVERS; cb_idx++) { |
1677 | if(MptDeviceDriverHandlers[ii] && | 1734 | if(MptDeviceDriverHandlers[cb_idx] && |
1678 | MptDeviceDriverHandlers[ii]->remove) { | 1735 | MptDeviceDriverHandlers[cb_idx]->remove) { |
1679 | MptDeviceDriverHandlers[ii]->remove(pdev); | 1736 | MptDeviceDriverHandlers[cb_idx]->remove(pdev); |
1680 | } | 1737 | } |
1681 | } | 1738 | } |
1682 | 1739 | ||
@@ -1788,7 +1845,7 @@ mpt_resume(struct pci_dev *pdev) | |||
1788 | #endif | 1845 | #endif |
1789 | 1846 | ||
1790 | static int | 1847 | static int |
1791 | mpt_signal_reset(int index, MPT_ADAPTER *ioc, int reset_phase) | 1848 | mpt_signal_reset(u8 index, MPT_ADAPTER *ioc, int reset_phase) |
1792 | { | 1849 | { |
1793 | if ((MptDriverClass[index] == MPTSPI_DRIVER && | 1850 | if ((MptDriverClass[index] == MPTSPI_DRIVER && |
1794 | ioc->bus_type != SPI) || | 1851 | ioc->bus_type != SPI) || |
@@ -1830,14 +1887,15 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag) | |||
1830 | int hard; | 1887 | int hard; |
1831 | int rc=0; | 1888 | int rc=0; |
1832 | int ii; | 1889 | int ii; |
1890 | u8 cb_idx; | ||
1833 | int handlers; | 1891 | int handlers; |
1834 | int ret = 0; | 1892 | int ret = 0; |
1835 | int reset_alt_ioc_active = 0; | 1893 | int reset_alt_ioc_active = 0; |
1836 | int irq_allocated = 0; | 1894 | int irq_allocated = 0; |
1837 | u8 *a; | 1895 | u8 *a; |
1838 | 1896 | ||
1839 | printk(KERN_INFO MYNAM ": Initiating %s %s\n", | 1897 | printk(MYIOC_s_INFO_FMT "Initiating %s\n", ioc->name, |
1840 | ioc->name, reason==MPT_HOSTEVENT_IOC_BRINGUP ? "bringup" : "recovery"); | 1898 | reason == MPT_HOSTEVENT_IOC_BRINGUP ? "bringup" : "recovery"); |
1841 | 1899 | ||
1842 | /* Disable reply interrupts (also blocks FreeQ) */ | 1900 | /* Disable reply interrupts (also blocks FreeQ) */ |
1843 | CHIPREG_WRITE32(&ioc->chip->IntMask, 0xFFFFFFFF); | 1901 | CHIPREG_WRITE32(&ioc->chip->IntMask, 0xFFFFFFFF); |
@@ -1858,21 +1916,19 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag) | |||
1858 | 1916 | ||
1859 | if ((hard_reset_done = MakeIocReady(ioc, hard, sleepFlag)) < 0) { | 1917 | if ((hard_reset_done = MakeIocReady(ioc, hard, sleepFlag)) < 0) { |
1860 | if (hard_reset_done == -4) { | 1918 | if (hard_reset_done == -4) { |
1861 | printk(KERN_WARNING MYNAM ": %s Owned by PEER..skipping!\n", | 1919 | printk(MYIOC_s_WARN_FMT "Owned by PEER..skipping!\n", |
1862 | ioc->name); | 1920 | ioc->name); |
1863 | 1921 | ||
1864 | if (reset_alt_ioc_active && ioc->alt_ioc) { | 1922 | if (reset_alt_ioc_active && ioc->alt_ioc) { |
1865 | /* (re)Enable alt-IOC! (reply interrupt, FreeQ) */ | 1923 | /* (re)Enable alt-IOC! (reply interrupt, FreeQ) */ |
1866 | dprintk(ioc, printk(KERN_INFO MYNAM | 1924 | dprintk(ioc, printk(MYIOC_s_INFO_FMT |
1867 | ": alt-%s reply irq re-enabled\n", | 1925 | "alt_ioc reply irq re-enabled\n", ioc->alt_ioc->name)); |
1868 | ioc->alt_ioc->name)); | ||
1869 | CHIPREG_WRITE32(&ioc->alt_ioc->chip->IntMask, MPI_HIM_DIM); | 1926 | CHIPREG_WRITE32(&ioc->alt_ioc->chip->IntMask, MPI_HIM_DIM); |
1870 | ioc->alt_ioc->active = 1; | 1927 | ioc->alt_ioc->active = 1; |
1871 | } | 1928 | } |
1872 | 1929 | ||
1873 | } else { | 1930 | } else { |
1874 | printk(KERN_WARNING MYNAM ": %s NOT READY WARNING!\n", | 1931 | printk(MYIOC_s_WARN_FMT "NOT READY!\n", ioc->name); |
1875 | ioc->name); | ||
1876 | } | 1932 | } |
1877 | return -1; | 1933 | return -1; |
1878 | } | 1934 | } |
@@ -1884,9 +1940,7 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag) | |||
1884 | if ((rc = MakeIocReady(ioc->alt_ioc, 0, sleepFlag)) == 0) | 1940 | if ((rc = MakeIocReady(ioc->alt_ioc, 0, sleepFlag)) == 0) |
1885 | alt_ioc_ready = 1; | 1941 | alt_ioc_ready = 1; |
1886 | else | 1942 | else |
1887 | printk(KERN_WARNING MYNAM | 1943 | printk(MYIOC_s_WARN_FMT "alt_ioc not ready!\n", ioc->alt_ioc->name); |
1888 | ": alt-%s: Not ready WARNING!\n", | ||
1889 | ioc->alt_ioc->name); | ||
1890 | } | 1944 | } |
1891 | 1945 | ||
1892 | for (ii=0; ii<5; ii++) { | 1946 | for (ii=0; ii<5; ii++) { |
@@ -1897,7 +1951,8 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag) | |||
1897 | 1951 | ||
1898 | 1952 | ||
1899 | if (ii == 5) { | 1953 | if (ii == 5) { |
1900 | dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Retry IocFacts failed rc=%x\n", ioc->name, rc)); | 1954 | dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT |
1955 | "Retry IocFacts failed rc=%x\n", ioc->name, rc)); | ||
1901 | ret = -2; | 1956 | ret = -2; |
1902 | } else if (reason == MPT_HOSTEVENT_IOC_BRINGUP) { | 1957 | } else if (reason == MPT_HOSTEVENT_IOC_BRINGUP) { |
1903 | MptDisplayIocCapabilities(ioc); | 1958 | MptDisplayIocCapabilities(ioc); |
@@ -1906,14 +1961,14 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag) | |||
1906 | if (alt_ioc_ready) { | 1961 | if (alt_ioc_ready) { |
1907 | if ((rc = GetIocFacts(ioc->alt_ioc, sleepFlag, reason)) != 0) { | 1962 | if ((rc = GetIocFacts(ioc->alt_ioc, sleepFlag, reason)) != 0) { |
1908 | dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT | 1963 | dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT |
1909 | "Initial Alt IocFacts failed rc=%x\n", ioc->name, rc)); | 1964 | "Initial Alt IocFacts failed rc=%x\n", ioc->name, rc)); |
1910 | /* Retry - alt IOC was initialized once | 1965 | /* Retry - alt IOC was initialized once |
1911 | */ | 1966 | */ |
1912 | rc = GetIocFacts(ioc->alt_ioc, sleepFlag, reason); | 1967 | rc = GetIocFacts(ioc->alt_ioc, sleepFlag, reason); |
1913 | } | 1968 | } |
1914 | if (rc) { | 1969 | if (rc) { |
1915 | dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT | 1970 | dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT |
1916 | "Retry Alt IocFacts failed rc=%x\n", ioc->name, rc)); | 1971 | "Retry Alt IocFacts failed rc=%x\n", ioc->name, rc)); |
1917 | alt_ioc_ready = 0; | 1972 | alt_ioc_ready = 0; |
1918 | reset_alt_ioc_active = 0; | 1973 | reset_alt_ioc_active = 0; |
1919 | } else if (reason == MPT_HOSTEVENT_IOC_BRINGUP) { | 1974 | } else if (reason == MPT_HOSTEVENT_IOC_BRINGUP) { |
@@ -1931,13 +1986,12 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag) | |||
1931 | if (ioc->pcidev->irq) { | 1986 | if (ioc->pcidev->irq) { |
1932 | if (mpt_msi_enable && !pci_enable_msi(ioc->pcidev)) | 1987 | if (mpt_msi_enable && !pci_enable_msi(ioc->pcidev)) |
1933 | printk(MYIOC_s_INFO_FMT "PCI-MSI enabled\n", | 1988 | printk(MYIOC_s_INFO_FMT "PCI-MSI enabled\n", |
1934 | ioc->name); | 1989 | ioc->name); |
1935 | rc = request_irq(ioc->pcidev->irq, mpt_interrupt, | 1990 | rc = request_irq(ioc->pcidev->irq, mpt_interrupt, |
1936 | IRQF_SHARED, ioc->name, ioc); | 1991 | IRQF_SHARED, ioc->name, ioc); |
1937 | if (rc < 0) { | 1992 | if (rc < 0) { |
1938 | printk(MYIOC_s_ERR_FMT "Unable to allocate " | 1993 | printk(MYIOC_s_ERR_FMT "Unable to allocate " |
1939 | "interrupt %d!\n", ioc->name, | 1994 | "interrupt %d!\n", ioc->name, ioc->pcidev->irq); |
1940 | ioc->pcidev->irq); | ||
1941 | if (mpt_msi_enable) | 1995 | if (mpt_msi_enable) |
1942 | pci_disable_msi(ioc->pcidev); | 1996 | pci_disable_msi(ioc->pcidev); |
1943 | return -EBUSY; | 1997 | return -EBUSY; |
@@ -1946,8 +2000,8 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag) | |||
1946 | ioc->pci_irq = ioc->pcidev->irq; | 2000 | ioc->pci_irq = ioc->pcidev->irq; |
1947 | pci_set_master(ioc->pcidev); /* ?? */ | 2001 | pci_set_master(ioc->pcidev); /* ?? */ |
1948 | pci_set_drvdata(ioc->pcidev, ioc); | 2002 | pci_set_drvdata(ioc->pcidev, ioc); |
1949 | dprintk(ioc, printk(KERN_INFO MYNAM ": %s installed at interrupt " | 2003 | dprintk(ioc, printk(MYIOC_s_INFO_FMT "installed at interrupt " |
1950 | "%d\n", ioc->name, ioc->pcidev->irq)); | 2004 | "%d\n", ioc->name, ioc->pcidev->irq)); |
1951 | } | 2005 | } |
1952 | } | 2006 | } |
1953 | 2007 | ||
@@ -1966,8 +2020,8 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag) | |||
1966 | ret = -4; | 2020 | ret = -4; |
1967 | // NEW! | 2021 | // NEW! |
1968 | if (alt_ioc_ready && ((rc = PrimeIocFifos(ioc->alt_ioc)) != 0)) { | 2022 | if (alt_ioc_ready && ((rc = PrimeIocFifos(ioc->alt_ioc)) != 0)) { |
1969 | printk(KERN_WARNING MYNAM ": alt-%s: (%d) FIFO mgmt alloc WARNING!\n", | 2023 | printk(MYIOC_s_WARN_FMT ": alt_ioc (%d) FIFO mgmt alloc!\n", |
1970 | ioc->alt_ioc->name, rc); | 2024 | ioc->alt_ioc->name, rc); |
1971 | alt_ioc_ready = 0; | 2025 | alt_ioc_ready = 0; |
1972 | reset_alt_ioc_active = 0; | 2026 | reset_alt_ioc_active = 0; |
1973 | } | 2027 | } |
@@ -1976,16 +2030,15 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag) | |||
1976 | if ((rc = SendIocInit(ioc->alt_ioc, sleepFlag)) != 0) { | 2030 | if ((rc = SendIocInit(ioc->alt_ioc, sleepFlag)) != 0) { |
1977 | alt_ioc_ready = 0; | 2031 | alt_ioc_ready = 0; |
1978 | reset_alt_ioc_active = 0; | 2032 | reset_alt_ioc_active = 0; |
1979 | printk(KERN_WARNING MYNAM | 2033 | printk(MYIOC_s_WARN_FMT "alt_ioc (%d) init failure!\n", |
1980 | ": alt-%s: (%d) init failure WARNING!\n", | 2034 | ioc->alt_ioc->name, rc); |
1981 | ioc->alt_ioc->name, rc); | ||
1982 | } | 2035 | } |
1983 | } | 2036 | } |
1984 | 2037 | ||
1985 | if (reason == MPT_HOSTEVENT_IOC_BRINGUP){ | 2038 | if (reason == MPT_HOSTEVENT_IOC_BRINGUP){ |
1986 | if (ioc->upload_fw) { | 2039 | if (ioc->upload_fw) { |
1987 | ddlprintk(ioc, printk(MYIOC_s_DEBUG_FMT | 2040 | ddlprintk(ioc, printk(MYIOC_s_DEBUG_FMT |
1988 | "firmware upload required!\n", ioc->name)); | 2041 | "firmware upload required!\n", ioc->name)); |
1989 | 2042 | ||
1990 | /* Controller is not operational, cannot do upload | 2043 | /* Controller is not operational, cannot do upload |
1991 | */ | 2044 | */ |
@@ -2001,12 +2054,13 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag) | |||
2001 | * mpt_diag_reset) | 2054 | * mpt_diag_reset) |
2002 | */ | 2055 | */ |
2003 | ddlprintk(ioc, printk(MYIOC_s_DEBUG_FMT | 2056 | ddlprintk(ioc, printk(MYIOC_s_DEBUG_FMT |
2004 | ": mpt_upload: alt_%s has cached_fw=%p \n", | 2057 | "mpt_upload: alt_%s has cached_fw=%p \n", |
2005 | ioc->name, ioc->alt_ioc->name, ioc->alt_ioc->cached_fw)); | 2058 | ioc->name, ioc->alt_ioc->name, ioc->alt_ioc->cached_fw)); |
2006 | ioc->alt_ioc->cached_fw = NULL; | 2059 | ioc->alt_ioc->cached_fw = NULL; |
2007 | } | 2060 | } |
2008 | } else { | 2061 | } else { |
2009 | printk(KERN_WARNING MYNAM ": firmware upload failure!\n"); | 2062 | printk(MYIOC_s_WARN_FMT |
2063 | "firmware upload failure!\n", ioc->name); | ||
2010 | ret = -5; | 2064 | ret = -5; |
2011 | } | 2065 | } |
2012 | } | 2066 | } |
@@ -2021,8 +2075,8 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag) | |||
2021 | 2075 | ||
2022 | if (reset_alt_ioc_active && ioc->alt_ioc) { | 2076 | if (reset_alt_ioc_active && ioc->alt_ioc) { |
2023 | /* (re)Enable alt-IOC! (reply interrupt) */ | 2077 | /* (re)Enable alt-IOC! (reply interrupt) */ |
2024 | dinitprintk(ioc, printk(KERN_INFO MYNAM ": alt-%s reply irq re-enabled\n", | 2078 | dinitprintk(ioc, printk(MYIOC_s_INFO_FMT "alt_ioc reply irq re-enabled\n", |
2025 | ioc->alt_ioc->name)); | 2079 | ioc->alt_ioc->name)); |
2026 | CHIPREG_WRITE32(&ioc->alt_ioc->chip->IntMask, MPI_HIM_DIM); | 2080 | CHIPREG_WRITE32(&ioc->alt_ioc->chip->IntMask, MPI_HIM_DIM); |
2027 | ioc->alt_ioc->active = 1; | 2081 | ioc->alt_ioc->active = 1; |
2028 | } | 2082 | } |
@@ -2075,10 +2129,8 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag) | |||
2075 | (void) GetLanConfigPages(ioc); | 2129 | (void) GetLanConfigPages(ioc); |
2076 | a = (u8*)&ioc->lan_cnfg_page1.HardwareAddressLow; | 2130 | a = (u8*)&ioc->lan_cnfg_page1.HardwareAddressLow; |
2077 | dprintk(ioc, printk(MYIOC_s_DEBUG_FMT | 2131 | dprintk(ioc, printk(MYIOC_s_DEBUG_FMT |
2078 | "LanAddr = %02X:%02X:%02X:" | 2132 | "LanAddr = %02X:%02X:%02X:%02X:%02X:%02X\n", |
2079 | "%02X:%02X:%02X\n", | 2133 | ioc->name, a[5], a[4], a[3], a[2], a[1], a[0])); |
2080 | ioc->name, a[5], a[4], | ||
2081 | a[3], a[2], a[1], a[0] )); | ||
2082 | 2134 | ||
2083 | } | 2135 | } |
2084 | } else { | 2136 | } else { |
@@ -2114,20 +2166,20 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag) | |||
2114 | */ | 2166 | */ |
2115 | if (hard_reset_done) { | 2167 | if (hard_reset_done) { |
2116 | rc = handlers = 0; | 2168 | rc = handlers = 0; |
2117 | for (ii=MPT_MAX_PROTOCOL_DRIVERS-1; ii; ii--) { | 2169 | for (cb_idx = MPT_MAX_PROTOCOL_DRIVERS-1; cb_idx; cb_idx--) { |
2118 | if ((ret == 0) && MptResetHandlers[ii]) { | 2170 | if ((ret == 0) && MptResetHandlers[cb_idx]) { |
2119 | dprintk(ioc, printk(MYIOC_s_DEBUG_FMT | 2171 | dprintk(ioc, printk(MYIOC_s_DEBUG_FMT |
2120 | "Calling IOC post_reset handler #%d\n", | 2172 | "Calling IOC post_reset handler #%d\n", |
2121 | ioc->name, ii)); | 2173 | ioc->name, cb_idx)); |
2122 | rc += mpt_signal_reset(ii, ioc, MPT_IOC_POST_RESET); | 2174 | rc += mpt_signal_reset(cb_idx, ioc, MPT_IOC_POST_RESET); |
2123 | handlers++; | 2175 | handlers++; |
2124 | } | 2176 | } |
2125 | 2177 | ||
2126 | if (alt_ioc_ready && MptResetHandlers[ii]) { | 2178 | if (alt_ioc_ready && MptResetHandlers[cb_idx]) { |
2127 | drsprintk(ioc, printk(MYIOC_s_DEBUG_FMT | 2179 | drsprintk(ioc, printk(MYIOC_s_DEBUG_FMT |
2128 | "Calling alt-%s post_reset handler #%d\n", | 2180 | "Calling IOC post_reset handler #%d\n", |
2129 | ioc->name, ioc->alt_ioc->name, ii)); | 2181 | ioc->alt_ioc->name, cb_idx)); |
2130 | rc += mpt_signal_reset(ii, ioc->alt_ioc, MPT_IOC_POST_RESET); | 2182 | rc += mpt_signal_reset(cb_idx, ioc->alt_ioc, MPT_IOC_POST_RESET); |
2131 | handlers++; | 2183 | handlers++; |
2132 | } | 2184 | } |
2133 | } | 2185 | } |
@@ -2166,8 +2218,8 @@ mpt_detect_bound_ports(MPT_ADAPTER *ioc, struct pci_dev *pdev) | |||
2166 | 2218 | ||
2167 | dprintk(ioc, printk(MYIOC_s_DEBUG_FMT "PCI device %s devfn=%x/%x," | 2219 | dprintk(ioc, printk(MYIOC_s_DEBUG_FMT "PCI device %s devfn=%x/%x," |
2168 | " searching for devfn match on %x or %x\n", | 2220 | " searching for devfn match on %x or %x\n", |
2169 | ioc->name, pci_name(pdev), pdev->bus->number, | 2221 | ioc->name, pci_name(pdev), pdev->bus->number, |
2170 | pdev->devfn, func-1, func+1)); | 2222 | pdev->devfn, func-1, func+1)); |
2171 | 2223 | ||
2172 | peer = pci_get_slot(pdev->bus, PCI_DEVFN(slot,func-1)); | 2224 | peer = pci_get_slot(pdev->bus, PCI_DEVFN(slot,func-1)); |
2173 | if (!peer) { | 2225 | if (!peer) { |
@@ -2181,15 +2233,15 @@ mpt_detect_bound_ports(MPT_ADAPTER *ioc, struct pci_dev *pdev) | |||
2181 | if (_pcidev == peer) { | 2233 | if (_pcidev == peer) { |
2182 | /* Paranoia checks */ | 2234 | /* Paranoia checks */ |
2183 | if (ioc->alt_ioc != NULL) { | 2235 | if (ioc->alt_ioc != NULL) { |
2184 | printk(KERN_WARNING MYNAM ": Oops, already bound (%s <==> %s)!\n", | 2236 | printk(MYIOC_s_WARN_FMT "Oops, already bound to %s!\n", |
2185 | ioc->name, ioc->alt_ioc->name); | 2237 | ioc->name, ioc->alt_ioc->name); |
2186 | break; | 2238 | break; |
2187 | } else if (ioc_srch->alt_ioc != NULL) { | 2239 | } else if (ioc_srch->alt_ioc != NULL) { |
2188 | printk(KERN_WARNING MYNAM ": Oops, already bound (%s <==> %s)!\n", | 2240 | printk(MYIOC_s_WARN_FMT "Oops, already bound to %s!\n", |
2189 | ioc_srch->name, ioc_srch->alt_ioc->name); | 2241 | ioc_srch->name, ioc_srch->alt_ioc->name); |
2190 | break; | 2242 | break; |
2191 | } | 2243 | } |
2192 | dprintk(ioc, printk(KERN_INFO MYNAM ": FOUND! binding %s <==> %s\n", | 2244 | dprintk(ioc, printk(MYIOC_s_INFO_FMT "FOUND! binding to %s\n", |
2193 | ioc->name, ioc_srch->name)); | 2245 | ioc->name, ioc_srch->name)); |
2194 | ioc_srch->alt_ioc = ioc; | 2246 | ioc_srch->alt_ioc = ioc; |
2195 | ioc->alt_ioc = ioc_srch; | 2247 | ioc->alt_ioc = ioc_srch; |
@@ -2210,10 +2262,11 @@ mpt_adapter_disable(MPT_ADAPTER *ioc) | |||
2210 | int ret; | 2262 | int ret; |
2211 | 2263 | ||
2212 | if (ioc->cached_fw != NULL) { | 2264 | if (ioc->cached_fw != NULL) { |
2213 | ddlprintk(ioc, printk(KERN_INFO MYNAM ": mpt_adapter_disable: Pushing FW onto adapter\n")); | 2265 | ddlprintk(ioc, printk(MYIOC_s_INFO_FMT |
2266 | "mpt_adapter_disable: Pushing FW onto adapter\n", ioc->name)); | ||
2214 | if ((ret = mpt_downloadboot(ioc, (MpiFwHeader_t *)ioc->cached_fw, NO_SLEEP)) < 0) { | 2267 | if ((ret = mpt_downloadboot(ioc, (MpiFwHeader_t *)ioc->cached_fw, NO_SLEEP)) < 0) { |
2215 | printk(KERN_WARNING MYNAM | 2268 | printk(MYIOC_s_WARN_FMT "firmware downloadboot failure (%d)!\n", |
2216 | ": firmware downloadboot failure (%d)!\n", ret); | 2269 | ioc->name, ret); |
2217 | } | 2270 | } |
2218 | } | 2271 | } |
2219 | 2272 | ||
@@ -2225,8 +2278,8 @@ mpt_adapter_disable(MPT_ADAPTER *ioc) | |||
2225 | 2278 | ||
2226 | if (ioc->alloc != NULL) { | 2279 | if (ioc->alloc != NULL) { |
2227 | sz = ioc->alloc_sz; | 2280 | sz = ioc->alloc_sz; |
2228 | dexitprintk(ioc, printk(KERN_INFO MYNAM ": %s.free @ %p, sz=%d bytes\n", | 2281 | dexitprintk(ioc, printk(MYIOC_s_INFO_FMT "free @ %p, sz=%d bytes\n", |
2229 | ioc->name, ioc->alloc, ioc->alloc_sz)); | 2282 | ioc->name, ioc->alloc, ioc->alloc_sz)); |
2230 | pci_free_consistent(ioc->pcidev, sz, | 2283 | pci_free_consistent(ioc->pcidev, sz, |
2231 | ioc->alloc, ioc->alloc_dma); | 2284 | ioc->alloc, ioc->alloc_dma); |
2232 | ioc->reply_frames = NULL; | 2285 | ioc->reply_frames = NULL; |
@@ -2286,15 +2339,14 @@ mpt_adapter_disable(MPT_ADAPTER *ioc) | |||
2286 | if (ioc->HostPageBuffer != NULL) { | 2339 | if (ioc->HostPageBuffer != NULL) { |
2287 | if((ret = mpt_host_page_access_control(ioc, | 2340 | if((ret = mpt_host_page_access_control(ioc, |
2288 | MPI_DB_HPBAC_FREE_BUFFER, NO_SLEEP)) != 0) { | 2341 | MPI_DB_HPBAC_FREE_BUFFER, NO_SLEEP)) != 0) { |
2289 | printk(KERN_ERR MYNAM | 2342 | printk(MYIOC_s_ERR_FMT |
2290 | ": %s: host page buffers free failed (%d)!\n", | 2343 | "host page buffers free failed (%d)!\n", |
2291 | __FUNCTION__, ret); | 2344 | ioc->name, ret); |
2292 | } | 2345 | } |
2293 | dexitprintk(ioc, printk(KERN_INFO MYNAM ": %s HostPageBuffer free @ %p, sz=%d bytes\n", | 2346 | dexitprintk(ioc, printk(MYIOC_s_INFO_FMT "HostPageBuffer free @ %p, sz=%d bytes\n", |
2294 | ioc->name, ioc->HostPageBuffer, ioc->HostPageBuffer_sz)); | 2347 | ioc->name, ioc->HostPageBuffer, ioc->HostPageBuffer_sz)); |
2295 | pci_free_consistent(ioc->pcidev, ioc->HostPageBuffer_sz, | 2348 | pci_free_consistent(ioc->pcidev, ioc->HostPageBuffer_sz, |
2296 | ioc->HostPageBuffer, | 2349 | ioc->HostPageBuffer, ioc->HostPageBuffer_dma); |
2297 | ioc->HostPageBuffer_dma); | ||
2298 | ioc->HostPageBuffer = NULL; | 2350 | ioc->HostPageBuffer = NULL; |
2299 | ioc->HostPageBuffer_sz = 0; | 2351 | ioc->HostPageBuffer_sz = 0; |
2300 | ioc->alloc_total -= ioc->HostPageBuffer_sz; | 2352 | ioc->alloc_total -= ioc->HostPageBuffer_sz; |
@@ -2336,7 +2388,7 @@ mpt_adapter_dispose(MPT_ADAPTER *ioc) | |||
2336 | #if defined(CONFIG_MTRR) && 0 | 2388 | #if defined(CONFIG_MTRR) && 0 |
2337 | if (ioc->mtrr_reg > 0) { | 2389 | if (ioc->mtrr_reg > 0) { |
2338 | mtrr_del(ioc->mtrr_reg, 0, 0); | 2390 | mtrr_del(ioc->mtrr_reg, 0, 0); |
2339 | dprintk(ioc, printk(KERN_INFO MYNAM ": %s: MTRR region de-registered\n", ioc->name)); | 2391 | dprintk(ioc, printk(MYIOC_s_INFO_FMT "MTRR region de-registered\n", ioc->name)); |
2340 | } | 2392 | } |
2341 | #endif | 2393 | #endif |
2342 | 2394 | ||
@@ -2344,8 +2396,8 @@ mpt_adapter_dispose(MPT_ADAPTER *ioc) | |||
2344 | list_del(&ioc->list); | 2396 | list_del(&ioc->list); |
2345 | 2397 | ||
2346 | sz_last = ioc->alloc_total; | 2398 | sz_last = ioc->alloc_total; |
2347 | dprintk(ioc, printk(KERN_INFO MYNAM ": %s: free'd %d of %d bytes\n", | 2399 | dprintk(ioc, printk(MYIOC_s_INFO_FMT "free'd %d of %d bytes\n", |
2348 | ioc->name, sz_first-sz_last+(int)sizeof(*ioc), sz_first)); | 2400 | ioc->name, sz_first-sz_last+(int)sizeof(*ioc), sz_first)); |
2349 | 2401 | ||
2350 | if (ioc->alt_ioc) | 2402 | if (ioc->alt_ioc) |
2351 | ioc->alt_ioc->alt_ioc = NULL; | 2403 | ioc->alt_ioc->alt_ioc = NULL; |
@@ -2424,7 +2476,7 @@ MakeIocReady(MPT_ADAPTER *ioc, int force, int sleepFlag) | |||
2424 | 2476 | ||
2425 | /* Get current [raw] IOC state */ | 2477 | /* Get current [raw] IOC state */ |
2426 | ioc_state = mpt_GetIocState(ioc, 0); | 2478 | ioc_state = mpt_GetIocState(ioc, 0); |
2427 | dhsprintk(ioc, printk(KERN_INFO MYNAM "::MakeIocReady, %s [raw] state=%08x\n", ioc->name, ioc_state)); | 2479 | dhsprintk(ioc, printk(MYIOC_s_INFO_FMT "MakeIocReady [raw] state=%08x\n", ioc->name, ioc_state)); |
2428 | 2480 | ||
2429 | /* | 2481 | /* |
2430 | * Check to see if IOC got left/stuck in doorbell handshake | 2482 | * Check to see if IOC got left/stuck in doorbell handshake |
@@ -2446,9 +2498,9 @@ MakeIocReady(MPT_ADAPTER *ioc, int force, int sleepFlag) | |||
2446 | if ((ioc_state & MPI_IOC_STATE_MASK) == MPI_IOC_STATE_FAULT) { | 2498 | if ((ioc_state & MPI_IOC_STATE_MASK) == MPI_IOC_STATE_FAULT) { |
2447 | statefault = 2; | 2499 | statefault = 2; |
2448 | printk(MYIOC_s_WARN_FMT "IOC is in FAULT state!!!\n", | 2500 | printk(MYIOC_s_WARN_FMT "IOC is in FAULT state!!!\n", |
2449 | ioc->name); | 2501 | ioc->name); |
2450 | printk(KERN_WARNING " FAULT code = %04xh\n", | 2502 | printk(MYIOC_s_WARN_FMT " FAULT code = %04xh\n", |
2451 | ioc_state & MPI_DOORBELL_DATA_MASK); | 2503 | ioc->name, ioc_state & MPI_DOORBELL_DATA_MASK); |
2452 | } | 2504 | } |
2453 | 2505 | ||
2454 | /* | 2506 | /* |
@@ -2464,9 +2516,9 @@ MakeIocReady(MPT_ADAPTER *ioc, int force, int sleepFlag) | |||
2464 | * Else, fall through to KickStart case | 2516 | * Else, fall through to KickStart case |
2465 | */ | 2517 | */ |
2466 | whoinit = (ioc_state & MPI_DOORBELL_WHO_INIT_MASK) >> MPI_DOORBELL_WHO_INIT_SHIFT; | 2518 | whoinit = (ioc_state & MPI_DOORBELL_WHO_INIT_MASK) >> MPI_DOORBELL_WHO_INIT_SHIFT; |
2467 | dinitprintk(ioc, printk(KERN_INFO MYNAM | 2519 | dinitprintk(ioc, printk(MYIOC_s_INFO_FMT |
2468 | ": whoinit 0x%x statefault %d force %d\n", | 2520 | "whoinit 0x%x statefault %d force %d\n", |
2469 | whoinit, statefault, force)); | 2521 | ioc->name, whoinit, statefault, force)); |
2470 | if (whoinit == MPI_WHOINIT_PCI_PEER) | 2522 | if (whoinit == MPI_WHOINIT_PCI_PEER) |
2471 | return -4; | 2523 | return -4; |
2472 | else { | 2524 | else { |
@@ -2549,7 +2601,6 @@ mpt_GetIocState(MPT_ADAPTER *ioc, int cooked) | |||
2549 | 2601 | ||
2550 | /* Get! */ | 2602 | /* Get! */ |
2551 | s = CHIPREG_READ32(&ioc->chip->Doorbell); | 2603 | s = CHIPREG_READ32(&ioc->chip->Doorbell); |
2552 | // dprintk((MYIOC_s_INFO_FMT "raw state = %08x\n", ioc->name, s)); | ||
2553 | sc = s & MPI_IOC_STATE_MASK; | 2604 | sc = s & MPI_IOC_STATE_MASK; |
2554 | 2605 | ||
2555 | /* Save! */ | 2606 | /* Save! */ |
@@ -2581,9 +2632,8 @@ GetIocFacts(MPT_ADAPTER *ioc, int sleepFlag, int reason) | |||
2581 | 2632 | ||
2582 | /* IOC *must* NOT be in RESET state! */ | 2633 | /* IOC *must* NOT be in RESET state! */ |
2583 | if (ioc->last_state == MPI_IOC_STATE_RESET) { | 2634 | if (ioc->last_state == MPI_IOC_STATE_RESET) { |
2584 | printk(KERN_ERR MYNAM ": ERROR - Can't get IOCFacts, %s NOT READY! (%08x)\n", | 2635 | printk(MYIOC_s_ERR_FMT "Can't get IOCFacts NOT READY! (%08x)\n", |
2585 | ioc->name, | 2636 | ioc->name, ioc->last_state ); |
2586 | ioc->last_state ); | ||
2587 | return -44; | 2637 | return -44; |
2588 | } | 2638 | } |
2589 | 2639 | ||
@@ -2703,8 +2753,8 @@ GetIocFacts(MPT_ADAPTER *ioc, int sleepFlag, int reason) | |||
2703 | } | 2753 | } |
2704 | ioc->NBShiftFactor = shiftFactor; | 2754 | ioc->NBShiftFactor = shiftFactor; |
2705 | dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT | 2755 | dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT |
2706 | "NB_for_64_byte_frame=%x NBShiftFactor=%x BlockSize=%x\n", | 2756 | "NB_for_64_byte_frame=%x NBShiftFactor=%x BlockSize=%x\n", |
2707 | ioc->name, vv, shiftFactor, r)); | 2757 | ioc->name, vv, shiftFactor, r)); |
2708 | 2758 | ||
2709 | if (reason == MPT_HOSTEVENT_IOC_BRINGUP) { | 2759 | if (reason == MPT_HOSTEVENT_IOC_BRINGUP) { |
2710 | /* | 2760 | /* |
@@ -2757,9 +2807,8 @@ GetPortFacts(MPT_ADAPTER *ioc, int portnum, int sleepFlag) | |||
2757 | 2807 | ||
2758 | /* IOC *must* NOT be in RESET state! */ | 2808 | /* IOC *must* NOT be in RESET state! */ |
2759 | if (ioc->last_state == MPI_IOC_STATE_RESET) { | 2809 | if (ioc->last_state == MPI_IOC_STATE_RESET) { |
2760 | printk(KERN_ERR MYNAM ": ERROR - Can't get PortFacts, %s NOT READY! (%08x)\n", | 2810 | printk(MYIOC_s_ERR_FMT "Can't get PortFacts NOT READY! (%08x)\n", |
2761 | ioc->name, | 2811 | ioc->name, ioc->last_state ); |
2762 | ioc->last_state ); | ||
2763 | return -4; | 2812 | return -4; |
2764 | } | 2813 | } |
2765 | 2814 | ||
@@ -2934,7 +2983,7 @@ SendIocInit(MPT_ADAPTER *ioc, int sleepFlag) | |||
2934 | state = mpt_GetIocState(ioc, 1); | 2983 | state = mpt_GetIocState(ioc, 1); |
2935 | count++; | 2984 | count++; |
2936 | } | 2985 | } |
2937 | dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "INFO - Wait IOC_OPERATIONAL state (cnt=%d)\n", | 2986 | dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Wait IOC_OPERATIONAL state (cnt=%d)\n", |
2938 | ioc->name, count)); | 2987 | ioc->name, count)); |
2939 | 2988 | ||
2940 | ioc->aen_event_read_flag=0; | 2989 | ioc->aen_event_read_flag=0; |
@@ -3027,10 +3076,9 @@ mpt_free_fw_memory(MPT_ADAPTER *ioc) | |||
3027 | int sz; | 3076 | int sz; |
3028 | 3077 | ||
3029 | sz = ioc->facts.FWImageSize; | 3078 | sz = ioc->facts.FWImageSize; |
3030 | dinitprintk(ioc, printk(KERN_INFO MYNAM "free_fw_memory: FW Image @ %p[%p], sz=%d[%x] bytes\n", | 3079 | dinitprintk(ioc, printk(MYIOC_s_INFO_FMT "free_fw_memory: FW Image @ %p[%p], sz=%d[%x] bytes\n", |
3031 | ioc->cached_fw, (void *)(ulong)ioc->cached_fw_dma, sz, sz)); | 3080 | ioc->name, ioc->cached_fw, (void *)(ulong)ioc->cached_fw_dma, sz, sz)); |
3032 | pci_free_consistent(ioc->pcidev, sz, | 3081 | pci_free_consistent(ioc->pcidev, sz, ioc->cached_fw, ioc->cached_fw_dma); |
3033 | ioc->cached_fw, ioc->cached_fw_dma); | ||
3034 | ioc->cached_fw = NULL; | 3082 | ioc->cached_fw = NULL; |
3035 | 3083 | ||
3036 | return; | 3084 | return; |
@@ -3054,7 +3102,6 @@ mpt_free_fw_memory(MPT_ADAPTER *ioc) | |||
3054 | static int | 3102 | static int |
3055 | mpt_do_upload(MPT_ADAPTER *ioc, int sleepFlag) | 3103 | mpt_do_upload(MPT_ADAPTER *ioc, int sleepFlag) |
3056 | { | 3104 | { |
3057 | u8 request[ioc->req_sz]; | ||
3058 | u8 reply[sizeof(FWUploadReply_t)]; | 3105 | u8 reply[sizeof(FWUploadReply_t)]; |
3059 | FWUpload_t *prequest; | 3106 | FWUpload_t *prequest; |
3060 | FWUploadReply_t *preply; | 3107 | FWUploadReply_t *preply; |
@@ -3071,8 +3118,8 @@ mpt_do_upload(MPT_ADAPTER *ioc, int sleepFlag) | |||
3071 | 3118 | ||
3072 | mpt_alloc_fw_memory(ioc, sz); | 3119 | mpt_alloc_fw_memory(ioc, sz); |
3073 | 3120 | ||
3074 | dinitprintk(ioc, printk(KERN_INFO MYNAM ": FW Image @ %p[%p], sz=%d[%x] bytes\n", | 3121 | dinitprintk(ioc, printk(MYIOC_s_INFO_FMT ": FW Image @ %p[%p], sz=%d[%x] bytes\n", |
3075 | ioc->cached_fw, (void *)(ulong)ioc->cached_fw_dma, sz, sz)); | 3122 | ioc->name, ioc->cached_fw, (void *)(ulong)ioc->cached_fw_dma, sz, sz)); |
3076 | 3123 | ||
3077 | if (ioc->cached_fw == NULL) { | 3124 | if (ioc->cached_fw == NULL) { |
3078 | /* Major Failure. | 3125 | /* Major Failure. |
@@ -3080,11 +3127,16 @@ mpt_do_upload(MPT_ADAPTER *ioc, int sleepFlag) | |||
3080 | return -ENOMEM; | 3127 | return -ENOMEM; |
3081 | } | 3128 | } |
3082 | 3129 | ||
3083 | prequest = (FWUpload_t *)&request; | 3130 | prequest = (sleepFlag == NO_SLEEP) ? kzalloc(ioc->req_sz, GFP_ATOMIC) : |
3084 | preply = (FWUploadReply_t *)&reply; | 3131 | kzalloc(ioc->req_sz, GFP_KERNEL); |
3132 | if (!prequest) { | ||
3133 | dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "fw upload failed " | ||
3134 | "while allocating memory \n", ioc->name)); | ||
3135 | mpt_free_fw_memory(ioc); | ||
3136 | return -ENOMEM; | ||
3137 | } | ||
3085 | 3138 | ||
3086 | /* Destination... */ | 3139 | preply = (FWUploadReply_t *)&reply; |
3087 | memset(prequest, 0, ioc->req_sz); | ||
3088 | 3140 | ||
3089 | reply_sz = sizeof(reply); | 3141 | reply_sz = sizeof(reply); |
3090 | memset(preply, 0, reply_sz); | 3142 | memset(preply, 0, reply_sz); |
@@ -3096,21 +3148,22 @@ mpt_do_upload(MPT_ADAPTER *ioc, int sleepFlag) | |||
3096 | ptcsge->DetailsLength = 12; | 3148 | ptcsge->DetailsLength = 12; |
3097 | ptcsge->Flags = MPI_SGE_FLAGS_TRANSACTION_ELEMENT; | 3149 | ptcsge->Flags = MPI_SGE_FLAGS_TRANSACTION_ELEMENT; |
3098 | ptcsge->ImageSize = cpu_to_le32(sz); | 3150 | ptcsge->ImageSize = cpu_to_le32(sz); |
3151 | ptcsge++; | ||
3099 | 3152 | ||
3100 | sgeoffset = sizeof(FWUpload_t) - sizeof(SGE_MPI_UNION) + sizeof(FWUploadTCSGE_t); | 3153 | sgeoffset = sizeof(FWUpload_t) - sizeof(SGE_MPI_UNION) + sizeof(FWUploadTCSGE_t); |
3101 | 3154 | ||
3102 | flagsLength = MPT_SGE_FLAGS_SSIMPLE_READ | sz; | 3155 | flagsLength = MPT_SGE_FLAGS_SSIMPLE_READ | sz; |
3103 | mpt_add_sge(&request[sgeoffset], flagsLength, ioc->cached_fw_dma); | 3156 | mpt_add_sge((char *)ptcsge, flagsLength, ioc->cached_fw_dma); |
3104 | 3157 | ||
3105 | sgeoffset += sizeof(u32) + sizeof(dma_addr_t); | 3158 | sgeoffset += sizeof(u32) + sizeof(dma_addr_t); |
3106 | dinitprintk(ioc, printk(KERN_INFO MYNAM ": Sending FW Upload (req @ %p) sgeoffset=%d \n", | 3159 | dinitprintk(ioc, printk(MYIOC_s_INFO_FMT ": Sending FW Upload (req @ %p) sgeoffset=%d \n", |
3107 | prequest, sgeoffset)); | 3160 | ioc->name, prequest, sgeoffset)); |
3108 | DBG_DUMP_FW_REQUEST_FRAME(ioc, (u32 *)prequest) | 3161 | DBG_DUMP_FW_REQUEST_FRAME(ioc, (u32 *)prequest); |
3109 | 3162 | ||
3110 | ii = mpt_handshake_req_reply_wait(ioc, sgeoffset, (u32*)prequest, | 3163 | ii = mpt_handshake_req_reply_wait(ioc, sgeoffset, (u32*)prequest, |
3111 | reply_sz, (u16*)preply, 65 /*seconds*/, sleepFlag); | 3164 | reply_sz, (u16*)preply, 65 /*seconds*/, sleepFlag); |
3112 | 3165 | ||
3113 | dinitprintk(ioc, printk(KERN_INFO MYNAM ": FW Upload completed rc=%x \n", ii)); | 3166 | dinitprintk(ioc, printk(MYIOC_s_INFO_FMT ": FW Upload completed rc=%x \n", ioc->name, ii)); |
3114 | 3167 | ||
3115 | cmdStatus = -EFAULT; | 3168 | cmdStatus = -EFAULT; |
3116 | if (ii == 0) { | 3169 | if (ii == 0) { |
@@ -3135,6 +3188,7 @@ mpt_do_upload(MPT_ADAPTER *ioc, int sleepFlag) | |||
3135 | ioc->name)); | 3188 | ioc->name)); |
3136 | mpt_free_fw_memory(ioc); | 3189 | mpt_free_fw_memory(ioc); |
3137 | } | 3190 | } |
3191 | kfree(prequest); | ||
3138 | 3192 | ||
3139 | return cmdStatus; | 3193 | return cmdStatus; |
3140 | } | 3194 | } |
@@ -3381,7 +3435,7 @@ KickStart(MPT_ADAPTER *ioc, int force, int sleepFlag) | |||
3381 | u32 ioc_state=0; | 3435 | u32 ioc_state=0; |
3382 | int cnt,cntdn; | 3436 | int cnt,cntdn; |
3383 | 3437 | ||
3384 | dinitprintk(ioc, printk(KERN_WARNING MYNAM ": KickStarting %s!\n", ioc->name)); | 3438 | dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "KickStarting!\n", ioc->name)); |
3385 | if (ioc->bus_type == SPI) { | 3439 | if (ioc->bus_type == SPI) { |
3386 | /* Always issue a Msg Unit Reset first. This will clear some | 3440 | /* Always issue a Msg Unit Reset first. This will clear some |
3387 | * SCSI bus hang conditions. | 3441 | * SCSI bus hang conditions. |
@@ -3400,7 +3454,7 @@ KickStart(MPT_ADAPTER *ioc, int force, int sleepFlag) | |||
3400 | return hard_reset_done; | 3454 | return hard_reset_done; |
3401 | 3455 | ||
3402 | dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Diagnostic reset successful!\n", | 3456 | dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Diagnostic reset successful!\n", |
3403 | ioc->name)); | 3457 | ioc->name)); |
3404 | 3458 | ||
3405 | cntdn = ((sleepFlag == CAN_SLEEP) ? HZ : 1000) * 2; /* 2 seconds */ | 3459 | cntdn = ((sleepFlag == CAN_SLEEP) ? HZ : 1000) * 2; /* 2 seconds */ |
3406 | for (cnt=0; cnt<cntdn; cnt++) { | 3460 | for (cnt=0; cnt<cntdn; cnt++) { |
@@ -3417,8 +3471,8 @@ KickStart(MPT_ADAPTER *ioc, int force, int sleepFlag) | |||
3417 | } | 3471 | } |
3418 | } | 3472 | } |
3419 | 3473 | ||
3420 | printk(MYIOC_s_ERR_FMT "Failed to come READY after reset! IocState=%x\n", | 3474 | dinitprintk(ioc, printk(MYIOC_s_ERR_FMT "Failed to come READY after reset! IocState=%x\n", |
3421 | ioc->name, ioc_state); | 3475 | ioc->name, mpt_GetIocState(ioc, 0))); |
3422 | return -1; | 3476 | return -1; |
3423 | } | 3477 | } |
3424 | 3478 | ||
@@ -3560,20 +3614,20 @@ mpt_diag_reset(MPT_ADAPTER *ioc, int ignore, int sleepFlag) | |||
3560 | * MptResetHandlers[] registered yet. | 3614 | * MptResetHandlers[] registered yet. |
3561 | */ | 3615 | */ |
3562 | { | 3616 | { |
3563 | int ii; | 3617 | u8 cb_idx; |
3564 | int r = 0; | 3618 | int r = 0; |
3565 | 3619 | ||
3566 | for (ii=MPT_MAX_PROTOCOL_DRIVERS-1; ii; ii--) { | 3620 | for (cb_idx = MPT_MAX_PROTOCOL_DRIVERS-1; cb_idx; cb_idx--) { |
3567 | if (MptResetHandlers[ii]) { | 3621 | if (MptResetHandlers[cb_idx]) { |
3568 | dprintk(ioc, printk(MYIOC_s_DEBUG_FMT | 3622 | dprintk(ioc, printk(MYIOC_s_DEBUG_FMT |
3569 | "Calling IOC pre_reset handler #%d\n", | 3623 | "Calling IOC pre_reset handler #%d\n", |
3570 | ioc->name, ii)); | 3624 | ioc->name, cb_idx)); |
3571 | r += mpt_signal_reset(ii, ioc, MPT_IOC_PRE_RESET); | 3625 | r += mpt_signal_reset(cb_idx, ioc, MPT_IOC_PRE_RESET); |
3572 | if (ioc->alt_ioc) { | 3626 | if (ioc->alt_ioc) { |
3573 | dprintk(ioc, printk(MYIOC_s_DEBUG_FMT | 3627 | dprintk(ioc, printk(MYIOC_s_DEBUG_FMT |
3574 | "Calling alt-%s pre_reset handler #%d\n", | 3628 | "Calling alt-%s pre_reset handler #%d\n", |
3575 | ioc->name, ioc->alt_ioc->name, ii)); | 3629 | ioc->name, ioc->alt_ioc->name, cb_idx)); |
3576 | r += mpt_signal_reset(ii, ioc->alt_ioc, MPT_IOC_PRE_RESET); | 3630 | r += mpt_signal_reset(cb_idx, ioc->alt_ioc, MPT_IOC_PRE_RESET); |
3577 | } | 3631 | } |
3578 | } | 3632 | } |
3579 | } | 3633 | } |
@@ -3606,8 +3660,8 @@ mpt_diag_reset(MPT_ADAPTER *ioc, int ignore, int sleepFlag) | |||
3606 | } | 3660 | } |
3607 | if ((count = mpt_downloadboot(ioc, | 3661 | if ((count = mpt_downloadboot(ioc, |
3608 | (MpiFwHeader_t *)iocp->cached_fw, sleepFlag)) < 0) { | 3662 | (MpiFwHeader_t *)iocp->cached_fw, sleepFlag)) < 0) { |
3609 | printk(KERN_WARNING MYNAM | 3663 | printk(MYIOC_s_WARN_FMT |
3610 | ": firmware downloadboot failure (%d)!\n", count); | 3664 | "firmware downloadboot failure (%d)!\n", ioc->name, count); |
3611 | } | 3665 | } |
3612 | 3666 | ||
3613 | } else { | 3667 | } else { |
@@ -3750,8 +3804,8 @@ SendIocReset(MPT_ADAPTER *ioc, u8 reset_type, int sleepFlag) | |||
3750 | if (sleepFlag != CAN_SLEEP) | 3804 | if (sleepFlag != CAN_SLEEP) |
3751 | count *= 10; | 3805 | count *= 10; |
3752 | 3806 | ||
3753 | printk(KERN_ERR MYNAM ": %s: ERROR - Wait IOC_READY state timeout(%d)!\n", | 3807 | printk(MYIOC_s_ERR_FMT "Wait IOC_READY state timeout(%d)!\n", |
3754 | ioc->name, (int)((count+5)/HZ)); | 3808 | ioc->name, (int)((count+5)/HZ)); |
3755 | return -ETIME; | 3809 | return -ETIME; |
3756 | } | 3810 | } |
3757 | 3811 | ||
@@ -4144,7 +4198,7 @@ mpt_handshake_req_reply_wait(MPT_ADAPTER *ioc, int reqBytes, u32 *req, | |||
4144 | } | 4198 | } |
4145 | 4199 | ||
4146 | dhsprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Handshake request frame (@%p) header\n", ioc->name, req)); | 4200 | dhsprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Handshake request frame (@%p) header\n", ioc->name, req)); |
4147 | DBG_DUMP_REQUEST_FRAME_HDR(ioc, (u32 *)req) | 4201 | DBG_DUMP_REQUEST_FRAME_HDR(ioc, (u32 *)req); |
4148 | 4202 | ||
4149 | dhsprintk(ioc, printk(MYIOC_s_DEBUG_FMT "HandShake request post done, WaitCnt=%d%s\n", | 4203 | dhsprintk(ioc, printk(MYIOC_s_DEBUG_FMT "HandShake request post done, WaitCnt=%d%s\n", |
4150 | ioc->name, t, failcnt ? " - MISSING DOORBELL ACK!" : "")); | 4204 | ioc->name, t, failcnt ? " - MISSING DOORBELL ACK!" : "")); |
@@ -4349,7 +4403,7 @@ WaitForDoorbellReply(MPT_ADAPTER *ioc, int howlong, int sleepFlag) | |||
4349 | #endif | 4403 | #endif |
4350 | 4404 | ||
4351 | dhsprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Got Handshake reply:\n", ioc->name)); | 4405 | dhsprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Got Handshake reply:\n", ioc->name)); |
4352 | DBG_DUMP_REPLY_FRAME(ioc, (u32 *)mptReply) | 4406 | DBG_DUMP_REPLY_FRAME(ioc, (u32 *)mptReply); |
4353 | 4407 | ||
4354 | dhsprintk(ioc, printk(MYIOC_s_DEBUG_FMT "WaitForDoorbell REPLY WaitCnt=%d (sz=%d)\n", | 4408 | dhsprintk(ioc, printk(MYIOC_s_DEBUG_FMT "WaitForDoorbell REPLY WaitCnt=%d (sz=%d)\n", |
4355 | ioc->name, t, u16cnt/2)); | 4409 | ioc->name, t, u16cnt/2)); |
@@ -4824,8 +4878,8 @@ mpt_GetScsiPortSettings(MPT_ADAPTER *ioc, int portnum) | |||
4824 | 4878 | ||
4825 | if ( (pPP0->Capabilities & MPI_SCSIPORTPAGE0_CAP_QAS) == 0 ) { | 4879 | if ( (pPP0->Capabilities & MPI_SCSIPORTPAGE0_CAP_QAS) == 0 ) { |
4826 | ioc->spi_data.noQas |= MPT_TARGET_NO_NEGO_QAS; | 4880 | ioc->spi_data.noQas |= MPT_TARGET_NO_NEGO_QAS; |
4827 | ddvprintk(ioc, printk(KERN_INFO MYNAM | 4881 | ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT |
4828 | " :%s noQas due to Capabilities=%x\n", | 4882 | "noQas due to Capabilities=%x\n", |
4829 | ioc->name, pPP0->Capabilities)); | 4883 | ioc->name, pPP0->Capabilities)); |
4830 | } | 4884 | } |
4831 | ioc->spi_data.maxBusWidth = pPP0->Capabilities & MPI_SCSIPORTPAGE0_CAP_WIDE ? 1 : 0; | 4885 | ioc->spi_data.maxBusWidth = pPP0->Capabilities & MPI_SCSIPORTPAGE0_CAP_WIDE ? 1 : 0; |
@@ -4888,6 +4942,38 @@ mpt_GetScsiPortSettings(MPT_ADAPTER *ioc, int portnum) | |||
4888 | /* Nvram data is left with INVALID mark | 4942 | /* Nvram data is left with INVALID mark |
4889 | */ | 4943 | */ |
4890 | rc = 1; | 4944 | rc = 1; |
4945 | } else if (ioc->pcidev->vendor == PCI_VENDOR_ID_ATTO) { | ||
4946 | |||
4947 | /* This is an ATTO adapter, read Page2 accordingly | ||
4948 | */ | ||
4949 | ATTO_SCSIPortPage2_t *pPP2 = (ATTO_SCSIPortPage2_t *) pbuf; | ||
4950 | ATTODeviceInfo_t *pdevice = NULL; | ||
4951 | u16 ATTOFlags; | ||
4952 | |||
4953 | /* Save the Port Page 2 data | ||
4954 | * (reformat into a 32bit quantity) | ||
4955 | */ | ||
4956 | for (ii=0; ii < MPT_MAX_SCSI_DEVICES; ii++) { | ||
4957 | pdevice = &pPP2->DeviceSettings[ii]; | ||
4958 | ATTOFlags = le16_to_cpu(pdevice->ATTOFlags); | ||
4959 | data = 0; | ||
4960 | |||
4961 | /* Translate ATTO device flags to LSI format | ||
4962 | */ | ||
4963 | if (ATTOFlags & ATTOFLAG_DISC) | ||
4964 | data |= (MPI_SCSIPORTPAGE2_DEVICE_DISCONNECT_ENABLE); | ||
4965 | if (ATTOFlags & ATTOFLAG_ID_ENB) | ||
4966 | data |= (MPI_SCSIPORTPAGE2_DEVICE_ID_SCAN_ENABLE); | ||
4967 | if (ATTOFlags & ATTOFLAG_LUN_ENB) | ||
4968 | data |= (MPI_SCSIPORTPAGE2_DEVICE_LUN_SCAN_ENABLE); | ||
4969 | if (ATTOFlags & ATTOFLAG_TAGGED) | ||
4970 | data |= (MPI_SCSIPORTPAGE2_DEVICE_TAG_QUEUE_ENABLE); | ||
4971 | if (!(ATTOFlags & ATTOFLAG_WIDE_ENB)) | ||
4972 | data |= (MPI_SCSIPORTPAGE2_DEVICE_WIDE_DISABLE); | ||
4973 | |||
4974 | data = (data << 16) | (pdevice->Period << 8) | 10; | ||
4975 | ioc->spi_data.nvram[ii] = data; | ||
4976 | } | ||
4891 | } else { | 4977 | } else { |
4892 | SCSIPortPage2_t *pPP2 = (SCSIPortPage2_t *) pbuf; | 4978 | SCSIPortPage2_t *pPP2 = (SCSIPortPage2_t *) pbuf; |
4893 | MpiDeviceInfo_t *pdevice = NULL; | 4979 | MpiDeviceInfo_t *pdevice = NULL; |
@@ -5701,10 +5787,10 @@ mpt_ioc_reset(MPT_ADAPTER *ioc, int reset_phase) | |||
5701 | CONFIGPARMS *pCfg; | 5787 | CONFIGPARMS *pCfg; |
5702 | unsigned long flags; | 5788 | unsigned long flags; |
5703 | 5789 | ||
5704 | dprintk(ioc, printk(KERN_DEBUG MYNAM | 5790 | dprintk(ioc, printk(MYIOC_s_DEBUG_FMT |
5705 | ": IOC %s_reset routed to MPT base driver!\n", | 5791 | ": IOC %s_reset routed to MPT base driver!\n", |
5706 | reset_phase==MPT_IOC_SETUP_RESET ? "setup" : ( | 5792 | ioc->name, reset_phase==MPT_IOC_SETUP_RESET ? "setup" : ( |
5707 | reset_phase==MPT_IOC_PRE_RESET ? "pre" : "post"))); | 5793 | reset_phase==MPT_IOC_PRE_RESET ? "pre" : "post"))); |
5708 | 5794 | ||
5709 | if (reset_phase == MPT_IOC_SETUP_RESET) { | 5795 | if (reset_phase == MPT_IOC_SETUP_RESET) { |
5710 | ; | 5796 | ; |
@@ -5843,7 +5929,7 @@ procmpt_summary_read(char *buf, char **start, off_t offset, int request, int *eo | |||
5843 | static int | 5929 | static int |
5844 | procmpt_version_read(char *buf, char **start, off_t offset, int request, int *eof, void *data) | 5930 | procmpt_version_read(char *buf, char **start, off_t offset, int request, int *eof, void *data) |
5845 | { | 5931 | { |
5846 | int ii; | 5932 | u8 cb_idx; |
5847 | int scsi, fc, sas, lan, ctl, targ, dmp; | 5933 | int scsi, fc, sas, lan, ctl, targ, dmp; |
5848 | char *drvname; | 5934 | char *drvname; |
5849 | int len; | 5935 | int len; |
@@ -5852,10 +5938,10 @@ procmpt_version_read(char *buf, char **start, off_t offset, int request, int *eo | |||
5852 | len += sprintf(buf+len, " Fusion MPT base driver\n"); | 5938 | len += sprintf(buf+len, " Fusion MPT base driver\n"); |
5853 | 5939 | ||
5854 | scsi = fc = sas = lan = ctl = targ = dmp = 0; | 5940 | scsi = fc = sas = lan = ctl = targ = dmp = 0; |
5855 | for (ii=MPT_MAX_PROTOCOL_DRIVERS-1; ii; ii--) { | 5941 | for (cb_idx = MPT_MAX_PROTOCOL_DRIVERS-1; cb_idx; cb_idx--) { |
5856 | drvname = NULL; | 5942 | drvname = NULL; |
5857 | if (MptCallbacks[ii]) { | 5943 | if (MptCallbacks[cb_idx]) { |
5858 | switch (MptDriverClass[ii]) { | 5944 | switch (MptDriverClass[cb_idx]) { |
5859 | case MPTSPI_DRIVER: | 5945 | case MPTSPI_DRIVER: |
5860 | if (!scsi++) drvname = "SPI host"; | 5946 | if (!scsi++) drvname = "SPI host"; |
5861 | break; | 5947 | break; |
@@ -6099,26 +6185,25 @@ mpt_HardResetHandler(MPT_ADAPTER *ioc, int sleepFlag) | |||
6099 | * For all other protocol drivers, this is a no-op. | 6185 | * For all other protocol drivers, this is a no-op. |
6100 | */ | 6186 | */ |
6101 | { | 6187 | { |
6102 | int ii; | 6188 | u8 cb_idx; |
6103 | int r = 0; | 6189 | int r = 0; |
6104 | 6190 | ||
6105 | for (ii=MPT_MAX_PROTOCOL_DRIVERS-1; ii; ii--) { | 6191 | for (cb_idx = MPT_MAX_PROTOCOL_DRIVERS-1; cb_idx; cb_idx--) { |
6106 | if (MptResetHandlers[ii]) { | 6192 | if (MptResetHandlers[cb_idx]) { |
6107 | dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Calling IOC reset_setup handler #%d\n", | 6193 | dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Calling IOC reset_setup handler #%d\n", |
6108 | ioc->name, ii)); | 6194 | ioc->name, cb_idx)); |
6109 | r += mpt_signal_reset(ii, ioc, MPT_IOC_SETUP_RESET); | 6195 | r += mpt_signal_reset(cb_idx, ioc, MPT_IOC_SETUP_RESET); |
6110 | if (ioc->alt_ioc) { | 6196 | if (ioc->alt_ioc) { |
6111 | dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Calling alt-%s setup reset handler #%d\n", | 6197 | dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Calling alt-%s setup reset handler #%d\n", |
6112 | ioc->name, ioc->alt_ioc->name, ii)); | 6198 | ioc->name, ioc->alt_ioc->name, cb_idx)); |
6113 | r += mpt_signal_reset(ii, ioc->alt_ioc, MPT_IOC_SETUP_RESET); | 6199 | r += mpt_signal_reset(cb_idx, ioc->alt_ioc, MPT_IOC_SETUP_RESET); |
6114 | } | 6200 | } |
6115 | } | 6201 | } |
6116 | } | 6202 | } |
6117 | } | 6203 | } |
6118 | 6204 | ||
6119 | if ((rc = mpt_do_ioc_recovery(ioc, MPT_HOSTEVENT_IOC_RECOVER, sleepFlag)) != 0) { | 6205 | if ((rc = mpt_do_ioc_recovery(ioc, MPT_HOSTEVENT_IOC_RECOVER, sleepFlag)) != 0) { |
6120 | printk(KERN_WARNING MYNAM ": WARNING - (%d) Cannot recover %s\n", | 6206 | printk(MYIOC_s_WARN_FMT "Cannot recover rc = %d!\n", ioc->name, rc); |
6121 | rc, ioc->name); | ||
6122 | } | 6207 | } |
6123 | ioc->reload_fw = 0; | 6208 | ioc->reload_fw = 0; |
6124 | if (ioc->alt_ioc) | 6209 | if (ioc->alt_ioc) |
@@ -6515,6 +6600,7 @@ ProcessEventNotification(MPT_ADAPTER *ioc, EventNotificationReply_t *pEventReply | |||
6515 | u32 evData0 = 0; | 6600 | u32 evData0 = 0; |
6516 | // u32 evCtx; | 6601 | // u32 evCtx; |
6517 | int ii; | 6602 | int ii; |
6603 | u8 cb_idx; | ||
6518 | int r = 0; | 6604 | int r = 0; |
6519 | int handlers = 0; | 6605 | int handlers = 0; |
6520 | char evStr[EVENT_DESCR_STR_SZ]; | 6606 | char evStr[EVENT_DESCR_STR_SZ]; |
@@ -6537,12 +6623,12 @@ ProcessEventNotification(MPT_ADAPTER *ioc, EventNotificationReply_t *pEventReply | |||
6537 | evStr)); | 6623 | evStr)); |
6538 | 6624 | ||
6539 | #ifdef CONFIG_FUSION_LOGGING | 6625 | #ifdef CONFIG_FUSION_LOGGING |
6540 | devtverboseprintk(ioc, printk(KERN_DEBUG MYNAM | 6626 | devtverboseprintk(ioc, printk(MYIOC_s_DEBUG_FMT |
6541 | ": Event data:\n")); | 6627 | ": Event data:\n", ioc->name)); |
6542 | for (ii = 0; ii < evDataLen; ii++) | 6628 | for (ii = 0; ii < evDataLen; ii++) |
6543 | devtverboseprintk(ioc, printk(" %08x", | 6629 | devtverboseprintk(ioc, printk(" %08x", |
6544 | le32_to_cpu(pEventReply->Data[ii]))); | 6630 | le32_to_cpu(pEventReply->Data[ii]))); |
6545 | devtverboseprintk(ioc, printk(KERN_DEBUG "\n")); | 6631 | devtverboseprintk(ioc, printk("\n")); |
6546 | #endif | 6632 | #endif |
6547 | 6633 | ||
6548 | /* | 6634 | /* |
@@ -6595,11 +6681,11 @@ ProcessEventNotification(MPT_ADAPTER *ioc, EventNotificationReply_t *pEventReply | |||
6595 | /* | 6681 | /* |
6596 | * Call each currently registered protocol event handler. | 6682 | * Call each currently registered protocol event handler. |
6597 | */ | 6683 | */ |
6598 | for (ii=MPT_MAX_PROTOCOL_DRIVERS-1; ii; ii--) { | 6684 | for (cb_idx = MPT_MAX_PROTOCOL_DRIVERS-1; cb_idx; cb_idx--) { |
6599 | if (MptEvHandlers[ii]) { | 6685 | if (MptEvHandlers[cb_idx]) { |
6600 | devtverboseprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Routing Event to event handler #%d\n", | 6686 | devtverboseprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Routing Event to event handler #%d\n", |
6601 | ioc->name, ii)); | 6687 | ioc->name, cb_idx)); |
6602 | r += (*(MptEvHandlers[ii]))(ioc, pEventReply); | 6688 | r += (*(MptEvHandlers[cb_idx]))(ioc, pEventReply); |
6603 | handlers++; | 6689 | handlers++; |
6604 | } | 6690 | } |
6605 | } | 6691 | } |
@@ -7034,8 +7120,8 @@ mpt_iocstatus_info_config(MPT_ADAPTER *ioc, u32 ioc_status, MPT_FRAME_HDR *mf) | |||
7034 | if (!desc) | 7120 | if (!desc) |
7035 | return; | 7121 | return; |
7036 | 7122 | ||
7037 | printk(MYIOC_s_INFO_FMT "IOCStatus(0x%04X): %s: %s\n", | 7123 | dreplyprintk(ioc, printk(MYIOC_s_DEBUG_FMT "IOCStatus(0x%04X): %s: %s\n", |
7038 | ioc->name, ioc_status, desc, extend_desc); | 7124 | ioc->name, ioc_status, desc, extend_desc)); |
7039 | } | 7125 | } |
7040 | 7126 | ||
7041 | /** | 7127 | /** |
@@ -7261,7 +7347,8 @@ mpt_iocstatus_info(MPT_ADAPTER *ioc, u32 ioc_status, MPT_FRAME_HDR *mf) | |||
7261 | if (!desc) | 7347 | if (!desc) |
7262 | return; | 7348 | return; |
7263 | 7349 | ||
7264 | printk(MYIOC_s_INFO_FMT "IOCStatus(0x%04X): %s\n", ioc->name, status, desc); | 7350 | dreplyprintk(ioc, printk(MYIOC_s_DEBUG_FMT "IOCStatus(0x%04X): %s\n", |
7351 | ioc->name, status, desc)); | ||
7265 | } | 7352 | } |
7266 | 7353 | ||
7267 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | 7354 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ |
@@ -7283,14 +7370,13 @@ EXPORT_SYMBOL(mpt_device_driver_register); | |||
7283 | EXPORT_SYMBOL(mpt_device_driver_deregister); | 7370 | EXPORT_SYMBOL(mpt_device_driver_deregister); |
7284 | EXPORT_SYMBOL(mpt_get_msg_frame); | 7371 | EXPORT_SYMBOL(mpt_get_msg_frame); |
7285 | EXPORT_SYMBOL(mpt_put_msg_frame); | 7372 | EXPORT_SYMBOL(mpt_put_msg_frame); |
7373 | EXPORT_SYMBOL(mpt_put_msg_frame_hi_pri); | ||
7286 | EXPORT_SYMBOL(mpt_free_msg_frame); | 7374 | EXPORT_SYMBOL(mpt_free_msg_frame); |
7287 | EXPORT_SYMBOL(mpt_add_sge); | 7375 | EXPORT_SYMBOL(mpt_add_sge); |
7288 | EXPORT_SYMBOL(mpt_send_handshake_request); | 7376 | EXPORT_SYMBOL(mpt_send_handshake_request); |
7289 | EXPORT_SYMBOL(mpt_verify_adapter); | 7377 | EXPORT_SYMBOL(mpt_verify_adapter); |
7290 | EXPORT_SYMBOL(mpt_GetIocState); | 7378 | EXPORT_SYMBOL(mpt_GetIocState); |
7291 | EXPORT_SYMBOL(mpt_print_ioc_summary); | 7379 | EXPORT_SYMBOL(mpt_print_ioc_summary); |
7292 | EXPORT_SYMBOL(mpt_lan_index); | ||
7293 | EXPORT_SYMBOL(mpt_stm_index); | ||
7294 | EXPORT_SYMBOL(mpt_HardResetHandler); | 7380 | EXPORT_SYMBOL(mpt_HardResetHandler); |
7295 | EXPORT_SYMBOL(mpt_config); | 7381 | EXPORT_SYMBOL(mpt_config); |
7296 | EXPORT_SYMBOL(mpt_findImVolumes); | 7382 | EXPORT_SYMBOL(mpt_findImVolumes); |
@@ -7308,16 +7394,16 @@ EXPORT_SYMBOL(mpt_raid_phys_disk_pg0); | |||
7308 | static int __init | 7394 | static int __init |
7309 | fusion_init(void) | 7395 | fusion_init(void) |
7310 | { | 7396 | { |
7311 | int i; | 7397 | u8 cb_idx; |
7312 | 7398 | ||
7313 | show_mptmod_ver(my_NAME, my_VERSION); | 7399 | show_mptmod_ver(my_NAME, my_VERSION); |
7314 | printk(KERN_INFO COPYRIGHT "\n"); | 7400 | printk(KERN_INFO COPYRIGHT "\n"); |
7315 | 7401 | ||
7316 | for (i = 0; i < MPT_MAX_PROTOCOL_DRIVERS; i++) { | 7402 | for (cb_idx = 0; cb_idx < MPT_MAX_PROTOCOL_DRIVERS; cb_idx++) { |
7317 | MptCallbacks[i] = NULL; | 7403 | MptCallbacks[cb_idx] = NULL; |
7318 | MptDriverClass[i] = MPTUNKNOWN_DRIVER; | 7404 | MptDriverClass[cb_idx] = MPTUNKNOWN_DRIVER; |
7319 | MptEvHandlers[i] = NULL; | 7405 | MptEvHandlers[cb_idx] = NULL; |
7320 | MptResetHandlers[i] = NULL; | 7406 | MptResetHandlers[cb_idx] = NULL; |
7321 | } | 7407 | } |
7322 | 7408 | ||
7323 | /* Register ourselves (mptbase) in order to facilitate | 7409 | /* Register ourselves (mptbase) in order to facilitate |
diff --git a/drivers/message/fusion/mptbase.h b/drivers/message/fusion/mptbase.h index 15ff22645844..d7682e083f59 100644 --- a/drivers/message/fusion/mptbase.h +++ b/drivers/message/fusion/mptbase.h | |||
@@ -3,9 +3,9 @@ | |||
3 | * High performance SCSI + LAN / Fibre Channel device drivers. | 3 | * High performance SCSI + LAN / Fibre Channel device drivers. |
4 | * For use with PCI chip/adapter(s): | 4 | * For use with PCI chip/adapter(s): |
5 | * LSIFC9xx/LSI409xx Fibre Channel | 5 | * LSIFC9xx/LSI409xx Fibre Channel |
6 | * running LSI Logic Fusion MPT (Message Passing Technology) firmware. | 6 | * running LSI Fusion MPT (Message Passing Technology) firmware. |
7 | * | 7 | * |
8 | * Copyright (c) 1999-2007 LSI Logic Corporation | 8 | * Copyright (c) 1999-2007 LSI Corporation |
9 | * (mailto:DL-MPTFusionLinux@lsi.com) | 9 | * (mailto:DL-MPTFusionLinux@lsi.com) |
10 | * | 10 | * |
11 | */ | 11 | */ |
@@ -68,15 +68,15 @@ | |||
68 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | 68 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ |
69 | 69 | ||
70 | #ifndef MODULEAUTHOR | 70 | #ifndef MODULEAUTHOR |
71 | #define MODULEAUTHOR "LSI Logic Corporation" | 71 | #define MODULEAUTHOR "LSI Corporation" |
72 | #endif | 72 | #endif |
73 | 73 | ||
74 | #ifndef COPYRIGHT | 74 | #ifndef COPYRIGHT |
75 | #define COPYRIGHT "Copyright (c) 1999-2007 " MODULEAUTHOR | 75 | #define COPYRIGHT "Copyright (c) 1999-2007 " MODULEAUTHOR |
76 | #endif | 76 | #endif |
77 | 77 | ||
78 | #define MPT_LINUX_VERSION_COMMON "3.04.05" | 78 | #define MPT_LINUX_VERSION_COMMON "3.04.06" |
79 | #define MPT_LINUX_PACKAGE_NAME "@(#)mptlinux-3.04.05" | 79 | #define MPT_LINUX_PACKAGE_NAME "@(#)mptlinux-3.04.06" |
80 | #define WHAT_MAGIC_STRING "@" "(" "#" ")" | 80 | #define WHAT_MAGIC_STRING "@" "(" "#" ")" |
81 | 81 | ||
82 | #define show_mptmod_ver(s,ver) \ | 82 | #define show_mptmod_ver(s,ver) \ |
@@ -186,6 +186,7 @@ | |||
186 | * MPT drivers. NOTE: Users of these macro defs must | 186 | * MPT drivers. NOTE: Users of these macro defs must |
187 | * themselves define their own MYNAM. | 187 | * themselves define their own MYNAM. |
188 | */ | 188 | */ |
189 | #define MYIOC_s_FMT MYNAM ": %s: " | ||
189 | #define MYIOC_s_DEBUG_FMT KERN_DEBUG MYNAM ": %s: " | 190 | #define MYIOC_s_DEBUG_FMT KERN_DEBUG MYNAM ": %s: " |
190 | #define MYIOC_s_INFO_FMT KERN_INFO MYNAM ": %s: " | 191 | #define MYIOC_s_INFO_FMT KERN_INFO MYNAM ": %s: " |
191 | #define MYIOC_s_NOTE_FMT KERN_NOTICE MYNAM ": %s: " | 192 | #define MYIOC_s_NOTE_FMT KERN_NOTICE MYNAM ": %s: " |
@@ -194,6 +195,35 @@ | |||
194 | 195 | ||
195 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | 196 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ |
196 | /* | 197 | /* |
198 | * ATTO UL4D associated structures and defines | ||
199 | */ | ||
200 | #define ATTOFLAG_DISC 0x0001 | ||
201 | #define ATTOFLAG_TAGGED 0x0002 | ||
202 | #define ATTOFLAG_WIDE_ENB 0x0008 | ||
203 | #define ATTOFLAG_ID_ENB 0x0010 | ||
204 | #define ATTOFLAG_LUN_ENB 0x0060 | ||
205 | |||
206 | typedef struct _ATTO_DEVICE_INFO | ||
207 | { | ||
208 | u8 Offset; /* 00h */ | ||
209 | u8 Period; /* 01h */ | ||
210 | u16 ATTOFlags; /* 02h */ | ||
211 | } ATTO_DEVICE_INFO, MPI_POINTER PTR_ATTO_DEVICE_INFO, | ||
212 | ATTODeviceInfo_t, MPI_POINTER pATTODeviceInfo_t; | ||
213 | |||
214 | typedef struct _ATTO_CONFIG_PAGE_SCSI_PORT_2 | ||
215 | { | ||
216 | CONFIG_PAGE_HEADER Header; /* 00h */ | ||
217 | u16 PortFlags; /* 04h */ | ||
218 | u16 Unused1; /* 06h */ | ||
219 | u32 Unused2; /* 08h */ | ||
220 | ATTO_DEVICE_INFO DeviceSettings[16]; /* 0Ch */ | ||
221 | } fATTO_CONFIG_PAGE_SCSI_PORT_2, MPI_POINTER PTR_ATTO_CONFIG_PAGE_SCSI_PORT_2, | ||
222 | ATTO_SCSIPortPage2_t, MPI_POINTER pATTO_SCSIPortPage2_t; | ||
223 | |||
224 | |||
225 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | ||
226 | /* | ||
197 | * MPT protocol driver defs... | 227 | * MPT protocol driver defs... |
198 | */ | 228 | */ |
199 | typedef enum { | 229 | typedef enum { |
@@ -307,7 +337,8 @@ typedef struct _SYSIF_REGS | |||
307 | u32 Reserved2[2]; /* 38-3F reserved for future use */ | 337 | u32 Reserved2[2]; /* 38-3F reserved for future use */ |
308 | u32 RequestFifo; /* 40 Request Post/Free FIFO */ | 338 | u32 RequestFifo; /* 40 Request Post/Free FIFO */ |
309 | u32 ReplyFifo; /* 44 Reply Post/Free FIFO */ | 339 | u32 ReplyFifo; /* 44 Reply Post/Free FIFO */ |
310 | u32 Reserved3[2]; /* 48-4F reserved for future use */ | 340 | u32 RequestHiPriFifo; /* 48 Hi Priority Request FIFO */ |
341 | u32 Reserved3; /* 4C-4F reserved for future use */ | ||
311 | u32 HostIndex; /* 50 Host Index register */ | 342 | u32 HostIndex; /* 50 Host Index register */ |
312 | u32 Reserved4[15]; /* 54-8F */ | 343 | u32 Reserved4[15]; /* 54-8F */ |
313 | u32 Fubar; /* 90 For Fubar usage */ | 344 | u32 Fubar; /* 90 For Fubar usage */ |
@@ -649,9 +680,9 @@ typedef struct _MPT_ADAPTER | |||
649 | u8 reload_fw; /* Force a FW Reload on next reset */ | 680 | u8 reload_fw; /* Force a FW Reload on next reset */ |
650 | u8 NBShiftFactor; /* NB Shift Factor based on Block Size (Facts) */ | 681 | u8 NBShiftFactor; /* NB Shift Factor based on Block Size (Facts) */ |
651 | u8 pad1[4]; | 682 | u8 pad1[4]; |
652 | int DoneCtx; | 683 | u8 DoneCtx; |
653 | int TaskCtx; | 684 | u8 TaskCtx; |
654 | int InternalCtx; | 685 | u8 InternalCtx; |
655 | spinlock_t initializing_hba_lock; | 686 | spinlock_t initializing_hba_lock; |
656 | int initializing_hba_lock_flag; | 687 | int initializing_hba_lock_flag; |
657 | struct list_head list; | 688 | struct list_head list; |
@@ -668,10 +699,14 @@ typedef struct _MPT_ADAPTER | |||
668 | 699 | ||
669 | struct work_struct fc_setup_reset_work; | 700 | struct work_struct fc_setup_reset_work; |
670 | struct list_head fc_rports; | 701 | struct list_head fc_rports; |
702 | struct work_struct fc_lsc_work; | ||
703 | u8 fc_link_speed[2]; | ||
671 | spinlock_t fc_rescan_work_lock; | 704 | spinlock_t fc_rescan_work_lock; |
672 | struct work_struct fc_rescan_work; | 705 | struct work_struct fc_rescan_work; |
673 | char fc_rescan_work_q_name[KOBJ_NAME_LEN]; | 706 | char fc_rescan_work_q_name[KOBJ_NAME_LEN]; |
674 | struct workqueue_struct *fc_rescan_work_q; | 707 | struct workqueue_struct *fc_rescan_work_q; |
708 | struct scsi_cmnd **ScsiLookup; | ||
709 | spinlock_t scsi_lookup_lock; | ||
675 | } MPT_ADAPTER; | 710 | } MPT_ADAPTER; |
676 | 711 | ||
677 | /* | 712 | /* |
@@ -785,7 +820,6 @@ typedef struct _MPT_SCSI_HOST { | |||
785 | MPT_ADAPTER *ioc; | 820 | MPT_ADAPTER *ioc; |
786 | int port; | 821 | int port; |
787 | u32 pad0; | 822 | u32 pad0; |
788 | struct scsi_cmnd **ScsiLookup; | ||
789 | MPT_LOCAL_REPLY *pLocal; /* used for internal commands */ | 823 | MPT_LOCAL_REPLY *pLocal; /* used for internal commands */ |
790 | struct timer_list timer; | 824 | struct timer_list timer; |
791 | /* Pool of memory for holding SCpnts before doing | 825 | /* Pool of memory for holding SCpnts before doing |
@@ -853,20 +887,21 @@ extern void mpt_detach(struct pci_dev *pdev); | |||
853 | extern int mpt_suspend(struct pci_dev *pdev, pm_message_t state); | 887 | extern int mpt_suspend(struct pci_dev *pdev, pm_message_t state); |
854 | extern int mpt_resume(struct pci_dev *pdev); | 888 | extern int mpt_resume(struct pci_dev *pdev); |
855 | #endif | 889 | #endif |
856 | extern int mpt_register(MPT_CALLBACK cbfunc, MPT_DRIVER_CLASS dclass); | 890 | extern u8 mpt_register(MPT_CALLBACK cbfunc, MPT_DRIVER_CLASS dclass); |
857 | extern void mpt_deregister(int cb_idx); | 891 | extern void mpt_deregister(u8 cb_idx); |
858 | extern int mpt_event_register(int cb_idx, MPT_EVHANDLER ev_cbfunc); | 892 | extern int mpt_event_register(u8 cb_idx, MPT_EVHANDLER ev_cbfunc); |
859 | extern void mpt_event_deregister(int cb_idx); | 893 | extern void mpt_event_deregister(u8 cb_idx); |
860 | extern int mpt_reset_register(int cb_idx, MPT_RESETHANDLER reset_func); | 894 | extern int mpt_reset_register(u8 cb_idx, MPT_RESETHANDLER reset_func); |
861 | extern void mpt_reset_deregister(int cb_idx); | 895 | extern void mpt_reset_deregister(u8 cb_idx); |
862 | extern int mpt_device_driver_register(struct mpt_pci_driver * dd_cbfunc, int cb_idx); | 896 | extern int mpt_device_driver_register(struct mpt_pci_driver * dd_cbfunc, u8 cb_idx); |
863 | extern void mpt_device_driver_deregister(int cb_idx); | 897 | extern void mpt_device_driver_deregister(u8 cb_idx); |
864 | extern MPT_FRAME_HDR *mpt_get_msg_frame(int handle, MPT_ADAPTER *ioc); | 898 | extern MPT_FRAME_HDR *mpt_get_msg_frame(u8 cb_idx, MPT_ADAPTER *ioc); |
865 | extern void mpt_free_msg_frame(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf); | 899 | extern void mpt_free_msg_frame(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf); |
866 | extern void mpt_put_msg_frame(int handle, MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf); | 900 | extern void mpt_put_msg_frame(u8 cb_idx, MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf); |
901 | extern void mpt_put_msg_frame_hi_pri(u8 cb_idx, MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf); | ||
867 | extern void mpt_add_sge(char *pAddr, u32 flagslength, dma_addr_t dma_addr); | 902 | extern void mpt_add_sge(char *pAddr, u32 flagslength, dma_addr_t dma_addr); |
868 | 903 | ||
869 | extern int mpt_send_handshake_request(int handle, MPT_ADAPTER *ioc, int reqBytes, u32 *req, int sleepFlag); | 904 | extern int mpt_send_handshake_request(u8 cb_idx, MPT_ADAPTER *ioc, int reqBytes, u32 *req, int sleepFlag); |
870 | extern int mpt_verify_adapter(int iocid, MPT_ADAPTER **iocpp); | 905 | extern int mpt_verify_adapter(int iocid, MPT_ADAPTER **iocpp); |
871 | extern u32 mpt_GetIocState(MPT_ADAPTER *ioc, int cooked); | 906 | extern u32 mpt_GetIocState(MPT_ADAPTER *ioc, int cooked); |
872 | extern void mpt_print_ioc_summary(MPT_ADAPTER *ioc, char *buf, int *size, int len, int showlan); | 907 | extern void mpt_print_ioc_summary(MPT_ADAPTER *ioc, char *buf, int *size, int len, int showlan); |
@@ -884,9 +919,6 @@ extern int mpt_raid_phys_disk_pg0(MPT_ADAPTER *ioc, u8 phys_disk_num, pRaidPhys | |||
884 | extern struct list_head ioc_list; | 919 | extern struct list_head ioc_list; |
885 | extern struct proc_dir_entry *mpt_proc_root_dir; | 920 | extern struct proc_dir_entry *mpt_proc_root_dir; |
886 | 921 | ||
887 | extern int mpt_lan_index; /* needed by mptlan.c */ | ||
888 | extern int mpt_stm_index; /* needed by mptstm.c */ | ||
889 | |||
890 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | 922 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ |
891 | #endif /* } __KERNEL__ */ | 923 | #endif /* } __KERNEL__ */ |
892 | 924 | ||
diff --git a/drivers/message/fusion/mptctl.c b/drivers/message/fusion/mptctl.c index 89695e705bdc..6029509702d3 100644 --- a/drivers/message/fusion/mptctl.c +++ b/drivers/message/fusion/mptctl.c | |||
@@ -1,10 +1,10 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/message/fusion/mptctl.c | 2 | * linux/drivers/message/fusion/mptctl.c |
3 | * mpt Ioctl driver. | 3 | * mpt Ioctl driver. |
4 | * For use with LSI Logic PCI chip/adapters | 4 | * For use with LSI PCI chip/adapters |
5 | * running LSI Logic Fusion MPT (Message Passing Technology) firmware. | 5 | * running LSI Fusion MPT (Message Passing Technology) firmware. |
6 | * | 6 | * |
7 | * Copyright (c) 1999-2007 LSI Logic Corporation | 7 | * Copyright (c) 1999-2007 LSI Corporation |
8 | * (mailto:DL-MPTFusionLinux@lsi.com) | 8 | * (mailto:DL-MPTFusionLinux@lsi.com) |
9 | * | 9 | * |
10 | */ | 10 | */ |
@@ -66,8 +66,8 @@ | |||
66 | #include <scsi/scsi_host.h> | 66 | #include <scsi/scsi_host.h> |
67 | #include <scsi/scsi_tcq.h> | 67 | #include <scsi/scsi_tcq.h> |
68 | 68 | ||
69 | #define COPYRIGHT "Copyright (c) 1999-2007 LSI Logic Corporation" | 69 | #define COPYRIGHT "Copyright (c) 1999-2007 LSI Corporation" |
70 | #define MODULEAUTHOR "LSI Logic Corporation" | 70 | #define MODULEAUTHOR "LSI Corporation" |
71 | #include "mptbase.h" | 71 | #include "mptbase.h" |
72 | #include "mptctl.h" | 72 | #include "mptctl.h" |
73 | 73 | ||
@@ -83,7 +83,7 @@ MODULE_VERSION(my_VERSION); | |||
83 | 83 | ||
84 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | 84 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ |
85 | 85 | ||
86 | static int mptctl_id = -1; | 86 | static u8 mptctl_id = MPT_MAX_PROTOCOL_DRIVERS; |
87 | 87 | ||
88 | static DECLARE_WAIT_QUEUE_HEAD ( mptctl_wait ); | 88 | static DECLARE_WAIT_QUEUE_HEAD ( mptctl_wait ); |
89 | 89 | ||
@@ -181,7 +181,6 @@ static inline int | |||
181 | mptctl_syscall_down(MPT_ADAPTER *ioc, int nonblock) | 181 | mptctl_syscall_down(MPT_ADAPTER *ioc, int nonblock) |
182 | { | 182 | { |
183 | int rc = 0; | 183 | int rc = 0; |
184 | // dctlprintk(ioc, printk(KERN_DEBUG MYNAM "::mptctl_syscall_down(%p,%d) called\n", ioc, nonblock)); | ||
185 | 184 | ||
186 | if (nonblock) { | 185 | if (nonblock) { |
187 | if (!mutex_trylock(&ioc->ioctl->ioctl_mutex)) | 186 | if (!mutex_trylock(&ioc->ioctl->ioctl_mutex)) |
@@ -190,7 +189,6 @@ mptctl_syscall_down(MPT_ADAPTER *ioc, int nonblock) | |||
190 | if (mutex_lock_interruptible(&ioc->ioctl->ioctl_mutex)) | 189 | if (mutex_lock_interruptible(&ioc->ioctl->ioctl_mutex)) |
191 | rc = -ERESTARTSYS; | 190 | rc = -ERESTARTSYS; |
192 | } | 191 | } |
193 | // dctlprintk(ioc, printk(KERN_DEBUG MYNAM "::mptctl_syscall_down return %d\n", rc)); | ||
194 | return rc; | 192 | return rc; |
195 | } | 193 | } |
196 | 194 | ||
@@ -342,7 +340,7 @@ static int mptctl_bus_reset(MPT_IOCTL *ioctl) | |||
342 | SCSITaskMgmt_t *pScsiTm; | 340 | SCSITaskMgmt_t *pScsiTm; |
343 | MPT_SCSI_HOST *hd; | 341 | MPT_SCSI_HOST *hd; |
344 | int ii; | 342 | int ii; |
345 | int retval; | 343 | int retval=0; |
346 | 344 | ||
347 | 345 | ||
348 | ioctl->reset &= ~MPTCTL_RESET_OK; | 346 | ioctl->reset &= ~MPTCTL_RESET_OK; |
@@ -350,7 +348,7 @@ static int mptctl_bus_reset(MPT_IOCTL *ioctl) | |||
350 | if (ioctl->ioc->sh == NULL) | 348 | if (ioctl->ioc->sh == NULL) |
351 | return -EPERM; | 349 | return -EPERM; |
352 | 350 | ||
353 | hd = (MPT_SCSI_HOST *) ioctl->ioc->sh->hostdata; | 351 | hd = shost_priv(ioctl->ioc->sh); |
354 | if (hd == NULL) | 352 | if (hd == NULL) |
355 | return -EPERM; | 353 | return -EPERM; |
356 | 354 | ||
@@ -395,12 +393,19 @@ static int mptctl_bus_reset(MPT_IOCTL *ioctl) | |||
395 | DBG_DUMP_TM_REQUEST_FRAME(ioctl->ioc, (u32 *)mf); | 393 | DBG_DUMP_TM_REQUEST_FRAME(ioctl->ioc, (u32 *)mf); |
396 | 394 | ||
397 | ioctl->wait_done=0; | 395 | ioctl->wait_done=0; |
398 | if ((retval = mpt_send_handshake_request(mptctl_id, ioctl->ioc, | 396 | |
399 | sizeof(SCSITaskMgmt_t), (u32*)pScsiTm, CAN_SLEEP)) != 0) { | 397 | if ((ioctl->ioc->facts.IOCCapabilities & MPI_IOCFACTS_CAPABILITY_HIGH_PRI_Q) && |
400 | dfailprintk(ioctl->ioc, printk(MYIOC_s_ERR_FMT "_send_handshake FAILED!" | 398 | (ioctl->ioc->facts.MsgVersion >= MPI_VERSION_01_05)) |
401 | " (hd %p, ioc %p, mf %p) \n", hd->ioc->name, hd, | 399 | mpt_put_msg_frame_hi_pri(mptctl_id, ioctl->ioc, mf); |
402 | hd->ioc, mf)); | 400 | else { |
403 | goto mptctl_bus_reset_done; | 401 | retval = mpt_send_handshake_request(mptctl_id, ioctl->ioc, |
402 | sizeof(SCSITaskMgmt_t), (u32*)pScsiTm, CAN_SLEEP); | ||
403 | if (retval != 0) { | ||
404 | dfailprintk(ioctl->ioc, printk(MYIOC_s_ERR_FMT "_send_handshake FAILED!" | ||
405 | " (hd %p, ioc %p, mf %p) \n", hd->ioc->name, hd, | ||
406 | hd->ioc, mf)); | ||
407 | goto mptctl_bus_reset_done; | ||
408 | } | ||
404 | } | 409 | } |
405 | 410 | ||
406 | /* Now wait for the command to complete */ | 411 | /* Now wait for the command to complete */ |
@@ -444,7 +449,7 @@ mptctl_free_tm_flags(MPT_ADAPTER *ioc) | |||
444 | MPT_SCSI_HOST * hd; | 449 | MPT_SCSI_HOST * hd; |
445 | unsigned long flags; | 450 | unsigned long flags; |
446 | 451 | ||
447 | hd = (MPT_SCSI_HOST *) ioc->sh->hostdata; | 452 | hd = shost_priv(ioc->sh); |
448 | if (hd == NULL) | 453 | if (hd == NULL) |
449 | return; | 454 | return; |
450 | 455 | ||
@@ -468,7 +473,7 @@ static int | |||
468 | mptctl_ioc_reset(MPT_ADAPTER *ioc, int reset_phase) | 473 | mptctl_ioc_reset(MPT_ADAPTER *ioc, int reset_phase) |
469 | { | 474 | { |
470 | MPT_IOCTL *ioctl = ioc->ioctl; | 475 | MPT_IOCTL *ioctl = ioc->ioctl; |
471 | dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT ": IOC %s_reset routed to IOCTL driver!\n",ioc->name, | 476 | dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "IOC %s_reset routed to IOCTL driver!\n", ioc->name, |
472 | reset_phase==MPT_IOC_SETUP_RESET ? "setup" : ( | 477 | reset_phase==MPT_IOC_SETUP_RESET ? "setup" : ( |
473 | reset_phase==MPT_IOC_PRE_RESET ? "pre" : "post"))); | 478 | reset_phase==MPT_IOC_PRE_RESET ? "pre" : "post"))); |
474 | 479 | ||
@@ -574,7 +579,7 @@ __mptctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
574 | MPT_ADAPTER *iocp = NULL; | 579 | MPT_ADAPTER *iocp = NULL; |
575 | 580 | ||
576 | if (copy_from_user(&khdr, uhdr, sizeof(khdr))) { | 581 | if (copy_from_user(&khdr, uhdr, sizeof(khdr))) { |
577 | printk(KERN_ERR "%s::mptctl_ioctl() @%d - " | 582 | printk(KERN_ERR MYNAM "%s::mptctl_ioctl() @%d - " |
578 | "Unable to copy mpt_ioctl_header data @ %p\n", | 583 | "Unable to copy mpt_ioctl_header data @ %p\n", |
579 | __FILE__, __LINE__, uhdr); | 584 | __FILE__, __LINE__, uhdr); |
580 | return -EFAULT; | 585 | return -EFAULT; |
@@ -587,13 +592,13 @@ __mptctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
587 | iocnumX = khdr.iocnum & 0xFF; | 592 | iocnumX = khdr.iocnum & 0xFF; |
588 | if (((iocnum = mpt_verify_adapter(iocnumX, &iocp)) < 0) || | 593 | if (((iocnum = mpt_verify_adapter(iocnumX, &iocp)) < 0) || |
589 | (iocp == NULL)) { | 594 | (iocp == NULL)) { |
590 | printk(KERN_DEBUG "%s::mptctl_ioctl() @%d - ioc%d not found!\n", | 595 | printk(KERN_DEBUG MYNAM "%s::mptctl_ioctl() @%d - ioc%d not found!\n", |
591 | __FILE__, __LINE__, iocnumX); | 596 | __FILE__, __LINE__, iocnumX); |
592 | return -ENODEV; | 597 | return -ENODEV; |
593 | } | 598 | } |
594 | 599 | ||
595 | if (!iocp->active) { | 600 | if (!iocp->active) { |
596 | printk(KERN_DEBUG "%s::mptctl_ioctl() @%d - Controller disabled.\n", | 601 | printk(KERN_DEBUG MYNAM "%s::mptctl_ioctl() @%d - Controller disabled.\n", |
597 | __FILE__, __LINE__); | 602 | __FILE__, __LINE__); |
598 | return -EFAULT; | 603 | return -EFAULT; |
599 | } | 604 | } |
@@ -660,14 +665,14 @@ static int mptctl_do_reset(unsigned long arg) | |||
660 | MPT_ADAPTER *iocp; | 665 | MPT_ADAPTER *iocp; |
661 | 666 | ||
662 | if (copy_from_user(&krinfo, urinfo, sizeof(struct mpt_ioctl_diag_reset))) { | 667 | if (copy_from_user(&krinfo, urinfo, sizeof(struct mpt_ioctl_diag_reset))) { |
663 | printk(KERN_ERR "%s@%d::mptctl_do_reset - " | 668 | printk(KERN_ERR MYNAM "%s@%d::mptctl_do_reset - " |
664 | "Unable to copy mpt_ioctl_diag_reset struct @ %p\n", | 669 | "Unable to copy mpt_ioctl_diag_reset struct @ %p\n", |
665 | __FILE__, __LINE__, urinfo); | 670 | __FILE__, __LINE__, urinfo); |
666 | return -EFAULT; | 671 | return -EFAULT; |
667 | } | 672 | } |
668 | 673 | ||
669 | if (mpt_verify_adapter(krinfo.hdr.iocnum, &iocp) < 0) { | 674 | if (mpt_verify_adapter(krinfo.hdr.iocnum, &iocp) < 0) { |
670 | printk(KERN_DEBUG "%s@%d::mptctl_do_reset - ioc%d not found!\n", | 675 | printk(KERN_DEBUG MYNAM "%s@%d::mptctl_do_reset - ioc%d not found!\n", |
671 | __FILE__, __LINE__, krinfo.hdr.iocnum); | 676 | __FILE__, __LINE__, krinfo.hdr.iocnum); |
672 | return -ENODEV; /* (-6) No such device or address */ | 677 | return -ENODEV; /* (-6) No such device or address */ |
673 | } | 678 | } |
@@ -676,8 +681,8 @@ static int mptctl_do_reset(unsigned long arg) | |||
676 | iocp->name)); | 681 | iocp->name)); |
677 | 682 | ||
678 | if (mpt_HardResetHandler(iocp, CAN_SLEEP) != 0) { | 683 | if (mpt_HardResetHandler(iocp, CAN_SLEEP) != 0) { |
679 | printk (KERN_ERR "%s@%d::mptctl_do_reset - reset failed.\n", | 684 | printk (MYIOC_s_ERR_FMT "%s@%d::mptctl_do_reset - reset failed.\n", |
680 | __FILE__, __LINE__); | 685 | iocp->name, __FILE__, __LINE__); |
681 | return -1; | 686 | return -1; |
682 | } | 687 | } |
683 | 688 | ||
@@ -708,7 +713,7 @@ mptctl_fw_download(unsigned long arg) | |||
708 | struct mpt_fw_xfer kfwdl; | 713 | struct mpt_fw_xfer kfwdl; |
709 | 714 | ||
710 | if (copy_from_user(&kfwdl, ufwdl, sizeof(struct mpt_fw_xfer))) { | 715 | if (copy_from_user(&kfwdl, ufwdl, sizeof(struct mpt_fw_xfer))) { |
711 | printk(KERN_ERR "%s@%d::_ioctl_fwdl - " | 716 | printk(KERN_ERR MYNAM "%s@%d::_ioctl_fwdl - " |
712 | "Unable to copy mpt_fw_xfer struct @ %p\n", | 717 | "Unable to copy mpt_fw_xfer struct @ %p\n", |
713 | __FILE__, __LINE__, ufwdl); | 718 | __FILE__, __LINE__, ufwdl); |
714 | return -EFAULT; | 719 | return -EFAULT; |
@@ -756,7 +761,8 @@ mptctl_do_fw_download(int ioc, char __user *ufwbuf, size_t fwlen) | |||
756 | pFWDownloadReply_t ReplyMsg = NULL; | 761 | pFWDownloadReply_t ReplyMsg = NULL; |
757 | 762 | ||
758 | if (mpt_verify_adapter(ioc, &iocp) < 0) { | 763 | if (mpt_verify_adapter(ioc, &iocp) < 0) { |
759 | printk(KERN_DEBUG "ioctl_fwdl - ioc%d not found!\n", ioc); | 764 | printk(KERN_DEBUG MYNAM "ioctl_fwdl - ioc%d not found!\n", |
765 | ioc); | ||
760 | return -ENODEV; /* (-6) No such device or address */ | 766 | return -ENODEV; /* (-6) No such device or address */ |
761 | } else { | 767 | } else { |
762 | 768 | ||
@@ -868,9 +874,9 @@ mptctl_do_fw_download(int ioc, char __user *ufwbuf, size_t fwlen) | |||
868 | mpt_add_sge(sgOut, sgIn->FlagsLength, sgIn->Address); | 874 | mpt_add_sge(sgOut, sgIn->FlagsLength, sgIn->Address); |
869 | n++; | 875 | n++; |
870 | if (copy_from_user(bl->kptr, ufwbuf+fw_bytes_copied, bl->len)) { | 876 | if (copy_from_user(bl->kptr, ufwbuf+fw_bytes_copied, bl->len)) { |
871 | printk(KERN_ERR "%s@%d::_ioctl_fwdl - " | 877 | printk(MYIOC_s_ERR_FMT "%s@%d::_ioctl_fwdl - " |
872 | "Unable to copy f/w buffer hunk#%d @ %p\n", | 878 | "Unable to copy f/w buffer hunk#%d @ %p\n", |
873 | __FILE__, __LINE__, n, ufwbuf); | 879 | iocp->name, __FILE__, __LINE__, n, ufwbuf); |
874 | goto fwdl_out; | 880 | goto fwdl_out; |
875 | } | 881 | } |
876 | fw_bytes_copied += bl->len; | 882 | fw_bytes_copied += bl->len; |
@@ -906,21 +912,22 @@ mptctl_do_fw_download(int ioc, char __user *ufwbuf, size_t fwlen) | |||
906 | ReplyMsg = (pFWDownloadReply_t)iocp->ioctl->ReplyFrame; | 912 | ReplyMsg = (pFWDownloadReply_t)iocp->ioctl->ReplyFrame; |
907 | iocstat = le16_to_cpu(ReplyMsg->IOCStatus) & MPI_IOCSTATUS_MASK; | 913 | iocstat = le16_to_cpu(ReplyMsg->IOCStatus) & MPI_IOCSTATUS_MASK; |
908 | if (iocstat == MPI_IOCSTATUS_SUCCESS) { | 914 | if (iocstat == MPI_IOCSTATUS_SUCCESS) { |
909 | printk(KERN_INFO MYNAM ": F/W update successfully sent to %s!\n", iocp->name); | 915 | printk(MYIOC_s_INFO_FMT "F/W update successfull!\n", iocp->name); |
910 | return 0; | 916 | return 0; |
911 | } else if (iocstat == MPI_IOCSTATUS_INVALID_FUNCTION) { | 917 | } else if (iocstat == MPI_IOCSTATUS_INVALID_FUNCTION) { |
912 | printk(KERN_WARNING MYNAM ": ?Hmmm... %s says it doesn't support F/W download!?!\n", | 918 | printk(MYIOC_s_WARN_FMT "Hmmm... F/W download not supported!?!\n", |
913 | iocp->name); | 919 | iocp->name); |
914 | printk(KERN_WARNING MYNAM ": (time to go bang on somebodies door)\n"); | 920 | printk(MYIOC_s_WARN_FMT "(time to go bang on somebodies door)\n", |
921 | iocp->name); | ||
915 | return -EBADRQC; | 922 | return -EBADRQC; |
916 | } else if (iocstat == MPI_IOCSTATUS_BUSY) { | 923 | } else if (iocstat == MPI_IOCSTATUS_BUSY) { |
917 | printk(KERN_WARNING MYNAM ": Warning! %s says: IOC_BUSY!\n", iocp->name); | 924 | printk(MYIOC_s_WARN_FMT "IOC_BUSY!\n", iocp->name); |
918 | printk(KERN_WARNING MYNAM ": (try again later?)\n"); | 925 | printk(MYIOC_s_WARN_FMT "(try again later?)\n", iocp->name); |
919 | return -EBUSY; | 926 | return -EBUSY; |
920 | } else { | 927 | } else { |
921 | printk(KERN_WARNING MYNAM "::ioctl_fwdl() ERROR! %s returned [bad] status = %04xh\n", | 928 | printk(MYIOC_s_WARN_FMT "ioctl_fwdl() returned [bad] status = %04xh\n", |
922 | iocp->name, iocstat); | 929 | iocp->name, iocstat); |
923 | printk(KERN_WARNING MYNAM ": (bad VooDoo)\n"); | 930 | printk(MYIOC_s_WARN_FMT "(bad VooDoo)\n", iocp->name); |
924 | return -ENOMSG; | 931 | return -ENOMSG; |
925 | } | 932 | } |
926 | return 0; | 933 | return 0; |
@@ -970,10 +977,9 @@ kbuf_alloc_2_sgl(int bytes, u32 sgdir, int sge_offset, int *frags, | |||
970 | * structures for the SG elements. | 977 | * structures for the SG elements. |
971 | */ | 978 | */ |
972 | i = MAX_SGL_BYTES / 8; | 979 | i = MAX_SGL_BYTES / 8; |
973 | buflist = kmalloc(i, GFP_USER); | 980 | buflist = kzalloc(i, GFP_USER); |
974 | if (buflist == NULL) | 981 | if (!buflist) |
975 | return NULL; | 982 | return NULL; |
976 | memset(buflist, 0, i); | ||
977 | buflist_ent = 0; | 983 | buflist_ent = 0; |
978 | 984 | ||
979 | /* Allocate a single block of memory to store the sg elements and | 985 | /* Allocate a single block of memory to store the sg elements and |
@@ -1008,10 +1014,10 @@ kbuf_alloc_2_sgl(int bytes, u32 sgdir, int sge_offset, int *frags, | |||
1008 | if (buflist[buflist_ent].kptr == NULL) { | 1014 | if (buflist[buflist_ent].kptr == NULL) { |
1009 | alloc_sz = alloc_sz / 2; | 1015 | alloc_sz = alloc_sz / 2; |
1010 | if (alloc_sz == 0) { | 1016 | if (alloc_sz == 0) { |
1011 | printk(KERN_WARNING MYNAM "-SG: No can do - " | 1017 | printk(MYIOC_s_WARN_FMT "-SG: No can do - " |
1012 | "not enough memory! :-(\n"); | 1018 | "not enough memory! :-(\n", ioc->name); |
1013 | printk(KERN_WARNING MYNAM "-SG: (freeing %d frags)\n", | 1019 | printk(MYIOC_s_WARN_FMT "-SG: (freeing %d frags)\n", |
1014 | numfrags); | 1020 | ioc->name, numfrags); |
1015 | goto free_and_fail; | 1021 | goto free_and_fail; |
1016 | } | 1022 | } |
1017 | continue; | 1023 | continue; |
@@ -1034,18 +1040,19 @@ kbuf_alloc_2_sgl(int bytes, u32 sgdir, int sge_offset, int *frags, | |||
1034 | 1040 | ||
1035 | /* Need to chain? */ | 1041 | /* Need to chain? */ |
1036 | if (fragcnt == sg_spill) { | 1042 | if (fragcnt == sg_spill) { |
1037 | printk(KERN_WARNING MYNAM "-SG: No can do - " "Chain required! :-(\n"); | 1043 | printk(MYIOC_s_WARN_FMT |
1038 | printk(KERN_WARNING MYNAM "(freeing %d frags)\n", numfrags); | 1044 | "-SG: No can do - " "Chain required! :-(\n", ioc->name); |
1045 | printk(MYIOC_s_WARN_FMT "(freeing %d frags)\n", ioc->name, numfrags); | ||
1039 | goto free_and_fail; | 1046 | goto free_and_fail; |
1040 | } | 1047 | } |
1041 | 1048 | ||
1042 | /* overflow check... */ | 1049 | /* overflow check... */ |
1043 | if (numfrags*8 > MAX_SGL_BYTES){ | 1050 | if (numfrags*8 > MAX_SGL_BYTES){ |
1044 | /* GRRRRR... */ | 1051 | /* GRRRRR... */ |
1045 | printk(KERN_WARNING MYNAM "-SG: No can do - " | 1052 | printk(MYIOC_s_WARN_FMT "-SG: No can do - " |
1046 | "too many SG frags! :-(\n"); | 1053 | "too many SG frags! :-(\n", ioc->name); |
1047 | printk(KERN_WARNING MYNAM "-SG: (freeing %d frags)\n", | 1054 | printk(MYIOC_s_WARN_FMT "-SG: (freeing %d frags)\n", |
1048 | numfrags); | 1055 | ioc->name, numfrags); |
1049 | goto free_and_fail; | 1056 | goto free_and_fail; |
1050 | } | 1057 | } |
1051 | } | 1058 | } |
@@ -1066,8 +1073,6 @@ kbuf_alloc_2_sgl(int bytes, u32 sgdir, int sge_offset, int *frags, | |||
1066 | 1073 | ||
1067 | free_and_fail: | 1074 | free_and_fail: |
1068 | if (sglbuf != NULL) { | 1075 | if (sglbuf != NULL) { |
1069 | int i; | ||
1070 | |||
1071 | for (i = 0; i < numfrags; i++) { | 1076 | for (i = 0; i < numfrags; i++) { |
1072 | dma_addr_t dma_addr; | 1077 | dma_addr_t dma_addr; |
1073 | u8 *kptr; | 1078 | u8 *kptr; |
@@ -1170,7 +1175,7 @@ mptctl_getiocinfo (unsigned long arg, unsigned int data_size) | |||
1170 | int cim_rev; | 1175 | int cim_rev; |
1171 | u8 revision; | 1176 | u8 revision; |
1172 | struct scsi_device *sdev; | 1177 | struct scsi_device *sdev; |
1173 | VirtDevice *vdev; | 1178 | VirtDevice *vdevice; |
1174 | 1179 | ||
1175 | /* Add of PCI INFO results in unaligned access for | 1180 | /* Add of PCI INFO results in unaligned access for |
1176 | * IA64 and Sparc. Reset long to int. Return no PCI | 1181 | * IA64 and Sparc. Reset long to int. Return no PCI |
@@ -1189,13 +1194,13 @@ mptctl_getiocinfo (unsigned long arg, unsigned int data_size) | |||
1189 | 1194 | ||
1190 | karg = kmalloc(data_size, GFP_KERNEL); | 1195 | karg = kmalloc(data_size, GFP_KERNEL); |
1191 | if (karg == NULL) { | 1196 | if (karg == NULL) { |
1192 | printk(KERN_ERR "%s::mpt_ioctl_iocinfo() @%d - no memory available!\n", | 1197 | printk(KERN_ERR MYNAM "%s::mpt_ioctl_iocinfo() @%d - no memory available!\n", |
1193 | __FILE__, __LINE__); | 1198 | __FILE__, __LINE__); |
1194 | return -ENOMEM; | 1199 | return -ENOMEM; |
1195 | } | 1200 | } |
1196 | 1201 | ||
1197 | if (copy_from_user(karg, uarg, data_size)) { | 1202 | if (copy_from_user(karg, uarg, data_size)) { |
1198 | printk(KERN_ERR "%s@%d::mptctl_getiocinfo - " | 1203 | printk(KERN_ERR MYNAM "%s@%d::mptctl_getiocinfo - " |
1199 | "Unable to read in mpt_ioctl_iocinfo struct @ %p\n", | 1204 | "Unable to read in mpt_ioctl_iocinfo struct @ %p\n", |
1200 | __FILE__, __LINE__, uarg); | 1205 | __FILE__, __LINE__, uarg); |
1201 | kfree(karg); | 1206 | kfree(karg); |
@@ -1204,7 +1209,7 @@ mptctl_getiocinfo (unsigned long arg, unsigned int data_size) | |||
1204 | 1209 | ||
1205 | if (((iocnum = mpt_verify_adapter(karg->hdr.iocnum, &ioc)) < 0) || | 1210 | if (((iocnum = mpt_verify_adapter(karg->hdr.iocnum, &ioc)) < 0) || |
1206 | (ioc == NULL)) { | 1211 | (ioc == NULL)) { |
1207 | printk(KERN_DEBUG "%s::mptctl_getiocinfo() @%d - ioc%d not found!\n", | 1212 | printk(KERN_DEBUG MYNAM "%s::mptctl_getiocinfo() @%d - ioc%d not found!\n", |
1208 | __FILE__, __LINE__, iocnum); | 1213 | __FILE__, __LINE__, iocnum); |
1209 | kfree(karg); | 1214 | kfree(karg); |
1210 | return -ENODEV; | 1215 | return -ENODEV; |
@@ -1212,9 +1217,9 @@ mptctl_getiocinfo (unsigned long arg, unsigned int data_size) | |||
1212 | 1217 | ||
1213 | /* Verify the data transfer size is correct. */ | 1218 | /* Verify the data transfer size is correct. */ |
1214 | if (karg->hdr.maxDataSize != data_size) { | 1219 | if (karg->hdr.maxDataSize != data_size) { |
1215 | printk(KERN_ERR "%s@%d::mptctl_getiocinfo - " | 1220 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_getiocinfo - " |
1216 | "Structure size mismatch. Command not completed.\n", | 1221 | "Structure size mismatch. Command not completed.\n", |
1217 | __FILE__, __LINE__); | 1222 | ioc->name, __FILE__, __LINE__); |
1218 | kfree(karg); | 1223 | kfree(karg); |
1219 | return -EFAULT; | 1224 | return -EFAULT; |
1220 | } | 1225 | } |
@@ -1265,8 +1270,8 @@ mptctl_getiocinfo (unsigned long arg, unsigned int data_size) | |||
1265 | karg->numDevices = 0; | 1270 | karg->numDevices = 0; |
1266 | if (ioc->sh) { | 1271 | if (ioc->sh) { |
1267 | shost_for_each_device(sdev, ioc->sh) { | 1272 | shost_for_each_device(sdev, ioc->sh) { |
1268 | vdev = sdev->hostdata; | 1273 | vdevice = sdev->hostdata; |
1269 | if (vdev->vtarget->tflags & | 1274 | if (vdevice->vtarget->tflags & |
1270 | MPT_TARGET_FLAGS_RAID_COMPONENT) | 1275 | MPT_TARGET_FLAGS_RAID_COMPONENT) |
1271 | continue; | 1276 | continue; |
1272 | karg->numDevices++; | 1277 | karg->numDevices++; |
@@ -1290,9 +1295,9 @@ mptctl_getiocinfo (unsigned long arg, unsigned int data_size) | |||
1290 | /* Copy the data from kernel memory to user memory | 1295 | /* Copy the data from kernel memory to user memory |
1291 | */ | 1296 | */ |
1292 | if (copy_to_user((char __user *)arg, karg, data_size)) { | 1297 | if (copy_to_user((char __user *)arg, karg, data_size)) { |
1293 | printk(KERN_ERR "%s@%d::mptctl_getiocinfo - " | 1298 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_getiocinfo - " |
1294 | "Unable to write out mpt_ioctl_iocinfo struct @ %p\n", | 1299 | "Unable to write out mpt_ioctl_iocinfo struct @ %p\n", |
1295 | __FILE__, __LINE__, uarg); | 1300 | ioc->name, __FILE__, __LINE__, uarg); |
1296 | kfree(karg); | 1301 | kfree(karg); |
1297 | return -EFAULT; | 1302 | return -EFAULT; |
1298 | } | 1303 | } |
@@ -1317,7 +1322,7 @@ mptctl_gettargetinfo (unsigned long arg) | |||
1317 | struct mpt_ioctl_targetinfo __user *uarg = (void __user *) arg; | 1322 | struct mpt_ioctl_targetinfo __user *uarg = (void __user *) arg; |
1318 | struct mpt_ioctl_targetinfo karg; | 1323 | struct mpt_ioctl_targetinfo karg; |
1319 | MPT_ADAPTER *ioc; | 1324 | MPT_ADAPTER *ioc; |
1320 | VirtDevice *vdev; | 1325 | VirtDevice *vdevice; |
1321 | char *pmem; | 1326 | char *pmem; |
1322 | int *pdata; | 1327 | int *pdata; |
1323 | int iocnum; | 1328 | int iocnum; |
@@ -1329,7 +1334,7 @@ mptctl_gettargetinfo (unsigned long arg) | |||
1329 | struct scsi_device *sdev; | 1334 | struct scsi_device *sdev; |
1330 | 1335 | ||
1331 | if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_targetinfo))) { | 1336 | if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_targetinfo))) { |
1332 | printk(KERN_ERR "%s@%d::mptctl_gettargetinfo - " | 1337 | printk(KERN_ERR MYNAM "%s@%d::mptctl_gettargetinfo - " |
1333 | "Unable to read in mpt_ioctl_targetinfo struct @ %p\n", | 1338 | "Unable to read in mpt_ioctl_targetinfo struct @ %p\n", |
1334 | __FILE__, __LINE__, uarg); | 1339 | __FILE__, __LINE__, uarg); |
1335 | return -EFAULT; | 1340 | return -EFAULT; |
@@ -1337,7 +1342,7 @@ mptctl_gettargetinfo (unsigned long arg) | |||
1337 | 1342 | ||
1338 | if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || | 1343 | if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || |
1339 | (ioc == NULL)) { | 1344 | (ioc == NULL)) { |
1340 | printk(KERN_DEBUG "%s::mptctl_gettargetinfo() @%d - ioc%d not found!\n", | 1345 | printk(KERN_DEBUG MYNAM "%s::mptctl_gettargetinfo() @%d - ioc%d not found!\n", |
1341 | __FILE__, __LINE__, iocnum); | 1346 | __FILE__, __LINE__, iocnum); |
1342 | return -ENODEV; | 1347 | return -ENODEV; |
1343 | } | 1348 | } |
@@ -1353,8 +1358,8 @@ mptctl_gettargetinfo (unsigned long arg) | |||
1353 | port = karg.hdr.port; | 1358 | port = karg.hdr.port; |
1354 | 1359 | ||
1355 | if (maxWordsLeft <= 0) { | 1360 | if (maxWordsLeft <= 0) { |
1356 | printk(KERN_ERR "%s::mptctl_gettargetinfo() @%d - no memory available!\n", | 1361 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_gettargetinfo() - no memory available!\n", |
1357 | __FILE__, __LINE__); | 1362 | ioc->name, __FILE__, __LINE__); |
1358 | return -ENOMEM; | 1363 | return -ENOMEM; |
1359 | } | 1364 | } |
1360 | 1365 | ||
@@ -1372,13 +1377,12 @@ mptctl_gettargetinfo (unsigned long arg) | |||
1372 | * 15- 8: Bus Number | 1377 | * 15- 8: Bus Number |
1373 | * 7- 0: Target ID | 1378 | * 7- 0: Target ID |
1374 | */ | 1379 | */ |
1375 | pmem = kmalloc(numBytes, GFP_KERNEL); | 1380 | pmem = kzalloc(numBytes, GFP_KERNEL); |
1376 | if (pmem == NULL) { | 1381 | if (!pmem) { |
1377 | printk(KERN_ERR "%s::mptctl_gettargetinfo() @%d - no memory available!\n", | 1382 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_gettargetinfo() - no memory available!\n", |
1378 | __FILE__, __LINE__); | 1383 | ioc->name, __FILE__, __LINE__); |
1379 | return -ENOMEM; | 1384 | return -ENOMEM; |
1380 | } | 1385 | } |
1381 | memset(pmem, 0, numBytes); | ||
1382 | pdata = (int *) pmem; | 1386 | pdata = (int *) pmem; |
1383 | 1387 | ||
1384 | /* Get number of devices | 1388 | /* Get number of devices |
@@ -1387,13 +1391,13 @@ mptctl_gettargetinfo (unsigned long arg) | |||
1387 | shost_for_each_device(sdev, ioc->sh) { | 1391 | shost_for_each_device(sdev, ioc->sh) { |
1388 | if (!maxWordsLeft) | 1392 | if (!maxWordsLeft) |
1389 | continue; | 1393 | continue; |
1390 | vdev = sdev->hostdata; | 1394 | vdevice = sdev->hostdata; |
1391 | if (vdev->vtarget->tflags & | 1395 | if (vdevice->vtarget->tflags & |
1392 | MPT_TARGET_FLAGS_RAID_COMPONENT) | 1396 | MPT_TARGET_FLAGS_RAID_COMPONENT) |
1393 | continue; | 1397 | continue; |
1394 | lun = (vdev->vtarget->raidVolume) ? 0x80 : vdev->lun; | 1398 | lun = (vdevice->vtarget->raidVolume) ? 0x80 : vdevice->lun; |
1395 | *pdata = (((u8)lun << 16) + (vdev->vtarget->channel << 8) + | 1399 | *pdata = (((u8)lun << 16) + (vdevice->vtarget->channel << 8) + |
1396 | (vdev->vtarget->id )); | 1400 | (vdevice->vtarget->id )); |
1397 | pdata++; | 1401 | pdata++; |
1398 | numDevices++; | 1402 | numDevices++; |
1399 | --maxWordsLeft; | 1403 | --maxWordsLeft; |
@@ -1405,9 +1409,9 @@ mptctl_gettargetinfo (unsigned long arg) | |||
1405 | */ | 1409 | */ |
1406 | if (copy_to_user((char __user *)arg, &karg, | 1410 | if (copy_to_user((char __user *)arg, &karg, |
1407 | sizeof(struct mpt_ioctl_targetinfo))) { | 1411 | sizeof(struct mpt_ioctl_targetinfo))) { |
1408 | printk(KERN_ERR "%s@%d::mptctl_gettargetinfo - " | 1412 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_gettargetinfo - " |
1409 | "Unable to write out mpt_ioctl_targetinfo struct @ %p\n", | 1413 | "Unable to write out mpt_ioctl_targetinfo struct @ %p\n", |
1410 | __FILE__, __LINE__, uarg); | 1414 | ioc->name, __FILE__, __LINE__, uarg); |
1411 | kfree(pmem); | 1415 | kfree(pmem); |
1412 | return -EFAULT; | 1416 | return -EFAULT; |
1413 | } | 1417 | } |
@@ -1415,9 +1419,9 @@ mptctl_gettargetinfo (unsigned long arg) | |||
1415 | /* Copy the remaining data from kernel memory to user memory | 1419 | /* Copy the remaining data from kernel memory to user memory |
1416 | */ | 1420 | */ |
1417 | if (copy_to_user(uarg->targetInfo, pmem, numBytes)) { | 1421 | if (copy_to_user(uarg->targetInfo, pmem, numBytes)) { |
1418 | printk(KERN_ERR "%s@%d::mptctl_gettargetinfo - " | 1422 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_gettargetinfo - " |
1419 | "Unable to write out mpt_ioctl_targetinfo struct @ %p\n", | 1423 | "Unable to write out mpt_ioctl_targetinfo struct @ %p\n", |
1420 | __FILE__, __LINE__, pdata); | 1424 | ioc->name, __FILE__, __LINE__, pdata); |
1421 | kfree(pmem); | 1425 | kfree(pmem); |
1422 | return -EFAULT; | 1426 | return -EFAULT; |
1423 | } | 1427 | } |
@@ -1444,7 +1448,7 @@ mptctl_readtest (unsigned long arg) | |||
1444 | int iocnum; | 1448 | int iocnum; |
1445 | 1449 | ||
1446 | if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_test))) { | 1450 | if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_test))) { |
1447 | printk(KERN_ERR "%s@%d::mptctl_readtest - " | 1451 | printk(KERN_ERR MYNAM "%s@%d::mptctl_readtest - " |
1448 | "Unable to read in mpt_ioctl_test struct @ %p\n", | 1452 | "Unable to read in mpt_ioctl_test struct @ %p\n", |
1449 | __FILE__, __LINE__, uarg); | 1453 | __FILE__, __LINE__, uarg); |
1450 | return -EFAULT; | 1454 | return -EFAULT; |
@@ -1452,7 +1456,7 @@ mptctl_readtest (unsigned long arg) | |||
1452 | 1456 | ||
1453 | if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || | 1457 | if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || |
1454 | (ioc == NULL)) { | 1458 | (ioc == NULL)) { |
1455 | printk(KERN_DEBUG "%s::mptctl_readtest() @%d - ioc%d not found!\n", | 1459 | printk(KERN_DEBUG MYNAM "%s::mptctl_readtest() @%d - ioc%d not found!\n", |
1456 | __FILE__, __LINE__, iocnum); | 1460 | __FILE__, __LINE__, iocnum); |
1457 | return -ENODEV; | 1461 | return -ENODEV; |
1458 | } | 1462 | } |
@@ -1476,9 +1480,9 @@ mptctl_readtest (unsigned long arg) | |||
1476 | /* Copy the data from kernel memory to user memory | 1480 | /* Copy the data from kernel memory to user memory |
1477 | */ | 1481 | */ |
1478 | if (copy_to_user((char __user *)arg, &karg, sizeof(struct mpt_ioctl_test))) { | 1482 | if (copy_to_user((char __user *)arg, &karg, sizeof(struct mpt_ioctl_test))) { |
1479 | printk(KERN_ERR "%s@%d::mptctl_readtest - " | 1483 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_readtest - " |
1480 | "Unable to write out mpt_ioctl_test struct @ %p\n", | 1484 | "Unable to write out mpt_ioctl_test struct @ %p\n", |
1481 | __FILE__, __LINE__, uarg); | 1485 | ioc->name, __FILE__, __LINE__, uarg); |
1482 | return -EFAULT; | 1486 | return -EFAULT; |
1483 | } | 1487 | } |
1484 | 1488 | ||
@@ -1505,7 +1509,7 @@ mptctl_eventquery (unsigned long arg) | |||
1505 | int iocnum; | 1509 | int iocnum; |
1506 | 1510 | ||
1507 | if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_eventquery))) { | 1511 | if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_eventquery))) { |
1508 | printk(KERN_ERR "%s@%d::mptctl_eventquery - " | 1512 | printk(KERN_ERR MYNAM "%s@%d::mptctl_eventquery - " |
1509 | "Unable to read in mpt_ioctl_eventquery struct @ %p\n", | 1513 | "Unable to read in mpt_ioctl_eventquery struct @ %p\n", |
1510 | __FILE__, __LINE__, uarg); | 1514 | __FILE__, __LINE__, uarg); |
1511 | return -EFAULT; | 1515 | return -EFAULT; |
@@ -1513,7 +1517,7 @@ mptctl_eventquery (unsigned long arg) | |||
1513 | 1517 | ||
1514 | if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || | 1518 | if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || |
1515 | (ioc == NULL)) { | 1519 | (ioc == NULL)) { |
1516 | printk(KERN_DEBUG "%s::mptctl_eventquery() @%d - ioc%d not found!\n", | 1520 | printk(KERN_DEBUG MYNAM "%s::mptctl_eventquery() @%d - ioc%d not found!\n", |
1517 | __FILE__, __LINE__, iocnum); | 1521 | __FILE__, __LINE__, iocnum); |
1518 | return -ENODEV; | 1522 | return -ENODEV; |
1519 | } | 1523 | } |
@@ -1526,9 +1530,9 @@ mptctl_eventquery (unsigned long arg) | |||
1526 | /* Copy the data from kernel memory to user memory | 1530 | /* Copy the data from kernel memory to user memory |
1527 | */ | 1531 | */ |
1528 | if (copy_to_user((char __user *)arg, &karg, sizeof(struct mpt_ioctl_eventquery))) { | 1532 | if (copy_to_user((char __user *)arg, &karg, sizeof(struct mpt_ioctl_eventquery))) { |
1529 | printk(KERN_ERR "%s@%d::mptctl_eventquery - " | 1533 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_eventquery - " |
1530 | "Unable to write out mpt_ioctl_eventquery struct @ %p\n", | 1534 | "Unable to write out mpt_ioctl_eventquery struct @ %p\n", |
1531 | __FILE__, __LINE__, uarg); | 1535 | ioc->name, __FILE__, __LINE__, uarg); |
1532 | return -EFAULT; | 1536 | return -EFAULT; |
1533 | } | 1537 | } |
1534 | return 0; | 1538 | return 0; |
@@ -1544,7 +1548,7 @@ mptctl_eventenable (unsigned long arg) | |||
1544 | int iocnum; | 1548 | int iocnum; |
1545 | 1549 | ||
1546 | if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_eventenable))) { | 1550 | if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_eventenable))) { |
1547 | printk(KERN_ERR "%s@%d::mptctl_eventenable - " | 1551 | printk(KERN_ERR MYNAM "%s@%d::mptctl_eventenable - " |
1548 | "Unable to read in mpt_ioctl_eventenable struct @ %p\n", | 1552 | "Unable to read in mpt_ioctl_eventenable struct @ %p\n", |
1549 | __FILE__, __LINE__, uarg); | 1553 | __FILE__, __LINE__, uarg); |
1550 | return -EFAULT; | 1554 | return -EFAULT; |
@@ -1552,7 +1556,7 @@ mptctl_eventenable (unsigned long arg) | |||
1552 | 1556 | ||
1553 | if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || | 1557 | if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || |
1554 | (ioc == NULL)) { | 1558 | (ioc == NULL)) { |
1555 | printk(KERN_DEBUG "%s::mptctl_eventenable() @%d - ioc%d not found!\n", | 1559 | printk(KERN_DEBUG MYNAM "%s::mptctl_eventenable() @%d - ioc%d not found!\n", |
1556 | __FILE__, __LINE__, iocnum); | 1560 | __FILE__, __LINE__, iocnum); |
1557 | return -ENODEV; | 1561 | return -ENODEV; |
1558 | } | 1562 | } |
@@ -1563,12 +1567,13 @@ mptctl_eventenable (unsigned long arg) | |||
1563 | /* Have not yet allocated memory - do so now. | 1567 | /* Have not yet allocated memory - do so now. |
1564 | */ | 1568 | */ |
1565 | int sz = MPTCTL_EVENT_LOG_SIZE * sizeof(MPT_IOCTL_EVENTS); | 1569 | int sz = MPTCTL_EVENT_LOG_SIZE * sizeof(MPT_IOCTL_EVENTS); |
1566 | ioc->events = kmalloc(sz, GFP_KERNEL); | 1570 | ioc->events = kzalloc(sz, GFP_KERNEL); |
1567 | if (ioc->events == NULL) { | 1571 | if (!ioc->events) { |
1568 | printk(KERN_ERR MYNAM ": ERROR - Insufficient memory to add adapter!\n"); | 1572 | printk(MYIOC_s_ERR_FMT |
1573 | ": ERROR - Insufficient memory to add adapter!\n", | ||
1574 | ioc->name); | ||
1569 | return -ENOMEM; | 1575 | return -ENOMEM; |
1570 | } | 1576 | } |
1571 | memset(ioc->events, 0, sz); | ||
1572 | ioc->alloc_total += sz; | 1577 | ioc->alloc_total += sz; |
1573 | 1578 | ||
1574 | ioc->eventContext = 0; | 1579 | ioc->eventContext = 0; |
@@ -1592,7 +1597,7 @@ mptctl_eventreport (unsigned long arg) | |||
1592 | int numBytes, maxEvents, max; | 1597 | int numBytes, maxEvents, max; |
1593 | 1598 | ||
1594 | if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_eventreport))) { | 1599 | if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_eventreport))) { |
1595 | printk(KERN_ERR "%s@%d::mptctl_eventreport - " | 1600 | printk(KERN_ERR MYNAM "%s@%d::mptctl_eventreport - " |
1596 | "Unable to read in mpt_ioctl_eventreport struct @ %p\n", | 1601 | "Unable to read in mpt_ioctl_eventreport struct @ %p\n", |
1597 | __FILE__, __LINE__, uarg); | 1602 | __FILE__, __LINE__, uarg); |
1598 | return -EFAULT; | 1603 | return -EFAULT; |
@@ -1600,7 +1605,7 @@ mptctl_eventreport (unsigned long arg) | |||
1600 | 1605 | ||
1601 | if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || | 1606 | if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || |
1602 | (ioc == NULL)) { | 1607 | (ioc == NULL)) { |
1603 | printk(KERN_DEBUG "%s::mptctl_eventreport() @%d - ioc%d not found!\n", | 1608 | printk(KERN_DEBUG MYNAM "%s::mptctl_eventreport() @%d - ioc%d not found!\n", |
1604 | __FILE__, __LINE__, iocnum); | 1609 | __FILE__, __LINE__, iocnum); |
1605 | return -ENODEV; | 1610 | return -ENODEV; |
1606 | } | 1611 | } |
@@ -1626,9 +1631,9 @@ mptctl_eventreport (unsigned long arg) | |||
1626 | */ | 1631 | */ |
1627 | numBytes = max * sizeof(MPT_IOCTL_EVENTS); | 1632 | numBytes = max * sizeof(MPT_IOCTL_EVENTS); |
1628 | if (copy_to_user(uarg->eventData, ioc->events, numBytes)) { | 1633 | if (copy_to_user(uarg->eventData, ioc->events, numBytes)) { |
1629 | printk(KERN_ERR "%s@%d::mptctl_eventreport - " | 1634 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_eventreport - " |
1630 | "Unable to write out mpt_ioctl_eventreport struct @ %p\n", | 1635 | "Unable to write out mpt_ioctl_eventreport struct @ %p\n", |
1631 | __FILE__, __LINE__, ioc->events); | 1636 | ioc->name, __FILE__, __LINE__, ioc->events); |
1632 | return -EFAULT; | 1637 | return -EFAULT; |
1633 | } | 1638 | } |
1634 | 1639 | ||
@@ -1646,7 +1651,7 @@ mptctl_replace_fw (unsigned long arg) | |||
1646 | int newFwSize; | 1651 | int newFwSize; |
1647 | 1652 | ||
1648 | if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_replace_fw))) { | 1653 | if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_replace_fw))) { |
1649 | printk(KERN_ERR "%s@%d::mptctl_replace_fw - " | 1654 | printk(KERN_ERR MYNAM "%s@%d::mptctl_replace_fw - " |
1650 | "Unable to read in mpt_ioctl_replace_fw struct @ %p\n", | 1655 | "Unable to read in mpt_ioctl_replace_fw struct @ %p\n", |
1651 | __FILE__, __LINE__, uarg); | 1656 | __FILE__, __LINE__, uarg); |
1652 | return -EFAULT; | 1657 | return -EFAULT; |
@@ -1654,7 +1659,7 @@ mptctl_replace_fw (unsigned long arg) | |||
1654 | 1659 | ||
1655 | if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || | 1660 | if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || |
1656 | (ioc == NULL)) { | 1661 | (ioc == NULL)) { |
1657 | printk(KERN_DEBUG "%s::mptctl_replace_fw() @%d - ioc%d not found!\n", | 1662 | printk(KERN_DEBUG MYNAM "%s::mptctl_replace_fw() @%d - ioc%d not found!\n", |
1658 | __FILE__, __LINE__, iocnum); | 1663 | __FILE__, __LINE__, iocnum); |
1659 | return -ENODEV; | 1664 | return -ENODEV; |
1660 | } | 1665 | } |
@@ -1684,9 +1689,9 @@ mptctl_replace_fw (unsigned long arg) | |||
1684 | /* Copy the data from user memory to kernel space | 1689 | /* Copy the data from user memory to kernel space |
1685 | */ | 1690 | */ |
1686 | if (copy_from_user(ioc->cached_fw, uarg->newImage, newFwSize)) { | 1691 | if (copy_from_user(ioc->cached_fw, uarg->newImage, newFwSize)) { |
1687 | printk(KERN_ERR "%s@%d::mptctl_replace_fw - " | 1692 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_replace_fw - " |
1688 | "Unable to read in mpt_ioctl_replace_fw image " | 1693 | "Unable to read in mpt_ioctl_replace_fw image " |
1689 | "@ %p\n", __FILE__, __LINE__, uarg); | 1694 | "@ %p\n", ioc->name, __FILE__, __LINE__, uarg); |
1690 | mpt_free_fw_memory(ioc); | 1695 | mpt_free_fw_memory(ioc); |
1691 | return -EFAULT; | 1696 | return -EFAULT; |
1692 | } | 1697 | } |
@@ -1720,7 +1725,7 @@ mptctl_mpt_command (unsigned long arg) | |||
1720 | 1725 | ||
1721 | 1726 | ||
1722 | if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_command))) { | 1727 | if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_command))) { |
1723 | printk(KERN_ERR "%s@%d::mptctl_mpt_command - " | 1728 | printk(KERN_ERR MYNAM "%s@%d::mptctl_mpt_command - " |
1724 | "Unable to read in mpt_ioctl_command struct @ %p\n", | 1729 | "Unable to read in mpt_ioctl_command struct @ %p\n", |
1725 | __FILE__, __LINE__, uarg); | 1730 | __FILE__, __LINE__, uarg); |
1726 | return -EFAULT; | 1731 | return -EFAULT; |
@@ -1728,7 +1733,7 @@ mptctl_mpt_command (unsigned long arg) | |||
1728 | 1733 | ||
1729 | if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || | 1734 | if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || |
1730 | (ioc == NULL)) { | 1735 | (ioc == NULL)) { |
1731 | printk(KERN_DEBUG "%s::mptctl_mpt_command() @%d - ioc%d not found!\n", | 1736 | printk(KERN_DEBUG MYNAM "%s::mptctl_mpt_command() @%d - ioc%d not found!\n", |
1732 | __FILE__, __LINE__, iocnum); | 1737 | __FILE__, __LINE__, iocnum); |
1733 | return -ENODEV; | 1738 | return -ENODEV; |
1734 | } | 1739 | } |
@@ -1769,21 +1774,24 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr) | |||
1769 | ulong timeout; | 1774 | ulong timeout; |
1770 | struct scsi_device *sdev; | 1775 | struct scsi_device *sdev; |
1771 | 1776 | ||
1777 | /* bufIn and bufOut are used for user to kernel space transfers | ||
1778 | */ | ||
1772 | bufIn.kptr = bufOut.kptr = NULL; | 1779 | bufIn.kptr = bufOut.kptr = NULL; |
1780 | bufIn.len = bufOut.len = 0; | ||
1773 | 1781 | ||
1774 | if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || | 1782 | if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || |
1775 | (ioc == NULL)) { | 1783 | (ioc == NULL)) { |
1776 | printk(KERN_DEBUG "%s::mptctl_do_mpt_command() @%d - ioc%d not found!\n", | 1784 | printk(KERN_DEBUG MYNAM "%s::mptctl_do_mpt_command() @%d - ioc%d not found!\n", |
1777 | __FILE__, __LINE__, iocnum); | 1785 | __FILE__, __LINE__, iocnum); |
1778 | return -ENODEV; | 1786 | return -ENODEV; |
1779 | } | 1787 | } |
1780 | if (!ioc->ioctl) { | 1788 | if (!ioc->ioctl) { |
1781 | printk(KERN_ERR "%s@%d::mptctl_do_mpt_command - " | 1789 | printk(KERN_ERR MYNAM "%s@%d::mptctl_do_mpt_command - " |
1782 | "No memory available during driver init.\n", | 1790 | "No memory available during driver init.\n", |
1783 | __FILE__, __LINE__); | 1791 | __FILE__, __LINE__); |
1784 | return -ENOMEM; | 1792 | return -ENOMEM; |
1785 | } else if (ioc->ioctl->status & MPT_IOCTL_STATUS_DID_IOCRESET) { | 1793 | } else if (ioc->ioctl->status & MPT_IOCTL_STATUS_DID_IOCRESET) { |
1786 | printk(KERN_ERR "%s@%d::mptctl_do_mpt_command - " | 1794 | printk(KERN_ERR MYNAM "%s@%d::mptctl_do_mpt_command - " |
1787 | "Busy with IOC Reset \n", __FILE__, __LINE__); | 1795 | "Busy with IOC Reset \n", __FILE__, __LINE__); |
1788 | return -EBUSY; | 1796 | return -EBUSY; |
1789 | } | 1797 | } |
@@ -1797,9 +1805,9 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr) | |||
1797 | sz += sizeof(dma_addr_t) + sizeof(u32); | 1805 | sz += sizeof(dma_addr_t) + sizeof(u32); |
1798 | 1806 | ||
1799 | if (sz > ioc->req_sz) { | 1807 | if (sz > ioc->req_sz) { |
1800 | printk(KERN_ERR "%s@%d::mptctl_do_mpt_command - " | 1808 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " |
1801 | "Request frame too large (%d) maximum (%d)\n", | 1809 | "Request frame too large (%d) maximum (%d)\n", |
1802 | __FILE__, __LINE__, sz, ioc->req_sz); | 1810 | ioc->name, __FILE__, __LINE__, sz, ioc->req_sz); |
1803 | return -EFAULT; | 1811 | return -EFAULT; |
1804 | } | 1812 | } |
1805 | 1813 | ||
@@ -1817,9 +1825,9 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr) | |||
1817 | * Request frame in user space | 1825 | * Request frame in user space |
1818 | */ | 1826 | */ |
1819 | if (copy_from_user(mf, mfPtr, karg.dataSgeOffset * 4)) { | 1827 | if (copy_from_user(mf, mfPtr, karg.dataSgeOffset * 4)) { |
1820 | printk(KERN_ERR "%s@%d::mptctl_do_mpt_command - " | 1828 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " |
1821 | "Unable to read MF from mpt_ioctl_command struct @ %p\n", | 1829 | "Unable to read MF from mpt_ioctl_command struct @ %p\n", |
1822 | __FILE__, __LINE__, mfPtr); | 1830 | ioc->name, __FILE__, __LINE__, mfPtr); |
1823 | rc = -EFAULT; | 1831 | rc = -EFAULT; |
1824 | goto done_free_mem; | 1832 | goto done_free_mem; |
1825 | } | 1833 | } |
@@ -1870,17 +1878,17 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr) | |||
1870 | 1878 | ||
1871 | id = (ioc->devices_per_bus == 0) ? 256 : ioc->devices_per_bus; | 1879 | id = (ioc->devices_per_bus == 0) ? 256 : ioc->devices_per_bus; |
1872 | if (pScsiReq->TargetID > id) { | 1880 | if (pScsiReq->TargetID > id) { |
1873 | printk(KERN_ERR "%s@%d::mptctl_do_mpt_command - " | 1881 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " |
1874 | "Target ID out of bounds. \n", | 1882 | "Target ID out of bounds. \n", |
1875 | __FILE__, __LINE__); | 1883 | ioc->name, __FILE__, __LINE__); |
1876 | rc = -ENODEV; | 1884 | rc = -ENODEV; |
1877 | goto done_free_mem; | 1885 | goto done_free_mem; |
1878 | } | 1886 | } |
1879 | 1887 | ||
1880 | if (pScsiReq->Bus >= ioc->number_of_buses) { | 1888 | if (pScsiReq->Bus >= ioc->number_of_buses) { |
1881 | printk(KERN_ERR "%s@%d::mptctl_do_mpt_command - " | 1889 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " |
1882 | "Target Bus out of bounds. \n", | 1890 | "Target Bus out of bounds. \n", |
1883 | __FILE__, __LINE__); | 1891 | ioc->name, __FILE__, __LINE__); |
1884 | rc = -ENODEV; | 1892 | rc = -ENODEV; |
1885 | goto done_free_mem; | 1893 | goto done_free_mem; |
1886 | } | 1894 | } |
@@ -1932,9 +1940,9 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr) | |||
1932 | ioc->ioctl->id = pScsiReq->TargetID; | 1940 | ioc->ioctl->id = pScsiReq->TargetID; |
1933 | 1941 | ||
1934 | } else { | 1942 | } else { |
1935 | printk(KERN_ERR "%s@%d::mptctl_do_mpt_command - " | 1943 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " |
1936 | "SCSI driver is not loaded. \n", | 1944 | "SCSI driver is not loaded. \n", |
1937 | __FILE__, __LINE__); | 1945 | ioc->name, __FILE__, __LINE__); |
1938 | rc = -EFAULT; | 1946 | rc = -EFAULT; |
1939 | goto done_free_mem; | 1947 | goto done_free_mem; |
1940 | } | 1948 | } |
@@ -1951,9 +1959,9 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr) | |||
1951 | 1959 | ||
1952 | case MPI_FUNCTION_SATA_PASSTHROUGH: | 1960 | case MPI_FUNCTION_SATA_PASSTHROUGH: |
1953 | if (!ioc->sh) { | 1961 | if (!ioc->sh) { |
1954 | printk(KERN_ERR "%s@%d::mptctl_do_mpt_command - " | 1962 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " |
1955 | "SCSI driver is not loaded. \n", | 1963 | "SCSI driver is not loaded. \n", |
1956 | __FILE__, __LINE__); | 1964 | ioc->name, __FILE__, __LINE__); |
1957 | rc = -EFAULT; | 1965 | rc = -EFAULT; |
1958 | goto done_free_mem; | 1966 | goto done_free_mem; |
1959 | } | 1967 | } |
@@ -2010,9 +2018,9 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr) | |||
2010 | ioc->ioctl->reset = MPTCTL_RESET_OK; | 2018 | ioc->ioctl->reset = MPTCTL_RESET_OK; |
2011 | ioc->ioctl->id = pScsiReq->TargetID; | 2019 | ioc->ioctl->id = pScsiReq->TargetID; |
2012 | } else { | 2020 | } else { |
2013 | printk(KERN_ERR "%s@%d::mptctl_do_mpt_command - " | 2021 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " |
2014 | "SCSI driver is not loaded. \n", | 2022 | "SCSI driver is not loaded. \n", |
2015 | __FILE__, __LINE__); | 2023 | ioc->name, __FILE__, __LINE__); |
2016 | rc = -EFAULT; | 2024 | rc = -EFAULT; |
2017 | goto done_free_mem; | 2025 | goto done_free_mem; |
2018 | } | 2026 | } |
@@ -2021,10 +2029,10 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr) | |||
2021 | case MPI_FUNCTION_SCSI_TASK_MGMT: | 2029 | case MPI_FUNCTION_SCSI_TASK_MGMT: |
2022 | { | 2030 | { |
2023 | MPT_SCSI_HOST *hd = NULL; | 2031 | MPT_SCSI_HOST *hd = NULL; |
2024 | if ((ioc->sh == NULL) || ((hd = (MPT_SCSI_HOST *)ioc->sh->hostdata) == NULL)) { | 2032 | if ((ioc->sh == NULL) || ((hd = shost_priv(ioc->sh)) == NULL)) { |
2025 | printk(KERN_ERR "%s@%d::mptctl_do_mpt_command - " | 2033 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " |
2026 | "SCSI driver not loaded or SCSI host not found. \n", | 2034 | "SCSI driver not loaded or SCSI host not found. \n", |
2027 | __FILE__, __LINE__); | 2035 | ioc->name, __FILE__, __LINE__); |
2028 | rc = -EFAULT; | 2036 | rc = -EFAULT; |
2029 | goto done_free_mem; | 2037 | goto done_free_mem; |
2030 | } else if (mptctl_set_tm_flags(hd) != 0) { | 2038 | } else if (mptctl_set_tm_flags(hd) != 0) { |
@@ -2055,9 +2063,9 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr) | |||
2055 | (pInit->ReplyFrameSize != cpu_to_le16(ioc->reply_sz)) || | 2063 | (pInit->ReplyFrameSize != cpu_to_le16(ioc->reply_sz)) || |
2056 | (pInit->HostMfaHighAddr != high_addr) || | 2064 | (pInit->HostMfaHighAddr != high_addr) || |
2057 | (pInit->SenseBufferHighAddr != sense_high)) { | 2065 | (pInit->SenseBufferHighAddr != sense_high)) { |
2058 | printk(KERN_ERR "%s@%d::mptctl_do_mpt_command - " | 2066 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " |
2059 | "IOC_INIT issued with 1 or more incorrect parameters. Rejected.\n", | 2067 | "IOC_INIT issued with 1 or more incorrect parameters. Rejected.\n", |
2060 | __FILE__, __LINE__); | 2068 | ioc->name, __FILE__, __LINE__); |
2061 | rc = -EFAULT; | 2069 | rc = -EFAULT; |
2062 | goto done_free_mem; | 2070 | goto done_free_mem; |
2063 | } | 2071 | } |
@@ -2088,9 +2096,9 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr) | |||
2088 | MPI_FUNCTION_LAN_RESET | 2096 | MPI_FUNCTION_LAN_RESET |
2089 | */ | 2097 | */ |
2090 | 2098 | ||
2091 | printk(KERN_ERR "%s@%d::mptctl_do_mpt_command - " | 2099 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " |
2092 | "Illegal request (function 0x%x) \n", | 2100 | "Illegal request (function 0x%x) \n", |
2093 | __FILE__, __LINE__, hdr->Function); | 2101 | ioc->name, __FILE__, __LINE__, hdr->Function); |
2094 | rc = -EFAULT; | 2102 | rc = -EFAULT; |
2095 | goto done_free_mem; | 2103 | goto done_free_mem; |
2096 | } | 2104 | } |
@@ -2103,11 +2111,6 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr) | |||
2103 | psge = (char *) (((int *) mf) + karg.dataSgeOffset); | 2111 | psge = (char *) (((int *) mf) + karg.dataSgeOffset); |
2104 | flagsLength = 0; | 2112 | flagsLength = 0; |
2105 | 2113 | ||
2106 | /* bufIn and bufOut are used for user to kernel space transfers | ||
2107 | */ | ||
2108 | bufIn.kptr = bufOut.kptr = NULL; | ||
2109 | bufIn.len = bufOut.len = 0; | ||
2110 | |||
2111 | if (karg.dataOutSize > 0) | 2114 | if (karg.dataOutSize > 0) |
2112 | sgSize ++; | 2115 | sgSize ++; |
2113 | 2116 | ||
@@ -2147,11 +2150,11 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr) | |||
2147 | if (copy_from_user(bufOut.kptr, | 2150 | if (copy_from_user(bufOut.kptr, |
2148 | karg.dataOutBufPtr, | 2151 | karg.dataOutBufPtr, |
2149 | bufOut.len)) { | 2152 | bufOut.len)) { |
2150 | printk(KERN_ERR | 2153 | printk(MYIOC_s_ERR_FMT |
2151 | "%s@%d::mptctl_do_mpt_command - Unable " | 2154 | "%s@%d::mptctl_do_mpt_command - Unable " |
2152 | "to read user data " | 2155 | "to read user data " |
2153 | "struct @ %p\n", | 2156 | "struct @ %p\n", |
2154 | __FILE__, __LINE__,karg.dataOutBufPtr); | 2157 | ioc->name, __FILE__, __LINE__,karg.dataOutBufPtr); |
2155 | rc = -EFAULT; | 2158 | rc = -EFAULT; |
2156 | goto done_free_mem; | 2159 | goto done_free_mem; |
2157 | } | 2160 | } |
@@ -2187,15 +2190,20 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr) | |||
2187 | 2190 | ||
2188 | DBG_DUMP_TM_REQUEST_FRAME(ioc, (u32 *)mf); | 2191 | DBG_DUMP_TM_REQUEST_FRAME(ioc, (u32 *)mf); |
2189 | 2192 | ||
2190 | if (mpt_send_handshake_request(mptctl_id, ioc, | 2193 | if ((ioc->facts.IOCCapabilities & MPI_IOCFACTS_CAPABILITY_HIGH_PRI_Q) && |
2191 | sizeof(SCSITaskMgmt_t), (u32*)mf, | 2194 | (ioc->facts.MsgVersion >= MPI_VERSION_01_05)) |
2192 | CAN_SLEEP) != 0) { | 2195 | mpt_put_msg_frame_hi_pri(mptctl_id, ioc, mf); |
2193 | dfailprintk(ioc, printk(MYIOC_s_ERR_FMT "_send_handshake FAILED!" | 2196 | else { |
2194 | " (ioc %p, mf %p) \n", ioc->name, | 2197 | rc =mpt_send_handshake_request(mptctl_id, ioc, |
2195 | ioc, mf)); | 2198 | sizeof(SCSITaskMgmt_t), (u32*)mf, CAN_SLEEP); |
2196 | mptctl_free_tm_flags(ioc); | 2199 | if (rc != 0) { |
2197 | rc = -ENODATA; | 2200 | dfailprintk(ioc, printk(MYIOC_s_ERR_FMT |
2198 | goto done_free_mem; | 2201 | "_send_handshake FAILED! (ioc %p, mf %p)\n", |
2202 | ioc->name, ioc, mf)); | ||
2203 | mptctl_free_tm_flags(ioc); | ||
2204 | rc = -ENODATA; | ||
2205 | goto done_free_mem; | ||
2206 | } | ||
2199 | } | 2207 | } |
2200 | 2208 | ||
2201 | } else | 2209 | } else |
@@ -2233,10 +2241,10 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr) | |||
2233 | if (sz > 0) { | 2241 | if (sz > 0) { |
2234 | if (copy_to_user(karg.replyFrameBufPtr, | 2242 | if (copy_to_user(karg.replyFrameBufPtr, |
2235 | &ioc->ioctl->ReplyFrame, sz)){ | 2243 | &ioc->ioctl->ReplyFrame, sz)){ |
2236 | printk(KERN_ERR | 2244 | printk(MYIOC_s_ERR_FMT |
2237 | "%s@%d::mptctl_do_mpt_command - " | 2245 | "%s@%d::mptctl_do_mpt_command - " |
2238 | "Unable to write out reply frame %p\n", | 2246 | "Unable to write out reply frame %p\n", |
2239 | __FILE__, __LINE__, karg.replyFrameBufPtr); | 2247 | ioc->name, __FILE__, __LINE__, karg.replyFrameBufPtr); |
2240 | rc = -ENODATA; | 2248 | rc = -ENODATA; |
2241 | goto done_free_mem; | 2249 | goto done_free_mem; |
2242 | } | 2250 | } |
@@ -2249,9 +2257,9 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr) | |||
2249 | sz = min(karg.maxSenseBytes, MPT_SENSE_BUFFER_SIZE); | 2257 | sz = min(karg.maxSenseBytes, MPT_SENSE_BUFFER_SIZE); |
2250 | if (sz > 0) { | 2258 | if (sz > 0) { |
2251 | if (copy_to_user(karg.senseDataPtr, ioc->ioctl->sense, sz)) { | 2259 | if (copy_to_user(karg.senseDataPtr, ioc->ioctl->sense, sz)) { |
2252 | printk(KERN_ERR "%s@%d::mptctl_do_mpt_command - " | 2260 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " |
2253 | "Unable to write sense data to user %p\n", | 2261 | "Unable to write sense data to user %p\n", |
2254 | __FILE__, __LINE__, | 2262 | ioc->name, __FILE__, __LINE__, |
2255 | karg.senseDataPtr); | 2263 | karg.senseDataPtr); |
2256 | rc = -ENODATA; | 2264 | rc = -ENODATA; |
2257 | goto done_free_mem; | 2265 | goto done_free_mem; |
@@ -2267,9 +2275,9 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr) | |||
2267 | 2275 | ||
2268 | if (copy_to_user(karg.dataInBufPtr, | 2276 | if (copy_to_user(karg.dataInBufPtr, |
2269 | bufIn.kptr, karg.dataInSize)) { | 2277 | bufIn.kptr, karg.dataInSize)) { |
2270 | printk(KERN_ERR "%s@%d::mptctl_do_mpt_command - " | 2278 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " |
2271 | "Unable to write data to user %p\n", | 2279 | "Unable to write data to user %p\n", |
2272 | __FILE__, __LINE__, | 2280 | ioc->name, __FILE__, __LINE__, |
2273 | karg.dataInBufPtr); | 2281 | karg.dataInBufPtr); |
2274 | rc = -ENODATA; | 2282 | rc = -ENODATA; |
2275 | } | 2283 | } |
@@ -2340,7 +2348,7 @@ mptctl_hp_hostinfo(unsigned long arg, unsigned int data_size) | |||
2340 | return -EFAULT; | 2348 | return -EFAULT; |
2341 | 2349 | ||
2342 | if (copy_from_user(&karg, uarg, sizeof(hp_host_info_t))) { | 2350 | if (copy_from_user(&karg, uarg, sizeof(hp_host_info_t))) { |
2343 | printk(KERN_ERR "%s@%d::mptctl_hp_host_info - " | 2351 | printk(KERN_ERR MYNAM "%s@%d::mptctl_hp_host_info - " |
2344 | "Unable to read in hp_host_info struct @ %p\n", | 2352 | "Unable to read in hp_host_info struct @ %p\n", |
2345 | __FILE__, __LINE__, uarg); | 2353 | __FILE__, __LINE__, uarg); |
2346 | return -EFAULT; | 2354 | return -EFAULT; |
@@ -2348,7 +2356,7 @@ mptctl_hp_hostinfo(unsigned long arg, unsigned int data_size) | |||
2348 | 2356 | ||
2349 | if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || | 2357 | if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || |
2350 | (ioc == NULL)) { | 2358 | (ioc == NULL)) { |
2351 | printk(KERN_DEBUG "%s::mptctl_hp_hostinfo() @%d - ioc%d not found!\n", | 2359 | printk(KERN_DEBUG MYNAM "%s::mptctl_hp_hostinfo() @%d - ioc%d not found!\n", |
2352 | __FILE__, __LINE__, iocnum); | 2360 | __FILE__, __LINE__, iocnum); |
2353 | return -ENODEV; | 2361 | return -ENODEV; |
2354 | } | 2362 | } |
@@ -2456,7 +2464,7 @@ mptctl_hp_hostinfo(unsigned long arg, unsigned int data_size) | |||
2456 | karg.soft_resets = 0; | 2464 | karg.soft_resets = 0; |
2457 | karg.timeouts = 0; | 2465 | karg.timeouts = 0; |
2458 | if (ioc->sh != NULL) { | 2466 | if (ioc->sh != NULL) { |
2459 | MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)ioc->sh->hostdata; | 2467 | MPT_SCSI_HOST *hd = shost_priv(ioc->sh); |
2460 | 2468 | ||
2461 | if (hd && (cim_rev == 1)) { | 2469 | if (hd && (cim_rev == 1)) { |
2462 | karg.hard_resets = hd->hard_resets; | 2470 | karg.hard_resets = hd->hard_resets; |
@@ -2529,9 +2537,9 @@ mptctl_hp_hostinfo(unsigned long arg, unsigned int data_size) | |||
2529 | /* Copy the data from kernel memory to user memory | 2537 | /* Copy the data from kernel memory to user memory |
2530 | */ | 2538 | */ |
2531 | if (copy_to_user((char __user *)arg, &karg, sizeof(hp_host_info_t))) { | 2539 | if (copy_to_user((char __user *)arg, &karg, sizeof(hp_host_info_t))) { |
2532 | printk(KERN_ERR "%s@%d::mptctl_hpgethostinfo - " | 2540 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_hpgethostinfo - " |
2533 | "Unable to write out hp_host_info @ %p\n", | 2541 | "Unable to write out hp_host_info @ %p\n", |
2534 | __FILE__, __LINE__, uarg); | 2542 | ioc->name, __FILE__, __LINE__, uarg); |
2535 | return -EFAULT; | 2543 | return -EFAULT; |
2536 | } | 2544 | } |
2537 | 2545 | ||
@@ -2567,7 +2575,7 @@ mptctl_hp_targetinfo(unsigned long arg) | |||
2567 | int tmp, np, rc = 0; | 2575 | int tmp, np, rc = 0; |
2568 | 2576 | ||
2569 | if (copy_from_user(&karg, uarg, sizeof(hp_target_info_t))) { | 2577 | if (copy_from_user(&karg, uarg, sizeof(hp_target_info_t))) { |
2570 | printk(KERN_ERR "%s@%d::mptctl_hp_targetinfo - " | 2578 | printk(KERN_ERR MYNAM "%s@%d::mptctl_hp_targetinfo - " |
2571 | "Unable to read in hp_host_targetinfo struct @ %p\n", | 2579 | "Unable to read in hp_host_targetinfo struct @ %p\n", |
2572 | __FILE__, __LINE__, uarg); | 2580 | __FILE__, __LINE__, uarg); |
2573 | return -EFAULT; | 2581 | return -EFAULT; |
@@ -2575,11 +2583,11 @@ mptctl_hp_targetinfo(unsigned long arg) | |||
2575 | 2583 | ||
2576 | if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || | 2584 | if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || |
2577 | (ioc == NULL)) { | 2585 | (ioc == NULL)) { |
2578 | printk(KERN_DEBUG "%s::mptctl_hp_targetinfo() @%d - ioc%d not found!\n", | 2586 | printk(KERN_DEBUG MYNAM "%s::mptctl_hp_targetinfo() @%d - ioc%d not found!\n", |
2579 | __FILE__, __LINE__, iocnum); | 2587 | __FILE__, __LINE__, iocnum); |
2580 | return -ENODEV; | 2588 | return -ENODEV; |
2581 | } | 2589 | } |
2582 | dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT ": mptctl_hp_targetinfo called.\n", | 2590 | dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mptctl_hp_targetinfo called.\n", |
2583 | ioc->name)); | 2591 | ioc->name)); |
2584 | 2592 | ||
2585 | /* There is nothing to do for FCP parts. | 2593 | /* There is nothing to do for FCP parts. |
@@ -2673,16 +2681,16 @@ mptctl_hp_targetinfo(unsigned long arg) | |||
2673 | pci_free_consistent(ioc->pcidev, data_sz, (u8 *) pg3_alloc, page_dma); | 2681 | pci_free_consistent(ioc->pcidev, data_sz, (u8 *) pg3_alloc, page_dma); |
2674 | } | 2682 | } |
2675 | } | 2683 | } |
2676 | hd = (MPT_SCSI_HOST *) ioc->sh->hostdata; | 2684 | hd = shost_priv(ioc->sh); |
2677 | if (hd != NULL) | 2685 | if (hd != NULL) |
2678 | karg.select_timeouts = hd->sel_timeout[karg.hdr.id]; | 2686 | karg.select_timeouts = hd->sel_timeout[karg.hdr.id]; |
2679 | 2687 | ||
2680 | /* Copy the data from kernel memory to user memory | 2688 | /* Copy the data from kernel memory to user memory |
2681 | */ | 2689 | */ |
2682 | if (copy_to_user((char __user *)arg, &karg, sizeof(hp_target_info_t))) { | 2690 | if (copy_to_user((char __user *)arg, &karg, sizeof(hp_target_info_t))) { |
2683 | printk(KERN_ERR "%s@%d::mptctl_hp_target_info - " | 2691 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_hp_target_info - " |
2684 | "Unable to write out mpt_ioctl_targetinfo struct @ %p\n", | 2692 | "Unable to write out mpt_ioctl_targetinfo struct @ %p\n", |
2685 | __FILE__, __LINE__, uarg); | 2693 | ioc->name, __FILE__, __LINE__, uarg); |
2686 | return -EFAULT; | 2694 | return -EFAULT; |
2687 | } | 2695 | } |
2688 | 2696 | ||
@@ -2732,7 +2740,7 @@ compat_mptfwxfer_ioctl(struct file *filp, unsigned int cmd, | |||
2732 | if (((iocnum = mpt_verify_adapter(iocnumX, &iocp)) < 0) || | 2740 | if (((iocnum = mpt_verify_adapter(iocnumX, &iocp)) < 0) || |
2733 | (iocp == NULL)) { | 2741 | (iocp == NULL)) { |
2734 | printk(KERN_DEBUG MYNAM "::compat_mptfwxfer_ioctl @%d - ioc%d not found!\n", | 2742 | printk(KERN_DEBUG MYNAM "::compat_mptfwxfer_ioctl @%d - ioc%d not found!\n", |
2735 | __LINE__, iocnumX); | 2743 | __LINE__, iocnumX); |
2736 | return -ENODEV; | 2744 | return -ENODEV; |
2737 | } | 2745 | } |
2738 | 2746 | ||
@@ -2772,7 +2780,7 @@ compat_mpt_command(struct file *filp, unsigned int cmd, | |||
2772 | if (((iocnum = mpt_verify_adapter(iocnumX, &iocp)) < 0) || | 2780 | if (((iocnum = mpt_verify_adapter(iocnumX, &iocp)) < 0) || |
2773 | (iocp == NULL)) { | 2781 | (iocp == NULL)) { |
2774 | printk(KERN_DEBUG MYNAM "::compat_mpt_command @%d - ioc%d not found!\n", | 2782 | printk(KERN_DEBUG MYNAM "::compat_mpt_command @%d - ioc%d not found!\n", |
2775 | __LINE__, iocnumX); | 2783 | __LINE__, iocnumX); |
2776 | return -ENODEV; | 2784 | return -ENODEV; |
2777 | } | 2785 | } |
2778 | 2786 | ||
@@ -2853,31 +2861,22 @@ static long compat_mpctl_ioctl(struct file *f, unsigned int cmd, unsigned long a | |||
2853 | static int | 2861 | static int |
2854 | mptctl_probe(struct pci_dev *pdev, const struct pci_device_id *id) | 2862 | mptctl_probe(struct pci_dev *pdev, const struct pci_device_id *id) |
2855 | { | 2863 | { |
2856 | int err; | 2864 | MPT_IOCTL *mem; |
2857 | int sz; | ||
2858 | u8 *mem; | ||
2859 | MPT_ADAPTER *ioc = pci_get_drvdata(pdev); | 2865 | MPT_ADAPTER *ioc = pci_get_drvdata(pdev); |
2860 | 2866 | ||
2861 | /* | 2867 | /* |
2862 | * Allocate and inite a MPT_IOCTL structure | 2868 | * Allocate and inite a MPT_IOCTL structure |
2863 | */ | 2869 | */ |
2864 | sz = sizeof (MPT_IOCTL); | 2870 | mem = kzalloc(sizeof(MPT_IOCTL), GFP_KERNEL); |
2865 | mem = kmalloc(sz, GFP_KERNEL); | 2871 | if (!mem) { |
2866 | if (mem == NULL) { | 2872 | mptctl_remove(pdev); |
2867 | err = -ENOMEM; | 2873 | return -ENOMEM; |
2868 | goto out_fail; | ||
2869 | } | 2874 | } |
2870 | 2875 | ||
2871 | memset(mem, 0, sz); | 2876 | ioc->ioctl = mem; |
2872 | ioc->ioctl = (MPT_IOCTL *) mem; | ||
2873 | ioc->ioctl->ioc = ioc; | 2877 | ioc->ioctl->ioc = ioc; |
2874 | mutex_init(&ioc->ioctl->ioctl_mutex); | 2878 | mutex_init(&ioc->ioctl->ioctl_mutex); |
2875 | return 0; | 2879 | return 0; |
2876 | |||
2877 | out_fail: | ||
2878 | |||
2879 | mptctl_remove(pdev); | ||
2880 | return err; | ||
2881 | } | 2880 | } |
2882 | 2881 | ||
2883 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | 2882 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ |
@@ -2924,7 +2923,8 @@ static int __init mptctl_init(void) | |||
2924 | * Install our handler | 2923 | * Install our handler |
2925 | */ | 2924 | */ |
2926 | ++where; | 2925 | ++where; |
2927 | if ((mptctl_id = mpt_register(mptctl_reply, MPTCTL_DRIVER)) < 0) { | 2926 | mptctl_id = mpt_register(mptctl_reply, MPTCTL_DRIVER); |
2927 | if (!mptctl_id || mptctl_id >= MPT_MAX_PROTOCOL_DRIVERS) { | ||
2928 | printk(KERN_ERR MYNAM ": ERROR: Failed to register with Fusion MPT base driver\n"); | 2928 | printk(KERN_ERR MYNAM ": ERROR: Failed to register with Fusion MPT base driver\n"); |
2929 | misc_deregister(&mptctl_miscdev); | 2929 | misc_deregister(&mptctl_miscdev); |
2930 | err = -EBUSY; | 2930 | err = -EBUSY; |
diff --git a/drivers/message/fusion/mptctl.h b/drivers/message/fusion/mptctl.h index 180b3c156247..2c1890127e15 100644 --- a/drivers/message/fusion/mptctl.h +++ b/drivers/message/fusion/mptctl.h | |||
@@ -3,9 +3,9 @@ | |||
3 | * Fusion MPT misc device (ioctl) driver. | 3 | * Fusion MPT misc device (ioctl) driver. |
4 | * For use with PCI chip/adapter(s): | 4 | * For use with PCI chip/adapter(s): |
5 | * LSIFC9xx/LSI409xx Fibre Channel | 5 | * LSIFC9xx/LSI409xx Fibre Channel |
6 | * running LSI Logic Fusion MPT (Message Passing Technology) firmware. | 6 | * running LSI Fusion MPT (Message Passing Technology) firmware. |
7 | * | 7 | * |
8 | * Copyright (c) 1999-2007 LSI Logic Corporation | 8 | * Copyright (c) 1999-2007 LSI Corporation |
9 | * (mailto:DL-MPTFusionLinux@lsi.com) | 9 | * (mailto:DL-MPTFusionLinux@lsi.com) |
10 | * | 10 | * |
11 | */ | 11 | */ |
diff --git a/drivers/message/fusion/mptfc.c b/drivers/message/fusion/mptfc.c index 8422c25e4a3e..3cdd4e962115 100644 --- a/drivers/message/fusion/mptfc.c +++ b/drivers/message/fusion/mptfc.c | |||
@@ -1,9 +1,9 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/message/fusion/mptfc.c | 2 | * linux/drivers/message/fusion/mptfc.c |
3 | * For use with LSI Logic PCI chip/adapter(s) | 3 | * For use with LSI PCI chip/adapter(s) |
4 | * running LSI Logic Fusion MPT (Message Passing Technology) firmware. | 4 | * running LSI Fusion MPT (Message Passing Technology) firmware. |
5 | * | 5 | * |
6 | * Copyright (c) 1999-2007 LSI Logic Corporation | 6 | * Copyright (c) 1999-2007 LSI Corporation |
7 | * (mailto:DL-MPTFusionLinux@lsi.com) | 7 | * (mailto:DL-MPTFusionLinux@lsi.com) |
8 | * | 8 | * |
9 | */ | 9 | */ |
@@ -90,9 +90,9 @@ static int max_lun = MPTFC_MAX_LUN; | |||
90 | module_param(max_lun, int, 0); | 90 | module_param(max_lun, int, 0); |
91 | MODULE_PARM_DESC(max_lun, " max lun, default=16895 "); | 91 | MODULE_PARM_DESC(max_lun, " max lun, default=16895 "); |
92 | 92 | ||
93 | static int mptfcDoneCtx = -1; | 93 | static u8 mptfcDoneCtx = MPT_MAX_PROTOCOL_DRIVERS; |
94 | static int mptfcTaskCtx = -1; | 94 | static u8 mptfcTaskCtx = MPT_MAX_PROTOCOL_DRIVERS; |
95 | static int mptfcInternalCtx = -1; /* Used only for internal commands */ | 95 | static u8 mptfcInternalCtx = MPT_MAX_PROTOCOL_DRIVERS; |
96 | 96 | ||
97 | static int mptfc_target_alloc(struct scsi_target *starget); | 97 | static int mptfc_target_alloc(struct scsi_target *starget); |
98 | static int mptfc_slave_alloc(struct scsi_device *sdev); | 98 | static int mptfc_slave_alloc(struct scsi_device *sdev); |
@@ -194,37 +194,36 @@ mptfc_block_error_handler(struct scsi_cmnd *SCpnt, | |||
194 | struct fc_rport *rport = starget_to_rport(scsi_target(sdev)); | 194 | struct fc_rport *rport = starget_to_rport(scsi_target(sdev)); |
195 | unsigned long flags; | 195 | unsigned long flags; |
196 | int ready; | 196 | int ready; |
197 | MPT_ADAPTER *ioc; | ||
197 | 198 | ||
198 | hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata; | 199 | hd = shost_priv(SCpnt->device->host); |
200 | ioc = hd->ioc; | ||
199 | spin_lock_irqsave(shost->host_lock, flags); | 201 | spin_lock_irqsave(shost->host_lock, flags); |
200 | while ((ready = fc_remote_port_chkready(rport) >> 16) == DID_IMM_RETRY) { | 202 | while ((ready = fc_remote_port_chkready(rport) >> 16) == DID_IMM_RETRY) { |
201 | spin_unlock_irqrestore(shost->host_lock, flags); | 203 | spin_unlock_irqrestore(shost->host_lock, flags); |
202 | dfcprintk (hd->ioc, printk(MYIOC_s_DEBUG_FMT | 204 | dfcprintk (ioc, printk(MYIOC_s_DEBUG_FMT |
203 | "mptfc_block_error_handler.%d: %d:%d, port status is " | 205 | "mptfc_block_error_handler.%d: %d:%d, port status is " |
204 | "DID_IMM_RETRY, deferring %s recovery.\n", | 206 | "DID_IMM_RETRY, deferring %s recovery.\n", |
205 | ((MPT_SCSI_HOST *) shost->hostdata)->ioc->name, | 207 | ioc->name, ioc->sh->host_no, |
206 | ((MPT_SCSI_HOST *) shost->hostdata)->ioc->sh->host_no, | 208 | SCpnt->device->id, SCpnt->device->lun, caller)); |
207 | SCpnt->device->id,SCpnt->device->lun,caller)); | ||
208 | msleep(1000); | 209 | msleep(1000); |
209 | spin_lock_irqsave(shost->host_lock, flags); | 210 | spin_lock_irqsave(shost->host_lock, flags); |
210 | } | 211 | } |
211 | spin_unlock_irqrestore(shost->host_lock, flags); | 212 | spin_unlock_irqrestore(shost->host_lock, flags); |
212 | 213 | ||
213 | if (ready == DID_NO_CONNECT || !SCpnt->device->hostdata) { | 214 | if (ready == DID_NO_CONNECT || !SCpnt->device->hostdata) { |
214 | dfcprintk (hd->ioc, printk(MYIOC_s_DEBUG_FMT | 215 | dfcprintk (ioc, printk(MYIOC_s_DEBUG_FMT |
215 | "%s.%d: %d:%d, failing recovery, " | 216 | "%s.%d: %d:%d, failing recovery, " |
216 | "port state %d, vdev %p.\n", caller, | 217 | "port state %d, vdevice %p.\n", caller, |
217 | ((MPT_SCSI_HOST *) shost->hostdata)->ioc->name, | 218 | ioc->name, ioc->sh->host_no, |
218 | ((MPT_SCSI_HOST *) shost->hostdata)->ioc->sh->host_no, | 219 | SCpnt->device->id, SCpnt->device->lun, ready, |
219 | SCpnt->device->id,SCpnt->device->lun,ready, | ||
220 | SCpnt->device->hostdata)); | 220 | SCpnt->device->hostdata)); |
221 | return FAILED; | 221 | return FAILED; |
222 | } | 222 | } |
223 | dfcprintk (hd->ioc, printk(MYIOC_s_DEBUG_FMT | 223 | dfcprintk (ioc, printk(MYIOC_s_DEBUG_FMT |
224 | "%s.%d: %d:%d, executing recovery.\n", caller, | 224 | "%s.%d: %d:%d, executing recovery.\n", caller, |
225 | ((MPT_SCSI_HOST *) shost->hostdata)->ioc->name, | 225 | ioc->name, ioc->sh->host_no, |
226 | ((MPT_SCSI_HOST *) shost->hostdata)->ioc->sh->host_no, | 226 | SCpnt->device->id, SCpnt->device->lun)); |
227 | SCpnt->device->id,SCpnt->device->lun)); | ||
228 | return (*func)(SCpnt); | 227 | return (*func)(SCpnt); |
229 | } | 228 | } |
230 | 229 | ||
@@ -470,7 +469,7 @@ mptfc_register_dev(MPT_ADAPTER *ioc, int channel, FCDevicePage0_t *pg0) | |||
470 | /* | 469 | /* |
471 | * if already mapped, remap here. If not mapped, | 470 | * if already mapped, remap here. If not mapped, |
472 | * target_alloc will allocate vtarget and map, | 471 | * target_alloc will allocate vtarget and map, |
473 | * slave_alloc will fill in vdev from vtarget. | 472 | * slave_alloc will fill in vdevice from vtarget. |
474 | */ | 473 | */ |
475 | if (ri->starget) { | 474 | if (ri->starget) { |
476 | vtarget = ri->starget->hostdata; | 475 | vtarget = ri->starget->hostdata; |
@@ -602,10 +601,10 @@ mptfc_slave_alloc(struct scsi_device *sdev) | |||
602 | { | 601 | { |
603 | MPT_SCSI_HOST *hd; | 602 | MPT_SCSI_HOST *hd; |
604 | VirtTarget *vtarget; | 603 | VirtTarget *vtarget; |
605 | VirtDevice *vdev; | 604 | VirtDevice *vdevice; |
606 | struct scsi_target *starget; | 605 | struct scsi_target *starget; |
607 | struct fc_rport *rport; | 606 | struct fc_rport *rport; |
608 | 607 | MPT_ADAPTER *ioc; | |
609 | 608 | ||
610 | starget = scsi_target(sdev); | 609 | starget = scsi_target(sdev); |
611 | rport = starget_to_rport(starget); | 610 | rport = starget_to_rport(starget); |
@@ -613,31 +612,32 @@ mptfc_slave_alloc(struct scsi_device *sdev) | |||
613 | if (!rport || fc_remote_port_chkready(rport)) | 612 | if (!rport || fc_remote_port_chkready(rport)) |
614 | return -ENXIO; | 613 | return -ENXIO; |
615 | 614 | ||
616 | hd = (MPT_SCSI_HOST *)sdev->host->hostdata; | 615 | hd = shost_priv(sdev->host); |
616 | ioc = hd->ioc; | ||
617 | 617 | ||
618 | vdev = kzalloc(sizeof(VirtDevice), GFP_KERNEL); | 618 | vdevice = kzalloc(sizeof(VirtDevice), GFP_KERNEL); |
619 | if (!vdev) { | 619 | if (!vdevice) { |
620 | printk(MYIOC_s_ERR_FMT "slave_alloc kmalloc(%zd) FAILED!\n", | 620 | printk(MYIOC_s_ERR_FMT "slave_alloc kmalloc(%zd) FAILED!\n", |
621 | hd->ioc->name, sizeof(VirtDevice)); | 621 | ioc->name, sizeof(VirtDevice)); |
622 | return -ENOMEM; | 622 | return -ENOMEM; |
623 | } | 623 | } |
624 | 624 | ||
625 | 625 | ||
626 | sdev->hostdata = vdev; | 626 | sdev->hostdata = vdevice; |
627 | vtarget = starget->hostdata; | 627 | vtarget = starget->hostdata; |
628 | 628 | ||
629 | if (vtarget->num_luns == 0) { | 629 | if (vtarget->num_luns == 0) { |
630 | vtarget->ioc_id = hd->ioc->id; | 630 | vtarget->ioc_id = ioc->id; |
631 | vtarget->tflags = MPT_TARGET_FLAGS_Q_YES; | 631 | vtarget->tflags = MPT_TARGET_FLAGS_Q_YES; |
632 | } | 632 | } |
633 | 633 | ||
634 | vdev->vtarget = vtarget; | 634 | vdevice->vtarget = vtarget; |
635 | vdev->lun = sdev->lun; | 635 | vdevice->lun = sdev->lun; |
636 | 636 | ||
637 | vtarget->num_luns++; | 637 | vtarget->num_luns++; |
638 | 638 | ||
639 | 639 | ||
640 | mptfc_dump_lun_info(hd->ioc, rport, sdev, vtarget); | 640 | mptfc_dump_lun_info(ioc, rport, sdev, vtarget); |
641 | 641 | ||
642 | return 0; | 642 | return 0; |
643 | } | 643 | } |
@@ -648,9 +648,9 @@ mptfc_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) | |||
648 | struct mptfc_rport_info *ri; | 648 | struct mptfc_rport_info *ri; |
649 | struct fc_rport *rport = starget_to_rport(scsi_target(SCpnt->device)); | 649 | struct fc_rport *rport = starget_to_rport(scsi_target(SCpnt->device)); |
650 | int err; | 650 | int err; |
651 | VirtDevice *vdev = SCpnt->device->hostdata; | 651 | VirtDevice *vdevice = SCpnt->device->hostdata; |
652 | 652 | ||
653 | if (!vdev || !vdev->vtarget) { | 653 | if (!vdevice || !vdevice->vtarget) { |
654 | SCpnt->result = DID_NO_CONNECT << 16; | 654 | SCpnt->result = DID_NO_CONNECT << 16; |
655 | done(SCpnt); | 655 | done(SCpnt); |
656 | return 0; | 656 | return 0; |
@@ -675,6 +675,50 @@ mptfc_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) | |||
675 | } | 675 | } |
676 | 676 | ||
677 | /* | 677 | /* |
678 | * mptfc_display_port_link_speed - displaying link speed | ||
679 | * @ioc: Pointer to MPT_ADAPTER structure | ||
680 | * @portnum: IOC Port number | ||
681 | * @pp0dest: port page0 data payload | ||
682 | * | ||
683 | */ | ||
684 | static void | ||
685 | mptfc_display_port_link_speed(MPT_ADAPTER *ioc, int portnum, FCPortPage0_t *pp0dest) | ||
686 | { | ||
687 | u8 old_speed, new_speed, state; | ||
688 | char *old, *new; | ||
689 | |||
690 | if (portnum >= 2) | ||
691 | return; | ||
692 | |||
693 | old_speed = ioc->fc_link_speed[portnum]; | ||
694 | new_speed = pp0dest->CurrentSpeed; | ||
695 | state = pp0dest->PortState; | ||
696 | |||
697 | if (state != MPI_FCPORTPAGE0_PORTSTATE_OFFLINE && | ||
698 | new_speed != MPI_FCPORTPAGE0_CURRENT_SPEED_UKNOWN) { | ||
699 | |||
700 | old = old_speed == MPI_FCPORTPAGE0_CURRENT_SPEED_1GBIT ? "1 Gbps" : | ||
701 | old_speed == MPI_FCPORTPAGE0_CURRENT_SPEED_2GBIT ? "2 Gbps" : | ||
702 | old_speed == MPI_FCPORTPAGE0_CURRENT_SPEED_4GBIT ? "4 Gbps" : | ||
703 | "Unknown"; | ||
704 | new = new_speed == MPI_FCPORTPAGE0_CURRENT_SPEED_1GBIT ? "1 Gbps" : | ||
705 | new_speed == MPI_FCPORTPAGE0_CURRENT_SPEED_2GBIT ? "2 Gbps" : | ||
706 | new_speed == MPI_FCPORTPAGE0_CURRENT_SPEED_4GBIT ? "4 Gbps" : | ||
707 | "Unknown"; | ||
708 | if (old_speed == 0) | ||
709 | printk(MYIOC_s_NOTE_FMT | ||
710 | "FC Link Established, Speed = %s\n", | ||
711 | ioc->name, new); | ||
712 | else if (old_speed != new_speed) | ||
713 | printk(MYIOC_s_WARN_FMT | ||
714 | "FC Link Speed Change, Old Speed = %s, New Speed = %s\n", | ||
715 | ioc->name, old, new); | ||
716 | |||
717 | ioc->fc_link_speed[portnum] = new_speed; | ||
718 | } | ||
719 | } | ||
720 | |||
721 | /* | ||
678 | * mptfc_GetFcPortPage0 - Fetch FCPort config Page0. | 722 | * mptfc_GetFcPortPage0 - Fetch FCPort config Page0. |
679 | * @ioc: Pointer to MPT_ADAPTER structure | 723 | * @ioc: Pointer to MPT_ADAPTER structure |
680 | * @portnum: IOC Port number | 724 | * @portnum: IOC Port number |
@@ -773,6 +817,7 @@ mptfc_GetFcPortPage0(MPT_ADAPTER *ioc, int portnum) | |||
773 | " complete.\n", | 817 | " complete.\n", |
774 | ioc->name); | 818 | ioc->name); |
775 | } | 819 | } |
820 | mptfc_display_port_link_speed(ioc, portnum, pp0dest); | ||
776 | } | 821 | } |
777 | 822 | ||
778 | pci_free_consistent(ioc->pcidev, data_sz, (u8 *) ppage0_alloc, page0_dma); | 823 | pci_free_consistent(ioc->pcidev, data_sz, (u8 *) ppage0_alloc, page0_dma); |
@@ -1023,6 +1068,18 @@ mptfc_init_host_attr(MPT_ADAPTER *ioc,int portnum) | |||
1023 | } | 1068 | } |
1024 | 1069 | ||
1025 | static void | 1070 | static void |
1071 | mptfc_link_status_change(struct work_struct *work) | ||
1072 | { | ||
1073 | MPT_ADAPTER *ioc = | ||
1074 | container_of(work, MPT_ADAPTER, fc_rescan_work); | ||
1075 | int ii; | ||
1076 | |||
1077 | for (ii=0; ii < ioc->facts.NumberOfPorts; ii++) | ||
1078 | (void) mptfc_GetFcPortPage0(ioc, ii); | ||
1079 | |||
1080 | } | ||
1081 | |||
1082 | static void | ||
1026 | mptfc_setup_reset(struct work_struct *work) | 1083 | mptfc_setup_reset(struct work_struct *work) |
1027 | { | 1084 | { |
1028 | MPT_ADAPTER *ioc = | 1085 | MPT_ADAPTER *ioc = |
@@ -1163,6 +1220,7 @@ mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id) | |||
1163 | spin_lock_init(&ioc->fc_rescan_work_lock); | 1220 | spin_lock_init(&ioc->fc_rescan_work_lock); |
1164 | INIT_WORK(&ioc->fc_rescan_work, mptfc_rescan_devices); | 1221 | INIT_WORK(&ioc->fc_rescan_work, mptfc_rescan_devices); |
1165 | INIT_WORK(&ioc->fc_setup_reset_work, mptfc_setup_reset); | 1222 | INIT_WORK(&ioc->fc_setup_reset_work, mptfc_setup_reset); |
1223 | INIT_WORK(&ioc->fc_lsc_work, mptfc_link_status_change); | ||
1166 | 1224 | ||
1167 | spin_lock_irqsave(&ioc->FreeQlock, flags); | 1225 | spin_lock_irqsave(&ioc->FreeQlock, flags); |
1168 | 1226 | ||
@@ -1218,20 +1276,21 @@ mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id) | |||
1218 | 1276 | ||
1219 | spin_unlock_irqrestore(&ioc->FreeQlock, flags); | 1277 | spin_unlock_irqrestore(&ioc->FreeQlock, flags); |
1220 | 1278 | ||
1221 | hd = (MPT_SCSI_HOST *) sh->hostdata; | 1279 | hd = shost_priv(sh); |
1222 | hd->ioc = ioc; | 1280 | hd->ioc = ioc; |
1223 | 1281 | ||
1224 | /* SCSI needs scsi_cmnd lookup table! | 1282 | /* SCSI needs scsi_cmnd lookup table! |
1225 | * (with size equal to req_depth*PtrSz!) | 1283 | * (with size equal to req_depth*PtrSz!) |
1226 | */ | 1284 | */ |
1227 | hd->ScsiLookup = kcalloc(ioc->req_depth, sizeof(void *), GFP_ATOMIC); | 1285 | ioc->ScsiLookup = kcalloc(ioc->req_depth, sizeof(void *), GFP_ATOMIC); |
1228 | if (!hd->ScsiLookup) { | 1286 | if (!ioc->ScsiLookup) { |
1229 | error = -ENOMEM; | 1287 | error = -ENOMEM; |
1230 | goto out_mptfc_probe; | 1288 | goto out_mptfc_probe; |
1231 | } | 1289 | } |
1290 | spin_lock_init(&ioc->scsi_lookup_lock); | ||
1232 | 1291 | ||
1233 | dprintk(ioc, printk(MYIOC_s_DEBUG_FMT "ScsiLookup @ %p\n", | 1292 | dprintk(ioc, printk(MYIOC_s_DEBUG_FMT "ScsiLookup @ %p\n", |
1234 | ioc->name, hd->ScsiLookup)); | 1293 | ioc->name, ioc->ScsiLookup)); |
1235 | 1294 | ||
1236 | /* Clear the TM flags | 1295 | /* Clear the TM flags |
1237 | */ | 1296 | */ |
@@ -1262,8 +1321,8 @@ mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id) | |||
1262 | sh->transportt = mptfc_transport_template; | 1321 | sh->transportt = mptfc_transport_template; |
1263 | error = scsi_add_host (sh, &ioc->pcidev->dev); | 1322 | error = scsi_add_host (sh, &ioc->pcidev->dev); |
1264 | if(error) { | 1323 | if(error) { |
1265 | dprintk(ioc, printk(KERN_ERR MYNAM | 1324 | dprintk(ioc, printk(MYIOC_s_ERR_FMT |
1266 | "scsi_add_host failed\n")); | 1325 | "scsi_add_host failed\n", ioc->name)); |
1267 | goto out_mptfc_probe; | 1326 | goto out_mptfc_probe; |
1268 | } | 1327 | } |
1269 | 1328 | ||
@@ -1325,7 +1384,7 @@ mptfc_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply) | |||
1325 | ioc->name, event)); | 1384 | ioc->name, event)); |
1326 | 1385 | ||
1327 | if (ioc->sh == NULL || | 1386 | if (ioc->sh == NULL || |
1328 | ((hd = (MPT_SCSI_HOST *)ioc->sh->hostdata) == NULL)) | 1387 | ((hd = shost_priv(ioc->sh)) == NULL)) |
1329 | return 1; | 1388 | return 1; |
1330 | 1389 | ||
1331 | switch (event) { | 1390 | switch (event) { |
@@ -1337,6 +1396,14 @@ mptfc_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply) | |||
1337 | } | 1396 | } |
1338 | spin_unlock_irqrestore(&ioc->fc_rescan_work_lock, flags); | 1397 | spin_unlock_irqrestore(&ioc->fc_rescan_work_lock, flags); |
1339 | break; | 1398 | break; |
1399 | case MPI_EVENT_LINK_STATUS_CHANGE: | ||
1400 | spin_lock_irqsave(&ioc->fc_rescan_work_lock, flags); | ||
1401 | if (ioc->fc_rescan_work_q) { | ||
1402 | queue_work(ioc->fc_rescan_work_q, | ||
1403 | &ioc->fc_lsc_work); | ||
1404 | } | ||
1405 | spin_unlock_irqrestore(&ioc->fc_rescan_work_lock, flags); | ||
1406 | break; | ||
1340 | default: | 1407 | default: |
1341 | rc = mptscsih_event_process(ioc,pEvReply); | 1408 | rc = mptscsih_event_process(ioc,pEvReply); |
1342 | break; | 1409 | break; |
diff --git a/drivers/message/fusion/mptlan.c b/drivers/message/fusion/mptlan.c index 3da4c37846ec..7950fc678ed1 100644 --- a/drivers/message/fusion/mptlan.c +++ b/drivers/message/fusion/mptlan.c | |||
@@ -1,10 +1,10 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/message/fusion/mptlan.c | 2 | * linux/drivers/message/fusion/mptlan.c |
3 | * IP Over Fibre Channel device driver. | 3 | * IP Over Fibre Channel device driver. |
4 | * For use with LSI Logic Fibre Channel PCI chip/adapters | 4 | * For use with LSI Fibre Channel PCI chip/adapters |
5 | * running LSI Logic Fusion MPT (Message Passing Technology) firmware. | 5 | * running LSI Fusion MPT (Message Passing Technology) firmware. |
6 | * | 6 | * |
7 | * Copyright (c) 2000-2007 LSI Logic Corporation | 7 | * Copyright (c) 2000-2007 LSI Corporation |
8 | * (mailto:DL-MPTFusionLinux@lsi.com) | 8 | * (mailto:DL-MPTFusionLinux@lsi.com) |
9 | * | 9 | * |
10 | */ | 10 | */ |
@@ -154,7 +154,7 @@ static unsigned short mpt_lan_type_trans(struct sk_buff *skb, | |||
154 | /* | 154 | /* |
155 | * Fusion MPT LAN private data | 155 | * Fusion MPT LAN private data |
156 | */ | 156 | */ |
157 | static int LanCtx = -1; | 157 | static u8 LanCtx = MPT_MAX_PROTOCOL_DRIVERS; |
158 | 158 | ||
159 | static u32 max_buckets_out = 127; | 159 | static u32 max_buckets_out = 127; |
160 | static u32 tx_max_out_p = 127 - 16; | 160 | static u32 tx_max_out_p = 127 - 16; |
@@ -165,12 +165,6 @@ DEFINE_RWLOCK(bad_naa_lock); | |||
165 | #endif | 165 | #endif |
166 | 166 | ||
167 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | 167 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ |
168 | /* | ||
169 | * Fusion MPT LAN external data | ||
170 | */ | ||
171 | extern int mpt_lan_index; | ||
172 | |||
173 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | ||
174 | /** | 168 | /** |
175 | * lan_reply - Handle all data sent from the hardware. | 169 | * lan_reply - Handle all data sent from the hardware. |
176 | * @ioc: Pointer to MPT_ADAPTER structure | 170 | * @ioc: Pointer to MPT_ADAPTER structure |
@@ -1230,6 +1224,8 @@ mpt_lan_post_receive_buckets(struct mpt_lan_priv *priv) | |||
1230 | } | 1224 | } |
1231 | pRecvReq = (LANReceivePostRequest_t *) mf; | 1225 | pRecvReq = (LANReceivePostRequest_t *) mf; |
1232 | 1226 | ||
1227 | i = le16_to_cpu(mf->u.frame.hwhdr.msgctxu.fld.req_idx); | ||
1228 | mpt_dev->RequestNB[i] = 0; | ||
1233 | count = buckets; | 1229 | count = buckets; |
1234 | if (count > max) | 1230 | if (count > max) |
1235 | count = max; | 1231 | count = max; |
@@ -1351,10 +1347,11 @@ mpt_lan_post_receive_buckets_work(struct work_struct *work) | |||
1351 | static struct net_device * | 1347 | static struct net_device * |
1352 | mpt_register_lan_device (MPT_ADAPTER *mpt_dev, int pnum) | 1348 | mpt_register_lan_device (MPT_ADAPTER *mpt_dev, int pnum) |
1353 | { | 1349 | { |
1354 | struct net_device *dev = alloc_fcdev(sizeof(struct mpt_lan_priv)); | 1350 | struct net_device *dev; |
1355 | struct mpt_lan_priv *priv = NULL; | 1351 | struct mpt_lan_priv *priv; |
1356 | u8 HWaddr[FC_ALEN], *a; | 1352 | u8 HWaddr[FC_ALEN], *a; |
1357 | 1353 | ||
1354 | dev = alloc_fcdev(sizeof(struct mpt_lan_priv)); | ||
1358 | if (!dev) | 1355 | if (!dev) |
1359 | return NULL; | 1356 | return NULL; |
1360 | 1357 | ||
@@ -1366,7 +1363,6 @@ mpt_register_lan_device (MPT_ADAPTER *mpt_dev, int pnum) | |||
1366 | priv->mpt_dev = mpt_dev; | 1363 | priv->mpt_dev = mpt_dev; |
1367 | priv->pnum = pnum; | 1364 | priv->pnum = pnum; |
1368 | 1365 | ||
1369 | memset(&priv->post_buckets_task, 0, sizeof(priv->post_buckets_task)); | ||
1370 | INIT_DELAYED_WORK(&priv->post_buckets_task, | 1366 | INIT_DELAYED_WORK(&priv->post_buckets_task, |
1371 | mpt_lan_post_receive_buckets_work); | 1367 | mpt_lan_post_receive_buckets_work); |
1372 | priv->post_buckets_active = 0; | 1368 | priv->post_buckets_active = 0; |
@@ -1391,8 +1387,6 @@ mpt_register_lan_device (MPT_ADAPTER *mpt_dev, int pnum) | |||
1391 | spin_lock_init(&priv->txfidx_lock); | 1387 | spin_lock_init(&priv->txfidx_lock); |
1392 | spin_lock_init(&priv->rxfidx_lock); | 1388 | spin_lock_init(&priv->rxfidx_lock); |
1393 | 1389 | ||
1394 | memset(&priv->stats, 0, sizeof(priv->stats)); | ||
1395 | |||
1396 | /* Grab pre-fetched LANPage1 stuff. :-) */ | 1390 | /* Grab pre-fetched LANPage1 stuff. :-) */ |
1397 | a = (u8 *) &mpt_dev->lan_cnfg_page1.HardwareAddressLow; | 1391 | a = (u8 *) &mpt_dev->lan_cnfg_page1.HardwareAddressLow; |
1398 | 1392 | ||
@@ -1508,9 +1502,6 @@ static int __init mpt_lan_init (void) | |||
1508 | return -EBUSY; | 1502 | return -EBUSY; |
1509 | } | 1503 | } |
1510 | 1504 | ||
1511 | /* Set the callback index to be used by driver core for turbo replies */ | ||
1512 | mpt_lan_index = LanCtx; | ||
1513 | |||
1514 | dlprintk((KERN_INFO MYNAM ": assigned context of %d\n", LanCtx)); | 1505 | dlprintk((KERN_INFO MYNAM ": assigned context of %d\n", LanCtx)); |
1515 | 1506 | ||
1516 | if (mpt_reset_register(LanCtx, mpt_lan_ioc_reset)) { | 1507 | if (mpt_reset_register(LanCtx, mpt_lan_ioc_reset)) { |
@@ -1531,10 +1522,9 @@ static void __exit mpt_lan_exit(void) | |||
1531 | mpt_device_driver_deregister(MPTLAN_DRIVER); | 1522 | mpt_device_driver_deregister(MPTLAN_DRIVER); |
1532 | mpt_reset_deregister(LanCtx); | 1523 | mpt_reset_deregister(LanCtx); |
1533 | 1524 | ||
1534 | if (LanCtx >= 0) { | 1525 | if (LanCtx) { |
1535 | mpt_deregister(LanCtx); | 1526 | mpt_deregister(LanCtx); |
1536 | LanCtx = -1; | 1527 | LanCtx = MPT_MAX_PROTOCOL_DRIVERS; |
1537 | mpt_lan_index = 0; | ||
1538 | } | 1528 | } |
1539 | } | 1529 | } |
1540 | 1530 | ||
diff --git a/drivers/message/fusion/mptlan.h b/drivers/message/fusion/mptlan.h index 8d08c2bed24a..bafb67fc8181 100644 --- a/drivers/message/fusion/mptlan.h +++ b/drivers/message/fusion/mptlan.h | |||
@@ -1,10 +1,10 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/message/fusion/mptlan.h | 2 | * linux/drivers/message/fusion/mptlan.h |
3 | * IP Over Fibre Channel device driver. | 3 | * IP Over Fibre Channel device driver. |
4 | * For use with LSI Logic Fibre Channel PCI chip/adapters | 4 | * For use with LSI Fibre Channel PCI chip/adapters |
5 | * running LSI Logic Fusion MPT (Message Passing Technology) firmware. | 5 | * running LSI Fusion MPT (Message Passing Technology) firmware. |
6 | * | 6 | * |
7 | * Copyright (c) 2000-2007 LSI Logic Corporation | 7 | * Copyright (c) 2000-2007 LSI Corporation |
8 | * (mailto:DL-MPTFusionLinux@lsi.com) | 8 | * (mailto:DL-MPTFusionLinux@lsi.com) |
9 | * | 9 | * |
10 | */ | 10 | */ |
@@ -75,7 +75,7 @@ | |||
75 | #include <asm/io.h> | 75 | #include <asm/io.h> |
76 | 76 | ||
77 | /* Override mptbase.h by pre-defining these! */ | 77 | /* Override mptbase.h by pre-defining these! */ |
78 | #define MODULEAUTHOR "LSI Logic Corporation" | 78 | #define MODULEAUTHOR "LSI Corporation" |
79 | 79 | ||
80 | #include "mptbase.h" | 80 | #include "mptbase.h" |
81 | 81 | ||
diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c index b9c69bff218c..e4c94f93de16 100644 --- a/drivers/message/fusion/mptsas.c +++ b/drivers/message/fusion/mptsas.c | |||
@@ -1,11 +1,10 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/message/fusion/mptsas.c | 2 | * linux/drivers/message/fusion/mptsas.c |
3 | * For use with LSI Logic PCI chip/adapter(s) | 3 | * For use with LSI PCI chip/adapter(s) |
4 | * running LSI Logic Fusion MPT (Message Passing Technology) firmware. | 4 | * running LSI Fusion MPT (Message Passing Technology) firmware. |
5 | * | 5 | * |
6 | * Copyright (c) 1999-2007 LSI Logic Corporation | 6 | * Copyright (c) 1999-2007 LSI Corporation |
7 | * (mailto:DL-MPTFusionLinux@lsi.com) | 7 | * (mailto:DL-MPTFusionLinux@lsi.com) |
8 | * Copyright (c) 2005-2007 Dell | ||
9 | */ | 8 | */ |
10 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | 9 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ |
11 | /* | 10 | /* |
@@ -61,6 +60,7 @@ | |||
61 | 60 | ||
62 | #include "mptbase.h" | 61 | #include "mptbase.h" |
63 | #include "mptscsih.h" | 62 | #include "mptscsih.h" |
63 | #include "mptsas.h" | ||
64 | 64 | ||
65 | 65 | ||
66 | #define my_NAME "Fusion MPT SAS Host driver" | 66 | #define my_NAME "Fusion MPT SAS Host driver" |
@@ -89,134 +89,35 @@ static int max_lun = MPTSAS_MAX_LUN; | |||
89 | module_param(max_lun, int, 0); | 89 | module_param(max_lun, int, 0); |
90 | MODULE_PARM_DESC(max_lun, " max lun, default=16895 "); | 90 | MODULE_PARM_DESC(max_lun, " max lun, default=16895 "); |
91 | 91 | ||
92 | static int mptsasDoneCtx = -1; | 92 | static u8 mptsasDoneCtx = MPT_MAX_PROTOCOL_DRIVERS; |
93 | static int mptsasTaskCtx = -1; | 93 | static u8 mptsasTaskCtx = MPT_MAX_PROTOCOL_DRIVERS; |
94 | static int mptsasInternalCtx = -1; /* Used only for internal commands */ | 94 | static u8 mptsasInternalCtx = MPT_MAX_PROTOCOL_DRIVERS; /* Used only for internal commands */ |
95 | static int mptsasMgmtCtx = -1; | 95 | static u8 mptsasMgmtCtx = MPT_MAX_PROTOCOL_DRIVERS; |
96 | 96 | ||
97 | static void mptsas_hotplug_work(struct work_struct *work); | 97 | static void mptsas_hotplug_work(struct work_struct *work); |
98 | 98 | ||
99 | struct mptsas_target_reset_event { | ||
100 | struct list_head list; | ||
101 | EVENT_DATA_SAS_DEVICE_STATUS_CHANGE sas_event_data; | ||
102 | u8 target_reset_issued; | ||
103 | }; | ||
104 | |||
105 | enum mptsas_hotplug_action { | ||
106 | MPTSAS_ADD_DEVICE, | ||
107 | MPTSAS_DEL_DEVICE, | ||
108 | MPTSAS_ADD_RAID, | ||
109 | MPTSAS_DEL_RAID, | ||
110 | MPTSAS_ADD_INACTIVE_VOLUME, | ||
111 | MPTSAS_IGNORE_EVENT, | ||
112 | }; | ||
113 | |||
114 | struct mptsas_hotplug_event { | ||
115 | struct work_struct work; | ||
116 | MPT_ADAPTER *ioc; | ||
117 | enum mptsas_hotplug_action event_type; | ||
118 | u64 sas_address; | ||
119 | u8 channel; | ||
120 | u8 id; | ||
121 | u32 device_info; | ||
122 | u16 handle; | ||
123 | u16 parent_handle; | ||
124 | u8 phy_id; | ||
125 | u8 phys_disk_num_valid; /* hrc (hidden raid component) */ | ||
126 | u8 phys_disk_num; /* hrc - unique index*/ | ||
127 | u8 hidden_raid_component; /* hrc - don't expose*/ | ||
128 | }; | ||
129 | |||
130 | struct mptsas_discovery_event { | ||
131 | struct work_struct work; | ||
132 | MPT_ADAPTER *ioc; | ||
133 | }; | ||
134 | |||
135 | /* | ||
136 | * SAS topology structures | ||
137 | * | ||
138 | * The MPT Fusion firmware interface spreads information about the | ||
139 | * SAS topology over many manufacture pages, thus we need some data | ||
140 | * structure to collect it and process it for the SAS transport class. | ||
141 | */ | ||
142 | |||
143 | struct mptsas_devinfo { | ||
144 | u16 handle; /* unique id to address this device */ | ||
145 | u16 handle_parent; /* unique id to address parent device */ | ||
146 | u16 handle_enclosure; /* enclosure identifier of the enclosure */ | ||
147 | u16 slot; /* physical slot in enclosure */ | ||
148 | u8 phy_id; /* phy number of parent device */ | ||
149 | u8 port_id; /* sas physical port this device | ||
150 | is assoc'd with */ | ||
151 | u8 id; /* logical target id of this device */ | ||
152 | u32 phys_disk_num; /* phys disk id, for csmi-ioctls */ | ||
153 | u8 channel; /* logical bus number of this device */ | ||
154 | u64 sas_address; /* WWN of this device, | ||
155 | SATA is assigned by HBA,expander */ | ||
156 | u32 device_info; /* bitfield detailed info about this device */ | ||
157 | }; | ||
158 | |||
159 | /* | ||
160 | * Specific details on ports, wide/narrow | ||
161 | */ | ||
162 | struct mptsas_portinfo_details{ | ||
163 | u16 num_phys; /* number of phys belong to this port */ | ||
164 | u64 phy_bitmask; /* TODO, extend support for 255 phys */ | ||
165 | struct sas_rphy *rphy; /* transport layer rphy object */ | ||
166 | struct sas_port *port; /* transport layer port object */ | ||
167 | struct scsi_target *starget; | ||
168 | struct mptsas_portinfo *port_info; | ||
169 | }; | ||
170 | |||
171 | struct mptsas_phyinfo { | ||
172 | u16 handle; /* unique id to address this */ | ||
173 | u8 phy_id; /* phy index */ | ||
174 | u8 port_id; /* firmware port identifier */ | ||
175 | u8 negotiated_link_rate; /* nego'd link rate for this phy */ | ||
176 | u8 hw_link_rate; /* hardware max/min phys link rate */ | ||
177 | u8 programmed_link_rate; /* programmed max/min phy link rate */ | ||
178 | u8 sas_port_add_phy; /* flag to request sas_port_add_phy*/ | ||
179 | struct mptsas_devinfo identify; /* point to phy device info */ | ||
180 | struct mptsas_devinfo attached; /* point to attached device info */ | ||
181 | struct sas_phy *phy; /* transport layer phy object */ | ||
182 | struct mptsas_portinfo *portinfo; | ||
183 | struct mptsas_portinfo_details * port_details; | ||
184 | }; | ||
185 | |||
186 | struct mptsas_portinfo { | ||
187 | struct list_head list; | ||
188 | u16 num_phys; /* number of phys */ | ||
189 | struct mptsas_phyinfo *phy_info; | ||
190 | }; | ||
191 | |||
192 | struct mptsas_enclosure { | ||
193 | u64 enclosure_logical_id; /* The WWN for the enclosure */ | ||
194 | u16 enclosure_handle; /* unique id to address this */ | ||
195 | u16 flags; /* details enclosure management */ | ||
196 | u16 num_slot; /* num slots */ | ||
197 | u16 start_slot; /* first slot */ | ||
198 | u8 start_id; /* starting logical target id */ | ||
199 | u8 start_channel; /* starting logical channel id */ | ||
200 | u8 sep_id; /* SEP device logical target id */ | ||
201 | u8 sep_channel; /* SEP channel logical channel id */ | ||
202 | }; | ||
203 | |||
204 | static void mptsas_print_phy_data(MPT_ADAPTER *ioc, | 99 | static void mptsas_print_phy_data(MPT_ADAPTER *ioc, |
205 | MPI_SAS_IO_UNIT0_PHY_DATA *phy_data) | 100 | MPI_SAS_IO_UNIT0_PHY_DATA *phy_data) |
206 | { | 101 | { |
207 | dsasprintk(ioc, printk(KERN_DEBUG "---- IO UNIT PAGE 0 ------------\n")); | 102 | dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT |
208 | dsasprintk(ioc, printk(KERN_DEBUG "Handle=0x%X\n", | 103 | "---- IO UNIT PAGE 0 ------------\n", ioc->name)); |
209 | le16_to_cpu(phy_data->AttachedDeviceHandle))); | 104 | dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Handle=0x%X\n", |
210 | dsasprintk(ioc, printk(KERN_DEBUG "Controller Handle=0x%X\n", | 105 | ioc->name, le16_to_cpu(phy_data->AttachedDeviceHandle))); |
211 | le16_to_cpu(phy_data->ControllerDevHandle))); | 106 | dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Controller Handle=0x%X\n", |
212 | dsasprintk(ioc, printk(KERN_DEBUG "Port=0x%X\n", phy_data->Port)); | 107 | ioc->name, le16_to_cpu(phy_data->ControllerDevHandle))); |
213 | dsasprintk(ioc, printk(KERN_DEBUG "Port Flags=0x%X\n", phy_data->PortFlags)); | 108 | dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Port=0x%X\n", |
214 | dsasprintk(ioc, printk(KERN_DEBUG "PHY Flags=0x%X\n", phy_data->PhyFlags)); | 109 | ioc->name, phy_data->Port)); |
215 | dsasprintk(ioc, printk(KERN_DEBUG "Negotiated Link Rate=0x%X\n", phy_data->NegotiatedLinkRate)); | 110 | dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Port Flags=0x%X\n", |
216 | dsasprintk(ioc, printk(KERN_DEBUG "Controller PHY Device Info=0x%X\n", | 111 | ioc->name, phy_data->PortFlags)); |
217 | le32_to_cpu(phy_data->ControllerPhyDeviceInfo))); | 112 | dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "PHY Flags=0x%X\n", |
218 | dsasprintk(ioc, printk(KERN_DEBUG "DiscoveryStatus=0x%X\n\n", | 113 | ioc->name, phy_data->PhyFlags)); |
219 | le32_to_cpu(phy_data->DiscoveryStatus))); | 114 | dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Negotiated Link Rate=0x%X\n", |
115 | ioc->name, phy_data->NegotiatedLinkRate)); | ||
116 | dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT | ||
117 | "Controller PHY Device Info=0x%X\n", ioc->name, | ||
118 | le32_to_cpu(phy_data->ControllerPhyDeviceInfo))); | ||
119 | dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "DiscoveryStatus=0x%X\n\n", | ||
120 | ioc->name, le32_to_cpu(phy_data->DiscoveryStatus))); | ||
220 | } | 121 | } |
221 | 122 | ||
222 | static void mptsas_print_phy_pg0(MPT_ADAPTER *ioc, SasPhyPage0_t *pg0) | 123 | static void mptsas_print_phy_pg0(MPT_ADAPTER *ioc, SasPhyPage0_t *pg0) |
@@ -225,27 +126,41 @@ static void mptsas_print_phy_pg0(MPT_ADAPTER *ioc, SasPhyPage0_t *pg0) | |||
225 | 126 | ||
226 | memcpy(&sas_address, &pg0->SASAddress, sizeof(__le64)); | 127 | memcpy(&sas_address, &pg0->SASAddress, sizeof(__le64)); |
227 | 128 | ||
228 | dsasprintk(ioc, printk(KERN_DEBUG "---- SAS PHY PAGE 0 ------------\n")); | 129 | dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT |
229 | dsasprintk(ioc, printk(KERN_DEBUG "Attached Device Handle=0x%X\n", | 130 | "---- SAS PHY PAGE 0 ------------\n", ioc->name)); |
230 | le16_to_cpu(pg0->AttachedDevHandle))); | 131 | dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT |
231 | dsasprintk(ioc, printk(KERN_DEBUG "SAS Address=0x%llX\n", | 132 | "Attached Device Handle=0x%X\n", ioc->name, |
232 | (unsigned long long)le64_to_cpu(sas_address))); | 133 | le16_to_cpu(pg0->AttachedDevHandle))); |
233 | dsasprintk(ioc, printk(KERN_DEBUG "Attached PHY Identifier=0x%X\n", pg0->AttachedPhyIdentifier)); | 134 | dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "SAS Address=0x%llX\n", |
234 | dsasprintk(ioc, printk(KERN_DEBUG "Attached Device Info=0x%X\n", | 135 | ioc->name, (unsigned long long)le64_to_cpu(sas_address))); |
235 | le32_to_cpu(pg0->AttachedDeviceInfo))); | 136 | dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT |
236 | dsasprintk(ioc, printk(KERN_DEBUG "Programmed Link Rate=0x%X\n", pg0->ProgrammedLinkRate)); | 137 | "Attached PHY Identifier=0x%X\n", ioc->name, |
237 | dsasprintk(ioc, printk(KERN_DEBUG "Change Count=0x%X\n", pg0->ChangeCount)); | 138 | pg0->AttachedPhyIdentifier)); |
238 | dsasprintk(ioc, printk(KERN_DEBUG "PHY Info=0x%X\n\n", le32_to_cpu(pg0->PhyInfo))); | 139 | dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Attached Device Info=0x%X\n", |
140 | ioc->name, le32_to_cpu(pg0->AttachedDeviceInfo))); | ||
141 | dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Programmed Link Rate=0x%X\n", | ||
142 | ioc->name, pg0->ProgrammedLinkRate)); | ||
143 | dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Change Count=0x%X\n", | ||
144 | ioc->name, pg0->ChangeCount)); | ||
145 | dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "PHY Info=0x%X\n\n", | ||
146 | ioc->name, le32_to_cpu(pg0->PhyInfo))); | ||
239 | } | 147 | } |
240 | 148 | ||
241 | static void mptsas_print_phy_pg1(MPT_ADAPTER *ioc, SasPhyPage1_t *pg1) | 149 | static void mptsas_print_phy_pg1(MPT_ADAPTER *ioc, SasPhyPage1_t *pg1) |
242 | { | 150 | { |
243 | dsasprintk(ioc, printk(KERN_DEBUG "---- SAS PHY PAGE 1 ------------\n")); | 151 | dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT |
244 | dsasprintk(ioc, printk(KERN_DEBUG "Invalid Dword Count=0x%x\n", pg1->InvalidDwordCount)); | 152 | "---- SAS PHY PAGE 1 ------------\n", ioc->name)); |
245 | dsasprintk(ioc, printk(KERN_DEBUG "Running Disparity Error Count=0x%x\n", | 153 | dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Invalid Dword Count=0x%x\n", |
246 | pg1->RunningDisparityErrorCount)); | 154 | ioc->name, pg1->InvalidDwordCount)); |
247 | dsasprintk(ioc, printk(KERN_DEBUG "Loss Dword Synch Count=0x%x\n", pg1->LossDwordSynchCount)); | 155 | dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT |
248 | dsasprintk(ioc, printk(KERN_DEBUG "PHY Reset Problem Count=0x%x\n\n", pg1->PhyResetProblemCount)); | 156 | "Running Disparity Error Count=0x%x\n", ioc->name, |
157 | pg1->RunningDisparityErrorCount)); | ||
158 | dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT | ||
159 | "Loss Dword Synch Count=0x%x\n", ioc->name, | ||
160 | pg1->LossDwordSynchCount)); | ||
161 | dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT | ||
162 | "PHY Reset Problem Count=0x%x\n\n", ioc->name, | ||
163 | pg1->PhyResetProblemCount)); | ||
249 | } | 164 | } |
250 | 165 | ||
251 | static void mptsas_print_device_pg0(MPT_ADAPTER *ioc, SasDevicePage0_t *pg0) | 166 | static void mptsas_print_device_pg0(MPT_ADAPTER *ioc, SasDevicePage0_t *pg0) |
@@ -254,37 +169,53 @@ static void mptsas_print_device_pg0(MPT_ADAPTER *ioc, SasDevicePage0_t *pg0) | |||
254 | 169 | ||
255 | memcpy(&sas_address, &pg0->SASAddress, sizeof(__le64)); | 170 | memcpy(&sas_address, &pg0->SASAddress, sizeof(__le64)); |
256 | 171 | ||
257 | dsasprintk(ioc, printk(KERN_DEBUG "---- SAS DEVICE PAGE 0 ---------\n")); | 172 | dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT |
258 | dsasprintk(ioc, printk(KERN_DEBUG "Handle=0x%X\n" ,le16_to_cpu(pg0->DevHandle))); | 173 | "---- SAS DEVICE PAGE 0 ---------\n", ioc->name)); |
259 | dsasprintk(ioc, printk(KERN_DEBUG "Parent Handle=0x%X\n" ,le16_to_cpu(pg0->ParentDevHandle))); | 174 | dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Handle=0x%X\n", |
260 | dsasprintk(ioc, printk(KERN_DEBUG "Enclosure Handle=0x%X\n", le16_to_cpu(pg0->EnclosureHandle))); | 175 | ioc->name, le16_to_cpu(pg0->DevHandle))); |
261 | dsasprintk(ioc, printk(KERN_DEBUG "Slot=0x%X\n", le16_to_cpu(pg0->Slot))); | 176 | dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Parent Handle=0x%X\n", |
262 | dsasprintk(ioc, printk(KERN_DEBUG "SAS Address=0x%llX\n", (unsigned long long) | 177 | ioc->name, le16_to_cpu(pg0->ParentDevHandle))); |
263 | le64_to_cpu(sas_address))); | 178 | dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Enclosure Handle=0x%X\n", |
264 | dsasprintk(ioc, printk(KERN_DEBUG "Target ID=0x%X\n", pg0->TargetID)); | 179 | ioc->name, le16_to_cpu(pg0->EnclosureHandle))); |
265 | dsasprintk(ioc, printk(KERN_DEBUG "Bus=0x%X\n", pg0->Bus)); | 180 | dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Slot=0x%X\n", |
266 | /* The PhyNum field specifies the PHY number of the parent | 181 | ioc->name, le16_to_cpu(pg0->Slot))); |
267 | * device this device is linked to | 182 | dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "SAS Address=0x%llX\n", |
268 | */ | 183 | ioc->name, (unsigned long long)le64_to_cpu(sas_address))); |
269 | dsasprintk(ioc, printk(KERN_DEBUG "Parent Phy Num=0x%X\n", pg0->PhyNum)); | 184 | dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Target ID=0x%X\n", |
270 | dsasprintk(ioc, printk(KERN_DEBUG "Access Status=0x%X\n", le16_to_cpu(pg0->AccessStatus))); | 185 | ioc->name, pg0->TargetID)); |
271 | dsasprintk(ioc, printk(KERN_DEBUG "Device Info=0x%X\n", le32_to_cpu(pg0->DeviceInfo))); | 186 | dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Bus=0x%X\n", |
272 | dsasprintk(ioc, printk(KERN_DEBUG "Flags=0x%X\n", le16_to_cpu(pg0->Flags))); | 187 | ioc->name, pg0->Bus)); |
273 | dsasprintk(ioc, printk(KERN_DEBUG "Physical Port=0x%X\n\n", pg0->PhysicalPort)); | 188 | dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Parent Phy Num=0x%X\n", |
189 | ioc->name, pg0->PhyNum)); | ||
190 | dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Access Status=0x%X\n", | ||
191 | ioc->name, le16_to_cpu(pg0->AccessStatus))); | ||
192 | dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Device Info=0x%X\n", | ||
193 | ioc->name, le32_to_cpu(pg0->DeviceInfo))); | ||
194 | dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Flags=0x%X\n", | ||
195 | ioc->name, le16_to_cpu(pg0->Flags))); | ||
196 | dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Physical Port=0x%X\n\n", | ||
197 | ioc->name, pg0->PhysicalPort)); | ||
274 | } | 198 | } |
275 | 199 | ||
276 | static void mptsas_print_expander_pg1(MPT_ADAPTER *ioc, SasExpanderPage1_t *pg1) | 200 | static void mptsas_print_expander_pg1(MPT_ADAPTER *ioc, SasExpanderPage1_t *pg1) |
277 | { | 201 | { |
278 | dsasprintk(ioc, printk(KERN_DEBUG "---- SAS EXPANDER PAGE 1 ------------\n")); | 202 | dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT |
279 | dsasprintk(ioc, printk(KERN_DEBUG "Physical Port=0x%X\n", pg1->PhysicalPort)); | 203 | "---- SAS EXPANDER PAGE 1 ------------\n", ioc->name)); |
280 | dsasprintk(ioc, printk(KERN_DEBUG "PHY Identifier=0x%X\n", pg1->PhyIdentifier)); | 204 | dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Physical Port=0x%X\n", |
281 | dsasprintk(ioc, printk(KERN_DEBUG "Negotiated Link Rate=0x%X\n", pg1->NegotiatedLinkRate)); | 205 | ioc->name, pg1->PhysicalPort)); |
282 | dsasprintk(ioc, printk(KERN_DEBUG "Programmed Link Rate=0x%X\n", pg1->ProgrammedLinkRate)); | 206 | dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "PHY Identifier=0x%X\n", |
283 | dsasprintk(ioc, printk(KERN_DEBUG "Hardware Link Rate=0x%X\n", pg1->HwLinkRate)); | 207 | ioc->name, pg1->PhyIdentifier)); |
284 | dsasprintk(ioc, printk(KERN_DEBUG "Owner Device Handle=0x%X\n", | 208 | dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Negotiated Link Rate=0x%X\n", |
285 | le16_to_cpu(pg1->OwnerDevHandle))); | 209 | ioc->name, pg1->NegotiatedLinkRate)); |
286 | dsasprintk(ioc, printk(KERN_DEBUG "Attached Device Handle=0x%X\n\n", | 210 | dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Programmed Link Rate=0x%X\n", |
287 | le16_to_cpu(pg1->AttachedDevHandle))); | 211 | ioc->name, pg1->ProgrammedLinkRate)); |
212 | dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Hardware Link Rate=0x%X\n", | ||
213 | ioc->name, pg1->HwLinkRate)); | ||
214 | dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Owner Device Handle=0x%X\n", | ||
215 | ioc->name, le16_to_cpu(pg1->OwnerDevHandle))); | ||
216 | dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT | ||
217 | "Attached Device Handle=0x%X\n\n", ioc->name, | ||
218 | le16_to_cpu(pg1->AttachedDevHandle))); | ||
288 | } | 219 | } |
289 | 220 | ||
290 | static inline MPT_ADAPTER *phy_to_ioc(struct sas_phy *phy) | 221 | static inline MPT_ADAPTER *phy_to_ioc(struct sas_phy *phy) |
@@ -354,8 +285,8 @@ mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_detai | |||
354 | port_info = port_details->port_info; | 285 | port_info = port_details->port_info; |
355 | phy_info = port_info->phy_info; | 286 | phy_info = port_info->phy_info; |
356 | 287 | ||
357 | dsaswideprintk(ioc, printk(KERN_DEBUG "%s: [%p]: num_phys=%02d " | 288 | dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "%s: [%p]: num_phys=%02d " |
358 | "bitmask=0x%016llX\n", __FUNCTION__, port_details, | 289 | "bitmask=0x%016llX\n", ioc->name, __FUNCTION__, port_details, |
359 | port_details->num_phys, (unsigned long long) | 290 | port_details->num_phys, (unsigned long long) |
360 | port_details->phy_bitmask)); | 291 | port_details->phy_bitmask)); |
361 | 292 | ||
@@ -382,14 +313,15 @@ mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rp | |||
382 | { | 313 | { |
383 | if (phy_info->port_details) { | 314 | if (phy_info->port_details) { |
384 | phy_info->port_details->rphy = rphy; | 315 | phy_info->port_details->rphy = rphy; |
385 | dsaswideprintk(ioc, printk(KERN_DEBUG "sas_rphy_add: rphy=%p\n", rphy)); | 316 | dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n", |
317 | ioc->name, rphy)); | ||
386 | } | 318 | } |
387 | 319 | ||
388 | if (rphy) { | 320 | if (rphy) { |
389 | dsaswideprintk(ioc, dev_printk(KERN_DEBUG, | 321 | dsaswideprintk(ioc, dev_printk(KERN_DEBUG, |
390 | &rphy->dev, "add:")); | 322 | &rphy->dev, MYIOC_s_FMT "add:", ioc->name)); |
391 | dsaswideprintk(ioc, printk(KERN_DEBUG "rphy=%p release=%p\n", | 323 | dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n", |
392 | rphy, rphy->dev.release)); | 324 | ioc->name, rphy, rphy->dev.release)); |
393 | } | 325 | } |
394 | } | 326 | } |
395 | 327 | ||
@@ -410,9 +342,9 @@ mptsas_set_port(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_po | |||
410 | 342 | ||
411 | if (port) { | 343 | if (port) { |
412 | dsaswideprintk(ioc, dev_printk(KERN_DEBUG, | 344 | dsaswideprintk(ioc, dev_printk(KERN_DEBUG, |
413 | &port->dev, "add:")); | 345 | &port->dev, MYIOC_s_FMT "add:", ioc->name)); |
414 | dsaswideprintk(ioc, printk(KERN_DEBUG "port=%p release=%p\n", | 346 | dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "port=%p release=%p\n", |
415 | port, port->dev.release)); | 347 | ioc->name, port, port->dev.release)); |
416 | } | 348 | } |
417 | } | 349 | } |
418 | 350 | ||
@@ -463,9 +395,9 @@ mptsas_setup_wide_ports(MPT_ADAPTER *ioc, struct mptsas_portinfo *port_info) | |||
463 | * Removing a phy from a port, letting the last | 395 | * Removing a phy from a port, letting the last |
464 | * phy be removed by firmware events. | 396 | * phy be removed by firmware events. |
465 | */ | 397 | */ |
466 | dsaswideprintk(ioc, printk(KERN_DEBUG | 398 | dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT |
467 | "%s: [%p]: deleting phy = %d\n", | 399 | "%s: [%p]: deleting phy = %d\n", |
468 | __FUNCTION__, port_details, i)); | 400 | ioc->name, __FUNCTION__, port_details, i)); |
469 | port_details->num_phys--; | 401 | port_details->num_phys--; |
470 | port_details->phy_bitmask &= ~ (1 << phy_info->phy_id); | 402 | port_details->phy_bitmask &= ~ (1 << phy_info->phy_id); |
471 | memset(&phy_info->attached, 0, sizeof(struct mptsas_devinfo)); | 403 | memset(&phy_info->attached, 0, sizeof(struct mptsas_devinfo)); |
@@ -479,8 +411,8 @@ mptsas_setup_wide_ports(MPT_ADAPTER *ioc, struct mptsas_portinfo *port_info) | |||
479 | phy_info = port_info->phy_info; | 411 | phy_info = port_info->phy_info; |
480 | for (i = 0 ; i < port_info->num_phys ; i++, phy_info++) { | 412 | for (i = 0 ; i < port_info->num_phys ; i++, phy_info++) { |
481 | sas_address = phy_info->attached.sas_address; | 413 | sas_address = phy_info->attached.sas_address; |
482 | dsaswideprintk(ioc, printk(KERN_DEBUG "phy_id=%d sas_address=0x%018llX\n", | 414 | dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "phy_id=%d sas_address=0x%018llX\n", |
483 | i, (unsigned long long)sas_address)); | 415 | ioc->name, i, (unsigned long long)sas_address)); |
484 | if (!sas_address) | 416 | if (!sas_address) |
485 | continue; | 417 | continue; |
486 | port_details = phy_info->port_details; | 418 | port_details = phy_info->port_details; |
@@ -498,9 +430,9 @@ mptsas_setup_wide_ports(MPT_ADAPTER *ioc, struct mptsas_portinfo *port_info) | |||
498 | port_details->phy_bitmask |= | 430 | port_details->phy_bitmask |= |
499 | (1 << phy_info->phy_id); | 431 | (1 << phy_info->phy_id); |
500 | phy_info->sas_port_add_phy=1; | 432 | phy_info->sas_port_add_phy=1; |
501 | dsaswideprintk(ioc, printk(KERN_DEBUG "\t\tForming port\n\t\t" | 433 | dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "\t\tForming port\n\t\t" |
502 | "phy_id=%d sas_address=0x%018llX\n", | 434 | "phy_id=%d sas_address=0x%018llX\n", |
503 | i, (unsigned long long)sas_address)); | 435 | ioc->name, i, (unsigned long long)sas_address)); |
504 | phy_info->port_details = port_details; | 436 | phy_info->port_details = port_details; |
505 | } | 437 | } |
506 | 438 | ||
@@ -515,9 +447,9 @@ mptsas_setup_wide_ports(MPT_ADAPTER *ioc, struct mptsas_portinfo *port_info) | |||
515 | continue; | 447 | continue; |
516 | if (phy_info_cmp->port_details == port_details ) | 448 | if (phy_info_cmp->port_details == port_details ) |
517 | continue; | 449 | continue; |
518 | dsaswideprintk(ioc, printk(KERN_DEBUG | 450 | dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT |
519 | "\t\tphy_id=%d sas_address=0x%018llX\n", | 451 | "\t\tphy_id=%d sas_address=0x%018llX\n", |
520 | j, (unsigned long long) | 452 | ioc->name, j, (unsigned long long) |
521 | phy_info_cmp->attached.sas_address)); | 453 | phy_info_cmp->attached.sas_address)); |
522 | if (phy_info_cmp->port_details) { | 454 | if (phy_info_cmp->port_details) { |
523 | port_details->rphy = | 455 | port_details->rphy = |
@@ -549,15 +481,15 @@ mptsas_setup_wide_ports(MPT_ADAPTER *ioc, struct mptsas_portinfo *port_info) | |||
549 | port_details = port_info->phy_info[i].port_details; | 481 | port_details = port_info->phy_info[i].port_details; |
550 | if (!port_details) | 482 | if (!port_details) |
551 | continue; | 483 | continue; |
552 | dsaswideprintk(ioc, printk(KERN_DEBUG | 484 | dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT |
553 | "%s: [%p]: phy_id=%02d num_phys=%02d " | 485 | "%s: [%p]: phy_id=%02d num_phys=%02d " |
554 | "bitmask=0x%016llX\n", __FUNCTION__, | 486 | "bitmask=0x%016llX\n", ioc->name, __FUNCTION__, |
555 | port_details, i, port_details->num_phys, | 487 | port_details, i, port_details->num_phys, |
556 | (unsigned long long)port_details->phy_bitmask)); | 488 | (unsigned long long)port_details->phy_bitmask)); |
557 | dsaswideprintk(ioc, printk(KERN_DEBUG"\t\tport = %p rphy=%p\n", | 489 | dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "\t\tport = %p rphy=%p\n", |
558 | port_details->port, port_details->rphy)); | 490 | ioc->name, port_details->port, port_details->rphy)); |
559 | } | 491 | } |
560 | dsaswideprintk(ioc, printk(KERN_DEBUG"\n")); | 492 | dsaswideprintk(ioc, printk("\n")); |
561 | mutex_unlock(&ioc->sas_topology_mutex); | 493 | mutex_unlock(&ioc->sas_topology_mutex); |
562 | } | 494 | } |
563 | 495 | ||
@@ -573,15 +505,15 @@ static VirtTarget * | |||
573 | mptsas_find_vtarget(MPT_ADAPTER *ioc, u8 channel, u8 id) | 505 | mptsas_find_vtarget(MPT_ADAPTER *ioc, u8 channel, u8 id) |
574 | { | 506 | { |
575 | struct scsi_device *sdev; | 507 | struct scsi_device *sdev; |
576 | VirtDevice *vdev; | 508 | VirtDevice *vdevice; |
577 | VirtTarget *vtarget = NULL; | 509 | VirtTarget *vtarget = NULL; |
578 | 510 | ||
579 | shost_for_each_device(sdev, ioc->sh) { | 511 | shost_for_each_device(sdev, ioc->sh) { |
580 | if ((vdev = sdev->hostdata) == NULL) | 512 | if ((vdevice = sdev->hostdata) == NULL) |
581 | continue; | 513 | continue; |
582 | if (vdev->vtarget->id == id && | 514 | if (vdevice->vtarget->id == id && |
583 | vdev->vtarget->channel == channel) | 515 | vdevice->vtarget->channel == channel) |
584 | vtarget = vdev->vtarget; | 516 | vtarget = vdevice->vtarget; |
585 | } | 517 | } |
586 | return vtarget; | 518 | return vtarget; |
587 | } | 519 | } |
@@ -623,13 +555,7 @@ mptsas_target_reset(MPT_ADAPTER *ioc, u8 channel, u8 id) | |||
623 | 555 | ||
624 | DBG_DUMP_TM_REQUEST_FRAME(ioc, (u32 *)mf); | 556 | DBG_DUMP_TM_REQUEST_FRAME(ioc, (u32 *)mf); |
625 | 557 | ||
626 | if (mpt_send_handshake_request(ioc->TaskCtx, ioc, | 558 | mpt_put_msg_frame_hi_pri(ioc->TaskCtx, ioc, mf); |
627 | sizeof(SCSITaskMgmt_t), (u32 *)mf, NO_SLEEP)) { | ||
628 | mpt_free_msg_frame(ioc, mf); | ||
629 | dfailprintk(ioc, printk(MYIOC_s_WARN_FMT "%s, tm handshake failed @%d!!\n", | ||
630 | ioc->name,__FUNCTION__, __LINE__)); | ||
631 | return 0; | ||
632 | } | ||
633 | 559 | ||
634 | return 1; | 560 | return 1; |
635 | } | 561 | } |
@@ -649,7 +575,7 @@ static void | |||
649 | mptsas_target_reset_queue(MPT_ADAPTER *ioc, | 575 | mptsas_target_reset_queue(MPT_ADAPTER *ioc, |
650 | EVENT_DATA_SAS_DEVICE_STATUS_CHANGE *sas_event_data) | 576 | EVENT_DATA_SAS_DEVICE_STATUS_CHANGE *sas_event_data) |
651 | { | 577 | { |
652 | MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)ioc->sh->hostdata; | 578 | MPT_SCSI_HOST *hd = shost_priv(ioc->sh); |
653 | VirtTarget *vtarget = NULL; | 579 | VirtTarget *vtarget = NULL; |
654 | struct mptsas_target_reset_event *target_reset_list; | 580 | struct mptsas_target_reset_event *target_reset_list; |
655 | u8 id, channel; | 581 | u8 id, channel; |
@@ -696,7 +622,7 @@ mptsas_target_reset_queue(MPT_ADAPTER *ioc, | |||
696 | static void | 622 | static void |
697 | mptsas_dev_reset_complete(MPT_ADAPTER *ioc) | 623 | mptsas_dev_reset_complete(MPT_ADAPTER *ioc) |
698 | { | 624 | { |
699 | MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)ioc->sh->hostdata; | 625 | MPT_SCSI_HOST *hd = shost_priv(ioc->sh); |
700 | struct list_head *head = &hd->target_reset_list; | 626 | struct list_head *head = &hd->target_reset_list; |
701 | struct mptsas_target_reset_event *target_reset_list; | 627 | struct mptsas_target_reset_event *target_reset_list; |
702 | struct mptsas_hotplug_event *ev; | 628 | struct mptsas_hotplug_event *ev; |
@@ -813,7 +739,7 @@ mptsas_ioc_reset(MPT_ADAPTER *ioc, int reset_phase) | |||
813 | 739 | ||
814 | if (!ioc->sh || !ioc->sh->hostdata) | 740 | if (!ioc->sh || !ioc->sh->hostdata) |
815 | goto out; | 741 | goto out; |
816 | hd = (MPT_SCSI_HOST *)ioc->sh->hostdata; | 742 | hd = shost_priv(ioc->sh); |
817 | if (!hd->ioc) | 743 | if (!hd->ioc) |
818 | goto out; | 744 | goto out; |
819 | 745 | ||
@@ -913,19 +839,20 @@ static int | |||
913 | mptsas_target_alloc(struct scsi_target *starget) | 839 | mptsas_target_alloc(struct scsi_target *starget) |
914 | { | 840 | { |
915 | struct Scsi_Host *host = dev_to_shost(&starget->dev); | 841 | struct Scsi_Host *host = dev_to_shost(&starget->dev); |
916 | MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; | 842 | MPT_SCSI_HOST *hd = shost_priv(host); |
917 | VirtTarget *vtarget; | 843 | VirtTarget *vtarget; |
918 | u8 id, channel; | 844 | u8 id, channel; |
919 | struct sas_rphy *rphy; | 845 | struct sas_rphy *rphy; |
920 | struct mptsas_portinfo *p; | 846 | struct mptsas_portinfo *p; |
921 | int i; | 847 | int i; |
848 | MPT_ADAPTER *ioc = hd->ioc; | ||
922 | 849 | ||
923 | vtarget = kzalloc(sizeof(VirtTarget), GFP_KERNEL); | 850 | vtarget = kzalloc(sizeof(VirtTarget), GFP_KERNEL); |
924 | if (!vtarget) | 851 | if (!vtarget) |
925 | return -ENOMEM; | 852 | return -ENOMEM; |
926 | 853 | ||
927 | vtarget->starget = starget; | 854 | vtarget->starget = starget; |
928 | vtarget->ioc_id = hd->ioc->id; | 855 | vtarget->ioc_id = ioc->id; |
929 | vtarget->tflags = MPT_TARGET_FLAGS_Q_YES; | 856 | vtarget->tflags = MPT_TARGET_FLAGS_Q_YES; |
930 | id = starget->id; | 857 | id = starget->id; |
931 | channel = 0; | 858 | channel = 0; |
@@ -934,15 +861,15 @@ mptsas_target_alloc(struct scsi_target *starget) | |||
934 | * RAID volumes placed beyond the last expected port. | 861 | * RAID volumes placed beyond the last expected port. |
935 | */ | 862 | */ |
936 | if (starget->channel == MPTSAS_RAID_CHANNEL) { | 863 | if (starget->channel == MPTSAS_RAID_CHANNEL) { |
937 | for (i=0; i < hd->ioc->raid_data.pIocPg2->NumActiveVolumes; i++) | 864 | for (i=0; i < ioc->raid_data.pIocPg2->NumActiveVolumes; i++) |
938 | if (id == hd->ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID) | 865 | if (id == ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID) |
939 | channel = hd->ioc->raid_data.pIocPg2->RaidVolume[i].VolumeBus; | 866 | channel = ioc->raid_data.pIocPg2->RaidVolume[i].VolumeBus; |
940 | goto out; | 867 | goto out; |
941 | } | 868 | } |
942 | 869 | ||
943 | rphy = dev_to_rphy(starget->dev.parent); | 870 | rphy = dev_to_rphy(starget->dev.parent); |
944 | mutex_lock(&hd->ioc->sas_topology_mutex); | 871 | mutex_lock(&ioc->sas_topology_mutex); |
945 | list_for_each_entry(p, &hd->ioc->sas_topology, list) { | 872 | list_for_each_entry(p, &ioc->sas_topology, list) { |
946 | for (i = 0; i < p->num_phys; i++) { | 873 | for (i = 0; i < p->num_phys; i++) { |
947 | if (p->phy_info[i].attached.sas_address != | 874 | if (p->phy_info[i].attached.sas_address != |
948 | rphy->identify.sas_address) | 875 | rphy->identify.sas_address) |
@@ -954,18 +881,18 @@ mptsas_target_alloc(struct scsi_target *starget) | |||
954 | /* | 881 | /* |
955 | * Exposing hidden raid components | 882 | * Exposing hidden raid components |
956 | */ | 883 | */ |
957 | if (mptscsih_is_phys_disk(hd->ioc, channel, id)) { | 884 | if (mptscsih_is_phys_disk(ioc, channel, id)) { |
958 | id = mptscsih_raid_id_to_num(hd->ioc, | 885 | id = mptscsih_raid_id_to_num(ioc, |
959 | channel, id); | 886 | channel, id); |
960 | vtarget->tflags |= | 887 | vtarget->tflags |= |
961 | MPT_TARGET_FLAGS_RAID_COMPONENT; | 888 | MPT_TARGET_FLAGS_RAID_COMPONENT; |
962 | p->phy_info[i].attached.phys_disk_num = id; | 889 | p->phy_info[i].attached.phys_disk_num = id; |
963 | } | 890 | } |
964 | mutex_unlock(&hd->ioc->sas_topology_mutex); | 891 | mutex_unlock(&ioc->sas_topology_mutex); |
965 | goto out; | 892 | goto out; |
966 | } | 893 | } |
967 | } | 894 | } |
968 | mutex_unlock(&hd->ioc->sas_topology_mutex); | 895 | mutex_unlock(&ioc->sas_topology_mutex); |
969 | 896 | ||
970 | kfree(vtarget); | 897 | kfree(vtarget); |
971 | return -ENXIO; | 898 | return -ENXIO; |
@@ -981,10 +908,11 @@ static void | |||
981 | mptsas_target_destroy(struct scsi_target *starget) | 908 | mptsas_target_destroy(struct scsi_target *starget) |
982 | { | 909 | { |
983 | struct Scsi_Host *host = dev_to_shost(&starget->dev); | 910 | struct Scsi_Host *host = dev_to_shost(&starget->dev); |
984 | MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; | 911 | MPT_SCSI_HOST *hd = shost_priv(host); |
985 | struct sas_rphy *rphy; | 912 | struct sas_rphy *rphy; |
986 | struct mptsas_portinfo *p; | 913 | struct mptsas_portinfo *p; |
987 | int i; | 914 | int i; |
915 | MPT_ADAPTER *ioc = hd->ioc; | ||
988 | 916 | ||
989 | if (!starget->hostdata) | 917 | if (!starget->hostdata) |
990 | return; | 918 | return; |
@@ -993,7 +921,7 @@ mptsas_target_destroy(struct scsi_target *starget) | |||
993 | goto out; | 921 | goto out; |
994 | 922 | ||
995 | rphy = dev_to_rphy(starget->dev.parent); | 923 | rphy = dev_to_rphy(starget->dev.parent); |
996 | list_for_each_entry(p, &hd->ioc->sas_topology, list) { | 924 | list_for_each_entry(p, &ioc->sas_topology, list) { |
997 | for (i = 0; i < p->num_phys; i++) { | 925 | for (i = 0; i < p->num_phys; i++) { |
998 | if (p->phy_info[i].attached.sas_address != | 926 | if (p->phy_info[i].attached.sas_address != |
999 | rphy->identify.sas_address) | 927 | rphy->identify.sas_address) |
@@ -1013,61 +941,62 @@ static int | |||
1013 | mptsas_slave_alloc(struct scsi_device *sdev) | 941 | mptsas_slave_alloc(struct scsi_device *sdev) |
1014 | { | 942 | { |
1015 | struct Scsi_Host *host = sdev->host; | 943 | struct Scsi_Host *host = sdev->host; |
1016 | MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; | 944 | MPT_SCSI_HOST *hd = shost_priv(host); |
1017 | struct sas_rphy *rphy; | 945 | struct sas_rphy *rphy; |
1018 | struct mptsas_portinfo *p; | 946 | struct mptsas_portinfo *p; |
1019 | VirtDevice *vdev; | 947 | VirtDevice *vdevice; |
1020 | struct scsi_target *starget; | 948 | struct scsi_target *starget; |
1021 | int i; | 949 | int i; |
950 | MPT_ADAPTER *ioc = hd->ioc; | ||
1022 | 951 | ||
1023 | vdev = kzalloc(sizeof(VirtDevice), GFP_KERNEL); | 952 | vdevice = kzalloc(sizeof(VirtDevice), GFP_KERNEL); |
1024 | if (!vdev) { | 953 | if (!vdevice) { |
1025 | printk(MYIOC_s_ERR_FMT "slave_alloc kzalloc(%zd) FAILED!\n", | 954 | printk(MYIOC_s_ERR_FMT "slave_alloc kzalloc(%zd) FAILED!\n", |
1026 | hd->ioc->name, sizeof(VirtDevice)); | 955 | ioc->name, sizeof(VirtDevice)); |
1027 | return -ENOMEM; | 956 | return -ENOMEM; |
1028 | } | 957 | } |
1029 | starget = scsi_target(sdev); | 958 | starget = scsi_target(sdev); |
1030 | vdev->vtarget = starget->hostdata; | 959 | vdevice->vtarget = starget->hostdata; |
1031 | 960 | ||
1032 | if (sdev->channel == MPTSAS_RAID_CHANNEL) | 961 | if (sdev->channel == MPTSAS_RAID_CHANNEL) |
1033 | goto out; | 962 | goto out; |
1034 | 963 | ||
1035 | rphy = dev_to_rphy(sdev->sdev_target->dev.parent); | 964 | rphy = dev_to_rphy(sdev->sdev_target->dev.parent); |
1036 | mutex_lock(&hd->ioc->sas_topology_mutex); | 965 | mutex_lock(&ioc->sas_topology_mutex); |
1037 | list_for_each_entry(p, &hd->ioc->sas_topology, list) { | 966 | list_for_each_entry(p, &ioc->sas_topology, list) { |
1038 | for (i = 0; i < p->num_phys; i++) { | 967 | for (i = 0; i < p->num_phys; i++) { |
1039 | if (p->phy_info[i].attached.sas_address != | 968 | if (p->phy_info[i].attached.sas_address != |
1040 | rphy->identify.sas_address) | 969 | rphy->identify.sas_address) |
1041 | continue; | 970 | continue; |
1042 | vdev->lun = sdev->lun; | 971 | vdevice->lun = sdev->lun; |
1043 | /* | 972 | /* |
1044 | * Exposing hidden raid components | 973 | * Exposing hidden raid components |
1045 | */ | 974 | */ |
1046 | if (mptscsih_is_phys_disk(hd->ioc, | 975 | if (mptscsih_is_phys_disk(ioc, |
1047 | p->phy_info[i].attached.channel, | 976 | p->phy_info[i].attached.channel, |
1048 | p->phy_info[i].attached.id)) | 977 | p->phy_info[i].attached.id)) |
1049 | sdev->no_uld_attach = 1; | 978 | sdev->no_uld_attach = 1; |
1050 | mutex_unlock(&hd->ioc->sas_topology_mutex); | 979 | mutex_unlock(&ioc->sas_topology_mutex); |
1051 | goto out; | 980 | goto out; |
1052 | } | 981 | } |
1053 | } | 982 | } |
1054 | mutex_unlock(&hd->ioc->sas_topology_mutex); | 983 | mutex_unlock(&ioc->sas_topology_mutex); |
1055 | 984 | ||
1056 | kfree(vdev); | 985 | kfree(vdevice); |
1057 | return -ENXIO; | 986 | return -ENXIO; |
1058 | 987 | ||
1059 | out: | 988 | out: |
1060 | vdev->vtarget->num_luns++; | 989 | vdevice->vtarget->num_luns++; |
1061 | sdev->hostdata = vdev; | 990 | sdev->hostdata = vdevice; |
1062 | return 0; | 991 | return 0; |
1063 | } | 992 | } |
1064 | 993 | ||
1065 | static int | 994 | static int |
1066 | mptsas_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) | 995 | mptsas_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) |
1067 | { | 996 | { |
1068 | VirtDevice *vdev = SCpnt->device->hostdata; | 997 | VirtDevice *vdevice = SCpnt->device->hostdata; |
1069 | 998 | ||
1070 | if (!vdev || !vdev->vtarget || vdev->vtarget->deleted) { | 999 | if (!vdevice || !vdevice->vtarget || vdevice->vtarget->deleted) { |
1071 | SCpnt->result = DID_NO_CONNECT << 16; | 1000 | SCpnt->result = DID_NO_CONNECT << 16; |
1072 | done(SCpnt); | 1001 | done(SCpnt); |
1073 | return 0; | 1002 | return 0; |
@@ -1239,10 +1168,8 @@ static int mptsas_phy_reset(struct sas_phy *phy, int hard_reset) | |||
1239 | /* process the completed Reply Message Frame */ | 1168 | /* process the completed Reply Message Frame */ |
1240 | reply = (SasIoUnitControlReply_t *)ioc->sas_mgmt.reply; | 1169 | reply = (SasIoUnitControlReply_t *)ioc->sas_mgmt.reply; |
1241 | if (reply->IOCStatus != MPI_IOCSTATUS_SUCCESS) { | 1170 | if (reply->IOCStatus != MPI_IOCSTATUS_SUCCESS) { |
1242 | printk("%s: IOCStatus=0x%X IOCLogInfo=0x%X\n", | 1171 | printk(MYIOC_s_INFO_FMT "%s: IOCStatus=0x%X IOCLogInfo=0x%X\n", |
1243 | __FUNCTION__, | 1172 | ioc->name, __FUNCTION__, reply->IOCStatus, reply->IOCLogInfo); |
1244 | reply->IOCStatus, | ||
1245 | reply->IOCLogInfo); | ||
1246 | error = -ENXIO; | 1173 | error = -ENXIO; |
1247 | goto out_unlock; | 1174 | goto out_unlock; |
1248 | } | 1175 | } |
@@ -1328,16 +1255,16 @@ static int mptsas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy, | |||
1328 | u64 sas_address = 0; | 1255 | u64 sas_address = 0; |
1329 | 1256 | ||
1330 | if (!rsp) { | 1257 | if (!rsp) { |
1331 | printk(KERN_ERR "%s: the smp response space is missing\n", | 1258 | printk(MYIOC_s_ERR_FMT "%s: the smp response space is missing\n", |
1332 | __FUNCTION__); | 1259 | ioc->name, __FUNCTION__); |
1333 | return -EINVAL; | 1260 | return -EINVAL; |
1334 | } | 1261 | } |
1335 | 1262 | ||
1336 | /* do we need to support multiple segments? */ | 1263 | /* do we need to support multiple segments? */ |
1337 | if (req->bio->bi_vcnt > 1 || rsp->bio->bi_vcnt > 1) { | 1264 | if (req->bio->bi_vcnt > 1 || rsp->bio->bi_vcnt > 1) { |
1338 | printk(KERN_ERR "%s: multiple segments req %u %u, rsp %u %u\n", | 1265 | printk(MYIOC_s_ERR_FMT "%s: multiple segments req %u %u, rsp %u %u\n", |
1339 | __FUNCTION__, req->bio->bi_vcnt, req->data_len, | 1266 | ioc->name, __FUNCTION__, req->bio->bi_vcnt, req->data_len, |
1340 | rsp->bio->bi_vcnt, rsp->data_len); | 1267 | rsp->bio->bi_vcnt, rsp->data_len); |
1341 | return -EINVAL; | 1268 | return -EINVAL; |
1342 | } | 1269 | } |
1343 | 1270 | ||
@@ -1402,7 +1329,7 @@ static int mptsas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy, | |||
1402 | 1329 | ||
1403 | timeleft = wait_for_completion_timeout(&ioc->sas_mgmt.done, 10 * HZ); | 1330 | timeleft = wait_for_completion_timeout(&ioc->sas_mgmt.done, 10 * HZ); |
1404 | if (!timeleft) { | 1331 | if (!timeleft) { |
1405 | printk(KERN_ERR "%s: smp timeout!\n", __FUNCTION__); | 1332 | printk(MYIOC_s_ERR_FMT "%s: smp timeout!\n", ioc->name, __FUNCTION__); |
1406 | /* On timeout reset the board */ | 1333 | /* On timeout reset the board */ |
1407 | mpt_HardResetHandler(ioc, CAN_SLEEP); | 1334 | mpt_HardResetHandler(ioc, CAN_SLEEP); |
1408 | ret = -ETIMEDOUT; | 1335 | ret = -ETIMEDOUT; |
@@ -1417,8 +1344,8 @@ static int mptsas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy, | |||
1417 | memcpy(req->sense, smprep, sizeof(*smprep)); | 1344 | memcpy(req->sense, smprep, sizeof(*smprep)); |
1418 | req->sense_len = sizeof(*smprep); | 1345 | req->sense_len = sizeof(*smprep); |
1419 | } else { | 1346 | } else { |
1420 | printk(KERN_ERR "%s: smp passthru reply failed to be returned\n", | 1347 | printk(MYIOC_s_ERR_FMT "%s: smp passthru reply failed to be returned\n", |
1421 | __FUNCTION__); | 1348 | ioc->name, __FUNCTION__); |
1422 | ret = -ENXIO; | 1349 | ret = -ENXIO; |
1423 | } | 1350 | } |
1424 | unmap: | 1351 | unmap: |
@@ -2062,12 +1989,12 @@ static int mptsas_probe_one_phy(struct device *dev, | |||
2062 | goto out; | 1989 | goto out; |
2063 | } | 1990 | } |
2064 | mptsas_set_port(ioc, phy_info, port); | 1991 | mptsas_set_port(ioc, phy_info, port); |
2065 | dsaswideprintk(ioc, printk(KERN_DEBUG | 1992 | dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT |
2066 | "sas_port_alloc: port=%p dev=%p port_id=%d\n", | 1993 | "sas_port_alloc: port=%p dev=%p port_id=%d\n", |
2067 | port, dev, port->port_identifier)); | 1994 | ioc->name, port, dev, port->port_identifier)); |
2068 | } | 1995 | } |
2069 | dsaswideprintk(ioc, printk(KERN_DEBUG "sas_port_add_phy: phy_id=%d\n", | 1996 | dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_port_add_phy: phy_id=%d\n", |
2070 | phy_info->phy_id)); | 1997 | ioc->name, phy_info->phy_id)); |
2071 | sas_port_add_phy(port, phy_info->phy); | 1998 | sas_port_add_phy(port, phy_info->phy); |
2072 | phy_info->sas_port_add_phy = 0; | 1999 | phy_info->sas_port_add_phy = 0; |
2073 | } | 2000 | } |
@@ -2369,8 +2296,9 @@ mptsas_delete_expander_phys(MPT_ADAPTER *ioc) | |||
2369 | expander_sas_address) | 2296 | expander_sas_address) |
2370 | continue; | 2297 | continue; |
2371 | dsaswideprintk(ioc, | 2298 | dsaswideprintk(ioc, |
2372 | dev_printk(KERN_DEBUG, &port->dev, | 2299 | dev_printk(KERN_DEBUG, &port->dev, |
2373 | "delete port (%d)\n", port->port_identifier)); | 2300 | MYIOC_s_FMT "delete port (%d)\n", ioc->name, |
2301 | port->port_identifier)); | ||
2374 | sas_port_delete(port); | 2302 | sas_port_delete(port); |
2375 | mptsas_port_delete(ioc, phy_info->port_details); | 2303 | mptsas_port_delete(ioc, phy_info->port_details); |
2376 | } | 2304 | } |
@@ -2613,7 +2541,7 @@ mptsas_adding_inactive_raid_components(MPT_ADAPTER *ioc, u8 channel, u8 id) | |||
2613 | 2541 | ||
2614 | ev = kzalloc(sizeof(*ev), GFP_ATOMIC); | 2542 | ev = kzalloc(sizeof(*ev), GFP_ATOMIC); |
2615 | if (!ev) { | 2543 | if (!ev) { |
2616 | printk(KERN_WARNING "mptsas: lost hotplug event\n"); | 2544 | printk(MYIOC_s_WARN_FMT "mptsas: lost hotplug event\n", ioc->name); |
2617 | goto out; | 2545 | goto out; |
2618 | } | 2546 | } |
2619 | 2547 | ||
@@ -2754,8 +2682,8 @@ mptsas_hotplug_work(struct work_struct *work) | |||
2754 | printk(MYIOC_s_INFO_FMT | 2682 | printk(MYIOC_s_INFO_FMT |
2755 | "removing %s device, channel %d, id %d, phy %d\n", | 2683 | "removing %s device, channel %d, id %d, phy %d\n", |
2756 | ioc->name, ds, ev->channel, ev->id, phy_info->phy_id); | 2684 | ioc->name, ds, ev->channel, ev->id, phy_info->phy_id); |
2757 | dev_printk(KERN_DEBUG, &port->dev, | 2685 | dev_printk(KERN_DEBUG, &port->dev, MYIOC_s_FMT |
2758 | "delete port (%d)\n", port->port_identifier); | 2686 | "delete port (%d)\n", ioc->name, port->port_identifier); |
2759 | sas_port_delete(port); | 2687 | sas_port_delete(port); |
2760 | mptsas_port_delete(ioc, phy_info->port_details); | 2688 | mptsas_port_delete(ioc, phy_info->port_details); |
2761 | break; | 2689 | break; |
@@ -2796,8 +2724,8 @@ mptsas_hotplug_work(struct work_struct *work) | |||
2796 | 2724 | ||
2797 | if (!vtarget) { | 2725 | if (!vtarget) { |
2798 | dfailprintk(ioc, printk(MYIOC_s_ERR_FMT | 2726 | dfailprintk(ioc, printk(MYIOC_s_ERR_FMT |
2799 | "%s: exit at line=%d\n", ioc->name, | 2727 | "%s: exit at line=%d\n", ioc->name, |
2800 | __FUNCTION__, __LINE__)); | 2728 | __FUNCTION__, __LINE__)); |
2801 | break; | 2729 | break; |
2802 | } | 2730 | } |
2803 | /* | 2731 | /* |
@@ -2930,7 +2858,7 @@ mptsas_send_sas_event(MPT_ADAPTER *ioc, | |||
2930 | case MPI_EVENT_SAS_DEV_STAT_RC_ADDED: | 2858 | case MPI_EVENT_SAS_DEV_STAT_RC_ADDED: |
2931 | ev = kzalloc(sizeof(*ev), GFP_ATOMIC); | 2859 | ev = kzalloc(sizeof(*ev), GFP_ATOMIC); |
2932 | if (!ev) { | 2860 | if (!ev) { |
2933 | printk(KERN_WARNING "mptsas: lost hotplug event\n"); | 2861 | printk(MYIOC_s_WARN_FMT "lost hotplug event\n", ioc->name); |
2934 | break; | 2862 | break; |
2935 | } | 2863 | } |
2936 | 2864 | ||
@@ -2989,7 +2917,7 @@ mptsas_send_raid_event(MPT_ADAPTER *ioc, | |||
2989 | 2917 | ||
2990 | ev = kzalloc(sizeof(*ev), GFP_ATOMIC); | 2918 | ev = kzalloc(sizeof(*ev), GFP_ATOMIC); |
2991 | if (!ev) { | 2919 | if (!ev) { |
2992 | printk(KERN_WARNING "mptsas: lost hotplug event\n"); | 2920 | printk(MYIOC_s_WARN_FMT "lost hotplug event\n", ioc->name); |
2993 | return; | 2921 | return; |
2994 | } | 2922 | } |
2995 | 2923 | ||
@@ -3288,20 +3216,22 @@ mptsas_probe(struct pci_dev *pdev, const struct pci_device_id *id) | |||
3288 | sh->sg_tablesize = numSGE; | 3216 | sh->sg_tablesize = numSGE; |
3289 | } | 3217 | } |
3290 | 3218 | ||
3291 | hd = (MPT_SCSI_HOST *) sh->hostdata; | 3219 | hd = shost_priv(sh); |
3292 | hd->ioc = ioc; | 3220 | hd->ioc = ioc; |
3293 | 3221 | ||
3294 | /* SCSI needs scsi_cmnd lookup table! | 3222 | /* SCSI needs scsi_cmnd lookup table! |
3295 | * (with size equal to req_depth*PtrSz!) | 3223 | * (with size equal to req_depth*PtrSz!) |
3296 | */ | 3224 | */ |
3297 | hd->ScsiLookup = kcalloc(ioc->req_depth, sizeof(void *), GFP_ATOMIC); | 3225 | ioc->ScsiLookup = kcalloc(ioc->req_depth, sizeof(void *), GFP_ATOMIC); |
3298 | if (!hd->ScsiLookup) { | 3226 | if (!ioc->ScsiLookup) { |
3299 | error = -ENOMEM; | 3227 | error = -ENOMEM; |
3228 | spin_unlock_irqrestore(&ioc->FreeQlock, flags); | ||
3300 | goto out_mptsas_probe; | 3229 | goto out_mptsas_probe; |
3301 | } | 3230 | } |
3231 | spin_lock_init(&ioc->scsi_lookup_lock); | ||
3302 | 3232 | ||
3303 | dprintk(ioc, printk(MYIOC_s_DEBUG_FMT "ScsiLookup @ %p\n", | 3233 | dprintk(ioc, printk(MYIOC_s_DEBUG_FMT "ScsiLookup @ %p\n", |
3304 | ioc->name, hd->ScsiLookup)); | 3234 | ioc->name, ioc->ScsiLookup)); |
3305 | 3235 | ||
3306 | /* Clear the TM flags | 3236 | /* Clear the TM flags |
3307 | */ | 3237 | */ |
@@ -3340,8 +3270,8 @@ mptsas_probe(struct pci_dev *pdev, const struct pci_device_id *id) | |||
3340 | 3270 | ||
3341 | error = scsi_add_host(sh, &ioc->pcidev->dev); | 3271 | error = scsi_add_host(sh, &ioc->pcidev->dev); |
3342 | if (error) { | 3272 | if (error) { |
3343 | dprintk(ioc, printk(KERN_ERR MYNAM | 3273 | dprintk(ioc, printk(MYIOC_s_ERR_FMT |
3344 | "scsi_add_host failed\n")); | 3274 | "scsi_add_host failed\n", ioc->name)); |
3345 | goto out_mptsas_probe; | 3275 | goto out_mptsas_probe; |
3346 | } | 3276 | } |
3347 | 3277 | ||
diff --git a/drivers/message/fusion/mptsas.h b/drivers/message/fusion/mptsas.h new file mode 100644 index 000000000000..7c150f50629a --- /dev/null +++ b/drivers/message/fusion/mptsas.h | |||
@@ -0,0 +1,158 @@ | |||
1 | /* | ||
2 | * linux/drivers/message/fusion/mptsas.h | ||
3 | * High performance SCSI + LAN / Fibre Channel device drivers. | ||
4 | * For use with PCI chip/adapter(s): | ||
5 | * LSIFC9xx/LSI409xx Fibre Channel | ||
6 | * running LSI MPT (Message Passing Technology) firmware. | ||
7 | * | ||
8 | * Copyright (c) 1999-2007 LSI Corporation | ||
9 | * (mailto:DL-MPTFusionLinux@lsi.com) | ||
10 | * | ||
11 | */ | ||
12 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | ||
13 | /* | ||
14 | This program is free software; you can redistribute it and/or modify | ||
15 | it under the terms of the GNU General Public License as published by | ||
16 | the Free Software Foundation; version 2 of the License. | ||
17 | |||
18 | This program is distributed in the hope that it will be useful, | ||
19 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
20 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
21 | GNU General Public License for more details. | ||
22 | |||
23 | NO WARRANTY | ||
24 | THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR | ||
25 | CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT | ||
26 | LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, | ||
27 | MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is | ||
28 | solely responsible for determining the appropriateness of using and | ||
29 | distributing the Program and assumes all risks associated with its | ||
30 | exercise of rights under this Agreement, including but not limited to | ||
31 | the risks and costs of program errors, damage to or loss of data, | ||
32 | programs or equipment, and unavailability or interruption of operations. | ||
33 | |||
34 | DISCLAIMER OF LIABILITY | ||
35 | NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY | ||
36 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
37 | DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND | ||
38 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR | ||
39 | TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE | ||
40 | USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED | ||
41 | HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES | ||
42 | |||
43 | You should have received a copy of the GNU General Public License | ||
44 | along with this program; if not, write to the Free Software | ||
45 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
46 | */ | ||
47 | |||
48 | #ifndef MPTSAS_H_INCLUDED | ||
49 | #define MPTSAS_H_INCLUDED | ||
50 | /*{-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | ||
51 | |||
52 | struct mptsas_target_reset_event { | ||
53 | struct list_head list; | ||
54 | EVENT_DATA_SAS_DEVICE_STATUS_CHANGE sas_event_data; | ||
55 | u8 target_reset_issued; | ||
56 | }; | ||
57 | |||
58 | enum mptsas_hotplug_action { | ||
59 | MPTSAS_ADD_DEVICE, | ||
60 | MPTSAS_DEL_DEVICE, | ||
61 | MPTSAS_ADD_RAID, | ||
62 | MPTSAS_DEL_RAID, | ||
63 | MPTSAS_ADD_INACTIVE_VOLUME, | ||
64 | MPTSAS_IGNORE_EVENT, | ||
65 | }; | ||
66 | |||
67 | struct mptsas_hotplug_event { | ||
68 | struct work_struct work; | ||
69 | MPT_ADAPTER *ioc; | ||
70 | enum mptsas_hotplug_action event_type; | ||
71 | u64 sas_address; | ||
72 | u8 channel; | ||
73 | u8 id; | ||
74 | u32 device_info; | ||
75 | u16 handle; | ||
76 | u16 parent_handle; | ||
77 | u8 phy_id; | ||
78 | u8 phys_disk_num_valid; /* hrc (hidden raid component) */ | ||
79 | u8 phys_disk_num; /* hrc - unique index*/ | ||
80 | u8 hidden_raid_component; /* hrc - don't expose*/ | ||
81 | }; | ||
82 | |||
83 | struct mptsas_discovery_event { | ||
84 | struct work_struct work; | ||
85 | MPT_ADAPTER *ioc; | ||
86 | }; | ||
87 | |||
88 | /* | ||
89 | * SAS topology structures | ||
90 | * | ||
91 | * The MPT Fusion firmware interface spreads information about the | ||
92 | * SAS topology over many manufacture pages, thus we need some data | ||
93 | * structure to collect it and process it for the SAS transport class. | ||
94 | */ | ||
95 | |||
96 | struct mptsas_devinfo { | ||
97 | u16 handle; /* unique id to address this device */ | ||
98 | u16 handle_parent; /* unique id to address parent device */ | ||
99 | u16 handle_enclosure; /* enclosure identifier of the enclosure */ | ||
100 | u16 slot; /* physical slot in enclosure */ | ||
101 | u8 phy_id; /* phy number of parent device */ | ||
102 | u8 port_id; /* sas physical port this device | ||
103 | is assoc'd with */ | ||
104 | u8 id; /* logical target id of this device */ | ||
105 | u32 phys_disk_num; /* phys disk id, for csmi-ioctls */ | ||
106 | u8 channel; /* logical bus number of this device */ | ||
107 | u64 sas_address; /* WWN of this device, | ||
108 | SATA is assigned by HBA,expander */ | ||
109 | u32 device_info; /* bitfield detailed info about this device */ | ||
110 | }; | ||
111 | |||
112 | /* | ||
113 | * Specific details on ports, wide/narrow | ||
114 | */ | ||
115 | struct mptsas_portinfo_details{ | ||
116 | u16 num_phys; /* number of phys belong to this port */ | ||
117 | u64 phy_bitmask; /* TODO, extend support for 255 phys */ | ||
118 | struct sas_rphy *rphy; /* transport layer rphy object */ | ||
119 | struct sas_port *port; /* transport layer port object */ | ||
120 | struct scsi_target *starget; | ||
121 | struct mptsas_portinfo *port_info; | ||
122 | }; | ||
123 | |||
124 | struct mptsas_phyinfo { | ||
125 | u16 handle; /* unique id to address this */ | ||
126 | u8 phy_id; /* phy index */ | ||
127 | u8 port_id; /* firmware port identifier */ | ||
128 | u8 negotiated_link_rate; /* nego'd link rate for this phy */ | ||
129 | u8 hw_link_rate; /* hardware max/min phys link rate */ | ||
130 | u8 programmed_link_rate; /* programmed max/min phy link rate */ | ||
131 | u8 sas_port_add_phy; /* flag to request sas_port_add_phy*/ | ||
132 | struct mptsas_devinfo identify; /* point to phy device info */ | ||
133 | struct mptsas_devinfo attached; /* point to attached device info */ | ||
134 | struct sas_phy *phy; /* transport layer phy object */ | ||
135 | struct mptsas_portinfo *portinfo; | ||
136 | struct mptsas_portinfo_details * port_details; | ||
137 | }; | ||
138 | |||
139 | struct mptsas_portinfo { | ||
140 | struct list_head list; | ||
141 | u16 num_phys; /* number of phys */ | ||
142 | struct mptsas_phyinfo *phy_info; | ||
143 | }; | ||
144 | |||
145 | struct mptsas_enclosure { | ||
146 | u64 enclosure_logical_id; /* The WWN for the enclosure */ | ||
147 | u16 enclosure_handle; /* unique id to address this */ | ||
148 | u16 flags; /* details enclosure management */ | ||
149 | u16 num_slot; /* num slots */ | ||
150 | u16 start_slot; /* first slot */ | ||
151 | u8 start_id; /* starting logical target id */ | ||
152 | u8 start_channel; /* starting logical channel id */ | ||
153 | u8 sep_id; /* SEP device logical target id */ | ||
154 | u8 sep_channel; /* SEP channel logical channel id */ | ||
155 | }; | ||
156 | |||
157 | /*}-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | ||
158 | #endif | ||
diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c index 5431529741ad..bdff950a54a1 100644 --- a/drivers/message/fusion/mptscsih.c +++ b/drivers/message/fusion/mptscsih.c | |||
@@ -1,9 +1,9 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/message/fusion/mptscsih.c | 2 | * linux/drivers/message/fusion/mptscsih.c |
3 | * For use with LSI Logic PCI chip/adapter(s) | 3 | * For use with LSI PCI chip/adapter(s) |
4 | * running LSI Logic Fusion MPT (Message Passing Technology) firmware. | 4 | * running LSI Fusion MPT (Message Passing Technology) firmware. |
5 | * | 5 | * |
6 | * Copyright (c) 1999-2007 LSI Logic Corporation | 6 | * Copyright (c) 1999-2007 LSI Corporation |
7 | * (mailto:DL-MPTFusionLinux@lsi.com) | 7 | * (mailto:DL-MPTFusionLinux@lsi.com) |
8 | * | 8 | * |
9 | */ | 9 | */ |
@@ -80,6 +80,10 @@ MODULE_VERSION(my_VERSION); | |||
80 | /* | 80 | /* |
81 | * Other private/forward protos... | 81 | * Other private/forward protos... |
82 | */ | 82 | */ |
83 | static struct scsi_cmnd * mptscsih_get_scsi_lookup(MPT_ADAPTER *ioc, int i); | ||
84 | static struct scsi_cmnd * mptscsih_getclear_scsi_lookup(MPT_ADAPTER *ioc, int i); | ||
85 | static void mptscsih_set_scsi_lookup(MPT_ADAPTER *ioc, int i, struct scsi_cmnd *scmd); | ||
86 | static int SCPNT_TO_LOOKUP_IDX(MPT_ADAPTER *ioc, struct scsi_cmnd *scmd); | ||
83 | int mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *r); | 87 | int mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *r); |
84 | static void mptscsih_report_queue_full(struct scsi_cmnd *sc, SCSIIOReply_t *pScsiReply, SCSIIORequest_t *pScsiReq); | 88 | static void mptscsih_report_queue_full(struct scsi_cmnd *sc, SCSIIOReply_t *pScsiReply, SCSIIORequest_t *pScsiReq); |
85 | int mptscsih_taskmgmt_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *r); | 89 | int mptscsih_taskmgmt_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *r); |
@@ -90,7 +94,6 @@ static void mptscsih_freeChainBuffers(MPT_ADAPTER *ioc, int req_idx); | |||
90 | static void mptscsih_copy_sense_data(struct scsi_cmnd *sc, MPT_SCSI_HOST *hd, MPT_FRAME_HDR *mf, SCSIIOReply_t *pScsiReply); | 94 | static void mptscsih_copy_sense_data(struct scsi_cmnd *sc, MPT_SCSI_HOST *hd, MPT_FRAME_HDR *mf, SCSIIOReply_t *pScsiReply); |
91 | static int mptscsih_tm_pending_wait(MPT_SCSI_HOST * hd); | 95 | static int mptscsih_tm_pending_wait(MPT_SCSI_HOST * hd); |
92 | static int mptscsih_tm_wait_for_completion(MPT_SCSI_HOST * hd, ulong timeout ); | 96 | static int mptscsih_tm_wait_for_completion(MPT_SCSI_HOST * hd, ulong timeout ); |
93 | static int SCPNT_TO_LOOKUP_IDX(struct scsi_cmnd *sc); | ||
94 | 97 | ||
95 | static int mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 id, int lun, int ctx2abort, ulong timeout); | 98 | static int mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 id, int lun, int ctx2abort, ulong timeout); |
96 | 99 | ||
@@ -192,7 +195,7 @@ mptscsih_getFreeChainBuffer(MPT_ADAPTER *ioc, int *retIndex) | |||
192 | int chain_idx; | 195 | int chain_idx; |
193 | 196 | ||
194 | dsgprintk(ioc, printk(MYIOC_s_DEBUG_FMT "getFreeChainBuffer called\n", | 197 | dsgprintk(ioc, printk(MYIOC_s_DEBUG_FMT "getFreeChainBuffer called\n", |
195 | ioc->name)); | 198 | ioc->name)); |
196 | spin_lock_irqsave(&ioc->FreeQlock, flags); | 199 | spin_lock_irqsave(&ioc->FreeQlock, flags); |
197 | if (!list_empty(&ioc->FreeChainQ)) { | 200 | if (!list_empty(&ioc->FreeChainQ)) { |
198 | int offset; | 201 | int offset; |
@@ -203,13 +206,14 @@ mptscsih_getFreeChainBuffer(MPT_ADAPTER *ioc, int *retIndex) | |||
203 | offset = (u8 *)chainBuf - (u8 *)ioc->ChainBuffer; | 206 | offset = (u8 *)chainBuf - (u8 *)ioc->ChainBuffer; |
204 | chain_idx = offset / ioc->req_sz; | 207 | chain_idx = offset / ioc->req_sz; |
205 | rc = SUCCESS; | 208 | rc = SUCCESS; |
206 | dsgprintk(ioc, printk(MYIOC_s_DEBUG_FMT "getFreeChainBuffer chainBuf=%p ChainBuffer=%p offset=%d chain_idx=%d\n", | 209 | dsgprintk(ioc, printk(MYIOC_s_DEBUG_FMT |
207 | ioc->name, chainBuf, ioc->ChainBuffer, offset, chain_idx)); | 210 | "getFreeChainBuffer chainBuf=%p ChainBuffer=%p offset=%d chain_idx=%d\n", |
211 | ioc->name, chainBuf, ioc->ChainBuffer, offset, chain_idx)); | ||
208 | } else { | 212 | } else { |
209 | rc = FAILED; | 213 | rc = FAILED; |
210 | chain_idx = MPT_HOST_NO_CHAIN; | 214 | chain_idx = MPT_HOST_NO_CHAIN; |
211 | dfailprintk(ioc, printk(MYIOC_s_DEBUG_FMT "getFreeChainBuffer failed\n", | 215 | dfailprintk(ioc, printk(MYIOC_s_ERR_FMT "getFreeChainBuffer failed\n", |
212 | ioc->name)); | 216 | ioc->name)); |
213 | } | 217 | } |
214 | spin_unlock_irqrestore(&ioc->FreeQlock, flags); | 218 | spin_unlock_irqrestore(&ioc->FreeQlock, flags); |
215 | 219 | ||
@@ -419,8 +423,8 @@ nextSGEset: | |||
419 | * out the Address and Flags fields. | 423 | * out the Address and Flags fields. |
420 | */ | 424 | */ |
421 | chainSge = (char *) psge; | 425 | chainSge = (char *) psge; |
422 | dsgprintk(ioc, printk(KERN_DEBUG " Current buff @ %p (index 0x%x)", | 426 | dsgprintk(ioc, printk(MYIOC_s_DEBUG_FMT " Current buff @ %p (index 0x%x)", |
423 | psge, req_idx)); | 427 | ioc->name, psge, req_idx)); |
424 | 428 | ||
425 | /* Start the SGE for the next buffer | 429 | /* Start the SGE for the next buffer |
426 | */ | 430 | */ |
@@ -428,8 +432,8 @@ nextSGEset: | |||
428 | sgeOffset = 0; | 432 | sgeOffset = 0; |
429 | sg_done = 0; | 433 | sg_done = 0; |
430 | 434 | ||
431 | dsgprintk(ioc, printk(KERN_DEBUG " Chain buff @ %p (index 0x%x)\n", | 435 | dsgprintk(ioc, printk(MYIOC_s_DEBUG_FMT " Chain buff @ %p (index 0x%x)\n", |
432 | psge, chain_idx)); | 436 | ioc->name, psge, chain_idx)); |
433 | 437 | ||
434 | /* Start the SGE for the next buffer | 438 | /* Start the SGE for the next buffer |
435 | */ | 439 | */ |
@@ -588,18 +592,17 @@ mptscsih_info_scsiio(MPT_ADAPTER *ioc, struct scsi_cmnd *sc, SCSIIOReply_t * pSc | |||
588 | } | 592 | } |
589 | 593 | ||
590 | scsi_print_command(sc); | 594 | scsi_print_command(sc); |
591 | printk(KERN_DEBUG "\tfw_channel = %d, fw_id = %d\n", | 595 | printk(MYIOC_s_DEBUG_FMT "\tfw_channel = %d, fw_id = %d\n", |
592 | pScsiReply->Bus, pScsiReply->TargetID); | 596 | ioc->name, pScsiReply->Bus, pScsiReply->TargetID); |
593 | printk(KERN_DEBUG "\trequest_len = %d, underflow = %d, resid = %d\n", | 597 | printk(MYIOC_s_DEBUG_FMT "\trequest_len = %d, underflow = %d, " |
594 | scsi_bufflen(sc), sc->underflow, scsi_get_resid(sc)); | 598 | "resid = %d\n", ioc->name, scsi_bufflen(sc), sc->underflow, |
595 | printk(KERN_DEBUG "\ttag = %d, transfer_count = %d, sc->result = %08X\n", | 599 | scsi_get_resid(sc)); |
596 | le16_to_cpu(pScsiReply->TaskTag), | 600 | printk(MYIOC_s_DEBUG_FMT "\ttag = %d, transfer_count = %d, " |
601 | "sc->result = %08X\n", ioc->name, le16_to_cpu(pScsiReply->TaskTag), | ||
597 | le32_to_cpu(pScsiReply->TransferCount), sc->result); | 602 | le32_to_cpu(pScsiReply->TransferCount), sc->result); |
598 | 603 | printk(MYIOC_s_DEBUG_FMT "\tiocstatus = %s (0x%04x), " | |
599 | printk(KERN_DEBUG "\tiocstatus = %s (0x%04x), " | ||
600 | "scsi_status = %s (0x%02x), scsi_state = (0x%02x)\n", | 604 | "scsi_status = %s (0x%02x), scsi_state = (0x%02x)\n", |
601 | desc, ioc_status, | 605 | ioc->name, desc, ioc_status, desc1, pScsiReply->SCSIStatus, |
602 | desc1, pScsiReply->SCSIStatus, | ||
603 | pScsiReply->SCSIState); | 606 | pScsiReply->SCSIState); |
604 | 607 | ||
605 | if (pScsiReply->SCSIState & MPI_SCSI_STATE_AUTOSENSE_VALID) { | 608 | if (pScsiReply->SCSIState & MPI_SCSI_STATE_AUTOSENSE_VALID) { |
@@ -607,9 +610,8 @@ mptscsih_info_scsiio(MPT_ADAPTER *ioc, struct scsi_cmnd *sc, SCSIIOReply_t * pSc | |||
607 | asc = sc->sense_buffer[12]; | 610 | asc = sc->sense_buffer[12]; |
608 | ascq = sc->sense_buffer[13]; | 611 | ascq = sc->sense_buffer[13]; |
609 | 612 | ||
610 | printk(KERN_DEBUG "\t[sense_key,asc,ascq]: " | 613 | printk(MYIOC_s_DEBUG_FMT "\t[sense_key,asc,ascq]: " |
611 | "[0x%02x,0x%02x,0x%02x]\n", | 614 | "[0x%02x,0x%02x,0x%02x]\n", ioc->name, skey, asc, ascq); |
612 | skey, asc, ascq); | ||
613 | } | 615 | } |
614 | 616 | ||
615 | /* | 617 | /* |
@@ -617,8 +619,8 @@ mptscsih_info_scsiio(MPT_ADAPTER *ioc, struct scsi_cmnd *sc, SCSIIOReply_t * pSc | |||
617 | */ | 619 | */ |
618 | if (pScsiReply->SCSIState & MPI_SCSI_STATE_RESPONSE_INFO_VALID && | 620 | if (pScsiReply->SCSIState & MPI_SCSI_STATE_RESPONSE_INFO_VALID && |
619 | pScsiReply->ResponseInfo) | 621 | pScsiReply->ResponseInfo) |
620 | printk(KERN_DEBUG "response_info = %08xh\n", | 622 | printk(MYIOC_s_DEBUG_FMT "response_info = %08xh\n", |
621 | le32_to_cpu(pScsiReply->ResponseInfo)); | 623 | ioc->name, le32_to_cpu(pScsiReply->ResponseInfo)); |
622 | } | 624 | } |
623 | #endif | 625 | #endif |
624 | 626 | ||
@@ -645,11 +647,10 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr) | |||
645 | SCSIIORequest_t *pScsiReq; | 647 | SCSIIORequest_t *pScsiReq; |
646 | SCSIIOReply_t *pScsiReply; | 648 | SCSIIOReply_t *pScsiReply; |
647 | u16 req_idx, req_idx_MR; | 649 | u16 req_idx, req_idx_MR; |
648 | VirtDevice *vdev; | 650 | VirtDevice *vdevice; |
649 | VirtTarget *vtarget; | 651 | VirtTarget *vtarget; |
650 | 652 | ||
651 | hd = (MPT_SCSI_HOST *) ioc->sh->hostdata; | 653 | hd = shost_priv(ioc->sh); |
652 | |||
653 | req_idx = le16_to_cpu(mf->u.frame.hwhdr.msgctxu.fld.req_idx); | 654 | req_idx = le16_to_cpu(mf->u.frame.hwhdr.msgctxu.fld.req_idx); |
654 | req_idx_MR = (mr != NULL) ? | 655 | req_idx_MR = (mr != NULL) ? |
655 | le16_to_cpu(mr->u.frame.hwhdr.msgctxu.fld.req_idx) : req_idx; | 656 | le16_to_cpu(mr->u.frame.hwhdr.msgctxu.fld.req_idx) : req_idx; |
@@ -660,12 +661,11 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr) | |||
660 | printk (MYIOC_s_ERR_FMT | 661 | printk (MYIOC_s_ERR_FMT |
661 | "req_idx=%x req_idx_MR=%x mf=%p mr=%p sc=%p\n", | 662 | "req_idx=%x req_idx_MR=%x mf=%p mr=%p sc=%p\n", |
662 | ioc->name, req_idx, req_idx_MR, mf, mr, | 663 | ioc->name, req_idx, req_idx_MR, mf, mr, |
663 | hd->ScsiLookup[req_idx_MR]); | 664 | mptscsih_get_scsi_lookup(ioc, req_idx_MR)); |
664 | return 0; | 665 | return 0; |
665 | } | 666 | } |
666 | 667 | ||
667 | sc = hd->ScsiLookup[req_idx]; | 668 | sc = mptscsih_getclear_scsi_lookup(ioc, req_idx); |
668 | hd->ScsiLookup[req_idx] = NULL; | ||
669 | if (sc == NULL) { | 669 | if (sc == NULL) { |
670 | MPIHeader_t *hdr = (MPIHeader_t *)mf; | 670 | MPIHeader_t *hdr = (MPIHeader_t *)mf; |
671 | 671 | ||
@@ -738,8 +738,8 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr) | |||
738 | */ | 738 | */ |
739 | if (scsi_state & MPI_SCSI_STATE_RESPONSE_INFO_VALID && | 739 | if (scsi_state & MPI_SCSI_STATE_RESPONSE_INFO_VALID && |
740 | pScsiReply->ResponseInfo) { | 740 | pScsiReply->ResponseInfo) { |
741 | printk(KERN_NOTICE "[%d:%d:%d:%d] " | 741 | printk(MYIOC_s_NOTE_FMT "[%d:%d:%d:%d] " |
742 | "FCP_ResponseInfo=%08xh\n", | 742 | "FCP_ResponseInfo=%08xh\n", ioc->name, |
743 | sc->device->host->host_no, sc->device->channel, | 743 | sc->device->host->host_no, sc->device->channel, |
744 | sc->device->id, sc->device->lun, | 744 | sc->device->id, sc->device->lun, |
745 | le32_to_cpu(pScsiReply->ResponseInfo)); | 745 | le32_to_cpu(pScsiReply->ResponseInfo)); |
@@ -771,10 +771,10 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr) | |||
771 | if (hd->sel_timeout[pScsiReq->TargetID] < 0xFFFF) | 771 | if (hd->sel_timeout[pScsiReq->TargetID] < 0xFFFF) |
772 | hd->sel_timeout[pScsiReq->TargetID]++; | 772 | hd->sel_timeout[pScsiReq->TargetID]++; |
773 | 773 | ||
774 | vdev = sc->device->hostdata; | 774 | vdevice = sc->device->hostdata; |
775 | if (!vdev) | 775 | if (!vdevice) |
776 | break; | 776 | break; |
777 | vtarget = vdev->vtarget; | 777 | vtarget = vdevice->vtarget; |
778 | if (vtarget->tflags & MPT_TARGET_FLAGS_LED_ON) { | 778 | if (vtarget->tflags & MPT_TARGET_FLAGS_LED_ON) { |
779 | mptscsih_issue_sep_command(ioc, vtarget, | 779 | mptscsih_issue_sep_command(ioc, vtarget, |
780 | MPI_SEP_REQ_SLOTSTATUS_UNCONFIGURED); | 780 | MPI_SEP_REQ_SLOTSTATUS_UNCONFIGURED); |
@@ -824,9 +824,9 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr) | |||
824 | sc->result=DID_SOFT_ERROR << 16; | 824 | sc->result=DID_SOFT_ERROR << 16; |
825 | else /* Sufficient data transfer occurred */ | 825 | else /* Sufficient data transfer occurred */ |
826 | sc->result = (DID_OK << 16) | scsi_status; | 826 | sc->result = (DID_OK << 16) | scsi_status; |
827 | dreplyprintk(ioc, printk(KERN_DEBUG | 827 | dreplyprintk(ioc, printk(MYIOC_s_DEBUG_FMT |
828 | "RESIDUAL_MISMATCH: result=%x on channel=%d id=%d\n", | 828 | "RESIDUAL_MISMATCH: result=%x on channel=%d id=%d\n", |
829 | sc->result, sc->device->channel, sc->device->id)); | 829 | ioc->name, sc->result, sc->device->channel, sc->device->id)); |
830 | break; | 830 | break; |
831 | 831 | ||
832 | case MPI_IOCSTATUS_SCSI_DATA_UNDERRUN: /* 0x0045 */ | 832 | case MPI_IOCSTATUS_SCSI_DATA_UNDERRUN: /* 0x0045 */ |
@@ -858,9 +858,11 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr) | |||
858 | } | 858 | } |
859 | 859 | ||
860 | 860 | ||
861 | dreplyprintk(ioc, printk(KERN_DEBUG " sc->underflow={report ERR if < %02xh bytes xfer'd}\n", | 861 | dreplyprintk(ioc, printk(MYIOC_s_DEBUG_FMT |
862 | sc->underflow)); | 862 | " sc->underflow={report ERR if < %02xh bytes xfer'd}\n", |
863 | dreplyprintk(ioc, printk(KERN_DEBUG " ActBytesXferd=%02xh\n", xfer_cnt)); | 863 | ioc->name, sc->underflow)); |
864 | dreplyprintk(ioc, printk(MYIOC_s_DEBUG_FMT | ||
865 | " ActBytesXferd=%02xh\n", ioc->name, xfer_cnt)); | ||
864 | 866 | ||
865 | /* Report Queue Full | 867 | /* Report Queue Full |
866 | */ | 868 | */ |
@@ -969,48 +971,32 @@ static void | |||
969 | mptscsih_flush_running_cmds(MPT_SCSI_HOST *hd) | 971 | mptscsih_flush_running_cmds(MPT_SCSI_HOST *hd) |
970 | { | 972 | { |
971 | MPT_ADAPTER *ioc = hd->ioc; | 973 | MPT_ADAPTER *ioc = hd->ioc; |
972 | struct scsi_cmnd *SCpnt; | 974 | struct scsi_cmnd *sc; |
973 | MPT_FRAME_HDR *mf; | 975 | SCSIIORequest_t *mf = NULL; |
974 | int ii; | 976 | int ii; |
975 | int max = ioc->req_depth; | 977 | int channel, id; |
976 | |||
977 | dprintk(ioc, printk(KERN_DEBUG MYNAM ": flush_ScsiLookup called\n")); | ||
978 | for (ii= 0; ii < max; ii++) { | ||
979 | if ((SCpnt = hd->ScsiLookup[ii]) != NULL) { | ||
980 | |||
981 | /* Command found. | ||
982 | */ | ||
983 | |||
984 | /* Null ScsiLookup index | ||
985 | */ | ||
986 | hd->ScsiLookup[ii] = NULL; | ||
987 | |||
988 | mf = MPT_INDEX_2_MFPTR(ioc, ii); | ||
989 | dmfprintk(ioc, printk(KERN_DEBUG MYNAM ": flush: ScsiDone (mf=%p,sc=%p)\n", | ||
990 | mf, SCpnt)); | ||
991 | |||
992 | /* Free Chain buffers */ | ||
993 | mptscsih_freeChainBuffers(ioc, ii); | ||
994 | |||
995 | /* Free Message frames */ | ||
996 | mpt_free_msg_frame(ioc, mf); | ||
997 | |||
998 | if ((unsigned char *)mf != SCpnt->host_scribble) | ||
999 | continue; | ||
1000 | |||
1001 | /* Set status, free OS resources (SG DMA buffers) | ||
1002 | * Do OS callback | ||
1003 | */ | ||
1004 | scsi_dma_unmap(SCpnt); | ||
1005 | |||
1006 | SCpnt->result = DID_RESET << 16; | ||
1007 | SCpnt->host_scribble = NULL; | ||
1008 | 978 | ||
1009 | SCpnt->scsi_done(SCpnt); /* Issue the command callback */ | 979 | for (ii= 0; ii < ioc->req_depth; ii++) { |
1010 | } | 980 | sc = mptscsih_getclear_scsi_lookup(ioc, ii); |
981 | if (!sc) | ||
982 | continue; | ||
983 | mf = (SCSIIORequest_t *)MPT_INDEX_2_MFPTR(ioc, ii); | ||
984 | if (!mf) | ||
985 | continue; | ||
986 | channel = mf->Bus; | ||
987 | id = mf->TargetID; | ||
988 | mptscsih_freeChainBuffers(ioc, ii); | ||
989 | mpt_free_msg_frame(ioc, (MPT_FRAME_HDR *)mf); | ||
990 | if ((unsigned char *)mf != sc->host_scribble) | ||
991 | continue; | ||
992 | scsi_dma_unmap(sc); | ||
993 | sc->result = DID_RESET << 16; | ||
994 | sc->host_scribble = NULL; | ||
995 | sdev_printk(KERN_INFO, sc->device, MYIOC_s_FMT | ||
996 | "completing cmds: fw_channel %d, fw_id %d, sc=%p," | ||
997 | " mf = %p, idx=%x\n", ioc->name, channel, id, sc, mf, ii); | ||
998 | sc->scsi_done(sc); | ||
1011 | } | 999 | } |
1012 | |||
1013 | return; | ||
1014 | } | 1000 | } |
1015 | 1001 | ||
1016 | /* | 1002 | /* |
@@ -1032,17 +1018,16 @@ mptscsih_search_running_cmds(MPT_SCSI_HOST *hd, VirtDevice *vdevice) | |||
1032 | { | 1018 | { |
1033 | SCSIIORequest_t *mf = NULL; | 1019 | SCSIIORequest_t *mf = NULL; |
1034 | int ii; | 1020 | int ii; |
1035 | int max = hd->ioc->req_depth; | ||
1036 | struct scsi_cmnd *sc; | 1021 | struct scsi_cmnd *sc; |
1037 | struct scsi_lun lun; | 1022 | struct scsi_lun lun; |
1023 | MPT_ADAPTER *ioc = hd->ioc; | ||
1024 | unsigned long flags; | ||
1038 | 1025 | ||
1039 | dsprintk(hd->ioc, printk(KERN_DEBUG MYNAM ": search_running channel %d id %d lun %d max %d\n", | 1026 | spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); |
1040 | vdevice->vtarget->channel, vdevice->vtarget->id, vdevice->lun, max)); | 1027 | for (ii = 0; ii < ioc->req_depth; ii++) { |
1041 | 1028 | if ((sc = ioc->ScsiLookup[ii]) != NULL) { | |
1042 | for (ii=0; ii < max; ii++) { | ||
1043 | if ((sc = hd->ScsiLookup[ii]) != NULL) { | ||
1044 | 1029 | ||
1045 | mf = (SCSIIORequest_t *)MPT_INDEX_2_MFPTR(hd->ioc, ii); | 1030 | mf = (SCSIIORequest_t *)MPT_INDEX_2_MFPTR(ioc, ii); |
1046 | if (mf == NULL) | 1031 | if (mf == NULL) |
1047 | continue; | 1032 | continue; |
1048 | /* If the device is a hidden raid component, then its | 1033 | /* If the device is a hidden raid component, then its |
@@ -1059,22 +1044,23 @@ mptscsih_search_running_cmds(MPT_SCSI_HOST *hd, VirtDevice *vdevice) | |||
1059 | memcmp(lun.scsi_lun, mf->LUN, 8)) | 1044 | memcmp(lun.scsi_lun, mf->LUN, 8)) |
1060 | continue; | 1045 | continue; |
1061 | 1046 | ||
1062 | /* Cleanup | ||
1063 | */ | ||
1064 | hd->ScsiLookup[ii] = NULL; | ||
1065 | mptscsih_freeChainBuffers(hd->ioc, ii); | ||
1066 | mpt_free_msg_frame(hd->ioc, (MPT_FRAME_HDR *)mf); | ||
1067 | if ((unsigned char *)mf != sc->host_scribble) | 1047 | if ((unsigned char *)mf != sc->host_scribble) |
1068 | continue; | 1048 | continue; |
1049 | ioc->ScsiLookup[ii] = NULL; | ||
1050 | spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); | ||
1051 | mptscsih_freeChainBuffers(ioc, ii); | ||
1052 | mpt_free_msg_frame(ioc, (MPT_FRAME_HDR *)mf); | ||
1069 | scsi_dma_unmap(sc); | 1053 | scsi_dma_unmap(sc); |
1070 | sc->host_scribble = NULL; | 1054 | sc->host_scribble = NULL; |
1071 | sc->result = DID_NO_CONNECT << 16; | 1055 | sc->result = DID_NO_CONNECT << 16; |
1072 | sdev_printk(KERN_INFO, sc->device, "completing cmds: fw_channel %d," | 1056 | sdev_printk(KERN_INFO, sc->device, MYIOC_s_FMT "completing cmds: fw_channel %d," |
1073 | "fw_id %d, sc=%p, mf = %p, idx=%x\n", vdevice->vtarget->channel, | 1057 | "fw_id %d, sc=%p, mf = %p, idx=%x\n", ioc->name, vdevice->vtarget->channel, |
1074 | vdevice->vtarget->id, sc, mf, ii); | 1058 | vdevice->vtarget->id, sc, mf, ii); |
1075 | sc->scsi_done(sc); | 1059 | sc->scsi_done(sc); |
1060 | spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); | ||
1076 | } | 1061 | } |
1077 | } | 1062 | } |
1063 | spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); | ||
1078 | return; | 1064 | return; |
1079 | } | 1065 | } |
1080 | 1066 | ||
@@ -1097,17 +1083,18 @@ mptscsih_report_queue_full(struct scsi_cmnd *sc, SCSIIOReply_t *pScsiReply, SCSI | |||
1097 | { | 1083 | { |
1098 | long time = jiffies; | 1084 | long time = jiffies; |
1099 | MPT_SCSI_HOST *hd; | 1085 | MPT_SCSI_HOST *hd; |
1086 | MPT_ADAPTER *ioc; | ||
1100 | 1087 | ||
1101 | if (sc->device == NULL) | 1088 | if (sc->device == NULL) |
1102 | return; | 1089 | return; |
1103 | if (sc->device->host == NULL) | 1090 | if (sc->device->host == NULL) |
1104 | return; | 1091 | return; |
1105 | if ((hd = (MPT_SCSI_HOST *)sc->device->host->hostdata) == NULL) | 1092 | if ((hd = shost_priv(sc->device->host)) == NULL) |
1106 | return; | 1093 | return; |
1107 | 1094 | ioc = hd->ioc; | |
1108 | if (time - hd->last_queue_full > 10 * HZ) { | 1095 | if (time - hd->last_queue_full > 10 * HZ) { |
1109 | dprintk(hd->ioc, printk(MYIOC_s_WARN_FMT "Device (%d:%d:%d) reported QUEUE_FULL!\n", | 1096 | dprintk(ioc, printk(MYIOC_s_WARN_FMT "Device (%d:%d:%d) reported QUEUE_FULL!\n", |
1110 | hd->ioc->name, 0, sc->device->id, sc->device->lun)); | 1097 | ioc->name, 0, sc->device->id, sc->device->lun)); |
1111 | hd->last_queue_full = time; | 1098 | hd->last_queue_full = time; |
1112 | } | 1099 | } |
1113 | } | 1100 | } |
@@ -1134,28 +1121,28 @@ mptscsih_remove(struct pci_dev *pdev) | |||
1134 | 1121 | ||
1135 | scsi_remove_host(host); | 1122 | scsi_remove_host(host); |
1136 | 1123 | ||
1137 | if((hd = (MPT_SCSI_HOST *)host->hostdata) == NULL) | 1124 | if((hd = shost_priv(host)) == NULL) |
1138 | return; | 1125 | return; |
1139 | 1126 | ||
1140 | mptscsih_shutdown(pdev); | 1127 | mptscsih_shutdown(pdev); |
1141 | 1128 | ||
1142 | sz1=0; | 1129 | sz1=0; |
1143 | 1130 | ||
1144 | if (hd->ScsiLookup != NULL) { | 1131 | if (ioc->ScsiLookup != NULL) { |
1145 | sz1 = hd->ioc->req_depth * sizeof(void *); | 1132 | sz1 = ioc->req_depth * sizeof(void *); |
1146 | kfree(hd->ScsiLookup); | 1133 | kfree(ioc->ScsiLookup); |
1147 | hd->ScsiLookup = NULL; | 1134 | ioc->ScsiLookup = NULL; |
1148 | } | 1135 | } |
1149 | 1136 | ||
1150 | dprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT | 1137 | dprintk(ioc, printk(MYIOC_s_DEBUG_FMT |
1151 | "Free'd ScsiLookup (%d) memory\n", | 1138 | "Free'd ScsiLookup (%d) memory\n", |
1152 | hd->ioc->name, sz1)); | 1139 | ioc->name, sz1)); |
1153 | 1140 | ||
1154 | kfree(hd->info_kbuf); | 1141 | kfree(hd->info_kbuf); |
1155 | 1142 | ||
1156 | /* NULL the Scsi_Host pointer | 1143 | /* NULL the Scsi_Host pointer |
1157 | */ | 1144 | */ |
1158 | hd->ioc->sh = NULL; | 1145 | ioc->sh = NULL; |
1159 | 1146 | ||
1160 | scsi_host_put(host); | 1147 | scsi_host_put(host); |
1161 | 1148 | ||
@@ -1171,15 +1158,6 @@ mptscsih_remove(struct pci_dev *pdev) | |||
1171 | void | 1158 | void |
1172 | mptscsih_shutdown(struct pci_dev *pdev) | 1159 | mptscsih_shutdown(struct pci_dev *pdev) |
1173 | { | 1160 | { |
1174 | MPT_ADAPTER *ioc = pci_get_drvdata(pdev); | ||
1175 | struct Scsi_Host *host = ioc->sh; | ||
1176 | MPT_SCSI_HOST *hd; | ||
1177 | |||
1178 | if(!host) | ||
1179 | return; | ||
1180 | |||
1181 | hd = (MPT_SCSI_HOST *)host->hostdata; | ||
1182 | |||
1183 | } | 1161 | } |
1184 | 1162 | ||
1185 | #ifdef CONFIG_PM | 1163 | #ifdef CONFIG_PM |
@@ -1225,7 +1203,7 @@ mptscsih_info(struct Scsi_Host *SChost) | |||
1225 | MPT_SCSI_HOST *h; | 1203 | MPT_SCSI_HOST *h; |
1226 | int size = 0; | 1204 | int size = 0; |
1227 | 1205 | ||
1228 | h = (MPT_SCSI_HOST *)SChost->hostdata; | 1206 | h = shost_priv(SChost); |
1229 | 1207 | ||
1230 | if (h) { | 1208 | if (h) { |
1231 | if (h->info_kbuf == NULL) | 1209 | if (h->info_kbuf == NULL) |
@@ -1319,7 +1297,7 @@ int | |||
1319 | mptscsih_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset, | 1297 | mptscsih_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset, |
1320 | int length, int func) | 1298 | int length, int func) |
1321 | { | 1299 | { |
1322 | MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; | 1300 | MPT_SCSI_HOST *hd = shost_priv(host); |
1323 | MPT_ADAPTER *ioc = hd->ioc; | 1301 | MPT_ADAPTER *ioc = hd->ioc; |
1324 | int size = 0; | 1302 | int size = 0; |
1325 | 1303 | ||
@@ -1358,7 +1336,7 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) | |||
1358 | MPT_SCSI_HOST *hd; | 1336 | MPT_SCSI_HOST *hd; |
1359 | MPT_FRAME_HDR *mf; | 1337 | MPT_FRAME_HDR *mf; |
1360 | SCSIIORequest_t *pScsiReq; | 1338 | SCSIIORequest_t *pScsiReq; |
1361 | VirtDevice *vdev = SCpnt->device->hostdata; | 1339 | VirtDevice *vdevice = SCpnt->device->hostdata; |
1362 | int lun; | 1340 | int lun; |
1363 | u32 datalen; | 1341 | u32 datalen; |
1364 | u32 scsictl; | 1342 | u32 scsictl; |
@@ -1368,7 +1346,7 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) | |||
1368 | int ii; | 1346 | int ii; |
1369 | MPT_ADAPTER *ioc; | 1347 | MPT_ADAPTER *ioc; |
1370 | 1348 | ||
1371 | hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata; | 1349 | hd = shost_priv(SCpnt->device->host); |
1372 | ioc = hd->ioc; | 1350 | ioc = hd->ioc; |
1373 | lun = SCpnt->device->lun; | 1351 | lun = SCpnt->device->lun; |
1374 | SCpnt->scsi_done = done; | 1352 | SCpnt->scsi_done = done; |
@@ -1385,7 +1363,7 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) | |||
1385 | /* | 1363 | /* |
1386 | * Put together a MPT SCSI request... | 1364 | * Put together a MPT SCSI request... |
1387 | */ | 1365 | */ |
1388 | if ((mf = mpt_get_msg_frame(hd->ioc->DoneCtx, hd->ioc)) == NULL) { | 1366 | if ((mf = mpt_get_msg_frame(ioc->DoneCtx, ioc)) == NULL) { |
1389 | dprintk(ioc, printk(MYIOC_s_WARN_FMT "QueueCmd, no msg frames!!\n", | 1367 | dprintk(ioc, printk(MYIOC_s_WARN_FMT "QueueCmd, no msg frames!!\n", |
1390 | ioc->name)); | 1368 | ioc->name)); |
1391 | return SCSI_MLQUEUE_HOST_BUSY; | 1369 | return SCSI_MLQUEUE_HOST_BUSY; |
@@ -1415,8 +1393,8 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) | |||
1415 | /* Default to untagged. Once a target structure has been allocated, | 1393 | /* Default to untagged. Once a target structure has been allocated, |
1416 | * use the Inquiry data to determine if device supports tagged. | 1394 | * use the Inquiry data to determine if device supports tagged. |
1417 | */ | 1395 | */ |
1418 | if (vdev | 1396 | if (vdevice |
1419 | && (vdev->vtarget->tflags & MPT_TARGET_FLAGS_Q_YES) | 1397 | && (vdevice->vtarget->tflags & MPT_TARGET_FLAGS_Q_YES) |
1420 | && (SCpnt->device->tagged_supported)) { | 1398 | && (SCpnt->device->tagged_supported)) { |
1421 | scsictl = scsidir | MPI_SCSIIO_CONTROL_SIMPLEQ; | 1399 | scsictl = scsidir | MPI_SCSIIO_CONTROL_SIMPLEQ; |
1422 | } else { | 1400 | } else { |
@@ -1425,10 +1403,10 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) | |||
1425 | 1403 | ||
1426 | /* Use the above information to set up the message frame | 1404 | /* Use the above information to set up the message frame |
1427 | */ | 1405 | */ |
1428 | pScsiReq->TargetID = (u8) vdev->vtarget->id; | 1406 | pScsiReq->TargetID = (u8) vdevice->vtarget->id; |
1429 | pScsiReq->Bus = vdev->vtarget->channel; | 1407 | pScsiReq->Bus = vdevice->vtarget->channel; |
1430 | pScsiReq->ChainOffset = 0; | 1408 | pScsiReq->ChainOffset = 0; |
1431 | if (vdev->vtarget->tflags & MPT_TARGET_FLAGS_RAID_COMPONENT) | 1409 | if (vdevice->vtarget->tflags & MPT_TARGET_FLAGS_RAID_COMPONENT) |
1432 | pScsiReq->Function = MPI_FUNCTION_RAID_SCSI_IO_PASSTHROUGH; | 1410 | pScsiReq->Function = MPI_FUNCTION_RAID_SCSI_IO_PASSTHROUGH; |
1433 | else | 1411 | else |
1434 | pScsiReq->Function = MPI_FUNCTION_SCSI_IO_REQUEST; | 1412 | pScsiReq->Function = MPI_FUNCTION_SCSI_IO_REQUEST; |
@@ -1453,7 +1431,7 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) | |||
1453 | pScsiReq->DataLength = cpu_to_le32(datalen); | 1431 | pScsiReq->DataLength = cpu_to_le32(datalen); |
1454 | 1432 | ||
1455 | /* SenseBuffer low address */ | 1433 | /* SenseBuffer low address */ |
1456 | pScsiReq->SenseBufferLowAddr = cpu_to_le32(hd->ioc->sense_buf_low_dma | 1434 | pScsiReq->SenseBufferLowAddr = cpu_to_le32(ioc->sense_buf_low_dma |
1457 | + (my_idx * MPT_SENSE_BUFFER_ALLOC)); | 1435 | + (my_idx * MPT_SENSE_BUFFER_ALLOC)); |
1458 | 1436 | ||
1459 | /* Now add the SG list | 1437 | /* Now add the SG list |
@@ -1465,23 +1443,22 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) | |||
1465 | (dma_addr_t) -1); | 1443 | (dma_addr_t) -1); |
1466 | } else { | 1444 | } else { |
1467 | /* Add a 32 or 64 bit SGE */ | 1445 | /* Add a 32 or 64 bit SGE */ |
1468 | if (mptscsih_AddSGE(hd->ioc, SCpnt, pScsiReq, my_idx) != SUCCESS) | 1446 | if (mptscsih_AddSGE(ioc, SCpnt, pScsiReq, my_idx) != SUCCESS) |
1469 | goto fail; | 1447 | goto fail; |
1470 | } | 1448 | } |
1471 | 1449 | ||
1472 | SCpnt->host_scribble = (unsigned char *)mf; | 1450 | SCpnt->host_scribble = (unsigned char *)mf; |
1473 | hd->ScsiLookup[my_idx] = SCpnt; | 1451 | mptscsih_set_scsi_lookup(ioc, my_idx, SCpnt); |
1474 | 1452 | ||
1475 | mpt_put_msg_frame(hd->ioc->DoneCtx, hd->ioc, mf); | 1453 | mpt_put_msg_frame(ioc->DoneCtx, ioc, mf); |
1476 | dmfprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Issued SCSI cmd (%p) mf=%p idx=%d\n", | 1454 | dmfprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Issued SCSI cmd (%p) mf=%p idx=%d\n", |
1477 | ioc->name, SCpnt, mf, my_idx)); | 1455 | ioc->name, SCpnt, mf, my_idx)); |
1478 | DBG_DUMP_REQUEST_FRAME(ioc, (u32 *)mf) | 1456 | DBG_DUMP_REQUEST_FRAME(ioc, (u32 *)mf); |
1479 | return 0; | 1457 | return 0; |
1480 | 1458 | ||
1481 | fail: | 1459 | fail: |
1482 | hd->ScsiLookup[my_idx] = NULL; | 1460 | mptscsih_freeChainBuffers(ioc, my_idx); |
1483 | mptscsih_freeChainBuffers(hd->ioc, my_idx); | 1461 | mpt_free_msg_frame(ioc, mf); |
1484 | mpt_free_msg_frame(hd->ioc, mf); | ||
1485 | return SCSI_MLQUEUE_HOST_BUSY; | 1462 | return SCSI_MLQUEUE_HOST_BUSY; |
1486 | } | 1463 | } |
1487 | 1464 | ||
@@ -1590,38 +1567,38 @@ mptscsih_TMHandler(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 id, int lun, int c | |||
1590 | */ | 1567 | */ |
1591 | if (mptscsih_tm_pending_wait(hd) == FAILED) { | 1568 | if (mptscsih_tm_pending_wait(hd) == FAILED) { |
1592 | if (type == MPI_SCSITASKMGMT_TASKTYPE_ABORT_TASK) { | 1569 | if (type == MPI_SCSITASKMGMT_TASKTYPE_ABORT_TASK) { |
1593 | dtmprintk(ioc, printk(KERN_DEBUG MYNAM ": %s: TMHandler abort: " | 1570 | dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "TMHandler abort: " |
1594 | "Timed out waiting for last TM (%d) to complete! \n", | 1571 | "Timed out waiting for last TM (%d) to complete! \n", |
1595 | ioc->name, hd->tmPending)); | 1572 | ioc->name, hd->tmPending)); |
1596 | return FAILED; | 1573 | return FAILED; |
1597 | } else if (type == MPI_SCSITASKMGMT_TASKTYPE_TARGET_RESET) { | 1574 | } else if (type == MPI_SCSITASKMGMT_TASKTYPE_TARGET_RESET) { |
1598 | dtmprintk(ioc, printk(KERN_DEBUG MYNAM ": %s: TMHandler target " | 1575 | dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "TMHandler target " |
1599 | "reset: Timed out waiting for last TM (%d) " | 1576 | "reset: Timed out waiting for last TM (%d) " |
1600 | "to complete! \n", ioc->name, | 1577 | "to complete! \n", ioc->name, |
1601 | hd->tmPending)); | 1578 | hd->tmPending)); |
1602 | return FAILED; | 1579 | return FAILED; |
1603 | } else if (type == MPI_SCSITASKMGMT_TASKTYPE_RESET_BUS) { | 1580 | } else if (type == MPI_SCSITASKMGMT_TASKTYPE_RESET_BUS) { |
1604 | dtmprintk(ioc, printk(KERN_DEBUG MYNAM ": %s: TMHandler bus reset: " | 1581 | dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "TMHandler bus reset: " |
1605 | "Timed out waiting for last TM (%d) to complete! \n", | 1582 | "Timed out waiting for last TM (%d) to complete! \n", |
1606 | ioc->name, hd->tmPending)); | 1583 | ioc->name, hd->tmPending)); |
1607 | return FAILED; | 1584 | return FAILED; |
1608 | } | 1585 | } |
1609 | } else { | 1586 | } else { |
1610 | spin_lock_irqsave(&hd->ioc->FreeQlock, flags); | 1587 | spin_lock_irqsave(&ioc->FreeQlock, flags); |
1611 | hd->tmPending |= (1 << type); | 1588 | hd->tmPending |= (1 << type); |
1612 | spin_unlock_irqrestore(&hd->ioc->FreeQlock, flags); | 1589 | spin_unlock_irqrestore(&ioc->FreeQlock, flags); |
1613 | } | 1590 | } |
1614 | 1591 | ||
1615 | ioc_raw_state = mpt_GetIocState(hd->ioc, 0); | 1592 | ioc_raw_state = mpt_GetIocState(ioc, 0); |
1616 | 1593 | ||
1617 | if ((ioc_raw_state & MPI_IOC_STATE_MASK) != MPI_IOC_STATE_OPERATIONAL) { | 1594 | if ((ioc_raw_state & MPI_IOC_STATE_MASK) != MPI_IOC_STATE_OPERATIONAL) { |
1618 | printk(MYIOC_s_WARN_FMT | 1595 | printk(MYIOC_s_WARN_FMT |
1619 | "TM Handler for type=%x: IOC Not operational (0x%x)!\n", | 1596 | "TM Handler for type=%x: IOC Not operational (0x%x)!\n", |
1620 | ioc->name, type, ioc_raw_state); | 1597 | ioc->name, type, ioc_raw_state); |
1621 | printk(KERN_WARNING " Issuing HardReset!!\n"); | 1598 | printk(MYIOC_s_WARN_FMT " Issuing HardReset!!\n", ioc->name); |
1622 | if (mpt_HardResetHandler(ioc, CAN_SLEEP) < 0) | 1599 | if (mpt_HardResetHandler(ioc, CAN_SLEEP) < 0) |
1623 | printk((KERN_WARNING "TMHandler: HardReset " | 1600 | printk(MYIOC_s_WARN_FMT "TMHandler: HardReset " |
1624 | "FAILED!!\n")); | 1601 | "FAILED!!\n", ioc->name); |
1625 | return FAILED; | 1602 | return FAILED; |
1626 | } | 1603 | } |
1627 | 1604 | ||
@@ -1680,16 +1657,17 @@ mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 id, int lun, i | |||
1680 | SCSITaskMgmt_t *pScsiTm; | 1657 | SCSITaskMgmt_t *pScsiTm; |
1681 | int ii; | 1658 | int ii; |
1682 | int retval; | 1659 | int retval; |
1660 | MPT_ADAPTER *ioc = hd->ioc; | ||
1683 | 1661 | ||
1684 | /* Return Fail to calling function if no message frames available. | 1662 | /* Return Fail to calling function if no message frames available. |
1685 | */ | 1663 | */ |
1686 | if ((mf = mpt_get_msg_frame(hd->ioc->TaskCtx, hd->ioc)) == NULL) { | 1664 | if ((mf = mpt_get_msg_frame(ioc->TaskCtx, ioc)) == NULL) { |
1687 | dfailprintk(hd->ioc, printk(MYIOC_s_ERR_FMT "IssueTaskMgmt, no msg frames!!\n", | 1665 | dfailprintk(ioc, printk(MYIOC_s_ERR_FMT "IssueTaskMgmt, no msg frames!!\n", |
1688 | hd->ioc->name)); | 1666 | ioc->name)); |
1689 | return FAILED; | 1667 | return FAILED; |
1690 | } | 1668 | } |
1691 | dtmprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "IssueTaskMgmt request @ %p\n", | 1669 | dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "IssueTaskMgmt request @ %p\n", |
1692 | hd->ioc->name, mf)); | 1670 | ioc->name, mf)); |
1693 | 1671 | ||
1694 | /* Format the Request | 1672 | /* Format the Request |
1695 | */ | 1673 | */ |
@@ -1712,28 +1690,34 @@ mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 id, int lun, i | |||
1712 | 1690 | ||
1713 | pScsiTm->TaskMsgContext = ctx2abort; | 1691 | pScsiTm->TaskMsgContext = ctx2abort; |
1714 | 1692 | ||
1715 | dtmprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "IssueTaskMgmt: ctx2abort (0x%08x) " | 1693 | dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "IssueTaskMgmt: ctx2abort (0x%08x) " |
1716 | "type=%d\n", hd->ioc->name, ctx2abort, type)); | 1694 | "type=%d\n", ioc->name, ctx2abort, type)); |
1717 | 1695 | ||
1718 | DBG_DUMP_TM_REQUEST_FRAME(ioc, (u32 *)pScsiTm); | 1696 | DBG_DUMP_TM_REQUEST_FRAME(ioc, (u32 *)pScsiTm); |
1719 | 1697 | ||
1720 | if ((retval = mpt_send_handshake_request(hd->ioc->TaskCtx, hd->ioc, | 1698 | if ((ioc->facts.IOCCapabilities & MPI_IOCFACTS_CAPABILITY_HIGH_PRI_Q) && |
1721 | sizeof(SCSITaskMgmt_t), (u32*)pScsiTm, CAN_SLEEP)) != 0) { | 1699 | (ioc->facts.MsgVersion >= MPI_VERSION_01_05)) |
1722 | dfailprintk(hd->ioc, printk(MYIOC_s_ERR_FMT "send_handshake FAILED!" | 1700 | mpt_put_msg_frame_hi_pri(ioc->TaskCtx, ioc, mf); |
1723 | " (hd %p, ioc %p, mf %p, rc=%d) \n", hd->ioc->name, hd, | 1701 | else { |
1724 | hd->ioc, mf, retval)); | 1702 | retval = mpt_send_handshake_request(ioc->TaskCtx, ioc, |
1725 | goto fail_out; | 1703 | sizeof(SCSITaskMgmt_t), (u32*)pScsiTm, CAN_SLEEP); |
1704 | if (retval) { | ||
1705 | dfailprintk(ioc, printk(MYIOC_s_ERR_FMT "send_handshake FAILED!" | ||
1706 | " (hd %p, ioc %p, mf %p, rc=%d) \n", ioc->name, hd, | ||
1707 | ioc, mf, retval)); | ||
1708 | goto fail_out; | ||
1709 | } | ||
1726 | } | 1710 | } |
1727 | 1711 | ||
1728 | if(mptscsih_tm_wait_for_completion(hd, timeout) == FAILED) { | 1712 | if(mptscsih_tm_wait_for_completion(hd, timeout) == FAILED) { |
1729 | dfailprintk(hd->ioc, printk(MYIOC_s_ERR_FMT "task management request TIMED OUT!" | 1713 | dfailprintk(ioc, printk(MYIOC_s_ERR_FMT "task management request TIMED OUT!" |
1730 | " (hd %p, ioc %p, mf %p) \n", hd->ioc->name, hd, | 1714 | " (hd %p, ioc %p, mf %p) \n", ioc->name, hd, |
1731 | hd->ioc, mf)); | 1715 | ioc, mf)); |
1732 | dtmprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "Calling HardReset! \n", | 1716 | dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Calling HardReset! \n", |
1733 | hd->ioc->name)); | 1717 | ioc->name)); |
1734 | retval = mpt_HardResetHandler(hd->ioc, CAN_SLEEP); | 1718 | retval = mpt_HardResetHandler(ioc, CAN_SLEEP); |
1735 | dtmprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "rc=%d \n", | 1719 | dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rc=%d \n", |
1736 | hd->ioc->name, retval)); | 1720 | ioc->name, retval)); |
1737 | goto fail_out; | 1721 | goto fail_out; |
1738 | } | 1722 | } |
1739 | 1723 | ||
@@ -1754,7 +1738,7 @@ mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 id, int lun, i | |||
1754 | /* | 1738 | /* |
1755 | * Free task managment mf, and corresponding tm flags | 1739 | * Free task managment mf, and corresponding tm flags |
1756 | */ | 1740 | */ |
1757 | mpt_free_msg_frame(hd->ioc, mf); | 1741 | mpt_free_msg_frame(ioc, mf); |
1758 | hd->tmPending = 0; | 1742 | hd->tmPending = 0; |
1759 | hd->tmState = TM_STATE_NONE; | 1743 | hd->tmState = TM_STATE_NONE; |
1760 | return FAILED; | 1744 | return FAILED; |
@@ -1797,11 +1781,11 @@ mptscsih_abort(struct scsi_cmnd * SCpnt) | |||
1797 | 1781 | ||
1798 | /* If we can't locate our host adapter structure, return FAILED status. | 1782 | /* If we can't locate our host adapter structure, return FAILED status. |
1799 | */ | 1783 | */ |
1800 | if ((hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata) == NULL) { | 1784 | if ((hd = shost_priv(SCpnt->device->host)) == NULL) { |
1801 | SCpnt->result = DID_RESET << 16; | 1785 | SCpnt->result = DID_RESET << 16; |
1802 | SCpnt->scsi_done(SCpnt); | 1786 | SCpnt->scsi_done(SCpnt); |
1803 | printk(KERN_DEBUG MYNAM ": mptscsih_abort: Can't locate " | 1787 | printk(KERN_ERR MYNAM ": task abort: " |
1804 | "host! (sc=%p)\n", SCpnt); | 1788 | "can't locate host! (sc=%p)\n", SCpnt); |
1805 | return FAILED; | 1789 | return FAILED; |
1806 | } | 1790 | } |
1807 | 1791 | ||
@@ -1812,8 +1796,9 @@ mptscsih_abort(struct scsi_cmnd * SCpnt) | |||
1812 | 1796 | ||
1813 | vdevice = SCpnt->device->hostdata; | 1797 | vdevice = SCpnt->device->hostdata; |
1814 | if (!vdevice || !vdevice->vtarget) { | 1798 | if (!vdevice || !vdevice->vtarget) { |
1815 | dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "task abort: device has been " | 1799 | dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT |
1816 | "deleted (sc=%p)\n", ioc->name, SCpnt)); | 1800 | "task abort: device has been deleted (sc=%p)\n", |
1801 | ioc->name, SCpnt)); | ||
1817 | SCpnt->result = DID_NO_CONNECT << 16; | 1802 | SCpnt->result = DID_NO_CONNECT << 16; |
1818 | SCpnt->scsi_done(SCpnt); | 1803 | SCpnt->scsi_done(SCpnt); |
1819 | retval = 0; | 1804 | retval = 0; |
@@ -1823,8 +1808,9 @@ mptscsih_abort(struct scsi_cmnd * SCpnt) | |||
1823 | /* Task aborts are not supported for hidden raid components. | 1808 | /* Task aborts are not supported for hidden raid components. |
1824 | */ | 1809 | */ |
1825 | if (vdevice->vtarget->tflags & MPT_TARGET_FLAGS_RAID_COMPONENT) { | 1810 | if (vdevice->vtarget->tflags & MPT_TARGET_FLAGS_RAID_COMPONENT) { |
1826 | dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "task abort: hidden raid " | 1811 | dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT |
1827 | "component (sc=%p)\n", ioc->name, SCpnt)); | 1812 | "task abort: hidden raid component (sc=%p)\n", |
1813 | ioc->name, SCpnt)); | ||
1828 | SCpnt->result = DID_RESET << 16; | 1814 | SCpnt->result = DID_RESET << 16; |
1829 | retval = FAILED; | 1815 | retval = FAILED; |
1830 | goto out; | 1816 | goto out; |
@@ -1832,12 +1818,12 @@ mptscsih_abort(struct scsi_cmnd * SCpnt) | |||
1832 | 1818 | ||
1833 | /* Find this command | 1819 | /* Find this command |
1834 | */ | 1820 | */ |
1835 | if ((scpnt_idx = SCPNT_TO_LOOKUP_IDX(SCpnt)) < 0) { | 1821 | if ((scpnt_idx = SCPNT_TO_LOOKUP_IDX(ioc, SCpnt)) < 0) { |
1836 | /* Cmd not found in ScsiLookup. | 1822 | /* Cmd not found in ScsiLookup. |
1837 | * Do OS callback. | 1823 | * Do OS callback. |
1838 | */ | 1824 | */ |
1839 | SCpnt->result = DID_RESET << 16; | 1825 | SCpnt->result = DID_RESET << 16; |
1840 | dtmprintk(ioc, printk(KERN_DEBUG MYNAM ": %s: mptscsih_abort: " | 1826 | dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "task abort: " |
1841 | "Command not in the active list! (sc=%p)\n", ioc->name, | 1827 | "Command not in the active list! (sc=%p)\n", ioc->name, |
1842 | SCpnt)); | 1828 | SCpnt)); |
1843 | retval = 0; | 1829 | retval = 0; |
@@ -1859,7 +1845,7 @@ mptscsih_abort(struct scsi_cmnd * SCpnt) | |||
1859 | * swap it here either. It is an opaque cookie to | 1845 | * swap it here either. It is an opaque cookie to |
1860 | * the controller, so it does not matter. -DaveM | 1846 | * the controller, so it does not matter. -DaveM |
1861 | */ | 1847 | */ |
1862 | mf = MPT_INDEX_2_MFPTR(hd->ioc, scpnt_idx); | 1848 | mf = MPT_INDEX_2_MFPTR(ioc, scpnt_idx); |
1863 | ctx2abort = mf->u.frame.hwhdr.msgctxu.MsgContext; | 1849 | ctx2abort = mf->u.frame.hwhdr.msgctxu.MsgContext; |
1864 | 1850 | ||
1865 | hd->abortSCpnt = SCpnt; | 1851 | hd->abortSCpnt = SCpnt; |
@@ -1868,7 +1854,7 @@ mptscsih_abort(struct scsi_cmnd * SCpnt) | |||
1868 | vdevice->vtarget->channel, vdevice->vtarget->id, vdevice->lun, | 1854 | vdevice->vtarget->channel, vdevice->vtarget->id, vdevice->lun, |
1869 | ctx2abort, mptscsih_get_tm_timeout(ioc)); | 1855 | ctx2abort, mptscsih_get_tm_timeout(ioc)); |
1870 | 1856 | ||
1871 | if (SCPNT_TO_LOOKUP_IDX(SCpnt) == scpnt_idx && | 1857 | if (SCPNT_TO_LOOKUP_IDX(ioc, SCpnt) == scpnt_idx && |
1872 | SCpnt->serial_number == sn) | 1858 | SCpnt->serial_number == sn) |
1873 | retval = FAILED; | 1859 | retval = FAILED; |
1874 | 1860 | ||
@@ -1901,9 +1887,9 @@ mptscsih_dev_reset(struct scsi_cmnd * SCpnt) | |||
1901 | 1887 | ||
1902 | /* If we can't locate our host adapter structure, return FAILED status. | 1888 | /* If we can't locate our host adapter structure, return FAILED status. |
1903 | */ | 1889 | */ |
1904 | if ((hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata) == NULL){ | 1890 | if ((hd = shost_priv(SCpnt->device->host)) == NULL){ |
1905 | printk(KERN_DEBUG MYNAM ": mptscsih_dev_reset: Can't " | 1891 | printk(KERN_ERR MYNAM ": target reset: " |
1906 | "locate host! (sc=%p)\n", SCpnt); | 1892 | "Can't locate host! (sc=%p)\n", SCpnt); |
1907 | return FAILED; | 1893 | return FAILED; |
1908 | } | 1894 | } |
1909 | 1895 | ||
@@ -1959,14 +1945,14 @@ mptscsih_bus_reset(struct scsi_cmnd * SCpnt) | |||
1959 | { | 1945 | { |
1960 | MPT_SCSI_HOST *hd; | 1946 | MPT_SCSI_HOST *hd; |
1961 | int retval; | 1947 | int retval; |
1962 | VirtDevice *vdev; | 1948 | VirtDevice *vdevice; |
1963 | MPT_ADAPTER *ioc; | 1949 | MPT_ADAPTER *ioc; |
1964 | 1950 | ||
1965 | /* If we can't locate our host adapter structure, return FAILED status. | 1951 | /* If we can't locate our host adapter structure, return FAILED status. |
1966 | */ | 1952 | */ |
1967 | if ((hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata) == NULL){ | 1953 | if ((hd = shost_priv(SCpnt->device->host)) == NULL){ |
1968 | printk(KERN_DEBUG MYNAM ": mptscsih_bus_reset: Can't " | 1954 | printk(KERN_ERR MYNAM ": bus reset: " |
1969 | "locate host! (sc=%p)\n", SCpnt ); | 1955 | "Can't locate host! (sc=%p)\n", SCpnt); |
1970 | return FAILED; | 1956 | return FAILED; |
1971 | } | 1957 | } |
1972 | 1958 | ||
@@ -1978,9 +1964,9 @@ mptscsih_bus_reset(struct scsi_cmnd * SCpnt) | |||
1978 | if (hd->timeouts < -1) | 1964 | if (hd->timeouts < -1) |
1979 | hd->timeouts++; | 1965 | hd->timeouts++; |
1980 | 1966 | ||
1981 | vdev = SCpnt->device->hostdata; | 1967 | vdevice = SCpnt->device->hostdata; |
1982 | retval = mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_RESET_BUS, | 1968 | retval = mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_RESET_BUS, |
1983 | vdev->vtarget->channel, 0, 0, 0, mptscsih_get_tm_timeout(ioc)); | 1969 | vdevice->vtarget->channel, 0, 0, 0, mptscsih_get_tm_timeout(ioc)); |
1984 | 1970 | ||
1985 | printk(MYIOC_s_INFO_FMT "bus reset: %s (sc=%p)\n", | 1971 | printk(MYIOC_s_INFO_FMT "bus reset: %s (sc=%p)\n", |
1986 | ioc->name, ((retval == 0) ? "SUCCESS" : "FAILED" ), SCpnt); | 1972 | ioc->name, ((retval == 0) ? "SUCCESS" : "FAILED" ), SCpnt); |
@@ -2008,9 +1994,9 @@ mptscsih_host_reset(struct scsi_cmnd *SCpnt) | |||
2008 | MPT_ADAPTER *ioc; | 1994 | MPT_ADAPTER *ioc; |
2009 | 1995 | ||
2010 | /* If we can't locate the host to reset, then we failed. */ | 1996 | /* If we can't locate the host to reset, then we failed. */ |
2011 | if ((hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata) == NULL){ | 1997 | if ((hd = shost_priv(SCpnt->device->host)) == NULL){ |
2012 | printk( KERN_DEBUG MYNAM ": mptscsih_host_reset: Can't " | 1998 | printk(KERN_ERR MYNAM ": host reset: " |
2013 | "locate host! (sc=%p)\n", SCpnt); | 1999 | "Can't locate host! (sc=%p)\n", SCpnt); |
2014 | return FAILED; | 2000 | return FAILED; |
2015 | } | 2001 | } |
2016 | 2002 | ||
@@ -2021,7 +2007,7 @@ mptscsih_host_reset(struct scsi_cmnd *SCpnt) | |||
2021 | /* If our attempts to reset the host failed, then return a failed | 2007 | /* If our attempts to reset the host failed, then return a failed |
2022 | * status. The host will be taken off line by the SCSI mid-layer. | 2008 | * status. The host will be taken off line by the SCSI mid-layer. |
2023 | */ | 2009 | */ |
2024 | if (mpt_HardResetHandler(hd->ioc, CAN_SLEEP) < 0) { | 2010 | if (mpt_HardResetHandler(ioc, CAN_SLEEP) < 0) { |
2025 | retval = FAILED; | 2011 | retval = FAILED; |
2026 | } else { | 2012 | } else { |
2027 | /* Make sure TM pending is cleared and TM state is set to | 2013 | /* Make sure TM pending is cleared and TM state is set to |
@@ -2051,17 +2037,18 @@ mptscsih_tm_pending_wait(MPT_SCSI_HOST * hd) | |||
2051 | unsigned long flags; | 2037 | unsigned long flags; |
2052 | int loop_count = 4 * 10; /* Wait 10 seconds */ | 2038 | int loop_count = 4 * 10; /* Wait 10 seconds */ |
2053 | int status = FAILED; | 2039 | int status = FAILED; |
2040 | MPT_ADAPTER *ioc = hd->ioc; | ||
2054 | 2041 | ||
2055 | do { | 2042 | do { |
2056 | spin_lock_irqsave(&hd->ioc->FreeQlock, flags); | 2043 | spin_lock_irqsave(&ioc->FreeQlock, flags); |
2057 | if (hd->tmState == TM_STATE_NONE) { | 2044 | if (hd->tmState == TM_STATE_NONE) { |
2058 | hd->tmState = TM_STATE_IN_PROGRESS; | 2045 | hd->tmState = TM_STATE_IN_PROGRESS; |
2059 | hd->tmPending = 1; | 2046 | hd->tmPending = 1; |
2060 | spin_unlock_irqrestore(&hd->ioc->FreeQlock, flags); | 2047 | spin_unlock_irqrestore(&ioc->FreeQlock, flags); |
2061 | status = SUCCESS; | 2048 | status = SUCCESS; |
2062 | break; | 2049 | break; |
2063 | } | 2050 | } |
2064 | spin_unlock_irqrestore(&hd->ioc->FreeQlock, flags); | 2051 | spin_unlock_irqrestore(&ioc->FreeQlock, flags); |
2065 | msleep(250); | 2052 | msleep(250); |
2066 | } while (--loop_count); | 2053 | } while (--loop_count); |
2067 | 2054 | ||
@@ -2082,15 +2069,16 @@ mptscsih_tm_wait_for_completion(MPT_SCSI_HOST * hd, ulong timeout ) | |||
2082 | unsigned long flags; | 2069 | unsigned long flags; |
2083 | int loop_count = 4 * timeout; | 2070 | int loop_count = 4 * timeout; |
2084 | int status = FAILED; | 2071 | int status = FAILED; |
2072 | MPT_ADAPTER *ioc = hd->ioc; | ||
2085 | 2073 | ||
2086 | do { | 2074 | do { |
2087 | spin_lock_irqsave(&hd->ioc->FreeQlock, flags); | 2075 | spin_lock_irqsave(&ioc->FreeQlock, flags); |
2088 | if(hd->tmPending == 0) { | 2076 | if(hd->tmPending == 0) { |
2089 | status = SUCCESS; | 2077 | status = SUCCESS; |
2090 | spin_unlock_irqrestore(&hd->ioc->FreeQlock, flags); | 2078 | spin_unlock_irqrestore(&ioc->FreeQlock, flags); |
2091 | break; | 2079 | break; |
2092 | } | 2080 | } |
2093 | spin_unlock_irqrestore(&hd->ioc->FreeQlock, flags); | 2081 | spin_unlock_irqrestore(&ioc->FreeQlock, flags); |
2094 | msleep(250); | 2082 | msleep(250); |
2095 | } while (--loop_count); | 2083 | } while (--loop_count); |
2096 | 2084 | ||
@@ -2172,7 +2160,7 @@ mptscsih_taskmgmt_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *m | |||
2172 | return 1; | 2160 | return 1; |
2173 | } | 2161 | } |
2174 | 2162 | ||
2175 | hd = (MPT_SCSI_HOST *)ioc->sh->hostdata; | 2163 | hd = shost_priv(ioc->sh); |
2176 | pScsiTmReply = (SCSITaskMgmtReply_t*)mr; | 2164 | pScsiTmReply = (SCSITaskMgmtReply_t*)mr; |
2177 | pScsiTmReq = (SCSITaskMgmt_t*)mf; | 2165 | pScsiTmReq = (SCSITaskMgmt_t*)mf; |
2178 | tmType = pScsiTmReq->TaskType; | 2166 | tmType = pScsiTmReq->TaskType; |
@@ -2223,7 +2211,7 @@ mptscsih_taskmgmt_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *m | |||
2223 | if (iocstatus == MPI_IOCSTATUS_SCSI_TASK_MGMT_FAILED || | 2211 | if (iocstatus == MPI_IOCSTATUS_SCSI_TASK_MGMT_FAILED || |
2224 | hd->cmdPtr) | 2212 | hd->cmdPtr) |
2225 | if (mpt_HardResetHandler(ioc, NO_SLEEP) < 0) | 2213 | if (mpt_HardResetHandler(ioc, NO_SLEEP) < 0) |
2226 | printk((KERN_WARNING " Firmware Reload FAILED!!\n")); | 2214 | printk(MYIOC_s_WARN_FMT " Firmware Reload FAILED!!\n", ioc->name); |
2227 | break; | 2215 | break; |
2228 | 2216 | ||
2229 | case MPI_SCSITASKMGMT_TASKTYPE_TARGET_RESET: | 2217 | case MPI_SCSITASKMGMT_TASKTYPE_TARGET_RESET: |
@@ -2366,7 +2354,7 @@ void | |||
2366 | mptscsih_slave_destroy(struct scsi_device *sdev) | 2354 | mptscsih_slave_destroy(struct scsi_device *sdev) |
2367 | { | 2355 | { |
2368 | struct Scsi_Host *host = sdev->host; | 2356 | struct Scsi_Host *host = sdev->host; |
2369 | MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; | 2357 | MPT_SCSI_HOST *hd = shost_priv(host); |
2370 | VirtTarget *vtarget; | 2358 | VirtTarget *vtarget; |
2371 | VirtDevice *vdevice; | 2359 | VirtDevice *vdevice; |
2372 | struct scsi_target *starget; | 2360 | struct scsi_target *starget; |
@@ -2393,16 +2381,17 @@ mptscsih_slave_destroy(struct scsi_device *sdev) | |||
2393 | int | 2381 | int |
2394 | mptscsih_change_queue_depth(struct scsi_device *sdev, int qdepth) | 2382 | mptscsih_change_queue_depth(struct scsi_device *sdev, int qdepth) |
2395 | { | 2383 | { |
2396 | MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)sdev->host->hostdata; | 2384 | MPT_SCSI_HOST *hd = shost_priv(sdev->host); |
2397 | VirtTarget *vtarget; | 2385 | VirtTarget *vtarget; |
2398 | struct scsi_target *starget; | 2386 | struct scsi_target *starget; |
2399 | int max_depth; | 2387 | int max_depth; |
2400 | int tagged; | 2388 | int tagged; |
2389 | MPT_ADAPTER *ioc = hd->ioc; | ||
2401 | 2390 | ||
2402 | starget = scsi_target(sdev); | 2391 | starget = scsi_target(sdev); |
2403 | vtarget = starget->hostdata; | 2392 | vtarget = starget->hostdata; |
2404 | 2393 | ||
2405 | if (hd->ioc->bus_type == SPI) { | 2394 | if (ioc->bus_type == SPI) { |
2406 | if (!(vtarget->tflags & MPT_TARGET_FLAGS_Q_YES)) | 2395 | if (!(vtarget->tflags & MPT_TARGET_FLAGS_Q_YES)) |
2407 | max_depth = 1; | 2396 | max_depth = 1; |
2408 | else if (sdev->type == TYPE_DISK && | 2397 | else if (sdev->type == TYPE_DISK && |
@@ -2437,19 +2426,20 @@ mptscsih_slave_configure(struct scsi_device *sdev) | |||
2437 | VirtTarget *vtarget; | 2426 | VirtTarget *vtarget; |
2438 | VirtDevice *vdevice; | 2427 | VirtDevice *vdevice; |
2439 | struct scsi_target *starget; | 2428 | struct scsi_target *starget; |
2440 | MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)sh->hostdata; | 2429 | MPT_SCSI_HOST *hd = shost_priv(sh); |
2430 | MPT_ADAPTER *ioc = hd->ioc; | ||
2441 | 2431 | ||
2442 | starget = scsi_target(sdev); | 2432 | starget = scsi_target(sdev); |
2443 | vtarget = starget->hostdata; | 2433 | vtarget = starget->hostdata; |
2444 | vdevice = sdev->hostdata; | 2434 | vdevice = sdev->hostdata; |
2445 | 2435 | ||
2446 | dsprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT | 2436 | dsprintk(ioc, printk(MYIOC_s_DEBUG_FMT |
2447 | "device @ %p, channel=%d, id=%d, lun=%d\n", | 2437 | "device @ %p, channel=%d, id=%d, lun=%d\n", |
2448 | hd->ioc->name, sdev, sdev->channel, sdev->id, sdev->lun)); | 2438 | ioc->name, sdev, sdev->channel, sdev->id, sdev->lun)); |
2449 | if (hd->ioc->bus_type == SPI) | 2439 | if (ioc->bus_type == SPI) |
2450 | dsprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT | 2440 | dsprintk(ioc, printk(MYIOC_s_DEBUG_FMT |
2451 | "sdtr %d wdtr %d ppr %d inq length=%d\n", | 2441 | "sdtr %d wdtr %d ppr %d inq length=%d\n", |
2452 | hd->ioc->name, sdev->sdtr, sdev->wdtr, | 2442 | ioc->name, sdev->sdtr, sdev->wdtr, |
2453 | sdev->ppr, sdev->inquiry_len)); | 2443 | sdev->ppr, sdev->inquiry_len)); |
2454 | 2444 | ||
2455 | if (sdev->id > sh->max_id) { | 2445 | if (sdev->id > sh->max_id) { |
@@ -2461,21 +2451,21 @@ mptscsih_slave_configure(struct scsi_device *sdev) | |||
2461 | vdevice->configured_lun = 1; | 2451 | vdevice->configured_lun = 1; |
2462 | mptscsih_change_queue_depth(sdev, MPT_SCSI_CMD_PER_DEV_HIGH); | 2452 | mptscsih_change_queue_depth(sdev, MPT_SCSI_CMD_PER_DEV_HIGH); |
2463 | 2453 | ||
2464 | dsprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT | 2454 | dsprintk(ioc, printk(MYIOC_s_DEBUG_FMT |
2465 | "Queue depth=%d, tflags=%x\n", | 2455 | "Queue depth=%d, tflags=%x\n", |
2466 | hd->ioc->name, sdev->queue_depth, vtarget->tflags)); | 2456 | ioc->name, sdev->queue_depth, vtarget->tflags)); |
2467 | 2457 | ||
2468 | if (hd->ioc->bus_type == SPI) | 2458 | if (ioc->bus_type == SPI) |
2469 | dsprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT | 2459 | dsprintk(ioc, printk(MYIOC_s_DEBUG_FMT |
2470 | "negoFlags=%x, maxOffset=%x, SyncFactor=%x\n", | 2460 | "negoFlags=%x, maxOffset=%x, SyncFactor=%x\n", |
2471 | hd->ioc->name, vtarget->negoFlags, vtarget->maxOffset, | 2461 | ioc->name, vtarget->negoFlags, vtarget->maxOffset, |
2472 | vtarget->minSyncFactor)); | 2462 | vtarget->minSyncFactor)); |
2473 | 2463 | ||
2474 | slave_configure_exit: | 2464 | slave_configure_exit: |
2475 | 2465 | ||
2476 | dsprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT | 2466 | dsprintk(ioc, printk(MYIOC_s_DEBUG_FMT |
2477 | "tagged %d, simple %d, ordered %d\n", | 2467 | "tagged %d, simple %d, ordered %d\n", |
2478 | hd->ioc->name,sdev->tagged_supported, sdev->simple_tags, | 2468 | ioc->name,sdev->tagged_supported, sdev->simple_tags, |
2479 | sdev->ordered_tags)); | 2469 | sdev->ordered_tags)); |
2480 | 2470 | ||
2481 | return 0; | 2471 | return 0; |
@@ -2494,14 +2484,15 @@ slave_configure_exit: | |||
2494 | static void | 2484 | static void |
2495 | mptscsih_copy_sense_data(struct scsi_cmnd *sc, MPT_SCSI_HOST *hd, MPT_FRAME_HDR *mf, SCSIIOReply_t *pScsiReply) | 2485 | mptscsih_copy_sense_data(struct scsi_cmnd *sc, MPT_SCSI_HOST *hd, MPT_FRAME_HDR *mf, SCSIIOReply_t *pScsiReply) |
2496 | { | 2486 | { |
2497 | VirtDevice *vdev; | 2487 | VirtDevice *vdevice; |
2498 | SCSIIORequest_t *pReq; | 2488 | SCSIIORequest_t *pReq; |
2499 | u32 sense_count = le32_to_cpu(pScsiReply->SenseCount); | 2489 | u32 sense_count = le32_to_cpu(pScsiReply->SenseCount); |
2490 | MPT_ADAPTER *ioc = hd->ioc; | ||
2500 | 2491 | ||
2501 | /* Get target structure | 2492 | /* Get target structure |
2502 | */ | 2493 | */ |
2503 | pReq = (SCSIIORequest_t *) mf; | 2494 | pReq = (SCSIIORequest_t *) mf; |
2504 | vdev = sc->device->hostdata; | 2495 | vdevice = sc->device->hostdata; |
2505 | 2496 | ||
2506 | if (sense_count) { | 2497 | if (sense_count) { |
2507 | u8 *sense_data; | 2498 | u8 *sense_data; |
@@ -2509,15 +2500,14 @@ mptscsih_copy_sense_data(struct scsi_cmnd *sc, MPT_SCSI_HOST *hd, MPT_FRAME_HDR | |||
2509 | 2500 | ||
2510 | /* Copy the sense received into the scsi command block. */ | 2501 | /* Copy the sense received into the scsi command block. */ |
2511 | req_index = le16_to_cpu(mf->u.frame.hwhdr.msgctxu.fld.req_idx); | 2502 | req_index = le16_to_cpu(mf->u.frame.hwhdr.msgctxu.fld.req_idx); |
2512 | sense_data = ((u8 *)hd->ioc->sense_buf_pool + (req_index * MPT_SENSE_BUFFER_ALLOC)); | 2503 | sense_data = ((u8 *)ioc->sense_buf_pool + (req_index * MPT_SENSE_BUFFER_ALLOC)); |
2513 | memcpy(sc->sense_buffer, sense_data, SNS_LEN(sc)); | 2504 | memcpy(sc->sense_buffer, sense_data, SNS_LEN(sc)); |
2514 | 2505 | ||
2515 | /* Log SMART data (asc = 0x5D, non-IM case only) if required. | 2506 | /* Log SMART data (asc = 0x5D, non-IM case only) if required. |
2516 | */ | 2507 | */ |
2517 | if ((hd->ioc->events) && (hd->ioc->eventTypes & (1 << MPI_EVENT_SCSI_DEVICE_STATUS_CHANGE))) { | 2508 | if ((ioc->events) && (ioc->eventTypes & (1 << MPI_EVENT_SCSI_DEVICE_STATUS_CHANGE))) { |
2518 | if ((sense_data[12] == 0x5D) && (vdev->vtarget->raidVolume == 0)) { | 2509 | if ((sense_data[12] == 0x5D) && (vdevice->vtarget->raidVolume == 0)) { |
2519 | int idx; | 2510 | int idx; |
2520 | MPT_ADAPTER *ioc = hd->ioc; | ||
2521 | 2511 | ||
2522 | idx = ioc->eventContext % MPTCTL_EVENT_LOG_SIZE; | 2512 | idx = ioc->eventContext % MPTCTL_EVENT_LOG_SIZE; |
2523 | ioc->events[idx].event = MPI_EVENT_SCSI_DEVICE_STATUS_CHANGE; | 2513 | ioc->events[idx].event = MPI_EVENT_SCSI_DEVICE_STATUS_CHANGE; |
@@ -2530,36 +2520,116 @@ mptscsih_copy_sense_data(struct scsi_cmnd *sc, MPT_SCSI_HOST *hd, MPT_FRAME_HDR | |||
2530 | ioc->events[idx].data[1] = (sense_data[13] << 8) | sense_data[12]; | 2520 | ioc->events[idx].data[1] = (sense_data[13] << 8) | sense_data[12]; |
2531 | 2521 | ||
2532 | ioc->eventContext++; | 2522 | ioc->eventContext++; |
2533 | if (hd->ioc->pcidev->vendor == | 2523 | if (ioc->pcidev->vendor == |
2534 | PCI_VENDOR_ID_IBM) { | 2524 | PCI_VENDOR_ID_IBM) { |
2535 | mptscsih_issue_sep_command(hd->ioc, | 2525 | mptscsih_issue_sep_command(ioc, |
2536 | vdev->vtarget, MPI_SEP_REQ_SLOTSTATUS_PREDICTED_FAULT); | 2526 | vdevice->vtarget, MPI_SEP_REQ_SLOTSTATUS_PREDICTED_FAULT); |
2537 | vdev->vtarget->tflags |= | 2527 | vdevice->vtarget->tflags |= |
2538 | MPT_TARGET_FLAGS_LED_ON; | 2528 | MPT_TARGET_FLAGS_LED_ON; |
2539 | } | 2529 | } |
2540 | } | 2530 | } |
2541 | } | 2531 | } |
2542 | } else { | 2532 | } else { |
2543 | dprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "Hmmm... SenseData len=0! (?)\n", | 2533 | dprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Hmmm... SenseData len=0! (?)\n", |
2544 | hd->ioc->name)); | 2534 | ioc->name)); |
2545 | } | 2535 | } |
2546 | } | 2536 | } |
2547 | 2537 | ||
2548 | static int | 2538 | /** |
2549 | SCPNT_TO_LOOKUP_IDX(struct scsi_cmnd *sc) | 2539 | * mptscsih_get_scsi_lookup |
2540 | * | ||
2541 | * retrieves scmd entry from ScsiLookup[] array list | ||
2542 | * | ||
2543 | * @ioc: Pointer to MPT_ADAPTER structure | ||
2544 | * @i: index into the array | ||
2545 | * | ||
2546 | * Returns the scsi_cmd pointer | ||
2547 | * | ||
2548 | **/ | ||
2549 | static struct scsi_cmnd * | ||
2550 | mptscsih_get_scsi_lookup(MPT_ADAPTER *ioc, int i) | ||
2550 | { | 2551 | { |
2551 | MPT_SCSI_HOST *hd; | 2552 | unsigned long flags; |
2552 | int i; | 2553 | struct scsi_cmnd *scmd; |
2553 | 2554 | ||
2554 | hd = (MPT_SCSI_HOST *) sc->device->host->hostdata; | 2555 | spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); |
2556 | scmd = ioc->ScsiLookup[i]; | ||
2557 | spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); | ||
2558 | |||
2559 | return scmd; | ||
2560 | } | ||
2561 | |||
2562 | /** | ||
2563 | * mptscsih_getclear_scsi_lookup | ||
2564 | * | ||
2565 | * retrieves and clears scmd entry from ScsiLookup[] array list | ||
2566 | * | ||
2567 | * @ioc: Pointer to MPT_ADAPTER structure | ||
2568 | * @i: index into the array | ||
2569 | * | ||
2570 | * Returns the scsi_cmd pointer | ||
2571 | * | ||
2572 | **/ | ||
2573 | static struct scsi_cmnd * | ||
2574 | mptscsih_getclear_scsi_lookup(MPT_ADAPTER *ioc, int i) | ||
2575 | { | ||
2576 | unsigned long flags; | ||
2577 | struct scsi_cmnd *scmd; | ||
2578 | |||
2579 | spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); | ||
2580 | scmd = ioc->ScsiLookup[i]; | ||
2581 | ioc->ScsiLookup[i] = NULL; | ||
2582 | spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); | ||
2583 | |||
2584 | return scmd; | ||
2585 | } | ||
2555 | 2586 | ||
2556 | for (i = 0; i < hd->ioc->req_depth; i++) { | 2587 | /** |
2557 | if (hd->ScsiLookup[i] == sc) { | 2588 | * mptscsih_set_scsi_lookup |
2558 | return i; | 2589 | * |
2590 | * writes a scmd entry into the ScsiLookup[] array list | ||
2591 | * | ||
2592 | * @ioc: Pointer to MPT_ADAPTER structure | ||
2593 | * @i: index into the array | ||
2594 | * @scmd: scsi_cmnd pointer | ||
2595 | * | ||
2596 | **/ | ||
2597 | static void | ||
2598 | mptscsih_set_scsi_lookup(MPT_ADAPTER *ioc, int i, struct scsi_cmnd *scmd) | ||
2599 | { | ||
2600 | unsigned long flags; | ||
2601 | |||
2602 | spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); | ||
2603 | ioc->ScsiLookup[i] = scmd; | ||
2604 | spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); | ||
2605 | } | ||
2606 | |||
2607 | /** | ||
2608 | * SCPNT_TO_LOOKUP_IDX | ||
2609 | * | ||
2610 | * search's for a given scmd in the ScsiLookup[] array list | ||
2611 | * | ||
2612 | * @ioc: Pointer to MPT_ADAPTER structure | ||
2613 | * @scmd: scsi_cmnd pointer | ||
2614 | * | ||
2615 | **/ | ||
2616 | static int | ||
2617 | SCPNT_TO_LOOKUP_IDX(MPT_ADAPTER *ioc, struct scsi_cmnd *sc) | ||
2618 | { | ||
2619 | unsigned long flags; | ||
2620 | int i, index=-1; | ||
2621 | |||
2622 | spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); | ||
2623 | for (i = 0; i < ioc->req_depth; i++) { | ||
2624 | if (ioc->ScsiLookup[i] == sc) { | ||
2625 | index = i; | ||
2626 | goto out; | ||
2559 | } | 2627 | } |
2560 | } | 2628 | } |
2561 | 2629 | ||
2562 | return -1; | 2630 | out: |
2631 | spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); | ||
2632 | return index; | ||
2563 | } | 2633 | } |
2564 | 2634 | ||
2565 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | 2635 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ |
@@ -2568,21 +2638,20 @@ mptscsih_ioc_reset(MPT_ADAPTER *ioc, int reset_phase) | |||
2568 | { | 2638 | { |
2569 | MPT_SCSI_HOST *hd; | 2639 | MPT_SCSI_HOST *hd; |
2570 | unsigned long flags; | 2640 | unsigned long flags; |
2571 | int ii; | ||
2572 | 2641 | ||
2573 | dtmprintk(ioc, printk(KERN_DEBUG MYNAM | 2642 | dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT |
2574 | ": IOC %s_reset routed to SCSI host driver!\n", | 2643 | ": IOC %s_reset routed to SCSI host driver!\n", |
2575 | reset_phase==MPT_IOC_SETUP_RESET ? "setup" : ( | 2644 | ioc->name, reset_phase==MPT_IOC_SETUP_RESET ? "setup" : ( |
2576 | reset_phase==MPT_IOC_PRE_RESET ? "pre" : "post"))); | 2645 | reset_phase==MPT_IOC_PRE_RESET ? "pre" : "post"))); |
2577 | 2646 | ||
2578 | /* If a FW reload request arrives after base installed but | 2647 | /* If a FW reload request arrives after base installed but |
2579 | * before all scsi hosts have been attached, then an alt_ioc | 2648 | * before all scsi hosts have been attached, then an alt_ioc |
2580 | * may have a NULL sh pointer. | 2649 | * may have a NULL sh pointer. |
2581 | */ | 2650 | */ |
2582 | if ((ioc->sh == NULL) || (ioc->sh->hostdata == NULL)) | 2651 | if (ioc->sh == NULL || shost_priv(ioc->sh) == NULL) |
2583 | return 0; | 2652 | return 0; |
2584 | else | 2653 | else |
2585 | hd = (MPT_SCSI_HOST *) ioc->sh->hostdata; | 2654 | hd = shost_priv(ioc->sh); |
2586 | 2655 | ||
2587 | if (reset_phase == MPT_IOC_SETUP_RESET) { | 2656 | if (reset_phase == MPT_IOC_SETUP_RESET) { |
2588 | dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Setup-Diag Reset\n", ioc->name)); | 2657 | dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Setup-Diag Reset\n", ioc->name)); |
@@ -2624,11 +2693,6 @@ mptscsih_ioc_reset(MPT_ADAPTER *ioc, int reset_phase) | |||
2624 | * Init all control structures. | 2693 | * Init all control structures. |
2625 | */ | 2694 | */ |
2626 | 2695 | ||
2627 | /* ScsiLookup initialization | ||
2628 | */ | ||
2629 | for (ii=0; ii < hd->ioc->req_depth; ii++) | ||
2630 | hd->ScsiLookup[ii] = NULL; | ||
2631 | |||
2632 | /* 2. Chain Buffer initialization | 2696 | /* 2. Chain Buffer initialization |
2633 | */ | 2697 | */ |
2634 | 2698 | ||
@@ -2675,7 +2739,7 @@ mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply) | |||
2675 | ioc->name, event)); | 2739 | ioc->name, event)); |
2676 | 2740 | ||
2677 | if (ioc->sh == NULL || | 2741 | if (ioc->sh == NULL || |
2678 | ((hd = (MPT_SCSI_HOST *)ioc->sh->hostdata) == NULL)) | 2742 | ((hd = shost_priv(ioc->sh)) == NULL)) |
2679 | return 1; | 2743 | return 1; |
2680 | 2744 | ||
2681 | switch (event) { | 2745 | switch (event) { |
@@ -2713,7 +2777,8 @@ mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply) | |||
2713 | case MPI_EVENT_STATE_CHANGE: /* 02 */ | 2777 | case MPI_EVENT_STATE_CHANGE: /* 02 */ |
2714 | case MPI_EVENT_EVENT_CHANGE: /* 0A */ | 2778 | case MPI_EVENT_EVENT_CHANGE: /* 0A */ |
2715 | default: | 2779 | default: |
2716 | dprintk(ioc, printk(KERN_DEBUG MYNAM ": Ignoring event (=%02Xh)\n", event)); | 2780 | dprintk(ioc, printk(MYIOC_s_DEBUG_FMT ": Ignoring event (=%02Xh)\n", |
2781 | ioc->name, event)); | ||
2717 | break; | 2782 | break; |
2718 | } | 2783 | } |
2719 | 2784 | ||
@@ -2753,7 +2818,7 @@ mptscsih_scandv_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr) | |||
2753 | int completionCode; | 2818 | int completionCode; |
2754 | u16 req_idx; | 2819 | u16 req_idx; |
2755 | 2820 | ||
2756 | hd = (MPT_SCSI_HOST *) ioc->sh->hostdata; | 2821 | hd = shost_priv(ioc->sh); |
2757 | 2822 | ||
2758 | if ((mf == NULL) || | 2823 | if ((mf == NULL) || |
2759 | (mf >= MPT_INDEX_2_MFPTR(ioc, ioc->req_depth))) { | 2824 | (mf >= MPT_INDEX_2_MFPTR(ioc, ioc->req_depth))) { |
@@ -2765,17 +2830,17 @@ mptscsih_scandv_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr) | |||
2765 | 2830 | ||
2766 | del_timer(&hd->timer); | 2831 | del_timer(&hd->timer); |
2767 | req_idx = le16_to_cpu(mf->u.frame.hwhdr.msgctxu.fld.req_idx); | 2832 | req_idx = le16_to_cpu(mf->u.frame.hwhdr.msgctxu.fld.req_idx); |
2768 | hd->ScsiLookup[req_idx] = NULL; | 2833 | mptscsih_set_scsi_lookup(ioc, req_idx, NULL); |
2769 | pReq = (SCSIIORequest_t *) mf; | 2834 | pReq = (SCSIIORequest_t *) mf; |
2770 | 2835 | ||
2771 | if (mf != hd->cmdPtr) { | 2836 | if (mf != hd->cmdPtr) { |
2772 | printk(MYIOC_s_WARN_FMT "ScanDvComplete (mf=%p, cmdPtr=%p, idx=%d)\n", | 2837 | printk(MYIOC_s_WARN_FMT "ScanDvComplete (mf=%p, cmdPtr=%p, idx=%d)\n", |
2773 | hd->ioc->name, (void *)mf, (void *) hd->cmdPtr, req_idx); | 2838 | ioc->name, (void *)mf, (void *) hd->cmdPtr, req_idx); |
2774 | } | 2839 | } |
2775 | hd->cmdPtr = NULL; | 2840 | hd->cmdPtr = NULL; |
2776 | 2841 | ||
2777 | ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT "ScanDvComplete (mf=%p,mr=%p,idx=%d)\n", | 2842 | ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT "ScanDvComplete (mf=%p,mr=%p,idx=%d)\n", |
2778 | hd->ioc->name, mf, mr, req_idx)); | 2843 | ioc->name, mf, mr, req_idx)); |
2779 | 2844 | ||
2780 | hd->pLocal = &hd->localReply; | 2845 | hd->pLocal = &hd->localReply; |
2781 | hd->pLocal->scsiStatus = 0; | 2846 | hd->pLocal->scsiStatus = 0; |
@@ -2839,15 +2904,15 @@ mptscsih_scandv_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr) | |||
2839 | */ | 2904 | */ |
2840 | completionCode = MPT_SCANDV_SENSE; | 2905 | completionCode = MPT_SCANDV_SENSE; |
2841 | hd->pLocal->scsiStatus = scsi_status; | 2906 | hd->pLocal->scsiStatus = scsi_status; |
2842 | sense_data = ((u8 *)hd->ioc->sense_buf_pool + | 2907 | sense_data = ((u8 *)ioc->sense_buf_pool + |
2843 | (req_idx * MPT_SENSE_BUFFER_ALLOC)); | 2908 | (req_idx * MPT_SENSE_BUFFER_ALLOC)); |
2844 | 2909 | ||
2845 | sz = min_t(int, pReq->SenseBufferLength, | 2910 | sz = min_t(int, pReq->SenseBufferLength, |
2846 | SCSI_STD_SENSE_BYTES); | 2911 | SCSI_STD_SENSE_BYTES); |
2847 | memcpy(hd->pLocal->sense, sense_data, sz); | 2912 | memcpy(hd->pLocal->sense, sense_data, sz); |
2848 | 2913 | ||
2849 | ddvprintk(ioc, printk(KERN_DEBUG " Check Condition, sense ptr %p\n", | 2914 | ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT " Check Condition, sense ptr %p\n", |
2850 | sense_data)); | 2915 | ioc->name, sense_data)); |
2851 | } else if (pReply->SCSIState & MPI_SCSI_STATE_AUTOSENSE_FAILED) { | 2916 | } else if (pReply->SCSIState & MPI_SCSI_STATE_AUTOSENSE_FAILED) { |
2852 | if (pReq->CDB[0] == INQUIRY) | 2917 | if (pReq->CDB[0] == INQUIRY) |
2853 | completionCode = MPT_SCANDV_ISSUE_SENSE; | 2918 | completionCode = MPT_SCANDV_ISSUE_SENSE; |
@@ -2906,8 +2971,9 @@ void | |||
2906 | mptscsih_timer_expired(unsigned long data) | 2971 | mptscsih_timer_expired(unsigned long data) |
2907 | { | 2972 | { |
2908 | MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *) data; | 2973 | MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *) data; |
2974 | MPT_ADAPTER *ioc = hd->ioc; | ||
2909 | 2975 | ||
2910 | ddvprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "Timer Expired! Cmd %p\n", hd->ioc->name, hd->cmdPtr)); | 2976 | ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Timer Expired! Cmd %p\n", ioc->name, hd->cmdPtr)); |
2911 | 2977 | ||
2912 | if (hd->cmdPtr) { | 2978 | if (hd->cmdPtr) { |
2913 | MPIHeader_t *cmd = (MPIHeader_t *)hd->cmdPtr; | 2979 | MPIHeader_t *cmd = (MPIHeader_t *)hd->cmdPtr; |
@@ -2921,13 +2987,13 @@ mptscsih_timer_expired(unsigned long data) | |||
2921 | */ | 2987 | */ |
2922 | } else { | 2988 | } else { |
2923 | /* Perform a FW reload */ | 2989 | /* Perform a FW reload */ |
2924 | if (mpt_HardResetHandler(hd->ioc, NO_SLEEP) < 0) { | 2990 | if (mpt_HardResetHandler(ioc, NO_SLEEP) < 0) { |
2925 | printk(MYIOC_s_WARN_FMT "Firmware Reload FAILED!\n", hd->ioc->name); | 2991 | printk(MYIOC_s_WARN_FMT "Firmware Reload FAILED!\n", ioc->name); |
2926 | } | 2992 | } |
2927 | } | 2993 | } |
2928 | } else { | 2994 | } else { |
2929 | /* This should NEVER happen */ | 2995 | /* This should NEVER happen */ |
2930 | printk(MYIOC_s_WARN_FMT "Null cmdPtr!!!!\n", hd->ioc->name); | 2996 | printk(MYIOC_s_WARN_FMT "Null cmdPtr!!!!\n", ioc->name); |
2931 | } | 2997 | } |
2932 | 2998 | ||
2933 | /* No more processing. | 2999 | /* No more processing. |
@@ -2935,7 +3001,7 @@ mptscsih_timer_expired(unsigned long data) | |||
2935 | * The FW will reply to all outstanding commands, callback will finish cleanup. | 3001 | * The FW will reply to all outstanding commands, callback will finish cleanup. |
2936 | * Hard reset clean-up will free all resources. | 3002 | * Hard reset clean-up will free all resources. |
2937 | */ | 3003 | */ |
2938 | ddvprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "Timer Expired Complete!\n", hd->ioc->name)); | 3004 | ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Timer Expired Complete!\n", ioc->name)); |
2939 | 3005 | ||
2940 | return; | 3006 | return; |
2941 | } | 3007 | } |
@@ -2973,11 +3039,12 @@ mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *io) | |||
2973 | char cmdLen; | 3039 | char cmdLen; |
2974 | char CDB[]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; | 3040 | char CDB[]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; |
2975 | char cmd = io->cmd; | 3041 | char cmd = io->cmd; |
3042 | MPT_ADAPTER *ioc = hd->ioc; | ||
2976 | 3043 | ||
2977 | in_isr = in_interrupt(); | 3044 | in_isr = in_interrupt(); |
2978 | if (in_isr) { | 3045 | if (in_isr) { |
2979 | dprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "Internal SCSI IO request not allowed in ISR context!\n", | 3046 | dprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Internal SCSI IO request not allowed in ISR context!\n", |
2980 | hd->ioc->name)); | 3047 | ioc->name)); |
2981 | return -EPERM; | 3048 | return -EPERM; |
2982 | } | 3049 | } |
2983 | 3050 | ||
@@ -3078,9 +3145,9 @@ mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *io) | |||
3078 | 3145 | ||
3079 | /* Get and Populate a free Frame | 3146 | /* Get and Populate a free Frame |
3080 | */ | 3147 | */ |
3081 | if ((mf = mpt_get_msg_frame(hd->ioc->InternalCtx, hd->ioc)) == NULL) { | 3148 | if ((mf = mpt_get_msg_frame(ioc->InternalCtx, ioc)) == NULL) { |
3082 | ddvprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "No msg frames!\n", | 3149 | dfailprintk(ioc, printk(MYIOC_s_WARN_FMT "No msg frames!\n", |
3083 | hd->ioc->name)); | 3150 | ioc->name)); |
3084 | return -EBUSY; | 3151 | return -EBUSY; |
3085 | } | 3152 | } |
3086 | 3153 | ||
@@ -3119,19 +3186,19 @@ mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *io) | |||
3119 | 3186 | ||
3120 | if (cmd == REQUEST_SENSE) { | 3187 | if (cmd == REQUEST_SENSE) { |
3121 | pScsiReq->Control = cpu_to_le32(dir | MPI_SCSIIO_CONTROL_UNTAGGED); | 3188 | pScsiReq->Control = cpu_to_le32(dir | MPI_SCSIIO_CONTROL_UNTAGGED); |
3122 | ddvprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "Untagged! 0x%2x\n", | 3189 | ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Untagged! 0x%2x\n", |
3123 | hd->ioc->name, cmd)); | 3190 | ioc->name, cmd)); |
3124 | } | 3191 | } |
3125 | 3192 | ||
3126 | for (ii=0; ii < 16; ii++) | 3193 | for (ii=0; ii < 16; ii++) |
3127 | pScsiReq->CDB[ii] = CDB[ii]; | 3194 | pScsiReq->CDB[ii] = CDB[ii]; |
3128 | 3195 | ||
3129 | pScsiReq->DataLength = cpu_to_le32(io->size); | 3196 | pScsiReq->DataLength = cpu_to_le32(io->size); |
3130 | pScsiReq->SenseBufferLowAddr = cpu_to_le32(hd->ioc->sense_buf_low_dma | 3197 | pScsiReq->SenseBufferLowAddr = cpu_to_le32(ioc->sense_buf_low_dma |
3131 | + (my_idx * MPT_SENSE_BUFFER_ALLOC)); | 3198 | + (my_idx * MPT_SENSE_BUFFER_ALLOC)); |
3132 | 3199 | ||
3133 | ddvprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "Sending Command 0x%x for (%d:%d:%d)\n", | 3200 | ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Sending Command 0x%x for (%d:%d:%d)\n", |
3134 | hd->ioc->name, cmd, io->channel, io->id, io->lun)); | 3201 | ioc->name, cmd, io->channel, io->id, io->lun)); |
3135 | 3202 | ||
3136 | if (dir == MPI_SCSIIO_CONTROL_READ) { | 3203 | if (dir == MPI_SCSIIO_CONTROL_READ) { |
3137 | mpt_add_sge((char *) &pScsiReq->SGL, | 3204 | mpt_add_sge((char *) &pScsiReq->SGL, |
@@ -3166,7 +3233,7 @@ mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *io) | |||
3166 | hd->cmdPtr = mf; | 3233 | hd->cmdPtr = mf; |
3167 | 3234 | ||
3168 | add_timer(&hd->timer); | 3235 | add_timer(&hd->timer); |
3169 | mpt_put_msg_frame(hd->ioc->InternalCtx, hd->ioc, mf); | 3236 | mpt_put_msg_frame(ioc->InternalCtx, ioc, mf); |
3170 | wait_event(hd->scandv_waitq, hd->scandv_wait_done); | 3237 | wait_event(hd->scandv_waitq, hd->scandv_wait_done); |
3171 | 3238 | ||
3172 | if (hd->pLocal) { | 3239 | if (hd->pLocal) { |
@@ -3182,8 +3249,8 @@ mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *io) | |||
3182 | } else { | 3249 | } else { |
3183 | rc = -EFAULT; | 3250 | rc = -EFAULT; |
3184 | /* This should never happen. */ | 3251 | /* This should never happen. */ |
3185 | ddvprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "_do_cmd: Null pLocal!!!\n", | 3252 | ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT "_do_cmd: Null pLocal!!!\n", |
3186 | hd->ioc->name)); | 3253 | ioc->name)); |
3187 | } | 3254 | } |
3188 | 3255 | ||
3189 | return rc; | 3256 | return rc; |
@@ -3235,7 +3302,7 @@ static ssize_t | |||
3235 | mptscsih_version_fw_show(struct class_device *cdev, char *buf) | 3302 | mptscsih_version_fw_show(struct class_device *cdev, char *buf) |
3236 | { | 3303 | { |
3237 | struct Scsi_Host *host = class_to_shost(cdev); | 3304 | struct Scsi_Host *host = class_to_shost(cdev); |
3238 | MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; | 3305 | MPT_SCSI_HOST *hd = shost_priv(host); |
3239 | MPT_ADAPTER *ioc = hd->ioc; | 3306 | MPT_ADAPTER *ioc = hd->ioc; |
3240 | 3307 | ||
3241 | return snprintf(buf, PAGE_SIZE, "%02d.%02d.%02d.%02d\n", | 3308 | return snprintf(buf, PAGE_SIZE, "%02d.%02d.%02d.%02d\n", |
@@ -3250,7 +3317,7 @@ static ssize_t | |||
3250 | mptscsih_version_bios_show(struct class_device *cdev, char *buf) | 3317 | mptscsih_version_bios_show(struct class_device *cdev, char *buf) |
3251 | { | 3318 | { |
3252 | struct Scsi_Host *host = class_to_shost(cdev); | 3319 | struct Scsi_Host *host = class_to_shost(cdev); |
3253 | MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; | 3320 | MPT_SCSI_HOST *hd = shost_priv(host); |
3254 | MPT_ADAPTER *ioc = hd->ioc; | 3321 | MPT_ADAPTER *ioc = hd->ioc; |
3255 | 3322 | ||
3256 | return snprintf(buf, PAGE_SIZE, "%02x.%02x.%02x.%02x\n", | 3323 | return snprintf(buf, PAGE_SIZE, "%02x.%02x.%02x.%02x\n", |
@@ -3265,7 +3332,7 @@ static ssize_t | |||
3265 | mptscsih_version_mpi_show(struct class_device *cdev, char *buf) | 3332 | mptscsih_version_mpi_show(struct class_device *cdev, char *buf) |
3266 | { | 3333 | { |
3267 | struct Scsi_Host *host = class_to_shost(cdev); | 3334 | struct Scsi_Host *host = class_to_shost(cdev); |
3268 | MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; | 3335 | MPT_SCSI_HOST *hd = shost_priv(host); |
3269 | MPT_ADAPTER *ioc = hd->ioc; | 3336 | MPT_ADAPTER *ioc = hd->ioc; |
3270 | 3337 | ||
3271 | return snprintf(buf, PAGE_SIZE, "%03x\n", ioc->facts.MsgVersion); | 3338 | return snprintf(buf, PAGE_SIZE, "%03x\n", ioc->facts.MsgVersion); |
@@ -3276,7 +3343,7 @@ static ssize_t | |||
3276 | mptscsih_version_product_show(struct class_device *cdev, char *buf) | 3343 | mptscsih_version_product_show(struct class_device *cdev, char *buf) |
3277 | { | 3344 | { |
3278 | struct Scsi_Host *host = class_to_shost(cdev); | 3345 | struct Scsi_Host *host = class_to_shost(cdev); |
3279 | MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; | 3346 | MPT_SCSI_HOST *hd = shost_priv(host); |
3280 | MPT_ADAPTER *ioc = hd->ioc; | 3347 | MPT_ADAPTER *ioc = hd->ioc; |
3281 | 3348 | ||
3282 | return snprintf(buf, PAGE_SIZE, "%s\n", ioc->prod_name); | 3349 | return snprintf(buf, PAGE_SIZE, "%s\n", ioc->prod_name); |
@@ -3288,7 +3355,7 @@ static ssize_t | |||
3288 | mptscsih_version_nvdata_persistent_show(struct class_device *cdev, char *buf) | 3355 | mptscsih_version_nvdata_persistent_show(struct class_device *cdev, char *buf) |
3289 | { | 3356 | { |
3290 | struct Scsi_Host *host = class_to_shost(cdev); | 3357 | struct Scsi_Host *host = class_to_shost(cdev); |
3291 | MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; | 3358 | MPT_SCSI_HOST *hd = shost_priv(host); |
3292 | MPT_ADAPTER *ioc = hd->ioc; | 3359 | MPT_ADAPTER *ioc = hd->ioc; |
3293 | 3360 | ||
3294 | return snprintf(buf, PAGE_SIZE, "%02xh\n", | 3361 | return snprintf(buf, PAGE_SIZE, "%02xh\n", |
@@ -3301,7 +3368,7 @@ static ssize_t | |||
3301 | mptscsih_version_nvdata_default_show(struct class_device *cdev, char *buf) | 3368 | mptscsih_version_nvdata_default_show(struct class_device *cdev, char *buf) |
3302 | { | 3369 | { |
3303 | struct Scsi_Host *host = class_to_shost(cdev); | 3370 | struct Scsi_Host *host = class_to_shost(cdev); |
3304 | MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; | 3371 | MPT_SCSI_HOST *hd = shost_priv(host); |
3305 | MPT_ADAPTER *ioc = hd->ioc; | 3372 | MPT_ADAPTER *ioc = hd->ioc; |
3306 | 3373 | ||
3307 | return snprintf(buf, PAGE_SIZE, "%02xh\n",ioc->nvdata_version_default); | 3374 | return snprintf(buf, PAGE_SIZE, "%02xh\n",ioc->nvdata_version_default); |
@@ -3313,7 +3380,7 @@ static ssize_t | |||
3313 | mptscsih_board_name_show(struct class_device *cdev, char *buf) | 3380 | mptscsih_board_name_show(struct class_device *cdev, char *buf) |
3314 | { | 3381 | { |
3315 | struct Scsi_Host *host = class_to_shost(cdev); | 3382 | struct Scsi_Host *host = class_to_shost(cdev); |
3316 | MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; | 3383 | MPT_SCSI_HOST *hd = shost_priv(host); |
3317 | MPT_ADAPTER *ioc = hd->ioc; | 3384 | MPT_ADAPTER *ioc = hd->ioc; |
3318 | 3385 | ||
3319 | return snprintf(buf, PAGE_SIZE, "%s\n", ioc->board_name); | 3386 | return snprintf(buf, PAGE_SIZE, "%s\n", ioc->board_name); |
@@ -3324,7 +3391,7 @@ static ssize_t | |||
3324 | mptscsih_board_assembly_show(struct class_device *cdev, char *buf) | 3391 | mptscsih_board_assembly_show(struct class_device *cdev, char *buf) |
3325 | { | 3392 | { |
3326 | struct Scsi_Host *host = class_to_shost(cdev); | 3393 | struct Scsi_Host *host = class_to_shost(cdev); |
3327 | MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; | 3394 | MPT_SCSI_HOST *hd = shost_priv(host); |
3328 | MPT_ADAPTER *ioc = hd->ioc; | 3395 | MPT_ADAPTER *ioc = hd->ioc; |
3329 | 3396 | ||
3330 | return snprintf(buf, PAGE_SIZE, "%s\n", ioc->board_assembly); | 3397 | return snprintf(buf, PAGE_SIZE, "%s\n", ioc->board_assembly); |
@@ -3336,7 +3403,7 @@ static ssize_t | |||
3336 | mptscsih_board_tracer_show(struct class_device *cdev, char *buf) | 3403 | mptscsih_board_tracer_show(struct class_device *cdev, char *buf) |
3337 | { | 3404 | { |
3338 | struct Scsi_Host *host = class_to_shost(cdev); | 3405 | struct Scsi_Host *host = class_to_shost(cdev); |
3339 | MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; | 3406 | MPT_SCSI_HOST *hd = shost_priv(host); |
3340 | MPT_ADAPTER *ioc = hd->ioc; | 3407 | MPT_ADAPTER *ioc = hd->ioc; |
3341 | 3408 | ||
3342 | return snprintf(buf, PAGE_SIZE, "%s\n", ioc->board_tracer); | 3409 | return snprintf(buf, PAGE_SIZE, "%s\n", ioc->board_tracer); |
@@ -3348,7 +3415,7 @@ static ssize_t | |||
3348 | mptscsih_io_delay_show(struct class_device *cdev, char *buf) | 3415 | mptscsih_io_delay_show(struct class_device *cdev, char *buf) |
3349 | { | 3416 | { |
3350 | struct Scsi_Host *host = class_to_shost(cdev); | 3417 | struct Scsi_Host *host = class_to_shost(cdev); |
3351 | MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; | 3418 | MPT_SCSI_HOST *hd = shost_priv(host); |
3352 | MPT_ADAPTER *ioc = hd->ioc; | 3419 | MPT_ADAPTER *ioc = hd->ioc; |
3353 | 3420 | ||
3354 | return snprintf(buf, PAGE_SIZE, "%02d\n", ioc->io_missing_delay); | 3421 | return snprintf(buf, PAGE_SIZE, "%02d\n", ioc->io_missing_delay); |
@@ -3360,7 +3427,7 @@ static ssize_t | |||
3360 | mptscsih_device_delay_show(struct class_device *cdev, char *buf) | 3427 | mptscsih_device_delay_show(struct class_device *cdev, char *buf) |
3361 | { | 3428 | { |
3362 | struct Scsi_Host *host = class_to_shost(cdev); | 3429 | struct Scsi_Host *host = class_to_shost(cdev); |
3363 | MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; | 3430 | MPT_SCSI_HOST *hd = shost_priv(host); |
3364 | MPT_ADAPTER *ioc = hd->ioc; | 3431 | MPT_ADAPTER *ioc = hd->ioc; |
3365 | 3432 | ||
3366 | return snprintf(buf, PAGE_SIZE, "%02d\n", ioc->device_missing_delay); | 3433 | return snprintf(buf, PAGE_SIZE, "%02d\n", ioc->device_missing_delay); |
@@ -3372,7 +3439,7 @@ static ssize_t | |||
3372 | mptscsih_debug_level_show(struct class_device *cdev, char *buf) | 3439 | mptscsih_debug_level_show(struct class_device *cdev, char *buf) |
3373 | { | 3440 | { |
3374 | struct Scsi_Host *host = class_to_shost(cdev); | 3441 | struct Scsi_Host *host = class_to_shost(cdev); |
3375 | MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; | 3442 | MPT_SCSI_HOST *hd = shost_priv(host); |
3376 | MPT_ADAPTER *ioc = hd->ioc; | 3443 | MPT_ADAPTER *ioc = hd->ioc; |
3377 | 3444 | ||
3378 | return snprintf(buf, PAGE_SIZE, "%08xh\n", ioc->debug_level); | 3445 | return snprintf(buf, PAGE_SIZE, "%08xh\n", ioc->debug_level); |
@@ -3382,7 +3449,7 @@ mptscsih_debug_level_store(struct class_device *cdev, const char *buf, | |||
3382 | size_t count) | 3449 | size_t count) |
3383 | { | 3450 | { |
3384 | struct Scsi_Host *host = class_to_shost(cdev); | 3451 | struct Scsi_Host *host = class_to_shost(cdev); |
3385 | MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; | 3452 | MPT_SCSI_HOST *hd = shost_priv(host); |
3386 | MPT_ADAPTER *ioc = hd->ioc; | 3453 | MPT_ADAPTER *ioc = hd->ioc; |
3387 | int val = 0; | 3454 | int val = 0; |
3388 | 3455 | ||
diff --git a/drivers/message/fusion/mptscsih.h b/drivers/message/fusion/mptscsih.h index 67b088db2f10..d289e97cfe8b 100644 --- a/drivers/message/fusion/mptscsih.h +++ b/drivers/message/fusion/mptscsih.h | |||
@@ -3,9 +3,9 @@ | |||
3 | * High performance SCSI / Fibre Channel SCSI Host device driver. | 3 | * High performance SCSI / Fibre Channel SCSI Host device driver. |
4 | * For use with PCI chip/adapter(s): | 4 | * For use with PCI chip/adapter(s): |
5 | * LSIFC9xx/LSI409xx Fibre Channel | 5 | * LSIFC9xx/LSI409xx Fibre Channel |
6 | * running LSI Logic Fusion MPT (Message Passing Technology) firmware. | 6 | * running LSI Fusion MPT (Message Passing Technology) firmware. |
7 | * | 7 | * |
8 | * Copyright (c) 1999-2007 LSI Logic Corporation | 8 | * Copyright (c) 1999-2007 LSI Corporation |
9 | * (mailto:DL-MPTFusionLinux@lsi.com) | 9 | * (mailto:DL-MPTFusionLinux@lsi.com) |
10 | * | 10 | * |
11 | */ | 11 | */ |
diff --git a/drivers/message/fusion/mptspi.c b/drivers/message/fusion/mptspi.c index 8c98420640a5..25bcfcf36f2e 100644 --- a/drivers/message/fusion/mptspi.c +++ b/drivers/message/fusion/mptspi.c | |||
@@ -1,9 +1,9 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/message/fusion/mptspi.c | 2 | * linux/drivers/message/fusion/mptspi.c |
3 | * For use with LSI Logic PCI chip/adapter(s) | 3 | * For use with LSI PCI chip/adapter(s) |
4 | * running LSI Logic Fusion MPT (Message Passing Technology) firmware. | 4 | * running LSI Fusion MPT (Message Passing Technology) firmware. |
5 | * | 5 | * |
6 | * Copyright (c) 1999-2007 LSI Logic Corporation | 6 | * Copyright (c) 1999-2007 LSI Corporation |
7 | * (mailto:DL-MPTFusionLinux@lsi.com) | 7 | * (mailto:DL-MPTFusionLinux@lsi.com) |
8 | * | 8 | * |
9 | */ | 9 | */ |
@@ -90,9 +90,9 @@ static int mptspi_write_spi_device_pg1(struct scsi_target *, | |||
90 | 90 | ||
91 | static struct scsi_transport_template *mptspi_transport_template = NULL; | 91 | static struct scsi_transport_template *mptspi_transport_template = NULL; |
92 | 92 | ||
93 | static int mptspiDoneCtx = -1; | 93 | static u8 mptspiDoneCtx = MPT_MAX_PROTOCOL_DRIVERS; |
94 | static int mptspiTaskCtx = -1; | 94 | static u8 mptspiTaskCtx = MPT_MAX_PROTOCOL_DRIVERS; |
95 | static int mptspiInternalCtx = -1; /* Used only for internal commands */ | 95 | static u8 mptspiInternalCtx = MPT_MAX_PROTOCOL_DRIVERS; /* Used only for internal commands */ |
96 | 96 | ||
97 | /** | 97 | /** |
98 | * mptspi_setTargetNegoParms - Update the target negotiation parameters | 98 | * mptspi_setTargetNegoParms - Update the target negotiation parameters |
@@ -107,7 +107,8 @@ static void | |||
107 | mptspi_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtTarget *target, | 107 | mptspi_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtTarget *target, |
108 | struct scsi_device *sdev) | 108 | struct scsi_device *sdev) |
109 | { | 109 | { |
110 | SpiCfgData *pspi_data = &hd->ioc->spi_data; | 110 | MPT_ADAPTER *ioc = hd->ioc; |
111 | SpiCfgData *pspi_data = &ioc->spi_data; | ||
111 | int id = (int) target->id; | 112 | int id = (int) target->id; |
112 | int nvram; | 113 | int nvram; |
113 | u8 width = MPT_NARROW; | 114 | u8 width = MPT_NARROW; |
@@ -138,9 +139,10 @@ mptspi_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtTarget *target, | |||
138 | else { | 139 | else { |
139 | factor = MPT_ULTRA320; | 140 | factor = MPT_ULTRA320; |
140 | if (scsi_device_qas(sdev)) { | 141 | if (scsi_device_qas(sdev)) { |
141 | ddvprintk(hd->ioc, | 142 | ddvprintk(ioc, |
142 | printk(KERN_DEBUG "Enabling QAS due to " | 143 | printk(MYIOC_s_DEBUG_FMT "Enabling QAS due to " |
143 | "byte56=%02x on id=%d!\n", scsi_device_qas(sdev), id)); | 144 | "byte56=%02x on id=%d!\n", ioc->name, |
145 | scsi_device_qas(sdev), id)); | ||
144 | noQas = 0; | 146 | noQas = 0; |
145 | } | 147 | } |
146 | if (sdev->type == TYPE_TAPE && | 148 | if (sdev->type == TYPE_TAPE && |
@@ -227,8 +229,8 @@ mptspi_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtTarget *target, | |||
227 | /* Disable QAS in a mixed configuration case | 229 | /* Disable QAS in a mixed configuration case |
228 | */ | 230 | */ |
229 | 231 | ||
230 | ddvprintk(hd->ioc, printk(KERN_DEBUG | 232 | ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT |
231 | "Disabling QAS due to noQas=%02x on id=%d!\n", noQas, id)); | 233 | "Disabling QAS due to noQas=%02x on id=%d!\n", ioc->name, noQas, id)); |
232 | } | 234 | } |
233 | } | 235 | } |
234 | 236 | ||
@@ -302,7 +304,7 @@ mptspi_writeIOCPage4(MPT_SCSI_HOST *hd, u8 channel , u8 id) | |||
302 | 304 | ||
303 | ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT | 305 | ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT |
304 | "writeIOCPage4: MaxSEP=%d ActiveSEP=%d id=%d bus=%d\n", | 306 | "writeIOCPage4: MaxSEP=%d ActiveSEP=%d id=%d bus=%d\n", |
305 | ioc->name, IOCPage4Ptr->MaxSEP, IOCPage4Ptr->ActiveSEP, id, channel)); | 307 | ioc->name, IOCPage4Ptr->MaxSEP, IOCPage4Ptr->ActiveSEP, id, channel)); |
306 | 308 | ||
307 | mpt_put_msg_frame(ioc->DoneCtx, ioc, mf); | 309 | mpt_put_msg_frame(ioc->DoneCtx, ioc, mf); |
308 | 310 | ||
@@ -374,14 +376,15 @@ static int | |||
374 | mptspi_is_raid(struct _MPT_SCSI_HOST *hd, u32 id) | 376 | mptspi_is_raid(struct _MPT_SCSI_HOST *hd, u32 id) |
375 | { | 377 | { |
376 | int i, rc = 0; | 378 | int i, rc = 0; |
379 | MPT_ADAPTER *ioc = hd->ioc; | ||
377 | 380 | ||
378 | if (!hd->ioc->raid_data.pIocPg2) | 381 | if (!ioc->raid_data.pIocPg2) |
379 | goto out; | 382 | goto out; |
380 | 383 | ||
381 | if (!hd->ioc->raid_data.pIocPg2->NumActiveVolumes) | 384 | if (!ioc->raid_data.pIocPg2->NumActiveVolumes) |
382 | goto out; | 385 | goto out; |
383 | for (i=0; i < hd->ioc->raid_data.pIocPg2->NumActiveVolumes; i++) { | 386 | for (i=0; i < ioc->raid_data.pIocPg2->NumActiveVolumes; i++) { |
384 | if (hd->ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID == id) { | 387 | if (ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID == id) { |
385 | rc = 1; | 388 | rc = 1; |
386 | goto out; | 389 | goto out; |
387 | } | 390 | } |
@@ -394,17 +397,19 @@ mptspi_is_raid(struct _MPT_SCSI_HOST *hd, u32 id) | |||
394 | static int mptspi_target_alloc(struct scsi_target *starget) | 397 | static int mptspi_target_alloc(struct scsi_target *starget) |
395 | { | 398 | { |
396 | struct Scsi_Host *shost = dev_to_shost(&starget->dev); | 399 | struct Scsi_Host *shost = dev_to_shost(&starget->dev); |
397 | struct _MPT_SCSI_HOST *hd = (struct _MPT_SCSI_HOST *)shost->hostdata; | 400 | struct _MPT_SCSI_HOST *hd = shost_priv(shost); |
398 | VirtTarget *vtarget; | 401 | VirtTarget *vtarget; |
402 | MPT_ADAPTER *ioc; | ||
399 | 403 | ||
400 | if (hd == NULL) | 404 | if (hd == NULL) |
401 | return -ENODEV; | 405 | return -ENODEV; |
402 | 406 | ||
407 | ioc = hd->ioc; | ||
403 | vtarget = kzalloc(sizeof(VirtTarget), GFP_KERNEL); | 408 | vtarget = kzalloc(sizeof(VirtTarget), GFP_KERNEL); |
404 | if (!vtarget) | 409 | if (!vtarget) |
405 | return -ENOMEM; | 410 | return -ENOMEM; |
406 | 411 | ||
407 | vtarget->ioc_id = hd->ioc->id; | 412 | vtarget->ioc_id = ioc->id; |
408 | vtarget->tflags = MPT_TARGET_FLAGS_Q_YES; | 413 | vtarget->tflags = MPT_TARGET_FLAGS_Q_YES; |
409 | vtarget->id = (u8)starget->id; | 414 | vtarget->id = (u8)starget->id; |
410 | vtarget->channel = (u8)starget->channel; | 415 | vtarget->channel = (u8)starget->channel; |
@@ -412,34 +417,34 @@ static int mptspi_target_alloc(struct scsi_target *starget) | |||
412 | starget->hostdata = vtarget; | 417 | starget->hostdata = vtarget; |
413 | 418 | ||
414 | if (starget->channel == 1) { | 419 | if (starget->channel == 1) { |
415 | if (mptscsih_is_phys_disk(hd->ioc, 0, starget->id) == 0) | 420 | if (mptscsih_is_phys_disk(ioc, 0, starget->id) == 0) |
416 | return 0; | 421 | return 0; |
417 | vtarget->tflags |= MPT_TARGET_FLAGS_RAID_COMPONENT; | 422 | vtarget->tflags |= MPT_TARGET_FLAGS_RAID_COMPONENT; |
418 | /* The real channel for this device is zero */ | 423 | /* The real channel for this device is zero */ |
419 | vtarget->channel = 0; | 424 | vtarget->channel = 0; |
420 | /* The actual physdisknum (for RAID passthrough) */ | 425 | /* The actual physdisknum (for RAID passthrough) */ |
421 | vtarget->id = mptscsih_raid_id_to_num(hd->ioc, 0, | 426 | vtarget->id = mptscsih_raid_id_to_num(ioc, 0, |
422 | starget->id); | 427 | starget->id); |
423 | } | 428 | } |
424 | 429 | ||
425 | if (starget->channel == 0 && | 430 | if (starget->channel == 0 && |
426 | mptspi_is_raid(hd, starget->id)) { | 431 | mptspi_is_raid(hd, starget->id)) { |
427 | vtarget->raidVolume = 1; | 432 | vtarget->raidVolume = 1; |
428 | ddvprintk(hd->ioc, printk(KERN_DEBUG | 433 | ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT |
429 | "RAID Volume @ channel=%d id=%d\n", starget->channel, | 434 | "RAID Volume @ channel=%d id=%d\n", ioc->name, starget->channel, |
430 | starget->id)); | 435 | starget->id)); |
431 | } | 436 | } |
432 | 437 | ||
433 | if (hd->ioc->spi_data.nvram && | 438 | if (ioc->spi_data.nvram && |
434 | hd->ioc->spi_data.nvram[starget->id] != MPT_HOST_NVRAM_INVALID) { | 439 | ioc->spi_data.nvram[starget->id] != MPT_HOST_NVRAM_INVALID) { |
435 | u32 nvram = hd->ioc->spi_data.nvram[starget->id]; | 440 | u32 nvram = ioc->spi_data.nvram[starget->id]; |
436 | spi_min_period(starget) = (nvram & MPT_NVRAM_SYNC_MASK) >> MPT_NVRAM_SYNC_SHIFT; | 441 | spi_min_period(starget) = (nvram & MPT_NVRAM_SYNC_MASK) >> MPT_NVRAM_SYNC_SHIFT; |
437 | spi_max_width(starget) = nvram & MPT_NVRAM_WIDE_DISABLE ? 0 : 1; | 442 | spi_max_width(starget) = nvram & MPT_NVRAM_WIDE_DISABLE ? 0 : 1; |
438 | } else { | 443 | } else { |
439 | spi_min_period(starget) = hd->ioc->spi_data.minSyncFactor; | 444 | spi_min_period(starget) = ioc->spi_data.minSyncFactor; |
440 | spi_max_width(starget) = hd->ioc->spi_data.maxBusWidth; | 445 | spi_max_width(starget) = ioc->spi_data.maxBusWidth; |
441 | } | 446 | } |
442 | spi_max_offset(starget) = hd->ioc->spi_data.maxSyncOffset; | 447 | spi_max_offset(starget) = ioc->spi_data.maxSyncOffset; |
443 | 448 | ||
444 | spi_offset(starget) = 0; | 449 | spi_offset(starget) = 0; |
445 | mptspi_write_width(starget, 0); | 450 | mptspi_write_width(starget, 0); |
@@ -509,10 +514,10 @@ static int mptspi_read_spi_device_pg0(struct scsi_target *starget, | |||
509 | struct _CONFIG_PAGE_SCSI_DEVICE_0 *pass_pg0) | 514 | struct _CONFIG_PAGE_SCSI_DEVICE_0 *pass_pg0) |
510 | { | 515 | { |
511 | struct Scsi_Host *shost = dev_to_shost(&starget->dev); | 516 | struct Scsi_Host *shost = dev_to_shost(&starget->dev); |
512 | struct _MPT_SCSI_HOST *hd = (struct _MPT_SCSI_HOST *)shost->hostdata; | 517 | struct _MPT_SCSI_HOST *hd = shost_priv(shost); |
513 | struct _MPT_ADAPTER *ioc = hd->ioc; | 518 | struct _MPT_ADAPTER *ioc = hd->ioc; |
514 | struct _CONFIG_PAGE_SCSI_DEVICE_0 *pg0; | 519 | struct _CONFIG_PAGE_SCSI_DEVICE_0 *spi_dev_pg0; |
515 | dma_addr_t pg0_dma; | 520 | dma_addr_t spi_dev_pg0_dma; |
516 | int size; | 521 | int size; |
517 | struct _x_config_parms cfg; | 522 | struct _x_config_parms cfg; |
518 | struct _CONFIG_PAGE_HEADER hdr; | 523 | struct _CONFIG_PAGE_HEADER hdr; |
@@ -530,9 +535,10 @@ static int mptspi_read_spi_device_pg0(struct scsi_target *starget, | |||
530 | size += 2048; | 535 | size += 2048; |
531 | */ | 536 | */ |
532 | 537 | ||
533 | pg0 = dma_alloc_coherent(&ioc->pcidev->dev, size, &pg0_dma, GFP_KERNEL); | 538 | spi_dev_pg0 = dma_alloc_coherent(&ioc->pcidev->dev, size, &spi_dev_pg0_dma, GFP_KERNEL); |
534 | if (pg0 == NULL) { | 539 | if (spi_dev_pg0 == NULL) { |
535 | starget_printk(KERN_ERR, starget, "dma_alloc_coherent for parameters failed\n"); | 540 | starget_printk(KERN_ERR, starget, MYIOC_s_FMT |
541 | "dma_alloc_coherent for parameters failed\n", ioc->name); | ||
536 | return -EINVAL; | 542 | return -EINVAL; |
537 | } | 543 | } |
538 | 544 | ||
@@ -546,22 +552,22 @@ static int mptspi_read_spi_device_pg0(struct scsi_target *starget, | |||
546 | memset(&cfg, 0, sizeof(cfg)); | 552 | memset(&cfg, 0, sizeof(cfg)); |
547 | 553 | ||
548 | cfg.cfghdr.hdr = &hdr; | 554 | cfg.cfghdr.hdr = &hdr; |
549 | cfg.physAddr = pg0_dma; | 555 | cfg.physAddr = spi_dev_pg0_dma; |
550 | cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT; | 556 | cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT; |
551 | cfg.dir = 0; | 557 | cfg.dir = 0; |
552 | cfg.pageAddr = starget->id; | 558 | cfg.pageAddr = starget->id; |
553 | 559 | ||
554 | if (mpt_config(ioc, &cfg)) { | 560 | if (mpt_config(ioc, &cfg)) { |
555 | starget_printk(KERN_ERR, starget, "mpt_config failed\n"); | 561 | starget_printk(KERN_ERR, starget, MYIOC_s_FMT "mpt_config failed\n", ioc->name); |
556 | goto out_free; | 562 | goto out_free; |
557 | } | 563 | } |
558 | err = 0; | 564 | err = 0; |
559 | memcpy(pass_pg0, pg0, size); | 565 | memcpy(pass_pg0, spi_dev_pg0, size); |
560 | 566 | ||
561 | mptspi_print_read_nego(hd, starget, le32_to_cpu(pg0->NegotiatedParameters)); | 567 | mptspi_print_read_nego(hd, starget, le32_to_cpu(spi_dev_pg0->NegotiatedParameters)); |
562 | 568 | ||
563 | out_free: | 569 | out_free: |
564 | dma_free_coherent(&ioc->pcidev->dev, size, pg0, pg0_dma); | 570 | dma_free_coherent(&ioc->pcidev->dev, size, spi_dev_pg0, spi_dev_pg0_dma); |
565 | return err; | 571 | return err; |
566 | } | 572 | } |
567 | 573 | ||
@@ -588,11 +594,11 @@ static u32 mptspi_getRP(struct scsi_target *starget) | |||
588 | static void mptspi_read_parameters(struct scsi_target *starget) | 594 | static void mptspi_read_parameters(struct scsi_target *starget) |
589 | { | 595 | { |
590 | int nego; | 596 | int nego; |
591 | struct _CONFIG_PAGE_SCSI_DEVICE_0 pg0; | 597 | struct _CONFIG_PAGE_SCSI_DEVICE_0 spi_dev_pg0; |
592 | 598 | ||
593 | mptspi_read_spi_device_pg0(starget, &pg0); | 599 | mptspi_read_spi_device_pg0(starget, &spi_dev_pg0); |
594 | 600 | ||
595 | nego = le32_to_cpu(pg0.NegotiatedParameters); | 601 | nego = le32_to_cpu(spi_dev_pg0.NegotiatedParameters); |
596 | 602 | ||
597 | spi_iu(starget) = (nego & MPI_SCSIDEVPAGE0_NP_IU) ? 1 : 0; | 603 | spi_iu(starget) = (nego & MPI_SCSIDEVPAGE0_NP_IU) ? 1 : 0; |
598 | spi_dt(starget) = (nego & MPI_SCSIDEVPAGE0_NP_DT) ? 1 : 0; | 604 | spi_dt(starget) = (nego & MPI_SCSIDEVPAGE0_NP_DT) ? 1 : 0; |
@@ -612,12 +618,13 @@ mptscsih_quiesce_raid(MPT_SCSI_HOST *hd, int quiesce, u8 channel, u8 id) | |||
612 | { | 618 | { |
613 | MpiRaidActionRequest_t *pReq; | 619 | MpiRaidActionRequest_t *pReq; |
614 | MPT_FRAME_HDR *mf; | 620 | MPT_FRAME_HDR *mf; |
621 | MPT_ADAPTER *ioc = hd->ioc; | ||
615 | 622 | ||
616 | /* Get and Populate a free Frame | 623 | /* Get and Populate a free Frame |
617 | */ | 624 | */ |
618 | if ((mf = mpt_get_msg_frame(hd->ioc->InternalCtx, hd->ioc)) == NULL) { | 625 | if ((mf = mpt_get_msg_frame(ioc->InternalCtx, ioc)) == NULL) { |
619 | ddvprintk(hd->ioc, printk(MYIOC_s_WARN_FMT "_do_raid: no msg frames!\n", | 626 | ddvprintk(ioc, printk(MYIOC_s_WARN_FMT "_do_raid: no msg frames!\n", |
620 | hd->ioc->name)); | 627 | ioc->name)); |
621 | return -EAGAIN; | 628 | return -EAGAIN; |
622 | } | 629 | } |
623 | pReq = (MpiRaidActionRequest_t *)mf; | 630 | pReq = (MpiRaidActionRequest_t *)mf; |
@@ -638,8 +645,8 @@ mptscsih_quiesce_raid(MPT_SCSI_HOST *hd, int quiesce, u8 channel, u8 id) | |||
638 | mpt_add_sge((char *)&pReq->ActionDataSGE, | 645 | mpt_add_sge((char *)&pReq->ActionDataSGE, |
639 | MPT_SGE_FLAGS_SSIMPLE_READ | 0, (dma_addr_t) -1); | 646 | MPT_SGE_FLAGS_SSIMPLE_READ | 0, (dma_addr_t) -1); |
640 | 647 | ||
641 | ddvprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "RAID Volume action=%x channel=%d id=%d\n", | 648 | ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT "RAID Volume action=%x channel=%d id=%d\n", |
642 | hd->ioc->name, pReq->Action, channel, id)); | 649 | ioc->name, pReq->Action, channel, id)); |
643 | 650 | ||
644 | hd->pLocal = NULL; | 651 | hd->pLocal = NULL; |
645 | hd->timer.expires = jiffies + HZ*10; /* 10 second timeout */ | 652 | hd->timer.expires = jiffies + HZ*10; /* 10 second timeout */ |
@@ -651,7 +658,7 @@ mptscsih_quiesce_raid(MPT_SCSI_HOST *hd, int quiesce, u8 channel, u8 id) | |||
651 | hd->cmdPtr = mf; | 658 | hd->cmdPtr = mf; |
652 | 659 | ||
653 | add_timer(&hd->timer); | 660 | add_timer(&hd->timer); |
654 | mpt_put_msg_frame(hd->ioc->InternalCtx, hd->ioc, mf); | 661 | mpt_put_msg_frame(ioc->InternalCtx, ioc, mf); |
655 | wait_event(hd->scandv_waitq, hd->scandv_wait_done); | 662 | wait_event(hd->scandv_waitq, hd->scandv_wait_done); |
656 | 663 | ||
657 | if ((hd->pLocal == NULL) || (hd->pLocal->completion != 0)) | 664 | if ((hd->pLocal == NULL) || (hd->pLocal->completion != 0)) |
@@ -664,6 +671,7 @@ static void mptspi_dv_device(struct _MPT_SCSI_HOST *hd, | |||
664 | struct scsi_device *sdev) | 671 | struct scsi_device *sdev) |
665 | { | 672 | { |
666 | VirtTarget *vtarget = scsi_target(sdev)->hostdata; | 673 | VirtTarget *vtarget = scsi_target(sdev)->hostdata; |
674 | MPT_ADAPTER *ioc = hd->ioc; | ||
667 | 675 | ||
668 | /* no DV on RAID devices */ | 676 | /* no DV on RAID devices */ |
669 | if (sdev->channel == 0 && | 677 | if (sdev->channel == 0 && |
@@ -673,8 +681,8 @@ static void mptspi_dv_device(struct _MPT_SCSI_HOST *hd, | |||
673 | /* If this is a piece of a RAID, then quiesce first */ | 681 | /* If this is a piece of a RAID, then quiesce first */ |
674 | if (sdev->channel == 1 && | 682 | if (sdev->channel == 1 && |
675 | mptscsih_quiesce_raid(hd, 1, vtarget->channel, vtarget->id) < 0) { | 683 | mptscsih_quiesce_raid(hd, 1, vtarget->channel, vtarget->id) < 0) { |
676 | starget_printk(KERN_ERR, scsi_target(sdev), | 684 | starget_printk(KERN_ERR, scsi_target(sdev), MYIOC_s_FMT |
677 | "Integrated RAID quiesce failed\n"); | 685 | "Integrated RAID quiesce failed\n", ioc->name); |
678 | return; | 686 | return; |
679 | } | 687 | } |
680 | 688 | ||
@@ -684,8 +692,8 @@ static void mptspi_dv_device(struct _MPT_SCSI_HOST *hd, | |||
684 | 692 | ||
685 | if (sdev->channel == 1 && | 693 | if (sdev->channel == 1 && |
686 | mptscsih_quiesce_raid(hd, 0, vtarget->channel, vtarget->id) < 0) | 694 | mptscsih_quiesce_raid(hd, 0, vtarget->channel, vtarget->id) < 0) |
687 | starget_printk(KERN_ERR, scsi_target(sdev), | 695 | starget_printk(KERN_ERR, scsi_target(sdev), MYIOC_s_FMT |
688 | "Integrated RAID resume failed\n"); | 696 | "Integrated RAID resume failed\n", ioc->name); |
689 | 697 | ||
690 | mptspi_read_parameters(sdev->sdev_target); | 698 | mptspi_read_parameters(sdev->sdev_target); |
691 | spi_display_xfer_agreement(sdev->sdev_target); | 699 | spi_display_xfer_agreement(sdev->sdev_target); |
@@ -694,28 +702,29 @@ static void mptspi_dv_device(struct _MPT_SCSI_HOST *hd, | |||
694 | 702 | ||
695 | static int mptspi_slave_alloc(struct scsi_device *sdev) | 703 | static int mptspi_slave_alloc(struct scsi_device *sdev) |
696 | { | 704 | { |
697 | MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)sdev->host->hostdata; | 705 | MPT_SCSI_HOST *hd = shost_priv(sdev->host); |
698 | VirtTarget *vtarget; | 706 | VirtTarget *vtarget; |
699 | VirtDevice *vdev; | 707 | VirtDevice *vdevice; |
700 | struct scsi_target *starget; | 708 | struct scsi_target *starget; |
709 | MPT_ADAPTER *ioc = hd->ioc; | ||
701 | 710 | ||
702 | if (sdev->channel == 1 && | 711 | if (sdev->channel == 1 && |
703 | mptscsih_is_phys_disk(hd->ioc, 0, sdev->id) == 0) | 712 | mptscsih_is_phys_disk(ioc, 0, sdev->id) == 0) |
704 | return -ENXIO; | 713 | return -ENXIO; |
705 | 714 | ||
706 | vdev = kzalloc(sizeof(VirtDevice), GFP_KERNEL); | 715 | vdevice = kzalloc(sizeof(VirtDevice), GFP_KERNEL); |
707 | if (!vdev) { | 716 | if (!vdevice) { |
708 | printk(MYIOC_s_ERR_FMT "slave_alloc kmalloc(%zd) FAILED!\n", | 717 | printk(MYIOC_s_ERR_FMT "slave_alloc kmalloc(%zd) FAILED!\n", |
709 | hd->ioc->name, sizeof(VirtDevice)); | 718 | ioc->name, sizeof(VirtDevice)); |
710 | return -ENOMEM; | 719 | return -ENOMEM; |
711 | } | 720 | } |
712 | 721 | ||
713 | vdev->lun = sdev->lun; | 722 | vdevice->lun = sdev->lun; |
714 | sdev->hostdata = vdev; | 723 | sdev->hostdata = vdevice; |
715 | 724 | ||
716 | starget = scsi_target(sdev); | 725 | starget = scsi_target(sdev); |
717 | vtarget = starget->hostdata; | 726 | vtarget = starget->hostdata; |
718 | vdev->vtarget = vtarget; | 727 | vdevice->vtarget = vtarget; |
719 | vtarget->num_luns++; | 728 | vtarget->num_luns++; |
720 | 729 | ||
721 | if (sdev->channel == 1) | 730 | if (sdev->channel == 1) |
@@ -726,8 +735,7 @@ static int mptspi_slave_alloc(struct scsi_device *sdev) | |||
726 | 735 | ||
727 | static int mptspi_slave_configure(struct scsi_device *sdev) | 736 | static int mptspi_slave_configure(struct scsi_device *sdev) |
728 | { | 737 | { |
729 | struct _MPT_SCSI_HOST *hd = | 738 | struct _MPT_SCSI_HOST *hd = shost_priv(sdev->host); |
730 | (struct _MPT_SCSI_HOST *)sdev->host->hostdata; | ||
731 | VirtTarget *vtarget = scsi_target(sdev)->hostdata; | 739 | VirtTarget *vtarget = scsi_target(sdev)->hostdata; |
732 | int ret; | 740 | int ret; |
733 | 741 | ||
@@ -755,24 +763,25 @@ static int mptspi_slave_configure(struct scsi_device *sdev) | |||
755 | static int | 763 | static int |
756 | mptspi_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) | 764 | mptspi_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) |
757 | { | 765 | { |
758 | struct _MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata; | 766 | struct _MPT_SCSI_HOST *hd = shost_priv(SCpnt->device->host); |
759 | VirtDevice *vdev = SCpnt->device->hostdata; | 767 | VirtDevice *vdevice = SCpnt->device->hostdata; |
768 | MPT_ADAPTER *ioc = hd->ioc; | ||
760 | 769 | ||
761 | if (!vdev || !vdev->vtarget) { | 770 | if (!vdevice || !vdevice->vtarget) { |
762 | SCpnt->result = DID_NO_CONNECT << 16; | 771 | SCpnt->result = DID_NO_CONNECT << 16; |
763 | done(SCpnt); | 772 | done(SCpnt); |
764 | return 0; | 773 | return 0; |
765 | } | 774 | } |
766 | 775 | ||
767 | if (SCpnt->device->channel == 1 && | 776 | if (SCpnt->device->channel == 1 && |
768 | mptscsih_is_phys_disk(hd->ioc, 0, SCpnt->device->id) == 0) { | 777 | mptscsih_is_phys_disk(ioc, 0, SCpnt->device->id) == 0) { |
769 | SCpnt->result = DID_NO_CONNECT << 16; | 778 | SCpnt->result = DID_NO_CONNECT << 16; |
770 | done(SCpnt); | 779 | done(SCpnt); |
771 | return 0; | 780 | return 0; |
772 | } | 781 | } |
773 | 782 | ||
774 | if (spi_dv_pending(scsi_target(SCpnt->device))) | 783 | if (spi_dv_pending(scsi_target(SCpnt->device))) |
775 | ddvprintk(hd->ioc, scsi_print_command(SCpnt)); | 784 | ddvprintk(ioc, scsi_print_command(SCpnt)); |
776 | 785 | ||
777 | return mptscsih_qcmd(SCpnt,done); | 786 | return mptscsih_qcmd(SCpnt,done); |
778 | } | 787 | } |
@@ -829,7 +838,7 @@ static int mptspi_write_spi_device_pg1(struct scsi_target *starget, | |||
829 | struct _CONFIG_PAGE_SCSI_DEVICE_1 *pass_pg1) | 838 | struct _CONFIG_PAGE_SCSI_DEVICE_1 *pass_pg1) |
830 | { | 839 | { |
831 | struct Scsi_Host *shost = dev_to_shost(&starget->dev); | 840 | struct Scsi_Host *shost = dev_to_shost(&starget->dev); |
832 | struct _MPT_SCSI_HOST *hd = (struct _MPT_SCSI_HOST *)shost->hostdata; | 841 | struct _MPT_SCSI_HOST *hd = shost_priv(shost); |
833 | struct _MPT_ADAPTER *ioc = hd->ioc; | 842 | struct _MPT_ADAPTER *ioc = hd->ioc; |
834 | struct _CONFIG_PAGE_SCSI_DEVICE_1 *pg1; | 843 | struct _CONFIG_PAGE_SCSI_DEVICE_1 *pg1; |
835 | dma_addr_t pg1_dma; | 844 | dma_addr_t pg1_dma; |
@@ -847,7 +856,8 @@ static int mptspi_write_spi_device_pg1(struct scsi_target *starget, | |||
847 | 856 | ||
848 | pg1 = dma_alloc_coherent(&ioc->pcidev->dev, size, &pg1_dma, GFP_KERNEL); | 857 | pg1 = dma_alloc_coherent(&ioc->pcidev->dev, size, &pg1_dma, GFP_KERNEL); |
849 | if (pg1 == NULL) { | 858 | if (pg1 == NULL) { |
850 | starget_printk(KERN_ERR, starget, "dma_alloc_coherent for parameters failed\n"); | 859 | starget_printk(KERN_ERR, starget, MYIOC_s_FMT |
860 | "dma_alloc_coherent for parameters failed\n", ioc->name); | ||
851 | return -EINVAL; | 861 | return -EINVAL; |
852 | } | 862 | } |
853 | 863 | ||
@@ -876,7 +886,8 @@ static int mptspi_write_spi_device_pg1(struct scsi_target *starget, | |||
876 | mptspi_print_write_nego(hd, starget, le32_to_cpu(pg1->RequestedParameters)); | 886 | mptspi_print_write_nego(hd, starget, le32_to_cpu(pg1->RequestedParameters)); |
877 | 887 | ||
878 | if (mpt_config(ioc, &cfg)) { | 888 | if (mpt_config(ioc, &cfg)) { |
879 | starget_printk(KERN_ERR, starget, "mpt_config failed\n"); | 889 | starget_printk(KERN_ERR, starget, MYIOC_s_FMT |
890 | "mpt_config failed\n", ioc->name); | ||
880 | goto out_free; | 891 | goto out_free; |
881 | } | 892 | } |
882 | err = 0; | 893 | err = 0; |
@@ -1015,7 +1026,7 @@ static void mptspi_write_qas(struct scsi_target *starget, int qas) | |||
1015 | { | 1026 | { |
1016 | struct _CONFIG_PAGE_SCSI_DEVICE_1 pg1; | 1027 | struct _CONFIG_PAGE_SCSI_DEVICE_1 pg1; |
1017 | struct Scsi_Host *shost = dev_to_shost(&starget->dev); | 1028 | struct Scsi_Host *shost = dev_to_shost(&starget->dev); |
1018 | struct _MPT_SCSI_HOST *hd = (struct _MPT_SCSI_HOST *)shost->hostdata; | 1029 | struct _MPT_SCSI_HOST *hd = shost_priv(shost); |
1019 | VirtTarget *vtarget = starget->hostdata; | 1030 | VirtTarget *vtarget = starget->hostdata; |
1020 | u32 nego; | 1031 | u32 nego; |
1021 | 1032 | ||
@@ -1067,15 +1078,16 @@ static void mpt_work_wrapper(struct work_struct *work) | |||
1067 | struct work_queue_wrapper *wqw = | 1078 | struct work_queue_wrapper *wqw = |
1068 | container_of(work, struct work_queue_wrapper, work); | 1079 | container_of(work, struct work_queue_wrapper, work); |
1069 | struct _MPT_SCSI_HOST *hd = wqw->hd; | 1080 | struct _MPT_SCSI_HOST *hd = wqw->hd; |
1070 | struct Scsi_Host *shost = hd->ioc->sh; | 1081 | MPT_ADAPTER *ioc = hd->ioc; |
1082 | struct Scsi_Host *shost = ioc->sh; | ||
1071 | struct scsi_device *sdev; | 1083 | struct scsi_device *sdev; |
1072 | int disk = wqw->disk; | 1084 | int disk = wqw->disk; |
1073 | struct _CONFIG_PAGE_IOC_3 *pg3; | 1085 | struct _CONFIG_PAGE_IOC_3 *pg3; |
1074 | 1086 | ||
1075 | kfree(wqw); | 1087 | kfree(wqw); |
1076 | 1088 | ||
1077 | mpt_findImVolumes(hd->ioc); | 1089 | mpt_findImVolumes(ioc); |
1078 | pg3 = hd->ioc->raid_data.pIocPg3; | 1090 | pg3 = ioc->raid_data.pIocPg3; |
1079 | if (!pg3) | 1091 | if (!pg3) |
1080 | return; | 1092 | return; |
1081 | 1093 | ||
@@ -1092,24 +1104,25 @@ static void mpt_work_wrapper(struct work_struct *work) | |||
1092 | if(vtarget->id != disk) | 1104 | if(vtarget->id != disk) |
1093 | continue; | 1105 | continue; |
1094 | 1106 | ||
1095 | starget_printk(KERN_INFO, vtarget->starget, | 1107 | starget_printk(KERN_INFO, vtarget->starget, MYIOC_s_FMT |
1096 | "Integrated RAID requests DV of new device\n"); | 1108 | "Integrated RAID requests DV of new device\n", ioc->name); |
1097 | mptspi_dv_device(hd, sdev); | 1109 | mptspi_dv_device(hd, sdev); |
1098 | } | 1110 | } |
1099 | shost_printk(KERN_INFO, shost, | 1111 | shost_printk(KERN_INFO, shost, MYIOC_s_FMT |
1100 | "Integrated RAID detects new device %d\n", disk); | 1112 | "Integrated RAID detects new device %d\n", ioc->name, disk); |
1101 | scsi_scan_target(&hd->ioc->sh->shost_gendev, 1, disk, 0, 1); | 1113 | scsi_scan_target(&ioc->sh->shost_gendev, 1, disk, 0, 1); |
1102 | } | 1114 | } |
1103 | 1115 | ||
1104 | 1116 | ||
1105 | static void mpt_dv_raid(struct _MPT_SCSI_HOST *hd, int disk) | 1117 | static void mpt_dv_raid(struct _MPT_SCSI_HOST *hd, int disk) |
1106 | { | 1118 | { |
1107 | struct work_queue_wrapper *wqw = kmalloc(sizeof(*wqw), GFP_ATOMIC); | 1119 | struct work_queue_wrapper *wqw = kmalloc(sizeof(*wqw), GFP_ATOMIC); |
1120 | MPT_ADAPTER *ioc = hd->ioc; | ||
1108 | 1121 | ||
1109 | if (!wqw) { | 1122 | if (!wqw) { |
1110 | shost_printk(KERN_ERR, hd->ioc->sh, | 1123 | shost_printk(KERN_ERR, ioc->sh, MYIOC_s_FMT |
1111 | "Failed to act on RAID event for physical disk %d\n", | 1124 | "Failed to act on RAID event for physical disk %d\n", |
1112 | disk); | 1125 | ioc->name, disk); |
1113 | return; | 1126 | return; |
1114 | } | 1127 | } |
1115 | INIT_WORK(&wqw->work, mpt_work_wrapper); | 1128 | INIT_WORK(&wqw->work, mpt_work_wrapper); |
@@ -1123,7 +1136,7 @@ static int | |||
1123 | mptspi_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply) | 1136 | mptspi_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply) |
1124 | { | 1137 | { |
1125 | u8 event = le32_to_cpu(pEvReply->Event) & 0xFF; | 1138 | u8 event = le32_to_cpu(pEvReply->Event) & 0xFF; |
1126 | struct _MPT_SCSI_HOST *hd = (struct _MPT_SCSI_HOST *)ioc->sh->hostdata; | 1139 | struct _MPT_SCSI_HOST *hd = shost_priv(ioc->sh); |
1127 | 1140 | ||
1128 | if (hd && event == MPI_EVENT_INTEGRATED_RAID) { | 1141 | if (hd && event == MPI_EVENT_INTEGRATED_RAID) { |
1129 | int reason | 1142 | int reason |
@@ -1190,6 +1203,8 @@ static struct spi_function_template mptspi_transport_functions = { | |||
1190 | static struct pci_device_id mptspi_pci_table[] = { | 1203 | static struct pci_device_id mptspi_pci_table[] = { |
1191 | { PCI_VENDOR_ID_LSI_LOGIC, MPI_MANUFACTPAGE_DEVID_53C1030, | 1204 | { PCI_VENDOR_ID_LSI_LOGIC, MPI_MANUFACTPAGE_DEVID_53C1030, |
1192 | PCI_ANY_ID, PCI_ANY_ID }, | 1205 | PCI_ANY_ID, PCI_ANY_ID }, |
1206 | { PCI_VENDOR_ID_ATTO, MPI_MANUFACTPAGE_DEVID_53C1030, | ||
1207 | PCI_ANY_ID, PCI_ANY_ID }, | ||
1193 | { PCI_VENDOR_ID_LSI_LOGIC, MPI_MANUFACTPAGE_DEVID_53C1035, | 1208 | { PCI_VENDOR_ID_LSI_LOGIC, MPI_MANUFACTPAGE_DEVID_53C1035, |
1194 | PCI_ANY_ID, PCI_ANY_ID }, | 1209 | PCI_ANY_ID, PCI_ANY_ID }, |
1195 | {0} /* Terminating entry */ | 1210 | {0} /* Terminating entry */ |
@@ -1210,11 +1225,12 @@ mptspi_dv_renegotiate_work(struct work_struct *work) | |||
1210 | struct scsi_target *starget; | 1225 | struct scsi_target *starget; |
1211 | struct _CONFIG_PAGE_SCSI_DEVICE_1 pg1; | 1226 | struct _CONFIG_PAGE_SCSI_DEVICE_1 pg1; |
1212 | u32 nego; | 1227 | u32 nego; |
1228 | MPT_ADAPTER *ioc = hd->ioc; | ||
1213 | 1229 | ||
1214 | kfree(wqw); | 1230 | kfree(wqw); |
1215 | 1231 | ||
1216 | if (hd->spi_pending) { | 1232 | if (hd->spi_pending) { |
1217 | shost_for_each_device(sdev, hd->ioc->sh) { | 1233 | shost_for_each_device(sdev, ioc->sh) { |
1218 | if (hd->spi_pending & (1 << sdev->id)) | 1234 | if (hd->spi_pending & (1 << sdev->id)) |
1219 | continue; | 1235 | continue; |
1220 | starget = scsi_target(sdev); | 1236 | starget = scsi_target(sdev); |
@@ -1225,7 +1241,7 @@ mptspi_dv_renegotiate_work(struct work_struct *work) | |||
1225 | mptspi_write_spi_device_pg1(starget, &pg1); | 1241 | mptspi_write_spi_device_pg1(starget, &pg1); |
1226 | } | 1242 | } |
1227 | } else { | 1243 | } else { |
1228 | shost_for_each_device(sdev, hd->ioc->sh) | 1244 | shost_for_each_device(sdev, ioc->sh) |
1229 | mptspi_dv_device(hd, sdev); | 1245 | mptspi_dv_device(hd, sdev); |
1230 | } | 1246 | } |
1231 | } | 1247 | } |
@@ -1250,7 +1266,7 @@ mptspi_dv_renegotiate(struct _MPT_SCSI_HOST *hd) | |||
1250 | static int | 1266 | static int |
1251 | mptspi_ioc_reset(MPT_ADAPTER *ioc, int reset_phase) | 1267 | mptspi_ioc_reset(MPT_ADAPTER *ioc, int reset_phase) |
1252 | { | 1268 | { |
1253 | struct _MPT_SCSI_HOST *hd = (struct _MPT_SCSI_HOST *)ioc->sh->hostdata; | 1269 | struct _MPT_SCSI_HOST *hd = shost_priv(ioc->sh); |
1254 | int rc; | 1270 | int rc; |
1255 | 1271 | ||
1256 | rc = mptscsih_ioc_reset(ioc, reset_phase); | 1272 | rc = mptscsih_ioc_reset(ioc, reset_phase); |
@@ -1269,7 +1285,7 @@ static int | |||
1269 | mptspi_resume(struct pci_dev *pdev) | 1285 | mptspi_resume(struct pci_dev *pdev) |
1270 | { | 1286 | { |
1271 | MPT_ADAPTER *ioc = pci_get_drvdata(pdev); | 1287 | MPT_ADAPTER *ioc = pci_get_drvdata(pdev); |
1272 | struct _MPT_SCSI_HOST *hd = (struct _MPT_SCSI_HOST *)ioc->sh->hostdata; | 1288 | struct _MPT_SCSI_HOST *hd = shost_priv(ioc->sh); |
1273 | int rc; | 1289 | int rc; |
1274 | 1290 | ||
1275 | rc = mptscsih_resume(pdev); | 1291 | rc = mptscsih_resume(pdev); |
@@ -1416,7 +1432,7 @@ mptspi_probe(struct pci_dev *pdev, const struct pci_device_id *id) | |||
1416 | 1432 | ||
1417 | if (numSGE < sh->sg_tablesize) { | 1433 | if (numSGE < sh->sg_tablesize) { |
1418 | /* Reset this value */ | 1434 | /* Reset this value */ |
1419 | dprintk(ioc, printk(MYIOC_s_INFO_FMT | 1435 | dprintk(ioc, printk(MYIOC_s_DEBUG_FMT |
1420 | "Resetting sg_tablesize to %d from %d\n", | 1436 | "Resetting sg_tablesize to %d from %d\n", |
1421 | ioc->name, numSGE, sh->sg_tablesize)); | 1437 | ioc->name, numSGE, sh->sg_tablesize)); |
1422 | sh->sg_tablesize = numSGE; | 1438 | sh->sg_tablesize = numSGE; |
@@ -1424,20 +1440,21 @@ mptspi_probe(struct pci_dev *pdev, const struct pci_device_id *id) | |||
1424 | 1440 | ||
1425 | spin_unlock_irqrestore(&ioc->FreeQlock, flags); | 1441 | spin_unlock_irqrestore(&ioc->FreeQlock, flags); |
1426 | 1442 | ||
1427 | hd = (MPT_SCSI_HOST *) sh->hostdata; | 1443 | hd = shost_priv(sh); |
1428 | hd->ioc = ioc; | 1444 | hd->ioc = ioc; |
1429 | 1445 | ||
1430 | /* SCSI needs scsi_cmnd lookup table! | 1446 | /* SCSI needs scsi_cmnd lookup table! |
1431 | * (with size equal to req_depth*PtrSz!) | 1447 | * (with size equal to req_depth*PtrSz!) |
1432 | */ | 1448 | */ |
1433 | hd->ScsiLookup = kcalloc(ioc->req_depth, sizeof(void *), GFP_ATOMIC); | 1449 | ioc->ScsiLookup = kcalloc(ioc->req_depth, sizeof(void *), GFP_ATOMIC); |
1434 | if (!hd->ScsiLookup) { | 1450 | if (!ioc->ScsiLookup) { |
1435 | error = -ENOMEM; | 1451 | error = -ENOMEM; |
1436 | goto out_mptspi_probe; | 1452 | goto out_mptspi_probe; |
1437 | } | 1453 | } |
1454 | spin_lock_init(&ioc->scsi_lookup_lock); | ||
1438 | 1455 | ||
1439 | dprintk(ioc, printk(MYIOC_s_DEBUG_FMT "ScsiLookup @ %p\n", | 1456 | dprintk(ioc, printk(MYIOC_s_DEBUG_FMT "ScsiLookup @ %p\n", |
1440 | ioc->name, hd->ScsiLookup)); | 1457 | ioc->name, ioc->ScsiLookup)); |
1441 | 1458 | ||
1442 | /* Clear the TM flags | 1459 | /* Clear the TM flags |
1443 | */ | 1460 | */ |
@@ -1477,13 +1494,13 @@ mptspi_probe(struct pci_dev *pdev, const struct pci_device_id *id) | |||
1477 | 1494 | ||
1478 | /* Some versions of the firmware don't support page 0; without | 1495 | /* Some versions of the firmware don't support page 0; without |
1479 | * that we can't get the parameters */ | 1496 | * that we can't get the parameters */ |
1480 | if (hd->ioc->spi_data.sdp0length != 0) | 1497 | if (ioc->spi_data.sdp0length != 0) |
1481 | sh->transportt = mptspi_transport_template; | 1498 | sh->transportt = mptspi_transport_template; |
1482 | 1499 | ||
1483 | error = scsi_add_host (sh, &ioc->pcidev->dev); | 1500 | error = scsi_add_host (sh, &ioc->pcidev->dev); |
1484 | if(error) { | 1501 | if(error) { |
1485 | dprintk(ioc, printk(KERN_ERR MYNAM | 1502 | dprintk(ioc, printk(MYIOC_s_ERR_FMT |
1486 | "scsi_add_host failed\n")); | 1503 | "scsi_add_host failed\n", ioc->name)); |
1487 | goto out_mptspi_probe; | 1504 | goto out_mptspi_probe; |
1488 | } | 1505 | } |
1489 | 1506 | ||