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

core|sys: Guard periph_pm calls #20523

Merged
merged 5 commits into from
Apr 9, 2024
Merged

Conversation

MrKevinWeiss
Copy link
Contributor

@MrKevinWeiss MrKevinWeiss commented Apr 2, 2024

Contribution description

It would seem that either we need to require the periph_pm module in shell or make it optional... since we have many other optional modules here and we still may want the RIOT_VERSION command, lets make it optional for now.

Edit: I also added guards in other places that use periph_pm without requiring it. The syscalls in newlib and picolib are probably also a good candidate for having this optional. There are many features withing the *lib that can be used without pm stuff.

Testing procedure

Remove the periph_pm feature from a board and try to examples/saul such as on this PR and you should not get a linking error that looks like:

/opt/gcc-arm-none-eabi-10.3-2021.10/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld: /data/riotbuild/riotbase/examples/saul/bin/gba_cartridge/shell_cmds/sys.o: in function `_reboot_handler':
/data/riotbuild/riotbase/sys/shell/cmds/sys.c:38: undefined reference to `pm_reboot'
collect2: error: ld returned 1 exit status

Issues/PRs references

discovered while testing #19519

It would seem that either we need to require the periph_pm module in shell
or make it optional... since we have many other optional modules here
and we still may want the RIOT_VERSION command, lets make it optional for now.
@github-actions github-actions bot added the Area: sys Area: System label Apr 2, 2024
@MrKevinWeiss MrKevinWeiss added Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors) CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed Area: sys Area: System labels Apr 2, 2024
@riot-ci
Copy link

riot-ci commented Apr 2, 2024

Murdock results

✔️ PASSED

b8c4617 sys/*: expose periph/pm.h

Success Failures Total Runtime
10045 0 10045 14m:40s

Artifacts

@Teufelchen1 Teufelchen1 added this pull request to the merge queue Apr 2, 2024
@maribu
Copy link
Member

maribu commented Apr 2, 2024

Interesting. Historically, I think all platforms have implemented pm_reboot() without implementing any other pm_<foobar>() and did not provide periph_pm as feature. E.g. AVR was one of these (but now does provide proper periph_pm) and MSP430 still is one of these.

I don't believe the historic way of having one pm_<foobar>() function singled out does not make any sense.

I guess, it would have made sense to have separate features for real power management and reboot capabilities. Also, I'm not sure if the reboot feature should really be pm_reboot(), but maybe rather some cpu_reboot() and grouped elsewhere. The reboot feature can be implemented in a number of ways, and most don't interact with the power management subsystem at all but rather e.g. abuse the watchdog or similar.

tl;dr

I think this is an improvement and should go in. But it is not yet the final solution and will cause regressions e.g. for MSP430.

@MrKevinWeiss MrKevinWeiss removed this pull request from the merge queue due to a manual request Apr 2, 2024
@github-actions github-actions bot added Area: core Area: RIOT kernel. Handle PRs marked with this with care! Area: sys Area: System labels Apr 2, 2024
@MrKevinWeiss MrKevinWeiss changed the title sys/shell/cmds: Guard periph_pm calls core|sys: Guard periph_pm calls Apr 2, 2024
@MrKevinWeiss MrKevinWeiss added the Process: needs >1 ACK Integration Process: This PR requires more than one ACK label Apr 2, 2024
@github-actions github-actions bot added the Process: missing approvals Integration Process: PR needs more ACKS (handled by action) label Apr 2, 2024
@MrKevinWeiss
Copy link
Contributor Author

Hmm, I updated it a bit more after discovering more unguarded calls.

But it is not yet the final solution and will cause regressions e.g. for MSP430.

I will look into that... I don't quite understand the issue with the MSP430.

@MrKevinWeiss
Copy link
Contributor Author

Also, I'm not sure if the reboot feature should really be pm_reboot(), but maybe rather some cpu_reboot() and grouped elsewhere.

Let's first fix the current system then worry about this later... Makes sense though.

@MrKevinWeiss
Copy link
Contributor Author

I don't think this will change the MSP430 behavior as the whole CPU provides periph_pm, thus the guards won't make any difference or change.

@MrKevinWeiss
Copy link
Contributor Author

Anyone interested? ping @Teufelchen1 or maybe @maribu

@@ -20,7 +20,9 @@

#include <stdio.h>

#ifdef MODULE_PERIPH_PM
#include "periph/pm.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you need to guard the header?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why would we include a header that we shouldn't use?

Other places also guard headers and I think it is someone cleaner is all (I think we always include the periph headers anyways).

Copy link
Contributor

Choose a reason for hiding this comment

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

It adds visual clutter and the header is always available.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

Copy link
Member

Choose a reason for hiding this comment

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

The coding convention btw. clearly says that @MrKevinWeiss original code is mandatory: https://github.com/RIOT-OS/RIOT/blob/master/CODING_CONVENTIONS.md#includes

However, the lived practice in RIOT's code base is to not add the guards.

I guess to reduce clutter we can always have the headers exposed since they are always included
even when we are not using them.
@maribu maribu enabled auto-merge April 8, 2024 12:25
@MrKevinWeiss
Copy link
Contributor Author

Hmmm I have 2 acks now... Maybe @Teufelchen1 can reACK?

@MrKevinWeiss MrKevinWeiss added Process: needs >1 ACK Integration Process: This PR requires more than one ACK and removed Process: needs >1 ACK Integration Process: This PR requires more than one ACK Process: missing approvals Integration Process: PR needs more ACKS (handled by action) labels Apr 9, 2024
@MrKevinWeiss
Copy link
Contributor Author

Or maybe it just needs a nudge

@maribu maribu added this pull request to the merge queue Apr 9, 2024
Merged via the queue into RIOT-OS:master with commit 93b05d5 Apr 9, 2024
28 of 30 checks passed
@MrKevinWeiss MrKevinWeiss deleted the pr/guard_shell_pm branch April 10, 2024 12:25
@MrKevinWeiss MrKevinWeiss added this to the Release 2024.04 milestone Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: core Area: RIOT kernel. Handle PRs marked with this with care! Area: sys Area: System CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Process: needs >1 ACK Integration Process: This PR requires more than one ACK Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants