Commit graph

709252 commits

Author SHA1 Message Date
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
Ben Skeggs cb7e88e70f drm/nouveau: hang drm client of a master
TTM memory allocations will be hanging off the DRM's client, but the
locking needed to do so gets really tricky with all the other use of
the DRM's object tree.

To solve this, we make the normal DRM client a child of a new master,
where the memory allocations will be done from instead.

This also solves a potential race with client creation.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:21 +10:00
Ben Skeggs 6be4421a9f drm/nouveau: consolidate identical functions in nouveau_ttm.c
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:21 +10:00
Ben Skeggs 792067e00b drm/nouveau: remove unnecessary use of ttm_mem_type_manager::priv
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:21 +10:00
Ben Skeggs a48296ab9d drm/nouveau: swap loop order in move_notify() hook
The conditional is the same for every mapping.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:21 +10:00
Ben Skeggs 425b34f7df drm/nouveau: simplify const-va map condition
We don't really care about where the memory is, just that it's compatible
with a VMA allocated for a given page size.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:21 +10:00
Ben Skeggs 7760a2e38a drm/nouveau: split various bo flags out into their own members
It's far more convenient to deal with like this.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:20 +10:00
Ben Skeggs bc3b0c7aff drm/nouveau: remove unused sysmem fence code
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:20 +10:00
Ben Skeggs e75c091baf drm/nouveau: store nouveau_drm in nouveau_cli, as opposed to drm_device
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:20 +10:00
Ben Skeggs b6838c14a2 drm/nouveau/gr/gf100-gk208: copy big page size setting from fb
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:20 +10:00
Ben Skeggs 223eaf4bf8 drm/nouveau/gr/gf100-gk208: make use of init_gpc_mmu() hook to share setup
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:20 +10:00
Ben Skeggs 2854ab8dd8 drm/nouveau/fb: finalise big page size selection in constructor
MMU will need to know this during its constructor, so we can't delay
deciding this until init-time.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:20 +10:00
Ben Skeggs 0b11b30de9 drm/nouveau/mmu/nv04-nv4x: move global vmm to nvkm_mmu
In a future commit, this will be constructed by common code.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:20 +10:00
Ben Skeggs ffd937bbd2 drm/nouveau/imem: use fast-path for resume restore
Before: "imem: init completed in 299277us"
 After: "imem: init completed in  11574us"

Suspend from Fedora 26 gnome desktop on GP102.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:20 +10:00
Ben Skeggs e9be3c7d7a drm/nouveau/imem: use fast-path for suspend backup
Before: "imem: suspend completed in 5540487us"
 After: "imem: suspend completed in 1871526us"

Suspend from Fedora 26 gnome desktop on GP102.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:20 +10:00
Ben Skeggs b00b843046 drm/nouveau/imem: separate pre-BAR2-bootstrap objects from the rest
These will require slow-path access during suspend/resume.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:20 +10:00
Ben Skeggs 54c70e3ac6 drm/nouveau/imem: switch to kvmalloc/kvfree for suspend/resume backup
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:20 +10:00
Ben Skeggs d52ddc953e drm/nouveau/imem: separate suspend/resume backup handling into their own functions
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:19 +10:00
Ben Skeggs 71370e620a drm/nouveau/imem: remove now-unused wrapper for backend objects
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:19 +10:00
Ben Skeggs 03edf1b31a drm/nouveau/imem/nv50: support eviction of BAR2 mappings
A good deal of the structures we map into here aren't accessed very often
at all, and Fedora 26 has exposed an issue where after creating a heap of
channels, BAR2 space would run out, and we'd need to make use of the slow
path while accessing important structures like page tables.

This implements an LRU on BAR2 space, which allows eviction of mappings
that aren't currently needed, to make space for other objects.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:19 +10:00
Ben Skeggs 69b136f200 drm/nouveau/imem/nv50: prevent fast-path for mapped objects when BAR isn't ready
Another piece of solving the "GP100 BAR2 VMM bootstrap" puzzle.

Without doing this, we'd attempt to write PDEs for the lower page table
levels through BAR2 before BAR2 access has been fully initialised.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:19 +10:00
Ben Skeggs dfcbd55068 drm/nouveau/imem/nv50: map bar2 write-combined
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:19 +10:00
Ben Skeggs be55287aa5 drm/nouveau/imem/nv50: embed nvkm_instobj directly into nv04_instobj
This is not as simple as it was for earlier GPUs, due to the need to swap
accessor functions depending on whether BAR2 is usable or not.

We were previously protected by nvkm_instobj's accessor functions keeping
an object mapped permanently, with some unclear magic that managed to hit
the slow-path where needed even if an object was marked as mapped.

That's been replaced here by reference counting maps (some objects, like
page tables can be accessed concurrently), and swapping the functions as
necessary.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:19 +10:00
Ben Skeggs af515ec8d3 drm/nouveau/imem/nv50: move slow-path locking into rd/wr functions
This is to simplify upcoming changes.  The slow-path is something that
currently occurs during bootstrap of the BAR2 VMM, while backing up an
object during suspend/resume, or when BAR2 address space runs out.

The latter is a real problem that can happen at runtime, and occurs in
Fedora 26 already (due to some change that causes a lot of channels to
be created at login), so ideally we'd prefer not to make it any slower.

We'd also like suspend/resume speed to not suffer.

Upcoming commits will solve those problems in a better way, making the
extra overhead of moving the locking here a non-issue.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:19 +10:00
Ben Skeggs f584bde609 drm/nouveau/imem/nv50: split object map out from api functions
acquire()/boot() will need different logic in addition to performing
the actual mapping.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:19 +10:00
Ben Skeggs b807270cbd drm/nouveau/imem/nv40: map bar2 write-combined
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:19 +10:00
Ben Skeggs 62465ac518 drm/nouveau/imem/nv40: embed nvkm_instobj directly into nv04_instobj
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:18 +10:00
Ben Skeggs 87717e7f28 drm/nouveau/imem/nv04: directly embed nvkm_instobj into nv04_instobj
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:18 +10:00
Ben Skeggs 49814f62a2 drm/nouveau/imem: allow nvkm_instobj to be directly embedded in backend object
This will eliminate a step through the call chain, and give backends
more flexibility.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:18 +10:00
Ben Skeggs 07bbc1c5f4 drm/nouveau/core/memory: split info pointers from accessor pointers
The accessor functions can change as a result of acquire()/release() calls,
and are protected by any refcounting done there.

Other functions must remain constant, as they can be called any time.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:18 +10:00
Ben Skeggs dde59b9c34 drm/nouveau/imem: add some useful debug output
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:18 +10:00
Ben Skeggs 70433b904a drm/nouveau/bar/gm107-: wait for instance block binding to complete
Discovered by accident while working to use BAR2 access to instmem objects
on more paths.

We've apparently been relying on luck up until now!

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:18 +10:00
Ben Skeggs 8e644cb29c drm/nouveau/bar: initialise bar2 during oneinit
If we initialise BAR2 earlier, we're able to complete BAR1 setup using
the instmem fast-path.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:18 +10:00
Ben Skeggs bb7e501a66 drm/nouveau/bar: prevent BAR2 mapping of objects during destructor
GP100's page table nests a lot more deeply than the GF100-compatible
layout we're currently using, which means our hackish-but-simple way
of dealing with BAR2 VMM teardown won't work anymore.

In order to sanely handle the chicken-and-egg (BAR2's PTs get mapped
into themselves) problem, we need prevent page tables getting mapped
back into BAR2 during the destruction of its VMM.

To do this, we simply key off the state that's now maintained by the
BAR2 init/fini functions.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:18 +10:00
Ben Skeggs a78dbce9a1 drm/nouveau/bar: modify interface to bar2 vmm mapping
Match API with the BAR1 version.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:18 +10:00
Ben Skeggs 570889dc50 drm/nouveau/bar: modify interface to bar1 vmm mapping
Upcoming changes will remove the nvkm_vmm pointer from nvkm_vma, instead
requiring it to be explicitly specified on each operation.

It's not currently possible to get this information for BAR1 mappings,
so let's fix that ahead of time.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:18 +10:00
Ben Skeggs e988952eef drm/nouveau/bar: expose interface to bar2 teardown
Will prevent spurious MMU fault interrupts if something decides to touch
BAR1 after we've unloaded the driver.

Exposed external to BAR so that INSTMEM can use it to better control the
suspend/resume fast-path access.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:18 +10:00
Ben Skeggs 48fe02478a drm/nouveau/bar: expose interface to bar2 initialisation
If we want to be able to hit the instmem fast-path in a few trickier cases,
we need to be more flexible with when we can initialise BAR2 access.

There's probably a decent case to be made for merging BAR/INSTMEM into BUS,
but that's something to ponder another day.

Flushes have been added after the write to bind the instance block,
as later commits will reveal the need for them.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:18 +10:00
Ben Skeggs bbb163e189 drm/nouveau/bar: implement bar1 teardown
Will prevent spurious MMU fault interrupts if something decides to touch
BAR1 after we've unloaded the driver.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:18 +10:00
Ben Skeggs 7313cfa4f6 drm/nouveau/bar: move bar1 initialisation into its own function
BAR2 being done for practical reasons, this is just for consistency.

Flushes have been added after the write to bind the instance block,
as later commits will reveal the need for them.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:17 +10:00
Ben Skeggs 269fe32d33 drm/nouveau/bar: swap oneinit/init ordering, and rename bar3 to bar2
NVIDIA call it BAR2, Linux APIs treat it as BAR3 due to BAR1 being a
64-bit BAR, which I presume take two slots or something.

No actual code changes here, just to make future commits less messy.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:17 +10:00
Ben Skeggs c9e7059296 drm/nouveau/bar: remove NV_PMC_ENABLE_PFIFO twiddling
It's handled by FIFO preinit() now.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:17 +10:00
Ben Skeggs e69dae85c9 drm/nouveau/bar/nv50,g84: drop mmu invalidate
Will already be done by MMU as a result of the PT writes that occur
during BAR2 bootstrapping.

This is likely just a left-over from the days when it was hardcoded.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:17 +10:00
Ben Skeggs 5e721ad198 drm/nouveau/fifo: perform reset from preinit
RM appears to do this really early in its initialisation, before DEVINIT.

We currently do this before BAR2 initialisation for some reason.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:17 +10:00
Ben Skeggs b5078d731f drm/nouveau/disp: add missing newline in ior debug messages
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:17 +10:00
Ben Skeggs 12973a37c4 drm/nouveau/secboot: add missing newline in debug message
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:17 +10:00
Ben Skeggs 4246b92cf9 drm/nouveau/core/device: remove object include to prevent unnecessary rebuilds
nvkm_device hasn't subclassed nvkm_object in a long time.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2017-11-02 13:32:16 +10:00