From 838f639b738848c1bd68f26fd9ed09f3e4cf29b1 Mon Sep 17 00:00:00 2001 From: Felix Kuehling Date: Mon, 17 Jul 2017 11:16:10 -0400 Subject: [PATCH] Align imported graphics buffers Imported graphics buffers are most likely images. Align them for tiled image access. 64KB seems to do the trick. This fixes VM faults with OpenCL graphics interop. Change-Id: I7f60e205d93fff9407e0d00d3dbb02cc4990b863 Signed-off-by: Felix Kuehling [ROCm/ROCR-Runtime commit: dc2c52be78b2f3f9a93fb75b9f654e6e359f6dc6] --- projects/rocr-runtime/src/fmm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/projects/rocr-runtime/src/fmm.c b/projects/rocr-runtime/src/fmm.c index 6776a8ef5b..de46fe77c1 100644 --- a/projects/rocr-runtime/src/fmm.c +++ b/projects/rocr-runtime/src/fmm.c @@ -2463,6 +2463,7 @@ HSAKMT_STATUS fmm_register_graphics_handle(HSAuint64 GraphicsResourceHandle, uint64_t offset; int r; HSAKMT_STATUS status = HSAKMT_STATUS_ERROR; + static const uint64_t IMAGE_ALIGN = 64*1024; if (gpu_id_array_size > 0 && !gpu_id_array) return HSAKMT_STATUS_INVALID_PARAMETER; @@ -2503,7 +2504,8 @@ HSAKMT_STATUS fmm_register_graphics_handle(HSAuint64 GraphicsResourceHandle, if (!aperture_is_valid(aperture->base, aperture->limit)) goto error_free_metadata; pthread_mutex_lock(&aperture->fmm_mutex); - mem = aperture_allocate_area(aperture, infoArgs.size, offset); + mem = aperture_allocate_area_aligned(aperture, infoArgs.size, offset, + MAX(aperture->align, IMAGE_ALIGN)); pthread_mutex_unlock(&aperture->fmm_mutex); if (!mem) goto error_free_metadata;