rtdm_iomap_to_user with phys addr > 4GB
Hello,
I am writing an RTDM driver to replace one that uses UIO. The device resides in a physical address > 4 GB on a PPC440EPx. The UIO could not handle this address so I made a proposal to address it, details at:
http://lists.ozlabs.org/pipermail/linuxppc-dev/2009-April/070097.html
Function rtdm_iomap_to_user() has same issue with the physical I/O address
unsigned long src_addr
I am new to Xenomai and would like to get some ideas on how to solve this
issue.
Thanks,
Luis G. Herrera-Bendezu
Quoted 7 lines · Luis
Hello,
I am writing an RTDM driver to replace one that uses UIO. The device resides in a physical address > 4 GB on a PPC440EPx. The UIO could not handle this address so I made a proposal to address it, details at:
http://lists.ozlabs.org/pipermail/linuxppc-dev/2009-April/070097.html
Quoted 7 lines
Function
rtdm_iomap_to_user()has same issue with the physical I/O address
unsigned longsrc_addrI am new to Xenomai and would like to get some ideas on how to solve this
issue.
I think UIO as well as RTDM suffers from the same problem here: The kernel service used to remap the physical memory (remap_pfn_range) accepts unsigned long, not phys_addr_t. How is this supposed to work?
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT SE 2 Corporate Competence Center Embedded Linux
Quoted 27 lines
-----Original Message-----
From: Jan Kiszka [mailto:[email protected]
Sent: Tuesday, November 10, 2009 12:03 PM
To: Herrera-Bendezu, Luis
Cc: [email protected]
Subject: Re:rtdm_iomap_to_userwith phys addr > 4GBQuoted 5 lines · Luis
Hello,
I am writing an RTDM driver to replace one that uses UIO. The device resides in a physical address > 4 GB on a PPC440EPx. The UIO could not handle this address so I made a proposal to address it,
details at:
Quoted 9 lines
http://lists.ozlabs.org/pipermail/linuxppc-dev/2009-April/070097.html
Function
rtdm_iomap_to_user()has same issue with the physical I/O address
unsigned longsrc_addrI am new to Xenomai and would like to get some ideas on how to solve this
issue.
Quoted 10 lines
I think UIO as well as RTDM suffers from the same problem here: The kernel service used to remap the physical memory (
remap_pfn_range) accepts unsigned long, notphys_addr_t. How is this supposed to work?Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT SE 2 Corporate Competence Center Embedded Linux
Actually, remap_pfn_range() gets passed the physical address left shifted by PAGE_SIZE in both UIO and RTDM (xnarch_remap_io_page_range, wrap_remap_io_page_range).
Luis
Quoted 32 lines · Luis
Quoted 32 lines
-----Original Message-----
From: Jan Kiszka [mailto:[email protected]]
Sent: Tuesday, November 10, 2009 12:03 PM
To: Herrera-Bendezu, Luis
Cc: [email protected]
Subject: Re:rtdm_iomap_to_userwith phys addr > 4GBQuoted 5 lines · Luis
Hello,
I am writing an RTDM driver to replace one that uses UIO. The device resides in a physical address > 4 GB on a PPC440EPx. The UIO could not handle this address so I made a proposal to address it,
details at:
Quoted 9 lines
http://lists.ozlabs.org/pipermail/linuxppc-dev/2009-April/070097.html
Function
rtdm_iomap_to_user()has same issue with the physical I/O address
unsigned longsrc_addrI am new to Xenomai and would like to get some ideas on how to solve this
issue.I think UIO as well as RTDM suffers from the same problem here: The kernel service used to remap the physical memory (
remap_pfn_range) accepts unsigned long, notphys_addr_t. How is this supposed to work?Jan
Quoted 8 lines
Quoted 4 lines
Signature · 2 lines
Siemens AG, Corporate Technology, CT SE 2 Corporate Competence Center Embedded LinuxActually,
remap_pfn_range()gets passed the physical address left shifted byPAGE_SIZEin both UIO and RTDM (xnarch_remap_io_page_range,wrap_remap_io_page_range).
No, the target address is expressed in pages, the source in bytes.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT SE 2 Corporate Competence Center Embedded Linux
Quoted 52 lines
-----Original Message-----
From: Jan Kiszka [mailto:[email protected]
Sent: Tuesday, November 10, 2009 1:13 PM
To: Herrera-Bendezu, Luis
Cc: [email protected]
Subject: Re:rtdm_iomap_to_userwith phys addr > 4GBQuoted 10 lines · Luis
Quoted 10 lines
-----Original Message-----
From: Jan Kiszka [mailto:[email protected]
Sent: Tuesday, November 10, 2009 12:03 PM
To: Herrera-Bendezu, Luis
Cc: [email protected]
Subject: Re:rtdm_iomap_to_userwith phys addr > 4GBQuoted 4 lines
Quoted 4 lines
Quoted 3 lines · Luis
Hello,
I am writing an RTDM driver to replace one that uses UIO.
The device
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
resides in a physical address > 4 GB on a PPC440EPx. The UIO could not handle this address so I made a proposal to address it,
details at:
Quoted 1 line
http://lists.ozlabs.org/pipermail/linuxppc-dev/2009-April/070097.html
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Function
rtdm_iomap_to_user()has same issue with the physical I/O address
unsigned longsrc_addrI am new to Xenomai and would like to get some ideas on
how to solve
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
this
issue.I think UIO as well as RTDM suffers from the same problem here: The kernel service used to remap the physical memory (
remap_pfn_range) accepts unsigned long, notphys_addr_t. How is thissupposed to work?
Quoted 8 lines
Quoted 7 lines
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT SE 2 Corporate Competence Center Embedded Linux
Quoted 7 lines
Quoted 2 lines
Actually,
remap_pfn_range()gets passed the physical address left shifted byPAGE_SIZEin both UIO and RTDM(
xnarch_remap_io_page_range,Quoted 1 line
wrap_remap_io_page_range).No, the target address is expressed in pages, the source in bytes.
That is true for rtdm_mmap_to_user but not for rtdm_iomap_to_user. See howmmap_data struct is set in both functions.
Luis
Quoted 50 lines · Luis
Quoted 50 lines
-----Original Message-----
From: Jan Kiszka [mailto:[email protected]]
Sent: Tuesday, November 10, 2009 1:13 PM
To: Herrera-Bendezu, Luis
Cc: [email protected]
Subject: Re:rtdm_iomap_to_userwith phys addr > 4GBQuoted 10 lines · Luis
Quoted 10 lines
-----Original Message-----
From: Jan Kiszka [mailto:[email protected]]
Sent: Tuesday, November 10, 2009 12:03 PM
To: Herrera-Bendezu, Luis
Cc: [email protected]
Subject: Re:rtdm_iomap_to_userwith phys addr > 4GBQuoted 4 lines
Quoted 4 lines
Quoted 3 lines · Luis
Hello,
I am writing an RTDM driver to replace one that uses UIO.
The device
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
resides in a physical address > 4 GB on a PPC440EPx. The UIO could not handle this address so I made a proposal to address it,
details at:
http://lists.ozlabs.org/pipermail/linuxppc-dev/2009-April/070097.html
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Function
rtdm_iomap_to_user()has same issue with the physical I/O address
unsigned longsrc_addrI am new to Xenomai and would like to get some ideas on
how to solve
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
this
issue.I think UIO as well as RTDM suffers from the same problem here: The kernel service used to remap the physical memory (
remap_pfn_range) accepts unsigned long, notphys_addr_t. How is thissupposed to work?
Quoted 8 lines
Quoted 6 lines
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT SE 2 Corporate Competence Center Embedded LinuxActually,
remap_pfn_range()gets passed the physical address left shifted byPAGE_SIZEin both UIO and RTDM
Quoted 7 lines
Quoted 4 lines
(
xnarch_remap_io_page_range,Quoted 1 line
wrap_remap_io_page_range).No, the target address is expressed in pages, the source in bytes.
That is true for
rtdm_mmap_to_userbut not forrtdm_iomap_to_user. See howmmap_datastruct is set in both functions.
struct rtdm_mmap_data mmap_data =
{ NULL, src_addr, vm_ops, vm_private_data };
with src_addr = "physical I/O address to be mapped", setting mmap_data.src_paddr -- are you looking at different code?
Besides this, the key is how remap_pfn_page interprets the source address argument.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT SE 2 Corporate Competence Center Embedded Linux
Quoted 71 lines
-----Original Message-----
From: Jan Kiszka [mailto:[email protected]
Sent: Tuesday, November 10, 2009 1:55 PM
To: Herrera-Bendezu, Luis
Cc: [email protected]
Subject: Re:rtdm_iomap_to_userwith phys addr > 4GBQuoted 21 lines · Luis
Quoted 21 lines
-----Original Message-----
From: Jan Kiszka [mailto:[email protected]
Sent: Tuesday, November 10, 2009 1:13 PM
To: Herrera-Bendezu, Luis
Cc: [email protected]
Subject: Re:rtdm_iomap_to_userwith phys addr > 4GBQuoted 10 lines · Luis
Quoted 10 lines
-----Original Message-----
From: Jan Kiszka [mailto:[email protected]
Sent: Tuesday, November 10, 2009 12:03 PM
To: Herrera-Bendezu, Luis
Cc: [email protected]
Subject: Re:rtdm_iomap_to_userwith phys addr > 4GBQuoted 6 lines
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines · Luis
Hello,
I am writing an RTDM driver to replace one that uses UIO.
The device
Quoted 1 line
Quoted 1 line
Quoted 1 line
resides in a physical address > 4 GB on a PPC440EPx. The
UIO could
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
not handle this address so I made a proposal to address it,
details at:
http://lists.ozlabs.org/pipermail/linuxppc-dev/2009-April/070097.html
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Function
rtdm_iomap_to_user()has same issue with thephysical I/O
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
address
unsigned longsrc_addrI am new to Xenomai and would like to get some ideas on
how to solve
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
this
issue.I think UIO as well as RTDM suffers from the same problem
here: The
Quoted 9 lines
Quoted 9 lines
Quoted 2 lines
Quoted 2 lines
kernel service used to remap the physical memory (
remap_pfn_range) accepts unsigned long, notphys_addr_t. How is thissupposed to work?
Quoted 6 lines
Quoted 6 lines
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT SE 2 Corporate Competence Center Embedded LinuxQuoted 7 lines
Quoted 6 lines
Quoted 2 lines
Actually,
remap_pfn_range()gets passed the physical address left shifted byPAGE_SIZEin both UIO and RTDM(
xnarch_remap_io_page_range,Quoted 1 line
wrap_remap_io_page_range).No, the target address is expressed in pages, the source in bytes.
That is true for
rtdm_mmap_to_userbut not for
rtdm_iomap_to_user. See
Quoted 9 lines
Quoted 2 lines
how
mmap_datastruct is set in both functions.struct
rtdm_mmap_datammap_data=
{ NULL,src_addr,vm_ops,vm_private_data};with
src_addr= "physical I/O address to be mapped", setting mmap_data.src_paddr -- are you looking at different code?
No, that is the code.
Quoted 3 lines
Besides this, the key is how
remap_pfn_pageinterprets the source address argument.
I had used UIO with success (as described in link above). The equivalent code in UIO is (uio.c):
static int uio_mmap_physical(struct vm_area_struct *vma)
{
struct uio_device *idev = vma->vm_private_data;
int mi = uio_find_mem_index(vma);
if (mi < 0)
return -EINVAL;
vma->vm_flags |= VM_IO | VM_RESERVED;
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
return remap_pfn_range(vma,
vma->vm_start,
idev->info->mem[mi].addr >> PAGE_SHIFT,
vma->vm_end - vma->vm_start,
vma->vm_page_prot);
}where idev->info->mem[mi].addr, mem[.] is the list of mappable regions. Note that for UIO, the user application needs to mmap these regions to user space. This is a step that is not needed on RTDM, right?
Luis
Quoted 72 lines · Luis
Quoted 72 lines
-----Original Message-----
From: Jan Kiszka [mailto:[email protected]
Sent: Tuesday, November 10, 2009 1:55 PM
To: Herrera-Bendezu, Luis
Cc: [email protected]
Subject: Re:rtdm_iomap_to_userwith phys addr > 4GBQuoted 21 lines · Luis
Quoted 21 lines
-----Original Message-----
From: Jan Kiszka [mailto:[email protected]
Sent: Tuesday, November 10, 2009 1:13 PM
To: Herrera-Bendezu, Luis
Cc: [email protected]
Subject: Re:rtdm_iomap_to_userwith phys addr > 4GBQuoted 10 lines · Luis
Quoted 10 lines
-----Original Message-----
From: Jan Kiszka [mailto:[email protected]
Sent: Tuesday, November 10, 2009 12:03 PM
To: Herrera-Bendezu, Luis
Cc: [email protected]
Subject: Re:rtdm_iomap_to_userwith phys addr > 4GBQuoted 6 lines
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines · Luis
Hello,
I am writing an RTDM driver to replace one that uses UIO.
The device
Quoted 1 line
Quoted 1 line
Quoted 1 line
resides in a physical address > 4 GB on a PPC440EPx. The
UIO could
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
not handle this address so I made a proposal to address it,
details at:
http://lists.ozlabs.org/pipermail/linuxppc-dev/2009-April/070097.html
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Function
rtdm_iomap_to_user()has same issue with thephysical I/O
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
address
unsigned longsrc_addrI am new to Xenomai and would like to get some ideas on
how to solve
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
this
issue.I think UIO as well as RTDM suffers from the same problem
here: The
Quoted 9 lines
Quoted 9 lines
Quoted 2 lines
Quoted 2 lines
kernel service used to remap the physical memory (
remap_pfn_range) accepts unsigned long, notphys_addr_t. How is thissupposed to work?
Quoted 6 lines
Quoted 6 lines
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT SE 2 Corporate Competence Center Embedded LinuxQuoted 7 lines
Quoted 6 lines
Quoted 2 lines
Actually,
remap_pfn_range()gets passed the physical address left shifted byPAGE_SIZEin both UIO and RTDM(
xnarch_remap_io_page_range,Quoted 1 line
wrap_remap_io_page_range).No, the target address is expressed in pages, the source in bytes.
That is true for
rtdm_mmap_to_userbut not for
rtdm_iomap_to_user. SeeQuoted 2 lines
how
mmap_datastruct is set in both functions.
Quoted 7 lines
Quoted 6 lines
struct
rtdm_mmap_datammap_data=
{ NULL,src_addr,vm_ops,vm_private_data};with
src_addr= "physical I/O address to be mapped", setting mmap_data.src_paddr -- are you looking at different code?No, that is the code.
But there is nothing shifted, the shifting takes place in Xenomai's wrapper.
Quoted 23 lines
Quoted 3 lines
Besides this, the key is how
remap_pfn_pageinterprets the source address argument.I had used UIO with success (as described in link above). The equivalent code in UIO is (
uio.c):
static intuio_mmap_physical(struct vm_area_struct *vma){ struct uio_device *idev = vma->vm_private_data; int mi = uio_find_mem_index(vma); if (mi < 0) return -EINVAL; vma->vm_flags |= VM_IO | VM_RESERVED; vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); return remap_pfn_range(vma, vma->vm_start, idev->info->mem[mi].addr >> PAGE_SHIFT, vma->vm_end - vma->vm_start, vma->vm_page_prot); }
Quoted 3 lines
where idev->info->mem[mi].addr, mem[.] is the list of mappable regions. Note that for UIO, the user application needs to mmap these regions to user space. This is a step that is not needed on RTDM, right?
OK, now I got my mistake: Confused by the wrong argument names of our wrap_remap_io_page_range (and probably others) I thought that the destination is given as page number, not the source.
But before adding some fancy new service for this use case, I'd like to understand how common it actually is (crazy embedded designs tend to pop up and deprecate faster than such APIs...).
And what was the final conclusion on LKML? As far as I understood the UIO maintainer, the proposal was rejected. Any different follow-ups on this that I missed? Of course, if you have a special design you can always patch your kernel and Xenomai to fit these special purposes. But for upstream support, kernel or Xenomai, it requires a clean and portable model.
Jan
Quoted 125 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]
Sent: Tuesday, November 10, 2009 4:22 PM
To: Herrera-Bendezu, Luis
Cc: [email protected]
Subject: Re:rtdm_iomap_to_userwith phys addr > 4GBQuoted 35 lines · Luis
Quoted 35 lines
-----Original Message-----
From: Jan Kiszka [mailto:[email protected]
Sent: Tuesday, November 10, 2009 1:55 PM
To: Herrera-Bendezu, Luis
Cc: [email protected]
Subject: Re:rtdm_iomap_to_userwith phys addr > 4GBQuoted 24 lines · Luis
Quoted 24 lines
-----Original Message-----
From: Jan Kiszka [mailto:[email protected]
Sent: Tuesday, November 10, 2009 1:13 PM
To: Herrera-Bendezu, Luis
Cc: [email protected]
Subject: Re:rtdm_iomap_to_userwith phys addr > 4GBQuoted 13 lines · Luis
Quoted 13 lines
-----Original Message-----
From: Jan Kiszka [mailto:[email protected]
Sent: Tuesday, November 10, 2009 12:03 PM
To: Herrera-Bendezu, Luis
Cc: [email protected]
Subject: Re:rtdm_iomap_to_userwith phys addr > 4GBQuoted 2 lines · Luis
Hello,
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
I am writing an RTDM driver to replace one that uses UIO.
The device
Quoted 1 line
Quoted 1 line
Quoted 1 line
resides in a physical address > 4 GB on a PPC440EPx. The
UIO could
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
not handle this address so I made a proposal to address it,
details at:
http://lists.ozlabs.org/pipermail/linuxppc-dev/2009-April/070097.html
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Function
rtdm_iomap_to_user()has same issue with thephysical I/O
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
address
unsigned longsrc_addrQuoted 7 lines
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
I am new to Xenomai and would like to get some ideas on
how to solve
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
this
issue.I think UIO as well as RTDM suffers from the same problem
here: The
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
kernel service used to remap the physical memory
(
remap_pfn_range)Quoted 18 lines
Quoted 18 lines
Quoted 8 lines
Quoted 8 lines
Quoted 1 line
Quoted 1 line
accepts unsigned long, not
phys_addr_t. How is thissupposed to work?
Quoted 6 lines
Quoted 6 lines
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT SE 2 Corporate Competence Center Embedded LinuxQuoted 7 lines
Quoted 6 lines
Quoted 2 lines
Actually,
remap_pfn_range()gets passed the physical address left shifted byPAGE_SIZEin both UIO and RTDM(
xnarch_remap_io_page_range,Quoted 1 line
wrap_remap_io_page_range).No, the target address is expressed in pages, the source in bytes.
That is true for
rtdm_mmap_to_userbut not for
rtdm_iomap_to_user. SeeQuoted 2 lines
how
mmap_datastruct is set in both functions.Quoted 7 lines
Quoted 6 lines
struct
rtdm_mmap_datammap_data=
{ NULL,src_addr,vm_ops,vm_private_data};with
src_addr= "physical I/O address to be mapped", setting mmap_data.src_paddr -- are you looking at different code?No, that is the code.
But there is nothing shifted, the shifting takes place in Xenomai's wrapper.
Quoted 4 lines
Quoted 3 lines
Besides this, the key is how
remap_pfn_pageinterprets the source address argument.I had used UIO with success (as described in link above).
The equivalent
Quoted 19 lines
code in UIO is (
uio.c):
static intuio_mmap_physical(struct vm_area_struct *vma){ struct uio_device *idev = vma->vm_private_data; int mi = uio_find_mem_index(vma); if (mi < 0) return -EINVAL; vma->vm_flags |= VM_IO | VM_RESERVED; vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); return remap_pfn_range(vma, vma->vm_start, idev->info->mem[mi].addr >> PAGE_SHIFT, vma->vm_end - vma->vm_start, vma->vm_page_prot); }Quoted 1 line
where idev->info->mem[mi].addr, mem[.] is the list of
mappable regions.
Quoted 1 line
Note that for UIO, the user application needs to mmap these
regions to
Quoted 1 line
user space. This is a step that is not needed on RTDM, right?
Quoted 8 lines
OK, now I got my mistake: Confused by the wrong argument names of our
wrap_remap_io_page_range(and probably others) I thought that the destination is given as page number, not the source.But before adding some fancy new service for this use case, I'd like to understand how common it actually is (crazy embedded designs tend to pop
up and deprecate faster than such APIs...).
I do not think this is a new service but a limitation in the design. The kernel supports it (application can mmap the device using /dev/mem) and the PPC (440EPx in particular) has PCI and internal peripherals located at addresses above 4 GB (I2C, SPI, etc.).
Quoted 7 lines
And what was the final conclusion on LKML? As far as I understood the UIO maintainer, the proposal was rejected. Any different follow-ups on this that I missed? Of course, if you have a special design you can always patch your kernel and Xenomai to fit these special purposes. But for upstream support, kernel or Xenomai, it requires a clean and portable model.
There were no follow-ups and the reply concerning the required changes was:
"I guess you'd have to look at the whole memory management stuff of each
architecture to find out which kind of memory can be mapped with
addresses
above unsigned long. Hardware often needs more than one contigous
pages.
It might well be possible that a certain arch could have RAM for user
virtual
addresses above 4GB, but no hardware. I don't know PPC well enough to
say
anything about its behaviour."
In the mean time, it would be helpful if you have some suggestions on how to
change RTDM to handle this case.
Thanks,
Luis
Quoted 126 lines · Luis
Quoted 126 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]]
Sent: Tuesday, November 10, 2009 4:22 PM
To: Herrera-Bendezu, Luis
Cc: [email protected]
Subject: Re:rtdm_iomap_to_userwith phys addr > 4GBQuoted 33 lines · Luis
Quoted 33 lines
-----Original Message-----
From: Jan Kiszka [mailto:[email protected]]
Sent: Tuesday, November 10, 2009 1:55 PM
To: Herrera-Bendezu, Luis
Cc: [email protected]
Subject: Re:rtdm_iomap_to_userwith phys addr > 4GBQuoted 22 lines · Luis
Quoted 22 lines
-----Original Message-----
From: Jan Kiszka [mailto:[email protected]]
Sent: Tuesday, November 10, 2009 1:13 PM
To: Herrera-Bendezu, Luis
Cc: [email protected]
Subject: Re:rtdm_iomap_to_userwith phys addr > 4GBQuoted 11 lines · Luis
Quoted 11 lines
-----Original Message-----
From: Jan Kiszka [mailto:[email protected]]
Sent: Tuesday, November 10, 2009 12:03 PM
To: Herrera-Bendezu, Luis
Cc: [email protected]
Subject: Re:rtdm_iomap_to_userwith phys addr > 4GBHerrera-Bendezu, Luis wrote:
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Hello,
I am writing an RTDM driver to replace one that uses UIO.
The device
Quoted 1 line
Quoted 1 line
Quoted 1 line
resides in a physical address > 4 GB on a PPC440EPx. The
UIO could
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
not handle this address so I made a proposal to address it,
details at:
http://lists.ozlabs.org/pipermail/linuxppc-dev/2009-April/070097.html
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Function
rtdm_iomap_to_user()has same issue with thephysical I/O
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
address
unsigned longsrc_addrQuoted 7 lines
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
I am new to Xenomai and would like to get some ideas on
how to solve
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
this
issue.I think UIO as well as RTDM suffers from the same problem
here: The
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
kernel service used to remap the physical memory
(
remap_pfn_range)Quoted 18 lines
Quoted 18 lines
Quoted 8 lines
Quoted 8 lines
Quoted 1 line
Quoted 1 line
accepts unsigned long, not
phys_addr_t. How is thissupposed to work?
Quoted 6 lines
Quoted 6 lines
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT SE 2 Corporate Competence Center Embedded LinuxQuoted 7 lines
Quoted 6 lines
Quoted 2 lines
Actually,
remap_pfn_range()gets passed the physical address left shifted byPAGE_SIZEin both UIO and RTDM(
xnarch_remap_io_page_range,Quoted 1 line
wrap_remap_io_page_range).No, the target address is expressed in pages, the source in bytes.
That is true for
rtdm_mmap_to_userbut not for
rtdm_iomap_to_user. SeeQuoted 2 lines
how
mmap_datastruct is set in both functions.Quoted 7 lines
Quoted 6 lines
struct
rtdm_mmap_datammap_data=
{ NULL,src_addr,vm_ops,vm_private_data};with
src_addr= "physical I/O address to be mapped", setting mmap_data.src_paddr -- are you looking at different code?No, that is the code.
But there is nothing shifted, the shifting takes place in Xenomai's wrapper.
Quoted 4 lines
Quoted 3 lines
Besides this, the key is how
remap_pfn_pageinterprets the source address argument.I had used UIO with success (as described in link above).
The equivalent
Quoted 19 lines
code in UIO is (
uio.c):
static intuio_mmap_physical(struct vm_area_struct *vma){ struct uio_device *idev = vma->vm_private_data; int mi = uio_find_mem_index(vma); if (mi < 0) return -EINVAL; vma->vm_flags |= VM_IO | VM_RESERVED; vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); return remap_pfn_range(vma, vma->vm_start, idev->info->mem[mi].addr >> PAGE_SHIFT, vma->vm_end - vma->vm_start, vma->vm_page_prot); }Quoted 1 line
where idev->info->mem[mi].addr, mem[.] is the list of
mappable regions.
Quoted 1 line
Note that for UIO, the user application needs to mmap these
regions to
Quoted 1 line
user space. This is a step that is not needed on RTDM, right?
OK, now I got my mistake: Confused by the wrong argument names of our
wrap_remap_io_page_range(and probably others) I thought that the destination is given as page number, not the source.
Quoted 8 lines
Quoted 4 lines
But before adding some fancy new service for this use case, I'd like to understand how common it actually is (crazy embedded designs tend to pop
up and deprecate faster than such APIs...).I do not think this is a new service but a limitation in the design. The kernel supports it (application can mmap the device using
/dev/mem) and the PPC (440EPx in particular) has PCI and internal peripherals located at addresses above 4 GB (I2C, SPI, etc.).
I think /dev/mem works by chance as it uses off_t to address the source, and that is 64 bit even on 32 bit hosts.
But I just collected the confirmation that this extension of the PPC's physical address range is indeed an increasingly common thing. It's still a fairly new one, so the kernel is obviously also still in the conversion process. Maybe poking those people again makes some sense.
Quoted 19 lines
Quoted 6 lines
And what was the final conclusion on LKML? As far as I understood the UIO maintainer, the proposal was rejected. Any different follow-ups on this that I missed? Of course, if you have a special design you can always patch your kernel and Xenomai to fit these special purposes. But for upstream support, kernel or Xenomai, it requires a clean and portable model.
There were no follow-ups and the reply concerning the required changes was:
"I guess you'd have to look at the whole memory management stuff of each
architecture to find out which kind of memory can be mapped with
addresses
above unsigned long. Hardware often needs more than one contigous
pages.
It might well be possible that a certain arch could have RAM for user
virtual
addresses above 4GB, but no hardware. I don't know PPC well enough to
say
anything about its behaviour."
Quoted 4 lines
In the mean time, it would be helpful if you have some suggestions on how to
change RTDM to handle this case.
I think we can change rtdm_iomap_to_user to take src_addr as phys_addr_t and propagate this internally properly. We also need to add a wrapper for phys_addr_t for kernels that doesn't support this (<2.6.28). To my current understanding, this should be sufficient, right?
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT SE 2 Corporate Competence Center Embedded Linux
Quoted 192 lines
-----Original Message-----
From: Jan Kiszka [mailto:[email protected]
Sent: Wednesday, November 11, 2009 9:06 AM
To: Herrera-Bendezu, Luis
Cc: [email protected]
Subject: Re:rtdm_iomap_to_userwith phys addr > 4GBQuoted 45 lines · Luis
Quoted 45 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]
Sent: Tuesday, November 10, 2009 4:22 PM
To: Herrera-Bendezu, Luis
Cc: [email protected]
Subject: Re:rtdm_iomap_to_userwith phys addr > 4GBQuoted 35 lines · Luis
Quoted 35 lines
-----Original Message-----
From: Jan Kiszka [mailto:[email protected]
Sent: Tuesday, November 10, 2009 1:55 PM
To: Herrera-Bendezu, Luis
Cc: [email protected]
Subject: Re:rtdm_iomap_to_userwith phys addr > 4GBQuoted 24 lines · Luis
Quoted 24 lines
-----Original Message-----
From: Jan Kiszka [mailto:[email protected]
Sent: Tuesday, November 10, 2009 1:13 PM
To: Herrera-Bendezu, Luis
Cc: [email protected]
Subject: Re:rtdm_iomap_to_userwith phys addr > 4GBQuoted 13 lines · Luis
Quoted 13 lines
-----Original Message-----
From: Jan Kiszka [mailto:[email protected]
Sent: Tuesday, November 10, 2009 12:03 PM
To: Herrera-Bendezu, Luis
Cc: [email protected]
Subject: Re:rtdm_iomap_to_userwith phys addr > 4GBQuoted 2 lines · Luis
Hello,
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
I am writing an RTDM driver to replace one that uses UIO.
The device
Quoted 1 line
Quoted 1 line
Quoted 1 line
resides in a physical address > 4 GB on a PPC440EPx. The
UIO could
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
not handle this address so I made a proposal to address it,
details at:
http://lists.ozlabs.org/pipermail/linuxppc-dev/2009-April/070097.html
Quoted 14 lines
Quoted 14 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Function
rtdm_iomap_to_user()has same issue with thephysical I/O
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
address
unsigned longsrc_addrQuoted 7 lines
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
I am new to Xenomai and would like to get some ideas on
how to solve
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
this
issue.I think UIO as well as RTDM suffers from the same problem
here: The
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
kernel service used to remap the physical memory
(
remap_pfn_range)Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
accepts unsigned long, not
phys_addr_t. How is thisQuoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
supposed to work?
Quoted 7 lines
Quoted 6 lines
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT SE 2 Corporate Competence Center Embedded LinuxActually,
remap_pfn_range()gets passed the physicaladdress left
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
shifted by
PAGE_SIZEin both UIO and RTDM(
xnarch_remap_io_page_range,Quoted 1 line
wrap_remap_io_page_range).No, the target address is expressed in pages, the
source in bytes.
Quoted 39 lines
Quoted 39 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Quoted 1 line
That is true for
rtdm_mmap_to_userbut not for
rtdm_iomap_to_user. SeeQuoted 2 lines
how
mmap_datastruct is set in both functions.Quoted 7 lines
Quoted 6 lines
struct
rtdm_mmap_datammap_data=
{ NULL,src_addr,vm_ops,vm_private_data};with
src_addr= "physical I/O address to be mapped", setting mmap_data.src_paddr -- are you looking at different code?No, that is the code.
But there is nothing shifted, the shifting takes place in Xenomai's wrapper.
Quoted 4 lines
Quoted 3 lines
Besides this, the key is how
remap_pfn_pageinterprets the source address argument.I had used UIO with success (as described in link above).
The equivalent
Quoted 19 lines
code in UIO is (
uio.c):
static intuio_mmap_physical(struct vm_area_struct *vma){ struct uio_device *idev = vma->vm_private_data; int mi = uio_find_mem_index(vma); if (mi < 0) return -EINVAL; vma->vm_flags |= VM_IO | VM_RESERVED; vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); return remap_pfn_range(vma, vma->vm_start, idev->info->mem[mi].addr >> PAGE_SHIFT, vma->vm_end - vma->vm_start, vma->vm_page_prot); }Quoted 6 lines
Quoted 6 lines
Quoted 1 line
where idev->info->mem[mi].addr, mem[.] is the list of
mappable regions.
Quoted 1 line
Note that for UIO, the user application needs to mmap these
regions to
Quoted 1 line
user space. This is a step that is not needed on RTDM, right?
OK, now I got my mistake: Confused by the wrong argument
names of our
Quoted 4 lines
Quoted 4 lines
wrap_remap_io_page_range(and probably others) I thought that the destination is given as page number, not the source.But before adding some fancy new service for this use case,
I'd like to
Quoted 5 lines
Quoted 3 lines
understand how common it actually is (crazy embedded designs tend to pop
up and deprecate faster than such APIs...).I do not think this is a new service but a limitation in the design. The kernel supports it (application can mmap the device
using
/dev/mem)Quoted 2 lines
and the PPC (440EPx in particular) has PCI and internal peripherals located at addresses above 4 GB (I2C, SPI, etc.).
I think
/dev/memworks by chance as it usesoff_tto address the source,
and that is 64 bit even on 32 bit hosts.But I just collected the confirmation that this extension of the PPC's physical address range is indeed an increasingly common thing. It's still a fairly new one, so the kernel is obviously also still in the conversion process. Maybe poking those people again makes some sense.
Quoted 1 line
Quoted 1 line
And what was the final conclusion on LKML? As far as I
understood the
Quoted 1 line
Quoted 1 line
UIO maintainer, the proposal was rejected. Any different
follow-ups on
Quoted 2 lines
Quoted 2 lines
this that I missed? Of course, if you have a special design you can always patch your kernel and Xenomai to fit these special
purposes. But
Quoted 3 lines
Quoted 2 lines
for upstream support, kernel or Xenomai, it requires a clean and portable model.
There were no follow-ups and the reply concerning the
required changes
Quoted 2 lines
was:
"I guess you'd have to look at the whole memory managementstuff of each
Quoted 5 lines
architecture to find out which kind of memory can be mapped with
addresses
above unsigned long. Hardware often needs more than one contigous
pages.
It might well be possible that a certain arch could haveRAM for user
Quoted 2 lines
virtual
addresses above 4GB, but no hardware. I don't know PPC wellenough to
Quoted 7 lines
say
anything about its behaviour."In the mean time, it would be helpful if you have some suggestions on how to
change RTDM to handle this case.
Quoted 5 lines
I think we can change
rtdm_iomap_to_userto takesrc_addrasphys_addr_t
and propagate this internally properly. We also need to add a wrapper forphys_addr_tfor kernels that doesn't support this (<2.6.28). To my current understanding, this should be sufficient, right?
Yes, I will give it a try and discuss results.
Luis
Re: [Xenomai-core] rtdm_iomap_to_user with phys addr > 4G
In reply to Jan KiszkaJan,
Quoted 6 lines
I think we can change
rtdm_iomap_to_userto takesrc_addrasphys_addr_t
and propagate this internally properly. We also need to add a wrapper forphys_addr_tfor kernels that doesn't support this (<2.6.28). To my current understanding, this should be sufficient, right?
This is a diff against Xenomai version 2.4.8 and Linux version 2.6.28 to handle RTDM mapping to user space of devices located at addresses > 4 GB.
Rather than modifying existing rtdm_iomap_to_user() API a new one is added, rtdm_iomap_to_user64() (to mimic mmap64()). Since this is a user API it can not use phys_addr_t so unsigned long long is used for the interface.
I tried to use rtdm_iomap_to_user() on a kernel module initialization section of my RTDM driver and passing NULL to user_info argument. This causes an invalid memory access and system panic. How can this function be called from kernel intialization code?
(quoted diff) +0 -0
b/include/asm-generic/xenomai/system.h
index 020e763..f2a9424 100644
include/asm-generic/xenomai/system.h +0 -0
@@ -417,7 +417,7 @@ static inline int xnarch_remap_vm_page(struct
vm_area_struct *vma,
static inline int xnarch_remap_io_page_range(struct file *filp,
struct vm_area_struct *vma, unsigned long from,
- unsigned long to,
+ phys_addr_t to,
unsigned long size, pgprot_t prot)
{
(quoted diff) +0 -0
b/include/asm-generic/xenomai/wrappers.h
index 943ed34..319ac0d 100644
include/asm-generic/xenomai/wrappers.h +5 -0
@@ -400,4 +400,9 @@ static inline int wrap_raise_cap(int cap) }#endif /* LINUX_VERSION_CODE >= 2.6.29 */ +/* For Linux versions < 2.6.28 */ +#ifndef phys_addr_t +#define phys_addr_t unsigned long +#endif +#endif /* _XENO_ASM_GENERIC_WRAPPERS_H */
(quoted diff) +0 -0
b/include/xenomai/rtdm/rtdm_driver.h
index 3026aff..181caef 100644
include/xenomai/rtdm/rtdm_driver.h +0 -0
@@ -1172,6 +1172,11 @@ int rtdm_iomap_to_user(rtdm_user_info_t
*user_info,
int prot, void **pptr,
struct vm_operations_struct *vm_ops, void *vm_private_data);
+int rtdm_iomap_to_user64(rtdm_user_info_t *user_info,
+ unsigned long long src_addr, size_t len,
+ int prot, void **pptr,
+ struct vm_operations_struct *vm_ops,
+ void *vm_private_data);
int rtdm_munmap(rtdm_user_info_t *user_info, void *ptr, size_t len);
static inline int rtdm_read_user_ok(rtdm_user_info_t *user_info,
(quoted diff) +0 -0
b/kernel/xenomai/skins/rtdm/drvlib.c
index 65c630f..0a710ee 100644
kernel/xenomai/skins/rtdm/drvlib.c +1 -1
@@ -1765,7 +1765,7 @@ void rtdm_nrtsig_pend(rtdm_nrtsig_t *nrt_sig);#if defined(CONFIG_XENO_OPT_PERVASIVE ) || defined(DOXYGEN_CPP )struct rtdm_mmap_data {void *src_vaddr; -unsigned long src_paddr; +phys_addr_t src_paddr;struct vm_operations_struct *vm_ops;void *vm_private_data; };
@@ -1773,14 +1773,15 @@ struct rtdm_mmap_data { static int rtdm_mmap_buffer(struct file *filp, struct vm_area_struct
*vma)
{
struct rtdm_mmap_data *mmap_data = filp->private_data;
- unsigned long vaddr, paddr, maddr, size;
+ unsigned long vaddr, maddr, size;
+ phys_addr_t paddr;
int ret;
vma->vm_ops = mmap_data->vm_ops; vma->vm_private_data = mmap_data->vm_private_data;
vaddr = (unsigned long)mmap_data->src_vaddr;
- paddr = (unsigned long)mmap_data->src_paddr;
+ paddr = (phys_addr_t)mmap_data->src_paddr;
if (!paddr)
/* kmalloc memory */
paddr = virt_to_phys((void *)vaddr);
@@ -1995,6 +1996,20 @@ int rtdm_iomap_to_user(rtdm_user_info_t *user_info,
EXPORT_SYMBOL(rtdm_iomap_to_user);
+int rtdm_iomap_to_user64(rtdm_user_info_t *user_info,
+ unsigned long long src_addr, size_t len,
+ int prot, void **pptr,
+ struct vm_operations_struct *vm_ops,
+ void *vm_private_data)
+{
+ struct rtdm_mmap_data mmap_data =
+ { NULL, src_addr, vm_ops, vm_private_data };
+
+ return rtdm_do_mmap(user_info, &mmap_data, len, prot, pptr);
+}
+
+EXPORT_SYMBOL(rtdm_iomap_to_user64);
+
/**
* Unmap a user memory range.
*
Luis
Re: [Xenomai-core] rtdm_iomap_to_user with phys addr > 4G
Quoted 9 lines · Luis
Jan,
Quoted 6 lines
I think we can change
rtdm_iomap_to_userto takesrc_addrasphys_addr_t
and propagate this internally properly. We also need to add a wrapper forphys_addr_tfor kernels that doesn't support this (<2.6.28). To my current understanding, this should be sufficient, right?
Quoted 3 lines
This is a diff against Xenomai version 2.4.8 and Linux version 2.6.28 to handle RTDM mapping to user space of devices located at addresses > 4 GB.
Does it apply against git-head as well? Note that this won't make it into stable 2.4.
Quoted 4 lines
Rather than modifying existing
rtdm_iomap_to_user()API a new one is added,rtdm_iomap_to_user64()(to mimicmmap64()). Since this is a user API it can not usephys_addr_tso unsigned long long is used for the interface.
64 bit is not related to phys_addr_t. It /may/ be 64 bit, but it may also be less (or more one day...?). So let's switch the existing interface, just like the kernel does.
And it is not a user API; it is used between the driver and RTDM only. How the driver deals with this in its user interface is a different story. I think there is currently no publicly available driver that maps I/O space into a user application, thus there is probably no stable RTDM profile that uses unsigned long to specify a physical address.
Quoted 5 lines
I tried to use
rtdm_iomap_to_user()on a kernel module initialization section of my RTDM driver and passing NULL touser_infoargument. This causes an invalid memory access and system panic. How can this function be called from kernel intialization code?
Not at all. It is supposed to be called on behalf of a user application, asking the driver to map some area into its address space. Then you have a valid user_info at hand.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [Xenomai-core] rtdm_iomap_to_user with phys addr > 4G
Please make sure to always preserve CCs.
Quoted 50 lines · Luis
Quoted 17 lines
-----Original Message-----
From: Jan Kiszka [mailto:[email protected]]
Sent: Wednesday, November 18, 2009 11:42 AM
To: Herrera-Bendezu, Luis
Cc: [email protected]
Subject: Re:rtdm_iomap_to_userwith phys addr > 4GQuoted 5 lines · Luis
Jan,
Quoted 3 lines
I think we can change
rtdm_iomap_to_userto takesrc_addrasphys_addr_t
and propagate this internally properly. We also need to adda wrapper
Quoted 1 line
Quoted 1 line
for
phys_addr_tfor kernels that doesn't support this(<2.6.28). To my
Quoted 9 lines
Quoted 3 lines
Quoted 2 lines
current understanding, this should be sufficient, right?
This is a diff against Xenomai version 2.4.8 and Linux
version 2.6.28 to
Quoted 2 lines
handle RTDM mapping to user space of devices located at addresses > 4 GB.
Does it apply against git-head as well? Note that this won't make it into stable 2.4.
Yes, included bellow.
Quoted 9 lines
Quoted 2 lines
Rather than modifying existing
rtdm_iomap_to_user()API a new one is added,rtdm_iomap_to_user64()(to mimicmmap64()). Sincethis is a user
Quoted 2 lines
API it can not use
phys_addr_tso unsigned long long is used for the interface.64 bit is not related to
phys_addr_t. It /may/ be 64 bit, but it may also be less (or more one day...?). So let's switch the existing interface, just like the kernel does.Quoted 8 lines
And it is not a user API; it is used between the driver and RTDM only. How the driver deals with this in its user interface is a different story. I think there is currently no publicly available driver that maps
I/O space into a user application, thus there is probably no stable RTDM
profile that uses unsigned long to specify a physical address.I was mislead by the function description on both accounts (only to be used by drivers and should be called from user application via driver, open, ioctl):
Environments:
Quoted 4 lines
This service can be called from:
* Kernel module initialization/cleanup code
* User-space task (non-RT)
Yeah, this can be confusing on first sight. It describes on behalf of which calling context an RTDM driver can execute a service.
Quoted 40 lines
Quoted 18 lines
Quoted 3 lines
I tried to use
rtdm_iomap_to_user()on a kernel module initialization section of my RTDM driver and passing NULL touser_infoargument. This
Quoted 2 lines
causes an invalid memory access and system panic. How can this function be called from kernel intialization code?
Not at all. It is supposed to be called on behalf of a user application,
asking the driver to map some area into its address space. Then you have
a validuser_infoat hand.Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linuxinclude/asm-generic/system.h +1
-1@@ -417,7 +417,7 @@ static inline int xnarch_remap_vm_page(structvm_area_struct *vma, static inline int xnarch_remap_io_page_range(struct file *filp,struct vm_area_struct *vma,unsigned long from, -unsigned long to, +phys_addr_t to,unsigned long size,pgprot_t prot){
include/asm-generic/wrappers.h +0
-0
include/asm-generic/wrappers.h static inline int wrap_raise_cap(int cap) · line 406
Quoted 7 lines
include/asm-generic/wrappers.h +4
-0@@ -400,4 +400,9 @@ static inline int wrap_raise_cap(int cap) }#endif /* LINUX_VERSION_CODE >= 2.6.29 */ +/* for Linux versions < 2.6.28 */ +#ifndef CONFIG_PHYS_ADDR_T_64BIT +typedef unsigned long phys_addr_t ; +#endif
Let's make this cleanly depend on the kernel version, not some other define which may or may not be defined independent of this type.
Quoted 34 lines
include/asm-generic/wrappers.h +1
-0+#endif /* _XENO_ASM_GENERIC_WRAPPERS_H */ include/rtdm/rtdm_driver.h +1
-1@@ -1168,7 +1168,7 @@ int rtdm_mmap_to_user(rtdm_user_info_t *user_info,struct vm_operations_struct *vm_ops, void *vm_private_data);int rtdm_iomap_to_user (rtdm_user_info_t *user_info, -unsigned long src_addr,size_t len, +phys_addr_t src_addr,size_t len,int prot,void **pptr,struct vm_operations_struct *vm_ops,void *vm_private_data);ksrc/skins/rtdm/drvlib.c +1
-2@@ -1765,7 +1765,7 @@ void rtdm_nrtsig_pend(rtdm_nrtsig_t *nrt_sig);#if defined(CONFIG_XENO_OPT_PERVASIVE ) || defined(DOXYGEN_CPP )struct rtdm_mmap_data {void *src_vaddr; -unsigned long src_paddr; +phys_addr_t src_paddr;struct vm_operations_struct *vm_ops;void *vm_private_data; };@@ -1773,14 +1773,15 @@ struct rtdm_mmap_data {static int rtdm_mmap_buffer (struct file *filp,struct vm_area_struct *vma) {struct rtdm_mmap_data *mmap_data = filp->private_data; -unsigned long vaddr, paddr, maddr, size;
ksrc/skins/rtdm/drvlib.c struct rtdm_mmap_data { · line 1785
Quoted 10 lines
ksrc/skins/rtdm/drvlib.c +3
-1+unsigned long vaddr, maddr, size; +phys_addr_t paddr;int ret; vma->vm_ops = mmap_data->vm_ops; vma->vm_private_data = mmap_data->vm_private_data; vaddr = (unsigned long )mmap_data->src_vaddr; - paddr = (unsigned long )mmap_data->src_paddr; + paddr = (phys_addr_t )mmap_data->src_paddr;
A good chance to drop this typecast-nop (paddr and src_paddr are already of the same type).
Quoted 13 lines
ksrc/skins/rtdm/drvlib.c +0
-0if (!paddr)/* kmalloc memory */ ksrc/skins/rtdm/drvlib.c +1
-1paddr =virt_to_phys ((void *)vaddr);@@ -1982,7 +1983,7 @@ EXPORT_SYMBOL(rtdm_mmap_to_user);* Rescheduling: possible. */ int rtdm_iomap_to_user (rtdm_user_info_t *user_info, -unsigned long src_addr,size_t len, +phys_addr_t src_addr,size_t len,int prot,void **pptr,struct vm_operations_struct *vm_ops,void *vm_private_data)
Quoted 1 line
Luis
Except for the minor remarks, I'm fine with the patch. Please repost in a proper format: patch subject, a short description, a signed-off, and then the diff.
Thanks,
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
PATCH 1/1 rtdm: Extend rtdm_iomap_to_user to map phys addr > 4G
rtdm_iomap_to_user does not handle I/O memory mapping of physical I/O address grater than 4 GB.
This patch changes the src_addr argument and underlying code to handle this case.
---
include/asm-generic/system.h +0 -0
@@ -417,7 +417,7 @@ static inline int xnarch_remap_vm_page(struct
vm_area_struct *vma,
static inline int xnarch_remap_io_page_range(struct file *filp,
struct vm_area_struct *vma, unsigned long from,
- unsigned long to,
+ phys_addr_t to,
unsigned long size, pgprot_t prot)
{
(quoted diff) +0 -0
b/include/asm-generic/wrappers.h
index 943ed34..239eb93 100644
include/asm-generic/wrappers.h +4 -0
@@ -400,4 +400,8 @@ static inline int wrap_raise_cap(int cap) }#endif /* LINUX_VERSION_CODE >= 2.6.29 */ +#if LINUX_VERSION_CODE <KERNEL_VERSION (2 ,6 ,28 ) +typedef unsigned long phys_addr_t ; +#endif +#endif /* _XENO_ASM_GENERIC_WRAPPERS_H */
include/rtdm/rtdm_driver.h +1 -1
@@ -1168,7 +1168,7 @@ int rtdm_mmap_to_user(rtdm_user_info_t *user_info,struct vm_operations_struct *vm_ops, void *vm_private_data);int rtdm_iomap_to_user (rtdm_user_info_t *user_info, -unsigned long src_addr,size_t len, +phys_addr_t src_addr,size_t len,int prot,void **pptr,struct vm_operations_struct *vm_ops,void *vm_private_data);
ksrc/skins/rtdm/drvlib.c +1 -1
@@ -1765,7 +1765,7 @@ void rtdm_nrtsig_pend(rtdm_nrtsig_t *nrt_sig);#if defined(CONFIG_XENO_OPT_PERVASIVE ) || defined(DOXYGEN_CPP )struct rtdm_mmap_data {void *src_vaddr; -unsigned long src_paddr; +phys_addr_t src_paddr;struct vm_operations_struct *vm_ops;void *vm_private_data; };
@@ -1773,14 +1773,15 @@ struct rtdm_mmap_data { static int rtdm_mmap_buffer(struct file *filp, struct vm_area_struct
*vma)
{
struct rtdm_mmap_data *mmap_data = filp->private_data;
- unsigned long vaddr, paddr, maddr, size;
+ unsigned long vaddr, maddr, size;
+ phys_addr_t paddr;
int ret;
vma->vm_ops = mmap_data->vm_ops; vma->vm_private_data = mmap_data->vm_private_data;
vaddr = (unsigned long)mmap_data->src_vaddr;
- paddr = (unsigned long)mmap_data->src_paddr;
+ paddr = mmap_data->src_paddr;
if (!paddr)
/* kmalloc memory */
paddr = virt_to_phys((void *)vaddr);
@@ -1982,7 +1983,7 @@ EXPORT_SYMBOL(rtdm_mmap_to_user);
* Rescheduling: possible.
*/
int rtdm_iomap_to_user(rtdm_user_info_t *user_info,
- unsigned long src_addr, size_t len,
+ phys_addr_t src_addr, size_t len,
int prot, void **pptr, struct vm_operations_struct *vm_ops, void *vm_private_data)
---
Re: [Xenomai-core] [PATCH] rtdm: Extend rtdm_iomap_to_user to map phys addr > 4G
Quoted 7 lines · Luis
rtdm_iomap_to_userdoes not handle I/O memory mapping of physical I/O address grater than 4 GB.This patch changes the
src_addrargument and underlying code to handle this case.Signed-off-by Luis Herrera-Bendezu <[email protected]>
^^^^^^^^^^^
Something made your mail address unreadable. This is pointless (your address is already archived on this list). Moreover, we need a proper signature as a declaration that you are authorized to contribute this patch. One may argue that the patch is trivial and not "copyrightable", but we better avoid being sloppy even in that case.
Besides this, the patch is unfortunately line wrap. Make sure that wrapping is switched off or use a different mailer.
Thanks,
Jan
Quoted 84 lines
---
include/asm-generic/system.h +1
-1@@ -417,7 +417,7 @@ static inline int xnarch_remap_vm_page(structvm_area_struct *vma, static inline int xnarch_remap_io_page_range(struct file *filp,struct vm_area_struct *vma,unsigned long from, -unsigned long to, +phys_addr_t to,unsigned long size,pgprot_t prot){
include/asm-generic/wrappers.h +4
-0@@ -400,4 +400,8 @@ static inline int wrap_raise_cap(int cap) }#endif /* LINUX_VERSION_CODE >= 2.6.29 */ +#if LINUX_VERSION_CODE <KERNEL_VERSION (2 ,6 ,28 ) +typedef unsigned long phys_addr_t ; +#endif +#endif /* _XENO_ASM_GENERIC_WRAPPERS_H */ include/rtdm/rtdm_driver.h +1
-1@@ -1168,7 +1168,7 @@ int rtdm_mmap_to_user(rtdm_user_info_t *user_info,struct vm_operations_struct *vm_ops, void *vm_private_data);int rtdm_iomap_to_user (rtdm_user_info_t *user_info, -unsigned long src_addr,size_t len, +phys_addr_t src_addr,size_t len,int prot,void **pptr,struct vm_operations_struct *vm_ops,void *vm_private_data);ksrc/skins/rtdm/drvlib.c +4
-3@@ -1765,7 +1765,7 @@ void rtdm_nrtsig_pend(rtdm_nrtsig_t *nrt_sig);#if defined(CONFIG_XENO_OPT_PERVASIVE ) || defined(DOXYGEN_CPP )struct rtdm_mmap_data {void *src_vaddr; -unsigned long src_paddr; +phys_addr_t src_paddr;struct vm_operations_struct *vm_ops;void *vm_private_data; };@@ -1773,14 +1773,15 @@ struct rtdm_mmap_data {static int rtdm_mmap_buffer (struct file *filp,struct vm_area_struct *vma) {struct rtdm_mmap_data *mmap_data = filp->private_data; -unsigned long vaddr, paddr, maddr, size; +unsigned long vaddr, maddr, size; +phys_addr_t paddr;int ret; vma->vm_ops = mmap_data->vm_ops; vma->vm_private_data = mmap_data->vm_private_data; vaddr = (unsigned long )mmap_data->src_vaddr; - paddr = (unsigned long )mmap_data->src_paddr; + paddr = mmap_data->src_paddr;if (!paddr)/* kmalloc memory */ ksrc/skins/rtdm/drvlib.c +1
-2paddr =virt_to_phys ((void *)vaddr);@@ -1982,7 +1983,7 @@ EXPORT_SYMBOL(rtdm_mmap_to_user);* Rescheduling: possible. */ int rtdm_iomap_to_user (rtdm_user_info_t *user_info, -unsigned long src_addr,size_t len, +phys_addr_t src_addr,size_t len,int prot,void **pptr,struct vm_operations_struct *vm_ops,void *vm_private_data) ---
Re: [Xenomai-core] [PATCH] rtdm: Extend rtdm_iomap_to_user to map phys addr > 4G
Jan,
Thanks for your feedback and help.
Luis
Quoted 23 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]
Sent: Saturday, November 21, 2009 3:43 AM
To: Herrera-Bendezu, Luis
Cc: xenomai-core
Subject: Re: [PATCH] rtdm: Extendrtdm_iomap_to_userto map phys addr > 4GQuoted 7 lines · Luis
rtdm_iomap_to_userdoes not handle I/O memory mapping of physical I/O address grater than 4 GB.This patch changes the
src_addrargument and underlying code to handle this case.Signed-off-by Luis Herrera-Bendezu <[email protected]>^^^^^^^^^^^Something made your mail address unreadable. This is pointless (your address is already archived on this list). Moreover, we need a proper signature as a declaration that you are authorized to contribute this patch. One may argue that the patch is trivial and not "copyrightable", but we better avoid being sloppy even in that case.
Quoted 5 lines
Besides this, the patch is unfortunately line wrap. Make sure that wrapping is switched off or use a different mailer.
Thanks,
Jan
rtdm_iomap_to_user does not handle I/O memory mapping of physical I/O address grater than 4 GB.
This patch changes the src_addr argument and underlying code to handle this case.
---
include/asm-generic/system.h +0 -0
@@ -417,7 +417,7 @@ static inline int xnarch_remap_vm_page(struct
vm_area_struct *vma,
static inline int xnarch_remap_io_page_range(struct file *filp,
struct vm_area_struct *vma, unsigned long from,
- unsigned long to,
+ phys_addr_t to,
unsigned long size, pgprot_t prot)
{
(quoted diff) +0 -0
b/include/asm-generic/wrappers.h
index 943ed34..239eb93 100644
include/asm-generic/wrappers.h +4 -0
@@ -400,4 +400,8 @@ static inline int wrap_raise_cap(int cap) }#endif /* LINUX_VERSION_CODE >= 2.6.29 */ +#if LINUX_VERSION_CODE <KERNEL_VERSION (2 ,6 ,28 ) +typedef unsigned long phys_addr_t ; +#endif +#endif /* _XENO_ASM_GENERIC_WRAPPERS_H */
include/rtdm/rtdm_driver.h +1 -1
@@ -1168,7 +1168,7 @@ int rtdm_mmap_to_user(rtdm_user_info_t *user_info,struct vm_operations_struct *vm_ops, void *vm_private_data);int rtdm_iomap_to_user (rtdm_user_info_t *user_info, -unsigned long src_addr,size_t len, +phys_addr_t src_addr,size_t len,int prot,void **pptr,struct vm_operations_struct *vm_ops,void *vm_private_data);
ksrc/skins/rtdm/drvlib.c +1 -1
@@ -1765,7 +1765,7 @@ void rtdm_nrtsig_pend(rtdm_nrtsig_t *nrt_sig);#if defined(CONFIG_XENO_OPT_PERVASIVE ) || defined(DOXYGEN_CPP )struct rtdm_mmap_data {void *src_vaddr; -unsigned long src_paddr; +phys_addr_t src_paddr;struct vm_operations_struct *vm_ops;void *vm_private_data; };
@@ -1773,14 +1773,15 @@ struct rtdm_mmap_data { static int rtdm_mmap_buffer(struct file *filp, struct vm_area_struct
*vma)
{
struct rtdm_mmap_data *mmap_data = filp->private_data;
- unsigned long vaddr, paddr, maddr, size;
+ unsigned long vaddr, maddr, size;
+ phys_addr_t paddr;
int ret;
vma->vm_ops = mmap_data->vm_ops; vma->vm_private_data = mmap_data->vm_private_data;
vaddr = (unsigned long)mmap_data->src_vaddr;
- paddr = (unsigned long)mmap_data->src_paddr;
+ paddr = mmap_data->src_paddr;
if (!paddr)
/* kmalloc memory */
paddr = virt_to_phys((void *)vaddr);
@@ -1982,7 +1983,7 @@ EXPORT_SYMBOL(rtdm_mmap_to_user);
* Rescheduling: possible.
*/
int rtdm_iomap_to_user(rtdm_user_info_t *user_info,
- unsigned long src_addr, size_t len,
+ phys_addr_t src_addr, size_t len,
int prot, void **pptr, struct vm_operations_struct *vm_ops, void *vm_private_data)
---
Re: [Xenomai-core] [PATCH] rtdm: Extend rtdm_iomap_to_user to map phys addr > 4G
Quoted 3 lines · Luis
Jan,
Thanks for your feedback and help.
Merged your patch (and sent out a pull request), though the line wrapping issue persisted (manually fixed up).
Your next patch to an open source project probably deserves the use of a better mail client.
Jan
Quoted 121 lines
Quoted 23 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]
Sent: Saturday, November 21, 2009 3:43 AM
To: Herrera-Bendezu, Luis
Cc: xenomai-core
Subject: Re: [PATCH] rtdm: Extendrtdm_iomap_to_userto map phys addr > 4GQuoted 7 lines · Luis
rtdm_iomap_to_userdoes not handle I/O memory mapping of physical I/O address grater than 4 GB.This patch changes the
src_addrargument and underlying code to handle this case.Signed-off-by Luis Herrera-Bendezu <[email protected]>^^^^^^^^^^^Something made your mail address unreadable. This is pointless (your address is already archived on this list). Moreover, we need a proper signature as a declaration that you are authorized to contribute this patch. One may argue that the patch is trivial and not "copyrightable", but we better avoid being sloppy even in that case.
Quoted 5 lines
Besides this, the patch is unfortunately line wrap. Make sure that wrapping is switched off or use a different mailer.
Thanks,
Jan
rtdm_iomap_to_userdoes not handle I/O memory mapping of physical I/O address grater than 4 GB.This patch changes the
src_addrargument and underlying code to handle this case.Signed-off-by Luis Herrera-Bendezu <[email protected]>---
include/asm-generic/system.h +1
-1@@ -417,7 +417,7 @@ static inline int xnarch_remap_vm_page(structvm_area_struct *vma, static inline int xnarch_remap_io_page_range(struct file *filp,struct vm_area_struct *vma,unsigned long from, -unsigned long to, +phys_addr_t to,unsigned long size,pgprot_t prot){
include/asm-generic/wrappers.h +4
-0@@ -400,4 +400,8 @@ static inline int wrap_raise_cap(int cap) }#endif /* LINUX_VERSION_CODE >= 2.6.29 */ +#if LINUX_VERSION_CODE <KERNEL_VERSION (2 ,6 ,28 ) +typedef unsigned long phys_addr_t ; +#endif +#endif /* _XENO_ASM_GENERIC_WRAPPERS_H */ include/rtdm/rtdm_driver.h +1
-1@@ -1168,7 +1168,7 @@ int rtdm_mmap_to_user(rtdm_user_info_t *user_info,struct vm_operations_struct *vm_ops, void *vm_private_data);int rtdm_iomap_to_user (rtdm_user_info_t *user_info, -unsigned long src_addr,size_t len, +phys_addr_t src_addr,size_t len,int prot,void **pptr,struct vm_operations_struct *vm_ops,void *vm_private_data);ksrc/skins/rtdm/drvlib.c +4
-3@@ -1765,7 +1765,7 @@ void rtdm_nrtsig_pend(rtdm_nrtsig_t *nrt_sig);#if defined(CONFIG_XENO_OPT_PERVASIVE ) || defined(DOXYGEN_CPP )struct rtdm_mmap_data {void *src_vaddr; -unsigned long src_paddr; +phys_addr_t src_paddr;struct vm_operations_struct *vm_ops;void *vm_private_data; };@@ -1773,14 +1773,15 @@ struct rtdm_mmap_data {static int rtdm_mmap_buffer (struct file *filp,struct vm_area_struct *vma) {struct rtdm_mmap_data *mmap_data = filp->private_data; -unsigned long vaddr, paddr, maddr, size; +unsigned long vaddr, maddr, size; +phys_addr_t paddr;int ret; vma->vm_ops = mmap_data->vm_ops; vma->vm_private_data = mmap_data->vm_private_data; vaddr = (unsigned long )mmap_data->src_vaddr; - paddr = (unsigned long )mmap_data->src_paddr; + paddr = mmap_data->src_paddr;if (!paddr)/* kmalloc memory */ ksrc/skins/rtdm/drvlib.c +1
-2paddr =virt_to_phys ((void *)vaddr);@@ -1982,7 +1983,7 @@ EXPORT_SYMBOL(rtdm_mmap_to_user);* Rescheduling: possible. */ int rtdm_iomap_to_user (rtdm_user_info_t *user_info, -unsigned long src_addr,size_t len, +phys_addr_t src_addr,size_t len,int prot,void **pptr,struct vm_operations_struct *vm_ops,void *vm_private_data) ---