Hello, I posted this to the RTAI mailing list, was wondering if any of you guys could check this out. I got PREEMPT_RT and RTAI patched to the same kernel but having trouble building RTAI itself. I was hoping I could maybe get some help here so we can have LinuxCNC switch between real-time POSIX threads and RTAI on the same kernel removing the need to reboot. Not really a LinuxCNC question though, please no ban.
Alec ----- Forwarded Message ----- From: Alec Ari <neotheu...@ymail.com> To: Rtai <r...@rtai.org> Sent: Sunday, November 6, 2022 at 07:01:45 PM CST Subject: Attempt at RTAI and PREEMPT_RT (same kernel) Hello, I patched the 5.4 PREEMPT_RT kernel source with IPIPE. The kernel boots and PREEMPT_RT latency is under 20 microseconds, however upon building RTAI, I get this: make[4]: Entering directory '/home/ntu/RTAI/src/ipc/mbx' CC [M] /home/ntu/RTAI/src/ipc/mbx/mbx.o In file included from /home/ntu/RTAI/include/rtai_schedcore.h:42, from /home/ntu/RTAI/src/ipc/mbx/mbx.c:40: /home/ntu/RTAI/src/ipc/mbx/mbx.c: In function ‘rt_typed_mbx_init’: ./include/linux/spinlock_rt.h:17:16: error: passing argument 1 of ‘rt_typed_sem_init’ from incompatible pointer type [-Werror=incompatible-pointer-types] 17 | rt_mutex_init(&(slock)->lock); \ | ^~~~~~~~~~~~~~ | | | struct rt_mutex * /home/ntu/RTAI/include/rtai_sem.h:244:58: note: in definition of macro ‘rt_mutex_init’ 244 | #define rt_mutex_init(mtx) rt_typed_sem_init(mtx, 1, RES_SEM) | ^~~ /home/ntu/RTAI/src/ipc/mbx/mbx.c:316:2: note: in expansion of macro ‘spin_lock_init’ 316 | spin_lock_init(&mbx->lock); | ^~~~~~~~~~~~~~ /home/ntu/RTAI/include/rtai_sem.h:113:47: note: expected ‘SEM *’ {aka ‘struct rt_semaphore *’} but argument is of type ‘struct rt_mutex *’ 113 | RTAI_SYSCALL_MODE void rt_typed_sem_init(SEM *sem, | ~~~~~^~~ cc1: some warnings being treated as errors make[6]: *** [scripts/Makefile.build:262: /home/ntu/RTAI/src/ipc/mbx/mbx.o] Error 1 make[5]: *** [Makefile:1739: /home/ntu/RTAI/src/ipc/mbx] Error 2 The code in question in mbx.c is this line: spin_lock_init(&mbx->lock); from this function: RTAI_SYSCALL_MODE int rt_typed_mbx_init(MBX *mbx, int size, int type) { if (!(mbx->bufadr = rt_malloc(size))) { return -ENOMEM; } rt_typed_sem_init(&(mbx->sndsem), 1, type & 3 ? type : BIN_SEM | type); rt_typed_sem_init(&(mbx->rcvsem), 1, type & 3 ? type : BIN_SEM | type); mbx->magic = RT_MBX_MAGIC; mbx->size = mbx->frbs = size; mbx->owndby = mbx->waiting_task = NULL; mbx->fbyte = mbx->lbyte = mbx->avbs = 0; spin_lock_init(&mbx->lock); #ifdef CONFIG_RTAI_RT_POLL mbx->poll_recv.pollq.prev = mbx->poll_recv.pollq.next = &(mbx->poll_recv.pollq); mbx->poll_send.pollq.prev = mbx->poll_send.pollq.next = &(mbx->poll_send.pollq); mbx->poll_recv.pollq.task = mbx->poll_send.pollq.task = NULL; spin_lock_init(&(mbx->poll_recv.pollock)); spin_lock_init(&(mbx->poll_send.pollock)); #endif return 0; } This was spin_lock_init() from the vanilla kernel source: #define spin_lock_init(_lock) \ do { \ spinlock_check(_lock); \ raw_spin_lock_init(&(_lock)->rlock); \ } while (0) And this is spin_lock_init() from PREEMPT_RT: #define spin_lock_init(slock) \ do { \ static struct lock_class_key __key; \ \ rt_mutex_init(&(slock)->lock); \ __rt_spin_lock_init(slock, #slock, &__key); \ } while (0) How do I fix the pointer type? It would be nice to have RTAI and PREEMPT_RT work together so one kernel can do it all, no rebooting. I'm also curious if RTAI latency improves. Alec _______________________________________________ Emc-developers mailing list Emc-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/emc-developers