diff options
| author | Yiwei Zhang <zzyiwei@chromium.org> | 2025-11-05 14:23:00 -0800 |
|---|---|---|
| committer | Marge Bot <marge-bot@fdo.invalid> | 2025-11-06 18:26:01 +0000 |
| commit | 4ec2a921d3437cfd6dc01c63b3cac180e308188e (patch) | |
| tree | 1fcd4fdf17254d49210eee458ba7ff9acfdd2d12 | |
| parent | 2d98d44e630efcafbd96bfe0e928ecb9f4b345d5 (diff) | |
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: 66bbd9eec83 ("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>
| -rw-r--r-- | src/panfrost/vulkan/panvk_android.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/panfrost/vulkan/panvk_android.c b/src/panfrost/vulkan/panvk_android.c index 63e196dcef7..82e30c61139 100644 --- a/src/panfrost/vulkan/panvk_android.c +++ b/src/panfrost/vulkan/panvk_android.c @@ -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 = |