summaryrefslogtreecommitdiff
path: root/lib/igt_pm.c
diff options
context:
space:
mode:
authorRiana Tauro <riana.tauro@intel.com>2022-09-09 12:57:43 +0530
committerAshutosh Dixit <ashutosh.dixit@intel.com>2022-09-09 12:40:34 -0700
commit60aad8d8c429f132640e969bc367c49abe9169f4 (patch)
treea7c9fb948c783d5177a9aa20e2ca47689ba6da89 /lib/igt_pm.c
parent7d91a6952dadaa9001b662ed60c08ccb8364929d (diff)
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: Riana Tauro <riana.tauro@intel.com> Reviewed-by: Anshuman Gupta <anshuman.gupta@intel.com>
Diffstat (limited to 'lib/igt_pm.c')
-rw-r--r--lib/igt_pm.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/lib/igt_pm.c b/lib/igt_pm.c
index 99251b40b..edebfdec3 100644
--- a/lib/igt_pm.c
+++ b/lib/igt_pm.c
@@ -38,6 +38,7 @@
#include <dirent.h>
#include "drmtest.h"
+#include "igt_device_scan.h"
#include "igt_kms.h"
#include "igt_pm.h"
#include "igt_aux.h"
@@ -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_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
igt_pm_restore_power_attr(struct pci_device *pci_dev, const char *attr, char *val, int len)
{