Commit Graph

709198 Commits

Author SHA1 Message Date
Ben Skeggs
fd542a3e52 drm/nouveau/mmu/nv50,g84: implement new vmm backend
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:29 +10:00
Ben Skeggs
6ce513529a drm/nouveau/mmu/nv44: implement new vmm backend
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:28 +10:00
Ben Skeggs
473f9aca6c drm/nouveau/mmu/nv41: implement new vmm backend
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:27 +10:00
Ben Skeggs
dd12d158eb drm/nouveau/mmu/nv04: implement new vmm backend
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:27 +10:00
Ben Skeggs
eb813999f2 drm/nouveau/mmu: implement new vmm backend
This is the common code to support a rework of the VMM backends.

It adds support for more than 2 levels of page table nesting, which
is required to be able to support GP100's MMU layout.

Sparse mappings (that don't cause MMU faults when accessed) are now
supported, where the backend provides it.

Dual-PT handling had to become more sophisticated to support sparse,
but this also allows us to support an optimisation the MMU provides
on GK104 and newer.

Certain operations can now be combined into a single page tree walk
to avoid some overhead, but also enables optimsations like skipping
PTE unmap writes when the PT will be destroyed anyway.

The old backend has been hacked up to forward requests onto the new
backend, if present, so that it's possible to bisect between issues
in the backend changes vs the upcoming frontend changes.

Until the new frontend has been merged, new backends will leak BAR2
page tables on module unload.  This is expected, and it's not worth
the effort of hacking around this as it doesn't effect runtime.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:27 +10:00
Ben Skeggs
bda9e379f6 drm/nouveau/fb/gm200: enable NV_PFB_MMU_CTRL_USE_FULL_COMP_TAG_LINE where appropriate
To avoid wasting compression tags when using 64KiB pages, we need to
enable this so we can select between upper/lower comptagline in PTEs.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:27 +10:00
Ben Skeggs
f8a1203920 drm/nouveau/ltc/gm200: limit NV_MMU_PTE_COMPTAGLINE bits to 16 where required
If NV_PFB_MMU_CTRL_USE_FULL_COMP_TAG_LINE is TRUE, then the last bit of
NV_MMU_PTE_COMPTAGLINE is re-purposed to select the upper/lower half of
a compression tag when using 64KiB big pages.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:27 +10:00
Ben Skeggs
ac47c15b76 drm/nouveau/fifo/nv04-nv40: fix missing nvkm_kmap() calls around ramfc access
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:27 +10:00
Ben Skeggs
d30af7ce2c drm/nouveau/mmu: handle instance block setup
We previously required each VMM user to allocate their own page directory
and fill in the instance block themselves.

It makes more sense to handle this in a common location.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:27 +10:00
Ben Skeggs
af3b8d5386 drm/nouveau/mmu: remove old vm creation hooks
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:26 +10:00
Ben Skeggs
8e39abff45 drm/nouveau/mmu/gp100,gp10b: implement vmm on top of new base
Adds support for:
- Selection of old/new-style page table layout (GP100MmuLayout=0/1).
- System-memory PDs.

New layout disabled by default for the moment, as we don't have a
backend that can handle it yet.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:26 +10:00
Ben Skeggs
5f300fed64 drm/nouveau/mmu/gm200,gm20b: implement vmm on top of new base
Adds support for:
- Per-VMM selection of big page size.
- System-memory PDs.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:26 +10:00
Ben Skeggs
7de078aa79 drm/nouveau/mmu/gk104,gk20a: implement vmm on top of new base
Adds support for:
- Selection of a 64KiB big page size (NvFbBigPage=16).
- System-memory PDs.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:26 +10:00
Ben Skeggs
540a1dde57 drm/nouveau/mmu/gf100: implement vmm on top of new base
Adds support for:
- Selection of a 64KiB big page size (NvFbBigPage=16).
- System-memory PDs.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:25 +10:00
Ben Skeggs
9f6219fde7 drm/nouveau/mmu/nv50,g84: implement vmm on top of new base
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:25 +10:00
Ben Skeggs
03b0ba7b54 drm/nouveau/mmu/nv44: implement vmm on top of new base
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:25 +10:00
Ben Skeggs
77783435c3 drm/nouveau/mmu/nv41: implement vmm on top of new base
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:25 +10:00
Ben Skeggs
5b17f3624e drm/nouveau/mmu/nv04: implement vmm on top of new base
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:25 +10:00
Ben Skeggs
806a733565 drm/nouveau/mmu: implement base for new vm management
This is the first chunk of the new VMM code that provides the structures
needed to describe a GPU virtual address-space layout, as well as common
interfaces to handle VMM creation, and connecting instances to a VMM.

The constructor now allocates the PD itself, rather than having the user
handle that manually.  This won't/can't be used until after all backends
have been ported to these interfaces, so a little bit of memory will be
wasted on Fermi and newer for a couple of commits in the series.

Compatibility has been hacked into the old code to allow each GPU backend
to be ported individually.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:25 +10:00
Ben Skeggs
f128039410 drm/nouveau/mmu: implement page table sub-allocation
GP100 "big" (which is a funny name, when it supports "even bigger") page
tables are small enough that we want to be able to suballocate them from
a larger block of memory.

This builds on the previous page table cache interfaces so that the VMM
code doesn't need to know the difference.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:24 +10:00
Ben Skeggs
9a45ddaaa6 drm/nouveau/mmu: implement page table cache
Builds up and maintains a small cache of each page table size in order
to reduce the frequency of expensive allocations, particularly in the
pathological case where an address range ping-pongs between allocated
and free.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:24 +10:00
Ben Skeggs
5e075fdeb1 drm/nouveau/mmu: automatically handle "un-bootstrapping" of vmm
Removes the need to expose internals outside of MMU, and GP100 is both
different, and a lot harder to deal with.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:24 +10:00
Ben Skeggs
6359c98224 drm/nouveau/mmu/gp10b: fork from gf100
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:24 +10:00
Ben Skeggs
b86a45877e drm/nouveau/mmu/gp100: fork from gf100
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:24 +10:00
Ben Skeggs
cedc4d57df drm/nouveau/mmu/gm20b: fork from gf100
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:24 +10:00
Ben Skeggs
e1e33c791a drm/nouveau/mmu/gm200: fork from gf100
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:24 +10:00
Ben Skeggs
d1f6c8d2e9 drm/nouveau/mmu/gk20a: fork from gf100
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:24 +10:00
Ben Skeggs
db018585a5 drm/nouveau/mmu/gk104: fork from gf100
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:23 +10:00
Ben Skeggs
0f43715fac drm/nouveau/mmu/g84: fork from nv50
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:23 +10:00
Ben Skeggs
b4e114f1aa drm/nouveau/fb/ram: remove old allocators
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:23 +10:00
Ben Skeggs
1de3377555 drm/nouveau: allocate vram with nvkm_ram_get()
This will cause a subtle behaviour change on GPUs that are in mixed-memory
configurations in that VRAM in the degraded section of VRAM will no longer
be used for TTM buffer objects.

That section of VRAM is not meant to be used for displayable/compressed
surfaces, and we have no reliable way with the current interfaces to be
able to make that decision properly.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:23 +10:00
Ben Skeggs
7b8656636a drm/nouveau: directly handle comptag allocation
Another transition step to allow finer-grained patches transitioning to
new MMU backends.

Old backends will continue operate as before (accessing nvkm_mem::tag),
and new backends will get a reference to the tags allocated here.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:23 +10:00
Ben Skeggs
bd275f1d1a drm/nouveau: wrap nvkm_mem objects in nvkm_memory interfaces
This is a transition step, to enable finer-grained commits while
transitioning to new MMU interfaces.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:23 +10:00
Ben Skeggs
bd447053b3 drm/nouveau/ltc/gf100-: allocate tagram with nvkm_ram_get()
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:23 +10:00
Ben Skeggs
7f4f82af6e drm/nouveau/imem/nv50: allocate memory with nvkm_ram_get()
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:23 +10:00
Ben Skeggs
2bfa0b0114 drm/nouveau/fb/ram/gt215: allocate training buffer with nvkm_ram_get()
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:23 +10:00
Ben Skeggs
e9a8b21804 drm/nouveau/fb/ram: add interface to allocate vram as an nvkm_memory object
Upcoming MMU changes use nvkm_memory as its basic representation of memory,
so we need to be able to allocate VRAM like this.

The code is basically identical to the current chipset-specific allocators,
minus support for compression tags (which will be handled elsewhere anyway).

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:23 +10:00
Ben Skeggs
c09597f083 drm/nouveau/core/memory: add some useful accessor macros
Adds support for 64-bit writes, and optimised filling of buffers with
fixed 32/64-bit values.

These will all be used by the upcoming MMU changes.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:22 +10:00
Ben Skeggs
997a89003c drm/nouveau/core/memory: add reference counting
We need to be able to prevent memory from being freed while it's still
mapped in a GPU's address-space.

Will be used by upcoming MMU changes.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:22 +10:00
Ben Skeggs
2c9c4910f8 drm/nouveau/core/memory: add mechanism to retrieve allocation granularity
Needed by VMM code to determine whether an allocation is compatible with
a given page size (ie. you can't map 4KiB system memory pages into 64KiB
GPU pages).

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:22 +10:00
Ben Skeggs
19a82e492c drm/nouveau/core/memory: change map interface to support upcoming mmu changes
Map flags (access, kind, etc) are currently defined in either the VMA,
or the memory object, which turns out to not be ideal for things like
suballocated buffers, etc.

These will become per-map flags instead, so we need to support passing
these arguments in nvkm_memory_map().

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:22 +10:00
Ben Skeggs
7f53d6dc9a drm/nouveau/core/memory: comptag allocation
nvkm_memory is going to be used by the upcoming mmu rework for the basic
representation of a memory allocation, as such, this commit adds support
for comptag allocation to nvkm_memory.

This is very simple for now, in that it requires comptags for the entire
memory allocation even if only certain ranges are compressed.

Support for tracking ranges will be added at a later date.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:22 +10:00
Ben Skeggs
6cd7670c1e drm/nouveau/ltc: init comptag mm in fb subdev
A single location for the MM allows us to share allocation logic.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:22 +10:00
Ben Skeggs
b1e839f3b3 drm/nouveau/fb/gf100: clear comptags at allocation time rather than mmu map
We probably don't want to destroy compression data when doing multiple
mappings of a memory object.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:22 +10:00
Ben Skeggs
af793b8cd9 drm/nouveau/fb: move comptag init out of ram submodule
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:22 +10:00
Ben Skeggs
7ef44bee64 drm/nouveau/fb: move comptags mm into nvkm_fb
We're moving towards having a central place to handle comptag allocation,
and as some GPUs don't have a ram submodule (ie. Tegra), we need to move
the mm somewhere else.

It probably never belonged in ram anyways.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:22 +10:00
Ben Skeggs
b7e1f3f1ba drm/nouveau/core/mm: introduce functions to access info about a given allocation
These will be used in upcoming patches.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:22 +10:00
Ben Skeggs
4d058fab63 drm/nouveau/core/mm: have users explicitly define heap identifiers
Different sections of VRAM may have different properties (ie. can't be used
for compression/display, can't be mapped, etc).

We currently already support this, but it's a bit magic.  This change makes
it more obvious where we're allocating from.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:22 +10:00
Ben Skeggs
24e8375b1b drm/nouveau: separate constant-va tracking from nvkm vma structure
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:21 +10:00
Ben Skeggs
9ce523cc3b drm/nouveau: separate buffer object backing memory from nvkm structures
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:21 +10:00