LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Embedded & Single-board computer (https://www.linuxquestions.org/questions/linux-embedded-and-single-board-computer-78/)
-   -   Device driver: read\write multiple words (https://www.linuxquestions.org/questions/linux-embedded-and-single-board-computer-78/device-driver-read%5Cwrite-multiple-words-4175567897/)

zvivered 01-25-2016 09:47 PM

Device driver: read\write multiple words
 
Hello,

I'm developing a device driver for an FPGA that has dozens of registers. The registers are not address contiguous.

Till now, every register was written with a single IOCtl request.

Is there any alternative ?

I suspect this way is quite slow.

I can map the BARs of the FPGA to user space and write\read by *(long*) from the user space driver.
Is it a wise step ?

Regards,
Z.V

blue_z 01-26-2016 03:14 AM

Quote:

Originally Posted by zvivered (Post 5487392)
Till now, every register was written with a single IOCtl request.

Is there any alternative ?

I suspect this way is quite slow.

The "slowness" would be due to the overhead of each system call.
You could minimize the overhead by using just one write() syscall, and pass the pointer of an array of the register values.
Use a soft mapping of array elements to FPGA registers.

E.G. The driver would have an array defining the mapping. Each element contains an FPGA register address (in any order you choose).
Code:

map[0] = reg_A
map[1] = reg_D
map[2] = reg_b
map[3] = reg_M

The userspace program would write to the device with an array. The driver copies the array into kernel space, and then in a loop extracts each value from the array and writes to the appropriate register per the map list.
You would need to handle various read/write lengths and maintain a read/write offset, and accept lseek(fd, 0, SEEK_SET) to reset that offset.

Regards


All times are GMT -5. The time now is 04:53 PM.