Re: [PATCH 1/2] drm/amdgpu: use HMM mirror callback to replace mmu notifier v5
On 2018-12-04 4:06 a.m., Christian König wrote: > Am 03.12.18 um 21:19 schrieb Yang, Philip: >> Replace our MMU notifier with hmm_mirror_ops.sync_cpu_device_pagetables >> callback. Enable CONFIG_HMM and CONFIG_HMM_MIRROR as a dependency in >> DRM_AMDGPU_USERPTR Kconfig. >> >> It supports both KFD userptr and gfx userptr paths. >> >> The depdent HMM patchsets from Jérôme Glisse are all merged into 4.20.0 >> kernel now. >> >> Change-Id: Ie62c3c5e3c5b8521ab3b438d1eff2aa2a003835e >> Signed-off-by: Philip Yang >> --- >> drivers/gpu/drm/amd/amdgpu/Kconfig | 6 +- >> drivers/gpu/drm/amd/amdgpu/Makefile | 2 +- >> drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c | 124 +++-- >> drivers/gpu/drm/amd/amdgpu/amdgpu_mn.h | 2 +- >> 4 files changed, 57 insertions(+), 77 deletions(-) >> >> diff --git a/drivers/gpu/drm/amd/amdgpu/Kconfig >> b/drivers/gpu/drm/amd/amdgpu/Kconfig >> index 9221e5489069..960a63355705 100644 >> --- a/drivers/gpu/drm/amd/amdgpu/Kconfig >> +++ b/drivers/gpu/drm/amd/amdgpu/Kconfig >> @@ -26,10 +26,10 @@ config DRM_AMDGPU_CIK >> config DRM_AMDGPU_USERPTR >> bool "Always enable userptr write support" >> depends on DRM_AMDGPU >> - select MMU_NOTIFIER >> + select HMM_MIRROR >> help >> - This option selects CONFIG_MMU_NOTIFIER if it isn't already >> - selected to enabled full userptr support. >> + This option selects CONFIG_HMM and CONFIG_HMM_MIRROR if it >> + isn't already selected to enabled full userptr support. >> config DRM_AMDGPU_GART_DEBUGFS >> bool "Allow GART access through debugfs" >> diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile >> b/drivers/gpu/drm/amd/amdgpu/Makefile >> index f76bcb9c45e4..05ca6dc381e0 100644 >> --- a/drivers/gpu/drm/amd/amdgpu/Makefile >> +++ b/drivers/gpu/drm/amd/amdgpu/Makefile >> @@ -172,7 +172,7 @@ endif >> amdgpu-$(CONFIG_COMPAT) += amdgpu_ioc32.o >> amdgpu-$(CONFIG_VGA_SWITCHEROO) += amdgpu_atpx_handler.o >> amdgpu-$(CONFIG_ACPI) += amdgpu_acpi.o >> -amdgpu-$(CONFIG_MMU_NOTIFIER) += amdgpu_mn.o >> +amdgpu-$(CONFIG_HMM) += amdgpu_mn.o > > This probably need to be CONFIG_HMM_MIRROR. Yes, CONFIG_HMM_MIRROR selects CONFIG_HMM, but the reverse is not true. > >> include $(FULL_AMD_PATH)/powerplay/Makefile >> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c >> b/drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c >> index e55508b39496..56595b3d90d2 100644 >> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c >> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c >> @@ -45,7 +45,7 @@ >> #include >> #include >> -#include >> +#include >> #include >> #include >> #include >> @@ -58,7 +58,6 @@ >> * >> * @adev: amdgpu device pointer >> * @mm: process address space >> - * @mn: MMU notifier structure >> * @type: type of MMU notifier >> * @work: destruction work item >> * @node: hash table node to find structure by adev and mn >> @@ -66,6 +65,7 @@ >> * @objects: interval tree containing amdgpu_mn_nodes >> * @read_lock: mutex for recursive locking of @lock >> * @recursion: depth of recursion >> + * @mirror: HMM mirror function support >> * >> * Data for each amdgpu device and process address space. >> */ >> @@ -73,7 +73,6 @@ struct amdgpu_mn { >> /* constant after initialisation */ >> struct amdgpu_device *adev; >> struct mm_struct *mm; >> - struct mmu_notifier mn; >> enum amdgpu_mn_type type; >> /* only used on destruction */ >> @@ -87,6 +86,9 @@ struct amdgpu_mn { >> struct rb_root_cached objects; >> struct mutex read_lock; >> atomic_t recursion; >> + >> + /* HMM mirror */ >> + struct hmm_mirror mirror; >> }; >> /** >> @@ -103,7 +105,7 @@ struct amdgpu_mn_node { >> }; >> /** >> - * amdgpu_mn_destroy - destroy the MMU notifier >> + * amdgpu_mn_destroy - destroy the HMM mirror >> * >> * @work: previously sheduled work item >> * >> @@ -129,28 +131,26 @@ static void amdgpu_mn_destroy(struct >> work_struct *work) >> } >> up_write(>lock); >> mutex_unlock(>mn_lock); >> - mmu_notifier_unregister_no_release(>mn, amn->mm); >> + >> + hmm_mirror_unregister(>mirror); >> kfree(amn); >> } >> /** >> - * amdgpu_mn_release - callback to notify about mm destruction >> + * amdgpu_hmm_mirror_release - callback to notify about mm destruction >> * >> - * @mn: our notifier >> - * @mm: the mm this callback is about >> + * @mirror: the HMM mirror (mm) this callback is about >> * >> - * Shedule a work item to lazy destroy our notifier. >> + * Shedule a work item to lazy destroy HMM mirror. >> */ >> -static void amdgpu_mn_release(struct mmu_notifier *mn, >> - struct mm_struct *mm) >> +static void amdgpu_hmm_mirror_release(struct hmm_mirror *mirror) >> { >> - struct amdgpu_mn *amn = container_of(mn, struct amdgpu_mn, mn); >> + struct amdgpu_mn *amn = container_of(mirror, struct amdgpu_mn, >>
Re: [PATCH 1/2] drm/amdgpu: use HMM mirror callback to replace mmu notifier v5
Am 03.12.18 um 21:19 schrieb Yang, Philip: Replace our MMU notifier with hmm_mirror_ops.sync_cpu_device_pagetables callback. Enable CONFIG_HMM and CONFIG_HMM_MIRROR as a dependency in DRM_AMDGPU_USERPTR Kconfig. It supports both KFD userptr and gfx userptr paths. The depdent HMM patchsets from Jérôme Glisse are all merged into 4.20.0 kernel now. Change-Id: Ie62c3c5e3c5b8521ab3b438d1eff2aa2a003835e Signed-off-by: Philip Yang --- drivers/gpu/drm/amd/amdgpu/Kconfig | 6 +- drivers/gpu/drm/amd/amdgpu/Makefile| 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c | 124 +++-- drivers/gpu/drm/amd/amdgpu/amdgpu_mn.h | 2 +- 4 files changed, 57 insertions(+), 77 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/Kconfig b/drivers/gpu/drm/amd/amdgpu/Kconfig index 9221e5489069..960a63355705 100644 --- a/drivers/gpu/drm/amd/amdgpu/Kconfig +++ b/drivers/gpu/drm/amd/amdgpu/Kconfig @@ -26,10 +26,10 @@ config DRM_AMDGPU_CIK config DRM_AMDGPU_USERPTR bool "Always enable userptr write support" depends on DRM_AMDGPU - select MMU_NOTIFIER + select HMM_MIRROR help - This option selects CONFIG_MMU_NOTIFIER if it isn't already - selected to enabled full userptr support. + This option selects CONFIG_HMM and CONFIG_HMM_MIRROR if it + isn't already selected to enabled full userptr support. config DRM_AMDGPU_GART_DEBUGFS bool "Allow GART access through debugfs" diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile b/drivers/gpu/drm/amd/amdgpu/Makefile index f76bcb9c45e4..05ca6dc381e0 100644 --- a/drivers/gpu/drm/amd/amdgpu/Makefile +++ b/drivers/gpu/drm/amd/amdgpu/Makefile @@ -172,7 +172,7 @@ endif amdgpu-$(CONFIG_COMPAT) += amdgpu_ioc32.o amdgpu-$(CONFIG_VGA_SWITCHEROO) += amdgpu_atpx_handler.o amdgpu-$(CONFIG_ACPI) += amdgpu_acpi.o -amdgpu-$(CONFIG_MMU_NOTIFIER) += amdgpu_mn.o +amdgpu-$(CONFIG_HMM) += amdgpu_mn.o This probably need to be CONFIG_HMM_MIRROR. include $(FULL_AMD_PATH)/powerplay/Makefile diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c index e55508b39496..56595b3d90d2 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c @@ -45,7 +45,7 @@ #include #include -#include +#include #include #include #include @@ -58,7 +58,6 @@ * * @adev: amdgpu device pointer * @mm: process address space - * @mn: MMU notifier structure * @type: type of MMU notifier * @work: destruction work item * @node: hash table node to find structure by adev and mn @@ -66,6 +65,7 @@ * @objects: interval tree containing amdgpu_mn_nodes * @read_lock: mutex for recursive locking of @lock * @recursion: depth of recursion + * @mirror: HMM mirror function support * * Data for each amdgpu device and process address space. */ @@ -73,7 +73,6 @@ struct amdgpu_mn { /* constant after initialisation */ struct amdgpu_device*adev; struct mm_struct*mm; - struct mmu_notifier mn; enum amdgpu_mn_type type; /* only used on destruction */ @@ -87,6 +86,9 @@ struct amdgpu_mn { struct rb_root_cached objects; struct mutexread_lock; atomic_trecursion; + + /* HMM mirror */ + struct hmm_mirror mirror; }; /** @@ -103,7 +105,7 @@ struct amdgpu_mn_node { }; /** - * amdgpu_mn_destroy - destroy the MMU notifier + * amdgpu_mn_destroy - destroy the HMM mirror * * @work: previously sheduled work item * @@ -129,28 +131,26 @@ static void amdgpu_mn_destroy(struct work_struct *work) } up_write(>lock); mutex_unlock(>mn_lock); - mmu_notifier_unregister_no_release(>mn, amn->mm); + + hmm_mirror_unregister(>mirror); kfree(amn); } /** - * amdgpu_mn_release - callback to notify about mm destruction + * amdgpu_hmm_mirror_release - callback to notify about mm destruction * - * @mn: our notifier - * @mm: the mm this callback is about + * @mirror: the HMM mirror (mm) this callback is about * - * Shedule a work item to lazy destroy our notifier. + * Shedule a work item to lazy destroy HMM mirror. */ -static void amdgpu_mn_release(struct mmu_notifier *mn, - struct mm_struct *mm) +static void amdgpu_hmm_mirror_release(struct hmm_mirror *mirror) { - struct amdgpu_mn *amn = container_of(mn, struct amdgpu_mn, mn); + struct amdgpu_mn *amn = container_of(mirror, struct amdgpu_mn, mirror); INIT_WORK(>work, amdgpu_mn_destroy); schedule_work(>work); } - /** * amdgpu_mn_lock - take the write side lock for this notifier * @@ -237,21 +237,19 @@ static void amdgpu_mn_invalidate_node(struct amdgpu_mn_node *node, /** * amdgpu_mn_invalidate_range_start_gfx - callback to notify about mm change * - * @mn: our notifier - * @mm: the mm this callback
[PATCH 1/2] drm/amdgpu: use HMM mirror callback to replace mmu notifier v5
Replace our MMU notifier with hmm_mirror_ops.sync_cpu_device_pagetables callback. Enable CONFIG_HMM and CONFIG_HMM_MIRROR as a dependency in DRM_AMDGPU_USERPTR Kconfig. It supports both KFD userptr and gfx userptr paths. The depdent HMM patchsets from Jérôme Glisse are all merged into 4.20.0 kernel now. Change-Id: Ie62c3c5e3c5b8521ab3b438d1eff2aa2a003835e Signed-off-by: Philip Yang --- drivers/gpu/drm/amd/amdgpu/Kconfig | 6 +- drivers/gpu/drm/amd/amdgpu/Makefile| 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c | 124 +++-- drivers/gpu/drm/amd/amdgpu/amdgpu_mn.h | 2 +- 4 files changed, 57 insertions(+), 77 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/Kconfig b/drivers/gpu/drm/amd/amdgpu/Kconfig index 9221e5489069..960a63355705 100644 --- a/drivers/gpu/drm/amd/amdgpu/Kconfig +++ b/drivers/gpu/drm/amd/amdgpu/Kconfig @@ -26,10 +26,10 @@ config DRM_AMDGPU_CIK config DRM_AMDGPU_USERPTR bool "Always enable userptr write support" depends on DRM_AMDGPU - select MMU_NOTIFIER + select HMM_MIRROR help - This option selects CONFIG_MMU_NOTIFIER if it isn't already - selected to enabled full userptr support. + This option selects CONFIG_HMM and CONFIG_HMM_MIRROR if it + isn't already selected to enabled full userptr support. config DRM_AMDGPU_GART_DEBUGFS bool "Allow GART access through debugfs" diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile b/drivers/gpu/drm/amd/amdgpu/Makefile index f76bcb9c45e4..05ca6dc381e0 100644 --- a/drivers/gpu/drm/amd/amdgpu/Makefile +++ b/drivers/gpu/drm/amd/amdgpu/Makefile @@ -172,7 +172,7 @@ endif amdgpu-$(CONFIG_COMPAT) += amdgpu_ioc32.o amdgpu-$(CONFIG_VGA_SWITCHEROO) += amdgpu_atpx_handler.o amdgpu-$(CONFIG_ACPI) += amdgpu_acpi.o -amdgpu-$(CONFIG_MMU_NOTIFIER) += amdgpu_mn.o +amdgpu-$(CONFIG_HMM) += amdgpu_mn.o include $(FULL_AMD_PATH)/powerplay/Makefile diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c index e55508b39496..56595b3d90d2 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c @@ -45,7 +45,7 @@ #include #include -#include +#include #include #include #include @@ -58,7 +58,6 @@ * * @adev: amdgpu device pointer * @mm: process address space - * @mn: MMU notifier structure * @type: type of MMU notifier * @work: destruction work item * @node: hash table node to find structure by adev and mn @@ -66,6 +65,7 @@ * @objects: interval tree containing amdgpu_mn_nodes * @read_lock: mutex for recursive locking of @lock * @recursion: depth of recursion + * @mirror: HMM mirror function support * * Data for each amdgpu device and process address space. */ @@ -73,7 +73,6 @@ struct amdgpu_mn { /* constant after initialisation */ struct amdgpu_device*adev; struct mm_struct*mm; - struct mmu_notifier mn; enum amdgpu_mn_type type; /* only used on destruction */ @@ -87,6 +86,9 @@ struct amdgpu_mn { struct rb_root_cached objects; struct mutexread_lock; atomic_trecursion; + + /* HMM mirror */ + struct hmm_mirror mirror; }; /** @@ -103,7 +105,7 @@ struct amdgpu_mn_node { }; /** - * amdgpu_mn_destroy - destroy the MMU notifier + * amdgpu_mn_destroy - destroy the HMM mirror * * @work: previously sheduled work item * @@ -129,28 +131,26 @@ static void amdgpu_mn_destroy(struct work_struct *work) } up_write(>lock); mutex_unlock(>mn_lock); - mmu_notifier_unregister_no_release(>mn, amn->mm); + + hmm_mirror_unregister(>mirror); kfree(amn); } /** - * amdgpu_mn_release - callback to notify about mm destruction + * amdgpu_hmm_mirror_release - callback to notify about mm destruction * - * @mn: our notifier - * @mm: the mm this callback is about + * @mirror: the HMM mirror (mm) this callback is about * - * Shedule a work item to lazy destroy our notifier. + * Shedule a work item to lazy destroy HMM mirror. */ -static void amdgpu_mn_release(struct mmu_notifier *mn, - struct mm_struct *mm) +static void amdgpu_hmm_mirror_release(struct hmm_mirror *mirror) { - struct amdgpu_mn *amn = container_of(mn, struct amdgpu_mn, mn); + struct amdgpu_mn *amn = container_of(mirror, struct amdgpu_mn, mirror); INIT_WORK(>work, amdgpu_mn_destroy); schedule_work(>work); } - /** * amdgpu_mn_lock - take the write side lock for this notifier * @@ -237,21 +237,19 @@ static void amdgpu_mn_invalidate_node(struct amdgpu_mn_node *node, /** * amdgpu_mn_invalidate_range_start_gfx - callback to notify about mm change * - * @mn: our notifier - * @mm: the mm this callback is about - * @start: start of updated range - * @end: end of updated range + * @mirror: the hmm_mirror (mm) is about to update + * @update: the
[PATCH 1/2] drm/amdgpu: use HMM mirror callback to replace mmu notifier v5
Replace our MMU notifier with hmm_mirror_ops.sync_cpu_device_pagetables callback. Enable CONFIG_HMM and CONFIG_HMM_MIRROR as a dependency in DRM_AMDGPU_USERPTR Kconfig. It supports both KFD userptr and gfx userptr paths. This depends on several HMM patchset from Jérôme Glisse queued for upstream. Change-Id: Ie62c3c5e3c5b8521ab3b438d1eff2aa2a003835e Signed-off-by: Philip Yang --- drivers/gpu/drm/amd/amdgpu/Kconfig | 6 +- drivers/gpu/drm/amd/amdgpu/Makefile| 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c | 124 ++--- drivers/gpu/drm/amd/amdgpu/amdgpu_mn.h | 2 +- 4 files changed, 57 insertions(+), 77 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/Kconfig b/drivers/gpu/drm/amd/amdgpu/Kconfig index 9221e54..960a633 100644 --- a/drivers/gpu/drm/amd/amdgpu/Kconfig +++ b/drivers/gpu/drm/amd/amdgpu/Kconfig @@ -26,10 +26,10 @@ config DRM_AMDGPU_CIK config DRM_AMDGPU_USERPTR bool "Always enable userptr write support" depends on DRM_AMDGPU - select MMU_NOTIFIER + select HMM_MIRROR help - This option selects CONFIG_MMU_NOTIFIER if it isn't already - selected to enabled full userptr support. + This option selects CONFIG_HMM and CONFIG_HMM_MIRROR if it + isn't already selected to enabled full userptr support. config DRM_AMDGPU_GART_DEBUGFS bool "Allow GART access through debugfs" diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile b/drivers/gpu/drm/amd/amdgpu/Makefile index 138cb78..c1e5d43 100644 --- a/drivers/gpu/drm/amd/amdgpu/Makefile +++ b/drivers/gpu/drm/amd/amdgpu/Makefile @@ -171,7 +171,7 @@ endif amdgpu-$(CONFIG_COMPAT) += amdgpu_ioc32.o amdgpu-$(CONFIG_VGA_SWITCHEROO) += amdgpu_atpx_handler.o amdgpu-$(CONFIG_ACPI) += amdgpu_acpi.o -amdgpu-$(CONFIG_MMU_NOTIFIER) += amdgpu_mn.o +amdgpu-$(CONFIG_HMM) += amdgpu_mn.o include $(FULL_AMD_PATH)/powerplay/Makefile diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c index e55508b..56595b3 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c @@ -45,7 +45,7 @@ #include #include -#include +#include #include #include #include @@ -58,7 +58,6 @@ * * @adev: amdgpu device pointer * @mm: process address space - * @mn: MMU notifier structure * @type: type of MMU notifier * @work: destruction work item * @node: hash table node to find structure by adev and mn @@ -66,6 +65,7 @@ * @objects: interval tree containing amdgpu_mn_nodes * @read_lock: mutex for recursive locking of @lock * @recursion: depth of recursion + * @mirror: HMM mirror function support * * Data for each amdgpu device and process address space. */ @@ -73,7 +73,6 @@ struct amdgpu_mn { /* constant after initialisation */ struct amdgpu_device*adev; struct mm_struct*mm; - struct mmu_notifier mn; enum amdgpu_mn_type type; /* only used on destruction */ @@ -87,6 +86,9 @@ struct amdgpu_mn { struct rb_root_cached objects; struct mutexread_lock; atomic_trecursion; + + /* HMM mirror */ + struct hmm_mirror mirror; }; /** @@ -103,7 +105,7 @@ struct amdgpu_mn_node { }; /** - * amdgpu_mn_destroy - destroy the MMU notifier + * amdgpu_mn_destroy - destroy the HMM mirror * * @work: previously sheduled work item * @@ -129,28 +131,26 @@ static void amdgpu_mn_destroy(struct work_struct *work) } up_write(>lock); mutex_unlock(>mn_lock); - mmu_notifier_unregister_no_release(>mn, amn->mm); + + hmm_mirror_unregister(>mirror); kfree(amn); } /** - * amdgpu_mn_release - callback to notify about mm destruction + * amdgpu_hmm_mirror_release - callback to notify about mm destruction * - * @mn: our notifier - * @mm: the mm this callback is about + * @mirror: the HMM mirror (mm) this callback is about * - * Shedule a work item to lazy destroy our notifier. + * Shedule a work item to lazy destroy HMM mirror. */ -static void amdgpu_mn_release(struct mmu_notifier *mn, - struct mm_struct *mm) +static void amdgpu_hmm_mirror_release(struct hmm_mirror *mirror) { - struct amdgpu_mn *amn = container_of(mn, struct amdgpu_mn, mn); + struct amdgpu_mn *amn = container_of(mirror, struct amdgpu_mn, mirror); INIT_WORK(>work, amdgpu_mn_destroy); schedule_work(>work); } - /** * amdgpu_mn_lock - take the write side lock for this notifier * @@ -237,21 +237,19 @@ static void amdgpu_mn_invalidate_node(struct amdgpu_mn_node *node, /** * amdgpu_mn_invalidate_range_start_gfx - callback to notify about mm change * - * @mn: our notifier - * @mm: the mm this callback is about - * @start: start of updated range - * @end: end of updated range + * @mirror: the hmm_mirror (mm) is about to update + * @update: the update start, end address *