From: Honglei Huang <[email protected]> Add amdgpu_userptr.h with types and declarations for xnack-off (noretry) restore infrastructure: - AMDGPU_SVM_RANGE_RESTORE_DELAY_MS: 1ms default restore delay - struct amdgpu_svm_restore: restore workqueue context with delayed_work, evicted_ranges atomic counter, quiesced state, begin/end callbacks - Function declarations for restore_init/fini/flush, invalidate, gc_work_func, quiesce/resume_compute
Signed-off-by: Honglei Huang <[email protected]> --- drivers/gpu/drm/amd/amdgpu/amdgpu_userptr.h | 63 +++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_userptr.h diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userptr.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_userptr.h new file mode 100644 index 000000000..a8f76f785 --- /dev/null +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userptr.h @@ -0,0 +1,63 @@ +/* SPDX-License-Identifier: MIT */ +/* + * Copyright 2026 Advanced Micro Devices, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + */ + +#ifndef __AMDGPU_USERPTR_H__ +#define __AMDGPU_USERPTR_H__ + +#include <linux/atomic.h> +#include <linux/list.h> +#include <linux/workqueue.h> + +struct amdgpu_svm; +struct drm_gpusvm_notifier; +struct drm_gpusvm_range; +struct mmu_notifier_range; + +#define AMDGPU_SVM_RANGE_RESTORE_DELAY_MS 1 + +struct amdgpu_svm_restore { + struct workqueue_struct *wq; + struct list_head list; + struct delayed_work work; + atomic_t quiesced; + atomic_t evicted_ranges; + void (*begin)(struct amdgpu_svm *svm); + void (*end)(struct amdgpu_svm *svm); +}; + +int amdgpu_svm_restore_init(struct amdgpu_svm *svm, + void (*begin)(struct amdgpu_svm *), + void (*end)(struct amdgpu_svm *)); +void amdgpu_svm_restore_fini(struct amdgpu_svm *svm); +void amdgpu_svm_restore_flush(struct amdgpu_svm *svm); +void amdgpu_svm_restore_gc_work_func(struct work_struct *w); +void amdgpu_svm_restore_invalidate(struct amdgpu_svm *svm, + struct drm_gpusvm_notifier *notifier, + const struct mmu_notifier_range *mmu_range, + struct drm_gpusvm_range *first, + uint64_t adj_start, uint64_t adj_end); +void amdgpu_svm_quiesce_compute(struct amdgpu_svm *svm); +void amdgpu_svm_resume_compute(struct amdgpu_svm *svm); + +#endif /* __AMDGPU_USERPTR_H__ */ -- 2.34.1
