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 1C2ABCAC5BB for ; Wed, 8 Oct 2025 23:19:35 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C361C10E104; Wed, 8 Oct 2025 23:19:34 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="jIqOZaWi"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4620110E104 for ; Wed, 8 Oct 2025 23:19:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1759965574; x=1791501574; h=date:message-id:from:to:cc:subject:in-reply-to: references:mime-version; bh=OQ0Qz2jrwiMOu0Ufucl4MDLha8VP8Kh01HdM6sNn08k=; b=jIqOZaWiJ/qmjol6JdUHuQQ4XqoC7M31Flf996eIEX/9Ha282Bw61Mht /cLXpdKO6SwXsiQ6zEk1NOC12gAJVSAimBqeVQRGHFbVxY8P1lam8cO7P DnDjg0b6gJlq3BtGLVHCP8JDI1/1CCdgRF7W6zXw6vsH+4oXcWnPOhxww hXX3VnIF0pJxJeqsjkwjMwBEzK5guIQILUWVSzfxcZwjulHkn2X1IvGX3 bQL/mnF1OnwE8p7GPXnxx9DSJOFZWpmhhm5gKk1Eniwoed8A7+4cZKwBU tgSHgVxQOm2xoldrrXMe3QjZSh9+oyKx2VgeZWTa2a3cJgIwb0h5HGOQJ Q==; X-CSE-ConnectionGUID: /HKVvcuUTGi01g7ZmpzdjQ== X-CSE-MsgGUID: mBVfQ9/PS4erDdcP8xnHDQ== X-IronPort-AV: E=McAfee;i="6800,10657,11576"; a="87630054" X-IronPort-AV: E=Sophos;i="6.19,214,1754982000"; d="scan'208";a="87630054" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Oct 2025 16:19:33 -0700 X-CSE-ConnectionGUID: C648RHfOQMqy8Sm54CGE0g== X-CSE-MsgGUID: EJR36S+wTeSk7bcyljyDFQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.19,214,1754982000"; d="scan'208";a="185859977" Received: from unknown (HELO adixit-MOBL3.intel.com) ([10.241.243.136]) by fmviesa004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Oct 2025 16:19:32 -0700 Date: Wed, 08 Oct 2025 16:19:31 -0700 Message-ID: <87h5w9dlrw.wl-ashutosh.dixit@intel.com> From: "Dixit, Ashutosh" To: Umesh Nerlige Ramappa Cc: Subject: Re: [PATCH i-g-t 04/18] tests/intel/xe_oa: Change oa_unit_engine to take an oa_unit argument In-Reply-To: References: <20251008211806.625154-1-ashutosh.dixit@intel.com> <20251008211806.625154-5-ashutosh.dixit@intel.com> 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/30.2 (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 Wed, 08 Oct 2025 15:40:38 -0700, Umesh Nerlige Ramappa wrote: > > On Wed, Oct 08, 2025 at 02:17:51PM -0700, Ashutosh Dixit wrote: > > To prevent code duplication with oa_unit_by_id(), pass 'struct > > drm_xe_oa_unit *' as argument to oa_unit_engine(). > > > > Signed-off-by: Ashutosh Dixit > > --- > > tests/intel/xe_oa.c | 32 ++++++++------------------------ > > 1 file changed, 8 insertions(+), 24 deletions(-) > > > > diff --git a/tests/intel/xe_oa.c b/tests/intel/xe_oa.c > > index 65e03b1010..c7de1d081d 100644 > > --- a/tests/intel/xe_oa.c > > +++ b/tests/intel/xe_oa.c > > @@ -472,25 +472,9 @@ static u64 oa_format_fields(u64 name) > > } > > #define __ff oa_format_fields > > > > -static struct drm_xe_engine_class_instance *oa_unit_engine(int fd, int n) > > +static struct drm_xe_engine_class_instance *oa_unit_engine(struct drm_xe_oa_unit *oau) > > { > > - struct drm_xe_query_oa_units *qoa = xe_oa_units(fd); > > - struct drm_xe_engine_class_instance *hwe = NULL; > > - struct drm_xe_oa_unit *oau; > > - u8 *poau; > > - > > - poau = (u8 *)&qoa->oa_units[0]; > > - for (int i = 0; i < qoa->num_oa_units; i++) { > > - oau = (struct drm_xe_oa_unit *)poau; > > - > > - if (i == n) { > > - hwe = oau->num_engines ? &oau->eci[random() % oau->num_engines] : NULL; > > - break; > > - } > > - poau += sizeof(*oau) + oau->num_engines * sizeof(oau->eci[0]); > > - } > > - > > - return hwe; > > + return !oau ? NULL : oau->num_engines ? &oau->eci[random() % oau->num_engines] : NULL; > > Since this can now return NULL hwe, test_oa_unit_exclusive_stream() and > test_oa_unit_concurrent_oa_buffer_read() should check if the hwe is NULL > and account for that. For test_oa_unit_exclusive_stream() this is done in the patch 16/18 ("tests/intel/xe_oa: Run test_oa_unit_exclusive_stream on multiple OA units"). For test_oa_unit_concurrent_oa_buffer_read(), hwe is eliminated in Patch 10/18 ("tests/intel/xe_oa: Convert blocking/polling tests to take OA unit arguments"). So looks ok to me I think. Thanks. > > Umesh > > > } > > > > static struct drm_xe_oa_unit *oa_unit_by_id(int fd, int n) > > @@ -4263,7 +4247,7 @@ test_oa_unit_exclusive_stream(bool exponent) > > > > /* for each oa unit, open one random perf stream with sample OA */ > > for (i = 0; i < qoa->num_oa_units; i++) { > > - struct drm_xe_engine_class_instance *hwe = oa_unit_engine(drm_fd, i); > > + struct drm_xe_engine_class_instance *hwe = oa_unit_engine(oa_unit_by_id(drm_fd, i)); > > > > oau = (struct drm_xe_oa_unit *)poau; > > if (oau->oa_unit_type != DRM_XE_OA_UNIT_TYPE_OAG) > > @@ -4295,7 +4279,7 @@ test_oa_unit_exclusive_stream(bool exponent) > > /* for each oa unit make sure no other streams can be opened */ > > poau = (u8 *)&qoa->oa_units[0]; > > for (i = 0; i < qoa->num_oa_units; i++) { > > - struct drm_xe_engine_class_instance *hwe = oa_unit_engine(drm_fd, i); > > + struct drm_xe_engine_class_instance *hwe = oa_unit_engine(oa_unit_by_id(drm_fd, i)); > > int err; > > > > oau = (struct drm_xe_oa_unit *)poau; > > @@ -4345,7 +4329,7 @@ test_oa_unit_concurrent_oa_buffer_read(void) > > struct drm_xe_query_oa_units *qoa = xe_oa_units(drm_fd); > > > > igt_fork(child, qoa->num_oa_units) { > > - struct drm_xe_engine_class_instance *hwe = oa_unit_engine(drm_fd, child); > > + struct drm_xe_engine_class_instance *hwe = oa_unit_engine(oa_unit_by_id(drm_fd, child)); > > > > /* No OAM support yet */ > > if (oa_unit_by_id(drm_fd, child)->oa_unit_type != DRM_XE_OA_UNIT_TYPE_OAG) > > @@ -4924,18 +4908,18 @@ static const char *xe_engine_class_name(uint32_t engine_class) > > > > #define __for_one_hwe_in_each_oa_unit(hwe) \ > > for (int m = 0; !m || hwe; m++) \ > > - for_each_if(hwe = oa_unit_engine(drm_fd, m)) \ > > + for_each_if(hwe = oa_unit_engine(oa_unit_by_id(drm_fd, m))) \ > > igt_dynamic_f("%s-%d", xe_engine_class_name(hwe->engine_class), \ > > hwe->engine_instance) > > > > /* Only OAG (not OAM) is currently supported */ > > #define __for_one_hwe_in_oag(hwe) \ > > - if ((hwe = oa_unit_engine(drm_fd, 0))) \ > > + if ((hwe = oa_unit_engine(oa_unit_by_id(drm_fd, 0)))) \ > > igt_dynamic_f("%s-%d", xe_engine_class_name(hwe->engine_class), \ > > hwe->engine_instance) > > > > #define __for_one_hwe_in_oag_w_arg(hwe, str) \ > > - if ((hwe = oa_unit_engine(drm_fd, 0))) \ > > + if ((hwe = oa_unit_engine(oa_unit_by_id(drm_fd, 0)))) \ > > igt_dynamic_f("%s-%d-%s", xe_engine_class_name(hwe->engine_class), \ > > hwe->engine_instance, str) > > > > -- > > 2.48.1 > >