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 CF382CD3430 for ; Mon, 4 May 2026 14:47:39 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 250A410E3CD; Mon, 4 May 2026 14:47:39 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=igalia.com header.i=@igalia.com header.b="n1dcg+Z3"; dkim-atps=neutral Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by gabe.freedesktop.org (Postfix) with ESMTPS id D9D2310E3CD for ; Mon, 4 May 2026 14:47:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:Cc:To:Subject:MIME-Version:Date:Message-ID:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=bF093xAPwSthM1dr3VtL1tG7V51VIWOVIPRGgKsB52M=; b=n1dcg+Z3AQtAw5a3tDALjkKsLp 5G5nxfN7FLUV2jz2OciuekkLEXDvLNwFyL+OWufulMRuixmMBDNWutJvMPDefVqaiyHre2iOPxET4 6976q7P/JlLUY+bYZ+V6Msl2sHcH2NVf/4eUZ2noBV+0aQ4e1zR4qmHDVkEkIwBNAzs9rNEXcS4CL UaBcUxwWI70k9XLRqbDxubqveH5OvX5qNmqebPIqPj1/IsvAgF1AeBCHQ0ry62TqQKILrVGZnlLz4 koW/5FjhAeWSjeqlYtV1+mexaJM8y3SYDnhN5oXMDyX07s7cTO0dVhCVSQXIMkTjnLqEgo6k0CIJO uMUzk2Tw==; Received: from [189.7.87.137] (helo=[192.168.0.5]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_128_GCM:128) (Exim) id 1wJuZu-005zRP-MK; Mon, 04 May 2026 16:47:22 +0200 Message-ID: Date: Mon, 4 May 2026 11:47:14 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] dma-fence: Clarify external lock use case in dma_fence_init() docs To: phasta@kernel.org, =?UTF-8?Q?Christian_K=C3=B6nig?= , Sumit Semwal , Boris Brezillon , Tvrtko Ursulin Cc: dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, kernel-dev@igalia.com References: <20260419134943.54833-2-mcanal@igalia.com> <6389c57fd1453b545709c15c5fa74aa76a3d9afa.camel@mailbox.org> From: =?UTF-8?Q?Ma=C3=ADra_Canal?= Content-Language: en-US Autocrypt: addr=mcanal@igalia.com; keydata= xsBNBGcCwywBCADgTji02Sv9zjHo26LXKdCaumcSWglfnJ93rwOCNkHfPIBll85LL9G0J7H8 /PmEL9y0LPo9/B3fhIpbD8VhSy9Sqz8qVl1oeqSe/rh3M+GceZbFUPpMSk5pNY9wr5raZ63d gJc1cs8XBhuj1EzeE8qbP6JAmsL+NMEmtkkNPfjhX14yqzHDVSqmAFEsh4Vmw6oaTMXvwQ40 SkFjtl3sr20y07cJMDe++tFet2fsfKqQNxwiGBZJsjEMO2T+mW7DuV2pKHr9aifWjABY5EPw G7qbrh+hXgfT+njAVg5+BcLz7w9Ju/7iwDMiIY1hx64Ogrpwykj9bXav35GKobicCAwHABEB AAHNIE1hw61yYSBDYW5hbCA8bWNhbmFsQGlnYWxpYS5jb20+wsCRBBMBCAA7FiEE+ORdfQEW dwcppnfRP/MOinaI+qoFAmcCwywCGwMFCwkI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UTepw4OwuPxOvtuPTUa1kgixYyG1Jck/67reJzMigeuYFt raV3P8t/6cmtawVjurhnCDuURyhUrjpRhgFp+lW8OGr6pepHol/WFIOQEg== In-Reply-To: <6389c57fd1453b545709c15c5fa74aa76a3d9afa.camel@mailbox.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Hi Christian, When possible, could you take a look at this patch? If you are okay with it, I can apply it to drm-misc-next. Best regards, - Maíra On 20/04/26 06:18, Philipp Stanner wrote: > On Sun, 2026-04-19 at 10:48 -0300, Maíra Canal wrote: >> The kerneldoc comment on dma_fence_init() and dma_fence_init64() describe >> the legacy reason to pass an external lock as a need to prevent multiple >> fences "from signaling out of order". However, this wording is a bit >> misleading: a shared spinlock does not (and cannot) prevent the signaler >> from signaling out of order. Signaling order is the driver's responsibility >> regardless of whether the lock is shared or per-fence. >> >> What a shared lock actually provides is serialization of signaling and >> observation across fences in a given context, so that observers never >> see a later fence signaled while an earlier one is not. >> >> Reword both comments to describe this more accurately. >> >> Signed-off-by: Maíra Canal > > Reviewed-by: Philipp Stanner > >> >> --- >> >> v1 -> v2: https://lore.kernel.org/dri-devel/20260411185756.1887119-4-mcanal@igalia.com/ >> >> - Be more explicit about not allowing new users to use an external lock. >> - De-duplicate the explanation in dma_fence_init64() by pointing to the >>   dma_fence_init() documentation. >> --- >>  drivers/dma-buf/dma-fence.c | 13 +++++++------ >>  1 file changed, 7 insertions(+), 6 deletions(-) >> >> diff --git a/drivers/dma-buf/dma-fence.c b/drivers/dma-buf/dma-fence.c >> index 1c1eaecaf1b0..63b349ba9a34 100644 >> --- a/drivers/dma-buf/dma-fence.c >> +++ b/drivers/dma-buf/dma-fence.c >> @@ -1102,9 +1102,11 @@ __dma_fence_init(struct dma_fence *fence, const struct dma_fence_ops *ops, >>   * context and seqno are used for easy comparison between fences, allowing >>   * to check which fence is later by simply using dma_fence_later(). >>   * >> - * It is strongly discouraged to provide an external lock because this couples >> - * lock and fence life time. This is only allowed for legacy use cases when >> - * multiple fences need to be prevented from signaling out of order. >> + * External locks are a relic from legacy use cases that needed a shared lock >> + * to serialize signaling and observation of fences within a context, so that >> + * observers never see a later fence signaled while an earlier one isn't. New >> + * users MUST NOT use external locks, as they force the issuer to outlive all >> + * fences that reference the lock. >>   */ >>  void >>  dma_fence_init(struct dma_fence *fence, const struct dma_fence_ops *ops, >> @@ -1129,9 +1131,8 @@ EXPORT_SYMBOL(dma_fence_init); >>   * Context and seqno are used for easy comparison between fences, allowing >>   * to check which fence is later by simply using dma_fence_later(). >>   * >> - * It is strongly discouraged to provide an external lock because this couples >> - * lock and fence life time. This is only allowed for legacy use cases when >> - * multiple fences need to be prevented from signaling out of order. >> + * New users MUST NOT use external locks. Check the documentation in >> + * dma_fence_init() to understand the motives behind the legacy use cases. >>   */ >>  void >>  dma_fence_init64(struct dma_fence *fence, const struct dma_fence_ops *ops, >