[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250821141857.26721bd6@fedora>
Date: Thu, 21 Aug 2025 14:18:57 +0200
From: Boris Brezillon <boris.brezillon@...labora.com>
To: "Danilo Krummrich" <dakr@...nel.org>
Cc: "Caterina Shablia" <caterina.shablia@...labora.com>, "Maarten Lankhorst"
<maarten.lankhorst@...ux.intel.com>, "Maxime Ripard" <mripard@...nel.org>,
"Thomas Zimmermann" <tzimmermann@...e.de>, "David Airlie"
<airlied@...il.com>, "Simona Vetter" <simona@...ll.ch>, "Frank Binns"
<frank.binns@...tec.com>, "Matt Coster" <matt.coster@...tec.com>, "Karol
Herbst" <kherbst@...hat.com>, "Lyude Paul" <lyude@...hat.com>, "Steven
Price" <steven.price@....com>, "Liviu Dudau" <liviu.dudau@....com>, "Lucas
De Marchi" <lucas.demarchi@...el.com>, Thomas Hellström
<thomas.hellstrom@...ux.intel.com>, "Rodrigo Vivi"
<rodrigo.vivi@...el.com>, <dri-devel@...ts.freedesktop.org>,
<linux-kernel@...r.kernel.org>, <nouveau@...ts.freedesktop.org>,
<intel-xe@...ts.freedesktop.org>, <asahi@...ts.linux.dev>, "Asahi Lina"
<lina@...hilina.net>
Subject: Re: [PATCH v4 4/7] drm/gpuvm: Add a helper to check if two VA can
be merged
On Mon, 07 Jul 2025 21:06:50 +0200
"Danilo Krummrich" <dakr@...nel.org> wrote:
> On Mon Jul 7, 2025 at 9:00 PM CEST, Danilo Krummrich wrote:
> > On Mon Jul 7, 2025 at 7:04 PM CEST, Caterina Shablia wrote:
> >> diff --git a/drivers/gpu/drm/drm_gpuvm.c b/drivers/gpu/drm/drm_gpuvm.c
> >> index 05978c5c38b1..dc3c2f906400 100644
> >> --- a/drivers/gpu/drm/drm_gpuvm.c
> >> +++ b/drivers/gpu/drm/drm_gpuvm.c
> >> @@ -2098,12 +2098,48 @@ op_unmap_cb(const struct drm_gpuvm_ops *fn, void *priv,
> >> return fn->sm_step_unmap(&op, priv);
> >> }
> >>
> >> +static bool can_merge(struct drm_gpuvm *gpuvm, const struct drm_gpuva *a,
> >> + const struct drm_gpuva *b)
> >> +{
> >> + /* Only GEM-based mappings can be merged, and they must point to
> >> + * the same GEM object.
> >> + */
> >> + if (a->gem.obj != b->gem.obj || !a->gem.obj)
> >> + return false;
> >> +
> >> + /* Let's keep things simple for now and force all flags to match. */
> >> + if (a->flags != b->flags)
> >> + return false;
>
> Forgot to mention, this can include driver specific flags. How do we know from
> the generic code whether this condition makes sense? *At least* it would need to
> be documented.
You're right, it should have been:
if ((a->flags & DRM_GPUVA_MERGEABLE_FLAGS_MASK) !=
(b->flags & DRM_GPUVA_MERGEABLE_FLAGS_MASK))
return false;
with DRM_GPUVA_COMMON_FLAGS_MASK set to the set of flags that matter
when merging.
>
> However, I think it would be better to provide an optional callback for drivers
> to check whether merge makes sense or not. This doesn't mean we need drivers to
> do those common checks, this can remain here in the common code.
Seems a bit premature to me. Again, if there's a need for drivers to add
extra checks we can always add a callback at this point, but until
this is the case, I'd rather stick to these common checks.
Powered by blists - more mailing lists