1 diff -uarN linux-2.6.1-rc2-reference/drivers/message/fusion/mptbase.c linux-2.6.1-rc2/drivers/message/fusion/mptbase.c
2 --- linux-2.6.1-rc2-reference/drivers/message/fusion/mptbase.c 2004-01-06 14:17:58.000000000 -0700
3 +++ linux-2.6.1-rc2/drivers/message/fusion/mptbase.c 2004-01-06 15:01:27.803311992 -0700
5 static MPT_EVHANDLER MptEvHandlers[MPT_MAX_PROTOCOL_DRIVERS];
6 /* Reset handler lookup table */
7 static MPT_RESETHANDLER MptResetHandlers[MPT_MAX_PROTOCOL_DRIVERS];
8 +static MPT_DVHANDLER MptDvHandler[MPT_MAX_PROTOCOL_DRIVERS];
10 static int FusionInitCalled = 0;
11 static int mpt_base_index = -1;
13 static int mpt_base_reply(MPT_ADAPTER *ioc, MPT_FRAME_HDR *req, MPT_FRAME_HDR *reply);
15 static int mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag);
16 -static int mpt_adapter_install(struct pci_dev *pdev);
17 static void mpt_detect_bound_ports(MPT_ADAPTER *this, struct pci_dev *pdev);
18 static void mpt_adapter_disable(MPT_ADAPTER *ioc, int freeup);
19 static void mpt_adapter_dispose(MPT_ADAPTER *ioc);
21 static void mpt_fc_log_info(MPT_ADAPTER *ioc, u32 log_info);
22 static void mpt_sp_log_info(MPT_ADAPTER *ioc, u32 log_info);
24 -int fusion_init(void);
25 -static void fusion_exit(void);
26 +/* module entry point */
27 +static int __devinit mptbase_probe (struct pci_dev *, const struct pci_device_id *);
28 +static void __devexit mptbase_remove(struct pci_dev *);
29 +static int __init fusion_init (void);
30 +static void __exit fusion_exit (void);
32 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
38 +/****************************************************************************
39 + * Supported hardware
41 +#define DEVT_INDEX_MPT 0x0000 /* Fusion MPT Interface */
43 +static struct pci_device_id mptbase_pci_table[] = {
45 + .vendor = PCI_VENDOR_ID_LSI_LOGIC,
46 + .device = PCI_DEVICE_ID_LSI_FC909,
47 + .subvendor = PCI_ANY_ID,
48 + .subdevice = PCI_ANY_ID,
49 + .class = PCI_CLASS_SERIAL_FIBER << 8,
50 + .class_mask = 0xFFFF00,
51 + .driver_data = DEVT_INDEX_MPT
54 + .vendor = PCI_VENDOR_ID_LSI_LOGIC,
55 + .device = PCI_DEVICE_ID_LSI_FC929,
56 + .subvendor = PCI_ANY_ID,
57 + .subdevice = PCI_ANY_ID,
58 + .class = PCI_CLASS_SERIAL_FIBER << 8,
59 + .class_mask = 0xFFFF00,
60 + .driver_data = DEVT_INDEX_MPT
63 + .vendor = PCI_VENDOR_ID_LSI_LOGIC,
64 + .device = PCI_DEVICE_ID_LSI_FC919,
65 + .subvendor = PCI_ANY_ID,
66 + .subdevice = PCI_ANY_ID,
67 + .class = PCI_CLASS_SERIAL_FIBER << 8,
68 + .class_mask = 0xFFFF00,
69 + .driver_data = DEVT_INDEX_MPT
72 + .vendor = PCI_VENDOR_ID_LSI_LOGIC,
73 + .device = PCI_DEVICE_ID_LSI_FC929X,
74 + .subvendor = PCI_ANY_ID,
75 + .subdevice = PCI_ANY_ID,
76 + .class = PCI_CLASS_SERIAL_FIBER << 8,
77 + .class_mask = 0xFFFF00,
78 + .driver_data = DEVT_INDEX_MPT
81 + .vendor = PCI_VENDOR_ID_LSI_LOGIC,
82 + .device = PCI_DEVICE_ID_LSI_FC919X,
83 + .subvendor = PCI_ANY_ID,
84 + .subdevice = PCI_ANY_ID,
85 + .class = PCI_CLASS_SERIAL_FIBER << 8,
86 + .class_mask = 0xFFFF00,
87 + .driver_data = DEVT_INDEX_MPT
90 + .vendor = PCI_VENDOR_ID_LSI_LOGIC,
91 + .device = PCI_DEVICE_ID_LSI_53C1030,
92 + .subvendor = PCI_ANY_ID,
93 + .subdevice = PCI_ANY_ID,
94 + .class = PCI_CLASS_STORAGE_SCSI << 8,
95 + .class_mask = 0xFFFF00,
96 + .driver_data = DEVT_INDEX_MPT
99 + .vendor = PCI_VENDOR_ID_LSI_LOGIC,
100 + .device = PCI_DEVICE_ID_LSI_1030_53C1035,
101 + .subvendor = PCI_ANY_ID,
102 + .subdevice = PCI_ANY_ID,
103 + .class = PCI_CLASS_STORAGE_SCSI << 8,
104 + .class_mask = 0xFFFF00,
105 + .driver_data = DEVT_INDEX_MPT
107 + {0} /* Terminating entry */
109 +MODULE_DEVICE_TABLE(pci, mptbase_pci_table);
112 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
113 /* 20000207 -sralston
114 * GRRRRR... IOSpace (port i/o) register access (for the 909) is back!
116 MptResetHandlers[cb_idx] = NULL;
120 +#ifndef MPTSCSIH_DISABLE_DOMAIN_VALIDATION
121 +/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
123 + * mpt_dv_register - Register protocol-specific domain validation handler.
125 +int mpt_dv_register(MPT_DVHANDLER dv_cbfunc, int cb_idx)
127 + if (cb_idx < 1 || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS)
130 + MptDvHandler[cb_idx] = dv_cbfunc;
134 +/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
136 + * mpt_dv_deregister - Deregister protocol-specific domain validation handler.
139 +mpt_dv_deregister(int cb_idx)
141 + if (cb_idx < 1 || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS)
144 + MptDvHandler[cb_idx] = NULL;
149 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
151 * mpt_get_msg_frame - Obtain a MPT request frame from the pool (of 1024)
152 @@ -1142,88 +1249,6 @@
156 -/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
158 - * mpt_pci_scan - Scan PCI devices for MPT adapters.
160 - * Returns count of MPT adapters found, keying off of PCI vendor and
166 - struct pci_dev *pdev = NULL;
167 - struct pci_dev *pdev2;
172 - dprintk((KERN_INFO MYNAM ": Checking for MPT adapters...\n"));
175 - * NOTE: The 929, 929X, 1030 and 1035 will appear as 2 separate PCI devices,
176 - * one for each channel.
178 - while ((pdev = pci_find_device(PCI_VENDOR_ID_LSI_LOGIC, PCI_ANY_ID, pdev)) != NULL) {
180 - if ((pdev->device != MPI_MANUFACTPAGE_DEVICEID_FC909) &&
181 - (pdev->device != MPI_MANUFACTPAGE_DEVICEID_FC929) &&
182 - (pdev->device != MPI_MANUFACTPAGE_DEVICEID_FC919) &&
183 - (pdev->device != MPI_MANUFACTPAGE_DEVICEID_FC929X) &&
184 - (pdev->device != MPI_MANUFACTPAGE_DEVICEID_FC919X) &&
185 - (pdev->device != MPI_MANUFACTPAGE_DEVID_53C1030) &&
186 - (pdev->device != MPI_MANUFACTPAGE_DEVID_1030_53C1035) &&
188 - dprintk((KERN_INFO MYNAM ": Skipping LSI device=%04xh\n", pdev->device));
193 - * dual function devices (929, 929X, 1030, 1035) may be presented in Func 1,0 order,
194 - * but we'd really really rather have them in Func 0,1 order.
195 - * Do some kind of look ahead here...
197 - if (pdev->devfn & 1) {
198 - pdev2 = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pdev);
199 - if (pdev2 && (pdev2->vendor == 0x1000) &&
200 - (PCI_SLOT(pdev2->devfn) == PCI_SLOT(pdev->devfn)) &&
201 - (pdev2->device == pdev->device) &&
202 - (pdev2->bus->number == pdev->bus->number) &&
203 - !(pdev2->devfn & 1)) {
204 - dprintk((KERN_INFO MYNAM ": MPT adapter found: PCI bus/dfn=%02x/%02xh, class=%08x, id=%xh\n",
205 - pdev2->bus->number, pdev2->devfn, pdev2->class, pdev2->device));
207 - if ((r = mpt_adapter_install(pdev2)) == 0)
214 - dprintk((KERN_INFO MYNAM ": MPT adapter found: PCI bus/dfn=%02x/%02xh, class=%08x, id=%xh\n",
215 - pdev->bus->number, pdev->devfn, pdev->class, pdev->device));
217 - if ((r = mpt_adapter_install(pdev)) == 0)
224 - printk(KERN_INFO MYNAM ": %d MPT adapter%s found, %d installed.\n",
225 - found, (found==1) ? "" : "s", count);
227 - if (!found || !count) {
232 -#ifdef CONFIG_PROC_FS
233 - (void) procmpt_create();
239 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
241 @@ -1253,7 +1278,7 @@
243 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
245 - * mpt_adapter_install - Install a PCI intelligent MPT adapter.
246 + * mptbase_probe - Install a PCI intelligent MPT adapter.
247 * @pdev: Pointer to pci_dev structure
249 * This routine performs all the steps necessary to bring the IOC of
250 @@ -1268,8 +1293,8 @@
252 * TODO: Add support for polled controllers
255 -mpt_adapter_install(struct pci_dev *pdev)
257 +__devinit mptbase_probe(struct pci_dev *pdev, const struct pci_device_id *id)
261 @@ -1292,6 +1317,13 @@
265 + if (!pci_set_consistent_dma_mask(pdev, mask))
266 + dprintk((KERN_INFO MYNAM
267 + ": Using 64 bit consistent mask\n"));
269 + dprintk((KERN_INFO MYNAM
270 + ": Not using 64 bit consistent mask\n"));
272 ioc = kmalloc(sizeof(MPT_ADAPTER), GFP_ATOMIC);
274 printk(KERN_ERR MYNAM ": ERROR - Insufficient memory to add adapter!\n");
275 @@ -1500,6 +1532,7 @@
276 ioc->pci_irq = pdev->irq;
278 pci_set_master(pdev); /* ?? */
279 + pci_set_drvdata(pdev, ioc);
282 dprintk((KERN_INFO MYNAM ": %s installed at interrupt %d\n", ioc->name, pdev->irq));
283 @@ -1525,6 +1558,146 @@
285 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
287 + * mptbase_remove - Remove a PCI intelligent MPT adapter.
288 + * @pdev: Pointer to pci_dev structure
293 +__devexit mptbase_remove(struct pci_dev *pdev)
295 + mptscsih_sync_irq(pdev->irq);
296 + pci_set_drvdata(pdev, NULL);
300 +/**************************************************************************
304 +#include <acpi/acpi_drivers.h>
306 +/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
308 + * mptbase_suspend - Fusion MPT base driver suspend routine.
312 +static int mptbase_suspend(struct pci_dev *pdev, u32 state)
315 + MPT_ADAPTER *ioc = pci_get_drvdata(pdev);
319 + case ACPI_STATE_S1:
320 + device_state=ACPI_STATE_D1;
322 + case ACPI_STATE_S3:
323 + case ACPI_STATE_S4:
324 + device_state=ACPI_STATE_D3;
327 + return -EAGAIN /*FIXME*/;
331 + printk(MYIOC_s_INFO_FMT
332 + "pci-suspend: pdev=0x%p, slot=%s, Entering operating state [D%d]\n",
333 + ioc->name, pdev, pci_name(pdev), device_state);
335 + pci_save_state(pdev, ioc->PciState);
337 + /* put ioc into READY_STATE */
338 + if(SendIocReset(ioc, MPI_FUNCTION_IOC_MESSAGE_UNIT_RESET, CAN_SLEEP)) {
339 + printk(MYIOC_s_ERR_FMT
340 + "pci-suspend: IOC msg unit reset failed!\n", ioc->name);
343 + /* disable interrupts */
344 + CHIPREG_WRITE32(&ioc->chip->IntMask, 0xFFFFFFFF);
347 + /* Clear any lingering interrupt */
348 + CHIPREG_WRITE32(&ioc->chip->IntStatus, 0);
350 + pci_disable_device(pdev);
351 + pci_set_power_state(pdev, device_state);
356 +/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
358 + * mptbase_resume - Fusion MPT base driver resume routine.
362 +static int mptbase_resume(struct pci_dev *pdev)
364 + MPT_ADAPTER *ioc = pci_get_drvdata(pdev);
365 + u32 device_state = pdev->current_state;
366 + int do_domain_validation_flag=0;
367 + int recovery_state;
369 + printk(MYIOC_s_INFO_FMT
370 + "pci-resume: pdev=0x%p, slot=%s, Previous operating state [D%d]\n",
371 + ioc->name, pdev, pci_name(pdev), device_state);
373 + pci_set_power_state(pdev, ACPI_STATE_D0);
374 + pci_restore_state(pdev, ioc->PciState);
375 + pci_enable_device(pdev);
377 + /* enable interrupts */
378 + CHIPREG_WRITE32(&ioc->chip->IntMask, ~(MPI_HIM_RIM));
381 + /* F/W not running */
382 + if(!CHIPREG_READ32(&ioc->chip->Doorbell)) {
383 + do_domain_validation_flag=1;
386 + printk(MYIOC_s_INFO_FMT
387 + "pci-resume: ioc-state=0x%x,doorbell=0x%x\n",
389 + (mpt_GetIocState(ioc, 1) >> MPI_IOC_STATE_SHIFT),
390 + CHIPREG_READ32(&ioc->chip->Doorbell));
392 + /* bring ioc to operational state */
393 + if ((recovery_state = mpt_do_ioc_recovery(ioc,
394 + MPT_HOSTEVENT_IOC_RECOVER, CAN_SLEEP)) != 0) {
395 + printk(MYIOC_s_INFO_FMT
396 + "pci-resume: Cannot recover, error:[%x]\n",
397 + ioc->name, recovery_state);
399 + printk(MYIOC_s_INFO_FMT
400 + "pci-resume: success\n", ioc->name);
403 +#ifndef MPTSCSIH_DISABLE_DOMAIN_VALIDATION
404 + if(do_domain_validation_flag) {
407 + for (ii=0; ii < MPT_MAX_SCSI_DEVICES; ii++) {
408 + ioc->spi_data.dvStatus[ii] |= MPT_SCSICFG_NEED_DV;
411 + for(ii=0; ii<MPT_MAX_PROTOCOL_DRIVERS; ii++) {
412 + if(MptDvHandler[ii]) {
413 + printk(MYIOC_s_INFO_FMT
414 + "pci-resume: domain validation\n",ioc->name);
415 + (*(MptDvHandler[ii]))(NULL);
425 +/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
427 * mpt_do_ioc_recovery - Initialize or recover MPT adapter.
428 * @ioc: Pointer to MPT adapter structure
429 * @reason: Event word / reason
430 @@ -5851,6 +6024,8 @@
431 EXPORT_SYMBOL(mpt_event_deregister);
432 EXPORT_SYMBOL(mpt_reset_register);
433 EXPORT_SYMBOL(mpt_reset_deregister);
434 +EXPORT_SYMBOL(mpt_dv_register);
435 +EXPORT_SYMBOL(mpt_dv_deregister);
436 EXPORT_SYMBOL(mpt_get_msg_frame);
437 EXPORT_SYMBOL(mpt_put_msg_frame);
438 EXPORT_SYMBOL(mpt_free_msg_frame);
439 @@ -5877,16 +6052,29 @@
440 EXPORT_SYMBOL(mpt_ASCQ_TableSz);
441 EXPORT_SYMBOL(mpt_ScsiOpcodesPtr);
444 +static struct pci_driver mptbase_driver = {
446 + .id_table = mptbase_pci_table,
447 + .probe = mptbase_probe,
448 + .remove = __devexit_p(mptbase_remove),
450 + .suspend = mptbase_suspend,
451 + .resume = mptbase_resume,
455 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
457 * fusion_init - Fusion MPT base driver initialization routine.
459 * Returns 0 for success, non-zero for failure.
464 +__init fusion_init(void)
469 if (FusionInitCalled++) {
470 dprintk((KERN_INFO MYNAM ": INFO - Driver late-init entry point called\n"));
471 @@ -5920,10 +6108,13 @@
475 - if ((i = mpt_pci_scan()) < 0)
477 + r = pci_module_init(&mptbase_driver);
480 +#ifdef CONFIG_PROC_FS
481 + (void) procmpt_create();
487 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
488 @@ -5934,13 +6125,14 @@
489 * and removes all %MPT_PROCFS_MPTBASEDIR entries.
493 +__exit fusion_exit(void)
496 - struct pci_dev *pdev = NULL;
498 dprintk((KERN_INFO MYNAM ": fusion_exit() called!\n"));
500 + pci_unregister_driver(&mptbase_driver);
502 /* Whups? 20010120 -sralston
503 * Moved this *above* removal of all MptAdapters!
505 @@ -5956,9 +6148,6 @@
509 - pdev = (struct pci_dev *)this->pcidev;
510 - mptscsih_sync_irq(pdev->irq);
512 /* Clear any lingering interrupt */
513 CHIPREG_WRITE32(&this->chip->IntStatus, 0);
515 @@ -5971,7 +6160,6 @@
516 mpt_reset_deregister(mpt_base_index);
519 -/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
521 module_init(fusion_init);
522 module_exit(fusion_exit);
523 diff -uarN linux-2.6.1-rc2-reference/drivers/message/fusion/mptbase.h linux-2.6.1-rc2/drivers/message/fusion/mptbase.h
524 --- linux-2.6.1-rc2-reference/drivers/message/fusion/mptbase.h 2004-01-06 14:17:58.000000000 -0700
525 +++ linux-2.6.1-rc2/drivers/message/fusion/mptbase.h 2003-12-19 10:01:51.000000000 -0700
527 #define COPYRIGHT "Copyright (c) 1999-2003 " MODULEAUTHOR
530 -#define MPT_LINUX_VERSION_COMMON "2.05.00.05"
531 -#define MPT_LINUX_PACKAGE_NAME "@(#)mptlinux-2.05.00.05"
532 +#define MPT_LINUX_VERSION_COMMON "3.00.00"
533 +#define MPT_LINUX_PACKAGE_NAME "@(#)mptlinux-3.00.00"
534 #define WHAT_MAGIC_STRING "@" "(" "#" ")"
536 #define show_mptmod_ver(s,ver) \
538 FCPortPage0_t fc_port_page0[2];
539 LANPage0_t lan_cnfg_page0;
540 LANPage1_t lan_cnfg_page1;
542 + u32 PciState[64]; /* save PCI state to this area */
545 u8 upload_fw; /* If set, do a fw upload */
546 u8 reload_fw; /* Force a FW Reload on next reset */
548 typedef int (*MPT_CALLBACK)(MPT_ADAPTER *ioc, MPT_FRAME_HDR *req, MPT_FRAME_HDR *reply);
549 typedef int (*MPT_EVHANDLER)(MPT_ADAPTER *ioc, EventNotificationReply_t *evReply);
550 typedef int (*MPT_RESETHANDLER)(MPT_ADAPTER *ioc, int reset_phase);
551 +typedef void (*MPT_DVHANDLER)(void *arg);
552 /* reset_phase defs */
553 #define MPT_IOC_PRE_RESET 0
554 #define MPT_IOC_POST_RESET 1
555 @@ -1001,6 +1005,8 @@
556 extern void mpt_event_deregister(int cb_idx);
557 extern int mpt_reset_register(int cb_idx, MPT_RESETHANDLER reset_func);
558 extern void mpt_reset_deregister(int cb_idx);
559 +extern int mpt_dv_register(MPT_DVHANDLER dv_cbfunc, int cb_idx);
560 +extern void mpt_dv_deregister(int cb_idx);
561 extern int mpt_register_ascqops_strings(void *ascqTable, int ascqtbl_sz, const char **opsTable);
562 extern void mpt_deregister_ascqops_strings(void);
563 extern MPT_FRAME_HDR *mpt_get_msg_frame(int handle, int iocid);
564 diff -uarN linux-2.6.1-rc2-reference/drivers/message/fusion/mptscsih.c linux-2.6.1-rc2/drivers/message/fusion/mptscsih.c
565 --- linux-2.6.1-rc2-reference/drivers/message/fusion/mptscsih.c 2004-01-06 14:17:58.000000000 -0700
566 +++ linux-2.6.1-rc2/drivers/message/fusion/mptscsih.c 2004-01-06 14:25:16.000000000 -0700
568 static MPT_FRAME_HDR *mptscsih_search_pendingQ(MPT_SCSI_HOST *hd, int scpnt_idx);
569 static void post_pendingQ_commands(MPT_SCSI_HOST *hd);
571 -static int mptscsih_TMHandler(MPT_SCSI_HOST *hd, u8 type, u8 target, u8 lun, int ctx2abort, int sleepFlag);
572 -static int mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 target, u8 lun, int ctx2abort, int sleepFlag);
573 +static int mptscsih_TMHandler(MPT_SCSI_HOST *hd, u8 type, u8 target, u8 lun, int ctx2abort, ulong timeout, int sleepFlag);
574 +static int mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 target, u8 lun, int ctx2abort, ulong timeout, int sleepFlag);
576 static int mptscsih_ioc_reset(MPT_ADAPTER *ioc, int post_reset);
577 static int mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply);
579 static int mptscsih_setup(char *str);
580 static int mptscsih_halt(struct notifier_block *nb, ulong event, void *buf);
582 +/* module entry point */
583 +static int __init mptscsih_init (void);
584 +static void __exit mptscsih_exit (void);
585 +int mptscsih_release(struct Scsi_Host *host);
589 * Reboot Notification
592 driver_setup = MPTSCSIH_DRIVER_SETUP;
594 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
596 +/* see mptscsih.h */
598 +#ifdef MPT_SCSIHOST_NEED_ENTRY_EXIT_HOOKUPS
599 +static Scsi_Host_Template driver_template = {
600 + .proc_name = "mptscsih",
601 + .proc_info = x_scsi_proc_info,
602 + .name = "MPT SCSI Host",
603 + .info = x_scsi_info,
604 + .queuecommand = x_scsi_queuecommand,
605 + .slave_alloc = x_scsi_slave_alloc,
606 + .slave_configure = x_scsi_slave_configure,
607 + .slave_destroy = x_scsi_slave_destroy,
608 + .eh_abort_handler = x_scsi_abort,
609 + .eh_device_reset_handler = x_scsi_dev_reset,
610 + .eh_bus_reset_handler = x_scsi_bus_reset,
611 + .eh_host_reset_handler = x_scsi_host_reset,
612 + .bios_param = x_scsi_bios_param,
613 + .can_queue = MPT_SCSI_CAN_QUEUE,
615 + .sg_tablesize = MPT_SCSI_SG_DEPTH,
616 + .max_sectors = MPT_SCSI_MAX_SECTORS,
617 + .cmd_per_lun = MPT_SCSI_CMD_PER_LUN,
618 + .use_clustering = ENABLE_CLUSTERING,
622 +/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
624 * Private inline routines...
626 @@ -264,12 +298,14 @@
627 mptscsih_io_direction(Scsi_Cmnd *cmd)
629 switch (cmd->cmnd[0]) {
635 return SCSI_DATA_WRITE;
642 return SCSI_DATA_READ;
646 switch (cmd->cmnd[0]) {
647 /* _DATA_OUT commands */
648 case WRITE_6: case WRITE_10: case WRITE_12:
650 case WRITE_LONG: case WRITE_SAME: case WRITE_BUFFER:
651 case WRITE_VERIFY: case WRITE_VERIFY_12:
652 case COMPARE: case COPY: case COPY_VERIFY:
654 sc->resid = sc->request_bufflen - xfer_cnt;
655 dprintk((KERN_NOTICE " SET sc->resid=%02xh\n", sc->resid));
657 + if(sc->underflow > xfer_cnt) {
658 + printk(MYIOC_s_INFO_FMT
659 + "SCSI data underrun: underflow=%02x, xfercnt=%02x\n",
660 + ioc->name, sc->underflow, xfer_cnt);
661 + sc->result = DID_SOFT_ERROR << 16;
666 if (sc->result == MPI_SCSI_STATUS_TASK_SET_FULL)
667 @@ -1231,8 +1275,9 @@
669 mem = (u8 *) hd->ReqToChain;
671 - memset(mem, 0xFF, sz);
673 +/* memset(mem, 0xFF, sz); */
674 + for(ii=0;ii<hd->ioc->req_depth;ii++)
675 + hd->ReqToChain[ii] = MPT_HOST_NO_CHAIN;
677 /* ChainToChain size must equal the total number
678 * of chain buffers to be allocated.
679 @@ -1275,7 +1320,6 @@
680 mem = (u8 *) hd->ChainToChain;
682 memset(mem, 0xFF, sz);
684 sz = num_chain * hd->ioc->req_sz;
685 if (hd->ChainBuffer == NULL) {
686 /* Allocate free chain buffer pool
687 @@ -1357,18 +1401,13 @@
688 /* SCSI host fops start here... */
689 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
691 - * mptscsih_detect - Register MPT adapter(s) as SCSI host(s) with
692 + * mptscsih_init - Register MPT adapter(s) as SCSI host(s) with
693 * linux scsi mid-layer.
694 - * @tpnt: Pointer to Scsi_Host_Template structure
696 - * (linux Scsi_Host_Template.detect routine)
698 - * Returns number of SCSI host adapters that were successfully
699 - * registered with the linux scsi mid-layer via the scsi_register()
701 + * Returns 0 for success, non-zero for failure.
704 -mptscsih_detect(Scsi_Host_Template *tpnt)
706 +__init mptscsih_init(void)
708 struct Scsi_Host *sh = NULL;
709 MPT_SCSI_HOST *hd = NULL;
710 @@ -1387,6 +1426,12 @@
711 ScsiTaskCtx = mpt_register(mptscsih_taskmgmt_complete, MPTSCSIH_DRIVER);
712 ScsiScanDvCtx = mpt_register(mptscsih_scandv_complete, MPTSCSIH_DRIVER);
714 +#ifndef MPTSCSIH_DISABLE_DOMAIN_VALIDATION
715 + if(mpt_dv_register(mptscsih_domainValidation, MPTSCSIH_DRIVER) != 0 ) {
716 + dprintk((KERN_INFO MYNAM
717 + ": failed to register dv callback\n"));
720 if (mpt_event_register(ScsiDoneCtx, mptscsih_event_process) == 0) {
721 dprintk((KERN_INFO MYNAM ": Registered for IOC event notifications\n"));
723 @@ -1431,14 +1476,17 @@
727 - tpnt->proc_info = mptscsih_proc_info;
728 - sh = scsi_register(tpnt, sizeof(MPT_SCSI_HOST));
729 + sh = scsi_host_alloc(&driver_template, sizeof(MPT_SCSI_HOST));
731 spin_lock_irqsave(&this->FreeQlock, flags);
736 + /* set 16 byte cdb's
738 + sh->max_cmd_len = 16;
740 /* Yikes! This is important!
741 * Otherwise, by default, linux
742 * only scans target IDs 0-7!
743 @@ -1634,7 +1682,7 @@
744 hd->ioc->spi_data.forceDv = 0;
745 for (ii=0; ii < MPT_MAX_SCSI_DEVICES; ii++)
746 hd->ioc->spi_data.dvStatus[ii] = MPT_SCSICFG_NEGOTIATE;
749 if (hd->negoNvram == 0) {
750 for (ii=0; ii < MPT_MAX_SCSI_DEVICES; ii++)
751 hd->ioc->spi_data.dvStatus[ii] |= MPT_SCSICFG_DV_NOT_DONE;
752 @@ -1649,6 +1697,10 @@
757 + scsi_add_host (sh, &this->pcidev->dev);
758 + scsi_scan_host(sh);
762 } /* for each adapter port */
763 @@ -1657,24 +1709,62 @@
767 - if (mpt_scsi_hosts > 0)
768 + if (mpt_scsi_hosts > 0) {
769 register_reboot_notifier(&mptscsih_notifier);
773 mpt_reset_deregister(ScsiDoneCtx);
774 dprintk((KERN_INFO MYNAM ": Deregistered for IOC reset notifications\n"));
776 mpt_event_deregister(ScsiDoneCtx);
777 dprintk((KERN_INFO MYNAM ": Deregistered for IOC event notifications\n"));
779 +#ifndef MPTSCSIH_DISABLE_DOMAIN_VALIDATION
780 + mpt_dv_deregister(MPTSCSIH_DRIVER);
782 mpt_deregister(ScsiScanDvCtx);
783 mpt_deregister(ScsiTaskCtx);
784 mpt_deregister(ScsiDoneCtx);
786 if (info_kbuf != NULL)
792 - return mpt_scsi_hosts;
795 +/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
796 +/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
798 + * mptscsih_exit - Unregisters MPT adapter(s)
802 +__exit mptscsih_exit(void)
805 + struct Scsi_Host *sh = NULL;
807 + this = mpt_adapter_find_first();
808 + while (this != NULL) {
810 + if (this->last_state != MPI_IOC_STATE_OPERATIONAL) {
811 + this = mpt_adapter_find_next(this);
820 + scsi_remove_host(sh);
821 + mptscsih_release(sh);
824 + this = mpt_adapter_find_next(this);
828 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
829 @@ -1801,7 +1891,6 @@
830 /* NULL the Scsi_Host pointer
833 - scsi_unregister(host);
835 if (mpt_scsi_hosts) {
836 if (--mpt_scsi_hosts == 0) {
837 @@ -1811,6 +1900,10 @@
838 mpt_event_deregister(ScsiDoneCtx);
839 dprintk((KERN_INFO MYNAM ": Deregistered for IOC event notifications\n"));
841 +#ifndef MPTSCSIH_DISABLE_DOMAIN_VALIDATION
842 + mpt_dv_deregister(MPTSCSIH_DRIVER);
845 mpt_deregister(ScsiScanDvCtx);
846 mpt_deregister(ScsiTaskCtx);
847 mpt_deregister(ScsiDoneCtx);
848 @@ -2606,7 +2699,7 @@
849 * Returns 0 for SUCCESS or -1 if FAILED.
852 -mptscsih_TMHandler(MPT_SCSI_HOST *hd, u8 type, u8 target, u8 lun, int ctx2abort, int sleepFlag)
853 +mptscsih_TMHandler(MPT_SCSI_HOST *hd, u8 type, u8 target, u8 lun, int ctx2abort, ulong timeout, int sleepFlag)
855 MPT_ADAPTER *ioc = NULL;
857 @@ -2662,7 +2755,7 @@
859 if (hd->hard_resets < -1)
861 - rc = mptscsih_IssueTaskMgmt(hd, type, target, lun, ctx2abort, sleepFlag);
862 + rc = mptscsih_IssueTaskMgmt(hd, type, target, lun, ctx2abort, timeout, sleepFlag);
864 printk(MYIOC_s_INFO_FMT "Issue of TaskMgmt failed!\n", hd->ioc->name);
866 @@ -2708,7 +2801,7 @@
867 * else other non-zero value returned.
870 -mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 target, u8 lun, int ctx2abort, int sleepFlag)
871 +mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 target, u8 lun, int ctx2abort, ulong timeout, int sleepFlag)
874 SCSITaskMgmt_t *pScsiTm;
875 @@ -2758,7 +2851,7 @@
879 - hd->TMtimer.expires = jiffies + HZ*20; /* 20 seconds */
880 + hd->TMtimer.expires = jiffies + timeout;
881 add_timer(&hd->TMtimer);
883 if ((retval = mpt_send_handshake_request(ScsiTaskCtx, hd->ioc->id,
884 @@ -2868,7 +2961,8 @@
886 spin_unlock_irq(host_lock);
887 if (mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_ABORT_TASK,
888 - SCpnt->device->id, SCpnt->device->lun, ctx2abort, CAN_SLEEP)
889 + SCpnt->device->id, SCpnt->device->lun,
890 + ctx2abort, (HZ*2) /* 2 second timeout */,CAN_SLEEP)
893 /* The TM request failed and the subsequent FW-reload failed!
894 @@ -2938,7 +3032,7 @@
897 if (mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_TARGET_RESET,
898 - SCpnt->device->id, 0, 0, CAN_SLEEP)
899 + SCpnt->device->id, 0, 0, (HZ*5) /* 5 second timeout */, CAN_SLEEP)
901 /* The TM request failed and the subsequent FW-reload failed!
903 @@ -3002,7 +3096,7 @@
905 /* We are now ready to execute the task management request. */
906 if (mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_RESET_BUS,
907 - 0, 0, 0, CAN_SLEEP)
908 + 0, 0, 0, (HZ*5) /* 5 second timeout */, CAN_SLEEP)
911 /* The TM request failed and the subsequent FW-reload failed!
912 @@ -3085,7 +3179,7 @@
913 mptscsih_tm_pending_wait(MPT_SCSI_HOST * hd)
916 - int loop_count = 60 * 4; /* Wait 60 seconds */
917 + int loop_count = 10 * 4; /* Wait 10 seconds */
921 @@ -3225,18 +3319,50 @@
924 mptscsih_bios_param(struct scsi_device * sdev, struct block_device *bdev,
925 - sector_t capacity, int *ip)
926 + sector_t capacity, int geom[])
931 + sector_t cylinders;
937 - ip[0] = 64; /* heads */
938 - ip[1] = 32; /* sectors */
939 - if ((ip[2] = size >> 11) > 1024) { /* cylinders, test for big disk */
940 - ip[0] = 255; /* heads */
941 - ip[1] = 63; /* sectors */
942 - ip[2] = size / (255 * 63); /* cylinders */
946 + dummy = heads * sectors;
947 + cylinders = capacity;
948 + do_div(cylinders,dummy);
950 + cylinders = (ulong)capacity / (heads * sectors);
954 + * Handle extended translation size for logical drives
957 + if ((ulong)capacity >= 0x200000) {
961 + dummy = heads * sectors;
962 + cylinders = capacity;
963 + do_div(cylinders,dummy);
965 + cylinders = (ulong)capacity / (heads * sectors);
969 + /* return result */
972 + geom[2] = cylinders;
974 + dprintk((KERN_NOTICE
975 + ": bios_param: Id=%i Lun=%i Channel=%i CHS=%i/%i/%i\n",
976 + sdev->id, sdev->lun,sdev->channel,(int)cylinders,heads,sectors));
981 @@ -3366,7 +3492,7 @@
982 vdev->raidVolume = 0;
983 if (hd->is_spi && (hd->ioc->spi_data.isRaid & (1 << (device->id)))) {
984 vdev->raidVolume = 1;
985 - ddvtprintk((KERN_INFO "RAID Volume @ id %d\n", target_id));
986 + ddvtprintk((KERN_INFO "RAID Volume @ id %d\n", device->id));
989 mptscsih_target_settings(hd, vdev, device);
990 @@ -3648,36 +3774,6 @@
994 -/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
996 -/* see mptscsih.h */
998 -#ifdef MPT_SCSIHOST_NEED_ENTRY_EXIT_HOOKUPS
999 -static Scsi_Host_Template driver_template = {
1000 - .proc_name = "mptscsih",
1001 - .proc_info = x_scsi_proc_info,
1002 - .name = "MPT SCSI Host",
1003 - .detect = x_scsi_detect,
1004 - .release = x_scsi_release,
1005 - .info = x_scsi_info,
1006 - .queuecommand = x_scsi_queuecommand,
1007 - .slave_alloc = x_scsi_slave_alloc,
1008 - .slave_configure = x_scsi_slave_configure,
1009 - .slave_destroy = x_scsi_slave_destroy,
1010 - .eh_abort_handler = x_scsi_abort,
1011 - .eh_device_reset_handler = x_scsi_dev_reset,
1012 - .eh_bus_reset_handler = x_scsi_bus_reset,
1013 - .eh_host_reset_handler = x_scsi_host_reset,
1014 - .bios_param = x_scsi_bios_param,
1015 - .can_queue = MPT_SCSI_CAN_QUEUE,
1017 - .sg_tablesize = MPT_SCSI_SG_DEPTH,
1018 - .max_sectors = MPT_SCSI_MAX_SECTORS,
1019 - .cmd_per_lun = MPT_SCSI_CMD_PER_LUN,
1020 - .use_clustering = ENABLE_CLUSTERING,
1022 -#include "../../scsi/scsi_module.c"
1025 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1026 /* Search the pendingQ for a command with specific index.
1027 @@ -4318,6 +4414,8 @@
1036 @@ -5413,7 +5511,7 @@
1037 flags = hd->ioc->spi_data.noQas;
1038 if (hd->ioc->spi_data.nvram && (hd->ioc->spi_data.nvram[id] != MPT_HOST_NVRAM_INVALID)) {
1039 data = hd->ioc->spi_data.nvram[id];
1042 if (data & MPT_NVRAM_WIDE_DISABLE)
1043 flags |= MPT_TARGET_NO_NEGO_WIDE;
1045 @@ -5518,7 +5616,7 @@
1046 /* DV only to SCSI adapters */
1047 if ((int)ioc->chip_type <= (int)FC929)
1051 /* Make sure everything looks ok */
1052 if (ioc->sh == NULL)
1054 @@ -7007,3 +7105,6 @@
1056 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1059 +module_init(mptscsih_init);
1060 +module_exit(mptscsih_exit);
1061 diff -uarN linux-2.6.1-rc2-reference/drivers/message/fusion/mptscsih.h linux-2.6.1-rc2/drivers/message/fusion/mptscsih.h
1062 --- linux-2.6.1-rc2-reference/drivers/message/fusion/mptscsih.h 2004-01-06 14:17:58.000000000 -0700
1063 +++ linux-2.6.1-rc2/drivers/message/fusion/mptscsih.h 2003-12-16 12:18:46.000000000 -0700
1066 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1068 -#define x_scsi_detect mptscsih_detect
1069 -#define x_scsi_release mptscsih_release
1070 #define x_scsi_info mptscsih_info
1071 #define x_scsi_queuecommand mptscsih_qcmd
1072 #define x_scsi_abort mptscsih_abort
1074 #define x_scsi_host_reset mptscsih_host_reset
1075 #define x_scsi_bios_param mptscsih_bios_param
1077 -#define x_scsi_taskmgmt_bh mptscsih_taskmgmt_bh
1078 -#define x_scsi_old_abort mptscsih_old_abort
1079 -#define x_scsi_old_reset mptscsih_old_reset
1080 #define x_scsi_slave_alloc mptscsih_slave_alloc
1081 #define x_scsi_slave_configure mptscsih_slave_configure
1082 #define x_scsi_slave_destroy mptscsih_slave_destroy
1085 * MPT SCSI Host / Initiator decls...
1087 -extern int x_scsi_detect(Scsi_Host_Template *);
1088 -extern int x_scsi_release(struct Scsi_Host *host);
1089 extern const char *x_scsi_info(struct Scsi_Host *);
1090 extern int x_scsi_queuecommand(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *));
1091 extern int x_scsi_abort(Scsi_Cmnd *);
1093 extern int x_scsi_dev_reset(Scsi_Cmnd *);
1094 extern int x_scsi_host_reset(Scsi_Cmnd *);
1095 extern int x_scsi_bios_param(struct scsi_device * sdev, struct block_device *bdev,
1096 - sector_t capacity, int *ip);
1097 -extern void x_scsi_taskmgmt_bh(void *);
1098 + sector_t capacity, int geom[]);
1099 extern int x_scsi_slave_alloc(Scsi_Device *);
1100 extern int x_scsi_slave_configure(Scsi_Device *);
1101 extern void x_scsi_slave_destroy(Scsi_Device *);