From mboxrd@z Thu Jan 1 00:00:00 1970 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 CF8CCC5B543 for ; Wed, 4 Jun 2025 23:53:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 80DEC10E7D4; Wed, 4 Jun 2025 23:53:16 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="kyma+Wkm"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) by gabe.freedesktop.org (Postfix) with ESMTPS id EE48910E222 for ; Wed, 4 Jun 2025 23:53:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1749081195; x=1780617195; h=date:message-id:from:to:cc:subject:in-reply-to: references:mime-version; bh=jpHDnAQy70GSw7Rwv6BnBVD30A848id3WG+gOS5yB3E=; b=kyma+Wkml49u2y24F5g3mSFDENKN8HIZAbQXIbV64MPRTVG2H7Zpp1XM DsyVhKYtqblmHTE60ugSLKYQkEB19UoJUZHc0s2mbnBRrgRur6USpo3an M8sS6r9qkdZwCKA6wowADsO+6quizxzaATlJxkiL2yg8Jp//lrQ3hzHt1 R4tO6RQagtOzsKAOqJMTm38YrPQRIfR8SjcZ5lzu7IffD91KBLLGocmfK epbYrwpVK45YKTq6a8i0KOCQxTOc9XNmO4Tq8V+ncSA40hucwpzXgr3oy PhOak0JAFXIXGE4plDovgbhDCilFbudqQvXcUGEt3yLbxrgFt7Q5khngs g==; X-CSE-ConnectionGUID: OhEV8LYPSnKmr4txjxKPEA== X-CSE-MsgGUID: zF8kh9QYR1mHH4pCriBTtA== X-IronPort-AV: E=McAfee;i="6800,10657,11454"; a="53815313" X-IronPort-AV: E=Sophos;i="6.16,210,1744095600"; d="scan'208";a="53815313" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jun 2025 16:53:14 -0700 X-CSE-ConnectionGUID: GBCnr72zRHWDRNDh+Hisbw== X-CSE-MsgGUID: RJnfiuo4SSG7O2IsdR0VuA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,210,1744095600"; d="scan'208";a="145290583" Received: from adixit-mobl3.clients.intel.com (HELO adixit-MOBL3.intel.com) ([10.24.12.163]) by orviesa010-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jun 2025 16:53:15 -0700 Date: Wed, 04 Jun 2025 16:53:14 -0700 Message-ID: <874iwvukr9.wl-ashutosh.dixit@intel.com> From: "Dixit, Ashutosh" To: Harish Chegondi Cc: Subject: Re: [PATCH i-g-t 1/3] tests/intel/xe_eu_stall: Close any open EU stall fd before opening a new one In-Reply-To: References: User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/29.4 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII 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" On Tue, 03 Jun 2025 16:57:34 -0700, Harish Chegondi wrote: > > asserts in a sub-test can prevent closing an EU stall fd and the next > subtest may fail with EBUSY if it tries to open another EU stall fd > as there can only be one EU stall stream open at a time. Any open fds > are automatically closed at the end of a test (last sub-test). > > Cc: Ashutosh Dixit > Signed-off-by: Harish Chegondi So -EBUSY errors are gone with this patch, correct? So this is: Reviewed-by: Ashutosh Dixit > --- > tests/intel/xe_eu_stall.c | 34 ++++++++++++++++++++++++++-------- > 1 file changed, 26 insertions(+), 8 deletions(-) > > diff --git a/tests/intel/xe_eu_stall.c b/tests/intel/xe_eu_stall.c > index 411c30871..1499ec4b4 100644 > --- a/tests/intel/xe_eu_stall.c > +++ b/tests/intel/xe_eu_stall.c > @@ -69,6 +69,7 @@ static uint8_t p_gt_id; > static uint32_t p_rate; > static uint32_t p_user = DEFAULT_USER_BUF_SIZE; > static uint32_t p_num_reports = DEFAULT_NUM_REPORTS; > +static int stream_fd = -1; > > static volatile bool child_is_running = true; > > @@ -302,6 +303,25 @@ static void set_fd_flags(int fd, int flags) > igt_assert_eq(0, fcntl(fd, F_SETFL, old | flags)); > } > > +static void eu_stall_close(int fd) > +{ > + close(fd); > + stream_fd = -1; > +} > + > +static int eu_stall_open(int drm_fd, struct xe_eu_stall_open_prop *props) > +{ > + int ret; > + > + if (stream_fd >= 0) > + eu_stall_close(stream_fd); > + > + ret = xe_eu_stall_ioctl(drm_fd, DRM_XE_OBSERVATION_OP_STREAM_OPEN, props); > + igt_require_fd(ret); > + > + return ret; > +} > + > /* > * Verify that tests with invalid arguments fail. > */ > @@ -353,7 +373,7 @@ static inline void disable_paranoid(void) > */ > static void test_non_privileged_access(int drm_fd) > { > - int paranoid, stream_fd; > + int paranoid; > > paranoid = read_u64_file(OBSERVATION_PARANOID); > > @@ -395,9 +415,8 @@ static void test_non_privileged_access(int drm_fd) > > igt_drop_root(); > > - stream_fd = xe_eu_stall_ioctl(drm_fd, DRM_XE_OBSERVATION_OP_STREAM_OPEN, &props); > - igt_require_fd(stream_fd); > - close(stream_fd); > + stream_fd = eu_stall_open(drm_fd, &props); > + eu_stall_close(stream_fd); > } > > igt_waitchildren(); > @@ -472,7 +491,7 @@ static void test_eustall(int drm_fd, uint32_t devid, bool blocking_read, int ite > uint32_t num_samples, num_drops; > struct igt_helper_process work_load = {}; > struct sigaction sa = { 0 }; > - int ret, flags, stream_fd; > + int ret, flags; > uint64_t total_size; > uint8_t *buf; > > @@ -518,8 +537,7 @@ static void test_eustall(int drm_fd, uint32_t devid, bool blocking_read, int ite > properties[3] = query_eu_stall_data->sampling_rates[0]; > igt_info("Sampling Rate: %lu\n", properties[3]); > > - stream_fd = xe_eu_stall_ioctl(drm_fd, DRM_XE_OBSERVATION_OP_STREAM_OPEN, &props); > - igt_require_fd(stream_fd); > + stream_fd = eu_stall_open(drm_fd, &props); > > if (!blocking_read) > flags = O_CLOEXEC | O_NONBLOCK; > @@ -592,7 +610,7 @@ enable: > if (--iter) > goto enable; > > - close(stream_fd); > + eu_stall_close(stream_fd); > free(buf); > } > > -- > 2.48.1 >