Skip to content

Commit

Permalink
Capture the chip id in libwrap.
Browse files Browse the repository at this point in the history
  • Loading branch information
RenfengLiu committed Oct 26, 2023
1 parent 04ec3fb commit 0bb8766
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions third_party/freedreno/util/redump.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ enum rd_sect_type {
RD_FRAG_SHADER,
RD_BUFFER_CONTENTS,
RD_GPU_ID,
RD_CHIP_ID,
};

/* RD_PARAM types: */
Expand Down
3 changes: 3 additions & 0 deletions third_party/freedreno/wrap/dive-wrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ limitations under the License.
#include "dive-wrap.h"

#include <pthread.h>
#include <stdlib.h>

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);
Expand Down
3 changes: 3 additions & 0 deletions third_party/freedreno/wrap/wrap-syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions third_party/freedreno/wrap/wrap-util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 0bb8766

Please sign in to comment.