From 20b809f1f09b45a64846b3d4d8748150cbd8bc9d Mon Sep 17 00:00:00 2001 From: Julia Zhang Date: Mon, 25 Aug 2025 14:47:14 +0800 Subject: [PATCH] pps: init driver in OnSetup Initialization of driver has been moved to register_data_source() from OnSetup() by: a739889789f4 ("pps: Report available counters when gpu.counters* data source is registered") With above change, pps will destroy driver when collecting data stops (pps may keep running) then the driver will become nullptr when user try to collect data again. This will cause segmentation fault in OnSetup(). So this remove driver = nullptr in OnStop() and init driver in OnSetup() to make sure driver exists when pps-producer run more than once. Fixes: a739889789f ("pps: Report available counters when gpu.counters* data source is registered") Signed-off-by: Julia Zhang Part-of: --- src/tool/pps/pps_datasource.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/tool/pps/pps_datasource.cc b/src/tool/pps/pps_datasource.cc index 8b9549bde34..bbacffcaa4c 100644 --- a/src/tool/pps/pps_datasource.cc +++ b/src/tool/pps/pps_datasource.cc @@ -40,6 +40,9 @@ float ms(const std::chrono::nanoseconds &t) void GpuDataSource::OnSetup(const SetupArgs &args) { + if (!driver->init_perfcnt()) + PPS_LOG_ERROR("Failed to initialize %s driver", driver->drm_device.name.c_str()); + // Parse perfetto config const std::string &config_raw = args.config->gpu_counter_config_raw(); perfetto::protos::pbzero::GpuCounterConfig::Decoder config(config_raw); @@ -111,7 +114,6 @@ void GpuDataSource::OnStop(const StopArgs &args) stop_closure(); driver->disable_perfcnt(); - driver = nullptr; std::lock_guard lock(started_m); started = false;