* [PATCH] PCI: stop crashing in pci_release_resource v2
@ 2018-02-21 9:07 Christian König
2018-02-21 19:24 ` Andy Shevchenko
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Christian König @ 2018-02-21 9:07 UTC (permalink / raw)
To: bhelgaas, linux-kernel, linux-pci
Is it entirely possible that the BIOS wasn't able to assign resources to
a device. In this case don't crash in pci_release_resource() when we try
to resize the resource.
v2: keep printing the info that we try to release the BAR
Signed-off-by: Christian König <christian.koenig@amd.com>
CC: stable@vger.kernel.org
---
drivers/pci/setup-res.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c
index e815111f3f81..c0f091614805 100644
--- a/drivers/pci/setup-res.c
+++ b/drivers/pci/setup-res.c
@@ -402,6 +402,10 @@ void pci_release_resource(struct pci_dev *dev, int resno)
struct resource *res = dev->resource + resno;
dev_info(&dev->dev, "BAR %d: releasing %pR\n", resno, res);
+
+ if (!res->parent)
+ return;
+
release_resource(res);
res->end = resource_size(res) - 1;
res->start = 0;
--
2.14.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] PCI: stop crashing in pci_release_resource v2
2018-02-21 9:07 [PATCH] PCI: stop crashing in pci_release_resource v2 Christian König
@ 2018-02-21 19:24 ` Andy Shevchenko
2018-02-26 20:56 ` Bjorn Helgaas
2018-03-01 18:49 ` Bjorn Helgaas
2 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2018-02-21 19:24 UTC (permalink / raw)
To: Christian König; +Cc: Bjorn Helgaas, Linux Kernel Mailing List, linux-pci
On Wed, Feb 21, 2018 at 11:07 AM, Christian König
<ckoenig.leichtzumerken@gmail.com> wrote:
> Is it entirely possible that the BIOS wasn't able to assign resources to
> a device. In this case don't crash in pci_release_resource() when we try
> to resize the resource.
>
> v2: keep printing the info that we try to release the BAR
>
FWIW,
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> Signed-off-by: Christian König <christian.koenig@amd.com>
> CC: stable@vger.kernel.org
> ---
> drivers/pci/setup-res.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c
> index e815111f3f81..c0f091614805 100644
> --- a/drivers/pci/setup-res.c
> +++ b/drivers/pci/setup-res.c
> @@ -402,6 +402,10 @@ void pci_release_resource(struct pci_dev *dev, int resno)
> struct resource *res = dev->resource + resno;
>
> dev_info(&dev->dev, "BAR %d: releasing %pR\n", resno, res);
> +
> + if (!res->parent)
> + return;
> +
> release_resource(res);
> res->end = resource_size(res) - 1;
> res->start = 0;
> --
> 2.14.1
>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] PCI: stop crashing in pci_release_resource v2
2018-02-21 9:07 [PATCH] PCI: stop crashing in pci_release_resource v2 Christian König
2018-02-21 19:24 ` Andy Shevchenko
@ 2018-02-26 20:56 ` Bjorn Helgaas
2018-03-01 18:49 ` Bjorn Helgaas
2 siblings, 0 replies; 5+ messages in thread
From: Bjorn Helgaas @ 2018-02-26 20:56 UTC (permalink / raw)
To: Christian König; +Cc: bhelgaas, linux-kernel, linux-pci
On Wed, Feb 21, 2018 at 10:07:15AM +0100, Christian König wrote:
> Is it entirely possible that the BIOS wasn't able to assign resources to
> a device. In this case don't crash in pci_release_resource() when we try
> to resize the resource.
>
> v2: keep printing the info that we try to release the BAR
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
> CC: stable@vger.kernel.org
I think we probably want this in v4.16, since it seems to be a fix for
8bb705e3e79d ("PCI: Add pci_resize_resource() for resizing BARs"),
which appeared in v4.15.
What does the crash look like? I might include a few lines in the
changelog to help people find the fix.
I added a Fixes: tag and Andy's Reviewed-by already.
> ---
> drivers/pci/setup-res.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c
> index e815111f3f81..c0f091614805 100644
> --- a/drivers/pci/setup-res.c
> +++ b/drivers/pci/setup-res.c
> @@ -402,6 +402,10 @@ void pci_release_resource(struct pci_dev *dev, int resno)
> struct resource *res = dev->resource + resno;
>
> dev_info(&dev->dev, "BAR %d: releasing %pR\n", resno, res);
> +
> + if (!res->parent)
> + return;
> +
> release_resource(res);
> res->end = resource_size(res) - 1;
> res->start = 0;
> --
> 2.14.1
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] PCI: stop crashing in pci_release_resource v2
2018-02-21 9:07 [PATCH] PCI: stop crashing in pci_release_resource v2 Christian König
2018-02-21 19:24 ` Andy Shevchenko
2018-02-26 20:56 ` Bjorn Helgaas
@ 2018-03-01 18:49 ` Bjorn Helgaas
2018-03-02 7:55 ` Christian König
2 siblings, 1 reply; 5+ messages in thread
From: Bjorn Helgaas @ 2018-03-01 18:49 UTC (permalink / raw)
To: Christian König; +Cc: bhelgaas, linux-kernel, linux-pci
On Wed, Feb 21, 2018 at 10:07:15AM +0100, Christian König wrote:
> Is it entirely possible that the BIOS wasn't able to assign resources to
> a device. In this case don't crash in pci_release_resource() when we try
> to resize the resource.
>
> v2: keep printing the info that we try to release the BAR
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
> CC: stable@vger.kernel.org
I was hoping for a dmesg snippet, but I added a Fixes: tag and applied
this to for-linus for v4.16.
> ---
> drivers/pci/setup-res.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c
> index e815111f3f81..c0f091614805 100644
> --- a/drivers/pci/setup-res.c
> +++ b/drivers/pci/setup-res.c
> @@ -402,6 +402,10 @@ void pci_release_resource(struct pci_dev *dev, int resno)
> struct resource *res = dev->resource + resno;
>
> dev_info(&dev->dev, "BAR %d: releasing %pR\n", resno, res);
> +
> + if (!res->parent)
> + return;
> +
> release_resource(res);
> res->end = resource_size(res) - 1;
> res->start = 0;
> --
> 2.14.1
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] PCI: stop crashing in pci_release_resource v2
2018-03-01 18:49 ` Bjorn Helgaas
@ 2018-03-02 7:55 ` Christian König
0 siblings, 0 replies; 5+ messages in thread
From: Christian König @ 2018-03-02 7:55 UTC (permalink / raw)
To: Bjorn Helgaas; +Cc: bhelgaas, linux-kernel, linux-pci
Am 01.03.2018 um 19:49 schrieb Bjorn Helgaas:
> On Wed, Feb 21, 2018 at 10:07:15AM +0100, Christian König wrote:
>> Is it entirely possible that the BIOS wasn't able to assign resources to
>> a device. In this case don't crash in pci_release_resource() when we try
>> to resize the resource.
>>
>> v2: keep printing the info that we try to release the BAR
>>
>> Signed-off-by: Christian König <christian.koenig@amd.com>
>> CC: stable@vger.kernel.org
> I was hoping for a dmesg snippet, but I added a Fixes: tag and applied
> this to for-linus for v4.16.
Sorry, been on vacation and missed your mail.
I don't have a dmesg of hand either, cause the reporter provided only a
mail with a picture of the crash :)
But he confirmed that the patch worked.
Thanks,
Christian.
>
>> ---
>> drivers/pci/setup-res.c | 4 ++++
>> 1 file changed, 4 insertions(+)
>>
>> diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c
>> index e815111f3f81..c0f091614805 100644
>> --- a/drivers/pci/setup-res.c
>> +++ b/drivers/pci/setup-res.c
>> @@ -402,6 +402,10 @@ void pci_release_resource(struct pci_dev *dev, int resno)
>> struct resource *res = dev->resource + resno;
>>
>> dev_info(&dev->dev, "BAR %d: releasing %pR\n", resno, res);
>> +
>> + if (!res->parent)
>> + return;
>> +
>> release_resource(res);
>> res->end = resource_size(res) - 1;
>> res->start = 0;
>> --
>> 2.14.1
>>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-03-02 7:55 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-21 9:07 [PATCH] PCI: stop crashing in pci_release_resource v2 Christian König
2018-02-21 19:24 ` Andy Shevchenko
2018-02-26 20:56 ` Bjorn Helgaas
2018-03-01 18:49 ` Bjorn Helgaas
2018-03-02 7:55 ` Christian König
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).