Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 21b55b1b authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge changes I51a58e57,Ibdf8c2c5,I0b1e9221,Ie2a62c5a,Ic7fab603, ... am:...

Merge changes I51a58e57,Ibdf8c2c5,I0b1e9221,Ie2a62c5a,Ic7fab603, ... am: 1d66f1aa am: ef6f588a am: 19c64426

Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/1472682

Change-Id: Ib3cd6925b4a7201a23e72cfaad439dea209d7d00
parents c9c9db3b 19c64426
Loading
Loading
Loading
Loading
+10 −5
Original line number Diff line number Diff line
@@ -43,18 +43,21 @@ void GpuMem::initialize() {
    // Make sure bpf programs are loaded
    bpf::waitForProgsLoaded();

    int fd = bpf::bpfFdGet(kGpuMemTotalProgPath, BPF_F_RDONLY);
    errno = 0;
    int fd = bpf::retrieveProgram(kGpuMemTotalProgPath);
    if (fd < 0) {
        ALOGE("Failed to retrieve pinned program from %s", kGpuMemTotalProgPath);
        ALOGE("Failed to retrieve pinned program from %s [%d(%s)]", kGpuMemTotalProgPath, errno,
              strerror(errno));
        return;
    }

    // Attach the program to the tracepoint, and the tracepoint is automatically enabled here.
    errno = 0;
    int count = 0;
    while (bpf_attach_tracepoint(fd, kGpuMemTraceGroup, kGpuMemTotalTracepoint) < 0) {
        if (++count > kGpuWaitTimeout) {
            ALOGE("Failed to attach bpf program to %s/%s tracepoint", kGpuMemTraceGroup,
                  kGpuMemTotalTracepoint);
            ALOGE("Failed to attach bpf program to %s/%s tracepoint [%d(%s)]", kGpuMemTraceGroup,
                  kGpuMemTotalTracepoint, errno, strerror(errno));
            return;
        }
        // Retry until GPU driver loaded or timeout.
@@ -62,9 +65,11 @@ void GpuMem::initialize() {
    }

    // Use the read-only wrapper BpfMapRO to properly retrieve the read-only map.
    errno = 0;
    auto map = bpf::BpfMapRO<uint64_t, uint64_t>(kGpuMemTotalMapPath);
    if (!map.isValid()) {
        ALOGE("Failed to create bpf map from %s", kGpuMemTotalMapPath);
        ALOGE("Failed to create bpf map from %s [%d(%s)]", kGpuMemTotalMapPath, errno,
              strerror(errno));
        return;
    }
    setGpuMemTotalMap(map);