From patchwork Thu May 3 14:25:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 10378487 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 BFA12603B4 for ; Thu, 3 May 2018 14:26:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ACF9129194 for ; Thu, 3 May 2018 14:26:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A200029197; Thu, 3 May 2018 14:26:24 +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=-5.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,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 2DDE729194 for ; Thu, 3 May 2018 14:26:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2ADB16E6CB; Thu, 3 May 2018 14:26:15 +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 996676E672 for ; Thu, 3 May 2018 14:26:13 +0000 (UTC) Received: by mail-wm0-x241.google.com with SMTP id f6so28721578wmc.4 for ; Thu, 03 May 2018 07:26:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PXql0GFje9p6CN1xOhBNdUfYw6H/We/H3+kLiSm6Bqo=; b=QhnaFT0IKOtEk7n4LDREPvzli6iAeNT1lvSBj0i+TQtFTrA380n16o7hpWNNWPNl8j qR6eY1C+GO/g3JPJBdlmUkjx8sidg2WoTcksnADfJsLmRS2ShlxWF08AdGGbLV10owv+ cphChFYejagblvwwGw4BuZN6jzEQtiNbz7Ahw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PXql0GFje9p6CN1xOhBNdUfYw6H/We/H3+kLiSm6Bqo=; b=o2YfK01MYN8d1oiFyZQyfyb4IMtKBY3JGO8OfdxJG+UgL265jN7uqnByI39bsFPoI7 sw7iSTa1JMtWwoto755ySLuksE8PbmaozcKzN9jkFUfmNwvuExQYBorpbEonNPvnlumB tQS0dnpre6PpmJhMxj51GqvRmsRoLbGJO4yBJsfgwY0ax73wiusv2SkuZkKVHHOp1qEV S1p6cWCV+DP11cBpotKslrkCmvP//+4si2t0oIMG9z2Cvag7eBmI/iSlBFmUJX6rmgrd V1CSfsWyRbqMi6d8DghqheteTkUURowoWYUKsgToxMS1/wLo5XYB9wPGjxe6PIyCel+X FouQ== X-Gm-Message-State: ALQs6tCc/Ayd9kEj2Z2R1ZVT8dz7Pfasb9QZlTBlyohLn9RnU9SHqhSn /jyWOv/n61PEIq4KKWPjkjfjmiQ4 X-Google-Smtp-Source: AB8JxZqHSMYSLUP9sYdEBDkfVc0qne9c/jPcoVPPbJWX978X9HYdScU7EpXOrP1ouiWKuXV4zC1xWQ== X-Received: by 2002:a50:ca01:: with SMTP id d1-v6mr32642550edi.187.1525357572014; Thu, 03 May 2018 07:26:12 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:5635:0:39d2:f87e:2033:9f6]) by smtp.gmail.com with ESMTPSA id u5-v6sm8095647edi.79.2018.05.03.07.26.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 May 2018 07:26:11 -0700 (PDT) From: Daniel Vetter To: DRI Development Subject: [PATCH 02/15] dma-fence: Make ->enable_signaling optional Date: Thu, 3 May 2018 16:25:50 +0200 Message-Id: <20180503142603.28513-3-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180503142603.28513-1-daniel.vetter@ffwll.ch> References: <20180503142603.28513-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Intel Graphics Development , linaro-mm-sig@lists.linaro.org, Daniel Vetter , Daniel Vetter , linux-media@vger.kernel.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Many drivers have a trivial implementation for ->enable_signaling. Let's make it optional by assuming that signalling is already available when the callback isn't present. Reviewed-by: Christian König Signed-off-by: Daniel Vetter Cc: Sumit Semwal Cc: Gustavo Padovan Cc: linux-media@vger.kernel.org Cc: linaro-mm-sig@lists.linaro.org --- drivers/dma-buf/dma-fence.c | 13 ++++++++++++- include/linux/dma-fence.h | 3 ++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/dma-buf/dma-fence.c b/drivers/dma-buf/dma-fence.c index 4edb9fd3cf47..7b5b40d6b70e 100644 --- a/drivers/dma-buf/dma-fence.c +++ b/drivers/dma-buf/dma-fence.c @@ -181,6 +181,13 @@ void dma_fence_release(struct kref *kref) } EXPORT_SYMBOL(dma_fence_release); +/** + * dma_fence_free - default release function for &dma_fence. + * @fence: fence to release + * + * This is the default implementation for &dma_fence_ops.release. It calls + * kfree_rcu() on @fence. + */ void dma_fence_free(struct dma_fence *fence) { kfree_rcu(fence, rcu); @@ -560,7 +567,7 @@ dma_fence_init(struct dma_fence *fence, const struct dma_fence_ops *ops, spinlock_t *lock, u64 context, unsigned seqno) { BUG_ON(!lock); - BUG_ON(!ops || !ops->wait || !ops->enable_signaling || + BUG_ON(!ops || !ops->wait || !ops->get_driver_name || !ops->get_timeline_name); kref_init(&fence->refcount); @@ -572,6 +579,10 @@ dma_fence_init(struct dma_fence *fence, const struct dma_fence_ops *ops, fence->flags = 0UL; fence->error = 0; + if (!ops->enable_signaling) + set_bit(DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT, + &fence->flags); + trace_dma_fence_init(fence); } EXPORT_SYMBOL(dma_fence_init); diff --git a/include/linux/dma-fence.h b/include/linux/dma-fence.h index 111aefe1c956..c053d19e1e24 100644 --- a/include/linux/dma-fence.h +++ b/include/linux/dma-fence.h @@ -166,7 +166,8 @@ struct dma_fence_ops { * released when the fence is signalled (through e.g. the interrupt * handler). * - * This callback is mandatory. + * This callback is optional. If this callback is not present, then the + * driver must always have signaling enabled. */ bool (*enable_signaling)(struct dma_fence *fence);