Skip to content

Conversation

@Zclarkwilliams
Copy link
Contributor

Description

When the Wifi network is enabled the connection
manager will trigger a network scan without a
profile to use. If there is a connected network
or attempting a connection, the scan will
interrupt and break the connection.

Fix - The Wifi Connection Manager will register
the scan on timer tick but will not set the timer. This timer will only be set when the user enters or selects a profile for connection in the BIOS menu. If the user does not select a profile there is no
need to start a scan timer. Additionally the scan
on timer tick will check for a profile to connect
and if no profile found then cancel the timer and
exit.

  • Breaking change?
    • Breaking change - Does this PR cause a break in build or boot behavior?
    • Examples: Does it add a new library class or move a module to a different repo.
  • Impacts security?
    • Security - Does this PR have a direct security impact?
    • Examples: Crypto algorithm change or buffer overflow fix.
  • Includes tests?
    • Tests - Does this PR include any explicit test code?
    • Examples: Unit tests or integration tests.

How This Was Tested

This change was tested on platforms with Wifi connections established and tested if this fixes the break in the current connect as well if this change breaks anything when the platform is supposed to scan correctly.

Integration Instructions

N/A

@Zclarkwilliams Zclarkwilliams force-pushed the fix_2_wcm_scan_timer branch from a016578 to d3b1868 Compare May 14, 2025 20:40
@Zclarkwilliams Zclarkwilliams marked this pull request as ready for review May 14, 2025 20:45
@Zclarkwilliams Zclarkwilliams force-pushed the fix_2_wcm_scan_timer branch 3 times, most recently from 0c08eb7 to ddf6274 Compare May 15, 2025 17:59
@Zclarkwilliams Zclarkwilliams force-pushed the fix_2_wcm_scan_timer branch from ddf6274 to a86ede0 Compare May 15, 2025 21:15
@mdkinney
Copy link
Member

mdkinney commented May 16, 2025

@ardbiesheuvel You had comments on the other PR #11039 for this issue that was closed and this alternate approach was implemented. Do you have comments on this approach?

@Zclarkwilliams Zclarkwilliams force-pushed the fix_2_wcm_scan_timer branch 2 times, most recently from 501b1d8 to 7f6190c Compare May 22, 2025 22:48
When the Wifi network is enabled the connection
manager will trigger a network scan without a
profile to use. If there is a connected network
or attempting a connection, the scan will
interrupt and break the connection.

Fix - The Wifi Connection Manager will register
the scan on timer tick but will not set the timer.
This timer will only be set when the user enters or
selects a profile for connection in the BIOS menu.
If the user does not select a profile there is no
need to start a scan timer. Additionally the scan
on timer tick will check for a profile to connect
and if no profile found then cancel the timer and
exit. When the driver loads it will check for a
profile and if one is found then the scan timer
will be set. If no profile is found then the
driver will not set the scan timer and will
not attempt to scan. This will prevent the
driver from scanning and breaking a connection
if the user does not select a profile.

Signed-off-by: Zachary Clark-Williams <[email protected]>
@Zclarkwilliams Zclarkwilliams force-pushed the fix_2_wcm_scan_timer branch from 1457958 to 357046c Compare May 27, 2025 17:52
@mdkinney mdkinney added the push Auto push patch series in PR if all checks pass label May 27, 2025
@mergify mergify bot merged commit 8b274d7 into tianocore:master May 28, 2025
126 checks passed
@Zclarkwilliams Zclarkwilliams deleted the fix_2_wcm_scan_timer branch May 28, 2025 15:47
@eblipp
Copy link

eblipp commented Aug 8, 2025

This pull request makes several changes to the WiFi Connection Manager in the EDK II project, with a focus on improving timer management, connection logic, and error handling. Here’s a concise review of the changes:

Summary of Changes

1. Logic Fixes for Connection Flow

  • In WifiConnectionMgrDriver.c, the logic for handling connection status is updated:
    • Previously, the code checked for a successful connection (!EFI_ERROR(Status)) before jumping to error handling (goto ERROR1).
    • Now, it checks for an error (EFI_ERROR(Status)), which is a more standard approach and likely fixes unintended behavior.

2. Improved Timer Management

  • In multiple locations (WifiConnectionMgrDriver.c, WifiConnectionMgrHiiConfigAccess.c, WifiConnectionMgrImpl.c), the code now:
    • Sets periodic timers only when necessary (e.g., when a profile is available).
    • Cancels timers when not needed, such as after a successful connection or when there’s no profile to connect to.
    • Adds error handling: if setting a timer fails, it closes the event to avoid resource leaks.

3. Refined Scan and Connection State Logic

  • The timer tick handler in WifiConnectionMgrImpl.c now cancels the timer and returns early if there’s no profile to connect to, with a debug message for visibility.
  • The scan trigger logic is updated to:
    • Avoid unnecessary scans when already connected or in the process of connecting.
    • Reset scan request flags and timing correctly.

Code Quality / Style

  • Error handling and resource management are improved throughout—timers are canceled and events are closed when needed.
  • Comments are added to explain the intent of new logic.
  • The changes bring the code closer to standard UEFI practices for timer/event handling and state management.

Impact

  • Reliability & Efficiency:
    These changes should reduce unnecessary timer events, improve connection reliability, and prevent resource leaks.
  • Readability:
    The code is easier to follow with the added comments and logical flow improvements.
  • Debugging & Maintenance:
    Added debug messages and clearer state transitions make future troubleshooting easier.

Suggestions

  • Consider further refactoring to centralize timer management to avoid repetition.
  • Ensure thorough testing for edge cases, such as rapid connect/disconnect scenarios and timer failures.

Verdict

Positive:
This PR improves robustness, correctness, and maintainability of the WiFi Connection Manager. I recommend merging after confirming that the updated timer and connection logic works as expected across all supported platforms and connection scenarios.


If you need a deeper review of the specific logic or want to discuss edge cases, let me know!

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

Labels

push Auto push patch series in PR if all checks pass

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants