From b910c7719f1fbb782ba09ea14633c2e95af9280f Mon Sep 17 00:00:00 2001 From: Julio Montes Date: Tue, 3 Oct 2017 10:48:50 -0500 Subject: [PATCH] kernel: add support for native hot plug Next kernel configs are needed to support native hot plug: * CONFIG_HOTPLUG_PCI=y * CONFIG_PCIEASPM_DEFAULT=y * CONFIG_PCIEASPM=y * CONFIG_HOTPLUG_PCI_PCIE=y * CONFIG_PCIEAER=y enabling above configs is not enough, pci probe patches must be removed Fixes #132 Signed-off-by: Julio Montes --- kernel/debian.series | 2 - kernel/kernel-config-4.9.x | 22 +++- kernel/linux-container.spec-template | 4 - kernel/patches-4.9.x/0106-pci-probe.patch | 123 ------------------ ...110-pci-probe-identify-known-devices.patch | 20 +-- ...st-kernel-set-pci-net-class-bar-to-4.patch | 46 ------- 6 files changed, 26 insertions(+), 191 deletions(-) delete mode 100644 kernel/patches-4.9.x/0106-pci-probe.patch delete mode 100644 kernel/patches-4.9.x/0207-pci-guest-kernel-set-pci-net-class-bar-to-4.patch diff --git a/kernel/debian.series b/kernel/debian.series index de33b72..29f0fbc 100644 --- a/kernel/debian.series +++ b/kernel/debian.series @@ -2,7 +2,6 @@ 0103-sysrq-skip-synchronize_rcu-if-there-is-no-old-op.patch 0104-fbcon-enable-no-blink-by-default.patch 0105-vmstats-wakeups.patch -0106-pci-probe.patch 0107-cgroup.patch 0108-smpboot-reuse-timer-calibration.patch 0109-perf.patch @@ -17,6 +16,5 @@ 0204-rdrand.patch 0205-reboot.patch 0206-no-early-modprobe.patch -0207-pci-guest-kernel-set-pci-net-class-bar-to-4.patch 0208-Show-restart-information-using-info-log.patch 0002-UBUNTU-SAUCE-no-up-disable-pie-when-gcc-has-it-enabl.patch diff --git a/kernel/kernel-config-4.9.x b/kernel/kernel-config-4.9.x index 8c45031..845a8e9 100644 --- a/kernel/kernel-config-4.9.x +++ b/kernel/kernel-config-4.9.x @@ -1,6 +1,6 @@ # # Automatically generated file; DO NOT EDIT. -# Linux/x86 4.9.4 Kernel Configuration +# Linux/x86 4.9.47 Kernel Configuration # CONFIG_64BIT=y CONFIG_X86_64=y @@ -581,8 +581,15 @@ CONFIG_PCI_MMCONFIG=y CONFIG_PCI_DOMAINS=y # CONFIG_PCI_CNB20LE_QUIRK is not set CONFIG_PCIEPORTBUS=y -# CONFIG_PCIEAER is not set -# CONFIG_PCIEASPM is not set +CONFIG_HOTPLUG_PCI_PCIE=y +CONFIG_PCIEAER=y +# CONFIG_PCIE_ECRC is not set +# CONFIG_PCIEAER_INJECT is not set +CONFIG_PCIEASPM=y +# CONFIG_PCIEASPM_DEBUG is not set +CONFIG_PCIEASPM_DEFAULT=y +# CONFIG_PCIEASPM_POWERSAVE is not set +# CONFIG_PCIEASPM_PERFORMANCE is not set # CONFIG_PCIE_DPC is not set # CONFIG_PCIE_PTM is not set CONFIG_PCI_BUS_ADDR_T_64BIT=y @@ -596,7 +603,10 @@ CONFIG_PCI_MSI_IRQ_DOMAIN=y # CONFIG_PCI_PRI is not set # CONFIG_PCI_PASID is not set CONFIG_PCI_LABEL=y -# CONFIG_HOTPLUG_PCI is not set +CONFIG_HOTPLUG_PCI=y +# CONFIG_HOTPLUG_PCI_ACPI is not set +# CONFIG_HOTPLUG_PCI_CPCI is not set +# CONFIG_HOTPLUG_PCI_SHPC is not set # # PCI host controller drivers @@ -1326,7 +1336,7 @@ CONFIG_NET_VENDOR_INTEL=y # CONFIG_IGBVF is not set # CONFIG_IXGB is not set CONFIG_IXGBE=y -CONFIG_IXGBEVF=y +# CONFIG_IXGBEVF is not set # CONFIG_I40E is not set # CONFIG_I40EVF is not set # CONFIG_FM10K is not set @@ -1822,7 +1832,7 @@ CONFIG_ARM_GIC_MAX_NR=1 # # Performance monitor support # -# CONFIG_RAS is not set +CONFIG_RAS=y # CONFIG_THUNDERBOLT is not set # diff --git a/kernel/linux-container.spec-template b/kernel/linux-container.spec-template index 7a8ac1f..3ed8f84 100644 --- a/kernel/linux-container.spec-template +++ b/kernel/linux-container.spec-template @@ -39,7 +39,6 @@ Patch0102: 0102-cpuidle-skip-synchronize_rcu-on-single-CPU-systems.patch Patch0103: 0103-sysrq-skip-synchronize_rcu-if-there-is-no-old-op.patch Patch0104: 0104-fbcon-enable-no-blink-by-default.patch Patch0105: 0105-vmstats-wakeups.patch -Patch0106: 0106-pci-probe.patch Patch0107: 0107-cgroup.patch Patch0108: 0108-smpboot-reuse-timer-calibration.patch Patch0109: 0109-perf.patch @@ -56,7 +55,6 @@ Patch0203: 0203-fs-9p-fix-create-unlink-getattr-idiom.patch Patch0204: 0204-rdrand.patch Patch0205: 0205-reboot.patch Patch0206: 0206-no-early-modprobe.patch -Patch0207: 0207-pci-guest-kernel-set-pci-net-class-bar-to-4.patch Patch0208: 0208-Show-restart-information-using-info-log.patch # Serie XYYY: Extra features modules @@ -73,7 +71,6 @@ The Linux kernel. %patch0103 -p1 %patch0104 -p1 %patch0105 -p1 -%patch0106 -p1 %patch0107 -p1 %patch0108 -p1 %patch0109 -p1 @@ -90,7 +87,6 @@ The Linux kernel. %patch0204 -p1 %patch0205 -p1 %patch0206 -p1 -%patch0207 -p1 %patch0208 -p1 # Serie XYYY: Extra features modules diff --git a/kernel/patches-4.9.x/0106-pci-probe.patch b/kernel/patches-4.9.x/0106-pci-probe.patch deleted file mode 100644 index 527d2ed..0000000 --- a/kernel/patches-4.9.x/0106-pci-probe.patch +++ /dev/null @@ -1,123 +0,0 @@ -From 6b1e2a25a8281e853927e32cecdc399e07473d80 Mon Sep 17 00:00:00 2001 -From: Arjan van de Ven -Date: Wed, 11 Feb 2015 16:53:08 -0600 -Subject: [PATCH 106/114] pci: probe - -Author: Arjan van de Ven - -Signed-off-by: Miguel Bernal Marin ---- - drivers/pci/probe.c | 43 ++++++++++++++++++++++++++++++++++++++++--- - 1 file changed, 40 insertions(+), 3 deletions(-) - -diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c -index 104c46d53121..e3377cd5a632 100644 ---- a/drivers/pci/probe.c -+++ b/drivers/pci/probe.c -@@ -182,6 +182,10 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type, - - mask = type ? PCI_ROM_ADDRESS_MASK : ~0; - -+ res->name = pci_name(dev); -+ -+ printk("clr: Starting probe for %s\n", res->name); -+ - /* No printks while decoding is disabled! */ - if (!dev->mmio_always_on) { - pci_read_config_word(dev, PCI_COMMAND, &orig_cmd); -@@ -191,8 +195,6 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type, - } - } - -- res->name = pci_name(dev); -- - pci_read_config_dword(dev, pos, &l); - pci_write_config_dword(dev, pos, l | mask); - pci_read_config_dword(dev, pos, &sz); -@@ -323,6 +325,8 @@ static void pci_read_bases(struct pci_dev *dev, unsigned int howmany, int rom) - if (dev->non_compliant_bars) - return; - -+ printk("clr: pci_read_bases start\n"); -+ - for (pos = 0; pos < howmany; pos++) { - struct resource *res = &dev->resource[pos]; - reg = PCI_BASE_ADDRESS_0 + (pos << 2); -@@ -331,11 +335,13 @@ static void pci_read_bases(struct pci_dev *dev, unsigned int howmany, int rom) - - if (rom) { - struct resource *res = &dev->resource[PCI_ROM_RESOURCE]; -+ printk("clr: rom path\n"); - dev->rom_base_reg = rom; - res->flags = IORESOURCE_MEM | IORESOURCE_PREFETCH | - IORESOURCE_READONLY | IORESOURCE_SIZEALIGN; - __pci_read_base(dev, pci_bar_mem32, res, rom); - } -+ printk("clr: pci_read_bases end\n"); - } - - static void pci_read_bridge_io(struct pci_bus *child) -@@ -1190,6 +1196,28 @@ static void pci_msi_setup_pci_dev(struct pci_dev *dev) - pci_msix_clear_and_set_ctrl(dev, PCI_MSIX_FLAGS_ENABLE, 0); - } - -+static int guess_bar_count(int class) -+{ -+ if (class == 0x068000) -+ return 0; -+ if (class == 0x020000) -+ return 2; -+ if (class == 0x010000) -+ return 2; -+ if (class == 0x00ff00) -+ return 1; -+ return 6; -+} -+ -+static int has_rom(int class, int rom) -+{ -+ if (class == 0x020000) -+ return 0; -+ if (class == 0x010000 || class == 0x00ff00) -+ return 0; -+ return rom; -+} -+ - /** - * pci_setup_device - fill in class and map information of a device - * @dev: the device structure to fill -@@ -1208,6 +1236,9 @@ int pci_setup_device(struct pci_dev *dev) - int pos = 0; - struct pci_bus_region region; - struct resource *res; -+ int maxbar; -+ -+ printk("clr: pci_setup_device start\n"); - - if (pci_read_config_byte(dev, PCI_HEADER_TYPE, &hdr_type)) - return -EIO; -@@ -1262,7 +1293,11 @@ int pci_setup_device(struct pci_dev *dev) - if (class == PCI_CLASS_BRIDGE_PCI) - goto bad; - pci_read_irq(dev); -- pci_read_bases(dev, 6, PCI_ROM_ADDRESS); -+ -+ maxbar = guess_bar_count(dev->class); -+ -+ if (class != PCI_CLASS_STORAGE_IDE) -+ pci_read_bases(dev, maxbar, has_rom(dev->class, PCI_ROM_ADDRESS)); - pci_read_config_word(dev, PCI_SUBSYSTEM_VENDOR_ID, &dev->subsystem_vendor); - pci_read_config_word(dev, PCI_SUBSYSTEM_ID, &dev->subsystem_device); - -@@ -1347,6 +1382,8 @@ int pci_setup_device(struct pci_dev *dev) - dev->class = PCI_CLASS_NOT_DEFINED << 8; - } - -+ printk("clr: pci_setup_device end\n"); -+ - /* We found a fine healthy device, go go go... */ - return 0; - } --- -2.11.0 - diff --git a/kernel/patches-4.9.x/0110-pci-probe-identify-known-devices.patch b/kernel/patches-4.9.x/0110-pci-probe-identify-known-devices.patch index 518aea9..70bbe8c 100644 --- a/kernel/patches-4.9.x/0110-pci-probe-identify-known-devices.patch +++ b/kernel/patches-4.9.x/0110-pci-probe-identify-known-devices.patch @@ -1,7 +1,7 @@ -From 3815fc20e3b97a003fd1ae6c5d5116ed5400baaf Mon Sep 17 00:00:00 2001 -From: Arjan van de Ven -Date: Sat, 14 Feb 2015 09:49:41 -0600 -Subject: [PATCH 110/114] pci: probe: identify known devices +From 3ef83534a6216dc2c3b19fb1e74ee0db9fa4257e Mon Sep 17 00:00:00 2001 +From: Julio Montes +Date: Fri, 29 Sep 2017 08:11:13 -0500 +Subject: [PATCH] pci: probe: identify known devices Author: Arjan van de Ven Modify-by: Miguel Bernal Marin @@ -12,7 +12,7 @@ Signed-off-by: Miguel Bernal Marin 1 file changed, 156 insertions(+) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c -index e3377cd5a632..cbe81b100d51 100644 +index d266d80..c182443 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -163,6 +163,159 @@ static inline unsigned long decode_bar(struct pci_dev *dev, u32 bar) @@ -175,16 +175,16 @@ index e3377cd5a632..cbe81b100d51 100644 /** * pci_read_base - read a PCI BAR * @dev: the PCI device -@@ -182,6 +335,9 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type, - - mask = type ? PCI_ROM_ADDRESS_MASK : ~0; +@@ -191,6 +344,9 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type, + } + } + if (is_known_device(dev, pos, &sz)) + return __pci_read_base_shortcut(dev, type, res, pos, sz, 0); + res->name = pci_name(dev); - printk("clr: Starting probe for %s\n", res->name); + pci_read_config_dword(dev, pos, &l); -- -2.11.0 +2.7.5 diff --git a/kernel/patches-4.9.x/0207-pci-guest-kernel-set-pci-net-class-bar-to-4.patch b/kernel/patches-4.9.x/0207-pci-guest-kernel-set-pci-net-class-bar-to-4.patch deleted file mode 100644 index eb639a8..0000000 --- a/kernel/patches-4.9.x/0207-pci-guest-kernel-set-pci-net-class-bar-to-4.patch +++ /dev/null @@ -1,46 +0,0 @@ -From bac97458bf52e5bcd5588b94435e402c44106496 Mon Sep 17 00:00:00 2001 -From: Fan Du -Date: Thu, 26 May 2016 12:55:29 -0500 -Subject: [PATCH 207/208] pci {guest kernel}: set pci net class bar to 4 - -For pci net class is defined as 0x020000 -By optimaztion, guess_bar_count set net class bar count to 2. -This will cause subsquent bar resource missing after lkvm -commit [1] extend virtio net bar resouces with MMIO bar. - -[1] a463650caad6 ("kvm tools: pci: add MMIO interface to virtio-pci devices") - -Signed-off-by: Fan Du - -Update to enable SRIOV on CC2.0 -Change suggested by Anthony Xu - -PCI device has 6 BARs, linux kernel normally scan all 6 BARs to -configure the MMIOs. Since scanning BAR operation is expensive -in VM and virtual NIC(virtio nic) use 3 BARs at most, there is -an optimization in clear-container guest KERNEL, which only scans -the first 3 BAR for NIC devices. Unfortunately igbvf uses BAR 3, -which is the 4th BAR, this BAR is not configured due to above -reason in Clear-Container. BAR 3 in igbvf is pointing to PBA, -which is used by MSI-X, that's why guest kernel failed to -configure MSI-X interrupt for igbvf. ---- - drivers/pci/probe.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c -index cbe81b100d51..8b7dbd221af3 100644 ---- a/drivers/pci/probe.c -+++ b/drivers/pci/probe.c -@@ -1357,7 +1357,7 @@ static int guess_bar_count(int class) - if (class == 0x068000) - return 0; - if (class == 0x020000) -- return 2; -+ return 4; - if (class == 0x010000) - return 2; - if (class == 0x00ff00) --- -2.11.0 -