Message ID | 20240106191502.29126-1-quic_manafm@quicinc.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-18699-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:37c1:b0:101:2151:f287 with SMTP id y1csp250560dyq; Sat, 6 Jan 2024 11:17:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IGbl6JQAwhQC9yRdGSWr8ICv2QOr1ZaRErzWu+lNNXyOUlSeNlC5uUw9/tTYLS4vMSMFMXN X-Received: by 2002:a17:907:97cd:b0:a28:fe51:9ea8 with SMTP id js13-20020a17090797cd00b00a28fe519ea8mr586689ejc.89.1704568630389; Sat, 06 Jan 2024 11:17:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704568630; cv=none; d=google.com; s=arc-20160816; b=IyoaZQzt/Nk8E5wpDias8NKqF3vmGdkZtee/26uE2yTaWqYXHXEnsGaaxjLFWA0K1x /MxDQu/zzl47D0t4D1RqK9Q0xf42xIcawq9qlbvcJXAQ4kxNG7Mp4+nHmNmWUoRtkuuw j68pmhjlrNYexhvCVRqEjvAg2TqPwEJj69H8knwWl/cKWLlktGIQhjgNOg7t9WJ4rlw0 AqyHzUCYbOejK7tb7eQ14XPBvVZDrjvWZGNAyE8/xxT8lehMV2mC8Bb4XTh+9NE3bmUy ZLehyhuwm8yv6plyjtGrepVLBkV5cUP9jPa+Pu1rbGTdUEXxEIJei89J1is+BlD8hNCl WNEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:date:subject:cc:to:from:dkim-signature; bh=WKPh7IvIQvD2msUo8q8oDJlSIRzNpjO+foZ7NbVBD7Y=; fh=gvyBVuvmqiQEQIwSri7pwgQeOjGIRxY8Z1ENVjUyq+M=; b=TMq+XpBh2KE6XbWde5k+ApjmEjpuXlPp9EImwCf7bakUUgOJd3mwDtu+/+D2489yV1 huO3S0/e0KVxTxAY5UGvb5xss0AwVtTfTgZGDVUComfGgDl1IG2zWY7jwUfKrOpQCwyL MBZbm4M/oq7S7nEgsBFm64+OOTzSnOD1Dqu65fEr/3k0ICCxXIxwsLA2JlQgVdYQ692e KB2uYa2LBBfZkd/EufzvazBwbUsD4hPTYJAzx4rYq4QyhqqdGvQ/FUYnr1zW4PJ3luto 55boxz0Q/GVb9ONGsM6rA4NMUD4x9MuK1KTJkNxQgAE1wJgzWCjvV35qiptfYxMZtY0l HB7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=mkzBSV6h; spf=pass (google.com: domain of linux-kernel+bounces-18699-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18699-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id r6-20020a17090638c600b00a28b410b572si1606356ejd.13.2024.01.06.11.17.10 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Jan 2024 11:17:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-18699-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=mkzBSV6h; spf=pass (google.com: domain of linux-kernel+bounces-18699-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18699-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 073A51F22205 for <ouuuleilei@gmail.com>; Sat, 6 Jan 2024 19:17:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4D1D1F513; Sat, 6 Jan 2024 19:16:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="mkzBSV6h" X-Original-To: linux-kernel@vger.kernel.org Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 06783DF4C; Sat, 6 Jan 2024 19:16:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 406J28af002663; Sat, 6 Jan 2024 19:15:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:mime-version:content-type; s= qcppdkim1; bh=WKPh7IvIQvD2msUo8q8oDJlSIRzNpjO+foZ7NbVBD7Y=; b=mk zBSV6hRIGDBTvzZVt6pO7ERtsyePf6+pqA2Z3kf2O/V8etCmXaV6XZ5zhV3xDVfT SP/s2ZNL9M9Por2qoZm5p0XGDB5ATwg8W4r44rEtzZeA+FHPveLEeuoiqcrUGj/D u9NwbaTNPHBlGC3xqjyywOLBAWE8HPmBWcA1NkpKeZiUQzV3JbpfisQR2JuhEGEZ oXMnkVGSORjVMyLkEocyeJPDAUVPmnpJ/s4VlAU36hG/Elx6VcXoKAT0HBRXg5zH sxO8NCJCYv8HwS5NADSTeD3GkwhHTka9U2A+42xAhMhW9ejJNsoC+MuHeRotWZFU mk2/12cN7wMfSe9zF4pA== Received: from nasanppmta03.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3veymm91kq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 06 Jan 2024 19:15:26 +0000 (GMT) Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 406JFPqH030897 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 6 Jan 2024 19:15:25 GMT Received: from codeaurora.org (10.80.80.8) by nasanex01c.na.qualcomm.com (10.45.79.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Sat, 6 Jan 2024 11:15:23 -0800 From: Manaf Meethalavalappu Pallikunhi <quic_manafm@quicinc.com> To: "Rafael J . Wysocki" <rafael@kernel.org>, Daniel Lezcano <daniel.lezcano@linaro.org>, Zhang Rui <rui.zhang@intel.com>, Lukasz Luba <lukasz.luba@arm.com> CC: <linux-pm@vger.kernel.org>, <linux-kernel@vger.kernel.org>, "Manaf Meethalavalappu Pallikunhi" <quic_manafm@quicinc.com> Subject: [PATCH] thermal/sysfs: Always enable hysteresis write support Date: Sun, 7 Jan 2024 00:45:02 +0530 Message-ID: <20240106191502.29126-1-quic_manafm@quicinc.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Type: text/plain X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01c.na.qualcomm.com (10.45.79.139) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: Mqo0o9bUz5b5aII9FhGjleUms7yd-vG9 X-Proofpoint-GUID: Mqo0o9bUz5b5aII9FhGjleUms7yd-vG9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-09_01,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1011 impostorscore=0 mlxlogscore=748 spamscore=0 phishscore=0 malwarescore=0 bulkscore=0 suspectscore=0 adultscore=0 mlxscore=0 priorityscore=1501 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2311290000 definitions=main-2401060128 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787369756343174542 X-GMAIL-MSGID: 1787369756343174542 |
Series |
thermal/sysfs: Always enable hysteresis write support
|
|
Commit Message
Manaf Meethalavalappu Pallikunhi
Jan. 6, 2024, 7:15 p.m. UTC
The commit 2e38a2a981b2("thermal/core: Add a generic
thermal_zone_set_trip() function") adds the support to update
trip hysteresis even if set_trip_hyst() operation is not defined.
But during hysteresis attribute creation, if this operation is
defined then only it enables hysteresis write access. It leads
to a case where hysteresis sysfs will be read only for a thermal
zone when its set_trip_hyst() operation is not defined.
Fix this by removing the check whether set_trip_hyst() operation
is defined or not during hysteresis attribute initialization.
Signed-off-by: Manaf Meethalavalappu Pallikunhi <quic_manafm@quicinc.com>
---
drivers/thermal/thermal_sysfs.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
Comments
On Sat, Jan 6, 2024 at 8:16 PM Manaf Meethalavalappu Pallikunhi <quic_manafm@quicinc.com> wrote: > > The commit 2e38a2a981b2("thermal/core: Add a generic > thermal_zone_set_trip() function") adds the support to update > trip hysteresis even if set_trip_hyst() operation is not defined. > But during hysteresis attribute creation, if this operation is > defined then only it enables hysteresis write access. It leads > to a case where hysteresis sysfs will be read only for a thermal > zone when its set_trip_hyst() operation is not defined. Which is by design. For some thermal zone types (eg. acpi), updating trip hysteresis via sysfs might lead to incorrect behavior.
Resending to reflect to format Hi Rafael, On 1/9/2024 7:12 PM, Rafael J. Wysocki wrote: > On Sat, Jan 6, 2024 at 8:16 PM Manaf Meethalavalappu Pallikunhi > <quic_manafm@quicinc.com> wrote: >> The commit 2e38a2a981b2("thermal/core: Add a generic >> thermal_zone_set_trip() function") adds the support to update >> trip hysteresis even if set_trip_hyst() operation is not defined. >> But during hysteresis attribute creation, if this operation is >> defined then only it enables hysteresis write access. It leads >> to a case where hysteresis sysfs will be read only for a thermal >> zone when its set_trip_hyst() operation is not defined. I think it is regression after recent re-work. If a sensor is registered witht thermal framework via thermal_of, sensor driver doesn't need to know the trip configuration and nothing to do with set_trip_hyst() in driver. Without this change, if a sensor needs to be monitored from userspace(trip/hysteresis), it is enforcing sensor driver to add dummy set_trip_hyst() operation. Correct me otherwise. > Which is by design. > > For some thermal zone types (eg. acpi), updating trip hysteresis via > sysfs might lead to incorrect behavior. To address this, is it okay to guard hysteresis write permission under CONFIG_THERMAL_WRITABLE_TRIPS flag ? Thanks, Manaf
Hi Manaf, On Wed, Jan 10, 2024 at 9:17 AM Manaf Meethalavalappu Pallikunhi <quic_manafm@quicinc.com> wrote: > > Hi Rafael, > > On 1/9/2024 7:12 PM, Rafael J. Wysocki wrote: > > On Sat, Jan 6, 2024 at 8:16 PM Manaf Meethalavalappu Pallikunhi > <quic_manafm@quicinc.com> wrote: > > The commit 2e38a2a981b2("thermal/core: Add a generic > thermal_zone_set_trip() function") adds the support to update > trip hysteresis even if set_trip_hyst() operation is not defined. > But during hysteresis attribute creation, if this operation is > defined then only it enables hysteresis write access. It leads > to a case where hysteresis sysfs will be read only for a thermal > zone when its set_trip_hyst() operation is not defined. > > Which is by design. > > I think it is regression after recent re-work. If a sensor is registered with thermal framework via thermal_of, > > sensor driver doesn't need to know the trip configuration and nothing to do with set_trip_hyst() in driver. > > Without this change, if a sensor needs to be monitored from userspace(trip/hysteresis), What exactly do you mean by "monitored" here? > it is enforcing sensor driver to add dummy set_trip_hyst() operation. Correct me otherwise With the current design, whether or not trip properties can be updated by user space is a thermal zone property expressed by the presence of the set_trip_* operations, so yes, whoever registers the thermal zone needs to provide those so that user space can update the trip properties. > For some thermal zone types (eg. acpi), updating trip hysteresis via > sysfs might lead to incorrect behavior. > > To address this issue, is it okay to guard hysteresis write permission under CONFIG_THERMAL_WRITABLE_TRIPS defconfig ? Not really, because it would affect all of the thermal zones then. TBH, the exact scenario in which user space needs to update trip hysteresis is not particularly clear to me, so can you provide some more details, please? Thanks!
On Wed, Jan 10, 2024 at 1:48 PM Manaf Meethalavalappu Pallikunhi <quic_manafm@quicinc.com> wrote: > > Resending to reflect to format > > Hi Rafael, > > On 1/9/2024 7:12 PM, Rafael J. Wysocki wrote: > > On Sat, Jan 6, 2024 at 8:16 PM Manaf Meethalavalappu Pallikunhi > > <quic_manafm@quicinc.com> wrote: > >> The commit 2e38a2a981b2("thermal/core: Add a generic > >> thermal_zone_set_trip() function") adds the support to update > >> trip hysteresis even if set_trip_hyst() operation is not defined. > >> But during hysteresis attribute creation, if this operation is > >> defined then only it enables hysteresis write access. It leads > >> to a case where hysteresis sysfs will be read only for a thermal > >> zone when its set_trip_hyst() operation is not defined. > I think it is regression after recent re-work. If a sensor is > registered witht thermal framework via thermal_of, sensor driver > doesn't need to know the trip configuration and nothing to do with > set_trip_hyst() in driver. Without this change, if a sensor needs to be > monitored from userspace(trip/hysteresis), it is enforcing sensor driver > to add dummy set_trip_hyst() operation. Correct me otherwise. > > Which is by design. > > > > For some thermal zone types (eg. acpi), updating trip hysteresis via > > sysfs might lead to incorrect behavior. > > To address this, is it okay to guard hysteresis write permission under > CONFIG_THERMAL_WRITABLE_TRIPS flag ? I've already sent a reply to the original message.
Hi Rafael, On 1/10/2024 6:18 PM, Rafael J. Wysocki wrote: > Hi Manaf, > > On Wed, Jan 10, 2024 at 9:17 AM Manaf Meethalavalappu Pallikunhi > <quic_manafm@quicinc.com> wrote: >> Hi Rafael, >> >> On 1/9/2024 7:12 PM, Rafael J. Wysocki wrote: >> >> On Sat, Jan 6, 2024 at 8:16 PM Manaf Meethalavalappu Pallikunhi >> <quic_manafm@quicinc.com> wrote: >> >> The commit 2e38a2a981b2("thermal/core: Add a generic >> thermal_zone_set_trip() function") adds the support to update >> trip hysteresis even if set_trip_hyst() operation is not defined. >> But during hysteresis attribute creation, if this operation is >> defined then only it enables hysteresis write access. It leads >> to a case where hysteresis sysfs will be read only for a thermal >> zone when its set_trip_hyst() operation is not defined. >> >> Which is by design. >> >> I think it is regression after recent re-work. If a sensor is registered with thermal framework via thermal_of, >> >> sensor driver doesn't need to know the trip configuration and nothing to do with set_trip_hyst() in driver. >> >> Without this change, if a sensor needs to be monitored from userspace(trip/hysteresis), > What exactly do you mean by "monitored" here? There can be userspace thermal manager/clients(eg: thermal HAL in android, thermal manager daemon etc. ) with different trip pairs(temperature and hysteresis) for its own thermal management, temperature reporting, thermal tuning etc. This client can update trip and hysteresis dynamically via thermal zone trip point sysfs nodes for event violation notification irrespective of kernel thermal zone devicetree trip values. This was supporting until this rework without any set_trip_* ops from sensor driver. > >> it is enforcing sensor driver to add dummy set_trip_hyst() operation. Correct me otherwise > With the current design, whether or not trip properties can be updated > by user space is a thermal zone property expressed by the presence of > the set_trip_* operations, so yes, whoever registers the thermal zone If you look at current code, it is allowing to set trip temperature without set_trip_temp() operation, only hysteresis is not allowed. As I mentioned above cases, userspace sysfs update is usecase/client driven, not always a sensor driver specific requirement especially a sensor is registered via thermal_of. Not sure adding a dummy ops in every sensor driver to achieve above requirement is right solution here. > needs to provide those so that user space can update the trip > properties. > >> For some thermal zone types (eg. acpi), updating trip hysteresis via >> sysfs might lead to incorrect behavior. >> >> To address this issue, is it okay to guard hysteresis write permission under CONFIG_THERMAL_WRITABLE_TRIPS defconfig ? > Not really, because it would affect all of the thermal zones then. > > TBH, the exact scenario in which user space needs to update trip > hysteresis is not particularly clear to me, so can you provide some > more details, please? I hope I explained more information in above comment. let me know otherwise. Thanks, Manaf > > Thanks!
On 10/01/2024 13:48, Rafael J. Wysocki wrote: > Hi Manaf, > > On Wed, Jan 10, 2024 at 9:17 AM Manaf Meethalavalappu Pallikunhi > <quic_manafm@quicinc.com> wrote: >> >> Hi Rafael, >> >> On 1/9/2024 7:12 PM, Rafael J. Wysocki wrote: >> >> On Sat, Jan 6, 2024 at 8:16 PM Manaf Meethalavalappu Pallikunhi >> <quic_manafm@quicinc.com> wrote: >> >> The commit 2e38a2a981b2("thermal/core: Add a generic >> thermal_zone_set_trip() function") adds the support to update >> trip hysteresis even if set_trip_hyst() operation is not defined. >> But during hysteresis attribute creation, if this operation is >> defined then only it enables hysteresis write access. It leads >> to a case where hysteresis sysfs will be read only for a thermal >> zone when its set_trip_hyst() operation is not defined. >> >> Which is by design. >> >> I think it is regression after recent re-work. If a sensor is registered with thermal framework via thermal_of, >> >> sensor driver doesn't need to know the trip configuration and nothing to do with set_trip_hyst() in driver. >> >> Without this change, if a sensor needs to be monitored from userspace(trip/hysteresis), > > What exactly do you mean by "monitored" here? > >> it is enforcing sensor driver to add dummy set_trip_hyst() operation. Correct me otherwise > > With the current design, whether or not trip properties can be updated > by user space is a thermal zone property expressed by the presence of > the set_trip_* operations, so yes, whoever registers the thermal zone > needs to provide those so that user space can update the trip > properties. > >> For some thermal zone types (eg. acpi), updating trip hysteresis via >> sysfs might lead to incorrect behavior. >> >> To address this issue, is it okay to guard hysteresis write permission under CONFIG_THERMAL_WRITABLE_TRIPS defconfig ? > > Not really, because it would affect all of the thermal zones then. It seems like there is an inconsistency here with the writable trip points and the writable hysteresis [1]. My understanding is it does not make sense to have the hysteresis writable even if the driver has a hysteresis dedicated ops. The code allowing to change the hysteresis was done regardless the consistency with the trip temperature change and writable trip points kernel option IMO. It would make sense to have: if enabled(CONFIG_WRITABLE_TRIP_POINT) -> trip_temp RW -> trip_hyst RW else -> trip temp RO -> trip hyst RO fi But if the interface exists since a long time, we may not want to change it, right ? However, we can take the opportunity to introduce a new 'user' trip point type in order to let the userspace to have dedicated trip point and receive temperature notifications [2] > TBH, the exact scenario in which user space needs to update trip > hysteresis is not particularly clear to me, so can you provide some > more details, please? IIUC changing the hysteresis value is useful because the temperature speed will vary given the thermal contribution of the components surrounding the thermal zone, that includes the ambient temperature. However, that may apply to slow speed temperature sensor like the skin temperature sensor where we may to do small hysteresis variation. The places managed by the kernel have an insane temperature transition speed. The userspace is unable to follow this speed and manage the hysteresis on the fly. So that brings us to userspace trip point handling again. -- Daniel [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/ABI/testing/sysfs-class-thermal?h=v6.7#n66 [2] https://lpc.events/event/17/contributions/1423/contribution.pdf
On Wed, Jan 17, 2024 at 5:57 PM Daniel Lezcano <daniel.lezcano@linaro.org> wrote: > > On 10/01/2024 13:48, Rafael J. Wysocki wrote: > > Hi Manaf, > > > > On Wed, Jan 10, 2024 at 9:17 AM Manaf Meethalavalappu Pallikunhi > > <quic_manafm@quicinc.com> wrote: > >> > >> Hi Rafael, > >> > >> On 1/9/2024 7:12 PM, Rafael J. Wysocki wrote: > >> > >> On Sat, Jan 6, 2024 at 8:16 PM Manaf Meethalavalappu Pallikunhi > >> <quic_manafm@quicinc.com> wrote: > >> > >> The commit 2e38a2a981b2("thermal/core: Add a generic > >> thermal_zone_set_trip() function") adds the support to update > >> trip hysteresis even if set_trip_hyst() operation is not defined. > >> But during hysteresis attribute creation, if this operation is > >> defined then only it enables hysteresis write access. It leads > >> to a case where hysteresis sysfs will be read only for a thermal > >> zone when its set_trip_hyst() operation is not defined. > >> > >> Which is by design. > >> > >> I think it is regression after recent re-work. If a sensor is registered with thermal framework via thermal_of, > >> > >> sensor driver doesn't need to know the trip configuration and nothing to do with set_trip_hyst() in driver. > >> > >> Without this change, if a sensor needs to be monitored from userspace(trip/hysteresis), > > > > What exactly do you mean by "monitored" here? > > > >> it is enforcing sensor driver to add dummy set_trip_hyst() operation. Correct me otherwise > > > > With the current design, whether or not trip properties can be updated > > by user space is a thermal zone property expressed by the presence of > > the set_trip_* operations, so yes, whoever registers the thermal zone > > needs to provide those so that user space can update the trip > > properties. > > > >> For some thermal zone types (eg. acpi), updating trip hysteresis via > >> sysfs might lead to incorrect behavior. > >> > >> To address this issue, is it okay to guard hysteresis write permission under CONFIG_THERMAL_WRITABLE_TRIPS defconfig ? > > > > Not really, because it would affect all of the thermal zones then. > > It seems like there is an inconsistency here with the writable trip > points and the writable hysteresis [1]. > > My understanding is it does not make sense to have the hysteresis > writable even if the driver has a hysteresis dedicated ops. The code > allowing to change the hysteresis was done regardless the consistency > with the trip temperature change and writable trip points kernel option IMO. > > It would make sense to have: > > if enabled(CONFIG_WRITABLE_TRIP_POINT) > -> trip_temp RW > -> trip_hyst RW > else > -> trip temp RO > -> trip hyst RO > fi > > But if the interface exists since a long time, we may not want to change > it, right ? If the platform firmware implements hysteresis by changing trip temperature (as recommended by the ACPI specification, for example), modifying the trip hysteresis via sysfs is simply incorrect and user space may not know that. > However, we can take the opportunity to introduce a new 'user' trip > point type in order to let the userspace to have dedicated trip point > and receive temperature notifications [2] > > > TBH, the exact scenario in which user space needs to update trip > > hysteresis is not particularly clear to me, so can you provide some > > more details, please? > > IIUC changing the hysteresis value is useful because the temperature > speed will vary given the thermal contribution of the components > surrounding the thermal zone, that includes the ambient temperature. > > However, that may apply to slow speed temperature sensor like the skin > temperature sensor where we may to do small hysteresis variation. > > The places managed by the kernel have an insane temperature transition > speed. The userspace is unable to follow this speed and manage the > hysteresis on the fly. > > So that brings us to userspace trip point handling again. Well, I've already said that whether hysteresis can be modified via sysfs is a property of a thermal zone. It may as well be a trip property, for example expressed via a (new) trip flag set in the trips table used for thermal zone registration.
On 17/01/2024 19:49, Rafael J. Wysocki wrote: > On Wed, Jan 17, 2024 at 5:57 PM Daniel Lezcano > <daniel.lezcano@linaro.org> wrote: >> >> On 10/01/2024 13:48, Rafael J. Wysocki wrote: >>> Hi Manaf, >>> >>> On Wed, Jan 10, 2024 at 9:17 AM Manaf Meethalavalappu Pallikunhi >>> <quic_manafm@quicinc.com> wrote: >>>> >>>> Hi Rafael, >>>> >>>> On 1/9/2024 7:12 PM, Rafael J. Wysocki wrote: >>>> >>>> On Sat, Jan 6, 2024 at 8:16 PM Manaf Meethalavalappu Pallikunhi >>>> <quic_manafm@quicinc.com> wrote: >>>> >>>> The commit 2e38a2a981b2("thermal/core: Add a generic >>>> thermal_zone_set_trip() function") adds the support to update >>>> trip hysteresis even if set_trip_hyst() operation is not defined. >>>> But during hysteresis attribute creation, if this operation is >>>> defined then only it enables hysteresis write access. It leads >>>> to a case where hysteresis sysfs will be read only for a thermal >>>> zone when its set_trip_hyst() operation is not defined. >>>> >>>> Which is by design. >>>> >>>> I think it is regression after recent re-work. If a sensor is registered with thermal framework via thermal_of, >>>> >>>> sensor driver doesn't need to know the trip configuration and nothing to do with set_trip_hyst() in driver. >>>> >>>> Without this change, if a sensor needs to be monitored from userspace(trip/hysteresis), >>> >>> What exactly do you mean by "monitored" here? >>> >>>> it is enforcing sensor driver to add dummy set_trip_hyst() operation. Correct me otherwise >>> >>> With the current design, whether or not trip properties can be updated >>> by user space is a thermal zone property expressed by the presence of >>> the set_trip_* operations, so yes, whoever registers the thermal zone >>> needs to provide those so that user space can update the trip >>> properties. >>> >>>> For some thermal zone types (eg. acpi), updating trip hysteresis via >>>> sysfs might lead to incorrect behavior. >>>> >>>> To address this issue, is it okay to guard hysteresis write permission under CONFIG_THERMAL_WRITABLE_TRIPS defconfig ? >>> >>> Not really, because it would affect all of the thermal zones then. >> >> It seems like there is an inconsistency here with the writable trip >> points and the writable hysteresis [1]. >> >> My understanding is it does not make sense to have the hysteresis >> writable even if the driver has a hysteresis dedicated ops. The code >> allowing to change the hysteresis was done regardless the consistency >> with the trip temperature change and writable trip points kernel option IMO. >> >> It would make sense to have: >> >> if enabled(CONFIG_WRITABLE_TRIP_POINT) >> -> trip_temp RW >> -> trip_hyst RW >> else >> -> trip temp RO >> -> trip hyst RO >> fi >> >> But if the interface exists since a long time, we may not want to change >> it, right ? > > If the platform firmware implements hysteresis by changing trip > temperature (as recommended by the ACPI specification, for example), > modifying the trip hysteresis via sysfs is simply incorrect and user > space may not know that. > >> However, we can take the opportunity to introduce a new 'user' trip >> point type in order to let the userspace to have dedicated trip point >> and receive temperature notifications [2] >> >>> TBH, the exact scenario in which user space needs to update trip >>> hysteresis is not particularly clear to me, so can you provide some >>> more details, please? >> >> IIUC changing the hysteresis value is useful because the temperature >> speed will vary given the thermal contribution of the components >> surrounding the thermal zone, that includes the ambient temperature. >> >> However, that may apply to slow speed temperature sensor like the skin >> temperature sensor where we may to do small hysteresis variation. >> >> The places managed by the kernel have an insane temperature transition >> speed. The userspace is unable to follow this speed and manage the >> hysteresis on the fly. >> >> So that brings us to userspace trip point handling again. > > Well, I've already said that whether hysteresis can be modified via > sysfs is a property of a thermal zone. > It may as well be a trip property, for example expressed via a (new) > trip flag set in the trips table used for thermal zone registration. Yes, a trip property makes more sense. I'm a bit lost about WRITABLE_TRIP_POINT, writable hysteresis, read-only temperature trip. Can we have a hysteresis writable but not the temperature ? You mentioned above "modifying the trip hysteresis via sysfs is simply incorrect", so shall we allow that at the end? Is it possible to recap the situation?
On Thu, Jan 18, 2024 at 11:25 AM Daniel Lezcano <daniel.lezcano@linaro.org> wrote: > > On 17/01/2024 19:49, Rafael J. Wysocki wrote: > > On Wed, Jan 17, 2024 at 5:57 PM Daniel Lezcano > > <daniel.lezcano@linaro.org> wrote: > >> > >> On 10/01/2024 13:48, Rafael J. Wysocki wrote: > >>> Hi Manaf, > >>> > >>> On Wed, Jan 10, 2024 at 9:17 AM Manaf Meethalavalappu Pallikunhi > >>> <quic_manafm@quicinc.com> wrote: > >>>> > >>>> Hi Rafael, > >>>> > >>>> On 1/9/2024 7:12 PM, Rafael J. Wysocki wrote: > >>>> > >>>> On Sat, Jan 6, 2024 at 8:16 PM Manaf Meethalavalappu Pallikunhi > >>>> <quic_manafm@quicinc.com> wrote: > >>>> > >>>> The commit 2e38a2a981b2("thermal/core: Add a generic > >>>> thermal_zone_set_trip() function") adds the support to update > >>>> trip hysteresis even if set_trip_hyst() operation is not defined. > >>>> But during hysteresis attribute creation, if this operation is > >>>> defined then only it enables hysteresis write access. It leads > >>>> to a case where hysteresis sysfs will be read only for a thermal > >>>> zone when its set_trip_hyst() operation is not defined. > >>>> > >>>> Which is by design. > >>>> > >>>> I think it is regression after recent re-work. If a sensor is registered with thermal framework via thermal_of, > >>>> > >>>> sensor driver doesn't need to know the trip configuration and nothing to do with set_trip_hyst() in driver. > >>>> > >>>> Without this change, if a sensor needs to be monitored from userspace(trip/hysteresis), > >>> > >>> What exactly do you mean by "monitored" here? > >>> > >>>> it is enforcing sensor driver to add dummy set_trip_hyst() operation. Correct me otherwise > >>> > >>> With the current design, whether or not trip properties can be updated > >>> by user space is a thermal zone property expressed by the presence of > >>> the set_trip_* operations, so yes, whoever registers the thermal zone > >>> needs to provide those so that user space can update the trip > >>> properties. > >>> > >>>> For some thermal zone types (eg. acpi), updating trip hysteresis via > >>>> sysfs might lead to incorrect behavior. > >>>> > >>>> To address this issue, is it okay to guard hysteresis write permission under CONFIG_THERMAL_WRITABLE_TRIPS defconfig ? > >>> > >>> Not really, because it would affect all of the thermal zones then. > >> > >> It seems like there is an inconsistency here with the writable trip > >> points and the writable hysteresis [1]. > >> > >> My understanding is it does not make sense to have the hysteresis > >> writable even if the driver has a hysteresis dedicated ops. The code > >> allowing to change the hysteresis was done regardless the consistency > >> with the trip temperature change and writable trip points kernel option IMO. > >> > >> It would make sense to have: > >> > >> if enabled(CONFIG_WRITABLE_TRIP_POINT) > >> -> trip_temp RW > >> -> trip_hyst RW > >> else > >> -> trip temp RO > >> -> trip hyst RO > >> fi > >> > >> But if the interface exists since a long time, we may not want to change > >> it, right ? > > > > If the platform firmware implements hysteresis by changing trip > > temperature (as recommended by the ACPI specification, for example), > > modifying the trip hysteresis via sysfs is simply incorrect and user > > space may not know that. > > > >> However, we can take the opportunity to introduce a new 'user' trip > >> point type in order to let the userspace to have dedicated trip point > >> and receive temperature notifications [2] > >> > >>> TBH, the exact scenario in which user space needs to update trip > >>> hysteresis is not particularly clear to me, so can you provide some > >>> more details, please? > >> > >> IIUC changing the hysteresis value is useful because the temperature > >> speed will vary given the thermal contribution of the components > >> surrounding the thermal zone, that includes the ambient temperature. > >> > >> However, that may apply to slow speed temperature sensor like the skin > >> temperature sensor where we may to do small hysteresis variation. > >> > >> The places managed by the kernel have an insane temperature transition > >> speed. The userspace is unable to follow this speed and manage the > >> hysteresis on the fly. > >> > >> So that brings us to userspace trip point handling again. > > > > Well, I've already said that whether hysteresis can be modified via > > sysfs is a property of a thermal zone. > > > It may as well be a trip property, for example expressed via a (new) > > trip flag set in the trips table used for thermal zone registration. > > Yes, a trip property makes more sense. > > I'm a bit lost about WRITABLE_TRIP_POINT, writable hysteresis, read-only > temperature trip. > > Can we have a hysteresis writable but not the temperature ? > > You mentioned above "modifying the trip hysteresis via sysfs is simply > incorrect", so shall we allow that at the end? > > Is it possible to recap the situation? Sure, which is a good idea BTW. First off, the callers of thermal_zone_device_register_with_trips() need to pass a mask of writeable trip points to it. If the mask is 0, none of the trip attributes are writeable for any trips. However, the mask only takes effect if CONFIG_THERMAL_WRITABLE_TRIPS is set. Otherwise, it is not taken into account at all. Now, if CONFIG_THERMAL_WRITABLE_TRIPS is set, it only affects the trip temperature, which is a bit inconsistent. Moreover, the hysteresis is allowed to be updated unconditionally if tz->ops->set_trip_hyst is not NULL, which is even more inconsistent. So, because it already is only enabled if the creator of the thermal zone asks for it explicitly, it would be fine by me to simply allow the hysteresis to be updated if the temperature is allowed to be updated. IOW, something like the patch below (unstested, white space messed-up by gmail). If this looks OK to everyone from the functionality perspective, I can submit it properly with a changelog etc. --- drivers/thermal/thermal_sysfs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) Index: linux-pm/drivers/thermal/thermal_sysfs.c =================================================================== --- linux-pm.orig/drivers/thermal/thermal_sysfs.c +++ linux-pm/drivers/thermal/thermal_sysfs.c @@ -474,7 +474,8 @@ static int create_trip_attrs(struct ther tz->trip_hyst_attrs[indx].name; tz->trip_hyst_attrs[indx].attr.attr.mode = S_IRUGO; tz->trip_hyst_attrs[indx].attr.show = trip_point_hyst_show; - if (tz->ops->set_trip_hyst) { + if (IS_ENABLED(CONFIG_THERMAL_WRITABLE_TRIPS) && + mask & (1 << indx)) { tz->trip_hyst_attrs[indx].attr.attr.mode |= S_IWUSR; tz->trip_hyst_attrs[indx].attr.store = trip_point_hyst_store;
On Mon, Jan 22, 2024 at 11:19 AM Rafael J. Wysocki <rafael@kernel.org> wrote: > > On Thu, Jan 18, 2024 at 11:25 AM Daniel Lezcano > <daniel.lezcano@linaro.org> wrote: > > > > On 17/01/2024 19:49, Rafael J. Wysocki wrote: > > > On Wed, Jan 17, 2024 at 5:57 PM Daniel Lezcano > > > <daniel.lezcano@linaro.org> wrote: > > >> > > >> On 10/01/2024 13:48, Rafael J. Wysocki wrote: > > >>> Hi Manaf, > > >>> > > >>> On Wed, Jan 10, 2024 at 9:17 AM Manaf Meethalavalappu Pallikunhi > > >>> <quic_manafm@quicinc.com> wrote: > > >>>> > > >>>> Hi Rafael, > > >>>> > > >>>> On 1/9/2024 7:12 PM, Rafael J. Wysocki wrote: > > >>>> > > >>>> On Sat, Jan 6, 2024 at 8:16 PM Manaf Meethalavalappu Pallikunhi > > >>>> <quic_manafm@quicinc.com> wrote: > > >>>> > > >>>> The commit 2e38a2a981b2("thermal/core: Add a generic > > >>>> thermal_zone_set_trip() function") adds the support to update > > >>>> trip hysteresis even if set_trip_hyst() operation is not defined. > > >>>> But during hysteresis attribute creation, if this operation is > > >>>> defined then only it enables hysteresis write access. It leads > > >>>> to a case where hysteresis sysfs will be read only for a thermal > > >>>> zone when its set_trip_hyst() operation is not defined. > > >>>> > > >>>> Which is by design. > > >>>> > > >>>> I think it is regression after recent re-work. If a sensor is registered with thermal framework via thermal_of, > > >>>> > > >>>> sensor driver doesn't need to know the trip configuration and nothing to do with set_trip_hyst() in driver. > > >>>> > > >>>> Without this change, if a sensor needs to be monitored from userspace(trip/hysteresis), > > >>> > > >>> What exactly do you mean by "monitored" here? > > >>> > > >>>> it is enforcing sensor driver to add dummy set_trip_hyst() operation. Correct me otherwise > > >>> > > >>> With the current design, whether or not trip properties can be updated > > >>> by user space is a thermal zone property expressed by the presence of > > >>> the set_trip_* operations, so yes, whoever registers the thermal zone > > >>> needs to provide those so that user space can update the trip > > >>> properties. > > >>> > > >>>> For some thermal zone types (eg. acpi), updating trip hysteresis via > > >>>> sysfs might lead to incorrect behavior. > > >>>> > > >>>> To address this issue, is it okay to guard hysteresis write permission under CONFIG_THERMAL_WRITABLE_TRIPS defconfig ? > > >>> > > >>> Not really, because it would affect all of the thermal zones then. > > >> > > >> It seems like there is an inconsistency here with the writable trip > > >> points and the writable hysteresis [1]. > > >> > > >> My understanding is it does not make sense to have the hysteresis > > >> writable even if the driver has a hysteresis dedicated ops. The code > > >> allowing to change the hysteresis was done regardless the consistency > > >> with the trip temperature change and writable trip points kernel option IMO. > > >> > > >> It would make sense to have: > > >> > > >> if enabled(CONFIG_WRITABLE_TRIP_POINT) > > >> -> trip_temp RW > > >> -> trip_hyst RW > > >> else > > >> -> trip temp RO > > >> -> trip hyst RO > > >> fi > > >> > > >> But if the interface exists since a long time, we may not want to change > > >> it, right ? > > > > > > If the platform firmware implements hysteresis by changing trip > > > temperature (as recommended by the ACPI specification, for example), > > > modifying the trip hysteresis via sysfs is simply incorrect and user > > > space may not know that. > > > > > >> However, we can take the opportunity to introduce a new 'user' trip > > >> point type in order to let the userspace to have dedicated trip point > > >> and receive temperature notifications [2] > > >> > > >>> TBH, the exact scenario in which user space needs to update trip > > >>> hysteresis is not particularly clear to me, so can you provide some > > >>> more details, please? > > >> > > >> IIUC changing the hysteresis value is useful because the temperature > > >> speed will vary given the thermal contribution of the components > > >> surrounding the thermal zone, that includes the ambient temperature. > > >> > > >> However, that may apply to slow speed temperature sensor like the skin > > >> temperature sensor where we may to do small hysteresis variation. > > >> > > >> The places managed by the kernel have an insane temperature transition > > >> speed. The userspace is unable to follow this speed and manage the > > >> hysteresis on the fly. > > >> > > >> So that brings us to userspace trip point handling again. > > > > > > Well, I've already said that whether hysteresis can be modified via > > > sysfs is a property of a thermal zone. > > > > > It may as well be a trip property, for example expressed via a (new) > > > trip flag set in the trips table used for thermal zone registration. > > > > Yes, a trip property makes more sense. > > > > I'm a bit lost about WRITABLE_TRIP_POINT, writable hysteresis, read-only > > temperature trip. > > > > Can we have a hysteresis writable but not the temperature ? > > > > You mentioned above "modifying the trip hysteresis via sysfs is simply > > incorrect", so shall we allow that at the end? > > > > Is it possible to recap the situation? > > Sure, which is a good idea BTW. > > First off, the callers of thermal_zone_device_register_with_trips() > need to pass a mask of writeable trip points to it. If the mask is 0, > none of the trip attributes are writeable for any trips. > > However, the mask only takes effect if CONFIG_THERMAL_WRITABLE_TRIPS > is set. Otherwise, it is not taken into account at all. > > Now, if CONFIG_THERMAL_WRITABLE_TRIPS is set, it only affects the trip > temperature, which is a bit inconsistent. > > Moreover, the hysteresis is allowed to be updated unconditionally if > tz->ops->set_trip_hyst is not NULL, which is even more inconsistent. > > So, because it already is only enabled if the creator of the thermal > zone asks for it explicitly, it would be fine by me to simply allow > the hysteresis to be updated if the temperature is allowed to be > updated. > > IOW, something like the patch below (unstested, white space messed-up by gmail). > > If this looks OK to everyone from the functionality perspective, I can > submit it properly with a changelog etc. > > --- > drivers/thermal/thermal_sysfs.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > Index: linux-pm/drivers/thermal/thermal_sysfs.c > =================================================================== > --- linux-pm.orig/drivers/thermal/thermal_sysfs.c > +++ linux-pm/drivers/thermal/thermal_sysfs.c > @@ -474,7 +474,8 @@ static int create_trip_attrs(struct ther > tz->trip_hyst_attrs[indx].name; > tz->trip_hyst_attrs[indx].attr.attr.mode = S_IRUGO; > tz->trip_hyst_attrs[indx].attr.show = trip_point_hyst_show; > - if (tz->ops->set_trip_hyst) { > + if (IS_ENABLED(CONFIG_THERMAL_WRITABLE_TRIPS) && > + mask & (1 << indx)) { > tz->trip_hyst_attrs[indx].attr.attr.mode |= S_IWUSR; > tz->trip_hyst_attrs[indx].attr.store = > trip_point_hyst_store; So it looks like I need to submit this, even though I'm not sure if anyone cares. In any case, I care about consistency.
Hi Rafael, On 29/01/2024 18:07, Rafael J. Wysocki wrote: [ ... ] >> Index: linux-pm/drivers/thermal/thermal_sysfs.c >> =================================================================== >> --- linux-pm.orig/drivers/thermal/thermal_sysfs.c >> +++ linux-pm/drivers/thermal/thermal_sysfs.c >> @@ -474,7 +474,8 @@ static int create_trip_attrs(struct ther >> tz->trip_hyst_attrs[indx].name; >> tz->trip_hyst_attrs[indx].attr.attr.mode = S_IRUGO; >> tz->trip_hyst_attrs[indx].attr.show = trip_point_hyst_show; >> - if (tz->ops->set_trip_hyst) { >> + if (IS_ENABLED(CONFIG_THERMAL_WRITABLE_TRIPS) && >> + mask & (1 << indx)) { >> tz->trip_hyst_attrs[indx].attr.attr.mode |= S_IWUSR; >> tz->trip_hyst_attrs[indx].attr.store = >> trip_point_hyst_store; > > So it looks like I need to submit this, even though I'm not sure if > anyone cares. > > In any case, I care about consistency. Yeah, sorry for the delay. I'll have a look at it tomorrow
Hi Daniel, On Mon, Jan 29, 2024 at 6:54 PM Daniel Lezcano <daniel.lezcano@linaro.org> wrote: > > Hi Rafael, > > On 29/01/2024 18:07, Rafael J. Wysocki wrote: > > [ ... ] > > >> Index: linux-pm/drivers/thermal/thermal_sysfs.c > >> =================================================================== > >> --- linux-pm.orig/drivers/thermal/thermal_sysfs.c > >> +++ linux-pm/drivers/thermal/thermal_sysfs.c > >> @@ -474,7 +474,8 @@ static int create_trip_attrs(struct ther > >> tz->trip_hyst_attrs[indx].name; > >> tz->trip_hyst_attrs[indx].attr.attr.mode = S_IRUGO; > >> tz->trip_hyst_attrs[indx].attr.show = trip_point_hyst_show; > >> - if (tz->ops->set_trip_hyst) { > >> + if (IS_ENABLED(CONFIG_THERMAL_WRITABLE_TRIPS) && > >> + mask & (1 << indx)) { > >> tz->trip_hyst_attrs[indx].attr.attr.mode |= S_IWUSR; > >> tz->trip_hyst_attrs[indx].attr.store = > >> trip_point_hyst_store; > > > > So it looks like I need to submit this, even though I'm not sure if > > anyone cares. > > > > In any case, I care about consistency. > > Yeah, sorry for the delay. I'll have a look at it tomorrow Thanks! Posted here with some additional remarks: https://lore.kernel.org/linux-pm/4565526.LvFx2qVVIh@kreacher/ Let's continue the discussion there.
diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.c index eef40d4f3063..08be016d7221 100644 --- a/drivers/thermal/thermal_sysfs.c +++ b/drivers/thermal/thermal_sysfs.c @@ -504,13 +504,9 @@ static int create_trip_attrs(struct thermal_zone_device *tz, int mask) sysfs_attr_init(&tz->trip_hyst_attrs[indx].attr.attr); tz->trip_hyst_attrs[indx].attr.attr.name = tz->trip_hyst_attrs[indx].name; - tz->trip_hyst_attrs[indx].attr.attr.mode = S_IRUGO; + tz->trip_hyst_attrs[indx].attr.attr.mode = S_IRUGO | S_IWUSR; tz->trip_hyst_attrs[indx].attr.show = trip_point_hyst_show; - if (tz->ops->set_trip_hyst) { - tz->trip_hyst_attrs[indx].attr.attr.mode |= S_IWUSR; - tz->trip_hyst_attrs[indx].attr.store = - trip_point_hyst_store; - } + tz->trip_hyst_attrs[indx].attr.store = trip_point_hyst_store; attrs[indx + tz->num_trips * 2] = &tz->trip_hyst_attrs[indx].attr.attr; }