From patchwork Fri Mar 15 12:09:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chunming Zhou X-Patchwork-Id: 10854639 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 CBDD315AC for ; Fri, 15 Mar 2019 12:11:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B3F3628D1F for ; Fri, 15 Mar 2019 12:11:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A83D22A290; Fri, 15 Mar 2019 12:11:01 +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 91C0F28D1F for ; Fri, 15 Mar 2019 12:11:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8F85F6E3E6; Fri, 15 Mar 2019 12:10:59 +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-eopbgr710051.outbound.protection.outlook.com [40.107.71.51]) by gabe.freedesktop.org (Postfix) with ESMTPS id 63F0D6E3E5; Fri, 15 Mar 2019 12:10:57 +0000 (UTC) Received: from DM6PR12CA0005.namprd12.prod.outlook.com (2603:10b6:5:1c0::18) by MN2PR12MB2973.namprd12.prod.outlook.com (2603:10b6:208:cc::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1709.14; Fri, 15 Mar 2019 12:10:55 +0000 Received: from DM3NAM03FT040.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e49::207) by DM6PR12CA0005.outlook.office365.com (2603:10b6:5:1c0::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1686.18 via Frontend Transport; Fri, 15 Mar 2019 12:10:54 +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 DM3NAM03FT040.mail.protection.outlook.com (10.152.83.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1709.13 via Frontend Transport; Fri, 15 Mar 2019 12:10:54 +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; Fri, 15 Mar 2019 07:10:53 -0500 From: Chunming Zhou To: , , , , Subject: [PATCH 5/9] drm/syncobj: use the timeline point in drm_syncobj_find_fence v3 Date: Fri, 15 Mar 2019 20:09:55 +0800 Message-ID: <20190315120959.25489-5-david1.zhou@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190315120959.25489-1-david1.zhou@amd.com> References: <20190315120959.25489-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)(346002)(136003)(39860400002)(396003)(376002)(2980300002)(428003)(189003)(199004)(5660300002)(50466002)(14444005)(316002)(110136005)(106466001)(105586002)(1076003)(54906003)(356004)(66574012)(6636002)(36756003)(50226002)(68736007)(104016004)(53936002)(72206003)(486006)(476003)(478600001)(5820100001)(76176011)(23676004)(7696005)(446003)(426003)(2616005)(11346002)(2906002)(186003)(305945005)(77096007)(86362001)(26005)(2201001)(4326008)(53416004)(47776003)(81166006)(8676002)(8936002)(81156014)(336012)(97736004)(126002)(2870700001); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR12MB2973; H:SATLEXCHOV02.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoDomainNonexistent; MX:1; A:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 850756ff-cbcd-4b84-b24c-08d6a93f464e X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(2017052603328)(7153060); SRVR:MN2PR12MB2973; X-MS-TrafficTypeDiagnostic: MN2PR12MB2973: X-Microsoft-Antispam-PRVS: X-Forefront-PRVS: 09778E995A X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: jf2vT55MBiTyXyjfhrA0sceVgLnOBBm85DlPt9O/XMqRWSYnKSi8jmjZejkF4M7IQNYOmqK7LUHeRcYMhK+aK9x5/ki7KbQr91C+fOUAA1zD5b/gByk7JhZvWu20R6OeMjYq7n+oV1vjR/cNs3DJAM3192bdUqcbWWoApBdhwL+wfkXZY4yhNukfwyH1NXbQFq1YawOl/cxSZrntoIGLAHONPW0LJOjzpZAeXjw1/+7wq28fU/UUMAcLeFDfMkved8kuCDEKKb4AhYvxbUhtW1Z5YzkHhPsyXKmBABNfmH4QLuNZ5cSrJtH8xEPagxQjqul92qGzcooiDhmoMamscoGsi/UdNqdTSGzS3eTlGegmicVXUze5Y3Zfc/sFCEBymmHxjIuUUf+vc4ULsYw0hODflGw5zEWSKvX7r01sE+E= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Mar 2019 12:10:54.4057 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 850756ff-cbcd-4b84-b24c-08d6a93f464e 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: MN2PR12MB2973 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=+iKs2GZ/g+agr5L5hABMicqDiaSu+5BR6lBZ0Hjfs3o=; b=jP7fqxFtisoUuX+6ClWcZ5JwK7BpUUBsj0ffXfNSzC55iPwEpwRFGvlfv2gdyLkrdkWZpck3uXu6NauQ/TB9ulYvPnFUyH0a2Lg7KJUd9EZmgzephAHb3m+kpQTkWnEYasUXFMdMJH5GUplXPfi7E0PAUBzrfAM5TeTBqW7uo9I= 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 v4: add timeout for find fence Signed-off-by: Christian König --- drivers/gpu/drm/drm_syncobj.c | 50 ++++++++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c index 0e62a793c8dd..dd19c47d0b44 100644 --- a/drivers/gpu/drm/drm_syncobj.c +++ b/drivers/gpu/drm/drm_syncobj.c @@ -213,6 +213,8 @@ static void drm_syncobj_assign_null_handle(struct drm_syncobj *syncobj) dma_fence_put(fence); } +/* 5s */ +#define DRM_SYNCOBJ_WAIT_FOR_SUBMIT_TIMEOUT 5000000000 /** * drm_syncobj_find_fence - lookup and reference the fence in a sync object * @file_private: drm file private pointer @@ -233,16 +235,58 @@ 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; + u64 timeout = nsecs_to_jiffies64(DRM_SYNCOBJ_WAIT_FOR_SUBMIT_TIMEOUT); + 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 (timeout == 0) { + ret = -ETIME; + break; + } + + if (signal_pending(current)) { + ret = -ERESTARTSYS; + break; + } + + timeout = schedule_timeout(timeout); + } 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);