From: Thomas Gleixner <tglx@linutronix.de>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Jiang Liu <jiang.liu@linux.intel.com>,
x86@kernel.org, Bjorn Helgaas <bhelgaas@google.com>,
"Rafael J. Wysocki" <rjw@rjwysocki.net>,
Borislav Petkov <bp@alien8.de>, Yinghai Lu <yinghai@kernel.org>
Subject: [patch 2/4] x86: pci: acpi: Respect ioresource flags
Date: Thu, 11 Dec 2014 19:48:20 -0000 [thread overview]
Message-ID: <20141211193112.630941351@linutronix.de> (raw)
In-Reply-To: <20141211191853.613107396@linutronix.de>
[-- Attachment #1: x86-pci-respect-ioresource-flags.patch --]
[-- Type: text/plain, Size: 2756 bytes --]
setup_res() blindly clear all resource->flags except IO and MEM. So if
a resource is marked disabled by the acpi code, setup_res() will use
it nevertheless.
Preserve the flags and add proper checks to setup_res() and
__release_pci_root_info(). The latter is simplified while at it.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
arch/x86/pci/acpi.c | 35 ++++++++++++++++-------------------
1 file changed, 16 insertions(+), 19 deletions(-)
Index: tip/arch/x86/pci/acpi.c
===================================================================
--- tip.orig/arch/x86/pci/acpi.c
+++ tip/arch/x86/pci/acpi.c
@@ -218,6 +218,12 @@ static void teardown_mcfg_map(struct pci
}
#endif
+static bool is_valid_resource(struct resource *res)
+{
+ return (res->flags & (IORESOURCE_MEM | IORESOURCE_IO)) &&
+ !(res->flags & IORESOURCE_DISABLED);
+}
+
static acpi_status count_resource(struct acpi_resource *acpi_res, void *data)
{
struct pci_root_info *info = data;
@@ -228,7 +234,7 @@ static acpi_status count_resource(struct
!acpi_dev_resource_address_space(acpi_res, &r))
return AE_OK;
- if ((r.flags & (IORESOURCE_IO | IORESOURCE_MEM)) && resource_size(&r))
+ if (is_valid_resource(&r))
info->res_num++;
return AE_OK;
@@ -242,13 +248,10 @@ static acpi_status setup_resource(struct
u64 orig_end;
memset(&r, 0, sizeof(r));
- if (acpi_dev_resource_memory(acpi_res, &r)) {
- r.flags &= IORESOURCE_MEM;
- } else if (acpi_dev_resource_address_space(acpi_res, &r)) {
+ if (!acpi_dev_resource_memory(acpi_res, &r)) {
struct acpi_resource_address64 addr;
- r.flags &= IORESOURCE_MEM | IORESOURCE_IO;
- if (r.flags == 0)
+ if (!acpi_dev_resource_address_space(acpi_res, &r))
return AE_OK;
if (ACPI_FAILURE(acpi_resource_to_address64(acpi_res, &addr)))
@@ -264,10 +267,11 @@ static acpi_status setup_resource(struct
translation_offset = addr.translation_offset;
r.start += translation_offset;
r.end += translation_offset;
- } else {
- return AE_OK;
}
+ if (!is_valid_resource(&r))
+ return AE_OK;
+
/* Exclude non-addressable range or non-addressable portion of range */
orig_end = r.end;
r.end = min(r.end, iomem_resource.end);
@@ -367,19 +371,12 @@ static void free_pci_root_info_res(struc
static void __release_pci_root_info(struct pci_root_info *info)
{
+ struct resource *res = info->res;
int i;
- struct resource *res;
-
- for (i = 0; i < info->res_num; i++) {
- res = &info->res[i];
-
- if (!res->parent)
- continue;
-
- if (!(res->flags & (IORESOURCE_MEM | IORESOURCE_IO)))
- continue;
- release_resource(res);
+ for (i = 0; i < info->res_num; i++, res++) {
+ if (res->parent && is_valid_resource(res))
+ release_resource(res);
}
free_pci_root_info_res(info);
next prev parent reply other threads:[~2014-12-11 19:48 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-11 19:48 [patch 0/4] x86: Fix the ACPI resource handling and range checking Thomas Gleixner
2014-12-11 19:48 ` [patch 1/4] x86, pci, acpi: Redo sanity checks for root brigde probing Thomas Gleixner
2014-12-12 11:33 ` Borislav Petkov
2014-12-11 19:48 ` Thomas Gleixner [this message]
2014-12-12 13:39 ` [patch 2/4] x86: pci: acpi: Respect ioresource flags Borislav Petkov
2014-12-11 19:48 ` [patch 3/4] x86: pci: acpi: Fix the range check for IO resources Thomas Gleixner
2014-12-12 14:56 ` Borislav Petkov
2014-12-11 19:48 ` [patch 4/4] acpi: ioapic: Respect the resource flags Thomas Gleixner
2014-12-12 2:44 ` Yinghai Lu
2014-12-12 7:53 ` Thomas Gleixner
2014-12-12 8:24 ` Yinghai Lu
2014-12-12 8:46 ` Jiang Liu
2014-12-12 11:43 ` Thomas Gleixner
2014-12-17 5:44 ` Jiang Liu
2014-12-17 8:55 ` Thomas Gleixner
2014-12-12 11:39 ` Thomas Gleixner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20141211193112.630941351@linutronix.de \
--to=tglx@linutronix.de \
--cc=bhelgaas@google.com \
--cc=bp@alien8.de \
--cc=jiang.liu@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rjw@rjwysocki.net \
--cc=x86@kernel.org \
--cc=yinghai@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®