Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp60733lqb; Tue, 28 May 2024 08:51:23 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVUc1BOOg8xUM9j0Kh+hK3wJPbYNTW4o01HwfEBw1tqRLyRKMA9a9Tjw9EdoGq9MG1zNbQ5BflVaECmJFd1OM/EFMl+hUeKyJ7qvyiFAw== X-Google-Smtp-Source: AGHT+IEChaOR7w11MO96xVqIHZxu+zfFXNuTnCY3kJrsF6TX3kMB71MfFd2UzkDWUG7r3uKgobG5 X-Received: by 2002:a17:902:c94d:b0:1f4:98f4:4763 with SMTP id d9443c01a7336-1f498f449a0mr68356685ad.53.1716911483441; Tue, 28 May 2024 08:51:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716911483; cv=pass; d=google.com; s=arc-20160816; b=Thk/RP5wt5u2RLSJoLRUsXk9qHSn4lNeSuYjp+C2sSo61pwLhiKlQOmAgvbOVKtqSe LJSrl6M1Zjg/BsJVKFkL+9K7EsL30b6DUfR9H+eLQxw62xCGcFsQUkfFBNynZenhDOMA AgbzmRiBsf+G6cVKaAUHOTNldh4sthYXP/4r2LZkq3TtCdOedAZxiDqw3/jBkNsbHN6l ICKEyg0seyLcGv763lGEHqer1EoILL3oe6dA4U/eOPRXbzfBsNxeqOo1KpsmH0XPdrXE T48JIFp8YBiYEKH5YVeAc9C7e3dwSSB4GEXuLI91yqiZOJRCyV0pTqucPVCIuz96ZYVN dcvQ== 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 :content-language:references:cc:to:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :sender:dkim-signature; bh=RPIwnjlc45VQT0mMiNcUcWFb46f4+KlFVHgSXlBA+XE=; fh=YohVjmzTvFTg9Ao7DLO01E5CDLFrZwNHqnfQMh3eQik=; b=Y41b+oAIgEzZ4XdV/N02inrJp5+PtLfbLwTZ8tr+rz2EoZRJgFQnjhMF0ESiu/eL/b 7oOyVskKlOG3N4lhDQHgB/LbpmD+CVaq6YsjulgR88hEwQEazU6yLE34agXuAqUXi2p2 5q1DT83hN5kfFuUZKNgaAGvydTcEdhcDTMviCi4I2jsQeyl4lxk/myu64j+tQhusl0E3 MCDxprRgntNSRnJNdv7Ha4vzhDOLCAH/TUR8AOz+Y1KeAEt9a/VYEm34J2iUz+MasPhS 1c5Sibh2I7wYmADn/oC79KRx4jWuyYugzanv8N7iFFRnaPmHzqhtk0g1FRyrpEtuWBYQ 1ZWA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=aekQx4jR; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-192693-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-192693-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f44c78a32csi80328625ad.108.2024.05.28.08.51.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 08:51:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-192693-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=aekQx4jR; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-192693-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-192693-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 3CA73B22621 for ; Tue, 28 May 2024 15:51:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0A775171E71; Tue, 28 May 2024 15:50:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aekQx4jR" Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (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 3C49E171E4D; Tue, 28 May 2024 15:50:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716911454; cv=none; b=b6/vG3BIYaGF/O0U9c47A9gG+8rzBJ/u9RHmbo20zUOEYfX/nAMiSdz+4tzd4ItQMzxNPzIadBV2BdXLjgMRqzzaTCxUVGFJtrQRlfa0Vdql5+rRNBEv0MgP3tFUKrLMrlOx+vWxUb3Kt1HgwaeJKaRRqvjE7CJIVM3B11wSy2Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716911454; c=relaxed/simple; bh=w893qe/kealbejw9LpXOPnWIUhnLGtUJMOvyHH8ODbY=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=bD0NAAUlCXUiGJrcULdXVULApvWCclQyy6r3NcLqL5xj5fv8ZDY+2og0bLd3BlZUl2bSKDtUOSJiZ43oqgg0cfnt+4XGC9gnsXzS0+TR1hpDkZ01qexmrIrBfzteBo2TG6/tP2ICPcmmjQoRgBPmonOB+rJ0wu3fRCmZIdKmIbs= 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=aekQx4jR; arc=none smtp.client-ip=209.85.214.173 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-pl1-f173.google.com with SMTP id d9443c01a7336-1f44b4404dfso8882785ad.0; Tue, 28 May 2024 08:50:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716911452; x=1717516252; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:sender:from:to:cc:subject:date:message-id:reply-to; bh=RPIwnjlc45VQT0mMiNcUcWFb46f4+KlFVHgSXlBA+XE=; b=aekQx4jRlitH7iwD+PQ2E3FVTuev1ovyyvr9GtWmO4w7fHlyqrKnt93Y45lSqTA6Mh LhH4ULsRn5he8etVdCFAG8S7kOoaZoQKtv/H2nhzq00dHmiqMHP2a35rfMQglEyuRWaA PvUouDOFroGpl/2x+i3s34hWog54RakxRPEA85IJk0N6hVv9AdaOrg/wNSHuXDXsnjNj LtjqPjQTmO2EPClSVHWFFLgLWkgo9OrzApG/tK0wRqPapKgvKfQFvWRcVNA4yBX6tEgB 4vTsXgd37k1kQ6ckEjVW4mOTBbnR64KFGTSUN13xk13ZCLlcyxBvYKYZuxh+0gSzliQK JiNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716911452; x=1717516252; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:sender:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=RPIwnjlc45VQT0mMiNcUcWFb46f4+KlFVHgSXlBA+XE=; b=gsNtSXE58KxDQWxisNROhpzawO4zU2XYnrHCbKOwpmMG2PK/yaE79DuVl+rlj3jDU/ g0ax2l6WSmsjnripS584fXJlwby9CgpyE6L7jvD0AvemOQpG1OLhZhoKmwh13w+IBh/y Oh+qkOK1h8ovzFqu95H/kmDkLmo2+n6fr6t1nQ/XuXhAX7FbdM3aa2Gp9hG1x8BuRwZA EVDWgoVABcC6nqBIkxFiLCq+CrgwH66IP0rij1FbnaioJI7kBhzmezhk5D9gmvKqcTa+ cmLv651umnU0gPdMsbFOnWlaigh1TToD9r7eSWwItV+X9CweOOO9HWFZ5xKXn1xvYWpF /ptw== X-Forwarded-Encrypted: i=1; AJvYcCXn2sfmNvoCqHjLQ1qVYFawpfyGLiUIb7c/5Hz5NeZZ8lKVMIVOMhJspDStiD1O0fLPqGWDp4pQh5UdoT/8Us4OcglUCWmpP+DR9PDL/EhghKai5fYPeG+GTS8FzGDnMmfXaY132mRwvAA= X-Gm-Message-State: AOJu0YwgyHDL3kb3Qs8hW+Eu0e9V04xIRyKlbyK9OXXlogK5T0H2MMwB 1ZGgxKvGoQGhaL651E1b2J4xEe/Lquy8CF1XDPzhpjUcwiGx6tFu X-Received: by 2002:a17:902:e544:b0:1f4:aac7:ffff with SMTP id d9443c01a7336-1f4aac8035fmr51948175ad.20.1716911452471; Tue, 28 May 2024 08:50:52 -0700 (PDT) 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 d9443c01a7336-1f44c967a45sm81765515ad.167.2024.05.28.08.50.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 28 May 2024 08:50:51 -0700 (PDT) Sender: Guenter Roeck Message-ID: Date: Tue, 28 May 2024 08:50:49 -0700 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 v2 1/2] hwmon: add ChromeOS EC driver To: Stephen Horvath , =?UTF-8?Q?Thomas_Wei=C3=9Fschuh?= Cc: Jean Delvare , Benson Leung , Lee Jones , Guenter Roeck , linux-kernel@vger.kernel.org, linux-hwmon@vger.kernel.org, chrome-platform@lists.linux.dev, Dustin Howett , Mario Limonciello , Moritz Fischer References: <20240507-cros_ec-hwmon-v2-0-1222c5fca0f7@weissschuh.net> <20240507-cros_ec-hwmon-v2-1-1222c5fca0f7@weissschuh.net> <9cf224dd-51eb-4608-abcf-06f337d08178@t-8ch.de> Content-Language: en-US From: Guenter Roeck Autocrypt: addr=linux@roeck-us.net; keydata= xsFNBE6H1WcBEACu6jIcw5kZ5dGeJ7E7B2uweQR/4FGxH10/H1O1+ApmcQ9i87XdZQiB9cpN RYHA7RCEK2dh6dDccykQk3bC90xXMPg+O3R+C/SkwcnUak1UZaeK/SwQbq/t0tkMzYDRxfJ7 nyFiKxUehbNF3r9qlJgPqONwX5vJy4/GvDHdddSCxV41P/ejsZ8PykxyJs98UWhF54tGRWFl 7i1xvaDB9lN5WTLRKSO7wICuLiSz5WZHXMkyF4d+/O5ll7yz/o/JxK5vO/sduYDIlFTvBZDh gzaEtNf5tQjsjG4io8E0Yq0ViobLkS2RTNZT8ICq/Jmvl0SpbHRvYwa2DhNsK0YjHFQBB0FX IdhdUEzNefcNcYvqigJpdICoP2e4yJSyflHFO4dr0OrdnGLe1Zi/8Xo/2+M1dSSEt196rXaC kwu2KgIgmkRBb3cp2vIBBIIowU8W3qC1+w+RdMUrZxKGWJ3juwcgveJlzMpMZNyM1jobSXZ0 VHGMNJ3MwXlrEFPXaYJgibcg6brM6wGfX/LBvc/haWw4yO24lT5eitm4UBdIy9pKkKmHHh7s jfZJkB5fWKVdoCv/omy6UyH6ykLO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j trjv82EZtrhLuLjHRCaG50OOm0hwPSk1J64R8O3HjSLdertmw7eyAYOo4RuWJguYMg5DRnBk WkRwrSuCn7UG+qVWZeKEsFKFOkynOs3pVbcbq1pxbhk3TRWCGRU5JolI4ohy/7JV1TVbjiDI HP/aVnm6NC8of26P40Pg8EdAhajZnHHjA7FrJXsy3cyIGqvg9os4rNkUWmrCfLLsZDHD8FnU mDW4+i+XlNFUPUYMrIKi9joBhu18ssf5i5Q= In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 5/27/24 17:15, Stephen Horvath wrote: > Hi Thomas, > > On 28/5/24 05:24, Thomas Weißschuh wrote: >> Hi Stephen, >> >> On 2024-05-25 09:13:09+0000, Stephen Horvath wrote: >>> I was the one to implement fan monitoring/control into Dustin's driver, and >>> just had a quick comment for your driver: >>> >>> On 8/5/24 02:29, Thomas Weißschuh wrote: >>>> The ChromeOS Embedded Controller exposes fan speed and temperature >>>> readings. >>>> Expose this data through the hwmon subsystem. >>>> >>>> The driver is designed to be probed via the cros_ec mfd device. >>>> >>>> Signed-off-by: Thomas Weißschuh >>>> --- >>>>    Documentation/hwmon/cros_ec_hwmon.rst |  26 ++++ >>>>    Documentation/hwmon/index.rst         |   1 + >>>>    MAINTAINERS                           |   8 + >>>>    drivers/hwmon/Kconfig                 |  11 ++ >>>>    drivers/hwmon/Makefile                |   1 + >>>>    drivers/hwmon/cros_ec_hwmon.c         | 269 ++++++++++++++++++++++++++++++++++ >>>>    6 files changed, 316 insertions(+) >>>> >> >> >> >>>> diff --git a/drivers/hwmon/cros_ec_hwmon.c b/drivers/hwmon/cros_ec_hwmon.c >>>> new file mode 100644 >>>> index 000000000000..d59d39df2ac4 >>>> --- /dev/null >>>> +++ b/drivers/hwmon/cros_ec_hwmon.c >>>> @@ -0,0 +1,269 @@ >>>> +// SPDX-License-Identifier: GPL-2.0-or-later >>>> +/* >>>> + *  ChromesOS EC driver for hwmon >>>> + * >>>> + *  Copyright (C) 2024 Thomas Weißschuh >>>> + */ >>>> + >>>> +#include >>>> +#include >>>> +#include >>>> +#include >>>> +#include >>>> +#include >>>> +#include >>>> +#include >>>> +#include >>>> + >>>> +#define DRV_NAME    "cros-ec-hwmon" >>>> + >>>> +struct cros_ec_hwmon_priv { >>>> +    struct cros_ec_device *cros_ec; >>>> +    u8 thermal_version; >>>> +    const char *temp_sensor_names[EC_TEMP_SENSOR_ENTRIES + EC_TEMP_SENSOR_B_ENTRIES]; >>>> +}; >>>> + >>>> +static int cros_ec_hwmon_read_fan_speed(struct cros_ec_device *cros_ec, u8 index, u16 *speed) >>>> +{ >>>> +    u16 data; >>>> +    int ret; >>>> + >>>> +    ret = cros_ec->cmd_readmem(cros_ec, EC_MEMMAP_FAN + index * 2, 2, &data); >>>> +    if (ret < 0) >>>> +        return ret; >>>> + >>>> +    data = le16_to_cpu(data); >>>> + >>>> +    if (data == EC_FAN_SPEED_NOT_PRESENT) >>>> +        return -ENODEV; >>>> + >>> >>> Don't forget it can also return `EC_FAN_SPEED_STALLED`. >> >> Thanks for the hint. I'll need to think about how to handle this better. >> >>> Like Guenter, I also don't like returning `-ENODEV`, but I don't have a >>> problem with checking for `EC_FAN_SPEED_NOT_PRESENT` in case it was removed >>> since init or something. >> That won't happen. Chromebooks are not servers, where one might be able to replace a fan tray while the system is running. >> Ok. >> >>> My approach was to return the speed as `0`, since the fan probably isn't >>> spinning, but set HWMON_F_FAULT for `EC_FAN_SPEED_NOT_PRESENT` and >>> HWMON_F_ALARM for `EC_FAN_SPEED_STALLED`. >>> No idea if this is correct though. >> >> I'm not a fan of returning a speed of 0 in case of errors. >> Rather -EIO which can't be mistaken. >> Maybe -EIO for both EC_FAN_SPEED_NOT_PRESENT (which should never happen) >> and also for EC_FAN_SPEED_STALLED. > > Yeah, that's pretty reasonable. > -EIO is an i/o error. I have trouble reconciling that with EC_FAN_SPEED_NOT_PRESENT or EC_FAN_SPEED_STALLED. Looking into the EC source code [1], I see: EC_FAN_SPEED_NOT_PRESENT means that the fan is not present. That should return -ENODEV in the above code, but only for the purpose of making the attribute invisible. EC_FAN_SPEED_STALLED means exactly that, i.e., that the fan is present but not turning. The EC code does not expect that to happen and generates a thermal event in case it does. Given that, it does make sense to set the fault flag. The actual fan speed value should then be reported as 0 or possibly -ENODATA. It should _not_ generate any other error because that would trip up the "sensors" command for no good reason. Guenter --- [1] https://chromium.googlesource.com/chromiumos/platform/ec