bugfix/wdfserial: preserve user's power management choice across reboots - #109
Merged
Chenxi Han (5656hcx) merged 2 commits intoSep 9, 2026
Conversation
BUG: the "Allow the computer to turn off this device to save power" checkbox reset to enabled after every reboot/re-enumeration, because QCPNP_EnableSelectiveSuspend always forced Enabled=WdfTrue, overwriting the persisted user choice stored by WDF in Device Parameters\WDF\IdleInWorkingState. - Add HonorPersistedUserChoice parameter to QCPNP_EnableSelectiveSuspend: boot/re-enum path (QCPNP_EvtDevicePrepareHardware) now passes TRUE, letting WDF apply WdfUseDefault and re-read the persisted value instead of forcing it on; runtime WMI toggle handlers (QCPNP_PMSetWmiDataItem/DataBlock) pass FALSE to apply the fresh WdfTrue/WdfFalse choice immediately. - HW-forced disable (SAHARA/FIREHOSE/LPC) still always wins via explicit WdfFalse, regardless of caller. - Add QCPNP_SyncPersistedIdleEnabledState: after WdfUseDefault is applied at boot, re-sync pDevContext->PowerManagementEnabled with the actual IdleInWorkingState registry value (read-only, no new registry keys) so the driver's own Power Management checkbox (QCPNP_PMQueryWmiDataBlock/DataItem) no longer shows a stale "enabled" state that mismatches what was actually persisted. Signed-off-by: Cristian Manca <Cristian.Manca@telit.com>
…boot Move QCPNP_SyncPersistedIdleEnabledState() from the boot path (QCPNP_EnableSelectiveSuspend) into QCPNP_PMQueryWmiDataBlock, so the persisted IdleInWorkingState registry value is read only when the Power Management page queries the WMI data block, not on every boot. PowerManagementEnabled is reset to TRUE on every device (re-)initialization, so syncing only at boot left the GUI checkbox stale vs. the actual persisted value. Windows also echoes the displayed value back on page close, so the stale TRUE was silently overwriting IdleInWorkingState. On-demand sync keeps the GUI fresh, removes registry I/O from the boot path, and prevents the close-triggered overwrite. Skip the sync for SAHARA/FIREHOSE/LPC (same guard as in QCPNP_EvtDevicePrepareHardware), since PowerManagementEnabled is hardware-forced for those and not registry-backed Signed-off-by: Cristian Manca <Cristian.Manca@telit.com>
Chenxi Han (5656hcx)
approved these changes
Sep 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes the "Allow the computer to turn off this device to save power"
checkbox resetting to enabled on every reboot/USB re-enumeration.
Fixes #108 .
Root Cause
QCPNP_EnableSelectiveSuspend()unconditionally forcedEnabled = WdfTrueon every call, including at device initialization (
EvtDevicePrepareHardware).This overwrote the value WDF persists per-device in the registry
(
Device Parameters\WDF\IdleInWorkingState), which backs the checkbox state.Additionally, using explicit
WdfTruebypassed WDF's initial-defaultlookup of
WdfDefaultIdleInWorkingState(INF-provided) on first deviceinstallation, forcing
IdleInWorkingState = 1regardless of any default.Changes
HonorPersistedUserChoiceparameter toQCPNP_EnableSelectiveSuspend:TRUE→ usesWdfUseDefault, letting WDFre-apply the persisted user choice instead of forcing it on
FALSE→ explicitWdfTrue/WdfFalse,so fresh user choices take effect immediately
WdfFalseQCPNP_SyncPersistedIdleEnabledState(): read-only sync of the driver'sinternal
PowerManagementEnabledflag with the actualIdleInWorkingStateregistry value after boot, so the driver's own Power Management checkbox
query reports the real persisted state instead of a stale default
No new registry keys introduced;
IdleInWorkingStateis never written bythe driver.
Type of Change
release/x.ybranch)How has this been tested?
Hardware validation on x64 laptop + USB modem (Windows 11 25H2):
it remained disabled in Device Manager.
verified it took effect immediately without regression.
targeting Windows 11; no new compiler warnings or WPP trace errors.
the new code path (
WdfUseDefaulton boot, explicit values on WMI toggle) executed as designed.Checklist
fix/wdfserial-idle-power-management-persistencedevelop- no merge commitsSigned-off-by:(DCO) - will be added at merge