aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/message/fusion/mptbase.c
diff options
context:
space:
mode:
authorKashyap, Desai <kashyap.desai@lsi.com>2009-05-29 07:22:37 -0400
committerJames Bottomley <James.Bottomley@HansenPartnership.com>2009-06-09 18:43:06 -0400
commit2f187862e579f1f5e883188cab6bd867cb60387f (patch)
tree85785a2e0e176da653323f1a8cf133f7e9e86ca6 /drivers/message/fusion/mptbase.c
parenteedf92b99806aeff18dc21c9dfb28999ce374413 (diff)
[SCSI] mpt fusion: Code Cleanup patch
Resending patch considering Grants G's code review. Main goal to submit this patch is code cleaup. 1. Better driver debug prints and code indentation. 2. fault_reset_work_lock is not used anywhere. driver is using taskmgmt_lock instead of fault_reset_work_lock. 3. setting pci_set_drvdata properly. 4. Ingore config request when IOC is in reset state.( ioc_reset_in_progress is set). 5. Init/clear managment frame proprely.(INITIALIZE_MGMT_STATUS and CLEAR_MGMT_STATUS) Signed-off-by: Kashyap Desai <kadesai@lsi.com> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'drivers/message/fusion/mptbase.c')
-rw-r--r--drivers/message/fusion/mptbase.c416
1 files changed, 283 insertions, 133 deletions
diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index d67b26378a52..8f04d37fb359 100644
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -207,7 +207,6 @@ static int procmpt_iocinfo_read(char *buf, char **start, off_t offset,
207#endif 207#endif
208static void mpt_get_fw_exp_ver(char *buf, MPT_ADAPTER *ioc); 208static void mpt_get_fw_exp_ver(char *buf, MPT_ADAPTER *ioc);
209 209
210//int mpt_HardResetHandler(MPT_ADAPTER *ioc, int sleepFlag);
211static int ProcessEventNotification(MPT_ADAPTER *ioc, 210static int ProcessEventNotification(MPT_ADAPTER *ioc,
212 EventNotificationReply_t *evReply, int *evHandlers); 211 EventNotificationReply_t *evReply, int *evHandlers);
213static void mpt_iocstatus_info(MPT_ADAPTER *ioc, u32 ioc_status, MPT_FRAME_HDR *mf); 212static void mpt_iocstatus_info(MPT_ADAPTER *ioc, u32 ioc_status, MPT_FRAME_HDR *mf);
@@ -374,11 +373,11 @@ mpt_fault_reset_work(struct work_struct *work)
374 ioc = ioc->alt_ioc; 373 ioc = ioc->alt_ioc;
375 374
376 /* rearm the timer */ 375 /* rearm the timer */
377 spin_lock_irqsave(&ioc->fault_reset_work_lock, flags); 376 spin_lock_irqsave(&ioc->taskmgmt_lock, flags);
378 if (ioc->reset_work_q) 377 if (ioc->reset_work_q)
379 queue_delayed_work(ioc->reset_work_q, &ioc->fault_reset_work, 378 queue_delayed_work(ioc->reset_work_q, &ioc->fault_reset_work,
380 msecs_to_jiffies(MPT_POLLING_INTERVAL)); 379 msecs_to_jiffies(MPT_POLLING_INTERVAL));
381 spin_unlock_irqrestore(&ioc->fault_reset_work_lock, flags); 380 spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags);
382} 381}
383 382
384 383
@@ -972,11 +971,15 @@ mpt_free_msg_frame(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf)
972 971
973 /* Put Request back on FreeQ! */ 972 /* Put Request back on FreeQ! */
974 spin_lock_irqsave(&ioc->FreeQlock, flags); 973 spin_lock_irqsave(&ioc->FreeQlock, flags);
975 mf->u.frame.linkage.arg1 = 0xdeadbeaf; /* signature to know if this mf is freed */ 974 if (cpu_to_le32(mf->u.frame.linkage.arg1) == 0xdeadbeaf)
975 goto out;
976 /* signature to know if this mf is freed */
977 mf->u.frame.linkage.arg1 = cpu_to_le32(0xdeadbeaf);
976 list_add_tail(&mf->u.frame.linkage.list, &ioc->FreeQ); 978 list_add_tail(&mf->u.frame.linkage.list, &ioc->FreeQ);
977#ifdef MFCNT 979#ifdef MFCNT
978 ioc->mfcnt--; 980 ioc->mfcnt--;
979#endif 981#endif
982 out:
980 spin_unlock_irqrestore(&ioc->FreeQlock, flags); 983 spin_unlock_irqrestore(&ioc->FreeQlock, flags);
981} 984}
982 985
@@ -1731,6 +1734,7 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1731 1734
1732 ioc->id = mpt_ids++; 1735 ioc->id = mpt_ids++;
1733 sprintf(ioc->name, "ioc%d", ioc->id); 1736 sprintf(ioc->name, "ioc%d", ioc->id);
1737 dinitprintk(ioc, printk(KERN_WARNING MYNAM ": mpt_adapter_install\n"));
1734 1738
1735 /* 1739 /*
1736 * set initial debug level 1740 * set initial debug level
@@ -1771,7 +1775,6 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1771 ioc->reply_sz = MPT_REPLY_FRAME_SIZE; 1775 ioc->reply_sz = MPT_REPLY_FRAME_SIZE;
1772 1776
1773 ioc->pcidev = pdev; 1777 ioc->pcidev = pdev;
1774 spin_lock_init(&ioc->initializing_hba_lock);
1775 1778
1776 spin_lock_init(&ioc->taskmgmt_lock); 1779 spin_lock_init(&ioc->taskmgmt_lock);
1777 mutex_init(&ioc->internal_cmds.mutex); 1780 mutex_init(&ioc->internal_cmds.mutex);
@@ -1792,6 +1795,7 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1792 ioc->mfcnt = 0; 1795 ioc->mfcnt = 0;
1793#endif 1796#endif
1794 1797
1798 ioc->sh = NULL;
1795 ioc->cached_fw = NULL; 1799 ioc->cached_fw = NULL;
1796 1800
1797 /* Initilize SCSI Config Data structure 1801 /* Initilize SCSI Config Data structure
@@ -1808,9 +1812,8 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1808 1812
1809 /* Initialize workqueue */ 1813 /* Initialize workqueue */
1810 INIT_DELAYED_WORK(&ioc->fault_reset_work, mpt_fault_reset_work); 1814 INIT_DELAYED_WORK(&ioc->fault_reset_work, mpt_fault_reset_work);
1811 spin_lock_init(&ioc->fault_reset_work_lock);
1812 1815
1813 snprintf(ioc->reset_work_q_name, sizeof(ioc->reset_work_q_name), 1816 snprintf(ioc->reset_work_q_name, MPT_KOBJ_NAME_LEN,
1814 "mpt_poll_%d", ioc->id); 1817 "mpt_poll_%d", ioc->id);
1815 ioc->reset_work_q = 1818 ioc->reset_work_q =
1816 create_singlethread_workqueue(ioc->reset_work_q_name); 1819 create_singlethread_workqueue(ioc->reset_work_q_name);
@@ -1885,11 +1888,14 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1885 case MPI_MANUFACTPAGE_DEVID_SAS1064: 1888 case MPI_MANUFACTPAGE_DEVID_SAS1064:
1886 case MPI_MANUFACTPAGE_DEVID_SAS1068: 1889 case MPI_MANUFACTPAGE_DEVID_SAS1068:
1887 ioc->errata_flag_1064 = 1; 1890 ioc->errata_flag_1064 = 1;
1891 ioc->bus_type = SAS;
1892 break;
1888 1893
1889 case MPI_MANUFACTPAGE_DEVID_SAS1064E: 1894 case MPI_MANUFACTPAGE_DEVID_SAS1064E:
1890 case MPI_MANUFACTPAGE_DEVID_SAS1068E: 1895 case MPI_MANUFACTPAGE_DEVID_SAS1068E:
1891 case MPI_MANUFACTPAGE_DEVID_SAS1078: 1896 case MPI_MANUFACTPAGE_DEVID_SAS1078:
1892 ioc->bus_type = SAS; 1897 ioc->bus_type = SAS;
1898 break;
1893 } 1899 }
1894 1900
1895 1901
@@ -1933,7 +1939,7 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1933 1939
1934 INIT_LIST_HEAD(&ioc->fw_event_list); 1940 INIT_LIST_HEAD(&ioc->fw_event_list);
1935 spin_lock_init(&ioc->fw_event_lock); 1941 spin_lock_init(&ioc->fw_event_lock);
1936 snprintf(ioc->fw_event_q_name, 20, "mpt/%d", ioc->id); 1942 snprintf(ioc->fw_event_q_name, MPT_KOBJ_NAME_LEN, "mpt/%d", ioc->id);
1937 ioc->fw_event_q = create_singlethread_workqueue(ioc->fw_event_q_name); 1943 ioc->fw_event_q = create_singlethread_workqueue(ioc->fw_event_q_name);
1938 1944
1939 if ((r = mpt_do_ioc_recovery(ioc, MPT_HOSTEVENT_IOC_BRINGUP, 1945 if ((r = mpt_do_ioc_recovery(ioc, MPT_HOSTEVENT_IOC_BRINGUP,
@@ -2008,10 +2014,10 @@ mpt_detach(struct pci_dev *pdev)
2008 /* 2014 /*
2009 * Stop polling ioc for fault condition 2015 * Stop polling ioc for fault condition
2010 */ 2016 */
2011 spin_lock_irqsave(&ioc->fault_reset_work_lock, flags); 2017 spin_lock_irqsave(&ioc->taskmgmt_lock, flags);
2012 wq = ioc->reset_work_q; 2018 wq = ioc->reset_work_q;
2013 ioc->reset_work_q = NULL; 2019 ioc->reset_work_q = NULL;
2014 spin_unlock_irqrestore(&ioc->fault_reset_work_lock, flags); 2020 spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags);
2015 cancel_delayed_work(&ioc->fault_reset_work); 2021 cancel_delayed_work(&ioc->fault_reset_work);
2016 destroy_workqueue(wq); 2022 destroy_workqueue(wq);
2017 2023
@@ -2234,12 +2240,16 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
2234 ioc->active = 0; 2240 ioc->active = 0;
2235 2241
2236 if (ioc->alt_ioc) { 2242 if (ioc->alt_ioc) {
2237 if (ioc->alt_ioc->active) 2243 if (ioc->alt_ioc->active ||
2244 reason == MPT_HOSTEVENT_IOC_RECOVER) {
2238 reset_alt_ioc_active = 1; 2245 reset_alt_ioc_active = 1;
2239 2246 /* Disable alt-IOC's reply interrupts
2240 /* Disable alt-IOC's reply interrupts (and FreeQ) for a bit ... */ 2247 * (and FreeQ) for a bit
2241 CHIPREG_WRITE32(&ioc->alt_ioc->chip->IntMask, 0xFFFFFFFF); 2248 **/
2242 ioc->alt_ioc->active = 0; 2249 CHIPREG_WRITE32(&ioc->alt_ioc->chip->IntMask,
2250 0xFFFFFFFF);
2251 ioc->alt_ioc->active = 0;
2252 }
2243 } 2253 }
2244 2254
2245 hard = 1; 2255 hard = 1;
@@ -2260,9 +2270,11 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
2260 } 2270 }
2261 2271
2262 } else { 2272 } else {
2263 printk(MYIOC_s_WARN_FMT "NOT READY!\n", ioc->name); 2273 printk(MYIOC_s_WARN_FMT
2274 "NOT READY WARNING!\n", ioc->name);
2264 } 2275 }
2265 return -1; 2276 ret = -1;
2277 goto out;
2266 } 2278 }
2267 2279
2268 /* hard_reset_done = 0 if a soft reset was performed 2280 /* hard_reset_done = 0 if a soft reset was performed
@@ -2272,7 +2284,9 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
2272 if ((rc = MakeIocReady(ioc->alt_ioc, 0, sleepFlag)) == 0) 2284 if ((rc = MakeIocReady(ioc->alt_ioc, 0, sleepFlag)) == 0)
2273 alt_ioc_ready = 1; 2285 alt_ioc_ready = 1;
2274 else 2286 else
2275 printk(MYIOC_s_WARN_FMT "alt_ioc not ready!\n", ioc->alt_ioc->name); 2287 printk(MYIOC_s_WARN_FMT
2288 ": alt-ioc Not ready WARNING!\n",
2289 ioc->alt_ioc->name);
2276 } 2290 }
2277 2291
2278 for (ii=0; ii<5; ii++) { 2292 for (ii=0; ii<5; ii++) {
@@ -2293,7 +2307,8 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
2293 if (alt_ioc_ready) { 2307 if (alt_ioc_ready) {
2294 if ((rc = GetIocFacts(ioc->alt_ioc, sleepFlag, reason)) != 0) { 2308 if ((rc = GetIocFacts(ioc->alt_ioc, sleepFlag, reason)) != 0) {
2295 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT 2309 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT
2296 "Initial Alt IocFacts failed rc=%x\n", ioc->name, rc)); 2310 "Initial Alt IocFacts failed rc=%x\n",
2311 ioc->name, rc));
2297 /* Retry - alt IOC was initialized once 2312 /* Retry - alt IOC was initialized once
2298 */ 2313 */
2299 rc = GetIocFacts(ioc->alt_ioc, sleepFlag, reason); 2314 rc = GetIocFacts(ioc->alt_ioc, sleepFlag, reason);
@@ -2337,16 +2352,20 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
2337 IRQF_SHARED, ioc->name, ioc); 2352 IRQF_SHARED, ioc->name, ioc);
2338 if (rc < 0) { 2353 if (rc < 0) {
2339 printk(MYIOC_s_ERR_FMT "Unable to allocate " 2354 printk(MYIOC_s_ERR_FMT "Unable to allocate "
2340 "interrupt %d!\n", ioc->name, ioc->pcidev->irq); 2355 "interrupt %d!\n",
2356 ioc->name, ioc->pcidev->irq);
2341 if (ioc->msi_enable) 2357 if (ioc->msi_enable)
2342 pci_disable_msi(ioc->pcidev); 2358 pci_disable_msi(ioc->pcidev);
2343 return -EBUSY; 2359 ret = -EBUSY;
2360 goto out;
2344 } 2361 }
2345 irq_allocated = 1; 2362 irq_allocated = 1;
2346 ioc->pci_irq = ioc->pcidev->irq; 2363 ioc->pci_irq = ioc->pcidev->irq;
2347 pci_set_master(ioc->pcidev); /* ?? */ 2364 pci_set_master(ioc->pcidev); /* ?? */
2348 dprintk(ioc, printk(MYIOC_s_INFO_FMT "installed at interrupt " 2365 pci_set_drvdata(ioc->pcidev, ioc);
2349 "%d\n", ioc->name, ioc->pcidev->irq)); 2366 dinitprintk(ioc, printk(MYIOC_s_INFO_FMT
2367 "installed at interrupt %d\n", ioc->name,
2368 ioc->pcidev->irq));
2350 } 2369 }
2351 } 2370 }
2352 2371
@@ -2355,17 +2374,22 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
2355 * init as upper addresses are needed for init. 2374 * init as upper addresses are needed for init.
2356 * If fails, continue with alt-ioc processing 2375 * If fails, continue with alt-ioc processing
2357 */ 2376 */
2377 dinitprintk(ioc, printk(MYIOC_s_INFO_FMT "PrimeIocFifos\n",
2378 ioc->name));
2358 if ((ret == 0) && ((rc = PrimeIocFifos(ioc)) != 0)) 2379 if ((ret == 0) && ((rc = PrimeIocFifos(ioc)) != 0))
2359 ret = -3; 2380 ret = -3;
2360 2381
2361 /* May need to check/upload firmware & data here! 2382 /* May need to check/upload firmware & data here!
2362 * If fails, continue with alt-ioc processing 2383 * If fails, continue with alt-ioc processing
2363 */ 2384 */
2385 dinitprintk(ioc, printk(MYIOC_s_INFO_FMT "SendIocInit\n",
2386 ioc->name));
2364 if ((ret == 0) && ((rc = SendIocInit(ioc, sleepFlag)) != 0)) 2387 if ((ret == 0) && ((rc = SendIocInit(ioc, sleepFlag)) != 0))
2365 ret = -4; 2388 ret = -4;
2366// NEW! 2389// NEW!
2367 if (alt_ioc_ready && ((rc = PrimeIocFifos(ioc->alt_ioc)) != 0)) { 2390 if (alt_ioc_ready && ((rc = PrimeIocFifos(ioc->alt_ioc)) != 0)) {
2368 printk(MYIOC_s_WARN_FMT ": alt_ioc (%d) FIFO mgmt alloc!\n", 2391 printk(MYIOC_s_WARN_FMT
2392 ": alt-ioc (%d) FIFO mgmt alloc WARNING!\n",
2369 ioc->alt_ioc->name, rc); 2393 ioc->alt_ioc->name, rc);
2370 alt_ioc_ready = 0; 2394 alt_ioc_ready = 0;
2371 reset_alt_ioc_active = 0; 2395 reset_alt_ioc_active = 0;
@@ -2375,8 +2399,9 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
2375 if ((rc = SendIocInit(ioc->alt_ioc, sleepFlag)) != 0) { 2399 if ((rc = SendIocInit(ioc->alt_ioc, sleepFlag)) != 0) {
2376 alt_ioc_ready = 0; 2400 alt_ioc_ready = 0;
2377 reset_alt_ioc_active = 0; 2401 reset_alt_ioc_active = 0;
2378 printk(MYIOC_s_WARN_FMT "alt_ioc (%d) init failure!\n", 2402 printk(MYIOC_s_WARN_FMT
2379 ioc->alt_ioc->name, rc); 2403 ": alt-ioc: (%d) init failure WARNING!\n",
2404 ioc->alt_ioc->name, rc);
2380 } 2405 }
2381 } 2406 }
2382 2407
@@ -2457,8 +2482,9 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
2457 mutex_init(&ioc->raid_data.inactive_list_mutex); 2482 mutex_init(&ioc->raid_data.inactive_list_mutex);
2458 INIT_LIST_HEAD(&ioc->raid_data.inactive_list); 2483 INIT_LIST_HEAD(&ioc->raid_data.inactive_list);
2459 2484
2460 if (ioc->bus_type == SAS) { 2485 switch (ioc->bus_type) {
2461 2486
2487 case SAS:
2462 /* clear persistency table */ 2488 /* clear persistency table */
2463 if(ioc->facts.IOCExceptions & 2489 if(ioc->facts.IOCExceptions &
2464 MPI_IOCFACTS_EXCEPT_PERSISTENT_TABLE_FULL) { 2490 MPI_IOCFACTS_EXCEPT_PERSISTENT_TABLE_FULL) {
@@ -2472,8 +2498,15 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
2472 */ 2498 */
2473 mpt_findImVolumes(ioc); 2499 mpt_findImVolumes(ioc);
2474 2500
2475 } else if (ioc->bus_type == FC) { 2501 /* Check, and possibly reset, the coalescing value
2476 if ((ioc->pfacts[0].ProtocolFlags & MPI_PORTFACTS_PROTOCOL_LAN) && 2502 */
2503 mpt_read_ioc_pg_1(ioc);
2504
2505 break;
2506
2507 case FC:
2508 if ((ioc->pfacts[0].ProtocolFlags &
2509 MPI_PORTFACTS_PROTOCOL_LAN) &&
2477 (ioc->lan_cnfg_page0.Header.PageLength == 0)) { 2510 (ioc->lan_cnfg_page0.Header.PageLength == 0)) {
2478 /* 2511 /*
2479 * Pre-fetch the ports LAN MAC address! 2512 * Pre-fetch the ports LAN MAC address!
@@ -2482,11 +2515,14 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
2482 (void) GetLanConfigPages(ioc); 2515 (void) GetLanConfigPages(ioc);
2483 a = (u8*)&ioc->lan_cnfg_page1.HardwareAddressLow; 2516 a = (u8*)&ioc->lan_cnfg_page1.HardwareAddressLow;
2484 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT 2517 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT
2485 "LanAddr = %02X:%02X:%02X:%02X:%02X:%02X\n", 2518 "LanAddr = %02X:%02X:%02X"
2486 ioc->name, a[5], a[4], a[3], a[2], a[1], a[0])); 2519 ":%02X:%02X:%02X\n",
2487 2520 ioc->name, a[5], a[4],
2521 a[3], a[2], a[1], a[0]));
2488 } 2522 }
2489 } else { 2523 break;
2524
2525 case SPI:
2490 /* Get NVRAM and adapter maximums from SPP 0 and 2 2526 /* Get NVRAM and adapter maximums from SPP 0 and 2
2491 */ 2527 */
2492 mpt_GetScsiPortSettings(ioc, 0); 2528 mpt_GetScsiPortSettings(ioc, 0);
@@ -2505,6 +2541,8 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
2505 mpt_read_ioc_pg_1(ioc); 2541 mpt_read_ioc_pg_1(ioc);
2506 2542
2507 mpt_read_ioc_pg_4(ioc); 2543 mpt_read_ioc_pg_4(ioc);
2544
2545 break;
2508 } 2546 }
2509 2547
2510 GetIoUnitPage2(ioc); 2548 GetIoUnitPage2(ioc);
@@ -2586,16 +2624,20 @@ mpt_detect_bound_ports(MPT_ADAPTER *ioc, struct pci_dev *pdev)
2586 if (_pcidev == peer) { 2624 if (_pcidev == peer) {
2587 /* Paranoia checks */ 2625 /* Paranoia checks */
2588 if (ioc->alt_ioc != NULL) { 2626 if (ioc->alt_ioc != NULL) {
2589 printk(MYIOC_s_WARN_FMT "Oops, already bound to %s!\n", 2627 printk(MYIOC_s_WARN_FMT
2590 ioc->name, ioc->alt_ioc->name); 2628 "Oops, already bound (%s <==> %s)!\n",
2629 ioc->name, ioc->name, ioc->alt_ioc->name);
2591 break; 2630 break;
2592 } else if (ioc_srch->alt_ioc != NULL) { 2631 } else if (ioc_srch->alt_ioc != NULL) {
2593 printk(MYIOC_s_WARN_FMT "Oops, already bound to %s!\n", 2632 printk(MYIOC_s_WARN_FMT
2594 ioc_srch->name, ioc_srch->alt_ioc->name); 2633 "Oops, already bound (%s <==> %s)!\n",
2634 ioc_srch->name, ioc_srch->name,
2635 ioc_srch->alt_ioc->name);
2595 break; 2636 break;
2596 } 2637 }
2597 dprintk(ioc, printk(MYIOC_s_INFO_FMT "FOUND! binding to %s\n", 2638 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT
2598 ioc->name, ioc_srch->name)); 2639 "FOUND! binding %s <==> %s\n",
2640 ioc->name, ioc->name, ioc_srch->name));
2599 ioc_srch->alt_ioc = ioc; 2641 ioc_srch->alt_ioc = ioc;
2600 ioc->alt_ioc = ioc_srch; 2642 ioc->alt_ioc = ioc_srch;
2601 } 2643 }
@@ -2615,8 +2657,8 @@ mpt_adapter_disable(MPT_ADAPTER *ioc)
2615 int ret; 2657 int ret;
2616 2658
2617 if (ioc->cached_fw != NULL) { 2659 if (ioc->cached_fw != NULL) {
2618 ddlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "%s: Pushing FW onto " 2660 ddlprintk(ioc, printk(MYIOC_s_DEBUG_FMT
2619 "adapter\n", __func__, ioc->name)); 2661 "%s: Pushing FW onto adapter\n", __func__, ioc->name));
2620 if ((ret = mpt_downloadboot(ioc, (MpiFwHeader_t *) 2662 if ((ret = mpt_downloadboot(ioc, (MpiFwHeader_t *)
2621 ioc->cached_fw, CAN_SLEEP)) < 0) { 2663 ioc->cached_fw, CAN_SLEEP)) < 0) {
2622 printk(MYIOC_s_WARN_FMT 2664 printk(MYIOC_s_WARN_FMT
@@ -2626,10 +2668,13 @@ mpt_adapter_disable(MPT_ADAPTER *ioc)
2626 } 2668 }
2627 2669
2628 /* Disable adapter interrupts! */ 2670 /* Disable adapter interrupts! */
2671 synchronize_irq(ioc->pcidev->irq);
2629 CHIPREG_WRITE32(&ioc->chip->IntMask, 0xFFFFFFFF); 2672 CHIPREG_WRITE32(&ioc->chip->IntMask, 0xFFFFFFFF);
2630 ioc->active = 0; 2673 ioc->active = 0;
2674
2631 /* Clear any lingering interrupt */ 2675 /* Clear any lingering interrupt */
2632 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); 2676 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0);
2677 CHIPREG_READ32(&ioc->chip->IntStatus);
2633 2678
2634 if (ioc->alloc != NULL) { 2679 if (ioc->alloc != NULL) {
2635 sz = ioc->alloc_sz; 2680 sz = ioc->alloc_sz;
@@ -2689,19 +2734,22 @@ mpt_adapter_disable(MPT_ADAPTER *ioc)
2689 if((ret = mpt_host_page_access_control(ioc, 2734 if((ret = mpt_host_page_access_control(ioc,
2690 MPI_DB_HPBAC_FREE_BUFFER, NO_SLEEP)) != 0) { 2735 MPI_DB_HPBAC_FREE_BUFFER, NO_SLEEP)) != 0) {
2691 printk(MYIOC_s_ERR_FMT 2736 printk(MYIOC_s_ERR_FMT
2692 "host page buffers free failed (%d)!\n", 2737 ": %s: host page buffers free failed (%d)!\n",
2693 ioc->name, ret); 2738 ioc->name, __func__, ret);
2694 } 2739 }
2695 dexitprintk(ioc, printk(MYIOC_s_INFO_FMT "HostPageBuffer free @ %p, sz=%d bytes\n", 2740 dexitprintk(ioc, printk(MYIOC_s_DEBUG_FMT
2696 ioc->name, ioc->HostPageBuffer, ioc->HostPageBuffer_sz)); 2741 "HostPageBuffer free @ %p, sz=%d bytes\n",
2742 ioc->name, ioc->HostPageBuffer,
2743 ioc->HostPageBuffer_sz));
2697 pci_free_consistent(ioc->pcidev, ioc->HostPageBuffer_sz, 2744 pci_free_consistent(ioc->pcidev, ioc->HostPageBuffer_sz,
2698 ioc->HostPageBuffer, ioc->HostPageBuffer_dma); 2745 ioc->HostPageBuffer, ioc->HostPageBuffer_dma);
2699 ioc->HostPageBuffer = NULL; 2746 ioc->HostPageBuffer = NULL;
2700 ioc->HostPageBuffer_sz = 0; 2747 ioc->HostPageBuffer_sz = 0;
2701 ioc->alloc_total -= ioc->HostPageBuffer_sz; 2748 ioc->alloc_total -= ioc->HostPageBuffer_sz;
2702 } 2749 }
2703}
2704 2750
2751 pci_set_drvdata(ioc->pcidev, NULL);
2752}
2705/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2753/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2706/** 2754/**
2707 * mpt_adapter_dispose - Free all resources associated with an MPT adapter 2755 * mpt_adapter_dispose - Free all resources associated with an MPT adapter
@@ -2841,8 +2889,12 @@ MakeIocReady(MPT_ADAPTER *ioc, int force, int sleepFlag)
2841 } 2889 }
2842 2890
2843 /* Is it already READY? */ 2891 /* Is it already READY? */
2844 if (!statefault && (ioc_state & MPI_IOC_STATE_MASK) == MPI_IOC_STATE_READY) 2892 if (!statefault &&
2893 ((ioc_state & MPI_IOC_STATE_MASK) == MPI_IOC_STATE_READY)) {
2894 dinitprintk(ioc, printk(MYIOC_s_INFO_FMT
2895 "IOC is in READY state\n", ioc->name));
2845 return 0; 2896 return 0;
2897 }
2846 2898
2847 /* 2899 /*
2848 * Check to see if IOC is in FAULT state. 2900 * Check to see if IOC is in FAULT state.
@@ -2915,8 +2967,9 @@ MakeIocReady(MPT_ADAPTER *ioc, int force, int sleepFlag)
2915 2967
2916 ii++; cntdn--; 2968 ii++; cntdn--;
2917 if (!cntdn) { 2969 if (!cntdn) {
2918 printk(MYIOC_s_ERR_FMT "Wait IOC_READY state timeout(%d)!\n", 2970 printk(MYIOC_s_ERR_FMT
2919 ioc->name, (int)((ii+5)/HZ)); 2971 "Wait IOC_READY state (0x%x) timeout(%d)!\n",
2972 ioc->name, ioc_state, (int)((ii+5)/HZ));
2920 return -ETIME; 2973 return -ETIME;
2921 } 2974 }
2922 2975
@@ -2929,9 +2982,8 @@ MakeIocReady(MPT_ADAPTER *ioc, int force, int sleepFlag)
2929 } 2982 }
2930 2983
2931 if (statefault < 3) { 2984 if (statefault < 3) {
2932 printk(MYIOC_s_INFO_FMT "Recovered from %s\n", 2985 printk(MYIOC_s_INFO_FMT "Recovered from %s\n", ioc->name,
2933 ioc->name, 2986 statefault == 1 ? "stuck handshake" : "IOC FAULT");
2934 statefault==1 ? "stuck handshake" : "IOC FAULT");
2935 } 2987 }
2936 2988
2937 return hard_reset_done; 2989 return hard_reset_done;
@@ -2984,8 +3036,9 @@ GetIocFacts(MPT_ADAPTER *ioc, int sleepFlag, int reason)
2984 3036
2985 /* IOC *must* NOT be in RESET state! */ 3037 /* IOC *must* NOT be in RESET state! */
2986 if (ioc->last_state == MPI_IOC_STATE_RESET) { 3038 if (ioc->last_state == MPI_IOC_STATE_RESET) {
2987 printk(MYIOC_s_ERR_FMT "Can't get IOCFacts NOT READY! (%08x)\n", 3039 printk(KERN_ERR MYNAM
2988 ioc->name, ioc->last_state ); 3040 ": ERROR - Can't get IOCFacts, %s NOT READY! (%08x)\n",
3041 ioc->name, ioc->last_state);
2989 return -44; 3042 return -44;
2990 } 3043 }
2991 3044
@@ -3047,7 +3100,7 @@ GetIocFacts(MPT_ADAPTER *ioc, int sleepFlag, int reason)
3047 * Old: u16{Major(4),Minor(4),SubMinor(8)} 3100 * Old: u16{Major(4),Minor(4),SubMinor(8)}
3048 * New: u32{Major(8),Minor(8),Unit(8),Dev(8)} 3101 * New: u32{Major(8),Minor(8),Unit(8),Dev(8)}
3049 */ 3102 */
3050 if (facts->MsgVersion < 0x0102) { 3103 if (facts->MsgVersion < MPI_VERSION_01_02) {
3051 /* 3104 /*
3052 * Handle old FC f/w style, convert to new... 3105 * Handle old FC f/w style, convert to new...
3053 */ 3106 */
@@ -3059,9 +3112,11 @@ GetIocFacts(MPT_ADAPTER *ioc, int sleepFlag, int reason)
3059 facts->FWVersion.Word = le32_to_cpu(facts->FWVersion.Word); 3112 facts->FWVersion.Word = le32_to_cpu(facts->FWVersion.Word);
3060 3113
3061 facts->ProductID = le16_to_cpu(facts->ProductID); 3114 facts->ProductID = le16_to_cpu(facts->ProductID);
3115
3062 if ((ioc->facts.ProductID & MPI_FW_HEADER_PID_PROD_MASK) 3116 if ((ioc->facts.ProductID & MPI_FW_HEADER_PID_PROD_MASK)
3063 > MPI_FW_HEADER_PID_PROD_TARGET_SCSI) 3117 > MPI_FW_HEADER_PID_PROD_TARGET_SCSI)
3064 ioc->ir_firmware = 1; 3118 ioc->ir_firmware = 1;
3119
3065 facts->CurrentHostMfaHighAddr = 3120 facts->CurrentHostMfaHighAddr =
3066 le32_to_cpu(facts->CurrentHostMfaHighAddr); 3121 le32_to_cpu(facts->CurrentHostMfaHighAddr);
3067 facts->GlobalCredits = le16_to_cpu(facts->GlobalCredits); 3122 facts->GlobalCredits = le16_to_cpu(facts->GlobalCredits);
@@ -3077,7 +3132,7 @@ GetIocFacts(MPT_ADAPTER *ioc, int sleepFlag, int reason)
3077 * to 14 in MPI-1.01.0x. 3132 * to 14 in MPI-1.01.0x.
3078 */ 3133 */
3079 if (facts->MsgLength >= (offsetof(IOCFactsReply_t,FWImageSize) + 7)/4 && 3134 if (facts->MsgLength >= (offsetof(IOCFactsReply_t,FWImageSize) + 7)/4 &&
3080 facts->MsgVersion > 0x0100) { 3135 facts->MsgVersion > MPI_VERSION_01_00) {
3081 facts->FWImageSize = le32_to_cpu(facts->FWImageSize); 3136 facts->FWImageSize = le32_to_cpu(facts->FWImageSize);
3082 } 3137 }
3083 3138
@@ -3259,6 +3314,7 @@ SendIocInit(MPT_ADAPTER *ioc, int sleepFlag)
3259 3314
3260 ioc_init.MaxDevices = (U8)ioc->devices_per_bus; 3315 ioc_init.MaxDevices = (U8)ioc->devices_per_bus;
3261 ioc_init.MaxBuses = (U8)ioc->number_of_buses; 3316 ioc_init.MaxBuses = (U8)ioc->number_of_buses;
3317
3262 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "facts.MsgVersion=%x\n", 3318 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "facts.MsgVersion=%x\n",
3263 ioc->name, ioc->facts.MsgVersion)); 3319 ioc->name, ioc->facts.MsgVersion));
3264 if (ioc->facts.MsgVersion >= MPI_VERSION_01_05) { 3320 if (ioc->facts.MsgVersion >= MPI_VERSION_01_05) {
@@ -3273,7 +3329,7 @@ SendIocInit(MPT_ADAPTER *ioc, int sleepFlag)
3273 } 3329 }
3274 ioc_init.ReplyFrameSize = cpu_to_le16(ioc->reply_sz); /* in BYTES */ 3330 ioc_init.ReplyFrameSize = cpu_to_le16(ioc->reply_sz); /* in BYTES */
3275 3331
3276 if (sizeof(dma_addr_t) == sizeof(u64)) { 3332 if (ioc->sg_addr_size == sizeof(u64)) {
3277 /* Save the upper 32-bits of the request 3333 /* Save the upper 32-bits of the request
3278 * (reply) and sense buffers. 3334 * (reply) and sense buffers.
3279 */ 3335 */
@@ -3526,29 +3582,29 @@ mpt_do_upload(MPT_ADAPTER *ioc, int sleepFlag)
3526 ii = mpt_handshake_req_reply_wait(ioc, request_size, (u32 *)prequest, 3582 ii = mpt_handshake_req_reply_wait(ioc, request_size, (u32 *)prequest,
3527 reply_sz, (u16 *)preply, 65 /*seconds*/, sleepFlag); 3583 reply_sz, (u16 *)preply, 65 /*seconds*/, sleepFlag);
3528 3584
3529 dinitprintk(ioc, printk(MYIOC_s_INFO_FMT ": FW Upload completed rc=%x \n", ioc->name, ii)); 3585 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "FW Upload completed "
3586 "rc=%x \n", ioc->name, ii));
3530 3587
3531 cmdStatus = -EFAULT; 3588 cmdStatus = -EFAULT;
3532 if (ii == 0) { 3589 if (ii == 0) {
3533 /* Handshake transfer was complete and successful. 3590 /* Handshake transfer was complete and successful.
3534 * Check the Reply Frame. 3591 * Check the Reply Frame.
3535 */ 3592 */
3536 int status, transfer_sz; 3593 int status;
3537 status = le16_to_cpu(preply->IOCStatus); 3594 status = le16_to_cpu(preply->IOCStatus) &
3538 if (status == MPI_IOCSTATUS_SUCCESS) { 3595 MPI_IOCSTATUS_MASK;
3539 transfer_sz = le32_to_cpu(preply->ActualImageSize); 3596 if (status == MPI_IOCSTATUS_SUCCESS &&
3540 if (transfer_sz == sz) 3597 ioc->facts.FWImageSize ==
3598 le32_to_cpu(preply->ActualImageSize))
3541 cmdStatus = 0; 3599 cmdStatus = 0;
3542 }
3543 } 3600 }
3544 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT ": do_upload cmdStatus=%d \n", 3601 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT ": do_upload cmdStatus=%d \n",
3545 ioc->name, cmdStatus)); 3602 ioc->name, cmdStatus));
3546 3603
3547 3604
3548 if (cmdStatus) { 3605 if (cmdStatus) {
3549 3606 ddlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "fw upload failed, "
3550 ddlprintk(ioc, printk(MYIOC_s_DEBUG_FMT ": fw upload failed, freeing image \n", 3607 "freeing image \n", ioc->name));
3551 ioc->name));
3552 mpt_free_fw_memory(ioc); 3608 mpt_free_fw_memory(ioc);
3553 } 3609 }
3554 kfree(prequest); 3610 kfree(prequest);
@@ -3872,6 +3928,10 @@ mpt_diag_reset(MPT_ADAPTER *ioc, int ignore, int sleepFlag)
3872 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); 3928 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0);
3873 3929
3874 if (ioc->pcidev->device == MPI_MANUFACTPAGE_DEVID_SAS1078) { 3930 if (ioc->pcidev->device == MPI_MANUFACTPAGE_DEVID_SAS1078) {
3931
3932 if (!ignore)
3933 return 0;
3934
3875 drsprintk(ioc, printk(MYIOC_s_WARN_FMT "%s: Doorbell=%p; 1078 reset " 3935 drsprintk(ioc, printk(MYIOC_s_WARN_FMT "%s: Doorbell=%p; 1078 reset "
3876 "address=%p\n", ioc->name, __func__, 3936 "address=%p\n", ioc->name, __func__,
3877 &ioc->chip->Doorbell, &ioc->chip->Reset_1078)); 3937 &ioc->chip->Doorbell, &ioc->chip->Reset_1078));
@@ -3889,6 +3949,7 @@ mpt_diag_reset(MPT_ADAPTER *ioc, int ignore, int sleepFlag)
3889 "looking for READY STATE: doorbell=%x" 3949 "looking for READY STATE: doorbell=%x"
3890 " count=%d\n", 3950 " count=%d\n",
3891 ioc->name, doorbell, count)); 3951 ioc->name, doorbell, count));
3952
3892 if (doorbell == MPI_IOC_STATE_READY) { 3953 if (doorbell == MPI_IOC_STATE_READY) {
3893 return 1; 3954 return 1;
3894 } 3955 }
@@ -4039,6 +4100,10 @@ mpt_diag_reset(MPT_ADAPTER *ioc, int ignore, int sleepFlag)
4039 doorbell = CHIPREG_READ32(&ioc->chip->Doorbell); 4100 doorbell = CHIPREG_READ32(&ioc->chip->Doorbell);
4040 doorbell &= MPI_IOC_STATE_MASK; 4101 doorbell &= MPI_IOC_STATE_MASK;
4041 4102
4103 drsprintk(ioc, printk(MYIOC_s_DEBUG_FMT
4104 "looking for READY STATE: doorbell=%x"
4105 " count=%d\n", ioc->name, doorbell, count));
4106
4042 if (doorbell == MPI_IOC_STATE_READY) { 4107 if (doorbell == MPI_IOC_STATE_READY) {
4043 break; 4108 break;
4044 } 4109 }
@@ -4050,6 +4115,11 @@ mpt_diag_reset(MPT_ADAPTER *ioc, int ignore, int sleepFlag)
4050 mdelay (1000); 4115 mdelay (1000);
4051 } 4116 }
4052 } 4117 }
4118
4119 if (doorbell != MPI_IOC_STATE_READY)
4120 printk(MYIOC_s_ERR_FMT "Failed to come READY "
4121 "after reset! IocState=%x", ioc->name,
4122 doorbell);
4053 } 4123 }
4054 } 4124 }
4055 4125
@@ -4168,8 +4238,9 @@ SendIocReset(MPT_ADAPTER *ioc, u8 reset_type, int sleepFlag)
4168 if (sleepFlag != CAN_SLEEP) 4238 if (sleepFlag != CAN_SLEEP)
4169 count *= 10; 4239 count *= 10;
4170 4240
4171 printk(MYIOC_s_ERR_FMT "Wait IOC_READY state timeout(%d)!\n", 4241 printk(MYIOC_s_ERR_FMT
4172 ioc->name, (int)((count+5)/HZ)); 4242 "Wait IOC_READY state (0x%x) timeout(%d)!\n",
4243 ioc->name, state, (int)((count+5)/HZ));
4173 return -ETIME; 4244 return -ETIME;
4174 } 4245 }
4175 4246
@@ -4255,8 +4326,13 @@ initChainBuffers(MPT_ADAPTER *ioc)
4255 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "num_sge=%d numSGE=%d\n", 4326 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "num_sge=%d numSGE=%d\n",
4256 ioc->name, num_sge, numSGE)); 4327 ioc->name, num_sge, numSGE));
4257 4328
4258 if ( numSGE > MPT_SCSI_SG_DEPTH ) 4329 if (ioc->bus_type == FC) {
4259 numSGE = MPT_SCSI_SG_DEPTH; 4330 if (numSGE > MPT_SCSI_FC_SG_DEPTH)
4331 numSGE = MPT_SCSI_FC_SG_DEPTH;
4332 } else {
4333 if (numSGE > MPT_SCSI_SG_DEPTH)
4334 numSGE = MPT_SCSI_SG_DEPTH;
4335 }
4260 4336
4261 num_chain = 1; 4337 num_chain = 1;
4262 while (numSGE - num_sge > 0) { 4338 while (numSGE - num_sge > 0) {
@@ -4493,6 +4569,7 @@ PrimeIocFifos(MPT_ADAPTER *ioc)
4493 return 0; 4569 return 0;
4494 4570
4495out_fail: 4571out_fail:
4572
4496 if (ioc->alloc != NULL) { 4573 if (ioc->alloc != NULL) {
4497 sz = ioc->alloc_sz; 4574 sz = ioc->alloc_sz;
4498 pci_free_consistent(ioc->pcidev, 4575 pci_free_consistent(ioc->pcidev,
@@ -5610,17 +5687,20 @@ mpt_inactive_raid_volumes(MPT_ADAPTER *ioc, u8 channel, u8 id)
5610 * -ENOMEM if pci_alloc failed 5687 * -ENOMEM if pci_alloc failed
5611 **/ 5688 **/
5612int 5689int
5613mpt_raid_phys_disk_pg0(MPT_ADAPTER *ioc, u8 phys_disk_num, pRaidPhysDiskPage0_t phys_disk) 5690mpt_raid_phys_disk_pg0(MPT_ADAPTER *ioc, u8 phys_disk_num,
5691 RaidPhysDiskPage0_t *phys_disk)
5614{ 5692{
5615 CONFIGPARMS cfg; 5693 CONFIGPARMS cfg;
5616 ConfigPageHeader_t hdr; 5694 ConfigPageHeader_t hdr;
5617 dma_addr_t dma_handle; 5695 dma_addr_t dma_handle;
5618 pRaidPhysDiskPage0_t buffer = NULL; 5696 pRaidPhysDiskPage0_t buffer = NULL;
5619 int rc; 5697 int rc;
5620 5698
5621 memset(&cfg, 0 , sizeof(CONFIGPARMS)); 5699 memset(&cfg, 0 , sizeof(CONFIGPARMS));
5622 memset(&hdr, 0 , sizeof(ConfigPageHeader_t)); 5700 memset(&hdr, 0 , sizeof(ConfigPageHeader_t));
5701 memset(phys_disk, 0, sizeof(RaidPhysDiskPage0_t));
5623 5702
5703 hdr.PageVersion = MPI_RAIDPHYSDISKPAGE0_PAGEVERSION;
5624 hdr.PageType = MPI_CONFIG_PAGETYPE_RAID_PHYSDISK; 5704 hdr.PageType = MPI_CONFIG_PAGETYPE_RAID_PHYSDISK;
5625 cfg.cfghdr.hdr = &hdr; 5705 cfg.cfghdr.hdr = &hdr;
5626 cfg.physAddr = -1; 5706 cfg.physAddr = -1;
@@ -6074,7 +6154,8 @@ mpt_config(MPT_ADAPTER *ioc, CONFIGPARMS *pCfg)
6074 int ret; 6154 int ret;
6075 u8 page_type = 0, extend_page; 6155 u8 page_type = 0, extend_page;
6076 unsigned long timeleft; 6156 unsigned long timeleft;
6077 int in_isr; 6157 unsigned long flags;
6158 int in_isr;
6078 u8 issue_hard_reset = 0; 6159 u8 issue_hard_reset = 0;
6079 u8 retry_count = 0; 6160 u8 retry_count = 0;
6080 6161
@@ -6086,7 +6167,17 @@ mpt_config(MPT_ADAPTER *ioc, CONFIGPARMS *pCfg)
6086 dcprintk(ioc, printk(MYIOC_s_WARN_FMT "Config request not allowed in ISR context!\n", 6167 dcprintk(ioc, printk(MYIOC_s_WARN_FMT "Config request not allowed in ISR context!\n",
6087 ioc->name)); 6168 ioc->name));
6088 return -EPERM; 6169 return -EPERM;
6170 }
6171
6172 /* don't send a config page during diag reset */
6173 spin_lock_irqsave(&ioc->taskmgmt_lock, flags);
6174 if (ioc->ioc_reset_in_progress) {
6175 dfailprintk(ioc, printk(MYIOC_s_DEBUG_FMT
6176 "%s: busy with host reset\n", ioc->name, __func__));
6177 spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags);
6178 return -EBUSY;
6089 } 6179 }
6180 spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags);
6090 6181
6091 /* don't send if no chance of success */ 6182 /* don't send if no chance of success */
6092 if (!ioc->active || 6183 if (!ioc->active ||
@@ -6270,6 +6361,12 @@ mpt_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
6270 MPT_MGMT_STATUS_DID_IOCRESET; 6361 MPT_MGMT_STATUS_DID_IOCRESET;
6271 complete(&ioc->mptbase_cmds.done); 6362 complete(&ioc->mptbase_cmds.done);
6272 } 6363 }
6364/* wake up taskmgmt_cmds */
6365 if (ioc->taskmgmt_cmds.status & MPT_MGMT_STATUS_PENDING) {
6366 ioc->taskmgmt_cmds.status |=
6367 MPT_MGMT_STATUS_DID_IOCRESET;
6368 complete(&ioc->taskmgmt_cmds.done);
6369 }
6273 break; 6370 break;
6274 default: 6371 default:
6275 break; 6372 break;
@@ -6690,7 +6787,9 @@ int
6690mpt_HardResetHandler(MPT_ADAPTER *ioc, int sleepFlag) 6787mpt_HardResetHandler(MPT_ADAPTER *ioc, int sleepFlag)
6691{ 6788{
6692 int rc; 6789 int rc;
6790 u8 cb_idx;
6693 unsigned long flags; 6791 unsigned long flags;
6792 unsigned long time_count;
6694 6793
6695 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "HardResetHandler Entered!\n", ioc->name)); 6794 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "HardResetHandler Entered!\n", ioc->name));
6696#ifdef MFCNT 6795#ifdef MFCNT
@@ -6721,30 +6820,24 @@ mpt_HardResetHandler(MPT_ADAPTER *ioc, int sleepFlag)
6721 * Prevents timeouts occurring during a diagnostic reset...very bad. 6820 * Prevents timeouts occurring during a diagnostic reset...very bad.
6722 * For all other protocol drivers, this is a no-op. 6821 * For all other protocol drivers, this is a no-op.
6723 */ 6822 */
6724 { 6823 for (cb_idx = MPT_MAX_PROTOCOL_DRIVERS-1; cb_idx; cb_idx--) {
6725 u8 cb_idx; 6824 if (MptResetHandlers[cb_idx]) {
6726 int r = 0; 6825 mpt_signal_reset(cb_idx, ioc, MPT_IOC_SETUP_RESET);
6727 6826 if (ioc->alt_ioc)
6728 for (cb_idx = MPT_MAX_PROTOCOL_DRIVERS-1; cb_idx; cb_idx--) { 6827 mpt_signal_reset(cb_idx, ioc->alt_ioc,
6729 if (MptResetHandlers[cb_idx]) { 6828 MPT_IOC_SETUP_RESET);
6730 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Calling IOC reset_setup handler #%d\n",
6731 ioc->name, cb_idx));
6732 r += mpt_signal_reset(cb_idx, ioc, MPT_IOC_SETUP_RESET);
6733 if (ioc->alt_ioc) {
6734 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Calling alt-%s setup reset handler #%d\n",
6735 ioc->name, ioc->alt_ioc->name, cb_idx));
6736 r += mpt_signal_reset(cb_idx, ioc->alt_ioc, MPT_IOC_SETUP_RESET);
6737 }
6738 }
6739 } 6829 }
6740 } 6830 }
6741 6831
6742 if ((rc = mpt_do_ioc_recovery(ioc, MPT_HOSTEVENT_IOC_RECOVER, sleepFlag)) != 0) { 6832 time_count = jiffies;
6743 printk(MYIOC_s_WARN_FMT "Cannot recover rc = %d!\n", ioc->name, rc); 6833 rc = mpt_do_ioc_recovery(ioc, MPT_HOSTEVENT_IOC_RECOVER, sleepFlag);
6834 if (rc != 0) {
6835 printk(KERN_WARNING MYNAM
6836 ": WARNING - (%d) Cannot recover %s\n", rc, ioc->name);
6837 } else {
6838 if (ioc->hard_resets < -1)
6839 ioc->hard_resets++;
6744 } 6840 }
6745 ioc->reload_fw = 0;
6746 if (ioc->alt_ioc)
6747 ioc->alt_ioc->reload_fw = 0;
6748 6841
6749 spin_lock_irqsave(&ioc->taskmgmt_lock, flags); 6842 spin_lock_irqsave(&ioc->taskmgmt_lock, flags);
6750 ioc->ioc_reset_in_progress = 0; 6843 ioc->ioc_reset_in_progress = 0;
@@ -6757,16 +6850,27 @@ mpt_HardResetHandler(MPT_ADAPTER *ioc, int sleepFlag)
6757 } 6850 }
6758 spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); 6851 spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags);
6759 6852
6760 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "HardResetHandler rc = %d!\n", ioc->name, rc)); 6853 dtmprintk(ioc,
6854 printk(MYIOC_s_DEBUG_FMT
6855 "HardResetHandler: completed (%d seconds): %s\n", ioc->name,
6856 jiffies_to_msecs(jiffies - time_count)/1000, ((rc == 0) ?
6857 "SUCCESS" : "FAILED")));
6761 6858
6762 return rc; 6859 return rc;
6763} 6860}
6764 6861
6765/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 6862#ifdef CONFIG_FUSION_LOGGING
6766static void 6863static void
6767EventDescriptionStr(u8 event, u32 evData0, char *evStr) 6864mpt_display_event_info(MPT_ADAPTER *ioc, EventNotificationReply_t *pEventReply)
6768{ 6865{
6769 char *ds = NULL; 6866 char *ds = NULL;
6867 u32 evData0;
6868 int ii;
6869 u8 event;
6870 char *evStr = ioc->evStr;
6871
6872 event = le32_to_cpu(pEventReply->Event) & 0xFF;
6873 evData0 = le32_to_cpu(pEventReply->Data[0]);
6770 6874
6771 switch(event) { 6875 switch(event) {
6772 case MPI_EVENT_NONE: 6876 case MPI_EVENT_NONE:
@@ -6800,9 +6904,9 @@ EventDescriptionStr(u8 event, u32 evData0, char *evStr)
6800 if (evData0 == MPI_EVENT_LOOP_STATE_CHANGE_LIP) 6904 if (evData0 == MPI_EVENT_LOOP_STATE_CHANGE_LIP)
6801 ds = "Loop State(LIP) Change"; 6905 ds = "Loop State(LIP) Change";
6802 else if (evData0 == MPI_EVENT_LOOP_STATE_CHANGE_LPE) 6906 else if (evData0 == MPI_EVENT_LOOP_STATE_CHANGE_LPE)
6803 ds = "Loop State(LPE) Change"; /* ??? */ 6907 ds = "Loop State(LPE) Change";
6804 else 6908 else
6805 ds = "Loop State(LPB) Change"; /* ??? */ 6909 ds = "Loop State(LPB) Change";
6806 break; 6910 break;
6807 case MPI_EVENT_LOGOUT: 6911 case MPI_EVENT_LOGOUT:
6808 ds = "Logout"; 6912 ds = "Logout";
@@ -7002,28 +7106,53 @@ EventDescriptionStr(u8 event, u32 evData0, char *evStr)
7002 } 7106 }
7003 case MPI_EVENT_IR2: 7107 case MPI_EVENT_IR2:
7004 { 7108 {
7109 u8 id = (u8)(evData0);
7110 u8 channel = (u8)(evData0 >> 8);
7111 u8 phys_num = (u8)(evData0 >> 24);
7005 u8 ReasonCode = (u8)(evData0 >> 16); 7112 u8 ReasonCode = (u8)(evData0 >> 16);
7113
7006 switch (ReasonCode) { 7114 switch (ReasonCode) {
7007 case MPI_EVENT_IR2_RC_LD_STATE_CHANGED: 7115 case MPI_EVENT_IR2_RC_LD_STATE_CHANGED:
7008 ds = "IR2: LD State Changed"; 7116 snprintf(evStr, EVENT_DESCR_STR_SZ,
7117 "IR2: LD State Changed: "
7118 "id=%d channel=%d phys_num=%d",
7119 id, channel, phys_num);
7009 break; 7120 break;
7010 case MPI_EVENT_IR2_RC_PD_STATE_CHANGED: 7121 case MPI_EVENT_IR2_RC_PD_STATE_CHANGED:
7011 ds = "IR2: PD State Changed"; 7122 snprintf(evStr, EVENT_DESCR_STR_SZ,
7123 "IR2: PD State Changed "
7124 "id=%d channel=%d phys_num=%d",
7125 id, channel, phys_num);
7012 break; 7126 break;
7013 case MPI_EVENT_IR2_RC_BAD_BLOCK_TABLE_FULL: 7127 case MPI_EVENT_IR2_RC_BAD_BLOCK_TABLE_FULL:
7014 ds = "IR2: Bad Block Table Full"; 7128 snprintf(evStr, EVENT_DESCR_STR_SZ,
7129 "IR2: Bad Block Table Full: "
7130 "id=%d channel=%d phys_num=%d",
7131 id, channel, phys_num);
7015 break; 7132 break;
7016 case MPI_EVENT_IR2_RC_PD_INSERTED: 7133 case MPI_EVENT_IR2_RC_PD_INSERTED:
7017 ds = "IR2: PD Inserted"; 7134 snprintf(evStr, EVENT_DESCR_STR_SZ,
7135 "IR2: PD Inserted: "
7136 "id=%d channel=%d phys_num=%d",
7137 id, channel, phys_num);
7018 break; 7138 break;
7019 case MPI_EVENT_IR2_RC_PD_REMOVED: 7139 case MPI_EVENT_IR2_RC_PD_REMOVED:
7020 ds = "IR2: PD Removed"; 7140 snprintf(evStr, EVENT_DESCR_STR_SZ,
7141 "IR2: PD Removed: "
7142 "id=%d channel=%d phys_num=%d",
7143 id, channel, phys_num);
7021 break; 7144 break;
7022 case MPI_EVENT_IR2_RC_FOREIGN_CFG_DETECTED: 7145 case MPI_EVENT_IR2_RC_FOREIGN_CFG_DETECTED:
7023 ds = "IR2: Foreign CFG Detected"; 7146 snprintf(evStr, EVENT_DESCR_STR_SZ,
7147 "IR2: Foreign CFG Detected: "
7148 "id=%d channel=%d phys_num=%d",
7149 id, channel, phys_num);
7024 break; 7150 break;
7025 case MPI_EVENT_IR2_RC_REBUILD_MEDIUM_ERROR: 7151 case MPI_EVENT_IR2_RC_REBUILD_MEDIUM_ERROR:
7026 ds = "IR2: Rebuild Medium Error"; 7152 snprintf(evStr, EVENT_DESCR_STR_SZ,
7153 "IR2: Rebuild Medium Error: "
7154 "id=%d channel=%d phys_num=%d",
7155 id, channel, phys_num);
7027 break; 7156 break;
7028 default: 7157 default:
7029 ds = "IR2"; 7158 ds = "IR2";
@@ -7059,13 +7188,18 @@ EventDescriptionStr(u8 event, u32 evData0, char *evStr)
7059 case MPI_EVENT_SAS_INIT_DEVICE_STATUS_CHANGE: 7188 case MPI_EVENT_SAS_INIT_DEVICE_STATUS_CHANGE:
7060 { 7189 {
7061 u8 reason = (u8)(evData0); 7190 u8 reason = (u8)(evData0);
7062 u8 port_num = (u8)(evData0 >> 8);
7063 u16 handle = le16_to_cpu(evData0 >> 16);
7064 7191
7065 snprintf(evStr, EVENT_DESCR_STR_SZ, 7192 switch (reason) {
7066 "SAS Initiator Device Status Change: reason=0x%02x " 7193 case MPI_EVENT_SAS_INIT_RC_ADDED:
7067 "port=%d handle=0x%04x", 7194 ds = "SAS Initiator Status Change: Added";
7068 reason, port_num, handle); 7195 break;
7196 case MPI_EVENT_SAS_INIT_RC_REMOVED:
7197 ds = "SAS Initiator Status Change: Deleted";
7198 break;
7199 default:
7200 ds = "SAS Initiator Status Change";
7201 break;
7202 }
7069 break; 7203 break;
7070 } 7204 }
7071 7205
@@ -7113,6 +7247,24 @@ EventDescriptionStr(u8 event, u32 evData0, char *evStr)
7113 break; 7247 break;
7114 } 7248 }
7115 7249
7250 case MPI_EVENT_SAS_EXPANDER_STATUS_CHANGE:
7251 {
7252 u8 reason = (u8)(evData0);
7253
7254 switch (reason) {
7255 case MPI_EVENT_SAS_EXP_RC_ADDED:
7256 ds = "Expander Status Change: Added";
7257 break;
7258 case MPI_EVENT_SAS_EXP_RC_NOT_RESPONDING:
7259 ds = "Expander Status Change: Deleted";
7260 break;
7261 default:
7262 ds = "Expander Status Change";
7263 break;
7264 }
7265 break;
7266 }
7267
7116 /* 7268 /*
7117 * MPT base "custom" events may be added here... 7269 * MPT base "custom" events may be added here...
7118 */ 7270 */
@@ -7122,8 +7274,20 @@ EventDescriptionStr(u8 event, u32 evData0, char *evStr)
7122 } 7274 }
7123 if (ds) 7275 if (ds)
7124 strncpy(evStr, ds, EVENT_DESCR_STR_SZ); 7276 strncpy(evStr, ds, EVENT_DESCR_STR_SZ);
7125}
7126 7277
7278
7279 devtprintk(ioc, printk(MYIOC_s_DEBUG_FMT
7280 "MPT event:(%02Xh) : %s\n",
7281 ioc->name, event, evStr));
7282
7283 devtverboseprintk(ioc, printk(KERN_DEBUG MYNAM
7284 ": Event data:\n"));
7285 for (ii = 0; ii < le16_to_cpu(pEventReply->EventDataLength); ii++)
7286 devtverboseprintk(ioc, printk(" %08x",
7287 le32_to_cpu(pEventReply->Data[ii])));
7288 devtverboseprintk(ioc, printk(KERN_DEBUG "\n"));
7289}
7290#endif
7127/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 7291/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
7128/** 7292/**
7129 * ProcessEventNotification - Route EventNotificationReply to all event handlers 7293 * ProcessEventNotification - Route EventNotificationReply to all event handlers
@@ -7140,37 +7304,24 @@ ProcessEventNotification(MPT_ADAPTER *ioc, EventNotificationReply_t *pEventReply
7140{ 7304{
7141 u16 evDataLen; 7305 u16 evDataLen;
7142 u32 evData0 = 0; 7306 u32 evData0 = 0;
7143// u32 evCtx;
7144 int ii; 7307 int ii;
7145 u8 cb_idx; 7308 u8 cb_idx;
7146 int r = 0; 7309 int r = 0;
7147 int handlers = 0; 7310 int handlers = 0;
7148 char evStr[EVENT_DESCR_STR_SZ];
7149 u8 event; 7311 u8 event;
7150 7312
7151 /* 7313 /*
7152 * Do platform normalization of values 7314 * Do platform normalization of values
7153 */ 7315 */
7154 event = le32_to_cpu(pEventReply->Event) & 0xFF; 7316 event = le32_to_cpu(pEventReply->Event) & 0xFF;
7155// evCtx = le32_to_cpu(pEventReply->EventContext);
7156 evDataLen = le16_to_cpu(pEventReply->EventDataLength); 7317 evDataLen = le16_to_cpu(pEventReply->EventDataLength);
7157 if (evDataLen) { 7318 if (evDataLen) {
7158 evData0 = le32_to_cpu(pEventReply->Data[0]); 7319 evData0 = le32_to_cpu(pEventReply->Data[0]);
7159 } 7320 }
7160 7321
7161 EventDescriptionStr(event, evData0, evStr);
7162 devtprintk(ioc, printk(MYIOC_s_DEBUG_FMT "MPT event:(%02Xh) : %s\n",
7163 ioc->name,
7164 event,
7165 evStr));
7166
7167#ifdef CONFIG_FUSION_LOGGING 7322#ifdef CONFIG_FUSION_LOGGING
7168 devtverboseprintk(ioc, printk(MYIOC_s_DEBUG_FMT 7323 if (evDataLen)
7169 ": Event data:\n", ioc->name)); 7324 mpt_display_event_info(ioc, pEventReply);
7170 for (ii = 0; ii < evDataLen; ii++)
7171 devtverboseprintk(ioc, printk(" %08x",
7172 le32_to_cpu(pEventReply->Data[ii])));
7173 devtverboseprintk(ioc, printk("\n"));
7174#endif 7325#endif
7175 7326
7176 /* 7327 /*
@@ -7225,8 +7376,9 @@ ProcessEventNotification(MPT_ADAPTER *ioc, EventNotificationReply_t *pEventReply
7225 */ 7376 */
7226 for (cb_idx = MPT_MAX_PROTOCOL_DRIVERS-1; cb_idx; cb_idx--) { 7377 for (cb_idx = MPT_MAX_PROTOCOL_DRIVERS-1; cb_idx; cb_idx--) {
7227 if (MptEvHandlers[cb_idx]) { 7378 if (MptEvHandlers[cb_idx]) {
7228 devtverboseprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Routing Event to event handler #%d\n", 7379 devtverboseprintk(ioc, printk(MYIOC_s_DEBUG_FMT
7229 ioc->name, cb_idx)); 7380 "Routing Event to event handler #%d\n",
7381 ioc->name, cb_idx));
7230 r += (*(MptEvHandlers[cb_idx]))(ioc, pEventReply); 7382 r += (*(MptEvHandlers[cb_idx]))(ioc, pEventReply);
7231 handlers++; 7383 handlers++;
7232 } 7384 }
@@ -7310,8 +7462,6 @@ mpt_spi_log_info(MPT_ADAPTER *ioc, u32 log_info)
7310 switch (info) { 7462 switch (info) {
7311 case 0x00010000: 7463 case 0x00010000:
7312 desc = "bug! MID not found"; 7464 desc = "bug! MID not found";
7313 if (ioc->reload_fw == 0)
7314 ioc->reload_fw++;
7315 break; 7465 break;
7316 7466
7317 case 0x00020000: 7467 case 0x00020000: