hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/include/linux/pci.h
....@@ -6,12 +6,18 @@
66 * Copyright 1994, Drew Eckhardt
77 * Copyright 1997--1999 Martin Mares <mj@ucw.cz>
88 *
9
+ * PCI Express ASPM defines and function prototypes
10
+ * Copyright (c) 2007 Intel Corp.
11
+ * Zhang Yanmin (yanmin.zhang@intel.com)
12
+ * Shaohua Li (shaohua.li@intel.com)
13
+ *
914 * For more information, please consult the following manuals (look at
1015 * http://www.pcisig.com/ for how to get them):
1116 *
1217 * PCI BIOS Specification
1318 * PCI Local Bus Specification
1419 * PCI to PCI Bridge Specification
20
+ * PCI Express Specification
1521 * PCI System Design Guide
1622 */
1723 #ifndef LINUX_PCI_H
....@@ -36,6 +42,13 @@
3642
3743 #include <linux/pci_ids.h>
3844 #include <linux/android_kabi.h>
45
+
46
+#define PCI_STATUS_ERROR_BITS (PCI_STATUS_DETECTED_PARITY | \
47
+ PCI_STATUS_SIG_SYSTEM_ERROR | \
48
+ PCI_STATUS_REC_MASTER_ABORT | \
49
+ PCI_STATUS_REC_TARGET_ABORT | \
50
+ PCI_STATUS_SIG_TARGET_ABORT | \
51
+ PCI_STATUS_PARITY)
3952
4053 /*
4154 * The PCI interface treats multi-function devices as independent
....@@ -77,7 +90,7 @@
7790 enum {
7891 /* #0-5: standard PCI resources */
7992 PCI_STD_RESOURCES,
80
- PCI_STD_RESOURCE_END = 5,
93
+ PCI_STD_RESOURCE_END = PCI_STD_RESOURCES + PCI_STD_NUM_BARS - 1,
8194
8295 /* #6: expansion ROM resource */
8396 PCI_ROM_RESOURCE,
....@@ -88,9 +101,21 @@
88101 PCI_IOV_RESOURCE_END = PCI_IOV_RESOURCES + PCI_SRIOV_NUM_BARS - 1,
89102 #endif
90103
91
- /* Resources assigned to buses behind the bridge */
104
+/* PCI-to-PCI (P2P) bridge windows */
105
+#define PCI_BRIDGE_IO_WINDOW (PCI_BRIDGE_RESOURCES + 0)
106
+#define PCI_BRIDGE_MEM_WINDOW (PCI_BRIDGE_RESOURCES + 1)
107
+#define PCI_BRIDGE_PREF_MEM_WINDOW (PCI_BRIDGE_RESOURCES + 2)
108
+
109
+/* CardBus bridge windows */
110
+#define PCI_CB_BRIDGE_IO_0_WINDOW (PCI_BRIDGE_RESOURCES + 0)
111
+#define PCI_CB_BRIDGE_IO_1_WINDOW (PCI_BRIDGE_RESOURCES + 1)
112
+#define PCI_CB_BRIDGE_MEM_0_WINDOW (PCI_BRIDGE_RESOURCES + 2)
113
+#define PCI_CB_BRIDGE_MEM_1_WINDOW (PCI_BRIDGE_RESOURCES + 3)
114
+
115
+/* Total number of bridge resources for P2P and CardBus */
92116 #define PCI_BRIDGE_RESOURCE_NUM 4
93117
118
+ /* Resources assigned to buses behind the bridge */
94119 PCI_BRIDGE_RESOURCES,
95120 PCI_BRIDGE_RESOURCE_END = PCI_BRIDGE_RESOURCES +
96121 PCI_BRIDGE_RESOURCE_NUM - 1,
....@@ -146,19 +171,16 @@
146171 return pci_power_names[1 + (__force int) state];
147172 }
148173
149
-#define PCI_PM_D2_DELAY 200
150
-#define PCI_PM_D3_WAIT 10
151
-#define PCI_PM_D3COLD_WAIT 100
152
-#define PCI_PM_BUS_WAIT 50
153
-
154174 /**
175
+ * typedef pci_channel_state_t
176
+ *
155177 * The pci_channel state describes connectivity between the CPU and
156178 * the PCI device. If some PCI bus between here and the PCI device
157179 * has crashed or locked up, this info is reflected here.
158180 */
159181 typedef unsigned int __bitwise pci_channel_state_t;
160182
161
-enum pci_channel_state {
183
+enum {
162184 /* I/O channel is in normal state */
163185 pci_channel_io_normal = (__force pci_channel_state_t) 1,
164186
....@@ -236,7 +258,7 @@
236258 PCIE_LNK_WIDTH_UNKNOWN = 0xff,
237259 };
238260
239
-/* Based on the PCI Hotplug Spec, but some values are made up by us */
261
+/* See matching string table in pci_speed_string() */
240262 enum pci_bus_speed {
241263 PCI_SPEED_33MHz = 0x00,
242264 PCI_SPEED_66MHz = 0x01,
....@@ -261,6 +283,7 @@
261283 PCIE_SPEED_5_0GT = 0x15,
262284 PCIE_SPEED_8_0GT = 0x16,
263285 PCIE_SPEED_16_0GT = 0x17,
286
+ PCIE_SPEED_32_0GT = 0x18,
264287 PCI_SPEED_UNKNOWN = 0xff,
265288 };
266289
....@@ -271,7 +294,7 @@
271294 u16 cap_nr;
272295 bool cap_extended;
273296 unsigned int size;
274
- u32 data[0];
297
+ u32 data[];
275298 };
276299
277300 struct pci_cap_saved_state {
....@@ -283,7 +306,7 @@
283306 struct pcie_link_state;
284307 struct pci_vpd;
285308 struct pci_sriov;
286
-struct pci_ats;
309
+struct pci_p2pdma;
287310
288311 /* The pci_dev structure describes PCI devices */
289312 struct pci_dev {
....@@ -328,6 +351,7 @@
328351 pci_power_t current_state; /* Current operating state. In ACPI,
329352 this is D0-D3, D0 being fully
330353 functional, and D3 being off. */
354
+ unsigned int imm_ready:1; /* Supports Immediate Readiness */
331355 u8 pm_cap; /* PM capability offset */
332356 unsigned int pme_support:5; /* Bitmask of states from which PME#
333357 can be generated */
....@@ -336,7 +360,6 @@
336360 unsigned int d2_support:1; /* Low power state D2 is supported */
337361 unsigned int no_d1d2:1; /* D1 and D2 are forbidden */
338362 unsigned int no_d3cold:1; /* D3cold is forbidden */
339
- unsigned int no_d3hot:1; /* D3hot is forbidden */
340363 unsigned int bridge_d3:1; /* Allow D3 for bridge */
341364 unsigned int d3cold_allowed:1; /* D3cold is allowed by user */
342365 unsigned int mmio_always_on:1; /* Disallow turning off io/mem
....@@ -346,19 +369,21 @@
346369 D3cold, not set for devices
347370 powered on/off by the
348371 corresponding bridge */
372
+ unsigned int skip_bus_pm:1; /* Internal: Skip bus-level PM */
349373 unsigned int ignore_hotplug:1; /* Ignore hotplug events */
350374 unsigned int hotplug_user_indicators:1; /* SlotCtl indicators
351375 controlled exclusively by
352376 user sysfs */
353377 unsigned int clear_retrain_link:1; /* Need to clear Retrain Link
354378 bit manually */
355
- unsigned int d3_delay; /* D3->D0 transition time in ms */
379
+ unsigned int d3hot_delay; /* D3hot->D0 transition time in ms */
356380 unsigned int d3cold_delay; /* D3cold->D0 transition time in ms */
357381
358382 #ifdef CONFIG_PCIEASPM
359383 struct pcie_link_state *link_state; /* ASPM link state */
360384 unsigned int ltr_path:1; /* Latency Tolerance Reporting
361385 supported from root to here */
386
+ int l1ss; /* L1SS Capability pointer */
362387 #endif
363388 unsigned int eetlp_prefix_path:1; /* End-to-End TLP Prefix */
364389
....@@ -377,11 +402,14 @@
377402 bool match_driver; /* Skip attaching driver */
378403
379404 unsigned int transparent:1; /* Subtractive decode bridge */
405
+ unsigned int io_window:1; /* Bridge has I/O window */
406
+ unsigned int pref_window:1; /* Bridge has pref mem window */
407
+ unsigned int pref_64_window:1; /* Pref mem window is 64-bit */
380408 unsigned int multifunction:1; /* Multi-function device */
381409
382410 unsigned int is_busmaster:1; /* Is busmaster */
383411 unsigned int no_msi:1; /* May not use MSI */
384
- unsigned int no_64bit_msi:1; /* May only use 32-bit MSIs */
412
+ unsigned int no_64bit_msi:1; /* May only use 32-bit MSIs */
385413 unsigned int block_cfg_access:1; /* Config space access blocked */
386414 unsigned int broken_parity_status:1; /* Generates false positive parity */
387415 unsigned int irq_reroute_variant:2; /* Needs IRQ rerouting variant */
....@@ -400,17 +428,34 @@
400428 unsigned int is_hotplug_bridge:1;
401429 unsigned int shpc_managed:1; /* SHPC owned by shpchp */
402430 unsigned int is_thunderbolt:1; /* Thunderbolt controller */
403
- unsigned int __aer_firmware_first_valid:1;
404
- unsigned int __aer_firmware_first:1;
431
+ /*
432
+ * Devices marked being untrusted are the ones that can potentially
433
+ * execute DMA attacks and similar. They are typically connected
434
+ * through external ports such as Thunderbolt but not limited to
435
+ * that. When an IOMMU is enabled they should be getting full
436
+ * mappings to make sure they cannot access arbitrary memory.
437
+ */
438
+ unsigned int untrusted:1;
439
+ /*
440
+ * Info from the platform, e.g., ACPI or device tree, may mark a
441
+ * device as "external-facing". An external-facing device is
442
+ * itself internal but devices downstream from it are external.
443
+ */
444
+ unsigned int external_facing:1;
405445 unsigned int broken_intx_masking:1; /* INTx masking can't be used */
406446 unsigned int io_window_1k:1; /* Intel bridge 1K I/O windows */
407447 unsigned int irq_managed:1;
408
- unsigned int has_secondary_link:1;
409448 unsigned int non_compliant_bars:1; /* Broken BARs; ignore them */
410449 unsigned int is_probed:1; /* Device probing in progress */
450
+ unsigned int link_active_reporting:1;/* Device capable of reporting link active */
451
+ unsigned int no_vf_scan:1; /* Don't scan for VFs after IOV enablement */
452
+ unsigned int no_command_memory:1; /* No PCI_COMMAND_MEMORY */
411453 pci_dev_flags_t dev_flags;
412454 atomic_t enable_cnt; /* pci_enable_device has been called */
413455
456
+#ifdef CONFIG_NO_GKI
457
+ atomic_t sysfs_init_cnt; /* pci_create_sysfs_dev_files has been called */
458
+#endif
414459 u32 saved_config_space[16]; /* Config space saved at suspend time */
415460 struct hlist_head saved_cap_space;
416461 struct bin_attribute *rom_attr; /* Attribute descriptor for sysfs ROM entry */
....@@ -430,6 +475,11 @@
430475 const struct attribute_group **msi_irq_groups;
431476 #endif
432477 struct pci_vpd *vpd;
478
+#ifdef CONFIG_PCIE_DPC
479
+ u16 dpc_cap;
480
+ unsigned int dpc_rp_extensions:1;
481
+ u8 dpc_rp_log_size;
482
+#endif
433483 #ifdef CONFIG_PCI_ATS
434484 union {
435485 struct pci_sriov *sriov; /* PF: SR-IOV info */
....@@ -437,14 +487,20 @@
437487 };
438488 u16 ats_cap; /* ATS Capability offset */
439489 u8 ats_stu; /* ATS Smallest Translation Unit */
440
- atomic_t ats_ref_cnt; /* Number of VFs with ATS enabled */
441490 #endif
442491 #ifdef CONFIG_PCI_PRI
492
+ u16 pri_cap; /* PRI Capability offset */
443493 u32 pri_reqs_alloc; /* Number of PRI requests allocated */
494
+ unsigned int pasid_required:1; /* PRG Response PASID Required */
444495 #endif
445496 #ifdef CONFIG_PCI_PASID
497
+ u16 pasid_cap; /* PASID Capability offset */
446498 u16 pasid_features;
447499 #endif
500
+#ifdef CONFIG_PCI_P2PDMA
501
+ struct pci_p2pdma *p2pdma;
502
+#endif
503
+ u16 acs_cap; /* ACS Capability offset */
448504 phys_addr_t rom; /* Physical address if not from BAR */
449505 size_t romlen; /* Length if not from BAR */
450506 char *driver_override; /* Driver name to force a match */
....@@ -480,9 +536,11 @@
480536 struct device dev;
481537 struct pci_bus *bus; /* Root bus */
482538 struct pci_ops *ops;
539
+ struct pci_ops *child_ops;
483540 void *sysdata;
484541 int busnr;
485542 struct list_head windows; /* resource_entry */
543
+ struct list_head dma_ranges; /* dma ranges resource list */
486544 u8 (*swizzle_irq)(struct pci_dev *, u8 *); /* Platform IRQ swizzler */
487545 int (*map_irq)(const struct pci_dev *, u8, u8);
488546 void (*release_fn)(struct pci_host_bridge *);
....@@ -495,13 +553,21 @@
495553 unsigned int native_shpc_hotplug:1; /* OS may use SHPC hotplug */
496554 unsigned int native_pme:1; /* OS may use PCIe PME */
497555 unsigned int native_ltr:1; /* OS may use PCIe LTR */
556
+ unsigned int native_dpc:1; /* OS may use PCIe DPC */
557
+ unsigned int preserve_config:1; /* Preserve FW resource setup */
558
+ unsigned int size_windows:1; /* Enable root bus sizing */
559
+
498560 /* Resource alignment requirements */
499561 resource_size_t (*align_resource)(struct pci_dev *dev,
500562 const struct resource *res,
501563 resource_size_t start,
502564 resource_size_t size,
503565 resource_size_t align);
504
- unsigned long private[0] ____cacheline_aligned;
566
+
567
+ ANDROID_KABI_RESERVE(1);
568
+ ANDROID_KABI_RESERVE(2);
569
+
570
+ unsigned long private[] ____cacheline_aligned;
505571 };
506572
507573 #define to_pci_host_bridge(n) container_of(n, struct pci_host_bridge, dev)
....@@ -594,6 +660,11 @@
594660
595661 #define to_pci_bus(n) container_of(n, struct pci_bus, dev)
596662
663
+static inline u16 pci_dev_id(struct pci_dev *dev)
664
+{
665
+ return PCI_DEVID(dev->bus->number, dev->devfn);
666
+}
667
+
597668 /*
598669 * Returns true if the PCI bus is root (behind host-PCI bridge),
599670 * false otherwise
....@@ -632,9 +703,6 @@
632703
633704 return dev->bus->self;
634705 }
635
-
636
-struct device *pci_get_host_bridge_device(struct pci_dev *dev);
637
-void pci_put_host_bridge_device(struct device *dev);
638706
639707 #ifdef CONFIG_PCI_MSI
640708 static inline bool pci_dev_msi_enabled(struct pci_dev *pci_dev)
....@@ -686,6 +754,8 @@
686754 void __iomem *(*map_bus)(struct pci_bus *bus, unsigned int devfn, int where);
687755 int (*read)(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *val);
688756 int (*write)(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 val);
757
+
758
+ ANDROID_KABI_RESERVE(1);
689759 };
690760
691761 /*
....@@ -747,7 +817,7 @@
747817 struct pci_error_handlers {
748818 /* PCI bus error detected on this device */
749819 pci_ers_result_t (*error_detected)(struct pci_dev *dev,
750
- enum pci_channel_state error);
820
+ pci_channel_state_t error);
751821
752822 /* MMIO has been re-enabled, but not DMA */
753823 pci_ers_result_t (*mmio_enabled)(struct pci_dev *dev);
....@@ -761,10 +831,54 @@
761831
762832 /* Device driver may resume normal operations */
763833 void (*resume)(struct pci_dev *dev);
834
+
835
+ ANDROID_KABI_RESERVE(1);
764836 };
765837
766838
767839 struct module;
840
+
841
+/**
842
+ * struct pci_driver - PCI driver structure
843
+ * @node: List of driver structures.
844
+ * @name: Driver name.
845
+ * @id_table: Pointer to table of device IDs the driver is
846
+ * interested in. Most drivers should export this
847
+ * table using MODULE_DEVICE_TABLE(pci,...).
848
+ * @probe: This probing function gets called (during execution
849
+ * of pci_register_driver() for already existing
850
+ * devices or later if a new device gets inserted) for
851
+ * all PCI devices which match the ID table and are not
852
+ * "owned" by the other drivers yet. This function gets
853
+ * passed a "struct pci_dev \*" for each device whose
854
+ * entry in the ID table matches the device. The probe
855
+ * function returns zero when the driver chooses to
856
+ * take "ownership" of the device or an error code
857
+ * (negative number) otherwise.
858
+ * The probe function always gets called from process
859
+ * context, so it can sleep.
860
+ * @remove: The remove() function gets called whenever a device
861
+ * being handled by this driver is removed (either during
862
+ * deregistration of the driver or when it's manually
863
+ * pulled out of a hot-pluggable slot).
864
+ * The remove function always gets called from process
865
+ * context, so it can sleep.
866
+ * @suspend: Put device into low power state.
867
+ * @resume: Wake device from low power state.
868
+ * (Please see Documentation/power/pci.rst for descriptions
869
+ * of PCI Power Management and the related functions.)
870
+ * @shutdown: Hook into reboot_notifier_list (kernel/sys.c).
871
+ * Intended to stop any idling DMA operations.
872
+ * Useful for enabling wake-on-lan (NIC) or changing
873
+ * the power state of a device before reboot.
874
+ * e.g. drivers/net/e100.c.
875
+ * @sriov_configure: Optional driver callback to allow configuration of
876
+ * number of VFs to enable via sysfs "sriov_numvfs" file.
877
+ * @err_handler: See Documentation/PCI/pci-error-recovery.rst
878
+ * @groups: Sysfs attribute groups.
879
+ * @driver: Driver model structure.
880
+ * @dynids: List of dynamically added device IDs.
881
+ */
768882 struct pci_driver {
769883 struct list_head node;
770884 const char *name;
....@@ -772,11 +886,9 @@
772886 int (*probe)(struct pci_dev *dev, const struct pci_device_id *id); /* New device inserted */
773887 void (*remove)(struct pci_dev *dev); /* Device removed (NULL if not a hot-plug capable driver) */
774888 int (*suspend)(struct pci_dev *dev, pm_message_t state); /* Device suspended */
775
- int (*suspend_late)(struct pci_dev *dev, pm_message_t state);
776
- int (*resume_early)(struct pci_dev *dev);
777
- int (*resume) (struct pci_dev *dev); /* Device woken up */
778
- void (*shutdown) (struct pci_dev *dev);
779
- int (*sriov_configure) (struct pci_dev *dev, int num_vfs); /* On PF */
889
+ int (*resume)(struct pci_dev *dev); /* Device woken up */
890
+ void (*shutdown)(struct pci_dev *dev);
891
+ int (*sriov_configure)(struct pci_dev *dev, int num_vfs); /* On PF */
780892 const struct pci_error_handlers *err_handler;
781893 const struct attribute_group **groups;
782894 struct device_driver driver;
....@@ -870,6 +982,11 @@
870982 PCI_SCAN_ALL_PCIE_DEVS = 0x00000040, /* Scan all, not just dev 0 */
871983 };
872984
985
+#define PCI_IRQ_LEGACY (1 << 0) /* Allow legacy interrupts */
986
+#define PCI_IRQ_MSI (1 << 1) /* Allow MSI interrupts */
987
+#define PCI_IRQ_MSIX (1 << 2) /* Allow MSI-X interrupts */
988
+#define PCI_IRQ_AFFINITY (1 << 3) /* Auto-assign affinity */
989
+
873990 /* These external functions are only available when PCI support is enabled */
874991 #ifdef CONFIG_PCI
875992
....@@ -914,7 +1031,7 @@
9141031 resource_size_t,
9151032 resource_size_t);
9161033
917
-/* Weak but can be overriden by arch */
1034
+/* Weak but can be overridden by arch */
9181035 void pci_fixup_cardbus(struct pci_bus *);
9191036
9201037 /* Generic PCI functions used internally */
....@@ -940,7 +1057,6 @@
9401057 int pci_scan_root_bus_bridge(struct pci_host_bridge *bridge);
9411058 struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev,
9421059 int busnr);
943
-void pcie_update_link_speed(struct pci_bus *bus, u16 link_status);
9441060 struct pci_slot *pci_create_slot(struct pci_bus *parent, int slot_nr,
9451061 const char *name,
9461062 struct hotplug_slot *hotplug);
....@@ -958,7 +1074,6 @@
9581074 void pci_read_bridge_bases(struct pci_bus *child);
9591075 struct resource *pci_find_parent_resource(const struct pci_dev *dev,
9601076 struct resource *res);
961
-struct pci_dev *pci_find_pcie_root_port(struct pci_dev *dev);
9621077 u8 pci_swizzle_interrupt_pin(const struct pci_dev *dev, u8 pin);
9631078 int pci_get_interrupt_pin(struct pci_dev *dev, struct pci_dev **bridge);
9641079 u8 pci_common_swizzle(struct pci_dev *dev, u8 *pinp);
....@@ -977,13 +1092,6 @@
9771092
9781093 /* Generic PCI functions exported to card drivers */
9791094
980
-enum pci_lost_interrupt_reason {
981
- PCI_LOST_IRQ_NO_INFORMATION = 0,
982
- PCI_LOST_IRQ_DISABLE_MSI,
983
- PCI_LOST_IRQ_DISABLE_MSIX,
984
- PCI_LOST_IRQ_DISABLE_ACPI,
985
-};
986
-enum pci_lost_interrupt_reason pci_lost_interrupt(struct pci_dev *dev);
9871095 int pci_find_capability(struct pci_dev *dev, int cap);
9881096 int pci_find_next_capability(struct pci_dev *dev, u8 pos, int cap);
9891097 int pci_find_ext_capability(struct pci_dev *dev, int cap);
....@@ -991,6 +1099,8 @@
9911099 int pci_find_ht_capability(struct pci_dev *dev, int ht_cap);
9921100 int pci_find_next_ht_capability(struct pci_dev *dev, int pos, int ht_cap);
9931101 struct pci_bus *pci_find_next_bus(const struct pci_bus *from);
1102
+
1103
+u64 pci_get_dsn(struct pci_dev *dev);
9941104
9951105 struct pci_dev *pci_get_device(unsigned int vendor, unsigned int device,
9961106 struct pci_dev *from);
....@@ -1149,6 +1259,8 @@
11491259 int pci_select_bars(struct pci_dev *dev, unsigned long flags);
11501260 bool pci_device_is_present(struct pci_dev *pdev);
11511261 void pci_ignore_hotplug(struct pci_dev *dev);
1262
+struct pci_dev *pci_real_dma_dev(struct pci_dev *dev);
1263
+int pci_status_get_and_clear_errors(struct pci_dev *pdev);
11521264
11531265 int __printf(6, 7) pci_request_irq(struct pci_dev *dev, unsigned int nr,
11541266 irq_handler_t handler, irq_handler_t thread_fn, void *dev_id,
....@@ -1175,7 +1287,7 @@
11751287 int pci_add_cap_save_buffer(struct pci_dev *dev, char cap, unsigned int size);
11761288 int pci_add_ext_cap_save_buffer(struct pci_dev *dev,
11771289 u16 cap, unsigned int size);
1178
-int __pci_complete_power_transition(struct pci_dev *dev, pci_power_t state);
1290
+int pci_platform_power_transition(struct pci_dev *dev, pci_power_t state);
11791291 int pci_set_power_state(struct pci_dev *dev, pci_power_t state);
11801292 pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state);
11811293 bool pci_pme_capable(struct pci_dev *dev, pci_power_t state);
....@@ -1185,18 +1297,11 @@
11851297 int pci_prepare_to_sleep(struct pci_dev *dev);
11861298 int pci_back_from_sleep(struct pci_dev *dev);
11871299 bool pci_dev_run_wake(struct pci_dev *dev);
1188
-bool pci_check_pme_status(struct pci_dev *dev);
1189
-void pci_pme_wakeup_bus(struct pci_bus *bus);
11901300 void pci_d3cold_enable(struct pci_dev *dev);
11911301 void pci_d3cold_disable(struct pci_dev *dev);
11921302 bool pcie_relaxed_ordering_enabled(struct pci_dev *dev);
11931303 void pci_wakeup_bus(struct pci_bus *bus);
11941304 void pci_bus_set_current_state(struct pci_bus *bus, pci_power_t state);
1195
-
1196
-/* PCI Virtual Channel */
1197
-int pci_save_vc_state(struct pci_dev *dev);
1198
-void pci_restore_vc_state(struct pci_dev *dev);
1199
-void pci_allocate_vc_save_buffers(struct pci_dev *dev);
12001305
12011306 /* For use by arch with custom probe code */
12021307 void set_pcie_port_type(struct pci_dev *pdev);
....@@ -1235,15 +1340,12 @@
12351340 int __must_check pci_request_regions_exclusive(struct pci_dev *, const char *);
12361341 void pci_release_regions(struct pci_dev *);
12371342 int __must_check pci_request_region(struct pci_dev *, int, const char *);
1238
-int __must_check pci_request_region_exclusive(struct pci_dev *, int, const char *);
12391343 void pci_release_region(struct pci_dev *, int);
12401344 int pci_request_selected_regions(struct pci_dev *, int, const char *);
12411345 int pci_request_selected_regions_exclusive(struct pci_dev *, int, const char *);
12421346 void pci_release_selected_regions(struct pci_dev *, int);
12431347
12441348 /* drivers/pci/bus.c */
1245
-struct pci_bus *pci_bus_get(struct pci_bus *bus);
1246
-void pci_bus_put(struct pci_bus *bus);
12471349 void pci_add_resource(struct list_head *resources, struct resource *res);
12481350 void pci_add_resource_offset(struct list_head *resources, struct resource *res,
12491351 resource_size_t offset);
....@@ -1317,9 +1419,8 @@
13171419 #define module_pci_driver(__pci_driver) \
13181420 module_driver(__pci_driver, pci_register_driver, pci_unregister_driver)
13191421
1320
-
13211422 #define module_pci_driver2(__pci_driver) \
1322
- module_driver2(__pci_driver, pci_register_driver, pci_unregister_driver)
1423
+ module_driver2(__pci_driver, pci_register_driver, pci_unregister_driver)
13231424
13241425 /**
13251426 * builtin_pci_driver() - Helper macro for registering a PCI driver
....@@ -1357,16 +1458,19 @@
13571458 int pci_set_vga_state(struct pci_dev *pdev, bool decode,
13581459 unsigned int command_bits, u32 flags);
13591460
1360
-#define PCI_IRQ_LEGACY (1 << 0) /* Allow legacy interrupts */
1361
-#define PCI_IRQ_MSI (1 << 1) /* Allow MSI interrupts */
1362
-#define PCI_IRQ_MSIX (1 << 2) /* Allow MSI-X interrupts */
1363
-#define PCI_IRQ_AFFINITY (1 << 3) /* Auto-assign affinity */
1461
+/*
1462
+ * Virtual interrupts allow for more interrupts to be allocated
1463
+ * than the device has interrupts for. These are not programmed
1464
+ * into the device's MSI-X table and must be handled by some
1465
+ * other driver means.
1466
+ */
1467
+#define PCI_IRQ_VIRTUAL (1 << 4)
1468
+
13641469 #define PCI_IRQ_ALL_TYPES \
13651470 (PCI_IRQ_LEGACY | PCI_IRQ_MSI | PCI_IRQ_MSIX)
13661471
13671472 /* kmem_cache style wrapper around pci_alloc_consistent() */
13681473
1369
-#include <linux/pci-dma.h>
13701474 #include <linux/dmapool.h>
13711475
13721476 #define pci_pool dma_pool
....@@ -1403,12 +1507,11 @@
14031507 }
14041508 int pci_alloc_irq_vectors_affinity(struct pci_dev *dev, unsigned int min_vecs,
14051509 unsigned int max_vecs, unsigned int flags,
1406
- const struct irq_affinity *affd);
1510
+ struct irq_affinity *affd);
14071511
14081512 void pci_free_irq_vectors(struct pci_dev *dev);
14091513 int pci_irq_vector(struct pci_dev *dev, unsigned int nr);
14101514 const struct cpumask *pci_irq_get_affinity(struct pci_dev *pdev, int vec);
1411
-int pci_irq_get_node(struct pci_dev *pdev, int vec);
14121515
14131516 #else
14141517 static inline int pci_msi_vec_count(struct pci_dev *dev) { return -ENOSYS; }
....@@ -1429,7 +1532,7 @@
14291532 static inline int
14301533 pci_alloc_irq_vectors_affinity(struct pci_dev *dev, unsigned int min_vecs,
14311534 unsigned int max_vecs, unsigned int flags,
1432
- const struct irq_affinity *aff_desc)
1535
+ struct irq_affinity *aff_desc)
14331536 {
14341537 if ((flags & PCI_IRQ_LEGACY) && min_vecs == 1 && dev->irq)
14351538 return 1;
....@@ -1451,20 +1554,7 @@
14511554 {
14521555 return cpu_possible_mask;
14531556 }
1454
-
1455
-static inline int pci_irq_get_node(struct pci_dev *pdev, int vec)
1456
-{
1457
- return first_online_node;
1458
-}
14591557 #endif
1460
-
1461
-static inline int
1462
-pci_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs,
1463
- unsigned int max_vecs, unsigned int flags)
1464
-{
1465
- return pci_alloc_irq_vectors_affinity(dev, min_vecs, max_vecs, flags,
1466
- NULL);
1467
-}
14681558
14691559 /**
14701560 * pci_irqd_intx_xlate() - Translate PCI INTx value to an IRQ domain hwirq
....@@ -1506,10 +1596,28 @@
15061596 #define pcie_ports_native false
15071597 #endif
15081598
1599
+#define PCIE_LINK_STATE_L0S BIT(0)
1600
+#define PCIE_LINK_STATE_L1 BIT(1)
1601
+#define PCIE_LINK_STATE_CLKPM BIT(2)
1602
+#define PCIE_LINK_STATE_L1_1 BIT(3)
1603
+#define PCIE_LINK_STATE_L1_2 BIT(4)
1604
+#define PCIE_LINK_STATE_L1_1_PCIPM BIT(5)
1605
+#define PCIE_LINK_STATE_L1_2_PCIPM BIT(6)
1606
+
15091607 #ifdef CONFIG_PCIEASPM
1608
+int pci_disable_link_state(struct pci_dev *pdev, int state);
1609
+int pci_disable_link_state_locked(struct pci_dev *pdev, int state);
1610
+void pcie_no_aspm(void);
15101611 bool pcie_aspm_support_enabled(void);
1612
+bool pcie_aspm_enabled(struct pci_dev *pdev);
15111613 #else
1614
+static inline int pci_disable_link_state(struct pci_dev *pdev, int state)
1615
+{ return 0; }
1616
+static inline int pci_disable_link_state_locked(struct pci_dev *pdev, int state)
1617
+{ return 0; }
1618
+static inline void pcie_no_aspm(void) { }
15121619 static inline bool pcie_aspm_support_enabled(void) { return false; }
1620
+static inline bool pcie_aspm_enabled(struct pci_dev *pdev) { return false; }
15131621 #endif
15141622
15151623 #ifdef CONFIG_PCIEAER
....@@ -1518,28 +1626,7 @@
15181626 static inline bool pci_aer_available(void) { return false; }
15191627 #endif
15201628
1521
-#ifdef CONFIG_PCIE_ECRC
1522
-void pcie_set_ecrc_checking(struct pci_dev *dev);
1523
-void pcie_ecrc_get_policy(char *str);
1524
-#else
1525
-static inline void pcie_set_ecrc_checking(struct pci_dev *dev) { }
1526
-static inline void pcie_ecrc_get_policy(char *str) { }
1527
-#endif
1528
-
15291629 bool pci_ats_disabled(void);
1530
-
1531
-#ifdef CONFIG_PCI_ATS
1532
-/* Address Translation Service */
1533
-void pci_ats_init(struct pci_dev *dev);
1534
-int pci_enable_ats(struct pci_dev *dev, int ps);
1535
-void pci_disable_ats(struct pci_dev *dev);
1536
-int pci_ats_queue_depth(struct pci_dev *dev);
1537
-#else
1538
-static inline void pci_ats_init(struct pci_dev *d) { }
1539
-static inline int pci_enable_ats(struct pci_dev *d, int ps) { return -ENODEV; }
1540
-static inline void pci_disable_ats(struct pci_dev *d) { }
1541
-static inline int pci_ats_queue_depth(struct pci_dev *d) { return -ENODEV; }
1542
-#endif
15431630
15441631 #ifdef CONFIG_PCIE_PTM
15451632 int pci_enable_ptm(struct pci_dev *dev, u8 *granularity);
....@@ -1660,8 +1747,10 @@
16601747 #define pci_dev_put(dev) do { } while (0)
16611748
16621749 static inline void pci_set_master(struct pci_dev *dev) { }
1750
+static inline void pci_clear_master(struct pci_dev *dev) { }
16631751 static inline int pci_enable_device(struct pci_dev *dev) { return -EIO; }
16641752 static inline void pci_disable_device(struct pci_dev *dev) { }
1753
+static inline int pcim_enable_device(struct pci_dev *pdev) { return -EIO; }
16651754 static inline int pci_assign_resource(struct pci_dev *dev, int i)
16661755 { return -EBUSY; }
16671756 static inline int __must_check __pci_register_driver(struct pci_driver *drv,
....@@ -1677,6 +1766,9 @@
16771766 int cap)
16781767 { return 0; }
16791768 static inline int pci_find_ext_capability(struct pci_dev *dev, int cap)
1769
+{ return 0; }
1770
+
1771
+static inline u64 pci_get_dsn(struct pci_dev *dev)
16801772 { return 0; }
16811773
16821774 /* Power management related routines */
....@@ -1702,11 +1794,6 @@
17021794
17031795 static inline unsigned long pci_address_to_pio(phys_addr_t addr) { return -1; }
17041796
1705
-static inline void pci_block_cfg_access(struct pci_dev *dev) { }
1706
-static inline int pci_block_cfg_access_in_atomic(struct pci_dev *dev)
1707
-{ return 0; }
1708
-static inline void pci_unblock_cfg_access(struct pci_dev *dev) { }
1709
-
17101797 static inline struct pci_bus *pci_find_next_bus(const struct pci_bus *from)
17111798 { return NULL; }
17121799 static inline struct pci_dev *pci_get_slot(struct pci_bus *bus,
....@@ -1730,13 +1817,39 @@
17301817 unsigned long *out_hwirq,
17311818 unsigned int *out_type)
17321819 { return -EINVAL; }
1820
+
1821
+static inline const struct pci_device_id *pci_match_id(const struct pci_device_id *ids,
1822
+ struct pci_dev *dev)
1823
+{ return NULL; }
1824
+static inline bool pci_ats_disabled(void) { return true; }
1825
+
1826
+static inline int pci_irq_vector(struct pci_dev *dev, unsigned int nr)
1827
+{
1828
+ return -EINVAL;
1829
+}
1830
+
1831
+static inline int
1832
+pci_alloc_irq_vectors_affinity(struct pci_dev *dev, unsigned int min_vecs,
1833
+ unsigned int max_vecs, unsigned int flags,
1834
+ struct irq_affinity *aff_desc)
1835
+{
1836
+ return -ENOSPC;
1837
+}
17331838 #endif /* CONFIG_PCI */
1839
+
1840
+static inline int
1841
+pci_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs,
1842
+ unsigned int max_vecs, unsigned int flags)
1843
+{
1844
+ return pci_alloc_irq_vectors_affinity(dev, min_vecs, max_vecs, flags,
1845
+ NULL);
1846
+}
17341847
17351848 /* Include architecture-dependent settings and functions */
17361849
17371850 #include <asm/pci.h>
17381851
1739
-/* These two functions provide almost identical functionality. Depennding
1852
+/* These two functions provide almost identical functionality. Depending
17401853 * on the architecture, one will be implemented as a wrapper around the
17411854 * other (in drivers/pci/mmap.c).
17421855 *
....@@ -1805,25 +1918,9 @@
18051918 return dev_name(&pdev->dev);
18061919 }
18071920
1808
-
1809
-/*
1810
- * Some archs don't want to expose struct resource to userland as-is
1811
- * in sysfs and /proc
1812
- */
1813
-#ifdef HAVE_ARCH_PCI_RESOURCE_TO_USER
18141921 void pci_resource_to_user(const struct pci_dev *dev, int bar,
18151922 const struct resource *rsrc,
18161923 resource_size_t *start, resource_size_t *end);
1817
-#else
1818
-static inline void pci_resource_to_user(const struct pci_dev *dev, int bar,
1819
- const struct resource *rsrc, resource_size_t *start,
1820
- resource_size_t *end)
1821
-{
1822
- *start = rsrc->start;
1823
- *end = rsrc->end;
1824
-}
1825
-#endif /* HAVE_ARCH_PCI_RESOURCE_TO_USER */
1826
-
18271924
18281925 /*
18291926 * The world is not perfect and supplies us with broken PCI devices.
....@@ -1856,19 +1953,28 @@
18561953 };
18571954
18581955 #ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
1859
-#define __DECLARE_PCI_FIXUP_SECTION(sec, name, vendor, device, class, \
1860
- class_shift, hook) \
1861
- __ADDRESSABLE(hook) \
1956
+#define ___DECLARE_PCI_FIXUP_SECTION(sec, name, vendor, device, class, \
1957
+ class_shift, hook, stub) \
1958
+ void __cficanonical stub(struct pci_dev *dev); \
1959
+ void __cficanonical stub(struct pci_dev *dev) \
1960
+ { \
1961
+ hook(dev); \
1962
+ } \
18621963 asm(".section " #sec ", \"a\" \n" \
18631964 ".balign 16 \n" \
18641965 ".short " #vendor ", " #device " \n" \
18651966 ".long " #class ", " #class_shift " \n" \
1866
- ".long " #hook " - . \n" \
1967
+ ".long " #stub " - . \n" \
18671968 ".previous \n");
1969
+
1970
+#define __DECLARE_PCI_FIXUP_SECTION(sec, name, vendor, device, class, \
1971
+ class_shift, hook, stub) \
1972
+ ___DECLARE_PCI_FIXUP_SECTION(sec, name, vendor, device, class, \
1973
+ class_shift, hook, stub)
18681974 #define DECLARE_PCI_FIXUP_SECTION(sec, name, vendor, device, class, \
18691975 class_shift, hook) \
18701976 __DECLARE_PCI_FIXUP_SECTION(sec, name, vendor, device, class, \
1871
- class_shift, hook)
1977
+ class_shift, hook, __UNIQUE_ID(hook))
18721978 #else
18731979 /* Anonymous variables would be nice... */
18741980 #define DECLARE_PCI_FIXUP_SECTION(section, name, vendor, device, class, \
....@@ -1965,10 +2071,6 @@
19652071 extern u8 pci_dfl_cache_line_size;
19662072 extern u8 pci_cache_line_size;
19672073
1968
-extern unsigned long pci_hotplug_io_size;
1969
-extern unsigned long pci_hotplug_mem_size;
1970
-extern unsigned long pci_hotplug_bus_size;
1971
-
19722074 /* Architecture-specific versions may override these (weak) */
19732075 void pcibios_disable_device(struct pci_dev *dev);
19742076 void pcibios_set_master(struct pci_dev *dev);
....@@ -1976,14 +2078,14 @@
19762078 enum pcie_reset_state state);
19772079 int pcibios_add_device(struct pci_dev *dev);
19782080 void pcibios_release_device(struct pci_dev *dev);
2081
+#ifdef CONFIG_PCI
19792082 void pcibios_penalize_isa_irq(int irq, int active);
2083
+#else
2084
+static inline void pcibios_penalize_isa_irq(int irq, int active) {}
2085
+#endif
19802086 int pcibios_alloc_irq(struct pci_dev *dev);
19812087 void pcibios_free_irq(struct pci_dev *dev);
19822088 resource_size_t pcibios_default_alignment(void);
1983
-
1984
-#ifdef CONFIG_HIBERNATE_CALLBACKS
1985
-extern struct dev_pm_ops pcibios_pm_ops;
1986
-#endif
19872089
19882090 #if defined(CONFIG_PCI_MMCONFIG) || defined(CONFIG_ACPI_MCFG)
19892091 void __init pci_mmcfg_early_init(void);
....@@ -2004,6 +2106,8 @@
20042106
20052107 int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn);
20062108 void pci_disable_sriov(struct pci_dev *dev);
2109
+
2110
+int pci_iov_sysfs_link(struct pci_dev *dev, struct pci_dev *virtfn, int id);
20072111 int pci_iov_add_virtfn(struct pci_dev *dev, int id);
20082112 void pci_iov_remove_virtfn(struct pci_dev *dev, int id);
20092113 int pci_num_vf(struct pci_dev *dev);
....@@ -2029,6 +2133,12 @@
20292133 }
20302134 static inline int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn)
20312135 { return -ENODEV; }
2136
+
2137
+static inline int pci_iov_sysfs_link(struct pci_dev *dev,
2138
+ struct pci_dev *virtfn, int id)
2139
+{
2140
+ return -ENODEV;
2141
+}
20322142 static inline int pci_iov_add_virtfn(struct pci_dev *dev, int id)
20332143 {
20342144 return -ENOSYS;
....@@ -2099,17 +2209,22 @@
20992209 return (pcie_caps_reg(dev) & PCI_EXP_FLAGS_TYPE) >> 4;
21002210 }
21012211
2212
+/**
2213
+ * pcie_find_root_port - Get the PCIe root port device
2214
+ * @dev: PCI device
2215
+ *
2216
+ * Traverse up the parent chain and return the PCIe Root Port PCI Device
2217
+ * for a given PCI/PCIe Device.
2218
+ */
21022219 static inline struct pci_dev *pcie_find_root_port(struct pci_dev *dev)
21032220 {
2104
- while (1) {
2105
- if (!pci_is_pcie(dev))
2106
- break;
2107
- if (pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT)
2221
+ while (dev) {
2222
+ if (pci_is_pcie(dev) &&
2223
+ pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT)
21082224 return dev;
2109
- if (!dev->bus->self)
2110
- break;
2111
- dev = dev->bus->self;
2225
+ dev = pci_upstream_bridge(dev);
21122226 }
2227
+
21132228 return NULL;
21142229 }
21152230
....@@ -2146,6 +2261,7 @@
21462261 #define PCI_VPD_INFO_FLD_HDR_SIZE 3
21472262
21482263 #define PCI_VPD_RO_KEYWORD_PARTNO "PN"
2264
+#define PCI_VPD_RO_KEYWORD_SERIALNO "SN"
21492265 #define PCI_VPD_RO_KEYWORD_MFR_ID "MN"
21502266 #define PCI_VPD_RO_KEYWORD_VENDOR0 "V0"
21512267 #define PCI_VPD_RO_KEYWORD_CHKSUM "RV"
....@@ -2196,7 +2312,7 @@
21962312
21972313 /**
21982314 * pci_vpd_info_field_size - Extracts the information field length
2199
- * @lrdt: Pointer to the beginning of an information field header
2315
+ * @info_field: Pointer to the beginning of an information field header
22002316 *
22012317 * Returns the extracted information field length.
22022318 */
....@@ -2234,31 +2350,14 @@
22342350 #ifdef CONFIG_OF
22352351 struct device_node;
22362352 struct irq_domain;
2237
-void pci_set_of_node(struct pci_dev *dev);
2238
-void pci_release_of_node(struct pci_dev *dev);
2239
-void pci_set_bus_of_node(struct pci_bus *bus);
2240
-void pci_release_bus_of_node(struct pci_bus *bus);
22412353 struct irq_domain *pci_host_bridge_of_msi_domain(struct pci_bus *bus);
2242
-int pci_parse_request_of_pci_ranges(struct device *dev,
2243
- struct list_head *resources,
2244
- struct resource **bus_range);
22452354
22462355 /* Arch may override this (weak) */
22472356 struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus);
22482357
22492358 #else /* CONFIG_OF */
2250
-static inline void pci_set_of_node(struct pci_dev *dev) { }
2251
-static inline void pci_release_of_node(struct pci_dev *dev) { }
2252
-static inline void pci_set_bus_of_node(struct pci_bus *bus) { }
2253
-static inline void pci_release_bus_of_node(struct pci_bus *bus) { }
22542359 static inline struct irq_domain *
22552360 pci_host_bridge_of_msi_domain(struct pci_bus *bus) { return NULL; }
2256
-static inline int pci_parse_request_of_pci_ranges(struct device *dev,
2257
- struct list_head *resources,
2258
- struct resource **bus_range)
2259
-{
2260
- return -EINVAL;
2261
-}
22622361 #endif /* CONFIG_OF */
22632362
22642363 static inline struct device_node *
....@@ -2277,9 +2376,11 @@
22772376
22782377 void
22792378 pci_msi_register_fwnode_provider(struct fwnode_handle *(*fn)(struct device *));
2379
+bool pci_pr3_present(struct pci_dev *pdev);
22802380 #else
22812381 static inline struct irq_domain *
22822382 pci_host_bridge_acpi_msi_domain(struct pci_bus *bus) { return NULL; }
2383
+static inline bool pci_pr3_present(struct pci_dev *pdev) { return false; }
22832384 #endif
22842385
22852386 #ifdef CONFIG_EEH
....@@ -2289,7 +2390,7 @@
22892390 }
22902391 #endif
22912392
2292
-void pci_add_dma_alias(struct pci_dev *dev, u8 devfn);
2393
+void pci_add_dma_alias(struct pci_dev *dev, u8 devfn_from, unsigned nr_devfns);
22932394 bool pci_devs_are_dma_aliases(struct pci_dev *dev1, struct pci_dev *dev2);
22942395 int pci_for_each_dma_alias(struct pci_dev *pdev,
22952396 int (*fn)(struct pci_dev *pdev,
....@@ -2361,4 +2462,18 @@
23612462 #define pci_info(pdev, fmt, arg...) dev_info(&(pdev)->dev, fmt, ##arg)
23622463 #define pci_dbg(pdev, fmt, arg...) dev_dbg(&(pdev)->dev, fmt, ##arg)
23632464
2465
+#define pci_notice_ratelimited(pdev, fmt, arg...) \
2466
+ dev_notice_ratelimited(&(pdev)->dev, fmt, ##arg)
2467
+
2468
+#define pci_info_ratelimited(pdev, fmt, arg...) \
2469
+ dev_info_ratelimited(&(pdev)->dev, fmt, ##arg)
2470
+
2471
+#define pci_WARN(pdev, condition, fmt, arg...) \
2472
+ WARN(condition, "%s %s: " fmt, \
2473
+ dev_driver_string(&(pdev)->dev), pci_name(pdev), ##arg)
2474
+
2475
+#define pci_WARN_ONCE(pdev, condition, fmt, arg...) \
2476
+ WARN_ONCE(condition, "%s %s: " fmt, \
2477
+ dev_driver_string(&(pdev)->dev), pci_name(pdev), ##arg)
2478
+
23642479 #endif /* LINUX_PCI_H */