From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=192.198.163.16 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796140766; b=y6ad1zyqgUaTRP/852ua5qpCysoTpAa/ZCiTawnnnz655HMbsjRW3UCE+h7dUyq0Opqr RB2R7Q3/Pm0XEmyJNX3PFqU2Ead/PA4EreGiQXzE8cRUbdU9EoHdZ8EBbnvyN7MIwl1/e YckssdDt/uXNU15FpKeVLADJ7x9cYhZPYiOUCwtDSIxXwSyOsb07HA6EdI4W3VA3TjGHp dQDDYITGU0FZBbEssQibOylkGvkED9v4rfpI1r5rEzd1g9fM+h4SnBXsiIvlUdF3D0hY7 Og/7/ACMWb/y+Wz2RGdBR2jst5K8u7pybllnxtgwK8weJXmAbwLjpMLw8+Wy+AeV/+g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796140766; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Type:Content-Transfer-Encoding; bh=DlwQ7s96WKtX1sWjFCeBm7NTSdXsqAV8mE5kZSrC9+E=; b=zr7GiTtmT1IJTfjFQ8IHAXUFiAP30crROrRkasHyJ3rNVLNjmyapX3SnFWw+2vcTZpyD hHSCr4lz8E+E8ND3A9gvKmVLJnYk/6wWYNq4AoxAoHafosz36Y8yNVBFZ6ucQcrtcDawf wwrJnsiImXYqPpA9K19POvGgsq3oRidRRcKXprfosNDCASKpv9pFd+KIVgP9CWgh3lpp1 i7vGmoVGnfHsAemsd/F96EqlTrjPvhXxWOWoJ4H/Etm9fDfJ+0aaE6dGwPKOLKr1ur8+q umz64/Ft6t5GCvB1c0sgHltyn+iumWIUHBasiu7MzApv/ne2C5+1fiQdTrEhDuDnkdQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=coQAqSXe; arc=none smtp.remote-ip=192.198.163.16 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 724CA606A31A; Tue, 1 Dec 2026 15:59:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 724CA606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=coQAqSXe DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796140766; x=1827676766; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=DlwQ7s96WKtX1sWjFCeBm7NTSdXsqAV8mE5kZSrC9+E=; b=coQAqSXe8vVjXIJMSMavtEhrhzqCABNW0LcVpIXHfpbGunrQ3e7fbW3V J9LKbHJTMIqeL3exz27ZiwcY4HillsWar/0lAbqF445Ia/U+i54fZq3/A afI3o4H0Kzouq7kSIouBK3fZsQhelaSiF+JfNCeZN9iUpl3QPemLD7AkA zofXwK1ocfICBn+VTjAKbsiaN2flfGW1SiFCZMakwhKx9kPVrPO0+pScj O4ffPqpQS/2+kabMjYza2U0zRaVCDXTt846jvmh4cKUGUp0rzWyF5GOLc /uZHmcJFHk4DDPfm7z0h8nyTpk7ItY1O1nGa1Y8D4YS3Q2OIpzsBfIC7A Q==; X-CSE-ConnectionGUID: TSDZlrLQRS24erW18eT2cg== X-CSE-MsgGUID: 7x3Qlp6aRwW5tevkKPGmGg== X-IronPort-AV: E=McAfee;i="6800,10657,11983"; a="5028065" X-IronPort-AV: E=Sophos;i="6.27,245,1787036400"; d="scan'208";a="5028065" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Dec 2026 07:59:26 -0800 X-CSE-ConnectionGUID: FiQnjoKjTzOb9SAW51eDlw== X-CSE-MsgGUID: Axm5uAD8QNGIDmnQtKSM9g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,245,1787036400"; d="scan'208";a="13250986" Received: from pgcooper-mobl3.ger.corp.intel.com (HELO localhost) ([10.245.245.21]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Dec 2026 07:59:18 -0800 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: Bjorn Helgaas , Lorenzo Pieralisi , Rob Herring , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , Matthew Brost , =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= , =?UTF-8?q?Micha=C5=82=20Winiarski?= , =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= , David Airlie , Simona Vetter , dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org, =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Cc: stable@vger.kernel.org Subject: [PATCH 02/15] PCI: Set new BAR Size only after releasing the BARs for BAR resize Date: Tue, 1 Dec 2026 17:58:26 +0200 Message-ID: <20261201155844.2278-3-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261201155844.2278-1-ilpo.jarvinen@linux.intel.com> References: <20261201155844.2278-1-ilpo.jarvinen@linux.intel.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit pci_do_resource_release_and_resize() sets the new BAR Size before it saves and releases the BARs that share the bridge window with the BAR being resized. The BAR Size decides which bits of the Base Address Register are read-only, so the address in the resized BAR may lose its low bits right away. Saving the BARs needs memory allocations, which can fail. If that happens before the resized BAR has been saved, the BAR resize rollback restores the old BAR Size but cannot restore the address of the resized BAR, which leaves the BAR and its resource out of sync. Nothing requires setting the new BAR Size that early. Set it only after all the BARs have been saved and released, right before the resource is resized. Fixes: 337b1b566db0 ("PCI: Fix restoring BARs on BAR resize rollback path") Signed-off-by: Ilpo Järvinen Cc: stable@vger.kernel.org --- 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 b69041fbbd39..608ca7afbfb8 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -2394,10 +2394,6 @@ int pci_do_resource_release_and_resize(struct pci_dev *pdev, int resno, int size if (old < 0) return old; - ret = pci_rebar_set_size(pdev, resno, size); - if (ret) - return ret; - down_read(&pci_bus_sem); pci_dev_for_each_resource(pdev, r, i) { @@ -2416,6 +2412,10 @@ int pci_do_resource_release_and_resize(struct pci_dev *pdev, int resno, int size pci_release_resource(pdev, i); } + ret = pci_rebar_set_size(pdev, resno, size); + if (ret) + goto restore; + pci_resize_resource_set_size(pdev, resno, size); if (bridge) { -- 2.47.3