All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gustavo Sousa <gustavo.sousa@intel.com>
To: intel-xe@lists.freedesktop.org
Subject: [Intel-xe] [PATCH 1/2] drm/xe: Call drmm_add_action_or_reset() early in xe_device_create()
Date: Thu, 18 May 2023 18:56:50 -0300	[thread overview]
Message-ID: <20230518215651.502159-2-gustavo.sousa@intel.com> (raw)
In-Reply-To: <20230518215651.502159-1-gustavo.sousa@intel.com>

Otherwise no cleanup is actually done if we branch to err_put.

This works for now: currently we do know that, once inside
xe_device_destroy(), ttm_device_init() was successful so we can safely
call ttm_device_fini(); and, for xe->ordered_wq, there is an upcoming
commit to check its value before calling destroy_workqueue().

However, we might need change this in the future if we have more
initializers called that can fail in a way that we can not know which
one was it once inside xe_device_destroy().

Signed-off-by: Gustavo Sousa <gustavo.sousa@intel.com>
---
 drivers/gpu/drm/xe/xe_device.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c
index f7f6a6a97757..4614bb791fb0 100644
--- a/drivers/gpu/drm/xe/xe_device.c
+++ b/drivers/gpu/drm/xe/xe_device.c
@@ -187,6 +187,10 @@ struct xe_device *xe_device_create(struct pci_dev *pdev,
 	if (WARN_ON(err))
 		goto err_put;
 
+	err = drmm_add_action_or_reset(&xe->drm, xe_device_destroy, NULL);
+	if (err)
+		goto err_put;
+
 	xe->info.devid = pdev->device;
 	xe->info.revid = pdev->revision;
 	xe->info.enable_guc = enable_guc;
@@ -212,10 +216,6 @@ struct xe_device *xe_device_create(struct pci_dev *pdev,
 	if (WARN_ON(err))
 		goto err_put;
 
-	err = drmm_add_action_or_reset(&xe->drm, xe_device_destroy, NULL);
-	if (err)
-		goto err_put;
-
 	return xe;
 
 err_put:
-- 
2.40.1


  reply	other threads:[~2023-05-18 21:57 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-18 21:56 [Intel-xe] [PATCH 0/2] drm/xe: Proper cleanup in xe_device_create() Gustavo Sousa
2023-05-18 21:56 ` Gustavo Sousa [this message]
2023-05-19 14:51   ` [Intel-xe] [PATCH 1/2] drm/xe: Call drmm_add_action_or_reset() early " Rodrigo Vivi
2023-05-18 21:56 ` [Intel-xe] [PATCH 2/2] drm/xe: Fail xe_device_create() if wq allocation fails Gustavo Sousa
2023-05-19 14:49   ` Rodrigo Vivi
2023-05-18 22:03 ` [Intel-xe] ✓ CI.Patch_applied: success for drm/xe: Proper cleanup in xe_device_create() Patchwork
2023-05-18 22:05 ` [Intel-xe] ✓ CI.KUnit: " Patchwork
2023-05-18 22:08 ` [Intel-xe] ✓ CI.Build: " Patchwork
2023-05-18 22:38 ` [Intel-xe] ○ CI.BAT: info " Patchwork
2023-05-19 18:35 ` [Intel-xe] ✓ CI.Patch_applied: success for drm/xe: Proper cleanup in xe_device_create() (rev2) Patchwork
2023-05-19 18:36 ` [Intel-xe] ✓ CI.KUnit: " Patchwork
2023-05-19 18:40 ` [Intel-xe] ✓ CI.Build: " Patchwork
2023-05-22 13:33 ` [Intel-xe] ✓ CI.Patch_applied: success for drm/xe: Proper cleanup in xe_device_create() (rev3) Patchwork
2023-05-22 13:35 ` [Intel-xe] ✓ CI.KUnit: " Patchwork
2023-05-22 13:39 ` [Intel-xe] ✓ CI.Build: " Patchwork
2023-05-22 14:08 ` [Intel-xe] ○ CI.BAT: info " Patchwork
2023-05-22 20:46 ` [Intel-xe] [PATCH 0/2] drm/xe: Proper cleanup in xe_device_create() Gustavo Sousa

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=20230518215651.502159-2-gustavo.sousa@intel.com \
    --to=gustavo.sousa@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    /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.