From: Ashutosh Dixit <ashutosh.dixit@intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t 03/20] lib/i915/perf: Add xe_perf_for_fd
Date: Mon, 7 Aug 2023 18:00:00 -0700 [thread overview]
Message-ID: <20230808010017.37819-4-ashutosh.dixit@intel.com> (raw)
In-Reply-To: <20230808010017.37819-1-ashutosh.dixit@intel.com>
Add xe_perf_for_fd which is called from intel_perf_for_fd for xe devices.
Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
---
lib/i915/perf.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++---
lib/meson.build | 2 +-
2 files changed, 54 insertions(+), 4 deletions(-)
diff --git a/lib/i915/perf.c b/lib/i915/perf.c
index ddadb53b61c8..5b82eeaf04b9 100644
--- a/lib/i915/perf.c
+++ b/lib/i915/perf.c
@@ -37,10 +37,11 @@
#include <i915_drm.h>
+#include "drmtest.h"
#include "i915_pciids.h"
-
#include "intel_chipset.h"
#include "perf.h"
+#include "xe/xe_query.h"
#include "i915_perf_metrics_hsw.h"
#include "i915_perf_metrics_bdw.h"
@@ -68,8 +69,6 @@
#include "i915_perf_metrics_mtlgt2.h"
#include "i915_perf_metrics_mtlgt3.h"
-#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
-
static int
perf_ioctl(int fd, unsigned long request, void *arg)
{
@@ -609,6 +608,54 @@ intel_sysfs_attr_id_to_name(int sysfs_dirfd, intel_sysfs_attr_id id, int gt)
intel_sysfs_attr_name[0][id];
}
+static struct intel_perf *
+xe_perf_for_fd(int drm_fd, int gt)
+{
+ uint32_t device_id;
+ uint32_t device_revision = 0;
+ uint32_t timestamp_frequency;
+ uint64_t gt_min_freq;
+ uint64_t gt_max_freq;
+ struct intel_perf *ret;
+ int sysfs_dir_fd = open_master_sysfs_dir(drm_fd);
+ char path_min[64], path_max[64];
+
+ if (sysfs_dir_fd < 0) {
+ igt_warn("open_master_sysfs_dir failed\n");
+ return NULL;
+ }
+
+ if (IS_PONTEVECCHIO(xe_dev_id(drm_fd))) {
+ sprintf(path_min, "device/tile%d/gt%d/freq_min", gt, gt);
+ sprintf(path_max, "device/tile%d/gt%d/freq_max", gt, gt);
+ } else {
+ sprintf(path_min, "device/tile0/gt%d/freq_min", gt);
+ sprintf(path_max, "device/tile0/gt%d/freq_max", gt);
+ }
+
+ if (!read_sysfs(sysfs_dir_fd, path_min, >_min_freq) ||
+ !read_sysfs(sysfs_dir_fd, path_max, >_max_freq)) {
+ igt_warn("Unable to read freqs from sysfs\n");
+ close(sysfs_dir_fd);
+ return NULL;
+ }
+ close(sysfs_dir_fd);
+
+ device_id = intel_get_drm_devid(drm_fd);
+ timestamp_frequency = xe_gts(drm_fd)->gts[0].oa_timestamp_freq;
+
+ ret = intel_perf_for_devinfo(device_id,
+ device_revision,
+ timestamp_frequency,
+ gt_min_freq * 1000000,
+ gt_max_freq * 1000000,
+ NULL);
+ if (!ret)
+ igt_warn("intel_perf_for_devinfo failed\n");
+
+ return ret;
+}
+
struct intel_perf *
intel_perf_for_fd(int drm_fd, int gt)
{
@@ -621,6 +668,9 @@ intel_perf_for_fd(int drm_fd, int gt)
struct intel_perf *ret;
int sysfs_dir_fd = open_master_sysfs_dir(drm_fd);
+ if (is_xe_device(drm_fd))
+ return xe_perf_for_fd(drm_fd, gt);
+
if (sysfs_dir_fd < 0)
return NULL;
diff --git a/lib/meson.build b/lib/meson.build
index ce11c0715f96..86b53f5bfae3 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -346,7 +346,7 @@ endforeach
lib_igt_i915_perf_build = shared_library(
'i915_perf',
i915_perf_files,
- dependencies: lib_igt_chipset,
+ dependencies: [lib_igt_chipset,lib_igt,pciaccess],
include_directories : inc,
install: true,
soversion: '1.5')
--
2.41.0
next prev parent reply other threads:[~2023-08-08 1:00 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-08 0:59 [igt-dev] [PATCH i-g-t 00/20] Extend i915/perf for testing Xe OA Ashutosh Dixit
2023-08-08 0:59 ` [igt-dev] [PATCH i-g-t 01/20] drm-uapi/xe_drm: OA changes Ashutosh Dixit
2023-08-08 0:59 ` [igt-dev] [PATCH i-g-t 02/20] lib/xe/xe_query: Add xe_gts interface Ashutosh Dixit
2023-08-08 1:00 ` Ashutosh Dixit [this message]
2023-08-08 6:20 ` [igt-dev] [PATCH i-g-t 03/20] lib/i915/perf: Add xe_perf_for_fd Zbigniew Kempczyński
2023-08-08 1:00 ` [igt-dev] [PATCH i-g-t 04/20] lib/i915/perf: Derive topology info for xe devices Ashutosh Dixit
2023-08-08 1:00 ` [igt-dev] [PATCH i-g-t 05/20] tests/i915/perf: Track variables across i915 and xe Ashutosh Dixit
2023-08-08 1:00 ` [igt-dev] [PATCH i-g-t 06/20] tests/i915/perf: Skip not ready tests for xe Ashutosh Dixit
2023-08-08 1:00 ` [igt-dev] [PATCH i-g-t 07/20] tests/i915/perf: Fix i915_perf_revision for use with xe Ashutosh Dixit
2023-08-08 1:00 ` [igt-dev] [PATCH i-g-t 08/20] tests/i915/perf: Fix sysfs functions for xe Ashutosh Dixit
2023-08-08 1:00 ` [igt-dev] [PATCH i-g-t 09/20] tests/i915/perf: Fix test_i915_ref_count " Ashutosh Dixit
2023-08-08 1:00 ` [igt-dev] [PATCH i-g-t 10/20] tests/i915/perf: Support only default_engine_group " Ashutosh Dixit
2023-08-08 1:00 ` [igt-dev] [PATCH i-g-t 11/20] tests/i915/perf: Only iterate over render engines " Ashutosh Dixit
2023-08-08 1:00 ` [igt-dev] [PATCH i-g-t 12/20] tests/i915/perf: Don't load module Ashutosh Dixit
2023-08-08 1:00 ` [igt-dev] [PATCH i-g-t 13/20] tests/i915/perf: Move test_sysctl_defaults after the fixture Ashutosh Dixit
2023-08-08 1:00 ` [igt-dev] [PATCH i-g-t 14/20] tests/i915/perf: Fix has_class_instance for xe Ashutosh Dixit
2023-08-08 6:35 ` Zbigniew Kempczyński
2023-08-08 1:00 ` [igt-dev] [PATCH i-g-t 15/20] tests/i915/perf: Temporarily skip render_copy " Ashutosh Dixit
2023-08-08 6:30 ` Zbigniew Kempczyński
2023-08-08 1:00 ` [igt-dev] [PATCH i-g-t 16/20] tests/i915/perf: Skip intel_ctx_create_all_physical " Ashutosh Dixit
2023-08-08 1:00 ` [igt-dev] [PATCH i-g-t 17/20] tests/i915/perf: Skip __for_each_render_engine " Ashutosh Dixit
2023-08-08 1:00 ` [igt-dev] [PATCH i-g-t 18/20] tests/i915/perf: Fix buf_map " Ashutosh Dixit
2023-08-08 6:26 ` Zbigniew Kempczyński
2023-08-08 1:00 ` [igt-dev] [PATCH i-g-t 19/20] tests/i915/perf: Use engine_id in gen12_test_mi_rpc " Ashutosh Dixit
2023-08-08 1:00 ` [igt-dev] [PATCH i-g-t 20/20] HAX: Add OA tests to xe-fast-feedback.testlist Ashutosh Dixit
2023-08-08 2:00 ` [igt-dev] ✓ Fi.CI.BAT: success for Extend i915/perf for testing Xe OA (rev2) Patchwork
2023-08-08 2:02 ` [igt-dev] ○ CI.xeBAT: info " Patchwork
2023-08-08 9:12 ` [igt-dev] ✓ Fi.CI.IGT: success " Patchwork
-- strict thread matches above, loose matches on Subject: below --
2023-07-20 23:17 [igt-dev] [PATCH i-g-t 00/20] Extend i915/perf for testing Xe OA Ashutosh Dixit
2023-07-20 23:17 ` [igt-dev] [PATCH i-g-t 03/20] lib/i915/perf: Add xe_perf_for_fd Ashutosh Dixit
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=20230808010017.37819-4-ashutosh.dixit@intel.com \
--to=ashutosh.dixit@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