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: 10378501 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 5DA1D60159 for ; Thu, 3 May 2018 14:26:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4B11229195 for ; Thu, 3 May 2018 14:26:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3F74F29199; Thu, 3 May 2018 14:26:46 +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=unavailable 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 D2F2529195 for ; Thu, 3 May 2018 14:26:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5EBF66E6F3; Thu, 3 May 2018 14:26:20 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wm0-x244.google.com (mail-wm0-x244.google.com [IPv6:2a00:1450:400c:c09::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id 594146E6A4 for ; Thu, 3 May 2018 14:26:13 +0000 (UTC) Received: by mail-wm0-x244.google.com with SMTP id w194so6647605wmf.2 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=saNV1NAnGBMHHWUngaygXbFpYH3+lzWqbZdYfWDFYQFYk9EMqxeTeSbXDOPrpwOLlH WjJK6dYiPLUNyqTJMbIYpmTC9WveHYHk4iDr9InPhFMv26MuBU3aII/VPDYx6bMtTnEC gT8ggrbYuO7SxyqmqS4MJ3SEZgTnC9ZF5A+ZiEY9mX6HK4ema9NQdZkhCfijJoWCdAaE 1lSeecn+szUgROodqQS+hf9jas74JitRjurmHlTnT6KDjTen60SAzlMdYHLIf2m7dKup g8BdMsSkV0FV/sNClb+FYg42gEuSTWnCBlb7wNkhrgksv4likI3DIvrnsnBY+m8rwWdN 9bdg== X-Gm-Message-State: ALQs6tAaTKG91vehaTdW8v7Z4yLD33pFJ/gymnEarQnGsXef+lpmmdKS 6xxgWK/muM2qiI1ERda0lEC17g== 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 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 Subject: [Intel-gfx] [PATCH 02/15] dma-fence: Make ->enable_signaling optional X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & 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 , Sumit Semwal , linux-media@vger.kernel.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" 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);