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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4B29FC433F5 for ; Mon, 13 Dec 2021 10:04:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239781AbhLMKEu (ORCPT ); Mon, 13 Dec 2021 05:04:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239497AbhLMJ7g (ORCPT ); Mon, 13 Dec 2021 04:59:36 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0ED00C09B10C; Mon, 13 Dec 2021 01:48:55 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id CAF71B80E16; Mon, 13 Dec 2021 09:48:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 18317C33A41; Mon, 13 Dec 2021 09:48:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1639388932; bh=0z+eY2f3dsDVB38otw6CYVFtegDwxCN2FcFSsw+EoPY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rOlnN+V1to7Cp5EhMRkSk8iZFG2KpPfbrvhF6uukaZMEjC72/0Qg0fTWWAOTnImCU tn2IwLDPVNTBO1d+Owm2Sd35EvjibyOpLKJJxTZAChj8gZDIgIoBvnYNxJ6X745mj7 pxRfE3S2xwfJ8W+Z0ZDep2I7Vh5leeSebxqLEm0s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bas Nieuwenhuizen , =?UTF-8?q?Christian=20K=C3=B6nig?= , Lionel Landwerlin Subject: [PATCH 5.10 060/132] drm/syncobj: Deal with signalled fences in drm_syncobj_find_fence. Date: Mon, 13 Dec 2021 10:30:01 +0100 Message-Id: <20211213092941.177986537@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20211213092939.074326017@linuxfoundation.org> References: <20211213092939.074326017@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bas Nieuwenhuizen commit b19926d4f3a660a8b76e5d989ffd1168e619a5c4 upstream. dma_fence_chain_find_seqno only ever returns the top fence in the chain or an unsignalled fence. Hence if we request a seqno that is already signalled it returns a NULL fence. Some callers are not prepared to handle this, like the syncobj transfer functions for example. This behavior is "new" with timeline syncobj and it looks like not all callers were updated. To fix this behavior make sure that a successful drm_sync_find_fence always returns a non-NULL fence. v2: Move the fix to drm_syncobj_find_fence from the transfer functions. Fixes: ea569910cbab ("drm/syncobj: add transition iotcls between binary and timeline v2") Cc: stable@vger.kernel.org Signed-off-by: Bas Nieuwenhuizen Reviewed-by: Christian König Acked-by: Lionel Landwerlin Signed-off-by: Christian König Link: https://patchwork.freedesktop.org/patch/msgid/20211208023935.17018-1-bas@basnieuwenhuizen.nl Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/drm_syncobj.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) --- a/drivers/gpu/drm/drm_syncobj.c +++ b/drivers/gpu/drm/drm_syncobj.c @@ -391,8 +391,17 @@ int drm_syncobj_find_fence(struct drm_fi if (*fence) { ret = dma_fence_chain_find_seqno(fence, point); - if (!ret) + if (!ret) { + /* If the requested seqno is already signaled + * drm_syncobj_find_fence may return a NULL + * fence. To make sure the recipient gets + * signalled, use a new fence instead. + */ + if (!*fence) + *fence = dma_fence_get_stub(); + goto out; + } dma_fence_put(*fence); } else { ret = -EINVAL;