All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-help] FW: rtdm_iomap_to_user() I-pipe error
@ 2011-04-14  6:14 Asier Tamayo
  2011-04-14  7:34 ` Jan Kiszka
  0 siblings, 1 reply; 9+ messages in thread
From: Asier Tamayo @ 2011-04-14  6:14 UTC (permalink / raw)
  To: xenomai


Hello,

I'm porting a PCI driver to a RTDM. Until now, I have successfully done most of the job.

I'm using Xenomai version 2.4.7 and Linux 2.6.27, from the ELinOS 5.0 distribution.

My problem appears with the rtdm_iomap_to_user() function. I want to allow a RT task to access the PCI memory directly, via mmap. As the RTDM has no mmap() function, I'm trying to use rtdm_iomap_to_user, but it always gives me the following error:

	I-pipe: Detected illicit call from domain 'Xenomai'
	        into a service reserved for domain 'Linux' and below.
	Pid: 991, comm: demo Not tainted 2.6.27.31-ELinOS-59 #66
	 [<c013682b>] ipipe_check_context+0x90/0x9a
	 [<c017ca34>] kmem_cache_alloc+0x23/0xd2
	 [<c0180038>] ? get_empty_filp+0x51/0xc0
	 [<c010db8f>] ? mcount+0x1f/0x23
	 [<c0180038>] get_empty_filp+0x51/0xc0
	 [<c0186ba9>] __path_lookup_intent_open+0x1e/0x7b
	 [<c0186c1b>] path_lookup_open+0x15/0x17
	 [<c01875aa>] do_filp_open+0x82/0x5c8
	 [<c010db8f>] ? mcount+0x1f/0x23
	 [<c0187af8>] ? filp_open+0x8/0x1c
	 [<c0187b07>] filp_open+0x17/0x1c
	 [<c016383d>] rtdm_do_mmap+0x27/0xb3
	 [<c01638f8>] rtdm_iomap_to_user+0x2f/0x31
	(...)
	 =======================
	I-pipe tracer log (100 points):
	    + func                    0 ipipe_trace_panic_freeze+0x9 (ipipe_check_context+0x3f)
	    + func                    0 ipipe_check_context+0x9 (kmem_cache_alloc+0x23)
	    + func                    0 kmem_cache_alloc+0xe (get_empty_filp+0x51)
	    + func                   -1 get_empty_filp+0xa (__path_lookup_intent_open+0x1e)
	    + func                   -2 __path_lookup_intent_open+0xe (path_lookup_open+0x15)
	    + func                   -2 path_lookup_open+0x8 (do_filp_open+0x82)
	    + func                   -3 do_filp_open+0xe (filp_open+0x17)
	    + func                   -4 filp_open+0x8 (rtdm_do_mmap+0x27)
	    + func                   -4 rtdm_do_mmap+0xe (rtdm_iomap_to_user+0x2f)
	    + func                   -5 rtdm_iomap_to_user+0xb (filstrup_rt_ioctl+0x102 [filstrup1_drv])
	(...)
	filstrup1_drv: rtdm_mmap = b5f02000 (retval 0)
	filstrup1_drv: rtdm_mmap = b5f02000 (retval 0)

My code is the following (simplified):

	struct xen_mydriver_context *xen_mydriver;

	int mydriver_rt_ioctl(struct rtdm_dev_context *context, rtdm_user_info_t *user_info, unsigned int cmd, void *arg)
	{
		(...)
		my_context = (struct xen_mydriver_context *)context->dev_private;
		switch(cmd) 
		{
		case IOCTL_MMAP:
			retval = rtdm_iomap_to_user(user_info,my_context->location, 300, PROT_READ|PROT_WRITE, (void**)arg, NULL, NULL);
			break;
		(...)
	}

	static int __devinit mydriver_probe(struct pci_dev *dev, const struct pci_device_id *id)
	{
		struct rtdm_device *rtdm_dev;
		(...)
		ret_val = pci_enable_device(dev);
		(...)
		xen_mydriver->location = pci_resource_start(dev,0);	// Physical address
		xen_mydriver->mem_size = pci_resource_len(dev,0);
		rtdm_dev = rtdm_malloc(sizeof(struct rtdm_device));
		(...)
		request_mem_region(xen_mydriver->location, xen_mydriver->mem_size, rtdm_dev->device_name);
		xen_mydriver->base_address = ioremap(xen_mydriver->location, xen_mydriver->mem_size);
		(...)
		ret_val = rtdm_dev_register(rtdm_dev);
	}

The value of xen_mydriver->location is 0x20000000. The value of xen_mydriver->base_address is 0xe0a00000.

My driver runs correctly until I call the IOCTL_MMAP ioctl. I can write to the PCI device directly in the RTDM driver by using the xen_mydriver->base_address pointer, but can't do it from the RT task.

I have searched the lists, but found no piece of information that could help me. I've found some clues (pci_alloc_consistent, rt_heap_*, /dev/rtheap, ...), but it has been impossible for me to solve this problem.

Can anyone help me with this issue? Has anyone got an example of how to use rtdm_iomap_to_user()? 

Thanks in advance, 

Asier





^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Xenomai-help] FW: rtdm_iomap_to_user() I-pipe error
  2011-04-14  6:14 [Xenomai-help] FW: rtdm_iomap_to_user() I-pipe error Asier Tamayo
@ 2011-04-14  7:34 ` Jan Kiszka
  2011-04-14  9:38   ` Asier Tamayo
  0 siblings, 1 reply; 9+ messages in thread
From: Jan Kiszka @ 2011-04-14  7:34 UTC (permalink / raw)
  To: Asier Tamayo; +Cc: xenomai

On 2011-04-14 08:14, Asier Tamayo wrote:
> 
> Hello,
> 
> I'm porting a PCI driver to a RTDM. Until now, I have successfully done most of the job.
> 
> I'm using Xenomai version 2.4.7 and Linux 2.6.27, from the ELinOS 5.0 distribution.
> 
> My problem appears with the rtdm_iomap_to_user() function. I want to allow a RT task to access the PCI memory directly, via mmap. As the RTDM has no mmap() function, I'm trying to use rtdm_iomap_to_user, but it always gives me the following error:
> 
> 	I-pipe: Detected illicit call from domain 'Xenomai'
> 	        into a service reserved for domain 'Linux' and below.

This is also documented: rtdm_iomap_to_user is not supposed to be called
from RT task context. This means your driver should only call it from
handlers registered for *_nrt entry points.

Jan

-- 
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Xenomai-help] FW: rtdm_iomap_to_user() I-pipe error
  2011-04-14  7:34 ` Jan Kiszka
@ 2011-04-14  9:38   ` Asier Tamayo
  2011-04-26 10:05     ` Asier Tamayo
  0 siblings, 1 reply; 9+ messages in thread
From: Asier Tamayo @ 2011-04-14  9:38 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: xenomai

Hello Jan,

First of all, thanks for your quick answer. 

Yes, you're completely right. My user application called rt_dev_ioctl, which eventually called rtdm_iomap_to_user, after rt_task_shadow. Now, I call it just after mlockall and rt_dev_open, and before rt_task_shadow. The rtdm_iomap_to_user function now seems to be working correctly, and dmesg no longer shows the previous errors. [By the way, it could be interesting to add a rtdm_in_rt_context() check in the rtdm_iomap_to_user function, which would return an error if in RT]

However, when I later try to write to the device, nothing is written. The mmap seems not to be correct. The following lines may show the problem:
	rtdm_printk("location %lx --> base %p --> iomap_to_user %p --> virt_to_phys %lx \n", 
		my_context->location, my_context->base_address, new_iomap, virt_to_phys(new_iomap));

gives the following result:
	location  20000000 -> base e0a00000 --> iomap_to_user b5f6f000 --> virt_to_phys f5f6f000

where the variables are:
	[unsigned long] xen_mydriver->location = pci_resource_start(dev,0);
	[void __iomem*] xen_mydriver->base_address = ioremap(xen_mydriver->location, xen_mydriver->mem_size);
	[void __iomem*] new_iomap
	rtdm_iomap_to_user(user_info,my_context->location, 300, PROT_READ|PROT_WRITE, &new_iomap, NULL, NULL);

If I execute in my RTDM driver:
	*(unsigned short*)(my_context->base_address + 0x100) = 0xAAAA;

I can see that the address is written. However, if I execute (either in the driver or from the RT task):
	*(unsigned short*)(new_iomap + 0x100) = 0xAAAA;
It doesn't work.

Does anybody know what is wrong? I'm sure I must be missing something important, but I can't see what.


Best regards,

Asier



> -----Original Message-----
> From: Jan Kiszka [mailto:jan.kiszka@domain.hid]
> Sent: Thursday, April 14, 2011 9:34 AM
> To: Asier Tamayo
> Cc: xenomai@xenomai.org
> Subject: Re: FW: rtdm_iomap_to_user() I-pipe error
> 
> 
> On 2011-04-14 08:14, Asier Tamayo wrote:
> > 
> > Hello,
> > 
> > I'm porting a PCI driver to a RTDM. Until now, I have 
> successfully done most of the job.
> > 
> > I'm using Xenomai version 2.4.7 and Linux 2.6.27, from the 
> ELinOS 5.0 distribution.
> > 
> > My problem appears with the rtdm_iomap_to_user() function. 
> I want to allow a RT task to access the PCI memory directly, 
> via mmap. As the RTDM has no mmap() function, I'm trying to 
> use rtdm_iomap_to_user, but it always gives me the following error:
> > 
> > 	I-pipe: Detected illicit call from domain 'Xenomai'
> > 	        into a service reserved for domain 'Linux' and below.
> 
> This is also documented: rtdm_iomap_to_user is not supposed 
> to be called
> from RT task context. This means your driver should only call it from
> handlers registered for *_nrt entry points.
> 
> Jan
> 
> -- 
> Siemens AG, Corporate Technology, CT T DE IT 1
> Corporate Competence Center Embedded Linux
> 


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Xenomai-help] FW: rtdm_iomap_to_user() I-pipe error
  2011-04-14  9:38   ` Asier Tamayo
@ 2011-04-26 10:05     ` Asier Tamayo
  2011-04-26 11:15       ` Gilles Chanteperdrix
  0 siblings, 1 reply; 9+ messages in thread
From: Asier Tamayo @ 2011-04-26 10:05 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: xenomai

Hello again,

When one doesn't get replies to his questions, it may be either because: i) they are too obvious (RTFM), ii) too difficult, iii) there is little information and it makes the checking in one's system impossible, or iv) they haven't been correctly explained. It may also be that the help demander is not being polite.

As i have received no answer, I will assume I haven't explained my problem correctly and will give myself a second chance ;) The following lines will just rewrite my question, since I haven't been able to find any new clue:

I'm porting a PCI driver to a RTDM, using Xenomai version 2.4.7 and Linux 2.6.27, from the ELinOS 5.0 distribution.

I want to allow a RT task to access the PCI memory directly, by calling the rtdm_iomap_to_user() function just after mlockall and rt_dev_open, and before rt_task_shadow. The function returns me a correct value, but then I cannot access the PCI registers by using that address. The mmap seems not to be correct. The values I get:

Driver:
	xen_mydriver->location = pci_resource_start(dev,0); --> 0x20000000 
	xen_mydriver->base_address = ioremap(xen_mydriver->location, xen_mydriver->mem_size); --> 0xe0a00000 
	*(unsigned short*)(my_context->base_address + 0x100) = 0xAAAA; --> It works

RT task:
	rtdm_iomap_to_user(user_info,my_context->location, 300, PROT_READ|PROT_WRITE, &new_iomap, NULL, NULL); --> 0xb5f6f000 
	virt_to_phys(new_iomap) --> 0xf5f6f000
	*(unsigned short*)(new_iomap + 0x100) = 0xAAAA; --> It doesn't work (either in the driver or in the RT task)

Hope this time I'll get some clue. I promise I won't send this question again without any new information.

Anyway, thanks for your time. Best regards,

Asier



> -----Original Message-----
> From: xenomai-help-bounces@domain.hid
> [mailto:xenomai-help-bounces@domain.hid Behalf Of Asier Tamayo
> Sent: Thursday, April 14, 2011 11:38 AM
> To: Jan Kiszka
> Cc: xenomai@xenomai.org
> Subject: Re: [Xenomai-help] FW: rtdm_iomap_to_user() I-pipe error
> 
> 
> Hello Jan,
> 
> First of all, thanks for your quick answer. 
> 
> Yes, you're completely right. My user application called 
> rt_dev_ioctl, which eventually called rtdm_iomap_to_user, 
> after rt_task_shadow. Now, I call it just after mlockall and 
> rt_dev_open, and before rt_task_shadow. The 
> rtdm_iomap_to_user function now seems to be working 
> correctly, and dmesg no longer shows the previous errors. [By 
> the way, it could be interesting to add a 
> rtdm_in_rt_context() check in the rtdm_iomap_to_user 
> function, which would return an error if in RT]
> 
> However, when I later try to write to the device, nothing is 
> written. The mmap seems not to be correct. The following 
> lines may show the problem:
> 	rtdm_printk("location %lx --> base %p --> iomap_to_user 
> %p --> virt_to_phys %lx \n", 
> 		my_context->location, my_context->base_address, 
> new_iomap, virt_to_phys(new_iomap));
> 
> gives the following result:
> 	location  20000000 -> base e0a00000 --> iomap_to_user 
> b5f6f000 --> virt_to_phys f5f6f000
> 
> where the variables are:
> 	[unsigned long] xen_mydriver->location = 
> pci_resource_start(dev,0);
> 	[void __iomem*] xen_mydriver->base_address = 
> ioremap(xen_mydriver->location, xen_mydriver->mem_size);
> 	[void __iomem*] new_iomap
> 	rtdm_iomap_to_user(user_info,my_context->location, 300, 
> PROT_READ|PROT_WRITE, &new_iomap, NULL, NULL);
> 
> If I execute in my RTDM driver:
> 	*(unsigned short*)(my_context->base_address + 0x100) = 0xAAAA;
> 
> I can see that the address is written. However, if I execute 
> (either in the driver or from the RT task):
> 	*(unsigned short*)(new_iomap + 0x100) = 0xAAAA;
> It doesn't work.
> 
> Does anybody know what is wrong? I'm sure I must be missing 
> something important, but I can't see what.
> 
> 
> Best regards,
> 
> Asier
> 
> 
> 
> > -----Original Message-----
> > From: Jan Kiszka [mailto:jan.kiszka@domain.hid]
> > Sent: Thursday, April 14, 2011 9:34 AM
> > To: Asier Tamayo
> > Cc: xenomai@xenomai.org
> > Subject: Re: FW: rtdm_iomap_to_user() I-pipe error
> > 
> > 
> > On 2011-04-14 08:14, Asier Tamayo wrote:
> > > 
> > > Hello,
> > > 
> > > I'm porting a PCI driver to a RTDM. Until now, I have 
> > successfully done most of the job.
> > > 
> > > I'm using Xenomai version 2.4.7 and Linux 2.6.27, from the 
> > ELinOS 5.0 distribution.
> > > 
> > > My problem appears with the rtdm_iomap_to_user() function. 
> > I want to allow a RT task to access the PCI memory directly, 
> > via mmap. As the RTDM has no mmap() function, I'm trying to 
> > use rtdm_iomap_to_user, but it always gives me the following error:
> > > 
> > > 	I-pipe: Detected illicit call from domain 'Xenomai'
> > > 	        into a service reserved for domain 'Linux' and below.
> > 
> > This is also documented: rtdm_iomap_to_user is not supposed 
> > to be called
> > from RT task context. This means your driver should only 
> call it from
> > handlers registered for *_nrt entry points.
> > 
> > Jan
> > 
> > -- 
> > Siemens AG, Corporate Technology, CT T DE IT 1
> > Corporate Competence Center Embedded Linux
> > 
> 
> _______________________________________________
> Xenomai-help mailing list
> Xenomai-help@domain.hid
> https://mail.gna.org/listinfo/xenomai-help
> 


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Xenomai-help] FW: rtdm_iomap_to_user() I-pipe error
  2011-04-26 10:05     ` Asier Tamayo
@ 2011-04-26 11:15       ` Gilles Chanteperdrix
  2011-04-27  7:05         ` Asier Tamayo
  0 siblings, 1 reply; 9+ messages in thread
From: Gilles Chanteperdrix @ 2011-04-26 11:15 UTC (permalink / raw)
  To: Asier Tamayo; +Cc: Jan Kiszka, xenomai

Asier Tamayo wrote:
> Hello again,
> 
> When one doesn't get replies to his questions, it may be either
> because: i) they are too obvious (RTFM), ii) too difficult, iii)
> there is little information and it makes the checking in one's system
> impossible, or iv) they haven't been correctly explained. It may also
> be that the help demander is not being polite.
> 
> As i have received no answer, I will assume I haven't explained my
> problem correctly and will give myself a second chance ;) The
> following lines will just rewrite my question, since I haven't been
> able to find any new clue:
> 
> I'm porting a PCI driver to a RTDM, using Xenomai version 2.4.7 and
> Linux 2.6.27, from the ELinOS 5.0 distribution.

Before anything else, please try the latest version of the branch you
use (that would be Xenomai 2.4.10)

> 
> I want to allow a RT task to access the PCI memory directly, by
> calling the rtdm_iomap_to_user() function just after mlockall and
> rt_dev_open, and before rt_task_shadow. The function returns me a
> correct value, but then I cannot access the PCI registers by using
> that address. The mmap seems not to be correct. The values I get:
> 
> Driver: xen_mydriver->location = pci_resource_start(dev,0); -->
> 0x20000000 xen_mydriver->base_address =
> ioremap(xen_mydriver->location, xen_mydriver->mem_size); -->
> 0xe0a00000 *(unsigned short*)(my_context->base_address + 0x100) =
> 0xAAAA; --> It works
> 
> RT task: rtdm_iomap_to_user(user_info,my_context->location, 300,
> PROT_READ|PROT_WRITE, &new_iomap, NULL, NULL); --> 0xb5f6f000 
> virt_to_phys(new_iomap) --> 0xf5f6f000 *(unsigned short*)(new_iomap +

virt_to_phys is not supposed to work in that case. Since you ioremap'ed
the address, you already know the physical address anyway.

-- 
                                                                Gilles.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Xenomai-help] FW: rtdm_iomap_to_user() I-pipe error
  2011-04-26 11:15       ` Gilles Chanteperdrix
@ 2011-04-27  7:05         ` Asier Tamayo
  2011-04-27  7:42           ` Gilles Chanteperdrix
  0 siblings, 1 reply; 9+ messages in thread
From: Asier Tamayo @ 2011-04-27  7:05 UTC (permalink / raw)
  To: Gilles Chanteperdrix; +Cc: Jan Kiszka, xenomai

Hello,

Thanks for your help. 

I know my Xenomai version is quite out of date. However, as I'm using the ELinOS distribution (which already has its own patches), I find it really difficult to upgrade to Xenomai 2.4.10. Anyway, I can apply changes to some files. 

The rtdm_iomap_to_user function is referenced in drvlib.c and rtdm_driver.h: I compare the 2.4.7 and 2.4.10 versions and they are almost identical, so I think there will be no use in patching the kernel for these 2 files. Do you know of any other file that could make any difference in my problem? 

If I compare versions 2.4.7 and 2.5.6 (the last one) of Xenomai, I can see the last version uses "/dev/rtheap" instead of "/dev/zero" and that there are some changes if CONFIG_MMU is not defined. My system (Intel Atom N270 CPU) is configured with MMU and therefore the only actual changes between the versions are regarding "dev/rtheap". Does it make any difference? Xenomai 2.4.7 has "/dev/rtpheap" but no "/dev/rtheap"; should I use it instead of "/dev/zero"?


> > virt_to_phys(new_iomap) --> 0xf5f6f000 
> 
> virt_to_phys is not supposed to work in that case. Since you ioremap'ed
> the address, you already know the physical address anyway.
> 
Is there any function that will tell me the real physical address in order to make sure the mapping is correct?

Again, thanks for your help.

Best regards,

Asier


> -----Original Message-----
> From: Gilles Chanteperdrix [mailto:gilles.chanteperdrix@xenomai.org]
> Sent: Tuesday, April 26, 2011 1:15 PM
> To: Asier Tamayo
> Cc: Jan Kiszka; xenomai-help@gna.org
> Subject: Re: [Xenomai-help] FW: rtdm_iomap_to_user() I-pipe error
> 
> 
> Asier Tamayo wrote:
> > Hello again,
> > 
> > When one doesn't get replies to his questions, it may be either
> > because: i) they are too obvious (RTFM), ii) too difficult, iii)
> > there is little information and it makes the checking in 
> one's system
> > impossible, or iv) they haven't been correctly explained. 
> It may also
> > be that the help demander is not being polite.
> > 
> > As i have received no answer, I will assume I haven't explained my
> > problem correctly and will give myself a second chance ;) The
> > following lines will just rewrite my question, since I haven't been
> > able to find any new clue:
> > 
> > I'm porting a PCI driver to a RTDM, using Xenomai version 2.4.7 and
> > Linux 2.6.27, from the ELinOS 5.0 distribution.
> 
> Before anything else, please try the latest version of the branch you
> use (that would be Xenomai 2.4.10)
> 
> > 
> > I want to allow a RT task to access the PCI memory directly, by
> > calling the rtdm_iomap_to_user() function just after mlockall and
> > rt_dev_open, and before rt_task_shadow. The function returns me a
> > correct value, but then I cannot access the PCI registers by using
> > that address. The mmap seems not to be correct. The values I get:
> > 
> > Driver: xen_mydriver->location = pci_resource_start(dev,0); -->
> > 0x20000000 xen_mydriver->base_address =
> > ioremap(xen_mydriver->location, xen_mydriver->mem_size); -->
> > 0xe0a00000 *(unsigned short*)(my_context->base_address + 0x100) =
> > 0xAAAA; --> It works
> > 
> > RT task: rtdm_iomap_to_user(user_info,my_context->location, 300,
> > PROT_READ|PROT_WRITE, &new_iomap, NULL, NULL); --> 0xb5f6f000 
> > virt_to_phys(new_iomap) --> 0xf5f6f000 *(unsigned 
> short*)(new_iomap +
> 
> virt_to_phys is not supposed to work in that case. Since you 
> ioremap'ed
> the address, you already know the physical address anyway.
> 
> -- 
>                                                               
>   Gilles.
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Xenomai-help] FW: rtdm_iomap_to_user() I-pipe error
  2011-04-27  7:05         ` Asier Tamayo
@ 2011-04-27  7:42           ` Gilles Chanteperdrix
  2011-04-27 17:36             ` Gilles Chanteperdrix
  0 siblings, 1 reply; 9+ messages in thread
From: Gilles Chanteperdrix @ 2011-04-27  7:42 UTC (permalink / raw)
  To: Asier Tamayo; +Cc: Jan Kiszka, xenomai

Asier Tamayo wrote:
> Hello,
> 
> Thanks for your help.
> 
> I know my Xenomai version is quite out of date. However, as I'm using
> the ELinOS distribution (which already has its own patches), I find
> it really difficult to upgrade to Xenomai 2.4.10. Anyway, I can apply
> changes to some files.

Sorry, I do not mean that you should upgrade to 2.4.10, I mean you
should run a self-contained test case on an unpatched 2.4.10, in order
to see whether you observe the same behaviour.

> 
> The rtdm_iomap_to_user function is referenced in drvlib.c and
> rtdm_driver.h: I compare the 2.4.7 and 2.4.10 versions and they are
> almost identical, so I think there will be no use in patching the
> kernel for these 2 files. Do you know of any other file that could
> make any difference in my problem?
> 
> If I compare versions 2.4.7 and 2.5.6 (the last one) of Xenomai, I
> can see the last version uses "/dev/rtheap" instead of "/dev/zero"
> and that there are some changes if CONFIG_MMU is not defined. My
> system (Intel Atom N270 CPU) is configured with MMU and therefore the
> only actual changes between the versions are regarding "dev/rtheap".
> Does it make any difference? Xenomai 2.4.7 has "/dev/rtpheap" but no
> "/dev/rtheap"; should I use it instead of "/dev/zero"?

The implementation is different, in order to know why, and which problem
 it solves, you can look into git history. The advantage of using
/dev/rtheap is that the implementation is shared with other skins.

> 
> 
>>> virt_to_phys(new_iomap) --> 0xf5f6f000
>> virt_to_phys is not supposed to work in that case. Since you
>> ioremap'ed the address, you already know the physical address
>> anyway.
>> 
> Is there any function that will tell me the real physical address in
> order to make sure the mapping is correct?

I would say vmalloc_to_page. But do not take my word for it, check the
"linux device drivers" book.

-- 
					    Gilles.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Xenomai-help] FW: rtdm_iomap_to_user() I-pipe error
  2011-04-27  7:42           ` Gilles Chanteperdrix
@ 2011-04-27 17:36             ` Gilles Chanteperdrix
  2011-04-28  8:54               ` Asier Tamayo
  0 siblings, 1 reply; 9+ messages in thread
From: Gilles Chanteperdrix @ 2011-04-27 17:36 UTC (permalink / raw)
  To: Asier Tamayo; +Cc: Jan Kiszka, xenomai

Gilles Chanteperdrix wrote:
> Asier Tamayo wrote:
>> Hello,
>>
>> Thanks for your help.
>>
>> I know my Xenomai version is quite out of date. However, as I'm using
>> the ELinOS distribution (which already has its own patches), I find
>> it really difficult to upgrade to Xenomai 2.4.10. Anyway, I can apply
>> changes to some files.
> 
> Sorry, I do not mean that you should upgrade to 2.4.10, I mean you
> should run a self-contained test case on an unpatched 2.4.10, in order
> to see whether you observe the same behaviour.
> 
>> The rtdm_iomap_to_user function is referenced in drvlib.c and
>> rtdm_driver.h: I compare the 2.4.7 and 2.4.10 versions and they are
>> almost identical, so I think there will be no use in patching the
>> kernel for these 2 files. Do you know of any other file that could
>> make any difference in my problem?
>>
>> If I compare versions 2.4.7 and 2.5.6 (the last one) of Xenomai, I
>> can see the last version uses "/dev/rtheap" instead of "/dev/zero"
>> and that there are some changes if CONFIG_MMU is not defined. My
>> system (Intel Atom N270 CPU) is configured with MMU and therefore the
>> only actual changes between the versions are regarding "dev/rtheap".
>> Does it make any difference? Xenomai 2.4.7 has "/dev/rtpheap" but no
>> "/dev/rtheap"; should I use it instead of "/dev/zero"?
> 
> The implementation is different, in order to know why, and which problem
>  it solves, you can look into git history. The advantage of using
> /dev/rtheap is that the implementation is shared with other skins.
> 
>>
>>>> virt_to_phys(new_iomap) --> 0xf5f6f000
>>> virt_to_phys is not supposed to work in that case. Since you
>>> ioremap'ed the address, you already know the physical address
>>> anyway.
>>>
>> Is there any function that will tell me the real physical address in
>> order to make sure the mapping is correct?
> 
> I would say vmalloc_to_page. But do not take my word for it, check the
> "linux device drivers" book.
> 
vmalloc_to_page would work for an address returned by vmalloc/ioremap,
not for one returned by the mapping functions.

To check what happens, you should trace drvlib.c to see what parameters
are finally passed to remap_page_range.

But there were several changes between 2.4 and 2.5, so, I would suggest
trying 2.5.6, just with the simple test case, no need to upgrade the
linux kernel.

-- 
                                                                Gilles.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Xenomai-help] FW: rtdm_iomap_to_user() I-pipe error
  2011-04-27 17:36             ` Gilles Chanteperdrix
@ 2011-04-28  8:54               ` Asier Tamayo
  0 siblings, 0 replies; 9+ messages in thread
From: Asier Tamayo @ 2011-04-28  8:54 UTC (permalink / raw)
  To: Gilles Chanteperdrix; +Cc: Jan Kiszka, xenomai

Hello,

Finally rtdm_iomap_to_user works! It was an initialization error: the probe() function correctly stored the pci_resource_start and pci_resource_len values in the xen_mydriver variable, but these values were not copied into the context->dev_private structure in the open() function. The ioctl function used my_context->location, which was 0.

In the new working driver, the open() function correctly initializes the context->dev_private variable. Later, rtdm_iomap_to_user() is called with the correct values.

Gilles, thank you very much for your help and patience. It would have been much harder to find a solution without your indications. 

By the way, I have upgraded to Xenomai 2.4.10. It was quite straightforward. I haven't applied the patches from ksrc/arch/x86/patches/adeos-ipipe*.

Thank you for your help.

Best regards,

Asier





> -----Original Message-----
> From: Gilles Chanteperdrix [mailto:gilles.chanteperdrix@xenomai.org]
> Sent: Wednesday, April 27, 2011 7:37 PM
> To: Asier Tamayo
> Cc: Jan Kiszka; xenomai-help@gna.org
> Subject: Re: [Xenomai-help] FW: rtdm_iomap_to_user() I-pipe error
> 
> 
> Gilles Chanteperdrix wrote:
> > Asier Tamayo wrote:
> >> Hello,
> >>
> >> Thanks for your help.
> >>
> >> I know my Xenomai version is quite out of date. However, 
> as I'm using
> >> the ELinOS distribution (which already has its own patches), I find
> >> it really difficult to upgrade to Xenomai 2.4.10. Anyway, 
> I can apply
> >> changes to some files.
> > 
> > Sorry, I do not mean that you should upgrade to 2.4.10, I mean you
> > should run a self-contained test case on an unpatched 
> 2.4.10, in order
> > to see whether you observe the same behaviour.
> > 
> >> The rtdm_iomap_to_user function is referenced in drvlib.c and
> >> rtdm_driver.h: I compare the 2.4.7 and 2.4.10 versions and they are
> >> almost identical, so I think there will be no use in patching the
> >> kernel for these 2 files. Do you know of any other file that could
> >> make any difference in my problem?
> >>
> >> If I compare versions 2.4.7 and 2.5.6 (the last one) of Xenomai, I
> >> can see the last version uses "/dev/rtheap" instead of "/dev/zero"
> >> and that there are some changes if CONFIG_MMU is not defined. My
> >> system (Intel Atom N270 CPU) is configured with MMU and 
> therefore the
> >> only actual changes between the versions are regarding 
> "dev/rtheap".
> >> Does it make any difference? Xenomai 2.4.7 has 
> "/dev/rtpheap" but no
> >> "/dev/rtheap"; should I use it instead of "/dev/zero"?
> > 
> > The implementation is different, in order to know why, and 
> which problem
> >  it solves, you can look into git history. The advantage of using
> > /dev/rtheap is that the implementation is shared with other skins.
> > 
> >>
> >>>> virt_to_phys(new_iomap) --> 0xf5f6f000
> >>> virt_to_phys is not supposed to work in that case. Since you
> >>> ioremap'ed the address, you already know the physical address
> >>> anyway.
> >>>
> >> Is there any function that will tell me the real physical 
> address in
> >> order to make sure the mapping is correct?
> > 
> > I would say vmalloc_to_page. But do not take my word for 
> it, check the
> > "linux device drivers" book.
> > 
> vmalloc_to_page would work for an address returned by vmalloc/ioremap,
> not for one returned by the mapping functions.
> 
> To check what happens, you should trace drvlib.c to see what 
> parameters
> are finally passed to remap_page_range.
> 
> But there were several changes between 2.4 and 2.5, so, I 
> would suggest
> trying 2.5.6, just with the simple test case, no need to upgrade the
> linux kernel.
> 
> -- 
>                                                               
>   Gilles.
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2011-04-28  8:54 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-14  6:14 [Xenomai-help] FW: rtdm_iomap_to_user() I-pipe error Asier Tamayo
2011-04-14  7:34 ` Jan Kiszka
2011-04-14  9:38   ` Asier Tamayo
2011-04-26 10:05     ` Asier Tamayo
2011-04-26 11:15       ` Gilles Chanteperdrix
2011-04-27  7:05         ` Asier Tamayo
2011-04-27  7:42           ` Gilles Chanteperdrix
2011-04-27 17:36             ` Gilles Chanteperdrix
2011-04-28  8:54               ` Asier Tamayo

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.