-
Notifications
You must be signed in to change notification settings - Fork 3k
PSoC 6: rework sleep overrides by Cypress's debug macro #13976
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
cyhal_syspm_sleep(); | ||
#endif |
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.
Question: As the macro CY_CFG_PWR_SYS_IDLE_MODE
is Cypress-specific, maybe it makes more sense to have that defined in cyhal_syspm_sleep()
(Cypress SDK code) instead of the Mbed OS HAL implementation? In that case we wouldn't need any tricks at all.
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.
@ARMmbed/team-cypress Or, could you confirm if the macro is still being used by Cypress's debug tool as of today?
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.
That's a good suggestion.
@kyle-cypress please review this proposal and let us know if you'd rather change your SDK.
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.
I don't think we should change cyhal_syspm_sleep. The intent of CY_CFG_PWR_SYS_IDLE_MODE is to control how the RTOS idle task behaves, not to completely disable the sleep driver (even if the two wind up being very similar in practice).
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 current proposal is good and easy to follow so I would go with it.
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 intent of CY_CFG_PWR_SYS_IDLE_MODE is to control how the RTOS idle task behaves,
Well, as explained in the description, the idle overriding is a feature we provide to the application. Overriding it by drivers/BSPs would create a conflict if the application uses it.
@LDong-Arm, thank you for your changes. |
cyhal_syspm_sleep(); | ||
#endif |
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.
I don't think we should change cyhal_syspm_sleep. The intent of CY_CFG_PWR_SYS_IDLE_MODE is to control how the RTOS idle task behaves, not to completely disable the sleep driver (even if the two wind up being very similar in practice).
@@ -41,9 +46,14 @@ void hal_deepsleep(void) | |||
cy_us_ticker_stop(); | |||
cyhal_syspm_deepsleep(); | |||
cy_us_ticker_start(); | |||
#else | |||
#else // DEVICE_LPTICKER | |||
cyhal_syspm_sleep(); |
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 seems like it is adding a lot of complexity to the hal_deepsleep implementation. Wouldn't it be simpler to keep the call to sleep_manager_lock_deep_sleep and let the sleep manager take care of figuring out whether to call hal_sleep or hal_deepsleep?
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.
sleep_manager_lock_deep_sleep()
as used before is fine in my opinion. I changed hal_deepsleep()
for consistency with the macro-checks in hal_sleep()
, but if it's overly complex I can revert this bit.
* Configurator. The default value is system deep sleep. | ||
*/ | ||
#if (CY_CFG_PWR_SYS_IDLE_MODE == CY_CFG_PWR_MODE_ACTIVE) | ||
rtos_attach_idle_hook(&active_idle_hook); |
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.
Instead of removing this entirely and adding extra checks to hal_sleep to turn it into a no-op, could this be replaced by a call to sleep_manager_lock_sleep? That would be simpler and I believe it would produce more correct results from the sleep/deepsleep statistics mechanism when that is enabled.
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.
Mbed OS only supports locking deep sleep, not sleep. This was probably the reason an idle hook was used instead. The locking of deep sleep ensures all features work:
mbed-os/platform/include/platform/mbed_power_mgmt.h
Lines 45 to 47 in e77b1d8
* Use locking/unlocking deepsleep for drivers that depend on features that | |
* are not allowed (=disabled) during the deepsleep. For instance, high frequency | |
* clocks. |
I think in most use cases, the need to lock regular sleep is comparatively low.
@evedon @kjbracey-arm In terms of functionality/actual use cases, does it make sense to add a lock for regular sleep?
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.
I dont see why anyone would lock sleep, as it is very shallow mode (core system clock is disabled).
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.
As @0xc0170 said, locking normal sleep makes little sense in actual use cases, so we may not add that to the API.
cyhal_syspm_sleep(); | ||
#endif |
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 current proposal is good and easy to follow so I would go with it.
@kyle-cypress @LDong-Arm are there any outstanding questions? There were couple of comments and some were answered. I set this to review again as I do not believe this is ready for CI. |
We have given our views on the questions, is there any proposal on how we can handle this? @ARMmbed/team-cypress |
@0xc0170 @LDong-Arm While we still think the new behavior here will differ slightly from the old behavior, we don't have any other proposals for this. We think it's fine to go ahead with this as-is. |
Thanks @dustin-crossman , we will proceed |
CI started |
Jenkins CI Test : ✔️ SUCCESSBuild Number: 1 | 🔒 Jenkins CI Job | 🌐 Logs & ArtifactsCLICK for Detailed Summary
|
Summary of changes
Fix for PSoC 6 targets mentioned in #13265
According to the discussion here, Cypress has a debug tool that generates the macro
CY_CFG_PWR_SYS_IDLE_MODE
which intends to disable/limit sleep during debug sessions:CY_CFG_PWR_MODE_DEEPSLEEP
: sleep and deep sleepCY_CFG_PWR_MODE_SLEEP
: sleep onlyCY_CFG_PWR_MODE_ACTIVE
: no sleepTo override sleep behaviours, the previous implementation relies on
rtos_attach_idle_hook()
, which is a non-API internal function reserved for the user-facing APIKernel::attach_idle_hook()
only. Functionally, if an application usesKernel::attach_idle_hook()
(which is a valid use case), the Cypress debug idle hook will get overriden.As discussed here, this PR moves the sleep overriding to
hal_sleep()
andhal_deepsleep()
implementations.Impact of changes
Target-specific rework, no noticeable impact to developers.
Migration actions required
None.
Documentation
None.
Pull request type
Test results
Reviewers
@ARMmbed/team-cypress @ARMmbed/mbed-os-core