Commit 5be73b69 authored by Jérôme Glisse's avatar Jérôme Glisse Committed by Ben Skeggs

drm/nouveau/dmem: device memory helpers for SVM

Device memory can be use in SVM, in which case we do not have any of
the existing buffer object. This commit add infrastructure to allow
use of device memory without nouveau_bo. Again this is a temporary
solution until a rework of GPU memory management.
Signed-off-by: default avatarJérôme Glisse <jglisse@redhat.com>
parent eeaf06ac
...@@ -31,6 +31,7 @@ nouveau-y += nouveau_vga.o ...@@ -31,6 +31,7 @@ nouveau-y += nouveau_vga.o
nouveau-y += nouveau_bo.o nouveau-y += nouveau_bo.o
nouveau-y += nouveau_gem.o nouveau-y += nouveau_gem.o
nouveau-$(CONFIG_DRM_NOUVEAU_SVM) += nouveau_svm.o nouveau-$(CONFIG_DRM_NOUVEAU_SVM) += nouveau_svm.o
nouveau-$(CONFIG_DRM_NOUVEAU_SVM) += nouveau_dmem.o
nouveau-y += nouveau_mem.o nouveau-y += nouveau_mem.o
nouveau-y += nouveau_prime.o nouveau-y += nouveau_prime.o
nouveau-y += nouveau_sgdma.o nouveau-y += nouveau_sgdma.o
......
...@@ -78,6 +78,7 @@ config DRM_NOUVEAU_SVM ...@@ -78,6 +78,7 @@ config DRM_NOUVEAU_SVM
depends on DRM_NOUVEAU depends on DRM_NOUVEAU
depends on STAGING depends on STAGING
select HMM_MIRROR select HMM_MIRROR
select DEVICE_PRIVATE
default n default n
help help
Say Y here if you want to enable experimental support for Say Y here if you want to enable experimental support for
......
This diff is collapsed.
/*
* Copyright 2018 Red Hat 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 __NOUVEAU_DMEM_H__
#define __NOUVEAU_DMEM_H__
#include <nvif/os.h>
struct drm_device;
struct drm_file;
struct nouveau_drm;
struct hmm_range;
#if IS_ENABLED(CONFIG_DRM_NOUVEAU_SVM)
void nouveau_dmem_init(struct nouveau_drm *);
void nouveau_dmem_fini(struct nouveau_drm *);
void nouveau_dmem_suspend(struct nouveau_drm *);
void nouveau_dmem_resume(struct nouveau_drm *);
int nouveau_dmem_migrate_vma(struct nouveau_drm *drm,
struct vm_area_struct *vma,
unsigned long start,
unsigned long end);
void nouveau_dmem_convert_pfn(struct nouveau_drm *drm,
struct hmm_range *range);
#else /* IS_ENABLED(CONFIG_DRM_NOUVEAU_SVM) */
static inline void nouveau_dmem_init(struct nouveau_drm *drm) {}
static inline void nouveau_dmem_fini(struct nouveau_drm *drm) {}
static inline void nouveau_dmem_suspend(struct nouveau_drm *drm) {}
static inline void nouveau_dmem_resume(struct nouveau_drm *drm) {}
static inline int nouveau_dmem_migrate_vma(struct nouveau_drm *drm,
struct vm_area_struct *vma,
unsigned long start,
unsigned long end)
{
return 0;
}
static inline void nouveau_dmem_convert_pfn(struct nouveau_drm *drm,
struct hmm_range *range) {}
#endif /* IS_ENABLED(CONFIG_DRM_NOUVEAU_SVM) */
#endif
...@@ -63,6 +63,7 @@ ...@@ -63,6 +63,7 @@
#include "nouveau_connector.h" #include "nouveau_connector.h"
#include "nouveau_platform.h" #include "nouveau_platform.h"
#include "nouveau_svm.h" #include "nouveau_svm.h"
#include "nouveau_dmem.h"
MODULE_PARM_DESC(config, "option string to pass to driver core"); MODULE_PARM_DESC(config, "option string to pass to driver core");
static char *nouveau_config; static char *nouveau_config;
...@@ -551,6 +552,7 @@ nouveau_drm_device_init(struct drm_device *dev) ...@@ -551,6 +552,7 @@ nouveau_drm_device_init(struct drm_device *dev)
nouveau_debugfs_init(drm); nouveau_debugfs_init(drm);
nouveau_hwmon_init(dev); nouveau_hwmon_init(dev);
nouveau_svm_init(drm); nouveau_svm_init(drm);
nouveau_dmem_init(drm);
nouveau_fbcon_init(dev); nouveau_fbcon_init(dev);
nouveau_led_init(dev); nouveau_led_init(dev);
...@@ -594,6 +596,7 @@ nouveau_drm_device_fini(struct drm_device *dev) ...@@ -594,6 +596,7 @@ nouveau_drm_device_fini(struct drm_device *dev)
nouveau_led_fini(dev); nouveau_led_fini(dev);
nouveau_fbcon_fini(dev); nouveau_fbcon_fini(dev);
nouveau_dmem_fini(drm);
nouveau_svm_fini(drm); nouveau_svm_fini(drm);
nouveau_hwmon_fini(dev); nouveau_hwmon_fini(dev);
nouveau_debugfs_fini(drm); nouveau_debugfs_fini(drm);
...@@ -741,6 +744,7 @@ nouveau_do_suspend(struct drm_device *dev, bool runtime) ...@@ -741,6 +744,7 @@ nouveau_do_suspend(struct drm_device *dev, bool runtime)
int ret; int ret;
nouveau_svm_suspend(drm); nouveau_svm_suspend(drm);
nouveau_dmem_suspend(drm);
nouveau_led_suspend(dev); nouveau_led_suspend(dev);
if (dev->mode_config.num_crtc) { if (dev->mode_config.num_crtc) {
...@@ -817,6 +821,7 @@ nouveau_do_resume(struct drm_device *dev, bool runtime) ...@@ -817,6 +821,7 @@ nouveau_do_resume(struct drm_device *dev, bool runtime)
} }
nouveau_led_resume(dev); nouveau_led_resume(dev);
nouveau_dmem_resume(drm);
nouveau_svm_resume(drm); nouveau_svm_resume(drm);
return 0; return 0;
} }
......
...@@ -212,6 +212,8 @@ struct nouveau_drm { ...@@ -212,6 +212,8 @@ struct nouveau_drm {
struct dev_pm_domain vga_pm_domain; struct dev_pm_domain vga_pm_domain;
struct nouveau_svm *svm; struct nouveau_svm *svm;
struct nouveau_dmem *dmem;
}; };
static inline struct nouveau_drm * static inline struct nouveau_drm *
......
...@@ -561,6 +561,8 @@ nouveau_svm_fault(struct nvif_notify *notify) ...@@ -561,6 +561,8 @@ nouveau_svm_fault(struct nvif_notify *notify)
goto again; goto again;
} }
nouveau_dmem_convert_pfn(svm->drm, &range);
svmm->vmm->vmm.object.client->super = true; svmm->vmm->vmm.object.client->super = true;
ret = nvif_object_ioctl(&svmm->vmm->vmm.object, ret = nvif_object_ioctl(&svmm->vmm->vmm.object,
&args, sizeof(args.i) + &args, sizeof(args.i) +
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment