]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/5.0.19/pci-fix-issue-with-pci-disable_acs_redir-parameter-b.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 5.0.19 / pci-fix-issue-with-pci-disable_acs_redir-parameter-b.patch
CommitLineData
e6832405
SL
1From 61b682be17b429c09e24c50bcf4429bd352275d8 Mon Sep 17 00:00:00 2001
2From: Logan Gunthorpe <logang@deltatee.com>
3Date: Wed, 10 Apr 2019 15:05:31 -0600
4Subject: PCI: Fix issue with "pci=disable_acs_redir" parameter being ignored
5
6[ Upstream commit d5bc73f34cc97c4b4b9202cc93182c2515076edf ]
7
8In most cases, kmalloc() will not be available early in boot when
9pci_setup() is called. Thus, the kstrdup() call that was added to fix the
10__initdata bug with the disable_acs_redir parameter usually returns NULL,
11so the parameter is discarded and has no effect.
12
13To fix this, store the string that's in initdata until an initcall function
14can allocate the memory appropriately. This way we don't need any
15additional static memory.
16
17Fixes: d2fd6e81912a ("PCI: Fix __initdata issue with "pci=disable_acs_redir" parameter")
18Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
19Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
20Signed-off-by: Sasha Levin <sashal@kernel.org>
21---
22 drivers/pci/pci.c | 19 +++++++++++++++++--
23 1 file changed, 17 insertions(+), 2 deletions(-)
24
25diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
26index e91005d0f20c7..3f77bab698ced 100644
27--- a/drivers/pci/pci.c
28+++ b/drivers/pci/pci.c
29@@ -6266,8 +6266,7 @@ static int __init pci_setup(char *str)
30 } else if (!strncmp(str, "pcie_scan_all", 13)) {
31 pci_add_flags(PCI_SCAN_ALL_PCIE_DEVS);
32 } else if (!strncmp(str, "disable_acs_redir=", 18)) {
33- disable_acs_redir_param =
34- kstrdup(str + 18, GFP_KERNEL);
35+ disable_acs_redir_param = str + 18;
36 } else {
37 printk(KERN_ERR "PCI: Unknown option `%s'\n",
38 str);
39@@ -6278,3 +6277,19 @@ static int __init pci_setup(char *str)
40 return 0;
41 }
42 early_param("pci", pci_setup);
43+
44+/*
45+ * 'disable_acs_redir_param' is initialized in pci_setup(), above, to point
46+ * to data in the __initdata section which will be freed after the init
47+ * sequence is complete. We can't allocate memory in pci_setup() because some
48+ * architectures do not have any memory allocation service available during
49+ * an early_param() call. So we allocate memory and copy the variable here
50+ * before the init section is freed.
51+ */
52+static int __init pci_realloc_setup_params(void)
53+{
54+ disable_acs_redir_param = kstrdup(disable_acs_redir_param, GFP_KERNEL);
55+
56+ return 0;
57+}
58+pure_initcall(pci_realloc_setup_params);
59--
602.20.1
61