[Xenomai-git] Gilles Chanteperdrix : nucleus/sched: avoid useless nklock synchronization in relax path

2011-01-07 Thread GIT version control
Module: xenomai-2.5
Branch: master
Commit: 15a48b82b49bb3cc8b336b081ac502d1544144f9
URL:
http://git.xenomai.org/?p=xenomai-2.5.git;a=commit;h=15a48b82b49bb3cc8b336b081ac502d1544144f9

Author: Gilles Chanteperdrix gilles.chanteperd...@xenomai.org
Date:   Fri Jan  7 23:56:00 2011 +0100

nucleus/sched: avoid useless nklock synchronization in relax path

---

 ksrc/nucleus/pod.c |   10 +++---
 1 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/ksrc/nucleus/pod.c b/ksrc/nucleus/pod.c
index d3a3122..b5ddbaa 100644
--- a/ksrc/nucleus/pod.c
+++ b/ksrc/nucleus/pod.c
@@ -2327,8 +2327,6 @@ reschedule:
 #ifdef CONFIG_XENO_OPT_PERVASIVE
   shadow_epilogue:
{
-   spl_t ignored;
-
/* Shadow on entry and root without shadow extension on exit?
   Mmmm... This must be the user-space mate of a deleted 
real-time
   shadow we've just rescheduled in the Linux domain to have it
@@ -2338,11 +2336,9 @@ reschedule:
xnshadow_exit();
}
 
-   /* We need to relock nklock here, since it is not locked and
-  the caller may expect it to be locked. */
-   xnlock_get_irqsave(nklock, ignored);
-   xnlock_put_irqrestore(nklock, s);
-
+   /* We are returning to xnshadow_relax via
+  xnpod_suspend_thread, do nothing,
+  xnpod_suspend_thread will re-enable interrupts. */
return;
}
 #endif /* CONFIG_XENO_OPT_PERVASIVE */


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


[Xenomai-git] Gilles Chanteperdrix : nucleus/sched: Fix fallout of f6af9b831

2011-01-07 Thread GIT version control
Module: xenomai-2.5
Branch: master
Commit: 9eb58f13ef476130371cb1bed4248640b05dfad6
URL:
http://git.xenomai.org/?p=xenomai-2.5.git;a=commit;h=9eb58f13ef476130371cb1bed4248640b05dfad6

Author: Gilles Chanteperdrix gilles.chanteperd...@xenomai.org
Date:   Fri Jan  7 23:44:29 2011 +0100

nucleus/sched: Fix fallout of f6af9b831

By re-enabling interrupts in the middle of xnpod_suspend_thread(), f6af9b831
allows an interrupt to happen when running __xnpod_schedule() as a result of
xnshadow_relax(), right between the time xnarch_escalate() is called, and the
time the interrupts are shut off (and the nklock locked).

When this happens, __xnpod_schedule() critical section is run while the current
Adeos domain is Linux, which is precisely what xnarch_escalate() was called to
avoid.

So, we simply shut interrupts off in xnpod_suspend_thread() right after
enabling them for the XNRELAX case, since this is the only place where this
issue may happen.

---

 ksrc/nucleus/pod.c |   13 +
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/ksrc/nucleus/pod.c b/ksrc/nucleus/pod.c
index 617c34d..d3a3122 100644
--- a/ksrc/nucleus/pod.c
+++ b/ksrc/nucleus/pod.c
@@ -1466,10 +1466,23 @@ void xnpod_suspend_thread(xnthread_t *thread, xnflags_t 
mask,
 * shortens the uninterruptible code path.  This
 * particular caller expects us to always return with
 * interrupts enabled.
+*
+* We have to shut irqs off around xnpod_schedule()
+* though: if an interrupt could preempt us in
+* __xnpod_schedule right after the call to
+* xnarch_escalate but before we lock the nklock, we
+* would enter the critical section in xnpod_schedule
+* while the current Adeos domain is Linux, which
+* would defeat the purpose of having called
+* xnarch_escalate(). xnpod_schedule() is expected to
+* return with interrupts on.
 */
if (mask  XNRELAX) {
xnlock_clear_irqon(nklock);
+
+   splhigh(s);
xnpod_schedule();
+   splexit(s);
return;
}
/*


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


[Xenomai-git] Stefan Kisdaroczi : 16550A: customizable irqtype

2011-01-07 Thread GIT version control
Module: xenomai-2.5
Branch: master
Commit: 56d9f7a94808d89cc4617b519974580cfcaf6e71
URL:
http://git.xenomai.org/?p=xenomai-2.5.git;a=commit;h=56d9f7a94808d89cc4617b519974580cfcaf6e71

Author: Stefan Kisdaroczi ki...@hispeed.ch
Date:   Fri Jan  7 20:21:16 2011 +0100

16550A: customizable irqtype

---

 ksrc/drivers/serial/16550A.c |6 --
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/ksrc/drivers/serial/16550A.c b/ksrc/drivers/serial/16550A.c
index 4c46d86..f290e43 100644
--- a/ksrc/drivers/serial/16550A.c
+++ b/ksrc/drivers/serial/16550A.c
@@ -119,6 +119,9 @@ static const struct rtser_config default_config = {
 static struct rtdm_device *device[MAX_DEVICES];
 
 static unsigned int irq[MAX_DEVICES];
+static unsigned long irqtype[MAX_DEVICES] = {
+   [0 ... MAX_DEVICES-1] = RTDM_IRQTYPE_SHARED | RTDM_IRQTYPE_EDGE
+};
 static unsigned int baud_base[MAX_DEVICES];
 static int tx_fifo[MAX_DEVICES];
 static unsigned int start_index;
@@ -478,8 +481,7 @@ int rt_16550_open(struct rtdm_dev_context *context,
rt_16550_set_config(ctx, default_config, dummy);
 
err = rtdm_irq_request(ctx-irq_handle, irq[dev_id],
-  rt_16550_interrupt,
-  RTDM_IRQTYPE_SHARED | RTDM_IRQTYPE_EDGE,
+  rt_16550_interrupt, irqtype[dev_id],
   context-device-proc_name, ctx);
if (err) {
/* reset DTR and RTS */


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


[Xenomai-git] Stefan Kisdaroczi : 16550A: pci support

2011-01-07 Thread GIT version control
Module: xenomai-2.5
Branch: master
Commit: bbd18368d30da7c76fd96a502e8f9628fe2f09b7
URL:
http://git.xenomai.org/?p=xenomai-2.5.git;a=commit;h=bbd18368d30da7c76fd96a502e8f9628fe2f09b7

Author: Stefan Kisdaroczi ki...@hispeed.ch
Date:   Fri Jan  7 20:21:48 2011 +0100

16550A: pci support

---

 ksrc/drivers/serial/16550A.c |3 +
 ksrc/drivers/serial/16550A_pci.h |  110 ++
 ksrc/drivers/serial/Kconfig  |8 +++
 3 files changed, 121 insertions(+), 0 deletions(-)

diff --git a/ksrc/drivers/serial/16550A.c b/ksrc/drivers/serial/16550A.c
index f290e43..8c8c864 100644
--- a/ksrc/drivers/serial/16550A.c
+++ b/ksrc/drivers/serial/16550A.c
@@ -143,6 +143,7 @@ MODULE_AUTHOR(jan.kis...@web.de);
 
 #include 16550A_io.h
 #include 16550A_pnp.h
+#include 16550A_pci.h
 
 static inline int rt_16550_rx_interrupt(struct rt_16550_context *ctx,
uint64_t * timestamp)
@@ -1121,6 +1122,7 @@ int __init rt_16550_init(void)
int i;
 
rt_16550_pnp_init();
+   rt_16550_pci_init();
 
for (i = 0; i  MAX_DEVICES; i++) {
if (!rt_16550_addr_param(i))
@@ -1194,6 +1196,7 @@ void rt_16550_exit(void)
kfree(device[i]);
}
 
+   rt_16550_pci_cleanup();
rt_16550_pnp_cleanup();
 }
 
diff --git a/ksrc/drivers/serial/16550A_pci.h b/ksrc/drivers/serial/16550A_pci.h
new file mode 100644
index 000..442846d
--- /dev/null
+++ b/ksrc/drivers/serial/16550A_pci.h
@@ -0,0 +1,110 @@
+/*
+ * Copyright (C) 2006-2007 Jan Kiszka jan.kis...@web.de.
+ * Copyright (C) 2011 Stefan Kisdaroczi ki...@hispeed.ch.
+ *
+ * Xenomai 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.
+ *
+ * Xenomai 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 Xenomai; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#if LINUX_VERSION_CODE = KERNEL_VERSION(2,6,0)  defined(CONFIG_PCI)  \
+   defined(CONFIG_XENO_DRIVERS_16550A_PCI)
+
+#include linux/pci.h
+
+struct rt_16550_pci_board {
+   char *name;
+   resource_size_t resource_base_addr;
+   unsigned int nports;
+   unsigned int port_ofs;
+   unsigned long irqtype;
+   unsigned int baud_base;
+   int tx_fifo;
+};
+
+DEFINE_PCI_DEVICE_TABLE( rt_16550_pci_table ) = {
+   { }
+};
+
+static int __devinit rt_16550_pci_probe( struct pci_dev *pdev,
+const struct pci_device_id *ent )
+{
+   struct rt_16550_pci_board *board;
+   int err;
+   int i;
+   int port = 0;
+   int base_addr;
+   int max_devices = 0;
+
+   if (!ent-driver_data)
+   return -ENODEV;
+
+   board = (struct rt_16550_pci_board *)ent-driver_data;
+
+   for (i = 0; i  MAX_DEVICES; i++)
+   if (!rt_16550_addr_param(i))
+   max_devices++;
+
+   if (board-nports  max_devices)
+   return -ENODEV;
+
+   if ((err = pci_enable_device(pdev)))
+   return err;
+
+   base_addr = pci_resource_start(pdev, board-resource_base_addr);
+
+   for (i = 0; i  MAX_DEVICES; i++) {
+   if ((port  board-nports)  (!rt_16550_addr_param(i))) {
+   io[i] = base_addr + port * board-port_ofs;
+   irq[i] = pdev-irq;
+   irqtype[i] = board-irqtype;
+   baud_base[i] = board-baud_base;
+   tx_fifo[i] = board-tx_fifo;
+   port++;
+   }
+   }
+
+   return 0;
+}
+
+static void __devexit rt_16550_pci_remove( struct pci_dev *pdev ) {
+   pci_disable_device( pdev );
+};
+
+static struct pci_driver rt_16550_pci_driver = {
+   .name = RT_16550_DRIVER_NAME,
+   .id_table = rt_16550_pci_table,
+   .probe= rt_16550_pci_probe,
+   .remove   = __devexit_p(rt_16550_pci_remove)
+};
+
+static int pci_registered;
+
+static inline void rt_16550_pci_init(void)
+{
+   if (pci_register_driver(rt_16550_pci_driver) == 0)
+   pci_registered = 1;
+}
+
+static inline void rt_16550_pci_cleanup(void)
+{
+   if (pci_registered)
+   pci_unregister_driver(rt_16550_pci_driver);
+}
+
+#else /* Linux  2.6.0 || !CONFIG_PCI || !(..._16550A_PCI */
+
+#define rt_16550_pci_init()do { } while (0)
+#define rt_16550_pci_cleanup() do { } while (0)
+
+#endif /* Linux  2.6.0 || !CONFIG_PCI || !(..._16550A_PCI */
diff --git 

[Xenomai-git] Stefan Kisdaroczi : 16550A: Moxa pci board support

2011-01-07 Thread GIT version control
Module: xenomai-2.5
Branch: master
Commit: 0b0d448c106f978b0834aeca42438d50a51349a1
URL:
http://git.xenomai.org/?p=xenomai-2.5.git;a=commit;h=0b0d448c106f978b0834aeca42438d50a51349a1

Author: Stefan Kisdaroczi ki...@hispeed.ch
Date:   Fri Jan  7 20:23:27 2011 +0100

16550A: Moxa pci board support

---

 ksrc/drivers/serial/16550A_pci.h |  177 ++
 ksrc/drivers/serial/Kconfig  |   16 
 2 files changed, 193 insertions(+), 0 deletions(-)

diff --git a/ksrc/drivers/serial/16550A_pci.h b/ksrc/drivers/serial/16550A_pci.h
index 442846d..2c71a5e 100644
--- a/ksrc/drivers/serial/16550A_pci.h
+++ b/ksrc/drivers/serial/16550A_pci.h
@@ -32,7 +32,184 @@ struct rt_16550_pci_board {
int tx_fifo;
 };
 
+#if defined(CONFIG_XENO_DRIVERS_16550A_PCI_MOXA)
+
+#define PCI_DEVICE_ID_CP112UL  0x1120
+#define PCI_DEVICE_ID_CP114UL  0x1143
+#define PCI_DEVICE_ID_CP138U   0x1380
+
+static const struct rt_16550_pci_board rt_16550_moxa_c104 = {
+   .name = Moxa C104H/PCI,
+   .resource_base_addr = 2,
+   .nports = 4,
+   .port_ofs = 8,
+   .baud_base = 921600,
+   .tx_fifo = 16,
+   .irqtype = RTDM_IRQTYPE_SHARED,
+};
+
+static const struct rt_16550_pci_board rt_16550_moxa_c168 = {
+   .name = Moxa C168H/PCI,
+   .resource_base_addr = 2,
+   .nports = 8,
+   .port_ofs = 8,
+   .baud_base = 921600,
+   .tx_fifo = 16,
+   .irqtype = RTDM_IRQTYPE_SHARED,
+};
+
+static const struct rt_16550_pci_board rt_16550_moxa_cp114 = {
+   .name = Moxa CP-114,
+   .resource_base_addr = 2,
+   .nports = 4,
+   .port_ofs = 8,
+   .baud_base = 921600,
+   .tx_fifo = 16,
+   .irqtype = RTDM_IRQTYPE_SHARED,
+};
+
+static const struct rt_16550_pci_board rt_16550_moxa_cp132 = {
+   .name = Moxa CP-132,
+   .resource_base_addr = 2,
+   .nports = 2,
+   .port_ofs = 8,
+   .baud_base = 921600,
+   .tx_fifo = 16,
+   .irqtype = RTDM_IRQTYPE_SHARED,
+};
+
+static const struct rt_16550_pci_board rt_16550_moxa_cp102u = {
+   .name = Moxa CP-102U,
+   .resource_base_addr = 2,
+   .nports = 2,
+   .port_ofs = 8,
+   .baud_base = 921600,
+   .tx_fifo = 16,
+   .irqtype = RTDM_IRQTYPE_SHARED,
+};
+
+static const struct rt_16550_pci_board rt_16550_moxa_cp102ul = {
+   .name = Moxa CP-102UL,
+   .resource_base_addr = 2,
+   .nports = 2,
+   .port_ofs = 8,
+   .baud_base = 921600,
+   .tx_fifo = 16,
+   .irqtype = RTDM_IRQTYPE_SHARED,
+};
+
+static const struct rt_16550_pci_board rt_16550_moxa_cp104u = {
+   .name = Moxa CP-104U,
+   .resource_base_addr = 2,
+   .nports = 4,
+   .port_ofs = 8,
+   .baud_base = 921600,
+   .tx_fifo = 16,
+   .irqtype = RTDM_IRQTYPE_SHARED,
+};
+
+static const struct rt_16550_pci_board rt_16550_moxa_cp112ul = {
+   .name = Moxa CP-112UL,
+   .resource_base_addr = 2,
+   .nports = 2,
+   .port_ofs = 8,
+   .baud_base = 921600,
+   .tx_fifo = 16,
+   .irqtype = RTDM_IRQTYPE_SHARED,
+};
+
+static const struct rt_16550_pci_board rt_16550_moxa_cp114ul = {
+   .name = Moxa CP-114UL,
+   .resource_base_addr = 2,
+   .nports = 4,
+   .port_ofs = 8,
+   .baud_base = 921600,
+   .tx_fifo = 16,
+   .irqtype = RTDM_IRQTYPE_SHARED,
+};
+
+static const struct rt_16550_pci_board rt_16550_moxa_cp118u = {
+   .name = Moxa CP-118U,
+   .resource_base_addr = 2,
+   .nports = 8,
+   .port_ofs = 8,
+   .baud_base = 921600,
+   .tx_fifo = 16,
+   .irqtype = RTDM_IRQTYPE_SHARED,
+};
+
+static const struct rt_16550_pci_board rt_16550_moxa_cp132u = {
+   .name = Moxa CP-132U,
+   .resource_base_addr = 2,
+   .nports = 2,
+   .port_ofs = 8,
+   .baud_base = 921600,
+   .tx_fifo = 16,
+   .irqtype = RTDM_IRQTYPE_SHARED,
+};
+
+static const struct rt_16550_pci_board rt_16550_moxa_cp134u = {
+   .name = Moxa CP-134U,
+   .resource_base_addr = 2,
+   .nports = 4,
+   .port_ofs = 8,
+   .baud_base = 921600,
+   .tx_fifo = 16,
+   .irqtype = RTDM_IRQTYPE_SHARED,
+};
+
+static const struct rt_16550_pci_board rt_16550_moxa_cp138u = {
+   .name = Moxa CP-138U,
+   .resource_base_addr = 2,
+   .nports = 8,
+   .port_ofs = 8,
+   .baud_base = 921600,
+   .tx_fifo = 16,
+   .irqtype = RTDM_IRQTYPE_SHARED,
+};
+
+static const struct rt_16550_pci_board rt_16550_moxa_cp168u = {
+   .name = Moxa CP-168U,
+   .resource_base_addr = 2,
+   .nports = 8,
+   .port_ofs = 8,
+   .baud_base = 921600,
+   .tx_fifo = 16,
+   .irqtype = RTDM_IRQTYPE_SHARED,
+};
+#endif
+
 DEFINE_PCI_DEVICE_TABLE( rt_16550_pci_table ) = {
+#if defined(CONFIG_XENO_DRIVERS_16550A_PCI_MOXA)
+   {PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_C104),
+.driver_data = (unsigned long)rt_16550_moxa_c104},
+   {PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_C168),
+