diff options
Diffstat (limited to 'drivers/message')
-rw-r--r-- | drivers/message/fusion/Kconfig | 17 | ||||
-rw-r--r-- | drivers/message/fusion/Makefile | 1 | ||||
-rw-r--r-- | drivers/message/fusion/mptbase.c | 963 | ||||
-rw-r--r-- | drivers/message/fusion/mptbase.h | 56 | ||||
-rw-r--r-- | drivers/message/fusion/mptctl.c | 4 | ||||
-rw-r--r-- | drivers/message/fusion/mptfc.c | 2 | ||||
-rw-r--r-- | drivers/message/fusion/mptlan.c | 7 | ||||
-rw-r--r-- | drivers/message/fusion/mptsas.c | 1235 | ||||
-rw-r--r-- | drivers/message/fusion/mptscsih.c | 463 | ||||
-rw-r--r-- | drivers/message/fusion/mptscsih.h | 7 | ||||
-rw-r--r-- | drivers/message/fusion/mptspi.c | 2 | ||||
-rw-r--r-- | drivers/message/i2o/config-osm.c | 5 |
12 files changed, 2276 insertions, 486 deletions
diff --git a/drivers/message/fusion/Kconfig b/drivers/message/fusion/Kconfig index 33f209a39cb6..1883d22cffeb 100644 --- a/drivers/message/fusion/Kconfig +++ b/drivers/message/fusion/Kconfig | |||
@@ -35,6 +35,23 @@ config FUSION_FC | |||
35 | LSIFC929X | 35 | LSIFC929X |
36 | LSIFC929XL | 36 | LSIFC929XL |
37 | 37 | ||
38 | config FUSION_SAS | ||
39 | tristate "Fusion MPT ScsiHost drivers for SAS" | ||
40 | depends on PCI && SCSI | ||
41 | select FUSION | ||
42 | select SCSI_SAS_ATTRS | ||
43 | ---help--- | ||
44 | SCSI HOST support for a SAS host adapters. | ||
45 | |||
46 | List of supported controllers: | ||
47 | |||
48 | LSISAS1064 | ||
49 | LSISAS1066 | ||
50 | LSISAS1068 | ||
51 | LSISAS1064E | ||
52 | LSISAS1066E | ||
53 | LSISAS1068E | ||
54 | |||
38 | config FUSION_MAX_SGE | 55 | config FUSION_MAX_SGE |
39 | int "Maximum number of scatter gather entries (16 - 128)" | 56 | int "Maximum number of scatter gather entries (16 - 128)" |
40 | depends on FUSION | 57 | depends on FUSION |
diff --git a/drivers/message/fusion/Makefile b/drivers/message/fusion/Makefile index 1d2f9db813c1..8a2e2657f4c2 100644 --- a/drivers/message/fusion/Makefile +++ b/drivers/message/fusion/Makefile | |||
@@ -34,5 +34,6 @@ | |||
34 | 34 | ||
35 | obj-$(CONFIG_FUSION_SPI) += mptbase.o mptscsih.o mptspi.o | 35 | obj-$(CONFIG_FUSION_SPI) += mptbase.o mptscsih.o mptspi.o |
36 | obj-$(CONFIG_FUSION_FC) += mptbase.o mptscsih.o mptfc.o | 36 | obj-$(CONFIG_FUSION_FC) += mptbase.o mptscsih.o mptfc.o |
37 | obj-$(CONFIG_FUSION_SAS) += mptbase.o mptscsih.o mptsas.o | ||
37 | obj-$(CONFIG_FUSION_CTL) += mptctl.o | 38 | obj-$(CONFIG_FUSION_CTL) += mptctl.o |
38 | obj-$(CONFIG_FUSION_LAN) += mptlan.o | 39 | obj-$(CONFIG_FUSION_LAN) += mptlan.o |
diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c index f517d0692d5f..790a2932ded9 100644 --- a/drivers/message/fusion/mptbase.c +++ b/drivers/message/fusion/mptbase.c | |||
@@ -135,13 +135,12 @@ static void mpt_adapter_dispose(MPT_ADAPTER *ioc); | |||
135 | 135 | ||
136 | static void MptDisplayIocCapabilities(MPT_ADAPTER *ioc); | 136 | static void MptDisplayIocCapabilities(MPT_ADAPTER *ioc); |
137 | static int MakeIocReady(MPT_ADAPTER *ioc, int force, int sleepFlag); | 137 | static int MakeIocReady(MPT_ADAPTER *ioc, int force, int sleepFlag); |
138 | //static u32 mpt_GetIocState(MPT_ADAPTER *ioc, int cooked); | ||
139 | static int GetIocFacts(MPT_ADAPTER *ioc, int sleepFlag, int reason); | 138 | static int GetIocFacts(MPT_ADAPTER *ioc, int sleepFlag, int reason); |
140 | static int GetPortFacts(MPT_ADAPTER *ioc, int portnum, int sleepFlag); | 139 | static int GetPortFacts(MPT_ADAPTER *ioc, int portnum, int sleepFlag); |
141 | static int SendIocInit(MPT_ADAPTER *ioc, int sleepFlag); | 140 | static int SendIocInit(MPT_ADAPTER *ioc, int sleepFlag); |
142 | static int SendPortEnable(MPT_ADAPTER *ioc, int portnum, int sleepFlag); | 141 | static int SendPortEnable(MPT_ADAPTER *ioc, int portnum, int sleepFlag); |
143 | static int mpt_do_upload(MPT_ADAPTER *ioc, int sleepFlag); | 142 | static int mpt_do_upload(MPT_ADAPTER *ioc, int sleepFlag); |
144 | static int mpt_downloadboot(MPT_ADAPTER *ioc, int sleepFlag); | 143 | static int mpt_downloadboot(MPT_ADAPTER *ioc, MpiFwHeader_t *pFwHeader, int sleepFlag); |
145 | static int mpt_diag_reset(MPT_ADAPTER *ioc, int ignore, int sleepFlag); | 144 | static int mpt_diag_reset(MPT_ADAPTER *ioc, int ignore, int sleepFlag); |
146 | static int KickStart(MPT_ADAPTER *ioc, int ignore, int sleepFlag); | 145 | static int KickStart(MPT_ADAPTER *ioc, int ignore, int sleepFlag); |
147 | static int SendIocReset(MPT_ADAPTER *ioc, u8 reset_type, int sleepFlag); | 146 | static int SendIocReset(MPT_ADAPTER *ioc, u8 reset_type, int sleepFlag); |
@@ -152,6 +151,7 @@ static int WaitForDoorbellReply(MPT_ADAPTER *ioc, int howlong, int sleepFlag); | |||
152 | static int GetLanConfigPages(MPT_ADAPTER *ioc); | 151 | static int GetLanConfigPages(MPT_ADAPTER *ioc); |
153 | static int GetFcPortPage0(MPT_ADAPTER *ioc, int portnum); | 152 | static int GetFcPortPage0(MPT_ADAPTER *ioc, int portnum); |
154 | static int GetIoUnitPage2(MPT_ADAPTER *ioc); | 153 | static int GetIoUnitPage2(MPT_ADAPTER *ioc); |
154 | int mptbase_sas_persist_operation(MPT_ADAPTER *ioc, u8 persist_opcode); | ||
155 | static int mpt_GetScsiPortSettings(MPT_ADAPTER *ioc, int portnum); | 155 | static int mpt_GetScsiPortSettings(MPT_ADAPTER *ioc, int portnum); |
156 | static int mpt_readScsiDevicePageHeaders(MPT_ADAPTER *ioc, int portnum); | 156 | static int mpt_readScsiDevicePageHeaders(MPT_ADAPTER *ioc, int portnum); |
157 | static void mpt_read_ioc_pg_1(MPT_ADAPTER *ioc); | 157 | static void mpt_read_ioc_pg_1(MPT_ADAPTER *ioc); |
@@ -159,6 +159,8 @@ static void mpt_read_ioc_pg_4(MPT_ADAPTER *ioc); | |||
159 | static void mpt_timer_expired(unsigned long data); | 159 | static void mpt_timer_expired(unsigned long data); |
160 | static int SendEventNotification(MPT_ADAPTER *ioc, u8 EvSwitch); | 160 | static int SendEventNotification(MPT_ADAPTER *ioc, u8 EvSwitch); |
161 | static int SendEventAck(MPT_ADAPTER *ioc, EventNotificationReply_t *evnp); | 161 | static int SendEventAck(MPT_ADAPTER *ioc, EventNotificationReply_t *evnp); |
162 | static int mpt_host_page_access_control(MPT_ADAPTER *ioc, u8 access_control_value, int sleepFlag); | ||
163 | static int mpt_host_page_alloc(MPT_ADAPTER *ioc, pIOCInit_t ioc_init); | ||
162 | 164 | ||
163 | #ifdef CONFIG_PROC_FS | 165 | #ifdef CONFIG_PROC_FS |
164 | static int procmpt_summary_read(char *buf, char **start, off_t offset, | 166 | static int procmpt_summary_read(char *buf, char **start, off_t offset, |
@@ -175,6 +177,7 @@ static int ProcessEventNotification(MPT_ADAPTER *ioc, EventNotificationReply_t * | |||
175 | static void mpt_sp_ioc_info(MPT_ADAPTER *ioc, u32 ioc_status, MPT_FRAME_HDR *mf); | 177 | static void mpt_sp_ioc_info(MPT_ADAPTER *ioc, u32 ioc_status, MPT_FRAME_HDR *mf); |
176 | static void mpt_fc_log_info(MPT_ADAPTER *ioc, u32 log_info); | 178 | static void mpt_fc_log_info(MPT_ADAPTER *ioc, u32 log_info); |
177 | static void mpt_sp_log_info(MPT_ADAPTER *ioc, u32 log_info); | 179 | static void mpt_sp_log_info(MPT_ADAPTER *ioc, u32 log_info); |
180 | static void mpt_sas_log_info(MPT_ADAPTER *ioc, u32 log_info); | ||
178 | 181 | ||
179 | /* module entry point */ | 182 | /* module entry point */ |
180 | static int __init fusion_init (void); | 183 | static int __init fusion_init (void); |
@@ -206,6 +209,144 @@ pci_enable_io_access(struct pci_dev *pdev) | |||
206 | pci_write_config_word(pdev, PCI_COMMAND, command_reg); | 209 | pci_write_config_word(pdev, PCI_COMMAND, command_reg); |
207 | } | 210 | } |
208 | 211 | ||
212 | /* | ||
213 | * Process turbo (context) reply... | ||
214 | */ | ||
215 | static void | ||
216 | mpt_turbo_reply(MPT_ADAPTER *ioc, u32 pa) | ||
217 | { | ||
218 | MPT_FRAME_HDR *mf = NULL; | ||
219 | MPT_FRAME_HDR *mr = NULL; | ||
220 | int req_idx = 0; | ||
221 | int cb_idx; | ||
222 | |||
223 | dmfprintk((MYIOC_s_INFO_FMT "Got TURBO reply req_idx=%08x\n", | ||
224 | ioc->name, pa)); | ||
225 | |||
226 | switch (pa >> MPI_CONTEXT_REPLY_TYPE_SHIFT) { | ||
227 | case MPI_CONTEXT_REPLY_TYPE_SCSI_INIT: | ||
228 | req_idx = pa & 0x0000FFFF; | ||
229 | cb_idx = (pa & 0x00FF0000) >> 16; | ||
230 | mf = MPT_INDEX_2_MFPTR(ioc, req_idx); | ||
231 | break; | ||
232 | case MPI_CONTEXT_REPLY_TYPE_LAN: | ||
233 | cb_idx = mpt_lan_index; | ||
234 | /* | ||
235 | * Blind set of mf to NULL here was fatal | ||
236 | * after lan_reply says "freeme" | ||
237 | * Fix sort of combined with an optimization here; | ||
238 | * added explicit check for case where lan_reply | ||
239 | * was just returning 1 and doing nothing else. | ||
240 | * For this case skip the callback, but set up | ||
241 | * proper mf value first here:-) | ||
242 | */ | ||
243 | if ((pa & 0x58000000) == 0x58000000) { | ||
244 | req_idx = pa & 0x0000FFFF; | ||
245 | mf = MPT_INDEX_2_MFPTR(ioc, req_idx); | ||
246 | mpt_free_msg_frame(ioc, mf); | ||
247 | mb(); | ||
248 | return; | ||
249 | break; | ||
250 | } | ||
251 | mr = (MPT_FRAME_HDR *) CAST_U32_TO_PTR(pa); | ||
252 | break; | ||
253 | case MPI_CONTEXT_REPLY_TYPE_SCSI_TARGET: | ||
254 | cb_idx = mpt_stm_index; | ||
255 | mr = (MPT_FRAME_HDR *) CAST_U32_TO_PTR(pa); | ||
256 | break; | ||
257 | default: | ||
258 | cb_idx = 0; | ||
259 | BUG(); | ||
260 | } | ||
261 | |||
262 | /* Check for (valid) IO callback! */ | ||
263 | if (cb_idx < 1 || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS || | ||
264 | MptCallbacks[cb_idx] == NULL) { | ||
265 | printk(MYIOC_s_WARN_FMT "%s: Invalid cb_idx (%d)!\n", | ||
266 | __FUNCTION__, ioc->name, cb_idx); | ||
267 | goto out; | ||
268 | } | ||
269 | |||
270 | if (MptCallbacks[cb_idx](ioc, mf, mr)) | ||
271 | mpt_free_msg_frame(ioc, mf); | ||
272 | out: | ||
273 | mb(); | ||
274 | } | ||
275 | |||
276 | static void | ||
277 | mpt_reply(MPT_ADAPTER *ioc, u32 pa) | ||
278 | { | ||
279 | MPT_FRAME_HDR *mf; | ||
280 | MPT_FRAME_HDR *mr; | ||
281 | int req_idx; | ||
282 | int cb_idx; | ||
283 | int freeme; | ||
284 | |||
285 | u32 reply_dma_low; | ||
286 | u16 ioc_stat; | ||
287 | |||
288 | /* non-TURBO reply! Hmmm, something may be up... | ||
289 | * Newest turbo reply mechanism; get address | ||
290 | * via left shift 1 (get rid of MPI_ADDRESS_REPLY_A_BIT)! | ||
291 | */ | ||
292 | |||
293 | /* Map DMA address of reply header to cpu address. | ||
294 | * pa is 32 bits - but the dma address may be 32 or 64 bits | ||
295 | * get offset based only only the low addresses | ||
296 | */ | ||
297 | |||
298 | reply_dma_low = (pa <<= 1); | ||
299 | mr = (MPT_FRAME_HDR *)((u8 *)ioc->reply_frames + | ||
300 | (reply_dma_low - ioc->reply_frames_low_dma)); | ||
301 | |||
302 | req_idx = le16_to_cpu(mr->u.frame.hwhdr.msgctxu.fld.req_idx); | ||
303 | cb_idx = mr->u.frame.hwhdr.msgctxu.fld.cb_idx; | ||
304 | mf = MPT_INDEX_2_MFPTR(ioc, req_idx); | ||
305 | |||
306 | dmfprintk((MYIOC_s_INFO_FMT "Got non-TURBO reply=%p req_idx=%x cb_idx=%x Function=%x\n", | ||
307 | ioc->name, mr, req_idx, cb_idx, mr->u.hdr.Function)); | ||
308 | DBG_DUMP_REPLY_FRAME(mr) | ||
309 | |||
310 | /* Check/log IOC log info | ||
311 | */ | ||
312 | ioc_stat = le16_to_cpu(mr->u.reply.IOCStatus); | ||
313 | if (ioc_stat & MPI_IOCSTATUS_FLAG_LOG_INFO_AVAILABLE) { | ||
314 | u32 log_info = le32_to_cpu(mr->u.reply.IOCLogInfo); | ||
315 | if (ioc->bus_type == FC) | ||
316 | mpt_fc_log_info(ioc, log_info); | ||
317 | else if (ioc->bus_type == SCSI) | ||
318 | mpt_sp_log_info(ioc, log_info); | ||
319 | else if (ioc->bus_type == SAS) | ||
320 | mpt_sas_log_info(ioc, log_info); | ||
321 | } | ||
322 | if (ioc_stat & MPI_IOCSTATUS_MASK) { | ||
323 | if (ioc->bus_type == SCSI && | ||
324 | cb_idx != mpt_stm_index && | ||
325 | cb_idx != mpt_lan_index) | ||
326 | mpt_sp_ioc_info(ioc, (u32)ioc_stat, mf); | ||
327 | } | ||
328 | |||
329 | |||
330 | /* Check for (valid) IO callback! */ | ||
331 | if (cb_idx < 1 || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS || | ||
332 | MptCallbacks[cb_idx] == NULL) { | ||
333 | printk(MYIOC_s_WARN_FMT "%s: Invalid cb_idx (%d)!\n", | ||
334 | __FUNCTION__, ioc->name, cb_idx); | ||
335 | freeme = 0; | ||
336 | goto out; | ||
337 | } | ||
338 | |||
339 | freeme = MptCallbacks[cb_idx](ioc, mf, mr); | ||
340 | |||
341 | out: | ||
342 | /* Flush (non-TURBO) reply with a WRITE! */ | ||
343 | CHIPREG_WRITE32(&ioc->chip->ReplyFifo, pa); | ||
344 | |||
345 | if (freeme) | ||
346 | mpt_free_msg_frame(ioc, mf); | ||
347 | mb(); | ||
348 | } | ||
349 | |||
209 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | 350 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ |
210 | /* | 351 | /* |
211 | * mpt_interrupt - MPT adapter (IOC) specific interrupt handler. | 352 | * mpt_interrupt - MPT adapter (IOC) specific interrupt handler. |
@@ -227,164 +368,21 @@ pci_enable_io_access(struct pci_dev *pdev) | |||
227 | static irqreturn_t | 368 | static irqreturn_t |
228 | mpt_interrupt(int irq, void *bus_id, struct pt_regs *r) | 369 | mpt_interrupt(int irq, void *bus_id, struct pt_regs *r) |
229 | { | 370 | { |
230 | MPT_ADAPTER *ioc; | 371 | MPT_ADAPTER *ioc = bus_id; |
231 | MPT_FRAME_HDR *mf; | 372 | u32 pa; |
232 | MPT_FRAME_HDR *mr; | ||
233 | u32 pa; | ||
234 | int req_idx; | ||
235 | int cb_idx; | ||
236 | int type; | ||
237 | int freeme; | ||
238 | |||
239 | ioc = (MPT_ADAPTER *)bus_id; | ||
240 | 373 | ||
241 | /* | 374 | /* |
242 | * Drain the reply FIFO! | 375 | * Drain the reply FIFO! |
243 | * | ||
244 | * NOTES: I've seen up to 10 replies processed in this loop, so far... | ||
245 | * Update: I've seen up to 9182 replies processed in this loop! ?? | ||
246 | * Update: Limit ourselves to processing max of N replies | ||
247 | * (bottom of loop). | ||
248 | */ | 376 | */ |
249 | while (1) { | 377 | while (1) { |
250 | 378 | pa = CHIPREG_READ32_dmasync(&ioc->chip->ReplyFifo); | |
251 | if ((pa = CHIPREG_READ32_dmasync(&ioc->chip->ReplyFifo)) == 0xFFFFFFFF) | 379 | if (pa == 0xFFFFFFFF) |
252 | return IRQ_HANDLED; | 380 | return IRQ_HANDLED; |
253 | 381 | else if (pa & MPI_ADDRESS_REPLY_A_BIT) | |
254 | cb_idx = 0; | 382 | mpt_reply(ioc, pa); |
255 | freeme = 0; | 383 | else |
256 | 384 | mpt_turbo_reply(ioc, pa); | |
257 | /* | 385 | } |
258 | * Check for non-TURBO reply! | ||
259 | */ | ||
260 | if (pa & MPI_ADDRESS_REPLY_A_BIT) { | ||
261 | u32 reply_dma_low; | ||
262 | u16 ioc_stat; | ||
263 | |||
264 | /* non-TURBO reply! Hmmm, something may be up... | ||
265 | * Newest turbo reply mechanism; get address | ||
266 | * via left shift 1 (get rid of MPI_ADDRESS_REPLY_A_BIT)! | ||
267 | */ | ||
268 | |||
269 | /* Map DMA address of reply header to cpu address. | ||
270 | * pa is 32 bits - but the dma address may be 32 or 64 bits | ||
271 | * get offset based only only the low addresses | ||
272 | */ | ||
273 | reply_dma_low = (pa = (pa << 1)); | ||
274 | mr = (MPT_FRAME_HDR *)((u8 *)ioc->reply_frames + | ||
275 | (reply_dma_low - ioc->reply_frames_low_dma)); | ||
276 | |||
277 | req_idx = le16_to_cpu(mr->u.frame.hwhdr.msgctxu.fld.req_idx); | ||
278 | cb_idx = mr->u.frame.hwhdr.msgctxu.fld.cb_idx; | ||
279 | mf = MPT_INDEX_2_MFPTR(ioc, req_idx); | ||
280 | |||
281 | dmfprintk((MYIOC_s_INFO_FMT "Got non-TURBO reply=%p req_idx=%x cb_idx=%x Function=%x\n", | ||
282 | ioc->name, mr, req_idx, cb_idx, mr->u.hdr.Function)); | ||
283 | DBG_DUMP_REPLY_FRAME(mr) | ||
284 | |||
285 | /* Check/log IOC log info | ||
286 | */ | ||
287 | ioc_stat = le16_to_cpu(mr->u.reply.IOCStatus); | ||
288 | if (ioc_stat & MPI_IOCSTATUS_FLAG_LOG_INFO_AVAILABLE) { | ||
289 | u32 log_info = le32_to_cpu(mr->u.reply.IOCLogInfo); | ||
290 | if (ioc->bus_type == FC) | ||
291 | mpt_fc_log_info(ioc, log_info); | ||
292 | else if (ioc->bus_type == SCSI) | ||
293 | mpt_sp_log_info(ioc, log_info); | ||
294 | } | ||
295 | if (ioc_stat & MPI_IOCSTATUS_MASK) { | ||
296 | if (ioc->bus_type == SCSI) | ||
297 | mpt_sp_ioc_info(ioc, (u32)ioc_stat, mf); | ||
298 | } | ||
299 | } else { | ||
300 | /* | ||
301 | * Process turbo (context) reply... | ||
302 | */ | ||
303 | dmfprintk((MYIOC_s_INFO_FMT "Got TURBO reply req_idx=%08x\n", ioc->name, pa)); | ||
304 | type = (pa >> MPI_CONTEXT_REPLY_TYPE_SHIFT); | ||
305 | if (type == MPI_CONTEXT_REPLY_TYPE_SCSI_TARGET) { | ||
306 | cb_idx = mpt_stm_index; | ||
307 | mf = NULL; | ||
308 | mr = (MPT_FRAME_HDR *) CAST_U32_TO_PTR(pa); | ||
309 | } else if (type == MPI_CONTEXT_REPLY_TYPE_LAN) { | ||
310 | cb_idx = mpt_lan_index; | ||
311 | /* Blind set of mf to NULL here was fatal | ||
312 | * after lan_reply says "freeme" | ||
313 | * Fix sort of combined with an optimization here; | ||
314 | * added explicit check for case where lan_reply | ||
315 | * was just returning 1 and doing nothing else. | ||
316 | * For this case skip the callback, but set up | ||
317 | * proper mf value first here:-) | ||
318 | */ | ||
319 | if ((pa & 0x58000000) == 0x58000000) { | ||
320 | req_idx = pa & 0x0000FFFF; | ||
321 | mf = MPT_INDEX_2_MFPTR(ioc, req_idx); | ||
322 | freeme = 1; | ||
323 | /* | ||
324 | * IMPORTANT! Invalidate the callback! | ||
325 | */ | ||
326 | cb_idx = 0; | ||
327 | } else { | ||
328 | mf = NULL; | ||
329 | } | ||
330 | mr = (MPT_FRAME_HDR *) CAST_U32_TO_PTR(pa); | ||
331 | } else { | ||
332 | req_idx = pa & 0x0000FFFF; | ||
333 | cb_idx = (pa & 0x00FF0000) >> 16; | ||
334 | mf = MPT_INDEX_2_MFPTR(ioc, req_idx); | ||
335 | mr = NULL; | ||
336 | } | ||
337 | pa = 0; /* No reply flush! */ | ||
338 | } | ||
339 | |||
340 | #ifdef MPT_DEBUG_IRQ | ||
341 | if (ioc->bus_type == SCSI) { | ||
342 | /* Verify mf, mr are reasonable. | ||
343 | */ | ||
344 | if ((mf) && ((mf >= MPT_INDEX_2_MFPTR(ioc, ioc->req_depth)) | ||
345 | || (mf < ioc->req_frames)) ) { | ||
346 | printk(MYIOC_s_WARN_FMT | ||
347 | "mpt_interrupt: Invalid mf (%p)!\n", ioc->name, (void *)mf); | ||
348 | cb_idx = 0; | ||
349 | pa = 0; | ||
350 | freeme = 0; | ||
351 | } | ||
352 | if ((pa) && (mr) && ((mr >= MPT_INDEX_2_RFPTR(ioc, ioc->req_depth)) | ||
353 | || (mr < ioc->reply_frames)) ) { | ||
354 | printk(MYIOC_s_WARN_FMT | ||
355 | "mpt_interrupt: Invalid rf (%p)!\n", ioc->name, (void *)mr); | ||
356 | cb_idx = 0; | ||
357 | pa = 0; | ||
358 | freeme = 0; | ||
359 | } | ||
360 | if (cb_idx > (MPT_MAX_PROTOCOL_DRIVERS-1)) { | ||
361 | printk(MYIOC_s_WARN_FMT | ||
362 | "mpt_interrupt: Invalid cb_idx (%d)!\n", ioc->name, cb_idx); | ||
363 | cb_idx = 0; | ||
364 | pa = 0; | ||
365 | freeme = 0; | ||
366 | } | ||
367 | } | ||
368 | #endif | ||
369 | |||
370 | /* Check for (valid) IO callback! */ | ||
371 | if (cb_idx) { | ||
372 | /* Do the callback! */ | ||
373 | freeme = (*(MptCallbacks[cb_idx]))(ioc, mf, mr); | ||
374 | } | ||
375 | |||
376 | if (pa) { | ||
377 | /* Flush (non-TURBO) reply with a WRITE! */ | ||
378 | CHIPREG_WRITE32(&ioc->chip->ReplyFifo, pa); | ||
379 | } | ||
380 | |||
381 | if (freeme) { | ||
382 | /* Put Request back on FreeQ! */ | ||
383 | mpt_free_msg_frame(ioc, mf); | ||
384 | } | ||
385 | |||
386 | mb(); | ||
387 | } /* drain reply FIFO */ | ||
388 | 386 | ||
389 | return IRQ_HANDLED; | 387 | return IRQ_HANDLED; |
390 | } | 388 | } |
@@ -509,6 +507,14 @@ mpt_base_reply(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *reply) | |||
509 | pCfg->wait_done = 1; | 507 | pCfg->wait_done = 1; |
510 | wake_up(&mpt_waitq); | 508 | wake_up(&mpt_waitq); |
511 | } | 509 | } |
510 | } else if (func == MPI_FUNCTION_SAS_IO_UNIT_CONTROL) { | ||
511 | /* we should be always getting a reply frame */ | ||
512 | memcpy(ioc->persist_reply_frame, reply, | ||
513 | min(MPT_DEFAULT_FRAME_SIZE, | ||
514 | 4*reply->u.reply.MsgLength)); | ||
515 | del_timer(&ioc->persist_timer); | ||
516 | ioc->persist_wait_done = 1; | ||
517 | wake_up(&mpt_waitq); | ||
512 | } else { | 518 | } else { |
513 | printk(MYIOC_s_ERR_FMT "Unexpected msg function (=%02Xh) reply received!\n", | 519 | printk(MYIOC_s_ERR_FMT "Unexpected msg function (=%02Xh) reply received!\n", |
514 | ioc->name, func); | 520 | ioc->name, func); |
@@ -750,6 +756,7 @@ mpt_get_msg_frame(int handle, MPT_ADAPTER *ioc) | |||
750 | mf = list_entry(ioc->FreeQ.next, MPT_FRAME_HDR, | 756 | mf = list_entry(ioc->FreeQ.next, MPT_FRAME_HDR, |
751 | u.frame.linkage.list); | 757 | u.frame.linkage.list); |
752 | list_del(&mf->u.frame.linkage.list); | 758 | list_del(&mf->u.frame.linkage.list); |
759 | mf->u.frame.linkage.arg1 = 0; | ||
753 | mf->u.frame.hwhdr.msgctxu.fld.cb_idx = handle; /* byte */ | 760 | mf->u.frame.hwhdr.msgctxu.fld.cb_idx = handle; /* byte */ |
754 | req_offset = (u8 *)mf - (u8 *)ioc->req_frames; | 761 | req_offset = (u8 *)mf - (u8 *)ioc->req_frames; |
755 | /* u16! */ | 762 | /* u16! */ |
@@ -845,6 +852,7 @@ mpt_free_msg_frame(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf) | |||
845 | 852 | ||
846 | /* Put Request back on FreeQ! */ | 853 | /* Put Request back on FreeQ! */ |
847 | spin_lock_irqsave(&ioc->FreeQlock, flags); | 854 | spin_lock_irqsave(&ioc->FreeQlock, flags); |
855 | mf->u.frame.linkage.arg1 = 0xdeadbeaf; /* signature to know if this mf is freed */ | ||
848 | list_add_tail(&mf->u.frame.linkage.list, &ioc->FreeQ); | 856 | list_add_tail(&mf->u.frame.linkage.list, &ioc->FreeQ); |
849 | #ifdef MFCNT | 857 | #ifdef MFCNT |
850 | ioc->mfcnt--; | 858 | ioc->mfcnt--; |
@@ -971,12 +979,123 @@ mpt_send_handshake_request(int handle, MPT_ADAPTER *ioc, int reqBytes, u32 *req, | |||
971 | 979 | ||
972 | /* Make sure there are no doorbells */ | 980 | /* Make sure there are no doorbells */ |
973 | CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); | 981 | CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); |
974 | 982 | ||
975 | return r; | 983 | return r; |
976 | } | 984 | } |
977 | 985 | ||
978 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | 986 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ |
979 | /** | 987 | /** |
988 | * mpt_host_page_access_control - provides mechanism for the host | ||
989 | * driver to control the IOC's Host Page Buffer access. | ||
990 | * @ioc: Pointer to MPT adapter structure | ||
991 | * @access_control_value: define bits below | ||
992 | * | ||
993 | * Access Control Value - bits[15:12] | ||
994 | * 0h Reserved | ||
995 | * 1h Enable Access { MPI_DB_HPBAC_ENABLE_ACCESS } | ||
996 | * 2h Disable Access { MPI_DB_HPBAC_DISABLE_ACCESS } | ||
997 | * 3h Free Buffer { MPI_DB_HPBAC_FREE_BUFFER } | ||
998 | * | ||
999 | * Returns 0 for success, non-zero for failure. | ||
1000 | */ | ||
1001 | |||
1002 | static int | ||
1003 | mpt_host_page_access_control(MPT_ADAPTER *ioc, u8 access_control_value, int sleepFlag) | ||
1004 | { | ||
1005 | int r = 0; | ||
1006 | |||
1007 | /* return if in use */ | ||
1008 | if (CHIPREG_READ32(&ioc->chip->Doorbell) | ||
1009 | & MPI_DOORBELL_ACTIVE) | ||
1010 | return -1; | ||
1011 | |||
1012 | CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); | ||
1013 | |||
1014 | CHIPREG_WRITE32(&ioc->chip->Doorbell, | ||
1015 | ((MPI_FUNCTION_HOST_PAGEBUF_ACCESS_CONTROL | ||
1016 | <<MPI_DOORBELL_FUNCTION_SHIFT) | | ||
1017 | (access_control_value<<12))); | ||
1018 | |||
1019 | /* Wait for IOC to clear Doorbell Status bit */ | ||
1020 | if ((r = WaitForDoorbellAck(ioc, 5, sleepFlag)) < 0) { | ||
1021 | return -2; | ||
1022 | }else | ||
1023 | return 0; | ||
1024 | } | ||
1025 | |||
1026 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | ||
1027 | /** | ||
1028 | * mpt_host_page_alloc - allocate system memory for the fw | ||
1029 | * If we already allocated memory in past, then resend the same pointer. | ||
1030 | * ioc@: Pointer to pointer to IOC adapter | ||
1031 | * ioc_init@: Pointer to ioc init config page | ||
1032 | * | ||
1033 | * Returns 0 for success, non-zero for failure. | ||
1034 | */ | ||
1035 | static int | ||
1036 | mpt_host_page_alloc(MPT_ADAPTER *ioc, pIOCInit_t ioc_init) | ||
1037 | { | ||
1038 | char *psge; | ||
1039 | int flags_length; | ||
1040 | u32 host_page_buffer_sz=0; | ||
1041 | |||
1042 | if(!ioc->HostPageBuffer) { | ||
1043 | |||
1044 | host_page_buffer_sz = | ||
1045 | le32_to_cpu(ioc->facts.HostPageBufferSGE.FlagsLength) & 0xFFFFFF; | ||
1046 | |||
1047 | if(!host_page_buffer_sz) | ||
1048 | return 0; /* fw doesn't need any host buffers */ | ||
1049 | |||
1050 | /* spin till we get enough memory */ | ||
1051 | while(host_page_buffer_sz > 0) { | ||
1052 | |||
1053 | if((ioc->HostPageBuffer = pci_alloc_consistent( | ||
1054 | ioc->pcidev, | ||
1055 | host_page_buffer_sz, | ||
1056 | &ioc->HostPageBuffer_dma)) != NULL) { | ||
1057 | |||
1058 | dinitprintk((MYIOC_s_INFO_FMT | ||
1059 | "host_page_buffer @ %p, dma @ %x, sz=%d bytes\n", | ||
1060 | ioc->name, | ||
1061 | ioc->HostPageBuffer, | ||
1062 | ioc->HostPageBuffer_dma, | ||
1063 | host_page_buffer_sz)); | ||
1064 | ioc->alloc_total += host_page_buffer_sz; | ||
1065 | ioc->HostPageBuffer_sz = host_page_buffer_sz; | ||
1066 | break; | ||
1067 | } | ||
1068 | |||
1069 | host_page_buffer_sz -= (4*1024); | ||
1070 | } | ||
1071 | } | ||
1072 | |||
1073 | if(!ioc->HostPageBuffer) { | ||
1074 | printk(MYIOC_s_ERR_FMT | ||
1075 | "Failed to alloc memory for host_page_buffer!\n", | ||
1076 | ioc->name); | ||
1077 | return -999; | ||
1078 | } | ||
1079 | |||
1080 | psge = (char *)&ioc_init->HostPageBufferSGE; | ||
1081 | flags_length = MPI_SGE_FLAGS_SIMPLE_ELEMENT | | ||
1082 | MPI_SGE_FLAGS_SYSTEM_ADDRESS | | ||
1083 | MPI_SGE_FLAGS_32_BIT_ADDRESSING | | ||
1084 | MPI_SGE_FLAGS_HOST_TO_IOC | | ||
1085 | MPI_SGE_FLAGS_END_OF_BUFFER; | ||
1086 | if (sizeof(dma_addr_t) == sizeof(u64)) { | ||
1087 | flags_length |= MPI_SGE_FLAGS_64_BIT_ADDRESSING; | ||
1088 | } | ||
1089 | flags_length = flags_length << MPI_SGE_FLAGS_SHIFT; | ||
1090 | flags_length |= ioc->HostPageBuffer_sz; | ||
1091 | mpt_add_sge(psge, flags_length, ioc->HostPageBuffer_dma); | ||
1092 | ioc->facts.HostPageBufferSGE = ioc_init->HostPageBufferSGE; | ||
1093 | |||
1094 | return 0; | ||
1095 | } | ||
1096 | |||
1097 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | ||
1098 | /** | ||
980 | * mpt_verify_adapter - Given a unique IOC identifier, set pointer to | 1099 | * mpt_verify_adapter - Given a unique IOC identifier, set pointer to |
981 | * the associated MPT adapter structure. | 1100 | * the associated MPT adapter structure. |
982 | * @iocid: IOC unique identifier (integer) | 1101 | * @iocid: IOC unique identifier (integer) |
@@ -1084,7 +1203,7 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id) | |||
1084 | 1203 | ||
1085 | /* Initilize SCSI Config Data structure | 1204 | /* Initilize SCSI Config Data structure |
1086 | */ | 1205 | */ |
1087 | memset(&ioc->spi_data, 0, sizeof(ScsiCfgData)); | 1206 | memset(&ioc->spi_data, 0, sizeof(SpiCfgData)); |
1088 | 1207 | ||
1089 | /* Initialize the running configQ head. | 1208 | /* Initialize the running configQ head. |
1090 | */ | 1209 | */ |
@@ -1213,6 +1332,33 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id) | |||
1213 | ioc->prod_name = "LSI53C1035"; | 1332 | ioc->prod_name = "LSI53C1035"; |
1214 | ioc->bus_type = SCSI; | 1333 | ioc->bus_type = SCSI; |
1215 | } | 1334 | } |
1335 | else if (pdev->device == MPI_MANUFACTPAGE_DEVID_SAS1064) { | ||
1336 | ioc->prod_name = "LSISAS1064"; | ||
1337 | ioc->bus_type = SAS; | ||
1338 | ioc->errata_flag_1064 = 1; | ||
1339 | } | ||
1340 | else if (pdev->device == MPI_MANUFACTPAGE_DEVID_SAS1066) { | ||
1341 | ioc->prod_name = "LSISAS1066"; | ||
1342 | ioc->bus_type = SAS; | ||
1343 | ioc->errata_flag_1064 = 1; | ||
1344 | } | ||
1345 | else if (pdev->device == MPI_MANUFACTPAGE_DEVID_SAS1068) { | ||
1346 | ioc->prod_name = "LSISAS1068"; | ||
1347 | ioc->bus_type = SAS; | ||
1348 | ioc->errata_flag_1064 = 1; | ||
1349 | } | ||
1350 | else if (pdev->device == MPI_MANUFACTPAGE_DEVID_SAS1064E) { | ||
1351 | ioc->prod_name = "LSISAS1064E"; | ||
1352 | ioc->bus_type = SAS; | ||
1353 | } | ||
1354 | else if (pdev->device == MPI_MANUFACTPAGE_DEVID_SAS1066E) { | ||
1355 | ioc->prod_name = "LSISAS1066E"; | ||
1356 | ioc->bus_type = SAS; | ||
1357 | } | ||
1358 | else if (pdev->device == MPI_MANUFACTPAGE_DEVID_SAS1068E) { | ||
1359 | ioc->prod_name = "LSISAS1068E"; | ||
1360 | ioc->bus_type = SAS; | ||
1361 | } | ||
1216 | 1362 | ||
1217 | if (ioc->errata_flag_1064) | 1363 | if (ioc->errata_flag_1064) |
1218 | pci_disable_io_access(pdev); | 1364 | pci_disable_io_access(pdev); |
@@ -1604,8 +1750,23 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag) | |||
1604 | */ | 1750 | */ |
1605 | if (ret == 0) { | 1751 | if (ret == 0) { |
1606 | rc = mpt_do_upload(ioc, sleepFlag); | 1752 | rc = mpt_do_upload(ioc, sleepFlag); |
1607 | if (rc != 0) | 1753 | if (rc == 0) { |
1754 | if (ioc->alt_ioc && ioc->alt_ioc->cached_fw) { | ||
1755 | /* | ||
1756 | * Maintain only one pointer to FW memory | ||
1757 | * so there will not be two attempt to | ||
1758 | * downloadboot onboard dual function | ||
1759 | * chips (mpt_adapter_disable, | ||
1760 | * mpt_diag_reset) | ||
1761 | */ | ||
1762 | ioc->cached_fw = NULL; | ||
1763 | ddlprintk((MYIOC_s_INFO_FMT ": mpt_upload: alt_%s has cached_fw=%p \n", | ||
1764 | ioc->name, ioc->alt_ioc->name, ioc->alt_ioc->cached_fw)); | ||
1765 | } | ||
1766 | } else { | ||
1608 | printk(KERN_WARNING MYNAM ": firmware upload failure!\n"); | 1767 | printk(KERN_WARNING MYNAM ": firmware upload failure!\n"); |
1768 | ret = -5; | ||
1769 | } | ||
1609 | } | 1770 | } |
1610 | } | 1771 | } |
1611 | } | 1772 | } |
@@ -1640,7 +1801,22 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag) | |||
1640 | * and we try GetLanConfigPages again... | 1801 | * and we try GetLanConfigPages again... |
1641 | */ | 1802 | */ |
1642 | if ((ret == 0) && (reason == MPT_HOSTEVENT_IOC_BRINGUP)) { | 1803 | if ((ret == 0) && (reason == MPT_HOSTEVENT_IOC_BRINGUP)) { |
1643 | if (ioc->bus_type == FC) { | 1804 | if (ioc->bus_type == SAS) { |
1805 | |||
1806 | /* clear persistency table */ | ||
1807 | if(ioc->facts.IOCExceptions & | ||
1808 | MPI_IOCFACTS_EXCEPT_PERSISTENT_TABLE_FULL) { | ||
1809 | ret = mptbase_sas_persist_operation(ioc, | ||
1810 | MPI_SAS_OP_CLEAR_NOT_PRESENT); | ||
1811 | if(ret != 0) | ||
1812 | return -1; | ||
1813 | } | ||
1814 | |||
1815 | /* Find IM volumes | ||
1816 | */ | ||
1817 | mpt_findImVolumes(ioc); | ||
1818 | |||
1819 | } else if (ioc->bus_type == FC) { | ||
1644 | /* | 1820 | /* |
1645 | * Pre-fetch FC port WWN and stuff... | 1821 | * Pre-fetch FC port WWN and stuff... |
1646 | * (FCPortPage0_t stuff) | 1822 | * (FCPortPage0_t stuff) |
@@ -1783,7 +1959,7 @@ mpt_adapter_disable(MPT_ADAPTER *ioc) | |||
1783 | 1959 | ||
1784 | if (ioc->cached_fw != NULL) { | 1960 | if (ioc->cached_fw != NULL) { |
1785 | ddlprintk((KERN_INFO MYNAM ": mpt_adapter_disable: Pushing FW onto adapter\n")); | 1961 | ddlprintk((KERN_INFO MYNAM ": mpt_adapter_disable: Pushing FW onto adapter\n")); |
1786 | if ((ret = mpt_downloadboot(ioc, NO_SLEEP)) < 0) { | 1962 | if ((ret = mpt_downloadboot(ioc, (MpiFwHeader_t *)ioc->cached_fw, NO_SLEEP)) < 0) { |
1787 | printk(KERN_WARNING MYNAM | 1963 | printk(KERN_WARNING MYNAM |
1788 | ": firmware downloadboot failure (%d)!\n", ret); | 1964 | ": firmware downloadboot failure (%d)!\n", ret); |
1789 | } | 1965 | } |
@@ -1831,9 +2007,9 @@ mpt_adapter_disable(MPT_ADAPTER *ioc) | |||
1831 | } | 2007 | } |
1832 | 2008 | ||
1833 | kfree(ioc->spi_data.nvram); | 2009 | kfree(ioc->spi_data.nvram); |
1834 | kfree(ioc->spi_data.pIocPg3); | 2010 | kfree(ioc->raid_data.pIocPg3); |
1835 | ioc->spi_data.nvram = NULL; | 2011 | ioc->spi_data.nvram = NULL; |
1836 | ioc->spi_data.pIocPg3 = NULL; | 2012 | ioc->raid_data.pIocPg3 = NULL; |
1837 | 2013 | ||
1838 | if (ioc->spi_data.pIocPg4 != NULL) { | 2014 | if (ioc->spi_data.pIocPg4 != NULL) { |
1839 | sz = ioc->spi_data.IocPg4Sz; | 2015 | sz = ioc->spi_data.IocPg4Sz; |
@@ -1852,6 +2028,23 @@ mpt_adapter_disable(MPT_ADAPTER *ioc) | |||
1852 | 2028 | ||
1853 | kfree(ioc->ChainToChain); | 2029 | kfree(ioc->ChainToChain); |
1854 | ioc->ChainToChain = NULL; | 2030 | ioc->ChainToChain = NULL; |
2031 | |||
2032 | if (ioc->HostPageBuffer != NULL) { | ||
2033 | if((ret = mpt_host_page_access_control(ioc, | ||
2034 | MPI_DB_HPBAC_FREE_BUFFER, NO_SLEEP)) != 0) { | ||
2035 | printk(KERN_ERR MYNAM | ||
2036 | ": %s: host page buffers free failed (%d)!\n", | ||
2037 | __FUNCTION__, ret); | ||
2038 | } | ||
2039 | dexitprintk((KERN_INFO MYNAM ": %s HostPageBuffer free @ %p, sz=%d bytes\n", | ||
2040 | ioc->name, ioc->HostPageBuffer, ioc->HostPageBuffer_sz)); | ||
2041 | pci_free_consistent(ioc->pcidev, ioc->HostPageBuffer_sz, | ||
2042 | ioc->HostPageBuffer, | ||
2043 | ioc->HostPageBuffer_dma); | ||
2044 | ioc->HostPageBuffer = NULL; | ||
2045 | ioc->HostPageBuffer_sz = 0; | ||
2046 | ioc->alloc_total -= ioc->HostPageBuffer_sz; | ||
2047 | } | ||
1855 | } | 2048 | } |
1856 | 2049 | ||
1857 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | 2050 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ |
@@ -2034,7 +2227,7 @@ MakeIocReady(MPT_ADAPTER *ioc, int force, int sleepFlag) | |||
2034 | * Loop here waiting for IOC to come READY. | 2227 | * Loop here waiting for IOC to come READY. |
2035 | */ | 2228 | */ |
2036 | ii = 0; | 2229 | ii = 0; |
2037 | cntdn = ((sleepFlag == CAN_SLEEP) ? HZ : 1000) * 15; /* 15 seconds */ | 2230 | cntdn = ((sleepFlag == CAN_SLEEP) ? HZ : 1000) * 5; /* 5 seconds */ |
2038 | 2231 | ||
2039 | while ((ioc_state = mpt_GetIocState(ioc, 1)) != MPI_IOC_STATE_READY) { | 2232 | while ((ioc_state = mpt_GetIocState(ioc, 1)) != MPI_IOC_STATE_READY) { |
2040 | if (ioc_state == MPI_IOC_STATE_OPERATIONAL) { | 2233 | if (ioc_state == MPI_IOC_STATE_OPERATIONAL) { |
@@ -2212,6 +2405,7 @@ GetIocFacts(MPT_ADAPTER *ioc, int sleepFlag, int reason) | |||
2212 | le32_to_cpu(facts->CurrentSenseBufferHighAddr); | 2405 | le32_to_cpu(facts->CurrentSenseBufferHighAddr); |
2213 | facts->CurReplyFrameSize = | 2406 | facts->CurReplyFrameSize = |
2214 | le16_to_cpu(facts->CurReplyFrameSize); | 2407 | le16_to_cpu(facts->CurReplyFrameSize); |
2408 | facts->IOCCapabilities = le32_to_cpu(facts->IOCCapabilities); | ||
2215 | 2409 | ||
2216 | /* | 2410 | /* |
2217 | * Handle NEW (!) IOCFactsReply fields in MPI-1.01.xx | 2411 | * Handle NEW (!) IOCFactsReply fields in MPI-1.01.xx |
@@ -2383,13 +2577,25 @@ SendIocInit(MPT_ADAPTER *ioc, int sleepFlag) | |||
2383 | ddlprintk((MYIOC_s_INFO_FMT "upload_fw %d facts.Flags=%x\n", | 2577 | ddlprintk((MYIOC_s_INFO_FMT "upload_fw %d facts.Flags=%x\n", |
2384 | ioc->name, ioc->upload_fw, ioc->facts.Flags)); | 2578 | ioc->name, ioc->upload_fw, ioc->facts.Flags)); |
2385 | 2579 | ||
2386 | if (ioc->bus_type == FC) | 2580 | if(ioc->bus_type == SAS) |
2581 | ioc_init.MaxDevices = ioc->facts.MaxDevices; | ||
2582 | else if(ioc->bus_type == FC) | ||
2387 | ioc_init.MaxDevices = MPT_MAX_FC_DEVICES; | 2583 | ioc_init.MaxDevices = MPT_MAX_FC_DEVICES; |
2388 | else | 2584 | else |
2389 | ioc_init.MaxDevices = MPT_MAX_SCSI_DEVICES; | 2585 | ioc_init.MaxDevices = MPT_MAX_SCSI_DEVICES; |
2390 | |||
2391 | ioc_init.MaxBuses = MPT_MAX_BUS; | 2586 | ioc_init.MaxBuses = MPT_MAX_BUS; |
2392 | 2587 | dinitprintk((MYIOC_s_INFO_FMT "facts.MsgVersion=%x\n", | |
2588 | ioc->name, ioc->facts.MsgVersion)); | ||
2589 | if (ioc->facts.MsgVersion >= MPI_VERSION_01_05) { | ||
2590 | // set MsgVersion and HeaderVersion host driver was built with | ||
2591 | ioc_init.MsgVersion = cpu_to_le16(MPI_VERSION); | ||
2592 | ioc_init.HeaderVersion = cpu_to_le16(MPI_HEADER_VERSION); | ||
2593 | |||
2594 | if (ioc->facts.Flags & MPI_IOCFACTS_FLAGS_HOST_PAGE_BUFFER_PERSISTENT) { | ||
2595 | ioc_init.HostPageBufferSGE = ioc->facts.HostPageBufferSGE; | ||
2596 | } else if(mpt_host_page_alloc(ioc, &ioc_init)) | ||
2597 | return -99; | ||
2598 | } | ||
2393 | ioc_init.ReplyFrameSize = cpu_to_le16(ioc->reply_sz); /* in BYTES */ | 2599 | ioc_init.ReplyFrameSize = cpu_to_le16(ioc->reply_sz); /* in BYTES */ |
2394 | 2600 | ||
2395 | if (sizeof(dma_addr_t) == sizeof(u64)) { | 2601 | if (sizeof(dma_addr_t) == sizeof(u64)) { |
@@ -2403,17 +2609,21 @@ SendIocInit(MPT_ADAPTER *ioc, int sleepFlag) | |||
2403 | ioc_init.HostMfaHighAddr = cpu_to_le32(0); | 2609 | ioc_init.HostMfaHighAddr = cpu_to_le32(0); |
2404 | ioc_init.SenseBufferHighAddr = cpu_to_le32(0); | 2610 | ioc_init.SenseBufferHighAddr = cpu_to_le32(0); |
2405 | } | 2611 | } |
2406 | 2612 | ||
2407 | ioc->facts.CurrentHostMfaHighAddr = ioc_init.HostMfaHighAddr; | 2613 | ioc->facts.CurrentHostMfaHighAddr = ioc_init.HostMfaHighAddr; |
2408 | ioc->facts.CurrentSenseBufferHighAddr = ioc_init.SenseBufferHighAddr; | 2614 | ioc->facts.CurrentSenseBufferHighAddr = ioc_init.SenseBufferHighAddr; |
2615 | ioc->facts.MaxDevices = ioc_init.MaxDevices; | ||
2616 | ioc->facts.MaxBuses = ioc_init.MaxBuses; | ||
2409 | 2617 | ||
2410 | dhsprintk((MYIOC_s_INFO_FMT "Sending IOCInit (req @ %p)\n", | 2618 | dhsprintk((MYIOC_s_INFO_FMT "Sending IOCInit (req @ %p)\n", |
2411 | ioc->name, &ioc_init)); | 2619 | ioc->name, &ioc_init)); |
2412 | 2620 | ||
2413 | r = mpt_handshake_req_reply_wait(ioc, sizeof(IOCInit_t), (u32*)&ioc_init, | 2621 | r = mpt_handshake_req_reply_wait(ioc, sizeof(IOCInit_t), (u32*)&ioc_init, |
2414 | sizeof(MPIDefaultReply_t), (u16*)&init_reply, 10 /*seconds*/, sleepFlag); | 2622 | sizeof(MPIDefaultReply_t), (u16*)&init_reply, 10 /*seconds*/, sleepFlag); |
2415 | if (r != 0) | 2623 | if (r != 0) { |
2624 | printk(MYIOC_s_ERR_FMT "Sending IOCInit failed(%d)!\n",ioc->name, r); | ||
2416 | return r; | 2625 | return r; |
2626 | } | ||
2417 | 2627 | ||
2418 | /* No need to byte swap the multibyte fields in the reply | 2628 | /* No need to byte swap the multibyte fields in the reply |
2419 | * since we don't even look at it's contents. | 2629 | * since we don't even look at it's contents. |
@@ -2472,7 +2682,7 @@ SendPortEnable(MPT_ADAPTER *ioc, int portnum, int sleepFlag) | |||
2472 | { | 2682 | { |
2473 | PortEnable_t port_enable; | 2683 | PortEnable_t port_enable; |
2474 | MPIDefaultReply_t reply_buf; | 2684 | MPIDefaultReply_t reply_buf; |
2475 | int ii; | 2685 | int rc; |
2476 | int req_sz; | 2686 | int req_sz; |
2477 | int reply_sz; | 2687 | int reply_sz; |
2478 | 2688 | ||
@@ -2494,22 +2704,15 @@ SendPortEnable(MPT_ADAPTER *ioc, int portnum, int sleepFlag) | |||
2494 | 2704 | ||
2495 | /* RAID FW may take a long time to enable | 2705 | /* RAID FW may take a long time to enable |
2496 | */ | 2706 | */ |
2497 | if (ioc->bus_type == FC) { | 2707 | if ( (ioc->facts.ProductID & MPI_FW_HEADER_PID_PROD_MASK) |
2498 | ii = mpt_handshake_req_reply_wait(ioc, req_sz, (u32*)&port_enable, | 2708 | > MPI_FW_HEADER_PID_PROD_TARGET_SCSI ) { |
2499 | reply_sz, (u16*)&reply_buf, 65 /*seconds*/, sleepFlag); | 2709 | rc = mpt_handshake_req_reply_wait(ioc, req_sz, (u32*)&port_enable, |
2500 | } else { | ||
2501 | ii = mpt_handshake_req_reply_wait(ioc, req_sz, (u32*)&port_enable, | ||
2502 | reply_sz, (u16*)&reply_buf, 300 /*seconds*/, sleepFlag); | 2710 | reply_sz, (u16*)&reply_buf, 300 /*seconds*/, sleepFlag); |
2711 | } else { | ||
2712 | rc = mpt_handshake_req_reply_wait(ioc, req_sz, (u32*)&port_enable, | ||
2713 | reply_sz, (u16*)&reply_buf, 30 /*seconds*/, sleepFlag); | ||
2503 | } | 2714 | } |
2504 | 2715 | return rc; | |
2505 | if (ii != 0) | ||
2506 | return ii; | ||
2507 | |||
2508 | /* We do not even look at the reply, so we need not | ||
2509 | * swap the multi-byte fields. | ||
2510 | */ | ||
2511 | |||
2512 | return 0; | ||
2513 | } | 2716 | } |
2514 | 2717 | ||
2515 | /* | 2718 | /* |
@@ -2666,9 +2869,8 @@ mpt_do_upload(MPT_ADAPTER *ioc, int sleepFlag) | |||
2666 | * <0 for fw upload failure. | 2869 | * <0 for fw upload failure. |
2667 | */ | 2870 | */ |
2668 | static int | 2871 | static int |
2669 | mpt_downloadboot(MPT_ADAPTER *ioc, int sleepFlag) | 2872 | mpt_downloadboot(MPT_ADAPTER *ioc, MpiFwHeader_t *pFwHeader, int sleepFlag) |
2670 | { | 2873 | { |
2671 | MpiFwHeader_t *pFwHeader; | ||
2672 | MpiExtImageHeader_t *pExtImage; | 2874 | MpiExtImageHeader_t *pExtImage; |
2673 | u32 fwSize; | 2875 | u32 fwSize; |
2674 | u32 diag0val; | 2876 | u32 diag0val; |
@@ -2679,18 +2881,8 @@ mpt_downloadboot(MPT_ADAPTER *ioc, int sleepFlag) | |||
2679 | u32 load_addr; | 2881 | u32 load_addr; |
2680 | u32 ioc_state=0; | 2882 | u32 ioc_state=0; |
2681 | 2883 | ||
2682 | ddlprintk((MYIOC_s_INFO_FMT "downloadboot: fw size 0x%x, ioc FW Ptr %p\n", | 2884 | ddlprintk((MYIOC_s_INFO_FMT "downloadboot: fw size 0x%x (%d), FW Ptr %p\n", |
2683 | ioc->name, ioc->facts.FWImageSize, ioc->cached_fw)); | 2885 | ioc->name, pFwHeader->ImageSize, pFwHeader->ImageSize, pFwHeader)); |
2684 | |||
2685 | if ( ioc->facts.FWImageSize == 0 ) | ||
2686 | return -1; | ||
2687 | |||
2688 | if (ioc->cached_fw == NULL) | ||
2689 | return -2; | ||
2690 | |||
2691 | /* prevent a second downloadboot and memory free with alt_ioc */ | ||
2692 | if (ioc->alt_ioc && ioc->alt_ioc->cached_fw) | ||
2693 | ioc->alt_ioc->cached_fw = NULL; | ||
2694 | 2886 | ||
2695 | CHIPREG_WRITE32(&ioc->chip->WriteSequence, 0xFF); | 2887 | CHIPREG_WRITE32(&ioc->chip->WriteSequence, 0xFF); |
2696 | CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_1ST_KEY_VALUE); | 2888 | CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_1ST_KEY_VALUE); |
@@ -2718,16 +2910,17 @@ mpt_downloadboot(MPT_ADAPTER *ioc, int sleepFlag) | |||
2718 | ioc->name, count)); | 2910 | ioc->name, count)); |
2719 | break; | 2911 | break; |
2720 | } | 2912 | } |
2721 | /* wait 1 sec */ | 2913 | /* wait .1 sec */ |
2722 | if (sleepFlag == CAN_SLEEP) { | 2914 | if (sleepFlag == CAN_SLEEP) { |
2723 | msleep_interruptible (1000); | 2915 | msleep_interruptible (100); |
2724 | } else { | 2916 | } else { |
2725 | mdelay (1000); | 2917 | mdelay (100); |
2726 | } | 2918 | } |
2727 | } | 2919 | } |
2728 | 2920 | ||
2729 | if ( count == 30 ) { | 2921 | if ( count == 30 ) { |
2730 | ddlprintk((MYIOC_s_INFO_FMT "downloadboot failed! Unable to RESET_ADAPTER diag0val=%x\n", | 2922 | ddlprintk((MYIOC_s_INFO_FMT "downloadboot failed! " |
2923 | "Unable to get MPI_DIAG_DRWE mode, diag0val=%x\n", | ||
2731 | ioc->name, diag0val)); | 2924 | ioc->name, diag0val)); |
2732 | return -3; | 2925 | return -3; |
2733 | } | 2926 | } |
@@ -2742,7 +2935,6 @@ mpt_downloadboot(MPT_ADAPTER *ioc, int sleepFlag) | |||
2742 | /* Set the DiagRwEn and Disable ARM bits */ | 2935 | /* Set the DiagRwEn and Disable ARM bits */ |
2743 | CHIPREG_WRITE32(&ioc->chip->Diagnostic, (MPI_DIAG_RW_ENABLE | MPI_DIAG_DISABLE_ARM)); | 2936 | CHIPREG_WRITE32(&ioc->chip->Diagnostic, (MPI_DIAG_RW_ENABLE | MPI_DIAG_DISABLE_ARM)); |
2744 | 2937 | ||
2745 | pFwHeader = (MpiFwHeader_t *) ioc->cached_fw; | ||
2746 | fwSize = (pFwHeader->ImageSize + 3)/4; | 2938 | fwSize = (pFwHeader->ImageSize + 3)/4; |
2747 | ptrFw = (u32 *) pFwHeader; | 2939 | ptrFw = (u32 *) pFwHeader; |
2748 | 2940 | ||
@@ -2792,19 +2984,38 @@ mpt_downloadboot(MPT_ADAPTER *ioc, int sleepFlag) | |||
2792 | /* Clear the internal flash bad bit - autoincrementing register, | 2984 | /* Clear the internal flash bad bit - autoincrementing register, |
2793 | * so must do two writes. | 2985 | * so must do two writes. |
2794 | */ | 2986 | */ |
2795 | CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwAddress, 0x3F000000); | 2987 | if (ioc->bus_type == SCSI) { |
2796 | diagRwData = CHIPREG_PIO_READ32(&ioc->pio_chip->DiagRwData); | 2988 | /* |
2797 | diagRwData |= 0x4000000; | 2989 | * 1030 and 1035 H/W errata, workaround to access |
2798 | CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwAddress, 0x3F000000); | 2990 | * the ClearFlashBadSignatureBit |
2799 | CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwData, diagRwData); | 2991 | */ |
2992 | CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwAddress, 0x3F000000); | ||
2993 | diagRwData = CHIPREG_PIO_READ32(&ioc->pio_chip->DiagRwData); | ||
2994 | diagRwData |= 0x40000000; | ||
2995 | CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwAddress, 0x3F000000); | ||
2996 | CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwData, diagRwData); | ||
2997 | |||
2998 | } else /* if((ioc->bus_type == SAS) || (ioc->bus_type == FC)) */ { | ||
2999 | diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic); | ||
3000 | CHIPREG_WRITE32(&ioc->chip->Diagnostic, diag0val | | ||
3001 | MPI_DIAG_CLEAR_FLASH_BAD_SIG); | ||
3002 | |||
3003 | /* wait 1 msec */ | ||
3004 | if (sleepFlag == CAN_SLEEP) { | ||
3005 | msleep_interruptible (1); | ||
3006 | } else { | ||
3007 | mdelay (1); | ||
3008 | } | ||
3009 | } | ||
2800 | 3010 | ||
2801 | if (ioc->errata_flag_1064) | 3011 | if (ioc->errata_flag_1064) |
2802 | pci_disable_io_access(ioc->pcidev); | 3012 | pci_disable_io_access(ioc->pcidev); |
2803 | 3013 | ||
2804 | diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic); | 3014 | diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic); |
2805 | ddlprintk((MYIOC_s_INFO_FMT "downloadboot diag0val=%x, turning off PREVENT_IOC_BOOT, DISABLE_ARM\n", | 3015 | ddlprintk((MYIOC_s_INFO_FMT "downloadboot diag0val=%x, " |
3016 | "turning off PREVENT_IOC_BOOT, DISABLE_ARM, RW_ENABLE\n", | ||
2806 | ioc->name, diag0val)); | 3017 | ioc->name, diag0val)); |
2807 | diag0val &= ~(MPI_DIAG_PREVENT_IOC_BOOT | MPI_DIAG_DISABLE_ARM); | 3018 | diag0val &= ~(MPI_DIAG_PREVENT_IOC_BOOT | MPI_DIAG_DISABLE_ARM | MPI_DIAG_RW_ENABLE); |
2808 | ddlprintk((MYIOC_s_INFO_FMT "downloadboot now diag0val=%x\n", | 3019 | ddlprintk((MYIOC_s_INFO_FMT "downloadboot now diag0val=%x\n", |
2809 | ioc->name, diag0val)); | 3020 | ioc->name, diag0val)); |
2810 | CHIPREG_WRITE32(&ioc->chip->Diagnostic, diag0val); | 3021 | CHIPREG_WRITE32(&ioc->chip->Diagnostic, diag0val); |
@@ -2812,10 +3023,23 @@ mpt_downloadboot(MPT_ADAPTER *ioc, int sleepFlag) | |||
2812 | /* Write 0xFF to reset the sequencer */ | 3023 | /* Write 0xFF to reset the sequencer */ |
2813 | CHIPREG_WRITE32(&ioc->chip->WriteSequence, 0xFF); | 3024 | CHIPREG_WRITE32(&ioc->chip->WriteSequence, 0xFF); |
2814 | 3025 | ||
3026 | if (ioc->bus_type == SAS) { | ||
3027 | ioc_state = mpt_GetIocState(ioc, 0); | ||
3028 | if ( (GetIocFacts(ioc, sleepFlag, | ||
3029 | MPT_HOSTEVENT_IOC_BRINGUP)) != 0 ) { | ||
3030 | ddlprintk((MYIOC_s_INFO_FMT "GetIocFacts failed: IocState=%x\n", | ||
3031 | ioc->name, ioc_state)); | ||
3032 | return -EFAULT; | ||
3033 | } | ||
3034 | } | ||
3035 | |||
2815 | for (count=0; count<HZ*20; count++) { | 3036 | for (count=0; count<HZ*20; count++) { |
2816 | if ((ioc_state = mpt_GetIocState(ioc, 0)) & MPI_IOC_STATE_READY) { | 3037 | if ((ioc_state = mpt_GetIocState(ioc, 0)) & MPI_IOC_STATE_READY) { |
2817 | ddlprintk((MYIOC_s_INFO_FMT "downloadboot successful! (count=%d) IocState=%x\n", | 3038 | ddlprintk((MYIOC_s_INFO_FMT "downloadboot successful! (count=%d) IocState=%x\n", |
2818 | ioc->name, count, ioc_state)); | 3039 | ioc->name, count, ioc_state)); |
3040 | if (ioc->bus_type == SAS) { | ||
3041 | return 0; | ||
3042 | } | ||
2819 | if ((SendIocInit(ioc, sleepFlag)) != 0) { | 3043 | if ((SendIocInit(ioc, sleepFlag)) != 0) { |
2820 | ddlprintk((MYIOC_s_INFO_FMT "downloadboot: SendIocInit failed\n", | 3044 | ddlprintk((MYIOC_s_INFO_FMT "downloadboot: SendIocInit failed\n", |
2821 | ioc->name)); | 3045 | ioc->name)); |
@@ -3049,12 +3273,13 @@ mpt_diag_reset(MPT_ADAPTER *ioc, int ignore, int sleepFlag) | |||
3049 | 3273 | ||
3050 | /* wait 1 sec */ | 3274 | /* wait 1 sec */ |
3051 | if (sleepFlag == CAN_SLEEP) { | 3275 | if (sleepFlag == CAN_SLEEP) { |
3052 | ssleep(1); | 3276 | msleep_interruptible (1000); |
3053 | } else { | 3277 | } else { |
3054 | mdelay (1000); | 3278 | mdelay (1000); |
3055 | } | 3279 | } |
3056 | } | 3280 | } |
3057 | if ((count = mpt_downloadboot(ioc, sleepFlag)) < 0) { | 3281 | if ((count = mpt_downloadboot(ioc, |
3282 | (MpiFwHeader_t *)ioc->cached_fw, sleepFlag)) < 0) { | ||
3058 | printk(KERN_WARNING MYNAM | 3283 | printk(KERN_WARNING MYNAM |
3059 | ": firmware downloadboot failure (%d)!\n", count); | 3284 | ": firmware downloadboot failure (%d)!\n", count); |
3060 | } | 3285 | } |
@@ -3637,7 +3862,7 @@ WaitForDoorbellAck(MPT_ADAPTER *ioc, int howlong, int sleepFlag) | |||
3637 | int count = 0; | 3862 | int count = 0; |
3638 | u32 intstat=0; | 3863 | u32 intstat=0; |
3639 | 3864 | ||
3640 | cntdn = ((sleepFlag == CAN_SLEEP) ? HZ : 1000) * howlong; | 3865 | cntdn = 1000 * howlong; |
3641 | 3866 | ||
3642 | if (sleepFlag == CAN_SLEEP) { | 3867 | if (sleepFlag == CAN_SLEEP) { |
3643 | while (--cntdn) { | 3868 | while (--cntdn) { |
@@ -3687,7 +3912,7 @@ WaitForDoorbellInt(MPT_ADAPTER *ioc, int howlong, int sleepFlag) | |||
3687 | int count = 0; | 3912 | int count = 0; |
3688 | u32 intstat=0; | 3913 | u32 intstat=0; |
3689 | 3914 | ||
3690 | cntdn = ((sleepFlag == CAN_SLEEP) ? HZ : 1000) * howlong; | 3915 | cntdn = 1000 * howlong; |
3691 | if (sleepFlag == CAN_SLEEP) { | 3916 | if (sleepFlag == CAN_SLEEP) { |
3692 | while (--cntdn) { | 3917 | while (--cntdn) { |
3693 | intstat = CHIPREG_READ32(&ioc->chip->IntStatus); | 3918 | intstat = CHIPREG_READ32(&ioc->chip->IntStatus); |
@@ -4001,6 +4226,85 @@ GetFcPortPage0(MPT_ADAPTER *ioc, int portnum) | |||
4001 | 4226 | ||
4002 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | 4227 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ |
4003 | /* | 4228 | /* |
4229 | * mptbase_sas_persist_operation - Perform operation on SAS Persitent Table | ||
4230 | * @ioc: Pointer to MPT_ADAPTER structure | ||
4231 | * @sas_address: 64bit SAS Address for operation. | ||
4232 | * @target_id: specified target for operation | ||
4233 | * @bus: specified bus for operation | ||
4234 | * @persist_opcode: see below | ||
4235 | * | ||
4236 | * MPI_SAS_OP_CLEAR_NOT_PRESENT - Free all persist TargetID mappings for | ||
4237 | * devices not currently present. | ||
4238 | * MPI_SAS_OP_CLEAR_ALL_PERSISTENT - Clear al persist TargetID mappings | ||
4239 | * | ||
4240 | * NOTE: Don't use not this function during interrupt time. | ||
4241 | * | ||
4242 | * Returns: 0 for success, non-zero error | ||
4243 | */ | ||
4244 | |||
4245 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | ||
4246 | int | ||
4247 | mptbase_sas_persist_operation(MPT_ADAPTER *ioc, u8 persist_opcode) | ||
4248 | { | ||
4249 | SasIoUnitControlRequest_t *sasIoUnitCntrReq; | ||
4250 | SasIoUnitControlReply_t *sasIoUnitCntrReply; | ||
4251 | MPT_FRAME_HDR *mf = NULL; | ||
4252 | MPIHeader_t *mpi_hdr; | ||
4253 | |||
4254 | |||
4255 | /* insure garbage is not sent to fw */ | ||
4256 | switch(persist_opcode) { | ||
4257 | |||
4258 | case MPI_SAS_OP_CLEAR_NOT_PRESENT: | ||
4259 | case MPI_SAS_OP_CLEAR_ALL_PERSISTENT: | ||
4260 | break; | ||
4261 | |||
4262 | default: | ||
4263 | return -1; | ||
4264 | break; | ||
4265 | } | ||
4266 | |||
4267 | printk("%s: persist_opcode=%x\n",__FUNCTION__, persist_opcode); | ||
4268 | |||
4269 | /* Get a MF for this command. | ||
4270 | */ | ||
4271 | if ((mf = mpt_get_msg_frame(mpt_base_index, ioc)) == NULL) { | ||
4272 | printk("%s: no msg frames!\n",__FUNCTION__); | ||
4273 | return -1; | ||
4274 | } | ||
4275 | |||
4276 | mpi_hdr = (MPIHeader_t *) mf; | ||
4277 | sasIoUnitCntrReq = (SasIoUnitControlRequest_t *)mf; | ||
4278 | memset(sasIoUnitCntrReq,0,sizeof(SasIoUnitControlRequest_t)); | ||
4279 | sasIoUnitCntrReq->Function = MPI_FUNCTION_SAS_IO_UNIT_CONTROL; | ||
4280 | sasIoUnitCntrReq->MsgContext = mpi_hdr->MsgContext; | ||
4281 | sasIoUnitCntrReq->Operation = persist_opcode; | ||
4282 | |||
4283 | init_timer(&ioc->persist_timer); | ||
4284 | ioc->persist_timer.data = (unsigned long) ioc; | ||
4285 | ioc->persist_timer.function = mpt_timer_expired; | ||
4286 | ioc->persist_timer.expires = jiffies + HZ*10 /* 10 sec */; | ||
4287 | ioc->persist_wait_done=0; | ||
4288 | add_timer(&ioc->persist_timer); | ||
4289 | mpt_put_msg_frame(mpt_base_index, ioc, mf); | ||
4290 | wait_event(mpt_waitq, ioc->persist_wait_done); | ||
4291 | |||
4292 | sasIoUnitCntrReply = | ||
4293 | (SasIoUnitControlReply_t *)ioc->persist_reply_frame; | ||
4294 | if (le16_to_cpu(sasIoUnitCntrReply->IOCStatus) != MPI_IOCSTATUS_SUCCESS) { | ||
4295 | printk("%s: IOCStatus=0x%X IOCLogInfo=0x%X\n", | ||
4296 | __FUNCTION__, | ||
4297 | sasIoUnitCntrReply->IOCStatus, | ||
4298 | sasIoUnitCntrReply->IOCLogInfo); | ||
4299 | return -1; | ||
4300 | } | ||
4301 | |||
4302 | printk("%s: success\n",__FUNCTION__); | ||
4303 | return 0; | ||
4304 | } | ||
4305 | |||
4306 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | ||
4307 | /* | ||
4004 | * GetIoUnitPage2 - Retrieve BIOS version and boot order information. | 4308 | * GetIoUnitPage2 - Retrieve BIOS version and boot order information. |
4005 | * @ioc: Pointer to MPT_ADAPTER structure | 4309 | * @ioc: Pointer to MPT_ADAPTER structure |
4006 | * | 4310 | * |
@@ -4340,10 +4644,10 @@ mpt_findImVolumes(MPT_ADAPTER *ioc) | |||
4340 | if (mpt_config(ioc, &cfg) != 0) | 4644 | if (mpt_config(ioc, &cfg) != 0) |
4341 | goto done_and_free; | 4645 | goto done_and_free; |
4342 | 4646 | ||
4343 | if ( (mem = (u8 *)ioc->spi_data.pIocPg2) == NULL ) { | 4647 | if ( (mem = (u8 *)ioc->raid_data.pIocPg2) == NULL ) { |
4344 | mem = kmalloc(iocpage2sz, GFP_ATOMIC); | 4648 | mem = kmalloc(iocpage2sz, GFP_ATOMIC); |
4345 | if (mem) { | 4649 | if (mem) { |
4346 | ioc->spi_data.pIocPg2 = (IOCPage2_t *) mem; | 4650 | ioc->raid_data.pIocPg2 = (IOCPage2_t *) mem; |
4347 | } else { | 4651 | } else { |
4348 | goto done_and_free; | 4652 | goto done_and_free; |
4349 | } | 4653 | } |
@@ -4360,7 +4664,7 @@ mpt_findImVolumes(MPT_ADAPTER *ioc) | |||
4360 | /* At least 1 RAID Volume | 4664 | /* At least 1 RAID Volume |
4361 | */ | 4665 | */ |
4362 | pIocRv = pIoc2->RaidVolume; | 4666 | pIocRv = pIoc2->RaidVolume; |
4363 | ioc->spi_data.isRaid = 0; | 4667 | ioc->raid_data.isRaid = 0; |
4364 | for (jj = 0; jj < nVols; jj++, pIocRv++) { | 4668 | for (jj = 0; jj < nVols; jj++, pIocRv++) { |
4365 | vid = pIocRv->VolumeID; | 4669 | vid = pIocRv->VolumeID; |
4366 | vbus = pIocRv->VolumeBus; | 4670 | vbus = pIocRv->VolumeBus; |
@@ -4369,7 +4673,7 @@ mpt_findImVolumes(MPT_ADAPTER *ioc) | |||
4369 | /* find the match | 4673 | /* find the match |
4370 | */ | 4674 | */ |
4371 | if (vbus == 0) { | 4675 | if (vbus == 0) { |
4372 | ioc->spi_data.isRaid |= (1 << vid); | 4676 | ioc->raid_data.isRaid |= (1 << vid); |
4373 | } else { | 4677 | } else { |
4374 | /* Error! Always bus 0 | 4678 | /* Error! Always bus 0 |
4375 | */ | 4679 | */ |
@@ -4404,8 +4708,8 @@ mpt_read_ioc_pg_3(MPT_ADAPTER *ioc) | |||
4404 | 4708 | ||
4405 | /* Free the old page | 4709 | /* Free the old page |
4406 | */ | 4710 | */ |
4407 | kfree(ioc->spi_data.pIocPg3); | 4711 | kfree(ioc->raid_data.pIocPg3); |
4408 | ioc->spi_data.pIocPg3 = NULL; | 4712 | ioc->raid_data.pIocPg3 = NULL; |
4409 | 4713 | ||
4410 | /* There is at least one physical disk. | 4714 | /* There is at least one physical disk. |
4411 | * Read and save IOC Page 3 | 4715 | * Read and save IOC Page 3 |
@@ -4442,7 +4746,7 @@ mpt_read_ioc_pg_3(MPT_ADAPTER *ioc) | |||
4442 | mem = kmalloc(iocpage3sz, GFP_ATOMIC); | 4746 | mem = kmalloc(iocpage3sz, GFP_ATOMIC); |
4443 | if (mem) { | 4747 | if (mem) { |
4444 | memcpy(mem, (u8 *)pIoc3, iocpage3sz); | 4748 | memcpy(mem, (u8 *)pIoc3, iocpage3sz); |
4445 | ioc->spi_data.pIocPg3 = (IOCPage3_t *) mem; | 4749 | ioc->raid_data.pIocPg3 = (IOCPage3_t *) mem; |
4446 | } | 4750 | } |
4447 | } | 4751 | } |
4448 | 4752 | ||
@@ -5366,8 +5670,8 @@ mpt_HardResetHandler(MPT_ADAPTER *ioc, int sleepFlag) | |||
5366 | } | 5670 | } |
5367 | 5671 | ||
5368 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | 5672 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ |
5369 | static char * | 5673 | static void |
5370 | EventDescriptionStr(u8 event, u32 evData0) | 5674 | EventDescriptionStr(u8 event, u32 evData0, char *evStr) |
5371 | { | 5675 | { |
5372 | char *ds; | 5676 | char *ds; |
5373 | 5677 | ||
@@ -5420,8 +5724,95 @@ EventDescriptionStr(u8 event, u32 evData0) | |||
5420 | ds = "Events(OFF) Change"; | 5724 | ds = "Events(OFF) Change"; |
5421 | break; | 5725 | break; |
5422 | case MPI_EVENT_INTEGRATED_RAID: | 5726 | case MPI_EVENT_INTEGRATED_RAID: |
5423 | ds = "Integrated Raid"; | 5727 | { |
5728 | u8 ReasonCode = (u8)(evData0 >> 16); | ||
5729 | switch (ReasonCode) { | ||
5730 | case MPI_EVENT_RAID_RC_VOLUME_CREATED : | ||
5731 | ds = "Integrated Raid: Volume Created"; | ||
5732 | break; | ||
5733 | case MPI_EVENT_RAID_RC_VOLUME_DELETED : | ||
5734 | ds = "Integrated Raid: Volume Deleted"; | ||
5735 | break; | ||
5736 | case MPI_EVENT_RAID_RC_VOLUME_SETTINGS_CHANGED : | ||
5737 | ds = "Integrated Raid: Volume Settings Changed"; | ||
5738 | break; | ||
5739 | case MPI_EVENT_RAID_RC_VOLUME_STATUS_CHANGED : | ||
5740 | ds = "Integrated Raid: Volume Status Changed"; | ||
5741 | break; | ||
5742 | case MPI_EVENT_RAID_RC_VOLUME_PHYSDISK_CHANGED : | ||
5743 | ds = "Integrated Raid: Volume Physdisk Changed"; | ||
5744 | break; | ||
5745 | case MPI_EVENT_RAID_RC_PHYSDISK_CREATED : | ||
5746 | ds = "Integrated Raid: Physdisk Created"; | ||
5747 | break; | ||
5748 | case MPI_EVENT_RAID_RC_PHYSDISK_DELETED : | ||
5749 | ds = "Integrated Raid: Physdisk Deleted"; | ||
5750 | break; | ||
5751 | case MPI_EVENT_RAID_RC_PHYSDISK_SETTINGS_CHANGED : | ||
5752 | ds = "Integrated Raid: Physdisk Settings Changed"; | ||
5753 | break; | ||
5754 | case MPI_EVENT_RAID_RC_PHYSDISK_STATUS_CHANGED : | ||
5755 | ds = "Integrated Raid: Physdisk Status Changed"; | ||
5756 | break; | ||
5757 | case MPI_EVENT_RAID_RC_DOMAIN_VAL_NEEDED : | ||
5758 | ds = "Integrated Raid: Domain Validation Needed"; | ||
5759 | break; | ||
5760 | case MPI_EVENT_RAID_RC_SMART_DATA : | ||
5761 | ds = "Integrated Raid; Smart Data"; | ||
5762 | break; | ||
5763 | case MPI_EVENT_RAID_RC_REPLACE_ACTION_STARTED : | ||
5764 | ds = "Integrated Raid: Replace Action Started"; | ||
5765 | break; | ||
5766 | default: | ||
5767 | ds = "Integrated Raid"; | ||
5768 | break; | ||
5769 | } | ||
5770 | break; | ||
5771 | } | ||
5772 | case MPI_EVENT_SCSI_DEVICE_STATUS_CHANGE: | ||
5773 | ds = "SCSI Device Status Change"; | ||
5774 | break; | ||
5775 | case MPI_EVENT_SAS_DEVICE_STATUS_CHANGE: | ||
5776 | { | ||
5777 | u8 ReasonCode = (u8)(evData0 >> 16); | ||
5778 | switch (ReasonCode) { | ||
5779 | case MPI_EVENT_SAS_DEV_STAT_RC_ADDED: | ||
5780 | ds = "SAS Device Status Change: Added"; | ||
5781 | break; | ||
5782 | case MPI_EVENT_SAS_DEV_STAT_RC_NOT_RESPONDING: | ||
5783 | ds = "SAS Device Status Change: Deleted"; | ||
5784 | break; | ||
5785 | case MPI_EVENT_SAS_DEV_STAT_RC_SMART_DATA: | ||
5786 | ds = "SAS Device Status Change: SMART Data"; | ||
5787 | break; | ||
5788 | case MPI_EVENT_SAS_DEV_STAT_RC_NO_PERSIST_ADDED: | ||
5789 | ds = "SAS Device Status Change: No Persistancy Added"; | ||
5790 | break; | ||
5791 | default: | ||
5792 | ds = "SAS Device Status Change: Unknown"; | ||
5793 | break; | ||
5794 | } | ||
5795 | break; | ||
5796 | } | ||
5797 | case MPI_EVENT_ON_BUS_TIMER_EXPIRED: | ||
5798 | ds = "Bus Timer Expired"; | ||
5799 | break; | ||
5800 | case MPI_EVENT_QUEUE_FULL: | ||
5801 | ds = "Queue Full"; | ||
5802 | break; | ||
5803 | case MPI_EVENT_SAS_SES: | ||
5804 | ds = "SAS SES Event"; | ||
5805 | break; | ||
5806 | case MPI_EVENT_PERSISTENT_TABLE_FULL: | ||
5807 | ds = "Persistent Table Full"; | ||
5808 | break; | ||
5809 | case MPI_EVENT_SAS_PHY_LINK_STATUS: | ||
5810 | ds = "SAS PHY Link Status"; | ||
5811 | break; | ||
5812 | case MPI_EVENT_SAS_DISCOVERY_ERROR: | ||
5813 | ds = "SAS Discovery Error"; | ||
5424 | break; | 5814 | break; |
5815 | |||
5425 | /* | 5816 | /* |
5426 | * MPT base "custom" events may be added here... | 5817 | * MPT base "custom" events may be added here... |
5427 | */ | 5818 | */ |
@@ -5429,7 +5820,7 @@ EventDescriptionStr(u8 event, u32 evData0) | |||
5429 | ds = "Unknown"; | 5820 | ds = "Unknown"; |
5430 | break; | 5821 | break; |
5431 | } | 5822 | } |
5432 | return ds; | 5823 | strcpy(evStr,ds); |
5433 | } | 5824 | } |
5434 | 5825 | ||
5435 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | 5826 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ |
@@ -5451,7 +5842,7 @@ ProcessEventNotification(MPT_ADAPTER *ioc, EventNotificationReply_t *pEventReply | |||
5451 | int ii; | 5842 | int ii; |
5452 | int r = 0; | 5843 | int r = 0; |
5453 | int handlers = 0; | 5844 | int handlers = 0; |
5454 | char *evStr; | 5845 | char evStr[100]; |
5455 | u8 event; | 5846 | u8 event; |
5456 | 5847 | ||
5457 | /* | 5848 | /* |
@@ -5464,7 +5855,7 @@ ProcessEventNotification(MPT_ADAPTER *ioc, EventNotificationReply_t *pEventReply | |||
5464 | evData0 = le32_to_cpu(pEventReply->Data[0]); | 5855 | evData0 = le32_to_cpu(pEventReply->Data[0]); |
5465 | } | 5856 | } |
5466 | 5857 | ||
5467 | evStr = EventDescriptionStr(event, evData0); | 5858 | EventDescriptionStr(event, evData0, evStr); |
5468 | devtprintk((MYIOC_s_INFO_FMT "MPT event (%s=%02Xh) detected!\n", | 5859 | devtprintk((MYIOC_s_INFO_FMT "MPT event (%s=%02Xh) detected!\n", |
5469 | ioc->name, | 5860 | ioc->name, |
5470 | evStr, | 5861 | evStr, |
@@ -5481,20 +5872,6 @@ ProcessEventNotification(MPT_ADAPTER *ioc, EventNotificationReply_t *pEventReply | |||
5481 | * Do general / base driver event processing | 5872 | * Do general / base driver event processing |
5482 | */ | 5873 | */ |
5483 | switch(event) { | 5874 | switch(event) { |
5484 | case MPI_EVENT_NONE: /* 00 */ | ||
5485 | case MPI_EVENT_LOG_DATA: /* 01 */ | ||
5486 | case MPI_EVENT_STATE_CHANGE: /* 02 */ | ||
5487 | case MPI_EVENT_UNIT_ATTENTION: /* 03 */ | ||
5488 | case MPI_EVENT_IOC_BUS_RESET: /* 04 */ | ||
5489 | case MPI_EVENT_EXT_BUS_RESET: /* 05 */ | ||
5490 | case MPI_EVENT_RESCAN: /* 06 */ | ||
5491 | case MPI_EVENT_LINK_STATUS_CHANGE: /* 07 */ | ||
5492 | case MPI_EVENT_LOOP_STATE_CHANGE: /* 08 */ | ||
5493 | case MPI_EVENT_LOGOUT: /* 09 */ | ||
5494 | case MPI_EVENT_INTEGRATED_RAID: /* 0B */ | ||
5495 | case MPI_EVENT_SCSI_DEVICE_STATUS_CHANGE: /* 0C */ | ||
5496 | default: | ||
5497 | break; | ||
5498 | case MPI_EVENT_EVENT_CHANGE: /* 0A */ | 5875 | case MPI_EVENT_EVENT_CHANGE: /* 0A */ |
5499 | if (evDataLen) { | 5876 | if (evDataLen) { |
5500 | u8 evState = evData0 & 0xFF; | 5877 | u8 evState = evData0 & 0xFF; |
@@ -5507,6 +5884,8 @@ ProcessEventNotification(MPT_ADAPTER *ioc, EventNotificationReply_t *pEventReply | |||
5507 | } | 5884 | } |
5508 | } | 5885 | } |
5509 | break; | 5886 | break; |
5887 | default: | ||
5888 | break; | ||
5510 | } | 5889 | } |
5511 | 5890 | ||
5512 | /* | 5891 | /* |
@@ -5653,6 +6032,111 @@ mpt_sp_log_info(MPT_ADAPTER *ioc, u32 log_info) | |||
5653 | printk(MYIOC_s_INFO_FMT "LogInfo(0x%08x): F/W: %s\n", ioc->name, log_info, desc); | 6032 | printk(MYIOC_s_INFO_FMT "LogInfo(0x%08x): F/W: %s\n", ioc->name, log_info, desc); |
5654 | } | 6033 | } |
5655 | 6034 | ||
6035 | /* strings for sas loginfo */ | ||
6036 | static char *originator_str[] = { | ||
6037 | "IOP", /* 00h */ | ||
6038 | "PL", /* 01h */ | ||
6039 | "IR" /* 02h */ | ||
6040 | }; | ||
6041 | static char *iop_code_str[] = { | ||
6042 | NULL, /* 00h */ | ||
6043 | "Invalid SAS Address", /* 01h */ | ||
6044 | NULL, /* 02h */ | ||
6045 | "Invalid Page", /* 03h */ | ||
6046 | NULL, /* 04h */ | ||
6047 | "Task Terminated" /* 05h */ | ||
6048 | }; | ||
6049 | static char *pl_code_str[] = { | ||
6050 | NULL, /* 00h */ | ||
6051 | "Open Failure", /* 01h */ | ||
6052 | "Invalid Scatter Gather List", /* 02h */ | ||
6053 | "Wrong Relative Offset or Frame Length", /* 03h */ | ||
6054 | "Frame Transfer Error", /* 04h */ | ||
6055 | "Transmit Frame Connected Low", /* 05h */ | ||
6056 | "SATA Non-NCQ RW Error Bit Set", /* 06h */ | ||
6057 | "SATA Read Log Receive Data Error", /* 07h */ | ||
6058 | "SATA NCQ Fail All Commands After Error", /* 08h */ | ||
6059 | "SATA Error in Receive Set Device Bit FIS", /* 09h */ | ||
6060 | "Receive Frame Invalid Message", /* 0Ah */ | ||
6061 | "Receive Context Message Valid Error", /* 0Bh */ | ||
6062 | "Receive Frame Current Frame Error", /* 0Ch */ | ||
6063 | "SATA Link Down", /* 0Dh */ | ||
6064 | "Discovery SATA Init W IOS", /* 0Eh */ | ||
6065 | "Config Invalid Page", /* 0Fh */ | ||
6066 | "Discovery SATA Init Timeout", /* 10h */ | ||
6067 | "Reset", /* 11h */ | ||
6068 | "Abort", /* 12h */ | ||
6069 | "IO Not Yet Executed", /* 13h */ | ||
6070 | "IO Executed", /* 14h */ | ||
6071 | NULL, /* 15h */ | ||
6072 | NULL, /* 16h */ | ||
6073 | NULL, /* 17h */ | ||
6074 | NULL, /* 18h */ | ||
6075 | NULL, /* 19h */ | ||
6076 | NULL, /* 1Ah */ | ||
6077 | NULL, /* 1Bh */ | ||
6078 | NULL, /* 1Ch */ | ||
6079 | NULL, /* 1Dh */ | ||
6080 | NULL, /* 1Eh */ | ||
6081 | NULL, /* 1Fh */ | ||
6082 | "Enclosure Management" /* 20h */ | ||
6083 | }; | ||
6084 | |||
6085 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | ||
6086 | /* | ||
6087 | * mpt_sas_log_info - Log information returned from SAS IOC. | ||
6088 | * @ioc: Pointer to MPT_ADAPTER structure | ||
6089 | * @log_info: U32 LogInfo reply word from the IOC | ||
6090 | * | ||
6091 | * Refer to lsi/mpi_log_sas.h. | ||
6092 | */ | ||
6093 | static void | ||
6094 | mpt_sas_log_info(MPT_ADAPTER *ioc, u32 log_info) | ||
6095 | { | ||
6096 | union loginfo_type { | ||
6097 | u32 loginfo; | ||
6098 | struct { | ||
6099 | u32 subcode:16; | ||
6100 | u32 code:8; | ||
6101 | u32 originator:4; | ||
6102 | u32 bus_type:4; | ||
6103 | }dw; | ||
6104 | }; | ||
6105 | union loginfo_type sas_loginfo; | ||
6106 | char *code_desc = NULL; | ||
6107 | |||
6108 | sas_loginfo.loginfo = log_info; | ||
6109 | if ((sas_loginfo.dw.bus_type != 3 /*SAS*/) && | ||
6110 | (sas_loginfo.dw.originator < sizeof(originator_str)/sizeof(char*))) | ||
6111 | return; | ||
6112 | if ((sas_loginfo.dw.originator == 0 /*IOP*/) && | ||
6113 | (sas_loginfo.dw.code < sizeof(iop_code_str)/sizeof(char*))) { | ||
6114 | code_desc = iop_code_str[sas_loginfo.dw.code]; | ||
6115 | }else if ((sas_loginfo.dw.originator == 1 /*PL*/) && | ||
6116 | (sas_loginfo.dw.code < sizeof(pl_code_str)/sizeof(char*) )) { | ||
6117 | code_desc = pl_code_str[sas_loginfo.dw.code]; | ||
6118 | } | ||
6119 | |||
6120 | if (code_desc != NULL) | ||
6121 | printk(MYIOC_s_INFO_FMT | ||
6122 | "LogInfo(0x%08x): Originator={%s}, Code={%s}," | ||
6123 | " SubCode(0x%04x)\n", | ||
6124 | ioc->name, | ||
6125 | log_info, | ||
6126 | originator_str[sas_loginfo.dw.originator], | ||
6127 | code_desc, | ||
6128 | sas_loginfo.dw.subcode); | ||
6129 | else | ||
6130 | printk(MYIOC_s_INFO_FMT | ||
6131 | "LogInfo(0x%08x): Originator={%s}, Code=(0x%02x)," | ||
6132 | " SubCode(0x%04x)\n", | ||
6133 | ioc->name, | ||
6134 | log_info, | ||
6135 | originator_str[sas_loginfo.dw.originator], | ||
6136 | sas_loginfo.dw.code, | ||
6137 | sas_loginfo.dw.subcode); | ||
6138 | } | ||
6139 | |||
5656 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | 6140 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ |
5657 | /* | 6141 | /* |
5658 | * mpt_sp_ioc_info - IOC information returned from SCSI Parallel IOC. | 6142 | * mpt_sp_ioc_info - IOC information returned from SCSI Parallel IOC. |
@@ -5814,6 +6298,7 @@ EXPORT_SYMBOL(mpt_findImVolumes); | |||
5814 | EXPORT_SYMBOL(mpt_read_ioc_pg_3); | 6298 | EXPORT_SYMBOL(mpt_read_ioc_pg_3); |
5815 | EXPORT_SYMBOL(mpt_alloc_fw_memory); | 6299 | EXPORT_SYMBOL(mpt_alloc_fw_memory); |
5816 | EXPORT_SYMBOL(mpt_free_fw_memory); | 6300 | EXPORT_SYMBOL(mpt_free_fw_memory); |
6301 | EXPORT_SYMBOL(mptbase_sas_persist_operation); | ||
5817 | 6302 | ||
5818 | 6303 | ||
5819 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | 6304 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ |
diff --git a/drivers/message/fusion/mptbase.h b/drivers/message/fusion/mptbase.h index f4827d923731..75105277e22f 100644 --- a/drivers/message/fusion/mptbase.h +++ b/drivers/message/fusion/mptbase.h | |||
@@ -65,6 +65,7 @@ | |||
65 | #include "lsi/mpi_fc.h" /* Fibre Channel (lowlevel) support */ | 65 | #include "lsi/mpi_fc.h" /* Fibre Channel (lowlevel) support */ |
66 | #include "lsi/mpi_targ.h" /* SCSI/FCP Target protcol support */ | 66 | #include "lsi/mpi_targ.h" /* SCSI/FCP Target protcol support */ |
67 | #include "lsi/mpi_tool.h" /* Tools support */ | 67 | #include "lsi/mpi_tool.h" /* Tools support */ |
68 | #include "lsi/mpi_sas.h" /* SAS support */ | ||
68 | 69 | ||
69 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | 70 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ |
70 | 71 | ||
@@ -76,8 +77,8 @@ | |||
76 | #define COPYRIGHT "Copyright (c) 1999-2005 " MODULEAUTHOR | 77 | #define COPYRIGHT "Copyright (c) 1999-2005 " MODULEAUTHOR |
77 | #endif | 78 | #endif |
78 | 79 | ||
79 | #define MPT_LINUX_VERSION_COMMON "3.03.02" | 80 | #define MPT_LINUX_VERSION_COMMON "3.03.03" |
80 | #define MPT_LINUX_PACKAGE_NAME "@(#)mptlinux-3.03.02" | 81 | #define MPT_LINUX_PACKAGE_NAME "@(#)mptlinux-3.03.03" |
81 | #define WHAT_MAGIC_STRING "@" "(" "#" ")" | 82 | #define WHAT_MAGIC_STRING "@" "(" "#" ")" |
82 | 83 | ||
83 | #define show_mptmod_ver(s,ver) \ | 84 | #define show_mptmod_ver(s,ver) \ |
@@ -423,7 +424,7 @@ typedef struct _MPT_IOCTL { | |||
423 | /* | 424 | /* |
424 | * Event Structure and define | 425 | * Event Structure and define |
425 | */ | 426 | */ |
426 | #define MPTCTL_EVENT_LOG_SIZE (0x0000000A) | 427 | #define MPTCTL_EVENT_LOG_SIZE (0x000000032) |
427 | typedef struct _mpt_ioctl_events { | 428 | typedef struct _mpt_ioctl_events { |
428 | u32 event; /* Specified by define above */ | 429 | u32 event; /* Specified by define above */ |
429 | u32 eventContext; /* Index or counter */ | 430 | u32 eventContext; /* Index or counter */ |
@@ -451,16 +452,13 @@ typedef struct _mpt_ioctl_events { | |||
451 | #define MPT_SCSICFG_ALL_IDS 0x02 /* WriteSDP1 to all IDS */ | 452 | #define MPT_SCSICFG_ALL_IDS 0x02 /* WriteSDP1 to all IDS */ |
452 | /* #define MPT_SCSICFG_BLK_NEGO 0x10 WriteSDP1 with WDTR and SDTR disabled */ | 453 | /* #define MPT_SCSICFG_BLK_NEGO 0x10 WriteSDP1 with WDTR and SDTR disabled */ |
453 | 454 | ||
454 | typedef struct _ScsiCfgData { | 455 | typedef struct _SpiCfgData { |
455 | u32 PortFlags; | 456 | u32 PortFlags; |
456 | int *nvram; /* table of device NVRAM values */ | 457 | int *nvram; /* table of device NVRAM values */ |
457 | IOCPage2_t *pIocPg2; /* table of Raid Volumes */ | ||
458 | IOCPage3_t *pIocPg3; /* table of physical disks */ | ||
459 | IOCPage4_t *pIocPg4; /* SEP devices addressing */ | 458 | IOCPage4_t *pIocPg4; /* SEP devices addressing */ |
460 | dma_addr_t IocPg4_dma; /* Phys Addr of IOCPage4 data */ | 459 | dma_addr_t IocPg4_dma; /* Phys Addr of IOCPage4 data */ |
461 | int IocPg4Sz; /* IOCPage4 size */ | 460 | int IocPg4Sz; /* IOCPage4 size */ |
462 | u8 dvStatus[MPT_MAX_SCSI_DEVICES]; | 461 | u8 dvStatus[MPT_MAX_SCSI_DEVICES]; |
463 | int isRaid; /* bit field, 1 if RAID */ | ||
464 | u8 minSyncFactor; /* 0xFF if async */ | 462 | u8 minSyncFactor; /* 0xFF if async */ |
465 | u8 maxSyncOffset; /* 0 if async */ | 463 | u8 maxSyncOffset; /* 0 if async */ |
466 | u8 maxBusWidth; /* 0 if narrow, 1 if wide */ | 464 | u8 maxBusWidth; /* 0 if narrow, 1 if wide */ |
@@ -472,10 +470,28 @@ typedef struct _ScsiCfgData { | |||
472 | u8 dvScheduled; /* 1 if scheduled */ | 470 | u8 dvScheduled; /* 1 if scheduled */ |
473 | u8 forceDv; /* 1 to force DV scheduling */ | 471 | u8 forceDv; /* 1 to force DV scheduling */ |
474 | u8 noQas; /* Disable QAS for this adapter */ | 472 | u8 noQas; /* Disable QAS for this adapter */ |
475 | u8 Saf_Te; /* 1 to force all Processors as SAF-TE if Inquiry data length is too short to check for SAF-TE */ | 473 | u8 Saf_Te; /* 1 to force all Processors as |
474 | * SAF-TE if Inquiry data length | ||
475 | * is too short to check for SAF-TE | ||
476 | */ | ||
476 | u8 mpt_dv; /* command line option: enhanced=1, basic=0 */ | 477 | u8 mpt_dv; /* command line option: enhanced=1, basic=0 */ |
478 | u8 bus_reset; /* 1 to allow bus reset */ | ||
477 | u8 rsvd[1]; | 479 | u8 rsvd[1]; |
478 | } ScsiCfgData; | 480 | }SpiCfgData; |
481 | |||
482 | typedef struct _SasCfgData { | ||
483 | u8 ptClear; /* 1 to automatically clear the | ||
484 | * persistent table. | ||
485 | * 0 to disable | ||
486 | * automatic clearing. | ||
487 | */ | ||
488 | }SasCfgData; | ||
489 | |||
490 | typedef struct _RaidCfgData { | ||
491 | IOCPage2_t *pIocPg2; /* table of Raid Volumes */ | ||
492 | IOCPage3_t *pIocPg3; /* table of physical disks */ | ||
493 | int isRaid; /* bit field, 1 if RAID */ | ||
494 | }RaidCfgData; | ||
479 | 495 | ||
480 | /* | 496 | /* |
481 | * Adapter Structure - pci_dev specific. Maximum: MPT_MAX_ADAPTERS | 497 | * Adapter Structure - pci_dev specific. Maximum: MPT_MAX_ADAPTERS |
@@ -530,11 +546,16 @@ typedef struct _MPT_ADAPTER | |||
530 | u8 *sense_buf_pool; | 546 | u8 *sense_buf_pool; |
531 | dma_addr_t sense_buf_pool_dma; | 547 | dma_addr_t sense_buf_pool_dma; |
532 | u32 sense_buf_low_dma; | 548 | u32 sense_buf_low_dma; |
549 | u8 *HostPageBuffer; /* SAS - host page buffer support */ | ||
550 | u32 HostPageBuffer_sz; | ||
551 | dma_addr_t HostPageBuffer_dma; | ||
533 | int mtrr_reg; | 552 | int mtrr_reg; |
534 | struct pci_dev *pcidev; /* struct pci_dev pointer */ | 553 | struct pci_dev *pcidev; /* struct pci_dev pointer */ |
535 | u8 __iomem *memmap; /* mmap address */ | 554 | u8 __iomem *memmap; /* mmap address */ |
536 | struct Scsi_Host *sh; /* Scsi Host pointer */ | 555 | struct Scsi_Host *sh; /* Scsi Host pointer */ |
537 | ScsiCfgData spi_data; /* Scsi config. data */ | 556 | SpiCfgData spi_data; /* Scsi config. data */ |
557 | RaidCfgData raid_data; /* Raid config. data */ | ||
558 | SasCfgData sas_data; /* Sas config. data */ | ||
538 | MPT_IOCTL *ioctl; /* ioctl data pointer */ | 559 | MPT_IOCTL *ioctl; /* ioctl data pointer */ |
539 | struct proc_dir_entry *ioc_dentry; | 560 | struct proc_dir_entry *ioc_dentry; |
540 | struct _MPT_ADAPTER *alt_ioc; /* ptr to 929 bound adapter port */ | 561 | struct _MPT_ADAPTER *alt_ioc; /* ptr to 929 bound adapter port */ |
@@ -554,31 +575,35 @@ typedef struct _MPT_ADAPTER | |||
554 | #else | 575 | #else |
555 | u32 mfcnt; | 576 | u32 mfcnt; |
556 | #endif | 577 | #endif |
557 | u32 NB_for_64_byte_frame; | 578 | u32 NB_for_64_byte_frame; |
558 | u32 hs_req[MPT_MAX_FRAME_SIZE/sizeof(u32)]; | 579 | u32 hs_req[MPT_MAX_FRAME_SIZE/sizeof(u32)]; |
559 | u16 hs_reply[MPT_MAX_FRAME_SIZE/sizeof(u16)]; | 580 | u16 hs_reply[MPT_MAX_FRAME_SIZE/sizeof(u16)]; |
560 | IOCFactsReply_t facts; | 581 | IOCFactsReply_t facts; |
561 | PortFactsReply_t pfacts[2]; | 582 | PortFactsReply_t pfacts[2]; |
562 | FCPortPage0_t fc_port_page0[2]; | 583 | FCPortPage0_t fc_port_page0[2]; |
584 | struct timer_list persist_timer; /* persist table timer */ | ||
585 | int persist_wait_done; /* persist completion flag */ | ||
586 | u8 persist_reply_frame[MPT_DEFAULT_FRAME_SIZE]; /* persist reply */ | ||
563 | LANPage0_t lan_cnfg_page0; | 587 | LANPage0_t lan_cnfg_page0; |
564 | LANPage1_t lan_cnfg_page1; | 588 | LANPage1_t lan_cnfg_page1; |
565 | /* | 589 | /* |
566 | * Description: errata_flag_1064 | 590 | * Description: errata_flag_1064 |
567 | * If a PCIX read occurs within 1 or 2 cycles after the chip receives | 591 | * If a PCIX read occurs within 1 or 2 cycles after the chip receives |
568 | * a split completion for a read data, an internal address pointer incorrectly | 592 | * a split completion for a read data, an internal address pointer incorrectly |
569 | * increments by 32 bytes | 593 | * increments by 32 bytes |
570 | */ | 594 | */ |
571 | int errata_flag_1064; | 595 | int errata_flag_1064; |
572 | u8 FirstWhoInit; | 596 | u8 FirstWhoInit; |
573 | u8 upload_fw; /* If set, do a fw upload */ | 597 | u8 upload_fw; /* If set, do a fw upload */ |
574 | u8 reload_fw; /* Force a FW Reload on next reset */ | 598 | u8 reload_fw; /* Force a FW Reload on next reset */ |
575 | u8 NBShiftFactor; /* NB Shift Factor based on Block Size (Facts) */ | 599 | u8 NBShiftFactor; /* NB Shift Factor based on Block Size (Facts) */ |
576 | u8 pad1[4]; | 600 | u8 pad1[4]; |
577 | int DoneCtx; | 601 | int DoneCtx; |
578 | int TaskCtx; | 602 | int TaskCtx; |
579 | int InternalCtx; | 603 | int InternalCtx; |
580 | struct list_head list; | 604 | struct list_head list; |
581 | struct net_device *netdev; | 605 | struct net_device *netdev; |
606 | struct list_head sas_topology; | ||
582 | } MPT_ADAPTER; | 607 | } MPT_ADAPTER; |
583 | 608 | ||
584 | /* | 609 | /* |
@@ -964,6 +989,7 @@ extern void mpt_alloc_fw_memory(MPT_ADAPTER *ioc, int size); | |||
964 | extern void mpt_free_fw_memory(MPT_ADAPTER *ioc); | 989 | extern void mpt_free_fw_memory(MPT_ADAPTER *ioc); |
965 | extern int mpt_findImVolumes(MPT_ADAPTER *ioc); | 990 | extern int mpt_findImVolumes(MPT_ADAPTER *ioc); |
966 | extern int mpt_read_ioc_pg_3(MPT_ADAPTER *ioc); | 991 | extern int mpt_read_ioc_pg_3(MPT_ADAPTER *ioc); |
992 | extern int mptbase_sas_persist_operation(MPT_ADAPTER *ioc, u8 persist_opcode); | ||
967 | 993 | ||
968 | /* | 994 | /* |
969 | * Public data decl's... | 995 | * Public data decl's... |
diff --git a/drivers/message/fusion/mptctl.c b/drivers/message/fusion/mptctl.c index 7577c2417e2e..cb2d59d5f5af 100644 --- a/drivers/message/fusion/mptctl.c +++ b/drivers/message/fusion/mptctl.c | |||
@@ -1326,7 +1326,7 @@ mptctl_gettargetinfo (unsigned long arg) | |||
1326 | */ | 1326 | */ |
1327 | if (hd && hd->Targets) { | 1327 | if (hd && hd->Targets) { |
1328 | mpt_findImVolumes(ioc); | 1328 | mpt_findImVolumes(ioc); |
1329 | pIoc2 = ioc->spi_data.pIocPg2; | 1329 | pIoc2 = ioc->raid_data.pIocPg2; |
1330 | for ( id = 0; id <= max_id; ) { | 1330 | for ( id = 0; id <= max_id; ) { |
1331 | if ( pIoc2 && pIoc2->NumActiveVolumes ) { | 1331 | if ( pIoc2 && pIoc2->NumActiveVolumes ) { |
1332 | if ( id == pIoc2->RaidVolume[0].VolumeID ) { | 1332 | if ( id == pIoc2->RaidVolume[0].VolumeID ) { |
@@ -1348,7 +1348,7 @@ mptctl_gettargetinfo (unsigned long arg) | |||
1348 | --maxWordsLeft; | 1348 | --maxWordsLeft; |
1349 | goto next_id; | 1349 | goto next_id; |
1350 | } else { | 1350 | } else { |
1351 | pIoc3 = ioc->spi_data.pIocPg3; | 1351 | pIoc3 = ioc->raid_data.pIocPg3; |
1352 | for ( jj = 0; jj < pIoc3->NumPhysDisks; jj++ ) { | 1352 | for ( jj = 0; jj < pIoc3->NumPhysDisks; jj++ ) { |
1353 | if ( pIoc3->PhysDisk[jj].PhysDiskID == id ) | 1353 | if ( pIoc3->PhysDisk[jj].PhysDiskID == id ) |
1354 | goto next_id; | 1354 | goto next_id; |
diff --git a/drivers/message/fusion/mptfc.c b/drivers/message/fusion/mptfc.c index 13771abea13f..a628be9bbbad 100644 --- a/drivers/message/fusion/mptfc.c +++ b/drivers/message/fusion/mptfc.c | |||
@@ -189,7 +189,7 @@ mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id) | |||
189 | printk(MYIOC_s_WARN_FMT | 189 | printk(MYIOC_s_WARN_FMT |
190 | "Skipping ioc=%p because SCSI Initiator mode is NOT enabled!\n", | 190 | "Skipping ioc=%p because SCSI Initiator mode is NOT enabled!\n", |
191 | ioc->name, ioc); | 191 | ioc->name, ioc); |
192 | return -ENODEV; | 192 | return 0; |
193 | } | 193 | } |
194 | 194 | ||
195 | sh = scsi_host_alloc(&mptfc_driver_template, sizeof(MPT_SCSI_HOST)); | 195 | sh = scsi_host_alloc(&mptfc_driver_template, sizeof(MPT_SCSI_HOST)); |
diff --git a/drivers/message/fusion/mptlan.c b/drivers/message/fusion/mptlan.c index 52794be5a95c..ed3c891e388f 100644 --- a/drivers/message/fusion/mptlan.c +++ b/drivers/message/fusion/mptlan.c | |||
@@ -312,7 +312,12 @@ static int | |||
312 | mpt_lan_ioc_reset(MPT_ADAPTER *ioc, int reset_phase) | 312 | mpt_lan_ioc_reset(MPT_ADAPTER *ioc, int reset_phase) |
313 | { | 313 | { |
314 | struct net_device *dev = ioc->netdev; | 314 | struct net_device *dev = ioc->netdev; |
315 | struct mpt_lan_priv *priv = netdev_priv(dev); | 315 | struct mpt_lan_priv *priv; |
316 | |||
317 | if (dev == NULL) | ||
318 | return(1); | ||
319 | else | ||
320 | priv = netdev_priv(dev); | ||
316 | 321 | ||
317 | dlprintk((KERN_INFO MYNAM ": IOC %s_reset routed to LAN driver!\n", | 322 | dlprintk((KERN_INFO MYNAM ": IOC %s_reset routed to LAN driver!\n", |
318 | reset_phase==MPT_IOC_SETUP_RESET ? "setup" : ( | 323 | reset_phase==MPT_IOC_SETUP_RESET ? "setup" : ( |
diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c new file mode 100644 index 000000000000..429820e48c69 --- /dev/null +++ b/drivers/message/fusion/mptsas.c | |||
@@ -0,0 +1,1235 @@ | |||
1 | /* | ||
2 | * linux/drivers/message/fusion/mptsas.c | ||
3 | * For use with LSI Logic PCI chip/adapter(s) | ||
4 | * running LSI Logic Fusion MPT (Message Passing Technology) firmware. | ||
5 | * | ||
6 | * Copyright (c) 1999-2005 LSI Logic Corporation | ||
7 | * (mailto:mpt_linux_developer@lsil.com) | ||
8 | * Copyright (c) 2005 Dell | ||
9 | */ | ||
10 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | ||
11 | /* | ||
12 | This program is free software; you can redistribute it and/or modify | ||
13 | it under the terms of the GNU General Public License as published by | ||
14 | the Free Software Foundation; version 2 of the License. | ||
15 | |||
16 | This program is distributed in the hope that it will be useful, | ||
17 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
19 | GNU General Public License for more details. | ||
20 | |||
21 | NO WARRANTY | ||
22 | THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR | ||
23 | CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT | ||
24 | LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, | ||
25 | MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is | ||
26 | solely responsible for determining the appropriateness of using and | ||
27 | distributing the Program and assumes all risks associated with its | ||
28 | exercise of rights under this Agreement, including but not limited to | ||
29 | the risks and costs of program errors, damage to or loss of data, | ||
30 | programs or equipment, and unavailability or interruption of operations. | ||
31 | |||
32 | DISCLAIMER OF LIABILITY | ||
33 | NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY | ||
34 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
35 | DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND | ||
36 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR | ||
37 | TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE | ||
38 | USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED | ||
39 | HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES | ||
40 | |||
41 | You should have received a copy of the GNU General Public License | ||
42 | along with this program; if not, write to the Free Software | ||
43 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
44 | */ | ||
45 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | ||
46 | |||
47 | #include <linux/module.h> | ||
48 | #include <linux/kernel.h> | ||
49 | #include <linux/init.h> | ||
50 | #include <linux/errno.h> | ||
51 | #include <linux/sched.h> | ||
52 | #include <linux/workqueue.h> | ||
53 | |||
54 | #include <scsi/scsi_cmnd.h> | ||
55 | #include <scsi/scsi_device.h> | ||
56 | #include <scsi/scsi_host.h> | ||
57 | #include <scsi/scsi_transport_sas.h> | ||
58 | |||
59 | #include "mptbase.h" | ||
60 | #include "mptscsih.h" | ||
61 | |||
62 | |||
63 | #define my_NAME "Fusion MPT SAS Host driver" | ||
64 | #define my_VERSION MPT_LINUX_VERSION_COMMON | ||
65 | #define MYNAM "mptsas" | ||
66 | |||
67 | MODULE_AUTHOR(MODULEAUTHOR); | ||
68 | MODULE_DESCRIPTION(my_NAME); | ||
69 | MODULE_LICENSE("GPL"); | ||
70 | |||
71 | static int mpt_pq_filter; | ||
72 | module_param(mpt_pq_filter, int, 0); | ||
73 | MODULE_PARM_DESC(mpt_pq_filter, | ||
74 | "Enable peripheral qualifier filter: enable=1 " | ||
75 | "(default=0)"); | ||
76 | |||
77 | static int mpt_pt_clear; | ||
78 | module_param(mpt_pt_clear, int, 0); | ||
79 | MODULE_PARM_DESC(mpt_pt_clear, | ||
80 | "Clear persistency table: enable=1 " | ||
81 | "(default=MPTSCSIH_PT_CLEAR=0)"); | ||
82 | |||
83 | static int mptsasDoneCtx = -1; | ||
84 | static int mptsasTaskCtx = -1; | ||
85 | static int mptsasInternalCtx = -1; /* Used only for internal commands */ | ||
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 | u8 phy_id; /* phy number of parent device */ | ||
99 | u8 port_id; /* sas physical port this device | ||
100 | is assoc'd with */ | ||
101 | u8 target; /* logical target id of this device */ | ||
102 | u8 bus; /* logical bus number of this device */ | ||
103 | u64 sas_address; /* WWN of this device, | ||
104 | SATA is assigned by HBA,expander */ | ||
105 | u32 device_info; /* bitfield detailed info about this device */ | ||
106 | }; | ||
107 | |||
108 | struct mptsas_phyinfo { | ||
109 | u8 phy_id; /* phy index */ | ||
110 | u8 port_id; /* port number this phy is part of */ | ||
111 | u8 negotiated_link_rate; /* nego'd link rate for this phy */ | ||
112 | u8 hw_link_rate; /* hardware max/min phys link rate */ | ||
113 | u8 programmed_link_rate; /* programmed max/min phy link rate */ | ||
114 | struct mptsas_devinfo identify; /* point to phy device info */ | ||
115 | struct mptsas_devinfo attached; /* point to attached device info */ | ||
116 | struct sas_rphy *rphy; | ||
117 | }; | ||
118 | |||
119 | struct mptsas_portinfo { | ||
120 | struct list_head list; | ||
121 | u16 handle; /* unique id to address this */ | ||
122 | u8 num_phys; /* number of phys */ | ||
123 | struct mptsas_phyinfo *phy_info; | ||
124 | }; | ||
125 | |||
126 | /* | ||
127 | * This is pretty ugly. We will be able to seriously clean it up | ||
128 | * once the DV code in mptscsih goes away and we can properly | ||
129 | * implement ->target_alloc. | ||
130 | */ | ||
131 | static int | ||
132 | mptsas_slave_alloc(struct scsi_device *device) | ||
133 | { | ||
134 | struct Scsi_Host *host = device->host; | ||
135 | MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; | ||
136 | struct sas_rphy *rphy; | ||
137 | struct mptsas_portinfo *p; | ||
138 | VirtDevice *vdev; | ||
139 | uint target = device->id; | ||
140 | int i; | ||
141 | |||
142 | if ((vdev = hd->Targets[target]) != NULL) | ||
143 | goto out; | ||
144 | |||
145 | vdev = kmalloc(sizeof(VirtDevice), GFP_KERNEL); | ||
146 | if (!vdev) { | ||
147 | printk(MYIOC_s_ERR_FMT "slave_alloc kmalloc(%zd) FAILED!\n", | ||
148 | hd->ioc->name, sizeof(VirtDevice)); | ||
149 | return -ENOMEM; | ||
150 | } | ||
151 | |||
152 | memset(vdev, 0, sizeof(VirtDevice)); | ||
153 | vdev->tflags = MPT_TARGET_FLAGS_Q_YES|MPT_TARGET_FLAGS_VALID_INQUIRY; | ||
154 | vdev->ioc_id = hd->ioc->id; | ||
155 | |||
156 | rphy = dev_to_rphy(device->sdev_target->dev.parent); | ||
157 | list_for_each_entry(p, &hd->ioc->sas_topology, list) { | ||
158 | for (i = 0; i < p->num_phys; i++) { | ||
159 | if (p->phy_info[i].attached.sas_address == | ||
160 | rphy->identify.sas_address) { | ||
161 | vdev->target_id = | ||
162 | p->phy_info[i].attached.target; | ||
163 | vdev->bus_id = p->phy_info[i].attached.bus; | ||
164 | hd->Targets[device->id] = vdev; | ||
165 | goto out; | ||
166 | } | ||
167 | } | ||
168 | } | ||
169 | |||
170 | printk("No matching SAS device found!!\n"); | ||
171 | kfree(vdev); | ||
172 | return -ENODEV; | ||
173 | |||
174 | out: | ||
175 | vdev->num_luns++; | ||
176 | device->hostdata = vdev; | ||
177 | return 0; | ||
178 | } | ||
179 | |||
180 | static struct scsi_host_template mptsas_driver_template = { | ||
181 | .proc_name = "mptsas", | ||
182 | .proc_info = mptscsih_proc_info, | ||
183 | .name = "MPT SPI Host", | ||
184 | .info = mptscsih_info, | ||
185 | .queuecommand = mptscsih_qcmd, | ||
186 | .slave_alloc = mptsas_slave_alloc, | ||
187 | .slave_configure = mptscsih_slave_configure, | ||
188 | .slave_destroy = mptscsih_slave_destroy, | ||
189 | .change_queue_depth = mptscsih_change_queue_depth, | ||
190 | .eh_abort_handler = mptscsih_abort, | ||
191 | .eh_device_reset_handler = mptscsih_dev_reset, | ||
192 | .eh_bus_reset_handler = mptscsih_bus_reset, | ||
193 | .eh_host_reset_handler = mptscsih_host_reset, | ||
194 | .bios_param = mptscsih_bios_param, | ||
195 | .can_queue = MPT_FC_CAN_QUEUE, | ||
196 | .this_id = -1, | ||
197 | .sg_tablesize = MPT_SCSI_SG_DEPTH, | ||
198 | .max_sectors = 8192, | ||
199 | .cmd_per_lun = 7, | ||
200 | .use_clustering = ENABLE_CLUSTERING, | ||
201 | }; | ||
202 | |||
203 | static struct sas_function_template mptsas_transport_functions = { | ||
204 | }; | ||
205 | |||
206 | static struct scsi_transport_template *mptsas_transport_template; | ||
207 | |||
208 | #ifdef SASDEBUG | ||
209 | static void mptsas_print_phy_data(MPI_SAS_IO_UNIT0_PHY_DATA *phy_data) | ||
210 | { | ||
211 | printk("---- IO UNIT PAGE 0 ------------\n"); | ||
212 | printk("Handle=0x%X\n", | ||
213 | le16_to_cpu(phy_data->AttachedDeviceHandle)); | ||
214 | printk("Controller Handle=0x%X\n", | ||
215 | le16_to_cpu(phy_data->ControllerDevHandle)); | ||
216 | printk("Port=0x%X\n", phy_data->Port); | ||
217 | printk("Port Flags=0x%X\n", phy_data->PortFlags); | ||
218 | printk("PHY Flags=0x%X\n", phy_data->PhyFlags); | ||
219 | printk("Negotiated Link Rate=0x%X\n", phy_data->NegotiatedLinkRate); | ||
220 | printk("Controller PHY Device Info=0x%X\n", | ||
221 | le32_to_cpu(phy_data->ControllerPhyDeviceInfo)); | ||
222 | printk("DiscoveryStatus=0x%X\n", | ||
223 | le32_to_cpu(phy_data->DiscoveryStatus)); | ||
224 | printk("\n"); | ||
225 | } | ||
226 | |||
227 | static void mptsas_print_phy_pg0(SasPhyPage0_t *pg0) | ||
228 | { | ||
229 | __le64 sas_address; | ||
230 | |||
231 | memcpy(&sas_address, &pg0->SASAddress, sizeof(__le64)); | ||
232 | |||
233 | printk("---- SAS PHY PAGE 0 ------------\n"); | ||
234 | printk("Attached Device Handle=0x%X\n", | ||
235 | le16_to_cpu(pg0->AttachedDevHandle)); | ||
236 | printk("SAS Address=0x%llX\n", | ||
237 | (unsigned long long)le64_to_cpu(sas_address)); | ||
238 | printk("Attached PHY Identifier=0x%X\n", pg0->AttachedPhyIdentifier); | ||
239 | printk("Attached Device Info=0x%X\n", | ||
240 | le32_to_cpu(pg0->AttachedDeviceInfo)); | ||
241 | printk("Programmed Link Rate=0x%X\n", pg0->ProgrammedLinkRate); | ||
242 | printk("Change Count=0x%X\n", pg0->ChangeCount); | ||
243 | printk("PHY Info=0x%X\n", le32_to_cpu(pg0->PhyInfo)); | ||
244 | printk("\n"); | ||
245 | } | ||
246 | |||
247 | static void mptsas_print_device_pg0(SasDevicePage0_t *pg0) | ||
248 | { | ||
249 | __le64 sas_address; | ||
250 | |||
251 | memcpy(&sas_address, &pg0->SASAddress, sizeof(__le64)); | ||
252 | |||
253 | printk("---- SAS DEVICE PAGE 0 ---------\n"); | ||
254 | printk("Handle=0x%X\n" ,le16_to_cpu(pg0->DevHandle)); | ||
255 | printk("Enclosure Handle=0x%X\n", le16_to_cpu(pg0->EnclosureHandle)); | ||
256 | printk("Slot=0x%X\n", le16_to_cpu(pg0->Slot)); | ||
257 | printk("SAS Address=0x%llX\n", le64_to_cpu(sas_address)); | ||
258 | printk("Target ID=0x%X\n", pg0->TargetID); | ||
259 | printk("Bus=0x%X\n", pg0->Bus); | ||
260 | printk("PhyNum=0x%X\n", pg0->PhyNum); | ||
261 | printk("AccessStatus=0x%X\n", le16_to_cpu(pg0->AccessStatus)); | ||
262 | printk("Device Info=0x%X\n", le32_to_cpu(pg0->DeviceInfo)); | ||
263 | printk("Flags=0x%X\n", le16_to_cpu(pg0->Flags)); | ||
264 | printk("Physical Port=0x%X\n", pg0->PhysicalPort); | ||
265 | printk("\n"); | ||
266 | } | ||
267 | |||
268 | static void mptsas_print_expander_pg1(SasExpanderPage1_t *pg1) | ||
269 | { | ||
270 | printk("---- SAS EXPANDER PAGE 1 ------------\n"); | ||
271 | |||
272 | printk("Physical Port=0x%X\n", pg1->PhysicalPort); | ||
273 | printk("PHY Identifier=0x%X\n", pg1->Phy); | ||
274 | printk("Negotiated Link Rate=0x%X\n", pg1->NegotiatedLinkRate); | ||
275 | printk("Programmed Link Rate=0x%X\n", pg1->ProgrammedLinkRate); | ||
276 | printk("Hardware Link Rate=0x%X\n", pg1->HwLinkRate); | ||
277 | printk("Owner Device Handle=0x%X\n", | ||
278 | le16_to_cpu(pg1->OwnerDevHandle)); | ||
279 | printk("Attached Device Handle=0x%X\n", | ||
280 | le16_to_cpu(pg1->AttachedDevHandle)); | ||
281 | } | ||
282 | #else | ||
283 | #define mptsas_print_phy_data(phy_data) do { } while (0) | ||
284 | #define mptsas_print_phy_pg0(pg0) do { } while (0) | ||
285 | #define mptsas_print_device_pg0(pg0) do { } while (0) | ||
286 | #define mptsas_print_expander_pg1(pg1) do { } while (0) | ||
287 | #endif | ||
288 | |||
289 | static int | ||
290 | mptsas_sas_io_unit_pg0(MPT_ADAPTER *ioc, struct mptsas_portinfo *port_info) | ||
291 | { | ||
292 | ConfigExtendedPageHeader_t hdr; | ||
293 | CONFIGPARMS cfg; | ||
294 | SasIOUnitPage0_t *buffer; | ||
295 | dma_addr_t dma_handle; | ||
296 | int error, i; | ||
297 | |||
298 | hdr.PageVersion = MPI_SASIOUNITPAGE0_PAGEVERSION; | ||
299 | hdr.ExtPageLength = 0; | ||
300 | hdr.PageNumber = 0; | ||
301 | hdr.Reserved1 = 0; | ||
302 | hdr.Reserved2 = 0; | ||
303 | hdr.PageType = MPI_CONFIG_PAGETYPE_EXTENDED; | ||
304 | hdr.ExtPageType = MPI_CONFIG_EXTPAGETYPE_SAS_IO_UNIT; | ||
305 | |||
306 | cfg.cfghdr.ehdr = &hdr; | ||
307 | cfg.physAddr = -1; | ||
308 | cfg.pageAddr = 0; | ||
309 | cfg.action = MPI_CONFIG_ACTION_PAGE_HEADER; | ||
310 | cfg.dir = 0; /* read */ | ||
311 | cfg.timeout = 10; | ||
312 | |||
313 | error = mpt_config(ioc, &cfg); | ||
314 | if (error) | ||
315 | goto out; | ||
316 | if (!hdr.ExtPageLength) { | ||
317 | error = -ENXIO; | ||
318 | goto out; | ||
319 | } | ||
320 | |||
321 | buffer = pci_alloc_consistent(ioc->pcidev, hdr.ExtPageLength * 4, | ||
322 | &dma_handle); | ||
323 | if (!buffer) { | ||
324 | error = -ENOMEM; | ||
325 | goto out; | ||
326 | } | ||
327 | |||
328 | cfg.physAddr = dma_handle; | ||
329 | cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT; | ||
330 | |||
331 | error = mpt_config(ioc, &cfg); | ||
332 | if (error) | ||
333 | goto out_free_consistent; | ||
334 | |||
335 | port_info->num_phys = buffer->NumPhys; | ||
336 | port_info->phy_info = kcalloc(port_info->num_phys, | ||
337 | sizeof(struct mptsas_phyinfo),GFP_KERNEL); | ||
338 | if (!port_info->phy_info) { | ||
339 | error = -ENOMEM; | ||
340 | goto out_free_consistent; | ||
341 | } | ||
342 | |||
343 | for (i = 0; i < port_info->num_phys; i++) { | ||
344 | mptsas_print_phy_data(&buffer->PhyData[i]); | ||
345 | port_info->phy_info[i].phy_id = i; | ||
346 | port_info->phy_info[i].port_id = | ||
347 | buffer->PhyData[i].Port; | ||
348 | port_info->phy_info[i].negotiated_link_rate = | ||
349 | buffer->PhyData[i].NegotiatedLinkRate; | ||
350 | } | ||
351 | |||
352 | out_free_consistent: | ||
353 | pci_free_consistent(ioc->pcidev, hdr.ExtPageLength * 4, | ||
354 | buffer, dma_handle); | ||
355 | out: | ||
356 | return error; | ||
357 | } | ||
358 | |||
359 | static int | ||
360 | mptsas_sas_phy_pg0(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, | ||
361 | u32 form, u32 form_specific) | ||
362 | { | ||
363 | ConfigExtendedPageHeader_t hdr; | ||
364 | CONFIGPARMS cfg; | ||
365 | SasPhyPage0_t *buffer; | ||
366 | dma_addr_t dma_handle; | ||
367 | int error; | ||
368 | |||
369 | hdr.PageVersion = MPI_SASPHY0_PAGEVERSION; | ||
370 | hdr.ExtPageLength = 0; | ||
371 | hdr.PageNumber = 0; | ||
372 | hdr.Reserved1 = 0; | ||
373 | hdr.Reserved2 = 0; | ||
374 | hdr.PageType = MPI_CONFIG_PAGETYPE_EXTENDED; | ||
375 | hdr.ExtPageType = MPI_CONFIG_EXTPAGETYPE_SAS_PHY; | ||
376 | |||
377 | cfg.cfghdr.ehdr = &hdr; | ||
378 | cfg.dir = 0; /* read */ | ||
379 | cfg.timeout = 10; | ||
380 | |||
381 | /* Get Phy Pg 0 for each Phy. */ | ||
382 | cfg.physAddr = -1; | ||
383 | cfg.pageAddr = form + form_specific; | ||
384 | cfg.action = MPI_CONFIG_ACTION_PAGE_HEADER; | ||
385 | |||
386 | error = mpt_config(ioc, &cfg); | ||
387 | if (error) | ||
388 | goto out; | ||
389 | |||
390 | if (!hdr.ExtPageLength) { | ||
391 | error = -ENXIO; | ||
392 | goto out; | ||
393 | } | ||
394 | |||
395 | buffer = pci_alloc_consistent(ioc->pcidev, hdr.ExtPageLength * 4, | ||
396 | &dma_handle); | ||
397 | if (!buffer) { | ||
398 | error = -ENOMEM; | ||
399 | goto out; | ||
400 | } | ||
401 | |||
402 | cfg.physAddr = dma_handle; | ||
403 | cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT; | ||
404 | |||
405 | error = mpt_config(ioc, &cfg); | ||
406 | if (error) | ||
407 | goto out_free_consistent; | ||
408 | |||
409 | mptsas_print_phy_pg0(buffer); | ||
410 | |||
411 | phy_info->hw_link_rate = buffer->HwLinkRate; | ||
412 | phy_info->programmed_link_rate = buffer->ProgrammedLinkRate; | ||
413 | phy_info->identify.handle = le16_to_cpu(buffer->OwnerDevHandle); | ||
414 | phy_info->attached.handle = le16_to_cpu(buffer->AttachedDevHandle); | ||
415 | |||
416 | out_free_consistent: | ||
417 | pci_free_consistent(ioc->pcidev, hdr.ExtPageLength * 4, | ||
418 | buffer, dma_handle); | ||
419 | out: | ||
420 | return error; | ||
421 | } | ||
422 | |||
423 | static int | ||
424 | mptsas_sas_device_pg0(MPT_ADAPTER *ioc, struct mptsas_devinfo *device_info, | ||
425 | u32 form, u32 form_specific) | ||
426 | { | ||
427 | ConfigExtendedPageHeader_t hdr; | ||
428 | CONFIGPARMS cfg; | ||
429 | SasDevicePage0_t *buffer; | ||
430 | dma_addr_t dma_handle; | ||
431 | __le64 sas_address; | ||
432 | int error; | ||
433 | |||
434 | hdr.PageVersion = MPI_SASDEVICE0_PAGEVERSION; | ||
435 | hdr.ExtPageLength = 0; | ||
436 | hdr.PageNumber = 0; | ||
437 | hdr.Reserved1 = 0; | ||
438 | hdr.Reserved2 = 0; | ||
439 | hdr.PageType = MPI_CONFIG_PAGETYPE_EXTENDED; | ||
440 | hdr.ExtPageType = MPI_CONFIG_EXTPAGETYPE_SAS_DEVICE; | ||
441 | |||
442 | cfg.cfghdr.ehdr = &hdr; | ||
443 | cfg.pageAddr = form + form_specific; | ||
444 | cfg.physAddr = -1; | ||
445 | cfg.action = MPI_CONFIG_ACTION_PAGE_HEADER; | ||
446 | cfg.dir = 0; /* read */ | ||
447 | cfg.timeout = 10; | ||
448 | |||
449 | error = mpt_config(ioc, &cfg); | ||
450 | if (error) | ||
451 | goto out; | ||
452 | if (!hdr.ExtPageLength) { | ||
453 | error = -ENXIO; | ||
454 | goto out; | ||
455 | } | ||
456 | |||
457 | buffer = pci_alloc_consistent(ioc->pcidev, hdr.ExtPageLength * 4, | ||
458 | &dma_handle); | ||
459 | if (!buffer) { | ||
460 | error = -ENOMEM; | ||
461 | goto out; | ||
462 | } | ||
463 | |||
464 | cfg.physAddr = dma_handle; | ||
465 | cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT; | ||
466 | |||
467 | error = mpt_config(ioc, &cfg); | ||
468 | if (error) | ||
469 | goto out_free_consistent; | ||
470 | |||
471 | mptsas_print_device_pg0(buffer); | ||
472 | |||
473 | device_info->handle = le16_to_cpu(buffer->DevHandle); | ||
474 | device_info->phy_id = buffer->PhyNum; | ||
475 | device_info->port_id = buffer->PhysicalPort; | ||
476 | device_info->target = buffer->TargetID; | ||
477 | device_info->bus = buffer->Bus; | ||
478 | memcpy(&sas_address, &buffer->SASAddress, sizeof(__le64)); | ||
479 | device_info->sas_address = le64_to_cpu(sas_address); | ||
480 | device_info->device_info = | ||
481 | le32_to_cpu(buffer->DeviceInfo); | ||
482 | |||
483 | out_free_consistent: | ||
484 | pci_free_consistent(ioc->pcidev, hdr.ExtPageLength * 4, | ||
485 | buffer, dma_handle); | ||
486 | out: | ||
487 | return error; | ||
488 | } | ||
489 | |||
490 | static int | ||
491 | mptsas_sas_expander_pg0(MPT_ADAPTER *ioc, struct mptsas_portinfo *port_info, | ||
492 | u32 form, u32 form_specific) | ||
493 | { | ||
494 | ConfigExtendedPageHeader_t hdr; | ||
495 | CONFIGPARMS cfg; | ||
496 | SasExpanderPage0_t *buffer; | ||
497 | dma_addr_t dma_handle; | ||
498 | int error; | ||
499 | |||
500 | hdr.PageVersion = MPI_SASEXPANDER0_PAGEVERSION; | ||
501 | hdr.ExtPageLength = 0; | ||
502 | hdr.PageNumber = 0; | ||
503 | hdr.Reserved1 = 0; | ||
504 | hdr.Reserved2 = 0; | ||
505 | hdr.PageType = MPI_CONFIG_PAGETYPE_EXTENDED; | ||
506 | hdr.ExtPageType = MPI_CONFIG_EXTPAGETYPE_SAS_EXPANDER; | ||
507 | |||
508 | cfg.cfghdr.ehdr = &hdr; | ||
509 | cfg.physAddr = -1; | ||
510 | cfg.pageAddr = form + form_specific; | ||
511 | cfg.action = MPI_CONFIG_ACTION_PAGE_HEADER; | ||
512 | cfg.dir = 0; /* read */ | ||
513 | cfg.timeout = 10; | ||
514 | |||
515 | error = mpt_config(ioc, &cfg); | ||
516 | if (error) | ||
517 | goto out; | ||
518 | |||
519 | if (!hdr.ExtPageLength) { | ||
520 | error = -ENXIO; | ||
521 | goto out; | ||
522 | } | ||
523 | |||
524 | buffer = pci_alloc_consistent(ioc->pcidev, hdr.ExtPageLength * 4, | ||
525 | &dma_handle); | ||
526 | if (!buffer) { | ||
527 | error = -ENOMEM; | ||
528 | goto out; | ||
529 | } | ||
530 | |||
531 | cfg.physAddr = dma_handle; | ||
532 | cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT; | ||
533 | |||
534 | error = mpt_config(ioc, &cfg); | ||
535 | if (error) | ||
536 | goto out_free_consistent; | ||
537 | |||
538 | /* save config data */ | ||
539 | port_info->num_phys = buffer->NumPhys; | ||
540 | port_info->handle = le16_to_cpu(buffer->DevHandle); | ||
541 | port_info->phy_info = kcalloc(port_info->num_phys, | ||
542 | sizeof(struct mptsas_phyinfo),GFP_KERNEL); | ||
543 | if (!port_info->phy_info) { | ||
544 | error = -ENOMEM; | ||
545 | goto out_free_consistent; | ||
546 | } | ||
547 | |||
548 | out_free_consistent: | ||
549 | pci_free_consistent(ioc->pcidev, hdr.ExtPageLength * 4, | ||
550 | buffer, dma_handle); | ||
551 | out: | ||
552 | return error; | ||
553 | } | ||
554 | |||
555 | static int | ||
556 | mptsas_sas_expander_pg1(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, | ||
557 | u32 form, u32 form_specific) | ||
558 | { | ||
559 | ConfigExtendedPageHeader_t hdr; | ||
560 | CONFIGPARMS cfg; | ||
561 | SasExpanderPage1_t *buffer; | ||
562 | dma_addr_t dma_handle; | ||
563 | int error; | ||
564 | |||
565 | hdr.PageVersion = MPI_SASEXPANDER0_PAGEVERSION; | ||
566 | hdr.ExtPageLength = 0; | ||
567 | hdr.PageNumber = 1; | ||
568 | hdr.Reserved1 = 0; | ||
569 | hdr.Reserved2 = 0; | ||
570 | hdr.PageType = MPI_CONFIG_PAGETYPE_EXTENDED; | ||
571 | hdr.ExtPageType = MPI_CONFIG_EXTPAGETYPE_SAS_EXPANDER; | ||
572 | |||
573 | cfg.cfghdr.ehdr = &hdr; | ||
574 | cfg.physAddr = -1; | ||
575 | cfg.pageAddr = form + form_specific; | ||
576 | cfg.action = MPI_CONFIG_ACTION_PAGE_HEADER; | ||
577 | cfg.dir = 0; /* read */ | ||
578 | cfg.timeout = 10; | ||
579 | |||
580 | error = mpt_config(ioc, &cfg); | ||
581 | if (error) | ||
582 | goto out; | ||
583 | |||
584 | if (!hdr.ExtPageLength) { | ||
585 | error = -ENXIO; | ||
586 | goto out; | ||
587 | } | ||
588 | |||
589 | buffer = pci_alloc_consistent(ioc->pcidev, hdr.ExtPageLength * 4, | ||
590 | &dma_handle); | ||
591 | if (!buffer) { | ||
592 | error = -ENOMEM; | ||
593 | goto out; | ||
594 | } | ||
595 | |||
596 | cfg.physAddr = dma_handle; | ||
597 | cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT; | ||
598 | |||
599 | error = mpt_config(ioc, &cfg); | ||
600 | if (error) | ||
601 | goto out_free_consistent; | ||
602 | |||
603 | |||
604 | mptsas_print_expander_pg1(buffer); | ||
605 | |||
606 | /* save config data */ | ||
607 | phy_info->phy_id = buffer->Phy; | ||
608 | phy_info->port_id = buffer->PhysicalPort; | ||
609 | phy_info->negotiated_link_rate = buffer->NegotiatedLinkRate; | ||
610 | phy_info->programmed_link_rate = buffer->ProgrammedLinkRate; | ||
611 | phy_info->hw_link_rate = buffer->HwLinkRate; | ||
612 | phy_info->identify.handle = le16_to_cpu(buffer->OwnerDevHandle); | ||
613 | phy_info->attached.handle = le16_to_cpu(buffer->AttachedDevHandle); | ||
614 | |||
615 | |||
616 | out_free_consistent: | ||
617 | pci_free_consistent(ioc->pcidev, hdr.ExtPageLength * 4, | ||
618 | buffer, dma_handle); | ||
619 | out: | ||
620 | return error; | ||
621 | } | ||
622 | |||
623 | static void | ||
624 | mptsas_parse_device_info(struct sas_identify *identify, | ||
625 | struct mptsas_devinfo *device_info) | ||
626 | { | ||
627 | u16 protocols; | ||
628 | |||
629 | identify->sas_address = device_info->sas_address; | ||
630 | identify->phy_identifier = device_info->phy_id; | ||
631 | |||
632 | /* | ||
633 | * Fill in Phy Initiator Port Protocol. | ||
634 | * Bits 6:3, more than one bit can be set, fall through cases. | ||
635 | */ | ||
636 | protocols = device_info->device_info & 0x78; | ||
637 | identify->initiator_port_protocols = 0; | ||
638 | if (protocols & MPI_SAS_DEVICE_INFO_SSP_INITIATOR) | ||
639 | identify->initiator_port_protocols |= SAS_PROTOCOL_SSP; | ||
640 | if (protocols & MPI_SAS_DEVICE_INFO_STP_INITIATOR) | ||
641 | identify->initiator_port_protocols |= SAS_PROTOCOL_STP; | ||
642 | if (protocols & MPI_SAS_DEVICE_INFO_SMP_INITIATOR) | ||
643 | identify->initiator_port_protocols |= SAS_PROTOCOL_SMP; | ||
644 | if (protocols & MPI_SAS_DEVICE_INFO_SATA_HOST) | ||
645 | identify->initiator_port_protocols |= SAS_PROTOCOL_SATA; | ||
646 | |||
647 | /* | ||
648 | * Fill in Phy Target Port Protocol. | ||
649 | * Bits 10:7, more than one bit can be set, fall through cases. | ||
650 | */ | ||
651 | protocols = device_info->device_info & 0x780; | ||
652 | identify->target_port_protocols = 0; | ||
653 | if (protocols & MPI_SAS_DEVICE_INFO_SSP_TARGET) | ||
654 | identify->target_port_protocols |= SAS_PROTOCOL_SSP; | ||
655 | if (protocols & MPI_SAS_DEVICE_INFO_STP_TARGET) | ||
656 | identify->target_port_protocols |= SAS_PROTOCOL_STP; | ||
657 | if (protocols & MPI_SAS_DEVICE_INFO_SMP_TARGET) | ||
658 | identify->target_port_protocols |= SAS_PROTOCOL_SMP; | ||
659 | if (protocols & MPI_SAS_DEVICE_INFO_SATA_DEVICE) | ||
660 | identify->target_port_protocols |= SAS_PROTOCOL_SATA; | ||
661 | |||
662 | /* | ||
663 | * Fill in Attached device type. | ||
664 | */ | ||
665 | switch (device_info->device_info & | ||
666 | MPI_SAS_DEVICE_INFO_MASK_DEVICE_TYPE) { | ||
667 | case MPI_SAS_DEVICE_INFO_NO_DEVICE: | ||
668 | identify->device_type = SAS_PHY_UNUSED; | ||
669 | break; | ||
670 | case MPI_SAS_DEVICE_INFO_END_DEVICE: | ||
671 | identify->device_type = SAS_END_DEVICE; | ||
672 | break; | ||
673 | case MPI_SAS_DEVICE_INFO_EDGE_EXPANDER: | ||
674 | identify->device_type = SAS_EDGE_EXPANDER_DEVICE; | ||
675 | break; | ||
676 | case MPI_SAS_DEVICE_INFO_FANOUT_EXPANDER: | ||
677 | identify->device_type = SAS_FANOUT_EXPANDER_DEVICE; | ||
678 | break; | ||
679 | } | ||
680 | } | ||
681 | |||
682 | static int mptsas_probe_one_phy(struct device *dev, | ||
683 | struct mptsas_phyinfo *phy_info, int index) | ||
684 | { | ||
685 | struct sas_phy *port; | ||
686 | int error; | ||
687 | |||
688 | port = sas_phy_alloc(dev, index); | ||
689 | if (!port) | ||
690 | return -ENOMEM; | ||
691 | |||
692 | port->port_identifier = phy_info->port_id; | ||
693 | mptsas_parse_device_info(&port->identify, &phy_info->identify); | ||
694 | |||
695 | /* | ||
696 | * Set Negotiated link rate. | ||
697 | */ | ||
698 | switch (phy_info->negotiated_link_rate) { | ||
699 | case MPI_SAS_IOUNIT0_RATE_PHY_DISABLED: | ||
700 | port->negotiated_linkrate = SAS_PHY_DISABLED; | ||
701 | break; | ||
702 | case MPI_SAS_IOUNIT0_RATE_FAILED_SPEED_NEGOTIATION: | ||
703 | port->negotiated_linkrate = SAS_LINK_RATE_FAILED; | ||
704 | break; | ||
705 | case MPI_SAS_IOUNIT0_RATE_1_5: | ||
706 | port->negotiated_linkrate = SAS_LINK_RATE_1_5_GBPS; | ||
707 | break; | ||
708 | case MPI_SAS_IOUNIT0_RATE_3_0: | ||
709 | port->negotiated_linkrate = SAS_LINK_RATE_3_0_GBPS; | ||
710 | break; | ||
711 | case MPI_SAS_IOUNIT0_RATE_SATA_OOB_COMPLETE: | ||
712 | case MPI_SAS_IOUNIT0_RATE_UNKNOWN: | ||
713 | default: | ||
714 | port->negotiated_linkrate = SAS_LINK_RATE_UNKNOWN; | ||
715 | break; | ||
716 | } | ||
717 | |||
718 | /* | ||
719 | * Set Max hardware link rate. | ||
720 | */ | ||
721 | switch (phy_info->hw_link_rate & MPI_SAS_PHY0_PRATE_MAX_RATE_MASK) { | ||
722 | case MPI_SAS_PHY0_HWRATE_MAX_RATE_1_5: | ||
723 | port->maximum_linkrate_hw = SAS_LINK_RATE_1_5_GBPS; | ||
724 | break; | ||
725 | case MPI_SAS_PHY0_PRATE_MAX_RATE_3_0: | ||
726 | port->maximum_linkrate_hw = SAS_LINK_RATE_3_0_GBPS; | ||
727 | break; | ||
728 | default: | ||
729 | break; | ||
730 | } | ||
731 | |||
732 | /* | ||
733 | * Set Max programmed link rate. | ||
734 | */ | ||
735 | switch (phy_info->programmed_link_rate & | ||
736 | MPI_SAS_PHY0_PRATE_MAX_RATE_MASK) { | ||
737 | case MPI_SAS_PHY0_PRATE_MAX_RATE_1_5: | ||
738 | port->maximum_linkrate = SAS_LINK_RATE_1_5_GBPS; | ||
739 | break; | ||
740 | case MPI_SAS_PHY0_PRATE_MAX_RATE_3_0: | ||
741 | port->maximum_linkrate = SAS_LINK_RATE_3_0_GBPS; | ||
742 | break; | ||
743 | default: | ||
744 | break; | ||
745 | } | ||
746 | |||
747 | /* | ||
748 | * Set Min hardware link rate. | ||
749 | */ | ||
750 | switch (phy_info->hw_link_rate & MPI_SAS_PHY0_HWRATE_MIN_RATE_MASK) { | ||
751 | case MPI_SAS_PHY0_HWRATE_MIN_RATE_1_5: | ||
752 | port->minimum_linkrate_hw = SAS_LINK_RATE_1_5_GBPS; | ||
753 | break; | ||
754 | case MPI_SAS_PHY0_PRATE_MIN_RATE_3_0: | ||
755 | port->minimum_linkrate_hw = SAS_LINK_RATE_3_0_GBPS; | ||
756 | break; | ||
757 | default: | ||
758 | break; | ||
759 | } | ||
760 | |||
761 | /* | ||
762 | * Set Min programmed link rate. | ||
763 | */ | ||
764 | switch (phy_info->programmed_link_rate & | ||
765 | MPI_SAS_PHY0_PRATE_MIN_RATE_MASK) { | ||
766 | case MPI_SAS_PHY0_PRATE_MIN_RATE_1_5: | ||
767 | port->minimum_linkrate = SAS_LINK_RATE_1_5_GBPS; | ||
768 | break; | ||
769 | case MPI_SAS_PHY0_PRATE_MIN_RATE_3_0: | ||
770 | port->minimum_linkrate = SAS_LINK_RATE_3_0_GBPS; | ||
771 | break; | ||
772 | default: | ||
773 | break; | ||
774 | } | ||
775 | |||
776 | error = sas_phy_add(port); | ||
777 | if (error) { | ||
778 | sas_phy_free(port); | ||
779 | return error; | ||
780 | } | ||
781 | |||
782 | if (phy_info->attached.handle) { | ||
783 | struct sas_rphy *rphy; | ||
784 | |||
785 | rphy = sas_rphy_alloc(port); | ||
786 | if (!rphy) | ||
787 | return 0; /* non-fatal: an rphy can be added later */ | ||
788 | |||
789 | mptsas_parse_device_info(&rphy->identify, &phy_info->attached); | ||
790 | error = sas_rphy_add(rphy); | ||
791 | if (error) { | ||
792 | sas_rphy_free(rphy); | ||
793 | return error; | ||
794 | } | ||
795 | |||
796 | phy_info->rphy = rphy; | ||
797 | } | ||
798 | |||
799 | return 0; | ||
800 | } | ||
801 | |||
802 | static int | ||
803 | mptsas_probe_hba_phys(MPT_ADAPTER *ioc, int *index) | ||
804 | { | ||
805 | struct mptsas_portinfo *port_info; | ||
806 | u32 handle = 0xFFFF; | ||
807 | int error = -ENOMEM, i; | ||
808 | |||
809 | port_info = kmalloc(sizeof(*port_info), GFP_KERNEL); | ||
810 | if (!port_info) | ||
811 | goto out; | ||
812 | memset(port_info, 0, sizeof(*port_info)); | ||
813 | |||
814 | error = mptsas_sas_io_unit_pg0(ioc, port_info); | ||
815 | if (error) | ||
816 | goto out_free_port_info; | ||
817 | |||
818 | list_add_tail(&port_info->list, &ioc->sas_topology); | ||
819 | |||
820 | for (i = 0; i < port_info->num_phys; i++) { | ||
821 | mptsas_sas_phy_pg0(ioc, &port_info->phy_info[i], | ||
822 | (MPI_SAS_PHY_PGAD_FORM_PHY_NUMBER << | ||
823 | MPI_SAS_PHY_PGAD_FORM_SHIFT), i); | ||
824 | |||
825 | mptsas_sas_device_pg0(ioc, &port_info->phy_info[i].identify, | ||
826 | (MPI_SAS_DEVICE_PGAD_FORM_GET_NEXT_HANDLE << | ||
827 | MPI_SAS_DEVICE_PGAD_FORM_SHIFT), handle); | ||
828 | handle = port_info->phy_info[i].identify.handle; | ||
829 | |||
830 | if (port_info->phy_info[i].attached.handle) { | ||
831 | mptsas_sas_device_pg0(ioc, | ||
832 | &port_info->phy_info[i].attached, | ||
833 | (MPI_SAS_DEVICE_PGAD_FORM_HANDLE << | ||
834 | MPI_SAS_DEVICE_PGAD_FORM_SHIFT), | ||
835 | port_info->phy_info[i].attached.handle); | ||
836 | } | ||
837 | |||
838 | mptsas_probe_one_phy(&ioc->sh->shost_gendev, | ||
839 | &port_info->phy_info[i], *index); | ||
840 | (*index)++; | ||
841 | } | ||
842 | |||
843 | return 0; | ||
844 | |||
845 | out_free_port_info: | ||
846 | kfree(port_info); | ||
847 | out: | ||
848 | return error; | ||
849 | } | ||
850 | |||
851 | static int | ||
852 | mptsas_probe_expander_phys(MPT_ADAPTER *ioc, u32 *handle, int *index) | ||
853 | { | ||
854 | struct mptsas_portinfo *port_info, *p; | ||
855 | int error = -ENOMEM, i, j; | ||
856 | |||
857 | port_info = kmalloc(sizeof(*port_info), GFP_KERNEL); | ||
858 | if (!port_info) | ||
859 | goto out; | ||
860 | memset(port_info, 0, sizeof(*port_info)); | ||
861 | |||
862 | error = mptsas_sas_expander_pg0(ioc, port_info, | ||
863 | (MPI_SAS_EXPAND_PGAD_FORM_GET_NEXT_HANDLE << | ||
864 | MPI_SAS_EXPAND_PGAD_FORM_SHIFT), *handle); | ||
865 | if (error) | ||
866 | goto out_free_port_info; | ||
867 | |||
868 | *handle = port_info->handle; | ||
869 | |||
870 | list_add_tail(&port_info->list, &ioc->sas_topology); | ||
871 | for (i = 0; i < port_info->num_phys; i++) { | ||
872 | struct device *parent; | ||
873 | |||
874 | mptsas_sas_expander_pg1(ioc, &port_info->phy_info[i], | ||
875 | (MPI_SAS_EXPAND_PGAD_FORM_HANDLE_PHY_NUM << | ||
876 | MPI_SAS_EXPAND_PGAD_FORM_SHIFT), (i << 16) + *handle); | ||
877 | |||
878 | if (port_info->phy_info[i].identify.handle) { | ||
879 | mptsas_sas_device_pg0(ioc, | ||
880 | &port_info->phy_info[i].identify, | ||
881 | (MPI_SAS_DEVICE_PGAD_FORM_HANDLE << | ||
882 | MPI_SAS_DEVICE_PGAD_FORM_SHIFT), | ||
883 | port_info->phy_info[i].identify.handle); | ||
884 | } | ||
885 | |||
886 | if (port_info->phy_info[i].attached.handle) { | ||
887 | mptsas_sas_device_pg0(ioc, | ||
888 | &port_info->phy_info[i].attached, | ||
889 | (MPI_SAS_DEVICE_PGAD_FORM_HANDLE << | ||
890 | MPI_SAS_DEVICE_PGAD_FORM_SHIFT), | ||
891 | port_info->phy_info[i].attached.handle); | ||
892 | } | ||
893 | |||
894 | /* | ||
895 | * If we find a parent port handle this expander is | ||
896 | * attached to another expander, else it hangs of the | ||
897 | * HBA phys. | ||
898 | */ | ||
899 | parent = &ioc->sh->shost_gendev; | ||
900 | list_for_each_entry(p, &ioc->sas_topology, list) { | ||
901 | for (j = 0; j < p->num_phys; j++) { | ||
902 | if (port_info->phy_info[i].identify.handle == | ||
903 | p->phy_info[j].attached.handle) | ||
904 | parent = &p->phy_info[j].rphy->dev; | ||
905 | } | ||
906 | } | ||
907 | |||
908 | mptsas_probe_one_phy(parent, &port_info->phy_info[i], *index); | ||
909 | (*index)++; | ||
910 | } | ||
911 | |||
912 | return 0; | ||
913 | |||
914 | out_free_port_info: | ||
915 | kfree(port_info); | ||
916 | out: | ||
917 | return error; | ||
918 | } | ||
919 | |||
920 | static void | ||
921 | mptsas_scan_sas_topology(MPT_ADAPTER *ioc) | ||
922 | { | ||
923 | u32 handle = 0xFFFF; | ||
924 | int index = 0; | ||
925 | |||
926 | mptsas_probe_hba_phys(ioc, &index); | ||
927 | while (!mptsas_probe_expander_phys(ioc, &handle, &index)) | ||
928 | ; | ||
929 | } | ||
930 | |||
931 | static int | ||
932 | mptsas_probe(struct pci_dev *pdev, const struct pci_device_id *id) | ||
933 | { | ||
934 | struct Scsi_Host *sh; | ||
935 | MPT_SCSI_HOST *hd; | ||
936 | MPT_ADAPTER *ioc; | ||
937 | unsigned long flags; | ||
938 | int sz, ii; | ||
939 | int numSGE = 0; | ||
940 | int scale; | ||
941 | int ioc_cap; | ||
942 | u8 *mem; | ||
943 | int error=0; | ||
944 | int r; | ||
945 | |||
946 | r = mpt_attach(pdev,id); | ||
947 | if (r) | ||
948 | return r; | ||
949 | |||
950 | ioc = pci_get_drvdata(pdev); | ||
951 | ioc->DoneCtx = mptsasDoneCtx; | ||
952 | ioc->TaskCtx = mptsasTaskCtx; | ||
953 | ioc->InternalCtx = mptsasInternalCtx; | ||
954 | |||
955 | /* Added sanity check on readiness of the MPT adapter. | ||
956 | */ | ||
957 | if (ioc->last_state != MPI_IOC_STATE_OPERATIONAL) { | ||
958 | printk(MYIOC_s_WARN_FMT | ||
959 | "Skipping because it's not operational!\n", | ||
960 | ioc->name); | ||
961 | return -ENODEV; | ||
962 | } | ||
963 | |||
964 | if (!ioc->active) { | ||
965 | printk(MYIOC_s_WARN_FMT "Skipping because it's disabled!\n", | ||
966 | ioc->name); | ||
967 | return -ENODEV; | ||
968 | } | ||
969 | |||
970 | /* Sanity check - ensure at least 1 port is INITIATOR capable | ||
971 | */ | ||
972 | ioc_cap = 0; | ||
973 | for (ii = 0; ii < ioc->facts.NumberOfPorts; ii++) { | ||
974 | if (ioc->pfacts[ii].ProtocolFlags & | ||
975 | MPI_PORTFACTS_PROTOCOL_INITIATOR) | ||
976 | ioc_cap++; | ||
977 | } | ||
978 | |||
979 | if (!ioc_cap) { | ||
980 | printk(MYIOC_s_WARN_FMT | ||
981 | "Skipping ioc=%p because SCSI Initiator mode " | ||
982 | "is NOT enabled!\n", ioc->name, ioc); | ||
983 | return 0; | ||
984 | } | ||
985 | |||
986 | sh = scsi_host_alloc(&mptsas_driver_template, sizeof(MPT_SCSI_HOST)); | ||
987 | if (!sh) { | ||
988 | printk(MYIOC_s_WARN_FMT | ||
989 | "Unable to register controller with SCSI subsystem\n", | ||
990 | ioc->name); | ||
991 | return -1; | ||
992 | } | ||
993 | |||
994 | spin_lock_irqsave(&ioc->FreeQlock, flags); | ||
995 | |||
996 | /* Attach the SCSI Host to the IOC structure | ||
997 | */ | ||
998 | ioc->sh = sh; | ||
999 | |||
1000 | sh->io_port = 0; | ||
1001 | sh->n_io_port = 0; | ||
1002 | sh->irq = 0; | ||
1003 | |||
1004 | /* set 16 byte cdb's */ | ||
1005 | sh->max_cmd_len = 16; | ||
1006 | |||
1007 | sh->max_id = ioc->pfacts->MaxDevices + 1; | ||
1008 | |||
1009 | sh->transportt = mptsas_transport_template; | ||
1010 | |||
1011 | sh->max_lun = MPT_LAST_LUN + 1; | ||
1012 | sh->max_channel = 0; | ||
1013 | sh->this_id = ioc->pfacts[0].PortSCSIID; | ||
1014 | |||
1015 | /* Required entry. | ||
1016 | */ | ||
1017 | sh->unique_id = ioc->id; | ||
1018 | |||
1019 | INIT_LIST_HEAD(&ioc->sas_topology); | ||
1020 | |||
1021 | /* Verify that we won't exceed the maximum | ||
1022 | * number of chain buffers | ||
1023 | * We can optimize: ZZ = req_sz/sizeof(SGE) | ||
1024 | * For 32bit SGE's: | ||
1025 | * numSGE = 1 + (ZZ-1)*(maxChain -1) + ZZ | ||
1026 | * + (req_sz - 64)/sizeof(SGE) | ||
1027 | * A slightly different algorithm is required for | ||
1028 | * 64bit SGEs. | ||
1029 | */ | ||
1030 | scale = ioc->req_sz/(sizeof(dma_addr_t) + sizeof(u32)); | ||
1031 | if (sizeof(dma_addr_t) == sizeof(u64)) { | ||
1032 | numSGE = (scale - 1) * | ||
1033 | (ioc->facts.MaxChainDepth-1) + scale + | ||
1034 | (ioc->req_sz - 60) / (sizeof(dma_addr_t) + | ||
1035 | sizeof(u32)); | ||
1036 | } else { | ||
1037 | numSGE = 1 + (scale - 1) * | ||
1038 | (ioc->facts.MaxChainDepth-1) + scale + | ||
1039 | (ioc->req_sz - 64) / (sizeof(dma_addr_t) + | ||
1040 | sizeof(u32)); | ||
1041 | } | ||
1042 | |||
1043 | if (numSGE < sh->sg_tablesize) { | ||
1044 | /* Reset this value */ | ||
1045 | dprintk((MYIOC_s_INFO_FMT | ||
1046 | "Resetting sg_tablesize to %d from %d\n", | ||
1047 | ioc->name, numSGE, sh->sg_tablesize)); | ||
1048 | sh->sg_tablesize = numSGE; | ||
1049 | } | ||
1050 | |||
1051 | spin_unlock_irqrestore(&ioc->FreeQlock, flags); | ||
1052 | |||
1053 | hd = (MPT_SCSI_HOST *) sh->hostdata; | ||
1054 | hd->ioc = ioc; | ||
1055 | |||
1056 | /* SCSI needs scsi_cmnd lookup table! | ||
1057 | * (with size equal to req_depth*PtrSz!) | ||
1058 | */ | ||
1059 | sz = ioc->req_depth * sizeof(void *); | ||
1060 | mem = kmalloc(sz, GFP_ATOMIC); | ||
1061 | if (mem == NULL) { | ||
1062 | error = -ENOMEM; | ||
1063 | goto mptsas_probe_failed; | ||
1064 | } | ||
1065 | |||
1066 | memset(mem, 0, sz); | ||
1067 | hd->ScsiLookup = (struct scsi_cmnd **) mem; | ||
1068 | |||
1069 | dprintk((MYIOC_s_INFO_FMT "ScsiLookup @ %p, sz=%d\n", | ||
1070 | ioc->name, hd->ScsiLookup, sz)); | ||
1071 | |||
1072 | /* Allocate memory for the device structures. | ||
1073 | * A non-Null pointer at an offset | ||
1074 | * indicates a device exists. | ||
1075 | * max_id = 1 + maximum id (hosts.h) | ||
1076 | */ | ||
1077 | sz = sh->max_id * sizeof(void *); | ||
1078 | mem = kmalloc(sz, GFP_ATOMIC); | ||
1079 | if (mem == NULL) { | ||
1080 | error = -ENOMEM; | ||
1081 | goto mptsas_probe_failed; | ||
1082 | } | ||
1083 | |||
1084 | memset(mem, 0, sz); | ||
1085 | hd->Targets = (VirtDevice **) mem; | ||
1086 | |||
1087 | dprintk((KERN_INFO | ||
1088 | " Targets @ %p, sz=%d\n", hd->Targets, sz)); | ||
1089 | |||
1090 | /* Clear the TM flags | ||
1091 | */ | ||
1092 | hd->tmPending = 0; | ||
1093 | hd->tmState = TM_STATE_NONE; | ||
1094 | hd->resetPending = 0; | ||
1095 | hd->abortSCpnt = NULL; | ||
1096 | |||
1097 | /* Clear the pointer used to store | ||
1098 | * single-threaded commands, i.e., those | ||
1099 | * issued during a bus scan, dv and | ||
1100 | * configuration pages. | ||
1101 | */ | ||
1102 | hd->cmdPtr = NULL; | ||
1103 | |||
1104 | /* Initialize this SCSI Hosts' timers | ||
1105 | * To use, set the timer expires field | ||
1106 | * and add_timer | ||
1107 | */ | ||
1108 | init_timer(&hd->timer); | ||
1109 | hd->timer.data = (unsigned long) hd; | ||
1110 | hd->timer.function = mptscsih_timer_expired; | ||
1111 | |||
1112 | hd->mpt_pq_filter = mpt_pq_filter; | ||
1113 | ioc->sas_data.ptClear = mpt_pt_clear; | ||
1114 | |||
1115 | if (ioc->sas_data.ptClear==1) { | ||
1116 | mptbase_sas_persist_operation( | ||
1117 | ioc, MPI_SAS_OP_CLEAR_ALL_PERSISTENT); | ||
1118 | } | ||
1119 | |||
1120 | ddvprintk((MYIOC_s_INFO_FMT | ||
1121 | "mpt_pq_filter %x mpt_pq_filter %x\n", | ||
1122 | ioc->name, | ||
1123 | mpt_pq_filter, | ||
1124 | mpt_pq_filter)); | ||
1125 | |||
1126 | init_waitqueue_head(&hd->scandv_waitq); | ||
1127 | hd->scandv_wait_done = 0; | ||
1128 | hd->last_queue_full = 0; | ||
1129 | |||
1130 | error = scsi_add_host(sh, &ioc->pcidev->dev); | ||
1131 | if (error) { | ||
1132 | dprintk((KERN_ERR MYNAM | ||
1133 | "scsi_add_host failed\n")); | ||
1134 | goto mptsas_probe_failed; | ||
1135 | } | ||
1136 | |||
1137 | mptsas_scan_sas_topology(ioc); | ||
1138 | |||
1139 | return 0; | ||
1140 | |||
1141 | mptsas_probe_failed: | ||
1142 | |||
1143 | mptscsih_remove(pdev); | ||
1144 | return error; | ||
1145 | } | ||
1146 | |||
1147 | static void __devexit mptsas_remove(struct pci_dev *pdev) | ||
1148 | { | ||
1149 | MPT_ADAPTER *ioc = pci_get_drvdata(pdev); | ||
1150 | struct mptsas_portinfo *p, *n; | ||
1151 | |||
1152 | sas_remove_host(ioc->sh); | ||
1153 | |||
1154 | list_for_each_entry_safe(p, n, &ioc->sas_topology, list) { | ||
1155 | list_del(&p->list); | ||
1156 | kfree(p); | ||
1157 | } | ||
1158 | |||
1159 | mptscsih_remove(pdev); | ||
1160 | } | ||
1161 | |||
1162 | static struct pci_device_id mptsas_pci_table[] = { | ||
1163 | { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_SAS1064, | ||
1164 | PCI_ANY_ID, PCI_ANY_ID }, | ||
1165 | { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_SAS1066, | ||
1166 | PCI_ANY_ID, PCI_ANY_ID }, | ||
1167 | { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_SAS1068, | ||
1168 | PCI_ANY_ID, PCI_ANY_ID }, | ||
1169 | { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_SAS1064E, | ||
1170 | PCI_ANY_ID, PCI_ANY_ID }, | ||
1171 | { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_SAS1066E, | ||
1172 | PCI_ANY_ID, PCI_ANY_ID }, | ||
1173 | { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_SAS1068E, | ||
1174 | PCI_ANY_ID, PCI_ANY_ID }, | ||
1175 | {0} /* Terminating entry */ | ||
1176 | }; | ||
1177 | MODULE_DEVICE_TABLE(pci, mptsas_pci_table); | ||
1178 | |||
1179 | |||
1180 | static struct pci_driver mptsas_driver = { | ||
1181 | .name = "mptsas", | ||
1182 | .id_table = mptsas_pci_table, | ||
1183 | .probe = mptsas_probe, | ||
1184 | .remove = __devexit_p(mptsas_remove), | ||
1185 | .shutdown = mptscsih_shutdown, | ||
1186 | #ifdef CONFIG_PM | ||
1187 | .suspend = mptscsih_suspend, | ||
1188 | .resume = mptscsih_resume, | ||
1189 | #endif | ||
1190 | }; | ||
1191 | |||
1192 | static int __init | ||
1193 | mptsas_init(void) | ||
1194 | { | ||
1195 | show_mptmod_ver(my_NAME, my_VERSION); | ||
1196 | |||
1197 | mptsas_transport_template = | ||
1198 | sas_attach_transport(&mptsas_transport_functions); | ||
1199 | if (!mptsas_transport_template) | ||
1200 | return -ENODEV; | ||
1201 | |||
1202 | mptsasDoneCtx = mpt_register(mptscsih_io_done, MPTSAS_DRIVER); | ||
1203 | mptsasTaskCtx = mpt_register(mptscsih_taskmgmt_complete, MPTSAS_DRIVER); | ||
1204 | mptsasInternalCtx = | ||
1205 | mpt_register(mptscsih_scandv_complete, MPTSAS_DRIVER); | ||
1206 | |||
1207 | if (mpt_event_register(mptsasDoneCtx, mptscsih_event_process) == 0) { | ||
1208 | devtprintk((KERN_INFO MYNAM | ||
1209 | ": Registered for IOC event notifications\n")); | ||
1210 | } | ||
1211 | |||
1212 | if (mpt_reset_register(mptsasDoneCtx, mptscsih_ioc_reset) == 0) { | ||
1213 | dprintk((KERN_INFO MYNAM | ||
1214 | ": Registered for IOC reset notifications\n")); | ||
1215 | } | ||
1216 | |||
1217 | return pci_register_driver(&mptsas_driver); | ||
1218 | } | ||
1219 | |||
1220 | static void __exit | ||
1221 | mptsas_exit(void) | ||
1222 | { | ||
1223 | pci_unregister_driver(&mptsas_driver); | ||
1224 | sas_release_transport(mptsas_transport_template); | ||
1225 | |||
1226 | mpt_reset_deregister(mptsasDoneCtx); | ||
1227 | mpt_event_deregister(mptsasDoneCtx); | ||
1228 | |||
1229 | mpt_deregister(mptsasInternalCtx); | ||
1230 | mpt_deregister(mptsasTaskCtx); | ||
1231 | mpt_deregister(mptsasDoneCtx); | ||
1232 | } | ||
1233 | |||
1234 | module_init(mptsas_init); | ||
1235 | module_exit(mptsas_exit); | ||
diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c index 4a003dc5fde8..5cb07eb224d7 100644 --- a/drivers/message/fusion/mptscsih.c +++ b/drivers/message/fusion/mptscsih.c | |||
@@ -62,6 +62,7 @@ | |||
62 | #include <scsi/scsi_device.h> | 62 | #include <scsi/scsi_device.h> |
63 | #include <scsi/scsi_host.h> | 63 | #include <scsi/scsi_host.h> |
64 | #include <scsi/scsi_tcq.h> | 64 | #include <scsi/scsi_tcq.h> |
65 | #include <scsi/scsi_dbg.h> | ||
65 | 66 | ||
66 | #include "mptbase.h" | 67 | #include "mptbase.h" |
67 | #include "mptscsih.h" | 68 | #include "mptscsih.h" |
@@ -93,8 +94,9 @@ typedef struct _BIG_SENSE_BUF { | |||
93 | 94 | ||
94 | #define MPT_ICFLAG_BUF_CAP 0x01 /* ReadBuffer Read Capacity format */ | 95 | #define MPT_ICFLAG_BUF_CAP 0x01 /* ReadBuffer Read Capacity format */ |
95 | #define MPT_ICFLAG_ECHO 0x02 /* ReadBuffer Echo buffer format */ | 96 | #define MPT_ICFLAG_ECHO 0x02 /* ReadBuffer Echo buffer format */ |
96 | #define MPT_ICFLAG_PHYS_DISK 0x04 /* Any SCSI IO but do Phys Disk Format */ | 97 | #define MPT_ICFLAG_EBOS 0x04 /* ReadBuffer Echo buffer has EBOS */ |
97 | #define MPT_ICFLAG_TAGGED_CMD 0x08 /* Do tagged IO */ | 98 | #define MPT_ICFLAG_PHYS_DISK 0x08 /* Any SCSI IO but do Phys Disk Format */ |
99 | #define MPT_ICFLAG_TAGGED_CMD 0x10 /* Do tagged IO */ | ||
98 | #define MPT_ICFLAG_DID_RESET 0x20 /* Bus Reset occurred with this command */ | 100 | #define MPT_ICFLAG_DID_RESET 0x20 /* Bus Reset occurred with this command */ |
99 | #define MPT_ICFLAG_RESERVED 0x40 /* Reserved has been issued */ | 101 | #define MPT_ICFLAG_RESERVED 0x40 /* Reserved has been issued */ |
100 | 102 | ||
@@ -159,6 +161,8 @@ int mptscsih_scandv_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR | |||
159 | static int mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *iocmd); | 161 | static int mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *iocmd); |
160 | static int mptscsih_synchronize_cache(MPT_SCSI_HOST *hd, int portnum); | 162 | static int mptscsih_synchronize_cache(MPT_SCSI_HOST *hd, int portnum); |
161 | 163 | ||
164 | static struct work_struct mptscsih_persistTask; | ||
165 | |||
162 | #ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION | 166 | #ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION |
163 | static int mptscsih_do_raid(MPT_SCSI_HOST *hd, u8 action, INTERNAL_CMD *io); | 167 | static int mptscsih_do_raid(MPT_SCSI_HOST *hd, u8 action, INTERNAL_CMD *io); |
164 | static void mptscsih_domainValidation(void *hd); | 168 | static void mptscsih_domainValidation(void *hd); |
@@ -167,6 +171,7 @@ static void mptscsih_qas_check(MPT_SCSI_HOST *hd, int id); | |||
167 | static int mptscsih_doDv(MPT_SCSI_HOST *hd, int channel, int target); | 171 | static int mptscsih_doDv(MPT_SCSI_HOST *hd, int channel, int target); |
168 | static void mptscsih_dv_parms(MPT_SCSI_HOST *hd, DVPARAMETERS *dv,void *pPage); | 172 | static void mptscsih_dv_parms(MPT_SCSI_HOST *hd, DVPARAMETERS *dv,void *pPage); |
169 | static void mptscsih_fillbuf(char *buffer, int size, int index, int width); | 173 | static void mptscsih_fillbuf(char *buffer, int size, int index, int width); |
174 | static void mptscsih_set_dvflags_raid(MPT_SCSI_HOST *hd, int id); | ||
170 | #endif | 175 | #endif |
171 | 176 | ||
172 | void mptscsih_remove(struct pci_dev *); | 177 | void mptscsih_remove(struct pci_dev *); |
@@ -606,11 +611,24 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr) | |||
606 | xfer_cnt = le32_to_cpu(pScsiReply->TransferCount); | 611 | xfer_cnt = le32_to_cpu(pScsiReply->TransferCount); |
607 | sc->resid = sc->request_bufflen - xfer_cnt; | 612 | sc->resid = sc->request_bufflen - xfer_cnt; |
608 | 613 | ||
614 | /* | ||
615 | * if we get a data underrun indication, yet no data was | ||
616 | * transferred and the SCSI status indicates that the | ||
617 | * command was never started, change the data underrun | ||
618 | * to success | ||
619 | */ | ||
620 | if (status == MPI_IOCSTATUS_SCSI_DATA_UNDERRUN && xfer_cnt == 0 && | ||
621 | (scsi_status == MPI_SCSI_STATUS_BUSY || | ||
622 | scsi_status == MPI_SCSI_STATUS_RESERVATION_CONFLICT || | ||
623 | scsi_status == MPI_SCSI_STATUS_TASK_SET_FULL)) { | ||
624 | status = MPI_IOCSTATUS_SUCCESS; | ||
625 | } | ||
626 | |||
609 | dreplyprintk((KERN_NOTICE "Reply ha=%d id=%d lun=%d:\n" | 627 | dreplyprintk((KERN_NOTICE "Reply ha=%d id=%d lun=%d:\n" |
610 | "IOCStatus=%04xh SCSIState=%02xh SCSIStatus=%02xh\n" | 628 | "IOCStatus=%04xh SCSIState=%02xh SCSIStatus=%02xh\n" |
611 | "resid=%d bufflen=%d xfer_cnt=%d\n", | 629 | "resid=%d bufflen=%d xfer_cnt=%d\n", |
612 | ioc->id, pScsiReq->TargetID, pScsiReq->LUN[1], | 630 | ioc->id, pScsiReq->TargetID, pScsiReq->LUN[1], |
613 | status, scsi_state, scsi_status, sc->resid, | 631 | status, scsi_state, scsi_status, sc->resid, |
614 | sc->request_bufflen, xfer_cnt)); | 632 | sc->request_bufflen, xfer_cnt)); |
615 | 633 | ||
616 | if (scsi_state & MPI_SCSI_STATE_AUTOSENSE_VALID) | 634 | if (scsi_state & MPI_SCSI_STATE_AUTOSENSE_VALID) |
@@ -619,8 +637,11 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr) | |||
619 | /* | 637 | /* |
620 | * Look for + dump FCP ResponseInfo[]! | 638 | * Look for + dump FCP ResponseInfo[]! |
621 | */ | 639 | */ |
622 | if (scsi_state & MPI_SCSI_STATE_RESPONSE_INFO_VALID) { | 640 | if (scsi_state & MPI_SCSI_STATE_RESPONSE_INFO_VALID && |
623 | printk(KERN_NOTICE " FCP_ResponseInfo=%08xh\n", | 641 | pScsiReply->ResponseInfo) { |
642 | printk(KERN_NOTICE "ha=%d id=%d lun=%d: " | ||
643 | "FCP_ResponseInfo=%08xh\n", | ||
644 | ioc->id, pScsiReq->TargetID, pScsiReq->LUN[1], | ||
624 | le32_to_cpu(pScsiReply->ResponseInfo)); | 645 | le32_to_cpu(pScsiReply->ResponseInfo)); |
625 | } | 646 | } |
626 | 647 | ||
@@ -661,23 +682,13 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr) | |||
661 | break; | 682 | break; |
662 | 683 | ||
663 | case MPI_IOCSTATUS_SCSI_RESIDUAL_MISMATCH: /* 0x0049 */ | 684 | case MPI_IOCSTATUS_SCSI_RESIDUAL_MISMATCH: /* 0x0049 */ |
664 | if ( xfer_cnt >= sc->underflow ) { | 685 | sc->resid = sc->request_bufflen - xfer_cnt; |
665 | /* Sufficient data transfer occurred */ | 686 | if((xfer_cnt==0)||(sc->underflow > xfer_cnt)) |
687 | sc->result=DID_SOFT_ERROR << 16; | ||
688 | else /* Sufficient data transfer occurred */ | ||
666 | sc->result = (DID_OK << 16) | scsi_status; | 689 | sc->result = (DID_OK << 16) | scsi_status; |
667 | } else if ( xfer_cnt == 0 ) { | 690 | dreplyprintk((KERN_NOTICE |
668 | /* A CRC Error causes this condition; retry */ | 691 | "RESIDUAL_MISMATCH: result=%x on id=%d\n", sc->result, sc->device->id)); |
669 | sc->result = (DRIVER_SENSE << 24) | (DID_OK << 16) | | ||
670 | (CHECK_CONDITION << 1); | ||
671 | sc->sense_buffer[0] = 0x70; | ||
672 | sc->sense_buffer[2] = NO_SENSE; | ||
673 | sc->sense_buffer[12] = 0; | ||
674 | sc->sense_buffer[13] = 0; | ||
675 | } else { | ||
676 | sc->result = DID_SOFT_ERROR << 16; | ||
677 | } | ||
678 | dreplyprintk((KERN_NOTICE | ||
679 | "RESIDUAL_MISMATCH: result=%x on id=%d\n", | ||
680 | sc->result, sc->device->id)); | ||
681 | break; | 692 | break; |
682 | 693 | ||
683 | case MPI_IOCSTATUS_SCSI_DATA_UNDERRUN: /* 0x0045 */ | 694 | case MPI_IOCSTATUS_SCSI_DATA_UNDERRUN: /* 0x0045 */ |
@@ -692,7 +703,10 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr) | |||
692 | ; | 703 | ; |
693 | } else { | 704 | } else { |
694 | if (xfer_cnt < sc->underflow) { | 705 | if (xfer_cnt < sc->underflow) { |
695 | sc->result = DID_SOFT_ERROR << 16; | 706 | if (scsi_status == SAM_STAT_BUSY) |
707 | sc->result = SAM_STAT_BUSY; | ||
708 | else | ||
709 | sc->result = DID_SOFT_ERROR << 16; | ||
696 | } | 710 | } |
697 | if (scsi_state & (MPI_SCSI_STATE_AUTOSENSE_FAILED | MPI_SCSI_STATE_NO_SCSI_STATUS)) { | 711 | if (scsi_state & (MPI_SCSI_STATE_AUTOSENSE_FAILED | MPI_SCSI_STATE_NO_SCSI_STATUS)) { |
698 | /* What to do? | 712 | /* What to do? |
@@ -717,8 +731,10 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr) | |||
717 | 731 | ||
718 | case MPI_IOCSTATUS_SCSI_RECOVERED_ERROR: /* 0x0040 */ | 732 | case MPI_IOCSTATUS_SCSI_RECOVERED_ERROR: /* 0x0040 */ |
719 | case MPI_IOCSTATUS_SUCCESS: /* 0x0000 */ | 733 | case MPI_IOCSTATUS_SUCCESS: /* 0x0000 */ |
720 | scsi_status = pScsiReply->SCSIStatus; | 734 | if (scsi_status == MPI_SCSI_STATUS_BUSY) |
721 | sc->result = (DID_OK << 16) | scsi_status; | 735 | sc->result = (DID_BUS_BUSY << 16) | scsi_status; |
736 | else | ||
737 | sc->result = (DID_OK << 16) | scsi_status; | ||
722 | if (scsi_state == 0) { | 738 | if (scsi_state == 0) { |
723 | ; | 739 | ; |
724 | } else if (scsi_state & MPI_SCSI_STATE_AUTOSENSE_VALID) { | 740 | } else if (scsi_state & MPI_SCSI_STATE_AUTOSENSE_VALID) { |
@@ -890,12 +906,13 @@ mptscsih_search_running_cmds(MPT_SCSI_HOST *hd, uint target, uint lun) | |||
890 | SCSIIORequest_t *mf = NULL; | 906 | SCSIIORequest_t *mf = NULL; |
891 | int ii; | 907 | int ii; |
892 | int max = hd->ioc->req_depth; | 908 | int max = hd->ioc->req_depth; |
909 | struct scsi_cmnd *sc; | ||
893 | 910 | ||
894 | dsprintk((KERN_INFO MYNAM ": search_running target %d lun %d max %d\n", | 911 | dsprintk((KERN_INFO MYNAM ": search_running target %d lun %d max %d\n", |
895 | target, lun, max)); | 912 | target, lun, max)); |
896 | 913 | ||
897 | for (ii=0; ii < max; ii++) { | 914 | for (ii=0; ii < max; ii++) { |
898 | if (hd->ScsiLookup[ii] != NULL) { | 915 | if ((sc = hd->ScsiLookup[ii]) != NULL) { |
899 | 916 | ||
900 | mf = (SCSIIORequest_t *)MPT_INDEX_2_MFPTR(hd->ioc, ii); | 917 | mf = (SCSIIORequest_t *)MPT_INDEX_2_MFPTR(hd->ioc, ii); |
901 | 918 | ||
@@ -910,9 +927,22 @@ mptscsih_search_running_cmds(MPT_SCSI_HOST *hd, uint target, uint lun) | |||
910 | hd->ScsiLookup[ii] = NULL; | 927 | hd->ScsiLookup[ii] = NULL; |
911 | mptscsih_freeChainBuffers(hd->ioc, ii); | 928 | mptscsih_freeChainBuffers(hd->ioc, ii); |
912 | mpt_free_msg_frame(hd->ioc, (MPT_FRAME_HDR *)mf); | 929 | mpt_free_msg_frame(hd->ioc, (MPT_FRAME_HDR *)mf); |
930 | if (sc->use_sg) { | ||
931 | pci_unmap_sg(hd->ioc->pcidev, | ||
932 | (struct scatterlist *) sc->request_buffer, | ||
933 | sc->use_sg, | ||
934 | sc->sc_data_direction); | ||
935 | } else if (sc->request_bufflen) { | ||
936 | pci_unmap_single(hd->ioc->pcidev, | ||
937 | sc->SCp.dma_handle, | ||
938 | sc->request_bufflen, | ||
939 | sc->sc_data_direction); | ||
940 | } | ||
941 | sc->host_scribble = NULL; | ||
942 | sc->result = DID_NO_CONNECT << 16; | ||
943 | sc->scsi_done(sc); | ||
913 | } | 944 | } |
914 | } | 945 | } |
915 | |||
916 | return; | 946 | return; |
917 | } | 947 | } |
918 | 948 | ||
@@ -967,8 +997,10 @@ mptscsih_remove(struct pci_dev *pdev) | |||
967 | unsigned long flags; | 997 | unsigned long flags; |
968 | int sz1; | 998 | int sz1; |
969 | 999 | ||
970 | if(!host) | 1000 | if(!host) { |
1001 | mpt_detach(pdev); | ||
971 | return; | 1002 | return; |
1003 | } | ||
972 | 1004 | ||
973 | scsi_remove_host(host); | 1005 | scsi_remove_host(host); |
974 | 1006 | ||
@@ -1256,8 +1288,7 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) | |||
1256 | MPT_SCSI_HOST *hd; | 1288 | MPT_SCSI_HOST *hd; |
1257 | MPT_FRAME_HDR *mf; | 1289 | MPT_FRAME_HDR *mf; |
1258 | SCSIIORequest_t *pScsiReq; | 1290 | SCSIIORequest_t *pScsiReq; |
1259 | VirtDevice *pTarget; | 1291 | VirtDevice *pTarget = SCpnt->device->hostdata; |
1260 | int target; | ||
1261 | int lun; | 1292 | int lun; |
1262 | u32 datalen; | 1293 | u32 datalen; |
1263 | u32 scsictl; | 1294 | u32 scsictl; |
@@ -1267,12 +1298,9 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) | |||
1267 | int ii; | 1298 | int ii; |
1268 | 1299 | ||
1269 | hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata; | 1300 | hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata; |
1270 | target = SCpnt->device->id; | ||
1271 | lun = SCpnt->device->lun; | 1301 | lun = SCpnt->device->lun; |
1272 | SCpnt->scsi_done = done; | 1302 | SCpnt->scsi_done = done; |
1273 | 1303 | ||
1274 | pTarget = hd->Targets[target]; | ||
1275 | |||
1276 | dmfprintk((MYIOC_s_INFO_FMT "qcmd: SCpnt=%p, done()=%p\n", | 1304 | dmfprintk((MYIOC_s_INFO_FMT "qcmd: SCpnt=%p, done()=%p\n", |
1277 | (hd && hd->ioc) ? hd->ioc->name : "ioc?", SCpnt, done)); | 1305 | (hd && hd->ioc) ? hd->ioc->name : "ioc?", SCpnt, done)); |
1278 | 1306 | ||
@@ -1315,7 +1343,7 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) | |||
1315 | /* Default to untagged. Once a target structure has been allocated, | 1343 | /* Default to untagged. Once a target structure has been allocated, |
1316 | * use the Inquiry data to determine if device supports tagged. | 1344 | * use the Inquiry data to determine if device supports tagged. |
1317 | */ | 1345 | */ |
1318 | if ( pTarget | 1346 | if (pTarget |
1319 | && (pTarget->tflags & MPT_TARGET_FLAGS_Q_YES) | 1347 | && (pTarget->tflags & MPT_TARGET_FLAGS_Q_YES) |
1320 | && (SCpnt->device->tagged_supported)) { | 1348 | && (SCpnt->device->tagged_supported)) { |
1321 | scsictl = scsidir | MPI_SCSIIO_CONTROL_SIMPLEQ; | 1349 | scsictl = scsidir | MPI_SCSIIO_CONTROL_SIMPLEQ; |
@@ -1325,8 +1353,8 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) | |||
1325 | 1353 | ||
1326 | /* Use the above information to set up the message frame | 1354 | /* Use the above information to set up the message frame |
1327 | */ | 1355 | */ |
1328 | pScsiReq->TargetID = (u8) target; | 1356 | pScsiReq->TargetID = (u8) pTarget->target_id; |
1329 | pScsiReq->Bus = (u8) SCpnt->device->channel; | 1357 | pScsiReq->Bus = pTarget->bus_id; |
1330 | pScsiReq->ChainOffset = 0; | 1358 | pScsiReq->ChainOffset = 0; |
1331 | pScsiReq->Function = MPI_FUNCTION_SCSI_IO_REQUEST; | 1359 | pScsiReq->Function = MPI_FUNCTION_SCSI_IO_REQUEST; |
1332 | pScsiReq->CDBLength = SCpnt->cmd_len; | 1360 | pScsiReq->CDBLength = SCpnt->cmd_len; |
@@ -1378,7 +1406,7 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) | |||
1378 | 1406 | ||
1379 | #ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION | 1407 | #ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION |
1380 | if (hd->ioc->bus_type == SCSI) { | 1408 | if (hd->ioc->bus_type == SCSI) { |
1381 | int dvStatus = hd->ioc->spi_data.dvStatus[target]; | 1409 | int dvStatus = hd->ioc->spi_data.dvStatus[pTarget->target_id]; |
1382 | int issueCmd = 1; | 1410 | int issueCmd = 1; |
1383 | 1411 | ||
1384 | if (dvStatus || hd->ioc->spi_data.forceDv) { | 1412 | if (dvStatus || hd->ioc->spi_data.forceDv) { |
@@ -1426,6 +1454,7 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) | |||
1426 | return 0; | 1454 | return 0; |
1427 | 1455 | ||
1428 | fail: | 1456 | fail: |
1457 | hd->ScsiLookup[my_idx] = NULL; | ||
1429 | mptscsih_freeChainBuffers(hd->ioc, my_idx); | 1458 | mptscsih_freeChainBuffers(hd->ioc, my_idx); |
1430 | mpt_free_msg_frame(hd->ioc, mf); | 1459 | mpt_free_msg_frame(hd->ioc, mf); |
1431 | return SCSI_MLQUEUE_HOST_BUSY; | 1460 | return SCSI_MLQUEUE_HOST_BUSY; |
@@ -1713,24 +1742,23 @@ mptscsih_abort(struct scsi_cmnd * SCpnt) | |||
1713 | MPT_FRAME_HDR *mf; | 1742 | MPT_FRAME_HDR *mf; |
1714 | u32 ctx2abort; | 1743 | u32 ctx2abort; |
1715 | int scpnt_idx; | 1744 | int scpnt_idx; |
1745 | int retval; | ||
1716 | 1746 | ||
1717 | /* If we can't locate our host adapter structure, return FAILED status. | 1747 | /* If we can't locate our host adapter structure, return FAILED status. |
1718 | */ | 1748 | */ |
1719 | if ((hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata) == NULL) { | 1749 | if ((hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata) == NULL) { |
1720 | SCpnt->result = DID_RESET << 16; | 1750 | SCpnt->result = DID_RESET << 16; |
1721 | SCpnt->scsi_done(SCpnt); | 1751 | SCpnt->scsi_done(SCpnt); |
1722 | dfailprintk((KERN_WARNING MYNAM ": mptscsih_abort: " | 1752 | dfailprintk((KERN_INFO MYNAM ": mptscsih_abort: " |
1723 | "Can't locate host! (sc=%p)\n", | 1753 | "Can't locate host! (sc=%p)\n", |
1724 | SCpnt)); | 1754 | SCpnt)); |
1725 | return FAILED; | 1755 | return FAILED; |
1726 | } | 1756 | } |
1727 | 1757 | ||
1728 | ioc = hd->ioc; | 1758 | ioc = hd->ioc; |
1729 | if (hd->resetPending) | 1759 | if (hd->resetPending) { |
1730 | return FAILED; | 1760 | return FAILED; |
1731 | 1761 | } | |
1732 | printk(KERN_WARNING MYNAM ": %s: >> Attempting task abort! (sc=%p)\n", | ||
1733 | hd->ioc->name, SCpnt); | ||
1734 | 1762 | ||
1735 | if (hd->timeouts < -1) | 1763 | if (hd->timeouts < -1) |
1736 | hd->timeouts++; | 1764 | hd->timeouts++; |
@@ -1738,16 +1766,20 @@ mptscsih_abort(struct scsi_cmnd * SCpnt) | |||
1738 | /* Find this command | 1766 | /* Find this command |
1739 | */ | 1767 | */ |
1740 | if ((scpnt_idx = SCPNT_TO_LOOKUP_IDX(SCpnt)) < 0) { | 1768 | if ((scpnt_idx = SCPNT_TO_LOOKUP_IDX(SCpnt)) < 0) { |
1741 | /* Cmd not found in ScsiLookup. | 1769 | /* Cmd not found in ScsiLookup. |
1742 | * Do OS callback. | 1770 | * Do OS callback. |
1743 | */ | 1771 | */ |
1744 | SCpnt->result = DID_RESET << 16; | 1772 | SCpnt->result = DID_RESET << 16; |
1745 | dtmprintk((KERN_WARNING MYNAM ": %s: mptscsih_abort: " | 1773 | dtmprintk((KERN_INFO MYNAM ": %s: mptscsih_abort: " |
1746 | "Command not in the active list! (sc=%p)\n", | 1774 | "Command not in the active list! (sc=%p)\n", |
1747 | hd->ioc->name, SCpnt)); | 1775 | hd->ioc->name, SCpnt)); |
1748 | return SUCCESS; | 1776 | return SUCCESS; |
1749 | } | 1777 | } |
1750 | 1778 | ||
1779 | printk(KERN_WARNING MYNAM ": %s: attempting task abort! (sc=%p)\n", | ||
1780 | hd->ioc->name, SCpnt); | ||
1781 | scsi_print_command(SCpnt); | ||
1782 | |||
1751 | /* Most important! Set TaskMsgContext to SCpnt's MsgContext! | 1783 | /* Most important! Set TaskMsgContext to SCpnt's MsgContext! |
1752 | * (the IO to be ABORT'd) | 1784 | * (the IO to be ABORT'd) |
1753 | * | 1785 | * |
@@ -1760,38 +1792,22 @@ mptscsih_abort(struct scsi_cmnd * SCpnt) | |||
1760 | 1792 | ||
1761 | hd->abortSCpnt = SCpnt; | 1793 | hd->abortSCpnt = SCpnt; |
1762 | 1794 | ||
1763 | if (mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_ABORT_TASK, | 1795 | retval = mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_ABORT_TASK, |
1764 | SCpnt->device->channel, SCpnt->device->id, SCpnt->device->lun, | 1796 | SCpnt->device->channel, SCpnt->device->id, SCpnt->device->lun, |
1765 | ctx2abort, 2 /* 2 second timeout */) | 1797 | ctx2abort, 2 /* 2 second timeout */); |
1766 | < 0) { | ||
1767 | 1798 | ||
1768 | /* The TM request failed and the subsequent FW-reload failed! | 1799 | printk (KERN_WARNING MYNAM ": %s: task abort: %s (sc=%p)\n", |
1769 | * Fatal error case. | 1800 | hd->ioc->name, |
1770 | */ | 1801 | ((retval == 0) ? "SUCCESS" : "FAILED" ), SCpnt); |
1771 | printk(MYIOC_s_WARN_FMT "Error issuing abort task! (sc=%p)\n", | ||
1772 | hd->ioc->name, SCpnt); | ||
1773 | 1802 | ||
1774 | /* We must clear our pending flag before clearing our state. | 1803 | if (retval == 0) |
1775 | */ | 1804 | return SUCCESS; |
1805 | |||
1806 | if(retval != FAILED ) { | ||
1776 | hd->tmPending = 0; | 1807 | hd->tmPending = 0; |
1777 | hd->tmState = TM_STATE_NONE; | 1808 | hd->tmState = TM_STATE_NONE; |
1778 | |||
1779 | /* Unmap the DMA buffers, if any. */ | ||
1780 | if (SCpnt->use_sg) { | ||
1781 | pci_unmap_sg(ioc->pcidev, (struct scatterlist *) SCpnt->request_buffer, | ||
1782 | SCpnt->use_sg, SCpnt->sc_data_direction); | ||
1783 | } else if (SCpnt->request_bufflen) { | ||
1784 | pci_unmap_single(ioc->pcidev, SCpnt->SCp.dma_handle, | ||
1785 | SCpnt->request_bufflen, SCpnt->sc_data_direction); | ||
1786 | } | ||
1787 | hd->ScsiLookup[scpnt_idx] = NULL; | ||
1788 | SCpnt->result = DID_RESET << 16; | ||
1789 | SCpnt->scsi_done(SCpnt); /* Issue the command callback */ | ||
1790 | mptscsih_freeChainBuffers(ioc, scpnt_idx); | ||
1791 | mpt_free_msg_frame(ioc, mf); | ||
1792 | return FAILED; | ||
1793 | } | 1809 | } |
1794 | return SUCCESS; | 1810 | return FAILED; |
1795 | } | 1811 | } |
1796 | 1812 | ||
1797 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | 1813 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ |
@@ -1807,11 +1823,12 @@ int | |||
1807 | mptscsih_dev_reset(struct scsi_cmnd * SCpnt) | 1823 | mptscsih_dev_reset(struct scsi_cmnd * SCpnt) |
1808 | { | 1824 | { |
1809 | MPT_SCSI_HOST *hd; | 1825 | MPT_SCSI_HOST *hd; |
1826 | int retval; | ||
1810 | 1827 | ||
1811 | /* If we can't locate our host adapter structure, return FAILED status. | 1828 | /* If we can't locate our host adapter structure, return FAILED status. |
1812 | */ | 1829 | */ |
1813 | if ((hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata) == NULL){ | 1830 | if ((hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata) == NULL){ |
1814 | dtmprintk((KERN_WARNING MYNAM ": mptscsih_dev_reset: " | 1831 | dtmprintk((KERN_INFO MYNAM ": mptscsih_dev_reset: " |
1815 | "Can't locate host! (sc=%p)\n", | 1832 | "Can't locate host! (sc=%p)\n", |
1816 | SCpnt)); | 1833 | SCpnt)); |
1817 | return FAILED; | 1834 | return FAILED; |
@@ -1820,24 +1837,26 @@ mptscsih_dev_reset(struct scsi_cmnd * SCpnt) | |||
1820 | if (hd->resetPending) | 1837 | if (hd->resetPending) |
1821 | return FAILED; | 1838 | return FAILED; |
1822 | 1839 | ||
1823 | printk(KERN_WARNING MYNAM ": %s: >> Attempting target reset! (sc=%p)\n", | 1840 | printk(KERN_WARNING MYNAM ": %s: attempting target reset! (sc=%p)\n", |
1824 | hd->ioc->name, SCpnt); | 1841 | hd->ioc->name, SCpnt); |
1842 | scsi_print_command(SCpnt); | ||
1825 | 1843 | ||
1826 | if (mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_TARGET_RESET, | 1844 | retval = mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_TARGET_RESET, |
1827 | SCpnt->device->channel, SCpnt->device->id, | 1845 | SCpnt->device->channel, SCpnt->device->id, |
1828 | 0, 0, 5 /* 5 second timeout */) | 1846 | 0, 0, 5 /* 5 second timeout */); |
1829 | < 0){ | 1847 | |
1830 | /* The TM request failed and the subsequent FW-reload failed! | 1848 | printk (KERN_WARNING MYNAM ": %s: target reset: %s (sc=%p)\n", |
1831 | * Fatal error case. | 1849 | hd->ioc->name, |
1832 | */ | 1850 | ((retval == 0) ? "SUCCESS" : "FAILED" ), SCpnt); |
1833 | printk(MYIOC_s_WARN_FMT "Error processing TaskMgmt request (sc=%p)\n", | 1851 | |
1834 | hd->ioc->name, SCpnt); | 1852 | if (retval == 0) |
1853 | return SUCCESS; | ||
1854 | |||
1855 | if(retval != FAILED ) { | ||
1835 | hd->tmPending = 0; | 1856 | hd->tmPending = 0; |
1836 | hd->tmState = TM_STATE_NONE; | 1857 | hd->tmState = TM_STATE_NONE; |
1837 | return FAILED; | ||
1838 | } | 1858 | } |
1839 | 1859 | return FAILED; | |
1840 | return SUCCESS; | ||
1841 | } | 1860 | } |
1842 | 1861 | ||
1843 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | 1862 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ |
@@ -1853,41 +1872,39 @@ int | |||
1853 | mptscsih_bus_reset(struct scsi_cmnd * SCpnt) | 1872 | mptscsih_bus_reset(struct scsi_cmnd * SCpnt) |
1854 | { | 1873 | { |
1855 | MPT_SCSI_HOST *hd; | 1874 | MPT_SCSI_HOST *hd; |
1856 | spinlock_t *host_lock = SCpnt->device->host->host_lock; | 1875 | int retval; |
1857 | 1876 | ||
1858 | /* If we can't locate our host adapter structure, return FAILED status. | 1877 | /* If we can't locate our host adapter structure, return FAILED status. |
1859 | */ | 1878 | */ |
1860 | if ((hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata) == NULL){ | 1879 | if ((hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata) == NULL){ |
1861 | dtmprintk((KERN_WARNING MYNAM ": mptscsih_bus_reset: " | 1880 | dtmprintk((KERN_INFO MYNAM ": mptscsih_bus_reset: " |
1862 | "Can't locate host! (sc=%p)\n", | 1881 | "Can't locate host! (sc=%p)\n", |
1863 | SCpnt ) ); | 1882 | SCpnt ) ); |
1864 | return FAILED; | 1883 | return FAILED; |
1865 | } | 1884 | } |
1866 | 1885 | ||
1867 | printk(KERN_WARNING MYNAM ": %s: >> Attempting bus reset! (sc=%p)\n", | 1886 | printk(KERN_WARNING MYNAM ": %s: attempting bus reset! (sc=%p)\n", |
1868 | hd->ioc->name, SCpnt); | 1887 | hd->ioc->name, SCpnt); |
1888 | scsi_print_command(SCpnt); | ||
1869 | 1889 | ||
1870 | if (hd->timeouts < -1) | 1890 | if (hd->timeouts < -1) |
1871 | hd->timeouts++; | 1891 | hd->timeouts++; |
1872 | 1892 | ||
1873 | /* We are now ready to execute the task management request. */ | 1893 | retval = mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_RESET_BUS, |
1874 | if (mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_RESET_BUS, | 1894 | SCpnt->device->channel, 0, 0, 0, 5 /* 5 second timeout */); |
1875 | SCpnt->device->channel, 0, 0, 0, 5 /* 5 second timeout */) | ||
1876 | < 0){ | ||
1877 | 1895 | ||
1878 | /* The TM request failed and the subsequent FW-reload failed! | 1896 | printk (KERN_WARNING MYNAM ": %s: bus reset: %s (sc=%p)\n", |
1879 | * Fatal error case. | 1897 | hd->ioc->name, |
1880 | */ | 1898 | ((retval == 0) ? "SUCCESS" : "FAILED" ), SCpnt); |
1881 | printk(MYIOC_s_WARN_FMT | 1899 | |
1882 | "Error processing TaskMgmt request (sc=%p)\n", | 1900 | if (retval == 0) |
1883 | hd->ioc->name, SCpnt); | 1901 | return SUCCESS; |
1902 | |||
1903 | if(retval != FAILED ) { | ||
1884 | hd->tmPending = 0; | 1904 | hd->tmPending = 0; |
1885 | hd->tmState = TM_STATE_NONE; | 1905 | hd->tmState = TM_STATE_NONE; |
1886 | spin_lock_irq(host_lock); | ||
1887 | return FAILED; | ||
1888 | } | 1906 | } |
1889 | 1907 | return FAILED; | |
1890 | return SUCCESS; | ||
1891 | } | 1908 | } |
1892 | 1909 | ||
1893 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | 1910 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ |
@@ -2169,7 +2186,7 @@ mptscsih_slave_alloc(struct scsi_device *device) | |||
2169 | vdev->raidVolume = 0; | 2186 | vdev->raidVolume = 0; |
2170 | hd->Targets[device->id] = vdev; | 2187 | hd->Targets[device->id] = vdev; |
2171 | if (hd->ioc->bus_type == SCSI) { | 2188 | if (hd->ioc->bus_type == SCSI) { |
2172 | if (hd->ioc->spi_data.isRaid & (1 << device->id)) { | 2189 | if (hd->ioc->raid_data.isRaid & (1 << device->id)) { |
2173 | vdev->raidVolume = 1; | 2190 | vdev->raidVolume = 1; |
2174 | ddvtprintk((KERN_INFO | 2191 | ddvtprintk((KERN_INFO |
2175 | "RAID Volume @ id %d\n", device->id)); | 2192 | "RAID Volume @ id %d\n", device->id)); |
@@ -2180,22 +2197,7 @@ mptscsih_slave_alloc(struct scsi_device *device) | |||
2180 | 2197 | ||
2181 | out: | 2198 | out: |
2182 | vdev->num_luns++; | 2199 | vdev->num_luns++; |
2183 | return 0; | 2200 | device->hostdata = vdev; |
2184 | } | ||
2185 | |||
2186 | static int | ||
2187 | mptscsih_is_raid_volume(MPT_SCSI_HOST *hd, uint id) | ||
2188 | { | ||
2189 | int i; | ||
2190 | |||
2191 | if (!hd->ioc->spi_data.isRaid || !hd->ioc->spi_data.pIocPg3) | ||
2192 | return 0; | ||
2193 | |||
2194 | for (i = 0; i < hd->ioc->spi_data.pIocPg3->NumPhysDisks; i++) { | ||
2195 | if (id == hd->ioc->spi_data.pIocPg3->PhysDisk[i].PhysDiskID) | ||
2196 | return 1; | ||
2197 | } | ||
2198 | |||
2199 | return 0; | 2201 | return 0; |
2200 | } | 2202 | } |
2201 | 2203 | ||
@@ -2226,7 +2228,7 @@ mptscsih_slave_destroy(struct scsi_device *device) | |||
2226 | hd->Targets[target] = NULL; | 2228 | hd->Targets[target] = NULL; |
2227 | 2229 | ||
2228 | if (hd->ioc->bus_type == SCSI) { | 2230 | if (hd->ioc->bus_type == SCSI) { |
2229 | if (mptscsih_is_raid_volume(hd, target)) { | 2231 | if (mptscsih_is_phys_disk(hd->ioc, target)) { |
2230 | hd->ioc->spi_data.forceDv |= MPT_SCSICFG_RELOAD_IOC_PG3; | 2232 | hd->ioc->spi_data.forceDv |= MPT_SCSICFG_RELOAD_IOC_PG3; |
2231 | } else { | 2233 | } else { |
2232 | hd->ioc->spi_data.dvStatus[target] = | 2234 | hd->ioc->spi_data.dvStatus[target] = |
@@ -2439,6 +2441,7 @@ mptscsih_ioc_reset(MPT_ADAPTER *ioc, int reset_phase) | |||
2439 | { | 2441 | { |
2440 | MPT_SCSI_HOST *hd; | 2442 | MPT_SCSI_HOST *hd; |
2441 | unsigned long flags; | 2443 | unsigned long flags; |
2444 | int ii; | ||
2442 | 2445 | ||
2443 | dtmprintk((KERN_WARNING MYNAM | 2446 | dtmprintk((KERN_WARNING MYNAM |
2444 | ": IOC %s_reset routed to SCSI host driver!\n", | 2447 | ": IOC %s_reset routed to SCSI host driver!\n", |
@@ -2496,11 +2499,8 @@ mptscsih_ioc_reset(MPT_ADAPTER *ioc, int reset_phase) | |||
2496 | 2499 | ||
2497 | /* ScsiLookup initialization | 2500 | /* ScsiLookup initialization |
2498 | */ | 2501 | */ |
2499 | { | 2502 | for (ii=0; ii < hd->ioc->req_depth; ii++) |
2500 | int ii; | 2503 | hd->ScsiLookup[ii] = NULL; |
2501 | for (ii=0; ii < hd->ioc->req_depth; ii++) | ||
2502 | hd->ScsiLookup[ii] = NULL; | ||
2503 | } | ||
2504 | 2504 | ||
2505 | /* 2. Chain Buffer initialization | 2505 | /* 2. Chain Buffer initialization |
2506 | */ | 2506 | */ |
@@ -2549,6 +2549,16 @@ mptscsih_ioc_reset(MPT_ADAPTER *ioc, int reset_phase) | |||
2549 | } | 2549 | } |
2550 | 2550 | ||
2551 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | 2551 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ |
2552 | /* work queue thread to clear the persitency table */ | ||
2553 | static void | ||
2554 | mptscsih_sas_persist_clear_table(void * arg) | ||
2555 | { | ||
2556 | MPT_ADAPTER *ioc = (MPT_ADAPTER *)arg; | ||
2557 | |||
2558 | mptbase_sas_persist_operation(ioc, MPI_SAS_OP_CLEAR_NOT_PRESENT); | ||
2559 | } | ||
2560 | |||
2561 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | ||
2552 | int | 2562 | int |
2553 | mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply) | 2563 | mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply) |
2554 | { | 2564 | { |
@@ -2558,18 +2568,18 @@ mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply) | |||
2558 | devtprintk((MYIOC_s_INFO_FMT "MPT event (=%02Xh) routed to SCSI host driver!\n", | 2568 | devtprintk((MYIOC_s_INFO_FMT "MPT event (=%02Xh) routed to SCSI host driver!\n", |
2559 | ioc->name, event)); | 2569 | ioc->name, event)); |
2560 | 2570 | ||
2571 | if (ioc->sh == NULL || | ||
2572 | ((hd = (MPT_SCSI_HOST *)ioc->sh->hostdata) == NULL)) | ||
2573 | return 1; | ||
2574 | |||
2561 | switch (event) { | 2575 | switch (event) { |
2562 | case MPI_EVENT_UNIT_ATTENTION: /* 03 */ | 2576 | case MPI_EVENT_UNIT_ATTENTION: /* 03 */ |
2563 | /* FIXME! */ | 2577 | /* FIXME! */ |
2564 | break; | 2578 | break; |
2565 | case MPI_EVENT_IOC_BUS_RESET: /* 04 */ | 2579 | case MPI_EVENT_IOC_BUS_RESET: /* 04 */ |
2566 | case MPI_EVENT_EXT_BUS_RESET: /* 05 */ | 2580 | case MPI_EVENT_EXT_BUS_RESET: /* 05 */ |
2567 | hd = NULL; | 2581 | if (hd && (ioc->bus_type == SCSI) && (hd->soft_resets < -1)) |
2568 | if (ioc->sh) { | 2582 | hd->soft_resets++; |
2569 | hd = (MPT_SCSI_HOST *) ioc->sh->hostdata; | ||
2570 | if (hd && (ioc->bus_type == SCSI) && (hd->soft_resets < -1)) | ||
2571 | hd->soft_resets++; | ||
2572 | } | ||
2573 | break; | 2583 | break; |
2574 | case MPI_EVENT_LOGOUT: /* 09 */ | 2584 | case MPI_EVENT_LOGOUT: /* 09 */ |
2575 | /* FIXME! */ | 2585 | /* FIXME! */ |
@@ -2588,69 +2598,24 @@ mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply) | |||
2588 | break; | 2598 | break; |
2589 | 2599 | ||
2590 | case MPI_EVENT_INTEGRATED_RAID: /* 0B */ | 2600 | case MPI_EVENT_INTEGRATED_RAID: /* 0B */ |
2601 | { | ||
2602 | pMpiEventDataRaid_t pRaidEventData = | ||
2603 | (pMpiEventDataRaid_t) pEvReply->Data; | ||
2591 | #ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION | 2604 | #ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION |
2592 | /* negoNvram set to 0 if DV enabled and to USE_NVRAM if | 2605 | /* Domain Validation Needed */ |
2593 | * if DV disabled. Need to check for target mode. | 2606 | if (ioc->bus_type == SCSI && |
2594 | */ | 2607 | pRaidEventData->ReasonCode == |
2595 | hd = NULL; | 2608 | MPI_EVENT_RAID_RC_DOMAIN_VAL_NEEDED) |
2596 | if (ioc->sh) | 2609 | mptscsih_set_dvflags_raid(hd, pRaidEventData->PhysDiskNum); |
2597 | hd = (MPT_SCSI_HOST *) ioc->sh->hostdata; | ||
2598 | |||
2599 | if (hd && (ioc->bus_type == SCSI) && (hd->negoNvram == 0)) { | ||
2600 | ScsiCfgData *pSpi; | ||
2601 | Ioc3PhysDisk_t *pPDisk; | ||
2602 | int numPDisk; | ||
2603 | u8 reason; | ||
2604 | u8 physDiskNum; | ||
2605 | |||
2606 | reason = (le32_to_cpu(pEvReply->Data[0]) & 0x00FF0000) >> 16; | ||
2607 | if (reason == MPI_EVENT_RAID_RC_DOMAIN_VAL_NEEDED) { | ||
2608 | /* New or replaced disk. | ||
2609 | * Set DV flag and schedule DV. | ||
2610 | */ | ||
2611 | pSpi = &ioc->spi_data; | ||
2612 | physDiskNum = (le32_to_cpu(pEvReply->Data[0]) & 0xFF000000) >> 24; | ||
2613 | ddvtprintk(("DV requested for phys disk id %d\n", physDiskNum)); | ||
2614 | if (pSpi->pIocPg3) { | ||
2615 | pPDisk = pSpi->pIocPg3->PhysDisk; | ||
2616 | numPDisk =pSpi->pIocPg3->NumPhysDisks; | ||
2617 | |||
2618 | while (numPDisk) { | ||
2619 | if (physDiskNum == pPDisk->PhysDiskNum) { | ||
2620 | pSpi->dvStatus[pPDisk->PhysDiskID] = (MPT_SCSICFG_NEED_DV | MPT_SCSICFG_DV_NOT_DONE); | ||
2621 | pSpi->forceDv = MPT_SCSICFG_NEED_DV; | ||
2622 | ddvtprintk(("NEED_DV set for phys disk id %d\n", pPDisk->PhysDiskID)); | ||
2623 | break; | ||
2624 | } | ||
2625 | pPDisk++; | ||
2626 | numPDisk--; | ||
2627 | } | ||
2628 | |||
2629 | if (numPDisk == 0) { | ||
2630 | /* The physical disk that needs DV was not found | ||
2631 | * in the stored IOC Page 3. The driver must reload | ||
2632 | * this page. DV routine will set the NEED_DV flag for | ||
2633 | * all phys disks that have DV_NOT_DONE set. | ||
2634 | */ | ||
2635 | pSpi->forceDv = MPT_SCSICFG_NEED_DV | MPT_SCSICFG_RELOAD_IOC_PG3; | ||
2636 | ddvtprintk(("phys disk %d not found. Setting reload IOC Pg3 Flag\n", physDiskNum)); | ||
2637 | } | ||
2638 | } | ||
2639 | } | ||
2640 | } | ||
2641 | #endif | 2610 | #endif |
2611 | break; | ||
2612 | } | ||
2642 | 2613 | ||
2643 | #if defined(MPT_DEBUG_DV) || defined(MPT_DEBUG_DV_TINY) | 2614 | /* Persistent table is full. */ |
2644 | printk("Raid Event RF: "); | 2615 | case MPI_EVENT_PERSISTENT_TABLE_FULL: |
2645 | { | 2616 | INIT_WORK(&mptscsih_persistTask, |
2646 | u32 *m = (u32 *)pEvReply; | 2617 | mptscsih_sas_persist_clear_table,(void *)ioc); |
2647 | int ii; | 2618 | schedule_work(&mptscsih_persistTask); |
2648 | int n = (int)pEvReply->MsgLength; | ||
2649 | for (ii=6; ii < n; ii++) | ||
2650 | printk(" %08x", le32_to_cpu(m[ii])); | ||
2651 | printk("\n"); | ||
2652 | } | ||
2653 | #endif | ||
2654 | break; | 2619 | break; |
2655 | 2620 | ||
2656 | case MPI_EVENT_NONE: /* 00 */ | 2621 | case MPI_EVENT_NONE: /* 00 */ |
@@ -2687,7 +2652,7 @@ mptscsih_initTarget(MPT_SCSI_HOST *hd, int bus_id, int target_id, u8 lun, char * | |||
2687 | { | 2652 | { |
2688 | int indexed_lun, lun_index; | 2653 | int indexed_lun, lun_index; |
2689 | VirtDevice *vdev; | 2654 | VirtDevice *vdev; |
2690 | ScsiCfgData *pSpi; | 2655 | SpiCfgData *pSpi; |
2691 | char data_56; | 2656 | char data_56; |
2692 | 2657 | ||
2693 | dinitprintk((MYIOC_s_INFO_FMT "initTarget bus=%d id=%d lun=%d hd=%p\n", | 2658 | dinitprintk((MYIOC_s_INFO_FMT "initTarget bus=%d id=%d lun=%d hd=%p\n", |
@@ -2794,7 +2759,7 @@ mptscsih_initTarget(MPT_SCSI_HOST *hd, int bus_id, int target_id, u8 lun, char * | |||
2794 | static void | 2759 | static void |
2795 | mptscsih_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtDevice *target, char byte56) | 2760 | mptscsih_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtDevice *target, char byte56) |
2796 | { | 2761 | { |
2797 | ScsiCfgData *pspi_data = &hd->ioc->spi_data; | 2762 | SpiCfgData *pspi_data = &hd->ioc->spi_data; |
2798 | int id = (int) target->target_id; | 2763 | int id = (int) target->target_id; |
2799 | int nvram; | 2764 | int nvram; |
2800 | VirtDevice *vdev; | 2765 | VirtDevice *vdev; |
@@ -2973,11 +2938,13 @@ mptscsih_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtDevice *target, char byte56) | |||
2973 | static void | 2938 | static void |
2974 | mptscsih_set_dvflags(MPT_SCSI_HOST *hd, SCSIIORequest_t *pReq) | 2939 | mptscsih_set_dvflags(MPT_SCSI_HOST *hd, SCSIIORequest_t *pReq) |
2975 | { | 2940 | { |
2941 | MPT_ADAPTER *ioc = hd->ioc; | ||
2976 | u8 cmd; | 2942 | u8 cmd; |
2977 | ScsiCfgData *pSpi; | 2943 | SpiCfgData *pSpi; |
2978 | 2944 | ||
2979 | ddvtprintk((" set_dvflags: id=%d lun=%d negoNvram=%x cmd=%x\n", | 2945 | ddvtprintk((MYIOC_s_NOTE_FMT |
2980 | pReq->TargetID, pReq->LUN[1], hd->negoNvram, pReq->CDB[0])); | 2946 | " set_dvflags: id=%d lun=%d negoNvram=%x cmd=%x\n", |
2947 | hd->ioc->name, pReq->TargetID, pReq->LUN[1], hd->negoNvram, pReq->CDB[0])); | ||
2981 | 2948 | ||
2982 | if ((pReq->LUN[1] != 0) || (hd->negoNvram != 0)) | 2949 | if ((pReq->LUN[1] != 0) || (hd->negoNvram != 0)) |
2983 | return; | 2950 | return; |
@@ -2985,12 +2952,12 @@ mptscsih_set_dvflags(MPT_SCSI_HOST *hd, SCSIIORequest_t *pReq) | |||
2985 | cmd = pReq->CDB[0]; | 2952 | cmd = pReq->CDB[0]; |
2986 | 2953 | ||
2987 | if ((cmd == READ_CAPACITY) || (cmd == MODE_SENSE)) { | 2954 | if ((cmd == READ_CAPACITY) || (cmd == MODE_SENSE)) { |
2988 | pSpi = &hd->ioc->spi_data; | 2955 | pSpi = &ioc->spi_data; |
2989 | if ((pSpi->isRaid & (1 << pReq->TargetID)) && pSpi->pIocPg3) { | 2956 | if ((ioc->raid_data.isRaid & (1 << pReq->TargetID)) && ioc->raid_data.pIocPg3) { |
2990 | /* Set NEED_DV for all hidden disks | 2957 | /* Set NEED_DV for all hidden disks |
2991 | */ | 2958 | */ |
2992 | Ioc3PhysDisk_t *pPDisk = pSpi->pIocPg3->PhysDisk; | 2959 | Ioc3PhysDisk_t *pPDisk = ioc->raid_data.pIocPg3->PhysDisk; |
2993 | int numPDisk = pSpi->pIocPg3->NumPhysDisks; | 2960 | int numPDisk = ioc->raid_data.pIocPg3->NumPhysDisks; |
2994 | 2961 | ||
2995 | while (numPDisk) { | 2962 | while (numPDisk) { |
2996 | pSpi->dvStatus[pPDisk->PhysDiskID] |= MPT_SCSICFG_NEED_DV; | 2963 | pSpi->dvStatus[pPDisk->PhysDiskID] |= MPT_SCSICFG_NEED_DV; |
@@ -3004,6 +2971,50 @@ mptscsih_set_dvflags(MPT_SCSI_HOST *hd, SCSIIORequest_t *pReq) | |||
3004 | } | 2971 | } |
3005 | } | 2972 | } |
3006 | 2973 | ||
2974 | /* mptscsih_raid_set_dv_flags() | ||
2975 | * | ||
2976 | * New or replaced disk. Set DV flag and schedule DV. | ||
2977 | */ | ||
2978 | static void | ||
2979 | mptscsih_set_dvflags_raid(MPT_SCSI_HOST *hd, int id) | ||
2980 | { | ||
2981 | MPT_ADAPTER *ioc = hd->ioc; | ||
2982 | SpiCfgData *pSpi = &ioc->spi_data; | ||
2983 | Ioc3PhysDisk_t *pPDisk; | ||
2984 | int numPDisk; | ||
2985 | |||
2986 | if (hd->negoNvram != 0) | ||
2987 | return; | ||
2988 | |||
2989 | ddvtprintk(("DV requested for phys disk id %d\n", id)); | ||
2990 | if (ioc->raid_data.pIocPg3) { | ||
2991 | pPDisk = ioc->raid_data.pIocPg3->PhysDisk; | ||
2992 | numPDisk = ioc->raid_data.pIocPg3->NumPhysDisks; | ||
2993 | while (numPDisk) { | ||
2994 | if (id == pPDisk->PhysDiskNum) { | ||
2995 | pSpi->dvStatus[pPDisk->PhysDiskID] = | ||
2996 | (MPT_SCSICFG_NEED_DV | MPT_SCSICFG_DV_NOT_DONE); | ||
2997 | pSpi->forceDv = MPT_SCSICFG_NEED_DV; | ||
2998 | ddvtprintk(("NEED_DV set for phys disk id %d\n", | ||
2999 | pPDisk->PhysDiskID)); | ||
3000 | break; | ||
3001 | } | ||
3002 | pPDisk++; | ||
3003 | numPDisk--; | ||
3004 | } | ||
3005 | |||
3006 | if (numPDisk == 0) { | ||
3007 | /* The physical disk that needs DV was not found | ||
3008 | * in the stored IOC Page 3. The driver must reload | ||
3009 | * this page. DV routine will set the NEED_DV flag for | ||
3010 | * all phys disks that have DV_NOT_DONE set. | ||
3011 | */ | ||
3012 | pSpi->forceDv = MPT_SCSICFG_NEED_DV | MPT_SCSICFG_RELOAD_IOC_PG3; | ||
3013 | ddvtprintk(("phys disk %d not found. Setting reload IOC Pg3 Flag\n",id)); | ||
3014 | } | ||
3015 | } | ||
3016 | } | ||
3017 | |||
3007 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | 3018 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ |
3008 | /* | 3019 | /* |
3009 | * If no Target, bus reset on 1st I/O. Set the flag to | 3020 | * If no Target, bus reset on 1st I/O. Set the flag to |
@@ -3091,7 +3102,7 @@ mptscsih_writeSDP1(MPT_SCSI_HOST *hd, int portnum, int target_id, int flags) | |||
3091 | MPT_ADAPTER *ioc = hd->ioc; | 3102 | MPT_ADAPTER *ioc = hd->ioc; |
3092 | Config_t *pReq; | 3103 | Config_t *pReq; |
3093 | SCSIDevicePage1_t *pData; | 3104 | SCSIDevicePage1_t *pData; |
3094 | VirtDevice *pTarget; | 3105 | VirtDevice *pTarget=NULL; |
3095 | MPT_FRAME_HDR *mf; | 3106 | MPT_FRAME_HDR *mf; |
3096 | dma_addr_t dataDma; | 3107 | dma_addr_t dataDma; |
3097 | u16 req_idx; | 3108 | u16 req_idx; |
@@ -3190,7 +3201,7 @@ mptscsih_writeSDP1(MPT_SCSI_HOST *hd, int portnum, int target_id, int flags) | |||
3190 | #endif | 3201 | #endif |
3191 | 3202 | ||
3192 | if (flags & MPT_SCSICFG_BLK_NEGO) | 3203 | if (flags & MPT_SCSICFG_BLK_NEGO) |
3193 | negoFlags = MPT_TARGET_NO_NEGO_WIDE | MPT_TARGET_NO_NEGO_SYNC; | 3204 | negoFlags |= MPT_TARGET_NO_NEGO_WIDE | MPT_TARGET_NO_NEGO_SYNC; |
3194 | 3205 | ||
3195 | mptscsih_setDevicePage1Flags(width, factor, offset, | 3206 | mptscsih_setDevicePage1Flags(width, factor, offset, |
3196 | &requested, &configuration, negoFlags); | 3207 | &requested, &configuration, negoFlags); |
@@ -4011,7 +4022,7 @@ mptscsih_synchronize_cache(MPT_SCSI_HOST *hd, int portnum) | |||
4011 | 4022 | ||
4012 | /* If target Ptr NULL or if this target is NOT a disk, skip. | 4023 | /* If target Ptr NULL or if this target is NOT a disk, skip. |
4013 | */ | 4024 | */ |
4014 | if ((pTarget) && (pTarget->tflags & MPT_TARGET_FLAGS_Q_YES)){ | 4025 | if ((pTarget) && (pTarget->inq_data[0] == TYPE_DISK)){ |
4015 | for (lun=0; lun <= MPT_LAST_LUN; lun++) { | 4026 | for (lun=0; lun <= MPT_LAST_LUN; lun++) { |
4016 | /* If LUN present, issue the command | 4027 | /* If LUN present, issue the command |
4017 | */ | 4028 | */ |
@@ -4106,9 +4117,9 @@ mptscsih_domainValidation(void *arg) | |||
4106 | 4117 | ||
4107 | if ((ioc->spi_data.forceDv & MPT_SCSICFG_RELOAD_IOC_PG3) != 0) { | 4118 | if ((ioc->spi_data.forceDv & MPT_SCSICFG_RELOAD_IOC_PG3) != 0) { |
4108 | mpt_read_ioc_pg_3(ioc); | 4119 | mpt_read_ioc_pg_3(ioc); |
4109 | if (ioc->spi_data.pIocPg3) { | 4120 | if (ioc->raid_data.pIocPg3) { |
4110 | Ioc3PhysDisk_t *pPDisk = ioc->spi_data.pIocPg3->PhysDisk; | 4121 | Ioc3PhysDisk_t *pPDisk = ioc->raid_data.pIocPg3->PhysDisk; |
4111 | int numPDisk = ioc->spi_data.pIocPg3->NumPhysDisks; | 4122 | int numPDisk = ioc->raid_data.pIocPg3->NumPhysDisks; |
4112 | 4123 | ||
4113 | while (numPDisk) { | 4124 | while (numPDisk) { |
4114 | if (ioc->spi_data.dvStatus[pPDisk->PhysDiskID] & MPT_SCSICFG_DV_NOT_DONE) | 4125 | if (ioc->spi_data.dvStatus[pPDisk->PhysDiskID] & MPT_SCSICFG_DV_NOT_DONE) |
@@ -4147,7 +4158,7 @@ mptscsih_domainValidation(void *arg) | |||
4147 | isPhysDisk = mptscsih_is_phys_disk(ioc, id); | 4158 | isPhysDisk = mptscsih_is_phys_disk(ioc, id); |
4148 | if (isPhysDisk) { | 4159 | if (isPhysDisk) { |
4149 | for (ii=0; ii < MPT_MAX_SCSI_DEVICES; ii++) { | 4160 | for (ii=0; ii < MPT_MAX_SCSI_DEVICES; ii++) { |
4150 | if (hd->ioc->spi_data.isRaid & (1 << ii)) { | 4161 | if (hd->ioc->raid_data.isRaid & (1 << ii)) { |
4151 | hd->ioc->spi_data.dvStatus[ii] |= MPT_SCSICFG_DV_PENDING; | 4162 | hd->ioc->spi_data.dvStatus[ii] |= MPT_SCSICFG_DV_PENDING; |
4152 | } | 4163 | } |
4153 | } | 4164 | } |
@@ -4166,7 +4177,7 @@ mptscsih_domainValidation(void *arg) | |||
4166 | 4177 | ||
4167 | if (isPhysDisk) { | 4178 | if (isPhysDisk) { |
4168 | for (ii=0; ii < MPT_MAX_SCSI_DEVICES; ii++) { | 4179 | for (ii=0; ii < MPT_MAX_SCSI_DEVICES; ii++) { |
4169 | if (hd->ioc->spi_data.isRaid & (1 << ii)) { | 4180 | if (hd->ioc->raid_data.isRaid & (1 << ii)) { |
4170 | hd->ioc->spi_data.dvStatus[ii] &= ~MPT_SCSICFG_DV_PENDING; | 4181 | hd->ioc->spi_data.dvStatus[ii] &= ~MPT_SCSICFG_DV_PENDING; |
4171 | } | 4182 | } |
4172 | } | 4183 | } |
@@ -4188,21 +4199,21 @@ mptscsih_domainValidation(void *arg) | |||
4188 | 4199 | ||
4189 | /* Search IOC page 3 to determine if this is hidden physical disk | 4200 | /* Search IOC page 3 to determine if this is hidden physical disk |
4190 | */ | 4201 | */ |
4191 | static int | 4202 | /* Search IOC page 3 to determine if this is hidden physical disk |
4203 | */ | ||
4204 | static int | ||
4192 | mptscsih_is_phys_disk(MPT_ADAPTER *ioc, int id) | 4205 | mptscsih_is_phys_disk(MPT_ADAPTER *ioc, int id) |
4193 | { | 4206 | { |
4194 | if (ioc->spi_data.pIocPg3) { | 4207 | int i; |
4195 | Ioc3PhysDisk_t *pPDisk = ioc->spi_data.pIocPg3->PhysDisk; | ||
4196 | int numPDisk = ioc->spi_data.pIocPg3->NumPhysDisks; | ||
4197 | 4208 | ||
4198 | while (numPDisk) { | 4209 | if (!ioc->raid_data.isRaid || !ioc->raid_data.pIocPg3) |
4199 | if (pPDisk->PhysDiskID == id) { | 4210 | return 0; |
4200 | return 1; | 4211 | |
4201 | } | 4212 | for (i = 0; i < ioc->raid_data.pIocPg3->NumPhysDisks; i++) { |
4202 | pPDisk++; | 4213 | if (id == ioc->raid_data.pIocPg3->PhysDisk[i].PhysDiskID) |
4203 | numPDisk--; | 4214 | return 1; |
4204 | } | ||
4205 | } | 4215 | } |
4216 | |||
4206 | return 0; | 4217 | return 0; |
4207 | } | 4218 | } |
4208 | 4219 | ||
@@ -4408,7 +4419,7 @@ mptscsih_doDv(MPT_SCSI_HOST *hd, int bus_number, int id) | |||
4408 | /* Skip this ID? Set cfg.cfghdr.hdr to force config page write | 4419 | /* Skip this ID? Set cfg.cfghdr.hdr to force config page write |
4409 | */ | 4420 | */ |
4410 | { | 4421 | { |
4411 | ScsiCfgData *pspi_data = &hd->ioc->spi_data; | 4422 | SpiCfgData *pspi_data = &hd->ioc->spi_data; |
4412 | if (pspi_data->nvram && (pspi_data->nvram[id] != MPT_HOST_NVRAM_INVALID)) { | 4423 | if (pspi_data->nvram && (pspi_data->nvram[id] != MPT_HOST_NVRAM_INVALID)) { |
4413 | /* Set the factor from nvram */ | 4424 | /* Set the factor from nvram */ |
4414 | nfactor = (pspi_data->nvram[id] & MPT_NVRAM_SYNC_MASK) >> 8; | 4425 | nfactor = (pspi_data->nvram[id] & MPT_NVRAM_SYNC_MASK) >> 8; |
@@ -4438,11 +4449,11 @@ mptscsih_doDv(MPT_SCSI_HOST *hd, int bus_number, int id) | |||
4438 | } | 4449 | } |
4439 | 4450 | ||
4440 | /* Finish iocmd inititialization - hidden or visible disk? */ | 4451 | /* Finish iocmd inititialization - hidden or visible disk? */ |
4441 | if (ioc->spi_data.pIocPg3) { | 4452 | if (ioc->raid_data.pIocPg3) { |
4442 | /* Search IOC page 3 for matching id | 4453 | /* Search IOC page 3 for matching id |
4443 | */ | 4454 | */ |
4444 | Ioc3PhysDisk_t *pPDisk = ioc->spi_data.pIocPg3->PhysDisk; | 4455 | Ioc3PhysDisk_t *pPDisk = ioc->raid_data.pIocPg3->PhysDisk; |
4445 | int numPDisk = ioc->spi_data.pIocPg3->NumPhysDisks; | 4456 | int numPDisk = ioc->raid_data.pIocPg3->NumPhysDisks; |
4446 | 4457 | ||
4447 | while (numPDisk) { | 4458 | while (numPDisk) { |
4448 | if (pPDisk->PhysDiskID == id) { | 4459 | if (pPDisk->PhysDiskID == id) { |
@@ -4466,7 +4477,7 @@ mptscsih_doDv(MPT_SCSI_HOST *hd, int bus_number, int id) | |||
4466 | /* RAID Volume ID's may double for a physical device. If RAID but | 4477 | /* RAID Volume ID's may double for a physical device. If RAID but |
4467 | * not a physical ID as well, skip DV. | 4478 | * not a physical ID as well, skip DV. |
4468 | */ | 4479 | */ |
4469 | if ((hd->ioc->spi_data.isRaid & (1 << id)) && !(iocmd.flags & MPT_ICFLAG_PHYS_DISK)) | 4480 | if ((hd->ioc->raid_data.isRaid & (1 << id)) && !(iocmd.flags & MPT_ICFLAG_PHYS_DISK)) |
4470 | goto target_done; | 4481 | goto target_done; |
4471 | 4482 | ||
4472 | 4483 | ||
@@ -4815,6 +4826,8 @@ mptscsih_doDv(MPT_SCSI_HOST *hd, int bus_number, int id) | |||
4815 | notDone = 0; | 4826 | notDone = 0; |
4816 | if (iocmd.flags & MPT_ICFLAG_ECHO) { | 4827 | if (iocmd.flags & MPT_ICFLAG_ECHO) { |
4817 | bufsize = ((pbuf1[2] & 0x1F) <<8) | pbuf1[3]; | 4828 | bufsize = ((pbuf1[2] & 0x1F) <<8) | pbuf1[3]; |
4829 | if (pbuf1[0] & 0x01) | ||
4830 | iocmd.flags |= MPT_ICFLAG_EBOS; | ||
4818 | } else { | 4831 | } else { |
4819 | bufsize = pbuf1[1]<<16 | pbuf1[2]<<8 | pbuf1[3]; | 4832 | bufsize = pbuf1[1]<<16 | pbuf1[2]<<8 | pbuf1[3]; |
4820 | } | 4833 | } |
@@ -4911,6 +4924,9 @@ mptscsih_doDv(MPT_SCSI_HOST *hd, int bus_number, int id) | |||
4911 | } | 4924 | } |
4912 | iocmd.flags &= ~MPT_ICFLAG_DID_RESET; | 4925 | iocmd.flags &= ~MPT_ICFLAG_DID_RESET; |
4913 | 4926 | ||
4927 | if (iocmd.flags & MPT_ICFLAG_EBOS) | ||
4928 | goto skip_Reserve; | ||
4929 | |||
4914 | repeat = 5; | 4930 | repeat = 5; |
4915 | while (repeat && (!(iocmd.flags & MPT_ICFLAG_RESERVED))) { | 4931 | while (repeat && (!(iocmd.flags & MPT_ICFLAG_RESERVED))) { |
4916 | iocmd.cmd = RESERVE; | 4932 | iocmd.cmd = RESERVE; |
@@ -4954,6 +4970,7 @@ mptscsih_doDv(MPT_SCSI_HOST *hd, int bus_number, int id) | |||
4954 | } | 4970 | } |
4955 | } | 4971 | } |
4956 | 4972 | ||
4973 | skip_Reserve: | ||
4957 | mptscsih_fillbuf(pbuf1, sz, patt, 1); | 4974 | mptscsih_fillbuf(pbuf1, sz, patt, 1); |
4958 | iocmd.cmd = WRITE_BUFFER; | 4975 | iocmd.cmd = WRITE_BUFFER; |
4959 | iocmd.data_dma = buf1_dma; | 4976 | iocmd.data_dma = buf1_dma; |
@@ -5198,11 +5215,12 @@ mptscsih_dv_parms(MPT_SCSI_HOST *hd, DVPARAMETERS *dv,void *pPage) | |||
5198 | * If not an LVD bus, the adapter minSyncFactor has been | 5215 | * If not an LVD bus, the adapter minSyncFactor has been |
5199 | * already throttled back. | 5216 | * already throttled back. |
5200 | */ | 5217 | */ |
5218 | negoFlags = hd->ioc->spi_data.noQas; | ||
5201 | if ((hd->Targets)&&((pTarget = hd->Targets[(int)id]) != NULL) && !pTarget->raidVolume) { | 5219 | if ((hd->Targets)&&((pTarget = hd->Targets[(int)id]) != NULL) && !pTarget->raidVolume) { |
5202 | width = pTarget->maxWidth; | 5220 | width = pTarget->maxWidth; |
5203 | offset = pTarget->maxOffset; | 5221 | offset = pTarget->maxOffset; |
5204 | factor = pTarget->minSyncFactor; | 5222 | factor = pTarget->minSyncFactor; |
5205 | negoFlags = pTarget->negoFlags; | 5223 | negoFlags |= pTarget->negoFlags; |
5206 | } else { | 5224 | } else { |
5207 | if (hd->ioc->spi_data.nvram && (hd->ioc->spi_data.nvram[id] != MPT_HOST_NVRAM_INVALID)) { | 5225 | if (hd->ioc->spi_data.nvram && (hd->ioc->spi_data.nvram[id] != MPT_HOST_NVRAM_INVALID)) { |
5208 | data = hd->ioc->spi_data.nvram[id]; | 5226 | data = hd->ioc->spi_data.nvram[id]; |
@@ -5223,7 +5241,6 @@ mptscsih_dv_parms(MPT_SCSI_HOST *hd, DVPARAMETERS *dv,void *pPage) | |||
5223 | } | 5241 | } |
5224 | 5242 | ||
5225 | /* Set the negotiation flags */ | 5243 | /* Set the negotiation flags */ |
5226 | negoFlags = hd->ioc->spi_data.noQas; | ||
5227 | if (!width) | 5244 | if (!width) |
5228 | negoFlags |= MPT_TARGET_NO_NEGO_WIDE; | 5245 | negoFlags |= MPT_TARGET_NO_NEGO_WIDE; |
5229 | 5246 | ||
diff --git a/drivers/message/fusion/mptscsih.h b/drivers/message/fusion/mptscsih.h index 51c0255ac16e..971fda4b8b57 100644 --- a/drivers/message/fusion/mptscsih.h +++ b/drivers/message/fusion/mptscsih.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/message/fusion/mptscsi.h | 2 | * linux/drivers/message/fusion/mptscsih.h |
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 |
@@ -53,8 +53,8 @@ | |||
53 | * SCSI Public stuff... | 53 | * SCSI Public stuff... |
54 | */ | 54 | */ |
55 | 55 | ||
56 | #define MPT_SCSI_CMD_PER_DEV_HIGH 31 | 56 | #define MPT_SCSI_CMD_PER_DEV_HIGH 64 |
57 | #define MPT_SCSI_CMD_PER_DEV_LOW 7 | 57 | #define MPT_SCSI_CMD_PER_DEV_LOW 32 |
58 | 58 | ||
59 | #define MPT_SCSI_CMD_PER_LUN 7 | 59 | #define MPT_SCSI_CMD_PER_LUN 7 |
60 | 60 | ||
@@ -77,6 +77,7 @@ | |||
77 | #define MPTSCSIH_MAX_WIDTH 1 | 77 | #define MPTSCSIH_MAX_WIDTH 1 |
78 | #define MPTSCSIH_MIN_SYNC 0x08 | 78 | #define MPTSCSIH_MIN_SYNC 0x08 |
79 | #define MPTSCSIH_SAF_TE 0 | 79 | #define MPTSCSIH_SAF_TE 0 |
80 | #define MPTSCSIH_PT_CLEAR 0 | ||
80 | 81 | ||
81 | 82 | ||
82 | #endif | 83 | #endif |
diff --git a/drivers/message/fusion/mptspi.c b/drivers/message/fusion/mptspi.c index 587d1274fd74..5c0e307d1d5d 100644 --- a/drivers/message/fusion/mptspi.c +++ b/drivers/message/fusion/mptspi.c | |||
@@ -199,7 +199,7 @@ mptspi_probe(struct pci_dev *pdev, const struct pci_device_id *id) | |||
199 | printk(MYIOC_s_WARN_FMT | 199 | printk(MYIOC_s_WARN_FMT |
200 | "Skipping ioc=%p because SCSI Initiator mode is NOT enabled!\n", | 200 | "Skipping ioc=%p because SCSI Initiator mode is NOT enabled!\n", |
201 | ioc->name, ioc); | 201 | ioc->name, ioc); |
202 | return -ENODEV; | 202 | return 0; |
203 | } | 203 | } |
204 | 204 | ||
205 | sh = scsi_host_alloc(&mptspi_driver_template, sizeof(MPT_SCSI_HOST)); | 205 | sh = scsi_host_alloc(&mptspi_driver_template, sizeof(MPT_SCSI_HOST)); |
diff --git a/drivers/message/i2o/config-osm.c b/drivers/message/i2o/config-osm.c index af32ab4e90cd..10432f665201 100644 --- a/drivers/message/i2o/config-osm.c +++ b/drivers/message/i2o/config-osm.c | |||
@@ -56,8 +56,11 @@ static int __init i2o_config_init(void) | |||
56 | return -EBUSY; | 56 | return -EBUSY; |
57 | } | 57 | } |
58 | #ifdef CONFIG_I2O_CONFIG_OLD_IOCTL | 58 | #ifdef CONFIG_I2O_CONFIG_OLD_IOCTL |
59 | if (i2o_config_old_init()) | 59 | if (i2o_config_old_init()) { |
60 | osm_err("old config handler initialization failed\n"); | ||
60 | i2o_driver_unregister(&i2o_config_driver); | 61 | i2o_driver_unregister(&i2o_config_driver); |
62 | return -EBUSY; | ||
63 | } | ||
61 | #endif | 64 | #endif |
62 | 65 | ||
63 | return 0; | 66 | return 0; |