From: Konstantin Baydarov <kbaidarov@ru.mvista.com>
To: ebiederm@xmission.com (Eric W. Biederman)
Cc: "Pallipadi, Venkatesh" <venkatesh.pallipadi@intel.com>,
<vgoyal@in.ibm.com>, "RT" <linux-rt-users@vger.kernel.org>,
"linux-kernel" <linux-kernel@vger.kernel.org>,
"Andi Kleen" <ak@suse.de>,
Kexec Mailing List <kexec@lists.infradead.org>
Subject: Re: [PATCH] kexec: reenable HPET before kexec
Date: Thu, 30 Aug 2007 20:07:49 +0400 [thread overview]
Message-ID: <20070830200749.2f1f0a18@windmill.dev.rtsoft.ru> (raw)
In-Reply-To: <m1ps1532b5.fsf@ebiederm.dsl.xmission.com>
On Thu, 30 Aug 2007 01:32:30 -0600
ebiederm@xmission.com (Eric W. Biederman) wrote:
>
> Ok. It looks like you understand this issue.
>
> Can you please try calling hpet_disable_int from
> hpet_set_mode under CLOCK_EVT_MODE_SHUTDOWN. I haven't
> traced the clock event methods all of the way through
> but as a first approximation I think that will get
> things called at the appropriate time with out needing
> to patch machine_kexec. Which is very much the wrong
> place to add call any hpet code from.
>
> We may also need to make the hpet initialization more
> robust so we can do something sane in the kexec on panic
> case, where we deliberately don't run any shutdown methods.
>
> Eric
Eric, actually calling hpet_disable_int() under
CLOCK_EVT_MODE_SHUTDOWN is not enough, because
HPET might not be shutdown at all (we might want to use HPET and don't
want to use LAPIC timer or in some cases HPET is used as broadcast
device with LAPIC timers enabled). So, somehow, we should call
hpet_set_mode with CLOCK_EVT_MODE_SHUTDOWN as an argument before
machine_kexec. To solve this I've added timekeeping_shutdown() to
timekeeping.c that calls clockevents_notify(CLOCK_EVT_NOTIFY_SUSPEND,
NULL). Function timekeeping_shutdown() is called from sysdev_shutdown().
Also If we are adding hpet_disable_int() under
CLOCK_EVT_MODE_SHUTDOWN we have to add hpet_enable_int under
CLOCK_EVT_MODE_PERIODIC and CLOCK_EVT_MODE_ONESHOT.
Also I've added call of hpet_disable_int() to machine_crash_shutdown()
because, as you said, sysdev_shutdown() won't be called on crash before
machine_kexec().
Also, as we have to make hpet_disable_int() global and call it from
machine_crash_shutdown(), I suggest not to add hpet_disable_int() under
CLOCK_EVT_MODE_SHUTDOWN. If we don't add hpet_disable_int() under
CLOCK_EVT_MODE_SHUTDOWN - patch will be more smaller because we don't
have to call clockevents_notify() and we don't have to add
hpet_enable_int. We just have to add hpet_disable_int() call to
timekeeping_shutdown(). But it's just suggestion - attached patch adds
hpet_disable_int() under CLOCK_EVT_MODE_SHUTDOWN.
Here is new version of fix. It still against kernel 2.6.23-rc3. Thanks.
Signed-off-by: Konstantin Baydarov <kbaidarov@ru.mvista.com>
arch/i386/kernel/crash.c | 4 ++++
arch/i386/kernel/hpet.c | 33 +++++++++++++++++++++++++++++++++
include/asm-i386/hpet.h | 3 +++
kernel/time/timekeeping.c | 13 +++++++++++++
4 files changed, 53 insertions(+)
Index: linux-2.6.23-rc3/arch/i386/kernel/hpet.c
===================================================================
--- linux-2.6.23-rc3.orig/arch/i386/kernel/hpet.c
+++ linux-2.6.23-rc3/arch/i386/kernel/hpet.c
@@ -144,11 +144,35 @@ static void hpet_enable_int(void)
{
unsigned long cfg = hpet_readl(HPET_CFG);
+#ifdef CONFIG_KEXEC
+ if (hpet_legacy_int_enabled)
+ return;
+#endif
+
cfg |= HPET_CFG_LEGACY;
hpet_writel(cfg, HPET_CFG);
hpet_legacy_int_enabled = 1;
}
+#ifdef CONFIG_KEXEC
+void hpet_disable_int(void)
+{
+ unsigned long cfg;
+
+ if (!hpet_legacy_int_enabled)
+ return;
+
+ if (!is_hpet_capable())
+ return;
+
+ cfg = hpet_readl(HPET_CFG);
+ cfg &= ~HPET_CFG_LEGACY;
+ hpet_writel(cfg, HPET_CFG);
+ hpet_legacy_int_enabled = 0;
+
+}
+#endif
+
static void hpet_set_mode(enum clock_event_mode mode,
struct clock_event_device *evt)
{
@@ -157,6 +181,9 @@ static void hpet_set_mode(enum clock_eve
switch(mode) {
case CLOCK_EVT_MODE_PERIODIC:
+#ifdef CONFIG_KEXEC
+ hpet_enable_int();
+#endif
delta = ((uint64_t)(NSEC_PER_SEC/HZ)) * hpet_clockevent.mult;
delta >>= hpet_clockevent.shift;
now = hpet_readl(HPET_COUNTER);
@@ -176,6 +203,9 @@ static void hpet_set_mode(enum clock_eve
break;
case CLOCK_EVT_MODE_ONESHOT:
+#ifdef CONFIG_KEXEC
+ hpet_enable_int();
+#endif
cfg = hpet_readl(HPET_T0_CFG);
cfg &= ~HPET_TN_PERIODIC;
cfg |= HPET_TN_ENABLE | HPET_TN_32BIT;
@@ -187,6 +217,9 @@ static void hpet_set_mode(enum clock_eve
cfg = hpet_readl(HPET_T0_CFG);
cfg &= ~HPET_TN_ENABLE;
hpet_writel(cfg, HPET_T0_CFG);
+#ifdef CONFIG_KEXEC
+ hpet_disable_int();
+#endif
break;
case CLOCK_EVT_MODE_RESUME:
Index: linux-2.6.23-rc3/include/asm-i386/hpet.h
===================================================================
--- linux-2.6.23-rc3.orig/include/asm-i386/hpet.h
+++ linux-2.6.23-rc3/include/asm-i386/hpet.h
@@ -66,6 +66,9 @@
extern unsigned long hpet_address;
extern int is_hpet_enabled(void);
extern int hpet_enable(void);
+#ifdef CONFIG_KEXEC
+extern void hpet_disable_int(void);
+#endif
#ifdef CONFIG_HPET_EMULATE_RTC
Index: linux-2.6.23-rc3/arch/i386/kernel/crash.c
===================================================================
--- linux-2.6.23-rc3.orig/arch/i386/kernel/crash.c
+++ linux-2.6.23-rc3/arch/i386/kernel/crash.c
@@ -24,6 +24,7 @@
#include <asm/apic.h>
#include <linux/kdebug.h>
#include <asm/smp.h>
+#include <asm/hpet.h>
#include <mach_ipi.h>
@@ -128,6 +129,9 @@ void machine_crash_shutdown(struct pt_re
/* Make a note of crashing cpu. Will be used in NMI callback.*/
crashing_cpu = safe_smp_processor_id();
+#ifdef CONFIG_KEXEC
+ hpet_disable_int();
+#endif
nmi_shootdown_cpus();
lapic_shutdown();
#if defined(CONFIG_X86_IO_APIC)
Index: linux-2.6.23-rc3/kernel/time/timekeeping.c
===================================================================
--- linux-2.6.23-rc3.orig/kernel/time/timekeeping.c
+++ linux-2.6.23-rc3/kernel/time/timekeeping.c
@@ -335,8 +335,21 @@ static int timekeeping_suspend(struct sy
return 0;
}
+#ifdef CONFIG_KEXEC
+static int timekeeping_shutdown(struct sys_device *dev)
+{
+ clockevents_notify(CLOCK_EVT_NOTIFY_SUSPEND, NULL);
+// hpet_disable_int();
+
+ return 0;
+}
+#endif
+
/* sysfs resume/suspend bits for timekeeping */
static struct sysdev_class timekeeping_sysclass = {
+#ifdef CONFIG_KEXEC
+ .shutdown = timekeeping_shutdown,
+#endif
.resume = timekeeping_resume,
.suspend = timekeeping_suspend,
set_kset_name("timekeeping"),
next prev parent reply other threads:[~2007-08-30 16:01 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-20 16:55 [PATCH] kexec: reenable HPET before kexec Konstantin Baydarov
2007-08-20 18:26 ` Andi Kleen
2007-08-20 21:10 ` Konstantin Baydarov
2007-08-20 21:31 ` Daniel Walker
2007-08-21 13:01 ` Konstantin Baydarov
2007-08-23 9:08 ` Vivek Goyal
2007-08-23 11:49 ` Konstantin Baydarov
2007-08-27 5:36 ` Vivek Goyal
2007-08-27 18:26 ` Pallipadi, Venkatesh
2007-08-27 18:33 ` Eric W. Biederman
2007-08-28 12:58 ` Konstantin Baydarov
2007-08-30 7:32 ` Eric W. Biederman
2007-08-30 16:07 ` Konstantin Baydarov [this message]
2007-08-30 18:04 ` Eric W. Biederman
2007-08-31 10:31 ` Konstantin Baydarov
2007-09-17 9:47 ` Konstantin Baydarov
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=20070830200749.2f1f0a18@windmill.dev.rtsoft.ru \
--to=kbaidarov@ru.mvista.com \
--cc=ak@suse.de \
--cc=ebiederm@xmission.com \
--cc=kexec@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-users@vger.kernel.org \
--cc=venkatesh.pallipadi@intel.com \
--cc=vgoyal@in.ibm.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