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 EEEC4C0219E for ; Fri, 7 Feb 2025 21:38:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9DC3810E143; Fri, 7 Feb 2025 21:38:22 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="Dz0Q7nkT"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4180F10E143 for ; Fri, 7 Feb 2025 21:38:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1738964300; x=1770500300; h=date:message-id:from:to:cc:subject:in-reply-to: references:mime-version; bh=XKFPGyNSTv/xkBXYBHuOjl+1OU/iDHMichOV5ozeCas=; b=Dz0Q7nkTALz1DwNgMe822lhcT1oW1KU4OLTwwOAP5QIpuQCZ4vzR3Nqw kjgL1MnLGBIzvuTCeGOaCi2OH6zF77ug1qU14eOXcbStC4gdD91T1xyAu 3QpB5X6cuU2G9o+znOw+l2iOz01ppY1ClEcbE7KIKALfQZRw5KSNzvJwu 23LFWNQj3txkeTQdT24fyyAFMXcdN4up34SOVqlny5EaHhlaiz5O1yaUP 8GzZHg1eCm37oQ3MEstNYRkKRhxNt7d7jtFp/JjG4QSqpyc+zIFxlFXL7 CWfN8q9zLiPaB8vqwHbU8PRhOBjoBUULVcsftwL3Q6gAdbxx1VTyyPoeR A==; X-CSE-ConnectionGUID: a8dauXCCRjujNs9jV0gkGA== X-CSE-MsgGUID: cutKsiJdTkWKNC0nmEq5Og== X-IronPort-AV: E=McAfee;i="6700,10204,11314"; a="51048065" X-IronPort-AV: E=Sophos;i="6.12,310,1728975600"; d="scan'208";a="51048065" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Feb 2025 13:38:20 -0800 X-CSE-ConnectionGUID: fRcm7FRSQs+GivLxICmcdg== X-CSE-MsgGUID: d5tZ7leyQo2uIa37oXVYyA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.13,268,1732608000"; d="scan'208";a="111460397" Received: from orsosgc001.jf.intel.com (HELO orsosgc001.intel.com) ([10.165.21.142]) by fmviesa006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Feb 2025 13:38:20 -0800 Date: Fri, 07 Feb 2025 13:38:19 -0800 Message-ID: <854j15l9kk.wl-ashutosh.dixit@intel.com> From: "Dixit, Ashutosh" To: Lucas De Marchi Cc: , Rodrigo Vivi , Francois Dugast Subject: Re: [PATCH v2 11/14] drm/xe/oa: Handle errors in xe_oa_register() In-Reply-To: <20250206232333.2660325-12-lucas.demarchi@intel.com> References: <20250206232333.2660325-1-lucas.demarchi@intel.com> <20250206232333.2660325-12-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:29 -0800, Lucas De Marchi wrote: > > Let xe_oa_unregister() be handled by devm infra since it's only putting > the kobject. Also, since kobject_create_and_add may fail, handle the > error accordingly. LGTM, Reviewed-by: Ashutosh Dixit > > Cc: Ashutosh Dixit > Signed-off-by: Lucas De Marchi > --- > drivers/gpu/drm/xe/xe_device.c | 14 ++++++++------ > drivers/gpu/drm/xe/xe_oa.c | 30 +++++++++++++++--------------- > drivers/gpu/drm/xe/xe_oa.h | 3 +-- > 3 files changed, 24 insertions(+), 23 deletions(-) > > diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c > index 5e4c50a70df35..6f90d74330524 100644 > --- a/drivers/gpu/drm/xe/xe_device.c > +++ b/drivers/gpu/drm/xe/xe_device.c > @@ -871,15 +871,17 @@ int xe_device_probe(struct xe_device *xe) > > err = xe_pxp_init(xe); > if (err) > - goto err_fini_display; > + goto err_remove_display; > > err = drm_dev_register(&xe->drm, 0); > if (err) > - goto err_fini_display; > + goto err_remove_display; > > xe_display_register(xe); > > - xe_oa_register(xe); > + err = xe_oa_register(xe); > + if (err) > + goto err_unregister_display; > > xe_pmu_register(&xe->pmu); > > @@ -896,7 +898,9 @@ int xe_device_probe(struct xe_device *xe) > > return devm_add_action_or_reset(xe->drm.dev, xe_device_sanitize, xe); > > -err_fini_display: > +err_unregister_display: > + xe_display_unregister(xe); > +err_remove_display: > xe_display_driver_remove(xe); > > return err; > @@ -962,8 +966,6 @@ void xe_device_remove(struct xe_device *xe) > > xe_display_driver_remove(xe); > > - xe_oa_unregister(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 2c640185bdeca..d89e6cabf5a56 100644 > --- a/drivers/gpu/drm/xe/xe_oa.c > +++ b/drivers/gpu/drm/xe/xe_oa.c > @@ -2423,36 +2423,36 @@ int xe_oa_remove_config_ioctl(struct drm_device *dev, u64 data, struct drm_file > return ret; > } > > +static void xe_oa_unregister(void *arg) > +{ > + struct xe_oa *oa = arg; > + > + if (!oa->metrics_kobj) > + return; > + > + kobject_put(oa->metrics_kobj); > + oa->metrics_kobj = NULL; > +} > + > /** > * xe_oa_register - Xe OA registration > * @xe: @xe_device > * > * Exposes the metrics sysfs directory upon completion of module initialization > */ > -void xe_oa_register(struct xe_device *xe) > +int xe_oa_register(struct xe_device *xe) > { > struct xe_oa *oa = &xe->oa; > > if (!oa->xe) > - return; > + return 0; > > oa->metrics_kobj = kobject_create_and_add("metrics", > &xe->drm.primary->kdev->kobj); > -} > - > -/** > - * xe_oa_unregister - Xe OA de-registration > - * @xe: @xe_device > - */ > -void xe_oa_unregister(struct xe_device *xe) > -{ > - struct xe_oa *oa = &xe->oa; > - > if (!oa->metrics_kobj) > - return; > + return -ENOMEM; > > - kobject_put(oa->metrics_kobj); > - oa->metrics_kobj = NULL; > + return devm_add_action_or_reset(xe->drm.dev, xe_oa_unregister, oa); > } > > static u32 num_oa_units_per_gt(struct xe_gt *gt) > diff --git a/drivers/gpu/drm/xe/xe_oa.h b/drivers/gpu/drm/xe/xe_oa.h > index eb36ce250c615..e510826f9efc6 100644 > --- a/drivers/gpu/drm/xe/xe_oa.h > +++ b/drivers/gpu/drm/xe/xe_oa.h > @@ -15,8 +15,7 @@ struct xe_gt; > struct xe_hw_engine; > > int xe_oa_init(struct xe_device *xe); > -void xe_oa_register(struct xe_device *xe); > -void xe_oa_unregister(struct xe_device *xe); > +int xe_oa_register(struct xe_device *xe); > int xe_oa_stream_open_ioctl(struct drm_device *dev, u64 data, struct drm_file *file); > int xe_oa_add_config_ioctl(struct drm_device *dev, u64 data, struct drm_file *file); > int xe_oa_remove_config_ioctl(struct drm_device *dev, u64 data, struct drm_file *file); > -- > 2.48.1 >