From patchwork Wed Jan 15 17:57:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Johnson X-Patchwork-Id: 11335509 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 422CF1398 for ; Wed, 15 Jan 2020 17:57:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 20B49214AF for ; Wed, 15 Jan 2020 17:57:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726587AbgAOR5N convert rfc822-to-8bit (ORCPT ); Wed, 15 Jan 2020 12:57:13 -0500 Received: from mail-oln040092255074.outbound.protection.outlook.com ([40.92.255.74]:7290 "EHLO APC01-HK2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726574AbgAOR5N (ORCPT ); Wed, 15 Jan 2020 12:57:13 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YdHKp7XMaxB0PNvw+F063xvDM2suQAgT0GxS0r2X/yufASQN0L74HWx6fJ57qxZJizXSer5y0j5poUldRreV/FyU9W2Urq6EreUj/FnABGFwaIQ6sjBqUrgz1CbjKsV0sfAqBBHPqyVJp+MwvtRahthp9xbX43wS8p4Txz1Q/wyt8iuR52xU7Cj94lFYRtBjYrHy6Z8iG/KLEKsevTyfTDqagxc1RH0NfzWusGsXHyDJYcXJqj4ED9tlMzmzpWuTd2PaYK7b8UTtXwUY1o4eHZUknkib9k1zIOAthgSKTprlydjxIRDERUx0p3JdW9EeY3SC7ZUqTkiSaR4QBkGCQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=NnxnZTseYNRSorcEdPv6JpSUmglTmlSUs21F/UpBx10=; b=hPpTFjF2y2nK0LtmoMKpWp5DjNCZFwPVvySSanOF4EnqPcSkbPAXWHYuj4MufgUIjAik0q1/2dr7SA3Sb0e0Fj5iHJD4Q1P/fC1KAkYVtb3J7WwG6D2Ua7rTNG6CJPnjgBzhc7NA7OkWNqROO9kxQ4QahBgWqlYFptBkV8k7JTsJg/iYLqlP07NV3DTTA3CUeFLphhOPsvoBuh4BNnNEuljZzoqOtaCbCpe3GiuotPmA3lFRi0LHiCOFf7LBsT4qTSHfsis/97kugt5OxkPxvxDQ3uJC7kReNWvRhORThEWQx18OL6H99Pc81riWJ4d2qTXBgsHhsFO49Ot/pH+BuA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from PU1APC01FT115.eop-APC01.prod.protection.outlook.com (10.152.252.51) by PU1APC01HT173.eop-APC01.prod.protection.outlook.com (10.152.253.186) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2602.11; Wed, 15 Jan 2020 17:57:08 +0000 Received: from PSXP216MB0438.KORP216.PROD.OUTLOOK.COM (10.152.252.57) by PU1APC01FT115.mail.protection.outlook.com (10.152.252.208) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2602.11 via Frontend Transport; Wed, 15 Jan 2020 17:57:08 +0000 Received: from PSXP216MB0438.KORP216.PROD.OUTLOOK.COM ([fe80::20ad:6646:5bcd:63c9]) by PSXP216MB0438.KORP216.PROD.OUTLOOK.COM ([fe80::20ad:6646:5bcd:63c9%11]) with mapi id 15.20.2623.018; Wed, 15 Jan 2020 17:57:08 +0000 Received: from nicholas-dell-linux (61.69.138.108) by ME2PR01CA0092.ausprd01.prod.outlook.com (2603:10c6:201:2d::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2644.20 via Frontend Transport; Wed, 15 Jan 2020 17:57:06 +0000 From: Nicholas Johnson To: "linux-kernel@vger.kernel.org" CC: "linux-pci@vger.kernel.org" , Bjorn Helgaas , Mika Westerberg , Benjamin Herrenschmidt , Logan Gunthorpe , Nicholas Johnson Subject: [PATCH v2 1/4] PCI: In extend_bridge_window() change available to new_size Thread-Topic: [PATCH v2 1/4] PCI: In extend_bridge_window() change available to new_size Thread-Index: AQHVy800b6sbH4fyHEqte7GWmI1Irg== Date: Wed, 15 Jan 2020 17:57:08 +0000 Message-ID: Accept-Language: en-AU, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: ME2PR01CA0092.ausprd01.prod.outlook.com (2603:10c6:201:2d::32) To PSXP216MB0438.KORP216.PROD.OUTLOOK.COM (2603:1096:300:d::20) x-incomingtopheadermarker: OriginalChecksum:19D8AE965C6259C3EF6F392DA44C51ED1D0226EDEAB295E60CF79DF5285D27BA;UpperCasedChecksum:C8529EBF9C6159CA1CB35642E0E155950603E3CF8D6F05EA69383FB954D46DA4;SizeAsReceived:7773;Count:48 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [xaRsmw/bvQv/n80rB9Ht9vX7d1RWx2NG] x-microsoft-original-message-id: <20200115175701.GA4514@nicholas-dell-linux> x-ms-publictraffictype: Email x-incomingheadercount: 48 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: 00efbd71-66ba-4d77-3955-08d799e456e2 x-ms-exchange-slblob-mailprops: mBy7Mai7yE5NBIk4d/kkaYf19Kf5IaBBc+KQ89c3PucBbkKhGIRbQguA6DdcNNtz5kBi/j0D0n/FMQHJCfq+NL7l8PsXM0UmScmkRUOSmWP26ey1ciNn6fImSVG1YTeCmDgFEFlT6P3LzzG4/j1w8EiY+oYAjye2mCYnbm4mARZR1N/tY01vt3+OkI6I93aYv5RUN8huvJP1aIb+WC6z84b+GtDf8gvFsAMf3dtsgnywnoQUD1W2HogwL2VLzj7nHnBs3rE6Gkr00QERjeFStF7Pdx7xdds6Dy9AxBAhgWT+fmqNdFCynM6AH/P0SOQw8zxDJO09V/0b0T3JJqtZfs05OACG3NCerpTzAx36GN6Z+cLCsLAMtpn2C5TJl4yn0z7InsCyEaCMOkj60SgWXk9vSpsWIknFbOz3najA5i3cJ8fhQSzyP3gNOIKxBQ8Iz29mq1HAS0DewJW/bPqsqG8PfihcY9nSnlt9rLV3Aaux6+oQrZeZDbaGBXuWf6oJKHJouOga4/o5Aa+HOxD9n+i4HrSFcB4+em522wnUSTffQx9256DGDvp9kHc8KD/Hvd3GOORF1LT6fMMVe17jc43dLCnIefqDg5JXKd/Ps+qjU00YW+GNcC1yzI3/2A+aQ/6lZup7uquf8zHU7uIezdZk8jHz2kUJtRH8CBYerbk3XMQLiTQ7SYQl/X8pwahiAYovSQYhHYaCZMklRHdINukBwppJTzbL x-ms-traffictypediagnostic: PU1APC01HT173: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: oHkLjS2vSBdOaV5EAWQol0De2Cgmo0CHW1mBfdesy3PKKC8FE0jp7ayfb++NYsbV/Pqc1hQNv1kh4mDn+YnH7e/dymdADiiL1l6t4cW7mJAgVM5yw4l37+lXvIEX7Z1iSPW4Rkr7guoxPditAmz5AkGwqHmqMJ7jwbsMXkbX1BAREpl/vk+gDAza4Juk4khk x-ms-exchange-transport-forked: True Content-ID: <6682A45BBFE5BC41960215529C46F0C7@KORP216.PROD.OUTLOOK.COM> 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: 00efbd71-66ba-4d77-3955-08d799e456e2 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Jan 2020 17:57:08.8632 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: PU1APC01HT173 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org In extend_bridge_window() change "available" parameter name to "new_size". This makes more sense as this parameter represents the new size for the window. Signed-off-by: Nicholas Johnson Reviewed-by: Mika Westerberg --- drivers/pci/setup-bus.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 8b39b9ebb..ed5055ef7 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -1834,14 +1834,14 @@ void __init pci_assign_unassigned_resources(void) static void extend_bridge_window(struct pci_dev *bridge, struct resource *res, struct list_head *add_list, - resource_size_t available) + resource_size_t new_size) { struct pci_dev_resource *dev_res; if (res->parent) return; - if (resource_size(res) >= available) + if (resource_size(res) >= new_size) return; dev_res = res_to_dev_res(add_list, res); @@ -1849,10 +1849,10 @@ static void extend_bridge_window(struct pci_dev *bridge, struct resource *res, return; /* Is there room to extend the window? */ - if (available - resource_size(res) <= dev_res->add_size) + if (new_size - resource_size(res) <= dev_res->add_size) return; - dev_res->add_size = available - resource_size(res); + dev_res->add_size = new_size - resource_size(res); pci_dbg(bridge, "bridge window %pR extended by %pa\n", res, &dev_res->add_size); } From patchwork Wed Jan 15 17:57:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Johnson X-Patchwork-Id: 11335511 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9ABED138D for ; Wed, 15 Jan 2020 17:57:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7877D2077B for ; Wed, 15 Jan 2020 17:57:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728928AbgAOR5c convert rfc822-to-8bit (ORCPT ); Wed, 15 Jan 2020 12:57:32 -0500 Received: from mail-oln040092254067.outbound.protection.outlook.com ([40.92.254.67]:19728 "EHLO APC01-PU1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726574AbgAOR5c (ORCPT ); Wed, 15 Jan 2020 12:57:32 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oezkU968Xj9Z4i+cy6tWEMWFtD295kb4fK6QRSEfgzyHvpe8p4lr+Tnoyj6mP5+r4C1neXUo04YQCaLE9e3w1uUQUR+wRG6+6STxvR7cqxn3YrWIBWZK6iEkSWkfZz4VbicRyyXCAusd/oJHenfW+5ikjbnLjf1IiUKI7H0fA/5ZyF78lGpIqniZIh9HTzlJ+1xr6oZLLe27ljjQtjmLtAkMnvr6Tzus6eNXs52Y04YoPZxUP+9Q+bdnc+RS5ZmFrFErgLkORTL6zHNE9jRPAeTMdsRB/50bKR9atZ9fMvt3HLn8Mkw09SWdlAvrQ9TzvBEqK/dPQBjBaLmh5OUJWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jk8iequVcjwgf3IHaHX3qvYpYUKdqFIydC16GtDRZ/8=; b=U2OG1OH9gIUIXGfZqmoRO/NWRV/Lfx3wEtTJQDrlj26UCAzQc1+tpLuyoA0Mn/v9N1gATmuTlOeJ26C/SBIl6W08BDmbHWRyD5n46An2s55BY/DdOrS7QYZDdTg50aGgqZu4cqRGwXlkUYhMTJfS35lgJQHeJ7hiTcp7a1m7wVcBGMiJss66XDX2uQ9NUhID9cMNhBXp3J0SwQA529iZgfmMZIPOe+PBnaw/vrubvtUxHuCUDIySMUJwH+wmjuqlnYkZFW3wM6fFhmbPmkwrlhvZKxZ4lw5s9Q8qNcwKVoghoqCnYmpr1qasNrxSjOcnvKvuRESCA5d4OjHfdUj2zQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from PU1APC01FT115.eop-APC01.prod.protection.outlook.com (10.152.252.58) by PU1APC01HT147.eop-APC01.prod.protection.outlook.com (10.152.252.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2602.11; Wed, 15 Jan 2020 17:57:28 +0000 Received: from PSXP216MB0438.KORP216.PROD.OUTLOOK.COM (10.152.252.57) by PU1APC01FT115.mail.protection.outlook.com (10.152.252.208) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2602.11 via Frontend Transport; Wed, 15 Jan 2020 17:57:28 +0000 Received: from PSXP216MB0438.KORP216.PROD.OUTLOOK.COM ([fe80::20ad:6646:5bcd:63c9]) by PSXP216MB0438.KORP216.PROD.OUTLOOK.COM ([fe80::20ad:6646:5bcd:63c9%11]) with mapi id 15.20.2623.018; Wed, 15 Jan 2020 17:57:28 +0000 Received: from nicholas-dell-linux (61.69.138.108) by ME2PR01CA0078.ausprd01.prod.outlook.com (2603:10c6:201:2d::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2644.18 via Frontend Transport; Wed, 15 Jan 2020 17:57:26 +0000 From: Nicholas Johnson To: "linux-kernel@vger.kernel.org" CC: "linux-pci@vger.kernel.org" , Bjorn Helgaas , Mika Westerberg , Benjamin Herrenschmidt , Logan Gunthorpe , Nicholas Johnson Subject: [PATCH v2 2/4] PCI: Rename extend_bridge_window() to adjust_bridge_window() Thread-Topic: [PATCH v2 2/4] PCI: Rename extend_bridge_window() to adjust_bridge_window() Thread-Index: AQHVy81AmdiPe5xhakqgfeJglwMu5A== Date: Wed, 15 Jan 2020 17:57:28 +0000 Message-ID: Accept-Language: en-AU, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: ME2PR01CA0078.ausprd01.prod.outlook.com (2603:10c6:201:2d::18) To PSXP216MB0438.KORP216.PROD.OUTLOOK.COM (2603:1096:300:d::20) x-incomingtopheadermarker: OriginalChecksum:DB4AA6AA804CD425C6F9B34934239CA01C47A7474E9627C457D9A799850E8E56;UpperCasedChecksum:048863291DD1A2EE09D935D23EE459C756E6157EB1AA943B3394C6EC696225F9;SizeAsReceived:7785;Count:48 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [lTpnRkEmm9kjBDzZdJqQo3MGMwOKkt+r] x-microsoft-original-message-id: <20200115175721.GA4519@nicholas-dell-linux> x-ms-publictraffictype: Email x-incomingheadercount: 48 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: f516d5c0-338c-497f-8f28-08d799e462a5 x-ms-exchange-slblob-mailprops: mBy7Mai7yE5NBIk4d/kkaYf19Kf5IaBBdgtO/F9AM/6n7rQwsnH13OQa3Beer+3kRezTDPhhxyCjb2vg3hpZJErDV2eFFg/Tn6eXsP5JQ79rep0aLb6wC8b7jLpmvxbcabg05crLEJCBLvJfWyIoVIoX0BDYXUbx0GHSW+n8+LEDUUOdM2EHVcwKUDsG9B1QzcKsmItpaKDiwXoE7rkC3aJJ+VKumjIemZKtRyEXHR1QVmBp7RQIlPlhKVVPQY17EvIuKT8xtSGjyQUrBD2VzDoUpmvlxqhaI2rzIqkbG1lQfUCXahL9lChFr911yC3VtYRtV+hPQkRxRorYXYwoRHMHEoS2Eg2ub252ZEOanXrycLcNsND5NJp7ggB8jxUL2q2GAfbs3L6YSfUHP63xbiFuLdjy8yNmAF0OcC1fUtU5LcmrmbyUQy1VVOHYIRf7h6QoKnmeQxUd0X/+JBvHUwo/fFOqI2vSZWzmJKH/M2/GoKDGIOKRwmLTI4aXNJgikWqKDPiObBSEs5LuuU4hjFpbz63qLxSOIVzOnSn8pUAueqMh3qS+ClkMy0XeYPieda/8cA+emP5w0nqrPs/04UKRVwl77J12ak02/F5UQgyZnUwgajh0A99S9qnSPwzvC/3DAN4/jR8era52+xpIYutxqxge7cchfmKcn5lhLYlZ09Z8a7GBb2N67JvfOK5w3/b2RrpmrZm94lCJRR16SANOXgHAlLdU x-ms-traffictypediagnostic: PU1APC01HT147: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: cuyQpbgFSvS+Tmh0XTByn9zTyaqvWbr4T9C9uZO/DdpbGW6+7TkPvnf9WObnA/u+9PUsEysvGdz6IPoQmUkhKjLh01g5nQqX4VCG6gS06DMlHUy9XesPRoEHLaaVV6MRR1R6uv8ggbfmbcV1tx2KgjbAidAX3SrUppk1KNn4DF5/DOm3fb7uOHgm8TSVObJg x-ms-exchange-transport-forked: True Content-ID: <53B6607E615FEA49B08376CD06612EEC@KORP216.PROD.OUTLOOK.COM> 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: f516d5c0-338c-497f-8f28-08d799e462a5 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Jan 2020 17:57:28.5693 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: PU1APC01HT147 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Rename extend_bridge_window() to adjust_bridge_window() to prepare for the fact that the window will be able to shrink. No functional changes. Signed-off-by: Nicholas Johnson Reviewed-by: Mika Westerberg --- drivers/pci/setup-bus.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index ed5055ef7..de43815be 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -1832,7 +1832,7 @@ void __init pci_assign_unassigned_resources(void) } } -static void extend_bridge_window(struct pci_dev *bridge, struct resource *res, +static void adjust_bridge_window(struct pci_dev *bridge, struct resource *res, struct list_head *add_list, resource_size_t new_size) { @@ -1895,9 +1895,9 @@ static void pci_bus_distribute_available_resources(struct pci_bus *bus, * calculated in __pci_bus_size_bridges() which covers all the * devices currently connected to the port and below. */ - extend_bridge_window(bridge, io_res, add_list, resource_size(&io)); - extend_bridge_window(bridge, mmio_res, add_list, resource_size(&mmio)); - extend_bridge_window(bridge, mmio_pref_res, add_list, + adjust_bridge_window(bridge, io_res, add_list, resource_size(&io)); + adjust_bridge_window(bridge, mmio_res, add_list, resource_size(&mmio)); + adjust_bridge_window(bridge, mmio_pref_res, add_list, resource_size(&mmio_pref)); /* From patchwork Wed Jan 15 17:57:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Johnson X-Patchwork-Id: 11335513 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C9BFB1398 for ; Wed, 15 Jan 2020 17:57:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A6C6A2077B for ; Wed, 15 Jan 2020 17:57:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729163AbgAOR5w convert rfc822-to-8bit (ORCPT ); Wed, 15 Jan 2020 12:57:52 -0500 Received: from mail-oln040092254070.outbound.protection.outlook.com ([40.92.254.70]:6186 "EHLO APC01-PU1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726574AbgAOR5v (ORCPT ); Wed, 15 Jan 2020 12:57:51 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NOHZBmw5KcLQRbBe3gy7iGjNgEhd9QJjJGh57ibBjgUqNFWPckhha0wWmhF3Ovt8XU9lwkHvKyYFSFJKENhscjbga92QB9exf1/ej53gJcbKTsuKtgZzUFh1cHOuYzGaj5tAzFgDqBhMJUoZMQtb63nTlo0k0LF+/0n614vn6OWWvVpvcEWgcLrkCi50HZqn1Uinzi6c+xTIHfPRiABTgOlvFwIgOdd92a8XY/E7LXYdkhI46jQKYdc2YzuWdz8e614x5tAhhfQ17W3OqaWiBbbHMIkcETeP15lgYEQ/O+1v9vEsq2nYtMzCpFpZJ8ruUgmXUgNUNXsybA4BgVS46w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SjJMCK5zDEwZvpHPtIKuV2lBmosv6lmDGSUAJ7ANHMQ=; b=gVRj3Q1eoFo0ncvQx22NYQw1WKOVeIAuUf+l8zQqZVFQgFmGaDbFE5Vq+3WsC/l5RG2vDV9TQ2wOhpQAaHcHgudq9DIeAXTt1qsp3JeaV45mV0epWNATLWLXMu+mAQyIquxE92VOEPDGRR3ei/dCgx146yAsmQKPDlmvLNrHAldjhiZ8DAipzJR5Oxf/5GrPn6KOsLHeUYBcRfapGaTH93cm0dIQyuxHzrVLpkOHQVcAjXnA7vsqQOL9A4jviVvLW0FtPkdo5Gt5uiEIIO8nP7PTZh3VtWuV9pSWzoV8VwLB/NWPGIuVpelDH1DJpZCWSXT6+HNUP8O2AiX/eNgjrA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from PU1APC01FT115.eop-APC01.prod.protection.outlook.com (10.152.252.59) by PU1APC01HT237.eop-APC01.prod.protection.outlook.com (10.152.253.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2602.11; Wed, 15 Jan 2020 17:57:47 +0000 Received: from PSXP216MB0438.KORP216.PROD.OUTLOOK.COM (10.152.252.57) by PU1APC01FT115.mail.protection.outlook.com (10.152.252.208) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2602.11 via Frontend Transport; Wed, 15 Jan 2020 17:57:47 +0000 Received: from PSXP216MB0438.KORP216.PROD.OUTLOOK.COM ([fe80::20ad:6646:5bcd:63c9]) by PSXP216MB0438.KORP216.PROD.OUTLOOK.COM ([fe80::20ad:6646:5bcd:63c9%11]) with mapi id 15.20.2623.018; Wed, 15 Jan 2020 17:57:47 +0000 Received: from nicholas-dell-linux (61.69.138.108) by ME2PR01CA0010.ausprd01.prod.outlook.com (2603:10c6:201:15::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2644.19 via Frontend Transport; Wed, 15 Jan 2020 17:57:45 +0000 From: Nicholas Johnson To: "linux-kernel@vger.kernel.org" CC: "linux-pci@vger.kernel.org" , Bjorn Helgaas , Mika Westerberg , Benjamin Herrenschmidt , Logan Gunthorpe , Nicholas Johnson Subject: [PATCH v2 3/4] PCI: Change extend_bridge_window() to set resource size directly Thread-Topic: [PATCH v2 3/4] PCI: Change extend_bridge_window() to set resource size directly Thread-Index: AQHVy81LGw6FLCbpeUmB0IsDxRkf/Q== Date: Wed, 15 Jan 2020 17:57:47 +0000 Message-ID: Accept-Language: en-AU, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: ME2PR01CA0010.ausprd01.prod.outlook.com (2603:10c6:201:15::22) To PSXP216MB0438.KORP216.PROD.OUTLOOK.COM (2603:1096:300:d::20) x-incomingtopheadermarker: OriginalChecksum:108CAED3704C9038B08BF6ADA1E99581A814D7149148976F0B4C02554A5593A4;UpperCasedChecksum:E280B6263045668F4894F8623CAC32A48C65CDCA29F317399441FB05CBBB6CDC;SizeAsReceived:7808;Count:48 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [5ziGKHdJgjerydAC4PVE9gud1jqcSCvu] x-microsoft-original-message-id: <20200115175739.GA4523@nicholas-dell-linux> x-ms-publictraffictype: Email x-incomingheadercount: 48 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: 9e9c392e-8ba4-447a-22a3-08d799e46dec x-ms-exchange-slblob-mailprops: mBy7Mai7yE5NBIk4d/kkaYf19Kf5IaBBWDTNUgNopOB7xn1ElHWtuVPWnZEztijD/yOPxzm9qLEqMfoL51u+V0pB76zx0oc0wAfxKbI0eMq91g5RhSvL5r6RfHacK+EsTNF3k/5vvjcGgxkGU1LgIv5gIB8Gs5V4JGI2K18oDxVmh9ZYPAZ6+chS7kyku6Ul1pa0XLLM9j7UmbTXhWRyWHh7amncHb+jvjJ159j+CG7QIAemtZFZm+XQRronXpGk2Up7gZwlNsPjM6jqK2JUlzZLzrAVk6w8+SVBcyCLTwrPY/FmfD9k04Li+15syAcKa/x//dyxM3x05rn5PI736eHy3Wna+1XrwMT4jhIkN4awzsUZGpYf6GNoI8Saa0P1dBkj7NZf7s1+HVjedcbh6Y/fm6QkhzFDqfMmcKDhrADPImen6T9yMrzsytSsuzeFDDHZj/nq2w4d7IMeLDo5uFNQmkFUfvzKjqZRDHHFSZTwvPtX1OEhZEEvq09VlKmunCTGutecCBQsK4adRzio1rrzEHwvTUdEG6XRphGMbMH45YrNVJS9JYcJZZcJ+6Q0D2n4kpv6CFuTIf7/3XRVxxRw3ih1DHIEecVsRQr+eLwUjtuIpXfvVhpest7qUhxFEerdQFv4eNYg/Jl9PNrEPg8V3UqJXcwGEX4ZvB9ZavtFCIoZmnbjH7aL/H2axTKV4N8EGADgMlE5RTAOeBATEl6a9abZMw88 x-ms-traffictypediagnostic: PU1APC01HT237: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: NBuyq9gDb7YB8Dg34p6fT3YdrxLuvpfGaxXo40tFLS4fYz9o6Sg09xx4gBeTmNyqptygbqUSIwTBXoF5MJnY8wy3Bk3n/svjYuJ3qPQ5Wkc3tAoEShu9q1EgFpc74O0R6svJuQdoYI06Zf61PEMGD2cK0HH/vLjqTbnQKsMPQxAFsv2QBE4z8maT6NsKmyYh x-ms-exchange-transport-forked: True Content-ID: 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: 9e9c392e-8ba4-447a-22a3-08d799e46dec X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Jan 2020 17:57:47.5438 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: PU1APC01HT237 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Change extend_bridge_window() to set resource size directly instead of using additional resource lists. This is required in preparation for the next patch [0] which will allow the resource to shrink. If we do not make this change, the next patch will need to have complicated logic to handle shrinking the overall size using size and add_size. Remove the resource from add_list, as a zero-sized additional resource is redundant. Update comment in pci_bus_distribute_available_resources() to reflect the above changes. [0] PCI: Allow extend_bridge_window() to shrink resource if necessary Signed-off-by: Nicholas Johnson Reviewed-by: Mika Westerberg --- drivers/pci/setup-bus.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index de43815be..50d14921a 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -1836,7 +1836,7 @@ static void adjust_bridge_window(struct pci_dev *bridge, struct resource *res, struct list_head *add_list, resource_size_t new_size) { - struct pci_dev_resource *dev_res; + resource_size_t add_size; if (res->parent) return; @@ -1844,17 +1844,10 @@ static void adjust_bridge_window(struct pci_dev *bridge, struct resource *res, if (resource_size(res) >= new_size) return; - dev_res = res_to_dev_res(add_list, res); - if (!dev_res) - return; - - /* Is there room to extend the window? */ - if (new_size - resource_size(res) <= dev_res->add_size) - return; - - dev_res->add_size = new_size - resource_size(res); - pci_dbg(bridge, "bridge window %pR extended by %pa\n", res, - &dev_res->add_size); + add_size = new_size - resource_size(res); + pci_dbg(bridge, "bridge window %pR extended by %pa\n", res, &add_size); + res->end = res->start + new_size - 1; + remove_from_list(add_list, res); } static void pci_bus_distribute_available_resources(struct pci_bus *bus, @@ -1890,10 +1883,8 @@ static void pci_bus_distribute_available_resources(struct pci_bus *bus, mmio_pref.end + 1); /* - * Update additional resource list (add_list) to fill all the - * extra resource space available for this port except the space - * calculated in __pci_bus_size_bridges() which covers all the - * devices currently connected to the port and below. + * Now that we have adjusted for alignment, update the bridge window + * resources to fill as much remaining resource space as possible. */ adjust_bridge_window(bridge, io_res, add_list, resource_size(&io)); adjust_bridge_window(bridge, mmio_res, add_list, resource_size(&mmio)); From patchwork Wed Jan 15 17:58:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Johnson X-Patchwork-Id: 11335515 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CC517109A for ; Wed, 15 Jan 2020 17:58:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A85EB214AF for ; Wed, 15 Jan 2020 17:58:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729074AbgAOR6L convert rfc822-to-8bit (ORCPT ); Wed, 15 Jan 2020 12:58:11 -0500 Received: from mail-oln040092255042.outbound.protection.outlook.com ([40.92.255.42]:42240 "EHLO APC01-HK2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726574AbgAOR6K (ORCPT ); Wed, 15 Jan 2020 12:58:10 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B9T+DB4Ni3F5mrwJp9i4VKTEe81i5pHMMML3TwAooJOQIanBmSeGg77hG9NBnH9Ai5kFpTkERFme/P/8PPmHeTyjSj0yw5m+eZv1NrIbJbrooQqoADhfqB8xxdM1PY+gaqEUwsewiIfsXW2sDe5trlX71jpZJ80r7f5QtyeWt1ekYJgXBLa5iCbn4SoBa9qyf2boYZMFSncBzzENo+hwll8HBhgRxeVf7Ybu3MKj+lNwjifBT6iOvltwPnjENQovmA+cB4w8E906V6BVy23QJogIH1qpH3Upl/nJg9ehfN/H5b2QxQgegAPXgQFUfVBO8IE6YsTIauUHsW7hnj9Ycw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jTZHIDttUSLS5LHeRxgppXH/XS/ZolcfcQDNSghrvKM=; b=gZ2bmNfh4grBQ5F+xpPoSMN31TuFgz01+f036ueiCu5pE4BNC7Fl2x1EljSbKz9qiCgNOpRrRT+xLJRZy+UmN4MuNhYyuiTtJ3UtEWACGeOK2TYAcRadEXeEvBXsCQQqa+OSK5Y3uNJYy8ssjOMh75eKiiont6o/g2bjllxc7TU2TI85cAjcYMhNu6qSqLbI8U00YyYWy6fcObSpvdoFR5zCYJggjG4GnQWvnaryPz0Vy+9SN9BjJayTfF3R7fBqW9Zpj7hV7Yd115BJ4jLUlJnAd4/tqHHlx1X5t0KmUV+dGfCENpwXTlefV4fqEqeEmo1eiuqz77qth0YEOYc7Pw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from PU1APC01FT115.eop-APC01.prod.protection.outlook.com (10.152.252.53) by PU1APC01HT223.eop-APC01.prod.protection.outlook.com (10.152.252.192) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2602.11; Wed, 15 Jan 2020 17:58:05 +0000 Received: from PSXP216MB0438.KORP216.PROD.OUTLOOK.COM (10.152.252.57) by PU1APC01FT115.mail.protection.outlook.com (10.152.252.208) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2602.11 via Frontend Transport; Wed, 15 Jan 2020 17:58:05 +0000 Received: from PSXP216MB0438.KORP216.PROD.OUTLOOK.COM ([fe80::20ad:6646:5bcd:63c9]) by PSXP216MB0438.KORP216.PROD.OUTLOOK.COM ([fe80::20ad:6646:5bcd:63c9%11]) with mapi id 15.20.2623.018; Wed, 15 Jan 2020 17:58:05 +0000 Received: from nicholas-dell-linux (61.69.138.108) by MEXPR01CA0139.ausprd01.prod.outlook.com (2603:10c6:200:2e::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2644.19 via Frontend Transport; Wed, 15 Jan 2020 17:58:03 +0000 From: Nicholas Johnson To: "linux-kernel@vger.kernel.org" CC: "linux-pci@vger.kernel.org" , Bjorn Helgaas , Mika Westerberg , Benjamin Herrenschmidt , Logan Gunthorpe , Nicholas Johnson Subject: [PATCH v2 4/4] PCI: Allow extend_bridge_window() to shrink resource if necessary Thread-Topic: [PATCH v2 4/4] PCI: Allow extend_bridge_window() to shrink resource if necessary Thread-Index: AQHVy81WZ0aY/Rpcq0KYMVH4glqmEQ== Date: Wed, 15 Jan 2020 17:58:05 +0000 Message-ID: Accept-Language: en-AU, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: MEXPR01CA0139.ausprd01.prod.outlook.com (2603:10c6:200:2e::24) To PSXP216MB0438.KORP216.PROD.OUTLOOK.COM (2603:1096:300:d::20) x-incomingtopheadermarker: OriginalChecksum:756F20CC4212D69BCB7AD88E73210CA08FC6953FE0F7CBC6D12E48230490FBCF;UpperCasedChecksum:9DBBA6096AE45A3C91CADFCAF97D76357282033536A95D1D4FC692A21538CDD2;SizeAsReceived:7794;Count:48 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [isfTshrZaUMoGiqt2tK+qf8qWlR7JcNC] x-microsoft-original-message-id: <20200115175758.GA4526@nicholas-dell-linux> x-ms-publictraffictype: Email x-incomingheadercount: 48 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: 9c1637dd-0271-414f-f24a-08d799e478d9 x-ms-exchange-slblob-mailprops: mBy7Mai7yE5NBIk4d/kkaYf19Kf5IaBBWDTNUgNopOAkOjQJjzlAjhv6afDIGsMI3TDXoosU/8nWIBIPe1ZYGNAM7EcMeQCVqcmqMloMKCdjHs9VrT0Ktz4vw13u2mB685eDdd2Y2tNvjnuaKUuRHqPwDNV5mvWELo2qBgUHMZNcV7QYRXoA/fRRx38e7+fiCzncrre5jjGOmF1cUBfxtmVHr2q16TKzVV0T1yUhgdFQxsstmYi6/oLu+DprnIRW2Q5HBUmcJHBjjhqOw6q1HdxNe6gO3jheS2HxtSH7AtVehNpEX96cQcDGZVmOfLDVtUZqnQDfGH38ZYKFWbLe8tC3mjNtKL0U/DXqUdDxJ5dtOd05BBapRspXADbFnu1bqvhr61Uznv38HvWNOQxM74KMC3S9HcEPAhHr/jcE564T0ZijzQhWiLsu/RfdVkmS6L+hpWWITVsHPqd//dFQwJe/7dKY14JWbNt7fERqcP+2Vuy0xo+bPlceqYFht6pPdzrZflv2sox52a3mvEbV8LxKrMbb6Bd65Uh0q7l4tPMytJVBIs07JSK6wukcCMhUBjR2nvR8GiPs6E1QoUm6orKjxJzEtGxZgWT7NVLzRsS/zPr3sLiZwqRusl7vata/dZV1ZeScO18PpH4JVPHdco5+Rwa4raP+A6tDdQWpxjV5/vMf2eD54DS6lNK2M3oYm15a9QoRLu8jMvzgOtk0aA1ddl5JfC6g x-ms-traffictypediagnostic: PU1APC01HT223: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: zSVERXP9nG5xbFo4f7IvalaEt5KZ/NelxKhFjoI4VwYu6OInlJChAuraikNUUHGvYlA4OHPL7VlRgze9m2vfzntFrOOchK1fRTQYbYKQUfFOu/OPA5ljnS8iCUNA0IARVnm4ojEC6rQAoBqvgCg15G9Xyk/QxeG5PRFKkFXgwO0rPA3Lj+kjHDHm4x+arcFC x-ms-exchange-transport-forked: True Content-ID: 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: 9c1637dd-0271-414f-f24a-08d799e478d9 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Jan 2020 17:58:05.8345 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: PU1APC01HT223 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Remove checks for resource size in extend_bridge_window(). This is necessary to allow the pci_bus_distribute_available_resources() to function when the kernel parameter pci=hpmemsize=nn[KMG] is used to allocate resources. Because the kernel parameter sets the size of all hotplug bridges to be the same, there are problems when nested hotplug bridges are encountered. Fitting a downstream hotplug bridge with size X and normal bridges with non-zero size Y into parent hotplug bridge with size X is impossible, and hence the downstream hotplug bridge needs to shrink to fit into its parent. Add check for if bridge is extended or shrunken and reflect that in the call to pci_dbg(). Do not change resource size if new size is zero (if we have run out of a bridge window resource) to prevent the PCI resource assignment code from attempting to assign a zero-sized resource. If this happens, we are running out of resource space, anyway, so not shrinking the resource will not deny space for other resources. This prevents the following from happening: pcieport 0000:07:04.0: can't enable device: BAR 13 [io 0x1000-0x0fff] not claimed Signed-off-by: Nicholas Johnson Reviewed-by: Mika Westerberg --- drivers/pci/setup-bus.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 50d14921a..074501a75 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -1836,16 +1836,24 @@ static void adjust_bridge_window(struct pci_dev *bridge, struct resource *res, struct list_head *add_list, resource_size_t new_size) { - resource_size_t add_size; + resource_size_t add_size, size = resource_size(res); if (res->parent) return; - if (resource_size(res) >= new_size) + if (!new_size) return; - add_size = new_size - resource_size(res); - pci_dbg(bridge, "bridge window %pR extended by %pa\n", res, &add_size); + if (new_size > size) { + add_size = new_size - size; + pci_dbg(bridge, "bridge window %pR extended by %pa\n", res, + &add_size); + } else if (new_size < size) { + add_size = size - new_size; + pci_dbg(bridge, "bridge window %pR shrunken by %pa\n", res, + &add_size); + } + res->end = res->start + new_size - 1; remove_from_list(add_list, res); }