From 3450bab862e5a5106541e17e82f8fddb4cf87431 Mon Sep 17 00:00:00 2001
From: Robert Nelson <robertcnelson@gmail.com>
Date: Tue, 15 Feb 2011 15:33:04 -0600
Subject: [PATCH] sgx cleanup, drop Big Kernel lock from configs, use 2 over 4
 for number of cpus

Signed-off-by: Robert Nelson <robertcnelson@gmail.com>
---
 patch.sh                                      |   4 +-
 patches/defconfig                             |  29 +-
 patches/no_devtmps-defconfig                  |  29 +-
 ...01-OMAP3-SGX-TI-3.01.00.06-2.6.32-PSP.diff | 574 ------------------
 ...1-OMAP3-SGX-TI-3.01.00.06-2.6.32-PSP.patch |  41 ++
 ...-OMAP3-SGX-TI-3.01.00.06-use-omap3630.diff |  13 -
 ...OMAP3-SGX-TI-3.01.00.06-use-omap3630.patch |  26 +
 version.sh                                    |   2 +-
 8 files changed, 78 insertions(+), 640 deletions(-)
 delete mode 100644 patches/sgx/0001-OMAP3-SGX-TI-3.01.00.06-2.6.32-PSP.diff
 create mode 100644 patches/sgx/0001-OMAP3-SGX-TI-3.01.00.06-2.6.32-PSP.patch
 delete mode 100644 patches/sgx/0001-OMAP3-SGX-TI-3.01.00.06-use-omap3630.diff
 create mode 100644 patches/sgx/0001-OMAP3-SGX-TI-3.01.00.06-use-omap3630.patch

diff --git a/patch.sh b/patch.sh
index b9f771412..2ae7da54d 100644
--- a/patch.sh
+++ b/patch.sh
@@ -134,8 +134,8 @@ patch -s -p1 < "${DIR}/patches/sgx/0001-OMAP3-SGX-Merge-TI-3.01.00.07-into-TI-3.
 patch -s -p1 < "${DIR}/patches/sgx/0001-OMAP3-SGX-Merge-TI-4.00.00.01-into-TI-3.01.00.07.patch"
 
 #3.01.00.06/07 & 4.00.00.01 Patches
-patch -s -p1 < "${DIR}/patches/sgx/0001-OMAP3-SGX-TI-3.01.00.06-2.6.32-PSP.diff"
-patch -s -p1 < "${DIR}/patches/sgx/0001-OMAP3-SGX-TI-3.01.00.06-use-omap3630.diff"
+patch -s -p1 < "${DIR}/patches/sgx/0001-OMAP3-SGX-TI-3.01.00.06-2.6.32-PSP.patch"
+patch -s -p1 < "${DIR}/patches/sgx/0001-OMAP3-SGX-TI-3.01.00.06-use-omap3630.patch"
 
 #dropped with 4.00.00.01
 #patch -s -p1 < "${DIR}/patches/sgx/0001-OMAP3-SGX-TI-3.01.00.06-Compile-Fixes.patch"
diff --git a/patches/defconfig b/patches/defconfig
index e5c09979d..bc2be2b25 100644
--- a/patches/defconfig
+++ b/patches/defconfig
@@ -1,7 +1,7 @@
 #
 # Automatically generated make config: don't edit
-# Linux/arm 2.6.38-rc3 Kernel Configuration
-# Tue Feb  1 10:24:51 2011
+# Linux/arm 2.6.38-rc4 Kernel Configuration
+# Tue Feb 15 12:48:15 2011
 #
 CONFIG_ARM=y
 CONFIG_SYS_SUPPORTS_APM_EMULATION=y
@@ -33,7 +33,6 @@ CONFIG_IRQ_WORK=y
 # General setup
 #
 CONFIG_EXPERIMENTAL=y
-CONFIG_LOCK_KERNEL=y
 CONFIG_INIT_ENV_ARG_LIMIT=32
 CONFIG_CROSS_COMPILE=""
 CONFIG_LOCALVERSION=""
@@ -423,7 +422,7 @@ CONFIG_VMSPLIT_3G=y
 # CONFIG_VMSPLIT_2G is not set
 # CONFIG_VMSPLIT_1G is not set
 CONFIG_PAGE_OFFSET=0xC0000000
-CONFIG_NR_CPUS=4
+CONFIG_NR_CPUS=2
 CONFIG_HOTPLUG_CPU=y
 CONFIG_LOCAL_TIMERS=y
 # CONFIG_PREEMPT_NONE is not set
@@ -908,14 +907,6 @@ CONFIG_DECNET=m
 # CONFIG_DECNET_ROUTER is not set
 CONFIG_LLC=m
 CONFIG_LLC2=m
-CONFIG_IPX=m
-# CONFIG_IPX_INTERN is not set
-CONFIG_ATALK=m
-CONFIG_DEV_APPLETALK=m
-CONFIG_IPDDP=m
-CONFIG_IPDDP_ENCAP=y
-CONFIG_IPDDP_DECAP=y
-CONFIG_X25=m
 CONFIG_LAPB=m
 CONFIG_ECONET=m
 CONFIG_ECONET_AUNUDP=y
@@ -3191,10 +3182,6 @@ CONFIG_STAGING=y
 CONFIG_USB_DABUSB=m
 # CONFIG_USB_SE401 is not set
 # CONFIG_USB_VICAM is not set
-CONFIG_USB_IP_COMMON=m
-CONFIG_USB_IP_VHCI_HCD=m
-CONFIG_USB_IP_HOST=m
-# CONFIG_USB_IP_DEBUG_ENABLE is not set
 # CONFIG_W35UND is not set
 CONFIG_PRISM2_USB=m
 # CONFIG_ECHO is not set
@@ -3207,7 +3194,6 @@ CONFIG_R8712U=m
 CONFIG_R8712_AP=y
 # CONFIG_TRANZPORT is not set
 # CONFIG_POHMELFS is not set
-# CONFIG_AUTOFS_FS is not set
 # CONFIG_LINE6_USB is not set
 # CONFIG_USB_SERIAL_QUATECH2 is not set
 # CONFIG_USB_SERIAL_QUATECH_USB2 is not set
@@ -3221,7 +3207,6 @@ CONFIG_ZRAM=m
 #
 # CONFIG_ST_BT is not set
 # CONFIG_LIRC_STAGING is not set
-# CONFIG_SMB_FS is not set
 # CONFIG_EASYCAP is not set
 CONFIG_TIDSPBRIDGE=m
 CONFIG_TIDSPBRIDGE_MEMPOOL_SIZE=0x600000
@@ -3364,8 +3349,6 @@ CONFIG_TMPFS_POSIX_ACL=y
 # CONFIG_HUGETLB_PAGE is not set
 CONFIG_CONFIGFS_FS=m
 CONFIG_MISC_FILESYSTEMS=y
-CONFIG_ADFS_FS=m
-# CONFIG_ADFS_FS_RW is not set
 CONFIG_AFFS_FS=m
 CONFIG_ECRYPT_FS=m
 CONFIG_HFS_FS=m
@@ -3406,7 +3389,6 @@ CONFIG_SQUASHFS_FRAGMENT_CACHE_SIZE=3
 CONFIG_VXFS_FS=m
 CONFIG_MINIX_FS=m
 CONFIG_OMFS_FS=m
-CONFIG_HPFS_FS=m
 CONFIG_QNX4FS_FS=m
 CONFIG_ROMFS_FS=m
 CONFIG_ROMFS_BACKED_BY_BLOCK=y
@@ -3414,9 +3396,6 @@ CONFIG_ROMFS_BACKED_BY_BLOCK=y
 # CONFIG_ROMFS_BACKED_BY_BOTH is not set
 CONFIG_ROMFS_ON_BLOCK=y
 CONFIG_SYSV_FS=m
-CONFIG_UFS_FS=m
-# CONFIG_UFS_FS_WRITE is not set
-# CONFIG_UFS_DEBUG is not set
 CONFIG_NETWORK_FILESYSTEMS=y
 CONFIG_NFS_FS=y
 CONFIG_NFS_V3=y
@@ -3571,7 +3550,7 @@ CONFIG_DEBUG_PREEMPT=y
 # CONFIG_RT_MUTEX_TESTER is not set
 # CONFIG_DEBUG_SPINLOCK is not set
 # CONFIG_DEBUG_MUTEXES is not set
-CONFIG_BKL=y
+# CONFIG_BKL is not set
 # CONFIG_DEBUG_LOCK_ALLOC is not set
 # CONFIG_PROVE_LOCKING is not set
 # CONFIG_SPARSE_RCU_POINTER is not set
diff --git a/patches/no_devtmps-defconfig b/patches/no_devtmps-defconfig
index 7ff1b7bb6..17625704a 100644
--- a/patches/no_devtmps-defconfig
+++ b/patches/no_devtmps-defconfig
@@ -1,7 +1,7 @@
 #
 # Automatically generated make config: don't edit
-# Linux/arm 2.6.38-rc3 Kernel Configuration
-# Tue Feb  1 10:24:51 2011
+# Linux/arm 2.6.38-rc4 Kernel Configuration
+# Tue Feb 15 12:48:15 2011
 #
 CONFIG_ARM=y
 CONFIG_SYS_SUPPORTS_APM_EMULATION=y
@@ -33,7 +33,6 @@ CONFIG_IRQ_WORK=y
 # General setup
 #
 CONFIG_EXPERIMENTAL=y
-CONFIG_LOCK_KERNEL=y
 CONFIG_INIT_ENV_ARG_LIMIT=32
 CONFIG_CROSS_COMPILE=""
 CONFIG_LOCALVERSION=""
@@ -423,7 +422,7 @@ CONFIG_VMSPLIT_3G=y
 # CONFIG_VMSPLIT_2G is not set
 # CONFIG_VMSPLIT_1G is not set
 CONFIG_PAGE_OFFSET=0xC0000000
-CONFIG_NR_CPUS=4
+CONFIG_NR_CPUS=2
 CONFIG_HOTPLUG_CPU=y
 CONFIG_LOCAL_TIMERS=y
 # CONFIG_PREEMPT_NONE is not set
@@ -908,14 +907,6 @@ CONFIG_DECNET=m
 # CONFIG_DECNET_ROUTER is not set
 CONFIG_LLC=m
 CONFIG_LLC2=m
-CONFIG_IPX=m
-# CONFIG_IPX_INTERN is not set
-CONFIG_ATALK=m
-CONFIG_DEV_APPLETALK=m
-CONFIG_IPDDP=m
-CONFIG_IPDDP_ENCAP=y
-CONFIG_IPDDP_DECAP=y
-CONFIG_X25=m
 CONFIG_LAPB=m
 CONFIG_ECONET=m
 CONFIG_ECONET_AUNUDP=y
@@ -3190,10 +3181,6 @@ CONFIG_STAGING=y
 CONFIG_USB_DABUSB=m
 # CONFIG_USB_SE401 is not set
 # CONFIG_USB_VICAM is not set
-CONFIG_USB_IP_COMMON=m
-CONFIG_USB_IP_VHCI_HCD=m
-CONFIG_USB_IP_HOST=m
-# CONFIG_USB_IP_DEBUG_ENABLE is not set
 # CONFIG_W35UND is not set
 CONFIG_PRISM2_USB=m
 # CONFIG_ECHO is not set
@@ -3206,7 +3193,6 @@ CONFIG_R8712U=m
 CONFIG_R8712_AP=y
 # CONFIG_TRANZPORT is not set
 # CONFIG_POHMELFS is not set
-# CONFIG_AUTOFS_FS is not set
 # CONFIG_LINE6_USB is not set
 # CONFIG_USB_SERIAL_QUATECH2 is not set
 # CONFIG_USB_SERIAL_QUATECH_USB2 is not set
@@ -3220,7 +3206,6 @@ CONFIG_ZRAM=m
 #
 # CONFIG_ST_BT is not set
 # CONFIG_LIRC_STAGING is not set
-# CONFIG_SMB_FS is not set
 # CONFIG_EASYCAP is not set
 CONFIG_TIDSPBRIDGE=m
 CONFIG_TIDSPBRIDGE_MEMPOOL_SIZE=0x600000
@@ -3363,8 +3348,6 @@ CONFIG_TMPFS_POSIX_ACL=y
 # CONFIG_HUGETLB_PAGE is not set
 CONFIG_CONFIGFS_FS=m
 CONFIG_MISC_FILESYSTEMS=y
-CONFIG_ADFS_FS=m
-# CONFIG_ADFS_FS_RW is not set
 CONFIG_AFFS_FS=m
 CONFIG_ECRYPT_FS=m
 CONFIG_HFS_FS=m
@@ -3405,7 +3388,6 @@ CONFIG_SQUASHFS_FRAGMENT_CACHE_SIZE=3
 CONFIG_VXFS_FS=m
 CONFIG_MINIX_FS=m
 CONFIG_OMFS_FS=m
-CONFIG_HPFS_FS=m
 CONFIG_QNX4FS_FS=m
 CONFIG_ROMFS_FS=m
 CONFIG_ROMFS_BACKED_BY_BLOCK=y
@@ -3413,9 +3395,6 @@ CONFIG_ROMFS_BACKED_BY_BLOCK=y
 # CONFIG_ROMFS_BACKED_BY_BOTH is not set
 CONFIG_ROMFS_ON_BLOCK=y
 CONFIG_SYSV_FS=m
-CONFIG_UFS_FS=m
-# CONFIG_UFS_FS_WRITE is not set
-# CONFIG_UFS_DEBUG is not set
 CONFIG_NETWORK_FILESYSTEMS=y
 CONFIG_NFS_FS=y
 CONFIG_NFS_V3=y
@@ -3570,7 +3549,7 @@ CONFIG_DEBUG_PREEMPT=y
 # CONFIG_RT_MUTEX_TESTER is not set
 # CONFIG_DEBUG_SPINLOCK is not set
 # CONFIG_DEBUG_MUTEXES is not set
-CONFIG_BKL=y
+# CONFIG_BKL is not set
 # CONFIG_DEBUG_LOCK_ALLOC is not set
 # CONFIG_PROVE_LOCKING is not set
 # CONFIG_SPARSE_RCU_POINTER is not set
diff --git a/patches/sgx/0001-OMAP3-SGX-TI-3.01.00.06-2.6.32-PSP.diff b/patches/sgx/0001-OMAP3-SGX-TI-3.01.00.06-2.6.32-PSP.diff
deleted file mode 100644
index d77692b60..000000000
--- a/patches/sgx/0001-OMAP3-SGX-TI-3.01.00.06-2.6.32-PSP.diff
+++ /dev/null
@@ -1,574 +0,0 @@
-diff --git a/arch/arm/plat-omap/include/plat/resource.h b/arch/arm/plat-omap/include/plat/resource.h
-new file mode 100644
-index 0000000..9acebcc
---- /dev/null
-+++ b/arch/arm/plat-omap/include/plat/resource.h
-@@ -0,0 +1,97 @@
-+/*
-+ * linux/include/asm-arm/arch-omap/resource.h
-+ * Structure definitions for Shared resource Framework
-+ *
-+ * Copyright (C) 2007-2008 Texas Instruments, Inc.
-+ * Written by Rajendra Nayak <rnayak@ti.com>
-+ *
-+ * This program is free software; you can redistribute it and/or modify
-+ * it under the terms of the GNU General Public License version 2 as
-+ * published by the Free Software Foundation.
-+ *
-+ * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
-+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
-+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-+ *
-+ * History:
-+ *
-+ */
-+
-+#ifndef __ARCH_ARM_OMAP_RESOURCE_H
-+#define __ARCH_ARM_OMAP_RESOURCE_H
-+
-+#include <linux/list.h>
-+#include <linux/mutex.h>
-+#include <linux/device.h>
-+
-+#include <plat/cpu.h>
-+
-+#define RES_PERFORMANCE_DEFAULTLEVEL	0
-+#define RES_LATENCY_DEFAULTLEVEL	-1
-+
-+/* Types of resources */
-+#define RES_TYPE_PERFORMANCE	0x1
-+#define RES_TYPE_LATENCY	0x2
-+
-+struct shared_resource_ops; /* forward declaration */
-+
-+/* Used to model a Shared Multilevel Resource */
-+struct shared_resource {
-+	/* Resource name */
-+	char *name;
-+	/* Used to represent the OMAP chip types containing this res */
-+	const struct omap_chip_id omap_chip;
-+	/* Resource type flags */
-+	const u8 flags;
-+	/* Total no of users at any point of this resource */
-+	u8 no_of_users;
-+	/* Current level of this resource */
-+	u32 curr_level;
-+	/* Used to store any resource specific data */
-+	void  *resource_data;
-+	/* List of all the current users for this resource */
-+	struct list_head users_list;
-+	/* Shared resource operations */
-+	struct shared_resource_ops *ops;
-+	struct list_head node;
-+};
-+
-+struct shared_resource_ops {
-+	/* Init function for the resource */
-+	void (*init)(struct shared_resource *res);
-+	/* Function to change the level of the resource */
-+	int (*change_level)(struct shared_resource *res, u32 target_level);
-+	/* Function to validate the requested level of the resource */
-+	int (*validate_level)(struct shared_resource *res, u32 target_level);
-+};
-+
-+/* Used to represent a user of a shared resource */
-+struct users_list {
-+	/* Device pointer used to uniquely identify the user */
-+	struct device *dev;
-+	/* Current level as requested for the resource by the user */
-+	u32 level;
-+	struct list_head node;
-+	u8 usage;
-+};
-+
-+extern struct shared_resource *resources_omap[];
-+/* Shared resource Framework API's */
-+void resource_init(struct shared_resource **resources);
-+int resource_refresh(void);
-+int resource_register(struct shared_resource *res);
-+int resource_unregister(struct shared_resource *res);
-+int resource_request(const char *name, struct device *dev,
-+						 unsigned long level);
-+int resource_release(const char *name, struct device *dev);
-+int resource_get_level(const char *name);
-+
-+extern int resource_set_opp_level(int res, u32 target_level, int flags);
-+extern int resource_access_opp_lock(int res, int delta);
-+#define resource_lock_opp(res) resource_access_opp_lock(res, 1)
-+#define resource_unlock_opp(res) resource_access_opp_lock(res, -1)
-+#define resource_get_opp_lock(res) resource_access_opp_lock(res, 0)
-+
-+#define OPP_IGNORE_LOCK 0x1
-+ 
-+#endif /* __ARCH_ARM_OMAP_RESOURCE_H */
-diff --git a/arch/arm/plat-omap/resource.c b/arch/arm/plat-omap/resource.c
-new file mode 100644
-index 0000000..f1cdecf
---- /dev/null
-+++ b/arch/arm/plat-omap/resource.c
-@@ -0,0 +1,465 @@
-+/*
-+ * linux/arch/arm/plat-omap/resource.c
-+ * Shared Resource Framework API implementation
-+ *
-+ * Copyright (C) 2007-2008 Texas Instruments, Inc.
-+ * Rajendra Nayak <rnayak@ti.com>
-+ *
-+ * This program is free software; you can redistribute it and/or modify
-+ * it under the terms of the GNU General Public License version 2 as
-+ * published by the Free Software Foundation.
-+ *
-+ * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
-+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
-+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-+ * History:
-+ *
-+ */
-+
-+#include <linux/errno.h>
-+#include <linux/err.h>
-+#include <linux/slab.h>
-+
-+#include <plat/resource.h>
-+
-+/*
-+ * This is for statically defining the users pool. This static pool is
-+ * used early at bootup till kmalloc becomes available.
-+ */
-+#define MAX_USERS	10
-+#define UNUSED		0x0
-+#define	DYNAMIC_ALLOC	0x1
-+#define STATIC_ALLOC	0x2
-+
-+/* res_list contains all registered struct shared_resource */
-+static LIST_HEAD(res_list);
-+
-+/* res_mutex protects res_list add and del ops */
-+static DECLARE_MUTEX(res_mutex);
-+
-+/* Static Pool of users for a resource used till kmalloc becomes available */
-+struct  users_list usr_list[MAX_USERS];
-+
-+/* Private/Internal functions */
-+
-+/**
-+ * _resource_lookup - loop up a resource by its name, return a pointer
-+ * @name: The name of the resource to lookup
-+ *
-+ * Looks for a registered resource by its name. Returns a pointer to
-+ * the struct shared_resource if found, else returns NULL.
-+ * The function is not lock safe.
-+ */
-+static struct shared_resource *_resource_lookup(const char *name)
-+{
-+	struct shared_resource *res, *tmp_res;
-+
-+	if (!name)
-+		return NULL;
-+
-+	res = NULL;
-+
-+	list_for_each_entry(tmp_res, &res_list, node) {
-+		if (!strcmp(name, tmp_res->name)) {
-+			res = tmp_res;
-+			break;
-+		}
-+	}
-+	return res;
-+}
-+
-+/**
-+ * resource_lookup - loop up a resource by its name, return a pointer
-+ * @name: The name of the resource to lookup
-+ *
-+ * Looks for a registered resource by its name. Returns a pointer to
-+ * the struct shared_resource if found, else returns NULL.
-+ * The function holds mutex and takes care of atomicity.
-+ */
-+static struct shared_resource *resource_lookup(const char *name)
-+{
-+	struct shared_resource *res;
-+
-+	if (!name)
-+		return NULL;
-+	down(&res_mutex);
-+	res = _resource_lookup(name);
-+	up(&res_mutex);
-+
-+	return res;
-+}
-+
-+/**
-+ * update_resource_level - Regenerates and updates the curr_level of the res
-+ * @resp: Pointer to the resource
-+ *
-+ * This function looks at all the users of the given resource and the levels
-+ * requested by each of them, and recomputes a target level for the resource
-+ * acceptable to all its current usres. It then calls platform specific
-+ * change_level to change the level of the resource.
-+ * Returns 0 on success, else a non-zero value returned by the platform
-+ * specific change_level function.
-+ **/
-+static int update_resource_level(struct shared_resource *resp)
-+{
-+	struct users_list *user;
-+	unsigned long target_level;
-+	int ret;
-+
-+	/* Regenerate the target_value for the resource */
-+	if (resp->flags & RES_TYPE_PERFORMANCE) {
-+		target_level = RES_PERFORMANCE_DEFAULTLEVEL;
-+		list_for_each_entry(user, &resp->users_list, node)
-+			if (user->level > target_level)
-+				target_level = user->level;
-+	} else if (resp->flags & RES_TYPE_LATENCY) {
-+		target_level = RES_LATENCY_DEFAULTLEVEL;
-+		list_for_each_entry(user, &resp->users_list, node)
-+			if (user->level < target_level)
-+				target_level = user->level;
-+	} else {
-+		pr_debug("SRF: Unknown resource type\n");
-+		return -EINVAL;
-+	}
-+
-+	pr_debug("SRF: Changing Level for resource %s to %ld\n",
-+				resp->name, target_level);
-+	ret = resp->ops->change_level(resp, target_level);
-+	if (ret) {
-+		printk(KERN_ERR "Unable to Change"
-+					"level for resource %s to %ld\n",
-+		resp->name, target_level);
-+	}
-+	return ret;
-+}
-+
-+/**
-+ * get_user - gets a new users_list struct from static pool or dynamically
-+ *
-+ * This function initally looks for availability in the static pool and
-+ * tries to dynamcially allocate only once the static pool is empty.
-+ * We hope that during bootup by the time we hit a case of dynamic allocation
-+ * slab initialization would have happened.
-+ * Returns a pointer users_list struct on success. On dynamic allocation failure
-+ * returns a ERR_PTR(-ENOMEM).
-+ */
-+static struct users_list *get_user(void)
-+{
-+	int ind = 0;
-+	struct users_list *user;
-+
-+	/* See if something available in the static pool */
-+	while (ind < MAX_USERS) {
-+		if (usr_list[ind].usage == UNUSED)
-+			break;
-+		else
-+			ind++;
-+	}
-+	if (ind < MAX_USERS) {
-+		/* Pick from the static pool */
-+		user = &usr_list[ind];
-+		user->usage = STATIC_ALLOC;
-+	} else {
-+		/* By this time we hope slab is initialized */
-+		if (slab_is_available()) {
-+			user = kmalloc(sizeof(struct  users_list), GFP_KERNEL);
-+			if (!user) {
-+				printk(KERN_ERR "SRF:FATAL ERROR: kmalloc"
-+							"failed\n");
-+				return ERR_PTR(-ENOMEM);
-+			}
-+			user->usage = DYNAMIC_ALLOC;
-+		} else {
-+			/* Dynamic alloc not available yet */
-+			printk(KERN_ERR "SRF: FATAL ERROR: users_list"
-+				"initial POOL EMPTY before slab init\n");
-+			return ERR_PTR(-ENOMEM);
-+		}
-+	}
-+	return user;
-+}
-+
-+/**
-+ * free_user - frees the dynamic users_list and marks the static one unused
-+ * @user: The struct users_list to be freed
-+ *
-+ * Looks at the usage flag and either frees the users_list if it was
-+ * dynamically allocated, and if its from the static pool, marks it unused.
-+ * No return value.
-+ */
-+void free_user(struct users_list *user)
-+{
-+	if (user->usage == DYNAMIC_ALLOC) {
-+		kfree(user);
-+	} else {
-+		user->usage = UNUSED;
-+		user->dev = NULL;
-+	}
-+}
-+
-+/**
-+ * resource_init - Initializes the Shared resource framework.
-+ * @resources: List of all the resources modelled
-+ *
-+ * Loops through the list of resources and registers all that
-+ * are available for the current CPU.
-+ * No return value
-+ */
-+void resource_init(struct shared_resource **resources)
-+{
-+	struct shared_resource **resp;
-+	int ind;
-+
-+	pr_debug("Initializing Shared Resource Framework\n");
-+
-+	if (!cpu_is_omap34xx()) {
-+		/* This CPU is not supported */
-+		printk(KERN_WARNING "Shared Resource Framework does not"
-+			"support this CPU type.\n");
-+		WARN_ON(1);
-+	}
-+
-+	/* Init the users_list POOL */
-+	for (ind = 0; ind < MAX_USERS; ind++) {
-+		usr_list[ind].usage = UNUSED;
-+		usr_list[ind].dev = NULL;
-+	}
-+
-+	if (resources)
-+		for (resp = resources; *resp; resp++)
-+			resource_register(*resp);
-+}
-+
-+/**
-+ * resource_refresh - Refresh the states of all current resources
-+ *
-+ * If a condition in power domains has changed that requires refreshing
-+ * power domain states, this function can be used to restore correct
-+ * states according to shared resources.
-+ * Returns 0 on success, non-zero, if some resource cannot be refreshed.
-+ */
-+int resource_refresh(void)
-+{
-+	struct shared_resource *resp = NULL;
-+	int ret = 0;
-+
-+	list_for_each_entry(resp, &res_list, node) {
-+		ret = update_resource_level(resp);
-+		if (ret)
-+			break;
-+	}
-+	return ret;
-+}
-+
-+/**
-+ * resource_register - registers and initializes a resource
-+ * @res: struct shared_resource * to register
-+ *
-+ * Initializes the given resource and adds it to the resource list
-+ * for the current CPU.
-+ * Returns 0 on success, -EINVAL if given a NULL pointer, -EEXIST if the
-+ * resource is already registered.
-+ */
-+int resource_register(struct shared_resource *resp)
-+{
-+	int ret = 0;
-+	if (!resp)
-+		return -EINVAL;
-+
-+	if (!omap_chip_is(resp->omap_chip))
-+		return -EINVAL;
-+
-+	/* Verify that the resource is not already registered */
-+	down(&res_mutex);
-+	if (_resource_lookup(resp->name)) {
-+		ret = -EEXIST;
-+		goto out;
-+	}
-+
-+	INIT_LIST_HEAD(&resp->users_list);
-+
-+	/* Add the resource to the resource list */
-+	list_add(&resp->node, &res_list);
-+
-+	/* Call the resource specific init*/
-+	if (resp->ops->init)
-+		resp->ops->init(resp);
-+
-+	pr_debug("resource: registered %s\n", resp->name);
-+
-+out:
-+	up(&res_mutex);
-+	return ret;
-+}
-+EXPORT_SYMBOL(resource_register);
-+
-+/**
-+ * resource_unregister - unregister a resource
-+ * @res: struct shared_resource * to unregister
-+ *
-+ * Removes a resource from the resource list.
-+ * Returns 0 on success, -EINVAL if passed a NULL pointer.
-+ */
-+int resource_unregister(struct shared_resource *resp)
-+{
-+	if (!resp)
-+		return -EINVAL;
-+
-+	down(&res_mutex);
-+	/* delete the resource from the resource list */
-+	list_del(&resp->node);
-+	up(&res_mutex);
-+
-+	pr_debug("resource: unregistered %s\n", resp->name);
-+
-+	return 0;
-+}
-+EXPORT_SYMBOL(resource_unregister);
-+
-+/**
-+ * resource_request - Request for a required level of a resource
-+ * @name: The name of the resource requested
-+ * @dev: Uniquely identifes the caller
-+ * @level: The requested level for the resource
-+ *
-+ * This function recomputes the target level of the resource based on
-+ * the level requested by the user. The level of the resource is
-+ * changed to the target level, if it is not the same as the existing level
-+ * of the resource. Multiple calls to this function by the same device will
-+ * replace the previous level requested
-+ * Returns 0 on success, -EINVAL if the resource name passed in invalid.
-+ * -ENOMEM if no static pool available or dynamic allocations fails.
-+ * Else returns a non-zero error value returned by one of the failing
-+ * shared_resource_ops.
-+ */
-+int resource_request(const char *name, struct device *dev,
-+					unsigned long level)
-+{
-+	struct shared_resource *resp;
-+	struct  users_list *user;
-+	int 	found = 0, ret = 0;
-+
-+	down(&res_mutex);
-+	resp = _resource_lookup(name);
-+	if (!resp) {
-+		printk(KERN_ERR "resource_request: Invalid resource name\n");
-+		ret = -EINVAL;
-+		goto res_unlock;
-+	}
-+
-+	/* Call the resource specific validate function */
-+	if (resp->ops->validate_level) {
-+		ret = resp->ops->validate_level(resp, level);
-+		if (ret)
-+			goto res_unlock;
-+	}
-+
-+	list_for_each_entry(user, &resp->users_list, node) {
-+		if (user->dev == dev) {
-+			found = 1;
-+			break;
-+		}
-+	}
-+
-+	if (!found) {
-+		/* First time user */
-+		user = get_user();
-+		if (IS_ERR(user)) {
-+			ret = -ENOMEM;
-+			goto res_unlock;
-+		}
-+		user->dev = dev;
-+		list_add(&user->node, &resp->users_list);
-+		resp->no_of_users++;
-+	}
-+	user->level = level;
-+
-+res_unlock:
-+	up(&res_mutex);
-+	/*
-+	 * Recompute and set the current level for the resource.
-+	 * NOTE: update_resource level moved out of spin_lock, as it may call
-+	 * pm_qos_add_requirement, which does a kzmalloc. This won't be allowed
-+	 * in iterrupt context. The spin_lock still protects add/remove users.
-+	 */
-+	if (!ret)
-+		ret = update_resource_level(resp);
-+	return ret;
-+}
-+EXPORT_SYMBOL(resource_request);
-+
-+/**
-+ * resource_release - Release a previously requested level of a resource
-+ * @name: The name of the resource to be released
-+ * @dev: Uniquely identifes the caller
-+ *
-+ * This function recomputes the target level of the resource after removing
-+ * the level requested by the user. The level of the resource is
-+ * changed to the target level, if it is not the same as the existing level
-+ * of the resource.
-+ * Returns 0 on success, -EINVAL if the resource name or dev structure
-+ * is invalid.
-+ */
-+int resource_release(const char *name, struct device *dev)
-+{
-+	struct shared_resource *resp;
-+	struct users_list *user;
-+	int found = 0, ret = 0;
-+
-+	down(&res_mutex);
-+	resp = _resource_lookup(name);
-+	if (!resp) {
-+		printk(KERN_ERR "resource_release: Invalid resource name\n");
-+		ret = -EINVAL;
-+		goto res_unlock;
-+	}
-+
-+	list_for_each_entry(user, &resp->users_list, node) {
-+		if (user->dev == dev) {
-+			found = 1;
-+			break;
-+		}
-+	}
-+
-+	if (!found) {
-+		/* No such user exists */
-+		ret = -EINVAL;
-+		goto res_unlock;
-+	}
-+
-+	resp->no_of_users--;
-+	list_del(&user->node);
-+	free_user(user);
-+
-+	/* Recompute and set the current level for the resource */
-+	ret = update_resource_level(resp);
-+res_unlock:
-+	up(&res_mutex);
-+	return ret;
-+}
-+EXPORT_SYMBOL(resource_release);
-+
-+/**
-+ * resource_get_level - Returns the current level of the resource
-+ * @name: Name of the resource
-+ *
-+ * Returns the current level of the resource if found, else returns
-+ * -EINVAL if the resource name is invalid.
-+ */
-+int resource_get_level(const char *name)
-+{
-+	struct shared_resource *resp;
-+	u32 ret;
-+
-+	down(&res_mutex);
-+	resp = _resource_lookup(name);
-+	if (!resp) {
-+		printk(KERN_ERR "resource_release: Invalid resource name\n");
-+		up(&res_mutex);
-+		return -EINVAL;
-+	}
-+	ret = resp->curr_level;
-+	up(&res_mutex);
-+	return ret;
-+}
-+EXPORT_SYMBOL(resource_get_level);
diff --git a/patches/sgx/0001-OMAP3-SGX-TI-3.01.00.06-2.6.32-PSP.patch b/patches/sgx/0001-OMAP3-SGX-TI-3.01.00.06-2.6.32-PSP.patch
new file mode 100644
index 000000000..1a69348e1
--- /dev/null
+++ b/patches/sgx/0001-OMAP3-SGX-TI-3.01.00.06-2.6.32-PSP.patch
@@ -0,0 +1,41 @@
+From 2e7cf5f1a6436466953fd8e1a6029d42de26ef31 Mon Sep 17 00:00:00 2001
+From: Robert Nelson <robertcnelson@gmail.com>
+Date: Tue, 15 Feb 2011 12:24:36 -0600
+Subject: [PATCH] OMAP3 SGX TI 3.01.00.06 2.6.32 PSP
+
+Using Koen better version from here:
+http://cgit.openembedded.org/cgit.cgi/openembedded/commit/?id=db4c0d8df9ed828e916e471753d2e041b5e69bbd
+
+Signed-off-by: Robert Nelson <robertcnelson@gmail.com>
+---
+ .../services4/system/omap3630/sysutils_linux.c     |    7 +++++++
+ 1 files changed, 7 insertions(+), 0 deletions(-)
+
+diff --git a/drivers/staging/omap3-sgx/services4/system/omap3630/sysutils_linux.c b/drivers/staging/omap3-sgx/services4/system/omap3630/sysutils_linux.c
+index 159b4da..396a95a 100644
+--- a/drivers/staging/omap3-sgx/services4/system/omap3630/sysutils_linux.c
++++ b/drivers/staging/omap3-sgx/services4/system/omap3630/sysutils_linux.c
+@@ -32,6 +32,12 @@
+ #include <asm/bug.h>
+ #include <linux/platform_device.h>
+ 
++#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,33))
++#include <linux/semaphore.h>
++#include <asm-generic/resource.h>
++#include <plat/omap-pm.h>
++#else
++
+ #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,31))
+ #include <linux/semaphore.h>
+ #include <plat/resource.h>
+@@ -49,6 +55,7 @@
+ #endif
+ #endif
+ #endif
++#endif
+ 
+ #if	(LINUX_VERSION_CODE >  KERNEL_VERSION(2,6,27)) && \
+ 	(LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,29))
+-- 
+1.7.1
+
diff --git a/patches/sgx/0001-OMAP3-SGX-TI-3.01.00.06-use-omap3630.diff b/patches/sgx/0001-OMAP3-SGX-TI-3.01.00.06-use-omap3630.diff
deleted file mode 100644
index 18164b88d..000000000
--- a/patches/sgx/0001-OMAP3-SGX-TI-3.01.00.06-use-omap3630.diff
+++ /dev/null
@@ -1,13 +0,0 @@
-diff --git a/drivers/staging/omap3-sgx/Kbuild b/drivers/staging/omap3-sgx/Kbuild
-index 73b3fb4..affc5a0 100644
---- a/drivers/staging/omap3-sgx/Kbuild
-+++ b/drivers/staging/omap3-sgx/Kbuild
-@@ -4,7 +4,7 @@
- 
- BUILD = release
- 
--TI_PLATFORM = omap3430
-+TI_PLATFORM = omap3630
- 
- SGXCORE = 530
- CORE = -DSGX530 -DSUPPORT_SGX530 -DSGX_CORE_REV=121
diff --git a/patches/sgx/0001-OMAP3-SGX-TI-3.01.00.06-use-omap3630.patch b/patches/sgx/0001-OMAP3-SGX-TI-3.01.00.06-use-omap3630.patch
new file mode 100644
index 000000000..6e3b72806
--- /dev/null
+++ b/patches/sgx/0001-OMAP3-SGX-TI-3.01.00.06-use-omap3630.patch
@@ -0,0 +1,26 @@
+From e00ed3f819d113a1d9c40e15abde93e2f1cacc9c Mon Sep 17 00:00:00 2001
+From: Robert Nelson <robertcnelson@gmail.com>
+Date: Tue, 15 Feb 2011 12:36:41 -0600
+Subject: [PATCH] OMAP3 SGX TI 3.01.00.06 use omap3630
+
+Signed-off-by: Robert Nelson <robertcnelson@gmail.com>
+---
+ drivers/staging/omap3-sgx/Kbuild |    2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/drivers/staging/omap3-sgx/Kbuild b/drivers/staging/omap3-sgx/Kbuild
+index 81fd965..1ee4fde 100644
+--- a/drivers/staging/omap3-sgx/Kbuild
++++ b/drivers/staging/omap3-sgx/Kbuild
+@@ -4,7 +4,7 @@
+ 
+ BUILD = release
+ 
+-TI_PLATFORM = omap3430
++TI_PLATFORM = omap3630
+ 
+ SGXCORE = 530
+ ifeq ($(TI_PLATFORM),ti8168)
+-- 
+1.7.1
+
diff --git a/version.sh b/version.sh
index 7e46aebe1..a819816a5 100644
--- a/version.sh
+++ b/version.sh
@@ -7,7 +7,7 @@ KERNEL_REL=2.6.37
 #PRE_RC=2.6.37-git18
 RC_KERNEL=2.6.38
 RC_PATCH=-rc4
-ABI=3
+ABI=3.1
 
 if [ "${NO_DEVTMPS}" ] ; then
 BUILD=dold${ABI}
-- 
GitLab