From patchwork Tue Mar 12 03:10:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chunming Zhou X-Patchwork-Id: 10848553 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 74C401850 for ; Tue, 12 Mar 2019 03:11:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 60D6B294BB for ; Tue, 12 Mar 2019 03:11:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 53C27294BE; Tue, 12 Mar 2019 03:11:40 +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 CCF1F294BB for ; Tue, 12 Mar 2019 03:11:39 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 741E089D89; Tue, 12 Mar 2019 03:11:38 +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-eopbgr710079.outbound.protection.outlook.com [40.107.71.79]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0439189D57; Tue, 12 Mar 2019 03:11:36 +0000 (UTC) Received: from MN2PR12CA0033.namprd12.prod.outlook.com (2603:10b6:208:a8::46) by BN8PR12MB2964.namprd12.prod.outlook.com (2603:10b6:408:61::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1686.21; Tue, 12 Mar 2019 03:11:33 +0000 Received: from DM3NAM03FT042.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e49::203) by MN2PR12CA0033.outlook.office365.com (2603:10b6:208:a8::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1686.20 via Frontend Transport; Tue, 12 Mar 2019 03:11:33 +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 DM3NAM03FT042.mail.protection.outlook.com (10.152.83.174) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1686.19 via Frontend Transport; Tue, 12 Mar 2019 03:11:32 +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; Mon, 11 Mar 2019 22:11:31 -0500 From: Chunming Zhou To: , , , , Subject: [PATCH 4/9] drm/syncobj: add timeline payload query ioctl v5 Date: Tue, 12 Mar 2019 11:10:44 +0800 Message-ID: <20190312031049.23647-4-david1.zhou@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190312031049.23647-1-david1.zhou@amd.com> References: <20190312031049.23647-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)(376002)(39860400002)(396003)(346002)(2980300002)(428003)(189003)(199004)(54906003)(11346002)(97736004)(23676004)(104016004)(316002)(110136005)(2201001)(14444005)(86362001)(478600001)(50466002)(336012)(2616005)(36756003)(72206003)(486006)(446003)(6666004)(356004)(126002)(476003)(76176011)(1076003)(5660300002)(7696005)(66574012)(53936002)(6636002)(8676002)(305945005)(186003)(81166006)(8936002)(106466001)(77096007)(26005)(2870700001)(5820100001)(68736007)(2906002)(81156014)(426003)(105586002)(47776003)(4326008)(50226002)(53416004); DIR:OUT; SFP:1101; SCL:1; SRVR:BN8PR12MB2964; 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: 4ee78eb0-2594-46b5-94ad-08d6a6986df2 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(2017052603328)(7153060); SRVR:BN8PR12MB2964; X-MS-TrafficTypeDiagnostic: BN8PR12MB2964: X-Microsoft-Exchange-Diagnostics: 1; BN8PR12MB2964; 20:KPir5TgMWwAmIus6EJ9O4AgH6GVDd3cJpiyt2N6vl04nHz6tBY4NPVMUTP68wQfL5WiltCNiFFNLnfaIsVj3sf8VLDvaTVV2FKHJ3ZRfZi11G/XzieBjqyUCbEf+UwPsjRCEa+5YegF/M2bS23faOfJxWKSGJep0LS7l1hQSw8DbMxM4XufTXHLdGvb9ZKZNG1VOzPAzhiguNi7rl0GnSHRCLaJC6QRuQDrthPG+7EiiMDtDlM4gK68BNa5qSo3gS9O2S/2VBC9sqlJu8gOwUxjuRZQ48dg4LSqx/RvdXbuSfHoFxzfVrbs6fGYl0HMI6ah6mILza6+qFezXVqzdR8BOLl3vB3BGeAw2dFhMVFUNhg8J5eDEyt9QVTnigweWsE2MGq+XKnNV07+8RyQEiVIDBihGtDro3N2ezYuXnCtGvcdyBGL/1sfy55397CfVrzr0P4eJrvNg1fA/y8J3mL/7piqkAsxdWG/T6qQrAWLUvDn4Za+H87DfnX8cSjCz X-Microsoft-Antispam-PRVS: X-Forefront-PRVS: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32AZgKE89EVNP+mVxZt0RZpWzob05nqnQU32+apUjePBMYePOHWwSijRxUw3AA?= =?utf-8?q?R6DvkDqn80f9ZUeAsT+4rjjF/DJlmUcmoyxp5UQjPQL0wj66xsSmrObLIjyM/jWye?= =?utf-8?q?CIz6TSrueQkKN56vUeV0zO5SsuKQRmxMh8fwE1osWtR41G3aise6x5R9JnCpMJGGT?= =?utf-8?q?6gHPo+DngTRPWrfYFs+HpjgHALVq/nSoFyE9+JIveknIENMzLWNQNFWMttMD6L4tr?= =?utf-8?q?/7t2pqy24c2Psr2uQqtQOY+wZ/ceHD4xv/wUxfnKPhbQnQd9XSpsP68ORe5OSwD/L?= =?utf-8?q?gLQdcz8tikqYDJM61Mp0Fi8pebYvAIO448llQFYR1plU6GdgMoINaO2eBzANFcj7W?= =?utf-8?q?UrB0pyNjm5RSBUoMBqqo7xLciS6qmoC0STva1+?= X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: Fo9OHdM3orIRYk+9URjPwv2WKG/fGzkqpio91XnmDF+1uc82T88ybUV8amzXpZHNRny/q1iYVJGqPBUD81Vr//cnjve6eGBuwuZPtTLsQeca2s/RFknSVvcRzxlO4gvtbZsyQOxBk8UBSmA6W9Cn4+EeJNM8YO7jXnBlXRxD0jMZQmoHTkQCydkbWOALFE//kL/8hNSyJZZ0rj2Y99TDDSIH5IwHFgso6/n6WvPc/R+ARDUCITIrfF3xd+40KU4BEUU/+iDz+2faFSxy2+/n4zG8fF18mEkpaCTJoirYqQwg0GPfqXpTaKiUz/PWMoXSrgxsNn2PoeQAWYLffeKKT8VYgE1KdnzO81sMrNDnnWbm1vyy3g36ns9rAF8bSyQQHPgv93IcxyrH46laz7z4GkUbHRngTmyyzjg++GGkVWg= X-Microsoft-Exchange-Diagnostics: 1; BN8PR12MB2964; 20:gYmHg3IciZnVl5zVvGwUWUTiGvrwTIvysgSIwvEVO/bKMyOubQgtycmWo/gAoPZ2qGA6DMRHEyPahIMs7JRfxRSkQtITH63IRvb4Ad+n7O4SbYijFpQ9euJU2I5Ub/vtLWPDV4D8YO1s1ii5uLgBExWBtvmckhuzjk+W3yxYvF7R3eGZVTfoNUlwF7k3zqsVTr2JIvV3x2h3zMhvpSj7GjAY+hOvWOTXe9UTPooeP9+tj/16OQImTK4n8oJRF5sz X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Mar 2019 03:11:32.5712 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4ee78eb0-2594-46b5-94ad-08d6a6986df2 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: BN8PR12MB2964 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=qwW+7phx1SsRjwINF+Y2URE9axwYRpS/k7NZQJbrg6I=; b=ySUyyvNOTyQf3HBPEZCCJXZeJ1OPf3mpnSTGS8AsPprjTGvY1uwQ5rkVd+FxZz8bpzfIhNEhZXIRYEq4hxgo7h2Dt6HV0/vdyXUxjtopPLEd1HnF1xjmua8Y3FmDjq2mIJTXu/kv9NM24fHIReDIaaPa/NSBgEwwEulPIVE4fIA= X-Mailman-Original-Authentication-Results: spf=none (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; basnieuwenhuizen.nl; dkim=none (message not signed) header.d=none;basnieuwenhuizen.nl; 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: Daniel Rakos , Dave Airlie , =?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 mode can query timeline payload. v2: check return value of copy_to_user v3: handle querying entry by entry v4: rebase on new chain container, simplify interface v5: query last signaled timeline point, not last point. Signed-off-by: Chunming Zhou Cc: Daniel Rakos Cc: Jason Ekstrand Cc: Bas Nieuwenhuizen Cc: Dave Airlie Cc: Christian König Cc: Chris Wilson --- drivers/gpu/drm/drm_internal.h | 2 ++ drivers/gpu/drm/drm_ioctl.c | 2 ++ drivers/gpu/drm/drm_syncobj.c | 58 ++++++++++++++++++++++++++++++++++ include/uapi/drm/drm.h | 10 ++++++ 4 files changed, 72 insertions(+) diff --git a/drivers/gpu/drm/drm_internal.h b/drivers/gpu/drm/drm_internal.h index 331ac6225b58..695179bb88dc 100644 --- a/drivers/gpu/drm/drm_internal.h +++ b/drivers/gpu/drm/drm_internal.h @@ -188,6 +188,8 @@ int drm_syncobj_reset_ioctl(struct drm_device *dev, void *data, struct drm_file *file_private); int drm_syncobj_signal_ioctl(struct drm_device *dev, void *data, struct drm_file *file_private); +int drm_syncobj_query_ioctl(struct drm_device *dev, void *data, + struct drm_file *file_private); /* drm_framebuffer.c */ void drm_framebuffer_print_info(struct drm_printer *p, unsigned int indent, diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c index c984654646fa..7a534c184e52 100644 --- a/drivers/gpu/drm/drm_ioctl.c +++ b/drivers/gpu/drm/drm_ioctl.c @@ -694,6 +694,8 @@ static const struct drm_ioctl_desc drm_ioctls[] = { DRM_UNLOCKED|DRM_RENDER_ALLOW), DRM_IOCTL_DEF(DRM_IOCTL_SYNCOBJ_SIGNAL, drm_syncobj_signal_ioctl, DRM_UNLOCKED|DRM_RENDER_ALLOW), + DRM_IOCTL_DEF(DRM_IOCTL_SYNCOBJ_QUERY, drm_syncobj_query_ioctl, + DRM_UNLOCKED|DRM_RENDER_ALLOW), DRM_IOCTL_DEF(DRM_IOCTL_CRTC_GET_SEQUENCE, drm_crtc_get_sequence_ioctl, DRM_UNLOCKED), DRM_IOCTL_DEF(DRM_IOCTL_CRTC_QUEUE_SEQUENCE, drm_crtc_queue_sequence_ioctl, DRM_UNLOCKED), DRM_IOCTL_DEF(DRM_IOCTL_MODE_CREATE_LEASE, drm_mode_create_lease_ioctl, DRM_MASTER|DRM_UNLOCKED), diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c index 25eb2176d8c7..a5adc7c06caa 100644 --- a/drivers/gpu/drm/drm_syncobj.c +++ b/drivers/gpu/drm/drm_syncobj.c @@ -1062,3 +1062,61 @@ drm_syncobj_signal_ioctl(struct drm_device *dev, void *data, return ret; } + +int drm_syncobj_query_ioctl(struct drm_device *dev, void *data, + struct drm_file *file_private) +{ + struct drm_syncobj_timeline_array *args = data; + struct drm_syncobj **syncobjs; + uint64_t __user *points = u64_to_user_ptr(args->points); + uint32_t i; + int ret; + + if (!drm_core_check_feature(dev, DRIVER_SYNCOBJ)) + return -ENODEV; + + if (args->pad != 0) + return -EINVAL; + + if (args->count_handles == 0) + return -EINVAL; + + ret = drm_syncobj_array_find(file_private, + u64_to_user_ptr(args->handles), + args->count_handles, + &syncobjs); + if (ret < 0) + return ret; + + for (i = 0; i < args->count_handles; i++) { + struct dma_fence_chain *chain; + struct dma_fence *fence; + uint64_t point; + + 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) + break; + 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; + dma_fence_put(last_signaled); + } else { + point = 0; + } + ret = copy_to_user(&points[i], &point, sizeof(uint64_t)); + ret = ret ? -EFAULT : 0; + if (ret) + break; + } + drm_syncobj_array_free(syncobjs, args->count_handles); + + return ret; +} diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h index 0092111d002c..b2c36f2b2599 100644 --- a/include/uapi/drm/drm.h +++ b/include/uapi/drm/drm.h @@ -767,6 +767,14 @@ struct drm_syncobj_array { __u32 pad; }; +struct drm_syncobj_timeline_array { + __u64 handles; + __u64 points; + __u32 count_handles; + __u32 pad; +}; + + /* Query current scanout sequence number */ struct drm_crtc_get_sequence { __u32 crtc_id; /* requested crtc_id */ @@ -924,6 +932,8 @@ extern "C" { #define DRM_IOCTL_MODE_REVOKE_LEASE DRM_IOWR(0xC9, struct drm_mode_revoke_lease) #define DRM_IOCTL_SYNCOBJ_TIMELINE_WAIT DRM_IOWR(0xCA, struct drm_syncobj_timeline_wait) +#define DRM_IOCTL_SYNCOBJ_QUERY DRM_IOWR(0xCB, struct drm_syncobj_timeline_array) + /** * Device specific ioctls should only be in their respective headers * The device specific ioctl range is from 0x40 to 0x9f.