From patchwork Fri Feb 21 15:54:11 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cavitt X-Patchwork-Id: 13985759 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 19B60C021B3 for ; Fri, 21 Feb 2025 15:54:21 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A551210EAC7; Fri, 21 Feb 2025 15:54:17 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="QODkOxOX"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) by gabe.freedesktop.org (Postfix) with ESMTPS id 33D2610EAC3; Fri, 21 Feb 2025 15:54:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1740153256; x=1771689256; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=C8/VP15dw5nM6vDUrN/jJM4lP9/GJpfnqfKL+bPMCNk=; b=QODkOxOX5WASRLUtSg6MGDIKcM+6jcEwG/7soPJkJhO2YfX3XpaX34hg BHRX62tafwr5olpe3rw+ijqBn/Xz0vik6M49jO3K+OYsJVyKG62a30Lmh yYxG5KksFZd9I3HgjnbHAFBpwuUHk6uLG0Bq1VYXxQ/o71AVJRVsA9VGz 0Mo5L0l7jzj+UyEhP4lg4F4knNmGBLmpZOkaFfiEjf70mfgyk+UMqv/+N doZ1lk8sEQqiupJVL9qAbWsixWQuLuAdLISXLht51HRvWpFcO36YKTmAG ulT5RRaAUv3pkFmd6xIYCa6xlFcsYvEBAch0WZOWhTCNXklcQj/ZwcYHa w==; X-CSE-ConnectionGUID: 6WB00pQASDCFpoyx/ykLBw== X-CSE-MsgGUID: jTWRB7BARuuVzBwEGpkJPw== X-IronPort-AV: E=McAfee;i="6700,10204,11352"; a="51190864" X-IronPort-AV: E=Sophos;i="6.13,305,1732608000"; d="scan'208";a="51190864" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Feb 2025 07:54:16 -0800 X-CSE-ConnectionGUID: ocPvaGxASvKY3kYB3ctAhg== X-CSE-MsgGUID: 1tChsnraS8WUogQ1uClL8w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,224,1728975600"; d="scan'208";a="152595563" Received: from dut4432lnl.fm.intel.com ([10.105.10.105]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Feb 2025 07:54:16 -0800 From: Jonathan Cavitt To: igt-dev@lists.freedesktop.org Cc: saurabhg.gupta@intel.com, alex.zuo@intel.com, jonathan.cavitt@intel.com, joonas.lahtinen@linux.intel.com, tvrtko.ursulin@igalia.com, lucas.demarchi@intel.com, matthew.brost@intel.com, dri-devel@lists.freedesktop.org, simona.vetter@ffwll.ch, kamil.konieczny@linux.intel.com Subject: [PATCH 1/4] drm-uapi/xe: Declare reset stats query Date: Fri, 21 Feb 2025 15:54:11 +0000 Message-ID: <20250221155414.13961-2-jonathan.cavitt@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250221155414.13961-1-jonathan.cavitt@intel.com> References: <20250221155414.13961-1-jonathan.cavitt@intel.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Align with 20250220203832.130430-1-jonathan.cavitt@intel.com Add initial declarations for the reset stats query, including necessary structures and IOCTL macros. Signed-off-by: Jonathan Cavitt --- include/drm-uapi/xe_drm.h | 50 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/include/drm-uapi/xe_drm.h b/include/drm-uapi/xe_drm.h index 08e263b3b2..e4f2f0d2a6 100644 --- a/include/drm-uapi/xe_drm.h +++ b/include/drm-uapi/xe_drm.h @@ -700,6 +700,7 @@ struct drm_xe_device_query { #define DRM_XE_DEVICE_QUERY_ENGINE_CYCLES 6 #define DRM_XE_DEVICE_QUERY_UC_FW_VERSION 7 #define DRM_XE_DEVICE_QUERY_OA_UNITS 8 +#define DRM_XE_DEVICE_QUERY_RESET_STATS 10 /** @query: The type of data to query */ __u32 query; @@ -1729,6 +1730,55 @@ struct drm_xe_oa_stream_info { __u64 reserved[3]; }; +#define MAX_BAN_COUNT 50 +/** + * struct drm_xe_exec_queue_ban - Per drm client exec queue ban info returned + * from @DRM_XE_DEVICE_QUERY_RESET_STATS query. Includes the exec queue ID and + * all associated pagefault information, if relevant. + */ +struct drm_xe_exec_queue_ban { + /** @exec_queue_id: ID of banned exec queue */ + __u32 exec_queue_id; + /** + * @pf_found: whether or not the ban is associated with a pagefault. + * If not, all pagefault data will default to 0 and will not be relevant. + */ + __u8 pf_found; + /** @access_type: access type of associated pagefault */ + __u8 access_type; + /** @fault_type: fault type of associated pagefault */ + __u8 fault_type; + /** @vfid: VFID of associated pagefault */ + __u8 vfid; + /** @asid: ASID of associated pagefault */ + __u32 asid; + /** @pdata: PDATA of associated pagefault */ + __u16 pdata; + /** @engine_class: engine class of associated pagefault */ + __u8 engine_class; + /** @engine_instance: engine instance of associated pagefault */ + __u8 engine_instance; + /** @fault_addr: faulted address of associated pagefault */ + __u64 fault_addr; +}; + +/** + * struct drm_xe_query_reset_stats - Per drm client reset stats query. + */ +struct drm_xe_query_reset_stats { + /** @extensions: Pointer to the first extension struct, if any */ + __u64 extensions; + /** @reset_count: Number of times the drm client has observed an engine reset */ + __u64 reset_count; + /** @ban_count: number of exec queue bans saved by the drm client */ + __u64 ban_count; + /** + * @ban_list: flexible array of struct drm_xe_exec_queue_ban, reporting all + * observed exec queue bans on the drm client. + */ + struct drm_xe_exec_queue_ban ban_list[]; +}; + #if defined(__cplusplus) } #endif From patchwork Fri Feb 21 15:54:12 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cavitt X-Patchwork-Id: 13985761 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 02754C021B6 for ; Fri, 21 Feb 2025 15:54:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 33CFC10EACB; Fri, 21 Feb 2025 15:54:18 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="iZC9cd3z"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) by gabe.freedesktop.org (Postfix) with ESMTPS id B3C8E10EAC1; Fri, 21 Feb 2025 15:54:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1740153257; x=1771689257; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3CCZcQ88N7xM0mUkD6/JYIoCM034YA+KexUX3QUBvHQ=; b=iZC9cd3z/4GOoFAhhyKTmoTiOLvv9+06l4m43NM5OEARjufdbqRw+AVa xTKnThH0J0/DbCrJsYZ6GlLU2rUhzVZ9MSUmIz4u+xSgqsV36OIl9vyKQ 1STnkgIQQhHA39UBJ9PGzXQPVTPS1jlXP/VRQz0m1HqRAWFcl+TeWLCcl nKxFa//2Hn/F/f9iJevdlV9IdYvjQjmhWD34Kx7q+rIuGUWFqwzM8OsHB USAy2+HiIrlL7c/T69eI/0vISNTfpkxdw46o6kW4solOd3C5ObFH6xItL LCwo7j9YmppWczX3vaMmhaY5LP1kEh7MeETKQqmqtZ2qtDgWgZxD9SIP4 w==; X-CSE-ConnectionGUID: 0wc284wXSJmU71t4YhJR4g== X-CSE-MsgGUID: sBh41qxOSWWmmw3OW65Qxg== X-IronPort-AV: E=McAfee;i="6700,10204,11352"; a="51190869" X-IronPort-AV: E=Sophos;i="6.13,305,1732608000"; d="scan'208";a="51190869" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Feb 2025 07:54:17 -0800 X-CSE-ConnectionGUID: m3vMS1DNRWeUyA8Xstv0GQ== X-CSE-MsgGUID: MT3cSLx/QTCkRltLZ0MCkw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,224,1728975600"; d="scan'208";a="152595569" Received: from dut4432lnl.fm.intel.com ([10.105.10.105]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Feb 2025 07:54:16 -0800 From: Jonathan Cavitt To: igt-dev@lists.freedesktop.org Cc: saurabhg.gupta@intel.com, alex.zuo@intel.com, jonathan.cavitt@intel.com, joonas.lahtinen@linux.intel.com, tvrtko.ursulin@igalia.com, lucas.demarchi@intel.com, matthew.brost@intel.com, dri-devel@lists.freedesktop.org, simona.vetter@ffwll.ch, kamil.konieczny@linux.intel.com Subject: [PATCH 2/4] tests/intel/xe_query: Implement reset stats query test Date: Fri, 21 Feb 2025 15:54:12 +0000 Message-ID: <20250221155414.13961-3-jonathan.cavitt@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250221155414.13961-1-jonathan.cavitt@intel.com> References: <20250221155414.13961-1-jonathan.cavitt@intel.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Add initial test to xe query test suite that exercises the reset stats query. The new test outputs the results of the query. Signed-off-by: Jonathan Cavitt --- tests/intel/xe_query.c | 85 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/tests/intel/xe_query.c b/tests/intel/xe_query.c index 1566680e7a..9862ea87d9 100644 --- a/tests/intel/xe_query.c +++ b/tests/intel/xe_query.c @@ -1077,6 +1077,90 @@ static void test_query_oa_units(int fd) } } +/** + * The reset stats query will report -EOPNOTSUPP if the kernel is + * configured without CONFIG_PROC_FS. Check this before running + * any tests on this query. + */ +static bool +query_reset_stats_supported(int fd) +{ + struct drm_xe_device_query query = { + .extensions = 0, + .query = DRM_XE_DEVICE_QUERY_RESET_STATS, + .size = 0, + .data = 0, + }; + int ret = igt_ioctl(fd, DRM_IOCTL_XE_DEVICE_QUERY, &query); + + if (ret) + igt_assert(ret == -EOPNOTSUPP); + return !ret; +} + +/** + * SUBTEST: query-reset-stats + * Description: Display fields for reset stats query + * + * SUBTEST: multigpu-query-reset-stats + * Description: Display fields for reset stats query for all GPU devices + * Sub-category: MultiGPU + */ +static void test_query_reset_stats(int fd) +{ + struct drm_xe_query_reset_stats *qrs; + struct drm_xe_device_query query = { + .extensions = 0, + .query = DRM_XE_DEVICE_QUERY_RESET_STATS, + .size = 0, + .data = 0, + }; + struct drm_xe_exec_queue_ban *ban; + + igt_skip_on(!query_reset_stats_supported(fd)); + igt_assert_eq(igt_ioctl(fd, DRM_IOCTL_XE_DEVICE_QUERY, &query), 0); + + qrs = malloc(query.size); + igt_assert(qrs); + + query.data = to_user_pointer(qrs); + igt_assert_eq(igt_ioctl(fd, DRM_IOCTL_XE_DEVICE_QUERY, &query), 0); + + igt_info("reset count: %lld\n", qrs->reset_count); + igt_info("ban count: %lld\n", qrs->ban_count); + + for (int i = 0; i < qrs->ban_count; i++) { + ban = &qrs->ban_list[i]; + + igt_info("-------------------------------\n"); + igt_info("exec queue ban %d\n", i); + igt_info("-------------------------------\n"); + igt_info("exec_queue_id: %d\n", ban->exec_queue_id); + if (!ban->pf_found) { + igt_info("no associated pagefault\n"); + continue; + } + igt_info("pagefault associated:\n"); + igt_info("\tASID: %d\n" + "\tVFID: %d\n" + "\tPDATA: 0x%04x\n" + "\tFaulted Address: 0x%08x%08x\n" + "\tFaultType: %d\n" + "\tAccessType: %d\n" + "\tEngineClass: %d %s\n" + "\tEngineInstance: %d\n", + ban->asid, ban->vfid, ban->pdata, + upper_32_bits(ban->fault_addr), + lower_32_bits(ban->fault_addr), + ban->fault_type, ban->access_type, + ban->engine_class, + xe_engine_class_string(ban->engine_class), + ban->engine_instance); + } + + free(qrs); +} + igt_main { const struct { @@ -1094,6 +1178,7 @@ igt_main { "query-uc-fw-version-guc", test_query_uc_fw_version_guc }, { "query-uc-fw-version-huc", test_query_uc_fw_version_huc }, { "query-oa-units", test_query_oa_units }, + { "query-reset-stats", test_query_reset_stats }, { "query-invalid-cs-cycles", test_engine_cycles_invalid }, { "query-invalid-query", test_query_invalid_query }, { "query-invalid-size", test_query_invalid_size }, From patchwork Fri Feb 21 15:54:13 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cavitt X-Patchwork-Id: 13985758 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 85157C021B7 for ; Fri, 21 Feb 2025 15:54:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A486C10EAC6; Fri, 21 Feb 2025 15:54:17 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="eu41Ynur"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3844C10EAC6; Fri, 21 Feb 2025 15:54:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1740153257; x=1771689257; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zI0CgkJN8PhMuLw7NBSP5eBEt5JvbKKdnyarZw+8Zvg=; b=eu41YnurlZnT5FjDFN/2JmNk0MytvEV/jDVp58+6LMGu6grIBPpSx4Nz DGvCOL4VPytFKpdHKgRe36ukpw1nS7NBGenbydfTS5clE+90ycU/WG+Dh GmM4htW7OrYpI3WKnanbKKGm5tHceO+G4kTmbJYQvK8e9stu8g188pFV8 Xz8burXIXyOPSQEkXboqMPblbOVoI5LnN+FgI7FcrGybfM23KMDpUHmuT KgEifpFI0yoTvBHjij4n2qxAMjLsiaLuk2hWiPQJ94IzbCMaHCBQn+Bjw qaOS8bXN8Jef5tUOM4w+00Gmd/UPhT+wppzKIRSfdT85vPIIKu5vH5iu+ w==; X-CSE-ConnectionGUID: Lt2WHZnhTr6fknqNM+XCgg== X-CSE-MsgGUID: O4KzuMtHShmrfmCFZU83cg== X-IronPort-AV: E=McAfee;i="6700,10204,11352"; a="51190872" X-IronPort-AV: E=Sophos;i="6.13,305,1732608000"; d="scan'208";a="51190872" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Feb 2025 07:54:17 -0800 X-CSE-ConnectionGUID: v3FUSx+QQi+6lIF8mvTM3A== X-CSE-MsgGUID: PF2Ni3ZqT9KKCvUyYg59uA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,224,1728975600"; d="scan'208";a="152595573" Received: from dut4432lnl.fm.intel.com ([10.105.10.105]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Feb 2025 07:54:17 -0800 From: Jonathan Cavitt To: igt-dev@lists.freedesktop.org Cc: saurabhg.gupta@intel.com, alex.zuo@intel.com, jonathan.cavitt@intel.com, joonas.lahtinen@linux.intel.com, tvrtko.ursulin@igalia.com, lucas.demarchi@intel.com, matthew.brost@intel.com, dri-devel@lists.freedesktop.org, simona.vetter@ffwll.ch, kamil.konieczny@linux.intel.com Subject: [PATCH 3/4] tests/intel/xe_query: Exercise reset count in reset stats Date: Fri, 21 Feb 2025 15:54:13 +0000 Message-ID: <20250221155414.13961-4-jonathan.cavitt@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250221155414.13961-1-jonathan.cavitt@intel.com> References: <20250221155414.13961-1-jonathan.cavitt@intel.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Extend the reset stats query tests to exercise the reset count value. Assert that the reset count increases when an engine reset occurs. Signed-off-by: Jonathan Cavitt --- tests/intel/xe_query.c | 52 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/tests/intel/xe_query.c b/tests/intel/xe_query.c index 9862ea87d9..1a9a583a9a 100644 --- a/tests/intel/xe_query.c +++ b/tests/intel/xe_query.c @@ -1161,6 +1161,57 @@ static void test_query_reset_stats(int fd) free(qrs); } +/** + * SUBTEST: query-reset-stats-reset + * Description: Assert reset stats query tracks reset count + * + * SUBTEST: multigpu-query-reset-stats-reset + * Description: Assert reset stats query tracks reset count for all GPU devices + * Sub-category: MultiGPU + */ +static void +test_query_reset_stats_reset(int fd) +{ + struct drm_xe_engine_class_instance *hwe; + struct drm_xe_query_reset_stats *qrs; + struct drm_xe_device_query query = { + .extensions = 0, + .query = DRM_XE_DEVICE_QUERY_RESET_STATS, + .size = 0, + .data = 0, + }; + u64 resets1, resets2; + + igt_skip_on(!query_reset_stats_supported(fd)); + igt_assert_eq(igt_ioctl(fd, DRM_IOCTL_XE_DEVICE_QUERY, &query), 0); + + qrs = malloc(query.size); + igt_assert(qrs); + + query.data = to_user_pointer(qrs); + igt_assert_eq(igt_ioctl(fd, DRM_IOCTL_XE_DEVICE_QUERY, &query), 0); + resets1 = qrs->reset_count; + free(qrs); + + query.size = 0; + query.data = 0; + + xe_for_each_engine(fd, hwe) + xe_force_gt_reset_sync(fd, hwe->gt_id); + + igt_assert_eq(igt_ioctl(fd, DRM_IOCTL_XE_DEVICE_QUERY, &query), 0); + + qrs = malloc(query.size); + igt_assert(qrs); + + query.data = to_user_pointer(qrs); + igt_assert_eq(igt_ioctl(fd, DRM_IOCTL_XE_DEVICE_QUERY, &query), 0); + resets2 = qrs->reset_count; + free(qrs); + + igt_assert_lt(resets1, resets2); +} + igt_main { const struct { @@ -1179,6 +1230,7 @@ igt_main { "query-uc-fw-version-huc", test_query_uc_fw_version_huc }, { "query-oa-units", test_query_oa_units }, { "query-reset-stats", test_query_reset_stats }, + { "query-reset-stats-reset", test_query_reset_stats_reset }, { "query-invalid-cs-cycles", test_engine_cycles_invalid }, { "query-invalid-query", test_query_invalid_query }, { "query-invalid-size", test_query_invalid_size }, From patchwork Fri Feb 21 15:54:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cavitt X-Patchwork-Id: 13985762 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EC8F0C021B5 for ; Fri, 21 Feb 2025 15:54:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8911410EACF; Fri, 21 Feb 2025 15:54:21 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="EQUPcnXK"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) by gabe.freedesktop.org (Postfix) with ESMTPS id D8D8710EAC9; Fri, 21 Feb 2025 15:54:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1740153258; x=1771689258; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2GM9VgOPos4phqkalJB74EWdm75V8sdJk+DMXLCJV2I=; b=EQUPcnXKY+DqVJpQEzoOeSjPK3c85bTVVCudK97w5azQJb1+ch2ApQKh /9uNzMc05nr5CtOEXBygdfi2ugSF3OCGRQxrgxXFz7PeVti+FfMb39KnB OFYgj/Q418aJxE3S5WcWD7/aBwkO+4qqpgyEvG2QumWB2gj8GvkZREoXI WIPBJW1AQgXsRVkdHZXA+NhJcIyiUbFSzg9her2Y98klhKx6HZVtnS4zH xhRO10sL6nfmzkOjLPSzs6bxlX09YNAbqxRWHYqPm8oJd7iBDH2AocUqV slwYoCbaD4FS+VJL4V2cTmOWo5NhzuaV7Iasj0Hb3Zs99U+gajBrguhel g==; X-CSE-ConnectionGUID: gl9Cu+NsREaX3XhHwx6hBw== X-CSE-MsgGUID: uj04zdTRSYic2autl5BrCA== X-IronPort-AV: E=McAfee;i="6700,10204,11352"; a="51190878" X-IronPort-AV: E=Sophos;i="6.13,305,1732608000"; d="scan'208";a="51190878" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Feb 2025 07:54:18 -0800 X-CSE-ConnectionGUID: k4+x0/cLQvGaN4nQ9f+AHQ== X-CSE-MsgGUID: LtaI7y+1TzmdshoJkOgfiw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,224,1728975600"; d="scan'208";a="152595576" Received: from dut4432lnl.fm.intel.com ([10.105.10.105]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Feb 2025 07:54:18 -0800 From: Jonathan Cavitt To: igt-dev@lists.freedesktop.org Cc: saurabhg.gupta@intel.com, alex.zuo@intel.com, jonathan.cavitt@intel.com, joonas.lahtinen@linux.intel.com, tvrtko.ursulin@igalia.com, lucas.demarchi@intel.com, matthew.brost@intel.com, dri-devel@lists.freedesktop.org, simona.vetter@ffwll.ch, kamil.konieczny@linux.intel.com Subject: [PATCH 4/4] tests/intel/xe_query: Exercise ban count in reset stats Date: Fri, 21 Feb 2025 15:54:14 +0000 Message-ID: <20250221155414.13961-5-jonathan.cavitt@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250221155414.13961-1-jonathan.cavitt@intel.com> References: <20250221155414.13961-1-jonathan.cavitt@intel.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Extend the reset stats query tests to exercise the ban count value. Assert that the ban count increases when a pagefault occurs. Signed-off-by: Jonathan Cavitt --- tests/intel/xe_query.c | 202 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 202 insertions(+) diff --git a/tests/intel/xe_query.c b/tests/intel/xe_query.c index 1a9a583a9a..cb4ebd8d6a 100644 --- a/tests/intel/xe_query.c +++ b/tests/intel/xe_query.c @@ -1212,6 +1212,207 @@ test_query_reset_stats_reset(int fd) igt_assert_lt(resets1, resets2); } +static void gen_pf(int fd, struct drm_xe_engine_class_instance *eci) +{ + uint32_t vm; + uint64_t addr = 0x1a0000; + uint64_t sync_addr = 0x101a0000; +#define USER_FENCE_VALUE 0xdeadbeefdeadbeefull + struct drm_xe_sync sync[1] = { + { .type = DRM_XE_SYNC_TYPE_USER_FENCE, .flags = DRM_XE_SYNC_FLAG_SIGNAL, + .timeline_value = USER_FENCE_VALUE }, + }; + struct drm_xe_exec exec = { + .num_batch_buffer = 1, + .num_syncs = 1, + .syncs = to_user_pointer(sync), + }; + uint32_t exec_queues[1]; + uint32_t bind_exec_queues[1]; + size_t bo_size, sync_size; + struct { + uint32_t batch[16]; + uint64_t pad; + uint64_t vm_sync; + uint32_t data; + } *data; + uint64_t *exec_sync; + int i, b; + int map_fd = -1; + int n_exec_queues = 1; + int n_execs = 64; + + vm = xe_vm_create(fd, DRM_XE_VM_CREATE_FLAG_LR_MODE | + DRM_XE_VM_CREATE_FLAG_FAULT_MODE, 0); + bo_size = sizeof(*data) * n_execs; + bo_size = xe_bb_size(fd, bo_size); + sync_size = sizeof(*exec_sync) * n_execs; + sync_size = xe_bb_size(fd, sync_size); + +#define MAP_ADDRESS 0x00007fadeadbe000 + data = mmap((void *)MAP_ADDRESS, bo_size, PROT_READ | + PROT_WRITE, MAP_SHARED | MAP_FIXED | + MAP_ANONYMOUS, -1, 0); + igt_assert(data != MAP_FAILED); + memset(data, 0, bo_size); + +#define EXEC_SYNC_ADDRESS 0x00007fbdeadbe000 + exec_sync = mmap((void *)EXEC_SYNC_ADDRESS, sync_size, PROT_READ | PROT_WRITE, + MAP_SHARED | MAP_FIXED | MAP_ANONYMOUS, -1, 0); + igt_assert(exec_sync != MAP_FAILED); + memset(exec_sync, 0, sync_size); + + for (i = 0; i < n_exec_queues; i++) { + exec_queues[i] = xe_exec_queue_create(fd, vm, eci, 0); + bind_exec_queues[i] = 0; + } + + sync[0].addr = to_user_pointer(&data[0].vm_sync); + xe_vm_bind_userptr_async(fd, vm, bind_exec_queues[0], + to_user_pointer(data), addr, + bo_size, sync, 1); + + xe_wait_ufence(fd, &data[0].vm_sync, USER_FENCE_VALUE, + bind_exec_queues[0], NSEC_PER_SEC); + data[0].vm_sync = 0; + + xe_vm_bind_userptr_async(fd, vm, bind_exec_queues[0], + to_user_pointer(exec_sync), sync_addr, + sync_size, sync, 1); + xe_wait_ufence(fd, &data[0].vm_sync, USER_FENCE_VALUE, + bind_exec_queues[0], NSEC_PER_SEC); + data[0].vm_sync = 0; + + for (i = 0; i < n_execs; i++) { + uint64_t batch_offset = (char *)&data[i].batch - (char *)data; + uint64_t batch_addr = addr + batch_offset; + uint64_t sdi_offset = (char *)&data[i].data - (char *)data; + uint64_t sdi_addr = addr + sdi_offset; + int e = i % n_exec_queues; + + b = 0; + + data[i].batch[b++] = MI_STORE_DWORD_IMM_GEN4; + data[i].batch[b++] = sdi_addr; + data[i].batch[b++] = sdi_addr >> 32; + data[i].batch[b++] = 0xc0ffee; + data[i].batch[b++] = MI_BATCH_BUFFER_END; + igt_assert(b <= ARRAY_SIZE(data[i].batch)); + + sync[0].addr = sync_addr + (char *)&exec_sync[i] - (char *)exec_sync; + + exec.exec_queue_id = exec_queues[e]; + exec.address = batch_addr; + xe_exec(fd, &exec); + + if (i + 1 != n_execs) { + /* + * Wait for exec completion and check data as + * userptr will likely change to different + * physical memory on next mmap call triggering + * an invalidate. + */ + xe_wait_ufence(fd, &exec_sync[i], + USER_FENCE_VALUE, exec_queues[e], + NSEC_PER_SEC); + igt_assert_eq(data[i].data, 0xc0ffee); + data = mmap((void *)MAP_ADDRESS, bo_size, + PROT_READ | PROT_WRITE, MAP_SHARED | + MAP_FIXED | MAP_ANONYMOUS, -1, 0); + igt_assert(data != MAP_FAILED); + } + } + + for (i = n_execs - 1; i < n_execs; i++) { + int64_t timeout = NSEC_PER_SEC; + + igt_assert_eq(__xe_wait_ufence(fd, &exec_sync[i], USER_FENCE_VALUE, + exec_queues[i % n_exec_queues], &timeout), 0); + } + + sync[0].addr = to_user_pointer(&data[0].vm_sync); + data[0].vm_sync = 0; + xe_vm_unbind_async(fd, vm, bind_exec_queues[0], 0, sync_addr, sync_size, + sync, 1); + xe_wait_ufence(fd, &data[0].vm_sync, USER_FENCE_VALUE, + bind_exec_queues[0], NSEC_PER_SEC); + data[0].vm_sync = 0; + xe_vm_unbind_async(fd, vm, bind_exec_queues[0], 0, addr, bo_size, + sync, 1); + xe_wait_ufence(fd, &data[0].vm_sync, USER_FENCE_VALUE, + bind_exec_queues[0], NSEC_PER_SEC); + + for (i = 0; i < n_exec_queues; i++) { + xe_exec_queue_destroy(fd, exec_queues[i]); + if (bind_exec_queues[i]) + xe_exec_queue_destroy(fd, bind_exec_queues[i]); + } + + munmap(exec_sync, sync_size); + xe_vm_destroy(fd, vm); + if (map_fd != -1) + close(map_fd); +} + +/** + * SUBTEST: query-reset-stats-bans + * Description: Assert reset stats query tracks exec queue bans + * + * SUBTEST: multigpu-query-reset-stats-bans + * Description: Assert reset stats query tracks exec queue bans for all GPU devices + * Sub-category: MultiGPU + */ +static void +test_query_reset_stats_bans(int fd) +{ + struct drm_xe_engine_class_instance *hwe; + struct drm_xe_query_reset_stats *qrs; + struct drm_xe_device_query query = { + .extensions = 0, + .query = DRM_XE_DEVICE_QUERY_RESET_STATS, + .size = 0, + .data = 0, + }; + u64 bans1, bans2; + + igt_skip_on(!query_reset_stats_supported(fd)); + igt_assert_eq(igt_ioctl(fd, DRM_IOCTL_XE_DEVICE_QUERY, &query), 0); + + qrs = malloc(query.size); + igt_assert(qrs); + + query.data = to_user_pointer(qrs); + igt_assert_eq(igt_ioctl(fd, DRM_IOCTL_XE_DEVICE_QUERY, &query), 0); + bans1 = qrs->ban_count; + free(qrs); + + query.size = 0; + query.data = 0; + + xe_for_each_engine(fd, hwe) + gen_pf(fd, hwe); + + igt_assert_eq(igt_ioctl(fd, DRM_IOCTL_XE_DEVICE_QUERY, &query), 0); + + qrs = malloc(query.size); + igt_assert(qrs); + + query.data = to_user_pointer(qrs); + igt_assert_eq(igt_ioctl(fd, DRM_IOCTL_XE_DEVICE_QUERY, &query), 0); + bans2 = qrs->ban_count; + free(qrs); + + /** + * There is a limit to the number of bans that can be saved to the + * ban list, so if that limit was already reached before now, assert + * the list did not get any smaller. + */ + if (bans1 == MAX_BAN_COUNT) + igt_assert_eq(bans1, bans2); + else + igt_assert_lt(bans1, bans2); +} + igt_main { const struct { @@ -1231,6 +1432,7 @@ igt_main { "query-oa-units", test_query_oa_units }, { "query-reset-stats", test_query_reset_stats }, { "query-reset-stats-reset", test_query_reset_stats_reset }, + { "query-reset-stats-bans", test_query_reset_stats_bans }, { "query-invalid-cs-cycles", test_engine_cycles_invalid }, { "query-invalid-query", test_query_invalid_query }, { "query-invalid-size", test_query_invalid_size },