virtgpu_cross_domain: fix planar size calculation

The last plane's size may include any padding bytes introduced by
virtgpu's page-alignment, but its not incorrect, and all other planes
will be exact.

BUG=b:365820897
TEST=Spot check new size calculation for YVU420_ANDROID allocation

Change-Id: I6e88905d7191dca7e68e5dfd773d2fcaac79773d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/5849473
Tested-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Chia-I Wu <olv@google.com>
Commit-Queue: Chia-I Wu <olv@google.com>
Auto-Submit: Ryan Neph <ryanneph@google.com>
Reviewed-by: Dawn Han <dawnhan@google.com>
This commit is contained in:
Ryan Neph 2024-09-10 19:48:59 +00:00 committed by Chromeos LUCI
parent 05865d75bb
commit 2381df8295

View file

@ -152,7 +152,7 @@ static int cross_domain_metadata_query(struct driver *drv, struct bo_metadata *m
struct cross_domain_private *priv = drv->priv;
struct CrossDomainGetImageRequirements cmd_get_reqs;
uint32_t *addr = (uint32_t *)priv->ring_addr;
uint32_t plane, remaining_size;
uint32_t plane;
memset(&cmd_get_reqs, 0, sizeof(cmd_get_reqs));
pthread_mutex_lock(&priv->metadata_cache_lock);
@ -204,15 +204,12 @@ static int cross_domain_metadata_query(struct driver *drv, struct bo_metadata *m
metadata->memory_idx = addr[14];
metadata->physical_device_idx = addr[15];
remaining_size = metadata->total_size;
for (plane = 0; plane < metadata->num_planes; plane++) {
if (plane != 0) {
metadata->sizes[plane - 1] = metadata->offsets[plane];
remaining_size -= metadata->offsets[plane];
}
for (plane = 1; plane < metadata->num_planes; plane++) {
metadata->sizes[plane - 1] =
metadata->offsets[plane] - metadata->offsets[plane - 1];
}
metadata->sizes[plane - 1] = metadata->total_size - metadata->offsets[plane - 1];
metadata->sizes[plane - 1] = remaining_size;
drv_array_append(priv->metadata_cache, metadata);
out_unlock: