From patchwork Sat Apr 8 16:26:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 9671109 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7D976601EB for ; Sat, 8 Apr 2017 16:26:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F6A028489 for ; Sat, 8 Apr 2017 16:26:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 40B74284F4; Sat, 8 Apr 2017 16:26:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 96C4A28489 for ; Sat, 8 Apr 2017 16:26:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 78F216E01B; Sat, 8 Apr 2017 16:26:08 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x241.google.com (mail-wm0-x241.google.com [IPv6:2a00:1450:400c:c09::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id A81626E01B; Sat, 8 Apr 2017 16:26:07 +0000 (UTC) Received: by mail-wm0-x241.google.com with SMTP id o81so2909298wmb.0; Sat, 08 Apr 2017 09:26:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=p0v4UCOy7JFcqSQ2xPA7qJrgPC5pHD5/yjRubBmGuGw=; b=AZTn0HSTjfqpanRpUzx3QHx0LZ82gwrY6exAt8w5KiSs14Qiw7K+oBKPGGWAZHk9BI ecJLfZQyYot9u+tqvz6cFW7d0MQYAHbV+alc/bOI7SvIUzYiWUqfKwQGcBOBSzq36c4S U/IMYnhii50/7TGepcsaDCxpUdkdcjgbIxidftKfSyiRPF4UqbN9CevTGLN4GF8iW3nX mgPg2Pc+cReZWp4DVnBbFwpROnpDD6Toi+XHid0n2420y0vjdB0M0MR0iAvB3WdImfj2 h24RZ4//PIVOpSafZUWo91+4h+TUlwzOZjef5Rz/LHLOLFXh5eqYdHlOKsGUp4lE7ry6 BfKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=p0v4UCOy7JFcqSQ2xPA7qJrgPC5pHD5/yjRubBmGuGw=; b=HJ9ze7UfFlLY1zI7UEyOnx4AP/ToCMU243pHJL2Md/M5kFNpy4s+gVul0NomnU7YXS Rcb7jVvxVNV8PNx0UfiqyVlNDnV+Z/mUUg+7+TwqJT/i2QlxmXEW3sXXl++v0KN1cB73 2hMintJb4fWGpQQN0bd40hZWuQuZ/ISsDMrhLGXoC4wO3tRWoesNEcfDFVygnIAISPH9 lMlJMSowOAbdgG0b47VBEWTLtjWcRcRbQ1/VelVKePIxYSEfLMitMf6E5DrV307MKDeV 4dmXExLAj7EnYOx80mkgNeyRG2Ck0ssfC4NW+SdfQRGmCq72BbZHe3crqCUC7RQWxyRW 9kBQ== X-Gm-Message-State: AN3rC/4vx5KFAKuUmYRAc7KHACrlmDuIDhXOldKep2G00TXM6SUDQNJu4oOuogLsxpGLKg== X-Received: by 10.28.9.15 with SMTP id 15mr3931463wmj.83.1491668766131; Sat, 08 Apr 2017 09:26:06 -0700 (PDT) Received: from haswell.alporthouse.com ([78.156.65.138]) by smtp.gmail.com with ESMTPSA id 191sm3256856wmv.25.2017.04.08.09.26.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 08 Apr 2017 09:26:05 -0700 (PDT) From: Chris Wilson To: dri-devel@lists.freedesktop.org Subject: [PATCH 1/3] dma-fence: Reserve 0 as a special NO_CONTEXT token Date: Sat, 8 Apr 2017 17:26:01 +0100 Message-Id: <20170408162603.28305-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Cc: intel-gfx@lists.freedesktop.org, Joonas Lahtinen , Daniel Vetter , Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 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" X-Virus-Scanned: ClamAV using ClamSMTP Reserve 0 for general use a token meaning that the fence doesn't belong to an ordered timeline (fence context). Signed-off-by: Chris Wilson Cc: Sumit Semwal Cc: Gustavo Padovan Cc: Joonas Lahtinen Cc: "Christian König" Cc: Alex Deucher --- drivers/dma-buf/dma-fence.c | 4 +++- include/linux/dma-fence.h | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/dma-buf/dma-fence.c b/drivers/dma-buf/dma-fence.c index 0918d3f003d6..0646357ea350 100644 --- a/drivers/dma-buf/dma-fence.c +++ b/drivers/dma-buf/dma-fence.c @@ -36,8 +36,10 @@ EXPORT_TRACEPOINT_SYMBOL(dma_fence_enable_signal); * fence context, this allows checking if fences belong to the same * context or not. One device can have multiple separate contexts, * and they're used if some engine can run independently of another. + * + * 0 is excluded and treated as a special DMA_FENCE_NO_CONTEXT. */ -static atomic64_t dma_fence_context_counter = ATOMIC64_INIT(0); +static atomic64_t dma_fence_context_counter = ATOMIC64_INIT(1); /** * dma_fence_context_alloc - allocate an array of fence contexts diff --git a/include/linux/dma-fence.h b/include/linux/dma-fence.h index 6048fa404e57..adfdc7fdd9c3 100644 --- a/include/linux/dma-fence.h +++ b/include/linux/dma-fence.h @@ -455,6 +455,8 @@ static inline signed long dma_fence_wait(struct dma_fence *fence, bool intr) return ret < 0 ? ret : 0; } +#define DMA_FENCE_NO_CONTEXT ((u64)0) + u64 dma_fence_context_alloc(unsigned num); #define DMA_FENCE_TRACE(f, fmt, args...) \