From: "Zbigniew Kempczyński" <zbigniew.kempczynski@intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t v3 3/8] lib/igt_pm: Add a helper to query the runtime_usage.
Date: Fri, 24 Feb 2023 11:44:38 +0100 [thread overview]
Message-ID: <20230224104443.62373-4-zbigniew.kempczynski@intel.com> (raw)
In-Reply-To: <20230224104443.62373-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>
---
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 26e8c9f0..d405861e 100644
--- a/lib/igt_pm.c
+++ b/lib/igt_pm.c
@@ -1355,3 +1355,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 f65b960c..d0d6d673 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
next prev parent reply other threads:[~2023-02-24 10:44 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-24 10:44 [igt-dev] [PATCH i-g-t v3 0/8] Initial Xe test suite Zbigniew Kempczyński
2023-02-24 10:44 ` [igt-dev] [PATCH i-g-t v3 1/8] drm-uapi/xe_drm: Add Xe uAPI Zbigniew Kempczyński
2023-02-24 17:57 ` Michal Wajdeczko
2023-02-28 8:25 ` Zbigniew Kempczyński
2023-02-28 15:08 ` Lucas De Marchi
2023-03-01 6:08 ` Mauro Carvalho Chehab
2023-02-24 10:44 ` [igt-dev] [PATCH i-g-t v3 2/8] lib/xe: Introduce Xe library Zbigniew Kempczyński
2023-02-24 18:46 ` Michal Wajdeczko
2023-02-28 10:04 ` Zbigniew Kempczyński
2023-02-28 20:27 ` Dugast, Francois
2023-02-24 10:44 ` Zbigniew Kempczyński [this message]
2023-02-24 10:44 ` [igt-dev] [PATCH i-g-t v3 4/8] tests/xe: Add Xe IGT tests Zbigniew Kempczyński
2023-02-24 10:44 ` [igt-dev] [PATCH i-g-t v3 5/8] tools/xe_reg: Add Xe register read/write tool Zbigniew Kempczyński
2023-02-24 10:44 ` [igt-dev] [PATCH i-g-t v3 6/8] intel-ci/xe-fast-feedback: Introduce xe-fast-feedback list Zbigniew Kempczyński
2023-02-24 10:44 ` [igt-dev] [PATCH i-g-t v3 7/8] docs/testplan: Introduce new way for documenting IGT Zbigniew Kempczyński
2023-02-24 10:44 ` [igt-dev] [PATCH i-g-t v3 8/8] runner/job_list: return error on crashes while running --list-subtests Zbigniew Kempczyński
2023-02-24 13:17 ` [igt-dev] ✗ GitLab.Pipeline: warning for Initial Xe test suite (rev3) Patchwork
2023-02-24 13:34 ` [igt-dev] ✓ Fi.CI.BAT: success " Patchwork
2023-02-24 17:14 ` [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=20230224104443.62373-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