From patchwork Tue Mar 6 07:00:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liu, Monk" X-Patchwork-Id: 10260869 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 E6010602C8 for ; Tue, 6 Mar 2018 07:14:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D18A328E5B for ; Tue, 6 Mar 2018 07:14:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C5CD828E6F; Tue, 6 Mar 2018 07:14:09 +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=BAD_ENC_HEADER,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 41CD928E5B for ; Tue, 6 Mar 2018 07:14:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C4A486E569; Tue, 6 Mar 2018 07:14:07 +0000 (UTC) X-Original-To: dri-devel@freedesktop.org Delivered-To: dri-devel@freedesktop.org Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-by2nam03on0078.outbound.protection.outlook.com [104.47.42.78]) by gabe.freedesktop.org (Postfix) with ESMTPS id 69F606E569 for ; Tue, 6 Mar 2018 07:14:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=BkL/7oJ7/VlFatX5Bnpw3xvB/0fHXC/cGWwWKANuavk=; b=ochamHL9sBB5rblE3N7wNq+EtfrmYVIau8Wrdxi9GTCssdoFsyFMPz0VW2hxmDai1hVn95adSLh09GU8Xyp7oKz6X2dATviGFYxTuzY6OS9fSEPIdFa9a5oiaC/5IQK81wXsf/UcpK3tOWFAAsZdJMavnVIGadby6myMcyMSRf8= Received: from SN1PR12CA0012.namprd12.prod.outlook.com (10.162.96.150) by BY2PR12MB0021.namprd12.prod.outlook.com (10.160.66.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.548.13; Tue, 6 Mar 2018 07:14:04 +0000 Received: from BY2NAM03FT030.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e4a::204) by SN1PR12CA0012.outlook.office365.com (2a01:111:e400:5174::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.548.13 via Frontend Transport; Tue, 6 Mar 2018 07:14:04 +0000 Authentication-Results: spf=none (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; freedesktop.org; dkim=none (message not signed) header.d=none;freedesktop.org; dmarc=permerror action=none header.from=amd.com; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXCHOV01.amd.com (165.204.84.17) by BY2NAM03FT030.mail.protection.outlook.com (10.152.84.214) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.20.527.18 via Frontend Transport; Tue, 6 Mar 2018 07:14:03 +0000 Received: from monk-build.amd.com (10.34.1.3) by SATLEXCHOV01.amd.com (10.181.40.71) with Microsoft SMTP Server id 14.3.382.0; Tue, 6 Mar 2018 01:14:01 -0600 From: Monk Liu To: Subject: [PATCH] dma-buf/reservation: should keep later one in add fence(v3) Date: Tue, 6 Mar 2018 15:00:53 +0800 Message-ID: <1520319653-4743-1-git-send-email-Monk.Liu@amd.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:165.204.84.17; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(39860400002)(39380400002)(396003)(346002)(376002)(2980300002)(428003)(199004)(189003)(2906002)(478600001)(68736007)(50466002)(106466001)(48376002)(105586002)(86362001)(16586007)(53416004)(47776003)(316002)(336012)(2351001)(81156014)(81166006)(1857600001)(8676002)(104016004)(50226002)(97736004)(5660300001)(6666003)(6916009)(36756003)(8936002)(7696005)(305945005)(77096007)(53936002)(4326008)(51416003)(59450400001)(26005)(72206003)(356003)(186003); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR12MB0021; H:SATLEXCHOV01.amd.com; FPR:; SPF:None; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2NAM03FT030; 1:t7J9a8Nx9f5IrHqUhsATW7Z+cEQ/L/rGJl5Gm7NFqgD32HsgkMa3HcHDIiU90KEtbw7UpzQM3D5xXALIewjz628x0iJ4enfkF6Q8fksTGow7CHlntb+/ZjvNnqAbynCD X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d1cb1377-8482-45e4-94aa-08d58331d7d1 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060); SRVR:BY2PR12MB0021; X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0021; 3:sQZoHkCHUbk6zg2e8X34T/w1RRdhTxsN/mI7Gk7OiwUnBlmysp8MQjjNIkaGss/RNHppPgYHXwkdPaEyYW1YP1EQMh+Eq7KLaQ/U6Pf/I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TkV8LZOLG5NlC2/L8Kn5mUuFfWRiBQZLXYPcu90dMkMx3q27Rup9mEIdXSa6kbZHokljIdfJdtaq5pCG2yLxpZwTM2JvYI2cc38mK+IeYmwTSZUEwe8M8UzrBstPHwMUdpd4LOtkD1tGX6dyc3xtjny+Wpk2Q1jSgfTiNtFfDK3q5Wtcc3+zIyDfAcf4X1Bcvi4/PCUHCXaCxCqCxtsQW63m2u7pZS6g6rf5iXNk+RojKBYjArERSPFfjfX+lLWfVI4jMq+9bwMpHEDHK26sZc5AHVkugvcKewUUz/03/o/C7pNCELJsTlgPkscEhLYzYSHD9uQFmszwB/bHsQqCgHONz X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040501)(2401047)(8121501046)(5005006)(93006095)(93003095)(10201501046)(3002001)(3231220)(944501244)(52105095)(6055026)(6041288)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(6072148)(201708071742011); SRVR:BY2PR12MB0021; BCL:0; PCL:0; RULEID:; SRVR:BY2PR12MB0021; X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0021; 4:XrLipqSET7PP+aO6Ycx7Y4mTMmccvytvTmjoIKynKYVjdHY897bf+5pPJaK/xSGbU4pvm+c1zcaaCliiW8zv4qQov0Fn8Pl3HMV2ROjVrq8ynmsvCh1p/uDhsuW2lbGEG0lN13RsuBfWbH3Wa1XZs+EdWaXcD+jU31kBg5cDrE72sxYaSiq/EQJ2qWmSBw+G5yWDg6BFimMSJMWsuQc5WleRSs0cCFuMIEsgb1oWf3Oo7bOoJuMVZ4pvsRrJ20Otj/TykcPjv7MXpFVViIOdNdkMh3UBuT1+PmLlGqCU6gUB79FXApTH2MA8lP38wG2l X-Forefront-PRVS: 06036BD506 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY2PR12MB0021;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J37wTznqR7fMsf8Iu6vcAr4VdHtuoAlEvkRnUHamXbodC/RAJJw8k+Fd4gDDCLRXpNCnFkAFkGlYY/1r11JzWsFiOpRlUla4qjGXg1ohE=; 7:I+E3HuS2MDY5BDIymXcQrs7nfcUfwZZLyeGDCcepgyIIhCIKZCEZsyM5ET6DTQpTazmoT6Gu+/ydPXVrwLzaIKilaaCaJzyZd6znoKpnw1QU4+qtQId0/lizMW6Tv1AT108RqlvI9CF8dvUeD2JaQxPdboEPVwiCgsfkzwSEbjqtXC74qjlqpP6GcWcnyUugEic19NYwvCNb1a+NLZGCTFMKGLXpMgmbPBKcWeakQULZHGXwsna59xrOtpatNOaX SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0021; 20:I2bVZyml23Jy5/y4k5NDiRCBcJmzpwy7QrqMPo8e725GK0KKU3Lhs2l2BXAhIpHIyISL48cURmvEStHLYnRQjX5cRPMzUvmNdGtcb/pJaM/sLeZ9D5PECHMdAT0Z6Wxb1qFdc0Fn2qneB/l5C+tUzMfRpy3ZlVPzapc1cljEgPAsAzZ4DuY2fGKsfm0bhnxQPcgkFr12VymMzAKe0RCNKz9m8iZKLDoVsAV/JWg5yr8kyA7Ns8aYGzKK1y8HIMjs X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Mar 2018 07:14:03.8703 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d1cb1377-8482-45e4-94aa-08d58331d7d1 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXCHOV01.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR12MB0021 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: Monk Liu Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP v2: still check context first to avoid warning from dma_fence_is_later apply this fix in add_shared_replace as well v3: use a bool falg to indict if fence is need to insert to new slot and ignore it if it is an eld fence compared with the one with the same context in old->shared Change-Id: If6a979ba9fd6c923b82212f35f07a9ff31c86767 Signed-off-by: Monk Liu --- drivers/dma-buf/reservation.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/drivers/dma-buf/reservation.c b/drivers/dma-buf/reservation.c index 314eb10..a7d0598 100644 --- a/drivers/dma-buf/reservation.c +++ b/drivers/dma-buf/reservation.c @@ -118,7 +118,8 @@ reservation_object_add_shared_inplace(struct reservation_object *obj, old_fence = rcu_dereference_protected(fobj->shared[i], reservation_object_held(obj)); - if (old_fence->context == fence->context) { + if (old_fence->context == fence->context && + dma_fence_is_later(fence, old_fence)) { /* memory barrier is added by write_seqcount_begin */ RCU_INIT_POINTER(fobj->shared[i], fence); write_seqcount_end(&obj->seq); @@ -158,6 +159,7 @@ reservation_object_add_shared_replace(struct reservation_object *obj, struct dma_fence *fence) { unsigned i, j, k; + bool wrong_fence = false; dma_fence_get(fence); @@ -179,15 +181,29 @@ reservation_object_add_shared_replace(struct reservation_object *obj, check = rcu_dereference_protected(old->shared[i], reservation_object_held(obj)); - if (check->context == fence->context || - dma_fence_is_signaled(check)) + if (dma_fence_is_signaled(check)) { + /* put check to tail of fobj if signaled */ RCU_INIT_POINTER(fobj->shared[--k], check); - else + } else if (check->context == fence->context) { + if (dma_fence_is_later(fence, check)) { + /* put check to tail of fobj if it is deprecated */ + RCU_INIT_POINTER(fobj->shared[--k], check); + } else { + /* this is a wrong operation that add an eld fence */ + wrong_fence = true; + RCU_INIT_POINTER(fobj->shared[j++], check); + } + } else { + /* add fence to new slot */ RCU_INIT_POINTER(fobj->shared[j++], check); + } } + fobj->shared_count = j; - RCU_INIT_POINTER(fobj->shared[fobj->shared_count], fence); - fobj->shared_count++; + if (!wrong_fence) { + RCU_INIT_POINTER(fobj->shared[fobj->shared_count], fence); + fobj->shared_count++; + } done: preempt_disable();