All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Dixit, Ashutosh" <ashutosh.dixit@intel.com>
To: Lucas De Marchi <lucas.demarchi@intel.com>
Cc: <intel-xe@lists.freedesktop.org>,
	Rodrigo Vivi <rodrigo.vivi@intel.com>,
	Francois Dugast <francois.dugast@intel.com>
Subject: Re: [PATCH v2 11/14] drm/xe/oa: Handle errors in xe_oa_register()
Date: Fri, 07 Feb 2025 13:38:19 -0800	[thread overview]
Message-ID: <854j15l9kk.wl-ashutosh.dixit@intel.com> (raw)
In-Reply-To: <20250206232333.2660325-12-lucas.demarchi@intel.com>

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 <ashutosh.dixit@intel.com>

>
> Cc: Ashutosh Dixit <ashutosh.dixit@intel.com>
> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
> ---
>  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
>

  reply	other threads:[~2025-02-07 21:38 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-06 23:23 [PATCH v2 00/14] Cleanup error handling on probe Lucas De Marchi
2025-02-06 23:23 ` [PATCH v2 01/14] drm/xe: Fix xe_display_fini() calls Lucas De Marchi
2025-02-06 23:23 ` [PATCH v2 02/14] drm/xe: Fix error handling in xe_irq_install() Lucas De Marchi
2025-02-06 23:23 ` [PATCH v2 03/14] drm/xe: Fix xe_tile_init_noalloc() error propagation Lucas De Marchi
2025-02-06 23:23 ` [PATCH v2 04/14] drm/xe: Stop ignoring errors from xe_ttm_stolen_mgr_init() Lucas De Marchi
2025-02-06 23:23 ` [PATCH v2 05/14] drm/xe: Remove leftover pxp comment Lucas De Marchi
2025-02-06 23:28   ` Daniele Ceraolo Spurio
2025-02-06 23:23 ` [PATCH v2 06/14] drm/xe: Add callback support for driver remove Lucas De Marchi
2025-02-06 23:23 ` [PATCH v2 07/14] drm/xe: Cleanup unwind of gt initialization Lucas De Marchi
2025-02-07  0:21   ` Daniele Ceraolo Spurio
2025-02-07  0:45     ` Lucas De Marchi
2025-02-06 23:23 ` [PATCH v2 08/14] drm/xe: Cleanup extra calls to xe_hw_fence_irq_finish() Lucas De Marchi
2025-02-06 23:23 ` [PATCH v2 09/14] drm/xe: Move oa fini to xe_oa Lucas De Marchi
2025-02-07 21:22   ` Dixit, Ashutosh
2025-02-06 23:23 ` [PATCH v2 10/14] drm/xe: Move drm_dev_unplug() out of display function Lucas De Marchi
2025-02-06 23:23 ` [PATCH v2 11/14] drm/xe/oa: Handle errors in xe_oa_register() Lucas De Marchi
2025-02-07 21:38   ` Dixit, Ashutosh [this message]
2025-02-06 23:23 ` [PATCH v2 12/14] drm/xe: Fail probe if xe_pmu_register() fails Lucas De Marchi
2025-02-06 23:23 ` [PATCH v2 13/14] drm/xe/hwmon: Fix mutex destroy Lucas De Marchi
2025-02-07  3:27   ` Lucas De Marchi
2025-02-07 10:20     ` Matthew Auld
2025-02-07 13:59       ` Lucas De Marchi
2025-02-06 23:23 ` [PATCH v2 14/14] drm/xe/hwmon: Stop ignoring errors on probe Lucas De Marchi
2025-02-07  0:59 ` ✓ CI.Patch_applied: success for Cleanup error handling on probe (rev2) Patchwork
2025-02-07  1:00 ` ✗ CI.checkpatch: warning " Patchwork
2025-02-07  1:01 ` ✓ CI.KUnit: success " Patchwork
2025-02-07  1:17 ` ✓ CI.Build: " Patchwork
2025-02-07  1:20 ` ✓ CI.Hooks: " Patchwork
2025-02-07  1:21 ` ✓ CI.checksparse: " Patchwork
2025-02-07  1:41 ` ✗ Xe.CI.BAT: failure " Patchwork
2025-02-07  7:27 ` ✗ Xe.CI.Full: " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=854j15l9kk.wl-ashutosh.dixit@intel.com \
    --to=ashutosh.dixit@intel.com \
    --cc=francois.dugast@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=lucas.demarchi@intel.com \
    --cc=rodrigo.vivi@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.