Skip to contentSkip to conversation

Try /dev/fmem first when reading system memory

PATCH New Tom St Denis 1 participant 1 message Mar 21, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Try /dev/fmem first when reading system memory

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.

---
 src/lib/read_vram.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
src/lib/read_vram.c +4 -1
index 6675dafbe1d0..e2087a252c10 100644
@@ -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 {
Signature · 6 lines
2.12.0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx