1814ab993SPhilip Yang /* SPDX-License-Identifier: GPL-2.0 OR MIT */ 2814ab993SPhilip Yang /* 3814ab993SPhilip Yang * Copyright 2020-2021 Advanced Micro Devices, Inc. 4814ab993SPhilip Yang * 5814ab993SPhilip Yang * Permission is hereby granted, free of charge, to any person obtaining a 6814ab993SPhilip Yang * copy of this software and associated documentation files (the "Software"), 7814ab993SPhilip Yang * to deal in the Software without restriction, including without limitation 8814ab993SPhilip Yang * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9814ab993SPhilip Yang * and/or sell copies of the Software, and to permit persons to whom the 10814ab993SPhilip Yang * Software is furnished to do so, subject to the following conditions: 11814ab993SPhilip Yang * 12814ab993SPhilip Yang * The above copyright notice and this permission notice shall be included in 13814ab993SPhilip Yang * all copies or substantial portions of the Software. 14814ab993SPhilip Yang * 15814ab993SPhilip Yang * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16814ab993SPhilip Yang * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17814ab993SPhilip Yang * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18814ab993SPhilip Yang * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 19814ab993SPhilip Yang * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 20814ab993SPhilip Yang * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 21814ab993SPhilip Yang * OTHER DEALINGS IN THE SOFTWARE. 22814ab993SPhilip Yang * 23814ab993SPhilip Yang */ 24814ab993SPhilip Yang 25814ab993SPhilip Yang #ifndef KFD_MIGRATE_H_ 26814ab993SPhilip Yang #define KFD_MIGRATE_H_ 27814ab993SPhilip Yang 28814ab993SPhilip Yang #include <linux/rwsem.h> 29814ab993SPhilip Yang #include <linux/list.h> 30814ab993SPhilip Yang #include <linux/mutex.h> 31814ab993SPhilip Yang #include <linux/sched/mm.h> 32814ab993SPhilip Yang #include <linux/hmm.h> 33814ab993SPhilip Yang #include "kfd_priv.h" 34814ab993SPhilip Yang #include "kfd_svm.h" 35814ab993SPhilip Yang 3650ea50cfSPhilip Yang enum MIGRATION_COPY_DIR { 3750ea50cfSPhilip Yang FROM_RAM_TO_VRAM = 0, 3850ea50cfSPhilip Yang FROM_VRAM_TO_RAM 3950ea50cfSPhilip Yang }; 4050ea50cfSPhilip Yang 41*1a3b2b5dSFelix Kuehling int svm_migrate_to_vram(struct svm_range *prange, uint32_t best_loc, 42cda0f85bSFelix Kuehling struct mm_struct *mm); 4348ff079bSFelix Kuehling int svm_migrate_vram_to_ram(struct svm_range *prange, struct mm_struct *mm); 4448ff079bSFelix Kuehling unsigned long 4548ff079bSFelix Kuehling svm_migrate_addr_to_pfn(struct amdgpu_device *adev, unsigned long addr); 460b0e518dSFelix Kuehling 47814ab993SPhilip Yang #if defined(CONFIG_DEVICE_PRIVATE) 48814ab993SPhilip Yang int svm_migrate_init(struct amdgpu_device *adev); 49814ab993SPhilip Yang void svm_migrate_fini(struct amdgpu_device *adev); 50814ab993SPhilip Yang 51814ab993SPhilip Yang #else 52814ab993SPhilip Yang static inline int svm_migrate_init(struct amdgpu_device *adev) 53814ab993SPhilip Yang { 54814ab993SPhilip Yang DRM_WARN_ONCE("DEVICE_PRIVATE kernel config option is not enabled, " 55814ab993SPhilip Yang "add CONFIG_DEVICE_PRIVATE=y in config file to fix\n"); 56814ab993SPhilip Yang return -ENODEV; 57814ab993SPhilip Yang } 58814ab993SPhilip Yang static inline void svm_migrate_fini(struct amdgpu_device *adev) {} 59814ab993SPhilip Yang #endif 60814ab993SPhilip Yang #endif /* KFD_MIGRATE_H_ */ 61