Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2842288rdb; Mon, 4 Dec 2023 08:56:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IGDfeqXePYxW60YDkB3fnAOM/FhKmtMNSpOY3oEup7wWh/sQrrDJ3gIDcnm849/myf0GOTT X-Received: by 2002:a05:6a20:3ca0:b0:18f:97c:8a1f with SMTP id b32-20020a056a203ca000b0018f097c8a1fmr5978202pzj.74.1701708980783; Mon, 04 Dec 2023 08:56:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701708980; cv=none; d=google.com; s=arc-20160816; b=meVo7cMDqXtluo0a4T6u/WLjgnDwrvKgc+AhYOWhz4KvPn+tgxNtj5Bm2q1wW+4/A/ omitUznL0a3jZRksOHsaTohowLyrFDfC4K/Sv0Zt2tZZEv85GQ/GSqtn//NHVS/b3FZm GqXsaxiPvbv1UuzDXLTV0LX6GUHWC/JVgRscd1ZeaicwDJYOdjh+osBnfFzIDBQP7Gm1 gt2HfD57sKpyet9p1nLePksJsNmQfxxmKSwxr1o/hb1PdlmjuJK1UZl1cyFMFaratIFm mrptzUzlkqxUd4Jcxj2swmq8NgBQ8AuInEA6ngw2REWMRgqW8BjoTbV/M66x9FbXghza QS2g== 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=3gdwaTpLNBr7sA7AwFQ/+pGFdvl9soWUtB8Z1U9cjJk=; fh=WD3PUBwbKW+eURwNczkCMPvWicegbE0hVFODSxn7LTw=; b=QEUfV6m5x9eSjppLc2BbaUzokY6IMJ4sShXZRxEwlMf50RIbzvp3GHyYteKsJnhk5u I6Kbh9k0a5yYGv6VzPGTfRbpE3lh0WGXSkQgUC/MUUpFFK6LibVeS8rBpJwzRXPQZJXh DpmoEmNg80fJbLHxfHC7VYGllOaHU1GWgISk02glaM4e/jvk/rgq8P9zNSP1BW06LZaG +I88Z27rv0Gw2XfBr3wJAZIskNND9Dv9AJ8wMJnxOmCddQ/m2EGHVQPRMa2oGLXbc3AX myfV/EltkrzxuPXUsYS6y0p/0TMcIyrHQ4+HhRgArUjH+XVlshu7lssvK5hGmXMb+kZz 09Xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=H24e38KD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id n22-20020a63ee56000000b005c6125b1731si4139327pgk.547.2023.12.04.08.56.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 08:56:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=H24e38KD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id D6B12807757F; Mon, 4 Dec 2023 08:55:36 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230043AbjLDQzY (ORCPT + 99 others); Mon, 4 Dec 2023 11:55:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229561AbjLDQzX (ORCPT ); Mon, 4 Dec 2023 11:55:23 -0500 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE7FCBB for ; Mon, 4 Dec 2023 08:55:27 -0800 (PST) Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-40c05ce04a8so23871745e9.0 for ; Mon, 04 Dec 2023 08:55:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1701708926; x=1702313726; 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=3gdwaTpLNBr7sA7AwFQ/+pGFdvl9soWUtB8Z1U9cjJk=; b=H24e38KDCSflSRDhe/MKHM50QJuvaWyLD7eewxK7UTV9jsIiyrLyBxLsN4ujkLbTY0 x9qS/rwx0/lchdnATxx0TzmKD2Ci0jkb3cdzmAdkwTivkh7RK2bl8jFxeBART0rO4M/X VFrlpEc4qvAl6RUi6vuT20CwrmPGUOkM1fln/IEqMkx3GJSiCAWUHGns5JmjXUyN/ZPY NnHVyJ7qzde9WgzrfdVnRcKkApLjRUO3I4PDmM468zUomHYA0EFFMEZWGa9LzSOIIaTE EIAFF9AA1kbiJY4t96afrcaIPkZ9BplJaA+7wUHtcEkATtq3KfaAAVkJvTXpgWpW0SY8 9VwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701708926; x=1702313726; 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=3gdwaTpLNBr7sA7AwFQ/+pGFdvl9soWUtB8Z1U9cjJk=; b=d98xeuz4PadOVXjxkT8cEod29x81XUSloj4fMNhOjI8mAYsmsyeYzjqR6AUZf4Sg/E EQMVaRQVi/+NIdihZghjPRKTPGoYayD/sAd4I4idcApnvUxpzzgjAbkwCJgS0bwCRbvB YJTa+5trOaG3NRKSK/xFVkKQ3dvuE0NddXS/skvVldcHDT3/23Up5WrEzVlAaAj+0bTn rHAl8XMV6pk1KH9nZJxwILA6kPySEDioKawb8ypySaMnkDykw8bXKaDP7tzbXMB64kOK yqCMdvXO0zpeTVR1X0Er52aLbl1FDR94UXE9oPxWMblpyFjQx+EL7oWQ2QSzneT6k9fe Ldyg== X-Gm-Message-State: AOJu0YxOs0Crh2womgogT1rAB0lNSUmpsJwHD/kdbMZ37DvsqbNaRAqh GOqnsppJw+v2WLBJpb3KGNCJOg== X-Received: by 2002:a05:600c:851a:b0:40b:5392:7ee9 with SMTP id gw26-20020a05600c851a00b0040b53927ee9mr1258612wmb.0.1701708925944; Mon, 04 Dec 2023 08:55:25 -0800 (PST) Received: from ?IPV6:2a05:6e02:1041:c10:c831:1e47:2:5b96? ([2a05:6e02:1041:c10:c831:1e47:2:5b96]) by smtp.googlemail.com with ESMTPSA id o15-20020a05600c510f00b004064cd71aa8sm14340224wms.34.2023.12.04.08.55.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 04 Dec 2023 08:55:25 -0800 (PST) Message-ID: Date: Mon, 4 Dec 2023 17:55:24 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 1/2] thermal: sysfs: Rework the handling of trip point updates Content-Language: en-US To: "Rafael J. Wysocki" , Lukasz Luba Cc: Linux PM , LKML , Srinivas Pandruvada , Zhang Rui References: <12338384.O9o76ZdvQC@kreacher> <4883151.31r3eYUQgx@kreacher> From: Daniel Lezcano In-Reply-To: <4883151.31r3eYUQgx@kreacher> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Mon, 04 Dec 2023 08:55:37 -0800 (PST) Hi Rafael, On 04/12/2023 15:50, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki > > Both trip_point_temp_store() and trip_point_hyst_store() use > thermal_zone_set_trip() to update a given trip point, but none of them > actually needs to change more than one field in struct thermal_trip > representing it. However, each of them effectively calls > __thermal_zone_get_trip() twice in a row for the same trip index value, > once directly and once via thermal_zone_set_trip(), which is not > particularly efficient, and the way in which thermal_zone_set_trip() > carries out the update is not particularly straightforward. > > Moreover, input processing need not be done under the thermal zone lock > in any of these functions. > > Rework trip_point_temp_store() and trip_point_hyst_store() to address > the above, move the part of thermal_zone_set_trip() that is still > useful to a new function called thermal_zone_trip_updated() and drop > the rest of it. > > While at it, make trip_point_hyst_store() reject negative hysteresis > values. > > Signed-off-by: Rafael J. Wysocki > --- > > v2 -> v3: No changes > > v1 -> v2: Still check device_is_registered() under the zone lock > > --- > drivers/thermal/thermal_core.h | 2 + > drivers/thermal/thermal_sysfs.c | 75 ++++++++++++++++++++++++++++------------ > drivers/thermal/thermal_trip.c | 45 ++++-------------------- > include/linux/thermal.h | 4 -- > 4 files changed, 64 insertions(+), 62 deletions(-) > > Index: linux-pm/drivers/thermal/thermal_sysfs.c > =================================================================== > --- linux-pm.orig/drivers/thermal/thermal_sysfs.c > +++ linux-pm/drivers/thermal/thermal_sysfs.c > @@ -78,6 +78,19 @@ mode_store(struct device *dev, struct de > return count; > } > > +static int check_thermal_zone_and_trip_id(struct device *dev, > + struct thermal_zone_device *tz, > + int trip_id) > +{ > + if (!device_is_registered(dev)) > + return -ENODEV; > + > + if (trip_id < 0 || trip_id >= tz->num_trips) > + return -EINVAL; I'm not sure if this check is useful. The function is called from trip_point_*_store() which is providing the trip id from the file name parsing which is in turn built from an existing trip id. There is no reason the trip id is going to be wrong. [ ... ] -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog