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=1796128224; b=vNf7Wb9WDJQroG5qg2fk7UvWqW6xgjD4XBTdxIsKXg5OTpC8YyCvvMqjGAaaDc5pdLuv 7YYzP+CbjaX3P58jzNIGxdZwNW5fgnYz56POepHw9ngUfDsnpEAbpAH+b4GNLixJjYUvT PVV9GC2vkcg6PaG82L7F8WF41z0hcw/443ot+GieBDIawDpj1K2ftHSkQJ/n1BoYO2WA+ 574wP8U2/xjuitKfiG4Yt2P9E4cC6OxX4/MTcXfryiZ96TZdxi4xrip+LMxTDXYmYVuAY 0W/jepDCAljJ8PhgCCzQ+6oRpNnYbiXG2MK93UVbfOYb8NUmNPFT5VROw6vVnwb037Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796128224; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=aFmBKY/A05Rw7vQE47k8QEP/H1rFkD1wHYVr+ypoa3U=; b=JrrOpllDT5E1sXnm+yQKxI8xCsL9u5JF7y2cfYbj/X4FdnGcGKD+7O34U3/s3vyjYa+k rC2WBb0lBejv9NGkVb5Fl95o/S/eA8L4Cu26C+wbuV9lh8h7foVUIYj7NcLhDt/xIV+Gc gvdY6Wfb59dRVhud2f9cJwvjvyeilRiFcVmvTIGzfIuCLBHz0vhG+1pHAJZGhfFo6Eshj pkAfFjAV2AdpnUkBx8mHHjgtk+s3BhhnY6/2NaWX3bYiI4TO2JQJJq5oX5a7LwFiV0gsu AWpAm92KOsVSIz8uMuEXsoTE8hJzMAaXK3vf0UuTle0OOftHLDq5UcQ8XScim+Uh2Ng== 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=isw9KbaA; 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 7035B606A325 for ; Tue, 1 Dec 2026 12:30:24 +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=isw9KbaA Received: by smtp.kernel.org (Postfix) with ESMTPSA id 51C761F00897; Tue, 1 Dec 2026 12:30:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796128224; bh=aFmBKY/A05Rw7vQE47k8QEP/H1rFkD1wHYVr+ypoa3U=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=isw9KbaAIIiD27cWe4OfWIiuF4MGYoLBPHG7SnYvcS4rJBAX1+0i4Mql5wVtsggyb rqrYMLynJ2NCnyeCwdZLkyYrgHCtroEfLSXgw8DK1V9RVSPOsDtmp1+JHRMkbyblBS JwPcxT4MJYBSyaJHpL8b/sxPyF6pK7VdswnmK5m7faus2e1p8hYc1AA0jXEPXCQ+PQ 9LAAk+/I8WOoaIbT79awU9sJz7s5NAeqfnFvEnV7HfW7QyxSLI7FBUOqufEqaN2cWP WCtMtDjuQsQ0/lT0sC2GdsCik+sPSZ58LjEooHYxE30ZLyZHONrHiNCBpUtR8a8yRz NFEHfFSvM2ogQ== From: Philipp Stanner To: Bjorn Helgaas Cc: linux-pci@vger.kernel.org, Philipp Stanner Subject: [PATCH 1/3] PCI: Deprecate public devres reversal functions Date: Tue, 1 Dec 2026 13:29:50 +0100 Message-ID: <20261201122951.904104-3-phasta@kernel.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261201122951.904104-2-phasta@kernel.org> References: <20261201122951.904104-2-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 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 --- 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