From patchwork Tue Mar 12 03:10:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chunming Zhou X-Patchwork-Id: 10848547 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 062F71850 for ; Tue, 12 Mar 2019 03:11:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D7A7D294BD for ; Tue, 12 Mar 2019 03:11:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CBA60294BF; Tue, 12 Mar 2019 03:11:12 +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 C88A3294BD for ; Tue, 12 Mar 2019 03:11:11 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2E8E089856; Tue, 12 Mar 2019 03:11:09 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM05-DM3-obe.outbound.protection.outlook.com (mail-eopbgr730080.outbound.protection.outlook.com [40.107.73.80]) by gabe.freedesktop.org (Postfix) with ESMTPS id 45CBC89854; Tue, 12 Mar 2019 03:11:07 +0000 (UTC) Received: from DM3PR12CA0126.namprd12.prod.outlook.com (2603:10b6:0:51::22) by BN8PR12MB2963.namprd12.prod.outlook.com (2603:10b6:408:61::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1686.20; Tue, 12 Mar 2019 03:11:04 +0000 Received: from DM3NAM03FT041.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e49::203) by DM3PR12CA0126.outlook.office365.com (2603:10b6:0:51::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1686.18 via Frontend Transport; Tue, 12 Mar 2019 03:11:04 +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 DM3NAM03FT041.mail.protection.outlook.com (10.152.83.207) 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:03 +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:02 -0500 From: Chunming Zhou To: , , , , Subject: [PATCH 1/9] dma-buf: add new dma_fence_chain container v5 Date: Tue, 12 Mar 2019 11:10:41 +0800 Message-ID: <20190312031049.23647-1-david1.zhou@amd.com> X-Mailer: git-send-email 2.17.1 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)(376002)(396003)(136003)(39860400002)(346002)(2980300002)(428003)(189003)(199004)(72206003)(5820100001)(86362001)(8936002)(2616005)(110136005)(2906002)(4326008)(54906003)(77096007)(2870700001)(36756003)(186003)(7696005)(486006)(26005)(2201001)(478600001)(336012)(5660300002)(68736007)(97736004)(66574012)(6666004)(356004)(426003)(81156014)(81166006)(8676002)(1076003)(53416004)(47776003)(30864003)(104016004)(6636002)(105586002)(316002)(106466001)(476003)(50466002)(126002)(50226002)(23676004)(14444005)(305945005)(53936002)(2004002); DIR:OUT; SFP:1101; SCL:1; SRVR:BN8PR12MB2963; H:SATLEXCHOV01.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoDomainNonexistent; MX:1; A:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: de70122e-938f-4df0-d89a-08d6a6985cd2 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(2017052603328)(7153060); SRVR:BN8PR12MB2963; X-MS-TrafficTypeDiagnostic: BN8PR12MB2963: X-Microsoft-Exchange-Diagnostics: 1; BN8PR12MB2963; 20:Oc02L4GjkQFpqKKJ0JMRxge0fwnKvM8XOa8Y8lVD+t4x5d9c34qimdPAQpjVtGIgD/uZ+xL16QgHMYaajKK8weFpEi4jwJY2Lytz91IqBGSW+tgQrlzb+Z7e+6A3KTjx2phLhog228gqrfSLtYjL0yyDgMayOdByH3enOWIJr7G4W7IoKvmHuNLrtyen8wQBfDrhvs495vxG44S62Ft7dT009i1GkHkEFhs55LY7m2zHpoOCjIy0uzTy2KHsFXo+TchPkzKufdCujj4ZQnK0o4/SU6lNWv99A2sRindndCkAaEzq//Br/tUyNEun5cazPKYBok/5aD6RwT6mSKychfi/ON5HP4epgo5ArhlAsf1zR9/FZ3Ri5YS+p2J3piZMGNuggvcmkBY7Zw/Ih3Q7HCZWCHIPwLIYWb9Q9/OS73KfJoTCajqnf9/Iw5sVo3ClKSqr3QwwY/1bdhqUS5rfhiXyVrNgNDccDOe15m/NN1rE2EpOxciw3npXi3Lm0Uv8 X-Microsoft-Antispam-PRVS: X-Forefront-PRVS: 09749A275C X-Microsoft-Exchange-Diagnostics: =?utf-8?q?1=3BBN8PR12MB2963=3B23=3ACH3dmMv?= =?utf-8?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k3xXmlOkmWsRz2rmJhTAr12ojIkeBX6wJeeYsu+Nyz/LErIWLKFRewtadL?= =?utf-8?q?yjae+rELD9AovxhgFd7AT5HmYCmHDmCqrypv8JzN5WeFAX09fK3yAIkkpLreZUrOq?= =?utf-8?q?mtSC22B0gmKxtfODJxbk1Z0sIefmvecdfwlL9Tz1hhy/yyl/VLd5ZldGniT7963e2?= =?utf-8?q?p5pVI1xe8jtB7j1YwC8z3EL34FZwrsFE30P3AydoR6p/qxUxJOUwi8PtJSqht1vFY?= =?utf-8?q?qKW9rhd/5bWhBtg2zfdx9aPZy87XZOov3m0D6qVW35W5isEXCUCaVJQIvMxEMJHOG?= =?utf-8?q?3O7MiKSg5s9QVoKOo=3D?= X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: pbIoMAXTun+oU4QhOK1wYxPRYUgIre3nqUD0IIwcxbYeNgvblHI+waZXPHdy4HMIFLP4dQ5SXV1VxplTujtCmvwVC1rONmjU0ougZDsI1B0w6/j8bEa+dHm42m/Wnlwzv9joBOcJjYqClvE6njqVPhbhlvqWCZWUujN+3qlMQ8mDVJvYMzXoN12PEaJdP4VcidetV+x6NLAqvd3ISbtWZeD8xANw+LvRamTIFYdF42Cc5iFP/55P+4wzg8FSHtcS7zD5GUkH/rtfDG/4A6AFt6GvK12jb/ceUYS1KkPtqhf6BCi2GG/jVIfMlfsljmFdJbjjicCs6+C/Dpm1Vp/eIxaw/XctP7EasgfBtdpt42UUhfGzm6Ce3y+PGmB05p9eaCPkHfhieru1SwvX4dTgqJoBwDJuIs/HcHnV/2t2zgg= X-Microsoft-Exchange-Diagnostics: 1; BN8PR12MB2963; 20:eMBtOcwrYA0DvAFIqnGLjc5fc4uVW4SPAY2md7yfNTp26USNZQ3XX4m8p5uSlI5r7xa7/eSrudwWaSMjVar8LEQrgMQFlKgAAZI1y1MvXGbW6WKyMZmc2wFgJWEV2teHdG58mTa3MfdimkCsCgwLngL9YM4dkRw6+oxCm7sX6RRq7xOvtUrfG+fCydMZnfvbO94GiPMOFMjlJbK+W9A/zvGkH1dKnlY1RaAbVvqmMsBTqCFdmPxreUkU7KbluxKj X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Mar 2019 03:11:03.9093 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: de70122e-938f-4df0-d89a-08d6a6985cd2 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: BN8PR12MB2963 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=8/thAMSLcad1SuGRwHuIQD2QE7El5jiNqSuiGi5g3FU=; b=A9UArpYVTPeKFbdcKuH+wDQ5igmeVsjG6HnViyyn7wJOg0IuUshTQHBErFg/uDBtf7GQm1BuR+Q3Yop+PCV3wkfAr+xFgqb1mf6UuAUPVwB52yHFm6SIJ0Aocgfv9boFPPXzUej6TjQwxFUGwxLMmWGen81ZqhYCgWhk3ZaRgYs= 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 Lockless container implementation similar to a dma_fence_array, but with only two elements per node and automatic garbage collection. v2: properly document dma_fence_chain_for_each, add dma_fence_chain_find_seqno, drop prev reference during garbage collection if it's not a chain fence. v3: use head and iterator for dma_fence_chain_for_each v4: fix reference count in dma_fence_chain_enable_signaling v5: fix iteration when walking each chain node Signed-off-by: Christian König --- drivers/dma-buf/Makefile | 3 +- drivers/dma-buf/dma-fence-chain.c | 241 ++++++++++++++++++++++++++++++ include/linux/dma-fence-chain.h | 81 ++++++++++ 3 files changed, 324 insertions(+), 1 deletion(-) create mode 100644 drivers/dma-buf/dma-fence-chain.c create mode 100644 include/linux/dma-fence-chain.h diff --git a/drivers/dma-buf/Makefile b/drivers/dma-buf/Makefile index 0913a6ccab5a..1f006e083eb9 100644 --- a/drivers/dma-buf/Makefile +++ b/drivers/dma-buf/Makefile @@ -1,4 +1,5 @@ -obj-y := dma-buf.o dma-fence.o dma-fence-array.o reservation.o seqno-fence.o +obj-y := dma-buf.o dma-fence.o dma-fence-array.o dma-fence-chain.o \ + reservation.o seqno-fence.o obj-$(CONFIG_SYNC_FILE) += sync_file.o obj-$(CONFIG_SW_SYNC) += sw_sync.o sync_debug.o obj-$(CONFIG_UDMABUF) += udmabuf.o diff --git a/drivers/dma-buf/dma-fence-chain.c b/drivers/dma-buf/dma-fence-chain.c new file mode 100644 index 000000000000..0c5e3c902fa0 --- /dev/null +++ b/drivers/dma-buf/dma-fence-chain.c @@ -0,0 +1,241 @@ +/* + * fence-chain: chain fences together in a timeline + * + * Copyright (C) 2018 Advanced Micro Devices, Inc. + * Authors: + * Christian König + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + */ + +#include + +static bool dma_fence_chain_enable_signaling(struct dma_fence *fence); + +/** + * dma_fence_chain_get_prev - use RCU to get a reference to the previous fence + * @chain: chain node to get the previous node from + * + * Use dma_fence_get_rcu_safe to get a reference to the previous fence of the + * chain node. + */ +static struct dma_fence *dma_fence_chain_get_prev(struct dma_fence_chain *chain) +{ + struct dma_fence *prev; + + rcu_read_lock(); + prev = dma_fence_get_rcu_safe(&chain->prev); + rcu_read_unlock(); + return prev; +} + +/** + * dma_fence_chain_walk - chain walking function + * @fence: current chain node + * + * Walk the chain to the next node. Returns the next fence or NULL if we are at + * the end of the chain. Garbage collects chain nodes which are already + * signaled. + */ +struct dma_fence *dma_fence_chain_walk(struct dma_fence *fence) +{ + struct dma_fence_chain *chain, *prev_chain; + struct dma_fence *prev, *replacement, *tmp; + + chain = to_dma_fence_chain(fence); + if (!chain) { + dma_fence_put(fence); + return NULL; + } + + while ((prev = dma_fence_chain_get_prev(chain))) { + + prev_chain = to_dma_fence_chain(prev); + if (prev_chain) { + if (!dma_fence_is_signaled(prev_chain->fence)) + break; + + replacement = dma_fence_chain_get_prev(prev_chain); + } else { + if (!dma_fence_is_signaled(prev)) + break; + + replacement = NULL; + } + + tmp = cmpxchg(&chain->prev, prev, replacement); + if (tmp == prev) + dma_fence_put(tmp); + else + dma_fence_put(replacement); + dma_fence_put(prev); + } + + dma_fence_put(fence); + return prev; +} +EXPORT_SYMBOL(dma_fence_chain_walk); + +/** + * dma_fence_chain_find_seqno - find fence chain node by seqno + * @pfence: pointer to the chain node where to start + * @seqno: the sequence number to search for + * + * Advance the fence pointer to the chain node which will signal this sequence + * number. If no sequence number is provided then this is a no-op. + * + * Returns EINVAL if the fence is not a chain node or the sequence number has + * not yet advanced far enough. + */ +int dma_fence_chain_find_seqno(struct dma_fence **pfence, uint64_t seqno) +{ + struct dma_fence_chain *chain; + + if (!seqno) + return 0; + + chain = to_dma_fence_chain(*pfence); + if (!chain || chain->base.seqno < seqno) + return -EINVAL; + + dma_fence_chain_for_each(*pfence, &chain->base) { + if ((*pfence)->context != chain->base.context || + to_dma_fence_chain(*pfence)->prev_seqno < seqno) + break; + } + dma_fence_put(&chain->base); + + return 0; +} +EXPORT_SYMBOL(dma_fence_chain_find_seqno); + +static const char *dma_fence_chain_get_driver_name(struct dma_fence *fence) +{ + return "dma_fence_chain"; +} + +static const char *dma_fence_chain_get_timeline_name(struct dma_fence *fence) +{ + return "unbound"; +} + +static void dma_fence_chain_irq_work(struct irq_work *work) +{ + struct dma_fence_chain *chain; + + chain = container_of(work, typeof(*chain), work); + + /* Try to rearm the callback */ + if (!dma_fence_chain_enable_signaling(&chain->base)) + /* Ok, we are done. No more unsignaled fences left */ + dma_fence_signal(&chain->base); + dma_fence_put(&chain->base); +} + +static void dma_fence_chain_cb(struct dma_fence *f, struct dma_fence_cb *cb) +{ + struct dma_fence_chain *chain; + + chain = container_of(cb, typeof(*chain), cb); + irq_work_queue(&chain->work); + dma_fence_put(f); +} + +static bool dma_fence_chain_enable_signaling(struct dma_fence *fence) +{ + struct dma_fence_chain *head = to_dma_fence_chain(fence); + + dma_fence_get(&head->base); + dma_fence_chain_for_each(fence, &head->base) { + struct dma_fence_chain *chain = to_dma_fence_chain(fence); + struct dma_fence *f = chain ? chain->fence : fence; + + dma_fence_get(f); + if (!dma_fence_add_callback(f, &head->cb, dma_fence_chain_cb)) { + dma_fence_put(fence); + return true; + } + dma_fence_put(f); + } + dma_fence_put(&head->base); + return false; +} + +static bool dma_fence_chain_signaled(struct dma_fence *fence) +{ + dma_fence_chain_for_each(fence, fence) { + struct dma_fence_chain *chain = to_dma_fence_chain(fence); + struct dma_fence *f = chain ? chain->fence : fence; + + if (!dma_fence_is_signaled(f)) { + dma_fence_put(fence); + return false; + } + } + + return true; +} + +static void dma_fence_chain_release(struct dma_fence *fence) +{ + struct dma_fence_chain *chain = to_dma_fence_chain(fence); + + dma_fence_put(chain->prev); + dma_fence_put(chain->fence); + dma_fence_free(fence); +} + +const struct dma_fence_ops dma_fence_chain_ops = { + .get_driver_name = dma_fence_chain_get_driver_name, + .get_timeline_name = dma_fence_chain_get_timeline_name, + .enable_signaling = dma_fence_chain_enable_signaling, + .signaled = dma_fence_chain_signaled, + .release = dma_fence_chain_release, +}; +EXPORT_SYMBOL(dma_fence_chain_ops); + +/** + * dma_fence_chain_init - initialize a fence chain + * @chain: the chain node to initialize + * @prev: the previous fence + * @fence: the current fence + * + * Initialize a new chain node and either start a new chain or add the node to + * the existing chain of the previous fence. + */ +void dma_fence_chain_init(struct dma_fence_chain *chain, + struct dma_fence *prev, + struct dma_fence *fence, + uint64_t seqno) +{ + struct dma_fence_chain *prev_chain = to_dma_fence_chain(prev); + uint64_t context; + + spin_lock_init(&chain->lock); + chain->prev = prev; + chain->fence = fence; + chain->prev_seqno = 0; + init_irq_work(&chain->work, dma_fence_chain_irq_work); + + /* Try to reuse the context of the previous chain node. */ + if (prev_chain && __dma_fence_is_later(seqno, prev->seqno)) { + context = prev->context; + chain->prev_seqno = prev->seqno; + } else { + context = dma_fence_context_alloc(1); + /* Make sure that we always have a valid sequence number. */ + if (prev_chain) + seqno = max(prev->seqno, seqno); + } + + dma_fence_init(&chain->base, &dma_fence_chain_ops, + &chain->lock, context, seqno); +} +EXPORT_SYMBOL(dma_fence_chain_init); diff --git a/include/linux/dma-fence-chain.h b/include/linux/dma-fence-chain.h new file mode 100644 index 000000000000..09b038d3f5ef --- /dev/null +++ b/include/linux/dma-fence-chain.h @@ -0,0 +1,81 @@ +/* + * fence-chain: chain fences together in a timeline + * + * Copyright (C) 2018 Advanced Micro Devices, Inc. + * Authors: + * Christian König + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + */ + +#ifndef __LINUX_DMA_FENCE_CHAIN_H +#define __LINUX_DMA_FENCE_CHAIN_H + +#include +#include + +/** + * struct dma_fence_chain - fence to represent an node of a fence chain + * @base: fence base class + * @lock: spinlock for fence handling + * @prev: previous fence of the chain + * @prev_seqno: original previous seqno before garbage collection + * @fence: encapsulated fence + * @cb: callback structure for signaling + * @work: irq work item for signaling + */ +struct dma_fence_chain { + struct dma_fence base; + spinlock_t lock; + struct dma_fence *prev; + u64 prev_seqno; + struct dma_fence *fence; + struct dma_fence_cb cb; + struct irq_work work; +}; + +extern const struct dma_fence_ops dma_fence_chain_ops; + +/** + * to_dma_fence_chain - cast a fence to a dma_fence_chain + * @fence: fence to cast to a dma_fence_array + * + * Returns NULL if the fence is not a dma_fence_chain, + * or the dma_fence_chain otherwise. + */ +static inline struct dma_fence_chain * +to_dma_fence_chain(struct dma_fence *fence) +{ + if (!fence || fence->ops != &dma_fence_chain_ops) + return NULL; + + return container_of(fence, struct dma_fence_chain, base); +} + +/** + * dma_fence_chain_for_each - iterate over all fences in chain + * @iter: current fence + * @head: starting point + * + * Iterate over all fences in the chain. We keep a reference to the current + * fence while inside the loop which must be dropped when breaking out. + */ +#define dma_fence_chain_for_each(iter, head) \ + for (iter = dma_fence_get(head); iter; \ + iter = dma_fence_chain_walk(iter)) + +struct dma_fence *dma_fence_chain_walk(struct dma_fence *fence); +int dma_fence_chain_find_seqno(struct dma_fence **pfence, uint64_t seqno); +void dma_fence_chain_init(struct dma_fence_chain *chain, + struct dma_fence *prev, + struct dma_fence *fence, + uint64_t seqno); + +#endif /* __LINUX_DMA_FENCE_CHAIN_H */ 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//PfLuSP821syDkZY3e6SeI4PKh1I5sHt6zlRxVI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f-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, From patchwork Tue Mar 12 03:10:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chunming Zhou X-Patchwork-Id: 10848551 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 36AD11850 for ; Tue, 12 Mar 2019 03:11:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 220E9294BB for ; Tue, 12 Mar 2019 03:11:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 154A4294BE; Tue, 12 Mar 2019 03:11:36 +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 27C5C294BB for ; Tue, 12 Mar 2019 03:11:35 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 444B289D43; Tue, 12 Mar 2019 03:11:33 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM01-SN1-obe.outbound.protection.outlook.com (mail-eopbgr820047.outbound.protection.outlook.com [40.107.82.47]) by gabe.freedesktop.org (Postfix) with ESMTPS id 709A789D43; Tue, 12 Mar 2019 03:11:32 +0000 (UTC) Received: from BN6PR1201CA0018.namprd12.prod.outlook.com (2603:10b6:405:4c::28) by MN2PR12MB2976.namprd12.prod.outlook.com (2603:10b6:208:c2::14) 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:29 +0000 Received: from DM3NAM03FT050.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e49::206) by BN6PR1201CA0018.outlook.office365.com (2603:10b6:405:4c::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1686.18 via Frontend Transport; Tue, 12 Mar 2019 03:11:23 +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 DM3NAM03FT050.mail.protection.outlook.com (10.152.82.252) 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:22 +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:21 -0500 From: Chunming Zhou To: , , , , Subject: [PATCH 3/9] drm/syncobj: add support for timeline point wait v8 Date: Tue, 12 Mar 2019 11:10:43 +0800 Message-ID: <20190312031049.23647-3-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)(346002)(396003)(376002)(39860400002)(2980300002)(428003)(189003)(199004)(356004)(7696005)(305945005)(6666004)(23676004)(316002)(5660300002)(186003)(5820100001)(104016004)(76176011)(36756003)(8936002)(26005)(81156014)(106466001)(54906003)(47776003)(110136005)(8676002)(14444005)(81166006)(77096007)(50466002)(336012)(6636002)(53936002)(97736004)(2201001)(2870700001)(66574012)(1076003)(53416004)(4326008)(30864003)(86362001)(426003)(50226002)(68736007)(2906002)(486006)(11346002)(2616005)(476003)(126002)(446003)(478600001)(72206003)(105586002)(21314003); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR12MB2976; H:SATLEXCHOV01.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoDomainNonexistent; MX:1; A:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a15070f4-5909-4b49-c678-08d6a698681d X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(2017052603328)(7153060); SRVR:MN2PR12MB2976; X-MS-TrafficTypeDiagnostic: MN2PR12MB2976: X-Microsoft-Exchange-Diagnostics: 1; MN2PR12MB2976; 20:OYTUujPa9gJYjj1XsoovKWY60Lw7VpC90R4bNap8TUzpeDXwdGS3MAz6nT4Q/Rm7/Iz47TN8gNKgN41+a/iysiSzWfxdJ7w8+D4Cjpv1rhF1VvdfBn6AKADzZ90r9UP4qcFPfyNtUjk8BGScwj2qpuNiKSE+6SPFuMY1XbSUrW0gsh6JbA8M/zeYRYsi55m7pQ9immSwBZ8RJQmusq1xuKujOsb1tOsY5tSKOEiWursoGNsGfHwVL4KSyOFf+pZdTd876nMGtrHLKPdpVNphNPzxsnDs0ePLKEt3r+eodEneRAqy7kojX7EBmrso4SFntURuz7yCNBXeycVOIBewSRXVCUE01GQclTZdSak8T/6oLilwz0e6B2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QhSRGPAiKL/7M9jbNwFtFdcoguSNqcWf5FslSjBBSK4+dnwo2op3jq2C8rM4MDmV9Fuxz4rOR4TqfsY6G1qNA1LKEWcZ5IHOcShSvDOnXRD7n3stux757djJ0AE= X-Microsoft-Exchange-Diagnostics: 1; MN2PR12MB2976; 20:Kf7LXjMilJwFK2rjXCoGtwPpbJol+OrDrZ4v37M/0tNUVKY9hQB76G55xU3+GBe4GN06uO5Rsb9OHWVymb5scJDjRPAjjPx2stFDhZr3hiuHZW17XfEj0wUjwbl6lfTRceD75GOKr06mdZtX1b7ISn4UOjFAzCr9SO7m0Uo1xS1G81T/Z5MnWqlEPAEsmWU/Ivc1I8iWFAhEDXPisj30VF5dxRFpwjGQG0F5WBz6P/qBiyfe++D9crbmfgdT5HHj X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Mar 2019 03:11:22.7105 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a15070f4-5909-4b49-c678-08d6a698681d 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: MN2PR12MB2976 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=c2A6Nr6YJsLEOgIPeQEuB7lzxTRKlZsVlgONDcZoRWU=; b=1drZ3DwvVRuFWoukVEWEOq3PV57wo1sWSb9PuI37UVrCimylLsQaYxjVEbHhh9vTj7X3uZST7nIY1rDA9E3HVDF0cGsfB7ykL3+ewj3XLTrWXcAVl2aGqmHhZod/dtdshsIi2uDSrrQPV4B6895EPNHwvxwGPZqDNCK9Zmjfo5Y= X-Mailman-Original-Authentication-Results: spf=none (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; basnieuwenhuizen.nl; dkim=none (message not signed) header.d=none;basnieuwenhuizen.nl; 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: Daniel Rakos , Dave Airlie , =?utf-8?q?Christian_K=C3=B6nig?= Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP points array is one-to-one match with syncobjs array. v2: add seperate ioctl for timeline point wait, otherwise break uapi. v3: userspace can specify two kinds waits:: a. Wait for time point to be completed. b. and wait for time point to become available v4: rebase v5: add comment for xxx_WAIT_AVAILABLE v6: rebase and rework on new container v7: drop _WAIT_COMPLETED, it is the default anyway v8: correctly handle garbage collected fences Signed-off-by: Chunming Zhou Signed-off-by: Christian König Cc: Daniel Rakos Cc: Jason Ekstrand Cc: Bas Nieuwenhuizen Cc: Dave Airlie Cc: Chris Wilson --- drivers/gpu/drm/drm_internal.h | 2 + drivers/gpu/drm/drm_ioctl.c | 2 + drivers/gpu/drm/drm_syncobj.c | 153 ++++++++++++++++++++++++++------- include/uapi/drm/drm.h | 15 ++++ 4 files changed, 143 insertions(+), 29 deletions(-) diff --git a/drivers/gpu/drm/drm_internal.h b/drivers/gpu/drm/drm_internal.h index 251d67e04c2d..331ac6225b58 100644 --- a/drivers/gpu/drm/drm_internal.h +++ b/drivers/gpu/drm/drm_internal.h @@ -182,6 +182,8 @@ int drm_syncobj_fd_to_handle_ioctl(struct drm_device *dev, void *data, struct drm_file *file_private); int drm_syncobj_wait_ioctl(struct drm_device *dev, void *data, struct drm_file *file_private); +int drm_syncobj_timeline_wait_ioctl(struct drm_device *dev, void *data, + struct drm_file *file_private); int drm_syncobj_reset_ioctl(struct drm_device *dev, void *data, struct drm_file *file_private); int drm_syncobj_signal_ioctl(struct drm_device *dev, void *data, diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c index 687943df58e1..c984654646fa 100644 --- a/drivers/gpu/drm/drm_ioctl.c +++ b/drivers/gpu/drm/drm_ioctl.c @@ -688,6 +688,8 @@ static const struct drm_ioctl_desc drm_ioctls[] = { DRM_UNLOCKED|DRM_RENDER_ALLOW), DRM_IOCTL_DEF(DRM_IOCTL_SYNCOBJ_WAIT, drm_syncobj_wait_ioctl, DRM_UNLOCKED|DRM_RENDER_ALLOW), + DRM_IOCTL_DEF(DRM_IOCTL_SYNCOBJ_TIMELINE_WAIT, drm_syncobj_timeline_wait_ioctl, + DRM_UNLOCKED|DRM_RENDER_ALLOW), DRM_IOCTL_DEF(DRM_IOCTL_SYNCOBJ_RESET, drm_syncobj_reset_ioctl, DRM_UNLOCKED|DRM_RENDER_ALLOW), DRM_IOCTL_DEF(DRM_IOCTL_SYNCOBJ_SIGNAL, drm_syncobj_signal_ioctl, diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c index 933225fde9a9..25eb2176d8c7 100644 --- a/drivers/gpu/drm/drm_syncobj.c +++ b/drivers/gpu/drm/drm_syncobj.c @@ -61,6 +61,7 @@ struct syncobj_wait_entry { struct task_struct *task; struct dma_fence *fence; struct dma_fence_cb fence_cb; + u64 point; }; static void syncobj_wait_syncobj_func(struct drm_syncobj *syncobj, @@ -95,6 +96,8 @@ EXPORT_SYMBOL(drm_syncobj_find); static void drm_syncobj_fence_add_wait(struct drm_syncobj *syncobj, struct syncobj_wait_entry *wait) { + struct dma_fence *fence; + if (wait->fence) return; @@ -103,11 +106,15 @@ static void drm_syncobj_fence_add_wait(struct drm_syncobj *syncobj, * have the lock, try one more time just to be sure we don't add a * callback when a fence has already been set. */ - if (syncobj->fence) - wait->fence = dma_fence_get( - rcu_dereference_protected(syncobj->fence, 1)); - else + fence = dma_fence_get(rcu_dereference_protected(syncobj->fence, 1)); + if (!fence || dma_fence_chain_find_seqno(&fence, wait->point)) { + dma_fence_put(fence); list_add_tail(&wait->node, &syncobj->cb_list); + } else if (!fence) { + wait->fence = dma_fence_get_stub(); + } else { + wait->fence = fence; + } spin_unlock(&syncobj->lock); } @@ -147,10 +154,8 @@ void drm_syncobj_add_point(struct drm_syncobj *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); + list_for_each_entry_safe(cur, tmp, &syncobj->cb_list, node) syncobj_wait_syncobj_func(syncobj, cur); - } spin_unlock(&syncobj->lock); /* Walk the chain once to trigger garbage collection */ @@ -182,10 +187,8 @@ void drm_syncobj_replace_fence(struct drm_syncobj *syncobj, rcu_assign_pointer(syncobj->fence, fence); if (fence != old_fence) { - list_for_each_entry_safe(cur, tmp, &syncobj->cb_list, node) { - list_del_init(&cur->node); + list_for_each_entry_safe(cur, tmp, &syncobj->cb_list, node) syncobj_wait_syncobj_func(syncobj, cur); - } } spin_unlock(&syncobj->lock); @@ -642,13 +645,27 @@ static void syncobj_wait_fence_func(struct dma_fence *fence, static void syncobj_wait_syncobj_func(struct drm_syncobj *syncobj, struct syncobj_wait_entry *wait) { + struct dma_fence *fence; + /* This happens inside the syncobj lock */ - wait->fence = dma_fence_get(rcu_dereference_protected(syncobj->fence, - lockdep_is_held(&syncobj->lock))); + fence = rcu_dereference_protected(syncobj->fence, + lockdep_is_held(&syncobj->lock)); + dma_fence_get(fence); + if (!fence || dma_fence_chain_find_seqno(&fence, wait->point)) { + dma_fence_put(fence); + return; + } else if (!fence) { + wait->fence = dma_fence_get_stub(); + } else { + wait->fence = fence; + } + wake_up_process(wait->task); + list_del_init(&wait->node); } static signed long drm_syncobj_array_wait_timeout(struct drm_syncobj **syncobjs, + void __user *user_points, uint32_t count, uint32_t flags, signed long timeout, @@ -656,12 +673,27 @@ static signed long drm_syncobj_array_wait_timeout(struct drm_syncobj **syncobjs, { struct syncobj_wait_entry *entries; struct dma_fence *fence; + uint64_t *points; uint32_t signaled_count, i; - entries = kcalloc(count, sizeof(*entries), GFP_KERNEL); - if (!entries) + points = kmalloc_array(count, sizeof(*points), GFP_KERNEL); + if (points == NULL) return -ENOMEM; + if (!user_points) { + memset(points, 0, count * sizeof(uint64_t)); + + } else if (copy_from_user(points, user_points, + sizeof(uint64_t) * count)) { + timeout = -EFAULT; + goto err_free_points; + } + + entries = kcalloc(count, sizeof(*entries), GFP_KERNEL); + if (!entries) { + timeout = -ENOMEM; + goto err_free_points; + } /* Walk the list of sync objects and initialize entries. We do * this up-front so that we can properly return -EINVAL if there is * a syncobj with a missing fence and then never have the chance of @@ -669,9 +701,13 @@ static signed long drm_syncobj_array_wait_timeout(struct drm_syncobj **syncobjs, */ signaled_count = 0; for (i = 0; i < count; ++i) { + struct dma_fence *fence; + entries[i].task = current; - entries[i].fence = drm_syncobj_fence_get(syncobjs[i]); - if (!entries[i].fence) { + entries[i].point = points[i]; + fence = drm_syncobj_fence_get(syncobjs[i]); + if (!fence || dma_fence_chain_find_seqno(&fence, points[i])) { + dma_fence_put(fence); if (flags & DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT) { continue; } else { @@ -680,7 +716,13 @@ static signed long drm_syncobj_array_wait_timeout(struct drm_syncobj **syncobjs, } } - if (dma_fence_is_signaled(entries[i].fence)) { + if (fence) + entries[i].fence = fence; + else + entries[i].fence = dma_fence_get_stub(); + + if ((flags & DRM_SYNCOBJ_WAIT_FLAGS_WAIT_AVAILABLE) || + dma_fence_is_signaled(entries[i].fence)) { if (signaled_count == 0 && idx) *idx = i; signaled_count++; @@ -713,7 +755,8 @@ static signed long drm_syncobj_array_wait_timeout(struct drm_syncobj **syncobjs, if (!fence) continue; - if (dma_fence_is_signaled(fence) || + if ((flags & DRM_SYNCOBJ_WAIT_FLAGS_WAIT_AVAILABLE) || + dma_fence_is_signaled(fence) || (!entries[i].fence_cb.func && dma_fence_add_callback(fence, &entries[i].fence_cb, @@ -758,6 +801,9 @@ static signed long drm_syncobj_array_wait_timeout(struct drm_syncobj **syncobjs, } kfree(entries); +err_free_points: + kfree(points); + return timeout; } @@ -797,19 +843,33 @@ EXPORT_SYMBOL(drm_timeout_abs_to_jiffies); static int drm_syncobj_array_wait(struct drm_device *dev, struct drm_file *file_private, struct drm_syncobj_wait *wait, - struct drm_syncobj **syncobjs) + struct drm_syncobj_timeline_wait *timeline_wait, + struct drm_syncobj **syncobjs, bool timeline) { - signed long timeout = drm_timeout_abs_to_jiffies(wait->timeout_nsec); + signed long timeout = 0; uint32_t first = ~0; - timeout = drm_syncobj_array_wait_timeout(syncobjs, - wait->count_handles, - wait->flags, - timeout, &first); - if (timeout < 0) - return timeout; - - wait->first_signaled = first; + if (!timeline) { + timeout = drm_timeout_abs_to_jiffies(wait->timeout_nsec); + timeout = drm_syncobj_array_wait_timeout(syncobjs, + NULL, + wait->count_handles, + wait->flags, + timeout, &first); + if (timeout < 0) + return timeout; + wait->first_signaled = first; + } else { + timeout = drm_timeout_abs_to_jiffies(timeline_wait->timeout_nsec); + timeout = drm_syncobj_array_wait_timeout(syncobjs, + u64_to_user_ptr(timeline_wait->points), + timeline_wait->count_handles, + timeline_wait->flags, + timeout, &first); + if (timeout < 0) + return timeout; + timeline_wait->first_signaled = first; + } return 0; } @@ -895,13 +955,48 @@ drm_syncobj_wait_ioctl(struct drm_device *dev, void *data, return ret; ret = drm_syncobj_array_wait(dev, file_private, - args, syncobjs); + args, NULL, syncobjs, false); drm_syncobj_array_free(syncobjs, args->count_handles); return ret; } +int +drm_syncobj_timeline_wait_ioctl(struct drm_device *dev, void *data, + struct drm_file *file_private) +{ + struct drm_syncobj_timeline_wait *args = data; + struct drm_syncobj **syncobjs; + int ret = 0; + + if (!drm_core_check_feature(dev, DRIVER_SYNCOBJ)) + return -ENODEV; + + if (args->flags & ~(DRM_SYNCOBJ_WAIT_FLAGS_WAIT_ALL | + DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT | + DRM_SYNCOBJ_WAIT_FLAGS_WAIT_AVAILABLE)) + return -EINVAL; + + if (args->count_handles == 0) + return -EINVAL; + + ret = drm_syncobj_array_find(file_private, + u64_to_user_ptr(args->handles), + args->count_handles, + &syncobjs); + if (ret < 0) + return ret; + + ret = drm_syncobj_array_wait(dev, file_private, + NULL, args, syncobjs, true); + + drm_syncobj_array_free(syncobjs, args->count_handles); + + return ret; +} + + int drm_syncobj_reset_ioctl(struct drm_device *dev, void *data, struct drm_file *file_private) diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h index 300f336633f2..0092111d002c 100644 --- a/include/uapi/drm/drm.h +++ b/include/uapi/drm/drm.h @@ -737,6 +737,7 @@ struct drm_syncobj_handle { #define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_ALL (1 << 0) #define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT (1 << 1) +#define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_AVAILABLE (1 << 2) struct drm_syncobj_wait { __u64 handles; /* absolute timeout */ @@ -747,6 +748,19 @@ struct drm_syncobj_wait { __u32 pad; }; +struct drm_syncobj_timeline_wait { + __u64 handles; + /* wait on specific timeline point for every handles*/ + __u64 points; + /* absolute timeout */ + __s64 timeout_nsec; + __u32 count_handles; + __u32 flags; + __u32 first_signaled; /* only valid when not waiting all */ + __u32 pad; +}; + + struct drm_syncobj_array { __u64 handles; __u32 count_handles; @@ -909,6 +923,7 @@ extern "C" { #define DRM_IOCTL_MODE_GET_LEASE DRM_IOWR(0xC8, struct drm_mode_get_lease) #define DRM_IOCTL_MODE_REVOKE_LEASE DRM_IOWR(0xC9, struct drm_mode_revoke_lease) +#define DRM_IOCTL_SYNCOBJ_TIMELINE_WAIT DRM_IOWR(0xCA, struct drm_syncobj_timeline_wait) /** * Device specific ioctls should only be in their respective headers * The device specific ioctl range is from 0x40 to 0x9f. From patchwork Tue Mar 12 03:10:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chunming Zhou X-Patchwork-Id: 10848553 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 74C401850 for ; Tue, 12 Mar 2019 03:11:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 60D6B294BB for ; Tue, 12 Mar 2019 03:11:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 53C27294BE; Tue, 12 Mar 2019 03:11:40 +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 CCF1F294BB for ; Tue, 12 Mar 2019 03:11:39 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 741E089D89; Tue, 12 Mar 2019 03:11:38 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM05-BY2-obe.outbound.protection.outlook.com (mail-eopbgr710079.outbound.protection.outlook.com [40.107.71.79]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0439189D57; Tue, 12 Mar 2019 03:11:36 +0000 (UTC) Received: from MN2PR12CA0033.namprd12.prod.outlook.com (2603:10b6:208:a8::46) by BN8PR12MB2964.namprd12.prod.outlook.com (2603:10b6:408:61::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1686.21; Tue, 12 Mar 2019 03:11:33 +0000 Received: from DM3NAM03FT042.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e49::203) by MN2PR12CA0033.outlook.office365.com (2603:10b6:208:a8::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1686.20 via Frontend Transport; Tue, 12 Mar 2019 03:11:33 +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 DM3NAM03FT042.mail.protection.outlook.com (10.152.83.174) 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:32 +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:31 -0500 From: Chunming Zhou To: , , , , Subject: [PATCH 4/9] drm/syncobj: add timeline payload query ioctl v5 Date: Tue, 12 Mar 2019 11:10:44 +0800 Message-ID: <20190312031049.23647-4-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)(39860400002)(396003)(346002)(2980300002)(428003)(189003)(199004)(54906003)(11346002)(97736004)(23676004)(104016004)(316002)(110136005)(2201001)(14444005)(86362001)(478600001)(50466002)(336012)(2616005)(36756003)(72206003)(486006)(446003)(6666004)(356004)(126002)(476003)(76176011)(1076003)(5660300002)(7696005)(66574012)(53936002)(6636002)(8676002)(305945005)(186003)(81166006)(8936002)(106466001)(77096007)(26005)(2870700001)(5820100001)(68736007)(2906002)(81156014)(426003)(105586002)(47776003)(4326008)(50226002)(53416004); DIR:OUT; SFP:1101; SCL:1; SRVR:BN8PR12MB2964; H:SATLEXCHOV01.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoDomainNonexistent; MX:1; A:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4ee78eb0-2594-46b5-94ad-08d6a6986df2 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(2017052603328)(7153060); SRVR:BN8PR12MB2964; X-MS-TrafficTypeDiagnostic: BN8PR12MB2964: X-Microsoft-Exchange-Diagnostics: 1; BN8PR12MB2964; 20:KPir5TgMWwAmIus6EJ9O4AgH6GVDd3cJpiyt2N6vl04nHz6tBY4NPVMUTP68wQfL5WiltCNiFFNLnfaIsVj3sf8VLDvaTVV2FKHJ3ZRfZi11G/XzieBjqyUCbEf+UwPsjRCEa+5YegF/M2bS23faOfJxWKSGJep0LS7l1hQSw8DbMxM4XufTXHLdGvb9ZKZNG1VOzPAzhiguNi7rl0GnSHRCLaJC6QRuQDrthPG+7EiiMDtDlM4gK68BNa5qSo3gS9O2S/2VBC9sqlJu8gOwUxjuRZQ48dg4LSqx/RvdXbuSfHoFxzfVrbs6fGYl0HMI6ah6mILza6+qFezXVqzdR8BOLl3vB3BGeAw2dFhMVFUNhg8J5eDEyt9QVTnigweWsE2MGq+XKnNV07+8RyQEiVIDBihGtDro3N2ezYuXnCtGvcdyBGL/1sfy55397CfVrzr0P4eJrvNg1fA/y8J3mL/7piqkAsxdWG/T6qQrAWLUvDn4Za+H87DfnX8cSjCz X-Microsoft-Antispam-PRVS: X-Forefront-PRVS: 09749A275C X-Microsoft-Exchange-Diagnostics: =?utf-8?q?1=3BBN8PR12MB2964=3B23=3Ai8p4Bdk?= =?utf-8?q?ckJEd821pnKAcRa8ZB3+PZXOeebe+E+pgJOdSd/xXe+yGi4qQCP6TKkdgTCaMEzXJ?= =?utf-8?q?2gIKRAl9Ptz0Cf5vNlCdJpN3tmd7p+ZVgI1yV+CcsANYNW7eCdTuj18tJT/omN3dN?= =?utf-8?q?Fyk8i3DfMIMDkUV+Cqxth8XTRK3jDFHDep2tNY+d1LxLBLxoHvxBH8cW8lF6SSCJz?= =?utf-8?q?ICqMAYQAlQBstvGTkC4nldsS5jPCappW6B+wybUXihgp/ha0hPoSbkGxt6glG+K74?= =?utf-8?q?e+GcX76wP8JlLB214lTUCK2p5iDqjs2O3fCV5yLAeNo6zL8FPUsQ8S2dihfXB6F5I?= =?utf-8?q?+e5PHnyfmr16TZuJFlD9r77qxc1b1uLmwDYz2gD4jl/xEv4uEOS0Hh20scl7JyRth?= =?utf-8?q?BJ0M4Kk7VNxspUhPXsFifk4aYfr2nnJPWyo4etrHuQd5AcL/UOHGxfgDNNdOpJmzS?= =?utf-8?q?S90syyutUfNUQuBg0a4hASOHL8gtottr+hgbCynlklBxHy47cW8/+u2PIHu3+Tx5T?= =?utf-8?q?lFdyZZSTXSX+mWzr+k+jIHATJP63i2YxewMkBlHAskUiR9KADPE1o6iP1qdZPvlyB?= =?utf-8?q?Z+DVc4nsKzFndONoTRsXkdfzAutPlt5uxJICRi9lXTUbHnsT1laX4G17rL2fE7DrL?= =?utf-8?q?CAsBErUlalQQRdknCE7I1JhLYzdaMWmxWJWXvx0SnDIko73vVqrUg+TIG0cpTpl6h?= =?utf-8?q?T7j57Bqf4+NhXYFN0tzdxjYGMrifDAlVDArjhB1dY84uKTocod/WKp2Pn0Ixqq0Y4?= =?utf-8?q?lx4vyhO9ZSIT0Ba+WE+iB48RZPpyGXcziaPleUIXABLZ+SB1DS2Tk60SPYe6JDKEa?= =?utf-8?q?Dju32AZgKE89EVNP+mVxZt0RZpWzob05nqnQU32+apUjePBMYePOHWwSijRxUw3AA?= =?utf-8?q?R6DvkDqn80f9ZUeAsT+4rjjF/DJlmUcmoyxp5UQjPQL0wj66xsSmrObLIjyM/jWye?= =?utf-8?q?CIz6TSrueQkKN56vUeV0zO5SsuKQRmxMh8fwE1osWtR41G3aise6x5R9JnCpMJGGT?= =?utf-8?q?6gHPo+DngTRPWrfYFs+HpjgHALVq/nSoFyE9+JIveknIENMzLWNQNFWMttMD6L4tr?= =?utf-8?q?/7t2pqy24c2Psr2uQqtQOY+wZ/ceHD4xv/wUxfnKPhbQnQd9XSpsP68ORe5OSwD/L?= =?utf-8?q?gLQdcz8tikqYDJM61Mp0Fi8pebYvAIO448llQFYR1plU6GdgMoINaO2eBzANFcj7W?= =?utf-8?q?UrB0pyNjm5RSBUoMBqqo7xLciS6qmoC0STva1+?= X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: Fo9OHdM3orIRYk+9URjPwv2WKG/fGzkqpio91XnmDF+1uc82T88ybUV8amzXpZHNRny/q1iYVJGqPBUD81Vr//cnjve6eGBuwuZPtTLsQeca2s/RFknSVvcRzxlO4gvtbZsyQOxBk8UBSmA6W9Cn4+EeJNM8YO7jXnBlXRxD0jMZQmoHTkQCydkbWOALFE//kL/8hNSyJZZ0rj2Y99TDDSIH5IwHFgso6/n6WvPc/R+ARDUCITIrfF3xd+40KU4BEUU/+iDz+2faFSxy2+/n4zG8fF18mEkpaCTJoirYqQwg0GPfqXpTaKiUz/PWMoXSrgxsNn2PoeQAWYLffeKKT8VYgE1KdnzO81sMrNDnnWbm1vyy3g36ns9rAF8bSyQQHPgv93IcxyrH46laz7z4GkUbHRngTmyyzjg++GGkVWg= X-Microsoft-Exchange-Diagnostics: 1; BN8PR12MB2964; 20:gYmHg3IciZnVl5zVvGwUWUTiGvrwTIvysgSIwvEVO/bKMyOubQgtycmWo/gAoPZ2qGA6DMRHEyPahIMs7JRfxRSkQtITH63IRvb4Ad+n7O4SbYijFpQ9euJU2I5Ub/vtLWPDV4D8YO1s1ii5uLgBExWBtvmckhuzjk+W3yxYvF7R3eGZVTfoNUlwF7k3zqsVTr2JIvV3x2h3zMhvpSj7GjAY+hOvWOTXe9UTPooeP9+tj/16OQImTK4n8oJRF5sz X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Mar 2019 03:11:32.5712 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4ee78eb0-2594-46b5-94ad-08d6a6986df2 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: BN8PR12MB2964 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=qwW+7phx1SsRjwINF+Y2URE9axwYRpS/k7NZQJbrg6I=; b=ySUyyvNOTyQf3HBPEZCCJXZeJ1OPf3mpnSTGS8AsPprjTGvY1uwQ5rkVd+FxZz8bpzfIhNEhZXIRYEq4hxgo7h2Dt6HV0/vdyXUxjtopPLEd1HnF1xjmua8Y3FmDjq2mIJTXu/kv9NM24fHIReDIaaPa/NSBgEwwEulPIVE4fIA= X-Mailman-Original-Authentication-Results: spf=none (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; basnieuwenhuizen.nl; dkim=none (message not signed) header.d=none;basnieuwenhuizen.nl; 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: Daniel Rakos , Dave Airlie , =?utf-8?q?Christian_K=C3=B6nig?= Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP user mode can query timeline payload. v2: check return value of copy_to_user v3: handle querying entry by entry v4: rebase on new chain container, simplify interface v5: query last signaled timeline point, not last point. Signed-off-by: Chunming Zhou Cc: Daniel Rakos Cc: Jason Ekstrand Cc: Bas Nieuwenhuizen Cc: Dave Airlie Cc: Christian König Cc: Chris Wilson --- drivers/gpu/drm/drm_internal.h | 2 ++ drivers/gpu/drm/drm_ioctl.c | 2 ++ drivers/gpu/drm/drm_syncobj.c | 58 ++++++++++++++++++++++++++++++++++ include/uapi/drm/drm.h | 10 ++++++ 4 files changed, 72 insertions(+) diff --git a/drivers/gpu/drm/drm_internal.h b/drivers/gpu/drm/drm_internal.h index 331ac6225b58..695179bb88dc 100644 --- a/drivers/gpu/drm/drm_internal.h +++ b/drivers/gpu/drm/drm_internal.h @@ -188,6 +188,8 @@ int drm_syncobj_reset_ioctl(struct drm_device *dev, void *data, struct drm_file *file_private); int drm_syncobj_signal_ioctl(struct drm_device *dev, void *data, struct drm_file *file_private); +int drm_syncobj_query_ioctl(struct drm_device *dev, void *data, + struct drm_file *file_private); /* drm_framebuffer.c */ void drm_framebuffer_print_info(struct drm_printer *p, unsigned int indent, diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c index c984654646fa..7a534c184e52 100644 --- a/drivers/gpu/drm/drm_ioctl.c +++ b/drivers/gpu/drm/drm_ioctl.c @@ -694,6 +694,8 @@ static const struct drm_ioctl_desc drm_ioctls[] = { DRM_UNLOCKED|DRM_RENDER_ALLOW), DRM_IOCTL_DEF(DRM_IOCTL_SYNCOBJ_SIGNAL, drm_syncobj_signal_ioctl, DRM_UNLOCKED|DRM_RENDER_ALLOW), + DRM_IOCTL_DEF(DRM_IOCTL_SYNCOBJ_QUERY, drm_syncobj_query_ioctl, + DRM_UNLOCKED|DRM_RENDER_ALLOW), DRM_IOCTL_DEF(DRM_IOCTL_CRTC_GET_SEQUENCE, drm_crtc_get_sequence_ioctl, DRM_UNLOCKED), DRM_IOCTL_DEF(DRM_IOCTL_CRTC_QUEUE_SEQUENCE, drm_crtc_queue_sequence_ioctl, DRM_UNLOCKED), DRM_IOCTL_DEF(DRM_IOCTL_MODE_CREATE_LEASE, drm_mode_create_lease_ioctl, DRM_MASTER|DRM_UNLOCKED), diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c index 25eb2176d8c7..a5adc7c06caa 100644 --- a/drivers/gpu/drm/drm_syncobj.c +++ b/drivers/gpu/drm/drm_syncobj.c @@ -1062,3 +1062,61 @@ drm_syncobj_signal_ioctl(struct drm_device *dev, void *data, return ret; } + +int drm_syncobj_query_ioctl(struct drm_device *dev, void *data, + struct drm_file *file_private) +{ + struct drm_syncobj_timeline_array *args = data; + struct drm_syncobj **syncobjs; + uint64_t __user *points = u64_to_user_ptr(args->points); + uint32_t i; + int ret; + + if (!drm_core_check_feature(dev, DRIVER_SYNCOBJ)) + return -ENODEV; + + if (args->pad != 0) + return -EINVAL; + + if (args->count_handles == 0) + return -EINVAL; + + ret = drm_syncobj_array_find(file_private, + u64_to_user_ptr(args->handles), + args->count_handles, + &syncobjs); + if (ret < 0) + return ret; + + for (i = 0; i < args->count_handles; i++) { + struct dma_fence_chain *chain; + struct dma_fence *fence; + uint64_t point; + + fence = drm_syncobj_fence_get(syncobjs[i]); + chain = to_dma_fence_chain(fence); + if (chain) { + struct dma_fence *iter, *last_signaled = NULL; + + dma_fence_chain_for_each(iter, fence) { + if (!iter) + break; + dma_fence_put(last_signaled); + last_signaled = dma_fence_get(iter); + } + point = dma_fence_is_signaled(last_signaled) ? + last_signaled->seqno : + to_dma_fence_chain(last_signaled)->prev_seqno; + dma_fence_put(last_signaled); + } else { + point = 0; + } + ret = copy_to_user(&points[i], &point, sizeof(uint64_t)); + ret = ret ? -EFAULT : 0; + if (ret) + break; + } + drm_syncobj_array_free(syncobjs, args->count_handles); + + return ret; +} diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h index 0092111d002c..b2c36f2b2599 100644 --- a/include/uapi/drm/drm.h +++ b/include/uapi/drm/drm.h @@ -767,6 +767,14 @@ struct drm_syncobj_array { __u32 pad; }; +struct drm_syncobj_timeline_array { + __u64 handles; + __u64 points; + __u32 count_handles; + __u32 pad; +}; + + /* Query current scanout sequence number */ struct drm_crtc_get_sequence { __u32 crtc_id; /* requested crtc_id */ @@ -924,6 +932,8 @@ extern "C" { #define DRM_IOCTL_MODE_REVOKE_LEASE DRM_IOWR(0xC9, struct drm_mode_revoke_lease) #define DRM_IOCTL_SYNCOBJ_TIMELINE_WAIT DRM_IOWR(0xCA, struct drm_syncobj_timeline_wait) +#define DRM_IOCTL_SYNCOBJ_QUERY DRM_IOWR(0xCB, struct drm_syncobj_timeline_array) + /** * Device specific ioctls should only be in their respective headers * The device specific ioctl range is from 0x40 to 0x9f. From patchwork Tue Mar 12 03:10:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chunming Zhou X-Patchwork-Id: 10848555 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 CA7BA1515 for ; Tue, 12 Mar 2019 03:11:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B61CC291A9 for ; Tue, 12 Mar 2019 03:11:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A9BD6294BD; Tue, 12 Mar 2019 03:11:46 +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 5ED65291A9 for ; Tue, 12 Mar 2019 03:11:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 44E8589D86; Tue, 12 Mar 2019 03:11:45 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM05-CO1-obe.outbound.protection.outlook.com (mail-co1nam05on060e.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe50::60e]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3237489D7C; Tue, 12 Mar 2019 03:11:43 +0000 (UTC) Received: from CY4PR12CA0028.namprd12.prod.outlook.com (2603:10b6:903:129::14) by BY2PR12MB0582.namprd12.prod.outlook.com (2a01:111:e400:52dd::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1686.20; Tue, 12 Mar 2019 03:11:41 +0000 Received: from DM3NAM03FT010.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e49::208) by CY4PR12CA0028.outlook.office365.com (2603:10b6:903:129::14) 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:41 +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 DM3NAM03FT010.mail.protection.outlook.com (10.152.82.65) 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:41 +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:39 -0500 From: Chunming Zhou To: , , , , Subject: [PATCH 5/9] drm/syncobj: use the timeline point in drm_syncobj_find_fence v3 Date: Tue, 12 Mar 2019 11:10:45 +0800 Message-ID: <20190312031049.23647-5-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)(39860400002)(346002)(376002)(136003)(396003)(2980300002)(428003)(189003)(199004)(2870700001)(14444005)(76176011)(50466002)(426003)(2906002)(8936002)(68736007)(356004)(6666004)(53936002)(105586002)(53416004)(50226002)(1076003)(336012)(5820100001)(66574012)(106466001)(47776003)(486006)(478600001)(316002)(54906003)(36756003)(305945005)(446003)(110136005)(72206003)(11346002)(81156014)(7696005)(81166006)(8676002)(4326008)(5660300002)(186003)(86362001)(6636002)(77096007)(97736004)(2201001)(476003)(26005)(23676004)(104016004)(2616005)(126002); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR12MB0582; H:SATLEXCHOV01.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoDomainNonexistent; MX:1; A:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 44d41a43-6040-499e-9b30-08d6a69872f8 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600127)(711020)(4605104)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060); SRVR:BY2PR12MB0582; X-MS-TrafficTypeDiagnostic: BY2PR12MB0582: X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0582; 20:5ylRgZSKBypCEofk51Ki+EoEBjZsK1Y4UdW0wFzasuu/0mfTbdR9p40tniaqQZyDC6uhxgGxcHpv9bAF5CInM9JUyY3YPzzObcMAp8xWjEXmEf21lAJ7+ZWSc9rRrY6jRaO6CNh8PRohVmrhno+3OizCTIpK6G+FDiMPmw2+ING19QVfdAGr+tQkc7uQbVcd/Lx0xtj/8EqkFjjF9/8PN8lCp5PVeQRVJcj1Yw+d8rjaus5num35xpB4sKzGZqMIkfojsR4HFwODUnXCPzHjKM2hsM3fYC4IkxTV//4VoCwAlc5nCZU9WkU2ICh3m5mFEV48/UT/jNgUtcSGUc6BjeFL3NmXnz5jU8eDqPJRlGAOyj5E/hwakMqcElaDNaYcFZWqqgRlHuk9YqaKsvkIhOOryVKLFe3GRDQhdprc289d1OyTvQtqMjsWMjNTkxrGzbB1lJSPhJOZdtktvRH6RqQi2lP30ApnrWFrcdClUZbZtwH8mojfEdNFk6vQn7Y6 X-Microsoft-Antispam-PRVS: X-Forefront-PRVS: 09749A275C X-Microsoft-Exchange-Diagnostics: =?utf-8?q?1=3BBY2PR12MB0582=3B23=3AepJ3vDy?= =?utf-8?q?2yjKEaPuBrwaI4jNjmDOPjtdRYlluISRGW5PBHVWCm/ctNVG6tqURH8XswJAEY7ol?= =?utf-8?q?UNrbkPTrJp3Wb2TistYHrA3f1Mff7m7Eexooj8zjJxmDWO1VV3AT069O+GH4O/qhb?= =?utf-8?q?yW/rND5uIVoaxOvB2w5RUHwZ3C7inrnGtKFQ9awYsFLPkklVOgmgfaxdgU//skfFX?= =?utf-8?q?t4NSFqtM7/Jt+g+aTHs+zFBp2JVRYnklCNoUT8DNarQc05bVTUgcbA+uIbgUS7PGI?= =?utf-8?q?ovIC9j6ppA5/hsnqxp2UQGbkEIjyOkX+3x+Bj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JbNbVLeRRODyVBdiy2bG?= =?utf-8?q?pbgN0SIg5XG5B6Dp9lElUKoqISAHpUH7YcNBlx?= X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: CNSJy2qZ/BB++yTb9J5U/1qTy3EZzQPY5KSuQFHlXjOWgE+ojZECM35e8NbJsDYB8mZ9jQIRu5SzdR9s5H6OEDVz+VqXKFEOcOxcOHHa21N7M1Sz2RBrE7DXQ0o+WREgrBmP4b4EIBIpzdQBYtI7MbY+oGD3Sxniqgu6bUAQectMEx5KtlQZV9LWnUxCuQQW/SWZkC1UBaL3+t0KzopZeqzpc1dwY2ZKadfwIhYPTz10CyoZtzFday5JSzy8ItoymbQc6xMbK02w9GscVL6ucfa+unl4mc0lkTX9UIq0dwi9ZsSoOIAho6wPDPY25Aui0sd37Sdty3S7AmPP/azPm3z4zCQCPRn/+QlowpjWKzL0PRNU5bQGWxNJCgHSTzFOlsaScR4HweZl6ZX2wEZ4mMhVwb4p+uL7dqnhRd2XGwQ= X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0582; 20:4MHLKSA3/0YTNyu19ql4l/ocTT5cql/mw37aOPSrP06qVVgPTOhXspaFYUYkV0i6Mx8cl9v68YXdCO4LROk8IA8A29BvAnf6yCbQVVxmslkKKHSqMKdOh9akYTRHpEhZNsGFVwh2dRFOzxO4EU0BAs1PUxESXXAsRhc541LH79zMXt7ajkfaZcloKjFwiznBVjWPu5JlahvDs6WsAg/cOAn7ux8UNMidIJRRBx535iZ/N7LM8QQlNKkpN2QPOKh9 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Mar 2019 03:11:41.0396 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 44d41a43-6040-499e-9b30-08d6a69872f8 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: BY2PR12MB0582 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=tLBcXvKybbKtgMvbFg/wn60+wVg5OGvVwPQFnK72hyk=; b=LQTXnnRIihvP2zpJXiOt4gPHfUHtlGgZOeAE0C5/R0qa1OIeBW1hX7TOMypAF1/QbFgVSvw+xB6AvKpFFc1LTEIYFSztDlPaM2XYgb2hq+fsOmRmlf5EiURT8Nirv65DlYb5S+pJh5Vup4efQI2vpsxwHrPM2sPh6Axoj7dS2OE= 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 Implement finding the right timeline point in drm_syncobj_find_fence. v2: return -EINVAL when the point is not submitted yet. v3: fix reference counting bug, add flags handling as well Signed-off-by: Christian König --- drivers/gpu/drm/drm_syncobj.c | 43 ++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c index a5adc7c06caa..673b805ab2e8 100644 --- a/drivers/gpu/drm/drm_syncobj.c +++ b/drivers/gpu/drm/drm_syncobj.c @@ -231,16 +231,53 @@ int drm_syncobj_find_fence(struct drm_file *file_private, struct dma_fence **fence) { struct drm_syncobj *syncobj = drm_syncobj_find(file_private, handle); - int ret = 0; + struct syncobj_wait_entry wait; + int ret; if (!syncobj) return -ENOENT; *fence = drm_syncobj_fence_get(syncobj); - if (!*fence) { + drm_syncobj_put(syncobj); + + if (*fence) { + ret = dma_fence_chain_find_seqno(fence, point); + if (!ret) + return 0; + dma_fence_put(*fence); + } else { ret = -EINVAL; } - drm_syncobj_put(syncobj); + + if (!(flags & DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT)) + return ret; + + memset(&wait, 0, sizeof(wait)); + wait.task = current; + wait.point = point; + drm_syncobj_fence_add_wait(syncobj, &wait); + + do { + set_current_state(TASK_INTERRUPTIBLE); + if (wait.fence) { + ret = 0; + break; + } + + if (signal_pending(current)) { + ret = -ERESTARTSYS; + break; + } + + schedule(); + } while (1); + + __set_current_state(TASK_RUNNING); + *fence = wait.fence; + + if (wait.node.next) + drm_syncobj_remove_wait(syncobj, &wait); + return ret; } EXPORT_SYMBOL(drm_syncobj_find_fence); From patchwork Tue Mar 12 03:10:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chunming Zhou X-Patchwork-Id: 10848557 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 B4BF01515 for ; Tue, 12 Mar 2019 03:11:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A01DD291A9 for ; Tue, 12 Mar 2019 03:11:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 943F3294BD; Tue, 12 Mar 2019 03:11:58 +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 ED2D3291A9 for ; Tue, 12 Mar 2019 03:11:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CF27F89D9B; Tue, 12 Mar 2019 03:11:56 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM05-CO1-obe.outbound.protection.outlook.com (mail-eopbgr720052.outbound.protection.outlook.com [40.107.72.52]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6B77189854; Tue, 12 Mar 2019 03:11:55 +0000 (UTC) Received: from BN4PR12CA0006.namprd12.prod.outlook.com (2603:10b6:403:2::16) by DM6PR12MB3465.namprd12.prod.outlook.com (2603:10b6:5:3b::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1686.18; Tue, 12 Mar 2019 03:11:53 +0000 Received: from DM3NAM03FT055.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e49::208) by BN4PR12CA0006.outlook.office365.com (2603:10b6:403:2::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1686.16 via Frontend Transport; Tue, 12 Mar 2019 03:11:52 +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 DM3NAM03FT055.mail.protection.outlook.com (10.152.83.209) 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:51 +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:49 -0500 From: Chunming Zhou To: , , , , Subject: [PATCH 6/9] drm/amdgpu: add timeline support in amdgpu CS v3 Date: Tue, 12 Mar 2019 11:10:46 +0800 Message-ID: <20190312031049.23647-6-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)(39860400002)(376002)(396003)(136003)(346002)(2980300002)(428003)(189003)(199004)(5820100001)(47776003)(5660300002)(77096007)(68736007)(97736004)(50466002)(104016004)(356004)(53936002)(81156014)(2870700001)(26005)(50226002)(6666004)(23676004)(8676002)(11346002)(81166006)(2906002)(305945005)(476003)(126002)(7696005)(486006)(446003)(478600001)(36756003)(2201001)(2616005)(336012)(426003)(186003)(4326008)(86362001)(6636002)(76176011)(72206003)(1076003)(105586002)(66574012)(54906003)(110136005)(316002)(53416004)(14444005)(8936002)(106466001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM6PR12MB3465; H:SATLEXCHOV01.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoDomainNonexistent; MX:1; A:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cf844b70-9343-424e-e5f2-08d6a698797d X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(2017052603328)(7153060); SRVR:DM6PR12MB3465; X-MS-TrafficTypeDiagnostic: DM6PR12MB3465: X-Microsoft-Exchange-Diagnostics: 1; DM6PR12MB3465; 20:ZvhCm0ZhQSxBuhDa1/x8t0Qgj9NL0l/0dJ+OxRQGT4r8kIVhhIrqpcQJfhKYKVAKLRo6tL0nQ1pOsWeF6SJQKZyvuZTN8CD+31gTM+oq2gnO1PN/YypKXc1frg8rC4Oy3kc2M8XgMerlpG4BDy1aUTmichFvA6ADDUzesy5zbD6Ly9bwJkel2fT+RtahzPDw1Q/Zmj0UtKzP55lwGJU0rsIRi7K97I9AbUO6DWU6yEZaHj+jIqcdhzaw0scqXsHKyAam6tBkNBOMdXK+ckYJOWJx/JHPsOZ1q81C2tcbkabwDpaUhcVvuGSrQd1BftDuEsdAvIxpqKPw5oU/tdB+p2qCasR1Sta6sJrev4xqePowwV8Zcud924S5KA0+23HB2no0wI8Y8zuda1pRaZ3erVJZ98pkS9SKIqphRfpyYddJdrns/4dVqw9NbR1/ser6P9yrg/Q+nRhnj7tMG4/0K56keRNwUGsp/XYT248xI2tjOJYjz0VEsMXcTOBQXr9u X-Microsoft-Antispam-PRVS: X-Forefront-PRVS: 09749A275C X-Microsoft-Exchange-Diagnostics: =?utf-8?q?1=3BDM6PR12MB3465=3B23=3AjMrabUJ?= =?utf-8?q?iT8A7Gfc7HwTy/kVziouNMzLe75w5o87xygzrGL9IWzGAAUdMNx/x2X5NTE4ijLTE?= =?utf-8?q?jXuf/jD1wPsxPhIGP20TK4yNYEz6SswTaLLxQDjwQ11gPg4MY3s3gMUcX9n0yYwfd?= =?utf-8?q?3u317YGfuNr/RlgtNHqhMdimMbvF+6HCfAI/RW97KvkzrFh3QRtbXPq7BuXxjJip3?= =?utf-8?q?iWYIq1F+FvCVhEpsNm6QBcU7obfSmdmdlHceYqxOCaIdybLLm9pPxxbLEpwfq9LAt?= =?utf-8?q?CnYIEklbWaILHRVu0lv9GSldK79wdmF2oG53bMt479o5iTk35sAavl/HKziOMMuU/?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n67VBrPjFHR33RI/8yw2gLzVXIHltsYiOU62?= X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: SttP3GqS1TD3wBfKXDkvPOIq842wRa2I0lylLb/d2mWa2xKYga/p0MZqcu6fxKUPIzqTnSQdjpW5xK4w1yqwisJU0D/FuSlwvdXyLcb/P5nsV6qlYXAloojuW6+ftahXvlTPc50soRnqQ6d13t7o5HsdxKAUTkYliPWE5cV09fxESFCVgTjpWbxQs1jXM46Epc9kd9Gd1T4z9Lz+BVMl/HjqHCGieesYYLjv5XVMiBxNdIhsXCv/XDazbdDbzmcOnhVZFyyPT4AOeoWcNWL45Fd0gWiyjC6Edv9Np7A0+n/aJX5ZJvfRZR2Gdk/Nmey0hZm1f5AIgon2cIoZ/p99jVC83ySrb85430HYwgc00BGCpLxM70yNGqBs+QC/xNB6QjSeKTjnIjXf2LbCkLvIHg6Bj+ZF3JJu9jREfUw/oWs= X-Microsoft-Exchange-Diagnostics: 1; DM6PR12MB3465; 20:xg5+AmDEgwCXh4bPil1II1zDeQVjr7C92e831mZWMq0rPKhk49Cp/scDPaTpY2BQ+PawgZjcCgC6lmlurEAntRKtqE783u0M8L3MQ7f9mqibOnmiI6a/Rf3G5Ny/EffXUDoJ2ObEFBpIykZiXxropvX0yA2VFxYeap/OzXPZbvcKt7JcTDKyUojyVsW0vnny16v8NV/91JwnbKY1U9VHmwDVKZzFMGvY/EjNMDhE4b7bHAb/t+BmBOAKAhjF0nrc X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Mar 2019 03:11:51.9302 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cf844b70-9343-424e-e5f2-08d6a698797d 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: DM6PR12MB3465 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=uQM95N1NWpwUilIME/MJxQlAmSPtOIb84PXp4DrA4ho=; b=TkPP/xetfQTHKDuOHjMZHxEzNemVF5VbGngX1rMYzoc3HsAZrXYRFEYgFkjshQZ0BakFhjJWJGJgWC8GUm1OMGNAe9HyBJIfzFJgHgDZ8Z8GNZr0URcDfLap/rcThmUa4qaVRs2JIfRJ9eJEzW7OduqY+tsWdeQW69rMxtqfL2s= X-Mailman-Original-Authentication-Results: spf=none (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; basnieuwenhuizen.nl; dkim=none (message not signed) header.d=none;basnieuwenhuizen.nl; 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: Daniel Rakos , Dave Airlie , =?utf-8?q?Christian_K=C3=B6nig?= Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP syncobj wait/signal operation is appending in command submission. v2: separate to two kinds in/out_deps functions v3: fix checking for timeline syncobj Signed-off-by: Chunming Zhou Cc: Daniel Rakos Cc: Jason Ekstrand Cc: Bas Nieuwenhuizen Cc: Dave Airlie Cc: Christian König Cc: Chris Wilson --- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 10 +- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 152 +++++++++++++++++++++---- include/uapi/drm/amdgpu_drm.h | 8 ++ 3 files changed, 144 insertions(+), 26 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index 8d0d7f3dd5fb..deec2c796253 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h @@ -433,6 +433,12 @@ struct amdgpu_cs_chunk { void *kdata; }; +struct amdgpu_cs_post_dep { + struct drm_syncobj *syncobj; + struct dma_fence_chain *chain; + u64 point; +}; + struct amdgpu_cs_parser { struct amdgpu_device *adev; struct drm_file *filp; @@ -462,8 +468,8 @@ struct amdgpu_cs_parser { /* user fence */ struct amdgpu_bo_list_entry uf_entry; - unsigned num_post_dep_syncobjs; - struct drm_syncobj **post_dep_syncobjs; + unsigned num_post_deps; + struct amdgpu_cs_post_dep *post_deps; }; static inline u32 amdgpu_get_ib_value(struct amdgpu_cs_parser *p, diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c index 52a5e4fdc95b..2f6239b6be6f 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c @@ -215,6 +215,8 @@ static int amdgpu_cs_parser_init(struct amdgpu_cs_parser *p, union drm_amdgpu_cs case AMDGPU_CHUNK_ID_SYNCOBJ_IN: case AMDGPU_CHUNK_ID_SYNCOBJ_OUT: case AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES: + case AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_WAIT: + case AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_SIGNAL: break; default: @@ -804,9 +806,11 @@ static void amdgpu_cs_parser_fini(struct amdgpu_cs_parser *parser, int error, ttm_eu_backoff_reservation(&parser->ticket, &parser->validated); - for (i = 0; i < parser->num_post_dep_syncobjs; i++) - drm_syncobj_put(parser->post_dep_syncobjs[i]); - kfree(parser->post_dep_syncobjs); + for (i = 0; i < parser->num_post_deps; i++) { + drm_syncobj_put(parser->post_deps[i].syncobj); + kfree(parser->post_deps[i].chain); + } + kfree(parser->post_deps); dma_fence_put(parser->fence); @@ -1117,13 +1121,18 @@ static int amdgpu_cs_process_fence_dep(struct amdgpu_cs_parser *p, } static int amdgpu_syncobj_lookup_and_add_to_sync(struct amdgpu_cs_parser *p, - uint32_t handle) + uint32_t handle, u64 point, + u64 flags) { - int r; struct dma_fence *fence; - r = drm_syncobj_find_fence(p->filp, handle, 0, 0, &fence); - if (r) + int r; + + r = drm_syncobj_find_fence(p->filp, handle, point, flags, &fence); + if (r) { + DRM_ERROR("syncobj %u failed to find fence @ %llu (%d)!\n", + handle, point, r); return r; + } r = amdgpu_sync_fence(p->adev, &p->job->sync, fence, true); dma_fence_put(fence); @@ -1134,46 +1143,118 @@ static int amdgpu_syncobj_lookup_and_add_to_sync(struct amdgpu_cs_parser *p, static int amdgpu_cs_process_syncobj_in_dep(struct amdgpu_cs_parser *p, struct amdgpu_cs_chunk *chunk) { + struct drm_amdgpu_cs_chunk_sem *deps; unsigned num_deps; int i, r; - struct drm_amdgpu_cs_chunk_sem *deps; deps = (struct drm_amdgpu_cs_chunk_sem *)chunk->kdata; num_deps = chunk->length_dw * 4 / sizeof(struct drm_amdgpu_cs_chunk_sem); + for (i = 0; i < num_deps; ++i) { + r = amdgpu_syncobj_lookup_and_add_to_sync(p, deps[i].handle, + 0, 0); + if (r) + return r; + } + + return 0; +} + +static int amdgpu_cs_process_syncobj_timeline_in_dep(struct amdgpu_cs_parser *p, + struct amdgpu_cs_chunk *chunk) +{ + struct drm_amdgpu_cs_chunk_syncobj *syncobj_deps; + unsigned num_deps; + int i, r; + + syncobj_deps = (struct drm_amdgpu_cs_chunk_syncobj *)chunk->kdata; + num_deps = chunk->length_dw * 4 / + sizeof(struct drm_amdgpu_cs_chunk_syncobj); for (i = 0; i < num_deps; ++i) { - r = amdgpu_syncobj_lookup_and_add_to_sync(p, deps[i].handle); + r = amdgpu_syncobj_lookup_and_add_to_sync(p, + syncobj_deps[i].handle, + syncobj_deps[i].point, + syncobj_deps[i].flags); if (r) return r; } + return 0; } static int amdgpu_cs_process_syncobj_out_dep(struct amdgpu_cs_parser *p, struct amdgpu_cs_chunk *chunk) { + struct drm_amdgpu_cs_chunk_sem *deps; unsigned num_deps; int i; - struct drm_amdgpu_cs_chunk_sem *deps; + deps = (struct drm_amdgpu_cs_chunk_sem *)chunk->kdata; num_deps = chunk->length_dw * 4 / sizeof(struct drm_amdgpu_cs_chunk_sem); - p->post_dep_syncobjs = kmalloc_array(num_deps, - sizeof(struct drm_syncobj *), - GFP_KERNEL); - p->num_post_dep_syncobjs = 0; + p->post_deps = kmalloc_array(num_deps, sizeof(*p->post_deps), + GFP_KERNEL); + p->num_post_deps = 0; - if (!p->post_dep_syncobjs) + if (!p->post_deps) return -ENOMEM; + for (i = 0; i < num_deps; ++i) { - p->post_dep_syncobjs[i] = drm_syncobj_find(p->filp, deps[i].handle); - if (!p->post_dep_syncobjs[i]) + p->post_deps[i].syncobj = + drm_syncobj_find(p->filp, deps[i].handle); + if (!p->post_deps[i].syncobj) return -EINVAL; - p->num_post_dep_syncobjs++; + p->post_deps[i].chain = NULL; + p->post_deps[i].point = 0; + p->num_post_deps++; } + + return 0; +} + + +static int amdgpu_cs_process_syncobj_timeline_out_dep(struct amdgpu_cs_parser *p, + struct amdgpu_cs_chunk + *chunk) +{ + struct drm_amdgpu_cs_chunk_syncobj *syncobj_deps; + unsigned num_deps; + int i; + + syncobj_deps = (struct drm_amdgpu_cs_chunk_syncobj *)chunk->kdata; + num_deps = chunk->length_dw * 4 / + sizeof(struct drm_amdgpu_cs_chunk_syncobj); + + p->post_deps = kmalloc_array(num_deps, sizeof(*p->post_deps), + GFP_KERNEL); + p->num_post_deps = 0; + + if (!p->post_deps) + return -ENOMEM; + + for (i = 0; i < num_deps; ++i) { + struct amdgpu_cs_post_dep *dep = &p->post_deps[i]; + + dep->chain = NULL; + if (syncobj_deps[i].point) { + dep->chain = kmalloc(sizeof(*dep->chain), GFP_KERNEL); + if (!dep->chain) + return -ENOMEM; + } + + dep->syncobj = drm_syncobj_find(p->filp, + syncobj_deps[i].handle); + if (!dep->syncobj) { + kfree(dep->chain); + return -EINVAL; + } + dep->point = syncobj_deps[i].point; + p->num_post_deps++; + } + return 0; } @@ -1187,19 +1268,33 @@ static int amdgpu_cs_dependencies(struct amdgpu_device *adev, chunk = &p->chunks[i]; - if (chunk->chunk_id == AMDGPU_CHUNK_ID_DEPENDENCIES || - chunk->chunk_id == AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES) { + switch (chunk->chunk_id) { + case AMDGPU_CHUNK_ID_DEPENDENCIES: + case AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES: r = amdgpu_cs_process_fence_dep(p, chunk); if (r) return r; - } else if (chunk->chunk_id == AMDGPU_CHUNK_ID_SYNCOBJ_IN) { + break; + case AMDGPU_CHUNK_ID_SYNCOBJ_IN: r = amdgpu_cs_process_syncobj_in_dep(p, chunk); if (r) return r; - } else if (chunk->chunk_id == AMDGPU_CHUNK_ID_SYNCOBJ_OUT) { + break; + case AMDGPU_CHUNK_ID_SYNCOBJ_OUT: r = amdgpu_cs_process_syncobj_out_dep(p, chunk); if (r) return r; + break; + case AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_WAIT: + r = amdgpu_cs_process_syncobj_timeline_in_dep(p, chunk); + if (r) + return r; + break; + case AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_SIGNAL: + r = amdgpu_cs_process_syncobj_timeline_out_dep(p, chunk); + if (r) + return r; + break; } } @@ -1210,8 +1305,17 @@ static void amdgpu_cs_post_dependencies(struct amdgpu_cs_parser *p) { int i; - for (i = 0; i < p->num_post_dep_syncobjs; ++i) - drm_syncobj_replace_fence(p->post_dep_syncobjs[i], p->fence); + for (i = 0; i < p->num_post_deps; ++i) { + if (p->post_deps[i].chain && p->post_deps[i].point) { + drm_syncobj_add_point(p->post_deps[i].syncobj, + p->post_deps[i].chain, + p->fence, p->post_deps[i].point); + p->post_deps[i].chain = NULL; + } else { + drm_syncobj_replace_fence(p->post_deps[i].syncobj, + p->fence); + } + } } static int amdgpu_cs_submit(struct amdgpu_cs_parser *p, diff --git a/include/uapi/drm/amdgpu_drm.h b/include/uapi/drm/amdgpu_drm.h index 4a53f6cfa034..e928760c4c1a 100644 --- a/include/uapi/drm/amdgpu_drm.h +++ b/include/uapi/drm/amdgpu_drm.h @@ -525,6 +525,8 @@ struct drm_amdgpu_gem_va { #define AMDGPU_CHUNK_ID_SYNCOBJ_OUT 0x05 #define AMDGPU_CHUNK_ID_BO_HANDLES 0x06 #define AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES 0x07 +#define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_WAIT 0x08 +#define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_SIGNAL 0x09 struct drm_amdgpu_cs_chunk { __u32 chunk_id; @@ -605,6 +607,12 @@ struct drm_amdgpu_cs_chunk_sem { __u32 handle; }; +struct drm_amdgpu_cs_chunk_syncobj { + __u32 handle; + __u32 flags; + __u64 point; +}; + #define AMDGPU_FENCE_TO_HANDLE_GET_SYNCOBJ 0 #define AMDGPU_FENCE_TO_HANDLE_GET_SYNCOBJ_FD 1 #define AMDGPU_FENCE_TO_HANDLE_GET_SYNC_FILE_FD 2 From patchwork Tue Mar 12 03:10:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunming Zhou X-Patchwork-Id: 10848559 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 CF4101850 for ; Tue, 12 Mar 2019 03:12:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BA8AB291A9 for ; Tue, 12 Mar 2019 03:12:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AD5FF294BD; Tue, 12 Mar 2019 03:12:03 +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 AD8F0291A9 for ; Tue, 12 Mar 2019 03:12:02 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CB5EE898F5; Tue, 12 Mar 2019 03:12:00 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-eopbgr810073.outbound.protection.outlook.com [40.107.81.73]) by gabe.freedesktop.org (Postfix) with ESMTPS id 007D389C63; Tue, 12 Mar 2019 03:11:58 +0000 (UTC) Received: from BN4PR12CA0006.namprd12.prod.outlook.com (2603:10b6:403:2::16) by BYAPR12MB3461.namprd12.prod.outlook.com (2603:10b6:a03:ad::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1709.13; Tue, 12 Mar 2019 03:11:56 +0000 Received: from DM3NAM03FT055.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e49::208) by BN4PR12CA0006.outlook.office365.com (2603:10b6:403:2::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1686.16 via Frontend Transport; Tue, 12 Mar 2019 03:11:55 +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 DM3NAM03FT055.mail.protection.outlook.com (10.152.83.209) 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:55 +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:52 -0500 From: Chunming Zhou To: , , , , Subject: [PATCH 7/9] drm/syncobj: add transition iotcls between binary and timeline v2 Date: Tue, 12 Mar 2019 11:10:47 +0800 Message-ID: <20190312031049.23647-7-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)(3190300001)(199004)(189003)(4326008)(186003)(478600001)(5660300002)(336012)(86362001)(305945005)(476003)(2616005)(2201001)(486006)(126002)(11346002)(446003)(8936002)(50226002)(426003)(48376002)(110136005)(6666004)(356004)(76176011)(26005)(104016004)(51416003)(7696005)(316002)(16586007)(47776003)(77096007)(53416004)(2906002)(36756003)(68736007)(72206003)(105586002)(106466001)(50466002)(14444005)(53936002)(8676002)(97736004)(81166006)(81156014)(6636002)(1076003); DIR:OUT; SFP:1101; SCL:1; SRVR:BYAPR12MB3461; 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: 2e18ff2a-c1b0-4730-46a3-08d6a6987b74 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(2017052603328)(7153060); SRVR:BYAPR12MB3461; X-MS-TrafficTypeDiagnostic: BYAPR12MB3461: X-Microsoft-Antispam-PRVS: X-Forefront-PRVS: 09749A275C X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: 5ia105mMDbix6PEf4L+n+/rWL1V2cghdt5vkPyimEp7XZbbIZkDOmle6uGhpMnE0L2iWV4oNoX3v1Qv06KVWZLRh3zIYx9Q8RHHiOsx5Y+AT2pOOBRxeFfXbxtIGE/YJ+IoYwGDFm+viT8LicnmZ9GYIx83u8GjMjI6F+BrKbhPRmaA8l/9wDBcIDIrJ4jgYzKVXDTK8Mq16/7BzsRKmvi0/k9+kCeJOFaIua77hl/dC/9QF/hfEWij88yulfHV7HiMoNS5hEXWQipnQ0XHOMgAPobO7o/CiZD/h8sujhcazTM1FWyPfOB8af3mxHkLWMrOkvV9kXUIXgwxl4rY1kh8X23dAHOyc/h3Me+U7AOG3N9erIQ+rUQS82Sn55UewM5eFiQ+/odRmViKXIaA0xsTq+GmQ57qa/OfCUVBtTJc= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Mar 2019 03:11:55.3349 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2e18ff2a-c1b0-4730-46a3-08d6a6987b74 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: BYAPR12MB3461 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=CQA0z3MuX+5kfwNgGrIHMRWs6IImZr7Kq64f8UDDc78=; b=q6+ZFwmozHY/+C84PIHMzaneHFkPd8U4bHdC0zRNHaj9lJHXnRWeSDDMLVTRwPVYFO1KzCMMbvrHAyOaV6M6kTaVvQUzfhDlrjcUVIbVSSwUrxYBj63Uon3Wt+tOled191FkXn/qtb+yHc3p0ZewcqjBdTfPE29v+iy2qwlCh1E= X-Mailman-Original-Authentication-Results: spf=none (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; intel.com; dkim=none (message not signed) header.d=none;intel.com; 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP we need to import/export timeline point. v2: unify to one transfer ioctl Signed-off-by: Chunming Zhou --- drivers/gpu/drm/drm_internal.h | 2 + drivers/gpu/drm/drm_ioctl.c | 2 + drivers/gpu/drm/drm_syncobj.c | 74 ++++++++++++++++++++++++++++++++++ include/uapi/drm/drm.h | 10 +++++ 4 files changed, 88 insertions(+) diff --git a/drivers/gpu/drm/drm_internal.h b/drivers/gpu/drm/drm_internal.h index 695179bb88dc..dd11ae5f1eef 100644 --- a/drivers/gpu/drm/drm_internal.h +++ b/drivers/gpu/drm/drm_internal.h @@ -180,6 +180,8 @@ int drm_syncobj_handle_to_fd_ioctl(struct drm_device *dev, void *data, struct drm_file *file_private); int drm_syncobj_fd_to_handle_ioctl(struct drm_device *dev, void *data, struct drm_file *file_private); +int drm_syncobj_transfer_ioctl(struct drm_device *dev, void *data, + struct drm_file *file_private); int drm_syncobj_wait_ioctl(struct drm_device *dev, void *data, struct drm_file *file_private); int drm_syncobj_timeline_wait_ioctl(struct drm_device *dev, void *data, diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c index 7a534c184e52..92b3b7b2fd81 100644 --- a/drivers/gpu/drm/drm_ioctl.c +++ b/drivers/gpu/drm/drm_ioctl.c @@ -686,6 +686,8 @@ static const struct drm_ioctl_desc drm_ioctls[] = { DRM_UNLOCKED|DRM_RENDER_ALLOW), DRM_IOCTL_DEF(DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE, drm_syncobj_fd_to_handle_ioctl, DRM_UNLOCKED|DRM_RENDER_ALLOW), + DRM_IOCTL_DEF(DRM_IOCTL_SYNCOBJ_TRANSFER, drm_syncobj_transfer_ioctl, + DRM_UNLOCKED|DRM_RENDER_ALLOW), DRM_IOCTL_DEF(DRM_IOCTL_SYNCOBJ_WAIT, drm_syncobj_wait_ioctl, DRM_UNLOCKED|DRM_RENDER_ALLOW), DRM_IOCTL_DEF(DRM_IOCTL_SYNCOBJ_TIMELINE_WAIT, drm_syncobj_timeline_wait_ioctl, diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c index 673b805ab2e8..f1d18d10d1f2 100644 --- a/drivers/gpu/drm/drm_syncobj.c +++ b/drivers/gpu/drm/drm_syncobj.c @@ -670,6 +670,80 @@ drm_syncobj_fd_to_handle_ioctl(struct drm_device *dev, void *data, &args->handle); } +static int drm_syncobj_transfer_to_timeline(struct drm_file *file_private, + struct drm_syncobj_transfer *args) +{ + struct drm_syncobj *timeline_syncobj = NULL; + struct dma_fence *fence; + struct dma_fence_chain *chain; + int ret; + + timeline_syncobj = drm_syncobj_find(file_private, args->dst_handle); + if (!timeline_syncobj) { + return -ENOENT; + } + ret = drm_syncobj_find_fence(file_private, args->src_handle, + args->src_point, args->flags, + &fence); + if (ret) + goto err; + chain = kzalloc(sizeof(struct dma_fence_chain), GFP_KERNEL); + if (!chain) { + ret = -ENOMEM; + goto err1; + } + drm_syncobj_add_point(timeline_syncobj, chain, fence, args->dst_point); +err1: + dma_fence_put(fence); +err: + drm_syncobj_put(timeline_syncobj); + + return ret; +} + +static int +drm_syncobj_transfer_to_binary(struct drm_file *file_private, + struct drm_syncobj_transfer *args) +{ + struct drm_syncobj *binary_syncobj = NULL; + struct dma_fence *fence; + int ret; + + binary_syncobj = drm_syncobj_find(file_private, args->dst_handle); + if (!binary_syncobj) + return -ENOENT; + ret = drm_syncobj_find_fence(file_private, args->src_handle, + args->src_point, args->flags, &fence); + if (ret) + goto err; + drm_syncobj_replace_fence(binary_syncobj, fence); + dma_fence_put(fence); +err: + drm_syncobj_put(binary_syncobj); + + return ret; +} +int +drm_syncobj_transfer_ioctl(struct drm_device *dev, void *data, + struct drm_file *file_private) +{ + struct drm_syncobj_transfer *args = data; + int ret; + + if (!drm_core_check_feature(dev, DRIVER_SYNCOBJ)) + return -ENODEV; + + if (args->pad) + return -EINVAL; + + if (args->dst_point) + ret = drm_syncobj_transfer_to_timeline(file_private, args); + else + ret = drm_syncobj_transfer_to_binary(file_private, args); + + return ret; +} + static void syncobj_wait_fence_func(struct dma_fence *fence, struct dma_fence_cb *cb) { diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h index b2c36f2b2599..4c1e2e6579fa 100644 --- a/include/uapi/drm/drm.h +++ b/include/uapi/drm/drm.h @@ -735,6 +735,15 @@ struct drm_syncobj_handle { __u32 pad; }; +struct drm_syncobj_transfer { + __u32 src_handle; + __u32 dst_handle; + __u64 src_point; + __u64 dst_point; + __u32 flags; + __u32 pad; +}; + #define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_ALL (1 << 0) #define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT (1 << 1) #define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_AVAILABLE (1 << 2) @@ -933,6 +942,7 @@ extern "C" { #define DRM_IOCTL_SYNCOBJ_TIMELINE_WAIT DRM_IOWR(0xCA, struct drm_syncobj_timeline_wait) #define DRM_IOCTL_SYNCOBJ_QUERY DRM_IOWR(0xCB, struct drm_syncobj_timeline_array) +#define DRM_IOCTL_SYNCOBJ_TRANSFER DRM_IOWR(0xCC, struct drm_syncobj_transfer) /** * Device specific ioctls should only be in their respective headers From patchwork Tue Mar 12 03:10:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunming Zhou X-Patchwork-Id: 10848561 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 376971515 for ; Tue, 12 Mar 2019 03:12:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 249A8291A9 for ; Tue, 12 Mar 2019 03:12:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 18B60294BD; Tue, 12 Mar 2019 03:12:05 +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=BAD_ENC_HEADER,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 9A808291A9 for ; Tue, 12 Mar 2019 03:12:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 01ED889DA4; Tue, 12 Mar 2019 03:12:01 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0618.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe48::618]) by gabe.freedesktop.org (Postfix) with ESMTPS id A72C689C63; Tue, 12 Mar 2019 03:11:59 +0000 (UTC) Received: from BN4PR12CA0006.namprd12.prod.outlook.com (2603:10b6:403:2::16) by BN8PR12MB2961.namprd12.prod.outlook.com (2603:10b6:408:61::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1686.18; Tue, 12 Mar 2019 03:11:57 +0000 Received: from DM3NAM03FT055.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e49::208) by BN4PR12CA0006.outlook.office365.com (2603:10b6:403:2::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1686.16 via Frontend Transport; Tue, 12 Mar 2019 03:11:57 +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 DM3NAM03FT055.mail.protection.outlook.com (10.152.83.209) 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:57 +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:56 -0500 From: Chunming Zhou To: , , , , Subject: [PATCH 8/9] drm/syncobj: add timeline signal ioctl for syncobj v3 Date: Tue, 12 Mar 2019 11:10:48 +0800 Message-ID: <20190312031049.23647-8-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)(39860400002)(346002)(376002)(396003)(2980300002)(428003)(3190300001)(189003)(199004)(104016004)(36756003)(316002)(305945005)(8936002)(97736004)(53936002)(50226002)(68736007)(6636002)(51416003)(7696005)(2906002)(8676002)(76176011)(126002)(105586002)(336012)(476003)(16586007)(81156014)(2616005)(426003)(486006)(81166006)(4326008)(2201001)(86362001)(48376002)(478600001)(6666004)(50466002)(186003)(356004)(53416004)(14444005)(110136005)(77096007)(26005)(106466001)(11346002)(446003)(1076003)(47776003)(5660300002)(72206003); DIR:OUT; SFP:1101; SCL:1; SRVR:BN8PR12MB2961; H:SATLEXCHOV01.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoDomainNonexistent; MX:1; A:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 23ca7430-ea55-4925-52b1-08d6a6987c7c X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(2017052603328)(7153060); SRVR:BN8PR12MB2961; X-MS-TrafficTypeDiagnostic: BN8PR12MB2961: X-Microsoft-Exchange-Diagnostics: 1; BN8PR12MB2961; 20:BInFhoyVMr6G0OucYagZSLMmzGUHzScQVq8xjI56l2LhC2HHjnl0+HANV+wGNyNvpupPtwIG8iO9fCKVOlb0oSeXHfZZ2t44OL1TFTx5QWFJHM/739fLcDTZXKlXkP92Wp3vJvPe4lAfXNlsG8HUsLYK0t6GaZda4HhiT90gbjSNam3RuIIHjq5kTUVEVx/sXsNF0O0Fkqbm9TyAZYZ1cxzBQaYOjGTefgE1OXTlnkTuNwPGtWWkrPEaQkSlh0WoKhszUGVYS6jJPlKwPKBnLgKd3AzokSKaiyNO/ndQyuXsTUSsDCTg400hl3io5UUkpeuIbW/JbnLPn74VLA82OYcdcSEP8BF9Mc9O+PsbXlrO4rR4RKcBZzjBPzwm5ls55G1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8KlOthyNnUxuHL+SQzjI35SRpByeVdxCsWDCkKuY3GNI5an9FDUdYKyCeDbfKP/ByJmSshVukHtWiNv/7j4bbseus4P5M9cQeSXY3Xo1Gif3eKVf9Xp9Ue0Uo71dtf1aG6YY7txGu3od55n5QE7VltF0toGj3fH0lZYBee3U4V514BnRK068VMJZ7yXa6IqXdlq+9LMf8x8RQcMmPTeba1BZVGY7wqgJmFUQHvndefSQ7V2+jlRph1POzruDZ7PlDKpJHu8l0k0LNvIQCFlowopVzT7smpA+8SBA0yiagTMH3lutnf8oyMCagJXJQX6EbErcfxbicYdfmwekNqsN9KFE35TcDZv0YrEho/XCQEdVbbPJCQ== X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: zz7VAOQRahP0Hb1JjdB5QY+T30R0+ZwchEBllkONRU8v/hmO+jTurpuUvoSa3q82oOzZ2P/JJbFb3U/OGifULIaL7vumICx6PHTAVv+yKTib9MTFg/M16gGuVNN0feTCkaICM4o9F7v6qn7jAmAIXik9C5WQK5p2rynx9rhJ1F/uMYCXKfHk30PeOKGX5mXoABkWPOOCF8MD/s8WN1bDnRhW6H2cO0Ph9lcYMh7H1OKTTbNimv0iQ3pIPs14LsAcg/YNWiQ200iB/5aDCvaqZdwCtP639eR22oTViGOeu2kwAp9twD/D+Sv6AH+F+G95qL8OzU4V5CuMQCCqACsDfEItzy/P/Kt/kHfLIOM9IMbFt+a4tDQ0dhBZGL04z9TrVMQ8QfmDQl0BkAn/vAyMifT0l/c/39cBv68fch5CYlU= X-Microsoft-Exchange-Diagnostics: 1; BN8PR12MB2961; 20:1pd8LnpEIexQvUHJaP3IprXQt7wbQ+dNyPgE98wxVGLcz5jC/tQ30+K/Q8M7nwg1O/Wiq4p0/8Cmvtl29xrd19hjupwr8yu5PI8AmKwjK08Vz6W6PJY9eviNDnP8IUrqyYoRZfkq9ySwG3J9P3J0Dct9j4VAjfb02XNmcUnc4prkavAvEslnysOm/E6Q8bBjrQlz1XzkviJ8v6zBLeBQIMeAG26XEzqAfO5kygsqFEc8VSPVYV42iyneLVVssvqN X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Mar 2019 03:11:57.0999 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 23ca7430-ea55-4925-52b1-08d6a6987c7c 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: BN8PR12MB2961 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=1cd0iJB9Yzvt6glQ7+6gs3XzVHiquIZhD2GQoeH3SYg=; b=xpLmoioBWPbB6ITdSuqmSkIL/97M5sDmrEo0Uu2v8h3Ta5XitGn2ifgg3pmmqfAlrhPifK4oca6m/yZ/09vQJvrNEpV9r/sbxEdeJX59SemXAdXfF42C2aqvpb2OUj3GHS123uKD50xoSLSr7/NnyPj5ROFbkGS/4pdLHNLZPwY= X-Mailman-Original-Authentication-Results: spf=none (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; intel.com; dkim=none (message not signed) header.d=none;intel.com; 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP v2: individually allocate chain array, since chain node is free independently. v3: all existing points must be already signaled before cpu perform signal operation, so add check condition for that. Signed-off-by: Chunming Zhou --- drivers/gpu/drm/drm_internal.h | 2 + drivers/gpu/drm/drm_ioctl.c | 2 + drivers/gpu/drm/drm_syncobj.c | 103 +++++++++++++++++++++++++++++++++ include/uapi/drm/drm.h | 1 + 4 files changed, 108 insertions(+) diff --git a/drivers/gpu/drm/drm_internal.h b/drivers/gpu/drm/drm_internal.h index dd11ae5f1eef..d9a483a5fce0 100644 --- a/drivers/gpu/drm/drm_internal.h +++ b/drivers/gpu/drm/drm_internal.h @@ -190,6 +190,8 @@ int drm_syncobj_reset_ioctl(struct drm_device *dev, void *data, struct drm_file *file_private); int drm_syncobj_signal_ioctl(struct drm_device *dev, void *data, struct drm_file *file_private); +int drm_syncobj_timeline_signal_ioctl(struct drm_device *dev, void *data, + struct drm_file *file_private); int drm_syncobj_query_ioctl(struct drm_device *dev, void *data, struct drm_file *file_private); diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c index 92b3b7b2fd81..d337f161909c 100644 --- a/drivers/gpu/drm/drm_ioctl.c +++ b/drivers/gpu/drm/drm_ioctl.c @@ -696,6 +696,8 @@ static const struct drm_ioctl_desc drm_ioctls[] = { DRM_UNLOCKED|DRM_RENDER_ALLOW), DRM_IOCTL_DEF(DRM_IOCTL_SYNCOBJ_SIGNAL, drm_syncobj_signal_ioctl, DRM_UNLOCKED|DRM_RENDER_ALLOW), + DRM_IOCTL_DEF(DRM_IOCTL_SYNCOBJ_TIMELINE_SIGNAL, drm_syncobj_timeline_signal_ioctl, + DRM_UNLOCKED|DRM_RENDER_ALLOW), DRM_IOCTL_DEF(DRM_IOCTL_SYNCOBJ_QUERY, drm_syncobj_query_ioctl, DRM_UNLOCKED|DRM_RENDER_ALLOW), DRM_IOCTL_DEF(DRM_IOCTL_CRTC_GET_SEQUENCE, drm_crtc_get_sequence_ioctl, DRM_UNLOCKED), diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c index f1d18d10d1f2..78fc1c029339 100644 --- a/drivers/gpu/drm/drm_syncobj.c +++ b/drivers/gpu/drm/drm_syncobj.c @@ -1174,6 +1174,109 @@ drm_syncobj_signal_ioctl(struct drm_device *dev, void *data, return ret; } +int +drm_syncobj_timeline_signal_ioctl(struct drm_device *dev, void *data, + struct drm_file *file_private) +{ + struct drm_syncobj_timeline_array *args = data; + struct drm_syncobj **syncobjs; + struct dma_fence_chain **chains; + uint64_t *points; + uint32_t i, j, timeline_count = 0; + int ret; + + if (!drm_core_check_feature(dev, DRIVER_SYNCOBJ)) + return -EOPNOTSUPP; + + if (args->pad != 0) + return -EINVAL; + + if (args->count_handles == 0) + return -EINVAL; + + ret = drm_syncobj_array_find(file_private, + u64_to_user_ptr(args->handles), + args->count_handles, + &syncobjs); + if (ret < 0) + return ret; + + for (i = 0; i < args->count_handles; i++) { + struct dma_fence_chain *chain; + struct dma_fence *fence; + + fence = drm_syncobj_fence_get(syncobjs[i]); + chain = to_dma_fence_chain(fence); + if (chain) { + struct dma_fence *iter; + + dma_fence_chain_for_each(iter, fence) { + if (!iter) + break; + if (!dma_fence_is_signaled(iter)) { + dma_fence_put(iter); + DRM_ERROR("Client must guarantee all existing timeline points signaled before performing host signal operation!"); + ret = -EPERM; + goto out; + } + } + } + } + + points = kmalloc_array(args->count_handles, sizeof(*points), + GFP_KERNEL); + if (!points) { + ret = -ENOMEM; + goto out; + } + if (!u64_to_user_ptr(args->points)) { + memset(points, 0, args->count_handles * sizeof(uint64_t)); + } else if (copy_from_user(points, u64_to_user_ptr(args->points), + sizeof(uint64_t) * args->count_handles)) { + ret = -EFAULT; + goto err_points; + } + + + for (i = 0; i < args->count_handles; i++) { + if (points[i]) + timeline_count++; + } + chains = kmalloc_array(timeline_count, sizeof(void *), GFP_KERNEL); + if (!chains) { + ret = -ENOMEM; + goto err_points; + } + for (i = 0; i < timeline_count; i++) { + chains[i] = kzalloc(sizeof(struct dma_fence_chain), GFP_KERNEL); + if (!chains[i]) { + for (j = 0; j < i; j++) + kfree(chains[j]); + ret = -ENOMEM; + goto err_chains; + } + } + + for (i = 0, j = 0; i < args->count_handles; i++) { + if (points[i]) { + struct dma_fence *fence = dma_fence_get_stub(); + + drm_syncobj_add_point(syncobjs[i], chains[j++], + fence, points[i]); + dma_fence_put(fence); + } else + drm_syncobj_assign_null_handle(syncobjs[i]); + } +err_chains: + kfree(chains); +err_points: + kfree(points); +out: + drm_syncobj_array_free(syncobjs, args->count_handles); + + return ret; +} + int drm_syncobj_query_ioctl(struct drm_device *dev, void *data, struct drm_file *file_private) { diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h index 4c1e2e6579fa..fe00b74268eb 100644 --- a/include/uapi/drm/drm.h +++ b/include/uapi/drm/drm.h @@ -943,6 +943,7 @@ extern "C" { #define DRM_IOCTL_SYNCOBJ_TIMELINE_WAIT DRM_IOWR(0xCA, struct drm_syncobj_timeline_wait) #define DRM_IOCTL_SYNCOBJ_QUERY DRM_IOWR(0xCB, struct drm_syncobj_timeline_array) #define DRM_IOCTL_SYNCOBJ_TRANSFER DRM_IOWR(0xCC, struct drm_syncobj_transfer) +#define DRM_IOCTL_SYNCOBJ_TIMELINE_SIGNAL DRM_IOWR(0xCD, struct drm_syncobj_timeline_array) /** * Device specific ioctls should only be in their respective headers From patchwork Tue Mar 12 03:10:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunming Zhou X-Patchwork-Id: 10848563 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 BBB7B1850 for ; Tue, 12 Mar 2019 03:12:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A9751291A9 for ; Tue, 12 Mar 2019 03:12:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9DF5B294BF; Tue, 12 Mar 2019 03:12:07 +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=BAD_ENC_HEADER,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 5BDEE291A9 for ; Tue, 12 Mar 2019 03:12:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1787189DBA; Tue, 12 Mar 2019 03:12:06 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM05-BY2-obe.outbound.protection.outlook.com (mail-eopbgr710084.outbound.protection.outlook.com [40.107.71.84]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6DBC889DA9; Tue, 12 Mar 2019 03:12:04 +0000 (UTC) Received: from MWHPR12CA0028.namprd12.prod.outlook.com (2603:10b6:301:2::14) by BLUPR12MB0578.namprd12.prod.outlook.com (2a01:111:e400:594f::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1686.16; Tue, 12 Mar 2019 03:12:02 +0000 Received: from DM3NAM03FT019.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e49::204) by MWHPR12CA0028.outlook.office365.com (2603:10b6:301:2::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1686.16 via Frontend Transport; Tue, 12 Mar 2019 03:12:01 +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 DM3NAM03FT019.mail.protection.outlook.com (10.152.82.197) 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:12:00 +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:59 -0500 From: Chunming Zhou To: , , , , Subject: [PATCH 9/9] drm/amdgpu: update version for timeline syncobj support in amdgpu Date: Tue, 12 Mar 2019 11:10:49 +0800 Message-ID: <20190312031049.23647-9-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)(39860400002)(396003)(136003)(376002)(346002)(2980300002)(428003)(3190300001)(199004)(189003)(6636002)(356004)(8676002)(14444005)(446003)(336012)(2201001)(48376002)(50466002)(16586007)(86362001)(81156014)(7696005)(81166006)(305945005)(4326008)(72206003)(50226002)(186003)(6666004)(126002)(36756003)(68736007)(53936002)(486006)(47776003)(426003)(478600001)(2906002)(53416004)(104016004)(5660300002)(2616005)(11346002)(476003)(97736004)(1076003)(4744005)(8936002)(110136005)(26005)(105586002)(51416003)(76176011)(316002)(77096007)(106466001); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR12MB0578; 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: f5ba367f-1106-44b3-1e24-08d6a6987ea8 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(2017052603328)(7153060); SRVR:BLUPR12MB0578; X-MS-TrafficTypeDiagnostic: BLUPR12MB0578: X-Microsoft-Exchange-Diagnostics: 1; BLUPR12MB0578; 20:B+ekzSyES8dhxgeuC38kxH+O50tdfgrNEKNVZaEirr6uON3Beb9bilwYQdbJnEQKNrEUwvjnizDDNCmgV9QA57hZcGYl9zNz2CEqzxWbLoiIfBdq54GEIvcrGKW5xjmYtv9Vf/o1iL0TOS8t2zuAR+pjFC5Z4bYxcVW/o3voknYzIh3ZMjlvXw9J0PXBDYW0sIPs9w+c/N3NPRM8p5ZRzRMG3Imze4R1ufhh09MNV+L9dPmdzUUNuOTC0/BUr88Zsfc9HKnLcfvvnV5FLpRiwdomTHWN1nbbkQa93mTqh8Tkm/69g08fFhsw/A1ua+owni1xlBY2sJKgWUiBHe+xGq6r08owIhKqpjpB13HZ71PQivtwHnHTFBDiQqECJRnaO1FBvULc3xfwQIOBgOxpLIRxFJvCPSk8BxID2+yATMKJ60enL0101PXPpXQojlrX8wk+NLg7hvM8vqYrvobRQ2kmv3fq262SapjTPvDRLJYJ2NPbNt8LRWFaE6tBFfwT X-Microsoft-Antispam-PRVS: X-Forefront-PRVS: 09749A275C X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BLUPR12MB0578; 23:Ry8u7n/y7Btp4MEnLnovybiodNXOS4EW4C3LHX4ET?= nWeMU64LklYyqbZNF2Tk1OcTD9WkHN3rurkyE7p4WBz9C7/5GJTjAt9rIXvtwEsbm/RtQ1YxZ6iQs4Lu176euSm2YXv61Su1IQ4mXTwCnrLex9iDqQIsiQWOpNZFZuCW0kM7P86VvDtN1uKJ5S1aRYx6Du8QoZHpGSeoD6fc8qAKwcf4EVs5gc0lcbi/E0BbNy1VFnfIEXrh3elqLE0Zg4PF3t7KMzEj6alus4/EQXO29THbJtZC82J0tyuQG4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xCw/LI/4lFDIQUlBZZb8HTi42x9wtATaBDrDg3Y8uqAkq8Z5n5EAthPcjC2oiTLp4+IQEU1DKvRyjYWSkQeeTdw/V1Dkh99SVbdjekJ2XZVQgsVIHv1VyPZyi0TvmXI8dTDotludgQYIbthcds9L5p3NKNeoc0eOutfJQaGoqQHjMeiwnC7jQcd5zJnsIqMkmY3uc7yqkxhhgKt2V2bcUpnqFTxYFeJHk5MuPgX6scPsMpcSiSf8wiHCv/I5WNH4o9bsLFGWh/dbnQPCXHBaDtbMDDNieNBX0uFCEZd2pSglPuflN7BByxn8dA86wxrNW5XRoXqNAUna+4y007579ydsDdvIYJLpMahUSSVCk9mBw= X-Microsoft-Exchange-Diagnostics: 1; BLUPR12MB0578; 20:/OG3HDlXZM/Y8BO7SehsMep2ZKzEdnoQStkFDpu0KdODjNFhZqGPvfH7qLahyQlM4BVRGsWwoYmPDIlQyV4DsEoQ87m+55d4Tb++tISVJCpFVTA3xfJJvXsy3ek2SOQtiUgCa2KeLqnoplJ+4xO88e0fL6w/bHZUxRmPv+XCgFgJtEfHLaA0uEujQOVp+cFGI73sJ8ZNLLZxoRsjJjVggQ1bVNWQyVrayLmKA1LjWmcexKyHE0KtYpa0Rlc5rixW X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Mar 2019 03:12:00.7428 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f5ba367f-1106-44b3-1e24-08d6a6987ea8 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: BLUPR12MB0578 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=4B/Xc1d8Tea67l23EcPrTVq6pS7GWsPgG96Ci7egfBQ=; b=RrPI8eZhfg3pVbjWV6Zd64VorC08yL5dCE0vyCb//6H3XJMoAYQ/793HoqPtLAQNpJUL0cQ+jroeRZLua8ifXjOysixG7KooMh/eVShBsI5ZePCVpA8f4cmgAFsPFvSgAdBY6oXeYfu5GdX5DlURlpawyMsxrlcze4n8pVr36jg= X-Mailman-Original-Authentication-Results: spf=none (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; intel.com; dkim=none (message not signed) header.d=none;intel.com; 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Chunming Zhou --- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c index 8a0732088640..4d8db87048d3 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c @@ -74,9 +74,10 @@ * - 3.28.0 - Add AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES * - 3.29.0 - Add AMDGPU_IB_FLAG_RESET_GDS_MAX_WAVE_ID * - 3.30.0 - Add AMDGPU_SCHED_OP_CONTEXT_PRIORITY_OVERRIDE. + * - 3.31.0 - Add syncobj timeline support to AMDGPU_CS. */ #define KMS_DRIVER_MAJOR 3 -#define KMS_DRIVER_MINOR 30 +#define KMS_DRIVER_MINOR 31 #define KMS_DRIVER_PATCHLEVEL 0 int amdgpu_vram_limit = 0;