From patchwork Wed Mar 20 05:47: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: 10860853 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 883E21708 for ; Wed, 20 Mar 2019 05:47:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6A744285E8 for ; Wed, 20 Mar 2019 05:47:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5EDFA28AA8; Wed, 20 Mar 2019 05:47:52 +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 069DC288AE for ; Wed, 20 Mar 2019 05:47:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 14D4F89C03; Wed, 20 Mar 2019 05:47:50 +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-eopbgr810075.outbound.protection.outlook.com [40.107.81.75]) by gabe.freedesktop.org (Postfix) with ESMTPS id BC5AC89BFC; Wed, 20 Mar 2019 05:47:48 +0000 (UTC) Received: from DM3PR12CA0052.namprd12.prod.outlook.com (2603:10b6:0:56::20) by DM6PR12MB2970.namprd12.prod.outlook.com (2603:10b6:5:115::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1709.15; Wed, 20 Mar 2019 05:47:47 +0000 Received: from BY2NAM03FT055.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e4a::201) by DM3PR12CA0052.outlook.office365.com (2603:10b6:0:56::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1709.13 via Frontend Transport; Wed, 20 Mar 2019 05:47: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 BY2NAM03FT055.mail.protection.outlook.com (10.152.85.245) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1730.9 via Frontend Transport; Wed, 20 Mar 2019 05:47:46 +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; Wed, 20 Mar 2019 00:47:44 -0500 From: Chunming Zhou To: , , , , , Subject: [PATCH 2/9] drm/syncobj: add new drm_syncobj_add_point interface v4 Date: Wed, 20 Mar 2019 13:47:17 +0800 Message-ID: <20190320054724.14636-2-david1.zhou@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190320054724.14636-1-david1.zhou@amd.com> References: <20190320054724.14636-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)(396003)(376002)(346002)(2980300002)(428003)(199004)(189003)(14444005)(486006)(5660300002)(5820100001)(26005)(1076003)(81166006)(6666004)(47776003)(305945005)(77096007)(316002)(356004)(66574012)(4326008)(7696005)(8676002)(81156014)(50226002)(110136005)(23676004)(54906003)(6636002)(8936002)(97736004)(68736007)(53936002)(2906002)(53416004)(36756003)(476003)(2616005)(76176011)(106466001)(478600001)(11346002)(72206003)(2201001)(86362001)(105586002)(336012)(426003)(50466002)(2870700001)(104016004)(126002)(186003)(446003); DIR:OUT; SFP:1101; SCL:1; SRVR:DM6PR12MB2970; 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: 1b3cfd12-bd57-42a2-f7f4-08d6acf79479 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600127)(711020)(4605104)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060); SRVR:DM6PR12MB2970; X-MS-TrafficTypeDiagnostic: DM6PR12MB2970: X-Microsoft-Antispam-PRVS: X-Forefront-PRVS: 098291215C X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: kY6cvy5ZxxqVn2aHzqj+ki4spwv70dfnWuRie5e6VxM2z1SdNER9rtQk/Q70vyVf6TnSFj4Lr/OSAbTNhU5syZhuVK4gS1ees7QnbPOIWmTdgmINkOV3unDRi3reSMRCB4dtq7BKpwcYZ6Ve4RsgaqPlFnp5Z6j8xe8oSC4J/lqkqYLTa6v+jF9kqXk77erIvZLZyy2LCV+U0UCR49wGoNiQylDbLqVFA9Xm39bL21nmnWfDiRN8aLyuVRco/PvgoJUYCDCOlIMwOWBdnbaoXk4YN2I9cvi8uTOIAVmPBXGG9IBmPXYj1H9xKNrnSoo2kXzG4sK6JKoojalZQfq/uaUETnn+xarAFhWgpevqaxMWJW8ZbKB9fPlEV74EC/XzQJ1Z4/ZspiM9KCV7y0D5rlXgKoTFA03TkB6d7kvhsqM= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Mar 2019 05:47:46.2300 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1b3cfd12-bd57-42a2-f7f4-08d6acf79479 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: DM6PR12MB2970 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=Lwk7r1yIRfFlADLLaWXlQftvTO8yTpphMiaZa2JMkiDC0IlmA/M2NkqHkmwYcMJ9gsT2RpIIC6hgGUppKkz4H4JXPZdF3Sh1Q1Ma0AfVtoHnZ5qltek+TvXbCn+jXsY+2UR0lmZOtMpvyMioXq1xbyFVRWxK4c3+7bdhL2Auo5Y= 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 --- 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,