From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 23254606A32C for ; Sat, 5 Dec 2026 01:26:15 +0000 (UTC) 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=dZH/Tnr1 Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4A9B610ED42; Sat, 5 Dec 2026 01:26:09 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by gabe.freedesktop.org (Postfix) with ESMTPS id A990A10E071; Sat, 5 Dec 2026 01:26:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796433963; x=1827969963; h=from:date:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=vLU+O+AhuNvuBXnW0znEvjchl9JR6Vd5TiH3ykoHPFk=; b=dZH/Tnr1tbAIIfwRM/gadPhvqFFqrT81gESBGaqf57MR7g4O5lkmc6by Nnr4iupXlRz6+5JWwdXyt1Bpk4jwOIgVay1m+mTDYGAmQd8WI3ZlsxzyT X/+rz0Zbc+rr3ape1GAzhrwKjwj+lM0fNArsLNVie5ubUIy6kcv3tv2gq BbIxI2h1bnkkHQm+KKcPPiHfvVIn8dL/kEz20Olgnei7B12uVPYKo7edH 3eVbLH+LR1CegSJGjeQiNLMru/tfKrW5onJ+iP76deH24i+hp0Fz1Yvv7 SQZyXi8OAr/uqgyfaSCklBtsfwNddgZHilWSdtI5NuiYaxKYBFmvEcZ8i A==; X-CSE-ConnectionGUID: a8kgBqIwT0KTcfjh6B4gRA== X-CSE-MsgGUID: cUAGDnugTHOZqnvrVK528A== X-IronPort-AV: E=McAfee;i="6800,10657,11986"; a="5337962" X-IronPort-AV: E=Sophos;i="6.29,79,1794902400"; d="scan'208";a="5337962" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Dec 2026 17:26:02 -0800 X-CSE-ConnectionGUID: /YvbgWrWSu2mzF5EWQZorQ== X-CSE-MsgGUID: l4xOzoWDTFyJueYBZibk1g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.29,79,1794902400"; d="scan'208";a="13999230" Received: from ijarvine-mobl1.ger.corp.intel.com (HELO localhost) ([10.245.245.47]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Dec 2026 17:26:00 -0800 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Date: Sat, 5 Dec 2026 03:25:57 +0200 (EET) To: sashiko-reviews@lists.linux.dev cc: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org, linux-pci@vger.kernel.org Subject: Re: [PATCH v2 03/16] PCI: Abort BAR resize only if saving the resized BAR fails In-Reply-To: Message-ID: <1feedb58-3002-59f7-a0f6-197bfb65d41b@linux.intel.com> References: <20261205003957.3304-1-ilpo.jarvinen@linux.intel.com> <20261205003957.3304-4-ilpo.jarvinen@linux.intel.com> X-Archived-By: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="8323328-1052962357-1796433957=:1171" X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Intel-xe" X-Spam-Status: No, score=-9.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323328-1052962357-1796433957=:1171 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE On Sat, 5 Dec 2026, sashiko-bot@kernel.org wrote: > Thank you for your contribution! Sashiko AI review found 2 potential > issues to consider: > - [Medium] PCI: continuing after -ENOMEM in > pci_do_resource_release_and_resize() > - [Medium] PCI: pci_do_resource_release_and_resize() skips unsaved > unassigned BARs > -- >=20 > commit 2e0d31c7b9377b1d5689204c149a99e359a637cb > Author: Ilpo J=C3=A4rvinen >=20 > PCI: Abort BAR resize only if saving the resized BAR fails >=20 > This commit changes pci_do_resource_release_and_resize() so that a > failure to save a BAR in the saved list only aborts and rolls back when > the failing BAR is the one being resized, leaving other BARs in place > and continuing. >=20 > > diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c > > index db16c8c2913d6..c18664b5e5a25 100644 > > --- a/drivers/pci/setup-bus.c > > +++ b/drivers/pci/setup-bus.c > > @@ -2407,8 +2407,11 @@ int pci_do_resource_release_and_resize(struct pc= i_dev *pdev, int resno, int size > > =09=09=09continue; > > =20 > > =09=09ret =3D pci_dev_res_add_to_list(&saved, pdev, r, 0, 0); > > -=09=09if (ret) > > -=09=09=09goto restore; > > +=09=09if (ret) { > > +=09=09=09if (i =3D=3D resno) > > +=09=09=09=09goto restore; > > +=09=09=09continue; > > +=09=09} > > =09=09pci_release_resource(pdev, i); > > =09} >=20 > [Severity: Medium] > Can continuing after pci_dev_res_add_to_list() fails with -ENOMEM turn a > clean rollback into a kernel panic? It can, like boot can too. One day, I'll remove that panic() but it isn't= =20 going to be in this series. There are no shortage of more important things= =20 to address than this panic(). > pci_dev_res_add_to_list() only fails when kzalloc_obj() cannot allocate a > struct pci_dev_resource. If that happens for a sibling BAR after the > resized BAR was already released, leaving the sibling BAR assigned keeps > b_win->child non-NULL. >=20 > pbus_reassign_bridge_resources() then skips its own save check and calls > into pdev_sort_resources(), which allocates the same struct pci_dev_resou= rce > with kzalloc_obj() for the released resized BAR and panics on failure. >=20 > Even if the allocation failure is transient, leaving the sibling BAR > assigned pins the bridge window and can mask the -ENOMEM as -ENOSPC. >=20 > [Severity: Medium] > What happens if the unsaved sibling BAR is currently unassigned rather th= an > assigned? >=20 > Because this loop does not check resource_assigned(r), an unassigned BAR > with non-zero flags (for example, on a PCI_PROBE_ONLY platform) still > matches b_win via pbus_select_window(). Continuing on error leaves it > unassigned and absent from saved. > > When b_win is not released (for example, when exclude_bars keeps another > BAR in place), pdev_sort_resources() includes that unassigned BAR and can > assign it into resno's vacated range while the enlarged resno fails with > -ENOSPC. >=20 > Rollback only releases resources tracked in saved and their children, so > neither b_win nor the sibling BAR is released. pci_claim_resource() for > resno then fails with -EBUSY, leaving the resized BAR unassigned. >=20 > Checking (i =3D=3D resno || !resource_assigned(r)) before jumping to rest= ore > would avoid leaving an unassigned BAR untracked. Generally, if a BAR is not assigned, pci_enable_resources() would have=20 already refused to enable the device, so it's hard to see how this would=20 make things significantly worse or better. Not sure what could be salvaged= =20 in the suggested rollback scenario as it only trades one resource failure= =20 to another. And it still has the alloc fail precondition too. --=20 i. --8323328-1052962357-1796433957=:1171--