Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 OR MIT */
0002 /*
0003  * Copyright 2020-2021 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 
0025 #ifndef KFD_MIGRATE_H_
0026 #define KFD_MIGRATE_H_
0027 
0028 #if IS_ENABLED(CONFIG_HSA_AMD_SVM)
0029 
0030 #include <linux/rwsem.h>
0031 #include <linux/list.h>
0032 #include <linux/mutex.h>
0033 #include <linux/sched/mm.h>
0034 #include <linux/hmm.h>
0035 #include "kfd_priv.h"
0036 #include "kfd_svm.h"
0037 
0038 enum MIGRATION_COPY_DIR {
0039     FROM_RAM_TO_VRAM = 0,
0040     FROM_VRAM_TO_RAM
0041 };
0042 
0043 int svm_migrate_to_vram(struct svm_range *prange,  uint32_t best_loc,
0044             struct mm_struct *mm, uint32_t trigger);
0045 int svm_migrate_vram_to_ram(struct svm_range *prange, struct mm_struct *mm,
0046                 uint32_t trigger);
0047 unsigned long
0048 svm_migrate_addr_to_pfn(struct amdgpu_device *adev, unsigned long addr);
0049 
0050 int svm_migrate_init(struct amdgpu_device *adev);
0051 
0052 #else
0053 
0054 static inline int svm_migrate_init(struct amdgpu_device *adev)
0055 {
0056     return 0;
0057 }
0058 
0059 #endif /* IS_ENABLED(CONFIG_HSA_AMD_SVM) */
0060 
0061 #endif /* KFD_MIGRATE_H_ */