libhsakmt: A+A: Mark buffers accessed by CP as UC

This change is for the A+A bring-up branch as it needs to made more
generic to handle all ASICs.

For A+A all the system buffers are mapped as NC (non coherent) unless
explicitly marked as UC (uncached). The coherency is then expected to be
handled by shader by explicitly using acquire/release instructions.

However, CP doesn't have same feature. The buffers used by CP thus have
to UC. For now queue buffer and Signal handler memory is marked as UC.

This change shouldn't affect other ASICs since Uncached flag is not used
in those. However, this change still need to be made more generic.

Signed-off-by: Harish Kasiviswanathan <Harish.Kasiviswanathan@amd.com>
Change-Id: I56c37a809913f7f08c94d01b0572d0f4864939aa
This commit is contained in:
Harish Kasiviswanathan
2020-12-30 18:47:48 -05:00
committato da Kent Russell
parent 4cf11c3a7e
commit 7c05c5240f
3 ha cambiato i file con 12 aggiunte e 8 eliminazioni
+1 -1
Vedi File
@@ -76,7 +76,7 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtCreateEvent(HsaEventDescriptor *EventDesc,
if (is_dgpu && !events_page) {
events_page = allocate_exec_aligned_memory_gpu(
KFD_SIGNAL_EVENT_LIMIT * 8, PAGE_SIZE, 0, true, false);
KFD_SIGNAL_EVENT_LIMIT * 8, PAGE_SIZE, 0, true, false, true);
if (!events_page) {
pthread_mutex_unlock(&hsakmt_mutex);
return HSAKMT_STATUS_ERROR;
+1 -1
Vedi File
@@ -169,7 +169,7 @@ HSAuint32 PageSizeFromFlags(unsigned int pageSizeFlags);
void* allocate_exec_aligned_memory_gpu(uint32_t size, uint32_t align,
uint32_t NodeId, bool NonPaged,
bool DeviceLocal);
bool DeviceLocal, bool Uncached);
void free_exec_aligned_memory_gpu(void *addr, uint32_t size, uint32_t align);
HSAKMT_STATUS init_process_doorbells(unsigned int NumNodes);
void destroy_process_doorbells(void);
+10 -6
Vedi File
@@ -455,7 +455,8 @@ static bool update_ctx_save_restore_size(uint32_t nodeid, struct queue *q)
void *allocate_exec_aligned_memory_gpu(uint32_t size, uint32_t align,
uint32_t NodeId, bool nonPaged,
bool DeviceLocal)
bool DeviceLocal,
bool Uncached)
{
void *mem;
HSAuint64 gpu_va;
@@ -469,6 +470,7 @@ void *allocate_exec_aligned_memory_gpu(uint32_t size, uint32_t align,
flags.ui32.NonPaged = nonPaged;
flags.ui32.PageSize = HSA_PAGE_SIZE_4KB;
flags.ui32.CoarseGrain = DeviceLocal;
flags.ui32.Uncached = Uncached;
/* Get the closest cpu_id to GPU NodeId for system memory allocation
* nonPaged=1 system memory allocation uses GTT path
@@ -518,11 +520,13 @@ void free_exec_aligned_memory_gpu(void *addr, uint32_t size, uint32_t align)
static void *allocate_exec_aligned_memory(uint32_t size,
bool use_ats,
uint32_t NodeId,
bool DeviceLocal)
bool DeviceLocal,
bool Uncached)
{
if (!use_ats)
return allocate_exec_aligned_memory_gpu(size, PAGE_SIZE, NodeId,
DeviceLocal, DeviceLocal);
DeviceLocal, DeviceLocal,
Uncached);
return allocate_exec_aligned_memory_cpu(size);
}
@@ -564,7 +568,7 @@ static int handle_concrete_asic(struct queue *q,
q->eop_buffer =
allocate_exec_aligned_memory(q->dev_info->eop_buffer_size,
q->use_ats,
NodeId, true);
NodeId, true, /* Unused for VRAM */false);
if (!q->eop_buffer)
return HSAKMT_STATUS_NO_MEMORY;
@@ -582,7 +586,7 @@ static int handle_concrete_asic(struct queue *q,
q->ctx_save_restore =
allocate_exec_aligned_memory(q->ctx_save_restore_size,
q->use_ats,
NodeId, false);
NodeId, false, false);
if (!q->ctx_save_restore)
return HSAKMT_STATUS_NO_MEMORY;
@@ -639,7 +643,7 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtCreateQueue(HSAuint32 NodeId,
struct queue *q = allocate_exec_aligned_memory(sizeof(*q),
use_ats,
NodeId, false);
NodeId, false, true);
if (!q)
return HSAKMT_STATUS_NO_MEMORY;