-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from no92/misc-fixes
Miscellaneous fixes
- Loading branch information
Showing
9 changed files
with
93 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,22 @@ | ||
#include "gtt.h" | ||
|
||
#include <lil/imports.h> | ||
|
||
#include "src/helpers.h" | ||
#include "src/coffee_lake/gtt.h" | ||
|
||
#define GTT_HAW 39 | ||
|
||
void lil_cfl_vmem_clear(LilGpu* gpu) { | ||
for (size_t i = 0; i < (gpu->gtt_size >> 12); i++) { | ||
volatile uint64_t* gtt = (uint64_t*)(gpu->gtt_address + i * 8); | ||
*gtt = 0; | ||
GTT64_ENTRY(gpu, i << 12) = 0; | ||
} | ||
} | ||
|
||
void lil_cfl_vmem_map(LilGpu* gpu, uint64_t host, GpuAddr gpu_addr) { | ||
if ((host & ~0xFFFFFFFFFF) != 0) | ||
lil_panic("Coffee Lake GPUs only supports 40-bit host addresses"); // TODO: Servers support 46-bits (At least according to the Skylake PRMs) support this | ||
// TODO: Servers support 46-bits (At least according to the Skylake PRMs); support this | ||
uint64_t mask = ((1UL << GTT_HAW) - 1) & ~0xFFF; | ||
|
||
if ((host & ~mask) != 0) | ||
lil_panic("Coffee Lake GPUs only support " STRINGIFY(GTT_HAW) "-bit host addresses"); | ||
|
||
*(volatile uint64_t*)(gpu->gtt_address + (gpu_addr / 0x1000) * 8) = host | 1; // Present | ||
GTT64_ENTRY(gpu, gpu_addr) = (host & mask) | GTT_PAGE_PRESENT; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#pragma once | ||
|
||
#define GTT_PAGE_PRESENT 1 | ||
|
||
#define GTT64_ENTRY(gpu, gpu_addr) (*(volatile uint64_t *) ((gpu)->gtt_address + ((gpu_addr) >> 12) * 8)) | ||
#define GTT32_ENTRY(gpu, gpu_addr) (*(volatile uint32_t *) ((gpu)->gtt_address + ((gpu_addr) >> 12) * 4)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#pragma once | ||
|
||
#define STRINGIFY(a) STRINGIFY_(a) | ||
#define STRINGIFY_(a) #a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
#include "gtt.h" | ||
|
||
#include <lil/imports.h> | ||
|
||
#include "src/gtt.h" | ||
#include "src/ivy_bridge/gtt.h" | ||
|
||
void lil_ivb_vmem_clear(LilGpu* gpu) { | ||
for (size_t i = 0; i < (gpu->gtt_size >> 12); i++) { | ||
volatile uint32_t* gtt = (uint32_t*)(gpu->gtt_address + i * 4); | ||
*gtt = 0; | ||
GTT32_ENTRY(gpu, i << 12) = 0; | ||
} | ||
} | ||
|
||
void lil_ivb_vmem_map(LilGpu* gpu, uint64_t host, GpuAddr gpu_addr) { | ||
if ((host & ~0xFFFFFFFFFF) != 0) | ||
lil_panic("Ivy Bridge GPU only supports 40-bit host addresses"); | ||
|
||
*(volatile uint32_t*)(gpu->gtt_address + (gpu_addr / 0x1000) * 4) = host | (((host >> 32) & 0xFF) << 4) | 0b110 | 1; // MLC/LLC Caching, Present | ||
GTT32_ENTRY(gpu, gpu_addr) = host | (((host >> 32) & 0xFF) << 4) | GTT_IVB_CACHE_MLC_LLC | GTT_PAGE_PRESENT; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters