Benjamin Herrenschmidt | 61305a9 | 2011-09-19 17:45:05 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Support PCI/PCIe on PowerNV platforms |
| 3 | * |
Benjamin Herrenschmidt | 61305a9 | 2011-09-19 17:45:05 +0000 | [diff] [blame] | 4 | * Copyright 2011 Benjamin Herrenschmidt, IBM Corp. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License |
| 8 | * as published by the Free Software Foundation; either version |
| 9 | * 2 of the License, or (at your option) any later version. |
| 10 | */ |
| 11 | |
| 12 | #include <linux/kernel.h> |
| 13 | #include <linux/pci.h> |
| 14 | #include <linux/delay.h> |
| 15 | #include <linux/string.h> |
| 16 | #include <linux/init.h> |
Benjamin Herrenschmidt | 61305a9 | 2011-09-19 17:45:05 +0000 | [diff] [blame] | 17 | #include <linux/irq.h> |
| 18 | #include <linux/io.h> |
Benjamin Herrenschmidt | c1a2562 | 2011-09-19 17:45:06 +0000 | [diff] [blame] | 19 | #include <linux/msi.h> |
Alexey Kardashevskiy | 4e13c1a | 2013-05-21 13:33:09 +1000 | [diff] [blame] | 20 | #include <linux/iommu.h> |
Benjamin Herrenschmidt | 61305a9 | 2011-09-19 17:45:05 +0000 | [diff] [blame] | 21 | |
| 22 | #include <asm/sections.h> |
| 23 | #include <asm/io.h> |
| 24 | #include <asm/prom.h> |
| 25 | #include <asm/pci-bridge.h> |
| 26 | #include <asm/machdep.h> |
Gavin Shan | fb1b55d | 2013-03-05 21:12:37 +0000 | [diff] [blame] | 27 | #include <asm/msi_bitmap.h> |
Benjamin Herrenschmidt | 61305a9 | 2011-09-19 17:45:05 +0000 | [diff] [blame] | 28 | #include <asm/ppc-pci.h> |
Gavin Shan | 7e19bf3 | 2016-05-20 16:41:40 +1000 | [diff] [blame^] | 29 | #include <asm/pnv-pci.h> |
Benjamin Herrenschmidt | 61305a9 | 2011-09-19 17:45:05 +0000 | [diff] [blame] | 30 | #include <asm/opal.h> |
| 31 | #include <asm/iommu.h> |
| 32 | #include <asm/tce.h> |
Stephen Rothwell | f533927 | 2012-03-15 18:18:00 +0000 | [diff] [blame] | 33 | #include <asm/firmware.h> |
Gavin Shan | be7e744 | 2013-06-20 13:21:15 +0800 | [diff] [blame] | 34 | #include <asm/eeh_event.h> |
| 35 | #include <asm/eeh.h> |
Benjamin Herrenschmidt | 61305a9 | 2011-09-19 17:45:05 +0000 | [diff] [blame] | 36 | |
| 37 | #include "powernv.h" |
| 38 | #include "pci.h" |
| 39 | |
Gavin Shan | 7e19bf3 | 2016-05-20 16:41:40 +1000 | [diff] [blame^] | 40 | int pnv_pci_get_slot_id(struct device_node *np, uint64_t *id) |
| 41 | { |
| 42 | struct device_node *parent = np; |
| 43 | u32 bdfn; |
| 44 | u64 phbid; |
| 45 | int ret; |
| 46 | |
| 47 | ret = of_property_read_u32(np, "reg", &bdfn); |
| 48 | if (ret) |
| 49 | return -ENXIO; |
| 50 | |
| 51 | bdfn = ((bdfn & 0x00ffff00) >> 8); |
| 52 | while ((parent = of_get_parent(parent))) { |
| 53 | if (!PCI_DN(parent)) { |
| 54 | of_node_put(parent); |
| 55 | break; |
| 56 | } |
| 57 | |
| 58 | if (!of_device_is_compatible(parent, "ibm,ioda2-phb")) { |
| 59 | of_node_put(parent); |
| 60 | continue; |
| 61 | } |
| 62 | |
| 63 | ret = of_property_read_u64(parent, "ibm,opal-phbid", &phbid); |
| 64 | if (ret) { |
| 65 | of_node_put(parent); |
| 66 | return -ENXIO; |
| 67 | } |
| 68 | |
| 69 | *id = PCI_SLOT_ID(phbid, bdfn); |
| 70 | return 0; |
| 71 | } |
| 72 | |
| 73 | return -ENODEV; |
| 74 | } |
| 75 | EXPORT_SYMBOL_GPL(pnv_pci_get_slot_id); |
| 76 | |
Benjamin Herrenschmidt | c1a2562 | 2011-09-19 17:45:06 +0000 | [diff] [blame] | 77 | #ifdef CONFIG_PCI_MSI |
Daniel Axtens | 92ae035 | 2015-04-28 15:12:05 +1000 | [diff] [blame] | 78 | int pnv_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type) |
Benjamin Herrenschmidt | c1a2562 | 2011-09-19 17:45:06 +0000 | [diff] [blame] | 79 | { |
| 80 | struct pci_controller *hose = pci_bus_to_host(pdev->bus); |
| 81 | struct pnv_phb *phb = hose->private_data; |
| 82 | struct msi_desc *entry; |
| 83 | struct msi_msg msg; |
Gavin Shan | fb1b55d | 2013-03-05 21:12:37 +0000 | [diff] [blame] | 84 | int hwirq; |
| 85 | unsigned int virq; |
Benjamin Herrenschmidt | c1a2562 | 2011-09-19 17:45:06 +0000 | [diff] [blame] | 86 | int rc; |
| 87 | |
Alexander Gordeev | 6b2fd7ef | 2014-09-07 20:57:53 +0200 | [diff] [blame] | 88 | if (WARN_ON(!phb) || !phb->msi_bmp.bitmap) |
| 89 | return -ENODEV; |
| 90 | |
Benjamin Herrenschmidt | 3607438 | 2014-10-07 16:12:36 +1100 | [diff] [blame] | 91 | if (pdev->no_64bit_msi && !phb->msi32_support) |
Benjamin Herrenschmidt | c1a2562 | 2011-09-19 17:45:06 +0000 | [diff] [blame] | 92 | return -ENODEV; |
| 93 | |
Jiang Liu | 2921d17 | 2015-07-09 16:00:38 +0800 | [diff] [blame] | 94 | for_each_pci_msi_entry(entry, pdev) { |
Benjamin Herrenschmidt | c1a2562 | 2011-09-19 17:45:06 +0000 | [diff] [blame] | 95 | if (!entry->msi_attrib.is_64 && !phb->msi32_support) { |
| 96 | pr_warn("%s: Supports only 64-bit MSIs\n", |
| 97 | pci_name(pdev)); |
| 98 | return -ENXIO; |
| 99 | } |
Gavin Shan | fb1b55d | 2013-03-05 21:12:37 +0000 | [diff] [blame] | 100 | hwirq = msi_bitmap_alloc_hwirqs(&phb->msi_bmp, 1); |
| 101 | if (hwirq < 0) { |
Benjamin Herrenschmidt | c1a2562 | 2011-09-19 17:45:06 +0000 | [diff] [blame] | 102 | pr_warn("%s: Failed to find a free MSI\n", |
| 103 | pci_name(pdev)); |
| 104 | return -ENOSPC; |
| 105 | } |
Gavin Shan | fb1b55d | 2013-03-05 21:12:37 +0000 | [diff] [blame] | 106 | virq = irq_create_mapping(NULL, phb->msi_base + hwirq); |
Benjamin Herrenschmidt | c1a2562 | 2011-09-19 17:45:06 +0000 | [diff] [blame] | 107 | if (virq == NO_IRQ) { |
| 108 | pr_warn("%s: Failed to map MSI to linux irq\n", |
| 109 | pci_name(pdev)); |
Gavin Shan | fb1b55d | 2013-03-05 21:12:37 +0000 | [diff] [blame] | 110 | msi_bitmap_free_hwirqs(&phb->msi_bmp, hwirq, 1); |
Benjamin Herrenschmidt | c1a2562 | 2011-09-19 17:45:06 +0000 | [diff] [blame] | 111 | return -ENOMEM; |
| 112 | } |
Gavin Shan | fb1b55d | 2013-03-05 21:12:37 +0000 | [diff] [blame] | 113 | rc = phb->msi_setup(phb, pdev, phb->msi_base + hwirq, |
Gavin Shan | 137436c | 2013-04-25 19:20:59 +0000 | [diff] [blame] | 114 | virq, entry->msi_attrib.is_64, &msg); |
Benjamin Herrenschmidt | c1a2562 | 2011-09-19 17:45:06 +0000 | [diff] [blame] | 115 | if (rc) { |
| 116 | pr_warn("%s: Failed to setup MSI\n", pci_name(pdev)); |
| 117 | irq_dispose_mapping(virq); |
Gavin Shan | fb1b55d | 2013-03-05 21:12:37 +0000 | [diff] [blame] | 118 | msi_bitmap_free_hwirqs(&phb->msi_bmp, hwirq, 1); |
Benjamin Herrenschmidt | c1a2562 | 2011-09-19 17:45:06 +0000 | [diff] [blame] | 119 | return rc; |
| 120 | } |
| 121 | irq_set_msi_desc(virq, entry); |
Jiang Liu | 83a1891 | 2014-11-09 23:10:34 +0800 | [diff] [blame] | 122 | pci_write_msi_msg(virq, &msg); |
Benjamin Herrenschmidt | c1a2562 | 2011-09-19 17:45:06 +0000 | [diff] [blame] | 123 | } |
| 124 | return 0; |
| 125 | } |
| 126 | |
Daniel Axtens | 92ae035 | 2015-04-28 15:12:05 +1000 | [diff] [blame] | 127 | void pnv_teardown_msi_irqs(struct pci_dev *pdev) |
Benjamin Herrenschmidt | c1a2562 | 2011-09-19 17:45:06 +0000 | [diff] [blame] | 128 | { |
| 129 | struct pci_controller *hose = pci_bus_to_host(pdev->bus); |
| 130 | struct pnv_phb *phb = hose->private_data; |
| 131 | struct msi_desc *entry; |
Paul Mackerras | e297c93 | 2015-09-10 14:36:21 +1000 | [diff] [blame] | 132 | irq_hw_number_t hwirq; |
Benjamin Herrenschmidt | c1a2562 | 2011-09-19 17:45:06 +0000 | [diff] [blame] | 133 | |
| 134 | if (WARN_ON(!phb)) |
| 135 | return; |
| 136 | |
Jiang Liu | 2921d17 | 2015-07-09 16:00:38 +0800 | [diff] [blame] | 137 | for_each_pci_msi_entry(entry, pdev) { |
Benjamin Herrenschmidt | c1a2562 | 2011-09-19 17:45:06 +0000 | [diff] [blame] | 138 | if (entry->irq == NO_IRQ) |
| 139 | continue; |
Paul Mackerras | e297c93 | 2015-09-10 14:36:21 +1000 | [diff] [blame] | 140 | hwirq = virq_to_hw(entry->irq); |
Benjamin Herrenschmidt | c1a2562 | 2011-09-19 17:45:06 +0000 | [diff] [blame] | 141 | irq_set_msi_desc(entry->irq, NULL); |
Benjamin Herrenschmidt | c1a2562 | 2011-09-19 17:45:06 +0000 | [diff] [blame] | 142 | irq_dispose_mapping(entry->irq); |
Paul Mackerras | e297c93 | 2015-09-10 14:36:21 +1000 | [diff] [blame] | 143 | msi_bitmap_free_hwirqs(&phb->msi_bmp, hwirq - phb->msi_base, 1); |
Benjamin Herrenschmidt | c1a2562 | 2011-09-19 17:45:06 +0000 | [diff] [blame] | 144 | } |
| 145 | } |
| 146 | #endif /* CONFIG_PCI_MSI */ |
Benjamin Herrenschmidt | 61305a9 | 2011-09-19 17:45:05 +0000 | [diff] [blame] | 147 | |
Gavin Shan | 93aef2a | 2013-11-22 16:28:45 +0800 | [diff] [blame] | 148 | static void pnv_pci_dump_p7ioc_diag_data(struct pci_controller *hose, |
| 149 | struct OpalIoPhbErrorCommon *common) |
Benjamin Herrenschmidt | cee72d5 | 2011-11-29 18:22:53 +0000 | [diff] [blame] | 150 | { |
Gavin Shan | 93aef2a | 2013-11-22 16:28:45 +0800 | [diff] [blame] | 151 | struct OpalIoP7IOCPhbErrorData *data; |
Benjamin Herrenschmidt | cee72d5 | 2011-11-29 18:22:53 +0000 | [diff] [blame] | 152 | int i; |
| 153 | |
Gavin Shan | 93aef2a | 2013-11-22 16:28:45 +0800 | [diff] [blame] | 154 | data = (struct OpalIoP7IOCPhbErrorData *)common; |
Gavin Shan | b34497d | 2014-04-24 18:00:10 +1000 | [diff] [blame] | 155 | pr_info("P7IOC PHB#%d Diag-data (Version: %d)\n", |
Gavin Shan | f18440f | 2014-07-17 14:41:42 +1000 | [diff] [blame] | 156 | hose->global_number, be32_to_cpu(common->version)); |
Benjamin Herrenschmidt | cee72d5 | 2011-11-29 18:22:53 +0000 | [diff] [blame] | 157 | |
Gavin Shan | af87d2f | 2014-02-25 15:28:38 +0800 | [diff] [blame] | 158 | if (data->brdgCtl) |
Gavin Shan | b34497d | 2014-04-24 18:00:10 +1000 | [diff] [blame] | 159 | pr_info("brdgCtl: %08x\n", |
Gavin Shan | f18440f | 2014-07-17 14:41:42 +1000 | [diff] [blame] | 160 | be32_to_cpu(data->brdgCtl)); |
Gavin Shan | af87d2f | 2014-02-25 15:28:38 +0800 | [diff] [blame] | 161 | if (data->portStatusReg || data->rootCmplxStatus || |
| 162 | data->busAgentStatus) |
Gavin Shan | b34497d | 2014-04-24 18:00:10 +1000 | [diff] [blame] | 163 | pr_info("UtlSts: %08x %08x %08x\n", |
Gavin Shan | f18440f | 2014-07-17 14:41:42 +1000 | [diff] [blame] | 164 | be32_to_cpu(data->portStatusReg), |
| 165 | be32_to_cpu(data->rootCmplxStatus), |
| 166 | be32_to_cpu(data->busAgentStatus)); |
Gavin Shan | af87d2f | 2014-02-25 15:28:38 +0800 | [diff] [blame] | 167 | if (data->deviceStatus || data->slotStatus || |
| 168 | data->linkStatus || data->devCmdStatus || |
| 169 | data->devSecStatus) |
Gavin Shan | b34497d | 2014-04-24 18:00:10 +1000 | [diff] [blame] | 170 | pr_info("RootSts: %08x %08x %08x %08x %08x\n", |
Gavin Shan | f18440f | 2014-07-17 14:41:42 +1000 | [diff] [blame] | 171 | be32_to_cpu(data->deviceStatus), |
| 172 | be32_to_cpu(data->slotStatus), |
| 173 | be32_to_cpu(data->linkStatus), |
| 174 | be32_to_cpu(data->devCmdStatus), |
| 175 | be32_to_cpu(data->devSecStatus)); |
Gavin Shan | af87d2f | 2014-02-25 15:28:38 +0800 | [diff] [blame] | 176 | if (data->rootErrorStatus || data->uncorrErrorStatus || |
| 177 | data->corrErrorStatus) |
Gavin Shan | b34497d | 2014-04-24 18:00:10 +1000 | [diff] [blame] | 178 | pr_info("RootErrSts: %08x %08x %08x\n", |
Gavin Shan | f18440f | 2014-07-17 14:41:42 +1000 | [diff] [blame] | 179 | be32_to_cpu(data->rootErrorStatus), |
| 180 | be32_to_cpu(data->uncorrErrorStatus), |
| 181 | be32_to_cpu(data->corrErrorStatus)); |
Gavin Shan | af87d2f | 2014-02-25 15:28:38 +0800 | [diff] [blame] | 182 | if (data->tlpHdr1 || data->tlpHdr2 || |
| 183 | data->tlpHdr3 || data->tlpHdr4) |
Gavin Shan | b34497d | 2014-04-24 18:00:10 +1000 | [diff] [blame] | 184 | pr_info("RootErrLog: %08x %08x %08x %08x\n", |
Gavin Shan | f18440f | 2014-07-17 14:41:42 +1000 | [diff] [blame] | 185 | be32_to_cpu(data->tlpHdr1), |
| 186 | be32_to_cpu(data->tlpHdr2), |
| 187 | be32_to_cpu(data->tlpHdr3), |
| 188 | be32_to_cpu(data->tlpHdr4)); |
Gavin Shan | af87d2f | 2014-02-25 15:28:38 +0800 | [diff] [blame] | 189 | if (data->sourceId || data->errorClass || |
| 190 | data->correlator) |
Gavin Shan | b34497d | 2014-04-24 18:00:10 +1000 | [diff] [blame] | 191 | pr_info("RootErrLog1: %08x %016llx %016llx\n", |
Gavin Shan | f18440f | 2014-07-17 14:41:42 +1000 | [diff] [blame] | 192 | be32_to_cpu(data->sourceId), |
| 193 | be64_to_cpu(data->errorClass), |
| 194 | be64_to_cpu(data->correlator)); |
Gavin Shan | af87d2f | 2014-02-25 15:28:38 +0800 | [diff] [blame] | 195 | if (data->p7iocPlssr || data->p7iocCsr) |
Gavin Shan | b34497d | 2014-04-24 18:00:10 +1000 | [diff] [blame] | 196 | pr_info("PhbSts: %016llx %016llx\n", |
Gavin Shan | f18440f | 2014-07-17 14:41:42 +1000 | [diff] [blame] | 197 | be64_to_cpu(data->p7iocPlssr), |
| 198 | be64_to_cpu(data->p7iocCsr)); |
Gavin Shan | b34497d | 2014-04-24 18:00:10 +1000 | [diff] [blame] | 199 | if (data->lemFir) |
| 200 | pr_info("Lem: %016llx %016llx %016llx\n", |
Gavin Shan | f18440f | 2014-07-17 14:41:42 +1000 | [diff] [blame] | 201 | be64_to_cpu(data->lemFir), |
| 202 | be64_to_cpu(data->lemErrorMask), |
| 203 | be64_to_cpu(data->lemWOF)); |
Gavin Shan | b34497d | 2014-04-24 18:00:10 +1000 | [diff] [blame] | 204 | if (data->phbErrorStatus) |
| 205 | pr_info("PhbErr: %016llx %016llx %016llx %016llx\n", |
Gavin Shan | f18440f | 2014-07-17 14:41:42 +1000 | [diff] [blame] | 206 | be64_to_cpu(data->phbErrorStatus), |
| 207 | be64_to_cpu(data->phbFirstErrorStatus), |
| 208 | be64_to_cpu(data->phbErrorLog0), |
| 209 | be64_to_cpu(data->phbErrorLog1)); |
Gavin Shan | b34497d | 2014-04-24 18:00:10 +1000 | [diff] [blame] | 210 | if (data->mmioErrorStatus) |
| 211 | pr_info("OutErr: %016llx %016llx %016llx %016llx\n", |
Gavin Shan | f18440f | 2014-07-17 14:41:42 +1000 | [diff] [blame] | 212 | be64_to_cpu(data->mmioErrorStatus), |
| 213 | be64_to_cpu(data->mmioFirstErrorStatus), |
| 214 | be64_to_cpu(data->mmioErrorLog0), |
| 215 | be64_to_cpu(data->mmioErrorLog1)); |
Gavin Shan | b34497d | 2014-04-24 18:00:10 +1000 | [diff] [blame] | 216 | if (data->dma0ErrorStatus) |
| 217 | pr_info("InAErr: %016llx %016llx %016llx %016llx\n", |
Gavin Shan | f18440f | 2014-07-17 14:41:42 +1000 | [diff] [blame] | 218 | be64_to_cpu(data->dma0ErrorStatus), |
| 219 | be64_to_cpu(data->dma0FirstErrorStatus), |
| 220 | be64_to_cpu(data->dma0ErrorLog0), |
| 221 | be64_to_cpu(data->dma0ErrorLog1)); |
Gavin Shan | b34497d | 2014-04-24 18:00:10 +1000 | [diff] [blame] | 222 | if (data->dma1ErrorStatus) |
| 223 | pr_info("InBErr: %016llx %016llx %016llx %016llx\n", |
Gavin Shan | f18440f | 2014-07-17 14:41:42 +1000 | [diff] [blame] | 224 | be64_to_cpu(data->dma1ErrorStatus), |
| 225 | be64_to_cpu(data->dma1FirstErrorStatus), |
| 226 | be64_to_cpu(data->dma1ErrorLog0), |
| 227 | be64_to_cpu(data->dma1ErrorLog1)); |
Benjamin Herrenschmidt | cee72d5 | 2011-11-29 18:22:53 +0000 | [diff] [blame] | 228 | |
| 229 | for (i = 0; i < OPAL_P7IOC_NUM_PEST_REGS; i++) { |
| 230 | if ((data->pestA[i] >> 63) == 0 && |
| 231 | (data->pestB[i] >> 63) == 0) |
| 232 | continue; |
Gavin Shan | 93aef2a | 2013-11-22 16:28:45 +0800 | [diff] [blame] | 233 | |
Gavin Shan | b34497d | 2014-04-24 18:00:10 +1000 | [diff] [blame] | 234 | pr_info("PE[%3d] A/B: %016llx %016llx\n", |
Gavin Shan | f18440f | 2014-07-17 14:41:42 +1000 | [diff] [blame] | 235 | i, be64_to_cpu(data->pestA[i]), |
| 236 | be64_to_cpu(data->pestB[i])); |
Benjamin Herrenschmidt | cee72d5 | 2011-11-29 18:22:53 +0000 | [diff] [blame] | 237 | } |
| 238 | } |
| 239 | |
Gavin Shan | 93aef2a | 2013-11-22 16:28:45 +0800 | [diff] [blame] | 240 | static void pnv_pci_dump_phb3_diag_data(struct pci_controller *hose, |
| 241 | struct OpalIoPhbErrorCommon *common) |
Benjamin Herrenschmidt | cee72d5 | 2011-11-29 18:22:53 +0000 | [diff] [blame] | 242 | { |
Gavin Shan | 93aef2a | 2013-11-22 16:28:45 +0800 | [diff] [blame] | 243 | struct OpalIoPhb3ErrorData *data; |
| 244 | int i; |
| 245 | |
| 246 | data = (struct OpalIoPhb3ErrorData*)common; |
Gavin Shan | b34497d | 2014-04-24 18:00:10 +1000 | [diff] [blame] | 247 | pr_info("PHB3 PHB#%d Diag-data (Version: %d)\n", |
Guo Chao | ddf0322a | 2014-06-09 16:58:51 +0800 | [diff] [blame] | 248 | hose->global_number, be32_to_cpu(common->version)); |
Gavin Shan | af87d2f | 2014-02-25 15:28:38 +0800 | [diff] [blame] | 249 | if (data->brdgCtl) |
Gavin Shan | b34497d | 2014-04-24 18:00:10 +1000 | [diff] [blame] | 250 | pr_info("brdgCtl: %08x\n", |
Guo Chao | ddf0322a | 2014-06-09 16:58:51 +0800 | [diff] [blame] | 251 | be32_to_cpu(data->brdgCtl)); |
Gavin Shan | af87d2f | 2014-02-25 15:28:38 +0800 | [diff] [blame] | 252 | if (data->portStatusReg || data->rootCmplxStatus || |
| 253 | data->busAgentStatus) |
Gavin Shan | b34497d | 2014-04-24 18:00:10 +1000 | [diff] [blame] | 254 | pr_info("UtlSts: %08x %08x %08x\n", |
Guo Chao | ddf0322a | 2014-06-09 16:58:51 +0800 | [diff] [blame] | 255 | be32_to_cpu(data->portStatusReg), |
| 256 | be32_to_cpu(data->rootCmplxStatus), |
| 257 | be32_to_cpu(data->busAgentStatus)); |
Gavin Shan | af87d2f | 2014-02-25 15:28:38 +0800 | [diff] [blame] | 258 | if (data->deviceStatus || data->slotStatus || |
| 259 | data->linkStatus || data->devCmdStatus || |
| 260 | data->devSecStatus) |
Gavin Shan | b34497d | 2014-04-24 18:00:10 +1000 | [diff] [blame] | 261 | pr_info("RootSts: %08x %08x %08x %08x %08x\n", |
Guo Chao | ddf0322a | 2014-06-09 16:58:51 +0800 | [diff] [blame] | 262 | be32_to_cpu(data->deviceStatus), |
| 263 | be32_to_cpu(data->slotStatus), |
| 264 | be32_to_cpu(data->linkStatus), |
| 265 | be32_to_cpu(data->devCmdStatus), |
| 266 | be32_to_cpu(data->devSecStatus)); |
Gavin Shan | af87d2f | 2014-02-25 15:28:38 +0800 | [diff] [blame] | 267 | if (data->rootErrorStatus || data->uncorrErrorStatus || |
| 268 | data->corrErrorStatus) |
Gavin Shan | b34497d | 2014-04-24 18:00:10 +1000 | [diff] [blame] | 269 | pr_info("RootErrSts: %08x %08x %08x\n", |
Guo Chao | ddf0322a | 2014-06-09 16:58:51 +0800 | [diff] [blame] | 270 | be32_to_cpu(data->rootErrorStatus), |
| 271 | be32_to_cpu(data->uncorrErrorStatus), |
| 272 | be32_to_cpu(data->corrErrorStatus)); |
Gavin Shan | af87d2f | 2014-02-25 15:28:38 +0800 | [diff] [blame] | 273 | if (data->tlpHdr1 || data->tlpHdr2 || |
| 274 | data->tlpHdr3 || data->tlpHdr4) |
Gavin Shan | b34497d | 2014-04-24 18:00:10 +1000 | [diff] [blame] | 275 | pr_info("RootErrLog: %08x %08x %08x %08x\n", |
Guo Chao | ddf0322a | 2014-06-09 16:58:51 +0800 | [diff] [blame] | 276 | be32_to_cpu(data->tlpHdr1), |
| 277 | be32_to_cpu(data->tlpHdr2), |
| 278 | be32_to_cpu(data->tlpHdr3), |
| 279 | be32_to_cpu(data->tlpHdr4)); |
Gavin Shan | af87d2f | 2014-02-25 15:28:38 +0800 | [diff] [blame] | 280 | if (data->sourceId || data->errorClass || |
| 281 | data->correlator) |
Gavin Shan | b34497d | 2014-04-24 18:00:10 +1000 | [diff] [blame] | 282 | pr_info("RootErrLog1: %08x %016llx %016llx\n", |
Guo Chao | ddf0322a | 2014-06-09 16:58:51 +0800 | [diff] [blame] | 283 | be32_to_cpu(data->sourceId), |
| 284 | be64_to_cpu(data->errorClass), |
| 285 | be64_to_cpu(data->correlator)); |
Gavin Shan | b34497d | 2014-04-24 18:00:10 +1000 | [diff] [blame] | 286 | if (data->nFir) |
| 287 | pr_info("nFir: %016llx %016llx %016llx\n", |
Guo Chao | ddf0322a | 2014-06-09 16:58:51 +0800 | [diff] [blame] | 288 | be64_to_cpu(data->nFir), |
| 289 | be64_to_cpu(data->nFirMask), |
| 290 | be64_to_cpu(data->nFirWOF)); |
Gavin Shan | af87d2f | 2014-02-25 15:28:38 +0800 | [diff] [blame] | 291 | if (data->phbPlssr || data->phbCsr) |
Gavin Shan | b34497d | 2014-04-24 18:00:10 +1000 | [diff] [blame] | 292 | pr_info("PhbSts: %016llx %016llx\n", |
Guo Chao | ddf0322a | 2014-06-09 16:58:51 +0800 | [diff] [blame] | 293 | be64_to_cpu(data->phbPlssr), |
| 294 | be64_to_cpu(data->phbCsr)); |
Gavin Shan | b34497d | 2014-04-24 18:00:10 +1000 | [diff] [blame] | 295 | if (data->lemFir) |
| 296 | pr_info("Lem: %016llx %016llx %016llx\n", |
Guo Chao | ddf0322a | 2014-06-09 16:58:51 +0800 | [diff] [blame] | 297 | be64_to_cpu(data->lemFir), |
| 298 | be64_to_cpu(data->lemErrorMask), |
| 299 | be64_to_cpu(data->lemWOF)); |
Gavin Shan | b34497d | 2014-04-24 18:00:10 +1000 | [diff] [blame] | 300 | if (data->phbErrorStatus) |
| 301 | pr_info("PhbErr: %016llx %016llx %016llx %016llx\n", |
Guo Chao | ddf0322a | 2014-06-09 16:58:51 +0800 | [diff] [blame] | 302 | be64_to_cpu(data->phbErrorStatus), |
| 303 | be64_to_cpu(data->phbFirstErrorStatus), |
| 304 | be64_to_cpu(data->phbErrorLog0), |
| 305 | be64_to_cpu(data->phbErrorLog1)); |
Gavin Shan | b34497d | 2014-04-24 18:00:10 +1000 | [diff] [blame] | 306 | if (data->mmioErrorStatus) |
| 307 | pr_info("OutErr: %016llx %016llx %016llx %016llx\n", |
Guo Chao | ddf0322a | 2014-06-09 16:58:51 +0800 | [diff] [blame] | 308 | be64_to_cpu(data->mmioErrorStatus), |
| 309 | be64_to_cpu(data->mmioFirstErrorStatus), |
| 310 | be64_to_cpu(data->mmioErrorLog0), |
| 311 | be64_to_cpu(data->mmioErrorLog1)); |
Gavin Shan | b34497d | 2014-04-24 18:00:10 +1000 | [diff] [blame] | 312 | if (data->dma0ErrorStatus) |
| 313 | pr_info("InAErr: %016llx %016llx %016llx %016llx\n", |
Guo Chao | ddf0322a | 2014-06-09 16:58:51 +0800 | [diff] [blame] | 314 | be64_to_cpu(data->dma0ErrorStatus), |
| 315 | be64_to_cpu(data->dma0FirstErrorStatus), |
| 316 | be64_to_cpu(data->dma0ErrorLog0), |
| 317 | be64_to_cpu(data->dma0ErrorLog1)); |
Gavin Shan | b34497d | 2014-04-24 18:00:10 +1000 | [diff] [blame] | 318 | if (data->dma1ErrorStatus) |
| 319 | pr_info("InBErr: %016llx %016llx %016llx %016llx\n", |
Guo Chao | ddf0322a | 2014-06-09 16:58:51 +0800 | [diff] [blame] | 320 | be64_to_cpu(data->dma1ErrorStatus), |
| 321 | be64_to_cpu(data->dma1FirstErrorStatus), |
| 322 | be64_to_cpu(data->dma1ErrorLog0), |
| 323 | be64_to_cpu(data->dma1ErrorLog1)); |
Gavin Shan | 93aef2a | 2013-11-22 16:28:45 +0800 | [diff] [blame] | 324 | |
| 325 | for (i = 0; i < OPAL_PHB3_NUM_PEST_REGS; i++) { |
Guo Chao | ddf0322a | 2014-06-09 16:58:51 +0800 | [diff] [blame] | 326 | if ((be64_to_cpu(data->pestA[i]) >> 63) == 0 && |
| 327 | (be64_to_cpu(data->pestB[i]) >> 63) == 0) |
Gavin Shan | 93aef2a | 2013-11-22 16:28:45 +0800 | [diff] [blame] | 328 | continue; |
| 329 | |
Gavin Shan | b34497d | 2014-04-24 18:00:10 +1000 | [diff] [blame] | 330 | pr_info("PE[%3d] A/B: %016llx %016llx\n", |
Guo Chao | ddf0322a | 2014-06-09 16:58:51 +0800 | [diff] [blame] | 331 | i, be64_to_cpu(data->pestA[i]), |
| 332 | be64_to_cpu(data->pestB[i])); |
Gavin Shan | 93aef2a | 2013-11-22 16:28:45 +0800 | [diff] [blame] | 333 | } |
| 334 | } |
| 335 | |
| 336 | void pnv_pci_dump_phb_diag_data(struct pci_controller *hose, |
| 337 | unsigned char *log_buff) |
| 338 | { |
| 339 | struct OpalIoPhbErrorCommon *common; |
| 340 | |
| 341 | if (!hose || !log_buff) |
| 342 | return; |
| 343 | |
| 344 | common = (struct OpalIoPhbErrorCommon *)log_buff; |
Guo Chao | ddf0322a | 2014-06-09 16:58:51 +0800 | [diff] [blame] | 345 | switch (be32_to_cpu(common->ioType)) { |
Gavin Shan | 93aef2a | 2013-11-22 16:28:45 +0800 | [diff] [blame] | 346 | case OPAL_PHB_ERROR_DATA_TYPE_P7IOC: |
| 347 | pnv_pci_dump_p7ioc_diag_data(hose, common); |
| 348 | break; |
| 349 | case OPAL_PHB_ERROR_DATA_TYPE_PHB3: |
| 350 | pnv_pci_dump_phb3_diag_data(hose, common); |
Benjamin Herrenschmidt | cee72d5 | 2011-11-29 18:22:53 +0000 | [diff] [blame] | 351 | break; |
| 352 | default: |
Gavin Shan | 93aef2a | 2013-11-22 16:28:45 +0800 | [diff] [blame] | 353 | pr_warn("%s: Unrecognized ioType %d\n", |
Guo Chao | ddf0322a | 2014-06-09 16:58:51 +0800 | [diff] [blame] | 354 | __func__, be32_to_cpu(common->ioType)); |
Benjamin Herrenschmidt | cee72d5 | 2011-11-29 18:22:53 +0000 | [diff] [blame] | 355 | } |
| 356 | } |
| 357 | |
| 358 | static void pnv_pci_handle_eeh_config(struct pnv_phb *phb, u32 pe_no) |
| 359 | { |
| 360 | unsigned long flags, rc; |
Gavin Shan | 98fd700 | 2014-07-21 14:42:35 +1000 | [diff] [blame] | 361 | int has_diag, ret = 0; |
Benjamin Herrenschmidt | cee72d5 | 2011-11-29 18:22:53 +0000 | [diff] [blame] | 362 | |
| 363 | spin_lock_irqsave(&phb->lock, flags); |
| 364 | |
Gavin Shan | 98fd700 | 2014-07-21 14:42:35 +1000 | [diff] [blame] | 365 | /* Fetch PHB diag-data */ |
Gavin Shan | 2377323 | 2013-06-20 13:21:05 +0800 | [diff] [blame] | 366 | rc = opal_pci_get_phb_diag_data2(phb->opal_id, phb->diag.blob, |
| 367 | PNV_PCI_DIAG_BUF_SIZE); |
Benjamin Herrenschmidt | cee72d5 | 2011-11-29 18:22:53 +0000 | [diff] [blame] | 368 | has_diag = (rc == OPAL_SUCCESS); |
| 369 | |
Gavin Shan | 98fd700 | 2014-07-21 14:42:35 +1000 | [diff] [blame] | 370 | /* If PHB supports compound PE, to handle it */ |
| 371 | if (phb->unfreeze_pe) { |
| 372 | ret = phb->unfreeze_pe(phb, |
| 373 | pe_no, |
Benjamin Herrenschmidt | cee72d5 | 2011-11-29 18:22:53 +0000 | [diff] [blame] | 374 | OPAL_EEH_ACTION_CLEAR_FREEZE_ALL); |
Gavin Shan | 98fd700 | 2014-07-21 14:42:35 +1000 | [diff] [blame] | 375 | } else { |
| 376 | rc = opal_pci_eeh_freeze_clear(phb->opal_id, |
| 377 | pe_no, |
| 378 | OPAL_EEH_ACTION_CLEAR_FREEZE_ALL); |
| 379 | if (rc) { |
| 380 | pr_warn("%s: Failure %ld clearing frozen " |
| 381 | "PHB#%x-PE#%x\n", |
| 382 | __func__, rc, phb->hose->global_number, |
| 383 | pe_no); |
| 384 | ret = -EIO; |
| 385 | } |
Benjamin Herrenschmidt | cee72d5 | 2011-11-29 18:22:53 +0000 | [diff] [blame] | 386 | } |
| 387 | |
Gavin Shan | 98fd700 | 2014-07-21 14:42:35 +1000 | [diff] [blame] | 388 | /* |
| 389 | * For now, let's only display the diag buffer when we fail to clear |
| 390 | * the EEH status. We'll do more sensible things later when we have |
| 391 | * proper EEH support. We need to make sure we don't pollute ourselves |
| 392 | * with the normal errors generated when probing empty slots |
| 393 | */ |
| 394 | if (has_diag && ret) |
| 395 | pnv_pci_dump_phb_diag_data(phb->hose, phb->diag.blob); |
| 396 | |
Benjamin Herrenschmidt | cee72d5 | 2011-11-29 18:22:53 +0000 | [diff] [blame] | 397 | spin_unlock_irqrestore(&phb->lock, flags); |
| 398 | } |
| 399 | |
Gavin Shan | 3532a741 | 2015-03-17 16:15:03 +1100 | [diff] [blame] | 400 | static void pnv_pci_config_check_eeh(struct pci_dn *pdn) |
Benjamin Herrenschmidt | 61305a9 | 2011-09-19 17:45:05 +0000 | [diff] [blame] | 401 | { |
Gavin Shan | 3532a741 | 2015-03-17 16:15:03 +1100 | [diff] [blame] | 402 | struct pnv_phb *phb = pdn->phb->private_data; |
Benjamin Herrenschmidt | 61305a9 | 2011-09-19 17:45:05 +0000 | [diff] [blame] | 403 | u8 fstate; |
Benjamin Herrenschmidt | 3a1a466 | 2013-09-23 12:05:01 +1000 | [diff] [blame] | 404 | __be16 pcierr; |
Gavin Shan | 689ee8c | 2016-05-03 15:41:25 +1000 | [diff] [blame] | 405 | unsigned int pe_no; |
Gavin Shan | 98fd700 | 2014-07-21 14:42:35 +1000 | [diff] [blame] | 406 | s64 rc; |
Benjamin Herrenschmidt | 61305a9 | 2011-09-19 17:45:05 +0000 | [diff] [blame] | 407 | |
Gavin Shan | 9bf41be | 2013-06-27 13:46:48 +0800 | [diff] [blame] | 408 | /* |
| 409 | * Get the PE#. During the PCI probe stage, we might not |
| 410 | * setup that yet. So all ER errors should be mapped to |
Gavin Shan | 36954dc | 2013-11-04 16:32:47 +0800 | [diff] [blame] | 411 | * reserved PE. |
Gavin Shan | 9bf41be | 2013-06-27 13:46:48 +0800 | [diff] [blame] | 412 | */ |
Gavin Shan | 3532a741 | 2015-03-17 16:15:03 +1100 | [diff] [blame] | 413 | pe_no = pdn->pe_number; |
Gavin Shan | 36954dc | 2013-11-04 16:32:47 +0800 | [diff] [blame] | 414 | if (pe_no == IODA_INVALID_PE) { |
Gavin Shan | 92b8f13 | 2016-05-03 15:41:24 +1000 | [diff] [blame] | 415 | pe_no = phb->ioda.reserved_pe_idx; |
Gavin Shan | 36954dc | 2013-11-04 16:32:47 +0800 | [diff] [blame] | 416 | } |
Benjamin Herrenschmidt | 61305a9 | 2011-09-19 17:45:05 +0000 | [diff] [blame] | 417 | |
Gavin Shan | 98fd700 | 2014-07-21 14:42:35 +1000 | [diff] [blame] | 418 | /* |
| 419 | * Fetch frozen state. If the PHB support compound PE, |
| 420 | * we need handle that case. |
| 421 | */ |
| 422 | if (phb->get_pe_state) { |
| 423 | fstate = phb->get_pe_state(phb, pe_no); |
| 424 | } else { |
| 425 | rc = opal_pci_eeh_freeze_status(phb->opal_id, |
| 426 | pe_no, |
| 427 | &fstate, |
| 428 | &pcierr, |
| 429 | NULL); |
| 430 | if (rc) { |
| 431 | pr_warn("%s: Failure %lld getting PHB#%x-PE#%x state\n", |
| 432 | __func__, rc, phb->hose->global_number, pe_no); |
| 433 | return; |
| 434 | } |
Benjamin Herrenschmidt | 61305a9 | 2011-09-19 17:45:05 +0000 | [diff] [blame] | 435 | } |
Gavin Shan | 98fd700 | 2014-07-21 14:42:35 +1000 | [diff] [blame] | 436 | |
Alexey Kardashevskiy | 9e44754 | 2016-05-02 17:06:12 +1000 | [diff] [blame] | 437 | pr_devel(" -> EEH check, bdfn=%04x PE#%d fstate=%x\n", |
| 438 | (pdn->busno << 8) | (pdn->devfn), pe_no, fstate); |
Gavin Shan | 98fd700 | 2014-07-21 14:42:35 +1000 | [diff] [blame] | 439 | |
| 440 | /* Clear the frozen state if applicable */ |
| 441 | if (fstate == OPAL_EEH_STOPPED_MMIO_FREEZE || |
| 442 | fstate == OPAL_EEH_STOPPED_DMA_FREEZE || |
| 443 | fstate == OPAL_EEH_STOPPED_MMIO_DMA_FREEZE) { |
| 444 | /* |
| 445 | * If PHB supports compound PE, freeze it for |
| 446 | * consistency. |
| 447 | */ |
| 448 | if (phb->freeze_pe) |
| 449 | phb->freeze_pe(phb, pe_no); |
| 450 | |
Benjamin Herrenschmidt | cee72d5 | 2011-11-29 18:22:53 +0000 | [diff] [blame] | 451 | pnv_pci_handle_eeh_config(phb, pe_no); |
Gavin Shan | 98fd700 | 2014-07-21 14:42:35 +1000 | [diff] [blame] | 452 | } |
Benjamin Herrenschmidt | 61305a9 | 2011-09-19 17:45:05 +0000 | [diff] [blame] | 453 | } |
| 454 | |
Gavin Shan | 3532a741 | 2015-03-17 16:15:03 +1100 | [diff] [blame] | 455 | int pnv_pci_cfg_read(struct pci_dn *pdn, |
Gavin Shan | 9bf41be | 2013-06-27 13:46:48 +0800 | [diff] [blame] | 456 | int where, int size, u32 *val) |
Benjamin Herrenschmidt | 61305a9 | 2011-09-19 17:45:05 +0000 | [diff] [blame] | 457 | { |
Gavin Shan | 9bf41be | 2013-06-27 13:46:48 +0800 | [diff] [blame] | 458 | struct pnv_phb *phb = pdn->phb->private_data; |
| 459 | u32 bdfn = (pdn->busno << 8) | pdn->devfn; |
Benjamin Herrenschmidt | 61305a9 | 2011-09-19 17:45:05 +0000 | [diff] [blame] | 460 | s64 rc; |
| 461 | |
Benjamin Herrenschmidt | 61305a9 | 2011-09-19 17:45:05 +0000 | [diff] [blame] | 462 | switch (size) { |
| 463 | case 1: { |
| 464 | u8 v8; |
| 465 | rc = opal_pci_config_read_byte(phb->opal_id, bdfn, where, &v8); |
| 466 | *val = (rc == OPAL_SUCCESS) ? v8 : 0xff; |
| 467 | break; |
| 468 | } |
| 469 | case 2: { |
Benjamin Herrenschmidt | 3a1a466 | 2013-09-23 12:05:01 +1000 | [diff] [blame] | 470 | __be16 v16; |
Benjamin Herrenschmidt | 61305a9 | 2011-09-19 17:45:05 +0000 | [diff] [blame] | 471 | rc = opal_pci_config_read_half_word(phb->opal_id, bdfn, where, |
| 472 | &v16); |
Benjamin Herrenschmidt | 3a1a466 | 2013-09-23 12:05:01 +1000 | [diff] [blame] | 473 | *val = (rc == OPAL_SUCCESS) ? be16_to_cpu(v16) : 0xffff; |
Benjamin Herrenschmidt | 61305a9 | 2011-09-19 17:45:05 +0000 | [diff] [blame] | 474 | break; |
| 475 | } |
| 476 | case 4: { |
Benjamin Herrenschmidt | 3a1a466 | 2013-09-23 12:05:01 +1000 | [diff] [blame] | 477 | __be32 v32; |
Benjamin Herrenschmidt | 61305a9 | 2011-09-19 17:45:05 +0000 | [diff] [blame] | 478 | rc = opal_pci_config_read_word(phb->opal_id, bdfn, where, &v32); |
Benjamin Herrenschmidt | 3a1a466 | 2013-09-23 12:05:01 +1000 | [diff] [blame] | 479 | *val = (rc == OPAL_SUCCESS) ? be32_to_cpu(v32) : 0xffffffff; |
Benjamin Herrenschmidt | 61305a9 | 2011-09-19 17:45:05 +0000 | [diff] [blame] | 480 | break; |
| 481 | } |
| 482 | default: |
| 483 | return PCIBIOS_FUNC_NOT_SUPPORTED; |
| 484 | } |
Gavin Shan | d0914f5 | 2014-04-24 18:00:12 +1000 | [diff] [blame] | 485 | |
Alexey Kardashevskiy | 9e44754 | 2016-05-02 17:06:12 +1000 | [diff] [blame] | 486 | pr_devel("%s: bus: %x devfn: %x +%x/%x -> %08x\n", |
| 487 | __func__, pdn->busno, pdn->devfn, where, size, *val); |
Benjamin Herrenschmidt | 61305a9 | 2011-09-19 17:45:05 +0000 | [diff] [blame] | 488 | return PCIBIOS_SUCCESSFUL; |
| 489 | } |
| 490 | |
Gavin Shan | 3532a741 | 2015-03-17 16:15:03 +1100 | [diff] [blame] | 491 | int pnv_pci_cfg_write(struct pci_dn *pdn, |
Gavin Shan | 9bf41be | 2013-06-27 13:46:48 +0800 | [diff] [blame] | 492 | int where, int size, u32 val) |
Benjamin Herrenschmidt | 61305a9 | 2011-09-19 17:45:05 +0000 | [diff] [blame] | 493 | { |
Gavin Shan | 9bf41be | 2013-06-27 13:46:48 +0800 | [diff] [blame] | 494 | struct pnv_phb *phb = pdn->phb->private_data; |
| 495 | u32 bdfn = (pdn->busno << 8) | pdn->devfn; |
Benjamin Herrenschmidt | 61305a9 | 2011-09-19 17:45:05 +0000 | [diff] [blame] | 496 | |
Alexey Kardashevskiy | 9e44754 | 2016-05-02 17:06:12 +1000 | [diff] [blame] | 497 | pr_devel("%s: bus: %x devfn: %x +%x/%x -> %08x\n", |
| 498 | __func__, pdn->busno, pdn->devfn, where, size, val); |
Benjamin Herrenschmidt | 61305a9 | 2011-09-19 17:45:05 +0000 | [diff] [blame] | 499 | switch (size) { |
| 500 | case 1: |
| 501 | opal_pci_config_write_byte(phb->opal_id, bdfn, where, val); |
| 502 | break; |
| 503 | case 2: |
| 504 | opal_pci_config_write_half_word(phb->opal_id, bdfn, where, val); |
| 505 | break; |
| 506 | case 4: |
| 507 | opal_pci_config_write_word(phb->opal_id, bdfn, where, val); |
| 508 | break; |
| 509 | default: |
| 510 | return PCIBIOS_FUNC_NOT_SUPPORTED; |
| 511 | } |
Gavin Shan | be7e744 | 2013-06-20 13:21:15 +0800 | [diff] [blame] | 512 | |
Benjamin Herrenschmidt | 61305a9 | 2011-09-19 17:45:05 +0000 | [diff] [blame] | 513 | return PCIBIOS_SUCCESSFUL; |
| 514 | } |
| 515 | |
Gavin Shan | d0914f5 | 2014-04-24 18:00:12 +1000 | [diff] [blame] | 516 | #if CONFIG_EEH |
Gavin Shan | 3532a741 | 2015-03-17 16:15:03 +1100 | [diff] [blame] | 517 | static bool pnv_pci_cfg_check(struct pci_dn *pdn) |
Gavin Shan | d0914f5 | 2014-04-24 18:00:12 +1000 | [diff] [blame] | 518 | { |
| 519 | struct eeh_dev *edev = NULL; |
Gavin Shan | 3532a741 | 2015-03-17 16:15:03 +1100 | [diff] [blame] | 520 | struct pnv_phb *phb = pdn->phb->private_data; |
Gavin Shan | d0914f5 | 2014-04-24 18:00:12 +1000 | [diff] [blame] | 521 | |
| 522 | /* EEH not enabled ? */ |
| 523 | if (!(phb->flags & PNV_PHB_FLAG_EEH)) |
| 524 | return true; |
| 525 | |
Gavin Shan | d2b0f6f | 2014-04-24 18:00:19 +1000 | [diff] [blame] | 526 | /* PE reset or device removed ? */ |
Gavin Shan | 3532a741 | 2015-03-17 16:15:03 +1100 | [diff] [blame] | 527 | edev = pdn->edev; |
Gavin Shan | d2b0f6f | 2014-04-24 18:00:19 +1000 | [diff] [blame] | 528 | if (edev) { |
| 529 | if (edev->pe && |
Gavin Shan | 8a6b371 | 2014-10-01 17:07:50 +1000 | [diff] [blame] | 530 | (edev->pe->state & EEH_PE_CFG_BLOCKED)) |
Gavin Shan | d2b0f6f | 2014-04-24 18:00:19 +1000 | [diff] [blame] | 531 | return false; |
| 532 | |
| 533 | if (edev->mode & EEH_DEV_REMOVED) |
| 534 | return false; |
| 535 | } |
Gavin Shan | d0914f5 | 2014-04-24 18:00:12 +1000 | [diff] [blame] | 536 | |
| 537 | return true; |
| 538 | } |
| 539 | #else |
Gavin Shan | 3532a741 | 2015-03-17 16:15:03 +1100 | [diff] [blame] | 540 | static inline pnv_pci_cfg_check(struct pci_dn *pdn) |
Gavin Shan | d0914f5 | 2014-04-24 18:00:12 +1000 | [diff] [blame] | 541 | { |
| 542 | return true; |
| 543 | } |
| 544 | #endif /* CONFIG_EEH */ |
| 545 | |
Gavin Shan | 9bf41be | 2013-06-27 13:46:48 +0800 | [diff] [blame] | 546 | static int pnv_pci_read_config(struct pci_bus *bus, |
| 547 | unsigned int devfn, |
| 548 | int where, int size, u32 *val) |
| 549 | { |
Gavin Shan | 9bf41be | 2013-06-27 13:46:48 +0800 | [diff] [blame] | 550 | struct pci_dn *pdn; |
Gavin Shan | d0914f5 | 2014-04-24 18:00:12 +1000 | [diff] [blame] | 551 | struct pnv_phb *phb; |
Gavin Shan | d0914f5 | 2014-04-24 18:00:12 +1000 | [diff] [blame] | 552 | int ret; |
Gavin Shan | 9bf41be | 2013-06-27 13:46:48 +0800 | [diff] [blame] | 553 | |
| 554 | *val = 0xFFFFFFFF; |
Gavin Shan | 3532a741 | 2015-03-17 16:15:03 +1100 | [diff] [blame] | 555 | pdn = pci_get_pdn_by_devfn(bus, devfn); |
| 556 | if (!pdn) |
Gavin Shan | d0914f5 | 2014-04-24 18:00:12 +1000 | [diff] [blame] | 557 | return PCIBIOS_DEVICE_NOT_FOUND; |
| 558 | |
Gavin Shan | 3532a741 | 2015-03-17 16:15:03 +1100 | [diff] [blame] | 559 | if (!pnv_pci_cfg_check(pdn)) |
| 560 | return PCIBIOS_DEVICE_NOT_FOUND; |
| 561 | |
| 562 | ret = pnv_pci_cfg_read(pdn, where, size, val); |
| 563 | phb = pdn->phb->private_data; |
| 564 | if (phb->flags & PNV_PHB_FLAG_EEH && pdn->edev) { |
Gavin Shan | d0914f5 | 2014-04-24 18:00:12 +1000 | [diff] [blame] | 565 | if (*val == EEH_IO_ERROR_VALUE(size) && |
Gavin Shan | 3532a741 | 2015-03-17 16:15:03 +1100 | [diff] [blame] | 566 | eeh_dev_check_failure(pdn->edev)) |
Gavin Shan | d0914f5 | 2014-04-24 18:00:12 +1000 | [diff] [blame] | 567 | return PCIBIOS_DEVICE_NOT_FOUND; |
| 568 | } else { |
Gavin Shan | 3532a741 | 2015-03-17 16:15:03 +1100 | [diff] [blame] | 569 | pnv_pci_config_check_eeh(pdn); |
Gavin Shan | d0914f5 | 2014-04-24 18:00:12 +1000 | [diff] [blame] | 570 | } |
| 571 | |
| 572 | return ret; |
Gavin Shan | 9bf41be | 2013-06-27 13:46:48 +0800 | [diff] [blame] | 573 | } |
| 574 | |
| 575 | static int pnv_pci_write_config(struct pci_bus *bus, |
| 576 | unsigned int devfn, |
| 577 | int where, int size, u32 val) |
| 578 | { |
Gavin Shan | 9bf41be | 2013-06-27 13:46:48 +0800 | [diff] [blame] | 579 | struct pci_dn *pdn; |
Gavin Shan | d0914f5 | 2014-04-24 18:00:12 +1000 | [diff] [blame] | 580 | struct pnv_phb *phb; |
Gavin Shan | d0914f5 | 2014-04-24 18:00:12 +1000 | [diff] [blame] | 581 | int ret; |
Gavin Shan | 9bf41be | 2013-06-27 13:46:48 +0800 | [diff] [blame] | 582 | |
Gavin Shan | 3532a741 | 2015-03-17 16:15:03 +1100 | [diff] [blame] | 583 | pdn = pci_get_pdn_by_devfn(bus, devfn); |
| 584 | if (!pdn) |
Gavin Shan | d0914f5 | 2014-04-24 18:00:12 +1000 | [diff] [blame] | 585 | return PCIBIOS_DEVICE_NOT_FOUND; |
| 586 | |
Gavin Shan | 3532a741 | 2015-03-17 16:15:03 +1100 | [diff] [blame] | 587 | if (!pnv_pci_cfg_check(pdn)) |
| 588 | return PCIBIOS_DEVICE_NOT_FOUND; |
| 589 | |
| 590 | ret = pnv_pci_cfg_write(pdn, where, size, val); |
| 591 | phb = pdn->phb->private_data; |
Gavin Shan | d0914f5 | 2014-04-24 18:00:12 +1000 | [diff] [blame] | 592 | if (!(phb->flags & PNV_PHB_FLAG_EEH)) |
Gavin Shan | 3532a741 | 2015-03-17 16:15:03 +1100 | [diff] [blame] | 593 | pnv_pci_config_check_eeh(pdn); |
Gavin Shan | d0914f5 | 2014-04-24 18:00:12 +1000 | [diff] [blame] | 594 | |
| 595 | return ret; |
Gavin Shan | 9bf41be | 2013-06-27 13:46:48 +0800 | [diff] [blame] | 596 | } |
| 597 | |
Benjamin Herrenschmidt | 61305a9 | 2011-09-19 17:45:05 +0000 | [diff] [blame] | 598 | struct pci_ops pnv_pci_ops = { |
Gavin Shan | 9bf41be | 2013-06-27 13:46:48 +0800 | [diff] [blame] | 599 | .read = pnv_pci_read_config, |
Benjamin Herrenschmidt | 61305a9 | 2011-09-19 17:45:05 +0000 | [diff] [blame] | 600 | .write = pnv_pci_write_config, |
| 601 | }; |
| 602 | |
Alexey Kardashevskiy | c5bb44e | 2015-06-05 16:35:14 +1000 | [diff] [blame] | 603 | static __be64 *pnv_tce(struct iommu_table *tbl, long idx) |
| 604 | { |
| 605 | __be64 *tmp = ((__be64 *)tbl->it_base); |
Alexey Kardashevskiy | bbb845c | 2015-06-05 16:35:19 +1000 | [diff] [blame] | 606 | int level = tbl->it_indirect_levels; |
| 607 | const long shift = ilog2(tbl->it_level_size); |
| 608 | unsigned long mask = (tbl->it_level_size - 1) << (level * shift); |
| 609 | |
| 610 | while (level) { |
| 611 | int n = (idx & mask) >> (level * shift); |
| 612 | unsigned long tce = be64_to_cpu(tmp[n]); |
| 613 | |
| 614 | tmp = __va(tce & ~(TCE_PCI_READ | TCE_PCI_WRITE)); |
| 615 | idx &= ~mask; |
| 616 | mask >>= shift; |
| 617 | --level; |
| 618 | } |
Alexey Kardashevskiy | c5bb44e | 2015-06-05 16:35:14 +1000 | [diff] [blame] | 619 | |
| 620 | return tmp + idx; |
| 621 | } |
| 622 | |
Alexey Kardashevskiy | da004c3 | 2015-06-05 16:35:06 +1000 | [diff] [blame] | 623 | int pnv_tce_build(struct iommu_table *tbl, long index, long npages, |
| 624 | unsigned long uaddr, enum dma_data_direction direction, |
| 625 | struct dma_attrs *attrs) |
Benjamin Herrenschmidt | 61305a9 | 2011-09-19 17:45:05 +0000 | [diff] [blame] | 626 | { |
Alexey Kardashevskiy | 10b35b2 | 2015-06-05 16:35:05 +1000 | [diff] [blame] | 627 | u64 proto_tce = iommu_direction_to_tce_perm(direction); |
Alexey Kardashevskiy | c5bb44e | 2015-06-05 16:35:14 +1000 | [diff] [blame] | 628 | u64 rpn = __pa(uaddr) >> tbl->it_page_shift; |
| 629 | long i; |
Benjamin Herrenschmidt | 61305a9 | 2011-09-19 17:45:05 +0000 | [diff] [blame] | 630 | |
Alexey Kardashevskiy | 6ecad91 | 2016-02-17 18:26:31 +1100 | [diff] [blame] | 631 | if (proto_tce & TCE_PCI_WRITE) |
| 632 | proto_tce |= TCE_PCI_READ; |
| 633 | |
Alexey Kardashevskiy | c5bb44e | 2015-06-05 16:35:14 +1000 | [diff] [blame] | 634 | for (i = 0; i < npages; i++) { |
| 635 | unsigned long newtce = proto_tce | |
| 636 | ((rpn + i) << tbl->it_page_shift); |
| 637 | unsigned long idx = index - tbl->it_offset + i; |
Benjamin Herrenschmidt | 61305a9 | 2011-09-19 17:45:05 +0000 | [diff] [blame] | 638 | |
Alexey Kardashevskiy | c5bb44e | 2015-06-05 16:35:14 +1000 | [diff] [blame] | 639 | *(pnv_tce(tbl, idx)) = cpu_to_be64(newtce); |
| 640 | } |
Benjamin Herrenschmidt | 1f1616e | 2011-11-06 18:55:59 +0000 | [diff] [blame] | 641 | |
Benjamin Herrenschmidt | 61305a9 | 2011-09-19 17:45:05 +0000 | [diff] [blame] | 642 | return 0; |
| 643 | } |
| 644 | |
Alexey Kardashevskiy | 05c6cfb | 2015-06-05 16:35:15 +1000 | [diff] [blame] | 645 | #ifdef CONFIG_IOMMU_API |
| 646 | int pnv_tce_xchg(struct iommu_table *tbl, long index, |
| 647 | unsigned long *hpa, enum dma_data_direction *direction) |
| 648 | { |
| 649 | u64 proto_tce = iommu_direction_to_tce_perm(*direction); |
| 650 | unsigned long newtce = *hpa | proto_tce, oldtce; |
| 651 | unsigned long idx = index - tbl->it_offset; |
| 652 | |
| 653 | BUG_ON(*hpa & ~IOMMU_PAGE_MASK(tbl)); |
| 654 | |
Alexey Kardashevskiy | 6ecad91 | 2016-02-17 18:26:31 +1100 | [diff] [blame] | 655 | if (newtce & TCE_PCI_WRITE) |
| 656 | newtce |= TCE_PCI_READ; |
| 657 | |
Alexey Kardashevskiy | 05c6cfb | 2015-06-05 16:35:15 +1000 | [diff] [blame] | 658 | oldtce = xchg(pnv_tce(tbl, idx), cpu_to_be64(newtce)); |
| 659 | *hpa = be64_to_cpu(oldtce) & ~(TCE_PCI_READ | TCE_PCI_WRITE); |
| 660 | *direction = iommu_tce_direction(oldtce); |
| 661 | |
| 662 | return 0; |
| 663 | } |
| 664 | #endif |
| 665 | |
Alexey Kardashevskiy | da004c3 | 2015-06-05 16:35:06 +1000 | [diff] [blame] | 666 | void pnv_tce_free(struct iommu_table *tbl, long index, long npages) |
Benjamin Herrenschmidt | 61305a9 | 2011-09-19 17:45:05 +0000 | [diff] [blame] | 667 | { |
Alexey Kardashevskiy | c5bb44e | 2015-06-05 16:35:14 +1000 | [diff] [blame] | 668 | long i; |
Benjamin Herrenschmidt | 1f1616e | 2011-11-06 18:55:59 +0000 | [diff] [blame] | 669 | |
Alexey Kardashevskiy | c5bb44e | 2015-06-05 16:35:14 +1000 | [diff] [blame] | 670 | for (i = 0; i < npages; i++) { |
| 671 | unsigned long idx = index - tbl->it_offset + i; |
Benjamin Herrenschmidt | 61305a9 | 2011-09-19 17:45:05 +0000 | [diff] [blame] | 672 | |
Alexey Kardashevskiy | c5bb44e | 2015-06-05 16:35:14 +1000 | [diff] [blame] | 673 | *(pnv_tce(tbl, idx)) = cpu_to_be64(0); |
| 674 | } |
Alexey Kardashevskiy | 8e0a161 | 2013-08-28 18:37:43 +1000 | [diff] [blame] | 675 | } |
| 676 | |
Alexey Kardashevskiy | da004c3 | 2015-06-05 16:35:06 +1000 | [diff] [blame] | 677 | unsigned long pnv_tce_get(struct iommu_table *tbl, long index) |
Alexey Kardashevskiy | 11f63d3 | 2012-09-04 15:19:35 +0000 | [diff] [blame] | 678 | { |
Alexey Kardashevskiy | c5bb44e | 2015-06-05 16:35:14 +1000 | [diff] [blame] | 679 | return *(pnv_tce(tbl, index - tbl->it_offset)); |
Alexey Kardashevskiy | 11f63d3 | 2012-09-04 15:19:35 +0000 | [diff] [blame] | 680 | } |
| 681 | |
Alexey Kardashevskiy | 0eaf4de | 2015-06-05 16:35:09 +1000 | [diff] [blame] | 682 | struct iommu_table *pnv_pci_table_alloc(int nid) |
| 683 | { |
| 684 | struct iommu_table *tbl; |
| 685 | |
| 686 | tbl = kzalloc_node(sizeof(struct iommu_table), GFP_KERNEL, nid); |
| 687 | INIT_LIST_HEAD_RCU(&tbl->it_group_list); |
| 688 | |
| 689 | return tbl; |
| 690 | } |
| 691 | |
| 692 | long pnv_pci_link_table_and_group(int node, int num, |
| 693 | struct iommu_table *tbl, |
| 694 | struct iommu_table_group *table_group) |
| 695 | { |
| 696 | struct iommu_table_group_link *tgl = NULL; |
| 697 | |
| 698 | if (WARN_ON(!tbl || !table_group)) |
| 699 | return -EINVAL; |
| 700 | |
| 701 | tgl = kzalloc_node(sizeof(struct iommu_table_group_link), GFP_KERNEL, |
| 702 | node); |
| 703 | if (!tgl) |
| 704 | return -ENOMEM; |
| 705 | |
| 706 | tgl->table_group = table_group; |
| 707 | list_add_rcu(&tgl->next, &tbl->it_group_list); |
| 708 | |
| 709 | table_group->tables[num] = tbl; |
| 710 | |
| 711 | return 0; |
| 712 | } |
| 713 | |
| 714 | static void pnv_iommu_table_group_link_free(struct rcu_head *head) |
| 715 | { |
| 716 | struct iommu_table_group_link *tgl = container_of(head, |
| 717 | struct iommu_table_group_link, rcu); |
| 718 | |
| 719 | kfree(tgl); |
| 720 | } |
| 721 | |
| 722 | void pnv_pci_unlink_table_and_group(struct iommu_table *tbl, |
| 723 | struct iommu_table_group *table_group) |
| 724 | { |
| 725 | long i; |
| 726 | bool found; |
| 727 | struct iommu_table_group_link *tgl; |
| 728 | |
| 729 | if (!tbl || !table_group) |
| 730 | return; |
| 731 | |
| 732 | /* Remove link to a group from table's list of attached groups */ |
| 733 | found = false; |
| 734 | list_for_each_entry_rcu(tgl, &tbl->it_group_list, next) { |
| 735 | if (tgl->table_group == table_group) { |
| 736 | list_del_rcu(&tgl->next); |
| 737 | call_rcu(&tgl->rcu, pnv_iommu_table_group_link_free); |
| 738 | found = true; |
| 739 | break; |
| 740 | } |
| 741 | } |
| 742 | if (WARN_ON(!found)) |
| 743 | return; |
| 744 | |
| 745 | /* Clean a pointer to iommu_table in iommu_table_group::tables[] */ |
| 746 | found = false; |
| 747 | for (i = 0; i < IOMMU_TABLE_GROUP_MAX_TABLES; ++i) { |
| 748 | if (table_group->tables[i] == tbl) { |
| 749 | table_group->tables[i] = NULL; |
| 750 | found = true; |
| 751 | break; |
| 752 | } |
| 753 | } |
| 754 | WARN_ON(!found); |
| 755 | } |
| 756 | |
Benjamin Herrenschmidt | 61305a9 | 2011-09-19 17:45:05 +0000 | [diff] [blame] | 757 | void pnv_pci_setup_iommu_table(struct iommu_table *tbl, |
| 758 | void *tce_mem, u64 tce_size, |
Alexey Kardashevskiy | 8fa5d45 | 2014-06-06 18:44:03 +1000 | [diff] [blame] | 759 | u64 dma_offset, unsigned page_shift) |
Benjamin Herrenschmidt | 61305a9 | 2011-09-19 17:45:05 +0000 | [diff] [blame] | 760 | { |
| 761 | tbl->it_blocksize = 16; |
| 762 | tbl->it_base = (unsigned long)tce_mem; |
Alexey Kardashevskiy | 8fa5d45 | 2014-06-06 18:44:03 +1000 | [diff] [blame] | 763 | tbl->it_page_shift = page_shift; |
Alistair Popple | 3a55317 | 2013-12-09 18:17:02 +1100 | [diff] [blame] | 764 | tbl->it_offset = dma_offset >> tbl->it_page_shift; |
Benjamin Herrenschmidt | 61305a9 | 2011-09-19 17:45:05 +0000 | [diff] [blame] | 765 | tbl->it_index = 0; |
| 766 | tbl->it_size = tce_size >> 3; |
| 767 | tbl->it_busno = 0; |
| 768 | tbl->it_type = TCE_PCI; |
| 769 | } |
| 770 | |
Daniel Axtens | 92ae035 | 2015-04-28 15:12:05 +1000 | [diff] [blame] | 771 | void pnv_pci_dma_dev_setup(struct pci_dev *pdev) |
Benjamin Herrenschmidt | 61305a9 | 2011-09-19 17:45:05 +0000 | [diff] [blame] | 772 | { |
| 773 | struct pci_controller *hose = pci_bus_to_host(pdev->bus); |
| 774 | struct pnv_phb *phb = hose->private_data; |
Wei Yang | 781a868 | 2015-03-25 16:23:57 +0800 | [diff] [blame] | 775 | #ifdef CONFIG_PCI_IOV |
| 776 | struct pnv_ioda_pe *pe; |
| 777 | struct pci_dn *pdn; |
| 778 | |
| 779 | /* Fix the VF pdn PE number */ |
| 780 | if (pdev->is_virtfn) { |
| 781 | pdn = pci_get_pdn(pdev); |
| 782 | WARN_ON(pdn->pe_number != IODA_INVALID_PE); |
| 783 | list_for_each_entry(pe, &phb->ioda.pe_list, list) { |
| 784 | if (pe->rid == ((pdev->bus->number << 8) | |
| 785 | (pdev->devfn & 0xff))) { |
| 786 | pdn->pe_number = pe->pe_number; |
| 787 | pe->pdev = pdev; |
| 788 | break; |
| 789 | } |
| 790 | } |
| 791 | } |
| 792 | #endif /* CONFIG_PCI_IOV */ |
Benjamin Herrenschmidt | 61305a9 | 2011-09-19 17:45:05 +0000 | [diff] [blame] | 793 | |
Benjamin Herrenschmidt | 61305a9 | 2011-09-19 17:45:05 +0000 | [diff] [blame] | 794 | if (phb && phb->dma_dev_setup) |
| 795 | phb->dma_dev_setup(phb, pdev); |
Benjamin Herrenschmidt | 61305a9 | 2011-09-19 17:45:05 +0000 | [diff] [blame] | 796 | } |
| 797 | |
Gavin Shan | 1bc74f1 | 2016-02-09 15:50:22 +1100 | [diff] [blame] | 798 | void pnv_pci_dma_bus_setup(struct pci_bus *bus) |
| 799 | { |
| 800 | struct pci_controller *hose = bus->sysdata; |
| 801 | struct pnv_phb *phb = hose->private_data; |
| 802 | struct pnv_ioda_pe *pe; |
| 803 | |
| 804 | list_for_each_entry(pe, &phb->ioda.pe_list, list) { |
| 805 | if (!(pe->flags & (PNV_IODA_PE_BUS | PNV_IODA_PE_BUS_ALL))) |
| 806 | continue; |
| 807 | |
| 808 | if (!pe->pbus) |
| 809 | continue; |
| 810 | |
| 811 | if (bus->number == ((pe->rid >> 8) & 0xFF)) { |
| 812 | pe->pbus = bus; |
| 813 | break; |
| 814 | } |
| 815 | } |
| 816 | } |
| 817 | |
Benjamin Herrenschmidt | 73ed148 | 2013-05-10 16:59:18 +1000 | [diff] [blame] | 818 | void pnv_pci_shutdown(void) |
| 819 | { |
| 820 | struct pci_controller *hose; |
| 821 | |
Michael Neuling | 7a8e6bb | 2015-05-27 16:06:59 +1000 | [diff] [blame] | 822 | list_for_each_entry(hose, &hose_list, list_node) |
| 823 | if (hose->controller_ops.shutdown) |
| 824 | hose->controller_ops.shutdown(hose); |
Benjamin Herrenschmidt | 73ed148 | 2013-05-10 16:59:18 +1000 | [diff] [blame] | 825 | } |
| 826 | |
Gavin Shan | aa0c033 | 2013-04-25 19:20:57 +0000 | [diff] [blame] | 827 | /* Fixup wrong class code in p7ioc and p8 root complex */ |
Greg Kroah-Hartman | cad5cef | 2012-12-21 14:04:10 -0800 | [diff] [blame] | 828 | static void pnv_p7ioc_rc_quirk(struct pci_dev *dev) |
Benjamin Herrenschmidt | ca45cfe | 2011-11-06 18:56:00 +0000 | [diff] [blame] | 829 | { |
| 830 | dev->class = PCI_CLASS_BRIDGE_PCI << 8; |
| 831 | } |
| 832 | DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_IBM, 0x3b9, pnv_p7ioc_rc_quirk); |
| 833 | |
Benjamin Herrenschmidt | 61305a9 | 2011-09-19 17:45:05 +0000 | [diff] [blame] | 834 | void __init pnv_pci_init(void) |
| 835 | { |
| 836 | struct device_node *np; |
| 837 | |
Bjorn Helgaas | 673c975 | 2012-02-23 20:18:58 -0700 | [diff] [blame] | 838 | pci_add_flags(PCI_CAN_SKIP_ISA_ALIGN); |
Benjamin Herrenschmidt | 61305a9 | 2011-09-19 17:45:05 +0000 | [diff] [blame] | 839 | |
Michael Ellerman | 646b54f | 2015-03-12 17:27:11 +1100 | [diff] [blame] | 840 | /* If we don't have OPAL, eg. in sim, just skip PCI probe */ |
| 841 | if (!firmware_has_feature(FW_FEATURE_OPAL)) |
| 842 | return; |
| 843 | |
Russell Currey | 2de50e9 | 2016-02-08 15:08:20 +1100 | [diff] [blame] | 844 | /* Look for IODA IO-Hubs. */ |
Michael Ellerman | 646b54f | 2015-03-12 17:27:11 +1100 | [diff] [blame] | 845 | for_each_compatible_node(np, NULL, "ibm,ioda-hub") { |
| 846 | pnv_pci_init_ioda_hub(np); |
Benjamin Herrenschmidt | 184cd4a | 2011-11-15 17:29:08 +0000 | [diff] [blame] | 847 | } |
Benjamin Herrenschmidt | 184cd4a | 2011-11-15 17:29:08 +0000 | [diff] [blame] | 848 | |
Michael Ellerman | 646b54f | 2015-03-12 17:27:11 +1100 | [diff] [blame] | 849 | /* Look for ioda2 built-in PHB3's */ |
| 850 | for_each_compatible_node(np, NULL, "ibm,ioda2-phb") |
| 851 | pnv_pci_init_ioda2_phb(np); |
Benjamin Herrenschmidt | 61305a9 | 2011-09-19 17:45:05 +0000 | [diff] [blame] | 852 | |
Alistair Popple | 5d2aa71 | 2015-12-17 13:43:13 +1100 | [diff] [blame] | 853 | /* Look for NPU PHBs */ |
| 854 | for_each_compatible_node(np, NULL, "ibm,ioda2-npu-phb") |
| 855 | pnv_pci_init_npu_phb(np); |
| 856 | |
Benjamin Herrenschmidt | 61305a9 | 2011-09-19 17:45:05 +0000 | [diff] [blame] | 857 | /* Configure IOMMU DMA hooks */ |
Benjamin Herrenschmidt | 61305a9 | 2011-09-19 17:45:05 +0000 | [diff] [blame] | 858 | set_pci_dma_ops(&dma_iommu_ops); |
Benjamin Herrenschmidt | 61305a9 | 2011-09-19 17:45:05 +0000 | [diff] [blame] | 859 | } |
Alexey Kardashevskiy | d905c5d | 2013-11-21 17:43:14 +1100 | [diff] [blame] | 860 | |
Michael Ellerman | b14726c | 2014-07-15 22:22:24 +1000 | [diff] [blame] | 861 | machine_subsys_initcall_sync(powernv, tce_iommu_bus_notifier_init); |