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 /thermalMonitorNetlink.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 'thermalMonitorNetlink.cpp')
-rw-r--r-- | thermalMonitorNetlink.cpp | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/thermalMonitorNetlink.cpp b/thermalMonitorNetlink.cpp index b8e7128..f081363 100644 --- a/thermalMonitorNetlink.cpp +++ b/thermalMonitorNetlink.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 @@ -73,11 +74,13 @@ int thermal_family_cb(struct nl_msg *n, void *data) } ThermalMonitor::ThermalMonitor(const eventMonitorCB &inp_event_cb, - const eventMonitorCB &inp_sample_cb): + const eventMonitorCB &inp_sample_cb, + const eventCreateMonitorCB &inp_event_create_cb): event_group(-1), sample_group(-1), event_cb(inp_event_cb), - sample_cb(inp_sample_cb) + sample_cb(inp_sample_cb), + event_create_cb(inp_event_create_cb) { monitor_shutdown = false; } @@ -99,6 +102,7 @@ int ThermalMonitor::event_parse(struct nl_msg *n, void *data) struct genlmsghdr *hdr = genlmsg_hdr(nl_hdr); struct nlattr *attrs[THERMAL_GENL_ATTR_MAX + 1]; int tzn = -1, trip = -1; + const char *tz_name = ""; genlmsg_parse(nl_hdr, 0, attrs, THERMAL_GENL_ATTR_MAX, NULL); @@ -111,10 +115,19 @@ int ThermalMonitor::event_parse(struct nl_msg *n, void *data) if (attrs[THERMAL_GENL_ATTR_TZ_TRIP_ID]) trip = nla_get_u32( attrs[THERMAL_GENL_ATTR_TZ_TRIP_ID]); - LOG(INFO) << "thermal_nl_event: TZ:" << tzn << " Trip:" - << trip << "event:" << hdr->cmd << std::endl; + LOG(DEBUG) << "thermal_nl_event: TZ:" << tzn << " Trip:" + << trip << "event:" << (int)hdr->cmd << std::endl; event_cb(tzn, trip); break; + case THERMAL_GENL_EVENT_TZ_CREATE: + if (attrs[THERMAL_GENL_ATTR_TZ_ID]) + tzn = nla_get_u32(attrs[THERMAL_GENL_ATTR_TZ_ID]); + if (attrs[THERMAL_GENL_ATTR_TZ_NAME]) + tz_name = nla_get_string(attrs[THERMAL_GENL_ATTR_TZ_NAME]); + LOG(DEBUG) << "thermal_nl_event: TZ_CREATE: TZ:" << tzn << " TZ_NAME:" + << tz_name << "event:" << (int)hdr->cmd << std::endl; + event_create_cb(tzn, tz_name); + break; } return 0; |