From: Yinghai Lu <yinghai@kernel.org>
To: Bjorn Helgaas <bhelgaas@google.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
Yinghai Lu <yinghai@kernel.org>
Subject: [PATCH 01/10] PCI: avoid arch_remove_reservations() for PCI_TEST
Date: Fri, 4 Aug 2017 23:37:52 -0700 [thread overview]
Message-ID: <20170805063801.15880-2-yinghai@kernel.org> (raw)
In-Reply-To: <20170805063801.15880-1-yinghai@kernel.org>
arch_remove_reservations will clip out with e820 from host that kernel
running, that will cause failure from PCI_TEST from simulated data.
PCI_TEST has different iomem resource instead iomem_resource,
so check if iomem_resource is related to avoid calling
arch_remove_reservations()
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
arch/x86/kernel/resource.c | 15 +++++++++++++--
include/linux/ioport.h | 3 ++-
kernel/resource.c | 5 +++--
3 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/arch/x86/kernel/resource.c b/arch/x86/kernel/resource.c
index 5ab3895..f19b0f6 100644
--- a/arch/x86/kernel/resource.c
+++ b/arch/x86/kernel/resource.c
@@ -35,14 +35,25 @@ static void remove_e820_regions(struct resource *avail)
}
}
-void arch_remove_reservations(struct resource *avail)
+static int is_from_iomem_resource(struct resource *root)
+{
+ while (root->parent)
+ root = root->parent;
+
+ if (root == &iomem_resource)
+ return 1;
+
+ return 0;
+}
+
+void arch_remove_reservations(struct resource *root, struct resource *avail)
{
/*
* Trim out BIOS area (high 2MB) and E820 regions. We do not remove
* the low 1MB unconditionally, as this area is needed for some ISA
* cards requiring a memory range, e.g. the i82365 PCMCIA controller.
*/
- if (avail->flags & IORESOURCE_MEM) {
+ if ((avail->flags & IORESOURCE_MEM) && is_from_iomem_resource(root)) {
resource_clip(avail, BIOS_ROM_BASE, BIOS_ROM_END);
remove_e820_regions(avail);
diff --git a/include/linux/ioport.h b/include/linux/ioport.h
index 6230064..4e9272d 100644
--- a/include/linux/ioport.h
+++ b/include/linux/ioport.h
@@ -177,7 +177,8 @@ extern struct resource *insert_resource_conflict(struct resource *parent, struct
extern int insert_resource(struct resource *parent, struct resource *new);
extern void insert_resource_expand_to_fit(struct resource *root, struct resource *new);
extern int remove_resource(struct resource *old);
-extern void arch_remove_reservations(struct resource *avail);
+extern void arch_remove_reservations(struct resource *root,
+ struct resource *avail);
extern int allocate_resource(struct resource *root, struct resource *new,
resource_size_t size, resource_size_t min,
resource_size_t max, resource_size_t align,
diff --git a/kernel/resource.c b/kernel/resource.c
index 9b5f044..4174020 100644
--- a/kernel/resource.c
+++ b/kernel/resource.c
@@ -570,7 +570,8 @@ int region_intersects(resource_size_t start, size_t size, unsigned long flags,
}
EXPORT_SYMBOL_GPL(region_intersects);
-void __weak arch_remove_reservations(struct resource *avail)
+void __weak arch_remove_reservations(struct resource *root,
+ struct resource *avail)
{
}
@@ -622,7 +623,7 @@ static int __find_resource(struct resource *root, struct resource *old,
goto next;
resource_clip(&tmp, constraint->min, constraint->max);
- arch_remove_reservations(&tmp);
+ arch_remove_reservations(root, &tmp);
/* Check for overflow after ALIGN() */
avail.start = ALIGN(tmp.start, constraint->align);
--
2.9.4
next prev parent reply other threads:[~2017-08-05 6:38 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-05 6:37 [PATCH 00/10] PCI: pci resource allocation test module Yinghai Lu
2017-08-05 6:37 ` Yinghai Lu [this message]
2017-08-05 6:37 ` [PATCH 02/10] PCI: introduce ioport_res/iomem_res for PCI_TEST Yinghai Lu
2017-08-05 6:37 ` [PATCH 03/10] PCI: export symbol for PCI_TEST module Yinghai Lu
2017-08-05 6:37 ` [PATCH 04/10] PCI: extend pci device match_driver state Yinghai Lu
2017-08-05 6:37 ` [PATCH 05/10] PCI: Add PCI_TEST module for resource allocation Yinghai Lu
2017-08-05 6:37 ` [PATCH 06/10] PCI: PCI_TEST simple data Yinghai Lu
2017-08-05 6:37 ` [PATCH 07/10] PCI: PCI_TEST data from x5-8 Yinghai Lu
2017-08-05 6:37 ` [PATCH 08/10] PCI: PCI_TEST data from x5-8 with zeroed bus number Yinghai Lu
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=20170805063801.15880-2-yinghai@kernel.org \
--to=yinghai@kernel.org \
--cc=bhelgaas@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=torvalds@linux-foundation.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;
as well as URLs for NNTP newsgroup(s).