Add debugging message on memory
Add pr_debug to all memory APIs and pr_err to some failure cases. Change-Id: I8b519a1228cc19e6c04118fd87432e7f48f3cbf9 Signed-off-by: Amber Lin <Amber.Lin@amd.com>
This commit is contained in:
@@ -2283,7 +2283,7 @@ static HSAKMT_STATUS dgpu_mem_init(uint32_t gpu_mem_id, void **base, void **limi
|
||||
munmap(ret_addr, len);
|
||||
}
|
||||
if (!ret_addr) {
|
||||
pr_err("Failed to reserve %uGB for SVM ...\n",
|
||||
pr_warn("Failed to reserve %uGB for SVM ...\n",
|
||||
(unsigned int)(len >> 30));
|
||||
continue;
|
||||
}
|
||||
@@ -2871,7 +2871,6 @@ HSAKMT_STATUS fmm_map_to_gpu_nodes(void *address, uint64_t size,
|
||||
if (!num_of_nodes || !nodes_to_map || !address)
|
||||
return HSAKMT_STATUS_INVALID_PARAMETER;
|
||||
|
||||
|
||||
/* Find object by address */
|
||||
if ((address >= svm.dgpu_aperture.base) &&
|
||||
(address <= svm.dgpu_aperture.limit))
|
||||
@@ -2882,7 +2881,6 @@ HSAKMT_STATUS fmm_map_to_gpu_nodes(void *address, uint64_t size,
|
||||
else {
|
||||
aperture = &svm.dgpu_aperture;
|
||||
userptr = true;
|
||||
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&aperture->fmm_mutex);
|
||||
|
||||
+59
-6
@@ -46,6 +46,9 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtSetMemoryPolicy(HSAuint32 Node,
|
||||
|
||||
CHECK_KFD_OPEN();
|
||||
|
||||
pr_debug("[%s] node %d; default %d; alternate %d\n",
|
||||
__func__, Node, DefaultPolicy, AlternatePolicy);
|
||||
|
||||
if (is_dgpu)
|
||||
/* This is a legacy API useful on Kaveri only. On dGPU
|
||||
* the alternate aperture is setup and used
|
||||
@@ -114,9 +117,13 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtAllocMemory(HSAuint32 PreferredNode,
|
||||
|
||||
CHECK_KFD_OPEN();
|
||||
|
||||
pr_debug("[%s] node %d\n", __func__, PreferredNode);
|
||||
|
||||
result = validate_nodeid(PreferredNode, &gpu_id);
|
||||
if (result != HSAKMT_STATUS_SUCCESS)
|
||||
if (result != HSAKMT_STATUS_SUCCESS) {
|
||||
pr_err("[%s] invalid node ID: %d\n", __func__, PreferredNode);
|
||||
return result;
|
||||
}
|
||||
|
||||
page_size = PageSizeFromFlags(MemFlags.ui32.PageSize);
|
||||
|
||||
@@ -127,8 +134,11 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtAllocMemory(HSAuint32 PreferredNode,
|
||||
*MemoryAddress = fmm_allocate_host(PreferredNode, SizeInBytes,
|
||||
MemFlags);
|
||||
|
||||
if (!(*MemoryAddress))
|
||||
if (!(*MemoryAddress)) {
|
||||
pr_err("[%s] failed to allocate %lu bytes from host\n",
|
||||
__func__, SizeInBytes);
|
||||
return HSAKMT_STATUS_ERROR;
|
||||
}
|
||||
|
||||
return HSAKMT_STATUS_SUCCESS;
|
||||
}
|
||||
@@ -136,16 +146,22 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtAllocMemory(HSAuint32 PreferredNode,
|
||||
if (gpu_id && MemFlags.ui32.NonPaged && !MemFlags.ui32.Scratch) {
|
||||
*MemoryAddress = fmm_allocate_device(gpu_id, SizeInBytes, MemFlags);
|
||||
|
||||
if (!(*MemoryAddress))
|
||||
if (!(*MemoryAddress)) {
|
||||
pr_err("[%s] failed to allocate %lu bytes from device\n",
|
||||
__func__, SizeInBytes);
|
||||
return HSAKMT_STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
return HSAKMT_STATUS_SUCCESS;
|
||||
}
|
||||
if (MemFlags.ui32.Scratch) {
|
||||
*MemoryAddress = fmm_allocate_scratch(gpu_id, SizeInBytes);
|
||||
|
||||
if (!(*MemoryAddress))
|
||||
if (!(*MemoryAddress)) {
|
||||
pr_err("[%s] failed to allocate %lu bytes from scratch\n",
|
||||
__func__, SizeInBytes);
|
||||
return HSAKMT_STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
return HSAKMT_STATUS_SUCCESS;
|
||||
}
|
||||
@@ -157,8 +173,11 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtAllocMemory(HSAuint32 PreferredNode,
|
||||
*MemoryAddress = fmm_allocate_host(PreferredNode, SizeInBytes,
|
||||
MemFlags);
|
||||
|
||||
if (!(*MemoryAddress))
|
||||
if (!(*MemoryAddress)) {
|
||||
pr_err("[%s] failed to allocate %lu bytes from paged\n",
|
||||
__func__, SizeInBytes);
|
||||
return HSAKMT_STATUS_ERROR;
|
||||
}
|
||||
|
||||
return HSAKMT_STATUS_SUCCESS;
|
||||
}
|
||||
@@ -171,6 +190,8 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtFreeMemory(void *MemoryAddress,
|
||||
{
|
||||
CHECK_KFD_OPEN();
|
||||
|
||||
pr_debug("[%s] address %p\n", __func__, MemoryAddress);
|
||||
|
||||
if (!MemoryAddress) {
|
||||
pr_err("FIXME: freeing NULL pointer\n");
|
||||
return HSAKMT_STATUS_ERROR;
|
||||
@@ -185,6 +206,8 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtRegisterMemory(void *MemoryAddress,
|
||||
{
|
||||
CHECK_KFD_OPEN();
|
||||
|
||||
pr_debug("[%s] address %p\n", __func__, MemoryAddress);
|
||||
|
||||
if (!is_dgpu)
|
||||
/* TODO: support mixed APU and dGPU configurations */
|
||||
return HSAKMT_STATUS_SUCCESS;
|
||||
@@ -202,6 +225,9 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtRegisterMemoryToNodes(void *MemoryAddress,
|
||||
uint32_t *gpu_id_array;
|
||||
HSAKMT_STATUS ret = HSAKMT_STATUS_SUCCESS;
|
||||
|
||||
pr_debug("[%s] address %p number of nodes %lu\n",
|
||||
__func__, MemoryAddress, NumberOfNodes);
|
||||
|
||||
if (!is_dgpu)
|
||||
/* TODO: support mixed APU and dGPU configurations */
|
||||
return HSAKMT_STATUS_NOT_SUPPORTED;
|
||||
@@ -229,6 +255,8 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtRegisterGraphicsHandleToNodes(HSAuint64 GraphicsRe
|
||||
uint32_t *gpu_id_array;
|
||||
HSAKMT_STATUS ret = HSAKMT_STATUS_SUCCESS;
|
||||
|
||||
pr_debug("[%s] number of nodes %lu\n", __func__, NumberOfNodes);
|
||||
|
||||
ret = validate_nodeid_array(&gpu_id_array,
|
||||
NumberOfNodes, NodeArray);
|
||||
|
||||
@@ -249,6 +277,8 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtShareMemory(void *MemoryAddress,
|
||||
{
|
||||
CHECK_KFD_OPEN();
|
||||
|
||||
pr_debug("[%s] address %p\n", __func__, MemoryAddress);
|
||||
|
||||
if (!SharedMemoryHandle)
|
||||
return HSAKMT_STATUS_INVALID_PARAMETER;
|
||||
|
||||
@@ -261,6 +291,8 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtRegisterSharedHandle(const HsaSharedMemoryHandle *
|
||||
{
|
||||
CHECK_KFD_OPEN();
|
||||
|
||||
pr_debug("[%s] handle %p\n", __func__, SharedMemoryHandle);
|
||||
|
||||
return hsaKmtRegisterSharedHandleToNodes(SharedMemoryHandle,
|
||||
MemoryAddress,
|
||||
SizeInBytes,
|
||||
@@ -279,6 +311,9 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtRegisterSharedHandleToNodes(const HsaSharedMemoryH
|
||||
uint32_t *gpu_id_array = NULL;
|
||||
HSAKMT_STATUS ret = HSAKMT_STATUS_SUCCESS;
|
||||
|
||||
pr_debug("[%s] handle %p number of nodes %lu\n",
|
||||
__func__, SharedMemoryHandle, NumberOfNodes);
|
||||
|
||||
if (!SharedMemoryHandle)
|
||||
return HSAKMT_STATUS_INVALID_PARAMETER;
|
||||
|
||||
@@ -323,6 +358,8 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtProcessVMRead(HSAuint32 Pid,
|
||||
{
|
||||
struct kfd_ioctl_cross_memory_copy_args args;
|
||||
|
||||
pr_debug("[%s]\n", __func__);
|
||||
|
||||
if (!LocalMemoryArray || !RemoteMemoryArray ||
|
||||
LocalMemoryArrayCount == 0 || RemoteMemoryArrayCount == 0)
|
||||
return HSAKMT_STATUS_ERROR;
|
||||
@@ -356,6 +393,8 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtProcessVMWrite(HSAuint32 Pid,
|
||||
{
|
||||
struct kfd_ioctl_cross_memory_copy_args args;
|
||||
|
||||
pr_debug("[%s]\n", __func__);
|
||||
|
||||
if (!LocalMemoryArray || !RemoteMemoryArray ||
|
||||
LocalMemoryArrayCount == 0 || RemoteMemoryArrayCount == 0)
|
||||
return HSAKMT_STATUS_ERROR;
|
||||
@@ -385,6 +424,8 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtDeregisterMemory(void *MemoryAddress)
|
||||
{
|
||||
CHECK_KFD_OPEN();
|
||||
|
||||
pr_debug("[%s] address %p\n", __func__, MemoryAddress);
|
||||
|
||||
return fmm_deregister_memory(MemoryAddress);
|
||||
}
|
||||
|
||||
@@ -394,6 +435,8 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtMapMemoryToGPU(void *MemoryAddress,
|
||||
{
|
||||
CHECK_KFD_OPEN();
|
||||
|
||||
pr_debug("[%s] address %p\n", __func__, MemoryAddress);
|
||||
|
||||
if (!MemoryAddress) {
|
||||
pr_err("FIXME: mapping NULL pointer\n");
|
||||
return HSAKMT_STATUS_ERROR;
|
||||
@@ -418,6 +461,9 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtMapMemoryToGPUNodes(void *MemoryAddress,
|
||||
uint32_t *gpu_id_array;
|
||||
HSAKMT_STATUS ret;
|
||||
|
||||
pr_debug("[%s] address %p number of nodes %lu\n",
|
||||
__func__, MemoryAddress, NumberOfNodes);
|
||||
|
||||
if (!MemoryAddress) {
|
||||
pr_err("FIXME: mapping NULL pointer\n");
|
||||
return HSAKMT_STATUS_ERROR;
|
||||
@@ -446,6 +492,8 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtUnmapMemoryToGPU(void *MemoryAddress)
|
||||
{
|
||||
CHECK_KFD_OPEN();
|
||||
|
||||
pr_debug("[%s] address %p\n", __func__, MemoryAddress);
|
||||
|
||||
if (!MemoryAddress) {
|
||||
/* Workaround for runtime bug */
|
||||
pr_err("FIXME: Unmapping NULL pointer\n");
|
||||
@@ -477,7 +525,6 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtUnmapGraphicHandle(HSAuint32 NodeId,
|
||||
HSAuint64 FlatMemoryAddress,
|
||||
HSAuint64 SizeInBytes)
|
||||
{
|
||||
|
||||
return hsaKmtUnmapMemoryToGPU(PORT_UINT64_TO_VPTR(FlatMemoryAddress));
|
||||
}
|
||||
|
||||
@@ -487,6 +534,8 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtGetTileConfig(HSAuint32 NodeId, HsaGpuTileConfig *
|
||||
uint32_t gpu_id;
|
||||
HSAKMT_STATUS result;
|
||||
|
||||
pr_debug("[%s] node %d\n", __func__, NodeId);
|
||||
|
||||
result = validate_nodeid(NodeId, &gpu_id);
|
||||
if (result != HSAKMT_STATUS_SUCCESS)
|
||||
return result;
|
||||
@@ -514,6 +563,8 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtGetTileConfig(HSAuint32 NodeId, HsaGpuTileConfig *
|
||||
HSAKMT_STATUS HSAKMTAPI hsaKmtQueryPointerInfo(const void *Pointer,
|
||||
HsaPointerInfo *PointerInfo)
|
||||
{
|
||||
pr_debug("[%s] pointer %p\n", __func__, Pointer);
|
||||
|
||||
if (!PointerInfo)
|
||||
return HSAKMT_STATUS_INVALID_PARAMETER;
|
||||
return fmm_get_mem_info(Pointer, PointerInfo);
|
||||
@@ -522,5 +573,7 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtQueryPointerInfo(const void *Pointer,
|
||||
HSAKMT_STATUS HSAKMTAPI hsaKmtSetMemoryUserData(const void *Pointer,
|
||||
void *UserData)
|
||||
{
|
||||
pr_debug("[%s] pointer %p\n", __func__, Pointer);
|
||||
|
||||
return fmm_set_mem_user_data(Pointer, UserData);
|
||||
}
|
||||
|
||||
Referens i nytt ärende
Block a user