From patchwork Mon Oct 30 14:59:04 2017 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: 10032729 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 ACE46603B4 for ; Mon, 30 Oct 2017 14:59:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9F72728595 for ; Mon, 30 Oct 2017 14:59:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 93F9A284D2; Mon, 30 Oct 2017 14:59:14 +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_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, 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 57494284D2 for ; Mon, 30 Oct 2017 14:59:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 12E6E6E3B4; Mon, 30 Oct 2017 14:59:13 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x243.google.com (mail-wm0-x243.google.com [IPv6:2a00:1450:400c:c09::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1E6526E3A3; Mon, 30 Oct 2017 14:59:09 +0000 (UTC) Received: by mail-wm0-x243.google.com with SMTP id b189so16389738wmd.4; Mon, 30 Oct 2017 07:59:09 -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=LqnfEFmz6tcGVMFHBtvjEc4VyX1pHaOtWnz51h7SsSM=; b=vgndZw7OHLWmT4dCAZmrZ7Ai96RV6Dw1wQ6qAi7FXzZEjlmZsIY2d5eK7/9/vEBOu5 DcyHgQWnyfXr9RZ3Q8o1PfR9PJ/5QSLCn0XYHpVcPhPIsQ42pxJPA9atv0weIg3UPt+p 1DoJC3qEGoESfnL0ARCQj64HnE4Zoqex0oCSkJBuQcHXf+4LGxyvP7x9CBjvS3kyFuHJ 4UyaODNHXzN0a9bxToC8kfvnoflrxcPFhka/TaUzy0i0Di+SXHTWdsODveAnB5yG46ek zgNiqZJuqg3Zt5pl85dW0rbIqR/+9T2JhS68arJD6C/lLrBCEvikV7OacCtmAKZD9pkW 0zYw== 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=LqnfEFmz6tcGVMFHBtvjEc4VyX1pHaOtWnz51h7SsSM=; b=DKlL1n4TiI3OXbFjM6mcSqJiFGss+3GrBSTdkEhVxOzScYCJi3txAVwpEI+KS/ED3r HZAzLMf/kU4Ljx7vuSFxYT/kWEhp25mq/POQv+9LMnsLYQo5WN1ZxhwrsdOV3b/KdmEH ZzRpALtHIH1dqFXixV5hC+TwgfOmdpDxGrDB0tEdU3o47iXXdRec4sPCyw09lv+rtsGd 5G23qb8XuhdAutpfiS4taYjmtGM4sXC1/bLjA9t5BnJ7+EmuONbD4FvUJiOyGkM0TA8D 3p7/BgIQ+A+YjVvXkgD4LLvX6QGNppdTHuisUy5fd+feCjhfFncAMTnKriJ+rtc0YP34 0Bkg== X-Gm-Message-State: AMCzsaVd8RrNkBnmI7WlKfThGjyN1u/OWQmVYdZkfUMRk9u1yZbs8Pft /V/smDKgtCNJOYMGex+2SuS0XA== X-Google-Smtp-Source: ABhQp+ShkjrCyBrbaorF+sWXQSWoLesb08Wd+FC+2JZlXALs2LF7CmAV0Znj5fV3wLu2T+j4Z7AoNg== X-Received: by 10.28.15.141 with SMTP id 135mr4086364wmp.74.1509375548428; Mon, 30 Oct 2017 07:59:08 -0700 (PDT) Received: from localhost.localdomain ([2a02:908:1251:7981:7dea:e6ff:9c90:f1e3]) by smtp.gmail.com with ESMTPSA id o20sm14670147wro.6.2017.10.30.07.59.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Oct 2017 07:59:07 -0700 (PDT) From: "=?UTF-8?q?Christian=20K=C3=B6nig?=" X-Google-Original-From: =?UTF-8?q?Christian=20K=C3=B6nig?= To: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org Subject: [PATCH 2/2] dma-buf: try to replace a signaled fence in reservation_object_add_shared_inplace Date: Mon, 30 Oct 2017 15:59:04 +0100 Message-Id: <20171030145904.18584-2-deathsimple@vodafone.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171030145904.18584-1-deathsimple@vodafone.de> References: <20171030145904.18584-1-deathsimple@vodafone.de> MIME-Version: 1.0 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 From: Christian König The amdgpu issue to also need signaled fences in the reservation objects should be fixed by now. Optimize the handling by replacing a signaled fence when adding a new shared one. Signed-off-by: Christian König --- drivers/dma-buf/reservation.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/dma-buf/reservation.c b/drivers/dma-buf/reservation.c index 6fc794576997..a3928ce9f311 100644 --- a/drivers/dma-buf/reservation.c +++ b/drivers/dma-buf/reservation.c @@ -104,7 +104,8 @@ reservation_object_add_shared_inplace(struct reservation_object *obj, struct reservation_object_list *fobj, struct dma_fence *fence) { - u32 i; + struct dma_fence *signaled = NULL; + u32 i, signaled_idx; dma_fence_get(fence); @@ -126,17 +127,28 @@ reservation_object_add_shared_inplace(struct reservation_object *obj, dma_fence_put(old_fence); return; } + + if (!signaled && dma_fence_is_signaled(old_fence)) { + signaled = old_fence; + signaled_idx = i; + } } /* * memory barrier is added by write_seqcount_begin, * fobj->shared_count is protected by this lock too */ - RCU_INIT_POINTER(fobj->shared[fobj->shared_count], fence); - fobj->shared_count++; + if (signaled) { + RCU_INIT_POINTER(fobj->shared[signaled_idx], fence); + } else { + RCU_INIT_POINTER(fobj->shared[fobj->shared_count], fence); + fobj->shared_count++; + } write_seqcount_end(&obj->seq); preempt_enable(); + + dma_fence_put(signaled); } static void