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

Đang mở
#22,209 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
58/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
c
Lĩnh vực
operating-systems

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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).

Ngôn ngữ chính
C
Star
4.1k
Fork
1.8k
Merge trung bình
1 ngày 18 giờ
Pull request đã merge (30 ngày)
852

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của apache/nuttx

Tất cả issue của apache/nuttx

Issue tương tự

Thêm issue về C

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.