diff --git a/src/fmm.c b/src/fmm.c index 2264e6fa9d..32562f363e 100644 --- a/src/fmm.c +++ b/src/fmm.c @@ -767,8 +767,8 @@ bool fmm_is_inside_some_aperture(void *address) #ifdef DEBUG_PRINT_APERTURE static void aperture_print(aperture_t *app) { - printf("\t Base: %p\n", app->base); - printf("\t Limit: %p\n", app->limit); + pr_info("\t Base: %p\n", app->base); + pr_info("\t Limit: %p\n", app->limit); } static void manageable_aperture_print(manageable_aperture_t *app) @@ -776,16 +776,16 @@ static void manageable_aperture_print(manageable_aperture_t *app) vm_area_t *cur = app->vm_ranges; vm_object_t *object = app->vm_objects; - printf("\t Base: %p\n", app->base); - printf("\t Limit: %p\n", app->limit); - printf("\t Ranges:\n"); + pr_info("\t Base: %p\n", app->base); + pr_info("\t Limit: %p\n", app->limit); + pr_info("\t Ranges:\n"); while (cur) { - printf("\t\t Range [%p - %p]\n", cur->start, cur->end); + pr_info("\t\t Range [%p - %p]\n", cur->start, cur->end); cur = cur->next; }; - printf("\t Objects:\n"); + pr_info("\t Objects:\n"); while (object) { - printf("\t\t Object [%p - %" PRIu64 "]\n", + pr_info("\t\t Object [%p - %" PRIu64 "]\n", object->start, object->size); object = object->next; }; @@ -796,19 +796,19 @@ void fmm_print(uint32_t gpu_id) int32_t gpu_mem_id = gpu_mem_find_by_gpu_id(gpu_id); if (gpu_mem_id >= 0) { /* Found */ - printf("LDS aperture:\n"); + pr_info("LDS aperture:\n"); aperture_print(&gpu_mem[gpu_mem_id].lds_aperture); - printf("GPUVM aperture:\n"); + pr_info("GPUVM aperture:\n"); manageable_aperture_print(&gpu_mem[gpu_mem_id].gpuvm_aperture); - printf("Scratch aperture:\n"); + pr_info("Scratch aperture:\n"); manageable_aperture_print(&gpu_mem[gpu_mem_id].scratch_aperture); - printf("Scratch backing memory:\n"); + pr_info("Scratch backing memory:\n"); manageable_aperture_print(&gpu_mem[gpu_mem_id].scratch_physical); } - printf("dGPU aperture:\n"); + pr_info("dGPU aperture:\n"); manageable_aperture_print(&svm.dgpu_aperture); - printf("dGPU alt aperture:\n"); + pr_info("dGPU alt aperture:\n"); manageable_aperture_print(&svm.dgpu_alt_aperture); } @@ -1533,7 +1533,7 @@ HSAKMT_STATUS fmm_init_process_apertures(unsigned int NumNodes) KFD_IOC_CACHE_POLICY_COHERENT, alt_base, alt_size); if (err != 0) { - fprintf(stderr, "Error! Failed to set alt aperture for GPU [0x%x]\n", + pr_err("Failed to set alt aperture for GPU [0x%x]\n", gpu_mem[gpu_mem_id].gpu_id); ret = HSAKMT_STATUS_ERROR; } @@ -1911,10 +1911,10 @@ static void print_device_id_array(uint32_t *device_id_array, uint32_t device_id_ #ifdef DEBUG_PRINT_APERTURE device_id_array_size /= sizeof(uint32_t); - printf("device id array size %d\n", device_id_array_size); + pr_info("device id array size %d\n", device_id_array_size); for (uint32_t i = 0 ; i < device_id_array_size; i++) - printf("%d . 0x%x\n", (i+1), device_id_array[i]); + pr_info("%d . 0x%x\n", (i+1), device_id_array[i]); #endif } @@ -2191,8 +2191,7 @@ static HSAKMT_STATUS dgpu_mem_init(uint32_t gpu_mem_id, void **base, void **limi ret = get_dgpu_vm_limit(&max_vm_limit_in_gb); if (ret != HSAKMT_STATUS_SUCCESS) { - fprintf(stderr, - "Unable to find vm_size for dGPU, assuming 64GB.\n"); + pr_err("Unable to find vm_size for dGPU, assuming 64GB.\n"); max_vm_limit_in_gb = 64; } max_vm_limit = ((HSAuint64)max_vm_limit_in_gb << 30) - 1; @@ -2216,15 +2215,13 @@ static HSAKMT_STATUS dgpu_mem_init(uint32_t gpu_mem_id, void **base, void **limi munmap(ret_addr, len); } if (!ret_addr) { - fprintf(stderr, - "Failed to reserve %uGB for SVM ...\n", + pr_err("Failed to reserve %uGB for SVM ...\n", (unsigned int)(len >> 30)); continue; } if ((HSAuint64)ret_addr + min_vm_size - 1 > max_vm_limit) { /* addressable size is less than the minimum */ - fprintf(stderr, - "Got %uGB for SVM at %p with only %dGB usable ...\n", + pr_warn("Got %uGB for SVM at %p with only %dGB usable ...\n", (unsigned int)(len >> 30), ret_addr, (int)(((HSAint64)max_vm_limit - (HSAint64)ret_addr) >> 30)); @@ -2237,8 +2234,7 @@ static HSAKMT_STATUS dgpu_mem_init(uint32_t gpu_mem_id, void **base, void **limi } if (!found) { - fprintf(stderr, - "Failed to reserve SVM address range. Giving up.\n"); + pr_err("Failed to reserve SVM address range. Giving up.\n"); return HSAKMT_STATUS_ERROR; } @@ -2421,8 +2417,7 @@ HSAKMT_STATUS fmm_register_memory(void *address, uint64_t size_in_bytes, if ((gpu_id_array_size != object->registered_device_id_array_size) || memcmp(object->registered_device_id_array, gpu_id_array, gpu_id_array_size)) { - fprintf(stderr, - "Error. Changing nodes in a registered addr.\n"); + pr_err("Cannot change nodes in a registered addr.\n"); return HSAKMT_STATUS_MEMORY_ALREADY_REGISTERED; } else return HSAKMT_STATUS_SUCCESS; diff --git a/src/memory.c b/src/memory.c index c4785b9ec1..fcf201a3ad 100644 --- a/src/memory.c +++ b/src/memory.c @@ -172,7 +172,7 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtFreeMemory(void *MemoryAddress, CHECK_KFD_OPEN(); if (!MemoryAddress) { - fprintf(stderr, "FIXME: freeing NULL pointer\n"); + pr_err("FIXME: freeing NULL pointer\n"); return HSAKMT_STATUS_ERROR; } @@ -308,7 +308,7 @@ static uint64_t convertHsaToKfdRange(HsaMemoryRange *HsaRange) { if (sizeof(struct kfd_memory_range) != sizeof(HsaMemoryRange)) { - fprintf(stderr, "Struct size mismatch in thunk. Cannot cast Hsa Range to KFD IOCTL range\n"); + pr_err("Struct size mismatch in thunk. Cannot cast Hsa Range to KFD IOCTL range\n"); return 0; } return (uint64_t) HsaRange; @@ -395,7 +395,7 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtMapMemoryToGPU(void *MemoryAddress, CHECK_KFD_OPEN(); if (!MemoryAddress) { - fprintf(stderr, "FIXME: mapping NULL pointer\n"); + pr_err("FIXME: mapping NULL pointer\n"); return HSAKMT_STATUS_ERROR; } @@ -419,7 +419,7 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtMapMemoryToGPUNodes(void *MemoryAddress, HSAKMT_STATUS ret; if (!MemoryAddress) { - fprintf(stderr, "FIXME: mapping NULL pointer\n"); + pr_err("FIXME: mapping NULL pointer\n"); return HSAKMT_STATUS_ERROR; } @@ -443,7 +443,7 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtUnmapMemoryToGPU(void *MemoryAddress) if (!MemoryAddress) { /* Workaround for runtime bug */ - fprintf(stderr, "FIXME: Unmapping NULL pointer\n"); + pr_err("FIXME: Unmapping NULL pointer\n"); return HSAKMT_STATUS_SUCCESS; } diff --git a/src/openclose.c b/src/openclose.c index 204b31c360..3a1a17b941 100644 --- a/src/openclose.c +++ b/src/openclose.c @@ -141,7 +141,7 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtOpenKFD(void) goto init_doorbell_failed; if (init_device_debugging_memory(sys_props.NumNodes) != HSAKMT_STATUS_SUCCESS) - printf("Insufficient Memory. Debugging unavailable\n"); + pr_warn("Insufficient Memory. Debugging unavailable\n"); mask = umask(0); /* save the current umask */ /* We don't want the existing umask to mask out S_IWOTH */ @@ -151,11 +151,10 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtOpenKFD(void) 0666); umask(mask); /* restore the original umask */ if (amd_hsa_thunk_lock_fd < 0) - fprintf(stderr, - "Profiling of privileged counters is not available\n"); + pr_warn("Profiling of privileged counters is not available\n"); if (init_counter_props(sys_props.NumNodes) != HSAKMT_STATUS_SUCCESS) - fprintf(stderr, "Profiling is not available\n"); + pr_warn("Profiling is not available\n"); } else { kfd_open_count++; result = HSAKMT_STATUS_SUCCESS; diff --git a/src/perfctr.c b/src/perfctr.c index f54599cd46..29801a686f 100644 --- a/src/perfctr.c +++ b/src/perfctr.c @@ -385,8 +385,7 @@ static HSAKMT_STATUS open_perf_event_fd(struct perf_trace_block *block) return HSAKMT_STATUS_INVALID_HANDLE; if (getuid()) { - fprintf(stderr, - "Error. Must be root to open perf_event.\n"); + pr_err("Must be root to open perf_event.\n"); return HSAKMT_STATUS_ERROR; } @@ -560,7 +559,7 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtPmcRegisterTrace(HSAuint32 NodeId, return HSAKMT_STATUS_INVALID_NODE_UNIT; if (NumberOfCounters > MAX_COUNTERS) { - fprintf(stderr, "Error: MAX_COUNTERS is too small for %d.\n", + pr_err("MAX_COUNTERS is too small for %d.\n", NumberOfCounters); return HSAKMT_STATUS_NO_MEMORY; } @@ -588,11 +587,11 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtPmcRegisterTrace(HSAuint32 NodeId, continue; concurrent_limit = get_block_concurrent_limit(NodeId, i); if (!concurrent_limit) { - fprintf(stderr, "Invalid block ID: %d\n", i); + pr_err("Invalid block ID: %d\n", i); return HSAKMT_STATUS_INVALID_PARAMETER; } if (num_counters[i] > concurrent_limit) { - fprintf(stderr, "Counters exceed the limit.\n"); + pr_err("Counters exceed the limit.\n"); return HSAKMT_STATUS_INVALID_PARAMETER; } num_blocks++; diff --git a/src/pmc_table.c b/src/pmc_table.c index 50ff81a521..e4c81f2949 100644 --- a/src/pmc_table.c +++ b/src/pmc_table.c @@ -1628,7 +1628,7 @@ static HSAKMT_STATUS alloc_pmc_blocks_iommu(void) continue; if (snprintf(path, len, "%s/%s", sysfs_amdiommu_event_path, dent->d_name) >= len) { - fprintf(stderr, "Increase path length.\n"); + pr_err("Increase path length.\n"); ret = HSAKMT_STATUS_NO_MEMORY; goto out; } @@ -1644,8 +1644,7 @@ static HSAKMT_STATUS alloc_pmc_blocks_iommu(void) } if (num > max_counter_id) /* This should never happen. If it does, check IOMMU driver. */ - fprintf(stderr, - "Error: max_counter_id %d is set too small.\n", + pr_err("max_counter_id %d is set too small.\n", max_counter_id); else { counter_id[num] = 1; @@ -1671,7 +1670,7 @@ static HSAKMT_STATUS alloc_pmc_blocks_iommu(void) "/sys/devices/virtual/kfd/kfd/topology/nodes", 0, /* IOMMU is in node 0. Change this if NUMA is introduced to APU. */ "perf/iommu/max_concurrent") >= len) { - fprintf(stderr, "Increase path length\n"); + pr_err("Increase path length\n"); ret = HSAKMT_STATUS_NO_MEMORY; goto out; }; diff --git a/src/topology.c b/src/topology.c index 2456a9c197..40d3316661 100644 --- a/src/topology.c +++ b/src/topology.c @@ -593,7 +593,7 @@ static HSAKMT_STATUS topology_get_cpu_model_name(HsaNodeProperties *props, fd = fopen(PROC_CPUINFO_PATH, "r"); if (!fd) { - printf("Failed to open [%s]. Unable to get CPU Model Name", + pr_err("Failed to open [%s]. Unable to get CPU Model Name", PROC_CPUINFO_PATH); return HSAKMT_STATUS_ERROR; } @@ -674,7 +674,7 @@ static void topology_set_processor_vendor(void) fd = fopen(PROC_CPUINFO_PATH, "r"); if (!fd) { - printf("Failed to open [%s]. Setting Processor Vendor to %s", + pr_err("Failed to open [%s]. Setting Processor Vendor to %s", PROC_CPUINFO_PATH, supported_processor_vendor_name[GENUINE_INTEL]); processor_vendor = GENUINE_INTEL; return; @@ -694,7 +694,7 @@ static void topology_set_processor_vendor(void) } } fclose(fd); - printf("Failed to get Processor Vendor. Setting to %s", + pr_err("Failed to get Processor Vendor. Setting to %s", supported_processor_vendor_name[GENUINE_INTEL]); processor_vendor = GENUINE_INTEL; } @@ -814,8 +814,7 @@ HSAKMT_STATUS topology_sysfs_get_node_props(uint32_t node_id, if ((sscanf(envvar, "%u.%u.%u%c", &major, &minor, &step, &dummy) != 3) || (major > 63 || minor > 255 || step > 255)) { - fprintf(stderr, - "HSA_OVERRIDE_GFX_VERSION %s is invalid\n", + pr_err("HSA_OVERRIDE_GFX_VERSION %s is invalid\n", envvar); ret = HSAKMT_STATUS_ERROR; goto err; @@ -840,7 +839,7 @@ HSAKMT_STATUS topology_sysfs_get_node_props(uint32_t node_id, /* Is APU node */ ret = topology_get_cpu_model_name(props, true); if (ret != HSAKMT_STATUS_SUCCESS) { - printf("Failed to get APU Model Name from %s\n", PROC_CPUINFO_PATH); + pr_err("Failed to get APU Model Name from %s\n", PROC_CPUINFO_PATH); ret = HSAKMT_STATUS_SUCCESS; /* No hard error, continue regardless */ } } else { @@ -859,7 +858,7 @@ HSAKMT_STATUS topology_sysfs_get_node_props(uint32_t node_id, if (!props->NumFComputeCores || !props->DeviceId) { ret = topology_get_cpu_model_name(props, false); if (ret != HSAKMT_STATUS_SUCCESS) { - printf("Failed to get CPU Model Name from %s\n", PROC_CPUINFO_PATH); + pr_err("Failed to get CPU Model Name from %s\n", PROC_CPUINFO_PATH); ret = HSAKMT_STATUS_SUCCESS; /* No hard error, continue regardless */ } } else { @@ -1005,7 +1004,7 @@ static HSAKMT_STATUS topology_create_temp_cpu_cache_list(void **temp_cpu_ci_list */ CPU_ZERO(&orig_cpuset); if (sched_getaffinity(0, sizeof(cpu_set_t), &orig_cpuset) != 0) { - printf("Failed to get CPU affinity\n"); + pr_err("Failed to get CPU affinity\n"); free(p_temp_cpu_ci_list); ret = HSAKMT_STATUS_ERROR; goto exit; @@ -1272,19 +1271,18 @@ static HsaIoLinkProperties *topology_get_free_io_link_slot_for_node(uint32_t nod HsaIoLinkProperties *props; if (node_id >= sys_props->NumNodes) { - fprintf(stderr, "Invalid node [%d]\n", node_id); + pr_err("Invalid node [%d]\n", node_id); return NULL; } props = nodes[node_id].link; if (!props) { - fprintf(stderr, "No io_link reported for Node [%d]\n", node_id); + pr_err("No io_link reported for Node [%d]\n", node_id); return NULL; } if (nodes[node_id].node.NumIOLinks >= sys_props->NumNodes - 1) { - fprintf(stderr, "No more space for io_link for Node [%d]\n", - node_id); + pr_err("No more space for io_link for Node [%d]\n", node_id); return NULL; } @@ -1470,8 +1468,7 @@ static void topology_create_indirect_gpu_links(const HsaSystemProperties *sys_pr continue; if (topology_add_io_link_for_node(i, sys_props, nodes, type, j, weight, true) != HSAKMT_STATUS_SUCCESS) - fprintf(stderr, - "Fail to add IO link %d->%d\n", i, j); + pr_err("Fail to add IO link %d->%d\n", i, j); } } } @@ -1611,7 +1608,7 @@ HSAKMT_STATUS topology_drop_snapshot(void) HSAKMT_STATUS err; if (!!_system != !!node) { - printf("Probable inconsistency?\n"); + pr_warn("Probably inconsistency?\n"); err = HSAKMT_STATUS_SUCCESS; goto out; }