Joerg Roedel | 9b1b0e4 | 2012-09-26 12:44:45 +0200 | [diff] [blame] | 1 | #include <linux/seq_file.h> |
Joerg Roedel | 1c4248c | 2012-09-26 12:44:35 +0200 | [diff] [blame] | 2 | #include <linux/cpumask.h> |
Joerg Roedel | 736baef | 2012-03-30 11:47:00 -0700 | [diff] [blame] | 3 | #include <linux/kernel.h> |
| 4 | #include <linux/string.h> |
| 5 | #include <linux/errno.h> |
Joerg Roedel | 98f1ad2 | 2012-07-06 13:28:37 +0200 | [diff] [blame] | 6 | #include <linux/msi.h> |
Joerg Roedel | 5afba62 | 2012-09-26 12:44:38 +0200 | [diff] [blame] | 7 | #include <linux/irq.h> |
| 8 | #include <linux/pci.h> |
Joerg Roedel | 98f1ad2 | 2012-07-06 13:28:37 +0200 | [diff] [blame] | 9 | |
| 10 | #include <asm/hw_irq.h> |
| 11 | #include <asm/irq_remapping.h> |
Joerg Roedel | 1c4248c | 2012-09-26 12:44:35 +0200 | [diff] [blame] | 12 | #include <asm/processor.h> |
| 13 | #include <asm/x86_init.h> |
| 14 | #include <asm/apic.h> |
Joerg Roedel | 736baef | 2012-03-30 11:47:00 -0700 | [diff] [blame] | 15 | |
Suresh Siddha | 8a8f422 | 2012-03-30 11:47:08 -0700 | [diff] [blame] | 16 | #include "irq_remapping.h" |
Joerg Roedel | 736baef | 2012-03-30 11:47:00 -0700 | [diff] [blame] | 17 | |
Suresh Siddha | 95a02e9 | 2012-03-30 11:47:07 -0700 | [diff] [blame] | 18 | int irq_remapping_enabled; |
Joerg Roedel | 736baef | 2012-03-30 11:47:00 -0700 | [diff] [blame] | 19 | |
Suresh Siddha | 95a02e9 | 2012-03-30 11:47:07 -0700 | [diff] [blame] | 20 | int disable_irq_remap; |
Joerg Roedel | 736baef | 2012-03-30 11:47:00 -0700 | [diff] [blame] | 21 | int disable_sourceid_checking; |
| 22 | int no_x2apic_optout; |
| 23 | |
| 24 | static struct irq_remap_ops *remap_ops; |
| 25 | |
Joerg Roedel | 5afba62 | 2012-09-26 12:44:38 +0200 | [diff] [blame] | 26 | static int msi_alloc_remapped_irq(struct pci_dev *pdev, int irq, int nvec); |
| 27 | static int msi_setup_remapped_irq(struct pci_dev *pdev, unsigned int irq, |
| 28 | int index, int sub_handle); |
Joerg Roedel | 373dd7a | 2012-09-26 12:44:39 +0200 | [diff] [blame] | 29 | static int set_remapped_irq_affinity(struct irq_data *data, |
| 30 | const struct cpumask *mask, |
| 31 | bool force); |
Joerg Roedel | 5afba62 | 2012-09-26 12:44:38 +0200 | [diff] [blame] | 32 | |
Joerg Roedel | a1bb20c | 2012-09-26 12:44:51 +0200 | [diff] [blame] | 33 | static bool irq_remapped(struct irq_cfg *cfg) |
| 34 | { |
| 35 | return (cfg->remapped == 1); |
| 36 | } |
| 37 | |
Joerg Roedel | 1c4248c | 2012-09-26 12:44:35 +0200 | [diff] [blame] | 38 | static void irq_remapping_disable_io_apic(void) |
| 39 | { |
| 40 | /* |
| 41 | * With interrupt-remapping, for now we will use virtual wire A |
| 42 | * mode, as virtual wire B is little complex (need to configure |
| 43 | * both IOAPIC RTE as well as interrupt-remapping table entry). |
| 44 | * As this gets called during crash dump, keep this simple for |
| 45 | * now. |
| 46 | */ |
| 47 | if (cpu_has_apic || apic_from_smp_config()) |
| 48 | disconnect_bsp_APIC(0); |
| 49 | } |
| 50 | |
Joerg Roedel | 5afba62 | 2012-09-26 12:44:38 +0200 | [diff] [blame] | 51 | static int do_setup_msi_irqs(struct pci_dev *dev, int nvec) |
| 52 | { |
| 53 | int node, ret, sub_handle, index = 0; |
| 54 | unsigned int irq; |
| 55 | struct msi_desc *msidesc; |
| 56 | |
| 57 | nvec = __roundup_pow_of_two(nvec); |
| 58 | |
| 59 | WARN_ON(!list_is_singular(&dev->msi_list)); |
| 60 | msidesc = list_entry(dev->msi_list.next, struct msi_desc, list); |
| 61 | WARN_ON(msidesc->irq); |
| 62 | WARN_ON(msidesc->msi_attrib.multiple); |
| 63 | |
| 64 | node = dev_to_node(&dev->dev); |
| 65 | irq = __create_irqs(get_nr_irqs_gsi(), nvec, node); |
| 66 | if (irq == 0) |
| 67 | return -ENOSPC; |
| 68 | |
| 69 | msidesc->msi_attrib.multiple = ilog2(nvec); |
| 70 | for (sub_handle = 0; sub_handle < nvec; sub_handle++) { |
| 71 | if (!sub_handle) { |
| 72 | index = msi_alloc_remapped_irq(dev, irq, nvec); |
| 73 | if (index < 0) { |
| 74 | ret = index; |
| 75 | goto error; |
| 76 | } |
| 77 | } else { |
| 78 | ret = msi_setup_remapped_irq(dev, irq + sub_handle, |
| 79 | index, sub_handle); |
| 80 | if (ret < 0) |
| 81 | goto error; |
| 82 | } |
| 83 | ret = setup_msi_irq(dev, msidesc, irq, sub_handle); |
| 84 | if (ret < 0) |
| 85 | goto error; |
| 86 | } |
| 87 | return 0; |
| 88 | |
| 89 | error: |
| 90 | destroy_irqs(irq, nvec); |
| 91 | |
| 92 | /* |
| 93 | * Restore altered MSI descriptor fields and prevent just destroyed |
| 94 | * IRQs from tearing down again in default_teardown_msi_irqs() |
| 95 | */ |
| 96 | msidesc->irq = 0; |
| 97 | msidesc->msi_attrib.multiple = 0; |
| 98 | |
| 99 | return ret; |
| 100 | } |
| 101 | |
| 102 | static int do_setup_msix_irqs(struct pci_dev *dev, int nvec) |
| 103 | { |
| 104 | int node, ret, sub_handle, index = 0; |
| 105 | struct msi_desc *msidesc; |
| 106 | unsigned int irq; |
| 107 | |
| 108 | node = dev_to_node(&dev->dev); |
| 109 | irq = get_nr_irqs_gsi(); |
| 110 | sub_handle = 0; |
| 111 | |
| 112 | list_for_each_entry(msidesc, &dev->msi_list, list) { |
| 113 | |
| 114 | irq = create_irq_nr(irq, node); |
| 115 | if (irq == 0) |
| 116 | return -1; |
| 117 | |
| 118 | if (sub_handle == 0) |
| 119 | ret = index = msi_alloc_remapped_irq(dev, irq, nvec); |
| 120 | else |
| 121 | ret = msi_setup_remapped_irq(dev, irq, index, sub_handle); |
| 122 | |
| 123 | if (ret < 0) |
| 124 | goto error; |
| 125 | |
| 126 | ret = setup_msi_irq(dev, msidesc, irq, 0); |
| 127 | if (ret < 0) |
| 128 | goto error; |
| 129 | |
| 130 | sub_handle += 1; |
| 131 | irq += 1; |
| 132 | } |
| 133 | |
| 134 | return 0; |
| 135 | |
| 136 | error: |
| 137 | destroy_irq(irq); |
| 138 | return ret; |
| 139 | } |
| 140 | |
| 141 | static int irq_remapping_setup_msi_irqs(struct pci_dev *dev, |
| 142 | int nvec, int type) |
| 143 | { |
| 144 | if (type == PCI_CAP_ID_MSI) |
| 145 | return do_setup_msi_irqs(dev, nvec); |
| 146 | else |
| 147 | return do_setup_msix_irqs(dev, nvec); |
| 148 | } |
| 149 | |
Joerg Roedel | da16532 | 2012-09-26 12:44:50 +0200 | [diff] [blame] | 150 | void eoi_ioapic_pin_remapped(int apic, int pin, int vector) |
| 151 | { |
| 152 | /* |
| 153 | * Intr-remapping uses pin number as the virtual vector |
| 154 | * in the RTE. Actual vector is programmed in |
| 155 | * intr-remapping table entry. Hence for the io-apic |
| 156 | * EOI we use the pin number. |
| 157 | */ |
| 158 | io_apic_eoi(apic, pin); |
| 159 | } |
| 160 | |
Joerg Roedel | 1c4248c | 2012-09-26 12:44:35 +0200 | [diff] [blame] | 161 | static void __init irq_remapping_modify_x86_ops(void) |
| 162 | { |
Joerg Roedel | 71054d8 | 2012-09-26 12:44:37 +0200 | [diff] [blame] | 163 | x86_io_apic_ops.disable = irq_remapping_disable_io_apic; |
Joerg Roedel | 373dd7a | 2012-09-26 12:44:39 +0200 | [diff] [blame] | 164 | x86_io_apic_ops.set_affinity = set_remapped_irq_affinity; |
Joerg Roedel | a6a25dd | 2012-09-26 12:44:40 +0200 | [diff] [blame] | 165 | x86_io_apic_ops.setup_entry = setup_ioapic_remapped_entry; |
Joerg Roedel | da16532 | 2012-09-26 12:44:50 +0200 | [diff] [blame] | 166 | x86_io_apic_ops.eoi_ioapic_pin = eoi_ioapic_pin_remapped; |
Joerg Roedel | 5afba62 | 2012-09-26 12:44:38 +0200 | [diff] [blame] | 167 | x86_msi.setup_msi_irqs = irq_remapping_setup_msi_irqs; |
Joerg Roedel | 71054d8 | 2012-09-26 12:44:37 +0200 | [diff] [blame] | 168 | x86_msi.setup_hpet_msi = setup_hpet_msi_remapped; |
Joerg Roedel | 7601384 | 2012-09-26 12:44:49 +0200 | [diff] [blame] | 169 | x86_msi.compose_msi_msg = compose_remapped_msi_msg; |
Joerg Roedel | 1c4248c | 2012-09-26 12:44:35 +0200 | [diff] [blame] | 170 | } |
| 171 | |
Joerg Roedel | 736baef | 2012-03-30 11:47:00 -0700 | [diff] [blame] | 172 | static __init int setup_nointremap(char *str) |
| 173 | { |
Suresh Siddha | 95a02e9 | 2012-03-30 11:47:07 -0700 | [diff] [blame] | 174 | disable_irq_remap = 1; |
Joerg Roedel | 736baef | 2012-03-30 11:47:00 -0700 | [diff] [blame] | 175 | return 0; |
| 176 | } |
| 177 | early_param("nointremap", setup_nointremap); |
| 178 | |
Suresh Siddha | 95a02e9 | 2012-03-30 11:47:07 -0700 | [diff] [blame] | 179 | static __init int setup_irqremap(char *str) |
Joerg Roedel | 736baef | 2012-03-30 11:47:00 -0700 | [diff] [blame] | 180 | { |
| 181 | if (!str) |
| 182 | return -EINVAL; |
| 183 | |
| 184 | while (*str) { |
| 185 | if (!strncmp(str, "on", 2)) |
Suresh Siddha | 95a02e9 | 2012-03-30 11:47:07 -0700 | [diff] [blame] | 186 | disable_irq_remap = 0; |
Joerg Roedel | 736baef | 2012-03-30 11:47:00 -0700 | [diff] [blame] | 187 | else if (!strncmp(str, "off", 3)) |
Suresh Siddha | 95a02e9 | 2012-03-30 11:47:07 -0700 | [diff] [blame] | 188 | disable_irq_remap = 1; |
Joerg Roedel | 736baef | 2012-03-30 11:47:00 -0700 | [diff] [blame] | 189 | else if (!strncmp(str, "nosid", 5)) |
| 190 | disable_sourceid_checking = 1; |
| 191 | else if (!strncmp(str, "no_x2apic_optout", 16)) |
| 192 | no_x2apic_optout = 1; |
| 193 | |
| 194 | str += strcspn(str, ","); |
| 195 | while (*str == ',') |
| 196 | str++; |
| 197 | } |
| 198 | |
| 199 | return 0; |
| 200 | } |
Suresh Siddha | 95a02e9 | 2012-03-30 11:47:07 -0700 | [diff] [blame] | 201 | early_param("intremap", setup_irqremap); |
Joerg Roedel | 736baef | 2012-03-30 11:47:00 -0700 | [diff] [blame] | 202 | |
Suresh Siddha | 95a02e9 | 2012-03-30 11:47:07 -0700 | [diff] [blame] | 203 | void __init setup_irq_remapping_ops(void) |
Joerg Roedel | 736baef | 2012-03-30 11:47:00 -0700 | [diff] [blame] | 204 | { |
| 205 | remap_ops = &intel_irq_remap_ops; |
Joerg Roedel | c18d238 | 2012-06-26 16:59:34 +0200 | [diff] [blame] | 206 | |
| 207 | #ifdef CONFIG_AMD_IOMMU |
| 208 | if (amd_iommu_irq_ops.prepare() == 0) |
| 209 | remap_ops = &amd_iommu_irq_ops; |
| 210 | #endif |
Joerg Roedel | 736baef | 2012-03-30 11:47:00 -0700 | [diff] [blame] | 211 | } |
| 212 | |
Suresh Siddha | 95a02e9 | 2012-03-30 11:47:07 -0700 | [diff] [blame] | 213 | int irq_remapping_supported(void) |
Joerg Roedel | 736baef | 2012-03-30 11:47:00 -0700 | [diff] [blame] | 214 | { |
Suresh Siddha | 95a02e9 | 2012-03-30 11:47:07 -0700 | [diff] [blame] | 215 | if (disable_irq_remap) |
Joerg Roedel | 736baef | 2012-03-30 11:47:00 -0700 | [diff] [blame] | 216 | return 0; |
| 217 | |
| 218 | if (!remap_ops || !remap_ops->supported) |
| 219 | return 0; |
| 220 | |
| 221 | return remap_ops->supported(); |
| 222 | } |
| 223 | |
Suresh Siddha | 95a02e9 | 2012-03-30 11:47:07 -0700 | [diff] [blame] | 224 | int __init irq_remapping_prepare(void) |
Joerg Roedel | 736baef | 2012-03-30 11:47:00 -0700 | [diff] [blame] | 225 | { |
Suresh Siddha | 95a02e9 | 2012-03-30 11:47:07 -0700 | [diff] [blame] | 226 | if (!remap_ops || !remap_ops->prepare) |
Joerg Roedel | 736baef | 2012-03-30 11:47:00 -0700 | [diff] [blame] | 227 | return -ENODEV; |
| 228 | |
Suresh Siddha | 95a02e9 | 2012-03-30 11:47:07 -0700 | [diff] [blame] | 229 | return remap_ops->prepare(); |
Joerg Roedel | 736baef | 2012-03-30 11:47:00 -0700 | [diff] [blame] | 230 | } |
| 231 | |
Suresh Siddha | 95a02e9 | 2012-03-30 11:47:07 -0700 | [diff] [blame] | 232 | int __init irq_remapping_enable(void) |
Joerg Roedel | 736baef | 2012-03-30 11:47:00 -0700 | [diff] [blame] | 233 | { |
Joerg Roedel | 1c4248c | 2012-09-26 12:44:35 +0200 | [diff] [blame] | 234 | int ret; |
| 235 | |
Suresh Siddha | 95a02e9 | 2012-03-30 11:47:07 -0700 | [diff] [blame] | 236 | if (!remap_ops || !remap_ops->enable) |
Joerg Roedel | 736baef | 2012-03-30 11:47:00 -0700 | [diff] [blame] | 237 | return -ENODEV; |
| 238 | |
Joerg Roedel | 1c4248c | 2012-09-26 12:44:35 +0200 | [diff] [blame] | 239 | ret = remap_ops->enable(); |
| 240 | |
| 241 | if (irq_remapping_enabled) |
| 242 | irq_remapping_modify_x86_ops(); |
| 243 | |
| 244 | return ret; |
Joerg Roedel | 736baef | 2012-03-30 11:47:00 -0700 | [diff] [blame] | 245 | } |
Joerg Roedel | 4f3d8b6 | 2012-03-30 11:47:01 -0700 | [diff] [blame] | 246 | |
Suresh Siddha | 95a02e9 | 2012-03-30 11:47:07 -0700 | [diff] [blame] | 247 | void irq_remapping_disable(void) |
Joerg Roedel | 4f3d8b6 | 2012-03-30 11:47:01 -0700 | [diff] [blame] | 248 | { |
Joerg Roedel | 70733e0 | 2012-09-26 12:44:33 +0200 | [diff] [blame] | 249 | if (!irq_remapping_enabled || |
| 250 | !remap_ops || |
| 251 | !remap_ops->disable) |
Joerg Roedel | 4f3d8b6 | 2012-03-30 11:47:01 -0700 | [diff] [blame] | 252 | return; |
| 253 | |
Suresh Siddha | 95a02e9 | 2012-03-30 11:47:07 -0700 | [diff] [blame] | 254 | remap_ops->disable(); |
Joerg Roedel | 4f3d8b6 | 2012-03-30 11:47:01 -0700 | [diff] [blame] | 255 | } |
| 256 | |
Suresh Siddha | 95a02e9 | 2012-03-30 11:47:07 -0700 | [diff] [blame] | 257 | int irq_remapping_reenable(int mode) |
Joerg Roedel | 4f3d8b6 | 2012-03-30 11:47:01 -0700 | [diff] [blame] | 258 | { |
Joerg Roedel | 70733e0 | 2012-09-26 12:44:33 +0200 | [diff] [blame] | 259 | if (!irq_remapping_enabled || |
| 260 | !remap_ops || |
| 261 | !remap_ops->reenable) |
Joerg Roedel | 4f3d8b6 | 2012-03-30 11:47:01 -0700 | [diff] [blame] | 262 | return 0; |
| 263 | |
Suresh Siddha | 95a02e9 | 2012-03-30 11:47:07 -0700 | [diff] [blame] | 264 | return remap_ops->reenable(mode); |
Joerg Roedel | 4f3d8b6 | 2012-03-30 11:47:01 -0700 | [diff] [blame] | 265 | } |
| 266 | |
Suresh Siddha | 95a02e9 | 2012-03-30 11:47:07 -0700 | [diff] [blame] | 267 | int __init irq_remap_enable_fault_handling(void) |
Joerg Roedel | 4f3d8b6 | 2012-03-30 11:47:01 -0700 | [diff] [blame] | 268 | { |
Joerg Roedel | 70733e0 | 2012-09-26 12:44:33 +0200 | [diff] [blame] | 269 | if (!irq_remapping_enabled) |
| 270 | return 0; |
| 271 | |
Joerg Roedel | 4f3d8b6 | 2012-03-30 11:47:01 -0700 | [diff] [blame] | 272 | if (!remap_ops || !remap_ops->enable_faulting) |
| 273 | return -ENODEV; |
| 274 | |
| 275 | return remap_ops->enable_faulting(); |
| 276 | } |
Joerg Roedel | 0c3f173 | 2012-03-30 11:47:02 -0700 | [diff] [blame] | 277 | |
Suresh Siddha | 95a02e9 | 2012-03-30 11:47:07 -0700 | [diff] [blame] | 278 | int setup_ioapic_remapped_entry(int irq, |
| 279 | struct IO_APIC_route_entry *entry, |
| 280 | unsigned int destination, int vector, |
| 281 | struct io_apic_irq_attr *attr) |
Joerg Roedel | 0c3f173 | 2012-03-30 11:47:02 -0700 | [diff] [blame] | 282 | { |
| 283 | if (!remap_ops || !remap_ops->setup_ioapic_entry) |
| 284 | return -ENODEV; |
| 285 | |
| 286 | return remap_ops->setup_ioapic_entry(irq, entry, destination, |
| 287 | vector, attr); |
| 288 | } |
Joerg Roedel | 4c1bad6 | 2012-03-30 11:47:03 -0700 | [diff] [blame] | 289 | |
Suresh Siddha | 95a02e9 | 2012-03-30 11:47:07 -0700 | [diff] [blame] | 290 | int set_remapped_irq_affinity(struct irq_data *data, const struct cpumask *mask, |
| 291 | bool force) |
Joerg Roedel | 4c1bad6 | 2012-03-30 11:47:03 -0700 | [diff] [blame] | 292 | { |
Suresh Siddha | 7eb9ae0 | 2012-06-14 18:28:49 -0700 | [diff] [blame] | 293 | if (!config_enabled(CONFIG_SMP) || !remap_ops || |
| 294 | !remap_ops->set_affinity) |
Joerg Roedel | 4c1bad6 | 2012-03-30 11:47:03 -0700 | [diff] [blame] | 295 | return 0; |
| 296 | |
| 297 | return remap_ops->set_affinity(data, mask, force); |
| 298 | } |
Joerg Roedel | 9d619f6 | 2012-03-30 11:47:04 -0700 | [diff] [blame] | 299 | |
Suresh Siddha | 95a02e9 | 2012-03-30 11:47:07 -0700 | [diff] [blame] | 300 | void free_remapped_irq(int irq) |
Joerg Roedel | 9d619f6 | 2012-03-30 11:47:04 -0700 | [diff] [blame] | 301 | { |
Joerg Roedel | 11b4a1c | 2012-09-26 12:44:47 +0200 | [diff] [blame] | 302 | struct irq_cfg *cfg = irq_get_chip_data(irq); |
| 303 | |
Joerg Roedel | 9d619f6 | 2012-03-30 11:47:04 -0700 | [diff] [blame] | 304 | if (!remap_ops || !remap_ops->free_irq) |
| 305 | return; |
| 306 | |
Joerg Roedel | 11b4a1c | 2012-09-26 12:44:47 +0200 | [diff] [blame] | 307 | if (irq_remapped(cfg)) |
| 308 | remap_ops->free_irq(irq); |
Joerg Roedel | 9d619f6 | 2012-03-30 11:47:04 -0700 | [diff] [blame] | 309 | } |
Joerg Roedel | 5e2b930 | 2012-03-30 11:47:05 -0700 | [diff] [blame] | 310 | |
Suresh Siddha | 95a02e9 | 2012-03-30 11:47:07 -0700 | [diff] [blame] | 311 | void compose_remapped_msi_msg(struct pci_dev *pdev, |
| 312 | unsigned int irq, unsigned int dest, |
| 313 | struct msi_msg *msg, u8 hpet_id) |
Joerg Roedel | 5e2b930 | 2012-03-30 11:47:05 -0700 | [diff] [blame] | 314 | { |
Joerg Roedel | 7601384 | 2012-09-26 12:44:49 +0200 | [diff] [blame] | 315 | struct irq_cfg *cfg = irq_get_chip_data(irq); |
Joerg Roedel | 5e2b930 | 2012-03-30 11:47:05 -0700 | [diff] [blame] | 316 | |
Joerg Roedel | 7601384 | 2012-09-26 12:44:49 +0200 | [diff] [blame] | 317 | if (!irq_remapped(cfg)) |
| 318 | native_compose_msi_msg(pdev, irq, dest, msg, hpet_id); |
| 319 | else if (remap_ops && remap_ops->compose_msi_msg) |
| 320 | remap_ops->compose_msi_msg(pdev, irq, dest, msg, hpet_id); |
Joerg Roedel | 5e2b930 | 2012-03-30 11:47:05 -0700 | [diff] [blame] | 321 | } |
| 322 | |
Joerg Roedel | 5afba62 | 2012-09-26 12:44:38 +0200 | [diff] [blame] | 323 | static int msi_alloc_remapped_irq(struct pci_dev *pdev, int irq, int nvec) |
Joerg Roedel | 5e2b930 | 2012-03-30 11:47:05 -0700 | [diff] [blame] | 324 | { |
| 325 | if (!remap_ops || !remap_ops->msi_alloc_irq) |
| 326 | return -ENODEV; |
| 327 | |
| 328 | return remap_ops->msi_alloc_irq(pdev, irq, nvec); |
| 329 | } |
| 330 | |
Joerg Roedel | 5afba62 | 2012-09-26 12:44:38 +0200 | [diff] [blame] | 331 | static int msi_setup_remapped_irq(struct pci_dev *pdev, unsigned int irq, |
| 332 | int index, int sub_handle) |
Joerg Roedel | 5e2b930 | 2012-03-30 11:47:05 -0700 | [diff] [blame] | 333 | { |
| 334 | if (!remap_ops || !remap_ops->msi_setup_irq) |
| 335 | return -ENODEV; |
| 336 | |
| 337 | return remap_ops->msi_setup_irq(pdev, irq, index, sub_handle); |
| 338 | } |
| 339 | |
Suresh Siddha | 95a02e9 | 2012-03-30 11:47:07 -0700 | [diff] [blame] | 340 | int setup_hpet_msi_remapped(unsigned int irq, unsigned int id) |
Joerg Roedel | 5e2b930 | 2012-03-30 11:47:05 -0700 | [diff] [blame] | 341 | { |
| 342 | if (!remap_ops || !remap_ops->setup_hpet_msi) |
| 343 | return -ENODEV; |
| 344 | |
| 345 | return remap_ops->setup_hpet_msi(irq, id); |
| 346 | } |
Joerg Roedel | 6a9f5de | 2012-09-26 12:44:41 +0200 | [diff] [blame] | 347 | |
| 348 | void panic_if_irq_remap(const char *msg) |
| 349 | { |
| 350 | if (irq_remapping_enabled) |
| 351 | panic(msg); |
| 352 | } |
Joerg Roedel | 9b1b0e4 | 2012-09-26 12:44:45 +0200 | [diff] [blame] | 353 | |
| 354 | static void ir_ack_apic_edge(struct irq_data *data) |
| 355 | { |
| 356 | ack_APIC_irq(); |
| 357 | } |
| 358 | |
| 359 | static void ir_ack_apic_level(struct irq_data *data) |
| 360 | { |
| 361 | ack_APIC_irq(); |
| 362 | eoi_ioapic_irq(data->irq, data->chip_data); |
| 363 | } |
| 364 | |
| 365 | static void ir_print_prefix(struct irq_data *data, struct seq_file *p) |
| 366 | { |
| 367 | seq_printf(p, " IR-%s", data->chip->name); |
| 368 | } |
| 369 | |
| 370 | void irq_remap_modify_chip_defaults(struct irq_chip *chip) |
| 371 | { |
| 372 | chip->irq_print_chip = ir_print_prefix; |
| 373 | chip->irq_ack = ir_ack_apic_edge; |
| 374 | chip->irq_eoi = ir_ack_apic_level; |
| 375 | chip->irq_set_affinity = x86_io_apic_ops.set_affinity; |
| 376 | } |
Joerg Roedel | 2976fd8 | 2012-09-26 12:44:48 +0200 | [diff] [blame] | 377 | |
| 378 | bool setup_remapped_irq(int irq, struct irq_cfg *cfg, struct irq_chip *chip) |
| 379 | { |
| 380 | if (!irq_remapped(cfg)) |
| 381 | return false; |
| 382 | irq_set_status_flags(irq, IRQ_MOVE_PCNTXT); |
| 383 | irq_remap_modify_chip_defaults(chip); |
| 384 | return true; |
| 385 | } |