Introduce pci_(request|release)_(mem|io)_regions
Subsystems (10)
v2 cover Introduce pci_(request|release)_(mem|io)_regions
The first patch in this series introduces the following 4 helper functions to the PCI core:
* pci_request_mem_regions()
* pci_request_io_regions()
* pci_release_mem_regions()
* pci_release_io_regions()
which encapsulate the request and release of a PCI device's memory or I/O bars.
The subsequent patches convert the drivers, which use the pci_request_selected_regions(pdev,
pci_select_bars(pdev, IORESOURCE_MEM), name);
and similar pattern to use the new interface.
This was suggested by Christoph Hellwig in
http://lists.infradead.org/pipermail/linux-nvme/2016-May/004570.html and tested on kernel v4.6 with NVMe.
The conversion of the drivers has been performed by the following coccinelle spatch:
// IORESOURCE_MEM
@@
expression err, pdev, name;
@@
- err = pci_request_selected_regions(pdev, pci_select_bars(pdev, IORESOURCE_MEM), name);
+ err = pci_request_mem_regions(pdev, name);
@@
expression pdev;
@@
- pci_release_selected_regions(pdev, pci_select_bars(pdev, IORESOURCE_MEM));
+ pci_release_mem_regions(pdev);
@@
expression err, pdev, name;
identifier bars;
@@
- bars = pci_select_bars(pdev, IORESOURCE_MEM);
...
- err = pci_request_selected_regions(pdev, bars, name);
+ err = pci_request_mem_regions(pdev, name);
@@
expression pdev;
identifier bars;
@@
- bars = pci_select_bars(pdev, IORESOURCE_MEM);
...
- pci_release_selected_regions(pdev, bars);
+ pci_release_mem_regions(pdev);
// IORESOURCE_IO
@@
expression err, pdev, name;
@@
- err = pci_request_selected_regions(pdev, pci_select_bars(pdev, IORESOURCE_IO), name);
+ err = pci_request_io_regions(pdev, name);
@@
expression pdev;
@@
- pci_release_selected_regions(pdev, pci_select_bars(pdev, IORESOURCE_IO));
+ pci_release_io_regions(pdev);
@@
expression err, pdev, name;
identifier bars;
@@
- bars = pci_select_bars(pdev, IORESOURCE_IO);
...
- err = pci_request_selected_regions(pdev, bars, name);
+ err = pci_request_io_regions(pdev, name);
@@
expression pdev;
identifier bars;
@@
- bars = pci_select_bars(pdev, IORESOURCE_IO);
...
- pci_release_selected_regions(pdev, bars);
+ pci_release_io_regions(pdev);
Changes since v1:
* Fixed indendatoin in pci.h patch to not cross the 80 chars boundary.
* Split Ethernet patches into two, one for Atheros and one for Intel drivers.
* Correctly named lpfc patch.
* Converted init-path of lpfc driver as well.
* Added Reviewed-by tags were appropriate.
Johannes Thumshirn (6):
PCI: Add helpers to request/release memory and I/O regions
NVMe: Use pci_(request|release)_mem_regions
lpfc: Use pci_(request|release)_mem_regions
GenWQE: Use pci_(request|release)_mem_regions ethernet/intel: Use pci_(request|release)_mem_regions
alx: Use pci_(request|release)_mem_regions
drivers/misc/genwqe/card_base.c | 13 +++++-------- drivers/net/ethernet/atheros/alx/main.c | 12 +++++------- drivers/net/ethernet/intel/e1000e/netdev.c | 6 ++---- drivers/net/ethernet/intel/fm10k/fm10k_pci.c | 11 +++-------- drivers/net/ethernet/intel/i40e/i40e_main.c | 9 +++------ drivers/net/ethernet/intel/igb/igb_main.c | 10 +++------- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 9 +++------ drivers/nvme/host/pci.c | 10 +++------- drivers/scsi/lpfc/lpfc_init.c | 15 ++++---------- include/linux/pci.h | 28 +++++++++++++++++++++++++++ 10 files changed, 59 insertions(+), 64 deletions(-)
Signature · 1 line
1.8.5.6
PATCH v2 1/6 PCI: Add helpers to request/release memory and I/O regions
Add helpers to request and release a device's memory or I/O regions.
With these helpers in place, one does not need to select a device's memory or I/O regions with pci_select_bars() prior to requesting or releasing them.
--- include/linux/pci.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
include/linux/pci.h +28 -0
@@ -2007,6 +2007,34 @@ static inline bool pci_is_dev_assigned(struct pci_dev *pdev)return (pdev->dev_flags &PCI_DEV_FLAGS_ASSIGNED ) ==PCI_DEV_FLAGS_ASSIGNED ; } +static inline int +pci_request_io_regions (struct pci_dev *pdev,const char *name) +{ +return pci_request_selected_regions (pdev, +pci_select_bars (pdev,IORESOURCE_IO ), name); +} + +static inline void +pci_release_io_regions (struct pci_dev *pdev) +{ +return pci_release_selected_regions (pdev, +pci_select_bars (pdev,IORESOURCE_IO )); +} + +static inline int +pci_request_mem_regions (struct pci_dev *pdev,const char *name) +{ +return pci_request_selected_regions (pdev, +pci_select_bars (pdev,IORESOURCE_MEM ), name); +} + +static inline void +pci_release_mem_regions (struct pci_dev *pdev) +{ +return pci_release_selected_regions (pdev, +pci_select_bars (pdev,IORESOURCE_MEM )); +} +/** * pci_ari_enabled - query ARI forwarding status * @bus: the PCI bus
Signature · 1 line
1.8.5.6
kbuild test robot
build botRe: [PATCH v2 1/6] PCI: Add helpers to request/release memory and I/O regions
reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree…
Hi,
[auto build test ERROR on jkirsher-next-queue/dev-queue]
[also build test ERROR on v4.7-rc1 next-20160603]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Johannes-Thumshirn/Introduce-pci_-request-release-_-mem-io-_regions/20160602-153400 base: https://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/next-queue.git dev-queue config: arm-trizeps4_defconfig (attached as .config) compiler: arm-linux-gnueabi-gcc (Debian 5.3.1-8) 5.3.1 20160205
reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm
All errors (new ones prefixed by >>):
In file included from drivers/hwmon/hwmon.c:24:0:
include/linux/pci.h: In function 'pci_request_io_regions':
include/linux/pci.h:2021:9: error: implicit declaration of function 'pci_request_selected_regions' [-Werror=implicit-function-declaration]
return pci_request_selected_regions(pdev,
^
include/linux/pci.h:2022:8: error: implicit declaration of function 'pci_select_bars' [-Werror=implicit-function-declaration]
pci_select_bars(pdev, IORESOURCE_IO), name);
^
include/linux/pci.h: In function 'pci_release_io_regions':
>> include/linux/pci.h:2028:9: error: implicit declaration of function 'pci_release_selected_regions' [-Werror=implicit-function-declaration]
return pci_release_selected_regions(pdev,
^
include/linux/pci.h:2028:9: warning: 'return' with a value, in function returning void
include/linux/pci.h: In function 'pci_release_mem_regions':
include/linux/pci.h:2042:9: warning: 'return' with a value, in function returning void
return pci_release_selected_regions(pdev,
^cc1: some warnings being treated as errors
vim +/pci_release_selected_regions +2028 include/linux/pci.h
2015 return (pdev->dev_flags & PCI_DEV_FLAGS_ASSIGNED) == PCI_DEV_FLAGS_ASSIGNED;
2016 }
2017
2018 static inline int
2019 pci_request_io_regions(struct pci_dev *pdev, const char *name)
2020 {
> 2021 return pci_request_selected_regions(pdev,
2022 pci_select_bars(pdev, IORESOURCE_IO), name);
2023 }
2024
2025 static inline void
2026 pci_release_io_regions(struct pci_dev *pdev)
2027 {
> 2028 return pci_release_selected_regions(pdev, 2029 pci_select_bars(pdev, IORESOURCE_IO));
2030 }
2031
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
kbuild test robot
build botRe: [PATCH v2 1/6] PCI: Add helpers to request/release memory and I/O regions
In reply to Johannes Thumshirnreproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree…
Hi,
[auto build test ERROR on jkirsher-next-queue/dev-queue]
[also build test ERROR on v4.7-rc1 next-20160603]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Johannes-Thumshirn/Introduce-pci_-request-release-_-mem-io-_regions/20160602-153400 base: https://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/next-queue.git dev-queue config: mips-rt305x_defconfig (attached as .config) compiler: mips-linux-gnu-gcc (Debian 5.3.1-8) 5.3.1 20160205
reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=mips
All errors (new ones prefixed by >>):
In file included from lib/pci_iomap.c:6:0:
include/linux/pci.h: In function 'pci_request_io_regions':
>> include/linux/pci.h:2021:9: error: implicit declaration of function 'pci_request_selected_regions' [-Werror=implicit-function-declaration]
return pci_request_selected_regions(pdev,
^
>> include/linux/pci.h:2022:8: error: implicit declaration of function 'pci_select_bars' [-Werror=implicit-function-declaration]
pci_select_bars(pdev, IORESOURCE_IO), name);
^
include/linux/pci.h: In function 'pci_release_io_regions':
include/linux/pci.h:2028:9: error: implicit declaration of function 'pci_release_selected_regions' [-Werror=implicit-function-declaration]
return pci_release_selected_regions(pdev,
^
include/linux/pci.h:2028:9: warning: 'return' with a value, in function returning void
include/linux/pci.h: In function 'pci_release_mem_regions':
include/linux/pci.h:2042:9: warning: 'return' with a value, in function returning void
return pci_release_selected_regions(pdev,
^cc1: some warnings being treated as errors
vim +/pci_request_selected_regions +2021 include/linux/pci.h
2015 return (pdev->dev_flags & PCI_DEV_FLAGS_ASSIGNED) == PCI_DEV_FLAGS_ASSIGNED;
2016 }
2017
2018 static inline int
2019 pci_request_io_regions(struct pci_dev *pdev, const char *name)
2020 {
> 2021 return pci_request_selected_regions(pdev, > 2022 pci_select_bars(pdev, IORESOURCE_IO), name);
2023 }
2024
2025 static inline void
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Re: [PATCH v2 1/6] PCI: Add helpers to request/release memory and I/O regions
Quoted 47 lines · kbuild test robot
Hi,
[auto build test ERROR on jkirsher-next-queue/dev-queue]
[also build test ERROR on v4.7-rc1 next-20160603]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]url: https://github.com/0day-ci/linux/commits/Johannes-Thumshirn/Introduce-pci_-request-release-_-mem-io-_regions/20160602-153400 base: https://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/next-queue.git dev-queue config: mips-rt305x_defconfig (attached as .config) compiler: mips-linux-gnu-gcc (Debian 5.3.1-8) 5.3.1 20160205reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=mipsAll errors (new ones prefixed by >>):
In file included from
lib/pci_iomap.c:6:0:
include/linux/pci.h: In function 'pci_request_io_regions':Quoted 1 line
Quoted 1 line
include/linux/pci.h:2021:9: error: implicit declaration of function 'pci_request_selected_regions' [-Werror=implicit-function-declaration]return pci_request_selected_regions(pdev, ^Quoted 1 line
Quoted 1 line
include/linux/pci.h:2022:8: error: implicit declaration of function 'pci_select_bars' [-Werror=implicit-function-declaration]pci_select_bars(pdev, IORESOURCE_IO), name); ^ include/linux/pci.h: In function 'pci_release_io_regions': include/linux/pci.h:2028:9: error: implicit declaration of function 'pci_release_selected_regions' [-Werror=implicit-function-declaration] return pci_release_selected_regions(pdev, ^ include/linux/pci.h:2028:9: warning: 'return' with a value, in function returning void include/linux/pci.h: In function 'pci_release_mem_regions': include/linux/pci.h:2042:9: warning: 'return' with a value, in function returning void return pci_release_selected_regions(pdev, ^cc1: some warnings being treated as errors
vim +/pci_request_selected_regions +2021
include/linux/pci.h2015 return (
pdev->dev_flags&PCI_DEV_FLAGS_ASSIGNED) ==PCI_DEV_FLAGS_ASSIGNED;
2016 }
2017
2018 static inline int
2019pci_request_io_regions(struct pci_dev *pdev, const char *name)
2020 {Quoted 2 lines
2021 return pci_request_selected_regions(pdev,
2022pci_select_bars(pdev, IORESOURCE_IO), name);
Quoted 7 lines
2023 }
2024
2025 static inline void---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Problem got addressed, waiting for an reply from Dick Kenedy on the lpfc patch before re-submission,
Thanks for reporting,
Johannes
Signature · 6 lines
Johannes Thumshirn Storage [email protected] +49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: Felix Imendörffer, Jane Smithard, Graham Norton HRB 21284 (AG Nürnberg) Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
PATCH v2 2/6 NVMe: Use pci_(request|release)_mem_regions
In reply to Johannes ThumshirnNow that we do have pci_request_mem_regions() and pci_release_mem_regions() at hand, use it in the NVMe driver.
--- drivers/nvme/host/pci.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/nvme/host/pci.c +3 -7
@@ -1756,7 +1756,7 @@ static void nvme_dev_unmap(struct nvme_dev *dev) {if (dev->bar)iounmap (dev->bar); -pci_release_regions (to_pci_dev (dev->dev)); +pci_release_mem_regions (to_pci_dev (dev->dev)); }static void nvme_pci_disable (struct nvme_dev *dev)
@@ -1979,13 +1979,9 @@ static const struct nvme_ctrl_ops nvme_pci_ctrl_ops = {static int nvme_dev_map (struct nvme_dev *dev) { -int bars;struct pci_dev *pdev =to_pci_dev (dev->dev); - bars =pci_select_bars (pdev,IORESOURCE_MEM ); -if (!bars) -return -ENODEV ; -if (pci_request_selected_regions (pdev, bars,"nvme" )) +if (pci_request_mem_regions (pdev,"nvme" ))return -ENODEV ; dev->bar =ioremap (pci_resource_start (pdev,0 ),8192 );
@@ -1994,7 +1990,7 @@ static int nvme_dev_map(struct nvme_dev *dev)return 0 ; release: -pci_release_regions (pdev); +pci_release_mem_regions (pdev);return -ENODEV ; }
Signature · 1 line
1.8.5.6
PATCH v2 3/6 lpfc: Use pci_(request|release)_mem_regions
In reply to Johannes ThumshirnNow that we do have pci_request_mem_regions() and pci_release_mem_regions() at hand, use it in the lpfc driver.
--- drivers/scsi/lpfc/lpfc_init.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-)
drivers/scsi/lpfc/lpfc_init.c +4 -11
@@ -4775,20 +4775,17 @@ static int lpfc_enable_pci_dev(struct lpfc_hba *phba) {struct pci_dev *pdev; -int bars =0 ;/* Obtain PCI device reference */ if (!phba->pcidev) goto out_error;else pdev = phba->pcidev; -/* Select PCI BARs */ - bars =pci_select_bars (pdev,IORESOURCE_MEM );/* Enable PCI device */ if (pci_enable_device_mem (pdev)) goto out_error;/* Request PCI resource for the device */ -if (pci_request_selected_regions (pdev, bars,LPFC_DRIVER_NAME )) +if (pci_request_mem_regions (pdev,LPFC_DRIVER_NAME )) goto out_disable_device;/* Set up device as PCI master and save state for EEH */ pci_set_master (pdev);
@@ -4805,7 +4802,7 @@ out_disable_device:pci_disable_device (pdev); out_error:lpfc_printf_log (phba,KERN_ERR ,LOG_INIT , -"1401 Failed to enable pci device, bars:x%x\n" , bars); +"1401 Failed to enable pci device\n" );return -ENODEV ; }
@@ -4820,17 +4817,14 @@ static void lpfc_disable_pci_dev(struct lpfc_hba *phba) {struct pci_dev *pdev; -int bars;/* Obtain PCI device reference */ if (!phba->pcidev)return ;else pdev = phba->pcidev; -/* Select PCI BARs */ - bars =pci_select_bars (pdev,IORESOURCE_MEM );/* Release PCI resource and disable PCI device */ -pci_release_selected_regions (pdev, bars); +pci_release_mem_regions (pdev);pci_disable_device (pdev);return ;
@@ -9705,7 +9699,6 @@ lpfc_pci_remove_one_s3(struct pci_dev *pdev)struct lpfc_vport **vports;struct lpfc_hba *phba = vport->phba;int i; -int bars =pci_select_bars (pdev,IORESOURCE_MEM );spin_lock_irq (&phba->hbalock); vport->load_flag |=FC_UNLOADING ;
@@ -9780,7 +9773,7 @@ lpfc_pci_remove_one_s3(struct pci_dev *pdev)lpfc_hba_free (phba); -pci_release_selected_regions (pdev, bars); +pci_release_mem_regions (pdev);pci_disable_device (pdev); }
Signature · 1 line
1.8.5.6
A message that is not in the archive (sent off-list or not yet received): CAGx+d6eHPKvOM_aYgv9qJvA1siJ89PzwHtK07U9tKs3yG7=O9w@mail.gmail.com
Re: [PATCH v2 3/6] lpfc: Use pci_(request|release)_mem_regions
Quoted 1 line · Dick Kennedy
Thanks Johannes, it looks good.
Hi Dick,
Can I use this as an Acked-by in the next submission?
Thanks,
Johannes
Quoted 96 lines
Quoted 92 lines · Johannes Thumshirn
Now that we do have
pci_request_mem_regions()andpci_release_mem_regions()at
hand, use it in the lpfc driver.Suggested-by Christoph Hellwig <[email protected]>Signed-off-by Johannes Thumshirn <[email protected]>Cc James Smart <[email protected]>Cc Dick Kennedy <[email protected]>Cc "James E.J. Bottomley" <[email protected]>Cc "Martin K. Petersen" <[email protected]>--- drivers/scsi/lpfc/lpfc_init.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-)drivers/scsi/lpfc/lpfc_init.c +4
-12@@ -4775,20 +4775,17 @@ static int lpfc_enable_pci_dev(struct lpfc_hba *phba) {struct pci_dev *pdev; -int bars =0 ;/* Obtain PCI device reference */ if (!phba->pcidev) goto out_error;else pdev = phba->pcidev; -/* Select PCI BARs */ - bars =pci_select_bars (pdev,IORESOURCE_MEM );/* Enable PCI device */ if (pci_enable_device_mem (pdev)) goto out_error;/* Request PCI resource for the device */ -if (pci_request_selected_regions (pdev, bars,LPFC_DRIVER_NAME )) +if (pci_request_mem_regions (pdev,LPFC_DRIVER_NAME )) goto out_disable_device;/* Set up device as PCI master and save state for EEH */ pci_set_master (pdev);@@ -4805,7 +4802,7 @@ out_disable_device:pci_disable_device (pdev); out_error:lpfc_printf_log (phba,KERN_ERR ,LOG_INIT , -"1401 Failed to enable pci device, bars:x%x\n" , bars); + "1401 Failed to enable pci device\n");return -ENODEV ; }@@ -4820,17 +4817,14 @@ static void lpfc_disable_pci_dev(struct lpfc_hba *phba) {struct pci_dev *pdev; -int bars;/* Obtain PCI device reference */ if (!phba->pcidev)return ;else pdev = phba->pcidev; -/* Select PCI BARs */ - bars =pci_select_bars (pdev,IORESOURCE_MEM );/* Release PCI resource and disable PCI device */ -pci_release_selected_regions (pdev, bars); +pci_release_mem_regions (pdev);pci_disable_device (pdev);return ;@@ -9705,7 +9699,6 @@ lpfc_pci_remove_one_s3(struct pci_dev *pdev)struct lpfc_vport **vports;struct lpfc_hba *phba = vport->phba;int i; -int bars =pci_select_bars (pdev,IORESOURCE_MEM );spin_lock_irq (&phba->hbalock); vport->load_flag |=FC_UNLOADING ;@@ -9780,7 +9773,7 @@ lpfc_pci_remove_one_s3(struct pci_dev *pdev)lpfc_hba_free (phba); -pci_release_selected_regions (pdev, bars); +pci_release_mem_regions (pdev);pci_disable_device (pdev); } --1.8.5.6
Signature · 6 lines
Johannes Thumshirn Storage [email protected] +49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: Felix Imendörffer, Jane Smithard, Graham Norton HRB 21284 (AG Nürnberg) Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
PATCH v2 4/6 GenWQE: Use pci_(request|release)_mem_regions
In reply to Johannes ThumshirnNow that we do have pci_request_mem_regions() and pci_release_mem_regions() at hand, use it in the genwqe driver.
--- drivers/misc/genwqe/card_base.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
drivers/misc/genwqe/card_base.c +5 -8
@@ -182,7 +182,7 @@ static void genwqe_dev_free(struct genwqe_dev *cd)*/ static int genwqe_bus_reset (struct genwqe_dev *cd) { -int bars, rc =0 ; +int rc =0 ;struct pci_dev *pci_dev = cd->pci_dev;void __iomem *mmio;
@@ -193,8 +193,7 @@ static int genwqe_bus_reset(struct genwqe_dev *cd) cd->mmio =NULL ;pci_iounmap (pci_dev, mmio); - bars =pci_select_bars (pci_dev,IORESOURCE_MEM ); -pci_release_selected_regions (pci_dev, bars); +pci_release_mem_regions (pci_dev);/* * Firmware/BIOS might change memory mapping during bus reset.
@@ -218,7 +217,7 @@ static int genwqe_bus_reset(struct genwqe_dev *cd)GENWQE_INJECT_GFIR_FATAL | GENWQE_INJECT_GFIR_INFO); - rc =pci_request_selected_regions (pci_dev, bars, genwqe_driver_name); + rc =pci_request_mem_regions (pci_dev, genwqe_driver_name);if (rc) {dev_err (&pci_dev->dev,"[%s] err: request bars failed (%d)\n" , __func__, rc);
@@ -1071,7 +1070,6 @@ static int genwqe_pci_setup(struct genwqe_dev *cd)int err, bars;struct pci_dev *pci_dev = cd->pci_dev; - bars =pci_select_bars (pci_dev,IORESOURCE_MEM ); err =pci_enable_device_mem (pci_dev);if (err) { dev_err(&pci_dev->dev,
@@ -1080,7 +1078,7 @@ static int genwqe_pci_setup(struct genwqe_dev *cd) }/* Reserve PCI I/O and memory resources */ - err =pci_request_selected_regions (pci_dev, bars, genwqe_driver_name); + err =pci_request_mem_regions (pci_dev, genwqe_driver_name);if (err) {dev_err (&pci_dev->dev,"[%s] err: request bars failed (%d)\n" , __func__, err);
@@ -1160,8 +1158,7 @@ static void genwqe_pci_remove(struct genwqe_dev *cd)if (cd->mmio)pci_iounmap (pci_dev, cd->mmio); - bars =pci_select_bars (pci_dev,IORESOURCE_MEM ); -pci_release_selected_regions (pci_dev, bars); +pci_release_mem_regions (pci_dev);pci_disable_device (pci_dev); }
Signature · 1 line
1.8.5.6
PATCH v2 5/6 ethernet/intel: Use pci_(request|release)_mem_regions
In reply to Johannes ThumshirnNow that we do have pci_request_mem_regions() and pci_release_mem_regions() at hand, use it in the Intel ethernet drivers.
--- drivers/net/ethernet/intel/e1000e/netdev.c | 6 ++---- drivers/net/ethernet/intel/fm10k/fm10k_pci.c | 11 +++-------- drivers/net/ethernet/intel/i40e/i40e_main.c | 9 +++------ drivers/net/ethernet/intel/igb/igb_main.c | 10 +++------- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 9 +++------ 5 files changed, 14 insertions(+), 31 deletions(-)
drivers/net/ethernet/intel/e1000e/netdev.c +2 -4
@@ -7284,8 +7284,7 @@ err_flashmap: err_ioremap:free_netdev (netdev); err_alloc_etherdev: -pci_release_selected_regions (pdev, -pci_select_bars (pdev,IORESOURCE_MEM )); +pci_release_mem_regions (pdev); err_pci_reg: err_dma:pci_disable_device (pdev);
@@ -7352,8 +7351,7 @@ static void e1000_remove(struct pci_dev *pdev)if ((adapter->hw.flash_address) && (adapter->hw.mac.type < e1000_pch_spt))iounmap (adapter->hw.flash_address); -pci_release_selected_regions (pdev, -pci_select_bars (pdev,IORESOURCE_MEM )); +pci_release_mem_regions (pdev);free_netdev (netdev);
drivers/net/ethernet/intel/fm10k/fm10k_pci.c +3 -8
@@ -1940,10 +1940,7 @@ static int fm10k_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto err_dma; } - err =pci_request_selected_regions (pdev, -pci_select_bars (pdev, -IORESOURCE_MEM ), - fm10k_driver_name); + err =pci_request_mem_regions (pdev, fm10k_driver_name);if (err) {dev_err (&pdev->dev,"pci_request_selected_regions failed: %d\n" , err);
@@ -2034,8 +2031,7 @@ err_sw_init: err_ioremap:free_netdev (netdev); err_alloc_netdev: -pci_release_selected_regions (pdev, -pci_select_bars (pdev,IORESOURCE_MEM )); +pci_release_mem_regions (pdev); err_pci_reg: err_dma:pci_disable_device (pdev);
@@ -2086,8 +2082,7 @@ static void fm10k_remove(struct pci_dev *pdev)free_netdev (netdev); -pci_release_selected_regions (pdev, -pci_select_bars (pdev,IORESOURCE_MEM )); +pci_release_mem_regions (pdev);pci_disable_pcie_error_reporting (pdev);
drivers/net/ethernet/intel/i40e/i40e_main.c +3 -6
@@ -10779,8 +10779,7 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent) }/* set up pci connections */ - err =pci_request_selected_regions (pdev,pci_select_bars (pdev, -IORESOURCE_MEM ), i40e_driver_name); + err =pci_request_mem_regions (pdev, i40e_driver_name);if (err) {dev_info (&pdev->dev,"pci_request_selected_regions failed %d\n" , err);
@@ -11277,8 +11276,7 @@ err_ioremap:kfree (pf); err_pf_alloc:pci_disable_pcie_error_reporting (pdev); -pci_release_selected_regions (pdev, -pci_select_bars (pdev,IORESOURCE_MEM )); +pci_release_mem_regions (pdev); err_pci_reg: err_dma:pci_disable_device (pdev);
@@ -11387,8 +11385,7 @@ static void i40e_remove(struct pci_dev *pdev)iounmap (hw->hw_addr);kfree (pf); -pci_release_selected_regions (pdev, -pci_select_bars (pdev,IORESOURCE_MEM )); +pci_release_mem_regions (pdev);pci_disable_pcie_error_reporting (pdev);pci_disable_device (pdev);
drivers/net/ethernet/intel/igb/igb_main.c +3 -7
@@ -2288,9 +2288,7 @@ static int igb_probe(struct pci_dev *pdev, const struct pci_device_id *ent) } } - err =pci_request_selected_regions (pdev,pci_select_bars (pdev, -IORESOURCE_MEM ), - igb_driver_name); + err =pci_request_mem_regions (pdev, igb_driver_name);if (err) goto err_pci_reg;
@@ -2707,8 +2705,7 @@ err_sw_init: err_ioremap:free_netdev (netdev); err_alloc_etherdev: -pci_release_selected_regions (pdev, -pci_select_bars (pdev,IORESOURCE_MEM )); +pci_release_mem_regions (pdev); err_pci_reg: err_dma:pci_disable_device (pdev);
@@ -2873,8 +2870,7 @@ static void igb_remove(struct pci_dev *pdev)pci_iounmap (pdev, adapter->io_addr);if (hw->flash_address)iounmap (hw->flash_address); -pci_release_selected_regions (pdev, -pci_select_bars (pdev,IORESOURCE_MEM )); +pci_release_mem_regions (pdev);kfree (adapter->shadow_vfta);free_netdev (netdev);
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +3 -6
@@ -9084,8 +9084,7 @@ static int ixgbe_probe(struct pci_dev *pdev, const struct pci_device_id *ent) pci_using_dac =0 ; } - err =pci_request_selected_regions (pdev,pci_select_bars (pdev, -IORESOURCE_MEM ), ixgbe_driver_name); + err =pci_request_mem_regions (pdev, ixgbe_driver_name);if (err) {dev_err (&pdev->dev,"pci_request_selected_regions failed 0x%x\n" , err);
@@ -9460,8 +9459,7 @@ err_ioremap: disable_dev = !test_and_set_bit (__IXGBE_DISABLED, &adapter->state);free_netdev (netdev); err_alloc_etherdev: -pci_release_selected_regions (pdev, -pci_select_bars (pdev,IORESOURCE_MEM )); +pci_release_mem_regions (pdev); err_pci_reg: err_dma:if (!adapter || disable_dev)
@@ -9527,8 +9525,7 @@ static void ixgbe_remove(struct pci_dev *pdev)#endif iounmap (adapter->io_addr); -pci_release_selected_regions (pdev,pci_select_bars (pdev, -IORESOURCE_MEM )); +pci_release_mem_regions (pdev);e_dev_info ("complete\n" );
Signature · 1 line
1.8.5.6
Re: [PATCH v2 5/6] ethernet/intel: Use pci_(request|release)_mem_regions
Quoted 11 lines · Johannes Thumshirn
Now that we do have
pci_request_mem_regions()andpci_release_mem_regions()at
hand, use it in the Intel ethernet drivers.Suggested-by Christoph Hellwig <[email protected]>Signed-off-by Johannes Thumshirn <[email protected]>Cc Jeff Kirsher <[email protected]>Cc David S. Miller <[email protected]>Cc netdev at vger.kernel.orgCc linux-kernel at vger.kernel.orgCc intel-wired-lan at lists.osuosl.org
Quoted 7 lines
---
?drivers/net/ethernet/intel/e1000e/netdev.c??? |? 6 ++---- ?drivers/net/ethernet/intel/fm10k/fm10k_pci.c? | 11 +++-------- ?drivers/net/ethernet/intel/i40e/i40e_main.c?? |? 9 +++------ ?drivers/net/ethernet/intel/igb/igb_main.c???? | 10 +++------- ?drivers/net/ethernet/intel/ixgbe/ixgbe_main.c |? 9 +++------?5 files changed, 14 insertions(+), 31 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://lists.osuosl.org/pipermail/intel-wired-lan/attachments/20160602/cb4ecd88/attachment.asc>
PATCH v2 6/6 alx: Use pci_(request|release)_mem_regions
In reply to Johannes ThumshirnNow that we do have pci_request_mem_regions() and pci_release_mem_regions() at hand, use it in the ethernet drivers.
--- drivers/net/ethernet/atheros/alx/main.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/net/ethernet/atheros/alx/main.c +5 -7
@@ -1238,7 +1238,7 @@ static int alx_probe(struct pci_dev *pdev, const struct pci_device_id *ent)struct alx_priv *alx;struct alx_hw *hw;bool phy_configured; -int bars, err; +int err; err =pci_enable_device_mem (pdev);if (err)
@@ -1258,11 +1258,10 @@ static int alx_probe(struct pci_dev *pdev, const struct pci_device_id *ent) } } - bars =pci_select_bars (pdev,IORESOURCE_MEM ); - err =pci_request_selected_regions (pdev, bars, alx_drv_name); + err =pci_request_mem_regions (pdev, alx_drv_name);if (err) {dev_err (&pdev->dev, -"pci_request_selected_regions failed(bars:%d)\n" , bars); +"pci_request_mem_regions failed\n" ); goto out_pci_disable; }
@@ -1388,7 +1387,7 @@ out_unmap: out_free_netdev:free_netdev (netdev); out_pci_release: -pci_release_selected_regions (pdev, bars); +pci_release_mem_regions (pdev); out_pci_disable:pci_disable_device (pdev);return err;
@@ -1407,8 +1406,7 @@ static void alx_remove(struct pci_dev *pdev)unregister_netdev (alx->dev);iounmap (hw->hw_addr); -pci_release_selected_regions (pdev, -pci_select_bars (pdev,IORESOURCE_MEM )); +pci_release_mem_regions (pdev);pci_disable_pcie_error_reporting (pdev);pci_disable_device (pdev);
Signature · 1 line
1.8.5.6