| .. | .. |
|---|
| 7 | 7 | #include <linux/slab.h> |
|---|
| 8 | 8 | #include <linux/string.h> |
|---|
| 9 | 9 | #include <linux/scatterlist.h> |
|---|
| 10 | +#include <linux/numa.h> |
|---|
| 10 | 11 | #include <asm/io.h> |
|---|
| 11 | | -#include <asm/pat.h> |
|---|
| 12 | +#include <asm/memtype.h> |
|---|
| 12 | 13 | #include <asm/x86_init.h> |
|---|
| 13 | | - |
|---|
| 14 | | -#ifdef __KERNEL__ |
|---|
| 15 | 14 | |
|---|
| 16 | 15 | struct pci_sysdata { |
|---|
| 17 | 16 | int domain; /* PCI domain */ |
|---|
| .. | .. |
|---|
| 26 | 25 | void *fwnode; /* IRQ domain for MSI assignment */ |
|---|
| 27 | 26 | #endif |
|---|
| 28 | 27 | #if IS_ENABLED(CONFIG_VMD) |
|---|
| 29 | | - bool vmd_domain; /* True if in Intel VMD domain */ |
|---|
| 28 | + struct pci_dev *vmd_dev; /* VMD Device if in Intel VMD domain */ |
|---|
| 30 | 29 | #endif |
|---|
| 31 | 30 | }; |
|---|
| 32 | 31 | |
|---|
| .. | .. |
|---|
| 34 | 33 | extern int noioapicquirk; |
|---|
| 35 | 34 | extern int noioapicreroute; |
|---|
| 36 | 35 | |
|---|
| 36 | +static inline struct pci_sysdata *to_pci_sysdata(const struct pci_bus *bus) |
|---|
| 37 | +{ |
|---|
| 38 | + return bus->sysdata; |
|---|
| 39 | +} |
|---|
| 40 | + |
|---|
| 37 | 41 | #ifdef CONFIG_PCI |
|---|
| 38 | 42 | |
|---|
| 39 | 43 | #ifdef CONFIG_PCI_DOMAINS |
|---|
| 40 | 44 | static inline int pci_domain_nr(struct pci_bus *bus) |
|---|
| 41 | 45 | { |
|---|
| 42 | | - struct pci_sysdata *sd = bus->sysdata; |
|---|
| 43 | | - |
|---|
| 44 | | - return sd->domain; |
|---|
| 46 | + return to_pci_sysdata(bus)->domain; |
|---|
| 45 | 47 | } |
|---|
| 46 | 48 | |
|---|
| 47 | 49 | static inline int pci_proc_domain(struct pci_bus *bus) |
|---|
| .. | .. |
|---|
| 53 | 55 | #ifdef CONFIG_PCI_MSI_IRQ_DOMAIN |
|---|
| 54 | 56 | static inline void *_pci_root_bus_fwnode(struct pci_bus *bus) |
|---|
| 55 | 57 | { |
|---|
| 56 | | - struct pci_sysdata *sd = bus->sysdata; |
|---|
| 57 | | - |
|---|
| 58 | | - return sd->fwnode; |
|---|
| 58 | + return to_pci_sysdata(bus)->fwnode; |
|---|
| 59 | 59 | } |
|---|
| 60 | 60 | |
|---|
| 61 | 61 | #define pci_root_bus_fwnode _pci_root_bus_fwnode |
|---|
| 62 | 62 | #endif |
|---|
| 63 | 63 | |
|---|
| 64 | +#if IS_ENABLED(CONFIG_VMD) |
|---|
| 64 | 65 | static inline bool is_vmd(struct pci_bus *bus) |
|---|
| 65 | 66 | { |
|---|
| 66 | | -#if IS_ENABLED(CONFIG_VMD) |
|---|
| 67 | | - struct pci_sysdata *sd = bus->sysdata; |
|---|
| 68 | | - |
|---|
| 69 | | - return sd->vmd_domain; |
|---|
| 70 | | -#else |
|---|
| 71 | | - return false; |
|---|
| 72 | | -#endif |
|---|
| 67 | + return to_pci_sysdata(bus)->vmd_dev != NULL; |
|---|
| 73 | 68 | } |
|---|
| 69 | +#else |
|---|
| 70 | +#define is_vmd(bus) false |
|---|
| 71 | +#endif /* CONFIG_VMD */ |
|---|
| 74 | 72 | |
|---|
| 75 | 73 | /* Can be used to override the logic in pci_scan_bus for skipping |
|---|
| 76 | 74 | already-configured bus numbers - to be used for buggy BIOSes |
|---|
| .. | .. |
|---|
| 107 | 105 | |
|---|
| 108 | 106 | extern void pci_iommu_alloc(void); |
|---|
| 109 | 107 | |
|---|
| 110 | | -#ifdef CONFIG_PCI_MSI |
|---|
| 111 | | -/* implemented in arch/x86/kernel/apic/io_apic. */ |
|---|
| 112 | | -struct msi_desc; |
|---|
| 113 | | -int native_setup_msi_irqs(struct pci_dev *dev, int nvec, int type); |
|---|
| 114 | | -void native_teardown_msi_irq(unsigned int irq); |
|---|
| 115 | | -void native_restore_msi_irqs(struct pci_dev *dev); |
|---|
| 116 | | -#else |
|---|
| 117 | | -#define native_setup_msi_irqs NULL |
|---|
| 118 | | -#define native_teardown_msi_irq NULL |
|---|
| 119 | | -#endif |
|---|
| 120 | | -#endif /* __KERNEL__ */ |
|---|
| 121 | | - |
|---|
| 122 | | -#ifdef CONFIG_X86_64 |
|---|
| 123 | | -#include <asm/pci_64.h> |
|---|
| 124 | | -#endif |
|---|
| 125 | | - |
|---|
| 126 | 108 | /* generic pci stuff */ |
|---|
| 127 | 109 | #include <asm-generic/pci.h> |
|---|
| 128 | 110 | |
|---|
| .. | .. |
|---|
| 130 | 112 | /* Returns the node based on pci bus */ |
|---|
| 131 | 113 | static inline int __pcibus_to_node(const struct pci_bus *bus) |
|---|
| 132 | 114 | { |
|---|
| 133 | | - const struct pci_sysdata *sd = bus->sysdata; |
|---|
| 134 | | - |
|---|
| 135 | | - return sd->node; |
|---|
| 115 | + return to_pci_sysdata(bus)->node; |
|---|
| 136 | 116 | } |
|---|
| 137 | 117 | |
|---|
| 138 | 118 | static inline const struct cpumask * |
|---|
| .. | .. |
|---|
| 141 | 121 | int node; |
|---|
| 142 | 122 | |
|---|
| 143 | 123 | node = __pcibus_to_node(bus); |
|---|
| 144 | | - return (node == -1) ? cpu_online_mask : |
|---|
| 124 | + return (node == NUMA_NO_NODE) ? cpu_online_mask : |
|---|
| 145 | 125 | cpumask_of_node(node); |
|---|
| 146 | 126 | } |
|---|
| 147 | 127 | #endif |
|---|