From: Ingo Molnar <mingo@elte.hu>
To: Yinghai Lu <yhlu.kernel@gmail.com>
Cc: David Witbrodt <dawitbro@sbcglobal.net>,
Linux-kernel Mailing List <linux-kernel@vger.kernel.org>,
Jesse Barnes <jbarnes@virtuousgeek.org>,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: HPET regression in 2.6.26 versus 2.6.25 -- found another user with the same regression
Date: Mon, 25 Aug 2008 09:31:25 +0200 [thread overview]
Message-ID: <20080825073125.GA27950@elte.hu> (raw)
In-Reply-To: <86802c440808242141j716b5875s709dc56c1163a7d5@mail.gmail.com>
* Yinghai Lu <yhlu.kernel@gmail.com> wrote:
> this one should work. please apply this one only.
>
> YH
>
> [PATCH] x86: check hpet with BAR v2
great. I've cleaned it up a bit (see the final commit below) and queued
it up in tip/x86/urgent for some testing. But there are a few open
questions, and an Ack/feedback from Jesse/Linus would be nice as well:
- the forced insertion and the embedded knowledge about iomem_resource
and ioport_resource looks ugly to me.
- we should also extend this to other platform resource types that we
know about: ioapic address(es) might be a prime candidate. (local
APICs are CPU entities and should never show up as PCI devices) The
mmconfig range is already properly accounted for by the PCI code
itself, right?
- plus a more highlevel approach would be nice as well i think - making
sure that the hpet driver runs before any of the PCI code, and
inserting a special "sticky" resource there which would keep any
potential followup generic PCI resource that overlaps this resource
untouched. (with a proper kernel warning emitted as well - such
situations are likely BIOS bugs.)
Possibly not for v2.6.27 though.
Ingo
----------->
>From f3865e9710bd4ac5750feae628469f998e49d0b4 Mon Sep 17 00:00:00 2001
From: Yinghai Lu <yhlu.kernel@gmail.com>
Date: Sun, 24 Aug 2008 21:41:28 -0700
Subject: [PATCH] x86: fix HPET regression in 2.6.26 versus 2.6.25, check hpet against BAR v2
David Witbrodt tracked down (and bisected) a bootup hang on his system
to the following problem: a BIOS bug made the hpet device visible as a
generic PCI device. If e820 reserved entries happen to be registered
first in the resource tree [which v2.6.26 started doing - to fix other
bugs], then the PCI code will reallocate that device's BAR to some other
address - breaking timer IRQs and hanging the system.
( Normally hpet devices are hidden by the BIOS from the OS's PCI discovery
via chipset magic. Sometimes the hpet is not a PCI device at all. )
Solve this fundamental fragility by making the non-PCI platform driver
insert resources into the resource tree even if it overlaps the e820
reserved entry, to keep the resource manager from updating the BAR.
NOTE: this is an RFC for now, there might be other, better approaches
as well:
- introduce a new resource type that is 'sticky': it would keep BARs
that are embedded in it from being reallocated.
or
- update the hpet_address from the PCI code. This is risky though: these
PCI devices are often non-generic and might break if we change their
BAR.
or
- do not insert e820 reserved entries at all. This would have
disadvantages as well: if there's some special non-RAM ACPI or SMM
area known to the system and enumerated in the e820 map, we must not
allow the PCI code from possibly allocating a resource into that
region.
[ mingo@elte.hu: cleanups ]
Bisected-by: David Witbrodt <dawitbro@sbcglobal.net>
Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Tested-by: David Witbrodt <dawitbro@sbcglobal.net>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
arch/x86/pci/i386.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 44 insertions(+), 0 deletions(-)
diff --git a/arch/x86/pci/i386.c b/arch/x86/pci/i386.c
index 5807d1b..562ec4d 100644
--- a/arch/x86/pci/i386.c
+++ b/arch/x86/pci/i386.c
@@ -33,6 +33,7 @@
#include <linux/bootmem.h>
#include <asm/pat.h>
+#include <asm/hpet.h>
#include "pci.h"
@@ -78,6 +79,47 @@ pcibios_align_resource(void *data, struct resource *res,
EXPORT_SYMBOL(pcibios_align_resource);
/*
+ * Make sure we protect magic platform devices such as hpet,
+ * even if they show up in PCI discovery. (which should really
+ * not happen, but it does on some broken BIOSen)
+ */
+static int check_platform(struct pci_dev *dev, struct resource *res)
+{
+ unsigned long base;
+ unsigned long size;
+
+ base = res->start;
+ size = (res->start == 0 && res->end == res->start) ? 0 :
+ (res->end - res->start + 1);
+
+ if (!base || !size)
+ return 0;
+
+#ifdef CONFIG_HPET_TIMER
+ /* for hpet */
+ if (base == hpet_address && (res->flags & IORESOURCE_MEM)) {
+ struct resource *root = NULL;
+
+ WARN("BAR has HPET at %08lx-%08lx\n", base, base + size - 1);
+ /*
+ * forcibly insert it into the
+ * resource tree
+ */
+ if (res->flags & IORESOURCE_MEM)
+ root = &iomem_resource;
+ else if (res->flags & IORESOURCE_IO)
+ root = &ioport_resource;
+
+ if (root)
+ insert_resource(root, res);
+ return 1;
+ }
+#endif
+
+ return 0;
+}
+
+/*
* Handle resources of PCI devices. If the world were perfect, we could
* just allocate all the resource regions and do nothing more. It isn't.
* On the other hand, we cannot just re-allocate all devices, as it would
@@ -171,6 +213,8 @@ static void __init pcibios_allocate_resources(int pass)
r->flags, disabled, pass);
pr = pci_find_parent_resource(dev, r);
if (!pr || request_resource(pr, r) < 0) {
+ if (check_platform(dev, r))
+ continue;
dev_err(&dev->dev, "BAR %d: can't "
"allocate resource\n", idx);
/* We'll assign a new address later */
next prev parent reply other threads:[~2008-08-25 7:31 UTC|newest]
Thread overview: 79+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-25 2:00 HPET regression in 2.6.26 versus 2.6.25 -- found another user with the same regression David Witbrodt
2008-08-25 2:37 ` Yinghai Lu
2008-08-25 4:41 ` Yinghai Lu
2008-08-25 6:27 ` Ingo Molnar
2008-08-25 6:40 ` Yinghai Lu
2008-08-25 7:31 ` Ingo Molnar [this message]
2008-08-25 8:00 ` Yinghai Lu
2008-08-27 22:41 ` Jesse Barnes
2008-08-27 23:23 ` Yinghai Lu
2008-08-27 23:42 ` Jesse Barnes
-- strict thread matches above, loose matches on Subject: below --
2008-08-26 15:25 David Witbrodt
2008-08-26 12:58 David Witbrodt
2008-08-26 13:28 ` Ingo Molnar
2008-08-25 13:39 David Witbrodt
2008-08-25 17:24 ` Yinghai Lu
2008-08-25 17:28 ` Yinghai Lu
2008-08-25 3:06 David Witbrodt
2008-08-24 13:05 David Witbrodt
2008-08-24 19:29 ` Yinghai Lu
2008-08-24 22:48 ` Yinghai Lu
2008-08-24 2:39 David Witbrodt
2008-08-24 3:44 ` Yinghai Lu
2008-08-23 23:42 David Witbrodt
2008-08-24 2:05 ` Yinghai Lu
2008-08-23 19:47 David Witbrodt
2008-08-23 20:12 ` Yinghai Lu
2008-08-23 20:51 ` Yinghai Lu
2008-08-23 19:29 David Witbrodt
2008-08-23 18:26 Rufus & Azrael
2008-08-23 19:17 ` Yinghai Lu
2008-08-23 19:40 ` Rufus & Azrael
2008-08-23 20:10 ` Yinghai Lu
2008-08-23 20:15 ` Rufus & Azrael
2008-08-23 20:28 ` Yinghai Lu
2008-08-23 20:33 ` Rufus & Azrael
2008-08-23 20:35 ` Yinghai Lu
2008-08-23 20:36 ` Rufus & Azrael
2008-08-23 20:45 ` Yinghai Lu
2008-08-23 21:05 ` Yinghai Lu
2008-08-28 22:52 ` Jordan Crouse
2008-09-12 17:39 ` Andreas Herrmann
2008-09-12 17:45 ` Jordan Crouse
2008-09-14 16:25 ` Ingo Molnar
2008-08-23 16:44 David Witbrodt
2008-08-23 16:32 David Witbrodt
2008-08-23 15:42 David Witbrodt
2008-08-23 15:55 ` Ingo Molnar
2008-08-23 11:58 David Witbrodt
2008-08-23 13:36 ` Ingo Molnar
2008-08-23 15:03 ` Ingo Molnar
2008-08-23 17:51 ` Yinghai Lu
2008-08-23 11:42 David Witbrodt
2008-08-23 2:25 David Witbrodt
2008-08-23 5:41 ` Yinghai Lu
2008-08-23 6:56 ` Yinghai Lu
2008-08-22 1:24 David Witbrodt
2008-08-21 16:53 David Witbrodt
2008-08-21 17:57 ` Yinghai Lu
2008-08-21 14:09 David Witbrodt
2008-08-21 15:33 ` Yinghai Lu
2008-08-21 13:33 David Witbrodt
2008-08-21 4:07 David Witbrodt
2008-08-21 6:42 ` Yinghai Lu
2008-08-21 7:04 ` Ilpo Järvinen
2008-08-21 2:48 David Witbrodt
2008-08-20 17:42 David Witbrodt
2008-08-20 17:58 ` Yinghai Lu
2008-08-21 2:02 ` Yinghai Lu
2008-08-20 16:44 David Witbrodt
2008-08-20 14:32 David Witbrodt
2008-08-20 14:49 ` Ingo Molnar
2008-08-20 14:08 David Witbrodt
2008-08-20 4:51 David Witbrodt
2008-08-20 5:21 ` Yinghai Lu
2008-08-20 7:51 ` Bill Fink
2008-08-20 8:02 ` Yinghai Lu
2008-08-20 9:15 ` Ingo Molnar
2008-08-20 9:31 ` Yinghai Lu
2008-08-20 9:36 ` Ingo Molnar
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=20080825073125.GA27950@elte.hu \
--to=mingo@elte.hu \
--cc=dawitbro@sbcglobal.net \
--cc=jbarnes@virtuousgeek.org \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=yhlu.kernel@gmail.com \
/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