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 6066FD33986 for ; Fri, 5 Dec 2025 15:55:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 17D6D10EB5E; Fri, 5 Dec 2025 15:55:01 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="MH/9fvLu"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id A788D10EB5E for ; Fri, 5 Dec 2025 15:54:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1764950100; x=1796486100; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=sIQH1I8lBRL4vLHF7zeV++K58PzO60VOgqEQMhHSqL8=; b=MH/9fvLuLiCmK3TCRy5GBYD21FgGZ7p7LqvLbQ3Yl77Xn0kG0gq7CnfO SstyrKwp+vnq+GlMs9SyRp0grkLvpSLzK/xNOVFz5IZyCv9KSZA9JlvFz gRlby9/r2uFFqZ+SWPRXiopQCZBn1003mhBvlYvzqoYeEZ19V4aei1hPP rOwdRHODGZ0jbi88e4hLVWtIy5N0RWFFeicseKvWZkkMUwdgssVJ4bP9o v+JyeJ4G2f9x8AN7pFrF+n8NIIbaPlufFus4EiE57lGllfgWsRNYcE9LM pTtzsiywoBeOKzCW2TOj+vhyWRdB6rQtZXIBQ2k5zEL1d8cBC94g3vMla w==; X-CSE-ConnectionGUID: Uuu0wmeZSh+nyKZYnIQgrw== X-CSE-MsgGUID: RXZeY2NSRvqY/Ug5UU05KA== X-IronPort-AV: E=McAfee;i="6800,10657,11633"; a="67026567" X-IronPort-AV: E=Sophos;i="6.20,252,1758610800"; d="scan'208";a="67026567" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Dec 2025 07:55:00 -0800 X-CSE-ConnectionGUID: BqtaMaLZQpyj7r1/3EtHQg== X-CSE-MsgGUID: i/TBMqhORDG8PUBOXn4nHA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.20,252,1758610800"; d="scan'208";a="226324432" Received: from psoham-nuc7i7bnh.iind.intel.com ([10.190.216.151]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Dec 2025 07:54:57 -0800 From: Soham Purkait To: igt-dev@lists.freedesktop.org, riana.tauro@intel.com, badal.nilawar@intel.com Cc: anshuman.gupta@intel.com, soham.purkait@intel.com, umesh.nerlige.ramappa@intel.com, kamil.konieczny@intel.com Subject: [PATCH i-g-t v2 1/3] lib/xe/xe_spin: Introduce xe_spin_reset Date: Fri, 5 Dec 2025 21:14:15 +0530 Message-Id: <20251205154417.3963533-2-soham.purkait@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251205154417.3963533-1-soham.purkait@intel.com> References: <20251205154417.3963533-1-soham.purkait@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: igt-dev@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development mailing list for IGT GPU Tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: igt-dev-bounces@lists.freedesktop.org Sender: "igt-dev" Create new function xe_spin_reset() This function resets the state of spin, allowing its reuse for engine activity accuracy test. v1: - Add simple commit message and mention test where it is going to be used. (kamil) v2: - Add fd description for xe_spin_reset. (Kamil) Signed-off-by: Soham Purkait --- lib/xe/xe_spin.c | 29 +++++++++++++++++++++++++++++ lib/xe/xe_spin.h | 1 + 2 files changed, 30 insertions(+) diff --git a/lib/xe/xe_spin.c b/lib/xe/xe_spin.c index 72b13ef42..f3866cca1 100644 --- a/lib/xe/xe_spin.c +++ b/lib/xe/xe_spin.c @@ -179,6 +179,35 @@ void xe_spin_init(struct xe_spin *spin, struct xe_spin_opts *opts) igt_assert(b <= ARRAY_SIZE(spin->batch)); } +/** + * xe_spin_reset: + * @fd: xe device file descriptor + * @spin: spin state from xe_spin_new() + * + * Reset the state of spin, allowing its reuse. + */ +void xe_spin_reset(int fd, igt_spin_t *spin) +{ + struct drm_xe_sync sync = { + .type = DRM_XE_SYNC_TYPE_SYNCOBJ, + .flags = DRM_XE_SYNC_FLAG_SIGNAL, + .handle = spin->syncobj, + }; + struct drm_xe_exec exec = { + .num_batch_buffer = 1, + .num_syncs = 1, + .syncs = to_user_pointer(&sync), + .exec_queue_id = spin->engine, + .address = spin->address, + }; + + xe_spin_init_opts((struct xe_spin *)spin->xe_spin, + .addr = spin->address, + .preempt = !(spin->opts.flags & IGT_SPIN_NO_PREEMPTION)); + igt_assert_eq(igt_ioctl(fd, DRM_IOCTL_XE_EXEC, &exec), 0); + xe_spin_wait_started((struct xe_spin *)spin->xe_spin); +} + /** * xe_spin_started: * @spin: pointer to spinner mapped bo diff --git a/lib/xe/xe_spin.h b/lib/xe/xe_spin.h index c2199d0aa..af32ab563 100644 --- a/lib/xe/xe_spin.h +++ b/lib/xe/xe_spin.h @@ -73,6 +73,7 @@ uint32_t xe_spin_nsec_to_ticks(int fd, int gt_id, uint64_t nsec); void xe_spin_init(struct xe_spin *spin, struct xe_spin_opts *opts); #define xe_spin_init_opts(fd, ...) \ xe_spin_init(fd, &((struct xe_spin_opts){__VA_ARGS__})) +void xe_spin_reset(int fd, igt_spin_t *spin); bool xe_spin_started(struct xe_spin *spin); void xe_spin_wait_started(struct xe_spin *spin); void xe_spin_end(struct xe_spin *spin); -- 2.34.1