Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp178595lqt; Wed, 5 Jun 2024 23:26:04 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWFdRpmB4rKftbgzFY6wh2SSkz81xk8SbqtRXMuhYbDpYlUxlAp5C8IZ5TkfBWtkPW8k/BnsuBnuMA6qops4nJn+cXspar7Uh3NTM0c1A== X-Google-Smtp-Source: AGHT+IGC9x9geBGD7Aekqwvgqo/TwfJwLQ6qA5lBFDadvkbsGln++saEw+08L/JHdTTPSk/AsIRp X-Received: by 2002:a05:6a20:9193:b0:1b2:1bf1:2b03 with SMTP id adf61e73a8af0-1b2b6f69526mr5867670637.26.1717655163752; Wed, 05 Jun 2024 23:26:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717655163; cv=pass; d=google.com; s=arc-20160816; b=D78AWgkK5xsjxAUppN+IwGYKMBLAi8wvRGFIN8iCFV25TLnAwEL8z7XprW+VWUo2kp VCD9EdH3ACJNk4gAzztZ80IgziTRK1OYnZuIpv1+Q+gnpiHKLK2x3Vrc0SqzOoSA9uo2 VE4Zwp5riYZpvOp+bHsTUiLfkZ9ddQIcobaKllBylFAENBNwz6nvR/myu2CG4UZmanrl ogQtVICO9gSvTfh40NpFjzjqCEpIKaPDh6HDOvoZQsLBFe2+KIcJROLgjxL4/abDw425 Fm/JYqdO2n/VOeo76ggdsZjn5VueseQaffu8kx6cohqL90YWUTJk9hJjyE/DhxsqY2D9 BoQw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=E/GHS/8H6SF8BgKS4wy5ha4cHnsfsSdDr8L+DlYCj0Q=; fh=ZAb43AhE7+eNWEO5r/0LpnIsdknKJRYSu7a8ya5JXYI=; b=W8iPoHzat+tNngpYoAUyiLW1BoFEnZuHEfMfp81WPERxmzfvXnXrFKXi9IBjgk8xK9 etNI91PxZWhaw/TE9IMxSyt3VIVGSLQu3MTfLBZDjW/Px2AHiOoDlSQeHUTF5OY9SKND p5UyE+hRA9DjiJJ7i0E/blw9iA7SSlKQZjMm+oKpVI2H2T8UtmUCjZvz3Ax9UrFi/SzW /UjjujhA17TwlZwsC6VJW+C7BHdEzUfMtlHCQLXEIjB+zgDzbbBrGKmRmcwbUkC8mmdK nEyjGLpTnOImsqctWRFZJqe4S3kBAvg3ejpa2n08owP+aAyM/A0fMX1jik90HnBZAeJF 3hEg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@weissschuh.net header.s=mail header.b=ap+aB7M7; arc=pass (i=1 spf=pass spfdomain=weissschuh.net dkim=pass dkdomain=weissschuh.net dmarc=pass fromdomain=weissschuh.net); spf=pass (google.com: domain of linux-kernel+bounces-203652-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-203652-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=weissschuh.net Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d2e1a72fcca58-703fd3b31c0si587019b3a.135.2024.06.05.23.26.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 23:26:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-203652-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=@weissschuh.net header.s=mail header.b=ap+aB7M7; arc=pass (i=1 spf=pass spfdomain=weissschuh.net dkim=pass dkdomain=weissschuh.net dmarc=pass fromdomain=weissschuh.net); spf=pass (google.com: domain of linux-kernel+bounces-203652-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-203652-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=weissschuh.net 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 126F32852DE for ; Thu, 6 Jun 2024 06:26:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 752D57347C; Thu, 6 Jun 2024 06:25:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="ap+aB7M7" Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (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 690D12E3E5; Thu, 6 Jun 2024 06:25:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717655156; cv=none; b=uUl5Aoemt+xfkajQtvFKjMlrLc3/kyDBW9x1CU9IWTZLUxWx4UTYhHcptTcshLHa5djoHapv/rleQbPrriz5Pga71NC5Dd7woYdBsEwTm51gf6nAOG1qlBeb4LpMb79Jf7SmsVBC8by1HCz0PuIHxGgL8RtPET8Cv6krxEQ0Qag= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717655156; c=relaxed/simple; bh=Wfeg8GAi9GwSyPrICtL0MY874pcQ+nuX+//SQF4Q63U=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=R+aSEPRVkltBXQe7RYZWPI4074npWMZWrH+YrbR5eRcFnVIiaLEt4BCRsFkttawp4PcNfAcZ/sI3nVRYmNbB0WDKFQi9hCpTvLF4kIMUbE6/agC6nywhGY6iBQHt7sFKTdrIZL399M1NrQJae5ZdPGHKqJkF0xCbt+eZreHk9qw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=ap+aB7M7; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1717655145; bh=Wfeg8GAi9GwSyPrICtL0MY874pcQ+nuX+//SQF4Q63U=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ap+aB7M7eNNAVWFNB2wesEkU4e+ielGbEoJAtWC2AXSaK71bYdLmrZz2sBOxDf+oy gPIdX+GOTSLEqMs4oG9uMHcRo2QJP9Zy1aPaPP12FbdZFFgKY+JOUm7Td/j/o1t+lr IoQOALg1kOo23Xw3657kI//xdH6vkp8ZqcrygMyA= Date: Thu, 6 Jun 2024 08:25:45 +0200 From: Thomas =?utf-8?Q?Wei=C3=9Fschuh?= To: Mario Limonciello , Matt Hartley Cc: Dustin Howett , Benson Leung , Guenter Roeck , Sebastian Reichel , Lee Jones , chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Stephen Horvath , Rajas Paranjpe Subject: Re: [PATCH v2 0/3] ChromeOS Embedded Controller charge control driver Message-ID: References: <20240528-cros_ec-charge-control-v2-0-81fb27e1cff4@weissschuh.net> <5baf3caf-dc09-4829-96db-2666fc902710@t-8ch.de> 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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: +Matt, the Linux support lead for Framework. Hi Matt, below we are discussing on how to implement charge controls for ChromeOS EC devices including Framework laptops in mainline Linux. Some feedback would be great. On 2024-06-05 15:32:33+0000, Mario Limonciello wrote: > On 6/5/2024 04:33, Thomas Weißschuh wrote: > > On 2024-06-04 20:27:57+0000, Dustin Howett wrote: > > > On Mon, Jun 3, 2024 at 3:59 PM Thomas Weißschuh wrote: > > > > > > > > Can you try disabling all of the Framework-specific charge control > > > > settings and test again? > > > > Probably the different, disparate logics in the Framework ECs are > > > > conflicting with each other. > > > > > > Fascinating! This board does indeed support charge limiting through > > > both interfaces. It looks like the most recently set one wins for a > > > time. > > > > If it is the most recent one, shouldn't the driver have worked? > > What does "for a time" mean? > > I'm using only the upstream EC command and that seems to work fine. > > > > > The UEFI setup utility only sets the framework-specific charge limit value. > > > > > > We should probably find some way to converge them, for all of the > > > supported Framework Laptop programs. > > > > In the long term, Framework should align their implementation with > > upstream CrOS EC and either drop their custom command or make it a thin > > wrapper around the normal the upstream command. > > > > (As you are familiar with EC programming maybe you want to tackle this?) > > > > Until then I think we can detect at probe-time if the Framework APIs are > > available and use them to disable the Framework-specific mechanism. > > Then the CrOS EC commands should be usable. > > > > The drawback is, that userspace using the Framework APIs will break > > the driver. That userspace would need to migrate to the standard UAPI. > > How does userspace access the Framework APIs? Surely it needs to go through > the kernel? Could you "filter" the userspace calls to block them? > > For example this is something that currently happens in the dell-pc driver > to block userspace from doing thermal calls and instead guide people to the > proper API that the driver exports. This would work when userspace uses /dev/cros_ec. But the EC can also used via raw port IO which wouldn't be covered. Given that /dev/cros_ec wasn't usable on Framework AMD until v6.9 it's not unlikely users are using that. And technically both aproaches would break userspace. Another aproach would be to not load the module on Framework devices which implement their custom command (overwritable by module parameter). Framework unifies the implementation of their command with the core CrOS EC logic so both commands work on the same data. The custom command is adapted to also implement a new command version. This is completely transparent as the old version will continue to work. We update the Linux driver to recognize that new command version, know that they are now compatible and probe the driver. Newer devices could also drop the custom command and the driver would start working. This scheme requires some cooperation from Framework, though. > > > > Also the settings set in the firmware would be ignored at that point. > > > > I don't want to use the functionality of the Framework command because > > it's less featureful and I really hope it will go away at some point. >