[RFC] splitting out LPAR support from CONFIG_PSERIES

Arnd Bergmann arnd at arndb.de
Wed Feb 23 03:23:51 EST 2005


I have a private patch set that currently depends on this patch.
It introduces a new compile time option that makes it possible
to disable support for LPAR or native setups from a pSeries kernel.

Obviously, this is not for generic distribution kernels, but I think
it makes sense to have the option when you're building for just one
machine. It also makes some of my subsequent patches simpler, especially
enabling RTAS on non-pSeries machines without requiring LPAR support.

The current form of the patch introduces lots of new #ifdefs, which
can be reduced if we use the scheme I proposed in the 
'Introduce CPU_HAS_FEATURE() macro' discussion. It would also be
cleaner to split the pSeries_iommu code into LPAR and native files.

I'm not proposing inclusion of this patch at this point, but I'd like
to know if the idea is ok or if I should better try not to touch
the pSeries code.

	Arnd <><

--- linux-2.6-ppc.orig/arch/ppc64/Kconfig	2005-02-18 16:28:53.305937360 -0500
+++ linux-2.6-ppc/arch/ppc64/Kconfig	2005-02-18 16:28:53.392924136 -0500
@@ -72,9 +72,19 @@
 
 endchoice
 
-config PPC_PSERIES
+config PPC_PSERIES_NATIVE
 	depends on PPC_MULTIPLATFORM
-	bool "  IBM pSeries & new iSeries"
+	bool "  IBM pSeries native"
+	default y
+
+config PPC_PSERIES_LPAR
+	depends on PPC_MULTIPLATFORM
+	bool "  IBM pSeries running in LPAR & new iSeries"
+	default y
+
+config PPC_PSERIES
+	depends on PPC_PSERIES_NATIVE || PPC_PSERIES_LPAR
+	bool
 	default y
 
 config PPC_PMAC
@@ -115,7 +125,7 @@
 	default y
 
 config PPC_SPLPAR
-	depends on PPC_PSERIES
+	depends on PPC_PSERIES_LPAR
 	bool "Support for shared-processor logical partitions"
 	default n
 	help
@@ -125,7 +135,7 @@
 	  two or more partitions.
 
 config IBMVIO
-	depends on PPC_PSERIES || PPC_ISERIES
+	depends on PPC_PSERIES_LPAR || PPC_ISERIES
 	bool
 	default y
 
@@ -271,7 +281,7 @@
 
 config LPARCFG
 	tristate "LPAR Configuration Data"
-	depends on PPC_PSERIES || PPC_ISERIES
+	depends on PPC_PSERIES_LPAR || PPC_ISERIES
 	help
 	Provide system capacity information via human readable
 	<key word>=<value> pairs through a /proc/ppc64/lparcfg interface.
Index: linux-2.6-ppc/arch/ppc64/kernel/Makefile
===================================================================
--- linux-2.6-ppc.orig/arch/ppc64/kernel/Makefile	2005-02-18 16:28:53.306937208 -0500
+++ linux-2.6-ppc/arch/ppc64/kernel/Makefile	2005-02-18 16:28:53.393923984 -0500
@@ -29,8 +29,9 @@
 
 obj-$(CONFIG_PPC_MULTIPLATFORM) += nvram.o i8259.o prom_init.o prom.o mpic.o
 
-obj-$(CONFIG_PPC_PSERIES) += pSeries_pci.o pSeries_lpar.o pSeries_hvCall.o \
-			     pSeries_nvram.o rtasd.o ras.o \
+obj-$(CONFIG_PPC_PSERIES_LPAR) += pSeries_lpar.o pSeries_hvCall.o
+
+obj-$(CONFIG_PPC_PSERIES) += pSeries_pci.o pSeries_nvram.o rtasd.o ras.o \
 			     xics.o rtas.o pSeries_setup.o pSeries_iommu.o
 
 obj-$(CONFIG_EEH)		+= eeh.o
Index: linux-2.6-ppc/arch/ppc64/kernel/idle.c
===================================================================
--- linux-2.6-ppc.orig/arch/ppc64/kernel/idle.c	2005-02-18 16:28:40.528019944 -0500
+++ linux-2.6-ppc/arch/ppc64/kernel/idle.c	2005-02-18 16:28:53.394923832 -0500
@@ -154,7 +154,7 @@
 	return 0;
 }
 
-#ifdef CONFIG_PPC_PSERIES
+#ifdef CONFIG_PPC_PSERIES_LPAR
 
 DECLARE_PER_CPU(unsigned long, smt_snooze_delay);
 
@@ -348,7 +348,7 @@
 #else
 	idle_loop = default_idle;
 #endif
-#ifdef CONFIG_PPC_PSERIES
+#ifdef CONFIG_PPC_PSERIES_LPAR
 	if (systemcfg->platform & PLATFORM_PSERIES) {
 		if (cur_cpu_spec->firmware_features & FW_FEATURE_SPLPAR) {
 			if (get_paca()->lppaca.shared_proc) {
Index: linux-2.6-ppc/arch/ppc64/kernel/pSeries_iommu.c
===================================================================
--- linux-2.6-ppc.orig/arch/ppc64/kernel/pSeries_iommu.c	2005-02-18 16:28:40.530019640 -0500
+++ linux-2.6-ppc/arch/ppc64/kernel/pSeries_iommu.c	2005-02-18 16:28:53.395923680 -0500
@@ -1,6 +1,8 @@
 /*
  * arch/ppc64/kernel/pSeries_iommu.c
  *
+ * FIXME: split this file into LPAR and native versions
+ *
  * Copyright (C) 2001 Mike Corrigan & Dave Engebretsen, IBM Corporation
  *
  * Rewrite, cleanup: 
@@ -50,6 +52,7 @@
 
 extern int is_python(struct device_node *);
 
+#ifdef CONFIG_PPC_PSERIES_NATIVE
 static void tce_build_pSeries(struct iommu_table *tbl, long index, 
 			      long npages, unsigned long uaddr, 
 			      enum dma_data_direction direction)
@@ -91,8 +94,9 @@
 		tp++;
 	}
 }
+#endif /* CONFIG_PPC_PSERIES_NATIVE */
 
-
+#ifdef CONFIG_PPC_PSERIES_LPAR
 static void tce_build_pSeriesLP(struct iommu_table *tbl, long tcenum,
 				long npages, unsigned long uaddr,
 				enum dma_data_direction direction)
@@ -235,7 +239,9 @@
 		show_stack(current, (unsigned long *)__get_SP());
 	}
 }
+#endif /* CONFIG_PPC_PSERIES_LPAR */
 
+#ifdef CONFIG_PPC_PSERIES_NATIVE
 static void iommu_table_setparms(struct pci_controller *phb,
 				 struct device_node *dn,
 				 struct iommu_table *tbl) 
@@ -275,7 +281,9 @@
 	tbl->it_blocksize = 16;
 	tbl->it_type = TCE_PCI;
 }
+#endif /* CONFIG_PPC_PSERIES_NATIVE */
 
+#ifdef CONFIG_PPC_PSERIES_LPAR
 /*
  * iommu_table_setparms_lpar
  *
@@ -305,7 +313,9 @@
 	tbl->it_blocksize  = 16;
 	tbl->it_type = TCE_PCI;
 }
+#endif
 
+#ifdef CONFIG_PPC_PSERIES_NATIVE
 static void iommu_bus_setup_pSeries(struct pci_bus *bus)
 {
 	struct device_node *dn, *pdn;
@@ -393,8 +403,9 @@
 		}
 	}
 }
+#endif /* CONFIG_PPC_PSERIES_NATIVE */
 
-
+#ifdef CONFIG_PPC_PSERIES_LPAR
 static void iommu_bus_setup_pSeriesLP(struct pci_bus *bus)
 {
 	struct iommu_table *tbl;
@@ -432,7 +443,7 @@
 	if (pdn != dn)
 		dn->iommu_table = pdn->iommu_table;
 }
-
+#endif
 
 static void iommu_dev_setup_pSeries(struct pci_dev *dev)
 {
@@ -471,6 +482,7 @@
 	}
 
 	if (systemcfg->platform & PLATFORM_LPAR) {
+#ifdef CONFIG_PPC_PSERIES_LPAR
 		if (cur_cpu_spec->firmware_features & FW_FEATURE_MULTITCE) {
 			ppc_md.tce_build = tce_buildmulti_pSeriesLP;
 			ppc_md.tce_free	 = tce_freemulti_pSeriesLP;
@@ -479,10 +491,13 @@
 			ppc_md.tce_free	 = tce_free_pSeriesLP;
 		}
 		ppc_md.iommu_bus_setup = iommu_bus_setup_pSeriesLP;
+#endif /* CONFIG_PPC_PSERIES_LPAR */
 	} else {
+#ifdef CONFIG_PPC_PSERIES_NATIVE
 		ppc_md.tce_build = tce_build_pSeries;
 		ppc_md.tce_free  = tce_free_pSeries;
 		ppc_md.iommu_bus_setup = iommu_bus_setup_pSeries;
+#endif /* CONFIG_PPC_PSERIES_NATIVE */
 	}
 
 	ppc_md.iommu_dev_setup = iommu_dev_setup_pSeries;
Index: linux-2.6-ppc/arch/ppc64/kernel/pSeries_setup.c
===================================================================
--- linux-2.6-ppc.orig/arch/ppc64/kernel/pSeries_setup.c	2005-02-18 16:28:40.532019336 -0500
+++ linux-2.6-ppc/arch/ppc64/kernel/pSeries_setup.c	2005-02-18 16:28:53.396923528 -0500
@@ -233,8 +233,10 @@
 
 	pSeries_nvram_init();
 
+#ifdef CONFIG_PPC_PSERIES_LPAR
 	if (cur_cpu_spec->firmware_features & FW_FEATURE_SPLPAR)
 		vpa_init(boot_cpuid);
+#endif
 }
 
 static int __init pSeries_init_panel(void)
@@ -326,7 +328,9 @@
 	/* Some hardware requires clearing the CPPR, while other hardware does not
 	 * it is safe either way
 	 */
+#ifdef CONFIG_PPC_PSERIES_LPAR
 	pSeriesLP_cppr_info(0, 0);
+#endif
 	rtas_stop_self();
 	/* Should never get here... */
 	BUG();
@@ -339,8 +343,6 @@
  */
 static void __init pSeries_init_early(void)
 {
-	void *comport;
-	int iommu_off = 0;
 	unsigned int default_speed;
 	u64 physport;
 
@@ -348,19 +350,28 @@
 
 	fw_feature_init();
 	
-	if (systemcfg->platform & PLATFORM_LPAR)
+	if (systemcfg->platform & PLATFORM_LPAR) {
+#ifdef CONFIG_PPC_PSERIES_LPAR
 		hpte_init_lpar();
-	else {
+#endif
+	} else {
+#ifdef CONFIG_PPC_PSERIES_NATIVE
+		int iommu_off = 0;
 		hpte_init_native();
 		iommu_off = (of_chosen &&
 			     get_property(of_chosen, "linux,iommu-off", NULL));
+#endif
 	}
 
 	generic_find_legacy_serial_ports(&physport, &default_speed);
 
-	if (systemcfg->platform & PLATFORM_LPAR)
+	if (systemcfg->platform & PLATFORM_LPAR) {
+#ifdef CONFIG_PPC_PSERIES_LPAR
 		find_udbg_vterm();
-	else if (physport) {
+#endif
+	} else if (physport) {
+#ifdef CONFIG_PPC_PSERIES_NATIVE
+		void *comport;
 		/* Map the uart for udbg. */
 		comport = (void *)__ioremap(physport, 16, _PAGE_NO_CACHE);
 		udbg_init_uart(comport, default_speed);
@@ -369,6 +380,7 @@
 		ppc_md.udbg_getc = udbg_getc;
 		ppc_md.udbg_getc_poll = udbg_getc_poll;
 		DBG("Hello World !\n");
+#endif
 	}
 
 
Index: linux-2.6-ppc/arch/ppc64/kernel/pSeries_smp.c
===================================================================
--- linux-2.6-ppc.orig/arch/ppc64/kernel/pSeries_smp.c	2005-02-18 16:28:40.536018728 -0500
+++ linux-2.6-ppc/arch/ppc64/kernel/pSeries_smp.c	2005-02-18 16:28:53.397923376 -0500
@@ -255,8 +255,10 @@
 	if (cpu != boot_cpuid)
 		xics_setup_cpu();
 
+#ifdef CONFIG_PPC_PSERIES_LPAR
 	if (cur_cpu_spec->firmware_features & FW_FEATURE_SPLPAR)
 		vpa_init(cpu);
+#endif
 
 	/*
 	 * Put the calling processor into the GIQ.  This is really only
Index: linux-2.6-ppc/arch/ppc64/kernel/sysfs.c
===================================================================
--- linux-2.6-ppc.orig/arch/ppc64/kernel/sysfs.c	2005-02-18 16:28:40.534019032 -0500
+++ linux-2.6-ppc/arch/ppc64/kernel/sysfs.c	2005-02-18 16:28:53.398923224 -0500
@@ -110,11 +110,10 @@
 void ppc64_enable_pmcs(void)
 {
 	unsigned long hid0;
-#ifdef CONFIG_PPC_PSERIES
+#ifdef CONFIG_PPC_PSERIES_LPAR
 	unsigned long set, reset;
 	int ret;
-	unsigned int ctrl;
-#endif /* CONFIG_PPC_PSERIES */
+#endif /* CONFIG_PPC_PSERIES_LPAR */
 
 	/* Only need to enable them once */
 	if (__get_cpu_var(pmcs_enabled))
@@ -142,7 +141,7 @@
 			     "memory");
 		break;
 
-#ifdef CONFIG_PPC_PSERIES
+#ifdef CONFIG_PPC_PSERIES_LPAR
 	case PLATFORM_PSERIES_LPAR:
 		set = 1UL << 63;
 		reset = 0;
@@ -158,16 +157,18 @@
 		break;
 	}
 
-#ifdef CONFIG_PPC_PSERIES
+#ifdef CONFIG_PPC_PSERIES_LPAR
 	/* instruct hypervisor to maintain PMCs */
 	if (cur_cpu_spec->firmware_features & FW_FEATURE_SPLPAR)
 		get_paca()->lppaca.pmcregs_in_use = 1;
-
+#endif /* CONFIG_PPC_PSERIES_LPAR */
+#ifdef CONFIG_PPC_PSERIES
 	/*
 	 * On SMT machines we have to set the run latch in the ctrl register
 	 * in order to make PMC6 spin.
 	 */
 	if (cur_cpu_spec->cpu_features & CPU_FTR_SMT) {
+		unsigned int ctrl;
 		ctrl = mfspr(CTRLF);
 		ctrl |= RUNLATCH;
 		mtspr(CTRLT, ctrl);
Index: linux-2.6-ppc/arch/ppc64/kernel/xics.c
===================================================================
--- linux-2.6-ppc.orig/arch/ppc64/kernel/xics.c	2005-02-18 16:28:40.539018272 -0500
+++ linux-2.6-ppc/arch/ppc64/kernel/xics.c	2005-02-18 16:28:53.399923072 -0500
@@ -84,8 +84,6 @@
 	} qirr;
 };
 
-static struct xics_ipl __iomem *xics_per_cpu[NR_CPUS];
-
 static int xics_irq_8259_cascade = 0;
 static int xics_irq_8259_cascade_real = 0;
 static unsigned int default_server = 0xFF;
@@ -112,7 +110,8 @@
 } xics_ops;
 
 
-/* SMP */
+#ifdef CONFIG_PPC_PSERIES_NATIVE
+static struct xics_ipl __iomem *xics_per_cpu[NR_CPUS];
 
 static int pSeries_xirr_info_get(int n_cpu)
 {
@@ -140,11 +139,9 @@
 	pSeries_cppr_info,
 	pSeries_qirr_info
 };
+#endif
 
-static xics_ops *ops = &pSeries_ops;
-
-
-/* LPAR */
+#ifdef CONFIG_PPC_PSERIES_LPAR
 
 static inline long plpar_eoi(unsigned long xirr)
 {
@@ -213,6 +210,9 @@
 	pSeriesLP_cppr_info,
 	pSeriesLP_qirr_info
 };
+#endif
+
+static xics_ops *ops;
 
 static unsigned int xics_startup(unsigned int virq)
 {
@@ -535,8 +535,9 @@
 			= virt_irq_create_mapping(xics_irq_8259_cascade_real);
 		of_node_put(np);
 	}
-
+#ifdef CONFIG_PPC_PSERIES_NATIVE
 	if (systemcfg->platform == PLATFORM_PSERIES) {
+		ops = &pSeries_ops;
 #ifdef CONFIG_SMP
 		for_each_cpu(i) {
 			int hard_id;
@@ -552,10 +553,13 @@
 #else
 		xics_per_cpu[0] = ioremap(intr_base, intr_size);
 #endif /* CONFIG_SMP */
-	} else if (systemcfg->platform == PLATFORM_PSERIES_LPAR) {
+	}
+#endif /* CONFIG_PPC_PSERIES_NATIVE */
+#ifdef CONFIG_PPC_PSERIES_LPAR
+	if (systemcfg->platform == PLATFORM_PSERIES_LPAR) {
 		ops = &pSeriesLP_ops;
 	}
-
+#endif /* CONFIG_PPC_PSERIES_LPAR */
 	xics_8259_pic.enable = i8259_pic.enable;
 	xics_8259_pic.disable = i8259_pic.disable;
 	for (i = 0; i < 16; ++i)
Index: linux-2.6-ppc/arch/ppc64/mm/hash_utils.c
===================================================================
--- linux-2.6-ppc.orig/arch/ppc64/mm/hash_utils.c	2005-02-18 16:28:40.541017968 -0500
+++ linux-2.6-ppc/arch/ppc64/mm/hash_utils.c	2005-02-18 16:28:53.400922920 -0500
@@ -116,13 +116,13 @@
 
 		hpteg = ((hash & htab_hash_mask) * HPTES_PER_GROUP);
 
-#ifdef CONFIG_PPC_PSERIES
+#ifdef CONFIG_PPC_PSERIES_LPAR
 		if (systemcfg->platform & PLATFORM_LPAR)
 			ret = pSeries_lpar_hpte_insert(hpteg, va,
 				virt_to_abs(addr) >> PAGE_SHIFT,
 				0, mode, 1, large);
 		else
-#endif /* CONFIG_PPC_PSERIES */
+#endif /* CONFIG_PPC_PSERIES_LPAR */
 			ret = native_hpte_insert(hpteg, va,
 				virt_to_abs(addr) >> PAGE_SHIFT,
 				0, mode, 1, large);
Index: linux-2.6-ppc/arch/ppc64/xmon/xmon.c
===================================================================
--- linux-2.6-ppc.orig/arch/ppc64/xmon/xmon.c	2005-02-18 16:28:53.353930064 -0500
+++ linux-2.6-ppc/arch/ppc64/xmon/xmon.c	2005-02-18 16:28:53.402922616 -0500
@@ -629,11 +629,13 @@
    (data address breakpoint register) directly. */
 static void set_controlled_dabr(unsigned long val)
 {
+#ifdef CONFIG_PPC_PSERIES_LPAR
 	if (systemcfg->platform == PLATFORM_PSERIES_LPAR) {
 		int rc = plpar_hcall_norets(H_SET_DABR, val);
 		if (rc != H_Success)
 			xmon_printf("Warning: setting DABR failed (%d)\n", rc);
 	} else
+#endif /* CONFIG_PPC_PSERIES_LPAR */
 		set_dabr(val);
 }
 
Index: linux-2.6-ppc/drivers/char/Kconfig
===================================================================
--- linux-2.6-ppc.orig/drivers/char/Kconfig	2005-02-18 16:28:40.545017360 -0500
+++ linux-2.6-ppc/drivers/char/Kconfig	2005-02-18 16:28:53.404922312 -0500
@@ -557,7 +557,7 @@
 
 config HVC_CONSOLE
 	bool "pSeries Hypervisor Virtual Console support"
-	depends on PPC_PSERIES
+	depends on PPC_PSERIES_LPAR
 	help
 	  pSeries machines when partitioned support a hypervisor virtual
 	  console. This driver allows each pSeries partition to have a console
@@ -565,7 +565,7 @@
 
 config HVCS
 	tristate "IBM Hypervisor Virtual Console Server support"
-	depends on PPC_PSERIES
+	depends on PPC_PSERIES_LPAR
 	help
 	  Partitionable IBM Power5 ppc64 machines allow hosting of
 	  firmware virtual consoles from one Linux partition by
Index: linux-2.6-ppc/drivers/net/Kconfig
===================================================================
--- linux-2.6-ppc.orig/drivers/net/Kconfig	2005-02-18 16:28:40.547017056 -0500
+++ linux-2.6-ppc/drivers/net/Kconfig	2005-02-18 16:28:53.407921856 -0500
@@ -1171,7 +1171,7 @@
 
 config IBMVETH
 	tristate "IBM LAN Virtual Ethernet support"
-	depends on NETDEVICES && NET_ETHERNET && PPC_PSERIES
+	depends on NETDEVICES && NET_ETHERNET && PPC_PSERIES_LPAR
 	---help---
 	  This driver supports virtual ethernet adapters on newer IBM iSeries
 	  and pSeries systems.
Index: linux-2.6-ppc/drivers/scsi/Kconfig
===================================================================
--- linux-2.6-ppc.orig/drivers/scsi/Kconfig	2005-02-18 16:28:40.550016600 -0500
+++ linux-2.6-ppc/drivers/scsi/Kconfig	2005-02-18 16:28:53.409921552 -0500
@@ -798,7 +798,7 @@
 
 config SCSI_IBMVSCSI
 	tristate "IBM Virtual SCSI support"
-	depends on PPC_PSERIES || PPC_ISERIES
+	depends on PPC_PSERIES_LPAR || PPC_ISERIES
 	help
 	  This is the IBM POWER Virtual SCSI Client
 



-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: signature
Url : http://ozlabs.org/pipermail/linuxppc64-dev/attachments/20050222/a136d144/attachment.pgp 


More information about the Linuxppc64-dev mailing list