[Xenomai-git] Philippe Gerum : drivers/udd: fix profile information

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: 64db3d1f97a745c99fb666c13c09eaa27e7a5e61
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=64db3d1f97a745c99fb666c13c09eaa27e7a5e61

Author: Philippe Gerum 
Date:   Sat Sep 10 16:05:35 2016 +0200

drivers/udd: fix profile information

---

 kernel/drivers/udd/udd.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/drivers/udd/udd.c b/kernel/drivers/udd/udd.c
index e14ff0b..972db12 100644
--- a/kernel/drivers/udd/udd.c
+++ b/kernel/drivers/udd/udd.c
@@ -286,7 +286,7 @@ static inline int register_mapper(struct udd_device *udd)
return -ENOMEM;
 
drv->profile_info = (struct rtdm_profile_info)
-   RTDM_PROFILE_INFO("mapper", RTDM_CLASS_MEMORY,
+   RTDM_PROFILE_INFO(mapper, RTDM_CLASS_MEMORY,
  RTDM_SUBCLASS_GENERIC, 0);
drv->device_flags = RTDM_NAMED_DEVICE|RTDM_FIXED_MINOR;
drv->device_count = UDD_NR_MAPS;


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/powerpc: fpu: drop obsolete xnarch_save_fpu()

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: 2856ff3c0c6199352fac11b4c6dab07a6e8b7b3b
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=2856ff3c0c6199352fac11b4c6dab07a6e8b7b3b

Author: Philippe Gerum 
Date:   Thu Sep  8 16:29:44 2016 +0200

cobalt/powerpc: fpu: drop obsolete xnarch_save_fpu()

---

 kernel/cobalt/arch/powerpc/include/asm/xenomai/thread.h |2 --
 kernel/cobalt/arch/powerpc/thread.c |6 +++---
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/kernel/cobalt/arch/powerpc/include/asm/xenomai/thread.h 
b/kernel/cobalt/arch/powerpc/include/asm/xenomai/thread.h
index 8d6be84..1de5cac 100644
--- a/kernel/cobalt/arch/powerpc/include/asm/xenomai/thread.h
+++ b/kernel/cobalt/arch/powerpc/include/asm/xenomai/thread.h
@@ -93,8 +93,6 @@ static inline int xnarch_escalate(void)
 
 void xnarch_switch_to(struct xnthread *out, struct xnthread *in);
 
-void xnarch_save_fpu(struct xnthread *thread);
-
 void xnarch_switch_fpu(struct xnthread *from, struct xnthread *thread);
 
 #endif /* !_COBALT_POWERPC_ASM_THREAD_H */
diff --git a/kernel/cobalt/arch/powerpc/thread.c 
b/kernel/cobalt/arch/powerpc/thread.c
index 2a61d50..e3be67f 100644
--- a/kernel/cobalt/arch/powerpc/thread.c
+++ b/kernel/cobalt/arch/powerpc/thread.c
@@ -92,7 +92,7 @@ static void xnarch_enable_fpu(struct xnthread *thread)
__asm_enable_fpu();
 }
 
-void xnarch_save_fpu(struct xnthread *thread)
+static void do_save_fpu(struct xnthread *thread)
 {
struct xnarchtcb *tcb = xnthread_archtcb(thread);
 
@@ -145,7 +145,7 @@ void xnarch_switch_fpu(struct xnthread *from, struct 
xnthread *to)
}

if (from)
-   xnarch_save_fpu(from);
+   do_save_fpu(from);

xnarch_restore_fpu(to);
 }
@@ -154,7 +154,7 @@ void xnarch_leave_root(struct xnthread *root)
 {
struct xnarchtcb *rootcb = xnthread_archtcb(root);
rootcb->core.user_fpu_owner = get_fpu_owner(rootcb->core.host_task);
-   /* So that xnarch_save_fpu() will operate on the right FPU area. */
+   /* So that do_save_fpu() operates on the right FPU area. */
rootcb->fpup = rootcb->core.user_fpu_owner ?
>core.user_fpu_owner->thread : NULL;
 }


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : drivers/gpio: serialize access to per-chip pin list

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: 1fbc7013634d51d807ef950d9059e911dd0fc578
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=1fbc7013634d51d807ef950d9059e911dd0fc578

Author: Philippe Gerum 
Date:   Fri Jun 17 16:12:27 2016 +0200

drivers/gpio: serialize access to per-chip pin list

---

 kernel/drivers/gpio/gpio-core.c |9 +
 kernel/drivers/gpio/gpio-core.h |1 +
 2 files changed, 10 insertions(+)

diff --git a/kernel/drivers/gpio/gpio-core.c b/kernel/drivers/gpio/gpio-core.c
index 4f707b8..319d5c7 100644
--- a/kernel/drivers/gpio/gpio-core.c
+++ b/kernel/drivers/gpio/gpio-core.c
@@ -175,15 +175,21 @@ static void delete_pin_devices(struct rtdm_gpio_chip *rgc)
struct rtdm_gpio_pin *pin, *n;
struct rtdm_device *dev;
 
+   rtdm_lock_get(>lock);
+   
list_for_each_entry_safe(pin, n, >pins, next) {
list_del(>next);
+   rtdm_lock_put(>lock);
dev = >dev;
rtdm_dev_unregister(dev);
rtdm_event_destroy(>event);
kfree(dev->label);
kfree(pin->name);
kfree(pin);
+   rtdm_lock_get(>lock);
}
+
+   rtdm_lock_put(>lock);
 }
 
 static int create_pin_devices(struct rtdm_gpio_chip *rgc)
@@ -217,7 +223,9 @@ static int create_pin_devices(struct rtdm_gpio_chip *rgc)
if (ret)
goto fail_register;
rtdm_event_init(>event, 0);
+   rtdm_lock_get(>lock);
list_add_tail(>next, >pins);
+   rtdm_lock_put(>lock);
}
 
return 0;
@@ -277,6 +285,7 @@ int rtdm_gpiochip_add(struct rtdm_gpio_chip *rgc,
 
rgc->gc = gc;
INIT_LIST_HEAD(>pins);
+   rtdm_lock_init(>lock);
 
ret = create_pin_devices(rgc);
if (ret)
diff --git a/kernel/drivers/gpio/gpio-core.h b/kernel/drivers/gpio/gpio-core.h
index 3fa7867..d4dd28a 100644
--- a/kernel/drivers/gpio/gpio-core.h
+++ b/kernel/drivers/gpio/gpio-core.h
@@ -31,6 +31,7 @@ struct rtdm_gpio_chip {
struct class *devclass;
struct list_head pins;
struct list_head next;
+   rtdm_lock_t lock;
 };
 
 int rtdm_gpiochip_add(struct rtdm_gpio_chip *rgc,


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : testsuite/spitest: add SPI test suite

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: dca68e639bc42d8b453932cd3893932372a6ab7f
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=dca68e639bc42d8b453932cd3893932372a6ab7f

Author: Philippe Gerum 
Date:   Sat Jun 25 18:55:14 2016 +0200

testsuite/spitest: add SPI test suite

---

 configure.ac  |1 +
 testsuite/Makefile.am |2 +
 testsuite/gpiotest/gpiotest.c |   31 +--
 testsuite/spitest/Makefile.am |   19 ++
 testsuite/spitest/spitest.c   |  451 +
 5 files changed, 491 insertions(+), 13 deletions(-)

diff --git a/configure.ac b/configure.ac
index 40fff80..aa3ce36 100644
--- a/configure.ac
+++ b/configure.ac
@@ -879,6 +879,7 @@ AC_CONFIG_FILES([ \
testsuite/latency/Makefile \
testsuite/switchtest/Makefile \
testsuite/gpiotest/Makefile \
+   testsuite/spitest/Makefile \
testsuite/smokey/Makefile \
testsuite/smokey/arith/Makefile \
testsuite/smokey/sched-quota/Makefile \
diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am
index c345472..76d108e 100644
--- a/testsuite/Makefile.am
+++ b/testsuite/Makefile.am
@@ -5,6 +5,7 @@ if XENO_COBALT
 SUBDIRS += \
clocktest   \
gpiotest\
+   spitest \
switchtest  \
xeno-test
 endif
@@ -14,5 +15,6 @@ DIST_SUBDIRS =\
gpiotest\
latency \
smokey  \
+   spitest \
switchtest  \
xeno-test
diff --git a/testsuite/gpiotest/gpiotest.c b/testsuite/gpiotest/gpiotest.c
index 65949ee..0bdd39f 100644
--- a/testsuite/gpiotest/gpiotest.c
+++ b/testsuite/gpiotest/gpiotest.c
@@ -1,19 +1,24 @@
 /*
- * Copyright (C) 2016 Philippe Gerum .
+ * Copyright (C) 2016 Philippe Gerum 
  *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
  *
- * This program is distributed in the hope that 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.
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *  
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 #include 
 #include 
diff --git a/testsuite/spitest/Makefile.am b/testsuite/spitest/Makefile.am
new file mode 100644
index 000..ccdd392
--- /dev/null
+++ b/testsuite/spitest/Makefile.am
@@ -0,0 +1,19 @@
+testdir = @XENO_TEST_DIR@
+
+CCLD = $(top_srcdir)/scripts/wrap-link.sh $(CC)
+
+test_PROGRAMS = spitest
+
+spitest_SOURCES = spitest.c
+
+spitest_CPPFLAGS = \
+   $(XENO_USER_CFLAGS) \
+   -I$(top_srcdir)/include
+
+spitest_LDFLAGS = @XENO_AUTOINIT_LDFLAGS@ $(XENO_POSIX_WRAPPERS)
+
+spitest_LDADD =\
+   ../../lib/smokey/libsmokey.la   \
+   ../../lib/@XENO_CORE_LIB@   \
+@XENO_USER_LDADD@  \
+   -lpthread -lrt
diff --git a/testsuite/spitest/spitest.c b/testsuite/spitest/spitest.c
new file mode 100644
index 000..0609bad
--- /dev/null
+++ b/testsuite/spitest/spitest.c
@@ -0,0 +1,451 @@
+/*
+ * Copyright (C) 2016 Philippe Gerum 
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of 

[Xenomai-git] Philippe Gerum : drivers/spi: introduce iobufs.map_len to expose the mapping length

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: 0090acdc5a95d76247904d82c56b1544c04140cc
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=0090acdc5a95d76247904d82c56b1544c04140cc

Author: Philippe Gerum 
Date:   Tue Jun 28 10:41:33 2016 +0200

drivers/spi: introduce iobufs.map_len to expose the mapping length

Overwriting iobufs.io_len for returning the length of the user-space
mapping makes no sense, since both values have different meanings
(DMA_ALIGNED(io_len) * 2 == map_len).

---

 include/rtdm/uapi/spi.h  |1 +
 kernel/drivers/spi/spi-bcm2835.c |2 +-
 testsuite/spitest/spitest.c  |4 ++--
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/include/rtdm/uapi/spi.h b/include/rtdm/uapi/spi.h
index 45bc92d..8f04237 100644
--- a/include/rtdm/uapi/spi.h
+++ b/include/rtdm/uapi/spi.h
@@ -30,6 +30,7 @@ struct rtdm_spi_iobufs {
__u32 io_len;
__u32 i_offset;
__u32 o_offset;
+   __u32 map_len;
 };
 
 #define SPI_RTIOC_SET_CONFIG   _IOW(RTDM_CLASS_SPI, 0, struct 
rtdm_spi_config)
diff --git a/kernel/drivers/spi/spi-bcm2835.c b/kernel/drivers/spi/spi-bcm2835.c
index 02ebecd..118cfd5 100644
--- a/kernel/drivers/spi/spi-bcm2835.c
+++ b/kernel/drivers/spi/spi-bcm2835.c
@@ -409,7 +409,7 @@ static int bcm2835_set_iobufs(struct rtdm_spi_remote_slave 
*slave,
 
p->i_offset = 0;
p->o_offset = bcm->io_len / 2;
-   p->io_len = bcm->io_len;
+   p->map_len = bcm->io_len;

return 0;
 }
diff --git a/testsuite/spitest/spitest.c b/testsuite/spitest/spitest.c
index 0609bad..40ef9a9 100644
--- a/testsuite/spitest/spitest.c
+++ b/testsuite/spitest/spitest.c
@@ -385,14 +385,14 @@ static int run_spi_transfer(struct smokey_test *t, int 
argc, char *const argv[])
if (!__T(ret, ioctl(fd, SPI_RTIOC_SET_IOBUFS, )))
return ret;
 
-   p = mmap(NULL, iobufs.io_len, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
+   p = mmap(NULL, iobufs.map_len, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
if (!__Fassert(p == MAP_FAILED))
return -EINVAL;

smokey_trace("input_area[%u..%u], output_area[%u..%u], mapping 
length=%u",
 iobufs.i_offset, iobufs.i_offset + TRANSFER_SIZE - 1,
 iobufs.o_offset, iobufs.o_offset + TRANSFER_SIZE - 1,
-iobufs.io_len);
+iobufs.map_len);

i_area = p + iobufs.i_offset;
o_area = p + iobufs.o_offset;


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : drivers/gpio: allow setting trigger type w/ GPIO_RTIOC_IRQEN

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: 782624eb3a4b9f225174b121e75607a5c6e868ab
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=782624eb3a4b9f225174b121e75607a5c6e868ab

Author: Philippe Gerum 
Date:   Tue Jun 28 12:16:02 2016 +0200

drivers/gpio: allow setting trigger type w/ GPIO_RTIOC_IRQEN

---

 include/rtdm/uapi/gpio.h|9 -
 kernel/drivers/gpio/gpio-core.c |   31 +++
 testsuite/gpiotest/gpiotest.c   |   34 +++---
 3 files changed, 66 insertions(+), 8 deletions(-)

diff --git a/include/rtdm/uapi/gpio.h b/include/rtdm/uapi/gpio.h
index b0d4899..307e190 100644
--- a/include/rtdm/uapi/gpio.h
+++ b/include/rtdm/uapi/gpio.h
@@ -22,7 +22,14 @@
 
 #define GPIO_RTIOC_DIR_OUT _IOW(RTDM_CLASS_GPIO, 0, int)
 #define GPIO_RTIOC_DIR_IN  _IO(RTDM_CLASS_GPIO, 1)
-#define GPIO_RTIOC_IRQEN   _IO(RTDM_CLASS_GPIO, 2)
+#define GPIO_RTIOC_IRQEN   _IOW(RTDM_CLASS_GPIO, 2, int) /* GPIO 
trigger */
 #define GPIO_RTIOC_IRQDIS  _IO(RTDM_CLASS_GPIO, 3)
 
+#define GPIO_TRIGGER_NONE  0x0 /* unspecified */
+#define GPIO_TRIGGER_EDGE_RISING   0x1
+#define GPIO_TRIGGER_EDGE_FALLING  0x2
+#define GPIO_TRIGGER_LEVEL_HIGH0x4
+#define GPIO_TRIGGER_LEVEL_LOW 0x8
+#define GPIO_TRIGGER_MASK  0xf
+
 #endif /* !_RTDM_UAPI_GPIO_H */
diff --git a/kernel/drivers/gpio/gpio-core.c b/kernel/drivers/gpio/gpio-core.c
index e8a7ba1..6c1f351 100644
--- a/kernel/drivers/gpio/gpio-core.c
+++ b/kernel/drivers/gpio/gpio-core.c
@@ -44,10 +44,20 @@ static int gpio_pin_interrupt(rtdm_irq_t *irqh)
return RTDM_IRQ_HANDLED;
 }
 
-static int request_gpio_irq(unsigned int gpio, struct rtdm_gpio_pin *pin)
+static int request_gpio_irq(unsigned int gpio, struct rtdm_gpio_pin *pin,
+   int trigger)
 {
+   static const int trigger_flags[] = {
+   IRQ_TYPE_EDGE_RISING,
+   IRQ_TYPE_EDGE_FALLING,
+   IRQ_TYPE_LEVEL_HIGH,
+   IRQ_TYPE_LEVEL_LOW,
+   };
+   int irq_trigger, ret;
unsigned int irq;
-   int ret;
+
+   if (trigger & ~GPIO_TRIGGER_MASK)
+   return -EINVAL;
 
ret = gpio_request(gpio, pin->name);
if (ret) {
@@ -66,6 +76,15 @@ static int request_gpio_irq(unsigned int gpio, struct 
rtdm_gpio_pin *pin)
 
rtdm_event_clear(>event);
irq = gpio_to_irq(gpio);
+   /*
+* Assumes GPIO_TRIGGER_xx values are forming a continuous
+* sequence of bits starting at bit #0.
+*/
+   if (trigger) {
+   irq_trigger = trigger_flags[ffs(trigger) - 1];
+   irq_set_irq_type(irq, irq_trigger);
+   }
+   
ret = rtdm_irq_request(>irqh, irq, gpio_pin_interrupt,
   0, pin->name, pin);
if (ret) {
@@ -93,8 +112,8 @@ static int gpio_pin_ioctl_nrt(struct rtdm_fd *fd,
 {
struct rtdm_device *dev = rtdm_fd_device(fd);
unsigned int gpio = rtdm_fd_minor(fd);
+   int ret = 0, val, trigger;
struct rtdm_gpio_pin *pin;
-   int ret = 0, val;

pin = container_of(dev, struct rtdm_gpio_pin, dev);
 
@@ -109,7 +128,11 @@ static int gpio_pin_ioctl_nrt(struct rtdm_fd *fd,
ret = gpio_direction_input(gpio);
break;
case GPIO_RTIOC_IRQEN:
-   ret = request_gpio_irq(gpio, pin);
+   ret = rtdm_safe_copy_from_user(fd, ,
+  arg, sizeof(trigger));
+   if (ret)
+   return ret;
+   ret = request_gpio_irq(gpio, pin, trigger);
break;
case GPIO_RTIOC_IRQDIS:
release_gpio_irq(gpio, pin);
diff --git a/testsuite/gpiotest/gpiotest.c b/testsuite/gpiotest/gpiotest.c
index 0bdd39f..6e9ce5b 100644
--- a/testsuite/gpiotest/gpiotest.c
+++ b/testsuite/gpiotest/gpiotest.c
@@ -55,8 +55,21 @@ smokey_test_plugin(write_value,
 
 static int run_interrupt(struct smokey_test *t, int argc, char *const argv[])
 {
-   const char *device = NULL;
-   int fd, ret;
+   static struct {
+   const char *name;
+   int flag;
+   } trigger_types[] = {
+   { .name = "edge", .flag = GPIO_TRIGGER_EDGE_RISING },
+   { .name = "edge-rising", .flag = GPIO_TRIGGER_EDGE_RISING },
+   { .name = "edge-falling", .flag = GPIO_TRIGGER_EDGE_FALLING },
+   { .name = "edge-both", .flag = 
GPIO_TRIGGER_EDGE_FALLING|GPIO_TRIGGER_EDGE_RISING },
+   { .name = "level", .flag = GPIO_TRIGGER_LEVEL_LOW },
+   { .name = "level-low", .flag = GPIO_TRIGGER_LEVEL_LOW },
+   { .name = "level-high", .flag = GPIO_TRIGGER_LEVEL_HIGH },
+   { NULL, 0 },
+   };
+   const char *device = NULL, *trigname;
+   int fd, ret, trigger, n;

[Xenomai-git] Philippe Gerum : drivers/spi: bcm2835: drop unused variables

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: 48c345abe2d4e189c3acbb1d3e9e8a17a00ed56f
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=48c345abe2d4e189c3acbb1d3e9e8a17a00ed56f

Author: Philippe Gerum 
Date:   Thu Sep 29 15:25:57 2016 +0200

drivers/spi: bcm2835: drop unused variables

---

 kernel/drivers/spi/spi-bcm2835.c |2 --
 1 file changed, 2 deletions(-)

diff --git a/kernel/drivers/spi/spi-bcm2835.c b/kernel/drivers/spi/spi-bcm2835.c
index da44bf7..e4a95d0 100644
--- a/kernel/drivers/spi/spi-bcm2835.c
+++ b/kernel/drivers/spi/spi-bcm2835.c
@@ -322,7 +322,6 @@ static ssize_t bcm2835_read(struct rtdm_spi_remote_slave 
*slave,
void *rx, size_t len)
 {
struct spi_master_bcm2835 *spim = to_master_bcm2835(slave);
-   struct spi_slave_bcm2835 *bcm = to_slave_bcm2835(slave);
 
spim->tx_len = len;
spim->rx_len = len;
@@ -336,7 +335,6 @@ static ssize_t bcm2835_write(struct rtdm_spi_remote_slave 
*slave,
 const void *tx, size_t len)
 {
struct spi_master_bcm2835 *spim = to_master_bcm2835(slave);
-   struct spi_slave_bcm2835 *bcm = to_slave_bcm2835(slave);
 
spim->tx_len = len;
spim->rx_len = len;


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : testsuite/gpio: add interrupt trigger argument

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: 289ed8676ff9a135da29f7b5ae8c75e8cc5c1ae7
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=289ed8676ff9a135da29f7b5ae8c75e8cc5c1ae7

Author: Philippe Gerum 
Date:   Tue Jul 12 10:03:48 2016 +0200

testsuite/gpio: add interrupt trigger argument

---

 testsuite/gpiotest/gpiotest.c |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/testsuite/gpiotest/gpiotest.c b/testsuite/gpiotest/gpiotest.c
index aeb16af..c6620e1 100644
--- a/testsuite/gpiotest/gpiotest.c
+++ b/testsuite/gpiotest/gpiotest.c
@@ -32,10 +32,13 @@
 smokey_test_plugin(interrupt,
   SMOKEY_ARGLIST(
   SMOKEY_STRING(device),
+  SMOKEY_STRING(trigger),
   SMOKEY_BOOL(select),
   ),
"Wait for interrupts from a GPIO pin.\n"
-   "\tdevice=."
+   "\tdevice=\n"
+   "\trigger={edge[-rising/falling/both], level[-low/high]}\n"
+   "\tselect, wait on select(2)."
 );
 
 smokey_test_plugin(read_value,


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : testsuite/gpio: fix output value set with direction

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: 182a4d989db8b1d1e1d71ec2baccfd21b2bd3680
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=182a4d989db8b1d1e1d71ec2baccfd21b2bd3680

Author: Philippe Gerum 
Date:   Tue Jul 12 10:03:48 2016 +0200

testsuite/gpio: fix output value set with direction

---

 testsuite/gpiotest/gpiotest.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/testsuite/gpiotest/gpiotest.c b/testsuite/gpiotest/gpiotest.c
index c6620e1..a845ef5 100644
--- a/testsuite/gpiotest/gpiotest.c
+++ b/testsuite/gpiotest/gpiotest.c
@@ -202,7 +202,8 @@ static int run_write_value(struct smokey_test *t, int argc, 
char *const argv[])
return ret;
}
 
-   if (!__T(ret, ioctl(fd, GPIO_RTIOC_DIR_OUT)))
+   value = 1;
+   if (!__T(ret, ioctl(fd, GPIO_RTIOC_DIR_OUT, )))
return ret;

ret = write(fd, , sizeof(value));


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : drivers/gpio: fix enumeration/detection of controllers

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: b4afc3ed63caaac49881c2be4a9f150ca182e735
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=b4afc3ed63caaac49881c2be4a9f150ca182e735

Author: Philippe Gerum 
Date:   Thu Sep 29 15:22:24 2016 +0200

drivers/gpio: fix enumeration/detection of controllers

---

 kernel/drivers/gpio/Kconfig|   18 +
 kernel/drivers/gpio/gpio-bcm2835.c |   12 +++---
 kernel/drivers/gpio/gpio-core.c|   71 +++-
 kernel/drivers/gpio/gpio-core.h|   10 -
 kernel/drivers/gpio/gpio-mxc.c |   39 ++--
 5 files changed, 89 insertions(+), 61 deletions(-)

diff --git a/kernel/drivers/gpio/Kconfig b/kernel/drivers/gpio/Kconfig
index 850127f..74c56d4 100644
--- a/kernel/drivers/gpio/Kconfig
+++ b/kernel/drivers/gpio/Kconfig
@@ -1,13 +1,17 @@
 menu "Real-time GPIO drivers"
 
 config XENO_DRIVERS_GPIO
-   tristate
+   tristate "GPIO controller"
depends on GPIOLIB
+   help
+
+   Real-time capable GPIO module.
+  
+if XENO_DRIVERS_GPIO
 
 config XENO_DRIVERS_GPIO_BCM2835
depends on MACH_BCM2708
-   select XENO_DRIVERS_GPIO
-   tristate "Support for BCM2835 GPIOs"
+   bool "Support for BCM2835 GPIOs"
help
 
Enables support for the GPIO controller available from
@@ -15,15 +19,15 @@ config XENO_DRIVERS_GPIO_BCM2835
 
 config XENO_DRIVERS_GPIO_MXC
depends on GPIO_MXC
-   select XENO_DRIVERS_GPIO
-   tristate "Support for MXC GPIOs"
+   bool "Support for MXC GPIOs"
help
 
Suitable for the GPIO controller available from
Freescale/NXP's MXC architecture.
 
 config XENO_DRIVERS_GPIO_DEBUG
-   depends on XENO_DRIVERS_GPIO
bool "Enable GPIO core debugging features"
-   
+
+endif
+
 endmenu
diff --git a/kernel/drivers/gpio/gpio-bcm2835.c 
b/kernel/drivers/gpio/gpio-bcm2835.c
index f277262..6328955 100644
--- a/kernel/drivers/gpio/gpio-bcm2835.c
+++ b/kernel/drivers/gpio/gpio-bcm2835.c
@@ -20,20 +20,18 @@
 
 #define RTDM_SUBCLASS_BCM2835  1
 
-static struct rtdm_gpio_chip bcm2835_gpio_chip;
-
 static int __init bcm2835_gpio_init(void)
 {
-   return rtdm_gpiochip_add_by_name(_gpio_chip, "bcm2708_gpio",
-RTDM_SUBCLASS_BCM2835);
+   return rtdm_gpiochip_scan_of(NULL, "brcm,bcm2835-gpio",
+RTDM_SUBCLASS_BCM2835);
 }
+module_init(bcm2835_gpio_init);
 
 static void __exit bcm2835_gpio_exit(void)
 {
-   rtdm_gpiochip_remove(_gpio_chip);
+   rtdm_gpiochip_remove_of(RTDM_SUBCLASS_BCM2835);
 }
-
-module_init(bcm2835_gpio_init);
 module_exit(bcm2835_gpio_exit);
 
 MODULE_LICENSE("GPL");
+
diff --git a/kernel/drivers/gpio/gpio-core.c b/kernel/drivers/gpio/gpio-core.c
index f18d571..5c08355 100644
--- a/kernel/drivers/gpio/gpio-core.c
+++ b/kernel/drivers/gpio/gpio-core.c
@@ -203,22 +203,23 @@ static void delete_pin_devices(struct rtdm_gpio_chip *rgc)
 {
struct rtdm_gpio_pin *pin, *n;
struct rtdm_device *dev;
+   rtdm_lockctx_t s;
 
-   rtdm_lock_get(>lock);
+   rtdm_lock_get_irqsave(>lock, s);

list_for_each_entry_safe(pin, n, >pins, next) {
list_del(>next);
-   rtdm_lock_put(>lock);
+   rtdm_lock_put_irqrestore(>lock, s);
dev = >dev;
rtdm_dev_unregister(dev);
rtdm_event_destroy(>event);
kfree(dev->label);
kfree(pin->name);
kfree(pin);
-   rtdm_lock_get(>lock);
+   rtdm_lock_get_irqsave(>lock, s);
}
 
-   rtdm_lock_put(>lock);
+   rtdm_lock_put_irqrestore(>lock, s);
 }
 
 static int create_pin_devices(struct rtdm_gpio_chip *rgc)
@@ -226,6 +227,7 @@ static int create_pin_devices(struct rtdm_gpio_chip *rgc)
struct gpio_chip *gc = rgc->gc;
struct rtdm_gpio_pin *pin;
struct rtdm_device *dev;
+   rtdm_lockctx_t s;
int n, ret;
 
for (n = gc->base; n < gc->base + gc->ngpio - 1; n++) {
@@ -252,9 +254,9 @@ static int create_pin_devices(struct rtdm_gpio_chip *rgc)
if (ret)
goto fail_register;
rtdm_event_init(>event, 0);
-   rtdm_lock_get(>lock);
+   rtdm_lock_get_irqsave(>lock, s);
list_add_tail(>next, >pins);
-   rtdm_lock_put(>lock);
+   rtdm_lock_put_irqrestore(>lock, s);
}
 
return 0;
@@ -362,8 +364,41 @@ EXPORT_SYMBOL_GPL(rtdm_gpiochip_add_by_name);
 
 #include 
 
+LIST_HEAD(rtdm_gpio_chips);
+
+static DEFINE_MUTEX(chip_lock);
+
+static int match_gpio_chip(struct gpio_chip *gc, void *data)
+{
+   struct device *dev = data;
+
+   return gc->dev == dev;
+}
+
+static int add_gpio_chip(struct gpio_chip *gc, int type)
+{
+   struct rtdm_gpio_chip *rgc;
+   int ret;
+
+   rgc = kzalloc(sizeof(*rgc), 

[Xenomai-git] Philippe Gerum : testsuite/gpio: illustrate select() + read() combination

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: 47a8001c4727dd181668951204cf7e23a1bc6aec
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=47a8001c4727dd181668951204cf7e23a1bc6aec

Author: Philippe Gerum 
Date:   Tue Jul 12 10:03:48 2016 +0200

testsuite/gpio: illustrate select() + read() combination

---

 testsuite/gpiotest/gpiotest.c |   24 +++-
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/testsuite/gpiotest/gpiotest.c b/testsuite/gpiotest/gpiotest.c
index 6e9ce5b..aeb16af 100644
--- a/testsuite/gpiotest/gpiotest.c
+++ b/testsuite/gpiotest/gpiotest.c
@@ -32,6 +32,7 @@
 smokey_test_plugin(interrupt,
   SMOKEY_ARGLIST(
   SMOKEY_STRING(device),
+  SMOKEY_BOOL(select),
   ),
"Wait for interrupts from a GPIO pin.\n"
"\tdevice=."
@@ -68,8 +69,8 @@ static int run_interrupt(struct smokey_test *t, int argc, 
char *const argv[])
{ .name = "level-high", .flag = GPIO_TRIGGER_LEVEL_HIGH },
{ NULL, 0 },
};
+   int do_select = 0, fd, ret, trigger, n, value;
const char *device = NULL, *trigname;
-   int fd, ret, trigger, n;
fd_set set;

smokey_parse_args(t, argc, argv);
@@ -88,6 +89,9 @@ static int run_interrupt(struct smokey_test *t, int argc, 
char *const argv[])
return ret;
}
 
+   if (SMOKEY_ARG_ISSET(interrupt, select))
+   do_select = SMOKEY_ARG_BOOL(interrupt, select);
+
trigger = GPIO_TRIGGER_NONE;
if (SMOKEY_ARG_ISSET(interrupt, trigger)) {
trigname = SMOKEY_ARG_STRING(interrupt, trigger);
@@ -115,13 +119,23 @@ static int run_interrupt(struct smokey_test *t, int argc, 
char *const argv[])
FD_SET(fd, );

for (;;) {
-   ret = select(fd + 1, , NULL, NULL, NULL);
+   if (do_select) {
+   ret = select(fd + 1, , NULL, NULL, NULL);
+   if (ret < 0) {
+   ret = -errno;
+   warning("failed listening to %s [%s]",
+   device, symerror(ret));
+   return ret;
+   }
+   }
+   ret = read(fd, , sizeof(value));
if (ret < 0) {
ret = -errno;
-   warning("failed listening to %s [%s]",
+   warning("failed reading from %s [%s]",
device, symerror(ret));
+   return ret;
}
-   printf("kick %d!\n", ret);
+   printf("received irq, GPIO state=%d\n", value);
}
 
close(fd);
@@ -142,7 +156,7 @@ static int run_read_value(struct smokey_test *t, int argc, 
char *const argv[])
}
 
device = SMOKEY_ARG_STRING(read_value, device);
-   fd = open(device, O_RDONLY);
+   fd = open(device, O_RDONLY|O_NONBLOCK);
if (fd < 0) {
ret = -errno;
warning("cannot open device %s [%s]",


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : drivers/gpio: bcm2835: look up for the right chip label

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: cc1a1d7dda59da126493190a3d77d99a27dfac79
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=cc1a1d7dda59da126493190a3d77d99a27dfac79

Author: Philippe Gerum 
Date:   Sun Jul 10 12:02:04 2016 +0200

drivers/gpio: bcm2835: look up for the right chip label

---

 kernel/drivers/gpio/gpio-bcm2835.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/drivers/gpio/gpio-bcm2835.c 
b/kernel/drivers/gpio/gpio-bcm2835.c
index 772298b..f277262 100644
--- a/kernel/drivers/gpio/gpio-bcm2835.c
+++ b/kernel/drivers/gpio/gpio-bcm2835.c
@@ -24,7 +24,7 @@ static struct rtdm_gpio_chip bcm2835_gpio_chip;
 
 static int __init bcm2835_gpio_init(void)
 {
-   return rtdm_gpiochip_add_by_name(_gpio_chip, "bcm2835_gpio",
+   return rtdm_gpiochip_add_by_name(_gpio_chip, "bcm2708_gpio",
 RTDM_SUBCLASS_BCM2835);
 }
 


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : drivers/spi: enable GPIO-based chip select

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: a220f522106c1c086908445f06992663f6bd5a64
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=a220f522106c1c086908445f06992663f6bd5a64

Author: Philippe Gerum 
Date:   Tue Jun 28 09:58:10 2016 +0200

drivers/spi: enable GPIO-based chip select

---

 kernel/drivers/spi/spi-device.c |   38 +-
 kernel/drivers/spi/spi-device.h |1 +
 kernel/drivers/spi/spi-master.c |   18 --
 3 files changed, 38 insertions(+), 19 deletions(-)

diff --git a/kernel/drivers/spi/spi-device.c b/kernel/drivers/spi/spi-device.c
index 62482b2..08cf9b0 100644
--- a/kernel/drivers/spi/spi-device.c
+++ b/kernel/drivers/spi/spi-device.c
@@ -43,22 +43,14 @@ int rtdm_spi_add_remote_slave(struct rtdm_spi_remote_slave 
*slave,
slave->config.speed_hz = spi->max_speed_hz;
slave->config.mode = spi->mode;
slave->master = master;
-   mutex_init(>ctl_lock);

dev = >dev;
dev->driver = >driver;
dev->label = kasprintf(GFP_KERNEL, "%s/slave%d.%%d",
   dev_name(>dev),
   kmaster->bus_num);
-   if (dev->label == NULL) {
-   ret = -ENOMEM;
-   goto fail_label;
-   }
-
-   dev->device_data = master;
-   ret = rtdm_dev_register(dev);
-   if (ret)
-   goto fail_register;
+   if (dev->label == NULL)
+   return -ENOMEM;
 
if (gpio_is_valid(spi->cs_gpio))
slave->cs_gpio = spi->cs_gpio;
@@ -68,21 +60,30 @@ int rtdm_spi_add_remote_slave(struct rtdm_spi_remote_slave 
*slave,
slave->cs_gpio = kmaster->cs_gpios[spi->chip_select];
}
 
-   if (gpio_is_valid(slave->cs_gpio))
-   dev_dbg(slave_to_kdev(slave), "using CS GPIO%d\n",
-   slave->cs_gpio);
+   if (gpio_is_valid(slave->cs_gpio)) {
+   ret = gpio_request(slave->cs_gpio, dev->label);
+   if (ret)
+   goto fail;
+   slave->cs_gpiod = gpio_to_desc(slave->cs_gpio);
+   if (slave->cs_gpiod == NULL)
+   goto fail;
+   }
+   
+   mutex_init(>ctl_lock);
+
+   dev->device_data = master;
+   ret = rtdm_dev_register(dev);
+   if (ret)
+   goto fail;
 
rtdm_lock_get_irqsave(>lock, c);
list_add_tail(>next, >slaves);
rtdm_lock_put_irqrestore(>lock, c);
 
return 0;
-
-fail_register:
+fail:
kfree(dev->label);
 
-fail_label:
-
return ret;
 }
 EXPORT_SYMBOL_GPL(rtdm_spi_add_remote_slave);
@@ -93,6 +94,9 @@ void rtdm_spi_remove_remote_slave(struct 
rtdm_spi_remote_slave *slave)
struct rtdm_device *dev;
rtdm_lockctx_t c;

+   if (gpio_is_valid(slave->cs_gpio))
+   gpio_free(slave->cs_gpio);
+
mutex_destroy(>ctl_lock);
rtdm_lock_get_irqsave(>lock, c);
list_del(>next);
diff --git a/kernel/drivers/spi/spi-device.h b/kernel/drivers/spi/spi-device.h
index fcfca90..ee43c38 100644
--- a/kernel/drivers/spi/spi-device.h
+++ b/kernel/drivers/spi/spi-device.h
@@ -30,6 +30,7 @@ struct rtdm_spi_master;
 struct rtdm_spi_remote_slave {
u8 chip_select;
int cs_gpio;
+   struct gpio_desc *cs_gpiod;
struct rtdm_device dev;
struct list_head next;
struct rtdm_spi_config config;
diff --git a/kernel/drivers/spi/spi-master.c b/kernel/drivers/spi/spi-master.c
index 132a3b9..fe2ee40 100644
--- a/kernel/drivers/spi/spi-master.c
+++ b/kernel/drivers/spi/spi-master.c
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "spi-master.h"
 
 static inline
@@ -105,6 +106,7 @@ static int do_chip_select(struct rtdm_spi_remote_slave 
*slave)
 {  /* master->bus_lock held */
struct rtdm_spi_master *master = slave->master;
rtdm_lockctx_t c;
+   int state;
 
if (slave->config.speed_hz == 0)
return -EINVAL; /* Setup is missing. */
@@ -113,7 +115,11 @@ static int do_chip_select(struct rtdm_spi_remote_slave 
*slave)
rtdm_lock_get_irqsave(>lock, c);

if (master->cs != slave) {
-   master->ops->chip_select(slave, true);
+   if (gpio_is_valid(slave->cs_gpio)) {
+   state = !!(slave->config.mode & SPI_CS_HIGH);
+   gpiod_set_raw_value(slave->cs_gpiod, state);
+   } else
+   master->ops->chip_select(slave, true);
master->cs = slave;
}
 
@@ -126,10 +132,18 @@ static void do_chip_deselect(struct rtdm_spi_remote_slave 
*slave)
 {  /* master->bus_lock held */
struct rtdm_spi_master *master = slave->master;
rtdm_lockctx_t c;
+   int state;
 
rtdm_lock_get_irqsave(>lock, c);
-   master->ops->chip_select(slave, false);

[Xenomai-git] Philippe Gerum : scripts/xeno-config: do not wrap main() with --auto-init-solib

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: 91f7a0c72e20e0eb5df56dfc44d410b4cff0c99c
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=91f7a0c72e20e0eb5df56dfc44d410b4cff0c99c

Author: Philippe Gerum 
Date:   Thu Sep 22 10:13:52 2016 +0200

scripts/xeno-config: do not wrap main() with --auto-init-solib

For the auto-init feature to make sense, the main() symbol has to be
defined in the main executable, so there is no need to wrap it when
emitting linker flags for an auto-boostrapped shared library.

---

 scripts/xeno-config-cobalt.in  |   10 +++---
 scripts/xeno-config-mercury.in |   10 +++---
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/scripts/xeno-config-cobalt.in b/scripts/xeno-config-cobalt.in
index 38f8208..802b778 100644
--- a/scripts/xeno-config-cobalt.in
+++ b/scripts/xeno-config-cobalt.in
@@ -262,10 +262,14 @@ if test x$do_ldflags = xy; then
 done
 wrap_main=
 if test x$do_autoinit = xy; then
-   test x$do_autoinit_solib = xy && codegen=-pic
-   wrap_main="${XENO_LIBRARY_DIR}/xenomai/bootstrap${codegen}.o 
-Wl,--wrap=main -Wl,--dynamic-list=${XENO_LIBRARY_DIR}/dynlist.ld"
+   if test x$do_autoinit_solib = xy; then
+   codegen=-pic
+   else
+   wrap_main="-Wl,--wrap=main 
-Wl,--dynamic-list=${XENO_LIBRARY_DIR}/dynlist.ld"
+   fi
+   bootstrap="${XENO_LIBRARY_DIR}/xenomai/bootstrap${codegen}.o"
 fi
-echo "$ldflags $copperplate $wrap_main $XENO_POSIX_LDFLAGS"
+echo "$ldflags $copperplate $bootstrap $wrap_main $XENO_POSIX_LDFLAGS"
 fi
 
 exit 0
diff --git a/scripts/xeno-config-mercury.in b/scripts/xeno-config-mercury.in
index 5dab4ba..a0aa75b 100644
--- a/scripts/xeno-config-mercury.in
+++ b/scripts/xeno-config-mercury.in
@@ -206,10 +206,14 @@ if test x$do_ldflags = xy; then
 done
 wrap_main=
 if test x$do_autoinit = xy; then
-   test x$do_autoinit_solib = xy && codegen=-pic
-   wrap_main="${XENO_LIBRARY_DIR}/xenomai/bootstrap${codegen}.o 
-Wl,--wrap=main -Wl,--dynamic-list=${XENO_LIBRARY_DIR}/dynlist.ld"
+   if test x$do_autoinit_solib = xy; then
+   codegen=-pic
+   else
+   wrap_main="-Wl,--wrap=main 
-Wl,--dynamic-list=${XENO_LIBRARY_DIR}/dynlist.ld"
+   fi
+   bootstrap="${XENO_LIBRARY_DIR}/xenomai/bootstrap${codegen}.o"
 fi
-echo "$ldflags $copperplate $wrap_main $XENO_BASE_LDFLAGS"
+echo "$ldflags $copperplate $bootstrap $wrap_main $XENO_BASE_LDFLAGS"
 fi
 
 exit 0


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : drivers/gpio: add debugging option

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: fd62a2559d983b794880764e768f8371f4861b20
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=fd62a2559d983b794880764e768f8371f4861b20

Author: Philippe Gerum 
Date:   Thu Jun 23 11:57:50 2016 +0200

drivers/gpio: add debugging option

---

 kernel/drivers/gpio/Kconfig |6 +-
 kernel/drivers/gpio/gpio-core.c |3 +++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/kernel/drivers/gpio/Kconfig b/kernel/drivers/gpio/Kconfig
index 8997963..618f23a 100644
--- a/kernel/drivers/gpio/Kconfig
+++ b/kernel/drivers/gpio/Kconfig
@@ -19,7 +19,11 @@ config XENO_DRIVERS_GPIO_MXC
tristate "Support for MXC GPIOs"
help
 
-   Suitable for the GPIO controller available with
+   Suitable for the GPIO controller available from
Freescale/NXP's MXC architecture.
 
+config XENO_DRIVERS_GPIO_DEBUG
+   depends on XENO_DRIVERS_GPIO
+   bool "Enable GPIO core debugging features"
+   
 endmenu
diff --git a/kernel/drivers/gpio/gpio-core.c b/kernel/drivers/gpio/gpio-core.c
index e8a7ba1..d9863d9 100644
--- a/kernel/drivers/gpio/gpio-core.c
+++ b/kernel/drivers/gpio/gpio-core.c
@@ -15,6 +15,9 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
+#ifdef CONFIG_XENO_DRIVERS_GPIO_DEBUG
+#define DEBUG
+#endif
 #include 
 #include 
 #include 


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : drivers/gpio: introduce real-time GPIO support

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: 089cebf3e1aa7ba02b0e106c49f960c840d6b2df
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=089cebf3e1aa7ba02b0e106c49f960c840d6b2df

Author: Philippe Gerum 
Date:   Wed May 25 10:54:22 2016 +0200

drivers/gpio: introduce real-time GPIO support

---

 configure.ac   |1 +
 include/rtdm/Makefile.am   |1 +
 include/rtdm/gpio.h|   24 +++
 include/rtdm/uapi/Makefile.am  |1 +
 include/rtdm/uapi/gpio.h   |   28 +++
 include/rtdm/uapi/rtdm.h   |1 +
 kernel/drivers/Kconfig |1 +
 kernel/drivers/Makefile|2 +-
 kernel/drivers/gpio/Kconfig|   25 +++
 kernel/drivers/gpio/Makefile   |7 +
 kernel/drivers/gpio/gpio-bcm2708.c |   39 
 kernel/drivers/gpio/gpio-core.c|  349 
 kernel/drivers/gpio/gpio-core.h|   48 +
 kernel/drivers/gpio/gpio-mxc.c |   67 +++
 14 files changed, 593 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 38a1749..40fff80 100644
--- a/configure.ac
+++ b/configure.ac
@@ -878,6 +878,7 @@ AC_CONFIG_FILES([ \
testsuite/Makefile \
testsuite/latency/Makefile \
testsuite/switchtest/Makefile \
+   testsuite/gpiotest/Makefile \
testsuite/smokey/Makefile \
testsuite/smokey/arith/Makefile \
testsuite/smokey/sched-quota/Makefile \
diff --git a/include/rtdm/Makefile.am b/include/rtdm/Makefile.am
index a4e6ff8..ad2c342 100644
--- a/include/rtdm/Makefile.am
+++ b/include/rtdm/Makefile.am
@@ -4,6 +4,7 @@ includesub_HEADERS =\
analogy.h   \
autotune.h  \
can.h   \
+   gpio.h  \
ipc.h   \
rtdm.h  \
serial.h\
diff --git a/include/rtdm/gpio.h b/include/rtdm/gpio.h
new file mode 100644
index 000..c61f229
--- /dev/null
+++ b/include/rtdm/gpio.h
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2016 Philippe Gerum 
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
+ */
+#ifndef _RTDM_GPIO_H
+#define _RTDM_GPIO_H
+
+#include 
+#include 
+
+#endif /* !_RTDM_GPIO_H */
diff --git a/include/rtdm/uapi/Makefile.am b/include/rtdm/uapi/Makefile.am
index 7cff6c2..d53f10c 100644
--- a/include/rtdm/uapi/Makefile.am
+++ b/include/rtdm/uapi/Makefile.am
@@ -4,6 +4,7 @@ includesub_HEADERS =\
analogy.h   \
autotune.h  \
can.h   \
+   gpio.h  \
ipc.h   \
rtdm.h  \
serial.h\
diff --git a/include/rtdm/uapi/gpio.h b/include/rtdm/uapi/gpio.h
new file mode 100644
index 000..b0d4899
--- /dev/null
+++ b/include/rtdm/uapi/gpio.h
@@ -0,0 +1,28 @@
+/**
+ * @note Copyright (C) 2016 Philippe Gerum 
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that 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 _RTDM_UAPI_GPIO_H
+#define _RTDM_UAPI_GPIO_H
+
+#include 
+
+#define GPIO_RTIOC_DIR_OUT _IOW(RTDM_CLASS_GPIO, 0, int)
+#define GPIO_RTIOC_DIR_IN  _IO(RTDM_CLASS_GPIO, 1)
+#define GPIO_RTIOC_IRQEN   _IO(RTDM_CLASS_GPIO, 2)
+#define GPIO_RTIOC_IRQDIS  _IO(RTDM_CLASS_GPIO, 3)
+
+#endif /* !_RTDM_UAPI_GPIO_H */
diff --git a/include/rtdm/uapi/rtdm.h b/include/rtdm/uapi/rtdm.h
index eed3b36..c49378c 100644
--- a/include/rtdm/uapi/rtdm.h
+++ b/include/rtdm/uapi/rtdm.h
@@ -79,6 +79,7 @@ typedef int64_t nanosecs_rel_t;
 #define RTDM_CLASS_COBALT  8
 #define RTDM_CLASS_UDD 9
 #define RTDM_CLASS_MEMORY

[Xenomai-git] Philippe Gerum : drivers/gpio: add blocking read()

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: 1f56f78877e3999f357d9467c18d94b391b72d55
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=1f56f78877e3999f357d9467c18d94b391b72d55

Author: Philippe Gerum 
Date:   Tue Jul 12 09:53:37 2016 +0200

drivers/gpio: add blocking read()

---

 include/rtdm/uapi/gpio.h|2 --
 kernel/drivers/gpio/gpio-core.c |7 +++
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/include/rtdm/uapi/gpio.h b/include/rtdm/uapi/gpio.h
index 307e190..f846f48 100644
--- a/include/rtdm/uapi/gpio.h
+++ b/include/rtdm/uapi/gpio.h
@@ -18,8 +18,6 @@
 #ifndef _RTDM_UAPI_GPIO_H
 #define _RTDM_UAPI_GPIO_H
 
-#include 
-
 #define GPIO_RTIOC_DIR_OUT _IOW(RTDM_CLASS_GPIO, 0, int)
 #define GPIO_RTIOC_DIR_IN  _IO(RTDM_CLASS_GPIO, 1)
 #define GPIO_RTIOC_IRQEN   _IOW(RTDM_CLASS_GPIO, 2, int) /* GPIO 
trigger */
diff --git a/kernel/drivers/gpio/gpio-core.c b/kernel/drivers/gpio/gpio-core.c
index 6c1f351..f18d571 100644
--- a/kernel/drivers/gpio/gpio-core.c
+++ b/kernel/drivers/gpio/gpio-core.c
@@ -155,6 +155,13 @@ static ssize_t gpio_pin_read_rt(struct rtdm_fd *fd,
return -EINVAL;
 
pin = container_of(dev, struct rtdm_gpio_pin, dev);
+
+   if (!(fd->oflags & O_NONBLOCK)) {
+   ret = rtdm_event_wait(>event);
+   if (ret)
+   return ret;
+   }
+
value = gpiod_get_raw_value(pin->desc);
ret = rtdm_safe_copy_to_user(fd, buf, , sizeof(value));



___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : drivers/spi: sanitize DEBUG mode switch

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: c5850842ed0de1c3acc30d46993300ab2d80126b
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=c5850842ed0de1c3acc30d46993300ab2d80126b

Author: Philippe Gerum 
Date:   Tue Jun 28 10:49:26 2016 +0200

drivers/spi: sanitize DEBUG mode switch

---

 kernel/drivers/spi/Makefile  |2 ++
 kernel/drivers/spi/spi-bcm2835.c |3 ---
 kernel/drivers/spi/spi-device.c  |3 ---
 kernel/drivers/spi/spi-master.c  |3 ---
 4 files changed, 2 insertions(+), 9 deletions(-)

diff --git a/kernel/drivers/spi/Makefile b/kernel/drivers/spi/Makefile
index 6c78a2e..2a00284 100644
--- a/kernel/drivers/spi/Makefile
+++ b/kernel/drivers/spi/Makefile
@@ -1,4 +1,6 @@
 
+ccflags-$(CONFIG_XENO_DRIVERS_SPI_DEBUG) := -DDEBUG
+
 obj-$(CONFIG_XENO_DRIVERS_SPI) += xeno_spi.o
 
 xeno_spi-y := spi-master.o spi-device.o
diff --git a/kernel/drivers/spi/spi-bcm2835.c b/kernel/drivers/spi/spi-bcm2835.c
index 118cfd5..117cf38 100644
--- a/kernel/drivers/spi/spi-bcm2835.c
+++ b/kernel/drivers/spi/spi-bcm2835.c
@@ -21,9 +21,6 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
-#ifdef CONFIG_XENO_DRIVERS_SPI_DEBUG
-#define DEBUG
-#endif
 #include 
 #include 
 #include 
diff --git a/kernel/drivers/spi/spi-device.c b/kernel/drivers/spi/spi-device.c
index 08cf9b0..71f30a6 100644
--- a/kernel/drivers/spi/spi-device.c
+++ b/kernel/drivers/spi/spi-device.c
@@ -15,9 +15,6 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
-#ifdef CONFIG_XENO_DRIVERS_SPI_DEBUG
-#define DEBUG
-#endif
 #include 
 #include 
 #include 
diff --git a/kernel/drivers/spi/spi-master.c b/kernel/drivers/spi/spi-master.c
index fe2ee40..ac7929a 100644
--- a/kernel/drivers/spi/spi-master.c
+++ b/kernel/drivers/spi/spi-master.c
@@ -15,9 +15,6 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
-#ifdef CONFIG_XENO_DRIVERS_SPI_DEBUG
-#define DEBUG
-#endif
 #include 
 #include 
 #include 


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : testsuite/gpiotest: add GPIO test suite

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: defe11f57a83c6a92062b09ab7d9dff4f1374046
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=defe11f57a83c6a92062b09ab7d9dff4f1374046

Author: Philippe Gerum 
Date:   Wed Jun  1 15:59:27 2016 +0200

testsuite/gpiotest: add GPIO test suite

---

 testsuite/Makefile.am  |2 +
 testsuite/gpiotest/Makefile.am |   19 
 testsuite/gpiotest/gpiotest.c  |  188 
 3 files changed, 209 insertions(+)

diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am
index e83e6cb..c345472 100644
--- a/testsuite/Makefile.am
+++ b/testsuite/Makefile.am
@@ -4,12 +4,14 @@ SUBDIRS = latency smokey
 if XENO_COBALT
 SUBDIRS += \
clocktest   \
+   gpiotest\
switchtest  \
xeno-test
 endif
 
 DIST_SUBDIRS = \
clocktest   \
+   gpiotest\
latency \
smokey  \
switchtest  \
diff --git a/testsuite/gpiotest/Makefile.am b/testsuite/gpiotest/Makefile.am
new file mode 100644
index 000..b01427b
--- /dev/null
+++ b/testsuite/gpiotest/Makefile.am
@@ -0,0 +1,19 @@
+testdir = @XENO_TEST_DIR@
+
+CCLD = $(top_srcdir)/scripts/wrap-link.sh $(CC)
+
+test_PROGRAMS = gpiotest
+
+gpiotest_SOURCES = gpiotest.c
+
+gpiotest_CPPFLAGS =\
+   $(XENO_USER_CFLAGS) \
+   -I$(top_srcdir)/include
+
+gpiotest_LDFLAGS = @XENO_AUTOINIT_LDFLAGS@ $(XENO_POSIX_WRAPPERS)
+
+gpiotest_LDADD =   \
+   ../../lib/smokey/libsmokey.la   \
+   ../../lib/@XENO_CORE_LIB@   \
+@XENO_USER_LDADD@  \
+   -lpthread -lrt
diff --git a/testsuite/gpiotest/gpiotest.c b/testsuite/gpiotest/gpiotest.c
new file mode 100644
index 000..838f498
--- /dev/null
+++ b/testsuite/gpiotest/gpiotest.c
@@ -0,0 +1,188 @@
+/*
+ * Copyright (C) 2016 Philippe Gerum .
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that 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.
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+smokey_test_plugin(interrupt,
+  SMOKEY_ARGLIST(
+  SMOKEY_STRING(device),
+  ),
+   "Wait for interrupts from a GPIO pin.\n"
+   "\tdevice=."
+);
+
+smokey_test_plugin(read_value,
+  SMOKEY_ARGLIST(
+  SMOKEY_STRING(device),
+  ),
+   "Read GPIO value.\n"
+   "\tdevice=."
+);
+
+smokey_test_plugin(write_value,
+  SMOKEY_ARGLIST(
+  SMOKEY_STRING(device),
+  ),
+   "Write GPIO value.\n"
+   "\tdevice=."
+);
+
+static int run_interrupt(struct smokey_test *t, int argc, char *const argv[])
+{
+   const char *device = NULL;
+   int fd, ret;
+   fd_set set;
+   
+   smokey_parse_args(t, argc, argv);
+
+   if (!SMOKEY_ARG_ISSET(interrupt, device)) {
+   warning("missing device= specification");
+   return -EINVAL;
+   }
+
+   device = SMOKEY_ARG_STRING(interrupt, device);
+   fd = open(device, O_RDWR);
+   if (fd < 0) {
+   ret = -errno;
+   warning("cannot open device %s [%s]",
+   device, symerror(ret));
+   return ret;
+   }
+
+   ret = ioctl(fd, GPIO_RTIOC_IRQEN);
+   if (ret) {
+   ret = -errno;
+   warning("GPIO_RTIOC_IRQEN failed on %s [%s]",
+   device, symerror(ret));
+   return ret;
+   }
+
+   FD_ZERO();
+   FD_SET(fd, );
+   
+   for (;;) {
+   ret = select(fd + 1, , NULL, NULL, NULL);
+   if (ret < 0) {
+   ret = -errno;
+   warning("failed listening to %s [%s]",
+   device, symerror(ret));
+   }
+   printf("kick %d!\n", ret);
+   }
+
+   close(fd);
+
+   return 0;
+}
+
+static int run_read_value(struct smokey_test *t, int argc, char *const argv[])
+{
+   const char *device = NULL;
+   int fd, ret, value = -1;
+
+   smokey_parse_args(t, argc, argv);
+
+   if (!SMOKEY_ARG_ISSET(read_value, device)) {
+   warning("missing device= specification");
+

[Xenomai-git] Philippe Gerum : testsuite/gpiotest: set GPIO direction

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: c777a7681d9eedd07eba38559473ac15f71eb1c8
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=c777a7681d9eedd07eba38559473ac15f71eb1c8

Author: Philippe Gerum 
Date:   Sat Jun 25 18:53:36 2016 +0200

testsuite/gpiotest: set GPIO direction

---

 testsuite/gpiotest/gpiotest.c |6 ++
 1 file changed, 6 insertions(+)

diff --git a/testsuite/gpiotest/gpiotest.c b/testsuite/gpiotest/gpiotest.c
index 838f498..65949ee 100644
--- a/testsuite/gpiotest/gpiotest.c
+++ b/testsuite/gpiotest/gpiotest.c
@@ -117,6 +117,9 @@ static int run_read_value(struct smokey_test *t, int argc, 
char *const argv[])
return ret;
}
 
+   if (!__T(ret, ioctl(fd, GPIO_RTIOC_DIR_IN)))
+   return ret;
+
ret = read(fd, , sizeof(value));
close(fd);
 
@@ -149,6 +152,9 @@ static int run_write_value(struct smokey_test *t, int argc, 
char *const argv[])
return ret;
}
 
+   if (!__T(ret, ioctl(fd, GPIO_RTIOC_DIR_OUT)))
+   return ret;
+   
ret = write(fd, , sizeof(value));
close(fd);
 


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : drivers/gpio: rename after the SoC

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: e4cbab7aded7df67691568ff03bdddbc7a1e22d4
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=e4cbab7aded7df67691568ff03bdddbc7a1e22d4

Author: Philippe Gerum 
Date:   Thu Jun 23 14:31:10 2016 +0200

drivers/gpio: rename after the SoC

---

 kernel/drivers/gpio/Kconfig|8 
 kernel/drivers/gpio/Makefile   |2 +-
 kernel/drivers/gpio/{gpio-bcm2708.c => gpio-bcm2835.c} |0
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/kernel/drivers/gpio/Kconfig b/kernel/drivers/gpio/Kconfig
index 618f23a..850127f 100644
--- a/kernel/drivers/gpio/Kconfig
+++ b/kernel/drivers/gpio/Kconfig
@@ -4,14 +4,14 @@ config XENO_DRIVERS_GPIO
tristate
depends on GPIOLIB
 
-config XENO_DRIVERS_GPIO_BCM2708
+config XENO_DRIVERS_GPIO_BCM2835
depends on MACH_BCM2708
select XENO_DRIVERS_GPIO
-   tristate "Support for BCM2708 GPIOs"
+   tristate "Support for BCM2835 GPIOs"
help
 
-   Suitable for the GPIO controller present on Broadcom's BCM2708
-   chip family.
+   Enables support for the GPIO controller available from
+   Broadcom's BCM2835 SoC.
 
 config XENO_DRIVERS_GPIO_MXC
depends on GPIO_MXC
diff --git a/kernel/drivers/gpio/Makefile b/kernel/drivers/gpio/Makefile
index 5d194a1..e237279 100644
--- a/kernel/drivers/gpio/Makefile
+++ b/kernel/drivers/gpio/Makefile
@@ -3,5 +3,5 @@ obj-$(CONFIG_XENO_DRIVERS_GPIO) += xeno_gpio.o
 
 xeno_gpio-y := gpio-core.o
 
-xeno_gpio-$(CONFIG_XENO_DRIVERS_GPIO_BCM2708) += gpio-bcm2708.o
+xeno_gpio-$(CONFIG_XENO_DRIVERS_GPIO_BCM2835) += gpio-bcm2835.o
 xeno_gpio-$(CONFIG_XENO_DRIVERS_GPIO_MXC) += gpio-mxc.o
diff --git a/kernel/drivers/gpio/gpio-bcm2708.c 
b/kernel/drivers/gpio/gpio-bcm2835.c
similarity index 100%
rename from kernel/drivers/gpio/gpio-bcm2708.c
rename to kernel/drivers/gpio/gpio-bcm2835.c


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/x86: fpu: drop obsolete xnarch_save_fpu()

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: 3d7cab71c44c341ff465ca7ea2a1562ceae1e125
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=3d7cab71c44c341ff465ca7ea2a1562ceae1e125

Author: Philippe Gerum 
Date:   Thu Sep  8 16:29:38 2016 +0200

cobalt/x86: fpu: drop obsolete xnarch_save_fpu()

---

 kernel/cobalt/arch/x86/include/asm/xenomai/thread.h |2 --
 kernel/cobalt/arch/x86/thread.c |   17 -
 2 files changed, 19 deletions(-)

diff --git a/kernel/cobalt/arch/x86/include/asm/xenomai/thread.h 
b/kernel/cobalt/arch/x86/include/asm/xenomai/thread.h
index 3862e33..bd39f5a 100644
--- a/kernel/cobalt/arch/x86/include/asm/xenomai/thread.h
+++ b/kernel/cobalt/arch/x86/include/asm/xenomai/thread.h
@@ -59,8 +59,6 @@ static inline int xnarch_shadow_p(struct xnarchtcb *tcb, 
struct task_struct *tas
 ((d)->exception == 1 || (d)->exception == 3))
 #define xnarch_fault_notify(d) (!xnarch_fault_bp_p(d))
 
-void xnarch_save_fpu(struct xnthread *thread);
-
 void xnarch_switch_fpu(struct xnthread *from, struct xnthread *to);
 
 int xnarch_handle_fpu_fault(struct xnthread *from, 
diff --git a/kernel/cobalt/arch/x86/thread.c b/kernel/cobalt/arch/x86/thread.c
index d367d13..0383f00 100644
--- a/kernel/cobalt/arch/x86/thread.c
+++ b/kernel/cobalt/arch/x86/thread.c
@@ -289,8 +289,6 @@ int xnarch_handle_fpu_fault(struct xnthread *from,
/*
 * The faulting task is a shadow using the FPU for the first
 * time, initialize the FPU context and tell linux about it.
-* The fpu usage bit is necessary for xnarch_save_fpu() to
-* save the FPU state at next switch.
 */
__asm__ __volatile__("clts; fninit");
 
@@ -346,21 +344,6 @@ void xnarch_leave_root(struct xnthread *root)
kernel_fpu_enable();
 }
 
-void xnarch_save_fpu(struct xnthread *thread)
-{
-   struct xnarchtcb *tcb = xnthread_archtcb(thread);
-   struct task_struct *p = tcb->core.host_task;
-
-   if (__thread_has_fpu(p) == 0)
-   /* Saved by last __switch_to */
-   return;
-   
-   clts();
-
-   __do_save_i387(x86_fpustate_ptr(>thread));
-   __thread_clear_has_fpu(p);
-}
-
 void xnarch_switch_fpu(struct xnthread *from, struct xnthread *to)
 {
x86_fpustate *const from_fpup = from ? from->tcb.fpup : NULL;


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : drivers/gpio: sanitize DEBUG mode switch

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: 0fc7664203d4a3326fdd83c126c891cf6124cf90
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=0fc7664203d4a3326fdd83c126c891cf6124cf90

Author: Philippe Gerum 
Date:   Tue Jun 28 10:49:17 2016 +0200

drivers/gpio: sanitize DEBUG mode switch

---

 kernel/drivers/gpio/Makefile|2 ++
 kernel/drivers/gpio/gpio-core.c |3 ---
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/kernel/drivers/gpio/Makefile b/kernel/drivers/gpio/Makefile
index e237279..c9e976f 100644
--- a/kernel/drivers/gpio/Makefile
+++ b/kernel/drivers/gpio/Makefile
@@ -1,4 +1,6 @@
 
+ccflags-$(CONFIG_XENO_DRIVERS_GPIO_DEBUG) := -DDEBUG
+
 obj-$(CONFIG_XENO_DRIVERS_GPIO) += xeno_gpio.o
 
 xeno_gpio-y := gpio-core.o
diff --git a/kernel/drivers/gpio/gpio-core.c b/kernel/drivers/gpio/gpio-core.c
index d9863d9..e8a7ba1 100644
--- a/kernel/drivers/gpio/gpio-core.c
+++ b/kernel/drivers/gpio/gpio-core.c
@@ -15,9 +15,6 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
-#ifdef CONFIG_XENO_DRIVERS_GPIO_DEBUG
-#define DEBUG
-#endif
 #include 
 #include 
 #include 


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : drivers/spi: fix read/write transfer descriptor

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: 4953b3e156fed32a1ca3368ad13573d3ad657200
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=4953b3e156fed32a1ca3368ad13573d3ad657200

Author: Philippe Gerum 
Date:   Wed Aug 10 10:14:28 2016 +0200

drivers/spi: fix read/write transfer descriptor

---

 kernel/drivers/spi/spi-bcm2835.c |   18 ++
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/kernel/drivers/spi/spi-bcm2835.c b/kernel/drivers/spi/spi-bcm2835.c
index 117cf38..da44bf7 100644
--- a/kernel/drivers/spi/spi-bcm2835.c
+++ b/kernel/drivers/spi/spi-bcm2835.c
@@ -324,13 +324,10 @@ static ssize_t bcm2835_read(struct rtdm_spi_remote_slave 
*slave,
struct spi_master_bcm2835 *spim = to_master_bcm2835(slave);
struct spi_slave_bcm2835 *bcm = to_slave_bcm2835(slave);
 
-   if (bcm->io_len == 0)
-   return -EINVAL; /* No I/O buffers set. */
-   
-   spim->tx_len = bcm->io_len / 2;
-   spim->rx_len = spim->tx_len;
+   spim->tx_len = len;
+   spim->rx_len = len;
spim->tx_buf = NULL;
-   spim->rx_buf = bcm->io_virt;
+   spim->rx_buf = rx;
 
return do_transfer_irq(slave) ?: len;
 }
@@ -341,12 +338,9 @@ static ssize_t bcm2835_write(struct rtdm_spi_remote_slave 
*slave,
struct spi_master_bcm2835 *spim = to_master_bcm2835(slave);
struct spi_slave_bcm2835 *bcm = to_slave_bcm2835(slave);
 
-   if (bcm->io_len == 0)
-   return -EINVAL; /* No I/O buffers set. */
-   
-   spim->tx_len = bcm->io_len / 2;
-   spim->rx_len = spim->tx_len;
-   spim->tx_buf = bcm->io_virt + bcm->io_len / 2;
+   spim->tx_len = len;
+   spim->rx_len = len;
+   spim->tx_buf = tx;
spim->rx_buf = NULL;
 
return do_transfer_irq(slave) ?: len;


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : drivers/gpio: return ENODEV on failed device detection

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: 64bbd2a22ab26aef0bfd1cf099d80af320785d8c
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=64bbd2a22ab26aef0bfd1cf099d80af320785d8c

Author: Philippe Gerum 
Date:   Sat Jun 18 12:20:43 2016 +0200

drivers/gpio: return ENODEV on failed device detection

---

 kernel/drivers/gpio/gpio-core.c |   11 ---
 kernel/drivers/gpio/gpio-core.h |2 ++
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/kernel/drivers/gpio/gpio-core.c b/kernel/drivers/gpio/gpio-core.c
index 319d5c7..e8a7ba1 100644
--- a/kernel/drivers/gpio/gpio-core.c
+++ b/kernel/drivers/gpio/gpio-core.c
@@ -22,7 +22,6 @@
 #include 
 #include 
 #include 
-#include 
 #include "gpio-core.h"
 
 struct rtdm_gpio_pin {
@@ -329,13 +328,17 @@ int rtdm_gpiochip_add_by_name(struct rtdm_gpio_chip *rgc,
 }
 EXPORT_SYMBOL_GPL(rtdm_gpiochip_add_by_name);
 
+#ifdef CONFIG_OF
+
+#include 
+
 int rtdm_gpiochip_scan_of(struct device_node *from, const char *compat,
  int (*match)(struct gpio_chip *gc))
 {
struct device_node *np = from;
struct platform_device *pdev;
-   int ret = -EPROBE_DEFER;
struct gpio_chip *gc;
+   int ret = -ENODEV;
 
for (;;) {
np = of_find_compatible_node(np, NULL, compat);
@@ -344,7 +347,7 @@ int rtdm_gpiochip_scan_of(struct device_node *from, const 
char *compat,
pdev = of_find_device_by_node(np);
of_node_put(np);
if (pdev == NULL)
-   return -ENODEV;
+   break;
gc = find_chip_by_name(dev_name(>dev));
if (gc) {
ret = match(gc);
@@ -356,3 +359,5 @@ int rtdm_gpiochip_scan_of(struct device_node *from, const 
char *compat,
return ret;
 }
 EXPORT_SYMBOL_GPL(rtdm_gpiochip_scan_of);
+
+#endif /* CONFIG_OF */
diff --git a/kernel/drivers/gpio/gpio-core.h b/kernel/drivers/gpio/gpio-core.h
index d4dd28a..c0eac32 100644
--- a/kernel/drivers/gpio/gpio-core.h
+++ b/kernel/drivers/gpio/gpio-core.h
@@ -43,7 +43,9 @@ void rtdm_gpiochip_remove(struct rtdm_gpio_chip *rgc);
 int rtdm_gpiochip_add_by_name(struct rtdm_gpio_chip *rgc,
  const char *label, int gpio_subclass);
 
+#ifdef CONFIG_OF
 int rtdm_gpiochip_scan_of(struct device_node *from, const char *compat,
  int (*match)(struct gpio_chip *gc));
+#endif
 
 #endif /* !_RTDM_GPIO_CORE_H */


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : doc: prebuild

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: 4993d845b9af8a51255aa2978e25715f0207162e
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=4993d845b9af8a51255aa2978e25715f0207162e

Author: Philippe Gerum 
Date:   Fri Sep  9 19:34:07 2016 +0200

doc: prebuild

---

 doc/prebuilt/html/MIGRATION/index.html |6 +-
 doc/prebuilt/html/README.APPLICATIONS/index.html   |2 +-
 doc/prebuilt/html/README.INSTALL/index.html|2 +-
 .../html/TROUBLESHOOTING.COBALT/index.html |2 +-
 .../html/TROUBLESHOOTING.MERCURY/index.html|2 +-
 doc/prebuilt/html/man1/xeno-config/index.html  |   25 +-
 .../html/xeno3prm/16550A__io_8h_source.html|2 +-
 .../html/xeno3prm/16550A__pci_8h_source.html   |4 +-
 .../html/xeno3prm/16550A__pnp_8h_source.html   |2 +-
 doc/prebuilt/html/xeno3prm/8255_8h_source.html |2 +-
 doc/prebuilt/html/xeno3prm/af__inet_8h_source.html |2 +-
 .../html/xeno3prm/alchemy_2compat_8h_source.html   |2 +-
 doc/prebuilt/html/xeno3prm/analogy_2driver_8h.html |2 +-
 .../html/xeno3prm/analogy_2driver_8h_source.html   |2 +-
 doc/prebuilt/html/xeno3prm/analogy_8h.html |   28 +-
 doc/prebuilt/html/xeno3prm/analogy_8h__incl.map|   26 +-
 doc/prebuilt/html/xeno3prm/analogy_8h__incl.md5|2 +-
 doc/prebuilt/html/xeno3prm/analogy_8h__incl.png|  Bin 59700 -> 69464 bytes
 doc/prebuilt/html/xeno3prm/analogy_8h_source.html  |2 +-
 doc/prebuilt/html/xeno3prm/annotated.html  |2 +-
 doc/prebuilt/html/xeno3prm/apc_8h_source.html  |2 +-
 doc/prebuilt/html/xeno3prm/api-tags.html   |   10 +-
 ..._2include_2asm_2xenomai_2machine_8h_source.html |  149 ++
 ...include_2asm_2xenomai_2syscall32_8h_source.html |  133 ++
 ..._2include_2asm_2xenomai_2machine_8h_source.html |2 +-
 ...include_2asm_2xenomai_2syscall32_8h_source.html |2 +-
 ..._2include_2asm_2xenomai_2machine_8h_source.html |2 +-
 ...include_2asm_2xenomai_2syscall32_8h_source.html |2 +-
 ..._2include_2asm_2xenomai_2machine_8h_source.html |2 +-
 ...include_2asm_2xenomai_2syscall32_8h_source.html |2 +-
 ..._2include_2asm_2xenomai_2machine_8h_source.html |2 +-
 ...include_2asm_2xenomai_2syscall32_8h_source.html |2 +-
 ...4_2include_2asm_2xenomai_2fptest_8h_source.html |  156 ++
 ...lude_2asm_2xenomai_2uapi_2fptest_8h_source.html |  214 +++
 ...m_2include_2asm_2xenomai_2fptest_8h_source.html |2 +-
 ...lude_2asm_2xenomai_2uapi_2fptest_8h_source.html |2 +-
 doc/prebuilt/html/xeno3prm/arp_8h_source.html  |2 +-
 doc/prebuilt/html/xeno3prm/assert_8h_source.html   |2 +-
 doc/prebuilt/html/xeno3prm/async_8c.html   |   46 +-
 doc/prebuilt/html/xeno3prm/async_8c__incl.map  |   44 +-
 doc/prebuilt/html/xeno3prm/async_8c__incl.md5  |2 +-
 doc/prebuilt/html/xeno3prm/async_8c__incl.png  |  Bin 120089 -> 139291 
bytes
 doc/prebuilt/html/xeno3prm/atomic_8h_source.html   |2 +-
 ...n_2include_2asm_2xenomai_2fptest_8h_source.html |2 +-
 ...lude_2asm_2xenomai_2uapi_2fptest_8h_source.html |2 +-
 .../boilerplate_2ancillaries_8h_source.html|2 +-
 .../html/xeno3prm/boilerplate_2list_8h_source.html |2 +-
 .../html/xeno3prm/boilerplate_2lock_8h_source.html |2 +-
 .../html/xeno3prm/boilerplate_2time_8h_source.html |2 +-
 .../xeno3prm/boilerplate_2tunables_8h_source.html  |2 +-
 doc/prebuilt/html/xeno3prm/bufd_8h_source.html |2 +-
 .../html/xeno3prm/bufp-label_8c-example.html   |2 +-
 .../html/xeno3prm/bufp-readwrite_8c-example.html   |2 +-
 doc/prebuilt/html/xeno3prm/c1e_8h_source.html  |2 +-
 doc/prebuilt/html/xeno3prm/calibration_8c.html |   34 +-
 .../html/xeno3prm/calibration_8c__incl.map |   32 +-
 .../html/xeno3prm/calibration_8c__incl.md5 |2 +-
 .../html/xeno3prm/calibration_8c__incl.png |  Bin 89552 -> 99227 bytes
 doc/prebuilt/html/xeno3prm/can-rtt_8c-example.html |2 +-
 doc/prebuilt/html/xeno3prm/channel__range_8h.html  |2 +-
 .../html/xeno3prm/channel__range_8h_source.html|2 +-
 doc/prebuilt/html/xeno3prm/classes.html|2 +-
 doc/prebuilt/html/xeno3prm/clockobj_8h_source.html |2 +-
 doc/prebuilt/html/xeno3prm/cluster_8h_source.html  |2 +-
 .../html/xeno3prm/cobalt-core_8h_source.html   |2 +-
 .../html/xeno3prm/cobalt-posix_8h_source.html  | 1873 ++--
 .../html/xeno3prm/cobalt-rtdm_8h_source.html   |   10 +-
 .../cobalt_2boilerplate_2limits_8h_source.html |2 +-
 .../cobalt_2boilerplate_2trace_8h_source.html  |2 +-
 .../cobalt_2kernel_2ancillaries_8h_source.html |2 +-
 .../xeno3prm/cobalt_2kernel_2compat_8h_source.html |2 +-
 .../xeno3prm/cobalt_2kernel_2init_8h_source.html   |2 +-
 .../xeno3prm/cobalt_2kernel_2list_8h_source.html   |2 +-
 .../xeno3prm/cobalt_2kernel_2lock_8h_source.html   |2 +-
 

[Xenomai-git] Philippe Gerum : boilerplate/list: add list_{prev, next}_entry() accessors

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: c35e76631e22a17b3f1387e7e95efa08b8accc96
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=c35e76631e22a17b3f1387e7e95efa08b8accc96

Author: Philippe Gerum 
Date:   Wed Sep 28 18:26:38 2016 +0200

boilerplate/list: add list_{prev, next}_entry() accessors

---

 include/boilerplate/private-list.h |   18 ++
 include/boilerplate/shared-list.h  |   24 
 2 files changed, 42 insertions(+)

diff --git a/include/boilerplate/private-list.h 
b/include/boilerplate/private-list.h
index f5aafac..72f1e4c 100644
--- a/include/boilerplate/private-list.h
+++ b/include/boilerplate/private-list.h
@@ -146,6 +146,24 @@ static inline int pvlist_heading_p(const struct pvholder 
*holder,
 #define pvlist_last_entry(list, type, member)  \
pvlist_entry((list)->head.prev, type, member)
 
+#define pvlist_prev_entry(pos, list, member)   \
+   ({  \
+   typeof(*pos) *__prev = NULL;\
+   if ((list)->head.next != &(pos)->member)\
+   __prev = pvlist_entry((pos)->member.prev,   \
+ typeof(*pos), member);\
+   __prev; \
+   })
+
+#define pvlist_next_entry(pos, list, member)   \
+   ({  \
+   typeof(*pos) *__next = NULL;\
+   if ((list)->head.prev != &(pos)->member)\
+   __next = pvlist_entry((pos)->member.next,   \
+ typeof(*pos), member);\
+   __next; \
+   })
+
 #define pvlist_pop_entry(list, type, member) ({
\
struct pvholder *__holder = pvlist_pop(list);   \
pvlist_entry(__holder, type, member); })
diff --git a/include/boilerplate/shared-list.h 
b/include/boilerplate/shared-list.h
index 0f88d6f..741dfc0 100644
--- a/include/boilerplate/shared-list.h
+++ b/include/boilerplate/shared-list.h
@@ -245,6 +245,30 @@ static inline int list_heading_p(const struct holder 
*holder,
 #define list_last_entry(list, type, member)\
__list_last_entry(__main_heap, list, type, member)
 
+#define __list_prev_entry(heap, pos, list, member) \
+   ({  \
+   typeof(*pos) *__prev = NULL;\
+   if ((list)->head.next != __hoff(heap, &(pos)->member))  \
+   __prev = list_entry(__hptr((heap),  \
+  (pos)->member.prev), typeof(*pos), member);  \
+   __prev; \
+   })
+
+#define list_prev_entry(pos, list, member) \
+   __list_prev_entry(__main_heap, pos, list, member)
+
+#define __list_next_entry(heap, pos, list, member) \
+   ({  \
+   typeof(*pos) *__next = NULL;\
+   if ((list)->head.prev != __hoff(heap, &(pos)->member))  \
+   __next = list_entry(__hptr((heap),  \
+  (pos)->member.next), typeof(*pos), member);  \
+   __next; \
+   })
+
+#define list_next_entry(pos, list, member) \
+   __list_next_entry(__main_heap, pos, list, member)
+
 #define __list_pop_entry(heap, list, type, member) ({  \
struct holder *__holder = __list_pop((heap), list); \
list_entry(__holder, type, member); })


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : doc/man: xeno-config: document --auto-init-solib

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: 66d624c447f189748e1761a53418d9792278e20b
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=66d624c447f189748e1761a53418d9792278e20b

Author: Philippe Gerum 
Date:   Fri Sep  9 19:18:34 2016 +0200

doc/man: xeno-config: document --auto-init-solib

---

 doc/asciidoc/man1/xeno-config.adoc |   18 --
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/doc/asciidoc/man1/xeno-config.adoc 
b/doc/asciidoc/man1/xeno-config.adoc
index 2844352..62ab888 100644
--- a/doc/asciidoc/man1/xeno-config.adoc
+++ b/doc/asciidoc/man1/xeno-config.adoc
@@ -35,7 +35,7 @@ SYNOPSIS
 
 *xeno-config* *--version*
 
-*xeno-config* [*--cc*] [*--ccld*] [*--arch*] [*--prefix*] 
[*--posix|alchemy|rtdm|psos|vxworks|smokey*] [*--compat*] 
[*--auto-init*|*no-auto-init*] [*--cflags*] [*--ldflags*] 
[*--library-dir*|*--libdir*|*--user-libdir*]
+*xeno-config* [*--cc*] [*--ccld*] [*--arch*] [*--prefix*] 
[*--posix|alchemy|rtdm|psos|vxworks|smokey*] [*--compat*] 
[*--auto-init*|*no-auto-init*] [*--auto-init-solib*] [*--cflags*] [*--ldflags*] 
[*--library-dir*|*--libdir*|*--user-libdir*]
 
 DESCRIPTION
 
@@ -126,7 +126,21 @@ initialization. In such a case, the application code shall 
call the
 chores on behalf on the +main()+ routine, *before* any real-time
 service is invoked.
 
-*xeno-config* enables the Copperplate auto-init feature by default.
+This flag makes sense when passed along with --ldflags
+only. *xeno-config* enables the Copperplate auto-init feature by
+default.
+
+*--auto-init-solib*::
+
+This switch enables the auto-initialization feature described above
+for a shared library target instead of a pure executable. The main
+difference resides in a position-independent (PIC) glue code being
+used for bootstrapping the initialization.
+
+The bootstrap code runs when the shared library is attached to a
+running executable, either because it appears in the static
+dependencies of this executable, or when loaded dynamically via the
+dlopen() interface.
 
 *--core*::
 Output the name of the real-time core the current Xenomai installation


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : copperplate/heapobj: pshared: fix corruption of sub-page block list

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: 3746052918643aad50cedbec47df54f03a1f0b92
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=3746052918643aad50cedbec47df54f03a1f0b92

Author: Philippe Gerum 
Date:   Thu Sep 22 11:27:58 2016 +0200

copperplate/heapobj: pshared: fix corruption of sub-page block list

Block allocation requests between HOBJ_PAGE_SIZE and HOBJ_PAGE_SIZE *
2 are satisfied by returning free raw pages directly, in which case
there is no free sub-page block list attached to the corresponding
log2 slot. Make sure we don't create a spurious one inadvertently.

This fixes a crash on such an allocation/release pattern:

int *p = xnmalloc(1400);
p[0] = -1;
xnfree(p);
xnmalloc(512);
xnmalloc(512);

Reported-by: Jan Kiszka 

---

 lib/copperplate/heapobj-pshared.c |8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lib/copperplate/heapobj-pshared.c 
b/lib/copperplate/heapobj-pshared.c
index f4c6f37..e02cfd3 100644
--- a/lib/copperplate/heapobj-pshared.c
+++ b/lib/copperplate/heapobj-pshared.c
@@ -437,10 +437,12 @@ static void *alloc_block(struct shared_heap *heap, size_t 
size)
block = get_free_range(heap, bsize, log2size);
if (block == NULL)
goto done;
-   if (bsize <= HOBJ_PAGE_SIZE)
+   if (bsize < HOBJ_PAGE_SIZE) {
heap->buckets[ilog].fcount += (HOBJ_PAGE_SIZE 
>> log2size) - 1;
+   heap->buckets[ilog].freelist = *((memoff_t 
*)block);
+   }
} else {
-   if (bsize <= HOBJ_PAGE_SIZE)
+   if (bsize < HOBJ_PAGE_SIZE)
--heap->buckets[ilog].fcount;
 
/* Search for the source extent of block. */
@@ -453,9 +455,9 @@ static void *alloc_block(struct shared_heap *heap, size_t 
size)
found:
pgnum = (__shoff(base, block) - extent->membase) >> 
HOBJ_PAGE_SHIFT;
++extent->pagemap[pgnum].bcount;
+   heap->buckets[ilog].freelist = *((memoff_t *)block);
}
 
-   heap->buckets[ilog].freelist = *((memoff_t *)block);
heap->ubytes += bsize;
} else {
if (size > heap->maxcont)


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/arm: upgrade I-pipe support

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: 2eae1185f359e6da8746333077d38e194352d805
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=2eae1185f359e6da8746333077d38e194352d805

Author: Philippe Gerum 
Date:   Fri Sep  9 18:55:43 2016 +0200

cobalt/arm: upgrade I-pipe support

---

 ...arm-9.patch => ipipe-core-3.18.20-arm-11.patch} |  342 +-
 ...8-arm-4.patch => ipipe-core-4.1.18-arm-8.patch} |  487 +++-
 2 files changed, 704 insertions(+), 125 deletions(-)

diff --git a/kernel/cobalt/arch/arm/patches/ipipe-core-3.18.20-arm-9.patch 
b/kernel/cobalt/arch/arm/patches/ipipe-core-3.18.20-arm-11.patch
similarity index 98%
rename from kernel/cobalt/arch/arm/patches/ipipe-core-3.18.20-arm-9.patch
rename to kernel/cobalt/arch/arm/patches/ipipe-core-3.18.20-arm-11.patch
index d594401..efe7c8f 100644
--- a/kernel/cobalt/arch/arm/patches/ipipe-core-3.18.20-arm-9.patch
+++ b/kernel/cobalt/arch/arm/patches/ipipe-core-3.18.20-arm-11.patch
@@ -1,5 +1,5 @@
 diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
-index 89c4b5c..46ec8f8 100644
+index 89c4b5c..6b13805 100644
 --- a/arch/arm/Kconfig
 +++ b/arch/arm/Kconfig
 @@ -33,8 +33,8 @@ config ARM
@@ -80,6 +80,14 @@ index 89c4b5c..46ec8f8 100644
  source kernel/Kconfig.preempt
  
  config HZ_FIXED
+@@ -1741,6 +1760,7 @@ config ALIGNMENT_TRAP
+ config UACCESS_WITH_MEMCPY
+   bool "Use kernel mem{cpy,set}() for {copy_to,clear}_user()"
+   depends on MMU
++  depends on !IPIPE
+   default y if CPU_FEROCEON
+   help
+ Implement faster copy_to_user and clear_user methods for CPU
 diff --git a/arch/arm/boot/compressed/decompress.c 
b/arch/arm/boot/compressed/decompress.c
 index bd245d3..65f2238 100644
 --- a/arch/arm/boot/compressed/decompress.c
@@ -1653,7 +1661,7 @@ index bb28af7..780ca50 100644
  static inline void sp804_clockevents_init(void __iomem *base, unsigned int 
irq, const char *name)
 diff --git a/arch/arm/include/asm/ipipe.h b/arch/arm/include/asm/ipipe.h
 new file mode 100644
-index 000..d1c125d
+index 000..5ec5eff
 --- /dev/null
 +++ b/arch/arm/include/asm/ipipe.h
 @@ -0,0 +1,272 @@
@@ -1701,7 +1709,7 @@ index 000..d1c125d
 +#include 
 +#include 
 +
-+#define IPIPE_CORE_RELEASE9
++#define IPIPE_CORE_RELEASE11
 +
 +struct ipipe_domain;
 +
@@ -4301,10 +4309,10 @@ index 000..8024a79
 +EXPORT_SYMBOL_GPL(cpu_architecture);
 diff --git a/arch/arm/kernel/ipipe_tsc.c b/arch/arm/kernel/ipipe_tsc.c
 new file mode 100644
-index 000..414ada5
+index 000..6bcabb3
 --- /dev/null
 +++ b/arch/arm/kernel/ipipe_tsc.c
-@@ -0,0 +1,203 @@
+@@ -0,0 +1,207 @@
 +#include 
 +#include 
 +#include 
@@ -4378,6 +4386,10 @@ index 000..414ada5
 +  tsc_addr = &__ipipe_tsc_addr;
 +#endif
 +  registered = ipipe_tsc_value != NULL;
++
++  if (registered && info->freq < tsc_info.freq)
++  return;
++
 +  ipipe_tsc_value = (struct ipipe_tsc_value_t *)tsc_area;
 +  vector_tsc_value = (struct ipipe_tsc_value_t *)__ipipe_tsc_area;
 +
@@ -7090,7 +7102,7 @@ index 5211f62..c0a8610 100644
platform_device_register_simple("imx31-audmux", 0, imx25_audmux_res,
ARRAY_SIZE(imx25_audmux_res));
 diff --git a/arch/arm/mach-imx/mm-imx27.c b/arch/arm/mach-imx/mm-imx27.c
-index 7d82a5a..9bbd0f4 100644
+index 7d82a5a5..9bbd0f4 100644
 --- a/arch/arm/mach-imx/mm-imx27.c
 +++ b/arch/arm/mach-imx/mm-imx27.c
 @@ -81,6 +81,10 @@ static const struct resource imx27_audmux_res[] __initconst 
= {
@@ -12308,6 +12320,85 @@ index 9f06825..1087ed1 100644
irq_find_mapping(d->irq_domain,
 d->chip.base + bit));
}
+diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c
+index a93ddbc..7c74176 100644
+--- a/drivers/gpio/gpio-mvebu.c
 b/drivers/gpio/gpio-mvebu.c
+@@ -295,10 +295,11 @@ static void mvebu_gpio_irq_ack(struct irq_data *d)
+   struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
+   struct mvebu_gpio_chip *mvchip = gc->private;
+   u32 mask = ~(1 << (d->irq - gc->irq_base));
++  unsigned long flags;
+ 
+-  irq_gc_lock(gc);
++  flags = irq_gc_lock(gc);
+   writel_relaxed(mask, mvebu_gpioreg_edge_cause(mvchip));
+-  irq_gc_unlock(gc);
++  irq_gc_unlock(gc, flags);
+ }
+ 
+ static void mvebu_gpio_edge_irq_mask(struct irq_data *d)
+@@ -307,12 +308,13 @@ static void mvebu_gpio_edge_irq_mask(struct irq_data *d)
+   struct mvebu_gpio_chip *mvchip = gc->private;
+   struct irq_chip_type *ct = irq_data_get_chip_type(d);
+   u32 mask = 1 << (d->irq - gc->irq_base);
++  unsigned long flags;
+ 
+-  irq_gc_lock(gc);
++  flags = irq_gc_lock(gc);
+   ct->mask_cache_priv &= ~mask;
+ 
+   writel_relaxed(ct->mask_cache_priv, mvebu_gpioreg_edge_mask(mvchip));
+-  irq_gc_unlock(gc);
++  irq_gc_unlock(gc, flags);
+ }
+ 
+ static void 

[Xenomai-git] Philippe Gerum : config: bump version code

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: 1f465de48fb93c7bccf58454798c52a6a6bfaa7e
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=1f465de48fb93c7bccf58454798c52a6a6bfaa7e

Author: Philippe Gerum 
Date:   Fri Sep  9 19:04:10 2016 +0200

config: bump version code

---

 config/version-code  |2 +-
 config/version-label |2 +-
 config/version-name  |2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/config/version-code b/config/version-code
index b502146..75a22a2 100644
--- a/config/version-code
+++ b/config/version-code
@@ -1 +1 @@
-3.0.2
+3.0.3
diff --git a/config/version-label b/config/version-label
index b502146..75a22a2 100644
--- a/config/version-label
+++ b/config/version-label
@@ -1 +1 @@
-3.0.2
+3.0.3
diff --git a/config/version-name b/config/version-name
index 272395d..09ba594 100644
--- a/config/version-name
+++ b/config/version-name
@@ -1 +1 @@
-Exact Zero
+Groovy Cosmic Halo


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : boilerplate/bootstrap: do not override main() in PIC mode

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: 82b63250083ea00f868f615a50d25256f3e219be
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=82b63250083ea00f868f615a50d25256f3e219be

Author: Philippe Gerum 
Date:   Wed Sep 21 15:38:07 2016 +0200

boilerplate/bootstrap: do not override main() in PIC mode

The PIC version of the bootstrap module is intended to be part of
shared libraries which want to enable Xenomai's auto-init feature when
loaded (i.e. dlopened).

Therefore, overriding the main() entry point is meaningless in such
context, assuming the latter should be defined in the main executable
instead.

---

 lib/boilerplate/init/bootstrap.c |4 
 1 file changed, 4 insertions(+)

diff --git a/lib/boilerplate/init/bootstrap.c b/lib/boilerplate/init/bootstrap.c
index 119b405..b0d4a12 100644
--- a/lib/boilerplate/init/bootstrap.c
+++ b/lib/boilerplate/init/bootstrap.c
@@ -28,6 +28,8 @@ static char *const *early_argv;
 
 const int xenomai_auto_bootstrap = 1;
 
+#ifndef __PIC__
+
 int __real_main(int argc, char *const argv[]);
 
 int __wrap_main(int argc, char *const argv[])
@@ -43,6 +45,8 @@ int xenomai_main(int argc, char *const argv[])
return __real_main(argc, argv);
 }
 
+#endif /* !__PIC__ */
+
 __bootstrap_ctor static void xenomai_bootstrap(void)
 {
char *arglist, *argend, *p, **v, *const *argv;


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/x86: upgrade I-pipe support

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: be6f3c41769cacbcfa9efc9add46543be0d09bde
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=be6f3c41769cacbcfa9efc9add46543be0d09bde

Author: Philippe Gerum 
Date:   Fri Sep  9 19:00:22 2016 +0200

cobalt/x86: upgrade I-pipe support

---

 ...-x86-6.patch => ipipe-core-3.18.20-x86-8.patch} |   79 +++--
 ...8-x86-3.patch => ipipe-core-4.1.18-x86-7.patch} |  313 +++-
 2 files changed, 302 insertions(+), 90 deletions(-)

diff --git a/kernel/cobalt/arch/x86/patches/ipipe-core-3.18.20-x86-6.patch 
b/kernel/cobalt/arch/x86/patches/ipipe-core-3.18.20-x86-8.patch
similarity index 99%
rename from kernel/cobalt/arch/x86/patches/ipipe-core-3.18.20-x86-6.patch
rename to kernel/cobalt/arch/x86/patches/ipipe-core-3.18.20-x86-8.patch
index 128c382..51ebf67 100644
--- a/kernel/cobalt/arch/x86/patches/ipipe-core-3.18.20-x86-6.patch
+++ b/kernel/cobalt/arch/x86/patches/ipipe-core-3.18.20-x86-8.patch
@@ -449,7 +449,7 @@ index 615fa90..e0a62ab 100644
  extern void default_send_IPI_mask_sequence_phys(const struct cpumask *mask,
 diff --git a/arch/x86/include/asm/ipipe.h b/arch/x86/include/asm/ipipe.h
 new file mode 100644
-index 000..ccc8945
+index 000..12305ff
 --- /dev/null
 +++ b/arch/x86/include/asm/ipipe.h
 @@ -0,0 +1,118 @@
@@ -479,7 +479,7 @@ index 000..ccc8945
 +
 +#ifdef CONFIG_IPIPE
 +
-+#define IPIPE_CORE_RELEASE6
++#define IPIPE_CORE_RELEASE8
 +
 +struct ipipe_domain;
 +struct pt_regs;
@@ -3426,10 +3426,10 @@ index e7cc537..bc5e8f8 100644
  handle_real_irq:
 diff --git a/arch/x86/kernel/ipipe.c b/arch/x86/kernel/ipipe.c
 new file mode 100644
-index 000..a06e6bb
+index 000..d756d17
 --- /dev/null
 +++ b/arch/x86/kernel/ipipe.c
-@@ -0,0 +1,499 @@
+@@ -0,0 +1,504 @@
 +/*   -*- linux-c -*-
 + *   linux/arch/x86/kernel/ipipe.c
 + *
@@ -3465,6 +3465,7 @@ index 000..a06e6bb
 +#include 
 +#include 
 +#include 
++#include 
 +#include 
 +#include 
 +#include 
@@ -3929,6 +3930,10 @@ index 000..a06e6bb
 +#if defined(CONFIG_CC_STACKPROTECTOR) && defined(CONFIG_X86_64)
 +EXPORT_PER_CPU_SYMBOL_GPL(irq_stack_union);
 +#endif
++
++#if defined(CONFIG_TRACEPOINTS) && defined(CONFIG_IPIPE_LEGACY)
++EXPORT_TRACEPOINT_SYMBOL_GPL(tlb_flush);
++#endif
 diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
 index 3790775..218eb83 100644
 --- a/arch/x86/kernel/irq.c
@@ -5831,6 +5836,18 @@ index abcafaa..a8440e4 100644
  } cacheline_aligned;
  
  /*
+diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
+index 662697b..6a9b6ad 100644
+--- a/include/linux/ftrace.h
 b/include/linux/ftrace.h
+@@ -108,6 +108,7 @@ enum {
+   FTRACE_OPS_FL_ADDING= 1 << 9,
+   FTRACE_OPS_FL_REMOVING  = 1 << 10,
+   FTRACE_OPS_FL_MODIFYING = 1 << 11,
++  FTRACE_OPS_FL_IPIPE_EXCLUSIVE   = 1 << 12,
+ };
+ 
+ #ifdef CONFIG_DYNAMIC_FTRACE
 diff --git a/include/linux/hardirq.h b/include/linux/hardirq.h
 index cba442e..b513a46 100644
 --- a/include/linux/hardirq.h
@@ -11776,7 +11793,7 @@ index 000..143f9e6
 +#endif /* CONFIG_IPIPE_HAVE_HOSTRT */
 diff --git a/kernel/ipipe/tracer.c b/kernel/ipipe/tracer.c
 new file mode 100644
-index 000..da272c50
+index 000..8388671
 --- /dev/null
 +++ b/kernel/ipipe/tracer.c
 @@ -0,0 +1,1468 @@
@@ -13114,7 +13131,7 @@ index 000..da272c50
 +
 +static struct ftrace_ops ipipe_trace_ops = {
 +  .func = ipipe_trace_function,
-+  .flags = FTRACE_OPS_FL_RECURSION_SAFE,
++  .flags = FTRACE_OPS_FL_IPIPE_EXCLUSIVE,
 +};
 +
 +static ssize_t __ipipe_wr_enable(struct file *file, const char __user *buffer,
@@ -14675,7 +14692,7 @@ index a5da09c..6650799 100644
help
  This option will modify all the calls to function tracing
 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
-index d1eff3d..2a324bc 100644
+index d1eff3d..f8b9472 100644
 --- a/kernel/trace/ftrace.c
 +++ b/kernel/trace/ftrace.c
 @@ -32,6 +32,7 @@
@@ -14686,7 +14703,33 @@ index d1eff3d..2a324bc 100644
  
  #include 
  
-@@ -2298,6 +2299,9 @@ void __weak arch_ftrace_update_code(int command)
+@@ -251,8 +252,17 @@ static inline void update_function_graph_func(void) { }
+ 
+ static void update_ftrace_function(void)
+ {
++  struct ftrace_ops *ops;
+   ftrace_func_t func;
+ 
++  for (ops = ftrace_ops_list;
++   ops != _list_end; ops = ops->next)
++  if (ops->flags & FTRACE_OPS_FL_IPIPE_EXCLUSIVE) {
++  set_function_trace_op = ops;
++  func = ops->func;
++  goto set_pointers;
++  }
++
+   /*
+* Prepare the ftrace_ops that the arch callback will use.
+* If there's only one ftrace_ops registered, the ftrace_ops_list
+@@ -280,6 +290,7 @@ static void update_ftrace_function(void)
+ 
+   update_function_graph_func();
+ 
++  set_pointers:
+   /* If there's no change, then do nothing more here */
+   

[Xenomai-git] Philippe Gerum : boilerplate/ancillaries: fix unique name generation in pshared mode

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: e539ab0b1db5ca56f8d3db39d2ca0bdf009c9b25
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=e539ab0b1db5ca56f8d3db39d2ca0bdf009c9b25

Author: Philippe Gerum 
Date:   Tue Sep 13 09:36:11 2016 +0200

boilerplate/ancillaries: fix unique name generation in pshared mode

---

 lib/boilerplate/ancillaries.c |4 
 1 file changed, 4 insertions(+)

diff --git a/lib/boilerplate/ancillaries.c b/lib/boilerplate/ancillaries.c
index a811a40..0f469a4 100644
--- a/lib/boilerplate/ancillaries.c
+++ b/lib/boilerplate/ancillaries.c
@@ -231,7 +231,11 @@ char *generate_name(char *buf, const char *radix,
buf[len] = '\0';
} else {
tag = atomic_add_fetch(>serial, 1);
+#ifdef CONFIG_XENO_PSHARED
+   snprintf(buf, len, "%s@%d[%d]", ngen->radix, tag, __node_id);
+#else
snprintf(buf, len, "%s@%d", ngen->radix, tag);
+#endif
}
 
return buf;


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/blackfin: upgrade I-pipe support

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: 2111a07350c4651f34c9d4972d7c06f63e1eb077
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=2111a07350c4651f34c9d4972d7c06f63e1eb077

Author: Philippe Gerum 
Date:   Fri Sep  9 18:58:13 2016 +0200

cobalt/blackfin: upgrade I-pipe support

---

 ...6.patch => ipipe-core-3.18.20-blackfin-8.patch} |   70 +++--
 ...-2.patch => ipipe-core-4.1.18-blackfin-6.patch} |  298 +++-
 2 files changed, 282 insertions(+), 86 deletions(-)

diff --git 
a/kernel/cobalt/arch/blackfin/patches/ipipe-core-3.18.20-blackfin-6.patch 
b/kernel/cobalt/arch/blackfin/patches/ipipe-core-3.18.20-blackfin-8.patch
similarity index 99%
rename from 
kernel/cobalt/arch/blackfin/patches/ipipe-core-3.18.20-blackfin-6.patch
rename to 
kernel/cobalt/arch/blackfin/patches/ipipe-core-3.18.20-blackfin-8.patch
index 6ecaf7f..e5d0f88 100644
--- a/kernel/cobalt/arch/blackfin/patches/ipipe-core-3.18.20-blackfin-6.patch
+++ b/kernel/cobalt/arch/blackfin/patches/ipipe-core-3.18.20-blackfin-8.patch
@@ -12,7 +12,7 @@ index af76634..ebff376 100644
  
  comment "Processor and Board Settings"
 diff --git a/arch/blackfin/include/asm/ipipe.h 
b/arch/blackfin/include/asm/ipipe.h
-index fe1160f..cc10543 100644
+index fe1160fb..44ed44e 100644
 --- a/arch/blackfin/include/asm/ipipe.h
 +++ b/arch/blackfin/include/asm/ipipe.h
 @@ -28,7 +28,7 @@
@@ -32,7 +32,7 @@ index fe1160f..cc10543 100644
 -#define IPIPE_MAJOR_NUMBER1
 -#define IPIPE_MINOR_NUMBER16
 -#define IPIPE_PATCH_NUMBER1
-+#define IPIPE_CORE_RELEASE6
++#define IPIPE_CORE_RELEASE8
  
  #ifdef CONFIG_SMP
  #error "I-pipe/blackfin: SMP not implemented"
@@ -2214,6 +2214,18 @@ index abcafaa..a8440e4 100644
  } cacheline_aligned;
  
  /*
+diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
+index 662697b..6a9b6ad 100644
+--- a/include/linux/ftrace.h
 b/include/linux/ftrace.h
+@@ -108,6 +108,7 @@ enum {
+   FTRACE_OPS_FL_ADDING= 1 << 9,
+   FTRACE_OPS_FL_REMOVING  = 1 << 10,
+   FTRACE_OPS_FL_MODIFYING = 1 << 11,
++  FTRACE_OPS_FL_IPIPE_EXCLUSIVE   = 1 << 12,
+ };
+ 
+ #ifdef CONFIG_DYNAMIC_FTRACE
 diff --git a/include/linux/hardirq.h b/include/linux/hardirq.h
 index cba442e..b513a46 100644
 --- a/include/linux/hardirq.h
@@ -8159,7 +8171,7 @@ index 000..143f9e6
 +#endif /* CONFIG_IPIPE_HAVE_HOSTRT */
 diff --git a/kernel/ipipe/tracer.c b/kernel/ipipe/tracer.c
 new file mode 100644
-index 000..da272c50
+index 000..8388671
 --- /dev/null
 +++ b/kernel/ipipe/tracer.c
 @@ -0,0 +1,1468 @@
@@ -9497,7 +9509,7 @@ index 000..da272c50
 +
 +static struct ftrace_ops ipipe_trace_ops = {
 +  .func = ipipe_trace_function,
-+  .flags = FTRACE_OPS_FL_RECURSION_SAFE,
++  .flags = FTRACE_OPS_FL_IPIPE_EXCLUSIVE,
 +};
 +
 +static ssize_t __ipipe_wr_enable(struct file *file, const char __user *buffer,
@@ -11058,7 +11070,7 @@ index a5da09c..6650799 100644
help
  This option will modify all the calls to function tracing
 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
-index d1eff3d..2a324bc 100644
+index d1eff3d..f8b9472 100644
 --- a/kernel/trace/ftrace.c
 +++ b/kernel/trace/ftrace.c
 @@ -32,6 +32,7 @@
@@ -11069,7 +11081,33 @@ index d1eff3d..2a324bc 100644
  
  #include 
  
-@@ -2298,6 +2299,9 @@ void __weak arch_ftrace_update_code(int command)
+@@ -251,8 +252,17 @@ static inline void update_function_graph_func(void) { }
+ 
+ static void update_ftrace_function(void)
+ {
++  struct ftrace_ops *ops;
+   ftrace_func_t func;
+ 
++  for (ops = ftrace_ops_list;
++   ops != _list_end; ops = ops->next)
++  if (ops->flags & FTRACE_OPS_FL_IPIPE_EXCLUSIVE) {
++  set_function_trace_op = ops;
++  func = ops->func;
++  goto set_pointers;
++  }
++
+   /*
+* Prepare the ftrace_ops that the arch callback will use.
+* If there's only one ftrace_ops registered, the ftrace_ops_list
+@@ -280,6 +290,7 @@ static void update_ftrace_function(void)
+ 
+   update_function_graph_func();
+ 
++  set_pointers:
+   /* If there's no change, then do nothing more here */
+   if (ftrace_trace_function == func)
+   return;
+@@ -2298,6 +2309,9 @@ void __weak arch_ftrace_update_code(int command)
  
  static void ftrace_run_update_code(int command)
  {
@@ -11079,7 +7,7 @@ index d1eff3d..2a324bc 100644
int ret;
  
ret = ftrace_arch_code_modify_prepare();
-@@ -2311,7 +2315,13 @@ static void ftrace_run_update_code(int command)
+@@ -2311,7 +2325,13 @@ static void ftrace_run_update_code(int command)
 * is safe. The stop_machine() is the safest, but also
 * produces the most overhead.
 */
@@ -11093,7 +11131,7 @@ index d1eff3d..2a324bc 100644
  
ret = ftrace_arch_code_modify_post_process();
FTRACE_WARN_ON(ret);
-@@ -4621,10 

[Xenomai-git] Philippe Gerum : cobalt/powerpc: upgrade I-pipe support

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: b88368afe7545b6900660785b1cb131d68e72839
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=b88368afe7545b6900660785b1cb131d68e72839

Author: Philippe Gerum 
Date:   Fri Sep  9 18:59:32 2016 +0200

cobalt/powerpc: upgrade I-pipe support

---

 ...-6.patch => ipipe-core-3.18.20-powerpc-8.patch} |   94 +-
 ...c-3.patch => ipipe-core-4.1.18-powerpc-7.patch} | 1133 +++-
 2 files changed, 924 insertions(+), 303 deletions(-)

diff --git 
a/kernel/cobalt/arch/powerpc/patches/ipipe-core-3.18.20-powerpc-6.patch 
b/kernel/cobalt/arch/powerpc/patches/ipipe-core-3.18.20-powerpc-8.patch
similarity index 99%
rename from 
kernel/cobalt/arch/powerpc/patches/ipipe-core-3.18.20-powerpc-6.patch
rename to kernel/cobalt/arch/powerpc/patches/ipipe-core-3.18.20-powerpc-8.patch
index a3792aa..f92259f 100644
--- a/kernel/cobalt/arch/powerpc/patches/ipipe-core-3.18.20-powerpc-6.patch
+++ b/kernel/cobalt/arch/powerpc/patches/ipipe-core-3.18.20-powerpc-8.patch
@@ -304,7 +304,7 @@ index b59ac27..9cc1d25 100644
   * or should we not care like we do now ? --BenH.
 diff --git a/arch/powerpc/include/asm/ipipe.h 
b/arch/powerpc/include/asm/ipipe.h
 new file mode 100644
-index 000..f79050e
+index 000..40aca5b
 --- /dev/null
 +++ b/arch/powerpc/include/asm/ipipe.h
 @@ -0,0 +1,157 @@
@@ -349,7 +349,7 @@ index 000..f79050e
 +#include 
 +#include 
 +
-+#define IPIPE_CORE_RELEASE6
++#define IPIPE_CORE_RELEASE8
 +
 +struct ipipe_domain;
 +
@@ -1640,7 +1640,7 @@ index 22b45a4..e973007 100644
   * PROM code for specific machines follows.  Put it
   * here so it's easy to add arch-specific sections later.
 diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
-index 0905c8d..df2cc87 100644
+index 0905c8d..f9293c9 100644
 --- a/arch/powerpc/kernel/entry_64.S
 +++ b/arch/powerpc/kernel/entry_64.S
 @@ -33,6 +33,7 @@
@@ -1879,25 +1879,21 @@ index 0905c8d..df2cc87 100644
  #endif /* CONFIG_PREEMPT */
  
.globl  fast_exc_return_irq
-@@ -751,6 +806,17 @@ restore:
+@@ -751,6 +806,13 @@ restore:
 * are about to re-enable interrupts
 */
ld  r5,SOFTE(r1)
 +#ifdef CONFIG_IPIPE
-+  cmpwi   cr0,r5,0
-+  nor r5,r5,r5/* IPIPE_STALL_FLAG = !SOFTE */
 +  ld  r4,PACAROOTPCPU(r13)
-+  ld  r3,0(r4)
-+  insrdi  r3,r5,1,63
-+  std r3,0(r4)
-+  beq 1f
++  cmpwi   cr0,r4,0
++  bne 1f
 +  TRACE_ENABLE_INTS
 +1:
 +#else /* !CONFIG_IPIPE */
lbz r6,PACASOFTIRQEN(r13)
cmpwi   cr0,r5,0
beq restore_irq_off
-@@ -777,6 +843,7 @@ restore_no_replay:
+@@ -777,6 +839,7 @@ restore_no_replay:
TRACE_ENABLE_INTS
li  r0,1
stb r0,PACASOFTIRQEN(r13);
@@ -1905,7 +1901,7 @@ index 0905c8d..df2cc87 100644
  
/*
 * Final return path. BookE is handled in a different file
-@@ -867,6 +934,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR)
+@@ -867,6 +930,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR)
  
  #endif /* CONFIG_PPC_BOOK3E */
  
@@ -1913,7 +1909,7 @@ index 0905c8d..df2cc87 100644
/*
 * We are returning to a context with interrupts soft disabled.
 *
-@@ -948,6 +1016,8 @@ restore_check_irq_replay:
+@@ -948,6 +1012,8 @@ restore_check_irq_replay:
b   ret_from_except
  #endif /* CONFIG_PPC_DOORBELL */
  1:b   ret_from_except /* What else to do here ? */
@@ -1922,7 +1918,7 @@ index 0905c8d..df2cc87 100644
   
  unrecov_restore:
addir3,r1,STACK_FRAME_OVERHEAD
-@@ -994,7 +1064,7 @@ _GLOBAL(enter_rtas)
+@@ -994,7 +1060,7 @@ _GLOBAL(enter_rtas)
li  r0,0
mtcrr0
  
@@ -2835,7 +2831,7 @@ index 000..292fed5
 +#endif/* !CONFIG_PPC64 */
 +#endif /* !CONFIG_IPIPE_LEGACY */
 diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
-index c143835..6b92a8b 100644
+index c143835..82279ee 100644
 --- a/arch/powerpc/kernel/irq.c
 +++ b/arch/powerpc/kernel/irq.c
 @@ -95,6 +95,36 @@ extern int tau_interrupts(int);
@@ -2867,7 +2863,7 @@ index c143835..6b92a8b 100644
 +static inline notrace int decrementer_check_overflow(void)
 +{
 +  u64 now = get_tb_or_rtc();
-+  u64 *next_tb = &__get_cpu_var(decrementers_next_tb);
++  u64 *next_tb = this_cpu_ptr(_next_tb);
 + 
 +  return now >= *next_tb;
 +}
@@ -6004,6 +6000,18 @@ index abcafaa..a8440e4 100644
  } cacheline_aligned;
  
  /*
+diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
+index 662697b..6a9b6ad 100644
+--- a/include/linux/ftrace.h
 b/include/linux/ftrace.h
+@@ -108,6 +108,7 @@ enum {
+   FTRACE_OPS_FL_ADDING= 1 << 9,
+   FTRACE_OPS_FL_REMOVING  = 1 << 10,
+   FTRACE_OPS_FL_MODIFYING = 1 << 11,
++  FTRACE_OPS_FL_IPIPE_EXCLUSIVE   = 1 << 12,
+ };
+ 
+ #ifdef CONFIG_DYNAMIC_FTRACE
 diff --git a/include/linux/hardirq.h b/include/linux/hardirq.h
 index 

[Xenomai-git] Philippe Gerum : cobalt/arm: fpu: drop obsolete xnarch_save_fpu()

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: 37253b634f258a1de3ee29f93a9b6a133a7391b0
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=37253b634f258a1de3ee29f93a9b6a133a7391b0

Author: Philippe Gerum 
Date:   Thu Sep  8 16:29:54 2016 +0200

cobalt/arm: fpu: drop obsolete xnarch_save_fpu()

---

 kernel/cobalt/arch/arm/include/asm/xenomai/thread.h |4 
 kernel/cobalt/arch/arm/thread.c |7 ---
 2 files changed, 11 deletions(-)

diff --git a/kernel/cobalt/arch/arm/include/asm/xenomai/thread.h 
b/kernel/cobalt/arch/arm/include/asm/xenomai/thread.h
index 3e332b2..bfe0b9c 100644
--- a/kernel/cobalt/arch/arm/include/asm/xenomai/thread.h
+++ b/kernel/cobalt/arch/arm/include/asm/xenomai/thread.h
@@ -89,8 +89,6 @@ int xnarch_fault_fpu_p(struct ipipe_trap_data *d);
 
 void xnarch_leave_root(struct xnthread *root);
 
-void xnarch_save_fpu(struct xnthread *thread);
-
 void xnarch_switch_fpu(struct xnthread *from, struct xnthread *thread);
 
 int xnarch_handle_fpu_fault(struct xnthread *from, 
@@ -113,8 +111,6 @@ static inline int xnarch_fault_fpu_p(struct ipipe_trap_data 
*d)
 
 static inline void xnarch_leave_root(struct xnthread *root) { }
 
-static inline void xnarch_save_fpu(struct xnthread *thread) { }
-
 static inline void xnarch_switch_fpu(struct xnthread *f, struct xnthread *t) { 
}
 
 static inline int xnarch_handle_fpu_fault(struct xnthread *from, 
diff --git a/kernel/cobalt/arch/arm/thread.c b/kernel/cobalt/arch/arm/thread.c
index 7e2b7cf..5224218 100644
--- a/kernel/cobalt/arch/arm/thread.c
+++ b/kernel/cobalt/arch/arm/thread.c
@@ -211,13 +211,6 @@ void xnarch_leave_root(struct xnthread *root)
rootcb->fpup = get_fpu_owner();
 }
 
-void xnarch_save_fpu(struct xnthread *thread)
-{
-   struct xnarchtcb *tcb = >tcb;
-   if (tcb->fpup)
-   __asm_vfp_save(tcb->fpup, do_enable_vfp());
-}
-
 void xnarch_switch_fpu(struct xnthread *from, struct xnthread *to)
 {
union vfp_state *const from_fpup = from ? from->tcb.fpup : NULL;


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/thread: fix race on accessing the global thread list

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: 203f2007e2c1328ca8847562ed3edbcb81d5e38a
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=203f2007e2c1328ca8847562ed3edbcb81d5e38a

Author: Philippe Gerum 
Date:   Wed Jun 29 09:54:12 2016 +0200

cobalt/thread: fix race on accessing the global thread list

nkthreadq is only used by the /proc interface handlers these days, to
get the list of active Cobalt threads.

Adding an emerging user-space thread to that list should not be done
before it is actually mated to a Cobalt shadow, otherwise the /proc
handlers might find such thread before its host_task pointer is known,
causing invalid memory accesses.

A simple way to reproduce the issue involves running a (user) thread
creation loop while continuously reading from /proc/xenomai/sched/* in
parallel.

The fix postpones the insertion of emerging threads into the global
thread queue until their TCB is fully built.

---

 kernel/cobalt/thread.c |   84 +++-
 1 file changed, 47 insertions(+), 37 deletions(-)

diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c
index e16f7a3..7daefdb 100644
--- a/kernel/cobalt/thread.c
+++ b/kernel/cobalt/thread.c
@@ -87,6 +87,13 @@ static void periodic_handler(struct xntimer *timer)
fixup_ptimer_affinity(thread);
 }
 
+static inline void enlist_new_thread(struct xnthread *thread)
+{  /* nklock held, irqs off */
+   list_add_tail(>glink, );
+   cobalt_nrthreads++;
+   xnvfile_touch_tag(_tag);
+}
+
 struct kthread_arg {
struct xnthread *thread;
struct completion *done;
@@ -557,10 +564,10 @@ void __xnthread_discard(struct xnthread *thread)
  * Initializes a new thread. The thread is left dormant until it is
  * actually started by xnthread_start().
  *
- * @param thread The address of a thread descriptor the nucleus will
- * use to store the thread-specific data.  This descriptor must always
- * be valid while the thread is active therefore it must be allocated
- * in permanent memory. @warning Some architectures may require the
+ * @param thread The address of a thread descriptor Cobalt will use to
+ * store the thread-specific data.  This descriptor must always be
+ * valid while the thread is active therefore it must be allocated in
+ * permanent memory. @warning Some architectures may require the
  * descriptor to be properly aligned in memory; this is an additional
  * reason for descriptors not to be laid in the program stack where
  * alignement constraints might not always be satisfied.
@@ -571,14 +578,13 @@ void __xnthread_discard(struct xnthread *thread)
  *
  * - name: An ASCII string standing for the symbolic name of the
  * thread. This name is copied to a safe place into the thread
- * descriptor. This name might be used in various situations by the
- * nucleus for issuing human-readable diagnostic messages, so it is
- * usually a good idea to provide a sensible value here.  NULL is fine
- * though and means "anonymous".
+ * descriptor. This name might be used in various situations by Cobalt
+ * for issuing human-readable diagnostic messages, so it is usually a
+ * good idea to provide a sensible value here.  NULL is fine though
+ * and means "anonymous".
  *
  * - flags: A set of creation flags affecting the operation. The
- * following flags can be part of this bitmask, each of them affecting
- * the nucleus behaviour regarding the created thread:
+ * following flags can be part of this bitmask:
  *
  *   - XNSUSP creates the thread in a suspended state. In such a case,
  * the thread shall be explicitly resumed using the xnthread_resume()
@@ -590,8 +596,8 @@ void __xnthread_discard(struct xnthread *thread)
  * user-space task. Otherwise, a new kernel host task is created, then
  * paired with the new Xenomai thread.
  *
- * - XNFPU (enable FPU) tells the nucleus that the new thread may use
- * the floating-point unit. XNFPU is implicitly assumed for user-space
+ * - XNFPU (enable FPU) tells Cobalt that the new thread may use the
+ * floating-point unit. XNFPU is implicitly assumed for user-space
  * threads even if not set in @a flags.
  *
  * - affinity: The processor affinity of this thread. Passing
@@ -620,7 +626,6 @@ int xnthread_init(struct xnthread *thread,
 {
struct xnsched *sched;
cpumask_t affinity;
-   spl_t s;
int ret;
 
if (attr->flags & ~(XNFPU | XNUSER | XNSUSP))
@@ -643,12 +648,6 @@ int xnthread_init(struct xnthread *thread,
 
trace_cobalt_thread_init(thread, attr, sched_class);
 
-   xnlock_get_irqsave(, s);
-   list_add_tail(>glink, );
-   cobalt_nrthreads++;
-   xnvfile_touch_tag(_tag);
-   xnlock_put_irqrestore(, s);
-
return 0;
 }
 EXPORT_SYMBOL_GPL(xnthread_init);
@@ -668,9 +667,8 @@ EXPORT_SYMBOL_GPL(xnthread_init);
  * execution properties of the new thread. Members of this structure
  * are defined as follows:
  *
- * - mode: The 

[Xenomai-git] Philippe Gerum : cobalt/powerpc: thread: move all TCB initializers out of line

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: d1ff8ae209e91b5cef29e46e0c1f8d89b3053fe8
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=d1ff8ae209e91b5cef29e46e0c1f8d89b3053fe8

Author: Philippe Gerum 
Date:   Fri Sep  9 16:07:54 2016 +0200

cobalt/powerpc: thread: move all TCB initializers out of line

Does not impact performances and fixes inclusion hell for pulling the
struct xnthread definition for good.

---

 kernel/cobalt/arch/powerpc/include/asm/xenomai/thread.h |   12 ++--
 kernel/cobalt/arch/powerpc/thread.c |   12 
 2 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/kernel/cobalt/arch/powerpc/include/asm/xenomai/thread.h 
b/kernel/cobalt/arch/powerpc/include/asm/xenomai/thread.h
index 1de5cac..0ab48be 100644
--- a/kernel/cobalt/arch/powerpc/include/asm/xenomai/thread.h
+++ b/kernel/cobalt/arch/powerpc/include/asm/xenomai/thread.h
@@ -52,17 +52,9 @@ static inline void xnarch_enter_root(struct xnthread *root) 
{ }
 
 #ifdef CONFIG_XENO_ARCH_FPU
 
-static inline void xnarch_init_root_tcb(struct xnthread *thread)
-{
-   struct xnarchtcb *tcb = xnthread_archtcb(thread);
-   tcb->fpup = NULL;
-}
+void xnarch_init_root_tcb(struct xnthread *thread);
 
-static inline void xnarch_init_shadow_tcb(struct xnthread *thread)
-{
-   struct xnarchtcb *tcb = xnthread_archtcb(thread);
-   tcb->fpup = >core.host_task->thread;
-}
+void xnarch_init_shadow_tcb(struct xnthread *thread);
 
 void xnarch_leave_root(struct xnthread *root);
 
diff --git a/kernel/cobalt/arch/powerpc/thread.c 
b/kernel/cobalt/arch/powerpc/thread.c
index e3be67f..062d33d 100644
--- a/kernel/cobalt/arch/powerpc/thread.c
+++ b/kernel/cobalt/arch/powerpc/thread.c
@@ -159,4 +159,16 @@ void xnarch_leave_root(struct xnthread *root)
>core.user_fpu_owner->thread : NULL;
 }
 
+void xnarch_init_root_tcb(struct xnthread *thread)
+{
+   struct xnarchtcb *tcb = >tcb;
+   tcb->fpup = NULL;
+}
+
+void xnarch_init_shadow_tcb(struct xnthread *thread)
+{
+   struct xnarchtcb *tcb = >tcb;
+   tcb->fpup = >core.host_task->thread;
+}
+
 #endif /* CONFIG_XENO_ARCH_FPU */


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : drivers/testing: drop unused context marker

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: 45eec71c67e1a4d26f0a00398101fd401dd7f293
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=45eec71c67e1a4d26f0a00398101fd401dd7f293

Author: Philippe Gerum 
Date:   Fri Jul  8 09:25:54 2016 +0200

drivers/testing: drop unused context marker

---

 include/rtdm/uapi/testing.h |1 -
 1 file changed, 1 deletion(-)

diff --git a/include/rtdm/uapi/testing.h b/include/rtdm/uapi/testing.h
index 76da5ee..5fddfae 100644
--- a/include/rtdm/uapi/testing.h
+++ b/include/rtdm/uapi/testing.h
@@ -83,7 +83,6 @@ struct rttst_swtest_error {
 
 #define RTTST_RTDM_NORMAL_CLOSE0
 #define RTTST_RTDM_DEFER_CLOSE_CONTEXT 1
-#define RTTST_RTDM_START_STOP_TASK 2
 
 #define RTIOC_TYPE_TESTING RTDM_CLASS_TESTING
 


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/kernel: use raw_spinlock* API to access IRQ pipeline locks

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: 18aaf9dbc07cf4857379fc6da0406bae33fc1b8b
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=18aaf9dbc07cf4857379fc6da0406bae33fc1b8b

Author: Philippe Gerum 
Date:   Fri Jul  8 15:04:01 2016 +0200

cobalt/kernel: use raw_spinlock* API to access IRQ pipeline locks

In order to cope with PREEMPT_RT_FULL, the spinlock* API should be
invoked for regular spin locks exclusively, so that those locks can be
handled by PREEMPT_RT's sleeping lock API seamlessly.

Since I-pipe locks are basically raw locks with hard IRQ management,
sticking to the raw_spinlock* API for them makes sense. The regular
spinlock* and raw_spinlock* APIs can be used indifferently for
manipulating IRQ pipeline locks (ipipe_spinlock_t) with the current
pipeline releases, so this change is backward compatible.

---

 include/cobalt/kernel/rtdm/driver.h |   10 +-
 kernel/cobalt/apc.c |   12 ++--
 kernel/cobalt/posix/process.c   |4 ++--
 3 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/include/cobalt/kernel/rtdm/driver.h 
b/include/cobalt/kernel/rtdm/driver.h
index 1133cca..0c7b62e 100644
--- a/include/cobalt/kernel/rtdm/driver.h
+++ b/include/cobalt/kernel/rtdm/driver.h
@@ -562,7 +562,7 @@ typedef unsigned long rtdm_lockctx_t;
  */
 static inline void rtdm_lock_init(rtdm_lock_t *lock)
 {
-   spin_lock_init(lock);
+   raw_spin_lock_init(lock);
 }
 
 /**
@@ -575,7 +575,7 @@ static inline void rtdm_lock_init(rtdm_lock_t *lock)
 static inline void rtdm_lock_get(rtdm_lock_t *lock)
 {
XENO_BUG_ON(COBALT, !spltest());
-   spin_lock(lock);
+   raw_spin_lock(lock);
xnsched_lock();
 }
 
@@ -588,7 +588,7 @@ static inline void rtdm_lock_get(rtdm_lock_t *lock)
  */
 static inline void rtdm_lock_put(rtdm_lock_t *lock)
 {
-   spin_unlock(lock);
+   raw_spin_unlock(lock);
xnsched_unlock();
 }
 
@@ -608,7 +608,7 @@ static inline rtdm_lockctx_t 
__rtdm_lock_get_irqsave(rtdm_lock_t *lock)
rtdm_lockctx_t context;
 
context = ipipe_test_and_stall_head();
-   spin_lock(lock);
+   raw_spin_lock(lock);
xnsched_lock();
 
return context;
@@ -625,7 +625,7 @@ static inline rtdm_lockctx_t 
__rtdm_lock_get_irqsave(rtdm_lock_t *lock)
 static inline
 void rtdm_lock_put_irqrestore(rtdm_lock_t *lock, rtdm_lockctx_t context)
 {
-   spin_unlock(lock);
+   raw_spin_unlock(lock);
xnsched_unlock();
ipipe_restore_head(context);
 }
diff --git a/kernel/cobalt/apc.c b/kernel/cobalt/apc.c
index 3383a26..97edcfc 100644
--- a/kernel/cobalt/apc.c
+++ b/kernel/cobalt/apc.c
@@ -55,7 +55,7 @@ void apc_dispatch(unsigned int virq, void *arg)
 * CPU, so that the handler is invoked on the same CPU than
 * the code which called xnapc_schedule().
 */
-   spin_lock(_lock);
+   raw_spin_lock(_lock);
 
/* This is atomic linux context (non-threaded IRQ). */
p = _cpu_ptr(_machine_cpudata)->apc_pending;
@@ -65,12 +65,12 @@ void apc_dispatch(unsigned int virq, void *arg)
handler = cobalt_pipeline.apc_table[apc].handler;
cookie = cobalt_pipeline.apc_table[apc].cookie;
raw_cpu_ptr(_machine_cpudata)->apc_shots[apc]++;
-   spin_unlock(_lock);
+   raw_spin_unlock(_lock);
handler(cookie);
-   spin_lock(_lock);
+   raw_spin_lock(_lock);
}
 
-   spin_unlock(_lock);
+   raw_spin_unlock(_lock);
 }
 
 /**
@@ -118,7 +118,7 @@ int xnapc_alloc(const char *name,
if (handler == NULL)
return -EINVAL;
 
-   spin_lock_irqsave(_lock, flags);
+   raw_spin_lock_irqsave(_lock, flags);
 
if (cobalt_pipeline.apc_map == ~0) {
apc = -EBUSY;
@@ -131,7 +131,7 @@ int xnapc_alloc(const char *name,
cobalt_pipeline.apc_table[apc].cookie = cookie;
cobalt_pipeline.apc_table[apc].name = name;
 out:
-   spin_unlock_irqrestore(_lock, flags);
+   raw_spin_unlock_irqrestore(_lock, flags);
 
return apc;
 }
diff --git a/kernel/cobalt/posix/process.c b/kernel/cobalt/posix/process.c
index 5c152e8..efd6b9e 100644
--- a/kernel/cobalt/posix/process.c
+++ b/kernel/cobalt/posix/process.c
@@ -969,7 +969,7 @@ static int handle_hostrt_event(struct ipipe_hostrt_data 
*hostrt)
 *   Linux kernel and against preemption by Xenomai
 * - The unsynced R/W block is for lockless read-only access.
 */
-   spin_lock_irqsave(&__hostrtlock, flags);
+   raw_spin_lock_irqsave(&__hostrtlock, flags);
 
unsynced_write_block(, >hostrt_data.lock) {
nkvdso->hostrt_data.live = 1;
@@ -983,7 +983,7 @@ static int handle_hostrt_event(struct ipipe_hostrt_data 
*hostrt)
nkvdso->hostrt_data.wtom_nsec = 
hostrt->wall_to_monotonic.tv_nsec;
}
 
-   spin_unlock_irqrestore(&__hostrtlock, flags);
+   

[Xenomai-git] Philippe Gerum : cobalt/rtdm: explain issues with driver registration

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: e5390e53816d947fc25b537b3ff772911d45e46d
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=e5390e53816d947fc25b537b3ff772911d45e46d

Author: Philippe Gerum 
Date:   Sat Jun 25 11:23:22 2016 +0200

cobalt/rtdm: explain issues with driver registration

---

 kernel/cobalt/rtdm/device.c |   22 ++
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/kernel/cobalt/rtdm/device.c b/kernel/cobalt/rtdm/device.c
index 07ad1a6..d0df7fa 100644
--- a/kernel/cobalt/rtdm/device.c
+++ b/kernel/cobalt/rtdm/device.c
@@ -272,27 +272,38 @@ static int register_driver(struct rtdm_driver *drv)
return 0;
}
 
-   if (drv->profile_info.magic != ~RTDM_CLASS_MAGIC)
+   if (drv->profile_info.magic != ~RTDM_CLASS_MAGIC) {
+   XENO_WARN_ON_ONCE(COBALT, 1);
return -EINVAL;
+   }
 
switch (drv->device_flags & RTDM_DEVICE_TYPE_MASK) {
case RTDM_NAMED_DEVICE:
case RTDM_PROTOCOL_DEVICE:
break;
default:
+   printk(XENO_WARNING "%s has invalid device type (%#x)\n",
+  drv->profile_info.name,
+  drv->device_flags & RTDM_DEVICE_TYPE_MASK);
return -EINVAL;
}
 
if (drv->device_count <= 0 ||
-   drv->device_count > RTDM_MAX_MINOR)
+   drv->device_count > RTDM_MAX_MINOR) {
+   printk(XENO_WARNING "%s has invalid device count (%d)\n",
+  drv->profile_info.name, drv->device_count);
return -EINVAL;
+   }
 
if ((drv->device_flags & RTDM_NAMED_DEVICE) == 0)
goto done;
 
if (drv->base_minor < 0 ||
-   drv->base_minor >= RTDM_MAX_MINOR)
+   drv->base_minor >= RTDM_MAX_MINOR) {
+   printk(XENO_WARNING "%s has invalid base minor (%d)\n",
+  drv->profile_info.name, drv->base_minor);
return -EINVAL;
+   }
 
ret = alloc_chrdev_region(, drv->base_minor, drv->device_count,
  drv->profile_info.name);
@@ -305,8 +316,11 @@ static int register_driver(struct rtdm_driver *drv)
 
cdev_init(>named.cdev, _dumb_fops);
ret = cdev_add(>named.cdev, rdev, drv->device_count);
-   if (ret)
+   if (ret) {
+   printk(XENO_WARNING "cannot create cdev series for %s\n",
+  drv->profile_info.name);
goto fail_cdev;
+   }
 
drv->named.major = MAJOR(rdev);
bitmap_zero(drv->minor_map, RTDM_MAX_MINOR);


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/arm: thread: move all TCB initializers out of line

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: f05ad9d1de19a2360e062b183915349241eb34da
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=f05ad9d1de19a2360e062b183915349241eb34da

Author: Philippe Gerum 
Date:   Fri Sep  9 16:07:54 2016 +0200

cobalt/arm: thread: move all TCB initializers out of line

Does not impact performances and fixes inclusion hell for pulling the
struct xnthread definition for good.

---

 kernel/cobalt/arch/arm/include/asm/xenomai/thread.h |6 +-
 kernel/cobalt/arch/arm/thread.c |7 +++
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/kernel/cobalt/arch/arm/include/asm/xenomai/thread.h 
b/kernel/cobalt/arch/arm/include/asm/xenomai/thread.h
index bfe0b9c..3ab9732 100644
--- a/kernel/cobalt/arch/arm/include/asm/xenomai/thread.h
+++ b/kernel/cobalt/arch/arm/include/asm/xenomai/thread.h
@@ -77,11 +77,7 @@ static inline int xnarch_escalate(void)
 
 #if defined(CONFIG_XENO_ARCH_FPU) && defined(CONFIG_VFP)
 
-static inline void xnarch_init_root_tcb(struct xnthread *thread)
-{
-   struct xnarchtcb *tcb = xnthread_archtcb(thread);
-   tcb->fpup = NULL;
-}
+void xnarch_init_root_tcb(struct xnthread *thread);
 
 void xnarch_init_shadow_tcb(struct xnthread *thread);
 
diff --git a/kernel/cobalt/arch/arm/thread.c b/kernel/cobalt/arch/arm/thread.c
index 5224218..d3c2fed 100644
--- a/kernel/cobalt/arch/arm/thread.c
+++ b/kernel/cobalt/arch/arm/thread.c
@@ -304,6 +304,13 @@ void xnarch_init_shadow_tcb(struct xnthread *thread)
/* XNFPU is set upon first FPU fault */
xnthread_clear_state(thread, XNFPU);
 }
+
+void xnarch_init_root_tcb(struct xnthread *thread)
+{
+   struct xnarchtcb *tcb = >tcb;
+   tcb->fpup = NULL;
+}
+
 #endif /* CONFIG_XENO_ARCH_FPU && CONFIG_VFP*/
 
 void xnarch_switch_to(struct xnthread *out, struct xnthread *in)


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/rtdm: leave mode selection to I/O syscall handlers

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: a96a6d8e2816914aea7580bfd1ca969487bf2b01
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=a96a6d8e2816914aea7580bfd1ca969487bf2b01

Author: Philippe Gerum 
Date:   Thu Jul  7 18:35:47 2016 +0200

cobalt/rtdm: leave mode selection to I/O syscall handlers

We don't want requests bearing invalid file descriptors (RTDM-wise) to
trigger any mode switch, so that RTDM requests on regular fildes can
be rejected with little overhead.

Tell the core to hand over mode selection to RTDM I/O syscall
handlers, which now check the file descriptor prior to triggering any
mode transition.

---

 kernel/cobalt/posix/io.c|   10 +--
 kernel/cobalt/posix/syscall32.c |4 +-
 kernel/cobalt/rtdm/fd.c |  144 +++
 3 files changed, 92 insertions(+), 66 deletions(-)

diff --git a/kernel/cobalt/posix/io.c b/kernel/cobalt/posix/io.c
index 7110d21..42b7b00 100644
--- a/kernel/cobalt/posix/io.c
+++ b/kernel/cobalt/posix/io.c
@@ -58,25 +58,25 @@ COBALT_SYSCALL(fcntl, current, (int fd, int cmd, int arg))
return rtdm_fd_fcntl(fd, cmd, arg);
 }
 
-COBALT_SYSCALL(ioctl, probing,
+COBALT_SYSCALL(ioctl, handover,
   (int fd, unsigned int request, void __user *arg))
 {
return rtdm_fd_ioctl(fd, request, arg);
 }
 
-COBALT_SYSCALL(read, probing,
+COBALT_SYSCALL(read, handover,
   (int fd, void __user *buf, size_t size))
 {
return rtdm_fd_read(fd, buf, size);
 }
 
-COBALT_SYSCALL(write, probing,
+COBALT_SYSCALL(write, handover,
   (int fd, const void __user *buf, size_t size))
 {
return rtdm_fd_write(fd, buf, size);
 }
 
-COBALT_SYSCALL(recvmsg, probing,
+COBALT_SYSCALL(recvmsg, handover,
   (int fd, struct user_msghdr __user *umsg, int flags))
 {
struct user_msghdr m;
@@ -93,7 +93,7 @@ COBALT_SYSCALL(recvmsg, probing,
return cobalt_copy_to_user(umsg, , sizeof(*umsg)) ?: ret;
 }
 
-COBALT_SYSCALL(sendmsg, probing,
+COBALT_SYSCALL(sendmsg, handover,
   (int fd, struct user_msghdr __user *umsg, int flags))
 {
struct user_msghdr m;
diff --git a/kernel/cobalt/posix/syscall32.c b/kernel/cobalt/posix/syscall32.c
index 0576b37..bc8b9d9 100644
--- a/kernel/cobalt/posix/syscall32.c
+++ b/kernel/cobalt/posix/syscall32.c
@@ -766,7 +766,7 @@ COBALT_SYSCALL32emu(select, nonrestartable,
return err;
 }
 
-COBALT_SYSCALL32emu(recvmsg, probing,
+COBALT_SYSCALL32emu(recvmsg, handover,
(int fd, struct compat_msghdr __user *umsg,
 int flags))
 {
@@ -784,7 +784,7 @@ COBALT_SYSCALL32emu(recvmsg, probing,
return sys32_put_msghdr(umsg, ) ?: ret;
 }
 
-COBALT_SYSCALL32emu(sendmsg, probing,
+COBALT_SYSCALL32emu(sendmsg, handover,
(int fd, struct compat_msghdr __user *umsg, int flags))
 {
struct user_msghdr m;
diff --git a/kernel/cobalt/rtdm/fd.c b/kernel/cobalt/rtdm/fd.c
index d82cfe4..3381dea 100644
--- a/kernel/cobalt/rtdm/fd.c
+++ b/kernel/cobalt/rtdm/fd.c
@@ -392,6 +392,44 @@ int rtdm_fd_fcntl(int ufd, int cmd, ...)
 }
 EXPORT_SYMBOL_GPL(rtdm_fd_fcntl);
 
+static struct rtdm_fd *get_fd_fixup_mode(int ufd)
+{
+   struct xnthread *thread;
+   struct rtdm_fd *fd;
+   
+   fd = rtdm_fd_get(ufd, 0);
+   if (IS_ERR(fd))
+   return fd;
+
+   /*
+* Mode is selected according to the following convention:
+*
+* - Cobalt threads must try running the syscall from primary
+* mode as a first attempt, regardless of their scheduling
+* class. The driver handler may ask for demoting the caller
+* to secondary mode by returning -ENOSYS.
+*
+* - Regular threads (i.e. not bound to Cobalt) may only run
+* the syscall from secondary mode.
+*/
+   thread = xnthread_current();
+   if (unlikely(ipipe_root_p)) {
+   if (thread == NULL ||
+   xnthread_test_localinfo(thread, XNDESCENT))
+   return fd;
+   } else if (likely(thread))
+   return fd;
+
+   /*
+* We need to switch to the converse mode. Since all callers
+* bear the "adaptive" tag, we just pass -ENOSYS back to the
+* syscall dispatcher to get switched to the next mode.
+*/
+   rtdm_fd_put(fd);
+
+   return ERR_PTR(-ENOSYS);
+}
+
 int rtdm_fd_ioctl(int ufd, unsigned int request, ...)
 {
struct rtdm_fd *fd;
@@ -399,16 +437,14 @@ int rtdm_fd_ioctl(int ufd, unsigned int request, ...)
va_list args;
int err, ret;
 
+   fd = get_fd_fixup_mode(ufd);
+   if (IS_ERR(fd))
+   return PTR_ERR(fd);
+
va_start(args, request);
arg = va_arg(args, void __user *);
va_end(args);
 
-   fd = rtdm_fd_get(ufd, 0);
-   if (IS_ERR(fd)) {
-   err = PTR_ERR(fd);
-   goto out;
-   }
-

[Xenomai-git] Philippe Gerum : cobalt/powerpc: add calibration value for CoreNet-based boards

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: c04e5dc6ce13183708404b067dca5aad8fabc7cd
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=c04e5dc6ce13183708404b067dca5aad8fabc7cd

Author: Philippe Gerum 
Date:   Sat Jul  9 12:32:03 2016 +0200

cobalt/powerpc: add calibration value for CoreNet-based boards

---

 kernel/cobalt/arch/powerpc/include/asm/xenomai/calibration.h |2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/cobalt/arch/powerpc/include/asm/xenomai/calibration.h 
b/kernel/cobalt/arch/powerpc/include/asm/xenomai/calibration.h
index e849e41..07dee5f 100644
--- a/kernel/cobalt/arch/powerpc/include/asm/xenomai/calibration.h
+++ b/kernel/cobalt/arch/powerpc/include/asm/xenomai/calibration.h
@@ -80,6 +80,8 @@ static inline void xnarch_get_latencies(struct 
xnclock_gravity *p)
  * Check for the most generic configs at the bottom of this list, so
  * that the most specific choices available are picked first.
  */
+#elif defined(CONFIG_CORENET_GENERIC)
+#define __sched_latency 2800
 #elif defined(CONFIG_MPC85xx) || defined(CONFIG_PPC_85xx)
 #define __sched_latency 1000
 #elif defined(CONFIG_405GPR)


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/powerpc: remove dependency on obsolete CONFIG_MATH_EMU

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: 34da16d96c6a171a31f51a8e078b411418380b47
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=34da16d96c6a171a31f51a8e078b411418380b47

Author: Philippe Gerum 
Date:   Mon Jul 11 15:42:01 2016 +0200

cobalt/powerpc: remove dependency on obsolete CONFIG_MATH_EMU

---

 kernel/cobalt/arch/powerpc/Kconfig |4 
 .../arch/powerpc/include/asm/xenomai/fptest.h  |   20 +++-
 2 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/kernel/cobalt/arch/powerpc/Kconfig 
b/kernel/cobalt/arch/powerpc/Kconfig
index ef49798..3e950f5 100644
--- a/kernel/cobalt/arch/powerpc/Kconfig
+++ b/kernel/cobalt/arch/powerpc/Kconfig
@@ -1,10 +1,6 @@
 source "kernel/xenomai/Kconfig"
 source "drivers/xenomai/Kconfig"
 
-config XENO_ARCH_MATH_EMU
-bool
-   default y if MATH_EMU || MATH_EMULATION
-
 config IPIPE_WANT_ACTIVE_MM
 bool
 
diff --git a/kernel/cobalt/arch/powerpc/include/asm/xenomai/fptest.h 
b/kernel/cobalt/arch/powerpc/include/asm/xenomai/fptest.h
index d99fa64..e907389 100644
--- a/kernel/cobalt/arch/powerpc/include/asm/xenomai/fptest.h
+++ b/kernel/cobalt/arch/powerpc/include/asm/xenomai/fptest.h
@@ -20,21 +20,23 @@
 #define _COBALT_POWERPC_ASM_FPTEST_H
 
 #include 
+#include 
 #include 
 
 static inline int fp_kernel_supported(void)
 {
+/*
+ * CAUTION: some architectures have a hardware FP unit, but a
+ * restricted set of supported FP instructions. Those may enable
+ * CONFIG_MATH_EMULATION and MATH_EMULATION_HW_UNIMPLEMENTED at the
+ * same time to provide an emulation of the missing instruction set.
+ */
 #ifdef CONFIG_PPC_FPU
return 1;
-#else  /* !CONFIG_PPC_FPU */
-#ifdef CONFIG_XENO_ARCH_MATH_EMU
-   static int once = 0;
-   if (!once) {
-   once = 1;
-   printk("Warning: math emulation code defined in kernel\n"
-  " no kernel-based FPU support for this 
platform\n");
-   }
-#endif /* !CONFIG_XENO_ARCH_MATH_EMU */
+#else
+#ifdef CONFIG_MATH_EMULATION
+   printk_once(XENO_WARN "kernel-based FPU support is disabled\n");
+#endif /* !CONFIG_MATH_EMULATION */
return 0;
 #endif /* !CONFIG_PPC_FPU */
 }


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/timer: prevent double dequeuing in overrun handler

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: bf4d5bd69f1ce74595e1d12716e07ef87d3ff69d
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=bf4d5bd69f1ce74595e1d12716e07ef87d3ff69d

Author: Philippe Gerum 
Date:   Fri Jul 15 17:25:49 2016 +0200

cobalt/timer: prevent double dequeuing in overrun handler

---

 kernel/cobalt/timer.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/cobalt/timer.c b/kernel/cobalt/timer.c
index c1a2081..1c79013 100644
--- a/kernel/cobalt/timer.c
+++ b/kernel/cobalt/timer.c
@@ -604,7 +604,8 @@ unsigned long long xntimer_get_overruns(struct xntimer 
*timer, xnticks_t now)
 
if (xntimer_running_p(timer)) {
q = xntimer_percpu_queue(timer);
-   xntimer_dequeue(timer, q);
+   if ((timer->status & XNTIMER_DEQUEUED) == 0)
+   xntimer_dequeue(timer, q);
while (xntimerh_date(>aplink) < now) {
timer->periodic_ticks++;
xntimer_update_date(timer);


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/timer: guard against invalid calls to get_overruns ()

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: ccbd3750c1af2c2e65e2d04e038f6a7bf194e5ca
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=ccbd3750c1af2c2e65e2d04e038f6a7bf194e5ca

Author: Philippe Gerum 
Date:   Sat Jul 16 16:25:07 2016 +0200

cobalt/timer: guard against invalid calls to get_overruns()

Calculating the number of overruns only makes sense with active
periodic timers exclusively, which must have been requeued for the
next delivery already.

---

 kernel/cobalt/timer.c |6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/kernel/cobalt/timer.c b/kernel/cobalt/timer.c
index 1c79013..3563636 100644
--- a/kernel/cobalt/timer.c
+++ b/kernel/cobalt/timer.c
@@ -593,6 +593,9 @@ unsigned long long xntimer_get_overruns(struct xntimer 
*timer, xnticks_t now)
xnsticks_t delta;
unsigned long long overruns = 0;
 
+   XENO_BUG_ON(COBALT, (timer->status &
+(XNTIMER_DEQUEUED|XNTIMER_PERIODIC)) != XNTIMER_PERIODIC);
+   
delta = now - xntimer_pexpect(timer);
if (unlikely(delta >= (xnsticks_t) period)) {
xntimerq_t *q;
@@ -604,8 +607,7 @@ unsigned long long xntimer_get_overruns(struct xntimer 
*timer, xnticks_t now)
 
if (xntimer_running_p(timer)) {
q = xntimer_percpu_queue(timer);
-   if ((timer->status & XNTIMER_DEQUEUED) == 0)
-   xntimer_dequeue(timer, q);
+   xntimer_dequeue(timer, q);
while (xntimerh_date(>aplink) < now) {
timer->periodic_ticks++;
xntimer_update_date(timer);


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/powerpc: fptest: include missing header

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: e6e56505438f07b17b6ea05767d9bc46bc80aa54
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=e6e56505438f07b17b6ea05767d9bc46bc80aa54

Author: Philippe Gerum 
Date:   Mon Jul 11 17:17:43 2016 +0200

cobalt/powerpc: fptest: include missing header

---

 kernel/cobalt/arch/powerpc/include/asm/xenomai/fptest.h |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/cobalt/arch/powerpc/include/asm/xenomai/fptest.h 
b/kernel/cobalt/arch/powerpc/include/asm/xenomai/fptest.h
index e907389..e09ca2c 100644
--- a/kernel/cobalt/arch/powerpc/include/asm/xenomai/fptest.h
+++ b/kernel/cobalt/arch/powerpc/include/asm/xenomai/fptest.h
@@ -35,7 +35,7 @@ static inline int fp_kernel_supported(void)
return 1;
 #else
 #ifdef CONFIG_MATH_EMULATION
-   printk_once(XENO_WARN "kernel-based FPU support is disabled\n");
+   printk_once(XENO_WARNING "kernel-based FPU support is disabled\n");
 #endif /* !CONFIG_MATH_EMULATION */
return 0;
 #endif /* !CONFIG_PPC_FPU */


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/powerpc: cleanup fpu support

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: d99ff61eaffa21d3674b26ae186c0f781182cf15
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=d99ff61eaffa21d3674b26ae186c0f781182cf15

Author: Philippe Gerum 
Date:   Thu Jul  7 10:52:41 2016 +0200

cobalt/powerpc: cleanup fpu support

In order to support the Book3E architecture, we now rely on the
regular kernel accessors for manipulating the MSR, instead of assuming
Book3S.

In the same move, some obsolete compat code for kernel releases prior
to v3.10 (i.e. not supported by Cobalt) was dropped.

---

 kernel/cobalt/arch/powerpc/fpu.S|   58 +--
 kernel/cobalt/arch/powerpc/thread.c |   51 ++
 2 files changed, 31 insertions(+), 78 deletions(-)

diff --git a/kernel/cobalt/arch/powerpc/fpu.S b/kernel/cobalt/arch/powerpc/fpu.S
index bd9bcc1..186e922 100644
--- a/kernel/cobalt/arch/powerpc/fpu.S
+++ b/kernel/cobalt/arch/powerpc/fpu.S
@@ -23,46 +23,15 @@
 #include 
 #include 
 
-#ifdef CONFIG_PPC601_SYNC_FIX
-#define SYNC   \
-BEGIN_FTR_SECTION  \
-   sync;   \
-   isync;  \
-END_FTR_SECTION_IFSET(CPU_FTR_601)
-#else /* !CONFIG_PPC601_SYNC_FIX */
-#defineSYNC
-#endif /* CONFIG_PPC601_SYNC_FIX */
-
-#ifdef CONFIG_PPC64
-#ifndef MTMSRD
-#define MTMSRD(r)  mtmsrd  r
-#endif
-#ifndef MTFSF_L
-#define MTFSF_L(REG) \
-   .long (0xfc00058e | ((0xff) << 17) | ((REG) << 11) | (1 << 25))
-#endif
-#else /* !CONFIG_PPC64 */
-#ifndef MTMSRD
-#define MTMSRD(r)  mtmsr   r
-#endif
-#ifndef MTFSF_L
-#define MTFSF_L(REG)   mtfsf   0xff, (REG)
-#endif
-#endif /* !CONFIG_PPC64 */
-
 #ifdef THREAD_FPSTATE
-#define FIXUP_REG_FPSTATE(__reg) addi  __reg,__reg,THREAD_FPSTATE
+#define FIXUP_REG_FPSTATE(__reg)   addi__reg, __reg, THREAD_FPSTATE
 #else
-#define FIXUP_REG_FPSTATE(__reg)
-#ifndef THREAD_FPSCR
 /*
- * The following accessor has to work with ancient kernel versions,
- * for which THREAD_FPSCR is not usable for 64bit save/restore.
+ * v3.10 -> v3.13 do not have THREAD_FPSTATE yet, but still
+ * define THREAD_FPSCR.
  */
-#define FPSTATE_FPSCR(base)THREAD_FPR0+32*8(base)
-#else
-#defineFPSTATE_FPSCR(base) THREAD_FPSCR(base)
-#endif
+#define FIXUP_REG_FPSTATE(__reg)
+#defineFPSTATE_FPSCR(__base)   THREAD_FPSCR(__base)
 #endif
 
 /* r3 = _struct (tcb->fpup) */
@@ -99,3 +68,20 @@ _GLOBAL(__asm_restore_fpu)
MTFSF_L(fr0)
REST_32FPRS(0,r3)
blr
+
+_GLOBAL(__asm_disable_fpu)
+   mfmsr   r5
+   li  r3,MSR_FP
+   andcr5,r5,r3
+   SYNC
+   MTMSRD(r5)
+   isync
+   blr
+
+_GLOBAL(__asm_enable_fpu)
+   mfmsr   r5
+   ori r5,r5,MSR_FP
+   SYNC
+   MTMSRD(r5)
+   isync
+   blr
diff --git a/kernel/cobalt/arch/powerpc/thread.c 
b/kernel/cobalt/arch/powerpc/thread.c
index 7f6ff87..2a61d50 100644
--- a/kernel/cobalt/arch/powerpc/thread.c
+++ b/kernel/cobalt/arch/powerpc/thread.c
@@ -67,6 +67,10 @@ asmlinkage void __asm_save_fpu(struct thread_struct *ts);
 
 asmlinkage void __asm_restore_fpu(struct thread_struct *ts);
 
+asmlinkage void __asm_disable_fpu(void);
+
+asmlinkage void __asm_enable_fpu(void);
+
 #ifndef CONFIG_SMP
 #define get_fpu_owner(cur) last_task_used_math
 #else /* CONFIG_SMP */
@@ -77,53 +81,15 @@ asmlinkage void __asm_restore_fpu(struct thread_struct *ts);
 })
 #endif /* CONFIG_SMP */
 
-#ifdef CONFIG_PPC64
-#define do_disable_fpu() ({\
-register unsigned long _msr;\
-__asm__ __volatile__ ( "mfmsr %0" : "=r"(_msr) );   \
-__asm__ __volatile__ ( "mtmsrd %0"  \
-  : /* no output */\
-  : "r"(_msr & ~(MSR_FP))  \
-  : "memory" );\
-})
-
-#define do_enable_fpu() ({ \
-register unsigned long _msr;\
-__asm__ __volatile__ ( "mfmsr %0" : "=r"(_msr) );   \
-__asm__ __volatile__ ( "mtmsrd %0"  \
-  : /* no output */\
-  : "r"(_msr | MSR_FP) \
-  : "memory" );\
-})
-#else /* !CONFIG_PPC64 */
-#define do_disable_fpu() ({\
-register unsigned long _msr;\
-__asm__ __volatile__ ( "mfmsr %0" : "=r"(_msr) );   \
-__asm__ __volatile__ ( "mtmsr %0"   \
-  : /* no output */\
-  : "r"(_msr & ~(MSR_FP))  \
-  : "memory" );\
-})
-
-#define do_enable_fpu() ({ \
-register unsigned long _msr;\
-__asm__ __volatile__ ( "mfmsr %0" : "=r"(_msr) );   \
-__asm__ __volatile__ 

[Xenomai-git] Philippe Gerum : drivers/testing: add test helpers for mode switch handover

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: be819d77a0e0651a75e9d671844a0dffee8086ea
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=be819d77a0e0651a75e9d671844a0dffee8086ea

Author: Philippe Gerum 
Date:   Fri Jul  8 10:02:51 2016 +0200

drivers/testing: add test helpers for mode switch handover

---

 include/rtdm/uapi/testing.h   |9 +
 kernel/drivers/testing/rtdmtest.c |   33 +++--
 2 files changed, 36 insertions(+), 6 deletions(-)

diff --git a/include/rtdm/uapi/testing.h b/include/rtdm/uapi/testing.h
index 5fddfae..06b8f1e 100644
--- a/include/rtdm/uapi/testing.h
+++ b/include/rtdm/uapi/testing.h
@@ -84,6 +84,9 @@ struct rttst_swtest_error {
 #define RTTST_RTDM_NORMAL_CLOSE0
 #define RTTST_RTDM_DEFER_CLOSE_CONTEXT 1
 
+#define RTTST_RTDM_MAGIC_PRIMARY   0xfefbfefb
+#define RTTST_RTDM_MAGIC_SECONDARY 0xa5b9a5b9
+
 #define RTIOC_TYPE_TESTING RTDM_CLASS_TESTING
 
 /*!
@@ -145,6 +148,12 @@ struct rttst_swtest_error {
 #define RTTST_RTIOC_RTDM_ACTOR_GET_CPU \
_IOR(RTIOC_TYPE_TESTING, 0x41, __u32)
   
+#define RTTST_RTIOC_RTDM_PING_PRIMARY \
+   _IOR(RTIOC_TYPE_TESTING, 0x42, __u32)
+  
+#define RTTST_RTIOC_RTDM_PING_SECONDARY \
+   _IOR(RTIOC_TYPE_TESTING, 0x43, __u32)
+  
 /** @} */
 
 #endif /* !_RTDM_UAPI_TESTING_H */
diff --git a/kernel/drivers/testing/rtdmtest.c 
b/kernel/drivers/testing/rtdmtest.c
index 5c705e6..bd1ae6b 100644
--- a/kernel/drivers/testing/rtdmtest.c
+++ b/kernel/drivers/testing/rtdmtest.c
@@ -87,11 +87,28 @@ static void rtdm_basic_close(struct rtdm_fd *fd)
rtdm_timer_destroy(>close_timer);
 }
 
-static int rtdm_basic_ioctl(struct rtdm_fd *fd,
+static int rtdm_basic_ioctl_rt(struct rtdm_fd *fd,
+   unsigned int request, void __user *arg)
+{
+   int ret, magic = RTTST_RTDM_MAGIC_PRIMARY;
+
+   switch (request) {
+   case RTTST_RTIOC_RTDM_PING_PRIMARY:
+   ret = rtdm_safe_copy_to_user(fd, arg, ,
+sizeof(magic));
+   break;
+   default:
+   ret = -ENOSYS;
+   }
+
+   return ret;
+}
+
+static int rtdm_basic_ioctl_nrt(struct rtdm_fd *fd,
unsigned int request, void __user *arg)
 {
struct rtdm_basic_context *ctx = rtdm_fd_to_private(fd);
-   int err = 0;
+   int ret = 0, magic = RTTST_RTDM_MAGIC_SECONDARY;
 
switch (request) {
case RTTST_RTIOC_RTDM_DEFER_CLOSE:
@@ -103,11 +120,15 @@ static int rtdm_basic_ioctl(struct rtdm_fd *fd,
RTDM_TIMERMODE_RELATIVE);
}
break;
+   case RTTST_RTIOC_RTDM_PING_SECONDARY:
+   ret = rtdm_safe_copy_to_user(fd, arg, ,
+sizeof(magic));
+   break;
default:
-   err = -ENOTTY;
+   ret = -ENOTTY;
}
 
-   return err;
+   return ret;
 }
 
 static void actor_handler(void *arg)
@@ -209,8 +230,8 @@ static struct rtdm_driver rtdm_basic_driver = {
.ops = {
.open   = rtdm_basic_open,
.close  = rtdm_basic_close,
-   .ioctl_rt   = rtdm_basic_ioctl,
-   .ioctl_nrt  = rtdm_basic_ioctl,
+   .ioctl_rt   = rtdm_basic_ioctl_rt,
+   .ioctl_nrt  = rtdm_basic_ioctl_nrt,
},
 };
 


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/clock: add limited support for handling frequency updates

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: 6c18d206f4d5f25b9d02d128bcfddbc3938d4236
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=6c18d206f4d5f25b9d02d128bcfddbc3938d4236

Author: Philippe Gerum 
Date:   Fri Jul 15 11:02:42 2016 +0200

cobalt/clock: add limited support for handling frequency updates

This support is aimed at handling changes in the clock device
frequency while the kernel boots. No provision for handling CPUFREQ
events during runtime.

---

 include/cobalt/kernel/clock.h |2 ++
 kernel/cobalt/clock.c |   26 ++
 kernel/cobalt/posix/process.c |   14 ++
 3 files changed, 34 insertions(+), 8 deletions(-)

diff --git a/include/cobalt/kernel/clock.h b/include/cobalt/kernel/clock.h
index c290b1d..3dfff38 100644
--- a/include/cobalt/kernel/clock.h
+++ b/include/cobalt/kernel/clock.h
@@ -328,6 +328,8 @@ static inline void xnclock_init_proc(void) { }
 static inline void xnclock_cleanup_proc(void) { }
 #endif
 
+void xnclock_update_freq(unsigned long long freq);
+
 int xnclock_init(unsigned long long freq);
 
 void xnclock_cleanup(void);
diff --git a/kernel/cobalt/clock.c b/kernel/cobalt/clock.c
index 1794f0e..647eca3 100644
--- a/kernel/cobalt/clock.c
+++ b/kernel/cobalt/clock.c
@@ -819,6 +819,23 @@ void xnclock_tick(struct xnclock *clock)
 }
 EXPORT_SYMBOL_GPL(xnclock_tick);
 
+void xnclock_update_freq(unsigned long long freq)
+{
+   spl_t s;
+
+   xnlock_get_irqsave(, s);
+   clockfreq = freq;
+#ifdef XNARCH_HAVE_LLMULSHFT
+   xnarch_init_llmulshft(10, freq, _scale, _shift);
+#ifdef XNARCH_HAVE_NODIV_LLIMD
+   xnarch_init_u32frac(_frac, 1 << tsc_shift, tsc_scale);
+   xnarch_init_u32frac(_frac, 1, 10);
+#endif
+#endif
+   cobalt_pipeline.clock_freq = freq;
+   xnlock_put_irqrestore(, s);
+}
+
 static int set_core_clock_gravity(struct xnclock *clock,
  const struct xnclock_gravity *p)
 {
@@ -861,14 +878,7 @@ void xnclock_cleanup(void)
 
 int __init xnclock_init(unsigned long long freq)
 {
-   clockfreq = freq;
-#ifdef XNARCH_HAVE_LLMULSHFT
-   xnarch_init_llmulshft(10, freq, _scale, _shift);
-#ifdef XNARCH_HAVE_NODIV_LLIMD
-   xnarch_init_u32frac(_frac, 1 << tsc_shift, tsc_scale);
-   xnarch_init_u32frac(_frac, 1, 10);
-#endif
-#endif
+   xnclock_update_freq(freq);
nktimerlat = xnarch_timer_calibrate();
xnclock_reset_gravity();
xnclock_register(, _realtime_cpus);
diff --git a/kernel/cobalt/posix/process.c b/kernel/cobalt/posix/process.c
index efd6b9e..b112a1a 100644
--- a/kernel/cobalt/posix/process.c
+++ b/kernel/cobalt/posix/process.c
@@ -1262,6 +1262,15 @@ static int handle_cleanup_event(struct mm_struct *mm)
return KEVENT_PROPAGATE;
 }
 
+static int handle_clockfreq_event(unsigned int *p)
+{
+   unsigned int newfreq = *p;
+
+   xnclock_update_freq(newfreq);
+
+   return KEVENT_PROPAGATE;
+}
+
 int ipipe_kevent_hook(int kevent, void *data)
 {
int ret;
@@ -1285,6 +1294,11 @@ int ipipe_kevent_hook(int kevent, void *data)
case IPIPE_KEVT_SETAFFINITY:
ret = handle_setaffinity_event(data);
break;
+#ifdef IPIPE_KEVT_CLOCKFREQ
+   case IPIPE_KEVT_CLOCKFREQ:
+   ret = handle_clockfreq_event(data);
+   break;
+#endif
default:
ret = KEVENT_PROPAGATE;
}


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : drivers/ipc: fix potential race in select()

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: 59284782ac15e24a55f57581bdb4dccd4bc84a73
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=59284782ac15e24a55f57581bdb4dccd4bc84a73

Author: Philippe Gerum 
Date:   Tue Sep  6 09:40:34 2016 +0200

drivers/ipc: fix potential race in select()

Acquiring the poll state and binding the selector must be done
atomically, so that such state does not change before xnselect_bind()
decides whether the caller should wait.

---

 kernel/drivers/ipc/bufp.c  |7 +--
 kernel/drivers/ipc/iddp.c  |7 +--
 kernel/drivers/ipc/rtipc.c |   26 +-
 kernel/drivers/ipc/xddp.c  |7 +--
 4 files changed, 16 insertions(+), 31 deletions(-)

diff --git a/kernel/drivers/ipc/bufp.c b/kernel/drivers/ipc/bufp.c
index f129eaa..2e7f5ad 100644
--- a/kernel/drivers/ipc/bufp.c
+++ b/kernel/drivers/ipc/bufp.c
@@ -1043,15 +1043,12 @@ static int bufp_ioctl(struct rtdm_fd *fd,
return ret;
 }
 
-static unsigned int bufp_pollstate(struct rtdm_fd *fd)
+static unsigned int bufp_pollstate(struct rtdm_fd *fd) /* atomic */
 {
struct rtipc_private *priv = rtdm_fd_to_private(fd);
struct bufp_socket *sk = priv->state, *rsk;
unsigned int mask = 0;
struct rtdm_fd *rfd;
-   spl_t s;
-
-   cobalt_atomic_enter(s);
 
if (test_bit(_BUFP_BOUND, >status) && sk->fillsz > 0)
mask |= POLLIN;
@@ -1072,8 +1069,6 @@ static unsigned int bufp_pollstate(struct rtdm_fd *fd)
} else
mask |= POLLOUT;
 
-   cobalt_atomic_leave(s);
-
return mask;
 }
 
diff --git a/kernel/drivers/ipc/iddp.c b/kernel/drivers/ipc/iddp.c
index 028e40a..6d3da57 100644
--- a/kernel/drivers/ipc/iddp.c
+++ b/kernel/drivers/ipc/iddp.c
@@ -935,15 +935,12 @@ static void iddp_exit(void)
xnmap_delete(portmap);
 }
 
-static unsigned int iddp_pollstate(struct rtdm_fd *fd)
+static unsigned int iddp_pollstate(struct rtdm_fd *fd) /* atomic */
 {
struct rtipc_private *priv = rtdm_fd_to_private(fd);
struct iddp_socket *sk = priv->state;
unsigned int mask = 0;
struct rtdm_fd *rfd;
-   spl_t s;
-
-   cobalt_atomic_enter(s);
 
if (test_bit(_IDDP_BOUND, >status) && !list_empty(>inq))
mask |= POLLIN;
@@ -966,8 +963,6 @@ static unsigned int iddp_pollstate(struct rtdm_fd *fd)
} else
mask |= POLLOUT;
 
-   cobalt_atomic_leave(s);
-
return mask;
 }
 
diff --git a/kernel/drivers/ipc/rtipc.c b/kernel/drivers/ipc/rtipc.c
index 77fc7dd..7bd4950 100644
--- a/kernel/drivers/ipc/rtipc.c
+++ b/kernel/drivers/ipc/rtipc.c
@@ -481,28 +481,28 @@ static int rtipc_select(struct rtdm_fd *fd, struct 
xnselector *selector,
spl_t s;
int ret;

+   if (type != XNSELECT_READ && type != XNSELECT_WRITE)
+   return -EINVAL;
+
+   binding = xnmalloc(sizeof(*binding));
+   if (binding == NULL)
+   return -ENOMEM;
+
+   cobalt_atomic_enter(s);
+
pollstate = priv->proto->proto_ops.pollstate(fd);
 
-   switch (type) {
-   case XNSELECT_READ:
+   if (type == XNSELECT_READ) {
mask = pollstate & POLLIN;
block = >recv_block;
-   break;
-   case XNSELECT_WRITE:
+   } else {
mask = pollstate & POLLOUT;
block = >send_block;
-   break;
-   default:
-   return -EINVAL;
}
 
-   binding = xnmalloc(sizeof(*binding));
-   if (binding == NULL)
-   return -ENOMEM;
-
-   xnlock_get_irqsave(, s);
ret = xnselect_bind(block, binding, selector, type, index, mask);
-   xnlock_put_irqrestore(, s);
+
+   cobalt_atomic_leave(s);
 
if (ret)
xnfree(binding);
diff --git a/kernel/drivers/ipc/xddp.c b/kernel/drivers/ipc/xddp.c
index c91aa02..c48b935 100644
--- a/kernel/drivers/ipc/xddp.c
+++ b/kernel/drivers/ipc/xddp.c
@@ -1081,15 +1081,12 @@ static int xddp_ioctl(struct rtdm_fd *fd,
return ret;
 }
 
-static unsigned int xddp_pollstate(struct rtdm_fd *fd)
+static unsigned int xddp_pollstate(struct rtdm_fd *fd) /* atomic */
 {
struct rtipc_private *priv = rtdm_fd_to_private(fd);
struct xddp_socket *sk = priv->state, *rsk;
unsigned int mask = 0, pollstate;
struct rtdm_fd *rfd;
-   spl_t s;
-
-   cobalt_atomic_enter(s);
 
pollstate = __xnpipe_pollstate(sk->minor);
if (test_bit(_XDDP_BOUND, >status))
@@ -1110,8 +1107,6 @@ static unsigned int xddp_pollstate(struct rtdm_fd *fd)
} else
mask |= POLLOUT;
 
-   cobalt_atomic_leave(s);
-
return mask;
 }
 


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/kernel: stop using deprecated set_cpus_allowed()

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: 95e603a385e06371f082a67f7de633974935952d
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=95e603a385e06371f082a67f7de633974935952d

Author: Philippe Gerum 
Date:   Sat Sep  3 11:20:21 2016 +0200

cobalt/kernel: stop using deprecated set_cpus_allowed()

---

 kernel/cobalt/thread.c  |4 ++--
 kernel/drivers/testing/switchtest.c |   10 +-
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c
index 7daefdb..01d86b3 100644
--- a/kernel/cobalt/thread.c
+++ b/kernel/cobalt/thread.c
@@ -2196,7 +2196,7 @@ void xnthread_relax(int notify, int reason)
if (xnthread_test_localinfo(thread, XNMOVED)) {
xnthread_clear_localinfo(thread, XNMOVED);
cpu = xnsched_cpu(thread->sched);
-   set_cpus_allowed(p, *cpumask_of(cpu));
+   set_cpus_allowed_ptr(p, cpumask_of(cpu));
}
 #endif
 
@@ -2444,7 +2444,7 @@ void xnthread_pin_initial(struct xnthread *thread)
if (!cpumask_test_cpu(cpu, >affinity))
cpu = cpumask_first(>affinity);
 
-   set_cpus_allowed(p, *cpumask_of(cpu));
+   set_cpus_allowed_ptr(p, cpumask_of(cpu));
/*
 * @thread is still unstarted Xenomai-wise, we are precisely
 * in the process of mapping the current kernel task to
diff --git a/kernel/drivers/testing/switchtest.c 
b/kernel/drivers/testing/switchtest.c
index 7283dd5..3a2e0d5 100644
--- a/kernel/drivers/testing/switchtest.c
+++ b/kernel/drivers/testing/switchtest.c
@@ -495,7 +495,7 @@ static int rtswitch_create_ktask(struct rtswitch_context 
*ctx,
iattr.affinity = *cpumask_of(ctx->cpu);
param.rt.prio = 1;
 
-   set_cpus_allowed(current, *cpumask_of(ctx->cpu));
+   set_cpus_allowed_ptr(current, cpumask_of(ctx->cpu));
 
err = xnthread_init(>ktask,
, _class_rt, );
@@ -512,9 +512,9 @@ static int rtswitch_create_ktask(struct rtswitch_context 
*ctx,
task->base.flags = 0;
/*
 * Putting the argument on stack is safe, because the new
-* thread, thanks to the abovce call of set_cpus_allowed,
-* will preempt the current thread immediately, and
-* will suspend only once the arguments on stack are used.
+* thread, thanks to the above call to set_cpus_allowed_ptr(),
+* will preempt the current thread immediately, and will
+* suspend only once the arguments on stack are used.
 */
 
return err;
@@ -553,7 +553,7 @@ static void rtswitch_close(struct rtdm_fd *fd)
rtdm_nrtsig_destroy(>wake_utask);
 
if (ctx->tasks) {
-   set_cpus_allowed(current, *cpumask_of(ctx->cpu));
+   set_cpus_allowed_ptr(current, cpumask_of(ctx->cpu));
 
for (i = 0; i < ctx->next_index; i++) {
struct rtswitch_task *task = >tasks[i];


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/syscalls: allow for handing over mode selection to syscall handlers

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: 62b824afef9bd3085bc37b0d7d7bc39e7788a2e8
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=62b824afef9bd3085bc37b0d7d7bc39e7788a2e8

Author: Philippe Gerum 
Date:   Thu Jul  7 17:05:16 2016 +0200

cobalt/syscalls: allow for handing over mode selection to syscall handlers

Specific system calls may benefit from dealing with the caller's
runtime mode by themselves, depending on internal information which
the generic syscall dispatcher does not have access to.

To this end, a new syscall mode called "handover" is
introduced. Syscalls bearing this mode bit are always entered from the
current calling domain. The syscall handler may return -ENOSYS to
trigger a switch to the converse domain until all domains have been
visited once, at which point the syscall fails with -ENOSYS
automatically.

---

 include/cobalt/uapi/kernel/thread.h |1 +
 kernel/cobalt/posix/syscall.c   |   68 ---
 2 files changed, 40 insertions(+), 29 deletions(-)

diff --git a/include/cobalt/uapi/kernel/thread.h 
b/include/cobalt/uapi/kernel/thread.h
index 89853e8..100ccee 100644
--- a/include/cobalt/uapi/kernel/thread.h
+++ b/include/cobalt/uapi/kernel/thread.h
@@ -76,6 +76,7 @@
 
 #define XNMOVED   0x0001 /**< CPU migration in primary mode occurred */
 #define XNLBALERT 0x0002 /**< Scheduler lock break alert (SIGDEBUG sent) */
+#define XNDESCENT 0x0004 /**< Adaptive transitioning to secondary mode */
 
 /** @} */
 
diff --git a/kernel/cobalt/posix/syscall.c b/kernel/cobalt/posix/syscall.c
index f7cde92..857f4f7 100644
--- a/kernel/cobalt/posix/syscall.c
+++ b/kernel/cobalt/posix/syscall.c
@@ -70,8 +70,10 @@
 #define __xn_exec_downup(__xn_exec_lostage|__xn_exec_switchback)
 /* Shorthand for non-restartable primary syscall. */
 #define __xn_exec_nonrestartable (__xn_exec_primary|__xn_exec_norestart)
-/* Shorthand for domain probing syscall */
+/* Domain probing syscall starting in conforming mode. */
 #define __xn_exec_probing   (__xn_exec_conforming|__xn_exec_adaptive)
+/* Hand over mode selection to syscall.  */
+#define __xn_exec_handover  (__xn_exec_current|__xn_exec_adaptive)
 
 typedef long (*cobalt_syshand)(unsigned long arg1, unsigned long arg2,
   unsigned long arg3, unsigned long arg4,
@@ -473,7 +475,7 @@ static inline int allowed_syscall(struct cobalt_process 
*process,
if (process == NULL)
return 0;
 
-   if (thread == NULL && (sysflags & __xn_exec_shadow) != 0)
+   if (thread == NULL && (sysflags & __xn_exec_shadow))
return 0;
 
return cap_raised(current_cap(), CAP_SYS_NICE);
@@ -546,12 +548,13 @@ static int handle_head_syscall(struct ipipe_domain *ipd, 
struct pt_regs *regs)
 * o Whether the caller currently runs in the Linux or Xenomai
 * domain.
 */
-   switched = 0;
 restart:
/*
 * Process adaptive syscalls by restarting them in the
-* opposite domain.
+* opposite domain upon receiving -ENOSYS from the syscall
+* handler.
 */
+   switched = 0;
if (sysflags & __xn_exec_lostage) {
/*
 * The syscall must run from the Linux domain.
@@ -585,15 +588,22 @@ restart:
return KEVENT_PROPAGATE;
}
 
+   /*
+* 'thread' has to be valid from that point: all syscalls
+* regular threads may call have been pipelined to the root
+* handler (lostage ones), or rejected by allowed_syscall().
+*/
+
ret = handler(__xn_reg_arglist(regs));
-   if (ret == -ENOSYS && (sysflags & __xn_exec_adaptive) != 0) {
+   if (ret == -ENOSYS && (sysflags & __xn_exec_adaptive)) {
if (switched) {
-   switched = 0;
ret = xnthread_harden();
-   if (ret)
+   if (ret) {
+   switched = 0;
goto done;
-   }
-
+   }
+   } else /* Mark the primary -> secondary transition. */
+   xnthread_set_localinfo(thread, XNDESCENT);
sysflags ^=
(__xn_exec_lostage | __xn_exec_histage |
 __xn_exec_adaptive);
@@ -616,12 +626,14 @@ done:
xnthread_relax(0, 0);
}
}
-   if (!sigs && (sysflags & __xn_exec_switchback) != 0 && switched)
-   xnthread_harden(); /* -EPERM will be trapped later if needed. */
+   if (!sigs && (sysflags & __xn_exec_switchback) && switched)
+   /* -EPERM will be trapped later if needed. */
+   xnthread_harden();
 
 ret_handled:
/* Update the stats and userland-visible state. */
if (thread) {
+   xnthread_clear_localinfo(thread, XNDESCENT);

[Xenomai-git] Philippe Gerum : cobalt/signal: fix error code in kill() routine

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: 5606da4ddedf424a611d84f67386dfb428fc334e
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=5606da4ddedf424a611d84f67386dfb428fc334e

Author: Philippe Gerum 
Date:   Mon Jul 11 11:35:20 2016 +0200

cobalt/signal: fix error code in kill() routine

---

 kernel/cobalt/posix/signal.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/cobalt/posix/signal.c b/kernel/cobalt/posix/signal.c
index 4822fda..416d3e4 100644
--- a/kernel/cobalt/posix/signal.c
+++ b/kernel/cobalt/posix/signal.c
@@ -480,7 +480,7 @@ int __cobalt_kill(struct cobalt_thread *thread, int sig, 
int group) /* nklocked,
 XN_INFINITE, XN_RELATIVE, NULL);
if (>threadbase == xnthread_current() &&
xnthread_test_info(>threadbase, XNBREAK))
-   ret = EINTR;
+   ret = -EINTR;
break;
case SIGRESM:
xnthread_resume(>threadbase, XNSUSP);


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/process: fix build warning ( missing CLOCKFREQ event)

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: ac1d5182b0d6149e4797a238ecff5f01e7af3b0f
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=ac1d5182b0d6149e4797a238ecff5f01e7af3b0f

Author: Philippe Gerum 
Date:   Wed Jul 20 06:01:39 2016 +0200

cobalt/process: fix build warning (missing CLOCKFREQ event)

---

 kernel/cobalt/posix/process.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/cobalt/posix/process.c b/kernel/cobalt/posix/process.c
index b112a1a..af94f4d 100644
--- a/kernel/cobalt/posix/process.c
+++ b/kernel/cobalt/posix/process.c
@@ -1262,7 +1262,7 @@ static int handle_cleanup_event(struct mm_struct *mm)
return KEVENT_PROPAGATE;
 }
 
-static int handle_clockfreq_event(unsigned int *p)
+static inline int handle_clockfreq_event(unsigned int *p)
 {
unsigned int newfreq = *p;
 


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/blackfin: fpu: drop obsolete xnarch_save_fpu()

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: d38b04ec28aa4865ececc07b696b725ada9dbd53
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=d38b04ec28aa4865ececc07b696b725ada9dbd53

Author: Philippe Gerum 
Date:   Thu Sep  8 16:29:50 2016 +0200

cobalt/blackfin: fpu: drop obsolete xnarch_save_fpu()

---

 kernel/cobalt/arch/blackfin/include/asm/xenomai/thread.h |1 -
 1 file changed, 1 deletion(-)

diff --git a/kernel/cobalt/arch/blackfin/include/asm/xenomai/thread.h 
b/kernel/cobalt/arch/blackfin/include/asm/xenomai/thread.h
index e270fa8..9956ec5 100644
--- a/kernel/cobalt/arch/blackfin/include/asm/xenomai/thread.h
+++ b/kernel/cobalt/arch/blackfin/include/asm/xenomai/thread.h
@@ -54,7 +54,6 @@ static inline void xnarch_init_root_tcb(struct xnthread 
*thread) { }
 static inline void xnarch_init_shadow_tcb(struct xnthread *thread) { }
 static inline void xnarch_enter_root(struct xnthread *root) { }
 static inline void xnarch_leave_root(struct xnthread *root) { }
-static inline void xnarch_save_fpu(struct xnthread *thread) { }
 static inline void
 xnarch_switch_fpu(struct xnthread *from, struct xnthread *thread)
 { 


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : copperplate/threadobj: mercury: fix error code in corespec_init call

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: 4688fd5968fbf65f6d99effc7a582537aef96068
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=4688fd5968fbf65f6d99effc7a582537aef96068

Author: Philippe Gerum 
Date:   Thu Jul  7 10:23:43 2016 +0200

copperplate/threadobj: mercury: fix error code in corespec_init call

At this chance, give a hint about a common cause of failure to set the
condvar clock, i.e. CLOCK_MONOTONIC_RAW not available.

---

 lib/copperplate/threadobj.c |8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib/copperplate/threadobj.c b/lib/copperplate/threadobj.c
index 831446a..e52984b 100644
--- a/lib/copperplate/threadobj.c
+++ b/lib/copperplate/threadobj.c
@@ -596,8 +596,12 @@ static inline int threadobj_init_corespec(struct threadobj 
*thobj)
 */
pthread_condattr_init();
pthread_condattr_setpshared(, mutex_scope_attribute);
-   ret = __bt(pthread_condattr_setclock(, CLOCK_COPPERPLATE));
-   if (ret == 0)
+   ret = __bt(-pthread_condattr_setclock(, CLOCK_COPPERPLATE));
+   if (ret)
+   warning("failed setting condvar clock, %s"
+   "(try --disable-clock-monotonic-raw)",
+   symerror(ret));
+   else
ret = __bt(-pthread_cond_init(>core.grant_sync, ));
pthread_condattr_destroy();
 


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/rtdm: add accessor to kernel device struct

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: 403d39c5777b0c1e3e97baf6adf8bd53986f036c
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=403d39c5777b0c1e3e97baf6adf8bd53986f036c

Author: Philippe Gerum 
Date:   Sun Jun 19 20:39:19 2016 +0200

cobalt/rtdm: add accessor to kernel device struct

Each RTDM device is mated to a regular kernel device object. Add
rtdm_dev_to_kdev() to return the address of such object.

---

 include/cobalt/kernel/rtdm/driver.h |5 +
 1 file changed, 5 insertions(+)

diff --git a/include/cobalt/kernel/rtdm/driver.h 
b/include/cobalt/kernel/rtdm/driver.h
index bcf6e54..1133cca 100644
--- a/include/cobalt/kernel/rtdm/driver.h
+++ b/include/cobalt/kernel/rtdm/driver.h
@@ -398,6 +398,11 @@ void rtdm_dev_unregister(struct rtdm_device *device);
 
 #ifndef DOXYGEN_CPP /* Avoid static inline tags for RTDM in doxygen */
 
+static inline struct device *rtdm_dev_to_kdev(struct rtdm_device *device)
+{
+   return device->kdev;
+}
+
 /* --- clock services --- */
 static inline nanosecs_abs_t rtdm_clock_read(void)
 {


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : testsuite/smokey: rtdm: add handover test

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: 7d55b32cc287dbf47fca5f1eeeb5e70690c83915
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=7d55b32cc287dbf47fca5f1eeeb5e70690c83915

Author: Philippe Gerum 
Date:   Sun Jul 10 10:07:24 2016 +0200

testsuite/smokey: rtdm: add handover test

---

 testsuite/smokey/rtdm/rtdm.c |   96 ++
 1 file changed, 96 insertions(+)

diff --git a/testsuite/smokey/rtdm/rtdm.c b/testsuite/smokey/rtdm/rtdm.c
index 2c035c0..c41daa7 100644
--- a/testsuite/smokey/rtdm/rtdm.c
+++ b/testsuite/smokey/rtdm/rtdm.c
@@ -73,6 +73,97 @@ static void check_sleep_inner(const char *fn, int line,
 static const char *devname = "/dev/rtdm/rtdm0";
 static const char *devname2 = "/dev/rtdm/rtdm1";
 
+static int do_handover(int fd)
+{
+   struct sched_param param;
+   int ret, magic = 0;
+
+   if (!__F(ret, ioctl(fd, RTTST_RTIOC_RTDM_PING_PRIMARY, )) ||
+   errno != ENOTTY)
+   return ret ? -ENOTTY : -EINVAL;
+
+   if (!__Tassert(magic == 0))
+   return -EINVAL;
+
+   if (!__T(ret, ioctl(fd, RTTST_RTIOC_RTDM_PING_SECONDARY, )))
+   return ret;
+
+   if (!__Tassert(magic == RTTST_RTDM_MAGIC_SECONDARY))
+   return -EINVAL;
+
+   /* Switch to Cobalt's SCHED_FIFO[1] */
+   
+   param.sched_priority = 1;
+   if (!__T(ret, pthread_setschedparam(pthread_self(),
+   SCHED_FIFO, )))
+   return ret;
+   
+   if (!__T(ret, ioctl(fd, RTTST_RTIOC_RTDM_PING_PRIMARY, )))
+   return ret;
+
+   if (!__Tassert(magic == RTTST_RTDM_MAGIC_PRIMARY))
+   return -EINVAL;
+
+   if (!__T(ret, ioctl(fd, RTTST_RTIOC_RTDM_PING_SECONDARY, )))
+   return ret;
+
+   if (!__Tassert(magic == RTTST_RTDM_MAGIC_SECONDARY))
+   return -EINVAL;
+
+   /* Switch to Cobalt's SCHED_WEAK[0] */
+   
+   param.sched_priority = 0;
+   if (!__T(ret, pthread_setschedparam(pthread_self(),
+   SCHED_WEAK, )))
+   return ret;
+   
+   if (!__T(ret, ioctl(fd, RTTST_RTIOC_RTDM_PING_PRIMARY, )))
+   return ret;
+
+   if (!__Tassert(magic == RTTST_RTDM_MAGIC_PRIMARY))
+   return -EINVAL;
+
+   if (!__T(ret, ioctl(fd, RTTST_RTIOC_RTDM_PING_SECONDARY, )))
+   return ret;
+
+   if (!__Tassert(magic == RTTST_RTDM_MAGIC_SECONDARY))
+   return -EINVAL;
+
+   return 0;
+}
+
+static void *__test_handover(void *arg)
+{
+   int fd = *(int *)arg;
+
+   return (void *)(long)do_handover(fd);
+}
+
+static int test_handover(int fd)
+{
+   struct sched_param param;
+   pthread_attr_t attr;
+   pthread_t tid;
+   void *p;
+   int ret;
+
+   pthread_attr_init();
+   param.sched_priority = 0;
+   pthread_attr_setdetachstate(, PTHREAD_CREATE_JOINABLE);
+   pthread_attr_setschedpolicy(, SCHED_OTHER);
+   pthread_attr_setschedparam(, );
+   pthread_attr_setinheritsched(, PTHREAD_EXPLICIT_SCHED);
+
+   if (!__T(ret, __STD(pthread_create(, ,
+  __test_handover, 
+   return ret;
+
+   if (!__T(ret, pthread_join(tid, )))
+   return ret;
+
+   return (int)(long)p;
+}
+
 static int run_rtdm(struct smokey_test *t, int argc, char *const argv[])
 {
unsigned long long start;
@@ -95,6 +186,11 @@ static int run_rtdm(struct smokey_test *t, int argc, char 
*const argv[])
dev2 = check("open", open(devname2, O_RDWR), dev + 1);
check("close", close(dev2), 0);
 
+   smokey_trace("Handover mode");
+   status = test_handover(dev);
+   if (status)
+   return status;
+
smokey_trace("Defer close by pending reference");
check("ioctl", ioctl(dev, RTTST_RTIOC_RTDM_DEFER_CLOSE,
 RTTST_RTDM_DEFER_CLOSE_CONTEXT), 0);


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/thread: drop obsolete release_fpu() helper

2016-09-29 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: 3754612c93eb5f2559590da313f2bad7e09ca90e
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=3754612c93eb5f2559590da313f2bad7e09ca90e

Author: Philippe Gerum 
Date:   Thu Sep  8 16:30:27 2016 +0200

cobalt/thread: drop obsolete release_fpu() helper

---

 kernel/cobalt/thread.c |   17 -
 1 file changed, 17 deletions(-)

diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c
index 01d86b3..fb856a4 100644
--- a/kernel/cobalt/thread.c
+++ b/kernel/cobalt/thread.c
@@ -435,19 +435,6 @@ static inline void giveup_fpu(struct xnsched *sched,
sched->fpuholder = NULL;
 }
 
-static inline void release_fpu(struct xnthread *thread)
-{
-   /*
-* Force the FPU save, and nullify the sched->fpuholder
-* pointer, to avoid leaving fpuholder pointing on the backup
-* area of the migrated thread.
-*/
-   if (xnthread_test_state(thread, XNFPU)) {
-   xnarch_save_fpu(thread);
-   thread->sched->fpuholder = NULL;
-   }
-}
-
 void xnthread_switch_fpu(struct xnsched *sched)
 {
struct xnthread *curr = sched->curr;
@@ -466,10 +453,6 @@ static inline void giveup_fpu(struct xnsched *sched,
 {
 }
 
-static inline void release_fpu(struct xnthread *thread)
-{
-}
-
 #endif /* !CONFIG_XENO_ARCH_FPU */
 
 static inline void cleanup_tcb(struct xnthread *thread) /* nklock held, irqs 
off */


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git