LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH v3 08/10] fadump: Invalidate registration and release reserved memory for general use.
From: Mahesh J Salgaonkar @ 2011-10-31 17:11 UTC (permalink / raw)
  To: linuxppc-dev, Linux Kernel, Benjamin Herrenschmidt
  Cc: Anton Blanchard, Eric W. Biederman, Milton Miller, Amerigo Wang
In-Reply-To: <20111031170200.12259.27663.stgit@mars.in.ibm.com>

From: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>

This patch introduces an sysfs interface '/sys/kernel/fadump_release_mem' to
invalidate the last fadump registration, invalidate '/proc/vmcore', release
the reserved memory for general use and re-register for future kernel dump.
Once the dump is copied to the disk, the userspace tool will echo 1 to
'/sys/kernel/fadump_release_mem'.

Release the reserved memory region excluding the size of the memory required
for future kernel dump registration.

Change in v3:
- Syncronize the fadump invalidation step to handle simultaneous writes to
  /sys/kernel/fadump_release_mem.

Change in v2:
- Introduced cpu_notes_buf_free() function to free memory allocated for
  cpu notes buffer.

Signed-off-by: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
---
 arch/powerpc/include/asm/fadump.h |    3 +
 arch/powerpc/kernel/fadump.c      |  170 ++++++++++++++++++++++++++++++++++++-
 2 files changed, 169 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/include/asm/fadump.h b/arch/powerpc/include/asm/fadump.h
index 4a7d63e..2d983e8 100644
--- a/arch/powerpc/include/asm/fadump.h
+++ b/arch/powerpc/include/asm/fadump.h
@@ -196,6 +196,9 @@ extern int fadump_reserve_mem(void);
 extern int setup_fadump(void);
 extern int is_fadump_active(void);
 extern void crash_fadump(struct pt_regs *, const char *);
+extern void fadump_cleanup(void);
+
+extern void vmcore_cleanup(void);
 #else	/* CONFIG_FA_DUMP */
 static inline int is_fadump_active(void) { return 0; }
 #endif
diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c
index 4d42fe5..ecdf81b 100644
--- a/arch/powerpc/kernel/fadump.c
+++ b/arch/powerpc/kernel/fadump.c
@@ -33,6 +33,8 @@
 #include <linux/debugfs.h>
 #include <linux/seq_file.h>
 #include <linux/crash_dump.h>
+#include <linux/kobject.h>
+#include <linux/sysfs.h>
 
 #include <asm/page.h>
 #include <asm/prom.h>
@@ -560,6 +562,19 @@ static void *cpu_notes_buf_alloc(unsigned long size)
 	return vaddr;
 }
 
+static void cpu_notes_buf_free(unsigned long vaddr, unsigned long size)
+{
+	struct page *page;
+	unsigned long order, count, i;
+
+	order = get_order(size);
+	count = 1 << order;
+	page = virt_to_page(vaddr);
+	for (i = 0; i < count; i++)
+		ClearPageReserved(page + i);
+	__free_pages(page, order);
+}
+
 /*
  * Read CPU state dump data and convert it into ELF notes.
  * The CPU dump starts with magic number "REGSAVE". NumCpusOffset should be
@@ -944,6 +959,131 @@ static int fadump_unregister_dump(struct fadump_mem_struct *fdm)
 	return 0;
 }
 
+static int fadump_invalidate_dump(struct fadump_mem_struct *fdm)
+{
+	int rc = 0;
+	unsigned int wait_time;
+
+	pr_debug("Invalidating firmware-assisted dump registration\n");
+
+	/* TODO: Add upper time limit for the delay */
+	do {
+		rc = rtas_call(fw_dump.ibm_configure_kernel_dump, 3, 1, NULL,
+			FADUMP_INVALIDATE, fdm,
+			sizeof(struct fadump_mem_struct));
+
+		wait_time = rtas_busy_delay_time(rc);
+		if (wait_time)
+			mdelay(wait_time);
+	} while (wait_time);
+
+	if (rc) {
+		printk(KERN_ERR "Failed to invalidate firmware-assisted dump "
+			"rgistration. unexpected error(%d).\n", rc);
+		return rc;
+	}
+	fw_dump.dump_active = 0;
+	fdm_active = NULL;
+	return 0;
+}
+
+void fadump_cleanup(void)
+{
+	/* Invalidate the registration only if dump is active. */
+	if (fw_dump.dump_active) {
+		init_fadump_mem_struct(&fdm,
+			fdm_active->cpu_state_data.destination_address);
+		fadump_invalidate_dump(&fdm);
+	}
+}
+
+/*
+ * Release the memory that was reserved in early boot to preserve the memory
+ * contents. The released memory will be available for general use.
+ */
+static void fadump_release_memory(unsigned long begin, unsigned long end)
+{
+	unsigned long addr;
+	unsigned long ra_start, ra_end;
+
+	ra_start = fw_dump.reserve_dump_area_start;
+	ra_end = ra_start + fw_dump.reserve_dump_area_size;
+
+	for (addr = begin; addr < end; addr += PAGE_SIZE) {
+		/*
+		 * exclude the dump reserve area. Will reuse it for next
+		 * fadump registration.
+		 */
+		if (addr <= ra_end && ((addr + PAGE_SIZE) > ra_start))
+			continue;
+
+		ClearPageReserved(pfn_to_page(addr >> PAGE_SHIFT));
+		init_page_count(pfn_to_page(addr >> PAGE_SHIFT));
+		free_page((unsigned long)__va(addr));
+		totalram_pages++;
+	}
+}
+
+static void fadump_invalidate_release_mem(void)
+{
+	unsigned long reserved_area_start, reserved_area_end;
+	unsigned long destination_address;
+
+	mutex_lock(&fadump_mutex);
+	if (!fw_dump.dump_active) {
+		mutex_unlock(&fadump_mutex);
+		return;
+	}
+
+	destination_address = fdm_active->cpu_state_data.destination_address;
+	fadump_cleanup();
+	mutex_unlock(&fadump_mutex);
+
+	/*
+	 * Save the current reserved memory bounds we will require them
+	 * later for releasing the memory for general use.
+	 */
+	reserved_area_start = fw_dump.reserve_dump_area_start;
+	reserved_area_end = reserved_area_start +
+			fw_dump.reserve_dump_area_size;
+	/*
+	 * Setup reserve_dump_area_start and its size so that we can
+	 * reuse this reserved memory for Re-registration.
+	 */
+	fw_dump.reserve_dump_area_start = destination_address;
+	fw_dump.reserve_dump_area_size = get_dump_area_size();
+
+	fadump_release_memory(reserved_area_start, reserved_area_end);
+	if (fw_dump.cpu_notes_buf) {
+		cpu_notes_buf_free((unsigned long)__va(fw_dump.cpu_notes_buf),
+					fw_dump.cpu_notes_buf_size);
+		fw_dump.cpu_notes_buf = 0;
+		fw_dump.cpu_notes_buf_size = 0;
+	}
+	/* Initialize the kernel dump memory structure for FAD registration. */
+	init_fadump_mem_struct(&fdm, fw_dump.reserve_dump_area_start);
+}
+
+static ssize_t fadump_release_memory_store(struct kobject *kobj,
+					struct kobj_attribute *attr,
+					const char *buf, size_t count)
+{
+	if (!fw_dump.dump_active)
+		return -EPERM;
+
+	if (buf[0] == '1') {
+		/*
+		 * Take away the '/proc/vmcore'. We are releasing the dump
+		 * memory, hence it will not be valid anymore.
+		 */
+		vmcore_cleanup();
+		fadump_invalidate_release_mem();
+
+	} else
+		return -EINVAL;
+	return count;
+}
+
 static ssize_t fadump_enabled_show(struct kobject *kobj,
 					struct kobj_attribute *attr,
 					char *buf)
@@ -1003,10 +1143,13 @@ static int fadump_region_show(struct seq_file *m, void *private)
 	if (!fw_dump.fadump_enabled)
 		return 0;
 
+	mutex_lock(&fadump_mutex);
 	if (fdm_active)
 		fdm_ptr = fdm_active;
-	else
+	else {
+		mutex_unlock(&fadump_mutex);
 		fdm_ptr = &fdm;
+	}
 
 	seq_printf(m,
 			"CPU : [%#016llx-%#016llx] %#llx bytes, "
@@ -1036,7 +1179,7 @@ static int fadump_region_show(struct seq_file *m, void *private)
 	if (!fdm_active ||
 		(fw_dump.reserve_dump_area_start ==
 		fdm_ptr->cpu_state_data.destination_address))
-		return 0;
+		goto out;
 
 	/* Dump is active. Show reserved memory region. */
 	seq_printf(m,
@@ -1048,9 +1191,15 @@ static int fadump_region_show(struct seq_file *m, void *private)
 			fw_dump.reserve_dump_area_start,
 			fdm_ptr->cpu_state_data.destination_address -
 			fw_dump.reserve_dump_area_start);
+out:
+	if (fdm_active)
+		mutex_unlock(&fadump_mutex);
 	return 0;
 }
 
+static struct kobj_attribute fadump_release_attr = __ATTR(fadump_release_mem,
+						0200, NULL,
+						fadump_release_memory_store);
 static struct kobj_attribute fadump_attr = __ATTR(fadump_enabled,
 						0444, fadump_enabled_show,
 						NULL);
@@ -1091,6 +1240,13 @@ static void fadump_init_files(void)
 	if (!debugfs_file)
 		printk(KERN_ERR "fadump: unable to create debugfs file"
 				" fadump_region\n");
+
+	if (fw_dump.dump_active) {
+		rc = sysfs_create_file(kernel_kobj, &fadump_release_attr.attr);
+		if (rc)
+			printk(KERN_ERR "fadump: unable to create sysfs file"
+				" fadump_release_mem (%d)\n", rc);
+	}
 	return;
 }
 
@@ -1110,8 +1266,14 @@ int __init setup_fadump(void)
 	 * If dump data is available then see if it is valid and prepare for
 	 * saving it to the disk.
 	 */
-	if (fw_dump.dump_active)
-		process_fadump(fdm_active);
+	if (fw_dump.dump_active) {
+		/*
+		 * if dump process fails then invalidate the registration
+		 * and release memory before proceeding for re-registration.
+		 */
+		if (process_fadump(fdm_active) < 0)
+			fadump_invalidate_release_mem();
+	}
 	/* Initialize the kernel dump memory structure for FAD registration. */
 	else if (fw_dump.reserve_dump_area_size)
 		init_fadump_mem_struct(&fdm, fw_dump.reserve_dump_area_start);

^ permalink raw reply related

* [RFC PATCH v3 09/10] fadump: Invalidate the fadump registration during machine shutdown.
From: Mahesh J Salgaonkar @ 2011-10-31 17:12 UTC (permalink / raw)
  To: linuxppc-dev, Linux Kernel, Benjamin Herrenschmidt
  Cc: Anton Blanchard, Eric W. Biederman, Milton Miller, Amerigo Wang
In-Reply-To: <20111031170200.12259.27663.stgit@mars.in.ibm.com>

From: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>

If dump is active during system reboot, shutdown or halt then invalidate
the fadump registration as it does not get invalidated automatically.

Signed-off-by: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
---
 arch/powerpc/kernel/setup-common.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
index ce35aaf..67e5caa 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -110,6 +110,14 @@ EXPORT_SYMBOL(ppc_do_canonicalize_irqs);
 /* also used by kexec */
 void machine_shutdown(void)
 {
+#ifdef CONFIG_FA_DUMP
+	/*
+	 * if fadump is active, cleanup the fadump registration before we
+	 * shutdown.
+	 */
+	fadump_cleanup();
+#endif
+
 	if (ppc_md.machine_shutdown)
 		ppc_md.machine_shutdown();
 }

^ permalink raw reply related

* [RFC PATCH v3 10/10] fadump: Introduce config option for firmware assisted dump feature
From: Mahesh J Salgaonkar @ 2011-10-31 17:13 UTC (permalink / raw)
  To: linuxppc-dev, Linux Kernel, Benjamin Herrenschmidt
  Cc: Anton Blanchard, Eric W. Biederman, Milton Miller, Amerigo Wang
In-Reply-To: <20111031170200.12259.27663.stgit@mars.in.ibm.com>

From: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>

This patch introduces a new config option CONFIG_FA_DUMP for firmware
assisted dump feature on Powerpc (ppc64) architecture.

Signed-off-by: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
---
 arch/powerpc/Kconfig |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 6926b61..7ce773c 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -379,6 +379,19 @@ config PHYP_DUMP
 
 	  If unsure, say "N"
 
+config FA_DUMP
+	bool "Firmware-assisted dump"
+	depends on PPC64 && PPC_RTAS && CRASH_DUMP
+	help
+	  A robust mechanism to get reliable kernel crash dump with
+	  assistance from firmware. This approach does not use kexec,
+	  instead firmware assists in booting the kdump kernel
+	  while preserving memory contents. Firmware-assisted dump
+	  is meant to be a kdump replacement offering robustness and
+	  speed not possible without system firmware assistance.
+
+	  If unsure, say "N"
+
 config PPCBUG_NVRAM
 	bool "Enable reading PPCBUG NVRAM during boot" if PPLUS || LOPEC
 	default y if PPC_PREP

^ permalink raw reply related

* Re: [1/4] powerpc: Revert show_regs() define for readability
From: Jimi Xenidis @ 2011-10-31 18:35 UTC (permalink / raw)
  To: Kumar Gala; +Cc: Linuxppc-dev list
In-Reply-To: <F8FBC967-70A0-47F4-9BB8-3E16CCEC6565@kernel.crashing.org>


On Oct 31, 2011, at 9:18 AM, Kumar Gala wrote:

>=20
> On Oct 28, 2011, at 2:40 PM, Jimi Xenidis wrote:
>=20
>>=20
>> On Oct 5, 2011, at 9:53 PM, Kumar Gala wrote:
>>=20
>>> We had an existing ifdef for 4xx & BOOKE processors that got changed =
to
>>> CONFIG_PPC_ADV_DEBUG_REGS.  The define has nothing to do with
>>> CONFIG_PPC_ADV_DEBUG_REGS.  The define really should be:
>>>=20
>>> #if defined(CONFIG_4xx) || defined(CONFIG_BOOKE)
>>>=20
>>> and not
>>>=20
>>> #ifdef CONFIG_PPC_ADV_DEBUG_REGS
>>>=20
>>> Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
>>>=20
>>> ---
>>> arch/powerpc/kernel/process.c |    2 +-
>>> 1 files changed, 1 insertions(+), 1 deletions(-)
>>>=20
>>> diff --git a/arch/powerpc/kernel/process.c =
b/arch/powerpc/kernel/process.c
>>> index 8f53954..a1b5981 100644
>>> --- a/arch/powerpc/kernel/process.c
>>> +++ b/arch/powerpc/kernel/process.c
>>> @@ -657,7 +657,7 @@ void show_regs(struct pt_regs * regs)
>>> 	if ((regs->trap !=3D 0xc00) && cpu_has_feature(CPU_FTR_CFAR))
>>> 		printk("CFAR: "REG"\n", regs->orig_gpr3);
>>> 	if (trap =3D=3D 0x300 || trap =3D=3D 0x600)
>>> -#ifdef CONFIG_PPC_ADV_DEBUG_REGS
>>> +#if defined(CONFIG_4xx) || defined(CONFIG_BOOKE)
>>> 		printk("DEAR: "REG", ESR: "REG"\n", regs->dar, =
regs->dsisr);
>>=20
>> I'll be needing "|| defined(CONFIG_PPC_BOOK3E)" added to this please.
>> -jx
>=20
> Under what platform is CONFIG_PPC_BOOK3E set and CONFIG_BOOKE is not?

this was a grep typo on my part.  sorry.
-jx


>=20
> - k
>=20

^ permalink raw reply

* Re: [4/4] powerpc/booke: Re-organize debug code
From: Jimi Xenidis @ 2011-10-31 18:37 UTC (permalink / raw)
  To: Kumar Gala; +Cc: linuxppc-dev
In-Reply-To: <137546DC-1F2C-4623-B96F-5F9FFB9498F9@kernel.crashing.org>


On Oct 31, 2011, at 9:21 AM, Kumar Gala wrote:

>=20
> On Oct 28, 2011, at 2:37 PM, Jimi Xenidis wrote:
>=20
>>=20
>> On Oct 5, 2011, at 9:53 PM, Kumar Gala wrote:
>>=20
>>> * set_dabr/do_dabr are no longer used when CNFIG_PPC_ADV_DEBUG_REGS =
is set
>>> refactor code a bit such that we only build the dabr code for
>>> !CONFIG_PPC_ADV_DEBUG_REGS and removed some =
CONFIG_PPC_ADV_DEBUG_REGS
>>> code in set_dabr that would never get built.
>>>=20
>>> * Move do_send_trap into traps.c as its only used there
>>>=20
>>> Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
>>>=20
>>> ---
>>> arch/powerpc/include/asm/system.h |    5 +--
>>> arch/powerpc/kernel/process.c     |   97 =
+++++++++++++-----------------------
>>> arch/powerpc/kernel/traps.c       |   17 +++++++
>>> 3 files changed, 53 insertions(+), 66 deletions(-)
>>>=20
>>> diff --git a/arch/powerpc/include/asm/system.h =
b/arch/powerpc/include/asm/system.h
>>> index e30a13d..1dc5d9c 100644
>>> --- a/arch/powerpc/include/asm/system.h
>>> +++ b/arch/powerpc/include/asm/system.h
>>> @@ -111,11 +111,8 @@ static inline int debugger_dabr_match(struct =
pt_regs *regs) { return 0; }
>>> static inline int debugger_fault_handler(struct pt_regs *regs) { =
return 0; }
>>> #endif
>>>=20
>>> +#ifndef CONFIG_PPC_ADV_DEBUG_REGS
>>> extern int set_dabr(unsigned long dabr);
>>> -#ifdef CONFIG_PPC_ADV_DEBUG_REGS
>>> -extern void do_send_trap(struct pt_regs *regs, unsigned long =
address,
>>> -			 unsigned long error_code, int signal_code, int =
brkpt);
>>> -#else
>>=20
>>=20
>> This part of the patch breaks xmon.c
>> Naively I simply wrapped the xmon call:
>>=20
>> diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
>> index f08836a..b5911b2 100644
>> --- a/arch/powerpc/xmon/xmon.c
>> +++ b/arch/powerpc/xmon/xmon.c
>> @@ -738,8 +738,10 @@ static void insert_bpts(void)
>>=20
>> static void insert_cpu_bpts(void)
>> {
>> +#ifndef CONFIG_PPC_ADV_DEBUG_REGS
>> 	if (dabr.enabled)
>> 		set_dabr(dabr.address | (dabr.enabled & 7));
>> +#endif
>> 	if (iabr && cpu_has_feature(CPU_FTR_IABR))
>> 		mtspr(SPRN_IABR, iabr->address
>> 			 | (iabr->enabled & (BP_IABR|BP_IABR_TE)));
>> @@ -767,7 +769,9 @@ static void remove_bpts(void)
>>=20
>> static void remove_cpu_bpts(void)
>> {
>> +#ifndef CONFIG_PPC_ADV_DEBUG_REGS
>> 	set_dabr(0);
>> +#endif
>> 	if (cpu_has_feature(CPU_FTR_IABR))
>> 		mtspr(SPRN_IABR, 0);
>> }
>=20
> Shouldn't all of these functions be #ifndef'd out as we don't support =
cpu_bpts on book-e parts in xmon code today?

Well I guess this is one for benh, because I would have expected xmon to =
test and call ppc_md.dabr.
Actually, should everyone be doing that?
-jx


>=20
>>=20
>> -JX
>>=20
>>=20
>>> extern void do_dabr(struct pt_regs *regs, unsigned long address,
>>> 		    unsigned long error_code);
>>> #endif
>>> diff --git a/arch/powerpc/kernel/process.c =
b/arch/powerpc/kernel/process.c
>>> index 269a309..989e574 100644
>>> --- a/arch/powerpc/kernel/process.c
>>> +++ b/arch/powerpc/kernel/process.c
>>> @@ -251,50 +251,6 @@ void discard_lazy_cpu_state(void)
>>> #endif /* CONFIG_SMP */
>>>=20
>>> #ifdef CONFIG_PPC_ADV_DEBUG_REGS
>>> -void do_send_trap(struct pt_regs *regs, unsigned long address,
>>> -		  unsigned long error_code, int signal_code, int =
breakpt)
>>> -{
>>> -	siginfo_t info;
>>> -
>>> -	if (notify_die(DIE_DABR_MATCH, "dabr_match", regs, error_code,
>>> -			11, SIGSEGV) =3D=3D NOTIFY_STOP)
>>> -		return;
>>> -
>>> -	/* Deliver the signal to userspace */
>>> -	info.si_signo =3D SIGTRAP;
>>> -	info.si_errno =3D breakpt;	/* breakpoint or watchpoint id =
*/
>>> -	info.si_code =3D signal_code;
>>> -	info.si_addr =3D (void __user *)address;
>>> -	force_sig_info(SIGTRAP, &info, current);
>>> -}
>>> -#else	/* !CONFIG_PPC_ADV_DEBUG_REGS */
>>> -void do_dabr(struct pt_regs *regs, unsigned long address,
>>> -		    unsigned long error_code)
>>> -{
>>> -	siginfo_t info;
>>> -
>>> -	if (notify_die(DIE_DABR_MATCH, "dabr_match", regs, error_code,
>>> -			11, SIGSEGV) =3D=3D NOTIFY_STOP)
>>> -		return;
>>> -
>>> -	if (debugger_dabr_match(regs))
>>> -		return;
>>> -
>>> -	/* Clear the DABR */
>>> -	set_dabr(0);
>>> -
>>> -	/* Deliver the signal to userspace */
>>> -	info.si_signo =3D SIGTRAP;
>>> -	info.si_errno =3D 0;
>>> -	info.si_code =3D TRAP_HWBKPT;
>>> -	info.si_addr =3D (void __user *)address;
>>> -	force_sig_info(SIGTRAP, &info, current);
>>> -}
>>> -#endif	/* CONFIG_PPC_ADV_DEBUG_REGS */
>>> -
>>> -static DEFINE_PER_CPU(unsigned long, current_dabr);
>>> -
>>> -#ifdef CONFIG_PPC_ADV_DEBUG_REGS
>>> /*
>>> * Set the debug registers back to their default "safe" values.
>>> */
>>> @@ -357,16 +313,7 @@ static void switch_booke_debug_regs(struct =
thread_struct *new_thread)
>>> 			prime_debug_regs(new_thread);
>>> }
>>> #else	/* !CONFIG_PPC_ADV_DEBUG_REGS */
>>> -#ifndef CONFIG_HAVE_HW_BREAKPOINT
>>> -static void set_debug_reg_defaults(struct thread_struct *thread)
>>> -{
>>> -	if (thread->dabr) {
>>> -		thread->dabr =3D 0;
>>> -		set_dabr(0);
>>> -	}
>>> -}
>>> -#endif /* !CONFIG_HAVE_HW_BREAKPOINT */
>>> -#endif	/* CONFIG_PPC_ADV_DEBUG_REGS */
>>> +static DEFINE_PER_CPU(unsigned long, current_dabr);
>>>=20
>>> int set_dabr(unsigned long dabr)
>>> {
>>> @@ -376,19 +323,45 @@ int set_dabr(unsigned long dabr)
>>> 		return ppc_md.set_dabr(dabr);
>>>=20
>>> 	/* XXX should we have a CPU_FTR_HAS_DABR ? */
>>> -#ifdef CONFIG_PPC_ADV_DEBUG_REGS
>>> -	mtspr(SPRN_DAC1, dabr);
>>> -#ifdef CONFIG_PPC_47x
>>> -	isync();
>>> -#endif
>>> -#elif defined(CONFIG_PPC_BOOK3S)
>>> 	mtspr(SPRN_DABR, dabr);
>>> -#endif
>>> -
>>>=20
>>> 	return 0;
>>> }
>>>=20
>>> +void do_dabr(struct pt_regs *regs, unsigned long address,
>>> +		    unsigned long error_code)
>>> +{
>>> +	siginfo_t info;
>>> +
>>> +	if (notify_die(DIE_DABR_MATCH, "dabr_match", regs, error_code,
>>> +			11, SIGSEGV) =3D=3D NOTIFY_STOP)
>>> +		return;
>>> +
>>> +	if (debugger_dabr_match(regs))
>>> +		return;
>>> +
>>> +	/* Clear the DABR */
>>> +	set_dabr(0);
>>> +
>>> +	/* Deliver the signal to userspace */
>>> +	info.si_signo =3D SIGTRAP;
>>> +	info.si_errno =3D 0;
>>> +	info.si_code =3D TRAP_HWBKPT;
>>> +	info.si_addr =3D (void __user *)address;
>>> +	force_sig_info(SIGTRAP, &info, current);
>>> +}
>>> +
>>> +#ifndef CONFIG_HAVE_HW_BREAKPOINT
>>> +static void set_debug_reg_defaults(struct thread_struct *thread)
>>> +{
>>> +	if (thread->dabr) {
>>> +		thread->dabr =3D 0;
>>> +		set_dabr(0);
>>> +	}
>>> +}
>>> +#endif /* !CONFIG_HAVE_HW_BREAKPOINT */
>>> +#endif	/* CONFIG_PPC_ADV_DEBUG_REGS */
>>> +
>>> #ifdef CONFIG_PPC64
>>> DEFINE_PER_CPU(struct cpu_usage, cpu_usage_array);
>>> #endif
>>> diff --git a/arch/powerpc/kernel/traps.c =
b/arch/powerpc/kernel/traps.c
>>> index db733d3..edc1108 100644
>>> --- a/arch/powerpc/kernel/traps.c
>>> +++ b/arch/powerpc/kernel/traps.c
>>> @@ -1184,6 +1184,23 @@ void SoftwareEmulation(struct pt_regs *regs)
>>> #endif /* CONFIG_8xx */
>>>=20
>>> #ifdef CONFIG_PPC_ADV_DEBUG_REGS
>>> +static void do_send_trap(struct pt_regs *regs, unsigned long =
address,
>>> +		  unsigned long error_code, int signal_code, int =
breakpt)
>>> +{
>>> +	siginfo_t info;
>>> +
>>> +	if (notify_die(DIE_DABR_MATCH, "dabr_match", regs, error_code,
>>> +			11, SIGSEGV) =3D=3D NOTIFY_STOP)
>>> +		return;
>>> +
>>> +	/* Deliver the signal to userspace */
>>> +	info.si_signo =3D SIGTRAP;
>>> +	info.si_errno =3D breakpt;	/* breakpoint or watchpoint id =
*/
>>> +	info.si_code =3D signal_code;
>>> +	info.si_addr =3D (void __user *)address;
>>> +	force_sig_info(SIGTRAP, &info, current);
>>> +}
>>> +
>>> static void handle_debug(struct pt_regs *regs, unsigned long =
debug_status)
>>> {
>>> 	int changed =3D 0;
>=20

^ permalink raw reply

* [RFC PATCH 02/10] powerpc: Consolidate mpic_alloc() OF address translation
From: Kyle Moffett @ 2011-10-31 21:10 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev
  Cc: Lennert Buytenhek, devicetree-discuss, Milton Miller,
	Paul Mackerras, Kyle Moffett, Scott Wood, Thomas Gleixner
In-Reply-To: <1320095411-20667-1-git-send-email-Kyle.D.Moffett@boeing.com>

Instead of using the open-coded "reg" property lookup and address
translation in mpic_alloc(), directly call of_address_to_resource().
This includes various workarounds for special cases which the naive
of_address_translate() does not.

Afterwards it is possible to remove the copiously copy-pasted calls to
of_address_translate() from the 85xx/86xx/powermac platforms.

Signed-off-by: Kyle Moffett <Kyle.D.Moffett@boeing.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Grant Likely <grant.likely@secretlab.ca>
Cc: Kumar Gala <galak@kernel.crashing.org>
---
 arch/powerpc/platforms/85xx/corenet_ds.c  |    9 +----
 arch/powerpc/platforms/85xx/ksi8560.c     |    9 +----
 arch/powerpc/platforms/85xx/mpc8536_ds.c  |    9 +----
 arch/powerpc/platforms/85xx/mpc85xx_ads.c |    9 +----
 arch/powerpc/platforms/85xx/mpc85xx_cds.c |    9 +----
 arch/powerpc/platforms/85xx/mpc85xx_ds.c  |   11 +----
 arch/powerpc/platforms/85xx/mpc85xx_mds.c |    9 +----
 arch/powerpc/platforms/85xx/mpc85xx_rdb.c |   11 +----
 arch/powerpc/platforms/85xx/p1010rdb.c    |    9 +----
 arch/powerpc/platforms/85xx/p1022_ds.c    |    9 +----
 arch/powerpc/platforms/85xx/p1023_rds.c   |    9 +----
 arch/powerpc/platforms/85xx/sbc8548.c     |    9 +----
 arch/powerpc/platforms/85xx/sbc8560.c     |    9 +----
 arch/powerpc/platforms/85xx/socrates.c    |    9 +----
 arch/powerpc/platforms/85xx/stx_gp3.c     |    9 +----
 arch/powerpc/platforms/85xx/tqm85xx.c     |    9 +----
 arch/powerpc/platforms/85xx/xes_mpc85xx.c |    9 +----
 arch/powerpc/platforms/86xx/pic.c         |    4 +-
 arch/powerpc/platforms/powermac/pic.c     |    7 +---
 arch/powerpc/sysdev/mpic.c                |   63 +++++++++++++++--------------
 20 files changed, 54 insertions(+), 177 deletions(-)

diff --git a/arch/powerpc/platforms/85xx/corenet_ds.c b/arch/powerpc/platforms/85xx/corenet_ds.c
index 435074d..7893ad3 100644
--- a/arch/powerpc/platforms/85xx/corenet_ds.c
+++ b/arch/powerpc/platforms/85xx/corenet_ds.c
@@ -36,7 +36,6 @@
 void __init corenet_ds_pic_init(void)
 {
 	struct mpic *mpic;
-	struct resource r;
 	struct device_node *np = NULL;
 	unsigned int flags = MPIC_PRIMARY | MPIC_BIG_ENDIAN |
 				MPIC_BROKEN_FRR_NIRQS | MPIC_SINGLE_DEST_CPU;
@@ -48,16 +47,10 @@ void __init corenet_ds_pic_init(void)
 		return;
 	}
 
-	if (of_address_to_resource(np, 0, &r)) {
-		printk(KERN_ERR "Failed to map mpic register space\n");
-		of_node_put(np);
-		return;
-	}
-
 	if (ppc_md.get_irq == mpic_get_coreint_irq)
 		flags |= MPIC_ENABLE_COREINT;
 
-	mpic = mpic_alloc(np, r.start, flags, 0, 256, " OpenPIC  ");
+	mpic = mpic_alloc(np, 0, flags, 0, 256, " OpenPIC  ");
 	BUG_ON(mpic == NULL);
 
 	mpic_init(mpic);
diff --git a/arch/powerpc/platforms/85xx/ksi8560.c b/arch/powerpc/platforms/85xx/ksi8560.c
index c46f935..b20c07d 100644
--- a/arch/powerpc/platforms/85xx/ksi8560.c
+++ b/arch/powerpc/platforms/85xx/ksi8560.c
@@ -68,7 +68,6 @@ static void cpm2_cascade(unsigned int irq, struct irq_desc *desc)
 static void __init ksi8560_pic_init(void)
 {
 	struct mpic *mpic;
-	struct resource r;
 	struct device_node *np;
 #ifdef CONFIG_CPM2
 	int irq;
@@ -81,13 +80,7 @@ static void __init ksi8560_pic_init(void)
 		return;
 	}
 
-	if (of_address_to_resource(np, 0, &r)) {
-		printk(KERN_ERR "Could not map mpic register space\n");
-		of_node_put(np);
-		return;
-	}
-
-	mpic = mpic_alloc(np, r.start,
+	mpic = mpic_alloc(np, 0,
 			MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
 			0, 256, " OpenPIC  ");
 	BUG_ON(mpic == NULL);
diff --git a/arch/powerpc/platforms/85xx/mpc8536_ds.c b/arch/powerpc/platforms/85xx/mpc8536_ds.c
index f79f2f1..03173ba 100644
--- a/arch/powerpc/platforms/85xx/mpc8536_ds.c
+++ b/arch/powerpc/platforms/85xx/mpc8536_ds.c
@@ -35,7 +35,6 @@
 void __init mpc8536_ds_pic_init(void)
 {
 	struct mpic *mpic;
-	struct resource r;
 	struct device_node *np;
 
 	np = of_find_node_by_type(NULL, "open-pic");
@@ -44,13 +43,7 @@ void __init mpc8536_ds_pic_init(void)
 		return;
 	}
 
-	if (of_address_to_resource(np, 0, &r)) {
-		printk(KERN_ERR "Failed to map mpic register space\n");
-		of_node_put(np);
-		return;
-	}
-
-	mpic = mpic_alloc(np, r.start,
+	mpic = mpic_alloc(np, 0,
 			  MPIC_PRIMARY | MPIC_WANTS_RESET |
 			  MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS,
 			0, 256, " OpenPIC  ");
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ads.c b/arch/powerpc/platforms/85xx/mpc85xx_ads.c
index 3b2c9bb..5cb797b 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_ads.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_ads.c
@@ -64,7 +64,6 @@ static void cpm2_cascade(unsigned int irq, struct irq_desc *desc)
 static void __init mpc85xx_ads_pic_init(void)
 {
 	struct mpic *mpic;
-	struct resource r;
 	struct device_node *np = NULL;
 #ifdef CONFIG_CPM2
 	int irq;
@@ -76,13 +75,7 @@ static void __init mpc85xx_ads_pic_init(void)
 		return;
 	}
 
-	if (of_address_to_resource(np, 0, &r)) {
-		printk(KERN_ERR "Could not map mpic register space\n");
-		of_node_put(np);
-		return;
-	}
-
-	mpic = mpic_alloc(np, r.start,
+	mpic = mpic_alloc(np, 0,
 			MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
 			0, 256, " OpenPIC  ");
 	BUG_ON(mpic == NULL);
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_cds.c b/arch/powerpc/platforms/85xx/mpc85xx_cds.c
index 2bf9978..69c1d0a 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_cds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_cds.c
@@ -187,7 +187,6 @@ static struct irqaction mpc85xxcds_8259_irqaction = {
 static void __init mpc85xx_cds_pic_init(void)
 {
 	struct mpic *mpic;
-	struct resource r;
 	struct device_node *np = NULL;
 
 	np = of_find_node_by_type(np, "open-pic");
@@ -197,13 +196,7 @@ static void __init mpc85xx_cds_pic_init(void)
 		return;
 	}
 
-	if (of_address_to_resource(np, 0, &r)) {
-		printk(KERN_ERR "Failed to map mpic register space\n");
-		of_node_put(np);
-		return;
-	}
-
-	mpic = mpic_alloc(np, r.start,
+	mpic = mpic_alloc(np, 0,
 			MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
 			0, 256, " OpenPIC  ");
 	BUG_ON(mpic == NULL);
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ds.c b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
index 52d2a3e..b608da7 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_ds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
@@ -61,7 +61,6 @@ static void mpc85xx_8259_cascade(unsigned int irq, struct irq_desc *desc)
 void __init mpc85xx_ds_pic_init(void)
 {
 	struct mpic *mpic;
-	struct resource r;
 	struct device_node *np;
 #ifdef CONFIG_PPC_I8259
 	struct device_node *cascade_node = NULL;
@@ -75,20 +74,14 @@ void __init mpc85xx_ds_pic_init(void)
 		return;
 	}
 
-	if (of_address_to_resource(np, 0, &r)) {
-		printk(KERN_ERR "Failed to map mpic register space\n");
-		of_node_put(np);
-		return;
-	}
-
 	if (of_flat_dt_is_compatible(root, "fsl,MPC8572DS-CAMP")) {
-		mpic = mpic_alloc(np, r.start,
+		mpic = mpic_alloc(np, 0,
 			MPIC_PRIMARY |
 			MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
 			MPIC_SINGLE_DEST_CPU,
 			0, 256, " OpenPIC  ");
 	} else {
-		mpic = mpic_alloc(np, r.start,
+		mpic = mpic_alloc(np, 0,
 			  MPIC_PRIMARY | MPIC_WANTS_RESET |
 			  MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
 			  MPIC_SINGLE_DEST_CPU,
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_mds.c b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
index 074be05..982f1a7 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_mds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
@@ -475,20 +475,13 @@ machine_arch_initcall(p1021_mds, swiotlb_setup_bus_notifier);
 static void __init mpc85xx_mds_pic_init(void)
 {
 	struct mpic *mpic;
-	struct resource r;
 	struct device_node *np = NULL;
 
 	np = of_find_node_by_type(NULL, "open-pic");
 	if (!np)
 		return;
 
-	if (of_address_to_resource(np, 0, &r)) {
-		printk(KERN_ERR "Failed to map mpic register space\n");
-		of_node_put(np);
-		return;
-	}
-
-	mpic = mpic_alloc(np, r.start,
+	mpic = mpic_alloc(np, 0,
 			MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN |
 			MPIC_BROKEN_FRR_NIRQS | MPIC_SINGLE_DEST_CPU,
 			0, 256, " OpenPIC  ");
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_rdb.c b/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
index cd49898..67bd1d4 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
@@ -43,7 +43,6 @@
 void __init mpc85xx_rdb_pic_init(void)
 {
 	struct mpic *mpic;
-	struct resource r;
 	struct device_node *np;
 	unsigned long root = of_get_flat_dt_root();
 
@@ -53,20 +52,14 @@ void __init mpc85xx_rdb_pic_init(void)
 		return;
 	}
 
-	if (of_address_to_resource(np, 0, &r)) {
-		printk(KERN_ERR "Failed to map mpic register space\n");
-		of_node_put(np);
-		return;
-	}
-
 	if (of_flat_dt_is_compatible(root, "fsl,MPC85XXRDB-CAMP")) {
-		mpic = mpic_alloc(np, r.start,
+		mpic = mpic_alloc(np, 0,
 			MPIC_PRIMARY |
 			MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
 			MPIC_SINGLE_DEST_CPU,
 			0, 256, " OpenPIC  ");
 	} else {
-		mpic = mpic_alloc(np, r.start,
+		mpic = mpic_alloc(np, 0,
 		  MPIC_PRIMARY | MPIC_WANTS_RESET |
 		  MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
 		  MPIC_SINGLE_DEST_CPU,
diff --git a/arch/powerpc/platforms/85xx/p1010rdb.c b/arch/powerpc/platforms/85xx/p1010rdb.c
index d7387fa..5ffca27 100644
--- a/arch/powerpc/platforms/85xx/p1010rdb.c
+++ b/arch/powerpc/platforms/85xx/p1010rdb.c
@@ -31,7 +31,6 @@
 void __init p1010_rdb_pic_init(void)
 {
 	struct mpic *mpic;
-	struct resource r;
 	struct device_node *np;
 
 	np = of_find_node_by_type(NULL, "open-pic");
@@ -40,13 +39,7 @@ void __init p1010_rdb_pic_init(void)
 		return;
 	}
 
-	if (of_address_to_resource(np, 0, &r)) {
-		printk(KERN_ERR "Failed to map mpic register space\n");
-		of_node_put(np);
-		return;
-	}
-
-	mpic = mpic_alloc(np, r.start, MPIC_PRIMARY | MPIC_WANTS_RESET |
+	mpic = mpic_alloc(np, NULL, MPIC_PRIMARY | MPIC_WANTS_RESET |
 	  MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS | MPIC_SINGLE_DEST_CPU,
 	  0, 256, " OpenPIC  ");
 
diff --git a/arch/powerpc/platforms/85xx/p1022_ds.c b/arch/powerpc/platforms/85xx/p1022_ds.c
index 7e90e24..d911aca 100644
--- a/arch/powerpc/platforms/85xx/p1022_ds.c
+++ b/arch/powerpc/platforms/85xx/p1022_ds.c
@@ -239,7 +239,6 @@ int p1022ds_set_sysfs_monitor_port(int val)
 void __init p1022_ds_pic_init(void)
 {
 	struct mpic *mpic;
-	struct resource r;
 	struct device_node *np;
 
 	np = of_find_node_by_type(NULL, "open-pic");
@@ -248,13 +247,7 @@ void __init p1022_ds_pic_init(void)
 		return;
 	}
 
-	if (of_address_to_resource(np, 0, &r)) {
-		pr_err("Failed to map mpic register space\n");
-		of_node_put(np);
-		return;
-	}
-
-	mpic = mpic_alloc(np, r.start,
+	mpic = mpic_alloc(np, 0,
 		MPIC_PRIMARY | MPIC_WANTS_RESET |
 		MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
 		MPIC_SINGLE_DEST_CPU,
diff --git a/arch/powerpc/platforms/85xx/p1023_rds.c b/arch/powerpc/platforms/85xx/p1023_rds.c
index 5ab21f3..30a5adb 100644
--- a/arch/powerpc/platforms/85xx/p1023_rds.c
+++ b/arch/powerpc/platforms/85xx/p1023_rds.c
@@ -109,7 +109,6 @@ machine_device_initcall(p1023_rds, p1023_publish_devices);
 static void __init mpc85xx_rds_pic_init(void)
 {
 	struct mpic *mpic;
-	struct resource r;
 	struct device_node *np = NULL;
 
 	np = of_find_node_by_type(NULL, "open-pic");
@@ -118,13 +117,7 @@ static void __init mpc85xx_rds_pic_init(void)
 		return;
 	}
 
-	if (of_address_to_resource(np, 0, &r)) {
-		printk(KERN_ERR "Failed to map mpic register space\n");
-		of_node_put(np);
-		return;
-	}
-
-	mpic = mpic_alloc(np, r.start,
+	mpic = mpic_alloc(np, NULL,
 		MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN |
 		MPIC_BROKEN_FRR_NIRQS | MPIC_SINGLE_DEST_CPU,
 		0, 256, " OpenPIC  ");
diff --git a/arch/powerpc/platforms/85xx/sbc8548.c b/arch/powerpc/platforms/85xx/sbc8548.c
index d07dcb7..daced7d 100644
--- a/arch/powerpc/platforms/85xx/sbc8548.c
+++ b/arch/powerpc/platforms/85xx/sbc8548.c
@@ -54,7 +54,6 @@ static int sbc_rev;
 static void __init sbc8548_pic_init(void)
 {
 	struct mpic *mpic;
-	struct resource r;
 	struct device_node *np = NULL;
 
 	np = of_find_node_by_type(np, "open-pic");
@@ -64,13 +63,7 @@ static void __init sbc8548_pic_init(void)
 		return;
 	}
 
-	if (of_address_to_resource(np, 0, &r)) {
-		printk(KERN_ERR "Failed to map mpic register space\n");
-		of_node_put(np);
-		return;
-	}
-
-	mpic = mpic_alloc(np, r.start,
+	mpic = mpic_alloc(np, 0,
 			MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
 			0, 256, " OpenPIC  ");
 	BUG_ON(mpic == NULL);
diff --git a/arch/powerpc/platforms/85xx/sbc8560.c b/arch/powerpc/platforms/85xx/sbc8560.c
index 09ced72..bd8b6c9 100644
--- a/arch/powerpc/platforms/85xx/sbc8560.c
+++ b/arch/powerpc/platforms/85xx/sbc8560.c
@@ -55,7 +55,6 @@ static void cpm2_cascade(unsigned int irq, struct irq_desc *desc)
 static void __init sbc8560_pic_init(void)
 {
 	struct mpic *mpic;
-	struct resource r;
 	struct device_node *np = NULL;
 #ifdef CONFIG_CPM2
 	int irq;
@@ -67,13 +66,7 @@ static void __init sbc8560_pic_init(void)
 		return;
 	}
 
-	if (of_address_to_resource(np, 0, &r)) {
-		printk(KERN_ERR "Could not map mpic register space\n");
-		of_node_put(np);
-		return;
-	}
-
-	mpic = mpic_alloc(np, r.start,
+	mpic = mpic_alloc(np, 0,
 			MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
 			0, 256, " OpenPIC  ");
 	BUG_ON(mpic == NULL);
diff --git a/arch/powerpc/platforms/85xx/socrates.c b/arch/powerpc/platforms/85xx/socrates.c
index 747d8fb..fb4bfd6 100644
--- a/arch/powerpc/platforms/85xx/socrates.c
+++ b/arch/powerpc/platforms/85xx/socrates.c
@@ -46,7 +46,6 @@
 static void __init socrates_pic_init(void)
 {
 	struct mpic *mpic;
-	struct resource r;
 	struct device_node *np;
 
 	np = of_find_node_by_type(NULL, "open-pic");
@@ -55,13 +54,7 @@ static void __init socrates_pic_init(void)
 		return;
 	}
 
-	if (of_address_to_resource(np, 0, &r)) {
-		printk(KERN_ERR "Could not map mpic register space\n");
-		of_node_put(np);
-		return;
-	}
-
-	mpic = mpic_alloc(np, r.start,
+	mpic = mpic_alloc(np, 0,
 			MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
 			0, 256, " OpenPIC  ");
 	BUG_ON(mpic == NULL);
diff --git a/arch/powerpc/platforms/85xx/stx_gp3.c b/arch/powerpc/platforms/85xx/stx_gp3.c
index 5387e9f..78aef45 100644
--- a/arch/powerpc/platforms/85xx/stx_gp3.c
+++ b/arch/powerpc/platforms/85xx/stx_gp3.c
@@ -59,7 +59,6 @@ static void cpm2_cascade(unsigned int irq, struct irq_desc *desc)
 static void __init stx_gp3_pic_init(void)
 {
 	struct mpic *mpic;
-	struct resource r;
 	struct device_node *np;
 #ifdef CONFIG_CPM2
 	int irq;
@@ -71,13 +70,7 @@ static void __init stx_gp3_pic_init(void)
 		return;
 	}
 
-	if (of_address_to_resource(np, 0, &r)) {
-		printk(KERN_ERR "Could not map mpic register space\n");
-		of_node_put(np);
-		return;
-	}
-
-	mpic = mpic_alloc(np, r.start,
+	mpic = mpic_alloc(np, 0,
 			MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
 			0, 256, " OpenPIC  ");
 	BUG_ON(mpic == NULL);
diff --git a/arch/powerpc/platforms/85xx/tqm85xx.c b/arch/powerpc/platforms/85xx/tqm85xx.c
index 325de77..5775f4c 100644
--- a/arch/powerpc/platforms/85xx/tqm85xx.c
+++ b/arch/powerpc/platforms/85xx/tqm85xx.c
@@ -57,7 +57,6 @@ static void cpm2_cascade(unsigned int irq, struct irq_desc *desc)
 static void __init tqm85xx_pic_init(void)
 {
 	struct mpic *mpic;
-	struct resource r;
 	struct device_node *np;
 #ifdef CONFIG_CPM2
 	int irq;
@@ -69,13 +68,7 @@ static void __init tqm85xx_pic_init(void)
 		return;
 	}
 
-	if (of_address_to_resource(np, 0, &r)) {
-		printk(KERN_ERR "Could not map mpic register space\n");
-		of_node_put(np);
-		return;
-	}
-
-	mpic = mpic_alloc(np, r.start,
+	mpic = mpic_alloc(np, 0,
 			MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
 			0, 256, " OpenPIC  ");
 	BUG_ON(mpic == NULL);
diff --git a/arch/powerpc/platforms/85xx/xes_mpc85xx.c b/arch/powerpc/platforms/85xx/xes_mpc85xx.c
index ce3f660..fccf9aa 100644
--- a/arch/powerpc/platforms/85xx/xes_mpc85xx.c
+++ b/arch/powerpc/platforms/85xx/xes_mpc85xx.c
@@ -42,7 +42,6 @@
 void __init xes_mpc85xx_pic_init(void)
 {
 	struct mpic *mpic;
-	struct resource r;
 	struct device_node *np;
 
 	np = of_find_node_by_type(NULL, "open-pic");
@@ -51,13 +50,7 @@ void __init xes_mpc85xx_pic_init(void)
 		return;
 	}
 
-	if (of_address_to_resource(np, 0, &r)) {
-		printk(KERN_ERR "Failed to map mpic register space\n");
-		of_node_put(np);
-		return;
-	}
-
-	mpic = mpic_alloc(np, r.start,
+	mpic = mpic_alloc(np, 0,
 			  MPIC_PRIMARY | MPIC_WANTS_RESET |
 			  MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS,
 			0, 256, " OpenPIC  ");
diff --git a/arch/powerpc/platforms/86xx/pic.c b/arch/powerpc/platforms/86xx/pic.c
index 8ef8960..f85c8f0 100644
--- a/arch/powerpc/platforms/86xx/pic.c
+++ b/arch/powerpc/platforms/86xx/pic.c
@@ -33,7 +33,6 @@ void __init mpc86xx_init_irq(void)
 {
 	struct mpic *mpic;
 	struct device_node *np;
-	struct resource res;
 #ifdef CONFIG_PPC_I8259
 	struct device_node *cascade_node = NULL;
 	int cascade_irq;
@@ -43,9 +42,8 @@ void __init mpc86xx_init_irq(void)
 	np = of_find_node_by_type(NULL, "open-pic");
 	if (np == NULL)
 		return;
-	of_address_to_resource(np, 0, &res);
 
-	mpic = mpic_alloc(np, res.start,
+	mpic = mpic_alloc(np, 0,
 			MPIC_PRIMARY | MPIC_WANTS_RESET |
 			MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
 			MPIC_SINGLE_DEST_CPU,
diff --git a/arch/powerpc/platforms/powermac/pic.c b/arch/powerpc/platforms/powermac/pic.c
index 7667db4..fe360f7c 100644
--- a/arch/powerpc/platforms/powermac/pic.c
+++ b/arch/powerpc/platforms/powermac/pic.c
@@ -500,15 +500,10 @@ static struct mpic * __init pmac_setup_one_mpic(struct device_node *np,
 						int master)
 {
 	const char *name = master ? " MPIC 1   " : " MPIC 2   ";
-	struct resource r;
 	struct mpic *mpic;
 	unsigned int flags = master ? MPIC_PRIMARY : 0;
 	int rc;
 
-	rc = of_address_to_resource(np, 0, &r);
-	if (rc)
-		return NULL;
-
 	pmac_call_feature(PMAC_FTR_ENABLE_MPIC, np, 0, 0);
 
 	flags |= MPIC_WANTS_RESET;
@@ -521,7 +516,7 @@ static struct mpic * __init pmac_setup_one_mpic(struct device_node *np,
 	if (master && (flags & MPIC_BIG_ENDIAN))
 		flags |= MPIC_U3_HT_IRQS;
 
-	mpic = mpic_alloc(np, r.start, flags, 0, 0, name);
+	mpic = mpic_alloc(np, 0, flags, 0, 0, name);
 	if (mpic == NULL)
 		return NULL;
 
diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
index d5d3ff3..d6ef4d9 100644
--- a/arch/powerpc/sysdev/mpic.c
+++ b/arch/powerpc/sysdev/mpic.c
@@ -1144,7 +1144,29 @@ struct mpic * __init mpic_alloc(struct device_node *node,
 	const char	*vers;
 	int		i;
 	int		intvec_top;
-	u64		paddr = phys_addr;
+
+	/*
+	 * If no phyiscal address was specified then all of the phyiscal
+	 * addressing parameters must come from the device-tree.
+	 */
+	if (!phys_addr) {
+		BUG_ON(!node);
+
+		/* Check if it is DCR-based */
+		if (of_get_property(node, "dcr-reg")) {
+			flags |= MPIC_USES_DCR;
+		} else {
+			struct resource r;
+			if (of_address_to_resource(node, 0, &r))
+				return NULL;
+			phys_addr = r.start;
+		}
+	}
+
+#ifndef CONFIG_PPC_DCR
+	/* If DCR support is not enabled then MPICs cannot use it */
+	BUG_ON(flags & MPIC_USES_DCR);
+#endif
 
 	mpic = kzalloc(sizeof(struct mpic), GFP_KERNEL);
 	if (mpic == NULL)
@@ -1226,35 +1248,16 @@ struct mpic * __init mpic_alloc(struct device_node *node,
 #endif
 
 	/* default register type */
-	mpic->reg_type = (flags & MPIC_BIG_ENDIAN) ?
-		mpic_access_mmio_be : mpic_access_mmio_le;
-
-	/* If no physical address is passed in, a device-node is mandatory */
-	BUG_ON(paddr == 0 && node == NULL);
-
-	/* If no physical address passed in, check if it's dcr based */
-	if (paddr == 0 && of_get_property(node, "dcr-reg", NULL) != NULL) {
-#ifdef CONFIG_PPC_DCR
-		mpic->flags |= MPIC_USES_DCR;
+	if (flags & MPIC_USES_DCR)
 		mpic->reg_type = mpic_access_dcr;
-#else
-		BUG();
-#endif /* CONFIG_PPC_DCR */
-	}
-
-	/* If the MPIC is not DCR based, and no physical address was passed
-	 * in, try to obtain one
-	 */
-	if (paddr == 0 && !(mpic->flags & MPIC_USES_DCR)) {
-		const u32 *reg = of_get_property(node, "reg", NULL);
-		BUG_ON(reg == NULL);
-		paddr = of_translate_address(node, reg);
-		BUG_ON(paddr == OF_BAD_ADDR);
-	}
+	else if (flags & MPIC_BIG_ENDIAN)
+		mpic->reg_type = mpic_access_mmio_be;
+	else
+		mpic->reg_type = mpic_access_mmio_le;
 
 	/* Map the global registers */
-	mpic_map(mpic, node, paddr, &mpic->gregs, MPIC_INFO(GREG_BASE), 0x1000);
-	mpic_map(mpic, node, paddr, &mpic->tmregs, MPIC_INFO(TIMER_BASE), 0x1000);
+	mpic_map(mpic, node, phys_addr, &mpic->gregs, MPIC_INFO(GREG_BASE), 0x1000);
+	mpic_map(mpic, node, phys_addr, &mpic->tmregs, MPIC_INFO(TIMER_BASE), 0x1000);
 
 	/* Reset */
 
@@ -1303,7 +1306,7 @@ struct mpic * __init mpic_alloc(struct device_node *node,
 
 	/* Map the per-CPU registers */
 	for (i = 0; i < mpic->num_cpus; i++) {
-		mpic_map(mpic, node, paddr, &mpic->cpuregs[i],
+		mpic_map(mpic, node, phys_addr, &mpic->cpuregs[i],
 			 MPIC_INFO(CPU_BASE) + i * MPIC_INFO(CPU_STRIDE),
 			 0x1000);
 	}
@@ -1311,7 +1314,7 @@ struct mpic * __init mpic_alloc(struct device_node *node,
 	/* Initialize main ISU if none provided */
 	if (mpic->isu_size == 0) {
 		mpic->isu_size = mpic->num_sources;
-		mpic_map(mpic, node, paddr, &mpic->isus[0],
+		mpic_map(mpic, node, phys_addr, &mpic->isus[0],
 			 MPIC_INFO(IRQ_BASE), MPIC_INFO(IRQ_STRIDE) * mpic->isu_size);
 	}
 	mpic->isu_shift = 1 + __ilog2(mpic->isu_size - 1);
@@ -1343,7 +1346,7 @@ struct mpic * __init mpic_alloc(struct device_node *node,
 	}
 	printk(KERN_INFO "mpic: Setting up MPIC \"%s\" version %s at %llx,"
 	       " max %d CPUs\n",
-	       name, vers, (unsigned long long)paddr, mpic->num_cpus);
+	       name, vers, (unsigned long long)phys_addr, mpic->num_cpus);
 	printk(KERN_INFO "mpic: ISU size: %d, shift: %d, mask: %x\n",
 	       mpic->isu_size, mpic->isu_shift, mpic->isu_mask);
 
-- 
1.7.2.5

^ permalink raw reply related

* [RFC PATCH 03/10] powerpc/mpic: Assume a device-node was passed in mpic_alloc()
From: Kyle Moffett @ 2011-10-31 21:10 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev
  Cc: devicetree-discuss, Milton Miller, Paul Mackerras, Kyle Moffett,
	Scott Wood
In-Reply-To: <1320095411-20667-1-git-send-email-Kyle.D.Moffett@boeing.com>

All of the existing callers of mpic_alloc() pass in a non-NULL
device-node pointer, so the checks for a NULL device-node may be
removed.

Signed-off-by: Kyle Moffett <Kyle.D.Moffett@boeing.com>
---
 arch/powerpc/sysdev/mpic.c |   50 ++++++++++++++++++-------------------------
 1 files changed, 21 insertions(+), 29 deletions(-)

diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
index d6ef4d9..f7de33e 100644
--- a/arch/powerpc/sysdev/mpic.c
+++ b/arch/powerpc/sysdev/mpic.c
@@ -1139,19 +1139,17 @@ struct mpic * __init mpic_alloc(struct device_node *node,
 				unsigned int irq_count,
 				const char *name)
 {
-	struct mpic	*mpic;
-	u32		greg_feature;
-	const char	*vers;
-	int		i;
-	int		intvec_top;
+	int i, psize, intvec_top;
+	struct mpic *mpic;
+	u32 greg_feature;
+	const char *vers;
+	const u32 *psrc;
 
-	/*
-	 * If no phyiscal address was specified then all of the phyiscal
-	 * addressing parameters must come from the device-tree.
-	 */
-	if (!phys_addr) {
-		BUG_ON(!node);
+	/* This code assumes that a non-NULL device node is passed in */
+	BUG_ON(!node);
 
+	/* Pick the physical address from the device tree if unspecified */
+	if (!phys_addr) {
 		/* Check if it is DCR-based */
 		if (of_get_property(node, "dcr-reg")) {
 			flags |= MPIC_USES_DCR;
@@ -1218,28 +1216,22 @@ struct mpic * __init mpic_alloc(struct device_node *node,
 	mpic->spurious_vec  = intvec_top;
 
 	/* Check for "big-endian" in device-tree */
-	if (node && of_get_property(node, "big-endian", NULL) != NULL)
+	if (of_get_property(node, "big-endian", NULL) != NULL)
 		mpic->flags |= MPIC_BIG_ENDIAN;
-	if (node && of_device_is_compatible(node, "fsl,mpic"))
+	if (of_device_is_compatible(node, "fsl,mpic"))
 		mpic->flags |= MPIC_FSL;
 
 	/* Look for protected sources */
-	if (node) {
-		int psize;
-		unsigned int bits, mapsize;
-		const u32 *psrc =
-			of_get_property(node, "protected-sources", &psize);
-		if (psrc) {
-			psize /= 4;
-			bits = intvec_top + 1;
-			mapsize = BITS_TO_LONGS(bits) * sizeof(unsigned long);
-			mpic->protected = kzalloc(mapsize, GFP_KERNEL);
-			BUG_ON(mpic->protected == NULL);
-			for (i = 0; i < psize; i++) {
-				if (psrc[i] > intvec_top)
-					continue;
-				__set_bit(psrc[i], mpic->protected);
-			}
+	psrc = of_get_property(node, "protected-sources", &psize);
+	if (psrc) {
+		/* Allocate a bitmap with one bit per interrupt */
+		unsigned int mapsize = BITS_TO_LONGS(intvec_top + 1);
+		mpic->protected = kzalloc(mapsize*sizeof(long), GFP_KERNEL);
+		BUG_ON(mpic->protected == NULL);
+		for (i = 0; i < psize/sizeof(u32); i++) {
+			if (psrc[i] > intvec_top)
+				continue;
+			__set_bit(psrc[i], mpic->protected);
 		}
 	}
 
-- 
1.7.2.5

^ permalink raw reply related

* [RFC PATCH 04/10] powerpc/mpic: Save computed phys_addr for board-specific code
From: Kyle Moffett @ 2011-10-31 21:10 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev
  Cc: devicetree-discuss, Milton Miller, Scott Wood, Paul Mackerras,
	Kyle Moffett, Olof Johansson, Thomas Gleixner
In-Reply-To: <1320095411-20667-1-git-send-email-Kyle.D.Moffett@boeing.com>

The MPIC code can already perform an automatic OF address translation
step as part of mpic_alloc(), but several boards need to use that base
address when they perform mpic_assign_isu().

The easiest solution is to save the computed physical address into the
"struct mpic" for later use by the board code.

Signed-off-by: Kyle Moffett <Kyle.D.Moffett@boeing.com>
---
 arch/powerpc/include/asm/mpic.h                   |    3 +++
 arch/powerpc/platforms/embedded6xx/holly.c        |   15 +++------------
 arch/powerpc/platforms/embedded6xx/linkstation.c  |   14 ++++----------
 arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c |   16 +++-------------
 arch/powerpc/platforms/embedded6xx/storcenter.c   |   16 +++-------------
 arch/powerpc/platforms/pasemi/setup.c             |    2 +-
 arch/powerpc/sysdev/mpic.c                        |   11 ++++++-----
 7 files changed, 23 insertions(+), 54 deletions(-)

diff --git a/arch/powerpc/include/asm/mpic.h b/arch/powerpc/include/asm/mpic.h
index df18989..49bab41 100644
--- a/arch/powerpc/include/asm/mpic.h
+++ b/arch/powerpc/include/asm/mpic.h
@@ -295,6 +295,9 @@ struct mpic
 	/* Register access method */
 	enum mpic_reg_type	reg_type;
 
+	/* The physical base address of the MPIC */
+	phys_addr_t paddr;
+
 	/* The various ioremap'ed bases */
 	struct mpic_reg_bank	gregs;
 	struct mpic_reg_bank	tmregs;
diff --git a/arch/powerpc/platforms/embedded6xx/holly.c b/arch/powerpc/platforms/embedded6xx/holly.c
index 487bda0..80b2e2a 100644
--- a/arch/powerpc/platforms/embedded6xx/holly.c
+++ b/arch/powerpc/platforms/embedded6xx/holly.c
@@ -147,7 +147,6 @@ static void __init holly_setup_arch(void)
 static void __init holly_init_IRQ(void)
 {
 	struct mpic *mpic;
-	phys_addr_t mpic_paddr = 0;
 	struct device_node *tsi_pic;
 #ifdef CONFIG_PCI
 	unsigned int cascade_pci_irq;
@@ -156,20 +155,12 @@ static void __init holly_init_IRQ(void)
 #endif
 
 	tsi_pic = of_find_node_by_type(NULL, "open-pic");
-	if (tsi_pic) {
-		unsigned int size;
-		const void *prop = of_get_property(tsi_pic, "reg", &size);
-		mpic_paddr = of_translate_address(tsi_pic, prop);
-	}
-
-	if (mpic_paddr == 0) {
+	if (!tsi_pic) {
 		printk(KERN_ERR "%s: No tsi108 PIC found !\n", __func__);
 		return;
 	}
 
-	pr_debug("%s: tsi108 pic phys_addr = 0x%x\n", __func__, (u32) mpic_paddr);
-
-	mpic = mpic_alloc(tsi_pic, mpic_paddr,
+	mpic = mpic_alloc(tsi_pic, 0,
 			MPIC_PRIMARY | MPIC_BIG_ENDIAN | MPIC_WANTS_RESET |
 			MPIC_SPV_EOI | MPIC_NO_PTHROU_DIS | MPIC_REGSET_TSI108,
 			24,
@@ -178,7 +169,7 @@ static void __init holly_init_IRQ(void)
 
 	BUG_ON(mpic == NULL);
 
-	mpic_assign_isu(mpic, 0, mpic_paddr + 0x100);
+	mpic_assign_isu(mpic, 0, mpic->paddr + 0x100);
 
 	mpic_init(mpic);
 
diff --git a/arch/powerpc/platforms/embedded6xx/linkstation.c b/arch/powerpc/platforms/embedded6xx/linkstation.c
index 244f997..72b3685 100644
--- a/arch/powerpc/platforms/embedded6xx/linkstation.c
+++ b/arch/powerpc/platforms/embedded6xx/linkstation.c
@@ -82,28 +82,22 @@ static void __init linkstation_init_IRQ(void)
 {
 	struct mpic *mpic;
 	struct device_node *dnp;
-	const u32 *prop;
-	int size;
-	phys_addr_t paddr;
 
 	dnp = of_find_node_by_type(NULL, "open-pic");
 	if (dnp == NULL)
 		return;
 
-	prop = of_get_property(dnp, "reg", &size);
-	paddr = (phys_addr_t)of_translate_address(dnp, prop);
-
-	mpic = mpic_alloc(dnp, paddr, MPIC_PRIMARY | MPIC_WANTS_RESET, 4, 32, " EPIC     ");
+	mpic = mpic_alloc(dnp, 0, MPIC_PRIMARY | MPIC_WANTS_RESET, 4, 32, " EPIC     ");
 	BUG_ON(mpic == NULL);
 
 	/* PCI IRQs */
-	mpic_assign_isu(mpic, 0, paddr + 0x10200);
+	mpic_assign_isu(mpic, 0, mpic->paddr + 0x10200);
 
 	/* I2C */
-	mpic_assign_isu(mpic, 1, paddr + 0x11000);
+	mpic_assign_isu(mpic, 1, mpic->paddr + 0x11000);
 
 	/* ttyS0, ttyS1 */
-	mpic_assign_isu(mpic, 2, paddr + 0x11100);
+	mpic_assign_isu(mpic, 2, mpic->paddr + 0x11100);
 
 	mpic_init(mpic);
 }
diff --git a/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c b/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c
index 1cb907c..28082f9 100644
--- a/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c
+++ b/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c
@@ -101,7 +101,6 @@ static void __init mpc7448_hpc2_setup_arch(void)
 static void __init mpc7448_hpc2_init_IRQ(void)
 {
 	struct mpic *mpic;
-	phys_addr_t mpic_paddr = 0;
 	struct device_node *tsi_pic;
 #ifdef CONFIG_PCI
 	unsigned int cascade_pci_irq;
@@ -110,21 +109,12 @@ static void __init mpc7448_hpc2_init_IRQ(void)
 #endif
 
 	tsi_pic = of_find_node_by_type(NULL, "open-pic");
-	if (tsi_pic) {
-		unsigned int size;
-		const void *prop = of_get_property(tsi_pic, "reg", &size);
-		mpic_paddr = of_translate_address(tsi_pic, prop);
-	}
-
-	if (mpic_paddr == 0) {
+	if (!tsi_pic) {
 		printk("%s: No tsi108 PIC found !\n", __func__);
 		return;
 	}
 
-	DBG("%s: tsi108 pic phys_addr = 0x%x\n", __func__,
-	    (u32) mpic_paddr);
-
-	mpic = mpic_alloc(tsi_pic, mpic_paddr,
+	mpic = mpic_alloc(tsi_pic, 0,
 			MPIC_PRIMARY | MPIC_BIG_ENDIAN | MPIC_WANTS_RESET |
 			MPIC_SPV_EOI | MPIC_NO_PTHROU_DIS | MPIC_REGSET_TSI108,
 			24,
@@ -133,7 +123,7 @@ static void __init mpc7448_hpc2_init_IRQ(void)
 
 	BUG_ON(mpic == NULL);
 
-	mpic_assign_isu(mpic, 0, mpic_paddr + 0x100);
+	mpic_assign_isu(mpic, 0, mpic->paddr + 0x100);
 
 	mpic_init(mpic);
 
diff --git a/arch/powerpc/platforms/embedded6xx/storcenter.c b/arch/powerpc/platforms/embedded6xx/storcenter.c
index 613070e..797870f 100644
--- a/arch/powerpc/platforms/embedded6xx/storcenter.c
+++ b/arch/powerpc/platforms/embedded6xx/storcenter.c
@@ -84,22 +84,12 @@ static void __init storcenter_init_IRQ(void)
 {
 	struct mpic *mpic;
 	struct device_node *dnp;
-	const void *prop;
-	int size;
-	phys_addr_t paddr;
 
 	dnp = of_find_node_by_type(NULL, "open-pic");
 	if (dnp == NULL)
 		return;
 
-	prop = of_get_property(dnp, "reg", &size);
-	if (prop == NULL) {
-		of_node_put(dnp);
-		return;
-	}
-
-	paddr = (phys_addr_t)of_translate_address(dnp, prop);
-	mpic = mpic_alloc(dnp, paddr, MPIC_PRIMARY | MPIC_WANTS_RESET,
+	mpic = mpic_alloc(dnp, 0, MPIC_PRIMARY | MPIC_WANTS_RESET,
 			16, 32, " OpenPIC  ");
 
 	of_node_put(dnp);
@@ -110,8 +100,8 @@ static void __init storcenter_init_IRQ(void)
 	 * 16 Serial Interrupts followed by 16 Internal Interrupts.
 	 * I2C is the second internal, so it is at 17, 0x11020.
 	 */
-	mpic_assign_isu(mpic, 0, paddr + 0x10200);
-	mpic_assign_isu(mpic, 1, paddr + 0x11000);
+	mpic_assign_isu(mpic, 0, mpic->paddr + 0x10200);
+	mpic_assign_isu(mpic, 1, mpic->paddr + 0x11000);
 
 	mpic_init(mpic);
 }
diff --git a/arch/powerpc/platforms/pasemi/setup.c b/arch/powerpc/platforms/pasemi/setup.c
index 7c858e6..883757e 100644
--- a/arch/powerpc/platforms/pasemi/setup.c
+++ b/arch/powerpc/platforms/pasemi/setup.c
@@ -233,7 +233,7 @@ static __init void pas_init_IRQ(void)
 			  mpic_flags, 0, 0, "PASEMI-OPIC");
 	BUG_ON(!mpic);
 
-	mpic_assign_isu(mpic, 0, openpic_addr + 0x10000);
+	mpic_assign_isu(mpic, 0, mpic->paddr + 0x10000);
 	mpic_init(mpic);
 	/* The NMI/MCK source needs to be prio 15 */
 	if (nmiprop) {
diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
index f7de33e..0ad7bf2 100644
--- a/arch/powerpc/sysdev/mpic.c
+++ b/arch/powerpc/sysdev/mpic.c
@@ -1171,6 +1171,7 @@ struct mpic * __init mpic_alloc(struct device_node *node,
 		return NULL;
 
 	mpic->name = name;
+	mpic->paddr = phys_addr;
 
 	mpic->hc_irq = mpic_irq_chip;
 	mpic->hc_irq.name = name;
@@ -1248,8 +1249,8 @@ struct mpic * __init mpic_alloc(struct device_node *node,
 		mpic->reg_type = mpic_access_mmio_le;
 
 	/* Map the global registers */
-	mpic_map(mpic, node, phys_addr, &mpic->gregs, MPIC_INFO(GREG_BASE), 0x1000);
-	mpic_map(mpic, node, phys_addr, &mpic->tmregs, MPIC_INFO(TIMER_BASE), 0x1000);
+	mpic_map(mpic, node, mpic->paddr, &mpic->gregs, MPIC_INFO(GREG_BASE), 0x1000);
+	mpic_map(mpic, node, mpic->paddr, &mpic->tmregs, MPIC_INFO(TIMER_BASE), 0x1000);
 
 	/* Reset */
 
@@ -1298,7 +1299,7 @@ struct mpic * __init mpic_alloc(struct device_node *node,
 
 	/* Map the per-CPU registers */
 	for (i = 0; i < mpic->num_cpus; i++) {
-		mpic_map(mpic, node, phys_addr, &mpic->cpuregs[i],
+		mpic_map(mpic, node, mpic->paddr, &mpic->cpuregs[i],
 			 MPIC_INFO(CPU_BASE) + i * MPIC_INFO(CPU_STRIDE),
 			 0x1000);
 	}
@@ -1306,7 +1307,7 @@ struct mpic * __init mpic_alloc(struct device_node *node,
 	/* Initialize main ISU if none provided */
 	if (mpic->isu_size == 0) {
 		mpic->isu_size = mpic->num_sources;
-		mpic_map(mpic, node, phys_addr, &mpic->isus[0],
+		mpic_map(mpic, node, mpic->paddr, &mpic->isus[0],
 			 MPIC_INFO(IRQ_BASE), MPIC_INFO(IRQ_STRIDE) * mpic->isu_size);
 	}
 	mpic->isu_shift = 1 + __ilog2(mpic->isu_size - 1);
@@ -1338,7 +1339,7 @@ struct mpic * __init mpic_alloc(struct device_node *node,
 	}
 	printk(KERN_INFO "mpic: Setting up MPIC \"%s\" version %s at %llx,"
 	       " max %d CPUs\n",
-	       name, vers, (unsigned long long)phys_addr, mpic->num_cpus);
+	       name, vers, (unsigned long long)mpic->paddr, mpic->num_cpus);
 	printk(KERN_INFO "mpic: ISU size: %d, shift: %d, mask: %x\n",
 	       mpic->isu_size, mpic->isu_shift, mpic->isu_mask);
 
-- 
1.7.2.5

^ permalink raw reply related

* [RFC PATCH 07/10] powerpc/mpic: Don't open-code dcr_resource_start
From: Kyle Moffett @ 2011-10-31 21:10 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev
  Cc: devicetree-discuss, Milton Miller, Paul Mackerras, Kyle Moffett,
	Scott Wood
In-Reply-To: <1320095411-20667-1-git-send-email-Kyle.D.Moffett@boeing.com>

Don't open-code the OpenFirmware "dcr-reg" property lookup trying to map
DCR resources.  This makes the code a bit easier to read.

Signed-off-by: Kyle Moffett <Kyle.D.Moffett@boeing.com>
---
 arch/powerpc/sysdev/mpic.c |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
index 31a9ada..0342ab8 100644
--- a/arch/powerpc/sysdev/mpic.c
+++ b/arch/powerpc/sysdev/mpic.c
@@ -319,11 +319,8 @@ static void _mpic_map_dcr(struct mpic *mpic, struct device_node *node,
 			  struct mpic_reg_bank *rb,
 			  unsigned int offset, unsigned int size)
 {
-	const u32 *dbasep;
-
-	dbasep = of_get_property(node, "dcr-reg", NULL);
-
-	rb->dhost = dcr_map(node, *dbasep + offset, size);
+	phys_addr_t phys_addr = dcr_resource_start(node);
+	rb->dhost = dcr_map(mpic->node, phys_addr + offset, size);
 	BUG_ON(!DCR_MAP_OK(rb->dhost));
 }
 
-- 
1.7.2.5

^ permalink raw reply related

* [RFC PATCH 08/10] powerpc/mpic: Put "pic-no-reset" test back into the MPIC code
From: Kyle Moffett @ 2011-10-31 21:10 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev
  Cc: devicetree-discuss, Milton Miller, Paul Mackerras, Kyle Moffett,
	Scott Wood
In-Reply-To: <1320095411-20667-1-git-send-email-Kyle.D.Moffett@boeing.com>

There's not really any reason to have this one-liner in a separate
static inline function, given that all the other similar tests are
already in the alloc_mpic() code.

Signed-off-by: Kyle Moffett <Kyle.D.Moffett@boeing.com>
---
 arch/powerpc/sysdev/mpic.c |    7 +------
 1 files changed, 1 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
index 0342ab8..8b4f022 100644
--- a/arch/powerpc/sysdev/mpic.c
+++ b/arch/powerpc/sysdev/mpic.c
@@ -1120,11 +1120,6 @@ static struct irq_host_ops mpic_host_ops = {
 	.xlate = mpic_host_xlate,
 };
 
-static int mpic_reset_prohibited(struct device_node *node)
-{
-	return node && of_get_property(node, "pic-no-reset", NULL);
-}
-
 /*
  * Exported functions
  */
@@ -1269,7 +1264,7 @@ struct mpic * __init mpic_alloc(struct device_node *node,
 	/* When using a device-node, reset requests are only honored if the MPIC
 	 * is allowed to reset.
 	 */
-	if (mpic_reset_prohibited(node))
+	if (of_get_property(node, "pic-no-reset", NULL))
 		mpic->flags |= MPIC_NO_RESET;
 
 	if ((flags & MPIC_WANTS_RESET) && !(mpic->flags & MPIC_NO_RESET)) {
-- 
1.7.2.5

^ permalink raw reply related

* [RFC PATCH 09/10] powerpc/mpic: Cache the device-tree node in "struct mpic"
From: Kyle Moffett @ 2011-10-31 21:10 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev
  Cc: devicetree-discuss, Milton Miller, Paul Mackerras, Kyle Moffett,
	Scott Wood
In-Reply-To: <1320095411-20667-1-git-send-email-Kyle.D.Moffett@boeing.com>

Store the node pointer in the MPIC during initialization so that all of
the later operational code can just reuse the cached pointer.

Signed-off-by: Kyle Moffett <Kyle.D.Moffett@boeing.com>
---
 arch/powerpc/include/asm/mpic.h |    3 +++
 arch/powerpc/sysdev/mpic.c      |   32 ++++++++++++++++----------------
 2 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/arch/powerpc/include/asm/mpic.h b/arch/powerpc/include/asm/mpic.h
index a241076..db78b89 100644
--- a/arch/powerpc/include/asm/mpic.h
+++ b/arch/powerpc/include/asm/mpic.h
@@ -251,6 +251,9 @@ struct mpic_irq_save {
 /* The instance data of a given MPIC */
 struct mpic
 {
+	/* The OpenFirmware dt node for this MPIC */
+	struct device_node *node;
+
 	/* The remapper for this MPIC */
 	struct irq_host		*irqhost;
 
diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
index 8b4f022..1826dae 100644
--- a/arch/powerpc/sysdev/mpic.c
+++ b/arch/powerpc/sysdev/mpic.c
@@ -315,26 +315,25 @@ static void _mpic_map_mmio(struct mpic *mpic, phys_addr_t phys_addr,
 }
 
 #ifdef CONFIG_PPC_DCR
-static void _mpic_map_dcr(struct mpic *mpic, struct device_node *node,
-			  struct mpic_reg_bank *rb,
+static void _mpic_map_dcr(struct mpic *mpic, struct mpic_reg_bank *rb,
 			  unsigned int offset, unsigned int size)
 {
-	phys_addr_t phys_addr = dcr_resource_start(node);
+	phys_addr_t phys_addr = dcr_resource_start(mpic->node);
 	rb->dhost = dcr_map(mpic->node, phys_addr + offset, size);
 	BUG_ON(!DCR_MAP_OK(rb->dhost));
 }
 
-static inline void mpic_map(struct mpic *mpic, struct device_node *node,
+static inline void mpic_map(struct mpic *mpic,
 			    phys_addr_t phys_addr, struct mpic_reg_bank *rb,
 			    unsigned int offset, unsigned int size)
 {
 	if (mpic->flags & MPIC_USES_DCR)
-		_mpic_map_dcr(mpic, node, rb, offset, size);
+		_mpic_map_dcr(mpic, rb, offset, size);
 	else
 		_mpic_map_mmio(mpic, phys_addr, rb, offset, size);
 }
 #else /* CONFIG_PPC_DCR */
-#define mpic_map(m,n,p,b,o,s)	_mpic_map_mmio(m,p,b,o,s)
+#define mpic_map(m,p,b,o,s)	_mpic_map_mmio(m,p,b,o,s)
 #endif /* !CONFIG_PPC_DCR */
 
 
@@ -1178,6 +1177,7 @@ struct mpic * __init mpic_alloc(struct device_node *node,
 		return NULL;
 
 	mpic->name = name;
+	mpic->node = node;
 	mpic->paddr = phys_addr;
 
 	mpic->hc_irq = mpic_irq_chip;
@@ -1224,13 +1224,13 @@ struct mpic * __init mpic_alloc(struct device_node *node,
 	mpic->spurious_vec  = intvec_top;
 
 	/* Check for "big-endian" in device-tree */
-	if (of_get_property(node, "big-endian", NULL) != NULL)
+	if (of_get_property(mpic->node, "big-endian", NULL) != NULL)
 		mpic->flags |= MPIC_BIG_ENDIAN;
-	if (of_device_is_compatible(node, "fsl,mpic"))
+	if (of_device_is_compatible(mpic->node, "fsl,mpic"))
 		mpic->flags |= MPIC_FSL;
 
 	/* Look for protected sources */
-	psrc = of_get_property(node, "protected-sources", &psize);
+	psrc = of_get_property(mpic->node, "protected-sources", &psize);
 	if (psrc) {
 		/* Allocate a bitmap with one bit per interrupt */
 		unsigned int mapsize = BITS_TO_LONGS(intvec_top + 1);
@@ -1256,15 +1256,15 @@ struct mpic * __init mpic_alloc(struct device_node *node,
 		mpic->reg_type = mpic_access_mmio_le;
 
 	/* Map the global registers */
-	mpic_map(mpic, node, mpic->paddr, &mpic->gregs, MPIC_INFO(GREG_BASE), 0x1000);
-	mpic_map(mpic, node, mpic->paddr, &mpic->tmregs, MPIC_INFO(TIMER_BASE), 0x1000);
+	mpic_map(mpic, mpic->paddr, &mpic->gregs, MPIC_INFO(GREG_BASE), 0x1000);
+	mpic_map(mpic, mpic->paddr, &mpic->tmregs, MPIC_INFO(TIMER_BASE), 0x1000);
 
 	/* Reset */
 
 	/* When using a device-node, reset requests are only honored if the MPIC
 	 * is allowed to reset.
 	 */
-	if (of_get_property(node, "pic-no-reset", NULL))
+	if (of_get_property(mpic->node, "pic-no-reset", NULL))
 		mpic->flags |= MPIC_NO_RESET;
 
 	if ((flags & MPIC_WANTS_RESET) && !(mpic->flags & MPIC_NO_RESET)) {
@@ -1306,7 +1306,7 @@ struct mpic * __init mpic_alloc(struct device_node *node,
 
 	/* Map the per-CPU registers */
 	for (i = 0; i < mpic->num_cpus; i++) {
-		mpic_map(mpic, node, mpic->paddr, &mpic->cpuregs[i],
+		mpic_map(mpic, mpic->paddr, &mpic->cpuregs[i],
 			 MPIC_INFO(CPU_BASE) + i * MPIC_INFO(CPU_STRIDE),
 			 0x1000);
 	}
@@ -1314,13 +1314,13 @@ struct mpic * __init mpic_alloc(struct device_node *node,
 	/* Initialize main ISU if none provided */
 	if (mpic->isu_size == 0) {
 		mpic->isu_size = mpic->num_sources;
-		mpic_map(mpic, node, mpic->paddr, &mpic->isus[0],
+		mpic_map(mpic, mpic->paddr, &mpic->isus[0],
 			 MPIC_INFO(IRQ_BASE), MPIC_INFO(IRQ_STRIDE) * mpic->isu_size);
 	}
 	mpic->isu_shift = 1 + __ilog2(mpic->isu_size - 1);
 	mpic->isu_mask = (1 << mpic->isu_shift) - 1;
 
-	mpic->irqhost = irq_alloc_host(node, IRQ_HOST_MAP_LINEAR,
+	mpic->irqhost = irq_alloc_host(mpic->node, IRQ_HOST_MAP_LINEAR,
 				       isu_size ? isu_size : mpic->num_sources,
 				       &mpic_host_ops,
 				       flags & MPIC_LARGE_VECTORS ? 2048 : 256);
@@ -1368,7 +1368,7 @@ void __init mpic_assign_isu(struct mpic *mpic, unsigned int isu_num,
 
 	BUG_ON(isu_num >= MPIC_MAX_ISU);
 
-	mpic_map(mpic, mpic->irqhost->of_node,
+	mpic_map(mpic,
 		 paddr, &mpic->isus[isu_num], 0,
 		 MPIC_INFO(IRQ_STRIDE) * mpic->isu_size);
 
-- 
1.7.2.5

^ permalink raw reply related

* [RFC PATCH 00/10] powerpc/mpic: General cleanup patch series
From: Kyle Moffett @ 2011-10-31 21:10 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev; +Cc: Kyle Moffett

Hello,

I've been tinkering with a series of patches to clean up the PowerPC
MPIC/OpenPIC init recently as part of a new board port I'm working on.

It's reached the point where I'd like some feedback on the general
approach.  The code itself hasn't been tested at all yet, and probably
does not compile right now (though that is my next step).

(Oh, actually, the first patch isn't really even about the MPIC code,
it should probably be reviewed on its own; oh well...)

Please let me know what you think.

Cheers,
Kyle Moffett

--
Curious about my work on the Debian powerpcspe port?
I'm keeping a blog here: http://pureperl.blogspot.com/

^ permalink raw reply

* [RFC PATCH 01/10] powerpc/85xx: Move mpc85xx_smp_init() decl to a new "smp.h"
From: Kyle Moffett @ 2011-10-31 21:10 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev; +Cc: Paul Mackerras, Kyle Moffett
In-Reply-To: <1320095411-20667-1-git-send-email-Kyle.D.Moffett@boeing.com>

This removes a bunch of "extern" declarations and CONFIG_SMP ifdefs.

Signed-off-by: Kyle Moffett <Kyle.D.Moffett@boeing.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Kumar Gala <galak@kernel.crashing.org>
---
 arch/powerpc/platforms/85xx/corenet_ds.c  |    7 +------
 arch/powerpc/platforms/85xx/mpc85xx_ds.c  |    6 +-----
 arch/powerpc/platforms/85xx/mpc85xx_mds.c |    7 +------
 arch/powerpc/platforms/85xx/mpc85xx_rdb.c |    7 +------
 arch/powerpc/platforms/85xx/p1022_ds.c    |    7 +------
 arch/powerpc/platforms/85xx/p1023_rds.c   |    5 +----
 arch/powerpc/platforms/85xx/smp.c         |    1 +
 arch/powerpc/platforms/85xx/smp.h         |   15 +++++++++++++++
 arch/powerpc/platforms/85xx/xes_mpc85xx.c |    6 +-----
 9 files changed, 23 insertions(+), 38 deletions(-)
 create mode 100644 arch/powerpc/platforms/85xx/smp.h

diff --git a/arch/powerpc/platforms/85xx/corenet_ds.c b/arch/powerpc/platforms/85xx/corenet_ds.c
index 802ad11..435074d 100644
--- a/arch/powerpc/platforms/85xx/corenet_ds.c
+++ b/arch/powerpc/platforms/85xx/corenet_ds.c
@@ -31,6 +31,7 @@
 #include <linux/of_platform.h>
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
+#include "smp.h"
 
 void __init corenet_ds_pic_init(void)
 {
@@ -65,10 +66,6 @@ void __init corenet_ds_pic_init(void)
 /*
  * Setup the architecture
  */
-#ifdef CONFIG_SMP
-void __init mpc85xx_smp_init(void);
-#endif
-
 void __init corenet_ds_setup_arch(void)
 {
 #ifdef CONFIG_PCI
@@ -77,9 +74,7 @@ void __init corenet_ds_setup_arch(void)
 #endif
 	dma_addr_t max = 0xffffffff;
 
-#ifdef CONFIG_SMP
 	mpc85xx_smp_init();
-#endif
 
 #ifdef CONFIG_PCI
 	for_each_node_by_type(np, "pci") {
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ds.c b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
index 1b9a8cf..52d2a3e 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_ds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
@@ -35,6 +35,7 @@
 
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
+#include "smp.h"
 
 #undef DEBUG
 
@@ -152,9 +153,6 @@ static int mpc85xx_exclude_device(struct pci_controller *hose,
 /*
  * Setup the architecture
  */
-#ifdef CONFIG_SMP
-extern void __init mpc85xx_smp_init(void);
-#endif
 static void __init mpc85xx_ds_setup_arch(void)
 {
 #ifdef CONFIG_PCI
@@ -187,9 +185,7 @@ static void __init mpc85xx_ds_setup_arch(void)
 	ppc_md.pci_exclude_device = mpc85xx_exclude_device;
 #endif
 
-#ifdef CONFIG_SMP
 	mpc85xx_smp_init();
-#endif
 
 #ifdef CONFIG_SWIOTLB
 	if (memblock_end_of_DRAM() > max) {
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_mds.c b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
index 973b3f4..074be05 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_mds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
@@ -52,6 +52,7 @@
 #include <asm/qe_ic.h>
 #include <asm/mpic.h>
 #include <asm/swiotlb.h>
+#include "smp.h"
 
 #undef DEBUG
 #ifdef DEBUG
@@ -154,10 +155,6 @@ static int mpc8568_mds_phy_fixups(struct phy_device *phydev)
  * Setup the architecture
  *
  */
-#ifdef CONFIG_SMP
-extern void __init mpc85xx_smp_init(void);
-#endif
-
 #ifdef CONFIG_QUICC_ENGINE
 static struct of_device_id mpc85xx_qe_ids[] __initdata = {
 	{ .type = "qe", },
@@ -382,9 +379,7 @@ static void __init mpc85xx_mds_setup_arch(void)
 	}
 #endif
 
-#ifdef CONFIG_SMP
 	mpc85xx_smp_init();
-#endif
 
 	mpc85xx_mds_qe_init();
 
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_rdb.c b/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
index f5ff911..cd49898 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
@@ -29,6 +29,7 @@
 
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
+#include "smp.h"
 
 #undef DEBUG
 
@@ -82,9 +83,6 @@ void __init mpc85xx_rdb_pic_init(void)
 /*
  * Setup the architecture
  */
-#ifdef CONFIG_SMP
-extern void __init mpc85xx_smp_init(void);
-#endif
 static void __init mpc85xx_rdb_setup_arch(void)
 {
 #ifdef CONFIG_PCI
@@ -102,10 +100,7 @@ static void __init mpc85xx_rdb_setup_arch(void)
 
 #endif
 
-#ifdef CONFIG_SMP
 	mpc85xx_smp_init();
-#endif
-
 	printk(KERN_INFO "MPC85xx RDB board from Freescale Semiconductor\n");
 }
 
diff --git a/arch/powerpc/platforms/85xx/p1022_ds.c b/arch/powerpc/platforms/85xx/p1022_ds.c
index 266b3aa..7e90e24 100644
--- a/arch/powerpc/platforms/85xx/p1022_ds.c
+++ b/arch/powerpc/platforms/85xx/p1022_ds.c
@@ -26,6 +26,7 @@
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
 #include <asm/fsl_guts.h>
+#include "smp.h"
 
 #if defined(CONFIG_FB_FSL_DIU) || defined(CONFIG_FB_FSL_DIU_MODULE)
 
@@ -265,10 +266,6 @@ void __init p1022_ds_pic_init(void)
 	mpic_init(mpic);
 }
 
-#ifdef CONFIG_SMP
-void __init mpc85xx_smp_init(void);
-#endif
-
 /*
  * Setup the architecture
  */
@@ -309,9 +306,7 @@ static void __init p1022_ds_setup_arch(void)
 	diu_ops.set_sysfs_monitor_port	= p1022ds_set_sysfs_monitor_port;
 #endif
 
-#ifdef CONFIG_SMP
 	mpc85xx_smp_init();
-#endif
 
 #ifdef CONFIG_SWIOTLB
 	if (memblock_end_of_DRAM() > max) {
diff --git a/arch/powerpc/platforms/85xx/p1023_rds.c b/arch/powerpc/platforms/85xx/p1023_rds.c
index 835e0b3..5ab21f3 100644
--- a/arch/powerpc/platforms/85xx/p1023_rds.c
+++ b/arch/powerpc/platforms/85xx/p1023_rds.c
@@ -30,6 +30,7 @@
 #include <asm/prom.h>
 #include <asm/udbg.h>
 #include <asm/mpic.h>
+#include "smp.h"
 
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
@@ -39,10 +40,6 @@
  * Setup the architecture
  *
  */
-#ifdef CONFIG_SMP
-void __init mpc85xx_smp_init(void);
-#endif
-
 static void __init mpc85xx_rds_setup_arch(void)
 {
 	struct device_node *np;
diff --git a/arch/powerpc/platforms/85xx/smp.c b/arch/powerpc/platforms/85xx/smp.c
index 5b9b901..4578112 100644
--- a/arch/powerpc/platforms/85xx/smp.c
+++ b/arch/powerpc/platforms/85xx/smp.c
@@ -27,6 +27,7 @@
 
 #include <sysdev/fsl_soc.h>
 #include <sysdev/mpic.h>
+#include "smp.h"
 
 extern void __early_start(void);
 
diff --git a/arch/powerpc/platforms/85xx/smp.h b/arch/powerpc/platforms/85xx/smp.h
new file mode 100644
index 0000000..e2b4493
--- /dev/null
+++ b/arch/powerpc/platforms/85xx/smp.h
@@ -0,0 +1,15 @@
+#ifndef POWERPC_85XX_SMP_H_
+#define POWERPC_85XX_SMP_H_ 1
+
+#include <linux/init.h>
+
+#ifdef CONFIG_SMP
+void __init mpc85xx_smp_init(void);
+#else
+static inline void mpc85xx_smp_init(void)
+{
+	/* Nothing to do */
+}
+#endif
+
+#endif /* not POWERPC_85XX_SMP_H_ */
diff --git a/arch/powerpc/platforms/85xx/xes_mpc85xx.c b/arch/powerpc/platforms/85xx/xes_mpc85xx.c
index a9dc5e7..ce3f660 100644
--- a/arch/powerpc/platforms/85xx/xes_mpc85xx.c
+++ b/arch/powerpc/platforms/85xx/xes_mpc85xx.c
@@ -32,6 +32,7 @@
 
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
+#include "smp.h"
 
 /* A few bit definitions needed for fixups on some boards */
 #define MPC85xx_L2CTL_L2E		0x80000000 /* L2 enable */
@@ -136,9 +137,6 @@ static int primary_phb_addr;
 /*
  * Setup the architecture
  */
-#ifdef CONFIG_SMP
-extern void __init mpc85xx_smp_init(void);
-#endif
 static void __init xes_mpc85xx_setup_arch(void)
 {
 #ifdef CONFIG_PCI
@@ -172,9 +170,7 @@ static void __init xes_mpc85xx_setup_arch(void)
 	}
 #endif
 
-#ifdef CONFIG_SMP
 	mpc85xx_smp_init();
-#endif
 }
 
 static struct of_device_id __initdata xes_mpc85xx_ids[] = {
-- 
1.7.2.5

^ permalink raw reply related

* [RFC PATCH 05/10] powerpc/mpic: Search for open-pic device-tree node if NULL
From: Kyle Moffett @ 2011-10-31 21:10 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev
  Cc: Milton Miller, Paul Mackerras, Kyle Moffett, Scott Wood,
	Thomas Gleixner
In-Reply-To: <1320095411-20667-1-git-send-email-Kyle.D.Moffett@boeing.com>

Almost all PowerPC platforms use a standard "open-pic" device node so
the mpic_alloc() function now accepts NULL for the device-node.  This
will cause it to perform a default search with of_find_matching_node().

Signed-off-by: Kyle Moffett <Kyle.D.Moffett@boeing.com>
---
 arch/powerpc/platforms/85xx/corenet_ds.c          |   10 +---------
 arch/powerpc/platforms/85xx/ksi8560.c             |   13 ++-----------
 arch/powerpc/platforms/85xx/mpc8536_ds.c          |   13 +------------
 arch/powerpc/platforms/85xx/mpc85xx_ads.c         |   12 ++----------
 arch/powerpc/platforms/85xx/mpc85xx_cds.c         |   15 +--------------
 arch/powerpc/platforms/85xx/mpc85xx_ds.c          |   14 +++-----------
 arch/powerpc/platforms/85xx/mpc85xx_mds.c         |   10 +---------
 arch/powerpc/platforms/85xx/mpc85xx_rdb.c         |   14 ++------------
 arch/powerpc/platforms/85xx/p1022_ds.c            |   14 +-------------
 arch/powerpc/platforms/85xx/sbc8548.c             |   16 +---------------
 arch/powerpc/platforms/85xx/sbc8560.c             |   13 ++-----------
 arch/powerpc/platforms/85xx/socrates.c            |   11 +----------
 arch/powerpc/platforms/85xx/stx_gp3.c             |   13 ++-----------
 arch/powerpc/platforms/85xx/tqm85xx.c             |   13 ++-----------
 arch/powerpc/platforms/85xx/xes_mpc85xx.c         |   13 +------------
 arch/powerpc/platforms/embedded6xx/holly.c        |   10 +---------
 arch/powerpc/platforms/embedded6xx/linkstation.c  |    8 ++------
 arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c |   10 +---------
 arch/powerpc/platforms/embedded6xx/storcenter.c   |   10 +---------
 arch/powerpc/sysdev/mpic.c                        |   19 +++++++++++++++++--
 20 files changed, 45 insertions(+), 206 deletions(-)

diff --git a/arch/powerpc/platforms/85xx/corenet_ds.c b/arch/powerpc/platforms/85xx/corenet_ds.c
index 7893ad3..134e1f8 100644
--- a/arch/powerpc/platforms/85xx/corenet_ds.c
+++ b/arch/powerpc/platforms/85xx/corenet_ds.c
@@ -36,21 +36,13 @@
 void __init corenet_ds_pic_init(void)
 {
 	struct mpic *mpic;
-	struct device_node *np = NULL;
 	unsigned int flags = MPIC_PRIMARY | MPIC_BIG_ENDIAN |
 				MPIC_BROKEN_FRR_NIRQS | MPIC_SINGLE_DEST_CPU;
 
-	np = of_find_node_by_type(np, "open-pic");
-
-	if (np == NULL) {
-		printk(KERN_ERR "Could not find open-pic node\n");
-		return;
-	}
-
 	if (ppc_md.get_irq == mpic_get_coreint_irq)
 		flags |= MPIC_ENABLE_COREINT;
 
-	mpic = mpic_alloc(np, 0, flags, 0, 256, " OpenPIC  ");
+	mpic = mpic_alloc(NULL, 0, flags, 0, 256, " OpenPIC  ");
 	BUG_ON(mpic == NULL);
 
 	mpic_init(mpic);
diff --git a/arch/powerpc/platforms/85xx/ksi8560.c b/arch/powerpc/platforms/85xx/ksi8560.c
index b20c07d..d49dbc4 100644
--- a/arch/powerpc/platforms/85xx/ksi8560.c
+++ b/arch/powerpc/platforms/85xx/ksi8560.c
@@ -68,24 +68,15 @@ static void cpm2_cascade(unsigned int irq, struct irq_desc *desc)
 static void __init ksi8560_pic_init(void)
 {
 	struct mpic *mpic;
-	struct device_node *np;
 #ifdef CONFIG_CPM2
+	struct device_node *np;
 	int irq;
 #endif
 
-	np = of_find_node_by_type(NULL, "open-pic");
-
-	if (np == NULL) {
-		printk(KERN_ERR "Could not find open-pic node\n");
-		return;
-	}
-
-	mpic = mpic_alloc(np, 0,
+	mpic = mpic_alloc(NULL, 0,
 			MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
 			0, 256, " OpenPIC  ");
 	BUG_ON(mpic == NULL);
-	of_node_put(np);
-
 	mpic_init(mpic);
 
 #ifdef CONFIG_CPM2
diff --git a/arch/powerpc/platforms/85xx/mpc8536_ds.c b/arch/powerpc/platforms/85xx/mpc8536_ds.c
index 03173ba..2c928f0 100644
--- a/arch/powerpc/platforms/85xx/mpc8536_ds.c
+++ b/arch/powerpc/platforms/85xx/mpc8536_ds.c
@@ -34,22 +34,11 @@
 
 void __init mpc8536_ds_pic_init(void)
 {
-	struct mpic *mpic;
-	struct device_node *np;
-
-	np = of_find_node_by_type(NULL, "open-pic");
-	if (np == NULL) {
-		printk(KERN_ERR "Could not find open-pic node\n");
-		return;
-	}
-
-	mpic = mpic_alloc(np, 0,
+	struct mpic *mpic = mpic_alloc(NULL, 0,
 			  MPIC_PRIMARY | MPIC_WANTS_RESET |
 			  MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS,
 			0, 256, " OpenPIC  ");
 	BUG_ON(mpic == NULL);
-	of_node_put(np);
-
 	mpic_init(mpic);
 }
 
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ads.c b/arch/powerpc/platforms/85xx/mpc85xx_ads.c
index 5cb797b..2b443ba 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_ads.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_ads.c
@@ -64,23 +64,15 @@ static void cpm2_cascade(unsigned int irq, struct irq_desc *desc)
 static void __init mpc85xx_ads_pic_init(void)
 {
 	struct mpic *mpic;
-	struct device_node *np = NULL;
 #ifdef CONFIG_CPM2
+	struct device_node *np = NULL;
 	int irq;
 #endif
 
-	np = of_find_node_by_type(np, "open-pic");
-	if (!np) {
-		printk(KERN_ERR "Could not find open-pic node\n");
-		return;
-	}
-
-	mpic = mpic_alloc(np, 0,
+	mpic = mpic_alloc(NULL, 0,
 			MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
 			0, 256, " OpenPIC  ");
 	BUG_ON(mpic == NULL);
-	of_node_put(np);
-
 	mpic_init(mpic);
 
 #ifdef CONFIG_CPM2
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_cds.c b/arch/powerpc/platforms/85xx/mpc85xx_cds.c
index 69c1d0a..3a2436b 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_cds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_cds.c
@@ -187,23 +187,10 @@ static struct irqaction mpc85xxcds_8259_irqaction = {
 static void __init mpc85xx_cds_pic_init(void)
 {
 	struct mpic *mpic;
-	struct device_node *np = NULL;
-
-	np = of_find_node_by_type(np, "open-pic");
-
-	if (np == NULL) {
-		printk(KERN_ERR "Could not find open-pic node\n");
-		return;
-	}
-
-	mpic = mpic_alloc(np, 0,
+	mpic = mpic_alloc(NULL, 0,
 			MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
 			0, 256, " OpenPIC  ");
 	BUG_ON(mpic == NULL);
-
-	/* Return the mpic node */
-	of_node_put(np);
-
 	mpic_init(mpic);
 }
 
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ds.c b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
index b608da7..14fccaf 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_ds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
@@ -61,27 +61,21 @@ static void mpc85xx_8259_cascade(unsigned int irq, struct irq_desc *desc)
 void __init mpc85xx_ds_pic_init(void)
 {
 	struct mpic *mpic;
-	struct device_node *np;
 #ifdef CONFIG_PPC_I8259
+	struct device_node *np;
 	struct device_node *cascade_node = NULL;
 	int cascade_irq;
 #endif
 	unsigned long root = of_get_flat_dt_root();
 
-	np = of_find_node_by_type(NULL, "open-pic");
-	if (np == NULL) {
-		printk(KERN_ERR "Could not find open-pic node\n");
-		return;
-	}
-
 	if (of_flat_dt_is_compatible(root, "fsl,MPC8572DS-CAMP")) {
-		mpic = mpic_alloc(np, 0,
+		mpic = mpic_alloc(NULL, 0,
 			MPIC_PRIMARY |
 			MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
 			MPIC_SINGLE_DEST_CPU,
 			0, 256, " OpenPIC  ");
 	} else {
-		mpic = mpic_alloc(np, 0,
+		mpic = mpic_alloc(NULL, 0,
 			  MPIC_PRIMARY | MPIC_WANTS_RESET |
 			  MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
 			  MPIC_SINGLE_DEST_CPU,
@@ -89,8 +83,6 @@ void __init mpc85xx_ds_pic_init(void)
 	}
 
 	BUG_ON(mpic == NULL);
-	of_node_put(np);
-
 	mpic_init(mpic);
 
 #ifdef CONFIG_PPC_I8259
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_mds.c b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
index 982f1a7..7ebd864 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_mds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
@@ -474,19 +474,11 @@ machine_arch_initcall(p1021_mds, swiotlb_setup_bus_notifier);
 
 static void __init mpc85xx_mds_pic_init(void)
 {
-	struct mpic *mpic;
-	struct device_node *np = NULL;
-
-	np = of_find_node_by_type(NULL, "open-pic");
-	if (!np)
-		return;
-
-	mpic = mpic_alloc(np, 0,
+	struct mpic *mpic = mpic_alloc(NULL, 0,
 			MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN |
 			MPIC_BROKEN_FRR_NIRQS | MPIC_SINGLE_DEST_CPU,
 			0, 256, " OpenPIC  ");
 	BUG_ON(mpic == NULL);
-	of_node_put(np);
 
 	mpic_init(mpic);
 	mpc85xx_mds_qeic_init();
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_rdb.c b/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
index 67bd1d4..9edb2b1 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
@@ -43,23 +43,16 @@
 void __init mpc85xx_rdb_pic_init(void)
 {
 	struct mpic *mpic;
-	struct device_node *np;
 	unsigned long root = of_get_flat_dt_root();
 
-	np = of_find_node_by_type(NULL, "open-pic");
-	if (np == NULL) {
-		printk(KERN_ERR "Could not find open-pic node\n");
-		return;
-	}
-
 	if (of_flat_dt_is_compatible(root, "fsl,MPC85XXRDB-CAMP")) {
-		mpic = mpic_alloc(np, 0,
+		mpic = mpic_alloc(NULL, 0,
 			MPIC_PRIMARY |
 			MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
 			MPIC_SINGLE_DEST_CPU,
 			0, 256, " OpenPIC  ");
 	} else {
-		mpic = mpic_alloc(np, 0,
+		mpic = mpic_alloc(NULL, 0,
 		  MPIC_PRIMARY | MPIC_WANTS_RESET |
 		  MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
 		  MPIC_SINGLE_DEST_CPU,
@@ -67,10 +60,7 @@ void __init mpc85xx_rdb_pic_init(void)
 	}
 
 	BUG_ON(mpic == NULL);
-	of_node_put(np);
-
 	mpic_init(mpic);
-
 }
 
 /*
diff --git a/arch/powerpc/platforms/85xx/p1022_ds.c b/arch/powerpc/platforms/85xx/p1022_ds.c
index d911aca..4279e83 100644
--- a/arch/powerpc/platforms/85xx/p1022_ds.c
+++ b/arch/powerpc/platforms/85xx/p1022_ds.c
@@ -238,24 +238,12 @@ int p1022ds_set_sysfs_monitor_port(int val)
 
 void __init p1022_ds_pic_init(void)
 {
-	struct mpic *mpic;
-	struct device_node *np;
-
-	np = of_find_node_by_type(NULL, "open-pic");
-	if (!np) {
-		pr_err("Could not find open-pic node\n");
-		return;
-	}
-
-	mpic = mpic_alloc(np, 0,
+	struct mpic *mpic = mpic_alloc(NULL, 0,
 		MPIC_PRIMARY | MPIC_WANTS_RESET |
 		MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
 		MPIC_SINGLE_DEST_CPU,
 		0, 256, " OpenPIC  ");
-
 	BUG_ON(mpic == NULL);
-	of_node_put(np);
-
 	mpic_init(mpic);
 }
 
diff --git a/arch/powerpc/platforms/85xx/sbc8548.c b/arch/powerpc/platforms/85xx/sbc8548.c
index daced7d..1b5597f 100644
--- a/arch/powerpc/platforms/85xx/sbc8548.c
+++ b/arch/powerpc/platforms/85xx/sbc8548.c
@@ -53,24 +53,10 @@ static int sbc_rev;
 
 static void __init sbc8548_pic_init(void)
 {
-	struct mpic *mpic;
-	struct device_node *np = NULL;
-
-	np = of_find_node_by_type(np, "open-pic");
-
-	if (np == NULL) {
-		printk(KERN_ERR "Could not find open-pic node\n");
-		return;
-	}
-
-	mpic = mpic_alloc(np, 0,
+	struct mpic *mpic = mpic_alloc(NULL, 0,
 			MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
 			0, 256, " OpenPIC  ");
 	BUG_ON(mpic == NULL);
-
-	/* Return the mpic node */
-	of_node_put(np);
-
 	mpic_init(mpic);
 }
 
diff --git a/arch/powerpc/platforms/85xx/sbc8560.c b/arch/powerpc/platforms/85xx/sbc8560.c
index bd8b6c9..20e68bb 100644
--- a/arch/powerpc/platforms/85xx/sbc8560.c
+++ b/arch/powerpc/platforms/85xx/sbc8560.c
@@ -54,24 +54,15 @@ static void cpm2_cascade(unsigned int irq, struct irq_desc *desc)
 
 static void __init sbc8560_pic_init(void)
 {
-	struct mpic *mpic;
-	struct device_node *np = NULL;
 #ifdef CONFIG_CPM2
+	struct device_node *np = NULL;
 	int irq;
 #endif
 
-	np = of_find_node_by_type(np, "open-pic");
-	if (!np) {
-		printk(KERN_ERR "Could not find open-pic node\n");
-		return;
-	}
-
-	mpic = mpic_alloc(np, 0,
+	struct mpic *mpic = mpic_alloc(NULL, 0,
 			MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
 			0, 256, " OpenPIC  ");
 	BUG_ON(mpic == NULL);
-	of_node_put(np);
-
 	mpic_init(mpic);
 
 #ifdef CONFIG_CPM2
diff --git a/arch/powerpc/platforms/85xx/socrates.c b/arch/powerpc/platforms/85xx/socrates.c
index fb4bfd6..a9a45f6 100644
--- a/arch/powerpc/platforms/85xx/socrates.c
+++ b/arch/powerpc/platforms/85xx/socrates.c
@@ -45,21 +45,12 @@
 
 static void __init socrates_pic_init(void)
 {
-	struct mpic *mpic;
 	struct device_node *np;
 
-	np = of_find_node_by_type(NULL, "open-pic");
-	if (!np) {
-		printk(KERN_ERR "Could not find open-pic node\n");
-		return;
-	}
-
-	mpic = mpic_alloc(np, 0,
+	struct mpic *mpic = mpic_alloc(NULL, 0,
 			MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
 			0, 256, " OpenPIC  ");
 	BUG_ON(mpic == NULL);
-	of_node_put(np);
-
 	mpic_init(mpic);
 
 	np = of_find_compatible_node(NULL, NULL, "abb,socrates-fpga-pic");
diff --git a/arch/powerpc/platforms/85xx/stx_gp3.c b/arch/powerpc/platforms/85xx/stx_gp3.c
index 78aef45..55e941b 100644
--- a/arch/powerpc/platforms/85xx/stx_gp3.c
+++ b/arch/powerpc/platforms/85xx/stx_gp3.c
@@ -58,24 +58,15 @@ static void cpm2_cascade(unsigned int irq, struct irq_desc *desc)
 
 static void __init stx_gp3_pic_init(void)
 {
-	struct mpic *mpic;
-	struct device_node *np;
 #ifdef CONFIG_CPM2
+	struct device_node *np;
 	int irq;
 #endif
 
-	np = of_find_node_by_type(NULL, "open-pic");
-	if (!np) {
-		printk(KERN_ERR "Could not find open-pic node\n");
-		return;
-	}
-
-	mpic = mpic_alloc(np, 0,
+	struct mpic *mpic = mpic_alloc(NULL, 0,
 			MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
 			0, 256, " OpenPIC  ");
 	BUG_ON(mpic == NULL);
-	of_node_put(np);
-
 	mpic_init(mpic);
 
 #ifdef CONFIG_CPM2
diff --git a/arch/powerpc/platforms/85xx/tqm85xx.c b/arch/powerpc/platforms/85xx/tqm85xx.c
index 5775f4c..660769b 100644
--- a/arch/powerpc/platforms/85xx/tqm85xx.c
+++ b/arch/powerpc/platforms/85xx/tqm85xx.c
@@ -56,24 +56,15 @@ static void cpm2_cascade(unsigned int irq, struct irq_desc *desc)
 
 static void __init tqm85xx_pic_init(void)
 {
-	struct mpic *mpic;
-	struct device_node *np;
 #ifdef CONFIG_CPM2
+	struct device_node *np;
 	int irq;
 #endif
 
-	np = of_find_node_by_type(NULL, "open-pic");
-	if (!np) {
-		printk(KERN_ERR "Could not find open-pic node\n");
-		return;
-	}
-
-	mpic = mpic_alloc(np, 0,
+	struct mpic *mpic = mpic_alloc(NULL, 0,
 			MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
 			0, 256, " OpenPIC  ");
 	BUG_ON(mpic == NULL);
-	of_node_put(np);
-
 	mpic_init(mpic);
 
 #ifdef CONFIG_CPM2
diff --git a/arch/powerpc/platforms/85xx/xes_mpc85xx.c b/arch/powerpc/platforms/85xx/xes_mpc85xx.c
index fccf9aa..09b8ba0 100644
--- a/arch/powerpc/platforms/85xx/xes_mpc85xx.c
+++ b/arch/powerpc/platforms/85xx/xes_mpc85xx.c
@@ -41,22 +41,11 @@
 
 void __init xes_mpc85xx_pic_init(void)
 {
-	struct mpic *mpic;
-	struct device_node *np;
-
-	np = of_find_node_by_type(NULL, "open-pic");
-	if (np == NULL) {
-		printk(KERN_ERR "Could not find open-pic node\n");
-		return;
-	}
-
-	mpic = mpic_alloc(np, 0,
+	struct mpic *mpic = mpic_alloc(np, 0,
 			  MPIC_PRIMARY | MPIC_WANTS_RESET |
 			  MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS,
 			0, 256, " OpenPIC  ");
 	BUG_ON(mpic == NULL);
-	of_node_put(np);
-
 	mpic_init(mpic);
 }
 
diff --git a/arch/powerpc/platforms/embedded6xx/holly.c b/arch/powerpc/platforms/embedded6xx/holly.c
index 80b2e2a..edfc84f 100644
--- a/arch/powerpc/platforms/embedded6xx/holly.c
+++ b/arch/powerpc/platforms/embedded6xx/holly.c
@@ -147,20 +147,13 @@ static void __init holly_setup_arch(void)
 static void __init holly_init_IRQ(void)
 {
 	struct mpic *mpic;
-	struct device_node *tsi_pic;
 #ifdef CONFIG_PCI
 	unsigned int cascade_pci_irq;
 	struct device_node *tsi_pci;
 	struct device_node *cascade_node = NULL;
 #endif
 
-	tsi_pic = of_find_node_by_type(NULL, "open-pic");
-	if (!tsi_pic) {
-		printk(KERN_ERR "%s: No tsi108 PIC found !\n", __func__);
-		return;
-	}
-
-	mpic = mpic_alloc(tsi_pic, 0,
+	mpic = mpic_alloc(NULL, 0,
 			MPIC_PRIMARY | MPIC_BIG_ENDIAN | MPIC_WANTS_RESET |
 			MPIC_SPV_EOI | MPIC_NO_PTHROU_DIS | MPIC_REGSET_TSI108,
 			24,
@@ -194,7 +187,6 @@ static void __init holly_init_IRQ(void)
 #endif
 	/* Configure MPIC outputs to CPU0 */
 	tsi108_write_reg(TSI108_MPIC_OFFSET + 0x30c, 0);
-	of_node_put(tsi_pic);
 }
 
 void holly_show_cpuinfo(struct seq_file *m)
diff --git a/arch/powerpc/platforms/embedded6xx/linkstation.c b/arch/powerpc/platforms/embedded6xx/linkstation.c
index 72b3685..502ff60 100644
--- a/arch/powerpc/platforms/embedded6xx/linkstation.c
+++ b/arch/powerpc/platforms/embedded6xx/linkstation.c
@@ -81,13 +81,9 @@ static void __init linkstation_setup_arch(void)
 static void __init linkstation_init_IRQ(void)
 {
 	struct mpic *mpic;
-	struct device_node *dnp;
 
-	dnp = of_find_node_by_type(NULL, "open-pic");
-	if (dnp == NULL)
-		return;
-
-	mpic = mpic_alloc(dnp, 0, MPIC_PRIMARY | MPIC_WANTS_RESET, 4, 32, " EPIC     ");
+	mpic = mpic_alloc(NULL, 0, MPIC_PRIMARY | MPIC_WANTS_RESET,
+			4, 32, " EPIC     ");
 	BUG_ON(mpic == NULL);
 
 	/* PCI IRQs */
diff --git a/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c b/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c
index 28082f9..1dd976e 100644
--- a/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c
+++ b/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c
@@ -101,20 +101,13 @@ static void __init mpc7448_hpc2_setup_arch(void)
 static void __init mpc7448_hpc2_init_IRQ(void)
 {
 	struct mpic *mpic;
-	struct device_node *tsi_pic;
 #ifdef CONFIG_PCI
 	unsigned int cascade_pci_irq;
 	struct device_node *tsi_pci;
 	struct device_node *cascade_node = NULL;
 #endif
 
-	tsi_pic = of_find_node_by_type(NULL, "open-pic");
-	if (!tsi_pic) {
-		printk("%s: No tsi108 PIC found !\n", __func__);
-		return;
-	}
-
-	mpic = mpic_alloc(tsi_pic, 0,
+	mpic = mpic_alloc(NULL, 0,
 			MPIC_PRIMARY | MPIC_BIG_ENDIAN | MPIC_WANTS_RESET |
 			MPIC_SPV_EOI | MPIC_NO_PTHROU_DIS | MPIC_REGSET_TSI108,
 			24,
@@ -148,7 +141,6 @@ static void __init mpc7448_hpc2_init_IRQ(void)
 #endif
 	/* Configure MPIC outputs to CPU0 */
 	tsi108_write_reg(TSI108_MPIC_OFFSET + 0x30c, 0);
-	of_node_put(tsi_pic);
 }
 
 void mpc7448_hpc2_show_cpuinfo(struct seq_file *m)
diff --git a/arch/powerpc/platforms/embedded6xx/storcenter.c b/arch/powerpc/platforms/embedded6xx/storcenter.c
index 797870f..a233d91 100644
--- a/arch/powerpc/platforms/embedded6xx/storcenter.c
+++ b/arch/powerpc/platforms/embedded6xx/storcenter.c
@@ -83,17 +83,9 @@ static void __init storcenter_setup_arch(void)
 static void __init storcenter_init_IRQ(void)
 {
 	struct mpic *mpic;
-	struct device_node *dnp;
 
-	dnp = of_find_node_by_type(NULL, "open-pic");
-	if (dnp == NULL)
-		return;
-
-	mpic = mpic_alloc(dnp, 0, MPIC_PRIMARY | MPIC_WANTS_RESET,
+	mpic = mpic_alloc(NULL, 0, MPIC_PRIMARY | MPIC_WANTS_RESET,
 			16, 32, " OpenPIC  ");
-
-	of_node_put(dnp);
-
 	BUG_ON(mpic == NULL);
 
 	/*
diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
index 0ad7bf2..548ca16 100644
--- a/arch/powerpc/sysdev/mpic.c
+++ b/arch/powerpc/sysdev/mpic.c
@@ -1145,8 +1145,23 @@ struct mpic * __init mpic_alloc(struct device_node *node,
 	const char *vers;
 	const u32 *psrc;
 
-	/* This code assumes that a non-NULL device node is passed in */
-	BUG_ON(!node);
+	/* Default MPIC search parameters */
+	static const struct of_device_id __initconst mpic_device_id[] = {
+		{ .type	      = "open-pic", },
+		{ .compatible = "open-pic", },
+		{},
+	};
+
+	/*
+	 * If we were not passed a device-tree node, then perform the default
+	 * search for standardized a standardized OpenPIC.
+	 */
+	if (!node)
+		node = of_find_matching_node(NULL, mpic_device_id);
+
+	/* Make sure we got *something* */
+	if (!node)
+		return NULL;
 
 	/* Pick the physical address from the device tree if unspecified */
 	if (!phys_addr) {
-- 
1.7.2.5

^ permalink raw reply related

* [RFC PATCH 06/10] powerpc/mpic: Invert the meaning of MPIC_PRIMARY
From: Kyle Moffett @ 2011-10-31 21:10 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev
  Cc: Thomas Gleixner, cbe-oss-dev, Lennert Buytenhek, Arnd Bergmann,
	Dmitry Eremin-Solenikov, Brian King, Milton Miller, Scott Wood,
	Paul Mackerras, Anton Blanchard, Kyle Moffett, Olof Johansson,
	Nishanth Aravamudan
In-Reply-To: <1320095411-20667-1-git-send-email-Kyle.D.Moffett@boeing.com>

It turns out that there are only 2 in-tree platforms which use MPICs
which are not "primary":  IBM Cell and PowerMac.  To reduce the
complexity of the typical board setup code, invert the MPIC_PRIMARY bit
into MPIC_SECONDARY.

Signed-off-by: Kyle Moffett <Kyle.D.Moffett@boeing.com>
---
 arch/powerpc/include/asm/mpic.h                   |    8 ++++----
 arch/powerpc/platforms/44x/iss4xx.c               |    2 +-
 arch/powerpc/platforms/85xx/corenet_ds.c          |    2 +-
 arch/powerpc/platforms/85xx/ksi8560.c             |    2 +-
 arch/powerpc/platforms/85xx/mpc8536_ds.c          |    2 +-
 arch/powerpc/platforms/85xx/mpc85xx_ads.c         |    3 +--
 arch/powerpc/platforms/85xx/mpc85xx_cds.c         |    2 +-
 arch/powerpc/platforms/85xx/mpc85xx_ds.c          |    3 +--
 arch/powerpc/platforms/85xx/mpc85xx_mds.c         |    2 +-
 arch/powerpc/platforms/85xx/mpc85xx_rdb.c         |    3 +--
 arch/powerpc/platforms/85xx/p1010rdb.c            |    2 +-
 arch/powerpc/platforms/85xx/p1022_ds.c            |    2 +-
 arch/powerpc/platforms/85xx/p1023_rds.c           |    2 +-
 arch/powerpc/platforms/85xx/sbc8548.c             |    2 +-
 arch/powerpc/platforms/85xx/sbc8560.c             |    2 +-
 arch/powerpc/platforms/85xx/socrates.c            |    2 +-
 arch/powerpc/platforms/85xx/stx_gp3.c             |    2 +-
 arch/powerpc/platforms/85xx/tqm85xx.c             |    2 +-
 arch/powerpc/platforms/85xx/xes_mpc85xx.c         |    2 +-
 arch/powerpc/platforms/86xx/pic.c                 |    2 +-
 arch/powerpc/platforms/cell/setup.c               |    2 +-
 arch/powerpc/platforms/chrp/setup.c               |    3 +--
 arch/powerpc/platforms/embedded6xx/holly.c        |    2 +-
 arch/powerpc/platforms/embedded6xx/linkstation.c  |    2 +-
 arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c |    2 +-
 arch/powerpc/platforms/embedded6xx/storcenter.c   |    2 +-
 arch/powerpc/platforms/maple/setup.c              |    2 +-
 arch/powerpc/platforms/pasemi/setup.c             |    2 +-
 arch/powerpc/platforms/powermac/pic.c             |    2 +-
 arch/powerpc/platforms/pseries/setup.c            |    3 +--
 arch/powerpc/sysdev/mpic.c                        |   14 +++++++-------
 31 files changed, 40 insertions(+), 45 deletions(-)

diff --git a/arch/powerpc/include/asm/mpic.h b/arch/powerpc/include/asm/mpic.h
index 49bab41..a241076 100644
--- a/arch/powerpc/include/asm/mpic.h
+++ b/arch/powerpc/include/asm/mpic.h
@@ -336,11 +336,11 @@ struct mpic
  * Note setting any ID (leaving those bits to 0) means standard MPIC
  */
 
-/* This is the primary controller, only that one has IPIs and
- * has afinity control. A non-primary MPIC always uses CPU0
- * registers only
+/*
+ * This is a secondary ("chained") controller; it only uses the CPU0
+ * registers.  Primary controllers have IPIs and affinity control.
  */
-#define MPIC_PRIMARY			0x00000001
+#define MPIC_SECONDARY			0x00000001
 
 /* Set this for a big-endian MPIC */
 #define MPIC_BIG_ENDIAN			0x00000002
diff --git a/arch/powerpc/platforms/44x/iss4xx.c b/arch/powerpc/platforms/44x/iss4xx.c
index 19395f1..5b8cdbb 100644
--- a/arch/powerpc/platforms/44x/iss4xx.c
+++ b/arch/powerpc/platforms/44x/iss4xx.c
@@ -71,7 +71,7 @@ static void __init iss4xx_init_irq(void)
 		/* The MPIC driver will get everything it needs from the
 		 * device-tree, just pass 0 to all arguments
 		 */
-		struct mpic *mpic = mpic_alloc(np, 0, MPIC_PRIMARY, 0, 0,
+		struct mpic *mpic = mpic_alloc(np, 0, 0, 0, 0,
 					       " MPIC     ");
 		BUG_ON(mpic == NULL);
 		mpic_init(mpic);
diff --git a/arch/powerpc/platforms/85xx/corenet_ds.c b/arch/powerpc/platforms/85xx/corenet_ds.c
index 134e1f8..7b737a9 100644
--- a/arch/powerpc/platforms/85xx/corenet_ds.c
+++ b/arch/powerpc/platforms/85xx/corenet_ds.c
@@ -36,7 +36,7 @@
 void __init corenet_ds_pic_init(void)
 {
 	struct mpic *mpic;
-	unsigned int flags = MPIC_PRIMARY | MPIC_BIG_ENDIAN |
+	unsigned int flags = MPIC_BIG_ENDIAN |
 				MPIC_BROKEN_FRR_NIRQS | MPIC_SINGLE_DEST_CPU;
 
 	if (ppc_md.get_irq == mpic_get_coreint_irq)
diff --git a/arch/powerpc/platforms/85xx/ksi8560.c b/arch/powerpc/platforms/85xx/ksi8560.c
index d49dbc4..278962b 100644
--- a/arch/powerpc/platforms/85xx/ksi8560.c
+++ b/arch/powerpc/platforms/85xx/ksi8560.c
@@ -74,7 +74,7 @@ static void __init ksi8560_pic_init(void)
 #endif
 
 	mpic = mpic_alloc(NULL, 0,
-			MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
+			MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
 			0, 256, " OpenPIC  ");
 	BUG_ON(mpic == NULL);
 	mpic_init(mpic);
diff --git a/arch/powerpc/platforms/85xx/mpc8536_ds.c b/arch/powerpc/platforms/85xx/mpc8536_ds.c
index 2c928f0..d1aece5 100644
--- a/arch/powerpc/platforms/85xx/mpc8536_ds.c
+++ b/arch/powerpc/platforms/85xx/mpc8536_ds.c
@@ -35,7 +35,7 @@
 void __init mpc8536_ds_pic_init(void)
 {
 	struct mpic *mpic = mpic_alloc(NULL, 0,
-			  MPIC_PRIMARY | MPIC_WANTS_RESET |
+			  MPIC_WANTS_RESET |
 			  MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS,
 			0, 256, " OpenPIC  ");
 	BUG_ON(mpic == NULL);
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ads.c b/arch/powerpc/platforms/85xx/mpc85xx_ads.c
index 2b443ba..65a3de4 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_ads.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_ads.c
@@ -69,8 +69,7 @@ static void __init mpc85xx_ads_pic_init(void)
 	int irq;
 #endif
 
-	mpic = mpic_alloc(NULL, 0,
-			MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
+	mpic = mpic_alloc(NULL, 0, MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
 			0, 256, " OpenPIC  ");
 	BUG_ON(mpic == NULL);
 	mpic_init(mpic);
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_cds.c b/arch/powerpc/platforms/85xx/mpc85xx_cds.c
index 3a2436b..081821d 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_cds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_cds.c
@@ -188,7 +188,7 @@ static void __init mpc85xx_cds_pic_init(void)
 {
 	struct mpic *mpic;
 	mpic = mpic_alloc(NULL, 0,
-			MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
+			MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
 			0, 256, " OpenPIC  ");
 	BUG_ON(mpic == NULL);
 	mpic_init(mpic);
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ds.c b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
index 14fccaf..5298137 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_ds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
@@ -70,13 +70,12 @@ void __init mpc85xx_ds_pic_init(void)
 
 	if (of_flat_dt_is_compatible(root, "fsl,MPC8572DS-CAMP")) {
 		mpic = mpic_alloc(NULL, 0,
-			MPIC_PRIMARY |
 			MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
 			MPIC_SINGLE_DEST_CPU,
 			0, 256, " OpenPIC  ");
 	} else {
 		mpic = mpic_alloc(NULL, 0,
-			  MPIC_PRIMARY | MPIC_WANTS_RESET |
+			  MPIC_WANTS_RESET |
 			  MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
 			  MPIC_SINGLE_DEST_CPU,
 			0, 256, " OpenPIC  ");
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_mds.c b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
index 7ebd864..b7d9636 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_mds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
@@ -475,7 +475,7 @@ machine_arch_initcall(p1021_mds, swiotlb_setup_bus_notifier);
 static void __init mpc85xx_mds_pic_init(void)
 {
 	struct mpic *mpic = mpic_alloc(NULL, 0,
-			MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN |
+			MPIC_WANTS_RESET | MPIC_BIG_ENDIAN |
 			MPIC_BROKEN_FRR_NIRQS | MPIC_SINGLE_DEST_CPU,
 			0, 256, " OpenPIC  ");
 	BUG_ON(mpic == NULL);
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_rdb.c b/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
index 9edb2b1..a3cf5d1 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
@@ -47,13 +47,12 @@ void __init mpc85xx_rdb_pic_init(void)
 
 	if (of_flat_dt_is_compatible(root, "fsl,MPC85XXRDB-CAMP")) {
 		mpic = mpic_alloc(NULL, 0,
-			MPIC_PRIMARY |
 			MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
 			MPIC_SINGLE_DEST_CPU,
 			0, 256, " OpenPIC  ");
 	} else {
 		mpic = mpic_alloc(NULL, 0,
-		  MPIC_PRIMARY | MPIC_WANTS_RESET |
+		  MPIC_WANTS_RESET |
 		  MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
 		  MPIC_SINGLE_DEST_CPU,
 		  0, 256, " OpenPIC  ");
diff --git a/arch/powerpc/platforms/85xx/p1010rdb.c b/arch/powerpc/platforms/85xx/p1010rdb.c
index 5ffca27..f6c3ffc 100644
--- a/arch/powerpc/platforms/85xx/p1010rdb.c
+++ b/arch/powerpc/platforms/85xx/p1010rdb.c
@@ -39,7 +39,7 @@ void __init p1010_rdb_pic_init(void)
 		return;
 	}
 
-	mpic = mpic_alloc(np, NULL, MPIC_PRIMARY | MPIC_WANTS_RESET |
+	mpic = mpic_alloc(np, NULL, MPIC_WANTS_RESET |
 	  MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS | MPIC_SINGLE_DEST_CPU,
 	  0, 256, " OpenPIC  ");
 
diff --git a/arch/powerpc/platforms/85xx/p1022_ds.c b/arch/powerpc/platforms/85xx/p1022_ds.c
index 4279e83..73e79ba 100644
--- a/arch/powerpc/platforms/85xx/p1022_ds.c
+++ b/arch/powerpc/platforms/85xx/p1022_ds.c
@@ -239,7 +239,7 @@ int p1022ds_set_sysfs_monitor_port(int val)
 void __init p1022_ds_pic_init(void)
 {
 	struct mpic *mpic = mpic_alloc(NULL, 0,
-		MPIC_PRIMARY | MPIC_WANTS_RESET |
+		MPIC_WANTS_RESET |
 		MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
 		MPIC_SINGLE_DEST_CPU,
 		0, 256, " OpenPIC  ");
diff --git a/arch/powerpc/platforms/85xx/p1023_rds.c b/arch/powerpc/platforms/85xx/p1023_rds.c
index 30a5adb..1a916eb 100644
--- a/arch/powerpc/platforms/85xx/p1023_rds.c
+++ b/arch/powerpc/platforms/85xx/p1023_rds.c
@@ -118,7 +118,7 @@ static void __init mpc85xx_rds_pic_init(void)
 	}
 
 	mpic = mpic_alloc(np, NULL,
-		MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN |
+		MPIC_WANTS_RESET | MPIC_BIG_ENDIAN |
 		MPIC_BROKEN_FRR_NIRQS | MPIC_SINGLE_DEST_CPU,
 		0, 256, " OpenPIC  ");
 
diff --git a/arch/powerpc/platforms/85xx/sbc8548.c b/arch/powerpc/platforms/85xx/sbc8548.c
index 1b5597f..bf8b8ff 100644
--- a/arch/powerpc/platforms/85xx/sbc8548.c
+++ b/arch/powerpc/platforms/85xx/sbc8548.c
@@ -54,7 +54,7 @@ static int sbc_rev;
 static void __init sbc8548_pic_init(void)
 {
 	struct mpic *mpic = mpic_alloc(NULL, 0,
-			MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
+			MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
 			0, 256, " OpenPIC  ");
 	BUG_ON(mpic == NULL);
 	mpic_init(mpic);
diff --git a/arch/powerpc/platforms/85xx/sbc8560.c b/arch/powerpc/platforms/85xx/sbc8560.c
index 20e68bb..7a43fb4 100644
--- a/arch/powerpc/platforms/85xx/sbc8560.c
+++ b/arch/powerpc/platforms/85xx/sbc8560.c
@@ -60,7 +60,7 @@ static void __init sbc8560_pic_init(void)
 #endif
 
 	struct mpic *mpic = mpic_alloc(NULL, 0,
-			MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
+			MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
 			0, 256, " OpenPIC  ");
 	BUG_ON(mpic == NULL);
 	mpic_init(mpic);
diff --git a/arch/powerpc/platforms/85xx/socrates.c b/arch/powerpc/platforms/85xx/socrates.c
index a9a45f6..94bd256 100644
--- a/arch/powerpc/platforms/85xx/socrates.c
+++ b/arch/powerpc/platforms/85xx/socrates.c
@@ -48,7 +48,7 @@ static void __init socrates_pic_init(void)
 	struct device_node *np;
 
 	struct mpic *mpic = mpic_alloc(NULL, 0,
-			MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
+			MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
 			0, 256, " OpenPIC  ");
 	BUG_ON(mpic == NULL);
 	mpic_init(mpic);
diff --git a/arch/powerpc/platforms/85xx/stx_gp3.c b/arch/powerpc/platforms/85xx/stx_gp3.c
index 55e941b..e0c88b3 100644
--- a/arch/powerpc/platforms/85xx/stx_gp3.c
+++ b/arch/powerpc/platforms/85xx/stx_gp3.c
@@ -64,7 +64,7 @@ static void __init stx_gp3_pic_init(void)
 #endif
 
 	struct mpic *mpic = mpic_alloc(NULL, 0,
-			MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
+			MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
 			0, 256, " OpenPIC  ");
 	BUG_ON(mpic == NULL);
 	mpic_init(mpic);
diff --git a/arch/powerpc/platforms/85xx/tqm85xx.c b/arch/powerpc/platforms/85xx/tqm85xx.c
index 660769b..2f6479a 100644
--- a/arch/powerpc/platforms/85xx/tqm85xx.c
+++ b/arch/powerpc/platforms/85xx/tqm85xx.c
@@ -62,7 +62,7 @@ static void __init tqm85xx_pic_init(void)
 #endif
 
 	struct mpic *mpic = mpic_alloc(NULL, 0,
-			MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
+			MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
 			0, 256, " OpenPIC  ");
 	BUG_ON(mpic == NULL);
 	mpic_init(mpic);
diff --git a/arch/powerpc/platforms/85xx/xes_mpc85xx.c b/arch/powerpc/platforms/85xx/xes_mpc85xx.c
index 09b8ba0..d95e765 100644
--- a/arch/powerpc/platforms/85xx/xes_mpc85xx.c
+++ b/arch/powerpc/platforms/85xx/xes_mpc85xx.c
@@ -42,7 +42,7 @@
 void __init xes_mpc85xx_pic_init(void)
 {
 	struct mpic *mpic = mpic_alloc(np, 0,
-			  MPIC_PRIMARY | MPIC_WANTS_RESET |
+			  MPIC_WANTS_RESET |
 			  MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS,
 			0, 256, " OpenPIC  ");
 	BUG_ON(mpic == NULL);
diff --git a/arch/powerpc/platforms/86xx/pic.c b/arch/powerpc/platforms/86xx/pic.c
index f85c8f0..78e50c9 100644
--- a/arch/powerpc/platforms/86xx/pic.c
+++ b/arch/powerpc/platforms/86xx/pic.c
@@ -44,7 +44,7 @@ void __init mpc86xx_init_irq(void)
 		return;
 
 	mpic = mpic_alloc(np, 0,
-			MPIC_PRIMARY | MPIC_WANTS_RESET |
+			MPIC_WANTS_RESET |
 			MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
 			MPIC_SINGLE_DEST_CPU,
 			0, 256, " MPIC     ");
diff --git a/arch/powerpc/platforms/cell/setup.c b/arch/powerpc/platforms/cell/setup.c
index c73cf4c..392cbdb 100644
--- a/arch/powerpc/platforms/cell/setup.c
+++ b/arch/powerpc/platforms/cell/setup.c
@@ -210,7 +210,7 @@ static void __init mpic_init_IRQ(void)
 		/* The MPIC driver will get everything it needs from the
 		 * device-tree, just pass 0 to all arguments
 		 */
-		mpic = mpic_alloc(dn, 0, 0, 0, 0, " MPIC     ");
+		mpic = mpic_alloc(dn, 0, MPIC_SECONDARY, 0, 0, " MPIC     ");
 		if (mpic == NULL)
 			continue;
 		mpic_init(mpic);
diff --git a/arch/powerpc/platforms/chrp/setup.c b/arch/powerpc/platforms/chrp/setup.c
index 1227864..f1f17bb 100644
--- a/arch/powerpc/platforms/chrp/setup.c
+++ b/arch/powerpc/platforms/chrp/setup.c
@@ -435,8 +435,7 @@ static void __init chrp_find_openpic(void)
 	if (len > 1)
 		isu_size = iranges[3];
 
-	chrp_mpic = mpic_alloc(np, opaddr, MPIC_PRIMARY,
-			       isu_size, 0, " MPIC    ");
+	chrp_mpic = mpic_alloc(np, opaddr, 0, isu_size, 0, " MPIC    ");
 	if (chrp_mpic == NULL) {
 		printk(KERN_ERR "Failed to allocate MPIC structure\n");
 		goto bail;
diff --git a/arch/powerpc/platforms/embedded6xx/holly.c b/arch/powerpc/platforms/embedded6xx/holly.c
index edfc84f..e8c1429 100644
--- a/arch/powerpc/platforms/embedded6xx/holly.c
+++ b/arch/powerpc/platforms/embedded6xx/holly.c
@@ -154,7 +154,7 @@ static void __init holly_init_IRQ(void)
 #endif
 
 	mpic = mpic_alloc(NULL, 0,
-			MPIC_PRIMARY | MPIC_BIG_ENDIAN | MPIC_WANTS_RESET |
+			MPIC_BIG_ENDIAN | MPIC_WANTS_RESET |
 			MPIC_SPV_EOI | MPIC_NO_PTHROU_DIS | MPIC_REGSET_TSI108,
 			24,
 			NR_IRQS-4, /* num_sources used */
diff --git a/arch/powerpc/platforms/embedded6xx/linkstation.c b/arch/powerpc/platforms/embedded6xx/linkstation.c
index 502ff60..bcfad92 100644
--- a/arch/powerpc/platforms/embedded6xx/linkstation.c
+++ b/arch/powerpc/platforms/embedded6xx/linkstation.c
@@ -82,7 +82,7 @@ static void __init linkstation_init_IRQ(void)
 {
 	struct mpic *mpic;
 
-	mpic = mpic_alloc(NULL, 0, MPIC_PRIMARY | MPIC_WANTS_RESET,
+	mpic = mpic_alloc(NULL, 0, MPIC_WANTS_RESET,
 			4, 32, " EPIC     ");
 	BUG_ON(mpic == NULL);
 
diff --git a/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c b/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c
index 1dd976e..32376b5 100644
--- a/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c
+++ b/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c
@@ -108,7 +108,7 @@ static void __init mpc7448_hpc2_init_IRQ(void)
 #endif
 
 	mpic = mpic_alloc(NULL, 0,
-			MPIC_PRIMARY | MPIC_BIG_ENDIAN | MPIC_WANTS_RESET |
+			MPIC_BIG_ENDIAN | MPIC_WANTS_RESET |
 			MPIC_SPV_EOI | MPIC_NO_PTHROU_DIS | MPIC_REGSET_TSI108,
 			24,
 			NR_IRQS-4, /* num_sources used */
diff --git a/arch/powerpc/platforms/embedded6xx/storcenter.c b/arch/powerpc/platforms/embedded6xx/storcenter.c
index a233d91..6b3fffe 100644
--- a/arch/powerpc/platforms/embedded6xx/storcenter.c
+++ b/arch/powerpc/platforms/embedded6xx/storcenter.c
@@ -84,7 +84,7 @@ static void __init storcenter_init_IRQ(void)
 {
 	struct mpic *mpic;
 
-	mpic = mpic_alloc(NULL, 0, MPIC_PRIMARY | MPIC_WANTS_RESET,
+	mpic = mpic_alloc(NULL, 0, MPIC_WANTS_RESET,
 			16, 32, " OpenPIC  ");
 	BUG_ON(mpic == NULL);
 
diff --git a/arch/powerpc/platforms/maple/setup.c b/arch/powerpc/platforms/maple/setup.c
index 5b3388b..a14ac90 100644
--- a/arch/powerpc/platforms/maple/setup.c
+++ b/arch/powerpc/platforms/maple/setup.c
@@ -220,7 +220,7 @@ static void __init maple_init_IRQ(void)
 	unsigned long openpic_addr = 0;
 	int naddr, n, i, opplen, has_isus = 0;
 	struct mpic *mpic;
-	unsigned int flags = MPIC_PRIMARY;
+	unsigned int flags = 0;
 
 	/* Locate MPIC in the device-tree. Note that there is a bug
 	 * in Maple device-tree where the type of the controller is
diff --git a/arch/powerpc/platforms/pasemi/setup.c b/arch/powerpc/platforms/pasemi/setup.c
index 883757e..851bdab 100644
--- a/arch/powerpc/platforms/pasemi/setup.c
+++ b/arch/powerpc/platforms/pasemi/setup.c
@@ -223,7 +223,7 @@ static __init void pas_init_IRQ(void)
 	openpic_addr = of_read_number(opprop, naddr);
 	printk(KERN_DEBUG "OpenPIC addr: %lx\n", openpic_addr);
 
-	mpic_flags = MPIC_PRIMARY | MPIC_LARGE_VECTORS | MPIC_NO_BIAS;
+	mpic_flags = MPIC_LARGE_VECTORS | MPIC_NO_BIAS;
 
 	nmiprop = of_get_property(mpic_node, "nmi-source", NULL);
 	if (nmiprop)
diff --git a/arch/powerpc/platforms/powermac/pic.c b/arch/powerpc/platforms/powermac/pic.c
index fe360f7c..f4dc247 100644
--- a/arch/powerpc/platforms/powermac/pic.c
+++ b/arch/powerpc/platforms/powermac/pic.c
@@ -501,7 +501,7 @@ static struct mpic * __init pmac_setup_one_mpic(struct device_node *np,
 {
 	const char *name = master ? " MPIC 1   " : " MPIC 2   ";
 	struct mpic *mpic;
-	unsigned int flags = master ? MPIC_PRIMARY : 0;
+	unsigned int flags = master ? 0 : MPIC_SECONDARY;
 	int rc;
 
 	pmac_call_feature(PMAC_FTR_ENABLE_MPIC, np, 0, 0);
diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
index 0969fd9..172980c 100644
--- a/arch/powerpc/platforms/pseries/setup.c
+++ b/arch/powerpc/platforms/pseries/setup.c
@@ -192,8 +192,7 @@ static void __init pseries_mpic_init_IRQ(void)
 	BUG_ON(openpic_addr == 0);
 
 	/* Setup the openpic driver */
-	mpic = mpic_alloc(pSeries_mpic_node, openpic_addr,
-			  MPIC_PRIMARY,
+	mpic = mpic_alloc(pSeries_mpic_node, openpic_addr, 0,
 			  16, 250, /* isu size, irq count */
 			  " MPIC     ");
 	BUG_ON(mpic == NULL);
diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
index 548ca16..31a9ada 100644
--- a/arch/powerpc/sysdev/mpic.c
+++ b/arch/powerpc/sysdev/mpic.c
@@ -154,7 +154,7 @@ static inline unsigned int mpic_processor_id(struct mpic *mpic)
 {
 	unsigned int cpu = 0;
 
-	if (mpic->flags & MPIC_PRIMARY)
+	if (!(mpic->flags & MPIC_SECONDARY))
 		cpu = hard_smp_processor_id();
 
 	return cpu;
@@ -992,7 +992,7 @@ static int mpic_host_map(struct irq_host *h, unsigned int virq,
 
 #ifdef CONFIG_SMP
 	else if (hw >= mpic->ipi_vecs[0]) {
-		WARN_ON(!(mpic->flags & MPIC_PRIMARY));
+		WARN_ON(mpic->flags & MPIC_SECONDARY);
 
 		DBG("mpic: mapping as IPI\n");
 		irq_set_chip_data(virq, mpic);
@@ -1003,7 +1003,7 @@ static int mpic_host_map(struct irq_host *h, unsigned int virq,
 #endif /* CONFIG_SMP */
 
 	if (hw >= mpic->timer_vecs[0] && hw <= mpic->timer_vecs[7]) {
-		WARN_ON(!(mpic->flags & MPIC_PRIMARY));
+		WARN_ON(mpic->flags & MPIC_SECONDARY);
 
 		DBG("mpic: mapping as timer\n");
 		irq_set_chip_data(virq, mpic);
@@ -1190,12 +1190,12 @@ struct mpic * __init mpic_alloc(struct device_node *node,
 
 	mpic->hc_irq = mpic_irq_chip;
 	mpic->hc_irq.name = name;
-	if (flags & MPIC_PRIMARY)
+	if (!(flags & MPIC_SECONDARY))
 		mpic->hc_irq.irq_set_affinity = mpic_set_affinity;
 #ifdef CONFIG_MPIC_U3_HT_IRQS
 	mpic->hc_ht_irq = mpic_irq_ht_chip;
 	mpic->hc_ht_irq.name = name;
-	if (flags & MPIC_PRIMARY)
+	if (!(flags & MPIC_SECONDARY))
 		mpic->hc_ht_irq.irq_set_affinity = mpic_set_affinity;
 #endif /* CONFIG_MPIC_U3_HT_IRQS */
 
@@ -1361,7 +1361,7 @@ struct mpic * __init mpic_alloc(struct device_node *node,
 	mpic->next = mpics;
 	mpics = mpic;
 
-	if (flags & MPIC_PRIMARY) {
+	if (!(flags & MPIC_SECONDARY)) {
 		mpic_primary = mpic;
 		irq_set_default_host(mpic->irqhost);
 	}
@@ -1431,7 +1431,7 @@ void __init mpic_init(struct mpic *mpic)
 
 	/* Do the HT PIC fixups on U3 broken mpic */
 	DBG("MPIC flags: %x\n", mpic->flags);
-	if ((mpic->flags & MPIC_U3_HT_IRQS) && (mpic->flags & MPIC_PRIMARY)) {
+	if ((mpic->flags & MPIC_U3_HT_IRQS) && !(mpic->flags & MPIC_SECONDARY)) {
 		mpic_scan_ht_pics(mpic);
 		mpic_u3msi_init(mpic);
 	}
-- 
1.7.2.5

^ permalink raw reply related

* [RFC PATCH 10/10] powerpc/mpic: Add in-core support for cascaded MPICs
From: Kyle Moffett @ 2011-10-31 21:10 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev
  Cc: cbe-oss-dev, Arnd Bergmann, Milton Miller, Paul Mackerras,
	Kyle Moffett, Scott Wood
In-Reply-To: <1320095411-20667-1-git-send-email-Kyle.D.Moffett@boeing.com>

The Cell and PowerMac platforms use virtually identical cascaded-IRQ
setup code, so just merge it into the core.  This does the obvious thing
when an MPIC device-node specifies an "interrupts" property.

Signed-off-by: Kyle Moffett <Kyle.D.Moffett@boeing.com>
---
 arch/powerpc/platforms/cell/setup.c   |   22 --------------------
 arch/powerpc/platforms/powermac/pic.c |   36 ++++----------------------------
 arch/powerpc/sysdev/mpic.c            |   27 ++++++++++++++++++++++-
 3 files changed, 30 insertions(+), 55 deletions(-)

diff --git a/arch/powerpc/platforms/cell/setup.c b/arch/powerpc/platforms/cell/setup.c
index 392cbdb..8708a71 100644
--- a/arch/powerpc/platforms/cell/setup.c
+++ b/arch/powerpc/platforms/cell/setup.c
@@ -183,19 +183,6 @@ static int __init cell_publish_devices(void)
 }
 machine_subsys_initcall(cell, cell_publish_devices);
 
-static void cell_mpic_cascade(unsigned int irq, struct irq_desc *desc)
-{
-	struct irq_chip *chip = irq_desc_get_chip(desc);
-	struct mpic *mpic = irq_desc_get_handler_data(desc);
-	unsigned int virq;
-
-	virq = mpic_get_one_irq(mpic);
-	if (virq != NO_IRQ)
-		generic_handle_irq(virq);
-
-	chip->irq_eoi(&desc->irq_data);
-}
-
 static void __init mpic_init_IRQ(void)
 {
 	struct device_node *dn;
@@ -214,15 +201,6 @@ static void __init mpic_init_IRQ(void)
 		if (mpic == NULL)
 			continue;
 		mpic_init(mpic);
-
-		virq = irq_of_parse_and_map(dn, 0);
-		if (virq == NO_IRQ)
-			continue;
-
-		printk(KERN_INFO "%s : hooking up to IRQ %d\n",
-		       dn->full_name, virq);
-		irq_set_handler_data(virq, mpic);
-		irq_set_chained_handler(virq, cell_mpic_cascade);
 	}
 }
 
diff --git a/arch/powerpc/platforms/powermac/pic.c b/arch/powerpc/platforms/powermac/pic.c
index f4dc247..e02cd79 100644
--- a/arch/powerpc/platforms/powermac/pic.c
+++ b/arch/powerpc/platforms/powermac/pic.c
@@ -466,18 +466,6 @@ int of_irq_map_oldworld(struct device_node *device, int index,
 }
 #endif /* CONFIG_PPC32 */
 
-static void pmac_u3_cascade(unsigned int irq, struct irq_desc *desc)
-{
-	struct irq_chip *chip = irq_desc_get_chip(desc);
-	struct mpic *mpic = irq_desc_get_handler_data(desc);
-	unsigned int cascade_irq = mpic_get_one_irq(mpic);
-
-	if (cascade_irq != NO_IRQ)
-		generic_handle_irq(cascade_irq);
-
-	chip->irq_eoi(&desc->irq_data);
-}
-
 static void __init pmac_pic_setup_mpic_nmi(struct mpic *mpic)
 {
 #if defined(CONFIG_XMON) && defined(CONFIG_PPC32)
@@ -529,7 +517,6 @@ static int __init pmac_pic_probe_mpic(void)
 {
 	struct mpic *mpic1, *mpic2;
 	struct device_node *np, *master = NULL, *slave = NULL;
-	unsigned int cascade;
 
 	/* We can have up to 2 MPICs cascaded */
 	for (np = NULL; (np = of_find_node_by_type(np, "open-pic"))
@@ -565,27 +552,14 @@ static int __init pmac_pic_probe_mpic(void)
 
 	of_node_put(master);
 
-	/* No slave, let's go out */
-	if (slave == NULL)
-		return 0;
-
-	/* Get/Map slave interrupt */
-	cascade = irq_of_parse_and_map(slave, 0);
-	if (cascade == NO_IRQ) {
-		printk(KERN_ERR "Failed to map cascade IRQ\n");
-		return 0;
-	}
-
-	mpic2 = pmac_setup_one_mpic(slave, 0);
-	if (mpic2 == NULL) {
-		printk(KERN_ERR "Failed to setup slave MPIC\n");
+	/* Set up a cascaded controller, if present */
+	if (slave) {
+		mpic2 = pmac_setup_one_mpic(slave, 0);
+		if (mpic2 == NULL)
+			printk(KERN_ERR "Failed to setup slave MPIC\n");
 		of_node_put(slave);
-		return 0;
 	}
-	irq_set_handler_data(cascade, mpic2);
-	irq_set_chained_handler(cascade, pmac_u3_cascade);
 
-	of_node_put(slave);
 	return 0;
 }
 
diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
index 1826dae..d5cf276 100644
--- a/arch/powerpc/sysdev/mpic.c
+++ b/arch/powerpc/sysdev/mpic.c
@@ -1113,6 +1113,21 @@ static int mpic_host_xlate(struct irq_host *h, struct device_node *ct,
 	return 0;
 }
 
+/* IRQ handler for a secondary MPIC cascaded from another IRQ controller */
+static void mpic_cascade(unsigned int irq, struct irq_desc *desc)
+{
+	struct irq_chip *chip = irq_desc_get_chip(desc);
+	struct mpic *mpic = irq_desc_get_handler_data(desc);
+
+	BUG_ON(!(mpic->flags & MPIC_SECONDARY));
+
+	unsigned int virq = mpic_get_one_irq(mpic);
+	if (virq != NO_IRQ)
+		generic_handle_irq(virq);
+
+	chip->irq_eoi(&desc->irq_data);
+}
+
 static struct irq_host_ops mpic_host_ops = {
 	.match = mpic_host_match,
 	.map = mpic_host_map,
@@ -1384,8 +1399,7 @@ void __init mpic_set_default_senses(struct mpic *mpic, u8 *senses, int count)
 
 void __init mpic_init(struct mpic *mpic)
 {
-	int i;
-	int cpu;
+	int i, cpu, virq;
 
 	BUG_ON(mpic->num_sources == 0);
 
@@ -1470,6 +1484,15 @@ void __init mpic_init(struct mpic *mpic)
 				  GFP_KERNEL);
 	BUG_ON(mpic->save_data == NULL);
 #endif
+
+	/* Check if this MPIC is chained from a parent interrupt controller */
+	virq = irq_of_parse_and_map(mpic->node, 0);
+	if (virq != NO_IRQ) {
+		printk(KERN_INFO "%s: hooking up to IRQ %d\n",
+				dn->full_name, virq);
+		irq_set_handler_data(virq, mpic);
+		irq_set_chained_handler(virq, &mpic_cascade);
+	}
 }
 
 void __init mpic_set_clk_ratio(struct mpic *mpic, u32 clock_ratio)
-- 
1.7.2.5

^ permalink raw reply related

* [PATCH] [v3] powerpc/fsl_msi: add support for the fsl, msi property in PCI nodes
From: Timur Tabi @ 2011-10-31 22:06 UTC (permalink / raw)
  To: kumar.gala, scottwood, miltonm, tglx, benh, linuxppc-dev, michael

On Freescale parts with multiple MSI controllers, the controllers are
combined into one "pool" of interrupts.  Whenever a device requests an MSI
interrupt, the next available interrupt from the pool is selected,
regardless of which MSI controller the interrupt is from.  This works
because each PCI bus has an ATMU to all of CCSR, so any PCI device can
access any MSI interrupt register.

The fsl,msi property is used to specify that a given PCI bus should only
use a specific MSI device.  This is necessary, for example, with the
Freescale hypervisor, because the MSI devices are assigned to specific
partitions.

Ideally, we'd like to be able to assign MSI devices to PCI busses within
the MSI or PCI layers.  However, there does not appear to be a mechanism
to do that.  Whenever the MSI layer wants to allocate an MSI interrupt to
a PCI device, it just calls arch_setup_msi_irqs().  It would be nice if we
could register an MSI device with a specific PCI bus.

So instead we remember the phandles of each MSI device, and we use that to
limit our search for an available interrupt.  Whenever we are asked to
allocate a new interrupt for a PCI device, we check the fsl,msi property
of the PCI bus for that device.  If it exists, then as we are looping over
all MSI devices, we skip the ones that don't have a matching phandle.

Signed-off-by: Timur Tabi <timur@freescale.com>
---

v3: added check for invalid fsl,msi phandles

 arch/powerpc/sysdev/fsl_msi.c |   39 +++++++++++++++++++++++++++++++++++++++
 arch/powerpc/sysdev/fsl_msi.h |    3 +++
 2 files changed, 42 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/sysdev/fsl_msi.c b/arch/powerpc/sysdev/fsl_msi.c
index e5c344d..89548e0 100644
--- a/arch/powerpc/sysdev/fsl_msi.c
+++ b/arch/powerpc/sysdev/fsl_msi.c
@@ -148,14 +148,47 @@ static void fsl_compose_msi_msg(struct pci_dev *pdev, int hwirq,
 
 static int fsl_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type)
 {
+	struct pci_controller *hose = pci_bus_to_host(pdev->bus);
+	struct device_node *np;
+	phandle phandle = 0;
 	int rc, hwirq = -ENOMEM;
 	unsigned int virq;
 	struct msi_desc *entry;
 	struct msi_msg msg;
 	struct fsl_msi *msi_data;
 
+	/*
+	 * If the PCI node has an fsl,msi property, then we need to use it
+	 * to find the specific MSI.
+	 */
+	np = of_parse_phandle(hose->dn, "fsl,msi", 0);
+	if (np) {
+		if (of_device_is_compatible(np, "fsl,mpic-msi"))
+			phandle = np->phandle;
+		else {
+			dev_err(&pdev->dev, "node %s has an invalid fsl,msi"
+				" phandle\n", hose->dn->full_name);
+			return -EINVAL;
+		}
+	}
+
 	list_for_each_entry(entry, &pdev->msi_list, list) {
+		/*
+		 * Loop over all the MSI devices until we find one that has an
+		 * available interrupt.
+		 */
 		list_for_each_entry(msi_data, &msi_head, list) {
+			/*
+			 * If the PCI node has an fsl,msi property, then we
+			 * restrict our search to the corresponding MSI node.
+			 * The simplest way is to skip over MSI nodes with the
+			 * wrong phandle. Under the Freescale hypervisor, this
+			 * has the additional benefit of skipping over MSI
+			 * nodes that are not mapped in the PAMU.
+			 */
+			if (phandle && (phandle != msi_data->phandle))
+				continue;
+
 			hwirq = msi_bitmap_alloc_hwirqs(&msi_data->bitmap, 1);
 			if (hwirq >= 0)
 				break;
@@ -370,6 +403,12 @@ static int __devinit fsl_of_msi_probe(struct platform_device *dev)
 
 	msi->msiir_offset = features->msiir_offset + (res.start & 0xfffff);
 
+	/*
+	 * Remember the phandle, so that we can match with any PCI nodes
+	 * that have an "fsl,msi" property.
+	 */
+	msi->phandle = dev->dev.of_node->phandle;
+
 	rc = fsl_msi_init_allocator(msi);
 	if (rc) {
 		dev_err(&dev->dev, "Error allocating MSI bitmap\n");
diff --git a/arch/powerpc/sysdev/fsl_msi.h b/arch/powerpc/sysdev/fsl_msi.h
index 1313abb..b5d25ba 100644
--- a/arch/powerpc/sysdev/fsl_msi.h
+++ b/arch/powerpc/sysdev/fsl_msi.h
@@ -13,6 +13,7 @@
 #ifndef _POWERPC_SYSDEV_FSL_MSI_H
 #define _POWERPC_SYSDEV_FSL_MSI_H
 
+#include <linux/of.h>
 #include <asm/msi_bitmap.h>
 
 #define NR_MSI_REG		8
@@ -36,6 +37,8 @@ struct fsl_msi {
 	struct msi_bitmap bitmap;
 
 	struct list_head list;          /* support multiple MSI banks */
+
+	phandle phandle;
 };
 
 #endif /* _POWERPC_SYSDEV_FSL_MSI_H */
-- 
1.7.3.4

^ permalink raw reply related

* Re: [PATCH] powerpc/iommu: remove default window before creating larger window
From: Nishanth Aravamudan @ 2011-10-31 22:47 UTC (permalink / raw)
  To: benh; +Cc: miltonm, paulus, linuxppc-dev
In-Reply-To: <20111026224323.GA15685@us.ibm.com>

Hi Ben,

Please don't take this patch :)

While, it does work around some issues I'm tracking down, it can lead
to worse ones if we are unable to configure the larger DMA window, or if
some functions in a PE don't use 64-bit DMA masks.

Thanks,
Nish

On 26.10.2011 [15:43:23 -0700], Nishanth Aravamudan wrote:
> The DDW feature relies on there being sufficient TCE space to allocate
> for the requested DMA window size. The default window uses up some of
> that space, though, and it is recommended to first remove the default
> window and then allocate the larger window advertised by firmware. Do
> this by abstracting out parts of remove_ddw into a function that does
> not assume an existing larger window has been created.
> 
> Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>
> ---
>  arch/powerpc/platforms/pseries/iommu.c |   35 +++++++++++++++++++++++--------
>  1 files changed, 26 insertions(+), 9 deletions(-)
> 
> Is there a better way to get the default window's LIOBN than to call
> of_parse_dma_window?
> 
> diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c
> index 01faab9..afcc04c 100644
> --- a/arch/powerpc/platforms/pseries/iommu.c
> +++ b/arch/powerpc/platforms/pseries/iommu.c
> @@ -655,6 +655,21 @@ static int __init disable_ddw_setup(char *str)
>  
>  early_param("disable_ddw", disable_ddw_setup);
>  
> +static void __remove_ddw(struct device_node *np, const u32 *ddw_avail, u64 liobn)
> +{
> +	int ret;
> +
> +	ret = rtas_call(ddw_avail[2], 1, 1, NULL, liobn);
> +	if (ret)
> +		pr_warning("%s: failed to remove direct window: rtas returned "
> +			"%d to ibm,remove-pe-dma-window(%x) %llx\n",
> +			np->full_name, ret, ddw_avail[2], liobn);
> +	else
> +		pr_debug("%s: successfully removed direct window: rtas returned "
> +			"%d to ibm,remove-pe-dma-window(%x) %llx\n",
> +			np->full_name, ret, ddw_avail[2], liobn);
> +}
> +
>  static void remove_ddw(struct device_node *np)
>  {
>  	struct dynamic_dma_window_prop *dwp;
> @@ -684,15 +699,7 @@ static void remove_ddw(struct device_node *np)
>  		pr_debug("%s successfully cleared tces in window.\n",
>  			 np->full_name);
>  
> -	ret = rtas_call(ddw_avail[2], 1, 1, NULL, liobn);
> -	if (ret)
> -		pr_warning("%s: failed to remove direct window: rtas returned "
> -			"%d to ibm,remove-pe-dma-window(%x) %llx\n",
> -			np->full_name, ret, ddw_avail[2], liobn);
> -	else
> -		pr_debug("%s: successfully removed direct window: rtas returned "
> -			"%d to ibm,remove-pe-dma-window(%x) %llx\n",
> -			np->full_name, ret, ddw_avail[2], liobn);
> +	__remove_ddw(np, ddw_avail, liobn);
>  
>  delprop:
>  	ret = prom_remove_property(np, win64);
> @@ -843,6 +850,8 @@ static u64 enable_ddw(struct pci_dev *dev, struct device_node *pdn)
>  	struct direct_window *window;
>  	struct property *win64;
>  	struct dynamic_dma_window_prop *ddwprop;
> +	const void *dma_window = NULL;
> +	unsigned long liobn, offset, size;
>  
>  	mutex_lock(&direct_window_init_mutex);
>  
> @@ -918,6 +927,14 @@ static u64 enable_ddw(struct pci_dev *dev, struct device_node *pdn)
>  		goto out_free_prop;
>  	}
>  
> +	/*
> +	 * To maximize the resources available to the create RTAS call,
> +	 * delete the existing DMA window
> +	 */
> +	dma_window = of_get_property(pdn, "ibm,dma-window", NULL);
> +	of_parse_dma_window(pdn, dma_window, &liobn, &offset, &size);
> +	__remove_ddw(pdn, ddw_avail, liobn);
> +
>  	ret = create_ddw(dev, ddw_avail, &create, page_shift, len);
>  	if (ret != 0)
>  		goto out_free_prop;
> -- 
> 1.7.5.4
> 
> 
> -- 
> Nishanth Aravamudan <nacc@us.ibm.com>
> IBM Linux Technology Center

-- 
Nishanth Aravamudan <nacc@us.ibm.com>
IBM Linux Technology Center

^ permalink raw reply

* Re: powerpc 476, Little-endian, pte fault
From: Santosh Kumar @ 2011-11-01  3:02 UTC (permalink / raw)
  To: Benjamin Herrenschmidt
  Cc: linuxppc-dev, Michael Neuling, Ian Munsie, linux-kernel
In-Reply-To: <1320060214.30202.34.camel@pasglop>

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

I have attached the patch with only the relevant changes.

The patch is not based on uLIBC patch.

Glibc doesnt support little endian for PPC, but after minor changes to
makefile i got it working. With the compiler i am using i could get
2.6.31 on ppc440 working. I am using the same compiler as 476 & 440
instruction is almost the same.

Thanks
Santosh Kumar .A

Vision without Action is a daydream... Action without Vision is a nightmare...



On 31 October 2011 16:53, Benjamin Herrenschmidt
<benh@kernel.crashing.org> wrote:
> On Mon, 2011-10-31 at 20:49 +1100, Michael Neuling wrote:
>> > I have built a cross compiler for ppc440 in little endian mode and
>> > using it to build the kernel.
>> >
>> > Yes i am running Linux in Little-Endian. This is the first user space
>> > process. I wrote the below program and running it as init from
>> > /sbin/init. I have also set the permissions with chmod +s.
>> >
>> > main()
>> > {
>> >
>> > while(1){
>> > printf("hello world");
>> > sleep(1);
>> >  }
>> > }
>>
>> Does libc even support little endian on PPC?
>
> Ian did a port a while back for uClibc, is that at least partially based
> on it ?
>
>> > I have attached the patch.
>>
>> This is a pretty huge patch:
>>
>>  115 files changed, 44479 insertions(+), 7398 deletions(-)
>>
>> It seems to include a new platform as well as a bunch of unrelated junk.
>>
>> I suggest you need to break this down into something more digestible.
>> Like remove all the junk in the patch.  Then add the support for the new
>> platform (invader? platform).  Then start looking at little endian.
>> Unless you do this, it's unlikely anyone here is going to be able to
>> help.
>>
>> When you get to the little endian work, you might want to take a look at
>> this patch series from Ian Munsie:
>>
>> http://lists.ozlabs.org/pipermail/linuxppc-dev/2010-October/086165.html
>
> Right, the new patch should be if possible based on Ian's series or at
> least a cleaned / rebased variant of it. Then split in bits so we can
> review it properly.
>
> Cheers,
> Ben.
>
>> Mikey
>> _______________________________________________
>> Linuxppc-dev mailing list
>> Linuxppc-dev@lists.ozlabs.org
>> https://lists.ozlabs.org/listinfo/linuxppc-dev
>
>
>

[-- Attachment #2: linux_ppc_476.patch --]
[-- Type: application/octet-stream, Size: 42386 bytes --]

diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/boot/div64.S ../linux-2.6.39.4/arch/powerpc/boot/div64.S
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/boot/div64.S	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/boot/div64.S	2011-10-22 14:16:46.616117143 +0530
@@ -17,8 +17,13 @@
 
 	.globl __div64_32
 __div64_32:
+#ifdef CONFIG_INVADER
+	lwz	r5,4(r3)	# get the dividend into r5/r6
+	lwz	r6,0(r3)
+#else
 	lwz	r5,0(r3)	# get the dividend into r5/r6
 	lwz	r6,4(r3)
+#endif
 	cmplw	r5,r4
 	li	r7,0
 	li	r8,0
@@ -53,7 +58,12 @@
 	mullw	r10,r0,r4	# and get the remainder
 	add	r8,r8,r0
 	subf	r6,r10,r6
+#ifdef CONFIG_INVADER
 4:	stw	r7,0(r3)	# return the quotient in *r3
 	stw	r8,4(r3)
+#else
+4:	stw	r7,0(r3)	# return the quotient in *r3
+	stw	r8,4(r3)
+#endif
 	mr	r3,r6		# return the remainder in r3
 	blr
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/boot/Makefile ../linux-2.6.39.4/arch/powerpc/boot/Makefile
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/boot/Makefile	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/boot/Makefile	2011-10-22 06:47:05.354137527 +0530
@@ -37,7 +37,7 @@
 
 DTC_FLAGS	?= -p 1024
 
-$(obj)/4xx.o: BOOTCFLAGS += -mcpu=405
+$(obj)/4xx.o: BOOTCFLAGS += -mcpu=440
 $(obj)/ebony.o: BOOTCFLAGS += -mcpu=405
 $(obj)/cuboot-hotfoot.o: BOOTCFLAGS += -mcpu=405
 $(obj)/cuboot-taishan.o: BOOTCFLAGS += -mcpu=405
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/boot/wrapper ../linux-2.6.39.4/arch/powerpc/boot/wrapper
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/boot/wrapper	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/boot/wrapper	2011-10-22 06:38:26.286134445 +0530
@@ -38,6 +38,7 @@
 dts=
 cacheit=
 binary=
+gzip=
 gzip=.gz
 
 # cross-compilation prefix
@@ -50,7 +51,6 @@
 object=arch/powerpc/boot
 objbin=$object
 dtc=scripts/dtc/dtc
-
 # directory for working files
 tmpdir=.
 
@@ -260,7 +260,6 @@
 	vmz="$vmz.$$"
     fi
 fi
-
 vmz="$vmz$gzip"
 
 # Extract kernel version information, some platforms want to include
@@ -277,12 +276,13 @@
 case "$platform" in
 uboot)
     rm -f "$ofile"
-    ${MKIMAGE} -A ppc -O linux -T kernel -C gzip -a $membase -e $membase \
+    ${MKIMAGE} -A ppc -O linux -T kernel -a $membase -e $membase \
 	$uboot_version -d "$vmz" "$ofile"
     if [ -z "$cacheit" ]; then
 	rm -f "$vmz"
     fi
     exit 0
+    echo "not exiting"
     ;;
 esac
 
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/include/asm/bitops.h ../linux-2.6.39.4/arch/powerpc/include/asm/bitops.h
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/include/asm/bitops.h	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/include/asm/bitops.h	2011-10-22 06:38:25.203141637 +0530
@@ -318,13 +318,34 @@
 	return __test_and_clear_bit(nr ^ BITOP_LE_SWIZZLE, addr);
 }
 
+static inline unsigned long find_next_zero_bit_le(const void *addr,
+                unsigned long size, unsigned long offset)
+{
+        return find_next_zero_bit(addr, size, offset);
+}
+
+static inline unsigned long find_next_bit_le(const void *addr,
+                unsigned long size, unsigned long offset)
+{
+        return find_next_bit(addr, size, offset);
+}
+
+static inline unsigned long find_first_zero_bit_le(const void *addr,
+                unsigned long size)
+{
+        return find_first_zero_bit(addr, size);
+}
+
 #define find_first_zero_bit_le(addr, size) \
 	find_next_zero_bit_le((addr), (size), 0)
+/*
 unsigned long find_next_zero_bit_le(const void *addr,
 				    unsigned long size, unsigned long offset);
 
 unsigned long find_next_bit_le(const void *addr,
 				    unsigned long size, unsigned long offset);
+*/
+
 /* Bitmap functions for the ext2 filesystem */
 
 #define ext2_set_bit_atomic(lock, nr, addr) \
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/include/asm/byteorder.h ../linux-2.6.39.4/arch/powerpc/include/asm/byteorder.h
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/include/asm/byteorder.h	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/include/asm/byteorder.h	2011-10-22 06:38:25.254182204 +0530
@@ -7,6 +7,12 @@
  * as published by the Free Software Foundation; either version
  * 2 of the License, or (at your option) any later version.
  */
+
+#ifdef CONFIG_INVADER
+#include <linux/byteorder/little_endian.h>
+#else
 #include <linux/byteorder/big_endian.h>
+#endif
+
 
 #endif /* _ASM_POWERPC_BYTEORDER_H */
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/include/asm/elf.h ../linux-2.6.39.4/arch/powerpc/include/asm/elf.h
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/include/asm/elf.h	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/include/asm/elf.h	2011-10-22 06:38:25.140139532 +0530
@@ -118,13 +118,21 @@
 # define ELF_GREG_TYPE	elf_greg_t32
 # define ELF_ARCH	EM_PPC
 # define ELF_CLASS	ELFCLASS32
+#ifdef CONFIG_INVADER
+# define ELF_DATA	ELFDATA2LSB
+#else
 # define ELF_DATA	ELFDATA2MSB
+#endif
 #endif /* __powerpc64__ */
 
 #ifndef ELF_ARCH
 # define ELF_ARCH	EM_PPC64
 # define ELF_CLASS	ELFCLASS64
+#ifdef CONFIG_INVADER
+# define ELF_DATA	ELFDATA2LSB
+#else
 # define ELF_DATA	ELFDATA2MSB
+#endif
   typedef elf_greg_t64 elf_greg_t;
   typedef elf_gregset_t64 elf_gregset_t;
 #else

 iff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/include/asm/pgtable-ppc32.h ../linux-2.6.39.4/arch/powerpc/include/asm/pgtable-ppc32.h
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/include/asm/pgtable-ppc32.h	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/include/asm/pgtable-ppc32.h	2011-10-28 13:54:33.350779238 +0530
@@ -63,8 +63,12 @@
 #ifdef CONFIG_HIGHMEM
 #define KVIRT_TOP	PKMAP_BASE
 #else
+#ifdef CONFIG_INVADER
+#define KVIRT_TOP	(0xbe000000UL)	
+#else
 #define KVIRT_TOP	(0xfe000000UL)	/* for now, could be FIXMAP_BASE ? */
 #endif
+#endif
 
 /*
  * ioremap_bot starts at that address. Early ioremaps move down from there,
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/include/asm/prom.h ../linux-2.6.39.4/arch/powerpc/include/asm/prom.h
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/include/asm/prom.h	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/include/asm/prom.h	2011-10-22 06:38:25.211141792 +0530
@@ -20,6 +20,10 @@
 #include <asm/irq.h>
 #include <asm/atomic.h>
 
+#ifdef CONFIG_INVADER
+#include <asm/io.h>
+#endif
+
 #define HAVE_ARCH_DEVTREE_FIXUPS
 
 #ifdef CONFIG_PPC32
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/include/asm/reg.h ../linux-2.6.39.4/arch/powerpc/include/asm/reg.h
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/include/asm/reg.h	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/include/asm/reg.h	2011-10-22 06:38:25.222139709 +0530
@@ -839,7 +839,11 @@
 #define PVR_403GC	0x00200200
 #define PVR_403GCX	0x00201400
 #define PVR_405GP	0x40110000
+#ifdef CONFIG_INVADER
+#define PVR_476		0x7ff52080
+#else
 #define PVR_476		0x11a52000
+#endif
 #define PVR_STB03XXX	0x40310000
 #define PVR_NP405H	0x41410000
 #define PVR_NP405L	0x41610000
 
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/kernel/cacheinfo.c ../linux-2.6.39.4/arch/powerpc/kernel/cacheinfo.c
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/kernel/cacheinfo.c	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/kernel/cacheinfo.c	2011-10-24 17:02:11.354148243 +0530
@@ -203,7 +203,12 @@
 	if (!cache_size)
 		return -ENODEV;
 
+	printk("cache size: 0x%u\n", be32_to_cpup(cache_size));
+#ifdef CONFIG_INVADER
+	*ret = be32_to_cpup(cache_size);
+#else
 	*ret = *cache_size;
+#endif
 	return 0;
 }
 
@@ -238,7 +243,12 @@
 	if (!line_size)
 		return -ENODEV;
 
+	printk("lne size: 0x%u\n", be32_to_cpup(line_size));
+#ifdef CONFIG_INVADER
+	*ret = be32_to_cpup(line_size);
+#else
 	*ret = *line_size;
+#endif
 	return 0;
 }
 
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/kernel/cputable.c ../linux-2.6.39.4/arch/powerpc/kernel/cputable.c
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/kernel/cputable.c	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/kernel/cputable.c	2011-10-22 06:38:27.763108473 +0530
@@ -1853,6 +1853,22 @@
 		.machine_check		= machine_check_47x,
 		.platform		= "ppc470",
 	},
+#ifdef CONFIG_INVADER
+        { /* 476 others */
+                .pvr_mask               = 0xffffffff,
+                .pvr_value              = 0x7ff52080,
+                .cpu_name               = "476fp",
+                .cpu_features           = CPU_FTRS_47X,
+                .cpu_user_features      = COMMON_USER_BOOKE |
+                        PPC_FEATURE_HAS_FPU,
+                .mmu_features           = MMU_FTR_TYPE_47x |
+                        MMU_FTR_USE_TLBIVAX_BCAST | MMU_FTR_LOCK_BCAST_INVAL,
+                .icache_bsize           = 32,
+                .dcache_bsize           = 32,
+                .machine_check          = machine_check_47x,
+                .platform               = "ppc470",
+        },
+#endif
 	{	/* default match */
 		.pvr_mask		= 0x00000000,
 		.pvr_value		= 0x00000000,
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/kernel/head_44x.S ../linux-2.6.39.4/arch/powerpc/kernel/head_44x.S
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/kernel/head_44x.S	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/kernel/head_44x.S	2011-10-30 16:00:57.409103255 +0530
@@ -259,8 +259,14 @@
 
 	/* Compute pte address */
 	rlwimi  r12, r10, PPC44x_PTE_ADD_SHIFT, PPC44x_PTE_ADD_MASK_BIT, 28
+
+#ifdef CONFIG_INVADER
+	lwz	r11, 4(r12)		/* Get high word of pte entry */
+	lwz	r12, 0(r12)		/* Get low word of pte entry */
+#else
 	lwz	r11, 0(r12)		/* Get high word of pte entry */
 	lwz	r12, 4(r12)		/* Get low word of pte entry */
+#endif
 
 	lis	r10,tlb_44x_index@ha
 
@@ -355,8 +361,13 @@
 
 	/* Compute pte address */
 	rlwimi	r12, r10, PPC44x_PTE_ADD_SHIFT, PPC44x_PTE_ADD_MASK_BIT, 28
+#ifdef CONFIG_INVADER
+	lwz	r11, 4(r12)		/* Get high word of pte entry */
+	lwz	r12, 0(r12)		/* Get low word of pte entry */
+#else
 	lwz	r11, 0(r12)		/* Get high word of pte entry */
 	lwz	r12, 4(r12)		/* Get low word of pte entry */
+#endif
 
 	lis	r10,tlb_44x_index@ha
 
@@ -508,8 +519,12 @@
 	/* Compute pte address */
 	rlwimi  r12,r10,PPC44x_PTE_ADD_SHIFT,PPC44x_PTE_ADD_MASK_BIT,28
 	beq	2f			/* Bail if no table */
-	lwz	r11,0(r12)		/* Get high word of pte entry */
 
+#ifdef CONFIG_INVADER
+	lwz	r11,4(r12)		/* Get high word of pte entry */
+#else
+	lwz	r11,0(r12)		/* Get high word of pte entry */
+#endif
 	/* XXX can we do better ? maybe insert a known 0 bit from r11 into the
 	 * bottom of r12 to create a data dependency... We can also use r10
 	 * as destination nowadays
@@ -517,8 +532,12 @@
 #ifdef CONFIG_SMP
 	lwsync
 #endif
-	lwz	r12,4(r12)		/* Get low word of pte entry */
 
+#ifdef CONFIG_INVADER
+	lwz	r12,0(r12)		/* Get low word of pte entry */
+#else
+	lwz	r12,4(r12)		/* Get low word of pte entry */
+#endif
 	andc.	r13,r13,r12		/* Check permission */
 
 	 /* Jump to common tlb load */
@@ -592,15 +611,23 @@
 	rlwimi  r12,r10,PPC44x_PTE_ADD_SHIFT,PPC44x_PTE_ADD_MASK_BIT,28
 	beq	2f			/* Bail if no table */
 
+#ifdef CONFIG_INVADER
+	lwz	r11,4(r12)		/* Get high word of pte entry */
+#else
 	lwz	r11,0(r12)		/* Get high word of pte entry */
+#endif
 	/* XXX can we do better ? maybe insert a known 0 bit from r11 into the
 	 * bottom of r12 to create a data dependency... We can also use r10
 	 * as destination nowadays
 	 */
-#ifdef CONFIG_SMP
+#ifndef CONFIG_SMP
 	lwsync
 #endif
+#ifdef CONFIG_INVADER
+	lwz	r11,0(r12)		/* Get high word of pte entry */
+#else
 	lwz	r12,4(r12)		/* Get low word of pte entry */
+#endif
 
 	andc.	r13,r13,r12		/* Check permission */
 
@@ -638,8 +665,12 @@
 	rlwimi	r10,r12,29,30,30		/* DIRTY -> SW position */
 	and	r11,r12,r10			/* Mask PTE bits to keep */
 	andi.	r10,r12,_PAGE_USER		/* User page ? */
+#ifdef CONFIG_INVADER
+	ori	r11,r11,PPC47x_TLB2_E
+#endif
 	beq	1f				/* nope, leave U bits empty */
 	rlwimi	r11,r11,3,26,28			/* yes, copy S bits to U */
+
 1:	tlbwe	r11,r13,2
 
 	/* Done...restore registers and get out of here.
@@ -935,6 +966,13 @@
  */
 
 head_start_47x:
+//	.align
+	nop
+	nop
+	nop
+	
+	li r3, 0x3
+	rlwinm r23, r3, 1, 31, 31
 	/* Load our current PID->MMUCR TID and MSR IS->MMUCR STS */
 	mfspr	r3,SPRN_PID			/* Get PID */
 	mfmsr	r4				/* Get MSR */
@@ -964,8 +1002,7 @@
 clear_all_utlb_entries:
 
 	#; Set initial values.
-
-	addis		r3,0,0x8000
+	addis		r3,0,0xa000	/* Invader change: quick fix?? */
 	addi		r4,0,0
 	addi		r5,0,0
 	b		clear_utlb_entry
@@ -976,6 +1013,7 @@
 
 clear_utlb_entry:
 
+//	isync	//not needed ??
 	tlbwe		r4,r3,0
 	tlbwe		r5,r3,1
 	tlbwe		r5,r3,2
@@ -987,12 +1025,15 @@
 	cmpwi		r4,0
 	bne		clear_utlb_entry
 
-	#; Restore original entry.
 
+	#; Restore original entry.
+#ifndef CONFIG_INVDER
+// Invader change 
 	oris	r23,r23,0x8000  /* specify the way */
 	tlbwe		r24,r23,0
 	tlbwe		r25,r23,1
 	tlbwe		r26,r23,2
+#endif
 
 /*
  * Configure and load pinned entry into TLB for the kernel core
@@ -1018,7 +1059,12 @@
 					/* ERPN is 0 for first 4GB page */
 	/* Word 2 */
 	li	r5,0
+#ifdef CONFIG_INVADER
+	ori	r5,r5,(PPC47x_TLB2_S_RWX|PPC47x_TLB2_E)
+#else
 	ori	r5,r5,PPC47x_TLB2_S_RWX
+#endif
+
 #ifdef CONFIG_SMP
 	ori	r5,r5,PPC47x_TLB2_M
 #endif
@@ -1062,14 +1108,19 @@
 
 	/* Word 0 */
 	lis	r3,PPC44x_EARLY_DEBUG_VIRTADDR@h
-	ori	r3,r3,PPC47x_TLB0_VALID | PPC47x_TLB0_TS | PPC47x_TLB0_1M
+	ori	r3,r3, (PPC47x_TLB0_VALID | PPC47x_TLB0_TS | PPC47x_TLB0_1M)
 
 	/* Word 1 */
 	lis	r4,CONFIG_PPC_EARLY_DEBUG_44x_PHYSLOW@h
 	ori	r4,r4,CONFIG_PPC_EARLY_DEBUG_44x_PHYSHIGH
 
-	/* Word 2 */
+#ifdef CONFIG_INVADER
+	/* Removing M flag as there is no SMP support for now*/
+	li	r5,(PPC47x_TLB2_S_RW | PPC47x_TLB2_I | PPC47x_TLB2_G | PPC47x_TLB2_E)
+
+#else
 	li	r5,(PPC47x_TLB2_S_RW | PPC47x_TLB2_IMG)
+#endif
 
 	/* Bolted in way 0, bolt slot 5, we -hope- we don't hit the same
 	 * congruence class as the kernel, we need to make sure of it at
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/kernel/irq.c ../linux-2.6.39.4/arch/powerpc/kernel/irq.c
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/kernel/irq.c	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/kernel/irq.c	2011-10-24 16:36:08.295113827 +0530
@@ -757,7 +757,11 @@
 
 	/* If host has no translation, then we assume interrupt line */
 	if (host->ops->xlate == NULL)
+#ifdef CONFIG_INVADER
+		hwirq = be32_to_cpu(intspec[0]);
+#else
 		hwirq = intspec[0];
+#endif
 	else {
 		if (host->ops->xlate(host, controller, intspec, intsize,
 				     &hwirq, &type))
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/kernel/misc_32.S ../linux-2.6.39.4/arch/powerpc/kernel/misc_32.S
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/kernel/misc_32.S	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/kernel/misc_32.S	2011-10-26 15:51:22.562068744 +0530
@@ -60,6 +60,32 @@
 /*
  * This returns the high 64 bits of the product of two 64-bit numbers.
  */
+
+#ifdef CONFIG_INVADER
+_GLOBAL(mulhdu)
+       cmpwi   r5,0
+       cmpwi   cr1,r4,0
+       mr      r10,r3
+       mulhwu  r3,r3,r6
+       beq     1f
+       mulhwu  r0,r10,r5
+       mullw   r7,r10,r6
+       addc    r7,r0,r7
+       addze   r3,r3
+1:     beqlr   cr1             /* all done if high part of A is 0 */
+       mr      r10,r4
+       mullw   r9,r4,r6
+       mulhwu  r4,r4,r6
+       beq     2f
+       mullw   r0,r10,r5
+       mulhwu  r8,r10,r5
+       addc    r7,r0,r7
+       adde    r3,r3,r8
+       addze   r4,r4
+2:     addc    r3,r3,r9
+       addze   r4,r4
+       blr
+#else
 _GLOBAL(mulhdu)
 	cmpwi	r6,0
 	cmpwi	cr1,r3,0
@@ -83,6 +109,7 @@
 2:	addc	r4,r4,r9
 	addze	r3,r3
 	blr
+#endif
 
 /*
  * sub_reloc_offset(x) returns x - reloc_offset().
@@ -605,6 +632,42 @@
  *  lshrdi3: logical right shift
  *  ashldi3: left shift
  */
+#ifdef CONFIG_INVADER
+_GLOBAL(__ashrdi3)
+       subfic  r6,r5,32
+       srw     r3,r3,r5        # LSW = count > 31 ? 0 : LSW >> count
+       addi    r7,r5,32        # could be xori, or addi with -32
+       slw     r6,r4,r6        # t1 = count > 31 ? 0 : MSW << (32-count)
+       rlwinm  r8,r7,0,32      # t3 = (count < 32) ? 32 : 0
+       sraw    r7,r4,r7        # t2 = MSW >> (count-32)
+       or      r3,r3,r6        # LSW |= t1
+       slw     r7,r7,r8        # t2 = (count < 32) ? 0 : t2
+       sraw    r4,r4,r5        # MSW = MSW >> count
+       or      r3,r3,r7        # LSW |= t2
+       blr
+
+_GLOBAL(__ashldi3)
+       subfic  r6,r5,32
+       slw     r4,r4,r5        # MSW = count > 31 ? 0 : MSW << count
+       addi    r7,r5,32        # could be xori, or addi with -32
+       srw     r6,r3,r6        # t1 = count > 31 ? 0 : LSW >> (32-count)
+       slw     r7,r3,r7        # t2 = count < 32 ? 0 : LSW << (count-32)
+       or      r4,r4,r6        # MSW |= t1
+       slw     r3,r3,r5        # LSW = LSW << count
+       or      r4,r4,r7        # MSW |= t2
+       blr
+
+_GLOBAL(__lshrdi3)
+       subfic  r6,r5,32
+       srw     r3,r3,r5        # LSW = count > 31 ? 0 : LSW >> count
+       addi    r7,r5,32        # could be xori, or addi with -32
+       slw     r6,r4,r6        # t1 = count > 31 ? 0 : MSW << (32-count)
+       srw     r7,r4,r7        # t2 = count < 32 ? 0 : MSW >> (count-32)
+       or      r3,r3,r6        # LSW |= t1
+       srw     r4,r4,r5        # MSW = MSW >> count
+       or      r3,r3,r7        # LSW |= t2
+       blr
+#else
 _GLOBAL(__ashrdi3)
 	subfic	r6,r5,32
 	srw	r4,r4,r5	# LSW = count > 31 ? 0 : LSW >> count
@@ -639,6 +702,7 @@
 	srw	r3,r3,r5	# MSW = MSW >> count
 	or	r4,r4,r7	# LSW |= t2
 	blr
+#endif 
 
 /*
  * 64-bit comparison: __ucmpdi2(u64 a, u64 b)
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/kernel/module_32.c ../linux-2.6.39.4/arch/powerpc/kernel/module_32.c
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/kernel/module_32.c	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/kernel/module_32.c	2011-10-22 06:38:27.155103324 +0530
@@ -46,9 +46,15 @@
 	r_addend = 0;
 	for (i = 0; i < num; i++)
 		/* Only count 24-bit relocs, others don't need stubs */
+#ifdef CONFIG_INVADER
+		if ( ((ELF32_R_TYPE(rela[i].r_info) == R_PPC_REL24) && (ELF32_R_TYPE(rela[i].r_info) == R_PPC_REL14) &&
+		    (r_info != ELF32_R_SYM(rela[i].r_info) ||
+		     r_addend != rela[i].r_addend)) ) {
+#else
 		if (ELF32_R_TYPE(rela[i].r_info) == R_PPC_REL24 &&
 		    (r_info != ELF32_R_SYM(rela[i].r_info) ||
 		     r_addend != rela[i].r_addend)) {
+#endif
 			_count_relocs++;
 			r_info = ELF32_R_SYM(rela[i].r_info);
 			r_addend = rela[i].r_addend;
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/kernel/prom.c ../linux-2.6.39.4/arch/powerpc/kernel/prom.c
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/kernel/prom.c	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/kernel/prom.c	2011-10-22 12:32:28.777113831 +0530
@@ -103,6 +103,8 @@
 		memcpy(p, initial_boot_params, size);
 		initial_boot_params = (struct boot_param_header *)p;
 		DBG("Moved device tree to 0x%p\n", p);
+// invader debug
+		printk("Moved device tree to 0x%p\n", p);
 	}
 
 	DBG("<- move_device_tree\n");
@@ -300,7 +302,7 @@
 		 */
 		if (initial_boot_params && initial_boot_params->version >= 2) {
 			if (intserv[i] ==
-					initial_boot_params->boot_cpuid_phys) {
+					be32_to_cpu(initial_boot_params->boot_cpuid_phys)) {
 				found = 1;
 				break;
 			}
@@ -344,8 +346,14 @@
 		 * it uses 0x0f000001.
 		 */
 		prop = of_get_flat_dt_prop(node, "cpu-version", NULL);
+		printk(KERN_DEBUG "INVADER PVR: 0x%x\n", be32_to_cpup(prop));
+#ifdef CONFIG_INVADER
+		if (prop && (be32_to_cpup(prop) & 0xff000000) == 0x0f000000)
+			identify_cpu(0, be32_to_cpup(prop));
+#else
 		if (prop && (*prop & 0xff000000) == 0x0f000000)
 			identify_cpu(0, *prop);
+#endif
 
 		identical_pvr_fixup(node);
 	}
@@ -478,6 +486,7 @@
 				if ((base + size) > 0x80000000ul)
 					size = 0x80000000ul - base;
 			}
+			printk(KERN_DEBUG "memblk Add1 base: 0x%llx, size: 0x%llx", base, size);
 			memblock_add(base, size);
 		} while (--rngs);
 	}
@@ -516,6 +525,7 @@
 	memstart_addr = min((u64)memstart_addr, base);
 
 	/* Add the chunk to the MEMBLOCK list */
+	printk(KERN_DEBUG "memblk Add2 base: 0x%llx, size: 0x%llx", base, size);
 	memblock_add(base, size);
 }
 
@@ -541,12 +551,18 @@
 	unsigned long self_base;
 	unsigned long self_size;
 
+	// Invader Change
 	reserve_map = (u64 *)(((unsigned long)initial_boot_params) +
+#ifdef CONFIG_INVADER
+					be32_to_cpu(initial_boot_params->off_mem_rsvmap));
+#else
 					initial_boot_params->off_mem_rsvmap);
+#endif
 
 	/* before we do anything, lets reserve the dt blob */
 	self_base = __pa((unsigned long)initial_boot_params);
-	self_size = initial_boot_params->totalsize;
+	self_size = be32_to_cpu(initial_boot_params->totalsize);
+
 	memblock_reserve(self_base, self_size);
 
 #ifdef CONFIG_BLK_DEV_INITRD
@@ -560,13 +576,18 @@
 	 * Handle the case where we might be booting from an old kexec
 	 * image that setup the mem_rsvmap as pairs of 32-bit values
 	 */
-	if (*reserve_map > 0xffffffffull) {
+	if (be64_to_cpu(*reserve_map) > 0xffffffffull) {
 		u32 base_32, size_32;
 		u32 *reserve_map_32 = (u32 *)reserve_map;
 
 		while (1) {
+#ifdef CONFIG_INVADER
+			base_32 = be32_to_cpu(*(reserve_map_32++));
+			size_32 = be32_to_cpu(*(reserve_map_32++));
+#else
 			base_32 = *(reserve_map_32++);
 			size_32 = *(reserve_map_32++);
+#endif
 			if (size_32 == 0)
 				break;
 			/* skip if the reservation is for the blob */
@@ -579,11 +600,17 @@
 	}
 #endif
 	while (1) {
+// Invader Changes
+#ifdef CONFIG_INVADER
+		base = be64_to_cpu(*(reserve_map++));
+		size = be64_to_cpu(*(reserve_map++));
+#else
 		base = *(reserve_map++);
 		size = *(reserve_map++);
+#endif
 		if (size == 0)
 			break;
-		DBG("reserving: %llx -> %llx\n", base, size);
+		DBG("reserving2: %llx -> %llx\n", base, size);
 		memblock_reserve(base, size);
 	}
 }
@@ -912,8 +939,8 @@
 {
 	struct dentry *d;
 
-	flat_dt_blob.data = initial_boot_params;
-	flat_dt_blob.size = initial_boot_params->totalsize;
+	flat_dt_blob.data = (initial_boot_params);
+	flat_dt_blob.size = be32_to_cpu(initial_boot_params->totalsize);
 
 	d = debugfs_create_blob("flat-device-tree", S_IFREG | S_IRUSR,
 				powerpc_debugfs_root, &flat_dt_blob);
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/kernel/prom_init.c ../linux-2.6.39.4/arch/powerpc/kernel/prom_init.c
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/kernel/prom_init.c	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/kernel/prom_init.c	2011-10-22 06:38:27.610103651 +0530
@@ -789,7 +789,11 @@
 } fake_elf = {
 	.elfhdr = {
 		.e_ident = { 0x7f, 'E', 'L', 'F',
+#ifdef CONFIG_INVADER
+			     ELFCLASS32, ELFDATA2LSB, EV_CURRENT },
+#else
 			     ELFCLASS32, ELFDATA2MSB, EV_CURRENT },
+#endif
 		.e_type = ET_EXEC,	/* yeah right */
 		.e_machine = EM_PPC,
 		.e_version = EV_CURRENT,

diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/kernel/vmlinux.lds.S ../linux-2.6.39.4/arch/powerpc/kernel/vmlinux.lds.S
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/kernel/vmlinux.lds.S	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/kernel/vmlinux.lds.S	2011-10-22 06:38:27.713103244 +0530
@@ -34,11 +34,15 @@
 jiffies = jiffies_64;
 #else
 OUTPUT_ARCH(powerpc:common)
+#ifdef CONFIG_INVADER
 jiffies = jiffies_64 + 4;
+#else
+jiffies = jiffies_64 + 4;
+#endif
 #endif
 SECTIONS
 {
-	. = 0;
+	. = 0x00;
 	reloc_start = .;
 
 	. = KERNELBASE;
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/lib/div64.S ../linux-2.6.39.4/arch/powerpc/lib/div64.S
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/lib/div64.S	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/lib/div64.S	2011-10-22 06:38:28.053112501 +0530
@@ -17,8 +17,13 @@
 #include <asm/processor.h>
 
 _GLOBAL(__div64_32)
+#ifdef CONFIG_INVADER
+	lwz	r5,4(r3)	# get the dividend into r5/r6
+	lwz	r6,0(r3)
+#else
 	lwz	r5,0(r3)	# get the dividend into r5/r6
 	lwz	r6,4(r3)
+#endif
 	cmplw	r5,r4
 	li	r7,0
 	li	r8,0
@@ -53,7 +58,12 @@
 	mullw	r10,r0,r4	# and get the remainder
 	add	r8,r8,r0
 	subf	r6,r10,r6
+#ifdef CONFIG_INVADER
+4:	stw	r7,4(r3)	# return the quotient in *r3
+	stw	r8,0(r3)
+#else
 4:	stw	r7,0(r3)	# return the quotient in *r3
 	stw	r8,4(r3)
+#endif
 	mr	r3,r6		# return the remainder in r3
 	blr
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/Makefile ../linux-2.6.39.4/arch/powerpc/Makefile
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/Makefile	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/Makefile	2011-10-22 06:42:29.464137538 +0530
@@ -17,8 +17,8 @@
 # Set default 32 bits cross compilers for vdso and boot wrapper
 CROSS32_COMPILE ?=
 
-CROSS32CC		:= $(CROSS32_COMPILE)gcc
-CROSS32AR		:= $(CROSS32_COMPILE)ar
+CROSS32CC		:= $(CROSS32_COMPILE)gcc -mlittle-endian -mno-mfcrf
+CROSS32AR		:= $(CROSS32_COMPILE)ar -EL
 
 ifeq ($(HAS_BIARCH),y)
 ifeq ($(CROSS32_COMPILE),)
@@ -57,9 +57,9 @@
 UTS_MACHINE := $(OLDARCH)
 
 ifeq ($(HAS_BIARCH),y)
-override AS	+= -a$(CONFIG_WORD_SIZE)
-override LD	+= -m elf$(CONFIG_WORD_SIZE)ppc
-override CC	+= -m$(CONFIG_WORD_SIZE)
+override AS	+= -a$(CONFIG_WORD_SIZE) -mlittle-endian
+override LD	+= -m elf$(CONFIG_WORD_SIZE)ppc -EL
+override CC	+= -m$(CONFIG_WORD_SIZE) -mlittle-endian -mno-mfcrf
 override AR	:= GNUTARGET=elf$(CONFIG_WORD_SIZE)-powerpc $(AR)
 endif
 
@@ -68,10 +68,10 @@
 LDFLAGS_vmlinux	:= $(LDFLAGS_vmlinux-yy)
 
 CFLAGS-$(CONFIG_PPC64)	:= -mminimal-toc -mtraceback=none  -mcall-aixdesc
-CFLAGS-$(CONFIG_PPC32)	:= -ffixed-r2 -mmultiple
+CFLAGS-$(CONFIG_PPC32)	:= -ffixed-r2
 KBUILD_CPPFLAGS	+= -Iarch/$(ARCH)
 KBUILD_AFLAGS	+= -Iarch/$(ARCH)
-KBUILD_CFLAGS	+= -msoft-float -pipe -Iarch/$(ARCH) $(CFLAGS-y)
+KBUILD_CFLAGS	+= -msoft-float -pipe -Iarch/$(ARCH) $(CFLAGS-y) 
 CPP		= $(CC) -E $(KBUILD_CFLAGS)
 
 CHECKFLAGS	+= -m$(CONFIG_WORD_SIZE) -D__powerpc__ -D__powerpc$(CONFIG_WORD_SIZE)__
@@ -119,7 +119,7 @@
 
 # Never use string load/store instructions as they are
 # often slow when they are implemented at all
-KBUILD_CFLAGS		+= -mno-string
+#KBUILD_CFLAGS		+= -mno-string
 
 ifeq ($(CONFIG_6xx),y)
 KBUILD_CFLAGS		+= -mcpu=powerpc
@@ -130,7 +130,7 @@
 KBUILD_CFLAGS		+= -mno-sched-epilog
 endif
 
-cpu-as-$(CONFIG_4xx)		+= -Wa,-m405
+cpu-as-$(CONFIG_4xx)		+= -Wa,-m440
 cpu-as-$(CONFIG_6xx)		+= -Wa,-maltivec
 cpu-as-$(CONFIG_POWER4)		+= -Wa,-maltivec
 cpu-as-$(CONFIG_E500)		+= -Wa,-me500
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/mm/44x_mmu.c ../linux-2.6.39.4/arch/powerpc/mm/44x_mmu.c
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/mm/44x_mmu.c	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/mm/44x_mmu.c	2011-10-24 17:26:29.012226884 +0530
@@ -165,7 +165,12 @@
 		"tlbwe	%0,%3,2\n"
 		:
 		: "r" (PPC47x_TLB2_SW | PPC47x_TLB2_SR |
+#ifdef CONFIG_INVADER
+		       PPC47x_TLB2_SX | PPC47x_TLB2_E
+#else
 		       PPC47x_TLB2_SX
+#endif
+
 #ifdef CONFIG_SMP
 		       | PPC47x_TLB2_M
 #endif
@@ -223,6 +228,7 @@
 	 */
 	BUG_ON(first_memblock_base != 0);
 
+	printk(KERN_DEBUG "setup_initial_memory_limit: 0x%llx, 0x%llx\n", first_memblock_base, first_memblock_size);
 	/* 44x has a 256M TLB entry pinned at boot */
 	memblock_set_current_limit(min_t(u64, first_memblock_size, PPC_PIN_SIZE));
 }
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/platforms/invader/invader_setup.c ../linux-2.6.39.4/arch/powerpc/platforms/invader/invader_setup.c
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/platforms/invader/invader_setup.c	1970-01-01 05:30:00.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/platforms/invader/invader_setup.c	2011-10-24 15:53:49.024532082 +0530
@@ -0,0 +1,87 @@
+/*
+	LSI HEADER ???
+*/
+
+#include <linux/init.h>
+#include <linux/of_platform.h>
+
+#include <asm/machdep.h>
+#include <asm/prom.h>
+#include <asm/udbg.h>
+#include <asm/time.h>
+#include <asm/mpic.h>
+#include <asm/ppc4xx.h>
+#include <asm/irq.h>
+#include <asm/pci-bridge.h>
+
+#define DEBUG 1
+
+static struct of_device_id invader_of_bus_ids[] = {
+	{ .compatible = "ibm,plb6", },
+        { .compatible = "simple-bus", },
+	{ .compatible = "chrp,open-pic", },
+	{},
+};
+
+static int __init invader_device_probe(void)
+{
+        of_platform_bus_probe(NULL, invader_of_bus_ids, NULL);
+
+        return 0;
+}
+machine_device_initcall(invader, invader_device_probe);
+
+static int __init invader_probe(void)
+{
+	unsigned long root = of_get_flat_dt_root();
+
+	if (!of_flat_dt_is_compatible(root, "LSI,Invader"))
+		return 0;
+
+	ppc_pci_set_flags(PPC_PCI_REASSIGN_ALL_RSRC);
+
+	return 1;
+}
+
+static void __init invader_init_irq(void)
+{
+        struct mpic *mpic;
+        struct resource r;
+        struct device_node *np = NULL;
+
+        /* Find top level interrupt controller */
+        for_each_node_with_property(np, "interrupt-controller") {
+                if (of_get_property(np, "interrupts", NULL) == NULL)
+                        break;
+        }
+        if (np == NULL)
+                panic("Invader: Can't find top level interrupt controller");
+
+        if (of_device_is_compatible(np, "chrp,open-pic")) {
+                /* The MPIC driver will get everything it needs from the
+                 * device-tree, just pass 0 to all arguments
+                 */
+                mpic = mpic_alloc(np, 0, MPIC_PRIMARY|MPIC_WANTS_RESET, 0, 0, " MPIC ");
+                BUG_ON(mpic == NULL);
+                mpic_init(mpic);
+                ppc_md.get_irq = mpic_get_irq;
+        } else
+                panic("Invader: Unrecognized top level interrupt controller");
+
+	printk("\n\n\t\t\tMPIC initialized\n\n\n");
+}
+
+static void __init invader_progress(char *s, unsigned short hex)
+{
+        printk("*** %04x : %s\n", hex, s ? s : "");
+}
+
+define_machine(invader) {
+	.name			= "Invader",
+	.probe			= invader_probe,
+        .progress               = invader_progress,
+        .init_IRQ       	= invader_init_irq,
+        .get_irq        	= mpic_get_irq,
+        .calibrate_decr         = generic_calibrate_decr,
+        .restart                = ppc4xx_reset_system,
+};
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/platforms/invader/Kconfig ../linux-2.6.39.4/arch/powerpc/platforms/invader/Kconfig
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/platforms/invader/Kconfig	1970-01-01 05:30:00.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/platforms/invader/Kconfig	2011-10-22 06:38:25.833134467 +0530
@@ -0,0 +1,8 @@
+config INVADER
+	bool "Invader"
+	depends on PPC_47x
+	help 
+	  This option enabled support for LSI PPC476 "Invader"
+		evaluation board.
+
+
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/platforms/invader/Makefile ../linux-2.6.39.4/arch/powerpc/platforms/invader/Makefile
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/platforms/invader/Makefile	1970-01-01 05:30:00.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/platforms/invader/Makefile	2011-10-22 06:38:25.828374811 +0530
@@ -0,0 +1 @@
+obj-$(CONFIG_INVADER)       += invader_setup.o
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/platforms/Kconfig ../linux-2.6.39.4/arch/powerpc/platforms/Kconfig
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/platforms/Kconfig	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/platforms/Kconfig	2011-10-22 06:38:26.083147732 +0530
@@ -20,6 +20,7 @@
 source "arch/powerpc/platforms/44x/Kconfig"
 source "arch/powerpc/platforms/40x/Kconfig"
 source "arch/powerpc/platforms/amigaone/Kconfig"
+source "arch/powerpc/platforms/invader/Kconfig"
 
 config KVM_GUEST
 	bool "KVM Guest support"
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/platforms/Makefile ../linux-2.6.39.4/arch/powerpc/platforms/Makefile
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/platforms/Makefile	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/platforms/Makefile	2011-10-22 06:38:25.910151396 +0530
@@ -22,3 +22,4 @@
 obj-$(CONFIG_PPC_PS3)		+= ps3/
 obj-$(CONFIG_EMBEDDED6xx)	+= embedded6xx/
 obj-$(CONFIG_AMIGAONE)		+= amigaone/
+obj-$(CONFIG_INVADER)		+= invader/
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/sysdev/dcr.c ../linux-2.6.39.4/arch/powerpc/sysdev/dcr.c
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/sysdev/dcr.c	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/sysdev/dcr.c	2011-10-24 16:41:24.331106125 +0530
@@ -133,7 +133,12 @@
 	if (dr == NULL || ds & 1 || index >= (ds / 8))
 		return 0;
 
+	printk(KERN_DEBUG " dcr-reg: 0x%x", be32_to_cpu(dr[index * 2]));
+#ifdef CONFIG_INVADER
+	return be32_to_cpu(dr[index * 2]);
+#else
 	return dr[index * 2];
+#endif
 }
 EXPORT_SYMBOL_GPL(dcr_resource_start);
 
@@ -145,7 +150,12 @@
 	if (dr == NULL || ds & 1 || index >= (ds / 8))
 		return 0;
 
+	printk(KERN_DEBUG " dcr-reg2: 0x%x", be32_to_cpu(dr[index * 2]+1));
+#ifdef CONFIG_INVADER
+	return be32_to_cpu(dr[index * 2 + 1]);
+#else
 	return dr[index * 2 + 1];
+#endif
 }
 EXPORT_SYMBOL_GPL(dcr_resource_len);
 
@@ -177,6 +187,8 @@
 
 	/* Maybe could do some better range checking here */
 	ret = of_translate_address(dp, p);
+	
+	printk(KERN_DEBUG " translate-dcr-reg: 0x%llx", ret);
 	if (ret != OF_BAD_ADDR)
 		ret += (u64)(stride) * (u64)dcr_n;
 	if (out_stride)
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/sysdev/mpic.c ../linux-2.6.39.4/arch/powerpc/sysdev/mpic.c
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/sysdev/mpic.c	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/sysdev/mpic.c	2011-10-25 18:07:53.637770104 +0530
@@ -296,7 +296,7 @@
 
 	dbasep = of_get_property(node, "dcr-reg", NULL);
 
-	rb->dhost = dcr_map(node, *dbasep + offset, size);
+	rb->dhost = dcr_map(node, be32_to_cpup(dbasep) + offset, size);
 	BUG_ON(!DCR_MAP_OK(rb->dhost));
 }
 
@@ -1179,8 +1179,9 @@
 	 */
 	if (paddr == 0 && !(mpic->flags & MPIC_USES_DCR)) {
 		const u32 *reg = of_get_property(node, "reg", NULL);
+		printk(KERN_DEBUG "mpic: reg: 0x%x\n", *reg);
 		BUG_ON(reg == NULL);
-		paddr = of_translate_address(node, reg);
+		paddr = be32_to_cpu(of_translate_address(node, reg));
 		BUG_ON(paddr == OF_BAD_ADDR);
 	}
 
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/sysdev/ppc4xx_soc.c ../linux-2.6.39.4/arch/powerpc/sysdev/ppc4xx_soc.c
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/sysdev/ppc4xx_soc.c	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/sysdev/ppc4xx_soc.c	2011-10-25 18:04:40.509769915 +0530
@@ -93,7 +93,11 @@
 		of_node_put(np);
 		return -ENODEV;
 	}
+#ifdef CONFIG_INVADER
+	l2_size = be32_to_cpu(prop[0]);
+#else
 	l2_size = prop[0];
+#endif
 
 	/* Map DCRs */
 	dcrreg = of_get_property(np, "dcr-reg", &len);
@@ -103,8 +107,13 @@
 		of_node_put(np);
 		return -ENODEV;
 	}
+#ifdef CONFIG_INVADER
+	dcrbase_isram = be32_to_cpu(dcrreg[0]);
+	dcrbase_l2c = be32_to_cpu(dcrreg[2]);
+#else
 	dcrbase_isram = dcrreg[0];
 	dcrbase_l2c = dcrreg[2];
+#endif
 
 	/* Get and map irq number from device tree */
 	irq = irq_of_parse_and_map(np, 0);
@@ -199,6 +208,7 @@
 	struct device_node *np;
 	u32 reset_type = DBCR0_RST_SYSTEM;
 	const u32 *prop;
+	u32	propVal=0;
 
 	np = of_find_node_by_type(NULL, "cpu");
 	if (np) {
@@ -210,8 +220,17 @@
 		 * 2 - PPC4xx chip reset
 		 * 3 - PPC4xx system reset (default)
 		 */
+#ifdef CONFIG_INVADER
+		if (prop)
+		{
+			propVal = be32_to_cpup(prop);
+			if (((propVal>= 1) && (propVal <= 3)))
+				reset_type = propVal << 28;
+		}
+#else
 		if ((prop) && ((prop[0] >= 1) && (prop[0] <= 3)))
 			reset_type = prop[0] << 28;
+#endif
 	}
 
 	mtspr(SPRN_DBCR0, mfspr(SPRN_DBCR0) | reset_type);
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/fs/ext2/balloc.c ../linux-2.6.39.4/fs/ext2/balloc.c
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/fs/ext2/balloc.c	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/fs/ext2/balloc.c	2011-10-22 06:38:04.625107806 +0530
@@ -18,6 +18,9 @@
 #include <linux/buffer_head.h>
 #include <linux/capability.h>
 
+#ifdef CONFIG_INVADER
+//#include <asm-generic/bitops/le.h>
+#endif
 /*
  * balloc.c contains the blocks allocation and deallocation routines
  */
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/include/asm-generic/bitops/non-atomic.h ../linux-2.6.39.4/include/asm-generic/bitops/non-atomic.h
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/include/asm-generic/bitops/non-atomic.h	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/include/asm-generic/bitops/non-atomic.h	2011-10-22 12:40:27.954406170 +0530
@@ -105,4 +105,25 @@
 	return 1UL & (addr[BIT_WORD(nr)] >> (nr & (BITS_PER_LONG-1)));
 }
 
+static inline int test_bit_dbg(int nr, const volatile unsigned long *addr, volatile unsigned long *ret, volatile unsigned long *ret1, volatile unsigned long *ret2)
+{
+	if(ret)
+		*ret = (addr[BIT_WORD(nr)] >> (nr & (BITS_PER_LONG-1)));
+
+	if (ret1)
+		*ret1 = 1UL&(*ret);
+
+	if (ret2)
+		*ret2 = 1UL & (addr[BIT_WORD(nr)] >> (nr & (BITS_PER_LONG-1)));
+
+#ifdef CONFIG_INVADER
+        return (addr[BIT_WORD(nr)] >> (nr & (BITS_PER_LONG-1)));
+#else
+        return 1UL & (addr[BIT_WORD(nr)] >> (nr & (BITS_PER_LONG-1)));
+#endif
+}
+
+
+
+
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/init/main.c ../linux-2.6.39.4/init/main.c
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/init/main.c	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/init/main.c	2011-10-30 14:04:41.250103375 +0530
@@ -664,7 +664,8 @@
 	int count = preempt_count();
 	int ret;
 
-	if (initcall_debug)
+//	if (initcall_debug)
+	if (1)
 		ret = do_one_initcall_debug(fn);
 	else
 		ret = fn();
@@ -729,6 +730,7 @@
 static void run_init_process(const char *init_filename)
 {
 	argv_init[0] = init_filename;
+	printk(KERN_DEBUG "RUNNING run_init_process %s\n", init_filename);
 	kernel_execve(init_filename, argv_init, envp_init);
 }
 
@@ -747,6 +749,7 @@
 
 	current->signal->flags |= SIGNAL_UNKILLABLE;
 
+	printk(KERN_DEBUG "ramdisk_execute_command: %s, execute_command: %s\n",ramdisk_execute_command ,execute_command);
 	if (ramdisk_execute_command) {
 		run_init_process(ramdisk_execute_command);
 		printk(KERN_WARNING "Failed to execute %s\n",
@@ -765,10 +768,10 @@
 					"defaults...\n", execute_command);
 	}
 	run_init_process("/sbin/init");
-	run_init_process("/etc/init");
+/*	run_init_process("/etc/init");
 	run_init_process("/bin/init");
 	run_init_process("/bin/sh");
-
+*/
 	panic("No init found.  Try passing init= option to kernel. "
 	      "See Linux Documentation/init.txt for guidance.");
 }
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/kernel/printk.c ../linux-2.6.39.4/kernel/printk.c
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/kernel/printk.c	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/kernel/printk.c	2011-10-24 11:52:01.814164824 +0530
@@ -1485,7 +1485,9 @@
 	}
 	console_unlock();
 	console_sysfs_notify();
-
+#ifdef CONFIG_INVADER
+	keep_bootcon = 1;
+#endif
 	/*
 	 * By unregistering the bootconsoles after we enable the real console
 	 * we get the "console xxx enabled" message on all the consoles -
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/Makefile ../linux-2.6.39.4/Makefile
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/Makefile	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/Makefile	2011-10-22 06:39:21.397105230 +0530
@@ -237,6 +237,7 @@
 
 HOSTCC       = gcc
 HOSTCXX      = g++
+#Invader Changes
 HOSTCFLAGS   = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer
 HOSTCXXFLAGS = -O2
 
@@ -320,9 +321,9 @@
 
 # Make variables (CC, etc...)
 
-AS		= $(CROSS_COMPILE)as
-LD		= $(CROSS_COMPILE)ld
-CC		= $(CROSS_COMPILE)gcc
+AS		= $(CROSS_COMPILE)as -mlittle-endian
+LD		= $(CROSS_COMPILE)ld -EL
+CC		= $(CROSS_COMPILE)gcc -mlittle-endian -mno-mfcrf
 CPP		= $(CC) -E
 AR		= $(CROSS_COMPILE)ar
 NM		= $(CROSS_COMPILE)nm
@@ -359,10 +360,12 @@
 		   -fno-strict-aliasing -fno-common \
 		   -Werror-implicit-function-declaration \
 		   -Wno-format-security \
-		   -fno-delete-null-pointer-checks
+		   -fno-delete-null-pointer-checks \
+		   -mlittle-endian \
+		   -fsigned-char
 KBUILD_AFLAGS_KERNEL :=
 KBUILD_CFLAGS_KERNEL :=
-KBUILD_AFLAGS   := -D__ASSEMBLY__
+KBUILD_AFLAGS   := -D__ASSEMBLY__ -mlittle-endian
 KBUILD_AFLAGS_MODULE  := -DMODULE
 KBUILD_CFLAGS_MODULE  := -DMODULE
 KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds
@@ -545,6 +548,7 @@
 ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
 KBUILD_CFLAGS	+= -Os
 else
+#Invader Changes
 KBUILD_CFLAGS	+= -O2
 endif
 


^ permalink raw reply

* What does rmo/tce stand for in powerpc?
From: Ryan Wang @ 2011-11-01  6:25 UTC (permalink / raw)
  To: linuxppc-dev

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

Hi,

In kernel source comments, I saw the words:
''

alloc_top is set to the top of RMO, eventually shrink down if the
<http://lxr.linux.no/linux+*/arch/powerpc/kernel/prom_init.c#L972>TCEs
overlap

''

I wonder what does RMO mean, and TCE?

thanks,

[-- Attachment #2: Type: text/html, Size: 484 bytes --]

^ permalink raw reply

* Re: powerpc 476, Little-endian, pte fault
From: Peter Bergner @ 2011-11-01 13:44 UTC (permalink / raw)
  To: Santosh Kumar; +Cc: Michael Neuling, Ian Munsie, linux-kernel, linuxppc-dev
In-Reply-To: <CAJw04pBpXsTS4=FeG5ZF3nqORXhiOZ=3V60cFCuJfgTiJcCh2g@mail.gmail.com>

On Tue, 2011-11-01 at 08:32 +0530, Santosh Kumar wrote:
> I am using the same compiler as 476 & 440 instruction is almost the same.

Well the 476 implements ISA 2.05, which I think has added a fair amount
over the 440.  Not to mention the 476 core that has been released has
a FP unit.  I'll note that GCC has support for a 476 with and without
a FP unit, even though AFAIK, we only ship one with a FP unit.
The relevant options are -mcpu=476 (no FP unit) and -mcpu=476fp
(with FP unit).  Basically, -mcpu=476 is equivalent to
-mcpu=476fp -msoft-float.



> @@ -53,7 +58,12 @@
>         mullw   r10,r0,r4       # and get the remainder
>         add     r8,r8,r0
>         subf    r6,r10,r6
> +#ifdef CONFIG_INVADER
>  4:     stw     r7,0(r3)        # return the quotient in *r3
>         stw     r8,4(r3)
> +#else
> +4:     stw     r7,0(r3)        # return the quotient in *r3
> +       stw     r8,4(r3)
> +#endif
>         mr      r3,r6           # return the remainder in r3
>         blr

This looks like a typo, since you didn't actually swap the offsets
on the stw's like you did in all of the other patch hunks.


Peter

^ permalink raw reply

* Re: powerpc 476, Little-endian, pte fault
From: Santosh Kumar @ 2011-11-01 17:14 UTC (permalink / raw)
  To: Peter Bergner; +Cc: Michael Neuling, Ian Munsie, linux-kernel, linuxppc-dev
In-Reply-To: <1320155074.2996.190.camel@otta>

> The relevant options are -mcpu=3D476 (no FP unit) and -mcpu=3D476fp> (wit=
h FP unit). =A0Basically, -mcpu=3D476 is equivalent to> -mcpu=3D476fp -msof=
t-float.
Yes what you have mentioned is right.

I had a problem configuring the GCC for 476 in little endian mode,
therefore I am using 440 compiler. As this compiler doesn't accept
-mcpu=3D476 i am using -mcpu=3D440.

So is this PTE fault related to the compiler options?

Thanks,
Santosh Kumar .A

On 1 November 2011 19:14, Peter Bergner <bergner@vnet.ibm.com> wrote:
> On Tue, 2011-11-01 at 08:32 +0530, Santosh Kumar wrote:
>> I am using the same compiler as 476 & 440 instruction is almost the same=
.
>
> Well the 476 implements ISA 2.05, which I think has added a fair amount
> over the 440. =A0Not to mention the 476 core that has been released has
> a FP unit. =A0I'll note that GCC has support for a 476 with and without
> a FP unit, even though AFAIK, we only ship one with a FP unit.
> The relevant options are -mcpu=3D476 (no FP unit) and -mcpu=3D476fp
> (with FP unit). =A0Basically, -mcpu=3D476 is equivalent to
> -mcpu=3D476fp -msoft-float.
>
>
>
>> @@ -53,7 +58,12 @@
>> =A0 =A0 =A0 =A0 mullw =A0 r10,r0,r4 =A0 =A0 =A0 # and get the remainder
>> =A0 =A0 =A0 =A0 add =A0 =A0 r8,r8,r0
>> =A0 =A0 =A0 =A0 subf =A0 =A0r6,r10,r6
>> +#ifdef CONFIG_INVADER
>> =A04: =A0 =A0 stw =A0 =A0 r7,0(r3) =A0 =A0 =A0 =A0# return the quotient =
in *r3
>> =A0 =A0 =A0 =A0 stw =A0 =A0 r8,4(r3)
>> +#else
>> +4: =A0 =A0 stw =A0 =A0 r7,0(r3) =A0 =A0 =A0 =A0# return the quotient in=
 *r3
>> + =A0 =A0 =A0 stw =A0 =A0 r8,4(r3)
>> +#endif
>> =A0 =A0 =A0 =A0 mr =A0 =A0 =A0r3,r6 =A0 =A0 =A0 =A0 =A0 # return the rem=
ainder in r3
>> =A0 =A0 =A0 =A0 blr
>
> This looks like a typo, since you didn't actually swap the offsets
> on the stw's like you did in all of the other patch hunks.
>
>
> Peter
>
>
>
>

^ permalink raw reply

* Re: What does rmo/tce stand for in powerpc?
From: Nishanth Aravamudan @ 2011-11-01 17:25 UTC (permalink / raw)
  To: Ryan Wang; +Cc: linuxppc-dev
In-Reply-To: <CAPxxNQnhXaKJ5ve-=0qwChuuvDj_027RM2pSD43DEf6BZbaHDA@mail.gmail.com>

Hi Ryan,

On 01.11.2011 [14:25:43 +0800], Ryan Wang wrote:
> Hi,
> 
> In kernel source comments, I saw the words:
> ''
> 
> alloc_top is set to the top of RMO, eventually shrink down if the
> <http://lxr.linux.no/linux+*/arch/powerpc/kernel/prom_init.c#L972>TCEs
> overlap
> 
> ''
> 
> I wonder what does RMO mean, and TCE?

RMO = Real Mode Offset -- deprecated in terms of Real Mode Area in PAPR.

TCE = Translation Control Entry

You should be able to find descriptions of both in PAPR.

Thanks,
Nish

-- 
Nishanth Aravamudan <nacc@us.ibm.com>
IBM Linux Technology Center

^ permalink raw reply

* Re: powerpc 476, Little-endian, pte fault
From: Peter Bergner @ 2011-11-01 18:44 UTC (permalink / raw)
  To: Santosh Kumar; +Cc: Michael Neuling, Ian Munsie, linux-kernel, linuxppc-dev
In-Reply-To: <CAJw04pA3mDOgHrOvPxeXR8Fw6Jn1kBz9qSrgq2vJ7HPpyQwSbg@mail.gmail.com>

On Tue, 2011-11-01 at 22:44 +0530, Santosh Kumar wrote:
> I had a problem configuring the GCC for 476 in little endian mode,

What type of problem?  I assume the binutils you are building
against has 476 support too, correct?  You'll need that.


> So is this PTE fault related to the compiler options?

This could be caused by anything, but I highly doubt this is
caused by a compiler option issue.  My $$ are that you either
have a bug in your kernel patch or there are more places in
the kernel source that need patching.

Peter

^ permalink raw reply

* Re: Regression: patch " hvc_console: display printk messages on console." causing infinite loop with 3.2-rc0 + Xen.
From: Stephen Rothwell @ 2011-11-02  1:13 UTC (permalink / raw)
  To: Greg KH
  Cc: xen-devel, Konrad Rzeszutek Wilk, Rusty Russell, miche,
	linux-kernel, virtualization, Linus, Anton Blanchard, Amit Shah,
	ppc-dev
In-Reply-To: <20111027054806.GA1377@suse.de>

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

Hi Greg,

On Thu, 27 Oct 2011 07:48:06 +0200 Greg KH <gregkh@suse.de> wrote:
>
> On Thu, Oct 27, 2011 at 01:30:08AM -0400, Konrad Rzeszutek Wilk wrote:
> > Hey Miche.
> > 
> > The git commit 361162459f62dc0826b82c9690a741a940f457f0:
> > 
> >     hvc_console: display printk messages on console.
> > 
> > is causing an infinite loop when booting Linux under Xen, as so:
> 
> Ick, not good, thanks for letting us know.

Indeed. I am wondering why it was put in a tree and sent to Linus without
any Acks or even being replied to by anyone.  It appeared in the tty tree
between Oct 14 and Oct 25 (while I was unfortunately on vacation).  If
anyone had tried to boot this on any PowerPC server, it would have been
immediately obvious (as it was when I booted Linus' tree last night).

And the original author expressed doubts as to his understanding of how
it should all work anyway.

Just a little more care, please.

I would vote for reverting the original and having it resubmitted with
corrections at some later date.
-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply


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