* [PATCH] NVMe: Only release requested regions
@ 2016-05-10 13:14 Johannes Thumshirn
2016-05-10 13:16 ` Hannes Reinecke
` (3 more replies)
0 siblings, 4 replies; 9+ messages in thread
From: Johannes Thumshirn @ 2016-05-10 13:14 UTC (permalink / raw)
To: Keith Busch, Jens Axboe; +Cc: linux-nvme, linux-kernel, Johannes Thumshirn
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@suse.de>
---
drivers/nvme/host/pci.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index eec73fe..6f5ad07 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -1759,9 +1759,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)
@@ -1998,7 +2003,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;
}
--
1.8.5.6
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] NVMe: Only release requested regions
2016-05-10 13:14 [PATCH] NVMe: Only release requested regions Johannes Thumshirn
@ 2016-05-10 13:16 ` Hannes Reinecke
2016-05-12 7:03 ` Christoph Hellwig
` (2 subsequent siblings)
3 siblings, 0 replies; 9+ messages in thread
From: Hannes Reinecke @ 2016-05-10 13:16 UTC (permalink / raw)
To: Johannes Thumshirn, Keith Busch, Jens Axboe; +Cc: linux-kernel, linux-nvme
On 05/10/2016 03:14 PM, Johannes Thumshirn wrote:
> 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@suse.de>
> ---
> drivers/nvme/host/pci.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Cheers,
Hannes
--
Dr. Hannes Reinecke Teamlead Storage & Networking
hare@suse.de +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] NVMe: Only release requested regions
2016-05-10 13:14 [PATCH] NVMe: Only release requested regions Johannes Thumshirn
2016-05-10 13:16 ` Hannes Reinecke
@ 2016-05-12 7:03 ` Christoph Hellwig
2016-05-12 7:34 ` Johannes Thumshirn
2016-05-24 9:15 ` Johannes Thumshirn
2016-06-08 7:16 ` Johannes Thumshirn
3 siblings, 1 reply; 9+ messages in thread
From: Christoph Hellwig @ 2016-05-12 7:03 UTC (permalink / raw)
To: Johannes Thumshirn
Cc: Keith Busch, Jens Axboe, linux-kernel, linux-nvme, linux-pci
> 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);
This looks fine, but I really hate this API.
Can someone add these two nice helpers to pci.h:
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));
}
But for now this should do it:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] NVMe: Only release requested regions
2016-05-12 7:03 ` Christoph Hellwig
@ 2016-05-12 7:34 ` Johannes Thumshirn
0 siblings, 0 replies; 9+ messages in thread
From: Johannes Thumshirn @ 2016-05-12 7:34 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Keith Busch, Jens Axboe, linux-kernel, linux-nvme, linux-pci
On Thu, May 12, 2016 at 12:03:52AM -0700, Christoph Hellwig wrote:
> > 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);
>
> This looks fine, but I really hate this API.
>
> Can someone add these two nice helpers to pci.h:
Well I could send a patch, but then this is your code...
>
> 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));
> }
>
> But for now this should do it:
>
> Reviewed-by: Christoph Hellwig <hch@lst.de>
Thanks
--
Johannes Thumshirn Storage
jthumshirn@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] 9+ messages in thread
* Re: [PATCH] NVMe: Only release requested regions
2016-05-10 13:14 [PATCH] NVMe: Only release requested regions Johannes Thumshirn
2016-05-10 13:16 ` Hannes Reinecke
2016-05-12 7:03 ` Christoph Hellwig
@ 2016-05-24 9:15 ` Johannes Thumshirn
2016-05-24 9:19 ` Christoph Hellwig
2016-06-08 7:16 ` Johannes Thumshirn
3 siblings, 1 reply; 9+ messages in thread
From: Johannes Thumshirn @ 2016-05-24 9:15 UTC (permalink / raw)
To: Keith Busch, Jens Axboe; +Cc: linux-nvme, linux-kernel
On Tue, May 10, 2016 at 03:14:28PM +0200, Johannes Thumshirn wrote:
> 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@suse.de>
> ---
> drivers/nvme/host/pci.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
> index eec73fe..6f5ad07 100644
> --- a/drivers/nvme/host/pci.c
> +++ b/drivers/nvme/host/pci.c
> @@ -1759,9 +1759,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)
> @@ -1998,7 +2003,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;
> }
>
> --
> 1.8.5.6
>
Keith, Jens, any opinions?
As I've probably missed v4.7, is it possible to get it for v4.8?
Or should I take on the PCI helper functions Christoph suggested first?
Johannes
--
Johannes Thumshirn Storage
jthumshirn@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] 9+ messages in thread
* Re: [PATCH] NVMe: Only release requested regions
2016-05-24 9:15 ` Johannes Thumshirn
@ 2016-05-24 9:19 ` Christoph Hellwig
2016-05-24 14:29 ` Keith Busch
0 siblings, 1 reply; 9+ messages in thread
From: Christoph Hellwig @ 2016-05-24 9:19 UTC (permalink / raw)
To: Johannes Thumshirn; +Cc: Keith Busch, Jens Axboe, linux-kernel, linux-nvme
On Tue, May 24, 2016 at 11:15:52AM +0200, Johannes Thumshirn wrote:
> As I've probably missed v4.7, is it possible to get it for v4.8?
> Or should I take on the PCI helper functions Christoph suggested first?
Let's get the quick fix in first, and I think it's still 4.7 material.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] NVMe: Only release requested regions
2016-05-24 9:19 ` Christoph Hellwig
@ 2016-05-24 14:29 ` Keith Busch
0 siblings, 0 replies; 9+ messages in thread
From: Keith Busch @ 2016-05-24 14:29 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Johannes Thumshirn, Jens Axboe, linux-kernel, linux-nvme
On Tue, May 24, 2016 at 02:19:17AM -0700, Christoph Hellwig wrote:
> On Tue, May 24, 2016 at 11:15:52AM +0200, Johannes Thumshirn wrote:
> > As I've probably missed v4.7, is it possible to get it for v4.8?
> > Or should I take on the PCI helper functions Christoph suggested first?
>
> Let's get the quick fix in first, and I think it's still 4.7 material.
Agreed.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] NVMe: Only release requested regions
2016-05-10 13:14 [PATCH] NVMe: Only release requested regions Johannes Thumshirn
` (2 preceding siblings ...)
2016-05-24 9:15 ` Johannes Thumshirn
@ 2016-06-08 7:16 ` Johannes Thumshirn
2016-06-09 20:28 ` Jens Axboe
3 siblings, 1 reply; 9+ messages in thread
From: Johannes Thumshirn @ 2016-06-08 7:16 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-nvme, linux-kernel
On Tue, May 10, 2016 at 03:14:28PM +0200, Johannes Thumshirn wrote:
> 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@suse.de>
> ---
> drivers/nvme/host/pci.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
> index eec73fe..6f5ad07 100644
> --- a/drivers/nvme/host/pci.c
> +++ b/drivers/nvme/host/pci.c
> @@ -1759,9 +1759,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)
> @@ -1998,7 +2003,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;
> }
>
> --
> 1.8.5.6
>
Jens, ping?
--
Johannes Thumshirn Storage
jthumshirn@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] 9+ messages in thread
* Re: [PATCH] NVMe: Only release requested regions
2016-06-08 7:16 ` Johannes Thumshirn
@ 2016-06-09 20:28 ` Jens Axboe
0 siblings, 0 replies; 9+ messages in thread
From: Jens Axboe @ 2016-06-09 20:28 UTC (permalink / raw)
To: Johannes Thumshirn; +Cc: linux-nvme, linux-kernel
On 06/08/2016 01:16 AM, Johannes Thumshirn wrote:
> On Tue, May 10, 2016 at 03:14:28PM +0200, Johannes Thumshirn wrote:
>> 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@suse.de>
>> ---
>> drivers/nvme/host/pci.c | 9 +++++++--
>> 1 file changed, 7 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
>> index eec73fe..6f5ad07 100644
>> --- a/drivers/nvme/host/pci.c
>> +++ b/drivers/nvme/host/pci.c
>> @@ -1759,9 +1759,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)
>> @@ -1998,7 +2003,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;
>> }
>>
>> --
>> 1.8.5.6
>>
>
>
> Jens, ping?
Added for 4.7, thanks.
--
Jens Axboe
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2016-06-09 20:29 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-10 13:14 [PATCH] NVMe: Only release requested regions Johannes Thumshirn
2016-05-10 13:16 ` Hannes Reinecke
2016-05-12 7:03 ` Christoph Hellwig
2016-05-12 7:34 ` Johannes Thumshirn
2016-05-24 9:15 ` Johannes Thumshirn
2016-05-24 9:19 ` Christoph Hellwig
2016-05-24 14:29 ` Keith Busch
2016-06-08 7:16 ` Johannes Thumshirn
2016-06-09 20:28 ` Jens Axboe
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).