linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Logan Gunthorpe <logang@deltatee.com>
To: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Stephen Bates <sbates@raithlin.com>,
	Logan Gunthorpe <logang@deltatee.com>,
	Andrew Maier <andrew.maier@eideticom.com>,
	Bjorn Helgaas <bhelgaas@google.com>
Subject: [PATCH] PCI: Fix issue with "pci=disable_acs_redir" parameter being ignored
Date: Mon,  1 Apr 2019 13:33:02 -0600	[thread overview]
Message-ID: <20190401193302.12813-1-logang@deltatee.com> (raw)

In most cases, kmalloc will not be available early in boot when
pci_setup() is called. Thus, the kstrdup call that was added to fix the
__initdata bug with the disable_acs_redir parameter usually returns
NULL. Thus the parameter is discarded and it does not take into effect.

To fix this we have to do what we originally did with the
resource_alignment parameter: allocate a static buffer and copy the
string from the command line to it.

Fixes: d2fd6e81912a ("PCI: Fix __initdata issue with "pci=disable_acs_redir" parameter")
Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Tested-by: Andrew Maier <andrew.maier@eideticom.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
---

Sorry, it seems I didn't test the previous patch in this area properly
and I actually made disable_acs_redir ineffective in most cases.

This change should fix it and I got a colleague to test it fully
on his system as well.

drivers/pci/pci.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 7c1b362f599a..537395dfd0df 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -3125,7 +3125,17 @@ void pci_request_acs(void)
 	pci_acs_enable = 1;
 }

-static const char *disable_acs_redir_param;
+static char disable_acs_redir_param[COMMAND_LINE_SIZE];
+
+static void pci_set_disable_acs_redir_param(const char *param)
+{
+	if (strlen(param) >= sizeof(disable_acs_redir_param)) {
+		pr_err("PCI: disable_acs_redir parameter is too long and has been ignored!\n");
+		return;
+	}
+
+	strcpy(disable_acs_redir_param, param);
+}

 /**
  * pci_disable_acs_redir - disable ACS redirect capabilities
@@ -3140,7 +3150,7 @@ static void pci_disable_acs_redir(struct pci_dev *dev)
 	int pos;
 	u16 ctrl;

-	if (!disable_acs_redir_param)
+	if (!disable_acs_redir_param[0])
 		return;

 	p = disable_acs_redir_param;
@@ -6262,8 +6272,7 @@ static int __init pci_setup(char *str)
 			} else if (!strncmp(str, "pcie_scan_all", 13)) {
 				pci_add_flags(PCI_SCAN_ALL_PCIE_DEVS);
 			} else if (!strncmp(str, "disable_acs_redir=", 18)) {
-				disable_acs_redir_param =
-					kstrdup(str + 18, GFP_KERNEL);
+				pci_set_disable_acs_redir_param(str + 18);
 			} else {
 				printk(KERN_ERR "PCI: Unknown option `%s'\n",
 						str);
--
2.20.1

             reply	other threads:[~2019-04-01 19:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-01 19:33 Logan Gunthorpe [this message]
2019-04-05 21:39 ` [PATCH] PCI: Fix issue with "pci=disable_acs_redir" parameter being ignored Bjorn Helgaas
2019-04-05 22:11   ` Logan Gunthorpe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190401193302.12813-1-logang@deltatee.com \
    --to=logang@deltatee.com \
    --cc=andrew.maier@eideticom.com \
    --cc=bhelgaas@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=sbates@raithlin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).