I am working on an x86-based 64-bit system. The device in question is an eMMC controller, that has 64-bit memory-mapped regions. I am trying to access first region through the address pointed to by the BAR, but I can only read 0xffffffff's (0xffffffff_ffffffff for 64-bit read). I have tried both using /dev/mem by explicitly using the BAR and pciemem
to read through /sys/devices/pcie/xxxxxx/resource0 and get same results.
If I use same logic on other PCIe devices (e.g. USB controller), I can read the memory without an issue. I have gone through the kernel source code and found out that both device drivers are using similar request_region calls, with exclusive flag = 0 (to allow user-space access to PCIe memory). Still, I have this problem only with the eMMC controller. Opening the resource0 or mmapping /dev/mem doesn't throw any error either. I need to find out why I am seeing 0xffffffff's and a way to fix this.
Another important piece of information is that I can access these registers from the bootloader. They are not accessible after Linux boots up, so my guess is that it has to do with memory access permissions, instead of HW locks to read certain registers.