aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/message/fusion
diff options
context:
space:
mode:
authorPrakash, Sathya <sathya.prakash@lsi.com>2008-03-07 05:49:50 -0500
committerJames Bottomley <James.Bottomley@HansenPartnership.com>2008-03-18 16:13:40 -0400
commit4d4109d0eb6930e59942d019980b83af679f187b (patch)
tree8fb0e28bbc6f9b7edb5f387723b3cc0f947f3d6f /drivers/message/fusion
parent1b96f8955aaeeb05f7fb7ff548aa12415fbf3904 (diff)
[SCSI] mpt fusion: Power Management fixes for MPT SAS PCI-E controllers
The system power state changes like hibernation and standby are not happening properly with 106XE controllers, this patch modifies the driver to free resources and allocate resources in power management entry points [jejb: compile fixes for upstream] Signed-off-by: Sathya Prakash <sathya.prakash@lsi.com> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'drivers/message/fusion')
-rw-r--r--drivers/message/fusion/mptbase.c276
-rw-r--r--drivers/message/fusion/mptscsih.c11
2 files changed, 166 insertions, 121 deletions
diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index 6b6df8679585..c6be6eba7dc3 100644
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -1430,6 +1430,98 @@ mpt_get_product_name(u16 vendor, u16 device, u8 revision, char *prod_name)
1430 sprintf(prod_name, "%s", product_str); 1430 sprintf(prod_name, "%s", product_str);
1431} 1431}
1432 1432
1433/**
1434 * mpt_mapresources - map in memory mapped io
1435 * @ioc: Pointer to pointer to IOC adapter
1436 *
1437 **/
1438static int
1439mpt_mapresources(MPT_ADAPTER *ioc)
1440{
1441 u8 __iomem *mem;
1442 int ii;
1443 unsigned long mem_phys;
1444 unsigned long port;
1445 u32 msize;
1446 u32 psize;
1447 u8 revision;
1448 int r = -ENODEV;
1449 struct pci_dev *pdev;
1450
1451 pdev = ioc->pcidev;
1452 ioc->bars = pci_select_bars(pdev, IORESOURCE_MEM);
1453 if (pci_enable_device_mem(pdev)) {
1454 printk(MYIOC_s_ERR_FMT "pci_enable_device_mem() "
1455 "failed\n", ioc->name);
1456 return r;
1457 }
1458 if (pci_request_selected_regions(pdev, ioc->bars, "mpt")) {
1459 printk(MYIOC_s_ERR_FMT "pci_request_selected_regions() with "
1460 "MEM failed\n", ioc->name);
1461 return r;
1462 }
1463
1464 pci_read_config_byte(pdev, PCI_CLASS_REVISION, &revision);
1465
1466 if (!pci_set_dma_mask(pdev, DMA_64BIT_MASK)
1467 && !pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK)) {
1468 dinitprintk(ioc, printk(MYIOC_s_INFO_FMT
1469 ": 64 BIT PCI BUS DMA ADDRESSING SUPPORTED\n",
1470 ioc->name));
1471 } else if (!pci_set_dma_mask(pdev, DMA_32BIT_MASK)
1472 && !pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK)) {
1473 dinitprintk(ioc, printk(MYIOC_s_INFO_FMT
1474 ": 32 BIT PCI BUS DMA ADDRESSING SUPPORTED\n",
1475 ioc->name));
1476 } else {
1477 printk(MYIOC_s_WARN_FMT "no suitable DMA mask for %s\n",
1478 ioc->name, pci_name(pdev));
1479 pci_release_selected_regions(pdev, ioc->bars);
1480 return r;
1481 }
1482
1483 mem_phys = msize = 0;
1484 port = psize = 0;
1485 for (ii = 0; ii < DEVICE_COUNT_RESOURCE; ii++) {
1486 if (pci_resource_flags(pdev, ii) & PCI_BASE_ADDRESS_SPACE_IO) {
1487 if (psize)
1488 continue;
1489 /* Get I/O space! */
1490 port = pci_resource_start(pdev, ii);
1491 psize = pci_resource_len(pdev, ii);
1492 } else {
1493 if (msize)
1494 continue;
1495 /* Get memmap */
1496 mem_phys = pci_resource_start(pdev, ii);
1497 msize = pci_resource_len(pdev, ii);
1498 }
1499 }
1500 ioc->mem_size = msize;
1501
1502 mem = NULL;
1503 /* Get logical ptr for PciMem0 space */
1504 /*mem = ioremap(mem_phys, msize);*/
1505 mem = ioremap(mem_phys, msize);
1506 if (mem == NULL) {
1507 printk(MYIOC_s_ERR_FMT ": ERROR - Unable to map adapter"
1508 " memory!\n", ioc->name);
1509 return -EINVAL;
1510 }
1511 ioc->memmap = mem;
1512 dinitprintk(ioc, printk(MYIOC_s_INFO_FMT "mem = %p, mem_phys = %lx\n",
1513 ioc->name, mem, mem_phys));
1514
1515 ioc->mem_phys = mem_phys;
1516 ioc->chip = (SYSIF_REGS __iomem *)mem;
1517
1518 /* Save Port IO values in case we need to do downloadboot */
1519 ioc->pio_mem_phys = port;
1520 ioc->pio_chip = (SYSIF_REGS __iomem *)port;
1521
1522 return 0;
1523}
1524
1433/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1525/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1434/** 1526/**
1435 * mpt_attach - Install a PCI intelligent MPT adapter. 1527 * mpt_attach - Install a PCI intelligent MPT adapter.
@@ -1452,13 +1544,6 @@ int
1452mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id) 1544mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1453{ 1545{
1454 MPT_ADAPTER *ioc; 1546 MPT_ADAPTER *ioc;
1455 u8 __iomem *mem;
1456 u8 __iomem *pmem;
1457 unsigned long mem_phys;
1458 unsigned long port;
1459 u32 msize;
1460 u32 psize;
1461 int ii;
1462 u8 cb_idx; 1547 u8 cb_idx;
1463 int r = -ENODEV; 1548 int r = -ENODEV;
1464 u8 revision; 1549 u8 revision;
@@ -1468,52 +1553,32 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1468 struct proc_dir_entry *dent, *ent; 1553 struct proc_dir_entry *dent, *ent;
1469#endif 1554#endif
1470 1555
1471 if (mpt_debug_level)
1472 printk(KERN_INFO MYNAM ": mpt_debug_level=%xh\n", mpt_debug_level);
1473
1474 ioc = kzalloc(sizeof(MPT_ADAPTER), GFP_ATOMIC); 1556 ioc = kzalloc(sizeof(MPT_ADAPTER), GFP_ATOMIC);
1475 if (ioc == NULL) { 1557 if (ioc == NULL) {
1476 printk(KERN_ERR MYNAM ": ERROR - Insufficient memory to add adapter!\n"); 1558 printk(KERN_ERR MYNAM ": ERROR - Insufficient memory to add adapter!\n");
1477 return -ENOMEM; 1559 return -ENOMEM;
1478 } 1560 }
1479 ioc->debug_level = mpt_debug_level; 1561
1480 ioc->id = mpt_ids++; 1562 ioc->id = mpt_ids++;
1481 sprintf(ioc->name, "ioc%d", ioc->id); 1563 sprintf(ioc->name, "ioc%d", ioc->id);
1482 1564
1483 ioc->bars = pci_select_bars(pdev, IORESOURCE_MEM); 1565 /*
1484 if (pci_enable_device_mem(pdev)) { 1566 * set initial debug level
1485 printk(MYIOC_s_ERR_FMT "pci_enable_device_mem() " 1567 * (refer to mptdebug.h)
1486 "failed\n", ioc->name); 1568 *
1487 kfree(ioc); 1569 */
1488 return r; 1570 ioc->debug_level = mpt_debug_level;
1489 } 1571 if (mpt_debug_level)
1490 if (pci_request_selected_regions(pdev, ioc->bars, "mpt")) { 1572 printk(KERN_INFO "mpt_debug_level=%xh\n", mpt_debug_level);
1491 printk(MYIOC_s_ERR_FMT "pci_request_selected_regions() with "
1492 "MEM failed\n", ioc->name);
1493 kfree(ioc);
1494 return r;
1495 }
1496 1573
1497 dinitprintk(ioc, printk(MYIOC_s_INFO_FMT ": mpt_adapter_install\n", ioc->name)); 1574 dinitprintk(ioc, printk(MYIOC_s_INFO_FMT ": mpt_adapter_install\n", ioc->name));
1498 1575
1499 if (!pci_set_dma_mask(pdev, DMA_64BIT_MASK)) { 1576 ioc->pcidev = pdev;
1500 dprintk(ioc, printk(MYIOC_s_INFO_FMT 1577 if (mpt_mapresources(ioc)) {
1501 ": 64 BIT PCI BUS DMA ADDRESSING SUPPORTED\n", ioc->name));
1502 } else if (pci_set_dma_mask(pdev, DMA_32BIT_MASK)) {
1503 printk(MYIOC_s_WARN_FMT ": 32 BIT PCI BUS DMA ADDRESSING NOT SUPPORTED\n",
1504 ioc->name);
1505 kfree(ioc); 1578 kfree(ioc);
1506 return r; 1579 return r;
1507 } 1580 }
1508 1581
1509 if (!pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK)) {
1510 dprintk(ioc, printk(MYIOC_s_INFO_FMT
1511 ": Using 64 bit consistent mask\n", ioc->name));
1512 } else {
1513 dprintk(ioc, printk(MYIOC_s_INFO_FMT
1514 ": Not using 64 bit consistent mask\n", ioc->name));
1515 }
1516
1517 ioc->alloc_total = sizeof(MPT_ADAPTER); 1582 ioc->alloc_total = sizeof(MPT_ADAPTER);
1518 ioc->req_sz = MPT_DEFAULT_FRAME_SIZE; /* avoid div by zero! */ 1583 ioc->req_sz = MPT_DEFAULT_FRAME_SIZE; /* avoid div by zero! */
1519 ioc->reply_sz = MPT_REPLY_FRAME_SIZE; 1584 ioc->reply_sz = MPT_REPLY_FRAME_SIZE;
@@ -1551,48 +1616,9 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1551 /* Find lookup slot. */ 1616 /* Find lookup slot. */
1552 INIT_LIST_HEAD(&ioc->list); 1617 INIT_LIST_HEAD(&ioc->list);
1553 1618
1554 mem_phys = msize = 0;
1555 port = psize = 0;
1556 for (ii=0; ii < DEVICE_COUNT_RESOURCE; ii++) {
1557 if (pci_resource_flags(pdev, ii) & PCI_BASE_ADDRESS_SPACE_IO) {
1558 if (psize)
1559 continue;
1560 /* Get I/O space! */
1561 port = pci_resource_start(pdev, ii);
1562 psize = pci_resource_len(pdev,ii);
1563 } else {
1564 if (msize)
1565 continue;
1566 /* Get memmap */
1567 mem_phys = pci_resource_start(pdev, ii);
1568 msize = pci_resource_len(pdev,ii);
1569 }
1570 }
1571 ioc->mem_size = msize;
1572
1573 mem = NULL;
1574 /* Get logical ptr for PciMem0 space */
1575 /*mem = ioremap(mem_phys, msize);*/
1576 mem = ioremap(mem_phys, msize);
1577 if (mem == NULL) {
1578 printk(MYIOC_s_ERR_FMT "Unable to map adapter memory!\n", ioc->name);
1579 kfree(ioc);
1580 return -EINVAL;
1581 }
1582 ioc->memmap = mem;
1583 dinitprintk(ioc, printk(MYIOC_s_INFO_FMT "mem = %p, mem_phys = %lx\n", ioc->name, mem, mem_phys));
1584
1585 dinitprintk(ioc, printk(MYIOC_s_INFO_FMT "facts @ %p, pfacts[0] @ %p\n", 1619 dinitprintk(ioc, printk(MYIOC_s_INFO_FMT "facts @ %p, pfacts[0] @ %p\n",
1586 ioc->name, &ioc->facts, &ioc->pfacts[0])); 1620 ioc->name, &ioc->facts, &ioc->pfacts[0]));
1587 1621
1588 ioc->mem_phys = mem_phys;
1589 ioc->chip = (SYSIF_REGS __iomem *)mem;
1590
1591 /* Save Port IO values in case we need to do downloadboot */
1592 ioc->pio_mem_phys = port;
1593 pmem = (u8 __iomem *)port;
1594 ioc->pio_chip = (SYSIF_REGS __iomem *)pmem;
1595
1596 pci_read_config_byte(pdev, PCI_CLASS_REVISION, &revision); 1622 pci_read_config_byte(pdev, PCI_CLASS_REVISION, &revision);
1597 mpt_get_product_name(pdev->vendor, pdev->device, revision, ioc->prod_name); 1623 mpt_get_product_name(pdev->vendor, pdev->device, revision, ioc->prod_name);
1598 1624
@@ -1688,7 +1714,9 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1688 list_del(&ioc->list); 1714 list_del(&ioc->list);
1689 if (ioc->alt_ioc) 1715 if (ioc->alt_ioc)
1690 ioc->alt_ioc->alt_ioc = NULL; 1716 ioc->alt_ioc->alt_ioc = NULL;
1691 iounmap(mem); 1717 iounmap(ioc->memmap);
1718 if (r != -5)
1719 pci_release_selected_regions(pdev, ioc->bars);
1692 kfree(ioc); 1720 kfree(ioc);
1693 pci_set_drvdata(pdev, NULL); 1721 pci_set_drvdata(pdev, NULL);
1694 return r; 1722 return r;
@@ -1784,13 +1812,10 @@ mpt_suspend(struct pci_dev *pdev, pm_message_t state)
1784 u32 device_state; 1812 u32 device_state;
1785 MPT_ADAPTER *ioc = pci_get_drvdata(pdev); 1813 MPT_ADAPTER *ioc = pci_get_drvdata(pdev);
1786 1814
1787 device_state=pci_choose_state(pdev, state); 1815 device_state = pci_choose_state(pdev, state);
1788 1816 printk(MYIOC_s_INFO_FMT "pci-suspend: pdev=0x%p, slot=%s, Entering "
1789 printk(MYIOC_s_INFO_FMT 1817 "operating state [D%d]\n", ioc->name, pdev, pci_name(pdev),
1790 "pci-suspend: pdev=0x%p, slot=%s, Entering operating state [D%d]\n", 1818 device_state);
1791 ioc->name, pdev, pci_name(pdev), device_state);
1792
1793 pci_save_state(pdev);
1794 1819
1795 /* put ioc into READY_STATE */ 1820 /* put ioc into READY_STATE */
1796 if(SendIocReset(ioc, MPI_FUNCTION_IOC_MESSAGE_UNIT_RESET, CAN_SLEEP)) { 1821 if(SendIocReset(ioc, MPI_FUNCTION_IOC_MESSAGE_UNIT_RESET, CAN_SLEEP)) {
@@ -1805,10 +1830,14 @@ mpt_suspend(struct pci_dev *pdev, pm_message_t state)
1805 /* Clear any lingering interrupt */ 1830 /* Clear any lingering interrupt */
1806 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); 1831 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0);
1807 1832
1833 free_irq(ioc->pci_irq, ioc);
1834 if (mpt_msi_enable)
1835 pci_disable_msi(ioc->pcidev);
1836 ioc->pci_irq = -1;
1837 pci_save_state(pdev);
1808 pci_disable_device(pdev); 1838 pci_disable_device(pdev);
1809 pci_release_selected_regions(pdev, ioc->bars); 1839 pci_release_selected_regions(pdev, ioc->bars);
1810 pci_set_power_state(pdev, device_state); 1840 pci_set_power_state(pdev, device_state);
1811
1812 return 0; 1841 return 0;
1813} 1842}
1814 1843
@@ -1823,48 +1852,54 @@ mpt_resume(struct pci_dev *pdev)
1823 MPT_ADAPTER *ioc = pci_get_drvdata(pdev); 1852 MPT_ADAPTER *ioc = pci_get_drvdata(pdev);
1824 u32 device_state = pdev->current_state; 1853 u32 device_state = pdev->current_state;
1825 int recovery_state; 1854 int recovery_state;
1855 int err;
1826 1856
1827 printk(MYIOC_s_INFO_FMT 1857 printk(MYIOC_s_INFO_FMT "pci-resume: pdev=0x%p, slot=%s, Previous "
1828 "pci-resume: pdev=0x%p, slot=%s, Previous operating state [D%d]\n", 1858 "operating state [D%d]\n", ioc->name, pdev, pci_name(pdev),
1829 ioc->name, pdev, pci_name(pdev), device_state); 1859 device_state);
1830 1860
1831 pci_set_power_state(pdev, 0); 1861 pci_set_power_state(pdev, PCI_D0);
1862 pci_enable_wake(pdev, PCI_D0, 0);
1832 pci_restore_state(pdev); 1863 pci_restore_state(pdev);
1833 if (ioc->facts.Flags & MPI_IOCFACTS_FLAGS_FW_DOWNLOAD_BOOT) { 1864 ioc->pcidev = pdev;
1834 ioc->bars = pci_select_bars(ioc->pcidev, IORESOURCE_MEM | 1865 err = mpt_mapresources(ioc);
1835 IORESOURCE_IO); 1866 if (err)
1836 if (pci_enable_device(pdev)) 1867 return err;
1837 return 0;
1838 } else {
1839 ioc->bars = pci_select_bars(pdev, IORESOURCE_MEM);
1840 if (pci_enable_device_mem(pdev))
1841 return 0;
1842 }
1843 if (pci_request_selected_regions(pdev, ioc->bars, "mpt"))
1844 return 0;
1845 1868
1846 /* enable interrupts */ 1869 printk(MYIOC_s_INFO_FMT "pci-resume: ioc-state=0x%x,doorbell=0x%x\n",
1847 CHIPREG_WRITE32(&ioc->chip->IntMask, MPI_HIM_DIM); 1870 ioc->name, (mpt_GetIocState(ioc, 1) >> MPI_IOC_STATE_SHIFT),
1848 ioc->active = 1; 1871 CHIPREG_READ32(&ioc->chip->Doorbell));
1849 1872
1850 printk(MYIOC_s_INFO_FMT 1873 /*
1851 "pci-resume: ioc-state=0x%x,doorbell=0x%x\n", 1874 * Errata workaround for SAS pci express:
1852 ioc->name, 1875 * Upon returning to the D0 state, the contents of the doorbell will be
1853 (mpt_GetIocState(ioc, 1) >> MPI_IOC_STATE_SHIFT), 1876 * stale data, and this will incorrectly signal to the host driver that
1854 CHIPREG_READ32(&ioc->chip->Doorbell)); 1877 * the firmware is ready to process mpt commands. The workaround is
1878 * to issue a diagnostic reset.
1879 */
1880 if (ioc->bus_type == SAS && (pdev->device ==
1881 MPI_MANUFACTPAGE_DEVID_SAS1068E || pdev->device ==
1882 MPI_MANUFACTPAGE_DEVID_SAS1064E)) {
1883 if (KickStart(ioc, 1, CAN_SLEEP) < 0) {
1884 printk(MYIOC_s_WARN_FMT "pci-resume: Cannot recover\n",
1885 ioc->name);
1886 goto out;
1887 }
1888 }
1855 1889
1856 /* bring ioc to operational state */ 1890 /* bring ioc to operational state */
1857 if ((recovery_state = mpt_do_ioc_recovery(ioc, 1891 printk(MYIOC_s_INFO_FMT "Sending mpt_do_ioc_recovery\n", ioc->name);
1858 MPT_HOSTEVENT_IOC_RECOVER, CAN_SLEEP)) != 0) { 1892 recovery_state = mpt_do_ioc_recovery(ioc, MPT_HOSTEVENT_IOC_BRINGUP,
1859 printk(MYIOC_s_INFO_FMT 1893 CAN_SLEEP);
1860 "pci-resume: Cannot recover, error:[%x]\n", 1894 if (recovery_state != 0)
1861 ioc->name, recovery_state); 1895 printk(MYIOC_s_WARN_FMT "pci-resume: Cannot recover, "
1862 } else { 1896 "error:[%x]\n", ioc->name, recovery_state);
1897 else
1863 printk(MYIOC_s_INFO_FMT 1898 printk(MYIOC_s_INFO_FMT
1864 "pci-resume: success\n", ioc->name); 1899 "pci-resume: success\n", ioc->name);
1865 } 1900 out:
1866
1867 return 0; 1901 return 0;
1902
1868} 1903}
1869#endif 1904#endif
1870 1905
@@ -1903,6 +1938,7 @@ mpt_signal_reset(u8 index, MPT_ADAPTER *ioc, int reset_phase)
1903 * -3 if READY but PrimeIOCFifos Failed 1938 * -3 if READY but PrimeIOCFifos Failed
1904 * -4 if READY but IOCInit Failed 1939 * -4 if READY but IOCInit Failed
1905 * -5 if failed to enable_device and/or request_selected_regions 1940 * -5 if failed to enable_device and/or request_selected_regions
1941 * -6 if failed to upload firmware
1906 */ 1942 */
1907static int 1943static int
1908mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag) 1944mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
@@ -2097,7 +2133,7 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
2097 } else { 2133 } else {
2098 printk(MYIOC_s_WARN_FMT 2134 printk(MYIOC_s_WARN_FMT
2099 "firmware upload failure!\n", ioc->name); 2135 "firmware upload failure!\n", ioc->name);
2100 ret = -5; 2136 ret = -6;
2101 } 2137 }
2102 } 2138 }
2103 } 2139 }
diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
index 0c252f60c4c1..c207bda6723b 100644
--- a/drivers/message/fusion/mptscsih.c
+++ b/drivers/message/fusion/mptscsih.c
@@ -1170,6 +1170,10 @@ mptscsih_shutdown(struct pci_dev *pdev)
1170int 1170int
1171mptscsih_suspend(struct pci_dev *pdev, pm_message_t state) 1171mptscsih_suspend(struct pci_dev *pdev, pm_message_t state)
1172{ 1172{
1173 MPT_ADAPTER *ioc = pci_get_drvdata(pdev);
1174
1175 scsi_block_requests(ioc->sh);
1176 flush_scheduled_work();
1173 mptscsih_shutdown(pdev); 1177 mptscsih_shutdown(pdev);
1174 return mpt_suspend(pdev,state); 1178 return mpt_suspend(pdev,state);
1175} 1179}
@@ -1183,7 +1187,12 @@ mptscsih_suspend(struct pci_dev *pdev, pm_message_t state)
1183int 1187int
1184mptscsih_resume(struct pci_dev *pdev) 1188mptscsih_resume(struct pci_dev *pdev)
1185{ 1189{
1186 return mpt_resume(pdev); 1190 MPT_ADAPTER *ioc = pci_get_drvdata(pdev);
1191 int rc;
1192
1193 rc = mpt_resume(pdev);
1194 scsi_unblock_requests(ioc->sh);
1195 return rc;
1187} 1196}
1188 1197
1189#endif 1198#endif