diff options
author | Tom St Denis <tom.stdenis@amd.com> | 2019-03-11 10:51:17 -0400 |
---|---|---|
committer | Tom St Denis <tom.stdenis@amd.com> | 2019-03-11 10:53:01 -0400 |
commit | 8e8c82b0be50f8b44ed940bcd2847bbe99a2cf31 (patch) | |
tree | 4c1f46ead83c5342ad08a7532752dfd6b9402055 | |
parent | a0e550ebe28195477eeb98b8ad6cb2b3815c6931 (diff) |
apply mem/reg callbacks the first time vram access is performed on xgmi asics
Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
-rw-r--r-- | src/lib/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/lib/read_vram.c | 7 | ||||
-rw-r--r-- | src/lib/umr_apply_callbacks.c | 39 | ||||
-rw-r--r-- | src/umr.h | 4 |
4 files changed, 51 insertions, 0 deletions
diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index 514145a..18f394a 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -23,6 +23,7 @@ add_library(umrcore STATIC sq_cmd_halt_waves.c transfer_soc15.c umr_apply_bank_address.c + umr_apply_callbacks.c umr_read_ring_data.c umr_read_pm4_stream.c umr_read_sdma_stream.c diff --git a/src/lib/read_vram.c b/src/lib/read_vram.c index 2043852..c219953 100644 --- a/src/lib/read_vram.c +++ b/src/lib/read_vram.c @@ -704,6 +704,7 @@ invalid_page: return -1; } +/** round_up_pot -- Round up value to next power of two */ static uint64_t round_up_pot(uint64_t x) { uint64_t y = (64ULL * 1024 * 1024); // start at 64MiB @@ -754,6 +755,12 @@ int umr_access_vram(struct umr_asic *asic, uint32_t vmid, uint64_t address, uint if (asic->options.use_xgmi) { int n; uint64_t addr = address; + + // copy callbacks so that sysram/vram accesses + // go through callbacks when we use other nodes + if (!asic->config.xgmi.callbacks_applied) + umr_apply_callbacks(asic, &asic->mem_funcs, &asic->reg_funcs); + for (n = 0; asic->config.xgmi.nodes[n].asic; n++) { // if remaining address is within this nodes VRAM size use it if (addr < asic->config.xgmi.nodes[n].asic->config.vram_size) { diff --git a/src/lib/umr_apply_callbacks.c b/src/lib/umr_apply_callbacks.c new file mode 100644 index 0000000..7be0496 --- /dev/null +++ b/src/lib/umr_apply_callbacks.c @@ -0,0 +1,39 @@ +/* + * Copyright 2019 Advanced Micro Devices, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Authors: Tom St Denis <tom.stdenis@amd.com> + * + */ +#include "umr.h" + +void umr_apply_callbacks(struct umr_asic *asic, + struct umr_memory_access_funcs *mems, + struct umr_register_access_funcs *regs) +{ + int n; + + n = 0; + while (asic->config.xgmi.nodes[n].asic) { + asic->config.xgmi.nodes[n].asic->mem_funcs = *mems; + asic->config.xgmi.nodes[n++].asic->reg_funcs = *regs; + } + asic->config.xgmi.callbacks_applied = 1; +} @@ -313,6 +313,7 @@ struct umr_asic { uint64_t device_id, hive_id; + int callbacks_applied; struct { uint64_t node_id; int instance; @@ -911,3 +912,6 @@ int umr_access_linear_vram(struct umr_asic *asic, uint64_t address, uint32_t siz void umr_bitfield_default(struct umr_asic *asic, char *asicname, char *ipname, char *regname, char *bitname, int start, int stop, uint32_t value); int umr_scan_config(struct umr_asic *asic, int xgmi_scan); +void umr_apply_callbacks(struct umr_asic *asic, + struct umr_memory_access_funcs *mems, + struct umr_register_access_funcs *regs); |