Debian Codegraph @

src/panfrost/ds/pan_pps_driver.h

raw
1 /*
2 * Copyright © 2020-2021 Collabora, Ltd.
3 * SPDX-License-Identifier: MIT
4 */
5
6 #pragma once
7
8 #include <pps/pps_driver.h>
9
10 #include "pan_pps_perf.h"
11
12 namespace pps {
13 /// @brief Panfrost implementation of PPS driver.
14 /// This driver queries the GPU through `drm/panfrost_drm.h`, using performance
15 /// counters ioctls, which can be enabled by setting a kernel parameter:
16 /// `modprobe panfrost unstable_ioctls=1`. The ioctl needs a buffer to copy data
17 /// from kernel to user space.
18 class PanfrostDriver : public Driver {
19 public:
20 static inline PanfrostDriver &into(Driver &dri);
21 static inline const PanfrostDriver &into(const Driver &dri);
22
23 /// @param A list of mali counter names
24 /// @return A pair with two lists: counter groups and available counters
25 static std::pair<std::vector<CounterGroup>, std::vector<Counter>>
26 create_available_counters(const PanfrostPerf &perf);
27
28 PanfrostDriver();
29 ~PanfrostDriver();
30
31 uint64_t get_min_sampling_period_ns() override;
32 bool init_perfcnt() override;
33 void enable_counter(uint32_t counter_id) override;
34 void enable_all_counters() override;
35 void enable_perfcnt(uint64_t sampling_period_ns) override;
36 void disable_perfcnt() override;
37 bool dump_perfcnt() override;
38 uint64_t next() override;
39 uint32_t gpu_clock_id() const override;
40 uint64_t gpu_timestamp() const override;
41 bool cpu_gpu_timestamp(uint64_t &cpu_timestamp,
42 uint64_t &gpu_timestamp) const override;
43
44 uint64_t last_dump_ts = 0;
45
46 std::unique_ptr<PanfrostDevice> dev = nullptr;
47 std::unique_ptr<PanfrostPerf> perf = nullptr;
48 };
49
50 PanfrostDriver &
51 PanfrostDriver::into(Driver &dri)
52 {
53 return reinterpret_cast<PanfrostDriver &>(dri);
54 }
55
56 const PanfrostDriver &
57 PanfrostDriver::into(const Driver &dri)
58 {
59 return reinterpret_cast<const PanfrostDriver &>(dri);
60 }
61
62 } // namespace pps