From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=192.198.163.10 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796431213; b=5J3wOKkMIXs/c7ReXSfFDdkAMwKLJZeVrL7PuWie0Kp4YiK7+vI4Ht2+7W2evbh0dWpS apjgIDJ7qP02GQk04Soay0UEY+ZDiS1rdHO4iQRz1zty7mJNtajwKPR3aUlwNIFDUUlzc ZlJdRKhNybI9Vm9bJTd/Wd6lE/w0+8Gm8WWr3Ykmn1PNOhCJcGVyHbADsdtXgtF856a5c rlCR2FS8CWc4fHo7wPMEXjTLxdYjPjZF4tPj03DZ+lzpLZV6iRmf9BqnxhnSj6Kln0VW5 6Xhy8dqhJw8RkjkRXLMUAtiYiCyxiut2dwqayn3H8uuyYptbVZUIQHVkAn9DW+ZKk2A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796431213; 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=P9d19KqerLcHw8gnPGrZs0ewl/SDttIGMz/tcrCtUSU=; b=o4N36s82VhWpSd4HfiLwBT1HqpNCkQn9I+6Dbl7F810bO0HDIGlSR48JdSRzp/bEbl3Z /11czKbf8FskAunB/NprShKd2Ii5CMN7X6XgKGQ6Vm/tH2MOk38qLvh/IvqJp+WYIHIqM zUycpmZkMGnd8xeBFO8DANGAZT08QfIu5/AS1rZHb3lC/+UyQzxGYRzvgq2A+9Jnhdypq OP7AqVxztjNL9kKsh61RhjLbTjJPGUXHKXsg6ZrB/GNeK4HY487it1/eSgSUfVJveOrYF lfyI9RZ3RtqYIL1chCj+CvNKuOkGuvyfaB97Uux+EEGt6RsEeJdHro2DdbWqr9g/wTw== 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=EyP7cLCL; arc=none smtp.remote-ip=192.198.163.10 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (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 02754606A322 for ; Sat, 5 Dec 2026 00:40:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 02754606A322 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=EyP7cLCL DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796431213; x=1827967213; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=P9d19KqerLcHw8gnPGrZs0ewl/SDttIGMz/tcrCtUSU=; b=EyP7cLCLktz8eUdty661piMJc5g82eUN8TNrRbWCtloF0089zmZfANdh Nrd/ySss1nLWMRJTNlKgtuv4f3JpeTczShVl3iD3+ePqHQ6R6Iu28BTan yH3DbHjldL7N9PN60pVkAzbSHsQk9LRuUYm3DHoWubAR1opN4y1F0PBdy WxOXUomepc0f41wVrxDtS6YU3K7P2tHSx4icQ1aAfXQrd7jxv71ixtyOv OT/J/U+xgeYeMh7g6os6iq0B/sayiDBVT7IddEhoQ6OPhgARbfyf5nvRv sTZWHb+gw0o0K/h1Y6LR7fTQvmiBy9rs/L/kF+JTgaaP6d6VUOTyECeQR A==; X-CSE-ConnectionGUID: WBnIczx5S/S5YL9xxCXnyQ== X-CSE-MsgGUID: bIhGFIUkQqOV4xoItO2E8A== X-IronPort-AV: E=McAfee;i="6800,10657,11986"; a="5308132" X-IronPort-AV: E=Sophos;i="6.29,79,1794902400"; d="scan'208";a="5308132" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Dec 2026 16:40:12 -0800 X-CSE-ConnectionGUID: 0g3GPbH1Sjq9ZGBuBYyG2w== X-CSE-MsgGUID: 667bI4fMTcyThAhyj9Xbqw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.29,79,1794902400"; d="scan'208";a="14765989" 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 16:40:04 -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, Anthony Pighin Cc: linux-kernel@vger.kernel.org, =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH v2 00/16] PCI: Resource release fixes and improvements Date: Sat, 5 Dec 2026 02:39:35 +0200 Message-ID: <20261205003957.3304-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. v2: - Add a patch to prevent destruction of IORESOURCE_PCI_FIXED resources - Do not restore old BAR size if it wasn't changed - In release_leaf_resource() pass release_child=false instead of true because it's more logical (no functional impact) - Tweaks to changelog text + one more Fixes tag Ilpo Järvinen (16): 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, kunit: Add test for releasing a resource not in the tree resource: Add release_leaf_resource() resource, kunit: Add 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: Keep the range of fixed resources when releasing them 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 | 73 +++++++++++++-------- drivers/pci/setup-res.c | 138 ++++++++++++++++++++++++++++++++++++++-- include/linux/ioport.h | 23 +++++++ kernel/resource.c | 75 ++++++++++++++++------ kernel/resource_kunit.c | 44 +++++++++++++ 7 files changed, 357 insertions(+), 52 deletions(-) base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4 -- 2.47.3