简体   繁体   English

Linux PCIe设备驱动程序读/写功能不适用于某些地址

[英]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. 我编写了PCIe设备驱动程序,读/写功能无法正常工作。 The device has 3 memory regions which begin at 0x10800000, 0x0c000000, and 0x80000000. 该器件有3个存储区,从0x10800000,0x0c000000和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. 如果我从用户空间应用程序调用pread()或pwrite(),我会看到前2个内存区域传递的地址,但是如果我调用第三个内存区域,我什么也看不见就好像它没有甚至进入驱动程序的读写功能。

My driver works completely fine on a 64-bit machine running linux version 2.6.32. 我的驱动程序在运行Linux版本2.6.32的64位计算机上运行完全正常。 This other machine that it doesn't work on is a 32-bit machine running linux version 2.6.25. 它不能使用的另一台机器是运行linux 2.6.25版本的32位机器。 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. 我的想法是,也许32位不喜欢0x80000000地址,但我不知道如何验证它或如何修复它,如果是这样的话。

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. 这是一个非常模糊的问题(你正在做什么文件pread / pwrite?)但是因为你说一切都在64位工作而你的驱动程序甚至没有被调用32位,我猜这个问题是off_t大小以及0x80000000溢出32位并成为巨大负数的事实。

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)? (或者在gcc命令行上传递“-D_FILE_OFFSET_BITS = 64”)?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM