.. | .. |
---|
2 | 2 | #ifndef __ASM_S390_PCI_H |
---|
3 | 3 | #define __ASM_S390_PCI_H |
---|
4 | 4 | |
---|
5 | | -/* must be set before including pci_clp.h */ |
---|
6 | | -#define PCI_BAR_COUNT 6 |
---|
7 | | - |
---|
8 | 5 | #include <linux/pci.h> |
---|
9 | 6 | #include <linux/mutex.h> |
---|
10 | 7 | #include <linux/iommu.h> |
---|
| 8 | +#include <linux/pci_hotplug.h> |
---|
11 | 9 | #include <asm-generic/pci.h> |
---|
12 | 10 | #include <asm/pci_clp.h> |
---|
13 | 11 | #include <asm/pci_debug.h> |
---|
.. | .. |
---|
24 | 22 | int pci_proc_domain(struct pci_bus *); |
---|
25 | 23 | |
---|
26 | 24 | #define ZPCI_BUS_NR 0 /* default bus number */ |
---|
27 | | -#define ZPCI_DEVFN 0 /* default device number */ |
---|
| 25 | + |
---|
| 26 | +#define ZPCI_NR_DMA_SPACES 1 |
---|
| 27 | +#define ZPCI_NR_DEVICES CONFIG_PCI_NR_FUNCTIONS |
---|
| 28 | +#define ZPCI_DOMAIN_BITMAP_SIZE (1 << 16) |
---|
| 29 | + |
---|
| 30 | +#ifdef PCI |
---|
| 31 | +#if (ZPCI_NR_DEVICES > ZPCI_DOMAIN_BITMAP_SIZE) |
---|
| 32 | +# error ZPCI_NR_DEVICES can not be bigger than ZPCI_DOMAIN_BITMAP_SIZE |
---|
| 33 | +#endif |
---|
| 34 | +#endif /* PCI */ |
---|
28 | 35 | |
---|
29 | 36 | /* PCI Function Controls */ |
---|
30 | 37 | #define ZPCI_FC_FN_ENABLED 0x80 |
---|
.. | .. |
---|
83 | 90 | |
---|
84 | 91 | struct zpci_bar_struct { |
---|
85 | 92 | struct resource *res; /* bus resource */ |
---|
| 93 | + void __iomem *mio_wb; |
---|
| 94 | + void __iomem *mio_wt; |
---|
86 | 95 | u32 val; /* bar start & 3 flag bits */ |
---|
87 | 96 | u16 map_idx; /* index into bar mapping array */ |
---|
88 | 97 | u8 size; /* order 2 exponent */ |
---|
.. | .. |
---|
90 | 99 | |
---|
91 | 100 | struct s390_domain; |
---|
92 | 101 | |
---|
| 102 | +#define ZPCI_FUNCTIONS_PER_BUS 256 |
---|
| 103 | +struct zpci_bus { |
---|
| 104 | + struct kref kref; |
---|
| 105 | + struct pci_bus *bus; |
---|
| 106 | + struct zpci_dev *function[ZPCI_FUNCTIONS_PER_BUS]; |
---|
| 107 | + struct list_head resources; |
---|
| 108 | + struct list_head bus_next; |
---|
| 109 | + struct resource bus_resource; |
---|
| 110 | + int pchid; |
---|
| 111 | + int domain_nr; |
---|
| 112 | + bool multifunction; |
---|
| 113 | + enum pci_bus_speed max_bus_speed; |
---|
| 114 | +}; |
---|
| 115 | + |
---|
93 | 116 | /* Private data per function */ |
---|
94 | 117 | struct zpci_dev { |
---|
95 | | - struct pci_bus *bus; |
---|
| 118 | + struct zpci_bus *zbus; |
---|
96 | 119 | struct list_head entry; /* list of all zpci_devices, needed for hotplug, etc. */ |
---|
| 120 | + struct list_head bus_next; |
---|
| 121 | + struct kref kref; |
---|
| 122 | + struct hotplug_slot hotplug_slot; |
---|
97 | 123 | |
---|
98 | 124 | enum zpci_state state; |
---|
99 | 125 | u32 fid; /* function ID, used by sclp */ |
---|
.. | .. |
---|
102 | 128 | u16 pchid; /* physical channel ID */ |
---|
103 | 129 | u8 pfgid; /* function group ID */ |
---|
104 | 130 | u8 pft; /* pci function type */ |
---|
105 | | - u16 domain; |
---|
| 131 | + u8 port; |
---|
| 132 | + u8 rid_available : 1; |
---|
| 133 | + u8 has_hp_slot : 1; |
---|
| 134 | + u8 is_physfn : 1; |
---|
| 135 | + u8 util_str_avail : 1; |
---|
| 136 | + u8 reserved : 4; |
---|
| 137 | + unsigned int devfn; /* DEVFN part of the RID*/ |
---|
106 | 138 | |
---|
107 | 139 | struct mutex lock; |
---|
108 | 140 | u8 pfip[CLP_PFIP_NR_SEGMENTS]; /* pci function internal path */ |
---|
.. | .. |
---|
112 | 144 | /* IRQ stuff */ |
---|
113 | 145 | u64 msi_addr; /* MSI address */ |
---|
114 | 146 | unsigned int max_msi; /* maximum number of MSI's */ |
---|
| 147 | + unsigned int msi_first_bit; |
---|
| 148 | + unsigned int msi_nr_irqs; |
---|
115 | 149 | struct airq_iv *aibv; /* adapter interrupt bit vector */ |
---|
116 | 150 | unsigned long aisb; /* number of the summary bit */ |
---|
117 | 151 | |
---|
.. | .. |
---|
130 | 164 | struct iommu_device iommu_dev; /* IOMMU core handle */ |
---|
131 | 165 | |
---|
132 | 166 | char res_name[16]; |
---|
133 | | - struct zpci_bar_struct bars[PCI_BAR_COUNT]; |
---|
| 167 | + bool mio_capable; |
---|
| 168 | + struct zpci_bar_struct bars[PCI_STD_NUM_BARS]; |
---|
134 | 169 | |
---|
135 | 170 | u64 start_dma; /* Start of available DMA addresses */ |
---|
136 | 171 | u64 end_dma; /* End of available DMA addresses */ |
---|
.. | .. |
---|
145 | 180 | atomic64_t mapped_pages; |
---|
146 | 181 | atomic64_t unmapped_pages; |
---|
147 | 182 | |
---|
| 183 | + u8 version; |
---|
148 | 184 | enum pci_bus_speed max_bus_speed; |
---|
149 | 185 | |
---|
150 | 186 | struct dentry *debugfs_dev; |
---|
151 | | - struct dentry *debugfs_perf; |
---|
152 | 187 | |
---|
153 | 188 | struct s390_domain *s390_domain; /* s390 IOMMU domain data */ |
---|
154 | 189 | }; |
---|
.. | .. |
---|
159 | 194 | } |
---|
160 | 195 | |
---|
161 | 196 | extern const struct attribute_group *zpci_attr_groups[]; |
---|
| 197 | +extern unsigned int s390_pci_force_floating __initdata; |
---|
| 198 | +extern unsigned int s390_pci_no_rid; |
---|
162 | 199 | |
---|
163 | 200 | /* ----------------------------------------------------------------------------- |
---|
164 | 201 | Prototypes |
---|
165 | 202 | ----------------------------------------------------------------------------- */ |
---|
166 | 203 | /* Base stuff */ |
---|
167 | | -int zpci_create_device(struct zpci_dev *); |
---|
168 | | -void zpci_remove_device(struct zpci_dev *zdev); |
---|
| 204 | +int zpci_create_device(u32 fid, u32 fh, enum zpci_state state); |
---|
| 205 | +void zpci_remove_device(struct zpci_dev *zdev, bool set_error); |
---|
169 | 206 | int zpci_enable_device(struct zpci_dev *); |
---|
170 | 207 | int zpci_disable_device(struct zpci_dev *); |
---|
| 208 | +void zpci_device_reserved(struct zpci_dev *zdev); |
---|
| 209 | +bool zpci_is_device_configured(struct zpci_dev *zdev); |
---|
| 210 | + |
---|
171 | 211 | int zpci_register_ioat(struct zpci_dev *, u8, u64, u64, u64); |
---|
172 | 212 | int zpci_unregister_ioat(struct zpci_dev *, u8); |
---|
173 | 213 | void zpci_remove_reserved_devices(void); |
---|
174 | 214 | |
---|
175 | 215 | /* CLP */ |
---|
| 216 | +int clp_setup_writeback_mio(void); |
---|
176 | 217 | int clp_scan_pci_devices(void); |
---|
177 | | -int clp_rescan_pci_devices(void); |
---|
178 | | -int clp_rescan_pci_devices_simple(void); |
---|
179 | | -int clp_add_pci_device(u32, u32, int); |
---|
| 218 | +int clp_query_pci_fn(struct zpci_dev *zdev); |
---|
180 | 219 | int clp_enable_fh(struct zpci_dev *, u8); |
---|
181 | 220 | int clp_disable_fh(struct zpci_dev *); |
---|
182 | 221 | int clp_get_state(u32 fid, enum zpci_state *state); |
---|
| 222 | + |
---|
| 223 | +/* UID */ |
---|
| 224 | +void update_uid_checking(bool new); |
---|
183 | 225 | |
---|
184 | 226 | /* IOMMU Interface */ |
---|
185 | 227 | int zpci_init_iommu(struct zpci_dev *zdev); |
---|
186 | 228 | void zpci_destroy_iommu(struct zpci_dev *zdev); |
---|
187 | 229 | |
---|
188 | 230 | #ifdef CONFIG_PCI |
---|
| 231 | +static inline bool zpci_use_mio(struct zpci_dev *zdev) |
---|
| 232 | +{ |
---|
| 233 | + return static_branch_likely(&have_mio) && zdev->mio_capable; |
---|
| 234 | +} |
---|
| 235 | + |
---|
189 | 236 | /* Error handling and recovery */ |
---|
190 | 237 | void zpci_event_error(void *); |
---|
191 | 238 | void zpci_event_availability(void *); |
---|
192 | | -void zpci_rescan(void); |
---|
193 | 239 | bool zpci_is_enabled(void); |
---|
194 | 240 | #else /* CONFIG_PCI */ |
---|
195 | 241 | static inline void zpci_event_error(void *e) {} |
---|
196 | 242 | static inline void zpci_event_availability(void *e) {} |
---|
197 | | -static inline void zpci_rescan(void) {} |
---|
198 | 243 | #endif /* CONFIG_PCI */ |
---|
199 | 244 | |
---|
200 | 245 | #ifdef CONFIG_HOTPLUG_PCI_S390 |
---|
.. | .. |
---|
211 | 256 | /* Helpers */ |
---|
212 | 257 | static inline struct zpci_dev *to_zpci(struct pci_dev *pdev) |
---|
213 | 258 | { |
---|
214 | | - return pdev->sysdata; |
---|
| 259 | + struct zpci_bus *zbus = pdev->sysdata; |
---|
| 260 | + |
---|
| 261 | + return zbus->function[pdev->devfn]; |
---|
| 262 | +} |
---|
| 263 | + |
---|
| 264 | +static inline struct zpci_dev *to_zpci_dev(struct device *dev) |
---|
| 265 | +{ |
---|
| 266 | + return to_zpci(to_pci_dev(dev)); |
---|
215 | 267 | } |
---|
216 | 268 | |
---|
217 | 269 | struct zpci_dev *get_zdev_by_fid(u32); |
---|
.. | .. |
---|
219 | 271 | /* DMA */ |
---|
220 | 272 | int zpci_dma_init(void); |
---|
221 | 273 | void zpci_dma_exit(void); |
---|
| 274 | + |
---|
| 275 | +int __init zpci_irq_init(void); |
---|
| 276 | +void __init zpci_irq_exit(void); |
---|
222 | 277 | |
---|
223 | 278 | /* FMB */ |
---|
224 | 279 | int zpci_fmb_enable_device(struct zpci_dev *); |
---|
.. | .. |
---|
229 | 284 | void zpci_debug_exit(void); |
---|
230 | 285 | void zpci_debug_init_device(struct zpci_dev *, const char *); |
---|
231 | 286 | void zpci_debug_exit_device(struct zpci_dev *); |
---|
232 | | -void zpci_debug_info(struct zpci_dev *, struct seq_file *); |
---|
233 | 287 | |
---|
234 | 288 | /* Error reporting */ |
---|
235 | 289 | int zpci_report_error(struct pci_dev *, struct zpci_report_error_header *); |
---|