Received: by 2002:ab2:6991:0:b0:1f2:fff1:ace7 with SMTP id v17csp221348lqo; Wed, 27 Mar 2024 11:04:56 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXYg4dwLaDG/5ju9t7z0MqjifLRmZcV9AzHcm7dEBdz02n39altRHYNt1J7M5JyBmEunwnBD1BooR5wQwJe2koZt6+0AK4hfFrlgtMa4Q== X-Google-Smtp-Source: AGHT+IGYFUY54Zk5p1qW3+NKOQR5yIRN9roXY6S/1OOYF6P0KQcShW7KoTGUD6s6Nu4GOD4tDYf4 X-Received: by 2002:a05:6a20:bc8f:b0:1a3:701c:cca9 with SMTP id fx15-20020a056a20bc8f00b001a3701ccca9mr656122pzb.27.1711562696475; Wed, 27 Mar 2024 11:04:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711562696; cv=pass; d=google.com; s=arc-20160816; b=Q8hKidwwXsnbwsP3OlZUxLUnuYQKOyPEfHW8r3vChnrXk/sDvEmPqpExoyKsjTN216 Se3HuQ1TXXLq28hN3zvsOkJ3iqrzTkYqyc20F1d8ro9E0uxcJkNToh77vECRPtP4JiCp pPZabtJePAt0cQvmQ0BnveuGWdV9VsgHuxXb+Nc3kHTUKkOkxNURrvJD8YArb4X2G/Qr BBkp5n+Yjyj58I7eQamqtt+Tc4i1UcKvsg5vSqD5NPohlBEen5H89FwZU6z+rgGzkxU2 PFTP5yyS3iSib+QN6Tso3yY/Jv75xtd9Q6lhpITCZ/1QURcgmwEAEZj/0MabSJyRRuIc eQzw== 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=AIEg/Xy/PoDqHT9QKAEWvyXIMReovS+YJb82S+wHteM=; fh=U3dOeCOIHZxj8qGrueTRXs/FLS66auUgvMxkwiIavBA=; b=JJP3Oks9kGq0vAA2RO3V14QKLEyxvycMt2Yx1bgnoRzkdzlrFoAYELArew4Da3lrYm 6N8OK3/aphZ2zTDyInd/pZ+yZfijwYjSF40UxkkH0YZIi3RXJb7peqFfcmJ09Sp6DdN9 03CkIPtJecjAcsjeAGKfsox0YS2D5emzvgpZkI6pMcqzCO2yQ2xQ9IA/m0ygUjtgnLC+ yMlYr5dt1wXYu2WKry6L2Pek7kp9WHNUicH+6bLAut52uKSsFCrfVfD323NwqWLIc9T0 HaYLXAcAffynIjYRG3wfCj2f1qqVsGm4ObbuEIgfQuJuk7Ps3wZ8p0VYuz69aJtoxU5A wrYQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=fail header.i=@rjwysocki.net header.s=dkim header.b=CL9h+rGd; arc=pass (i=1 spf=pass spfdomain=rjwysocki.net); spf=pass (google.com: domain of linux-kernel+bounces-121704-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-121704-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 p33-20020a634f61000000b005e2b1e879d6si12403875pgl.370.2024.03.27.11.04.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 11:04:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-121704-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=CL9h+rGd; arc=pass (i=1 spf=pass spfdomain=rjwysocki.net); spf=pass (google.com: domain of linux-kernel+bounces-121704-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-121704-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 EC2B9B22CEA for ; Wed, 27 Mar 2024 17:37:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CD91D14D6EC; Wed, 27 Mar 2024 17:37:21 +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="CL9h+rGd" 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 9ADD61327FA; Wed, 27 Mar 2024 17:37:16 +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=1711561040; cv=none; b=USxm37ADKwwT/cr7xbggPudlpPO2JBmB612yreZtYnjc6bwWWSpUwnn4VBz38EVz9Nf1Vloogo+WhWMTm+dt1sK5sYOZDxo3Mhv3x9pd7j5STBkWjmqJ+XZbcpTFHIIqr/mL+QEzhx+YBsDtsn+gUaHrG3+caLxrV55P6yLXDeE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711561040; c=relaxed/simple; bh=KX4g13Xup63sTGBlrDCIfXNymgHLjpMxAiruTR8DQuM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=T1mK88s53ccvQsPsUn7q0+ZcJR+ufSgMEe6jcVHy/kfCGfL20l4F80B2tPIpPyibIpne62VDkVGmh/NI9JU5V20qX7lsvyZoqqiHXhL1fFtwdyzVgVP/g6YsbKgyn5jjV9w45hBbHfCUe7SQRzwPy1gnpPVfJvJctxmKYMrOmIo= 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=CL9h+rGd 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 51f46517d15d43b9; Wed, 27 Mar 2024 18:37:07 +0100 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 E6BCB66BFF7; Wed, 27 Mar 2024 18:37:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rjwysocki.net; s=dkim; t=1711561027; bh=KX4g13Xup63sTGBlrDCIfXNymgHLjpMxAiruTR8DQuM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=CL9h+rGdc5t2hRD4P9hhAuaXnvU8i5cfdd9GdUTT5OuXR+f8LWEHcPfM0kq4MDVKa ttwfuhEiSiBYmJyQmlkaxLQSnGnaopGTspfgH4nvW/RToL0/4IwZODxa5QT+cUzQzG 0pGOwC3RPDghBLTnw6gm+1/TTWiQJYOLj9JPfxTIArOmMVQ7+RCSblQo1L/fw+leqk qMuexrnk0rAnCdSmLU0p1yeGRGbiR7UDOQiO/xw3niISW1WJf2/OaQgAj3KmXsbjbu sdu8dB4z3ioNLfhN3m2x/PcgN6c5ti4HCtd6BUBfzf//7Ctp+c+/fXkbOfyUV+cZdk r8z1AghcTXVJw== From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , Srinivas Pandruvada , Stanislaw Gruszka , Daniel Lezcano , Lukasz Luba , AngeloGioacchino Del Regno Subject: [Update][PATCH v2.1 1/3] thermal: core: Move threshold out of struct thermal_trip Date: Wed, 27 Mar 2024 18:37:06 +0100 Message-ID: <5787324.DvuYhMxLoT@kreacher> In-Reply-To: <1894658.tdWV9SEqCh@kreacher> References: <2331888.ElGaqSPkdT@kreacher> <1894658.tdWV9SEqCh@kreacher> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: gggruggvucftvghtrhhoucdtuddrgedvledrudduiedgjeekucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgjfhgggfgtsehtqhertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepkeeileehffelfefggfdtjedvkeettdejfeevueegfedvhffgudeuteeigfeileetnecuffhomhgrihhnpehkvghrnhgvlhdrohhrghenucfkphepudelhedrudefiedrudelrdelgeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeduleehrddufeeirdduledrleegpdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhnsggprhgtphhtthhopeejpdhrtghpthhtoheplhhinhhugidqphhmsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepshhrihhnihhvrghsrdhprghnughruhhvrggurgeslhhinhhugidrihhnthgvlhdrtghomhdprhgtphhtthhopehs thgrnhhishhlrgifrdhgrhhushiikhgrsehlihhnuhigrdhinhhtvghlrdgtohhmpdhrtghpthhtohepuggrnhhivghlrdhlvgiitggrnhhosehlihhnrghrohdrohhrghdprhgtphhtthhopehluhhkrghsiidrlhhusggrsegrrhhmrdgtohhm X-DCC--Metrics: v370.home.net.pl 1024; Body=7 Fuz1=7 Fuz2=7 =46rom: Rafael J. Wysocki The threshold field in struct thermal_trip is only used internally by the thermal core and it is better to prevent drivers from misusing it. It also takes some space unnecessarily in the trip tables passed by drivers to the core during thermal zone registration. =46or this reason, introduce struct thermal_trip_desc as a wrapper around struct thermal_trip, move the threshold field directly into it and make the thermal core store struct thermal_trip_desc objects in the internal thermal zone trip tables. Adjust all of the code using trip tables in the thermal core accordingly. No intentional function impact. Signed-off-by: Rafael J. Wysocki =2D-- v2 -> v2.1: * Rebase on top of https://lore.kernel.org/linux-pm/20240325222424.4179635-1-daniel.lezca= no@linaro.org/ =2D-- drivers/thermal/gov_fair_share.c | 7 +++-- drivers/thermal/gov_power_allocator.c | 6 ++-- drivers/thermal/thermal_core.c | 46 +++++++++++++++++++----------= =2D---- drivers/thermal/thermal_core.h | 7 +++-- drivers/thermal/thermal_debugfs.c | 6 ++-- drivers/thermal/thermal_helpers.c | 8 +++-- drivers/thermal/thermal_netlink.c | 6 ++-- drivers/thermal/thermal_sysfs.c | 20 +++++++------- drivers/thermal/thermal_trip.c | 15 +++++------ include/linux/thermal.h | 9 ++++-- 10 files changed, 78 insertions(+), 52 deletions(-) Index: linux-pm/include/linux/thermal.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 =2D-- linux-pm.orig/include/linux/thermal.h +++ linux-pm/include/linux/thermal.h @@ -61,7 +61,6 @@ enum thermal_notify_event { * struct thermal_trip - representation of a point in temperature domain * @temperature: temperature value in miliCelsius * @hysteresis: relative hysteresis in miliCelsius =2D * @threshold: trip crossing notification threshold miliCelsius * @type: trip point type * @priv: pointer to driver data associated with this trip * @flags: flags representing binary properties of the trip @@ -69,12 +68,16 @@ enum thermal_notify_event { struct thermal_trip { int temperature; int hysteresis; =2D int threshold; enum thermal_trip_type type; u8 flags; void *priv; }; =20 +struct thermal_trip_desc { + struct thermal_trip trip; + int threshold; +}; + #define THERMAL_TRIP_FLAG_RW_TEMP BIT(0) #define THERMAL_TRIP_FLAG_RW_HYST BIT(1) =20 @@ -203,7 +206,7 @@ struct thermal_zone_device { #ifdef CONFIG_THERMAL_DEBUGFS struct thermal_debugfs *debugfs; #endif =2D struct thermal_trip trips[] __counted_by(num_trips); + struct thermal_trip_desc trips[] __counted_by(num_trips); }; =20 /** 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 =2D-- linux-pm.orig/drivers/thermal/thermal_core.c +++ linux-pm/drivers/thermal/thermal_core.c @@ -361,17 +361,19 @@ static void handle_critical_trips(struct } =20 static void handle_thermal_trip(struct thermal_zone_device *tz, =2D struct thermal_trip *trip) + struct thermal_trip_desc *td) { + const struct thermal_trip *trip =3D &td->trip; + if (trip->temperature =3D=3D THERMAL_TEMP_INVALID) return; =20 if (tz->last_temperature =3D=3D THERMAL_TEMP_INVALID) { /* Initialization. */ =2D trip->threshold =3D trip->temperature; =2D if (tz->temperature >=3D trip->threshold) =2D trip->threshold -=3D trip->hysteresis; =2D } else if (tz->last_temperature < trip->threshold) { + td->threshold =3D trip->temperature; + if (tz->temperature >=3D td->threshold) + td->threshold -=3D trip->hysteresis; + } else if (tz->last_temperature < td->threshold) { /* * The trip threshold is equal to the trip temperature, unless * the latter has changed in the meantime. In either case, @@ -382,9 +384,9 @@ static void handle_thermal_trip(struct t if (tz->temperature >=3D trip->temperature) { thermal_notify_tz_trip_up(tz, trip); thermal_debug_tz_trip_up(tz, trip); =2D trip->threshold =3D trip->temperature - trip->hysteresis; + td->threshold =3D trip->temperature - trip->hysteresis; } else { =2D trip->threshold =3D trip->temperature; + td->threshold =3D trip->temperature; } } else { /* @@ -400,9 +402,9 @@ static void handle_thermal_trip(struct t if (tz->temperature < trip->temperature - trip->hysteresis) { thermal_notify_tz_trip_down(tz, trip); thermal_debug_tz_trip_down(tz, trip); =2D trip->threshold =3D trip->temperature; + td->threshold =3D trip->temperature; } else { =2D trip->threshold =3D trip->temperature - trip->hysteresis; + td->threshold =3D trip->temperature - trip->hysteresis; } } =20 @@ -458,7 +460,7 @@ static void thermal_zone_device_init(str void __thermal_zone_device_update(struct thermal_zone_device *tz, enum thermal_notify_event event) { =2D struct thermal_trip *trip; + struct thermal_trip_desc *td; =20 if (tz->suspended) return; @@ -472,8 +474,8 @@ void __thermal_zone_device_update(struct =20 tz->notify_event =3D event; =20 =2D for_each_trip(tz, trip) =2D handle_thermal_trip(tz, trip); + for_each_trip_desc(tz, td) + handle_thermal_trip(tz, td); =20 monitor_thermal_zone(tz); } @@ -766,7 +768,7 @@ int thermal_zone_bind_cooling_device(str if (trip_index < 0 || trip_index >=3D tz->num_trips) return -EINVAL; =20 =2D return thermal_bind_cdev_to_trip(tz, &tz->trips[trip_index], cdev, + return thermal_bind_cdev_to_trip(tz, &tz->trips[trip_index].trip, cdev, upper, lower, weight); } EXPORT_SYMBOL_GPL(thermal_zone_bind_cooling_device); @@ -825,7 +827,7 @@ int thermal_zone_unbind_cooling_device(s if (trip_index < 0 || trip_index >=3D tz->num_trips) return -EINVAL; =20 =2D return thermal_unbind_cdev_from_trip(tz, &tz->trips[trip_index], cdev); + return thermal_unbind_cdev_from_trip(tz, &tz->trips[trip_index].trip, cde= v); } EXPORT_SYMBOL_GPL(thermal_zone_unbind_cooling_device); =20 @@ -1221,16 +1223,19 @@ static void thermal_set_delay_jiffies(un =20 int thermal_zone_get_crit_temp(struct thermal_zone_device *tz, int *temp) { =2D int i, ret =3D -EINVAL; + const struct thermal_trip_desc *td; + int ret =3D -EINVAL; =20 if (tz->ops.get_crit_temp) return tz->ops.get_crit_temp(tz, temp); =20 mutex_lock(&tz->lock); =20 =2D for (i =3D 0; i < tz->num_trips; i++) { =2D if (tz->trips[i].type =3D=3D THERMAL_TRIP_CRITICAL) { =2D *temp =3D tz->trips[i].temperature; + for_each_trip_desc(tz, td) { + const struct thermal_trip *trip =3D &td->trip; + + if (trip->type =3D=3D THERMAL_TRIP_CRITICAL) { + *temp =3D trip->temperature; ret =3D 0; break; } @@ -1274,7 +1279,9 @@ thermal_zone_device_register_with_trips( const struct thermal_zone_params *tzp, int passive_delay, int polling_delay) { + const struct thermal_trip *trip =3D trips; struct thermal_zone_device *tz; + struct thermal_trip_desc *td; int id; int result; struct thermal_governor *governor; @@ -1339,7 +1346,8 @@ thermal_zone_device_register_with_trips( tz->device.class =3D thermal_class; tz->devdata =3D devdata; tz->num_trips =3D num_trips; =2D memcpy(tz->trips, trips, num_trips * sizeof(*trips)); + for_each_trip_desc(tz, td) + td->trip =3D *trip++; =20 thermal_set_delay_jiffies(&tz->passive_delay_jiffies, passive_delay); thermal_set_delay_jiffies(&tz->polling_delay_jiffies, polling_delay); Index: linux-pm/drivers/thermal/thermal_core.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 =2D-- linux-pm.orig/drivers/thermal/thermal_core.h +++ linux-pm/drivers/thermal/thermal_core.h @@ -120,8 +120,11 @@ void thermal_governor_update_tz(struct t enum thermal_notify_event reason); =20 /* Helpers */ =2D#define for_each_trip(__tz, __trip) \ =2D for (__trip =3D __tz->trips; __trip - __tz->trips < __tz->num_trips; __= trip++) +#define for_each_trip_desc(__tz, __td) \ + for (__td =3D __tz->trips; __td - __tz->trips < __tz->num_trips; __td++) + +#define trip_to_trip_desc(__trip) \ + container_of(__trip, struct thermal_trip_desc, trip) =20 void __thermal_zone_set_trips(struct thermal_zone_device *tz); int thermal_zone_trip_id(const struct thermal_zone_device *tz, Index: linux-pm/drivers/thermal/thermal_sysfs.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 =2D-- linux-pm.orig/drivers/thermal/thermal_sysfs.c +++ linux-pm/drivers/thermal/thermal_sysfs.c @@ -88,7 +88,7 @@ trip_point_type_show(struct device *dev, if (sscanf(attr->attr.name, "trip_point_%d_type", &trip_id) !=3D 1) return -EINVAL; =20 =2D switch (tz->trips[trip_id].type) { + switch (tz->trips[trip_id].trip.type) { case THERMAL_TRIP_CRITICAL: return sprintf(buf, "critical\n"); case THERMAL_TRIP_HOT: @@ -120,7 +120,7 @@ trip_point_temp_store(struct device *dev =20 mutex_lock(&tz->lock); =20 =2D trip =3D &tz->trips[trip_id]; + trip =3D &tz->trips[trip_id].trip; =20 if (temp !=3D trip->temperature) { if (tz->ops.set_trip_temp) { @@ -150,7 +150,7 @@ trip_point_temp_show(struct device *dev, if (sscanf(attr->attr.name, "trip_point_%d_temp", &trip_id) !=3D 1) return -EINVAL; =20 =2D return sprintf(buf, "%d\n", tz->trips[trip_id].temperature); + return sprintf(buf, "%d\n", tz->trips[trip_id].trip.temperature); } =20 static ssize_t @@ -171,7 +171,7 @@ trip_point_hyst_store(struct device *dev =20 mutex_lock(&tz->lock); =20 =2D trip =3D &tz->trips[trip_id]; + trip =3D &tz->trips[trip_id].trip; =20 if (hyst !=3D trip->hysteresis) { trip->hysteresis =3D hyst; @@ -194,7 +194,7 @@ trip_point_hyst_show(struct device *dev, if (sscanf(attr->attr.name, "trip_point_%d_hyst", &trip_id) !=3D 1) return -EINVAL; =20 =2D return sprintf(buf, "%d\n", tz->trips[trip_id].hysteresis); + return sprintf(buf, "%d\n", tz->trips[trip_id].trip.hysteresis); } =20 static ssize_t @@ -393,7 +393,7 @@ static const struct attribute_group *the */ static int create_trip_attrs(struct thermal_zone_device *tz) { =2D const struct thermal_trip *trip; + const struct thermal_trip_desc *td; struct attribute **attrs; =20 /* This function works only for zones with at least one trip */ @@ -429,8 +429,8 @@ static int create_trip_attrs(struct ther return -ENOMEM; } =20 =2D for_each_trip(tz, trip) { =2D int indx =3D thermal_zone_trip_id(tz, trip); + for_each_trip_desc(tz, td) { + int indx =3D thermal_zone_trip_id(tz, &td->trip); =20 /* create trip type attribute */ snprintf(tz->trip_type_attrs[indx].name, THERMAL_NAME_LENGTH, @@ -452,7 +452,7 @@ static int create_trip_attrs(struct ther tz->trip_temp_attrs[indx].name; tz->trip_temp_attrs[indx].attr.attr.mode =3D S_IRUGO; tz->trip_temp_attrs[indx].attr.show =3D trip_point_temp_show; =2D if (trip->flags & THERMAL_TRIP_FLAG_RW_TEMP) { + if (td->trip.flags & THERMAL_TRIP_FLAG_RW_TEMP) { tz->trip_temp_attrs[indx].attr.attr.mode |=3D S_IWUSR; tz->trip_temp_attrs[indx].attr.store =3D trip_point_temp_store; @@ -467,7 +467,7 @@ static int create_trip_attrs(struct ther tz->trip_hyst_attrs[indx].name; tz->trip_hyst_attrs[indx].attr.attr.mode =3D S_IRUGO; tz->trip_hyst_attrs[indx].attr.show =3D trip_point_hyst_show; =2D if (trip->flags & THERMAL_TRIP_FLAG_RW_HYST) { + if (td->trip.flags & THERMAL_TRIP_FLAG_RW_HYST) { tz->trip_hyst_attrs[indx].attr.attr.mode |=3D S_IWUSR; tz->trip_hyst_attrs[indx].attr.store =3D trip_point_hyst_store; 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 =2D-- linux-pm.orig/drivers/thermal/thermal_debugfs.c +++ linux-pm/drivers/thermal/thermal_debugfs.c @@ -744,7 +744,7 @@ static void tze_seq_stop(struct seq_file static int tze_seq_show(struct seq_file *s, void *v) { struct thermal_zone_device *tz =3D s->private; =2D struct thermal_trip *trip; + struct thermal_trip_desc *td; struct tz_episode *tze; const char *type; int trip_id; @@ -757,7 +757,9 @@ static int tze_seq_show(struct seq_file =20 seq_printf(s, "| trip | type | temp(=C2=B0mC) | hyst(=C2=B0mC) | dur= ation | avg(=C2=B0mC) | min(=C2=B0mC) | max(=C2=B0mC) |\n"); =20 =2D for_each_trip(tz, trip) { + for_each_trip_desc(tz, td) { + const struct thermal_trip *trip =3D &td->trip; + /* * There is no possible mitigation happening at the * critical trip point, so the stats will be always Index: linux-pm/drivers/thermal/thermal_netlink.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 =2D-- linux-pm.orig/drivers/thermal/thermal_netlink.c +++ linux-pm/drivers/thermal/thermal_netlink.c @@ -445,7 +445,7 @@ out_cancel_nest: static int thermal_genl_cmd_tz_get_trip(struct param *p) { struct sk_buff *msg =3D p->msg; =2D const struct thermal_trip *trip; + const struct thermal_trip_desc *td; struct thermal_zone_device *tz; struct nlattr *start_trip; int id; @@ -465,7 +465,9 @@ static int thermal_genl_cmd_tz_get_trip( =20 mutex_lock(&tz->lock); =20 =2D for_each_trip(tz, trip) { + for_each_trip_desc(tz, td) { + const struct thermal_trip *trip =3D &td->trip; + if (nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_ID, thermal_zone_trip_id(tz, trip)) || nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_TYPE, trip->type) || Index: linux-pm/drivers/thermal/thermal_trip.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 =2D-- linux-pm.orig/drivers/thermal/thermal_trip.c +++ linux-pm/drivers/thermal/thermal_trip.c @@ -13,11 +13,11 @@ int for_each_thermal_trip(struct thermal int (*cb)(struct thermal_trip *, void *), void *data) { =2D struct thermal_trip *trip; + struct thermal_trip_desc *td; int ret; =20 =2D for_each_trip(tz, trip) { =2D ret =3D cb(trip, data); + for_each_trip_desc(tz, td) { + ret =3D cb(&td->trip, data); if (ret) return ret; } @@ -63,7 +63,7 @@ EXPORT_SYMBOL_GPL(thermal_zone_get_num_t */ void __thermal_zone_set_trips(struct thermal_zone_device *tz) { =2D const struct thermal_trip *trip; + const struct thermal_trip_desc *td; int low =3D -INT_MAX, high =3D INT_MAX; int ret; =20 @@ -72,7 +72,8 @@ void __thermal_zone_set_trips(struct the if (!tz->ops.set_trips) return; =20 =2D for_each_trip(tz, trip) { + for_each_trip_desc(tz, td) { + const struct thermal_trip *trip =3D &td->trip; int trip_low; =20 trip_low =3D trip->temperature - trip->hysteresis; @@ -110,7 +111,7 @@ int __thermal_zone_get_trip(struct therm if (!tz || trip_id < 0 || trip_id >=3D tz->num_trips || !trip) return -EINVAL; =20 =2D *trip =3D tz->trips[trip_id]; + *trip =3D tz->trips[trip_id].trip; return 0; } EXPORT_SYMBOL_GPL(__thermal_zone_get_trip); @@ -135,7 +136,7 @@ int thermal_zone_trip_id(const struct th * Assume the trip to be located within the bounds of the thermal * zone's trips[] table. */ =2D return trip - tz->trips; + return trip_to_trip_desc(trip) - tz->trips; } void thermal_zone_trip_updated(struct thermal_zone_device *tz, const struct thermal_trip *trip) Index: linux-pm/drivers/thermal/gov_fair_share.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 =2D-- linux-pm.orig/drivers/thermal/gov_fair_share.c +++ linux-pm/drivers/thermal/gov_fair_share.c @@ -17,10 +17,13 @@ =20 static int get_trip_level(struct thermal_zone_device *tz) { =2D const struct thermal_trip *trip, *level_trip =3D NULL; + const struct thermal_trip *level_trip =3D NULL; + const struct thermal_trip_desc *td; int trip_level =3D -1; =20 =2D for_each_trip(tz, trip) { + for_each_trip_desc(tz, td) { + const struct thermal_trip *trip =3D &td->trip; + if (trip->temperature >=3D tz->temperature) continue; =20 Index: linux-pm/drivers/thermal/gov_power_allocator.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 =2D-- linux-pm.orig/drivers/thermal/gov_power_allocator.c +++ linux-pm/drivers/thermal/gov_power_allocator.c @@ -496,9 +496,11 @@ static void get_governor_trips(struct th const struct thermal_trip *first_passive =3D NULL; const struct thermal_trip *last_passive =3D NULL; const struct thermal_trip *last_active =3D NULL; =2D const struct thermal_trip *trip; + const struct thermal_trip_desc *td; + + for_each_trip_desc(tz, td) { + const struct thermal_trip *trip =3D &td->trip; =20 =2D for_each_trip(tz, trip) { switch (trip->type) { case THERMAL_TRIP_PASSIVE: if (!first_passive) { Index: linux-pm/drivers/thermal/thermal_helpers.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 =2D-- linux-pm.orig/drivers/thermal/thermal_helpers.c +++ linux-pm/drivers/thermal/thermal_helpers.c @@ -50,7 +50,7 @@ get_thermal_instance(struct thermal_zone mutex_lock(&tz->lock); mutex_lock(&cdev->lock); =20 =2D trip =3D &tz->trips[trip_index]; + trip =3D &tz->trips[trip_index].trip; =20 list_for_each_entry(pos, &tz->thermal_instances, tz_node) { if (pos->tz =3D=3D tz && pos->trip =3D=3D trip && pos->cdev =3D=3D cdev)= { @@ -82,7 +82,7 @@ EXPORT_SYMBOL(get_thermal_instance); */ int __thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp) { =2D const struct thermal_trip *trip; + const struct thermal_trip_desc *td; int crit_temp =3D INT_MAX; int ret =3D -EINVAL; =20 @@ -91,7 +91,9 @@ int __thermal_zone_get_temp(struct therm ret =3D tz->ops.get_temp(tz, temp); =20 if (IS_ENABLED(CONFIG_THERMAL_EMULATION) && tz->emul_temperature) { =2D for_each_trip(tz, trip) { + for_each_trip_desc(tz, td) { + const struct thermal_trip *trip =3D &td->trip; + if (trip->type =3D=3D THERMAL_TRIP_CRITICAL) { crit_temp =3D trip->temperature; break;