LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Password
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.

Notices


Reply
  Search this Thread
Old 09-29-2020, 07:20 PM   #1
DavesGarage
LQ Newbie
 
Registered: Sep 2020
Location: USA
Distribution: Ubuntu
Posts: 3

Rep: Reputation: Disabled
Mapping off-board memory over a PCIe interface as a tmpfs drive.


Hi all. I'm interested in discussing ways to map off-board memory to a locally mapped file system.
To explain: I have access to off-board memory, and a kernel module supplied by Xilinx called xdma that is up and running nicely. I define the DMA channel, pass it an address and offset, and I can read/write over the PCIe interface just fine, using interrupts or just polling.

Now I was thinking I could write a block kernel module to interface with the DMA engine, then map the block device as a drive (like a hard drive), and assign a file system to it, and use it like a hard drive.

I'd like to discuss this approach with someone more familiar with linux than myself.
 
Old 09-30-2020, 09:20 AM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,155

Rep: Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266
You have it right. Implementing a block driver gets you all the benefits of the standard machinery for dealing with disks and storage. The O'Reilley "Linux Device Drivers" has a chapter on block device drivers, but is not updated since 2005, so some details may have wandered a little. Not sure if there is a better reference.

Basically, you have to implement a request queue for handling the async I/O requests to your device, and some of the calls on the block_device_operations struct (open/close/ioctl). Look at an existing driver for reference. The hard disk (sd.c) and floppy disk (floppy.c) are both pretty big to deal with all the hardware complications, but yours can take a lot of shortcuts.
 
1 members found this post helpful.
Old 09-30-2020, 09:38 AM   #3
DavesGarage
LQ Newbie
 
Registered: Sep 2020
Location: USA
Distribution: Ubuntu
Posts: 3

Original Poster
Rep: Reputation: Disabled
Awesome. That's what I was looking for. I read the section from O-Reilley https://www.oreilly.com/openbook/lin.../book/ch16.pdf and it seemed appropriate. You're right, it's antiquated.
I'll have a look at sd.c and floppy.c...

Is ioctl still used, or has this been deprecated now? I thought I read somewhere there's another preferred method?

Anyway, thank you for confirming this approach.
 
Old 09-30-2020, 12:32 PM   #4
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,155

Rep: Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266
Some userspace code might expect certain ioctls, but I don't think they are absolutely necessary. I'm thinking of equally deprecated software like fdisk. It's simpler to use the /sys interface for new code.
 
1 members found this post helpful.
Old 09-30-2020, 12:57 PM   #5
DavesGarage
LQ Newbie
 
Registered: Sep 2020
Location: USA
Distribution: Ubuntu
Posts: 3

Original Poster
Rep: Reputation: Disabled
Thumbs up

Click image for larger version

Name:	image1.jpg
Views:	31
Size:	29.5 KB
ID:	34198

Ok, I'll update later when I get things working correctly.
Thanks again!
-Dave
 
  


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
/etc/fstab "tmpfs /tmp tmpfs defaults 0 0" ramfs?! HOW? xcislav Linux - General 2 06-04-2011 03:03 AM
Linux Virtual memory mapping to Board memory map !rajkums! Linux - Kernel 4 10-19-2008 12:27 PM
Kernel virtual memory map TO Board memory map -----> Mapping !rajkums! Linux - Embedded & Single-board computer 0 10-18-2008 09:21 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer

All times are GMT -5. The time now is 07:55 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