Skip to content
Snippets Groups Projects
Commit 60aad8d8 authored by Riana Tauro's avatar Riana Tauro Committed by Ashutosh Dixit
Browse files

lib/igt_pm : Add pm functions for d3cold_allowed


Add functions to set/get d3cold_allowed attribute of
the pci_device

v2 :  Add forward declaration in header (Anshuman)

Signed-off-by: default avatarRiana Tauro <riana.tauro@intel.com>
Reviewed-by: default avatarAnshuman Gupta <anshuman.gupta@intel.com>
parent 7d91a695
No related branches found
No related tags found
No related merge requests found
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include <dirent.h> #include <dirent.h>
#include "drmtest.h" #include "drmtest.h"
#include "igt_device_scan.h"
#include "igt_kms.h" #include "igt_kms.h"
#include "igt_pm.h" #include "igt_pm.h"
#include "igt_aux.h" #include "igt_aux.h"
...@@ -1122,6 +1123,52 @@ void igt_pm_setup_pci_card_runtime_pm(struct pci_device *pci_dev) ...@@ -1122,6 +1123,52 @@ void igt_pm_setup_pci_card_runtime_pm(struct pci_device *pci_dev)
igt_pm_setup_pci_card_power_attrs(pci_dev, true, 0); igt_pm_setup_pci_card_power_attrs(pci_dev, true, 0);
} }
/**
* igt_pm_get_d3cold_allowed:
* @igt_device_card: device card
* @val: value to be read into
*
* Reads the value of d3cold_allowed attribute
* of the pci device
*/
void igt_pm_get_d3cold_allowed(struct igt_device_card *card, char *val)
{
char name[PATH_MAX];
int fd;
snprintf(name, PATH_MAX, "/sys/bus/pci/devices/%s",
card->pci_slot_name);
fd = open(name, O_RDONLY);
igt_assert_f(fd >= 0, "Can't open %s\n", name);
igt_sysfs_read(fd, "d3cold_allowed", val, sizeof(val));
close(fd);
}
/**
* igt_pm_get_d3cold_allowed:
* @igt_device_card: device card
* @val: value to be written
*
* writes the value to d3cold_allowed attribute of pci device
*/
void igt_pm_set_d3cold_allowed(struct igt_device_card *card, const char *val)
{
char name[PATH_MAX];
int fd;
snprintf(name, PATH_MAX, "/sys/bus/pci/devices/%s",
card->pci_slot_name);
fd = open(name, O_RDONLY);
igt_assert_f(fd >= 0, "Can't open %s\n", name);
igt_sysfs_write(fd, "d3cold_allowed", val, sizeof(val));
close(fd);
}
static void static void
igt_pm_restore_power_attr(struct pci_device *pci_dev, const char *attr, char *val, int len) igt_pm_restore_power_attr(struct pci_device *pci_dev, const char *attr, char *val, int len)
{ {
......
...@@ -63,6 +63,8 @@ struct igt_pm_pci_dev_pwrattr { ...@@ -63,6 +63,8 @@ struct igt_pm_pci_dev_pwrattr {
char autosuspend_delay[64]; char autosuspend_delay[64];
}; };
struct igt_device_card;
bool igt_setup_runtime_pm(int device); bool igt_setup_runtime_pm(int device);
void igt_disable_runtime_pm(void); void igt_disable_runtime_pm(void);
void igt_restore_runtime_pm(void); void igt_restore_runtime_pm(void);
...@@ -76,6 +78,8 @@ enum igt_acpi_d_state ...@@ -76,6 +78,8 @@ enum igt_acpi_d_state
igt_pm_get_acpi_real_d_state(struct pci_device *pci_dev); igt_pm_get_acpi_real_d_state(struct pci_device *pci_dev);
void igt_pm_enable_pci_card_runtime_pm(struct pci_device *root, void igt_pm_enable_pci_card_runtime_pm(struct pci_device *root,
struct pci_device *i915); struct pci_device *i915);
void igt_pm_get_d3cold_allowed(struct igt_device_card *card, char *val);
void igt_pm_set_d3cold_allowed(struct igt_device_card *card, const char *val);
void igt_pm_setup_pci_card_runtime_pm(struct pci_device *pci_dev); void igt_pm_setup_pci_card_runtime_pm(struct pci_device *pci_dev);
void igt_pm_restore_pci_card_runtime_pm(void); void igt_pm_restore_pci_card_runtime_pm(void);
void igt_pm_print_pci_card_runtime_status(void); void igt_pm_print_pci_card_runtime_status(void);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment