From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 98150CCF9E3 for ; Thu, 30 Oct 2025 14:35:35 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3EEB310E272; Thu, 30 Oct 2025 14:35:35 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=collabora.com header.i=@collabora.com header.b="K+zr7UEo"; dkim-atps=neutral Received: from bali.collaboradmins.com (bali.collaboradmins.com [148.251.105.195]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0554E10E272; Thu, 30 Oct 2025 14:35:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1761834932; bh=XsFKQJcZnJq+uVlimqD2hH4Nr2x6cyzczLSyOoOVMuw=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=K+zr7UEo7Wmw/Aoy4KfKJPjv63v6cGvsD2lVmsY36nxMHj5zDLdKq7zLA1O1PfmIM ZC9IR5GHfadpUAb7sy4g9PVuNb5W1GWsvLkNYvWduNnPzwDwt4kEiRxdUDg4xpadiu Y67XOk0UH5wbdCmykHAaWaHusxW6Epihna8JKbLEUWK+iWZG2NrqFUa8uGwUxrkhv3 XqtvUIERm1++tiyWUfgDad0UtHVBQLGl/qJAeTDy0UlquIHiEmtqQgkah2BH210YQ7 JRkNDmVmxFssAlRCKAnkrLSCjqfM3Y7E5t6fjJrIfJENWxJ4HvzqmzrndT5mz6MuMC KxewZKvSmqADA== Received: from fedora (unknown [IPv6:2a01:e0a:2c:6930:d919:a6e:5ea1:8a9f]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bbrezillon) by bali.collaboradmins.com (Postfix) with ESMTPSA id 758C817E00A6; Thu, 30 Oct 2025 15:35:31 +0100 (CET) Date: Thu, 30 Oct 2025 15:35:03 +0100 From: Boris Brezillon To: Christian =?UTF-8?B?S8O2bmln?= Cc: Steven Price , dri-devel@lists.freedesktop.org, Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Faith Ekstrand , Thierry Reding , Mikko Perttunen , Melissa Wen , =?UTF-8?B?TWHDrXJh?= Canal , Lucas De Marchi , Thomas =?UTF-8?B?SGVsbHN0csO2bQ==?= , Rodrigo Vivi , Frank Binns , Matt Coster , Rob Clark , Dmitry Baryshkov , Abhinav Kumar , Jessica Zhang , Sean Paul , Marijn Suijten , Alex Deucher , amd-gfx@lists.freedesktop.org, kernel@collabora.com Subject: Re: [PATCH v5 01/16] drm/prime: Simplify life of drivers needing custom dma_buf_ops Message-ID: <20251030153503.59a8717b@fedora> In-Reply-To: References: <20251030140525.366636-1-boris.brezillon@collabora.com> <20251030140525.366636-2-boris.brezillon@collabora.com> Organization: Collabora X-Mailer: Claws Mail 4.3.1 (GTK 3.24.49; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: amd-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion list for AMD gfx List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: amd-gfx-bounces@lists.freedesktop.org Sender: "amd-gfx" On Thu, 30 Oct 2025 15:25:50 +0100 Christian K=C3=B6nig wrote: > On 10/30/25 15:05, Boris Brezillon wrote: > > drm_gem_is_prime_exported_dma_buf() checks the dma_buf->ops against > > drm_gem_prime_dmabuf_ops, which makes it impossible to use if the > > driver implements custom dma_buf_ops. Instead of duplicating a bunch > > of helpers to work around it, let's provide a way for drivers to > > expose their custom dma_buf_ops so the core prime helpers can rely on > > that instead of hardcoding &drm_gem_prime_dmabuf_ops. =20 >=20 > That's generally nice to have, I've re-implemented quite a number of func= tions in amdgpu because of this as well. >=20 > >=20 > > v5: > > - New patch > >=20 > > Signed-off-by: Boris Brezillon > > --- > > drivers/gpu/drm/drm_prime.c | 14 +++++++++++--- > > include/drm/drm_drv.h | 8 ++++++++ > > 2 files changed, 19 insertions(+), 3 deletions(-) > >=20 > > diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c > > index 43a10b4af43a..3796844af418 100644 > > --- a/drivers/gpu/drm/drm_prime.c > > +++ b/drivers/gpu/drm/drm_prime.c > > @@ -903,6 +903,15 @@ unsigned long drm_prime_get_contiguous_size(struct= sg_table *sgt) > > } > > EXPORT_SYMBOL(drm_prime_get_contiguous_size); > > =20 > > +static const struct dma_buf_ops * > > +drm_gem_prime_get_dma_buf_ops(struct drm_device *dev) > > +{ > > + if (dev->driver->gem_prime_get_dma_buf_ops) > > + return dev->driver->gem_prime_get_dma_buf_ops(dev); =20 >=20 > I have strong doubts that a driver changes their dma_buf ops during their= runtime, so instead of a callback could we just have it as pointer in drm_= driver? Sure thing, I considered doing that too actually.