Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1019392rdb; Wed, 6 Dec 2023 06:39:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IEqMHL2Nl1um/YQerfhdfI8RRv1dHerrmIC3vQOZvIv/iKLl1+70R6vBDUGdealM4ZVHlfM X-Received: by 2002:a05:6a21:149a:b0:18f:97c:8a4f with SMTP id od26-20020a056a21149a00b0018f097c8a4fmr922326pzb.122.1701873551666; Wed, 06 Dec 2023 06:39:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701873551; cv=none; d=google.com; s=arc-20160816; b=kXni0GPtqmNe+i2WLU9c0cUNnBU9K8mDgQRDAs8hA4hqIXnryrOdUQc3syT8c+SgPk P8VnUmMrb3fOyJM9KcX3joV/ZNHCTfg2aVbjmwUirzRa1Qmdt4+v6QswEqC/c2vHcCIR 8Iy2Url5F4WU5Tj7FGpzaM3XLAsIpAiQxKXVA9ia+W+cigwQcTIQHAet7T95FgbKGl3N eXfrqozIdDym3OB4pc1T4usz9W7ntHT5LCz6mSW5AgG3a5pflmgXXBjT8FXIxHBvEM72 UAWx7d4qe3tDV8KgLdWPNuntO1Yev2yzsmHSWquyIZAuyZj2ubA5PIkej5k3r78qz+78 yCfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=Gy0xfaNC3TmuUx7S3psA+A+EQOiJknmpliCDJOGmCGs=; fh=LBoYCTwcnc4aGCO1Ky9m5KD26cM4ZwLGFt7YdcTzbHo=; b=f8iDVjAVbZcO10X4j/n2SBsTBAg4BKCg1pC4EBNgMPu366PbjlourkYBAyOnDaaqS8 zLOoNX+5vQrS7EcGSZYhp3g032u1g0C1Axf8VB1eYRIbF41+Yxa0j2pXMmw8xOfqfCFB 5DcVee7tVYzUiH3H2hqRpVSz9XkkEvTAY/u7JUq/mWLo2Kn+mXvC34W7AfkteX8srygE gRNMdbmD+dc+cvwjYDz9gfOxgvXWIhcjwW08y+AfmQTKMjRNPHHwF+q0WDGtbvgNCjKk qpeu61pzWHUlrIFG/+GsUXLr0AOGl1jzBkgfWNuzobpX4Gwo2hXQBInbhMGWa4fMzSWY QHdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RenhSSUW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id fd3-20020a056a002e8300b006cbd28f1f43si51195pfb.47.2023.12.06.06.39.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 06:39:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RenhSSUW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 06463804C63A; Wed, 6 Dec 2023 06:39:08 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378942AbjLFOit (ORCPT + 99 others); Wed, 6 Dec 2023 09:38:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378870AbjLFOis (ORCPT ); Wed, 6 Dec 2023 09:38:48 -0500 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC2301BD for ; Wed, 6 Dec 2023 06:38:53 -0800 (PST) Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-40c236624edso4733075e9.1 for ; Wed, 06 Dec 2023 06:38:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1701873532; x=1702478332; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=Gy0xfaNC3TmuUx7S3psA+A+EQOiJknmpliCDJOGmCGs=; b=RenhSSUWfvBNUjxN5b2nV8o0NZ7vKK+axTC+Ik7JwyQzohJi256+FuosE0gGG26V2p pMHihYmNZs7+GQ33eBmxNOK7mWMBq7iF+kMjhCecLLIehmp8YqrkYYiR9XBn6GjU26jj 45d4XGFYG50hJGlZQwOKaSSl7C9DN5XTlAfz4/afxFxQQed3z0T5N1TkMO85u9DT/w9J 7uSqpDVEPtKX12tluI1BiIU+VKIJY8LTTLHBLXuLM+i8I/kGTMQ91vuq9y+j5SUZW2aK UddJwWP19Kn6NvstbJzOt2afA0hxdpNouJP0NPgWjGQGFHpXpQfvQr0VAJY/T9q/aMw6 afvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701873532; x=1702478332; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Gy0xfaNC3TmuUx7S3psA+A+EQOiJknmpliCDJOGmCGs=; b=rUqHTwA6LOXMhi5OZlR07tWCDuUJh7Y8N16KVAlMOj/Z5RetTdmozHgQalIBvc1Hw3 NLSNMQiYZA1uBGbkQs4wK6ndzzhbMv+pUF/R72F1hmxMmZUMTEa9pFoCc7Gp/xBYYVHe ibrX9nWv2021eyNgrF/hGWgW9iXzC4Dg7ecej3U0ERbyB6q9K8KbAI4RBJJMFGAt7Z5R Wiq2dTS/hf3OP+QdqTVZKQDyGOkat5gapFUhJoMR5oj5kXnJgaNayvMRFXMCjx64BvhF dj5+19ZFD83JCVrR9HRiG+i9nN74wPcWRfN9v9wMSlY/zHwUV03iaMu0ge17QrMrwXBM 64Rg== X-Gm-Message-State: AOJu0YwtWC29Pqy1BIT/PWU1cz/52xksyundLlcTK5g5OedkEc9Uycxs 6ux710gmOePPcEYVkCduZsN9qQ== X-Received: by 2002:a05:600c:252:b0:40c:23c7:8cf7 with SMTP id 18-20020a05600c025200b0040c23c78cf7mr364518wmj.167.1701873531976; Wed, 06 Dec 2023 06:38:51 -0800 (PST) Received: from ?IPV6:2a05:6e02:1041:c10:c49e:e1a5:3210:b8c0? ([2a05:6e02:1041:c10:c49e:e1a5:3210:b8c0]) by smtp.googlemail.com with ESMTPSA id q3-20020adff783000000b003332febec90sm15062021wrp.7.2023.12.06.06.38.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 06 Dec 2023 06:38:51 -0800 (PST) Message-ID: Date: Wed, 6 Dec 2023 15:38:50 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1] thermal: trip: Send trip change notifications on all trip updates Content-Language: en-US To: "Rafael J. Wysocki" , Linux PM Cc: Srinivas Pandruvada , Zhang Rui , Linux ACPI , LKML , Lukasz Luba References: <5737811.DvuYhMxLoT@kreacher> From: Daniel Lezcano In-Reply-To: <5737811.DvuYhMxLoT@kreacher> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 06 Dec 2023 06:39:08 -0800 (PST) Hi Rafael, On 05/12/2023 20:18, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki > > The _store callbacks of the trip point temperature and hysteresis sysfs > attributes invoke thermal_notify_tz_trip_change() to send a notification > regarding the trip point change, but when trip points are updated by the > platform firmware, trip point change notifications are not sent. > > To make the behavior after a trip point change more consistent, > modify all of the 3 places where trip point temperature is updated > to use a new function called thermal_zone_set_trip_temp() for this > purpose and make that function call thermal_notify_tz_trip_change(). > > Note that trip point hysteresis can only be updated via sysfs and > trip_point_hyst_store() calls thermal_notify_tz_trip_change() already, > so this code path need not be changed. Why the ACPI driver is not calling thermal_zone_device_update() after changing the trip point like the other drivers? It would make sense to have the thermal framework to be notified about this change and check if there is a trip violation, no ? > Signed-off-by: Rafael J. Wysocki > --- > > Depends on https://lore.kernel.org/linux-pm/12337662.O9o76ZdvQC@kreacher/ > > --- > drivers/acpi/thermal.c | 7 +++-- > drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c | 8 +++--- > drivers/thermal/thermal_sysfs.c | 4 +-- > drivers/thermal/thermal_trip.c | 14 ++++++++++- > include/linux/thermal.h | 2 + > 5 files changed, 27 insertions(+), 8 deletions(-) > > Index: linux-pm/drivers/thermal/thermal_sysfs.c > =================================================================== > --- linux-pm.orig/drivers/thermal/thermal_sysfs.c > +++ linux-pm/drivers/thermal/thermal_sysfs.c > @@ -146,9 +146,9 @@ trip_point_temp_store(struct device *dev > goto unlock; > } > > - trip->temperature = temp; > + thermal_zone_set_trip_temp(tz, trip, temp); > > - thermal_zone_trip_updated(tz, trip); > + __thermal_zone_device_update(tz, THERMAL_TRIP_CHANGED); > } > > unlock: > Index: linux-pm/drivers/thermal/thermal_trip.c > =================================================================== > --- linux-pm.orig/drivers/thermal/thermal_trip.c > +++ linux-pm/drivers/thermal/thermal_trip.c > @@ -152,7 +152,6 @@ int thermal_zone_trip_id(struct thermal_ > */ > return trip - tz->trips; > } > - > void thermal_zone_trip_updated(struct thermal_zone_device *tz, > const struct thermal_trip *trip) > { > @@ -161,3 +160,16 @@ void thermal_zone_trip_updated(struct th > trip->hysteresis); > __thermal_zone_device_update(tz, THERMAL_TRIP_CHANGED); > } > + > +void thermal_zone_set_trip_temp(struct thermal_zone_device *tz, > + struct thermal_trip *trip, int temp) > +{ > + if (trip->temperature == temp) > + return; > + > + trip->temperature = temp; > + thermal_notify_tz_trip_change(tz->id, thermal_zone_trip_id(tz, trip), > + trip->type, trip->temperature, > + trip->hysteresis); > +} > +EXPORT_SYMBOL_GPL(thermal_zone_set_trip_temp); > Index: linux-pm/include/linux/thermal.h > =================================================================== > --- linux-pm.orig/include/linux/thermal.h > +++ linux-pm/include/linux/thermal.h > @@ -289,6 +289,8 @@ int thermal_zone_for_each_trip(struct th > int (*cb)(struct thermal_trip *, void *), > void *data); > int thermal_zone_get_num_trips(struct thermal_zone_device *tz); > +void thermal_zone_set_trip_temp(struct thermal_zone_device *tz, > + struct thermal_trip *trip, int temp); > > int thermal_zone_get_crit_temp(struct thermal_zone_device *tz, int *temp); > > Index: linux-pm/drivers/acpi/thermal.c > =================================================================== > --- linux-pm.orig/drivers/acpi/thermal.c > +++ linux-pm/drivers/acpi/thermal.c > @@ -294,6 +294,7 @@ static int acpi_thermal_adjust_trip(stru > struct acpi_thermal_trip *acpi_trip = trip->priv; > struct adjust_trip_data *atd = data; > struct acpi_thermal *tz = atd->tz; > + int temp; > > if (!acpi_trip || !acpi_thermal_trip_valid(acpi_trip)) > return 0; > @@ -304,9 +305,11 @@ static int acpi_thermal_adjust_trip(stru > acpi_thermal_update_trip_devices(tz, trip); > > if (acpi_thermal_trip_valid(acpi_trip)) > - trip->temperature = acpi_thermal_temp(tz, acpi_trip->temp_dk); > + temp = acpi_thermal_temp(tz, acpi_trip->temp_dk); > else > - trip->temperature = THERMAL_TEMP_INVALID; > + temp = THERMAL_TEMP_INVALID; > + > + thermal_zone_set_trip_temp(tz->thermal_zone, trip, temp); > > return 0; > } > Index: linux-pm/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c > =================================================================== > --- linux-pm.orig/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c > +++ linux-pm/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c > @@ -225,7 +225,8 @@ EXPORT_SYMBOL_GPL(int340x_thermal_zone_r > > static int int340x_update_one_trip(struct thermal_trip *trip, void *arg) > { > - struct acpi_device *zone_adev = arg; > + struct int34x_thermal_zone *int34x_zone = arg; > + struct acpi_device *zone_adev = int34x_zone->adev; > int temp, err; > > switch (trip->type) { > @@ -249,14 +250,15 @@ static int int340x_update_one_trip(struc > if (err) > temp = THERMAL_TEMP_INVALID; > > - trip->temperature = temp; > + thermal_zone_set_trip_temp(int34x_zone->zone, trip, temp); > + > return 0; > } > > void int340x_thermal_update_trips(struct int34x_thermal_zone *int34x_zone) > { > thermal_zone_for_each_trip(int34x_zone->zone, int340x_update_one_trip, > - int34x_zone->adev); > + int34x_zone); > } > EXPORT_SYMBOL_GPL(int340x_thermal_update_trips); > > > > -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog