Linux ARM-MSM sub-architecture
 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; 4+ 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] 4+ messages in thread

* [PATCH 1/2] drm: Add DRM-managed alloc_workqueue() and alloc_ordered_workqueue()
  2024-03-15 14:50 [PATCH 0/2] drm: Add DRM managed workqueues Jeffrey Hugo
@ 2024-03-15 14:50 ` 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
  1 sibling, 1 reply; 4+ 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, Daniel Vetter, Jeffrey Hugo

From: Jiasheng Jiang <jiasheng@iscas.ac.cn>

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>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
[jhugo: fix API to return the alloc'd workqueue]
Signed-off-by: Jeffrey Hugo <quic_jhugo@quicinc.com>
Reviewed-by: Carl Vanderlip <quic_carlv@quicinc.com>
Reviewed-by: Pranjal Ramajor Asha Kanojiya <quic_pkanojiy@quicinc.com>
---
 drivers/gpu/drm/drm_managed.c | 82 +++++++++++++++++++++++++++++++++++
 include/drm/drm_managed.h     |  8 ++++
 2 files changed, 90 insertions(+)

diff --git a/drivers/gpu/drm/drm_managed.c b/drivers/gpu/drm/drm_managed.c
index 7646f67bda4e..d5135a471ff2 100644
--- a/drivers/gpu/drm/drm_managed.c
+++ b/drivers/gpu/drm/drm_managed.c
@@ -310,3 +310,85 @@ void __drmm_mutex_release(struct drm_device *dev, void *res)
 	mutex_destroy(lock);
 }
 EXPORT_SYMBOL(__drmm_mutex_release);
+
+static void drmm_destroy_workqueue(struct drm_device *dev, void *res)
+{
+	struct workqueue_struct *wq = res;
+
+	destroy_workqueue(wq);
+}
+
+/**
+ * drmm_alloc_workqueue - &drm_device-managed alloc_workqueue()
+ * @dev: DRM device
+ * @wq: workqueue to be allocated
+ *
+ * Returns:
+ * Valid pointer on success, NULL on error.
+ *
+ * This is a &drm_device-managed version of alloc_workqueue().
+ * The initialized lock is automatically destroyed on the final
+ * drm_dev_put().
+ */
+struct workqueue_struct *drmm_alloc_workqueue(struct drm_device *dev,
+					      const char *fmt, unsigned int flags,
+					      int max_active, ...)
+{
+	struct workqueue_struct *wq;
+	va_list args;
+	int ret;
+
+	va_start(args, max_active);
+	wq = alloc_workqueue(fmt, flags, max_active, args);
+	va_end(args);
+
+	if (!wq)
+		return NULL;
+
+	ret = drmm_add_action_or_reset(dev, drmm_destroy_workqueue, wq);
+	if (ret) {
+		destroy_workqueue(wq);
+		return NULL;
+	}
+
+	return 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:
+ * Valid pointer on success, NULL on error.
+ *
+ * This is a &drm_device-managed version of alloc_ordered_workqueue().
+ * The initialized lock is automatically destroyed on the final
+ * drm_dev_put().
+ */
+struct workqueue_struct *drmm_alloc_ordered_workqueue(struct drm_device *dev,
+						      const char *fmt,
+						      unsigned int flags, ...)
+{
+	struct workqueue_struct *wq;
+	va_list args;
+	int ret;
+
+	va_start(args, flags);
+	wq = alloc_ordered_workqueue(fmt, flags, args);
+	va_end(args);
+
+	if (!wq)
+		return NULL;
+
+	ret = drmm_add_action_or_reset(dev, drmm_destroy_workqueue, wq);
+	if (ret) {
+		destroy_workqueue(wq);
+		return NULL;
+	}
+
+	return wq;
+}
+EXPORT_SYMBOL(drmm_alloc_ordered_workqueue);
diff --git a/include/drm/drm_managed.h b/include/drm/drm_managed.h
index f547b09ca023..cb42fb252648 100644
--- a/include/drm/drm_managed.h
+++ b/include/drm/drm_managed.h
@@ -127,4 +127,12 @@ void __drmm_mutex_release(struct drm_device *dev, void *res);
 	drmm_add_action_or_reset(dev, __drmm_mutex_release, lock);	     \
 })									     \
 
+struct workqueue_struct *drmm_alloc_workqueue(struct drm_device *dev,
+					      const char *fmt, unsigned int flags,
+					      int max_active, ...);
+
+struct workqueue_struct *drmm_alloc_ordered_workqueue(struct drm_device *dev,
+						      const char *fmt,
+						      unsigned int flags, ...);
+
 #endif
-- 
2.34.1


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

* [PATCH 2/2] accel/qaic: Use drmm_alloc_workqueue()
  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 14:50 ` Jeffrey Hugo
  1 sibling, 0 replies; 4+ 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

Now that drmm_alloc_workqueue() exists, we can stop open coding our own
implementation.

Signed-off-by: Jeffrey Hugo <quic_jhugo@quicinc.com>
Reviewed-by: Carl Vanderlip <quic_carlv@quicinc.com>
Reviewed-by: Pranjal Ramajor Asha Kanojiya <quic_pkanojiy@quicinc.com>
---
 drivers/accel/qaic/qaic_drv.c | 30 ++++--------------------------
 1 file changed, 4 insertions(+), 26 deletions(-)

diff --git a/drivers/accel/qaic/qaic_drv.c b/drivers/accel/qaic/qaic_drv.c
index f072edb74f22..9bc09b87a7e1 100644
--- a/drivers/accel/qaic/qaic_drv.c
+++ b/drivers/accel/qaic/qaic_drv.c
@@ -45,28 +45,6 @@ MODULE_PARM_DESC(datapath_polling, "Operate the datapath in polling mode");
 static bool link_up;
 static DEFINE_IDA(qaic_usrs);
 
-static void qaicm_wq_release(struct drm_device *dev, void *res)
-{
-	struct workqueue_struct *wq = res;
-
-	destroy_workqueue(wq);
-}
-
-static struct workqueue_struct *qaicm_wq_init(struct drm_device *dev, const char *fmt)
-{
-	struct workqueue_struct *wq;
-	int ret;
-
-	wq = alloc_workqueue(fmt, WQ_UNBOUND, 0);
-	if (!wq)
-		return ERR_PTR(-ENOMEM);
-	ret = drmm_add_action_or_reset(dev, qaicm_wq_release, wq);
-	if (ret)
-		return ERR_PTR(ret);
-
-	return wq;
-}
-
 static void qaicm_srcu_release(struct drm_device *dev, void *res)
 {
 	struct srcu_struct *lock = res;
@@ -391,11 +369,11 @@ static struct qaic_device *create_qdev(struct pci_dev *pdev, const struct pci_de
 	if (ret)
 		return NULL;
 
-	qdev->cntl_wq = qaicm_wq_init(drm, "qaic_cntl");
-	if (IS_ERR(qdev->cntl_wq))
+	qdev->cntl_wq = drmm_alloc_workqueue(drm, "qaic_cntl", WQ_UNBOUND, WQ_UNBOUND_MAX_ACTIVE);
+	if (!qdev->cntl_wq)
 		return NULL;
-	qdev->qts_wq = qaicm_wq_init(drm, "qaic_ts");
-	if (IS_ERR(qdev->qts_wq))
+	qdev->qts_wq = drmm_alloc_workqueue(drm, "qaic_ts", WQ_UNBOUND, WQ_UNBOUND_MAX_ACTIVE);
+	if (!qdev->qts_wq)
 		return NULL;
 
 	ret = qaicm_srcu_init(drm, &qdev->dev_lock);
-- 
2.34.1


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

* Re: [PATCH 1/2] drm: Add DRM-managed alloc_workqueue() and alloc_ordered_workqueue()
  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
  0 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2024-03-15 20:51 UTC (permalink / raw)
  To: Jeffrey Hugo, daniel, jiasheng, quic_carlv, quic_pkanojiy,
	stanislaw.gruszka, jacek.lawrynowicz
  Cc: oe-kbuild-all, linux-arm-msm, dri-devel, ogabbay, Daniel Vetter,
	Jeffrey Hugo

Hi Jeffrey,

kernel test robot noticed the following build warnings:

[auto build test WARNING on drm-misc/drm-misc-next]
[also build test WARNING on linus/master v6.8 next-20240315]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Jeffrey-Hugo/drm-Add-DRM-managed-alloc_workqueue-and-alloc_ordered_workqueue/20240315-225330
base:   git://anongit.freedesktop.org/drm/drm-misc drm-misc-next
patch link:    https://lore.kernel.org/r/20240315145034.3972749-2-quic_jhugo%40quicinc.com
patch subject: [PATCH 1/2] drm: Add DRM-managed alloc_workqueue() and alloc_ordered_workqueue()
config: parisc-defconfig (https://download.01.org/0day-ci/archive/20240316/202403160449.IaCY0Cl5-lkp@intel.com/config)
compiler: hppa-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240316/202403160449.IaCY0Cl5-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202403160449.IaCY0Cl5-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/gpu/drm/drm_managed.c:336: warning: Function parameter or struct member 'fmt' not described in 'drmm_alloc_workqueue'
>> drivers/gpu/drm/drm_managed.c:336: warning: Function parameter or struct member 'flags' not described in 'drmm_alloc_workqueue'
>> drivers/gpu/drm/drm_managed.c:336: warning: Function parameter or struct member 'max_active' not described in 'drmm_alloc_workqueue'
>> drivers/gpu/drm/drm_managed.c:336: warning: Excess function parameter 'wq' description in 'drmm_alloc_workqueue'
>> drivers/gpu/drm/drm_managed.c:374: warning: Function parameter or struct member 'fmt' not described in 'drmm_alloc_ordered_workqueue'
>> drivers/gpu/drm/drm_managed.c:374: warning: Function parameter or struct member 'flags' not described in 'drmm_alloc_ordered_workqueue'
>> drivers/gpu/drm/drm_managed.c:374: warning: Excess function parameter 'wq' description in 'drmm_alloc_ordered_workqueue'


vim +336 drivers/gpu/drm/drm_managed.c

   320	
   321	/**
   322	 * drmm_alloc_workqueue - &drm_device-managed alloc_workqueue()
   323	 * @dev: DRM device
   324	 * @wq: workqueue to be allocated
   325	 *
   326	 * Returns:
   327	 * Valid pointer on success, NULL on error.
   328	 *
   329	 * This is a &drm_device-managed version of alloc_workqueue().
   330	 * The initialized lock is automatically destroyed on the final
   331	 * drm_dev_put().
   332	 */
   333	struct workqueue_struct *drmm_alloc_workqueue(struct drm_device *dev,
   334						      const char *fmt, unsigned int flags,
   335						      int max_active, ...)
 > 336	{
   337		struct workqueue_struct *wq;
   338		va_list args;
   339		int ret;
   340	
   341		va_start(args, max_active);
   342		wq = alloc_workqueue(fmt, flags, max_active, args);
   343		va_end(args);
   344	
   345		if (!wq)
   346			return NULL;
   347	
   348		ret = drmm_add_action_or_reset(dev, drmm_destroy_workqueue, wq);
   349		if (ret) {
   350			destroy_workqueue(wq);
   351			return NULL;
   352		}
   353	
   354		return wq;
   355	}
   356	EXPORT_SYMBOL(drmm_alloc_workqueue);
   357	
   358	/**
   359	 * drmm_alloc_ordered_workqueue - &drm_device-managed
   360	 * alloc_ordered_workqueue()
   361	 * @dev: DRM device
   362	 * @wq: workqueue to be allocated
   363	 *
   364	 * Returns:
   365	 * Valid pointer on success, NULL on error.
   366	 *
   367	 * This is a &drm_device-managed version of alloc_ordered_workqueue().
   368	 * The initialized lock is automatically destroyed on the final
   369	 * drm_dev_put().
   370	 */
   371	struct workqueue_struct *drmm_alloc_ordered_workqueue(struct drm_device *dev,
   372							      const char *fmt,
   373							      unsigned int flags, ...)
 > 374	{

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

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

Thread overview: 4+ 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

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