Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Zbigniew Kempczyński" <zbigniew.kempczynski@intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t v7 3/7] lib/igt_pm: Add a helper to query the runtime_usage.
Date: Tue,  7 Mar 2023 23:12:32 +0100	[thread overview]
Message-ID: <20230307221236.913429-4-zbigniew.kempczynski@intel.com> (raw)
In-Reply-To: <20230307221236.913429-1-zbigniew.kempczynski@intel.com>

From: Rodrigo Vivi <rodrigo.vivi@intel.com>

It will be useful so the tests can assert the expected
usage counter movement depending on the operation.

Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
Acked-by: Mauro Carvalho Chehab <mchehab@kernel.org>
---
 lib/igt_pm.c | 18 ++++++++++++++++++
 lib/igt_pm.h |  1 +
 2 files changed, 19 insertions(+)

diff --git a/lib/igt_pm.c b/lib/igt_pm.c
index 6c84e94f63..704acf7d14 100644
--- a/lib/igt_pm.c
+++ b/lib/igt_pm.c
@@ -1363,3 +1363,21 @@ int igt_pm_get_runtime_suspended_time(struct pci_device *pci_dev)
 
 	return -1;
 }
+
+/**
+ * igt_pm_get_runtime_usage:
+ * @pci_dev: pci device
+ *
+ * Reports the runtime PM usage count of a device.
+ */
+int igt_pm_get_runtime_usage(struct pci_device *pci_dev)
+{
+	char usage_str[64];
+	int usage, fd;
+
+	fd = igt_pm_get_power_attr_fd_rdonly(pci_dev, "runtime_usage");
+	if (igt_pm_read_power_attr(fd, usage_str, 64, true))
+		igt_assert(sscanf(usage_str, "%d", &usage) > 0);
+
+	return usage;
+}
diff --git a/lib/igt_pm.h b/lib/igt_pm.h
index f65b960c38..d0d6d673e8 100644
--- a/lib/igt_pm.h
+++ b/lib/igt_pm.h
@@ -86,5 +86,6 @@ void igt_pm_restore_pci_card_runtime_pm(void);
 void igt_pm_print_pci_card_runtime_status(void);
 bool i915_is_slpc_enabled(int fd);
 int igt_pm_get_runtime_suspended_time(struct pci_device *pci_dev);
+int igt_pm_get_runtime_usage(struct pci_device *pci_dev);
 
 #endif /* IGT_PM_H */
-- 
2.34.1

  parent reply	other threads:[~2023-03-07 22:12 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-07 22:12 [igt-dev] [PATCH i-g-t v7 0/7] Initial Xe test suite Zbigniew Kempczyński
2023-03-07 22:12 ` [igt-dev] [PATCH i-g-t v7 1/7] drm-uapi/xe_drm: Add Xe uAPI Zbigniew Kempczyński
2023-03-07 22:12 ` [igt-dev] [PATCH i-g-t v7 2/7] lib/xe: Introduce Xe library Zbigniew Kempczyński
2023-03-10  4:30   ` Dixit, Ashutosh
2023-03-10  4:38     ` Dixit, Ashutosh
2023-03-10  6:41       ` Mauro Carvalho Chehab
2023-03-11  4:09         ` Dixit, Ashutosh
2023-03-07 22:12 ` Zbigniew Kempczyński [this message]
2023-03-07 22:12 ` [igt-dev] [PATCH i-g-t v7 4/7] tests/xe: Add Xe IGT tests Zbigniew Kempczyński
2023-03-07 22:12 ` [igt-dev] [PATCH i-g-t v7 5/7] tools/xe_reg: Add Xe register read/write tool Zbigniew Kempczyński
2023-03-07 22:12 ` [igt-dev] [PATCH i-g-t v7 6/7] intel-ci/xe-fast-feedback: Introduce xe-fast-feedback list Zbigniew Kempczyński
2023-03-07 22:12 ` [igt-dev] [PATCH i-g-t v7 7/7] runner/job_list: return error on crashes while running --list-subtests Zbigniew Kempczyński
2023-03-07 22:28 ` [igt-dev] ✗ GitLab.Pipeline: warning for Initial Xe test suite (rev7) Patchwork
2023-03-07 22:50 ` [igt-dev] ✓ Fi.CI.BAT: success " Patchwork
2023-03-09 12:42 ` [igt-dev] ✓ Fi.CI.IGT: " 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=20230307221236.913429-4-zbigniew.kempczynski@intel.com \
    --to=zbigniew.kempczynski@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