From patchwork Mon Mar 25 08:32:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chunming Zhou X-Patchwork-Id: 10868203 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 133671390 for ; Mon, 25 Mar 2019 08:32:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F2ADC29271 for ; Mon, 25 Mar 2019 08:32:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E73C029275; Mon, 25 Mar 2019 08:32:50 +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 8FB7D29271 for ; Mon, 25 Mar 2019 08:32:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5B45B6E68B; Mon, 25 Mar 2019 08:32:49 +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-eopbgr710061.outbound.protection.outlook.com [40.107.71.61]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2B95B6E688; Mon, 25 Mar 2019 08:32:48 +0000 (UTC) Received: from CY4PR12CA0033.namprd12.prod.outlook.com (2603:10b6:903:129::19) 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.1730.17; Mon, 25 Mar 2019 08:32:46 +0000 Received: from CO1NAM03FT019.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e48::207) by CY4PR12CA0033.outlook.office365.com (2603:10b6:903:129::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1730.19 via Frontend Transport; Mon, 25 Mar 2019 08:32:46 +0000 Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXCHOV02.amd.com (165.204.84.17) by CO1NAM03FT019.mail.protection.outlook.com (10.152.80.176) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1750.11 via Frontend Transport; Mon, 25 Mar 2019 08:32:45 +0000 Received: from zhoucm1.amd.com (10.34.1.3) by SATLEXCHOV02.amd.com (10.181.40.72) with Microsoft SMTP Server id 14.3.389.1; Mon, 25 Mar 2019 03:32:44 -0500 From: Chunming Zhou To: , , , , , Subject: [PATCH 2/9] drm/syncobj: add new drm_syncobj_add_point interface v4 Date: Mon, 25 Mar 2019 16:32:17 +0800 Message-ID: <20190325083224.2983-2-david1.zhou@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190325083224.2983-1-david1.zhou@amd.com> References: <20190325083224.2983-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)(39860400002)(376002)(2980300002)(428003)(199004)(189003)(186003)(97736004)(50466002)(2906002)(86362001)(26005)(305945005)(68736007)(5660300002)(66574012)(50226002)(4326008)(8936002)(2870700001)(1076003)(76176011)(77096007)(356004)(5820100001)(7696005)(81166006)(81156014)(23676004)(8676002)(6666004)(106466001)(316002)(2201001)(53936002)(14444005)(54906003)(426003)(336012)(36756003)(6636002)(110136005)(478600001)(2616005)(446003)(126002)(47776003)(11346002)(486006)(53416004)(72206003)(104016004)(105586002)(476003); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR12MB0582; H:SATLEXCHOV02.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoDomainNonexistent; A:1; MX:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2ca34353-4b04-4ad9-f6df-08d6b0fc7512 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(2017052603328)(7153060); SRVR:BY2PR12MB0582; X-MS-TrafficTypeDiagnostic: BY2PR12MB0582: X-Microsoft-Antispam-PRVS: X-Forefront-PRVS: 0987ACA2E2 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: pzeGww7PRfoW8Fkbzxb/mqs03/2pB1g6oK91BSMKHSaf6F6d5jkBfyjQEj5q74fv6XJz97Ardz79xDtjAH3hZUPPuFdasROLxiPbhKzcDsQnbPec/ENkM28vwb832gArUx3PvxKPmioA7gD4ji2BqnfArZkIXJLpnmXwBwRZRPf0R6NA4+wGNqDG32GrZ7s47y8oGcvR9zSfhBuc9p0Tk+Qi/J2uz9GBVKBHYAdU9R5crOGYG+CUMPOjVMhFwgiK8GljpWz0ZMlVNiBw8Kx7x/5Ec9aKAZslBghFvnQSTjjjKRSjKw6rTQHgmz9Joh/oWqdnsoVQLRzYX0/BClrFCtULeWITxQch57froT+rbaiHwxaODyn14bZFwVwAVQnL7kX0rLzrRQ0Czl7cfIgHcJB5MWRa+r/7WZ6Mcf/Z3UA= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Mar 2019 08:32:45.9816 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2ca34353-4b04-4ad9-f6df-08d6b0fc7512 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=[SATLEXCHOV02.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=xl8nzfoU/edPpwU6fIwWq0jI12+5/bExv+mZ0XfBQBI=; b=juxiAvsICAGu6pv3XAo8TpFwJr7V4RSxRlZjqSbNRIN1rR+LRAlaafwFkLVWAWpcWWQNaiR76URj1vyR+lY3RwG3wBkQuSEGbeRRZZa8TfeGKsu30CfSuDkFo/mLVc7TkC05w+IHDVZ4fW7D5H/CAgeMv56PcTxOtVXAsGg6uN0= 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 v4: add unorder point check, print a warn calltrace Signed-off-by: Christian König Cc: Lionel Landwerlin Reviewed-by: Lionel Landwerlin --- drivers/gpu/drm/drm_syncobj.c | 39 +++++++++++++++++++++++++++++++++++ include/drm/drm_syncobj.h | 5 +++++ 2 files changed, 44 insertions(+) diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c index 5329e66598c6..19a9ce638119 100644 --- a/drivers/gpu/drm/drm_syncobj.c +++ b/drivers/gpu/drm/drm_syncobj.c @@ -122,6 +122,45 @@ 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); + /* You are adding an unorder point to timeline, which could cause payload returned from query_ioctl is 0! */ + WARN_ON_ONCE(prev && prev->seqno >= point); + 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,