diff options
author | Manaf Meethalavalappu Pallikunhi <quic_manafm@quicinc.com> | 2022-05-14 01:53:29 +0530 |
---|---|---|
committer | Manaf Meethalavalappu Pallikunhi <quic_manafm@quicinc.com> | 2022-06-03 13:19:34 +0530 |
commit | ab1e3c58366864a0795dd1fff31d74a20c61a70d (patch) | |
tree | 1e7226a8c8035f5f3c7030b981659054e63dbfe9 /thermalUtilsNetlink.cpp | |
parent | 5ad97e6421bf7beeb5f55043ffee80c150878663 (diff) |
thermal-hal: Add support to monitor TZ_CREATE netlink notification
There are some thermal zones those can be created post thermal
hal initialization. It leads to a case where thermal zone
sensor init is failing due to configured sensor is not present
in available thermal zones. To avoid this issue, earlier added
a workaround to restart thermal-hal later.
thermal netlink protocol supports one event notification for
thermal zone creation. Add support to monitor thermal zone
creation event and re-initialize hal sensors.
Remove earlier workaround to restart hal service.
Change-Id: Id1aa6c3b08ada05f4c276d5b749e2c452a3fe2c6
Diffstat (limited to 'thermalUtilsNetlink.cpp')
-rw-r--r-- | thermalUtilsNetlink.cpp | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/thermalUtilsNetlink.cpp b/thermalUtilsNetlink.cpp index b709404..2b340f8 100644 --- a/thermalUtilsNetlink.cpp +++ b/thermalUtilsNetlink.cpp @@ -1,5 +1,6 @@ /* * Copyright (c) 2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -52,6 +53,9 @@ ThermalUtils::ThermalUtils(const ueventCB &inp_cb): std::placeholders::_2), std::bind(&ThermalUtils::sampleParse, this, std::placeholders::_1, + std::placeholders::_2), + std::bind(&ThermalUtils::eventCreateParse, this, + std::placeholders::_1, std::placeholders::_2)), cb(inp_cb) { @@ -72,8 +76,8 @@ ThermalUtils::ThermalUtils(const ueventCB &inp_cb): cmnInst.estimateSeverity(sens); cmnInst.initThreshold(sens); } - monitor.start(); } + monitor.start(); ret = cmnInst.initCdev(); if (ret > 0) { is_cdev_init = true; @@ -121,6 +125,45 @@ void ThermalUtils::sampleParse(int tzn, int temp) return Notify(sens); } +void ThermalUtils::eventCreateParse(int tzn, const char *name) +{ + int ret = 0; + std::vector<struct therm_sensor> sensorList; + std::vector<struct target_therm_cfg> therm_cfg = cfg.fetchConfig(); + std::vector<struct target_therm_cfg>::iterator it_vec; + std::vector<std::string>::iterator it; + + if (isSensorInitialized()) + return; + for (it_vec = therm_cfg.begin(); + it_vec != therm_cfg.end(); it_vec++) { + for (it = it_vec->sensor_list.begin(); + it != it_vec->sensor_list.end(); it++) { + if (!it->compare(name)) + break; + } + if (it != it_vec->sensor_list.end()) + break; + } + if (it_vec == therm_cfg.end()) { + LOG(DEBUG) << "sensor is not monitored:" << tzn + << std::endl; + return; + } + ret = cmnInst.initThermalZones(therm_cfg); + if (ret > 0) { + is_sensor_init = true; + sensorList = cmnInst.fetch_sensor_list(); + std::lock_guard<std::mutex> _lock(sens_cb_mutex); + for (struct therm_sensor sens: sensorList) { + thermalConfig[sens.tzn] = sens; + cmnInst.read_temperature(sens); + cmnInst.estimateSeverity(sens); + cmnInst.initThreshold(sens); + } + } +} + int ThermalUtils::readTemperatures(hidl_vec<Temperature_1_0>& temp) { std::unordered_map<int, struct therm_sensor>::iterator it; |