* [PATCH] clean up mach_reboot_fixups
@ 2007-03-14 22:24 Jeremy Fitzhardinge
2007-03-14 22:42 ` Andi Kleen
0 siblings, 1 reply; 6+ messages in thread
From: Jeremy Fitzhardinge @ 2007-03-14 22:24 UTC (permalink / raw)
To: Andi Kleen; +Cc: Linux Kernel Mailing List
The reboot_fixups stuff seems to be a bit of a mess, specifically the
header is in linux/ when its a purely i386-specific piece of code. I'm
not sure why it has its config option; its only currently needed for
"geode-gx1/cs5530a", so perhaps whatever config option controls that
hardware should enable this?
Signed-off-by: Jeremy Fitzhardinge <jeremy@xensource.com>
---
arch/i386/kernel/reboot.c | 6 +++++-
arch/i386/kernel/reboot_fixups.c | 2 +-
include/asm-i386/reboot_fixups.h | 6 ++++++
include/linux/reboot_fixups.h | 10 ----------
4 files changed, 12 insertions(+), 12 deletions(-)
===================================================================
--- a/arch/i386/kernel/reboot.c
+++ b/arch/i386/kernel/reboot.c
@@ -17,7 +17,7 @@
#include <asm/apic.h>
#include <asm/desc.h>
#include "mach_reboot.h"
-#include <linux/reboot_fixups.h>
+#include <asm/reboot_fixups.h>
/*
* Power off function, if any
@@ -314,6 +314,10 @@ void machine_shutdown(void)
#ifdef CONFIG_X86_IO_APIC
disable_IO_APIC();
#endif
+}
+
+void __attribute__((weak)) mach_reboot_fixups(void)
+{
}
void machine_emergency_restart(void)
===================================================================
--- a/arch/i386/kernel/reboot_fixups.c
+++ b/arch/i386/kernel/reboot_fixups.c
@@ -10,7 +10,7 @@
#include <asm/delay.h>
#include <linux/pci.h>
-#include <linux/reboot_fixups.h>
+#include <asm/reboot_fixups.h>
static void cs5530a_warm_reset(struct pci_dev *dev)
{
===================================================================
--- /dev/null
+++ b/include/asm-i386/reboot_fixups.h
@@ -0,0 +1,6 @@
+#ifndef _LINUX_REBOOT_FIXUPS_H
+#define _LINUX_REBOOT_FIXUPS_H
+
+extern void mach_reboot_fixups(void);
+
+#endif /* _LINUX_REBOOT_FIXUPS_H */
===================================================================
--- a/include/linux/reboot_fixups.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef _LINUX_REBOOT_FIXUPS_H
-#define _LINUX_REBOOT_FIXUPS_H
-
-#ifdef CONFIG_X86_REBOOTFIXUPS
-extern void mach_reboot_fixups(void);
-#else
-#define mach_reboot_fixups() ((void)(0))
-#endif
-
-#endif /* _LINUX_REBOOT_FIXUPS_H */
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] clean up mach_reboot_fixups
2007-03-14 22:24 [PATCH] clean up mach_reboot_fixups Jeremy Fitzhardinge
@ 2007-03-14 22:42 ` Andi Kleen
2007-03-15 2:18 ` Geode cs5530a magic (Was: Re: [PATCH] clean up mach_reboot_fixups) Jeremy Fitzhardinge
0 siblings, 1 reply; 6+ messages in thread
From: Andi Kleen @ 2007-03-14 22:42 UTC (permalink / raw)
To: Jeremy Fitzhardinge; +Cc: Linux Kernel Mailing List
On Wednesday 14 March 2007 23:24, Jeremy Fitzhardinge wrote:
> The reboot_fixups stuff seems to be a bit of a mess, specifically the
> header is in linux/ when its a purely i386-specific piece of code. I'm
> not sure why it has its config option; its only currently needed for
> "geode-gx1/cs5530a", so perhaps whatever config option controls that
> hardware should enable this?
Thanks. Looks good.
-Andi
^ permalink raw reply [flat|nested] 6+ messages in thread
* Geode cs5530a magic (Was: Re: [PATCH] clean up mach_reboot_fixups)
2007-03-14 22:42 ` Andi Kleen
@ 2007-03-15 2:18 ` Jeremy Fitzhardinge
2007-03-19 14:48 ` Eric W. Biederman
0 siblings, 1 reply; 6+ messages in thread
From: Jeremy Fitzhardinge @ 2007-03-15 2:18 UTC (permalink / raw)
To: Andi Kleen; +Cc: Linux Kernel Mailing List, Alan Cox, Jaya Kumar
Andi Kleen wrote:
> On Wednesday 14 March 2007 23:24, Jeremy Fitzhardinge wrote:
>
>> The reboot_fixups stuff seems to be a bit of a mess, specifically the
>> header is in linux/ when its a purely i386-specific piece of code. I'm
>> not sure why it has its config option; its only currently needed for
>> "geode-gx1/cs5530a", so perhaps whatever config option controls that
>> hardware should enable this?
>>
>
> Thanks. Looks good.
It looks like a cs5530a is a PATA driver in drivers/ata/pata_cs5530.c.
Seems to me the cleanest fix is to register a reboot notifier in the
driver and have it do the magic rather than have the special
mach_reboot_fixups mechanism at all.
Assuming it needs to be done at all...
Alan? Jaya?
J
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: Geode cs5530a magic (Was: Re: [PATCH] clean up mach_reboot_fixups)
2007-03-15 2:18 ` Geode cs5530a magic (Was: Re: [PATCH] clean up mach_reboot_fixups) Jeremy Fitzhardinge
@ 2007-03-19 14:48 ` Eric W. Biederman
0 siblings, 0 replies; 6+ messages in thread
From: Eric W. Biederman @ 2007-03-19 14:48 UTC (permalink / raw)
To: Jeremy Fitzhardinge
Cc: Andi Kleen, Linux Kernel Mailing List, Alan Cox, Jaya Kumar
Jeremy Fitzhardinge <jeremy@goop.org> writes:
> Andi Kleen wrote:
>> On Wednesday 14 March 2007 23:24, Jeremy Fitzhardinge wrote:
>>
>>> The reboot_fixups stuff seems to be a bit of a mess, specifically the
>>> header is in linux/ when its a purely i386-specific piece of code. I'm
>>> not sure why it has its config option; its only currently needed for
>>> "geode-gx1/cs5530a", so perhaps whatever config option controls that
>>> hardware should enable this?
>>>
>>
>> Thanks. Looks good.
>
> It looks like a cs5530a is a PATA driver in drivers/ata/pata_cs5530.c.
> Seems to me the cleanest fix is to register a reboot notifier in the
> driver and have it do the magic rather than have the special
> mach_reboot_fixups mechanism at all.
>
> Assuming it needs to be done at all...
>
> Alan? Jaya?
I'm guessing rather it is an embedded setup, then a weird pata thing.
If we want to remove crud from this path we should provide a hook like
pm_power_off to handle the reboot case.
This is not the kind of thing that a reboot notifier can be used for.
as:
a) reboot notifiers don't get called on all paths to machine_emergency_restart.
b) touching those bits looks like they immediately flip the reset line, so
trigger the reboot immediately.
Eric
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] Simplify smp_call_function*() by using common implementation
@ 2007-03-27 22:13 Jeremy Fitzhardinge
2007-03-28 19:43 ` [PATCH] Add machine_ops interface to abstract halting and rebooting Andi Kleen
0 siblings, 1 reply; 6+ messages in thread
From: Jeremy Fitzhardinge @ 2007-03-27 22:13 UTC (permalink / raw)
To: Andrew Morton
Cc: Linux Kernel Mailing List, Virtualization Mailing List,
Jan Beulich, Stephane Eranian, Andi Kleen, Ingo Molnar,
Randy.Dunlap
smp_call_function and smp_call_function_single are almost complete
duplicates of the same logic. This patch combines them by
implementing them in terms of the more general
smp_call_function_mask().
[ Jan, Andi: This only changes arch/i386; can x86_64 be changed in the
same way? ]
[ Rebased onto Jan's x86_64-mm-consolidate-smp_send_stop patch ]
Signed-off-by: Jeremy Fitzhardinge <jeremy@xensource.com>
Cc: Jan Beulich <jbeulich@novell.com>
Cc: Stephane Eranian <eranian@hpl.hp.com>
Cc: Andrew Morton <akpm@osdl.org>
Cc: Andi Kleen <ak@suse.de>
Cc: "Randy.Dunlap" <rdunlap@xenotime.net>
Cc: Ingo Molnar <mingo@elte.hu>
---
arch/i386/kernel/smp.c | 177 +++++++++++++++++++++++-------------------------
1 file changed, 86 insertions(+), 91 deletions(-)
===================================================================
--- a/arch/i386/kernel/smp.c
+++ b/arch/i386/kernel/smp.c
@@ -515,14 +515,26 @@ void unlock_ipi_call_lock(void)
static struct call_data_struct *call_data;
-static void __smp_call_function(void (*func) (void *info), void *info,
- int nonatomic, int wait)
+
+static int __smp_call_function_mask(cpumask_t mask,
+ void (*func)(void *), void *info,
+ int wait)
{
struct call_data_struct data;
- int cpus = num_online_cpus() - 1;
+ cpumask_t allbutself;
+ int cpus;
+
+ /* Can deadlock when called with interrupts disabled */
+ WARN_ON(irqs_disabled());
+
+ allbutself = cpu_online_map;
+ cpu_clear(smp_processor_id(), allbutself);
+
+ cpus_and(mask, mask, allbutself);
+ cpus = cpus_weight(mask);
if (!cpus)
- return;
+ return 0;
data.func = func;
data.info = info;
@@ -533,9 +545,12 @@ static void __smp_call_function(void (*f
call_data = &data;
mb();
-
- /* Send a message to all other CPUs and wait for them to respond */
- send_IPI_allbutself(CALL_FUNCTION_VECTOR);
+
+ /* Send a message to other CPUs */
+ if (cpus_equal(mask, allbutself))
+ send_IPI_allbutself(CALL_FUNCTION_VECTOR);
+ else
+ send_IPI_mask(mask, CALL_FUNCTION_VECTOR);
/* Wait for response */
while (atomic_read(&data.started) != cpus)
@@ -544,6 +559,34 @@ static void __smp_call_function(void (*f
if (wait)
while (atomic_read(&data.finished) != cpus)
cpu_relax();
+
+ return 0;
+}
+
+/**
+ * smp_call_function_mask(): Run a function on a set of other CPUs.
+ * @mask: The set of cpus to run on. Must not include the current cpu.
+ * @func: The function to run. This must be fast and non-blocking.
+ * @info: An arbitrary pointer to pass to the function.
+ * @wait: If true, wait (atomically) until function has completed on other CPUs.
+ *
+ * Returns 0 on success, else a negative status code. Does not return until
+ * remote CPUs are nearly ready to execute <<func>> or are or have finished.
+ *
+ * You must not call this function with disabled interrupts or from a
+ * hardware interrupt handler or from a bottom half handler.
+ */
+int smp_call_function_mask(cpumask_t mask,
+ void (*func)(void *), void *info,
+ int wait)
+{
+ int ret;
+
+ spin_lock(&call_lock);
+ ret = __smp_call_function_mask(mask, func, info, wait);
+ spin_unlock(&call_lock);
+
+ return ret;
}
/**
@@ -559,20 +602,43 @@ static void __smp_call_function(void (*f
* You must not call this function with disabled interrupts or from a
* hardware interrupt handler or from a bottom half handler.
*/
-int smp_call_function (void (*func) (void *info), void *info, int nonatomic,
- int wait)
-{
- /* Can deadlock when called with interrupts disabled */
- WARN_ON(irqs_disabled());
-
- /* Holding any lock stops cpus from going down. */
- spin_lock(&call_lock);
- __smp_call_function(func, info, nonatomic, wait);
- spin_unlock(&call_lock);
-
- return 0;
+int smp_call_function(void (*func) (void *info), void *info, int nonatomic,
+ int wait)
+{
+ return smp_call_function_mask(cpu_online_map, func, info, wait);
}
EXPORT_SYMBOL(smp_call_function);
+
+/*
+ * smp_call_function_single - Run a function on another CPU
+ * @func: The function to run. This must be fast and non-blocking.
+ * @info: An arbitrary pointer to pass to the function.
+ * @nonatomic: Currently unused.
+ * @wait: If true, wait until function has completed on other CPUs.
+ *
+ * Retrurns 0 on success, else a negative status code.
+ *
+ * Does not return until the remote CPU is nearly ready to execute <func>
+ * or is or has executed.
+ */
+int smp_call_function_single(int cpu, void (*func) (void *info), void *info,
+ int nonatomic, int wait)
+{
+ /* prevent preemption and reschedule on another processor */
+ int ret;
+ int me = get_cpu();
+ if (cpu == me) {
+ WARN_ON(1);
+ put_cpu();
+ return -EBUSY;
+ }
+
+ ret = smp_call_function_mask(cpumask_of_cpu(cpu), func, info, wait);
+
+ put_cpu();
+ return ret;
+}
+EXPORT_SYMBOL(smp_call_function_single);
static void stop_this_cpu (void * dummy)
{
@@ -598,7 +664,7 @@ void smp_send_stop(void)
unsigned long flags;
local_irq_save(flags);
- __smp_call_function(stop_this_cpu, NULL, 0, 0);
+ __smp_call_function_mask(cpu_online_map, stop_this_cpu, NULL, 0);
if (!nolock)
spin_unlock(&call_lock);
disable_local_APIC();
@@ -641,77 +707,6 @@ fastcall void smp_call_function_interrup
}
}
-/*
- * this function sends a 'generic call function' IPI to one other CPU
- * in the system.
- *
- * cpu is a standard Linux logical CPU number.
- */
-static void
-__smp_call_function_single(int cpu, void (*func) (void *info), void *info,
- int nonatomic, int wait)
-{
- struct call_data_struct data;
- int cpus = 1;
-
- data.func = func;
- data.info = info;
- atomic_set(&data.started, 0);
- data.wait = wait;
- if (wait)
- atomic_set(&data.finished, 0);
-
- call_data = &data;
- wmb();
- /* Send a message to all other CPUs and wait for them to respond */
- send_IPI_mask(cpumask_of_cpu(cpu), CALL_FUNCTION_VECTOR);
-
- /* Wait for response */
- while (atomic_read(&data.started) != cpus)
- cpu_relax();
-
- if (!wait)
- return;
-
- while (atomic_read(&data.finished) != cpus)
- cpu_relax();
-}
-
-/*
- * smp_call_function_single - Run a function on another CPU
- * @func: The function to run. This must be fast and non-blocking.
- * @info: An arbitrary pointer to pass to the function.
- * @nonatomic: Currently unused.
- * @wait: If true, wait until function has completed on other CPUs.
- *
- * Retrurns 0 on success, else a negative status code.
- *
- * Does not return until the remote CPU is nearly ready to execute <func>
- * or is or has executed.
- */
-
-int smp_call_function_single(int cpu, void (*func) (void *info), void *info,
- int nonatomic, int wait)
-{
- /* prevent preemption and reschedule on another processor */
- int me = get_cpu();
- if (cpu == me) {
- WARN_ON(1);
- put_cpu();
- return -EBUSY;
- }
-
- /* Can deadlock when called with interrupts disabled */
- WARN_ON(irqs_disabled());
-
- spin_lock_bh(&call_lock);
- __smp_call_function_single(cpu, func, info, nonatomic, wait);
- spin_unlock_bh(&call_lock);
- put_cpu();
- return 0;
-}
-EXPORT_SYMBOL(smp_call_function_single);
-
static int convert_apicid_to_cpu(int apic_id)
{
int i;
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] Add machine_ops interface to abstract halting and rebooting
@ 2007-03-28 19:43 ` Andi Kleen
2007-03-28 19:47 ` Jeremy Fitzhardinge
0 siblings, 1 reply; 6+ messages in thread
From: Andi Kleen @ 2007-03-28 19:43 UTC (permalink / raw)
To: Jeremy Fitzhardinge
Cc: Andrew Morton, Linux Kernel Mailing List,
Virtualization Mailing List, Jan Beulich, Stephane Eranian,
Ingo Molnar, Randy.Dunlap
On Wednesday 28 March 2007 21:32, Jeremy Fitzhardinge wrote:
> machine_ops is an interface for the machine_* functions defined in
> <linux/reboot.h>. This is intended to allow hypervisors to intercept
> the reboot process, but it could be used to implement other x86
> subarchtecture reboots.
Both patches added thanks
-Andi
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Add machine_ops interface to abstract halting and rebooting
2007-03-28 19:43 ` [PATCH] Add machine_ops interface to abstract halting and rebooting Andi Kleen
@ 2007-03-28 19:47 ` Jeremy Fitzhardinge
2007-03-28 19:54 ` Andi Kleen
0 siblings, 1 reply; 6+ messages in thread
From: Jeremy Fitzhardinge @ 2007-03-28 19:47 UTC (permalink / raw)
To: Andi Kleen
Cc: Andrew Morton, Linux Kernel Mailing List,
Virtualization Mailing List, Jan Beulich, Stephane Eranian,
Ingo Molnar, Randy.Dunlap
Andi Kleen wrote:
> On Wednesday 28 March 2007 21:32, Jeremy Fitzhardinge wrote:
>
>> machine_ops is an interface for the machine_* functions defined in
>> <linux/reboot.h>. This is intended to allow hypervisors to intercept
>> the reboot process, but it could be used to implement other x86
>> subarchtecture reboots.
>>
>
> Both patches added thanks
>
I presume you've also got the reboot-fixups cleanup patch?
J
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] Add machine_ops interface to abstract halting and rebooting
2007-03-28 19:47 ` Jeremy Fitzhardinge
@ 2007-03-28 19:54 ` Andi Kleen
2007-03-28 20:11 ` [PATCH] Clean up mach_reboot_fixups Jeremy Fitzhardinge
0 siblings, 1 reply; 6+ messages in thread
From: Andi Kleen @ 2007-03-28 19:54 UTC (permalink / raw)
To: Jeremy Fitzhardinge
Cc: Andrew Morton, Linux Kernel Mailing List,
Virtualization Mailing List, Jan Beulich, Stephane Eranian,
Ingo Molnar, Randy.Dunlap
On Wednesday 28 March 2007 21:47, Jeremy Fitzhardinge wrote:
> Andi Kleen wrote:
> > On Wednesday 28 March 2007 21:32, Jeremy Fitzhardinge wrote:
> >
> >> machine_ops is an interface for the machine_* functions defined in
> >> <linux/reboot.h>. This is intended to allow hypervisors to intercept
> >> the reboot process, but it could be used to implement other x86
> >> subarchtecture reboots.
> >>
> >
> > Both patches added thanks
> >
>
> I presume you've also got the reboot-fixups cleanup patch?
No, please resend too
-Andi
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] Clean up mach_reboot_fixups
2007-03-28 19:54 ` Andi Kleen
@ 2007-03-28 20:11 ` Jeremy Fitzhardinge
2007-03-28 20:14 ` Andi Kleen
0 siblings, 1 reply; 6+ messages in thread
From: Jeremy Fitzhardinge @ 2007-03-28 20:11 UTC (permalink / raw)
To: Andi Kleen
Cc: Jeremy Fitzhardinge, Virtualization Mailing List,
Stephane Eranian, Andrew Morton, Ingo Molnar, Jan Beulich,
Linux Kernel Mailing List
Two cleanups:
- reboot_fixups.h is entirely i386-dependent, so put it in asm-i386
- use a weak version rather than ifdeffery
[ Andi - the machine_ops probably depends on this, but only in a minor
context-clash way. ]
Signed-off-by: Jeremy Fitzhardinge <jeremy@xensource.com>
Cc: Jaya Kumar <jayalk@intworks.biz>
---
arch/i386/kernel/reboot.c | 6 +++++-
arch/i386/kernel/reboot_fixups.c | 2 +-
include/asm-i386/reboot_fixups.h | 6 ++++++
include/linux/reboot_fixups.h | 10 ----------
4 files changed, 12 insertions(+), 12 deletions(-)
===================================================================
--- a/arch/i386/kernel/reboot.c
+++ b/arch/i386/kernel/reboot.c
@@ -17,7 +17,7 @@
#include <asm/apic.h>
#include <asm/desc.h>
#include "mach_reboot.h"
-#include <linux/reboot_fixups.h>
+#include <asm/reboot_fixups.h>
/*
* Power off function, if any
@@ -314,6 +314,10 @@ void machine_shutdown(void)
#ifdef CONFIG_X86_IO_APIC
disable_IO_APIC();
#endif
+}
+
+void __attribute__((weak)) mach_reboot_fixups(void)
+{
}
void machine_emergency_restart(void)
===================================================================
--- a/arch/i386/kernel/reboot_fixups.c
+++ b/arch/i386/kernel/reboot_fixups.c
@@ -10,7 +10,7 @@
#include <asm/delay.h>
#include <linux/pci.h>
-#include <linux/reboot_fixups.h>
+#include <asm/reboot_fixups.h>
static void cs5530a_warm_reset(struct pci_dev *dev)
{
===================================================================
--- /dev/null
+++ b/include/asm-i386/reboot_fixups.h
@@ -0,0 +1,6 @@
+#ifndef _LINUX_REBOOT_FIXUPS_H
+#define _LINUX_REBOOT_FIXUPS_H
+
+extern void mach_reboot_fixups(void);
+
+#endif /* _LINUX_REBOOT_FIXUPS_H */
===================================================================
--- a/include/linux/reboot_fixups.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef _LINUX_REBOOT_FIXUPS_H
-#define _LINUX_REBOOT_FIXUPS_H
-
-#ifdef CONFIG_X86_REBOOTFIXUPS
-extern void mach_reboot_fixups(void);
-#else
-#define mach_reboot_fixups() ((void)(0))
-#endif
-
-#endif /* _LINUX_REBOOT_FIXUPS_H */
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] Clean up mach_reboot_fixups
2007-03-28 20:11 ` [PATCH] Clean up mach_reboot_fixups Jeremy Fitzhardinge
@ 2007-03-28 20:14 ` Andi Kleen
0 siblings, 0 replies; 6+ messages in thread
From: Andi Kleen @ 2007-03-28 20:14 UTC (permalink / raw)
To: Jeremy Fitzhardinge
Cc: Virtualization Mailing List, Stephane Eranian, Andrew Morton,
Ingo Molnar, Jan Beulich, Linux Kernel Mailing List
On Wednesday 28 March 2007 22:11, Jeremy Fitzhardinge wrote:
> Two cleanups:
> - reboot_fixups.h is entirely i386-dependent, so put it in asm-i386
> - use a weak version rather than ifdeffery
>
> [ Andi - the machine_ops probably depends on this, but only in a minor
> context-clash way. ]
Sorry I actually had it already, but forgot about it
-Andi
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2007-03-28 20:15 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-14 22:24 [PATCH] clean up mach_reboot_fixups Jeremy Fitzhardinge
2007-03-14 22:42 ` Andi Kleen
2007-03-15 2:18 ` Geode cs5530a magic (Was: Re: [PATCH] clean up mach_reboot_fixups) Jeremy Fitzhardinge
2007-03-19 14:48 ` Eric W. Biederman
-- strict thread matches above, loose matches on Subject: below --
2007-03-27 22:13 [PATCH] Simplify smp_call_function*() by using common implementation Jeremy Fitzhardinge
2007-03-28 19:43 ` [PATCH] Add machine_ops interface to abstract halting and rebooting Andi Kleen
2007-03-28 19:47 ` Jeremy Fitzhardinge
2007-03-28 19:54 ` Andi Kleen
2007-03-28 20:11 ` [PATCH] Clean up mach_reboot_fixups Jeremy Fitzhardinge
2007-03-28 20:14 ` Andi Kleen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox