SV: Question about using device driver with RTAI/LXRT

Philippe Gerum rpm at xenomai.org
Fri Aug 5 10:47:08 CEST 2005


Per-Arne Söderkvist wrote:
> Hello!
> 
> With the line "mlockall(MCL_CURRENT | MCL_FUTURE);" commented away, works
> the modified LXRT-program when I read/write to the "PCI-memory" (reflective
> memory), works both with own driver with /dev/vmic0 and direct mapping
> against /dev/mem.
> 
> I found that is an old problem (threads with "mlockall and mmap of IO
> devices don't mix", see below:
> "the use of mlockall(2) in a process that has mmap(2)ed the registers of an
> IO device will hang that process uninterruptibly. "
> 
> See thread/link below for more information:
> http://groups.google.se/group/fa.linux.kernel/browse_thread/thread/46154bebe
> b608da/4a9ba1e874d58783?lnk=st&q=mlockall+and+mmap+of+IO+devices+don%27t+mix
> &rnum=1&hl=sv#4a9ba1e874d58783).
> 
> This thread talks about a "There's an utterly ancient patch in -mm which
> might fix this.", see below:
> http://www.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.6/2.6.6-m
> m4/broken-out/get_user_pages-handle-VM_IO.patch
> 
> Note: I'm using kernel 2.6.9 and RTAI 3.2
> 
> 
> QUESTIONS:
> 
> Q1: Is there any new patch/solution for this problem or should I use this
> old solution?
>

If the following is an option implementation-wise, you should be able to 
work around this issue by splitting the mlockall request in two parts:

1. mlockall(MCL_CURRENT)
2. mmap() the PCI space
3. mlockall(MCL_FUTURE)


> Q2: I'm new at Linux/RTAI, so I need some explanation how to use a patch to
> update my system.
>     Or some explanation how to use any newer solution if any;)
> 
> 
> // Thanks in advance, Per-Arne
> 
> ------------------------------------------------------------------
> 
> Some of the earlier message remains below:
> ------------------------------------------
> Hello, thanks for your answer,
> 
> The testprogram stills hangs when I use /dev/mem with mmap to physical
> address? See below for more info. What's happens, any solution?
> 
> Background/Info:
> ----------------
> I't seems that I have managed to use /dev/mem and the physical address
> "0xd0000000" found with ***) below. I can read and write with memcpy both
> from testprogram using "fd=open("/dev/mem", O_RDWR);" with "test =mmap(NULL,
> Mem_Size, PROT_READ|PROT_WRITE, MAP_SHARED , fd, 0xd0000000".
> 
> Works also using the "driver", i.e. using "fd=open("/dev/vmic0",O_RDWR);"
> with "test =mmap(NULL, Mem_Size, PROT_READ|PROT_WRITE, MAP_SHARED , fd, 0);"
> and
> have of course loaded the vmic-driver with insmod before using it and
> created the "/dev/vmic0" with "mknod -m 660 /dev/vmic0 c 245 0".
> ...
> 
> 
> _______________________________________________
> RTAI mailing list
> RTAI at rtai.org
> https://mail.rtai.org/cgi-bin/mailman/listinfo/rtai
> 


-- 

Philippe.




More information about the Rtai mailing list