From patchwork Wed Jun 16 08:26:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 461737 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 15C92C49361 for ; Wed, 16 Jun 2021 08:27:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ED5AF61359 for ; Wed, 16 Jun 2021 08:27:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231481AbhFPI3I (ORCPT ); Wed, 16 Jun 2021 04:29:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231468AbhFPI3I (ORCPT ); Wed, 16 Jun 2021 04:29:08 -0400 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C22AC06175F for ; Wed, 16 Jun 2021 01:27:01 -0700 (PDT) Received: by mail-ed1-x535.google.com with SMTP id s15so1512945edt.13 for ; Wed, 16 Jun 2021 01:27:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=bAUQPXbSkvT19k/XhsYs0cmL8Bgj7Ny0WAGbdIQQDHQ=; b=HxP9msOguWQ3QrHteS08n9aIIpmSVL0B0jsiRk4MJRbL7uofgZCKCoapjNf/2kiwdk 6Pb3l1Fc9AAZ/VCA3EHdMq5afGHtPvdGX2GUQdVJ0cKXTwGUpQJWgaUhzC0OOXYMGMs2 JbdyCuOMZpj8iV/WG+xz7zoV7SR38QcnQ9FBNgOimACUD0REuMD5SPbZyBucGx/w2Vpj gDk4kQBGE5BXa6AxcD7Q5IgG8RSE/JYkxUGv+IjtKZYbgR5iko6rgwhIsOid1X8SXd9o RfsKcaUNJD8eByyW4wemDj68FQ/qrYOOCUsR3cTTWq04Y1TPeEorHNbttrukQnr3h8k0 wXbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bAUQPXbSkvT19k/XhsYs0cmL8Bgj7Ny0WAGbdIQQDHQ=; b=rRAsqSQM9hqKy5+Bde7TU4o6/4XDDKrPokS0fxc0foWXM4CFOc17RMDH8oA5/bpjyW 4DloIlanXtYZ4vjtpGfADpvX2HGNproE7AvVjeHUg8zoF0ClZwMMyJGJ+wtGjqWdbNl0 axe9vTNH/NjuX+NspYMfBgKTFwdPqoR8x0riMmpjcRUrUOP0oOTqyC6jpuVPwnzGS9tW J4jypXGRWpYXssWUNThFgcMt+njsTGe+MJbpU3tn7y97xdn7aWcLnSYP6PCEjIL/N1ii aziaZZA/v+ndwVsVEyU5soRJedXO10WmzceJr63WXhSRqyrxpjjkzazXTdEFB1Rhublo CM3g== X-Gm-Message-State: AOAM530Abzf6On8zsBDaVfN05MrT6z5KuKJzfVfxUq/mbp8w/DDHq1Bq eXxb0YqHx/2qrslMJ2IL9ZY= X-Google-Smtp-Source: ABdhPJwuv9+M+3+hOg8rwV487BVcNbOkILX2dYfgDgwmpTEez1b9S9OjYK3Etjby1E1nrcMXGLnRog== X-Received: by 2002:aa7:cd77:: with SMTP id ca23mr2794529edb.259.1623832019927; Wed, 16 Jun 2021 01:26:59 -0700 (PDT) Received: from abel.fritz.box ([2a02:908:1252:fb60:8b88:17a4:582b:121f]) by smtp.gmail.com with ESMTPSA id v7sm1152639edx.38.2021.06.16.01.26.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Jun 2021 01:26:59 -0700 (PDT) From: "=?UTF-8?q?Christian=20K=C3=B6nig?=" X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: daniel@ffwll.ch, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-media@vger.kernel.org, sumit.semwal@linaro.org Subject: [PATCH 1/7] dma-buf: add some more kerneldoc to dma_resv_add_shared_fence Date: Wed, 16 Jun 2021 10:26:49 +0200 Message-Id: <20210616082655.111001-2-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210616082655.111001-1-christian.koenig@amd.com> References: <20210616082655.111001-1-christian.koenig@amd.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Explicitly document that code can't assume that shared fences signal after the exclusive fence. Signed-off-by: Christian König --- drivers/dma-buf/dma-resv.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c index f26c71747d43..4ab02b6c387a 100644 --- a/drivers/dma-buf/dma-resv.c +++ b/drivers/dma-buf/dma-resv.c @@ -235,7 +235,10 @@ EXPORT_SYMBOL(dma_resv_reset_shared_max); * @fence: the shared fence to add * * Add a fence to a shared slot, obj->lock must be held, and - * dma_resv_reserve_shared() has been called. + * dma_resv_reserve_shared() has been called. The shared fences can signal in + * any order and there is especially no guarantee that shared fences signal + * after the exclusive one. Code relying on any signaling order is broken and + * needs to be fixed. */ void dma_resv_add_shared_fence(struct dma_resv *obj, struct dma_fence *fence) { From patchwork Wed Jun 16 08:26:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 461736 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5467AC48BE6 for ; Wed, 16 Jun 2021 08:27:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3D244613B4 for ; Wed, 16 Jun 2021 08:27:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231665AbhFPI3K (ORCPT ); Wed, 16 Jun 2021 04:29:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231335AbhFPI3J (ORCPT ); Wed, 16 Jun 2021 04:29:09 -0400 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D0B7C061574 for ; Wed, 16 Jun 2021 01:27:02 -0700 (PDT) Received: by mail-ed1-x531.google.com with SMTP id w21so1563412edv.3 for ; Wed, 16 Jun 2021 01:27:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=gH3OUhd3wXODbH6KpjmAlhZdfVecYYvZR4fcrZvAXRQ=; b=tYxvk49yyGvTd8vEGSVaCnxFvwFkVCpsUMnteHFBbcJSiCa9f7yiKk3IAxuwoEzIHM DsNEKfPn5ZZG/Gzt5/goj6jN9vFtjg8UWoG76YxDEwmKQWwa/9LEJ50GshNb9nVVt0J1 Rpoc/Z58kE7LRRJqvUXjs2xhJgBdHSN27aqqWXj3vrs4er6qr675VMwtk1BrOkuQQLki kzonZ95ZHRvR7ydrkVjOxJksBpymEf7jfB83+npzBMPJXekPDel2c6/9hF8fDbFXRl8g 3DjQeAQdObC7q++IFfYHliGT95LofP/flAapNDxXtLCEBAnQt6F6Ed1tSZAhcQt+Hpch Pw8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gH3OUhd3wXODbH6KpjmAlhZdfVecYYvZR4fcrZvAXRQ=; b=YwWIc3ExZR/pYsobIdbybj1/lQFLOPPd6dL/ayd/3zlRJgAL8wo20a73z5UaakXQxQ p1skkm4Xmulj5WydZpB4LaM44h8mlBF5ZSoHAXemQRIBhZS6PXM96wM429RrAdwZTwxk zfPAQC9d1S8IhWb6OGM9VcewbW3kZwEVnl4qaeXRRHiHySOBf0RwqMQYd2NPJPyNTkwb Ml98jMWVlabl1a6+aLwyeHlmzSA1LN0frtZmkj8N5hJ1QqYv37foqeMv2Owxy1j/otRD J1QxjT0yNtYVdzgtDIA2ggriHiiLwgqOKw3l/8Uff/yH/gNIfELiUM6Il9pGY5C4gvL4 fFQA== X-Gm-Message-State: AOAM533tt0yo7cm3MUGdREALzHgH/vmdOoQ4ZFbxJGEIwimbf5qXFpH4 ZrWDhmtv0/pdP1UjFfRsTxQ= X-Google-Smtp-Source: ABdhPJyoEYuhmKxBRIP4z0Q2CNfPcVS2L6+e9AYh23KI9VbQsFNPnAWmb3Pc18CsbpC5neEG9/X/0Q== X-Received: by 2002:aa7:dd0b:: with SMTP id i11mr2693934edv.51.1623832020758; Wed, 16 Jun 2021 01:27:00 -0700 (PDT) Received: from abel.fritz.box ([2a02:908:1252:fb60:8b88:17a4:582b:121f]) by smtp.gmail.com with ESMTPSA id v7sm1152639edx.38.2021.06.16.01.26.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Jun 2021 01:27:00 -0700 (PDT) From: "=?UTF-8?q?Christian=20K=C3=B6nig?=" X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: daniel@ffwll.ch, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-media@vger.kernel.org, sumit.semwal@linaro.org Subject: [PATCH 2/7] dma-buf: fix and rework dma_buf_poll v2 Date: Wed, 16 Jun 2021 10:26:50 +0200 Message-Id: <20210616082655.111001-3-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210616082655.111001-1-christian.koenig@amd.com> References: <20210616082655.111001-1-christian.koenig@amd.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Daniel pointed me towards this function and there are multiple obvious problems in the implementation. First of all the retry loop is not working as intended. In general the retry makes only sense if you grab the reference first and then check the sequence values. It's also good practice to keep the reference around when installing callbacks to fences you don't own. Then we skipped checking the exclusive fence when shared fences were present. And last the whole implementation was unnecessary complex and rather hard to understand which could lead to probably unexpected behavior of the IOCTL. Fix all this by reworking the implementation from scratch. Only mildly tested and needs a thoughtful review of the code. v2: fix the reference counting as well Signed-off-by: Christian König --- drivers/dma-buf/dma-buf.c | 133 ++++++++++++++++---------------------- include/linux/dma-buf.h | 2 +- 2 files changed, 55 insertions(+), 80 deletions(-) diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c index 511fe0d217a0..b67fbf4e3705 100644 --- a/drivers/dma-buf/dma-buf.c +++ b/drivers/dma-buf/dma-buf.c @@ -72,7 +72,7 @@ static void dma_buf_release(struct dentry *dentry) * If you hit this BUG() it means someone dropped their ref to the * dma-buf while still having pending operation to the buffer. */ - BUG_ON(dmabuf->cb_shared.active || dmabuf->cb_excl.active); + BUG_ON(dmabuf->cb_in.active || dmabuf->cb_out.active); dmabuf->ops->release(dmabuf); @@ -202,16 +202,20 @@ static void dma_buf_poll_cb(struct dma_fence *fence, struct dma_fence_cb *cb) wake_up_locked_poll(dcb->poll, dcb->active); dcb->active = 0; spin_unlock_irqrestore(&dcb->poll->lock, flags); + dma_fence_put(fence); } static __poll_t dma_buf_poll(struct file *file, poll_table *poll) { + struct dma_buf_poll_cb_t *dcb; struct dma_buf *dmabuf; struct dma_resv *resv; struct dma_resv_list *fobj; struct dma_fence *fence_excl; - __poll_t events; unsigned shared_count, seq; + struct dma_fence *fence; + __poll_t events; + int r, i; dmabuf = file->private_data; if (!dmabuf || !dmabuf->resv) @@ -225,99 +229,70 @@ static __poll_t dma_buf_poll(struct file *file, poll_table *poll) if (!events) return 0; + dcb = events & EPOLLOUT ? &dmabuf->cb_out : &dmabuf->cb_in; + + /* Only queue a new one if we are not still waiting for the old one */ + spin_lock_irq(&dmabuf->poll.lock); + if (dcb->active) + events = 0; + else + dcb->active = events; + spin_unlock_irq(&dmabuf->poll.lock); + if (!events) + return 0; + retry: seq = read_seqcount_begin(&resv->seq); rcu_read_lock(); fobj = rcu_dereference(resv->fence); - if (fobj) + if (fobj && events & EPOLLOUT) shared_count = fobj->shared_count; else shared_count = 0; - fence_excl = dma_resv_excl_fence(resv); - if (read_seqcount_retry(&resv->seq, seq)) { - rcu_read_unlock(); - goto retry; - } - if (fence_excl && (!(events & EPOLLOUT) || shared_count == 0)) { - struct dma_buf_poll_cb_t *dcb = &dmabuf->cb_excl; - __poll_t pevents = EPOLLIN; - - if (shared_count == 0) - pevents |= EPOLLOUT; - - spin_lock_irq(&dmabuf->poll.lock); - if (dcb->active) { - dcb->active |= pevents; - events &= ~pevents; - } else - dcb->active = pevents; - spin_unlock_irq(&dmabuf->poll.lock); - - if (events & pevents) { - if (!dma_fence_get_rcu(fence_excl)) { - /* force a recheck */ - events &= ~pevents; - dma_buf_poll_cb(NULL, &dcb->cb); - } else if (!dma_fence_add_callback(fence_excl, &dcb->cb, - dma_buf_poll_cb)) { - events &= ~pevents; - dma_fence_put(fence_excl); - } else { - /* - * No callback queued, wake up any additional - * waiters. - */ - dma_fence_put(fence_excl); - dma_buf_poll_cb(NULL, &dcb->cb); - } + for (i = 0; i < shared_count; ++i) { + fence = rcu_dereference(fobj->shared[i]); + fence = dma_fence_get_rcu(fence); + if (!fence || read_seqcount_retry(&resv->seq, seq)) { + /* Concurrent modify detected, force re-check */ + dma_fence_put(fence); + rcu_read_unlock(); + goto retry; } - } - if ((events & EPOLLOUT) && shared_count > 0) { - struct dma_buf_poll_cb_t *dcb = &dmabuf->cb_shared; - int i; - - /* Only queue a new callback if no event has fired yet */ - spin_lock_irq(&dmabuf->poll.lock); - if (dcb->active) - events &= ~EPOLLOUT; - else - dcb->active = EPOLLOUT; - spin_unlock_irq(&dmabuf->poll.lock); - - if (!(events & EPOLLOUT)) + r = dma_fence_add_callback(fence, &dcb->cb, dma_buf_poll_cb); + if (!r) { + /* Callback queued */ + events = 0; goto out; + } + dma_fence_put(fence); + } - for (i = 0; i < shared_count; ++i) { - struct dma_fence *fence = rcu_dereference(fobj->shared[i]); - - if (!dma_fence_get_rcu(fence)) { - /* - * fence refcount dropped to zero, this means - * that fobj has been freed - * - * call dma_buf_poll_cb and force a recheck! - */ - events &= ~EPOLLOUT; - dma_buf_poll_cb(NULL, &dcb->cb); - break; - } - if (!dma_fence_add_callback(fence, &dcb->cb, - dma_buf_poll_cb)) { - dma_fence_put(fence); - events &= ~EPOLLOUT; - break; - } + fence = dma_resv_excl_fence(resv); + if (fence) { + fence = dma_fence_get_rcu(fence); + if (!fence || read_seqcount_retry(&resv->seq, seq)) { + /* Concurrent modify detected, force re-check */ dma_fence_put(fence); + rcu_read_unlock(); + goto retry; + } - /* No callback queued, wake up any additional waiters. */ - if (i == shared_count) - dma_buf_poll_cb(NULL, &dcb->cb); + r = dma_fence_add_callback(fence, &dcb->cb, dma_buf_poll_cb); + if (!r) { + /* Callback queued */ + events = 0; + goto out; + } + dma_fence_put(fence_excl); } + /* No callback queued, wake up any additional waiters. */ + dma_buf_poll_cb(NULL, &dcb->cb); + out: rcu_read_unlock(); return events; @@ -562,8 +537,8 @@ struct dma_buf *dma_buf_export(const struct dma_buf_export_info *exp_info) dmabuf->owner = exp_info->owner; spin_lock_init(&dmabuf->name_lock); init_waitqueue_head(&dmabuf->poll); - dmabuf->cb_excl.poll = dmabuf->cb_shared.poll = &dmabuf->poll; - dmabuf->cb_excl.active = dmabuf->cb_shared.active = 0; + dmabuf->cb_in.poll = dmabuf->cb_out.poll = &dmabuf->poll; + dmabuf->cb_in.active = dmabuf->cb_out.active = 0; if (!resv) { resv = (struct dma_resv *)&dmabuf[1]; diff --git a/include/linux/dma-buf.h b/include/linux/dma-buf.h index efdc56b9d95f..7e747ad54c81 100644 --- a/include/linux/dma-buf.h +++ b/include/linux/dma-buf.h @@ -329,7 +329,7 @@ struct dma_buf { wait_queue_head_t *poll; __poll_t active; - } cb_excl, cb_shared; + } cb_in, cb_out; }; /** From patchwork Wed Jun 16 08:26:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 462561 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DE9DDC49EA2 for ; Wed, 16 Jun 2021 08:27:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B243D610CA for ; Wed, 16 Jun 2021 08:27:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231589AbhFPI3J (ORCPT ); Wed, 16 Jun 2021 04:29:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231389AbhFPI3I (ORCPT ); Wed, 16 Jun 2021 04:29:08 -0400 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7EFEC061760 for ; Wed, 16 Jun 2021 01:27:02 -0700 (PDT) Received: by mail-ed1-x533.google.com with SMTP id t7so1550178edd.5 for ; Wed, 16 Jun 2021 01:27:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=yylOD234iuv0OMUdGg2HNgmrF+LL5FUxi7mZp3iTQtM=; b=IPfZjfHVbG0OCn+KKeCOXK5UK6WlYoq3WBGAITBYT177wcs8YEOrG/D5j6Pp+dx+XV vSuDXkWFGTMI7iX1g1KUfz8RItABTnIqmtbDDAY1AWZpafqbDjoaJXVzvEeAeEIwfgaX BFPj5kDSgkf4OrxL5PxuTu8KmnfFPOrk1HGMANOPQDIg8H2qYtp5h0nW16B430t54YiA MnOxWddiKvBCw6XlkdZViIlvwxe7tfrdg/PKmkm/tQ/RDvOhtvjSZVMHsF6KaTq3m9nA dUz3Bob1iSVI11XSMvyWBeYQTflU+vBQWBbgL04E4SnPh1maV/mIVlGaMJQQ8Wty3SNu JaEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yylOD234iuv0OMUdGg2HNgmrF+LL5FUxi7mZp3iTQtM=; b=I+A/tLhVwbOfdiXGRL4dd98a3d8Mv2S/tjHw1R8yuoF86hgozhBeEP4sPpmLbMImiY LK9eFKZzz47s/0R8YtQuFerauzpNTmb3xVqf5H1rw72/pKLsk8BXSM+IHMzKqYpHpYxn PHo5BOs7LLKviQZd0aMcjvBp9wHoVztNbJBNS4NiyPt/TE/l9ehm2AfVQ2EqOYO2neT8 Kw9wof7y+AANKgH7PE3HAvKGnF9S9vG3tgUh6O4u/d6wPoHwYIzvM7ydkjrPqda7wqVX Z6tFbsToOZIytOSHzD05ge96Jzis9doLZMdpJAgYwzDCroFyyMOKsvpy0ewSWMA0ra9C j67w== X-Gm-Message-State: AOAM532WVGo0ruqquwfO3qpWA1xHcgvw3foOXQhnG2ARbqlR3Z0Xiq0y 3uIX1kdPbyEL/HhgSOjF7QY= X-Google-Smtp-Source: ABdhPJxMIYtsfV1dgkVNP3Vy0nsp5M8aYGD7HNMOvq14lrRQdJQKg7mZZynBVSsqgsANM28ZJBEXJg== X-Received: by 2002:aa7:d288:: with SMTP id w8mr2730674edq.276.1623832021459; Wed, 16 Jun 2021 01:27:01 -0700 (PDT) Received: from abel.fritz.box ([2a02:908:1252:fb60:8b88:17a4:582b:121f]) by smtp.gmail.com with ESMTPSA id v7sm1152639edx.38.2021.06.16.01.27.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Jun 2021 01:27:01 -0700 (PDT) From: "=?UTF-8?q?Christian=20K=C3=B6nig?=" X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: daniel@ffwll.ch, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-media@vger.kernel.org, sumit.semwal@linaro.org Subject: [PATCH 3/7] dma-buf: fix dma_resv_test_signaled test_all handling v2 Date: Wed, 16 Jun 2021 10:26:51 +0200 Message-Id: <20210616082655.111001-4-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210616082655.111001-1-christian.koenig@amd.com> References: <20210616082655.111001-1-christian.koenig@amd.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org As the name implies if testing all fences is requested we should indeed test all fences and not skip the exclusive one because we see shared ones. v2: fix logic once more Signed-off-by: Christian König --- drivers/dma-buf/dma-resv.c | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c index 4ab02b6c387a..18dd5a6ca06c 100644 --- a/drivers/dma-buf/dma-resv.c +++ b/drivers/dma-buf/dma-resv.c @@ -618,25 +618,21 @@ static inline int dma_resv_test_signaled_single(struct dma_fence *passed_fence) */ bool dma_resv_test_signaled(struct dma_resv *obj, bool test_all) { - unsigned int seq, shared_count; + struct dma_fence *fence; + unsigned int seq; int ret; rcu_read_lock(); retry: ret = true; - shared_count = 0; seq = read_seqcount_begin(&obj->seq); if (test_all) { struct dma_resv_list *fobj = dma_resv_shared_list(obj); - unsigned int i; - - if (fobj) - shared_count = fobj->shared_count; + unsigned int i, shared_count; + shared_count = fobj ? fobj->shared_count : 0; for (i = 0; i < shared_count; ++i) { - struct dma_fence *fence; - fence = rcu_dereference(fobj->shared[i]); ret = dma_resv_test_signaled_single(fence); if (ret < 0) @@ -644,24 +640,19 @@ bool dma_resv_test_signaled(struct dma_resv *obj, bool test_all) else if (!ret) break; } - - if (read_seqcount_retry(&obj->seq, seq)) - goto retry; } - if (!shared_count) { - struct dma_fence *fence_excl = dma_resv_excl_fence(obj); - - if (fence_excl) { - ret = dma_resv_test_signaled_single(fence_excl); - if (ret < 0) - goto retry; + fence = dma_resv_excl_fence(obj); + if (ret && fence) { + ret = dma_resv_test_signaled_single(fence); + if (ret < 0) + goto retry; - if (read_seqcount_retry(&obj->seq, seq)) - goto retry; - } } + if (read_seqcount_retry(&obj->seq, seq)) + goto retry; + rcu_read_unlock(); return ret; } From patchwork Wed Jun 16 08:26:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 462560 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8E08C48BE5 for ; Wed, 16 Jun 2021 08:27:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C886B61369 for ; Wed, 16 Jun 2021 08:27:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231666AbhFPI3K (ORCPT ); Wed, 16 Jun 2021 04:29:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231602AbhFPI3J (ORCPT ); Wed, 16 Jun 2021 04:29:09 -0400 Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8EC42C06175F for ; Wed, 16 Jun 2021 01:27:03 -0700 (PDT) Received: by mail-ed1-x536.google.com with SMTP id u24so1521675edy.11 for ; Wed, 16 Jun 2021 01:27:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=ND7KwC2J9bqQZCM3dXcypP939eYSZ8A7ifwwevA1684=; b=unqs/raZ1t5J4i0tVMb8sZRh9eQVDcU+0zh4oyD9beiUYRJFxM0B6pk7bdOaSRv6pz ALXYdvQLZ6aV6zWNTRTeW/y/XkFlFbPJ+A9EIeBHMK5zR760JaTihUqsgb8FecRjuHKc A2YBF7tB3TSkCzFPDmcwzeuZ9+OX1ZbomPk3SV/kzWe6/vS2HO3oOQGTTunKbCvELRoP K0cPNjiWbjaJHsNkgwAjFWGMGjoOoSQ+wfkoncM4ivOQWAqmL7fRrqMuWYYpVW+NvLKh daOem2XyiML/PNHiudTUm5y7hyCDxNpTx92LDOX7Yoxw6ingJzlFpSiPeDrHJOqSFQ+N 40Tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ND7KwC2J9bqQZCM3dXcypP939eYSZ8A7ifwwevA1684=; b=pY07tscKMXzxxzKSNmWsXmeRyuyE4L+6r/IwZOarIpiO4tELVAe2sPTPnhb4n2OceI VQ/Pa4z2ZItuCFrHXtP9fT+/9CPI7yzQYATLHC0FJgQtXE+9qaLl5eF6gURkqMzeRdWa FT1FqJFwj7MSYUFzexVzbYdROTMO5/PM+d9l/SvIaeUyfAFIvtH5JdHW0CFInyh9D9q1 VcFqrU9DXqSlXMddZ9zYuXwtIh2syGNkrZxDn11twOEeevvNb/T2CBkgDCu7Ih3zR7jj Kq0H9iZg8mSDO8A6J/Uh6MuYihAyawLWieC2M9ZjO9wUkbj/CRj4TjtpWWRpMLw3a9pb fsHQ== X-Gm-Message-State: AOAM532TGJcWMG/siMmSnKosa2O2hf/5HMLJfuG7zZJaZ7sTsRxsRGfE bu7W0UVfs7ldp5MjJemau9E= X-Google-Smtp-Source: ABdhPJxW25RCxGgBd4Rp2bAkplsJ1rs8Gw3ttP6+9OZanazszl0LNYDwjaUxdetHpXeEzpHYeOcshQ== X-Received: by 2002:a05:6402:520c:: with SMTP id s12mr2753961edd.304.1623832022213; Wed, 16 Jun 2021 01:27:02 -0700 (PDT) Received: from abel.fritz.box ([2a02:908:1252:fb60:8b88:17a4:582b:121f]) by smtp.gmail.com with ESMTPSA id v7sm1152639edx.38.2021.06.16.01.27.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Jun 2021 01:27:01 -0700 (PDT) From: "=?UTF-8?q?Christian=20K=C3=B6nig?=" X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: daniel@ffwll.ch, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-media@vger.kernel.org, sumit.semwal@linaro.org Subject: [PATCH 4/7] drm/nouveau: always wait for the exclusive fence Date: Wed, 16 Jun 2021 10:26:52 +0200 Message-Id: <20210616082655.111001-5-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210616082655.111001-1-christian.koenig@amd.com> References: <20210616082655.111001-1-christian.koenig@amd.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Drivers also need to to sync to the exclusive fence when a shared one is present. Signed-off-by: Christian König --- drivers/gpu/drm/nouveau/nouveau_fence.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.c b/drivers/gpu/drm/nouveau/nouveau_fence.c index 6b43918035df..05d0b3eb3690 100644 --- a/drivers/gpu/drm/nouveau/nouveau_fence.c +++ b/drivers/gpu/drm/nouveau/nouveau_fence.c @@ -358,7 +358,7 @@ nouveau_fence_sync(struct nouveau_bo *nvbo, struct nouveau_channel *chan, bool e fobj = dma_resv_shared_list(resv); fence = dma_resv_excl_fence(resv); - if (fence && (!exclusive || !fobj || !fobj->shared_count)) { + if (fence) { struct nouveau_channel *prev = NULL; bool must_wait = true; From patchwork Wed Jun 16 08:26:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 461735 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ED88FC48BE8 for ; Wed, 16 Jun 2021 08:27:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D25D8613B4 for ; Wed, 16 Jun 2021 08:27:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231727AbhFPI3L (ORCPT ); Wed, 16 Jun 2021 04:29:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231602AbhFPI3L (ORCPT ); Wed, 16 Jun 2021 04:29:11 -0400 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54B5AC061574 for ; Wed, 16 Jun 2021 01:27:04 -0700 (PDT) Received: by mail-ed1-x52f.google.com with SMTP id ba2so1567237edb.2 for ; Wed, 16 Jun 2021 01:27:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=5WMQmwGHbFSsJZWDXuAJvQZzGWBWH2W4bsFT3at8Zrc=; b=NVrqaPl19uEslX/a+KyWratsaSC97kBg4iUcUB8MZJukI/CUgyD9y2YUaJ2tOIj3Vb ixt1qRYMlSRMZnfCGzpujLwyyLlQeLXocGBTZH8KvIb+6ooOpakMj5YkfcoQRGgqTjPP AqYI7SqZDm6uW6UNrRpGRvdMe/7lQOiq5tnaQA0AG3Bs1b6+UKNgmls2Dz05f86K0etC UjAVH9NsRWKPjP5uVLJbNEf/l0yLnpTITa6piqgHIcAMbIwpks+BdphqoYZUTQKeDOuE KNxiTx8W3IbQw2UyIMREJWGpzjv2/kWL0J1pW9a+ZsrhV+6DA+cLIKnuoF+3a2+/Vmvi SY1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5WMQmwGHbFSsJZWDXuAJvQZzGWBWH2W4bsFT3at8Zrc=; b=alQmsaCTVzrgXNKEdhvgp+jgxJsLw6IpTaKZkokp98H7mtK0DW4lTuTFlQhAIjwXlm BgRACQupDjj355uLD6t37qzO+E1zpC0qQlxjm+8twHguureedq+F23i6tTWGsw4IA360 OOFDryHEqa0yTqxYlmMJpc2/i5fgCtDN3MxuQe0f1/93OE3OMyWg81SSBCm+6St5oI+W JcVAqMKMuEuSIa4IIRkx7fTZK/5J+QvI6WdIM3Z2ByghwvsbHDJlK1N7pBKNEXZ2FubF 0uD2RU/qnUkjJhmqe0eM6YVYuaJ8FUNHHNZyIq7EGO8qLjFPzOXYfmWYjF+I6L3asOPS MuYg== X-Gm-Message-State: AOAM53299rGDFYz2nXv0Sus+JLmRPNw/qIb1QJoT8/uqOEqQoD3j3R1Y CRAuJnzzza/93Vfod/+VpP0= X-Google-Smtp-Source: ABdhPJwV7+n84rFPY62ZziQgf22oMXHmHw5Wg3+23X3qqR6nGWr7dVvkNQCVJypfg3IWq7wiJAhiTA== X-Received: by 2002:a05:6402:5:: with SMTP id d5mr2758141edu.312.1623832022944; Wed, 16 Jun 2021 01:27:02 -0700 (PDT) Received: from abel.fritz.box ([2a02:908:1252:fb60:8b88:17a4:582b:121f]) by smtp.gmail.com with ESMTPSA id v7sm1152639edx.38.2021.06.16.01.27.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Jun 2021 01:27:02 -0700 (PDT) From: "=?UTF-8?q?Christian=20K=C3=B6nig?=" X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: daniel@ffwll.ch, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-media@vger.kernel.org, sumit.semwal@linaro.org Subject: [PATCH 5/7] drm/msm: always wait for the exclusive fence Date: Wed, 16 Jun 2021 10:26:53 +0200 Message-Id: <20210616082655.111001-6-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210616082655.111001-1-christian.koenig@amd.com> References: <20210616082655.111001-1-christian.koenig@amd.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Drivers also need to to sync to the exclusive fence when a shared one is present. Completely untested since the driver won't even compile on !ARM. Signed-off-by: Christian König --- drivers/gpu/drm/msm/msm_gem.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c index a94a43de95ef..72a07e311de3 100644 --- a/drivers/gpu/drm/msm/msm_gem.c +++ b/drivers/gpu/drm/msm/msm_gem.c @@ -817,17 +817,15 @@ int msm_gem_sync_object(struct drm_gem_object *obj, struct dma_fence *fence; int i, ret; - fobj = dma_resv_shared_list(obj->resv); - if (!fobj || (fobj->shared_count == 0)) { - fence = dma_resv_excl_fence(obj->resv); - /* don't need to wait on our own fences, since ring is fifo */ - if (fence && (fence->context != fctx->context)) { - ret = dma_fence_wait(fence, true); - if (ret) - return ret; - } + fence = dma_resv_excl_fence(obj->resv); + /* don't need to wait on our own fences, since ring is fifo */ + if (fence && (fence->context != fctx->context)) { + ret = dma_fence_wait(fence, true); + if (ret) + return ret; } + fobj = dma_resv_shared_list(obj->resv); if (!exclusive || !fobj) return 0; From patchwork Wed Jun 16 08:26:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 462559 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2168DC49361 for ; Wed, 16 Jun 2021 08:27:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0B1DC6101A for ; Wed, 16 Jun 2021 08:27:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231846AbhFPI3M (ORCPT ); Wed, 16 Jun 2021 04:29:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231602AbhFPI3L (ORCPT ); Wed, 16 Jun 2021 04:29:11 -0400 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 443B3C06175F for ; Wed, 16 Jun 2021 01:27:05 -0700 (PDT) Received: by mail-ed1-x530.google.com with SMTP id t7so1550323edd.5 for ; Wed, 16 Jun 2021 01:27:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=eOLQYHUi8EbWMSyj8fpL7+TUOhuUkdVsm2sbvIBW7rQ=; b=peIJ6pH3RtosgHbcBzthWIHp5Ht3/i9wko21RYQ4Wwjat8wwNDxFQLd+PS9YmzbNn6 zYW9IB3T/spJ9QbFwbV1eQFf0KyS1qSyk/N2KYypvl3q+WP6vULhFB6zQ/r4/8pBgIlx nCD3ORHu2xcgasBZuy2uKg9TdsycDRBe0Ooqre8wVRqK27vy9bx/meJJciYH9ebkUC61 7CdfbPXBFbuzxTxe7HGoqdktglROg90cs7h7L1O/vT1vHc/Tp4AIPeMeQ/Gi/jd/8BS6 wilmsl8Et949y7ZreBxhqO+RmJgtPtm+V3RK4bpOAziaE/HSriApWjAfJNqWKk3OOzDB c4VA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eOLQYHUi8EbWMSyj8fpL7+TUOhuUkdVsm2sbvIBW7rQ=; b=rKJH8NjJT8fF2jAcdjY8ApAYb2F7HVsVfCCkzQghHruQL6Hgmgey95lSAlu7+zx2L/ TncJCEo3dJ4+fwJXwnKuT+ui3Rr1lBoY6U36OA6eHNO1zrDmKL2oZt13Mnk7x2xsdj4B ivDF51RpAA0jsu4EGzpTcNyOCwqiFK5BjwUWyBr3+oFbbsCDu8ju1o2XZlDTFRa/of95 x59TEKqTE9fzfhGA9A9YH5Hmw6Ro2zX10ubmu7m4C0ou8cgvHAf8LYmCYcm3M4oqYINy +3PW/u3pTlyXv0rHkLDS8gZSVubMBf4pJnJVlAqeeXm/x7flFgcNMFmCOyhgCb6D4z7I habg== X-Gm-Message-State: AOAM532zZZGM2wV2Lw/OF25+8uRAdQlz1/O/3pcW4Wx2kDfFwjPU0oUs nFg5WTQaAuY+QzvbxCWVjsQ= X-Google-Smtp-Source: ABdhPJxTFpqW21OrNereNEfws2tTVm4Wn0Se9rWNC+9t5y4vIFlD5DkHnDgU/63ucoG65cOJGMdm8A== X-Received: by 2002:a05:6402:54f:: with SMTP id i15mr2671173edx.339.1623832023875; Wed, 16 Jun 2021 01:27:03 -0700 (PDT) Received: from abel.fritz.box ([2a02:908:1252:fb60:8b88:17a4:582b:121f]) by smtp.gmail.com with ESMTPSA id v7sm1152639edx.38.2021.06.16.01.27.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Jun 2021 01:27:03 -0700 (PDT) From: "=?UTF-8?q?Christian=20K=C3=B6nig?=" X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: daniel@ffwll.ch, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-media@vger.kernel.org, sumit.semwal@linaro.org Subject: [PATCH 6/7] drm/amdgpu: drop workaround for adding page table clears as shared fence Date: Wed, 16 Jun 2021 10:26:54 +0200 Message-Id: <20210616082655.111001-7-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210616082655.111001-1-christian.koenig@amd.com> References: <20210616082655.111001-1-christian.koenig@amd.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org We no longer need to add the exclusive fence as shared fence as welldrm/amdgpu: drop workaround for adding page table clears as shared fence We no longer need to add the exclusive fence as shared fence as well.. Signed-off-by: Christian König --- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c index 0780e8d18992..d7baa207f391 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c @@ -207,7 +207,7 @@ static void amdgpu_gem_object_close(struct drm_gem_object *obj, INIT_LIST_HEAD(&duplicates); tv.bo = &bo->tbo; - tv.num_shared = 2; + tv.num_shared = 1; list_add(&tv.head, &list); amdgpu_vm_get_pd_bo(vm, &list, &vm_pd); @@ -226,12 +226,6 @@ static void amdgpu_gem_object_close(struct drm_gem_object *obj, if (!amdgpu_vm_ready(vm)) goto out_unlock; - fence = dma_resv_excl_fence(bo->tbo.base.resv); - if (fence) { - amdgpu_bo_fence(bo, fence, true); - fence = NULL; - } - r = amdgpu_vm_clear_freed(adev, vm, &fence); if (r || !fence) goto out_unlock; From patchwork Wed Jun 16 08:26:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 461734 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB015C49EA3 for ; Wed, 16 Jun 2021 08:27:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B97BB610CA for ; Wed, 16 Jun 2021 08:27:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231889AbhFPI3N (ORCPT ); Wed, 16 Jun 2021 04:29:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231744AbhFPI3M (ORCPT ); Wed, 16 Jun 2021 04:29:12 -0400 Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21C99C061574 for ; Wed, 16 Jun 2021 01:27:06 -0700 (PDT) Received: by mail-ed1-x536.google.com with SMTP id n20so1536232edv.8 for ; Wed, 16 Jun 2021 01:27:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=IVTqokzmJtH8YP62XhkCvu3HVJ/rLNfsAlMIAEY59CE=; b=EwEYNY4o/LxWqe7QhW3a60rhBvw/kRELesY+OsHJ+XaBjf0r6WAzYlVTjcdo3Q+M0B hlXIM9gJRkjGWtrSWXsIB1Y9niKXfnaCOZUVlw3phEEKG7nQDYXmmmN2Ucu9vqaHWEV7 tWJ4gJwUSDTwiOoG/dQUHjc4hOFVi7cJ2h9TTcKLtXsUbxKE+zsrWj7tUT6UhK727GP9 28UoI8wNQKRUSJQQm7gGpOGysujbsiyWzIbMJ3p5hqBn6Q9UK6gdq2tnSP0kBgNjwGRM jGN5xHkwvWTZXFhTHC3ye6Skxz67KYEhWjyqNJA1inGuvlzJo5C7CyopuppTDQvFj9ZZ skuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IVTqokzmJtH8YP62XhkCvu3HVJ/rLNfsAlMIAEY59CE=; b=ntLaoOYV2J8SIQzhUIoY+KECe0kzWuWIPEajwxdOCR572ZXuKjz4PNJjxZDnfstJJl pWnG61lZJVorxKl/x3KwfQFPJZDflylRRMKHVkkijdG7fRhs+F9jtoTSE/Tn8u3MJchL tMGcO9cDWzkz/PTagL2CPMUJEWK1qujlXpCiRuFTJX3iqljvhJ6pfCnzQACKadgftfWC Ktvp5QUIIvPhxpO4k3lThPIK1gGH0XXD9lWgyDT+HQGmCMN4rMPjz4skuTVc7ecB4May HadZYzWRRZ254ZHf6B5KGG5Z5s7eS93qq+ty9JVZWykJYD1exFCB6QU3Miv+lesqVAhn cOzQ== X-Gm-Message-State: AOAM530ZQ0BLaFX/P34UNQ/zABiB+1dSCe+S8fL+nJTxyWAhCled59Eq aVaVQHb2733+6ZaGYS0fWi7sWyVQgdg= X-Google-Smtp-Source: ABdhPJx4sV239SQRT2vcbJ7VyXdlQJ8tWQ82/GMk1JT2JyYbq5iZo7gKx4+Rw7i+3JlO3ydX9xlE6w== X-Received: by 2002:a05:6402:1644:: with SMTP id s4mr2774807edx.190.1623832024719; Wed, 16 Jun 2021 01:27:04 -0700 (PDT) Received: from abel.fritz.box ([2a02:908:1252:fb60:8b88:17a4:582b:121f]) by smtp.gmail.com with ESMTPSA id v7sm1152639edx.38.2021.06.16.01.27.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Jun 2021 01:27:04 -0700 (PDT) From: "=?UTF-8?q?Christian=20K=C3=B6nig?=" X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: daniel@ffwll.ch, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-media@vger.kernel.org, sumit.semwal@linaro.org Subject: [PATCH 7/7] drm/amdgpu: drop CS workaround adding the shared manually Date: Wed, 16 Jun 2021 10:26:55 +0200 Message-Id: <20210616082655.111001-8-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210616082655.111001-1-christian.koenig@amd.com> References: <20210616082655.111001-1-christian.koenig@amd.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Drop the workaround adding the shared fence manually in the CS. Signed-off-by: Christian König --- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c index 25655414e9c0..af8f5ff5f12c 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c @@ -1273,14 +1273,10 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p, /* * Work around dma_resv shortcommings by wrapping up the * submission in a dma_fence_chain and add it as exclusive - * fence, but first add the submission as shared fence to make - * sure that shared fences never signal before the exclusive - * one. + * fence. */ dma_fence_chain_init(chain, dma_resv_excl_fence(resv), dma_fence_get(p->fence), 1); - - dma_resv_add_shared_fence(resv, p->fence); rcu_assign_pointer(resv->fence_excl, &chain->base); e->chain = NULL; }