17ec681f3Smrg/* 27ec681f3Smrg * Copyright © 2020-2021 Collabora, Ltd. 37ec681f3Smrg * Author: Antonio Caggiano <antonio.caggiano@collabora.com> 47ec681f3Smrg * Author: Rohan Garg <rohan.garg@collabora.com> 57ec681f3Smrg * Author: Robert Beckett <bob.beckett@collabora.com> 67ec681f3Smrg * 77ec681f3Smrg * SPDX-License-Identifier: MIT 87ec681f3Smrg */ 97ec681f3Smrg 107ec681f3Smrg#pragma once 117ec681f3Smrg 127ec681f3Smrg#include <pps/pps_driver.h> 137ec681f3Smrg 147ec681f3Smrg#include "pan_pps_perf.h" 157ec681f3Smrg 167ec681f3Smrgnamespace pps 177ec681f3Smrg{ 187ec681f3Smrg/// @brief Panfrost implementation of PPS driver. 197ec681f3Smrg/// This driver queries the GPU through `drm/panfrost_drm.h`, using performance counters ioctls, 207ec681f3Smrg/// which can be enabled by setting a kernel parameter: `modprobe panfrost unstable_ioctls=1`. 217ec681f3Smrg/// The ioctl needs a buffer to copy data from kernel to user space. 227ec681f3Smrgclass PanfrostDriver : public Driver 237ec681f3Smrg{ 247ec681f3Smrg public: 257ec681f3Smrg static inline PanfrostDriver &into(Driver &dri); 267ec681f3Smrg static inline const PanfrostDriver &into(const Driver &dri); 277ec681f3Smrg 287ec681f3Smrg /// @param A list of mali counter names 297ec681f3Smrg /// @return A pair with two lists: counter groups and available counters 307ec681f3Smrg static std::pair<std::vector<CounterGroup>, std::vector<Counter>> create_available_counters( 317ec681f3Smrg const PanfrostPerf& perf); 327ec681f3Smrg 337ec681f3Smrg PanfrostDriver(); 347ec681f3Smrg ~PanfrostDriver(); 357ec681f3Smrg 367ec681f3Smrg uint64_t get_min_sampling_period_ns() override; 377ec681f3Smrg bool init_perfcnt() override; 387ec681f3Smrg void enable_counter(uint32_t counter_id) override; 397ec681f3Smrg void enable_all_counters() override; 407ec681f3Smrg void enable_perfcnt(uint64_t sampling_period_ns) override; 417ec681f3Smrg void disable_perfcnt() override; 427ec681f3Smrg bool dump_perfcnt() override; 437ec681f3Smrg uint64_t next() override; 447ec681f3Smrg 457ec681f3Smrg uint64_t last_dump_ts = 0; 467ec681f3Smrg 477ec681f3Smrg std::unique_ptr<PanfrostDevice> dev = nullptr; 487ec681f3Smrg std::unique_ptr<PanfrostPerf> perf = nullptr; 497ec681f3Smrg}; 507ec681f3Smrg 517ec681f3SmrgPanfrostDriver &PanfrostDriver::into(Driver &dri) 527ec681f3Smrg{ 537ec681f3Smrg return reinterpret_cast<PanfrostDriver &>(dri); 547ec681f3Smrg} 557ec681f3Smrg 567ec681f3Smrgconst PanfrostDriver &PanfrostDriver::into(const Driver &dri) 577ec681f3Smrg{ 587ec681f3Smrg return reinterpret_cast<const PanfrostDriver &>(dri); 597ec681f3Smrg} 607ec681f3Smrg 617ec681f3Smrg} // namespace pps 62