Received: by 2002:a4a:311b:0:0:0:0:0 with SMTP id k27-v6csp4692955ooa; Tue, 14 Aug 2018 09:15:46 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxXWNIGQI2d0rbN/I7eTJ9EmDnMPczrecDATDTjm2mz3kryiUbH69GSHWNmhnvQgzhjcsDP X-Received: by 2002:a63:1d3:: with SMTP id 202-v6mr21635293pgb.136.1534263346190; Tue, 14 Aug 2018 09:15:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534263346; cv=none; d=google.com; s=arc-20160816; b=UEFAXcRdZYuzOyweIUlQlv4ebU3qOocfPEMPLdn43JlibxQsjxRPB5hnRjJfWEROJx BIAvLll0F7bBeLmeQcyXqHGCJ3Zj8/YgZ7V4F83LWK4slwG32Xw6i3+H8rkVTbulqbw9 10iIpeRGC+n4ohgnXLNjHdEffWRQ60s+5lPuAIpdIGzr5+CiV+4c9lQiEO5BxvNEp8w0 zG1Asbb0XgLD/XvjC3fUvTc7YuTOxV5C93hAtjAicZPZXhydXKzXt09B5S6i7ueXWNpY F421yokFS02yElTH8xjXvStN13NQ3Zxyri/kzaey6wVaJwoAPxICYzKz1aLgsMObN+Xb IPNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:arc-authentication-results; bh=K9hEfki1KbkbsKMMM43Awi3az89vGhgJxOM9lN0k0lE=; b=nmnuPkEcRCGZepkjdd7LkEkIZb/T/wULf0K7Hcn0Nra5YwHmhPHO01LiHTDKCxOHrJ LUJjNSeC+GMegEmVHYj4d/nvK4jxB9Ltw+wj4KrKpFGR+S5Tu/e70zQiysCTBODeEuxQ DZzzjwOa47OhQj1ROjEsqx/5ygKmEwREtSFCd7WMvxgSOlAXE/bj9DREYhz2T/7DUkha bpTTXjc10eqxvEyF7J2XwJgvdcxHpe8ifsDA2uT7tKBJQegf3zfZUgh0v0QFq6gvpw1F NEAu25e57PDnD4AqfgQ6qi5e5tEvfZ/QVbXyfQgcNaR/X+AAGX/CO2uSKoU88WxXyN1L cHvQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b7-v6si23412483pfj.245.2018.08.14.09.15.30; Tue, 14 Aug 2018 09:15:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732771AbeHNTAk (ORCPT + 99 others); Tue, 14 Aug 2018 15:00:40 -0400 Received: from mga02.intel.com ([134.134.136.20]:41520 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731841AbeHNTAj (ORCPT ); Tue, 14 Aug 2018 15:00:39 -0400 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Aug 2018 09:12:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,238,1531810800"; d="p7s'?scan'208";a="224591667" Received: from orsmsx106.amr.corp.intel.com ([10.22.225.133]) by orsmga004.jf.intel.com with ESMTP; 14 Aug 2018 09:12:52 -0700 Received: from orsmsx112.amr.corp.intel.com (10.22.240.13) by ORSMSX106.amr.corp.intel.com (10.22.225.133) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 14 Aug 2018 09:12:51 -0700 Received: from orsmsx101.amr.corp.intel.com ([169.254.8.46]) by ORSMSX112.amr.corp.intel.com ([169.254.3.2]) with mapi id 14.03.0319.002; Tue, 14 Aug 2018 09:12:51 -0700 From: "Derrick, Jonathan" To: "helgaas@kernel.org" CC: "linux-kernel@vger.kernel.org" , "lorenzo.pieralisi@arm.com" , "okaya@codeaurora.org" , "sbates@raithlin.com" , "logang@deltatee.com" , "mika.westerberg@linux.intel.com" , "gregkh@linuxfoundation.org" , "linux-pci@vger.kernel.org" , "Busch, Keith" Subject: Re: [PATCH] PCI: Equalize hotplug memory for non/occupied slots Thread-Topic: [PATCH] PCI: Equalize hotplug memory for non/occupied slots Thread-Index: AQHUJGwISo4RbMWkQEqcaJwsAsbgs6S//8qA Date: Tue, 14 Aug 2018 16:12:50 +0000 Message-ID: <1534263169.4361.1.camel@intel.com> References: <1532559779-3542-1-git-send-email-jonathan.derrick@intel.com> In-Reply-To: <1532559779-3542-1-git-send-email-jonathan.derrick@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: x-originating-ip: [10.255.0.101] Content-Type: multipart/signed; micalg=sha-1; protocol="application/x-pkcs7-signature"; boundary="=-EWgyLFeAbv/TF08WK4WF" MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-EWgyLFeAbv/TF08WK4WF Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable It's been a few weeks. Thoughts on this one? On Wed, 2018-07-25 at 17:02 -0600, Jon Derrick wrote: > Currently, a hotplug bridge will be given hpmemsize additional memory > if > available, in order to satisfy any future hotplug allocation > requirements. >=20 > These calculations don't consider the current memory size of the > hotplug > bridge/slot, so hotplug bridges/slots which have downstream devices > will > get their current allocation in addition to the hpmemsize value. >=20 > This makes for possibly undesirable results with a mix of unoccupied > and > occupied slots (ex, with hpmemsize=3D2M): >=20 > 02:03.0 PCI bridge: <-- Occupied > Memory behind bridge: d6200000-d64fffff [size=3D3M] > 02:04.0 PCI bridge: <-- Unoccupied > Memory behind bridge: d6500000-d66fffff [size=3D2M] >=20 > This change considers the current allocation size when using the > hpmemsize parameter to make the reservations predictable for the mix > of > unoccupied and occupied slots: >=20 > 02:03.0 PCI bridge: <-- Occupied > Memory behind bridge: d6200000-d63fffff [size=3D2M] > 02:04.0 PCI bridge: <-- Unoccupied > Memory behind bridge: d6400000-d65fffff [size=3D2M] >=20 > Signed-off-by: Jon Derrick > --- > Original RFC here: > https://patchwork.ozlabs.org/patch/945374/ >=20 > I split this bit out from the RFC while awaiting the pci string > handling > enhancements to handle per-device settings >=20 > Changed from RFC is a simpler algo >=20 > drivers/pci/setup-bus.c | 13 ++++++------- > 1 file changed, 6 insertions(+), 7 deletions(-) >=20 > diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c > index 79b1824..5ae39e6 100644 > --- a/drivers/pci/setup-bus.c > +++ b/drivers/pci/setup-bus.c > @@ -831,7 +831,8 @@ static resource_size_t > calculate_iosize(resource_size_t size, > =20 > static resource_size_t calculate_memsize(resource_size_t size, > resource_size_t min_size, > - resource_size_t size1, > + resource_size_t add_size, > + resource_size_t children_add_size, > resource_size_t old_size, > resource_size_t align) > { > @@ -841,7 +842,7 @@ static resource_size_t > calculate_memsize(resource_size_t size, > old_size =3D 0; > if (size < old_size) > size =3D old_size; > - size =3D ALIGN(size + size1, align); > + size =3D ALIGN(max(size, add_size) + children_add_size, > align); > return size; > } > =20 > @@ -1079,12 +1080,10 @@ static int pbus_size_mem(struct pci_bus *bus, > unsigned long mask, > =20 > min_align =3D calculate_mem_align(aligns, max_order); > min_align =3D max(min_align, window_alignment(bus, b_res- > >flags)); > - size0 =3D calculate_memsize(size, min_size, 0, > resource_size(b_res), min_align); > + size0 =3D calculate_memsize(size, min_size, 0, 0, > resource_size(b_res), min_align); > add_align =3D max(min_align, add_align); > - if (children_add_size > add_size) > - add_size =3D children_add_size; > - size1 =3D (!realloc_head || (realloc_head && !add_size)) ? > size0 : > - calculate_memsize(size, min_size, add_size, > + size1 =3D (!realloc_head || (realloc_head && !add_size && > !children_add_size)) ? size0 : > + calculate_memsize(size, min_size, add_size, > children_add_size, > resource_size(b_res), add_align); > if (!size0 && !size1) { > if (b_res->start || b_res->end) --=-EWgyLFeAbv/TF08WK4WF Content-Type: application/x-pkcs7-signature; name="smime.p7s" Content-Disposition: attachment; filename="smime.p7s" Content-Transfer-Encoding: base64 MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIKeTCCBOsw ggPToAMCAQICEFLpAsoR6ESdlGU4L6MaMLswDQYJKoZIhvcNAQEFBQAwbzELMAkGA1UEBhMCU0Ux FDASBgNVBAoTC0FkZFRydXN0IEFCMSYwJAYDVQQLEx1BZGRUcnVzdCBFeHRlcm5hbCBUVFAgTmV0 d29yazEiMCAGA1UEAxMZQWRkVHJ1c3QgRXh0ZXJuYWwgQ0EgUm9vdDAeFw0xMzAzMTkwMDAwMDBa Fw0yMDA1MzAxMDQ4MzhaMHkxCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDQTEUMBIGA1UEBxMLU2Fu dGEgQ2xhcmExGjAYBgNVBAoTEUludGVsIENvcnBvcmF0aW9uMSswKQYDVQQDEyJJbnRlbCBFeHRl cm5hbCBCYXNpYyBJc3N1aW5nIENBIDRBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA 4LDMgJ3YSVX6A9sE+jjH3b+F3Xa86z3LLKu/6WvjIdvUbxnoz2qnvl9UKQI3sE1zURQxrfgvtP0b Pgt1uDwAfLc6H5eqnyi+7FrPsTGCR4gwDmq1WkTQgNDNXUgb71e9/6sfq+WfCDpi8ScaglyLCRp7 ph/V60cbitBvnZF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