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

Aperta
#22,209 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
58/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
c

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

Lingua principale
C
Stelle
4.1k
Fork
1.8k
Merge medio
1g 18h
PR unite (30g)
852

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di apache/nuttx

Tutte le issue di apache/nuttx

Issue simili

Altre issue su C

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.