LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 12-21-2018, 08:03 PM   #1
jwprice100
LQ Newbie
 
Registered: Dec 2018
Posts: 4

Rep: Reputation: Disabled
Pages of PCI-E Memory mapped with ioremap


Hello,

My background is in FPGA design, not kernel development. I'm pretty new to a lot of the things going on behind the scenes in the kernel. I've been trying to get my head wrapped around various details related to memory management in Linux. I appear to have hit a roadblock and could really use some help.

I'm trying to determine how to obtain the page structures of PCI-E virtual addresses I've mapped with ioremap. I have no problem actually reading or writing to memory so I'm sure that much as been done correctly. I get a virtual address back and was planning to to virt_to_page. However I noticed that virt_addr_valid returns false. Digging more into things two appear to be two kinds of virtual address within the kernel: logical and virtual (this seems like an unfortunate naming convention). Near as I can virt_addr_valid is checking for logical address. The virtual address space is often referred to as the vma_alloc area as well. This area is also where IO is mapped. Digging more I found the is_vmalloc_addr helper. Passing in the address return from ioremap returns true. Great, so now I can use vmalloc_to_page. Unfortunately This returns NULL for my PCI-Express virtual address. Passing in a pointer allocated with vmaalloc does return a page. At this point I've appeared to have exhausted all avenues for actually getting these pages. I may dig more into how ioremap in to get answers but I'm hoping a kind expert will be able to point me in the right direction.

Thanks for any assistance!
 
Old 12-22-2018, 03:54 PM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,141

Rep: Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264
I'm not an expert on this, but I think ioremap returns a virtual address which is not in the page tables. Access to the PCIe memory is supported instead by request_mem_region which will prevent multiple processes from mapping the same addresses.

Why would you need a page structure for an I/O region? If you are trying to map to user space you just use the uio driver.
 
Old 12-27-2018, 09:51 AM   #3
jwprice100
LQ Newbie
 
Registered: Dec 2018
Posts: 4

Original Poster
Rep: Reputation: Disabled
According to this random blog post, ioremap does create entries in the page table: http://learnlinuxconcepts.blogspot.c...s-ioremap.html.

Why do I need this? I'm trying to do some interesting work where I'm moving data between different hardware peripherals without going through system memory. Trying to paint into user space and then DMA from userspace isn't an oprion as I'm pushing a whole lot of data (gigabytes per second). Interestingly enough the 4.20 kernel has added support for this kind of functionality between PCI-Express endpoints (with certain limitations), but I also have a use case where I'm moving data where one of the endpoints isn't a PCI-Express device. I'm trying to keep Linux involved and orchestrating these transfers (especially in the case of when writing files to a disk). However I'm not super knowledgeable about anything outside of user space and basic driver development so I'm not 100% sure this is possible yet.
 
Old 12-28-2018, 06:36 PM   #4
jwprice100
LQ Newbie
 
Registered: Dec 2018
Posts: 4

Original Poster
Rep: Reputation: Disabled
For those interested, playing around with the PCI Peer to Peer infrastructure bore some fruit. The pci_p2pdma_add_resource creates page structures. I'm not 100% sure if ioremap does or not. It creates something in the in the page tables, but I wasn't able to get a valid page structure. Fortunately the addresses returned from pci_alloc_p2pmem are kernel logical address. As a result virt_to_page works on them. Doing a page_to_phys returns the BAR address so all looks good. There are some limitations with the currently supported features, but I expect future versions of the kernel to expand upon details.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Module development - set-aside memory and ioremap scorn001 Programming 1 07-26-2018 09:14 AM
Get number of dirty pages of memory-mapped file via syscall dezo Linux - Kernel 1 01-16-2012 11:14 AM
memory mapped i/o and i/o mapped i/o shilpa rangappa General 1 12-14-2009 10:27 PM
Network device Memory mapped or Port mapped ?? Bignon Linux - Hardware 0 10-20-2009 08:36 AM
how to count the fault pages and the mapped pages riquelme Programming 0 05-20-2004 10:16 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 12:17 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration