diff options
author | Tom St Denis <tom.stdenis@amd.com> | 2019-03-08 13:20:31 -0500 |
---|---|---|
committer | Tom St Denis <tom.stdenis@amd.com> | 2019-03-08 13:20:31 -0500 |
commit | 6bef9e20197410cd60e11f680a9e5e03e64c4d08 (patch) | |
tree | db42c54c5316df1b0cb35c475cea3c9972920871 | |
parent | 0319b0ce62509c89d36db31c1911bb64b992a4a5 (diff) |
round vram size up to power of two for xgmi mapping
Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
-rw-r--r-- | src/lib/read_vram.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/lib/read_vram.c b/src/lib/read_vram.c index 4df511c..2043852 100644 --- a/src/lib/read_vram.c +++ b/src/lib/read_vram.c @@ -704,6 +704,14 @@ invalid_page: return -1; } +static uint64_t round_up_pot(uint64_t x) +{ + uint64_t y = (64ULL * 1024 * 1024); // start at 64MiB + while (y < x) + y <<= 1; + return y; +} + /** * umr_access_vram - Access GPU mapped memory * @@ -754,7 +762,7 @@ int umr_access_vram(struct umr_asic *asic, uint32_t vmid, uint64_t address, uint break; } else { // otherwise subtract this vram size from the address and go to the next device - addr -= asic->config.xgmi.nodes[n].asic->config.vram_size; + addr -= round_up_pot(asic->config.xgmi.nodes[n].asic->config.vram_size); } } // now {asic, address} are the device and it's relative address |