From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 592381553B7 for ; Tue, 14 Jan 2025 16:04:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.199 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736870682; cv=none; b=WMXKN1V/aHoiurrt+Gpd8OcES5rcbWwYhdBpkYNW2rVkVPaWruAUApvkPcvzx+7fIqeuGwZt84mZ1S4Aj3p3PPsfX35hqO6FOYBzTOC1ejRF6U/v0vT1A0F93s/MfzmDRgNxrqPPD+HhkwEXW/np41g7Cz7ZcK1ARrQWx1kypg0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736870682; c=relaxed/simple; bh=Imlr2sIB/8TG90ytArdyZh6++4UskI5oj4rdz0a9xyk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=qWNPeDry8Hw1GMGR5BfQz1XFThrbS72lYVNXIaplxBqXn3faSaqYpwMpkQqJSzI/wVIIaBlwCTQ5Sp9XmzsAiV+9sJv5DVigrOWX1Hv/fOwTzq0K95Y7Z9U0IK3ral4Vt+m2rGjFsOu9NxSaRyaM7ivWOq1ZgYRhUo4QAimVz+s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=Phj5zwDY; arc=none smtp.client-ip=217.70.183.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="Phj5zwDY" Received: by mail.gandi.net (Postfix) with ESMTPSA id 92185FF805; Tue, 14 Jan 2025 16:04:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1736870672; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=IVZ8R+dm2xry0V0ZXA6iIU+BsIOOLytrdyYusIJV5HI=; b=Phj5zwDY9AhJCEmr00ydP6xoQqVYnsxhTQ+XQ0TxmPoiVuFOEn8h0wshcTC/T/v9HXLb+J g4T8V0qwI4HBVPIeN12d6SLtglflYXiEwYdivChKiETa0SVXykKX3yFfohWw/U/0LEiUjT ij4vzLRQenygem08Lea63IdEeVt+L6ExfVqv2yrs12aM5n8wMTE9ecwhQ6JQgusGVkMAHN bDb29PEXNhF/GQ1HKrvKg9g7TNvLG08DIZ7ijM5Ao8g/DI7X2/VbZEG+M/PpNCtJ4w1Bdv RJ7RY9xHpZW2AURSX39s6eo46jUxfDJCL2k7s4e82asNXCAPTX1EEFedWX5RoQ== Date: Tue, 14 Jan 2025 17:04:29 +0100 From: Louis Chauvet To: Maxime Ripard Cc: Rodrigo Siqueira , Melissa Wen , =?iso-8859-1?Q?Ma=EDra?= Canal , Haneen Mohammed , Maarten Lankhorst , Thomas Zimmermann , David Airlie , Simona Vetter , Simona Vetter , dri-devel@lists.freedesktop.org, arthurgrillo@riseup.net, linux-kernel@vger.kernel.org, jeremie.dautheribes@bootlin.com, miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com, seanpaul@google.com, nicolejadeyee@google.com Subject: Re: [PATCH v8 3/8] drm/managed: Add DRM-managed alloc_ordered_workqueue Message-ID: Mail-Followup-To: Maxime Ripard , Rodrigo Siqueira , Melissa Wen , =?iso-8859-1?Q?Ma=EDra?= Canal , Haneen Mohammed , Maarten Lankhorst , Thomas Zimmermann , David Airlie , Simona Vetter , Simona Vetter , dri-devel@lists.freedesktop.org, arthurgrillo@riseup.net, linux-kernel@vger.kernel.org, jeremie.dautheribes@bootlin.com, miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com, seanpaul@google.com, nicolejadeyee@google.com References: <20250114-google-vkms-managed-v8-0-da4254aa3dd5@bootlin.com> <20250114-google-vkms-managed-v8-3-da4254aa3dd5@bootlin.com> <20250114-spectral-beetle-of-dignity-986943@houat> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250114-spectral-beetle-of-dignity-986943@houat> X-GND-Sasl: louis.chauvet@bootlin.com On 14/01/25 - 16:29, Maxime Ripard wrote: > On Tue, Jan 14, 2025 at 03:05:45PM +0100, Louis Chauvet wrote: > > Add drmm_alloc_ordered_workqueue(), a helper that provides managed ordered > > workqueue cleanup. The workqueue will be destroyed with the final > > reference of the DRM device. > > > > Signed-off-by: Louis Chauvet > > > > --- > > > > Hi Thomas, > > > > I noted that you wanted to mark this as Reviewed, but as this was not > > the complete patch, I prefered to have a confirmation before merging the > > patch. > > > > Thanks for your time, > > Louis Chauvet > > --- > > drivers/gpu/drm/drm_managed.c | 8 ++++++++ > > include/drm/drm_managed.h | 12 ++++++++++++ > > 2 files changed, 20 insertions(+) > > > > diff --git a/drivers/gpu/drm/drm_managed.c b/drivers/gpu/drm/drm_managed.c > > index 79ce86a5bd67a7201f5d60550a12364f2628e0ec..1589c28410f23b5a1e93dd1638420b3ae5c4b854 100644 > > --- a/drivers/gpu/drm/drm_managed.c > > +++ b/drivers/gpu/drm/drm_managed.c > > @@ -310,3 +310,11 @@ void __drmm_mutex_release(struct drm_device *dev, void *res) > > mutex_destroy(lock); > > } > > EXPORT_SYMBOL(__drmm_mutex_release); > > + > > +void __drmm_destroy_workqueue(struct drm_device *device, void *res) > > +{ > > + struct workqueue_struct *wq = res; > > + > > + destroy_workqueue(wq); > > +} > > +EXPORT_SYMBOL(__drmm_destroy_workqueue); > > diff --git a/include/drm/drm_managed.h b/include/drm/drm_managed.h > > index f547b09ca0239dd7c4fb734038bae4438321395c..96d9b0e811675fe66d5d48f02b17bc7de2ac437e 100644 > > --- a/include/drm/drm_managed.h > > +++ b/include/drm/drm_managed.h > > @@ -127,4 +127,16 @@ void __drmm_mutex_release(struct drm_device *dev, void *res); > > drmm_add_action_or_reset(dev, __drmm_mutex_release, lock); \ > > }) \ > > > > +void __drmm_destroy_workqueue(struct drm_device *device, void *wq); > > + > > +#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_destroy_workqueue, wq); \ > > + ret ? ERR_PTR(ret) : wq; \ > > + }) : \ > > + wq; \ > > + }) > > + > > #endif > > Is there a reason to do a macro and not a proper function? I wrote a macro because creating a proper function is more complex. The function would require a va_list variant for alloc_ordered_workqueue, which does not currently exist. Louis Chauvet --- Sorry if you received this message twice. The first attempt was rejected by most of the recipients, including mailing lists. > Maxime