Message ID | 9235101.CDJkKcVGEf@kreacher |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-62209-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp102276dyb; Mon, 12 Feb 2024 10:44:27 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXC1S7kK1N7Lv3Jxdbi44fHqMyfMvsaxjxeWNjgBJgI9lgvpAkcp6MgDAUZNvV/gsUJsznLRrunm7CwdhZ+wlNQ0/ZqNA== X-Google-Smtp-Source: AGHT+IED5hy5spkAHiEThOAAcSHWilhZkPXNe3dEKyeuV3q834UiDgELrN9xlwGYd+XMLvA/WU2+ X-Received: by 2002:a17:906:853:b0:a3c:3612:c2c6 with SMTP id f19-20020a170906085300b00a3c3612c2c6mr5123090ejd.8.1707763467339; Mon, 12 Feb 2024 10:44:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707763467; cv=pass; d=google.com; s=arc-20160816; b=T3iJmKdR1B0nYXOn8IJJvwBobq9HxaA4oe2mmvGbPmOVSV3FqaQekv2iTPCsJFRn10 Z9x1wkTeZkYEwgk05HS9Ask5bK2Q+f6iVXVMENzf3MCfrBbV+0uohvi0oPJvMlDrGFB5 fXy/XQgRqUXaf5blIFtijb8CX6pDwa+ZRHuaTed9R/BGhVm1xTNKKtIQQuhOX28y2y/b YUPUtrsjB3F6vk5AJzdvY2TH8vXJR55YdURbhh6Z6bRKQBExCj3PAGxhYniW+eAH4/tK zTeujCPz5qFhyJ3fDajxEHpHaziKLLwx5hxiNJH1/yrEYstMwC4Z3k5UYLCLMq9JsCFB WSnQ== 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; bh=qJ9BAfTEHUYsBR82jgQXCHJtBKONbaGbUj7R5mBp7Sw=; fh=BjgPVHxVFysxdEbdtaGB+dUOZNJlyif2jow3PN0P9mU=; b=hbBuwZ5La/5RQtmrRiHHZCIIPSuxgOBD4pFtSdjyf/cbkW81lzutrKndkRUww6sSAE 9lNZ22AKNGpZ9ZFyYiSHoKDG4pVXNA4Rz3M000R8+QZmPlkfp+LRtiHcQQ7xtp2AFUeW ih48CwOGZAeslDbHf1uEzx1W2tLpPVgN/0HuoN42KoYR8zaQ7iM96/wp2un4fDaLt/If +nkq6QlBsEL149cH3N1n1FpL46Bz0c8nPeC7aahEnx3KrCuesTm16b9f8tcA2NSWAXT4 eKr//0iT8DMxFD0UhwuYBBvqYWzB5tYCjZb63zbpVQw7O3BRvHVtxtHYvqTXXspC7vS2 jJrg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=rjwysocki.net); spf=pass (google.com: domain of linux-kernel+bounces-62209-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62209-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCWWQSeyZ2Zvdl1zQViyw2c1PHMb0xb6aKyrnZ5u3NQgVSNuFT1OV84pbT5rn5y4cP5wEfxWCNH3ErF+68wKB1etg4TJ8g== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id k27-20020a170906129b00b00a3c98aa5ab6si430443ejb.758.2024.02.12.10.44.27 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 10:44:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-62209-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=rjwysocki.net); spf=pass (google.com: domain of linux-kernel+bounces-62209-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62209-ouuuleilei=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 am.mirrors.kernel.org (Postfix) with ESMTPS id EEBA01F23C42 for <ouuuleilei@gmail.com>; Mon, 12 Feb 2024 18:44:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 683CB4C622; Mon, 12 Feb 2024 18:42:36 +0000 (UTC) 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 D23CF3FE36; Mon, 12 Feb 2024 18:42:30 +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=1707763354; cv=none; b=c8ZZycxkYQ+g0ZOla0f+i8uiNngM8E4elzkdP1UMKwJDh+xrjQlxfIzbQ0KbBKz1QBlsK01KFeECRxmsCNWTKzws4EN0am3Tx/MkXP0W8D7P9zThemKQQHsB45MweeWNFBjY9E+NqW3iw/5UolNfqylCvK4zGRivSaJMGjPRPyg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707763354; c=relaxed/simple; bh=L3NRX4YCC5wAmVuFoBGeSlDkUFlbjD5+xbxslNXvKy0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=OJUkBZLxTH+lo/cDoOv3pgz0wnyWw2ycPO1VqOtY1LiwGwFrkzb0Z9bX9te75zH++AY0RQ4whXlJopHSM8fyy8LtcyqCwUZb+7ZwWIxoEeuac54owHBwQSQxbqXDEV6vJecfNjdcTJyJLMITNS/JjRreDRd5Li9IAogg/ektEMs= 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; 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 5.4.0) id 0f78f23c5a53093c; Mon, 12 Feb 2024 19:42:29 +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 9385C669CF2; Mon, 12 Feb 2024 19:42:28 +0100 (CET) From: "Rafael J. Wysocki" <rjw@rjwysocki.net> To: Linux PM <linux-pm@vger.kernel.org> Cc: Lukasz Luba <lukasz.luba@arm.com>, LKML <linux-kernel@vger.kernel.org>, Daniel Lezcano <daniel.lezcano@linaro.org>, Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>, Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>, Zhang Rui <rui.zhang@intel.com>, netdev@vger.kernel.org, Ido Schimmel <idosch@nvidia.com>, Petr Machata <petrm@nvidia.com>, Miri Korenblit <miriam.rachel.korenblit@intel.com>, linux-wireless@vger.kernel.org, Shawn Guo <shawnguo@kernel.org>, Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix Kernel Team <kernel@pengutronix.de>, Manaf Meethalavalappu Pallikunhi <quic_manafm@quicinc.com> Subject: [PATCH v2 8/9] thermal: of: Set THERMAL_TRIP_FLAG_RW_TEMP directly Date: Mon, 12 Feb 2024 19:40:34 +0100 Message-ID: <9235101.CDJkKcVGEf@kreacher> In-Reply-To: <6017196.lOV4Wx5bFT@kreacher> References: <6017196.lOV4Wx5bFT@kreacher> 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-Transfer-Encoding: 7Bit 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: gggruggvucftvghtrhhoucdtuddrgedvledrudefgdduudegucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgjfhgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepvdffueeitdfgvddtudegueejtdffteetgeefkeffvdeftddttdeuhfegfedvjefhnecukfhppeduleehrddufeeirdduledrleegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepudelhedrudefiedrudelrdelgedphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedpnhgspghrtghpthhtohepudeipdhrtghpthhtoheplhhinhhugidqphhmsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhukhgrshiirdhluhgsrgesrghrmhdrtghomhdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopegurghnihgvlhdrlhgviigtrghnoheslhhinhgrrhhordhorhhgpdhrtghpthhtohepshht rghnihhslhgrfidrghhruhhsiihkrgeslhhinhhugidrihhnthgvlhdrtghomhdprhgtphhtthhopehsrhhinhhivhgrshdrphgrnhgurhhuvhgruggrsehlihhnuhigrdhinhhtvghlrdgtohhm X-DCC--Metrics: v370.home.net.pl 1024; Body=16 Fuz1=16 Fuz2=16 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790719785830797902 X-GMAIL-MSGID: 1790719785830797902 |
Series |
thermal: Writable trip points handling rework
|
|
Commit Message
Rafael J. Wysocki
Feb. 12, 2024, 6:40 p.m. UTC
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com> It is now possible to flag trip points with THERMAL_TRIP_FLAG_RW_TEMP to allow their temperature to be set from user space via sysfs instead of using a nonzero writable trips mask during thermal zone registration, so make the OF thermal code do that. No intentional functional impact. Note that this change is requisite for dropping the mask argument from thermal_zone_device_register_with_trips() going forward. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> --- v1 -> v2: Rename trip flag (Stanislaw). --- drivers/thermal/thermal_of.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
Comments
On 12/02/2024 19:40, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > > It is now possible to flag trip points with THERMAL_TRIP_FLAG_RW_TEMP > to allow their temperature to be set from user space via sysfs instead > of using a nonzero writable trips mask during thermal zone registration, > so make the OF thermal code do that. > > No intentional functional impact. > > Note that this change is requisite for dropping the mask argument from > thermal_zone_device_register_with_trips() going forward. > > Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > --- > > v1 -> v2: Rename trip flag (Stanislaw). > > --- > drivers/thermal/thermal_of.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > Index: linux-pm/drivers/thermal/thermal_of.c > =================================================================== > --- linux-pm.orig/drivers/thermal/thermal_of.c > +++ linux-pm/drivers/thermal/thermal_of.c > @@ -117,6 +117,8 @@ static int thermal_of_populate_trip(stru > return ret; > } > > + trip->flags = THERMAL_TRIP_FLAG_RW_TEMP; > + > return 0; > } Even if you are not at the origin of this default behavior. I'm wondering if we should be more protective against changes from userspace when the firmware is telling us to protect the silicon at a specific temperature. What do you think if we set the THERMAL_TRIP_FLAG_RW_TEMP only if the trip point is not bound to a cooling device? So trip points without associated cooling device can be writable but others can be considered as managed by the kernel and no modifiable. (This comment does not put in question this patch BTW) > @@ -477,7 +479,7 @@ static struct thermal_zone_device *therm > struct device_node *np; > const char *action; > int delay, pdelay; > - int ntrips, mask; > + int ntrips; > int ret; > > of_ops = kmemdup(ops, sizeof(*ops), GFP_KERNEL); > @@ -510,15 +512,13 @@ static struct thermal_zone_device *therm > of_ops->bind = thermal_of_bind; > of_ops->unbind = thermal_of_unbind; > > - mask = GENMASK_ULL((ntrips) - 1, 0); > - > ret = of_property_read_string(np, "critical-action", &action); > if (!ret) > if (!of_ops->critical && !strcasecmp(action, "reboot")) > of_ops->critical = thermal_zone_device_critical_reboot; > > tz = thermal_zone_device_register_with_trips(np->name, trips, ntrips, > - mask, data, of_ops, &tzp, > + 0, data, of_ops, &tzp, > pdelay, delay); > if (IS_ERR(tz)) { > ret = PTR_ERR(tz); > > >
On Thu, Feb 22, 2024 at 2:48 PM Daniel Lezcano <daniel.lezcano@linaro.org> wrote: > > On 12/02/2024 19:40, Rafael J. Wysocki wrote: > > From: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > > > > It is now possible to flag trip points with THERMAL_TRIP_FLAG_RW_TEMP > > to allow their temperature to be set from user space via sysfs instead > > of using a nonzero writable trips mask during thermal zone registration, > > so make the OF thermal code do that. > > > > No intentional functional impact. > > > > Note that this change is requisite for dropping the mask argument from > > thermal_zone_device_register_with_trips() going forward. > > > > Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > > --- > > > > v1 -> v2: Rename trip flag (Stanislaw). > > > > --- > > drivers/thermal/thermal_of.c | 8 ++++---- > > 1 file changed, 4 insertions(+), 4 deletions(-) > > > > Index: linux-pm/drivers/thermal/thermal_of.c > > =================================================================== > > --- linux-pm.orig/drivers/thermal/thermal_of.c > > +++ linux-pm/drivers/thermal/thermal_of.c > > @@ -117,6 +117,8 @@ static int thermal_of_populate_trip(stru > > return ret; > > } > > > > + trip->flags = THERMAL_TRIP_FLAG_RW_TEMP; > > + > > return 0; > > } > > Even if you are not at the origin of this default behavior. I'm > wondering if we should be more protective against changes from userspace > when the firmware is telling us to protect the silicon at a specific > temperature. > > What do you think if we set the THERMAL_TRIP_FLAG_RW_TEMP only if the > trip point is not bound to a cooling device? > > So trip points without associated cooling device can be writable but > others can be considered as managed by the kernel and no modifiable. This sounds reasonable to me. This is mostly relevant to thermal_of anyway, because the other drivers asking for writable trip temperature seem to want it regardless. > (This comment does not put in question this patch BTW) OK
On 12/02/2024 19:40, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > > It is now possible to flag trip points with THERMAL_TRIP_FLAG_RW_TEMP > to allow their temperature to be set from user space via sysfs instead > of using a nonzero writable trips mask during thermal zone registration, > so make the OF thermal code do that. > > No intentional functional impact. > > Note that this change is requisite for dropping the mask argument from > thermal_zone_device_register_with_trips() going forward. > > Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Index: linux-pm/drivers/thermal/thermal_of.c =================================================================== --- linux-pm.orig/drivers/thermal/thermal_of.c +++ linux-pm/drivers/thermal/thermal_of.c @@ -117,6 +117,8 @@ static int thermal_of_populate_trip(stru return ret; } + trip->flags = THERMAL_TRIP_FLAG_RW_TEMP; + return 0; } @@ -477,7 +479,7 @@ static struct thermal_zone_device *therm struct device_node *np; const char *action; int delay, pdelay; - int ntrips, mask; + int ntrips; int ret; of_ops = kmemdup(ops, sizeof(*ops), GFP_KERNEL); @@ -510,15 +512,13 @@ static struct thermal_zone_device *therm of_ops->bind = thermal_of_bind; of_ops->unbind = thermal_of_unbind; - mask = GENMASK_ULL((ntrips) - 1, 0); - ret = of_property_read_string(np, "critical-action", &action); if (!ret) if (!of_ops->critical && !strcasecmp(action, "reboot")) of_ops->critical = thermal_zone_device_critical_reboot; tz = thermal_zone_device_register_with_trips(np->name, trips, ntrips, - mask, data, of_ops, &tzp, + 0, data, of_ops, &tzp, pdelay, delay); if (IS_ERR(tz)) { ret = PTR_ERR(tz);