Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for framework-laptop-kmod as an alternative to ectool #47

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

NAKlama
Copy link
Contributor

@NAKlama NAKlama commented Jun 6, 2024

Since there is a kernel module (https://github.com/DHowett/framework-laptop-kmod
) allowing fan control over sysfs, I added the ability to use that instead of ectool.
It would allow those unhappy with the supplied binary to use the kernel module instead.

@NAKlama
Copy link
Contributor Author

NAKlama commented Jun 6, 2024

I've also added using the GPU temperature as well (as an option).
Since the Framework 16 uses the same fan to cool the CPU and GPU, a high GPU temperature with a low CPU temperature would not cause the fans to speed up, this way it does.

@leopoldhub
Copy link
Collaborator

Hello, thank you for your contribution, I will check your various PRs in detail in about 3 hours.

At first glance, this one looks pretty good but I think all these conditions add a lot of complexity (and more in the future if other ways to get temperature/control the fans are implemented as well).
Would you mind making FanController abstract and creating inherited subclasses for ectool and kmod instead?

This should reduce the complexity and make the code a bit easier to read.

@leopoldhub leopoldhub self-requested a review June 6, 2024 13:39
@NAKlama
Copy link
Contributor Author

NAKlama commented Jun 6, 2024

I can do that.

@NAKlama
Copy link
Contributor Author

NAKlama commented Jun 6, 2024

How is this?

@NAKlama
Copy link
Contributor Author

NAKlama commented Jun 6, 2024

Did a quick test using both ectool and framework-laptop-kmod.
Nothing thorough, but had it running and changed strategies for a couple of minutes each.

@leopoldhub
Copy link
Collaborator

Hi, thanks for your hard work!
I have left some comments on your modifications.
Please let me know if you have any questions

return self.configuration.getDefaultStrategy()
return self.configuration.getDischargingStrategy()
@abstractmethod
def pause(self):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.active = False should be present in any implementation of the pause method, so I think that this function should not be abstract but extended instead.

text=True).stdout
return len(re.findall(r'Flags.*(AC_PRESENT)', rawOut)) > 0
@abstractmethod
def setSpeed(self, speed: int) -> None:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same applies here, self.speed = speed should always be present.


return round(temps[0], 1)
def getBatteryChargingStatus(self):
Copy link
Collaborator

@leopoldhub leopoldhub Jun 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part still uses ectool even in kmod mode, is there an equivalent?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I never used that feature. Totally overlooked this. ;)

for file in hwmon_interface.iterdir():
if file.name.startswith("temp") and file.name.endswith("_input"):
self.sysfs_get_temp.append(file)
elif self.configuration.getUseGPU() and device_name == "amdgpu":
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm struggling to understand why the end user would want to disable the GPU temperature sensor.
Please let me know me if I have missed something.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disabled is the default state, if I can, I make changes to code that don't change the main functionality.
Since it didn't include the dGPU temperature before, that's the default configuration right now.
Still, it's preferable to have it on. ;)

Copy link
Collaborator

@leopoldhub leopoldhub Jun 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it didn't include the dGPU temperature before

In fact, it does since March
You can disable it if you want, but it definitely should be on by default.
If this option stays, could you please also document it in the README, and add its default state in the config.json?

and len(self.sysfs_reset_to_auto_files) == 0 and len(self.sysfs_get_temp) == 0:
raise KModNotWorkingException(f"Could not find files necessary to control fans")

if strategyName is not None and strategyName != "":
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part should be present in every constructor, I think it might deserves its own function if you want to call it only after the initialization.

args = parser.parse_args()

if args.run:
strategy = args.strategy
if strategy is None:
strategy = args._strategy
fan = FanController(configPath=args.config, strategyName=args.strategy)
config = Configuration(args.config)
mode = config.getMode()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the choice between using kmod or ectool should be made using the script arguments instead of the config file as it cannot be changed at runtime.
This would also allow users to choose via the install script.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be changed at runtime.
We could easily swap them out.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing that would require a complete rework of our runtime cycles, and considering the fact that it certainly will never be changed after the initial setup, I believe it is not worth it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm just playing with the idea, I know it's pointless to change it at runtime.

@leopoldhub
Copy link
Collaborator

Hi @NAKlama,

Are you still working on it?
If not, I will close this PR in about a week.

Have a nice day

@leopoldhub leopoldhub added the inactive This has not been worked on for a while or do not receive response label Aug 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
inactive This has not been worked on for a while or do not receive response
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants