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 27D8AC4345F for ; Wed, 24 Apr 2024 23:26:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D97C610FB57; Wed, 24 Apr 2024 23:26:46 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="iHoujt6b"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8E87210FB57 for ; Wed, 24 Apr 2024 23:26:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1714001206; x=1745537206; h=date:message-id:from:to:cc:subject:in-reply-to: references:mime-version; bh=Rl7i4Ge+hdfDwaMbOZJXic9mvJ5jfS2I2L2gALGxOqk=; b=iHoujt6baj6QCwLDyvkOOmHtM05DZ9+UnbWMjAgIm6uYUOK/cZQZdwF2 Kv93U3WocLCPUw/NPid8Hell4MYjZhuamwTkjrw8aNGRt/gIbszXyyLBY fkxLPVd5ix3kTIHik7+uU9KN7xWg5QZxQq59VPTWg71LKfEawV6fVt0CW ToOQiGr68BvSB2teEeQiMGRMx96CWTbG2RLuiiwl0TDGn75QCemW9RPMl mXkHl+ksxUSXEytPNdF0yGQ4SFRtxuO/u9oDExnaL+osz3GjoZ7Ro31iq owWb8+hBj3uOKKEZx4Hljcvi4sqMmFRxzE7w03b2qLqtQKmAzS0l6p8v6 w==; X-CSE-ConnectionGUID: ACtLZjRKTXCkRdyzl9XQVw== X-CSE-MsgGUID: FHex259iTZSChdCulhU0WA== X-IronPort-AV: E=McAfee;i="6600,9927,11054"; a="21072068" X-IronPort-AV: E=Sophos;i="6.07,227,1708416000"; d="scan'208";a="21072068" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Apr 2024 16:26:45 -0700 X-CSE-ConnectionGUID: j3t4gjWeRTWml6ijQ1pivA== X-CSE-MsgGUID: wXD20a/bR5KEfKaKOdS84w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,227,1708416000"; d="scan'208";a="29517816" Received: from orsosgc001.jf.intel.com (HELO orsosgc001.intel.com) ([10.165.21.138]) by fmviesa004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Apr 2024 16:26:44 -0700 Date: Wed, 24 Apr 2024 16:26:44 -0700 Message-ID: <851q6umjez.wl-ashutosh.dixit@intel.com> From: "Dixit, Ashutosh" To: intel-xe@lists.freedesktop.org Cc: Umesh Nerlige Ramappa , Lucas De Marchi Subject: Re: [PATCH 12/17] drm/xe/oa/uapi: Query OA unit properties In-Reply-To: <20240315013518.2848986-13-ashutosh.dixit@intel.com> References: <20240315013518.2848986-1-ashutosh.dixit@intel.com> <20240315013518.2848986-13-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/28.2 (x86_64-redhat-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: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-xe-bounces@lists.freedesktop.org Sender: "Intel-xe" On Thu, 14 Mar 2024 18:35:13 -0700, Ashutosh Dixit wrote: > > diff --git a/include/uapi/drm/xe_drm.h b/include/uapi/drm/xe_drm.h > index 4bfa06ebf6da..54d0912f2ba8 100644 > > +/** > + * struct drm_xe_oa_unit - describe OA unit > + */ > +struct drm_xe_oa_unit { > + /** @extensions: Pointer to the first extension struct, if any */ > + __u64 extensions; > + > + /** @oa_unit_id: OA unit ID */ > + __u32 oa_unit_id; > + > + /** @oa_unit_type: OA unit type of @drm_xe_oa_unit_type */ > + __u32 oa_unit_type; > + > + /** @capabilities: OA capabilities bit-mask */ > + __u64 capabilities; > +#define DRM_XE_OA_CAPS_BASE (1 << 0) > + > + /** @oa_timestamp_freq: OA timestamp freq */ > + __u64 oa_timestamp_freq; > + > + /** @reserved: MBZ */ > + __u64 reserved[4]; > + > + /** @num_engines: number of engines in @eci array */ > + __u64 num_engines; > + > + /** @eci: engines attached to this OA unit */ > + struct drm_xe_engine_class_instance eci[]; > +}; > + > +/** > + * struct drm_xe_query_oa_units - describe OA units > + * > + * If a query is made with a struct drm_xe_device_query where .query > + * is equal to DRM_XE_DEVICE_QUERY_OA_UNITS, then the reply uses struct > + * drm_xe_query_oa_units in .data. > + * > + * OA unit properties for all OA units can be accessed using a code block > + * such as the one below: > + * > + * .. code-block:: C > + * > + * struct drm_xe_query_oa_units *qoa; > + * struct drm_xe_oa_unit *oau; > + * u8 *poau; > + * > + * // malloc qoa and issue DRM_XE_DEVICE_QUERY_OA_UNITS. Then: > + * poau = (u8 *)&qoa->oa_units[0]; > + * for (int i = 0; i < qoa->num_oa_units; i++) { > + * oau = (struct drm_xe_oa_unit *)poau; > + * // Access 'struct drm_xe_oa_unit' fields here > + * poau += sizeof(*oau) + oau->num_engines * sizeof(oau->eci[0]); > + * } > + */ > +struct drm_xe_query_oa_units { > + /** @extensions: Pointer to the first extension struct, if any */ > + __u64 extensions; > + /** @num_oa_units: number of OA units returned in oau[] */ > + __u32 num_oa_units; > + /** @pad: MBZ */ > + __u32 pad; > + /** @oa_units: OA units returned for this device */ > + struct drm_xe_oa_unit oa_units[]; > +}; It has been pointed out that the doubly nested flexible arrays used here break compilation on Windows due to this MSVC issue: https://learn.microsoft.com/en-us/cpp/error-messages/compiler-errors-1/compiler-error-c2233?view=msvc-170 Umesh had previously already pointed this out here: https://patchwork.freedesktop.org/patch/571290/?series=121084&rev=7#comment_1048210 In any case, this is considered unacceptabe and needs to change. Current options: a. Include a "next" pointer in 'struct drm_xe_oa_unit' (suggested by Lucas). This works except people not familiar with the MSVC issue might wonder why it is not simply an array, or why we are using a linked list construct for something which is actually an array. b. I am thinking another option may be to just do this: diff --git a/include/uapi/drm/xe_drm.h b/include/uapi/drm/xe_drm.h index 03c559af2027..6c864dc1b65f 100644 --- a/include/uapi/drm/xe_drm.h +++ b/include/uapi/drm/xe_drm.h @@ -1506,8 +1506,8 @@ struct drm_xe_query_oa_units { __u32 num_oa_units; /** @pad: MBZ */ __u32 pad; - /** @oa_units: OA units returned for this device */ - struct drm_xe_oa_unit oa_units[]; + /** @oa_units: struct drm_xe_oa_unit array returned for this device */ + __u8 oa_units[]; }; Though the next pointer has the advantage of it being simpler to reach the nth element of the array. So I am still trying to figure out the least hacky way to change this. If you have any suggestions/opinion about this please respond. Thanks. -- Ashutosh