Message ID | 20231222122901.49538-2-ilpo.jarvinen@linux.intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-9702-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp1025035dyi; Fri, 22 Dec 2023 04:30:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IHkal7+uT4iiota2HqwCEOXvpLipnlFvwhBa0jMXoF5ZiPrPgPQ2vUkWhDJjAiKrHRPR5j2 X-Received: by 2002:a05:6808:22a0:b0:3ae:1298:257a with SMTP id bo32-20020a05680822a000b003ae1298257amr1383731oib.1.1703248199810; Fri, 22 Dec 2023 04:29:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703248199; cv=none; d=google.com; s=arc-20160816; b=Y5g6z+PxTJnd2LD7+tA430rJR1rNdBUbtPgtib/bHeoVNV4WpMf1wYqTzFf1g/8ul7 1EEY1VJouK+SyVmo2U5PghyxUWWqgKvVkgpet4WPPb310SmyNKjaM5fgiaQrnX4sLMRV 3dcBefk4tfzwZ/oQ0KLtNcIbIv29jXe55YeR4JgnAyV8Lf+tJkOzcZUogDmdheqmvzRP 7fhRtQITgQdYLk3wHk/yczSzRw+5zMLlT20tmAIkdLviTSHskWKrGlXNt/lDM2bXqLDX lv4Kn3T7vYuncZejiIRT5kGV7SDiTvX8zORMzDI4ErQNRIMTJVYEYCYmw4LiSqTDwFSC 4wZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=gwEOFxbI2yDL2y6iq/2YGqhZ0x0H2WQKRKiCddsl91o=; fh=yqUIIgKqVOYsTyZW6w8zcpjOuZt/iZwb7E0FG62Kafw=; b=UWv4GATxaQdQHQtme9VaILfWCXGtSw9c35CHzO0LOLW1/nOPtFskL2G8EJcOqqJ99K puLzH94asG7qlsRo1wu3Vb8rljoM+z6VoYY62ujOHOQddTWWplq+LP7Xi9xgH7VAsdgD NaUEyNhc8Gz+OSxg28GHdCKYkBkPr36m9nULyx9sC0ugADDBEtQHRS2RQbi+w6kwdzyC TYBoEaWweO8y2oRmVcD0V+GEPaDeoHQQzF2+55EgKfpg+hWIpjZ2kBlrD2AB4x5OzwGg RnCs7yqRzpz4B+VTIP+I6fuLO4G9qX6y+wcSy0jLQhichp8WGX/mzkt5BEDa+rHbBC4w 3MnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=L7vgg2ex; spf=pass (google.com: domain of linux-kernel+bounces-9702-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9702-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id w2-20020a0ce102000000b0067f89f0a735si2778821qvk.236.2023.12.22.04.29.59 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Dec 2023 04:29:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-9702-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=L7vgg2ex; spf=pass (google.com: domain of linux-kernel+bounces-9702-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9702-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 862AB1C214AD for <ouuuleilei@gmail.com>; Fri, 22 Dec 2023 12:29:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5789A19BD3; Fri, 22 Dec 2023 12:29:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="L7vgg2ex" X-Original-To: linux-kernel@vger.kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5B1A5199A1; Fri, 22 Dec 2023 12:29:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1703248168; x=1734784168; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LCe+OPVf6ypAOTjFWig95nNeJVsgngMAJh/hD3RJ254=; b=L7vgg2exjtHCbQFLj8azE2qQZPp1P/e1KlT2Bl+bdqyNxCM536S767yd lo1V9FNCaW3QkGUp3Ac5Bx74DlSs+nU2lNNJ5teENNfkO4nDJYI37TMqv Ua7XKpSF3Fsmx/K/uwpVI2jpbEwW6Njk5O3A3c9sgUsI83LMtffpttWQS YAB1GPE3Sqvfgb6cgN1CR1dsqfuLCILRd5P8yBOYcQ6aihXlQR10rwEf3 yj3z3fHWxDBKepEs1uboAtF41orgbZzJOziJETKAJ981e2UMOy2STU/5q 2oIQ8dDayblUVt6qDpZaowZ24LKAY7WTlbEddV2MDHY5VRU2Tnip9Dhy3 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10931"; a="17681298" X-IronPort-AV: E=Sophos;i="6.04,296,1695711600"; d="scan'208";a="17681298" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Dec 2023 04:29:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10931"; a="950263952" X-IronPort-AV: E=Sophos;i="6.04,296,1695711600"; d="scan'208";a="950263952" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.94.248.105]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Dec 2023 04:29:22 -0800 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= <ilpo.jarvinen@linux.intel.com> To: linux-pci@vger.kernel.org, Bjorn Helgaas <bhelgaas@google.com>, Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>, Rob Herring <robh@kernel.org>, =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= <kw@linux.com>, Igor Mammedov <imammedo@redhat.com>, Lukas Wunner <lukas@wunner.de>, Mika Westerberg <mika.westerberg@linux.intel.com>, Andy Shevchenko <andriy.shevchenko@intel.com>, "Rafael J . Wysocki" <rafael@kernel.org>, linux-kernel@vger.kernel.org Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= <ilpo.jarvinen@linux.intel.com> Subject: [PATCH 1/7] PCI: Fix resource double counting on remove & rescan Date: Fri, 22 Dec 2023 14:28:55 +0200 Message-Id: <20231222122901.49538-2-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20231222122901.49538-1-ilpo.jarvinen@linux.intel.com> References: <20231222122901.49538-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785985184375764475 X-GMAIL-MSGID: 1785985184375764475 |
Series |
PCI: Solve two bridge window sizing issues
|
|
Commit Message
Ilpo Järvinen
Dec. 22, 2023, 12:28 p.m. UTC
pbus_size_mem() keeps the size of the optional resources in
children_add_size. When calculating the PCI bridge window size,
calculate_memsize() lower bounds size by old_size before adding
children_add_size and performing the window size alignment. This
results in double counting for the resources in children_add_size
because old_size may be based on the previous size of the bridge
window after it has already included children_add_size (that is,
size1 in pbus_size_mem() from an earlier invocation of that
function).
As a result, on repeated remove of the bus & rescan cycles the resource
size keeps increasing when children_add_size is non-zero as can be seen
from this extract:
iomem0: 23fffd00000-23fffdfffff : PCI Bus 0000:03
iomem1: 20000000000-200001fffff : PCI Bus 0000:03
iomem2: 20000000000-200002fffff : PCI Bus 0000:03
iomem3: 20000000000-200003fffff : PCI Bus 0000:03
iomem4: 20000000000-200004fffff : PCI Bus 0000:03
Solve the double counting by moving old_size check later in
calculate_memsize() so that children_add_size is already accounted for.
After the patch, the bridge window retains its size as expected:
iomem0: 23fffd00000-23fffdfffff : PCI Bus 0000:03
iomem1: 20000000000-200000fffff : PCI Bus 0000:03
iomem2: 20000000000-200000fffff : PCI Bus 0000:03
Fixes: a4ac9fea016f ("PCI : Calculate right add_size")
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
drivers/pci/setup-bus.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index fd74f1c99dba..e3e6ff8854a7 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -820,11 +820,9 @@ static resource_size_t calculate_memsize(resource_size_t size, size = min_size; if (old_size == 1) old_size = 0; - if (size < old_size) - size = old_size; - size = ALIGN(max(size, add_size) + children_add_size, align); - return size; + size = max(size, add_size) + children_add_size; + return ALIGN(max(size, old_size), align); } resource_size_t __weak pcibios_window_alignment(struct pci_bus *bus,