pm: pm_idle() ignores a positive non-zero prepare() veto

未关闭
#22,209 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
58/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
c

调研方向

The bug is in the three ret < 0 checks in drivers/power/pm/pm_idle.c, one in the non-SMP path and two in the SMP path. Read pm_changestate.c to confirm that it reverts the domain and returns any non-zero prepare value, and check the prepare contract in include/nuttx/power/pm.h. Build the host reproducer from the issue's src/ and shim/ and run it. Done means that a +1 veto leaves the idle handler at PM_NORMAL, the SMP and system-domain fallbacks are unchanged, and the reproducer prints VETO_HONORED.

由索引模型根据 Issue 内容生成。

描述

Mechanism. The prepare() contract aborts a transition on any non-zero return, and pm_changestate() reverts the domain state and returns that value. The non-SMP pm_idle() tests only ret < 0, so a +1 veto is swallowed: the domain reverts to PM_NORMAL while the idle handler still receives the refused PM_SLEEP.

Location. drivers/power/pm/pm_idle.c:160,187,243 (three ret < 0 sites: non-SMP plus two SMP); drivers/power/pm/pm_changestate.c; include/nuttx/power/pm.h (non-zero means abort). Affected NuttX 13.1.0 (commit 2b5c0de5), confirmed by source inspection; measured on a hosted harness with the real pm_changestate.c, not sim:nsh.

Trigger. pm_checkstate() selects PM_SLEEP, a registered driver's prepare() returns +1, and pm_changestate() returns +1. Only the non-SMP branch is exercised; the SMP sites were checked by source inspection only, not run.

Expected. Any non-zero pm_changestate() return vetoes the transition, so the idle handler receives the reverted state (PM_NORMAL), not PM_SLEEP.

Evidence. Measured: before domain_state=0, idle_handler_state=3 (VETO_SWALLOWED); after idle_handler_state=0 (VETO_HONORED).

Patch. Change the three checks to ret != OK, keeping fallbacks (oldstate for the SMP CPU branch, PM_NORMAL for system and non-SMP), consistent with upstream 46d555e (identified by source inspection).

主要语言
C
星标
4.1k
派生
1.8k
平均合并
1 天 18 小时
30 天内合并 PR
852

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

apache/nuttx 的其他 Issue

查看 apache/nuttx 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。