Received: by 2002:a4a:311b:0:0:0:0:0 with SMTP id k27-v6csp4843457ooa; Tue, 14 Aug 2018 11:18:25 -0700 (PDT) X-Google-Smtp-Source: AA+uWPweqydi4ZS8D1VZrSVqGRUriNOVt/c+XmjA9X7pCztgWPkXeuMJjPzLG2MHLTwzPqMdTowU X-Received: by 2002:a17:902:6b89:: with SMTP id p9-v6mr21454432plk.272.1534270705394; Tue, 14 Aug 2018 11:18:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534270705; cv=none; d=google.com; s=arc-20160816; b=FEFtOeD3dOaHu/vdy50SfdohsW5sQYwrZWTZOgw/xe9cY6A6F5GfSZA4rEgDhaB/F1 d/q7nNlHZtrt8zsht0mJ0txh+NosKoUXDKk5im4UKA7V/d/O4hRTxcqilTrxjFl7IoF9 fegPxvT6QfgagvKT7LQQXiI1UZ3HOM+9nl7CR1oE1na9mUSltFWObUZeg6h176pEVzvB 7YEFO+6S8KoabQxEhGxMl1LMB09JxQdmwWoH91WJitEJsvAPBXH43wN7V47GHXZhTKGv fjpKhMTXnvGDHOAsYbUCDn18WiTEaV7/jrJvk0bxqaDdnwvRS6KKug5N6GEyVeeJ0VFL nC7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=5APfRaqzPBMq5wXU/5sU+08fWm4WywyuhZZgnueuMMY=; b=y3LdJvNSYabJfginXtvXITmK8OhMN7NAZmrQ+i3ifZKnTYipR3fpJkKoJ3L3iRwcgI A1J7+emEIzpPw7LDqEZdX8g3nUfBLfYJGexpeR5wYwOpLlHI3Lyld54ohx9RWoVTI2bs ZbpXO17t9AJbCt4jnLqxYrB6cOf3ICQ7ux1Aq2kKGFOCWRPUCeuEExgQljeDYiGsNdiE UNxE7sJUZZL1E7Qg+Z8N1Ce9A3T7WHkLgGOLzYLcSQOp/8XSaF7TwLEM0cXFUBOVucsW frB0z7L6aZzNXaP2dhaynMjisU0TowfQNHc+OLko+9kHCLN5F+AJyzZpM5wNAJK/IfOS cmdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hDDtoUDa; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i7-v6si16269468plt.433.2018.08.14.11.18.09; Tue, 14 Aug 2018 11:18:25 -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; dkim=pass header.i=@kernel.org header.s=default header.b=hDDtoUDa; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728036AbeHNVFF (ORCPT + 99 others); Tue, 14 Aug 2018 17:05:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:52964 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725915AbeHNVFE (ORCPT ); Tue, 14 Aug 2018 17:05:04 -0400 Received: from localhost (unknown [69.71.4.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 13E84214EE; Tue, 14 Aug 2018 18:16:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1534270602; bh=Y90WETNs4ZLac+d9ElVN3V0fvEJV9u5NvW19CbJpIBw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=hDDtoUDayY1eyyyAZJVUgk846tcPty6GvQAmNV4YKn7fDLcWH5Ein6hwMJpKqPzef z6crfsoOUSL0HjzBP6YymnxSG5MVYVFZt/a80WX+PyaTETfA3zgQ6ApWMSOPUvah2t 3qrOLJjNGhgeqsj7hPm1bnDJroX+cD65HyD/YQbE= Date: Tue, 14 Aug 2018 13:16:34 -0500 From: Bjorn Helgaas To: Jon Derrick Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Lorenzo Pieralisi , Keith Busch , Greg Kroah-Hartman , Mika Westerberg , Sinan Kaya , Logan Gunthorpe , Stephen Bates Subject: Re: [PATCH] PCI: Equalize hotplug memory for non/occupied slots Message-ID: <20180814181634.GQ113140@bhelgaas-glaptop.roam.corp.google.com> References: <1532559779-3542-1-git-send-email-jonathan.derrick@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1532559779-3542-1-git-send-email-jonathan.derrick@intel.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 25, 2018 at 05:02:59PM -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. > > 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. > > This makes for possibly undesirable results with a mix of unoccupied and > occupied slots (ex, with hpmemsize=2M): > > 02:03.0 PCI bridge: <-- Occupied > Memory behind bridge: d6200000-d64fffff [size=3M] > 02:04.0 PCI bridge: <-- Unoccupied > Memory behind bridge: d6500000-d66fffff [size=2M] > > 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: > > 02:03.0 PCI bridge: <-- Occupied > Memory behind bridge: d6200000-d63fffff [size=2M] > 02:04.0 PCI bridge: <-- Unoccupied > Memory behind bridge: d6400000-d65fffff [size=2M] The I/O sizing code (pbus_size_io() and calculate_iosize()) is essentially identical to the mem sizing code you're updating. I assume the same considerations would apply there? If not, please include a note in the changelog about why you changed the mem code but not the I/O code. > Signed-off-by: Jon Derrick > --- > Original RFC here: > https://patchwork.ozlabs.org/patch/945374/ > > I split this bit out from the RFC while awaiting the pci string handling > enhancements to handle per-device settings > > Changed from RFC is a simpler algo > > drivers/pci/setup-bus.c | 13 ++++++------- > 1 file changed, 6 insertions(+), 7 deletions(-) > > 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, > > 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 = 0; > if (size < old_size) > size = old_size; > - size = ALIGN(size + size1, align); > + size = ALIGN(max(size, add_size) + children_add_size, align); > return size; > } > > @@ -1079,12 +1080,10 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask, > > min_align = calculate_mem_align(aligns, max_order); > min_align = max(min_align, window_alignment(bus, b_res->flags)); > - size0 = calculate_memsize(size, min_size, 0, resource_size(b_res), min_align); > + size0 = calculate_memsize(size, min_size, 0, 0, resource_size(b_res), min_align); > add_align = max(min_align, add_align); > - if (children_add_size > add_size) > - add_size = children_add_size; > - size1 = (!realloc_head || (realloc_head && !add_size)) ? size0 : > - calculate_memsize(size, min_size, add_size, > + size1 = (!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) > -- > 1.8.3.1 >