linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sathyanarayanan Kuppuswamy <sathyanarayanan.kuppuswamy@linux.intel.com>
To: "Philipp Stanner" <phasta@kernel.org>,
	"Jonathan Corbet" <corbet@lwn.net>,
	"Bjorn Helgaas" <bhelgaas@google.com>,
	"Mark Brown" <broonie@kernel.org>,
	"David Lechner" <dlechner@baylibre.com>,
	"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
	"Zijun Hu" <quic_zijuhu@quicinc.com>,
	"Yang Yingliang" <yangyingliang@huawei.com>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Krzysztof Wilczyński" <kw@linux.com>
Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-pci@vger.kernel.org
Subject: Re: [PATCH v2 1/6] PCI: Remove hybrid devres nature from request functions
Date: Fri, 16 May 2025 15:58:59 -0700	[thread overview]
Message-ID: <99dba1da-4fc6-4e35-a6fc-40233144f7dd@linux.intel.com> (raw)
In-Reply-To: <20250516174141.42527-2-phasta@kernel.org>

Hi,

On 5/16/25 10:41 AM, Philipp Stanner wrote:
> All functions based on __pci_request_region() and its release counter
> part support "hybrid mode", where the functions become managed if the
> PCI device was enabled with pcim_enable_device().
>
> Removing this undesirable feature requires to remove all users who
> activated their device with that function and use one of the affected
> request functions.
>
> These users were:
> 	ASoC
> 	alsa
> 	cardreader
> 	cirrus
> 	i2c
> 	mmc
> 	mtd
> 	mtd
> 	mxser
> 	net
> 	spi
> 	vdpa
> 	vmwgfx
>
> all of which have been ported to always-managed pcim_ functions by now.
>
> The hybrid nature can, thus, be removed from the aforementioned PCI
> functions.
>
> Remove all function guards and documentation in pci.c related to the
> hybrid redirection. Adjust the visibility of pcim_release_region().
>
> Signed-off-by: Philipp Stanner <phasta@kernel.org>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---

Reviewed-by: Kuppuswamy Sathyanarayanan 
<sathyanarayanan.kuppuswamy@linux.intel.com>

>   drivers/pci/devres.c | 39 ++++++++++++---------------------------
>   drivers/pci/pci.c    | 42 ------------------------------------------
>   drivers/pci/pci.h    |  1 -
>   3 files changed, 12 insertions(+), 70 deletions(-)
>
> diff --git a/drivers/pci/devres.c b/drivers/pci/devres.c
> index 73047316889e..5480d537f400 100644
> --- a/drivers/pci/devres.c
> +++ b/drivers/pci/devres.c
> @@ -6,30 +6,13 @@
>   /*
>    * On the state of PCI's devres implementation:
>    *
> - * The older devres API for PCI has two significant problems:
> + * The older PCI devres API has one significant problem:
>    *
> - * 1. It is very strongly tied to the statically allocated mapping table in
> - *    struct pcim_iomap_devres below. This is mostly solved in the sense of the
> - *    pcim_ functions in this file providing things like ranged mapping by
> - *    bypassing this table, whereas the functions that were present in the old
> - *    API still enter the mapping addresses into the table for users of the old
> - *    API.
> - *
> - * 2. The region-request-functions in pci.c do become managed IF the device has
> - *    been enabled with pcim_enable_device() instead of pci_enable_device().
> - *    This resulted in the API becoming inconsistent: Some functions have an
> - *    obviously managed counter-part (e.g., pci_iomap() <-> pcim_iomap()),
> - *    whereas some don't and are never managed, while others don't and are
> - *    _sometimes_ managed (e.g. pci_request_region()).
> - *
> - *    Consequently, in the new API, region requests performed by the pcim_
> - *    functions are automatically cleaned up through the devres callback
> - *    pcim_addr_resource_release().
> - *
> - *    Users of pcim_enable_device() + pci_*region*() are redirected in
> - *    pci.c to the managed functions here in this file. This isn't exactly
> - *    perfect, but the only alternative way would be to port ALL drivers
> - *    using said combination to pcim_ functions.
> + * It is very strongly tied to the statically allocated mapping table in struct
> + * pcim_iomap_devres below. This is mostly solved in the sense of the pcim_
> + * functions in this file providing things like ranged mapping by bypassing
> + * this table, whereas the functions that were present in the old API still
> + * enter the mapping addresses into the table for users of the old API.
>    *
>    * TODO:
>    * Remove the legacy table entirely once all calls to pcim_iomap_table() in
> @@ -89,10 +72,12 @@ static inline void pcim_addr_devres_clear(struct pcim_addr_devres *res)
>   
>   /*
>    * The following functions, __pcim_*_region*, exist as counterparts to the
> - * versions from pci.c - which, unfortunately, can be in "hybrid mode", i.e.,
> - * sometimes managed, sometimes not.
> + * versions from pci.c - which, unfortunately, were in the past in "hybrid
> + * mode", i.e., sometimes managed, sometimes not.

Why not remove "hybrid mode"  reference like other places?

>    *
> - * To separate the APIs cleanly, we define our own, simplified versions here.
> + * To separate the APIs cleanly, we defined our own, simplified versions here.
> + *
> + * TODO: unify those functions with the counterparts in pci.c
>    */
>   
>   /**
> @@ -893,7 +878,7 @@ int pcim_request_region_exclusive(struct pci_dev *pdev, int bar, const char *nam
>    * Release a region manually that was previously requested by
>    * pcim_request_region().
>    */
> -void pcim_release_region(struct pci_dev *pdev, int bar)
> +static void pcim_release_region(struct pci_dev *pdev, int bar)
>   {
>   	struct pcim_addr_devres res_searched;
>   
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index e77d5b53c0ce..4acc23823637 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -3937,16 +3937,6 @@ void pci_release_region(struct pci_dev *pdev, int bar)
>   	if (!pci_bar_index_is_valid(bar))
>   		return;
>   
> -	/*
> -	 * This is done for backwards compatibility, because the old PCI devres
> -	 * API had a mode in which the function became managed if it had been
> -	 * enabled with pcim_enable_device() instead of pci_enable_device().
> -	 */
> -	if (pci_is_managed(pdev)) {
> -		pcim_release_region(pdev, bar);
> -		return;
> -	}
> -
>   	if (pci_resource_len(pdev, bar) == 0)
>   		return;
>   	if (pci_resource_flags(pdev, bar) & IORESOURCE_IO)
> @@ -3984,13 +3974,6 @@ static int __pci_request_region(struct pci_dev *pdev, int bar,
>   	if (!pci_bar_index_is_valid(bar))
>   		return -EINVAL;
>   
> -	if (pci_is_managed(pdev)) {
> -		if (exclusive == IORESOURCE_EXCLUSIVE)
> -			return pcim_request_region_exclusive(pdev, bar, name);
> -
> -		return pcim_request_region(pdev, bar, name);
> -	}
> -
>   	if (pci_resource_len(pdev, bar) == 0)
>   		return 0;
>   
> @@ -4027,11 +4010,6 @@ static int __pci_request_region(struct pci_dev *pdev, int bar,
>    *
>    * Returns 0 on success, or %EBUSY on error.  A warning
>    * message is also printed on failure.
> - *
> - * NOTE:
> - * This is a "hybrid" function: It's normally unmanaged, but becomes managed
> - * when pcim_enable_device() has been called in advance. This hybrid feature is
> - * DEPRECATED! If you want managed cleanup, use the pcim_* functions instead.
>    */
>   int pci_request_region(struct pci_dev *pdev, int bar, const char *name)
>   {
> @@ -4084,11 +4062,6 @@ static int __pci_request_selected_regions(struct pci_dev *pdev, int bars,
>    * @name: Name of the driver requesting the resources
>    *
>    * Returns: 0 on success, negative error code on failure.
> - *
> - * NOTE:
> - * This is a "hybrid" function: It's normally unmanaged, but becomes managed
> - * when pcim_enable_device() has been called in advance. This hybrid feature is
> - * DEPRECATED! If you want managed cleanup, use the pcim_* functions instead.
>    */
>   int pci_request_selected_regions(struct pci_dev *pdev, int bars,
>   				 const char *name)
> @@ -4104,11 +4077,6 @@ EXPORT_SYMBOL(pci_request_selected_regions);
>    * @name: name of the driver requesting the resources
>    *
>    * Returns: 0 on success, negative error code on failure.
> - *
> - * NOTE:
> - * This is a "hybrid" function: It's normally unmanaged, but becomes managed
> - * when pcim_enable_device() has been called in advance. This hybrid feature is
> - * DEPRECATED! If you want managed cleanup, use the pcim_* functions instead.
>    */
>   int pci_request_selected_regions_exclusive(struct pci_dev *pdev, int bars,
>   					   const char *name)
> @@ -4144,11 +4112,6 @@ EXPORT_SYMBOL(pci_release_regions);
>    *
>    * Returns 0 on success, or %EBUSY on error.  A warning
>    * message is also printed on failure.
> - *
> - * NOTE:
> - * This is a "hybrid" function: It's normally unmanaged, but becomes managed
> - * when pcim_enable_device() has been called in advance. This hybrid feature is
> - * DEPRECATED! If you want managed cleanup, use the pcim_* functions instead.
>    */
>   int pci_request_regions(struct pci_dev *pdev, const char *name)
>   {
> @@ -4173,11 +4136,6 @@ EXPORT_SYMBOL(pci_request_regions);
>    *
>    * Returns 0 on success, or %EBUSY on error.  A warning message is also
>    * printed on failure.
> - *
> - * NOTE:
> - * This is a "hybrid" function: It's normally unmanaged, but becomes managed
> - * when pcim_enable_device() has been called in advance. This hybrid feature is
> - * DEPRECATED! If you want managed cleanup, use the pcim_* functions instead.
>    */
>   int pci_request_regions_exclusive(struct pci_dev *pdev, const char *name)
>   {
> diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
> index b81e99cd4b62..8c3e5fb2443a 100644
> --- a/drivers/pci/pci.h
> +++ b/drivers/pci/pci.h
> @@ -1062,7 +1062,6 @@ static inline pci_power_t mid_pci_get_power_state(struct pci_dev *pdev)
>   int pcim_intx(struct pci_dev *dev, int enable);
>   int pcim_request_region_exclusive(struct pci_dev *pdev, int bar,
>   				  const char *name);
> -void pcim_release_region(struct pci_dev *pdev, int bar);
>   

Since you removed the only use of pcim_request_region_exclusive(), why 
not remove the definition in the same patch?
>   /*
>    * Config Address for PCI Configuration Mechanism #1

-- 
Sathyanarayanan Kuppuswamy
Linux Kernel Developer


  reply	other threads:[~2025-05-16 22:59 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-16 17:41 [PATCH v2 0/6] PCI: Remove hybrid-devres region requests Philipp Stanner
2025-05-16 17:41 ` [PATCH v2 1/6] PCI: Remove hybrid devres nature from request functions Philipp Stanner
2025-05-16 22:58   ` Sathyanarayanan Kuppuswamy [this message]
2025-05-16 23:14     ` Sathyanarayanan Kuppuswamy
2025-05-19  7:33     ` Philipp Stanner
2025-05-16 17:41 ` [PATCH v2 2/6] Documentation/driver-api: Update pcim_enable_device() Philipp Stanner
2025-05-16 19:27   ` Randy Dunlap
2025-05-16 21:02   ` ALOK TIWARI
2025-05-16 17:41 ` [PATCH v2 3/6] PCI: Remove pcim_request_region_exclusive() Philipp Stanner
2025-05-16 17:41 ` [PATCH v2 4/6] PCI: Remove request_flags relict from devres Philipp Stanner
2025-05-16 17:41 ` [PATCH v2 5/6] PCI: Remove redundant set of request funcs Philipp Stanner
2025-05-16 17:41 ` [PATCH v2 6/6] PCI: Remove hybrid-devres hazzard warnings from doc Philipp Stanner
2025-05-16 18:25 ` [PATCH v2 0/6] PCI: Remove hybrid-devres region requests Krzysztof Wilczyński
2025-05-16 23:14 ` Sathyanarayanan Kuppuswamy
2025-05-17 16:33   ` Andy Shevchenko
2025-05-17 17:13     ` Sathyanarayanan Kuppuswamy

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=99dba1da-4fc6-4e35-a6fc-40233144f7dd@linux.intel.com \
    --to=sathyanarayanan.kuppuswamy@linux.intel.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=bhelgaas@google.com \
    --cc=broonie@kernel.org \
    --cc=corbet@lwn.net \
    --cc=dlechner@baylibre.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kw@linux.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=phasta@kernel.org \
    --cc=quic_zijuhu@quicinc.com \
    --cc=yangyingliang@huawei.com \
    /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;
as well as URLs for NNTP newsgroup(s).