2
0

libhsakmt: Fix and simplify debug_get_reg_status

The NULL pointer check was the only way for that function to fail. And it
was done after the pointer was accessed. Simplify this by just returning
the result as a return value instead of using a pointer as output
parameter. This way the function can never fail and the caller doesn't
need to do any error handling.

Declare the function in libhsakmt.h instead of duplicating the
declaration in fmm.c.

Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
Change-Id: I91b90d66166fd3b5cdc47c73a9bbc369c45b51fe
Este cometimento está contido em:
Felix Kuehling
2022-11-25 13:53:31 -05:00
ascendente 8a746bdaed
cometimento 2d53430ce3
3 ficheiros modificados com 8 adições e 15 eliminações
+5 -12
Ver ficheiro
@@ -33,8 +33,6 @@
static bool *is_device_debugged;
int debug_get_reg_status(uint32_t node_id, bool *is_debugged);
HSAKMT_STATUS init_device_debugging_memory(unsigned int NumNodes)
{
unsigned int i;
@@ -57,6 +55,11 @@ void destroy_device_debugging_memory(void)
}
}
bool debug_get_reg_status(uint32_t node_id)
{
return is_device_debugged[node_id];
}
HSAKMT_STATUS HSAKMTAPI hsaKmtDbgRegister(HSAuint32 NodeId)
{
HSAKMT_STATUS result;
@@ -262,16 +265,6 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtDbgAddressWatch(HSAuint32 NodeId,
return HSAKMT_STATUS_SUCCESS;
}
int debug_get_reg_status(uint32_t node_id, bool *is_debugged)
{
*is_debugged = NULL;
if (!is_device_debugged)
return -1;
*is_debugged = is_device_debugged[node_id];
return 0;
}
/* Get the major and minor version of the kernel debugger support. */
HSAKMT_STATUS
HSAKMTAPI
+2 -3
Ver ficheiro
@@ -296,7 +296,6 @@ static inline HsaSharedMemoryHandle *to_hsa_shared_memory_handle(
return (HsaSharedMemoryHandle *)SharedMemoryStruct;
}
extern int debug_get_reg_status(uint32_t node_id, bool *is_debugged);
static int __fmm_release(vm_object_t *object, manageable_aperture_t *aperture);
static int _fmm_unmap_from_gpu_scratch(uint32_t gpu_id,
manageable_aperture_t *aperture,
@@ -2841,9 +2840,9 @@ static int _fmm_map_to_gpu_scratch(uint32_t gpu_id, manageable_aperture_t *apert
VOID_PTR_ADD(address, size - 1) > aperture->limit)
return -1;
ret = debug_get_reg_status(gpu_mem[gpu_mem_id].node_id, &is_debugger);
is_debugger = debug_get_reg_status(gpu_mem[gpu_mem_id].node_id);
/* allocate object within the scratch backing aperture */
if (!ret && !is_debugger) {
if (!is_debugger) {
obj = fmm_allocate_memory_object(
gpu_id, address, size, aperture, &mmap_offset,
KFD_IOC_ALLOC_MEM_FLAGS_VRAM |
+1
Ver ficheiro
@@ -191,6 +191,7 @@ HSAKMT_STATUS init_process_doorbells(unsigned int NumNodes);
void destroy_process_doorbells(void);
HSAKMT_STATUS init_device_debugging_memory(unsigned int NumNodes);
void destroy_device_debugging_memory(void);
bool debug_get_reg_status(uint32_t node_id);
HSAKMT_STATUS init_counter_props(unsigned int NumNodes);
void destroy_counter_props(void);
uint32_t *convert_queue_ids(HSAuint32 NumQueues, HSA_QUEUEID *Queues);