-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Lib: SMF Modify HSM operation for UML-Style transitions #71729
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
Conversation
1f035e2
to
5416d51
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is actually an entirely new file, not a rename.
4348b81
to
eb05134
Compare
a76ceb3
to
4350114
Compare
lib/smf/smf.c
Outdated
}; | ||
|
||
static bool share_paren(const struct smf_state *test_state, | ||
const struct smf_state *target_state) | ||
#if CONFIG_SMF_ANCESTOR_SUPPORT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because you're using the __unused
attribute, wrapping these functions in an #ifdef
isn't required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The #ifdef
is required because we conditionally compile in parent
in smf_state
Should I delete the __unused
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
Sorry - I responded before looking at the latest patchset. You need either __unused
or #ifdef
. I'm good with the __unused
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.Sorry - I responded before looking at the latest patchset. You need either__unused
or#ifdef
. I'm good with the__unused
.
Unfortunately you need the #ifdefs
, so I'll delete the __unused
4350114
to
daa0a6d
Compare
Review comments fixed or otherwise addressed. @keith-zephyr Please can you take another look? |
a48b474
to
1460d7d
Compare
doc/services/smf/index.rst
Outdated
.. note:: State machines can only call :c:func:`smf_set_state` from Run | ||
functions, not Entry or Exit functions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delete this sentence. It is conflict with the previous note.
.. note:: State machines can only call :c:func:`smf_set_state` from Run | |
functions, not Entry or Exit functions. |
lib/smf/smf.c
Outdated
static bool share_paren(const struct smf_state *test_state, | ||
const struct smf_state *target_state) | ||
const struct smf_state *target_state) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you run clang-format on this?
lib/smf/smf.c
Outdated
/* | ||
* The final target will be the deepest leaf state that | ||
* the target contains. Set that as the real target. | ||
*/ | ||
while (new_state->initial) { | ||
new_state = new_state->initial; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix the indentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drat. Thought i caught them all. Clang-format run on the file.
1460d7d
to
d091517
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Getting pretty close.
I'm also going to test this against my downstream uses of the SMF.
if (o->terminate == ROOT_ENTRY) { | ||
smf_set_terminate(obj, -1); | ||
return; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This condition never occurs and isn't verified by the test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Non-blocking - prefer that you delete since it isn't used.
if (o->terminate == ROOT_ENTRY) { | |
smf_set_terminate(obj, -1); | |
return; | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be better to build a test that tests termination in root_entry? I think the other tests have that covered with PARENT_ENTRY not wrapped in a root state.
lib/smf/smf.c
Outdated
@@ -35,8 +33,7 @@ static bool share_paren(const struct smf_state *test_state, | |||
return false; | |||
} | |||
|
|||
static bool last_state_share_paren(struct smf_ctx *const ctx, | |||
const struct smf_state *state) | |||
static bool last_state_share_paren(struct smf_ctx *const ctx, const struct smf_state *state) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function no longer has any callers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, it's killing the tests. Let me delete it.
I tested this change against our downstream uses. Our unit tests pass and the code boots. Downstream uses: |
Looks like some bugs crept in. Let me update it when I'm off the clock.
…On Mon, 20 May 2024 at 10:44, Keith Short ***@***.***> wrote:
I tested this change against our downstream uses. Our unit tests pass and
the code boots.
Downstream uses:
Power Delivery Subsystem
<https://source.chromium.org/chromiumos/chromiumos/codesearch/+/HEAD:src/platform/ec/zephyr/drivers/usbc/pdc_rts54xx.c;l=1398;drc=d68d5db24185c658633393dff2cf1b2b391f0b08>
Power Delivery Driver
<https://source.chromium.org/chromiumos/chromiumos/codesearch/+/HEAD:src/platform/ec/zephyr/drivers/usbc/pdc_rts54xx.c;l=1398;drc=d68d5db24185c658633393dff2cf1b2b391f0b08>
—
Reply to this email directly, view it on GitHub
<#71729 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AH7LIR7DDUXKUZPK3KXJ7MTZDIY6JAVCNFSM6AAAAABGRAWSBCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMRQHEYTANRUGQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
d091517
to
51ec1ba
Compare
if (o->terminate == ROOT_ENTRY) { | ||
smf_set_terminate(obj, -1); | ||
return; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Non-blocking - prefer that you delete since it isn't used.
if (o->terminate == ROOT_ENTRY) { | |
smf_set_terminate(obj, -1); | |
return; | |
} |
Modify the SMF such that state transitions from parent states choose the correct Least Common Ancestor based on the transition source rather than the current state. SMF set as experimental. Signed-off-by: Glenn Andrews <[email protected]>
51ec1ba
to
ab678da
Compare
@sambhurst Do you have time to look at this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
@glenn-andrews In the future, please avoid mixing whitespace changes with functional changes in the same commit. It makes it very difficult to isolate and review (and understand) the actual, functional changes. Thanks! |
Very good point and I will attempt to do so. That leads me to a question, though. I tried using Format Selection in VSCode on places I touched, which works, but doing so manually means I may miss some (as I did above with indentation) I then ran clang-format on the entire file as requested, which would change formatting for the entire file. If the file does not currently comply with clang-format, what is the appropriate procedure? May I run clang-format in one commit, then make code changes in a second commit in the same PR, or do they have to be separate PRs? |
If you really feel the need to reformat an entire file like this, please do so in a separate commit. It is okay to include it in the same PR as a set of functional changes. |
Thank you. I'll try to do so in future. It's not so much feeling the need to touch the entire file as making sure my part is formatted correctly, which is easier if I can just clang-format the document before committing rather than only formatting the parts I touched. Maybe I should run clang-format on the entire source tree and submit that as a PR 😉 |
You wouldn't be the first ;) |
A possible solution to #71675
Modify the SMF such that state transitions from parent states choose the correct Least Common Ancestor based on the transition source rather than the current state.
Also, SMF_CREATE_STATE() now always takes five arguments so all types of state machines (flat and hierarchical with and without initial transitions) can be used in the same project without errors. This is in response to #71252 The only subsystem using SMF, UCB-C, has been updated to take 5 arguments.