Fix unconditional unmap in fmm_map_to_gpu_nodes

_fmm_unmap_from_gpu is called in fmm_map_to_gpu_nodes
to unmap buffer from nodes that is already mapped to
but not in the new map nodes list. Previously, the unmap
was called unconditionally even though the size of the
array to unmap is 0. This fixes the issue by calling
the unmap func only when the unmap array size is not 0.

Also releases the fmm_mutex on error returns

Change-Id: Iadd8383caf7ebb92f02618798c5efd138a352aaa
Signed-off-by: Oak Zeng <Oak.Zeng@amd.com>
Этот коммит содержится в:
Oak Zeng
2017-11-20 10:57:37 -05:00
родитель f06e887725
Коммит 061db45fe2
+10 -5
Просмотреть файл
@@ -3022,11 +3022,16 @@ HSAKMT_STATUS fmm_map_to_gpu_nodes(void *address, uint64_t size,
}
temp_node_id_array_size *= sizeof(uint32_t);
ret = _fmm_unmap_from_gpu(aperture, address,
temp_node_id_array, temp_node_id_array_size,
object);
if (ret != HSAKMT_STATUS_SUCCESS)
return ret;
if (temp_node_id_array_size) {
ret = _fmm_unmap_from_gpu(aperture, address,
temp_node_id_array,
temp_node_id_array_size,
object);
if (ret != HSAKMT_STATUS_SUCCESS) {
pthread_mutex_unlock(&aperture->fmm_mutex);
return ret;
}
}
}
retcode = _fmm_map_to_gpu_gtt(aperture, address, size, object,