linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/6] Introduce pci_(request|release)_(mem|io)_regions
@ 2016-06-07  7:44 Johannes Thumshirn
  2016-06-07  7:44 ` [PATCH v3 2/6] NVMe: Use pci_(request|release)_mem_regions Johannes Thumshirn
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Johannes Thumshirn @ 2016-06-07  7:44 UTC (permalink / raw)


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 v2:
* Fixed compilation error on platforms with CONFIG_PCI=n
* Added Jeff's Acked-by on the Intel ethernet patch
* Added Dick's Acked-by on the lpfc patch

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(-)

Cc: Christoph Hellwig <hch at infradead.org>
Cc: Keith Busch <keith.busch at intel.com>
Cc: Jens Axboe <axboe at fb.com>
Cc: linux-nvme at lists.infradead.org
Cc: James Smart <james.smart at avagotech.com>
Cc: Dick Kennedy <dick.kennedy at avagotech.com>
Cc: "James E.J. Bottomley" <jejb at linux.vnet.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen at oracle.com>
Cc: linux-scsi at vger.kernel.org
Cc: linux-kernel at vger.kernel.org
Cc: Frank Haverkamp <haver at linux.vnet.ibm.com>
Cc: Greg Kroah-Hartman <gregkh at linuxfoundation.org>
Cc: Jay Cliburn <jcliburn at gmail.com>
Cc: Chris Snook <chris.snook at gmail.com>
Cc: Jeff Kirsher <jeffrey.t.kirsher at intel.com>
Cc: David S. Miller <davem at davemloft.net>
Cc: netdev at vger.kernel.org
Cc: linux-kernel at vger.kernel.org
Cc: intel-wired-lan at lists.osuosl.org
-- 
1.8.5.6

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v3 2/6] NVMe: Use pci_(request|release)_mem_regions
  2016-06-07  7:44 [PATCH v3 0/6] Introduce pci_(request|release)_(mem|io)_regions Johannes Thumshirn
@ 2016-06-07  7:44 ` Johannes Thumshirn
  2016-06-17 11:27   ` Johannes Thumshirn
  2016-06-07 11:57 ` [PATCH v3 0/6] Introduce pci_(request|release)_(mem|io)_regions Christoph Hellwig
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Johannes Thumshirn @ 2016-06-07  7:44 UTC (permalink / raw)


Now that we do have pci_request_mem_regions() and pci_release_mem_regions() at
hand, use it in the NVMe driver.

Suggested-by: Christoph Hellwig <hch at infradead.org>
Signed-off-by: Johannes Thumshirn <jthumshirn at suse.de>
Reviewed-by: Christoph Hellwig <hch at lst.de>
Cc: Christoph Hellwig <hch at infradead.org>
Cc: Keith Busch <keith.busch at intel.com>
Cc: Jens Axboe <axboe at fb.com>
Cc: linux-nvme at lists.infradead.org
---
 drivers/nvme/host/pci.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 4fd733f..e7d17ae 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -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;
 }
 
-- 
1.8.5.6

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v3 0/6] Introduce pci_(request|release)_(mem|io)_regions
  2016-06-07  7:44 [PATCH v3 0/6] Introduce pci_(request|release)_(mem|io)_regions Johannes Thumshirn
  2016-06-07  7:44 ` [PATCH v3 2/6] NVMe: Use pci_(request|release)_mem_regions Johannes Thumshirn
@ 2016-06-07 11:57 ` Christoph Hellwig
  2016-06-08  7:28 ` Johannes Thumshirn
  2016-06-21 22:28 ` Bjorn Helgaas
  3 siblings, 0 replies; 8+ messages in thread
From: Christoph Hellwig @ 2016-06-07 11:57 UTC (permalink / raw)


The whole series looks fine to me:

Reviewed-by: Christoph Hellwig <hch at lst.de>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v3 0/6] Introduce pci_(request|release)_(mem|io)_regions
  2016-06-07  7:44 [PATCH v3 0/6] Introduce pci_(request|release)_(mem|io)_regions Johannes Thumshirn
  2016-06-07  7:44 ` [PATCH v3 2/6] NVMe: Use pci_(request|release)_mem_regions Johannes Thumshirn
  2016-06-07 11:57 ` [PATCH v3 0/6] Introduce pci_(request|release)_(mem|io)_regions Christoph Hellwig
@ 2016-06-08  7:28 ` Johannes Thumshirn
  2016-06-08 23:04   ` Jeff Kirsher
  2016-06-21 22:28 ` Bjorn Helgaas
  3 siblings, 1 reply; 8+ messages in thread
From: Johannes Thumshirn @ 2016-06-08  7:28 UTC (permalink / raw)


On Tue, Jun 07, 2016@09:44:00AM +0200, Johannes Thumshirn wrote:
> 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.
> 

Btw, as I've seen already Jeff applying the Intel Ethernet patch to his
tree, I think this should go via the PCI tree as the build dependency is
the PCI patch.

Thanks,
	Johannes
-- 
Johannes Thumshirn                                          Storage
jthumshirn at suse.de                                +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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v3 0/6] Introduce pci_(request|release)_(mem|io)_regions
  2016-06-08  7:28 ` Johannes Thumshirn
@ 2016-06-08 23:04   ` Jeff Kirsher
  0 siblings, 0 replies; 8+ messages in thread
From: Jeff Kirsher @ 2016-06-08 23:04 UTC (permalink / raw)


On Wed, 2016-06-08@09:28 +0200, Johannes Thumshirn wrote:
> On Tue, Jun 07, 2016@09:44:00AM +0200, Johannes Thumshirn wrote:
> > 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?an
> d
> > tested on kernel v4.6 with NVMe.
> >?
> 
> Btw, as I've seen already Jeff applying the Intel Ethernet patch to his
> tree, I think this should go via the PCI tree as the build dependency is
> the PCI patch.

Bjorn should pick up the entire series, I just applied the Intel patch (and
dependent patches) so we could touch test it.
-------------- 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.infradead.org/pipermail/linux-nvme/attachments/20160608/37d3a717/attachment-0001.sig>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v3 2/6] NVMe: Use pci_(request|release)_mem_regions
  2016-06-07  7:44 ` [PATCH v3 2/6] NVMe: Use pci_(request|release)_mem_regions Johannes Thumshirn
@ 2016-06-17 11:27   ` Johannes Thumshirn
  2016-06-21 22:27     ` Bjorn Helgaas
  0 siblings, 1 reply; 8+ messages in thread
From: Johannes Thumshirn @ 2016-06-17 11:27 UTC (permalink / raw)


On Tue, Jun 07, 2016@09:44:02AM +0200, Johannes Thumshirn wrote:
> Now that we do have pci_request_mem_regions() and pci_release_mem_regions() at
> hand, use it in the NVMe driver.
> 
> Suggested-by: Christoph Hellwig <hch at infradead.org>
> Signed-off-by: Johannes Thumshirn <jthumshirn at suse.de>
> Reviewed-by: Christoph Hellwig <hch at lst.de>
> Cc: Christoph Hellwig <hch at infradead.org>
> Cc: Keith Busch <keith.busch at intel.com>
> Cc: Jens Axboe <axboe at fb.com>
> Cc: linux-nvme at lists.infradead.org

Bjorn, 

Jens merged a band aid here which conflicts with the patch. Shall I send you
this patch re-based or the entire series?

Thanks,
	Johannes
-- 
Johannes Thumshirn                                          Storage
jthumshirn at suse.de                                +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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v3 2/6] NVMe: Use pci_(request|release)_mem_regions
  2016-06-17 11:27   ` Johannes Thumshirn
@ 2016-06-21 22:27     ` Bjorn Helgaas
  0 siblings, 0 replies; 8+ messages in thread
From: Bjorn Helgaas @ 2016-06-21 22:27 UTC (permalink / raw)


On Fri, Jun 17, 2016@01:27:16PM +0200, Johannes Thumshirn wrote:
> On Tue, Jun 07, 2016@09:44:02AM +0200, Johannes Thumshirn wrote:
> > Now that we do have pci_request_mem_regions() and pci_release_mem_regions() at
> > hand, use it in the NVMe driver.
> > 
> > Suggested-by: Christoph Hellwig <hch at infradead.org>
> > Signed-off-by: Johannes Thumshirn <jthumshirn at suse.de>
> > Reviewed-by: Christoph Hellwig <hch at lst.de>
> > Cc: Christoph Hellwig <hch at infradead.org>
> > Cc: Keith Busch <keith.busch at intel.com>
> > Cc: Jens Axboe <axboe at fb.com>
> > Cc: linux-nvme at lists.infradead.org
> 
> Bjorn, 
> 
> Jens merged a band aid here which conflicts with the patch. Shall I send you
> this patch re-based or the entire series?

I see the conflict with the patch below.  I don't know how Jens
manages his tree, but the conflict should be pretty trivial to
resolve, so I won't worry about it too much.


commit edb50a5403d2
Author: Johannes Thumshirn <jthumshirn at suse.de>
Date:   Tue May 10 15:14:28 2016 +0200

    NVMe: Only release requested regions
    
    The NVMe driver only requests the PCIe device's memory regions but releases
    all possible regions (including eventual I/O regions). This leads to a stale
    warning entry in dmesg about freeing non existent resources.
    
    Signed-off-by: Johannes Thumshirn <jthumshirn at suse.de>
    Signed-off-by: Jens Axboe <axboe at fb.com>

diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 78dca31..befac5b 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -1679,9 +1679,14 @@ static int nvme_pci_enable(struct nvme_dev *dev)
 
 static void nvme_dev_unmap(struct nvme_dev *dev)
 {
+       struct pci_dev *pdev = to_pci_dev(dev->dev);
+       int bars;
+
        if (dev->bar)
                iounmap(dev->bar);
-       pci_release_regions(to_pci_dev(dev->dev));
+
+       bars = pci_select_bars(pdev, IORESOURCE_MEM);
+       pci_release_selected_regions(pdev, bars);
 }
 
 static void nvme_pci_disable(struct nvme_dev *dev)
@@ -1924,7 +1929,7 @@ static int nvme_dev_map(struct nvme_dev *dev)
 
        return 0;
   release:
-       pci_release_regions(pdev);
+       pci_release_selected_regions(pdev, bars);
        return -ENODEV;
 }
 

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v3 0/6] Introduce pci_(request|release)_(mem|io)_regions
  2016-06-07  7:44 [PATCH v3 0/6] Introduce pci_(request|release)_(mem|io)_regions Johannes Thumshirn
                   ` (2 preceding siblings ...)
  2016-06-08  7:28 ` Johannes Thumshirn
@ 2016-06-21 22:28 ` Bjorn Helgaas
  3 siblings, 0 replies; 8+ messages in thread
From: Bjorn Helgaas @ 2016-06-21 22:28 UTC (permalink / raw)


On Tue, Jun 07, 2016@09:44:00AM +0200, Johannes Thumshirn wrote:
> 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.

I applied all six of these to pci/resources for v4.8, thanks, Johannes.

> 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 +++++++++++++++++++++++++++

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-06-21 22:28 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-07  7:44 [PATCH v3 0/6] Introduce pci_(request|release)_(mem|io)_regions Johannes Thumshirn
2016-06-07  7:44 ` [PATCH v3 2/6] NVMe: Use pci_(request|release)_mem_regions Johannes Thumshirn
2016-06-17 11:27   ` Johannes Thumshirn
2016-06-21 22:27     ` Bjorn Helgaas
2016-06-07 11:57 ` [PATCH v3 0/6] Introduce pci_(request|release)_(mem|io)_regions Christoph Hellwig
2016-06-08  7:28 ` Johannes Thumshirn
2016-06-08 23:04   ` Jeff Kirsher
2016-06-21 22:28 ` Bjorn Helgaas

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).