Re: [PATCH v2 0/3] ChromeOS Embedded Controller charge control driver
From: Thomas Weißschuh
Date: Thu Jun 06 2024 - 02:26:03 EST
+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 <linux@xxxxxxxxxxxxxx> 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.
>