From patchwork Mon Apr 1 19:33:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Logan Gunthorpe X-Patchwork-Id: 10880525 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5436513B5 for ; Mon, 1 Apr 2019 19:33:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3F2042875E for ; Mon, 1 Apr 2019 19:33:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2EE222882D; Mon, 1 Apr 2019 19:33:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BEE762875E for ; Mon, 1 Apr 2019 19:33:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725880AbfDATdT (ORCPT ); Mon, 1 Apr 2019 15:33:19 -0400 Received: from ale.deltatee.com ([207.54.116.67]:45386 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725878AbfDATdT (ORCPT ); Mon, 1 Apr 2019 15:33:19 -0400 Received: from cgy1-donard.priv.deltatee.com ([172.16.1.31]) by ale.deltatee.com with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hB2gH-00005u-Iu; Mon, 01 Apr 2019 13:33:18 -0600 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.89) (envelope-from ) id 1hB2gG-0003LN-Qq; Mon, 01 Apr 2019 13:33:16 -0600 From: Logan Gunthorpe To: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Stephen Bates , Logan Gunthorpe , Andrew Maier , Bjorn Helgaas Date: Mon, 1 Apr 2019 13:33:02 -0600 Message-Id: <20190401193302.12813-1-logang@deltatee.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-SA-Exim-Connect-IP: 172.16.1.31 X-SA-Exim-Rcpt-To: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, sbates@raithlin.com, logang@deltatee.com, andrew.maier@eideticom.com, bhelgaas@google.com X-SA-Exim-Mail-From: gunthorp@deltatee.com Subject: [PATCH] PCI: Fix issue with "pci=disable_acs_redir" parameter being ignored X-SA-Exim-Version: 4.2.1 (built Tue, 02 Aug 2016 21:08:31 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Tested-by: Andrew Maier Cc: Bjorn Helgaas --- 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(-) -- 2.20.1 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);