All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/6] MIPS: APRP: Enable APRP for platforms with a CM.
@ 2013-10-17  2:14 Steven J. Hill
  2013-10-17  2:14 ` [PATCH 1/6] MIPS: APRP: Split VPE loader into separate files Steven J. Hill
                   ` (5 more replies)
  0 siblings, 6 replies; 20+ messages in thread
From: Steven J. Hill @ 2013-10-17  2:14 UTC (permalink / raw)
  To: linux-mips; +Cc: Steven J. Hill, ralf

From: "Steven J. Hill" <Steven.Hill@imgtec.com>

The APRP model makes it possible that one or more CPUs to run the
Linux kernel and a dedicated CPU runs a special real-time or signal
processing program.

This patchset adds the following to the current APRP support:
1. Add CM and multicore APRP support.
2. Several bug fixes.
3. Running floating point heavy jobs on the RP side.
4. Waking up the RP side read by interrupt.

Deng-Cheng Zhu (5):
  MIPS: APRP: Split VPE loader into separate files.
  MIPS: APRP: Add VPE loader support for CMP platforms.
  MIPS: APRP: Split RTLX support into separate files.
  MIPS: APRP: Add RTLX API support for CMP platforms.
  MIPS: APRP: Malta Add support for Malta CMP platform.

Steven J. Hill (1):
  MIPS: APRP: Code formatting clean-ups.

 arch/mips/include/asm/amon.h     |   15 +-
 arch/mips/include/asm/rtlx.h     |   49 ++-
 arch/mips/include/asm/vpe.h      |  136 +++++-
 arch/mips/kernel/Makefile        |    4 +-
 arch/mips/kernel/rtlx-cmp.c      |  120 +++++
 arch/mips/kernel/rtlx-mt.c       |  152 +++++++
 arch/mips/kernel/rtlx.c          |  275 +++---------
 arch/mips/kernel/vpe-cmp.c       |  184 ++++++++
 arch/mips/kernel/vpe-mt.c        |  527 ++++++++++++++++++++++
 arch/mips/kernel/vpe.c           |  893 ++++++--------------------------------
 arch/mips/mti-malta/malta-amon.c |   48 +-
 arch/mips/mti-malta/malta-int.c  |  127 +++---
 12 files changed, 1435 insertions(+), 1095 deletions(-)
 create mode 100644 arch/mips/kernel/rtlx-cmp.c
 create mode 100644 arch/mips/kernel/rtlx-mt.c
 create mode 100644 arch/mips/kernel/vpe-cmp.c
 create mode 100644 arch/mips/kernel/vpe-mt.c

-- 
1.7.9.5

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

* [PATCH 1/6] MIPS: APRP: Split VPE loader into separate files.
  2013-10-17  2:14 [PATCH 0/6] MIPS: APRP: Enable APRP for platforms with a CM Steven J. Hill
@ 2013-10-17  2:14 ` Steven J. Hill
  2013-10-17  2:14 ` [PATCH 2/6] MIPS: APRP: Add VPE loader support for CMP platforms Steven J. Hill
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 20+ messages in thread
From: Steven J. Hill @ 2013-10-17  2:14 UTC (permalink / raw)
  To: linux-mips; +Cc: Deng-Cheng Zhu, ralf, Steven J. Hill

From: Deng-Cheng Zhu <dengcheng.zhu@imgtec.com>

Split the VPE functionality in preparation for adding support
for CMP platforms. Common functions remain in the original file
and a new file contains code specific to platforms that do not
have a CMP present.

Signed-off-by: Deng-Cheng Zhu <dengcheng.zhu@imgtec.com>
Signed-off-by: Steven J. Hill <Steven.Hill@imgtec.com>
Reviewed-by: Qais Yousef <Qais.Yousef@imgtec.com>
---
 arch/mips/include/asm/vpe.h |  117 +++++++-
 arch/mips/kernel/Makefile   |    2 +-
 arch/mips/kernel/vpe-mt.c   |  523 ++++++++++++++++++++++++++++++++++
 arch/mips/kernel/vpe.c      |  647 ++-----------------------------------------
 4 files changed, 655 insertions(+), 634 deletions(-)
 create mode 100644 arch/mips/kernel/vpe-mt.c

diff --git a/arch/mips/include/asm/vpe.h b/arch/mips/include/asm/vpe.h
index c6e1b96..becd555 100644
--- a/arch/mips/include/asm/vpe.h
+++ b/arch/mips/include/asm/vpe.h
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2005 MIPS Technologies, Inc.  All rights reserved.
+ * Copyright (C) 2013 Imagination Technologies Ltd.
  *
  *  This program is free software; you can distribute it and/or modify it
  *  under the terms of the GNU General Public License (Version 2) as
@@ -19,6 +20,88 @@
 #ifndef _ASM_VPE_H
 #define _ASM_VPE_H
 
+#include <linux/init.h>
+#include <linux/list.h>
+#include <linux/smp.h>
+#include <linux/spinlock.h>
+
+#define VPE_MODULE_NAME "vpe"
+#define VPE_MODULE_MINOR 1
+
+/* grab the likely amount of memory we will need. */
+#ifdef CONFIG_MIPS_VPE_LOADER_TOM
+#define P_SIZE (2 * 1024 * 1024)
+#else
+/* add an overhead to the max kmalloc size for non-striped symbols/etc */
+#define P_SIZE (256 * 1024)
+#endif
+
+#define MAX_VPES 16
+#define VPE_PATH_MAX 256
+
+static inline int aprp_cpu_index(void)
+{
+#ifdef CONFIG_MIPS_CMP
+	return setup_max_cpus;
+#else
+	extern int tclimit;
+	return tclimit;
+#endif
+}
+
+enum vpe_state {
+	VPE_STATE_UNUSED = 0,
+	VPE_STATE_INUSE,
+	VPE_STATE_RUNNING
+};
+
+enum tc_state {
+	TC_STATE_UNUSED = 0,
+	TC_STATE_INUSE,
+	TC_STATE_RUNNING,
+	TC_STATE_DYNAMIC
+};
+
+struct vpe {
+	enum vpe_state state;
+
+	/* (device) minor associated with this vpe */
+	int minor;
+
+	/* elfloader stuff */
+	void *load_addr;
+	unsigned long len;
+	char *pbuffer;
+	unsigned long plen;
+	unsigned int uid, gid;
+	char cwd[VPE_PATH_MAX];
+
+	unsigned long __start;
+
+	/* tc's associated with this vpe */
+	struct list_head tc;
+
+	/* The list of vpe's */
+	struct list_head list;
+
+	/* shared symbol address */
+	void *shared_ptr;
+
+	/* the list of who wants to know when something major happens */
+	struct list_head notify;
+
+	unsigned int ntcs;
+};
+
+struct tc {
+	enum tc_state state;
+	int index;
+
+	struct vpe *pvpe;	/* parent VPE */
+	struct list_head tc;	/* The list of TC's with this VPE */
+	struct list_head list;	/* The global list of tc's */
+};
+
 struct vpe_notifications {
 	void (*start)(int vpe);
 	void (*stop)(int vpe);
@@ -26,12 +109,36 @@ struct vpe_notifications {
 	struct list_head list;
 };
 
+struct vpe_control {
+	spinlock_t vpe_list_lock;
+	struct list_head vpe_list;      /* Virtual processing elements */
+	spinlock_t tc_list_lock;
+	struct list_head tc_list;       /* Thread contexts */
+};
+
+extern unsigned long physical_memsize;
+extern struct vpe_control vpecontrol;
+extern const struct file_operations vpe_fops;
+
+int vpe_notify(int index, struct vpe_notifications *notify);
+
+void *vpe_get_shared(int index);
+int vpe_getuid(int index);
+int vpe_getgid(int index);
+char *vpe_getcwd(int index);
+
+struct vpe *get_vpe(int minor);
+struct tc *get_tc(int index);
+struct vpe *alloc_vpe(int minor);
+struct tc *alloc_tc(int index);
+void release_vpe(struct vpe *v);
 
-extern int vpe_notify(int index, struct vpe_notifications *notify);
+void *alloc_progmem(unsigned long len);
+void release_progmem(void *ptr);
 
-extern void *vpe_get_shared(int index);
-extern int vpe_getuid(int index);
-extern int vpe_getgid(int index);
-extern char *vpe_getcwd(int index);
+int __weak vpe_run(struct vpe *v);
+void cleanup_tc(struct tc *tc);
 
+int __init vpe_module_init(void);
+void __exit vpe_module_exit(void);
 #endif /* _ASM_VPE_H */
diff --git a/arch/mips/kernel/Makefile b/arch/mips/kernel/Makefile
index 1c1b717..51f9117 100644
--- a/arch/mips/kernel/Makefile
+++ b/arch/mips/kernel/Makefile
@@ -54,7 +54,7 @@ obj-$(CONFIG_MIPS_MT_SMP)	+= smp-mt.o
 obj-$(CONFIG_MIPS_CMP)		+= smp-cmp.o
 obj-$(CONFIG_CPU_MIPSR2)	+= spram.o
 
-obj-$(CONFIG_MIPS_VPE_LOADER)	+= vpe.o
+obj-$(CONFIG_MIPS_VPE_LOADER)	+= vpe.o vpe-mt.o
 obj-$(CONFIG_MIPS_VPE_APSP_API) += rtlx.o
 
 obj-$(CONFIG_I8259)		+= i8259.o
diff --git a/arch/mips/kernel/vpe-mt.c b/arch/mips/kernel/vpe-mt.c
new file mode 100644
index 0000000..45abe9a
--- /dev/null
+++ b/arch/mips/kernel/vpe-mt.c
@@ -0,0 +1,523 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2004, 2005 MIPS Technologies, Inc.  All rights reserved.
+ * Copyright (C) 2013 Imagination Technologies Ltd.
+ */
+#include <linux/kernel.h>
+#include <linux/device.h>
+#include <linux/fs.h>
+#include <linux/slab.h>
+#include <linux/export.h>
+
+#include <asm/mipsregs.h>
+#include <asm/mipsmtregs.h>
+#include <asm/mips_mt.h>
+#include <asm/vpe.h>
+
+static int major;
+
+/* The number of TCs and VPEs physically available on the core */
+static int hw_tcs, hw_vpes;
+
+/* We are prepared so configure and start the VPE... */
+int vpe_run(struct vpe *v)
+{
+	unsigned long flags, val, dmt_flag;
+	struct vpe_notifications *n;
+	unsigned int vpeflags;
+	struct tc *t;
+
+	/* check we are the Master VPE */
+	local_irq_save(flags);
+	val = read_c0_vpeconf0();
+	if (!(val & VPECONF0_MVP)) {
+		pr_warn("VPE loader: only Master VPE's are able to config MT\n");
+		local_irq_restore(flags);
+
+		return -1;
+	}
+
+	dmt_flag = dmt();
+	vpeflags = dvpe();
+
+	if (list_empty(&v->tc)) {
+		evpe(vpeflags);
+		emt(dmt_flag);
+		local_irq_restore(flags);
+
+		pr_warn("VPE loader: No TC's associated with VPE %d\n",
+			v->minor);
+
+		return -ENOEXEC;
+	}
+
+	t = list_first_entry(&v->tc, struct tc, tc);
+
+	/* Put MVPE's into 'configuration state' */
+	set_c0_mvpcontrol(MVPCONTROL_VPC);
+
+	settc(t->index);
+
+	/* should check it is halted, and not activated */
+	if ((read_tc_c0_tcstatus() & TCSTATUS_A) ||
+	   !(read_tc_c0_tchalt() & TCHALT_H)) {
+		evpe(vpeflags);
+		emt(dmt_flag);
+		local_irq_restore(flags);
+
+		pr_warn("VPE loader: TC %d is already active!\n",
+			t->index);
+
+		return -ENOEXEC;
+	}
+
+	/*
+	 * Write the address we want it to start running from in the TCPC
+	 * register.
+	 */
+	write_tc_c0_tcrestart((unsigned long)v->__start);
+	write_tc_c0_tccontext((unsigned long)0);
+
+	/*
+	 * Mark the TC as activated, not interrupt exempt and not dynamically
+	 * allocatable
+	 */
+	val = read_tc_c0_tcstatus();
+	val = (val & ~(TCSTATUS_DA | TCSTATUS_IXMT)) | TCSTATUS_A;
+	write_tc_c0_tcstatus(val);
+
+	write_tc_c0_tchalt(read_tc_c0_tchalt() & ~TCHALT_H);
+
+	/*
+	 * The sde-kit passes 'memsize' to __start in $a3, so set something
+	 * here...  Or set $a3 to zero and define DFLT_STACK_SIZE and
+	 * DFLT_HEAP_SIZE when you compile your program
+	 */
+	mttgpr(6, v->ntcs);
+	mttgpr(7, physical_memsize);
+
+	/* set up VPE1 */
+	/*
+	 * bind the TC to VPE 1 as late as possible so we only have the final
+	 * VPE registers to set up, and so an EJTAG probe can trigger on it
+	 */
+	write_tc_c0_tcbind((read_tc_c0_tcbind() & ~TCBIND_CURVPE) | 1);
+
+	write_vpe_c0_vpeconf0(read_vpe_c0_vpeconf0() & ~(VPECONF0_VPA));
+
+	back_to_back_c0_hazard();
+
+	/* Set up the XTC bit in vpeconf0 to point at our tc */
+	write_vpe_c0_vpeconf0((read_vpe_c0_vpeconf0() & ~(VPECONF0_XTC))
+			      | (t->index << VPECONF0_XTC_SHIFT));
+
+	back_to_back_c0_hazard();
+
+	/* enable this VPE */
+	write_vpe_c0_vpeconf0(read_vpe_c0_vpeconf0() | VPECONF0_VPA);
+
+	/* clear out any left overs from a previous program */
+	write_vpe_c0_status(0);
+	write_vpe_c0_cause(0);
+
+	/* take system out of configuration state */
+	clear_c0_mvpcontrol(MVPCONTROL_VPC);
+
+	/*
+	 * SMTC/SMVP kernels manage VPE enable independently,
+	 * but uniprocessor kernels need to turn it on, even
+	 * if that wasn't the pre-dvpe() state.
+	 */
+#ifdef CONFIG_SMP
+	evpe(vpeflags);
+#else
+	evpe(EVPE_ENABLE);
+#endif
+	emt(dmt_flag);
+	local_irq_restore(flags);
+
+	list_for_each_entry(n, &v->notify, list)
+		n->start(VPE_MODULE_MINOR);
+
+	return 0;
+}
+
+void cleanup_tc(struct tc *tc)
+{
+	unsigned long flags;
+	unsigned int mtflags, vpflags;
+	int tmp;
+
+	local_irq_save(flags);
+	mtflags = dmt();
+	vpflags = dvpe();
+	/* Put MVPE's into 'configuration state' */
+	set_c0_mvpcontrol(MVPCONTROL_VPC);
+
+	settc(tc->index);
+	tmp = read_tc_c0_tcstatus();
+
+	/* mark not allocated and not dynamically allocatable */
+	tmp &= ~(TCSTATUS_A | TCSTATUS_DA);
+	tmp |= TCSTATUS_IXMT;	/* interrupt exempt */
+	write_tc_c0_tcstatus(tmp);
+
+	write_tc_c0_tchalt(TCHALT_H);
+	mips_ihb();
+
+	clear_c0_mvpcontrol(MVPCONTROL_VPC);
+	evpe(vpflags);
+	emt(mtflags);
+	local_irq_restore(flags);
+}
+
+/* module wrapper entry points */
+/* give me a vpe */
+void *vpe_alloc(void)
+{
+	int i;
+	struct vpe *v;
+
+	/* find a vpe */
+	for (i = 1; i < MAX_VPES; i++) {
+		v = get_vpe(i);
+		if (v != NULL) {
+			v->state = VPE_STATE_INUSE;
+			return v;
+		}
+	}
+	return NULL;
+}
+EXPORT_SYMBOL(vpe_alloc);
+
+/* start running from here */
+int vpe_start(void *vpe, unsigned long start)
+{
+	struct vpe *v = vpe;
+
+	v->__start = start;
+	return vpe_run(v);
+}
+EXPORT_SYMBOL(vpe_start);
+
+/* halt it for now */
+int vpe_stop(void *vpe)
+{
+	struct vpe *v = vpe;
+	struct tc *t;
+	unsigned int evpe_flags;
+
+	evpe_flags = dvpe();
+
+	t = list_entry(v->tc.next, struct tc, tc);
+	if (t != NULL) {
+		settc(t->index);
+		write_vpe_c0_vpeconf0(read_vpe_c0_vpeconf0() & ~VPECONF0_VPA);
+	}
+
+	evpe(evpe_flags);
+
+	return 0;
+}
+EXPORT_SYMBOL(vpe_stop);
+
+/* I've done with it thank you */
+int vpe_free(void *vpe)
+{
+	struct vpe *v = vpe;
+	struct tc *t;
+	unsigned int evpe_flags;
+
+	t = list_entry(v->tc.next, struct tc, tc);
+	if (t == NULL)
+		return -ENOEXEC;
+
+	evpe_flags = dvpe();
+
+	/* Put MVPE's into 'configuration state' */
+	set_c0_mvpcontrol(MVPCONTROL_VPC);
+
+	settc(t->index);
+	write_vpe_c0_vpeconf0(read_vpe_c0_vpeconf0() & ~VPECONF0_VPA);
+
+	/* halt the TC */
+	write_tc_c0_tchalt(TCHALT_H);
+	mips_ihb();
+
+	/* mark the TC unallocated */
+	write_tc_c0_tcstatus(read_tc_c0_tcstatus() & ~TCSTATUS_A);
+
+	v->state = VPE_STATE_UNUSED;
+
+	clear_c0_mvpcontrol(MVPCONTROL_VPC);
+	evpe(evpe_flags);
+
+	return 0;
+}
+EXPORT_SYMBOL(vpe_free);
+
+static ssize_t store_kill(struct device *dev, struct device_attribute *attr,
+			  const char *buf, size_t len)
+{
+	struct vpe *vpe = get_vpe(aprp_cpu_index());
+	struct vpe_notifications *notifier;
+
+	list_for_each_entry(notifier, &vpe->notify, list)
+		notifier->stop(aprp_cpu_index());
+
+	release_progmem(vpe->load_addr);
+	cleanup_tc(get_tc(aprp_cpu_index()));
+	vpe_stop(vpe);
+	vpe_free(vpe);
+
+	return len;
+}
+static DEVICE_ATTR(kill, S_IWUSR, NULL, store_kill);
+
+static ssize_t ntcs_show(struct device *cd, struct device_attribute *attr,
+			 char *buf)
+{
+	struct vpe *vpe = get_vpe(aprp_cpu_index());
+
+	return sprintf(buf, "%d\n", vpe->ntcs);
+}
+
+static ssize_t ntcs_store(struct device *dev, struct device_attribute *attr,
+			  const char *buf, size_t len)
+{
+	struct vpe *vpe = get_vpe(aprp_cpu_index());
+	unsigned long new;
+	int ret;
+
+	ret = kstrtoul(buf, 0, &new);
+	if (ret < 0)
+		return ret;
+
+	if (new == 0 || new > (hw_tcs - aprp_cpu_index()))
+		return -EINVAL;
+
+	vpe->ntcs = new;
+
+	return len;
+}
+static DEVICE_ATTR_RW(ntcs);
+
+static struct attribute *vpe_attrs[] = {
+	&dev_attr_kill.attr,
+	&dev_attr_ntcs.attr,
+	NULL,
+};
+ATTRIBUTE_GROUPS(vpe);
+
+static void vpe_device_release(struct device *cd)
+{
+	kfree(cd);
+}
+
+static struct class vpe_class = {
+	.name = "vpe",
+	.owner = THIS_MODULE,
+	.dev_release = vpe_device_release,
+	.dev_groups = vpe_groups,
+};
+
+static struct device vpe_device;
+
+int __init vpe_module_init(void)
+{
+	unsigned int mtflags, vpflags;
+	unsigned long flags, val;
+	struct vpe *v = NULL;
+	struct tc *t;
+	int tc, err;
+
+	if (!cpu_has_mipsmt) {
+		pr_warn("VPE loader: not a MIPS MT capable processor\n");
+		return -ENODEV;
+	}
+
+	if (vpelimit == 0) {
+		pr_warn("No VPEs reserved for AP/SP, not initialize VPE loader\n"
+			"Pass maxvpes=<n> argument as kernel argument\n");
+
+		return -ENODEV;
+	}
+
+	if (aprp_cpu_index() == 0) {
+		pr_warn("No TCs reserved for AP/SP, not initialize VPE loader\n"
+			"Pass maxtcs=<n> argument as kernel argument\n");
+
+		return -ENODEV;
+	}
+
+	major = register_chrdev(0, VPE_MODULE_NAME, &vpe_fops);
+	if (major < 0) {
+		pr_warn("VPE loader: unable to register character device\n");
+		return major;
+	}
+
+	err = class_register(&vpe_class);
+	if (err) {
+		pr_err("vpe_class registration failed\n");
+		goto out_chrdev;
+	}
+
+	device_initialize(&vpe_device);
+	vpe_device.class	= &vpe_class,
+	vpe_device.parent	= NULL,
+	dev_set_name(&vpe_device, "vpe1");
+	vpe_device.devt = MKDEV(major, VPE_MODULE_MINOR);
+	err = device_add(&vpe_device);
+	if (err) {
+		pr_err("Adding vpe_device failed\n");
+		goto out_class;
+	}
+
+	local_irq_save(flags);
+	mtflags = dmt();
+	vpflags = dvpe();
+
+	/* Put MVPE's into 'configuration state' */
+	set_c0_mvpcontrol(MVPCONTROL_VPC);
+
+	val = read_c0_mvpconf0();
+	hw_tcs = (val & MVPCONF0_PTC) + 1;
+	hw_vpes = ((val & MVPCONF0_PVPE) >> MVPCONF0_PVPE_SHIFT) + 1;
+
+	for (tc = aprp_cpu_index(); tc < hw_tcs; tc++) {
+		/*
+		 * Must re-enable multithreading temporarily or in case we
+		 * reschedule send IPIs or similar we might hang.
+		 */
+		clear_c0_mvpcontrol(MVPCONTROL_VPC);
+		evpe(vpflags);
+		emt(mtflags);
+		local_irq_restore(flags);
+		t = alloc_tc(tc);
+		if (!t) {
+			err = -ENOMEM;
+			goto out_dev;
+		}
+
+		local_irq_save(flags);
+		mtflags = dmt();
+		vpflags = dvpe();
+		set_c0_mvpcontrol(MVPCONTROL_VPC);
+
+		/* VPE's */
+		if (tc < hw_tcs) {
+			settc(tc);
+
+			v = alloc_vpe(tc);
+			if (v == NULL) {
+				pr_warn("VPE: unable to allocate VPE\n");
+				goto out_reenable;
+			}
+
+			v->ntcs = hw_tcs - aprp_cpu_index();
+
+			/* add the tc to the list of this vpe's tc's. */
+			list_add(&t->tc, &v->tc);
+
+			/* deactivate all but vpe0 */
+			if (tc >= aprp_cpu_index()) {
+				unsigned long tmp = read_vpe_c0_vpeconf0();
+
+				tmp &= ~VPECONF0_VPA;
+
+				/* master VPE */
+				tmp |= VPECONF0_MVP;
+				write_vpe_c0_vpeconf0(tmp);
+			}
+
+			/* disable multi-threading with TC's */
+			write_vpe_c0_vpecontrol(read_vpe_c0_vpecontrol() &
+						~VPECONTROL_TE);
+
+			if (tc >= vpelimit) {
+				/*
+				 * Set config to be the same as vpe0,
+				 * particularly kseg0 coherency alg
+				 */
+				write_vpe_c0_config(read_c0_config());
+			}
+		}
+
+		/* TC's */
+		t->pvpe = v;	/* set the parent vpe */
+
+		if (tc >= aprp_cpu_index()) {
+			unsigned long tmp;
+
+			settc(tc);
+
+			/* Any TC that is bound to VPE0 gets left as is - in
+			 * case we are running SMTC on VPE0. A TC that is bound
+			 * to any other VPE gets bound to VPE0, ideally I'd like
+			 * to make it homeless but it doesn't appear to let me
+			 * bind a TC to a non-existent VPE. Which is perfectly
+			 * reasonable.
+			 *
+			 * The (un)bound state is visible to an EJTAG probe so
+			 * may notify GDB...
+			 */
+			tmp = read_tc_c0_tcbind();
+			if (tmp & TCBIND_CURVPE) {
+				/* tc is bound >vpe0 */
+				write_tc_c0_tcbind(tmp & ~TCBIND_CURVPE);
+
+				t->pvpe = get_vpe(0);	/* set the parent vpe */
+			}
+
+			/* halt the TC */
+			write_tc_c0_tchalt(TCHALT_H);
+			mips_ihb();
+
+			tmp = read_tc_c0_tcstatus();
+
+			/* mark not activated and not dynamically allocatable */
+			tmp &= ~(TCSTATUS_A | TCSTATUS_DA);
+			tmp |= TCSTATUS_IXMT;	/* interrupt exempt */
+			write_tc_c0_tcstatus(tmp);
+		}
+	}
+
+out_reenable:
+	/* release config state */
+	clear_c0_mvpcontrol(MVPCONTROL_VPC);
+
+	evpe(vpflags);
+	emt(mtflags);
+	local_irq_restore(flags);
+
+	return 0;
+
+out_dev:
+	device_del(&vpe_device);
+
+out_class:
+	class_unregister(&vpe_class);
+
+out_chrdev:
+	unregister_chrdev(major, VPE_MODULE_NAME);
+
+	return err;
+}
+
+void __exit vpe_module_exit(void)
+{
+	struct vpe *v, *n;
+
+	device_del(&vpe_device);
+	class_unregister(&vpe_class);
+	unregister_chrdev(major, VPE_MODULE_NAME);
+
+	/* No locking needed here */
+	list_for_each_entry_safe(v, n, &vpecontrol.vpe_list, list) {
+		if (v->state != VPE_STATE_UNUSED)
+			release_vpe(v);
+	}
+}
diff --git a/arch/mips/kernel/vpe.c b/arch/mips/kernel/vpe.c
index 59b2b3c..61dfd5b 100644
--- a/arch/mips/kernel/vpe.c
+++ b/arch/mips/kernel/vpe.c
@@ -51,8 +51,6 @@
 #include <asm/processor.h>
 #include <asm/vpe.h>
 
-typedef void *vpe_handle;
-
 #ifndef ARCH_SHF_SMALL
 #define ARCH_SHF_SMALL 0
 #endif
@@ -60,96 +58,15 @@ typedef void *vpe_handle;
 /* If this is set, the section belongs in the init part of the module */
 #define INIT_OFFSET_MASK (1UL << (BITS_PER_LONG-1))
 
-/*
- * The number of TCs and VPEs physically available on the core
- */
-static int hw_tcs, hw_vpes;
-static char module_name[] = "vpe";
-static int major;
-static const int minor = 1;	/* fixed for now  */
-
-/* grab the likely amount of memory we will need. */
-#ifdef CONFIG_MIPS_VPE_LOADER_TOM
-#define P_SIZE (2 * 1024 * 1024)
-#else
-/* add an overhead to the max kmalloc size for non-striped symbols/etc */
-#define P_SIZE (256 * 1024)
-#endif
-
-extern unsigned long physical_memsize;
-
-#define MAX_VPES 16
-#define VPE_PATH_MAX 256
-
-enum vpe_state {
-	VPE_STATE_UNUSED = 0,
-	VPE_STATE_INUSE,
-	VPE_STATE_RUNNING
-};
-
-enum tc_state {
-	TC_STATE_UNUSED = 0,
-	TC_STATE_INUSE,
-	TC_STATE_RUNNING,
-	TC_STATE_DYNAMIC
-};
-
-struct vpe {
-	enum vpe_state state;
-
-	/* (device) minor associated with this vpe */
-	int minor;
-
-	/* elfloader stuff */
-	void *load_addr;
-	unsigned long len;
-	char *pbuffer;
-	unsigned long plen;
-	unsigned int uid, gid;
-	char cwd[VPE_PATH_MAX];
-
-	unsigned long __start;
-
-	/* tc's associated with this vpe */
-	struct list_head tc;
-
-	/* The list of vpe's */
-	struct list_head list;
-
-	/* shared symbol address */
-	void *shared_ptr;
-
-	/* the list of who wants to know when something major happens */
-	struct list_head notify;
-
-	unsigned int ntcs;
-};
-
-struct tc {
-	enum tc_state state;
-	int index;
-
-	struct vpe *pvpe;	/* parent VPE */
-	struct list_head tc;	/* The list of TC's with this VPE */
-	struct list_head list;	/* The global list of tc's */
-};
-
-struct {
-	spinlock_t vpe_list_lock;
-	struct list_head vpe_list;	/* Virtual processing elements */
-	spinlock_t tc_list_lock;
-	struct list_head tc_list;	/* Thread contexts */
-} vpecontrol = {
+struct vpe_control vpecontrol = {
 	.vpe_list_lock	= __SPIN_LOCK_UNLOCKED(vpe_list_lock),
 	.vpe_list	= LIST_HEAD_INIT(vpecontrol.vpe_list),
 	.tc_list_lock	= __SPIN_LOCK_UNLOCKED(tc_list_lock),
 	.tc_list	= LIST_HEAD_INIT(vpecontrol.tc_list)
 };
 
-static void release_progmem(void *ptr);
-
 /* get the vpe associated with this minor */
-static struct vpe *get_vpe(int minor)
+struct vpe *get_vpe(int minor)
 {
 	struct vpe *res, *v;
 
@@ -159,7 +76,7 @@ static struct vpe *get_vpe(int minor)
 	res = NULL;
 	spin_lock(&vpecontrol.vpe_list_lock);
 	list_for_each_entry(v, &vpecontrol.vpe_list, list) {
-		if (v->minor == minor) {
+		if (v->minor == VPE_MODULE_MINOR) {
 			res = v;
 			break;
 		}
@@ -170,7 +87,7 @@ static struct vpe *get_vpe(int minor)
 }
 
 /* get the vpe associated with this minor */
-static struct tc *get_tc(int index)
+struct tc *get_tc(int index)
 {
 	struct tc *res, *t;
 
@@ -188,7 +105,7 @@ static struct tc *get_tc(int index)
 }
 
 /* allocate a vpe and associate it with this minor (or index) */
-static struct vpe *alloc_vpe(int minor)
+struct vpe *alloc_vpe(int minor)
 {
 	struct vpe *v;
 
@@ -201,13 +118,13 @@ static struct vpe *alloc_vpe(int minor)
 	spin_unlock(&vpecontrol.vpe_list_lock);
 
 	INIT_LIST_HEAD(&v->notify);
-	v->minor = minor;
+	v->minor = VPE_MODULE_MINOR;
 
 	return v;
 }
 
 /* allocate a tc. At startup only tc0 is running, all other can be halted. */
-static struct tc *alloc_tc(int index)
+struct tc *alloc_tc(int index)
 {
 	struct tc *tc;
 
@@ -226,7 +143,7 @@ out:
 }
 
 /* clean up and free everything */
-static void release_vpe(struct vpe *v)
+void release_vpe(struct vpe *v)
 {
 	list_del(&v->list);
 	if (v->load_addr)
@@ -234,28 +151,8 @@ static void release_vpe(struct vpe *v)
 	kfree(v);
 }
 
-static void __maybe_unused dump_mtregs(void)
-{
-	unsigned long val;
-
-	val = read_c0_config3();
-	printk("config3 0x%lx MT %ld\n", val,
-	       (val & CONFIG3_MT) >> CONFIG3_MT_SHIFT);
-
-	val = read_c0_mvpcontrol();
-	printk("MVPControl 0x%lx, STLB %ld VPC %ld EVP %ld\n", val,
-	       (val & MVPCONTROL_STLB) >> MVPCONTROL_STLB_SHIFT,
-	       (val & MVPCONTROL_VPC) >> MVPCONTROL_VPC_SHIFT,
-	       (val & MVPCONTROL_EVP));
-
-	val = read_c0_mvpconf0();
-	printk("mvpconf0 0x%lx, PVPE %ld PTC %ld M %ld\n", val,
-	       (val & MVPCONF0_PVPE) >> MVPCONF0_PVPE_SHIFT,
-	       val & MVPCONF0_PTC, (val & MVPCONF0_M) >> MVPCONF0_M_SHIFT);
-}
-
 /* Find some VPE program space	*/
-static void *alloc_progmem(unsigned long len)
+void *alloc_progmem(unsigned long len)
 {
 	void *addr;
 
@@ -274,7 +171,7 @@ static void *alloc_progmem(unsigned long len)
 	return addr;
 }
 
-static void release_progmem(void *ptr)
+void release_progmem(void *ptr)
 {
 #ifndef CONFIG_MIPS_VPE_LOADER_TOM
 	kfree(ptr);
@@ -675,127 +572,6 @@ static void dump_elfsymbols(Elf_Shdr * sechdrs, unsigned int symindex,
 }
 #endif
 
-/* We are prepared so configure and start the VPE... */
-static int vpe_run(struct vpe * v)
-{
-	unsigned long flags, val, dmt_flag;
-	struct vpe_notifications *n;
-	unsigned int vpeflags;
-	struct tc *t;
-
-	/* check we are the Master VPE */
-	local_irq_save(flags);
-	val = read_c0_vpeconf0();
-	if (!(val & VPECONF0_MVP)) {
-		printk(KERN_WARNING
-		       "VPE loader: only Master VPE's are allowed to configure MT\n");
-		local_irq_restore(flags);
-
-		return -1;
-	}
-
-	dmt_flag = dmt();
-	vpeflags = dvpe();
-
-	if (list_empty(&v->tc)) {
-		evpe(vpeflags);
-		emt(dmt_flag);
-		local_irq_restore(flags);
-
-		printk(KERN_WARNING
-		       "VPE loader: No TC's associated with VPE %d\n",
-		       v->minor);
-
-		return -ENOEXEC;
-	}
-
-	t = list_first_entry(&v->tc, struct tc, tc);
-
-	/* Put MVPE's into 'configuration state' */
-	set_c0_mvpcontrol(MVPCONTROL_VPC);
-
-	settc(t->index);
-
-	/* should check it is halted, and not activated */
-	if ((read_tc_c0_tcstatus() & TCSTATUS_A) || !(read_tc_c0_tchalt() & TCHALT_H)) {
-		evpe(vpeflags);
-		emt(dmt_flag);
-		local_irq_restore(flags);
-
-		printk(KERN_WARNING "VPE loader: TC %d is already active!\n",
-		       t->index);
-
-		return -ENOEXEC;
-	}
-
-	/* Write the address we want it to start running from in the TCPC register. */
-	write_tc_c0_tcrestart((unsigned long)v->__start);
-	write_tc_c0_tccontext((unsigned long)0);
-
-	/*
-	 * Mark the TC as activated, not interrupt exempt and not dynamically
-	 * allocatable
-	 */
-	val = read_tc_c0_tcstatus();
-	val = (val & ~(TCSTATUS_DA | TCSTATUS_IXMT)) | TCSTATUS_A;
-	write_tc_c0_tcstatus(val);
-
-	write_tc_c0_tchalt(read_tc_c0_tchalt() & ~TCHALT_H);
-
-	/*
-	 * The sde-kit passes 'memsize' to __start in $a3, so set something
-	 * here...  Or set $a3 to zero and define DFLT_STACK_SIZE and
-	 * DFLT_HEAP_SIZE when you compile your program
-	 */
-	mttgpr(6, v->ntcs);
-	mttgpr(7, physical_memsize);
-
-	/* set up VPE1 */
-	/*
-	 * bind the TC to VPE 1 as late as possible so we only have the final
-	 * VPE registers to set up, and so an EJTAG probe can trigger on it
-	 */
-	write_tc_c0_tcbind((read_tc_c0_tcbind() & ~TCBIND_CURVPE) | 1);
-
-	write_vpe_c0_vpeconf0(read_vpe_c0_vpeconf0() & ~(VPECONF0_VPA));
-
-	back_to_back_c0_hazard();
-
-	/* Set up the XTC bit in vpeconf0 to point at our tc */
-	write_vpe_c0_vpeconf0( (read_vpe_c0_vpeconf0() & ~(VPECONF0_XTC))
-			      | (t->index << VPECONF0_XTC_SHIFT));
-
-	back_to_back_c0_hazard();
-
-	/* enable this VPE */
-	write_vpe_c0_vpeconf0(read_vpe_c0_vpeconf0() | VPECONF0_VPA);
-
-	/* clear out any left overs from a previous program */
-	write_vpe_c0_status(0);
-	write_vpe_c0_cause(0);
-
-	/* take system out of configuration state */
-	clear_c0_mvpcontrol(MVPCONTROL_VPC);
-
-	/*
-	 * SMTC/SMVP kernels manage VPE enable independently,
-	 * but uniprocessor kernels need to turn it on, even
-	 * if that wasn't the pre-dvpe() state.
-	 */
-#ifdef CONFIG_SMP
-	evpe(vpeflags);
-#else
-	evpe(EVPE_ENABLE);
-#endif
-	emt(dmt_flag);
-	local_irq_restore(flags);
-
-	list_for_each_entry(n, &v->notify, list)
-		n->start(minor);
-
-	return 0;
-}
-
 static int find_vpe_symbols(struct vpe * v, Elf_Shdr * sechdrs,
 				      unsigned int symindex, const char *strtab,
 				      struct module *mod)
@@ -993,38 +769,6 @@ static int vpe_elfload(struct vpe * v)
 	return 0;
 }
 
-static void cleanup_tc(struct tc *tc)
-{
-	unsigned long flags;
-	unsigned int mtflags, vpflags;
-	int tmp;
-
-	local_irq_save(flags);
-	mtflags = dmt();
-	vpflags = dvpe();
-	/* Put MVPE's into 'configuration state' */
-	set_c0_mvpcontrol(MVPCONTROL_VPC);
-
-	settc(tc->index);
-	tmp = read_tc_c0_tcstatus();
-
-	/* mark not allocated and not dynamically allocatable */
-	tmp &= ~(TCSTATUS_A | TCSTATUS_DA);
-	tmp |= TCSTATUS_IXMT;	/* interrupt exempt */
-	write_tc_c0_tcstatus(tmp);
-
-	write_tc_c0_tchalt(TCHALT_H);
-	mips_ihb();
-
-	/* bind it to anything other than VPE1 */
-//	write_tc_c0_tcbind(read_tc_c0_tcbind() & ~TCBIND_CURVPE); // | TCBIND_CURVPE
-
-	clear_c0_mvpcontrol(MVPCONTROL_VPC);
-	evpe(vpflags);
-	emt(mtflags);
-	local_irq_restore(flags);
-}
-
 static int getcwd(char *buff, int size)
 {
 	mm_segment_t old_fs;
@@ -1048,14 +792,14 @@ static int vpe_open(struct inode *inode, struct file *filp)
 	struct vpe *v;
 	int ret;
 
-	if (minor != iminor(inode)) {
+	if (VPE_MODULE_MINOR != iminor(inode)) {
 		/* assume only 1 device at the moment. */
 		pr_warning("VPE loader: only vpe1 is supported\n");
 
 		return -ENODEV;
 	}
 
-	if ((v = get_vpe(tclimit)) == NULL) {
+	if ((v = get_vpe(aprp_cpu_index())) == NULL) {
 		pr_warning("VPE loader: unable to get vpe\n");
 
 		return -ENODEV;
@@ -1066,11 +810,11 @@ static int vpe_open(struct inode *inode, struct file *filp)
 		printk(KERN_DEBUG "VPE loader: tc in use dumping regs\n");
 
 		list_for_each_entry(not, &v->notify, list) {
-			not->stop(tclimit);
+			not->stop(aprp_cpu_index());
 		}
 
 		release_progmem(v->load_addr);
-		cleanup_tc(get_tc(tclimit));
+		cleanup_tc(get_tc(aprp_cpu_index()));
 	}
 
 	/* this of-course trashes what was there before... */
@@ -1103,13 +847,13 @@ static int vpe_release(struct inode *inode, struct file *filp)
 	Elf_Ehdr *hdr;
 	int ret = 0;
 
-	v = get_vpe(tclimit);
+	v = get_vpe(aprp_cpu_index());
 	if (v == NULL)
 		return -ENODEV;
 
 	hdr = (Elf_Ehdr *) v->pbuffer;
 	if (memcmp(hdr->e_ident, ELFMAG, SELFMAG) == 0) {
-		if (vpe_elfload(v) >= 0) {
+		if ((vpe_elfload(v) >= 0) && vpe_run) {
 			vpe_run(v);
 		} else {
 			printk(KERN_WARNING "VPE loader: ELF load failed.\n");
@@ -1140,10 +884,10 @@ static ssize_t vpe_write(struct file *file, const char __user * buffer,
 	size_t ret = count;
 	struct vpe *v;
 
-	if (iminor(file_inode(file)) != minor)
+	if (iminor(file_inode(file)) != VPE_MODULE_MINOR)
 		return -ENODEV;
 
-	v = get_vpe(tclimit);
+	v = get_vpe(aprp_cpu_index());
 	if (v == NULL)
 		return -ENODEV;
 
@@ -1161,7 +905,7 @@ static ssize_t vpe_write(struct file *file, const char __user * buffer,
 	return ret;
 }
 
-static const struct file_operations vpe_fops = {
+const struct file_operations vpe_fops = {
 	.owner = THIS_MODULE,
 	.open = vpe_open,
 	.release = vpe_release,
@@ -1169,94 +913,6 @@ static const struct file_operations vpe_fops = {
 	.llseek = noop_llseek,
 };
 
-/* module wrapper entry points */
-/* give me a vpe */
-vpe_handle vpe_alloc(void)
-{
-	int i;
-	struct vpe *v;
-
-	/* find a vpe */
-	for (i = 1; i < MAX_VPES; i++) {
-		if ((v = get_vpe(i)) != NULL) {
-			v->state = VPE_STATE_INUSE;
-			return v;
-		}
-	}
-	return NULL;
-}
-
-EXPORT_SYMBOL(vpe_alloc);
-
-/* start running from here */
-int vpe_start(vpe_handle vpe, unsigned long start)
-{
-	struct vpe *v = vpe;
-
-	v->__start = start;
-	return vpe_run(v);
-}
-
-EXPORT_SYMBOL(vpe_start);
-
-/* halt it for now */
-int vpe_stop(vpe_handle vpe)
-{
-	struct vpe *v = vpe;
-	struct tc *t;
-	unsigned int evpe_flags;
-
-	evpe_flags = dvpe();
-
-	if ((t = list_entry(v->tc.next, struct tc, tc)) != NULL) {
-
-		settc(t->index);
-		write_vpe_c0_vpeconf0(read_vpe_c0_vpeconf0() & ~VPECONF0_VPA);
-	}
-
-	evpe(evpe_flags);
-
-	return 0;
-}
-
-EXPORT_SYMBOL(vpe_stop);
-
-/* I've done with it thank you */
-int vpe_free(vpe_handle vpe)
-{
-	struct vpe *v = vpe;
-	struct tc *t;
-	unsigned int evpe_flags;
-
-	if ((t = list_entry(v->tc.next, struct tc, tc)) == NULL) {
-		return -ENOEXEC;
-	}
-
-	evpe_flags = dvpe();
-
-	/* Put MVPE's into 'configuration state' */
-	set_c0_mvpcontrol(MVPCONTROL_VPC);
-
-	settc(t->index);
-	write_vpe_c0_vpeconf0(read_vpe_c0_vpeconf0() & ~VPECONF0_VPA);
-
-	/* halt the TC */
-	write_tc_c0_tchalt(TCHALT_H);
-	mips_ihb();
-
-	/* mark the TC unallocated */
-	write_tc_c0_tcstatus(read_tc_c0_tcstatus() & ~TCSTATUS_A);
-
-	v->state = VPE_STATE_UNUSED;
-
-	clear_c0_mvpcontrol(MVPCONTROL_VPC);
-	evpe(evpe_flags);
-
-	return 0;
-}
-
-EXPORT_SYMBOL(vpe_free);
-
 void *vpe_get_shared(int index)
 {
 	struct vpe *v;
@@ -1318,271 +974,6 @@ char *vpe_getcwd(int index)
 
 EXPORT_SYMBOL(vpe_getcwd);
 
-static ssize_t store_kill(struct device *dev, struct device_attribute *attr,
-			  const char *buf, size_t len)
-{
-	struct vpe *vpe = get_vpe(tclimit);
-	struct vpe_notifications *not;
-
-	list_for_each_entry(not, &vpe->notify, list) {
-		not->stop(tclimit);
-	}
-
-	release_progmem(vpe->load_addr);
-	cleanup_tc(get_tc(tclimit));
-	vpe_stop(vpe);
-	vpe_free(vpe);
-
-	return len;
-}
-static DEVICE_ATTR(kill, S_IWUSR, NULL, store_kill);
-
-static ssize_t ntcs_show(struct device *cd, struct device_attribute *attr,
-			 char *buf)
-{
-	struct vpe *vpe = get_vpe(tclimit);
-
-	return sprintf(buf, "%d\n", vpe->ntcs);
-}
-
-static ssize_t ntcs_store(struct device *dev, struct device_attribute *attr,
-			  const char *buf, size_t len)
-{
-	struct vpe *vpe = get_vpe(tclimit);
-	unsigned long new;
-	char *endp;
-
-	new = simple_strtoul(buf, &endp, 0);
-	if (endp == buf)
-		goto out_einval;
-
-	if (new == 0 || new > (hw_tcs - tclimit))
-		goto out_einval;
-
-	vpe->ntcs = new;
-
-	return len;
-
-out_einval:
-	return -EINVAL;
-}
-static DEVICE_ATTR_RW(ntcs);
-
-static struct attribute *vpe_attrs[] = {
-	&dev_attr_kill.attr,
-	&dev_attr_ntcs.attr,
-	NULL,
-};
-ATTRIBUTE_GROUPS(vpe);
-
-static void vpe_device_release(struct device *cd)
-{
-	kfree(cd);
-}
-
-struct class vpe_class = {
-	.name = "vpe",
-	.owner = THIS_MODULE,
-	.dev_release = vpe_device_release,
-	.dev_groups = vpe_groups,
-};
-
-struct device vpe_device;
-
-static int __init vpe_module_init(void)
-{
-	unsigned int mtflags, vpflags;
-	unsigned long flags, val;
-	struct vpe *v = NULL;
-	struct tc *t;
-	int tc, err;
-
-	if (!cpu_has_mipsmt) {
-		printk("VPE loader: not a MIPS MT capable processor\n");
-		return -ENODEV;
-	}
-
-	if (vpelimit == 0) {
-		printk(KERN_WARNING "No VPEs reserved for AP/SP, not "
-		       "initializing VPE loader.\nPass maxvpes=<n> argument as "
-		       "kernel argument\n");
-
-		return -ENODEV;
-	}
-
-	if (tclimit == 0) {
-		printk(KERN_WARNING "No TCs reserved for AP/SP, not "
-		       "initializing VPE loader.\nPass maxtcs=<n> argument as "
-		       "kernel argument\n");
-
-		return -ENODEV;
-	}
-
-	major = register_chrdev(0, module_name, &vpe_fops);
-	if (major < 0) {
-		printk("VPE loader: unable to register character device\n");
-		return major;
-	}
-
-	err = class_register(&vpe_class);
-	if (err) {
-		printk(KERN_ERR "vpe_class registration failed\n");
-		goto out_chrdev;
-	}
-
-	device_initialize(&vpe_device);
-	vpe_device.class	= &vpe_class,
-	vpe_device.parent	= NULL,
-	dev_set_name(&vpe_device, "vpe1");
-	vpe_device.devt = MKDEV(major, minor);
-	err = device_add(&vpe_device);
-	if (err) {
-		printk(KERN_ERR "Adding vpe_device failed\n");
-		goto out_class;
-	}
-
-	local_irq_save(flags);
-	mtflags = dmt();
-	vpflags = dvpe();
-
-	/* Put MVPE's into 'configuration state' */
-	set_c0_mvpcontrol(MVPCONTROL_VPC);
-
-	/* dump_mtregs(); */
-
-	val = read_c0_mvpconf0();
-	hw_tcs = (val & MVPCONF0_PTC) + 1;
-	hw_vpes = ((val & MVPCONF0_PVPE) >> MVPCONF0_PVPE_SHIFT) + 1;
-
-	for (tc = tclimit; tc < hw_tcs; tc++) {
-		/*
-		 * Must re-enable multithreading temporarily or in case we
-		 * reschedule send IPIs or similar we might hang.
-		 */
-		clear_c0_mvpcontrol(MVPCONTROL_VPC);
-		evpe(vpflags);
-		emt(mtflags);
-		local_irq_restore(flags);
-		t = alloc_tc(tc);
-		if (!t) {
-			err = -ENOMEM;
-			goto out;
-		}
-
-		local_irq_save(flags);
-		mtflags = dmt();
-		vpflags = dvpe();
-		set_c0_mvpcontrol(MVPCONTROL_VPC);
-
-		/* VPE's */
-		if (tc < hw_tcs) {
-			settc(tc);
-
-			if ((v = alloc_vpe(tc)) == NULL) {
-				printk(KERN_WARNING "VPE: unable to allocate VPE\n");
-
-				goto out_reenable;
-			}
-
-			v->ntcs = hw_tcs - tclimit;
-
-			/* add the tc to the list of this vpe's tc's. */
-			list_add(&t->tc, &v->tc);
-
-			/* deactivate all but vpe0 */
-			if (tc >= tclimit) {
-				unsigned long tmp = read_vpe_c0_vpeconf0();
-
-				tmp &= ~VPECONF0_VPA;
-
-				/* master VPE */
-				tmp |= VPECONF0_MVP;
-				write_vpe_c0_vpeconf0(tmp);
-			}
-
-			/* disable multi-threading with TC's */
-			write_vpe_c0_vpecontrol(read_vpe_c0_vpecontrol() & ~VPECONTROL_TE);
-
-			if (tc >= vpelimit) {
-				/*
-				 * Set config to be the same as vpe0,
-				 * particularly kseg0 coherency alg
-				 */
-				write_vpe_c0_config(read_c0_config());
-			}
-		}
-
-		/* TC's */
-		t->pvpe = v;	/* set the parent vpe */
-
-		if (tc >= tclimit) {
-			unsigned long tmp;
-
-			settc(tc);
-
-			/* Any TC that is bound to VPE0 gets left as is - in case
-			   we are running SMTC on VPE0. A TC that is bound to any
-			   other VPE gets bound to VPE0, ideally I'd like to make
-			   it homeless but it doesn't appear to let me bind a TC
-			   to a non-existent VPE. Which is perfectly reasonable.
-
-			   The (un)bound state is visible to an EJTAG probe so may
-			   notify GDB...
-			*/
-
-			if (((tmp = read_tc_c0_tcbind()) & TCBIND_CURVPE)) {
-				/* tc is bound >vpe0 */
-				write_tc_c0_tcbind(tmp & ~TCBIND_CURVPE);
-
-				t->pvpe = get_vpe(0);	/* set the parent vpe */
-			}
-
-			/* halt the TC */
-			write_tc_c0_tchalt(TCHALT_H);
-			mips_ihb();
-
-			tmp = read_tc_c0_tcstatus();
-
-			/* mark not activated and not dynamically allocatable */
-			tmp &= ~(TCSTATUS_A | TCSTATUS_DA);
-			tmp |= TCSTATUS_IXMT;	/* interrupt exempt */
-			write_tc_c0_tcstatus(tmp);
-		}
-	}
-
-out_reenable:
-	/* release config state */
-	clear_c0_mvpcontrol(MVPCONTROL_VPC);
-
-	evpe(vpflags);
-	emt(mtflags);
-	local_irq_restore(flags);
-
-	return 0;
-
-out_class:
-	class_unregister(&vpe_class);
-out_chrdev:
-	unregister_chrdev(major, module_name);
-
-out:
-	return err;
-}
-
-static void __exit vpe_module_exit(void)
-{
-	struct vpe *v, *n;
-
-	device_del(&vpe_device);
-	unregister_chrdev(major, module_name);
-
-	/* No locking needed here */
-	list_for_each_entry_safe(v, n, &vpecontrol.vpe_list, list) {
-		if (v->state != VPE_STATE_UNUSED)
-			release_vpe(v);
-	}
-}
-
 module_init(vpe_module_init);
 module_exit(vpe_module_exit);
 MODULE_DESCRIPTION("MIPS VPE Loader");
-- 
1.7.9.5

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

* [PATCH 2/6] MIPS: APRP: Add VPE loader support for CMP platforms.
  2013-10-17  2:14 [PATCH 0/6] MIPS: APRP: Enable APRP for platforms with a CM Steven J. Hill
  2013-10-17  2:14 ` [PATCH 1/6] MIPS: APRP: Split VPE loader into separate files Steven J. Hill
@ 2013-10-17  2:14 ` Steven J. Hill
  2013-10-17 17:40   ` David Daney
  2013-10-17  2:14 ` [PATCH 3/6] MIPS: APRP: Split RTLX support into separate files Steven J. Hill
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 20+ messages in thread
From: Steven J. Hill @ 2013-10-17  2:14 UTC (permalink / raw)
  To: linux-mips; +Cc: Deng-Cheng Zhu, ralf, Steven J. Hill

From: Deng-Cheng Zhu <dengcheng.zhu@imgtec.com>

This patch adds VPE loader support for platforms having a CMP.

Signed-off-by: Deng-Cheng Zhu <dengcheng.zhu@imgtec.com>
Signed-off-by: Steven J. Hill <Steven.Hill@imgtec.com>
Reviewed-by: Qais Yousef <Qais.Yousef@imgtec.com>
---
 arch/mips/kernel/Makefile  |    2 +-
 arch/mips/kernel/vpe-cmp.c |  184 ++++++++++++++++++++++++++++++++++++++++++++
 arch/mips/kernel/vpe-mt.c  |    4 +
 3 files changed, 189 insertions(+), 1 deletion(-)
 create mode 100644 arch/mips/kernel/vpe-cmp.c

diff --git a/arch/mips/kernel/Makefile b/arch/mips/kernel/Makefile
index 51f9117..912eb64 100644
--- a/arch/mips/kernel/Makefile
+++ b/arch/mips/kernel/Makefile
@@ -54,7 +54,7 @@ obj-$(CONFIG_MIPS_MT_SMP)	+= smp-mt.o
 obj-$(CONFIG_MIPS_CMP)		+= smp-cmp.o
 obj-$(CONFIG_CPU_MIPSR2)	+= spram.o
 
-obj-$(CONFIG_MIPS_VPE_LOADER)	+= vpe.o vpe-mt.o
+obj-$(CONFIG_MIPS_VPE_LOADER)	+= vpe.o vpe-cmp.o vpe-mt.o
 obj-$(CONFIG_MIPS_VPE_APSP_API) += rtlx.o
 
 obj-$(CONFIG_I8259)		+= i8259.o
diff --git a/arch/mips/kernel/vpe-cmp.c b/arch/mips/kernel/vpe-cmp.c
new file mode 100644
index 0000000..a5628ca
--- /dev/null
+++ b/arch/mips/kernel/vpe-cmp.c
@@ -0,0 +1,184 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2004, 2005 MIPS Technologies, Inc.  All rights reserved.
+ * Copyright (C) 2013 Imagination Technologies Ltd.
+ */
+#ifdef CONFIG_MIPS_CMP
+
+#include <linux/kernel.h>
+#include <linux/device.h>
+#include <linux/fs.h>
+#include <linux/slab.h>
+#include <linux/export.h>
+
+#include <asm/vpe.h>
+
+static int major;
+
+void cleanup_tc(struct tc *tc)
+{
+
+}
+
+static ssize_t store_kill(struct device *dev, struct device_attribute *attr,
+			  const char *buf, size_t len)
+{
+	struct vpe *vpe = get_vpe(aprp_cpu_index());
+	struct vpe_notifications *notifier;
+
+	list_for_each_entry(notifier, &vpe->notify, list)
+		notifier->stop(aprp_cpu_index());
+
+	release_progmem(vpe->load_addr);
+	vpe->state = VPE_STATE_UNUSED;
+
+	return len;
+}
+static DEVICE_ATTR(kill, S_IWUSR, NULL, store_kill);
+
+static ssize_t ntcs_show(struct device *cd, struct device_attribute *attr,
+			 char *buf)
+{
+	struct vpe *vpe = get_vpe(aprp_cpu_index());
+
+	return sprintf(buf, "%d\n", vpe->ntcs);
+}
+
+static ssize_t ntcs_store(struct device *dev, struct device_attribute *attr,
+			  const char *buf, size_t len)
+{
+	struct vpe *vpe = get_vpe(aprp_cpu_index());
+	unsigned long new;
+	int ret;
+
+	ret = kstrtoul(buf, 0, &new);
+	if (ret < 0)
+		return ret;
+
+	/* APRP can only reserve one TC in a VPE and no more. */
+	if (new != 1)
+		return -EINVAL;
+
+	vpe->ntcs = new;
+
+	return len;
+}
+static DEVICE_ATTR_RW(ntcs);
+
+static struct attribute *vpe_attrs[] = {
+	&dev_attr_kill.attr,
+	&dev_attr_ntcs.attr,
+	NULL,
+};
+ATTRIBUTE_GROUPS(vpe);
+
+static void vpe_device_release(struct device *cd)
+{
+	kfree(cd);
+}
+
+static struct class vpe_class = {
+	.name = "vpe",
+	.owner = THIS_MODULE,
+	.dev_release = vpe_device_release,
+	.dev_groups = vpe_groups,
+};
+
+static struct device vpe_device;
+
+int __init vpe_module_init(void)
+{
+	struct vpe *v = NULL;
+	struct tc *t;
+	int err;
+
+	if (!cpu_has_mipsmt) {
+		pr_warn("VPE loader: not a MIPS MT capable processor\n");
+		return -ENODEV;
+	}
+
+	if (num_possible_cpus() - aprp_cpu_index() < 1) {
+		pr_warn("No VPEs reserved for AP/SP, not initialize VPE loader\n"
+			"Pass maxcpus=<n> argument as kernel argument\n");
+		return -ENODEV;
+	}
+
+	major = register_chrdev(0, VPE_MODULE_NAME, &vpe_fops);
+	if (major < 0) {
+		pr_warn("VPE loader: unable to register character device\n");
+		return major;
+	}
+
+	err = class_register(&vpe_class);
+	if (err) {
+		pr_err("vpe_class registration failed\n");
+		goto out_chrdev;
+	}
+
+	device_initialize(&vpe_device);
+	vpe_device.class	= &vpe_class,
+	vpe_device.parent	= NULL,
+	dev_set_name(&vpe_device, "vpe_sp");
+	vpe_device.devt = MKDEV(major, VPE_MODULE_MINOR);
+	err = device_add(&vpe_device);
+	if (err) {
+		pr_err("Adding vpe_device failed\n");
+		goto out_class;
+	}
+
+	t = alloc_tc(aprp_cpu_index());
+	if (!t) {
+		pr_warn("VPE: unable to allocate TC\n");
+		err = -ENOMEM;
+		goto out_dev;
+	}
+
+	/* VPE */
+	v = alloc_vpe(aprp_cpu_index());
+	if (v == NULL) {
+		pr_warn("VPE: unable to allocate VPE\n");
+		kfree(t);
+		err = -ENOMEM;
+		goto out_dev;
+	}
+
+	v->ntcs = 1;
+
+	/* add the tc to the list of this vpe's tc's. */
+	list_add(&t->tc, &v->tc);
+
+	/* TC */
+	t->pvpe = v;	/* set the parent vpe */
+
+	return 0;
+
+out_dev:
+	device_del(&vpe_device);
+
+out_class:
+	class_unregister(&vpe_class);
+
+out_chrdev:
+	unregister_chrdev(major, VPE_MODULE_NAME);
+
+	return err;
+}
+
+void __exit vpe_module_exit(void)
+{
+	struct vpe *v, *n;
+
+	device_del(&vpe_device);
+	class_unregister(&vpe_class);
+	unregister_chrdev(major, VPE_MODULE_NAME);
+
+	/* No locking needed here */
+	list_for_each_entry_safe(v, n, &vpecontrol.vpe_list, list)
+		if (v->state != VPE_STATE_UNUSED)
+			release_vpe(v);
+}
+
+#endif /* CONFIG_MIPS_CMP */
diff --git a/arch/mips/kernel/vpe-mt.c b/arch/mips/kernel/vpe-mt.c
index 45abe9a..323ca69 100644
--- a/arch/mips/kernel/vpe-mt.c
+++ b/arch/mips/kernel/vpe-mt.c
@@ -6,6 +6,8 @@
  * Copyright (C) 2004, 2005 MIPS Technologies, Inc.  All rights reserved.
  * Copyright (C) 2013 Imagination Technologies Ltd.
  */
+#ifndef CONFIG_MIPS_CMP
+
 #include <linux/kernel.h>
 #include <linux/device.h>
 #include <linux/fs.h>
@@ -521,3 +523,5 @@ void __exit vpe_module_exit(void)
 			release_vpe(v);
 	}
 }
+
+#endif /* !CONFIG_MIPS_CMP */
-- 
1.7.9.5

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

* [PATCH 3/6] MIPS: APRP: Split RTLX support into separate files.
  2013-10-17  2:14 [PATCH 0/6] MIPS: APRP: Enable APRP for platforms with a CM Steven J. Hill
  2013-10-17  2:14 ` [PATCH 1/6] MIPS: APRP: Split VPE loader into separate files Steven J. Hill
  2013-10-17  2:14 ` [PATCH 2/6] MIPS: APRP: Add VPE loader support for CMP platforms Steven J. Hill
@ 2013-10-17  2:14 ` Steven J. Hill
  2013-10-17  2:14 ` [PATCH 4/6] MIPS: APRP: Add RTLX API support for CMP platforms Steven J. Hill
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 20+ messages in thread
From: Steven J. Hill @ 2013-10-17  2:14 UTC (permalink / raw)
  To: linux-mips; +Cc: Deng-Cheng Zhu, ralf, Steven J. Hill

From: Deng-Cheng Zhu <dengcheng.zhu@imgtec.com>

Split the RTLX functionality in preparation for adding support
for CMP platforms. Common functions remain in the original file
and a new file contains code specific to platforms that do not
have a CMP.

Signed-off-by: Deng-Cheng Zhu <dengcheng.zhu@imgtec.com>
Signed-off-by: Steven J. Hill <Steven.Hill@imgtec.com>
Reviewed-by: Qais Yousef <Qais.Yousef@imgtec.com>
---
 arch/mips/include/asm/rtlx.h |   43 ++++++++----
 arch/mips/kernel/Makefile    |    2 +-
 arch/mips/kernel/rtlx-mt.c   |  148 ++++++++++++++++++++++++++++++++++++++++++
 arch/mips/kernel/rtlx.c      |  143 ++++------------------------------------
 4 files changed, 191 insertions(+), 145 deletions(-)
 create mode 100644 arch/mips/kernel/rtlx-mt.c

diff --git a/arch/mips/include/asm/rtlx.h b/arch/mips/include/asm/rtlx.h
index 90985b6..6766026 100644
--- a/arch/mips/include/asm/rtlx.h
+++ b/arch/mips/include/asm/rtlx.h
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2004, 2005 MIPS Technologies, Inc.  All rights reserved.
- *
+ * Copyright (C) 2013 Imagination Technologies Ltd.
  */
 
 #ifndef __ASM_RTLX_H_
@@ -8,6 +8,8 @@
 
 #include <irq.h>
 
+#define RTLX_MODULE_NAME "rtlx"
+
 #define LX_NODE_BASE 10
 
 #define MIPS_CPU_RTLX_IRQ 0
@@ -15,18 +17,31 @@
 #define RTLX_VERSION 2
 #define RTLX_xID 0x12345600
 #define RTLX_ID (RTLX_xID | RTLX_VERSION)
+#define RTLX_BUFFER_SIZE 2048
 #define RTLX_CHANNELS 8
 
 #define RTLX_CHANNEL_STDIO	0
 #define RTLX_CHANNEL_DBG	1
 #define RTLX_CHANNEL_SYSIO	2
 
-extern int rtlx_open(int index, int can_sleep);
-extern int rtlx_release(int index);
-extern ssize_t rtlx_read(int index, void __user *buff, size_t count);
-extern ssize_t rtlx_write(int index, const void __user *buffer, size_t count);
-extern unsigned int rtlx_read_poll(int index, int can_sleep);
-extern unsigned int rtlx_write_poll(int index);
+void rtlx_starting(int vpe);
+void rtlx_stopping(int vpe);
+
+int rtlx_open(int index, int can_sleep);
+int rtlx_release(int index);
+ssize_t rtlx_read(int index, void __user *buff, size_t count);
+ssize_t rtlx_write(int index, const void __user *buffer, size_t count);
+unsigned int rtlx_read_poll(int index, int can_sleep);
+unsigned int rtlx_write_poll(int index);
+
+int __init rtlx_module_init(void);
+void __exit rtlx_module_exit(void);
+
+void _interrupt_sp(void);
+
+extern struct vpe_notifications rtlx_notify;
+extern const struct file_operations rtlx_fops;
+extern void (*aprp_hook)(void);
 
 enum rtlx_state {
 	RTLX_STATE_UNUSED = 0,
@@ -35,10 +50,15 @@ enum rtlx_state {
 	RTLX_STATE_OPENED
 };
 
-#define RTLX_BUFFER_SIZE 2048
+extern struct chan_waitqueues {
+	wait_queue_head_t rt_queue;
+	wait_queue_head_t lx_queue;
+	atomic_t in_open;
+	struct mutex mutex;
+} channel_wqs[RTLX_CHANNELS];
 
 /* each channel supports read and write.
-   linux (vpe0) reads lx_buffer	 and writes rt_buffer
+   linux (vpe0) reads lx_buffer and writes rt_buffer
    SP (vpe1) reads rt_buffer and writes lx_buffer
 */
 struct rtlx_channel {
@@ -55,11 +75,10 @@ struct rtlx_channel {
 	char *lx_buffer;
 };
 
-struct rtlx_info {
+extern struct rtlx_info {
 	unsigned long id;
 	enum rtlx_state state;
 
 	struct rtlx_channel channel[RTLX_CHANNELS];
-};
-
+} *rtlx;
 #endif /* __ASM_RTLX_H_ */
diff --git a/arch/mips/kernel/Makefile b/arch/mips/kernel/Makefile
index 912eb64..2a8a272 100644
--- a/arch/mips/kernel/Makefile
+++ b/arch/mips/kernel/Makefile
@@ -55,7 +55,7 @@ obj-$(CONFIG_MIPS_CMP)		+= smp-cmp.o
 obj-$(CONFIG_CPU_MIPSR2)	+= spram.o
 
 obj-$(CONFIG_MIPS_VPE_LOADER)	+= vpe.o vpe-cmp.o vpe-mt.o
-obj-$(CONFIG_MIPS_VPE_APSP_API) += rtlx.o
+obj-$(CONFIG_MIPS_VPE_APSP_API) += rtlx.o rtlx-mt.o
 
 obj-$(CONFIG_I8259)		+= i8259.o
 obj-$(CONFIG_IRQ_CPU)		+= irq_cpu.o
diff --git a/arch/mips/kernel/rtlx-mt.c b/arch/mips/kernel/rtlx-mt.c
new file mode 100644
index 0000000..91d61ba
--- /dev/null
+++ b/arch/mips/kernel/rtlx-mt.c
@@ -0,0 +1,148 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2005 MIPS Technologies, Inc.  All rights reserved.
+ * Copyright (C) 2013 Imagination Technologies Ltd.
+ */
+#include <linux/device.h>
+#include <linux/fs.h>
+#include <linux/err.h>
+#include <linux/wait.h>
+#include <linux/sched.h>
+#include <linux/interrupt.h>
+#include <linux/irq.h>
+
+#include <asm/mips_mt.h>
+#include <asm/vpe.h>
+#include <asm/rtlx.h>
+
+static int major;
+
+static void rtlx_dispatch(void)
+{
+	if (read_c0_cause() & read_c0_status() & C_SW0)
+		do_IRQ(MIPS_CPU_IRQ_BASE + MIPS_CPU_RTLX_IRQ);
+}
+
+/*
+ * Interrupt handler may be called before rtlx_init has otherwise had
+ * a chance to run.
+ */
+static irqreturn_t rtlx_interrupt(int irq, void *dev_id)
+{
+	unsigned int vpeflags;
+	unsigned long flags;
+	int i;
+
+	/* Ought not to be strictly necessary for SMTC builds */
+	local_irq_save(flags);
+	vpeflags = dvpe();
+	set_c0_status(0x100 << MIPS_CPU_RTLX_IRQ);
+	irq_enable_hazard();
+	evpe(vpeflags);
+	local_irq_restore(flags);
+
+	for (i = 0; i < RTLX_CHANNELS; i++) {
+		wake_up(&channel_wqs[i].lx_queue);
+		wake_up(&channel_wqs[i].rt_queue);
+	}
+
+	return IRQ_HANDLED;
+}
+
+static struct irqaction rtlx_irq = {
+	.handler	= rtlx_interrupt,
+	.name		= "RTLX",
+};
+
+static int rtlx_irq_num = MIPS_CPU_IRQ_BASE + MIPS_CPU_RTLX_IRQ;
+
+void _interrupt_sp(void)
+{
+	unsigned long flags;
+
+	local_irq_save(flags);
+	dvpe();
+	settc(1);
+	write_vpe_c0_cause(read_vpe_c0_cause() | C_SW0);
+	evpe(EVPE_ENABLE);
+	local_irq_restore(flags);
+}
+
+int __init rtlx_module_init(void)
+{
+	struct device *dev;
+	int i, err;
+
+	if (!cpu_has_mipsmt) {
+		pr_warn("VPE loader: not a MIPS MT capable processor\n");
+		return -ENODEV;
+	}
+
+	if (aprp_cpu_index() == 0) {
+		pr_warn("No TCs reserved for AP/SP, not initializing RTLX.\n"
+			"Pass maxtcs=<n> argument as kernel argument\n");
+
+		return -ENODEV;
+	}
+
+	major = register_chrdev(0, RTLX_MODULE_NAME, &rtlx_fops);
+	if (major < 0) {
+		pr_err("rtlx_module_init: unable to register device\n");
+		return major;
+	}
+
+	/* initialise the wait queues */
+	for (i = 0; i < RTLX_CHANNELS; i++) {
+		init_waitqueue_head(&channel_wqs[i].rt_queue);
+		init_waitqueue_head(&channel_wqs[i].lx_queue);
+		atomic_set(&channel_wqs[i].in_open, 0);
+		mutex_init(&channel_wqs[i].mutex);
+
+		dev = device_create(mt_class, NULL, MKDEV(major, i), NULL,
+				    "%s%d", RTLX_MODULE_NAME, i);
+		if (IS_ERR(dev)) {
+			err = PTR_ERR(dev);
+			goto out_chrdev;
+		}
+	}
+
+	/* set up notifiers */
+	rtlx_notify.start = rtlx_starting;
+	rtlx_notify.stop = rtlx_stopping;
+	vpe_notify(aprp_cpu_index(), &rtlx_notify);
+
+	if (cpu_has_vint) {
+		aprp_hook = rtlx_dispatch;
+	} else {
+		pr_err("APRP RTLX init on non-vectored-interrupt processor\n");
+		err = -ENODEV;
+		goto out_class;
+	}
+
+	rtlx_irq.dev_id = rtlx;
+	err = setup_irq(rtlx_irq_num, &rtlx_irq);
+	if (err)
+		goto out_class;
+
+	return 0;
+
+out_class:
+	for (i = 0; i < RTLX_CHANNELS; i++)
+		device_destroy(mt_class, MKDEV(major, i));
+out_chrdev:
+	unregister_chrdev(major, RTLX_MODULE_NAME);
+
+	return err;
+}
+
+void __exit rtlx_module_exit(void)
+{
+	int i;
+
+	for (i = 0; i < RTLX_CHANNELS; i++)
+		device_destroy(mt_class, MKDEV(major, i));
+	unregister_chrdev(major, RTLX_MODULE_NAME);
+}
diff --git a/arch/mips/kernel/rtlx.c b/arch/mips/kernel/rtlx.c
index d763f11..cd78618 100644
--- a/arch/mips/kernel/rtlx.c
+++ b/arch/mips/kernel/rtlx.c
@@ -42,52 +42,12 @@
 #include <asm/rtlx.h>
 #include <asm/setup.h>
 
-static struct rtlx_info *rtlx;
-static int major;
-static char module_name[] = "rtlx";
-
-static struct chan_waitqueues {
-	wait_queue_head_t rt_queue;
-	wait_queue_head_t lx_queue;
-	atomic_t in_open;
-	struct mutex mutex;
-} channel_wqs[RTLX_CHANNELS];
-
-static struct vpe_notifications notify;
 static int sp_stopping;
-
-extern void *vpe_get_shared(int index);
-
-static void rtlx_dispatch(void)
-{
-	do_IRQ(MIPS_CPU_IRQ_BASE + MIPS_CPU_RTLX_IRQ);
-}
-
-
-/* Interrupt handler may be called before rtlx_init has otherwise had
-   a chance to run.
-*/
-static irqreturn_t rtlx_interrupt(int irq, void *dev_id)
-{
-	unsigned int vpeflags;
-	unsigned long flags;
-	int i;
-
-	/* Ought not to be strictly necessary for SMTC builds */
-	local_irq_save(flags);
-	vpeflags = dvpe();
-	set_c0_status(0x100 << MIPS_CPU_RTLX_IRQ);
-	irq_enable_hazard();
-	evpe(vpeflags);
-	local_irq_restore(flags);
-
-	for (i = 0; i < RTLX_CHANNELS; i++) {
-			wake_up(&channel_wqs[i].lx_queue);
-			wake_up(&channel_wqs[i].rt_queue);
-	}
-
-	return IRQ_HANDLED;
-}
+struct rtlx_info *rtlx;
+struct chan_waitqueues channel_wqs[RTLX_CHANNELS];
+struct vpe_notifications rtlx_notify;
+void (*aprp_hook)(void) = NULL;
+EXPORT_SYMBOL(aprp_hook);
 
 static void __used dump_rtlx(void)
 {
@@ -127,7 +87,7 @@ static int rtlx_init(struct rtlx_info *rtlxi)
 }
 
 /* notifications */
-static void starting(int vpe)
+void rtlx_starting(int vpe)
 {
 	int i;
 	sp_stopping = 0;
@@ -140,7 +100,7 @@ static void starting(int vpe)
 		wake_up_interruptible(&channel_wqs[i].lx_queue);
 }
 
-static void stopping(int vpe)
+void rtlx_stopping(int vpe)
 {
 	int i;
 
@@ -384,6 +344,8 @@ out:
 	smp_wmb();
 	mutex_unlock(&channel_wqs[index].mutex);
 
+	_interrupt_sp();
+
 	return count;
 }
 
@@ -455,7 +417,7 @@ static ssize_t file_write(struct file *file, const char __user * buffer,
 	return rtlx_write(minor, buffer, count);
 }
 
-static const struct file_operations rtlx_fops = {
+const struct file_operations rtlx_fops = {
 	.owner =   THIS_MODULE,
 	.open =	   file_open,
 	.release = file_release,
@@ -465,93 +427,10 @@ static const struct file_operations rtlx_fops = {
 	.llseek =  noop_llseek,
 };
 
-static struct irqaction rtlx_irq = {
-	.handler	= rtlx_interrupt,
-	.name		= "RTLX",
-};
-
-static int rtlx_irq_num = MIPS_CPU_IRQ_BASE + MIPS_CPU_RTLX_IRQ;
-
-static char register_chrdev_failed[] __initdata =
-	KERN_ERR "rtlx_module_init: unable to register device\n";
-
-static int __init rtlx_module_init(void)
-{
-	struct device *dev;
-	int i, err;
-
-	if (!cpu_has_mipsmt) {
-		printk("VPE loader: not a MIPS MT capable processor\n");
-		return -ENODEV;
-	}
-
-	if (tclimit == 0) {
-		printk(KERN_WARNING "No TCs reserved for AP/SP, not "
-		       "initializing RTLX.\nPass maxtcs=<n> argument as kernel "
-		       "argument\n");
-
-		return -ENODEV;
-	}
-
-	major = register_chrdev(0, module_name, &rtlx_fops);
-	if (major < 0) {
-		printk(register_chrdev_failed);
-		return major;
-	}
-
-	/* initialise the wait queues */
-	for (i = 0; i < RTLX_CHANNELS; i++) {
-		init_waitqueue_head(&channel_wqs[i].rt_queue);
-		init_waitqueue_head(&channel_wqs[i].lx_queue);
-		atomic_set(&channel_wqs[i].in_open, 0);
-		mutex_init(&channel_wqs[i].mutex);
-
-		dev = device_create(mt_class, NULL, MKDEV(major, i), NULL,
-				    "%s%d", module_name, i);
-		if (IS_ERR(dev)) {
-			err = PTR_ERR(dev);
-			goto out_chrdev;
-		}
-	}
-
-	/* set up notifiers */
-	notify.start = starting;
-	notify.stop = stopping;
-	vpe_notify(tclimit, &notify);
-
-	if (cpu_has_vint)
-		set_vi_handler(MIPS_CPU_RTLX_IRQ, rtlx_dispatch);
-	else {
-		pr_err("APRP RTLX init on non-vectored-interrupt processor\n");
-		err = -ENODEV;
-		goto out_chrdev;
-	}
-
-	rtlx_irq.dev_id = rtlx;
-	setup_irq(rtlx_irq_num, &rtlx_irq);
-
-	return 0;
-
-out_chrdev:
-	for (i = 0; i < RTLX_CHANNELS; i++)
-		device_destroy(mt_class, MKDEV(major, i));
-
-	return err;
-}
-
-static void __exit rtlx_module_exit(void)
-{
-	int i;
-
-	for (i = 0; i < RTLX_CHANNELS; i++)
-		device_destroy(mt_class, MKDEV(major, i));
-
-	unregister_chrdev(major, module_name);
-}
-
 module_init(rtlx_module_init);
 module_exit(rtlx_module_exit);
 
 MODULE_DESCRIPTION("MIPS RTLX");
 MODULE_AUTHOR("Elizabeth Oldham, MIPS Technologies, Inc.");
 MODULE_LICENSE("GPL");
+
-- 
1.7.9.5

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

* [PATCH 4/6] MIPS: APRP: Add RTLX API support for CMP platforms.
  2013-10-17  2:14 [PATCH 0/6] MIPS: APRP: Enable APRP for platforms with a CM Steven J. Hill
                   ` (2 preceding siblings ...)
  2013-10-17  2:14 ` [PATCH 3/6] MIPS: APRP: Split RTLX support into separate files Steven J. Hill
@ 2013-10-17  2:14 ` Steven J. Hill
  2013-10-17  2:14 ` [PATCH 5/6] MIPS: APRP: Malta Add support for Malta CMP platform Steven J. Hill
  2013-10-17  2:14 ` [PATCH 6/6] MIPS: APRP: Code formatting clean-ups Steven J. Hill
  5 siblings, 0 replies; 20+ messages in thread
From: Steven J. Hill @ 2013-10-17  2:14 UTC (permalink / raw)
  To: linux-mips; +Cc: Deng-Cheng Zhu, ralf, Steven J. Hill

From: Deng-Cheng Zhu <dengcheng.zhu@imgtec.com>

This patch adds RTLX API support for platforms having a CMP.

Signed-off-by: Deng-Cheng Zhu <dengcheng.zhu@imgtec.com>
Signed-off-by: Steven J. Hill <Steven.Hill@imgtec.com>
Reviewed-by: Qais Yousef <Qais.Yousef@imgtec.com>
---
 arch/mips/include/asm/rtlx.h |    1 +
 arch/mips/kernel/Makefile    |    2 +-
 arch/mips/kernel/rtlx-cmp.c  |  120 ++++++++++++++++++++++++++++++++++++++++++
 arch/mips/kernel/rtlx-mt.c   |    4 ++
 4 files changed, 126 insertions(+), 1 deletion(-)
 create mode 100644 arch/mips/kernel/rtlx-cmp.c

diff --git a/arch/mips/include/asm/rtlx.h b/arch/mips/include/asm/rtlx.h
index 6766026..fa86dfd 100644
--- a/arch/mips/include/asm/rtlx.h
+++ b/arch/mips/include/asm/rtlx.h
@@ -78,6 +78,7 @@ struct rtlx_channel {
 extern struct rtlx_info {
 	unsigned long id;
 	enum rtlx_state state;
+	int ap_int_pending;	/* Status of 0 or 1 for CONFIG_MIPS_CMP only */
 
 	struct rtlx_channel channel[RTLX_CHANNELS];
 } *rtlx;
diff --git a/arch/mips/kernel/Makefile b/arch/mips/kernel/Makefile
index 2a8a272..91c8d5b 100644
--- a/arch/mips/kernel/Makefile
+++ b/arch/mips/kernel/Makefile
@@ -55,7 +55,7 @@ obj-$(CONFIG_MIPS_CMP)		+= smp-cmp.o
 obj-$(CONFIG_CPU_MIPSR2)	+= spram.o
 
 obj-$(CONFIG_MIPS_VPE_LOADER)	+= vpe.o vpe-cmp.o vpe-mt.o
-obj-$(CONFIG_MIPS_VPE_APSP_API) += rtlx.o rtlx-mt.o
+obj-$(CONFIG_MIPS_VPE_APSP_API) += rtlx.o rtlx-cmp.o rtlx-mt.o
 
 obj-$(CONFIG_I8259)		+= i8259.o
 obj-$(CONFIG_IRQ_CPU)		+= irq_cpu.o
diff --git a/arch/mips/kernel/rtlx-cmp.c b/arch/mips/kernel/rtlx-cmp.c
new file mode 100644
index 0000000..0171cb3
--- /dev/null
+++ b/arch/mips/kernel/rtlx-cmp.c
@@ -0,0 +1,120 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2005 MIPS Technologies, Inc.  All rights reserved.
+ * Copyright (C) 2013 Imagination Technologies Ltd.
+ */
+#ifdef CONFIG_MIPS_CMP
+
+#include <linux/device.h>
+#include <linux/fs.h>
+#include <linux/err.h>
+#include <linux/wait.h>
+#include <linux/sched.h>
+#include <linux/smp.h>
+
+#include <asm/mips_mt.h>
+#include <asm/vpe.h>
+#include <asm/rtlx.h>
+
+static int major;
+
+static void rtlx_interrupt(void)
+{
+	int i;
+	struct rtlx_info *info;
+	struct rtlx_info **p = vpe_get_shared(aprp_cpu_index());
+
+	if (p == NULL || *p == NULL)
+		return;
+
+	info = *p;
+
+	if (info->ap_int_pending == 1 && smp_processor_id() == 0) {
+		for (i = 0; i < RTLX_CHANNELS; i++) {
+			wake_up(&channel_wqs[i].lx_queue);
+			wake_up(&channel_wqs[i].rt_queue);
+		}
+		info->ap_int_pending = 0;
+	}
+}
+
+void _interrupt_sp(void)
+{
+	smp_send_reschedule(aprp_cpu_index());
+}
+
+int __init rtlx_module_init(void)
+{
+	struct device *dev;
+	int i, err;
+
+	if (!cpu_has_mipsmt) {
+		pr_warn("VPE loader: not a MIPS MT capable processor\n");
+		return -ENODEV;
+	}
+
+	if (num_possible_cpus() - aprp_cpu_index() < 1) {
+		pr_warn("No TCs reserved for AP/SP, not initializing RTLX.\n"
+			"Pass maxcpus=<n> argument as kernel argument\n");
+
+		return -ENODEV;
+	}
+
+	major = register_chrdev(0, RTLX_MODULE_NAME, &rtlx_fops);
+	if (major < 0) {
+		pr_err("rtlx_module_init: unable to register device\n");
+		return major;
+	}
+
+	/* initialise the wait queues */
+	for (i = 0; i < RTLX_CHANNELS; i++) {
+		init_waitqueue_head(&channel_wqs[i].rt_queue);
+		init_waitqueue_head(&channel_wqs[i].lx_queue);
+		atomic_set(&channel_wqs[i].in_open, 0);
+		mutex_init(&channel_wqs[i].mutex);
+
+		dev = device_create(mt_class, NULL, MKDEV(major, i), NULL,
+				    "%s%d", RTLX_MODULE_NAME, i);
+		if (IS_ERR(dev)) {
+			err = PTR_ERR(dev);
+			goto out_chrdev;
+		}
+	}
+
+	/* set up notifiers */
+	rtlx_notify.start = rtlx_starting;
+	rtlx_notify.stop = rtlx_stopping;
+	vpe_notify(aprp_cpu_index(), &rtlx_notify);
+
+	if (cpu_has_vint) {
+		aprp_hook = rtlx_interrupt;
+	} else {
+		pr_err("APRP RTLX init on non-vectored-interrupt processor\n");
+		err = -ENODEV;
+		goto out_class;
+	}
+
+	return 0;
+
+out_class:
+	for (i = 0; i < RTLX_CHANNELS; i++)
+		device_destroy(mt_class, MKDEV(major, i));
+out_chrdev:
+	unregister_chrdev(major, RTLX_MODULE_NAME);
+
+	return err;
+}
+
+void __exit rtlx_module_exit(void)
+{
+	int i;
+
+	for (i = 0; i < RTLX_CHANNELS; i++)
+		device_destroy(mt_class, MKDEV(major, i));
+	unregister_chrdev(major, RTLX_MODULE_NAME);
+}
+
+#endif /* CONFIG_MIPS_CMP */
diff --git a/arch/mips/kernel/rtlx-mt.c b/arch/mips/kernel/rtlx-mt.c
index 91d61ba..80c408a 100644
--- a/arch/mips/kernel/rtlx-mt.c
+++ b/arch/mips/kernel/rtlx-mt.c
@@ -6,6 +6,8 @@
  * Copyright (C) 2005 MIPS Technologies, Inc.  All rights reserved.
  * Copyright (C) 2013 Imagination Technologies Ltd.
  */
+#ifndef CONFIG_MIPS_CMP
+
 #include <linux/device.h>
 #include <linux/fs.h>
 #include <linux/err.h>
@@ -146,3 +148,5 @@ void __exit rtlx_module_exit(void)
 		device_destroy(mt_class, MKDEV(major, i));
 	unregister_chrdev(major, RTLX_MODULE_NAME);
 }
+
+#endif /* CONFIG_MIPS_CMP */
-- 
1.7.9.5

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

* [PATCH 5/6] MIPS: APRP: Malta Add support for Malta CMP platform.
  2013-10-17  2:14 [PATCH 0/6] MIPS: APRP: Enable APRP for platforms with a CM Steven J. Hill
                   ` (3 preceding siblings ...)
  2013-10-17  2:14 ` [PATCH 4/6] MIPS: APRP: Add RTLX API support for CMP platforms Steven J. Hill
@ 2013-10-17  2:14 ` Steven J. Hill
  2013-10-17  2:14 ` [PATCH 6/6] MIPS: APRP: Code formatting clean-ups Steven J. Hill
  5 siblings, 0 replies; 20+ messages in thread
From: Steven J. Hill @ 2013-10-17  2:14 UTC (permalink / raw)
  To: linux-mips; +Cc: Deng-Cheng Zhu, ralf, Steven J. Hill

From: Deng-Cheng Zhu <dengcheng.zhu@imgtec.com>

Malta with multi-core CM platforms can now use APRP functionality.

Signed-off-by: Deng-Cheng Zhu <dengcheng.zhu@imgtec.com>
Signed-off-by: Steven J. Hill <Steven.Hill@imgtec.com>
Reviewed-by: Qais Yousef <Qais.Yousef@imgtec.com>
---
 arch/mips/include/asm/amon.h     |    4 ++--
 arch/mips/mti-malta/malta-amon.c |   24 +++++++++++++++++++++---
 arch/mips/mti-malta/malta-int.c  |   12 ++++++++++++
 3 files changed, 35 insertions(+), 5 deletions(-)

diff --git a/arch/mips/include/asm/amon.h b/arch/mips/include/asm/amon.h
index c3dc1a6..3bd6e76 100644
--- a/arch/mips/include/asm/amon.h
+++ b/arch/mips/include/asm/amon.h
@@ -3,5 +3,5 @@
  */
 
 int amon_cpu_avail(int);
-void amon_cpu_start(int, unsigned long, unsigned long,
-		    unsigned long, unsigned long);
+int amon_cpu_start(int, unsigned long, unsigned long,
+		   unsigned long, unsigned long);
diff --git a/arch/mips/mti-malta/malta-amon.c b/arch/mips/mti-malta/malta-amon.c
index 1e47844..917df6d 100644
--- a/arch/mips/mti-malta/malta-amon.c
+++ b/arch/mips/mti-malta/malta-amon.c
@@ -25,6 +25,7 @@
 #include <asm/addrspace.h>
 #include <asm/mips-boards/launch.h>
 #include <asm/mipsmtregs.h>
+#include <asm/vpe.h>
 
 int amon_cpu_avail(int cpu)
 {
@@ -48,7 +49,7 @@ int amon_cpu_avail(int cpu)
 	return 1;
 }
 
-void amon_cpu_start(int cpu,
+int amon_cpu_start(int cpu,
 		    unsigned long pc, unsigned long sp,
 		    unsigned long gp, unsigned long a0)
 {
@@ -56,10 +57,10 @@ void amon_cpu_start(int cpu,
 		(struct cpulaunch  *)CKSEG0ADDR(CPULAUNCH);
 
 	if (!amon_cpu_avail(cpu))
-		return;
+		return -1;
 	if (cpu == smp_processor_id()) {
 		pr_debug("launch: I am cpu%d!\n", cpu);
-		return;
+		return -1;
 	}
 	launch += cpu;
 
@@ -78,4 +79,21 @@ void amon_cpu_start(int cpu,
 		;
 	smp_rmb();	/* Target will be updating flags soon */
 	pr_debug("launch: cpu%d gone!\n", cpu);
+
+	return 0;
+}
+
+#ifdef CONFIG_MIPS_VPE_LOADER
+int vpe_run(struct vpe *v)
+{
+	struct vpe_notifications *n;
+
+	if (amon_cpu_start(aprp_cpu_index(), v->__start, 0, 0, 0) < 0)
+		return -1;
+
+	list_for_each_entry(n, &v->notify, list)
+		n->start(VPE_MODULE_MINOR);
+
+	return 0;
 }
+#endif
diff --git a/arch/mips/mti-malta/malta-int.c b/arch/mips/mti-malta/malta-int.c
index be4a1092..ea9338d 100644
--- a/arch/mips/mti-malta/malta-int.c
+++ b/arch/mips/mti-malta/malta-int.c
@@ -2,6 +2,7 @@
  * Carsten Langgaard, carstenl@mips.com
  * Copyright (C) 2000, 2001, 2004 MIPS Technologies, Inc.
  * Copyright (C) 2001 Ralf Baechle
+ * Copyright (C) 2013 Imagination Technologies Ltd.
  *
  *  This program is free software; you can distribute it and/or modify it
  *  under the terms of the GNU General Public License (Version 2) as
@@ -44,6 +45,7 @@
 #include <asm/gic.h>
 #include <asm/gcmpregs.h>
 #include <asm/setup.h>
+#include <asm/rtlx.h>
 
 int gcmp_present = -1;
 static unsigned long _msc01_biu_base;
@@ -126,6 +128,11 @@ static void malta_hw0_irqdispatch(void)
 	}
 
 	do_IRQ(MALTA_INT_BASE + irq);
+
+#ifdef MIPS_VPE_APSP_API
+	if (aprp_hook)
+		aprp_hook();
+#endif
 }
 
 static void malta_ipi_irqdispatch(void)
@@ -313,6 +320,11 @@ static void ipi_call_dispatch(void)
 
 static irqreturn_t ipi_resched_interrupt(int irq, void *dev_id)
 {
+#ifdef MIPS_VPE_APSP_API
+	if (aprp_hook)
+		aprp_hook();
+#endif
+
 	scheduler_ipi();
 
 	return IRQ_HANDLED;
-- 
1.7.9.5

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

* [PATCH 6/6] MIPS: APRP: Code formatting clean-ups.
  2013-10-17  2:14 [PATCH 0/6] MIPS: APRP: Enable APRP for platforms with a CM Steven J. Hill
                   ` (4 preceding siblings ...)
  2013-10-17  2:14 ` [PATCH 5/6] MIPS: APRP: Malta Add support for Malta CMP platform Steven J. Hill
@ 2013-10-17  2:14 ` Steven J. Hill
  2013-10-17 17:50   ` David Daney
  5 siblings, 1 reply; 20+ messages in thread
From: Steven J. Hill @ 2013-10-17  2:14 UTC (permalink / raw)
  To: linux-mips; +Cc: Steven J. Hill, ralf

From: "Steven J. Hill" <Steven.Hill@imgtec.com>

Clean-up code according to the 'checkpatch.pl' script.

Signed-off-by: Steven J. Hill <Steven.Hill@imgtec.com>
Reviewed-by: Qais Yousef <Qais.Yousef@imgtec.com>
---
 arch/mips/include/asm/amon.h     |   15 ++-
 arch/mips/include/asm/rtlx.h     |    5 +-
 arch/mips/include/asm/vpe.h      |   19 +--
 arch/mips/kernel/rtlx.c          |  134 ++++++++------------
 arch/mips/kernel/vpe-mt.c        |    6 +-
 arch/mips/kernel/vpe.c           |  252 +++++++++++++++++---------------------
 arch/mips/mti-malta/malta-amon.c |   24 ++--
 arch/mips/mti-malta/malta-int.c  |  115 +++++++++--------
 8 files changed, 250 insertions(+), 320 deletions(-)

diff --git a/arch/mips/include/asm/amon.h b/arch/mips/include/asm/amon.h
index 3bd6e76..3cc03c6 100644
--- a/arch/mips/include/asm/amon.h
+++ b/arch/mips/include/asm/amon.h
@@ -1,7 +1,12 @@
 /*
- * Amon support
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2013 Imagination Technologies Ltd.
+ *
+ * Arbitrary Monitor Support (AMON)
  */
-
-int amon_cpu_avail(int);
-int amon_cpu_start(int, unsigned long, unsigned long,
-		   unsigned long, unsigned long);
+int amon_cpu_avail(int cpu);
+int amon_cpu_start(int cpu, unsigned long pc, unsigned long sp,
+		   unsigned long gp, unsigned long a0);
diff --git a/arch/mips/include/asm/rtlx.h b/arch/mips/include/asm/rtlx.h
index fa86dfd..c102065 100644
--- a/arch/mips/include/asm/rtlx.h
+++ b/arch/mips/include/asm/rtlx.h
@@ -1,8 +1,11 @@
 /*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
  * Copyright (C) 2004, 2005 MIPS Technologies, Inc.  All rights reserved.
  * Copyright (C) 2013 Imagination Technologies Ltd.
  */
-
 #ifndef __ASM_RTLX_H_
 #define __ASM_RTLX_H_
 
diff --git a/arch/mips/include/asm/vpe.h b/arch/mips/include/asm/vpe.h
index becd555..e0684f5 100644
--- a/arch/mips/include/asm/vpe.h
+++ b/arch/mips/include/asm/vpe.h
@@ -1,22 +1,11 @@
 /*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
  * Copyright (C) 2005 MIPS Technologies, Inc.  All rights reserved.
  * Copyright (C) 2013 Imagination Technologies Ltd.
- *
- *  This program is free software; you can distribute it and/or modify it
- *  under the terms of the GNU General Public License (Version 2) as
- *  published by the Free Software Foundation.
- *
- *  This program is distributed in the hope it will be useful, but WITHOUT
- *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- *  for more details.
- *
- *  You should have received a copy of the GNU General Public License along
- *  with this program; if not, write to the Free Software Foundation, Inc.,
- *  59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
  */
-
 #ifndef _ASM_VPE_H
 #define _ASM_VPE_H
 
diff --git a/arch/mips/kernel/rtlx.c b/arch/mips/kernel/rtlx.c
index cd78618..8053b4e 100644
--- a/arch/mips/kernel/rtlx.c
+++ b/arch/mips/kernel/rtlx.c
@@ -1,46 +1,23 @@
 /*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
  * Copyright (C) 2005 MIPS Technologies, Inc.  All rights reserved.
  * Copyright (C) 2005, 06 Ralf Baechle (ralf@linux-mips.org)
- *
- *  This program is free software; you can distribute it and/or modify it
- *  under the terms of the GNU General Public License (Version 2) as
- *  published by the Free Software Foundation.
- *
- *  This program is distributed in the hope it will be useful, but WITHOUT
- *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- *  for more details.
- *
- *  You should have received a copy of the GNU General Public License along
- *  with this program; if not, write to the Free Software Foundation, Inc.,
- *  59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
+ * Copyright (C) 2013 Imagination Technologies Ltd.
  */
-
-#include <linux/device.h>
 #include <linux/kernel.h>
 #include <linux/fs.h>
-#include <linux/init.h>
-#include <asm/uaccess.h>
-#include <linux/list.h>
-#include <linux/vmalloc.h>
-#include <linux/elf.h>
-#include <linux/seq_file.h>
 #include <linux/syscalls.h>
 #include <linux/moduleloader.h>
-#include <linux/interrupt.h>
-#include <linux/poll.h>
-#include <linux/sched.h>
-#include <linux/wait.h>
+#include <linux/atomic.h>
 #include <asm/mipsmtregs.h>
 #include <asm/mips_mt.h>
-#include <asm/cacheflush.h>
-#include <linux/atomic.h>
-#include <asm/cpu.h>
 #include <asm/processor.h>
-#include <asm/vpe.h>
 #include <asm/rtlx.h>
 #include <asm/setup.h>
+#include <asm/vpe.h>
 
 static int sp_stopping;
 struct rtlx_info *rtlx;
@@ -53,22 +30,22 @@ static void __used dump_rtlx(void)
 {
 	int i;
 
-	printk("id 0x%lx state %d\n", rtlx->id, rtlx->state);
+	pr_info("id 0x%lx state %d\n", rtlx->id, rtlx->state);
 
 	for (i = 0; i < RTLX_CHANNELS; i++) {
 		struct rtlx_channel *chan = &rtlx->channel[i];
 
-		printk(" rt_state %d lx_state %d buffer_size %d\n",
-		       chan->rt_state, chan->lx_state, chan->buffer_size);
+		pr_info(" rt_state %d lx_state %d buffer_size %d\n",
+			chan->rt_state, chan->lx_state, chan->buffer_size);
 
-		printk(" rt_read %d rt_write %d\n",
-		       chan->rt_read, chan->rt_write);
+		pr_info(" rt_read %d rt_write %d\n",
+			chan->rt_read, chan->rt_write);
 
-		printk(" lx_read %d lx_write %d\n",
-		       chan->lx_read, chan->lx_write);
+		pr_info(" lx_read %d lx_write %d\n",
+			chan->lx_read, chan->lx_write);
 
-		printk(" rt_buffer <%s>\n", chan->rt_buffer);
-		printk(" lx_buffer <%s>\n", chan->lx_buffer);
+		pr_info(" rt_buffer <%s>\n", chan->rt_buffer);
+		pr_info(" lx_buffer <%s>\n", chan->lx_buffer);
 	}
 }
 
@@ -76,8 +53,7 @@ static void __used dump_rtlx(void)
 static int rtlx_init(struct rtlx_info *rtlxi)
 {
 	if (rtlxi->id != RTLX_ID) {
-		printk(KERN_ERR "no valid RTLX id at 0x%p 0x%lx\n",
-			rtlxi, rtlxi->id);
+		pr_err("no valid RTLX id at 0x%p 0x%lx\n", rtlxi, rtlxi->id);
 		return -ENOEXEC;
 	}
 
@@ -93,7 +69,7 @@ void rtlx_starting(int vpe)
 	sp_stopping = 0;
 
 	/* force a reload of rtlx */
-	rtlx=NULL;
+	rtlx = NULL;
 
 	/* wake up any sleeping rtlx_open's */
 	for (i = 0; i < RTLX_CHANNELS; i++)
@@ -118,30 +94,31 @@ int rtlx_open(int index, int can_sleep)
 	int ret = 0;
 
 	if (index >= RTLX_CHANNELS) {
-		printk(KERN_DEBUG "rtlx_open index out of range\n");
+		pr_debug("rtlx_open index out of range\n");
 		return -ENOSYS;
 	}
 
 	if (atomic_inc_return(&channel_wqs[index].in_open) > 1) {
-		printk(KERN_DEBUG "rtlx_open channel %d already opened\n",
-		       index);
+		pr_debug("rtlx_open channel %d already opened\n", index);
 		ret = -EBUSY;
 		goto out_fail;
 	}
 
 	if (rtlx == NULL) {
-		if( (p = vpe_get_shared(tclimit)) == NULL) {
-		    if (can_sleep) {
-			__wait_event_interruptible(channel_wqs[index].lx_queue,
-				(p = vpe_get_shared(tclimit)), ret);
-			if (ret)
+		p = vpe_get_shared(aprp_cpu_index());
+		if (p == NULL) {
+			if (can_sleep) {
+				__wait_event_interruptible(
+					channel_wqs[index].lx_queue,
+					(p = vpe_get_shared(aprp_cpu_index())),
+					ret);
+				if (ret)
+					goto out_fail;
+			} else {
+				pr_debug("No SP program loaded, and device opened with O_NONBLOCK\n");
+				ret = -ENOSYS;
 				goto out_fail;
-		    } else {
-			printk(KERN_DEBUG "No SP program loaded, and device "
-					"opened with O_NONBLOCK\n");
-			ret = -ENOSYS;
-			goto out_fail;
-		    }
+			}
 		}
 
 		smp_rmb();
@@ -163,24 +140,24 @@ int rtlx_open(int index, int can_sleep)
 					ret = -ERESTARTSYS;
 					goto out_fail;
 				}
-				finish_wait(&channel_wqs[index].lx_queue, &wait);
+				finish_wait(&channel_wqs[index].lx_queue,
+					    &wait);
 			} else {
-				pr_err(" *vpe_get_shared is NULL. "
-				       "Has an SP program been loaded?\n");
+				pr_err(" *vpe_get_shared is NULL. Has an SP program been loaded?\n");
 				ret = -ENOSYS;
 				goto out_fail;
 			}
 		}
 
 		if ((unsigned int)*p < KSEG0) {
-			printk(KERN_WARNING "vpe_get_shared returned an "
-			       "invalid pointer maybe an error code %d\n",
-			       (int)*p);
+			pr_warn("vpe_get_shared returned an invalid pointer maybe an error code %d\n",
+				(int)*p);
 			ret = -ENOSYS;
 			goto out_fail;
 		}
 
-		if ((ret = rtlx_init(*p)) < 0)
+		ret = rtlx_init(*p);
+		if (ret < 0)
 			goto out_ret;
 	}
 
@@ -312,7 +289,7 @@ ssize_t rtlx_write(int index, const void __user *buffer, size_t count)
 	size_t fl;
 
 	if (rtlx == NULL)
-		return(-ENOSYS);
+		return -ENOSYS;
 
 	rt = &rtlx->channel[index];
 
@@ -321,8 +298,8 @@ ssize_t rtlx_write(int index, const void __user *buffer, size_t count)
 	rt_read = rt->rt_read;
 
 	/* total number of bytes to copy */
-	count = min(count, (size_t)write_spacefree(rt_read, rt->rt_write,
-							rt->buffer_size));
+	count = min_t(size_t, count, write_spacefree(rt_read, rt->rt_write,
+						     rt->buffer_size));
 
 	/* first bit from write pointer to the end of the buffer, or count */
 	fl = min(count, (size_t) rt->buffer_size - rt->rt_write);
@@ -332,9 +309,8 @@ ssize_t rtlx_write(int index, const void __user *buffer, size_t count)
 		goto out;
 
 	/* if there's any left copy to the beginning of the buffer */
-	if (count - fl) {
+	if (count - fl)
 		failed = copy_from_user(rt->rt_buffer, buffer + fl, count - fl);
-	}
 
 out:
 	count -= failed;
@@ -360,7 +336,7 @@ static int file_release(struct inode *inode, struct file *filp)
 	return rtlx_release(iminor(inode));
 }
 
-static unsigned int file_poll(struct file *file, poll_table * wait)
+static unsigned int file_poll(struct file *file, poll_table *wait)
 {
 	int minor = iminor(file_inode(file));
 	unsigned int mask = 0;
@@ -382,21 +358,20 @@ static unsigned int file_poll(struct file *file, poll_table * wait)
 	return mask;
 }
 
-static ssize_t file_read(struct file *file, char __user * buffer, size_t count,
-			 loff_t * ppos)
+static ssize_t file_read(struct file *file, char __user *buffer, size_t count,
+			 loff_t *ppos)
 {
 	int minor = iminor(file_inode(file));
 
 	/* data available? */
-	if (!rtlx_read_poll(minor, (file->f_flags & O_NONBLOCK) ? 0 : 1)) {
-		return 0;	// -EAGAIN makes cat whinge
-	}
+	if (!rtlx_read_poll(minor, (file->f_flags & O_NONBLOCK) ? 0 : 1))
+		return 0;	/* -EAGAIN makes 'cat' whine */
 
 	return rtlx_read(minor, buffer, count);
 }
 
-static ssize_t file_write(struct file *file, const char __user * buffer,
-			  size_t count, loff_t * ppos)
+static ssize_t file_write(struct file *file, const char __user *buffer,
+			  size_t count, loff_t *ppos)
 {
 	int minor = iminor(file_inode(file));
 
@@ -419,11 +394,11 @@ static ssize_t file_write(struct file *file, const char __user * buffer,
 
 const struct file_operations rtlx_fops = {
 	.owner =   THIS_MODULE,
-	.open =	   file_open,
+	.open =    file_open,
 	.release = file_release,
 	.write =   file_write,
-	.read =	   file_read,
-	.poll =	   file_poll,
+	.read =    file_read,
+	.poll =    file_poll,
 	.llseek =  noop_llseek,
 };
 
@@ -433,4 +408,3 @@ module_exit(rtlx_module_exit);
 MODULE_DESCRIPTION("MIPS RTLX");
 MODULE_AUTHOR("Elizabeth Oldham, MIPS Technologies, Inc.");
 MODULE_LICENSE("GPL");
-
diff --git a/arch/mips/kernel/vpe-mt.c b/arch/mips/kernel/vpe-mt.c
index 323ca69..daccee4 100644
--- a/arch/mips/kernel/vpe-mt.c
+++ b/arch/mips/kernel/vpe-mt.c
@@ -28,7 +28,7 @@ static int hw_tcs, hw_vpes;
 int vpe_run(struct vpe *v)
 {
 	unsigned long flags, val, dmt_flag;
-	struct vpe_notifications *n;
+	struct vpe_notifications *notifier;
 	unsigned int vpeflags;
 	struct tc *t;
 
@@ -141,8 +141,8 @@ int vpe_run(struct vpe *v)
 	emt(dmt_flag);
 	local_irq_restore(flags);
 
-	list_for_each_entry(n, &v->notify, list)
-		n->start(VPE_MODULE_MINOR);
+	list_for_each_entry(notifier, &v->notify, list)
+		notifier->start(VPE_MODULE_MINOR);
 
 	return 0;
 }
diff --git a/arch/mips/kernel/vpe.c b/arch/mips/kernel/vpe.c
index 61dfd5b..42d3ca0 100644
--- a/arch/mips/kernel/vpe.c
+++ b/arch/mips/kernel/vpe.c
@@ -1,37 +1,22 @@
 /*
- * Copyright (C) 2004, 2005 MIPS Technologies, Inc.  All rights reserved.
- *
- *  This program is free software; you can distribute it and/or modify it
- *  under the terms of the GNU General Public License (Version 2) as
- *  published by the Free Software Foundation.
- *
- *  This program is distributed in the hope it will be useful, but WITHOUT
- *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- *  for more details.
- *
- *  You should have received a copy of the GNU General Public License along
- *  with this program; if not, write to the Free Software Foundation, Inc.,
- *  59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
- */
-
-/*
- * VPE support module
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
  *
- * Provides support for loading a MIPS SP program on VPE1.
- * The SP environment is rather simple, no tlb's.  It needs to be relocatable
- * (or partially linked). You should initialise your stack in the startup
- * code. This loader looks for the symbol __start and sets up
- * execution to resume from there. The MIPS SDE kit contains suitable examples.
+ * Copyright (C) 2004, 2005 MIPS Technologies, Inc.  All rights reserved.
+ * Copyright (C) 2013 Imagination Technologies Ltd.
  *
- * To load and run, simply cat a SP 'program file' to /dev/vpe1.
- * i.e cat spapp >/dev/vpe1.
+ * VPE spport module for loading a MIPS SP program into VPE1. The SP
+ * environment is rather simple since there are no TLBs. It needs
+ * to be relocatable (or partiall linked). Initialize your stack in
+ * the startup-code. The loader looks for the symbol __start and sets
+ * up the execution to resume from there. To load and run, simply do
+ * a cat SP 'binary' to the /dev/vpe1 device.
  */
 #include <linux/kernel.h>
 #include <linux/device.h>
 #include <linux/fs.h>
 #include <linux/init.h>
-#include <asm/uaccess.h>
 #include <linux/slab.h>
 #include <linux/list.h>
 #include <linux/vmalloc.h>
@@ -46,7 +31,6 @@
 #include <asm/mipsmtregs.h>
 #include <asm/cacheflush.h>
 #include <linux/atomic.h>
-#include <asm/cpu.h>
 #include <asm/mips_mt.h>
 #include <asm/processor.h>
 #include <asm/vpe.h>
@@ -109,8 +93,9 @@ struct vpe *alloc_vpe(int minor)
 {
 	struct vpe *v;
 
-	if ((v = kzalloc(sizeof(struct vpe), GFP_KERNEL)) == NULL)
-		return NULL;
+	v = kzalloc(sizeof(struct vpe), GFP_KERNEL);
+	if (v == NULL)
+		goto out;
 
 	INIT_LIST_HEAD(&v->tc);
 	spin_lock(&vpecontrol.vpe_list_lock);
@@ -120,6 +105,7 @@ struct vpe *alloc_vpe(int minor)
 	INIT_LIST_HEAD(&v->notify);
 	v->minor = VPE_MODULE_MINOR;
 
+out:
 	return v;
 }
 
@@ -128,7 +114,8 @@ struct tc *alloc_tc(int index)
 {
 	struct tc *tc;
 
-	if ((tc = kzalloc(sizeof(struct tc), GFP_KERNEL)) == NULL)
+	tc = kzalloc(sizeof(struct tc), GFP_KERNEL);
+	if (tc == NULL)
 		goto out;
 
 	INIT_LIST_HEAD(&tc->tc);
@@ -151,7 +138,7 @@ void release_vpe(struct vpe *v)
 	kfree(v);
 }
 
-/* Find some VPE program space	*/
+/* Find some VPE program space */
 void *alloc_progmem(unsigned long len)
 {
 	void *addr;
@@ -179,7 +166,7 @@ void release_progmem(void *ptr)
 }
 
 /* Update size with this section: return offset. */
-static long get_offset(unsigned long *size, Elf_Shdr * sechdr)
+static long get_offset(unsigned long *size, Elf_Shdr *sechdr)
 {
 	long ret;
 
@@ -192,8 +179,8 @@ static long get_offset(unsigned long *size, Elf_Shdr * sechdr)
    might -- code, read-only data, read-write data, small data.	Tally
    sizes, and place the offsets into sh_entsize fields: high bit means it
    belongs in init. */
-static void layout_sections(struct module *mod, const Elf_Ehdr * hdr,
-			    Elf_Shdr * sechdrs, const char *secstrings)
+static void layout_sections(struct module *mod, const Elf_Ehdr *hdr,
+			    Elf_Shdr *sechdrs, const char *secstrings)
 {
 	static unsigned long const masks[][2] = {
 		/* NOTE: all executable code must be the first section
@@ -213,7 +200,6 @@ static void layout_sections(struct module *mod, const Elf_Ehdr * hdr,
 		for (i = 0; i < hdr->e_shnum; ++i) {
 			Elf_Shdr *s = &sechdrs[i];
 
-			//  || strncmp(secstrings + s->sh_name, ".init", 5) == 0)
 			if ((s->sh_flags & masks[m][0]) != masks[m][0]
 			    || (s->sh_flags & masks[m][1])
 			    || s->sh_entsize != ~0UL)
@@ -228,7 +214,6 @@ static void layout_sections(struct module *mod, const Elf_Ehdr * hdr,
 	}
 }
 
-
 /* from module-elf32.c, but subverted a little */
 
 struct mips_hi16 {
@@ -251,20 +236,18 @@ static int apply_r_mips_gprel16(struct module *me, uint32_t *location,
 {
 	int rel;
 
-	if( !(*location & 0xffff) ) {
+	if (!(*location & 0xffff)) {
 		rel = (int)v - gp_addr;
-	}
-	else {
+	} else {
 		/* .sbss + gp(relative) + offset */
 		/* kludge! */
 		rel =  (int)(short)((int)v + gp_offs +
 				    (int)(short)(*location & 0xffff) - gp_addr);
 	}
 
-	if( (rel > 32768) || (rel < -32768) ) {
-		printk(KERN_DEBUG "VPE loader: apply_r_mips_gprel16: "
-		       "relative address 0x%x out of range of gp register\n",
-		       rel);
+	if ((rel > 32768) || (rel < -32768)) {
+		pr_debug("VPE loader: apply_r_mips_gprel16: relative address 0x%x out of range of gp register\n",
+			 rel);
 		return -ENOEXEC;
 	}
 
@@ -278,12 +261,12 @@ static int apply_r_mips_pc16(struct module *me, uint32_t *location,
 {
 	int rel;
 	rel = (((unsigned int)v - (unsigned int)location));
-	rel >>= 2;		// because the offset is in _instructions_ not bytes.
-	rel -= 1;		// and one instruction less due to the branch delay slot.
+	rel >>= 2; /* because the offset is in _instructions_ not bytes. */
+	rel -= 1;  /* and one instruction less due to the branch delay slot. */
 
-	if( (rel > 32768) || (rel < -32768) ) {
-		printk(KERN_DEBUG "VPE loader: "
-		       "apply_r_mips_pc16: relative address out of range 0x%x\n", rel);
+	if ((rel > 32768) || (rel < -32768)) {
+		pr_debug("VPE loader: apply_r_mips_pc16: relative address out of range 0x%x\n",
+			 rel);
 		return -ENOEXEC;
 	}
 
@@ -304,8 +287,7 @@ static int apply_r_mips_26(struct module *me, uint32_t *location,
 			   Elf32_Addr v)
 {
 	if (v % 4) {
-		printk(KERN_DEBUG "VPE loader: apply_r_mips_26 "
-		       " unaligned relocation\n");
+		pr_debug("VPE loader: apply_r_mips_26: unaligned relocation\n");
 		return -ENOEXEC;
 	}
 
@@ -336,7 +318,7 @@ static int apply_r_mips_hi16(struct module *me, uint32_t *location,
 	 * the carry we need to add.  Save the information, and let LO16 do the
 	 * actual relocation.
 	 */
-	n = kmalloc(sizeof *n, GFP_KERNEL);
+	n = kmalloc(sizeof(*n), GFP_KERNEL);
 	if (!n)
 		return -ENOMEM;
 
@@ -368,9 +350,7 @@ static int apply_r_mips_lo16(struct module *me, uint32_t *location,
 			 * The value for the HI16 had best be the same.
 			 */
 			if (v != l->value) {
-				printk(KERN_DEBUG "VPE loader: "
-				       "apply_r_mips_lo16/hi16: \t"
-				       "inconsistent value information\n");
+				pr_debug("VPE loader: apply_r_mips_lo16/hi16: inconsistent value information\n");
 				goto out_free;
 			}
 
@@ -466,20 +446,19 @@ static int apply_relocations(Elf32_Shdr *sechdrs,
 			+ ELF32_R_SYM(r_info);
 
 		if (!sym->st_value) {
-			printk(KERN_DEBUG "%s: undefined weak symbol %s\n",
-			       me->name, strtab + sym->st_name);
+			pr_debug("%s: undefined weak symbol %s\n",
+				 me->name, strtab + sym->st_name);
 			/* just print the warning, dont barf */
 		}
 
 		v = sym->st_value;
 
 		res = reloc_handlers[ELF32_R_TYPE(r_info)](me, location, v);
-		if( res ) {
+		if (res) {
 			char *r = rstrs[ELF32_R_TYPE(r_info)];
-			printk(KERN_WARNING "VPE loader: .text+0x%x "
-			       "relocation type %s for symbol \"%s\" failed\n",
-			       rel[i].r_offset, r ? r : "UNKNOWN",
-			       strtab + sym->st_name);
+			pr_warn("VPE loader: .text+0x%x relocation type %s for symbol \"%s\" failed\n",
+				rel[i].r_offset, r ? r : "UNKNOWN",
+				strtab + sym->st_name);
 			return res;
 		}
 	}
@@ -494,10 +473,8 @@ static inline void save_gp_address(unsigned int secbase, unsigned int rel)
 }
 /* end module-elf32.c */
 
-
-
 /* Change all symbols so that sh_value encodes the pointer directly. */
-static void simplify_symbols(Elf_Shdr * sechdrs,
+static void simplify_symbols(Elf_Shdr *sechdrs,
 			    unsigned int symindex,
 			    const char *strtab,
 			    const char *secstrings,
@@ -538,18 +515,16 @@ static void simplify_symbols(Elf_Shdr * sechdrs,
 			break;
 
 		case SHN_MIPS_SCOMMON:
-			printk(KERN_DEBUG "simplify_symbols: ignoring SHN_MIPS_SCOMMON "
-			       "symbol <%s> st_shndx %d\n", strtab + sym[i].st_name,
-			       sym[i].st_shndx);
-			// .sbss section
+			pr_debug("simplify_symbols: ignoring SHN_MIPS_SCOMMON symbol <%s> st_shndx %d\n",
+				 strtab + sym[i].st_name, sym[i].st_shndx);
+			/* .sbss section */
 			break;
 
 		default:
 			secbase = sechdrs[sym[i].st_shndx].sh_addr;
 
-			if (strncmp(strtab + sym[i].st_name, "_gp", 3) == 0) {
+			if (strncmp(strtab + sym[i].st_name, "_gp", 3) == 0)
 				save_gp_address(secbase, sym[i].st_value);
-			}
 
 			sym[i].st_value += secbase;
 			break;
@@ -558,21 +533,21 @@ static void simplify_symbols(Elf_Shdr * sechdrs,
 }
 
 #ifdef DEBUG_ELFLOADER
-static void dump_elfsymbols(Elf_Shdr * sechdrs, unsigned int symindex,
+static void dump_elfsymbols(Elf_Shdr *sechdrs, unsigned int symindex,
 			    const char *strtab, struct module *mod)
 {
 	Elf_Sym *sym = (void *)sechdrs[symindex].sh_addr;
 	unsigned int i, n = sechdrs[symindex].sh_size / sizeof(Elf_Sym);
 
-	printk(KERN_DEBUG "dump_elfsymbols: n %d\n", n);
+	pr_debug("dump_elfsymbols: n %d\n", n);
 	for (i = 1; i < n; i++) {
-		printk(KERN_DEBUG " i %d name <%s> 0x%x\n", i,
-		       strtab + sym[i].st_name, sym[i].st_value);
+		pr_debug(" i %d name <%s> 0x%x\n", i, strtab + sym[i].st_name,
+			 sym[i].st_value);
 	}
 }
 #endif
 
-static int find_vpe_symbols(struct vpe * v, Elf_Shdr * sechdrs,
+static int find_vpe_symbols(struct vpe *v, Elf_Shdr *sechdrs,
 				      unsigned int symindex, const char *strtab,
 				      struct module *mod)
 {
@@ -580,16 +555,14 @@ static int find_vpe_symbols(struct vpe * v, Elf_Shdr * sechdrs,
 	unsigned int i, n = sechdrs[symindex].sh_size / sizeof(Elf_Sym);
 
 	for (i = 1; i < n; i++) {
-		if (strcmp(strtab + sym[i].st_name, "__start") == 0) {
+		if (strcmp(strtab + sym[i].st_name, "__start") == 0)
 			v->__start = sym[i].st_value;
-		}
 
-		if (strcmp(strtab + sym[i].st_name, "vpe_shared") == 0) {
+		if (strcmp(strtab + sym[i].st_name, "vpe_shared") == 0)
 			v->shared_ptr = (void *)sym[i].st_value;
-		}
 	}
 
-	if ( (v->__start == 0) || (v->shared_ptr == NULL))
+	if ((v->__start == 0) || (v->shared_ptr == NULL))
 		return -1;
 
 	return 0;
@@ -600,14 +573,14 @@ static int find_vpe_symbols(struct vpe * v, Elf_Shdr * sechdrs,
  * contents of the program (p)buffer performing relocatations/etc, free's it
  * when finished.
  */
-static int vpe_elfload(struct vpe * v)
+static int vpe_elfload(struct vpe *v)
 {
 	Elf_Ehdr *hdr;
 	Elf_Shdr *sechdrs;
 	long err = 0;
 	char *secstrings, *strtab = NULL;
 	unsigned int len, i, symindex = 0, strindex = 0, relocate = 0;
-	struct module mod;	// so we can re-use the relocations code
+	struct module mod; /* so we can re-use the relocations code */
 
 	memset(&mod, 0, sizeof(struct module));
 	strcpy(mod.name, "VPE loader");
@@ -621,8 +594,7 @@ static int vpe_elfload(struct vpe * v)
 	    || (hdr->e_type != ET_REL && hdr->e_type != ET_EXEC)
 	    || !elf_check_arch(hdr)
 	    || hdr->e_shentsize != sizeof(*sechdrs)) {
-		printk(KERN_WARNING
-		       "VPE loader: program wrong arch or weird elf version\n");
+		pr_warn("VPE loader: program wrong arch or weird elf version\n");
 
 		return -ENOEXEC;
 	}
@@ -631,8 +603,7 @@ static int vpe_elfload(struct vpe * v)
 		relocate = 1;
 
 	if (len < hdr->e_shoff + hdr->e_shnum * sizeof(Elf_Shdr)) {
-		printk(KERN_ERR "VPE loader: program length %u truncated\n",
-		       len);
+		pr_err("VPE loader: program length %u truncated\n", len);
 
 		return -ENOEXEC;
 	}
@@ -647,22 +618,24 @@ static int vpe_elfload(struct vpe * v)
 
 	if (relocate) {
 		for (i = 1; i < hdr->e_shnum; i++) {
-			if (sechdrs[i].sh_type != SHT_NOBITS
-			    && len < sechdrs[i].sh_offset + sechdrs[i].sh_size) {
-				printk(KERN_ERR "VPE program length %u truncated\n",
+			if ((sechdrs[i].sh_type != SHT_NOBITS) &&
+			    (len < sechdrs[i].sh_offset + sechdrs[i].sh_size)) {
+				pr_err("VPE program length %u truncated\n",
 				       len);
 				return -ENOEXEC;
 			}
 
 			/* Mark all sections sh_addr with their address in the
 			   temporary image. */
-			sechdrs[i].sh_addr = (size_t) hdr + sechdrs[i].sh_offset;
+			sechdrs[i].sh_addr = (size_t) hdr +
+				sechdrs[i].sh_offset;
 
 			/* Internal symbols and strings. */
 			if (sechdrs[i].sh_type == SHT_SYMTAB) {
 				symindex = i;
 				strindex = sechdrs[i].sh_link;
-				strtab = (char *)hdr + sechdrs[strindex].sh_offset;
+				strtab = (char *)hdr +
+					sechdrs[strindex].sh_offset;
 			}
 		}
 		layout_sections(&mod, hdr, sechdrs, secstrings);
@@ -689,8 +662,9 @@ static int vpe_elfload(struct vpe * v)
 			/* Update sh_addr to point to copy in image. */
 			sechdrs[i].sh_addr = (unsigned long)dest;
 
-			printk(KERN_DEBUG " section sh_name %s sh_addr 0x%x\n",
-			       secstrings + sechdrs[i].sh_name, sechdrs[i].sh_addr);
+			pr_debug(" section sh_name %s sh_addr 0x%x\n",
+				 secstrings + sechdrs[i].sh_name,
+				 sechdrs[i].sh_addr);
 		}
 
 		/* Fix up syms, so that st_value is a pointer to location. */
@@ -711,17 +685,18 @@ static int vpe_elfload(struct vpe * v)
 				continue;
 
 			if (sechdrs[i].sh_type == SHT_REL)
-				err = apply_relocations(sechdrs, strtab, symindex, i,
-							&mod);
+				err = apply_relocations(sechdrs, strtab,
+							symindex, i, &mod);
 			else if (sechdrs[i].sh_type == SHT_RELA)
-				err = apply_relocate_add(sechdrs, strtab, symindex, i,
-							 &mod);
+				err = apply_relocate_add(sechdrs, strtab,
+							 symindex, i, &mod);
 			if (err < 0)
 				return err;
 
 		}
 	} else {
-		struct elf_phdr *phdr = (struct elf_phdr *) ((char *)hdr + hdr->e_phoff);
+		struct elf_phdr *phdr = (struct elf_phdr *)
+						((char *)hdr + hdr->e_phoff);
 
 		for (i = 0; i < hdr->e_phnum; i++) {
 			if (phdr->p_type == PT_LOAD) {
@@ -739,11 +714,15 @@ static int vpe_elfload(struct vpe * v)
 			if (sechdrs[i].sh_type == SHT_SYMTAB) {
 				symindex = i;
 				strindex = sechdrs[i].sh_link;
-				strtab = (char *)hdr + sechdrs[strindex].sh_offset;
-
-				/* mark the symtab's address for when we try to find the
-				   magic symbols */
-				sechdrs[i].sh_addr = (size_t) hdr + sechdrs[i].sh_offset;
+				strtab = (char *)hdr +
+					sechdrs[strindex].sh_offset;
+
+				/*
+				 * mark symtab's address for when we try
+				 * to find the magic symbols
+				 */
+				sechdrs[i].sh_addr = (size_t) hdr +
+					sechdrs[i].sh_offset;
 			}
 		}
 	}
@@ -754,18 +733,16 @@ static int vpe_elfload(struct vpe * v)
 
 	if ((find_vpe_symbols(v, sechdrs, symindex, strtab, &mod)) < 0) {
 		if (v->__start == 0) {
-			printk(KERN_WARNING "VPE loader: program does not contain "
-			       "a __start symbol\n");
+			pr_warn("VPE loader: program does not contain a __start symbol\n");
 			return -ENOEXEC;
 		}
 
 		if (v->shared_ptr == NULL)
-			printk(KERN_WARNING "VPE loader: "
-			       "program does not contain vpe_shared symbol.\n"
-			       " Unable to use AMVP (AP/SP) facilities.\n");
+			pr_warn("VPE loader: program does not contain vpe_shared symbol.\n"
+				" Unable to use AMVP (AP/SP) facilities.\n");
 	}
 
-	printk(" elf loaded\n");
+	pr_info(" elf loaded\n");
 	return 0;
 }
 
@@ -788,30 +765,30 @@ static int getcwd(char *buff, int size)
 static int vpe_open(struct inode *inode, struct file *filp)
 {
 	enum vpe_state state;
-	struct vpe_notifications *not;
+	struct vpe_notifications *notifier;
 	struct vpe *v;
 	int ret;
 
 	if (VPE_MODULE_MINOR != iminor(inode)) {
 		/* assume only 1 device at the moment. */
-		pr_warning("VPE loader: only vpe1 is supported\n");
+		pr_warn("VPE loader: only vpe1 is supported\n");
 
 		return -ENODEV;
 	}
 
-	if ((v = get_vpe(aprp_cpu_index())) == NULL) {
-		pr_warning("VPE loader: unable to get vpe\n");
+	v = get_vpe(aprp_cpu_index());
+	if (v == NULL) {
+		pr_warn("VPE loader: unable to get vpe\n");
 
 		return -ENODEV;
 	}
 
 	state = xchg(&v->state, VPE_STATE_INUSE);
 	if (state != VPE_STATE_UNUSED) {
-		printk(KERN_DEBUG "VPE loader: tc in use dumping regs\n");
+		pr_debug("VPE loader: tc in use dumping regs\n");
 
-		list_for_each_entry(not, &v->notify, list) {
-			not->stop(aprp_cpu_index());
-		}
+		list_for_each_entry(notifier, &v->notify, list)
+			notifier->stop(aprp_cpu_index());
 
 		release_progmem(v->load_addr);
 		cleanup_tc(get_tc(aprp_cpu_index()));
@@ -820,7 +797,7 @@ static int vpe_open(struct inode *inode, struct file *filp)
 	/* this of-course trashes what was there before... */
 	v->pbuffer = vmalloc(P_SIZE);
 	if (!v->pbuffer) {
-		pr_warning("VPE loader: unable to allocate memory\n");
+		pr_warn("VPE loader: unable to allocate memory\n");
 		return -ENOMEM;
 	}
 	v->plen = P_SIZE;
@@ -833,7 +810,7 @@ static int vpe_open(struct inode *inode, struct file *filp)
 	v->cwd[0] = 0;
 	ret = getcwd(v->cwd, VPE_PATH_MAX);
 	if (ret < 0)
-		printk(KERN_WARNING "VPE loader: open, getcwd returned %d\n", ret);
+		pr_warn("VPE loader: open, getcwd returned %d\n", ret);
 
 	v->shared_ptr = NULL;
 	v->__start = 0;
@@ -856,11 +833,11 @@ static int vpe_release(struct inode *inode, struct file *filp)
 		if ((vpe_elfload(v) >= 0) && vpe_run) {
 			vpe_run(v);
 		} else {
-			printk(KERN_WARNING "VPE loader: ELF load failed.\n");
+			pr_warn("VPE loader: ELF load failed.\n");
 			ret = -ENOEXEC;
 		}
 	} else {
-		printk(KERN_WARNING "VPE loader: only elf files are supported\n");
+		pr_warn("VPE loader: only elf files are supported\n");
 		ret = -ENOEXEC;
 	}
 
@@ -878,8 +855,8 @@ static int vpe_release(struct inode *inode, struct file *filp)
 	return ret;
 }
 
-static ssize_t vpe_write(struct file *file, const char __user * buffer,
-			 size_t count, loff_t * ppos)
+static ssize_t vpe_write(struct file *file, const char __user *buffer,
+			 size_t count, loff_t *ppos)
 {
 	size_t ret = count;
 	struct vpe *v;
@@ -888,12 +865,12 @@ static ssize_t vpe_write(struct file *file, const char __user * buffer,
 		return -ENODEV;
 
 	v = get_vpe(aprp_cpu_index());
+
 	if (v == NULL)
 		return -ENODEV;
 
 	if ((count + v->len) > v->plen) {
-		printk(KERN_WARNING
-		       "VPE loader: elf size too big. Perhaps strip uneeded symbols\n");
+		pr_warn("VPE loader: elf size too big. Perhaps strip uneeded symbols\n");
 		return -ENOMEM;
 	}
 
@@ -915,63 +892,58 @@ const struct file_operations vpe_fops = {
 
 void *vpe_get_shared(int index)
 {
-	struct vpe *v;
+	struct vpe *v = get_vpe(index);
 
-	if ((v = get_vpe(index)) == NULL)
+	if (v == NULL)
 		return NULL;
 
 	return v->shared_ptr;
 }
-
 EXPORT_SYMBOL(vpe_get_shared);
 
 int vpe_getuid(int index)
 {
-	struct vpe *v;
+	struct vpe *v = get_vpe(index);
 
-	if ((v = get_vpe(index)) == NULL)
+	if (v == NULL)
 		return -1;
 
 	return v->uid;
 }
-
 EXPORT_SYMBOL(vpe_getuid);
 
 int vpe_getgid(int index)
 {
-	struct vpe *v;
+	struct vpe *v = get_vpe(index);
 
-	if ((v = get_vpe(index)) == NULL)
+	if (v == NULL)
 		return -1;
 
 	return v->gid;
 }
-
 EXPORT_SYMBOL(vpe_getgid);
 
 int vpe_notify(int index, struct vpe_notifications *notify)
 {
-	struct vpe *v;
+	struct vpe *v = get_vpe(index);
 
-	if ((v = get_vpe(index)) == NULL)
+	if (v == NULL)
 		return -1;
 
 	list_add(&notify->list, &v->notify);
 	return 0;
 }
-
 EXPORT_SYMBOL(vpe_notify);
 
 char *vpe_getcwd(int index)
 {
-	struct vpe *v;
+	struct vpe *v = get_vpe(index);
 
-	if ((v = get_vpe(index)) == NULL)
+	if (v == NULL)
 		return NULL;
 
 	return v->cwd;
 }
-
 EXPORT_SYMBOL(vpe_getcwd);
 
 module_init(vpe_module_init);
diff --git a/arch/mips/mti-malta/malta-amon.c b/arch/mips/mti-malta/malta-amon.c
index 917df6d..0319ad8 100644
--- a/arch/mips/mti-malta/malta-amon.c
+++ b/arch/mips/mti-malta/malta-amon.c
@@ -1,30 +1,20 @@
 /*
- * Copyright (C) 2007  MIPS Technologies, Inc.
- *	All rights reserved.
-
- *  This program is free software; you can distribute it and/or modify it
- *  under the terms of the GNU General Public License (Version 2) as
- *  published by the Free Software Foundation.
- *
- *  This program is distributed in the hope it will be useful, but WITHOUT
- *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- *  for more details.
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
  *
- *  You should have received a copy of the GNU General Public License along
- *  with this program; if not, write to the Free Software Foundation, Inc.,
- *  59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
+ * Copyright (C) 2007 MIPS Technologies, Inc.  All rights reserved.
+ * Copyright (C) 2013 Imagination Technologies Ltd.
  *
- * Arbitrary Monitor interface
+ * Arbitrary Monitor Interface
  */
-
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/smp.h>
 
 #include <asm/addrspace.h>
-#include <asm/mips-boards/launch.h>
 #include <asm/mipsmtregs.h>
+#include <asm/mips-boards/launch.h>
 #include <asm/vpe.h>
 
 int amon_cpu_avail(int cpu)
diff --git a/arch/mips/mti-malta/malta-int.c b/arch/mips/mti-malta/malta-int.c
index ea9338d..efa2289 100644
--- a/arch/mips/mti-malta/malta-int.c
+++ b/arch/mips/mti-malta/malta-int.c
@@ -1,26 +1,16 @@
 /*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
  * Carsten Langgaard, carstenl@mips.com
  * Copyright (C) 2000, 2001, 2004 MIPS Technologies, Inc.
  * Copyright (C) 2001 Ralf Baechle
  * Copyright (C) 2013 Imagination Technologies Ltd.
  *
- *  This program is free software; you can distribute it and/or modify it
- *  under the terms of the GNU General Public License (Version 2) as
- *  published by the Free Software Foundation.
- *
- *  This program is distributed in the hope it will be useful, but WITHOUT
- *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- *  for more details.
- *
- *  You should have received a copy of the GNU General Public License along
- *  with this program; if not, write to the Free Software Foundation, Inc.,
- *  59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
  * Routines for generic manipulation of the interrupts found on the MIPS
- * Malta board.
- * The interrupt controller is located in the South Bridge a PIIX4 device
- * with two internal 82C95 interrupt controllers.
+ * Malta board. The interrupt controller is located in the South Bridge
+ * a PIIX4 device with two internal 82C95 interrupt controllers.
  */
 #include <linux/init.h>
 #include <linux/irq.h>
@@ -92,7 +82,7 @@ static inline int mips_pcibios_iack(void)
 		BONITO_PCIMAP_CFG = 0;
 		break;
 	default:
-		printk(KERN_WARNING "Unknown system controller.\n");
+		pr_emerg("Unknown system controller.\n");
 		return -1;
 	}
 	return irq;
@@ -156,11 +146,11 @@ static void corehi_irqdispatch(void)
 	unsigned int intrcause, datalo, datahi;
 	struct pt_regs *regs = get_irq_regs();
 
-	printk(KERN_EMERG "CoreHI interrupt, shouldn't happen, we die here!\n");
-	printk(KERN_EMERG "epc	 : %08lx\nStatus: %08lx\n"
-			"Cause : %08lx\nbadVaddr : %08lx\n",
-			regs->cp0_epc, regs->cp0_status,
-			regs->cp0_cause, regs->cp0_badvaddr);
+	pr_emerg("CoreHI interrupt, shouldn't happen, we die here!\n");
+	pr_emerg("epc	 : %08lx\nStatus: %08lx\n"
+		 "Cause : %08lx\nbadVaddr : %08lx\n",
+		 regs->cp0_epc, regs->cp0_status,
+		 regs->cp0_cause, regs->cp0_badvaddr);
 
 	/* Read all the registers and then print them as there is a
 	   problem with interspersed printk's upsetting the Bonito controller.
@@ -178,8 +168,8 @@ static void corehi_irqdispatch(void)
 		intrcause = GT_READ(GT_INTRCAUSE_OFS);
 		datalo = GT_READ(GT_CPUERR_ADDRLO_OFS);
 		datahi = GT_READ(GT_CPUERR_ADDRHI_OFS);
-		printk(KERN_EMERG "GT_INTRCAUSE = %08x\n", intrcause);
-		printk(KERN_EMERG "GT_CPUERR_ADDR = %02x%08x\n",
+		pr_emerg("GT_INTRCAUSE = %08x\n", intrcause);
+		pr_emerg("GT_CPUERR_ADDR = %02x%08x\n",
 				datahi, datalo);
 		break;
 	case MIPS_REVISION_SCON_BONITO:
@@ -191,14 +181,14 @@ static void corehi_irqdispatch(void)
 		intedge = BONITO_INTEDGE;
 		intsteer = BONITO_INTSTEER;
 		pcicmd = BONITO_PCICMD;
-		printk(KERN_EMERG "BONITO_INTISR = %08x\n", intisr);
-		printk(KERN_EMERG "BONITO_INTEN = %08x\n", inten);
-		printk(KERN_EMERG "BONITO_INTPOL = %08x\n", intpol);
-		printk(KERN_EMERG "BONITO_INTEDGE = %08x\n", intedge);
-		printk(KERN_EMERG "BONITO_INTSTEER = %08x\n", intsteer);
-		printk(KERN_EMERG "BONITO_PCICMD = %08x\n", pcicmd);
-		printk(KERN_EMERG "BONITO_PCIBADADDR = %08x\n", pcibadaddr);
-		printk(KERN_EMERG "BONITO_PCIMSTAT = %08x\n", pcimstat);
+		pr_emerg("BONITO_INTISR = %08x\n", intisr);
+		pr_emerg("BONITO_INTEN = %08x\n", inten);
+		pr_emerg("BONITO_INTPOL = %08x\n", intpol);
+		pr_emerg("BONITO_INTEDGE = %08x\n", intedge);
+		pr_emerg("BONITO_INTSTEER = %08x\n", intsteer);
+		pr_emerg("BONITO_PCICMD = %08x\n", pcicmd);
+		pr_emerg("BONITO_PCIBADADDR = %08x\n", pcibadaddr);
+		pr_emerg("BONITO_PCIMSTAT = %08x\n", pcimstat);
 		break;
 	}
 
@@ -377,13 +367,13 @@ static struct irqaction corehi_irqaction = {
 	.flags = IRQF_NO_THREAD,
 };
 
-static msc_irqmap_t __initdata msc_irqmap[] = {
+static msc_irqmap_t msc_irqmap[] __initdata = {
 	{MSC01C_INT_TMR,		MSC01_IRQ_EDGE, 0},
 	{MSC01C_INT_PCI,		MSC01_IRQ_LEVEL, 0},
 };
-static int __initdata msc_nr_irqs = ARRAY_SIZE(msc_irqmap);
+static int msc_nr_irqs __initdata = ARRAY_SIZE(msc_irqmap);
 
-static msc_irqmap_t __initdata msc_eicirqmap[] = {
+static msc_irqmap_t msc_eicirqmap[] __initdata = {
 	{MSC01E_INT_SW0,		MSC01_IRQ_LEVEL, 0},
 	{MSC01E_INT_SW1,		MSC01_IRQ_LEVEL, 0},
 	{MSC01E_INT_I8259A,		MSC01_IRQ_LEVEL, 0},
@@ -396,7 +386,7 @@ static msc_irqmap_t __initdata msc_eicirqmap[] = {
 	{MSC01E_INT_CPUCTR,		MSC01_IRQ_LEVEL, 0}
 };
 
-static int __initdata msc_nr_eicirqs = ARRAY_SIZE(msc_eicirqmap);
+static int msc_nr_eicirqs __initdata = ARRAY_SIZE(msc_eicirqmap);
 
 /*
  * This GIC specific tabular array defines the association between External
@@ -443,9 +433,12 @@ int __init gcmp_probe(unsigned long addr, unsigned long size)
 	if (gcmp_present >= 0)
 		return gcmp_present;
 
-	_gcmp_base = (unsigned long) ioremap_nocache(GCMP_BASE_ADDR, GCMP_ADDRSPACE_SZ);
-	_msc01_biu_base = (unsigned long) ioremap_nocache(MSC01_BIU_REG_BASE, MSC01_BIU_ADDRSPACE_SZ);
-	gcmp_present = (GCMPGCB(GCMPB) & GCMP_GCB_GCMPB_GCMPBASE_MSK) == GCMP_BASE_ADDR;
+	_gcmp_base = (unsigned long) ioremap_nocache(GCMP_BASE_ADDR,
+		GCMP_ADDRSPACE_SZ);
+	_msc01_biu_base = (unsigned long) ioremap_nocache(MSC01_BIU_REG_BASE,
+		MSC01_BIU_ADDRSPACE_SZ);
+	gcmp_present = ((GCMPGCB(GCMPB) & GCMP_GCB_GCMPB_GCMPBASE_MSK) ==
+		GCMP_BASE_ADDR);
 
 	if (gcmp_present)
 		pr_debug("GCMP present\n");
@@ -455,9 +448,8 @@ int __init gcmp_probe(unsigned long addr, unsigned long size)
 /* Return the number of IOCU's present */
 int __init gcmp_niocu(void)
 {
-  return gcmp_present ?
-    (GCMPGCB(GC) & GCMP_GCB_GC_NUMIOCU_MSK) >> GCMP_GCB_GC_NUMIOCU_SHF :
-    0;
+	return gcmp_present ? ((GCMPGCB(GC) & GCMP_GCB_GC_NUMIOCU_MSK) >>
+		GCMP_GCB_GC_NUMIOCU_SHF) : 0;
 }
 
 /* Set GCMP region attributes */
@@ -605,11 +597,14 @@ void __init arch_init_irq(void)
 			set_vi_handler(MIPSCPU_INT_IPI1, malta_ipi_irqdispatch);
 		}
 		/* Argh.. this really needs sorting out.. */
-		printk("CPU%d: status register was %08x\n", smp_processor_id(), read_c0_status());
+		pr_info("CPU%d: status register was %08x\n",
+			smp_processor_id(), read_c0_status());
 		write_c0_status(read_c0_status() | STATUSF_IP3 | STATUSF_IP4);
-		printk("CPU%d: status register now %08x\n", smp_processor_id(), read_c0_status());
+		pr_info("CPU%d: status register now %08x\n",
+			smp_processor_id(), read_c0_status());
 		write_c0_status(0x1100dc00);
-		printk("CPU%d: status register frc %08x\n", smp_processor_id(), read_c0_status());
+		pr_info("CPU%d: status register frc %08x\n",
+			smp_processor_id(), read_c0_status());
 		for (i = 0; i < NR_CPUS; i++) {
 			arch_init_ipiirq(MIPS_GIC_IRQ_BASE +
 					 GIC_RESCHED_INT(i), &irq_resched);
@@ -627,11 +622,15 @@ void __init arch_init_irq(void)
 			cpu_ipi_call_irq = MSC01E_INT_SW1;
 		} else {
 			if (cpu_has_vint) {
-				set_vi_handler (MIPS_CPU_IPI_RESCHED_IRQ, ipi_resched_dispatch);
-				set_vi_handler (MIPS_CPU_IPI_CALL_IRQ, ipi_call_dispatch);
+				set_vi_handler (MIPS_CPU_IPI_RESCHED_IRQ,
+					ipi_resched_dispatch);
+				set_vi_handler (MIPS_CPU_IPI_CALL_IRQ,
+					ipi_call_dispatch);
 			}
-			cpu_ipi_resched_irq = MIPS_CPU_IRQ_BASE + MIPS_CPU_IPI_RESCHED_IRQ;
-			cpu_ipi_call_irq = MIPS_CPU_IRQ_BASE + MIPS_CPU_IPI_CALL_IRQ;
+			cpu_ipi_resched_irq = MIPS_CPU_IRQ_BASE +
+				MIPS_CPU_IPI_RESCHED_IRQ;
+			cpu_ipi_call_irq = MIPS_CPU_IRQ_BASE +
+				MIPS_CPU_IPI_CALL_IRQ;
 		}
 		arch_init_ipiirq(cpu_ipi_resched_irq, &irq_resched);
 		arch_init_ipiirq(cpu_ipi_call_irq, &irq_call);
@@ -641,9 +640,7 @@ void __init arch_init_irq(void)
 
 void malta_be_init(void)
 {
-	if (gcmp_present) {
-		/* Could change CM error mask register */
-	}
+	/* Could change CM error mask register. */
 }
 
 
@@ -723,14 +720,14 @@ int malta_be_handler(struct pt_regs *regs, int is_fixup)
 			if (cause < 16) {
 				unsigned long cca_bits = (cm_error >> 15) & 7;
 				unsigned long tr_bits = (cm_error >> 12) & 7;
-				unsigned long mcmd_bits = (cm_error >> 7) & 0x1f;
+				unsigned long cmd_bits = (cm_error >> 7) & 0x1f;
 				unsigned long stag_bits = (cm_error >> 3) & 15;
 				unsigned long sport_bits = (cm_error >> 0) & 7;
 
 				snprintf(buf, sizeof(buf),
 					 "CCA=%lu TR=%s MCmd=%s STag=%lu "
 					 "SPort=%lu\n",
-					 cca_bits, tr[tr_bits], mcmd[mcmd_bits],
+					 cca_bits, tr[tr_bits], mcmd[cmd_bits],
 					 stag_bits, sport_bits);
 			} else {
 				/* glob state & sresp together */
@@ -739,7 +736,7 @@ int malta_be_handler(struct pt_regs *regs, int is_fixup)
 				unsigned long c1_bits = (cm_error >> 12) & 7;
 				unsigned long c0_bits = (cm_error >> 9) & 7;
 				unsigned long sc_bit = (cm_error >> 8) & 1;
-				unsigned long mcmd_bits = (cm_error >> 3) & 0x1f;
+				unsigned long cmd_bits = (cm_error >> 3) & 0x1f;
 				unsigned long sport_bits = (cm_error >> 0) & 7;
 				snprintf(buf, sizeof(buf),
 					 "C3=%s C2=%s C1=%s C0=%s SC=%s "
@@ -747,16 +744,16 @@ int malta_be_handler(struct pt_regs *regs, int is_fixup)
 					 core[c3_bits], core[c2_bits],
 					 core[c1_bits], core[c0_bits],
 					 sc_bit ? "True" : "False",
-					 mcmd[mcmd_bits], sport_bits);
+					 mcmd[cmd_bits], sport_bits);
 			}
 
 			ocause = (cm_other & GCMP_GCB_GMEO_ERROR_2ND_MSK) >>
 				 GCMP_GCB_GMEO_ERROR_2ND_SHF;
 
-			printk("CM_ERROR=%08lx %s <%s>\n", cm_error,
+			pr_err("CM_ERROR=%08lx %s <%s>\n", cm_error,
 			       causes[cause], buf);
-			printk("CM_ADDR =%08lx\n", cm_addr);
-			printk("CM_OTHER=%08lx %s\n", cm_other, causes[ocause]);
+			pr_err("CM_ADDR =%08lx\n", cm_addr);
+			pr_err("CM_OTHER=%08lx %s\n", cm_other, causes[ocause]);
 
 			/* reprime cause register */
 			GCMPGCB(GCMEC) = 0;
-- 
1.7.9.5

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

* Re: [PATCH 2/6] MIPS: APRP: Add VPE loader support for CMP platforms.
  2013-10-17  2:14 ` [PATCH 2/6] MIPS: APRP: Add VPE loader support for CMP platforms Steven J. Hill
@ 2013-10-17 17:40   ` David Daney
  2013-10-17 22:00       ` Deng-Cheng Zhu
  0 siblings, 1 reply; 20+ messages in thread
From: David Daney @ 2013-10-17 17:40 UTC (permalink / raw)
  To: Steven J. Hill; +Cc: linux-mips, Deng-Cheng Zhu, ralf

On 10/16/2013 07:14 PM, Steven J. Hill wrote:
> From: Deng-Cheng Zhu <dengcheng.zhu@imgtec.com>
>
> This patch adds VPE loader support for platforms having a CMP.
>
> Signed-off-by: Deng-Cheng Zhu <dengcheng.zhu@imgtec.com>
> Signed-off-by: Steven J. Hill <Steven.Hill@imgtec.com>
> Reviewed-by: Qais Yousef <Qais.Yousef@imgtec.com>
> ---
>   arch/mips/kernel/Makefile  |    2 +-
>   arch/mips/kernel/vpe-cmp.c |  184 ++++++++++++++++++++++++++++++++++++++++++++
>   arch/mips/kernel/vpe-mt.c  |    4 +
>   3 files changed, 189 insertions(+), 1 deletion(-)
>   create mode 100644 arch/mips/kernel/vpe-cmp.c
>
> diff --git a/arch/mips/kernel/Makefile b/arch/mips/kernel/Makefile
> index 51f9117..912eb64 100644
> --- a/arch/mips/kernel/Makefile
> +++ b/arch/mips/kernel/Makefile
> @@ -54,7 +54,7 @@ obj-$(CONFIG_MIPS_MT_SMP)	+= smp-mt.o
>   obj-$(CONFIG_MIPS_CMP)		+= smp-cmp.o
>   obj-$(CONFIG_CPU_MIPSR2)	+= spram.o
>
> -obj-$(CONFIG_MIPS_VPE_LOADER)	+= vpe.o vpe-mt.o
> +obj-$(CONFIG_MIPS_VPE_LOADER)	+= vpe.o vpe-cmp.o vpe-mt.o
>   obj-$(CONFIG_MIPS_VPE_APSP_API) += rtlx.o
>
>   obj-$(CONFIG_I8259)		+= i8259.o
> diff --git a/arch/mips/kernel/vpe-cmp.c b/arch/mips/kernel/vpe-cmp.c
> new file mode 100644
> index 0000000..a5628ca
> --- /dev/null
> +++ b/arch/mips/kernel/vpe-cmp.c
> @@ -0,0 +1,184 @@
> +/*
> + * This file is subject to the terms and conditions of the GNU General Public
> + * License.  See the file "COPYING" in the main directory of this archive
> + * for more details.
> + *
> + * Copyright (C) 2004, 2005 MIPS Technologies, Inc.  All rights reserved.
> + * Copyright (C) 2013 Imagination Technologies Ltd.
> + */
> +#ifdef CONFIG_MIPS_CMP
> +

Get rid of all these #ifdef.

Use Kconfig symbols in the makefile instead.

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

* Re: [PATCH 6/6] MIPS: APRP: Code formatting clean-ups.
  2013-10-17  2:14 ` [PATCH 6/6] MIPS: APRP: Code formatting clean-ups Steven J. Hill
@ 2013-10-17 17:50   ` David Daney
  2013-10-17 18:26       ` Steven J. Hill
  0 siblings, 1 reply; 20+ messages in thread
From: David Daney @ 2013-10-17 17:50 UTC (permalink / raw)
  To: Steven J. Hill; +Cc: linux-mips, ralf

On 10/16/2013 07:14 PM, Steven J. Hill wrote:
> From: "Steven J. Hill" <Steven.Hill@imgtec.com>
>
> Clean-up code according to the 'checkpatch.pl' script.

This should probably be the first patch, so you don't end up making 
poorly formatted additions, and then later clean them up.

Also the change log text is not at all true, please make it reflect reality.

>
> Signed-off-by: Steven J. Hill <Steven.Hill@imgtec.com>
> Reviewed-by: Qais Yousef <Qais.Yousef@imgtec.com>
> ---
>   arch/mips/include/asm/amon.h     |   15 ++-
>   arch/mips/include/asm/rtlx.h     |    5 +-
>   arch/mips/include/asm/vpe.h      |   19 +--
>   arch/mips/kernel/rtlx.c          |  134 ++++++++------------
>   arch/mips/kernel/vpe-mt.c        |    6 +-
>   arch/mips/kernel/vpe.c           |  252 +++++++++++++++++---------------------
>   arch/mips/mti-malta/malta-amon.c |   24 ++--
>   arch/mips/mti-malta/malta-int.c  |  115 +++++++++--------
>   8 files changed, 250 insertions(+), 320 deletions(-)
>
> diff --git a/arch/mips/include/asm/amon.h b/arch/mips/include/asm/amon.h
> index 3bd6e76..3cc03c6 100644
> --- a/arch/mips/include/asm/amon.h
> +++ b/arch/mips/include/asm/amon.h
> @@ -1,7 +1,12 @@
>   /*
> - * Amon support
> + * This file is subject to the terms and conditions of the GNU General Public
> + * License.  See the file "COPYING" in the main directory of this archive
> + * for more details.
> + *
> + * Copyright (C) 2013 Imagination Technologies Ltd.
> + *
> + * Arbitrary Monitor Support (AMON)

Reflowing white space doesn't really count as the type of modification 
that allows you to assert copyright.


>    */
> -
> -int amon_cpu_avail(int);
> -int amon_cpu_start(int, unsigned long, unsigned long,
> -		   unsigned long, unsigned long);
> +int amon_cpu_avail(int cpu);
> +int amon_cpu_start(int cpu, unsigned long pc, unsigned long sp,
> +		   unsigned long gp, unsigned long a0);
> diff --git a/arch/mips/include/asm/rtlx.h b/arch/mips/include/asm/rtlx.h
> index fa86dfd..c102065 100644
> --- a/arch/mips/include/asm/rtlx.h
> +++ b/arch/mips/include/asm/rtlx.h
> @@ -1,8 +1,11 @@
>   /*
> + * This file is subject to the terms and conditions of the GNU General Public
> + * License.  See the file "COPYING" in the main directory of this archive
> + * for more details.
> + *

This is hot a checkpatch.pl related change.  So it should not be in this 
patch.

>    * Copyright (C) 2004, 2005 MIPS Technologies, Inc.  All rights reserved.
>    * Copyright (C) 2013 Imagination Technologies Ltd.
>    */
> -
>   #ifndef __ASM_RTLX_H_
>   #define __ASM_RTLX_H_
>
> diff --git a/arch/mips/include/asm/vpe.h b/arch/mips/include/asm/vpe.h
> index becd555..e0684f5 100644
> --- a/arch/mips/include/asm/vpe.h
> +++ b/arch/mips/include/asm/vpe.h
> @@ -1,22 +1,11 @@
>   /*
> + * This file is subject to the terms and conditions of the GNU General Public
> + * License.  See the file "COPYING" in the main directory of this archive
> + * for more details.
> + *
>    * Copyright (C) 2005 MIPS Technologies, Inc.  All rights reserved.
>    * Copyright (C) 2013 Imagination Technologies Ltd.
> - *
> - *  This program is free software; you can distribute it and/or modify it
> - *  under the terms of the GNU General Public License (Version 2) as
> - *  published by the Free Software Foundation.
> - *
> - *  This program is distributed in the hope it will be useful, but WITHOUT
> - *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> - *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
> - *  for more details.
> - *
> - *  You should have received a copy of the GNU General Public License along
> - *  with this program; if not, write to the Free Software Foundation, Inc.,
> - *  59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
> - *
>    */

Another change not related to checkpatch.pl


> -
>   #ifndef _ASM_VPE_H
>   #define _ASM_VPE_H
>
> diff --git a/arch/mips/kernel/rtlx.c b/arch/mips/kernel/rtlx.c
> index cd78618..8053b4e 100644
> --- a/arch/mips/kernel/rtlx.c
> +++ b/arch/mips/kernel/rtlx.c
> @@ -1,46 +1,23 @@
>   /*
> + * This file is subject to the terms and conditions of the GNU General Public
> + * License.  See the file "COPYING" in the main directory of this archive
> + * for more details.
> + *
>    * Copyright (C) 2005 MIPS Technologies, Inc.  All rights reserved.
>    * Copyright (C) 2005, 06 Ralf Baechle (ralf@linux-mips.org)
> - *
> - *  This program is free software; you can distribute it and/or modify it
> - *  under the terms of the GNU General Public License (Version 2) as
> - *  published by the Free Software Foundation.
> - *
> - *  This program is distributed in the hope it will be useful, but WITHOUT
> - *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> - *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
> - *  for more details.
> - *
> - *  You should have received a copy of the GNU General Public License along
> - *  with this program; if not, write to the Free Software Foundation, Inc.,
> - *  59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
> - *
> + * Copyright (C) 2013 Imagination Technologies Ltd.

And another.

>    */
> -
> -#include <linux/device.h>
>   #include <linux/kernel.h>
>   #include <linux/fs.h>
> -#include <linux/init.h>
> -#include <asm/uaccess.h>
> -#include <linux/list.h>
> -#include <linux/vmalloc.h>
> -#include <linux/elf.h>
> -#include <linux/seq_file.h>
>   #include <linux/syscalls.h>
>   #include <linux/moduleloader.h>
> -#include <linux/interrupt.h>
> -#include <linux/poll.h>
> -#include <linux/sched.h>
> -#include <linux/wait.h>
> +#include <linux/atomic.h>
>   #include <asm/mipsmtregs.h>
>   #include <asm/mips_mt.h>
> -#include <asm/cacheflush.h>
> -#include <linux/atomic.h>
> -#include <asm/cpu.h>
>   #include <asm/processor.h>
> -#include <asm/vpe.h>
>   #include <asm/rtlx.h>
>   #include <asm/setup.h>
> +#include <asm/vpe.h>
>
>   static int sp_stopping;
>   struct rtlx_info *rtlx;
> @@ -53,22 +30,22 @@ static void __used dump_rtlx(void)
>   {
>   	int i;
>
> -	printk("id 0x%lx state %d\n", rtlx->id, rtlx->state);
> +	pr_info("id 0x%lx state %d\n", rtlx->id, rtlx->state);
>
>   	for (i = 0; i < RTLX_CHANNELS; i++) {
>   		struct rtlx_channel *chan = &rtlx->channel[i];
>
> -		printk(" rt_state %d lx_state %d buffer_size %d\n",
> -		       chan->rt_state, chan->lx_state, chan->buffer_size);
> +		pr_info(" rt_state %d lx_state %d buffer_size %d\n",
> +			chan->rt_state, chan->lx_state, chan->buffer_size);
>
> -		printk(" rt_read %d rt_write %d\n",
> -		       chan->rt_read, chan->rt_write);
> +		pr_info(" rt_read %d rt_write %d\n",
> +			chan->rt_read, chan->rt_write);
>
> -		printk(" lx_read %d lx_write %d\n",
> -		       chan->lx_read, chan->lx_write);
> +		pr_info(" lx_read %d lx_write %d\n",
> +			chan->lx_read, chan->lx_write);
>
> -		printk(" rt_buffer <%s>\n", chan->rt_buffer);
> -		printk(" lx_buffer <%s>\n", chan->lx_buffer);
> +		pr_info(" rt_buffer <%s>\n", chan->rt_buffer);
> +		pr_info(" lx_buffer <%s>\n", chan->lx_buffer);
>   	}
>   }
>
> @@ -76,8 +53,7 @@ static void __used dump_rtlx(void)
>   static int rtlx_init(struct rtlx_info *rtlxi)
>   {
>   	if (rtlxi->id != RTLX_ID) {
> -		printk(KERN_ERR "no valid RTLX id at 0x%p 0x%lx\n",
> -			rtlxi, rtlxi->id);
> +		pr_err("no valid RTLX id at 0x%p 0x%lx\n", rtlxi, rtlxi->id);
>   		return -ENOEXEC;
>   	}
>
> @@ -93,7 +69,7 @@ void rtlx_starting(int vpe)
>   	sp_stopping = 0;
>
>   	/* force a reload of rtlx */
> -	rtlx=NULL;
> +	rtlx = NULL;
>
>   	/* wake up any sleeping rtlx_open's */
>   	for (i = 0; i < RTLX_CHANNELS; i++)
> @@ -118,30 +94,31 @@ int rtlx_open(int index, int can_sleep)
>   	int ret = 0;
>
>   	if (index >= RTLX_CHANNELS) {
> -		printk(KERN_DEBUG "rtlx_open index out of range\n");
> +		pr_debug("rtlx_open index out of range\n");
>   		return -ENOSYS;
>   	}
>
>   	if (atomic_inc_return(&channel_wqs[index].in_open) > 1) {
> -		printk(KERN_DEBUG "rtlx_open channel %d already opened\n",
> -		       index);
> +		pr_debug("rtlx_open channel %d already opened\n", index);
>   		ret = -EBUSY;
>   		goto out_fail;
>   	}
>
>   	if (rtlx == NULL) {
> -		if( (p = vpe_get_shared(tclimit)) == NULL) {
> -		    if (can_sleep) {
> -			__wait_event_interruptible(channel_wqs[index].lx_queue,
> -				(p = vpe_get_shared(tclimit)), ret);
> -			if (ret)
> +		p = vpe_get_shared(aprp_cpu_index());
> +		if (p == NULL) {
> +			if (can_sleep) {
> +				__wait_event_interruptible(
> +					channel_wqs[index].lx_queue,
> +					(p = vpe_get_shared(aprp_cpu_index())),
> +					ret);
> +				if (ret)
> +					goto out_fail;
> +			} else {
> +				pr_debug("No SP program loaded, and device opened with O_NONBLOCK\n");
> +				ret = -ENOSYS;
>   				goto out_fail;
> -		    } else {
> -			printk(KERN_DEBUG "No SP program loaded, and device "
> -					"opened with O_NONBLOCK\n");
> -			ret = -ENOSYS;
> -			goto out_fail;
> -		    }
> +			}
>   		}
>
>   		smp_rmb();
> @@ -163,24 +140,24 @@ int rtlx_open(int index, int can_sleep)
>   					ret = -ERESTARTSYS;
>   					goto out_fail;
>   				}
> -				finish_wait(&channel_wqs[index].lx_queue, &wait);
> +				finish_wait(&channel_wqs[index].lx_queue,
> +					    &wait);

Gratuitous uglification here.  Probably not a good idea.


>   			} else {
> -				pr_err(" *vpe_get_shared is NULL. "
> -				       "Has an SP program been loaded?\n");
> +				pr_err(" *vpe_get_shared is NULL. Has an SP program been loaded?\n");
>   				ret = -ENOSYS;
>   				goto out_fail;
>   			}
>   		}
>
>   		if ((unsigned int)*p < KSEG0) {
> -			printk(KERN_WARNING "vpe_get_shared returned an "
> -			       "invalid pointer maybe an error code %d\n",
> -			       (int)*p);
> +			pr_warn("vpe_get_shared returned an invalid pointer maybe an error code %d\n",
> +				(int)*p);
>   			ret = -ENOSYS;
>   			goto out_fail;
>   		}
>
> -		if ((ret = rtlx_init(*p)) < 0)
> +		ret = rtlx_init(*p);
> +		if (ret < 0)
>   			goto out_ret;
>   	}
>
> @@ -312,7 +289,7 @@ ssize_t rtlx_write(int index, const void __user *buffer, size_t count)
>   	size_t fl;
>
>   	if (rtlx == NULL)
> -		return(-ENOSYS);
> +		return -ENOSYS;
>
>   	rt = &rtlx->channel[index];
>
> @@ -321,8 +298,8 @@ ssize_t rtlx_write(int index, const void __user *buffer, size_t count)
>   	rt_read = rt->rt_read;
>
>   	/* total number of bytes to copy */
> -	count = min(count, (size_t)write_spacefree(rt_read, rt->rt_write,
> -							rt->buffer_size));
> +	count = min_t(size_t, count, write_spacefree(rt_read, rt->rt_write,
> +						     rt->buffer_size));
>
>   	/* first bit from write pointer to the end of the buffer, or count */
>   	fl = min(count, (size_t) rt->buffer_size - rt->rt_write);
> @@ -332,9 +309,8 @@ ssize_t rtlx_write(int index, const void __user *buffer, size_t count)
>   		goto out;
>
>   	/* if there's any left copy to the beginning of the buffer */
> -	if (count - fl) {
> +	if (count - fl)
>   		failed = copy_from_user(rt->rt_buffer, buffer + fl, count - fl);
> -	}
>
>   out:
>   	count -= failed;
> @@ -360,7 +336,7 @@ static int file_release(struct inode *inode, struct file *filp)
>   	return rtlx_release(iminor(inode));
>   }
>
> -static unsigned int file_poll(struct file *file, poll_table * wait)
> +static unsigned int file_poll(struct file *file, poll_table *wait)
>   {
>   	int minor = iminor(file_inode(file));
>   	unsigned int mask = 0;
> @@ -382,21 +358,20 @@ static unsigned int file_poll(struct file *file, poll_table * wait)
>   	return mask;
>   }
>
> -static ssize_t file_read(struct file *file, char __user * buffer, size_t count,
> -			 loff_t * ppos)
> +static ssize_t file_read(struct file *file, char __user *buffer, size_t count,
> +			 loff_t *ppos)
>   {
>   	int minor = iminor(file_inode(file));
>
>   	/* data available? */
> -	if (!rtlx_read_poll(minor, (file->f_flags & O_NONBLOCK) ? 0 : 1)) {
> -		return 0;	// -EAGAIN makes cat whinge
> -	}
> +	if (!rtlx_read_poll(minor, (file->f_flags & O_NONBLOCK) ? 0 : 1))
> +		return 0;	/* -EAGAIN makes 'cat' whine */
>
>   	return rtlx_read(minor, buffer, count);
>   }
>
> -static ssize_t file_write(struct file *file, const char __user * buffer,
> -			  size_t count, loff_t * ppos)
> +static ssize_t file_write(struct file *file, const char __user *buffer,
> +			  size_t count, loff_t *ppos)
>   {
>   	int minor = iminor(file_inode(file));
>
> @@ -419,11 +394,11 @@ static ssize_t file_write(struct file *file, const char __user * buffer,
>
>   const struct file_operations rtlx_fops = {
>   	.owner =   THIS_MODULE,
> -	.open =	   file_open,
> +	.open =    file_open,
>   	.release = file_release,
>   	.write =   file_write,
> -	.read =	   file_read,
> -	.poll =	   file_poll,
> +	.read =    file_read,
> +	.poll =    file_poll,
>   	.llseek =  noop_llseek,
>   };
>
> @@ -433,4 +408,3 @@ module_exit(rtlx_module_exit);
>   MODULE_DESCRIPTION("MIPS RTLX");
>   MODULE_AUTHOR("Elizabeth Oldham, MIPS Technologies, Inc.");
>   MODULE_LICENSE("GPL");
> -
> diff --git a/arch/mips/kernel/vpe-mt.c b/arch/mips/kernel/vpe-mt.c
> index 323ca69..daccee4 100644
> --- a/arch/mips/kernel/vpe-mt.c
> +++ b/arch/mips/kernel/vpe-mt.c
> @@ -28,7 +28,7 @@ static int hw_tcs, hw_vpes;
>   int vpe_run(struct vpe *v)
>   {
>   	unsigned long flags, val, dmt_flag;
> -	struct vpe_notifications *n;
> +	struct vpe_notifications *notifier;
>   	unsigned int vpeflags;
>   	struct tc *t;
>
> @@ -141,8 +141,8 @@ int vpe_run(struct vpe *v)
>   	emt(dmt_flag);
>   	local_irq_restore(flags);
>
> -	list_for_each_entry(n, &v->notify, list)
> -		n->start(VPE_MODULE_MINOR);
> +	list_for_each_entry(notifier, &v->notify, list)
> +		notifier->start(VPE_MODULE_MINOR);
>
>   	return 0;
>   }
> diff --git a/arch/mips/kernel/vpe.c b/arch/mips/kernel/vpe.c
> index 61dfd5b..42d3ca0 100644
> --- a/arch/mips/kernel/vpe.c
> +++ b/arch/mips/kernel/vpe.c
> @@ -1,37 +1,22 @@
>   /*
> - * Copyright (C) 2004, 2005 MIPS Technologies, Inc.  All rights reserved.
> - *
> - *  This program is free software; you can distribute it and/or modify it
> - *  under the terms of the GNU General Public License (Version 2) as
> - *  published by the Free Software Foundation.
> - *
> - *  This program is distributed in the hope it will be useful, but WITHOUT
> - *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> - *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
> - *  for more details.
> - *
> - *  You should have received a copy of the GNU General Public License along
> - *  with this program; if not, write to the Free Software Foundation, Inc.,
> - *  59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
> - */
> -
> -/*
> - * VPE support module
> + * This file is subject to the terms and conditions of the GNU General Public
> + * License.  See the file "COPYING" in the main directory of this archive
> + * for more details.
>    *
> - * Provides support for loading a MIPS SP program on VPE1.
> - * The SP environment is rather simple, no tlb's.  It needs to be relocatable
> - * (or partially linked). You should initialise your stack in the startup
> - * code. This loader looks for the symbol __start and sets up
> - * execution to resume from there. The MIPS SDE kit contains suitable examples.
> + * Copyright (C) 2004, 2005 MIPS Technologies, Inc.  All rights reserved.
> + * Copyright (C) 2013 Imagination Technologies Ltd.
>    *

More license frobbing, not checkpatch.pl related


.
.
.

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

* Re: [PATCH 6/6] MIPS: APRP: Code formatting clean-ups.
@ 2013-10-17 18:26       ` Steven J. Hill
  0 siblings, 0 replies; 20+ messages in thread
From: Steven J. Hill @ 2013-10-17 18:26 UTC (permalink / raw)
  To: David Daney; +Cc: linux-mips, ralf

On 10/17/2013 12:50 PM, David Daney wrote:
> On 10/16/2013 07:14 PM, Steven J. Hill wrote:
>> From: "Steven J. Hill" <Steven.Hill@imgtec.com>
>>
>> Clean-up code according to the 'checkpatch.pl' script.
>
> This should probably be the first patch, so you don't end up making
> poorly formatted additions, and then later clean them up.
>
Noted, but I am not inclined to change the order of the patches right now.

> Also the change log text is not at all true, please make it reflect
> reality.
>
Yes, the changelog should be updated to note copyright clean-ups and 
other formatting changes. I will update that.

Steve

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

* Re: [PATCH 6/6] MIPS: APRP: Code formatting clean-ups.
@ 2013-10-17 18:26       ` Steven J. Hill
  0 siblings, 0 replies; 20+ messages in thread
From: Steven J. Hill @ 2013-10-17 18:26 UTC (permalink / raw)
  To: David Daney; +Cc: linux-mips, ralf

On 10/17/2013 12:50 PM, David Daney wrote:
> On 10/16/2013 07:14 PM, Steven J. Hill wrote:
>> From: "Steven J. Hill" <Steven.Hill@imgtec.com>
>>
>> Clean-up code according to the 'checkpatch.pl' script.
>
> This should probably be the first patch, so you don't end up making
> poorly formatted additions, and then later clean them up.
>
Noted, but I am not inclined to change the order of the patches right now.

> Also the change log text is not at all true, please make it reflect
> reality.
>
Yes, the changelog should be updated to note copyright clean-ups and 
other formatting changes. I will update that.

Steve

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

* Re: [PATCH 2/6] MIPS: APRP: Add VPE loader support for CMP platforms.
@ 2013-10-17 22:00       ` Deng-Cheng Zhu
  0 siblings, 0 replies; 20+ messages in thread
From: Deng-Cheng Zhu @ 2013-10-17 22:00 UTC (permalink / raw)
  To: David Daney, Steven J. Hill; +Cc: linux-mips, ralf

On 10/17/2013 10:40 AM, David Daney wrote:
> On 10/16/2013 07:14 PM, Steven J. Hill wrote:
>> From: Deng-Cheng Zhu <dengcheng.zhu@imgtec.com>
>>
>> This patch adds VPE loader support for platforms having a CMP.
>>
>> Signed-off-by: Deng-Cheng Zhu <dengcheng.zhu@imgtec.com>
>> Signed-off-by: Steven J. Hill <Steven.Hill@imgtec.com>
>> Reviewed-by: Qais Yousef <Qais.Yousef@imgtec.com>
>> ---
>>   arch/mips/kernel/Makefile  |    2 +-
>>   arch/mips/kernel/vpe-cmp.c |  184 
>> ++++++++++++++++++++++++++++++++++++++++++++
>>   arch/mips/kernel/vpe-mt.c  |    4 +
>>   3 files changed, 189 insertions(+), 1 deletion(-)
>>   create mode 100644 arch/mips/kernel/vpe-cmp.c
>>
>> diff --git a/arch/mips/kernel/Makefile b/arch/mips/kernel/Makefile
>> index 51f9117..912eb64 100644
>> --- a/arch/mips/kernel/Makefile
>> +++ b/arch/mips/kernel/Makefile
>> @@ -54,7 +54,7 @@ obj-$(CONFIG_MIPS_MT_SMP)    += smp-mt.o
>>   obj-$(CONFIG_MIPS_CMP)        += smp-cmp.o
>>   obj-$(CONFIG_CPU_MIPSR2)    += spram.o
>>
>> -obj-$(CONFIG_MIPS_VPE_LOADER)    += vpe.o vpe-mt.o
>> +obj-$(CONFIG_MIPS_VPE_LOADER)    += vpe.o vpe-cmp.o vpe-mt.o
>>   obj-$(CONFIG_MIPS_VPE_APSP_API) += rtlx.o
>>
>>   obj-$(CONFIG_I8259)        += i8259.o
>> diff --git a/arch/mips/kernel/vpe-cmp.c b/arch/mips/kernel/vpe-cmp.c
>> new file mode 100644
>> index 0000000..a5628ca
>> --- /dev/null
>> +++ b/arch/mips/kernel/vpe-cmp.c
>> @@ -0,0 +1,184 @@
>> +/*
>> + * This file is subject to the terms and conditions of the GNU General 
>> Public
>> + * License.  See the file "COPYING" in the main directory of this archive
>> + * for more details.
>> + *
>> + * Copyright (C) 2004, 2005 MIPS Technologies, Inc.  All rights reserved.
>> + * Copyright (C) 2013 Imagination Technologies Ltd.
>> + */
>> +#ifdef CONFIG_MIPS_CMP
>> +
>
> Get rid of all these #ifdef.
>
> Use Kconfig symbols in the makefile instead.
>
>

Right. Splitting stuff into -cmp/-mt files is an effort to remove such kind 
of #ifdef. The example can be found in Makefile in the v4 of this patch 
set: http://patchwork.linux-mips.org/patch/5059/


Deng-Cheng

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

* Re: [PATCH 2/6] MIPS: APRP: Add VPE loader support for CMP platforms.
@ 2013-10-17 22:00       ` Deng-Cheng Zhu
  0 siblings, 0 replies; 20+ messages in thread
From: Deng-Cheng Zhu @ 2013-10-17 22:00 UTC (permalink / raw)
  To: David Daney, Steven J. Hill; +Cc: linux-mips, ralf

On 10/17/2013 10:40 AM, David Daney wrote:
> On 10/16/2013 07:14 PM, Steven J. Hill wrote:
>> From: Deng-Cheng Zhu <dengcheng.zhu@imgtec.com>
>>
>> This patch adds VPE loader support for platforms having a CMP.
>>
>> Signed-off-by: Deng-Cheng Zhu <dengcheng.zhu@imgtec.com>
>> Signed-off-by: Steven J. Hill <Steven.Hill@imgtec.com>
>> Reviewed-by: Qais Yousef <Qais.Yousef@imgtec.com>
>> ---
>>   arch/mips/kernel/Makefile  |    2 +-
>>   arch/mips/kernel/vpe-cmp.c |  184 
>> ++++++++++++++++++++++++++++++++++++++++++++
>>   arch/mips/kernel/vpe-mt.c  |    4 +
>>   3 files changed, 189 insertions(+), 1 deletion(-)
>>   create mode 100644 arch/mips/kernel/vpe-cmp.c
>>
>> diff --git a/arch/mips/kernel/Makefile b/arch/mips/kernel/Makefile
>> index 51f9117..912eb64 100644
>> --- a/arch/mips/kernel/Makefile
>> +++ b/arch/mips/kernel/Makefile
>> @@ -54,7 +54,7 @@ obj-$(CONFIG_MIPS_MT_SMP)    += smp-mt.o
>>   obj-$(CONFIG_MIPS_CMP)        += smp-cmp.o
>>   obj-$(CONFIG_CPU_MIPSR2)    += spram.o
>>
>> -obj-$(CONFIG_MIPS_VPE_LOADER)    += vpe.o vpe-mt.o
>> +obj-$(CONFIG_MIPS_VPE_LOADER)    += vpe.o vpe-cmp.o vpe-mt.o
>>   obj-$(CONFIG_MIPS_VPE_APSP_API) += rtlx.o
>>
>>   obj-$(CONFIG_I8259)        += i8259.o
>> diff --git a/arch/mips/kernel/vpe-cmp.c b/arch/mips/kernel/vpe-cmp.c
>> new file mode 100644
>> index 0000000..a5628ca
>> --- /dev/null
>> +++ b/arch/mips/kernel/vpe-cmp.c
>> @@ -0,0 +1,184 @@
>> +/*
>> + * This file is subject to the terms and conditions of the GNU General 
>> Public
>> + * License.  See the file "COPYING" in the main directory of this archive
>> + * for more details.
>> + *
>> + * Copyright (C) 2004, 2005 MIPS Technologies, Inc.  All rights reserved.
>> + * Copyright (C) 2013 Imagination Technologies Ltd.
>> + */
>> +#ifdef CONFIG_MIPS_CMP
>> +
>
> Get rid of all these #ifdef.
>
> Use Kconfig symbols in the makefile instead.
>
>

Right. Splitting stuff into -cmp/-mt files is an effort to remove such kind 
of #ifdef. The example can be found in Makefile in the v4 of this patch 
set: http://patchwork.linux-mips.org/patch/5059/


Deng-Cheng

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

* Re: [PATCH 2/6] MIPS: APRP: Add VPE loader support for CMP platforms.
  2013-10-17 22:00       ` Deng-Cheng Zhu
  (?)
@ 2013-10-17 22:11       ` David Daney
  2013-10-17 22:38           ` Deng-Cheng Zhu
  -1 siblings, 1 reply; 20+ messages in thread
From: David Daney @ 2013-10-17 22:11 UTC (permalink / raw)
  To: Deng-Cheng Zhu; +Cc: Steven J. Hill, linux-mips, ralf

On 10/17/2013 03:00 PM, Deng-Cheng Zhu wrote:
> On 10/17/2013 10:40 AM, David Daney wrote:
>> On 10/16/2013 07:14 PM, Steven J. Hill wrote:
>>> From: Deng-Cheng Zhu <dengcheng.zhu@imgtec.com>
>>>
>>> This patch adds VPE loader support for platforms having a CMP.
>>>
>>> Signed-off-by: Deng-Cheng Zhu <dengcheng.zhu@imgtec.com>
>>> Signed-off-by: Steven J. Hill <Steven.Hill@imgtec.com>
>>> Reviewed-by: Qais Yousef <Qais.Yousef@imgtec.com>
>>> ---
>>>   arch/mips/kernel/Makefile  |    2 +-
>>>   arch/mips/kernel/vpe-cmp.c |  184
>>> ++++++++++++++++++++++++++++++++++++++++++++
>>>   arch/mips/kernel/vpe-mt.c  |    4 +
>>>   3 files changed, 189 insertions(+), 1 deletion(-)
>>>   create mode 100644 arch/mips/kernel/vpe-cmp.c
>>>
>>> diff --git a/arch/mips/kernel/Makefile b/arch/mips/kernel/Makefile
>>> index 51f9117..912eb64 100644
>>> --- a/arch/mips/kernel/Makefile
>>> +++ b/arch/mips/kernel/Makefile
>>> @@ -54,7 +54,7 @@ obj-$(CONFIG_MIPS_MT_SMP)    += smp-mt.o
>>>   obj-$(CONFIG_MIPS_CMP)        += smp-cmp.o
>>>   obj-$(CONFIG_CPU_MIPSR2)    += spram.o
>>>
>>> -obj-$(CONFIG_MIPS_VPE_LOADER)    += vpe.o vpe-mt.o
>>> +obj-$(CONFIG_MIPS_VPE_LOADER)    += vpe.o vpe-cmp.o vpe-mt.o
>>>   obj-$(CONFIG_MIPS_VPE_APSP_API) += rtlx.o
>>>
>>>   obj-$(CONFIG_I8259)        += i8259.o
>>> diff --git a/arch/mips/kernel/vpe-cmp.c b/arch/mips/kernel/vpe-cmp.c
>>> new file mode 100644
>>> index 0000000..a5628ca
>>> --- /dev/null
>>> +++ b/arch/mips/kernel/vpe-cmp.c
>>> @@ -0,0 +1,184 @@
>>> +/*
>>> + * This file is subject to the terms and conditions of the GNU
>>> General Public
>>> + * License.  See the file "COPYING" in the main directory of this
>>> archive
>>> + * for more details.
>>> + *
>>> + * Copyright (C) 2004, 2005 MIPS Technologies, Inc.  All rights
>>> reserved.
>>> + * Copyright (C) 2013 Imagination Technologies Ltd.
>>> + */
>>> +#ifdef CONFIG_MIPS_CMP
>>> +
>>
>> Get rid of all these #ifdef.
>>
>> Use Kconfig symbols in the makefile instead.
>>
>>
>
> Right. Splitting stuff into -cmp/-mt files is an effort to remove such
> kind of #ifdef. The example can be found in Makefile in the v4 of this
> patch set: http://patchwork.linux-mips.org/patch/5059/
>
>

OK, that patch you point to seems a little better, but there are still 
ifdefs in the Makefile.  You can create synthetic Kconfig variables so 
the makefile is cleaner, but I don't know if it is worth it in this case.

Why did we get this new patch that regresses?

David Daney

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

* Re: [PATCH 2/6] MIPS: APRP: Add VPE loader support for CMP platforms.
@ 2013-10-17 22:38           ` Deng-Cheng Zhu
  0 siblings, 0 replies; 20+ messages in thread
From: Deng-Cheng Zhu @ 2013-10-17 22:38 UTC (permalink / raw)
  To: David Daney; +Cc: Steven J. Hill, linux-mips, ralf

On 10/17/2013 03:11 PM, David Daney wrote:
> On 10/17/2013 03:00 PM, Deng-Cheng Zhu wrote:
>> On 10/17/2013 10:40 AM, David Daney wrote:
>>> On 10/16/2013 07:14 PM, Steven J. Hill wrote:
>>>> From: Deng-Cheng Zhu <dengcheng.zhu@imgtec.com>
>>>>
>>>> This patch adds VPE loader support for platforms having a CMP.
>>>>
>>>> Signed-off-by: Deng-Cheng Zhu <dengcheng.zhu@imgtec.com>
>>>> Signed-off-by: Steven J. Hill <Steven.Hill@imgtec.com>
>>>> Reviewed-by: Qais Yousef <Qais.Yousef@imgtec.com>
>>>> ---
>>>>   arch/mips/kernel/Makefile  |    2 +-
>>>>   arch/mips/kernel/vpe-cmp.c |  184
>>>> ++++++++++++++++++++++++++++++++++++++++++++
>>>>   arch/mips/kernel/vpe-mt.c  |    4 +
>>>>   3 files changed, 189 insertions(+), 1 deletion(-)
>>>>   create mode 100644 arch/mips/kernel/vpe-cmp.c
>>>>
>>>> diff --git a/arch/mips/kernel/Makefile b/arch/mips/kernel/Makefile
>>>> index 51f9117..912eb64 100644
>>>> --- a/arch/mips/kernel/Makefile
>>>> +++ b/arch/mips/kernel/Makefile
>>>> @@ -54,7 +54,7 @@ obj-$(CONFIG_MIPS_MT_SMP)    += smp-mt.o
>>>>   obj-$(CONFIG_MIPS_CMP)        += smp-cmp.o
>>>>   obj-$(CONFIG_CPU_MIPSR2)    += spram.o
>>>>
>>>> -obj-$(CONFIG_MIPS_VPE_LOADER)    += vpe.o vpe-mt.o
>>>> +obj-$(CONFIG_MIPS_VPE_LOADER)    += vpe.o vpe-cmp.o vpe-mt.o
>>>>   obj-$(CONFIG_MIPS_VPE_APSP_API) += rtlx.o
>>>>
>>>>   obj-$(CONFIG_I8259)        += i8259.o
>>>> diff --git a/arch/mips/kernel/vpe-cmp.c b/arch/mips/kernel/vpe-cmp.c
>>>> new file mode 100644
>>>> index 0000000..a5628ca
>>>> --- /dev/null
>>>> +++ b/arch/mips/kernel/vpe-cmp.c
>>>> @@ -0,0 +1,184 @@
>>>> +/*
>>>> + * This file is subject to the terms and conditions of the GNU
>>>> General Public
>>>> + * License.  See the file "COPYING" in the main directory of this
>>>> archive
>>>> + * for more details.
>>>> + *
>>>> + * Copyright (C) 2004, 2005 MIPS Technologies, Inc.  All rights
>>>> reserved.
>>>> + * Copyright (C) 2013 Imagination Technologies Ltd.
>>>> + */
>>>> +#ifdef CONFIG_MIPS_CMP
>>>> +
>>>
>>> Get rid of all these #ifdef.
>>>
>>> Use Kconfig symbols in the makefile instead.
>>>
>>>
>>
>> Right. Splitting stuff into -cmp/-mt files is an effort to remove such
>> kind of #ifdef. The example can be found in Makefile in the v4 of this
>> patch set: http://patchwork.linux-mips.org/patch/5059/
>>
>>
>
> OK, that patch you point to seems a little better, but there are still 
> ifdefs in the Makefile.  You can create synthetic Kconfig variables so 
> the makefile is cleaner, but I don't know if it is worth it in this case.

Hmm. That has pros and cons, IMO. So the Makefile will look like:

obj-$(CONFIG_MIPS_VPE_LOADER_CMP)  += vpe.o vpe-cmp.o
obj-$(CONFIG_MIPS_VPE_APSP_API_CMP) += rtlx.o rtlx-cmp.o
obj-$(CONFIG_MIPS_VPE_LOADER_MT)  += vpe.o vpe-mt.o
obj-$(CONFIG_MIPS_VPE_APSP_API_MT) += rtlx.o rtlx-mt.o

It removes ifdef, but doesn't look straightforward to me: CMP and MT APRP 
are mutually exclusive.

>
> Why did we get this new patch that regresses?

This may be something overlooked during the patch reorganization.


Deng-Cheng

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

* Re: [PATCH 2/6] MIPS: APRP: Add VPE loader support for CMP platforms.
@ 2013-10-17 22:38           ` Deng-Cheng Zhu
  0 siblings, 0 replies; 20+ messages in thread
From: Deng-Cheng Zhu @ 2013-10-17 22:38 UTC (permalink / raw)
  To: David Daney; +Cc: Steven J. Hill, linux-mips, ralf

On 10/17/2013 03:11 PM, David Daney wrote:
> On 10/17/2013 03:00 PM, Deng-Cheng Zhu wrote:
>> On 10/17/2013 10:40 AM, David Daney wrote:
>>> On 10/16/2013 07:14 PM, Steven J. Hill wrote:
>>>> From: Deng-Cheng Zhu <dengcheng.zhu@imgtec.com>
>>>>
>>>> This patch adds VPE loader support for platforms having a CMP.
>>>>
>>>> Signed-off-by: Deng-Cheng Zhu <dengcheng.zhu@imgtec.com>
>>>> Signed-off-by: Steven J. Hill <Steven.Hill@imgtec.com>
>>>> Reviewed-by: Qais Yousef <Qais.Yousef@imgtec.com>
>>>> ---
>>>>   arch/mips/kernel/Makefile  |    2 +-
>>>>   arch/mips/kernel/vpe-cmp.c |  184
>>>> ++++++++++++++++++++++++++++++++++++++++++++
>>>>   arch/mips/kernel/vpe-mt.c  |    4 +
>>>>   3 files changed, 189 insertions(+), 1 deletion(-)
>>>>   create mode 100644 arch/mips/kernel/vpe-cmp.c
>>>>
>>>> diff --git a/arch/mips/kernel/Makefile b/arch/mips/kernel/Makefile
>>>> index 51f9117..912eb64 100644
>>>> --- a/arch/mips/kernel/Makefile
>>>> +++ b/arch/mips/kernel/Makefile
>>>> @@ -54,7 +54,7 @@ obj-$(CONFIG_MIPS_MT_SMP)    += smp-mt.o
>>>>   obj-$(CONFIG_MIPS_CMP)        += smp-cmp.o
>>>>   obj-$(CONFIG_CPU_MIPSR2)    += spram.o
>>>>
>>>> -obj-$(CONFIG_MIPS_VPE_LOADER)    += vpe.o vpe-mt.o
>>>> +obj-$(CONFIG_MIPS_VPE_LOADER)    += vpe.o vpe-cmp.o vpe-mt.o
>>>>   obj-$(CONFIG_MIPS_VPE_APSP_API) += rtlx.o
>>>>
>>>>   obj-$(CONFIG_I8259)        += i8259.o
>>>> diff --git a/arch/mips/kernel/vpe-cmp.c b/arch/mips/kernel/vpe-cmp.c
>>>> new file mode 100644
>>>> index 0000000..a5628ca
>>>> --- /dev/null
>>>> +++ b/arch/mips/kernel/vpe-cmp.c
>>>> @@ -0,0 +1,184 @@
>>>> +/*
>>>> + * This file is subject to the terms and conditions of the GNU
>>>> General Public
>>>> + * License.  See the file "COPYING" in the main directory of this
>>>> archive
>>>> + * for more details.
>>>> + *
>>>> + * Copyright (C) 2004, 2005 MIPS Technologies, Inc.  All rights
>>>> reserved.
>>>> + * Copyright (C) 2013 Imagination Technologies Ltd.
>>>> + */
>>>> +#ifdef CONFIG_MIPS_CMP
>>>> +
>>>
>>> Get rid of all these #ifdef.
>>>
>>> Use Kconfig symbols in the makefile instead.
>>>
>>>
>>
>> Right. Splitting stuff into -cmp/-mt files is an effort to remove such
>> kind of #ifdef. The example can be found in Makefile in the v4 of this
>> patch set: http://patchwork.linux-mips.org/patch/5059/
>>
>>
>
> OK, that patch you point to seems a little better, but there are still 
> ifdefs in the Makefile.  You can create synthetic Kconfig variables so 
> the makefile is cleaner, but I don't know if it is worth it in this case.

Hmm. That has pros and cons, IMO. So the Makefile will look like:

obj-$(CONFIG_MIPS_VPE_LOADER_CMP)  += vpe.o vpe-cmp.o
obj-$(CONFIG_MIPS_VPE_APSP_API_CMP) += rtlx.o rtlx-cmp.o
obj-$(CONFIG_MIPS_VPE_LOADER_MT)  += vpe.o vpe-mt.o
obj-$(CONFIG_MIPS_VPE_APSP_API_MT) += rtlx.o rtlx-mt.o

It removes ifdef, but doesn't look straightforward to me: CMP and MT APRP 
are mutually exclusive.

>
> Why did we get this new patch that regresses?

This may be something overlooked during the patch reorganization.


Deng-Cheng

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

* Re: [PATCH 2/6] MIPS: APRP: Add VPE loader support for CMP platforms.
  2013-10-17 22:38           ` Deng-Cheng Zhu
  (?)
@ 2013-10-17 22:54           ` David Daney
  2013-10-17 23:13               ` Deng-Cheng Zhu
  -1 siblings, 1 reply; 20+ messages in thread
From: David Daney @ 2013-10-17 22:54 UTC (permalink / raw)
  To: Deng-Cheng Zhu; +Cc: Steven J. Hill, linux-mips, ralf

On 10/17/2013 03:38 PM, Deng-Cheng Zhu wrote:
> On 10/17/2013 03:11 PM, David Daney wrote:
>> On 10/17/2013 03:00 PM, Deng-Cheng Zhu wrote:
>>> On 10/17/2013 10:40 AM, David Daney wrote:
>>>> On 10/16/2013 07:14 PM, Steven J. Hill wrote:
>>>>> From: Deng-Cheng Zhu <dengcheng.zhu@imgtec.com>
>>>>>
>>>>> This patch adds VPE loader support for platforms having a CMP.
>>>>>
>>>>> Signed-off-by: Deng-Cheng Zhu <dengcheng.zhu@imgtec.com>
>>>>> Signed-off-by: Steven J. Hill <Steven.Hill@imgtec.com>
>>>>> Reviewed-by: Qais Yousef <Qais.Yousef@imgtec.com>
>>>>> ---
>>>>>   arch/mips/kernel/Makefile  |    2 +-
>>>>>   arch/mips/kernel/vpe-cmp.c |  184
>>>>> ++++++++++++++++++++++++++++++++++++++++++++
>>>>>   arch/mips/kernel/vpe-mt.c  |    4 +
>>>>>   3 files changed, 189 insertions(+), 1 deletion(-)
>>>>>   create mode 100644 arch/mips/kernel/vpe-cmp.c
>>>>>
>>>>> diff --git a/arch/mips/kernel/Makefile b/arch/mips/kernel/Makefile
>>>>> index 51f9117..912eb64 100644
>>>>> --- a/arch/mips/kernel/Makefile
>>>>> +++ b/arch/mips/kernel/Makefile
>>>>> @@ -54,7 +54,7 @@ obj-$(CONFIG_MIPS_MT_SMP)    += smp-mt.o
>>>>>   obj-$(CONFIG_MIPS_CMP)        += smp-cmp.o
>>>>>   obj-$(CONFIG_CPU_MIPSR2)    += spram.o
>>>>>
>>>>> -obj-$(CONFIG_MIPS_VPE_LOADER)    += vpe.o vpe-mt.o
>>>>> +obj-$(CONFIG_MIPS_VPE_LOADER)    += vpe.o vpe-cmp.o vpe-mt.o
>>>>>   obj-$(CONFIG_MIPS_VPE_APSP_API) += rtlx.o
>>>>>
>>>>>   obj-$(CONFIG_I8259)        += i8259.o
>>>>> diff --git a/arch/mips/kernel/vpe-cmp.c b/arch/mips/kernel/vpe-cmp.c
>>>>> new file mode 100644
>>>>> index 0000000..a5628ca
>>>>> --- /dev/null
>>>>> +++ b/arch/mips/kernel/vpe-cmp.c
>>>>> @@ -0,0 +1,184 @@
>>>>> +/*
>>>>> + * This file is subject to the terms and conditions of the GNU
>>>>> General Public
>>>>> + * License.  See the file "COPYING" in the main directory of this
>>>>> archive
>>>>> + * for more details.
>>>>> + *
>>>>> + * Copyright (C) 2004, 2005 MIPS Technologies, Inc.  All rights
>>>>> reserved.
>>>>> + * Copyright (C) 2013 Imagination Technologies Ltd.
>>>>> + */
>>>>> +#ifdef CONFIG_MIPS_CMP
>>>>> +
>>>>
>>>> Get rid of all these #ifdef.
>>>>
>>>> Use Kconfig symbols in the makefile instead.
>>>>
>>>>
>>>
>>> Right. Splitting stuff into -cmp/-mt files is an effort to remove such
>>> kind of #ifdef. The example can be found in Makefile in the v4 of this
>>> patch set: http://patchwork.linux-mips.org/patch/5059/
>>>
>>>
>>
>> OK, that patch you point to seems a little better, but there are still
>> ifdefs in the Makefile.  You can create synthetic Kconfig variables so
>> the makefile is cleaner, but I don't know if it is worth it in this case.
>
> Hmm. That has pros and cons, IMO. So the Makefile will look like:
>
> obj-$(CONFIG_MIPS_VPE_LOADER_CMP)  += vpe.o vpe-cmp.o
> obj-$(CONFIG_MIPS_VPE_APSP_API_CMP) += rtlx.o rtlx-cmp.o
> obj-$(CONFIG_MIPS_VPE_LOADER_MT)  += vpe.o vpe-mt.o
> obj-$(CONFIG_MIPS_VPE_APSP_API_MT) += rtlx.o rtlx-mt.o
>
> It removes ifdef, but doesn't look straightforward to me: CMP and MT
> APRP are mutually exclusive.

It is not necessarily cleaner but you could have something like:
---------------------
config MIPS_VPE_LOADER_CMP
	bool
	default "y"
	depends on MIPS_VPE_LOADER && MIPS_CMP

config MIPS_VPE_LOADER_MT
	bool
	default "y"
	depends on MIPS_VPE_LOADER && !MIPS_CMP

----------
obj-$(CONFIG_MIPS_VPE_LOADER)	+= vpe.o
obj-$(CONFIG_MIPS_VPE_LOADER_CMP)	+= vpe-cmt.o
obj-$(CONFIG_MIPS_VPE_LOADER_MT)	+= vpe-mt.o


I would do either that, or what you have in 
http://patchwork.linux-mips.org/patch/5059/  either is acceptable I think.

My main objection was the thing about putting the #ifdefs around the 
entire body of the C files.

David Daney

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

* Re: [PATCH 2/6] MIPS: APRP: Add VPE loader support for CMP platforms.
@ 2013-10-17 23:13               ` Deng-Cheng Zhu
  0 siblings, 0 replies; 20+ messages in thread
From: Deng-Cheng Zhu @ 2013-10-17 23:13 UTC (permalink / raw)
  To: David Daney; +Cc: Steven J. Hill, linux-mips, ralf

On 10/17/2013 03:54 PM, David Daney wrote:
> On 10/17/2013 03:38 PM, Deng-Cheng Zhu wrote:
>> On 10/17/2013 03:11 PM, David Daney wrote:
>>> On 10/17/2013 03:00 PM, Deng-Cheng Zhu wrote:
>>>> On 10/17/2013 10:40 AM, David Daney wrote:
>>>>> On 10/16/2013 07:14 PM, Steven J. Hill wrote:
>>>>>> From: Deng-Cheng Zhu <dengcheng.zhu@imgtec.com>
>>>>>>
>>>>>> This patch adds VPE loader support for platforms having a CMP.
>>>>>>
>>>>>> Signed-off-by: Deng-Cheng Zhu <dengcheng.zhu@imgtec.com>
>>>>>> Signed-off-by: Steven J. Hill <Steven.Hill@imgtec.com>
>>>>>> Reviewed-by: Qais Yousef <Qais.Yousef@imgtec.com>
>>>>>> ---
>>>>>>   arch/mips/kernel/Makefile  |    2 +-
>>>>>>   arch/mips/kernel/vpe-cmp.c |  184
>>>>>> ++++++++++++++++++++++++++++++++++++++++++++
>>>>>>   arch/mips/kernel/vpe-mt.c  |    4 +
>>>>>>   3 files changed, 189 insertions(+), 1 deletion(-)
>>>>>>   create mode 100644 arch/mips/kernel/vpe-cmp.c
>>>>>>
>>>>>> diff --git a/arch/mips/kernel/Makefile b/arch/mips/kernel/Makefile
>>>>>> index 51f9117..912eb64 100644
>>>>>> --- a/arch/mips/kernel/Makefile
>>>>>> +++ b/arch/mips/kernel/Makefile
>>>>>> @@ -54,7 +54,7 @@ obj-$(CONFIG_MIPS_MT_SMP)    += smp-mt.o
>>>>>>   obj-$(CONFIG_MIPS_CMP)        += smp-cmp.o
>>>>>>   obj-$(CONFIG_CPU_MIPSR2)    += spram.o
>>>>>>
>>>>>> -obj-$(CONFIG_MIPS_VPE_LOADER)    += vpe.o vpe-mt.o
>>>>>> +obj-$(CONFIG_MIPS_VPE_LOADER)    += vpe.o vpe-cmp.o vpe-mt.o
>>>>>>   obj-$(CONFIG_MIPS_VPE_APSP_API) += rtlx.o
>>>>>>
>>>>>>   obj-$(CONFIG_I8259)        += i8259.o
>>>>>> diff --git a/arch/mips/kernel/vpe-cmp.c b/arch/mips/kernel/vpe-cmp.c
>>>>>> new file mode 100644
>>>>>> index 0000000..a5628ca
>>>>>> --- /dev/null
>>>>>> +++ b/arch/mips/kernel/vpe-cmp.c
>>>>>> @@ -0,0 +1,184 @@
>>>>>> +/*
>>>>>> + * This file is subject to the terms and conditions of the GNU
>>>>>> General Public
>>>>>> + * License.  See the file "COPYING" in the main directory of this
>>>>>> archive
>>>>>> + * for more details.
>>>>>> + *
>>>>>> + * Copyright (C) 2004, 2005 MIPS Technologies, Inc. All rights
>>>>>> reserved.
>>>>>> + * Copyright (C) 2013 Imagination Technologies Ltd.
>>>>>> + */
>>>>>> +#ifdef CONFIG_MIPS_CMP
>>>>>> +
>>>>>
>>>>> Get rid of all these #ifdef.
>>>>>
>>>>> Use Kconfig symbols in the makefile instead.
>>>>>
>>>>>
>>>>
>>>> Right. Splitting stuff into -cmp/-mt files is an effort to remove such
>>>> kind of #ifdef. The example can be found in Makefile in the v4 of this
>>>> patch set: http://patchwork.linux-mips.org/patch/5059/
>>>>
>>>>
>>>
>>> OK, that patch you point to seems a little better, but there are still
>>> ifdefs in the Makefile.  You can create synthetic Kconfig variables so
>>> the makefile is cleaner, but I don't know if it is worth it in this case.
>>
>> Hmm. That has pros and cons, IMO. So the Makefile will look like:
>>
>> obj-$(CONFIG_MIPS_VPE_LOADER_CMP)  += vpe.o vpe-cmp.o
>> obj-$(CONFIG_MIPS_VPE_APSP_API_CMP) += rtlx.o rtlx-cmp.o
>> obj-$(CONFIG_MIPS_VPE_LOADER_MT)  += vpe.o vpe-mt.o
>> obj-$(CONFIG_MIPS_VPE_APSP_API_MT) += rtlx.o rtlx-mt.o
>>
>> It removes ifdef, but doesn't look straightforward to me: CMP and MT
>> APRP are mutually exclusive.
>
> It is not necessarily cleaner but you could have something like:
> ---------------------
> config MIPS_VPE_LOADER_CMP
>     bool
>     default "y"
>     depends on MIPS_VPE_LOADER && MIPS_CMP
>
> config MIPS_VPE_LOADER_MT
>     bool
>     default "y"
>     depends on MIPS_VPE_LOADER && !MIPS_CMP
>
> ----------
> obj-$(CONFIG_MIPS_VPE_LOADER)    += vpe.o
> obj-$(CONFIG_MIPS_VPE_LOADER_CMP)    += vpe-cmt.o
> obj-$(CONFIG_MIPS_VPE_LOADER_MT)    += vpe-mt.o

Yes, I forgot to use the generic variables for vpe.o and rtlx.o in my last 
reply. Your solution above is right what I wanted to discuss. Thanks for 
the catch of large ifdefs in the C files.


Deng-Cheng

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

* Re: [PATCH 2/6] MIPS: APRP: Add VPE loader support for CMP platforms.
@ 2013-10-17 23:13               ` Deng-Cheng Zhu
  0 siblings, 0 replies; 20+ messages in thread
From: Deng-Cheng Zhu @ 2013-10-17 23:13 UTC (permalink / raw)
  To: David Daney; +Cc: Steven J. Hill, linux-mips, ralf

On 10/17/2013 03:54 PM, David Daney wrote:
> On 10/17/2013 03:38 PM, Deng-Cheng Zhu wrote:
>> On 10/17/2013 03:11 PM, David Daney wrote:
>>> On 10/17/2013 03:00 PM, Deng-Cheng Zhu wrote:
>>>> On 10/17/2013 10:40 AM, David Daney wrote:
>>>>> On 10/16/2013 07:14 PM, Steven J. Hill wrote:
>>>>>> From: Deng-Cheng Zhu <dengcheng.zhu@imgtec.com>
>>>>>>
>>>>>> This patch adds VPE loader support for platforms having a CMP.
>>>>>>
>>>>>> Signed-off-by: Deng-Cheng Zhu <dengcheng.zhu@imgtec.com>
>>>>>> Signed-off-by: Steven J. Hill <Steven.Hill@imgtec.com>
>>>>>> Reviewed-by: Qais Yousef <Qais.Yousef@imgtec.com>
>>>>>> ---
>>>>>>   arch/mips/kernel/Makefile  |    2 +-
>>>>>>   arch/mips/kernel/vpe-cmp.c |  184
>>>>>> ++++++++++++++++++++++++++++++++++++++++++++
>>>>>>   arch/mips/kernel/vpe-mt.c  |    4 +
>>>>>>   3 files changed, 189 insertions(+), 1 deletion(-)
>>>>>>   create mode 100644 arch/mips/kernel/vpe-cmp.c
>>>>>>
>>>>>> diff --git a/arch/mips/kernel/Makefile b/arch/mips/kernel/Makefile
>>>>>> index 51f9117..912eb64 100644
>>>>>> --- a/arch/mips/kernel/Makefile
>>>>>> +++ b/arch/mips/kernel/Makefile
>>>>>> @@ -54,7 +54,7 @@ obj-$(CONFIG_MIPS_MT_SMP)    += smp-mt.o
>>>>>>   obj-$(CONFIG_MIPS_CMP)        += smp-cmp.o
>>>>>>   obj-$(CONFIG_CPU_MIPSR2)    += spram.o
>>>>>>
>>>>>> -obj-$(CONFIG_MIPS_VPE_LOADER)    += vpe.o vpe-mt.o
>>>>>> +obj-$(CONFIG_MIPS_VPE_LOADER)    += vpe.o vpe-cmp.o vpe-mt.o
>>>>>>   obj-$(CONFIG_MIPS_VPE_APSP_API) += rtlx.o
>>>>>>
>>>>>>   obj-$(CONFIG_I8259)        += i8259.o
>>>>>> diff --git a/arch/mips/kernel/vpe-cmp.c b/arch/mips/kernel/vpe-cmp.c
>>>>>> new file mode 100644
>>>>>> index 0000000..a5628ca
>>>>>> --- /dev/null
>>>>>> +++ b/arch/mips/kernel/vpe-cmp.c
>>>>>> @@ -0,0 +1,184 @@
>>>>>> +/*
>>>>>> + * This file is subject to the terms and conditions of the GNU
>>>>>> General Public
>>>>>> + * License.  See the file "COPYING" in the main directory of this
>>>>>> archive
>>>>>> + * for more details.
>>>>>> + *
>>>>>> + * Copyright (C) 2004, 2005 MIPS Technologies, Inc. All rights
>>>>>> reserved.
>>>>>> + * Copyright (C) 2013 Imagination Technologies Ltd.
>>>>>> + */
>>>>>> +#ifdef CONFIG_MIPS_CMP
>>>>>> +
>>>>>
>>>>> Get rid of all these #ifdef.
>>>>>
>>>>> Use Kconfig symbols in the makefile instead.
>>>>>
>>>>>
>>>>
>>>> Right. Splitting stuff into -cmp/-mt files is an effort to remove such
>>>> kind of #ifdef. The example can be found in Makefile in the v4 of this
>>>> patch set: http://patchwork.linux-mips.org/patch/5059/
>>>>
>>>>
>>>
>>> OK, that patch you point to seems a little better, but there are still
>>> ifdefs in the Makefile.  You can create synthetic Kconfig variables so
>>> the makefile is cleaner, but I don't know if it is worth it in this case.
>>
>> Hmm. That has pros and cons, IMO. So the Makefile will look like:
>>
>> obj-$(CONFIG_MIPS_VPE_LOADER_CMP)  += vpe.o vpe-cmp.o
>> obj-$(CONFIG_MIPS_VPE_APSP_API_CMP) += rtlx.o rtlx-cmp.o
>> obj-$(CONFIG_MIPS_VPE_LOADER_MT)  += vpe.o vpe-mt.o
>> obj-$(CONFIG_MIPS_VPE_APSP_API_MT) += rtlx.o rtlx-mt.o
>>
>> It removes ifdef, but doesn't look straightforward to me: CMP and MT
>> APRP are mutually exclusive.
>
> It is not necessarily cleaner but you could have something like:
> ---------------------
> config MIPS_VPE_LOADER_CMP
>     bool
>     default "y"
>     depends on MIPS_VPE_LOADER && MIPS_CMP
>
> config MIPS_VPE_LOADER_MT
>     bool
>     default "y"
>     depends on MIPS_VPE_LOADER && !MIPS_CMP
>
> ----------
> obj-$(CONFIG_MIPS_VPE_LOADER)    += vpe.o
> obj-$(CONFIG_MIPS_VPE_LOADER_CMP)    += vpe-cmt.o
> obj-$(CONFIG_MIPS_VPE_LOADER_MT)    += vpe-mt.o

Yes, I forgot to use the generic variables for vpe.o and rtlx.o in my last 
reply. Your solution above is right what I wanted to discuss. Thanks for 
the catch of large ifdefs in the C files.


Deng-Cheng

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

* [PATCH 2/6] MIPS: APRP: Add VPE loader support for CMP platforms.
  2013-10-30 20:52 [PATCH v2 0/6] MIPS: APRP: Enable APRP for platforms with a CM Steven J. Hill
@ 2013-10-30 20:52 ` Steven J. Hill
  0 siblings, 0 replies; 20+ messages in thread
From: Steven J. Hill @ 2013-10-30 20:52 UTC (permalink / raw)
  To: linux-mips; +Cc: Deng-Cheng Zhu, ralf, Steven J. Hill

From: Deng-Cheng Zhu <dengcheng.zhu@imgtec.com>

This patch adds VPE loader support for platforms having a CMP.

Signed-off-by: Deng-Cheng Zhu <dengcheng.zhu@imgtec.com>
Signed-off-by: Steven J. Hill <Steven.Hill@imgtec.com>
Reviewed-by: Qais Yousef <Qais.Yousef@imgtec.com>
---
 arch/mips/Kconfig          |    5 ++
 arch/mips/kernel/Makefile  |    1 +
 arch/mips/kernel/vpe-cmp.c |  180 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 186 insertions(+)
 create mode 100644 arch/mips/kernel/vpe-cmp.c

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index cc2f283..4c5290e 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -1919,6 +1919,11 @@ config MIPS_VPE_LOADER
 	  Includes a loader for loading an elf relocatable object
 	  onto another VPE and running it.
 
+config MIPS_VPE_LOADER_CMP
+	bool
+	default "y"
+	depends on MIPS_VPE_LOADER && MIPS_CMP
+
 config MIPS_VPE_LOADER_MT
 	bool
 	default "y"
diff --git a/arch/mips/kernel/Makefile b/arch/mips/kernel/Makefile
index 3b9ab45..7f538d1 100644
--- a/arch/mips/kernel/Makefile
+++ b/arch/mips/kernel/Makefile
@@ -55,6 +55,7 @@ obj-$(CONFIG_MIPS_CMP)		+= smp-cmp.o
 obj-$(CONFIG_CPU_MIPSR2)	+= spram.o
 
 obj-$(CONFIG_MIPS_VPE_LOADER)	+= vpe.o
+obj-$(CONFIG_MIPS_VPE_LOADER_CMP) += vpe-cmp.o
 obj-$(CONFIG_MIPS_VPE_LOADER_MT) += vpe-mt.o
 obj-$(CONFIG_MIPS_VPE_APSP_API) += rtlx.o
 
diff --git a/arch/mips/kernel/vpe-cmp.c b/arch/mips/kernel/vpe-cmp.c
new file mode 100644
index 0000000..9268ebc
--- /dev/null
+++ b/arch/mips/kernel/vpe-cmp.c
@@ -0,0 +1,180 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2004, 2005 MIPS Technologies, Inc.  All rights reserved.
+ * Copyright (C) 2013 Imagination Technologies Ltd.
+ */
+#include <linux/kernel.h>
+#include <linux/device.h>
+#include <linux/fs.h>
+#include <linux/slab.h>
+#include <linux/export.h>
+
+#include <asm/vpe.h>
+
+static int major;
+
+void cleanup_tc(struct tc *tc)
+{
+
+}
+
+static ssize_t store_kill(struct device *dev, struct device_attribute *attr,
+			  const char *buf, size_t len)
+{
+	struct vpe *vpe = get_vpe(aprp_cpu_index());
+	struct vpe_notifications *notifier;
+
+	list_for_each_entry(notifier, &vpe->notify, list)
+		notifier->stop(aprp_cpu_index());
+
+	release_progmem(vpe->load_addr);
+	vpe->state = VPE_STATE_UNUSED;
+
+	return len;
+}
+static DEVICE_ATTR(kill, S_IWUSR, NULL, store_kill);
+
+static ssize_t ntcs_show(struct device *cd, struct device_attribute *attr,
+			 char *buf)
+{
+	struct vpe *vpe = get_vpe(aprp_cpu_index());
+
+	return sprintf(buf, "%d\n", vpe->ntcs);
+}
+
+static ssize_t ntcs_store(struct device *dev, struct device_attribute *attr,
+			  const char *buf, size_t len)
+{
+	struct vpe *vpe = get_vpe(aprp_cpu_index());
+	unsigned long new;
+	int ret;
+
+	ret = kstrtoul(buf, 0, &new);
+	if (ret < 0)
+		return ret;
+
+	/* APRP can only reserve one TC in a VPE and no more. */
+	if (new != 1)
+		return -EINVAL;
+
+	vpe->ntcs = new;
+
+	return len;
+}
+static DEVICE_ATTR_RW(ntcs);
+
+static struct attribute *vpe_attrs[] = {
+	&dev_attr_kill.attr,
+	&dev_attr_ntcs.attr,
+	NULL,
+};
+ATTRIBUTE_GROUPS(vpe);
+
+static void vpe_device_release(struct device *cd)
+{
+	kfree(cd);
+}
+
+static struct class vpe_class = {
+	.name = "vpe",
+	.owner = THIS_MODULE,
+	.dev_release = vpe_device_release,
+	.dev_groups = vpe_groups,
+};
+
+static struct device vpe_device;
+
+int __init vpe_module_init(void)
+{
+	struct vpe *v = NULL;
+	struct tc *t;
+	int err;
+
+	if (!cpu_has_mipsmt) {
+		pr_warn("VPE loader: not a MIPS MT capable processor\n");
+		return -ENODEV;
+	}
+
+	if (num_possible_cpus() - aprp_cpu_index() < 1) {
+		pr_warn("No VPEs reserved for AP/SP, not initialize VPE loader\n"
+			"Pass maxcpus=<n> argument as kernel argument\n");
+		return -ENODEV;
+	}
+
+	major = register_chrdev(0, VPE_MODULE_NAME, &vpe_fops);
+	if (major < 0) {
+		pr_warn("VPE loader: unable to register character device\n");
+		return major;
+	}
+
+	err = class_register(&vpe_class);
+	if (err) {
+		pr_err("vpe_class registration failed\n");
+		goto out_chrdev;
+	}
+
+	device_initialize(&vpe_device);
+	vpe_device.class	= &vpe_class,
+	vpe_device.parent	= NULL,
+	dev_set_name(&vpe_device, "vpe_sp");
+	vpe_device.devt = MKDEV(major, VPE_MODULE_MINOR);
+	err = device_add(&vpe_device);
+	if (err) {
+		pr_err("Adding vpe_device failed\n");
+		goto out_class;
+	}
+
+	t = alloc_tc(aprp_cpu_index());
+	if (!t) {
+		pr_warn("VPE: unable to allocate TC\n");
+		err = -ENOMEM;
+		goto out_dev;
+	}
+
+	/* VPE */
+	v = alloc_vpe(aprp_cpu_index());
+	if (v == NULL) {
+		pr_warn("VPE: unable to allocate VPE\n");
+		kfree(t);
+		err = -ENOMEM;
+		goto out_dev;
+	}
+
+	v->ntcs = 1;
+
+	/* add the tc to the list of this vpe's tc's. */
+	list_add(&t->tc, &v->tc);
+
+	/* TC */
+	t->pvpe = v;	/* set the parent vpe */
+
+	return 0;
+
+out_dev:
+	device_del(&vpe_device);
+
+out_class:
+	class_unregister(&vpe_class);
+
+out_chrdev:
+	unregister_chrdev(major, VPE_MODULE_NAME);
+
+	return err;
+}
+
+void __exit vpe_module_exit(void)
+{
+	struct vpe *v, *n;
+
+	device_del(&vpe_device);
+	class_unregister(&vpe_class);
+	unregister_chrdev(major, VPE_MODULE_NAME);
+
+	/* No locking needed here */
+	list_for_each_entry_safe(v, n, &vpecontrol.vpe_list, list)
+		if (v->state != VPE_STATE_UNUSED)
+			release_vpe(v);
+}
-- 
1.7.9.5

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

end of thread, other threads:[~2013-10-30 20:52 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-17  2:14 [PATCH 0/6] MIPS: APRP: Enable APRP for platforms with a CM Steven J. Hill
2013-10-17  2:14 ` [PATCH 1/6] MIPS: APRP: Split VPE loader into separate files Steven J. Hill
2013-10-17  2:14 ` [PATCH 2/6] MIPS: APRP: Add VPE loader support for CMP platforms Steven J. Hill
2013-10-17 17:40   ` David Daney
2013-10-17 22:00     ` Deng-Cheng Zhu
2013-10-17 22:00       ` Deng-Cheng Zhu
2013-10-17 22:11       ` David Daney
2013-10-17 22:38         ` Deng-Cheng Zhu
2013-10-17 22:38           ` Deng-Cheng Zhu
2013-10-17 22:54           ` David Daney
2013-10-17 23:13             ` Deng-Cheng Zhu
2013-10-17 23:13               ` Deng-Cheng Zhu
2013-10-17  2:14 ` [PATCH 3/6] MIPS: APRP: Split RTLX support into separate files Steven J. Hill
2013-10-17  2:14 ` [PATCH 4/6] MIPS: APRP: Add RTLX API support for CMP platforms Steven J. Hill
2013-10-17  2:14 ` [PATCH 5/6] MIPS: APRP: Malta Add support for Malta CMP platform Steven J. Hill
2013-10-17  2:14 ` [PATCH 6/6] MIPS: APRP: Code formatting clean-ups Steven J. Hill
2013-10-17 17:50   ` David Daney
2013-10-17 18:26     ` Steven J. Hill
2013-10-17 18:26       ` Steven J. Hill
  -- strict thread matches above, loose matches on Subject: below --
2013-10-30 20:52 [PATCH v2 0/6] MIPS: APRP: Enable APRP for platforms with a CM Steven J. Hill
2013-10-30 20:52 ` [PATCH 2/6] MIPS: APRP: Add VPE loader support for CMP platforms Steven J. Hill

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.