[Xenomai-git] Alexis Berlemont : analogy: comsetic change in mite.c
Module: xenomai-abe Branch: analogy Commit: a301772cf408165481fd3d6a7bfb0d3af40545c2 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=a301772cf408165481fd3d6a7bfb0d3af40545c2 Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Sat Sep 4 00:30:10 2010 +0200 analogy: comsetic change in mite.c --- ksrc/drivers/analogy/national_instruments/mite.c |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ksrc/drivers/analogy/national_instruments/mite.c b/ksrc/drivers/analogy/national_instruments/mite.c index da1f6a5..9b0394a 100644 --- a/ksrc/drivers/analogy/national_instruments/mite.c +++ b/ksrc/drivers/analogy/national_instruments/mite.c @@ -332,10 +332,10 @@ void mite_release_channel(struct mite_channel *mite_chan) struct mite_struct *mite = mite_chan-mite; unsigned long flags; - // spin lock to prevent races with mite_request_channel + /* Spin lock to prevent races with mite_request_channel */ a4l_lock_irqsave(mite-lock, flags); if (mite-channel_allocated[mite_chan-channel]) { - // disable all channel's interrupts + /* disable all channel's interrupts */ writel(CHCR_CLR_DMA_IE | CHCR_CLR_LINKP_IE | CHCR_CLR_SAR_IE | CHCR_CLR_DONE_IE | CHCR_CLR_MRDY_IE | CHCR_CLR_DRDY_IE | ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: minor change in analogy Kconfig text
Module: xenomai-abe Branch: analogy Commit: a2a4a8dea6e81f830232f19884bcd3b677d1854b URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=a2a4a8dea6e81f830232f19884bcd3b677d1854b Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Tue Jul 20 00:07:04 2010 +0200 analogy: minor change in analogy Kconfig text --- ksrc/drivers/analogy/Kconfig |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/ksrc/drivers/analogy/Kconfig b/ksrc/drivers/analogy/Kconfig index b33fd67..7bc5ff2 100644 --- a/ksrc/drivers/analogy/Kconfig +++ b/ksrc/drivers/analogy/Kconfig @@ -6,7 +6,7 @@ config XENO_DRIVERS_ANALOGY help ANALOGY is a framework aimed at supporting data acquisition - drivers. + devices. config XENO_DRIVERS_ANALOGY_DEBUG depends on XENO_DRIVERS_ANALOGY ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: add comments in the buffer management code
Module: xenomai-abe Branch: analogy Commit: ab1559329229069ba7eb2dcf859b76dd16a4d738 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=ab1559329229069ba7eb2dcf859b76dd16a4d738 Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Wed Jul 21 00:22:46 2010 +0200 analogy: add comments in the buffer management code --- include/analogy/buffer.h | 52 ksrc/drivers/analogy/buffer.c | 23 +- 2 files changed, 68 insertions(+), 7 deletions(-) diff --git a/include/analogy/buffer.h b/include/analogy/buffer.h index 9e5ae8a..b5be3f0 100644 --- a/include/analogy/buffer.h +++ b/include/analogy/buffer.h @@ -90,9 +90,12 @@ struct a4l_buffer { }; typedef struct a4l_buffer a4l_buf_t; -/* Static inline Buffer related functions */ +/* --- Static inline functions related with + user-kernel data transfers --- */ -/* Produce memcpy function */ +/* The function __produce is an inline function which copies data into + the asynchronous buffer and takes care of the non-contiguous issue + when looping. This function is used in read and write operations */ static inline int __produce(a4l_cxt_t *cxt, a4l_buf_t *buf, void *pin, unsigned long count) { @@ -122,7 +125,9 @@ static inline int __produce(a4l_cxt_t *cxt, return ret; } -/* Consume memcpy function */ +/* The function __consume is an inline function which copies data from + the asynchronous buffer and takes care of the non-contiguous issue + when looping. This function is used in read and write operations */ static inline int __consume(a4l_cxt_t *cxt, a4l_buf_t *buf, void *pout, unsigned long count) { @@ -153,7 +158,9 @@ static inline int __consume(a4l_cxt_t *cxt, return ret; } -/* Munge procedure */ +/* The function __munge is an inline function which calls the + subdevice specific munge callback on contiguous windows within the + whole buffer. This function is used in read and write operations */ static inline void __munge(struct a4l_subdevice * subd, void (*munge) (struct a4l_subdevice *, void *, unsigned long), @@ -176,7 +183,9 @@ static inline void __munge(struct a4l_subdevice * subd, } } -/* Event consumption function */ +/* The function __handle_event can only be called from process context + (not interrupt service routine). It allows the client process to + retrieve the buffer status which has been updated by the driver */ static inline int __handle_event(a4l_buf_t * buf) { int ret = 0; @@ -194,7 +203,38 @@ static inline int __handle_event(a4l_buf_t * buf) return ret; } -/* Counters management functions */ +/* --- Counters management functions --- */ + +/* Here, we may wonder why we need more than two counters / pointers. + + Theoretically, we only need two counters (or two pointers): + - one which tells where the reader should be within the buffer + - one which tells where the writer should be within the buffer + + With these two counters (or pointers), we just have to check that + the writer does not overtake the reader inside the ring buffer + BEFORE any read / write operations. + + However, if one element is a DMA controller, we have to be more + careful. Generally a DMA transfer occurs like this: + DMA shot + |- then DMA interrupt + |- then DMA soft handler which checks the counter + + So, the checkings occur AFTER the write operations. + + Let's take an example: the reader is a software task and the writer + is a DMA controller. At the end of the DMA shot, the write counter + is higher than the read counter. Unfortunately, a read operation + occurs between the DMA shot and the DMA interrupt, so the handler + will not notice that an overflow occured. + + That is why tmp_count comes into play: tmp_count records the + read/consumer current counter before the next DMA shot and once the + next DMA shot is done, we check that the updated writer/producer + counter is not higher than tmp_count. Thus we are sure that the DMA + writer has not overtaken the reader because it was not able to + overtake the n-1 value. */ static inline int __pre_abs_put(a4l_buf_t * buf, unsigned long count) { diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index f9bcad7..8bd7d38 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -35,7 +35,11 @@ /* --- Initialization functions (init, alloc, free) --- */ -void a4l_free_buffer(a4l_buf_t *buf_desc) +/* The buffer charactistic is very close to the Comedi one: it is + allocated with vmalloc() and all physical addresses of the pages which + compose the virtual buffer are hold in a table */ + +void a4l_free_buffer(a4l_buf_t * buf_desc) { if (buf_desc-pg_list != NULL) { rtdm_free(buf_desc-pg_list); @@ -249,6
[Xenomai-git] Alexis Berlemont : analogy: [pcimio] rework the mite setup procedures
Module: xenomai-abe Branch: analogy Commit: b4978903c759ab09805c51aac573e7522df649a6 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=b4978903c759ab09805c51aac573e7522df649a6 Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Sat Sep 4 00:30:43 2010 +0200 analogy: [pcimio] rework the mite setup procedures --- .../analogy/national_instruments/mio_common.c | 116 +--- 1 files changed, 76 insertions(+), 40 deletions(-) diff --git a/ksrc/drivers/analogy/national_instruments/mio_common.c b/ksrc/drivers/analogy/national_instruments/mio_common.c index f9e6dba..a1a50dc 100644 --- a/ksrc/drivers/analogy/national_instruments/mio_common.c +++ b/ksrc/drivers/analogy/national_instruments/mio_common.c @@ -402,25 +402,30 @@ static int ni_request_gpct_mite_channel(a4l_dev_t * dev, static int ni_request_cdo_mite_channel(a4l_dev_t *dev) { unsigned long flags; + int err = 0; a4l_lock_irqsave(devpriv-mite_channel_lock, flags); + + /* No channel should be allocated... */ BUG_ON(devpriv-cdo_mite_chan); + /* ...until now */ devpriv-cdo_mite_chan = mite_request_channel(devpriv-mite, devpriv-cdo_mite_ring); - if (devpriv-cdo_mite_chan == NULL) { - a4l_unlock_irqrestore(devpriv-mite_channel_lock, - flags); + + if (devpriv-cdo_mite_chan) { + devpriv-cdo_mite_chan-dir = A4L_OUTPUT; + ni_set_cdo_dma_channel(dev, devpriv-cdo_mite_chan-channel); + } else { + err = -EBUSY; a4l_err(dev, ni_request_cdo_mite_channel: failed to reserve mite dma channel for correlated digital outut.); - return -EBUSY; } - devpriv-cdo_mite_chan-dir = A4L_OUTPUT; - ni_set_cdo_dma_channel(dev, devpriv-cdo_mite_chan-channel); + a4l_unlock_irqrestore(devpriv-mite_channel_lock, flags); - return 0; + return err; } void ni_release_ai_mite_channel(a4l_dev_t *dev) @@ -1425,13 +1430,18 @@ static void ni_ai_munge32(a4l_subd_t *subd, void *buf, unsigned long size) static int ni_ai_setup_MITE_dma(a4l_subd_t *subd) { a4l_dev_t *dev = subd-dev; - int retval; + unsigned long flags; + int err; - retval = ni_request_ai_mite_channel(dev); - if (retval) - return retval; + err = ni_request_ai_mite_channel(dev); + if (err 0) + return err; + + err = mite_buf_change(devpriv-ai_mite_chan-ring, subd); + if (err 0) + return err; - mite_buf_change(devpriv-ai_mite_chan-ring, subd); + a4l_lock_irqsave(devpriv-mite_channel_lock, flags); switch (boardtype.reg_type) { case ni_reg_611x: @@ -1449,36 +1459,74 @@ static int ni_ai_setup_MITE_dma(a4l_subd_t *subd) /* start the MITE */ mite_dma_arm(devpriv-ai_mite_chan); + a4l_unlock_irqrestore(devpriv-mite_channel_lock, flags); + return 0; } static int ni_ao_setup_MITE_dma(a4l_subd_t *subd) { a4l_dev_t *dev = subd-dev; - - int retval; unsigned long flags; + int err; - retval = ni_request_ao_mite_channel(dev); - if (retval) - return retval; + err = ni_request_ao_mite_channel(dev); + if (err 0) + return err; - if (devpriv-ao_mite_chan) { + err = mite_buf_change(devpriv-ao_mite_chan-ring, subd); + if (err 0) + return err; - mite_buf_change(devpriv-ao_mite_chan-ring, subd); + a4l_lock_irqsave(devpriv-mite_channel_lock, flags); + + if (devpriv-ao_mite_chan) { if (boardtype.reg_type (ni_reg_611x | ni_reg_6713)) { mite_prep_dma(devpriv-ao_mite_chan, 32, 32); } else { - /* doing 32 instead of 16 bit wide transfers from memory - makes the mite do 32 bit pci transfers, doubling pci bandwidth. */ + /* Doing 32 instead of 16 bit wide transfers + from memory makes the mite do 32 bit pci + transfers, doubling pci bandwidth. */ mite_prep_dma(devpriv-ao_mite_chan, 16, 32); } mite_dma_arm(devpriv-ao_mite_chan); } else - retval = -EIO; + err = -EIO; - return retval; + a4l_unlock_irqrestore(devpriv-mite_channel_lock, flags); + + return err; +} + +static int ni_cdo_setup_MITE_dma(a4l_subd_t *subd) +{ + a4l_dev_t *dev = subd-dev; + unsigned long flags; + int err; + + err = ni_request_cdo_mite_channel(dev); + if (err 0) + return err; + + /* No need to get a lock to setup the ring buffer */ + err =
[Xenomai-git] Alexis Berlemont : analogy: [pcimio] fix a forgotten warning
Module: xenomai-abe Branch: analogy Commit: b10d17463982202d703ba24da8300f22f749a767 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=b10d17463982202d703ba24da8300f22f749a767 Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Sat Sep 4 01:06:59 2010 +0200 analogy: [pcimio] fix a forgotten warning --- .../analogy/national_instruments/mio_common.c |1 - 1 files changed, 0 insertions(+), 1 deletions(-) diff --git a/ksrc/drivers/analogy/national_instruments/mio_common.c b/ksrc/drivers/analogy/national_instruments/mio_common.c index a1a50dc..17aa1f5 100644 --- a/ksrc/drivers/analogy/national_instruments/mio_common.c +++ b/ksrc/drivers/analogy/national_instruments/mio_common.c @@ -3441,7 +3441,6 @@ int ni_cdio_cmd(a4l_subd_t *subd, a4l_cmd_t *cmd) { a4l_dev_t *dev = subd-dev; unsigned cdo_mode_bits = CDO_FIFO_Mode_Bit | CDO_Halt_On_Error_Bit; - int retval; ni_writel(CDO_Reset_Bit, M_Offset_CDIO_Command); switch (cmd-scan_begin_src) { ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: minor changes in cmd_bits
Module: xenomai-abe Branch: analogy Commit: 51d69ef9393dbc183e21ab8adc58d55d6f11ea7f URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=51d69ef9393dbc183e21ab8adc58d55d6f11ea7f Author: Alexis Berlemont alexis.berlem...@gmail.com Date: Tue Aug 24 00:52:36 2010 +0200 analogy: minor changes in cmd_bits --- src/utils/analogy/cmd_bits.c |6 +- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/src/utils/analogy/cmd_bits.c b/src/utils/analogy/cmd_bits.c index aa0e082..966e278 100644 --- a/src/utils/analogy/cmd_bits.c +++ b/src/utils/analogy/cmd_bits.c @@ -45,7 +45,7 @@ a4l_cmd_t cmd = { .start_src = TRIG_INT, .start_arg = 0, .scan_begin_src = TRIG_EXT, - .scan_begin_arg = 0, /* in ns */ + .scan_begin_arg = 28, /* in ns */ .convert_src = TRIG_NOW, .convert_arg = 0, /* in ns */ .scan_end_src = TRIG_COUNT, @@ -270,6 +270,10 @@ out_cmd_bits: if (dsc.sbdata != NULL) free(dsc.sbdata); + /* The fd closure will automatically trigger a cancel; so, + wait a little bit for the end of the transfer */ + sleep(1); + /* Release the file descriptor */ a4l_close(dsc); ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : nucleus/bufd: fix documentation group tag
Module: xenomai-rpm Branch: for-upstream Commit: 201c288f37ff50da9be183016c60a132b167c8c3 URL: http://git.xenomai.org/?p=xenomai-rpm.git;a=commit;h=201c288f37ff50da9be183016c60a132b167c8c3 Author: Philippe Gerum r...@xenomai.org Date: Mon Sep 20 07:02:51 2010 +0200 nucleus/bufd: fix documentation group tag --- include/nucleus/bufd.h |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/include/nucleus/bufd.h b/include/nucleus/bufd.h index 262e546..2b56474 100644 --- a/include/nucleus/bufd.h +++ b/include/nucleus/bufd.h @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA * 02111-1307, USA. * - * \ingroup map + * \ingroup bufd */ #ifndef _XENO_NUCLEUS_BUFD_H ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : psos: fix t_shadow() regression
Module: xenomai-rpm Branch: for-upstream Commit: 55c1b958c6bd11068cacb6258c7a957ab581ce73 URL: http://git.xenomai.org/?p=xenomai-rpm.git;a=commit;h=55c1b958c6bd11068cacb6258c7a957ab581ce73 Author: Philippe Gerum r...@xenomai.org Date: Mon Sep 20 07:02:55 2010 +0200 psos: fix t_shadow() regression Introducing the u_mode support caused the t_shadow routine to send a bad arglist to the __t_create syscall used internally. --- ksrc/skins/psos+/syscall.c |3 ++- src/skins/psos+/task.c |4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ksrc/skins/psos+/syscall.c b/ksrc/skins/psos+/syscall.c index ef20b48..3ce53cc 100644 --- a/ksrc/skins/psos+/syscall.c +++ b/ksrc/skins/psos+/syscall.c @@ -110,7 +110,8 @@ static int __t_create(struct pt_regs *regs) * TCB pointer freely. */ tid = xnthread_handle(task-threadbase); task-pthread = bulk.a5; /* hidden pthread_t identifier. */ - if (__xn_safe_copy_to_user((void __user *)__xn_reg_arg2(regs), tid, + if (__xn_reg_arg2(regs) + __xn_safe_copy_to_user((void __user *)__xn_reg_arg2(regs), tid, sizeof(tid))) return -EFAULT; diff --git a/src/skins/psos+/task.c b/src/skins/psos+/task.c index 89b22ed..89871cb 100644 --- a/src/skins/psos+/task.c +++ b/src/skins/psos+/task.c @@ -180,10 +180,10 @@ u_long t_shadow(const char *name, /* Xenomai extension. */ bulk.a1 = (u_long)name; bulk.a2 = (u_long)prio; bulk.a3 = (u_long)flags; - bulk.a4 = (u_long)tid_r; + bulk.a4 = (u_long)xeno_init_current_mode(); bulk.a5 = (u_long)pthread_self(); - ret = XENOMAI_SKINCALL2(__psos_muxid, __psos_t_create, bulk, NULL); + ret = XENOMAI_SKINCALL3(__psos_muxid, __psos_t_create, bulk, tid_r, NULL); if (!ret) xeno_set_current(); ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : psos: fix t_shadow() regression
Module: xenomai-rpm Branch: for-upstream Commit: 99f1515db3b36308ad0b50bf07b2c4fcfac0738d URL: http://git.xenomai.org/?p=xenomai-rpm.git;a=commit;h=99f1515db3b36308ad0b50bf07b2c4fcfac0738d Author: Philippe Gerum r...@xenomai.org Date: Mon Sep 20 07:02:55 2010 +0200 psos: fix t_shadow() regression Introducing the u_mode support caused the t_shadow routine to send a bad arglist to the __t_create syscall used internally. --- ksrc/skins/psos+/syscall.c |3 ++- src/skins/psos+/task.c |4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ksrc/skins/psos+/syscall.c b/ksrc/skins/psos+/syscall.c index ef20b48..3ce53cc 100644 --- a/ksrc/skins/psos+/syscall.c +++ b/ksrc/skins/psos+/syscall.c @@ -110,7 +110,8 @@ static int __t_create(struct pt_regs *regs) * TCB pointer freely. */ tid = xnthread_handle(task-threadbase); task-pthread = bulk.a5; /* hidden pthread_t identifier. */ - if (__xn_safe_copy_to_user((void __user *)__xn_reg_arg2(regs), tid, + if (__xn_reg_arg2(regs) + __xn_safe_copy_to_user((void __user *)__xn_reg_arg2(regs), tid, sizeof(tid))) return -EFAULT; diff --git a/src/skins/psos+/task.c b/src/skins/psos+/task.c index 89b22ed..89871cb 100644 --- a/src/skins/psos+/task.c +++ b/src/skins/psos+/task.c @@ -180,10 +180,10 @@ u_long t_shadow(const char *name, /* Xenomai extension. */ bulk.a1 = (u_long)name; bulk.a2 = (u_long)prio; bulk.a3 = (u_long)flags; - bulk.a4 = (u_long)tid_r; + bulk.a4 = (u_long)xeno_init_current_mode(); bulk.a5 = (u_long)pthread_self(); - ret = XENOMAI_SKINCALL2(__psos_muxid, __psos_t_create, bulk, NULL); + ret = XENOMAI_SKINCALL3(__psos_muxid, __psos_t_create, bulk, tid_r, NULL); if (!ret) xeno_set_current(); ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : nucleus/bufd: fix documentation group tag
Module: xenomai-rpm Branch: for-upstream Commit: 7ad5bafd9f39c3255c6b3e22fe0bdf8a5fec4d58 URL: http://git.xenomai.org/?p=xenomai-rpm.git;a=commit;h=7ad5bafd9f39c3255c6b3e22fe0bdf8a5fec4d58 Author: Philippe Gerum r...@xenomai.org Date: Mon Sep 20 07:02:51 2010 +0200 nucleus/bufd: fix documentation group tag --- include/nucleus/bufd.h |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/include/nucleus/bufd.h b/include/nucleus/bufd.h index 262e546..2b56474 100644 --- a/include/nucleus/bufd.h +++ b/include/nucleus/bufd.h @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA * 02111-1307, USA. * - * \ingroup map + * \ingroup bufd */ #ifndef _XENO_NUCLEUS_BUFD_H ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git