Power Management

Power Management — Power Management related helpers

Functions

Types and Values

Includes

#include <igt.h>

Description

This library provides various helpers to enable power management for, and in some cases subsequently allow restoring the old behaviour of, various external components that by default are set up in a way that interferes with the testing of our power management functionality.

Functions

igt_pm_enable_audio_runtime_pm ()

void
igt_pm_enable_audio_runtime_pm (void);

We know that if we don't enable audio runtime PM, snd_hda_intel will never release its power well refcount, and we'll never reach the LPSP state. There's no guarantee that it will release the power well if we enable runtime PM, but at least we can try.

We don't have any assertions on open since the user may not even have snd_hda_intel loaded, which is not a problem.


igt_pm_enable_sata_link_power_management ()

void
igt_pm_enable_sata_link_power_management
                               (void);

Enables the min_power policy for SATA link power management. Without this we cannot reach deep runtime power states.


igt_pm_restore_sata_link_power_management ()

void
igt_pm_restore_sata_link_power_management
                               (void);

Restores the link power management policies to the values prior to enabling min_power.

Caveat: If the system supports hotplugging and hotplugging takes place during our testing so that the hosts change numbers we might restore the settings to the wrong hosts.


igt_setup_runtime_pm ()

bool
igt_setup_runtime_pm (int device);

Sets up the runtime PM helper functions and enables runtime PM. To speed up tests the autosuspend delay is set to 0.

Return: True if runtime pm is available, false otherwise.


igt_disable_runtime_pm ()

void
igt_disable_runtime_pm (void);

Disables the runtime pm for i915 device. igt_disable_runtime_pm assumes that igt_setup_runtime_pm has already called to save runtime autosuspend and control attributes.


igt_restore_runtime_pm ()

void
igt_restore_runtime_pm (void);

Restores the runtime PM configuration as it was before the call to igt_setup_runtime_pm.


igt_get_runtime_pm_status ()

enum igt_runtime_pm_status
igt_get_runtime_pm_status (void);

Return: The current runtime PM status.


igt_wait_for_pm_status ()

bool
igt_wait_for_pm_status (enum igt_runtime_pm_status status);

Waits until for the driver to switch to into the desired runtime PM status, with a 10 second timeout.

Return: True if the desired runtime PM status was attained, false if the operation timed out.

Parameters

status

desired runtime PM status

 

igt_pm_dmc_loaded ()

bool
igt_pm_dmc_loaded (int debugfs);

Check whether DMC FW is loaded or not. DMC FW is require for few Display C states like DC5 and DC6. FW does the Context Save and Restore during Display C States entry and exit.

Return: True if DMC FW is loaded otherwise false.

Parameters

debugfs

FD to the debugfs directory

 

igt_pm_pc8_plus_residencies_enabled ()

bool
igt_pm_pc8_plus_residencies_enabled (int msr_fd);

Check whether BIOS has disabled the PC8 package deeper state.

Return: True if PC8+ package deeper state enabled on machine otherwise false.

Parameters

msr_fd

FD to /dev/cpu/0/msr

 

i915_output_is_lpsp_capable ()

bool
i915_output_is_lpsp_capable (int drm_fd,
                             igt_output_t *output);

Checks LPSP capability for a given output.

Return: True if given output is LPSP capable otherwise false.

Parameters

drm_fd

fd to drm device

 

output

igt output for which lpsp capability need to be evaluated

 

igt_pm_get_pcie_acpihp_slot ()

int
igt_pm_get_pcie_acpihp_slot (struct pci_device *pci_dev);

Gets PCI bridge acpi hotplug slot number, if bridge's ACPI firmware_node handle supports _SUN method.

Return: PCIe bridge Slot number or -ENOENT number in case firmware_node/sun is not supported by the bridge.

Parameters

pci_dev

PCI bridge device struct

 

igt_pm_acpi_d3cold_supported ()

bool
igt_pm_acpi_d3cold_supported (struct pci_device *pci_dev);

Checks ACPI D3Cold support.

Return: True if ACPI D3Cold supported otherwise false.

Parameters

pci_dev

Root port PCI device struct

 

igt_pm_get_acpi_real_d_state ()

enum igt_acpi_d_state
igt_pm_get_acpi_real_d_state (struct pci_device *pci_dev);

Gets ACPI D state for a given root port.

Return: igt_acpi_d_state state.

Parameters

pci_dev

Root port PCI device struct

 

igt_pm_get_autosuspend_delay ()

int
igt_pm_get_autosuspend_delay (struct pci_device *pci_dev);

Return: The autosuspend delay time in milliseconds.

Parameters

pci_dev

PCI device struct

 

igt_pm_set_autosuspend_delay ()

void
igt_pm_set_autosuspend_delay (struct pci_device *pci_dev,
                              int delay_ms);

Sets the autosuspend delay value for the PCI device through.

Parameters

pci_dev

PCI device struct

 

delay_ms

Autosuspend delay in milliseconds.

 

igt_pm_enable_pci_card_runtime_pm ()

void
igt_pm_enable_pci_card_runtime_pm (struct pci_device *root,
                                   struct pci_device *i915);

Enables runtime PM for all PCI endpoints devices for a given root port by setting power/control attr to "auto" and setting autosuspend_delay_ms to zero.

Parameters

root

Root port PCI device struct

 

gfx

PCI device struct of graphics device

 

igt_pm_get_d3cold_allowed ()

void
igt_pm_get_d3cold_allowed (const char *pci_slot_name,
                           uint32_t *value);

Reads the value of d3cold_allowed attribute of the PCI device.

Parameters

pci_slot_name

Slot name of the PCI device

 

value

Value to be read into

 

igt_pm_set_d3cold_allowed ()

void
igt_pm_set_d3cold_allowed (const char *pci_slot_name,
                           uint32_t value);

Writes the value to d3cold_allowed attribute of PCI device.

Parameters

pci_slot_name

Slot name of PCI device

 

value

Value to be written

 

igt_pm_setup_pci_card_runtime_pm ()

void
igt_pm_setup_pci_card_runtime_pm (struct pci_device *pci_dev);

Setup runtime PM for all PCI endpoints devices for a given root port by enabling runtime suspend and setting autosuspend_delay_ms to zero. It also saves and restore power control attribute for all PCI endpoints devices under given root port.

Parameters

pci_dev

Root port PCI device struct

 

igt_pm_restore_pci_card_runtime_pm ()

void
igt_pm_restore_pci_card_runtime_pm (void);

Restores control and autosuspend_delay_ms power attribute for all PCI endpoints devices under gfx root port, which were saved earlier by igt_pm_setup_pci_card_runtime_pm().


igt_pm_print_pci_card_runtime_status ()

void
igt_pm_print_pci_card_runtime_status (void);

Prints runtime suspend status for all PCI endpoints devices for a given root port.

Parameters

pci_dev

Root port PCI device struct

 

i915_is_slpc_enabled_gt ()

bool
i915_is_slpc_enabled_gt (int drm_fd,
                         int gt);

Return: True if SLPC is enabled on a given gt .

Parameters

drm_fd

DRM file descriptor

 

gt

GT ID

 

i915_is_slpc_enabled ()

bool
i915_is_slpc_enabled (int drm_fd);

Return: True if SLPC is enabled on the device.

Parameters

drm_fd

DRM file descriptor

 

igt_pm_get_runtime_suspended_time ()

uint64_t
igt_pm_get_runtime_suspended_time (struct pci_device *pci_dev);

Return: The total time in milliseconds that the device has been suspended.

Parameters

pci_dev

PCI device struct

 

igt_pm_get_runtime_active_time ()

uint64_t
igt_pm_get_runtime_active_time (struct pci_device *pci_dev);

Return: The total time in milliseconds that the device has been active.

Parameters

pci_dev

PCI device struct

 

igt_pm_get_runtime_usage ()

int
igt_pm_get_runtime_usage (struct pci_device *pci_dev);

Return: The runtime PM usage count of a device.

Parameters

pci_dev

PCI device struct

 

igt_pm_ignore_slpc_efficient_freq ()

void
igt_pm_ignore_slpc_efficient_freq (int i915,
                                   int gtfd,
                                   bool val);

Ignores/un-ignores SLPC efficient frequency.

Parameters

i915

open i915 drm file descriptor

 

gtfd

open gt sysfs fd

 

val

value to set

 

Types and Values

enum igt_runtime_pm_status

Symbolic values for runtime PM device status.

Members

IGT_RUNTIME_PM_STATUS_ACTIVE

device is active

 

IGT_RUNTIME_PM_STATUS_SUSPENDED

device is suspended

 

IGT_RUNTIME_PM_STATUS_SUSPENDING

device is in the process of suspending

 

IGT_RUNTIME_PM_STATUS_RESUMING

device is in the process of resuming

 

IGT_RUNTIME_PM_STATUS_UNKNOWN

unknown runtime PM status

 

enum igt_acpi_d_state

Members

IGT_ACPI_D0

   

IGT_ACPI_D1

   

IGT_ACPI_D2

   

IGT_ACPI_D3Hot

   

IGT_ACPI_D3Cold

   

IGT_ACPI_UNKNOWN_STATE

   

struct igt_pm_pci_dev_pwrattr

struct igt_pm_pci_dev_pwrattr {
	struct pci_device *pci_dev;
	char control[64];
	bool autosuspend_supported;
	char autosuspend_delay[64];
};

struct igt_device_card

struct igt_device_card {
	char subsystem[NAME_MAX];
	char card[NAME_MAX];
	char render[NAME_MAX];
	char pci_slot_name[PCI_SLOT_NAME_SIZE+1];
	uint16_t pci_vendor, pci_device;
};