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