diff options
author | Tom St Denis <tom.stdenis@amd.com> | 2019-04-03 13:51:06 -0400 |
---|---|---|
committer | Tom St Denis <tom.stdenis@amd.com> | 2019-04-03 13:51:06 -0400 |
commit | d15c81aab05f322632fce0aac162e0d8ff98de52 (patch) | |
tree | 9b3352dd76ddf406fc86c0ae4d85bd62118f5ed7 | |
parent | 113987639a70762a00fd0d0c344e48a8dee8f64b (diff) |
improve comments on umr_vm_dma_to_phys()
Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
-rw-r--r-- | src/lib/lowlevel/linux/mem.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/lib/lowlevel/linux/mem.c b/src/lib/lowlevel/linux/mem.c index 1df4550..944be4d 100644 --- a/src/lib/lowlevel/linux/mem.c +++ b/src/lib/lowlevel/linux/mem.c @@ -32,17 +32,22 @@ #define DEBUG(...) #endif -// try to convert a DMA address to physical via trace -uint64_t umr_vm_dma_to_phys(struct umr_asic *asic, uint64_t dma_addr) +/** umr_vm_dma_to_phys -- Convert a GPU bound bus address to CPU physical */ + uint64_t umr_vm_dma_to_phys(struct umr_asic *asic, uint64_t dma_addr) { uint64_t phys; if (asic->fd.iova >= 0) { + // older kernels had a iova debugfs file which would return + // an address given a seek to a given address this has been + // removed in newer kernels lseek(asic->fd.iova, dma_addr & ~0xFFFULL, SEEK_SET); if (read(asic->fd.iova, &phys, 8) != 8) { fprintf(stderr, "[ERROR]: Could not read from debugfs iova file for address %" PRIx64 "\n", dma_addr); return 0; } } else { + // newer kernels use iomem which requires a GPU bus address + // to read/write system memory bound to the GPU phys = dma_addr; } return phys; |