Chris
Chris

Reputation: 412

Linux PCIe device driver read/write functions not working for certain addresses

I have written a PCIe device driver and the read/write functions are not working correctly. The device has 3 memory regions which begin at 0x10800000, 0x0c000000, and 0x80000000. Just for testing purposes, my read and write functions in the driver print out the address passed and return. If I call pread() or pwrite() from a user space app, I see the address passed for the first 2 memory regions, but if I make the call for the third memory region, I see nothing at all as if it didn't even enter the driver read or write functions.

My driver works completely fine on a 64-bit machine running linux version 2.6.32. This other machine that it doesn't work on is a 32-bit machine running linux version 2.6.25. My thought is that maybe 32-bit doesn't like the 0x80000000 address, but I don't know how to verify that or how to fix it if that is the case.

Upvotes: 3

Views: 1566

Answers (1)

Roland
Roland

Reputation: 6543

This is a pretty vague question (what file are you doing pread/pwrite on?) but since you say everything works on 64-bit and your driver doesn't even get called on 32-bit, I'm guessing the issue is the size of off_t and the fact that 0x80000000 overflows 32 bits and becomes a huge negative number.

What if you put

  #define _FILE_OFFSET_BITS 64

as the first line of your userspace source code? (Or pass "-D_FILE_OFFSET_BITS=64" on the gcc command line)?

Upvotes: 1

Related Questions