RTDM rework (2)
Hi,
here comes a second attempt at introducing a file descriptor support for other purposes than RTDM drivers.
This time, the file descriptors are called rtdm_fd and are part of the RTDM API, but can be used by the POSIX personality. The actual RB-tree where they are stored is part of the xnsys_ppd structure, as this way it can be used by one of the RTDM and POSIX personalities, even if the current process is not bound to the other personality.
I have posted the patches to the timerbench, switchtest, rtdm, xddp, iddp and bufp drivers to allow seeing the API changes.
Regards.
Signature · 1 line
Gilles.
PATCH 1/9 cobalt/rtdm: base protocol devices on xnid
--- include/cobalt/kernel/rtdm/driver.h | 6 +- kernel/cobalt/rtdm/device.c | 103 ++++++++++++----------------------- kernel/cobalt/rtdm/internal.h | 4 +- kernel/cobalt/rtdm/proc.c | 60 ++++++++++---------- 4 files changed, 71 insertions(+), 102 deletions(-)
include/cobalt/kernel/rtdm/driver.h +5 -1
@@ -39,6 +39,7 @@#include <cobalt/kernel/apc.h> #include <cobalt/kernel/shadow.h> #include <cobalt/kernel/init.h> +#include <cobalt/kernel/tree.h> #include <rtdm/rtdm.h> /* debug support */
@@ -444,7 +445,10 @@ rtdm_private_to_context(void *dev_private) }struct rtdm_dev_reserved { -struct list_head entry; +union { +struct list_head entry; +struct xnid id; + };atomic_t refcount;struct rtdm_dev_context *exclusive_context; };
kernel/cobalt/rtdm/device.c +36 -67
181 lines not on this page · raw message
kernel/cobalt/rtdm/internal.h +2 -2
@@ -23,6 +23,7 @@#include <linux/list.h> #include <linux/sem.h> #include <cobalt/kernel/ppd.h> +#include <cobalt/kernel/tree.h> #include <rtdm/driver.h> #define RTDM_FD_MAX CONFIG_XENO_OPT_RTDM_FILDES
@@ -49,9 +50,8 @@ extern struct rtdm_fildes fildes_table[];extern int open_fildes;extern struct semaphore nrt_dev_lock;extern unsigned int devname_hashtab_size; -extern unsigned int protocol_hashtab_size;extern struct list_head *rtdm_named_devices; -extern struct list_head *rtdm_protocol_devices; +extern struct rb_root rtdm_protocol_devices;extern struct xnpersonality rtdm_personality;extern int rtdm_initialised;
kernel/cobalt/rtdm/proc.c +28 -32
102 lines not on this page · raw message
Signature · 1 line
1.7.10.4
PATCH 2/9 cobalt/rtdm: base named devices on nucleus registry
--- include/cobalt/kernel/rtdm/driver.h | 12 ++-- kernel/cobalt/rtdm/device.c | 115 +++++++++++------------------------ kernel/cobalt/rtdm/internal.h | 2 +- kernel/cobalt/rtdm/proc.c | 94 ++++++++-------------------- 4 files changed, 69 insertions(+), 154 deletions(-)
include/cobalt/kernel/rtdm/driver.h +8 -4
@@ -445,8 +445,12 @@ rtdm_private_to_context(void *dev_private) }struct rtdm_dev_reserved { +unsigned magic;union { -struct list_head entry; +struct { +struct list_head entry; +xnhandle_t handle; + };struct xnid id; };atomic_t refcount;
@@ -461,6 +465,9 @@ struct rtdm_dev_reserved {* not reside in write-protected memory. */ struct rtdm_device { +/** Data stored by RTDM inside a registered device (internal use only) */ +struct rtdm_dev_reserved reserved; +/** Revision number of this structure, see * @ref drv_versioning "Driver Versioning" defines */ int struct_version;
@@ -529,9 +536,6 @@ struct rtdm_device {int device_id;/** Driver definable device data */ void *device_data; - -/** Data stored by RTDM inside a registered device (internal use only) */ -struct rtdm_dev_reserved reserved; };/** @} devregister */
kernel/cobalt/rtdm/device.c +34 -81
216 lines not on this page · raw message
kernel/cobalt/rtdm/internal.h +1 -1
@@ -50,7 +50,7 @@ extern struct rtdm_fildes fildes_table[];extern int open_fildes;extern struct semaphore nrt_dev_lock;extern unsigned int devname_hashtab_size; -extern struct list_head *rtdm_named_devices; +extern struct list_head rtdm_named_devices;extern struct rb_root rtdm_protocol_devices;extern struct xnpersonality rtdm_personality;
kernel/cobalt/rtdm/proc.c +26 -68
149 lines not on this page · raw message
Signature · 1 line
1.7.10.4
PATCH 3/9 cobalt/rtdm: extract fd API
In reply to Gilles Chanteperdrixfor use by POSIX skin.
--- include/cobalt/kernel/ppd.h | 3 +- include/cobalt/kernel/rtdm/driver.h | 338 ++++---------------- include/cobalt/kernel/rtdm/fd.h | 186 +++++++++++ include/cobalt/kernel/rtdm/rtdm.h | 48 +-- include/cobalt/uapi/rtdm/syscall.h | 17 +- kernel/cobalt/Kconfig | 8 +- kernel/cobalt/init.c | 3 + kernel/cobalt/posix/select.c | 47 +-- kernel/cobalt/rtdm/Makefile | 1 + kernel/cobalt/rtdm/core.c | 578 ++++++----------------------------- kernel/cobalt/rtdm/device.c | 48 +-- kernel/cobalt/rtdm/drvlib.c | 36 +-- kernel/cobalt/rtdm/fd.c | 541 ++++++++++++++++++++++++++++++++ kernel/cobalt/rtdm/internal.h | 6 - kernel/cobalt/rtdm/proc.c | 33 +- kernel/cobalt/rtdm/syscall.c | 72 ++--- kernel/cobalt/shadow.c | 3 + lib/cobalt/init.c | 7 +- lib/cobalt/rtdm.c | 502 ++++++++++++++---------------- 19 files changed, 1212 insertions(+), 1265 deletions(-) create mode 100644 include/cobalt/kernel/rtdm/fd.h create mode 100644 kernel/cobalt/rtdm/fd.c
include/cobalt/kernel/ppd.h +2 -1
@@ -25,10 +25,10 @@#include <cobalt/kernel/shadow.h> #include <cobalt/kernel/lock.h> #include <cobalt/kernel/heap.h> +#include <rtdm/fd.h> #define NR_PERSONALITIES 4 -/* Called with nklock locked irqs off. */ void *xnshadow_private_get (unsigned int muxid);struct xnsys_ppd {
@@ -36,6 +36,7 @@ struct xnsys_ppd {unsigned long mayday_addr;atomic_t refcnt;char *exe_path; +struct rb_root fds; };struct xnshadow_process {
include/cobalt/kernel/rtdm/driver.h +51 -287
509 lines not on this page · raw message
include/cobalt/kernel/rtdm/fd.h new file +186 -0
186 lines not on this page · raw message
include/cobalt/kernel/rtdm/rtdm.h +16 -32
80 lines not on this page · raw message
include/cobalt/uapi/rtdm/syscall.h +8 -9
@@ -21,14 +21,13 @@#define RTDM_BINDING_MAGIC 0x5254444D -#define sc_rtdm_fdcount 0 -#define sc_rtdm_open 1 -#define sc_rtdm_socket 2 -#define sc_rtdm_close 3 -#define sc_rtdm_ioctl 4 -#define sc_rtdm_read 5 -#define sc_rtdm_write 6 -#define sc_rtdm_recvmsg 7 -#define sc_rtdm_sendmsg 8 +#define sc_rtdm_open 0 +#define sc_rtdm_socket 1 +#define sc_rtdm_close 2 +#define sc_rtdm_ioctl 3 +#define sc_rtdm_read 4 +#define sc_rtdm_write 5 +#define sc_rtdm_recvmsg 6 +#define sc_rtdm_sendmsg 7#endif /* !_COBALT_UAPI_RTDM_SYSCALL_H */
kernel/cobalt/Kconfig +3 -5
@@ -349,11 +349,9 @@ config XENO_OPT_RTDM_FILDES default 128 help - This option defines the maximum number of RTDM file - descriptors which can be opened at the same time. RTDM file - descriptors are a global resource all applications share, - either via RTDM directly or via the embedded services of the - Cobalt API. + This option defines the maximum number of kernel-space RTDM + file descriptors which can be opened at the same time. RTDM + kernel-space file descriptors are a global resource. endmenu
kernel/cobalt/init.c +3 -0
@@ -33,6 +33,7 @@#include <cobalt/kernel/pipe.h> #include <cobalt/kernel/select.h> #include <cobalt/kernel/vdso.h> +#include <rtdm/fd.h> #include "rtdm/internal.h" #include "posix/internal.h" #include "procfs.h"
@@ -420,6 +421,8 @@ static int __init xenomai_init(void)if (ret) goto cleanup_rtdm; +rtdm_fd_init (); +printk (XENO_INFO "Cobalt v%s enabled%s\n" ,XENO_VERSION_STRING , boot_notice);
kernel/cobalt/posix/select.c +8 -39
73 lines not on this page · raw message
kernel/cobalt/rtdm/Makefile +1 -0
@@ -4,6 +4,7 @@ obj-$(CONFIG_XENOMAI) += rtdm.o rtdm-y := core.o \ device.o \ drvlib.o \ + fd.o \ init.o \ syscall.o
kernel/cobalt/rtdm/core.c +90 -488
690 lines not on this page · raw message
kernel/cobalt/rtdm/device.c +13 -35
107 lines not on this page · raw message
kernel/cobalt/rtdm/drvlib.c +18 -18
@@ -1884,7 +1884,7 @@ static struct file_operations rtdm_mmap_fops = { .get_unmapped_area = rtdm_unmapped_area }; -static int rtdm_do_mmap (rtdm_user_info_t *user_info, +static int rtdm_do_mmap (struct rtdm_fd *fd,struct rtdm_mmap_data *mmap_data,size_t len,int prot,void **pptr) {
@@ -1912,7 +1912,7 @@ static int rtdm_do_mmap(rtdm_user_info_t *user_info, filp->f_op = (typeof(filp->f_op))old_fops; filp->private_data = old_priv_data; -filp_close (filp, user_info->files); +filp_close (filp, current->files);if (IS_ERR_VALUE (u_addr))return (int )u_addr;
@@ -1976,7 +1976,7 @@ static int rtdm_do_mmap(rtdm_user_info_t *user_info,* * Rescheduling: possible. */ -int rtdm_mmap_to_user(rtdm_user_info_t *user_info, +int rtdm_mmap_to_user(struct rtdm_fd *fd, void *src_addr, size_t len, int prot, void **pptr, struct vm_operations_struct *vm_ops,
@@ -1989,7 +1989,7 @@ int rtdm_mmap_to_user(rtdm_user_info_t *user_info, .vm_private_data = vm_private_data }; -return rtdm_do_mmap (user_info, &mmap_data, len, prot, pptr); +return rtdm_do_mmap (fd, &mmap_data, len, prot, pptr); }EXPORT_SYMBOL_GPL (rtdm_mmap_to_user);
@@ -2044,7 +2044,7 @@ EXPORT_SYMBOL_GPL(rtdm_mmap_to_user);* * Rescheduling: possible. */ -int rtdm_iomap_to_user(rtdm_user_info_t *user_info, +int rtdm_iomap_to_user(struct rtdm_fd *fd, phys_addr_t src_addr, size_t len, int prot, void **pptr, struct vm_operations_struct *vm_ops,
@@ -2057,7 +2057,7 @@ int rtdm_iomap_to_user(rtdm_user_info_t *user_info, .vm_private_data = vm_private_data }; -return rtdm_do_mmap (user_info, &mmap_data, len, prot, pptr); +return rtdm_do_mmap (fd, &mmap_data, len, prot, pptr); }EXPORT_SYMBOL_GPL (rtdm_iomap_to_user);
@@ -2086,16 +2086,16 @@ EXPORT_SYMBOL_GPL(rtdm_iomap_to_user);* * Rescheduling: possible. */ -int rtdm_munmap (rtdm_user_info_t *user_info,void *ptr,size_t len) +int rtdm_munmap (struct rtdm_fd *fd,void *ptr,size_t len) {int err;if (!XENO_ASSERT (RTDM ,xnsched_root_p ()))return -EPERM ; -down_write (&user_info->mm->mmap_sem); - err =do_munmap (user_info->mm, (unsigned long )ptr, len); -up_write (&user_info->mm->mmap_sem); +down_write (¤t->mm->mmap_sem); + err =do_munmap (current->mm, (unsigned long )ptr, len); +up_write (¤t->mm->mmap_sem);return err; }
@@ -2263,7 +2263,7 @@ void rtdm_free(void *ptr);* * Rescheduling: never. */ -int rtdm_read_user_ok (rtdm_user_info_t *user_info,const void __user *ptr, +int rtdm_read_user_ok (struct rtdm_fd *fd,const void __user *ptr,size_t size);/**
@@ -2287,7 +2287,7 @@ int rtdm_read_user_ok(rtdm_user_info_t *user_info, const void __user *ptr,* * Rescheduling: never. */ -int rtdm_rw_user_ok (rtdm_user_info_t *user_info,const void __user *ptr, +int rtdm_rw_user_ok (struct rtdm_fd *fd,const void __user *ptr,size_t size);/**
@@ -2316,7 +2316,7 @@ int rtdm_rw_user_ok(rtdm_user_info_t *user_info, const void __user *ptr,* * Rescheduling: never. */ -int rtdm_copy_from_user (rtdm_user_info_t *user_info,void *dst, +int rtdm_copy_from_user (struct rtdm_fd *fd,void *dst,const void __user *src,size_t size);/**
@@ -2346,7 +2346,7 @@ int rtdm_copy_from_user(rtdm_user_info_t *user_info, void *dst,* * Rescheduling: never. */ -int rtdm_safe_copy_from_user (rtdm_user_info_t *user_info,void *dst, +int rtdm_safe_copy_from_user (struct rtdm_fd *fd,void *dst,const void __user *src,size_t size);/**
@@ -2375,7 +2375,7 @@ int rtdm_safe_copy_from_user(rtdm_user_info_t *user_info, void *dst,* * Rescheduling: never. */ -int rtdm_copy_to_user (rtdm_user_info_t *user_info,void __user *dst, +int rtdm_copy_to_user (struct rtdm_fd *fd,void __user *dst,const void *src,size_t size);/**
@@ -2405,7 +2405,7 @@ int rtdm_copy_to_user(rtdm_user_info_t *user_info, void __user *dst,* * Rescheduling: never. */ -int rtdm_safe_copy_to_user (rtdm_user_info_t *user_info,void __user *dst, +int rtdm_safe_copy_to_user (struct rtdm_fd *fd,void __user *dst,const void *src,size_t size);/**
@@ -2436,7 +2436,7 @@ int rtdm_safe_copy_to_user(rtdm_user_info_t *user_info, void __user *dst,* * Rescheduling: never. */ -int rtdm_strncpy_from_user (rtdm_user_info_t *user_info,char *dst, +int rtdm_strncpy_from_user (struct rtdm_fd *fd,char *dst,const char __user *src,size_t count);/**
@@ -2482,7 +2482,7 @@ int rtdm_in_rt_context(void);* * Rescheduling: never. */ -int rtdm_rt_capable (rtdm_user_info_t *user_info); +int rtdm_rt_capable (struct rtdm_fd *fd);#endif /* DOXYGEN_CPP */
kernel/cobalt/rtdm/fd.c new file +541 -0
541 lines not on this page · raw message
kernel/cobalt/rtdm/internal.h +0 -6
@@ -31,10 +31,6 @@#define DEF_DEVNAME_HASHTAB_SIZE 256/* entries in name hash table */ #define DEF_PROTO_HASHTAB_SIZE 256/* entries in protocol hash table */ -struct rtdm_fildes { -struct rtdm_dev_context *context; -}; -struct rtdm_process {#ifdef CONFIG_XENO_OPT_VFILE char name[32 ];
@@ -46,10 +42,8 @@ DECLARE_EXTERN_XNLOCK(rt_fildes_lock);DECLARE_EXTERN_XNLOCK (rt_dev_lock);extern int __rtdm_muxid; -extern struct rtdm_fildes fildes_table[];extern int open_fildes;extern struct semaphore nrt_dev_lock; -extern unsigned int devname_hashtab_size;extern struct list_head rtdm_named_devices;extern struct rb_root rtdm_protocol_devices;extern struct xnpersonality rtdm_personality;
kernel/cobalt/rtdm/proc.c +14 -19
@@ -184,40 +184,35 @@ static int openfd_show(struct xnvfile_regular_iterator *it, void *data)struct rtdm_dev_context *context;struct rtdm_device *device;struct rtdm_process owner; -int close_lock_count, fd; -spl_t s; +int close_lock_count, i; +struct rtdm_fd *fd;if (data ==NULL ) {xnvfile_puts (it,"Index\tLocked\tDevice\t\t\t\tOwner [PID]\n" );return 0 ; } - fd = (int )it->pos -1 ; + i = (int )it->pos -1 ; -xnlock_get_irqsave (&rt_fildes_lock, s); - - context = fildes_table[fd].context; -if (context ==NULL ) { -xnlock_put_irqrestore (&rt_fildes_lock, s); + fd =rtdm_fd_get (&__xnsys_global_ppd, i,RTDM_FD_MAGIC ); +if (fd ==NULL )return VFILE_SEQ_SKIP ; - } - close_lock_count =atomic_read (&context->close_lock_count); + context =rtdm_context (fd); + close_lock_count = fd->refs; device = context->device; -if (context->reserved.owner) -memcpy (&owner, context->reserved.owner,sizeof (owner)); -else { -strcpy (owner.name,"<kernel>" ); - owner.pid =-1 ; - } -xnlock_put_irqrestore (&rt_fildes_lock, s); +strcpy (owner.name,"<kernel>" ); + owner.pid =-1 ; -xnvfile_printf (it,"%d\t%d\t%-31s %s [%d]\n" , fd, +xnvfile_printf (it,"%d\t%d\t%-31s %s [%d]\n" , i, close_lock_count, (device->device_flags &RTDM_NAMED_DEVICE ) ? device->device_name : device->proc_name, owner.name, owner.pid); + +rtdm_fd_put (fd); +return 0 ; }
@@ -230,7 +225,7 @@ static ssize_t openfd_store(struct xnvfile_input *input)if (ret <0 )return ret; - cret =__rt_dev_close (current, (int )val); + cret =rtdm_fd_close (&__xnsys_global_ppd, (int )val,RTDM_FD_MAGIC );if (cret <0 )return cret;
kernel/cobalt/rtdm/syscall.c +29 -43
124 lines not on this page · raw message
kernel/cobalt/shadow.c +3 -0
@@ -58,6 +58,7 @@#include <cobalt/kernel/ppd.h> #include <cobalt/kernel/vdso.h> #include <cobalt/kernel/thread.h> +#include <rtdm/fd.h> #include <asm/xenomai/features.h> #include <asm/xenomai/syscall.h> #include <asm-generic/xenomai/mayday.h>
@@ -1601,6 +1602,7 @@ static void user_process_detach(void *arg)if (p->exe_path)kfree (p->exe_path); +rtdm_fd_cleanup (p);process_hash_remove (process);xnheap_destroy_mapped (&p->sem_heap, post_ppd_release,NULL );atomic_dec (&personalities[user_muxid]->refcnt);
@@ -1648,6 +1650,7 @@ static void *user_process_attach(void) exe_path =NULL ;/* Not lethal, but weird. */ } p->exe_path = exe_path; +xntree_init (&p->fds);atomic_set (&p->refcnt,1 );atomic_inc (&personalities[user_muxid]->refcnt);
lib/cobalt/init.c +1 -6
@@ -49,8 +49,6 @@ pthread_t __cobalt_main_tid;int __rtdm_muxid =-1 ; -int __rtdm_fd_start =INT_MAX ; -static void sigill_handler (int sig) {const char m[] ="no Xenomai support in kernel?\n" ;
@@ -151,11 +149,8 @@ void __libcobalt_init(void) breq.feat_req =XENOMAI_FEAT_DEP ; breq.abi_rev =XENOMAI_ABI_REV ; muxid =XENOMAI_SYSBIND (RTDM_BINDING_MAGIC , &breq); -if (muxid >0 ) { +if (muxid >0 ) __rtdm_muxid =__xn_mux_shifted_id (muxid); - __rtdm_fd_start =FD_SETSIZE -XENOMAI_SKINCALL0 (__rtdm_muxid, - sc_rtdm_fdcount); - }/* * Upon fork, in case the parent required init deferral, this
lib/cobalt/rtdm.c +225 -277
360 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.7.10.4
Part of the diff is not shown here. View the raw message.
PATCH 4/9 drivers/testing: adapt timerbench after RTDM changes
In reply to Gilles Chanteperdrix--- kernel/drivers/testing/timerbench.c | 90 +++++++++++++++-------------------- 1 file changed, 39 insertions(+), 51 deletions(-)
kernel/drivers/testing/timerbench.c +39 -51
@@ -189,12 +189,11 @@ static void timer_proc(rtdm_timer_t *timer) }while (err); } -static int rt_tmbench_open (struct rtdm_dev_context *context, -rtdm_user_info_t *user_info,int oflags) +static int rt_tmbench_open (struct rtdm_fd *context,int oflags) {struct rt_tmbench_context *ctx; - ctx = (struct rt_tmbench_context *)context->dev_private; + ctx =rtdm_context_to_private (context); ctx->mode =RTTST_TMBENCH_INVALID ;sema_init (&ctx->nrt_mutex,1 );
@@ -202,12 +201,11 @@ static int rt_tmbench_open(struct rtdm_dev_context *context,return 0 ; } -static int rt_tmbench_close (struct rtdm_dev_context *context, -rtdm_user_info_t *user_info) +static void rt_tmbench_close (struct rtdm_fd *context) {struct rt_tmbench_context *ctx; - ctx = (struct rt_tmbench_context *)context->dev_private; + ctx =rtdm_context_to_private (context);down (&ctx->nrt_mutex);
@@ -227,13 +225,10 @@ static int rt_tmbench_close(struct rtdm_dev_context *context, }up (&ctx->nrt_mutex); - -return 0 ; } -static int rt_tmbench_start (struct rtdm_dev_context *context, +static int rt_tmbench_start (struct rtdm_fd *context,struct rt_tmbench_context *ctx, -rtdm_user_info_t *user_info,struct rttst_tmbench_config __user *user_config) {int err =0 ;
@@ -242,9 +237,9 @@ static int rt_tmbench_start(struct rtdm_dev_context *context,struct rttst_tmbench_config *config = (struct rttst_tmbench_config *)user_config; -if (user_info) { +if (rtdm_context_user_p (context)) {if (rtdm_safe_copy_from_user - (user_info, &config_buf,user_config, + (context, &config_buf,user_config,sizeof (struct rttst_tmbench_config )) <0 )return -EFAULT ;
@@ -295,33 +290,28 @@ static int rt_tmbench_start(struct rtdm_dev_context *context,rtdm_event_init (&ctx->result_event,0 );if (config->mode ==RTTST_TMBENCH_TASK ) { -if (!test_bit (RTDM_CLOSING , &context->context_flags)) { - err =rtdm_task_init (&ctx->timer_task,"timerbench" , - timer_task_proc, ctx, - config->priority,0 ); -if (!err) - ctx->mode =RTTST_TMBENCH_TASK ; - } + err =rtdm_task_init (&ctx->timer_task,"timerbench" , + timer_task_proc, ctx, + config->priority,0 ); +if (!err) + ctx->mode =RTTST_TMBENCH_TASK ; }else {rtdm_timer_init (&ctx->timer, timer_proc, - context->device->device_name); +rtdm_context_device (context)->device_name); ctx->curr.test_loops =0 ; -if (!test_bit (RTDM_CLOSING , &context->context_flags)) { - ctx->mode =RTTST_TMBENCH_HANDLER ; + ctx->mode =RTTST_TMBENCH_HANDLER ; -RTDM_EXECUTE_ATOMICALLY ( - ctx->start_time = rtdm_clock_read_monotonic(); +RTDM_EXECUTE_ATOMICALLY ( + ctx->start_time = rtdm_clock_read_monotonic(); -/* first event: one millisecond from now. */ - ctx->date = ctx->start_time +1000000 ; +/* first event: one millisecond from now. */ + ctx->date = ctx->start_time +1000000 ; - err = -rtdm_timer_start (&ctx->timer, ctx->date,0 , -RTDM_TIMERMODE_ABSOLUTE ); - ); - } + err =rtdm_timer_start (&ctx->timer, ctx->date,0 , +RTDM_TIMERMODE_ABSOLUTE ); + ); }up (&ctx->nrt_mutex);
@@ -330,9 +320,9 @@ static int rt_tmbench_start(struct rtdm_dev_context *context, }static int rt_tmbench_stop (struct rt_tmbench_context *ctx, -rtdm_user_info_t *user_info,struct rttst_overall_bench_res __user *user_res) { +struct rtdm_fd *context =rtdm_private_to_context (ctx);int err =0 ;down (&ctx->nrt_mutex);
@@ -356,8 +346,8 @@ static int rt_tmbench_stop(struct rt_tmbench_context *ctx, ((ctx->result.overall.test_loops) >1 ? ctx->result.overall.test_loops : 2) - 1); -if (user_info) - err =rtdm_safe_copy_to_user (user_info, &user_res->result, +if (rtdm_context_user_p (context)) + err =rtdm_safe_copy_to_user (context, &user_res->result, &ctx->result.overall,sizeof (struct rttst_bench_res ));/* Do not break on error here - we may have to free a
@@ -373,19 +363,19 @@ static int rt_tmbench_stop(struct rt_tmbench_context *ctx,if (ctx->histogram_size >0 ) {int size = ctx->histogram_size *sizeof (long ); -if (user_info) { +if (rtdm_context_user_p (context)) {struct rttst_overall_bench_res res_buf; -if (rtdm_safe_copy_from_user (user_info, +if (rtdm_safe_copy_from_user (context, &res_buf, user_res,sizeof (res_buf)) <0 || -rtdm_safe_copy_to_user (user_info, +rtdm_safe_copy_to_user (context, (void __user *)res_buf.histogram_min, ctx->histogram_min, size) <0 || -rtdm_safe_copy_to_user (user_info, +rtdm_safe_copy_to_user (context, (void __user *)res_buf.histogram_max, ctx->histogram_max, size) <0 || -rtdm_safe_copy_to_user (user_info, +rtdm_safe_copy_to_user (context, (void __user *)res_buf.histogram_avg, ctx->histogram_avg, size) <0 ) err = -EFAULT ;
@@ -406,22 +396,21 @@ static int rt_tmbench_stop(struct rt_tmbench_context *ctx,return err; } -static int rt_tmbench_ioctl_nrt (struct rtdm_dev_context *context, -rtdm_user_info_t *user_info, +static int rt_tmbench_ioctl_nrt (struct rtdm_fd *context,unsigned int request,void __user *arg) {struct rt_tmbench_context *ctx;int err =0 ; - ctx = (struct rt_tmbench_context *)context->dev_private; + ctx =rtdm_context_to_private (context);switch (request) {case RTTST_RTIOC_TMBENCH_START : - err =rt_tmbench_start (context, ctx, user_info, arg); + err =rt_tmbench_start (context, ctx, arg);break ;case RTTST_RTIOC_TMBENCH_STOP : - err =rt_tmbench_stop (ctx, user_info, arg); + err =rt_tmbench_stop (ctx, arg);break ;case RTTST_RTIOC_INTERM_BENCH_RES :
@@ -435,14 +424,13 @@ static int rt_tmbench_ioctl_nrt(struct rtdm_dev_context *context,return err; } -static int rt_tmbench_ioctl_rt (struct rtdm_dev_context *context, -rtdm_user_info_t *user_info, +static int rt_tmbench_ioctl_rt (struct rtdm_fd *context,unsigned int request,void __user *arg) {struct rt_tmbench_context *ctx;int err =0 ; - ctx = (struct rt_tmbench_context *)context->dev_private; + ctx =rtdm_context_to_private (context);switch (request) {case RTTST_RTIOC_INTERM_BENCH_RES :
@@ -450,10 +438,10 @@ static int rt_tmbench_ioctl_rt(struct rtdm_dev_context *context,if (err)return err; -if (user_info) { +if (rtdm_context_user_p (context)) {struct rttst_interm_bench_res __user *user_res = arg; - err =rtdm_safe_copy_to_user (user_info, user_res, + err =rtdm_safe_copy_to_user (context, user_res, &ctx->result,sizeof (*user_res)); }else {
@@ -483,10 +471,10 @@ static struct rtdm_device device = { .context_size = sizeof(struct rt_tmbench_context), .device_name = "", - .open_nrt = rt_tmbench_open, + .open = rt_tmbench_open, .ops = { - .close_nrt = rt_tmbench_close, + .close = rt_tmbench_close, .ioctl_rt = rt_tmbench_ioctl_rt, .ioctl_nrt = rt_tmbench_ioctl_nrt,
Signature · 1 line
1.7.10.4
PATCH 5/9 drivers/testing: adapt switchtest after RTDM changes
In reply to Gilles Chanteperdrix--- kernel/drivers/testing/switchtest.c | 111 ++++++++++++++--------------------- 1 file changed, 45 insertions(+), 66 deletions(-)
kernel/drivers/testing/switchtest.c +45 -66
@@ -511,11 +511,9 @@ static void rtswitch_utask_waker(rtdm_nrtsig_t sig, void *arg)up (&ctx->utask->nrt_synch); } -static int rtswitch_open (struct rtdm_dev_context *context, -rtdm_user_info_t *user_info, -int oflags) +static int rtswitch_open (struct rtdm_fd *context,int oflags) { -rtswitch_context_t *ctx = (rtswitch_context_t *) context->dev_private; +rtswitch_context_t *ctx =rtdm_context_to_private (context);int err; ctx->tasks =NULL ;
@@ -534,10 +532,9 @@ static int rtswitch_open(struct rtdm_dev_context *context,return 0 ; } -static int rtswitch_close (struct rtdm_dev_context *context, -rtdm_user_info_t *user_info) +static void rtswitch_close (struct rtdm_fd *context) { -rtswitch_context_t *ctx = (rtswitch_context_t *) context->dev_private; +rtswitch_context_t *ctx =rtdm_context_to_private (context);unsigned i;if (ctx->tasks) {
@@ -556,16 +553,13 @@ static int rtswitch_close(struct rtdm_dev_context *context, }rtdm_timer_destroy (&ctx->wake_up_delay);rtdm_nrtsig_destroy (&ctx->wake_utask); - -return 0 ; } -static int rtswitch_ioctl_nrt (struct rtdm_dev_context *context, -rtdm_user_info_t *user_info, +static int rtswitch_ioctl_nrt (struct rtdm_fd *context,unsigned int request,void *arg) { -rtswitch_context_t *ctx = (rtswitch_context_t *) context->dev_private; +rtswitch_context_t *ctx =rtdm_context_to_private (context);struct rttst_swtest_task task;struct rttst_swtest_dir fromto;unsigned long count;
@@ -588,15 +582,15 @@ static int rtswitch_ioctl_nrt(struct rtdm_dev_context *context,return 0 ;case RTTST_RTIOC_SWTEST_REGISTER_UTASK : -if (!rtdm_rw_user_ok (user_info, arg,sizeof (task))) +if (!rtdm_rw_user_ok (context, arg,sizeof (task)))return -EFAULT ; -rtdm_copy_from_user (user_info, &task, arg,sizeof (task)); +rtdm_copy_from_user (context, &task, arg,sizeof (task)); err =rtswitch_register_task (ctx, &task);if (!err) -rtdm_copy_to_user (user_info, +rtdm_copy_to_user (context, arg, &task,sizeof (task));
@@ -604,15 +598,15 @@ static int rtswitch_ioctl_nrt(struct rtdm_dev_context *context,return err;case RTTST_RTIOC_SWTEST_CREATE_KTASK : -if (!rtdm_rw_user_ok (user_info, arg,sizeof (task))) +if (!rtdm_rw_user_ok (context, arg,sizeof (task)))return -EFAULT ; -rtdm_copy_from_user (user_info, &task, arg,sizeof (task)); +rtdm_copy_from_user (context, &task, arg,sizeof (task)); err =rtswitch_create_ktask (ctx, &task);if (!err) -rtdm_copy_to_user (user_info, +rtdm_copy_to_user (context, arg, &task,sizeof (task));
@@ -620,18 +614,18 @@ static int rtswitch_ioctl_nrt(struct rtdm_dev_context *context,return err;case RTTST_RTIOC_SWTEST_PEND : -if (!rtdm_read_user_ok (user_info, arg,sizeof (task))) +if (!rtdm_read_user_ok (context, arg,sizeof (task)))return -EFAULT ; -rtdm_copy_from_user (user_info, &task, arg,sizeof (task)); +rtdm_copy_from_user (context, &task, arg,sizeof (task));return rtswitch_pend_nrt (ctx, task.index);case RTTST_RTIOC_SWTEST_SWITCH_TO : -if (!rtdm_read_user_ok (user_info, arg,sizeof (fromto))) +if (!rtdm_read_user_ok (context, arg,sizeof (fromto)))return -EFAULT ; -rtdm_copy_from_user (user_info, +rtdm_copy_from_user (context, &fromto, arg,sizeof (fromto));
@@ -639,20 +633,20 @@ static int rtswitch_ioctl_nrt(struct rtdm_dev_context *context,return rtswitch_to_nrt (ctx, fromto.from, fromto.to);case RTTST_RTIOC_SWTEST_GET_SWITCHES_COUNT : -if (!rtdm_rw_user_ok (user_info, arg,sizeof (count))) +if (!rtdm_rw_user_ok (context, arg,sizeof (count)))return -EFAULT ; count = ctx->switches_count; -rtdm_copy_to_user (user_info, arg, &count,sizeof (count)); +rtdm_copy_to_user (context, arg, &count,sizeof (count));return 0 ;case RTTST_RTIOC_SWTEST_GET_LAST_ERROR : -if (!rtdm_rw_user_ok (user_info, arg,sizeof (ctx->error))) +if (!rtdm_rw_user_ok (context, arg,sizeof (ctx->error)))return -EFAULT ; -rtdm_copy_to_user (user_info, +rtdm_copy_to_user (context, arg, &ctx->error,sizeof (ctx->error));
@@ -664,12 +658,11 @@ static int rtswitch_ioctl_nrt(struct rtdm_dev_context *context, } } -static int rtswitch_ioctl_rt (struct rtdm_dev_context *context, -rtdm_user_info_t *user_info, +static int rtswitch_ioctl_rt (struct rtdm_fd *context,unsigned int request,void *arg) { -rtswitch_context_t *ctx = (rtswitch_context_t *) context->dev_private; +rtswitch_context_t *ctx =rtdm_context_to_private (context);struct rttst_swtest_task task;struct rttst_swtest_dir fromto;
@@ -680,18 +673,18 @@ static int rtswitch_ioctl_rt(struct rtdm_dev_context *context,return -ENOSYS ;case RTTST_RTIOC_SWTEST_PEND : -if (!rtdm_read_user_ok (user_info, arg,sizeof (task))) +if (!rtdm_read_user_ok (context, arg,sizeof (task)))return -EFAULT ; -rtdm_copy_from_user (user_info, &task, arg,sizeof (task)); +rtdm_copy_from_user (context, &task, arg,sizeof (task));return rtswitch_pend_rt (ctx, task.index);case RTTST_RTIOC_SWTEST_SWITCH_TO : -if (!rtdm_read_user_ok (user_info, arg,sizeof (fromto))) +if (!rtdm_read_user_ok (context, arg,sizeof (fromto)))return -EFAULT ; -rtdm_copy_from_user (user_info, +rtdm_copy_from_user (context, &fromto, arg,sizeof (fromto));
@@ -699,10 +692,10 @@ static int rtswitch_ioctl_rt(struct rtdm_dev_context *context,return rtswitch_to_rt (ctx, fromto.from, fromto.to);case RTTST_RTIOC_SWTEST_GET_LAST_ERROR : -if (!rtdm_rw_user_ok (user_info, arg,sizeof (ctx->error))) +if (!rtdm_rw_user_ok (context, arg,sizeof (ctx->error)))return -EFAULT ; -rtdm_copy_to_user (user_info, +rtdm_copy_to_user (context, arg, &ctx->error,sizeof (ctx->error));
@@ -715,43 +708,29 @@ static int rtswitch_ioctl_rt(struct rtdm_dev_context *context, }static struct rtdm_device device = { - struct_version:RTDM_DEVICE_STRUCT_VER , - - device_flags:RTDM_NAMED_DEVICE , - context_size:sizeof (rtswitch_context_t), - device_name:"" , - - open_rt:NULL , - open_nrt: rtswitch_open, - - ops: { - close_rt:NULL , - close_nrt: rtswitch_close, - - ioctl_rt: rtswitch_ioctl_rt, - ioctl_nrt: rtswitch_ioctl_nrt, + .struct_version =RTDM_DEVICE_STRUCT_VER , - read_rt:NULL , - read_nrt:NULL , + .device_flags =RTDM_NAMED_DEVICE , + .context_size =sizeof (rtswitch_context_t), + .device_name ="" , - write_rt:NULL , - write_nrt:NULL , + .open = rtswitch_open, - recvmsg_rt:NULL , - recvmsg_nrt:NULL , + .ops = { + .close = rtswitch_close, - sendmsg_rt:NULL , - sendmsg_nrt:NULL , + .ioctl_rt = rtswitch_ioctl_rt, + .ioctl_nrt = rtswitch_ioctl_nrt, }, - device_class:RTDM_CLASS_TESTING , - device_sub_class:RTDM_SUBCLASS_SWITCHTEST , - profile_version:RTTST_PROFILE_VER , - driver_name:"xeno_switchtest" , - driver_version:RTDM_DRIVER_VER (0 ,1 ,1 ), - peripheral_name:"Context Switch Test" , - provider_name:"Gilles Chanteperdrix" , - proc_name: device.device_name, + .device_class =RTDM_CLASS_TESTING , + .device_sub_class =RTDM_SUBCLASS_SWITCHTEST , + .profile_version =RTTST_PROFILE_VER , + .driver_name ="xeno_switchtest" , + .driver_version =RTDM_DRIVER_VER (0 ,1 ,1 ), + .peripheral_name ="Context Switch Test" , + .provider_name ="Gilles Chanteperdrix" , + .proc_name = device.device_name, };int __init __switchtest_init (void )
Signature · 1 line
1.7.10.4
PATCH 6/9 drivers/testing: adapt rtdmtest after RTDM changes
In reply to Gilles Chanteperdrix--- include/rtdm/uapi/testing.h | 3 +-- kernel/drivers/testing/rtdmtest.c | 54 ++++++++++++------------------------- testsuite/unit/rtdm.c | 11 -------- 3 files changed, 18 insertions(+), 50 deletions(-)
include/rtdm/uapi/testing.h +1 -2
@@ -103,8 +103,7 @@ struct rttst_swtest_error { };#define RTTST_RTDM_NORMAL_CLOSE 0 -#define RTTST_RTDM_DEFER_CLOSE_HANDLER 1 -#define RTTST_RTDM_DEFER_CLOSE_CONTEXT 2 +#define RTTST_RTDM_DEFER_CLOSE_CONTEXT 1#define RTIOC_TYPE_TESTING RTDM_CLASS_TESTING
kernel/drivers/testing/rtdmtest.c +17 -37
98 lines not on this page · raw message
testsuite/unit/rtdm.c +0 -11
@@ -75,17 +75,6 @@ int main(int argc, const char *argv[]) dev2 =check ("open" ,open (devname2,O_RDWR ), dev +1 );check ("close" ,close (dev2),0 ); -printf ("Defer close by driver handler\n" ); -check ("ioctl" ,ioctl (dev,RTTST_RTIOC_RTDM_DEFER_CLOSE , -RTTST_RTDM_DEFER_CLOSE_HANDLER ),0 ); - start =rt_timer_tsc (); -check ("close" ,close (dev),0 ); -check ("open" ,open (devname,O_RDWR ), -EBUSY ); - dev2 =check ("open" ,open (devname2,O_RDWR ), dev); -check ("close" ,close (dev2),0 ); -usleep (300000 ); - dev =check ("open" ,open (devname,O_RDWR ), dev); -printf ("Defer close by pending reference\n" );check ("ioctl" ,ioctl (dev,RTTST_RTIOC_RTDM_DEFER_CLOSE ,RTTST_RTDM_DEFER_CLOSE_CONTEXT ),0 );
Signature · 1 line
1.7.10.4
PATCH 7/9 drivers/ipc: adapt XDDP after RTDM changes
In reply to Gilles Chanteperdrix--- kernel/drivers/ipc/internal.h | 26 +++++----- kernel/drivers/ipc/rtipc.c | 67 +++++++++++------------- kernel/drivers/ipc/xddp.c | 115 ++++++++++++++++++++++------------------- 3 files changed, 104 insertions(+), 104 deletions(-)
kernel/drivers/ipc/internal.h +13 -13
@@ -42,28 +42,28 @@ struct rtipc_protocol {void (*proto_exit)(void );struct {int (*socket)(struct rtipc_private *priv, -rtdm_user_info_t *user_info); -int (*close)(struct rtipc_private *priv, -rtdm_user_info_t *user_info); +struct rtdm_fd *context); +void (*close)(struct rtipc_private *priv, +struct rtdm_fd *context);ssize_t (*recvmsg)(struct rtipc_private *priv, -rtdm_user_info_t *user_info, +struct rtdm_fd *context,struct msghdr *msg,int flags);ssize_t (*sendmsg)(struct rtipc_private *priv, -rtdm_user_info_t *user_info, +struct rtdm_fd *context,const struct msghdr *msg,int flags);ssize_t (*read)(struct rtipc_private *priv, -rtdm_user_info_t *user_info, +struct rtdm_fd *context,void *buf,size_t len);ssize_t (*write)(struct rtipc_private *priv, -rtdm_user_info_t *user_info, +struct rtdm_fd *context,const void *buf,size_t len);int (*ioctl)(struct rtipc_private *priv, -rtdm_user_info_t *user_info, +struct rtdm_fd *context,unsigned int request,void *arg); } proto_ops; }; -static inline void *rtipc_context_to_state (struct rtdm_dev_context *context) +static inline void *rtipc_context_to_state (struct rtdm_fd *context) {struct rtipc_private *p =rtdm_context_to_private (context);return p->state;
@@ -97,16 +97,16 @@ static inline void rtipc_ns_to_timeval(struct timeval *tv, nanosecs_rel_t ns) tv->tv_usec = nsecs /1000 ; } -int rtipc_get_arg (rtdm_user_info_t *user_info, +int rtipc_get_arg (struct rtdm_fd *fd,void *dst,const void *src,size_t len); -int rtipc_put_arg (rtdm_user_info_t *user_info, +int rtipc_put_arg (struct rtdm_fd *fd,void *dst,const void *src,size_t len); -int rtipc_get_sockaddr (rtdm_user_info_t *user_info, +int rtipc_get_sockaddr (struct rtdm_fd *fd,const void *arg,struct sockaddr_ipc **saddrp); -int rtipc_put_sockaddr (rtdm_user_info_t *user_info,void *arg, +int rtipc_put_sockaddr (struct rtdm_fd *fd,void *arg,const struct sockaddr_ipc *saddr);ssize_t rtipc_get_iov_flatlen (struct iovec *iov,int iovlen);
kernel/drivers/ipc/rtipc.c +30 -37
179 lines not on this page · raw message
kernel/drivers/ipc/xddp.c +61 -54
393 lines not on this page · raw message
Signature · 1 line
1.7.10.4
PATCH 8/9 drivers/ipc: adapt IDDP after RTDM changes
In reply to Gilles Chanteperdrix--- kernel/drivers/ipc/iddp.c | 114 +++++++++++++++++++++-------------------- kernel/drivers/ipc/internal.h | 10 ---- 2 files changed, 59 insertions(+), 65 deletions(-)
kernel/drivers/ipc/iddp.c +59 -55
@@ -192,7 +192,7 @@ static void __iddp_flush_pool(struct xnheap *heap, }static int iddp_socket (struct rtipc_private *priv, -rtdm_user_info_t *user_info) +struct rtdm_fd *context) {struct iddp_socket *sk = priv->state;
@@ -217,14 +217,16 @@ static int iddp_socket(struct rtipc_private *priv,return 0 ; } -static int iddp_close (struct rtipc_private *priv, -rtdm_user_info_t *user_info) +static void iddp_close (struct rtipc_private *priv, +struct rtdm_fd *context) {struct iddp_socket *sk = priv->state;struct iddp_message *mbuf;if (sk->name.sipc_port >-1 ) -xnmap_remove (portmap, sk->name.sipc_port); +RTDM_EXECUTE_ATOMICALLY ( + xnmap_remove(portmap, sk->name.sipc_port); + );rtdm_sem_destroy (&sk->insem);rtdm_event_destroy (&sk->privevt);
@@ -234,7 +236,7 @@ static int iddp_close(struct rtipc_private *priv,if (sk->bufpool != &kheap) {xnheap_destroy (&sk->privpool, __iddp_flush_pool,NULL ); -return 0 ; +return ; }/* Send unread datagrams back to the system heap. */
@@ -246,11 +248,11 @@ static int iddp_close(struct rtipc_private *priv,kfree (sk); -return 0 ; +return ; }static ssize_t __iddp_recvmsg (struct rtipc_private *priv, -rtdm_user_info_t *user_info, +struct rtdm_fd *context,struct iovec *iov,int iovlen,int flags,struct sockaddr_ipc *saddr) {
@@ -303,7 +305,7 @@ static ssize_t __iddp_recvmsg(struct rtipc_private *priv,if (iov[nvec].iov_len ==0 )continue ; vlen = wrlen >= iov[nvec].iov_len ? iov[nvec].iov_len : wrlen; -if (user_info) { +if (rtdm_context_user_p (context)) {xnbufd_map_uread (&bufd, iov[nvec].iov_base, vlen); ret =xnbufd_copy_from_kmem (&bufd, mbuf->data + rdoff, vlen);xnbufd_unmap_uread (&bufd);
@@ -327,7 +329,7 @@ static ssize_t __iddp_recvmsg(struct rtipc_private *priv, }static ssize_t iddp_recvmsg (struct rtipc_private *priv, -rtdm_user_info_t *user_info, +struct rtdm_fd *context,struct msghdr *msg,int flags) {struct iovec iov[RTIPC_IOV_MAX ];
@@ -347,23 +349,23 @@ static ssize_t iddp_recvmsg(struct rtipc_private *priv,return -EINVAL ;/* Copy I/O vector in */ -if (rtipc_get_arg (user_info, iov, msg->msg_iov, +if (rtipc_get_arg (context, iov, msg->msg_iov,sizeof (iov[0 ]) * msg->msg_iovlen))return -EFAULT ; - ret =__iddp_recvmsg (priv, user_info, + ret =__iddp_recvmsg (priv, context, iov, msg->msg_iovlen, flags, &saddr);if (ret <=0 )return ret;/* Copy the updated I/O vector back */ -if (rtipc_put_arg (user_info, msg->msg_iov, iov, +if (rtipc_put_arg (context, msg->msg_iov, iov,sizeof (iov[0 ]) * msg->msg_iovlen))return -EFAULT ;/* Copy the source address if required. */ if (msg->msg_name) { -if (rtipc_put_arg (user_info, msg->msg_name, +if (rtipc_put_arg (context, msg->msg_name, &saddr,sizeof (saddr)))return -EFAULT ; msg->msg_namelen =sizeof (struct sockaddr_ipc );
@@ -373,35 +375,34 @@ static ssize_t iddp_recvmsg(struct rtipc_private *priv, }static ssize_t iddp_read (struct rtipc_private *priv, -rtdm_user_info_t *user_info, +struct rtdm_fd *context,void *buf,size_t len) {struct iovec iov = { .iov_base = buf, .iov_len = len }; -return __iddp_recvmsg (priv, user_info, &iov,1 ,0 ,NULL ); +return __iddp_recvmsg (priv, context, &iov,1 ,0 ,NULL ); }static ssize_t __iddp_sendmsg (struct rtipc_private *priv, -rtdm_user_info_t *user_info, +struct rtdm_fd *context,struct iovec *iov,int iovlen,int flags,const struct sockaddr_ipc *daddr) {struct iddp_socket *sk = priv->state, *rsk; -struct rtdm_dev_context *rcontext;struct iddp_message *mbuf;ssize_t len, rdlen, vlen; +struct rtdm_fd *rcontext;int nvec, wroff, ret;struct xnbufd bufd; -void *p; len =rtipc_get_iov_flatlen (iov, iovlen);if (len ==0 )return 0 ; - p =xnmap_fetch_nocheck (portmap, daddr->sipc_port); -if (p ==NULL ) -return -ECONNRESET ; - - rcontext =rtdm_context_get (rtipc_map2fd (p)); +RTDM_EXECUTE_ATOMICALLY ( + rcontext = xnmap_fetch_nocheck(portmap, daddr->sipc_port); +if (rcontext &&rtdm_context_lock (rcontext) <0 ) + rcontext =NULL ; + );if (rcontext ==NULL )return -ECONNRESET ;
@@ -423,7 +424,7 @@ static ssize_t __iddp_sendmsg(struct rtipc_private *priv,if (iov[nvec].iov_len ==0 )continue ; vlen = rdlen >= iov[nvec].iov_len ? iov[nvec].iov_len : rdlen; -if (user_info) { +if (rtdm_context_user_p (context)) {xnbufd_map_uread (&bufd, iov[nvec].iov_base, vlen); ret =xnbufd_copy_to_kmem (mbuf->data + wroff, &bufd, vlen);xnbufd_unmap_uread (&bufd);
@@ -462,7 +463,7 @@ fail: }static ssize_t iddp_sendmsg (struct rtipc_private *priv, -rtdm_user_info_t *user_info, +struct rtdm_fd *context,const struct msghdr *msg,int flags) {struct iddp_socket *sk = priv->state;
@@ -478,7 +479,7 @@ static ssize_t iddp_sendmsg(struct rtipc_private *priv,return -EINVAL ;/* Fetch the destination address to send to. */ -if (rtipc_get_arg (user_info, &daddr, +if (rtipc_get_arg (context, &daddr, msg->msg_name,sizeof (daddr)))return -EFAULT ;
@@ -497,17 +498,17 @@ static ssize_t iddp_sendmsg(struct rtipc_private *priv,return -EINVAL ;/* Copy I/O vector in */ -if (rtipc_get_arg (user_info, iov, msg->msg_iov, +if (rtipc_get_arg (context, iov, msg->msg_iov,sizeof (iov[0 ]) * msg->msg_iovlen))return -EFAULT ; - ret =__iddp_sendmsg (priv, user_info, iov, + ret =__iddp_sendmsg (priv, context, iov, msg->msg_iovlen, flags, &daddr);if (ret <=0 )return ret;/* Copy updated I/O vector back */ -if (rtipc_put_arg (user_info, msg->msg_iov, iov, +if (rtipc_put_arg (context, msg->msg_iov, iov,sizeof (iov[0 ]) * msg->msg_iovlen))return -EFAULT ;
@@ -515,7 +516,7 @@ static ssize_t iddp_sendmsg(struct rtipc_private *priv, }static ssize_t iddp_write (struct rtipc_private *priv, -rtdm_user_info_t *user_info, +struct rtdm_fd *context,const void *buf,size_t len) {struct iovec iov = { .iov_base = (void *)buf, .iov_len = len };
@@ -524,14 +525,15 @@ static ssize_t iddp_write(struct rtipc_private *priv,if (sk->peer.sipc_port <0 )return -EDESTADDRREQ ; -return __iddp_sendmsg (priv, user_info, &iov,1 ,0 , &sk->peer); +return __iddp_sendmsg (priv, context, &iov,1 ,0 , &sk->peer); }static int __iddp_bind_socket (struct rtipc_private *priv,struct sockaddr_ipc *sa) {struct iddp_socket *sk = priv->state; -int ret =0 , port, fd; +int ret =0 , port; +struct rtdm_fd *fd;void *poolmem;size_t poolsz;
@@ -552,8 +554,10 @@ static int __iddp_bind_socket(struct rtipc_private *priv,/* Will auto-select a free port number if unspec (-1). */ port = sa->sipc_port; - fd =rtdm_private_to_context (priv)->fd; - port =xnmap_enter (portmap, port,rtipc_fd2map (fd)); + fd =rtdm_private_to_context (priv); +RTDM_EXECUTE_ATOMICALLY ( + port = xnmap_enter(portmap, port, fd); + );if (port <0 )return port == -EEXIST ? -EADDRINUSE : -ENOMEM ;
@@ -680,7 +684,7 @@ set_assoc: }static int __iddp_setsockopt (struct iddp_socket *sk, -rtdm_user_info_t *user_info, +struct rtdm_fd *context,void *arg) {struct _rtdm_setsockopt_args sopt;
@@ -689,7 +693,7 @@ static int __iddp_setsockopt(struct iddp_socket *sk,int ret =0 ;size_t len; -if (rtipc_get_arg (user_info, &sopt, arg,sizeof (sopt))) +if (rtipc_get_arg (context, &sopt, arg,sizeof (sopt)))return -EFAULT ;if (sopt.level ==SOL_SOCKET ) {
@@ -698,7 +702,7 @@ static int __iddp_setsockopt(struct iddp_socket *sk,case SO_RCVTIMEO :if (sopt.optlen !=sizeof (tv))return -EINVAL ; -if (rtipc_get_arg (user_info, &tv, +if (rtipc_get_arg (context, &tv, sopt.optval,sizeof (tv)))return -EFAULT ; sk->rx_timeout =rtipc_timeval_to_ns (&tv);
@@ -707,7 +711,7 @@ static int __iddp_setsockopt(struct iddp_socket *sk,case SO_SNDTIMEO :if (sopt.optlen !=sizeof (tv))return -EINVAL ; -if (rtipc_get_arg (user_info, &tv, +if (rtipc_get_arg (context, &tv, sopt.optval,sizeof (tv)))return -EFAULT ; sk->tx_timeout =rtipc_timeval_to_ns (&tv);
@@ -728,7 +732,7 @@ static int __iddp_setsockopt(struct iddp_socket *sk,case IDDP_POOLSZ :if (sopt.optlen !=sizeof (len))return -EINVAL ; -if (rtipc_get_arg (user_info, &len, +if (rtipc_get_arg (context, &len, sopt.optval,sizeof (len)))return -EFAULT ;if (len ==0 )
@@ -749,7 +753,7 @@ static int __iddp_setsockopt(struct iddp_socket *sk,case IDDP_LABEL :if (sopt.optlen <sizeof (plabel))return -EINVAL ; -if (rtipc_get_arg (user_info, &plabel, +if (rtipc_get_arg (context, &plabel, sopt.optval,sizeof (plabel)))return -EFAULT ; RTDM_EXECUTE_ATOMICALLY(
@@ -774,7 +778,7 @@ static int __iddp_setsockopt(struct iddp_socket *sk, }static int __iddp_getsockopt (struct iddp_socket *sk, -rtdm_user_info_t *user_info, +struct rtdm_fd *context,void *arg) {struct _rtdm_getsockopt_args sopt;
@@ -783,10 +787,10 @@ static int __iddp_getsockopt(struct iddp_socket *sk,socklen_t len;int ret =0 ; -if (rtipc_get_arg (user_info, &sopt, arg,sizeof (sopt))) +if (rtipc_get_arg (context, &sopt, arg,sizeof (sopt)))return -EFAULT ; -if (rtipc_get_arg (user_info, &len, sopt.optlen,sizeof (len))) +if (rtipc_get_arg (context, &len, sopt.optlen,sizeof (len)))return -EFAULT ;if (sopt.level ==SOL_SOCKET ) {
@@ -796,7 +800,7 @@ static int __iddp_getsockopt(struct iddp_socket *sk,if (len !=sizeof (tv))return -EINVAL ;rtipc_ns_to_timeval (&tv, sk->rx_timeout); -if (rtipc_put_arg (user_info, sopt.optval, +if (rtipc_put_arg (context, sopt.optval, &tv,sizeof (tv)))return -EFAULT ;break ;
@@ -805,7 +809,7 @@ static int __iddp_getsockopt(struct iddp_socket *sk,if (len !=sizeof (tv))return -EINVAL ;rtipc_ns_to_timeval (&tv, sk->tx_timeout); -if (rtipc_put_arg (user_info, sopt.optval, +if (rtipc_put_arg (context, sopt.optval, &tv,sizeof (tv)))return -EFAULT ;break ;
@@ -828,7 +832,7 @@ static int __iddp_getsockopt(struct iddp_socket *sk,RTDM_EXECUTE_ATOMICALLY ( strcpy(plabel.label, sk->label); ); -if (rtipc_put_arg (user_info, sopt.optval, +if (rtipc_put_arg (context, sopt.optval, &plabel,sizeof (plabel)))return -EFAULT ;break ;
@@ -841,7 +845,7 @@ static int __iddp_getsockopt(struct iddp_socket *sk, }static int __iddp_ioctl (struct rtipc_private *priv, -rtdm_user_info_t *user_info, +struct rtdm_fd *context,unsigned int request,void *arg) {struct sockaddr_ipc saddr, *saddrp = &saddr;
@@ -851,14 +855,14 @@ static int __iddp_ioctl(struct rtipc_private *priv,switch (request) {case _RTIOC_CONNECT: - ret =rtipc_get_sockaddr (user_info, arg, &saddrp); + ret =rtipc_get_sockaddr (context, arg, &saddrp);if (ret)return ret; ret =__iddp_connect_socket (sk, saddrp);break ;case _RTIOC_BIND: - ret =rtipc_get_sockaddr (user_info, arg, &saddrp); + ret =rtipc_get_sockaddr (context, arg, &saddrp);if (ret)return ret;if (saddrp ==NULL )
@@ -867,19 +871,19 @@ static int __iddp_ioctl(struct rtipc_private *priv,break ;case _RTIOC_GETSOCKNAME: - ret =rtipc_put_sockaddr (user_info, arg, &sk->name); + ret =rtipc_put_sockaddr (context, arg, &sk->name);break ;case _RTIOC_GETPEERNAME: - ret =rtipc_put_sockaddr (user_info, arg, &sk->peer); + ret =rtipc_put_sockaddr (context, arg, &sk->peer);break ;case _RTIOC_SETSOCKOPT: - ret =__iddp_setsockopt (sk, user_info, arg); + ret =__iddp_setsockopt (sk, context, arg);break ;case _RTIOC_GETSOCKOPT: - ret =__iddp_getsockopt (sk, user_info, arg); + ret =__iddp_getsockopt (sk, context, arg);break ;case _RTIOC_LISTEN:
@@ -899,13 +903,13 @@ static int __iddp_ioctl(struct rtipc_private *priv, }static int iddp_ioctl (struct rtipc_private *priv, -rtdm_user_info_t *user_info, +struct rtdm_fd *context,unsigned int request,void *arg) {if (rtdm_in_rt_context () && request == _RTIOC_BIND)return -ENOSYS ;/* Try downgrading to NRT */ -return __iddp_ioctl (priv, user_info, request, arg); +return __iddp_ioctl (priv, context, request, arg); }static int iddp_init (void )
kernel/drivers/ipc/internal.h +0 -10
@@ -69,16 +69,6 @@ static inline void *rtipc_context_to_state(struct rtdm_fd *context)return p->state; } -static inline void *rtipc_fd2map (int fd) -{ -return (void *)(long )(fd +1 ); -} - -static inline int rtipc_map2fd (void *p) -{ -return (long )p -1 ; -} -static inline nanosecs_rel_t rtipc_timeval_to_ns (const struct timeval *tv) {nanosecs_rel_t ns = tv->tv_usec *1000 ;
Signature · 1 line
1.7.10.4
PATCH 9/9 drivers/ipc: adapt BUFP after RTDM changes
In reply to Gilles Chanteperdrix--- kernel/drivers/ipc/bufp.c | 114 +++++++++++++++++++++++---------------------- 1 file changed, 58 insertions(+), 56 deletions(-)
kernel/drivers/ipc/bufp.c +58 -56
@@ -113,7 +113,7 @@ static struct xnpnode_link __bufp_pnode = {#endif /* !CONFIG_XENO_OPT_VFILE */ static int bufp_socket (struct rtipc_private *priv, -rtdm_user_info_t *user_info) +struct rtdm_fd *context) {struct bufp_socket *sk = priv->state;
@@ -139,8 +139,8 @@ static int bufp_socket(struct rtipc_private *priv,return 0 ; } -static int bufp_close (struct rtipc_private *priv, -rtdm_user_info_t *user_info) +static void bufp_close (struct rtipc_private *priv, +struct rtdm_fd *context) {struct bufp_socket *sk = priv->state;
@@ -148,7 +148,9 @@ static int bufp_close(struct rtipc_private *priv,rtdm_event_destroy (&sk->o_event);if (sk->name.sipc_port >-1 ) -xnmap_remove (portmap, sk->name.sipc_port); +RTDM_EXECUTE_ATOMICALLY ( + xnmap_remove(portmap, sk->name.sipc_port); + );if (sk->handle)xnregistry_remove (sk->handle);
@@ -157,8 +159,6 @@ static int bufp_close(struct rtipc_private *priv,free_pages_exact (sk->bufmem, sk->bufsz);kfree (sk); - -return 0 ; } static ssize_t __bufp_readbuf(struct bufp_socket *sk,
@@ -290,7 +290,7 @@ out: }static ssize_t __bufp_recvmsg (struct rtipc_private *priv, -rtdm_user_info_t *user_info, +struct rtdm_fd *context,struct iovec *iov,int iovlen,int flags,struct sockaddr_ipc *saddr) {
@@ -321,7 +321,7 @@ static ssize_t __bufp_recvmsg(struct rtipc_private *priv,if (iov[nvec].iov_len ==0 )continue ; vlen = wrlen >= iov[nvec].iov_len ? iov[nvec].iov_len : wrlen; -if (user_info) { +if (rtdm_context_user_p (context)) {xnbufd_map_uread (&bufd, iov[nvec].iov_base, vlen); ret =__bufp_readbuf (sk, &bufd, flags);xnbufd_unmap_uread (&bufd);
@@ -352,7 +352,7 @@ static ssize_t __bufp_recvmsg(struct rtipc_private *priv, }static ssize_t bufp_recvmsg (struct rtipc_private *priv, -rtdm_user_info_t *user_info, +struct rtdm_fd *context,struct msghdr *msg,int flags) {struct iovec iov[RTIPC_IOV_MAX ];
@@ -372,23 +372,23 @@ static ssize_t bufp_recvmsg(struct rtipc_private *priv,return -EINVAL ;/* Copy I/O vector in */ -if (rtipc_get_arg (user_info, iov, msg->msg_iov, +if (rtipc_get_arg (context, iov, msg->msg_iov,sizeof (iov[0 ]) * msg->msg_iovlen))return -EFAULT ; - ret =__bufp_recvmsg (priv, user_info, + ret =__bufp_recvmsg (priv, context, iov, msg->msg_iovlen, flags, &saddr);if (ret <=0 )return ret;/* Copy the updated I/O vector back */ -if (rtipc_put_arg (user_info, msg->msg_iov, iov, +if (rtipc_put_arg (context, msg->msg_iov, iov,sizeof (iov[0 ]) * msg->msg_iovlen))return -EFAULT ;/* Copy the source address if required. */ if (msg->msg_name) { -if (rtipc_put_arg (user_info, msg->msg_name, +if (rtipc_put_arg (context, msg->msg_name, &saddr,sizeof (saddr)))return -EFAULT ; msg->msg_namelen =sizeof (struct sockaddr_ipc );
@@ -398,11 +398,11 @@ static ssize_t bufp_recvmsg(struct rtipc_private *priv, }static ssize_t bufp_read (struct rtipc_private *priv, -rtdm_user_info_t *user_info, +struct rtdm_fd *context,void *buf,size_t len) {struct iovec iov = { .iov_base = buf, .iov_len = len }; -return __bufp_recvmsg (priv, user_info, &iov,1 ,0 ,NULL ); +return __bufp_recvmsg (priv, context, &iov,1 ,0 ,NULL ); } static ssize_t __bufp_writebuf(struct bufp_socket *rsk,
@@ -522,26 +522,25 @@ out: }static ssize_t __bufp_sendmsg (struct rtipc_private *priv, -rtdm_user_info_t *user_info, +struct rtdm_fd *context,struct iovec *iov,int iovlen,int flags,const struct sockaddr_ipc *daddr) {struct bufp_socket *sk = priv->state, *rsk; -struct rtdm_dev_context *rcontext;ssize_t len, rdlen, vlen, ret =0 ; +struct rtdm_fd *rcontext;struct xnbufd bufd;int nvec; -void *p; len =rtipc_get_iov_flatlen (iov, iovlen);if (len ==0 )return 0 ; - - p =xnmap_fetch_nocheck (portmap, daddr->sipc_port); -if (p ==NULL ) -return -ECONNRESET ; - - rcontext =rtdm_context_get (rtipc_map2fd (p)); + +RTDM_EXECUTE_ATOMICALLY ( + rcontext = xnmap_fetch_nocheck(portmap, daddr->sipc_port); +if (rcontext &&rtdm_context_lock (rcontext) <0 ) + rcontext =NULL ; + );if (rcontext ==NULL )return -ECONNRESET ;
@@ -569,7 +568,7 @@ static ssize_t __bufp_sendmsg(struct rtipc_private *priv,if (iov[nvec].iov_len ==0 )continue ; vlen = rdlen >= iov[nvec].iov_len ? iov[nvec].iov_len : rdlen; -if (user_info) { +if (rtdm_context_user_p (context)) {xnbufd_map_uread (&bufd, iov[nvec].iov_base, vlen); ret =__bufp_writebuf (rsk, sk, &bufd, flags);xnbufd_unmap_uread (&bufd);
@@ -596,7 +595,7 @@ fail: }static ssize_t bufp_sendmsg (struct rtipc_private *priv, -rtdm_user_info_t *user_info, +struct rtdm_fd *context,const struct msghdr *msg,int flags) {struct bufp_socket *sk = priv->state;
@@ -612,7 +611,7 @@ static ssize_t bufp_sendmsg(struct rtipc_private *priv,return -EINVAL ;/* Fetch the destination address to send to. */ -if (rtipc_get_arg (user_info, &daddr, +if (rtipc_get_arg (context, &daddr, msg->msg_name,sizeof (daddr)))return -EFAULT ;
@@ -631,17 +630,17 @@ static ssize_t bufp_sendmsg(struct rtipc_private *priv,return -EINVAL ;/* Copy I/O vector in */ -if (rtipc_get_arg (user_info, iov, msg->msg_iov, +if (rtipc_get_arg (context, iov, msg->msg_iov,sizeof (iov[0 ]) * msg->msg_iovlen))return -EFAULT ; - ret =__bufp_sendmsg (priv, user_info, iov, + ret =__bufp_sendmsg (priv, context, iov, msg->msg_iovlen, flags, &daddr);if (ret <=0 )return ret;/* Copy updated I/O vector back */ -if (rtipc_put_arg (user_info, msg->msg_iov, iov, +if (rtipc_put_arg (context, msg->msg_iov, iov,sizeof (iov[0 ]) * msg->msg_iovlen))return -EFAULT ;
@@ -649,7 +648,7 @@ static ssize_t bufp_sendmsg(struct rtipc_private *priv, }static ssize_t bufp_write (struct rtipc_private *priv, -rtdm_user_info_t *user_info, +struct rtdm_fd *context,const void *buf,size_t len) {struct iovec iov = { .iov_base = (void *)buf, .iov_len = len };
@@ -658,14 +657,15 @@ static ssize_t bufp_write(struct rtipc_private *priv,if (sk->peer.sipc_port <0 )return -EDESTADDRREQ ; -return __bufp_sendmsg (priv, user_info, &iov,1 ,0 , &sk->peer); +return __bufp_sendmsg (priv, context, &iov,1 ,0 , &sk->peer); }static int __bufp_bind_socket (struct rtipc_private *priv,struct sockaddr_ipc *sa) {struct bufp_socket *sk = priv->state; -int ret =0 , port, fd; +int ret =0 , port; +struct rtdm_fd *fd;if (sa->sipc_family !=AF_RTIPC )return -EINVAL ;
@@ -684,8 +684,10 @@ static int __bufp_bind_socket(struct rtipc_private *priv,/* Will auto-select a free port number if unspec (-1). */ port = sa->sipc_port; - fd =rtdm_private_to_context (priv)->fd; - port =xnmap_enter (portmap, port,rtipc_fd2map (fd)); + fd =rtdm_private_to_context (priv); +RTDM_EXECUTE_ATOMICALLY ( + port = xnmap_enter(portmap, port, fd); + );if (port <0 )return port == -EEXIST ? -EADDRINUSE : -ENOMEM ;
@@ -797,7 +799,7 @@ set_assoc: }static int __bufp_setsockopt (struct bufp_socket *sk, -rtdm_user_info_t *user_info, +struct rtdm_fd *context,void *arg) {struct _rtdm_setsockopt_args sopt;
@@ -806,7 +808,7 @@ static int __bufp_setsockopt(struct bufp_socket *sk,int ret =0 ;size_t len; -if (rtipc_get_arg (user_info, &sopt, arg,sizeof (sopt))) +if (rtipc_get_arg (context, &sopt, arg,sizeof (sopt)))return -EFAULT ;if (sopt.level ==SOL_SOCKET ) {
@@ -815,7 +817,7 @@ static int __bufp_setsockopt(struct bufp_socket *sk,case SO_RCVTIMEO :if (sopt.optlen !=sizeof (tv))return -EINVAL ; -if (rtipc_get_arg (user_info, &tv, +if (rtipc_get_arg (context, &tv, sopt.optval,sizeof (tv)))return -EFAULT ; sk->rx_timeout =rtipc_timeval_to_ns (&tv);
@@ -824,7 +826,7 @@ static int __bufp_setsockopt(struct bufp_socket *sk,case SO_SNDTIMEO :if (sopt.optlen !=sizeof (tv))return -EINVAL ; -if (rtipc_get_arg (user_info, &tv, +if (rtipc_get_arg (context, &tv, sopt.optval,sizeof (tv)))return -EFAULT ; sk->tx_timeout =rtipc_timeval_to_ns (&tv);
@@ -845,7 +847,7 @@ static int __bufp_setsockopt(struct bufp_socket *sk,case BUFP_BUFSZ :if (sopt.optlen !=sizeof (len))return -EINVAL ; -if (rtipc_get_arg (user_info, &len, +if (rtipc_get_arg (context, &len, sopt.optval,sizeof (len)))return -EFAULT ;if (len ==0 )
@@ -866,7 +868,7 @@ static int __bufp_setsockopt(struct bufp_socket *sk,case BUFP_LABEL :if (sopt.optlen <sizeof (plabel))return -EINVAL ; -if (rtipc_get_arg (user_info, &plabel, +if (rtipc_get_arg (context, &plabel, sopt.optval,sizeof (plabel)))return -EFAULT ; RTDM_EXECUTE_ATOMICALLY(
@@ -891,7 +893,7 @@ static int __bufp_setsockopt(struct bufp_socket *sk, }static int __bufp_getsockopt (struct bufp_socket *sk, -rtdm_user_info_t *user_info, +struct rtdm_fd *context,void *arg) {struct _rtdm_getsockopt_args sopt;
@@ -900,10 +902,10 @@ static int __bufp_getsockopt(struct bufp_socket *sk,socklen_t len;int ret =0 ; -if (rtipc_get_arg (user_info, &sopt, arg,sizeof (sopt))) +if (rtipc_get_arg (context, &sopt, arg,sizeof (sopt)))return -EFAULT ; -if (rtipc_get_arg (user_info, &len, sopt.optlen,sizeof (len))) +if (rtipc_get_arg (context, &len, sopt.optlen,sizeof (len)))return -EFAULT ;if (sopt.level ==SOL_SOCKET ) {
@@ -913,7 +915,7 @@ static int __bufp_getsockopt(struct bufp_socket *sk,if (len !=sizeof (tv))return -EINVAL ;rtipc_ns_to_timeval (&tv, sk->rx_timeout); -if (rtipc_put_arg (user_info, sopt.optval, +if (rtipc_put_arg (context, sopt.optval, &tv,sizeof (tv)))return -EFAULT ;break ;
@@ -922,7 +924,7 @@ static int __bufp_getsockopt(struct bufp_socket *sk,if (len !=sizeof (tv))return -EINVAL ;rtipc_ns_to_timeval (&tv, sk->tx_timeout); -if (rtipc_put_arg (user_info, sopt.optval, +if (rtipc_put_arg (context, sopt.optval, &tv,sizeof (tv)))return -EFAULT ;break ;
@@ -945,7 +947,7 @@ static int __bufp_getsockopt(struct bufp_socket *sk,RTDM_EXECUTE_ATOMICALLY ( strcpy(plabel.label, sk->label); ); -if (rtipc_put_arg (user_info, sopt.optval, +if (rtipc_put_arg (context, sopt.optval, &plabel,sizeof (plabel)))return -EFAULT ;break ;
@@ -958,7 +960,7 @@ static int __bufp_getsockopt(struct bufp_socket *sk, }static int __bufp_ioctl (struct rtipc_private *priv, -rtdm_user_info_t *user_info, +struct rtdm_fd *context,unsigned int request,void *arg) {struct sockaddr_ipc saddr, *saddrp = &saddr;
@@ -968,14 +970,14 @@ static int __bufp_ioctl(struct rtipc_private *priv,switch (request) {case _RTIOC_CONNECT: - ret =rtipc_get_sockaddr (user_info, arg, &saddrp); + ret =rtipc_get_sockaddr (context, arg, &saddrp);if (ret)return ret; ret =__bufp_connect_socket (sk, saddrp);break ;case _RTIOC_BIND: - ret =rtipc_get_sockaddr (user_info, arg, &saddrp); + ret =rtipc_get_sockaddr (context, arg, &saddrp);if (ret)return ret;if (saddrp ==NULL )
@@ -984,19 +986,19 @@ static int __bufp_ioctl(struct rtipc_private *priv,break ;case _RTIOC_GETSOCKNAME: - ret =rtipc_put_sockaddr (user_info, arg, &sk->name); + ret =rtipc_put_sockaddr (context, arg, &sk->name);break ;case _RTIOC_GETPEERNAME: - ret =rtipc_put_sockaddr (user_info, arg, &sk->peer); + ret =rtipc_put_sockaddr (context, arg, &sk->peer);break ;case _RTIOC_SETSOCKOPT: - ret =__bufp_setsockopt (sk, user_info, arg); + ret =__bufp_setsockopt (sk, context, arg);break ;case _RTIOC_GETSOCKOPT: - ret =__bufp_getsockopt (sk, user_info, arg); + ret =__bufp_getsockopt (sk, context, arg);break ;case _RTIOC_LISTEN:
@@ -1016,13 +1018,13 @@ static int __bufp_ioctl(struct rtipc_private *priv, }static int bufp_ioctl (struct rtipc_private *priv, -rtdm_user_info_t *user_info, +struct rtdm_fd *context,unsigned int request,void *arg) {if (rtdm_in_rt_context () && request == _RTIOC_BIND)return -ENOSYS ;/* Try downgrading to NRT */ -return __bufp_ioctl (priv, user_info, request, arg); +return __bufp_ioctl (priv, context, request, arg); }static int bufp_init (void )
Signature · 1 line
1.7.10.4
Quoted 6 lines · Gilles Chanteperdrix
Hi,
here comes a second attempt at introducing a file descriptor support for other purposes than RTDM drivers.
Quoted 8 lines
This time, the file descriptors are called
rtdm_fdand are part of the RTDM API, but can be used by the POSIX personality. The actual RB-tree where they are stored is part of thexnsys_ppdstructure, as this way it can be used by one of the RTDM and POSIX personalities, even if the current process is not bound to the other personality.I have posted the patches to the timerbench, switchtest, rtdm, xddp, iddp and bufp drivers to allow seeing the API changes.
Hi Jan,
ping?
I have a pile of code needing to be rebased on these patches, I would very much like to get all this merged before it bitrots too much.
Regards.
Signature · 1 line
Gilles.
Quoted 16 lines · Gilles Chanteperdrix
Quoted 6 lines · Gilles Chanteperdrix
Hi,
here comes a second attempt at introducing a file descriptor support for other purposes than RTDM drivers.
Quoted 8 lines
This time, the file descriptors are called
rtdm_fdand are part of the RTDM API, but can be used by the POSIX personality. The actual RB-tree where they are stored is part of thexnsys_ppdstructure, as this way it can be used by one of the RTDM and POSIX personalities, even if the current process is not bound to the other personality.I have posted the patches to the timerbench, switchtest, rtdm, xddp, iddp and bufp drivers to allow seeing the API changes.
Quoted 6 lines
Hi Jan,
ping?
I have a pile of code needing to be rebased on these patches, I would very much like to get all this merged before it bitrots too much.
Finally looking into them now. Do you happen to have them in git somewhere? Or what was the revision they once applied to?
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT RTC ITP SES-DE Corporate Competence Center Embedded Linux
Quoted 19 lines · Jan Kiszka
Quoted 18 lines · Gilles Chanteperdrix
Quoted 6 lines · Gilles Chanteperdrix
Hi,
here comes a second attempt at introducing a file descriptor support for other purposes than RTDM drivers.
Quoted 8 lines
This time, the file descriptors are called
rtdm_fdand are part of the RTDM API, but can be used by the POSIX personality. The actual RB-tree where they are stored is part of thexnsys_ppdstructure, as this way it can be used by one of the RTDM and POSIX personalities, even if the current process is not bound to the other personality.I have posted the patches to the timerbench, switchtest, rtdm, xddp, iddp and bufp drivers to allow seeing the API changes.
Hi Jan,
Quoted 7 lines
Quoted 4 lines
ping?
I have a pile of code needing to be rebased on these patches, I would very much like to get all this merged before it bitrots too much.
Finally looking into them now. Do you happen to have them in git somewhere? Or what was the revision they once applied to?
Branch for-forge-rtdm-rework in xenomai-gch.git.
Signature · 1 line
Gilles.
Quoted 22 lines · Gilles Chanteperdrix
Quoted 21 lines · Jan Kiszka
Quoted 20 lines · Gilles Chanteperdrix
Quoted 6 lines · Gilles Chanteperdrix
Hi,
here comes a second attempt at introducing a file descriptor support for other purposes than RTDM drivers.
Quoted 8 lines
This time, the file descriptors are called
rtdm_fdand are part of the RTDM API, but can be used by the POSIX personality. The actual RB-tree where they are stored is part of thexnsys_ppdstructure, as this way it can be used by one of the RTDM and POSIX personalities, even if the current process is not bound to the other personality.I have posted the patches to the timerbench, switchtest, rtdm, xddp, iddp and bufp drivers to allow seeing the API changes.
Hi Jan,
ping?
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
I have a pile of code needing to be rebased on these patches, I would very much like to get all this merged before it bitrots too much.
Finally looking into them now. Do you happen to have them in git somewhere? Or what was the revision they once applied to?
Branch for-forge-rtdm-rework in xenomai-gch.git.
Thanks, worked through this now. I'm fine with the general approach. We should prepare it for merge.
Some minor things I stumbled over while reading:
- rtdm_context_user_p (I personally still prefer something like "is_user") and rtdm_context_device (to_device?) are apparently public APIs and, thus, need documentation
- there are still things (arguments, functions etc.) called "context" that are of type rtdm_fd, thus should rather be called "fd", no?
- outdated documentation of rtdm_device
- diff highlighted quite a lot of trailing white spaces here
- API and struct versions should be increased to reflect the changes and allow drivers to wrap the difference if desired
BTW, some compat wrapping would be helpful, i.e. something to allow the same driver sources to be used for both Xenomai 2.x and 3.x. Have you already thought about any helpers/macros that could be provided by Xenomai (for copying over into out-of-tree drivers)?
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT RTC ITP SES-DE Corporate Competence Center Embedded Linux
Quoted 36 lines · Jan Kiszka
Quoted 22 lines · Gilles Chanteperdrix
Quoted 21 lines · Jan Kiszka
Quoted 20 lines · Gilles Chanteperdrix
Quoted 6 lines · Gilles Chanteperdrix
Hi,
here comes a second attempt at introducing a file descriptor support for other purposes than RTDM drivers.
Quoted 8 lines
This time, the file descriptors are called
rtdm_fdand are part of the RTDM API, but can be used by the POSIX personality. The actual RB-tree where they are stored is part of thexnsys_ppdstructure, as this way it can be used by one of the RTDM and POSIX personalities, even if the current process is not bound to the other personality.I have posted the patches to the timerbench, switchtest, rtdm, xddp, iddp and bufp drivers to allow seeing the API changes.
Hi Jan,
ping?
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
I have a pile of code needing to be rebased on these patches, I would very much like to get all this merged before it bitrots too much.
Finally looking into them now. Do you happen to have them in git somewhere? Or what was the revision they once applied to?
Branch for-forge-rtdm-rework in xenomai-gch.git.
Thanks, worked through this now. I'm fine with the general approach. We should prepare it for merge.
Some minor things I stumbled over while reading:
Quoted 9 lines
-
rtdm_context_user_p(I personally still prefer something like "is_user") andrtdm_context_device(to_device?) are apparently public APIs and, thus, need documentation
- there are still things (arguments, functions etc.) called "context" that are of typertdm_fd, thus should rather be called "fd", no?
- outdated documentation ofrtdm_device
- diff highlighted quite a lot of trailing white spaces here
- API and struct versions should be increased to reflect the changes and allow drivers to wrap the difference if desired
Ok, will cleanup the patches during the long week-end.
Quoted 5 lines
BTW, some compat wrapping would be helpful, i.e. something to allow the same driver sources to be used for both Xenomai 2.x and 3.x. Have you already thought about any helpers/macros that could be provided by Xenomai (for copying over into out-of-tree drivers)?
No, I have not tried thinking about this. Note that we could add the compatibility macros to xenomai 2.6 as well.
Signature · 1 line
Gilles.
Quoted 34 lines · Jan Kiszka
Quoted 22 lines · Gilles Chanteperdrix
Quoted 21 lines · Jan Kiszka
Quoted 20 lines · Gilles Chanteperdrix
Quoted 6 lines · Gilles Chanteperdrix
Hi,
here comes a second attempt at introducing a file descriptor support for other purposes than RTDM drivers.
Quoted 8 lines
This time, the file descriptors are called
rtdm_fdand are part of the RTDM API, but can be used by the POSIX personality. The actual RB-tree where they are stored is part of thexnsys_ppdstructure, as this way it can be used by one of the RTDM and POSIX personalities, even if the current process is not bound to the other personality.I have posted the patches to the timerbench, switchtest, rtdm, xddp, iddp and bufp drivers to allow seeing the API changes.
Hi Jan,
ping?
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
I have a pile of code needing to be rebased on these patches, I would very much like to get all this merged before it bitrots too much.
Finally looking into them now. Do you happen to have them in git somewhere? Or what was the revision they once applied to?
Branch for-forge-rtdm-rework in xenomai-gch.git.
Thanks, worked through this now. I'm fine with the general approach. We should prepare it for merge.
Quoted 7 lines
Some minor things I stumbled over while reading:
-
rtdm_context_user_p(I personally still prefer something like "is_user") andrtdm_context_device(to_device?) are apparently public APIs and, thus, need documentation
- there are still things (arguments, functions etc.) called "context" that are of typertdm_fd, thus should rather be called "fd", no?
Hi Jan,
I have started cleaning up the patches, however, about the last remark, do you propose to rename rtdm_private_to_context to rtdm_private_to_fd for instance? I was thinking that rtdm_fd was the new context, so we could keep the context everywhere? Keeping the old API names would limit the need for wrappers.
Regards.
Signature · 1 line
Gilles.
Quoted 43 lines · Gilles Chanteperdrix
Quoted 34 lines · Jan Kiszka
Quoted 22 lines · Gilles Chanteperdrix
Quoted 21 lines · Jan Kiszka
Quoted 20 lines · Gilles Chanteperdrix
Quoted 6 lines · Gilles Chanteperdrix
Hi,
here comes a second attempt at introducing a file descriptor support for other purposes than RTDM drivers.
Quoted 8 lines
This time, the file descriptors are called
rtdm_fdand are part of the RTDM API, but can be used by the POSIX personality. The actual RB-tree where they are stored is part of thexnsys_ppdstructure, as this way it can be used by one of the RTDM and POSIX personalities, even if the current process is not bound to the other personality.I have posted the patches to the timerbench, switchtest, rtdm, xddp, iddp and bufp drivers to allow seeing the API changes.
Hi Jan,
ping?
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
I have a pile of code needing to be rebased on these patches, I would very much like to get all this merged before it bitrots too much.
Finally looking into them now. Do you happen to have them in git somewhere? Or what was the revision they once applied to?
Branch for-forge-rtdm-rework in xenomai-gch.git.
Thanks, worked through this now. I'm fine with the general approach. We should prepare it for merge.
Quoted 7 lines
Some minor things I stumbled over while reading:
-
rtdm_context_user_p(I personally still prefer something like "is_user") andrtdm_context_device(to_device?) are apparently public APIs and, thus, need documentation
- there are still things (arguments, functions etc.) called "context" that are of typertdm_fd, thus should rather be called "fd", no?
Quoted 7 lines
Hi Jan,
I have started cleaning up the patches, however, about the last remark, do you propose to rename
rtdm_private_to_contexttortdm_private_to_fdfor instance? I was thinking thatrtdm_fdwas the new context, so we could keep the context everywhere? Keeping the old API names would limit the need for wrappers.
We can still keep (undocumented) legacy wrappers for a while, but it would be better to call the new API after what it is really translating.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT RTC ITP SES-DE Corporate Competence Center Embedded Linux
Quoted 46 lines · Jan Kiszka
Quoted 45 lines · Gilles Chanteperdrix
Quoted 34 lines · Jan Kiszka
Quoted 22 lines · Gilles Chanteperdrix
Quoted 21 lines · Jan Kiszka
Quoted 20 lines · Gilles Chanteperdrix
Quoted 6 lines · Gilles Chanteperdrix
Hi,
here comes a second attempt at introducing a file descriptor support for other purposes than RTDM drivers.
Quoted 8 lines
This time, the file descriptors are called
rtdm_fdand are part of the RTDM API, but can be used by the POSIX personality. The actual RB-tree where they are stored is part of thexnsys_ppdstructure, as this way it can be used by one of the RTDM and POSIX personalities, even if the current process is not bound to the other personality.I have posted the patches to the timerbench, switchtest, rtdm, xddp, iddp and bufp drivers to allow seeing the API changes.
Hi Jan,
ping?
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
I have a pile of code needing to be rebased on these patches, I would very much like to get all this merged before it bitrots too much.
Finally looking into them now. Do you happen to have them in git somewhere? Or what was the revision they once applied to?
Branch for-forge-rtdm-rework in xenomai-gch.git.
Thanks, worked through this now. I'm fine with the general approach. We should prepare it for merge.
Quoted 7 lines
Some minor things I stumbled over while reading:
-
rtdm_context_user_p(I personally still prefer something like "is_user") andrtdm_context_device(to_device?) are apparently public APIs and, thus, need documentation
- there are still things (arguments, functions etc.) called "context" that are of typertdm_fd, thus should rather be called "fd", no?Hi Jan,
Quoted 8 lines
Quoted 5 lines
I have started cleaning up the patches, however, about the last remark, do you propose to rename
rtdm_private_to_contexttortdm_private_to_fdfor instance? I was thinking thatrtdm_fdwas the new context, so we could keep the context everywhere? Keeping the old API names would limit the need for wrappers.We can still keep (undocumented) legacy wrappers for a while, but it would be better to call the new API after what it is really translating.
Hi Jan,
I have pushed a new version which addresses your comments in the "for-forge-rtdm-rework" branch.
You can ignore the "whitespace cleanup" commit, it is just there to allow me to simply commit without whitespace issues, it will be removed later on.
Note that analogy has not been updated to the API change, I will address this later, if you agree with the current version.
Regards.
Signature · 1 line
Gilles.
Quoted 61 lines · Gilles Chanteperdrix
Quoted 46 lines · Jan Kiszka
Quoted 45 lines · Gilles Chanteperdrix
Quoted 34 lines · Jan Kiszka
Quoted 22 lines · Gilles Chanteperdrix
Quoted 21 lines · Jan Kiszka
Quoted 20 lines · Gilles Chanteperdrix
Quoted 6 lines · Gilles Chanteperdrix
Hi,
here comes a second attempt at introducing a file descriptor support for other purposes than RTDM drivers.
Quoted 8 lines
This time, the file descriptors are called
rtdm_fdand are part of the RTDM API, but can be used by the POSIX personality. The actual RB-tree where they are stored is part of thexnsys_ppdstructure, as this way it can be used by one of the RTDM and POSIX personalities, even if the current process is not bound to the other personality.I have posted the patches to the timerbench, switchtest, rtdm, xddp, iddp and bufp drivers to allow seeing the API changes.
Hi Jan,
ping?
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
I have a pile of code needing to be rebased on these patches, I would very much like to get all this merged before it bitrots too much.
Finally looking into them now. Do you happen to have them in git somewhere? Or what was the revision they once applied to?
Branch for-forge-rtdm-rework in xenomai-gch.git.
Thanks, worked through this now. I'm fine with the general approach. We should prepare it for merge.
Quoted 7 lines
Some minor things I stumbled over while reading:
-
rtdm_context_user_p(I personally still prefer something like "is_user") andrtdm_context_device(to_device?) are apparently public APIs and, thus, need documentation
- there are still things (arguments, functions etc.) called "context" that are of typertdm_fd, thus should rather be called "fd", no?Hi Jan,
Quoted 8 lines
Quoted 5 lines
I have started cleaning up the patches, however, about the last remark, do you propose to rename
rtdm_private_to_contexttortdm_private_to_fdfor instance? I was thinking thatrtdm_fdwas the new context, so we could keep the context everywhere? Keeping the old API names would limit the need for wrappers.We can still keep (undocumented) legacy wrappers for a while, but it would be better to call the new API after what it is really translating.
Hi Jan,
I have pushed a new version which addresses your comments in the "for-forge-rtdm-rework" branch.
Quoted 6 lines
You can ignore the "whitespace cleanup" commit, it is just there to allow me to simply commit without whitespace issues, it will be removed later on.
Note that analogy has not been updated to the API change, I will address this later, if you agree with the current version.
I finally also pushed the analogy changes.
Signature · 1 line
Gilles.
Hi Gilles,
Quoted 11 lines · Gilles Chanteperdrix
Hi Jan,
I have pushed a new version which addresses your comments in the "for-forge-rtdm-rework" branch.
You can ignore the "whitespace cleanup" commit, it is just there to allow me to simply commit without whitespace issues, it will be removed later on.
Note that analogy has not been updated to the API change, I will address this later, if you agree with the current version.
Looks good.
Minor note on rtdm_device::open/socket doc: They are running non-real-time context, and the documentation should mention this clearly (compare to the regular file ops with their two variants).
I can't look at the implementation, unfortunately.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT RTC ITP SES-DE Corporate Competence Center Embedded Linux
Quoted 15 lines · Jan Kiszka
Hi Gilles,
Quoted 11 lines · Gilles Chanteperdrix
Hi Jan,
I have pushed a new version which addresses your comments in the "for-forge-rtdm-rework" branch.
You can ignore the "whitespace cleanup" commit, it is just there to allow me to simply commit without whitespace issues, it will be removed later on.
Note that analogy has not been updated to the API change, I will address this later, if you agree with the current version.
Quoted 7 lines
Looks good.
Minor note on rtdm_device::open/socket doc: They are running non-real-time context, and the documentation should mention this clearly (compare to the regular file ops with their two variants).
I can't look at the implementation, unfortunately.
Ok, one change you may have missed: the close callback now returns void. Since the close callback is now invoked when the reference count reaches 0, it is not always possible to return the error to the user. The automatic periodic invocation of close when it returns EAGAIN is also removed: it is possible to get the same result by using rtdm_fd_lock/rtdm_fd_unlock, so for the sake of simplicity, only this solution was kept.
Signature · 1 line
Gilles.
Quoted 15 lines · Jan Kiszka
Hi Gilles,
Quoted 11 lines · Gilles Chanteperdrix
Hi Jan,
I have pushed a new version which addresses your comments in the "for-forge-rtdm-rework" branch.
You can ignore the "whitespace cleanup" commit, it is just there to allow me to simply commit without whitespace issues, it will be removed later on.
Note that analogy has not been updated to the API change, I will address this later, if you agree with the current version.
Quoted 7 lines
Looks good.
Minor note on rtdm_device::open/socket doc: They are running non-real-time context, and the documentation should mention this clearly (compare to the regular file ops with their two variants).
I can't look at the implementation, unfortunately.
I have submitted the pull request in order to move forward, but we can still do some changes afterward.
Regards.
Signature · 1 line
Gilles.
Quoted 18 lines · Gilles Chanteperdrix
Quoted 17 lines · Jan Kiszka
Hi Gilles,
Quoted 11 lines · Gilles Chanteperdrix
Hi Jan,
I have pushed a new version which addresses your comments in the "for-forge-rtdm-rework" branch.
You can ignore the "whitespace cleanup" commit, it is just there to allow me to simply commit without whitespace issues, it will be removed later on.
Note that analogy has not been updated to the API change, I will address this later, if you agree with the current version.
Looks good.
Quoted 8 lines
Quoted 5 lines
Minor note on rtdm_device::open/socket doc: They are running non-real-time context, and the documentation should mention this clearly (compare to the regular file ops with their two variants).
I can't look at the implementation, unfortunately.
I have submitted the pull request in order to move forward, but we can still do some changes afterward.
Ack.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT RTC ITP SES-DE Corporate Competence Center Embedded Linux