I have a PCI-e hardware device that has a number of registers that I want to read from and write to. However, when I read a register, I will get a value from a previous read (the first read returns 0xFFFFFFFF).
I'm using pci_iomap() to get the base address of the I/O area. I tried using readl() and ioread32() instead of direct pointer dereferencing that was in the original code that I received. All give the same results.
For example, if register foo
contains 0xDEADBEEF, the first read will return 0xFFFFFFFF while subsequent reads return 0xDEADBEEF. If I then read register bar
, which contains 0xFEEDFACE, the first read will return 0xDEADBEEF, all subsequent reads will return 0xFEEDFACE.
If you are seeing the bad values from the user code, calling ioctl(), and getting the bad value back, take a look at the driver's use of copy_from_user() and copy_to_user(). As a check you could use printk() or better dev_dbg() to print the register address and value as seen by the driver.
User contributions licensed under CC BY-SA 3.0