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 5E2FDC02196 for ; Fri, 7 Feb 2025 21:25:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0680E10E02F; Fri, 7 Feb 2025 21:25:09 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="Koo3GEW/"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0E16310E02F for ; Fri, 7 Feb 2025 21:22:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1738963373; x=1770499373; h=date:message-id:from:to:cc:subject:in-reply-to: references:mime-version; bh=epvTLOH/sIO/2I3tSLgPDbWZSrwS4lhAF9kvSMuWOBo=; b=Koo3GEW/bK6OHeQggy1+kMl6TLH2J38qo+p6aVg2GUXfUMJ796STOdfs 2U9zhpuy9ZGomhz1/0SlIePdGLsAYWs03TdQLgF/9Msp5/bjJOkTFdwCk FKNMD5qZd0alNQrtW7ZpuXU+k7Z8d8eWSSwCzdUM7YDdvno1cugznTWmg 07nOzuqKwlyK6pX+BTk+y1YvImrOiFctvo92vofzoB8pSvAyWHN5As30R WHQWS6NsP+B4yHInPCzD8/tj0SCqJFr0eivZ49RLcPlF+KfPGu0KZrp/t 6pZPyepJY+6HsVRrvCI9JhoZliScrkk2YmCSdc7y26KpVESDbmAeEWvhH Q==; X-CSE-ConnectionGUID: YwC/Oq5gRdq3JfvwAOyVbg== X-CSE-MsgGUID: vof+ur2RTm+0XxMJi+pqnQ== X-IronPort-AV: E=McAfee;i="6700,10204,11338"; a="39524370" X-IronPort-AV: E=Sophos;i="6.13,268,1732608000"; d="scan'208";a="39524370" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Feb 2025 13:22:53 -0800 X-CSE-ConnectionGUID: NLlD3wMlTtKmxDefjznnkQ== X-CSE-MsgGUID: DWLwBTFkSZGxIbVBfzjJsQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,224,1728975600"; d="scan'208";a="148837514" Received: from orsosgc001.jf.intel.com (HELO orsosgc001.intel.com) ([10.165.21.142]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Feb 2025 13:22:54 -0800 Date: Fri, 07 Feb 2025 13:22:54 -0800 Message-ID: <855xlllaa9.wl-ashutosh.dixit@intel.com> From: "Dixit, Ashutosh" To: Lucas De Marchi Cc: , Rodrigo Vivi , Francois Dugast Subject: Re: [PATCH v2 09/14] drm/xe: Move oa fini to xe_oa In-Reply-To: <20250206232333.2660325-10-lucas.demarchi@intel.com> References: <20250206232333.2660325-1-lucas.demarchi@intel.com> <20250206232333.2660325-10-lucas.demarchi@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, 06 Feb 2025 15:23:27 -0800, Lucas De Marchi wrote: > > Like done with other functions, cleanup the error handling in > xe_device_probe() by moving the OA fini to be handled by xe_oa. Maybe just mention devm cleanup here in the commit message as the reason for this patch. Otherwise, lgtm: Reviewed-by: Ashutosh Dixit > Cc: Ashutosh Dixit > Signed-off-by: Lucas De Marchi > --- > drivers/gpu/drm/xe/xe_device.c | 7 +---- > drivers/gpu/drm/xe/xe_oa.c | 48 +++++++++++++++++----------------- > drivers/gpu/drm/xe/xe_oa.h | 1 - > 3 files changed, 25 insertions(+), 31 deletions(-) > > diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c > index 09288558e4e44..944a40a1e0174 100644 > --- a/drivers/gpu/drm/xe/xe_device.c > +++ b/drivers/gpu/drm/xe/xe_device.c > @@ -867,7 +867,7 @@ int xe_device_probe(struct xe_device *xe) > > err = xe_display_init(xe); > if (err) > - goto err_fini_oa; > + return err; > > err = xe_pxp_init(xe); > if (err) > @@ -899,9 +899,6 @@ int xe_device_probe(struct xe_device *xe) > err_fini_display: > xe_display_driver_remove(xe); > > -err_fini_oa: > - xe_oa_fini(xe); > - > return err; > } > > @@ -971,8 +968,6 @@ void xe_device_remove(struct xe_device *xe) > > xe_device_remove_display(xe); > > - xe_oa_fini(xe); > - > xe_heci_gsc_fini(xe); > > xe_device_call_remove_actions(xe); > diff --git a/drivers/gpu/drm/xe/xe_oa.c b/drivers/gpu/drm/xe/xe_oa.c > index fa873f3d0a9d1..2c640185bdeca 100644 > --- a/drivers/gpu/drm/xe/xe_oa.c > +++ b/drivers/gpu/drm/xe/xe_oa.c > @@ -2641,6 +2641,27 @@ static void xe_oa_init_supported_formats(struct xe_oa *oa) > } > } > > +static int destroy_config(int id, void *p, void *data) > +{ > + xe_oa_config_put(p); > + > + return 0; > +} > + > +static void xe_oa_fini(void *arg) > +{ > + struct xe_device *xe = arg; > + struct xe_oa *oa = &xe->oa; > + > + if (!oa->xe) > + return; > + > + idr_for_each(&oa->metrics_idr, destroy_config, oa); > + idr_destroy(&oa->metrics_idr); > + > + oa->xe = NULL; > +} > + > /** > * xe_oa_init - OA initialization during device probe > * @xe: @xe_device > @@ -2672,31 +2693,10 @@ int xe_oa_init(struct xe_device *xe) > } > > xe_oa_init_supported_formats(oa); > - return 0; > -exit: > - oa->xe = NULL; > - return ret; > -} > > -static int destroy_config(int id, void *p, void *data) > -{ > - xe_oa_config_put(p); > - return 0; > -} > - > -/** > - * xe_oa_fini - OA de-initialization during device remove > - * @xe: @xe_device > - */ > -void xe_oa_fini(struct xe_device *xe) > -{ > - struct xe_oa *oa = &xe->oa; > - > - if (!oa->xe) > - return; > - > - idr_for_each(&oa->metrics_idr, destroy_config, oa); > - idr_destroy(&oa->metrics_idr); > + return devm_add_action_or_reset(xe->drm.dev, xe_oa_fini, xe); > > +exit: > oa->xe = NULL; > + return ret; > } > diff --git a/drivers/gpu/drm/xe/xe_oa.h b/drivers/gpu/drm/xe/xe_oa.h > index 87a38820c317d..eb36ce250c615 100644 > --- a/drivers/gpu/drm/xe/xe_oa.h > +++ b/drivers/gpu/drm/xe/xe_oa.h > @@ -15,7 +15,6 @@ struct xe_gt; > struct xe_hw_engine; > > int xe_oa_init(struct xe_device *xe); > -void xe_oa_fini(struct xe_device *xe); > void xe_oa_register(struct xe_device *xe); > void xe_oa_unregister(struct xe_device *xe); > int xe_oa_stream_open_ioctl(struct drm_device *dev, u64 data, struct drm_file *file); > -- > 2.48.1 >