diff options
author | Joshua Bakita <jbakita@cs.unc.edu> | 2024-04-13 14:19:10 -0400 |
---|---|---|
committer | Joshua Bakita <jbakita@cs.unc.edu> | 2024-04-13 14:19:10 -0400 |
commit | 6c8c5c70a885395afae4e7dd49d6abd9c470bc9e (patch) | |
tree | dd0440345208df6f1d3c35e5c9813ec296358ad5 /nvdebug.h | |
parent | 7cfa24cebeaf144b446d07e15fb25e78bb14841e (diff) |
Add /proc/gpu#/local_memory API for getting VRAM size
Diffstat (limited to 'nvdebug.h')
-rw-r--r-- | nvdebug.h | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -1145,7 +1145,34 @@ typedef union { | |||
1145 | } page_tbl_entry_v0_t; | 1145 | } page_tbl_entry_v0_t; |
1146 | */ | 1146 | */ |
1147 | 1147 | ||
1148 | /* VRAM Information | ||
1148 | 1149 | ||
1150 | If ECC is disabled: | ||
1151 | bytes = (magnitude << scale) * 1024 * 1024 | ||
1152 | If ECC is enabled: | ||
1153 | bytes = ((magnitude << scale) * 1024 * 1024) / 16 * 15 | ||
1154 | |||
1155 | Support: Pascal, Volta, Turing, [more?] | ||
1156 | */ | ||
1157 | #define NV_FB_MMU_LOCAL_MEMORY_RANGE 0x00100ce0 | ||
1158 | typedef union { | ||
1159 | struct { | ||
1160 | uint32_t scale:4; | ||
1161 | uint32_t mag:6; | ||
1162 | uint32_t:20; | ||
1163 | bool is_ecc:1; | ||
1164 | uint32_t:1; | ||
1165 | } __attribute__((packed)); | ||
1166 | uint32_t raw; | ||
1167 | } memory_range_t; | ||
1168 | |||
1169 | static inline uint64_t memory_range_to_bytes(memory_range_t range) { | ||
1170 | // ECC takes a byte out of available memory for parity data | ||
1171 | if (range.is_ecc) | ||
1172 | return ((range.mag << range.scale) * 1024ull * 1024ull) / 16 * 15; | ||
1173 | else | ||
1174 | return (range.mag << range.scale) * 1024ull * 1024ull; | ||
1175 | } | ||
1149 | 1176 | ||
1150 | /* Begin nvdebug types and functions */ | 1177 | /* Begin nvdebug types and functions */ |
1151 | 1178 | ||