panvk: fix mem alloc size for VkBuffer backed by imported blob AHB

For AHB VkBuffer import, the allocationSize comes from the raw external
AHB props query and it can be larger than the underlying buffer memory
requirement. So we must respect the allocationSize for the actual mem
import to support mapping the whole AHB size, and the dedicated buffer
info has to be stripped to obey the spec.

Test: CtsNativeHardwareTestCases no longer crashes on debug build panvk

Fixes: 66bbd9eec8 ("panvk: implement AHB image deferred init and memory alloc")
Tested-by: Valentine Burley <valentine.burley@collabora.com>
Reviewed-by: Lars-Ivar Hesselberg Simonsen <lars-ivar.simonsen@arm.com>
Reviewed-by: Christoph Pillmayer <christoph.pillmayer@arm.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38274>
This commit is contained in:
Yiwei Zhang
2025-11-05 14:23:00 -08:00
committed by Marge Bot
parent 2d98d44e63
commit 4ec2a921d3

View File

@@ -436,6 +436,17 @@ panvk_android_import_ahb_memory(VkDevice device,
buf_handle = dedicated_info->buffer;
result = panvk_android_get_buffer_mem_reqs(device, buf_handle, dma_buf_fd,
&mem_reqs);
if (result == VK_SUCCESS &&
pAllocateInfo->allocationSize > mem_reqs.size) {
/* For AHB VkBuffer import, the allocationSize comes from the raw
* external AHB props query and it can be larger than the underlying
* buffer memory requirement. So we must respect the allocationSize
* for the actual mem import to support mapping the whole AHB size,
* and the dedicated buffer info has to be stripped to obey the spec.
*/
mem_reqs.size = pAllocateInfo->allocationSize;
buf_handle = VK_NULL_HANDLE;
}
} else {
mem_reqs.size = pAllocateInfo->allocationSize;
mem_reqs.memoryTypeBits =