From patchwork Wed May 22 14:31:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Johnson X-Patchwork-Id: 10955947 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 A5DE614B6 for ; Wed, 22 May 2019 14:31:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 95BAB28B56 for ; Wed, 22 May 2019 14:31:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 88BF728BBB; Wed, 22 May 2019 14:31:30 +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 E2E8028998 for ; Wed, 22 May 2019 14:31:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729362AbfEVOb3 (ORCPT ); Wed, 22 May 2019 10:31:29 -0400 Received: from mail-oln040092255066.outbound.protection.outlook.com ([40.92.255.66]:29856 "EHLO APC01-HK2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728835AbfEVOb3 (ORCPT ); Wed, 22 May 2019 10:31:29 -0400 Received: from HK2APC01FT049.eop-APC01.prod.protection.outlook.com (10.152.248.51) by HK2APC01HT047.eop-APC01.prod.protection.outlook.com (10.152.249.52) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1922.16; Wed, 22 May 2019 14:31:23 +0000 Received: from PS2P216MB0642.KORP216.PROD.OUTLOOK.COM (10.152.248.53) by HK2APC01FT049.mail.protection.outlook.com (10.152.249.218) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1922.16 via Frontend Transport; Wed, 22 May 2019 14:31:23 +0000 Received: from PS2P216MB0642.KORP216.PROD.OUTLOOK.COM ([fe80::1c5e:7ea0:b90c:65c9]) by PS2P216MB0642.KORP216.PROD.OUTLOOK.COM ([fe80::1c5e:7ea0:b90c:65c9%10]) with mapi id 15.20.1922.016; Wed, 22 May 2019 14:31:23 +0000 From: Nicholas Johnson To: "linux-kernel@vger.kernel.org" CC: "linux-pci@vger.kernel.org" , "bhelgaas@google.com" , "mika.westerberg@linux.intel.com" , "corbet@lwn.net" , Nicholas Johnson Subject: [PATCH v6 4/4] PCI: Add pci=hpmemprefsize parameter to set MMIO_PREF size independently Thread-Topic: [PATCH v6 4/4] PCI: Add pci=hpmemprefsize parameter to set MMIO_PREF size independently Thread-Index: AQHVEKsHwCqlldYoMk6d0urRHVeKyg== Date: Wed, 22 May 2019 14:31:23 +0000 Message-ID: References: <20190522222928.2964-1-nicholas.johnson-opensource@outlook.com.au> In-Reply-To: <20190522222928.2964-1-nicholas.johnson-opensource@outlook.com.au> Accept-Language: en-AU, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: SYBPR01CA0209.ausprd01.prod.outlook.com (2603:10c6:10:16::29) To PS2P216MB0642.KORP216.PROD.OUTLOOK.COM (2603:1096:300:1c::16) x-incomingtopheadermarker: OriginalChecksum:2A4859F7C8B715DA7ADA99596C0698E9012A0B0C69BFDB5F30E7CB48A19DA3FF;UpperCasedChecksum:6568E58DD8E9C9342E6324D7C0697A8C333EEDB1F9970289F8698CDC1FFCB3D8;SizeAsReceived:7925;Count:50 x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.19.1 x-tmn: [VWHQ7I6Ekcvs30bkRjrumcJvj8YCVFrLQEh9ZdwS4OoB8v9HHOGo96hn/fxG6Y5jRtZK7LOK18Y=] x-microsoft-original-message-id: <20190522222928.2964-5-nicholas.johnson-opensource@outlook.com.au> x-ms-publictraffictype: Email x-incomingheadercount: 50 x-eopattributedmessage: 0 x-ms-exchange-slblob-mailprops: LtmIgUwM0qRgu7a18JoWELM9szmhVHsD3EF14rrkFiPtQC+gjKyJ1EfWf5MwespRaa9DFaS5UHgkm7DnYY9kCz1TyJsXGIwyvw0G6qStU3SfPiApj0TXaR7cVWoSCDu+jTGWvpVscq9k/VzIY60BjnAhbYxfBuGHZllfIzujgNEEtJys3Iv7jmEn/EpDGF+pFO70nKxDy2PIW23kGgUZ3Nqpbo+yoVMBipojJ1WmQd0P0a2xaqMtynK4+4AVFUZfH1otoVphf7HUHV7pVqK2G5nWJtJnO76GU9SHfLAFOTIdkJ5QsvQ/c0gA5+mhAUAag+v/Jwz+5DBPHvhX8RXrgsz6lfp9Pan8Kcri0HH4NCvBxab0ocsnLfbDx1KghjXmze3rEtVjMVK5UnHZ9whCBqzZqUlCQWW7XGls2mGP/AR5yDtkQcW5wen4Lp/46mdYsluknw6VSF6SjeTmepuMRH4UL3JogyQYEgJu4ANzkhiMZJ5mucB4yf4Xe8sJThofibvmY24RCrxhyaKAvLD3bOZWL4xeTV9qmqRoi5kqFGvxCTkCfX6Fe7vcq6EfctFhaCrPxmJ/e0qh0W8TsQ5tBN7Y6uEixOCL3FKvorcvhzu5tHGlIGj3b1DQva7QF+RcskHHTMiDBCz+6emcR9mt6fIOplujy+F5FkxUq3hCUGBEpW1nT4f6c+TwYK6K0d1EUg/ytHXygSIarMsGD6d3cqhibgsOcfE5kLE59tBGlar32m6yBq9BRlVZ/tzBKq5rWOabCS4BWx4j7HyT3yePGg== x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(5050001)(7020095)(20181119110)(201702061078)(5061506573)(5061507331)(1603103135)(2017031320274)(201702181274)(2017031322404)(2017031323274)(2017031324274)(1601125500)(1603101475)(1701031045);SRVR:HK2APC01HT047; x-ms-traffictypediagnostic: HK2APC01HT047: x-microsoft-antispam-message-info: WlKi5JPdSeJ4guVYVSnb4IUijRmHVeQPUwCQLZwzAp5S10/TL2WZLBQ2WeeWr6mJi3wxO6OTzF4uaYUxpgOG1ANd6kEVDcnwaO6Pls8YrHNpWjyjZKSR4w/ChcwQHUAU4GMMIwXmsDOAXlAX8hEQ7qdiBh1CQTGLoiTetIkoiHDgiFwpwJ8xaxa2dcanfUXJ MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: b73a84f9-8bfb-4185-b3c7-08d6dec229c3 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 22 May 2019 14:31:23.0181 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: HK2APC01HT047 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 Add kernel parameter pci=hpmemprefsize=nn[KMG] to control MMIO_PREF size for PCI hotplug bridges. Change behaviour of pci=hpmemsize=nn[KMG] to not set MMIO_PREF size if hpmempref has been specified, rather than controlling both MMIO and MMIO_PREF sizes unconditionally. Update kernel-parameters documentation to reflect the above changes. The effect of the above changes is to allow for MMIO and MMIO_PREF to be specified independently, whilst ensuring no changes in functionality are noticed by the user if updating kernel version with hpmemsize specified. Signed-off-by: Nicholas Johnson --- .../admin-guide/kernel-parameters.txt | 7 +++++- drivers/pci/pci.c | 18 ++++++++++--- drivers/pci/setup-bus.c | 25 +++++++++++-------- include/linux/pci.h | 3 ++- 4 files changed, 37 insertions(+), 16 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 138f6664b..fdecff06c 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -3439,7 +3439,12 @@ reserved for hotplug bridge's IO window. Default size is 256 bytes. hpmemsize=nn[KMG] The fixed amount of bus space which is - reserved for hotplug bridge's memory window. + reserved for hotplug bridge's MMIO window. If + hpmemprefsize is not specified, then the same + size is applied to hotplug bridge's MMIO_PREF + window. Default size is 2 megabytes. + hpmemprefsize=nn[KMG] The fixed amount of bus space which is + reserved for hotplug bridge's MMIO_PREF window. Default size is 2 megabytes. hpbussize=nn The minimum amount of additional bus numbers reserved for buses below a hotplug bridge. diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 8abc843b1..0e6292009 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -85,10 +85,12 @@ unsigned long pci_cardbus_io_size = DEFAULT_CARDBUS_IO_SIZE; unsigned long pci_cardbus_mem_size = DEFAULT_CARDBUS_MEM_SIZE; #define DEFAULT_HOTPLUG_IO_SIZE (256) -#define DEFAULT_HOTPLUG_MEM_SIZE (2*1024*1024) +#define DEFAULT_HOTPLUG_MMIO_SIZE (2*1024*1024) +#define DEFAULT_HOTPLUG_MMIO_PREF_SIZE (2*1024*1024) /* pci=hpmemsize=nnM,hpiosize=nn can override this */ unsigned long pci_hotplug_io_size = DEFAULT_HOTPLUG_IO_SIZE; -unsigned long pci_hotplug_mem_size = DEFAULT_HOTPLUG_MEM_SIZE; +unsigned long pci_hotplug_mmio_size = DEFAULT_HOTPLUG_MMIO_SIZE; +unsigned long pci_hotplug_mmio_pref_size = DEFAULT_HOTPLUG_MMIO_PREF_SIZE; #define DEFAULT_HOTPLUG_BUS_SIZE 1 unsigned long pci_hotplug_bus_size = DEFAULT_HOTPLUG_BUS_SIZE; @@ -6198,6 +6200,8 @@ EXPORT_SYMBOL(pci_fixup_cardbus); static int __init pci_setup(char *str) { + bool mmio_pref_specified = false; + while (str) { char *k = strchr(str, ','); if (k) @@ -6232,7 +6236,15 @@ static int __init pci_setup(char *str) } else if (!strncmp(str, "hpiosize=", 9)) { pci_hotplug_io_size = memparse(str + 9, &str); } else if (!strncmp(str, "hpmemsize=", 10)) { - pci_hotplug_mem_size = memparse(str + 10, &str); + pci_hotplug_mmio_size = + memparse(str + 10, &str); + if (!mmio_pref_specified) + pci_hotplug_mmio_pref_size = + pci_hotplug_mmio_size; + } else if (!strncmp(str, "hpmemprefsize=", 14)) { + mmio_pref_specified = true; + pci_hotplug_mmio_pref_size = + memparse(str + 14, &str); } else if (!strncmp(str, "hpbussize=", 10)) { pci_hotplug_bus_size = simple_strtoul(str + 10, &str, 0); diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 8e1bc7ee7..44c37dda9 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -1187,7 +1187,8 @@ void __pci_bus_size_bridges(struct pci_bus *bus, struct list_head *realloc_head) { struct pci_dev *dev; unsigned long mask, prefmask, type2 = 0, type3 = 0; - resource_size_t additional_mem_size = 0, additional_io_size = 0; + resource_size_t additional_io_size = 0, additional_mmio_size = 0, + additional_mmio_pref_size = 0; struct resource *b_res; int ret; @@ -1221,7 +1222,8 @@ void __pci_bus_size_bridges(struct pci_bus *bus, struct list_head *realloc_head) pci_bridge_check_ranges(bus); if (bus->self->is_hotplug_bridge) { additional_io_size = pci_hotplug_io_size; - additional_mem_size = pci_hotplug_mem_size; + additional_mmio_size = pci_hotplug_mmio_size; + additional_mmio_pref_size = pci_hotplug_mmio_pref_size; } /* Fall through */ default: @@ -1239,9 +1241,9 @@ void __pci_bus_size_bridges(struct pci_bus *bus, struct list_head *realloc_head) if (b_res[2].flags & IORESOURCE_MEM_64) { prefmask |= IORESOURCE_MEM_64; ret = pbus_size_mem(bus, prefmask, prefmask, - prefmask, prefmask, - realloc_head ? 0 : additional_mem_size, - additional_mem_size, realloc_head); + prefmask, prefmask, + realloc_head ? 0 : additional_mmio_pref_size, + additional_mmio_pref_size, realloc_head); /* * If successful, all non-prefetchable resources @@ -1263,9 +1265,9 @@ void __pci_bus_size_bridges(struct pci_bus *bus, struct list_head *realloc_head) if (!type2) { prefmask &= ~IORESOURCE_MEM_64; ret = pbus_size_mem(bus, prefmask, prefmask, - prefmask, prefmask, - realloc_head ? 0 : additional_mem_size, - additional_mem_size, realloc_head); + prefmask, prefmask, + realloc_head ? 0 : additional_mmio_pref_size, + additional_mmio_pref_size, realloc_head); /* * If successful, only non-prefetchable resources @@ -1274,7 +1276,8 @@ void __pci_bus_size_bridges(struct pci_bus *bus, struct list_head *realloc_head) if (ret == 0) mask = prefmask; else - additional_mem_size += additional_mem_size; + additional_mmio_size += + additional_mmio_pref_size; type2 = type3 = IORESOURCE_MEM; } @@ -1294,8 +1297,8 @@ void __pci_bus_size_bridges(struct pci_bus *bus, struct list_head *realloc_head) * prefetchable resource in a 64-bit prefetchable window. */ pbus_size_mem(bus, mask, IORESOURCE_MEM, type2, type3, - realloc_head ? 0 : additional_mem_size, - additional_mem_size, realloc_head); + realloc_head ? 0 : additional_mmio_size, + additional_mmio_size, realloc_head); break; } } diff --git a/include/linux/pci.h b/include/linux/pci.h index 4a5a84d7b..7015f0b0f 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1972,7 +1972,8 @@ extern u8 pci_dfl_cache_line_size; extern u8 pci_cache_line_size; extern unsigned long pci_hotplug_io_size; -extern unsigned long pci_hotplug_mem_size; +extern unsigned long pci_hotplug_mmio_size; +extern unsigned long pci_hotplug_mmio_pref_size; extern unsigned long pci_hotplug_bus_size; /* Architecture-specific versions may override these (weak) */