[PATCH i-g-t 1/2] lib/igt_pm : Add pm functions for d3cold_allowed
Riana Tauro
riana.tauro at intel.com
Thu Sep 8 11:31:55 UTC 2022
Add functions to set/get d3cold_allowed attribute of
the pci_device
Signed-off-by: Riana Tauro <riana.tauro at intel.com>
---
lib/igt_pm.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
lib/igt_pm.h | 4 ++++
2 files changed, 50 insertions(+)
diff --git a/lib/igt_pm.c b/lib/igt_pm.c
index 99251b40..f0063d8e 100644
--- a/lib/igt_pm.c
+++ b/lib/igt_pm.c
@@ -1122,6 +1122,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_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 = -1;
+
+ 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
igt_pm_restore_power_attr(struct pci_device *pci_dev, const char *attr, char *val, int len)
{
diff --git a/lib/igt_pm.h b/lib/igt_pm.h
index cbbde12b..d9db8100 100644
--- a/lib/igt_pm.h
+++ b/lib/igt_pm.h
@@ -24,6 +24,8 @@
#ifndef IGT_PM_H
#define IGT_PM_H
+#include "igt_device_scan.h"
+
void igt_pm_enable_audio_runtime_pm(void);
void igt_pm_enable_sata_link_power_management(void);
void igt_pm_restore_sata_link_power_management(void);
@@ -76,6 +78,8 @@ enum igt_acpi_d_state
igt_pm_get_acpi_real_d_state(struct pci_device *pci_dev);
void igt_pm_enable_pci_card_runtime_pm(struct pci_device *root,
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_restore_pci_card_runtime_pm(void);
void igt_pm_print_pci_card_runtime_status(void);
--
2.25.1
More information about the Intel-gfx-trybot
mailing list