From patchwork Thu Mar 25 19:36:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 408853 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp818182jai; Thu, 25 Mar 2021 12:38:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy6OGMX9q1HDsH/fSK4+olxoqWI7w0fLgzPW+GbfZTGhjP9vgwSKrPYurixkOzYOjKlEZq2 X-Received: by 2002:aa7:da14:: with SMTP id r20mr10803153eds.181.1616701086409; Thu, 25 Mar 2021 12:38:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616701086; cv=none; d=google.com; s=arc-20160816; b=kFi63QZ+jzYcXKBOTaPVCENrBdR+Bf2I6eiyq7CvDm2+m86xCeEmOEMQnA2aB3VQMn PFDreCcnYFrau9k6Asye94b5G0iMxS1xK0mnMR7Xoh/kzdmVuaSSi2g1Ix7ANufPoYGI WKGinXhxLkYQrk27NY1WAH4uqcOJcs4MrugC+CNWv6JN8IXGzrzNWD7o513+U5eEZbg2 Llzc8T8Es1tk3tMAwMXckxbrOZIEAOAAmLc4Y3K7bkChT4ma5IPFiDwe2l6VJS2qhawB yYw1Z/p7FbjN3cHw50g3g/W7qjVmWW1Pu//6m6JER7hmh/l152RPBpinYZ8z9cYi8jZ2 hDDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=c28V1qEol1I4QrexdXU8KtR/UuqWaDR44oRtym8omog=; b=VFwAu7DIfZ2n5BrrfXU4IR3rcs28ph9l0KT6LamuQfzf0dBZBdjyCjMXzm605dfI3H Y01QZeuN3X8I2zUko6ELswDn93B+p87qCgQJciq0SmAHnieiXFRdZb1WmotrqZryRij5 umD1W1G5jyTKp2PZV7V7KfAUkKbyA6THOfRPEsZ1NZm8c6orZVZyHcjqEiRCUkuw3Iy4 v20lAZkOFWbWobxrepOgStq+DG3ZIRXx7bZAONibIy8njDQRjscdqNuUgyjz07Tixgmd FkRXLWLVpOEwFWIZORONqog7OsOadqsIfWXrBDeKwpRKhQWBzj+4JbLUAyUuD29YxA2M uZ5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rqHrJiGt; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c11si5029536edv.591.2021.03.25.12.38.06; Thu, 25 Mar 2021 12:38:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rqHrJiGt; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229669AbhCYThd (ORCPT + 7 others); Thu, 25 Mar 2021 15:37:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230059AbhCYThA (ORCPT ); Thu, 25 Mar 2021 15:37:00 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2C82C06175F for ; Thu, 25 Mar 2021 12:36:58 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id j20-20020a05600c1914b029010f31e15a7fso3745192wmq.1 for ; Thu, 25 Mar 2021 12:36:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=c28V1qEol1I4QrexdXU8KtR/UuqWaDR44oRtym8omog=; b=rqHrJiGtdaFIDWFvz2/YQL40pxirOdoQHfB+PAgJ0oYhv9k4vd3ALvRKEewsisgmtD POIKgErjUeibWdmqe+uCwplydDvG1qzxc/1w1rB7cQqjpahs7gG5Ih2T/TqCplsPrInz qUodO7S70wOSVekTbKaK+Hi11An+CrW4w73zPBAOen6GkfHjaJhXxY1M+Unl27tPHswB /5P9kS+jkE5w/niDGNqWJBP3Mog7C2cklB7fGL9C2RRGRzyKsVEBPFOuHObqvKekM6WF 6sIuXkeeYNdqqRqzha5169RgSAQqEHdZ6jP/HJlOOEyMEaBktXCrlQImF040GvHlTU9K imEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=c28V1qEol1I4QrexdXU8KtR/UuqWaDR44oRtym8omog=; b=XtffsfDHMsVqLI8k+ze/IyAdy15xX1GJCy0SsekkQO580FRLQgouMCfAYbYF73k+PO OeTASqTqGUx07pgjm5XCalDn1OKtk7trueW6rml9sk0FufMPaAbqcEfu2rYynWGX1pLe H9n8Vzb0+LSOdBQvZgPLpdXONvySMeGj7IQb463SWwVtd6lIKNicTl84Hidyz65ZvP9v fXf+5Wk0mVj/qqiJR5WK9/roEwcsVpLFdp54+4CuNR1cUz2R7iAvuYs8osT5wy9Mj34h CzBTavHbswIhYQ85EUvGky1AmkXy9FszVxxJrx+6t8MD7uwQgFohQzcrVI3/5Ue4avoW rLKw== X-Gm-Message-State: AOAM532d9CB9Km/nrHL/82yoOF4ArwucD1122EYZJ2LYinpY5zd8FEQ7 CEAR1tT5anvvt41s7HwGlhAKtQ== X-Received: by 2002:a1c:df46:: with SMTP id w67mr9475403wmg.176.1616701017347; Thu, 25 Mar 2021 12:36:57 -0700 (PDT) Received: from localhost.localdomain ([82.142.13.80]) by smtp.gmail.com with ESMTPSA id h12sm2240217wrv.58.2021.03.25.12.36.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Mar 2021 12:36:56 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org Cc: rkumbako@quicinc.com, Zhang Rui , Amit Kucheria , linux-pm@vger.kernel.org (open list:THERMAL), linux-kernel@vger.kernel.org (open list), linux-api@vger.kernel.org (open list:ABI/API) Subject: [PATCH] thermal/drivers/netlink: Add the temperature when crossing a trip point Date: Thu, 25 Mar 2021 20:36:32 +0100 Message-Id: <20210325193633.19592-1-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.17.1 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The slope of the temperature increase or decrease can be high and when the temperature crosses the trip point, there could be a significant difference between the trip temperature and the measured temperatures. That forces the userspace to read the temperature back right after receiving a trip violation notification. In order to be efficient, give the temperature which resulted in the trip violation. Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_core.c | 6 ++++-- drivers/thermal/thermal_netlink.c | 11 ++++++----- drivers/thermal/thermal_netlink.h | 8 ++++---- include/uapi/linux/thermal.h | 2 +- 4 files changed, 15 insertions(+), 12 deletions(-) -- 2.17.1 diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 996c038f83a4..948020ef51b1 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -430,10 +430,12 @@ static void handle_thermal_trip(struct thermal_zone_device *tz, int trip) if (tz->last_temperature != THERMAL_TEMP_INVALID) { if (tz->last_temperature < trip_temp && tz->temperature >= trip_temp) - thermal_notify_tz_trip_up(tz->id, trip); + thermal_notify_tz_trip_up(tz->id, trip, + tz->temperature); if (tz->last_temperature >= trip_temp && tz->temperature < (trip_temp - hyst)) - thermal_notify_tz_trip_down(tz->id, trip); + thermal_notify_tz_trip_down(tz->id, trip, + tz->temperature); } if (type == THERMAL_TRIP_CRITICAL || type == THERMAL_TRIP_HOT) diff --git a/drivers/thermal/thermal_netlink.c b/drivers/thermal/thermal_netlink.c index 1234dbe95895..a16dd4d5d710 100644 --- a/drivers/thermal/thermal_netlink.c +++ b/drivers/thermal/thermal_netlink.c @@ -121,7 +121,8 @@ static int thermal_genl_event_tz(struct param *p) static int thermal_genl_event_tz_trip_up(struct param *p) { if (nla_put_u32(p->msg, THERMAL_GENL_ATTR_TZ_ID, p->tz_id) || - nla_put_u32(p->msg, THERMAL_GENL_ATTR_TZ_TRIP_ID, p->trip_id)) + nla_put_u32(p->msg, THERMAL_GENL_ATTR_TZ_TRIP_ID, p->trip_id) || + nla_put_u32(p->msg, THERMAL_GENL_ATTR_TZ_TEMP, p->temp)) return -EMSGSIZE; return 0; @@ -285,16 +286,16 @@ int thermal_notify_tz_disable(int tz_id) return thermal_genl_send_event(THERMAL_GENL_EVENT_TZ_DISABLE, &p); } -int thermal_notify_tz_trip_down(int tz_id, int trip_id) +int thermal_notify_tz_trip_down(int tz_id, int trip_id, int temp) { - struct param p = { .tz_id = tz_id, .trip_id = trip_id }; + struct param p = { .tz_id = tz_id, .trip_id = trip_id, .temp = temp }; return thermal_genl_send_event(THERMAL_GENL_EVENT_TZ_TRIP_DOWN, &p); } -int thermal_notify_tz_trip_up(int tz_id, int trip_id) +int thermal_notify_tz_trip_up(int tz_id, int trip_id, int temp) { - struct param p = { .tz_id = tz_id, .trip_id = trip_id }; + struct param p = { .tz_id = tz_id, .trip_id = trip_id, .temp = temp }; return thermal_genl_send_event(THERMAL_GENL_EVENT_TZ_TRIP_UP, &p); } diff --git a/drivers/thermal/thermal_netlink.h b/drivers/thermal/thermal_netlink.h index 828d1dddfa98..e554f76291f4 100644 --- a/drivers/thermal/thermal_netlink.h +++ b/drivers/thermal/thermal_netlink.h @@ -11,8 +11,8 @@ int thermal_notify_tz_create(int tz_id, const char *name); int thermal_notify_tz_delete(int tz_id); int thermal_notify_tz_enable(int tz_id); int thermal_notify_tz_disable(int tz_id); -int thermal_notify_tz_trip_down(int tz_id, int id); -int thermal_notify_tz_trip_up(int tz_id, int id); +int thermal_notify_tz_trip_down(int tz_id, int id, int temp); +int thermal_notify_tz_trip_up(int tz_id, int id, int temp); int thermal_notify_tz_trip_delete(int tz_id, int id); int thermal_notify_tz_trip_add(int tz_id, int id, int type, int temp, int hyst); @@ -49,12 +49,12 @@ static inline int thermal_notify_tz_disable(int tz_id) return 0; } -static inline int thermal_notify_tz_trip_down(int tz_id, int id) +static inline int thermal_notify_tz_trip_down(int tz_id, int id, int temp) { return 0; } -static inline int thermal_notify_tz_trip_up(int tz_id, int id) +static inline int thermal_notify_tz_trip_up(int tz_id, int id, int temp) { return 0; } diff --git a/include/uapi/linux/thermal.h b/include/uapi/linux/thermal.h index c105054cbb57..bf5d9c8ef16f 100644 --- a/include/uapi/linux/thermal.h +++ b/include/uapi/linux/thermal.h @@ -18,7 +18,7 @@ enum thermal_trip_type { /* Adding event notification support elements */ #define THERMAL_GENL_FAMILY_NAME "thermal" -#define THERMAL_GENL_VERSION 0x01 +#define THERMAL_GENL_VERSION 0x02 #define THERMAL_GENL_SAMPLING_GROUP_NAME "sampling" #define THERMAL_GENL_EVENT_GROUP_NAME "event"