From 0bb87669c9211c64678d9d924d10ba8c154d5e59 Mon Sep 17 00:00:00 2001 From: Robin Liu Date: Wed, 25 Oct 2023 16:38:59 -0400 Subject: [PATCH] Capture the chip id in libwrap. --- third_party/freedreno/util/redump.h | 1 + third_party/freedreno/wrap/dive-wrap.c | 3 +++ third_party/freedreno/wrap/wrap-syscall.c | 3 +++ third_party/freedreno/wrap/wrap-util.c | 10 ++++++++++ 4 files changed, 17 insertions(+) diff --git a/third_party/freedreno/util/redump.h b/third_party/freedreno/util/redump.h index c77344e69..9a375fff4 100644 --- a/third_party/freedreno/util/redump.h +++ b/third_party/freedreno/util/redump.h @@ -39,6 +39,7 @@ enum rd_sect_type { RD_FRAG_SHADER, RD_BUFFER_CONTENTS, RD_GPU_ID, + RD_CHIP_ID, }; /* RD_PARAM types: */ diff --git a/third_party/freedreno/wrap/dive-wrap.c b/third_party/freedreno/wrap/dive-wrap.c index ccfb4ad1d..7c5d0843a 100644 --- a/third_party/freedreno/wrap/dive-wrap.c +++ b/third_party/freedreno/wrap/dive-wrap.c @@ -17,10 +17,13 @@ limitations under the License. #include "dive-wrap.h" #include +#include static pthread_mutex_t capture_state_lock = PTHREAD_MUTEX_INITIALIZER; static int capture_state = 0; +void rd_end(void); + int IsCapturing() { pthread_mutex_lock(&capture_state_lock); diff --git a/third_party/freedreno/wrap/wrap-syscall.c b/third_party/freedreno/wrap/wrap-syscall.c index 9415a0360..ab85dad94 100644 --- a/third_party/freedreno/wrap/wrap-syscall.c +++ b/third_party/freedreno/wrap/wrap-syscall.c @@ -859,6 +859,9 @@ static void kgsl_ioctl_device_getproperty_post(int fd, ((devinfo->chip_id >> 8) & 0xff) * 1; } rd_write_section(RD_GPU_ID, &gpu_id, sizeof(gpu_id)); + uint64_t chip_id = devinfo->chip_id; + rd_write_section(RD_CHIP_ID, &chip_id, sizeof(chip_id)); + printf("\t\tgpu_id: %d\n", gpu_id); printf("\t\tgmem_sizebytes: 0x%x\n", (uint32_t)devinfo->gmem_sizebytes); #ifdef FAKE diff --git a/third_party/freedreno/wrap/wrap-util.c b/third_party/freedreno/wrap/wrap-util.c index 2b8dd05f7..fb06fa0b9 100644 --- a/third_party/freedreno/wrap/wrap-util.c +++ b/third_party/freedreno/wrap/wrap-util.c @@ -28,6 +28,8 @@ static int fd = -1; static unsigned int gpu_id; +// GOOGLE: Store the chip ID. +static uint64_t chip_id = 0; #ifdef USE_PTHREADS static pthread_mutex_t l = PTHREAD_RECURSIVE_MUTEX_INITIALIZER; @@ -106,6 +108,11 @@ void rd_start(const char *name, const char *fmt, ...) */ rd_write_section(RD_GPU_ID, &gpu_id, sizeof(gpu_id)); } + + // GOOGLE: Write out the chip id. + if(chip_id) { + rd_write_section(RD_CHIP_ID, &chip_id, sizeof(chip_id)); + } } void rd_end(void) @@ -143,6 +150,9 @@ void rd_write_section(enum rd_sect_type type, const void *buf, int sz) if (type == RD_GPU_ID) { gpu_id = *(unsigned int *)buf; } + if (type == RD_CHIP_ID) { + chip_id = *(uint64_t *)buf; + } if(!IsCapturing()) { return; }