From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796302426; b=mG5T4SxizX72pLLZJCN0+DSvxOyOf5O2TVX750JSWahaptkP4tUqzApGR849YDBNPN2i 5IOHmZ7VnNZ2sCSkOr49idEH3s7aduWIYMzsrD9e4cMBDmdO5u236cbSPkGy9v9pW560s dI295zmLtWEz+gXb0jNtWA5E2TwXIcgH/YTaxH6nOHyKCf7em2VuXGcZ1RKPod91OjFU3 Kd8DLV85Hd1qfy5TmtlEnLJ9vRM0+QGeUyUxTeFQmuKZ9MCMzpNWrJSK6mXxCMDV005dD w4hiRKzVlJLTspqC64Bm0+f8aU7YS1flvbMWzauix7ougrvVm8A4dQwZSPqD74w4zRQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796302426; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=q8JJrlpvXhBwpw6BkWsiFYrCItkm3l6blCG7U7K7SNM=; b=nIL35YrbrZUSImyFL7bnrS9eV1QW+hgmDuSi0eRhaNboc3uhgIkJnzGot4soxdc7sDqU 4zZT84r5jy3iyhBjVonQ3eMxTChny4PcI8rbZlOhpBVh8iUK4XtzA+lwGbbRFpUakEDN6 3ohtEAuBjYITWjXC7gsLJslcY+joQ1i9efRs4BQBnwniT492EMfnAkJmdxzXe1zBJijwy zMP3faqDUMqH8INKLljymMg52zNODv621Bwkx/bvvfng9HkWMWjLlvdBSGHSUSV/c6JBb hJCzJ7/3jQ3kR3qi4Zvjyg+V0fYthHVQ2XezYYL6kuYuGhWqZNHhHR2XdhNYXLkNjCw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=SSVwwjX4; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2D8C0606A32C for ; Thu, 3 Dec 2026 12:53:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=SSVwwjX4 Received: by smtp.kernel.org (Postfix) with ESMTPSA id C245E1F000C1; Thu, 3 Dec 2026 12:53:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796302425; bh=q8JJrlpvXhBwpw6BkWsiFYrCItkm3l6blCG7U7K7SNM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=SSVwwjX4qMGmwbQh3lj9VfHzw9J17P8V8gu95PWWLYnmrnpuAK9T7o4695zZSDOoO klkcSP5ftE54HyuyJ1K1Jvsp6ApJNAGXfrp229yI8rGss5ML44D58+326Hrw92mXiY HG/BzBHwJd4hB+PX+v72jW1QJoxzkXH15IUWNrStS5oX6KGrscXIM9O254JNhgKXEV fh4bG9V/OkMSWm3ygJJWJS1a6cT8r/WGqmxgo2K7YucGhMxqJAkTSKfDOz6u782t3s OzOWCw44zBQ6GzLW+eQDjfVLH7/Qia7KvcMwJkI9OTNruVLcshSqnMpkaUHrTUqw0a 4OJztpxRzBj8w== From: Philipp Stanner To: Bjorn Helgaas Cc: linux-pci@vger.kernel.org, Philipp Stanner Subject: [PATCH v2 1/3] PCI: Deprecate public devres reversal functions Date: Thu, 3 Dec 2026 13:53:28 +0100 Message-ID: <20261203125328.2421736-4-phasta@kernel.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261203125328.2421736-3-phasta@kernel.org> References: <20261203125328.2421736-3-phasta@kernel.org> X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The PCI devres API has become a bit inconsistent. Devres is intended to fully manage the device resources automatically, i.e., they get released on driver unbind. However, APIs were added to PCI devres that allow to revert another's actions. For example, pcim_iomap() creates an automatically released mapping, and yet pcim_iounmap() exists to *manually* release it. This has confused users in the past. Some ended up freeing resources with said interfaces manually in their remove() implementation, despite the entire point being that exactly this is done automatically by devres. Nevertheless, sometimes users want or need manual resource management, for example in suspend() and resume() paths. In these cases, they should fully manage their resources manually. Mark all manual release functions as deprecated and tell users what they should do instead. Signed-off-by: Philipp Stanner --- drivers/pci/devres.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/pci/devres.c b/drivers/pci/devres.c index f075e7881c3a..48451581516a 100644 --- a/drivers/pci/devres.c +++ b/drivers/pci/devres.c @@ -522,8 +522,7 @@ static void pcim_remove_bar_from_legacy_table(struct pci_dev *pdev, int bar) * * Returns: __iomem pointer on success, NULL on failure. * - * Managed pci_iomap(). Map is automatically unmapped on driver detach. If - * desired, unmap manually only with pcim_iounmap(). + * Managed pci_iomap(). Map is automatically unmapped on driver detach. * * This SHOULD only be used once per BAR. * @@ -565,12 +564,16 @@ void __iomem *pcim_iomap(struct pci_dev *pdev, int bar, unsigned long maxlen) EXPORT_SYMBOL(pcim_iomap); /** - * pcim_iounmap - Managed pci_iounmap() + * pcim_iounmap - Managed pci_iounmap() (DEPRECATED) * @pdev: PCI device to iounmap for * @addr: Address to unmap * * Managed pci_iounmap(). @addr must have been mapped using a pcim_* mapping * function. + * + * This function is deprecated (at least for external users). If you're ever in + * a position where it seems useful, you should manage your IO-mappings fully + * manually, e.g., with pci_iomap(). */ void pcim_iounmap(struct pci_dev *pdev, void __iomem *addr) { @@ -640,12 +643,16 @@ void __iomem *pcim_iomap_region(struct pci_dev *pdev, int bar, EXPORT_SYMBOL(pcim_iomap_region); /** - * pcim_iounmap_region - Unmap and release a PCI BAR + * pcim_iounmap_region - Unmap and release a PCI BAR (DEPRECATED) * @pdev: PCI device to operate on * @bar: Index of BAR to unmap and release * * Unmap a BAR and release its region manually. Only pass BARs that were * previously mapped by pcim_iomap_region(). + * + * This function is deprecated (at least for external users). If you're ever in + * a position where it seems useful, you should manage your regions fully + * manually with unmanaged pci_ interfaces. */ void pcim_iounmap_region(struct pci_dev *pdev, int bar) { @@ -825,8 +832,7 @@ EXPORT_SYMBOL(pcim_request_all_regions); * Creates a new IO-Mapping within the specified @bar, ranging from @offset to * @offset + @len. * - * The mapping will automatically get unmapped on driver detach. If desired, - * release manually only with pcim_iounmap(). + * The mapping will automatically get unmapped on driver detach. */ void __iomem *pcim_iomap_range(struct pci_dev *pdev, int bar, unsigned long offset, unsigned long len) -- 2.56.0