From patchwork Tue Mar 12 03:10:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chunming Zhou X-Patchwork-Id: 10848549 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 037561515 for ; Tue, 12 Mar 2019 03:11:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E0280294BE for ; Tue, 12 Mar 2019 03:11:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D3C55294BF; Tue, 12 Mar 2019 03:11:19 +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.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED 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 7C115294C5 for ; Tue, 12 Mar 2019 03:11:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 08B6889C60; Tue, 12 Mar 2019 03:11:17 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM03-DM3-obe.outbound.protection.outlook.com (mail-dm3nam03on0624.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe49::624]) by gabe.freedesktop.org (Postfix) with ESMTPS id 942AF898C2; Tue, 12 Mar 2019 03:11:15 +0000 (UTC) Received: from BN6PR1201CA0008.namprd12.prod.outlook.com (2603:10b6:405:4c::18) by BY2PR12MB0584.namprd12.prod.outlook.com (2a01:111:e400:52dd::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1686.19; Tue, 12 Mar 2019 03:11:13 +0000 Received: from DM3NAM03FT014.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e49::208) by BN6PR1201CA0008.outlook.office365.com (2603:10b6:405:4c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1686.17 via Frontend Transport; Tue, 12 Mar 2019 03:11:13 +0000 Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXCHOV01.amd.com (165.204.84.17) by DM3NAM03FT014.mail.protection.outlook.com (10.152.82.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1686.19 via Frontend Transport; Tue, 12 Mar 2019 03:11:12 +0000 Received: from zhoucm1.amd.com (10.34.1.3) by SATLEXCHOV01.amd.com (10.181.40.71) with Microsoft SMTP Server id 14.3.389.1; Mon, 11 Mar 2019 22:11:11 -0500 From: Chunming Zhou To: , , , , Subject: [PATCH 2/9] drm/syncobj: add new drm_syncobj_add_point interface v3 Date: Tue, 12 Mar 2019 11:10:42 +0800 Message-ID: <20190312031049.23647-2-david1.zhou@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190312031049.23647-1-david1.zhou@amd.com> References: <20190312031049.23647-1-david1.zhou@amd.com> 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)(136003)(376002)(346002)(396003)(39860400002)(2980300002)(428003)(199004)(189003)(2201001)(4326008)(53416004)(105586002)(66574012)(316002)(50466002)(5660300002)(478600001)(8936002)(50226002)(53936002)(1076003)(54906003)(14444005)(47776003)(6666004)(110136005)(97736004)(76176011)(6636002)(2616005)(2906002)(81156014)(7696005)(23676004)(126002)(476003)(486006)(356004)(36756003)(305945005)(336012)(106466001)(81166006)(11346002)(68736007)(426003)(446003)(186003)(2870700001)(5820100001)(8676002)(72206003)(77096007)(26005)(104016004)(86362001); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR12MB0584; H:SATLEXCHOV01.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoDomainNonexistent; A:1; MX:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f0389fe9-99c0-40c0-bfea-08d6a698621f X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(2017052603328)(7153060); SRVR:BY2PR12MB0584; X-MS-TrafficTypeDiagnostic: BY2PR12MB0584: X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0584; 20:4OXA/9ySaUyShQ8F+IrOpNYxl6MVQ5jDtZ+h3TNcmq2gfCWggj4pAv7738lG48TPIuMgMmb6U7I0Jx4+qIoXAuWEruZIF7c+1mDqYxJfLlMdqa72RzmA8jcmp6s5rcfNdarVoFzW3bkl2Eg4PnFeZKRQ4EUBdGnYCX2Jb8naVrRhiz1gvSR5RRiXYjNCHJeuvYbuj7bddyV/PejJSWFPQbt+szQ26jyGFNBdHkAj5xQlULB32zJt4LJBnUcbW9AfZFJHHp5kmWV/G8RoJ3SHKWfsB0DLtwqBUnX3NHe5wIfu70mT9mDtWFAIid0DeGtr9dvov2Jc1IvlD9r02eSjJol6qNx5aunS/yb1HxpUUVWWWoQ/tNKIXISUNBN1D4Fh4kmVrJEEWU2GIkZ1t/0WEheshtKye7vvvS03VIeQMF0OsRJ1yWIAbRLEhgFFI/iBe8HPTI7cEvaLyTCvIHJ7c7cNTlFFI41UYS0jZr5s8vSYr6OxoNAc6Ff6WKL6gO9j X-Microsoft-Antispam-PRVS: X-Forefront-PRVS: 09749A275C X-Microsoft-Exchange-Diagnostics: =?utf-8?q?1=3BBY2PR12MB0584=3B23=3ApnSN0i+?= =?utf-8?q?wcGNSVOi5F04BJHSU7C1ter8T2qjakN+OSM2vUh/gB59545Y9roUnXtwXmd3OatE/?= =?utf-8?q?G1e/d4esJHx8MOsr0a//PfLuSP821syDkZY3e6SeI4PKh1I5sHt6zlRxVIAttv4v4?= =?utf-8?q?vPa6JUP0D+DhKaEUb8/i0Y2CnBZOsLONjiOwD1V0a2hjxsVTqiQsGPaoT5lZ0wTq9?= =?utf-8?q?K38QuTlCSH/MnKmgblDv9P1k/SR+qpB9y7oT4Qi2qAGnKp1Ij2JkbeoKngJFRokop?= =?utf-8?q?x1T5iq/nlXASoy2bSgdqjYQRZfSfGNftLUdG88VtXhigoK6ji9Q6EQyrGqMh/yitx?= =?utf-8?q?JIwvHnZ6V0h2HcD4UMkwb8EhMjubsLj3kNDhCL5QDIqTegvRpNJSx720jzmPYgnzr?= =?utf-8?q?86bemG2YL6iT/b0bWb4fzfFtqLp3nxBNzj/ev3bfLzCeyrzJ9nIk+woMfDjJflyFi?= =?utf-8?q?tO1OJJthtcVbshJ7wZ4B2FmY52egRUQkrbXGB+caSFN+gdS39SHN4N90YjkGMDPSM?= =?utf-8?q?GbvCEUx4eiy/3rWSmJAzTAZsAqkEgK7fSMR2R14qP8N21IJbZRjcA15O6HPOadkx6?= =?utf-8?q?aMJQpUe3qFB7BrcFc9pgWfL0NcJ7fEuQbw/suhtqyaq2bkuzcHvXsZM9/vE+92dxq?= =?utf-8?q?EwHzDodfNZUotIdf9LE2gHHde0vODx7qvia35ku1rkGibbsylJRsiBhkcGbXj6GKk?= =?utf-8?q?0UtEi/PaTX7AL6nmZnhTFccOdQqGrT06EnnZ68eMnyTboKpay/dX9zem4EKAOgX8N?= =?utf-8?q?Ngs2pHilhHdOeIpFb9iLW3FXmdh9JDEItN6+3tMCB3T3ljMNZNdXzL1Ce9TvbuzAW?= =?utf-8?q?3N6wSJedj4VZzlwTpK3cDrlaUy4mWwLI0oTDY3JLlixx068yHa0CME7tzXufUInOM?= =?utf-8?q?2nlNe6Hbgy5BfJh977lifGyan56TKq/10RdqZ9PtVV/GXom7jd92Abpg4nzhQLLW9?= =?utf-8?q?dbTOgSTPlW2k5jghw3pO0wQ00oopZ7Kv4f33hJT2XnKKkKpvEVIsU65NKy0HKr04s?= =?utf-8?q?oLdwQchRIotjEQPSchtmU/PGaM5mPVltLwykoROGbVGgWFjJi5YNdEdWOtLhQ30Kr?= =?utf-8?q?3IYrJou+og9R8izrnzLvr/EJCRwDSQ/eijGlSN6sQAu8GBNYSs+L/1FZCqPCfOq8U?= =?utf-8?q?QKQ04vNexoOSGUA/JDBpHnu6FUqVZGcxzR2z1CGGcRuSGe4VuGgtfBtfyYWA3eh0C?= =?utf-8?q?MUDfDuu/Rkmi+ZtPJSxqmZyoRK0ks9tStJlwBU?= X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: 8RPe48dmjsT3HgAm3Bcq45Rm91GfuSyjwwuOkLyi25ZihJ8JgXTMOV2e1AyrcaDPrBkrcCgBZqhCevgFAKFet8S5FaayJqV7bHH96WAjmv+gFgsNuks/veCQ+Yoem8JHity08sSZil+DzRRbaPf+fd1+v63S+7hkw6ZpcvOHfg2p/ZPUjPF47Y48aUw6EwbdX+frRpimwGO+SRi5ql/Fgn+T04JBFWkFuWLC/9PcY40RJEkqgD8iJQ6I9TLbKTRwF3Hd1tZVLt6t3KuQQnX6fEI8JueK72y7L8mxAvxPST3PlHVVlCQVh3kxdOjpr0dkCmuWQbtFSfANC8YIe7rbpsGKq/MDd5XugPxhne1M0MWnSgYMkvLslUeeVFzMjCMtfVqNvt4KbxlIh2EogKdHX7uuCm2LtLUCU0DTZncZbeg= X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0584; 20:n0hmt1gQFEr8nYkzH98oTEGdMX4XhZ00ItYjZ3gtP2xBn81FLs0h/HIsvwJlMjQmZx7Zidpq+oIvMdnJ4jn1uKK2B4ysecTlCH8GzvXcxOadtG+7kxfDqRbeZll4Jt2u1A4MbKszOAIBQ9S9l5s6ab4niJ4JQj9MUBenav2xWYonqYoP56CdkbLY2tvQtck4mbpp9UwiVB6AUHbFh4OIQZTIf++v3v5V3ynMj3ZSYfxJPeku/Vurvd7nkFXopJlA X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Mar 2019 03:11:12.7868 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f0389fe9-99c0-40c0-bfea-08d6a698621f 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: BY2PR12MB0584 X-Mailman-Original-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:X-MS-Exchange-SenderADCheck; bh=g/XGLbxgaU88DGm81v8i08Pk9I1h4avpmVfID/xALT4=; b=Tg08vA76x7/+wAZQlVD/e5M455H5wnr4CNSGCWDuMOHFIvKKSAlhNNys4DtIYi/JemjpGzEl5OTlu8GebCJ8N2y3xa73IqLZ6dBSFNfKccf84NwlPHafVQWNCekoANi9WkeI5UZ0L+6/NOW9Q35QnieUZp2hH0MYi4AUgxHoO7I= X-Mailman-Original-Authentication-Results: spf=none (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; jlekstrand.net; dkim=none (message not signed) header.d=none;jlekstrand.net; dmarc=permerror action=none header.from=amd.com; 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: =?utf-8?q?Christian_K=C3=B6nig?= , =?utf-8?q?Christian_K=C3=B6nig?= Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Christian König Use the dma_fence_chain object to create a timeline of fence objects instead of just replacing the existing fence. v2: rebase and cleanup v3: fix garbage collection parameters Signed-off-by: Christian König --- drivers/gpu/drm/drm_syncobj.c | 37 +++++++++++++++++++++++++++++++++++ include/drm/drm_syncobj.h | 5 +++++ 2 files changed, 42 insertions(+) diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c index 5329e66598c6..933225fde9a9 100644 --- a/drivers/gpu/drm/drm_syncobj.c +++ b/drivers/gpu/drm/drm_syncobj.c @@ -122,6 +122,43 @@ static void drm_syncobj_remove_wait(struct drm_syncobj *syncobj, spin_unlock(&syncobj->lock); } +/** + * drm_syncobj_add_point - add new timeline point to the syncobj + * @syncobj: sync object to add timeline point do + * @chain: chain node to use to add the point + * @fence: fence to encapsulate in the chain node + * @point: sequence number to use for the point + * + * Add the chain node as new timeline point to the syncobj. + */ +void drm_syncobj_add_point(struct drm_syncobj *syncobj, + struct dma_fence_chain *chain, + struct dma_fence *fence, + uint64_t point) +{ + struct syncobj_wait_entry *cur, *tmp; + struct dma_fence *prev; + + dma_fence_get(fence); + + spin_lock(&syncobj->lock); + + prev = drm_syncobj_fence_get(syncobj); + dma_fence_chain_init(chain, prev, fence, point); + rcu_assign_pointer(syncobj->fence, &chain->base); + + list_for_each_entry_safe(cur, tmp, &syncobj->cb_list, node) { + list_del_init(&cur->node); + syncobj_wait_syncobj_func(syncobj, cur); + } + spin_unlock(&syncobj->lock); + + /* Walk the chain once to trigger garbage collection */ + dma_fence_chain_for_each(fence, prev); + dma_fence_put(prev); +} +EXPORT_SYMBOL(drm_syncobj_add_point); + /** * drm_syncobj_replace_fence - replace fence in a sync object. * @syncobj: Sync object to replace fence in diff --git a/include/drm/drm_syncobj.h b/include/drm/drm_syncobj.h index 0311c9fdbd2f..6cf7243a1dc5 100644 --- a/include/drm/drm_syncobj.h +++ b/include/drm/drm_syncobj.h @@ -27,6 +27,7 @@ #define __DRM_SYNCOBJ_H__ #include +#include struct drm_file; @@ -112,6 +113,10 @@ drm_syncobj_fence_get(struct drm_syncobj *syncobj) struct drm_syncobj *drm_syncobj_find(struct drm_file *file_private, u32 handle); +void drm_syncobj_add_point(struct drm_syncobj *syncobj, + struct dma_fence_chain *chain, + struct dma_fence *fence, + uint64_t point); void drm_syncobj_replace_fence(struct drm_syncobj *syncobj, struct dma_fence *fence); int drm_syncobj_find_fence(struct drm_file *file_private,