Skip to content

accel/amdxdna: aie4: restore power override across suspend/resume - #1537

Open
NishadSaraf wants to merge 1 commit into
amd:mainfrom
NishadSaraf:fix
Open

accel/amdxdna: aie4: restore power override across suspend/resume#1537
NishadSaraf wants to merge 1 commit into
amd:mainfrom
NishadSaraf:fix

Conversation

@NishadSaraf

Copy link
Copy Markdown
Member

The AIE4 power override was silently lost on any suspend/resume (S3/S4 or runtime PM). Two coupled issues caused this:

  • aie4_query_aie() runs on every VF/Classic resume and unconditionally reset ndev->pw_mode to POWER_MODE_DEFAULT, wiping the cached user setting reported by DRM_AMDXDNA_GET_POWER_MODE.
  • Firmware always reboots in POWER_MODE_DEFAULT and no resume path re-sent AIE4_MSG_OP_POWER_OVERRIDE, so even the PF path (which keeps its cache) left the firmware at DEFAULT, diverging from the cache.

Power override is a per-VF property: firmware stores each supervisor's requested mode and the hypervisor arbitrates globally by taking the highest mode across all supervisors. A full firmware reload on suspend clears every supervisor override, so each device type (PF, VF and classic) must re-send its own cached override on resume to preserve its contribution to that arbitration.

Set the probe-time default explicitly in aie4m_pcidev_init(), stop clobbering the cache in aie4_query_aie(), and add aie4_restore_power_mode() to re-send the cached override to firmware from all three hw_start paths once the mailbox is up. On a fresh probe pw_mode is DEFAULT so it is a no-op; on resume it re-applies the user's override. A failure only warns and does not fail hw start, mirroring the ctx hysteresis handling.

The AIE4 power override was silently lost on any suspend/resume (S3/S4 or
runtime PM). Two coupled issues caused this:

  - aie4_query_aie() runs on every VF/Classic resume and unconditionally
    reset ndev->pw_mode to POWER_MODE_DEFAULT, wiping the cached user
    setting reported by DRM_AMDXDNA_GET_POWER_MODE.
  - Firmware always reboots in POWER_MODE_DEFAULT and no resume path
    re-sent AIE4_MSG_OP_POWER_OVERRIDE, so even the PF path (which keeps
    its cache) left the firmware at DEFAULT, diverging from the cache.

Power override is a per-VF property: firmware stores each supervisor's
requested mode and the hypervisor arbitrates globally by taking the
highest mode across all supervisors. A full firmware reload on suspend
clears every supervisor override, so each device type (PF, VF and classic)
must re-send its own cached override on resume to preserve its contribution
to that arbitration.

Set the probe-time default explicitly in aie4m_pcidev_init(), stop
clobbering the cache in aie4_query_aie(), and add aie4_restore_power_mode()
to re-send the cached override to firmware from all three hw_start paths
once the mailbox is up. On a fresh probe pw_mode is DEFAULT so it is a
no-op; on resume it re-applies the user's override. A failure only warns
and does not fail hw start, mirroring the ctx hysteresis handling.

Signed-off-by: Nishad Saraf <nishad.saraf@amd.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes AIE4 power override persistence across suspend/resume and runtime PM by ensuring the driver’s cached power mode isn’t clobbered during resume and by re-applying the cached override to firmware whenever hardware is started (PF, VF, and classic paths).

Changes:

  • Stop resetting ndev->pw_mode inside aie4_query_aie() (which runs on resume), preserving the user’s cached override.
  • Initialize the probe-time default explicitly (ndev->pw_mode = POWER_MODE_DEFAULT) in aie4m_pcidev_init().
  • Add aie4_restore_power_mode() and call it from all three *_hw_start() paths to re-send AIE4_MSG_OP_POWER_OVERRIDE after firmware/mailbox is up.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants