Received: by 10.223.164.202 with SMTP id h10csp5336832wrb; Tue, 21 Nov 2017 08:12:24 -0800 (PST) X-Google-Smtp-Source: AGs4zMZ2nvesXsUW0vSpM44Mm6shuCzbZODzswUfWkHFMFDp1sWGnkH36nVKeYYaHkERJ4EpHF2m X-Received: by 10.99.168.5 with SMTP id o5mr17687778pgf.427.1511280744076; Tue, 21 Nov 2017 08:12:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511280744; cv=none; d=google.com; s=arc-20160816; b=K7pWH95hJxiC/qtBQ6bM6lhWTm7HbVmStlhPZk98PNzqymI8yld9Ul0+nEexTrNTeP asgYFqAc281v6dZ/a5afQgA1MEaRvan8liq8e26Zq6oXh7tnu0b89wsI1nKsLewyniYr kXt2wAmVRYBbmyD1BDpLR9DGBR84zpV/G6Uug64m1TQV89Je7FroUnwcDxJyQBUNN0Ld qS7f0GzT+6F54NsS6BwlGl7C5bYu5ePsCw/3LB8CnkLYeVL6LQ/hOH/QmdUxzQOAiSgh XUn32MkuusmFHQYloID5a3Htets8j+JBYBkiAQpJ617kzGJv6WN5UBhVQg6q6rWuYx07 2Xaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:reply-to:dkim-signature :arc-authentication-results; bh=F7bDYIUdviLCSJgr6nIV/xTD2qryifGzt+23eAeW0aI=; b=b65DyvYTpM8MM5Up2Xl91bPExVk688AJiOquNu6Bb77NSO2gwEV8UZdienNOXQRQLm MNkj8A5f1aoFy5NEZMIx795vdEN4snacX9qfXiZHP4KTddBuCR9b/nXPs57Js2jCqt5d lher63VJ1h7AhwgH73yGcxOABkpLTz6mEgXQ/E2HFrCvzzFdMUfMJuljfwMmwZwO8kpi 1iWDUr8a9Kz6mk5d2kh4YU8f5BlQnPsd7FreuMxEpz/BS5BRDha0eROW1iQqAmaqBf0T HsjXSPlMfImkg7vOgzgl5/d2HDZuTTPhWk/PBq8mRRT5SYo3/z9Ete12caCHyTLLkfRl N0QQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=JU/RTggO; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a72si10934217pge.529.2017.11.21.08.12.12; Tue, 21 Nov 2017 08:12:24 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=JU/RTggO; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751516AbdKUQLj (ORCPT + 76 others); Tue, 21 Nov 2017 11:11:39 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:34257 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751187AbdKUQLd (ORCPT ); Tue, 21 Nov 2017 11:11:33 -0500 Received: by mail-wm0-f67.google.com with SMTP id y82so10612985wmg.1; Tue, 21 Nov 2017 08:11:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=reply-to:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=F7bDYIUdviLCSJgr6nIV/xTD2qryifGzt+23eAeW0aI=; b=JU/RTggOCVCI7NY4+cMfWjjMq/zBU9xFzyy+YfQDazEpiqovNvPeNGPhKfn+Y2GkS5 yTVYCdIYsGhr9luXBwLqu+GGRme45EYvqeZqIj2lAER04WSWUSZ+obncNWFVKAzUJmob W7uadmcTftnqVusf/FYAum2m129n3ZTUp6VLslZQigkIDVJaVBlmChnsfxuF2LYVgsao Zs5+GNd+7+qAG8aqLmushzGL1N6wNuiB3iT5dq4V+riIKzmE7DXanaF8xDQmttayujyZ rXC7qWZtu9wojmaPoH+GGRlohknLKUKcH7lJcGLrsTauya1jcUycmf5yV3uVLHfLkxWg w+Fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:reply-to:subject:to:cc:references:from :message-id:date:user-agent:mime-version:in-reply-to :content-transfer-encoding:content-language; bh=F7bDYIUdviLCSJgr6nIV/xTD2qryifGzt+23eAeW0aI=; b=gQneO9ENDinj3aB0lJE6miwIKxPrqtOjT7X3BMecQF4Ep9o4Wi2cgsveNcPv9JD4bI nZlpnfR+v0R9YqAAWGVfG3gB3DJ6Gg1zp3KYHoWfUbi8P3fgU68H89YiCFLG9LNr49BP 7fqshVAbRa3f++MSwJEI6iRIHtcOhxO6NH7YdVFwP0AY92DwpqEO8Drj3AU/EFYBniRP JHCducyJ31XGi2308uTId0kgsRRngfz3a2EUbrKg5jQHvyCJoK0mpj1x+CXIb7jI1DhL FfjwbKCEd8xVa8VOId8c431Yzb1/uK1cTWuA1fV/ps3rRM9AI7c1CbphULhblkTDc7B1 RX6A== X-Gm-Message-State: AJaThX5/x6hntBrwwRGTO7fEyc0FKORX0lNhaOBI1tunkiZaie/EAj0E Eik4V76N+zmRDjxhoKo1J3ncUHxR X-Received: by 10.80.167.34 with SMTP id h31mr26503982edc.43.1511280691841; Tue, 21 Nov 2017 08:11:31 -0800 (PST) Received: from ?IPv6:2a02:908:1251:7981:fcc0:d6fe:33e7:da04? ([2a02:908:1251:7981:fcc0:d6fe:33e7:da04]) by smtp.gmail.com with ESMTPSA id x38sm9848468edd.94.2017.11.21.08.11.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Nov 2017 08:11:31 -0800 (PST) Reply-To: christian.koenig@amd.com Subject: Re: [PATCH] reservation: don't wait when timeout=0 To: Chris Wilson , christian.koenig@amd.com, Rob Clark 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> <151127989753.436.17300151969206767494@mail.alporthouse.com> From: =?UTF-8?Q?Christian_K=c3=b6nig?= Message-ID: <3ab1ad07-4ed0-e533-2df1-d9a04cf6dc0a@gmail.com> Date: Tue, 21 Nov 2017 17:11:29 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <151127989753.436.17300151969206767494@mail.alporthouse.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am 21.11.2017 um 16:58 schrieb Chris Wilson: > 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. I don't find that very intuitive either, but you would also have to handle the error code in the calling function as well. And it is what the whole kernel does all over the place with it's wait_event_* and scheduler timeouts as well. Regards, Christian. > -Chris From 1584691895194275529@xxx Tue Nov 21 15:59:19 +0000 2017 X-GM-THRID: 1584685078993396088 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread