Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp298749lqb; Tue, 28 May 2024 16:30:11 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUhyz3io23/6WlKBY2NgapqUduiKzuiQirh2e20zdzDPLRRFfz4q80OXuDJzPnCxLdHmpB2m7Zg1baS2kVOu8hPatW1Yjv5n4JYUbUw8Q== X-Google-Smtp-Source: AGHT+IHwwtfNYni70H5AHXfn1fjkqUJimcgh/wqPz7M6YvqCl/yEeNGV9wMSdYXDZpTAKwPbhmDw X-Received: by 2002:a05:620a:c0c:b0:794:c600:e306 with SMTP id af79cd13be357-794dfb99e78mr98102085a.16.1716939011492; Tue, 28 May 2024 16:30:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716939011; cv=pass; d=google.com; s=arc-20160816; b=Q367ZZS3GoKteehy/FlPLfCpweA4QfU19nEAN8efb8ORRG0E51FLH2748pbkCEKjTW Hgn+p2L3j8XnTFEhFb0bc0sqM0iuQSlbENYdw0aR2sthiKrl6sTzQQA+ATCXB2Ei+a+R NsPXhP19CLWwAsOpUQaP6KGZqfAP8FwACRCb8/tb8R59MoQSW+vb+sVWBQP2S5JLUGQc t+D26y09MzmEdqZlg6xtMhPzzOiZWmvQUMK2gNTPWlok0zspjQvuO1DsLorpQmdi7KbV ZuXdGa1XiMIXKI68s6zZPaR22PFVcXlVMTsE1ahWhalwKxnfyh7FPKQv6Fzu4ycWDM0v f5Gw== 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=S0TMaPpYmodXALWZ1bjrbJlYf3i9gaDMevPP9GtJUgM=; fh=olK6U9ZcAEs8n7aM20GKgFqq9J1UVrIdNzANFuGdjJc=; b=GhJE6enQEIiIRvAxQ71mGIEdwiTDqM0PQ0Y7dgVkejSFtPRXg9IE0E00NTkJC6lyCn LPTlnKq0flHKlA5CCx6D96vgOZxPuFrL8pSJ9Vzjdmb2xKz9dopTleMng7JJUN/cWPBO VCerpTGMTt2Kc/EP0K6o+BUXLFrbUmfrKn7z2CwvQdUXz78LZjAvP0aHuk7wScLR01AK VcaJln496nwo1JEpf6+PZFgcFx3ZTHsKMkY/snxb1Bpg+3P0btEPKLx8in9nbbtBbNVR wFsGrNCeKnZjacxHF7pgRIAin9jkYl0byO7hYMTRgB+R56MivoyybRkr949GiJOALaCY 7UJg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=PS8UR4rN; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-193231-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193231-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id af79cd13be357-794abd608easi1271808585a.749.2024.05.28.16.30.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 16:30:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-193231-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=PS8UR4rN; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-193231-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193231-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 2A90F1C24189 for ; Tue, 28 May 2024 23:30:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A94F013F432; Tue, 28 May 2024 23:30:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PS8UR4rN" Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (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 DCF3913F43B; Tue, 28 May 2024 23:30:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716939004; cv=none; b=IWRVRTkv+6cshGUAL1Sz4Qs6rV1w+HCvD9eQByxd3my6ySC9UwJWnoBvN6lBewSd/2eR/bc+2hDqH/F9JeLBN6vUZNb129u7oOnJwAqdcE0FgYj4CLOE0QWDeX7UoAzlCvWk/TVgYP7p7j6k14E7p5ra8K3G5XTVLMFNMTwdiXs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716939004; c=relaxed/simple; bh=u3JWoyCmWuIDEXzw4nozaITn17g9692yK6khrCNgFsk=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=RlJILBUmZDAjrmgW6UKh4OvCy3pEB6iUT+3BXpAmCiyD5Nrw0aEULfFECBfNbBmbbbv2u/rOkrRPIXBtiEsWJSKb49Uli8OCIYrpVQw3GDk4/XxEngST8jRQhMrpj0dD+WWJ/XK75Osu1ajiKTjFUmTOtdpoyvqvwMfzUpgkXJo= 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=PS8UR4rN; arc=none smtp.client-ip=209.85.214.180 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-f180.google.com with SMTP id d9443c01a7336-1f48e9414e9so3168665ad.0; Tue, 28 May 2024 16:30:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716939002; x=1717543802; 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=S0TMaPpYmodXALWZ1bjrbJlYf3i9gaDMevPP9GtJUgM=; b=PS8UR4rNmZePUWkAkTz9Tw9wBFk0gYhBcJZCS2S632kP2Tyv+FmQ8Ya1kKd9WW46Sd IM7iPf0hkBynaIO+Fvv2AvsbjBbhFev+DKlbFcPRuCyIwpXzAbic27aKJTCFhF8QvnOj KPqq9Ga+m7hQeUz7ZqK3SSjBhajnlySLdMiIbMXoctfaU88e7oSkD7wJsFdxAy9wA9Xv iZw7renWb+HLR/q17MsWt68oCBPHsAYPravQMGn6wQIkJjwJzmNKtkeCKDMKYDSVlL2U uQ1rI+ehJWemhsFfk62LG/C/ttoa66NGUigT5M8rF4zSl2+CSuI/75LW5fk9HyM3bCPq hGzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716939002; x=1717543802; 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=S0TMaPpYmodXALWZ1bjrbJlYf3i9gaDMevPP9GtJUgM=; b=R3ipK4kpE7aZ5voN6YCd81P1mPPudyqfa/UwOEiXelkkpwLLchXgYM8Ea7h9mxo8r4 sc3504bQ5sxFHLPRP5cVkqavfZ/1YJQ5UqAFirktvXQN/B2nyRmKFGrQ4hpy0XJCIZsL Q9aatUCx4cd9CfOE5epTp7EblDvV/NFvh4Ovub8o7cl3H9UUMrwtAtLoXUlbtcfim9L3 UkzAgwYtSX5Im5X8TRjtDxI3UN0hbAXzg1eGvsUjKuiZIG53ddvAFdsWz2CmpofsSGUW +QHqt6CJMOtPJ90AqjT9s2JwA7b3axVZfkuQVKrkRwlpTkRzFHzsZfQ2p58hG3I3Vg7e jeBA== X-Forwarded-Encrypted: i=1; AJvYcCUZA7gSc2LXRHvkDIYK1PKdbIiErT3rNRaNnFQ4KBzAcys2GkjTh3zk+DOXTJU61/ovD92BQjZkk19IjIIVqvWwPEnbgULKoMg+drAM9dMc3IVDa5/WQj47o1JIIG6e/74VVg5u5DvOsdk= X-Gm-Message-State: AOJu0YyDMf+QIoywOc5VwxiCJJiisQZ4vxC/NedSEPKql7QyqgXUCzXm EFizSTnbXkjb4Zuo8t+Ibc9TDa8dnT/Wae0BucVzB19aqvOuLTJN X-Received: by 2002:a17:903:22cb:b0:1f0:9951:8491 with SMTP id d9443c01a7336-1f4eab1798fmr6315325ad.29.1716939001940; Tue, 28 May 2024 16:30:01 -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-1f44c757845sm86133405ad.5.2024.05.28.16.29.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 28 May 2024 16:30:00 -0700 (PDT) Sender: Guenter Roeck Message-ID: <6824f030-92da-4439-af3b-8c2498f4382e@roeck-us.net> Date: Tue, 28 May 2024 16:29:58 -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: =?UTF-8?Q?Thomas_Wei=C3=9Fschuh?= Cc: Stephen Horvath , 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/omy6UyH6ykLOPFugl+hVL2Prf8xrXuZe1CM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m0hwPSk1J64R8O3HjSLdertmw7eyAYOo4RuWJguYMg5DRnBk 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/28/24 09:15, Thomas Weißschuh wrote: > On 2024-05-28 08:50:49+0000, Guenter Roeck wrote: >> On 5/27/24 17:15, Stephen Horvath wrote: >>> On 28/5/24 05:24, Thomas Weißschuh wrote: >>>> 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. > > In one of my testruns this actually happened. > When running on battery, one specific of the CPU sensors sporadically > returned EC_FAN_SPEED_NOT_PRESENT. > What Chromebook was that ? I can't see the code path in the EC source that would get me there. >>>> 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. > > Ack. > > Currently I have the following logic (for both fans and temp): > > if NOT_PRESENT during probing: > make the attribute invisible. > > if any error during runtime (including NOT_PRESENT): > return -ENODATA and a FAULT > > This should also handle the sporadic NOT_PRESENT failures. > > What do you think? > > Is there any other feedback to this revision or should I send the next? > No, except I'd really like to know which Chromebook randomly generates a EC_FAN_SPEED_NOT_PRESENT response because that really looks like a bug. Also, can you reproduce the problem with the ectool command ? Thanks, Guenter