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 C40EAC3DA7F for ; Thu, 15 Aug 2024 20:47:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8C60910E54E; Thu, 15 Aug 2024 20:47:04 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="CmR+k+Vs"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1C25010E54E for ; Thu, 15 Aug 2024 20:47:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1723754823; x=1755290823; h=date:message-id:from:to:cc:subject:in-reply-to: references:mime-version:content-transfer-encoding; bh=H18LteWG9GwcaMwbFmHZlFG+SMMdzDTX7XInkRxCD2E=; b=CmR+k+VsmME/h5x029NH5BUwkCCQfE53Y4QNxQGOd+5YNme2pJM2u9A/ QBjPBJt2mSqqLlOOivva6k1CHA+dFRcLsDzXoU9PMLz+tMPZQ2gOGdZVQ PBz7Whc4v0Ml/NTURfJaMvKksONMVriAztHXG+T3D+rdX9L77lKwIGsqx y5GNvTQvXMdlhfRwBsR8Y7mO3NjQr1SXeE8/WjkjfbPzHLUAuPuy5V6U+ LjJh98R4uhFhxjoSLSQSnlB5Hg4i+tabSxcxNCQcxPjDmESZo9tEjqnEm 5TAQw9yYYmWPX+bJA0FMH4YdzbD+UhlA/1LHyj2normvL1F3oQacgBKzT w==; X-CSE-ConnectionGUID: tfYK4ROBQ8GNxey+yJRTXA== X-CSE-MsgGUID: 1IVo2OUETDeVN6PUutdk8A== X-IronPort-AV: E=McAfee;i="6700,10204,11165"; a="13038932" X-IronPort-AV: E=Sophos;i="6.10,149,1719903600"; d="scan'208";a="13038932" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Aug 2024 13:47:03 -0700 X-CSE-ConnectionGUID: KEojKtlOSHiQHyXEh2COGg== X-CSE-MsgGUID: DPBPSTo2TxW08hzkDDAF9Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,149,1719903600"; d="scan'208";a="59103397" Received: from ticede-or-134.amr.corp.intel.com (HELO adixit-arch.intel.com) ([10.124.51.80]) by fmviesa006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Aug 2024 13:47:02 -0700 Date: Thu, 15 Aug 2024 13:40:22 -0700 Message-ID: <875xs1eczt.wl-ashutosh.dixit@intel.com> From: "Dixit, Ashutosh" To: Lucas De Marchi Cc: =?ISO-8859-1?Q?Jos=E9?= Roberto de Souza , Subject: Re: [PATCH 3/3] drm/xe/oa: Destroy dangling oa streams when xe_file is removed In-Reply-To: References: <20240815162758.36495-1-jose.souza@intel.com> <20240815162758.36495-3-jose.souza@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/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=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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, 15 Aug 2024 11:17:05 -0700, Lucas De Marchi wrote: > Hi Jose, > On Thu, Aug 15, 2024 at 09:27:58AM GMT, Jose Souza wrote: > > If an application opens an oa stream and for whatever reason it don't > > close the stream the oa unit associeted with it will never be release, > > so no other application can use it. > > The only workaround was to unload the driver or reboot. The premise of this patch and the need for it seems misplaced. How are you reproducing this? OA stream open returns a fd. Whether or not the process closes the stream, fd will get closed on process exit, which triggers the the release method (xe_oa_release(), specified in xe_oa_fops), which does the cleanup and makes the OA unit available again. I just verified this works without closing the OA stream or reloading the module. > > So here adding a list of oa stream and and when a xe_file is closed > > it will also destroy all oa stream with the same xe_file. We will also need to explain why something like this was never needed in i915, since this mechanism is the same between i915 and xe. > > > > Signed-off-by: Jos=E9 Roberto de Souza > > --- > > drivers/gpu/drm/xe/xe_device.c | 2 ++ > > drivers/gpu/drm/xe/xe_oa.c | 28 +++++++++++++++++++++++++++- > > drivers/gpu/drm/xe/xe_oa.h | 1 + > > drivers/gpu/drm/xe/xe_oa_types.h | 8 ++++++++ > > 4 files changed, 38 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_dev= ice.c > > index 2063283871503..b098685ed3636 100644 > > --- a/drivers/gpu/drm/xe/xe_device.c > > +++ b/drivers/gpu/drm/xe/xe_device.c > > @@ -158,6 +158,8 @@ static void xe_file_close(struct drm_device *dev, s= truct drm_file *file) > > > > xe_pm_runtime_get(xe); > > > > + xe_oa_file_destroy_stream(xef); > > I'm not sure about this impl giving xef for oa to delete from a list, > will leave the to Ashutosh. Comment below about a mistake though > > > static int xe_oa_alloc_oa_buffer(struct xe_oa_stream *stream) > > @@ -1480,11 +1484,15 @@ static int xe_oa_stream_open_ioctl_locked(struc= t xe_oa *oa, > > goto exit; > > } > > > > + stream->xef =3D param->xef; > > if you keep a pointer to xef, you need to get a ref. Use > xe_file_get()/xe_file_put(). Done here: https://patchwork.freedesktop.org/patch/607603/?series=3D137058&rev=3D1 Thanks. -- Ashutosh