summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChia-I Wu <olv@google.com>2023-11-08 13:22:06 -0800
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-11-15 01:58:57 +0000
commit48a3e34e168fd0eae3d299c13f157f6fffc615d3 (patch)
treee7cbcb48a5c6923ca01c820e2431f9c7035977f8
parent90b2d4773273b3ea180aff8f995d58e7b7604eb5 (diff)
downloadminigbm-48a3e34e168fd0eae3d299c13f157f6fffc615d3.tar.gz
drv: add support for bo logging
When MINIGBM_DEBUG=log_bos is set, log all bos created/imported. BUG=none TEST=add MINIGBM_DEBUG=log_bos to /etc/chrome_dev.conf and see logs in /var/log/ui/ui.LATEST Change-Id: Ib2b2d5c3181862b557dbc5499fef84f2c9ac8122 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/5014198 Commit-Queue: ChromeOS Auto Retry <chromeos-auto-retry@chromeos-bot.iam.gserviceaccount.com> Reviewed-by: Dawn Han <dawnhan@google.com> Tested-by: Chia-I Wu <olv@google.com>
-rw-r--r--drv.c33
-rw-r--r--drv.h2
-rw-r--r--drv_priv.h1
3 files changed, 35 insertions, 1 deletions
diff --git a/drv.c b/drv.c
index e3a71cb..d238122 100644
--- a/drv.c
+++ b/drv.c
@@ -6,6 +6,7 @@
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
+#include <inttypes.h>
#include <pthread.h>
#include <stdint.h>
#include <stdio.h>
@@ -118,7 +119,8 @@ struct driver *drv_create(int fd)
const char *minigbm_debug;
minigbm_debug = drv_get_os_option(MINIGBM_DEBUG);
- drv->compression = (minigbm_debug == NULL) || (strcmp(minigbm_debug, "nocompression") != 0);
+ drv->compression = (minigbm_debug == NULL) || (strstr(minigbm_debug, "nocompression") == NULL);
+ drv->log_bos = (minigbm_debug && strstr(minigbm_debug, "log_bos") != NULL);
drv->fd = fd;
drv->backend = drv_get_backend(fd);
@@ -365,6 +367,9 @@ struct bo *drv_bo_create(struct driver *drv, uint32_t width, uint32_t height, ui
drv_bo_acquire(bo);
+ if (drv->log_bos)
+ drv_bo_log_info(bo, "legacy created");
+
return bo;
}
@@ -402,6 +407,9 @@ struct bo *drv_bo_create_with_modifiers(struct driver *drv, uint32_t width, uint
drv_bo_acquire(bo);
+ if (drv->log_bos)
+ drv_bo_log_info(bo, "created");
+
return bo;
}
@@ -460,6 +468,9 @@ struct bo *drv_bo_import(struct driver *drv, struct drv_import_fd_data *data)
bo->meta.total_size += bo->meta.sizes[plane];
}
+ if (drv->log_bos)
+ drv_bo_log_info(bo, "imported");
+
return bo;
destroy_bo:
@@ -710,6 +721,26 @@ size_t drv_bo_get_total_size(struct bo *bo)
return bo->meta.total_size;
}
+void drv_bo_log_info(const struct bo *bo, const char *prefix)
+{
+ const struct bo_metadata *meta = &bo->meta;
+
+ drv_logd("%s %s bo %p: %dx%d '%c%c%c%c' tiling %d plane %zu mod 0x%" PRIx64 " use 0x%" PRIx64 " size %zu\n",
+ prefix, bo->drv->backend->name, bo,
+ meta->width, meta->height,
+ meta->format & 0xff,
+ (meta->format >> 8) & 0xff,
+ (meta->format >> 16) & 0xff,
+ (meta->format >> 24) & 0xff,
+ meta->tiling, meta->num_planes, meta->format_modifier,
+ meta->use_flags, meta->total_size);
+ for (uint32_t i = 0; i < meta->num_planes; i++) {
+ drv_logd(" bo %p plane %d: offset %d size %d stride %d\n",
+ bo, i, meta->offsets[i], meta->sizes[i],
+ meta->strides[i]);
+ }
+}
+
/*
* Map internal fourcc codes back to standard fourcc codes.
*/
diff --git a/drv.h b/drv.h
index f80dab6..a6e602b 100644
--- a/drv.h
+++ b/drv.h
@@ -208,6 +208,8 @@ uint64_t drv_bo_get_use_flags(struct bo *bo);
size_t drv_bo_get_total_size(struct bo *bo);
+void drv_bo_log_info(const struct bo *bo, const char *prefix);
+
uint32_t drv_get_standard_fourcc(uint32_t fourcc_internal);
uint32_t drv_bytes_per_pixel_from_format(uint32_t format, size_t plane);
diff --git a/drv_priv.h b/drv_priv.h
index d9888d0..a4f950b 100644
--- a/drv_priv.h
+++ b/drv_priv.h
@@ -70,6 +70,7 @@ struct driver {
struct drv_array *mappings;
struct drv_array *combos;
bool compression;
+ bool log_bos;
};
struct backend {