Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp53616lqo; Thu, 9 May 2024 12:20:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWMROb9oThP8XyHajAChE4qVxAyDdl2J08Rnnv30aNm5oUfhKyNrW2c1ktRCRqj3NWzSDVM1wX9yebfHwyU+gNzB68En0h+/IvdHx2wnA== X-Google-Smtp-Source: AGHT+IH5oPl6dF7p+lGwyAmN3yaewejT5KOxQGsxaoO+Is+X0/PS6lKvTantV1Ej9NyZ6+i1QvjK X-Received: by 2002:a17:903:184:b0:1e4:24bc:426e with SMTP id d9443c01a7336-1ef43d2eac1mr7146385ad.28.1715282405719; Thu, 09 May 2024 12:20:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715282405; cv=pass; d=google.com; s=arc-20160816; b=WXUm8o3zNfy4HkTHd8HekTfjc4LSNeiFXmrY1okgCJ5r46wDImT5VZfucwWlZ22GWI DHddz57kxXVmM4H57gVPtS3ZxIWgFBUVPVyZQlq/5Q8t1A6reLseIVfm5qw2P0Mwtq61 lnTq7SvWWFh082SH7LX4BRax7mCxswG0l+Pzz4aU1TECeodeLLtVnfp9RuSRXdfwZ0+t BHlV+SurZ7CLpiXON6Gl+wi4HPrqy5e0DGVJUua/Y62bhlp/RbBgl113Nie/g8fq4MMv CpQAWpNETQH/4vAJ9EMqrwYFbuyaitPNDIdo8ihQIcyrEB7QvZFXwkmevyO6j+OjbCje HN9w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=mbiWQerDsuxD+HYskj0EiL7TWnytbxgRUfPDmrxQtoY=; fh=HP39+yda0QHsXMT3XaLy3KM419Yj59UqEZWQZo+gOsI=; b=NwfM7UkMWTfezCafirAAwKERJL52jJphHXZa1gwNHE5f0le59DnkMrU6IBAstsDn+B 2Edy7DD0pPh8TToFdr+dMseCXXBujg7YPbuR6NzADHFjGPtWtLkv5mEMPJjX8eKEFF3M 4h2YhECwykyC4E3bHopm0urFEIvJLGo5IKB10COYSmX5E9KDax5ZKMyd98EW2/sQIQyV GYQp/RCUikG45G/ROzRRWk1TuEATRqjM1aXoqLpKBUlAtSImr4ZClCZqawFElGsQIRno xuacJNcSwDShw4BFlniXzR9HtIzq8udHYQ+kIJjORc908qNqeGo6LS/kjVtRkSlFHDhy +o1Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=fail header.i=@rjwysocki.net header.s=dkim header.b=D9U60wo3; arc=pass (i=1 spf=pass spfdomain=rjwysocki.net); spf=pass (google.com: domain of linux-kernel+bounces-174815-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-174815-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id d9443c01a7336-1ef0bf31752si20821065ad.306.2024.05.09.12.20.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 May 2024 12:20:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-174815-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=fail header.i=@rjwysocki.net header.s=dkim header.b=D9U60wo3; arc=pass (i=1 spf=pass spfdomain=rjwysocki.net); spf=pass (google.com: domain of linux-kernel+bounces-174815-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-174815-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 82FABB21819 for ; Thu, 9 May 2024 19:19:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8E8EC85955; Thu, 9 May 2024 19:17:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=rjwysocki.net header.i=@rjwysocki.net header.b="D9U60wo3" Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7445880BFA; Thu, 9 May 2024 19:17:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=79.96.170.134 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715282275; cv=none; b=EQ9UUO0sML0Y7QievCeAPhBCfTOyyJUybse7kR2r7Xcrc08TuClagTcVY5Xhfb1EdHz1HDj4plmm0XSxMF99a8MwzKDFcaN1Smv1LiZZe39vvL88mu5YoUWTrvu/ezHOX7EIhwRFHVcIKu+wjYzxGaAPj7v8q4EFAcpr93ELH2U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715282275; c=relaxed/simple; bh=ZsUvE8bCFSM2mKEbiGx8vW2UaEuMB+r0WfdCWDI78Lk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=gyX+vPbX/BIU9oyzcJshp88n1FQ3ceHbBCueik0V5x6gdICWKMH5hrwQzqOTltU8cLsfolnBWrDXux8gcBBQLxIAP7SGunsJcsG+tVxrdWoQyHShkc1KiEl63Gh2i+DtoUJ7n5XNwBAE/mLzACDe8G02Y+L0Ys/E6hkMdQka6ds= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rjwysocki.net; spf=pass smtp.mailfrom=rjwysocki.net; dkim=fail (2048-bit key) header.d=rjwysocki.net header.i=@rjwysocki.net header.b=D9U60wo3 reason="signature verification failed"; arc=none smtp.client-ip=79.96.170.134 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rjwysocki.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rjwysocki.net Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 6.0.0) id 1147030c55151564; Thu, 9 May 2024 21:17:46 +0200 Received: from kreacher.localnet (unknown [195.136.19.94]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by cloudserver094114.home.pl (Postfix) with ESMTPSA id 91F20A524E7; Thu, 9 May 2024 21:17:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rjwysocki.net; s=dkim; t=1715282266; bh=ZsUvE8bCFSM2mKEbiGx8vW2UaEuMB+r0WfdCWDI78Lk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=D9U60wo3wUp6f2xw5u+ffvM0RmHBMAEGdbIaV+ClmIgSRoCtYfDQI55Kq7rkVlwn8 obtOvtJKqW92u1BkLQf0C7A9DU6+WjtQ5rIoUtT7OOOI+KOmEXa5eG1+f9AczJ+8QL KbuIoruV/z8m3wkyr0/o21xjMcMLquiAmBMWgtQv0cHOFTB94IO6shrTxWAfQ1vByV 3GXhkADOJMRKGPfQN2wEtlvZjHxFrBLHb3+sdnJZVT9/tHaTtK5FHJhrPurlZ6TbNS 7TeG1SGrDUc/n+6ks8QiBA3kegPbrBgiJBruD5+wZS0wOd59KnGY+FXeFYxZmcj4fx JQwov6Xh3r0Tg== From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , "Rafael J. Wysocki" , Lukasz Luba , Daniel Lezcano Subject: [PATCH v1 1/7] thermal/debugfs: Use helper to update trip point overstepping duration Date: Thu, 09 May 2024 21:09:51 +0200 Message-ID: <4924137.31r3eYUQgx@kreacher> In-Reply-To: <12438864.O9o76ZdvQC@kreacher> References: <12438864.O9o76ZdvQC@kreacher> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="UTF-8" X-CLIENT-IP: 195.136.19.94 X-CLIENT-HOSTNAME: 195.136.19.94 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvledrvdefvddgudefvdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfjqffogffrnfdpggftiffpkfenuceurghilhhouhhtmecuudehtdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkjghfggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpedvffeuiedtgfdvtddugeeujedtffetteegfeekffdvfedttddtuefhgeefvdejhfenucfkphepudelhedrudefiedrudelrdelgeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeduleehrddufeeirdduledrleegpdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhnsggprhgtphhtthhopeehpdhrtghpthhtoheplhhinhhugidqphhmsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheprhgrfhgrvghlsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehluhhkrghsiidrlhhusggrsegrrhhmrdgtohhmpdhrtghpthhtohepuggrnhhivghlrdhlvgii tggrnhhosehlihhnrghrohdrohhrgh X-DCC--Metrics: v370.home.net.pl 1024; Body=5 Fuz1=5 Fuz2=5 From: Rafael J. Wysocki Add a helper for updating trip point overstepping duration to be called from thermal_debug_tz_trip_down(). Subsequently, it will also be used during resume from system-wide suspend. No intentional functional impact. Signed-off-by: Rafael J. Wysocki --- drivers/thermal/thermal_debugfs.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) Index: linux-pm/drivers/thermal/thermal_debugfs.c =================================================================== --- linux-pm.orig/drivers/thermal/thermal_debugfs.c +++ linux-pm/drivers/thermal/thermal_debugfs.c @@ -645,14 +645,24 @@ unlock: mutex_unlock(&thermal_dbg->lock); } +static void tz_episode_close_trip(struct tz_episode *tze, int trip_id, ktime_t now) +{ + struct trip_stats *trip_stats = &tze->trip_stats[trip_id]; + ktime_t delta = ktime_sub(now, trip_stats->timestamp); + + trip_stats->duration = ktime_add(delta, trip_stats->duration); + /* Mark the end of mitigation for this trip point. */ + trip_stats->timestamp = KTIME_MAX; +} + void thermal_debug_tz_trip_down(struct thermal_zone_device *tz, const struct thermal_trip *trip) { struct thermal_debugfs *thermal_dbg = tz->debugfs; + int trip_id = thermal_zone_trip_id(tz, trip); + ktime_t now = ktime_get(); struct tz_episode *tze; struct tz_debugfs *tz_dbg; - ktime_t delta, now = ktime_get(); - int trip_id = thermal_zone_trip_id(tz, trip); int i; if (!thermal_dbg) @@ -687,13 +697,7 @@ void thermal_debug_tz_trip_down(struct t tze = list_first_entry(&tz_dbg->tz_episodes, struct tz_episode, node); - delta = ktime_sub(now, tze->trip_stats[trip_id].timestamp); - - tze->trip_stats[trip_id].duration = - ktime_add(delta, tze->trip_stats[trip_id].duration); - - /* Mark the end of mitigation for this trip point. */ - tze->trip_stats[trip_id].timestamp = KTIME_MAX; + tz_episode_close_trip(tze, trip_id, now); /* * This event closes the mitigation as we are crossing the