Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp1579640rdb; Wed, 24 Jan 2024 22:54:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IGNcAbbnKfNEI0Y9pw3fItXgK5cIPoaiEO9TsEa0KhIfeiNoV6dfvlDmHzES/EmC0nIc6FP X-Received: by 2002:a05:6808:1d4:b0:3bd:c1c3:6945 with SMTP id x20-20020a05680801d400b003bdc1c36945mr514539oic.95.1706165668977; Wed, 24 Jan 2024 22:54:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706165668; cv=pass; d=google.com; s=arc-20160816; b=i/yXUj/9IQ1l5Sqp8NiLdE23dsryZB3w9xFs5C3YanFebdnt98KPZPIbGNpbzP7fcG cRpNoFhUezbCNKKhwto+TbUP4VbeqJHJCKS9eRBFe589EntbLUCPds+cVfJ2Vn119fYn C0H3L8UCZqur9NDoJ2kS11OYVQ1bcIhc65SzdnIMJdlCv1nQdwAexZ1OHoWeoAuzd8E+ FUMEEDooV2ud0m2FtqaIB62Y51Fwi7VnLCDp3kRobVB8nh7hH8v9o68EFgeEsAXowfLu I2PSaJiznoEsxu8muH7rvmDttc7tHJrQ9M1EVfrO5m/ii+lyB+Fhugu/+3abF6U1MElM KFkQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :sender:dkim-signature; bh=a/dD/tk5ZZP0MVQmDxuJNtWfiuXCG0ReCzTna959dS0=; fh=mab1fLViFmQ1KYUhubvYMDcwsypPGhQZajMBYM0Ai0A=; b=Y4U+uf+7ouwfDEQRP+OltYfyxQGFA5qZMdvaxG+qhMTbfp4RlWeJqo6mvOXjF4+Cfk NMAdVk3c2YKc1sbLgnZdtGjKsOXYBDgYAoCrdlzhk+caljNHY0Zt3/NdI2WaVCczgDnH iVBR/1fVkIAjLuX4v79JE6LNyNZafh8a7KjTZZC7WItJCkKgTR6uBihhyt9NuYwQIJ+R x6wUVNB7O6zokTUUSckZyy0i3W20EZ2r2QJRS3GwZscjWHeSBr2ILUwfRSRQdq8pKBXt kfN7UVWP2CNPomcqaP7CYjDfnKP3dTPqxwl3OgbbMrQcPBw05FQHd4rlwPXPh6Pon6DV CYhA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="QQXvMpL/"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-38056-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38056-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id g1-20020a056a000b8100b006dd7c188edasi3836061pfj.154.2024.01.24.22.54.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 22:54:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-38056-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; dkim=pass header.i=@gmail.com header.s=20230601 header.b="QQXvMpL/"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-38056-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38056-linux.lists.archive=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 90304281823 for ; Thu, 25 Jan 2024 06:54:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 020FD10A25; Thu, 25 Jan 2024 06:54:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QQXvMpL/" Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 291D11118F; Thu, 25 Jan 2024 06:54:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706165652; cv=none; b=oPe/SRj8z5SGfHxYUpXxpMhjN/jW+GMk08rbE4mAu6aYMRmT7LyK1FQX2BZxyub3S3cNg7X2qqAYHy/ZeHLZad4YNmwKECt7mdIwFkfLzujTfEypYnrphnXlcmdkLdYKNWq1UNLiitSI5jU+sozNwAm82h0Iq9Yhp8qDRAoBITY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706165652; c=relaxed/simple; bh=re5XjGDf5/5kNM67wjDSBeuJf2pc+Y0fVEHApMogd+s=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=tSwhMLPLSLQxGzWC5BeYXU+YJG0aVsFouviTNKq/7SRIOP5cWMNzFteHIyQ3O+eqcv13a3Xhj0bfgE6bSZNPkIBZ7s/xlOrbxHwseqvZFiKxYpnK06JHtXltUfdC3WANOFAWko09qdXQTP60ZXZWMLE09jivzgJQ4iOmaqWVZD4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=QQXvMpL/; arc=none smtp.client-ip=209.85.210.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pf1-f182.google.com with SMTP id d2e1a72fcca58-6ddcfbc569dso143794b3a.3; Wed, 24 Jan 2024 22:54:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706165649; x=1706770449; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=a/dD/tk5ZZP0MVQmDxuJNtWfiuXCG0ReCzTna959dS0=; b=QQXvMpL/+2qww7CHHaRQxQru1SNJNR+za3yM2lngKdxK7BCQhoq+8bANuoxGtEIGP0 n6Llx30od8rm/mh85jQxnCaCckSiiuHrVwRYpS7gV/8GjkZGLdL2ffwhTAU4ozyZFtfA etvRJFX6T9FpnA16W0e6birqPTmFdeKXK2K/PGPR0mLIIZJBPYUpS3V/KFJw+VikxNHL IGubpqm8iI56W9hWrUpnAAwu1vqyHo8GMDxQ8icOFzHLYNYykRkQog4pmKJkf2u2TBSc +ThArnZF/fosSWSRlvJQC9YxGRzl8uff+D0Q0yx/Vhdc9YoOkeOHbPzRQkuWw4Fe6mKM rvQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706165649; x=1706770449; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=a/dD/tk5ZZP0MVQmDxuJNtWfiuXCG0ReCzTna959dS0=; b=ojbXzMA5t66lHjMl2MNpHU+ZsEL69uCEA8WO6qlJOCzWm2U/8CrFhi9cy+YsSTbscv aCY+BfkCEx51iONXDe6ms5ZfZAQrgRfcs65MX6vAbn+QFz3uvIFBOBMLeqvHnhC+NE0J nFEL7dv7FNbBx9E30jRoYpQiVoAfteu4U95NrnTmmwsnozAa2GpsiDRNkoAiKrx5z/98 b+hRWvsgnA4Nx87q4ZuadaYD89z+lA8EQQb/VYleXs1zavTvldW0PwyKMIsKzXNY7Krd Q45cCczUPd++6aHXeyWUBSpf6EOe/+8s5n5djAq+gIRxLOhMGVY5zx7l8eKXQlJH51K0 bnkw== X-Gm-Message-State: AOJu0Yy6JGCB9aCsAzfxfB4Eb40a7/5kenHDK3S+vgl1aChYQzc2g3DU dHjTR2SvLmA2Kpmx0rlp14shjEH2LrF7Qm8vXBfkGt9Lipqp2NrJFfoHgwrw X-Received: by 2002:a05:6a00:98b:b0:6dd:82b0:1bed with SMTP id u11-20020a056a00098b00b006dd82b01bedmr334564pfg.11.1706165649363; Wed, 24 Jan 2024 22:54:09 -0800 (PST) Received: from ?IPV6:2600:1700:e321:62f0:329c:23ff:fee3:9d7c? ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id d2-20020a62f802000000b006dd6bb57a2asm4773499pfh.114.2024.01.24.22.54.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 24 Jan 2024 22:54:08 -0800 (PST) Sender: Guenter Roeck Message-ID: Date: Wed, 24 Jan 2024 22:54:07 -0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH V3] hwmon: scmi-hwmon: implement change_mode for thermal zones Content-Language: en-US To: "Peng Fan (OSS)" , groeck7@gmail.com, sudeep.holla@arm.com, cristian.marussi@arm.com, jdelvare@suse.com Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, Peng Fan References: <20240125064422.347002-1-peng.fan@oss.nxp.com> From: Guenter Roeck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chKKri2gDhRb2QNNDyBnQn5mRFw7CyuFclAksOdV/sdpQnYlYcRQWOUGY HhQ5eqTRZjm9z+qQe/T0HQpmiPTqQcIaG/edgKVTUjITfA7AJMKLQHgp04Vylb+G6jocnQQX JqvvP09whbqrABEBAAHCwWUEGAECAA8CGwwFAlVcpi8FCRmg08MACgkQyx8mb86fmYHNRQ/+ J0OZsBYP4leJvQF8lx9zif+v4ZY/6C9tTcUv/KNAE5leyrD4IKbnV4PnbrVhjq861it/zRQW cFpWQszZyWRwNPWUUz7ejmm9lAwPbr8xWT4qMSA43VKQ7ZCeTQJ4TC8kjqtcbw41SjkjrcTG wF52zFO4bOWyovVAPncvV9eGA/vtnd3xEZXQiSt91kBSqK28yjxAqK/c3G6i7IX2rg6pzgqh hiH3/1qM2M/LSuqAv0Rwrt/k+pZXE+B4Ud42hwmMr0TfhNxG+X7YKvjKC+SjPjqp0CaztQ0H nsDLSLElVROxCd9m8CAUuHplgmR3seYCOrT4jriMFBtKNPtj2EE4DNV4s7k0Zy+6iRQ8G8ng QjsSqYJx8iAR8JRB7Gm2rQOMv8lSRdjva++GT0VLXtHULdlzg8VjDnFZ3lfz5PWEOeIMk7Rj trjv82EZtrhLuLjHRCaG50OOm0hwPSk1J64R8O3HjSLdertmw7eyAYOo4RuWJguYMg5DRnBk WkRwrSuCn7UG+qVWZeKEsFKFOkynOs3pVbcbq1pxbhk3TRWCGRU5JolI4ohy/7JV1TVbjiDI HP/aVnm6NC8of26P40Pg8EdAhajZnHHjA7FrJXsy3cyIGqvg9os4rNkUWmrCfLLsZDHD8FnU mDW4+i+XlNFUPUYMrIKi9joBhu18ssf5i5Q= In-Reply-To: <20240125064422.347002-1-peng.fan@oss.nxp.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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. > 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 ? Thanks, Guenter > + */ > + config &= ~(SCMI_SENS_CFG_UPDATE_SECS_MASK | > + SCMI_SENS_CFG_UPDATE_EXP_MASK | > + SCMI_SENS_CFG_ROUND_MASK); > + if (new_mode == THERMAL_DEVICE_ENABLED) > + config |= SCMI_SENS_CFG_SENSOR_ENABLED_MASK; > + else > + config &= ~SCMI_SENS_CFG_SENSOR_ENABLED_MASK; > + > + return sensor_ops->config_set(th_sensor->ph, th_sensor->info->id, > + config); > +} > + > static const struct thermal_zone_device_ops scmi_hwmon_thermal_ops = { > + .change_mode = scmi_hwmon_thermal_change_mode, > .get_temp = scmi_hwmon_thermal_get_temp, > }; >