1 /* 2 * Copyright (C) 2022 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef SRC_TRACE_PROCESSOR_IMPORTERS_FTRACE_MALI_GPU_EVENT_TRACKER_H_ 18 #define SRC_TRACE_PROCESSOR_IMPORTERS_FTRACE_MALI_GPU_EVENT_TRACKER_H_ 19 20 #include <array> 21 #include <cstdint> 22 23 #include "src/trace_processor/storage/trace_storage.h" 24 #include "src/trace_processor/util/descriptors.h" 25 26 #include "protos/perfetto/trace/ftrace/ftrace_event.pbzero.h" 27 28 namespace perfetto::trace_processor { 29 30 class TraceProcessorContext; 31 32 class MaliGpuEventTracker { 33 public: 34 explicit MaliGpuEventTracker(TraceProcessorContext*); 35 void ParseMaliGpuIrqEvent(int64_t timestamp, 36 uint32_t field_id, 37 uint32_t cpu, 38 protozero::ConstBytes blob); 39 void ParseMaliGpuMcuStateEvent(int64_t timestamp, uint32_t field_id); 40 41 private: 42 void ParseMaliCSFInterruptStart(int64_t timestamp, 43 TrackId track_id, 44 protozero::ConstBytes blob); 45 void ParseMaliCSFInterruptEnd(int64_t timestamp, 46 TrackId track_id, 47 protozero::ConstBytes blob); 48 49 template <uint32_t FieldId> 50 void RegisterMcuState(const char* state_name); 51 52 static constexpr uint32_t kFirstMcuStateId = protos::pbzero::FtraceEvent:: 53 kMaliMaliPMMCUHCTLCORESDOWNSCALENOTIFYPENDFieldNumber; 54 static constexpr uint32_t kLastMcuStateId = 55 protos::pbzero::FtraceEvent::kMaliMaliPMMCURESETWAITFieldNumber; 56 57 TraceProcessorContext* context_; 58 StringId mali_KCPU_CQS_SET_id_; 59 StringId mali_KCPU_CQS_WAIT_id_; 60 StringId mali_KCPU_FENCE_SIGNAL_id_; 61 StringId mali_KCPU_FENCE_WAIT_id_; 62 StringId mali_CSF_INTERRUPT_id_; 63 StringId mali_CSF_INTERRUPT_info_val_id_; 64 65 std::array<StringId, (kLastMcuStateId - kFirstMcuStateId) + 1> 66 mcu_state_names_; 67 StringId current_mcu_state_name_; 68 }; 69 70 } // namespace perfetto::trace_processor 71 72 #endif // SRC_TRACE_PROCESSOR_IMPORTERS_FTRACE_MALI_GPU_EVENT_TRACKER_H_ 73