From patchwork Fri Oct 1 22:33:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 515119 Delivered-To: patch@linaro.org Received: by 2002:a02:606e:0:0:0:0:0 with SMTP id d46csp1225644jaf; Fri, 1 Oct 2021 15:33:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzzea6RxNL96qLNH9qcwD+6wA9EvFLkPP7+SDwPKi0Nimx3++l5ss2n61PNRi5WNqDR3gTW X-Received: by 2002:a05:6402:19b5:: with SMTP id o21mr97326edz.214.1633127618154; Fri, 01 Oct 2021 15:33:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633127618; cv=none; d=google.com; s=arc-20160816; b=bH0+eYd2D7Wf/QE9ZXGLyUpNGIcWYvuUciXAjlm1Nf6pdvEmvvhySAmaXQMh7KpME8 wJ+tvxHiqqtxtkai0zRSnNzVCXFfqtoCQRPZxViZUZ9hol2xbVTKvWME+Aqw1ExvfTRL ruypMNCYkiAh2C6h+Wg+hQoMEnZM6Yl8shZH0BVuXnIZY88Mh3vKYt34ozhxXBbgE4tz mhBdFZMddrsniQLmbgFVm1AEq0IoMdWZHt9RxmYCbOb2cyUerx3Dln1GrdVX+jnXM3m0 Qlr03igzD66vW+6cMMpHqcXBtx0ZE6ogIAqxa6WRQpNLTGbUNVCRmJkHyVFS/COOqlbG q+cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=8nDTUff3NWAShPXkSJUHpdXF/tre0swCngGs+0ldBuo=; b=xk8+d17rH1iJspawepU8fGWh32iPxrZ0Tr1Wuq43Jpnmqz6YIgWhReGrGkNOg1dooO 5AhUSLDGdo96hyxde6F6vanQRVBH9OrH9srEwhugFFbH0Zkv95+a8btXwTSbYjJcKa77 c1MODhV5oaXflPd/QPBS2wUINcQ3+JAF7talCS4rsMpchbacgJh8SLH8+18F5KBlMdKr orxzkPQZHdXkQw1ayKmVuFPgXfrXhsCP6E4WGZd9rMkkjdLTi6Pl4SjoKDRoGV7A/yTA ZhRqXoK6nLD9xReSUTVcWokusThWkvH1cZd6FVKPJwJZk5OrNOLgJkt9NEonFNGofeWE jVBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iTFcfgD9; 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 m22si8198401ejl.525.2021.10.01.15.33.37; Fri, 01 Oct 2021 15:33:38 -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=iTFcfgD9; 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 S1355900AbhJAWfT (ORCPT + 7 others); Fri, 1 Oct 2021 18:35:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355824AbhJAWfR (ORCPT ); Fri, 1 Oct 2021 18:35:17 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4173C0613E3 for ; Fri, 1 Oct 2021 15:33:32 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id q127-20020a1ca785000000b0030cb71ea4d1so7713264wme.1 for ; Fri, 01 Oct 2021 15:33:32 -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:mime-version :content-transfer-encoding; bh=8nDTUff3NWAShPXkSJUHpdXF/tre0swCngGs+0ldBuo=; b=iTFcfgD9k1Ew/Q3d85rswksP5KXCDig/JMG7z4OhD2EquHZpCoQt7WZ1Ks7iAxlx5F j79zOLzzrSFIu3t5mp3BdYb8xK+ue+VQpYMOng91ymPADIOBDQXsYPTrI+Y8Pp8Ddl3z VStEoSKYKklC02gxEXkv2MM+BBemjoiJHqs0CPbPJq/xooJxLlrm6IaCkzaW9U0bInzq ssdNVwWQQrjFwmBfEXg3Q4QVKTRZvE6SqrE19ONi7tNV0Uq2cvwjt8FESqH/Y2ij2+56 Cw+mRWRH+K+isrtp97UodjIvbXVjfs5bke++3w26zh5lK1BoDhVuHpNnxoSRP5I+eSuS 5kCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=8nDTUff3NWAShPXkSJUHpdXF/tre0swCngGs+0ldBuo=; b=F8+82JcoC4scKamYWkgnnuJ+/hRfnI2g2nUGlA7rEezrL/2Cjvbzu3zTEAKcQdxTx4 8ocu72e15k1xdg/Iv61BDITTSjUmr8GUba9X7mGERMY3SBNQmzRhxtj4Kv4b9Kbha82K pqyHCvDfUDXaZJa5to2k73paxNk4k67SPJNKyi6yEjHHZEnl2EHGVXARgazcVc0iE1RM /YVQqcr9b15znMrud8+Hfla13bGwj+X19MxB7IBAYO7opc7LiAM8mGeIBAt8fra3mx0J qzJPG/4Wt6FBLjgCqFqpwzbP2hND32JYpiw8VsmdhY5FF+k3Ib8nhSFLhSnl+4Byuw2n V7HQ== X-Gm-Message-State: AOAM532zJ26osfQF9Q6Cs89vagf3+LGPStIH/PazhSe3mWOf3UZjzHdz M8HCpIdr3PD9MAIxoTSqce4XXQ== X-Received: by 2002:a05:600c:a45:: with SMTP id c5mr6979189wmq.79.1633127611224; Fri, 01 Oct 2021 15:33:31 -0700 (PDT) Received: from localhost.localdomain ([82.142.20.44]) by smtp.gmail.com with ESMTPSA id 8sm6921066wmo.47.2021.10.01.15.33.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Oct 2021 15:33:30 -0700 (PDT) From: Daniel Lezcano To: rafael@kernel.org Cc: srinivas.pandruvada@linux.intel.com, daniel.lezcano@linaro.org, rui.zhang@intel.com, rkumbako@quicinc.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, Amit Kucheria Subject: [PATCH RESEND] thermal/drivers/netlink: Add the temperature when crossing a trip point Date: Sat, 2 Oct 2021 00:33:23 +0200 Message-Id: <20211001223323.1836640-1-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 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 Acked-by: Srinivas Pandruvada --- drivers/thermal/thermal_core.c | 6 ++++-- drivers/thermal/thermal_netlink.c | 11 ++++++----- drivers/thermal/thermal_netlink.h | 8 ++++---- 3 files changed, 14 insertions(+), 11 deletions(-) -- 2.25.1 diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 51374f4e1cca..9e243d9f929e 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -375,10 +375,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; }