From d77e164105c38a08817cb04276f30492ae9de229 Mon Sep 17 00:00:00 2001 From: Dawn Han Date: Fri, 17 Feb 2023 17:32:05 +0000 Subject: minigbm: Relax the validateBufferSize check Blob formats (aka buffers) get represented as R8 textures with height of one and width==size. These have no particular stride requirement, even though the host might ask for a pitch that would make sense for a 2D R8 texture with height greater than one. Relax the validateBufferSize check for format_blob rather than set the stride. As blob defined: buffers of this format must have a height of 1, so height doesn't need to be checked specifically. BUG=b:269565421 TEST=CQ Change-Id: I7a8d4dbf292330df0c24b502abd9dbf3dceac728 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4263402 Reviewed-by: Yiwei Zhang Tested-by: Yiwei Zhang --- cros_gralloc/gralloc4/CrosGralloc4Mapper.cc | 8 +++++++- virtgpu_cross_domain.c | 5 ----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/cros_gralloc/gralloc4/CrosGralloc4Mapper.cc b/cros_gralloc/gralloc4/CrosGralloc4Mapper.cc index 65fc83c..90d9506 100644 --- a/cros_gralloc/gralloc4/CrosGralloc4Mapper.cc +++ b/cros_gralloc/gralloc4/CrosGralloc4Mapper.cc @@ -155,7 +155,13 @@ Return CrosGralloc4Mapper::validateBufferSize(void* rawHandle, return Error::BAD_VALUE; } - if (stride != crosHandle->pixel_stride) { + if (crosHandle->droid_format == HAL_PIXEL_FORMAT_BLOB) { + if (stride > crosHandle->pixel_stride) { + ALOGE("Failed to validateBufferSize. Oversized stride (%d vs %d).", stride, + crosHandle->pixel_stride); + return Error::BAD_VALUE; + } + } else if (stride != crosHandle->pixel_stride) { ALOGE("Failed to validateBufferSize. Stride mismatch (%d vs %d).", stride, crosHandle->pixel_stride); return Error::BAD_VALUE; diff --git a/virtgpu_cross_domain.c b/virtgpu_cross_domain.c index 4af9c3a..b94a4ae 100644 --- a/virtgpu_cross_domain.c +++ b/virtgpu_cross_domain.c @@ -196,11 +196,6 @@ static int cross_domain_metadata_query(struct driver *drv, struct bo_metadata *m metadata->memory_idx = addr[14]; metadata->physical_device_idx = addr[15]; - /* Detect buffers, which have no particular stride alignment requirement: */ - if ((metadata->height == 1) && (metadata->format == DRM_FORMAT_R8)) { - metadata->strides[0] = metadata->width; - } - remaining_size = metadata->total_size; for (plane = 0; plane < metadata->num_planes; plane++) { if (plane != 0) { -- cgit v1.2.3