Skip to content

RDKEMW-17527: Fix for hangup issue in PowerController library#3890

Open
yuvaramachandran-gurusamy wants to merge 10 commits intodevelopfrom
topic/RDKEMW-17527
Open

RDKEMW-17527: Fix for hangup issue in PowerController library#3890
yuvaramachandran-gurusamy wants to merge 10 commits intodevelopfrom
topic/RDKEMW-17527

Conversation

@yuvaramachandran-gurusamy
Copy link
Copy Markdown
Contributor

RDKEMW-17527: Fix for hangup issue in PowerController library

Signed-off-by: yuvaramachandran_gurusamy yuvaramachandran_gurusamy@comcast.com

Signed-off-by: yuvaramachandran_gurusamy <yuvaramachandran_gurusamy@comcast.com>
Copilot AI review requested due to automatic review settings May 5, 2026 22:05
@yuvaramachandran-gurusamy yuvaramachandran-gurusamy requested review from a team as code owners May 5, 2026 22:05
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the WPEFramework clientlibraries patch for the PowerController/PowerManager client to address a reported hang scenario by reworking notification (un)subscription flow and expanding callback/connection logging.

Changes:

  • Renames and refactors notification registration helpers (e.g., “Thunder” notification registration) and adds subscribe/unsubscribe-all helpers during operational up/down transitions.
  • Adds extensive logging around connection lifecycle and callback registration/unregistration.
  • Adds per-callback timing instrumentation when dispatching notifications.
Comments suppressed due to low confidence (1)

recipes-extended/wpe-framework/wpeframework-clientlibraries/r4.4/0001-PowerManagerClient-library-implementation.patch:1044

  • User callbacks are invoked while _callbackLock is held. If a callback calls back into this library (e.g., to register/unregister callbacks), it will try to re-acquire _callbackLock and can deadlock. A safer pattern is to copy the callback list under the lock, release the lock, then invoke callbacks outside the lock.
+        _callbackLock.Lock();
+        LOGINFO(">>> Callback Lock acquired");
+        // avoid notifying operational state changed if shuting down because of Term
+        if (!_shutdown) {
+            for (auto& cb : _operationalStateChangeCallbacks) {
+                cb.callback(upAndRunning, cb.userdata);

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

+// Templated Callback list avoid code duplication, for individual callback types
+// This class expects mechanism to register / unregister for individual & unique notifications with PowerManager
+// via RegisterNotificationLocked and UnregisterNotificationLocked methods. To be implemented in PowerController (i,e PARENT)
+// via RegisterThunderNotificationLocked and UnregisterNotificationLocked methods. To be implemented in PowerController (i,e PARENT)
Comment on lines +1053 to +1057
+ void SubscribeAllNotificationsLocked()
+ {
+ _powerModeChangedCallbacks.RegisterNotificationLocked();
+ _powerModePreChangeCallbacks.RegisterNotificationLocked();
+ _deepSleepTimeoutCallbacks.RegisterNotificationLocked();
+ _networkStandbyModeChangedCallbacks.RegisterNotificationLocked();
+ _thermalModeChangedCallbacks.RegisterNotificationLocked();
+ _rebootBeginCallbacks.RegisterNotificationLocked();
+ LOGINFO("Entering ...");
+ _powerModeChangedCallbacks.RegisterNotificationInternalLocked();
+ _powerModePreChangeCallbacks.RegisterNotificationInternalLocked();
Comment on lines +1066 to +1070
+ void UnsubscribeAllNotificationsLocked()
+ {
+ _powerModeChangedCallbacks.UnregisterNotificationLocked(true);
+ _powerModePreChangeCallbacks.UnregisterNotificationLocked(true);
+ _deepSleepTimeoutCallbacks.UnregisterNotificationLocked(true);
+ _networkStandbyModeChangedCallbacks.UnregisterNotificationLocked(true);
+ _thermalModeChangedCallbacks.UnregisterNotificationLocked(true);
+ _rebootBeginCallbacks.UnregisterNotificationLocked(true);
+ LOGINFO("Entering ...");
+ _powerModeChangedCallbacks.UnregisterNotificationInternalLocked(true);
+ _powerModePreChangeCallbacks.UnregisterNotificationInternalLocked(true);
Comment on lines +1598 to 1611
+
+ LOGINFO(">>> currentState[%d], newState[%d]", currentState_, newState_);
+ _callbackLock.Lock();
+ LOGINFO("Callback count: %zu", _powerModeChangedCallbacks.Count());
+
+ for (auto& cb : _powerModeChangedCallbacks) {
+ auto start = std::chrono::steady_clock::now();
+ cb.callback(currentState_, newState_, cb.userdata);
+ auto end = std::chrono::steady_clock::now();
+ auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
+ LOGINFO("Callback %p took %lld ms to process PowerModeChanged notification", cb.callback, duration);
+ }
+
+ _callbackLock.Unlock();
Comment on lines 1620 to +1624
+ _callbackLock.Lock();
+ LOGINFO("Callback count: %zu", _powerModePreChangeCallbacks.Count());
+
+ for (auto& cb : _powerModePreChangeCallbacks) {
+ auto start = std::chrono::steady_clock::now();
Comment on lines +1696 to 1706
+ LOGINFO("Callback count: %zu", _rebootBeginCallbacks.Count());
+
+ for (auto& cb : _rebootBeginCallbacks) {
+ auto start = std::chrono::steady_clock::now();
+ cb.callback(rebootReasonCustom.c_str(), rebootReasonOther.c_str(), rebootRequestor.c_str(), cb.userdata);
+ auto end = std::chrono::steady_clock::now();
+ auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
+ LOGINFO("Callback %p took %lld ms to process RebootBegin notification", cb.callback, duration);
+ }
+
+ _callbackLock.Unlock();
Comment on lines +1716 to 1721
+ LOGINFO(">>> callback: %p, userdata: %p", callback, userdata);
+
+ ASSERT(nullptr != callback);
+
+ if (nullptr != callback) {
+ _callbackLock.Lock();
Comment on lines 1191 to +1196
+ if (nullptr == _instance) {
+ LOGERR("PowerController::Init failed, out of memory ?");
+ }
+ else {
+ LOGINFO("PowerController::Init successful");
+ }
+ if (it == this->end()) {
+ LOGINFO("Callback identifier[%p]", (void*)callback);
+ this->emplace_back(callback, userdata);
+ result = Core::ERROR_NONE;
+ this->erase(it);
+ result = Core::ERROR_NONE;
+ UnregisterNotificationLocked(false);
+ UnregisterNotificationInternalLocked(false);
@svc-rdkeportal01
Copy link
Copy Markdown

CCI-Build-Verified +1
sha: ffde930

@svc-rdkeportal01
Copy link
Copy Markdown

CCI-Test-Verified +1
sha: ffde930

Signed-off-by: yuvaramachandran_gurusamy <yuvaramachandran_gurusamy@comcast.com>
@svc-rdkeportal01
Copy link
Copy Markdown

CCI-Build-Verified +1
sha: a88b538

@svc-rdkeportal01
Copy link
Copy Markdown

CCI-Test-Verified +1
sha: a88b538

Signed-off-by: yuvaramachandran_gurusamy <yuvaramachandran_gurusamy@comcast.com>
Copilot AI review requested due to automatic review settings May 6, 2026 16:31
@svc-rdkeportal01
Copy link
Copy Markdown

CCI-Build-Verified +1
sha: b72cadd

@svc-rdkeportal01
Copy link
Copy Markdown

CCI-Test-Verified +1
sha: b72cadd

@svc-rdkeportal01
Copy link
Copy Markdown

CCI-Build-Verified +1
sha: 319241e

Signed-off-by: yuvaramachandran_gurusamy <yuvaramachandran_gurusamy@comcast.com>
Signed-off-by: yuvaramachandran_gurusamy <yuvaramachandran_gurusamy@comcast.com>
@svc-rdkeportal01
Copy link
Copy Markdown

CCI-Test-Verified +1
sha: 319241e

@svc-rdkeportal01
Copy link
Copy Markdown

CCI-Build-Verified +1
sha: fa991ad

3 similar comments
@svc-rdkeportal01
Copy link
Copy Markdown

CCI-Build-Verified +1
sha: fa991ad

@svc-rdkeportal01
Copy link
Copy Markdown

CCI-Build-Verified +1
sha: fa991ad

@svc-rdkeportal01
Copy link
Copy Markdown

CCI-Build-Verified +1
sha: fa991ad

@svc-rdkeportal01
Copy link
Copy Markdown

CCI-Test-Verified +1
sha: fa991ad

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants