All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/1] Simplify drmm_alloc_ordered_workqueue return
@ 2025-07-02 23:28 Matthew Brost
  2025-07-02 23:28 ` [PATCH 1/1] drm: " Matthew Brost
  0 siblings, 1 reply; 4+ messages in thread
From: Matthew Brost @ 2025-07-02 23:28 UTC (permalink / raw)
  To: dri-devel; +Cc: louis.chauvet

We want to use drmm_alloc_ordered_workqueue in Xe, let's make this work
a little better.

Matthew Brost (1):
  drm: Simplify drmm_alloc_ordered_workqueue return

 drivers/gpu/drm/vkms/vkms_crtc.c |  2 --
 include/drm/drm_managed.h        | 15 +++++++++++++--
 2 files changed, 13 insertions(+), 4 deletions(-)

-- 
2.34.1


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

* [PATCH 1/1] drm: Simplify drmm_alloc_ordered_workqueue return
  2025-07-02 23:28 [PATCH 0/1] Simplify drmm_alloc_ordered_workqueue return Matthew Brost
@ 2025-07-02 23:28 ` Matthew Brost
  2025-07-03  8:12   ` Louis Chauvet
  0 siblings, 1 reply; 4+ messages in thread
From: Matthew Brost @ 2025-07-02 23:28 UTC (permalink / raw)
  To: dri-devel; +Cc: louis.chauvet

Rather than returning ERR_PTR or NULL on failure, replace the NULL
return with ERR_PTR(-ENOMEM). This simplifies error handling at the
caller. While here, add kernel documentation for
drmm_alloc_ordered_workqueue.

Cc: Louis Chauvet <louis.chauvet@bootlin.com>
Signed-off-by: Matthew Brost <matthew.brost@intel.com>
---
 drivers/gpu/drm/vkms/vkms_crtc.c |  2 --
 include/drm/drm_managed.h        | 15 +++++++++++++--
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c
index 8c9898b9055d..e60573e0f3e9 100644
--- a/drivers/gpu/drm/vkms/vkms_crtc.c
+++ b/drivers/gpu/drm/vkms/vkms_crtc.c
@@ -302,8 +302,6 @@ struct vkms_output *vkms_crtc_init(struct drm_device *dev, struct drm_plane *pri
 	vkms_out->composer_workq = drmm_alloc_ordered_workqueue(dev, "vkms_composer", 0);
 	if (IS_ERR(vkms_out->composer_workq))
 		return ERR_CAST(vkms_out->composer_workq);
-	if (!vkms_out->composer_workq)
-		return ERR_PTR(-ENOMEM);
 
 	return vkms_out;
 }
diff --git a/include/drm/drm_managed.h b/include/drm/drm_managed.h
index 53017cc609ac..72bfac002c06 100644
--- a/include/drm/drm_managed.h
+++ b/include/drm/drm_managed.h
@@ -129,14 +129,25 @@ void __drmm_mutex_release(struct drm_device *dev, void *res);
 
 void __drmm_workqueue_release(struct drm_device *device, void *wq);
 
+/**
+ * drmm_alloc_ordered_workqueue - &drm_device managed alloc_ordered_workqueue()
+ * @dev: DRM device
+ * @fmt: printf format for the name of the workqueue
+ * @flags: WQ_* flags (only WQ_FREEZABLE and WQ_MEM_RECLAIM are meaningful)
+ * @args: args for @fmt
+ *
+ * This is a &drm_device-managed version of alloc_ordered_workqueue(). The
+ * allocated workqueue is automatically destroyed on the final drm_dev_put().
+ *
+ * Returns: workqueue on success, negative ERR_PTR otherwise.
+ */
 #define drmm_alloc_ordered_workqueue(dev, fmt, flags, args...)					\
 	({											\
 		struct workqueue_struct *wq = alloc_ordered_workqueue(fmt, flags, ##args);	\
 		wq ? ({										\
 			int ret = drmm_add_action_or_reset(dev, __drmm_workqueue_release, wq);	\
 			ret ? ERR_PTR(ret) : wq;						\
-		}) :										\
-			wq;									\
+		}) : ERR_PTR(-ENOMEM);								\
 	})
 
 #endif
-- 
2.34.1


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

* Re: [PATCH 1/1] drm: Simplify drmm_alloc_ordered_workqueue return
  2025-07-02 23:28 ` [PATCH 1/1] drm: " Matthew Brost
@ 2025-07-03  8:12   ` Louis Chauvet
  2025-07-03 15:19     ` Matthew Brost
  0 siblings, 1 reply; 4+ messages in thread
From: Louis Chauvet @ 2025-07-03  8:12 UTC (permalink / raw)
  To: Matthew Brost, dri-devel



Le 03/07/2025 à 01:28, Matthew Brost a écrit :
> Rather than returning ERR_PTR or NULL on failure, replace the NULL
> return with ERR_PTR(-ENOMEM). This simplifies error handling at the
> caller. While here, add kernel documentation for
> drmm_alloc_ordered_workqueue.
> 
> Cc: Louis Chauvet <louis.chauvet@bootlin.com>
> Signed-off-by: Matthew Brost <matthew.brost@intel.com>

Reviewed-by: Louis Chauvet <louis.chauvet@bootlin.com>

As you need it in xe, I don't know the process to apply the patch. 
Should I apply it on drm-misc-next?

Thanks,
Louis Chauvet

> ---
>   drivers/gpu/drm/vkms/vkms_crtc.c |  2 --
>   include/drm/drm_managed.h        | 15 +++++++++++++--
>   2 files changed, 13 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c
> index 8c9898b9055d..e60573e0f3e9 100644
> --- a/drivers/gpu/drm/vkms/vkms_crtc.c
> +++ b/drivers/gpu/drm/vkms/vkms_crtc.c
> @@ -302,8 +302,6 @@ struct vkms_output *vkms_crtc_init(struct drm_device *dev, struct drm_plane *pri
>   	vkms_out->composer_workq = drmm_alloc_ordered_workqueue(dev, "vkms_composer", 0);
>   	if (IS_ERR(vkms_out->composer_workq))
>   		return ERR_CAST(vkms_out->composer_workq);
> -	if (!vkms_out->composer_workq)
> -		return ERR_PTR(-ENOMEM);
>   
>   	return vkms_out;
>   }
> diff --git a/include/drm/drm_managed.h b/include/drm/drm_managed.h
> index 53017cc609ac..72bfac002c06 100644
> --- a/include/drm/drm_managed.h
> +++ b/include/drm/drm_managed.h
> @@ -129,14 +129,25 @@ void __drmm_mutex_release(struct drm_device *dev, void *res);
>   
>   void __drmm_workqueue_release(struct drm_device *device, void *wq);
>   
> +/**
> + * drmm_alloc_ordered_workqueue - &drm_device managed alloc_ordered_workqueue()
> + * @dev: DRM device
> + * @fmt: printf format for the name of the workqueue
> + * @flags: WQ_* flags (only WQ_FREEZABLE and WQ_MEM_RECLAIM are meaningful)
> + * @args: args for @fmt
> + *
> + * This is a &drm_device-managed version of alloc_ordered_workqueue(). The
> + * allocated workqueue is automatically destroyed on the final drm_dev_put().
> + *
> + * Returns: workqueue on success, negative ERR_PTR otherwise.
> + */
>   #define drmm_alloc_ordered_workqueue(dev, fmt, flags, args...)					\
>   	({											\
>   		struct workqueue_struct *wq = alloc_ordered_workqueue(fmt, flags, ##args);	\
>   		wq ? ({										\
>   			int ret = drmm_add_action_or_reset(dev, __drmm_workqueue_release, wq);	\
>   			ret ? ERR_PTR(ret) : wq;						\
> -		}) :										\
> -			wq;									\
> +		}) : ERR_PTR(-ENOMEM);								\
>   	})
>   
>   #endif

-- 
Louis Chauvet, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com


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

* Re: [PATCH 1/1] drm: Simplify drmm_alloc_ordered_workqueue return
  2025-07-03  8:12   ` Louis Chauvet
@ 2025-07-03 15:19     ` Matthew Brost
  0 siblings, 0 replies; 4+ messages in thread
From: Matthew Brost @ 2025-07-03 15:19 UTC (permalink / raw)
  To: Louis Chauvet; +Cc: dri-devel

On Thu, Jul 03, 2025 at 10:12:41AM +0200, Louis Chauvet wrote:
> 
> 
> Le 03/07/2025 à 01:28, Matthew Brost a écrit :
> > Rather than returning ERR_PTR or NULL on failure, replace the NULL
> > return with ERR_PTR(-ENOMEM). This simplifies error handling at the
> > caller. While here, add kernel documentation for
> > drmm_alloc_ordered_workqueue.
> > 
> > Cc: Louis Chauvet <louis.chauvet@bootlin.com>
> > Signed-off-by: Matthew Brost <matthew.brost@intel.com>
> 
> Reviewed-by: Louis Chauvet <louis.chauvet@bootlin.com>
> 
> As you need it in xe, I don't know the process to apply the patch. Should I
> apply it on drm-misc-next?
> 

I think we can apply it to drm-misc-next then cherry pick into the
needed Xe branches. I'll confirm with my maintainers and apply this to
drm-misc-next.

Thanks,
Matt

> Thanks,
> Louis Chauvet
> 
> > ---
> >   drivers/gpu/drm/vkms/vkms_crtc.c |  2 --
> >   include/drm/drm_managed.h        | 15 +++++++++++++--
> >   2 files changed, 13 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c
> > index 8c9898b9055d..e60573e0f3e9 100644
> > --- a/drivers/gpu/drm/vkms/vkms_crtc.c
> > +++ b/drivers/gpu/drm/vkms/vkms_crtc.c
> > @@ -302,8 +302,6 @@ struct vkms_output *vkms_crtc_init(struct drm_device *dev, struct drm_plane *pri
> >   	vkms_out->composer_workq = drmm_alloc_ordered_workqueue(dev, "vkms_composer", 0);
> >   	if (IS_ERR(vkms_out->composer_workq))
> >   		return ERR_CAST(vkms_out->composer_workq);
> > -	if (!vkms_out->composer_workq)
> > -		return ERR_PTR(-ENOMEM);
> >   	return vkms_out;
> >   }
> > diff --git a/include/drm/drm_managed.h b/include/drm/drm_managed.h
> > index 53017cc609ac..72bfac002c06 100644
> > --- a/include/drm/drm_managed.h
> > +++ b/include/drm/drm_managed.h
> > @@ -129,14 +129,25 @@ void __drmm_mutex_release(struct drm_device *dev, void *res);
> >   void __drmm_workqueue_release(struct drm_device *device, void *wq);
> > +/**
> > + * drmm_alloc_ordered_workqueue - &drm_device managed alloc_ordered_workqueue()
> > + * @dev: DRM device
> > + * @fmt: printf format for the name of the workqueue
> > + * @flags: WQ_* flags (only WQ_FREEZABLE and WQ_MEM_RECLAIM are meaningful)
> > + * @args: args for @fmt
> > + *
> > + * This is a &drm_device-managed version of alloc_ordered_workqueue(). The
> > + * allocated workqueue is automatically destroyed on the final drm_dev_put().
> > + *
> > + * Returns: workqueue on success, negative ERR_PTR otherwise.
> > + */
> >   #define drmm_alloc_ordered_workqueue(dev, fmt, flags, args...)					\
> >   	({											\
> >   		struct workqueue_struct *wq = alloc_ordered_workqueue(fmt, flags, ##args);	\
> >   		wq ? ({										\
> >   			int ret = drmm_add_action_or_reset(dev, __drmm_workqueue_release, wq);	\
> >   			ret ? ERR_PTR(ret) : wq;						\
> > -		}) :										\
> > -			wq;									\
> > +		}) : ERR_PTR(-ENOMEM);								\
> >   	})
> >   #endif
> 
> -- 
> Louis Chauvet, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com
> 

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

end of thread, other threads:[~2025-07-03 15:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-02 23:28 [PATCH 0/1] Simplify drmm_alloc_ordered_workqueue return Matthew Brost
2025-07-02 23:28 ` [PATCH 1/1] drm: " Matthew Brost
2025-07-03  8:12   ` Louis Chauvet
2025-07-03 15:19     ` Matthew Brost

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.