![]() |
|
|||
0001 // SPDX-License-Identifier: GPL-2.0 OR MIT 0002 /* 0003 * Copyright 2014-2022 Advanced Micro Devices, Inc. 0004 * 0005 * Permission is hereby granted, free of charge, to any person obtaining a 0006 * copy of this software and associated documentation files (the "Software"), 0007 * to deal in the Software without restriction, including without limitation 0008 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 0009 * and/or sell copies of the Software, and to permit persons to whom the 0010 * Software is furnished to do so, subject to the following conditions: 0011 * 0012 * The above copyright notice and this permission notice shall be included in 0013 * all copies or substantial portions of the Software. 0014 * 0015 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 0016 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 0017 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 0018 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 0019 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 0020 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 0021 * OTHER DEALINGS IN THE SOFTWARE. 0022 */ 0023 0024 #include <linux/types.h> 0025 #include "kfd_priv.h" 0026 #include "amdgpu_ids.h" 0027 0028 static unsigned int pasid_bits = 16; 0029 static bool pasids_allocated; /* = false */ 0030 0031 bool kfd_set_pasid_limit(unsigned int new_limit) 0032 { 0033 if (new_limit < 2) 0034 return false; 0035 0036 if (new_limit < (1U << pasid_bits)) { 0037 if (pasids_allocated) 0038 /* We've already allocated user PASIDs, too late to 0039 * change the limit 0040 */ 0041 return false; 0042 0043 while (new_limit < (1U << pasid_bits)) 0044 pasid_bits--; 0045 } 0046 0047 return true; 0048 } 0049 0050 unsigned int kfd_get_pasid_limit(void) 0051 { 0052 return 1U << pasid_bits; 0053 } 0054 0055 u32 kfd_pasid_alloc(void) 0056 { 0057 int r = amdgpu_pasid_alloc(pasid_bits); 0058 0059 if (r > 0) { 0060 pasids_allocated = true; 0061 return r; 0062 } 0063 0064 return 0; 0065 } 0066 0067 void kfd_pasid_free(u32 pasid) 0068 { 0069 amdgpu_pasid_free(pasid); 0070 }
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |