All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: PI mutex support on ARM
@ 2007-08-20 12:12 Manfred Gruber
  2007-08-20 12:59 ` Russell King - ARM Linux
  2007-08-20 18:59 ` Remy Bohmer
  0 siblings, 2 replies; 15+ messages in thread
From: Manfred Gruber @ 2007-08-20 12:12 UTC (permalink / raw)
  To: linux-rt-users; +Cc: l.pinguin, tglx, linux, mingo

hi !

Is about the PI Mutex issue on ARM some work going on?
Or does someone have an information for me how to implement this for a armv4 
correct ?

thanks
	fred

^ permalink raw reply	[flat|nested] 15+ messages in thread
* PI mutex support on ARM
@ 2007-07-08  8:24 Remy Bohmer
  2007-07-08  9:58 ` Ingo Molnar
  2007-07-09  7:20 ` Matthieu CASTET
  0 siblings, 2 replies; 15+ messages in thread
From: Remy Bohmer @ 2007-07-08  8:24 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: linux-kernel, Ingo Molnar, linux-rt-users

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

Hello Thomas,

I have build an implementation for the routine
futex_atomic_cmpxchg_inatomic() to make PTHREAD_PRIO_INHERIT mutex
work on ARM.
Compared to other architectures where CPU specific assembler is used,
it is probably not the most optimal implementation possible, but I
tested it successfully on a Atmel AT91RM9200 core, and it could work
on other (UP) architectures as well.

What do you think of it?
Or do you know a better solution?

Kind Regards,

Remy

[-- Attachment #2: fix-userspace-prio-inherit.patch --]
[-- Type: text/x-patch, Size: 2039 bytes --]

Index: linux-2.6.21/include/asm/futex.h
===================================================================
--- linux-2.6.21.orig/include/asm/futex.h	2007-04-26 05:08:32.000000000 +0200
+++ linux-2.6.21/include/asm/futex.h	2007-07-06 15:11:01.000000000 +0200
@@ -1,6 +1,79 @@
-#ifndef _ASM_FUTEX_H
-#define _ASM_FUTEX_H
+#ifndef _ASM_ARM_FUTEX_H
+#define _ASM_ARM_FUTEX_H
 
-#include <asm-generic/futex.h>
+#ifdef __KERNEL__
+
+#include <linux/futex.h>
+#include <asm/errno.h>
+#include <asm/uaccess.h>
+
+static inline int
+futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
+{
+	int op = (encoded_op >> 28) & 7;
+	int cmp = (encoded_op >> 24) & 15;
+	int oparg = (encoded_op << 8) >> 20;
+	int cmparg = (encoded_op << 20) >> 20;
+	int oldval = 0, ret;
+	if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28))
+		oparg = 1 << oparg;
+
+	if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int)))
+		return -EFAULT;
+
+	pagefault_disable();
+
+	switch (op) {
+	case FUTEX_OP_SET:
+	case FUTEX_OP_ADD:
+	case FUTEX_OP_OR:
+	case FUTEX_OP_ANDN:
+	case FUTEX_OP_XOR:
+	default:
+		ret = -ENOSYS;
+	}
+
+	pagefault_enable();
+
+	if (!ret) {
+		switch (cmp) {
+		case FUTEX_OP_CMP_EQ: ret = (oldval == cmparg); break;
+		case FUTEX_OP_CMP_NE: ret = (oldval != cmparg); break;
+		case FUTEX_OP_CMP_LT: ret = (oldval < cmparg); break;
+		case FUTEX_OP_CMP_GE: ret = (oldval >= cmparg); break;
+		case FUTEX_OP_CMP_LE: ret = (oldval <= cmparg); break;
+		case FUTEX_OP_CMP_GT: ret = (oldval > cmparg); break;
+		default: ret = -ENOSYS;
+		}
+	}
+	return ret;
+}
+
+static inline int
+futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval)
+{
+	int err = 0;
+	int uval;
+	unsigned long flags;
+
+	if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int)))
+		return -EFAULT;
+
+	local_irq_save(flags);
+
+	err = get_user(uval, uaddr);
+	if (err)
+	{
+		local_irq_restore(flags);
+		 return -EFAULT;
+	}
+	if (uval == oldval)
+		err = put_user(newval, uaddr);
+
+	local_irq_restore(flags);
+
+	if (err) return -EFAULT;
+	return uval;
+}
 
 #endif

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

end of thread, other threads:[~2007-09-15 20:43 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-20 12:12 PI mutex support on ARM Manfred Gruber
2007-08-20 12:59 ` Russell King - ARM Linux
2007-08-20 18:59 ` Remy Bohmer
2007-08-21  6:58   ` Manfred Gruber
2007-09-04 11:48     ` Manfred Gruber
2007-09-05 12:57       ` Remy Bohmer
2007-09-05 16:36         ` Manfred Gruber
2007-09-05 18:46           ` Remy Bohmer
2007-09-15  2:23             ` Steven Rostedt
2007-09-15 20:43               ` Remy Bohmer
  -- strict thread matches above, loose matches on Subject: below --
2007-07-08  8:24 Remy Bohmer
2007-07-08  9:58 ` Ingo Molnar
2007-07-08 20:17   ` Remy Bohmer
2007-07-09 14:46     ` Arjan van de Ven
2007-07-09  7:20 ` Matthieu CASTET

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.