libhsakmt: unmap from GPU error handling

If unmap from GPU return failed, for example, unmap user queue buffer
while queue is active, we should not free obj->mapped_node_id_array,
otherwise, the following unmap user queue buffer after queue is
destroyed still return failed.

Signed-off-by: Philip Yang <Philip.Yang@amd.com>
Change-Id: I32aeb18871c2e971d01900d92916c54680f5c9fa
This commit is contained in:
Philip Yang
2025-05-16 15:51:15 -04:00
committed by Yang, Philip
parent f853dda9ba
commit 3e6f51b715
+9 -8
View File
@@ -3339,15 +3339,16 @@ static int _fmm_unmap_from_gpu(manageable_aperture_t *aperture, void *address,
args.n_devices * sizeof(uint32_t));
ret = hsakmt_ioctl(hsakmt_kfd_fd, AMDKFD_IOC_UNMAP_MEMORY_FROM_GPU, &args);
remove_device_ids_from_mapped_array(object,
(uint32_t *)args.device_ids_array_ptr,
args.n_success * sizeof(uint32_t));
if (object->mapped_node_id_array)
free(object->mapped_node_id_array);
object->mapped_node_id_array = NULL;
object->mapping_count = 0;
if (!ret) {
remove_device_ids_from_mapped_array(object,
(uint32_t *)args.device_ids_array_ptr,
args.n_success * sizeof(uint32_t));
if (object->mapped_node_id_array)
free(object->mapped_node_id_array);
object->mapped_node_id_array = NULL;
object->mapping_count = 0;
}
out:
if (!obj)
pthread_mutex_unlock(&aperture->fmm_mutex);