public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Cleanup subarch definitions in Linux/i386
@ 2006-03-30  4:18 Zachary Amsden
  2006-03-30  8:00 ` Chris Wright
  0 siblings, 1 reply; 3+ messages in thread
From: Zachary Amsden @ 2006-03-30  4:18 UTC (permalink / raw)
  To: Andrew Morton, Linus Torvalds, Linux Kernel Mailing List, pazke,
	James.Bottomley

[-- Attachment #1: Type: text/plain, Size: 1609 bytes --]

There is some redundant code and unnecessary function calls where 
inlines would be more appropriate in many of the sub-arches of i386.  In 
addition, some subarches do not compile with certain kernel config 
options, which needed to be fixed.  I have attempted to clean up the 
subarch implementation of i386 by removing the requirement of 
implementing a complete setup.c; instead, architectures are free to 
define only the hooks they actually need in the subarch headers, by 
introducing mach-xxx/mach_hooks.h and putting the generic definitions in 
arch_hooks.h.

I have tested this as best as I can, and all of the subarches continue 
to compile (in fact, even better with the config fixes).  I don't have 
all of the hardware combinations to actually test the generated kernels, 
but in general, this is fairly straightforward code movement.  One 
liberty I took was removing the sub-arch hook for mca_nmi_handler, as it 
is clear this does not apply to any other subarch than Voyager.

I created a new file, arch/i386/default.c, which has the default 
functions that are appropriate for all kernel compiles, which removes 
the redundant need to redefine IPI mechanisms in all architectures that 
provide a setup.c file.  This was required, since Voyager chooses to 
override the entire functionality of smp.c.

Comments, suggestions, anything welcome.  I think this is a much cleaner 
approach, and both new and existing sub-architectures will benefit.  I 
am sorry this patch is so large, but it is very difficult to separate 
into multiple steps that still allow all the subarches to compile.

Zach

[-- Attachment #2: i386-subarch-cleanup --]
[-- Type: text/plain, Size: 20075 bytes --]

Signed-off-by: Zachary Amsden <zach@vmware.com>

Index: linux-2.6.16.1/arch/i386/Kconfig
===================================================================
--- linux-2.6.16.1.orig/arch/i386/Kconfig	2006-03-29 19:38:47.000000000 -0800
+++ linux-2.6.16.1/arch/i386/Kconfig	2006-03-29 19:38:54.000000000 -0800
@@ -218,7 +218,7 @@ config NR_CPUS
 
 config SCHED_SMT
 	bool "SMT (Hyperthreading) scheduler support"
-	depends on SMP
+	depends on SMP && !X86_VOYAGER
 	default off
 	help
 	  SMT scheduler support improves the CPU scheduler's decision making
@@ -689,7 +689,7 @@ source kernel/Kconfig.hz
 
 config KEXEC
 	bool "kexec system call (EXPERIMENTAL)"
-	depends on EXPERIMENTAL
+	depends on EXPERIMENTAL && (!X86_VOYAGER && SMP)
 	help
 	  kexec is a system call that implements the ability to shutdown your
 	  current kernel, and to start another kernel.  It is like a reboot
Index: linux-2.6.16.1/arch/i386/Makefile
===================================================================
--- linux-2.6.16.1.orig/arch/i386/Makefile	2006-03-29 19:38:47.000000000 -0800
+++ linux-2.6.16.1/arch/i386/Makefile	2006-03-29 19:38:54.000000000 -0800
@@ -45,37 +45,32 @@ CFLAGS				+= $(shell if [ $(call cc-vers
 
 CFLAGS += $(cflags-y)
 
-# Default subarch .c files
-mcore-y  := mach-default
+# Default subarch .c files (none)
+mcore-y  := 
 
 # Voyager subarch support
 mflags-$(CONFIG_X86_VOYAGER)	:= -Iinclude/asm-i386/mach-voyager
-mcore-$(CONFIG_X86_VOYAGER)	:= mach-voyager
+mcore-$(CONFIG_X86_VOYAGER)	:= arch/i386/mach-voyager/
 
 # VISWS subarch support
 mflags-$(CONFIG_X86_VISWS)	:= -Iinclude/asm-i386/mach-visws
-mcore-$(CONFIG_X86_VISWS)	:= mach-visws
+mcore-$(CONFIG_X86_VISWS)	:= arch/i386/mach-visws/
 
 # NUMAQ subarch support
 mflags-$(CONFIG_X86_NUMAQ)	:= -Iinclude/asm-i386/mach-numaq
-mcore-$(CONFIG_X86_NUMAQ)	:= mach-default
 
 # BIGSMP subarch support
 mflags-$(CONFIG_X86_BIGSMP)	:= -Iinclude/asm-i386/mach-bigsmp
-mcore-$(CONFIG_X86_BIGSMP)	:= mach-default
 
 #Summit subarch support
 mflags-$(CONFIG_X86_SUMMIT) := -Iinclude/asm-i386/mach-summit
-mcore-$(CONFIG_X86_SUMMIT)  := mach-default
 
 # generic subarchitecture
 mflags-$(CONFIG_X86_GENERICARCH) := -Iinclude/asm-i386/mach-generic
-mcore-$(CONFIG_X86_GENERICARCH) := mach-default
 core-$(CONFIG_X86_GENERICARCH) += arch/i386/mach-generic/
 
 # ES7000 subarch support
 mflags-$(CONFIG_X86_ES7000)	:= -Iinclude/asm-i386/mach-es7000
-mcore-$(CONFIG_X86_ES7000)	:= mach-default
 core-$(CONFIG_X86_ES7000)	:= arch/i386/mach-es7000/
 
 # default subarch .h files
@@ -86,7 +81,7 @@ head-y := arch/i386/kernel/head.o arch/i
 libs-y 					+= arch/i386/lib/
 core-y					+= arch/i386/kernel/ \
 					   arch/i386/mm/ \
-					   arch/i386/$(mcore-y)/ \
+					   $(mcore-y) \
 					   arch/i386/crypto/
 drivers-$(CONFIG_MATH_EMULATION)	+= arch/i386/math-emu/
 drivers-$(CONFIG_PCI)			+= arch/i386/pci/
Index: linux-2.6.16.1/arch/i386/kernel/Makefile
===================================================================
--- linux-2.6.16.1.orig/arch/i386/kernel/Makefile	2006-03-29 19:38:47.000000000 -0800
+++ linux-2.6.16.1/arch/i386/kernel/Makefile	2006-03-29 19:38:54.000000000 -0800
@@ -7,7 +7,7 @@ extra-y := head.o init_task.o vmlinux.ld
 obj-y	:= process.o semaphore.o signal.o entry.o traps.o irq.o \
 		ptrace.o time.o ioport.o ldt.o setup.o i8259.o sys_i386.o \
 		pci-dma.o i386_ksyms.o i387.o dmi_scan.o bootflag.o \
-		quirks.o i8237.o topology.o
+		quirks.o i8237.o topology.o default.o
 
 obj-y				+= cpu/
 obj-y				+= timers/
Index: linux-2.6.16.1/arch/i386/kernel/default.c
===================================================================
--- linux-2.6.16.1.orig/arch/i386/kernel/default.c	2006-03-29 19:38:54.000000000 -0800
+++ linux-2.6.16.1/arch/i386/kernel/default.c	2006-03-29 19:38:54.000000000 -0800
@@ -0,0 +1,48 @@
+/*
+ * Default architecture definitions used by sub-arch hooks.
+ */
+
+#include <linux/config.h>
+#include <linux/smp.h>
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <asm/arch_hooks.h>
+
+/*
+ * IRQ0 is the default timer interrupts.
+ * IRQ2 is cascade interrupt to second interrupt controller
+ */
+struct irqaction irq2 = { no_action, 0, CPU_MASK_NONE, "cascade", NULL, NULL};
+struct irqaction irq0  = { timer_interrupt, SA_INTERRUPT, CPU_MASK_NONE, "timer", NULL, NULL};
+					
+
+/* These can't be moved into smp.c, as some subarchitectures override that */
+#ifdef CONFIG_SMP
+
+#ifdef CONFIG_HOTPLUG_CPU
+#define DEFAULT_SEND_IPI      (1)
+#else
+#define DEFAULT_SEND_IPI      (0)
+#endif
+
+int no_broadcast=DEFAULT_SEND_IPI;
+
+static __init int no_ipi_broadcast(char *str)
+{
+	get_option(&str, &no_broadcast);
+	printk ("Using %s mode\n", no_broadcast ? "No IPI Broadcast" :
+						  "IPI Broadcast");
+	return 1;
+}
+
+__setup("no_ipi_broadcast", no_ipi_broadcast);
+
+static int __init print_ipi_mode(void)
+{
+	printk ("Using IPI %s mode\n", no_broadcast ? "No-Shortcut" :
+						      "Shortcut");
+	return 0;
+}
+
+late_initcall(print_ipi_mode);
+#endif
Index: linux-2.6.16.1/arch/i386/kernel/i8259.c
===================================================================
--- linux-2.6.16.1.orig/arch/i386/kernel/i8259.c	2006-03-29 19:38:47.000000000 -0800
+++ linux-2.6.16.1/arch/i386/kernel/i8259.c	2006-03-29 19:38:54.000000000 -0800
@@ -419,6 +419,9 @@ void __init init_IRQ(void)
 	/* setup after call gates are initialised (usually add in
 	 * the architecture specific gates)
 	 */
+#ifdef CONFIG_X86_LOCAL_APIC
+	apic_intr_init();
+#endif
 	intr_init_hook();
 
 	/*
Index: linux-2.6.16.1/arch/i386/kernel/mca.c
===================================================================
--- linux-2.6.16.1.orig/arch/i386/kernel/mca.c	2006-03-29 19:38:47.000000000 -0800
+++ linux-2.6.16.1/arch/i386/kernel/mca.c	2006-03-29 19:38:54.000000000 -0800
@@ -463,6 +463,18 @@ static int mca_handle_nmi_callback(struc
 	return 0;
 }
 
+
+#ifdef CONFIG_X86_VOYAGER
+/*
+ * Voyager wants to do something smarter with NMIs.  Rather than add an
+ * arch hook for this, keep the MCA code together where it is in context.
+ * No other subarch requires an MCA NMI hook, and most don't support MCA.
+ */
+extern void mca_nmi_hook(void);
+#else
+#define mca_nmi_hook() printk("NMI generated from unknown source!\n");
+#endif
+
 void mca_handle_nmi(void)
 {
 	/* First try - scan the various adapters and see if a specific
Index: linux-2.6.16.1/arch/i386/mach-default/Makefile
===================================================================
--- linux-2.6.16.1.orig/arch/i386/mach-default/Makefile	2006-03-29 19:38:47.000000000 -0800
+++ linux-2.6.16.1/arch/i386/mach-default/Makefile	2003-01-30 02:24:37.000000000 -0800
@@ -1,5 +0,0 @@
-#
-# Makefile for the linux kernel.
-#
-
-obj-y				:= setup.o
Index: linux-2.6.16.1/arch/i386/mach-default/setup.c
===================================================================
--- linux-2.6.16.1.orig/arch/i386/mach-default/setup.c	2006-03-29 19:38:47.000000000 -0800
+++ linux-2.6.16.1/arch/i386/mach-default/setup.c	2003-01-30 02:24:37.000000000 -0800
@@ -1,132 +0,0 @@
-/*
- *	Machine specific setup for generic
- */
-
-#include <linux/config.h>
-#include <linux/smp.h>
-#include <linux/init.h>
-#include <linux/interrupt.h>
-#include <asm/acpi.h>
-#include <asm/arch_hooks.h>
-
-#ifdef CONFIG_HOTPLUG_CPU
-#define DEFAULT_SEND_IPI	(1)
-#else
-#define DEFAULT_SEND_IPI	(0)
-#endif
-
-int no_broadcast=DEFAULT_SEND_IPI;
-
-/**
- * pre_intr_init_hook - initialisation prior to setting up interrupt vectors
- *
- * Description:
- *	Perform any necessary interrupt initialisation prior to setting up
- *	the "ordinary" interrupt call gates.  For legacy reasons, the ISA
- *	interrupts should be initialised here if the machine emulates a PC
- *	in any way.
- **/
-void __init pre_intr_init_hook(void)
-{
-	init_ISA_irqs();
-}
-
-/*
- * IRQ2 is cascade interrupt to second interrupt controller
- */
-static struct irqaction irq2 = { no_action, 0, CPU_MASK_NONE, "cascade", NULL, NULL};
-
-/**
- * intr_init_hook - post gate setup interrupt initialisation
- *
- * Description:
- *	Fill in any interrupts that may have been left out by the general
- *	init_IRQ() routine.  interrupts having to do with the machine rather
- *	than the devices on the I/O bus (like APIC interrupts in intel MP
- *	systems) are started here.
- **/
-void __init intr_init_hook(void)
-{
-#ifdef CONFIG_X86_LOCAL_APIC
-	apic_intr_init();
-#endif
-
-	if (!acpi_ioapic)
-		setup_irq(2, &irq2);
-}
-
-/**
- * pre_setup_arch_hook - hook called prior to any setup_arch() execution
- *
- * Description:
- *	generally used to activate any machine specific identification
- *	routines that may be needed before setup_arch() runs.  On VISWS
- *	this is used to get the board revision and type.
- **/
-void __init pre_setup_arch_hook(void)
-{
-}
-
-/**
- * trap_init_hook - initialise system specific traps
- *
- * Description:
- *	Called as the final act of trap_init().  Used in VISWS to initialise
- *	the various board specific APIC traps.
- **/
-void __init trap_init_hook(void)
-{
-}
-
-static struct irqaction irq0  = { timer_interrupt, SA_INTERRUPT, CPU_MASK_NONE, "timer", NULL, NULL};
-
-/**
- * time_init_hook - do any specific initialisations for the system timer.
- *
- * Description:
- *	Must plug the system timer interrupt source at HZ into the IRQ listed
- *	in irq_vectors.h:TIMER_IRQ
- **/
-void __init time_init_hook(void)
-{
-	setup_irq(0, &irq0);
-}
-
-#ifdef CONFIG_MCA
-/**
- * mca_nmi_hook - hook into MCA specific NMI chain
- *
- * Description:
- *	The MCA (Microchannel Arcitecture) has an NMI chain for NMI sources
- *	along the MCA bus.  Use this to hook into that chain if you will need
- *	it.
- **/
-void __init mca_nmi_hook(void)
-{
-	/* If I recall correctly, there's a whole bunch of other things that
-	 * we can do to check for NMI problems, but that's all I know about
-	 * at the moment.
-	 */
-
-	printk("NMI generated from unknown source!\n");
-}
-#endif
-
-static __init int no_ipi_broadcast(char *str)
-{
-	get_option(&str, &no_broadcast);
-	printk ("Using %s mode\n", no_broadcast ? "No IPI Broadcast" :
-											"IPI Broadcast");
-	return 1;
-}
-
-__setup("no_ipi_broadcast", no_ipi_broadcast);
-
-static int __init print_ipi_mode(void)
-{
-	printk ("Using IPI %s mode\n", no_broadcast ? "No-Shortcut" :
-											"Shortcut");
-	return 0;
-}
-
-late_initcall(print_ipi_mode);
Index: linux-2.6.16.1/arch/i386/mach-visws/setup.c
===================================================================
--- linux-2.6.16.1.orig/arch/i386/mach-visws/setup.c	2006-03-29 19:38:47.000000000 -0800
+++ linux-2.6.16.1/arch/i386/mach-visws/setup.c	2006-03-29 19:38:54.000000000 -0800
@@ -13,8 +13,6 @@
 #include "cobalt.h"
 #include "piix4.h"
 
-int no_broadcast;
-
 char visws_board_type = -1;
 char visws_board_rev = -1;
 
@@ -94,30 +92,7 @@ void __init visws_get_board_type_and_rev
 		"unknown")), visws_board_rev);
 }
 
-void __init pre_intr_init_hook(void)
-{
-	init_VISWS_APIC_irqs();
-}
-
-void __init intr_init_hook(void)
-{
-#ifdef CONFIG_X86_LOCAL_APIC
-	apic_intr_init();
-#endif
-}
-
-void __init pre_setup_arch_hook()
-{
-	visws_get_board_type_and_rev();
-}
-
-static struct irqaction irq0 = {
-	.handler =	timer_interrupt,
-	.flags =	SA_INTERRUPT,
-	.name =		"timer",
-};
-
-void __init time_init_hook(void)
+void __init visws_time_init_hook(void)
 {
 	printk(KERN_INFO "Starting Cobalt Timer system clock\n");
 
Index: linux-2.6.16.1/arch/i386/mach-visws/traps.c
===================================================================
--- linux-2.6.16.1.orig/arch/i386/mach-visws/traps.c	2006-03-29 19:38:47.000000000 -0800
+++ linux-2.6.16.1/arch/i386/mach-visws/traps.c	2006-03-29 19:38:54.000000000 -0800
@@ -62,7 +62,7 @@ static __init void cobalt_init(void)
 		co_apic_read(CO_APIC_ID));
 }
 
-void __init trap_init_hook(void)
+void __init visws_trap_init_hook(void)
 {
 	lithium_init();
 	cobalt_init();
Index: linux-2.6.16.1/arch/i386/mach-voyager/Makefile
===================================================================
--- linux-2.6.16.1.orig/arch/i386/mach-voyager/Makefile	2006-03-29 19:38:47.000000000 -0800
+++ linux-2.6.16.1/arch/i386/mach-voyager/Makefile	2006-03-29 19:38:54.000000000 -0800
@@ -3,6 +3,6 @@
 #
 
 EXTRA_CFLAGS	+= -I../kernel
-obj-y			:= setup.o voyager_basic.o voyager_thread.o
+obj-y			:= voyager_basic.o voyager_thread.o
 
 obj-$(CONFIG_SMP)	+= voyager_smp.o voyager_cat.o
Index: linux-2.6.16.1/arch/i386/mach-voyager/setup.c
===================================================================
--- linux-2.6.16.1.orig/arch/i386/mach-voyager/setup.c	2006-03-29 19:38:47.000000000 -0800
+++ linux-2.6.16.1/arch/i386/mach-voyager/setup.c	2003-01-30 02:24:37.000000000 -0800
@@ -1,47 +0,0 @@
-/*
- *	Machine specific setup for generic
- */
-
-#include <linux/config.h>
-#include <linux/init.h>
-#include <linux/interrupt.h>
-#include <asm/acpi.h>
-#include <asm/arch_hooks.h>
-
-void __init pre_intr_init_hook(void)
-{
-	init_ISA_irqs();
-}
-
-/*
- * IRQ2 is cascade interrupt to second interrupt controller
- */
-static struct irqaction irq2 = { no_action, 0, CPU_MASK_NONE, "cascade", NULL, NULL};
-
-void __init intr_init_hook(void)
-{
-#ifdef CONFIG_SMP
-	smp_intr_init();
-#endif
-
-	if (!acpi_ioapic)
-		setup_irq(2, &irq2);
-}
-
-void __init pre_setup_arch_hook(void)
-{
-	/* Voyagers run their CPUs from independent clocks, so disable
-	 * the TSC code because we can't sync them */
-	tsc_disable = 1;
-}
-
-void __init trap_init_hook(void)
-{
-}
-
-static struct irqaction irq0  = { timer_interrupt, SA_INTERRUPT, CPU_MASK_NONE, "timer", NULL, NULL};
-
-void __init time_init_hook(void)
-{
-	setup_irq(0, &irq0);
-}
Index: linux-2.6.16.1/include/asm-i386/acpi.h
===================================================================
--- linux-2.6.16.1.orig/include/asm-i386/acpi.h	2006-03-29 19:38:47.000000000 -0800
+++ linux-2.6.16.1/include/asm-i386/acpi.h	2006-03-29 19:38:54.000000000 -0800
@@ -31,6 +31,7 @@
 #include <acpi/pdc_intel.h>
 
 #include <asm/system.h>		/* defines cmpxchg */
+#include <asm/processor.h>	/* defines boot_cpu_data */
 
 #define COMPILER_DEPENDENT_INT64   long long
 #define COMPILER_DEPENDENT_UINT64  unsigned long long
Index: linux-2.6.16.1/include/asm-i386/arch_hooks.h
===================================================================
--- linux-2.6.16.1.orig/include/asm-i386/arch_hooks.h	2006-03-29 19:38:47.000000000 -0800
+++ linux-2.6.16.1/include/asm-i386/arch_hooks.h	2006-03-29 19:38:54.000000000 -0800
@@ -1,7 +1,13 @@
 #ifndef _ASM_ARCH_HOOKS_H
 #define _ASM_ARCH_HOOKS_H
 
+#include <linux/config.h>
+#include <linux/smp.h>
+#include <linux/init.h>
 #include <linux/interrupt.h>
+#include <asm/acpi.h>
+#include <asm/arch_hooks.h>
+#include <asm/desc.h>
 
 /*
  *	linux/include/asm/arch_hooks.h
@@ -16,12 +22,93 @@ extern void apic_intr_init(void);
 extern void smp_intr_init(void);
 extern irqreturn_t timer_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 
-/* these are the defined hooks */
-extern void intr_init_hook(void);
-extern void pre_intr_init_hook(void);
-extern void pre_setup_arch_hook(void);
-extern void trap_init_hook(void);
-extern void time_init_hook(void);
-extern void mca_nmi_hook(void);
+/*
+ * There are also some generic structures used by most architectures.
+ *
+ * IRQ0 is the default timer interrupt
+ * IRQ2 is cascade interrupt to second interrupt controller
+ */
+extern struct irqaction irq0;
+extern struct irqaction irq2;
+
+static inline void legacy_intr_init_hook(void)
+{
+	if (!acpi_ioapic)
+		setup_irq(2, &irq2);
+}
+
+static inline void default_timer_init(void)
+{
+	setup_irq(0, &irq0);
+}
+
+/* include to allow sub-arch override */
+#include <mach_hooks.h>
+
+/* these are the default hooks */
+
+/**
+ * pre_intr_init_hook - initialisation prior to setting up interrupt vectors
+ *
+ * Description:
+ *	Perform any necessary interrupt initialisation prior to setting up
+ *	the "ordinary" interrupt call gates.  For legacy reasons, the ISA
+ *	interrupts should be initialised here if the machine emulates a PC
+ *	in any way.
+ **/
+#ifndef pre_intr_init_hook
+#define pre_intr_init_hook() init_ISA_irqs()
+#endif
+
+
+/**
+ * intr_init_hook - post gate setup interrupt initialisation
+ *
+ * Description:
+ *	Fill in any interrupts that may have been left out by the general
+ *	init_IRQ() routine.  interrupts having to do with the machine rather
+ *	than the devices on the I/O bus (like APIC interrupts in intel MP
+ *	systems) are started here.
+ **/
+#ifndef intr_init_hook
+#define intr_init_hook() legacy_intr_init_hook()
+#endif
+
+
+/**
+ * pre_setup_arch_hook - hook called prior to any setup_arch() execution
+ *
+ * Description:
+ *	generally used to activate any machine specific identification
+ *	routines that may be needed before setup_arch() runs.  On VISWS
+ *	this is used to get the board revision and type.
+ **/
+#ifndef pre_setup_arch_hook
+#define pre_setup_arch_hook()
+#endif
+
+
+/**
+ * trap_init_hook - initialise system specific traps
+ *
+ * Description:
+ *	Called as the final act of trap_init().  Used in VISWS to initialise
+ *	the various board specific APIC traps.
+ **/
+#ifndef trap_init_hook
+#define trap_init_hook()
+#endif
+
+
+/**
+ * time_init_hook - do any specific initialisations for the system timer.
+ *
+ * Description:
+ *	Must plug the system timer interrupt source at HZ into the IRQ listed
+ *	in irq_vectors.h:TIMER_IRQ
+ **/
+#ifndef time_init_hook
+#define time_init_hook() default_timer_init()
+#endif
 
 #endif
Index: linux-2.6.16.1/include/asm-i386/mach-default/mach_hooks.h
===================================================================
--- linux-2.6.16.1.orig/include/asm-i386/mach-default/mach_hooks.h	2006-03-29 19:38:54.000000000 -0800
+++ linux-2.6.16.1/include/asm-i386/mach-default/mach_hooks.h	2006-03-29 19:38:54.000000000 -0800
@@ -0,0 +1,6 @@
+#ifndef _MACH_HOOKS_H
+#define _MACH_HOOKS_H
+
+/* Fall back to the default hooks in include/asm-i386/arch_hooks.h */
+
+#endif
Index: linux-2.6.16.1/include/asm-i386/mach-visws/mach_hooks.h
===================================================================
--- linux-2.6.16.1.orig/include/asm-i386/mach-visws/mach_hooks.h	2006-03-29 19:38:54.000000000 -0800
+++ linux-2.6.16.1/include/asm-i386/mach-visws/mach_hooks.h	2006-03-29 19:38:54.000000000 -0800
@@ -0,0 +1,15 @@
+#ifndef MACH_HOOKS_H
+#define MACH_HOOKS_H
+
+#define pre_intr_init_hook() init_VISWS_APIC_irqs()
+
+extern void visws_get_board_type_and_rev(void);
+#define pre_setup_arch_hook() visws_get_board_type_and_rev()
+
+extern void visws_time_init_hook(void);
+#define time_init_hook() visws_time_init_hook()
+
+extern void visws_trap_init_hook(void);
+#define trap_init_hook() visws_trap_init_hook()
+
+#endif
Index: linux-2.6.16.1/include/asm-i386/mach-voyager/mach_hooks.h
===================================================================
--- linux-2.6.16.1.orig/include/asm-i386/mach-voyager/mach_hooks.h	2006-03-29 19:38:54.000000000 -0800
+++ linux-2.6.16.1/include/asm-i386/mach-voyager/mach_hooks.h	2006-03-29 19:38:54.000000000 -0800
@@ -0,0 +1,38 @@
+#ifndef MACH_HOOKS_H
+#define MACH_HOOKS_H
+
+/**
+ * intr_init_hook - post gate setup interrupt initialisation
+ *
+ * Description:
+ *	Fill in any interrupts that may have been left out by the general
+ *	init_IRQ() routine.  interrupts having to do with the machine rather
+ *	than the devices on the I/O bus (like APIC interrupts in intel MP
+ *	systems) are started here.
+ **/
+static inline void voyager_intr_init_hook(void)
+{
+#ifdef CONFIG_SMP
+	smp_intr_init();
+#endif
+	legacy_intr_init_hook();
+}
+
+#define intr_init_hook() voyager_intr_init_hook()
+
+
+/**
+ * pre_setup_arch_hook - hook called prior to any setup_arch() execution
+ *
+ * Description:
+ *	generally used to activate any machine specific identification
+ *	routines that may be needed before setup_arch() runs. 
+ *	Voyagers run their CPUs from independent clocks, so disable
+ *	the TSC code because we can't sync them
+ **/
+#define pre_setup_arch_hook()	\
+do { 				\
+	tsc_disable = 1;	\
+} while (0)
+
+#endif

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Cleanup subarch definitions in Linux/i386
  2006-03-30  4:18 [PATCH] Cleanup subarch definitions in Linux/i386 Zachary Amsden
@ 2006-03-30  8:00 ` Chris Wright
  2006-03-30 19:25   ` Zachary Amsden
  0 siblings, 1 reply; 3+ messages in thread
From: Chris Wright @ 2006-03-30  8:00 UTC (permalink / raw)
  To: Zachary Amsden
  Cc: Andrew Morton, Linus Torvalds, Linux Kernel Mailing List, pazke,
	James.Bottomley

* Zachary Amsden (zach@vmware.com) wrote:
> Comments, suggestions, anything welcome.  I think this is a much cleaner 
> approach, and both new and existing sub-architectures will benefit.  I 
> am sorry this patch is so large, but it is very difficult to separate 
> into multiple steps that still allow all the subarches to compile.

Zach, looks nice.  Saves Xen a partial copy of setup.c.  Did you have
further/similar consolidations in mind?

> --- linux-2.6.16.1.orig/arch/i386/Makefile	2006-03-29 19:38:47.000000000 -0800
> +++ linux-2.6.16.1/arch/i386/Makefile	2006-03-29 19:38:54.000000000 -0800
> @@ -45,37 +45,32 @@ CFLAGS				+= $(shell if [ $(call cc-vers
>  
>  CFLAGS += $(cflags-y)
>  
> -# Default subarch .c files
> -mcore-y  := mach-default
> +# Default subarch .c files (none)
> +mcore-y  := 
>  
>  # Voyager subarch support
>  mflags-$(CONFIG_X86_VOYAGER)	:= -Iinclude/asm-i386/mach-voyager
> -mcore-$(CONFIG_X86_VOYAGER)	:= mach-voyager
> +mcore-$(CONFIG_X86_VOYAGER)	:= arch/i386/mach-voyager/

Is this intended to make way for possible fine tuning?  Smth like:

mcore-$(CONFIG_X86_VOYAGER)	+= arch/i386/another_default.o
(hmm, not sure if that would even work)

Or just an aesthetic change?

> --- linux-2.6.16.1.orig/include/asm-i386/acpi.h	2006-03-29 19:38:47.000000000 -0800
> +++ linux-2.6.16.1/include/asm-i386/acpi.h	2006-03-29 19:38:54.000000000 -0800
> @@ -31,6 +31,7 @@
>  #include <acpi/pdc_intel.h>
>  
>  #include <asm/system.h>		/* defines cmpxchg */
> +#include <asm/processor.h>	/* defines boot_cpu_data */

that one necessary?

>  #define COMPILER_DEPENDENT_INT64   long long
>  #define COMPILER_DEPENDENT_UINT64  unsigned long long
> Index: linux-2.6.16.1/include/asm-i386/arch_hooks.h
> ===================================================================
> --- linux-2.6.16.1.orig/include/asm-i386/arch_hooks.h	2006-03-29 19:38:47.000000000 -0800
> +++ linux-2.6.16.1/include/asm-i386/arch_hooks.h	2006-03-29 19:38:54.000000000 -0800
> @@ -1,7 +1,13 @@
>  #ifndef _ASM_ARCH_HOOKS_H
>  #define _ASM_ARCH_HOOKS_H
>  
> +#include <linux/config.h>
> +#include <linux/smp.h>
> +#include <linux/init.h>
>  #include <linux/interrupt.h>
> +#include <asm/acpi.h>
> +#include <asm/arch_hooks.h>

extraneous include

> --- linux-2.6.16.1.orig/include/asm-i386/mach-default/mach_hooks.h	2006-03-29 19:38:54.000000000 -0800
> +++ linux-2.6.16.1/include/asm-i386/mach-default/mach_hooks.h	2006-03-29 19:38:54.000000000 -0800
> @@ -0,0 +1,6 @@
> +#ifndef _MACH_HOOKS_H
> +#define _MACH_HOOKS_H

should probably be consistent (_MACH_HOOKS_H vs. MACH_HOOKS_H)

> --- linux-2.6.16.1.orig/include/asm-i386/mach-visws/mach_hooks.h	2006-03-29 19:38:54.000000000 -0800
> +++ linux-2.6.16.1/include/asm-i386/mach-visws/mach_hooks.h	2006-03-29 19:38:54.000000000 -0800
> @@ -0,0 +1,15 @@
> +#ifndef MACH_HOOKS_H
> +#define MACH_HOOKS_H

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Cleanup subarch definitions in Linux/i386
  2006-03-30  8:00 ` Chris Wright
@ 2006-03-30 19:25   ` Zachary Amsden
  0 siblings, 0 replies; 3+ messages in thread
From: Zachary Amsden @ 2006-03-30 19:25 UTC (permalink / raw)
  To: Chris Wright
  Cc: Andrew Morton, Linus Torvalds, Linux Kernel Mailing List, pazke,
	James.Bottomley

[-- Attachment #1: Type: text/plain, Size: 4090 bytes --]

Chris Wright wrote:
> * Zachary Amsden (zach@vmware.com) wrote:
>   
>> Comments, suggestions, anything welcome.  I think this is a much cleaner 
>> approach, and both new and existing sub-architectures will benefit.  I 
>> am sorry this patch is so large, but it is very difficult to separate 
>> into multiple steps that still allow all the subarches to compile.
>>     

Thanks for looking over these.  There is a bit more cleanup on top of 
this, mostly due to the include mess.  I have attached another patch.

> Zach, looks nice.  Saves Xen a partial copy of setup.c.  Did you have
> further/similar consolidations in mind?
>   

Exactly.
>   
>> --- linux-2.6.16.1.orig/arch/i386/Makefile	2006-03-29 19:38:47.000000000 -0800
>> +++ linux-2.6.16.1/arch/i386/Makefile	2006-03-29 19:38:54.000000000 -0800
>> @@ -45,37 +45,32 @@ CFLAGS				+= $(shell if [ $(call cc-vers
>>  
>>  CFLAGS += $(cflags-y)
>>  
>> -# Default subarch .c files
>> -mcore-y  := mach-default
>> +# Default subarch .c files (none)
>> +mcore-y  := 
>>  
>>  # Voyager subarch support
>>  mflags-$(CONFIG_X86_VOYAGER)	:= -Iinclude/asm-i386/mach-voyager
>> -mcore-$(CONFIG_X86_VOYAGER)	:= mach-voyager
>> +mcore-$(CONFIG_X86_VOYAGER)	:= arch/i386/mach-voyager/
>>     
>
> Is this intended to make way for possible fine tuning?  Smth like:
>
> mcore-$(CONFIG_X86_VOYAGER)	+= arch/i386/another_default.o
> (hmm, not sure if that would even work)
>
> Or just an aesthetic change?
>   

No - it was required in order to leave the subarch blank for the default 
case.  Including "arch/i386//" wasn't so happy in the makefile.

>   
>> --- linux-2.6.16.1.orig/include/asm-i386/acpi.h	2006-03-29 19:38:47.000000000 -0800
>> +++ linux-2.6.16.1/include/asm-i386/acpi.h	2006-03-29 19:38:54.000000000 -0800
>> @@ -31,6 +31,7 @@
>>  #include <acpi/pdc_intel.h>
>>  
>>  #include <asm/system.h>		/* defines cmpxchg */
>> +#include <asm/processor.h>	/* defines boot_cpu_data */
>>     
>
> that one necessary?
>   

Needed for mach-generic subarch to compile with CPU defined as I386 -- 
the definition of cmpxchg on older CPUs depends on boot_cpu_data.  
Removing this opens a giant rat hole.  This ginourmous rat hole is quite 
annoying.  What goes in system.h vs. processor.h is so poorly defined.  
I had to hoist boot_cpu_data into system.h as the cleanest way to fix 
this without introducing circular dependencies - processor.h already 
depends on system.h for alternative_input(), read_cr4(), write_cr4(), 
write_cr3(), and there is no end to this mess.  Trying to move dependent 
processor.h pieces into system.h didn't work, since the include/linux 
headers make the assumption that they can include asm/processor.h to 
determine if the architecture already has a prefetch instruction 
defined.  What a nightmare.  Trying to move system.h pieces into 
processor.h also doesn't work, since you basically need to move the 
whole file.

Maybe that is the way to go, but I would rather not go there now.


>>  #define COMPILER_DEPENDENT_INT64   long long
>>  #define COMPILER_DEPENDENT_UINT64  unsigned long long
>> Index: linux-2.6.16.1/include/asm-i386/arch_hooks.h
>> ===================================================================
>> --- linux-2.6.16.1.orig/include/asm-i386/arch_hooks.h	2006-03-29 19:38:47.000000000 -0800
>> +++ linux-2.6.16.1/include/asm-i386/arch_hooks.h	2006-03-29 19:38:54.000000000 -0800
>> @@ -1,7 +1,13 @@
>>  #ifndef _ASM_ARCH_HOOKS_H
>>  #define _ASM_ARCH_HOOKS_H
>>  
>> +#include <linux/config.h>
>> +#include <linux/smp.h>
>> +#include <linux/init.h>
>>  #include <linux/interrupt.h>
>> +#include <asm/acpi.h>
>> +#include <asm/arch_hooks.h>
>>     
>
> extraneous include
>   

Yes, somewhat extraneous.

>   
>> --- linux-2.6.16.1.orig/include/asm-i386/mach-default/mach_hooks.h	2006-03-29 19:38:54.000000000 -0800
>> +++ linux-2.6.16.1/include/asm-i386/mach-default/mach_hooks.h	2006-03-29 19:38:54.000000000 -0800
>> @@ -0,0 +1,6 @@
>> +#ifndef _MACH_HOOKS_H
>> +#define _MACH_HOOKS_H
>>     
>
> should probably be consistent (_MACH_HOOKS_H vs. MACH_HOOKS_H)
>   
Patch attached.

[-- Attachment #2: i386-tidy-subarch-cleanup --]
[-- Type: text/plain, Size: 8242 bytes --]

Tidy up the subarch cleanup patch with nits noticed by Chris Wright.

Signed-off-by: Zachary Amsden <zach@vmware.com>

Index: linux-2.6.16.1/include/asm-i386/arch_hooks.h
===================================================================
--- linux-2.6.16.1.orig/include/asm-i386/arch_hooks.h	2006-03-30 10:53:45.000000000 -0800
+++ linux-2.6.16.1/include/asm-i386/arch_hooks.h	2006-03-30 10:54:27.000000000 -0800
@@ -1,13 +1,9 @@
 #ifndef _ASM_ARCH_HOOKS_H
 #define _ASM_ARCH_HOOKS_H
 
-#include <linux/config.h>
-#include <linux/smp.h>
-#include <linux/init.h>
 #include <linux/interrupt.h>
 #include <asm/acpi.h>
 #include <asm/arch_hooks.h>
-#include <asm/desc.h>
 
 /*
  *	linux/include/asm/arch_hooks.h
Index: linux-2.6.16.1/include/asm-i386/acpi.h
===================================================================
--- linux-2.6.16.1.orig/include/asm-i386/acpi.h	2006-03-30 10:53:45.000000000 -0800
+++ linux-2.6.16.1/include/asm-i386/acpi.h	2006-03-30 10:54:27.000000000 -0800
@@ -31,7 +31,6 @@
 #include <acpi/pdc_intel.h>
 
 #include <asm/system.h>		/* defines cmpxchg */
-#include <asm/processor.h>	/* defines boot_cpu_data */
 
 #define COMPILER_DEPENDENT_INT64   long long
 #define COMPILER_DEPENDENT_UINT64  unsigned long long
Index: linux-2.6.16.1/include/asm-i386/processor.h
===================================================================
--- linux-2.6.16.1.orig/include/asm-i386/processor.h	2006-03-30 10:53:45.000000000 -0800
+++ linux-2.6.16.1/include/asm-i386/processor.h	2006-03-30 11:03:16.000000000 -0800
@@ -16,7 +16,6 @@
 #include <asm/cpufeature.h>
 #include <asm/msr.h>
 #include <asm/system.h>
-#include <linux/cache.h>
 #include <linux/config.h>
 #include <linux/threads.h>
 #include <asm/percpu.h>
@@ -39,82 +38,13 @@ struct desc_struct {
  */
 #define current_text_addr() ({ void *pc; __asm__("movl $1f,%0\n1:":"=g" (pc)); pc; })
 
-/*
- *  CPU type and hardware bug flags. Kept separately for each CPU.
- *  Members of this structure are referenced in head.S, so think twice
- *  before touching them. [mj]
- */
-
-struct cpuinfo_x86 {
-	__u8	x86;		/* CPU family */
-	__u8	x86_vendor;	/* CPU vendor */
-	__u8	x86_model;
-	__u8	x86_mask;
-	char	wp_works_ok;	/* It doesn't on 386's */
-	char	hlt_works_ok;	/* Problems on some 486Dx4's and old 386's */
-	char	hard_math;
-	char	rfu;
-       	int	cpuid_level;	/* Maximum supported CPUID level, -1=no CPUID */
-	unsigned long	x86_capability[NCAPINTS];
-	char	x86_vendor_id[16];
-	char	x86_model_id[64];
-	int 	x86_cache_size;  /* in KB - valid for CPUS which support this
-				    call  */
-	int 	x86_cache_alignment;	/* In bytes */
-	char	fdiv_bug;
-	char	f00f_bug;
-	char	coma_bug;
-	char	pad0;
-	int	x86_power;
-	unsigned long loops_per_jiffy;
-	unsigned char x86_max_cores;	/* cpuid returned max cores value */
-	unsigned char booted_cores;	/* number of cores as seen by OS */
-	unsigned char apicid;
-} __attribute__((__aligned__(SMP_CACHE_BYTES)));
-
-#define X86_VENDOR_INTEL 0
-#define X86_VENDOR_CYRIX 1
-#define X86_VENDOR_AMD 2
-#define X86_VENDOR_UMC 3
-#define X86_VENDOR_NEXGEN 4
-#define X86_VENDOR_CENTAUR 5
-#define X86_VENDOR_RISE 6
-#define X86_VENDOR_TRANSMETA 7
-#define X86_VENDOR_NSC 8
-#define X86_VENDOR_NUM 9
-#define X86_VENDOR_UNKNOWN 0xff
-
-/*
- * capabilities of CPUs
- */
-
-extern struct cpuinfo_x86 boot_cpu_data;
-extern struct cpuinfo_x86 new_cpu_data;
 extern struct tss_struct doublefault_tss;
 DECLARE_PER_CPU(struct tss_struct, init_tss);
 
-#ifdef CONFIG_SMP
-extern struct cpuinfo_x86 cpu_data[];
-#define current_cpu_data cpu_data[smp_processor_id()]
-#else
-#define cpu_data (&boot_cpu_data)
-#define current_cpu_data boot_cpu_data
-#endif
-
 extern	int phys_proc_id[NR_CPUS];
 extern	int cpu_core_id[NR_CPUS];
 extern char ignore_fpu_irq;
 
-extern void identify_cpu(struct cpuinfo_x86 *);
-extern void print_cpu_info(struct cpuinfo_x86 *);
-extern unsigned int init_intel_cacheinfo(struct cpuinfo_x86 *c);
-
-#ifdef CONFIG_X86_HT
-extern void detect_ht(struct cpuinfo_x86 *c);
-#else
-static inline void detect_ht(struct cpuinfo_x86 *c) {}
-#endif
-
 /*
  * EFLAGS bits
  */
@@ -720,8 +650,6 @@ static inline void prefetchw(const void 
 
 extern void select_idle_routine(const struct cpuinfo_x86 *c);
 
-#define cache_line_size() (boot_cpu_data.x86_cache_alignment)
-
 extern unsigned long boot_option_idle_override;
 extern void enable_sep_cpu(void);
 extern int sysenter_setup(void);
Index: linux-2.6.16.1/include/asm-i386/system.h
===================================================================
--- linux-2.6.16.1.orig/include/asm-i386/system.h	2006-03-30 10:53:45.000000000 -0800
+++ linux-2.6.16.1/include/asm-i386/system.h	2006-03-30 11:04:28.000000000 -0800
@@ -5,12 +5,80 @@
 #include <linux/kernel.h>
 #include <asm/segment.h>
 #include <asm/cpufeature.h>
+#include <linux/cache.h>
 #include <linux/bitops.h> /* for LOCK_PREFIX */
 
 #ifdef __KERNEL__
 
-struct task_struct;	/* one of the stranger aspects of C forward declarations.. */
-extern struct task_struct * FASTCALL(__switch_to(struct task_struct *prev, struct task_struct *next));
+/*
+ *  CPU type and hardware bug flags. Kept separately for each CPU.
+ *  Members of this structure are referenced in head.S, so think twice
+ *  before touching them. [mj]
+ */
+
+struct cpuinfo_x86 {
+	__u8	x86;		/* CPU family */
+	__u8	x86_vendor;	/* CPU vendor */
+	__u8	x86_model;
+	__u8	x86_mask;
+	char	wp_works_ok;	/* It doesn't on 386's */
+	char	hlt_works_ok;	/* Problems on some 486Dx4's and old 386's */
+	char	hard_math;
+	char	rfu;
+       	int	cpuid_level;	/* Maximum supported CPUID level, -1=no CPUID */
+	unsigned long	x86_capability[NCAPINTS];
+	char	x86_vendor_id[16];
+	char	x86_model_id[64];
+	int 	x86_cache_size;  /* in KB - valid for CPUS which support this
+				    call  */
+	int 	x86_cache_alignment;	/* In bytes */
+	char	fdiv_bug;
+	char	f00f_bug;
+	char	coma_bug;
+	char	pad0;
+	int	x86_power;
+	unsigned long loops_per_jiffy;
+	unsigned char x86_max_cores;	/* cpuid returned max cores value */
+	unsigned char booted_cores;	/* number of cores as seen by OS */
+	unsigned char apicid;
+} __attribute__((__aligned__(SMP_CACHE_BYTES)));
+
+#define X86_VENDOR_INTEL 0
+#define X86_VENDOR_CYRIX 1
+#define X86_VENDOR_AMD 2
+#define X86_VENDOR_UMC 3
+#define X86_VENDOR_NEXGEN 4
+#define X86_VENDOR_CENTAUR 5
+#define X86_VENDOR_RISE 6
+#define X86_VENDOR_TRANSMETA 7
+#define X86_VENDOR_NSC 8
+#define X86_VENDOR_NUM 9
+#define X86_VENDOR_UNKNOWN 0xff
+
+/*
+ * capabilities of CPUs
+ */
+extern struct cpuinfo_x86 boot_cpu_data;
+extern struct cpuinfo_x86 new_cpu_data;
+#define cache_line_size() (boot_cpu_data.x86_cache_alignment)
+
+#ifdef CONFIG_SMP
+extern struct cpuinfo_x86 cpu_data[];
+#define current_cpu_data cpu_data[smp_processor_id()]
+#else
+#define cpu_data (&boot_cpu_data)
+#define current_cpu_data boot_cpu_data
+#endif
+
+extern void identify_cpu(struct cpuinfo_x86 *);
+extern void print_cpu_info(struct cpuinfo_x86 *);
+extern unsigned int init_intel_cacheinfo(struct cpuinfo_x86 *c);
+
+#ifdef CONFIG_X86_HT
+extern void detect_ht(struct cpuinfo_x86 *c);
+#else
+static inline void detect_ht(struct cpuinfo_x86 *c) {}
+#endif
 
 #define switch_to(prev,next,last) do {					\
 	unsigned long esi,edi;						\
Index: linux-2.6.16.1/include/asm-i386/mach-visws/mach_hooks.h
===================================================================
--- linux-2.6.16.1.orig/include/asm-i386/mach-visws/mach_hooks.h	2006-03-30 10:53:45.000000000 -0800
+++ linux-2.6.16.1/include/asm-i386/mach-visws/mach_hooks.h	2006-03-30 10:54:27.000000000 -0800
@@ -1,5 +1,5 @@
-#ifndef MACH_HOOKS_H
-#define MACH_HOOKS_H
+#ifndef _MACH_HOOKS_H
+#define _MACH_HOOKS_H
 
 #define pre_intr_init_hook() init_VISWS_APIC_irqs()
 
Index: linux-2.6.16.1/include/asm-i386/mach-voyager/mach_hooks.h
===================================================================
--- linux-2.6.16.1.orig/include/asm-i386/mach-voyager/mach_hooks.h	2006-03-30 10:53:45.000000000 -0800
+++ linux-2.6.16.1/include/asm-i386/mach-voyager/mach_hooks.h	2006-03-30 10:54:27.000000000 -0800
@@ -1,5 +1,5 @@
-#ifndef MACH_HOOKS_H
-#define MACH_HOOKS_H
+#ifndef _MACH_HOOKS_H
+#define _MACH_HOOKS_H
 
 /**
  * intr_init_hook - post gate setup interrupt initialisation

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-03-30 19:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-30  4:18 [PATCH] Cleanup subarch definitions in Linux/i386 Zachary Amsden
2006-03-30  8:00 ` Chris Wright
2006-03-30 19:25   ` Zachary Amsden

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox