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 96786CA0EEB for ; Thu, 21 Aug 2025 12:19:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4775910E962; Thu, 21 Aug 2025 12:19:07 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=collabora.com header.i=@collabora.com header.b="LlldnUvb"; dkim-atps=neutral Received: from bali.collaboradmins.com (bali.collaboradmins.com [148.251.105.195]) by gabe.freedesktop.org (Postfix) with ESMTPS id C43A510E95F; Thu, 21 Aug 2025 12:19:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1755778744; bh=bFU9XiPsxjfmEfPRcMGGVE6IuhV4+uSXPKLukn2eMZQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=LlldnUvbdDItwIr0fva3L0VBACLEsvOo3kfYmC7RsQ2UjHiJhshdjDobOyLxiRj95 axyQ4+VFtMviqwLn9VciweCumcVNmY+Y5HOivhZ+LSywkQgO0lhl6GVM1g+S6Wgt4A QSxMF5m9vh6T/uluedoz7qexQNjpID8VvKl+ddoCNBlhwo2iPDiHobTVP8jKDe4Ikg eOIPpy1GUjwG5d2D3RSVzUoqwq/ot2bzJI/QhiYKa+nQRKMXAy0JjRv94OT3x2j+e1 h45hhdqxmoERCXz988lEmo41O7MOa/iok5tILLQXsebmkDBFYchBRZpvGrbDqfa4nh /8MbJjFNbkz5A== 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 96E7317E0071; Thu, 21 Aug 2025 14:19:03 +0200 (CEST) Date: Thu, 21 Aug 2025 14:18:57 +0200 From: Boris Brezillon To: "Danilo Krummrich" Cc: "Caterina Shablia" , "Maarten Lankhorst" , "Maxime Ripard" , "Thomas Zimmermann" , "David Airlie" , "Simona Vetter" , "Frank Binns" , "Matt Coster" , "Karol Herbst" , "Lyude Paul" , "Steven Price" , "Liviu Dudau" , "Lucas De Marchi" , Thomas =?UTF-8?B?SGVsbHN0csO2bQ==?= , "Rodrigo Vivi" , , , , , , "Asahi Lina" Subject: Re: [PATCH v4 4/7] drm/gpuvm: Add a helper to check if two VA can be merged Message-ID: <20250821141857.26721bd6@fedora> In-Reply-To: References: <20250707170442.1437009-1-caterina.shablia@collabora.com> <20250707170442.1437009-5-caterina.shablia@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=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-xe-bounces@lists.freedesktop.org Sender: "Intel-xe" On Mon, 07 Jul 2025 21:06:50 +0200 "Danilo Krummrich" 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.