From patchwork Tue Jul 23 05:22:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chunming Zhou X-Patchwork-Id: 11053815 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 BDF671398 for ; Tue, 23 Jul 2019 05:23:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 98AD728524 for ; Tue, 23 Jul 2019 05:23:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8819D285A3; Tue, 23 Jul 2019 05:23:16 +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 D4FAC28524 for ; Tue, 23 Jul 2019 05:23:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5F6AC89E5A; Tue, 23 Jul 2019 05:23:13 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-eopbgr740080.outbound.protection.outlook.com [40.107.74.80]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3477789E5A for ; Tue, 23 Jul 2019 05:23:12 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=We74DWcGuWYhUmaAdsXYZS0dOW3zzXbxFNZfSgE5d0awj1/b8AMVCcBhOKAiM/l3H1zxQPfsHwKHZan8PYVmQSpmha/fnub38WtI3TmCzTYkcFGCXinaUqp51CbwvcAAe0uUzF+VtqL1OWML/mC9qedGu9rzyt15GTuOEJ4v7dAYQqvfNktR1mOynyzJuXD+XARrV3+qqRSo1YUeMQOGEfWlynRL1i1s/FM5EmVVRrkM8g2RD5Ok29aYl3hBHbyxhURpaCEMcs+dFp8VVxcGfEGqEWt5jx9HnEMhK/v0ocMIFbo1dXD0Z323beYarwdzjNNVo+rENDAwJE+oVyah8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gAnG0UTXwhrjER3HqeAn72FDG3O9jCzm77QuYtOxYhM=; b=PDpRIXYgVDnkgaDCq3aAWe7UvNa7zXseKWW8AkSn5j80hzIw9Is12wp5snH4rQtjcwTiwCq+b4BsgN7RVARASaa3cgp6Re6awZ21U4spNRoxQpCzmYDacArsr3DmyDh3JWV3DMeTLWFbSHObDtay4iK4taNTGCGCSlVhbZso80MPhYsxBQBl5eTcCtxL3yqqJFr54/WD/tqxtb46MOqP9ywKFLBj/dQdIXAG3OruJBJ4zQqnL0pbQTbt+948zk0MBaaN6EbduozHEQCaCbWS0C97zbA2r7eq1GGaMnxEoMw9NuYvag1YsxpoeSSh7H+kZeo301yf6moXZ+CoYi3NsQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1;spf=none (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com smtp.mailfrom=amd.com;dmarc=permerror action=none header.from=amd.com;dkim=none (message not signed);arc=none Received: from SN1PR12CA0074.namprd12.prod.outlook.com (2603:10b6:802:20::45) by BN6PR12MB1570.namprd12.prod.outlook.com (2603:10b6:405:5::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2094.16; Tue, 23 Jul 2019 05:23:10 +0000 Received: from BY2NAM03FT041.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e4a::204) by SN1PR12CA0074.outlook.office365.com (2603:10b6:802:20::45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2073.14 via Frontend Transport; Tue, 23 Jul 2019 05:23:09 +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 BY2NAM03FT041.mail.protection.outlook.com (10.152.85.246) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2052.18 via Frontend Transport; Tue, 23 Jul 2019 05:23:09 +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; Tue, 23 Jul 2019 00:23:08 -0500 From: Chunming Zhou To: Subject: [PATCH] drm/syncobj: extend syncobj query ability Date: Tue, 23 Jul 2019 13:22:57 +0800 Message-ID: <20190723052257.14436-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)(4636009)(396003)(39860400002)(346002)(136003)(376002)(2980300002)(428003)(189003)(199004)(53936002)(6916009)(2906002)(23676004)(476003)(7696005)(126002)(186003)(5660300002)(26005)(53416004)(2870700001)(305945005)(336012)(2616005)(426003)(68736007)(8676002)(50226002)(5820100001)(6666004)(356004)(36756003)(1076003)(8936002)(81166006)(70206006)(70586007)(47776003)(81156014)(316002)(54906003)(486006)(50466002)(86362001)(4326008)(478600001)(2351001); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR12MB1570; 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: 71b2fd73-0d6d-4d65-a47f-08d70f2dd9bd X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328); SRVR:BN6PR12MB1570; X-MS-TrafficTypeDiagnostic: BN6PR12MB1570: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2276; X-Forefront-PRVS: 0107098B6C X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: zK8qtC4at6QnumBTmso3+cVgntQN5M9wgyB9WS9OqsUEkcMNc+RtGVGld7AcBf8aBv6eRkppX2eoreYYzFz0CCgX/JChUDd89jFx0OmBXgBo54vox4YpRe8sSHlgAOkLdtaEYDjzONnSd1LywO72eAofTCU7n7x0gm2iD3xGXshQy947H+uEEY5UFPLzzehL8tMDhrqldCA3k4FeraLOeeZr133fNIBP5ecj/OkXvU33uglZxuixJPaZpoQ4R7yX8rXBErXTp84kHDOC1/alHZ/dy+9OT8XpA5YZHZeQTQxJPqJ7YddJZ2p1MWqhsOmiYyv+ZSW0Qd1xF+D5zN+zhpdbYnN5mC2uT7+yo4tJVlTB2LzTaMk/SOoMUG4BLH5QEaCoExs5M4OFRS17a11Chdej+cCB2XGDmaFOS3ZB7wo= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jul 2019 05:23:09.5672 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 71b2fd73-0d6d-4d65-a47f-08d70f2dd9bd 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: BN6PR12MB1570 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gAnG0UTXwhrjER3HqeAn72FDG3O9jCzm77QuYtOxYhM=; b=iRslmb0E+/KP3MumW7d4Y2iDvH3BsFpyfxj+2ucVbpTMQ3f7TUrp2VVZ3LsGXBON2NJwLG3Vi6FiXKEDUB53LTiO0qzM5TQKJ3nw7c0xhgaVaEo2a3KK1Z2bhFXfrqsequARxQU9HlL0mD3J3+O168Ayzlx5BUIV7BuCxWkKbDw= 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: , Cc: =?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 space needs a flexiable query ability. So that umd can get last signaled or submitted point. Change-Id: I6512b430524ebabe715e602a2bf5abb0a7e780ea Signed-off-by: Chunming Zhou Cc: Lionel Landwerlin Cc: Christian König --- drivers/gpu/drm/drm_syncobj.c | 36 +++++++++++++++++------------------ include/uapi/drm/drm.h | 3 ++- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c index 3d400905100b..f70dedf3ef4f 100644 --- a/drivers/gpu/drm/drm_syncobj.c +++ b/drivers/gpu/drm/drm_syncobj.c @@ -1197,9 +1197,6 @@ drm_syncobj_timeline_signal_ioctl(struct drm_device *dev, void *data, if (!drm_core_check_feature(dev, DRIVER_SYNCOBJ_TIMELINE)) return -EOPNOTSUPP; - if (args->pad != 0) - return -EINVAL; - if (args->count_handles == 0) return -EINVAL; @@ -1268,9 +1265,6 @@ int drm_syncobj_query_ioctl(struct drm_device *dev, void *data, if (!drm_core_check_feature(dev, DRIVER_SYNCOBJ_TIMELINE)) return -EOPNOTSUPP; - if (args->pad != 0) - return -EINVAL; - if (args->count_handles == 0) return -EINVAL; @@ -1291,23 +1285,29 @@ int drm_syncobj_query_ioctl(struct drm_device *dev, void *data, 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); - if (!to_dma_fence_chain(last_signaled)->prev_seqno) - /* It is most likely that timeline has - * unorder points. */ - break; + if (args->flags & + DRM_SYNCOBJ_QUERY_FLAGS_LAST_SUBMITTED) { + point = fence->seqno; + } else { + dma_fence_chain_for_each(iter, fence) { + if (!iter) + break; + dma_fence_put(last_signaled); + last_signaled = dma_fence_get(iter); + if (!to_dma_fence_chain(last_signaled)->prev_seqno) + /* It is most likely that timeline has + * unorder points. */ + break; + } + point = dma_fence_is_signaled(last_signaled) ? + last_signaled->seqno : + to_dma_fence_chain(last_signaled)->prev_seqno; } - 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; } + dma_fence_put(fence); ret = copy_to_user(&points[i], &point, sizeof(uint64_t)); ret = ret ? -EFAULT : 0; if (ret) diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h index 661d73f9a919..fd987ce24d9f 100644 --- a/include/uapi/drm/drm.h +++ b/include/uapi/drm/drm.h @@ -777,11 +777,12 @@ struct drm_syncobj_array { __u32 pad; }; +#define DRM_SYNCOBJ_QUERY_FLAGS_LAST_SUBMITTED (1 << 0) /* last available point on timeline syncobj */ struct drm_syncobj_timeline_array { __u64 handles; __u64 points; __u32 count_handles; - __u32 pad; + __u32 flags; };