Received: by 10.223.164.202 with SMTP id h10csp5318805wrb; Tue, 21 Nov 2017 07:59:19 -0800 (PST) X-Google-Smtp-Source: AGs4zMb5+a47k6b4VScfeSEdDcwV3D4MtaIGOaXz40JGMkUvpK5v4DOEFi5SrvFSvCJF7LL6O1k3 X-Received: by 10.84.131.40 with SMTP id 37mr18104143pld.302.1511279959880; Tue, 21 Nov 2017 07:59:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511279959; cv=none; d=google.com; s=arc-20160816; b=hoL1VJRccuqH8rkGml6/RA2yhT82/o8Crdl+eMio6p3AA20G+spnc11un1NYsJxZMd 5xwDmPECvTBBkJi0aoTRY1xt7j4iFRgt4RVkPDm5rLm9K21ncUXTCeZNIozSOQXIz/qL exuCqe4m1IAaqIcxJxNnURvOK/xdZ+/oGcR78k1ML0IviAFMyukyhpeAn5UKfbot7yFR BT5qT7yhpy7pYkoeQAIXQAxB+ipI5rZgo12aWUcMGt8unuROwJ3Sf7h11Yn+qyrfrhel 7K9/Fp5pfCPw6V3RhCiS/F+55UWhAWO4MjSWeTAaUWDFTCGSm7dZSddYnAkRCmo6MB2+ 6c7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:subject:user-agent:message-id :references:cc:in-reply-to:from:to:content-transfer-encoding :mime-version:arc-authentication-results; bh=5U7wqtRNiwXknfw150k+fqwMOdmTVOF8EaXLLoeTJnM=; b=sT3qSikrWO7z4sdI76XNACm32iHU9U4+F6XDIpFwl+D6GVWqPhTQO1ovF3dFWhOhEv UrGgrwn7zpeQENr6y+Fs8370/Wxjbp3aSr1YUntq5oHm6AP5b+dyrfrOYGc0F5WOoJi2 J09hs7LnIu+mLoMNFz/7FH5Be1ZYsVOviX5BASN7IfefTy+utwzN39A/3SQ0AG5Qy33k kHbIH687Vu2Rb9cVMBfQtRr/K/7qlAvSKHjqNseeMa4/rcji/TCqSMC2L9rmd9kXUc8B m7Jex/tM5kHikSvkK0FHBOt3JLo3lYhHiH0xDN5+s0lLXDWULy3CtTk3ZOR8xBhF8IIP GP8Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o3si9342321plk.45.2017.11.21.07.59.08; Tue, 21 Nov 2017 07:59:19 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751322AbdKUP6Z convert rfc822-to-8bit (ORCPT + 76 others); Tue, 21 Nov 2017 10:58:25 -0500 Received: from mail.fireflyinternet.com ([109.228.58.192]:52893 "EHLO fireflyinternet.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751067AbdKUP6Y (ORCPT ); Tue, 21 Nov 2017 10:58:24 -0500 X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.65.138; Received: from localhost (unverified [78.156.65.138]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP (TLS) id 9678498-1500050 for multiple; Tue, 21 Nov 2017 15:58:19 +0000 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8BIT To: christian.koenig@amd.com, =?utf-8?q?Christian_K=C3=B6nig?= , "Rob Clark" From: Chris Wilson In-Reply-To: <83c7c887-0d40-69b5-2ad2-67d0af6eda71@gmail.com> Cc: "linaro-mm-sig@lists.linaro.org" , "Linux Kernel Mailing List" , "dri-devel@lists.freedesktop.org" , "linux-media@vger.kernel.org" References: <20171121140850.23401-1-robdclark@gmail.com> <151127508188.436.3320065005004428970@mail.alporthouse.com> <83c7c887-0d40-69b5-2ad2-67d0af6eda71@gmail.com> Message-ID: <151127989753.436.17300151969206767494@mail.alporthouse.com> User-Agent: alot/0.3.6 Subject: Re: [PATCH] reservation: don't wait when timeout=0 Date: Tue, 21 Nov 2017 15:58:17 +0000 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Christian König (2017-11-21 15:49:55) > Am 21.11.2017 um 15:59 schrieb Rob Clark: > > On Tue, Nov 21, 2017 at 9:38 AM, Chris Wilson wrote: > >> Quoting Rob Clark (2017-11-21 14:08:46) > >>> If we are testing if a reservation object's fences have been > >>> signaled with timeout=0 (non-blocking), we need to pass 0 for > >>> timeout to dma_fence_wait_timeout(). > >>> > >>> Plus bonus spelling correction. > >>> > >>> Signed-off-by: Rob Clark > >>> --- > >>> drivers/dma-buf/reservation.c | 11 +++++++++-- > >>> 1 file changed, 9 insertions(+), 2 deletions(-) > >>> > >>> diff --git a/drivers/dma-buf/reservation.c b/drivers/dma-buf/reservation.c > >>> index dec3a815455d..71f51140a9ad 100644 > >>> --- a/drivers/dma-buf/reservation.c > >>> +++ b/drivers/dma-buf/reservation.c > >>> @@ -420,7 +420,7 @@ EXPORT_SYMBOL_GPL(reservation_object_get_fences_rcu); > >>> * > >>> * RETURNS > >>> * Returns -ERESTARTSYS if interrupted, 0 if the wait timed out, or > >>> - * greater than zer on success. > >>> + * greater than zero on success. > >>> */ > >>> long reservation_object_wait_timeout_rcu(struct reservation_object *obj, > >>> bool wait_all, bool intr, > >>> @@ -483,7 +483,14 @@ long reservation_object_wait_timeout_rcu(struct reservation_object *obj, > >>> goto retry; > >>> } > >>> > >>> - ret = dma_fence_wait_timeout(fence, intr, ret); > >>> + /* > >>> + * Note that dma_fence_wait_timeout() will return 1 if > >>> + * the fence is already signaled, so in the wait_all > >>> + * case when we go through the retry loop again, ret > >>> + * will be greater than 0 and we don't want this to > >>> + * cause _wait_timeout() to block > >>> + */ > >>> + ret = dma_fence_wait_timeout(fence, intr, timeout ? ret : 0); > >> One should ask if we should just fix the interface to stop returning > >> incorrect results (stop "correcting" a completion with 0 jiffies remaining > >> as 1). A timeout can be distinguished by -ETIME (or your pick of errno). > > perhaps -EBUSY, if we go that route (although maybe it should be a > > follow-on patch, this one is suitable for backport to stable/lts if > > one should so choose..) > > > > I think current approach was chosen to match schedule_timeout() and > > other such functions that take a timeout in jiffies. Not making a > > judgement on whether that is a good or bad reason.. > > We intentionally switched away from that to be in sync with the > wait_event_* interface. > > Returning 1 when a function with a zero timeout succeeds is actually > quite common in the kernel. We actually had this conversation last time, and outside of that it isn't. Looking at all the convolution to first return 1, then undo the damage in the caller, it looks pretty silly. -Chris From 1584691375086675501@xxx Tue Nov 21 15:51:03 +0000 2017 X-GM-THRID: 1584685078993396088 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread