Skip to content

Commit 51f6aec

Browse files
Philipp Stannerkwilczynski
authored andcommitted
PCI: Remove hybrid devres nature from request functions
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 <[email protected]> Signed-off-by: Krzysztof Wilczyński <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Reviewed-by: Kuppuswamy Sathyanarayanan <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 855c634 commit 51f6aec

File tree

3 files changed

+13
-71
lines changed

3 files changed

+13
-71
lines changed

drivers/pci/devres.c

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,13 @@
66
/*
77
* On the state of PCI's devres implementation:
88
*
9-
* The older devres API for PCI has two significant problems:
10-
*
11-
* 1. It is very strongly tied to the statically allocated mapping table in
12-
* struct pcim_iomap_devres below. This is mostly solved in the sense of the
13-
* pcim_ functions in this file providing things like ranged mapping by
14-
* bypassing this table, whereas the functions that were present in the old
15-
* API still enter the mapping addresses into the table for users of the old
16-
* API.
17-
*
18-
* 2. The region-request-functions in pci.c do become managed IF the device has
19-
* been enabled with pcim_enable_device() instead of pci_enable_device().
20-
* This resulted in the API becoming inconsistent: Some functions have an
21-
* obviously managed counter-part (e.g., pci_iomap() <-> pcim_iomap()),
22-
* whereas some don't and are never managed, while others don't and are
23-
* _sometimes_ managed (e.g. pci_request_region()).
24-
*
25-
* Consequently, in the new API, region requests performed by the pcim_
26-
* functions are automatically cleaned up through the devres callback
27-
* pcim_addr_resource_release().
28-
*
29-
* Users of pcim_enable_device() + pci_*region*() are redirected in
30-
* pci.c to the managed functions here in this file. This isn't exactly
31-
* perfect, but the only alternative way would be to port ALL drivers
32-
* using said combination to pcim_ functions.
9+
* The older PCI devres API has one significant problem:
10+
*
11+
* It is very strongly tied to the statically allocated mapping table in struct
12+
* pcim_iomap_devres below. This is mostly solved in the sense of the pcim_
13+
* functions in this file providing things like ranged mapping by bypassing
14+
* this table, whereas the functions that were present in the old API still
15+
* enter the mapping addresses into the table for users of the old API.
3316
*
3417
* TODO:
3518
* 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)
8972

9073
/*
9174
* The following functions, __pcim_*_region*, exist as counterparts to the
92-
* versions from pci.c - which, unfortunately, can be in "hybrid mode", i.e.,
93-
* sometimes managed, sometimes not.
75+
* versions from pci.c - which, unfortunately, were in the past in "hybrid
76+
* mode", i.e., sometimes managed, sometimes not.
77+
*
78+
* To separate the APIs cleanly, we defined our own, simplified versions here.
9479
*
95-
* To separate the APIs cleanly, we define our own, simplified versions here.
80+
* TODO: unify those functions with the counterparts in pci.c
9681
*/
9782

9883
/**
@@ -893,7 +878,7 @@ int pcim_request_region_exclusive(struct pci_dev *pdev, int bar, const char *nam
893878
* Release a region manually that was previously requested by
894879
* pcim_request_region().
895880
*/
896-
void pcim_release_region(struct pci_dev *pdev, int bar)
881+
static void pcim_release_region(struct pci_dev *pdev, int bar)
897882
{
898883
struct pcim_addr_devres res_searched;
899884

drivers/pci/pci.c

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3937,16 +3937,6 @@ void pci_release_region(struct pci_dev *pdev, int bar)
39373937
if (!pci_bar_index_is_valid(bar))
39383938
return;
39393939

3940-
/*
3941-
* This is done for backwards compatibility, because the old PCI devres
3942-
* API had a mode in which the function became managed if it had been
3943-
* enabled with pcim_enable_device() instead of pci_enable_device().
3944-
*/
3945-
if (pci_is_managed(pdev)) {
3946-
pcim_release_region(pdev, bar);
3947-
return;
3948-
}
3949-
39503940
if (pci_resource_len(pdev, bar) == 0)
39513941
return;
39523942
if (pci_resource_flags(pdev, bar) & IORESOURCE_IO)
@@ -3984,13 +3974,6 @@ static int __pci_request_region(struct pci_dev *pdev, int bar,
39843974
if (!pci_bar_index_is_valid(bar))
39853975
return -EINVAL;
39863976

3987-
if (pci_is_managed(pdev)) {
3988-
if (exclusive == IORESOURCE_EXCLUSIVE)
3989-
return pcim_request_region_exclusive(pdev, bar, name);
3990-
3991-
return pcim_request_region(pdev, bar, name);
3992-
}
3993-
39943977
if (pci_resource_len(pdev, bar) == 0)
39953978
return 0;
39963979

@@ -4027,11 +4010,6 @@ static int __pci_request_region(struct pci_dev *pdev, int bar,
40274010
*
40284011
* Returns 0 on success, or %EBUSY on error. A warning
40294012
* message is also printed on failure.
4030-
*
4031-
* NOTE:
4032-
* This is a "hybrid" function: It's normally unmanaged, but becomes managed
4033-
* when pcim_enable_device() has been called in advance. This hybrid feature is
4034-
* DEPRECATED! If you want managed cleanup, use the pcim_* functions instead.
40354013
*/
40364014
int pci_request_region(struct pci_dev *pdev, int bar, const char *name)
40374015
{
@@ -4084,11 +4062,6 @@ static int __pci_request_selected_regions(struct pci_dev *pdev, int bars,
40844062
* @name: Name of the driver requesting the resources
40854063
*
40864064
* Returns: 0 on success, negative error code on failure.
4087-
*
4088-
* NOTE:
4089-
* This is a "hybrid" function: It's normally unmanaged, but becomes managed
4090-
* when pcim_enable_device() has been called in advance. This hybrid feature is
4091-
* DEPRECATED! If you want managed cleanup, use the pcim_* functions instead.
40924065
*/
40934066
int pci_request_selected_regions(struct pci_dev *pdev, int bars,
40944067
const char *name)
@@ -4104,11 +4077,6 @@ EXPORT_SYMBOL(pci_request_selected_regions);
41044077
* @name: name of the driver requesting the resources
41054078
*
41064079
* Returns: 0 on success, negative error code on failure.
4107-
*
4108-
* NOTE:
4109-
* This is a "hybrid" function: It's normally unmanaged, but becomes managed
4110-
* when pcim_enable_device() has been called in advance. This hybrid feature is
4111-
* DEPRECATED! If you want managed cleanup, use the pcim_* functions instead.
41124080
*/
41134081
int pci_request_selected_regions_exclusive(struct pci_dev *pdev, int bars,
41144082
const char *name)
@@ -4144,11 +4112,6 @@ EXPORT_SYMBOL(pci_release_regions);
41444112
*
41454113
* Returns 0 on success, or %EBUSY on error. A warning
41464114
* message is also printed on failure.
4147-
*
4148-
* NOTE:
4149-
* This is a "hybrid" function: It's normally unmanaged, but becomes managed
4150-
* when pcim_enable_device() has been called in advance. This hybrid feature is
4151-
* DEPRECATED! If you want managed cleanup, use the pcim_* functions instead.
41524115
*/
41534116
int pci_request_regions(struct pci_dev *pdev, const char *name)
41544117
{
@@ -4173,11 +4136,6 @@ EXPORT_SYMBOL(pci_request_regions);
41734136
*
41744137
* Returns 0 on success, or %EBUSY on error. A warning message is also
41754138
* printed on failure.
4176-
*
4177-
* NOTE:
4178-
* This is a "hybrid" function: It's normally unmanaged, but becomes managed
4179-
* when pcim_enable_device() has been called in advance. This hybrid feature is
4180-
* DEPRECATED! If you want managed cleanup, use the pcim_* functions instead.
41814139
*/
41824140
int pci_request_regions_exclusive(struct pci_dev *pdev, const char *name)
41834141
{

drivers/pci/pci.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1062,7 +1062,6 @@ static inline pci_power_t mid_pci_get_power_state(struct pci_dev *pdev)
10621062
int pcim_intx(struct pci_dev *dev, int enable);
10631063
int pcim_request_region_exclusive(struct pci_dev *pdev, int bar,
10641064
const char *name);
1065-
void pcim_release_region(struct pci_dev *pdev, int bar);
10661065

10671066
/*
10681067
* Config Address for PCI Configuration Mechanism #1

0 commit comments

Comments
 (0)