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 
284ab159d2SFelix Kuehling #if IS_ENABLED(CONFIG_HSA_AMD_SVM)
294ab159d2SFelix Kuehling 
30814ab993SPhilip Yang #include <linux/rwsem.h>
31814ab993SPhilip Yang #include <linux/list.h>
32814ab993SPhilip Yang #include <linux/mutex.h>
33814ab993SPhilip Yang #include <linux/sched/mm.h>
34814ab993SPhilip Yang #include <linux/hmm.h>
35814ab993SPhilip Yang #include "kfd_priv.h"
36814ab993SPhilip Yang #include "kfd_svm.h"
37814ab993SPhilip Yang 
3850ea50cfSPhilip Yang enum MIGRATION_COPY_DIR {
3950ea50cfSPhilip Yang 	FROM_RAM_TO_VRAM = 0,
4050ea50cfSPhilip Yang 	FROM_VRAM_TO_RAM
4150ea50cfSPhilip Yang };
4250ea50cfSPhilip Yang 
431a3b2b5dSFelix Kuehling int svm_migrate_to_vram(struct svm_range *prange,  uint32_t best_loc,
44acac270dSPhilip Yang 			struct mm_struct *mm, uint32_t trigger);
45acac270dSPhilip Yang int svm_migrate_vram_to_ram(struct svm_range *prange, struct mm_struct *mm,
46*16ce101dSAlistair Popple 			    uint32_t trigger, struct page *fault_page);
4748ff079bSFelix Kuehling unsigned long
4848ff079bSFelix Kuehling svm_migrate_addr_to_pfn(struct amdgpu_device *adev, unsigned long addr);
490b0e518dSFelix Kuehling 
504ab159d2SFelix Kuehling #endif /* IS_ENABLED(CONFIG_HSA_AMD_SVM) */
514ab159d2SFelix Kuehling 
52814ab993SPhilip Yang #endif /* KFD_MIGRATE_H_ */
53