Debian Codegraph @

src/panfrost/ds/pan_pps_perf.cpp

raw
1 /*
2 * Copyright © 2021 Collabora, Ltd.
3 * SPDX-License-Identifier: MIT
4 */
5
6 #include "pan_pps_perf.h"
7
8 #include <lib/kmod/pan_kmod.h>
9 #include <perf/pan_perf.h>
10
11 #include <pps/pps.h>
12 #include <util/ralloc.h>
13
14 namespace pps {
15 PanfrostDevice::PanfrostDevice(int fd): fd(fd)
16 {
17 assert(fd >= 0);
18 }
19
20 PanfrostDevice::~PanfrostDevice()
21 {
22 }
23
24 PanfrostDevice::PanfrostDevice(PanfrostDevice &&o): fd{o.fd}
25 {
26 o.fd = -1;
27 }
28
29 PanfrostDevice &
30 PanfrostDevice::operator=(PanfrostDevice &&o)
31 {
32 std::swap(fd, o.fd);
33 return *this;
34 }
35
36 PanfrostPerf::PanfrostPerf(const PanfrostDevice &dev)
37 : perf{reinterpret_cast<struct pan_perf *>(
38 rzalloc(nullptr, struct pan_perf))}
39 {
40 assert(perf);
41 assert(dev.fd >= 0);
42 pan_perf_init(perf, dev.fd);
43 }
44
45 PanfrostPerf::~PanfrostPerf()
46 {
47 if (perf) {
48 pan_perf_disable(perf);
49 ralloc_free(perf);
50 }
51 }
52
53 PanfrostPerf::PanfrostPerf(PanfrostPerf &&o): perf{o.perf}
54 {
55 o.perf = nullptr;
56 }
57
58 PanfrostPerf &
59 PanfrostPerf::operator=(PanfrostPerf &&o)
60 {
61 std::swap(perf, o.perf);
62 return *this;
63 }
64
65 int
66 PanfrostPerf::enable() const
67 {
68 assert(perf);
69 return pan_perf_enable(perf);
70 }
71
72 void
73 PanfrostPerf::disable() const
74 {
75 assert(perf);
76 pan_perf_disable(perf);
77 }
78
79 int
80 PanfrostPerf::dump() const
81 {
82 assert(perf);
83 return pan_perf_dump(perf);
84 }
85
86 } // namespace pps