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 "protos/perfetto/trace/ftrace/ftrace_event.pbzero.h" 21 #include "src/trace_processor/storage/trace_storage.h" 22 #include "src/trace_processor/util/descriptors.h" 23 24 namespace perfetto { 25 namespace trace_processor { 26 27 class TraceProcessorContext; 28 29 class MaliGpuEventTracker { 30 public: 31 explicit MaliGpuEventTracker(TraceProcessorContext*); 32 void ParseMaliGpuEvent(int64_t timestamp, uint32_t field_id, uint32_t pid); 33 void ParseMaliGpuIrqEvent(int64_t timestamp, 34 uint32_t field_id, 35 uint32_t cpu, 36 protozero::ConstBytes blob); 37 void ParseMaliGpuMcuStateEvent(int64_t timestamp, uint32_t field_id); 38 39 private: 40 void ParseMaliKcpuFenceSignal(int64_t timestamp, TrackId track_id); 41 void ParseMaliKcpuFenceWaitStart(int64_t timestamp, TrackId track_id); 42 void ParseMaliKcpuFenceWaitEnd(int64_t timestamp, TrackId track_id); 43 void ParseMaliKcpuCqsSet(int64_t timestamp, TrackId track_id); 44 void ParseMaliKcpuCqsWaitStart(int64_t timestamp, TrackId track_id); 45 void ParseMaliKcpuCqsWaitEnd(int64_t timestamp, TrackId track_id); 46 void ParseMaliCSFInterruptStart(int64_t timestamp, 47 TrackId track_id, 48 protozero::ConstBytes blob); 49 void ParseMaliCSFInterruptEnd(int64_t timestamp, 50 TrackId track_id, 51 protozero::ConstBytes blob); 52 53 template <uint32_t FieldId> 54 void RegisterMcuState(const char* state_name); 55 56 static constexpr uint32_t kFirstMcuStateId = protos::pbzero::FtraceEvent:: 57 kMaliMaliPMMCUHCTLCORESDOWNSCALENOTIFYPENDFieldNumber; 58 static constexpr uint32_t kLastMcuStateId = 59 protos::pbzero::FtraceEvent::kMaliMaliPMMCURESETWAITFieldNumber; 60 61 TraceProcessorContext* context_; 62 StringId mali_KCPU_CQS_SET_id_; 63 StringId mali_KCPU_CQS_WAIT_id_; 64 StringId mali_KCPU_FENCE_SIGNAL_id_; 65 StringId mali_KCPU_FENCE_WAIT_id_; 66 StringId mali_CSF_INTERRUPT_id_; 67 StringId mali_CSF_INTERRUPT_info_val_id_; 68 69 std::array<StringId, (kLastMcuStateId - kFirstMcuStateId) + 1> 70 mcu_state_names_; 71 StringId current_mcu_state_name_; 72 StringId mcu_state_track_name_; 73 }; 74 75 } // namespace trace_processor 76 } // namespace perfetto 77 78 #endif // SRC_TRACE_PROCESSOR_IMPORTERS_FTRACE_MALI_GPU_EVENT_TRACKER_H_ 79