dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] drm: Add DRM managed workqueues
@ 2024-03-15 14:50 Jeffrey Hugo
  2024-03-15 14:50 ` [PATCH 1/2] drm: Add DRM-managed alloc_workqueue() and alloc_ordered_workqueue() Jeffrey Hugo
  2024-03-15 14:50 ` [PATCH 2/2] accel/qaic: Use drmm_alloc_workqueue() Jeffrey Hugo
  0 siblings, 2 replies; 8+ messages in thread
From: Jeffrey Hugo @ 2024-03-15 14:50 UTC (permalink / raw)
  To: daniel, jiasheng, quic_carlv, quic_pkanojiy, stanislaw.gruszka,
	jacek.lawrynowicz
  Cc: linux-arm-msm, dri-devel, ogabbay, Jeffrey Hugo

Based on work at https://lore.kernel.org/dri-devel/20230118032413.6496-1-jiasheng@iscas.ac.cn/

The API in the origional work seemed to have two issues:
1. The output parameter was not correctly defined
2. The allocating functions did not return the allocated object like the
other drmm functions

I tweaked the implementation to address both of these.

From what I can tell, the i915 change no longer applies to the code
base, likely due to refactoring from merging xe.  I dropped it.

Jeffrey Hugo (1):
  accel/qaic: Use drmm_alloc_workqueue()

Jiasheng Jiang (1):
  drm: Add DRM-managed alloc_workqueue() and alloc_ordered_workqueue()

 drivers/accel/qaic/qaic_drv.c | 30 ++-----------
 drivers/gpu/drm/drm_managed.c | 82 +++++++++++++++++++++++++++++++++++
 include/drm/drm_managed.h     |  8 ++++
 3 files changed, 94 insertions(+), 26 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] drm: Add DRM-managed alloc_workqueue() and alloc_ordered_workqueue()
@ 2023-01-18  3:24 Jiasheng Jiang
  2023-11-14 16:03 ` Jeffrey Hugo
  0 siblings, 1 reply; 8+ messages in thread
From: Jiasheng Jiang @ 2023-01-18  3:24 UTC (permalink / raw)
  To: daniel; +Cc: Jiasheng Jiang, linux-kernel, dri-devel, tzimmermann

> On Tue, Jan 10, 2023 at 11:24:47PM +0800, Jiasheng Jiang wrote:
>> Add drmm_alloc_workqueue() and drmm_alloc_ordered_workqueue(), the helpers
>> that provide managed workqueue cleanup. The workqueue will be destroyed
>> with the final reference of the DRM device.
>> 
>> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
> 
> Yeah I think this looks nice.
> 
> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> 
> I'm assuming driver maintainers will pick this up, if not please holler.
> 
> Also the threading seems broken, it's not a patch series. The b4 tool or
> git send-email (of all the patches of the entire series at once, not each
> individually) should get this right.
> 
> Unfortunately I did't find the right link in the kernel docs, or at least
> they're not as detailed as I hoped.
> 
> Also your previous submission had iirc a bunch more patches, do you plan
> to include them all in the next patch set?

I have found that some previous patches have already been applied.
Need I just convert alloc*workqueue into drmm_alloc*workqueue and remove
the destroy_workqueue?
Or need I convert all the alloc*workqueue in the DRM?

Thanks,
Jiang


^ permalink raw reply	[flat|nested] 8+ messages in thread
* [PATCH 1/2] drm: Add DRM-managed alloc_workqueue() and alloc_ordered_workqueue()
@ 2023-01-10 15:24 Jiasheng Jiang
  2023-01-11 22:46 ` Daniel Vetter
  0 siblings, 1 reply; 8+ messages in thread
From: Jiasheng Jiang @ 2023-01-10 15:24 UTC (permalink / raw)
  To: maarten.lankhorst, mripard, tzimmermann, airlied, daniel
  Cc: Jiasheng Jiang, linux-kernel, dri-devel

Add drmm_alloc_workqueue() and drmm_alloc_ordered_workqueue(), the helpers
that provide managed workqueue cleanup. The workqueue will be destroyed
with the final reference of the DRM device.

Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
 drivers/gpu/drm/drm_managed.c | 66 +++++++++++++++++++++++++++++++++++
 include/drm/drm_managed.h     |  8 +++++
 2 files changed, 74 insertions(+)

diff --git a/drivers/gpu/drm/drm_managed.c b/drivers/gpu/drm/drm_managed.c
index 4cf214de50c4..d3bd6247eec9 100644
--- a/drivers/gpu/drm/drm_managed.c
+++ b/drivers/gpu/drm/drm_managed.c
@@ -271,6 +271,13 @@ static void drmm_mutex_release(struct drm_device *dev, void *res)
 	mutex_destroy(lock);
 }
 
+static void drmm_destroy_workqueue(struct drm_device *dev, void *res)
+{
+	struct workqueue_struct *wq = res;
+
+	destroy_workqueue(wq);
+}
+
 /**
  * drmm_mutex_init - &drm_device-managed mutex_init()
  * @dev: DRM device
@@ -289,3 +296,62 @@ int drmm_mutex_init(struct drm_device *dev, struct mutex *lock)
 	return drmm_add_action_or_reset(dev, drmm_mutex_release, lock);
 }
 EXPORT_SYMBOL(drmm_mutex_init);
+
+/**
+ * drmm_alloc_workqueue - &drm_device-managed alloc_workqueue()
+ * @dev: DRM device
+ * @wq: workqueue to be allocated
+ *
+ * Returns:
+ * 0 on success, or a negative errno code otherwise.
+ *
+ * This is a &drm_device-managed version of alloc_workqueue().
+ * The initialized lock is automatically destroyed on the final
+ * drm_dev_put().
+ */
+int drmm_alloc_workqueue(struct drm_device *dev,
+			  struct workqueue_struct *wq, const char *fmt,
+			  unsigned int flags, int max_active, ...)
+{
+	va_list args;
+
+	va_start(args, max_active);
+	wq = alloc_workqueue(fmt, flags, max_active, args);
+	va_end(args);
+
+	if (!wq)
+		return -ENOMEM;
+
+	return drmm_add_action_or_reset(dev, drmm_destroy_workqueue, wq);
+}
+EXPORT_SYMBOL(drmm_alloc_workqueue);
+
+/**
+ * drmm_alloc_ordered_workqueue - &drm_device-managed
+ * alloc_ordered_workqueue()
+ * @dev: DRM device
+ * @wq: workqueue to be allocated
+ *
+ * Returns:
+ * 0 on success, or a negative errno code otherwise.
+ *
+ * This is a &drm_device-managed version of alloc_ordered_workqueue().
+ * The initialized lock is automatically destroyed on the final
+ * drm_dev_put().
+ */
+int drmm_alloc_ordered_workqueue(struct drm_device *dev,
+				  struct workqueue_struct *wq,
+				  const char *fmt, unsigned int flags, ...)
+{
+	va_list args;
+
+	va_start(args, flags);
+	wq = alloc_ordered_workqueue(fmt, flags, args);
+	va_end(args);
+
+	if (!wq)
+		return -ENOMEM;
+
+	return drmm_add_action_or_reset(dev, drmm_destroy_workqueue, wq);
+}
+EXPORT_SYMBOL(drmm_alloc_ordered_workqueue);
diff --git a/include/drm/drm_managed.h b/include/drm/drm_managed.h
index 359883942612..68cecc14e1af 100644
--- a/include/drm/drm_managed.h
+++ b/include/drm/drm_managed.h
@@ -107,4 +107,12 @@ void drmm_kfree(struct drm_device *dev, void *data);
 
 int drmm_mutex_init(struct drm_device *dev, struct mutex *lock);
 
+int drmm_alloc_workqueue(struct drm_device *dev,
+			  struct workqueue_struct *wq, const char *fmt,
+			  unsigned int flags, int max_active, ...);
+
+int drmm_alloc_ordered_workqueue(struct drm_device *dev,
+				  struct workqueue_struct *wq,
+				  const char *fmt, unsigned int flags, ...);
+
 #endif
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-03-15 20:52 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-15 14:50 [PATCH 0/2] drm: Add DRM managed workqueues Jeffrey Hugo
2024-03-15 14:50 ` [PATCH 1/2] drm: Add DRM-managed alloc_workqueue() and alloc_ordered_workqueue() Jeffrey Hugo
2024-03-15 20:51   ` kernel test robot
2024-03-15 14:50 ` [PATCH 2/2] accel/qaic: Use drmm_alloc_workqueue() Jeffrey Hugo
  -- strict thread matches above, loose matches on Subject: below --
2023-01-18  3:24 [PATCH 1/2] drm: Add DRM-managed alloc_workqueue() and alloc_ordered_workqueue() Jiasheng Jiang
2023-11-14 16:03 ` Jeffrey Hugo
2023-01-10 15:24 Jiasheng Jiang
2023-01-11 22:46 ` Daniel Vetter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox