aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/message/fusion/mptbase.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/message/fusion/mptbase.c')
-rw-r--r--drivers/message/fusion/mptbase.c209
1 files changed, 53 insertions, 156 deletions
diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index 59690cbabfca..12dd8d493ee2 100644
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -1185,7 +1185,6 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1185 ioc->pcidev = pdev; 1185 ioc->pcidev = pdev;
1186 ioc->diagPending = 0; 1186 ioc->diagPending = 0;
1187 spin_lock_init(&ioc->diagLock); 1187 spin_lock_init(&ioc->diagLock);
1188 spin_lock_init(&ioc->fc_rescan_work_lock);
1189 spin_lock_init(&ioc->initializing_hba_lock); 1188 spin_lock_init(&ioc->initializing_hba_lock);
1190 1189
1191 /* Initialize the event logging. 1190 /* Initialize the event logging.
@@ -1383,30 +1382,6 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1383 /* Set lookup ptr. */ 1382 /* Set lookup ptr. */
1384 list_add_tail(&ioc->list, &ioc_list); 1383 list_add_tail(&ioc->list, &ioc_list);
1385 1384
1386 ioc->pci_irq = -1;
1387 if (pdev->irq) {
1388 if (mpt_msi_enable && !pci_enable_msi(pdev))
1389 printk(MYIOC_s_INFO_FMT "PCI-MSI enabled\n", ioc->name);
1390
1391 r = request_irq(pdev->irq, mpt_interrupt, SA_SHIRQ, ioc->name, ioc);
1392
1393 if (r < 0) {
1394 printk(MYIOC_s_ERR_FMT "Unable to allocate interrupt %d!\n",
1395 ioc->name, pdev->irq);
1396 list_del(&ioc->list);
1397 iounmap(mem);
1398 kfree(ioc);
1399 return -EBUSY;
1400 }
1401
1402 ioc->pci_irq = pdev->irq;
1403
1404 pci_set_master(pdev); /* ?? */
1405 pci_set_drvdata(pdev, ioc);
1406
1407 dprintk((KERN_INFO MYNAM ": %s installed at interrupt %d\n", ioc->name, pdev->irq));
1408 }
1409
1410 /* Check for "bound ports" (929, 929X, 1030, 1035) to reduce redundant resets. 1385 /* Check for "bound ports" (929, 929X, 1030, 1035) to reduce redundant resets.
1411 */ 1386 */
1412 mpt_detect_bound_ports(ioc, pdev); 1387 mpt_detect_bound_ports(ioc, pdev);
@@ -1416,11 +1391,7 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1416 printk(KERN_WARNING MYNAM 1391 printk(KERN_WARNING MYNAM
1417 ": WARNING - %s did not initialize properly! (%d)\n", 1392 ": WARNING - %s did not initialize properly! (%d)\n",
1418 ioc->name, r); 1393 ioc->name, r);
1419
1420 list_del(&ioc->list); 1394 list_del(&ioc->list);
1421 free_irq(ioc->pci_irq, ioc);
1422 if (mpt_msi_enable)
1423 pci_disable_msi(pdev);
1424 if (ioc->alt_ioc) 1395 if (ioc->alt_ioc)
1425 ioc->alt_ioc->alt_ioc = NULL; 1396 ioc->alt_ioc->alt_ioc = NULL;
1426 iounmap(mem); 1397 iounmap(mem);
@@ -1639,6 +1610,7 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
1639 int handlers; 1610 int handlers;
1640 int ret = 0; 1611 int ret = 0;
1641 int reset_alt_ioc_active = 0; 1612 int reset_alt_ioc_active = 0;
1613 int irq_allocated = 0;
1642 1614
1643 printk(KERN_INFO MYNAM ": Initiating %s %s\n", 1615 printk(KERN_INFO MYNAM ": Initiating %s %s\n",
1644 ioc->name, reason==MPT_HOSTEVENT_IOC_BRINGUP ? "bringup" : "recovery"); 1616 ioc->name, reason==MPT_HOSTEVENT_IOC_BRINGUP ? "bringup" : "recovery");
@@ -1722,6 +1694,36 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
1722 } 1694 }
1723 } 1695 }
1724 1696
1697 /*
1698 * Device is reset now. It must have de-asserted the interrupt line
1699 * (if it was asserted) and it should be safe to register for the
1700 * interrupt now.
1701 */
1702 if ((ret == 0) && (reason == MPT_HOSTEVENT_IOC_BRINGUP)) {
1703 ioc->pci_irq = -1;
1704 if (ioc->pcidev->irq) {
1705 if (mpt_msi_enable && !pci_enable_msi(ioc->pcidev))
1706 printk(MYIOC_s_INFO_FMT "PCI-MSI enabled\n",
1707 ioc->name);
1708 rc = request_irq(ioc->pcidev->irq, mpt_interrupt,
1709 SA_SHIRQ, ioc->name, ioc);
1710 if (rc < 0) {
1711 printk(MYIOC_s_ERR_FMT "Unable to allocate "
1712 "interrupt %d!\n", ioc->name,
1713 ioc->pcidev->irq);
1714 if (mpt_msi_enable)
1715 pci_disable_msi(ioc->pcidev);
1716 return -EBUSY;
1717 }
1718 irq_allocated = 1;
1719 ioc->pci_irq = ioc->pcidev->irq;
1720 pci_set_master(ioc->pcidev); /* ?? */
1721 pci_set_drvdata(ioc->pcidev, ioc);
1722 dprintk((KERN_INFO MYNAM ": %s installed at interrupt "
1723 "%d\n", ioc->name, ioc->pcidev->irq));
1724 }
1725 }
1726
1725 /* Prime reply & request queues! 1727 /* Prime reply & request queues!
1726 * (mucho alloc's) Must be done prior to 1728 * (mucho alloc's) Must be done prior to
1727 * init as upper addresses are needed for init. 1729 * init as upper addresses are needed for init.
@@ -1821,7 +1823,7 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
1821 ret = mptbase_sas_persist_operation(ioc, 1823 ret = mptbase_sas_persist_operation(ioc,
1822 MPI_SAS_OP_CLEAR_NOT_PRESENT); 1824 MPI_SAS_OP_CLEAR_NOT_PRESENT);
1823 if(ret != 0) 1825 if(ret != 0)
1824 return -1; 1826 goto out;
1825 } 1827 }
1826 1828
1827 /* Find IM volumes 1829 /* Find IM volumes
@@ -1829,14 +1831,6 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
1829 mpt_findImVolumes(ioc); 1831 mpt_findImVolumes(ioc);
1830 1832
1831 } else if (ioc->bus_type == FC) { 1833 } else if (ioc->bus_type == FC) {
1832 /*
1833 * Pre-fetch FC port WWN and stuff...
1834 * (FCPortPage0_t stuff)
1835 */
1836 for (ii=0; ii < ioc->facts.NumberOfPorts; ii++) {
1837 (void) mptbase_GetFcPortPage0(ioc, ii);
1838 }
1839
1840 if ((ioc->pfacts[0].ProtocolFlags & MPI_PORTFACTS_PROTOCOL_LAN) && 1834 if ((ioc->pfacts[0].ProtocolFlags & MPI_PORTFACTS_PROTOCOL_LAN) &&
1841 (ioc->lan_cnfg_page0.Header.PageLength == 0)) { 1835 (ioc->lan_cnfg_page0.Header.PageLength == 0)) {
1842 /* 1836 /*
@@ -1902,6 +1896,12 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
1902 /* FIXME? Examine results here? */ 1896 /* FIXME? Examine results here? */
1903 } 1897 }
1904 1898
1899out:
1900 if ((ret != 0) && irq_allocated) {
1901 free_irq(ioc->pci_irq, ioc);
1902 if (mpt_msi_enable)
1903 pci_disable_msi(ioc->pcidev);
1904 }
1905 return ret; 1905 return ret;
1906} 1906}
1907 1907
@@ -2276,7 +2276,7 @@ MakeIocReady(MPT_ADAPTER *ioc, int force, int sleepFlag)
2276 } 2276 }
2277 2277
2278 if (sleepFlag == CAN_SLEEP) { 2278 if (sleepFlag == CAN_SLEEP) {
2279 msleep_interruptible(1); 2279 msleep(1);
2280 } else { 2280 } else {
2281 mdelay (1); /* 1 msec delay */ 2281 mdelay (1); /* 1 msec delay */
2282 } 2282 }
@@ -2664,7 +2664,7 @@ SendIocInit(MPT_ADAPTER *ioc, int sleepFlag)
2664 state = mpt_GetIocState(ioc, 1); 2664 state = mpt_GetIocState(ioc, 1);
2665 while (state != MPI_IOC_STATE_OPERATIONAL && --cntdn) { 2665 while (state != MPI_IOC_STATE_OPERATIONAL && --cntdn) {
2666 if (sleepFlag == CAN_SLEEP) { 2666 if (sleepFlag == CAN_SLEEP) {
2667 msleep_interruptible(1); 2667 msleep(1);
2668 } else { 2668 } else {
2669 mdelay(1); 2669 mdelay(1);
2670 } 2670 }
@@ -2916,7 +2916,7 @@ mpt_downloadboot(MPT_ADAPTER *ioc, MpiFwHeader_t *pFwHeader, int sleepFlag)
2916 2916
2917 /* wait 1 msec */ 2917 /* wait 1 msec */
2918 if (sleepFlag == CAN_SLEEP) { 2918 if (sleepFlag == CAN_SLEEP) {
2919 msleep_interruptible(1); 2919 msleep(1);
2920 } else { 2920 } else {
2921 mdelay (1); 2921 mdelay (1);
2922 } 2922 }
@@ -2933,7 +2933,7 @@ mpt_downloadboot(MPT_ADAPTER *ioc, MpiFwHeader_t *pFwHeader, int sleepFlag)
2933 } 2933 }
2934 /* wait .1 sec */ 2934 /* wait .1 sec */
2935 if (sleepFlag == CAN_SLEEP) { 2935 if (sleepFlag == CAN_SLEEP) {
2936 msleep_interruptible (100); 2936 msleep (100);
2937 } else { 2937 } else {
2938 mdelay (100); 2938 mdelay (100);
2939 } 2939 }
@@ -3023,7 +3023,7 @@ mpt_downloadboot(MPT_ADAPTER *ioc, MpiFwHeader_t *pFwHeader, int sleepFlag)
3023 3023
3024 /* wait 1 msec */ 3024 /* wait 1 msec */
3025 if (sleepFlag == CAN_SLEEP) { 3025 if (sleepFlag == CAN_SLEEP) {
3026 msleep_interruptible (1); 3026 msleep (1);
3027 } else { 3027 } else {
3028 mdelay (1); 3028 mdelay (1);
3029 } 3029 }
@@ -3071,7 +3071,7 @@ mpt_downloadboot(MPT_ADAPTER *ioc, MpiFwHeader_t *pFwHeader, int sleepFlag)
3071 return 0; 3071 return 0;
3072 } 3072 }
3073 if (sleepFlag == CAN_SLEEP) { 3073 if (sleepFlag == CAN_SLEEP) {
3074 msleep_interruptible (10); 3074 msleep (10);
3075 } else { 3075 } else {
3076 mdelay (10); 3076 mdelay (10);
3077 } 3077 }
@@ -3122,7 +3122,7 @@ KickStart(MPT_ADAPTER *ioc, int force, int sleepFlag)
3122 SendIocReset(ioc, MPI_FUNCTION_IOC_MESSAGE_UNIT_RESET, sleepFlag); 3122 SendIocReset(ioc, MPI_FUNCTION_IOC_MESSAGE_UNIT_RESET, sleepFlag);
3123 3123
3124 if (sleepFlag == CAN_SLEEP) { 3124 if (sleepFlag == CAN_SLEEP) {
3125 msleep_interruptible (1000); 3125 msleep (1000);
3126 } else { 3126 } else {
3127 mdelay (1000); 3127 mdelay (1000);
3128 } 3128 }
@@ -3144,7 +3144,7 @@ KickStart(MPT_ADAPTER *ioc, int force, int sleepFlag)
3144 return hard_reset_done; 3144 return hard_reset_done;
3145 } 3145 }
3146 if (sleepFlag == CAN_SLEEP) { 3146 if (sleepFlag == CAN_SLEEP) {
3147 msleep_interruptible (10); 3147 msleep (10);
3148 } else { 3148 } else {
3149 mdelay (10); 3149 mdelay (10);
3150 } 3150 }
@@ -3215,7 +3215,7 @@ mpt_diag_reset(MPT_ADAPTER *ioc, int ignore, int sleepFlag)
3215 3215
3216 /* wait 100 msec */ 3216 /* wait 100 msec */
3217 if (sleepFlag == CAN_SLEEP) { 3217 if (sleepFlag == CAN_SLEEP) {
3218 msleep_interruptible (100); 3218 msleep (100);
3219 } else { 3219 } else {
3220 mdelay (100); 3220 mdelay (100);
3221 } 3221 }
@@ -3294,7 +3294,7 @@ mpt_diag_reset(MPT_ADAPTER *ioc, int ignore, int sleepFlag)
3294 3294
3295 /* wait 1 sec */ 3295 /* wait 1 sec */
3296 if (sleepFlag == CAN_SLEEP) { 3296 if (sleepFlag == CAN_SLEEP) {
3297 msleep_interruptible (1000); 3297 msleep (1000);
3298 } else { 3298 } else {
3299 mdelay (1000); 3299 mdelay (1000);
3300 } 3300 }
@@ -3322,7 +3322,7 @@ mpt_diag_reset(MPT_ADAPTER *ioc, int ignore, int sleepFlag)
3322 3322
3323 /* wait 1 sec */ 3323 /* wait 1 sec */
3324 if (sleepFlag == CAN_SLEEP) { 3324 if (sleepFlag == CAN_SLEEP) {
3325 msleep_interruptible (1000); 3325 msleep (1000);
3326 } else { 3326 } else {
3327 mdelay (1000); 3327 mdelay (1000);
3328 } 3328 }
@@ -3356,7 +3356,7 @@ mpt_diag_reset(MPT_ADAPTER *ioc, int ignore, int sleepFlag)
3356 3356
3357 /* wait 100 msec */ 3357 /* wait 100 msec */
3358 if (sleepFlag == CAN_SLEEP) { 3358 if (sleepFlag == CAN_SLEEP) {
3359 msleep_interruptible (100); 3359 msleep (100);
3360 } else { 3360 } else {
3361 mdelay (100); 3361 mdelay (100);
3362 } 3362 }
@@ -3450,7 +3450,7 @@ SendIocReset(MPT_ADAPTER *ioc, u8 reset_type, int sleepFlag)
3450 } 3450 }
3451 3451
3452 if (sleepFlag == CAN_SLEEP) { 3452 if (sleepFlag == CAN_SLEEP) {
3453 msleep_interruptible(1); 3453 msleep(1);
3454 } else { 3454 } else {
3455 mdelay (1); /* 1 msec delay */ 3455 mdelay (1); /* 1 msec delay */
3456 } 3456 }
@@ -3890,7 +3890,7 @@ WaitForDoorbellAck(MPT_ADAPTER *ioc, int howlong, int sleepFlag)
3890 intstat = CHIPREG_READ32(&ioc->chip->IntStatus); 3890 intstat = CHIPREG_READ32(&ioc->chip->IntStatus);
3891 if (! (intstat & MPI_HIS_IOP_DOORBELL_STATUS)) 3891 if (! (intstat & MPI_HIS_IOP_DOORBELL_STATUS))
3892 break; 3892 break;
3893 msleep_interruptible (1); 3893 msleep (1);
3894 count++; 3894 count++;
3895 } 3895 }
3896 } else { 3896 } else {
@@ -3939,7 +3939,7 @@ WaitForDoorbellInt(MPT_ADAPTER *ioc, int howlong, int sleepFlag)
3939 intstat = CHIPREG_READ32(&ioc->chip->IntStatus); 3939 intstat = CHIPREG_READ32(&ioc->chip->IntStatus);
3940 if (intstat & MPI_HIS_DOORBELL_INTERRUPT) 3940 if (intstat & MPI_HIS_DOORBELL_INTERRUPT)
3941 break; 3941 break;
3942 msleep_interruptible(1); 3942 msleep(1);
3943 count++; 3943 count++;
3944 } 3944 }
3945 } else { 3945 } else {
@@ -4162,108 +4162,6 @@ GetLanConfigPages(MPT_ADAPTER *ioc)
4162 4162
4163/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 4163/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
4164/* 4164/*
4165 * mptbase_GetFcPortPage0 - Fetch FCPort config Page0.
4166 * @ioc: Pointer to MPT_ADAPTER structure
4167 * @portnum: IOC Port number
4168 *
4169 * Return: 0 for success
4170 * -ENOMEM if no memory available
4171 * -EPERM if not allowed due to ISR context
4172 * -EAGAIN if no msg frames currently available
4173 * -EFAULT for non-successful reply or no reply (timeout)
4174 */
4175int
4176mptbase_GetFcPortPage0(MPT_ADAPTER *ioc, int portnum)
4177{
4178 ConfigPageHeader_t hdr;
4179 CONFIGPARMS cfg;
4180 FCPortPage0_t *ppage0_alloc;
4181 FCPortPage0_t *pp0dest;
4182 dma_addr_t page0_dma;
4183 int data_sz;
4184 int copy_sz;
4185 int rc;
4186 int count = 400;
4187
4188
4189 /* Get FCPort Page 0 header */
4190 hdr.PageVersion = 0;
4191 hdr.PageLength = 0;
4192 hdr.PageNumber = 0;
4193 hdr.PageType = MPI_CONFIG_PAGETYPE_FC_PORT;
4194 cfg.cfghdr.hdr = &hdr;
4195 cfg.physAddr = -1;
4196 cfg.action = MPI_CONFIG_ACTION_PAGE_HEADER;
4197 cfg.dir = 0;
4198 cfg.pageAddr = portnum;
4199 cfg.timeout = 0;
4200
4201 if ((rc = mpt_config(ioc, &cfg)) != 0)
4202 return rc;
4203
4204 if (hdr.PageLength == 0)
4205 return 0;
4206
4207 data_sz = hdr.PageLength * 4;
4208 rc = -ENOMEM;
4209 ppage0_alloc = (FCPortPage0_t *) pci_alloc_consistent(ioc->pcidev, data_sz, &page0_dma);
4210 if (ppage0_alloc) {
4211
4212 try_again:
4213 memset((u8 *)ppage0_alloc, 0, data_sz);
4214 cfg.physAddr = page0_dma;
4215 cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT;
4216
4217 if ((rc = mpt_config(ioc, &cfg)) == 0) {
4218 /* save the data */
4219 pp0dest = &ioc->fc_port_page0[portnum];
4220 copy_sz = min_t(int, sizeof(FCPortPage0_t), data_sz);
4221 memcpy(pp0dest, ppage0_alloc, copy_sz);
4222
4223 /*
4224 * Normalize endianness of structure data,
4225 * by byte-swapping all > 1 byte fields!
4226 */
4227 pp0dest->Flags = le32_to_cpu(pp0dest->Flags);
4228 pp0dest->PortIdentifier = le32_to_cpu(pp0dest->PortIdentifier);
4229 pp0dest->WWNN.Low = le32_to_cpu(pp0dest->WWNN.Low);
4230 pp0dest->WWNN.High = le32_to_cpu(pp0dest->WWNN.High);
4231 pp0dest->WWPN.Low = le32_to_cpu(pp0dest->WWPN.Low);
4232 pp0dest->WWPN.High = le32_to_cpu(pp0dest->WWPN.High);
4233 pp0dest->SupportedServiceClass = le32_to_cpu(pp0dest->SupportedServiceClass);
4234 pp0dest->SupportedSpeeds = le32_to_cpu(pp0dest->SupportedSpeeds);
4235 pp0dest->CurrentSpeed = le32_to_cpu(pp0dest->CurrentSpeed);
4236 pp0dest->MaxFrameSize = le32_to_cpu(pp0dest->MaxFrameSize);
4237 pp0dest->FabricWWNN.Low = le32_to_cpu(pp0dest->FabricWWNN.Low);
4238 pp0dest->FabricWWNN.High = le32_to_cpu(pp0dest->FabricWWNN.High);
4239 pp0dest->FabricWWPN.Low = le32_to_cpu(pp0dest->FabricWWPN.Low);
4240 pp0dest->FabricWWPN.High = le32_to_cpu(pp0dest->FabricWWPN.High);
4241 pp0dest->DiscoveredPortsCount = le32_to_cpu(pp0dest->DiscoveredPortsCount);
4242 pp0dest->MaxInitiators = le32_to_cpu(pp0dest->MaxInitiators);
4243
4244 /*
4245 * if still doing discovery,
4246 * hang loose a while until finished
4247 */
4248 if (pp0dest->PortState == MPI_FCPORTPAGE0_PORTSTATE_UNKNOWN) {
4249 if (count-- > 0) {
4250 msleep_interruptible(100);
4251 goto try_again;
4252 }
4253 printk(MYIOC_s_INFO_FMT "Firmware discovery not"
4254 " complete.\n",
4255 ioc->name);
4256 }
4257 }
4258
4259 pci_free_consistent(ioc->pcidev, data_sz, (u8 *) ppage0_alloc, page0_dma);
4260 }
4261
4262 return rc;
4263}
4264
4265/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
4266/*
4267 * mptbase_sas_persist_operation - Perform operation on SAS Persitent Table 4165 * mptbase_sas_persist_operation - Perform operation on SAS Persitent Table
4268 * @ioc: Pointer to MPT_ADAPTER structure 4166 * @ioc: Pointer to MPT_ADAPTER structure
4269 * @sas_address: 64bit SAS Address for operation. 4167 * @sas_address: 64bit SAS Address for operation.
@@ -6467,7 +6365,6 @@ EXPORT_SYMBOL(mpt_findImVolumes);
6467EXPORT_SYMBOL(mpt_alloc_fw_memory); 6365EXPORT_SYMBOL(mpt_alloc_fw_memory);
6468EXPORT_SYMBOL(mpt_free_fw_memory); 6366EXPORT_SYMBOL(mpt_free_fw_memory);
6469EXPORT_SYMBOL(mptbase_sas_persist_operation); 6367EXPORT_SYMBOL(mptbase_sas_persist_operation);
6470EXPORT_SYMBOL(mptbase_GetFcPortPage0);
6471 6368
6472 6369
6473/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 6370/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/