All of lore.kernel.org
 help / color / mirror / Atom feed
From: Philippe Gerum <rpm@xenomai.org>
To: Thomas.Debes@domain.hid
Cc: xenomai@xenomai.org
Subject: Re: [Xenomai-help] Problems using rtdm_iomap_to_user
Date: Fri, 16 May 2008 12:28:39 +0200	[thread overview]
Message-ID: <482D61D7.7090100@domain.hid> (raw)
In-Reply-To: <4B2EEE69E41E524EB7FCDC62A15D68D8EA1D3C@ARVMAIL1.mra.roland-man.biz>

Thomas.Debes@domain.hid wrote:
> Hi,
>  
> we are currently implementing an RTDM driver for our PCI based fieldbus card running in a MPC5200 system (Xenomai 2.3.5/Kernel 2.4 PPC). In order to provide backward compatibility for existing applications (using an older Linux version of the driver) we need an ioctl to let those applications read/write to a mapped io memory. Therefore we used the following (incomplete)  piece of code :
>  
> void map_dpm_to_user(pcidev_t *pcidev,  rtdm_user_info_t *user_info,  void *arg)
>  {
>         unsigned long memaddr = 0, memlen = 0;
>         unsigned char *dpm = NULL;
> 
>         /* Get start address and length of resource */
>         memaddr = pci_resource_start(pcidev, 2);
>         memlen = pci_resource_len(pcidev, 2);
> 
>         memaddr &= PCI_BASE_ADDRESS_IO_MASK;
> 
>         /* Request resource */
>         request_mem_region(memaddr, memlen, NULL);
> 
>         /* Remap for direct access in kernel space */
>         dpm = (unsigned char*)ioremap(memaddrmask, memlen);
> 
>         /* Map to user */
>         rtdm_iomap_to_user(user_info, memaddr, memlen,
>                          PROT_READ|PROT_WRITE, (void **)arg, NULL, NULL);
> }
>  
> This code executes without errors but the application freezes on accessing the mapped memory. There was a similar question posted earlier (https://mail.gna.org/public/xenomai-core/2007-09/msg00030.html) but the suggested solution can not be used with a 2.4 kernel because phys_mem_access_prot was introduced with the kernel version 2.6 (afaik).  Can you confirm this problem? Are there any related patches in the current Xenomai version (2.4.x)?
>

This has partially been fixed in v2.4.x and beyond, by using pgprot_noncached()
so set the VMA protection bits in wrap_remap_io_page_range(), and fixing
rtdm_mmap_buffer() to better distinguish protection flags between I/O memory and
kmem areas. The point is that you need _PAGE_NO_CACHE | _PAGE_GUARDED to be set
in the VMA prot bits.

However, ppc is a bit special, since there may be the added requirement to clear
the _PAGE_GUARDED flag in case the mapped area is actually some prefetchable IO
memory resource from a PCI device.

Well, you could try the 2.4.x fixes, in case that fits your needs. But we will
likely have to change wrap_remap_io_page_range() and rtdm_mmap_buffer() anew, to
use phys_mem_access_prot() where available.

> Thanks
> Thomas 
> 
> MAN Roland Druckmaschinen AG
> Vorsitzender des Aufsichtsrates: Hanno C. Fiedler
> Vorstand: Gerd Finkbeiner (Vorsitzender), Dr. Ingo Koch, Dr. Markus Rall, Paul Steidle    
> Sitz der Gesellschaft: Offenbach am Main, Registergericht: Amtsgericht Offenbach HRB-Nr. 42592    
> USt-Ident-Nr. DE 250200933
> 
> _______________________________________________
> Xenomai-help mailing list
> Xenomai-help@domain.hid
> https://mail.gna.org/listinfo/xenomai-help
> 


-- 
Philippe.


      reply	other threads:[~2008-05-16 10:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-15 21:30 [Xenomai-help] Problems using rtdm_iomap_to_user Thomas.Debes
2008-05-16 10:28 ` Philippe Gerum [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=482D61D7.7090100@domain.hid \
    --to=rpm@xenomai.org \
    --cc=Thomas.Debes@domain.hid \
    --cc=xenomai@xenomai.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.