From patchwork Tue Mar 6 07:19:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chunming Zhou X-Patchwork-Id: 10260875 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 B313360211 for ; Tue, 6 Mar 2018 07:19:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8FE6628E76 for ; Tue, 6 Mar 2018 07:19:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8345028E7C; Tue, 6 Mar 2018 07:19:54 +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_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 1C8F828E76 for ; Tue, 6 Mar 2018 07:19:53 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 61FF66E577; Tue, 6 Mar 2018 07:19:51 +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-by2nam03on0073.outbound.protection.outlook.com [104.47.42.73]) by gabe.freedesktop.org (Postfix) with ESMTPS id 198976E577 for ; Tue, 6 Mar 2018 07:19:49 +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=vXSmEeM7CHEzPZyZpze4eoAkyj7jY+Fb/PbX5kG1XcM=; b=tTOxUSNz+MPpUXSUn6Ti8KaaMn6CMBs1kuc05mpy71Q2MAk4Zed2UPONSDA7BxBrgszHZKdyohIEZ9Zjhl23UpUTfXJoOyLjs7NF8T6ViPB1bzCpRuUciYGXWCeX3I5PNlLTAHV7g97br211sC0Ab/Bhs+Z3COdmO+1pV3QEEm8= Received: from MWHPR1201MB0206.namprd12.prod.outlook.com (10.174.99.16) by MWHPR1201MB0110.namprd12.prod.outlook.com (10.174.98.137) 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:19:47 +0000 Received: from MWHPR1201MB0206.namprd12.prod.outlook.com ([fe80::b874:65ec:383a:7e62]) by MWHPR1201MB0206.namprd12.prod.outlook.com ([fe80::b874:65ec:383a:7e62%17]) with mapi id 15.20.0548.016; Tue, 6 Mar 2018 07:19:46 +0000 From: "Zhou, David(ChunMing)" To: "Liu, Monk" , "dri-devel@freedesktop.org" Subject: RE: [PATCH] dma-buf/reservation: should keep later one in add fence(v3) Thread-Topic: [PATCH] dma-buf/reservation: should keep later one in add fence(v3) Thread-Index: AQHTtRq+iccCuAyZY0mwyIgoIYSORKPCzDwg Date: Tue, 6 Mar 2018 07:19:46 +0000 Message-ID: References: <1520319653-4743-1-git-send-email-Monk.Liu@amd.com> In-Reply-To: <1520319653-4743-1-git-send-email-Monk.Liu@amd.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [116.228.147.241] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; MWHPR1201MB0110; 7:HFjf19XDpg9N+dEPNrFfFu9w/wZUBPpduWuzcxMIl0L8VtHt+HuV0tt7MWJ7Seuadmq5gGLbOyMN1LLEXSp1CyWYzCMCcSUEX2GiuXh2KsvKGE/sCD6zHMprx8ASe2YIjFW6OQl+quwtpIUqOH3v5o9lCHquYBK+dHfw26EdaTfyJxkc2bpSMjFHdZZF6ckI+HK6Wdpb8GBsE31X1pA9GKLuFApnCcFBwIdzsupajxOs/GMrDtidZQcRd7BcqGj5; 20:RAkbQpVEKWMzDYcK34hrQh8iIDp6f6O+7XZtj7HqWFJB1H/VAAvrYwwu04YRvGf/46xIi+XSzYFaI8VTGNL4bo4o/aaXnmaQBqVuxLXnn7r4vLW4Ffj0hD29pZD0Z0xWcwHu9zmcLHbrdW4zbriu+08wlZC+zwUigC1Z/lG7c35njlI1mPTni2NvIPD6Bfcx9zrDNC2ryOlASRfiZVcVeGPehoccZaD/dPngDCcFJ7O47mL7QO59IRxhSvEbgF3H x-ms-exchange-antispam-srfa-diagnostics: SSOS;SSOR; x-forefront-antispam-report: SFV:SKI; SCL:-1; SFV:NSPM; SFS:(10009020)(366004)(39380400002)(346002)(39860400002)(396003)(376002)(13464003)(199004)(189003)(14454004)(53936002)(5660300001)(229853002)(105586002)(102836004)(6346003)(8676002)(9686003)(6436002)(26005)(81166006)(81156014)(66066001)(6506007)(55016002)(53546011)(25786009)(6306002)(305945005)(68736007)(74316002)(59450400001)(3660700001)(3280700002)(4326008)(99286004)(72206003)(478600001)(6116002)(86362001)(316002)(2501003)(33656002)(7696005)(76176011)(5250100002)(7736002)(106356001)(97736004)(2906002)(966005)(2950100002)(110136005)(6246003)(8936002)(3846002)(2900100001); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR1201MB0110; H:MWHPR1201MB0206.namprd12.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 473519c2-521e-4e56-e9bb-08d58332a3e4 x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(2017052603328)(7153060)(7193020); SRVR:MWHPR1201MB0110; x-ms-traffictypediagnostic: MWHPR1201MB0110: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(767451399110)(217544274631240); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040501)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231220)(944501244)(52105095)(10201501046)(3002001)(6055026)(6041288)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123558120)(6072148)(201708071742011); SRVR:MWHPR1201MB0110; BCL:0; PCL:0; RULEID:; SRVR:MWHPR1201MB0110; x-forefront-prvs: 06036BD506 received-spf: None (protection.outlook.com: amd.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=David1.Zhou@amd.com; x-microsoft-antispam-message-info: 3AZoSwxEBKaSPz0QmgZ1jsTtQscVlbBYwKDg9W/jdI4Fz+rUDOn5FGe19rHADJIrzUXb9JiBemXq65AXlBc6BX6WAYDZGW1NlLf+qQNrYZiaj5kS3Ed+qIQQfZR4BdR/YWSooKs79A4Pp9tsIAnHFBihWDly/pKFgz0EOfOfOnM7VI8wiq4oVbyuWC6XXgAgPgQ0xF+X8UlGQkG+qJJ6iB97mZmwy2sUe1ccg0JRDrtlYxUHAmC+CBAW7DxL8/51mDi9L7A5oSPEb9pcPjtscy6xXB5n7HAgr9SYRPARrbaJUkMDcBZ82By+KhTjLY52AECw9/UBDLU01AMuK/bjzw== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 473519c2-521e-4e56-e9bb-08d58332a3e4 X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Mar 2018 07:19:46.2209 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR1201MB0110 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: "Liu, Monk" Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Patch looks ok to me, Reviewed-by: Chunming Zhou , and it’s better to get others RB as well. Regards, David Zhou -----Original Message----- From: dri-devel [mailto:dri-devel-bounces@lists.freedesktop.org] On Behalf Of Monk Liu Sent: Tuesday, March 06, 2018 3:01 PM To: dri-devel@freedesktop.org Cc: Liu, Monk Subject: [PATCH] dma-buf/reservation: should keep later one in add fence(v3) 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(-) -- 2.7.4 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel 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();