From patchwork Tue Jul 30 13:02:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chunming Zhou X-Patchwork-Id: 11065755 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 7A4E3112C for ; Tue, 30 Jul 2019 13:02:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 69F6928706 for ; Tue, 30 Jul 2019 13:02:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C7A52870F; Tue, 30 Jul 2019 13:02:27 +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 C96B928706 for ; Tue, 30 Jul 2019 13:02:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D34C76E4EA; Tue, 30 Jul 2019 13:02:25 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-eopbgr780059.outbound.protection.outlook.com [40.107.78.59]) by gabe.freedesktop.org (Postfix) with ESMTPS id 424066E4EA for ; Tue, 30 Jul 2019 13:02:24 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BN2u16R2K9XLUKXnBtR32zvcvzBHeN4QleLKFcTM2ejNz+d5pIsl+5Ht0WkUqpLbcF55nxXrNHObnX9vhlQFG7x/frEerebFiO3C1u2VO2P5mKeWCIoB83I4YGCmLk91EOV24ExlpHkLpEghvfrqm90bqe5sg+Unp6zP77Q7uA7Ruki12v12DbBwzgxqut2DiT9bNY69+LA5xeC+dA9Do0T1EsF6xPtWr8e8HGxaXEfo0JY6lr7bUaJsqEx+0u0RGX21vfsylKS+vylbJ2024OXnWc1RDhlkV+oDQ0yHoZ3/WyIE/zF2un6oH8FrWfxPQphCN29lOFsOff/KqjBbKQ== 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=dpywGKowgivwb6ETA5xOSFCM/0J4jChtjexrdb5gBHo=; b=UA17gvz1OAxFW4O9FaiMOuUfIYuNGNO8bKh8pU3iss8rET86Zow3qhoFDJT5367n5W8D109QcTrci+obM5/Rp0p6+U8F0ITGcO+0VjkeqT3trTWgjCVvehBtzCD1FDsOXx/sf3QffCXDMYzhHbDDQhJ2Gl+ZtGdpCxwUdADxOUi5BcX3kOEhjkvucqOQGdHwn3T4IpBD1wskTuP8RVQJkxlSQ89cQJ1BFTdZ912oAX+nBH1jIfG01YZuIzrqyWlZ1vAQfTbe3tSpy3zJmSuLJnuXFP9FiOvBWL6VAg4n4gWfHgx065AFIWecGq7iLWkki3t88rUhQGCn/CIpEg+Cow== 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 DM6PR12CA0032.namprd12.prod.outlook.com (2603:10b6:5:1c0::45) by MW2PR12MB2538.namprd12.prod.outlook.com (2603:10b6:907:9::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2115.15; Tue, 30 Jul 2019 13:02:21 +0000 Received: from CO1NAM03FT006.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e48::203) by DM6PR12CA0032.outlook.office365.com (2603:10b6:5:1c0::45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2115.15 via Frontend Transport; Tue, 30 Jul 2019 13:02:21 +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 CO1NAM03FT006.mail.protection.outlook.com (10.152.80.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2115.10 via Frontend Transport; Tue, 30 Jul 2019 13:02:21 +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; Tue, 30 Jul 2019 08:02:14 -0500 From: Chunming Zhou To: Subject: [PATCH] drm/syncobj: extend syncobj query ability v3 Date: Tue, 30 Jul 2019 21:02:08 +0800 Message-ID: <20190730130208.30977-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)(136003)(376002)(39860400002)(346002)(396003)(2980300002)(428003)(189003)(199004)(186003)(54906003)(86362001)(5660300002)(426003)(2351001)(50466002)(1076003)(6666004)(356004)(23676004)(2906002)(53936002)(336012)(26005)(2870700001)(316002)(7696005)(305945005)(50226002)(8936002)(81166006)(8676002)(81156014)(70206006)(70586007)(68736007)(47776003)(6916009)(486006)(2616005)(126002)(476003)(36756003)(5820100001)(53416004)(478600001)(4326008); DIR:OUT; SFP:1101; SCL:1; SRVR:MW2PR12MB2538; 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: 32af8f98-3803-444b-2cf0-08d714ee28cb X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328); SRVR:MW2PR12MB2538; X-MS-TrafficTypeDiagnostic: MW2PR12MB2538: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2276; X-Forefront-PRVS: 0114FF88F6 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: /iDrcj7PFRBpRIxsfdq1rkDaA9tVE9u0gapgvue1xY2R61lE89HGr/HsMsoOCKathYqtCU6lADmVpFBGCkYHibCR1x2XEIcrjUWM7gAp/zFz+FoR5eDblgQA4dUjWI7ey2m5oXjEH/98YNXQzlQeCeA4PIynq63P4f8btDViRXMb2BWlAWoa7UmM93z5EJfszqob2a1gjUMvLYdbVzX1TOEi5gSXvNacQChm2kfSuu9ZcZiM+xdmz9uOjZ36APov7L5vMsXJ5GdKrQCBDSxkgOyROcIE3yoYdNljzoGlFif9nLF1XLEHsHzsGhjrioipjyKuvIFTy1OAcodv67vI0U3jWu6HcypxXL+1UjTYyYgP4qSkr79Z5yjgzEZp9VzOzBtFA+e+ZRdLodb1RC4Yn9APH4BH7q12BRfLMPHq3OI= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jul 2019 13:02:21.2498 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 32af8f98-3803-444b-2cf0-08d714ee28cb 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: MW2PR12MB2538 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=dpywGKowgivwb6ETA5xOSFCM/0J4jChtjexrdb5gBHo=; b=mKD1/hDkAC7vqRDO/gNbETluyavO8IGASd8LI4WMrHMl5n9nwqQaeDvuUCrc8/zpnYXY4hTd1OXo1gKSMiB62KumDUsjelGNQR7R6uihMiTOSs9tGyMTgL+ye5fJZjossRN28qowCxv4RE1Tx5ZKlTTFg76Gf3tZ1S0Mx+CM3gE= 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. v2: add sanitizer checking. v3: rebase Change-Id: I6512b430524ebabe715e602a2bf5abb0a7e780ea Signed-off-by: Chunming Zhou Cc: Lionel Landwerlin Cc: Christian König Reviewed-by: Lionel Landwerlin Reviewed-by: Christian König --- drivers/gpu/drm/drm_syncobj.c | 37 +++++++++++++++++++++-------------- include/uapi/drm/drm.h | 3 ++- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c index cecff2e447b1..d4432f1513ac 100644 --- a/drivers/gpu/drm/drm_syncobj.c +++ b/drivers/gpu/drm/drm_syncobj.c @@ -1197,7 +1197,7 @@ 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) + if (args->flags != 0) return -EINVAL; if (args->count_handles == 0) @@ -1268,7 +1268,7 @@ 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) + if (args->flags & ~DRM_SYNCOBJ_QUERY_FLAGS_LAST_SUBMITTED) return -EINVAL; if (args->count_handles == 0) @@ -1289,25 +1289,32 @@ int drm_syncobj_query_ioctl(struct drm_device *dev, void *data, 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->context != fence->context) { - dma_fence_put(iter); - /* It is most likely that timeline has - * unorder points. */ - break; + struct dma_fence *iter, *last_signaled = + dma_fence_get(fence); + + if (args->flags & + DRM_SYNCOBJ_QUERY_FLAGS_LAST_SUBMITTED) { + point = fence->seqno; + } else { + dma_fence_chain_for_each(iter, fence) { + if (iter->context != fence->context) { + dma_fence_put(iter); + /* It is most likely that timeline has + * unorder points. */ + break; + } + dma_fence_put(last_signaled); + last_signaled = dma_fence_get(iter); } - 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; } - 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; };