Received: by 2002:ab2:784b:0:b0:1fd:adc2:8405 with SMTP id m11csp289862lqp; Mon, 10 Jun 2024 04:29:49 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVlvc3FKoMbKJDPna93LFQQDLpxkZDypLj5rGsxyXrlaTa1/Nf48aST97j85I/wL1zIfdBwGa4xmv+x2vqu/+lzQNp1Y9Pj1cWLiHHSow== X-Google-Smtp-Source: AGHT+IFBRFbSelAq611dBK3PjOhoLtf9yoQ2Fqyp6Hh91OxTEjBu2aIkVDJH93EegeG244/GlnOU X-Received: by 2002:a05:6358:4195:b0:19e:e48f:939c with SMTP id e5c5f4694b2df-19f1fd1698fmr1086747555d.10.1718018989096; Mon, 10 Jun 2024 04:29:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718018989; cv=pass; d=google.com; s=arc-20160816; b=aZD4z67dpyn+5eCrpbuzckWYHud+jccr0HNX5sxdJ1npXQERl35WE0GBA/sUZzgMZX ksIyLi5GVyw2sXm7uyoe4CklmI7r6fcnlUa2y/ANSMN8ZRwU+B9qLB3zRwkrPuri+FiR VlIwjh3tlPF6LIUacp2V8WOt3KvXxF1Aw96op3gege+f+mDHlCa65HhkzsM2RkW30iY0 YXRL7sKLhervbVHwePYHbsSHr57bo8bkN9HQmtlesXzh+fpYjiyKMKH1m2ReGa74fnQO gJ4xfi4wZqJPJhwiz6ILbnJQ5OIFSQLyyVe3z509JG5hkxTLOO8cVQsnOap24m83xjBt xbvQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=U3EvtPBdENGWFMhmL+KA+OzIqZtXVd3LPNnR+Yz3n8A=; fh=IpDtfRWx9y2xFj2QhDVxJpZECWZ4c5iJxSeiHxXw8NM=; b=cqIq4jlzHraE9puRWv6VjWwbgebmM/qJ0/9qnAZAtrlTexBKMyNdN+arCHYGFvW1vG fZTm+4fcv//kcgzpudZ8cJgf5lWVWlNj1SIh8B+wMeEXzl41jpyD5aCI/Uo7AXhYhz8A MxHC2rtGKqH4ioYJSwPpyxvVjrBKU7Q43BEM5r4oEq0vpLpoP0lJYHdIJ1WnaSHIvYQo 6Oh4yyFhq756U21rR+MQC73hwqAYYAFvffOzEkZ7eHD3SX+U3xuPfY5Nl7+xfiWZ3JGQ zDHVSnXn/g1agrGH3avwRVqg6m2rpSjUEHXI1nVJb5zshyP5/LoDLfd7jUOTpND43TYf 0RwQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="mZEhh/4X"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-208083-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208083-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-6de20831829si4457512a12.133.2024.06.10.04.29.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 04:29:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-208083-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="mZEhh/4X"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-208083-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208083-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 9B962281EF5 for ; Mon, 10 Jun 2024 11:29:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C391D7CF3A; Mon, 10 Jun 2024 11:29:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="mZEhh/4X" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 CE28FFC01; Mon, 10 Jun 2024 11:29:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718018979; cv=none; b=Cmi6iZSKdvLF3x5h1QNnW3bSnJ/rd29JcFboZc3vSTQpyTDjXl23X6LJBU/w4C11M4x4emzfLyLvsbutWN44PVWAHLv6oqNdP+4MpHErCSXtaDU7TgPxUNQjoCQOVc576Cw1Uvc53smvKxlLOx5kBPK2QCESc9NiFbMeckLSyRY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718018979; c=relaxed/simple; bh=jk8n/cQIyOtPlDlv0It//nz2b1lfoB7isGVlvjgPBQc=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=JQdZhhTe0RcvmjjyIlK2iY4YGOT17Gz78KnMamqiR08jL10LPtuNHR6sEfZ9fE/zCSfHkNAx/PMaSIjYKlvX3AgtzBEd5L2ZcC5qvkcz/aZ+cQ2pJ4xb48qItvL8tdueLb5wQ02JKfIM/g/bhiF9K1onwamFZZNTRe8KwIqkRUo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mZEhh/4X; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id A587CC2BBFC; Mon, 10 Jun 2024 11:29:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718018979; bh=jk8n/cQIyOtPlDlv0It//nz2b1lfoB7isGVlvjgPBQc=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=mZEhh/4XtnFBVFQ+oCfOitN6iUToxytSUyLnvo4esaZcNIIUJ6I+RZAZINgWnP3VC DTF8VTzBszwrY96qvSc1Hl8qrMRsqbZiykPkHLXBkUUSMHWux9bpJcgvsJazlclDka O20JdMbK6w3xfHmwugI+Ub+k43TJy7AvRun0Cs4VPGOh91snypGWVL3niUKlC7p9BU 9iJq9lEs7QhW9obK+QAXlVwfLYtSxcZ/+dEbcHR/u7BcCmN4wF4De38dq10LiamcgL Qh04fxO+5nij/q8MFE9tW5ihuXJ4jvqoWgtjYrnR7a+FT8OE7AII37M0JE/bJl444E GpW57aaixxVRg== Received: by mail-oo1-f48.google.com with SMTP id 006d021491bc7-5bad97708efso85687eaf.1; Mon, 10 Jun 2024 04:29:39 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCW2owVxxHv4rXo6Uqz5MTZFg1bS0Bq3Kdb63ymDCImNNBULFEVh4SLhA2ErY1Q7B1xcqV9a5UAyyykEjGORvxgcyAI5y/ZMX+OkW/ZHGzgUG70KmpjR78Mcm0p+SFF2qvC3kz03WYA= X-Gm-Message-State: AOJu0Ywx/GXZQlnaBlzbG4l9T4vN1YzjILkZL5kJmfZvqewRTMaKeUuT lzRjHZquZE00MZYw+VFsLqY6MSU2TY0si3tXqQbJ1ZFd6loxDUA0b4Oiml+kpQWqMw+PC8YxYWU sjqVRSGVFSHqWKspfKd/x5HJ5ShQ= X-Received: by 2002:a4a:a788:0:b0:5ba:ca8a:6598 with SMTP id 006d021491bc7-5baca8a70b5mr7692336eaf.0.1718018978887; Mon, 10 Jun 2024 04:29:38 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <5794974.DvuYhMxLoT@kreacher> <2337425.ElGaqSPkdT@kreacher> In-Reply-To: From: "Rafael J. Wysocki" Date: Mon, 10 Jun 2024 13:29:27 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 2/8] thermal/debugfs: Do not extend mitigation episodes beyond system resume To: Daniel Lezcano Cc: "Rafael J. Wysocki" , Linux PM , LKML , "Rafael J. Wysocki" , Lukasz Luba Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Jun 10, 2024 at 10:28=E2=80=AFAM Daniel Lezcano wrote: > > On 28/05/2024 16:53, Rafael J. Wysocki wrote: > > From: Rafael J. Wysocki > > > > Because thermal zone handling by the thermal core is started from > > scratch during resume from system-wide suspend, prevent the debug > > code from extending mitigation episodes beyond that point by ending > > the mitigation episode currently in progress, if any, for each thermal > > zone. > > Why it is done at resume time and not at suspend time ? Because it is related to thermal_zone_device_init() which also runs at the resume time, so IMV it's better to keep these two pieces together. Why would it be better to run this during suspend? > > Signed-off-by: Rafael J. Wysocki > > --- > > > > v1 -> v2: Rebase. > > > > --- > > drivers/thermal/thermal_core.c | 1 + > > drivers/thermal/thermal_debugfs.c | 36 ++++++++++++++++++++++++++++= ++++++++ > > drivers/thermal/thermal_debugfs.h | 2 ++ > > 3 files changed, 39 insertions(+) > > > > Index: linux-pm/drivers/thermal/thermal_core.c > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > --- linux-pm.orig/drivers/thermal/thermal_core.c > > +++ linux-pm/drivers/thermal/thermal_core.c > > @@ -1641,6 +1641,7 @@ static void thermal_zone_device_resume(s > > > > tz->suspended =3D false; > > > > + thermal_debug_tz_resume(tz); > > thermal_zone_device_init(tz); > > __thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED); > > > > Index: linux-pm/drivers/thermal/thermal_debugfs.c > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > --- linux-pm.orig/drivers/thermal/thermal_debugfs.c > > +++ linux-pm/drivers/thermal/thermal_debugfs.c > > @@ -926,3 +926,39 @@ void thermal_debug_tz_remove(struct ther > > thermal_debugfs_remove_id(thermal_dbg); > > kfree(trips_crossed); > > } > > + > > +void thermal_debug_tz_resume(struct thermal_zone_device *tz) > > +{ > > + struct thermal_debugfs *thermal_dbg =3D tz->debugfs; > > + ktime_t now =3D ktime_get(); > > + struct tz_debugfs *tz_dbg; > > + struct tz_episode *tze; > > + int i; > > + > > + if (!thermal_dbg) > > + return; > > + > > + mutex_lock(&thermal_dbg->lock); > > + > > + tz_dbg =3D &thermal_dbg->tz_dbg; > > + > > + if (!tz_dbg->nr_trips) > > + goto out; > > + > > + /* > > + * A mitigation episode was in progress before the preceding syst= em > > + * suspend transition, so close it because the zone handling is s= tarting > > + * over from scratch. > > + */ > > + tze =3D list_first_entry(&tz_dbg->tz_episodes, struct tz_episode,= node); > > + > > + for (i =3D 0; i < tz_dbg->nr_trips; i++) > > + tz_episode_close_trip(tze, tz_dbg->trips_crossed[i], now)= ; > > + > > + tze->duration =3D ktime_sub(now, tze->timestamp); > > + > > + tz_dbg->nr_trips =3D 0; > > + > > +out: > > + mutex_unlock(&thermal_dbg->lock); > > +} > > Index: linux-pm/drivers/thermal/thermal_debugfs.h > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > --- linux-pm.orig/drivers/thermal/thermal_debugfs.h > > +++ linux-pm/drivers/thermal/thermal_debugfs.h > > @@ -7,6 +7,7 @@ void thermal_debug_cdev_remove(struct th > > void thermal_debug_cdev_state_update(const struct thermal_cooling_dev= ice *cdev, int state); > > void thermal_debug_tz_add(struct thermal_zone_device *tz); > > void thermal_debug_tz_remove(struct thermal_zone_device *tz); > > +void thermal_debug_tz_resume(struct thermal_zone_device *tz); > > void thermal_debug_tz_trip_up(struct thermal_zone_device *tz, > > const struct thermal_trip *trip); > > void thermal_debug_tz_trip_down(struct thermal_zone_device *tz, > > @@ -20,6 +21,7 @@ static inline void thermal_debug_cdev_st > > int state) {} > > static inline void thermal_debug_tz_add(struct thermal_zone_device *t= z) {} > > static inline void thermal_debug_tz_remove(struct thermal_zone_device= *tz) {} > > +static inline void thermal_debug_tz_resume(struct thermal_zone_device = *tz) {} > > static inline void thermal_debug_tz_trip_up(struct thermal_zone_devic= e *tz, > > const struct thermal_trip *tr= ip) {}; > > static inline void thermal_debug_tz_trip_down(struct thermal_zone_dev= ice *tz, > > > > > > > > -- > Linaro.org =E2=94=82 Open source software for AR= M SoCs > > Follow Linaro: Facebook | > Twitter | > Blog >