Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1049344rwb; Wed, 9 Nov 2022 12:03:24 -0800 (PST) X-Google-Smtp-Source: AMsMyM4LHPPJI2AxK9YF5LvPflHDUDrgYLVkSg9tTvjnGyemjqV+qrSoQvbw3CtTRckn7llXs9u+ X-Received: by 2002:aa7:cb87:0:b0:43b:e650:6036 with SMTP id r7-20020aa7cb87000000b0043be6506036mr61539051edt.350.1668024204013; Wed, 09 Nov 2022 12:03:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668024204; cv=none; d=google.com; s=arc-20160816; b=vfpaGsC7M/S5Pj20QZhG1xLvM+m1HeIX5d9ghLJS9KcHTR5geGFbH6SQA+5+fpnOQY 9TgkmEhuIzTlc0mWraXPh/6+rgDzcKJ1+xDhUowpUELA3OimzLTrooM7OUsLem37pkm2 DEXBb2OzpZI74JMRNWbz3wWjUQw5uYoBdR1Hjg4Hodm/a+/0enKnW3mH70V4yylG5k5I awJ+a23iwSI+EFeyuYfHdkuAxDiFi3cfnaGWxAj0v1jdOGBMO7Dp2zfabJo4QTFkC0/3 fz4aMteVnyB73xBuVt9Ib3s0LESomaMdjgMm+Am23k3z9ME9h/qUCr/4nUrOuv5UwRih iRaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=usHXXQzAxjv86jFgd79YpGBPc136eS58Mj78h556ISE=; b=IKUWtenfgy6FDQpTsCw4HIt5E2Sxp/OZGhp9qgEooe/1n4ttWZ21SJvETZPy8iE1nA LIsxIO6ZPtPFl2axfk9NjSocnxtJwCdkIURwJnAvYb6vxS30A8KRkzaVU/Xdyqt6EWcb rBD9guMER6MR8GwnkLp0xXf7FUrY+Qqn9bKVHgU2UgleOrfRpfEoFyNvlrK4okFst+1t O2fkvcGCiDAZEazKBl9WNdZIPkiP+7G37NPud6ujz/AxpBfG8PYS7EYAwj1VoqpSOlno qlOonGO+uVWzMhLw6qN+cCEX+DP2Y4Zw89QwLW+gCT8N9ZdxTX7JFeOuaH1uYVyUxneO Iv2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JRI19WQr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b15-20020a056402350f00b004599ae68f98si18050684edd.136.2022.11.09.12.03.01; Wed, 09 Nov 2022 12:03:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JRI19WQr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231283AbiKITK7 (ORCPT + 92 others); Wed, 9 Nov 2022 14:10:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230386AbiKITK5 (ORCPT ); Wed, 9 Nov 2022 14:10:57 -0500 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4736A22B0F for ; Wed, 9 Nov 2022 11:10:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668021055; x=1699557055; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6LAVoH57Z67SFgpBICBCC2rV+kEpQgeJZ63fSc0PrTQ=; b=JRI19WQrFJqMSWfbmc1zS75DfsR8UcWaUM4uhbvQMy7YTy4xXgS3hGag wJBCTTOKjD1GYPHsJP88xXA4uWD0tVN3f17NPrDJjmpvaguETY+lD9g8B CMOoJMDLt2IAUsycjlFdCcgy9WkxamQjxXCP6Fh3oZQaMIaTlH28ZDeM8 4btzWkgtHGtKX12sInVdvMCTFzRDTcsdKEmlrX/NLroaesLFZrhKEEBeP IW7IAUhl/0goHo/CkAyan/TZToLt8IZxzQgq8efEB40tmfwocpzVXAcMi dsKf3etMSVfRBG9ilMtUNmVfK9ZHaI3eT64Z2QOo0Ygo6fLAFwVX64PJ6 Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10526"; a="312234715" X-IronPort-AV: E=Sophos;i="5.96,151,1665471600"; d="scan'208";a="312234715" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2022 11:10:53 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10526"; a="668105979" X-IronPort-AV: E=Sophos;i="5.96,151,1665471600"; d="scan'208";a="668105979" Received: from jkrzyszt-mobl1.ger.corp.intel.com ([10.213.6.201]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2022 11:10:30 -0800 From: Janusz Krzysztofik To: Joonas Lahtinen Cc: Jani Nikula , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Daniel Vetter , Chris Wilson , intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] drm/i915: Fix 0 return value from DMA fence wait on i915 requests Date: Wed, 9 Nov 2022 20:09:37 +0100 Message-Id: <20221109190937.64155-4-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221109190937.64155-1-janusz.krzysztofik@linux.intel.com> References: <20221109190937.64155-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org According to the docs, dma_fence_wait_timeout() returns "0 if the wait timed out," ... "Other error values may be returned on custom implementations." While it is not quite clear if a custom implementation is allowed to return "other error" instead of 0, it is rather clear that 0 return value should always mean that the wait timed out before the fence got signaled. i915 implementation of dma_fence_ops.wait() used with request fences, which is a transparent wrapper around i915_request_wait_timeout(), returns -ETIME if the wait has timed out -- that may be considered as acceptable. However, it can return 0 in a rare case when the fence has been found signaled right after no more wait time was left, and that's not compatible with expectations of dma-fence and its users. Since other users of i915_request_wait_timeout() may interpret 0 return value as success, don't touch it, update the i915_fence_wait() wrapper instead. Return 1 instead of 0, but keep -ETIME in case of timeout since some i915 users of dma_fence_wait_timeout() may expect it. Signed-off-by: Janusz Krzysztofik --- drivers/gpu/drm/i915/i915_request.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/i915_request.c b/drivers/gpu/drm/i915/i915_request.c index f949a9495758a..451456ab1ddef 100644 --- a/drivers/gpu/drm/i915/i915_request.c +++ b/drivers/gpu/drm/i915/i915_request.c @@ -102,7 +102,7 @@ static signed long i915_fence_wait(struct dma_fence *fence, { return i915_request_wait_timeout(to_request(fence), interruptible | I915_WAIT_PRIORITY, - timeout); + timeout) ?: 1; } struct kmem_cache *i915_request_slab_cache(void) -- 2.25.1