platform/kernel/linux-rpi3.git
6 years agodrm/nouveau/gem: off by one bugs in nouveau_gem_pushbuf_reloc_apply()
Dan Carpenter [Tue, 3 Jul 2018 12:30:56 +0000 (15:30 +0300)]
drm/nouveau/gem: off by one bugs in nouveau_gem_pushbuf_reloc_apply()

The bo array has req->nr_buffers elements so the > should be >= so we
don't read beyond the end of the array.

Fixes: a1606a9596e5 ("drm/nouveau: new gem pushbuf interface, bump to 0.0.16")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/kms/nv50-: ensure window updates are submitted when flushing mst disables
Ben Skeggs [Tue, 3 Jul 2018 00:52:34 +0000 (10:52 +1000)]
drm/nouveau/kms/nv50-: ensure window updates are submitted when flushing mst disables

It was possible for this to be skipped when shutting down MST streams, and
leaving the core channel interlocked with a wndw channel update that never
happens - leading to a hung display.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Tested-By: Lyude Paul <lyude@redhat.com>
6 years agodrm/nouveau/kms/nv50-: cursors always use core channel vram ctxdma
Ben Skeggs [Mon, 18 Jun 2018 08:06:13 +0000 (18:06 +1000)]
drm/nouveau/kms/nv50-: cursors always use core channel vram ctxdma

Ctxdmas for cursors from all heads are setup in the core channel, and due
to us tracking allocated handles per-window, we were failing with -EEXIST
on multiple-head setups trying to allocate duplicate handles.

The cursor code is hardcoded to use the core channel vram ctxdma already,
so just skip ctxdma allocation for cursor fbs to fix the issue.

Fixes: 5bca1621c07 ("drm/nouveau/kms/nv50-: move fb ctxdma tracking into windows")
Reported-by: Adam Borowski <kilobyte@angband.pl>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/gr/gf100-: insert some WFIs during gr init
Ben Skeggs [Wed, 16 May 2018 02:07:32 +0000 (12:07 +1000)]
drm/nouveau/gr/gf100-: insert some WFIs during gr init

Inserted wait-for-gr-idle in the places it seems that RM does it, seems
to prevent some random mmio timeouts on Quadro GV100.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/clk: Use list_for_each_entry_from_reverse
Arushi Singhal [Tue, 8 May 2018 13:13:09 +0000 (23:13 +1000)]
drm/nouveau/clk: Use list_for_each_entry_from_reverse

It's better to use "list_for_each_entry_from_reverse" for iterating list
than "for loop" as it makes the code more clear to read.
This patch replace "for loop" with "list_for_each_entry_from_reverse"
and "start" variable with "cstate" which helps in refactoring
the code and also "cstate" variable is more commonly used in the other
functions.

changes in v2:
"start" variable is removed, before "cstate" variable was removed
but "cstate" is more common so preferred "cstate" over "start".

Signed-off-by: Arushi Singhal <arushisinghal19971997@gmail.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau: fix temp/pwm visibility, skip hwmon when no sensors exist
Ilia Mirkin [Sun, 22 Apr 2018 21:47:12 +0000 (17:47 -0400)]
drm/nouveau: fix temp/pwm visibility, skip hwmon when no sensors exist

A NV34 GPU was seeing temp and pwm entries in hwmon, which would error
out when read. These should not have been visible, but also the whole
hwmon object should just not have been registered in the first place.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau: fix nouveau_dsm_get_client_id()'s return type
Luc Van Oostenryck [Tue, 24 Apr 2018 13:15:38 +0000 (15:15 +0200)]
drm/nouveau: fix nouveau_dsm_get_client_id()'s return type

The method struct vga_switcheroo_handler::get_client_id() is defined
as returning an 'enum vga_switcheroo_client_id' but the implementation
in this driver, nouveau_dsm_get_client_id(), returns an 'int'.

Fix this by returning 'enum vga_switcheroo_client_id' in this driver too.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau: fix mode_valid's return type
Luc Van Oostenryck [Tue, 24 Apr 2018 13:15:10 +0000 (15:15 +0200)]
drm/nouveau: fix mode_valid's return type

The method struct drm_connector_helper_funcs::mode_valid is defined
as returning an 'enum drm_mode_status' but the driver implementation
for this method uses an 'int' for it.

Fix this by using 'enum drm_mode_status' in the driver too.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/gr/gv100: initial support
Ben Skeggs [Tue, 8 May 2018 10:39:48 +0000 (20:39 +1000)]
drm/nouveau/gr/gv100: initial support

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/ce/gv100: initial support
Ben Skeggs [Tue, 8 May 2018 10:39:48 +0000 (20:39 +1000)]
drm/nouveau/ce/gv100: initial support

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/fifo/gv100: initial support
Ben Skeggs [Tue, 8 May 2018 10:39:48 +0000 (20:39 +1000)]
drm/nouveau/fifo/gv100: initial support

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/kms/gv100: initial support
Ben Skeggs [Tue, 8 May 2018 10:39:48 +0000 (20:39 +1000)]
drm/nouveau/kms/gv100: initial support

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/disp/gv100: initial support
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/disp/gv100: initial support

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/dma/gv100: initial support
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/dma/gv100: initial support

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/therm/gv100: initial support
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/therm/gv100: initial support

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/pmu/gv100: initial support
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/pmu/gv100: initial support

Appears to be compatible with GP102.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/fault/gv100: initial support
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/fault/gv100: initial support

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/bar/gv100: initial support
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/bar/gv100: initial support

Appears to be compatible with GM107.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/mmu/gv100: initial support
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/mmu/gv100: initial support

VEID support hacked in here, as it's the most convenient place for now.

Will be refined once it's better understood.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/ltc/gv100: initial support
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/ltc/gv100: initial support

Appears to be compatible with GP102.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/fb/gv100: initial support
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/fb/gv100: initial support

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/imem/gv100: initial support
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/imem/gv100: initial support

Can't imagine this will be any different.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/tmr/gv100: initial support
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/tmr/gv100: initial support

Appears to be compatible with GK20A.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/bus/gv100: initial support
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/bus/gv100: initial support

Appears to be compatible with GF100.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/mc/gv100: initial support
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/mc/gv100: initial support

Appears to be compatible with GP100.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/fuse/gv100: initial support
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/fuse/gv100: initial support

Appears to be compatible with GM107.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/i2c/gv100: initial support
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/i2c/gv100: initial support

Appears to be compatible with GM200.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/gpio/gv100: initial support
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/gpio/gv100: initial support

Appears to be compatible with GK104.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/ibus/gv100: initial support
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/ibus/gv100: initial support

Appears to be compatible with GM200.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/top/gv100: initial support
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/top/gv100: initial support

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/devinit/gv100: initial support
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/devinit/gv100: initial support

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/bios/pll: limits table 5.0
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/bios/pll: limits table 5.0

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/bios/gv100: initial support
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/bios/gv100: initial support

No real surprises here so far.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/pci/gv100: initial support
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/pci/gv100: initial support

Appears to be compatible with GP100.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/core: recognise gv100
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/core: recognise gv100

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/core: increase maximum number of copy engines to 9
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/core: increase maximum number of copy engines to 9

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/kms/nv50-: initial overlay support
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/kms/nv50-: initial overlay support

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/kms/gk104-: add support for [XA]2R10G10B10 formats
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/kms/gk104-: add support for [XA]2R10G10B10 formats

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/kms/gk104-: support additional cursor sizes
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/kms/gk104-: support additional cursor sizes

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/kms/nv50-: separate blocklinear vs linear pitch
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/kms/nv50-: separate blocklinear vs linear pitch

Will be required to support Volta.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/kms/nv50-: handle degamma LUT from window channels
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/kms/nv50-: handle degamma LUT from window channels

Required to eventually support DRM colour management APIs, and to
support Volta.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/kms/nv50-: plane updates don't always require image_set()
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/kms/nv50-: plane updates don't always require image_set()

When only the position of a window changes, there's no need to submit
an image update as well.

Will be required to support the overlays, and Volta windows.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/kms/nv50-: store window visibility in state
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/kms/nv50-: store window visibility in state

Window visibility is going to become a little more complicated with the
upcoming LUT changes, so store the calculated value to avoid needing to
recalculate the armed state again.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/kms/nv50-: simplify swap interval handling
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/kms/nv50-: simplify swap interval handling

This is just cleaning up some left-overs from when we needed a custom
legacy page flip implementation.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/kms/nv50-: decouple window state changes, and update method submisssion
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/kms/nv50-: decouple window state changes, and update method submisssion

This will be required to support Volta.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/kms/nv50-: simplify tracking of channel interlocks
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/kms/nv50-: simplify tracking of channel interlocks

Instead of windows returning their core channel interlock mask if they
know core has been modified, it's recorded unconditionally and used if
required when update methods are emitted.

This will be required to support Volta.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/kms/nv50-: determine MST support from DP Info Table
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/kms/nv50-: determine MST support from DP Info Table

GV100 doesn't support MST, use the information provided in VBIOS tables to
detect its presence instead.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/kms/nv50-: extend window image data for stereo/planar formats
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/kms/nv50-: extend window image data for stereo/planar formats

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/kms/nv50-: move drm format->hw conversion into common code
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/kms/nv50-: move drm format->hw conversion into common code

This will be required to support additional HW features.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/kms/nv50-: unify set/clr masks
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/kms/nv50-: unify set/clr masks

This is a simplification that'll be used to improve interlock handling.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/kms/nv50-: allow specification of valid heads for a window
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/kms/nv50-: allow specification of valid heads for a window

This will be required to support Volta, where window ID != head.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/kms/nv50-: split base implementation by hardware class
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/kms/nv50-: split base implementation by hardware class

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/kms/nv50-: split core implementation by hardware class
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/kms/nv50-: split core implementation by hardware class

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/kms/nv50-: split each resource type into their own source files
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/kms/nv50-: split each resource type into their own source files

There should be no code changes here, just shuffling stuff around.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/kms/nv50: abstract OR interfaces so the code can be split
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/kms/nv50: abstract OR interfaces so the code can be split

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/kms/nv50: handle SetControlOutputResource from head
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/kms/nv50: handle SetControlOutputResource from head

Removes duplicated code from OR-specific functions.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/kms/nv50-: abstract head interfaces so the code can be split
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/kms/nv50-: abstract head interfaces so the code can be split

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/kms/nv50: modify core allocation so the code can be split
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/kms/nv50: modify core allocation so the code can be split

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/kms/nv50-: modify base allocation so the code can be split
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/kms/nv50-: modify base allocation so the code can be split

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/kms/nv50-: modify cursor allocation so the code can be split
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/kms/nv50-: modify cursor allocation so the code can be split

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/kms/nv50-: modify overlay allocation so the code can be split
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/kms/nv50-: modify overlay allocation so the code can be split

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/kms/nv50-: move fb ctxdma tracking into windows
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/kms/nv50-: move fb ctxdma tracking into windows

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/kms/nv50-: fix i2c-over-aux on anx9805
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/kms/nv50-: fix i2c-over-aux on anx9805

We don't support address-only transactions there.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/kms/nv50-: move code underneath dispnv50/
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/kms/nv50-: move code underneath dispnv50/

The code is about to be split up, and this matches dispnv04.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/kms: move display class instantiation to library
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/kms: move display class instantiation to library

This function is useful outside of DRM code.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/drm/nv50-: remove allocation of sw class
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/drm/nv50-: remove allocation of sw class

Hasn't been required for a long time.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau: no need to create ctxdma for push buffers on fermi and up
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau: no need to create ctxdma for push buffers on fermi and up

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau: remove fence wait code from deferred client work handler
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau: remove fence wait code from deferred client work handler

Fences attached to deferred client work items now originate from channels
belonging to the client, meaning we can be certain they've been signalled
before we destroy a client.

This closes a race that could happen if the dma_fence_wait_timeout() call
didn't succeed.  When the fence was later signalled, a use-after-free was
possible.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/gem: tie deferred unmapping of buffers to VMA fence completion
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/gem: tie deferred unmapping of buffers to VMA fence completion

As VMAs are per-client, unlike buffers, this allows us to avoid referencing
foreign fences (those that belong to another client/driver) from the client
deferred work handler, and prevent some not-fun race conditions that can be
triggered when a fence stalls.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/gem: attach fences to VMAs to track GPU usage
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/gem: attach fences to VMAs to track GPU usage

An upcoming patch will use these to fix issues related to the deferred
unmapping of GEM objects.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/gem: lookup VMAs for buffers referenced by pushbuf ioctl
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/gem: lookup VMAs for buffers referenced by pushbuf ioctl

We previously only did this for push buffers, but an upcoming patch will
need to attach fences to all VMAs to resolve another issue.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/gr/gp102-: setup stencil zbc
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/gr/gp102-: setup stencil zbc

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/gr/gp100-: use correct registers for zbc colour/depth setup
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/gr/gp100-: use correct registers for zbc colour/depth setup

These were missed the first time around due to the driver version I traced
using the older registers still.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/gr/gp100-: fix attrib cb setup
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/gr/gp100-: fix attrib cb setup

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/gr/gp100-: fix pagepool setup
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/gr/gp100-: fix pagepool setup

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/gr/gf100-gm10x: update register lists
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/gr/gf100-gm10x: update register lists

There are differences on GM200 and newer too, but we can't fix them there
as they come from firmware packages.

A request has been made to NVIDIA to release updated firmware.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/gr/gf100-: swap bundle and pagepool
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/gr/gf100-: swap bundle and pagepool

Makes it easier to diff against RM traces.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/gr/gf100-: calculate and use sm mapping table
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/gr/gf100-: calculate and use sm mapping table

There's a number of places that require this data, so let's separate out
the calculations to ensure they remain consistent.

This is incorrect for GM200 and newer, but will produce the same results
as we did before.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/gr/gf100-: port zcull tile mapping calculations from NVGPU
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/gr/gf100-: port zcull tile mapping calculations from NVGPU

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/gr/gf100-: port tile mapping calculations from NVGPU
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/gr/gf100-: port tile mapping calculations from NVGPU

There's also a couple of hardcoded tables for a couple of very specific
configurations that NVGPU's algorithm didn't work for.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/gr/gf100-: virtualise trap_mp
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/gr/gf100-: virtualise trap_mp

Required to support Volta.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/gr/gf100-: add missing reset sequence before golden context init
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/gr/gf100-: add missing reset sequence before golden context init

RM and NVGPU both have a variant of this, we probably should too.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/gr/gf100-: delete duplicated grctx init code
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/gr/gf100-: delete duplicated grctx init code

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/gr/gf100-: update r408840 where required
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/gr/gf100-: update r408840 where required

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/gr/gf100-: update 419a3c where required
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/gr/gf100-: update 419a3c where required

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/gr/gf100-: virtualise r418e94
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/gr/gf100-: virtualise r418e94

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/gr/gf100-: virtualise r419e00
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/gr/gf100-: virtualise r419e00

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/gr/gf100-: update 419eb0 where required
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/gr/gf100-: update 419eb0 where required

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/gr/gf100-: note missing 418800 modifications
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/gr/gf100-: note missing 418800 modifications

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/gr/gf100-gf119: update 419cb8 where required
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/gr/gf100-gf119: update 419cb8 where required

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/gr/gf100-: support firmware-provided bundle/method everywhere
Ben Skeggs [Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)]
drm/nouveau/gr/gf100-: support firmware-provided bundle/method everywhere

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/gr/gf100-: virtualise tpc_mask + apply fixes from traces
Ben Skeggs [Tue, 8 May 2018 10:39:46 +0000 (20:39 +1000)]
drm/nouveau/gr/gf100-: virtualise tpc_mask + apply fixes from traces

We weren't placing higher TPC IDs in the right place on some configurations.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/gr/gf100-: virtualise r419f78 + apply fixes from traces
Ben Skeggs [Tue, 8 May 2018 10:39:46 +0000 (20:39 +1000)]
drm/nouveau/gr/gf100-: virtualise r419f78 + apply fixes from traces

Removed from GK110[B]/GK208 as RM traces show it not being touched.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/gr/gf100-: virtualise gpc_tpc_nr
Ben Skeggs [Tue, 8 May 2018 10:39:46 +0000 (20:39 +1000)]
drm/nouveau/gr/gf100-: virtualise gpc_tpc_nr

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/gr/gf100-: virtualise r406500
Ben Skeggs [Tue, 8 May 2018 10:39:46 +0000 (20:39 +1000)]
drm/nouveau/gr/gf100-: virtualise r406500

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/gr/gf100-: virtualise dist_skip_table + improve algorithm
Ben Skeggs [Tue, 8 May 2018 10:39:46 +0000 (20:39 +1000)]
drm/nouveau/gr/gf100-: virtualise dist_skip_table + improve algorithm

The algorithm for GM200 and newer matches RM for all the boards I have, but
I don't have enough data to try and figure something out for earlier boards,
so these will still write zeroes to the table as we did before.

The code in NVGPU isn't helpful here, it appears to handle specific cases.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/gr/gf100-gf119: modify max_ways_evict where required
Ben Skeggs [Tue, 8 May 2018 10:39:46 +0000 (20:39 +1000)]
drm/nouveau/gr/gf100-gf119: modify max_ways_evict where required

I don't think this is done after Fermi, NVGPU used to do it but removed
the code, and I've not seen RM traces touching it either.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/gr/gf100-: virtualise alpha_beta_tables + improve algorithms
Ben Skeggs [Tue, 8 May 2018 10:39:46 +0000 (20:39 +1000)]
drm/nouveau/gr/gf100-: virtualise alpha_beta_tables + improve algorithms

I haven't yet been able to find a fully programatic way of calculating the
same mapping as NVIDIA for GF100-GF119, so the algorithm partially depends
on data tables for specific configurations.

I couldn't find traces for every possibility, so the algorithm will switch
to a mapping similar to what GK104-GM10x use if it encounters one.  We did
the wrong thing before anyway, so shouldn't matter too much.

The algorithm used in the GK104 implementation was ported from NVGPU.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/gr/gf100-: virtualise rop_mapping
Ben Skeggs [Tue, 8 May 2018 10:39:46 +0000 (20:39 +1000)]
drm/nouveau/gr/gf100-: virtualise rop_mapping

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/gr/gf100-: virtualise r4060a8 + apply fixes from traces
Ben Skeggs [Tue, 8 May 2018 10:39:46 +0000 (20:39 +1000)]
drm/nouveau/gr/gf100-: virtualise r4060a8 + apply fixes from traces

Also fixes some GPUs where we write too many registers.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>