From: Gustavo Sousa <gustavo.sousa@intel.com>
To: intel-xe@lists.freedesktop.org
Subject: [Intel-xe] [PATCH 2/2] drm/xe: Fail xe_device_create() if wq allocation fails
Date: Thu, 18 May 2023 18:56:51 -0300 [thread overview]
Message-ID: <20230518215651.502159-3-gustavo.sousa@intel.com> (raw)
In-Reply-To: <20230518215651.502159-1-gustavo.sousa@intel.com>
Let's make sure we give the driver a valid workqueue.
While at it, also make sure to call destroy_workqueue() only if the
workqueue is a valid one. That is necessary because xe_device_destroy()
is indirectly called as part of the cleanup process of a failed
xe_device_create().
Signed-off-by: Gustavo Sousa <gustavo.sousa@intel.com>
---
drivers/gpu/drm/xe/xe_device.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c
index 4614bb791fb0..dd4a4a6e0b94 100644
--- a/drivers/gpu/drm/xe/xe_device.c
+++ b/drivers/gpu/drm/xe/xe_device.c
@@ -10,6 +10,7 @@
#include <drm/drm_gem_ttm_helper.h>
#include <drm/drm_ioctl.h>
#include <drm/drm_managed.h>
+#include <drm/drm_print.h>
#include <drm/xe_drm.h>
#include "regs/xe_regs.h"
@@ -161,7 +162,9 @@ static void xe_device_destroy(struct drm_device *dev, void *dummy)
{
struct xe_device *xe = to_xe_device(dev);
- destroy_workqueue(xe->ordered_wq);
+ if (xe->ordered_wq)
+ destroy_workqueue(xe->ordered_wq);
+
ttm_device_fini(&xe->ttm);
}
@@ -211,6 +214,11 @@ struct xe_device *xe_device_create(struct pci_dev *pdev,
INIT_LIST_HEAD(&xe->pinned.evicted);
xe->ordered_wq = alloc_ordered_workqueue("xe-ordered-wq", 0);
+ if (!xe->ordered_wq) {
+ drm_err(&xe->drm, "Failed to allocate xe-ordered-wq\n");
+ err = -ENOMEM;
+ goto err_put;
+ }
err = xe_display_create(xe);
if (WARN_ON(err))
--
2.40.1
next prev parent 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 ` [Intel-xe] [PATCH 1/2] drm/xe: Call drmm_add_action_or_reset() early " Gustavo Sousa
2023-05-19 14:51 ` Rodrigo Vivi
2023-05-18 21:56 ` Gustavo Sousa [this message]
2023-05-19 14:49 ` [Intel-xe] [PATCH 2/2] drm/xe: Fail xe_device_create() if wq allocation fails 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-3-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.