[PATCH umr] Try /dev/fmem first when reading system memory
Tom St Denis
tstdenis82 at gmail.com
Tue Mar 21 14:20:37 UTC 2017
On many platforms /dev/mem is restricted to PCI I/O space
only. The /dev/fmem device driver can be found
on github and it allows unrestricted access to physical memory.
Signed-off-by: Tom St Denis <tom.stdenis at amd.com>
---
src/lib/read_vram.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/lib/read_vram.c b/src/lib/read_vram.c
index 6675dafbe1d0..e2087a252c10 100644
--- a/src/lib/read_vram.c
+++ b/src/lib/read_vram.c
@@ -61,7 +61,9 @@ static int umr_read_sram(uint64_t address, uint32_t size, void *dst)
{
int fd;
- fd = open("/dev/mem", O_RDWR | O_DSYNC);
+ fd = open("/dev/fmem", O_RDWR);
+ if (fd < 0)
+ fd = open("/dev/mem", O_RDWR | O_DSYNC);
if (fd >= 0) {
memset(dst, 0xFF, size);
lseek(fd, address, SEEK_SET);
@@ -192,6 +194,7 @@ static int umr_read_vram_vi(struct umr_asic *asic, uint32_t vmid, uint64_t addre
if (pte_fields.system) {
if (umr_read_sram(start_addr, chunk_size, pdst) < 0) {
fprintf(stderr, "[ERROR] Cannot read system ram, perhaps CONFIG_STRICT_DEVMEM is set in your kernel config?\n");
+ fprintf(stderr, "[ERROR] Alternatively download and install /dev/fmem\n");
return -1;
}
} else {
--
2.12.0
More information about the amd-gfx
mailing list