Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Riana Tauro <riana.tauro@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: badal.nilawar@intel.com
Subject: [igt-dev] [PATCH i-g-t 2/4] lib/igt_pm: change d3cold_allowed function parameters
Date: Thu,  3 Aug 2023 10:36:07 +0530	[thread overview]
Message-ID: <20230803050609.2835714-3-riana.tauro@intel.com> (raw)
In-Reply-To: <20230803050609.2835714-1-riana.tauro@intel.com>

Change function parameter of d3cold_allowed get/set functions
to pci slot name. Change the data type from char to uint32_t
as it is more appropriate.

This change is done so that both xe tests and i915 test can
use the same library function.
Modify i915_suspend to use these functions.
No Functional Changes.

Signed-off-by: Riana Tauro <riana.tauro@intel.com>
---
 lib/igt_pm.c              | 22 +++++++++++-----------
 lib/igt_pm.h              |  4 ++--
 tests/i915/i915_suspend.c |  8 ++++----
 3 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/lib/igt_pm.c b/lib/igt_pm.c
index ba591f0f8..11cf82950 100644
--- a/lib/igt_pm.c
+++ b/lib/igt_pm.c
@@ -1204,47 +1204,47 @@ void igt_pm_setup_pci_card_runtime_pm(struct pci_device *pci_dev)
 
 /**
  * igt_pm_get_d3cold_allowed:
- * @igt_device_card: device card
- * @val: value to be read into
+ * @pci_slot_name: slot name of the pci device
+ * @value: 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)
+void igt_pm_get_d3cold_allowed(const char *pci_slot_name, uint32_t *value)
 {
 	char name[PATH_MAX];
 	int fd;
 
 	snprintf(name, PATH_MAX, "/sys/bus/pci/devices/%s",
-		 card->pci_slot_name);
+		 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));
+	__igt_sysfs_get_u32(fd, "d3cold_allowed", value);
 
 	close(fd);
 }
 
 /**
- * igt_pm_get_d3cold_allowed:
- * @igt_device_card: device card
- * @val: value to be written
+ * igt_pm_set_d3cold_allowed:
+ * @pci_slot_name: slot name of pci device
+ * @value: 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)
+void igt_pm_set_d3cold_allowed(const char *pci_slot_name, uint32_t value)
 {
 	char name[PATH_MAX];
 	int fd;
 
 	snprintf(name, PATH_MAX, "/sys/bus/pci/devices/%s",
-		 card->pci_slot_name);
+		 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));
+	__igt_sysfs_set_u32(fd, "d3cold_allowed", value);
 	close(fd);
 }
 
diff --git a/lib/igt_pm.h b/lib/igt_pm.h
index 71ec2f239..306a9eb46 100644
--- a/lib/igt_pm.h
+++ b/lib/igt_pm.h
@@ -79,8 +79,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_get_d3cold_allowed(const char *pci_slot_name, uint32_t *value);
+void igt_pm_set_d3cold_allowed(const char *pci_slot_name, uint32_t value);
 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);
diff --git a/tests/i915/i915_suspend.c b/tests/i915/i915_suspend.c
index 851e797c2..c25805584 100644
--- a/tests/i915/i915_suspend.c
+++ b/tests/i915/i915_suspend.c
@@ -283,7 +283,7 @@ static void
 test_suspend_without_i915(int state)
 {
 	struct igt_device_card card;
-	char d3cold_allowed[2];
+	uint32_t d3cold_allowed;
 	int fd;
 
 	fd = __drm_open_driver(DRIVER_INTEL);
@@ -297,8 +297,8 @@ test_suspend_without_i915(int state)
 	 */
 	if (state == SUSPEND_STATE_FREEZE &&
 	    igt_device_find_first_i915_discrete_card(&card)) {
-		igt_pm_get_d3cold_allowed(&card, d3cold_allowed);
-		igt_pm_set_d3cold_allowed(&card, "0\n");
+		igt_pm_get_d3cold_allowed(card.pci_slot_name, &d3cold_allowed);
+		igt_pm_set_d3cold_allowed(card.pci_slot_name, 0);
 	}
 	drm_close_driver(fd);
 
@@ -308,7 +308,7 @@ test_suspend_without_i915(int state)
 	igt_system_suspend_autoresume(state, SUSPEND_TEST_NONE);
 
 	if (state == SUSPEND_STATE_FREEZE && strlen(card.card))
-		igt_pm_set_d3cold_allowed(&card, d3cold_allowed);
+		igt_pm_set_d3cold_allowed(card.pci_slot_name, d3cold_allowed);
 
 	igt_kmsg(KMSG_INFO "Re-loading i915 \n");
 	igt_assert_eq(igt_i915_driver_load(NULL), 0);
-- 
2.40.0

  parent reply	other threads:[~2023-08-03  5:02 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-03  5:06 [igt-dev] [PATCH i-g-t 0/4] RFC Modify igt_pm functions and add GT C6 freeze test Riana Tauro
2023-08-03  5:06 ` [igt-dev] [PATCH i-g-t 1/4] lib/igt_device: Add a function to get the pci slot name Riana Tauro
2023-08-03  6:44   ` Gupta, Anshuman
2023-08-03  5:06 ` Riana Tauro [this message]
2023-08-03  7:07   ` [igt-dev] [PATCH i-g-t 2/4] lib/igt_pm: change d3cold_allowed function parameters Gupta, Anshuman
2023-08-03  8:46     ` Riana Tauro
2023-08-03  8:48       ` Gupta, Anshuman
2023-08-03  5:06 ` [igt-dev] [PATCH i-g-t 3/4] tests/xe: use igt_pm library functions Riana Tauro
2023-08-03  5:06 ` [igt-dev] [PATCH i-g-t 4/4] tests/xe: Add a test that validates residency during s2idle Riana Tauro
2023-08-03  7:47   ` Gupta, Anshuman
2023-08-03  8:48     ` Riana Tauro
2023-08-03  6:05 ` [igt-dev] ○ CI.xeBAT: info for RFC Modify igt_pm functions and add GT C6 freeze test Patchwork
2023-08-03  6:09 ` [igt-dev] ✓ Fi.CI.BAT: success " Patchwork
2023-08-03  7:50 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230803050609.2835714-3-riana.tauro@intel.com \
    --to=riana.tauro@intel.com \
    --cc=badal.nilawar@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox