From 5671964771ac01eaf06670be4b14c0262dee1362 Mon Sep 17 00:00:00 2001 From: David P Date: Fri, 6 Dec 2019 18:23:34 -0300 Subject: updpkg: libre/linux-libre-pae 5.4.2-1 Signed-off-by: David P --- ...ctl-and-CONFIG-to-disallow-unprivileged-C.patch | 20 +- ...idp-Fix-assumptions-on-the-return-value-o.patch | 63 ----- ...vres-add-a-helper-function-for-ioremap_uc.patch | 79 ++++++ ...d-intel-lpss-Use-devm_ioremap_uc-for-MMIO.patch | 48 ++++ ...Do-not-disable-interrupt-twice-on-suspend.patch | 99 ++++++++ ...PCI-pciehp-Prevent-deadlock-on-disconnect.patch | 272 +++++++++++++++++++++ libre/linux-libre-pae/PKGBUILD | 55 ++--- libre/linux-libre-pae/config | 190 +++++++++----- 8 files changed, 662 insertions(+), 164 deletions(-) delete mode 100644 libre/linux-libre-pae/0002-Bluetooth-hidp-Fix-assumptions-on-the-return-value-o.patch create mode 100644 libre/linux-libre-pae/0002-lib-devres-add-a-helper-function-for-ioremap_uc.patch create mode 100644 libre/linux-libre-pae/0003-mfd-intel-lpss-Use-devm_ioremap_uc-for-MMIO.patch create mode 100644 libre/linux-libre-pae/0004-PCI-pciehp-Do-not-disable-interrupt-twice-on-suspend.patch create mode 100644 libre/linux-libre-pae/0005-PCI-pciehp-Prevent-deadlock-on-disconnect.patch (limited to 'libre') diff --git a/libre/linux-libre-pae/0001-ZEN-Add-sysctl-and-CONFIG-to-disallow-unprivileged-C.patch b/libre/linux-libre-pae/0001-ZEN-Add-sysctl-and-CONFIG-to-disallow-unprivileged-C.patch index 4f5e8626a..bcd694ec0 100644 --- a/libre/linux-libre-pae/0001-ZEN-Add-sysctl-and-CONFIG-to-disallow-unprivileged-C.patch +++ b/libre/linux-libre-pae/0001-ZEN-Add-sysctl-and-CONFIG-to-disallow-unprivileged-C.patch @@ -1,7 +1,7 @@ -From 9927eac296fb506ef31e1c926dfbfc1ceeb44852 Mon Sep 17 00:00:00 2001 +From 270144c854dea695a7721fdd3a5503eb4acae7e4 Mon Sep 17 00:00:00 2001 From: "Jan Alexander Steffens (heftig)" Date: Mon, 16 Sep 2019 04:53:20 +0200 -Subject: [PATCH 1/2] ZEN: Add sysctl and CONFIG to disallow unprivileged +Subject: [PATCH 1/5] ZEN: Add sysctl and CONFIG to disallow unprivileged CLONE_NEWUSER Our default behavior continues to match the vanilla kernel. @@ -13,10 +13,10 @@ Our default behavior continues to match the vanilla kernel. 4 files changed, 50 insertions(+) diff --git a/init/Kconfig b/init/Kconfig -index bd7d650d4a99..658f9c052151 100644 +index b4daad2bac23..362f82c5ec07 100644 --- a/init/Kconfig +++ b/init/Kconfig -@@ -1091,6 +1091,22 @@ config USER_NS +@@ -1118,6 +1118,22 @@ config USER_NS If unsure, say N. @@ -40,7 +40,7 @@ index bd7d650d4a99..658f9c052151 100644 bool "PID Namespaces" default y diff --git a/kernel/fork.c b/kernel/fork.c -index 3647097e6783..f092d7be6847 100644 +index 6cabc124378c..fda4986da9eb 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -106,6 +106,11 @@ @@ -55,7 +55,7 @@ index 3647097e6783..f092d7be6847 100644 /* * Minimum number of threads to boot the kernel -@@ -1788,6 +1793,10 @@ static __latent_entropy struct task_struct *copy_process( +@@ -1779,6 +1784,10 @@ static __latent_entropy struct task_struct *copy_process( if ((clone_flags & (CLONE_NEWUSER|CLONE_FS)) == (CLONE_NEWUSER|CLONE_FS)) return ERR_PTR(-EINVAL); @@ -66,7 +66,7 @@ index 3647097e6783..f092d7be6847 100644 /* * Thread groups must share signals as well, and detached threads * can only be started up within the thread group. -@@ -2819,6 +2828,12 @@ int ksys_unshare(unsigned long unshare_flags) +@@ -2826,6 +2835,12 @@ int ksys_unshare(unsigned long unshare_flags) if (unshare_flags & CLONE_NEWNS) unshare_flags |= CLONE_FS; @@ -80,7 +80,7 @@ index 3647097e6783..f092d7be6847 100644 if (err) goto bad_unshare_out; diff --git a/kernel/sysctl.c b/kernel/sysctl.c -index 078950d9605b..baead3605bbe 100644 +index b6f2f35d0bcf..2e9c273990e8 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -110,6 +110,9 @@ extern int core_uses_pid; @@ -93,7 +93,7 @@ index 078950d9605b..baead3605bbe 100644 extern int pid_max; extern int pid_max_min, pid_max_max; extern int percpu_pagelist_fraction; -@@ -545,6 +548,15 @@ static struct ctl_table kern_table[] = { +@@ -546,6 +549,15 @@ static struct ctl_table kern_table[] = { .proc_handler = proc_dointvec, }, #endif @@ -128,5 +128,5 @@ index 8eadadc478f9..c36ecd19562c 100644 static DEFINE_MUTEX(userns_state_mutex); -- -2.23.0 +2.24.0 diff --git a/libre/linux-libre-pae/0002-Bluetooth-hidp-Fix-assumptions-on-the-return-value-o.patch b/libre/linux-libre-pae/0002-Bluetooth-hidp-Fix-assumptions-on-the-return-value-o.patch deleted file mode 100644 index aaefa37bb..000000000 --- a/libre/linux-libre-pae/0002-Bluetooth-hidp-Fix-assumptions-on-the-return-value-o.patch +++ /dev/null @@ -1,63 +0,0 @@ -From 0bee55974a73eed4a9b9c9e87000df34117e7f69 Mon Sep 17 00:00:00 2001 -From: Dan Elkouby -Date: Fri, 6 Sep 2019 14:06:44 +0300 -Subject: [PATCH 2/2] Bluetooth: hidp: Fix assumptions on the return value of - hidp_send_message - -hidp_send_message was changed to return non-zero values on success, -which some other bits did not expect. This caused spurious errors to be -propagated through the stack, breaking some drivers, such as hid-sony -for the Dualshock 4 in Bluetooth mode. - -As pointed out by Dan Carpenter, hid-microsoft directly relied on that -assumption as well. - -Fixes: 48d9cc9d85dd ("Bluetooth: hidp: Let hidp_send_message return number of queued bytes") - -Signed-off-by: Dan Elkouby -Reviewed-by: Dan Carpenter -Reviewed-by: Jiri Kosina -Signed-off-by: Marcel Holtmann ---- - drivers/hid/hid-microsoft.c | 2 +- - net/bluetooth/hidp/core.c | 4 ++-- - 2 files changed, 3 insertions(+), 3 deletions(-) - -diff --git a/drivers/hid/hid-microsoft.c b/drivers/hid/hid-microsoft.c -index 8b3a922bdad3..2cf83856f2e4 100644 ---- a/drivers/hid/hid-microsoft.c -+++ b/drivers/hid/hid-microsoft.c -@@ -303,7 +303,7 @@ static void ms_ff_worker(struct work_struct *work) - r->magnitude[MAGNITUDE_WEAK] = ms->weak; /* right actuator */ - - ret = hid_hw_output_report(hdev, (__u8 *)r, sizeof(*r)); -- if (ret) -+ if (ret < 0) - hid_warn(hdev, "failed to send FF report\n"); - } - -diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c -index 8d889969ae7e..bef84b95e2c4 100644 ---- a/net/bluetooth/hidp/core.c -+++ b/net/bluetooth/hidp/core.c -@@ -267,7 +267,7 @@ static int hidp_get_raw_report(struct hid_device *hid, - set_bit(HIDP_WAITING_FOR_RETURN, &session->flags); - data[0] = report_number; - ret = hidp_send_ctrl_message(session, report_type, data, 1); -- if (ret) -+ if (ret < 0) - goto err; - - /* Wait for the return of the report. The returned report -@@ -343,7 +343,7 @@ static int hidp_set_raw_report(struct hid_device *hid, unsigned char reportnum, - data[0] = reportnum; - set_bit(HIDP_WAITING_FOR_SEND_ACK, &session->flags); - ret = hidp_send_ctrl_message(session, report_type, data, count); -- if (ret) -+ if (ret < 0) - goto err; - - /* Wait for the ACK from the device. */ --- -2.23.0 - diff --git a/libre/linux-libre-pae/0002-lib-devres-add-a-helper-function-for-ioremap_uc.patch b/libre/linux-libre-pae/0002-lib-devres-add-a-helper-function-for-ioremap_uc.patch new file mode 100644 index 000000000..9befdd67a --- /dev/null +++ b/libre/linux-libre-pae/0002-lib-devres-add-a-helper-function-for-ioremap_uc.patch @@ -0,0 +1,79 @@ +From f20221735640685313d5020d7e6db4aad293a3ae Mon Sep 17 00:00:00 2001 +From: Tuowen Zhao +Date: Wed, 16 Oct 2019 15:06:28 -0600 +Subject: [PATCH 2/5] lib: devres: add a helper function for ioremap_uc + +Implement a resource managed strongly uncachable ioremap function. + +Cc: # v4.19+ +Tested-by: AceLan Kao +Signed-off-by: Tuowen Zhao +Acked-by: Mika Westerberg +Acked-by: Andy Shevchenko +Acked-by: Luis Chamberlain +Signed-off-by: Lee Jones +--- + include/linux/io.h | 2 ++ + lib/devres.c | 19 +++++++++++++++++++ + 2 files changed, 21 insertions(+) + +diff --git a/include/linux/io.h b/include/linux/io.h +index accac822336a..a59834bc0a11 100644 +--- a/include/linux/io.h ++++ b/include/linux/io.h +@@ -64,6 +64,8 @@ static inline void devm_ioport_unmap(struct device *dev, void __iomem *addr) + + void __iomem *devm_ioremap(struct device *dev, resource_size_t offset, + resource_size_t size); ++void __iomem *devm_ioremap_uc(struct device *dev, resource_size_t offset, ++ resource_size_t size); + void __iomem *devm_ioremap_nocache(struct device *dev, resource_size_t offset, + resource_size_t size); + void __iomem *devm_ioremap_wc(struct device *dev, resource_size_t offset, +diff --git a/lib/devres.c b/lib/devres.c +index 6a0e9bd6524a..17624d35e82d 100644 +--- a/lib/devres.c ++++ b/lib/devres.c +@@ -9,6 +9,7 @@ + enum devm_ioremap_type { + DEVM_IOREMAP = 0, + DEVM_IOREMAP_NC, ++ DEVM_IOREMAP_UC, + DEVM_IOREMAP_WC, + }; + +@@ -39,6 +40,9 @@ static void __iomem *__devm_ioremap(struct device *dev, resource_size_t offset, + case DEVM_IOREMAP_NC: + addr = ioremap_nocache(offset, size); + break; ++ case DEVM_IOREMAP_UC: ++ addr = ioremap_uc(offset, size); ++ break; + case DEVM_IOREMAP_WC: + addr = ioremap_wc(offset, size); + break; +@@ -68,6 +72,21 @@ void __iomem *devm_ioremap(struct device *dev, resource_size_t offset, + } + EXPORT_SYMBOL(devm_ioremap); + ++/** ++ * devm_ioremap_uc - Managed ioremap_uc() ++ * @dev: Generic device to remap IO address for ++ * @offset: Resource address to map ++ * @size: Size of map ++ * ++ * Managed ioremap_uc(). Map is automatically unmapped on driver detach. ++ */ ++void __iomem *devm_ioremap_uc(struct device *dev, resource_size_t offset, ++ resource_size_t size) ++{ ++ return __devm_ioremap(dev, offset, size, DEVM_IOREMAP_UC); ++} ++EXPORT_SYMBOL_GPL(devm_ioremap_uc); ++ + /** + * devm_ioremap_nocache - Managed ioremap_nocache() + * @dev: Generic device to remap IO address for +-- +2.24.0 + diff --git a/libre/linux-libre-pae/0003-mfd-intel-lpss-Use-devm_ioremap_uc-for-MMIO.patch b/libre/linux-libre-pae/0003-mfd-intel-lpss-Use-devm_ioremap_uc-for-MMIO.patch new file mode 100644 index 000000000..926097948 --- /dev/null +++ b/libre/linux-libre-pae/0003-mfd-intel-lpss-Use-devm_ioremap_uc-for-MMIO.patch @@ -0,0 +1,48 @@ +From affb9e39e0d2b1eefff47e2dc0a0aa3893b9bb5d Mon Sep 17 00:00:00 2001 +From: Tuowen Zhao +Date: Wed, 16 Oct 2019 15:06:29 -0600 +Subject: [PATCH 3/5] mfd: intel-lpss: Use devm_ioremap_uc for MMIO + +Some BIOS erroneously specifies write-combining BAR for intel-lpss-pci +in MTRR. This will cause the system to hang during boot. If possible, +this bug could be corrected with a firmware update. + +This patch use devm_ioremap_uc to overwrite/ignore the MTRR settings +by forcing the use of strongly uncachable pages for intel-lpss. + +The BIOS bug is present on Dell XPS 13 7390 2-in-1: + +[ 0.001734] 5 base 4000000000 mask 6000000000 write-combining + +4000000000-7fffffffff : PCI Bus 0000:00 + 4000000000-400fffffff : 0000:00:02.0 (i915) + 4010000000-4010000fff : 0000:00:15.0 (intel-lpss-pci) + +Link: https://bugzilla.kernel.org/show_bug.cgi?id=203485 +Cc: # v4.19+ +Tested-by: AceLan Kao +Signed-off-by: Tuowen Zhao +Acked-by: Mika Westerberg +Acked-by: Andy Shevchenko +Tested-by: Roman Gilg +Signed-off-by: Lee Jones +--- + drivers/mfd/intel-lpss.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/mfd/intel-lpss.c b/drivers/mfd/intel-lpss.c +index bfe4ff337581..b0f0781a6b9c 100644 +--- a/drivers/mfd/intel-lpss.c ++++ b/drivers/mfd/intel-lpss.c +@@ -384,7 +384,7 @@ int intel_lpss_probe(struct device *dev, + if (!lpss) + return -ENOMEM; + +- lpss->priv = devm_ioremap(dev, info->mem->start + LPSS_PRIV_OFFSET, ++ lpss->priv = devm_ioremap_uc(dev, info->mem->start + LPSS_PRIV_OFFSET, + LPSS_PRIV_SIZE); + if (!lpss->priv) + return -ENOMEM; +-- +2.24.0 + diff --git a/libre/linux-libre-pae/0004-PCI-pciehp-Do-not-disable-interrupt-twice-on-suspend.patch b/libre/linux-libre-pae/0004-PCI-pciehp-Do-not-disable-interrupt-twice-on-suspend.patch new file mode 100644 index 000000000..f3cba134a --- /dev/null +++ b/libre/linux-libre-pae/0004-PCI-pciehp-Do-not-disable-interrupt-twice-on-suspend.patch @@ -0,0 +1,99 @@ +From bdbb6d41bab0f525b679cf5018f77d5299773568 Mon Sep 17 00:00:00 2001 +From: Mika Westerberg +Date: Tue, 29 Oct 2019 20:00:21 +0300 +Subject: [PATCH 4/5] PCI: pciehp: Do not disable interrupt twice on suspend + +We try to keep PCIe hotplug ports runtime suspended when entering system +suspend. Because the PCIe portdrv sets the DPM_FLAG_NEVER_SKIP flag, the PM +core always calls system suspend/resume hooks even if the device is left +runtime suspended. Since PCIe hotplug driver re-used the same function for +both runtime suspend and system suspend, it ended up disabling hotplug +interrupt twice and the second time following was printed: + + pciehp 0000:03:01.0:pcie204: pcie_do_write_cmd: no response from device + +Prevent this from happening by checking whether the device is already +runtime suspended when the system suspend hook is called. + +Fixes: 9c62f0bfb832 ("PCI: pciehp: Implement runtime PM callbacks") +Link: https://lore.kernel.org/r/20191029170022.57528-1-mika.westerberg@linux.intel.com +Reported-by: Kai-Heng Feng +Tested-by: Kai-Heng Feng +Signed-off-by: Mika Westerberg +Signed-off-by: Bjorn Helgaas +Reviewed-by: Rafael J. Wysocki +--- + drivers/pci/hotplug/pciehp_core.c | 25 +++++++++++++++++++++++-- + 1 file changed, 23 insertions(+), 2 deletions(-) + +diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c +index b3122c151b80..56daad828c9e 100644 +--- a/drivers/pci/hotplug/pciehp_core.c ++++ b/drivers/pci/hotplug/pciehp_core.c +@@ -253,7 +253,7 @@ static bool pme_is_native(struct pcie_device *dev) + return pcie_ports_native || host->native_pme; + } + +-static int pciehp_suspend(struct pcie_device *dev) ++static void pciehp_disable_interrupt(struct pcie_device *dev) + { + /* + * Disable hotplug interrupt so that it does not trigger +@@ -261,7 +261,19 @@ static int pciehp_suspend(struct pcie_device *dev) + */ + if (pme_is_native(dev)) + pcie_disable_interrupt(get_service_data(dev)); ++} + ++#ifdef CONFIG_PM_SLEEP ++static int pciehp_suspend(struct pcie_device *dev) ++{ ++ /* ++ * If the port is already runtime suspended we can keep it that ++ * way. ++ */ ++ if (dev_pm_smart_suspend_and_suspended(&dev->port->dev)) ++ return 0; ++ ++ pciehp_disable_interrupt(dev); + return 0; + } + +@@ -279,6 +291,7 @@ static int pciehp_resume_noirq(struct pcie_device *dev) + + return 0; + } ++#endif + + static int pciehp_resume(struct pcie_device *dev) + { +@@ -292,6 +305,12 @@ static int pciehp_resume(struct pcie_device *dev) + return 0; + } + ++static int pciehp_runtime_suspend(struct pcie_device *dev) ++{ ++ pciehp_disable_interrupt(dev); ++ return 0; ++} ++ + static int pciehp_runtime_resume(struct pcie_device *dev) + { + struct controller *ctrl = get_service_data(dev); +@@ -318,10 +337,12 @@ static struct pcie_port_service_driver hpdriver_portdrv = { + .remove = pciehp_remove, + + #ifdef CONFIG_PM ++#ifdef CONFIG_PM_SLEEP + .suspend = pciehp_suspend, + .resume_noirq = pciehp_resume_noirq, + .resume = pciehp_resume, +- .runtime_suspend = pciehp_suspend, ++#endif ++ .runtime_suspend = pciehp_runtime_suspend, + .runtime_resume = pciehp_runtime_resume, + #endif /* PM */ + }; +-- +2.24.0 + diff --git a/libre/linux-libre-pae/0005-PCI-pciehp-Prevent-deadlock-on-disconnect.patch b/libre/linux-libre-pae/0005-PCI-pciehp-Prevent-deadlock-on-disconnect.patch new file mode 100644 index 000000000..0fc654b74 --- /dev/null +++ b/libre/linux-libre-pae/0005-PCI-pciehp-Prevent-deadlock-on-disconnect.patch @@ -0,0 +1,272 @@ +From 23db61d908b9a4854c9b15565d4cbfa800c45cfe Mon Sep 17 00:00:00 2001 +From: Mika Westerberg +Date: Tue, 29 Oct 2019 20:00:22 +0300 +Subject: [PATCH 5/5] PCI: pciehp: Prevent deadlock on disconnect + +This addresses deadlocks in these common cases in hierarchies containing +two switches: + + - All involved ports are runtime suspended and they are unplugged. This + can happen easily if the drivers involved automatically enable runtime + PM (xHCI for example does that). + + - System is suspended (e.g., closing the lid on a laptop) with a dock + + something else connected, and the dock is unplugged while suspended. + +These cases lead to the following deadlock: + + INFO: task irq/126-pciehp:198 blocked for more than 120 seconds. + irq/126-pciehp D 0 198 2 0x80000000 + Call Trace: + schedule+0x2c/0x80 + schedule_timeout+0x246/0x350 + wait_for_completion+0xb7/0x140 + kthread_stop+0x49/0x110 + free_irq+0x32/0x70 + pcie_shutdown_notification+0x2f/0x50 + pciehp_remove+0x27/0x50 + pcie_port_remove_service+0x36/0x50 + device_release_driver+0x12/0x20 + bus_remove_device+0xec/0x160 + device_del+0x13b/0x350 + device_unregister+0x1a/0x60 + remove_iter+0x1e/0x30 + device_for_each_child+0x56/0x90 + pcie_port_device_remove+0x22/0x40 + pcie_portdrv_remove+0x20/0x60 + pci_device_remove+0x3e/0xc0 + device_release_driver_internal+0x18c/0x250 + device_release_driver+0x12/0x20 + pci_stop_bus_device+0x6f/0x90 + pci_stop_bus_device+0x31/0x90 + pci_stop_and_remove_bus_device+0x12/0x20 + pciehp_unconfigure_device+0x88/0x140 + pciehp_disable_slot+0x6a/0x110 + pciehp_handle_presence_or_link_change+0x263/0x400 + pciehp_ist+0x1c9/0x1d0 + irq_thread_fn+0x24/0x60 + irq_thread+0xeb/0x190 + kthread+0x120/0x140 + + INFO: task irq/190-pciehp:2288 blocked for more than 120 seconds. + irq/190-pciehp D 0 2288 2 0x80000000 + Call Trace: + __schedule+0x2a2/0x880 + schedule+0x2c/0x80 + schedule_preempt_disabled+0xe/0x10 + mutex_lock+0x2c/0x30 + pci_lock_rescan_remove+0x15/0x20 + pciehp_unconfigure_device+0x4d/0x140 + pciehp_disable_slot+0x6a/0x110 + pciehp_handle_presence_or_link_change+0x263/0x400 + pciehp_ist+0x1c9/0x1d0 + irq_thread_fn+0x24/0x60 + irq_thread+0xeb/0x190 + kthread+0x120/0x140 + +What happens here is that the whole hierarchy is runtime resumed and the +parent PCIe downstream port, which got the hot-remove event, starts +removing devices below it, taking pci_lock_rescan_remove() lock. When the +child PCIe port is runtime resumed it calls pciehp_check_presence() which +ends up calling pciehp_card_present() and pciehp_check_link_active(). Both +of these use pcie_capability_read_word(), which notices that the underlying +device is already gone and returns PCIBIOS_DEVICE_NOT_FOUND with the +capability value set to 0. When pciehp gets this value it thinks that its +child device is also hot-removed and schedules its IRQ thread to handle the +event. + +The deadlock happens when the child's IRQ thread runs and tries to acquire +pci_lock_rescan_remove() which is already taken by the parent and the +parent waits for the child's IRQ thread to finish. + +Prevent this from happening by checking the return value of +pcie_capability_read_word() and if it is PCIBIOS_DEVICE_NOT_FOUND stop +performing any hot-removal activities. + +[bhelgaas: add common scenarios to commit log] +Link: https://lore.kernel.org/r/20191029170022.57528-2-mika.westerberg@linux.intel.com +Tested-by: Kai-Heng Feng +Signed-off-by: Mika Westerberg +Signed-off-by: Bjorn Helgaas +--- + drivers/pci/hotplug/pciehp.h | 6 ++-- + drivers/pci/hotplug/pciehp_core.c | 11 ++++-- + drivers/pci/hotplug/pciehp_ctrl.c | 4 +-- + drivers/pci/hotplug/pciehp_hpc.c | 59 +++++++++++++++++++++++++------ + 4 files changed, 61 insertions(+), 19 deletions(-) + +diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h +index 654c972b8ea0..afea59a3aad2 100644 +--- a/drivers/pci/hotplug/pciehp.h ++++ b/drivers/pci/hotplug/pciehp.h +@@ -172,10 +172,10 @@ void pciehp_set_indicators(struct controller *ctrl, int pwr, int attn); + + void pciehp_get_latch_status(struct controller *ctrl, u8 *status); + int pciehp_query_power_fault(struct controller *ctrl); +-bool pciehp_card_present(struct controller *ctrl); +-bool pciehp_card_present_or_link_active(struct controller *ctrl); ++int pciehp_card_present(struct controller *ctrl); ++int pciehp_card_present_or_link_active(struct controller *ctrl); + int pciehp_check_link_status(struct controller *ctrl); +-bool pciehp_check_link_active(struct controller *ctrl); ++int pciehp_check_link_active(struct controller *ctrl); + void pciehp_release_ctrl(struct controller *ctrl); + + int pciehp_sysfs_enable_slot(struct hotplug_slot *hotplug_slot); +diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c +index 56daad828c9e..312cc45c44c7 100644 +--- a/drivers/pci/hotplug/pciehp_core.c ++++ b/drivers/pci/hotplug/pciehp_core.c +@@ -139,10 +139,15 @@ static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 *value) + { + struct controller *ctrl = to_ctrl(hotplug_slot); + struct pci_dev *pdev = ctrl->pcie->port; ++ int ret; + + pci_config_pm_runtime_get(pdev); +- *value = pciehp_card_present_or_link_active(ctrl); ++ ret = pciehp_card_present_or_link_active(ctrl); + pci_config_pm_runtime_put(pdev); ++ if (ret < 0) ++ return ret; ++ ++ *value = ret; + return 0; + } + +@@ -158,13 +163,13 @@ static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 *value) + */ + static void pciehp_check_presence(struct controller *ctrl) + { +- bool occupied; ++ int occupied; + + down_read(&ctrl->reset_lock); + mutex_lock(&ctrl->state_lock); + + occupied = pciehp_card_present_or_link_active(ctrl); +- if ((occupied && (ctrl->state == OFF_STATE || ++ if ((occupied > 0 && (ctrl->state == OFF_STATE || + ctrl->state == BLINKINGON_STATE)) || + (!occupied && (ctrl->state == ON_STATE || + ctrl->state == BLINKINGOFF_STATE))) +diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c +index 21af7b16d7a4..c760a13ec7b1 100644 +--- a/drivers/pci/hotplug/pciehp_ctrl.c ++++ b/drivers/pci/hotplug/pciehp_ctrl.c +@@ -226,7 +226,7 @@ void pciehp_handle_disable_request(struct controller *ctrl) + + void pciehp_handle_presence_or_link_change(struct controller *ctrl, u32 events) + { +- bool present, link_active; ++ int present, link_active; + + /* + * If the slot is on and presence or link has changed, turn it off. +@@ -257,7 +257,7 @@ void pciehp_handle_presence_or_link_change(struct controller *ctrl, u32 events) + mutex_lock(&ctrl->state_lock); + present = pciehp_card_present(ctrl); + link_active = pciehp_check_link_active(ctrl); +- if (!present && !link_active) { ++ if (present <= 0 && link_active <= 0) { + mutex_unlock(&ctrl->state_lock); + return; + } +diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c +index 1a522c1c4177..526a8f70bac5 100644 +--- a/drivers/pci/hotplug/pciehp_hpc.c ++++ b/drivers/pci/hotplug/pciehp_hpc.c +@@ -201,17 +201,29 @@ static void pcie_write_cmd_nowait(struct controller *ctrl, u16 cmd, u16 mask) + pcie_do_write_cmd(ctrl, cmd, mask, false); + } + +-bool pciehp_check_link_active(struct controller *ctrl) ++/** ++ * pciehp_check_link_active() - Is the link active ++ * @ctrl: PCIe hotplug controller ++ * ++ * Check whether the downstream link is currently active. Note it is ++ * possible that the card is removed immediately after this so the ++ * caller may need to take it into account. ++ * ++ * If the hotplug controller itself is not available anymore returns ++ * %-ENODEV. ++ */ ++int pciehp_check_link_active(struct controller *ctrl) + { + struct pci_dev *pdev = ctrl_dev(ctrl); + u16 lnk_status; +- bool ret; ++ int ret; + +- pcie_capability_read_word(pdev, PCI_EXP_LNKSTA, &lnk_status); +- ret = !!(lnk_status & PCI_EXP_LNKSTA_DLLLA); ++ ret = pcie_capability_read_word(pdev, PCI_EXP_LNKSTA, &lnk_status); ++ if (ret == PCIBIOS_DEVICE_NOT_FOUND || lnk_status == (u16)~0) ++ return -ENODEV; + +- if (ret) +- ctrl_dbg(ctrl, "%s: lnk_status = %x\n", __func__, lnk_status); ++ ret = !!(lnk_status & PCI_EXP_LNKSTA_DLLLA); ++ ctrl_dbg(ctrl, "%s: lnk_status = %x\n", __func__, lnk_status); + + return ret; + } +@@ -373,13 +385,29 @@ void pciehp_get_latch_status(struct controller *ctrl, u8 *status) + *status = !!(slot_status & PCI_EXP_SLTSTA_MRLSS); + } + +-bool pciehp_card_present(struct controller *ctrl) ++/** ++ * pciehp_card_present() - Is the card present ++ * @ctrl: PCIe hotplug controller ++ * ++ * Function checks whether the card is currently present in the slot and ++ * in that case returns true. Note it is possible that the card is ++ * removed immediately after the check so the caller may need to take ++ * this into account. ++ * ++ * It the hotplug controller itself is not available anymore returns ++ * %-ENODEV. ++ */ ++int pciehp_card_present(struct controller *ctrl) + { + struct pci_dev *pdev = ctrl_dev(ctrl); + u16 slot_status; ++ int ret; + +- pcie_capability_read_word(pdev, PCI_EXP_SLTSTA, &slot_status); +- return slot_status & PCI_EXP_SLTSTA_PDS; ++ ret = pcie_capability_read_word(pdev, PCI_EXP_SLTSTA, &slot_status); ++ if (ret == PCIBIOS_DEVICE_NOT_FOUND || slot_status == (u16)~0) ++ return -ENODEV; ++ ++ return !!(slot_status & PCI_EXP_SLTSTA_PDS); + } + + /** +@@ -390,10 +418,19 @@ bool pciehp_card_present(struct controller *ctrl) + * Presence Detect State bit, this helper also returns true if the Link Active + * bit is set. This is a concession to broken hotplug ports which hardwire + * Presence Detect State to zero, such as Wilocity's [1ae9:0200]. ++ * ++ * Returns: %1 if the slot is occupied and %0 if it is not. If the hotplug ++ * port is not present anymore returns %-ENODEV. + */ +-bool pciehp_card_present_or_link_active(struct controller *ctrl) ++int pciehp_card_present_or_link_active(struct controller *ctrl) + { +- return pciehp_card_present(ctrl) || pciehp_check_link_active(ctrl); ++ int ret; ++ ++ ret = pciehp_card_present(ctrl); ++ if (ret) ++ return ret; ++ ++ return pciehp_check_link_active(ctrl); + } + + int pciehp_query_power_fault(struct controller *ctrl) +-- +2.24.0 + diff --git a/libre/linux-libre-pae/PKGBUILD b/libre/linux-libre-pae/PKGBUILD index 60e5a5207..b5655e5df 100644 --- a/libre/linux-libre-pae/PKGBUILD +++ b/libre/linux-libre-pae/PKGBUILD @@ -1,4 +1,4 @@ -# Maintainer: David P +# Maintainer: David P. # Contributor: André Silva # Contributor: Márcio Silva @@ -9,22 +9,22 @@ _replacesoldkernels=() # '%' gets replaced with kernel suffix _replacesoldmodules=() # '%' gets replaced with kernel suffix pkgbase=linux-libre-pae -pkgver=5.3.13_gnu +pkgver=5.4.2 pkgrel=1 pkgdesc='Linux-libre PAE (physical address extension)' url='https://linux-libre.fsfla.org/' arch=(i686) license=(GPL2) makedepends=( - xmlto kmod inetutils bc libelf - python-sphinx python-sphinx_rtd_theme graphviz imagemagick + bc kmod libelf + xmlto python-sphinx python-sphinx_rtd_theme graphviz imagemagick cpio ) options=('!strip') -_srcname=linux-5.3 +_srcname=linux-5.4 source=( "https://linux-libre.fsfla.org/pub/linux-libre/releases/${_srcname##*-}-gnu/linux-libre-${_srcname##*-}-gnu.tar.xz"{,.sign} - "https://linux-libre.fsfla.org/pub/linux-libre/releases/${pkgver//_/-}/patch-${_srcname##*-}-gnu-${pkgver//_/-}.xz"{,.sign} + "https://linux-libre.fsfla.org/pub/linux-libre/releases/$pkgver-gnu/patch-${_srcname##*-}-gnu-$pkgver-gnu.xz"{,.sign} "https://repo.parabola.nu/other/linux-libre/logos/logo_linux_"{clut224.ppm,vga16.ppm,mono.pbm}{,.sig} config # the main kernel config files @@ -35,18 +35,20 @@ source=( # https://labs.parabola.nu/issues/877 # http://www.fsfla.org/pipermail/linux-libre/2015-November/003202.html 0002-fix-Atmel-maXTouch-touchscreen-support.patch - - # Arch's custom linux patches + # extracted patches from Arch Linux kernel sources 0001-ZEN-Add-sysctl-and-CONFIG-to-disallow-unprivileged-C.patch - 0002-Bluetooth-hidp-Fix-assumptions-on-the-return-value-o.patch + 0002-lib-devres-add-a-helper-function-for-ioremap_uc.patch + 0003-mfd-intel-lpss-Use-devm_ioremap_uc-for-MMIO.patch + 0004-PCI-pciehp-Do-not-disable-interrupt-twice-on-suspend.patch + 0005-PCI-pciehp-Prevent-deadlock-on-disconnect.patch ) validpgpkeys=( '474402C8C582DAFBE389C427BCB7CF877E7D47A7' # Alexandre Oliva '6DB9C4B4F0D8C0DC432CF6E4227CA7C556B2BA78' # David P. ) -sha512sums=('85d83c973ef96ab414354414da70ab3e1c3df19c3088458498cec1594952878b7967a8988bd9e36d4e728cc573a36e6eac056dbcab2f9aa742f18cbb4fb3164f' +sha512sums=('0d0915133864eb031adfc6700066147dcf3e768a50a31c39754950c95ef4fd322dc701cd50af49c403ef0325adfcb07e354d5e46c1be3dcdd719a7a55c963f37' 'SKIP' - '3e9c95825f6852a0721a940c80b01b9772c17ae1680c1ce5a151e4f5b577a4a50f030aa0f2fbbc2b53b898b081bf33e67bfdeb513fe5535f95c4b479452264c3' + '0b177b5ab5e7b65769c7b1176590f9fadd134f32af4db2bd0fa362dccfefb28d7fd0865b46418f54f10f039623d86012b49bcfb968bae77274447d7a97da35f5' 'SKIP' '13cb5bc42542e7b8bb104d5f68253f6609e463b6799800418af33eb0272cc269aaa36163c3e6f0aacbdaaa1d05e2827a4a7c4a08a029238439ed08b89c564bb3' 'SKIP' @@ -54,11 +56,14 @@ sha512sums=('85d83c973ef96ab414354414da70ab3e1c3df19c3088458498cec1594952878b796 'SKIP' '267295aa0cea65684968420c68b32f1a66a22d018b9d2b2c1ef14267bcf4cb68aaf7099d073cbfefe6c25c8608bdcbbd45f7ac8893fdcecbf1e621abdfe9ecc1' 'SKIP' - '6573f6f2a1cc3c2b3b084e57c70849b8153c4f1cdb745bfed596811e8b04e0080d7c2217b8f94ac254972b20a4ef9d60fe24ac8ef4c7b9ea330ab451c4d1f794' + '63f3c3bfe27eb66391dfa2120193476f03cf668bbd9edf4b7cc5dcb8c53295b830ecb6afd10b9a89c190d7f02597529b484c22dbb849d221ef975af8db1d8049' '02af4dd2a007e41db0c63822c8ab3b80b5d25646af1906dc85d0ad9bb8bbf5236f8e381d7f91cf99ed4b0978c50aee37cb9567cdeef65b7ec3d91b882852b1af' 'b8fe56e14006ab866970ddbd501c054ae37186ddc065bb869cf7d18db8c0d455118d5bda3255fb66a0dde38b544655cfe9040ffe46e41d19830b47959b2fb168' - '5c48b0092ab6a31453e27e6345347fd2d066e1c306c4c8a9144260bf37d0d13879b5cfe688906a06627d39a40a37e229e5300a479b2c9159e93e05ea7adc6b0a' - 'b07d84cac1c784f5652a4681efd54ef89ce9cb0778bd2a633709b7150f9fb59db978dc290b92bcb69b8d211471c22a0be2a81a129318cd7efff601a3c591483c') + '5bb7fa615301014045383b5421901892565ba7f7fd67da93e34a2b032d3721f6f3e677f8fc87072a33d0d79089541e37b5a34a14bfab2a71b587e3abe3e9743f' + '3ff6fc2cdf541b73e53b22213dd1b218544b15f363d6ce15f42a6ac2deb928dd8f536962a8162a648751cadde827d25427105d0bac4e596288ef839943b71f3a' + 'cfa690ea2e500b4a9670cfff96c9ffc675ffd34799b6ee41a7e173fb71d4fb915a8ff8b50f8802bbc59d1e9fe1ac458bdbdd3f0af249fbc44d3cc80b09a9da75' + 'd71a80d180f4f0a5491fc87dcda6237e53cb309d21d497a76a4f914ce376b53885cd767db2603e6a7ee5b0e6c1f926ac85865614f0997122a73e1e8d1c127749' + '56e94bb21c2f233c61f91336b08263bfc28a755e65cd8ddad89186e8f157417f51925927182bca106f03ddae6a5139e78647c48b6961b669444c4337c7b64731') _replacesarchkernel=("${_replacesarchkernel[@]/\%/${pkgbase#linux-libre}}") _replacesoldkernels=("${_replacesoldkernels[@]/\%/${pkgbase#linux-libre}}") @@ -71,9 +76,9 @@ export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EP prepare() { cd $_srcname - if [ "${_srcname##*-}-gnu" != "${pkgver//_/-}" ]; then + if [ "${_srcname##*-}" != "$pkgver" ]; then msg2 "Applying upstream patch..." - patch -p1 -i ../patch-${_srcname##*-}-gnu-${pkgver//_/-} + patch -Np1 -i ../patch-${_srcname##*-}-gnu-$pkgver-gnu fi msg2 "Adding freedo as boot logo..." @@ -218,7 +223,7 @@ _package-headers() { } _package-docs() { - pkgdesc="Kernel hacker's manual for the $pkgdesc kernel" + pkgdesc="Documentation for the $pkgdesc kernel" provides=("${_replacesarchkernel[@]/%/-docs=${pkgver%%_*}}") conflicts=("${_replacesarchkernel[@]/%/-docs}" "${_replacesoldkernels[@]/%/-docs}") replaces=("${_replacesarchkernel[@]/%/-docs}" "${_replacesoldkernels[@]/%/-docs}") @@ -227,20 +232,12 @@ _package-docs() { local builddir="$pkgdir/usr/lib/modules/$(