diff mbox

[v2,1/6] PCI: Add helpers to request/release memory and I/O regions

Message ID 2a5ab5c7cdf2d068395a2c97c934c258ae8d58c0.1464795082.git.jthumshirn@suse.de (mailing list archive)
State New, archived
Delegated to: Bjorn Helgaas
Headers show

Commit Message

Johannes Thumshirn June 2, 2016, 7:30 a.m. UTC
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.

Suggested-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Cc: Christoph Hellwig <hch@infradead.org>
---
 include/linux/pci.h | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

Comments

kernel test robot June 4, 2016, 11:11 p.m. UTC | #1
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
kernel test robot June 4, 2016, 11:32 p.m. UTC | #2
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
Johannes Thumshirn June 6, 2016, 8:14 a.m. UTC | #3
On Sun, Jun 05, 2016 at 07:32:13AM +0800, kbuild test robot wrote:
> 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

Problem got addressed, waiting for an reply from Dick Kenedy on the lpfc patch
before re-submission,

Thanks for reporting,
	Johannes
diff mbox

Patch

diff --git a/include/linux/pci.h b/include/linux/pci.h
index 932ec74..565c38e 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -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