Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Capture the chip ID in libwrap #27

Merged
merged 2 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
wangra-google marked this conversation as resolved.
Show resolved Hide resolved
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