Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp3356933rwb; Mon, 7 Aug 2023 12:08:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEVCPKAszoSLWin2gnDMbhNj5H0NXA7FJtcIZsQLdirHSBAwvDVcOAszMHXBGlbQwyYsI5J X-Received: by 2002:a05:6a21:7887:b0:140:324c:1255 with SMTP id bf7-20020a056a21788700b00140324c1255mr8487022pzc.54.1691435284957; Mon, 07 Aug 2023 12:08:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691435284; cv=none; d=google.com; s=arc-20160816; b=0KZMdGNUQYO2cnUt3LsOWTbMIbz0oB7zmA7+0b26CIjMdzESwNqFk++/l9X8Gg3B+w pSLNCb7HYM3mLvs/GMw8F5oOeLcumXV0YQt5Uyi76orpv8EByYTTdKe0OWYRkt9XIvL1 gSL5t6vNS0PGnvauJy6KUQ6GUlvt5FTHYOmTHKcubzaM3eto3rwXef6ZXJCe2jIkOJwH htFYqSo49ksM5ynIG+GMhdmejQtwwgeKvBT4JJ58yNFbJHdIB8RISuh2/yuq9Syehp3g VweAAN8OzKS3di2JE0CWctYNfdDgZ5/Ln5/NaubVJJ9Nt1WXqwdX5RUybTKjMBfORpqJ NSxg== 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=RIlIjbKDgaIkXBvvVymBj3ZKl60d9D23Kc9LmoR65Aw=; fh=nSKBlyqdkKNC6TThtUZnMmy3FM/UamNp3DF6XNwe6eQ=; b=PbAPi9eqimMYhJNH6lBxLmr7WMkUhhzLmVUGE3uikfUoR5DXq9kdYq91KEhSSNXfAr 7BPmXlP1BOlUM3uDPtWqpEVryvikhvyZvUIw6MrXWjPEFx4MoNeFkDMg2VfvANurouAM bgKSybuwWrhMIqA+cbKP3TyqfhD8OSIjrp5BH7TPqsi/6sVcA5AkKBRMwDRr/Y2BmCt9 YFiusQSsXsBauCV/uBZR1jwlYR1C03c5ssr7uu9zD99sXRKZT5falT0JynFn/uj9l1A9 Ov6VAL/UqCdRRLWzGxS6baU3pO4JRxfnZPlInB2b/ovO/QFmm/1EkUgrG5B69lk7wWG+ cX2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xVVmmsRG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cn11-20020a056a00340b00b00661cd40bd67si5839569pfb.314.2023.08.07.12.07.51; Mon, 07 Aug 2023 12:08:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xVVmmsRG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231417AbjHGQSF (ORCPT + 99 others); Mon, 7 Aug 2023 12:18:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231215AbjHGQR6 (ORCPT ); Mon, 7 Aug 2023 12:17:58 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA21E171A for ; Mon, 7 Aug 2023 09:17:55 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-31751d7d96eso3538176f8f.1 for ; Mon, 07 Aug 2023 09:17:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1691425074; x=1692029874; 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=RIlIjbKDgaIkXBvvVymBj3ZKl60d9D23Kc9LmoR65Aw=; b=xVVmmsRGOYQ+2FYP9Btd0rH4ipKU9RFh4BoJQ2pnAMwfnmVsKYQYhYLHZ0HgBXTYVc OFTjAvJwbYuSzepjhO+zUEkqcTkQ7PiVGEozx3immf8pASdOmoLe07HBWyuHBCiRwPXM sRHnD2FLy1hb7GZZsoMkZtYCdXcFjVwz8ZvBoTBXxY8n+WZJAvEZ6PVNxIbhwVmRaa01 X1XUO0QeG8JwzVbil2uscnaiC6saJeaSjOeFfivZ4SJeE8c6mNMth0N1djcilQSkKd1k jzG7DYmltb7Eiggv+kzXq88caUQtTFn1MdM2Ba/vDt17DI5BnLuW/iLWyrz5vDp2NmLg t+kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691425074; x=1692029874; 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=RIlIjbKDgaIkXBvvVymBj3ZKl60d9D23Kc9LmoR65Aw=; b=N1tDLcomYUv1SyyZUPMxkT/QB43A7r9/YZ0Nx51XkRmvZk4rXiaeoTBpLEJzRu1Ote HDhJ/daRAK4xGj6VBFDullCLtNKkCh9/Ue3ftk0w3UQN3FdB17ZvurBHlZOvBaK6coMv BsbhOM7pFRLDmH9YjgsE4z/29uxDyRuylyYZPenmbfQAhjXBLVvyTCvYY19CB+lZ6rm1 IYdZTWm0n560KAgnYxTuZDxN+0IQF8cAbfHYpbbhdIbChe2A9xzXG6M0a3T0uyvxpjoS x78SrsUYX8XEx3Km6KWmpUrzthfHjojHwKQH1/3zhfJXPiGWOeeCjpwp6TVnOQw3Oqcl isLA== X-Gm-Message-State: AOJu0YzJlDezJy/4Xd49mBKVC7ZNmJw9z4S2wokY1guK+acI5ph1I2qy e6bsH28yKmgK715Ldj3CrTgC1PHOzEMaeR6ayU4= X-Received: by 2002:adf:f608:0:b0:316:ff0e:81b6 with SMTP id t8-20020adff608000000b00316ff0e81b6mr6056372wrp.32.1691425074215; Mon, 07 Aug 2023 09:17:54 -0700 (PDT) Received: from [192.168.10.46] (146725694.box.freepro.com. [130.180.211.218]) by smtp.googlemail.com with ESMTPSA id j6-20020adfff86000000b003175f00e555sm10952018wrr.97.2023.08.07.09.17.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 07 Aug 2023 09:17:53 -0700 (PDT) Message-ID: <4bfabfce-574b-ed52-2956-d0d2b9502e60@linaro.org> Date: Mon, 7 Aug 2023 18:17:53 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH v4 04/10] thermal: core: Add thermal_zone_update_trip_temp() helper routine Content-Language: en-US To: "Rafael J. Wysocki" Cc: "Rafael J. Wysocki" , Linux ACPI , LKML , Linux PM , Michal Wilczynski , Zhang Rui , Srinivas Pandruvada References: <13318886.uLZWGnKmhe@kreacher> <4878513.31r3eYUQgx@kreacher> <1967710.PYKUYFuaPT@kreacher> From: Daniel Lezcano In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS 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 On 07/08/2023 17:40, Rafael J. Wysocki wrote: > On Mon, Aug 7, 2023 at 1:34 PM Daniel Lezcano wrote: >> >> On 04/08/2023 23:05, Rafael J. Wysocki wrote: >>> From: Rafael J. Wysocki >>> >>> Introduce a helper routine called thermal_zone_update_trip_temp() that >>> can be used to update a trip point's temperature with the help of a >>> pointer to local data associated with that trip point provided by >>> the thermal driver that created it. >>> >>> Signed-off-by: Rafael J. Wysocki >>> --- >>> >>> New patch in v4. >>> >>> --- >>> drivers/thermal/thermal_trip.c | 37 +++++++++++++++++++++++++++++++++++++ >>> include/linux/thermal.h | 4 ++++ >>> 2 files changed, 41 insertions(+) >>> >>> Index: linux-pm/drivers/thermal/thermal_trip.c >>> =================================================================== >>> --- linux-pm.orig/drivers/thermal/thermal_trip.c >>> +++ linux-pm/drivers/thermal/thermal_trip.c >>> @@ -180,3 +180,40 @@ int thermal_zone_set_trip(struct thermal >>> >>> return 0; >>> } >>> + >>> +/** >>> + * thermal_zone_update_trip_temp - Update the trip point temperature. >>> + * @tz: Thermal zone. >>> + * @trip_priv: Trip tag. >>> + * @temp: New trip temperature. >>> + * >>> + * This only works for thermal zones using trip tables and its caller must >>> + * ensure that the zone lock is held before using it. >>> + * >>> + * @trip_priv is expected to be the value that has been stored by the driver >>> + * in the struct thermal_trip representing the trip point in question, so it >>> + * can be matched against the value of the priv field in that structure. >>> + * >>> + * If @trip_priv does not match any trip point in the trip table of @tz, >>> + * nothing happens. >>> + */ >>> +void thermal_zone_update_trip_temp(struct thermal_zone_device *tz, >>> + void *trip_priv, int temperature) >>> +{ >>> + int i; >>> + >>> + lockdep_assert_held(&tz->lock); >>> + >>> + if (!tz->trips || !trip_priv) >>> + return; >>> + >>> + for (i = 0; i < tz->num_trips; i++) { >>> + struct thermal_trip *trip = &tz->trips[i]; >>> + >>> + if (trip->priv == trip_priv) { >>> + trip->temperature = temperature; >>> + return; >>> + } >>> + } >>> +} >>> +EXPORT_SYMBOL_GPL(thermal_zone_update_trip_temp); >> >> This function would imply the comparator is always trip->priv but if we >> want another comparison eg. trip->priv->id, that won't be possible. >> >> Actually, I think you can reuse an existing function with a simple >> change, for_each_thermal_trip() located in thermal_core.h. > > for_each_thermal_trip() is only defined in tools/lib/thermal/thermal.c > AFAICS, but this one could actually work, so I can copy that > definition to somewhere else. > > But I suppose that you mean __for_each_thermal_trip() which won't > work, because it makes a copy of the trip and passes that to the > callback, but the callback would need to update the temperature of the > original trip. > > It would work if it passed the original trip to the caller, so I can > add something like that. As there is no user of this function yet, I think you can change that to use the trip array instead of the __thermal_zone_get_trip(). This one was used to have a compatibility with thermal zones using get_trip_* ops but that is not really needed and with your series only one driver will remain before dropping these ops. >> The changes would be renaming it without the '__' prefix and moving it >> in include/linux/thermal.h. >> >> Then the comparison function and the temperature change can be an ACPI >> driver specific callback passed as parameter to for_each_thermal_zone > > I guess you mean for_each_thermal_trip(). Yes, __for_each_thermal_trip() > As per the above, not really, but I can do something along these lines. -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog