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=1796140741; b=0tMh48SkKeBhN04duP6FEmzyc4NQqWNg5MPMjio1C9fluS8TjwV7FaF+be7t4V1dQ+ZM u75X1FEGjhj7zB6KPwsxx1UuyQ2EwkZABZTX4WZ4CqxdwZ9k3SdkPX+mp9zY3Itq0nUbc 18vSdIiSoNEl3m9tvCt6su2jlRAVECFuOOwMDXpVXlrDSwxt5AdB8wDkUoghufeP8gSu7 qP9oh6DM4yHTBznNBazCdeS9/4zrLO1yWFXvTPRYF6Aw/YadXAC5oVjhHl21uBO4xTQ3t 5GBIGPmi87fcBFYKSbVGJvQZLe3kuFAoVgYEZzZcOh2yHIcwvGlKoYTxyLdIZ0d449A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796140741; 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:MIME-Version:Content-Type: Content-Transfer-Encoding; bh=1j+j6kFPDgHJUTGxtOeZ7+HXfqUVzZMNlSwXkwWlcwc=; b=fQAjJMpzRo0suWxugcRDMYVzRicTwX9dexk4lcnWQnEQQ2GVRZED5CgjvjG5rL59sZMr QHGM4c/03kEIw40FaXhWnvVzL3gZ1ek4MIeezbb0OHLKZw8d3uepa66A15Wism8LsUOGD Yhz7AtsrooE3mbTIEP5sBX+xkVYYg4F8nV/d9G1qeufptb6tfKJSG7jcFnYHPHaUZIUqQ pakHdcCma3rgw+AOwCuLn5dhHSdF+g5iT26H6aBJoOPKKOBG01sfTqCNtMlLLbIgfHqVi lbL6IPn6xN9DWfhxs7GrjZRynI/ndyiEr0gc1yQkCMSwLRZNhsFu9OcH4nNbTgJMIgQ== 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=MivAuMMt; 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 8E41B606A322 for ; Tue, 1 Dec 2026 15:59:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 8E41B606A322 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=MivAuMMt DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796140741; x=1827676741; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=1j+j6kFPDgHJUTGxtOeZ7+HXfqUVzZMNlSwXkwWlcwc=; b=MivAuMMtlkMZzHEcjbAU19IsMYiNR1mOWahLMCPQ/s6qZcXH8QA8mts2 P/DKHI2EOTfe+JT8b2Cw6KtSJIIHK8YjPHgR7QdZOH500BCnrk3Y5jpXI lI+yOJ2bXuaoVk7ZOZ7blUymROIatGYkmWiP9aGgJfb86U8I1b+VhXD3f cVV0+vlcdPiWM7YmMqOgU8lRhbdPb7dVLVc54wtW5QvELsr+omwJ6sbUN mA+I1HFhPPl5ahNunOREkGu3eGBN2scLHaPDUxk7ZJeagkLV97c8gu1hO TuWY+swcr/bXLhPIWG6QqX+NaPx3MpwvGwPIWoxt+GFR7XGtN9zwXqECj Q==; X-CSE-ConnectionGUID: 1I6QUtv+SNK/N8R76x/FcA== X-CSE-MsgGUID: yqEYqQ0iTm6uxnN3Bb4Ofg== X-IronPort-AV: E=McAfee;i="6800,10657,11983"; a="5028000" X-IronPort-AV: E=Sophos;i="6.27,245,1787036400"; d="scan'208";a="5028000" 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:00 -0800 X-CSE-ConnectionGUID: Qt6j4no8S8igXJ7hsZgX9Q== X-CSE-MsgGUID: 6YB/agvITV+xmVNNZqKL5g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,245,1787036400"; d="scan'208";a="13250838" 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:58:52 -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 Cc: linux-kernel@vger.kernel.org, =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH 00/15] PCI: Resource release fixes and improvements Date: Tue, 1 Dec 2026 17:58:24 +0200 Message-ID: <20261201155844.2278-1-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.47.3 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 Hi all, Releasing a PCI resource does not care what resides underneath it. A released bridge window takes its children along, including regions requested by drivers, which can corrupt the resource tree once the window and its resources are assigned elsewhere. This series makes pci_release_resource() refuse resources with children and adds pci_release_resource_tree() that releases only PCI resources. The check and the release are done under resource_lock, which the resource core now exposes. Exposing resource_lock is probably the most debatable part; an alternative to this would be to pass check and release callbacks to a new resource core function. The first 5 patches are related fixes. The most immediate effect of these changes is for driver initiated BAR resize which could fail if there are any extra resources underneath the one to be resized. My impression is that this is not the case with any of the GPU drivers using BAR resize but it would be good still that GPU people take a look and test as needed. The series is a prerequisite for sizing already assigned bridge windows. The resource fitting and assignment algorithm self-race conditions due to insufficient locking are out-of-scope. They are fixed by this series: https://lore.kernel.org/linux-pci/20261125230925.2441-1-ilpo.jarvinen@linux.intel.com/ ... and another (unsubmitted) series on top of that to bring pci_assign_resource() and pci_bus_alloc_resource() under the same lock. Ilpo Järvinen (15): PCI: Release all resources before restoring them in BAR resize rollback PCI: Set new BAR Size only after releasing the BARs for BAR resize PCI: Abort BAR resize only if saving the resized BAR fails PCI: Consistently use Header Type to detect bridge headers resource: Check that the resource is in the tree when releasing it resource: Add KUnit test for releasing a resource not in the tree resource: Add release_leaf_resource() resource: Add KUnit test for release_leaf_resource() PCI: Do not release resources with children in pci_release_resource() resource: Rename next_resource() and for_each_resource() resource: Make resource_lock and resource tree traversal available resource: Add release_resource_locked() PCI: Split pci_resource_post_release() out of pci_release_resource() PCI: Add iterators for devices and resources in bus windows PCI: Release only PCI resources when releasing a resource tree drivers/pci/bus.c | 33 +++++++++++ drivers/pci/pci.h | 23 ++++++++ drivers/pci/setup-bus.c | 66 ++++++++++++++------- drivers/pci/setup-res.c | 124 +++++++++++++++++++++++++++++++++++++--- include/linux/ioport.h | 23 ++++++++ kernel/resource.c | 75 +++++++++++++++++------- kernel/resource_kunit.c | 44 ++++++++++++++ 7 files changed, 339 insertions(+), 49 deletions(-) base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4 -- 2.47.3