1d722e3fbSopenharmony_ci/* 2d722e3fbSopenharmony_ci * Copyright 2017 Advanced Micro Devices, Inc. 3d722e3fbSopenharmony_ci * 4d722e3fbSopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 5d722e3fbSopenharmony_ci * copy of this software and associated documentation files (the "Software"), 6d722e3fbSopenharmony_ci * to deal in the Software without restriction, including without limitation 7d722e3fbSopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8d722e3fbSopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 9d722e3fbSopenharmony_ci * Software is furnished to do so, subject to the following conditions: 10d722e3fbSopenharmony_ci * 11d722e3fbSopenharmony_ci * The above copyright notice and this permission notice shall be included in 12d722e3fbSopenharmony_ci * all copies or substantial portions of the Software. 13d722e3fbSopenharmony_ci * 14d722e3fbSopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15d722e3fbSopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16d722e3fbSopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17d722e3fbSopenharmony_ci * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 18d722e3fbSopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19d722e3fbSopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20d722e3fbSopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE. 21d722e3fbSopenharmony_ci * 22d722e3fbSopenharmony_ci */ 23d722e3fbSopenharmony_ci 24d722e3fbSopenharmony_ci#include "amdgpu.h" 25d722e3fbSopenharmony_ci#include "amdgpu_drm.h" 26d722e3fbSopenharmony_ci#include "xf86drm.h" 27d722e3fbSopenharmony_ci#include "amdgpu_internal.h" 28d722e3fbSopenharmony_ci 29d722e3fbSopenharmony_cidrm_public int amdgpu_vm_reserve_vmid(amdgpu_device_handle dev, uint32_t flags) 30d722e3fbSopenharmony_ci{ 31d722e3fbSopenharmony_ci union drm_amdgpu_vm vm; 32d722e3fbSopenharmony_ci 33d722e3fbSopenharmony_ci vm.in.op = AMDGPU_VM_OP_RESERVE_VMID; 34d722e3fbSopenharmony_ci vm.in.flags = flags; 35d722e3fbSopenharmony_ci 36d722e3fbSopenharmony_ci return drmCommandWriteRead(dev->fd, DRM_AMDGPU_VM, 37d722e3fbSopenharmony_ci &vm, sizeof(vm)); 38d722e3fbSopenharmony_ci} 39d722e3fbSopenharmony_ci 40d722e3fbSopenharmony_cidrm_public int amdgpu_vm_unreserve_vmid(amdgpu_device_handle dev, 41d722e3fbSopenharmony_ci uint32_t flags) 42d722e3fbSopenharmony_ci{ 43d722e3fbSopenharmony_ci union drm_amdgpu_vm vm; 44d722e3fbSopenharmony_ci 45d722e3fbSopenharmony_ci vm.in.op = AMDGPU_VM_OP_UNRESERVE_VMID; 46d722e3fbSopenharmony_ci vm.in.flags = flags; 47d722e3fbSopenharmony_ci 48d722e3fbSopenharmony_ci return drmCommandWriteRead(dev->fd, DRM_AMDGPU_VM, 49d722e3fbSopenharmony_ci &vm, sizeof(vm)); 50d722e3fbSopenharmony_ci} 51