From: Philipp Stanner <phasta@kernel.org>
To: Bjorn Helgaas <bhelgaas@google.com>
Cc: linux-pci@vger.kernel.org, Philipp Stanner <phasta@kernel.org>
Subject: [PATCH 1/3] PCI: Deprecate public devres reversal functions
Date: Tue, 1 Dec 2026 13:29:50 +0100 [thread overview]
Message-ID: <20261201122951.904104-3-phasta@kernel.org> (raw)
In-Reply-To: <20261201122951.904104-2-phasta@kernel.org>
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 manually 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 <phasta@kernel.org>
---
drivers/pci/devres.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/pci/devres.c b/drivers/pci/devres.c
index f075e7881c3a..9a085fb18100 100644
--- a/drivers/pci/devres.c
+++ b/drivers/pci/devres.c
@@ -565,12 +565,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 +644,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, e.g., with pci_iomap_region().
*/
void pcim_iounmap_region(struct pci_dev *pdev, int bar)
{
--
2.56.0
next prev parent reply other threads:[~2026-12-01 12:30 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 12:29 [PATCH 0/3] PCI: Improve devres documentation Philipp Stanner
2026-12-01 12:29 ` Philipp Stanner [this message]
2026-12-01 12:40 ` [PATCH 1/3] PCI: Deprecate public devres reversal functions sashiko-bot
2026-12-01 12:29 ` [PATCH 2/3] PCI: Better document pcim_enable_device() Philipp Stanner
2026-12-01 12:29 ` [PATCH 3/3] PCI: Deprecate pcim_pin_device() Philipp Stanner
2026-12-01 12:40 ` [PATCH 0/3] PCI: Improve devres documentation sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261201122951.904104-3-phasta@kernel.org \
--to=phasta@kernel.org \
--cc=bhelgaas@google.com \
--cc=linux-pci@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox