From patchwork Tue Jul 23 14:21:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chunming Zhou X-Patchwork-Id: 11054579 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 7A2AE1398 for ; Tue, 23 Jul 2019 14:21:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 69FAC26E73 for ; Tue, 23 Jul 2019 14:21:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5E8C426E96; Tue, 23 Jul 2019 14:21:39 +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 EB13426E82 for ; Tue, 23 Jul 2019 14:21:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E6B196E2CE; Tue, 23 Jul 2019 14:21:37 +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-eopbgr710068.outbound.protection.outlook.com [40.107.71.68]) by gabe.freedesktop.org (Postfix) with ESMTPS id 86FB56E2CD for ; Tue, 23 Jul 2019 14:21:36 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Q16WbEqO6TsOPBjYJRwuUXXJuF7DftmlLaJ0MMmjv/WtLa+mqKxLGC6TypPVSXm1P3IQYFKclrDnPE6XP7Mf8YQxShmuS50i2JbCP1SujkjzAxry3P+/xOpICNu9NuhiH2+TBylvAQfFvUOlCLY6pmS6wFhXhiHhHxFcyYQ/34I8GmSKfJMgoZp1Ygybt6d+FHfmKDyUpzaMEH0uYCWDUJp/VusR9+B3nVFpoSD9wYvuXLnf9mQJl0LcdOjnQOqBLnsxrYta2oWcUgBQgRxwvDdYiAg/WSEjx3HW2cwE9eePmv/moulJ6qxjrcxNZ5N/0Is2AtIc0ZGIqDnZzXowQQ== 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=AyuZghyspznZMgndpg5zE/QPFH76jvYL//D2oihAbJg=; b=hZyfMb2egIT8BDDVGn0qk7HnlfN8Dc8tOCcfYfT84V38X5sZG5yPcYjKReJbMOn//K4oJjFxE1EYqorZKlGxTxlIog5eHoM/A4YypfunaSifhJVEKHsmU/rWPbPglXmEJ27uGRYni4I96ZRoksWXpYsEOwk9KyfEvF1udE25HFwDnTdOYIebcyfTVN8oTvMeg3kLwjaSTsXlSkakVN5WdolgwKZg74KRvNh6Z2QZE3kuaZV1I+t5pE38HN+dfo0X0kIJjw5otZzFXE5oSlyUw78ksi+aUBU3fs7lQo0nccoc45ZJdTvpmp43j10OA6p3NcDoroFFoQOwsD16DMfmdw== 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 BN8PR12CA0012.namprd12.prod.outlook.com (2603:10b6:408:60::25) by MWHPR12MB1310.namprd12.prod.outlook.com (2603:10b6:300:a::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2094.17; Tue, 23 Jul 2019 14:21:34 +0000 Received: from BY2NAM03FT003.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e4a::203) by BN8PR12CA0012.outlook.office365.com (2603:10b6:408:60::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2094.16 via Frontend Transport; Tue, 23 Jul 2019 14:21:33 +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 BY2NAM03FT003.mail.protection.outlook.com (10.152.84.105) 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 14:21:33 +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, 23 Jul 2019 09:21:21 -0500 From: Chunming Zhou To: Subject: [PATCH] drm/syncobj: extend syncobj query ability v2 Date: Tue, 23 Jul 2019 22:21:14 +0800 Message-ID: <20190723142114.24688-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)(39860400002)(346002)(396003)(376002)(136003)(2980300002)(428003)(199004)(189003)(305945005)(50466002)(36756003)(426003)(54906003)(8936002)(126002)(47776003)(81156014)(81166006)(86362001)(336012)(476003)(50226002)(2616005)(478600001)(68736007)(26005)(8676002)(316002)(53416004)(5820100001)(186003)(2906002)(6666004)(356004)(5660300002)(1076003)(70206006)(4326008)(6916009)(70586007)(2870700001)(7696005)(486006)(53936002)(2351001)(23676004); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR12MB1310; 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: c5dc614a-3b72-487a-fc28-08d70f79103d X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328); SRVR:MWHPR12MB1310; X-MS-TrafficTypeDiagnostic: MWHPR12MB1310: 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: MTSqgwdQMOje6xHwmnDSNUHMZrp2FRY91r8uydBVvZzClxy8Oxjm2Tk+DU4WhvcLFOmkYyAEq8WlDL17kq9dxtMexlW2lF+Pj6Oao7qdvNz8SELxfAlqGTTXAWKVtfZxCWpgPrkgWi9viMJo872ysP53X0Emt/o5ntMr+YJ3XAgboRsR+tV96b+Q+xjL8iu0TYkQ8Tlye1vdpLiZDVTOTbnwa2/Qwgsaf/h8872U7Nb7ccffDvL1w3iBAS1zgK5AqmHfpEREg6UHjClAEfaW2wd41zZ0r2dRobaOSTx4SeJhcCmkSmszSyiSH9/kxVnLyDRul2iayzNZ+LJptLNy+VK5hEw00lSajljCaRZ1QSV6WOopipHYLWh8jMJAjXQx5Y9UD1pvFzA+cOdtyLM7noZCtWYtQ/ylotU9Hy162C4= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jul 2019 14:21:33.2740 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c5dc614a-3b72-487a-fc28-08d70f79103d 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: MWHPR12MB1310 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=AyuZghyspznZMgndpg5zE/QPFH76jvYL//D2oihAbJg=; b=WQjAe3uDHOKBtrSiWRX7LsWsOlZ9h3Ot/gaEGua/N2RTJPAmbC48MJfXhIkX+895fkZYdOxvu8JKxVMgeBJDJ3+jlKNGBi96sE9t/7cX/u6br0i01406FwqzuYuuoO8XIoOsArTYORqxDcdfgoBhqGt0XTfyFaXzGNc8luqYR2k= 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. Change-Id: I6512b430524ebabe715e602a2bf5abb0a7e780ea Signed-off-by: Chunming Zhou Cc: Lionel Landwerlin Cc: Christian König Reviewed-by: Lionel Landwerlin --- drivers/gpu/drm/drm_syncobj.c | 34 ++++++++++++++++++++-------------- include/uapi/drm/drm.h | 3 ++- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c index 3d400905100b..3fc8f66ada68 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) @@ -1291,23 +1291,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; };