From patchwork Fri Oct 27 00:15:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 10028903 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2C87E6022E for ; Fri, 27 Oct 2017 00:16:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1CEBA2684F for ; Fri, 27 Oct 2017 00:16:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 10EBE28EE5; Fri, 27 Oct 2017 00:16:18 +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=-4.1 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID 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 08F282684F for ; Fri, 27 Oct 2017 00:16:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BF5896E86E; Fri, 27 Oct 2017 00:16:14 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM03-DM3-obe.outbound.protection.outlook.com (mail-dm3nam03on0056.outbound.protection.outlook.com [104.47.41.56]) by gabe.freedesktop.org (Postfix) with ESMTPS id 826586E86E; Fri, 27 Oct 2017 00:16:13 +0000 (UTC) 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; bh=QFZlzHVtM9eE/IzLEGI8awuvv6JNCCMl0x4hL0vWYUA=; b=2bbl7Mo7HWWQli6AAkWi3zstU4YfWY2Q0tTxoGwPcT/+esof0L5tGmdZlr0fTubuAklNYOMwfzRWJPHur2T/aFV5F+2exlqnuXg4bE300d0CqbgONQo5nvjaBJRpX3EfYFyqB33CfjVvAxv4kgHAUSvXGr8gYM6+vKCaeHnXMJk= Received: from DM3PR12CA0110.namprd12.prod.outlook.com (10.161.150.158) by BN6PR12MB1267.namprd12.prod.outlook.com (10.168.227.141) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.156.4; Fri, 27 Oct 2017 00:16:07 +0000 Received: from BY2NAM03FT027.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e4a::204) by DM3PR12CA0110.outlook.office365.com (2603:10b6:0:55::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.178.6 via Frontend Transport; Fri, 27 Oct 2017 00:16:07 +0000 Authentication-Results: spf=none (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; lists.freedesktop.org; dkim=none (message not signed) header.d=none;lists.freedesktop.org; dmarc=permerror action=none header.from=amd.com; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXCHOV02.amd.com (165.204.84.17) by BY2NAM03FT027.mail.protection.outlook.com (10.152.84.237) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.20.178.5 via Frontend Transport; Fri, 27 Oct 2017 00:16:07 +0000 Received: from SATLEXDAG01.amd.com (10.181.40.3) by SATLEXCHOV02.amd.com (10.181.40.72) with Microsoft SMTP Server (TLS) id 14.3.361.1; Thu, 26 Oct 2017 19:16:05 -0500 Received: from SCYBEXDAG04.amd.com (10.34.11.14) by SATLEXDAG01.amd.com (10.181.40.3) with Microsoft SMTP Server (TLS) id 14.3.361.1; Thu, 26 Oct 2017 20:16:04 -0400 Received: from andrey-target.amd.com (10.224.50.240) by SCYBEXDAG04.amd.com (10.34.11.14) with Microsoft SMTP Server id 14.3.361.1; Fri, 27 Oct 2017 08:15:59 +0800 From: Andrey Grodzovsky To: , Subject: [PATCH libdrm 1/2] amdgpu: Add wrappers for AMDGPU_VM IOCTL. Date: Thu, 26 Oct 2017 20:15:54 -0400 Message-ID: <1509063355-5205-1-git-send-email-Andrey.Grodzovsky@amd.com> X-Mailer: git-send-email 2.7.4 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)(6009001)(346002)(39860400002)(376002)(2980300002)(428002)(189002)(199003)(50466002)(72206003)(4326008)(478600001)(8936002)(77096006)(97736004)(6666003)(86362001)(575784001)(2906002)(53416004)(50226002)(189998001)(305945005)(101416001)(81156014)(81166006)(105586002)(47776003)(450100002)(68736007)(50986999)(356003)(53936002)(110136005)(316002)(5660300001)(8676002)(36756003)(5003940100001)(106466001)(48376002)(54906003)(16586007); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR12MB1267; H:SATLEXCHOV02.amd.com; FPR:; SPF:None; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2NAM03FT027; 1:qLxzZW3odTlW7t+xoRBpo1D/hVVUZlQ1/ektxluZ32FB+Abmtbml4gONHK+Dj66SObDtGTAo/ah39lF159Ba4MUTTD4PdxvKOzDCDZccHcc5M837larSBfeycYAQjAnx X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 652fd9ae-e6b6-4269-e8b7-08d51ccfeb38 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(4534020)(4602075)(4627075)(201703031133081)(201702281549075)(2017052603199); SRVR:BN6PR12MB1267; X-Microsoft-Exchange-Diagnostics: 1; BN6PR12MB1267; 3:9NZT++7v1htlS0YdUCPM4V1US/ZUluQfle+waSvBcaG3KygCK7hFPlghyBfA651JIR9MyDWt/WAxHrrzx0QYCjjDUXhS0PgfRYaU8Onz5k+2QxOWFdMxLfdTifgrbmxGgl47Ue76mj51ux9CBmRY1nt4dw1+KMOobbZdqlBJRD1zRKBrEanxnSySXAtfNrCOe6oXTV+duXWv5oTr20bs+PB99AJIgGaa7Vd20yZTA7kNMI04dcwO83uGp/thLNthS5d8d89lW0akl2fPYSdrVWoQ2aT/50Xu5xrGwe1NLuiq5hgmmJVXzwZZXhPBzxxs5PwQG5k8QNnNh4efbdeFnzUIRxbKEkOH1ekmKZSA+YI=; 25:YWJuvACqFr/97xi4kjb+IjaT0mW6+aWi0PM3WfuorN9bj7K/xxuK2aW86zc3gtR6F05tYOy4Aa7lLTGqV/5S7pZqzcE1DmfS1O3JA3lzMTeg0AKU96LSPBea6DxG01olAFIREP9clJVGurZVkNKvbUCwWDY0+mOtn7HNRhuVl2GWS180xKpne8vvg2CYjFNdvgVS6+jK30VLtt5d+947ZJbgkeV/innboaz4Wr0k/B+rj/eMtocO0191f8EW5GQVSefx+AebkwXI3oLAhfer3ukHW7iyW7TE/+rZVPZ3K0bTKt9lW9iBjBjIuONamcxHdpHjYgyFGftB2Qjolu9Gk6dz7j/EQv3uj5eslOj2OqE= X-MS-TrafficTypeDiagnostic: BN6PR12MB1267: X-Microsoft-Exchange-Diagnostics: 1; BN6PR12MB1267; 31:52Ja0XcCelo1iDLX26drrqf5DC5wWHwft5UAnAhoSZzuaq7itfbNQazTJcadbGfm8kPQBeaw0CXCSCqk0uvM9v3T3Y/cqTK27F09NNIMA1+fmSlUuUHvDEn2tQ5LZbIjVsgEY3FlI+EcTPq+lkPmH3zKvor5opuwjPnSgxyf2R7Wel25k+35Lhc9dJJF3A/AMz7fFGXgkNKkRmwNpYDQqx2ozvA3/p6i6bOmcUzEsGs=; 20:vUzVzVMtQRj9PbL9Z6Je8t9TfhL26eXSikicuRk9/9xTW0QayumhdF02j1AVQoKqf8IJsrDHqxlPCBza2E4/zYNmsrz/7zEBHumvin9prfqROx9pEKdUHB490iX83mm9g/Rj5jfsxehc2I7P4qjwVprlva+GAUlvvE1P/u9+LHyh1qwfRomV2tGBzP7uabWqxSCrhFjpyLEsLibXZ8cKsP9Kt8c5xt5w7W/jk/MjtAqM5DB93q7tQoeVmnWozjXQ5DuzrrYMpko9uKRuH0h+giYgKfpTl/28UrXD/SE5zR0yy0mKPMUMkD6SXpgv5znGWch11OoF8cqlnX09+eDjDGTUA4wExiXh+FAGRd+DIc/evVVLpYKAGFkZsCWv6YA52cTQr+V+66ytu4U4ZuT3+s9OEqHJ/AjlKGyXTNTyo5o45mAPBchKT5iZwlSoodbb6RsNXWHBEV1SYEKXAwPEod8qa8HBTJsWYl5O3pvdHXn0psv9YKh+2LY2+qusqZWO X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(5005006)(8121501046)(93006095)(93003095)(100000703101)(100105400095)(3231020)(3002001)(10201501046)(6055026)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123555025)(20161123562025)(20161123558100)(20161123560025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:BN6PR12MB1267; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:BN6PR12MB1267; X-Microsoft-Exchange-Diagnostics: 1; BN6PR12MB1267; 4:jGcY+181DZO0UxKorMuLXNY0+LKTEJ5jerLkCZpkhELZ2Gnqa7T7Q444t4GyERAB6Il0xefNic87TUPRaftwhA/3yh0OgZuqlumh98b3DZY2BAwcd38X89DyOh41W9ap2RQe+O0oSPj3HdfZZD5Qw5hHmSBDNagzFa77H35OJF+JkzwaddrufuaYR13IUC29gVeECv1uon4zhzJAJJYO/eDQy2f7JkhF+3fREGj08QjQHLG+cqnuG1k+vvsGw9bpO5qPcAGJ/gMJQn2VYuLvbFc21R1EQuVAvFFsJYc0Rq8= X-Forefront-PRVS: 0473A03F3F X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN6PR12MB1267; 23:OoQNrDTeUKpmPae2KNLmf99v4fipeDlEPrpA9X603?= =?us-ascii?Q?sGyYi6l+bWsANjA+opLwwXJgNLSyNzYy9Lsa/eUp3oM8cIAP9VVkuaCFnmgL?= =?us-ascii?Q?Z5MK7NYoKd1sp3+9fIeK/ykFsJOzF3Fg4M3s4G2U7IhtrFbapm2HL3YQ9Gph?= =?us-ascii?Q?pmnyFMESjEGK2teNPCsq03QnhamWMNwHHZk8ADy714NyTWXgvcpdx0NOJ1jC?= =?us-ascii?Q?DSJcyaLADmn+2u7httRtWIIoyuqcVuQsZkCsUbyJwWqrfAP93TkmdQ1qg22t?= =?us-ascii?Q?dOr4obNLx07luXHfcr77yQDLv/C1coP0qECohQXUN51ki1IRAjSpa3+UGrxu?= =?us-ascii?Q?fUi5npUYUeS3YDiytIhc5m3q6SnANLHnFj60c47pj1q4+EJ0Bau1z93jD2ps?= =?us-ascii?Q?Q94yL1EMJt/0RQAShFGcG3wUWXm5tAhHfe3z3Om5hRloW/wrqE77hkOvn2PS?= =?us-ascii?Q?NvcqOyzZEPd4gqluugfmvIaDwZR3qSorWWP0WfVh76eLF3+yuMEnvePRv2f1?= =?us-ascii?Q?EIB5djabDYAxmsI+05RMaBvVh81UR6yzXMdLyHeBsjDnV2wUg7+4vwgYFwCf?= =?us-ascii?Q?gy0UmQnAFj5TH8LU4MDlO+FtFplGlA5ksxffK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:m1O4wyDr4+goyQNxZVPjX9QkQgDF2PEBwSw7/ijOGvDR9HqBlvLbj6HR36+xXdEtyptlu9xlwvkEEb8igYVHnEjbNkVuJiuQ1WvLptZtyLk=; 7:uEksyxEO/5lqQOP6/RNW7CEdKJ1uEj2bJGycafpEmlCzPU1JVKuXr4tFflUF0khXFP3U9y3DCSgpzHcsNw8HgdS3ycp1ImbSE4L4ZzAmOOn9n8ACRIvgftKv+hzPo+oRjUauZMvOjyIyJqFBx/Fdld20tAE4wqWCXz0Z5wNqs70Td7cMB7sxRtcpu9+3Uxml7Q5/1biYo62P9T3BfoI1Z14Mk8nXAsRg5VRCUcIupJk= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN6PR12MB1267; 20:x4IEH34TGCgTIjUH6Zo3DrqeFAigwVAUGB+YOV0w8DV+E0IZV7KDPW+qCAlBYE90T+m780KXrJo85rVhDkZqU6wjDYKPPLT9N1o8PVzYI3pUdnTHLwpL3cJ+peLTDDI6T3HQPN3CzRafU+54Ct0hW8lq7r9WnqXRr4HD4FNtfi25ctScHcNcRpsa0u7eXgyorzeSQE68Wo9ce6zErPMo/G+e8JznDFoimgesU0+rmRhy4yGSznStPFvvhHzn/qy/ X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Oct 2017 00:16:07.1414 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 652fd9ae-e6b6-4269-e8b7-08d51ccfeb38 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: BN6PR12MB1267 Cc: Alexander.Deucher@amd.com, christian.koenig@amd.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Change-Id: I7eafb85c1ca96d6d255f0183bed0ce4129746fe0 Signed-off-by: Andrey Grodzovsky --- amdgpu/Makefile.sources | 1 + amdgpu/amdgpu.h | 20 +++++++++++++++++++ amdgpu/amdgpu_vm.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 amdgpu/amdgpu_vm.c diff --git a/amdgpu/Makefile.sources b/amdgpu/Makefile.sources index bc3abaa..498b64c 100644 --- a/amdgpu/Makefile.sources +++ b/amdgpu/Makefile.sources @@ -6,6 +6,7 @@ LIBDRM_AMDGPU_FILES := \ amdgpu_gpu_info.c \ amdgpu_internal.h \ amdgpu_vamgr.c \ + amdgpu_vm.c \ util_hash.c \ util_hash.h \ util_hash_table.c \ diff --git a/amdgpu/amdgpu.h b/amdgpu/amdgpu.h index ecc975f..07f2851 100644 --- a/amdgpu/amdgpu.h +++ b/amdgpu/amdgpu.h @@ -1489,6 +1489,26 @@ void amdgpu_cs_chunk_fence_to_dep(struct amdgpu_cs_fence *fence, void amdgpu_cs_chunk_fence_info_to_data(struct amdgpu_cs_fence_info *fence_info, struct drm_amdgpu_cs_chunk_data *data); +/** + * Reserve VMID + * \param context - \c [in] GPU Context + * \param flags - \c [in] TBD + * + * \return 0 on success otherwise POSIX Error code +*/ +int amdgpu_vm_alloc_reserved_vmid(amdgpu_context_handle context, + uint32_t flags); + +/** + * Free reserved VMID + * \param context - \c [in] GPU Context + * \param flags - \c [in] TBD + * + * \return 0 on success otherwise POSIX Error code +*/ +int amdgpu_vm_free_reserved_vmid(amdgpu_context_handle context, + uint32_t flags); + #ifdef __cplusplus } #endif diff --git a/amdgpu/amdgpu_vm.c b/amdgpu/amdgpu_vm.c new file mode 100644 index 0000000..1664b7b --- /dev/null +++ b/amdgpu/amdgpu_vm.c @@ -0,0 +1,52 @@ +/* + * Copyright 2017 Advanced Micro Devices, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + */ + + +#include "amdgpu.h" +#include "amdgpu_drm.h" +#include "xf86drm.h" +#include "amdgpu_internal.h" + +int amdgpu_vm_alloc_reserved_vmid(amdgpu_context_handle context, + uint32_t flags) +{ + union drm_amdgpu_vm vm; + + vm.in.op = AMDGPU_VM_OP_RESERVE_VMID; + vm.in.flags = flags; + + return drmCommandWriteRead(context->dev->fd, DRM_AMDGPU_VM, + &vm, sizeof(vm)); +} + +int amdgpu_vm_free_reserved_vmid(amdgpu_context_handle context, + uint32_t flags) +{ + union drm_amdgpu_vm vm; + + vm.in.op = AMDGPU_VM_OP_UNRESERVE_VMID; + vm.in.flags = flags; + + return drmCommandWriteRead(context->dev->fd, DRM_AMDGPU_VM, + &vm, sizeof(vm)); +}