Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp1649984rdb; Thu, 25 Jan 2024 01:56:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IE+teKupCdDvVGqMgmIHP+goWxQEIENs0z8n1dNdBIIPPdyV01i4IVLmS33z2/ESoo1N46q X-Received: by 2002:a05:6871:8905:b0:210:e860:c500 with SMTP id ti5-20020a056871890500b00210e860c500mr712289oab.42.1706176592706; Thu, 25 Jan 2024 01:56:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706176592; cv=pass; d=google.com; s=arc-20160816; b=Bal563BiJlEe5QBInWgx0mEXyosab2+F9ZR8N5nnkREL+0IkDMIlVSeTdhjk5gqSns sHeMB3RYByK8fTih/JDHNM+1xf2ash0IoGSiS2+CZrSHd144XcsGQ4fxvQzfLIQOPpFr IoCZeHkdkUqBbC5+2N4sUU+wbl2b6iRFnfzmY9JC+kqxFKU296fEk65/GV4/jFEMXhfb Mw6dbyxqVrSc7lJECrmLffXVv0w6FQd+p0HooXSUXRNPhuE4xjpGKpp+8A9xxPYi2CFh sL2msC+9CsGw3BeYdlwZtjPLbftPXpUXGaP2AKNk+cO9J5xqLlTjAUBS81VdGCp/xGcp EPUg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=8XM+tIpeS41ctI6pbxR/5tBafxGZOT3JM/BCmpn1+Fs=; fh=IEJoC5+tEXAPM8MCBt/ZxcfeXDF1Nk9INP/WZMQDWQM=; b=Dis5jqeHyuvm9MtkhdLM4j4w4DBEwTZ8b7I+OgRP2N3KLFkLYxGY/PRNXmhYKhCtKK 9SmoWkbBMkgy/G81VNHUFEiT9WO8yWUOyctaN4d8pitPD2ynXUtzgtPpfaVdsp12/dwq fwqhMCVhdaXu83CKd1LFkBKYz/FW6SgqTrP2wR2OCPi3h6onmni6MccciMBOAwGwrjpP /EihNMtZXahZgSx9DrpFuQ+reJposVPM+ikTBbaiv/dMlUfJ5Hys8Q/bgOYYkPirrJ3w KwbRoCY67cOhAUDv6DfBUGoL/80mCNnNFXtn59/Fxum3AgoPWpS4INg5Gps6hICamR6f kcmA== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-38318-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38318-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id n24-20020a63f818000000b005cecbe69c23si13088886pgh.43.2024.01.25.01.56.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 01:56:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-38318-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-38318-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38318-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 1982B283A30 for ; Thu, 25 Jan 2024 09:47:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6F99C1C69C; Thu, 25 Jan 2024 09:45:21 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CE56D1C6AE; Thu, 25 Jan 2024 09:45:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706175920; cv=none; b=B/Ich17DAgWEjz7Pqpzxz2Hem/stCHcLZcOvFg8oG7TGwHAieIrg3mLPgA96o/mPYjDRcMfJ/vnQX0MDU046hzouAiBqACGrFYo+mXB817R2o9APgo2NZ8O9JNUpBemgegNLgb80FCAaNZPW+6ZcC28pjghdwLP0nCHM61YDKGA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706175920; c=relaxed/simple; bh=BBBMj/+LwJcWhyi1zR7X13yXCz0XNJvnrWKsG9hK2Bw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=iZos4rospTcDewzCP9PgjsmdpxM9ZN77iTcny3yiJENYhHOzofzuqW9VprwnocJTKeHCkcl4/tGvtqLlh+qp1qe3WotLPdVEjSIk3m67n2hSvdBfY++6FAG8Wu1H6vYf4lML6cqfZ2T1wUwYRnEzwciW6DBJPeAt715PG9q6S6I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id BC8A3153B; Thu, 25 Jan 2024 01:46:02 -0800 (PST) Received: from pluto (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 03AE83F73F; Thu, 25 Jan 2024 01:45:16 -0800 (PST) Date: Thu, 25 Jan 2024 09:45:14 +0000 From: Cristian Marussi To: Peng Fan , Guenter Roeck Cc: "Peng Fan (OSS)" , "groeck7@gmail.com" , "sudeep.holla@arm.com" , "jdelvare@suse.com" , "linux-hwmon@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH V3] hwmon: scmi-hwmon: implement change_mode for thermal zones Message-ID: References: <20240125064422.347002-1-peng.fan@oss.nxp.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Thu, Jan 25, 2024 at 07:06:25AM +0000, Peng Fan wrote: > Hi Guenter, > Hi, > > Subject: Re: [PATCH V3] hwmon: scmi-hwmon: implement change_mode for > > thermal zones > > > > On 1/24/24 22:44, Peng Fan (OSS) wrote: > > > From: Peng Fan > > > > > > The thermal sensors maybe disabled before kernel boot, so add > > > change_mode for thermal zones to support configuring the thermal > > > sensor to enabled state. If reading the temperature when the sensor is > > > disabled, there will be error reported. > > > > > > The cost is an extra config_get all to SCMI firmware to get the status > > > of the thermal sensor. No function level impact. > > > > > > Reviewed-by: Cristian Marussi > > > Signed-off-by: Peng Fan > > > --- > > > > > > V3: > > > Update commit log to show it only applys to thermal > > > Add comments in code > > > Add R-b from Cristian > > > > > > > You didn't address my question regarding the behavior of hwmon attributes if > > a sensor is disabled. > > Would you please share a bit more on what attributes? > You mean the files under /sys/class/hwmon/hwmon0? > > If the sensor is disabled, when cat temp[x]_input, it will > report: > root@imx95-19x19-lpddr5-evk:/sys/class/hwmon/hwmon0# cat temp3_input > cat: temp3_input: Protocol error > > For enabled, it will report value: > root@imx95-19x19-lpddr5-evk:/sys/class/hwmon/hwmon0# cat temp1_input > 31900 > > > > > > Guenter, I Cced linux@roeck-us.net when sending V1/V2 > > > Let me Cc Guenter Roeck in V3, hope you not mind > > > > > This time I received it twice ;-). > > > > > V2: > > > Use SCMI_SENS_CFG_IS_ENABLED & clear BIT[31:9] before update > > > config(Thanks Cristian) > > > > > > drivers/hwmon/scmi-hwmon.c | 39 > > ++++++++++++++++++++++++++++++++++++++ > > > 1 file changed, 39 insertions(+) > > > > > > diff --git a/drivers/hwmon/scmi-hwmon.c b/drivers/hwmon/scmi-hwmon.c > > > index 364199b332c0..af2267fea5f0 100644 > > > --- a/drivers/hwmon/scmi-hwmon.c > > > +++ b/drivers/hwmon/scmi-hwmon.c > > > @@ -151,7 +151,46 @@ static int scmi_hwmon_thermal_get_temp(struct > > thermal_zone_device *tz, > > > return ret; > > > } > > > > > > +static int scmi_hwmon_thermal_change_mode(struct > > thermal_zone_device *tz, > > > + enum thermal_device_mode > > new_mode) { > > > + int ret; > > > + u32 config; > > > + enum thermal_device_mode cur_mode = > > THERMAL_DEVICE_DISABLED; > > > + struct scmi_thermal_sensor *th_sensor = > > > +thermal_zone_device_priv(tz); > > > + > > > + ret = sensor_ops->config_get(th_sensor->ph, th_sensor->info->id, > > > + &config); > > > + if (ret) > > > + return ret; > > > + > > > + if (SCMI_SENS_CFG_IS_ENABLED(config)) > > > + cur_mode = THERMAL_DEVICE_ENABLED; > > > + > > > + if (cur_mode == new_mode) > > > + return 0; > > > + > > > + /* > > > + * Per SENSOR_CONFIG_SET sensor_config description: > > > + * BIT[31:11] should be set to 0 if the sensor update interval does > > > + * not need to be updated, so clear them. > > > + * And SENSOR_CONFIG_GET does not return round up/down, so also > > clear > > > + * BIT[10:9] round up/down. > > > > What does "clear" mean ? Is it going to round up ? Round down ? And why > > would it be necessary to clear those bits if SENSOR_CONFIG_GET does not > > return the current setting in the first place ? > > This is to follow Cristian's suggestion to clear [31:9], because we only need > to set the sensor to enabled state, no other attributes. > My understanding is with BIT[31:11] set to 0, BIT[10:9] will not take effect. > Cristian may help comment more since he suggested to clear them in V1/V2 > > You are right, currently config_get will return [10:2] as reserved, > so config_set bit[10:9] no need touch. But config_get bit[10:2] > may update to return the value in future SCMI spec? > > Cristian or Sudeep may help comment here. From the spec SENSOR_CONFIG_SET can also be used to set the chosen update-interval for the sensor and the rounding-mode, but the specified rounding mode refers only to the currently issued CONFIG_SET operation, it is not a permanent configuration for the sensor: for this reason when you instead issue a CONFIG_GET it does not make any sense to return the rounding mode, since the interval returned by the GET is the already (previously) rounded final value configured on the sensor. So the spec is right and does not need any change in these regards. By the spec, also, if you set the update-interval to 0 in a CONFIG_SET, the chosen interval will remain unchanged, so the value of the ROUND bits is indeed irrelevant. Now, my (probably ill) advice to anyway clear also the round bits was aimed at using some sort of well-known value in the SET (even though ignored) given that the GET does specify those bits as reserved but you cannot be sure what the previous GET just returned from the fw-of-the-day (maybe by mistake), and if those bits will be effectively ignored on the SET given the zeroed interval value. Indeed, looking at this again, all of this is maybe just overthinking and it just confusing at this point to needlessly clear also those ROUNDING bits, since not required by the spec. Just clear the interval bits, my bad. Thanks, Cristian