Skip to contentSkip to conversation

drm/nouveau: replace "ioctl" interface between drm/nvkm

PATCH In review Ben Skeggs 4 participants 163 messages Apr 16, 2024 – Apr 22, 2024 Page 1 of 3

Subsystems (4)
lore
Share & tools
lore

Ben Skeggs

author
#0 lore raw

cover drm/nouveau: replace "ioctl" interface between drm/nvkm

This is a series of cleanups that I intended on doing after posting the initial GSP-RM support several months ago, and have now had the opportunity to work on again.

The main intention here is to replace the ioctl-like interface that sits between NVKM and the nouveau DRM driver with more direct calls, to reduce the call-chain complexity (and overhead).

This is achieved by having NVKM return structs of info and function pointers specific to each class, along with an opaque pointer to its private data. These are stored in the NVIF structs and used to call directly into an implementation without handle lookups and multiple layers of indirection.

There's room for further cleanups and API changes from here, but for now most of the API usage is exactly as it was before, as the series has gotten quite large enough already.

The first part of the series starts out by cleaning up some of the interfaces within the DRM driver, and reimplementing the subset of "ioctl" interfaces needed by userspace directly.

A number of unused interfaces/function args are then removed so that they don't need to be ported, and some initial renames/preparations are made to the NVKM's user object implementations so that diffs of the next set of patches are more straightforward to read.

I then go through each class in turn, starting from the root of the object tree (client), and working up from there. The object ctors/ dtors are ported first, followed by sclass/map/etc, followed by the class's methods, and then repeating the process with each of their children.

Objects remain accessible with the "ioctl" interface throughout the changes (until their last use, after which they're removed from the object rb entirely) to allow each change to be done independently.

After all classes have been ported, some final cleanups are made to the DRM driver to complete the series.

Ben Skeggs (156):
drm/nouveau: add nouveau_drm.device/mmu
drm/nouveau: alias nouveau_drm.client to nouveau_drm.cli drm/nouveau: pass drm to nouveau_mem_new(), instead of cli drm/nouveau: pass drm to nv50_dmac_create(), rather than device+disp drm/nouveau: pass cli to nouveau_channel_new() instead of drm+device drm/nouveau: remove nouveau_chan.device
drm/nouveau: remove chan->drm
drm/nouveau: replace some void casts with chan->cli drm/nouveau: remove nouveau_drm.master
drm/nouveau: always map device
drm/nouveau: add nouveau_cli to nouveau_abi16
drm/nouveau: handle limited nvif in abi16
drm/nouveau: remove abi16->device
drm/nouveau: remove abi16->handles
drm/nouveau: store nvkm_device pointer in nouveau_drm drm/nouveau: create pci device once
drm/nouveau: remove push pointer from nouveau_channel drm/nouveau/kms: remove a few unused struct members and fn decls drm/nouveau/kms: remove push pointer from nv50_dmac drm/nouveau/kms: move hw ring tracking vars into nvif_push drm/nouveau/kms: move dmac sync/vram ctxdmas to core+wndws drm/nouveau/nvkm: remove detect/mmio/subdev_mask from device args drm/nouveau/nvkm: move nouveau_nvif.c to nvkm/core/driver.c drm/nouveau/nvkm: move nvkm/engine/device/ to nvkm/device/ drm/nouveau/nvkm: remove perfmon
drm/nouveau/nvkm: remove nvkm_client_search() drm/nouveau/nvif: remove support for userspace backends drm/nouveau/nvif: remove route/token
drm/nouveau/nvif: remove nvxx_object()
drm/nouveau/nvif: remove nvxx_client()
drm/nouveau/nvif: remove driver keep/fini drm/nouveau/nvif: remove client version
drm/nouveau/nvif: remove client devlist
drm/nouveau/nvif: remove client fini
drm/nouveau/nvif: remove device args
drm/nouveau/nvif: remove device rd/wr
drm/nouveau/nvif: remove disp chan rd/wr
drm/nouveau/nvkm: rename struct nvkm_uevent drm/nouveau/nvkm: remove nvkm_client()
drm/nouveau/nvkm: rename struct nvkm_udevice drm/nouveau/nvkm: rename struct nvkm_control drm/nouveau/nvkm: rename struct nvkm_uvfn drm/nouveau/nvkm: rename struct nvkm_ummu drm/nouveau/nvkm: rename struct nvkm_umem drm/nouveau/nvkm: rename struct nvkm_uvmm drm/nouveau/nvkm: detach user handling from nvkm_fault_buffer drm/nouveau/nvkm: detach user handling from nvkm_disp drm/nouveau/nvkm: detach user handling from nvkm_conn drm/nouveau/nvkm: detach user handling from nvkm_outp drm/nouveau/nvkm: detach user handling from nvkm_uhead drm/nouveau/nvkm: detach user handling from nvkm_disp_chan drm/nouveau/nvkm: rename struct nvkm_ucgrp drm/nouveau/nvkm: rename struct nvkm_uchan drm/nouveau/nvkm: move umem list to mmu
drm/nouveau/disp: simplify hw user definition drm/nouveau/nvif: output oclass id in object dbg messages drm/nouveau/nvif: add alternate version of nvif_object_ctor() drm/nouveau/nvif: add alternate version of nvif_event_ctor() drm/nouveau/nvif: move nvif<->nvkm interface definitions to driverif.h drm/nouveau/nvif: rework "new driver" api drm/nouveau/nvkm: remove device list
drm/nouveau/nvif: rework driver "new client" api drm/nouveau/nvif: rework client "new device" api drm/nouveau/nvif: remove client from object rb drm/nouveau/nvif: rework device "sclass" api drm/nouveau/nvif: rework device "map" api drm/nouveau/nvif: rework device "info v0" api drm/nouveau/nvif: rework device "info v1" api drm/nouveau/nvif: rework device "time" api drm/nouveau/nvif: rework device "new ctrl" api drm/nouveau/nvif: rework ctrl "pstate info" api drm/nouveau/nvif: rework ctrl "pstate attr" api drm/nouveau/nvif: rework ctrl "pstate user" api drm/nouveau/nvif: remove ctrl from object rb drm/nouveau/nvif: rework device "new usermode" api drm/nouveau/nvif: rework usermode "map" api drm/nouveau/nvif: remove usermode from object rb drm/nouveau/nvif: rework device "new mmu" api drm/nouveau/nvif: rework mmu "sclass" api drm/nouveau/nvif: rework mmu "heap" api
drm/nouveau/nvif: rework mmu "type" api
drm/nouveau/nvif: rework mmu "kind" api
drm/nouveau/nvif: rework mmu "new mem" api drm/nouveau/nvif: rework mem "map"/"unmap" apis drm/nouveau/nvif: rework mmu "new vmm" api drm/nouveau/nvif: remove mmu from object rb drm/nouveau/nvif: rework vmm "page" api
drm/nouveau/nvif: rework vmm "get"/"put" apis drm/nouveau/nvif: rework vmm "map"/"unmap" apis drm/nouveau/nvif: rework vmm "pfnmap"/"pfnclr" apis drm/nouveau/nvif: rework vmm "raw get"/"raw put" apis drm/nouveau/nvif: rework vmm "raw map"/"raw unmap" apis drm/nouveau/nvif: rework vmm "raw sparse" api drm/nouveau/nvif: rework vmm "fault replay"/"fault cancel" apis drm/nouveau/nvif: rework device "new fault buffer" api drm/nouveau/nvif: rework fault buffer "map" api drm/nouveau/nvif: rework fault buffer "new event" api drm/nouveau/nvif: remove fault buffer from object rb drm/nouveau/nvif: rework device "new disp" api drm/nouveau/nvif: rework disp "sclass" api drm/nouveau/nvif: rework disp "new caps" api drm/nouveau/nvif: rework disp "new conn" api drm/nouveau/nvif: rework conn "new event" api drm/nouveau/nvif: remove conn from object rb drm/nouveau/nvif: rework disp "new outp" api drm/nouveau/nvif: rework outp "detect" api drm/nouveau/nvif: rework outp "edid get" api drm/nouveau/nvif: rework outp "load detect" api drm/nouveau/nvif: rework outp "inherit" apis drm/nouveau/nvif: rework outp "acquire" api drm/nouveau/nvif: rework outp "release" api drm/nouveau/nvif: rework outp "bl get"/"bl set" apis drm/nouveau/nvif: rework outp "lvds config" api drm/nouveau/nvif: rework outp "hdmi config" api drm/nouveau/nvif: rework outp "infoframe" api drm/nouveau/nvif: rework outp "hda eld" api drm/nouveau/nvif: rework outp "dp aux pwr" api drm/nouveau/nvif: rework outp "dp aux xfer" api drm/nouveau/nvif: rework outp "dp rates" api drm/nouveau/nvif: rework outp "dp train" api drm/nouveau/nvif: rework outp "dp drive" api drm/nouveau/nvif: rework outp "dp sst" api drm/nouveau/nvif: rework outp "dp mst id get"/"dp mst id put" apis drm/nouveau/nvif: rework outp "dp mst vcpi" api drm/nouveau/nvif: remove outp from object rb drm/nouveau/nvif: rework disp "new head" api drm/nouveau/nvif: rework head "scanoutpos" api drm/nouveau/nvif: rework head "new event" api drm/nouveau/nvif: remove head from object rb drm/nouveau/nvif: rework disp "new chan" apis drm/nouveau/nvif: remove disp from object rb drm/nouveau/nvif: rework disp chan "new ctxdma" api drm/nouveau/nvif: remove disp chans from object rb drm/nouveau/nvif: rework device "new cgrp" api drm/nouveau/nvif: rework device "new ctxdma" api drm/nouveau/nvif: rework device/cgrp "new chan" apis drm/nouveau/nvif: remove mem from object rb drm/nouveau/nvif: remove vmm from object rb drm/nouveau/nvif: remove ctxdma from object rb drm/nouveau/nvif: remove device from object rb drm/nouveau/nvif: rework chan "map" api
drm/nouveau/nvif: rework chan "sclass" api drm/nouveau/nvif: rework chan "new event" apis drm/nouveau/nvif: rework chan "new ctxdma" api drm/nouveau/nvif: rework chan "new engobj" apis drm/nouveau/nvif: remove chan from object rb drm/nouveau/nvif: rework engobj "mthd" api drm/nouveau/nvif: rework engobj "new event" api drm/nouveau/nvif: remove engobj from object rb drm/nouveau/nvkm: switch nvkm_object to non-irqsafe spinlock drm/nouveau: remove client_mutex
drm/nouveau: move nvxx_* definitions to nouveau_drv.h drm/nouveau: pass nouveau_drm to nvxx_*
drm/nouveau: remove remaining usage of nvif_device.info drm/nouveau: remove remaining usage of nvif_device.object.map drm/nouveau: remove remaining usage of nouveau_drm.client

 drivers/gpu/drm/nouveau/Kbuild                |   2 -
 drivers/gpu/drm/nouveau/dispnv04/arb.c        |   7 +-
 drivers/gpu/drm/nouveau/dispnv04/crtc.c       |  50 +-
 drivers/gpu/drm/nouveau/dispnv04/cursor.c     |   2 +-
 drivers/gpu/drm/nouveau/dispnv04/dac.c        |  18 +-
 drivers/gpu/drm/nouveau/dispnv04/dfp.c        |  12 +-
 drivers/gpu/drm/nouveau/dispnv04/disp.c       |  15 +-
 drivers/gpu/drm/nouveau/dispnv04/disp.h       |   6 +-
 drivers/gpu/drm/nouveau/dispnv04/hw.c         |  83 +-
 drivers/gpu/drm/nouveau/dispnv04/hw.h         |  45 +-
 drivers/gpu/drm/nouveau/dispnv04/overlay.c    |  21 +-
 drivers/gpu/drm/nouveau/dispnv04/tvnv04.c     |   4 +-
 drivers/gpu/drm/nouveau/dispnv04/tvnv17.c     |  16 +-
 drivers/gpu/drm/nouveau/dispnv04/tvnv17.h     |  10 +-
 drivers/gpu/drm/nouveau/dispnv50/base.c       |  33 +-
 drivers/gpu/drm/nouveau/dispnv50/base507c.c   |  43 +-
 drivers/gpu/drm/nouveau/dispnv50/base827c.c   |   2 +-
 drivers/gpu/drm/nouveau/dispnv50/base907c.c   |  10 +-
 drivers/gpu/drm/nouveau/dispnv50/core.c       |  84 +-
 drivers/gpu/drm/nouveau/dispnv50/core.h       |   9 +-
 drivers/gpu/drm/nouveau/dispnv50/core507d.c   |  34 +-
 drivers/gpu/drm/nouveau/dispnv50/core907d.c   |   2 +-
 drivers/gpu/drm/nouveau/dispnv50/corec37d.c   |  19 +-
 drivers/gpu/drm/nouveau/dispnv50/corec57d.c   |   4 +-
 drivers/gpu/drm/nouveau/dispnv50/crc.c        |  34 +-
 drivers/gpu/drm/nouveau/dispnv50/crc.h        |   4 +-
 drivers/gpu/drm/nouveau/dispnv50/crc907d.c    |  12 +-
 drivers/gpu/drm/nouveau/dispnv50/crcc37d.c    |  12 +-
 drivers/gpu/drm/nouveau/dispnv50/crcc57d.c    |   4 +-
 drivers/gpu/drm/nouveau/dispnv50/curs.c       |  35 +-
 drivers/gpu/drm/nouveau/dispnv50/curs507a.c   |  41 +-
 drivers/gpu/drm/nouveau/dispnv50/cursc37a.c   |  12 +-
 drivers/gpu/drm/nouveau/dispnv50/dac507d.c    |   2 +-
 drivers/gpu/drm/nouveau/dispnv50/dac907d.c    |   2 +-
 drivers/gpu/drm/nouveau/dispnv50/disp.c       | 313 +------
 drivers/gpu/drm/nouveau/dispnv50/disp.h       |  37 +-
 drivers/gpu/drm/nouveau/dispnv50/head.c       |   4 +-
 drivers/gpu/drm/nouveau/dispnv50/head507d.c   |  26 +-
 drivers/gpu/drm/nouveau/dispnv50/head827d.c   |  10 +-
 drivers/gpu/drm/nouveau/dispnv50/head907d.c   |  26 +-
 drivers/gpu/drm/nouveau/dispnv50/head917d.c   |   6 +-
 drivers/gpu/drm/nouveau/dispnv50/headc37d.c   |  18 +-
 drivers/gpu/drm/nouveau/dispnv50/headc57d.c   |  12 +-
 drivers/gpu/drm/nouveau/dispnv50/lut.c        |  12 +-
 drivers/gpu/drm/nouveau/dispnv50/lut.h        |   5 +-
 drivers/gpu/drm/nouveau/dispnv50/oimm.c       |  29 +-
 drivers/gpu/drm/nouveau/dispnv50/oimm507b.c   |  20 +-
 drivers/gpu/drm/nouveau/dispnv50/ovly.c       |  32 +-
 drivers/gpu/drm/nouveau/dispnv50/ovly507e.c   |  28 +-
 drivers/gpu/drm/nouveau/dispnv50/ovly827e.c   |   2 +-
 drivers/gpu/drm/nouveau/dispnv50/ovly907e.c   |   2 +-
 drivers/gpu/drm/nouveau/dispnv50/pior507d.c   |   2 +-
 drivers/gpu/drm/nouveau/dispnv50/sor507d.c    |   2 +-
 drivers/gpu/drm/nouveau/dispnv50/sor907d.c    |   2 +-
 drivers/gpu/drm/nouveau/dispnv50/sorc37d.c    |   2 +-
 drivers/gpu/drm/nouveau/dispnv50/wimm.c       |  25 +-
 drivers/gpu/drm/nouveau/dispnv50/wimmc37b.c   |  24 +-
 drivers/gpu/drm/nouveau/dispnv50/wndw.c       | 101 +-
 drivers/gpu/drm/nouveau/dispnv50/wndw.h       |  20 +-
 drivers/gpu/drm/nouveau/dispnv50/wndwc37e.c   |  46 +-
 drivers/gpu/drm/nouveau/dispnv50/wndwc57e.c   |  10 +-
 drivers/gpu/drm/nouveau/dispnv50/wndwc67e.c   |   2 +-
 drivers/gpu/drm/nouveau/include/nvif/cgrp.h   |  17 +
 drivers/gpu/drm/nouveau/include/nvif/chan.h   |  45 +
 drivers/gpu/drm/nouveau/include/nvif/cl0080.h |  60 --
 drivers/gpu/drm/nouveau/include/nvif/class.h  |   8 -
 drivers/gpu/drm/nouveau/include/nvif/clb069.h |  15 -
 drivers/gpu/drm/nouveau/include/nvif/client.h |  14 +-
 drivers/gpu/drm/nouveau/include/nvif/conn.h   |  24 +-
 drivers/gpu/drm/nouveau/include/nvif/ctxdma.h |  29 +
 drivers/gpu/drm/nouveau/include/nvif/device.h |  51 +-
 drivers/gpu/drm/nouveau/include/nvif/disp.h   |  19 +-
 .../gpu/drm/nouveau/include/nvif/dispchan.h   |  25 +
 drivers/gpu/drm/nouveau/include/nvif/driver.h |  27 +-
 .../gpu/drm/nouveau/include/nvif/driverif.h   | 643 +++++++++++++
 drivers/gpu/drm/nouveau/include/nvif/event.h  |  16 +-
 drivers/gpu/drm/nouveau/include/nvif/fifo.h   |  11 +-
 drivers/gpu/drm/nouveau/include/nvif/head.h   |   2 +
 drivers/gpu/drm/nouveau/include/nvif/if0000.h |  20 -
 drivers/gpu/drm/nouveau/include/nvif/if0001.h |  47 -
 drivers/gpu/drm/nouveau/include/nvif/if0002.h |  39 -
 drivers/gpu/drm/nouveau/include/nvif/if0003.h |  34 -
 drivers/gpu/drm/nouveau/include/nvif/if0008.h |  42 -
 drivers/gpu/drm/nouveau/include/nvif/if000c.h | 117 ---
 drivers/gpu/drm/nouveau/include/nvif/if000d.h |   1 -
 drivers/gpu/drm/nouveau/include/nvif/if000e.h |  26 -
 drivers/gpu/drm/nouveau/include/nvif/if0010.h |  14 -
 drivers/gpu/drm/nouveau/include/nvif/if0011.h |  18 -
 drivers/gpu/drm/nouveau/include/nvif/if0012.h | 294 ------
 drivers/gpu/drm/nouveau/include/nvif/if0013.h |  35 -
 drivers/gpu/drm/nouveau/include/nvif/if0014.h |  13 -
 drivers/gpu/drm/nouveau/include/nvif/if0020.h |  45 -
 drivers/gpu/drm/nouveau/include/nvif/if0021.h |  16 -
 drivers/gpu/drm/nouveau/include/nvif/if500d.h |   1 -
 drivers/gpu/drm/nouveau/include/nvif/if900d.h |   1 -
 drivers/gpu/drm/nouveau/include/nvif/ifb00d.h |   1 -
 drivers/gpu/drm/nouveau/include/nvif/ifc00d.h |   1 -
 drivers/gpu/drm/nouveau/include/nvif/ioctl.h  |  44 -
 drivers/gpu/drm/nouveau/include/nvif/mem.h    |  18 +-
 drivers/gpu/drm/nouveau/include/nvif/mmu.h    |  38 +-
 drivers/gpu/drm/nouveau/include/nvif/object.h | 105 +--
 drivers/gpu/drm/nouveau/include/nvif/os.h     |  19 +
 drivers/gpu/drm/nouveau/include/nvif/outp.h   |  58 +-
 drivers/gpu/drm/nouveau/include/nvif/printf.h |   9 +-
 drivers/gpu/drm/nouveau/include/nvif/push.h   |  18 +-
 drivers/gpu/drm/nouveau/include/nvif/user.h   |   6 +-
 drivers/gpu/drm/nouveau/include/nvif/vmm.h    |  30 +-
 .../drm/nouveau/include/nvkm/core/client.h    |  16 +-
 .../drm/nouveau/include/nvkm/core/device.h    |   6 -
 .../drm/nouveau/include/nvkm/core/driver.h    |   9 +
 .../gpu/drm/nouveau/include/nvkm/core/event.h |  10 +-
 .../gpu/drm/nouveau/include/nvkm/core/ioctl.h |   8 -
 .../drm/nouveau/include/nvkm/core/layout.h    |   1 -
 .../drm/nouveau/include/nvkm/core/object.h    |  43 +-
 .../drm/nouveau/include/nvkm/core/oclass.h    |   2 -
 .../gpu/drm/nouveau/include/nvkm/core/os.h    |  21 +-
 .../gpu/drm/nouveau/include/nvkm/core/pci.h   |   1 -
 .../drm/nouveau/include/nvkm/core/subdev.h    |   2 -
 .../gpu/drm/nouveau/include/nvkm/core/tegra.h |   1 -
 .../drm/nouveau/include/nvkm/engine/disp.h    |   4 +-
 .../gpu/drm/nouveau/include/nvkm/engine/dma.h |   2 -
 .../gpu/drm/nouveau/include/nvkm/engine/pm.h  |  29 -
 .../gpu/drm/nouveau/include/nvkm/subdev/mmu.h |   3 -
 drivers/gpu/drm/nouveau/nouveau_abi16.c       | 498 ++++++----
 drivers/gpu/drm/nouveau/nouveau_abi16.h       |  11 +-
 drivers/gpu/drm/nouveau/nouveau_backlight.c   |  30 +-
 drivers/gpu/drm/nouveau/nouveau_bios.c        |  22 +-
 drivers/gpu/drm/nouveau/nouveau_bios.h        |   1 +
 drivers/gpu/drm/nouveau/nouveau_bo.c          | 130 +--
 drivers/gpu/drm/nouveau/nouveau_bo0039.c      |   8 +-
 drivers/gpu/drm/nouveau/nouveau_bo5039.c      |  10 +-
 drivers/gpu/drm/nouveau/nouveau_bo74c1.c      |   2 +-
 drivers/gpu/drm/nouveau/nouveau_bo85b5.c      |   2 +-
 drivers/gpu/drm/nouveau/nouveau_bo9039.c      |   4 +-
 drivers/gpu/drm/nouveau/nouveau_bo90b5.c      |   2 +-
 drivers/gpu/drm/nouveau/nouveau_boa0b5.c      |   4 +-
 drivers/gpu/drm/nouveau/nouveau_chan.c        | 353 ++++---
 drivers/gpu/drm/nouveau/nouveau_chan.h        |  31 +-
 drivers/gpu/drm/nouveau/nouveau_connector.c   |  30 +-
 drivers/gpu/drm/nouveau/nouveau_debugfs.c     |  47 +-
 drivers/gpu/drm/nouveau/nouveau_debugfs.h     |   2 +
 drivers/gpu/drm/nouveau/nouveau_display.c     |  50 +-
 drivers/gpu/drm/nouveau/nouveau_dma.c         |  10 +-
 drivers/gpu/drm/nouveau/nouveau_dma.h         |   2 +-
 drivers/gpu/drm/nouveau/nouveau_dmem.c        |  19 +-
 drivers/gpu/drm/nouveau/nouveau_dp.c          |   2 +-
 drivers/gpu/drm/nouveau/nouveau_drm.c         | 359 +++-----
 drivers/gpu/drm/nouveau/nouveau_drv.h         |  71 +-
 drivers/gpu/drm/nouveau/nouveau_fence.c       |  33 +-
 drivers/gpu/drm/nouveau/nouveau_gem.c         |  34 +-
 drivers/gpu/drm/nouveau/nouveau_hwmon.c       |  46 +-
 drivers/gpu/drm/nouveau/nouveau_led.c         |   6 +-
 drivers/gpu/drm/nouveau/nouveau_mem.c         |  44 +-
 drivers/gpu/drm/nouveau/nouveau_mem.h         |   4 +-
 drivers/gpu/drm/nouveau/nouveau_prime.c       |   2 +-
 drivers/gpu/drm/nouveau/nouveau_sgdma.c       |   4 +-
 drivers/gpu/drm/nouveau/nouveau_svm.c         | 174 ++--
 drivers/gpu/drm/nouveau/nouveau_ttm.c         |  43 +-
 drivers/gpu/drm/nouveau/nouveau_usif.c        | 194 ----
 drivers/gpu/drm/nouveau/nouveau_usif.h        |  10 -
 drivers/gpu/drm/nouveau/nouveau_uvmm.c        |   4 +-
 drivers/gpu/drm/nouveau/nouveau_vga.c         |   8 +-
 drivers/gpu/drm/nouveau/nouveau_vmm.c         |  14 +-
 drivers/gpu/drm/nouveau/nouveau_vmm.h         |   2 +-
 drivers/gpu/drm/nouveau/nv04_fence.c          |   9 +-
 drivers/gpu/drm/nouveau/nv10_fence.c          |   6 +-
 drivers/gpu/drm/nouveau/nv10_fence.h          |   2 +-
 drivers/gpu/drm/nouveau/nv17_fence.c          |  25 +-
 drivers/gpu/drm/nouveau/nv50_fence.c          |  13 +-
 drivers/gpu/drm/nouveau/nv84_fence.c          |  20 +-
 drivers/gpu/drm/nouveau/nvc0_fence.c          |   4 +-
 drivers/gpu/drm/nouveau/nvif/Kbuild           |   3 +
 drivers/gpu/drm/nouveau/nvif/cgrp.c           |  52 ++
 drivers/gpu/drm/nouveau/nvif/chan.c           | 130 +++
 drivers/gpu/drm/nouveau/nvif/client.c         |  54 +-
 drivers/gpu/drm/nouveau/nvif/conn.c           |  53 +-
 drivers/gpu/drm/nouveau/nvif/device.c         |  67 +-
 drivers/gpu/drm/nouveau/nvif/disp.c           | 107 ++-
 drivers/gpu/drm/nouveau/nvif/dispchan.c       | 222 +++++
 drivers/gpu/drm/nouveau/nvif/driver.c         |  40 +-
 drivers/gpu/drm/nouveau/nvif/event.c          |  63 +-
 drivers/gpu/drm/nouveau/nvif/fifo.c           |  66 +-
 drivers/gpu/drm/nouveau/nvif/head.c           |  35 +-
 drivers/gpu/drm/nouveau/nvif/mem.c            | 102 ++-
 drivers/gpu/drm/nouveau/nvif/mmu.c            | 111 +--
 drivers/gpu/drm/nouveau/nvif/object.c         | 290 +-----
 drivers/gpu/drm/nouveau/nvif/outp.c           | 353 ++-----
 drivers/gpu/drm/nouveau/nvif/user.c           |  50 +-
 drivers/gpu/drm/nouveau/nvif/userc361.c       |   8 +-
 drivers/gpu/drm/nouveau/nvif/vmm.c            | 200 +---
 drivers/gpu/drm/nouveau/nvkm/Kbuild           |   1 +
 drivers/gpu/drm/nouveau/nvkm/core/Kbuild      |   2 +-
 drivers/gpu/drm/nouveau/nvkm/core/client.c    | 150 +--
 .../{nouveau_nvif.c => nvkm/core/driver.c}    |  69 +-
 drivers/gpu/drm/nouveau/nvkm/core/engine.c    |  12 -
 drivers/gpu/drm/nouveau/nvkm/core/ioctl.c     | 390 --------
 drivers/gpu/drm/nouveau/nvkm/core/object.c    | 159 +---
 drivers/gpu/drm/nouveau/nvkm/core/oproxy.c    |  76 --
 drivers/gpu/drm/nouveau/nvkm/core/subdev.c    |   8 -
 drivers/gpu/drm/nouveau/nvkm/core/uevent.c    |  88 +-
 drivers/gpu/drm/nouveau/nvkm/device/Kbuild    |   7 +
 .../nouveau/nvkm/{engine => }/device/acpi.c   |   0
 .../nouveau/nvkm/{engine => }/device/acpi.h   |   0
 .../nouveau/nvkm/{engine => }/device/base.c   | 552 +++++------
 drivers/gpu/drm/nouveau/nvkm/device/ctrl.c    | 172 ++++
 drivers/gpu/drm/nouveau/nvkm/device/ctrl.h    |   9 +
 .../nouveau/nvkm/{engine => }/device/pci.c    |   4 +-
 .../nouveau/nvkm/{engine => }/device/priv.h   |   2 -
 .../nouveau/nvkm/{engine => }/device/tegra.c  |   5 +-
 drivers/gpu/drm/nouveau/nvkm/device/user.c    | 434 +++++++++
 drivers/gpu/drm/nouveau/nvkm/device/user.h    |   9 +
 drivers/gpu/drm/nouveau/nvkm/engine/Kbuild    |   2 -
 .../gpu/drm/nouveau/nvkm/engine/device/Kbuild |   7 -
 .../gpu/drm/nouveau/nvkm/engine/device/ctrl.c | 212 -----
 .../gpu/drm/nouveau/nvkm/engine/device/ctrl.h |  13 -
 .../gpu/drm/nouveau/nvkm/engine/device/user.c | 431 ---------
 .../gpu/drm/nouveau/nvkm/engine/disp/Kbuild   |   1 +
 .../gpu/drm/nouveau/nvkm/engine/disp/ad102.c  |  13 +-
 .../gpu/drm/nouveau/nvkm/engine/disp/base.c   |  29 +-
 .../gpu/drm/nouveau/nvkm/engine/disp/chan.c   | 272 +++---
 .../gpu/drm/nouveau/nvkm/engine/disp/chan.h   |  15 +-
 .../gpu/drm/nouveau/nvkm/engine/disp/conn.h   |   2 +-
 .../gpu/drm/nouveau/nvkm/engine/disp/g84.c    |  13 +-
 .../gpu/drm/nouveau/nvkm/engine/disp/g94.c    |  13 +-
 .../gpu/drm/nouveau/nvkm/engine/disp/ga102.c  |  13 +-
 .../gpu/drm/nouveau/nvkm/engine/disp/gf119.c  |  13 +-
 .../gpu/drm/nouveau/nvkm/engine/disp/gk104.c  |  13 +-
 .../gpu/drm/nouveau/nvkm/engine/disp/gk110.c  |  13 +-
 .../gpu/drm/nouveau/nvkm/engine/disp/gm107.c  |  13 +-
 .../gpu/drm/nouveau/nvkm/engine/disp/gm200.c  |  13 +-
 .../gpu/drm/nouveau/nvkm/engine/disp/gp100.c  |  13 +-
 .../gpu/drm/nouveau/nvkm/engine/disp/gp102.c  |  13 +-
 .../gpu/drm/nouveau/nvkm/engine/disp/gt200.c  |  13 +-
 .../gpu/drm/nouveau/nvkm/engine/disp/gt215.c  |  13 +-
 .../gpu/drm/nouveau/nvkm/engine/disp/gv100.c  |  52 +-
 .../gpu/drm/nouveau/nvkm/engine/disp/head.h   |   2 +-
 .../gpu/drm/nouveau/nvkm/engine/disp/mcp77.c  |  13 +-
 .../gpu/drm/nouveau/nvkm/engine/disp/mcp89.c  |  13 +-
 .../gpu/drm/nouveau/nvkm/engine/disp/nv04.c   |   5 +-
 .../gpu/drm/nouveau/nvkm/engine/disp/nv50.c   |  20 +-
 .../gpu/drm/nouveau/nvkm/engine/disp/outp.h   |   3 +-
 .../gpu/drm/nouveau/nvkm/engine/disp/priv.h   |  31 +-
 .../gpu/drm/nouveau/nvkm/engine/disp/r535.c   |  46 +-
 .../gpu/drm/nouveau/nvkm/engine/disp/tu102.c  |  13 +-
 .../gpu/drm/nouveau/nvkm/engine/disp/ucaps.c  |  70 ++
 .../gpu/drm/nouveau/nvkm/engine/disp/ucaps.h  |   9 +
 .../gpu/drm/nouveau/nvkm/engine/disp/uchan.h  |  10 +
 .../gpu/drm/nouveau/nvkm/engine/disp/uconn.c  | 176 ++--
 .../gpu/drm/nouveau/nvkm/engine/disp/uconn.h  |   9 +
 .../gpu/drm/nouveau/nvkm/engine/disp/udisp.c  | 288 ++++--
 .../gpu/drm/nouveau/nvkm/engine/disp/udisp.h  |  17 +
 .../gpu/drm/nouveau/nvkm/engine/disp/uhead.c  | 125 +--
 .../gpu/drm/nouveau/nvkm/engine/disp/uhead.h  |   9 +
 .../gpu/drm/nouveau/nvkm/engine/disp/uoutp.c  | 778 ++++++++--------
 .../gpu/drm/nouveau/nvkm/engine/disp/uoutp.h  |   9 +
 .../gpu/drm/nouveau/nvkm/engine/dma/user.c    |  19 -
 .../drm/nouveau/nvkm/engine/dma/usergf100.c   |   5 -
 .../drm/nouveau/nvkm/engine/dma/usergf119.c   |   5 -
 .../drm/nouveau/nvkm/engine/dma/usergv100.c   |   5 -
 .../drm/nouveau/nvkm/engine/dma/usernv50.c    |   6 -
 .../gpu/drm/nouveau/nvkm/engine/fifo/Kbuild   |   1 +
 .../gpu/drm/nouveau/nvkm/engine/fifo/base.c   | 126 ---
 .../gpu/drm/nouveau/nvkm/engine/fifo/chan.c   |   2 -
 .../gpu/drm/nouveau/nvkm/engine/fifo/priv.h   |   5 -
 .../gpu/drm/nouveau/nvkm/engine/fifo/ucgrp.c  | 108 ++-
 .../gpu/drm/nouveau/nvkm/engine/fifo/ucgrp.h  |   9 +
 .../gpu/drm/nouveau/nvkm/engine/fifo/uchan.c  | 388 +++++---
 .../gpu/drm/nouveau/nvkm/engine/fifo/uchan.h  |  11 +
 .../gpu/drm/nouveau/nvkm/engine/fifo/ufifo.c  | 129 +++
 .../gpu/drm/nouveau/nvkm/engine/fifo/ufifo.h  |   8 +
 .../gpu/drm/nouveau/nvkm/engine/gr/gf100.c    |   1 -
 drivers/gpu/drm/nouveau/nvkm/engine/pm/Kbuild |  11 -
 drivers/gpu/drm/nouveau/nvkm/engine/pm/base.c | 867 ------------------
 drivers/gpu/drm/nouveau/nvkm/engine/pm/g84.c  | 165 ----
 .../gpu/drm/nouveau/nvkm/engine/pm/gf100.c    | 243 -----
 .../gpu/drm/nouveau/nvkm/engine/pm/gf100.h    |  20 -
 .../gpu/drm/nouveau/nvkm/engine/pm/gf108.c    |  66 --
 .../gpu/drm/nouveau/nvkm/engine/pm/gf117.c    |  80 --
 .../gpu/drm/nouveau/nvkm/engine/pm/gk104.c    | 184 ----
 .../gpu/drm/nouveau/nvkm/engine/pm/gt200.c    | 157 ----
 .../gpu/drm/nouveau/nvkm/engine/pm/gt215.c    | 138 ---
 drivers/gpu/drm/nouveau/nvkm/engine/pm/nv40.c | 123 ---
 drivers/gpu/drm/nouveau/nvkm/engine/pm/nv40.h |  15 -
 drivers/gpu/drm/nouveau/nvkm/engine/pm/nv50.c | 175 ----
 drivers/gpu/drm/nouveau/nvkm/engine/pm/priv.h | 105 ---
 drivers/gpu/drm/nouveau/nvkm/engine/sw/nvsw.c |  14 +-
 .../gpu/drm/nouveau/nvkm/subdev/fault/base.c  |   1 -
 .../gpu/drm/nouveau/nvkm/subdev/fault/priv.h  |   5 -
 .../gpu/drm/nouveau/nvkm/subdev/fault/user.c  |  99 +-
 .../gpu/drm/nouveau/nvkm/subdev/fault/user.h  |   9 +
 .../gpu/drm/nouveau/nvkm/subdev/mmu/base.c    |   1 -
 .../gpu/drm/nouveau/nvkm/subdev/mmu/umem.c    | 125 ++-
 .../gpu/drm/nouveau/nvkm/subdev/mmu/umem.h    |  24 +-
 .../gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c    | 186 ++--
 .../gpu/drm/nouveau/nvkm/subdev/mmu/ummu.h    |  13 +-
 .../gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c    | 357 +++-----
 .../gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.h    |  12 +-
 drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.h |   8 +-
 .../drm/nouveau/nvkm/subdev/mmu/vmmgp100.c    |  68 +-
 .../drm/nouveau/nvkm/subdev/mmu/vmmgp10b.c    |   2 +-
 .../drm/nouveau/nvkm/subdev/mmu/vmmgv100.c    |   2 +-
 .../drm/nouveau/nvkm/subdev/mmu/vmmtu102.c    |   2 +-
 .../gpu/drm/nouveau/nvkm/subdev/vfn/base.c    |   1 -
 .../gpu/drm/nouveau/nvkm/subdev/vfn/priv.h    |   3 -
 .../gpu/drm/nouveau/nvkm/subdev/vfn/uvfn.c    |  44 +-
 .../gpu/drm/nouveau/nvkm/subdev/vfn/uvfn.h    |   9 +
 306 files changed, 6653 insertions(+), 10697 deletions(-)
 create mode 100644 drivers/gpu/drm/nouveau/include/nvif/cgrp.h
 create mode 100644 drivers/gpu/drm/nouveau/include/nvif/chan.h
 delete mode 100644 drivers/gpu/drm/nouveau/include/nvif/clb069.h
 create mode 100644 drivers/gpu/drm/nouveau/include/nvif/ctxdma.h
 create mode 100644 drivers/gpu/drm/nouveau/include/nvif/dispchan.h
 create mode 100644 drivers/gpu/drm/nouveau/include/nvif/driverif.h
 delete mode 100644 drivers/gpu/drm/nouveau/include/nvif/if0000.h
 delete mode 100644 drivers/gpu/drm/nouveau/include/nvif/if0001.h
 delete mode 100644 drivers/gpu/drm/nouveau/include/nvif/if0002.h
 delete mode 100644 drivers/gpu/drm/nouveau/include/nvif/if0003.h
 delete mode 100644 drivers/gpu/drm/nouveau/include/nvif/if0008.h
 delete mode 100644 drivers/gpu/drm/nouveau/include/nvif/if000c.h
 delete mode 100644 drivers/gpu/drm/nouveau/include/nvif/if000e.h
 delete mode 100644 drivers/gpu/drm/nouveau/include/nvif/if0010.h
 delete mode 100644 drivers/gpu/drm/nouveau/include/nvif/if0012.h
 delete mode 100644 drivers/gpu/drm/nouveau/include/nvif/if0013.h
 delete mode 100644 drivers/gpu/drm/nouveau/include/nvif/if0014.h
 delete mode 100644 drivers/gpu/drm/nouveau/include/nvif/if0020.h
 delete mode 100644 drivers/gpu/drm/nouveau/include/nvif/if0021.h
 create mode 100644 drivers/gpu/drm/nouveau/include/nvkm/core/driver.h
 delete mode 100644 drivers/gpu/drm/nouveau/include/nvkm/core/ioctl.h
 delete mode 100644 drivers/gpu/drm/nouveau/include/nvkm/engine/pm.h
 delete mode 100644 drivers/gpu/drm/nouveau/nouveau_usif.c
 delete mode 100644 drivers/gpu/drm/nouveau/nouveau_usif.h
 create mode 100644 drivers/gpu/drm/nouveau/nvif/cgrp.c
 create mode 100644 drivers/gpu/drm/nouveau/nvif/chan.c
 create mode 100644 drivers/gpu/drm/nouveau/nvif/dispchan.c
 rename drivers/gpu/drm/nouveau/{nouveau_nvif.c => nvkm/core/driver.c} (65%)
 delete mode 100644 drivers/gpu/drm/nouveau/nvkm/core/ioctl.c
 create mode 100644 drivers/gpu/drm/nouveau/nvkm/device/Kbuild
 rename drivers/gpu/drm/nouveau/nvkm/{engine => }/device/acpi.c (100%)
 rename drivers/gpu/drm/nouveau/nvkm/{engine => }/device/acpi.h (100%)
 rename drivers/gpu/drm/nouveau/nvkm/{engine => }/device/base.c (89%)
 create mode 100644 drivers/gpu/drm/nouveau/nvkm/device/ctrl.c
 create mode 100644 drivers/gpu/drm/nouveau/nvkm/device/ctrl.h
 rename drivers/gpu/drm/nouveau/nvkm/{engine => }/device/pci.c (99%)
 rename drivers/gpu/drm/nouveau/nvkm/{engine => }/device/priv.h (95%)
 rename drivers/gpu/drm/nouveau/nvkm/{engine => }/device/tegra.c (97%)
 create mode 100644 drivers/gpu/drm/nouveau/nvkm/device/user.c
 create mode 100644 drivers/gpu/drm/nouveau/nvkm/device/user.h
 delete mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/device/Kbuild
 delete mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/device/ctrl.c
 delete mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/device/ctrl.h
 delete mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/device/user.c
 create mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/disp/ucaps.c
 create mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/disp/ucaps.h
 create mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/disp/uchan.h
 create mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/disp/uconn.h
 create mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.h
 create mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/disp/uhead.h
 create mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.h
 create mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/fifo/ucgrp.h
 create mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/fifo/uchan.h
 create mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/fifo/ufifo.c
 create mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/fifo/ufifo.h
 delete mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/pm/Kbuild
 delete mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/pm/base.c
 delete mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/pm/g84.c
 delete mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/pm/gf100.c
 delete mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/pm/gf100.h
 delete mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/pm/gf108.c
 delete mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/pm/gf117.c
 delete mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/pm/gk104.c
 delete mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/pm/gt200.c
 delete mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/pm/gt215.c
 delete mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/pm/nv40.c
 delete mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/pm/nv40.h
 delete mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/pm/nv50.c
 delete mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/pm/priv.h
 create mode 100644 drivers/gpu/drm/nouveau/nvkm/subdev/fault/user.h
 create mode 100644 drivers/gpu/drm/nouveau/nvkm/subdev/vfn/uvfn.h
Signature · 1 line
2.41.0
author
#1 lore raw

PATCH 1/156 drm/nouveau: add nouveau_drm.device/mmu

- removing nouveau_drm.master, and will transition to these

---
 drivers/gpu/drm/nouveau/nouveau_drm.c | 25 ++++++++++++++++++++++++-
 drivers/gpu/drm/nouveau/nouveau_drv.h |  3 +++
 2 files changed, 27 insertions(+), 1 deletion(-)
drivers/gpu/drm/nouveau/nouveau_drm.c +24 -1
index a947e1d5f309..7e651779751d 100644
@@ -603,9 +603,27 @@ nouveau_drm_device_init(struct drm_device *dev)
 	if (ret)
 		goto fail_wq;
 
+	ret = nvif_device_ctor(&drm->master.base.object, "drmDevice", 0, NV_DEVICE,
+			       &(struct nv_device_v0) {
+					.device = ~0,
+					.priv = true,
+			       }, sizeof(struct nv_device_v0),
+			       &drm->device);
+	if (ret) {
+		NV_ERROR(drm, "Device allocation failed: %d\n", ret);
+		goto fail_master;
+	}
+
+	ret = nvif_mmu_ctor(&drm->device.object, "drmMmu", drm->master.mmu.object.oclass,
+			    &drm->mmu);
+	if (ret) {
+		NV_ERROR(drm, "MMU allocation failed: %d\n", ret);
+		goto fail_nvif;
+	}
+
 	ret = nouveau_cli_init(drm, "DRM", &drm->client);
 	if (ret)
-		goto fail_master;
+		goto fail_nvif;
 
 	nvxx_client(&drm->client.base)->debug =
 		nvkm_dbgopt(nouveau_debug, "DRM");
@@ -669,6 +687,9 @@ nouveau_drm_device_init(struct drm_device *dev)
 fail_ttm:
 	nouveau_vga_fini(drm);
 	nouveau_cli_fini(&drm->client);
+fail_nvif:
+	nvif_mmu_dtor(&drm->mmu);
+	nvif_device_dtor(&drm->device);
 fail_master:
 	nouveau_cli_fini(&drm->master);
 fail_wq:
@@ -725,6 +746,8 @@ nouveau_drm_device_fini(struct drm_device *dev)
 	mutex_unlock(&drm->clients_lock);
 
 	nouveau_cli_fini(&drm->client);
+	nvif_mmu_dtor(&drm->mmu);
+	nvif_device_dtor(&drm->device);
 	nouveau_cli_fini(&drm->master);
 	destroy_workqueue(drm->sched_wq);
 	nvif_parent_dtor(&drm->parent);
drivers/gpu/drm/nouveau/nouveau_drv.h +3 -0
index e239c6bf4afa..a7079efe42f3 100644
@@ -202,6 +202,9 @@ u_memcpya(uint64_t user, unsigned int nmemb, unsigned int size)
 
 struct nouveau_drm {
 	struct nvif_parent parent;
+	struct nvif_device device;
+	struct nvif_mmu mmu;
+
 	struct nouveau_cli master;
 	struct nouveau_cli client;
 	struct drm_device *dev;
Signature · 1 line
2.41.0
author
#2 lore raw

PATCH 2/156 drm/nouveau: alias nouveau_drm.client to nouveau_drm.cli

In reply to Ben Skeggs

- first part of a rename
- later patches remove remaining usage

---
 drivers/gpu/drm/nouveau/nouveau_drm.c | 6 +++---
 drivers/gpu/drm/nouveau/nouveau_drv.h | 5 ++++-
 2 files changed, 7 insertions(+), 4 deletions(-)
drivers/gpu/drm/nouveau/nouveau_drm.c +3 -3
index 7e651779751d..be9088ed273e 100644
@@ -621,7 +621,7 @@ nouveau_drm_device_init(struct drm_device *dev)
 		goto fail_nvif;
 	}
 
-	ret = nouveau_cli_init(drm, "DRM", &drm->client);
+	ret = nouveau_cli_init(drm, "DRM", &drm->cli);
 	if (ret)
 		goto fail_nvif;
 
@@ -686,7 +686,7 @@ nouveau_drm_device_init(struct drm_device *dev)
 	nouveau_ttm_fini(drm);
 fail_ttm:
 	nouveau_vga_fini(drm);
-	nouveau_cli_fini(&drm->client);
+	nouveau_cli_fini(&drm->cli);
 fail_nvif:
 	nvif_mmu_dtor(&drm->mmu);
 	nvif_device_dtor(&drm->device);
@@ -745,7 +745,7 @@ nouveau_drm_device_fini(struct drm_device *dev)
 	}
 	mutex_unlock(&drm->clients_lock);
 
-	nouveau_cli_fini(&drm->client);
+	nouveau_cli_fini(&drm->cli);
 	nvif_mmu_dtor(&drm->mmu);
 	nvif_device_dtor(&drm->device);
 	nouveau_cli_fini(&drm->master);
drivers/gpu/drm/nouveau/nouveau_drv.h +4 -1
index a7079efe42f3..8f04f3630936 100644
@@ -206,7 +206,10 @@ struct nouveau_drm {
 	struct nvif_mmu mmu;
 
 	struct nouveau_cli master;
-	struct nouveau_cli client;
+	union {
+		struct nouveau_cli client;
+		struct nouveau_cli cli;
+	};
 	struct drm_device *dev;
 
 	struct list_head clients;
Signature · 1 line
2.41.0
author
#3 lore raw

PATCH 3/156 drm/nouveau: pass drm to nouveau_mem_new(), instead of cli

In reply to Ben Skeggs

- these only operate on drm.master these days, not per-client

---
 drivers/gpu/drm/nouveau/nouveau_mem.c   | 20 ++++++++++----------
 drivers/gpu/drm/nouveau/nouveau_mem.h   |  4 ++--
 drivers/gpu/drm/nouveau/nouveau_sgdma.c |  2 +-
 drivers/gpu/drm/nouveau/nouveau_ttm.c   |  8 ++++----
 4 files changed, 17 insertions(+), 17 deletions(-)
drivers/gpu/drm/nouveau/nouveau_mem.c +10 -10
index 25f31d5169e5..4d9ac9f30f05 100644
@@ -78,19 +78,19 @@ nouveau_mem_map(struct nouveau_mem *mem,
 void
 nouveau_mem_fini(struct nouveau_mem *mem)
 {
-	nvif_vmm_put(&mem->cli->drm->client.vmm.vmm, &mem->vma[1]);
-	nvif_vmm_put(&mem->cli->drm->client.vmm.vmm, &mem->vma[0]);
-	mutex_lock(&mem->cli->drm->master.lock);
+	nvif_vmm_put(&mem->drm->cli.vmm.vmm, &mem->vma[1]);
+	nvif_vmm_put(&mem->drm->cli.vmm.vmm, &mem->vma[0]);
+	mutex_lock(&mem->drm->master.lock);
 	nvif_mem_dtor(&mem->mem);
-	mutex_unlock(&mem->cli->drm->master.lock);
+	mutex_unlock(&mem->drm->master.lock);
 }
 
 int
 nouveau_mem_host(struct ttm_resource *reg, struct ttm_tt *tt)
 {
 	struct nouveau_mem *mem = nouveau_mem(reg);
-	struct nouveau_cli *cli = mem->cli;
-	struct nouveau_drm *drm = cli->drm;
+	struct nouveau_drm *drm = mem->drm;
+	struct nouveau_cli *cli = &drm->master;
 	struct nvif_mmu *mmu = &cli->mmu;
 	struct nvif_mem_ram_v0 args = {};
 	u8 type;
@@ -126,8 +126,8 @@ int
 nouveau_mem_vram(struct ttm_resource *reg, bool contig, u8 page)
 {
 	struct nouveau_mem *mem = nouveau_mem(reg);
-	struct nouveau_cli *cli = mem->cli;
-	struct nouveau_drm *drm = cli->drm;
+	struct nouveau_drm *drm = mem->drm;
+	struct nouveau_cli *cli = &drm->master;
 	struct nvif_mmu *mmu = &cli->mmu;
 	u64 size = ALIGN(reg->size, 1 << page);
 	int ret;
@@ -173,7 +173,7 @@ nouveau_mem_del(struct ttm_resource_manager *man, struct ttm_resource *reg)
 }
 
 int
-nouveau_mem_new(struct nouveau_cli *cli, u8 kind, u8 comp,
+nouveau_mem_new(struct nouveau_drm *drm, u8 kind, u8 comp,
 		struct ttm_resource **res)
 {
 	struct nouveau_mem *mem;
@@ -181,7 +181,7 @@ nouveau_mem_new(struct nouveau_cli *cli, u8 kind, u8 comp,
 	if (!(mem = kzalloc(sizeof(*mem), GFP_KERNEL)))
 		return -ENOMEM;
 
-	mem->cli = cli;
+	mem->drm = drm;
 	mem->kind = kind;
 	mem->comp = comp;
 
drivers/gpu/drm/nouveau/nouveau_mem.h +2 -2
index 5365a3d3a17f..a070ee049f6b 100644
@@ -8,7 +8,7 @@ struct ttm_tt;
 
 struct nouveau_mem {
 	struct ttm_resource base;
-	struct nouveau_cli *cli;
+	struct nouveau_drm *drm;
 	u8 kind;
 	u8 comp;
 	struct nvif_mem mem;
@@ -21,7 +21,7 @@ nouveau_mem(struct ttm_resource *reg)
 	return container_of(reg, struct nouveau_mem, base);
 }
 
-int nouveau_mem_new(struct nouveau_cli *, u8 kind, u8 comp,
+int nouveau_mem_new(struct nouveau_drm *, u8 kind, u8 comp,
 		    struct ttm_resource **);
 void nouveau_mem_del(struct ttm_resource_manager *man,
 		     struct ttm_resource *);
drivers/gpu/drm/nouveau/nouveau_sgdma.c +1 -1
index b14895f75b3c..172744470bd1 100644
@@ -43,7 +43,7 @@ nouveau_sgdma_bind(struct ttm_device *bdev, struct ttm_tt *ttm, struct ttm_resou
 		return ret;
 
 	if (drm->client.device.info.family < NV_DEVICE_INFO_V0_TESLA) {
-		ret = nouveau_mem_map(mem, &mem->cli->vmm.vmm, &mem->vma[0]);
+		ret = nouveau_mem_map(mem, &drm->cli.vmm.vmm, &mem->vma[0]);
 		if (ret) {
 			nouveau_mem_fini(mem);
 			return ret;
drivers/gpu/drm/nouveau/nouveau_ttm.c +4 -4
index 486f39f31a38..57c7e3ba8e7b 100644
@@ -73,7 +73,7 @@ nouveau_vram_manager_new(struct ttm_resource_manager *man,
 	if (drm->client.device.info.ram_size == 0)
 		return -ENOMEM;
 
-	ret = nouveau_mem_new(&drm->master, nvbo->kind, nvbo->comp, res);
+	ret = nouveau_mem_new(drm, nvbo->kind, nvbo->comp, res);
 	if (ret)
 		return ret;
 
@@ -105,7 +105,7 @@ nouveau_gart_manager_new(struct ttm_resource_manager *man,
 	struct nouveau_drm *drm = nouveau_bdev(bo->bdev);
 	int ret;
 
-	ret = nouveau_mem_new(&drm->master, nvbo->kind, nvbo->comp, res);
+	ret = nouveau_mem_new(drm, nvbo->kind, nvbo->comp, res);
 	if (ret)
 		return ret;
 
@@ -132,13 +132,13 @@ nv04_gart_manager_new(struct ttm_resource_manager *man,
 	struct nouveau_mem *mem;
 	int ret;
 
-	ret = nouveau_mem_new(&drm->master, nvbo->kind, nvbo->comp, res);
+	ret = nouveau_mem_new(drm, nvbo->kind, nvbo->comp, res);
 	if (ret)
 		return ret;
 
 	mem = nouveau_mem(*res);
 	ttm_resource_init(bo, place, *res);
-	ret = nvif_vmm_get(&mem->cli->vmm.vmm, PTES, false, 12, 0,
+	ret = nvif_vmm_get(&drm->cli.vmm.vmm, PTES, false, 12, 0,
 			   (long)(*res)->size, &mem->vma[0]);
 	if (ret) {
 		nouveau_mem_del(man, *res);
Signature · 1 line
2.41.0
author
#4 lore raw

PATCH 4/156 drm/nouveau: pass drm to nv50_dmac_create(), rather than device+disp

In reply to Ben Skeggs

- zero reason to do otherwise

---
 drivers/gpu/drm/nouveau/dispnv50/base507c.c | 3 +--
 drivers/gpu/drm/nouveau/dispnv50/core507d.c | 2 +-
 drivers/gpu/drm/nouveau/dispnv50/disp.c     | 7 ++++---
 drivers/gpu/drm/nouveau/dispnv50/disp.h     | 2 +-
 drivers/gpu/drm/nouveau/dispnv50/ovly507e.c | 2 +-
 drivers/gpu/drm/nouveau/dispnv50/wimmc37b.c | 3 +--
 drivers/gpu/drm/nouveau/dispnv50/wndwc37e.c | 2 +-
 7 files changed, 10 insertions(+), 11 deletions(-)
drivers/gpu/drm/nouveau/dispnv50/base507c.c +1 -2
index 70c62b861276..e36a473f2075 100644
@@ -307,7 +307,6 @@ base507c_new_(const struct nv50_wndw_func *func, const u32 *format,
 	struct nvif_disp_chan_v0 args = {
 		.id = head,
 	};
-	struct nouveau_display *disp = nouveau_display(drm->dev);
 	struct nv50_disp *disp50 = nv50_disp(drm->dev);
 	struct nv50_wndw *wndw;
 	int ret;
@@ -318,7 +317,7 @@ base507c_new_(const struct nv50_wndw_func *func, const u32 *format,
 	if (*pwndw = wndw, ret)
 		return ret;
 
-	ret = nv50_dmac_create(&drm->client.device, &disp->disp.object,
+	ret = nv50_dmac_create(drm,
 			       &oclass, head, &args, sizeof(args),
 			       disp50->sync->offset, &wndw->wndw);
 	if (ret) {
drivers/gpu/drm/nouveau/dispnv50/core507d.c +1 -1
index e5bb5ca950c8..85845e3dc7ba 100644
@@ -166,7 +166,7 @@ core507d_new_(const struct nv50_core_func *func, struct nouveau_drm *drm,
 		return -ENOMEM;
 	core->func = func;
 
-	ret = nv50_dmac_create(&drm->client.device, &disp->disp->object,
+	ret = nv50_dmac_create(drm,
 			       &oclass, 0, &args, sizeof(args),
 			       disp->sync->offset, &core->chan);
 	if (ret) {
drivers/gpu/drm/nouveau/dispnv50/disp.c +4 -3
index 0c3d88ad0b0e..f8ca57cc7af6 100644
@@ -226,11 +226,12 @@ static int nv50_dmac_vram_pushbuf = -1;
 module_param_named(kms_vram_pushbuf, nv50_dmac_vram_pushbuf, int, 0400);
 
 int
-nv50_dmac_create(struct nvif_device *device, struct nvif_object *disp,
+nv50_dmac_create(struct nouveau_drm *drm,
 		 const s32 *oclass, u8 head, void *data, u32 size, s64 syncbuf,
 		 struct nv50_dmac *dmac)
 {
-	struct nouveau_cli *cli = (void *)device->object.client;
+	struct nvif_device *device = &drm->device;
+	struct nvif_object *disp = &drm->display->disp.object;
 	struct nvif_disp_chan_v0 *args = data;
 	u8 type = NVIF_MEM_COHERENT;
 	int ret;
@@ -250,7 +251,7 @@ nv50_dmac_create(struct nvif_device *device, struct nvif_object *disp,
 	    (nv50_dmac_vram_pushbuf < 0 && device->info.family == NV_DEVICE_INFO_V0_PASCAL))
 		type |= NVIF_MEM_VRAM;
 
-	ret = nvif_mem_ctor_map(&cli->mmu, "kmsChanPush", type, 0x1000,
+	ret = nvif_mem_ctor_map(&drm->mmu, "kmsChanPush", type, 0x1000,
 				&dmac->_push.mem);
 	if (ret)
 		return ret;
drivers/gpu/drm/nouveau/dispnv50/disp.h +1 -1
index 5508a7cfd492..da3add95f354 100644
@@ -95,7 +95,7 @@ struct nv50_outp_atom {
 	} set, clr;
 };
 
-int nv50_dmac_create(struct nvif_device *device, struct nvif_object *disp,
+int nv50_dmac_create(struct nouveau_drm *,
 		     const s32 *oclass, u8 head, void *data, u32 size,
 		     s64 syncbuf, struct nv50_dmac *dmac);
 void nv50_dmac_destroy(struct nv50_dmac *);
drivers/gpu/drm/nouveau/dispnv50/ovly507e.c +1 -1
index 797c1e4e0eaa..73fcfb27c32c 100644
@@ -159,7 +159,7 @@ ovly507e_new_(const struct nv50_wndw_func *func, const u32 *format,
 	if (*pwndw = wndw, ret)
 		return ret;
 
-	ret = nv50_dmac_create(&drm->client.device, &disp->disp->object,
+	ret = nv50_dmac_create(drm,
 			       &oclass, 0, &args, sizeof(args),
 			       disp->sync->offset, &wndw->wndw);
 	if (ret) {
drivers/gpu/drm/nouveau/dispnv50/wimmc37b.c +1 -2
index ee76b091d4ef..8cb5b79bacbf 100644
@@ -71,10 +71,9 @@ wimmc37b_init_(const struct nv50_wimm_func *func, struct nouveau_drm *drm,
 	struct nvif_disp_chan_v0 args = {
 		.id = wndw->id,
 	};
-	struct nv50_disp *disp = nv50_disp(drm->dev);
 	int ret;
 
-	ret = nv50_dmac_create(&drm->client.device, &disp->disp->object,
+	ret = nv50_dmac_create(drm,
 			       &oclass, 0, &args, sizeof(args), -1,
 			       &wndw->wimm);
 	if (ret) {
drivers/gpu/drm/nouveau/dispnv50/wndwc37e.c +1 -1
index b3deea5aca58..caf40977f455 100644
@@ -363,7 +363,7 @@ wndwc37e_new_(const struct nv50_wndw_func *func, struct nouveau_drm *drm,
 	if (*pwndw = wndw, ret)
 		return ret;
 
-	ret = nv50_dmac_create(&drm->client.device, &disp->disp->object,
+	ret = nv50_dmac_create(drm,
 			       &oclass, 0, &args, sizeof(args),
 			       disp->sync->offset, &wndw->wndw);
 	if (ret) {
Signature · 1 line
2.41.0
#5 lore raw

Re: [PATCH 004/156] drm/nouveau: pass drm to nv50_dmac_create(), rather than device+disp

Quoted 1 line · Ben Skeggs

- zero reason to do otherwise

to do _what_ otherwise? that refers to the title, it seems. But one could describe why it was ever done that way (older architecture? bug? mistake?) in the first place.

The commit messages in this entire series are extremely short and only really comprehensible by the author.

This example here especially.

The messages should first briefly introduce what the current state is, why that's a problem and what the commit does about it.

P.

Quoted 156 lines

---
 drivers/gpu/drm/nouveau/dispnv50/base507c.c | 3 +-- drivers/gpu/drm/nouveau/dispnv50/core507d.c | 2 +- drivers/gpu/drm/nouveau/dispnv50/disp.c     | 7 ++++--- drivers/gpu/drm/nouveau/dispnv50/disp.h     | 2 +-

 drivers/gpu/drm/nouveau/dispnv50/ovly507e.c | 2 +-
 drivers/gpu/drm/nouveau/dispnv50/wimmc37b.c | 3 +--
 drivers/gpu/drm/nouveau/dispnv50/wndwc37e.c | 2 +-
 7 files changed, 10 insertions(+), 11 deletions(-)
drivers/gpu/drm/nouveau/dispnv50/base507c.c +0 -1
index 70c62b861276..e36a473f2075 100644
@@ -307,7 +307,6 @@ base507c_new_(const struct nv50_wndw_func *func,
 const u32 *format,
         struct nvif_disp_chan_v0 args = {
                 .id = head,
         };
-       struct nouveau_display *disp = nouveau_display(drm->dev);
         struct nv50_disp *disp50 = nv50_disp(drm->dev);
         struct nv50_wndw *wndw;

        int ret;

drivers/gpu/drm/nouveau/dispnv50/base507c.c +0 -0
@@ -318,7 +317,7 @@ base507c_new_(const struct nv50_wndw_func *func,
 const u32 *format,
         if (*pwndw = wndw, ret)
                 return ret;


-       ret = nv50_dmac_create(&drm->client.device, &disp-

Quoted 1 line

disp.object,

+       ret = nv50_dmac_create(drm,
                               &oclass, head, &args, sizeof(args), disp50->sync->offset, &wndw->wndw); if (ret) {

drivers/gpu/drm/nouveau/dispnv50/core507d.c +0 -0
index e5bb5ca950c8..85845e3dc7ba 100644
@@ -166,7 +166,7 @@ core507d_new_(const struct nv50_core_func *func,
 struct nouveau_drm *drm,
                 return -ENOMEM;
         core->func = func;


-       ret = nv50_dmac_create(&drm->client.device, &disp->disp-

Quoted 1 line

object,

+       ret = nv50_dmac_create(drm,
                               &oclass, 0, &args, sizeof(args), disp->sync->offset, &core->chan); if (ret) {

drivers/gpu/drm/nouveau/dispnv50/disp.c +0 -0
index 0c3d88ad0b0e..f8ca57cc7af6 100644
@@ -226,11 +226,12 @@ static int nv50_dmac_vram_pushbuf = -1;
  module_param_named(kms_vram_pushbuf, nv50_dmac_vram_pushbuf, int,
 0400);


 int
-nv50_dmac_create(struct nvif_device *device, struct nvif_object *disp,
+nv50_dmac_create(struct nouveau_drm *drm,
                 const s32 *oclass, u8 head, void *data, u32 size, s64 syncbuf,
                 struct nv50_dmac *dmac)
 {
-       struct nouveau_cli *cli = (void *)device->object.client; +       struct nvif_device *device = &drm->device;
+       struct nvif_object *disp = &drm->display->disp.object; struct nvif_disp_chan_v0 *args = data;
        u8 type = NVIF_MEM_COHERENT;
        int ret;

drivers/gpu/drm/nouveau/dispnv50/disp.c +0 -0
@@ -250,7 +251,7 @@ nv50_dmac_create(struct nvif_device *device,
 struct nvif_object *disp,

            (nv50_dmac_vram_pushbuf < 0 && device->info.family == NV_DEVICE_INFO_V0_PASCAL))
                type |= NVIF_MEM_VRAM;

-       ret = nvif_mem_ctor_map(&cli->mmu, "kmsChanPush", type, 0x1000,
+       ret = nvif_mem_ctor_map(&drm->mmu, "kmsChanPush", type, 0x1000,
                                &dmac->_push.mem);
        if (ret)
                return ret;

drivers/gpu/drm/nouveau/dispnv50/disp.h +0 -0
index 5508a7cfd492..da3add95f354 100644
@@ -95,7 +95,7 @@ struct nv50_outp_atom {
         } set, clr;
  };


-int nv50_dmac_create(struct nvif_device *device, struct nvif_object *disp,
+int nv50_dmac_create(struct nouveau_drm *,
                     const s32 *oclass, u8 head, void *data, u32 size,
                     s64 syncbuf, struct nv50_dmac *dmac); void nv50_dmac_destroy(struct nv50_dmac *);

drivers/gpu/drm/nouveau/dispnv50/ovly507e.c +0 -0
index 797c1e4e0eaa..73fcfb27c32c 100644
@@ -159,7 +159,7 @@ ovly507e_new_(const struct nv50_wndw_func *func,
 const u32 *format,
         if (*pwndw = wndw, ret)
                 return ret;


-       ret = nv50_dmac_create(&drm->client.device, &disp->disp-

Quoted 1 line

object,

+       ret = nv50_dmac_create(drm,
                               &oclass, 0, &args, sizeof(args), disp->sync->offset, &wndw->wndw); if (ret) {

drivers/gpu/drm/nouveau/dispnv50/wimmc37b.c +0 -1
index ee76b091d4ef..8cb5b79bacbf 100644
@@ -71,10 +71,9 @@ wimmc37b_init_(const struct nv50_wimm_func *func,
 struct nouveau_drm *drm,
         struct nvif_disp_chan_v0 args = {
                 .id = wndw->id,
         };
-       struct nv50_disp *disp = nv50_disp(drm->dev);
         int ret;


-       ret = nv50_dmac_create(&drm->client.device, &disp->disp-

Quoted 1 line

object,

+       ret = nv50_dmac_create(drm,
                               &oclass, 0, &args, sizeof(args), -1, &wndw->wimm);
        if (ret) {

drivers/gpu/drm/nouveau/dispnv50/wndwc37e.c +0 -0
index b3deea5aca58..caf40977f455 100644
@@ -363,7 +363,7 @@ wndwc37e_new_(const struct nv50_wndw_func *func,
 struct nouveau_drm *drm,
         if (*pwndw = wndw, ret)
                 return ret;


-       ret = nv50_dmac_create(&drm->client.device, &disp->disp-

Quoted 1 line

object,

+       ret = nv50_dmac_create(drm,
                               &oclass, 0, &args, sizeof(args), disp->sync->offset, &wndw->wndw); if (ret) {

author
#6 lore raw

PATCH 5/156 drm/nouveau: pass cli to nouveau_channel_new() instead of drm+device

In reply to Ben Skeggs

- both of these are stored in nouveau_cli already

---
 drivers/gpu/drm/nouveau/nouveau_abi16.c |  2 +-
 drivers/gpu/drm/nouveau/nouveau_chan.c  | 17 +++++++++--------
 drivers/gpu/drm/nouveau/nouveau_chan.h  |  3 ++-
 drivers/gpu/drm/nouveau/nouveau_drm.c   |  4 ++--
 4 files changed, 14 insertions(+), 12 deletions(-)
drivers/gpu/drm/nouveau/nouveau_abi16.c +1 -1
index f465fe93b1f7..291107ddc59b 100644
@@ -353,7 +353,7 @@ nouveau_abi16_ioctl_channel_alloc(ABI16_IOCTL_ARGS)
 	list_add(&chan->head, &abi16->channels);
 
 	/* create channel object and initialise dma and fence management */
-	ret = nouveau_channel_new(drm, device, false, runm, init->fb_ctxdma_handle,
+	ret = nouveau_channel_new(cli, false, runm, init->fb_ctxdma_handle,
 				  init->tt_ctxdma_handle, &chan->chan);
 	if (ret)
 		goto done;
drivers/gpu/drm/nouveau/nouveau_chan.c +9 -8
index 7c97b2886807..290523522717 100644
@@ -142,10 +142,11 @@ nouveau_channel_wait(struct nvif_push *push, u32 size)
 }
 
 static int
-nouveau_channel_prep(struct nouveau_drm *drm, struct nvif_device *device,
+nouveau_channel_prep(struct nouveau_cli *cli,
 		     u32 size, struct nouveau_channel **pchan)
 {
-	struct nouveau_cli *cli = (void *)device->object.client;
+	struct nouveau_drm *drm = cli->drm;
+	struct nvif_device *device = &cli->device;
 	struct nv_dma_v0 args = {};
 	struct nouveau_channel *chan;
 	u32 target;
@@ -155,6 +156,7 @@ nouveau_channel_prep(struct nouveau_drm *drm, struct nvif_device *device,
 	if (!chan)
 		return -ENOMEM;
 
+	chan->cli = cli;
 	chan->device = device;
 	chan->drm = drm;
 	chan->vmm = nouveau_cli_vmm(cli);
@@ -254,7 +256,7 @@ nouveau_channel_prep(struct nouveau_drm *drm, struct nvif_device *device,
 }
 
 static int
-nouveau_channel_ctor(struct nouveau_drm *drm, struct nvif_device *device, bool priv, u64 runm,
+nouveau_channel_ctor(struct nouveau_cli *cli, bool priv, u64 runm,
 		     struct nouveau_channel **pchan)
 {
 	const struct nvif_mclass hosts[] = {
@@ -279,7 +281,7 @@ nouveau_channel_ctor(struct nouveau_drm *drm, struct nvif_device *device, bool p
 		struct nvif_chan_v0 chan;
 		char name[TASK_COMM_LEN+16];
 	} args;
-	struct nouveau_cli *cli = (void *)device->object.client;
+	struct nvif_device *device = &cli->device;
 	struct nouveau_channel *chan;
 	const u64 plength = 0x10000;
 	const u64 ioffset = plength;
@@ -298,7 +300,7 @@ nouveau_channel_ctor(struct nouveau_drm *drm, struct nvif_device *device, bool p
 		size = ioffset + ilength;
 
 	/* allocate dma push buffer */
-	ret = nouveau_channel_prep(drm, device, size, &chan);
+	ret = nouveau_channel_prep(cli, size, &chan);
 	*pchan = chan;
 	if (ret)
 		return ret;
@@ -493,13 +495,12 @@ nouveau_channel_init(struct nouveau_channel *chan, u32 vram, u32 gart)
 }
 
 int
-nouveau_channel_new(struct nouveau_drm *drm, struct nvif_device *device,
+nouveau_channel_new(struct nouveau_cli *cli,
 		    bool priv, u64 runm, u32 vram, u32 gart, struct nouveau_channel **pchan)
 {
-	struct nouveau_cli *cli = (void *)device->object.client;
 	int ret;
 
-	ret = nouveau_channel_ctor(drm, device, priv, runm, pchan);
+	ret = nouveau_channel_ctor(cli, priv, runm, pchan);
 	if (ret) {
 		NV_PRINTK(dbg, cli, "channel create, %d\n", ret);
 		return ret;
drivers/gpu/drm/nouveau/nouveau_chan.h +2 -1
index 5de2ef4e98c2..260febd634ee 100644
@@ -12,6 +12,7 @@ struct nouveau_channel {
 		struct nvif_push *push;
 	} chan;
 
+	struct nouveau_cli *cli;
 	struct nvif_device *device;
 	struct nouveau_drm *drm;
 	struct nouveau_vmm *vmm;
@@ -62,7 +63,7 @@ struct nouveau_channel {
 int nouveau_channels_init(struct nouveau_drm *);
 void nouveau_channels_fini(struct nouveau_drm *);
 
-int  nouveau_channel_new(struct nouveau_drm *, struct nvif_device *, bool priv, u64 runm,
+int  nouveau_channel_new(struct nouveau_cli *, bool priv, u64 runm,
 			 u32 vram, u32 gart, struct nouveau_channel **);
 void nouveau_channel_del(struct nouveau_channel **);
 int  nouveau_channel_idle(struct nouveau_channel *);
drivers/gpu/drm/nouveau/nouveau_drm.c +2 -2
index be9088ed273e..da5bb7c51dab 100644
@@ -356,7 +356,7 @@ nouveau_accel_ce_init(struct nouveau_drm *drm)
 		return;
 	}
 
-	ret = nouveau_channel_new(drm, device, false, runm, NvDmaFB, NvDmaTT, &drm->cechan);
+	ret = nouveau_channel_new(&drm->cli, false, runm, NvDmaFB, NvDmaTT, &drm->cechan);
 	if (ret)
 		NV_ERROR(drm, "failed to create ce channel, %d\n", ret);
 }
@@ -384,7 +384,7 @@ nouveau_accel_gr_init(struct nouveau_drm *drm)
 		return;
 	}
 
-	ret = nouveau_channel_new(drm, device, false, runm, NvDmaFB, NvDmaTT, &drm->channel);
+	ret = nouveau_channel_new(&drm->cli, false, runm, NvDmaFB, NvDmaTT, &drm->channel);
 	if (ret) {
 		NV_ERROR(drm, "failed to create kernel channel, %d\n", ret);
 		nouveau_accel_gr_fini(drm);
Signature · 1 line
2.41.0
author
#7 lore raw

PATCH 6/156 drm/nouveau: remove nouveau_chan.device

In reply to Ben Skeggs

- not required for anything

---
 drivers/gpu/drm/nouveau/nouveau_chan.c | 3 +--
 drivers/gpu/drm/nouveau/nouveau_chan.h | 1 -
 2 files changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/nouveau/nouveau_chan.c +1 -2
index 290523522717..e4065b7f1f9f 100644
@@ -157,7 +157,6 @@ nouveau_channel_prep(struct nouveau_cli *cli,
 		return -ENOMEM;
 
 	chan->cli = cli;
-	chan->device = device;
 	chan->drm = drm;
 	chan->vmm = nouveau_cli_vmm(cli);
 	atomic_set(&chan->killed, 0);
@@ -365,8 +364,8 @@ nouveau_channel_ctor(struct nouveau_cli *cli, bool priv, u64 runm,
 static int
 nouveau_channel_init(struct nouveau_channel *chan, u32 vram, u32 gart)
 {
-	struct nvif_device *device = chan->device;
 	struct nouveau_drm *drm = chan->drm;
+	struct nvif_device *device = &drm->device;
 	struct nv_dma_v0 args = {};
 	int ret, i;
 
drivers/gpu/drm/nouveau/nouveau_chan.h +0 -1
index 260febd634ee..18a9cbfef8ca 100644
@@ -13,7 +13,6 @@ struct nouveau_channel {
 	} chan;
 
 	struct nouveau_cli *cli;
-	struct nvif_device *device;
 	struct nouveau_drm *drm;
 	struct nouveau_vmm *vmm;
 
Signature · 1 line
2.41.0
author
#8 lore raw

PATCH 7/156 drm/nouveau: remove chan->drm

In reply to Ben Skeggs

- can be accessed via chan->cli->drm

---
 drivers/gpu/drm/nouveau/dispnv04/crtc.c  |  4 ++--
 drivers/gpu/drm/nouveau/nouveau_bo0039.c |  2 +-
 drivers/gpu/drm/nouveau/nouveau_bo5039.c |  2 +-
 drivers/gpu/drm/nouveau/nouveau_chan.c   | 25 ++++++++++--------------
 drivers/gpu/drm/nouveau/nouveau_chan.h   |  1 -
 drivers/gpu/drm/nouveau/nouveau_dma.c    |  2 +-
 drivers/gpu/drm/nouveau/nouveau_fence.c  | 15 +++++++-------
 drivers/gpu/drm/nouveau/nouveau_gem.c    |  7 ++++---
 drivers/gpu/drm/nouveau/nv17_fence.c     |  6 +++---
 drivers/gpu/drm/nouveau/nv50_fence.c     |  2 +-
 drivers/gpu/drm/nouveau/nv84_fence.c     |  8 ++++----
 11 files changed, 35 insertions(+), 39 deletions(-)
drivers/gpu/drm/nouveau/dispnv04/crtc.c +2 -2
index 4310ad71870b..8f2fd5d9dcb7 100644
@@ -1042,7 +1042,7 @@ nv04_finish_page_flip(struct nouveau_channel *chan,
 		      struct nv04_page_flip_state *ps)
 {
 	struct nouveau_fence_chan *fctx = chan->fence;
-	struct nouveau_drm *drm = chan->drm;
+	struct nouveau_drm *drm = chan->cli->drm;
 	struct drm_device *dev = drm->dev;
 	struct nv04_page_flip_state *s;
 	unsigned long flags;
@@ -1098,7 +1098,7 @@ nv04_page_flip_emit(struct nouveau_channel *chan,
 		    struct nouveau_fence **pfence)
 {
 	struct nouveau_fence_chan *fctx = chan->fence;
-	struct nouveau_drm *drm = chan->drm;
+	struct nouveau_drm *drm = chan->cli->drm;
 	struct drm_device *dev = drm->dev;
 	struct nvif_push *push = chan->chan.push;
 	unsigned long flags;
drivers/gpu/drm/nouveau/nouveau_bo0039.c +1 -1
index e2ce44adaa5c..2babc6c47241 100644
@@ -104,6 +104,6 @@ nv04_bo_move_init(struct nouveau_channel *chan, u32 handle)
 		return ret;
 
 	PUSH_MTHD(push, NV039, SET_OBJECT, handle);
-	PUSH_MTHD(push, NV039, SET_CONTEXT_DMA_NOTIFIES, chan->drm->ntfy.handle);
+	PUSH_MTHD(push, NV039, SET_CONTEXT_DMA_NOTIFIES, chan->cli->drm->ntfy.handle);
 	return 0;
 }
drivers/gpu/drm/nouveau/nouveau_bo5039.c +1 -1
index c6cf3629a9f9..0a6b1fce1108 100644
@@ -144,7 +144,7 @@ nv50_bo_move_init(struct nouveau_channel *chan, u32 handle)
 		return ret;
 
 	PUSH_MTHD(push, NV5039, SET_OBJECT, handle);
-	PUSH_MTHD(push, NV5039, SET_CONTEXT_DMA_NOTIFY, chan->drm->ntfy.handle,
+	PUSH_MTHD(push, NV5039, SET_CONTEXT_DMA_NOTIFY, chan->cli->drm->ntfy.handle,
 				SET_CONTEXT_DMA_BUFFER_IN, chan->vram.handle,
 				SET_CONTEXT_DMA_BUFFER_OUT, chan->vram.handle);
 	return 0;
drivers/gpu/drm/nouveau/nouveau_chan.c +10 -15
index e4065b7f1f9f..a5eeb6e76ff1 100644
@@ -90,12 +90,10 @@ nouveau_channel_del(struct nouveau_channel **pchan)
 {
 	struct nouveau_channel *chan = *pchan;
 	if (chan) {
-		struct nouveau_cli *cli = (void *)chan->user.client;
-
 		if (chan->fence)
-			nouveau_fence(chan->drm)->context_del(chan);
+			nouveau_fence(chan->cli->drm)->context_del(chan);
 
-		if (cli)
+		if (nvif_object_constructed(&chan->user))
 			nouveau_svmm_part(chan->vmm->svmm, chan->inst);
 
 		nvif_object_dtor(&chan->blit);
@@ -157,7 +155,6 @@ nouveau_channel_prep(struct nouveau_cli *cli,
 		return -ENOMEM;
 
 	chan->cli = cli;
-	chan->drm = drm;
 	chan->vmm = nouveau_cli_vmm(cli);
 	atomic_set(&chan->killed, 0);
 
@@ -229,12 +226,11 @@ nouveau_channel_prep(struct nouveau_cli *cli,
 			args.limit = device->info.ram_user - 1;
 		}
 	} else {
-		if (chan->drm->agp.bridge) {
+		if (drm->agp.bridge) {
 			args.target = NV_DMA_V0_TARGET_AGP;
 			args.access = NV_DMA_V0_ACCESS_RDWR;
-			args.start = chan->drm->agp.base;
-			args.limit = chan->drm->agp.base +
-				     chan->drm->agp.size - 1;
+			args.start = drm->agp.base;
+			args.limit = drm->agp.base + drm->agp.size - 1;
 		} else {
 			args.target = NV_DMA_V0_TARGET_VM;
 			args.access = NV_DMA_V0_ACCESS_RDWR;
@@ -364,7 +360,7 @@ nouveau_channel_ctor(struct nouveau_cli *cli, bool priv, u64 runm,
 static int
 nouveau_channel_init(struct nouveau_channel *chan, u32 vram, u32 gart)
 {
-	struct nouveau_drm *drm = chan->drm;
+	struct nouveau_drm *drm = chan->cli->drm;
 	struct nvif_device *device = &drm->device;
 	struct nv_dma_v0 args = {};
 	int ret, i;
@@ -420,12 +416,11 @@ nouveau_channel_init(struct nouveau_channel *chan, u32 vram, u32 gart)
 			args.start = 0;
 			args.limit = chan->vmm->vmm.limit - 1;
 		} else
-		if (chan->drm->agp.bridge) {
+		if (drm->agp.bridge) {
 			args.target = NV_DMA_V0_TARGET_AGP;
 			args.access = NV_DMA_V0_ACCESS_RDWR;
-			args.start = chan->drm->agp.base;
-			args.limit = chan->drm->agp.base +
-				     chan->drm->agp.size - 1;
+			args.start = drm->agp.base;
+			args.limit = drm->agp.base + drm->agp.size - 1;
 		} else {
 			args.target = NV_DMA_V0_TARGET_VM;
 			args.access = NV_DMA_V0_ACCESS_RDWR;
@@ -490,7 +485,7 @@ nouveau_channel_init(struct nouveau_channel *chan, u32 vram, u32 gart)
 	}
 
 	/* initialise synchronisation */
-	return nouveau_fence(chan->drm)->context_new(chan);
+	return nouveau_fence(drm)->context_new(chan);
 }
 
 int
drivers/gpu/drm/nouveau/nouveau_chan.h +0 -1
index 18a9cbfef8ca..3ce9832c9528 100644
@@ -13,7 +13,6 @@ struct nouveau_channel {
 	} chan;
 
 	struct nouveau_cli *cli;
-	struct nouveau_drm *drm;
 	struct nouveau_vmm *vmm;
 
 	struct nvif_mem mem_userd;
drivers/gpu/drm/nouveau/nouveau_dma.c +1 -1
index b01c029f3a90..a1f329ef0641 100644
@@ -72,7 +72,7 @@ void
 nv50_dma_push(struct nouveau_channel *chan, u64 offset, u32 length,
 	      bool no_prefetch)
 {
-	struct nvif_user *user = &chan->drm->client.device.user;
+	struct nvif_user *user = &chan->cli->drm->client.device.user;
 	struct nouveau_bo *pb = chan->push.buffer;
 	int ip = (chan->dma.ib_put * 2) + chan->dma.ib_base;
 
drivers/gpu/drm/nouveau/nouveau_fence.c +8 -7
index 93f08f9479d8..ba25ce1294a6 100644
@@ -181,8 +181,9 @@ nouveau_fence_wait_uevent_handler(struct nvif_event *event, void *repv, u32 repc
 void
 nouveau_fence_context_new(struct nouveau_channel *chan, struct nouveau_fence_chan *fctx)
 {
-	struct nouveau_fence_priv *priv = (void*)chan->drm->fence;
-	struct nouveau_cli *cli = (void *)chan->user.client;
+	struct nouveau_cli *cli = chan->cli;
+	struct nouveau_drm *drm = cli->drm;
+	struct nouveau_fence_priv *priv = (void*)drm->fence;
 	struct {
 		struct nvif_event_v0 base;
 		struct nvif_chan_event_v0 host;
@@ -193,11 +194,11 @@ nouveau_fence_context_new(struct nouveau_channel *chan, struct nouveau_fence_cha
 	INIT_LIST_HEAD(&fctx->flip);
 	INIT_LIST_HEAD(&fctx->pending);
 	spin_lock_init(&fctx->lock);
-	fctx->context = chan->drm->runl[chan->runlist].context_base + chan->chid;
+	fctx->context = drm->runl[chan->runlist].context_base + chan->chid;
 
-	if (chan == chan->drm->cechan)
+	if (chan == drm->cechan)
 		strcpy(fctx->name, "copy engine channel");
-	else if (chan == chan->drm->channel)
+	else if (chan == drm->channel)
 		strcpy(fctx->name, "generic kernel channel");
 	else
 		strcpy(fctx->name, nvxx_client(&cli->base)->name);
@@ -221,7 +222,7 @@ nouveau_fence_emit(struct nouveau_fence *fence)
 {
 	struct nouveau_channel *chan = unrcu_pointer(fence->channel);
 	struct nouveau_fence_chan *fctx = chan->fence;
-	struct nouveau_fence_priv *priv = (void*)chan->drm->fence;
+	struct nouveau_fence_priv *priv = (void*)chan->cli->drm->fence;
 	int ret;
 
 	fence->timeout  = jiffies + (15 * HZ);
@@ -382,7 +383,7 @@ nouveau_fence_sync(struct nouveau_bo *nvbo, struct nouveau_channel *chan,
 			if (i == 0 && usage == DMA_RESV_USAGE_WRITE)
 				continue;
 
-			f = nouveau_local_fence(fence, chan->drm);
+			f = nouveau_local_fence(fence, chan->cli->drm);
 			if (f) {
 				struct nouveau_channel *prev;
 				bool must_wait = true;
drivers/gpu/drm/nouveau/nouveau_gem.c +4 -3
index 5a887d67dc0e..22f4ee483ff3 100644
@@ -567,10 +567,11 @@ validate_init(struct nouveau_channel *chan, struct drm_file *file_priv,
 }
 
 static int
-validate_list(struct nouveau_channel *chan, struct nouveau_cli *cli,
+validate_list(struct nouveau_channel *chan,
 	      struct list_head *list, struct drm_nouveau_gem_pushbuf_bo *pbbo)
 {
-	struct nouveau_drm *drm = chan->drm;
+	struct nouveau_cli *cli = chan->cli;
+	struct nouveau_drm *drm = cli->drm;
 	struct nouveau_bo *nvbo;
 	int ret, relocs = 0;
 
@@ -642,7 +643,7 @@ nouveau_gem_pushbuf_validate(struct nouveau_channel *chan,
 		return ret;
 	}
 
-	ret = validate_list(chan, cli, &op->list, pbbo);
+	ret = validate_list(chan, &op->list, pbbo);
 	if (unlikely(ret < 0)) {
 		if (ret != -ERESTARTSYS)
 			NV_PRINTK(err, cli, "validating bo list\n");
drivers/gpu/drm/nouveau/nv17_fence.c +3 -3
index 07c2e0878c24..7fa52ec61b30 100644
@@ -36,8 +36,8 @@ int
 nv17_fence_sync(struct nouveau_fence *fence,
 		struct nouveau_channel *prev, struct nouveau_channel *chan)
 {
-	struct nouveau_cli *cli = (void *)prev->user.client;
-	struct nv10_fence_priv *priv = chan->drm->fence;
+	struct nouveau_cli *cli = prev->cli;
+	struct nv10_fence_priv *priv = cli->drm->fence;
 	struct nv10_fence_chan *fctx = chan->fence;
 	struct nvif_push *ppush = prev->chan.push;
 	struct nvif_push *npush = chan->chan.push;
@@ -76,7 +76,7 @@ nv17_fence_sync(struct nouveau_fence *fence,
 static int
 nv17_fence_context_new(struct nouveau_channel *chan)
 {
-	struct nv10_fence_priv *priv = chan->drm->fence;
+	struct nv10_fence_priv *priv = chan->cli->drm->fence;
 	struct ttm_resource *reg = priv->bo->bo.resource;
 	struct nv10_fence_chan *fctx;
 	u32 start = reg->start * PAGE_SIZE;
drivers/gpu/drm/nouveau/nv50_fence.c +1 -1
index ea1e1f480bfe..8b76cb227f55 100644
@@ -35,7 +35,7 @@
 static int
 nv50_fence_context_new(struct nouveau_channel *chan)
 {
-	struct nv10_fence_priv *priv = chan->drm->fence;
+	struct nv10_fence_priv *priv = chan->cli->drm->fence;
 	struct nv10_fence_chan *fctx;
 	struct ttm_resource *reg = priv->bo->bo.resource;
 	u32 start = reg->start * PAGE_SIZE;
drivers/gpu/drm/nouveau/nv84_fence.c +4 -4
index 812b8c62eeba..7f62089dc940 100644
@@ -79,7 +79,7 @@ nv84_fence_sync32(struct nouveau_channel *chan, u64 virtual, u32 sequence)
 static inline u32
 nv84_fence_chid(struct nouveau_channel *chan)
 {
-	return chan->drm->runl[chan->runlist].chan_id_base + chan->chid;
+	return chan->cli->drm->runl[chan->runlist].chan_id_base + chan->chid;
 }
 
 static int
@@ -105,14 +105,14 @@ nv84_fence_sync(struct nouveau_fence *fence,
 static u32
 nv84_fence_read(struct nouveau_channel *chan)
 {
-	struct nv84_fence_priv *priv = chan->drm->fence;
+	struct nv84_fence_priv *priv = chan->cli->drm->fence;
 	return nouveau_bo_rd32(priv->bo, nv84_fence_chid(chan) * 16/4);
 }
 
 static void
 nv84_fence_context_del(struct nouveau_channel *chan)
 {
-	struct nv84_fence_priv *priv = chan->drm->fence;
+	struct nv84_fence_priv *priv = chan->cli->drm->fence;
 	struct nv84_fence_chan *fctx = chan->fence;
 
 	nouveau_bo_wr32(priv->bo, nv84_fence_chid(chan) * 16 / 4, fctx->base.sequence);
@@ -127,7 +127,7 @@ nv84_fence_context_del(struct nouveau_channel *chan)
 int
 nv84_fence_context_new(struct nouveau_channel *chan)
 {
-	struct nv84_fence_priv *priv = chan->drm->fence;
+	struct nv84_fence_priv *priv = chan->cli->drm->fence;
 	struct nv84_fence_chan *fctx;
 	int ret;
 
Signature · 1 line
2.41.0
author
#9 lore raw

PATCH 8/156 drm/nouveau: replace some void casts with chan->cli

In reply to Ben Skeggs

- probably a touch safer...

---
 drivers/gpu/drm/nouveau/dispnv04/crtc.c | 2 +-
 drivers/gpu/drm/nouveau/nouveau_bo.c    | 2 +-
 drivers/gpu/drm/nouveau/nouveau_chan.c  | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/nouveau/dispnv04/crtc.c +1 -1
index 8f2fd5d9dcb7..3535cf571300 100644
@@ -1157,7 +1157,7 @@ nv04_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
 	chan = drm->channel;
 	if (!chan)
 		return -ENODEV;
-	cli = (void *)chan->user.client;
+	cli = chan->cli;
 	push = chan->chan.push;
 
 	s = kzalloc(sizeof(*s), GFP_KERNEL);
drivers/gpu/drm/nouveau/nouveau_bo.c +1 -1
index 1e2d28fd10dc..e1483fd5d283 100644
@@ -865,7 +865,7 @@ nouveau_bo_move_m2mf(struct ttm_buffer_object *bo, int evict,
 {
 	struct nouveau_drm *drm = nouveau_bdev(bo->bdev);
 	struct nouveau_channel *chan = drm->ttm.chan;
-	struct nouveau_cli *cli = (void *)chan->user.client;
+	struct nouveau_cli *cli = chan->cli;
 	struct nouveau_fence *fence;
 	int ret;
 
drivers/gpu/drm/nouveau/nouveau_chan.c +2 -2
index a5eeb6e76ff1..ea8db569bd1a 100644
@@ -52,7 +52,7 @@ static int
 nouveau_channel_killed(struct nvif_event *event, void *repv, u32 repc)
 {
 	struct nouveau_channel *chan = container_of(event, typeof(*chan), kill);
-	struct nouveau_cli *cli = (void *)chan->user.client;
+	struct nouveau_cli *cli = chan->cli;
 
 	NV_PRINTK(warn, cli, "channel %d killed!\n", chan->chid);
 
@@ -66,7 +66,7 @@ int
 nouveau_channel_idle(struct nouveau_channel *chan)
 {
 	if (likely(chan && chan->fence && !atomic_read(&chan->killed))) {
-		struct nouveau_cli *cli = (void *)chan->user.client;
+		struct nouveau_cli *cli = chan->cli;
 		struct nouveau_fence *fence = NULL;
 		int ret;
 
Signature · 1 line
2.41.0
author
#10 lore raw

PATCH 9/156 drm/nouveau: remove nouveau_drm.master

In reply to Ben Skeggs

- preparation for upcoming api changes

---
 drivers/gpu/drm/nouveau/nouveau_drm.c | 91 +++++++++++++--------------
 drivers/gpu/drm/nouveau/nouveau_drv.h |  3 +-
 drivers/gpu/drm/nouveau/nouveau_mem.c | 20 +++---
 3 files changed, 56 insertions(+), 58 deletions(-)
drivers/gpu/drm/nouveau/nouveau_drm.c +44 -47
index da5bb7c51dab..ad5de7ed48ce 100644
@@ -209,9 +209,9 @@ nouveau_cli_fini(struct nouveau_cli *cli)
 	nouveau_vmm_fini(&cli->vmm);
 	nvif_mmu_dtor(&cli->mmu);
 	nvif_device_dtor(&cli->device);
-	mutex_lock(&cli->drm->master.lock);
+	mutex_lock(&cli->drm->client_mutex);
 	nvif_client_dtor(&cli->base);
-	mutex_unlock(&cli->drm->master.lock);
+	mutex_unlock(&cli->drm->client_mutex);
 }
 
 static int
@@ -226,13 +226,6 @@ nouveau_cli_init(struct nouveau_drm *drm, const char *sname,
 		{}
 	};
 	static const struct nvif_mclass
-	mmus[] = {
-		{ NVIF_CLASS_MMU_GF100, -1 },
-		{ NVIF_CLASS_MMU_NV50 , -1 },
-		{ NVIF_CLASS_MMU_NV04 , -1 },
-		{}
-	};
-	static const struct nvif_mclass
 	vmms[] = {
 		{ NVIF_CLASS_VMM_GP100, -1 },
 		{ NVIF_CLASS_VMM_GM200, -1 },
@@ -253,15 +246,10 @@ nouveau_cli_init(struct nouveau_drm *drm, const char *sname,
 	INIT_LIST_HEAD(&cli->worker);
 	mutex_init(&cli->lock);
 
-	if (cli == &drm->master) {
-		ret = nvif_driver_init(NULL, nouveau_config, nouveau_debug,
-				       cli->name, device, &cli->base);
-	} else {
-		mutex_lock(&drm->master.lock);
-		ret = nvif_client_ctor(&drm->master.base, cli->name, device,
-				       &cli->base);
-		mutex_unlock(&drm->master.lock);
-	}
+	mutex_lock(&drm->client_mutex);
+	ret = nvif_client_ctor(&drm->_client, cli->name, device,
+			       &cli->base);
+	mutex_unlock(&drm->client_mutex);
 	if (ret) {
 		NV_PRINTK(err, cli, "Client allocation failed: %d\n", ret);
 		goto done;
@@ -278,13 +266,7 @@ nouveau_cli_init(struct nouveau_drm *drm, const char *sname,
 		goto done;
 	}
 
-	ret = nvif_mclass(&cli->device.object, mmus);
-	if (ret < 0) {
-		NV_PRINTK(err, cli, "No supported MMU class\n");
-		goto done;
-	}
-
-	ret = nvif_mmu_ctor(&cli->device.object, "drmMmu", mmus[ret].oclass,
+	ret = nvif_mmu_ctor(&cli->device.object, "drmMmu", drm->mmu.object.oclass,
 			    &cli->mmu);
 	if (ret) {
 		NV_PRINTK(err, cli, "MMU allocation failed: %d\n", ret);
@@ -581,6 +563,13 @@ nouveau_parent = {
 static int
 nouveau_drm_device_init(struct drm_device *dev)
 {
+	static const struct nvif_mclass
+	mmus[] = {
+		{ NVIF_CLASS_MMU_GF100, -1 },
+		{ NVIF_CLASS_MMU_NV50 , -1 },
+		{ NVIF_CLASS_MMU_NV04 , -1 },
+		{}
+	};
 	struct nouveau_drm *drm;
 	int ret;
 
@@ -590,20 +579,16 @@ nouveau_drm_device_init(struct drm_device *dev)
 	drm->dev = dev;
 
 	nvif_parent_ctor(&nouveau_parent, &drm->parent);
-	drm->master.base.object.parent = &drm->parent;
 
-	drm->sched_wq = alloc_workqueue("nouveau_sched_wq_shared", 0,
-					WQ_MAX_ACTIVE);
-	if (!drm->sched_wq) {
-		ret = -ENOMEM;
-		goto fail_alloc;
-	}
+	mutex_init(&drm->client_mutex);
+	drm->_client.object.parent = &drm->parent;
 
-	ret = nouveau_cli_init(drm, "DRM-master", &drm->master);
+	ret = nvif_driver_init(NULL, nouveau_config, nouveau_debug, "drm", nouveau_name(dev),
+			       &drm->_client);
 	if (ret)
-		goto fail_wq;
+		goto fail_alloc;
 
-	ret = nvif_device_ctor(&drm->master.base.object, "drmDevice", 0, NV_DEVICE,
+	ret = nvif_device_ctor(&drm->_client.object, "drmDevice", 0, NV_DEVICE,
 			       &(struct nv_device_v0) {
 					.device = ~0,
 					.priv = true,
@@ -611,19 +596,31 @@ nouveau_drm_device_init(struct drm_device *dev)
 			       &drm->device);
 	if (ret) {
 		NV_ERROR(drm, "Device allocation failed: %d\n", ret);
-		goto fail_master;
+		goto fail_nvif;
+	}
+
+	ret = nvif_mclass(&drm->device.object, mmus);
+	if (ret < 0) {
+		NV_ERROR(drm, "No supported MMU class\n");
+		goto fail_nvif;
 	}
 
-	ret = nvif_mmu_ctor(&drm->device.object, "drmMmu", drm->master.mmu.object.oclass,
-			    &drm->mmu);
+	ret = nvif_mmu_ctor(&drm->device.object, "drmMmu", mmus[ret].oclass, &drm->mmu);
 	if (ret) {
 		NV_ERROR(drm, "MMU allocation failed: %d\n", ret);
 		goto fail_nvif;
 	}
 
+	drm->sched_wq = alloc_workqueue("nouveau_sched_wq_shared", 0,
+					WQ_MAX_ACTIVE);
+	if (!drm->sched_wq) {
+		ret = -ENOMEM;
+		goto fail_nvif;
+	}
+
 	ret = nouveau_cli_init(drm, "DRM", &drm->cli);
 	if (ret)
-		goto fail_nvif;
+		goto fail_wq;
 
 	nvxx_client(&drm->client.base)->debug =
 		nvkm_dbgopt(nouveau_debug, "DRM");
@@ -687,14 +684,14 @@ nouveau_drm_device_init(struct drm_device *dev)
 fail_ttm:
 	nouveau_vga_fini(drm);
 	nouveau_cli_fini(&drm->cli);
+fail_wq:
+	destroy_workqueue(drm->sched_wq);
 fail_nvif:
 	nvif_mmu_dtor(&drm->mmu);
 	nvif_device_dtor(&drm->device);
-fail_master:
-	nouveau_cli_fini(&drm->master);
-fail_wq:
-	destroy_workqueue(drm->sched_wq);
+	nvif_client_dtor(&drm->_client);
 fail_alloc:
+	mutex_destroy(&drm->client_mutex);
 	nvif_parent_dtor(&drm->parent);
 	kfree(drm);
 	return ret;
@@ -746,10 +743,10 @@ nouveau_drm_device_fini(struct drm_device *dev)
 	mutex_unlock(&drm->clients_lock);
 
 	nouveau_cli_fini(&drm->cli);
+	destroy_workqueue(drm->sched_wq);
 	nvif_mmu_dtor(&drm->mmu);
 	nvif_device_dtor(&drm->device);
-	nouveau_cli_fini(&drm->master);
-	destroy_workqueue(drm->sched_wq);
+	mutex_destroy(&drm->client_mutex);
 	nvif_parent_dtor(&drm->parent);
 	mutex_destroy(&drm->clients_lock);
 	kfree(drm);
@@ -962,7 +959,7 @@ nouveau_do_suspend(struct drm_device *dev, bool runtime)
 	}
 
 	NV_DEBUG(drm, "suspending object tree...\n");
-	ret = nvif_client_suspend(&drm->master.base);
+	ret = nvif_client_suspend(&drm->_client);
 	if (ret)
 		goto fail_client;
 
@@ -987,7 +984,7 @@ nouveau_do_resume(struct drm_device *dev, bool runtime)
 	struct nouveau_drm *drm = nouveau_drm(dev);
 
 	NV_DEBUG(drm, "resuming object tree...\n");
-	ret = nvif_client_resume(&drm->master.base);
+	ret = nvif_client_resume(&drm->_client);
 	if (ret) {
 		NV_ERROR(drm, "Client resume failed with error: %d\n", ret);
 		return ret;
drivers/gpu/drm/nouveau/nouveau_drv.h +2 -1
index 8f04f3630936..683600db4ff9 100644
@@ -202,10 +202,11 @@ u_memcpya(uint64_t user, unsigned int nmemb, unsigned int size)
 
 struct nouveau_drm {
 	struct nvif_parent parent;
+	struct mutex client_mutex;
+	struct nvif_client _client;
 	struct nvif_device device;
 	struct nvif_mmu mmu;
 
-	struct nouveau_cli master;
 	union {
 		struct nouveau_cli client;
 		struct nouveau_cli cli;
drivers/gpu/drm/nouveau/nouveau_mem.c +10 -10
index 4d9ac9f30f05..baea74899fcf 100644
@@ -80,9 +80,9 @@ nouveau_mem_fini(struct nouveau_mem *mem)
 {
 	nvif_vmm_put(&mem->drm->cli.vmm.vmm, &mem->vma[1]);
 	nvif_vmm_put(&mem->drm->cli.vmm.vmm, &mem->vma[0]);
-	mutex_lock(&mem->drm->master.lock);
+	mutex_lock(&mem->drm->client_mutex);
 	nvif_mem_dtor(&mem->mem);
-	mutex_unlock(&mem->drm->master.lock);
+	mutex_unlock(&mem->drm->client_mutex);
 }
 
 int
@@ -90,8 +90,8 @@ nouveau_mem_host(struct ttm_resource *reg, struct ttm_tt *tt)
 {
 	struct nouveau_mem *mem = nouveau_mem(reg);
 	struct nouveau_drm *drm = mem->drm;
-	struct nouveau_cli *cli = &drm->master;
-	struct nvif_mmu *mmu = &cli->mmu;
+	struct nouveau_cli *cli = &drm->cli;
+	struct nvif_mmu *mmu = &drm->mmu;
 	struct nvif_mem_ram_v0 args = {};
 	u8 type;
 	int ret;
@@ -114,11 +114,11 @@ nouveau_mem_host(struct ttm_resource *reg, struct ttm_tt *tt)
 	else
 		args.dma = tt->dma_address;
 
-	mutex_lock(&drm->master.lock);
+	mutex_lock(&drm->client_mutex);
 	ret = nvif_mem_ctor_type(mmu, "ttmHostMem", cli->mem->oclass, type, PAGE_SHIFT,
 				 reg->size,
 				 &args, sizeof(args), &mem->mem);
-	mutex_unlock(&drm->master.lock);
+	mutex_unlock(&drm->client_mutex);
 	return ret;
 }
 
@@ -127,12 +127,12 @@ nouveau_mem_vram(struct ttm_resource *reg, bool contig, u8 page)
 {
 	struct nouveau_mem *mem = nouveau_mem(reg);
 	struct nouveau_drm *drm = mem->drm;
-	struct nouveau_cli *cli = &drm->master;
-	struct nvif_mmu *mmu = &cli->mmu;
+	struct nouveau_cli *cli = &drm->cli;
+	struct nvif_mmu *mmu = &drm->mmu;
 	u64 size = ALIGN(reg->size, 1 << page);
 	int ret;
 
-	mutex_lock(&drm->master.lock);
+	mutex_lock(&drm->client_mutex);
 	switch (cli->mem->oclass) {
 	case NVIF_CLASS_MEM_GF100:
 		ret = nvif_mem_ctor_type(mmu, "ttmVram", cli->mem->oclass,
@@ -156,7 +156,7 @@ nouveau_mem_vram(struct ttm_resource *reg, bool contig, u8 page)
 		WARN_ON(1);
 		break;
 	}
-	mutex_unlock(&drm->master.lock);
+	mutex_unlock(&drm->client_mutex);
 
 	reg->start = mem->mem.addr >> PAGE_SHIFT;
 	return ret;
Signature · 1 line
2.41.0
author
#11 lore raw

PATCH 10/156 drm/nouveau: always map device

In reply to Ben Skeggs

- rd/wr apis are being removed, require device to be mapped

---
 drivers/gpu/drm/nouveau/dispnv04/disp.c       | 5 -----
 drivers/gpu/drm/nouveau/include/nvif/device.h | 1 +
 drivers/gpu/drm/nouveau/nouveau_drm.c         | 9 +++++++++
 drivers/gpu/drm/nouveau/nvif/device.c         | 6 ++++++
 4 files changed, 16 insertions(+), 5 deletions(-)
drivers/gpu/drm/nouveau/dispnv04/disp.c +0 -5
index 13705c5f1497..e8b27bb135e7 100644
@@ -189,7 +189,6 @@ static void
 nv04_display_destroy(struct drm_device *dev)
 {
 	struct nv04_display *disp = nv04_display(dev);
-	struct nouveau_drm *drm = nouveau_drm(dev);
 	struct nouveau_encoder *encoder;
 	struct nouveau_crtc *nv_crtc;
 
@@ -206,8 +205,6 @@ nv04_display_destroy(struct drm_device *dev)
 
 	nouveau_display(dev)->priv = NULL;
 	vfree(disp);
-
-	nvif_object_unmap(&drm->client.device.object);
 }
 
 int
@@ -229,8 +226,6 @@ nv04_display_create(struct drm_device *dev)
 
 	disp->drm = drm;
 
-	nvif_object_map(&drm->client.device.object, NULL, 0);
-
 	nouveau_display(dev)->priv = disp;
 	nouveau_display(dev)->dtor = nv04_display_destroy;
 	nouveau_display(dev)->init = nv04_display_init;
drivers/gpu/drm/nouveau/include/nvif/device.h +1 -0
index b0e59800a320..64b8e4defc35 100644
@@ -21,6 +21,7 @@ struct nvif_device {
 int  nvif_device_ctor(struct nvif_object *, const char *name, u32 handle,
 		      s32 oclass, void *, u32, struct nvif_device *);
 void nvif_device_dtor(struct nvif_device *);
+int  nvif_device_map(struct nvif_device *);
 u64  nvif_device_time(struct nvif_device *);
 
 /*XXX*/
drivers/gpu/drm/nouveau/nouveau_drm.c +9 -0
index ad5de7ed48ce..68564c648eda 100644
@@ -208,6 +208,7 @@ nouveau_cli_fini(struct nouveau_cli *cli)
 	nouveau_vmm_fini(&cli->svm);
 	nouveau_vmm_fini(&cli->vmm);
 	nvif_mmu_dtor(&cli->mmu);
+	cli->device.object.map.ptr = NULL;
 	nvif_device_dtor(&cli->device);
 	mutex_lock(&cli->drm->client_mutex);
 	nvif_client_dtor(&cli->base);
@@ -266,6 +267,8 @@ nouveau_cli_init(struct nouveau_drm *drm, const char *sname,
 		goto done;
 	}
 
+	cli->device.object.map.ptr = drm->device.object.map.ptr;
+
 	ret = nvif_mmu_ctor(&cli->device.object, "drmMmu", drm->mmu.object.oclass,
 			    &cli->mmu);
 	if (ret) {
@@ -599,6 +602,12 @@ nouveau_drm_device_init(struct drm_device *dev)
 		goto fail_nvif;
 	}
 
+	ret = nvif_device_map(&drm->device);
+	if (ret) {
+		NV_ERROR(drm, "Failed to map PRI: %d\n", ret);
+		goto fail_nvif;
+	}
+
 	ret = nvif_mclass(&drm->device.object, mmus);
 	if (ret < 0) {
 		NV_ERROR(drm, "No supported MMU class\n");
drivers/gpu/drm/nouveau/nvif/device.c +6 -0
index 8c3d883f3313..2fef6553a013 100644
@@ -38,6 +38,12 @@ nvif_device_time(struct nvif_device *device)
 	return device->user.func->time(&device->user);
 }
 
+int
+nvif_device_map(struct nvif_device *device)
+{
+	return nvif_object_map(&device->object, NULL, 0);
+}
+
 void
 nvif_device_dtor(struct nvif_device *device)
 {
Signature · 1 line
2.41.0
author
#12 lore raw

PATCH 11/156 drm/nouveau: add nouveau_cli to nouveau_abi16

In reply to Ben Skeggs

- removes some dubious void casts

---
 drivers/gpu/drm/nouveau/nouveau_abi16.c | 9 +++++----
 drivers/gpu/drm/nouveau/nouveau_abi16.h | 1 +
 2 files changed, 6 insertions(+), 4 deletions(-)
drivers/gpu/drm/nouveau/nouveau_abi16.c +5 -4
index 291107ddc59b..440d92d93acd 100644
@@ -50,6 +50,7 @@ nouveau_abi16(struct drm_file *file_priv)
 				.device = ~0ULL,
 			};
 
+			abi16->cli = cli;
 			INIT_LIST_HEAD(&abi16->channels);
 
 			/* allocate device object targeting client's default
@@ -82,7 +83,7 @@ nouveau_abi16_get(struct drm_file *file_priv)
 int
 nouveau_abi16_put(struct nouveau_abi16 *abi16, int ret)
 {
-	struct nouveau_cli *cli = (void *)abi16->device.object.client;
+	struct nouveau_cli *cli = abi16->cli;
 	mutex_unlock(&cli->mutex);
 	return ret;
 }
@@ -164,7 +165,7 @@ nouveau_abi16_chan_fini(struct nouveau_abi16 *abi16,
 void
 nouveau_abi16_fini(struct nouveau_abi16 *abi16)
 {
-	struct nouveau_cli *cli = (void *)abi16->device.object.client;
+	struct nouveau_cli *cli = abi16->cli;
 	struct nouveau_abi16_chan *chan, *temp;
 
 	/* cleanup channels */
@@ -526,7 +527,7 @@ nouveau_abi16_ioctl_grobj_alloc(ABI16_IOCTL_ARGS)
 
 	if (init->handle == ~0)
 		return nouveau_abi16_put(abi16, -EINVAL);
-	client = abi16->device.object.client;
+	client = &abi16->cli->base;
 
 	chan = nouveau_abi16_chan(abi16, init->channel);
 	if (!chan)
@@ -620,7 +621,7 @@ nouveau_abi16_ioctl_notifierobj_alloc(ABI16_IOCTL_ARGS)
 	/* completely unnecessary for these chipsets... */
 	if (unlikely(device->info.family >= NV_DEVICE_INFO_V0_FERMI))
 		return nouveau_abi16_put(abi16, -EINVAL);
-	client = abi16->device.object.client;
+	client = &abi16->cli->base;
 
 	chan = nouveau_abi16_chan(abi16, info->channel);
 	if (!chan)
drivers/gpu/drm/nouveau/nouveau_abi16.h +1 -0
index 661b901d8ecc..0a9121e63143 100644
@@ -30,6 +30,7 @@ struct nouveau_abi16_chan {
 };
 
 struct nouveau_abi16 {
+	struct nouveau_cli *cli;
 	struct nvif_device device;
 	struct list_head channels;
 	u64 handles;
Signature · 1 line
2.41.0
author
#13 lore raw

PATCH 12/156 drm/nouveau: handle limited nvif in abi16

In reply to Ben Skeggs

nouveau_usif.c was mostly been stripped right back already a couple of years ago, but now the NVKM side of these interfaces are being removed.

Fortunately, userspace only ever ended up using a fraction of the APIs, so I've reimplemented those in a more direct manner, and return -EINVAL to userspace for everything else.

---
 drivers/gpu/drm/nouveau/Kbuild          |   1 -
 drivers/gpu/drm/nouveau/nouveau_abi16.c | 277 ++++++++++++++++++++----
 drivers/gpu/drm/nouveau/nouveau_abi16.h |   3 +-
 drivers/gpu/drm/nouveau/nouveau_drm.c   |   5 +-
 drivers/gpu/drm/nouveau/nouveau_nvif.c  |   1 -
 drivers/gpu/drm/nouveau/nouveau_usif.c  | 194 -----------------
 drivers/gpu/drm/nouveau/nouveau_usif.h  |  10 -
 7 files changed, 242 insertions(+), 249 deletions(-)
 delete mode 100644 drivers/gpu/drm/nouveau/nouveau_usif.c
 delete mode 100644 drivers/gpu/drm/nouveau/nouveau_usif.h
drivers/gpu/drm/nouveau/Kbuild +0 -1
index cf6b3a80c0c8..c3223ec97aff 100644
@@ -27,7 +27,6 @@ nouveau-$(CONFIG_COMPAT) += nouveau_ioc32.o
 nouveau-$(CONFIG_LEDS_CLASS) += nouveau_led.o
 nouveau-y += nouveau_nvif.o
 nouveau-$(CONFIG_NOUVEAU_PLATFORM_DRIVER) += nouveau_platform.o
-nouveau-y += nouveau_usif.o # userspace <-> nvif
 nouveau-y += nouveau_vga.o
 
 # DRM - memory management
drivers/gpu/drm/nouveau/nouveau_abi16.c +239 -38

304 lines not on this page · raw message

drivers/gpu/drm/nouveau/nouveau_abi16.h +2 -1
index 0a9121e63143..75a883a44e04 100644
@@ -34,13 +34,14 @@ struct nouveau_abi16 {
 	struct nvif_device device;
 	struct list_head channels;
 	u64 handles;
+	struct list_head objects;
 };
 
 struct nouveau_abi16 *nouveau_abi16_get(struct drm_file *);
 int  nouveau_abi16_put(struct nouveau_abi16 *, int);
 void nouveau_abi16_fini(struct nouveau_abi16 *);
 s32  nouveau_abi16_swclass(struct nouveau_drm *);
-int  nouveau_abi16_usif(struct drm_file *, void *data, u32 size);
+int nouveau_abi16_ioctl(struct drm_file *, void __user *user, u32 size);
 
 #define NOUVEAU_GEM_DOMAIN_VRAM      (1 << 1)
 #define NOUVEAU_GEM_DOMAIN_GART      (1 << 2)
drivers/gpu/drm/nouveau/nouveau_drm.c +1 -4
index 68564c648eda..c0d74be4c47b 100644
@@ -63,7 +63,6 @@
 #include "nouveau_abi16.h"
 #include "nouveau_fence.h"
 #include "nouveau_debugfs.h"
-#include "nouveau_usif.h"
 #include "nouveau_connector.h"
 #include "nouveau_platform.h"
 #include "nouveau_svm.h"
@@ -200,7 +199,6 @@ nouveau_cli_fini(struct nouveau_cli *cli)
 	flush_work(&cli->work);
 	WARN_ON(!list_empty(&cli->worker));
 
-	usif_client_fini(cli);
 	if (cli->sched)
 		nouveau_sched_destroy(&cli->sched);
 	if (uvmm)
@@ -241,7 +239,6 @@ nouveau_cli_init(struct nouveau_drm *drm, const char *sname,
 	snprintf(cli->name, sizeof(cli->name), "%s", sname);
 	cli->drm = drm;
 	mutex_init(&cli->mutex);
-	usif_client_init(cli);
 
 	INIT_WORK(&cli->work, nouveau_cli_work);
 	INIT_LIST_HEAD(&cli->worker);
@@ -1278,7 +1275,7 @@ nouveau_drm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 
 	switch (_IOC_NR(cmd) - DRM_COMMAND_BASE) {
 	case DRM_NOUVEAU_NVIF:
-		ret = usif_ioctl(filp, (void __user *)arg, _IOC_SIZE(cmd));
+		ret = nouveau_abi16_ioctl(filp, (void __user *)arg, _IOC_SIZE(cmd));
 		break;
 	default:
 		ret = drm_ioctl(file, cmd, arg);
drivers/gpu/drm/nouveau/nouveau_nvif.c +0 -1
index 1d49ebdfd5dc..9a7e3f64b79f 100644
@@ -35,7 +35,6 @@
 #include <nvif/ioctl.h>
 
 #include "nouveau_drv.h"
-#include "nouveau_usif.h"
 
 static void
 nvkm_client_unmap(void *priv, void __iomem *ptr, u32 size)
drivers/gpu/drm/nouveau/nouveau_usif.c deleted +0 -194

194 lines not on this page · raw message

drivers/gpu/drm/nouveau/nouveau_usif.h deleted +0 -10
deleted file mode 100644
index dc90d4a9d0d9..000000000000
@@ -1,10 +0,0 @@
-/* SPDX-License-Identifier: MIT */
-#ifndef __NOUVEAU_USIF_H__
-#define __NOUVEAU_USIF_H__
-
-void usif_client_init(struct nouveau_cli *);
-void usif_client_fini(struct nouveau_cli *);
-int  usif_ioctl(struct drm_file *, void __user *, u32);
-int  usif_notify(const void *, u32, const void *, u32);
-
-#endif
Signature · 1 line
2.41.0
author
#14 lore raw

PATCH 13/156 drm/nouveau: remove abi16->device

In reply to Ben Skeggs

- not used anymore other than device info, use drm->device instead

---
 drivers/gpu/drm/nouveau/nouveau_abi16.c | 24 ++----------------------
 drivers/gpu/drm/nouveau/nouveau_abi16.h |  1 -
 2 files changed, 2 insertions(+), 23 deletions(-)
drivers/gpu/drm/nouveau/nouveau_abi16.c +2 -22
index 5341d96ffc85..5ebd19ece13b 100644
@@ -46,25 +46,9 @@ nouveau_abi16(struct drm_file *file_priv)
 		struct nouveau_abi16 *abi16;
 		cli->abi16 = abi16 = kzalloc(sizeof(*abi16), GFP_KERNEL);
 		if (cli->abi16) {
-			struct nv_device_v0 args = {
-				.device = ~0ULL,
-			};
-
 			abi16->cli = cli;
 			INIT_LIST_HEAD(&abi16->channels);
 			INIT_LIST_HEAD(&abi16->objects);
-
-			/* allocate device object targeting client's default
-			 * device (ie. the one that belongs to the fd it
-			 * opened)
-			 */
-			if (nvif_device_ctor(&cli->base.object, "abi16Device",
-					     0, NV_DEVICE, &args, sizeof(args),
-					     &abi16->device) == 0)
-				return cli->abi16;
-
-			kfree(cli->abi16);
-			cli->abi16 = NULL;
 		}
 	}
 	return cli->abi16;
@@ -235,9 +219,6 @@ nouveau_abi16_fini(struct nouveau_abi16 *abi16)
 		nouveau_abi16_chan_fini(abi16, chan);
 	}
 
-	/* destroy the device object */
-	nvif_device_dtor(&abi16->device);
-
 	kfree(cli->abi16);
 	cli->abi16 = NULL;
 }
@@ -351,7 +332,7 @@ nouveau_abi16_ioctl_channel_alloc(ABI16_IOCTL_ARGS)
 	struct nouveau_drm *drm = nouveau_drm(dev);
 	struct nouveau_abi16 *abi16 = nouveau_abi16_get(file_priv);
 	struct nouveau_abi16_chan *chan;
-	struct nvif_device *device;
+	struct nvif_device *device = &drm->device;
 	u64 engine, runm;
 	int ret;
 
@@ -368,7 +349,6 @@ nouveau_abi16_ioctl_channel_alloc(ABI16_IOCTL_ARGS)
 	 */
 	__nouveau_cli_disable_uvmm_noinit(cli);
 
-	device = &abi16->device;
 	engine = NV_DEVICE_HOST_RUNLIST_ENGINES_GR;
 
 	/* hack to allow channel engine type specification on kepler */
@@ -634,7 +614,7 @@ nouveau_abi16_ioctl_notifierobj_alloc(ABI16_IOCTL_ARGS)
 	struct nouveau_abi16 *abi16 = nouveau_abi16_get(file_priv);
 	struct nouveau_abi16_chan *chan;
 	struct nouveau_abi16_ntfy *ntfy;
-	struct nvif_device *device = &abi16->device;
+	struct nvif_device *device = &drm->device;
 	struct nvif_client *client;
 	struct nv_dma_v0 args = {};
 	int ret;
drivers/gpu/drm/nouveau/nouveau_abi16.h +0 -1
index 75a883a44e04..4743459ea14c 100644
@@ -31,7 +31,6 @@ struct nouveau_abi16_chan {
 
 struct nouveau_abi16 {
 	struct nouveau_cli *cli;
-	struct nvif_device device;
 	struct list_head channels;
 	u64 handles;
 	struct list_head objects;
Signature · 1 line
2.41.0
author
#15 lore raw

PATCH 14/156 drm/nouveau: remove abi16->handles

In reply to Ben Skeggs

- hasn't been needed since 2015...

---
 drivers/gpu/drm/nouveau/nouveau_abi16.h | 1 -
 1 file changed, 1 deletion(-)
drivers/gpu/drm/nouveau/nouveau_abi16.h +0 -1
index 4743459ea14c..af6b4e1cefd2 100644
@@ -32,7 +32,6 @@ struct nouveau_abi16_chan {
 struct nouveau_abi16 {
 	struct nouveau_cli *cli;
 	struct list_head channels;
-	u64 handles;
 	struct list_head objects;
 };
 
Signature · 1 line
2.41.0
author
#16 lore raw

PATCH 15/156 drm/nouveau: store nvkm_device pointer in nouveau_drm

In reply to Ben Skeggs

- removes the need for a nvkm_device_find(), which is going away
- will be needed later when cleaning up nvif_driver init

---
 drivers/gpu/drm/nouveau/nouveau_drm.c | 13 +++++--------
 drivers/gpu/drm/nouveau/nouveau_drv.h |  1 +
 2 files changed, 6 insertions(+), 8 deletions(-)
drivers/gpu/drm/nouveau/nouveau_drm.c +5 -8
index c0d74be4c47b..8d34a4cf2900 100644
@@ -561,7 +561,7 @@ nouveau_parent = {
 };
 
 static int
-nouveau_drm_device_init(struct drm_device *dev)
+nouveau_drm_device_init(struct drm_device *dev, struct nvkm_device *nvkm)
 {
 	static const struct nvif_mclass
 	mmus[] = {
@@ -577,6 +577,7 @@ nouveau_drm_device_init(struct drm_device *dev)
 		return -ENOMEM;
 	dev->dev_private = drm;
 	drm->dev = dev;
+	drm->nvkm = nvkm;
 
 	nvif_parent_ctor(&nouveau_parent, &drm->parent);
 
@@ -863,7 +864,7 @@ static int nouveau_drm_probe(struct pci_dev *pdev,
 
 	pci_set_drvdata(pdev, drm_dev);
 
-	ret = nouveau_drm_device_init(drm_dev);
+	ret = nouveau_drm_device_init(drm_dev, device);
 	if (ret)
 		goto fail_pci;
 
@@ -894,14 +895,10 @@ void
 nouveau_drm_device_remove(struct drm_device *dev)
 {
 	struct nouveau_drm *drm = nouveau_drm(dev);
-	struct nvkm_client *client;
-	struct nvkm_device *device;
+	struct nvkm_device *device = drm->nvkm;
 
 	drm_dev_unplug(dev);
 
-	client = nvxx_client(&drm->client.base);
-	device = nvkm_device_find(client->device);
-
 	nouveau_drm_device_fini(dev);
 	drm_dev_put(dev);
 	nvkm_device_del(&device);
@@ -1409,7 +1406,7 @@ nouveau_platform_device_create(const struct nvkm_device_tegra_func *func,
 		goto err_free;
 	}
 
-	err = nouveau_drm_device_init(drm);
+	err = nouveau_drm_device_init(drm, *pdevice);
 	if (err)
 		goto err_put;
 
drivers/gpu/drm/nouveau/nouveau_drv.h +1 -0
index 683600db4ff9..35dfc95b32ed 100644
@@ -201,6 +201,7 @@ u_memcpya(uint64_t user, unsigned int nmemb, unsigned int size)
 #include <nvif/parent.h>
 
 struct nouveau_drm {
+	struct nvkm_device *nvkm;
 	struct nvif_parent parent;
 	struct mutex client_mutex;
 	struct nvif_client _client;
Signature · 1 line
2.41.0
author
#17 lore raw

PATCH 16/156 drm/nouveau: create pci device once

In reply to Ben Skeggs

HW isn't touched anymore (aside from detection) until the first nvif_device has been allocated, so we no longer need a separate probe-only step before kicking efifb (etc) off the HW.

---
 drivers/gpu/drm/nouveau/nouveau_drm.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)
drivers/gpu/drm/nouveau/nouveau_drm.c +2 -9
index 8d34a4cf2900..9a4f2b0a8463 100644
@@ -830,23 +830,16 @@ static int nouveau_drm_probe(struct pci_dev *pdev,
 	/* We need to check that the chipset is supported before booting
 	 * fbdev off the hardware, as there's no way to put it back.
 	 */
-	ret = nvkm_device_pci_new(pdev, nouveau_config, "error",
-				  true, false, 0, &device);
+	ret = nvkm_device_pci_new(pdev, nouveau_config, nouveau_debug,
+				  true, true, ~0ULL, &device);
 	if (ret)
 		return ret;
 
-	nvkm_device_del(&device);
-
 	/* Remove conflicting drivers (vesafb, efifb etc). */
 	ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, &driver_pci);
 	if (ret)
 		return ret;
 
-	ret = nvkm_device_pci_new(pdev, nouveau_config, nouveau_debug,
-				  true, true, ~0ULL, &device);
-	if (ret)
-		return ret;
-
 	pci_set_master(pdev);
 
 	if (nouveau_atomic)
Signature · 1 line
2.41.0
author
#18 lore raw

PATCH 17/156 drm/nouveau: remove push pointer from nouveau_channel

In reply to Ben Skeggs

- the struct itself lives in nouveau_channel already, just use that

---
 drivers/gpu/drm/nouveau/dispnv04/crtc.c  |  4 +--
 drivers/gpu/drm/nouveau/nouveau_bo0039.c |  4 +--
 drivers/gpu/drm/nouveau/nouveau_bo5039.c |  4 +--
 drivers/gpu/drm/nouveau/nouveau_bo74c1.c |  2 +-
 drivers/gpu/drm/nouveau/nouveau_bo85b5.c |  2 +-
 drivers/gpu/drm/nouveau/nouveau_bo9039.c |  4 +--
 drivers/gpu/drm/nouveau/nouveau_bo90b5.c |  2 +-
 drivers/gpu/drm/nouveau/nouveau_boa0b5.c |  4 +--
 drivers/gpu/drm/nouveau/nouveau_chan.c   | 41 ++++++++++++------------
 drivers/gpu/drm/nouveau/nouveau_chan.h   |  3 +-
 drivers/gpu/drm/nouveau/nouveau_dmem.c   |  4 +--
 drivers/gpu/drm/nouveau/nouveau_drm.c    |  3 +-
 drivers/gpu/drm/nouveau/nouveau_gem.c    | 14 ++++----
 drivers/gpu/drm/nouveau/nv04_fence.c     |  2 +-
 drivers/gpu/drm/nouveau/nv10_fence.c     |  2 +-
 drivers/gpu/drm/nouveau/nv17_fence.c     |  4 +--
 drivers/gpu/drm/nouveau/nv84_fence.c     |  4 +--
 drivers/gpu/drm/nouveau/nvc0_fence.c     |  4 +--
 18 files changed, 53 insertions(+), 54 deletions(-)
drivers/gpu/drm/nouveau/dispnv04/crtc.c +2 -2
index 3535cf571300..8e8a43b28f71 100644
@@ -1100,7 +1100,7 @@ nv04_page_flip_emit(struct nouveau_channel *chan,
 	struct nouveau_fence_chan *fctx = chan->fence;
 	struct nouveau_drm *drm = chan->cli->drm;
 	struct drm_device *dev = drm->dev;
-	struct nvif_push *push = chan->chan.push;
+	struct nvif_push *push = &chan->chan.push;
 	unsigned long flags;
 	int ret;
 
@@ -1158,7 +1158,7 @@ nv04_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
 	if (!chan)
 		return -ENODEV;
 	cli = chan->cli;
-	push = chan->chan.push;
+	push = &chan->chan.push;
 
 	s = kzalloc(sizeof(*s), GFP_KERNEL);
 	if (!s)
drivers/gpu/drm/nouveau/nouveau_bo0039.c +2 -2
index 2babc6c47241..0b6758e024a1 100644
@@ -47,7 +47,7 @@ int
 nv04_bo_move_m2mf(struct nouveau_channel *chan, struct ttm_buffer_object *bo,
 		  struct ttm_resource *old_reg, struct ttm_resource *new_reg)
 {
-	struct nvif_push *push = chan->chan.push;
+	struct nvif_push *push = &chan->chan.push;
 	u32 src_ctxdma = nouveau_bo_mem_ctxdma(bo, chan, old_reg);
 	u32 src_offset = old_reg->start << PAGE_SHIFT;
 	u32 dst_ctxdma = nouveau_bo_mem_ctxdma(bo, chan, new_reg);
@@ -96,7 +96,7 @@ nv04_bo_move_m2mf(struct nouveau_channel *chan, struct ttm_buffer_object *bo,
 int
 nv04_bo_move_init(struct nouveau_channel *chan, u32 handle)
 {
-	struct nvif_push *push = chan->chan.push;
+	struct nvif_push *push = &chan->chan.push;
 	int ret;
 
 	ret = PUSH_WAIT(push, 4);
drivers/gpu/drm/nouveau/nouveau_bo5039.c +2 -2
index 0a6b1fce1108..c3de17548d97 100644
@@ -40,7 +40,7 @@ nv50_bo_move_m2mf(struct nouveau_channel *chan, struct ttm_buffer_object *bo,
 		  struct ttm_resource *old_reg, struct ttm_resource *new_reg)
 {
 	struct nouveau_mem *mem = nouveau_mem(old_reg);
-	struct nvif_push *push = chan->chan.push;
+	struct nvif_push *push = &chan->chan.push;
 	u64 length = new_reg->size;
 	u64 src_offset = mem->vma[0].addr;
 	u64 dst_offset = mem->vma[1].addr;
@@ -136,7 +136,7 @@ nv50_bo_move_m2mf(struct nouveau_channel *chan, struct ttm_buffer_object *bo,
 int
 nv50_bo_move_init(struct nouveau_channel *chan, u32 handle)
 {
-	struct nvif_push *push = chan->chan.push;
+	struct nvif_push *push = &chan->chan.push;
 	int ret;
 
 	ret = PUSH_WAIT(push, 6);
drivers/gpu/drm/nouveau/nouveau_bo74c1.c +1 -1
index 9b7ba31fae13..e6ef79de2498 100644
@@ -37,7 +37,7 @@ nv84_bo_move_exec(struct nouveau_channel *chan, struct ttm_buffer_object *bo,
 		  struct ttm_resource *old_reg, struct ttm_resource *new_reg)
 {
 	struct nouveau_mem *mem = nouveau_mem(old_reg);
-	struct nvif_push *push = chan->chan.push;
+	struct nvif_push *push = &chan->chan.push;
 	int ret;
 
 	ret = PUSH_WAIT(push, 7);
drivers/gpu/drm/nouveau/nouveau_bo85b5.c +1 -1
index a15a38a87a95..c4861d073ad4 100644
@@ -41,7 +41,7 @@ nva3_bo_move_copy(struct nouveau_channel *chan, struct ttm_buffer_object *bo,
 		  struct ttm_resource *old_reg, struct ttm_resource *new_reg)
 {
 	struct nouveau_mem *mem = nouveau_mem(old_reg);
-	struct nvif_push *push = chan->chan.push;
+	struct nvif_push *push = &chan->chan.push;
 	u64 src_offset = mem->vma[0].addr;
 	u64 dst_offset = mem->vma[1].addr;
 	u32 page_count = PFN_UP(new_reg->size);
drivers/gpu/drm/nouveau/nouveau_bo9039.c +2 -2
index d2bb2687d401..ad82269c7725 100644
@@ -38,7 +38,7 @@ int
 nvc0_bo_move_m2mf(struct nouveau_channel *chan, struct ttm_buffer_object *bo,
 		  struct ttm_resource *old_reg, struct ttm_resource *new_reg)
 {
-	struct nvif_push *push = chan->chan.push;
+	struct nvif_push *push = &chan->chan.push;
 	struct nouveau_mem *mem = nouveau_mem(old_reg);
 	u64 src_offset = mem->vma[0].addr;
 	u64 dst_offset = mem->vma[1].addr;
@@ -86,7 +86,7 @@ nvc0_bo_move_m2mf(struct nouveau_channel *chan, struct ttm_buffer_object *bo,
 int
 nvc0_bo_move_init(struct nouveau_channel *chan, u32 handle)
 {
-	struct nvif_push *push = chan->chan.push;
+	struct nvif_push *push = &chan->chan.push;
 	int ret;
 
 	ret = PUSH_WAIT(push, 2);
drivers/gpu/drm/nouveau/nouveau_bo90b5.c +1 -1
index 4618f4f5ab56..5eaeef9d25e4 100644
@@ -34,7 +34,7 @@ nvc0_bo_move_copy(struct nouveau_channel *chan, struct ttm_buffer_object *bo,
 		  struct ttm_resource *old_reg, struct ttm_resource *new_reg)
 {
 	struct nouveau_mem *mem = nouveau_mem(old_reg);
-	struct nvif_push *push = chan->chan.push;
+	struct nvif_push *push = &chan->chan.push;
 	u64 src_offset = mem->vma[0].addr;
 	u64 dst_offset = mem->vma[1].addr;
 	u32 page_count = PFN_UP(new_reg->size);
drivers/gpu/drm/nouveau/nouveau_boa0b5.c +2 -2
index 07a5c6302c98..dff2ae0e1e45 100644
@@ -39,7 +39,7 @@ nve0_bo_move_copy(struct nouveau_channel *chan, struct ttm_buffer_object *bo,
 		  struct ttm_resource *old_reg, struct ttm_resource *new_reg)
 {
 	struct nouveau_mem *mem = nouveau_mem(old_reg);
-	struct nvif_push *push = chan->chan.push;
+	struct nvif_push *push = &chan->chan.push;
 	int ret;
 
 	ret = PUSH_WAIT(push, 10);
@@ -78,7 +78,7 @@ nve0_bo_move_copy(struct nouveau_channel *chan, struct ttm_buffer_object *bo,
 int
 nve0_bo_move_init(struct nouveau_channel *chan, u32 handle)
 {
-	struct nvif_push *push = chan->chan.push;
+	struct nvif_push *push = &chan->chan.push;
 	int ret;
 
 	ret = PUSH_WAIT(push, 2);
drivers/gpu/drm/nouveau/nouveau_chan.c +20 -21

81 lines not on this page · raw message

drivers/gpu/drm/nouveau/nouveau_chan.h +1 -2
index 3ce9832c9528..016f668c0bc1 100644
@@ -8,8 +8,7 @@ struct nvif_device;
 
 struct nouveau_channel {
 	struct {
-		struct nvif_push _push;
-		struct nvif_push *push;
+		struct nvif_push push;
 	} chan;
 
 	struct nouveau_cli *cli;
drivers/gpu/drm/nouveau/nouveau_dmem.c +2 -2
index 6fb65b01d778..b2f20e33bf66 100644
@@ -443,7 +443,7 @@ nvc0b5_migrate_copy(struct nouveau_drm *drm, u64 npages,
 		    enum nouveau_aper dst_aper, u64 dst_addr,
 		    enum nouveau_aper src_aper, u64 src_addr)
 {
-	struct nvif_push *push = drm->dmem->migrate.chan->chan.push;
+	struct nvif_push *push = &drm->dmem->migrate.chan->chan.push;
 	u32 launch_dma = 0;
 	int ret;
 
@@ -516,7 +516,7 @@ static int
 nvc0b5_migrate_clear(struct nouveau_drm *drm, u32 length,
 		     enum nouveau_aper dst_aper, u64 dst_addr)
 {
-	struct nvif_push *push = drm->dmem->migrate.chan->chan.push;
+	struct nvif_push *push = &drm->dmem->migrate.chan->chan.push;
 	u32 launch_dma = 0;
 	int ret;
 
drivers/gpu/drm/nouveau/nouveau_drm.c +2 -1
index 9a4f2b0a8463..92b347b79919 100644
@@ -389,7 +389,8 @@ nouveau_accel_gr_init(struct nouveau_drm *drm)
 		}
 
 		if (ret == 0) {
-			struct nvif_push *push = drm->channel->chan.push;
+			struct nvif_push *push = &drm->channel->chan.push;
+
 			ret = PUSH_WAIT(push, 8);
 			if (ret == 0) {
 				if (device->info.chipset >= 0x11) {
drivers/gpu/drm/nouveau/nouveau_gem.c +7 -7
index 22f4ee483ff3..9ae2cee1c7c5 100644
@@ -871,7 +871,7 @@ nouveau_gem_ioctl_pushbuf(struct drm_device *dev, void *data,
 		}
 	} else
 	if (drm->client.device.info.chipset >= 0x25) {
-		ret = PUSH_WAIT(chan->chan.push, req->nr_push * 2);
+		ret = PUSH_WAIT(&chan->chan.push, req->nr_push * 2);
 		if (ret) {
 			NV_PRINTK(err, cli, "cal_space: %d\n", ret);
 			goto out;
@@ -881,11 +881,11 @@ nouveau_gem_ioctl_pushbuf(struct drm_device *dev, void *data,
 			struct nouveau_bo *nvbo = (void *)(unsigned long)
 				bo[push[i].bo_index].user_priv;
 
-			PUSH_CALL(chan->chan.push, nvbo->offset + push[i].offset);
-			PUSH_DATA(chan->chan.push, 0);
+			PUSH_CALL(&chan->chan.push, nvbo->offset + push[i].offset);
+			PUSH_DATA(&chan->chan.push, 0);
 		}
 	} else {
-		ret = PUSH_WAIT(chan->chan.push, req->nr_push * (2 + NOUVEAU_DMA_SKIPS));
+		ret = PUSH_WAIT(&chan->chan.push, req->nr_push * (2 + NOUVEAU_DMA_SKIPS));
 		if (ret) {
 			NV_PRINTK(err, cli, "jmp_space: %d\n", ret);
 			goto out;
@@ -914,10 +914,10 @@ nouveau_gem_ioctl_pushbuf(struct drm_device *dev, void *data,
 						push[i].length - 8) / 4, cmd);
 			}
 
-			PUSH_JUMP(chan->chan.push, nvbo->offset + push[i].offset);
-			PUSH_DATA(chan->chan.push, 0);
+			PUSH_JUMP(&chan->chan.push, nvbo->offset + push[i].offset);
+			PUSH_DATA(&chan->chan.push, 0);
 			for (j = 0; j < NOUVEAU_DMA_SKIPS; j++)
-				PUSH_DATA(chan->chan.push, 0);
+				PUSH_DATA(&chan->chan.push, 0);
 		}
 	}
 
drivers/gpu/drm/nouveau/nv04_fence.c +1 -1
index cdbc75e3d1f6..fa5c6029f783 100644
@@ -39,7 +39,7 @@ struct nv04_fence_priv {
 static int
 nv04_fence_emit(struct nouveau_fence *fence)
 {
-	struct nvif_push *push = unrcu_pointer(fence->channel)->chan.push;
+	struct nvif_push *push = &unrcu_pointer(fence->channel)->chan.push;
 	int ret = PUSH_WAIT(push, 2);
 	if (ret == 0) {
 		PUSH_NVSQ(push, NV_SW, 0x0150, fence->base.seqno);
drivers/gpu/drm/nouveau/nv10_fence.c +1 -1
index c6a0db5b9e21..1e45b5fcbf23 100644
@@ -32,7 +32,7 @@
 int
 nv10_fence_emit(struct nouveau_fence *fence)
 {
-	struct nvif_push *push = fence->channel->chan.push;
+	struct nvif_push *push = &fence->channel->chan.push;
 	int ret = PUSH_WAIT(push, 2);
 	if (ret == 0) {
 		PUSH_MTHD(push, NV06E, SET_REFERENCE, fence->base.seqno);
drivers/gpu/drm/nouveau/nv17_fence.c +2 -2
index 7fa52ec61b30..4415a6de680b 100644
@@ -39,8 +39,8 @@ nv17_fence_sync(struct nouveau_fence *fence,
 	struct nouveau_cli *cli = prev->cli;
 	struct nv10_fence_priv *priv = cli->drm->fence;
 	struct nv10_fence_chan *fctx = chan->fence;
-	struct nvif_push *ppush = prev->chan.push;
-	struct nvif_push *npush = chan->chan.push;
+	struct nvif_push *ppush = &prev->chan.push;
+	struct nvif_push *npush = &chan->chan.push;
 	u32 value;
 	int ret;
 
drivers/gpu/drm/nouveau/nv84_fence.c +2 -2
index 7f62089dc940..a9cbea2d1cc0 100644
@@ -35,7 +35,7 @@
 static int
 nv84_fence_emit32(struct nouveau_channel *chan, u64 virtual, u32 sequence)
 {
-	struct nvif_push *push = chan->chan.push;
+	struct nvif_push *push = &chan->chan.push;
 	int ret = PUSH_WAIT(push, 8);
 	if (ret == 0) {
 		PUSH_MTHD(push, NV826F, SET_CONTEXT_DMA_SEMAPHORE, chan->vram.handle);
@@ -58,7 +58,7 @@ nv84_fence_emit32(struct nouveau_channel *chan, u64 virtual, u32 sequence)
 static int
 nv84_fence_sync32(struct nouveau_channel *chan, u64 virtual, u32 sequence)
 {
-	struct nvif_push *push = chan->chan.push;
+	struct nvif_push *push = &chan->chan.push;
 	int ret = PUSH_WAIT(push, 7);
 	if (ret == 0) {
 		PUSH_MTHD(push, NV826F, SET_CONTEXT_DMA_SEMAPHORE, chan->vram.handle);
drivers/gpu/drm/nouveau/nvc0_fence.c +2 -2
index e1461c0b0779..a5e98d0d4217 100644
@@ -34,7 +34,7 @@
 static int
 nvc0_fence_emit32(struct nouveau_channel *chan, u64 virtual, u32 sequence)
 {
-	struct nvif_push *push = chan->chan.push;
+	struct nvif_push *push = &chan->chan.push;
 	int ret = PUSH_WAIT(push, 6);
 	if (ret == 0) {
 		PUSH_MTHD(push, NV906F, SEMAPHOREA,
@@ -57,7 +57,7 @@ nvc0_fence_emit32(struct nouveau_channel *chan, u64 virtual, u32 sequence)
 static int
 nvc0_fence_sync32(struct nouveau_channel *chan, u64 virtual, u32 sequence)
 {
-	struct nvif_push *push = chan->chan.push;
+	struct nvif_push *push = &chan->chan.push;
 	int ret = PUSH_WAIT(push, 5);
 	if (ret == 0) {
 		PUSH_MTHD(push, NV906F, SEMAPHOREA,
Signature · 1 line
2.41.0
author
#19 lore raw

PATCH 18/156 drm/nouveau/kms: remove a few unused struct members and fn decls

In reply to Ben Skeggs

- left-overs from the past

---
 drivers/gpu/drm/nouveau/dispnv50/disp.c | 3 ---
 drivers/gpu/drm/nouveau/dispnv50/disp.h | 9 ---------
 2 files changed, 12 deletions(-)
drivers/gpu/drm/nouveau/dispnv50/disp.c +0 -3
index f8ca57cc7af6..f4c9399e85ab 100644
@@ -236,8 +236,6 @@ nv50_dmac_create(struct nouveau_drm *drm,
 	u8 type = NVIF_MEM_COHERENT;
 	int ret;
 
-	mutex_init(&dmac->lock);
-
 	/* Pascal added support for 47-bit physical addresses, but some
 	 * parts of EVO still only accept 40-bit PAs.
 	 *
@@ -256,7 +254,6 @@ nv50_dmac_create(struct nouveau_drm *drm,
 	if (ret)
 		return ret;
 
-	dmac->ptr = dmac->_push.mem.object.map.ptr;
 	dmac->_push.wait = nv50_dmac_wait;
 	dmac->_push.kick = nv50_dmac_kick;
 	dmac->push = &dmac->_push;
drivers/gpu/drm/nouveau/dispnv50/disp.h +0 -9
index da3add95f354..b66a30915af2 100644
@@ -64,16 +64,10 @@ struct nv50_dmac {
 
 	struct nvif_push _push;
 	struct nvif_push *push;
-	u32 *ptr;
 
 	struct nvif_object sync;
 	struct nvif_object vram;
 
-	/* Protects against concurrent pushbuf access to this channel, lock is
-	 * grabbed by evo_wait (if the pushbuf reservation is successful) and
-	 * dropped again by evo_kick. */
-	struct mutex lock;
-
 	u32 cur;
 	u32 put;
 	u32 max;
@@ -108,9 +102,6 @@ void nv50_dmac_destroy(struct nv50_dmac *);
  */
 struct nouveau_encoder *nv50_real_outp(struct drm_encoder *encoder);
 
-u32 *evo_wait(struct nv50_dmac *, int nr);
-void evo_kick(u32 *, struct nv50_dmac *);
-
 extern const u64 disp50xx_modifiers[];
 extern const u64 disp90xx_modifiers[];
 extern const u64 wndwc57e_modifiers[];
Signature · 1 line
2.41.0
author
#20 lore raw

PATCH 19/156 drm/nouveau/kms: remove push pointer from nv50_dmac

In reply to Ben Skeggs

- just use the struct itself

---
 drivers/gpu/drm/nouveau/dispnv50/base507c.c | 18 +++++------
 drivers/gpu/drm/nouveau/dispnv50/base827c.c |  2 +-
 drivers/gpu/drm/nouveau/dispnv50/base907c.c | 10 +++---
 drivers/gpu/drm/nouveau/dispnv50/core507d.c |  6 ++--
 drivers/gpu/drm/nouveau/dispnv50/corec37d.c |  6 ++--
 drivers/gpu/drm/nouveau/dispnv50/corec57d.c |  2 +-
 drivers/gpu/drm/nouveau/dispnv50/crc907d.c  |  4 +--
 drivers/gpu/drm/nouveau/dispnv50/crcc37d.c  |  4 +--
 drivers/gpu/drm/nouveau/dispnv50/crcc57d.c  |  2 +-
 drivers/gpu/drm/nouveau/dispnv50/dac507d.c  |  2 +-
 drivers/gpu/drm/nouveau/dispnv50/dac907d.c  |  2 +-
 drivers/gpu/drm/nouveau/dispnv50/disp.c     | 35 ++++++++++-----------
 drivers/gpu/drm/nouveau/dispnv50/disp.h     |  3 +-
 drivers/gpu/drm/nouveau/dispnv50/head507d.c | 24 +++++++-------
 drivers/gpu/drm/nouveau/dispnv50/head827d.c | 10 +++---
 drivers/gpu/drm/nouveau/dispnv50/head907d.c | 26 +++++++--------
 drivers/gpu/drm/nouveau/dispnv50/head917d.c |  6 ++--
 drivers/gpu/drm/nouveau/dispnv50/headc37d.c | 18 +++++------
 drivers/gpu/drm/nouveau/dispnv50/headc57d.c | 12 +++----
 drivers/gpu/drm/nouveau/dispnv50/ovly507e.c |  4 +--
 drivers/gpu/drm/nouveau/dispnv50/ovly827e.c |  2 +-
 drivers/gpu/drm/nouveau/dispnv50/ovly907e.c |  2 +-
 drivers/gpu/drm/nouveau/dispnv50/pior507d.c |  2 +-
 drivers/gpu/drm/nouveau/dispnv50/sor507d.c  |  2 +-
 drivers/gpu/drm/nouveau/dispnv50/sor907d.c  |  2 +-
 drivers/gpu/drm/nouveau/dispnv50/sorc37d.c  |  2 +-
 drivers/gpu/drm/nouveau/dispnv50/wimmc37b.c |  4 +--
 drivers/gpu/drm/nouveau/dispnv50/wndwc37e.c | 22 ++++++-------
 drivers/gpu/drm/nouveau/dispnv50/wndwc57e.c | 10 +++---
 drivers/gpu/drm/nouveau/dispnv50/wndwc67e.c |  2 +-
 30 files changed, 122 insertions(+), 124 deletions(-)
drivers/gpu/drm/nouveau/dispnv50/base507c.c +9 -9
index e36a473f2075..a431f6c5f6fa 100644
@@ -35,7 +35,7 @@
 int
 base507c_update(struct nv50_wndw *wndw, u32 *interlock)
 {
-	struct nvif_push *push = wndw->wndw.push;
+	struct nvif_push *push = &wndw->wndw.push;
 	int ret;
 
 	if ((ret = PUSH_WAIT(push, 2)))
@@ -48,7 +48,7 @@ base507c_update(struct nv50_wndw *wndw, u32 *interlock)
 int
 base507c_image_clr(struct nv50_wndw *wndw)
 {
-	struct nvif_push *push = wndw->wndw.push;
+	struct nvif_push *push = &wndw->wndw.push;
 	int ret;
 
 	if ((ret = PUSH_WAIT(push, 4)))
@@ -65,7 +65,7 @@ base507c_image_clr(struct nv50_wndw *wndw)
 static int
 base507c_image_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
 {
-	struct nvif_push *push = wndw->wndw.push;
+	struct nvif_push *push = &wndw->wndw.push;
 	int ret;
 
 	if ((ret = PUSH_WAIT(push, 13)))
@@ -118,7 +118,7 @@ base507c_image_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
 int
 base507c_xlut_clr(struct nv50_wndw *wndw)
 {
-	struct nvif_push *push = wndw->wndw.push;
+	struct nvif_push *push = &wndw->wndw.push;
 	int ret;
 
 	if ((ret = PUSH_WAIT(push, 2)))
@@ -132,7 +132,7 @@ base507c_xlut_clr(struct nv50_wndw *wndw)
 int
 base507c_xlut_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
 {
-	struct nvif_push *push = wndw->wndw.push;
+	struct nvif_push *push = &wndw->wndw.push;
 	int ret;
 
 	if ((ret = PUSH_WAIT(push, 2)))
@@ -158,7 +158,7 @@ base507c_ntfy_wait_begun(struct nouveau_bo *bo, u32 offset,
 int
 base507c_ntfy_clr(struct nv50_wndw *wndw)
 {
-	struct nvif_push *push = wndw->wndw.push;
+	struct nvif_push *push = &wndw->wndw.push;
 	int ret;
 
 	if ((ret = PUSH_WAIT(push, 2)))
@@ -171,7 +171,7 @@ base507c_ntfy_clr(struct nv50_wndw *wndw)
 int
 base507c_ntfy_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
 {
-	struct nvif_push *push = wndw->wndw.push;
+	struct nvif_push *push = &wndw->wndw.push;
 	int ret;
 
 	if ((ret = PUSH_WAIT(push, 3)))
@@ -195,7 +195,7 @@ base507c_ntfy_reset(struct nouveau_bo *bo, u32 offset)
 int
 base507c_sema_clr(struct nv50_wndw *wndw)
 {
-	struct nvif_push *push = wndw->wndw.push;
+	struct nvif_push *push = &wndw->wndw.push;
 	int ret;
 
 	if ((ret = PUSH_WAIT(push, 2)))
@@ -208,7 +208,7 @@ base507c_sema_clr(struct nv50_wndw *wndw)
 int
 base507c_sema_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
 {
-	struct nvif_push *push = wndw->wndw.push;
+	struct nvif_push *push = &wndw->wndw.push;
 	int ret;
 
 	if ((ret = PUSH_WAIT(push, 5)))
drivers/gpu/drm/nouveau/dispnv50/base827c.c +1 -1
index 093d4ba6910e..4545cc5f3a14 100644
@@ -28,7 +28,7 @@
 static int
 base827c_image_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
 {
-	struct nvif_push *push = wndw->wndw.push;
+	struct nvif_push *push = &wndw->wndw.push;
 	int ret;
 
 	if ((ret = PUSH_WAIT(push, 13)))
drivers/gpu/drm/nouveau/dispnv50/base907c.c +5 -5
index e6b0417c325b..4a2d5a259e15 100644
@@ -28,7 +28,7 @@
 static int
 base907c_image_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
 {
-	struct nvif_push *push = wndw->wndw.push;
+	struct nvif_push *push = &wndw->wndw.push;
 	int ret;
 
 	if ((ret = PUSH_WAIT(push, 10)))
@@ -65,7 +65,7 @@ base907c_image_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
 static int
 base907c_xlut_clr(struct nv50_wndw *wndw)
 {
-	struct nvif_push *push = wndw->wndw.push;
+	struct nvif_push *push = &wndw->wndw.push;
 	int ret;
 
 	if ((ret = PUSH_WAIT(push, 6)))
@@ -84,7 +84,7 @@ base907c_xlut_clr(struct nv50_wndw *wndw)
 static int
 base907c_xlut_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
 {
-	struct nvif_push *push = wndw->wndw.push;
+	struct nvif_push *push = &wndw->wndw.push;
 	int ret;
 
 	if ((ret = PUSH_WAIT(push, 6)))
@@ -156,7 +156,7 @@ base907c_csc(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw,
 static int
 base907c_csc_clr(struct nv50_wndw *wndw)
 {
-	struct nvif_push *push = wndw->wndw.push;
+	struct nvif_push *push = &wndw->wndw.push;
 	int ret;
 
 	if ((ret = PUSH_WAIT(push, 2)))
@@ -170,7 +170,7 @@ base907c_csc_clr(struct nv50_wndw *wndw)
 static int
 base907c_csc_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
 {
-	struct nvif_push *push = wndw->wndw.push;
+	struct nvif_push *push = &wndw->wndw.push;
 	int ret;
 
 	if ((ret = PUSH_WAIT(push, 13)))
drivers/gpu/drm/nouveau/dispnv50/core507d.c +3 -3
index 85845e3dc7ba..ce2cb78bbdd3 100644
@@ -33,7 +33,7 @@
 int
 core507d_update(struct nv50_core *core, u32 *interlock, bool ntfy)
 {
-	struct nvif_push *push = core->chan.push;
+	struct nvif_push *push = &core->chan.push;
 	int ret;
 
 	if ((ret = PUSH_WAIT(push, (ntfy ? 2 : 0) + 3)))
@@ -80,7 +80,7 @@ core507d_ntfy_init(struct nouveau_bo *bo, u32 offset)
 int
 core507d_read_caps(struct nv50_disp *disp)
 {
-	struct nvif_push *push = disp->core->chan.push;
+	struct nvif_push *push = &disp->core->chan.push;
 	int ret;
 
 	ret = PUSH_WAIT(push, 6);
@@ -130,7 +130,7 @@ core507d_caps_init(struct nouveau_drm *drm, struct nv50_disp *disp)
 int
 core507d_init(struct nv50_core *core)
 {
-	struct nvif_push *push = core->chan.push;
+	struct nvif_push *push = &core->chan.push;
 	int ret;
 
 	if ((ret = PUSH_WAIT(push, 2)))
drivers/gpu/drm/nouveau/dispnv50/corec37d.c +3 -3
index 42f877f2ced2..7f637b8830be 100644
@@ -33,7 +33,7 @@
 int
 corec37d_wndw_owner(struct nv50_core *core)
 {
-	struct nvif_push *push = core->chan.push;
+	struct nvif_push *push = &core->chan.push;
 	const u32 windows = 8; /*XXX*/
 	int ret, i;
 
@@ -51,7 +51,7 @@ corec37d_wndw_owner(struct nv50_core *core)
 int
 corec37d_update(struct nv50_core *core, u32 *interlock, bool ntfy)
 {
-	struct nvif_push *push = core->chan.push;
+	struct nvif_push *push = &core->chan.push;
 	int ret;
 
 	if ((ret = PUSH_WAIT(push, (ntfy ? 2 * 2 : 0) + 5)))
@@ -127,7 +127,7 @@ int corec37d_caps_init(struct nouveau_drm *drm, struct nv50_disp *disp)
 static int
 corec37d_init(struct nv50_core *core)
 {
-	struct nvif_push *push = core->chan.push;
+	struct nvif_push *push = &core->chan.push;
 	const u32 windows = 8; /*XXX*/
 	int ret, i;
 
drivers/gpu/drm/nouveau/dispnv50/corec57d.c +1 -1
index 53b1e2a569c1..421d0d57e1d8 100644
@@ -29,7 +29,7 @@
 static int
 corec57d_init(struct nv50_core *core)
 {
-	struct nvif_push *push = core->chan.push;
+	struct nvif_push *push = &core->chan.push;
 	const u32 windows = 8; /*XXX*/
 	int ret, i;
 
drivers/gpu/drm/nouveau/dispnv50/crc907d.c +2 -2
index f9ad641555b7..a674ba435b05 100644
@@ -26,7 +26,7 @@ static int
 crc907d_set_src(struct nv50_head *head, int or, enum nv50_crc_source_type source,
 		struct nv50_crc_notifier_ctx *ctx)
 {
-	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+	struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
 	const int i = head->base.index;
 	u32 crc_args = NVDEF(NV907D, HEAD_SET_CRC_CONTROL, CONTROLLING_CHANNEL, CORE) |
 		       NVDEF(NV907D, HEAD_SET_CRC_CONTROL, EXPECT_BUFFER_COLLAPSE, FALSE) |
@@ -74,7 +74,7 @@ crc907d_set_src(struct nv50_head *head, int or, enum nv50_crc_source_type source
 static int
 crc907d_set_ctx(struct nv50_head *head, struct nv50_crc_notifier_ctx *ctx)
 {
-	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+	struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
 	const int i = head->base.index;
 	int ret;
 
drivers/gpu/drm/nouveau/dispnv50/crcc37d.c +2 -2
index f10f6c484408..4821ce32f9ed 100644
@@ -15,7 +15,7 @@ static int
 crcc37d_set_src(struct nv50_head *head, int or, enum nv50_crc_source_type source,
 		struct nv50_crc_notifier_ctx *ctx)
 {
-	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+	struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
 	const int i = head->base.index;
 	u32 crc_args = NVVAL(NVC37D, HEAD_SET_CRC_CONTROL, CONTROLLING_CHANNEL, i * 4) |
 		       NVDEF(NVC37D, HEAD_SET_CRC_CONTROL, EXPECT_BUFFER_COLLAPSE, FALSE) |
@@ -53,7 +53,7 @@ crcc37d_set_src(struct nv50_head *head, int or, enum nv50_crc_source_type source
 
 int crcc37d_set_ctx(struct nv50_head *head, struct nv50_crc_notifier_ctx *ctx)
 {
-	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+	struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
 	const int i = head->base.index;
 	int ret;
 
drivers/gpu/drm/nouveau/dispnv50/crcc57d.c +1 -1
index cc0130e3d496..ad591dcb0bc9 100644
@@ -13,7 +13,7 @@
 static int crcc57d_set_src(struct nv50_head *head, int or, enum nv50_crc_source_type source,
 			   struct nv50_crc_notifier_ctx *ctx)
 {
-	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+	struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
 	const int i = head->base.index;
 	u32 crc_args = NVDEF(NVC57D, HEAD_SET_CRC_CONTROL, CONTROLLING_CHANNEL, CORE) |
 		       NVDEF(NVC57D, HEAD_SET_CRC_CONTROL, EXPECT_BUFFER_COLLAPSE, FALSE) |
drivers/gpu/drm/nouveau/dispnv50/dac507d.c +1 -1
index 09de78d96679..99ae692f219e 100644
@@ -29,7 +29,7 @@ static int
 dac507d_ctrl(struct nv50_core *core, int or, u32 ctrl,
 	     struct nv50_head_atom *asyh)
 {
-	struct nvif_push *push = core->chan.push;
+	struct nvif_push *push = &core->chan.push;
 	u32 sync = 0;
 	int ret;
 
drivers/gpu/drm/nouveau/dispnv50/dac907d.c +1 -1
index 95efa625b691..74bc9f81e3f1 100644
@@ -29,7 +29,7 @@ static int
 dac907d_ctrl(struct nv50_core *core, int or, u32 ctrl,
 	     struct nv50_head_atom *asyh)
 {
-	struct nvif_push *push = core->chan.push;
+	struct nvif_push *push = &core->chan.push;
 	int ret;
 
 	if ((ret = PUSH_WAIT(push, 2)))
drivers/gpu/drm/nouveau/dispnv50/disp.c +17 -18
index f4c9399e85ab..b64b283f8e9c 100644
@@ -124,20 +124,20 @@ nv50_dmac_destroy(struct nv50_dmac *dmac)
 
 	nv50_chan_destroy(&dmac->base);
 
-	nvif_mem_dtor(&dmac->_push.mem);
+	nvif_mem_dtor(&dmac->push.mem);
 }
 
 static void
 nv50_dmac_kick(struct nvif_push *push)
 {
-	struct nv50_dmac *dmac = container_of(push, typeof(*dmac), _push);
+	struct nv50_dmac *dmac = container_of(push, typeof(*dmac), push);
 
-	dmac->cur = push->cur - (u32 __iomem *)dmac->_push.mem.object.map.ptr;
+	dmac->cur = push->cur - (u32 __iomem *)dmac->push.mem.object.map.ptr;
 	if (dmac->put != dmac->cur) {
 		/* Push buffer fetches are not coherent with BAR1, we need to ensure
 		 * writes have been flushed right through to VRAM before writing PUT.
 		 */
-		if (dmac->push->mem.type & NVIF_MEM_VRAM) {
+		if (dmac->push.mem.type & NVIF_MEM_VRAM) {
 			struct nvif_device *device = dmac->base.device;
 			nvif_wr32(&device->object, 0x070000, 0x00000001);
 			nvif_msec(device, 2000,
@@ -172,7 +172,7 @@ nv50_dmac_wind(struct nv50_dmac *dmac)
 	if (get == 0) {
 		/* Corner-case, HW idle, but non-committed work pending. */
 		if (dmac->put == 0)
-			nv50_dmac_kick(dmac->push);
+			nv50_dmac_kick(&dmac->push);
 
 		if (nvif_msec(dmac->base.device, 2000,
 			if (NVIF_TV32(&dmac->base.user, NV507C, GET, PTR, >, 0))
@@ -181,7 +181,7 @@ nv50_dmac_wind(struct nv50_dmac *dmac)
 			return -ETIMEDOUT;
 	}
 
-	PUSH_RSVD(dmac->push, PUSH_JUMP(dmac->push, 0));
+	PUSH_RSVD(&dmac->push, PUSH_JUMP(&dmac->push, 0));
 	dmac->cur = 0;
 	return 0;
 }
@@ -189,19 +189,19 @@ nv50_dmac_wind(struct nv50_dmac *dmac)
 static int
 nv50_dmac_wait(struct nvif_push *push, u32 size)
 {
-	struct nv50_dmac *dmac = container_of(push, typeof(*dmac), _push);
+	struct nv50_dmac *dmac = container_of(push, typeof(*dmac), push);
 	int free;
 
 	if (WARN_ON(size > dmac->max))
 		return -EINVAL;
 
-	dmac->cur = push->cur - (u32 __iomem *)dmac->_push.mem.object.map.ptr;
+	dmac->cur = push->cur - (u32 __iomem *)dmac->push.mem.object.map.ptr;
 	if (dmac->cur + size >= dmac->max) {
 		int ret = nv50_dmac_wind(dmac);
 		if (ret)
 			return ret;
 
-		push->cur = dmac->_push.mem.object.map.ptr;
+		push->cur = dmac->push.mem.object.map.ptr;
 		push->cur = push->cur + dmac->cur;
 		nv50_dmac_kick(push);
 	}
@@ -214,7 +214,7 @@ nv50_dmac_wait(struct nvif_push *push, u32 size)
 		return -ETIMEDOUT;
 	}
 
-	push->bgn = dmac->_push.mem.object.map.ptr;
+	push->bgn = dmac->push.mem.object.map.ptr;
 	push->bgn = push->bgn + dmac->cur;
 	push->cur = push->bgn;
 	push->end = push->cur + free;
@@ -250,16 +250,15 @@ nv50_dmac_create(struct nouveau_drm *drm,
 		type |= NVIF_MEM_VRAM;
 
 	ret = nvif_mem_ctor_map(&drm->mmu, "kmsChanPush", type, 0x1000,
-				&dmac->_push.mem);
+				&dmac->push.mem);
 	if (ret)
 		return ret;
 
-	dmac->_push.wait = nv50_dmac_wait;
-	dmac->_push.kick = nv50_dmac_kick;
-	dmac->push = &dmac->_push;
-	dmac->push->bgn = dmac->_push.mem.object.map.ptr;
-	dmac->push->cur = dmac->push->bgn;
-	dmac->push->end = dmac->push->bgn;
+	dmac->push.wait = nv50_dmac_wait;
+	dmac->push.kick = nv50_dmac_kick;
+	dmac->push.bgn = dmac->push.mem.object.map.ptr;
+	dmac->push.cur = dmac->push.bgn;
+	dmac->push.end = dmac->push.bgn;
 	dmac->max = 0x1000/4 - 1;
 
 	/* EVO channels are affected by a HW bug where the last 12 DWORDs
@@ -268,7 +267,7 @@ nv50_dmac_create(struct nouveau_drm *drm,
 	if (disp->oclass < GV100_DISP)
 		dmac->max -= 12;
 
-	args->pushbuf = nvif_handle(&dmac->_push.mem.object);
+	args->pushbuf = nvif_handle(&dmac->push.mem.object);
 
 	ret = nv50_chan_create(device, disp, oclass, head, data, size,
 			       &dmac->base);
drivers/gpu/drm/nouveau/dispnv50/disp.h +1 -2
index b66a30915af2..15f9242b72ac 100644
@@ -62,8 +62,7 @@ struct nv50_chan {
 struct nv50_dmac {
 	struct nv50_chan base;
 
-	struct nvif_push _push;
-	struct nvif_push *push;
+	struct nvif_push push;
 
 	struct nvif_object sync;
 	struct nvif_object vram;
drivers/gpu/drm/nouveau/dispnv50/head507d.c +12 -12
index 0edd4e520c8e..7fa1e0279d7d 100644
@@ -29,7 +29,7 @@
 int
 head507d_procamp(struct nv50_head *head, struct nv50_head_atom *asyh)
 {
-	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+	struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
 	const int i = head->base.index;
 	int ret;
 
@@ -48,7 +48,7 @@ head507d_procamp(struct nv50_head *head, struct nv50_head_atom *asyh)
 int
 head507d_dither(struct nv50_head *head, struct nv50_head_atom *asyh)
 {
-	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+	struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
 	const int i = head->base.index;
 	int ret;
 
@@ -66,7 +66,7 @@ head507d_dither(struct nv50_head *head, struct nv50_head_atom *asyh)
 int
 head507d_ovly(struct nv50_head *head, struct nv50_head_atom *asyh)
 {
-	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+	struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
 	const int i = head->base.index;
 	u32 bounds = 0;
 	int ret;
@@ -94,7 +94,7 @@ head507d_ovly(struct nv50_head *head, struct nv50_head_atom *asyh)
 int
 head507d_base(struct nv50_head *head, struct nv50_head_atom *asyh)
 {
-	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+	struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
 	const int i = head->base.index;
 	u32 bounds = 0;
 	int ret;
@@ -122,7 +122,7 @@ head507d_base(struct nv50_head *head, struct nv50_head_atom *asyh)
 static int
 head507d_curs_clr(struct nv50_head *head)
 {
-	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+	struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
 	const int i = head->base.index;
 	int ret;
 
@@ -139,7 +139,7 @@ head507d_curs_clr(struct nv50_head *head)
 static int
 head507d_curs_set(struct nv50_head *head, struct nv50_head_atom *asyh)
 {
-	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+	struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
 	const int i = head->base.index;
 	int ret;
 
@@ -188,7 +188,7 @@ head507d_curs_layout(struct nv50_head *head, struct nv50_wndw_atom *asyw,
 int
 head507d_core_clr(struct nv50_head *head)
 {
-	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+	struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
 	const int i = head->base.index;
 	int ret;
 
@@ -202,7 +202,7 @@ head507d_core_clr(struct nv50_head *head)
 static int
 head507d_core_set(struct nv50_head *head, struct nv50_head_atom *asyh)
 {
-	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+	struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
 	const int i = head->base.index;
 	int ret;
 
@@ -278,7 +278,7 @@ head507d_core_calc(struct nv50_head *head, struct nv50_head_atom *asyh)
 static int
 head507d_olut_clr(struct nv50_head *head)
 {
-	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+	struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
 	const int i = head->base.index;
 	int ret;
 
@@ -293,7 +293,7 @@ head507d_olut_clr(struct nv50_head *head)
 static int
 head507d_olut_set(struct nv50_head *head, struct nv50_head_atom *asyh)
 {
-	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+	struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
 	const int i = head->base.index;
 	int ret;
 
@@ -345,7 +345,7 @@ head507d_olut(struct nv50_head *head, struct nv50_head_atom *asyh, int size)
 int
 head507d_mode(struct nv50_head *head, struct nv50_head_atom *asyh)
 {
-	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+	struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
 	struct nv50_head_mode *m = &asyh->mode;
 	const int i = head->base.index;
 	int ret;
@@ -400,7 +400,7 @@ head507d_mode(struct nv50_head *head, struct nv50_head_atom *asyh)
 int
 head507d_view(struct nv50_head *head, struct nv50_head_atom *asyh)
 {
-	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+	struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
 	const int i = head->base.index;
 	int ret;
 
drivers/gpu/drm/nouveau/dispnv50/head827d.c +5 -5
index 194d1771c481..1545d576fe9c 100644
@@ -29,7 +29,7 @@
 static int
 head827d_curs_clr(struct nv50_head *head)
 {
-	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+	struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
 	const int i = head->base.index;
 	int ret;
 
@@ -48,7 +48,7 @@ head827d_curs_clr(struct nv50_head *head)
 static int
 head827d_curs_set(struct nv50_head *head, struct nv50_head_atom *asyh)
 {
-	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+	struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
 	const int i = head->base.index;
 	int ret;
 
@@ -73,7 +73,7 @@ head827d_curs_set(struct nv50_head *head, struct nv50_head_atom *asyh)
 static int
 head827d_core_set(struct nv50_head *head, struct nv50_head_atom *asyh)
 {
-	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+	struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
 	const int i = head->base.index;
 	int ret;
 
@@ -110,7 +110,7 @@ head827d_core_set(struct nv50_head *head, struct nv50_head_atom *asyh)
 static int
 head827d_olut_clr(struct nv50_head *head)
 {
-	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+	struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
 	const int i = head->base.index;
 	int ret;
 
@@ -127,7 +127,7 @@ head827d_olut_clr(struct nv50_head *head)
 static int
 head827d_olut_set(struct nv50_head *head, struct nv50_head_atom *asyh)
 {
-	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+	struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
 	const int i = head->base.index;
 	int ret;
 
drivers/gpu/drm/nouveau/dispnv50/head907d.c +13 -13
index 18fe4c1e2d6a..6c9e0438e55c 100644
@@ -36,7 +36,7 @@
 int
 head907d_or(struct nv50_head *head, struct nv50_head_atom *asyh)
 {
-	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+	struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
 	const int i = head->base.index;
 	int ret;
 
@@ -57,7 +57,7 @@ head907d_or(struct nv50_head *head, struct nv50_head_atom *asyh)
 int
 head907d_procamp(struct nv50_head *head, struct nv50_head_atom *asyh)
 {
-	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+	struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
 	const int i = head->base.index;
 	int ret;
 
@@ -77,7 +77,7 @@ head907d_procamp(struct nv50_head *head, struct nv50_head_atom *asyh)
 static int
 head907d_dither(struct nv50_head *head, struct nv50_head_atom *asyh)
 {
-	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+	struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
 	const int i = head->base.index;
 	int ret;
 
@@ -95,7 +95,7 @@ head907d_dither(struct nv50_head *head, struct nv50_head_atom *asyh)
 int
 head907d_ovly(struct nv50_head *head, struct nv50_head_atom *asyh)
 {
-	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+	struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
 	const int i = head->base.index;
 	u32 bounds = 0;
 	int ret;
@@ -124,7 +124,7 @@ head907d_ovly(struct nv50_head *head, struct nv50_head_atom *asyh)
 static int
 head907d_base(struct nv50_head *head, struct nv50_head_atom *asyh)
 {
-	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+	struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
 	const int i = head->base.index;
 	u32 bounds = 0;
 	int ret;
@@ -152,7 +152,7 @@ head907d_base(struct nv50_head *head, struct nv50_head_atom *asyh)
 int
 head907d_curs_clr(struct nv50_head *head)
 {
-	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+	struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
 	const int i = head->base.index;
 	int ret;
 
@@ -171,7 +171,7 @@ head907d_curs_clr(struct nv50_head *head)
 int
 head907d_curs_set(struct nv50_head *head, struct nv50_head_atom *asyh)
 {
-	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+	struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
 	const int i = head->base.index;
 	int ret;
 
@@ -195,7 +195,7 @@ head907d_curs_set(struct nv50_head *head, struct nv50_head_atom *asyh)
 int
 head907d_core_clr(struct nv50_head *head)
 {
-	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+	struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
 	const int i = head->base.index;
 	int ret;
 
@@ -209,7 +209,7 @@ head907d_core_clr(struct nv50_head *head)
 int
 head907d_core_set(struct nv50_head *head, struct nv50_head_atom *asyh)
 {
-	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+	struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
 	const int i = head->base.index;
 	int ret;
 
@@ -246,7 +246,7 @@ head907d_core_set(struct nv50_head *head, struct nv50_head_atom *asyh)
 int
 head907d_olut_clr(struct nv50_head *head)
 {
-	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+	struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
 	const int i = head->base.index;
 	int ret;
 
@@ -263,7 +263,7 @@ head907d_olut_clr(struct nv50_head *head)
 int
 head907d_olut_set(struct nv50_head *head, struct nv50_head_atom *asyh)
 {
-	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+	struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
 	const int i = head->base.index;
 	int ret;
 
@@ -322,7 +322,7 @@ bool head907d_ilut_check(int size)
 int
 head907d_mode(struct nv50_head *head, struct nv50_head_atom *asyh)
 {
-	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+	struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
 	struct nv50_head_mode *m = &asyh->mode;
 	const int i = head->base.index;
 	int ret;
@@ -378,7 +378,7 @@ head907d_mode(struct nv50_head *head, struct nv50_head_atom *asyh)
 int
 head907d_view(struct nv50_head *head, struct nv50_head_atom *asyh)
 {
-	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+	struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
 	const int i = head->base.index;
 	int ret;
 
drivers/gpu/drm/nouveau/dispnv50/head917d.c +3 -3
index 4ce47b55f72c..2d9aee050510 100644
@@ -30,7 +30,7 @@
 static int
 head917d_dither(struct nv50_head *head, struct nv50_head_atom *asyh)
 {
-	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+	struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
 	const int i = head->base.index;
 	int ret;
 
@@ -48,7 +48,7 @@ head917d_dither(struct nv50_head *head, struct nv50_head_atom *asyh)
 static int
 head917d_base(struct nv50_head *head, struct nv50_head_atom *asyh)
 {
-	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+	struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
 	const int i = head->base.index;
 	u32 bounds = 0;
 	int ret;
@@ -77,7 +77,7 @@ head917d_base(struct nv50_head *head, struct nv50_head_atom *asyh)
 static int
 head917d_curs_set(struct nv50_head *head, struct nv50_head_atom *asyh)
 {
-	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+	struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
 	const int i = head->base.index;
 	int ret;
 
drivers/gpu/drm/nouveau/dispnv50/headc37d.c +9 -9
index a4a3b78ea42c..2bcb3790fc10 100644
@@ -30,7 +30,7 @@
 static int
 headc37d_or(struct nv50_head *head, struct nv50_head_atom *asyh)
 {
-	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+	struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
 	const int i = head->base.index;
 	u8 depth;
 	int ret;
@@ -64,7 +64,7 @@ headc37d_or(struct nv50_head *head, struct nv50_head_atom *asyh)
 static int
 headc37d_procamp(struct nv50_head *head, struct nv50_head_atom *asyh)
 {
-	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+	struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
 	const int i = head->base.index;
 	int ret;
 
@@ -85,7 +85,7 @@ headc37d_procamp(struct nv50_head *head, struct nv50_head_atom *asyh)
 int
 headc37d_dither(struct nv50_head *head, struct nv50_head_atom *asyh)
 {
-	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+	struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
 	const int i = head->base.index;
 	int ret;
 
@@ -104,7 +104,7 @@ headc37d_dither(struct nv50_head *head, struct nv50_head_atom *asyh)
 int
 headc37d_curs_clr(struct nv50_head *head)
 {
-	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+	struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
 	const int i = head->base.index;
 	int ret;
 
@@ -122,7 +122,7 @@ headc37d_curs_clr(struct nv50_head *head)
 int
 headc37d_curs_set(struct nv50_head *head, struct nv50_head_atom *asyh)
 {
-	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+	struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
 	const int i = head->base.index;
 	int ret;
 
@@ -161,7 +161,7 @@ headc37d_curs_format(struct nv50_head *head, struct nv50_wndw_atom *asyw,
 static int
 headc37d_olut_clr(struct nv50_head *head)
 {
-	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+	struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
 	const int i = head->base.index;
 	int ret;
 
@@ -175,7 +175,7 @@ headc37d_olut_clr(struct nv50_head *head)
 static int
 headc37d_olut_set(struct nv50_head *head, struct nv50_head_atom *asyh)
 {
-	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+	struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
 	const int i = head->base.index;
 	int ret;
 
@@ -209,7 +209,7 @@ headc37d_olut(struct nv50_head *head, struct nv50_head_atom *asyh, int size)
 static int
 headc37d_mode(struct nv50_head *head, struct nv50_head_atom *asyh)
 {
-	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+	struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
 	struct nv50_head_mode *m = &asyh->mode;
 	const int i = head->base.index;
 	int ret;
@@ -254,7 +254,7 @@ headc37d_mode(struct nv50_head *head, struct nv50_head_atom *asyh)
 int
 headc37d_view(struct nv50_head *head, struct nv50_head_atom *asyh)
 {
-	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+	struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
 	const int i = head->base.index;
 	int ret;
 
drivers/gpu/drm/nouveau/dispnv50/headc57d.c +6 -6
index 53b1248c40ec..fde4087e7691 100644
@@ -30,7 +30,7 @@
 static int
 headc57d_display_id(struct nv50_head *head, u32 display_id)
 {
-	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+	struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
 	int ret;
 
 	if ((ret = PUSH_WAIT(push, 2)))
@@ -43,7 +43,7 @@ headc57d_display_id(struct nv50_head *head, u32 display_id)
 static int
 headc57d_or(struct nv50_head *head, struct nv50_head_atom *asyh)
 {
-	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+	struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
 	const int i = head->base.index;
 	u8 depth;
 	int ret;
@@ -78,7 +78,7 @@ headc57d_or(struct nv50_head *head, struct nv50_head_atom *asyh)
 static int
 headc57d_procamp(struct nv50_head *head, struct nv50_head_atom *asyh)
 {
-	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+	struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
 	const int i = head->base.index;
 	int ret;
 
@@ -96,7 +96,7 @@ headc57d_procamp(struct nv50_head *head, struct nv50_head_atom *asyh)
 static int
 headc57d_olut_clr(struct nv50_head *head)
 {
-	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+	struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
 	const int i = head->base.index;
 	int ret;
 
@@ -110,7 +110,7 @@ headc57d_olut_clr(struct nv50_head *head)
 static int
 headc57d_olut_set(struct nv50_head *head, struct nv50_head_atom *asyh)
 {
-	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+	struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
 	const int i = head->base.index;
 	int ret;
 
@@ -201,7 +201,7 @@ headc57d_olut(struct nv50_head *head, struct nv50_head_atom *asyh, int size)
 static int
 headc57d_mode(struct nv50_head *head, struct nv50_head_atom *asyh)
 {
-	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+	struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
 	struct nv50_head_mode *m = &asyh->mode;
 	const int i = head->base.index;
 	int ret;
drivers/gpu/drm/nouveau/dispnv50/ovly507e.c +2 -2
index 73fcfb27c32c..654e506f8431 100644
@@ -33,7 +33,7 @@
 int
 ovly507e_scale_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
 {
-	struct nvif_push *push = wndw->wndw.push;
+	struct nvif_push *push = &wndw->wndw.push;
 	int ret;
 
 	if ((ret = PUSH_WAIT(push, 4)))
@@ -55,7 +55,7 @@ ovly507e_scale_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
 static int
 ovly507e_image_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
 {
-	struct nvif_push *push = wndw->wndw.push;
+	struct nvif_push *push = &wndw->wndw.push;
 	int ret;
 
 	if ((ret = PUSH_WAIT(push, 12)))
drivers/gpu/drm/nouveau/dispnv50/ovly827e.c +1 -1
index 02dc02d9260f..a5ae22ed663d 100644
@@ -32,7 +32,7 @@
 static int
 ovly827e_image_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
 {
-	struct nvif_push *push = wndw->wndw.push;
+	struct nvif_push *push = &wndw->wndw.push;
 	int ret;
 
 	if ((ret = PUSH_WAIT(push, 12)))
drivers/gpu/drm/nouveau/dispnv50/ovly907e.c +1 -1
index 645130d18a99..8cf0e18fa596 100644
@@ -29,7 +29,7 @@
 static int
 ovly907e_image_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
 {
-	struct nvif_push *push = wndw->wndw.push;
+	struct nvif_push *push = &wndw->wndw.push;
 	int ret;
 
 	if ((ret = PUSH_WAIT(push, 12)))
drivers/gpu/drm/nouveau/dispnv50/pior507d.c +1 -1
index 17d230256bdd..79507d169778 100644
@@ -30,7 +30,7 @@ static int
 pior507d_ctrl(struct nv50_core *core, int or, u32 ctrl,
 	      struct nv50_head_atom *asyh)
 {
-	struct nvif_push *push = core->chan.push;
+	struct nvif_push *push = &core->chan.push;
 	int ret;
 
 	if (asyh) {
drivers/gpu/drm/nouveau/dispnv50/sor507d.c +1 -1
index ca73d7710885..08cc9845322e 100644
@@ -30,7 +30,7 @@ static int
 sor507d_ctrl(struct nv50_core *core, int or, u32 ctrl,
 	     struct nv50_head_atom *asyh)
 {
-	struct nvif_push *push = core->chan.push;
+	struct nvif_push *push = &core->chan.push;
 	int ret;
 
 	if (asyh) {
drivers/gpu/drm/nouveau/dispnv50/sor907d.c +1 -1
index c86cd8fa61d6..23957cc8f326 100644
@@ -32,7 +32,7 @@ static int
 sor907d_ctrl(struct nv50_core *core, int or, u32 ctrl,
 	     struct nv50_head_atom *asyh)
 {
-	struct nvif_push *push = core->chan.push;
+	struct nvif_push *push = &core->chan.push;
 	int ret;
 
 	if ((ret = PUSH_WAIT(push, 2)))
drivers/gpu/drm/nouveau/dispnv50/sorc37d.c +1 -1
index 9eaef34816da..da05d4614e00 100644
@@ -29,7 +29,7 @@ static int
 sorc37d_ctrl(struct nv50_core *core, int or, u32 ctrl,
 	     struct nv50_head_atom *asyh)
 {
-	struct nvif_push *push = core->chan.push;
+	struct nvif_push *push = &core->chan.push;
 	int ret;
 
 	if ((ret = PUSH_WAIT(push, 2)))
drivers/gpu/drm/nouveau/dispnv50/wimmc37b.c +2 -2
index 8cb5b79bacbf..7985da61aaac 100644
@@ -31,7 +31,7 @@
 static int
 wimmc37b_update(struct nv50_wndw *wndw, u32 *interlock)
 {
-	struct nvif_push *push = wndw->wimm.push;
+	struct nvif_push *push = &wndw->wimm.push;
 	int ret;
 
 	if ((ret = PUSH_WAIT(push, 2)))
@@ -46,7 +46,7 @@ wimmc37b_update(struct nv50_wndw *wndw, u32 *interlock)
 static int
 wimmc37b_point(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
 {
-	struct nvif_push *push = wndw->wimm.push;
+	struct nvif_push *push = &wndw->wimm.push;
 	int ret;
 
 	if ((ret = PUSH_WAIT(push, 2)))
drivers/gpu/drm/nouveau/dispnv50/wndwc37e.c +11 -11
index caf40977f455..50a7b97d37a2 100644
@@ -39,7 +39,7 @@ wndwc37e_csc_clr(struct nv50_wndw *wndw)
 static int
 wndwc37e_csc_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
 {
-	struct nvif_push *push = wndw->wndw.push;
+	struct nvif_push *push = &wndw->wndw.push;
 	int ret;
 
 	if ((ret = PUSH_WAIT(push, 13)))
@@ -52,7 +52,7 @@ wndwc37e_csc_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
 static int
 wndwc37e_ilut_clr(struct nv50_wndw *wndw)
 {
-	struct nvif_push *push = wndw->wndw.push;
+	struct nvif_push *push = &wndw->wndw.push;
 	int ret;
 
 	if ((ret = PUSH_WAIT(push, 2)))
@@ -65,7 +65,7 @@ wndwc37e_ilut_clr(struct nv50_wndw *wndw)
 static int
 wndwc37e_ilut_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
 {
-	struct nvif_push *push = wndw->wndw.push;
+	struct nvif_push *push = &wndw->wndw.push;
 	int ret;
 
 	if ((ret = PUSH_WAIT(push, 4)))
@@ -94,7 +94,7 @@ wndwc37e_ilut(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw, int size)
 int
 wndwc37e_blend_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
 {
-	struct nvif_push *push = wndw->wndw.push;
+	struct nvif_push *push = &wndw->wndw.push;
 	int ret;
 
 	if ((ret = PUSH_WAIT(push, 8)))
@@ -139,7 +139,7 @@ wndwc37e_blend_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
 int
 wndwc37e_image_clr(struct nv50_wndw *wndw)
 {
-	struct nvif_push *push = wndw->wndw.push;
+	struct nvif_push *push = &wndw->wndw.push;
 	int ret;
 
 	if ((ret = PUSH_WAIT(push, 4)))
@@ -156,7 +156,7 @@ wndwc37e_image_clr(struct nv50_wndw *wndw)
 static int
 wndwc37e_image_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
 {
-	struct nvif_push *push = wndw->wndw.push;
+	struct nvif_push *push = &wndw->wndw.push;
 	int ret;
 
 	if ((ret = PUSH_WAIT(push, 17)))
@@ -209,7 +209,7 @@ wndwc37e_image_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
 int
 wndwc37e_ntfy_clr(struct nv50_wndw *wndw)
 {
-	struct nvif_push *push = wndw->wndw.push;
+	struct nvif_push *push = &wndw->wndw.push;
 	int ret;
 
 	if ((ret = PUSH_WAIT(push, 2)))
@@ -222,7 +222,7 @@ wndwc37e_ntfy_clr(struct nv50_wndw *wndw)
 int
 wndwc37e_ntfy_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
 {
-	struct nvif_push *push = wndw->wndw.push;
+	struct nvif_push *push = &wndw->wndw.push;
 	int ret;
 
 	if ((ret = PUSH_WAIT(push, 3)))
@@ -239,7 +239,7 @@ wndwc37e_ntfy_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
 int
 wndwc37e_sema_clr(struct nv50_wndw *wndw)
 {
-	struct nvif_push *push = wndw->wndw.push;
+	struct nvif_push *push = &wndw->wndw.push;
 	int ret;
 
 	if ((ret = PUSH_WAIT(push, 2)))
@@ -252,7 +252,7 @@ wndwc37e_sema_clr(struct nv50_wndw *wndw)
 int
 wndwc37e_sema_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
 {
-	struct nvif_push *push = wndw->wndw.push;
+	struct nvif_push *push = &wndw->wndw.push;
 	int ret;
 
 	if ((ret = PUSH_WAIT(push, 5)))
@@ -268,7 +268,7 @@ wndwc37e_sema_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
 int
 wndwc37e_update(struct nv50_wndw *wndw, u32 *interlock)
 {
-	struct nvif_push *push = wndw->wndw.push;
+	struct nvif_push *push = &wndw->wndw.push;
 	int ret;
 
 	if ((ret = PUSH_WAIT(push, 5)))
drivers/gpu/drm/nouveau/dispnv50/wndwc57e.c +5 -5
index 1d214a4b960a..d1ca51aae58c 100644
@@ -32,7 +32,7 @@
 static int
 wndwc57e_image_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
 {
-	struct nvif_push *push = wndw->wndw.push;
+	struct nvif_push *push = &wndw->wndw.push;
 	int ret;
 
 	if ((ret = PUSH_WAIT(push, 17)))
@@ -81,7 +81,7 @@ wndwc57e_image_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
 int
 wndwc57e_csc_clr(struct nv50_wndw *wndw)
 {
-	struct nvif_push *push = wndw->wndw.push;
+	struct nvif_push *push = &wndw->wndw.push;
 	const u32 identity[12] = {
 		0x00010000, 0x00000000, 0x00000000, 0x00000000,
 		0x00000000, 0x00010000, 0x00000000, 0x00000000,
@@ -99,7 +99,7 @@ wndwc57e_csc_clr(struct nv50_wndw *wndw)
 int
 wndwc57e_csc_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
 {
-	struct nvif_push *push = wndw->wndw.push;
+	struct nvif_push *push = &wndw->wndw.push;
 	int ret;
 
 	if ((ret = PUSH_WAIT(push, 13)))
@@ -112,7 +112,7 @@ wndwc57e_csc_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
 int
 wndwc57e_ilut_clr(struct nv50_wndw *wndw)
 {
-	struct nvif_push *push = wndw->wndw.push;
+	struct nvif_push *push = &wndw->wndw.push;
 	int ret;
 
 	if ((ret = PUSH_WAIT(push, 2)))
@@ -125,7 +125,7 @@ wndwc57e_ilut_clr(struct nv50_wndw *wndw)
 int
 wndwc57e_ilut_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
 {
-	struct nvif_push *push = wndw->wndw.push;
+	struct nvif_push *push = &wndw->wndw.push;
 	int ret;
 
 	if ((ret = PUSH_WAIT(push, 4)))
drivers/gpu/drm/nouveau/dispnv50/wndwc67e.c +1 -1
index 7a370fa1df20..52af293c98f4 100644
@@ -29,7 +29,7 @@
 static int
 wndwc67e_image_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
 {
-	struct nvif_push *push = wndw->wndw.push;
+	struct nvif_push *push = &wndw->wndw.push;
 	int ret;
 
 	if ((ret = PUSH_WAIT(push, 17)))
Signature · 1 line
2.41.0
author
#21 lore raw

PATCH 20/156 drm/nouveau/kms: move hw ring tracking vars into nvif_push

In reply to Ben Skeggs

- will help later in the series where display channel apis are modified

---
 drivers/gpu/drm/nouveau/dispnv50/disp.c     | 35 +++++++++++----------
 drivers/gpu/drm/nouveau/dispnv50/disp.h     |  4 ---
 drivers/gpu/drm/nouveau/include/nvif/push.h | 12 +++++--
 3 files changed, 28 insertions(+), 23 deletions(-)
drivers/gpu/drm/nouveau/dispnv50/disp.c +19 -16
index b64b283f8e9c..125c33ee251a 100644
@@ -132,8 +132,8 @@ nv50_dmac_kick(struct nvif_push *push)
 {
 	struct nv50_dmac *dmac = container_of(push, typeof(*dmac), push);
 
-	dmac->cur = push->cur - (u32 __iomem *)dmac->push.mem.object.map.ptr;
-	if (dmac->put != dmac->cur) {
+	push->hw.cur = push->cur - (u32 __iomem *)dmac->push.mem.object.map.ptr;
+	if (push->hw.put != push->hw.cur) {
 		/* Push buffer fetches are not coherent with BAR1, we need to ensure
 		 * writes have been flushed right through to VRAM before writing PUT.
 		 */
@@ -146,8 +146,8 @@ nv50_dmac_kick(struct nvif_push *push)
 			);
 		}
 
-		NVIF_WV32(&dmac->base.user, NV507C, PUT, PTR, dmac->cur);
-		dmac->put = dmac->cur;
+		NVIF_WV32(&dmac->base.user, NV507C, PUT, PTR, push->hw.cur);
+		push->hw.put = push->hw.cur;
 	}
 
 	push->bgn = push->cur;
@@ -156,22 +156,25 @@ nv50_dmac_kick(struct nvif_push *push)
 static int
 nv50_dmac_free(struct nv50_dmac *dmac)
 {
+	struct nvif_push *push = &dmac->push;
 	u32 get = NVIF_RV32(&dmac->base.user, NV507C, GET, PTR);
-	if (get > dmac->cur) /* NVIDIA stay 5 away from GET, do the same. */
-		return get - dmac->cur - 5;
-	return dmac->max - dmac->cur;
+	if (get > push->hw.cur) /* NVIDIA stay 5 away from GET, do the same. */
+		return get - push->hw.cur - 5;
+	return push->hw.max - push->hw.cur;
 }
 
 static int
 nv50_dmac_wind(struct nv50_dmac *dmac)
 {
+	struct nvif_push *push = &dmac->push;
+
 	/* Wait for GET to depart from the beginning of the push buffer to
 	 * prevent writing PUT == GET, which would be ignored by HW.
 	 */
 	u32 get = NVIF_RV32(&dmac->base.user, NV507C, GET, PTR);
 	if (get == 0) {
 		/* Corner-case, HW idle, but non-committed work pending. */
-		if (dmac->put == 0)
+		if (push->hw.put == 0)
 			nv50_dmac_kick(&dmac->push);
 
 		if (nvif_msec(dmac->base.device, 2000,
@@ -182,7 +185,7 @@ nv50_dmac_wind(struct nv50_dmac *dmac)
 	}
 
 	PUSH_RSVD(&dmac->push, PUSH_JUMP(&dmac->push, 0));
-	dmac->cur = 0;
+	push->hw.cur = 0;
 	return 0;
 }
 
@@ -192,17 +195,17 @@ nv50_dmac_wait(struct nvif_push *push, u32 size)
 	struct nv50_dmac *dmac = container_of(push, typeof(*dmac), push);
 	int free;
 
-	if (WARN_ON(size > dmac->max))
+	if (WARN_ON(size > push->hw.max))
 		return -EINVAL;
 
-	dmac->cur = push->cur - (u32 __iomem *)dmac->push.mem.object.map.ptr;
-	if (dmac->cur + size >= dmac->max) {
+	push->hw.cur = push->cur - (u32 __iomem *)dmac->push.mem.object.map.ptr;
+	if (push->hw.cur + size >= push->hw.max) {
 		int ret = nv50_dmac_wind(dmac);
 		if (ret)
 			return ret;
 
 		push->cur = dmac->push.mem.object.map.ptr;
-		push->cur = push->cur + dmac->cur;
+		push->cur = push->cur + push->hw.cur;
 		nv50_dmac_kick(push);
 	}
 
@@ -215,7 +218,7 @@ nv50_dmac_wait(struct nvif_push *push, u32 size)
 	}
 
 	push->bgn = dmac->push.mem.object.map.ptr;
-	push->bgn = push->bgn + dmac->cur;
+	push->bgn = push->bgn + push->hw.cur;
 	push->cur = push->bgn;
 	push->end = push->cur + free;
 	return 0;
@@ -259,13 +262,13 @@ nv50_dmac_create(struct nouveau_drm *drm,
 	dmac->push.bgn = dmac->push.mem.object.map.ptr;
 	dmac->push.cur = dmac->push.bgn;
 	dmac->push.end = dmac->push.bgn;
-	dmac->max = 0x1000/4 - 1;
+	dmac->push.hw.max = 0x1000/4 - 1;
 
 	/* EVO channels are affected by a HW bug where the last 12 DWORDs
 	 * of the push buffer aren't able to be used safely.
 	 */
 	if (disp->oclass < GV100_DISP)
-		dmac->max -= 12;
+		dmac->push.hw.max -= 12;
 
 	args->pushbuf = nvif_handle(&dmac->push.mem.object);
 
drivers/gpu/drm/nouveau/dispnv50/disp.h +0 -4
index 15f9242b72ac..a7a01ae77ff4 100644
@@ -66,10 +66,6 @@ struct nv50_dmac {
 
 	struct nvif_object sync;
 	struct nvif_object vram;
-
-	u32 cur;
-	u32 put;
-	u32 max;
 };
 
 struct nv50_outp_atom {
drivers/gpu/drm/nouveau/include/nvif/push.h +9 -3
index 6d3a8a3d2087..b88024ef6cc0 100644
@@ -27,15 +27,21 @@
 #include <nvhw/drf.h>
 
 struct nvif_push {
-	int (*wait)(struct nvif_push *push, u32 size);
-	void (*kick)(struct nvif_push *push);
-
 	struct nvif_mem mem;
 
+	struct {
+		u32 cur;
+		u32 put;
+		u32 max;
+	} hw;
+
 	u32 *bgn;
 	u32 *cur;
 	u32 *seg;
 	u32 *end;
+
+	int (*wait)(struct nvif_push *push, u32 size);
+	void (*kick)(struct nvif_push *push);
 };
 
 static inline __must_check int
Signature · 1 line
2.41.0
author
#22 lore raw

PATCH 21/156 drm/nouveau/kms: move dmac sync/vram ctxdmas to core+wndws

In reply to Ben Skeggs

- will help later in the series where display channels apis are modified

---
 drivers/gpu/drm/nouveau/dispnv50/base507c.c |  4 +-
 drivers/gpu/drm/nouveau/dispnv50/core.c     | 39 ++++++++++++++++-
 drivers/gpu/drm/nouveau/dispnv50/core.h     |  4 ++
 drivers/gpu/drm/nouveau/dispnv50/core507d.c |  2 +-
 drivers/gpu/drm/nouveau/dispnv50/corec37d.c |  2 +-
 drivers/gpu/drm/nouveau/dispnv50/corec57d.c |  2 +-
 drivers/gpu/drm/nouveau/dispnv50/curs507a.c |  6 +--
 drivers/gpu/drm/nouveau/dispnv50/disp.c     | 27 ------------
 drivers/gpu/drm/nouveau/dispnv50/disp.h     |  3 --
 drivers/gpu/drm/nouveau/dispnv50/head.c     |  2 +-
 drivers/gpu/drm/nouveau/dispnv50/head507d.c |  2 +-
 drivers/gpu/drm/nouveau/dispnv50/ovly507e.c |  4 +-
 drivers/gpu/drm/nouveau/dispnv50/wndw.c     | 46 +++++++++++++++++++--
 drivers/gpu/drm/nouveau/dispnv50/wndw.h     |  6 ++-
 drivers/gpu/drm/nouveau/dispnv50/wndwc37e.c |  4 +-
 15 files changed, 104 insertions(+), 49 deletions(-)
drivers/gpu/drm/nouveau/dispnv50/base507c.c +2 -2
index a431f6c5f6fa..0b6fb663d78e 100644
@@ -311,7 +311,7 @@ base507c_new_(const struct nv50_wndw_func *func, const u32 *format,
 	struct nv50_wndw *wndw;
 	int ret;
 
-	ret = nv50_wndw_new_(func, drm->dev, DRM_PLANE_TYPE_PRIMARY,
+	ret = nv50_wndw_prep(func, drm->dev, DRM_PLANE_TYPE_PRIMARY,
 			     "base", head, format, BIT(head),
 			     NV50_DISP_INTERLOCK_BASE, interlock_data, &wndw);
 	if (*pwndw = wndw, ret)
@@ -328,7 +328,7 @@ base507c_new_(const struct nv50_wndw_func *func, const u32 *format,
 	wndw->ntfy = NV50_DISP_BASE_NTFY(wndw->id);
 	wndw->sema = NV50_DISP_BASE_SEM0(wndw->id);
 	wndw->data = 0x00000000;
-	return 0;
+	return nv50_wndw_ctor(wndw);
 }
 
 int
drivers/gpu/drm/nouveau/dispnv50/core.c +38 -1
index f045515696cb..1864f3e3bbc3 100644
@@ -20,14 +20,20 @@
  * OTHER DEALINGS IN THE SOFTWARE.
  */
 #include "core.h"
+#include "handles.h"
+
+#include "nouveau_bo.h"
 
 #include <nvif/class.h>
+#include <nvif/cl0002.h>
 
 void
 nv50_core_del(struct nv50_core **pcore)
 {
 	struct nv50_core *core = *pcore;
 	if (core) {
+		nvif_object_dtor(&core->sync);
+		nvif_object_dtor(&core->vram);
 		nv50_dmac_destroy(&core->chan);
 		kfree(*pcore);
 		*pcore = NULL;
@@ -61,7 +67,9 @@ nv50_core_new(struct nouveau_drm *drm, struct nv50_core **pcore)
 		{}
 	};
 	struct nv50_disp *disp = nv50_disp(drm->dev);
+	struct nv50_core *core;
 	int cid;
+	int ret;
 
 	cid = nvif_mclass(&disp->disp->object, cores);
 	if (cid < 0) {
@@ -69,5 +77,34 @@ nv50_core_new(struct nouveau_drm *drm, struct nv50_core **pcore)
 		return cid;
 	}
 
-	return cores[cid].new(drm, cores[cid].oclass, pcore);
+	ret = cores[cid].new(drm, cores[cid].oclass, &core);
+	*pcore = core;
+	if (ret)
+		return ret;
+
+	ret = nvif_object_ctor(&core->chan.base.user, "kmsCoreSyncCtxdma", NV50_DISP_HANDLE_SYNCBUF,
+			       NV_DMA_IN_MEMORY,
+			       &(struct nv_dma_v0) {
+					.target = NV_DMA_V0_TARGET_VRAM,
+					.access = NV_DMA_V0_ACCESS_RDWR,
+					.start = disp->sync->offset + 0x0000,
+					.limit = disp->sync->offset + 0x0fff,
+			       }, sizeof(struct nv_dma_v0),
+			       &core->sync);
+	if (ret)
+		return ret;
+
+	ret = nvif_object_ctor(&core->chan.base.user, "kmsCoreVramCtxdma", NV50_DISP_HANDLE_VRAM,
+			       NV_DMA_IN_MEMORY,
+			       &(struct nv_dma_v0) {
+					.target = NV_DMA_V0_TARGET_VRAM,
+					.access = NV_DMA_V0_ACCESS_RDWR,
+					.start = 0,
+					.limit = drm->device.info.ram_user - 1,
+			       }, sizeof(struct nv_dma_v0),
+			       &core->vram);
+	if (ret)
+		return ret;
+
+	return 0;
 }
drivers/gpu/drm/nouveau/dispnv50/core.h +4 -0
index f75088186fba..a967c66dc7a2 100644
@@ -8,6 +8,10 @@
 struct nv50_core {
 	const struct nv50_core_func *func;
 	struct nv50_dmac chan;
+
+	struct nvif_object vram;
+	struct nvif_object sync;
+
 	bool assign_windows;
 };
 
drivers/gpu/drm/nouveau/dispnv50/core507d.c +1 -1
index ce2cb78bbdd3..c6eee88ae99a 100644
@@ -136,7 +136,7 @@ core507d_init(struct nv50_core *core)
 	if ((ret = PUSH_WAIT(push, 2)))
 		return ret;
 
-	PUSH_MTHD(push, NV507D, SET_CONTEXT_DMA_NOTIFIER, core->chan.sync.handle);
+	PUSH_MTHD(push, NV507D, SET_CONTEXT_DMA_NOTIFIER, core->sync.handle);
 	return PUSH_KICK(push);
 }
 
drivers/gpu/drm/nouveau/dispnv50/corec37d.c +1 -1
index 7f637b8830be..9525fd30c8fc 100644
@@ -134,7 +134,7 @@ corec37d_init(struct nv50_core *core)
 	if ((ret = PUSH_WAIT(push, 2 + windows * 5)))
 		return ret;
 
-	PUSH_MTHD(push, NVC37D, SET_CONTEXT_DMA_NOTIFIER, core->chan.sync.handle);
+	PUSH_MTHD(push, NVC37D, SET_CONTEXT_DMA_NOTIFIER, core->sync.handle);
 
 	for (i = 0; i < windows; i++) {
 		PUSH_MTHD(push, NVC37D, WINDOW_SET_WINDOW_FORMAT_USAGE_BOUNDS(i),
drivers/gpu/drm/nouveau/dispnv50/corec57d.c +1 -1
index 421d0d57e1d8..485892c2e775 100644
@@ -36,7 +36,7 @@ corec57d_init(struct nv50_core *core)
 	if ((ret = PUSH_WAIT(push, 2 + windows * 5)))
 		return ret;
 
-	PUSH_MTHD(push, NVC57D, SET_CONTEXT_DMA_NOTIFIER, core->chan.sync.handle);
+	PUSH_MTHD(push, NVC57D, SET_CONTEXT_DMA_NOTIFIER, core->sync.handle);
 
 	for (i = 0; i < windows; i++) {
 		PUSH_MTHD(push, NVC57D, WINDOW_SET_WINDOW_FORMAT_USAGE_BOUNDS(i),
drivers/gpu/drm/nouveau/dispnv50/curs507a.c +3 -3
index a95ee5dcc2e3..7292d1554dba 100644
@@ -78,7 +78,7 @@ static void
 curs507a_prepare(struct nv50_wndw *wndw, struct nv50_head_atom *asyh,
 		 struct nv50_wndw_atom *asyw)
 {
-	u32 handle = nv50_disp(wndw->plane.dev)->core->chan.vram.handle;
+	u32 handle = nv50_disp(wndw->plane.dev)->core->vram.handle;
 	u32 offset = asyw->image.offset[0];
 	if (asyh->curs.handle != handle || asyh->curs.offset != offset) {
 		asyh->curs.handle = handle;
@@ -177,7 +177,7 @@ curs507a_new_(const struct nv50_wimm_func *func, struct nouveau_drm *drm,
 	struct nv50_wndw *wndw;
 	int ret;
 
-	ret = nv50_wndw_new_(&curs507a_wndw, drm->dev, DRM_PLANE_TYPE_CURSOR,
+	ret = nv50_wndw_prep(&curs507a_wndw, drm->dev, DRM_PLANE_TYPE_CURSOR,
 			     "curs", head, curs507a_format, BIT(head),
 			     NV50_DISP_INTERLOCK_CURS, interlock_data, &wndw);
 	if (*pwndw = wndw, ret)
@@ -193,7 +193,7 @@ curs507a_new_(const struct nv50_wimm_func *func, struct nouveau_drm *drm,
 	nvif_object_map(&wndw->wimm.base.user, NULL, 0);
 	wndw->immd = func;
 	wndw->ctxdma.parent = NULL;
-	return 0;
+	return nv50_wndw_ctor(wndw);
 }
 
 int
drivers/gpu/drm/nouveau/dispnv50/disp.c +0 -27
index 125c33ee251a..31b46a62b501 100644
@@ -119,9 +119,6 @@ nv50_chan_destroy(struct nv50_chan *chan)
 void
 nv50_dmac_destroy(struct nv50_dmac *dmac)
 {
-	nvif_object_dtor(&dmac->vram);
-	nvif_object_dtor(&dmac->sync);
-
 	nv50_chan_destroy(&dmac->base);
 
 	nvif_mem_dtor(&dmac->push.mem);
@@ -280,30 +277,6 @@ nv50_dmac_create(struct nouveau_drm *drm,
 	if (syncbuf < 0)
 		return 0;
 
-	ret = nvif_object_ctor(&dmac->base.user, "kmsSyncCtxDma", NV50_DISP_HANDLE_SYNCBUF,
-			       NV_DMA_IN_MEMORY,
-			       &(struct nv_dma_v0) {
-					.target = NV_DMA_V0_TARGET_VRAM,
-					.access = NV_DMA_V0_ACCESS_RDWR,
-					.start = syncbuf + 0x0000,
-					.limit = syncbuf + 0x0fff,
-			       }, sizeof(struct nv_dma_v0),
-			       &dmac->sync);
-	if (ret)
-		return ret;
-
-	ret = nvif_object_ctor(&dmac->base.user, "kmsVramCtxDma", NV50_DISP_HANDLE_VRAM,
-			       NV_DMA_IN_MEMORY,
-			       &(struct nv_dma_v0) {
-					.target = NV_DMA_V0_TARGET_VRAM,
-					.access = NV_DMA_V0_ACCESS_RDWR,
-					.start = 0,
-					.limit = device->info.ram_user - 1,
-			       }, sizeof(struct nv_dma_v0),
-			       &dmac->vram);
-	if (ret)
-		return ret;
-
 	return ret;
 }
 
drivers/gpu/drm/nouveau/dispnv50/disp.h +0 -3
index a7a01ae77ff4..9485f8c90cac 100644
@@ -63,9 +63,6 @@ struct nv50_dmac {
 	struct nv50_chan base;
 
 	struct nvif_push push;
-
-	struct nvif_object sync;
-	struct nvif_object vram;
 };
 
 struct nv50_outp_atom {
drivers/gpu/drm/nouveau/dispnv50/head.c +1 -1
index 83355dbc15ee..007857ac8542 100644
@@ -274,7 +274,7 @@ nv50_head_atomic_check_lut(struct nv50_head *head,
 			  size, crtc->base.id, crtc->name);
 		return -EINVAL;
 	}
-	asyh->olut.handle = disp->core->chan.vram.handle;
+	asyh->olut.handle = disp->core->vram.handle;
 	asyh->olut.buffer = !asyh->olut.buffer;
 
 	return 0;
drivers/gpu/drm/nouveau/dispnv50/head507d.c +1 -1
index 7fa1e0279d7d..634f6166f38d 100644
@@ -265,7 +265,7 @@ head507d_core_calc(struct nv50_head *head, struct nv50_head_atom *asyh)
 		asyh->core.w = asyh->state.mode.hdisplay;
 		asyh->core.h = asyh->state.mode.vdisplay;
 	}
-	asyh->core.handle = disp->core->chan.vram.handle;
+	asyh->core.handle = disp->core->vram.handle;
 	asyh->core.offset = 0;
 	asyh->core.format = NV507D_HEAD_SET_PARAMS_FORMAT_A8R8G8B8;
 	asyh->core.kind = NV507D_HEAD_SET_PARAMS_KIND_KIND_PITCH;
drivers/gpu/drm/nouveau/dispnv50/ovly507e.c +2 -2
index 654e506f8431..4e109c5b5a1b 100644
@@ -152,7 +152,7 @@ ovly507e_new_(const struct nv50_wndw_func *func, const u32 *format,
 	struct nv50_wndw *wndw;
 	int ret;
 
-	ret = nv50_wndw_new_(func, drm->dev, DRM_PLANE_TYPE_OVERLAY,
+	ret = nv50_wndw_prep(func, drm->dev, DRM_PLANE_TYPE_OVERLAY,
 			     "ovly", head, format, BIT(head),
 			     NV50_DISP_INTERLOCK_OVLY, interlock_data,
 			     &wndw);
@@ -170,7 +170,7 @@ ovly507e_new_(const struct nv50_wndw_func *func, const u32 *format,
 	wndw->ntfy = NV50_DISP_OVLY_NTFY(wndw->id);
 	wndw->sema = NV50_DISP_OVLY_SEM0(wndw->id);
 	wndw->data = 0x00000000;
-	return 0;
+	return nv50_wndw_ctor(wndw);
 }
 
 int
drivers/gpu/drm/nouveau/dispnv50/wndw.c +43 -3

70 lines not on this page · raw message

drivers/gpu/drm/nouveau/dispnv50/wndw.h +5 -1
index 76a6ae5d5652..66a06e20a6a0 100644
@@ -28,16 +28,20 @@ struct nv50_wndw {
 	struct nv50_dmac wndw;
 	struct nv50_dmac wimm;
 
+	struct nvif_object vram;
+	struct nvif_object sync;
+
 	u16 ntfy;
 	u16 sema;
 	u32 data;
 };
 
-int nv50_wndw_new_(const struct nv50_wndw_func *, struct drm_device *,
+int nv50_wndw_prep(const struct nv50_wndw_func *, struct drm_device *,
 		   enum drm_plane_type, const char *name, int index,
 		   const u32 *format, u32 heads,
 		   enum nv50_disp_interlock_type, u32 interlock_data,
 		   struct nv50_wndw **);
+int nv50_wndw_ctor(struct nv50_wndw *);
 void nv50_wndw_flush_set(struct nv50_wndw *, u32 *interlock,
 			 struct nv50_wndw_atom *);
 void nv50_wndw_flush_clr(struct nv50_wndw *, u32 *interlock, bool flush,
drivers/gpu/drm/nouveau/dispnv50/wndwc37e.c +2 -2
index 50a7b97d37a2..5029dfd98443 100644
@@ -357,7 +357,7 @@ wndwc37e_new_(const struct nv50_wndw_func *func, struct nouveau_drm *drm,
 	struct nv50_wndw *wndw;
 	int ret;
 
-	ret = nv50_wndw_new_(func, drm->dev, type, "wndw", index,
+	ret = nv50_wndw_prep(func, drm->dev, type, "wndw", index,
 			     wndwc37e_format, heads, NV50_DISP_INTERLOCK_WNDW,
 			     BIT(index), &wndw);
 	if (*pwndw = wndw, ret)
@@ -374,7 +374,7 @@ wndwc37e_new_(const struct nv50_wndw_func *func, struct nouveau_drm *drm,
 	wndw->ntfy = NV50_DISP_WNDW_NTFY(wndw->id);
 	wndw->sema = NV50_DISP_WNDW_SEM0(wndw->id);
 	wndw->data = 0x00000000;
-	return 0;
+	return nv50_wndw_ctor(wndw);
 }
 
 int
Signature · 1 line
2.41.0
author
#23 lore raw

PATCH 22/156 drm/nouveau/nvkm: remove detect/mmio/subdev_mask from device args

In reply to Ben Skeggs

- now unused

---
 .../gpu/drm/nouveau/include/nvkm/core/pci.h   |   1 -
 .../gpu/drm/nouveau/include/nvkm/core/tegra.h |   1 -
 drivers/gpu/drm/nouveau/nouveau_drm.c         |   6 +-
 .../gpu/drm/nouveau/nvkm/engine/device/base.c | 422 +++++++++---------
 .../gpu/drm/nouveau/nvkm/engine/device/pci.c  |   4 +-
 .../gpu/drm/nouveau/nvkm/engine/device/priv.h |   1 -
 .../drm/nouveau/nvkm/engine/device/tegra.c    |   5 +-
 7 files changed, 209 insertions(+), 231 deletions(-)
drivers/gpu/drm/nouveau/include/nvkm/core/pci.h +0 -1
index b4b5df3e1610..7444c4d59e09 100644
@@ -10,6 +10,5 @@ struct nvkm_device_pci {
 };
 
 int nvkm_device_pci_new(struct pci_dev *, const char *cfg, const char *dbg,
-			bool detect, bool mmio, u64 subdev_mask,
 			struct nvkm_device **);
 #endif
drivers/gpu/drm/nouveau/include/nvkm/core/tegra.h +0 -1
index ccee53d4e4ec..22f74fc88cd7 100644
@@ -51,6 +51,5 @@ struct nvkm_device_tegra_func {
 int nvkm_device_tegra_new(const struct nvkm_device_tegra_func *,
 			  struct platform_device *,
 			  const char *cfg, const char *dbg,
-			  bool detect, bool mmio, u64 subdev_mask,
 			  struct nvkm_device **);
 #endif
drivers/gpu/drm/nouveau/nouveau_drm.c +2 -4
index 92b347b79919..33883c4e8221 100644
@@ -831,8 +831,7 @@ static int nouveau_drm_probe(struct pci_dev *pdev,
 	/* We need to check that the chipset is supported before booting
 	 * fbdev off the hardware, as there's no way to put it back.
 	 */
-	ret = nvkm_device_pci_new(pdev, nouveau_config, nouveau_debug,
-				  true, true, ~0ULL, &device);
+	ret = nvkm_device_pci_new(pdev, nouveau_config, nouveau_debug, &device);
 	if (ret)
 		return ret;
 
@@ -1389,8 +1388,7 @@ nouveau_platform_device_create(const struct nvkm_device_tegra_func *func,
 	struct drm_device *drm;
 	int err;
 
-	err = nvkm_device_tegra_new(func, pdev, nouveau_config, nouveau_debug,
-				    true, true, ~0ULL, pdevice);
+	err = nvkm_device_tegra_new(func, pdev, nouveau_config, nouveau_debug, pdevice);
 	if (err)
 		goto err_free;
 
drivers/gpu/drm/nouveau/nvkm/engine/device/base.c +205 -217

478 lines not on this page · raw message

drivers/gpu/drm/nouveau/nvkm/engine/device/pci.c +1 -3
index abccb2bb68a6..3ff6436007fa 100644
@@ -1626,7 +1626,6 @@ nvkm_device_pci_func = {
 
 int
 nvkm_device_pci_new(struct pci_dev *pci_dev, const char *cfg, const char *dbg,
-		    bool detect, bool mmio, u64 subdev_mask,
 		    struct nvkm_device **pdevice)
 {
 	const struct nvkm_device_quirk *quirk = NULL;
@@ -1680,8 +1679,7 @@ nvkm_device_pci_new(struct pci_dev *pci_dev, const char *cfg, const char *dbg,
 				    pci_dev->bus->number << 16 |
 				    PCI_SLOT(pci_dev->devfn) << 8 |
 				    PCI_FUNC(pci_dev->devfn), name,
-			       cfg, dbg, detect, mmio, subdev_mask,
-			       &pdev->device);
+			       cfg, dbg, &pdev->device);
 
 	if (ret)
 		return ret;
drivers/gpu/drm/nouveau/nvkm/engine/device/priv.h +0 -1
index bf3176bec18a..c182d9c3e4fa 100644
@@ -56,7 +56,6 @@ int  nvkm_device_ctor(const struct nvkm_device_func *,
 		      const struct nvkm_device_quirk *,
 		      struct device *, enum nvkm_device_type, u64 handle,
 		      const char *name, const char *cfg, const char *dbg,
-		      bool detect, bool mmio, u64 subdev_mask,
 		      struct nvkm_device *);
 int  nvkm_device_init(struct nvkm_device *);
 int  nvkm_device_fini(struct nvkm_device *, bool suspend);
drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c +1 -4
index 87caa4a72921..d1c294f00665 100644
@@ -237,7 +237,6 @@ int
 nvkm_device_tegra_new(const struct nvkm_device_tegra_func *func,
 		      struct platform_device *pdev,
 		      const char *cfg, const char *dbg,
-		      bool detect, bool mmio, u64 subdev_mask,
 		      struct nvkm_device **pdevice)
 {
 	struct nvkm_device_tegra *tdev;
@@ -311,8 +310,7 @@ nvkm_device_tegra_new(const struct nvkm_device_tegra_func *func,
 	tdev->gpu_speedo_id = tegra_sku_info.gpu_speedo_id;
 	ret = nvkm_device_ctor(&nvkm_device_tegra_func, NULL, &pdev->dev,
 			       NVKM_DEVICE_TEGRA, pdev->id, NULL,
-			       cfg, dbg, detect, mmio, subdev_mask,
-			       &tdev->device);
+			       cfg, dbg, &tdev->device);
 	if (ret)
 		goto powerdown;
 
@@ -333,7 +331,6 @@ int
 nvkm_device_tegra_new(const struct nvkm_device_tegra_func *func,
 		      struct platform_device *pdev,
 		      const char *cfg, const char *dbg,
-		      bool detect, bool mmio, u64 subdev_mask,
 		      struct nvkm_device **pdevice)
 {
 	return -ENOSYS;
Signature · 1 line
2.41.0
author
#24 lore raw

PATCH 23/156 drm/nouveau/nvkm: move nouveau_nvif.c to nvkm/core/driver.c

In reply to Ben Skeggs

- move to a more appropriate place before making changes

---
 drivers/gpu/drm/nouveau/Kbuild                |  1 -
 drivers/gpu/drm/nouveau/nvkm/core/Kbuild      |  1 +
 .../{nouveau_nvif.c => nvkm/core/driver.c}    | 36 +++++++++----------
 3 files changed, 18 insertions(+), 20 deletions(-)
 rename drivers/gpu/drm/nouveau/{nouveau_nvif.c => nvkm/core/driver.c} (75%)
drivers/gpu/drm/nouveau/Kbuild +0 -1
index c3223ec97aff..f99b7b227947 100644
@@ -25,7 +25,6 @@ nouveau-y += nouveau_drm.o
 nouveau-y += nouveau_hwmon.o
 nouveau-$(CONFIG_COMPAT) += nouveau_ioc32.o
 nouveau-$(CONFIG_LEDS_CLASS) += nouveau_led.o
-nouveau-y += nouveau_nvif.o
 nouveau-$(CONFIG_NOUVEAU_PLATFORM_DRIVER) += nouveau_platform.o
 nouveau-y += nouveau_vga.o
 
drivers/gpu/drm/nouveau/nvkm/core/Kbuild +1 -0
index e40712023c73..7d111a5481d3 100644
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: MIT
 nvkm-y := nvkm/core/client.o
+nvkm-y += nvkm/core/driver.o
 nvkm-y += nvkm/core/engine.o
 nvkm-y += nvkm/core/enum.o
 nvkm-y += nvkm/core/event.o
drivers/gpu/drm/nouveau/nvkm/core/driver.c renamed from drivers/gpu/drm/nouveau/nouveau_nvif.c +17 -19
similarity index 75%
rename from drivers/gpu/drm/nouveau/nouveau_nvif.c
rename to drivers/gpu/drm/nouveau/nvkm/core/driver.c
index 9a7e3f64b79f..3494002b40cd 100644
@@ -27,49 +27,48 @@
  ******************************************************************************/
 
 #include <core/client.h>
+#include <core/event.h>
 #include <core/ioctl.h>
 
-#include <nvif/client.h>
 #include <nvif/driver.h>
 #include <nvif/event.h>
-#include <nvif/ioctl.h>
-
-#include "nouveau_drv.h"
 
 static void
-nvkm_client_unmap(void *priv, void __iomem *ptr, u32 size)
+nvkm_driver_unmap(void *priv, void __iomem *ptr, u32 size)
 {
 	iounmap(ptr);
 }
 
 static void __iomem *
-nvkm_client_map(void *priv, u64 handle, u32 size)
+nvkm_driver_map(void *priv, u64 handle, u32 size)
 {
 	return ioremap(handle, size);
 }
 
 static int
-nvkm_client_ioctl(void *priv, void *data, u32 size, void **hack)
+nvkm_driver_ioctl(void *priv, void *data, u32 size, void **hack)
 {
 	return nvkm_ioctl(priv, data, size, hack);
 }
 
 static int
-nvkm_client_resume(void *priv)
+nvkm_driver_resume(void *priv)
 {
 	struct nvkm_client *client = priv;
+
 	return nvkm_object_init(&client->object);
 }
 
 static int
-nvkm_client_suspend(void *priv)
+nvkm_driver_suspend(void *priv)
 {
 	struct nvkm_client *client = priv;
+
 	return nvkm_object_fini(&client->object, true);
 }
 
 static int
-nvkm_client_event(u64 token, void *repv, u32 repc)
+nvkm_driver_event(u64 token, void *repv, u32 repc)
 {
 	struct nvif_object *object = (void *)(unsigned long)token;
 	struct nvif_event *event = container_of(object, typeof(*event), object);
@@ -81,21 +80,20 @@ nvkm_client_event(u64 token, void *repv, u32 repc)
 }
 
 static int
-nvkm_client_driver_init(const char *name, u64 device, const char *cfg,
-			const char *dbg, void **ppriv)
+nvkm_driver_init(const char *name, u64 device, const char *cfg, const char *dbg, void **ppriv)
 {
-	return nvkm_client_new(name, device, cfg, dbg, nvkm_client_event,
+	return nvkm_client_new(name, device, cfg, dbg, nvkm_driver_event,
 			       (struct nvkm_client **)ppriv);
 }
 
 const struct nvif_driver
 nvif_driver_nvkm = {
 	.name = "nvkm",
-	.init = nvkm_client_driver_init,
-	.suspend = nvkm_client_suspend,
-	.resume = nvkm_client_resume,
-	.ioctl = nvkm_client_ioctl,
-	.map = nvkm_client_map,
-	.unmap = nvkm_client_unmap,
+	.init = nvkm_driver_init,
+	.suspend = nvkm_driver_suspend,
+	.resume = nvkm_driver_resume,
+	.ioctl = nvkm_driver_ioctl,
+	.map = nvkm_driver_map,
+	.unmap = nvkm_driver_unmap,
 	.keep = false,
 };
Signature · 1 line
2.41.0
author
#25 lore raw

PATCH 24/156 drm/nouveau/nvkm: move nvkm/engine/device/ to nvkm/device/

In reply to Ben Skeggs

- move to a more appropriate place before making changes

---
 drivers/gpu/drm/nouveau/nvkm/Kbuild                      | 1 +
 drivers/gpu/drm/nouveau/nvkm/device/Kbuild               | 7 +++++++
 drivers/gpu/drm/nouveau/nvkm/{engine => }/device/acpi.c  | 0
 drivers/gpu/drm/nouveau/nvkm/{engine => }/device/acpi.h  | 0
 drivers/gpu/drm/nouveau/nvkm/{engine => }/device/base.c  | 0
 drivers/gpu/drm/nouveau/nvkm/{engine => }/device/ctrl.c  | 0
 drivers/gpu/drm/nouveau/nvkm/{engine => }/device/ctrl.h  | 0
 drivers/gpu/drm/nouveau/nvkm/{engine => }/device/pci.c   | 0
 drivers/gpu/drm/nouveau/nvkm/{engine => }/device/priv.h  | 0
 drivers/gpu/drm/nouveau/nvkm/{engine => }/device/tegra.c | 0
 drivers/gpu/drm/nouveau/nvkm/{engine => }/device/user.c  | 0
 drivers/gpu/drm/nouveau/nvkm/engine/Kbuild               | 1 -
 drivers/gpu/drm/nouveau/nvkm/engine/device/Kbuild        | 7 -------
 13 files changed, 8 insertions(+), 8 deletions(-)
 create mode 100644 drivers/gpu/drm/nouveau/nvkm/device/Kbuild
 rename drivers/gpu/drm/nouveau/nvkm/{engine => }/device/acpi.c (100%)
 rename drivers/gpu/drm/nouveau/nvkm/{engine => }/device/acpi.h (100%)
 rename drivers/gpu/drm/nouveau/nvkm/{engine => }/device/base.c (100%)
 rename drivers/gpu/drm/nouveau/nvkm/{engine => }/device/ctrl.c (100%)
 rename drivers/gpu/drm/nouveau/nvkm/{engine => }/device/ctrl.h (100%)
 rename drivers/gpu/drm/nouveau/nvkm/{engine => }/device/pci.c (100%)
 rename drivers/gpu/drm/nouveau/nvkm/{engine => }/device/priv.h (100%)
 rename drivers/gpu/drm/nouveau/nvkm/{engine => }/device/tegra.c (100%)
 rename drivers/gpu/drm/nouveau/nvkm/{engine => }/device/user.c (100%)
 delete mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/device/Kbuild
drivers/gpu/drm/nouveau/nvkm/Kbuild +1 -0
index db3ade125fa9..f68c19586b53 100644
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: MIT
 include $(src)/nvkm/core/Kbuild
 include $(src)/nvkm/nvfw/Kbuild
+include $(src)/nvkm/device/Kbuild
 include $(src)/nvkm/falcon/Kbuild
 include $(src)/nvkm/subdev/Kbuild
 include $(src)/nvkm/engine/Kbuild
drivers/gpu/drm/nouveau/nvkm/device/Kbuild new file +7 -0
new file mode 100644
index 000000000000..0e5ce7877b94
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: MIT
+nvkm-y += nvkm/device/acpi.o
+nvkm-y += nvkm/device/base.o
+nvkm-y += nvkm/device/ctrl.o
+nvkm-y += nvkm/device/pci.o
+nvkm-y += nvkm/device/tegra.o
+nvkm-y += nvkm/device/user.o
drivers/gpu/drm/nouveau/nvkm/device/acpi.c renamed from drivers/gpu/drm/nouveau/nvkm/engine/device/acpi.c +0 -0
similarity index 100%
rename from drivers/gpu/drm/nouveau/nvkm/engine/device/acpi.c
rename to drivers/gpu/drm/nouveau/nvkm/device/acpi.c
drivers/gpu/drm/nouveau/nvkm/device/acpi.h renamed from drivers/gpu/drm/nouveau/nvkm/engine/device/acpi.h +0 -0
similarity index 100%
rename from drivers/gpu/drm/nouveau/nvkm/engine/device/acpi.h
rename to drivers/gpu/drm/nouveau/nvkm/device/acpi.h
drivers/gpu/drm/nouveau/nvkm/device/base.c renamed from drivers/gpu/drm/nouveau/nvkm/engine/device/base.c +0 -0
similarity index 100%
rename from drivers/gpu/drm/nouveau/nvkm/engine/device/base.c
rename to drivers/gpu/drm/nouveau/nvkm/device/base.c
drivers/gpu/drm/nouveau/nvkm/device/ctrl.c renamed from drivers/gpu/drm/nouveau/nvkm/engine/device/ctrl.c +0 -0
similarity index 100%
rename from drivers/gpu/drm/nouveau/nvkm/engine/device/ctrl.c
rename to drivers/gpu/drm/nouveau/nvkm/device/ctrl.c
drivers/gpu/drm/nouveau/nvkm/device/ctrl.h renamed from drivers/gpu/drm/nouveau/nvkm/engine/device/ctrl.h +0 -0
similarity index 100%
rename from drivers/gpu/drm/nouveau/nvkm/engine/device/ctrl.h
rename to drivers/gpu/drm/nouveau/nvkm/device/ctrl.h
drivers/gpu/drm/nouveau/nvkm/device/pci.c renamed from drivers/gpu/drm/nouveau/nvkm/engine/device/pci.c +0 -0
similarity index 100%
rename from drivers/gpu/drm/nouveau/nvkm/engine/device/pci.c
rename to drivers/gpu/drm/nouveau/nvkm/device/pci.c
drivers/gpu/drm/nouveau/nvkm/device/priv.h renamed from drivers/gpu/drm/nouveau/nvkm/engine/device/priv.h +0 -0
similarity index 100%
rename from drivers/gpu/drm/nouveau/nvkm/engine/device/priv.h
rename to drivers/gpu/drm/nouveau/nvkm/device/priv.h
drivers/gpu/drm/nouveau/nvkm/device/tegra.c renamed from drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c +0 -0
similarity index 100%
rename from drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c
rename to drivers/gpu/drm/nouveau/nvkm/device/tegra.c
drivers/gpu/drm/nouveau/nvkm/device/user.c renamed from drivers/gpu/drm/nouveau/nvkm/engine/device/user.c +0 -0
similarity index 100%
rename from drivers/gpu/drm/nouveau/nvkm/engine/device/user.c
rename to drivers/gpu/drm/nouveau/nvkm/device/user.c
drivers/gpu/drm/nouveau/nvkm/engine/Kbuild +0 -1
index bfaaff645a34..f9eb68a25de8 100644
@@ -5,7 +5,6 @@ nvkm-y += nvkm/engine/xtensa.o
 include $(src)/nvkm/engine/bsp/Kbuild
 include $(src)/nvkm/engine/ce/Kbuild
 include $(src)/nvkm/engine/cipher/Kbuild
-include $(src)/nvkm/engine/device/Kbuild
 include $(src)/nvkm/engine/disp/Kbuild
 include $(src)/nvkm/engine/dma/Kbuild
 include $(src)/nvkm/engine/fifo/Kbuild
drivers/gpu/drm/nouveau/nvkm/engine/device/Kbuild deleted +0 -7
deleted file mode 100644
index 293c57678dab..000000000000
@@ -1,7 +0,0 @@
-# SPDX-License-Identifier: MIT
-nvkm-y += nvkm/engine/device/acpi.o
-nvkm-y += nvkm/engine/device/base.o
-nvkm-y += nvkm/engine/device/ctrl.o
-nvkm-y += nvkm/engine/device/pci.o
-nvkm-y += nvkm/engine/device/tegra.o
-nvkm-y += nvkm/engine/device/user.o
Signature · 1 line
2.41.0
author
#26 lore raw

PATCH 25/156 drm/nouveau/nvkm: remove perfmon

In reply to Ben Skeggs

This has never really been used for anything, in part due to never having reclocking stable enough in general to attempt to implement dynamic clock changes based on load, etc.

To avoid having to rework its interfaces, remove it entirely.

---
 drivers/gpu/drm/nouveau/include/nvif/class.h  |   3 -
 drivers/gpu/drm/nouveau/include/nvif/if0002.h |  39 -
 drivers/gpu/drm/nouveau/include/nvif/if0003.h |  34 -
 .../drm/nouveau/include/nvkm/core/layout.h    |   1 -
 .../gpu/drm/nouveau/include/nvkm/engine/pm.h  |  29 -
 drivers/gpu/drm/nouveau/nvkm/device/base.c    |  82 --
 drivers/gpu/drm/nouveau/nvkm/device/priv.h    |   1 -
 drivers/gpu/drm/nouveau/nvkm/device/user.c    |   3 +-
 drivers/gpu/drm/nouveau/nvkm/engine/Kbuild    |   1 -
 drivers/gpu/drm/nouveau/nvkm/engine/pm/Kbuild |  11 -
 drivers/gpu/drm/nouveau/nvkm/engine/pm/base.c | 867 ------------------
 drivers/gpu/drm/nouveau/nvkm/engine/pm/g84.c  | 165 ----
 .../gpu/drm/nouveau/nvkm/engine/pm/gf100.c    | 243 -----
 .../gpu/drm/nouveau/nvkm/engine/pm/gf100.h    |  20 -
 .../gpu/drm/nouveau/nvkm/engine/pm/gf108.c    |  66 --
 .../gpu/drm/nouveau/nvkm/engine/pm/gf117.c    |  80 --
 .../gpu/drm/nouveau/nvkm/engine/pm/gk104.c    | 184 ----
 .../gpu/drm/nouveau/nvkm/engine/pm/gt200.c    | 157 ----
 .../gpu/drm/nouveau/nvkm/engine/pm/gt215.c    | 138 ---
 drivers/gpu/drm/nouveau/nvkm/engine/pm/nv40.c | 123 ---
 drivers/gpu/drm/nouveau/nvkm/engine/pm/nv40.h |  15 -
 drivers/gpu/drm/nouveau/nvkm/engine/pm/nv50.c | 175 ----
 drivers/gpu/drm/nouveau/nvkm/engine/pm/priv.h | 105 ---
 23 files changed, 1 insertion(+), 2541 deletions(-)
 delete mode 100644 drivers/gpu/drm/nouveau/include/nvif/if0002.h
 delete mode 100644 drivers/gpu/drm/nouveau/include/nvif/if0003.h
 delete mode 100644 drivers/gpu/drm/nouveau/include/nvkm/engine/pm.h
 delete mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/pm/Kbuild
 delete mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/pm/base.c
 delete mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/pm/g84.c
 delete mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/pm/gf100.c
 delete mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/pm/gf100.h
 delete mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/pm/gf108.c
 delete mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/pm/gf117.c
 delete mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/pm/gk104.c
 delete mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/pm/gt200.c
 delete mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/pm/gt215.c
 delete mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/pm/nv40.c
 delete mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/pm/nv40.h
 delete mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/pm/nv50.c
 delete mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/pm/priv.h
drivers/gpu/drm/nouveau/include/nvif/class.h +0 -3
index e668ab1664f0..824e052dcc25 100644
@@ -7,9 +7,6 @@
 
 #define NVIF_CLASS_CONTROL                           /* if0001.h */ -0x00000001
 
-#define NVIF_CLASS_PERFMON                           /* if0002.h */ -0x00000002
-#define NVIF_CLASS_PERFDOM                           /* if0003.h */ -0x00000003
-
 #define NVIF_CLASS_SW_NV04                           /* if0004.h */ -0x00000004
 #define NVIF_CLASS_SW_NV10                           /* if0005.h */ -0x00000005
 #define NVIF_CLASS_SW_NV50                           /* if0005.h */ -0x00000006
drivers/gpu/drm/nouveau/include/nvif/if0002.h deleted +0 -39
deleted file mode 100644
index df2915d6a61e..000000000000
@@ -1,39 +0,0 @@
-/* SPDX-License-Identifier: MIT */
-#ifndef __NVIF_IF0002_H__
-#define __NVIF_IF0002_H__
-
-#define NVIF_PERFMON_V0_QUERY_DOMAIN                                       0x00
-#define NVIF_PERFMON_V0_QUERY_SIGNAL                                       0x01
-#define NVIF_PERFMON_V0_QUERY_SOURCE                                       0x02
-
-struct nvif_perfmon_query_domain_v0 {
-	__u8  version;
-	__u8  id;
-	__u8  counter_nr;
-	__u8  iter;
-	__u16 signal_nr;
-	__u8  pad05[2];
-	char  name[64];
-};
-
-struct nvif_perfmon_query_signal_v0 {
-	__u8  version;
-	__u8  domain;
-	__u16 iter;
-	__u8  signal;
-	__u8  source_nr;
-	__u8  pad05[2];
-	char  name[64];
-};
-
-struct nvif_perfmon_query_source_v0 {
-	__u8  version;
-	__u8  domain;
-	__u8  signal;
-	__u8  iter;
-	__u8  pad04[4];
-	__u32 source;
-	__u32 mask;
-	char  name[64];
-};
-#endif
drivers/gpu/drm/nouveau/include/nvif/if0003.h deleted +0 -34
deleted file mode 100644
index 78467da07c37..000000000000
@@ -1,34 +0,0 @@
-/* SPDX-License-Identifier: MIT */
-#ifndef __NVIF_IF0003_H__
-#define __NVIF_IF0003_H__
-
-struct nvif_perfdom_v0 {
-	__u8  version;
-	__u8  domain;
-	__u8  mode;
-	__u8  pad03[1];
-	struct {
-		__u8  signal[4];
-		__u64 source[4][8];
-		__u16 logic_op;
-	} ctr[4];
-};
-
-#define NVIF_PERFDOM_V0_INIT                                               0x00
-#define NVIF_PERFDOM_V0_SAMPLE                                             0x01
-#define NVIF_PERFDOM_V0_READ                                               0x02
-
-struct nvif_perfdom_init {
-};
-
-struct nvif_perfdom_sample {
-};
-
-struct nvif_perfdom_read_v0 {
-	__u8  version;
-	__u8  pad01[7];
-	__u32 ctr[4];
-	__u32 clk;
-	__u8  pad04[4];
-};
-#endif
drivers/gpu/drm/nouveau/include/nvkm/core/layout.h +0 -1
index 30c17db483cb..9d2a1abf64f9 100644
@@ -46,7 +46,6 @@ NVKM_LAYOUT_INST(NVKM_ENGINE_NVDEC   , struct nvkm_nvdec   ,    nvdec, 8)
 NVKM_LAYOUT_INST(NVKM_ENGINE_NVENC   , struct nvkm_nvenc   ,    nvenc, 3)
 NVKM_LAYOUT_INST(NVKM_ENGINE_NVJPG   , struct nvkm_engine  ,    nvjpg, 8)
 NVKM_LAYOUT_ONCE(NVKM_ENGINE_OFA     , struct nvkm_engine  ,      ofa)
-NVKM_LAYOUT_ONCE(NVKM_ENGINE_PM      , struct nvkm_pm      ,       pm)
 NVKM_LAYOUT_ONCE(NVKM_ENGINE_SEC     , struct nvkm_engine  ,      sec)
 NVKM_LAYOUT_ONCE(NVKM_ENGINE_SEC2    , struct nvkm_sec2    ,     sec2)
 NVKM_LAYOUT_ONCE(NVKM_ENGINE_SW      , struct nvkm_sw      ,       sw)
drivers/gpu/drm/nouveau/include/nvkm/engine/pm.h deleted +0 -29
deleted file mode 100644
index af89d46ea360..000000000000
@@ -1,29 +0,0 @@
-/* SPDX-License-Identifier: MIT */
-#ifndef __NVKM_PM_H__
-#define __NVKM_PM_H__
-#include <core/engine.h>
-
-struct nvkm_pm {
-	const struct nvkm_pm_func *func;
-	struct nvkm_engine engine;
-
-	struct {
-		spinlock_t lock;
-		struct nvkm_object *object;
-	} client;
-
-	struct list_head domains;
-	struct list_head sources;
-	u32 sequence;
-};
-
-int nv40_pm_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_pm **);
-int nv50_pm_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_pm **);
-int g84_pm_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_pm **);
-int gt200_pm_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_pm **);
-int gt215_pm_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_pm **);
-int gf100_pm_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_pm **);
-int gf108_pm_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_pm **);
-int gf117_pm_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_pm **);
-int gk104_pm_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_pm **);
-#endif
drivers/gpu/drm/nouveau/nvkm/device/base.c +0 -82

574 lines not on this page · raw message

drivers/gpu/drm/nouveau/nvkm/device/priv.h +0 -1
index c182d9c3e4fa..e42b18820a95 100644
@@ -45,7 +45,6 @@
 #include <engine/nvdec.h>
 #include <engine/nvjpg.h>
 #include <engine/ofa.h>
-#include <engine/pm.h>
 #include <engine/sec.h>
 #include <engine/sec2.h>
 #include <engine/sw.h>
drivers/gpu/drm/nouveau/nvkm/device/user.c +1 -2
index 7fd4800a876a..d937c54e8dfa 100644
@@ -322,8 +322,7 @@ nvkm_udevice_child_get(struct nvkm_object *object, int index,
 	struct nvkm_engine *engine;
 	u64 mask = (1ULL << NVKM_ENGINE_DMAOBJ) |
 		   (1ULL << NVKM_ENGINE_FIFO) |
-		   (1ULL << NVKM_ENGINE_DISP) |
-		   (1ULL << NVKM_ENGINE_PM);
+		   (1ULL << NVKM_ENGINE_DISP);
 	const struct nvkm_device_oclass *sclass = NULL;
 	int i;
 
drivers/gpu/drm/nouveau/nvkm/engine/Kbuild +0 -1
index f9eb68a25de8..565715db662e 100644
@@ -18,7 +18,6 @@ include $(src)/nvkm/engine/nvenc/Kbuild
 include $(src)/nvkm/engine/nvdec/Kbuild
 include $(src)/nvkm/engine/nvjpg/Kbuild
 include $(src)/nvkm/engine/ofa/Kbuild
-include $(src)/nvkm/engine/pm/Kbuild
 include $(src)/nvkm/engine/sec/Kbuild
 include $(src)/nvkm/engine/sec2/Kbuild
 include $(src)/nvkm/engine/sw/Kbuild
drivers/gpu/drm/nouveau/nvkm/engine/pm/Kbuild deleted +0 -11
deleted file mode 100644
index 2cc8a5f6fe0c..000000000000
@@ -1,11 +0,0 @@
-# SPDX-License-Identifier: MIT
-nvkm-y += nvkm/engine/pm/base.o
-nvkm-y += nvkm/engine/pm/nv40.o
-nvkm-y += nvkm/engine/pm/nv50.o
-nvkm-y += nvkm/engine/pm/g84.o
-nvkm-y += nvkm/engine/pm/gt200.o
-nvkm-y += nvkm/engine/pm/gt215.o
-nvkm-y += nvkm/engine/pm/gf100.o
-nvkm-y += nvkm/engine/pm/gf108.o
-nvkm-y += nvkm/engine/pm/gf117.o
-nvkm-y += nvkm/engine/pm/gk104.o
drivers/gpu/drm/nouveau/nvkm/engine/pm/base.c deleted +0 -867

867 lines not on this page · raw message

drivers/gpu/drm/nouveau/nvkm/engine/pm/g84.c deleted +0 -165

165 lines not on this page · raw message

drivers/gpu/drm/nouveau/nvkm/engine/pm/gf100.c deleted +0 -243

243 lines not on this page · raw message

drivers/gpu/drm/nouveau/nvkm/engine/pm/gf100.h deleted +0 -20
deleted file mode 100644
index bc4b014c4e8e..000000000000
@@ -1,20 +0,0 @@
-/* SPDX-License-Identifier: MIT */
-#ifndef __NVKM_PM_NVC0_H__
-#define __NVKM_PM_NVC0_H__
-#include "priv.h"
-
-struct gf100_pm_func {
-	const struct nvkm_specdom *doms_hub;
-	const struct nvkm_specdom *doms_gpc;
-	const struct nvkm_specdom *doms_part;
-};
-
-int gf100_pm_new_(const struct gf100_pm_func *, struct nvkm_device *, enum nvkm_subdev_type, int,
-		  struct nvkm_pm **);
-
-extern const struct nvkm_funcdom gf100_perfctr_func;
-extern const struct nvkm_specdom gf100_pm_gpc[];
-
-extern const struct nvkm_specsrc gf100_pbfb_sources[];
-extern const struct nvkm_specsrc gf100_pmfb_sources[];
-#endif
drivers/gpu/drm/nouveau/nvkm/engine/pm/gf108.c deleted +0 -66

66 lines not on this page · raw message

drivers/gpu/drm/nouveau/nvkm/engine/pm/gf117.c deleted +0 -80

80 lines not on this page · raw message

drivers/gpu/drm/nouveau/nvkm/engine/pm/gk104.c deleted +0 -184

184 lines not on this page · raw message

drivers/gpu/drm/nouveau/nvkm/engine/pm/gt200.c deleted +0 -157

157 lines not on this page · raw message

drivers/gpu/drm/nouveau/nvkm/engine/pm/gt215.c deleted +0 -138

138 lines not on this page · raw message

drivers/gpu/drm/nouveau/nvkm/engine/pm/nv40.c deleted +0 -123

123 lines not on this page · raw message

drivers/gpu/drm/nouveau/nvkm/engine/pm/nv40.h deleted +0 -15
deleted file mode 100644
index afb79843723d..000000000000
@@ -1,15 +0,0 @@
-/* SPDX-License-Identifier: MIT */
-#ifndef __NVKM_PM_NV40_H__
-#define __NVKM_PM_NV40_H__
-#define nv40_pm(p) container_of((p), struct nv40_pm, base)
-#include "priv.h"
-
-struct nv40_pm {
-	struct nvkm_pm base;
-	u32 sequence;
-};
-
-int nv40_pm_new_(const struct nvkm_specdom *, struct nvkm_device *, enum nvkm_subdev_type, int,
-		 struct nvkm_pm **);
-extern const struct nvkm_funcdom nv40_perfctr_func;
-#endif
drivers/gpu/drm/nouveau/nvkm/engine/pm/nv50.c deleted +0 -175

175 lines not on this page · raw message

drivers/gpu/drm/nouveau/nvkm/engine/pm/priv.h deleted +0 -105

41 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.41.0

Part of the diff is not shown here. View the raw message.

author
#27 lore raw

PATCH 26/156 drm/nouveau/nvkm: remove nvkm_client_search()

In reply to Ben Skeggs

- has been unused for a while now

---
 drivers/gpu/drm/nouveau/include/nvkm/core/client.h |  1 -
 drivers/gpu/drm/nouveau/nvkm/core/client.c         | 13 -------------
 2 files changed, 14 deletions(-)
drivers/gpu/drm/nouveau/include/nvkm/core/client.h +0 -1
index 932c9fd0b2d8..15f27fdd877a 100644
@@ -22,7 +22,6 @@ struct nvkm_client {
 
 int  nvkm_client_new(const char *name, u64 device, const char *cfg, const char *dbg,
 		     int (*)(u64, void *, u32), struct nvkm_client **);
-struct nvkm_client *nvkm_client_search(struct nvkm_client *, u64 handle);
 
 /* logging for client-facing objects */
 #define nvif_printk(o,l,p,f,a...) do {                                         \
drivers/gpu/drm/nouveau/nvkm/core/client.c +0 -13
index c55662937ab2..48416c5039a1 100644
@@ -67,19 +67,6 @@ nvkm_uclient_sclass = {
 	.ctor = nvkm_uclient_new,
 };
 
-static const struct nvkm_object_func nvkm_client;
-struct nvkm_client *
-nvkm_client_search(struct nvkm_client *client, u64 handle)
-{
-	struct nvkm_object *object;
-
-	object = nvkm_object_search(client, handle, &nvkm_client);
-	if (IS_ERR(object))
-		return (void *)object;
-
-	return nvkm_client(object);
-}
-
 static int
 nvkm_client_mthd_devlist(struct nvkm_client *client, void *data, u32 size)
 {
Signature · 1 line
2.41.0
author
#28 lore raw

PATCH 27/156 drm/nouveau/nvif: remove support for userspace backends

In reply to Ben Skeggs

- the tools that used libnvkm no longer exist

---
 drivers/gpu/drm/nouveau/include/nvif/driver.h |  3 --
 drivers/gpu/drm/nouveau/nvif/driver.c         | 32 ++++---------------
 2 files changed, 7 insertions(+), 28 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/driver.h +0 -3
index 7a3af05f7f98..8d294ce3cf0a 100644
@@ -21,7 +21,4 @@ int nvif_driver_init(const char *drv, const char *cfg, const char *dbg,
 		     const char *name, u64 device, struct nvif_client *);
 
 extern const struct nvif_driver nvif_driver_nvkm;
-extern const struct nvif_driver nvif_driver_drm;
-extern const struct nvif_driver nvif_driver_lib;
-extern const struct nvif_driver nvif_driver_null;
 #endif
drivers/gpu/drm/nouveau/nvif/driver.c +7 -25
index 5e00dd07afed..acb708df2559 100644
@@ -24,35 +24,17 @@
 #include <nvif/driver.h>
 #include <nvif/client.h>
 
-static const struct nvif_driver *
-nvif_driver[] = {
-#ifdef __KERNEL__
-	&nvif_driver_nvkm,
-#else
-	&nvif_driver_drm,
-	&nvif_driver_lib,
-	&nvif_driver_null,
-#endif
-	NULL
-};
-
 int
 nvif_driver_init(const char *drv, const char *cfg, const char *dbg,
 		 const char *name, u64 device, struct nvif_client *client)
 {
-	int ret = -EINVAL, i;
+	int ret;
+
+	client->driver = &nvif_driver_nvkm;
 
-	for (i = 0; (client->driver = nvif_driver[i]); i++) {
-		if (!drv || !strcmp(client->driver->name, drv)) {
-			ret = client->driver->init(name, device, cfg, dbg,
-						   &client->object.priv);
-			if (ret == 0)
-				break;
-			client->driver->fini(client->object.priv);
-		}
-	}
+	ret = client->driver->init(name, device, cfg, dbg, &client->object.priv);
+	if (ret)
+		return ret;
 
-	if (ret == 0)
-		ret = nvif_client_ctor(client, name, device, client);
-	return ret;
+	return nvif_client_ctor(client, name, device, client);
 }
Signature · 1 line
2.41.0
author
#29 lore raw

PATCH 28/156 drm/nouveau/nvif: remove route/token

In reply to Ben Skeggs

- these are no longer useful for anything

---
 drivers/gpu/drm/nouveau/include/nvif/client.h |  1 -
 .../drm/nouveau/include/nvkm/core/object.h    |  2 --
 .../drm/nouveau/include/nvkm/core/oclass.h    |  2 --
 drivers/gpu/drm/nouveau/nouveau_abi16.c       |  8 --------
 drivers/gpu/drm/nouveau/nvif/client.c         |  1 -
 drivers/gpu/drm/nouveau/nvif/object.c         |  3 ---
 drivers/gpu/drm/nouveau/nvkm/core/client.c    |  2 --
 drivers/gpu/drm/nouveau/nvkm/core/ioctl.c     | 19 ++++---------------
 drivers/gpu/drm/nouveau/nvkm/core/object.c    |  2 --
 drivers/gpu/drm/nouveau/nvkm/core/uevent.c    |  4 ++--
 10 files changed, 6 insertions(+), 38 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/client.h +0 -1
index 5d9395e651b6..64b033222c56 100644
@@ -8,7 +8,6 @@ struct nvif_client {
 	struct nvif_object object;
 	const struct nvif_driver *driver;
 	u64 version;
-	u8 route;
 };
 
 int  nvif_client_ctor(struct nvif_client *parent, const char *name, u64 device,
drivers/gpu/drm/nouveau/include/nvkm/core/object.h +0 -2
index ed1f66360782..d4f1c964ba31 100644
@@ -15,8 +15,6 @@ struct nvkm_object {
 
 	struct list_head head;
 	struct list_head tree;
-	u8  route;
-	u64 token;
 	u64 object;
 	struct rb_node node;
 };
drivers/gpu/drm/nouveau/include/nvkm/core/oclass.h +0 -2
index 8e1b945d38f3..cad05f0e7948 100644
@@ -21,8 +21,6 @@ struct nvkm_oclass {
 	const void *priv;
 	const void *engn;
 	u32 handle;
-	u8  route;
-	u64 token;
 	u64 object;
 	struct nvkm_client *client;
 	struct nvkm_object *parent;
drivers/gpu/drm/nouveau/nouveau_abi16.c +0 -8
index 5ebd19ece13b..2648e42e0496 100644
@@ -521,7 +521,6 @@ nouveau_abi16_ioctl_grobj_alloc(ABI16_IOCTL_ARGS)
 	struct nouveau_abi16 *abi16 = nouveau_abi16_get(file_priv);
 	struct nouveau_abi16_chan *chan;
 	struct nouveau_abi16_ntfy *ntfy;
-	struct nvif_client *client;
 	struct nvif_sclass *sclass;
 	s32 oclass = 0;
 	int ret, i;
@@ -531,7 +530,6 @@ nouveau_abi16_ioctl_grobj_alloc(ABI16_IOCTL_ARGS)
 
 	if (init->handle == ~0)
 		return nouveau_abi16_put(abi16, -EINVAL);
-	client = &abi16->cli->base;
 
 	chan = nouveau_abi16_chan(abi16, init->channel);
 	if (!chan)
@@ -596,10 +594,8 @@ nouveau_abi16_ioctl_grobj_alloc(ABI16_IOCTL_ARGS)
 
 	list_add(&ntfy->head, &chan->notifiers);
 
-	client->route = NVDRM_OBJECT_ABI16;
 	ret = nvif_object_ctor(&chan->chan->user, "abi16EngObj", init->handle,
 			       oclass, NULL, 0, &ntfy->object);
-	client->route = NVDRM_OBJECT_NVIF;
 
 	if (ret)
 		nouveau_abi16_ntfy_fini(chan, ntfy);
@@ -615,7 +611,6 @@ nouveau_abi16_ioctl_notifierobj_alloc(ABI16_IOCTL_ARGS)
 	struct nouveau_abi16_chan *chan;
 	struct nouveau_abi16_ntfy *ntfy;
 	struct nvif_device *device = &drm->device;
-	struct nvif_client *client;
 	struct nv_dma_v0 args = {};
 	int ret;
 
@@ -625,7 +620,6 @@ nouveau_abi16_ioctl_notifierobj_alloc(ABI16_IOCTL_ARGS)
 	/* completely unnecessary for these chipsets... */
 	if (unlikely(device->info.family >= NV_DEVICE_INFO_V0_FERMI))
 		return nouveau_abi16_put(abi16, -EINVAL);
-	client = &abi16->cli->base;
 
 	chan = nouveau_abi16_chan(abi16, info->channel);
 	if (!chan)
@@ -662,11 +656,9 @@ nouveau_abi16_ioctl_notifierobj_alloc(ABI16_IOCTL_ARGS)
 		args.limit += chan->ntfy->offset;
 	}
 
-	client->route = NVDRM_OBJECT_ABI16;
 	ret = nvif_object_ctor(&chan->chan->user, "abi16Ntfy", info->handle,
 			       NV_DMA_IN_MEMORY, &args, sizeof(args),
 			       &ntfy->object);
-	client->route = NVDRM_OBJECT_NVIF;
 	if (ret)
 		goto done;
 
drivers/gpu/drm/nouveau/nvif/client.c +0 -1
index 3a27245f467f..cd5439b73ac7 100644
@@ -79,7 +79,6 @@ nvif_client_ctor(struct nvif_client *parent, const char *name, u64 device,
 
 	client->object.client = client;
 	client->object.handle = ~0;
-	client->route = NVIF_IOCTL_V0_ROUTE_NVIF;
 	client->driver = parent->driver;
 
 	if (ret == 0) {
drivers/gpu/drm/nouveau/nvif/object.c +0 -3
index 4d1aaee8fe15..2b3e05197846 100644
@@ -40,7 +40,6 @@ nvif_object_ioctl(struct nvif_object *object, void *data, u32 size, void **hack)
 			args->v0.object = nvif_handle(object);
 		else
 			args->v0.object = 0;
-		args->v0.owner = NVIF_IOCTL_V0_OWNER_ANY;
 	} else
 		return -ENOSYS;
 
@@ -286,8 +285,6 @@ nvif_object_ctor(struct nvif_object *parent, const char *name, u32 handle,
 		args->ioctl.version = 0;
 		args->ioctl.type = NVIF_IOCTL_V0_NEW;
 		args->new.version = 0;
-		args->new.route = parent->client->route;
-		args->new.token = nvif_handle(object);
 		args->new.object = nvif_handle(object);
 		args->new.handle = handle;
 		args->new.oclass = oclass;
drivers/gpu/drm/nouveau/nvkm/core/client.c +0 -2
index 48416c5039a1..95cbb5b682f2 100644
@@ -51,8 +51,6 @@ nvkm_uclient_new(const struct nvkm_oclass *oclass, void *argv, u32 argc,
 
 	client->object.client = oclass->client;
 	client->object.handle = oclass->handle;
-	client->object.route  = oclass->route;
-	client->object.token  = oclass->token;
 	client->object.object = oclass->object;
 	client->debug = oclass->client->debug;
 	*pobject = &client->object;
drivers/gpu/drm/nouveau/nvkm/core/ioctl.c +4 -15
index 0b33287e43a7..39d5c9700867 100644
@@ -112,10 +112,9 @@ nvkm_ioctl_new(struct nvkm_client *client,
 
 	nvif_ioctl(parent, "new size %d\n", size);
 	if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) {
-		nvif_ioctl(parent, "new vers %d handle %08x class %08x "
-				   "route %02x token %llx object %016llx\n",
+		nvif_ioctl(parent, "new vers %d handle %08x class %08x object %016llx\n",
 			   args->v0.version, args->v0.handle, args->v0.oclass,
-			   args->v0.route, args->v0.token, args->v0.object);
+			   args->v0.object);
 	} else
 		return ret;
 
@@ -127,8 +126,6 @@ nvkm_ioctl_new(struct nvkm_client *client,
 	do {
 		memset(&oclass, 0x00, sizeof(oclass));
 		oclass.handle = args->v0.handle;
-		oclass.route  = args->v0.route;
-		oclass.token  = args->v0.token;
 		oclass.object = args->v0.object;
 		oclass.client = client;
 		oclass.parent = parent;
@@ -331,7 +328,7 @@ nvkm_ioctl_v0[] = {
 
 static int
 nvkm_ioctl_path(struct nvkm_client *client, u64 handle, u32 type,
-		void *data, u32 size, u8 owner, u8 *route, u64 *token)
+		void *data, u32 size)
 {
 	struct nvkm_object *object;
 	int ret;
@@ -342,13 +339,6 @@ nvkm_ioctl_path(struct nvkm_client *client, u64 handle, u32 type,
 		return PTR_ERR(object);
 	}
 
-	if (owner != NVIF_IOCTL_V0_OWNER_ANY && owner != object->route) {
-		nvif_ioctl(&client->object, "route != owner\n");
-		return -EACCES;
-	}
-	*route = object->route;
-	*token = object->token;
-
 	if (ret = -EINVAL, type < ARRAY_SIZE(nvkm_ioctl_v0)) {
 		if (nvkm_ioctl_v0[type].version == 0)
 			ret = nvkm_ioctl_v0[type].func(client, object, data, size);
@@ -374,8 +364,7 @@ nvkm_ioctl(struct nvkm_client *client, void *data, u32 size, void **hack)
 			   args->v0.version, args->v0.type, args->v0.object,
 			   args->v0.owner);
 		ret = nvkm_ioctl_path(client, args->v0.object, args->v0.type,
-				      data, size, args->v0.owner,
-				      &args->v0.route, &args->v0.token);
+				      data, size);
 	}
 
 	if (ret != 1) {
drivers/gpu/drm/nouveau/nvkm/core/object.c +0 -2
index aea3ba72027a..580b8c7f25af 100644
@@ -313,8 +313,6 @@ nvkm_object_ctor(const struct nvkm_object_func *func,
 	object->engine = nvkm_engine_ref(oclass->engine);
 	object->oclass = oclass->base.oclass;
 	object->handle = oclass->handle;
-	object->route  = oclass->route;
-	object->token  = oclass->token;
 	object->object = oclass->object;
 	INIT_LIST_HEAD(&object->head);
 	INIT_LIST_HEAD(&object->tree);
drivers/gpu/drm/nouveau/nvkm/core/uevent.c +2 -2
index ba9d9edaec75..cc254c390a57 100644
@@ -116,9 +116,9 @@ nvkm_uevent_ntfy(struct nvkm_event_ntfy *ntfy, u32 bits)
 	struct nvkm_client *client = uevent->object.client;
 
 	if (uevent->func)
-		return uevent->func(uevent->parent, uevent->object.token, bits);
+		return uevent->func(uevent->parent, uevent->object.object, bits);
 
-	return client->event(uevent->object.token, NULL, 0);
+	return client->event(uevent->object.object, NULL, 0);
 }
 
 int
Signature · 1 line
2.41.0
author
#30 lore raw

PATCH 29/156 drm/nouveau/nvif: remove nvxx_object()

In reply to Ben Skeggs

- no longer used

---
 drivers/gpu/drm/nouveau/include/nvif/object.h |  7 -------
 drivers/gpu/drm/nouveau/include/nvif/os.h     | 19 +++++++++++++++++++
 .../gpu/drm/nouveau/include/nvkm/core/os.h    | 19 -------------------
 3 files changed, 19 insertions(+), 26 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/object.h +0 -7
index f52399caee82..478cbb8f2dfe 100644
@@ -134,11 +134,4 @@ struct nvif_mclass {
 #define NVIF_MR32(p,A...) DRF_MR(NVIF_RD32_, NVIF_WR32_, u32, (p), 0, ##A)
 #define NVIF_MV32(p,A...) DRF_MV(NVIF_RD32_, NVIF_WR32_, u32, (p), 0, ##A)
 #define NVIF_MD32(p,A...) DRF_MD(NVIF_RD32_, NVIF_WR32_, u32, (p), 0, ##A)
-
-/*XXX*/
-#include <core/object.h>
-#define nvxx_object(a) ({                                                      \
-	struct nvif_object *_object = (a);                                     \
-	(struct nvkm_object *)_object->priv;                                   \
-})
 #endif
drivers/gpu/drm/nouveau/include/nvif/os.h +19 -0
index 429d0106c123..a2eaf3929ac3 100644
@@ -34,4 +34,23 @@
 
 #include <soc/tegra/fuse.h>
 #include <soc/tegra/pmc.h>
+
+#ifdef __BIG_ENDIAN
+#define ioread16_native ioread16be
+#define iowrite16_native iowrite16be
+#define ioread32_native  ioread32be
+#define iowrite32_native iowrite32be
+#else
+#define ioread16_native ioread16
+#define iowrite16_native iowrite16
+#define ioread32_native  ioread32
+#define iowrite32_native iowrite32
+#endif
+
+#define iowrite64_native(v,p) do {                                             \
+	u32 __iomem *_p = (u32 __iomem *)(p);                                  \
+	u64 _v = (v);                                                          \
+	iowrite32_native(lower_32_bits(_v), &_p[0]);                           \
+	iowrite32_native(upper_32_bits(_v), &_p[1]);                           \
+} while(0)
 #endif
drivers/gpu/drm/nouveau/include/nvkm/core/os.h +0 -19
index 3fd5c007a663..9b05612e6490 100644
@@ -3,25 +3,6 @@
 #define __NVKM_OS_H__
 #include <nvif/os.h>
 
-#ifdef __BIG_ENDIAN
-#define ioread16_native ioread16be
-#define iowrite16_native iowrite16be
-#define ioread32_native  ioread32be
-#define iowrite32_native iowrite32be
-#else
-#define ioread16_native ioread16
-#define iowrite16_native iowrite16
-#define ioread32_native  ioread32
-#define iowrite32_native iowrite32
-#endif
-
-#define iowrite64_native(v,p) do {                                             \
-	u32 __iomem *_p = (u32 __iomem *)(p);				       \
-	u64 _v = (v);							       \
-	iowrite32_native(lower_32_bits(_v), &_p[0]);			       \
-	iowrite32_native(upper_32_bits(_v), &_p[1]);			       \
-} while(0)
-
 struct nvkm_blob {
 	void *data;
 	u32 size;
Signature · 1 line
2.41.0
author
#31 lore raw

PATCH 30/156 drm/nouveau/nvif: remove nvxx_client()

In reply to Ben Skeggs

- cli->name is a thing
- messages using nvkm_client.debug are being removed, so it's not needed

---
 drivers/gpu/drm/nouveau/include/nvif/client.h | 5 -----
 drivers/gpu/drm/nouveau/nouveau_chan.c        | 2 +-
 drivers/gpu/drm/nouveau/nouveau_drm.c         | 3 ---
 drivers/gpu/drm/nouveau/nouveau_fence.c       | 2 +-
 4 files changed, 2 insertions(+), 10 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/client.h +0 -5
index 64b033222c56..5210007d7669 100644
@@ -18,9 +18,4 @@ int  nvif_client_suspend(struct nvif_client *);
 int  nvif_client_resume(struct nvif_client *);
 
 /*XXX*/
-#include <core/client.h>
-#define nvxx_client(a) ({                                                      \
-	struct nvif_client *_client = (a);                                     \
-	(struct nvkm_client *)_client->object.priv;                            \
-})
 #endif
drivers/gpu/drm/nouveau/nouveau_chan.c +1 -1
index db86cca9ea37..7977bb353c92 100644
@@ -78,7 +78,7 @@ nouveau_channel_idle(struct nouveau_channel *chan)
 
 		if (ret) {
 			NV_PRINTK(err, cli, "failed to idle channel %d [%s]\n",
-				  chan->chid, nvxx_client(&cli->base)->name);
+				  chan->chid, cli->name);
 			return ret;
 		}
 	}
drivers/gpu/drm/nouveau/nouveau_drm.c +0 -3
index 33883c4e8221..ad2772cf5e23 100644
@@ -630,9 +630,6 @@ nouveau_drm_device_init(struct drm_device *dev, struct nvkm_device *nvkm)
 	if (ret)
 		goto fail_wq;
 
-	nvxx_client(&drm->client.base)->debug =
-		nvkm_dbgopt(nouveau_debug, "DRM");
-
 	INIT_LIST_HEAD(&drm->clients);
 	mutex_init(&drm->clients_lock);
 	spin_lock_init(&drm->tile.lock);
drivers/gpu/drm/nouveau/nouveau_fence.c +1 -1
index ba25ce1294a6..09686d038d60 100644
@@ -201,7 +201,7 @@ nouveau_fence_context_new(struct nouveau_channel *chan, struct nouveau_fence_cha
 	else if (chan == drm->channel)
 		strcpy(fctx->name, "generic kernel channel");
 	else
-		strcpy(fctx->name, nvxx_client(&cli->base)->name);
+		strcpy(fctx->name, cli->name);
 
 	kref_init(&fctx->fence_ref);
 	if (!priv->uevent)
Signature · 1 line
2.41.0
author
#32 lore raw

PATCH 31/156 drm/nouveau/nvif: remove driver keep/fini

In reply to Ben Skeggs

- no longer used

---
 drivers/gpu/drm/nouveau/include/nvif/driver.h | 2 --
 drivers/gpu/drm/nouveau/nvif/client.c         | 6 +-----
 drivers/gpu/drm/nouveau/nvkm/core/driver.c    | 1 -
 3 files changed, 1 insertion(+), 8 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/driver.h +0 -2
index 8d294ce3cf0a..7b08ff769039 100644
@@ -8,13 +8,11 @@ struct nvif_driver {
 	const char *name;
 	int (*init)(const char *name, u64 device, const char *cfg,
 		    const char *dbg, void **priv);
-	void (*fini)(void *priv);
 	int (*suspend)(void *priv);
 	int (*resume)(void *priv);
 	int (*ioctl)(void *priv, void *data, u32 size, void **hack);
 	void __iomem *(*map)(void *priv, u64 handle, u32 size);
 	void (*unmap)(void *priv, void __iomem *ptr, u32 size);
-	bool keep;
 };
 
 int nvif_driver_init(const char *drv, const char *cfg, const char *dbg,
drivers/gpu/drm/nouveau/nvif/client.c +1 -5
index cd5439b73ac7..85ad5091e8e2 100644
@@ -51,11 +51,7 @@ void
 nvif_client_dtor(struct nvif_client *client)
 {
 	nvif_object_dtor(&client->object);
-	if (client->driver) {
-		if (client->driver->fini)
-			client->driver->fini(client->object.priv);
-		client->driver = NULL;
-	}
+	client->driver = NULL;
 }
 
 int
drivers/gpu/drm/nouveau/nvkm/core/driver.c +0 -1
index 3494002b40cd..1f5273ff2225 100644
@@ -95,5 +95,4 @@ nvif_driver_nvkm = {
 	.ioctl = nvkm_driver_ioctl,
 	.map = nvkm_driver_map,
 	.unmap = nvkm_driver_unmap,
-	.keep = false,
 };
Signature · 1 line
2.41.0
author
#33 lore raw

PATCH 32/156 drm/nouveau/nvif: remove client version

In reply to Ben Skeggs

- unused

---
 drivers/gpu/drm/nouveau/include/nvif/client.h |  2 --
 drivers/gpu/drm/nouveau/include/nvif/ioctl.h  |  7 -------
 drivers/gpu/drm/nouveau/nvif/client.c         | 20 +------------------
 drivers/gpu/drm/nouveau/nvkm/core/ioctl.c     | 13 +-----------
 4 files changed, 2 insertions(+), 40 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/client.h +0 -2
index 5210007d7669..87dc55f8bde6 100644
@@ -7,13 +7,11 @@
 struct nvif_client {
 	struct nvif_object object;
 	const struct nvif_driver *driver;
-	u64 version;
 };
 
 int  nvif_client_ctor(struct nvif_client *parent, const char *name, u64 device,
 		      struct nvif_client *);
 void nvif_client_dtor(struct nvif_client *);
-int  nvif_client_ioctl(struct nvif_client *, void *, u32);
 int  nvif_client_suspend(struct nvif_client *);
 int  nvif_client_resume(struct nvif_client *);
 
drivers/gpu/drm/nouveau/include/nvif/ioctl.h +0 -7
index 4e047bb1fc07..1e74245621e0 100644
@@ -2,11 +2,8 @@
 #ifndef __NVIF_IOCTL_H__
 #define __NVIF_IOCTL_H__
 
-#define NVIF_VERSION_LATEST                               0x0000000000000100ULL
-
 struct nvif_ioctl_v0 {
 	__u8  version;
-#define NVIF_IOCTL_V0_NOP                                                  0x00
 #define NVIF_IOCTL_V0_SCLASS                                               0x01
 #define NVIF_IOCTL_V0_NEW                                                  0x02
 #define NVIF_IOCTL_V0_DEL                                                  0x03
@@ -28,10 +25,6 @@ struct nvif_ioctl_v0 {
 	__u8  data[];		/* ioctl data (below) */
 };
 
-struct nvif_ioctl_nop_v0 {
-	__u64 version;
-};
-
 struct nvif_ioctl_sclass_v0 {
 	/* nvif_ioctl ... */
 	__u8  version;
drivers/gpu/drm/nouveau/nvif/client.c +1 -19
index 85ad5091e8e2..098831d92eac 100644
@@ -29,12 +29,6 @@
 #include <nvif/class.h>
 #include <nvif/if0000.h>
 
-int
-nvif_client_ioctl(struct nvif_client *client, void *data, u32 size)
-{
-	return client->driver->ioctl(client->object.priv, data, size, NULL);
-}
-
 int
 nvif_client_suspend(struct nvif_client *client)
 {
@@ -59,10 +53,6 @@ nvif_client_ctor(struct nvif_client *parent, const char *name, u64 device,
 		 struct nvif_client *client)
 {
 	struct nvif_client_v0 args = { .device = device };
-	struct {
-		struct nvif_ioctl_v0 ioctl;
-		struct nvif_ioctl_nop_v0 nop;
-	} nop = {};
 	int ret;
 
 	strscpy_pad(args.name, name, sizeof(args.name));
@@ -76,13 +66,5 @@ nvif_client_ctor(struct nvif_client *parent, const char *name, u64 device,
 	client->object.client = client;
 	client->object.handle = ~0;
 	client->driver = parent->driver;
-
-	if (ret == 0) {
-		ret = nvif_client_ioctl(client, &nop, sizeof(nop));
-		client->version = nop.nop.version;
-	}
-
-	if (ret)
-		nvif_client_dtor(client);
-	return ret;
+	return 0;
 }
drivers/gpu/drm/nouveau/nvkm/core/ioctl.c +1 -12
index 39d5c9700867..584fc43c0d75 100644
@@ -33,18 +33,7 @@ static int
 nvkm_ioctl_nop(struct nvkm_client *client,
 	       struct nvkm_object *object, void *data, u32 size)
 {
-	union {
-		struct nvif_ioctl_nop_v0 v0;
-	} *args = data;
-	int ret = -ENOSYS;
-
-	nvif_ioctl(object, "nop size %d\n", size);
-	if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
-		nvif_ioctl(object, "nop vers %lld\n", args->v0.version);
-		args->v0.version = NVIF_VERSION_LATEST;
-	}
-
-	return ret;
+	return -ENOSYS;
 }
 
 #include <nvif/class.h>
Signature · 1 line
2.41.0
author
#34 lore raw

PATCH 33/156 drm/nouveau/nvif: remove client devlist

In reply to Ben Skeggs

- unused

---
 drivers/gpu/drm/nouveau/include/nvif/if0000.h |  9 -----
 .../drm/nouveau/include/nvkm/core/device.h    |  1 -
 drivers/gpu/drm/nouveau/nvkm/core/client.c    | 40 -------------------
 drivers/gpu/drm/nouveau/nvkm/device/base.c    | 14 -------
 4 files changed, 64 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/if0000.h +0 -9
index f7b8f8f48760..4b31496b37e1 100644
@@ -8,13 +8,4 @@ struct nvif_client_v0 {
 	__u64 device;
 	char  name[32];
 };
-
-#define NVIF_CLIENT_V0_DEVLIST                                             0x00
-
-struct nvif_client_devlist_v0 {
-	__u8  version;
-	__u8  count;
-	__u8  pad02[6];
-	__u64 device[];
-};
 #endif
drivers/gpu/drm/nouveau/include/nvkm/core/device.h +0 -1
index f057d348221e..46afb877a296 100644
@@ -109,7 +109,6 @@ struct nvkm_device_chip {
 };
 
 struct nvkm_device *nvkm_device_find(u64 name);
-int nvkm_device_list(u64 *name, int size);
 
 /* privileged register interface accessor macros */
 #define nvkm_rd08(d,a) ioread8((d)->pri + (a))
drivers/gpu/drm/nouveau/nvkm/core/client.c +0 -40
index 95cbb5b682f2..3e7049427b06 100644
@@ -65,45 +65,6 @@ nvkm_uclient_sclass = {
 	.ctor = nvkm_uclient_new,
 };
 
-static int
-nvkm_client_mthd_devlist(struct nvkm_client *client, void *data, u32 size)
-{
-	union {
-		struct nvif_client_devlist_v0 v0;
-	} *args = data;
-	int ret = -ENOSYS;
-
-	nvif_ioctl(&client->object, "client devlist size %d\n", size);
-	if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) {
-		nvif_ioctl(&client->object, "client devlist vers %d count %d\n",
-			   args->v0.version, args->v0.count);
-		if (size == sizeof(args->v0.device[0]) * args->v0.count) {
-			ret = nvkm_device_list(args->v0.device, args->v0.count);
-			if (ret >= 0) {
-				args->v0.count = ret;
-				ret = 0;
-			}
-		} else {
-			ret = -EINVAL;
-		}
-	}
-
-	return ret;
-}
-
-static int
-nvkm_client_mthd(struct nvkm_object *object, u32 mthd, void *data, u32 size)
-{
-	struct nvkm_client *client = nvkm_client(object);
-	switch (mthd) {
-	case NVIF_CLIENT_V0_DEVLIST:
-		return nvkm_client_mthd_devlist(client, data, size);
-	default:
-		break;
-	}
-	return -EINVAL;
-}
-
 static int
 nvkm_client_child_new(const struct nvkm_oclass *oclass,
 		      void *data, u32 size, struct nvkm_object **pobject)
@@ -145,7 +106,6 @@ static const struct nvkm_object_func
 nvkm_client = {
 	.dtor = nvkm_client_dtor,
 	.fini = nvkm_client_fini,
-	.mthd = nvkm_client_mthd,
 	.sclass = nvkm_client_child_get,
 };
 
drivers/gpu/drm/nouveau/nvkm/device/base.c +0 -14
index 3f827adcb19d..3ce42de55aa9 100644
@@ -53,20 +53,6 @@ nvkm_device_find(u64 handle)
 	return device;
 }
 
-int
-nvkm_device_list(u64 *name, int size)
-{
-	struct nvkm_device *device;
-	int nr = 0;
-	mutex_lock(&nv_devices_mutex);
-	list_for_each_entry(device, &nv_devices, head) {
-		if (nr++ < size)
-			name[nr - 1] = device->handle;
-	}
-	mutex_unlock(&nv_devices_mutex);
-	return nr;
-}
-
 static const struct nvkm_device_chip
 nv4_chipset = {
 	.name = "NV04",
Signature · 1 line
2.41.0
author
#35 lore raw

PATCH 34/156 drm/nouveau/nvif: remove client fini

In reply to Ben Skeggs

- unused

---
 drivers/gpu/drm/nouveau/nvkm/core/client.c | 7 -------
 1 file changed, 7 deletions(-)
drivers/gpu/drm/nouveau/nvkm/core/client.c +0 -7
index 3e7049427b06..f73d58eb6de6 100644
@@ -90,12 +90,6 @@ nvkm_client_child_get(struct nvkm_object *object, int index,
 	return 0;
 }
 
-static int
-nvkm_client_fini(struct nvkm_object *object, bool suspend)
-{
-	return 0;
-}
-
 static void *
 nvkm_client_dtor(struct nvkm_object *object)
 {
@@ -105,7 +99,6 @@ nvkm_client_dtor(struct nvkm_object *object)
 static const struct nvkm_object_func
 nvkm_client = {
 	.dtor = nvkm_client_dtor,
-	.fini = nvkm_client_fini,
 	.sclass = nvkm_client_child_get,
 };
 
Signature · 1 line
2.41.0
author
#36 lore raw

PATCH 35/156 drm/nouveau/nvif: remove device args

In reply to Ben Skeggs

- now unused
- pass nvif_client as parent, rather than nvif_client.object

---
 drivers/gpu/drm/nouveau/include/nvif/cl0080.h |  7 ----
 drivers/gpu/drm/nouveau/include/nvif/device.h |  3 +-
 drivers/gpu/drm/nouveau/nouveau_drm.c         | 14 ++------
 drivers/gpu/drm/nouveau/nvif/device.c         |  9 +++--
 drivers/gpu/drm/nouveau/nvkm/device/user.c    | 36 ++-----------------
 5 files changed, 10 insertions(+), 59 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/cl0080.h +0 -7
index fa161b74d967..ea937fa7bc55 100644
@@ -2,13 +2,6 @@
 #ifndef __NVIF_CL0080_H__
 #define __NVIF_CL0080_H__
 
-struct nv_device_v0 {
-	__u8  version;
-	__u8  priv;
-	__u8  pad02[6];
-	__u64 device;	/* device identifier, ~0 for client default */
-};
-
 #define NV_DEVICE_V0_INFO                                                  0x00
 #define NV_DEVICE_V0_TIME                                                  0x01
 
drivers/gpu/drm/nouveau/include/nvif/device.h +1 -2
index 64b8e4defc35..fec76f4733a4 100644
@@ -18,8 +18,7 @@ struct nvif_device {
 	struct nvif_user user;
 };
 
-int  nvif_device_ctor(struct nvif_object *, const char *name, u32 handle,
-		      s32 oclass, void *, u32, struct nvif_device *);
+int  nvif_device_ctor(struct nvif_client *, const char *name, struct nvif_device *);
 void nvif_device_dtor(struct nvif_device *);
 int  nvif_device_map(struct nvif_device *);
 u64  nvif_device_time(struct nvif_device *);
drivers/gpu/drm/nouveau/nouveau_drm.c +2 -12
index ad2772cf5e23..9caadcdb3c29 100644
@@ -253,12 +253,7 @@ nouveau_cli_init(struct nouveau_drm *drm, const char *sname,
 		goto done;
 	}
 
-	ret = nvif_device_ctor(&cli->base.object, "drmDevice", 0, NV_DEVICE,
-			       &(struct nv_device_v0) {
-					.device = ~0,
-					.priv = true,
-			       }, sizeof(struct nv_device_v0),
-			       &cli->device);
+	ret = nvif_device_ctor(&cli->base, "drmDevice", &cli->device);
 	if (ret) {
 		NV_PRINTK(err, cli, "Device allocation failed: %d\n", ret);
 		goto done;
@@ -590,12 +585,7 @@ nouveau_drm_device_init(struct drm_device *dev, struct nvkm_device *nvkm)
 	if (ret)
 		goto fail_alloc;
 
-	ret = nvif_device_ctor(&drm->_client.object, "drmDevice", 0, NV_DEVICE,
-			       &(struct nv_device_v0) {
-					.device = ~0,
-					.priv = true,
-			       }, sizeof(struct nv_device_v0),
-			       &drm->device);
+	ret = nvif_device_ctor(&drm->_client, "drmDevice", &drm->device);
 	if (ret) {
 		NV_ERROR(drm, "Device allocation failed: %d\n", ret);
 		goto fail_nvif;
drivers/gpu/drm/nouveau/nvif/device.c +4 -5
index 2fef6553a013..24880931039f 100644
@@ -21,8 +21,8 @@
  *
  * Authors: Ben Skeggs <[email protected]>
  */
-
 #include <nvif/device.h>
+#include <nvif/client.h>
 
 u64
 nvif_device_time(struct nvif_device *device)
@@ -54,11 +54,10 @@ nvif_device_dtor(struct nvif_device *device)
 }
 
 int
-nvif_device_ctor(struct nvif_object *parent, const char *name, u32 handle,
-		 s32 oclass, void *data, u32 size, struct nvif_device *device)
+nvif_device_ctor(struct nvif_client *client, const char *name, struct nvif_device *device)
 {
-	int ret = nvif_object_ctor(parent, name ? name : "nvifDevice", handle,
-				   oclass, data, size, &device->object);
+	int ret = nvif_object_ctor(&client->object, name ? name : "nvifDevice", 0,
+				   0x0080, NULL, 0, &device->object);
 	device->runlist = NULL;
 	device->user.func = NULL;
 	if (ret == 0) {
drivers/gpu/drm/nouveau/nvkm/device/user.c +3 -33
index d937c54e8dfa..65bd6712bce2 100644
@@ -357,7 +357,7 @@ nvkm_udevice_child_get(struct nvkm_object *object, int index,
 }
 
 static const struct nvkm_object_func
-nvkm_udevice_super = {
+nvkm_udevice = {
 	.init = nvkm_udevice_init,
 	.fini = nvkm_udevice_fini,
 	.mthd = nvkm_udevice_mthd,
@@ -371,50 +371,20 @@ nvkm_udevice_super = {
 	.sclass = nvkm_udevice_child_get,
 };
 
-static const struct nvkm_object_func
-nvkm_udevice = {
-	.init = nvkm_udevice_init,
-	.fini = nvkm_udevice_fini,
-	.mthd = nvkm_udevice_mthd,
-	.sclass = nvkm_udevice_child_get,
-};
-
 static int
 nvkm_udevice_new(const struct nvkm_oclass *oclass, void *data, u32 size,
 		 struct nvkm_object **pobject)
 {
-	union {
-		struct nv_device_v0 v0;
-	} *args = data;
 	struct nvkm_client *client = oclass->client;
-	struct nvkm_object *parent = &client->object;
-	const struct nvkm_object_func *func;
 	struct nvkm_udevice *udev;
-	int ret = -ENOSYS;
-
-	nvif_ioctl(parent, "create device size %d\n", size);
-	if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
-		nvif_ioctl(parent, "create device v%d device %016llx\n",
-			   args->v0.version, args->v0.device);
-	} else
-		return ret;
-
-	/* give priviledged clients register access */
-	if (args->v0.priv)
-		func = &nvkm_udevice_super;
-	else
-		func = &nvkm_udevice;
 
 	if (!(udev = kzalloc(sizeof(*udev), GFP_KERNEL)))
 		return -ENOMEM;
-	nvkm_object_ctor(func, oclass, &udev->object);
+	nvkm_object_ctor(&nvkm_udevice, oclass, &udev->object);
 	*pobject = &udev->object;
 
 	/* find the device that matches what the client requested */
-	if (args->v0.device != ~0)
-		udev->device = nvkm_device_find(args->v0.device);
-	else
-		udev->device = nvkm_device_find(client->device);
+	udev->device = nvkm_device_find(client->device);
 	if (!udev->device)
 		return -ENODEV;
 
Signature · 1 line
2.41.0
author
#37 lore raw

PATCH 36/156 drm/nouveau/nvif: remove device rd/wr

In reply to Ben Skeggs

- device is always mapped now, these are unneeded

---
 .../drm/nouveau/include/nvkm/core/object.h    |  8 ---
 drivers/gpu/drm/nouveau/nvkm/core/ioctl.c     | 10 ----
 drivers/gpu/drm/nouveau/nvkm/core/object.c    | 32 -----------
 drivers/gpu/drm/nouveau/nvkm/core/oproxy.c    | 28 ----------
 drivers/gpu/drm/nouveau/nvkm/device/user.c    | 54 -------------------
 5 files changed, 132 deletions(-)
drivers/gpu/drm/nouveau/include/nvkm/core/object.h +0 -8
index d4f1c964ba31..c91abac44bd6 100644
@@ -33,11 +33,7 @@ struct nvkm_object_func {
 	int (*map)(struct nvkm_object *, void *argv, u32 argc,
 		   enum nvkm_object_map *, u64 *addr, u64 *size);
 	int (*unmap)(struct nvkm_object *);
-	int (*rd08)(struct nvkm_object *, u64 addr, u8 *data);
-	int (*rd16)(struct nvkm_object *, u64 addr, u16 *data);
 	int (*rd32)(struct nvkm_object *, u64 addr, u32 *data);
-	int (*wr08)(struct nvkm_object *, u64 addr, u8 data);
-	int (*wr16)(struct nvkm_object *, u64 addr, u16 data);
 	int (*wr32)(struct nvkm_object *, u64 addr, u32 data);
 	int (*bind)(struct nvkm_object *, struct nvkm_gpuobj *, int align,
 		    struct nvkm_gpuobj **);
@@ -61,11 +57,7 @@ int nvkm_object_ntfy(struct nvkm_object *, u32 mthd, struct nvkm_event **);
 int nvkm_object_map(struct nvkm_object *, void *argv, u32 argc,
 		    enum nvkm_object_map *, u64 *addr, u64 *size);
 int nvkm_object_unmap(struct nvkm_object *);
-int nvkm_object_rd08(struct nvkm_object *, u64 addr, u8  *data);
-int nvkm_object_rd16(struct nvkm_object *, u64 addr, u16 *data);
 int nvkm_object_rd32(struct nvkm_object *, u64 addr, u32 *data);
-int nvkm_object_wr08(struct nvkm_object *, u64 addr, u8   data);
-int nvkm_object_wr16(struct nvkm_object *, u64 addr, u16  data);
 int nvkm_object_wr32(struct nvkm_object *, u64 addr, u32  data);
 int nvkm_object_bind(struct nvkm_object *, struct nvkm_gpuobj *, int align,
 		     struct nvkm_gpuobj **);
drivers/gpu/drm/nouveau/nvkm/core/ioctl.c +0 -10
index 584fc43c0d75..95e9537e1d7c 100644
@@ -206,14 +206,6 @@ nvkm_ioctl_rd(struct nvkm_client *client,
 		nvif_ioctl(object, "rd vers %d size %d addr %016llx\n",
 			   args->v0.version, args->v0.size, args->v0.addr);
 		switch (args->v0.size) {
-		case 1:
-			ret = nvkm_object_rd08(object, args->v0.addr, &v.b08);
-			args->v0.data = v.b08;
-			break;
-		case 2:
-			ret = nvkm_object_rd16(object, args->v0.addr, &v.b16);
-			args->v0.data = v.b16;
-			break;
 		case 4:
 			ret = nvkm_object_rd32(object, args->v0.addr, &v.b32);
 			args->v0.data = v.b32;
@@ -246,8 +238,6 @@ nvkm_ioctl_wr(struct nvkm_client *client,
 		return ret;
 
 	switch (args->v0.size) {
-	case 1: return nvkm_object_wr08(object, args->v0.addr, args->v0.data);
-	case 2: return nvkm_object_wr16(object, args->v0.addr, args->v0.data);
 	case 4: return nvkm_object_wr32(object, args->v0.addr, args->v0.data);
 	default:
 		break;
drivers/gpu/drm/nouveau/nvkm/core/object.c +0 -32
index 580b8c7f25af..913c3bae51f7 100644
@@ -132,22 +132,6 @@ nvkm_object_unmap(struct nvkm_object *object)
 	return -ENODEV;
 }
 
-int
-nvkm_object_rd08(struct nvkm_object *object, u64 addr, u8 *data)
-{
-	if (likely(object->func->rd08))
-		return object->func->rd08(object, addr, data);
-	return -ENODEV;
-}
-
-int
-nvkm_object_rd16(struct nvkm_object *object, u64 addr, u16 *data)
-{
-	if (likely(object->func->rd16))
-		return object->func->rd16(object, addr, data);
-	return -ENODEV;
-}
-
 int
 nvkm_object_rd32(struct nvkm_object *object, u64 addr, u32 *data)
 {
@@ -156,22 +140,6 @@ nvkm_object_rd32(struct nvkm_object *object, u64 addr, u32 *data)
 	return -ENODEV;
 }
 
-int
-nvkm_object_wr08(struct nvkm_object *object, u64 addr, u8 data)
-{
-	if (likely(object->func->wr08))
-		return object->func->wr08(object, addr, data);
-	return -ENODEV;
-}
-
-int
-nvkm_object_wr16(struct nvkm_object *object, u64 addr, u16 data)
-{
-	if (likely(object->func->wr16))
-		return object->func->wr16(object, addr, data);
-	return -ENODEV;
-}
-
 int
 nvkm_object_wr32(struct nvkm_object *object, u64 addr, u32 data)
 {
drivers/gpu/drm/nouveau/nvkm/core/oproxy.c +0 -28
index 3385528da650..afc10ec256a7 100644
@@ -55,36 +55,12 @@ nvkm_oproxy_unmap(struct nvkm_object *object)
 	return nvkm_object_unmap(oproxy->object);
 }
 
-static int
-nvkm_oproxy_rd08(struct nvkm_object *object, u64 addr, u8 *data)
-{
-	return nvkm_object_rd08(nvkm_oproxy(object)->object, addr, data);
-}
-
-static int
-nvkm_oproxy_rd16(struct nvkm_object *object, u64 addr, u16 *data)
-{
-	return nvkm_object_rd16(nvkm_oproxy(object)->object, addr, data);
-}
-
 static int
 nvkm_oproxy_rd32(struct nvkm_object *object, u64 addr, u32 *data)
 {
 	return nvkm_object_rd32(nvkm_oproxy(object)->object, addr, data);
 }
 
-static int
-nvkm_oproxy_wr08(struct nvkm_object *object, u64 addr, u8 data)
-{
-	return nvkm_object_wr08(nvkm_oproxy(object)->object, addr, data);
-}
-
-static int
-nvkm_oproxy_wr16(struct nvkm_object *object, u64 addr, u16 data)
-{
-	return nvkm_object_wr16(nvkm_oproxy(object)->object, addr, data);
-}
-
 static int
 nvkm_oproxy_wr32(struct nvkm_object *object, u64 addr, u32 data)
 {
@@ -197,11 +173,7 @@ nvkm_oproxy_func = {
 	.ntfy = nvkm_oproxy_ntfy,
 	.map = nvkm_oproxy_map,
 	.unmap = nvkm_oproxy_unmap,
-	.rd08 = nvkm_oproxy_rd08,
-	.rd16 = nvkm_oproxy_rd16,
 	.rd32 = nvkm_oproxy_rd32,
-	.wr08 = nvkm_oproxy_wr08,
-	.wr16 = nvkm_oproxy_wr16,
 	.wr32 = nvkm_oproxy_wr32,
 	.bind = nvkm_oproxy_bind,
 	.sclass = nvkm_oproxy_sclass,
drivers/gpu/drm/nouveau/nvkm/device/user.c +0 -54

66 lines not on this page · raw message

Signature · 1 line
2.41.0
author
#38 lore raw

PATCH 37/156 drm/nouveau/nvif: remove disp chan rd/wr

In reply to Ben Skeggs

- require display channel allocations to use map() instead

---
 drivers/gpu/drm/nouveau/dispnv50/disp.c       |  7 ++-
 drivers/gpu/drm/nouveau/include/nvif/ioctl.h  | 20 --------
 drivers/gpu/drm/nouveau/include/nvif/object.h | 17 ++-----
 .../drm/nouveau/include/nvkm/core/object.h    |  4 --
 drivers/gpu/drm/nouveau/nvif/object.c         | 37 --------------
 drivers/gpu/drm/nouveau/nvkm/core/ioctl.c     | 49 +------------------
 drivers/gpu/drm/nouveau/nvkm/core/object.c    | 16 ------
 drivers/gpu/drm/nouveau/nvkm/core/oproxy.c    | 14 ------
 .../gpu/drm/nouveau/nvkm/engine/disp/chan.c   | 24 ---------
 9 files changed, 10 insertions(+), 178 deletions(-)
drivers/gpu/drm/nouveau/dispnv50/disp.c +5 -2
index 31b46a62b501..4508c24720e2 100644
@@ -93,8 +93,11 @@ nv50_chan_create(struct nvif_device *device, struct nvif_object *disp,
 				ret = nvif_object_ctor(disp, "kmsChan", 0,
 						       oclass[0], data, size,
 						       &chan->user);
-				if (ret == 0)
-					nvif_object_map(&chan->user, NULL, 0);
+				if (ret == 0) {
+					ret = nvif_object_map(&chan->user, NULL, 0);
+					if (ret)
+						nvif_object_dtor(&chan->user);
+				}
 				nvif_object_sclass_put(&sclass);
 				return ret;
 			}
drivers/gpu/drm/nouveau/include/nvif/ioctl.h +0 -20
index 1e74245621e0..e825c8a1d9ca 100644
@@ -8,8 +8,6 @@ struct nvif_ioctl_v0 {
 #define NVIF_IOCTL_V0_NEW                                                  0x02
 #define NVIF_IOCTL_V0_DEL                                                  0x03
 #define NVIF_IOCTL_V0_MTHD                                                 0x04
-#define NVIF_IOCTL_V0_RD                                                   0x05
-#define NVIF_IOCTL_V0_WR                                                   0x06
 #define NVIF_IOCTL_V0_MAP                                                  0x07
 #define NVIF_IOCTL_V0_UNMAP                                                0x08
 	__u8  type;
@@ -60,24 +58,6 @@ struct nvif_ioctl_mthd_v0 {
 	__u8  data[];		/* method data (class.h) */
 };
 
-struct nvif_ioctl_rd_v0 {
-	/* nvif_ioctl ... */
-	__u8  version;
-	__u8  size;
-	__u8  pad02[2];
-	__u32 data;
-	__u64 addr;
-};
-
-struct nvif_ioctl_wr_v0 {
-	/* nvif_ioctl ... */
-	__u8  version;
-	__u8  size;
-	__u8  pad02[2];
-	__u32 data;
-	__u64 addr;
-};
-
 struct nvif_ioctl_map_v0 {
 	/* nvif_ioctl ... */
 	__u8  version;
drivers/gpu/drm/nouveau/include/nvif/object.h +3 -14
index 478cbb8f2dfe..8d205b6af46a 100644
@@ -34,8 +34,6 @@ void nvif_object_dtor(struct nvif_object *);
 int  nvif_object_ioctl(struct nvif_object *, void *, u32, void **);
 int  nvif_object_sclass_get(struct nvif_object *, struct nvif_sclass **);
 void nvif_object_sclass_put(struct nvif_sclass **);
-u32  nvif_object_rd(struct nvif_object *, int, u64);
-void nvif_object_wr(struct nvif_object *, int, u64, u32);
 int  nvif_object_mthd(struct nvif_object *, u32, void *, u32);
 int  nvif_object_map_handle(struct nvif_object *, void *, u32,
 			    u64 *handle, u64 *length);
@@ -47,20 +45,11 @@ void nvif_object_unmap(struct nvif_object *);
 #define nvif_object(a) (a)->object
 
 #define nvif_rd(a,f,b,c) ({                                                    \
-	struct nvif_object *_object = (a);                                     \
-	u32 _data;                                                             \
-	if (likely(_object->map.ptr))                                          \
-		_data = f((u8 __iomem *)_object->map.ptr + (c));               \
-	else                                                                   \
-		_data = nvif_object_rd(_object, (b), (c));                     \
+	u32 _data = f((u8 __iomem *)(a)->map.ptr + (c));                       \
 	_data;                                                                 \
 })
 #define nvif_wr(a,f,b,c,d) ({                                                  \
-	struct nvif_object *_object = (a);                                     \
-	if (likely(_object->map.ptr))                                          \
-		f((d), (u8 __iomem *)_object->map.ptr + (c));                  \
-	else                                                                   \
-		nvif_object_wr(_object, (b), (c), (d));                        \
+	f((d), (u8 __iomem *)(a)->map.ptr + (c));                              \
 })
 #define nvif_rd08(a,b) ({ ((u8)nvif_rd((a), ioread8, 1, (b))); })
 #define nvif_rd16(a,b) ({ ((u16)nvif_rd((a), ioread16_native, 2, (b))); })
@@ -69,7 +58,7 @@ void nvif_object_unmap(struct nvif_object *);
 #define nvif_wr16(a,b,c) nvif_wr((a), iowrite16_native, 2, (b), (u16)(c))
 #define nvif_wr32(a,b,c) nvif_wr((a), iowrite32_native, 4, (b), (u32)(c))
 #define nvif_mask(a,b,c,d) ({                                                  \
-	struct nvif_object *__object = (a);                                    \
+	typeof(a) __object = (a);                                              \
 	u32 _addr = (b), _data = nvif_rd32(__object, _addr);                   \
 	nvif_wr32(__object, _addr, (_data & ~(c)) | (d));                      \
 	_data;                                                                 \
drivers/gpu/drm/nouveau/include/nvkm/core/object.h +0 -4
index c91abac44bd6..10107ef3ca49 100644
@@ -33,8 +33,6 @@ struct nvkm_object_func {
 	int (*map)(struct nvkm_object *, void *argv, u32 argc,
 		   enum nvkm_object_map *, u64 *addr, u64 *size);
 	int (*unmap)(struct nvkm_object *);
-	int (*rd32)(struct nvkm_object *, u64 addr, u32 *data);
-	int (*wr32)(struct nvkm_object *, u64 addr, u32 data);
 	int (*bind)(struct nvkm_object *, struct nvkm_gpuobj *, int align,
 		    struct nvkm_gpuobj **);
 	int (*sclass)(struct nvkm_object *, int index, struct nvkm_oclass *);
@@ -57,8 +55,6 @@ int nvkm_object_ntfy(struct nvkm_object *, u32 mthd, struct nvkm_event **);
 int nvkm_object_map(struct nvkm_object *, void *argv, u32 argc,
 		    enum nvkm_object_map *, u64 *addr, u64 *size);
 int nvkm_object_unmap(struct nvkm_object *);
-int nvkm_object_rd32(struct nvkm_object *, u64 addr, u32 *data);
-int nvkm_object_wr32(struct nvkm_object *, u64 addr, u32  data);
 int nvkm_object_bind(struct nvkm_object *, struct nvkm_gpuobj *, int align,
 		     struct nvkm_gpuobj **);
 
drivers/gpu/drm/nouveau/nvif/object.c +0 -37
index 2b3e05197846..8a2a7bfec2f8 100644
@@ -97,43 +97,6 @@ nvif_object_sclass_get(struct nvif_object *object, struct nvif_sclass **psclass)
 	return ret;
 }
 
-u32
-nvif_object_rd(struct nvif_object *object, int size, u64 addr)
-{
-	struct {
-		struct nvif_ioctl_v0 ioctl;
-		struct nvif_ioctl_rd_v0 rd;
-	} args = {
-		.ioctl.type = NVIF_IOCTL_V0_RD,
-		.rd.size = size,
-		.rd.addr = addr,
-	};
-	int ret = nvif_object_ioctl(object, &args, sizeof(args), NULL);
-	if (ret) {
-		/*XXX: warn? */
-		return 0;
-	}
-	return args.rd.data;
-}
-
-void
-nvif_object_wr(struct nvif_object *object, int size, u64 addr, u32 data)
-{
-	struct {
-		struct nvif_ioctl_v0 ioctl;
-		struct nvif_ioctl_wr_v0 wr;
-	} args = {
-		.ioctl.type = NVIF_IOCTL_V0_WR,
-		.wr.size = size,
-		.wr.addr = addr,
-		.wr.data = data,
-	};
-	int ret = nvif_object_ioctl(object, &args, sizeof(args), NULL);
-	if (ret) {
-		/*XXX: warn? */
-	}
-}
-
 int
 nvif_object_mthd(struct nvif_object *object, u32 mthd, void *data, u32 size)
 {
drivers/gpu/drm/nouveau/nvkm/core/ioctl.c +2 -47

61 lines not on this page · raw message

drivers/gpu/drm/nouveau/nvkm/core/object.c +0 -16
index 913c3bae51f7..390c265cf8af 100644
@@ -132,22 +132,6 @@ nvkm_object_unmap(struct nvkm_object *object)
 	return -ENODEV;
 }
 
-int
-nvkm_object_rd32(struct nvkm_object *object, u64 addr, u32 *data)
-{
-	if (likely(object->func->rd32))
-		return object->func->rd32(object, addr, data);
-	return -ENODEV;
-}
-
-int
-nvkm_object_wr32(struct nvkm_object *object, u64 addr, u32 data)
-{
-	if (likely(object->func->wr32))
-		return object->func->wr32(object, addr, data);
-	return -ENODEV;
-}
-
 int
 nvkm_object_bind(struct nvkm_object *object, struct nvkm_gpuobj *gpuobj,
 		 int align, struct nvkm_gpuobj **pgpuobj)
drivers/gpu/drm/nouveau/nvkm/core/oproxy.c +0 -14
index afc10ec256a7..5db80d1780f0 100644
@@ -55,18 +55,6 @@ nvkm_oproxy_unmap(struct nvkm_object *object)
 	return nvkm_object_unmap(oproxy->object);
 }
 
-static int
-nvkm_oproxy_rd32(struct nvkm_object *object, u64 addr, u32 *data)
-{
-	return nvkm_object_rd32(nvkm_oproxy(object)->object, addr, data);
-}
-
-static int
-nvkm_oproxy_wr32(struct nvkm_object *object, u64 addr, u32 data)
-{
-	return nvkm_object_wr32(nvkm_oproxy(object)->object, addr, data);
-}
-
 static int
 nvkm_oproxy_bind(struct nvkm_object *object, struct nvkm_gpuobj *parent,
 		 int align, struct nvkm_gpuobj **pgpuobj)
@@ -173,8 +161,6 @@ nvkm_oproxy_func = {
 	.ntfy = nvkm_oproxy_ntfy,
 	.map = nvkm_oproxy_map,
 	.unmap = nvkm_oproxy_unmap,
-	.rd32 = nvkm_oproxy_rd32,
-	.wr32 = nvkm_oproxy_wr32,
 	.bind = nvkm_oproxy_bind,
 	.sclass = nvkm_oproxy_sclass,
 	.uevent = nvkm_oproxy_uevent,
drivers/gpu/drm/nouveau/nvkm/engine/disp/chan.c +0 -24
index d5e18daed79f..4e43ee383c34 100644
@@ -26,28 +26,6 @@
 
 #include <nvif/if0014.h>
 
-static int
-nvkm_disp_chan_rd32(struct nvkm_object *object, u64 addr, u32 *data)
-{
-	struct nvkm_disp_chan *chan = nvkm_disp_chan(object);
-	struct nvkm_device *device = chan->disp->engine.subdev.device;
-	u64 size, base = chan->func->user(chan, &size);
-
-	*data = nvkm_rd32(device, base + addr);
-	return 0;
-}
-
-static int
-nvkm_disp_chan_wr32(struct nvkm_object *object, u64 addr, u32 data)
-{
-	struct nvkm_disp_chan *chan = nvkm_disp_chan(object);
-	struct nvkm_device *device = chan->disp->engine.subdev.device;
-	u64 size, base = chan->func->user(chan, &size);
-
-	nvkm_wr32(device, base + addr, data);
-	return 0;
-}
-
 static int
 nvkm_disp_chan_ntfy(struct nvkm_object *object, u32 type, struct nvkm_event **pevent)
 {
@@ -188,8 +166,6 @@ nvkm_disp_chan = {
 	.dtor = nvkm_disp_chan_dtor,
 	.init = nvkm_disp_chan_init,
 	.fini = nvkm_disp_chan_fini,
-	.rd32 = nvkm_disp_chan_rd32,
-	.wr32 = nvkm_disp_chan_wr32,
 	.ntfy = nvkm_disp_chan_ntfy,
 	.map = nvkm_disp_chan_map,
 	.sclass = nvkm_disp_chan_child_get,
Signature · 1 line
2.41.0
author
#39 lore raw

PATCH 38/156 drm/nouveau/nvkm: rename struct nvkm_uevent

In reply to Ben Skeggs

- preparation for upcoming patches
- open-code current nvkm_uevent() macro
- alias remaining use of nvkm_uevent to nvif_event_priv, removed later

---
 drivers/gpu/drm/nouveau/include/nvkm/core/os.h |  2 ++
 drivers/gpu/drm/nouveau/nvkm/core/uevent.c     | 17 ++++++++---------
 2 files changed, 10 insertions(+), 9 deletions(-)
drivers/gpu/drm/nouveau/include/nvkm/core/os.h +2 -0
index 9b05612e6490..668338d7bda3 100644
@@ -30,4 +30,6 @@ nvkm_blob_dtor(struct nvkm_blob *blob)
 	(p = container_of((h), typeof(*p), m), nvkm_list_find_next(p, (h), m, (c)))
 #define nvkm_list_foreach(p,h,m,c)                                                           \
 	for (p = nvkm_list_find(p, (h), m, (c)); p; p = nvkm_list_find_next(p, (h), m, (c)))
+
+#define nvkm_uevent nvif_event_priv
 #endif
drivers/gpu/drm/nouveau/nvkm/core/uevent.c +8 -9
index cc254c390a57..900814c9a6bd 100644
@@ -19,13 +19,12 @@
  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
  */
-#define nvkm_uevent(p) container_of((p), struct nvkm_uevent, object)
 #include <core/event.h>
 #include <core/client.h>
 
 #include <nvif/if000e.h>
 
-struct nvkm_uevent {
+struct nvif_event_priv {
 	struct nvkm_object object;
 	struct nvkm_object *parent;
 	nvkm_uevent_func func;
@@ -60,7 +59,7 @@ nvkm_uevent_mthd_allow(struct nvkm_uevent *uevent, union nvif_event_allow_args *
 static int
 nvkm_uevent_mthd(struct nvkm_object *object, u32 mthd, void *argv, u32 argc)
 {
-	struct nvkm_uevent *uevent = nvkm_uevent(object);
+	struct nvif_event_priv *uevent = container_of(object, typeof(*uevent), object);
 
 	switch (mthd) {
 	case NVIF_EVENT_V0_ALLOW: return nvkm_uevent_mthd_allow(uevent, argv, argc);
@@ -75,7 +74,7 @@ nvkm_uevent_mthd(struct nvkm_object *object, u32 mthd, void *argv, u32 argc)
 static int
 nvkm_uevent_fini(struct nvkm_object *object, bool suspend)
 {
-	struct nvkm_uevent *uevent = nvkm_uevent(object);
+	struct nvif_event_priv *uevent = container_of(object, typeof(*uevent), object);
 
 	nvkm_event_ntfy_block(&uevent->ntfy);
 	return 0;
@@ -84,7 +83,7 @@ nvkm_uevent_fini(struct nvkm_object *object, bool suspend)
 static int
 nvkm_uevent_init(struct nvkm_object *object)
 {
-	struct nvkm_uevent *uevent = nvkm_uevent(object);
+	struct nvif_event_priv *uevent = container_of(object, typeof(*uevent), object);
 
 	if (atomic_read(&uevent->allowed))
 		nvkm_event_ntfy_allow(&uevent->ntfy);
@@ -95,7 +94,7 @@ nvkm_uevent_init(struct nvkm_object *object)
 static void *
 nvkm_uevent_dtor(struct nvkm_object *object)
 {
-	struct nvkm_uevent *uevent = nvkm_uevent(object);
+	struct nvif_event_priv *uevent = container_of(object, typeof(*uevent), object);
 
 	nvkm_event_ntfy_del(&uevent->ntfy);
 	return uevent;
@@ -112,7 +111,7 @@ nvkm_uevent = {
 static int
 nvkm_uevent_ntfy(struct nvkm_event_ntfy *ntfy, u32 bits)
 {
-	struct nvkm_uevent *uevent = container_of(ntfy, typeof(*uevent), ntfy);
+	struct nvif_event_priv *uevent = container_of(ntfy, typeof(*uevent), ntfy);
 	struct nvkm_client *client = uevent->object.client;
 
 	if (uevent->func)
@@ -122,7 +121,7 @@ nvkm_uevent_ntfy(struct nvkm_event_ntfy *ntfy, u32 bits)
 }
 
 int
-nvkm_uevent_add(struct nvkm_uevent *uevent, struct nvkm_event *event, int id, u32 bits,
+nvkm_uevent_add(struct nvif_event_priv *uevent, struct nvkm_event *event, int id, u32 bits,
 		nvkm_uevent_func func)
 {
 	if (WARN_ON(uevent->func))
@@ -138,7 +137,7 @@ nvkm_uevent_new(const struct nvkm_oclass *oclass, void *argv, u32 argc,
 		struct nvkm_object **pobject)
 {
 	struct nvkm_object *parent = oclass->parent;
-	struct nvkm_uevent *uevent;
+	struct nvif_event_priv *uevent;
 	union nvif_event_args *args = argv;
 
 	if (argc < sizeof(args->v0) || args->v0.version != 0)
Signature · 1 line
2.41.0
author
#40 lore raw

PATCH 39/156 drm/nouveau/nvkm: remove nvkm_client()

In reply to Ben Skeggs

- preparation for upcoming patches

---
 drivers/gpu/drm/nouveau/include/nvkm/core/client.h | 1 -
 drivers/gpu/drm/nouveau/nvkm/core/client.c         | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/nouveau/include/nvkm/core/client.h +0 -1
index 15f27fdd877a..4045b9f5ef4e 100644
@@ -1,7 +1,6 @@
 /* SPDX-License-Identifier: MIT */
 #ifndef __NVKM_CLIENT_H__
 #define __NVKM_CLIENT_H__
-#define nvkm_client(p) container_of((p), struct nvkm_client, object)
 #include <core/object.h>
 
 struct nvkm_client {
drivers/gpu/drm/nouveau/nvkm/core/client.c +1 -1
index f73d58eb6de6..b127676078b1 100644
@@ -93,7 +93,7 @@ nvkm_client_child_get(struct nvkm_object *object, int index,
 static void *
 nvkm_client_dtor(struct nvkm_object *object)
 {
-	return nvkm_client(object);
+	return container_of(object, struct nvkm_client, object);
 }
 
 static const struct nvkm_object_func
Signature · 1 line
2.41.0
author
#41 lore raw

PATCH 40/156 drm/nouveau/nvkm: rename struct nvkm_udevice

In reply to Ben Skeggs

- preparation for upcoming patches
- open-code current nvkm_udevice() macro
- alias remaining use of nvkm_udevice to nvif_device_priv, removed later

---
 drivers/gpu/drm/nouveau/nvkm/device/user.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)
drivers/gpu/drm/nouveau/nvkm/device/user.c +10 -9
index d7f75b3a43c8..af5aa9e1e5ea 100644
@@ -21,7 +21,6 @@
  *
  * Authors: Ben Skeggs
  */
-#define nvkm_udevice(p) container_of((p), struct nvkm_udevice, object)
 #include "priv.h"
 #include "ctrl.h"
 
@@ -34,7 +33,9 @@
 #include <nvif/cl0080.h>
 #include <nvif/unpack.h>
 
-struct nvkm_udevice {
+#define nvkm_udevice nvif_device_priv
+
+struct nvif_device_priv {
 	struct nvkm_object object;
 	struct nvkm_device *device;
 };
@@ -189,7 +190,7 @@ nvkm_udevice_time(struct nvkm_udevice *udev, void *data, u32 size)
 static int
 nvkm_udevice_mthd(struct nvkm_object *object, u32 mthd, void *data, u32 size)
 {
-	struct nvkm_udevice *udev = nvkm_udevice(object);
+	struct nvif_device_priv *udev = container_of(object, typeof(*udev), object);
 	nvif_ioctl(object, "device mthd %08x\n", mthd);
 	switch (mthd) {
 	case NV_DEVICE_V0_INFO:
@@ -206,7 +207,7 @@ static int
 nvkm_udevice_map(struct nvkm_object *object, void *argv, u32 argc,
 		 enum nvkm_object_map *type, u64 *addr, u64 *size)
 {
-	struct nvkm_udevice *udev = nvkm_udevice(object);
+	struct nvif_device_priv *udev = container_of(object, typeof(*udev), object);
 	struct nvkm_device *device = udev->device;
 	*type = NVKM_OBJECT_MAP_IO;
 	*addr = device->func->resource_addr(device, 0);
@@ -217,7 +218,7 @@ nvkm_udevice_map(struct nvkm_object *object, void *argv, u32 argc,
 static int
 nvkm_udevice_fini(struct nvkm_object *object, bool suspend)
 {
-	struct nvkm_udevice *udev = nvkm_udevice(object);
+	struct nvif_device_priv *udev = container_of(object, typeof(*udev), object);
 	struct nvkm_device *device = udev->device;
 	int ret = 0;
 
@@ -238,7 +239,7 @@ nvkm_udevice_fini(struct nvkm_object *object, bool suspend)
 static int
 nvkm_udevice_init(struct nvkm_object *object)
 {
-	struct nvkm_udevice *udev = nvkm_udevice(object);
+	struct nvif_device_priv *udev = container_of(object, typeof(*udev), object);
 	struct nvkm_device *device = udev->device;
 	int ret = 0;
 
@@ -260,7 +261,7 @@ static int
 nvkm_udevice_child_new(const struct nvkm_oclass *oclass,
 		       void *data, u32 size, struct nvkm_object **pobject)
 {
-	struct nvkm_udevice *udev = nvkm_udevice(oclass->parent);
+	struct nvif_device_priv *udev = container_of(oclass->parent, typeof(*udev), object);
 	const struct nvkm_device_oclass *sclass = oclass->priv;
 	return sclass->ctor(udev->device, oclass, data, size, pobject);
 }
@@ -269,7 +270,7 @@ static int
 nvkm_udevice_child_get(struct nvkm_object *object, int index,
 		       struct nvkm_oclass *oclass)
 {
-	struct nvkm_udevice *udev = nvkm_udevice(object);
+	struct nvif_device_priv *udev = container_of(object, typeof(*udev), object);
 	struct nvkm_device *device = udev->device;
 	struct nvkm_engine *engine;
 	u64 mask = (1ULL << NVKM_ENGINE_DMAOBJ) |
@@ -322,7 +323,7 @@ nvkm_udevice_new(const struct nvkm_oclass *oclass, void *data, u32 size,
 		 struct nvkm_object **pobject)
 {
 	struct nvkm_client *client = oclass->client;
-	struct nvkm_udevice *udev;
+	struct nvif_device_priv *udev;
 
 	if (!(udev = kzalloc(sizeof(*udev), GFP_KERNEL)))
 		return -ENOMEM;
Signature · 1 line
2.41.0
author
#42 lore raw

PATCH 41/156 drm/nouveau/nvkm: rename struct nvkm_control

In reply to Ben Skeggs

- preparation for upcoming patches
- open-code current nvkm_control() macro
- alias remaining use of nvkm_control to nvif_control_priv, removed later

---
 drivers/gpu/drm/nouveau/nvkm/device/ctrl.c | 11 +++++++++--
 drivers/gpu/drm/nouveau/nvkm/device/ctrl.h |  7 -------
 2 files changed, 9 insertions(+), 9 deletions(-)
drivers/gpu/drm/nouveau/nvkm/device/ctrl.c +9 -2
index ce774579c89d..a74fb78ca7ab 100644
@@ -31,6 +31,13 @@
 #include <nvif/ioctl.h>
 #include <nvif/unpack.h>
 
+#define nvkm_control nvif_control_priv
+
+struct nvif_control_priv {
+	struct nvkm_object object;
+	struct nvkm_device *device;
+};
+
 static int
 nvkm_control_mthd_pstate_info(struct nvkm_control *ctrl, void *data, u32 size)
 {
@@ -169,7 +176,7 @@ nvkm_control_mthd_pstate_user(struct nvkm_control *ctrl, void *data, u32 size)
 static int
 nvkm_control_mthd(struct nvkm_object *object, u32 mthd, void *data, u32 size)
 {
-	struct nvkm_control *ctrl = nvkm_control(object);
+	struct nvif_control_priv *ctrl = container_of(object, typeof(*ctrl), object);
 	switch (mthd) {
 	case NVIF_CONTROL_PSTATE_INFO:
 		return nvkm_control_mthd_pstate_info(ctrl, data, size);
@@ -192,7 +199,7 @@ static int
 nvkm_control_new(struct nvkm_device *device, const struct nvkm_oclass *oclass,
 		 void *data, u32 size, struct nvkm_object **pobject)
 {
-	struct nvkm_control *ctrl;
+	struct nvif_control_priv *ctrl;
 
 	if (!(ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL)))
 		return -ENOMEM;
drivers/gpu/drm/nouveau/nvkm/device/ctrl.h +0 -7
index 9f6d7f23af8d..d241329a1e7a 100644
@@ -1,13 +1,6 @@
 /* SPDX-License-Identifier: MIT */
 #ifndef __NVKM_DEVICE_CTRL_H__
 #define __NVKM_DEVICE_CTRL_H__
-#define nvkm_control(p) container_of((p), struct nvkm_control, object)
-#include <core/object.h>
-
-struct nvkm_control {
-	struct nvkm_object object;
-	struct nvkm_device *device;
-};
 
 extern const struct nvkm_device_oclass nvkm_control_oclass;
 #endif
Signature · 1 line
2.41.0
author
#43 lore raw

PATCH 42/156 drm/nouveau/nvkm: rename struct nvkm_uvfn

In reply to Ben Skeggs

- preparation for upcoming patches
- open-code current nvkm_uvfn() macro

---
 drivers/gpu/drm/nouveau/nvkm/subdev/vfn/uvfn.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/gpu/drm/nouveau/nvkm/subdev/vfn/uvfn.c +3 -4
index c5460a14c541..fe35024d69ba 100644
@@ -19,12 +19,11 @@
  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
  */
-#define nvkm_uvfn(p) container_of((p), struct nvkm_uvfn, object)
 #include "priv.h"
 
 #include <core/object.h>
 
-struct nvkm_uvfn {
+struct nvif_usermode_priv {
 	struct nvkm_object object;
 	struct nvkm_vfn *vfn;
 };
@@ -33,7 +32,7 @@ static int
 nvkm_uvfn_map(struct nvkm_object *object, void *argv, u32 argc,
 	      enum nvkm_object_map *type, u64 *addr, u64 *size)
 {
-	struct nvkm_vfn *vfn = nvkm_uvfn(object)->vfn;
+	struct nvkm_vfn *vfn = container_of(object, struct nvif_usermode_priv, object)->vfn;
 	struct nvkm_device *device = vfn->subdev.device;
 
 	*addr = device->func->resource_addr(device, 0) + vfn->addr.user;
@@ -51,7 +50,7 @@ int
 nvkm_uvfn_new(struct nvkm_device *device, const struct nvkm_oclass *oclass,
 	      void *argv, u32 argc, struct nvkm_object **pobject)
 {
-	struct nvkm_uvfn *uvfn;
+	struct nvif_usermode_priv *uvfn;
 
 	if (argc != 0)
 		return -ENOSYS;
Signature · 1 line
2.41.0
author
#44 lore raw

PATCH 43/156 drm/nouveau/nvkm: rename struct nvkm_ummu

In reply to Ben Skeggs

- preparation for upcoming patches
- open-code current nvkm_ummu() macro
- alias remaining use of nvkm_ummu to nvif_mmu_priv, removed later

---
 drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.c | 2 +-
 drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c | 6 +++---
 drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.h | 5 +++--
 drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c | 2 +-
 4 files changed, 8 insertions(+), 7 deletions(-)
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.c +1 -1
index e530bb8b3b17..62d69bb7fe90 100644
@@ -142,7 +142,7 @@ int
 nvkm_umem_new(const struct nvkm_oclass *oclass, void *argv, u32 argc,
 	      struct nvkm_object **pobject)
 {
-	struct nvkm_mmu *mmu = nvkm_ummu(oclass->parent)->mmu;
+	struct nvkm_mmu *mmu = container_of(oclass->parent, struct nvif_mmu_priv, object)->mmu;
 	union {
 		struct nvif_mem_v0 v0;
 	} *args = argv;
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c +3 -3
index 6870fda4b188..3f008402f451 100644
@@ -32,7 +32,7 @@ static int
 nvkm_ummu_sclass(struct nvkm_object *object, int index,
 		 struct nvkm_oclass *oclass)
 {
-	struct nvkm_mmu *mmu = nvkm_ummu(object)->mmu;
+	struct nvkm_mmu *mmu = container_of(object, struct nvif_mmu_priv, object)->mmu;
 
 	if (mmu->func->mem.user.oclass) {
 		if (index-- == 0) {
@@ -132,7 +132,7 @@ nvkm_ummu_kind(struct nvkm_ummu *ummu, void *argv, u32 argc)
 static int
 nvkm_ummu_mthd(struct nvkm_object *object, u32 mthd, void *argv, u32 argc)
 {
-	struct nvkm_ummu *ummu = nvkm_ummu(object);
+	struct nvif_mmu_priv *ummu = container_of(object, typeof(*ummu), object);
 	switch (mthd) {
 	case NVIF_MMU_V0_HEAP: return nvkm_ummu_heap(ummu, argv, argc);
 	case NVIF_MMU_V0_TYPE: return nvkm_ummu_type(ummu, argv, argc);
@@ -157,7 +157,7 @@ nvkm_ummu_new(struct nvkm_device *device, const struct nvkm_oclass *oclass,
 		struct nvif_mmu_v0 v0;
 	} *args = argv;
 	struct nvkm_mmu *mmu = device->mmu;
-	struct nvkm_ummu *ummu;
+	struct nvif_mmu_priv *ummu;
 	int ret = -ENOSYS, kinds = 0;
 	u8 unused = 0;
 
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.h +3 -2
index 0cd510dcfc68..35ae48758017 100644
@@ -1,10 +1,11 @@
 #ifndef __NVKM_UMMU_H__
 #define __NVKM_UMMU_H__
-#define nvkm_ummu(p) container_of((p), struct nvkm_ummu, object)
 #include <core/object.h>
 #include "priv.h"
 
-struct nvkm_ummu {
+#define nvkm_ummu nvif_mmu_priv
+
+struct nvif_mmu_priv {
 	struct nvkm_object object;
 	struct nvkm_mmu *mmu;
 };
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c +1 -1
index cf490ff2b9f1..bd51cdb1c578 100644
@@ -532,7 +532,7 @@ int
 nvkm_uvmm_new(const struct nvkm_oclass *oclass, void *argv, u32 argc,
 	      struct nvkm_object **pobject)
 {
-	struct nvkm_mmu *mmu = nvkm_ummu(oclass->parent)->mmu;
+	struct nvkm_mmu *mmu = container_of(oclass->parent, struct nvif_mmu_priv, object)->mmu;
 	const bool more = oclass->base.maxver >= 0;
 	union {
 		struct nvif_vmm_v0 v0;
Signature · 1 line
2.41.0
author
#45 lore raw

PATCH 44/156 drm/nouveau/nvkm: rename struct nvkm_umem

In reply to Ben Skeggs

- preparation for upcoming patches
- open-code current nvkm_umem() macro

---
 .../gpu/drm/nouveau/nvkm/subdev/mmu/umem.c    | 29 +++++++++++++++----
 .../gpu/drm/nouveau/nvkm/subdev/mmu/umem.h    | 18 ------------
 2 files changed, 23 insertions(+), 24 deletions(-)
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.c +23 -6
index 62d69bb7fe90..45ab7e445d58 100644
@@ -30,6 +30,22 @@
 #include <nvif/if000a.h>
 #include <nvif/unpack.h>
 
+struct nvif_mem_priv {
+	struct nvkm_object object;
+	struct nvkm_mmu *mmu;
+	u8 type:8;
+	bool mappable:1;
+	bool io:1;
+
+	struct nvkm_memory *memory;
+	struct list_head head;
+
+	union {
+		struct nvkm_vma *bar;
+		void *map;
+	};
+};
+
 static const struct nvkm_object_func nvkm_umem;
 struct nvkm_memory *
 nvkm_umem_search(struct nvkm_client *client, u64 handle)
@@ -37,7 +53,7 @@ nvkm_umem_search(struct nvkm_client *client, u64 handle)
 	struct nvkm_client *master = client->object.client;
 	struct nvkm_memory *memory = NULL;
 	struct nvkm_object *object;
-	struct nvkm_umem *umem;
+	struct nvif_mem_priv *umem;
 
 	object = nvkm_object_search(client, handle, &nvkm_umem);
 	if (IS_ERR(object)) {
@@ -52,7 +68,7 @@ nvkm_umem_search(struct nvkm_client *client, u64 handle)
 			spin_unlock(&master->lock);
 		}
 	} else {
-		umem = nvkm_umem(object);
+		umem = container_of(object, typeof(*umem), object);
 		memory = nvkm_memory_ref(umem->memory);
 	}
 
@@ -62,7 +78,7 @@ nvkm_umem_search(struct nvkm_client *client, u64 handle)
 static int
 nvkm_umem_unmap(struct nvkm_object *object)
 {
-	struct nvkm_umem *umem = nvkm_umem(object);
+	struct nvif_mem_priv *umem = container_of(object, typeof(*umem), object);
 
 	if (!umem->map)
 		return -EEXIST;
@@ -86,7 +102,7 @@ static int
 nvkm_umem_map(struct nvkm_object *object, void *argv, u32 argc,
 	      enum nvkm_object_map *type, u64 *handle, u64 *length)
 {
-	struct nvkm_umem *umem = nvkm_umem(object);
+	struct nvif_mem_priv *umem = container_of(object, typeof(*umem), object);
 	struct nvkm_mmu *mmu = umem->mmu;
 
 	if (!umem->mappable)
@@ -123,7 +139,8 @@ nvkm_umem_map(struct nvkm_object *object, void *argv, u32 argc,
 static void *
 nvkm_umem_dtor(struct nvkm_object *object)
 {
-	struct nvkm_umem *umem = nvkm_umem(object);
+	struct nvif_mem_priv *umem = container_of(object, typeof(*umem), object);
+
 	spin_lock(&umem->object.client->lock);
 	list_del_init(&umem->head);
 	spin_unlock(&umem->object.client->lock);
@@ -146,7 +163,7 @@ nvkm_umem_new(const struct nvkm_oclass *oclass, void *argv, u32 argc,
 	union {
 		struct nvif_mem_v0 v0;
 	} *args = argv;
-	struct nvkm_umem *umem;
+	struct nvif_mem_priv *umem;
 	int type, ret = -ENOSYS;
 	u8  page;
 	u64 size;
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.h +0 -18
index d56a594016cc..d2012ab625d3 100644
@@ -1,25 +1,7 @@
 #ifndef __NVKM_UMEM_H__
 #define __NVKM_UMEM_H__
-#define nvkm_umem(p) container_of((p), struct nvkm_umem, object)
-#include <core/object.h>
 #include "mem.h"
 
-struct nvkm_umem {
-	struct nvkm_object object;
-	struct nvkm_mmu *mmu;
-	u8 type:8;
-	bool mappable:1;
-	bool io:1;
-
-	struct nvkm_memory *memory;
-	struct list_head head;
-
-	union {
-		struct nvkm_vma *bar;
-		void *map;
-	};
-};
-
 int nvkm_umem_new(const struct nvkm_oclass *, void *argv, u32 argc,
 		  struct nvkm_object **);
 #endif
Signature · 1 line
2.41.0
author
#46 lore raw

PATCH 45/156 drm/nouveau/nvkm: rename struct nvkm_uvmm

In reply to Ben Skeggs

- preparation for upcoming patches
- open-code current nvkm_uvmm() macro
- alias remaining use of nvkm_uvmm to nvif_vmm_priv, removed later

---
 drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c | 18 +++++++++++++-----
 drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.h |  7 -------
 2 files changed, 13 insertions(+), 12 deletions(-)
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c +13 -5
index bd51cdb1c578..6f261f81a2ad 100644
@@ -29,6 +29,13 @@
 #include <nvif/if000c.h>
 #include <nvif/unpack.h>
 
+#define nvkm_uvmm nvif_vmm_priv
+
+struct nvif_vmm_priv {
+	struct nvkm_object object;
+	struct nvkm_vmm *vmm;
+};
+
 static const struct nvkm_object_func nvkm_uvmm;
 struct nvkm_vmm *
 nvkm_uvmm_search(struct nvkm_client *client, u64 handle)
@@ -39,7 +46,7 @@ nvkm_uvmm_search(struct nvkm_client *client, u64 handle)
 	if (IS_ERR(object))
 		return (void *)object;
 
-	return nvkm_vmm_ref(nvkm_uvmm(object)->vmm);
+	return nvkm_vmm_ref(container_of(object, struct nvif_vmm_priv, object)->vmm);
 }
 
 static int
@@ -327,7 +334,7 @@ nvkm_uvmm_mthd_page(struct nvkm_uvmm *uvmm, void *argv, u32 argc)
 }
 
 static inline int
-nvkm_uvmm_page_index(struct nvkm_uvmm *uvmm, u64 size, u8 shift, u8 *refd)
+nvkm_uvmm_page_index(struct nvif_vmm_priv *uvmm, u64 size, u8 shift, u8 *refd)
 {
 	struct nvkm_vmm *vmm = uvmm->vmm;
 	const struct nvkm_vmm_page *page;
@@ -491,7 +498,7 @@ nvkm_uvmm_mthd_raw(struct nvkm_uvmm *uvmm, void *argv, u32 argc)
 static int
 nvkm_uvmm_mthd(struct nvkm_object *object, u32 mthd, void *argv, u32 argc)
 {
-	struct nvkm_uvmm *uvmm = nvkm_uvmm(object);
+	struct nvif_vmm_priv *uvmm = container_of(object, typeof(*uvmm), object);
 	switch (mthd) {
 	case NVIF_VMM_V0_PAGE  : return nvkm_uvmm_mthd_page  (uvmm, argv, argc);
 	case NVIF_VMM_V0_GET   : return nvkm_uvmm_mthd_get   (uvmm, argv, argc);
@@ -517,7 +524,8 @@ nvkm_uvmm_mthd(struct nvkm_object *object, u32 mthd, void *argv, u32 argc)
 static void *
 nvkm_uvmm_dtor(struct nvkm_object *object)
 {
-	struct nvkm_uvmm *uvmm = nvkm_uvmm(object);
+	struct nvif_vmm_priv *uvmm = container_of(object, typeof(*uvmm), object);
+
 	nvkm_vmm_unref(&uvmm->vmm);
 	return uvmm;
 }
@@ -538,7 +546,7 @@ nvkm_uvmm_new(const struct nvkm_oclass *oclass, void *argv, u32 argc,
 		struct nvif_vmm_v0 v0;
 	} *args = argv;
 	const struct nvkm_vmm_page *page;
-	struct nvkm_uvmm *uvmm;
+	struct nvif_vmm_priv *uvmm;
 	int ret = -ENOSYS;
 	u64 addr, size;
 	bool managed, raw;
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.h +0 -7
index 71dab55e18a9..cf0172a320c3 100644
@@ -1,14 +1,7 @@
 #ifndef __NVKM_UVMM_H__
 #define __NVKM_UVMM_H__
-#define nvkm_uvmm(p) container_of((p), struct nvkm_uvmm, object)
-#include <core/object.h>
 #include "vmm.h"
 
-struct nvkm_uvmm {
-	struct nvkm_object object;
-	struct nvkm_vmm *vmm;
-};
-
 int nvkm_uvmm_new(const struct nvkm_oclass *, void *argv, u32 argc,
 		  struct nvkm_object **);
 #endif
Signature · 1 line
2.41.0
author
#47 lore raw

PATCH 46/156 drm/nouveau/nvkm: detach user handling from nvkm_fault_buffer

In reply to Ben Skeggs

- preparation for upcoming patches
- open-code current nvkm_fault_buffer() macro

---
 .../gpu/drm/nouveau/nvkm/subdev/fault/priv.h  |  2 --
 .../gpu/drm/nouveau/nvkm/subdev/fault/user.c  | 30 ++++++++++++++-----
 2 files changed, 23 insertions(+), 9 deletions(-)
drivers/gpu/drm/nouveau/nvkm/subdev/fault/priv.h +0 -2
index a5510332c402..3c26e76d1d3c 100644
@@ -1,6 +1,5 @@
 #ifndef __NVKM_FAULT_PRIV_H__
 #define __NVKM_FAULT_PRIV_H__
-#define nvkm_fault_buffer(p) container_of((p), struct nvkm_fault_buffer, object)
 #define nvkm_fault(p) container_of((p), struct nvkm_fault, subdev)
 #include <subdev/fault.h>
 
@@ -8,7 +7,6 @@
 #include <core/object.h>
 
 struct nvkm_fault_buffer {
-	struct nvkm_object object;
 	struct nvkm_fault *fault;
 	int id;
 	int entries;
drivers/gpu/drm/nouveau/nvkm/subdev/fault/user.c +23 -7
index c123e5893d76..6c3ede8b0321 100644
@@ -28,10 +28,15 @@
 #include <nvif/clb069.h>
 #include <nvif/unpack.h>
 
+struct nvif_faultbuf_priv {
+	struct nvkm_object object;
+	struct nvkm_fault_buffer *buffer;
+};
+
 static int
 nvkm_ufault_uevent(struct nvkm_object *object, void *argv, u32 argc, struct nvkm_uevent *uevent)
 {
-	struct nvkm_fault_buffer *buffer = nvkm_fault_buffer(object);
+	struct nvkm_fault_buffer *buffer = container_of(object, struct nvif_faultbuf_priv, object)->buffer;
 	union nvif_clb069_event_args *args = argv;
 
 	if (!uevent)
@@ -47,7 +52,7 @@ static int
 nvkm_ufault_map(struct nvkm_object *object, void *argv, u32 argc,
 		enum nvkm_object_map *type, u64 *addr, u64 *size)
 {
-	struct nvkm_fault_buffer *buffer = nvkm_fault_buffer(object);
+	struct nvkm_fault_buffer *buffer = container_of(object, struct nvif_faultbuf_priv, object)->buffer;
 	struct nvkm_device *device = buffer->fault->subdev.device;
 	*type = NVKM_OBJECT_MAP_IO;
 	*addr = device->func->resource_addr(device, 3) + buffer->addr;
@@ -58,7 +63,9 @@ nvkm_ufault_map(struct nvkm_object *object, void *argv, u32 argc,
 static int
 nvkm_ufault_fini(struct nvkm_object *object, bool suspend)
 {
-	struct nvkm_fault_buffer *buffer = nvkm_fault_buffer(object);
+	struct nvif_faultbuf_priv *ufault = container_of(object, typeof(*ufault), object);
+	struct nvkm_fault_buffer *buffer = ufault->buffer;
+
 	buffer->fault->func->buffer.fini(buffer);
 	return 0;
 }
@@ -66,7 +73,9 @@ nvkm_ufault_fini(struct nvkm_object *object, bool suspend)
 static int
 nvkm_ufault_init(struct nvkm_object *object)
 {
-	struct nvkm_fault_buffer *buffer = nvkm_fault_buffer(object);
+	struct nvif_faultbuf_priv *ufault = container_of(object, typeof(*ufault), object);
+	struct nvkm_fault_buffer *buffer = ufault->buffer;
+
 	buffer->fault->func->buffer.init(buffer);
 	return 0;
 }
@@ -74,7 +83,7 @@ nvkm_ufault_init(struct nvkm_object *object)
 static void *
 nvkm_ufault_dtor(struct nvkm_object *object)
 {
-	return NULL;
+	return container_of(object, struct nvif_faultbuf_priv, object);
 }
 
 static const struct nvkm_object_func
@@ -94,6 +103,7 @@ nvkm_ufault_new(struct nvkm_device *device, const struct nvkm_oclass *oclass,
 		struct nvif_clb069_v0 v0;
 	} *args = argv;
 	struct nvkm_fault *fault = device->fault;
+	struct nvif_faultbuf_priv *ufault;
 	struct nvkm_fault_buffer *buffer = fault->buffer[fault->func->user.rp];
 	int ret = -ENOSYS;
 
@@ -104,7 +114,13 @@ nvkm_ufault_new(struct nvkm_device *device, const struct nvkm_oclass *oclass,
 	} else
 		return ret;
 
-	nvkm_object_ctor(&nvkm_ufault, oclass, &buffer->object);
-	*pobject = &buffer->object;
+	ufault = kzalloc(sizeof(*ufault), GFP_KERNEL);
+	if (!ufault)
+		return -ENOMEM;
+
+	nvkm_object_ctor(&nvkm_ufault, oclass, &ufault->object);
+	ufault->buffer = fault->buffer[fault->func->user.rp];
+
+	*pobject = &ufault->object;
 	return 0;
 }
Signature · 1 line
2.41.0
author
#48 lore raw

PATCH 47/156 drm/nouveau/nvkm: detach user handling from nvkm_disp

In reply to Ben Skeggs

- preparation for upcoming patches
- open-code current nvkm_udisp() macro

---
 .../drm/nouveau/include/nvkm/engine/disp.h    |  4 +-
 .../gpu/drm/nouveau/nvkm/engine/disp/base.c   |  2 +-
 .../gpu/drm/nouveau/nvkm/engine/disp/chan.c   | 17 +++++----
 .../gpu/drm/nouveau/nvkm/engine/disp/gv100.c  |  3 +-
 .../gpu/drm/nouveau/nvkm/engine/disp/priv.h   |  1 -
 .../gpu/drm/nouveau/nvkm/engine/disp/uconn.c  | 11 +++---
 .../gpu/drm/nouveau/nvkm/engine/disp/udisp.c  | 37 ++++++++++++-------
 .../gpu/drm/nouveau/nvkm/engine/disp/udisp.h  | 11 ++++++
 .../gpu/drm/nouveau/nvkm/engine/disp/uhead.c  | 11 +++---
 .../gpu/drm/nouveau/nvkm/engine/disp/uoutp.c  | 11 +++---
 10 files changed, 66 insertions(+), 42 deletions(-)
 create mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.h
drivers/gpu/drm/nouveau/include/nvkm/engine/disp.h +2 -2
index 3e8db8280e2a..e954c36630f0 100644
@@ -65,8 +65,8 @@ struct nvkm_disp {
 
 	struct {
 		spinlock_t lock;
-		struct nvkm_object object;
-	} client;
+		bool allocated;
+	} user;
 };
 
 int nv04_disp_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_disp **);
drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c +1 -1
index b24eb1e560bc..e93646d53378 100644
@@ -240,7 +240,7 @@ nvkm_disp_new_(const struct nvkm_disp_func *func, struct nvkm_device *device,
 	INIT_LIST_HEAD(&disp->iors);
 	INIT_LIST_HEAD(&disp->outps);
 	INIT_LIST_HEAD(&disp->conns);
-	spin_lock_init(&disp->client.lock);
+	spin_lock_init(&disp->user.lock);
 
 	ret = nvkm_engine_ctor(&nvkm_disp, device, type, inst, true, &disp->engine);
 	if (ret) {
drivers/gpu/drm/nouveau/nvkm/engine/disp/chan.c +9 -8
index 4e43ee383c34..25fe9946957f 100644
@@ -152,10 +152,10 @@ nvkm_disp_chan_dtor(struct nvkm_object *object)
 	struct nvkm_disp_chan *chan = nvkm_disp_chan(object);
 	struct nvkm_disp *disp = chan->disp;
 
-	spin_lock(&disp->client.lock);
+	spin_lock(&disp->user.lock);
 	if (disp->chan[chan->chid.user] == chan)
 		disp->chan[chan->chid.user] = NULL;
-	spin_unlock(&disp->client.lock);
+	spin_unlock(&disp->user.lock);
 
 	nvkm_memory_unref(&chan->memory);
 	return chan;
@@ -213,21 +213,22 @@ nvkm_disp_chan_new_(struct nvkm_disp *disp, int nr, const struct nvkm_oclass *oc
 			return ret;
 	}
 
-	spin_lock(&disp->client.lock);
+	spin_lock(&disp->user.lock);
 	if (disp->chan[chan->chid.user]) {
-		spin_unlock(&disp->client.lock);
+		spin_unlock(&disp->user.lock);
 		return -EBUSY;
 	}
 	disp->chan[chan->chid.user] = chan;
-	spin_unlock(&disp->client.lock);
+	spin_unlock(&disp->user.lock);
 	return 0;
 }
 
+#include "udisp.h"
 int
 nvkm_disp_wndw_new(const struct nvkm_oclass *oclass, void *argv, u32 argc,
 		   struct nvkm_object **pobject)
 {
-	struct nvkm_disp *disp = nvkm_udisp(oclass->parent);
+	struct nvkm_disp *disp = container_of(oclass->parent, struct nvif_disp_priv, object)->disp;
 
 	return nvkm_disp_chan_new_(disp, disp->wndw.nr, oclass, argv, argc, pobject);
 }
@@ -236,7 +237,7 @@ int
 nvkm_disp_chan_new(const struct nvkm_oclass *oclass, void *argv, u32 argc,
 		   struct nvkm_object **pobject)
 {
-	struct nvkm_disp *disp = nvkm_udisp(oclass->parent);
+	struct nvkm_disp *disp = container_of(oclass->parent, struct nvif_disp_priv, object)->disp;
 
 	return nvkm_disp_chan_new_(disp, disp->head.nr, oclass, argv, argc, pobject);
 }
@@ -245,7 +246,7 @@ int
 nvkm_disp_core_new(const struct nvkm_oclass *oclass, void *argv, u32 argc,
 		   struct nvkm_object **pobject)
 {
-	struct nvkm_disp *disp = nvkm_udisp(oclass->parent);
+	struct nvkm_disp *disp = container_of(oclass->parent, struct nvif_disp_priv, object)->disp;
 
 	return nvkm_disp_chan_new_(disp, 1, oclass, argv, argc, pobject);
 }
drivers/gpu/drm/nouveau/nvkm/engine/disp/gv100.c +2 -1
index cfa3698d3a2f..5787fd26e5c7 100644
@@ -815,11 +815,12 @@ gv100_disp_caps = {
 	.map = gv100_disp_caps_map,
 };
 
+#include "udisp.h"
 int
 gv100_disp_caps_new(const struct nvkm_oclass *oclass, void *argv, u32 argc,
 		    struct nvkm_object **pobject)
 {
-	struct nvkm_disp *disp = nvkm_udisp(oclass->parent);
+	struct nvkm_disp *disp = container_of(oclass->parent, struct nvif_disp_priv, object)->disp;
 	struct gv100_disp_caps *caps;
 
 	if (!(caps = kzalloc(sizeof(*caps), GFP_KERNEL)))
drivers/gpu/drm/nouveau/nvkm/engine/disp/priv.h +0 -1
index a3fd7cb7c488..6f0b119dfd90 100644
@@ -1,7 +1,6 @@
 /* SPDX-License-Identifier: MIT */
 #ifndef __NVKM_DISP_PRIV_H__
 #define __NVKM_DISP_PRIV_H__
-#define nvkm_udisp(p) container_of((p), struct nvkm_disp, client.object)
 #include <engine/disp.h>
 #include <core/enum.h>
 struct nvkm_head;
drivers/gpu/drm/nouveau/nvkm/engine/disp/uconn.c +6 -5
index 2dab6612c4fc..5e44ec977d42 100644
@@ -154,9 +154,9 @@ nvkm_uconn_dtor(struct nvkm_object *object)
 	struct nvkm_conn *conn = nvkm_uconn(object);
 	struct nvkm_disp *disp = conn->disp;
 
-	spin_lock(&disp->client.lock);
+	spin_lock(&disp->user.lock);
 	conn->object.func = NULL;
-	spin_unlock(&disp->client.lock);
+	spin_unlock(&disp->user.lock);
 	return NULL;
 }
 
@@ -166,10 +166,11 @@ nvkm_uconn = {
 	.uevent = nvkm_uconn_uevent,
 };
 
+#include "udisp.h"
 int
 nvkm_uconn_new(const struct nvkm_oclass *oclass, void *argv, u32 argc, struct nvkm_object **pobject)
 {
-	struct nvkm_disp *disp = nvkm_udisp(oclass->parent);
+	struct nvkm_disp *disp = container_of(oclass->parent, struct nvif_disp_priv, object)->disp;
 	struct nvkm_conn *cont, *conn = NULL;
 	union nvif_conn_args *args = argv;
 	int ret;
@@ -188,7 +189,7 @@ nvkm_uconn_new(const struct nvkm_oclass *oclass, void *argv, u32 argc, struct nv
 		return -EINVAL;
 
 	ret = -EBUSY;
-	spin_lock(&disp->client.lock);
+	spin_lock(&disp->user.lock);
 	if (!conn->object.func) {
 		switch (conn->info.type) {
 		case DCB_CONNECTOR_VGA      : args->v0.type = NVIF_CONN_V0_VGA; break;
@@ -220,6 +221,6 @@ nvkm_uconn_new(const struct nvkm_oclass *oclass, void *argv, u32 argc, struct nv
 		*pobject = &conn->object;
 		ret = 0;
 	}
-	spin_unlock(&disp->client.lock);
+	spin_unlock(&disp->user.lock);
 	return ret;
 }
drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c +23 -14
index 0268d1d75805..272d6a040a51 100644
@@ -19,7 +19,7 @@
  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
  */
-#include "priv.h"
+#include "udisp.h"
 #include "conn.h"
 #include "head.h"
 #include "outp.h"
@@ -30,7 +30,7 @@
 static int
 nvkm_udisp_sclass(struct nvkm_object *object, int index, struct nvkm_oclass *sclass)
 {
-	struct nvkm_disp *disp = nvkm_udisp(object);
+	struct nvkm_disp *disp = container_of(object, struct nvif_disp_priv, object)->disp;
 
 	if (index-- == 0) {
 		sclass->base = (struct nvkm_sclass) { 0, 0, NVIF_CLASS_CONN };
@@ -62,13 +62,13 @@ nvkm_udisp_sclass(struct nvkm_object *object, int index, struct nvkm_oclass *scl
 static void *
 nvkm_udisp_dtor(struct nvkm_object *object)
 {
-	struct nvkm_disp *disp = nvkm_udisp(object);
+	struct nvif_disp_priv *udisp = container_of(object, typeof(*udisp), object);
+	struct nvkm_disp *disp = udisp->disp;
 
-	spin_lock(&disp->client.lock);
-	if (object == &disp->client.object)
-		disp->client.object.func = NULL;
-	spin_unlock(&disp->client.lock);
-	return NULL;
+	spin_lock(&disp->user.lock);
+	disp->user.allocated = false;
+	spin_unlock(&disp->user.lock);
+	return udisp;
 }
 
 static const struct nvkm_object_func
@@ -85,18 +85,27 @@ nvkm_udisp_new(const struct nvkm_oclass *oclass, void *argv, u32 argc, struct nv
 	struct nvkm_outp *outp;
 	struct nvkm_head *head;
 	union nvif_disp_args *args = argv;
+	struct nvif_disp_priv *udisp;
 
 	if (argc != sizeof(args->v0) || args->v0.version != 0)
 		return -ENOSYS;
 
-	spin_lock(&disp->client.lock);
-	if (disp->client.object.func) {
-		spin_unlock(&disp->client.lock);
+	udisp = kzalloc(sizeof(*udisp), GFP_KERNEL);
+	if (!udisp)
+		return -ENOMEM;
+
+	spin_lock(&disp->user.lock);
+	if (disp->user.allocated) {
+		spin_unlock(&disp->user.lock);
+		kfree(udisp);
 		return -EBUSY;
 	}
-	nvkm_object_ctor(&nvkm_udisp, oclass, &disp->client.object);
-	*pobject = &disp->client.object;
-	spin_unlock(&disp->client.lock);
+	disp->user.allocated = true;
+	spin_unlock(&disp->user.lock);
+
+	nvkm_object_ctor(&nvkm_udisp, oclass, &udisp->object);
+	udisp->disp = disp;
+	*pobject = &udisp->object;
 
 	args->v0.conn_mask = 0;
 	list_for_each_entry(conn, &disp->conns, head)
drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.h new file +11 -0
new file mode 100644
index 000000000000..2918ecbca5d3
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: MIT */
+#ifndef __NVKM_UDISP_H__
+#define __NVKM_UDISP_H__
+#include <core/object.h>
+#include "priv.h"
+
+struct nvif_disp_priv {
+	struct nvkm_object object;
+	struct nvkm_disp *disp;
+};
+#endif
drivers/gpu/drm/nouveau/nvkm/engine/disp/uhead.c +6 -5
index f072cec16040..89e9b61914d6 100644
@@ -89,9 +89,9 @@ nvkm_uhead_dtor(struct nvkm_object *object)
 	struct nvkm_head *head = nvkm_uhead(object);
 	struct nvkm_disp *disp = head->disp;
 
-	spin_lock(&disp->client.lock);
+	spin_lock(&disp->user.lock);
 	head->object.func = NULL;
-	spin_unlock(&disp->client.lock);
+	spin_unlock(&disp->user.lock);
 	return NULL;
 }
 
@@ -102,10 +102,11 @@ nvkm_uhead = {
 	.uevent = nvkm_uhead_uevent,
 };
 
+#include "udisp.h"
 int
 nvkm_uhead_new(const struct nvkm_oclass *oclass, void *argv, u32 argc, struct nvkm_object **pobject)
 {
-	struct nvkm_disp *disp = nvkm_udisp(oclass->parent);
+	struct nvkm_disp *disp = container_of(oclass->parent, struct nvif_disp_priv, object)->disp;
 	struct nvkm_head *head;
 	union nvif_head_args *args = argv;
 	int ret;
@@ -116,12 +117,12 @@ nvkm_uhead_new(const struct nvkm_oclass *oclass, void *argv, u32 argc, struct nv
 		return -EINVAL;
 
 	ret = -EBUSY;
-	spin_lock(&disp->client.lock);
+	spin_lock(&disp->user.lock);
 	if (!head->object.func) {
 		nvkm_object_ctor(&nvkm_uhead, oclass, &head->object);
 		*pobject = &head->object;
 		ret = 0;
 	}
-	spin_unlock(&disp->client.lock);
+	spin_unlock(&disp->user.lock);
 	return ret;
 }
drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c +6 -5
index 377d0e0cef84..75669d5f8a42 100644
@@ -570,9 +570,9 @@ nvkm_uoutp_dtor(struct nvkm_object *object)
 	struct nvkm_outp *outp = nvkm_uoutp(object);
 	struct nvkm_disp *disp = outp->disp;
 
-	spin_lock(&disp->client.lock);
+	spin_lock(&disp->user.lock);
 	outp->object.func = NULL;
-	spin_unlock(&disp->client.lock);
+	spin_unlock(&disp->user.lock);
 	return NULL;
 }
 
@@ -582,10 +582,11 @@ nvkm_uoutp = {
 	.mthd = nvkm_uoutp_mthd,
 };
 
+#include "udisp.h"
 int
 nvkm_uoutp_new(const struct nvkm_oclass *oclass, void *argv, u32 argc, struct nvkm_object **pobject)
 {
-	struct nvkm_disp *disp = nvkm_udisp(oclass->parent);
+	struct nvkm_disp *disp = container_of(oclass->parent, struct nvif_disp_priv, object)->disp;
 	struct nvkm_outp *outt, *outp = NULL;
 	union nvif_outp_args *args = argv;
 	int ret;
@@ -604,7 +605,7 @@ nvkm_uoutp_new(const struct nvkm_oclass *oclass, void *argv, u32 argc, struct nv
 		return -EINVAL;
 
 	ret = -EBUSY;
-	spin_lock(&disp->client.lock);
+	spin_lock(&disp->user.lock);
 	if (!outp->object.func) {
 		switch (outp->info.type) {
 		case DCB_OUTPUT_ANALOG:
@@ -660,6 +661,6 @@ nvkm_uoutp_new(const struct nvkm_oclass *oclass, void *argv, u32 argc, struct nv
 	}
 
 done:
-	spin_unlock(&disp->client.lock);
+	spin_unlock(&disp->user.lock);
 	return ret;
 }
Signature · 1 line
2.41.0
author
#49 lore raw

PATCH 48/156 drm/nouveau/nvkm: detach user handling from nvkm_conn

In reply to Ben Skeggs

- preparation for upcoming patches
- open-code current nvkm_uconn() macro

---
 .../gpu/drm/nouveau/nvkm/engine/disp/conn.h   |  2 +-
 .../gpu/drm/nouveau/nvkm/engine/disp/uconn.c  | 91 +++++++++++--------
 .../gpu/drm/nouveau/nvkm/engine/disp/uconn.h  |  6 ++
 3 files changed, 58 insertions(+), 41 deletions(-)
 create mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/disp/uconn.h
drivers/gpu/drm/nouveau/nvkm/engine/disp/conn.h +1 -1
index 01c3146c7066..0eb15e28d0c8 100644
@@ -13,7 +13,7 @@ struct nvkm_conn {
 
 	struct list_head head;
 
-	struct nvkm_object object;
+	bool user; /* protected by disp->user.lock */
 };
 
 int nvkm_conn_new(struct nvkm_disp *, int index, struct nvbios_connE *,
drivers/gpu/drm/nouveau/nvkm/engine/disp/uconn.c +51 -40

131 lines not on this page · raw message

drivers/gpu/drm/nouveau/nvkm/engine/disp/uconn.h new file +6 -0
new file mode 100644
index 000000000000..f53d151e5b09
@@ -0,0 +1,6 @@
+/* SPDX-License-Identifier: MIT */
+#ifndef __NVKM_UCONN_H__
+#define __NVKM_UCONN_H__
+#include "conn.h"
+
+#endif
Signature · 1 line
2.41.0
author
#50 lore raw

PATCH 49/156 drm/nouveau/nvkm: detach user handling from nvkm_outp

In reply to Ben Skeggs

- preparation for upcoming patches
- open-code current nvkm_uoutp() macro

---
 .../gpu/drm/nouveau/nvkm/engine/disp/outp.h   |   3 +-
 .../gpu/drm/nouveau/nvkm/engine/disp/uoutp.c  | 131 ++++++++++--------
 .../gpu/drm/nouveau/nvkm/engine/disp/uoutp.h  |   6 +
 3 files changed, 78 insertions(+), 62 deletions(-)
 create mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.h
drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.h +2 -1
index ebd2f499b4b1..1beba54f80eb 100644
@@ -63,10 +63,11 @@ struct nvkm_outp {
 		} dp;
 	};
 
-	struct nvkm_object object;
 	struct {
 		struct nvkm_head *head;
 	} asy;
+
+	bool user; /* protected by disp->user.lock */
 };
 
 int nvkm_outp_new_(const struct nvkm_outp_func *, struct nvkm_disp *, int index,
drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c +70 -61

174 lines not on this page · raw message

drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.h new file +6 -0
new file mode 100644
index 000000000000..37ecd2891a1a
@@ -0,0 +1,6 @@
+/* SPDX-License-Identifier: MIT */
+#ifndef __NVKM_UOUTP_H__
+#define __NVKM_UOUTP_H__
+#include "outp.h"
+
+#endif
Signature · 1 line
2.41.0
author
#51 lore raw

PATCH 50/156 drm/nouveau/nvkm: detach user handling from nvkm_uhead

In reply to Ben Skeggs

- preparation for upcoming patches
- open-code current nvkm_uhead() macro

---
 .../gpu/drm/nouveau/nvkm/engine/disp/head.h   |  2 +-
 .../gpu/drm/nouveau/nvkm/engine/disp/uhead.c  | 42 ++++++++++++-------
 .../gpu/drm/nouveau/nvkm/engine/disp/uhead.h  |  6 +++
 3 files changed, 34 insertions(+), 16 deletions(-)
 create mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/disp/uhead.h
drivers/gpu/drm/nouveau/nvkm/engine/disp/head.h +1 -1
index 856252bf559a..cd60e901d625 100644
@@ -28,7 +28,7 @@ struct nvkm_head {
 		} or;
 	} arm, asy;
 
-	struct nvkm_object object;
+	bool user; /* protected by disp->user.lock */
 };
 
 int nvkm_head_new_(const struct nvkm_head_func *, struct nvkm_disp *, int id);
drivers/gpu/drm/nouveau/nvkm/engine/disp/uhead.c +27 -15

85 lines not on this page · raw message

drivers/gpu/drm/nouveau/nvkm/engine/disp/uhead.h new file +6 -0
new file mode 100644
index 000000000000..f19c9ae33707
@@ -0,0 +1,6 @@
+/* SPDX-License-Identifier: MIT */
+#ifndef __NVKM_UHEAD_H__
+#define __NVKM_UHEAD_H__
+#include "head.h"
+
+#endif
Signature · 1 line
2.41.0
author
#52 lore raw

PATCH 51/156 drm/nouveau/nvkm: detach user handling from nvkm_disp_chan

In reply to Ben Skeggs

- preparation for upcoming patches
- open-code current nvkm_disp_chan() macro

---
 .../gpu/drm/nouveau/nvkm/engine/disp/chan.c   | 63 +++++++++++++------
 .../gpu/drm/nouveau/nvkm/engine/disp/chan.h   | 11 ++--
 .../gpu/drm/nouveau/nvkm/engine/disp/nv50.c   |  7 +--
 .../gpu/drm/nouveau/nvkm/engine/disp/r535.c   | 20 +++---
 4 files changed, 58 insertions(+), 43 deletions(-)
drivers/gpu/drm/nouveau/nvkm/engine/disp/chan.c +43 -20
index 25fe9946957f..b34615dcc8eb 100644
@@ -23,14 +23,20 @@
 
 #include <core/oproxy.h>
 #include <core/ramht.h>
+#include <subdev/mmu.h>
 
 #include <nvif/if0014.h>
 
+struct nvif_disp_chan_priv {
+	struct nvkm_object object;
+	struct nvkm_disp_chan chan;
+};
+
 static int
 nvkm_disp_chan_ntfy(struct nvkm_object *object, u32 type, struct nvkm_event **pevent)
 {
-	struct nvkm_disp_chan *chan = nvkm_disp_chan(object);
-	struct nvkm_disp *disp = chan->disp;
+	struct nvif_disp_chan_priv *uchan = container_of(object, typeof(*uchan), object);
+	struct nvkm_disp *disp = uchan->chan.disp;
 
 	switch (type) {
 	case 0:
@@ -47,7 +53,8 @@ static int
 nvkm_disp_chan_map(struct nvkm_object *object, void *argv, u32 argc,
 		   enum nvkm_object_map *type, u64 *addr, u64 *size)
 {
-	struct nvkm_disp_chan *chan = nvkm_disp_chan(object);
+	struct nvif_disp_chan_priv *uchan = container_of(object, typeof(*uchan), object);
+	struct nvkm_disp_chan *chan = &uchan->chan;
 	struct nvkm_device *device = chan->disp->engine.subdev.device;
 	const u64 base = device->func->resource_addr(device, 0);
 
@@ -79,7 +86,8 @@ static int
 nvkm_disp_chan_child_new(const struct nvkm_oclass *oclass, void *argv, u32 argc,
 			 struct nvkm_object **pobject)
 {
-	struct nvkm_disp_chan *chan = nvkm_disp_chan(oclass->parent);
+	struct nvif_disp_chan_priv *uchan = container_of(oclass->parent, typeof(*uchan), object);
+	struct nvkm_disp_chan *chan = &uchan->chan;
 	struct nvkm_disp *disp = chan->disp;
 	struct nvkm_device *device = disp->engine.subdev.device;
 	const struct nvkm_device_oclass *sclass = oclass->priv;
@@ -106,7 +114,8 @@ nvkm_disp_chan_child_new(const struct nvkm_oclass *oclass, void *argv, u32 argc,
 static int
 nvkm_disp_chan_child_get(struct nvkm_object *object, int index, struct nvkm_oclass *sclass)
 {
-	struct nvkm_disp_chan *chan = nvkm_disp_chan(object);
+	struct nvif_disp_chan_priv *uchan = container_of(object, typeof(*uchan), object);
+	struct nvkm_disp_chan *chan = &uchan->chan;
 	struct nvkm_device *device = chan->disp->engine.subdev.device;
 	const struct nvkm_device_oclass *oclass = NULL;
 
@@ -130,7 +139,8 @@ nvkm_disp_chan_child_get(struct nvkm_object *object, int index, struct nvkm_ocla
 static int
 nvkm_disp_chan_fini(struct nvkm_object *object, bool suspend)
 {
-	struct nvkm_disp_chan *chan = nvkm_disp_chan(object);
+	struct nvif_disp_chan_priv *uchan = container_of(object, typeof(*uchan), object);
+	struct nvkm_disp_chan *chan = &uchan->chan;
 
 	chan->func->fini(chan);
 	chan->func->intr(chan, false);
@@ -140,7 +150,8 @@ nvkm_disp_chan_fini(struct nvkm_object *object, bool suspend)
 static int
 nvkm_disp_chan_init(struct nvkm_object *object)
 {
-	struct nvkm_disp_chan *chan = nvkm_disp_chan(object);
+	struct nvif_disp_chan_priv *uchan = container_of(object, typeof(*uchan), object);
+	struct nvkm_disp_chan *chan = &uchan->chan;
 
 	chan->func->intr(chan, true);
 	return chan->func->init(chan);
@@ -149,16 +160,17 @@ nvkm_disp_chan_init(struct nvkm_object *object)
 static void *
 nvkm_disp_chan_dtor(struct nvkm_object *object)
 {
-	struct nvkm_disp_chan *chan = nvkm_disp_chan(object);
+
+	struct nvif_disp_chan_priv *uchan = container_of(object, typeof(*uchan), object);
+	struct nvkm_disp_chan *chan = &uchan->chan;
 	struct nvkm_disp *disp = chan->disp;
 
 	spin_lock(&disp->user.lock);
-	if (disp->chan[chan->chid.user] == chan)
-		disp->chan[chan->chid.user] = NULL;
+	disp->chan[chan->chid.user] = NULL;
 	spin_unlock(&disp->user.lock);
 
 	nvkm_memory_unref(&chan->memory);
-	return chan;
+	return uchan;
 }
 
 static const struct nvkm_object_func
@@ -176,6 +188,7 @@ nvkm_disp_chan_new_(struct nvkm_disp *disp, int nr, const struct nvkm_oclass *oc
 		    void *argv, u32 argc, struct nvkm_object **pobject)
 {
 	const struct nvkm_disp_chan_user *user = NULL;
+	struct nvif_disp_chan_priv *uchan;
 	struct nvkm_disp_chan *chan;
 	union nvif_disp_chan_args *args = argv;
 	int ret, i;
@@ -195,11 +208,12 @@ nvkm_disp_chan_new_(struct nvkm_disp *disp, int nr, const struct nvkm_oclass *oc
 	if (args->v0.id >= nr || !args->v0.pushbuf != !user->func->push)
 		return -EINVAL;
 
-	if (!(chan = kzalloc(sizeof(*chan), GFP_KERNEL)))
+	uchan = kzalloc(sizeof(*uchan), GFP_KERNEL);
+	if (!uchan)
 		return -ENOMEM;
-	*pobject = &chan->object;
+	chan = &uchan->chan;
 
-	nvkm_object_ctor(&nvkm_disp_chan, oclass, &chan->object);
+	nvkm_object_ctor(&nvkm_disp_chan, oclass, &uchan->object);
 	chan->func = user->func;
 	chan->mthd = user->mthd;
 	chan->disp = disp;
@@ -207,19 +221,28 @@ nvkm_disp_chan_new_(struct nvkm_disp *disp, int nr, const struct nvkm_oclass *oc
 	chan->chid.user = user->user + args->v0.id;
 	chan->head = args->v0.id;
 
-	if (chan->func->push) {
-		ret = chan->func->push(chan, args->v0.pushbuf);
-		if (ret)
-			return ret;
-	}
-
 	spin_lock(&disp->user.lock);
 	if (disp->chan[chan->chid.user]) {
 		spin_unlock(&disp->user.lock);
+		kfree(uchan);
 		return -EBUSY;
 	}
 	disp->chan[chan->chid.user] = chan;
+	chan->user.oclass = oclass->base.oclass;
 	spin_unlock(&disp->user.lock);
+
+	*pobject = &uchan->object;
+
+	if (chan->func->push) {
+		chan->memory = nvkm_umem_search(uchan->object.client, args->v0.pushbuf);
+		if (IS_ERR(chan->memory))
+			return PTR_ERR(chan->memory);
+
+		ret = chan->func->push(chan);
+		if (ret)
+			return ret;
+	}
+
 	return 0;
 }
 
drivers/gpu/drm/nouveau/nvkm/engine/disp/chan.h +6 -5
index 020290510157..8c212dde036f 100644
@@ -1,7 +1,6 @@
 /* SPDX-License-Identifier: MIT */
 #ifndef __NVKM_DISP_CHAN_H__
 #define __NVKM_DISP_CHAN_H__
-#define nvkm_disp_chan(p) container_of((p), struct nvkm_disp_chan, object)
 #include <core/object.h>
 #include "priv.h"
 
@@ -16,8 +15,6 @@ struct nvkm_disp_chan {
 	} chid;
 	int head;
 
-	struct nvkm_object object;
-
 	struct nvkm_memory *memory;
 	u64 push;
 
@@ -26,6 +23,10 @@ struct nvkm_disp_chan {
 	struct {
 		struct nvkm_gsp_object object;
 	} rm;
+
+	struct {
+		s32 oclass;
+	} user;
 };
 
 int nvkm_disp_core_new(const struct nvkm_oclass *, void *, u32, struct nvkm_object **);
@@ -33,7 +34,7 @@ int nvkm_disp_chan_new(const struct nvkm_oclass *, void *, u32, struct nvkm_obje
 int nvkm_disp_wndw_new(const struct nvkm_oclass *, void *, u32, struct nvkm_object **);
 
 struct nvkm_disp_chan_func {
-	int (*push)(struct nvkm_disp_chan *, u64 object);
+	int (*push)(struct nvkm_disp_chan *);
 	int (*init)(struct nvkm_disp_chan *);
 	void (*fini)(struct nvkm_disp_chan *);
 	void (*intr)(struct nvkm_disp_chan *, bool en);
@@ -45,7 +46,7 @@ void nv50_disp_chan_intr(struct nvkm_disp_chan *, bool);
 u64 nv50_disp_chan_user(struct nvkm_disp_chan *, u64 *);
 extern const struct nvkm_disp_chan_func nv50_disp_pioc_func;
 extern const struct nvkm_disp_chan_func nv50_disp_dmac_func;
-int nv50_disp_dmac_push(struct nvkm_disp_chan *, u64);
+int nv50_disp_dmac_push(struct nvkm_disp_chan *);
 int nv50_disp_dmac_bind(struct nvkm_disp_chan *, struct nvkm_object *, u32);
 extern const struct nvkm_disp_chan_func nv50_disp_core_func;
 
drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.c +1 -6
index 03a5f88a4b99..682628fe5b20 100644
@@ -37,7 +37,6 @@
 #include <subdev/bios/pll.h>
 #include <subdev/devinit.h>
 #include <subdev/i2c.h>
-#include <subdev/mmu.h>
 #include <subdev/timer.h>
 
 #include <nvif/class.h>
@@ -681,12 +680,8 @@ nv50_disp_dmac_init(struct nvkm_disp_chan *chan)
 }
 
 int
-nv50_disp_dmac_push(struct nvkm_disp_chan *chan, u64 object)
+nv50_disp_dmac_push(struct nvkm_disp_chan *chan)
 {
-	chan->memory = nvkm_umem_search(chan->object.client, object);
-	if (IS_ERR(chan->memory))
-		return PTR_ERR(chan->memory);
-
 	if (nvkm_memory_size(chan->memory) < 0x1000)
 		return -EINVAL;
 
drivers/gpu/drm/nouveau/nvkm/engine/disp/r535.c +8 -12
index 027867c2a8c5..f94858bc64f9 100644
@@ -53,7 +53,7 @@
 static u64
 r535_chan_user(struct nvkm_disp_chan *chan, u64 *psize)
 {
-	switch (chan->object.oclass & 0xff) {
+	switch (chan->user.oclass & 0xff) {
 	case 0x7d: *psize = 0x10000; return 0x680000;
 	case 0x7e: *psize = 0x01000; return 0x690000 + (chan->head * *psize);
 	case 0x7b: *psize = 0x01000; return 0x6b0000 + (chan->head * *psize);
@@ -111,9 +111,9 @@ r535_chan_push(struct nvkm_disp_chan *chan)
 		ctrl->limit = nvkm_memory_size(chan->memory) - 1;
 	}
 
-	ctrl->hclass = chan->object.oclass;
+	ctrl->hclass = chan->user.oclass;
 	ctrl->channelInstance = chan->head;
-	ctrl->valid = ((chan->object.oclass & 0xff) != 0x7a) ? 1 : 0;
+	ctrl->valid = ((chan->user.oclass & 0xff) != 0x7a) ? 1 : 0;
 
 	return nvkm_gsp_rm_ctrl_wr(&gsp->internal.device.subdevice, ctrl);
 }
@@ -129,8 +129,8 @@ r535_curs_init(struct nvkm_disp_chan *chan)
 		return ret;
 
 	args = nvkm_gsp_rm_alloc_get(&chan->disp->rm.object,
-				     (chan->object.oclass << 16) | chan->head,
-				     chan->object.oclass, sizeof(*args), &chan->rm.object);
+				     (chan->user.oclass << 16) | chan->head,
+				     chan->user.oclass, sizeof(*args), &chan->rm.object);
 	if (IS_ERR(args))
 		return PTR_ERR(args);
 
@@ -182,8 +182,8 @@ r535_dmac_init(struct nvkm_disp_chan *chan)
 		return ret;
 
 	args = nvkm_gsp_rm_alloc_get(&chan->disp->rm.object,
-				     (chan->object.oclass << 16) | chan->head,
-				     chan->object.oclass, sizeof(*args), &chan->rm.object);
+				     (chan->user.oclass << 16) | chan->head,
+				     chan->user.oclass, sizeof(*args), &chan->rm.object);
 	if (IS_ERR(args))
 		return PTR_ERR(args);
 
@@ -194,12 +194,8 @@ r535_dmac_init(struct nvkm_disp_chan *chan)
 }
 
 static int
-r535_dmac_push(struct nvkm_disp_chan *chan, u64 memory)
+r535_dmac_push(struct nvkm_disp_chan *chan)
 {
-	chan->memory = nvkm_umem_search(chan->object.client, memory);
-	if (IS_ERR(chan->memory))
-		return PTR_ERR(chan->memory);
-
 	return 0;
 }
 
Signature · 1 line
2.41.0
author
#53 lore raw

PATCH 52/156 drm/nouveau/nvkm: rename struct nvkm_ucgrp

In reply to Ben Skeggs

- preparation for upcoming patches
- open-code current nvkm_ucgrp() macro

---
 drivers/gpu/drm/nouveau/nvkm/engine/fifo/ucgrp.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/gpu/drm/nouveau/nvkm/engine/fifo/ucgrp.c +5 -6
index 52c594dfb1b8..7c9a151b03a3 100644
@@ -19,7 +19,6 @@
  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
  */
-#define nvkm_ucgrp(p) container_of((p), struct nvkm_ucgrp, object)
 #include "priv.h"
 #include "cgrp.h"
 #include "runl.h"
@@ -28,7 +27,7 @@
 
 #include <nvif/if0021.h>
 
-struct nvkm_ucgrp {
+struct nvif_cgrp_priv {
 	struct nvkm_object object;
 	struct nvkm_cgrp *cgrp;
 };
@@ -37,7 +36,7 @@ static int
 nvkm_ucgrp_chan_new(const struct nvkm_oclass *oclass, void *argv, u32 argc,
 		    struct nvkm_object **pobject)
 {
-	struct nvkm_cgrp *cgrp = nvkm_ucgrp(oclass->parent)->cgrp;
+	struct nvkm_cgrp *cgrp = container_of(oclass->parent, struct nvif_cgrp_priv, object)->cgrp;
 
 	return nvkm_uchan_new(cgrp->runl->fifo, cgrp, oclass, argv, argc, pobject);
 }
@@ -45,7 +44,7 @@ nvkm_ucgrp_chan_new(const struct nvkm_oclass *oclass, void *argv, u32 argc,
 static int
 nvkm_ucgrp_sclass(struct nvkm_object *object, int index, struct nvkm_oclass *oclass)
 {
-	struct nvkm_cgrp *cgrp = nvkm_ucgrp(object)->cgrp;
+	struct nvkm_cgrp *cgrp = container_of(object, struct nvif_cgrp_priv, object)->cgrp;
 	struct nvkm_fifo *fifo = cgrp->runl->fifo;
 	const struct nvkm_fifo_func_chan *chan = &fifo->func->chan;
 	int c = 0;
@@ -65,7 +64,7 @@ nvkm_ucgrp_sclass(struct nvkm_object *object, int index, struct nvkm_oclass *ocl
 static void *
 nvkm_ucgrp_dtor(struct nvkm_object *object)
 {
-	struct nvkm_ucgrp *ucgrp = nvkm_ucgrp(object);
+	struct nvif_cgrp_priv *ucgrp = container_of(object, typeof(*ucgrp), object);
 
 	nvkm_cgrp_unref(&ucgrp->cgrp);
 	return ucgrp;
@@ -84,7 +83,7 @@ nvkm_ucgrp_new(struct nvkm_fifo *fifo, const struct nvkm_oclass *oclass, void *a
 	union nvif_cgrp_args *args = argv;
 	struct nvkm_runl *runl;
 	struct nvkm_vmm *vmm;
-	struct nvkm_ucgrp *ucgrp;
+	struct nvif_cgrp_priv *ucgrp;
 	int ret;
 
 	if (argc < sizeof(args->v0) || args->v0.version != 0)
Signature · 1 line
2.41.0
author
#54 lore raw

PATCH 53/156 drm/nouveau/nvkm: rename struct nvkm_uchan

In reply to Ben Skeggs

- preparation for upcoming patches
- open-code current nvkm_uchan() macro

---
 .../gpu/drm/nouveau/nvkm/engine/fifo/uchan.c  | 21 +++++++++----------
 1 file changed, 10 insertions(+), 11 deletions(-)
drivers/gpu/drm/nouveau/nvkm/engine/fifo/uchan.c +10 -11
index 9e56bcc166ed..3dbc424869b3 100644
@@ -19,7 +19,6 @@
  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
  */
-#define nvkm_uchan(p) container_of((p), struct nvkm_uchan, object)
 #include "priv.h"
 #include "cgrp.h"
 #include "chan.h"
@@ -33,7 +32,7 @@
 
 #include <nvif/if0020.h>
 
-struct nvkm_uchan {
+struct nvif_chan_priv {
 	struct nvkm_object object;
 	struct nvkm_chan *chan;
 };
@@ -41,7 +40,7 @@ struct nvkm_uchan {
 static int
 nvkm_uchan_uevent(struct nvkm_object *object, void *argv, u32 argc, struct nvkm_uevent *uevent)
 {
-	struct nvkm_chan *chan = nvkm_uchan(object)->chan;
+	struct nvkm_chan *chan = container_of(object, struct nvif_chan_priv, object)->chan;
 	struct nvkm_runl *runl = chan->cgrp->runl;
 	union nvif_chan_event_args *args = argv;
 
@@ -154,7 +153,7 @@ static int
 nvkm_uchan_object_new(const struct nvkm_oclass *oclass, void *argv, u32 argc,
 		      struct nvkm_object **pobject)
 {
-	struct nvkm_chan *chan = nvkm_uchan(oclass->parent)->chan;
+	struct nvkm_chan *chan = container_of(oclass->parent, struct nvif_chan_priv, object)->chan;
 	struct nvkm_cgrp *cgrp = chan->cgrp;
 	struct nvkm_engn *engn;
 	struct nvkm_uobj *uobj;
@@ -203,7 +202,7 @@ nvkm_uchan_object_new(const struct nvkm_oclass *oclass, void *argv, u32 argc,
 static int
 nvkm_uchan_sclass(struct nvkm_object *object, int index, struct nvkm_oclass *oclass)
 {
-	struct nvkm_chan *chan = nvkm_uchan(object)->chan;
+	struct nvkm_chan *chan = container_of(object, struct nvif_chan_priv, object)->chan;
 	struct nvkm_engn *engn;
 	int ret, runq = 0;
 
@@ -255,7 +254,7 @@ static int
 nvkm_uchan_map(struct nvkm_object *object, void *argv, u32 argc,
 	       enum nvkm_object_map *type, u64 *addr, u64 *size)
 {
-	struct nvkm_chan *chan = nvkm_uchan(object)->chan;
+	struct nvkm_chan *chan = container_of(object, struct nvif_chan_priv, object)->chan;
 	struct nvkm_device *device = chan->cgrp->runl->fifo->engine.subdev.device;
 
 	if (chan->func->userd->bar < 0)
@@ -271,7 +270,7 @@ nvkm_uchan_map(struct nvkm_object *object, void *argv, u32 argc,
 static int
 nvkm_uchan_fini(struct nvkm_object *object, bool suspend)
 {
-	struct nvkm_chan *chan = nvkm_uchan(object)->chan;
+	struct nvkm_chan *chan = container_of(object, struct nvif_chan_priv, object)->chan;
 
 	nvkm_chan_block(chan);
 	nvkm_chan_remove(chan, true);
@@ -285,7 +284,7 @@ nvkm_uchan_fini(struct nvkm_object *object, bool suspend)
 static int
 nvkm_uchan_init(struct nvkm_object *object)
 {
-	struct nvkm_chan *chan = nvkm_uchan(object)->chan;
+	struct nvkm_chan *chan = container_of(object, struct nvif_chan_priv, object)->chan;
 
 	if (atomic_read(&chan->errored))
 		return 0;
@@ -301,7 +300,7 @@ nvkm_uchan_init(struct nvkm_object *object)
 static void *
 nvkm_uchan_dtor(struct nvkm_object *object)
 {
-	struct nvkm_uchan *uchan = nvkm_uchan(object);
+	struct nvif_chan_priv *uchan = container_of(object, typeof(*uchan), object);
 
 	nvkm_chan_del(&uchan->chan);
 	return uchan;
@@ -323,7 +322,7 @@ nvkm_uchan_chan(struct nvkm_object *object)
 	if (WARN_ON(object->func != &nvkm_uchan))
 		return NULL;
 
-	return nvkm_uchan(object)->chan;
+	return container_of(object, struct nvif_chan_priv, object)->chan;
 }
 
 int
@@ -335,7 +334,7 @@ nvkm_uchan_new(struct nvkm_fifo *fifo, struct nvkm_cgrp *cgrp, const struct nvkm
 	struct nvkm_vmm *vmm = NULL;
 	struct nvkm_dmaobj *ctxdma = NULL;
 	struct nvkm_memory *userd = NULL;
-	struct nvkm_uchan *uchan;
+	struct nvif_chan_priv *uchan;
 	struct nvkm_chan *chan;
 	int ret;
 
Signature · 1 line
2.41.0
author
#55 lore raw

PATCH 54/156 drm/nouveau/nvkm: move umem list to mmu

In reply to Ben Skeggs

This hack will be removed entirely later in the series, but for now we need to move it out of client for upcoming changes.

---
 .../gpu/drm/nouveau/include/nvkm/core/client.h |  3 ---
 .../gpu/drm/nouveau/include/nvkm/subdev/mmu.h  |  5 ++++-
 drivers/gpu/drm/nouveau/nvkm/core/client.c     |  2 --
 .../gpu/drm/nouveau/nvkm/engine/disp/chan.c    |  2 +-
 .../gpu/drm/nouveau/nvkm/engine/fifo/uchan.c   |  2 +-
 drivers/gpu/drm/nouveau/nvkm/subdev/mmu/base.c |  2 ++
 drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.c | 18 +++++++++---------
 drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c |  4 ++--
 8 files changed, 19 insertions(+), 19 deletions(-)
drivers/gpu/drm/nouveau/include/nvkm/core/client.h +0 -3
index 4045b9f5ef4e..f7f195d87838 100644
@@ -14,9 +14,6 @@ struct nvkm_client {
 
 	void *data;
 	int (*event)(u64 token, void *argv, u32 argc);
-
-	struct list_head umem;
-	spinlock_t lock;
 };
 
 int  nvkm_client_new(const char *name, u64 device, const char *cfg, const char *dbg,
drivers/gpu/drm/nouveau/include/nvkm/subdev/mmu.h +4 -1
index 935b1cacd528..f2d23bfdf29a 100644
@@ -109,7 +109,7 @@ int nvkm_vmm_map(struct nvkm_vmm *, struct nvkm_vma *, void *argv, u32 argc,
 		 struct nvkm_vmm_map *);
 void nvkm_vmm_unmap(struct nvkm_vmm *, struct nvkm_vma *);
 
-struct nvkm_memory *nvkm_umem_search(struct nvkm_client *, u64);
+struct nvkm_memory *nvkm_umem_search(struct nvkm_mmu *, struct nvkm_client *, u64);
 struct nvkm_vmm *nvkm_uvmm_search(struct nvkm_client *, u64 handle);
 
 struct nvkm_mmu {
@@ -148,6 +148,9 @@ struct nvkm_mmu {
 	struct mutex mutex; /* serialises mmu invalidations */
 
 	struct nvkm_device_oclass user;
+
+	spinlock_t umem_lock;
+	struct list_head umem;
 };
 
 int nv04_mmu_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_mmu **);
drivers/gpu/drm/nouveau/nvkm/core/client.c +0 -2
index b127676078b1..7dc425e67dd4 100644
@@ -120,7 +120,5 @@ nvkm_client_new(const char *name, u64 device, const char *cfg, const char *dbg,
 	client->objroot = RB_ROOT;
 	spin_lock_init(&client->obj_lock);
 	client->event = event;
-	INIT_LIST_HEAD(&client->umem);
-	spin_lock_init(&client->lock);
 	return 0;
 }
drivers/gpu/drm/nouveau/nvkm/engine/disp/chan.c +1 -1
index b34615dcc8eb..d3c0537c08db 100644
@@ -234,7 +234,7 @@ nvkm_disp_chan_new_(struct nvkm_disp *disp, int nr, const struct nvkm_oclass *oc
 	*pobject = &uchan->object;
 
 	if (chan->func->push) {
-		chan->memory = nvkm_umem_search(uchan->object.client, args->v0.pushbuf);
+		chan->memory = nvkm_umem_search(disp->engine.subdev.device->mmu, uchan->object.client, args->v0.pushbuf);
 		if (IS_ERR(chan->memory))
 			return PTR_ERR(chan->memory);
 
drivers/gpu/drm/nouveau/nvkm/engine/fifo/uchan.c +1 -1
index 3dbc424869b3..23d992413442 100644
@@ -365,7 +365,7 @@ nvkm_uchan_new(struct nvkm_fifo *fifo, struct nvkm_cgrp *cgrp, const struct nvkm
 	}
 
 	if (args->v0.huserd) {
-		userd = nvkm_umem_search(oclass->client, args->v0.huserd);
+		userd = nvkm_umem_search(fifo->engine.subdev.device->mmu, oclass->client, args->v0.huserd);
 		if (IS_ERR(userd)) {
 			ret = PTR_ERR(userd);
 			userd = NULL;
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/base.c +2 -0
index b67ace7ae93c..7b949a43c372 100644
@@ -428,6 +428,8 @@ nvkm_mmu_ctor(const struct nvkm_mmu_func *func, struct nvkm_device *device,
 	mutex_init(&mmu->mutex);
 	mmu->user.ctor = nvkm_ummu_new;
 	mmu->user.base = func->mmu.user;
+	spin_lock_init(&mmu->umem_lock);
+	INIT_LIST_HEAD(&mmu->umem);
 }
 
 int
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.c +9 -9
index 45ab7e445d58..45f589eb5d78 100644
@@ -48,7 +48,7 @@ struct nvif_mem_priv {
 
 static const struct nvkm_object_func nvkm_umem;
 struct nvkm_memory *
-nvkm_umem_search(struct nvkm_client *client, u64 handle)
+nvkm_umem_search(struct nvkm_mmu *mmu, struct nvkm_client *client, u64 handle)
 {
 	struct nvkm_client *master = client->object.client;
 	struct nvkm_memory *memory = NULL;
@@ -58,14 +58,14 @@ nvkm_umem_search(struct nvkm_client *client, u64 handle)
 	object = nvkm_object_search(client, handle, &nvkm_umem);
 	if (IS_ERR(object)) {
 		if (client != master) {
-			spin_lock(&master->lock);
-			list_for_each_entry(umem, &master->umem, head) {
+			spin_lock(&mmu->umem_lock);
+			list_for_each_entry(umem, &mmu->umem, head) {
 				if (umem->object.object == handle) {
 					memory = nvkm_memory_ref(umem->memory);
 					break;
 				}
 			}
-			spin_unlock(&master->lock);
+			spin_unlock(&mmu->umem_lock);
 		}
 	} else {
 		umem = container_of(object, typeof(*umem), object);
@@ -141,9 +141,9 @@ nvkm_umem_dtor(struct nvkm_object *object)
 {
 	struct nvif_mem_priv *umem = container_of(object, typeof(*umem), object);
 
-	spin_lock(&umem->object.client->lock);
+	spin_lock(&umem->mmu->umem_lock);
 	list_del_init(&umem->head);
-	spin_unlock(&umem->object.client->lock);
+	spin_unlock(&umem->mmu->umem_lock);
 	nvkm_memory_unref(&umem->memory);
 	return umem;
 }
@@ -196,9 +196,9 @@ nvkm_umem_new(const struct nvkm_oclass *oclass, void *argv, u32 argc,
 	if (ret)
 		return ret;
 
-	spin_lock(&umem->object.client->lock);
-	list_add(&umem->head, &umem->object.client->umem);
-	spin_unlock(&umem->object.client->lock);
+	spin_lock(&mmu->umem_lock);
+	list_add(&umem->head, &mmu->umem);
+	spin_unlock(&mmu->umem_lock);
 
 	args->v0.page = nvkm_memory_page(umem->memory);
 	args->v0.addr = nvkm_memory_addr(umem->memory);
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c +2 -2
index 6f261f81a2ad..761a50047b42 100644
@@ -178,7 +178,7 @@ nvkm_uvmm_mthd_map(struct nvkm_uvmm *uvmm, void *argv, u32 argc)
 	if (nvkm_vmm_in_managed_range(vmm, addr, size) && vmm->managed.raw)
 		return -EINVAL;
 
-	memory = nvkm_umem_search(client, handle);
+	memory = nvkm_umem_search(vmm->mmu, client, handle);
 	if (IS_ERR(memory)) {
 		VMM_DEBUG(vmm, "memory %016llx %ld\n", handle, PTR_ERR(memory));
 		return PTR_ERR(memory);
@@ -421,7 +421,7 @@ nvkm_uvmm_mthd_raw_map(struct nvkm_uvmm *uvmm, struct nvif_vmm_raw_v0 *args)
 
 	vma.page = vma.refd = refd;
 
-	memory = nvkm_umem_search(client, args->memory);
+	memory = nvkm_umem_search(uvmm->vmm->mmu, client, args->memory);
 	if (IS_ERR(memory)) {
 		VMM_DEBUG(vmm, "memory %016llx %ld\n", handle, PTR_ERR(memory));
 		return PTR_ERR(memory);
Signature · 1 line
2.41.0
author
#56 lore raw

PATCH 55/156 drm/nouveau/disp: simplify hw user definition

In reply to Ben Skeggs

- needed for upcoming changes to display channel allocation APIs

---
 .../gpu/drm/nouveau/nvkm/engine/disp/ad102.c  | 13 +++--
 .../gpu/drm/nouveau/nvkm/engine/disp/base.c   |  2 +-
 .../gpu/drm/nouveau/nvkm/engine/disp/chan.c   | 15 ++++--
 .../gpu/drm/nouveau/nvkm/engine/disp/g84.c    | 13 +++--
 .../gpu/drm/nouveau/nvkm/engine/disp/g94.c    | 13 +++--
 .../gpu/drm/nouveau/nvkm/engine/disp/ga102.c  | 13 +++--
 .../gpu/drm/nouveau/nvkm/engine/disp/gf119.c  | 13 +++--
 .../gpu/drm/nouveau/nvkm/engine/disp/gk104.c  | 13 +++--
 .../gpu/drm/nouveau/nvkm/engine/disp/gk110.c  | 13 +++--
 .../gpu/drm/nouveau/nvkm/engine/disp/gm107.c  | 13 +++--
 .../gpu/drm/nouveau/nvkm/engine/disp/gm200.c  | 13 +++--
 .../gpu/drm/nouveau/nvkm/engine/disp/gp100.c  | 13 +++--
 .../gpu/drm/nouveau/nvkm/engine/disp/gp102.c  | 13 +++--
 .../gpu/drm/nouveau/nvkm/engine/disp/gt200.c  | 13 +++--
 .../gpu/drm/nouveau/nvkm/engine/disp/gt215.c  | 13 +++--
 .../gpu/drm/nouveau/nvkm/engine/disp/gv100.c  | 13 +++--
 .../gpu/drm/nouveau/nvkm/engine/disp/mcp77.c  | 13 +++--
 .../gpu/drm/nouveau/nvkm/engine/disp/mcp89.c  | 13 +++--
 .../gpu/drm/nouveau/nvkm/engine/disp/nv04.c   |  5 +-
 .../gpu/drm/nouveau/nvkm/engine/disp/nv50.c   | 13 +++--
 .../gpu/drm/nouveau/nvkm/engine/disp/priv.h   | 24 ++++++---
 .../gpu/drm/nouveau/nvkm/engine/disp/r535.c   | 26 +++-------
 .../gpu/drm/nouveau/nvkm/engine/disp/tu102.c  | 13 +++--
 .../gpu/drm/nouveau/nvkm/engine/disp/udisp.c  | 49 +++++++++++++++++--
 24 files changed, 194 insertions(+), 161 deletions(-)
drivers/gpu/drm/nouveau/nvkm/engine/disp/ad102.c +6 -7
index 7f300a79aa29..f818828e3f04 100644
@@ -30,14 +30,13 @@ static const struct nvkm_disp_func
 ad102_disp = {
 	.uevent = &gv100_disp_chan_uevent,
 	.ramht_size = 0x2000,
-	.root = {  0, 0,AD102_DISP },
 	.user = {
-		{{-1,-1,GV100_DISP_CAPS                  }, gv100_disp_caps_new },
-		{{ 0, 0,GA102_DISP_CURSOR                }, nvkm_disp_chan_new, &gv100_disp_curs },
-		{{ 0, 0,GA102_DISP_WINDOW_IMM_CHANNEL_DMA}, nvkm_disp_wndw_new, &gv100_disp_wimm },
-		{{ 0, 0,AD102_DISP_CORE_CHANNEL_DMA      }, nvkm_disp_core_new, &gv100_disp_core },
-		{{ 0, 0,GA102_DISP_WINDOW_CHANNEL_DMA    }, nvkm_disp_wndw_new, &gv100_disp_wndw },
-		{}
+		.root = { AD102_DISP },
+		.caps = { GV100_DISP_CAPS                  ,  gv100_disp_caps_new },
+		.curs = { GA102_DISP_CURSOR                , &gv100_disp_curs },
+		.wimm = { GA102_DISP_WINDOW_IMM_CHANNEL_DMA, &gv100_disp_wimm },
+		.core = { AD102_DISP_CORE_CHANNEL_DMA      , &gv100_disp_core },
+		.wndw = { GA102_DISP_WINDOW_CHANNEL_DMA    , &gv100_disp_wndw },
 	},
 };
 
drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c +1 -1
index e93646d53378..6850c703ff2d 100644
@@ -84,7 +84,7 @@ nvkm_disp_class_get(struct nvkm_oclass *oclass, int index,
 {
 	struct nvkm_disp *disp = nvkm_disp(oclass->engine);
 	if (index == 0) {
-		oclass->base = disp->func->root;
+		oclass->base = (struct nvkm_sclass) { 0, 0, disp->func->user.root.oclass };
 		*class = &nvkm_disp_sclass;
 		return 0;
 	}
drivers/gpu/drm/nouveau/nvkm/engine/disp/chan.c +12 -3
index d3c0537c08db..86938c633272 100644
@@ -187,15 +187,24 @@ static int
 nvkm_disp_chan_new_(struct nvkm_disp *disp, int nr, const struct nvkm_oclass *oclass,
 		    void *argv, u32 argc, struct nvkm_object **pobject)
 {
+	const struct nvkm_disp_func_chan *chans[] = {
+		&disp->func->user.core,
+		&disp->func->user.base,
+		&disp->func->user.ovly,
+		&disp->func->user.wndw,
+		&disp->func->user.wimm,
+		&disp->func->user.curs,
+		&disp->func->user.oimm,
+	};
 	const struct nvkm_disp_chan_user *user = NULL;
 	struct nvif_disp_chan_priv *uchan;
 	struct nvkm_disp_chan *chan;
 	union nvif_disp_chan_args *args = argv;
 	int ret, i;
 
-	for (i = 0; disp->func->user[i].ctor; i++) {
-		if (disp->func->user[i].base.oclass == oclass->base.oclass) {
-			user = disp->func->user[i].chan;
+	for (i = 0; i < ARRAY_SIZE(chans); i++) {
+		if (chans[i]->oclass == oclass->base.oclass) {
+			user = chans[i]->chan;
 			break;
 		}
 	}
drivers/gpu/drm/nouveau/nvkm/engine/disp/g84.c +6 -7
index 1be97a68a83e..1ee61eb1faf2 100644
@@ -330,14 +330,13 @@ g84_disp = {
 	.dac = { .cnt = nv50_dac_cnt, .new = nv50_dac_new },
 	.sor = { .cnt = nv50_sor_cnt, .new = g84_sor_new },
 	.pior = { .cnt = nv50_pior_cnt, .new = nv50_pior_new },
-	.root = { 0,0,G82_DISP },
 	.user = {
-		{{0,0,G82_DISP_CURSOR             }, nvkm_disp_chan_new, &nv50_disp_curs },
-		{{0,0,G82_DISP_OVERLAY            }, nvkm_disp_chan_new, &nv50_disp_oimm },
-		{{0,0,G82_DISP_BASE_CHANNEL_DMA   }, nvkm_disp_chan_new, & g84_disp_base },
-		{{0,0,G82_DISP_CORE_CHANNEL_DMA   }, nvkm_disp_core_new, & g84_disp_core },
-		{{0,0,G82_DISP_OVERLAY_CHANNEL_DMA}, nvkm_disp_chan_new, & g84_disp_ovly },
-		{}
+		.root = { G82_DISP },
+		.curs = { G82_DISP_CURSOR             , &nv50_disp_curs },
+		.oimm = { G82_DISP_OVERLAY            , &nv50_disp_oimm },
+		.base = { G82_DISP_BASE_CHANNEL_DMA   , & g84_disp_base },
+		.core = { G82_DISP_CORE_CHANNEL_DMA   , & g84_disp_core },
+		.ovly = { G82_DISP_OVERLAY_CHANNEL_DMA, & g84_disp_ovly },
 	},
 };
 
drivers/gpu/drm/nouveau/nvkm/engine/disp/g94.c +6 -7
index 843a2661ce9d..7165b924e514 100644
@@ -360,14 +360,13 @@ g94_disp = {
 	.dac = { .cnt = nv50_dac_cnt, .new = nv50_dac_new },
 	.sor = { .cnt = g94_sor_cnt, .new = g94_sor_new },
 	.pior = { .cnt = nv50_pior_cnt, .new = nv50_pior_new },
-	.root = { 0,0,GT206_DISP },
 	.user = {
-		{{0,0,  G82_DISP_CURSOR             }, nvkm_disp_chan_new, & nv50_disp_curs },
-		{{0,0,  G82_DISP_OVERLAY            }, nvkm_disp_chan_new, & nv50_disp_oimm },
-		{{0,0,GT200_DISP_BASE_CHANNEL_DMA   }, nvkm_disp_chan_new, &  g84_disp_base },
-		{{0,0,GT206_DISP_CORE_CHANNEL_DMA   }, nvkm_disp_core_new, &  g94_disp_core },
-		{{0,0,GT200_DISP_OVERLAY_CHANNEL_DMA}, nvkm_disp_chan_new, &gt200_disp_ovly },
-		{}
+		.root = { GT206_DISP },
+		.curs = {   G82_DISP_CURSOR             , & nv50_disp_curs },
+		.oimm = {   G82_DISP_OVERLAY            , & nv50_disp_oimm },
+		.base = { GT200_DISP_BASE_CHANNEL_DMA   , &  g84_disp_base },
+		.core = { GT206_DISP_CORE_CHANNEL_DMA   , &  g94_disp_core },
+		.ovly = { GT200_DISP_OVERLAY_CHANNEL_DMA, &gt200_disp_ovly },
 	},
 };
 
drivers/gpu/drm/nouveau/nvkm/engine/disp/ga102.c +6 -7
index ab0a85c92430..c6b77e4d08a0 100644
@@ -133,14 +133,13 @@ ga102_disp = {
 	.head = { .cnt = gv100_head_cnt, .new = gv100_head_new },
 	.sor = { .cnt = gv100_sor_cnt, .new = ga102_sor_new },
 	.ramht_size = 0x2000,
-	.root = {  0, 0,GA102_DISP },
 	.user = {
-		{{-1,-1,GV100_DISP_CAPS                  }, gv100_disp_caps_new },
-		{{ 0, 0,GA102_DISP_CURSOR                }, nvkm_disp_chan_new, &gv100_disp_curs },
-		{{ 0, 0,GA102_DISP_WINDOW_IMM_CHANNEL_DMA}, nvkm_disp_wndw_new, &gv100_disp_wimm },
-		{{ 0, 0,GA102_DISP_CORE_CHANNEL_DMA      }, nvkm_disp_core_new, &gv100_disp_core },
-		{{ 0, 0,GA102_DISP_WINDOW_CHANNEL_DMA    }, nvkm_disp_wndw_new, &gv100_disp_wndw },
-		{}
+		.root = { GA102_DISP },
+		.caps = { GV100_DISP_CAPS                  ,  gv100_disp_caps_new },
+		.curs = { GA102_DISP_CURSOR                , &gv100_disp_curs },
+		.wimm = { GA102_DISP_WINDOW_IMM_CHANNEL_DMA, &gv100_disp_wimm },
+		.core = { GA102_DISP_CORE_CHANNEL_DMA      , &gv100_disp_core },
+		.wndw = { GA102_DISP_WINDOW_CHANNEL_DMA    , &gv100_disp_wndw },
 	},
 };
 
drivers/gpu/drm/nouveau/nvkm/engine/disp/gf119.c +6 -7
index 83a1323600ae..5234edda8306 100644
@@ -1242,14 +1242,13 @@ gf119_disp = {
 	.head = { .cnt = gf119_head_cnt, .new = gf119_head_new },
 	.dac = { .cnt = gf119_dac_cnt, .new = gf119_dac_new },
 	.sor = { .cnt = gf119_sor_cnt, .new = gf119_sor_new },
-	.root = { 0,0,GF110_DISP },
 	.user = {
-		{{0,0,GF110_DISP_CURSOR             }, nvkm_disp_chan_new, &gf119_disp_curs },
-		{{0,0,GF110_DISP_OVERLAY            }, nvkm_disp_chan_new, &gf119_disp_oimm },
-		{{0,0,GF110_DISP_BASE_CHANNEL_DMA   }, nvkm_disp_chan_new, &gf119_disp_base },
-		{{0,0,GF110_DISP_CORE_CHANNEL_DMA   }, nvkm_disp_core_new, &gf119_disp_core },
-		{{0,0,GF110_DISP_OVERLAY_CONTROL_DMA}, nvkm_disp_chan_new, &gf119_disp_ovly },
-		{}
+		.root = { GF110_DISP },
+		.curs = { GF110_DISP_CURSOR             , &gf119_disp_curs },
+		.oimm = { GF110_DISP_OVERLAY            , &gf119_disp_oimm },
+		.base = { GF110_DISP_BASE_CHANNEL_DMA   , &gf119_disp_base },
+		.core = { GF110_DISP_CORE_CHANNEL_DMA   , &gf119_disp_core },
+		.ovly = { GF110_DISP_OVERLAY_CONTROL_DMA, &gf119_disp_ovly },
 	},
 };
 
drivers/gpu/drm/nouveau/nvkm/engine/disp/gk104.c +6 -7
index a3e2fbadade4..2f22d0cfc8ae 100644
@@ -314,14 +314,13 @@ gk104_disp = {
 	.head = { .cnt = gf119_head_cnt, .new = gf119_head_new },
 	.dac = { .cnt = gf119_dac_cnt, .new = gf119_dac_new },
 	.sor = { .cnt = gf119_sor_cnt, .new = gk104_sor_new },
-	.root = { 0,0,GK104_DISP },
 	.user = {
-		{{0,0,GK104_DISP_CURSOR             }, nvkm_disp_chan_new, &gf119_disp_curs },
-		{{0,0,GK104_DISP_OVERLAY            }, nvkm_disp_chan_new, &gf119_disp_oimm },
-		{{0,0,GK104_DISP_BASE_CHANNEL_DMA   }, nvkm_disp_chan_new, &gf119_disp_base },
-		{{0,0,GK104_DISP_CORE_CHANNEL_DMA   }, nvkm_disp_core_new, &gk104_disp_core },
-		{{0,0,GK104_DISP_OVERLAY_CONTROL_DMA}, nvkm_disp_chan_new, &gk104_disp_ovly },
-		{}
+		.root = { GK104_DISP },
+		.curs = { GK104_DISP_CURSOR             , &gf119_disp_curs },
+		.oimm = { GK104_DISP_OVERLAY            , &gf119_disp_oimm },
+		.base = { GK104_DISP_BASE_CHANNEL_DMA   , &gf119_disp_base },
+		.core = { GK104_DISP_CORE_CHANNEL_DMA   , &gk104_disp_core },
+		.ovly = { GK104_DISP_OVERLAY_CONTROL_DMA, &gk104_disp_ovly },
 	},
 };
 
drivers/gpu/drm/nouveau/nvkm/engine/disp/gk110.c +6 -7
index 1704aa381ee9..205c05ad0306 100644
@@ -40,14 +40,13 @@ gk110_disp = {
 	.head = { .cnt = gf119_head_cnt, .new = gf119_head_new },
 	.dac = { .cnt = gf119_dac_cnt, .new = gf119_dac_new },
 	.sor = { .cnt = gf119_sor_cnt, .new = gk104_sor_new },
-	.root = { 0,0,GK110_DISP },
 	.user = {
-		{{0,0,GK104_DISP_CURSOR             }, nvkm_disp_chan_new, &gf119_disp_curs },
-		{{0,0,GK104_DISP_OVERLAY            }, nvkm_disp_chan_new, &gf119_disp_oimm },
-		{{0,0,GK110_DISP_BASE_CHANNEL_DMA   }, nvkm_disp_chan_new, &gf119_disp_base },
-		{{0,0,GK110_DISP_CORE_CHANNEL_DMA   }, nvkm_disp_core_new, &gk104_disp_core },
-		{{0,0,GK104_DISP_OVERLAY_CONTROL_DMA}, nvkm_disp_chan_new, &gk104_disp_ovly },
-		{}
+		.root = { GK110_DISP },
+		.curs = { GK104_DISP_CURSOR             , &gf119_disp_curs },
+		.oimm = { GK104_DISP_OVERLAY            , &gf119_disp_oimm },
+		.base = { GK110_DISP_BASE_CHANNEL_DMA   , &gf119_disp_base },
+		.core = { GK110_DISP_CORE_CHANNEL_DMA   , &gk104_disp_core },
+		.ovly = { GK104_DISP_OVERLAY_CONTROL_DMA, &gk104_disp_ovly },
 	},
 };
 
drivers/gpu/drm/nouveau/nvkm/engine/disp/gm107.c +6 -7
index 688e123ad482..a57cf832e789 100644
@@ -94,14 +94,13 @@ gm107_disp = {
 	.head = { .cnt = gf119_head_cnt, .new = gf119_head_new },
 	.dac = { .cnt = gf119_dac_cnt, .new = gf119_dac_new },
 	.sor = { .cnt = gf119_sor_cnt, .new = gm107_sor_new },
-	.root = { 0,0,GM107_DISP },
 	.user = {
-		{{0,0,GK104_DISP_CURSOR             }, nvkm_disp_chan_new, &gf119_disp_curs },
-		{{0,0,GK104_DISP_OVERLAY            }, nvkm_disp_chan_new, &gf119_disp_oimm },
-		{{0,0,GK110_DISP_BASE_CHANNEL_DMA   }, nvkm_disp_chan_new, &gf119_disp_base },
-		{{0,0,GM107_DISP_CORE_CHANNEL_DMA   }, nvkm_disp_core_new, &gk104_disp_core },
-		{{0,0,GK104_DISP_OVERLAY_CONTROL_DMA}, nvkm_disp_chan_new, &gk104_disp_ovly },
-		{}
+		.root = { GM107_DISP },
+		.curs = { GK104_DISP_CURSOR             , &gf119_disp_curs },
+		.oimm = { GK104_DISP_OVERLAY            , &gf119_disp_oimm },
+		.base = { GK110_DISP_BASE_CHANNEL_DMA   , &gf119_disp_base },
+		.core = { GM107_DISP_CORE_CHANNEL_DMA   , &gk104_disp_core },
+		.ovly = { GK104_DISP_OVERLAY_CONTROL_DMA, &gk104_disp_ovly },
 	},
 };
 
drivers/gpu/drm/nouveau/nvkm/engine/disp/gm200.c +6 -7
index 511e7831b2f5..350b10d19288 100644
@@ -177,14 +177,13 @@ gm200_disp = {
 	.head = { .cnt = gf119_head_cnt, .new = gf119_head_new },
 	.dac = { .cnt = gf119_dac_cnt, .new = gf119_dac_new },
 	.sor = { .cnt = gf119_sor_cnt, .new = gm200_sor_new },
-	.root = { 0,0,GM200_DISP },
 	.user = {
-		{{0,0,GK104_DISP_CURSOR             }, nvkm_disp_chan_new, &gf119_disp_curs },
-		{{0,0,GK104_DISP_OVERLAY            }, nvkm_disp_chan_new, &gf119_disp_oimm },
-		{{0,0,GK110_DISP_BASE_CHANNEL_DMA   }, nvkm_disp_chan_new, &gf119_disp_base },
-		{{0,0,GM200_DISP_CORE_CHANNEL_DMA   }, nvkm_disp_core_new, &gk104_disp_core },
-		{{0,0,GK104_DISP_OVERLAY_CONTROL_DMA}, nvkm_disp_chan_new, &gk104_disp_ovly },
-		{}
+		.root = { GM200_DISP },
+		.curs = { GK104_DISP_CURSOR             , &gf119_disp_curs },
+		.oimm = { GK104_DISP_OVERLAY            , &gf119_disp_oimm },
+		.base = { GK110_DISP_BASE_CHANNEL_DMA   , &gf119_disp_base },
+		.core = { GM200_DISP_CORE_CHANNEL_DMA   , &gk104_disp_core },
+		.ovly = { GK104_DISP_OVERLAY_CONTROL_DMA, &gk104_disp_ovly },
 	},
 };
 
drivers/gpu/drm/nouveau/nvkm/engine/disp/gp100.c +6 -7
index 4070447bd800..c0a9e18f1ccb 100644
@@ -66,14 +66,13 @@ gp100_disp = {
 	.uevent = &gf119_disp_chan_uevent,
 	.head = { .cnt = gf119_head_cnt, .new = gf119_head_new },
 	.sor = { .cnt = gf119_sor_cnt, .new = gp100_sor_new },
-	.root = { 0,0,GP100_DISP },
 	.user = {
-		{{0,0,GK104_DISP_CURSOR             }, nvkm_disp_chan_new, &gf119_disp_curs },
-		{{0,0,GK104_DISP_OVERLAY            }, nvkm_disp_chan_new, &gf119_disp_oimm },
-		{{0,0,GK110_DISP_BASE_CHANNEL_DMA   }, nvkm_disp_chan_new, &gf119_disp_base },
-		{{0,0,GP100_DISP_CORE_CHANNEL_DMA   }, nvkm_disp_core_new, &gk104_disp_core },
-		{{0,0,GK104_DISP_OVERLAY_CONTROL_DMA}, nvkm_disp_chan_new, &gk104_disp_ovly },
-		{}
+		.root = { GP100_DISP },
+		.curs = { GK104_DISP_CURSOR             , &gf119_disp_curs },
+		.oimm = { GK104_DISP_OVERLAY            , &gf119_disp_oimm },
+		.base = { GK110_DISP_BASE_CHANNEL_DMA   , &gf119_disp_base },
+		.core = { GP100_DISP_CORE_CHANNEL_DMA   , &gk104_disp_core },
+		.ovly = { GK104_DISP_OVERLAY_CONTROL_DMA, &gk104_disp_ovly },
 	},
 };
 
drivers/gpu/drm/nouveau/nvkm/engine/disp/gp102.c +6 -7
index 07e9aeec5e08..6513d0456749 100644
@@ -181,14 +181,13 @@ gp102_disp = {
 	.uevent = &gf119_disp_chan_uevent,
 	.head = { .cnt = gf119_head_cnt, .new = gf119_head_new },
 	.sor = { .cnt = gf119_sor_cnt, .new = gp100_sor_new },
-	.root = { 0,0,GP102_DISP },
 	.user = {
-		{{0,0,GK104_DISP_CURSOR             }, nvkm_disp_chan_new, &gp102_disp_curs },
-		{{0,0,GK104_DISP_OVERLAY            }, nvkm_disp_chan_new, &gp102_disp_oimm },
-		{{0,0,GK110_DISP_BASE_CHANNEL_DMA   }, nvkm_disp_chan_new, &gp102_disp_base },
-		{{0,0,GP102_DISP_CORE_CHANNEL_DMA   }, nvkm_disp_core_new, &gp102_disp_core },
-		{{0,0,GK104_DISP_OVERLAY_CONTROL_DMA}, nvkm_disp_chan_new, &gp102_disp_ovly },
-		{}
+		.root = { GP102_DISP },
+		.curs = { GK104_DISP_CURSOR             , &gp102_disp_curs },
+		.oimm = { GK104_DISP_OVERLAY            , &gp102_disp_oimm },
+		.base = { GK110_DISP_BASE_CHANNEL_DMA   , &gp102_disp_base },
+		.core = { GP102_DISP_CORE_CHANNEL_DMA   , &gp102_disp_core },
+		.ovly = { GK104_DISP_OVERLAY_CONTROL_DMA, &gp102_disp_ovly },
 	},
 };
 
drivers/gpu/drm/nouveau/nvkm/engine/disp/gt200.c +6 -7
index 6f69c4e3ade2..b97970800a90 100644
@@ -90,14 +90,13 @@ gt200_disp = {
 	.dac = { .cnt = nv50_dac_cnt, .new = nv50_dac_new },
 	.sor = { .cnt = nv50_sor_cnt, .new = g84_sor_new },
 	.pior = { .cnt = nv50_pior_cnt, .new = nv50_pior_new },
-	.root = { 0,0,GT200_DISP },
 	.user = {
-		{{0,0,  G82_DISP_CURSOR             }, nvkm_disp_chan_new, & nv50_disp_curs },
-		{{0,0,  G82_DISP_OVERLAY            }, nvkm_disp_chan_new, & nv50_disp_oimm },
-		{{0,0,GT200_DISP_BASE_CHANNEL_DMA   }, nvkm_disp_chan_new, &  g84_disp_base },
-		{{0,0,GT200_DISP_CORE_CHANNEL_DMA   }, nvkm_disp_core_new, &  g84_disp_core },
-		{{0,0,GT200_DISP_OVERLAY_CHANNEL_DMA}, nvkm_disp_chan_new, &gt200_disp_ovly },
-		{}
+		.root = { GT200_DISP },
+		.curs = {   G82_DISP_CURSOR             , & nv50_disp_curs },
+		.oimm = {   G82_DISP_OVERLAY            , & nv50_disp_oimm },
+		.base = { GT200_DISP_BASE_CHANNEL_DMA   , &  g84_disp_base },
+		.core = { GT200_DISP_CORE_CHANNEL_DMA   , &  g84_disp_core },
+		.ovly = { GT200_DISP_OVERLAY_CHANNEL_DMA, &gt200_disp_ovly },
 	},
 };
 
drivers/gpu/drm/nouveau/nvkm/engine/disp/gt215.c +6 -7
index 6318721b66f6..ea75b23c38b3 100644
@@ -248,14 +248,13 @@ gt215_disp = {
 	.dac = { .cnt = nv50_dac_cnt, .new = nv50_dac_new },
 	.sor = { .cnt = g94_sor_cnt, .new = gt215_sor_new },
 	.pior = { .cnt = nv50_pior_cnt, .new = nv50_pior_new },
-	.root = { 0,0,GT214_DISP },
 	.user = {
-		{{0,0,GT214_DISP_CURSOR             }, nvkm_disp_chan_new, & nv50_disp_curs },
-		{{0,0,GT214_DISP_OVERLAY            }, nvkm_disp_chan_new, & nv50_disp_oimm },
-		{{0,0,GT214_DISP_BASE_CHANNEL_DMA   }, nvkm_disp_chan_new, &  g84_disp_base },
-		{{0,0,GT214_DISP_CORE_CHANNEL_DMA   }, nvkm_disp_core_new, &  g94_disp_core },
-		{{0,0,GT214_DISP_OVERLAY_CHANNEL_DMA}, nvkm_disp_chan_new, &  g84_disp_ovly },
-		{}
+		.root = { GT214_DISP },
+		.curs = { GT214_DISP_CURSOR             , & nv50_disp_curs },
+		.oimm = { GT214_DISP_OVERLAY            , & nv50_disp_oimm },
+		.base = { GT214_DISP_BASE_CHANNEL_DMA   , &  g84_disp_base },
+		.core = { GT214_DISP_CORE_CHANNEL_DMA   , &  g94_disp_core },
+		.ovly = { GT214_DISP_OVERLAY_CHANNEL_DMA, &  g84_disp_ovly },
 	},
 };
 
drivers/gpu/drm/nouveau/nvkm/engine/disp/gv100.c +6 -7
index 5787fd26e5c7..7876241e10e7 100644
@@ -1236,14 +1236,13 @@ gv100_disp = {
 	.head = { .cnt = gv100_head_cnt, .new = gv100_head_new },
 	.sor = { .cnt = gv100_sor_cnt, .new = gv100_sor_new },
 	.ramht_size = 0x2000,
-	.root = {  0, 0,GV100_DISP },
 	.user = {
-		{{-1,-1,GV100_DISP_CAPS                  }, gv100_disp_caps_new },
-		{{ 0, 0,GV100_DISP_CURSOR                },  nvkm_disp_chan_new, &gv100_disp_curs },
-		{{ 0, 0,GV100_DISP_WINDOW_IMM_CHANNEL_DMA},  nvkm_disp_wndw_new, &gv100_disp_wimm },
-		{{ 0, 0,GV100_DISP_CORE_CHANNEL_DMA      },  nvkm_disp_core_new, &gv100_disp_core },
-		{{ 0, 0,GV100_DISP_WINDOW_CHANNEL_DMA    },  nvkm_disp_wndw_new, &gv100_disp_wndw },
-		{}
+		.root = { GV100_DISP },
+		.caps = { GV100_DISP_CAPS                  ,  gv100_disp_caps_new },
+		.curs = { GV100_DISP_CURSOR                , &gv100_disp_curs },
+		.wimm = { GV100_DISP_WINDOW_IMM_CHANNEL_DMA, &gv100_disp_wimm },
+		.core = { GV100_DISP_CORE_CHANNEL_DMA      , &gv100_disp_core },
+		.wndw = { GV100_DISP_WINDOW_CHANNEL_DMA    , &gv100_disp_wndw },
 	},
 };
 
drivers/gpu/drm/nouveau/nvkm/engine/disp/mcp77.c +6 -7
index 841e3b69fcaf..3d065b77229b 100644
@@ -53,14 +53,13 @@ mcp77_disp = {
 	.dac = { .cnt = nv50_dac_cnt, .new = nv50_dac_new },
 	.sor = { .cnt = g94_sor_cnt, .new = mcp77_sor_new },
 	.pior = { .cnt = nv50_pior_cnt, .new = nv50_pior_new },
-	.root = { 0,0,GT206_DISP },
 	.user = {
-		{{0,0,  G82_DISP_CURSOR             }, nvkm_disp_chan_new, & nv50_disp_curs },
-		{{0,0,  G82_DISP_OVERLAY            }, nvkm_disp_chan_new, & nv50_disp_oimm },
-		{{0,0,GT200_DISP_BASE_CHANNEL_DMA   }, nvkm_disp_chan_new, &  g84_disp_base },
-		{{0,0,GT206_DISP_CORE_CHANNEL_DMA   }, nvkm_disp_core_new, &  g94_disp_core },
-		{{0,0,GT200_DISP_OVERLAY_CHANNEL_DMA}, nvkm_disp_chan_new, &gt200_disp_ovly },
-		{}
+		.root = { GT206_DISP },
+		.curs = {   G82_DISP_CURSOR             , & nv50_disp_curs },
+		.oimm = {   G82_DISP_OVERLAY            , & nv50_disp_oimm },
+		.base = { GT200_DISP_BASE_CHANNEL_DMA   , &  g84_disp_base },
+		.core = { GT206_DISP_CORE_CHANNEL_DMA   , &  g94_disp_core },
+		.ovly = { GT200_DISP_OVERLAY_CHANNEL_DMA, &gt200_disp_ovly },
 	},
 };
 
drivers/gpu/drm/nouveau/nvkm/engine/disp/mcp89.c +6 -7
index e0c5fb6df3d7..3b25c147c0c0 100644
@@ -68,14 +68,13 @@ mcp89_disp = {
 	.dac = { .cnt = nv50_dac_cnt, .new = nv50_dac_new },
 	.sor = { .cnt = g94_sor_cnt, .new = mcp89_sor_new },
 	.pior = { .cnt = nv50_pior_cnt, .new = nv50_pior_new },
-	.root = { 0,0,GT214_DISP },
 	.user = {
-		{{0,0,GT214_DISP_CURSOR             }, nvkm_disp_chan_new, &nv50_disp_curs },
-		{{0,0,GT214_DISP_OVERLAY            }, nvkm_disp_chan_new, &nv50_disp_oimm },
-		{{0,0,GT214_DISP_BASE_CHANNEL_DMA   }, nvkm_disp_chan_new, & g84_disp_base },
-		{{0,0,GT214_DISP_CORE_CHANNEL_DMA   }, nvkm_disp_core_new, & g94_disp_core },
-		{{0,0,GT214_DISP_OVERLAY_CHANNEL_DMA}, nvkm_disp_chan_new, & g84_disp_ovly },
-		{}
+		.root = { GT214_DISP },
+		.curs = { GT214_DISP_CURSOR             , &nv50_disp_curs },
+		.oimm = { GT214_DISP_OVERLAY            , &nv50_disp_oimm },
+		.base = { GT214_DISP_BASE_CHANNEL_DMA   , & g84_disp_base },
+		.core = { GT214_DISP_CORE_CHANNEL_DMA   , & g94_disp_core },
+		.ovly = { GT214_DISP_OVERLAY_CHANNEL_DMA, & g84_disp_ovly },
 	},
 };
 
drivers/gpu/drm/nouveau/nvkm/engine/disp/nv04.c +3 -2
index e4cf11a33969..7ba9c84b027c 100644
@@ -106,8 +106,9 @@ nv04_disp_intr(struct nvkm_disp *disp)
 static const struct nvkm_disp_func
 nv04_disp = {
 	.intr = nv04_disp_intr,
-	.root = { 0, 0, NV04_DISP },
-	.user = { {} },
+	.user = {
+		.root = { NV04_DISP },
+	}
 };
 
 int
drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.c +6 -7
index 682628fe5b20..0625f35bffec 100644
@@ -1771,14 +1771,13 @@ nv50_disp = {
 	.dac = { .cnt = nv50_dac_cnt, .new = nv50_dac_new },
 	.sor = { .cnt = nv50_sor_cnt, .new = nv50_sor_new },
 	.pior = { .cnt = nv50_pior_cnt, .new = nv50_pior_new },
-	.root = { 0, 0, NV50_DISP },
 	.user = {
-		{{0,0,NV50_DISP_CURSOR             }, nvkm_disp_chan_new, &nv50_disp_curs },
-		{{0,0,NV50_DISP_OVERLAY            }, nvkm_disp_chan_new, &nv50_disp_oimm },
-		{{0,0,NV50_DISP_BASE_CHANNEL_DMA   }, nvkm_disp_chan_new, &nv50_disp_base },
-		{{0,0,NV50_DISP_CORE_CHANNEL_DMA   }, nvkm_disp_core_new, &nv50_disp_core },
-		{{0,0,NV50_DISP_OVERLAY_CHANNEL_DMA}, nvkm_disp_chan_new, &nv50_disp_ovly },
-		{}
+		.root = { NV50_DISP },
+		.curs = { NV50_DISP_CURSOR             , &nv50_disp_curs },
+		.oimm = { NV50_DISP_OVERLAY            , &nv50_disp_oimm },
+		.base = { NV50_DISP_BASE_CHANNEL_DMA   , &nv50_disp_base },
+		.core = { NV50_DISP_CORE_CHANNEL_DMA   , &nv50_disp_core },
+		.ovly = { NV50_DISP_OVERLAY_CHANNEL_DMA, &nv50_disp_ovly },
 	}
 };
 
drivers/gpu/drm/nouveau/nvkm/engine/disp/priv.h +16 -8
index 6f0b119dfd90..82b16cc9212a 100644
@@ -35,14 +35,22 @@ struct nvkm_disp_func {
 
 	u16 ramht_size;
 
-	struct nvkm_sclass root;
-
-	struct nvkm_disp_user {
-		struct nvkm_sclass base;
-		int (*ctor)(const struct nvkm_oclass *, void *argv, u32 argc,
-			    struct nvkm_object **);
-		const struct nvkm_disp_chan_user *chan;
-	} user[];
+	struct {
+		struct {
+			s32 oclass;
+		} root;
+
+		struct {
+			s32 oclass;
+			int (*ctor)(const struct nvkm_oclass *, void *argv, u32 argc,
+				    struct nvkm_object **);
+		} caps;
+
+		struct nvkm_disp_func_chan {
+			s32 oclass;
+			const struct nvkm_disp_chan_user *chan;
+		} core, base, ovly, wndw, wimm, curs, oimm;
+	} user;
 };
 
 int nv50_disp_oneinit(struct nvkm_disp *);
drivers/gpu/drm/nouveau/nvkm/engine/disp/r535.c +8 -18
index f94858bc64f9..067e5e7177d6 100644
@@ -1417,8 +1417,8 @@ r535_disp_init(struct nvkm_disp *disp)
 {
 	int ret;
 
-	ret = nvkm_gsp_rm_alloc(&disp->rm.device.object, disp->func->root.oclass << 16,
-				disp->func->root.oclass, 0, &disp->rm.object);
+	ret = nvkm_gsp_rm_alloc(&disp->rm.device.object, disp->func->user.root.oclass << 16,
+				disp->func->user.root.oclass, 0, &disp->rm.object);
 	if (ret)
 		return ret;
 
@@ -1674,7 +1674,7 @@ r535_disp_new(const struct nvkm_disp_func *hw, struct nvkm_device *device,
 	struct nvkm_disp_func *rm;
 	int ret;
 
-	if (!(rm = kzalloc(sizeof(*rm) + 6 * sizeof(rm->user[0]), GFP_KERNEL)))
+	if (!(rm = kzalloc(sizeof(*rm), GFP_KERNEL)))
 		return -ENOMEM;
 
 	rm->dtor = r535_disp_dtor;
@@ -1685,21 +1685,11 @@ r535_disp_new(const struct nvkm_disp_func *hw, struct nvkm_device *device,
 	rm->sor.cnt = r535_sor_cnt;
 	rm->sor.new = r535_sor_new;
 	rm->ramht_size = hw->ramht_size;
-
-	rm->root = hw->root;
-
-	for (int i = 0; hw->user[i].ctor; i++) {
-		switch (hw->user[i].base.oclass & 0xff) {
-		case 0x73: rm->user[i] = hw->user[i]; break;
-		case 0x7d: rm->user[i] = hw->user[i]; rm->user[i].chan = &r535_core; break;
-		case 0x7e: rm->user[i] = hw->user[i]; rm->user[i].chan = &r535_wndw; break;
-		case 0x7b: rm->user[i] = hw->user[i]; rm->user[i].chan = &r535_wimm; break;
-		case 0x7a: rm->user[i] = hw->user[i]; rm->user[i].chan = &r535_curs; break;
-		default:
-			WARN_ON(1);
-			continue;
-		}
-	}
+	rm->user = hw->user;
+	rm->user.core.chan = &r535_core;
+	rm->user.wndw.chan = &r535_wndw;
+	rm->user.wimm.chan = &r535_wimm;
+	rm->user.curs.chan = &r535_curs;
 
 	ret = nvkm_disp_new_(rm, device, type, inst, pdisp);
 	if (ret)
drivers/gpu/drm/nouveau/nvkm/engine/disp/tu102.c +6 -7
index dcb9f8ba374c..21b945a88823 100644
@@ -219,14 +219,13 @@ tu102_disp = {
 	.head = { .cnt = gv100_head_cnt, .new = gv100_head_new },
 	.sor = { .cnt = gv100_sor_cnt, .new = tu102_sor_new },
 	.ramht_size = 0x2000,
-	.root = {  0, 0,TU102_DISP },
 	.user = {
-		{{-1,-1,GV100_DISP_CAPS                  }, gv100_disp_caps_new },
-		{{ 0, 0,TU102_DISP_CURSOR                },  nvkm_disp_chan_new, &gv100_disp_curs },
-		{{ 0, 0,TU102_DISP_WINDOW_IMM_CHANNEL_DMA},  nvkm_disp_wndw_new, &gv100_disp_wimm },
-		{{ 0, 0,TU102_DISP_CORE_CHANNEL_DMA      },  nvkm_disp_core_new, &gv100_disp_core },
-		{{ 0, 0,TU102_DISP_WINDOW_CHANNEL_DMA    },  nvkm_disp_wndw_new, &gv100_disp_wndw },
-		{}
+		.root = { TU102_DISP },
+		.caps = { GV100_DISP_CAPS                  ,  gv100_disp_caps_new },
+		.curs = { TU102_DISP_CURSOR                , &gv100_disp_curs },
+		.wimm = { TU102_DISP_WINDOW_IMM_CHANNEL_DMA, &gv100_disp_wimm },
+		.core = { TU102_DISP_CORE_CHANNEL_DMA      , &gv100_disp_core },
+		.wndw = { TU102_DISP_WINDOW_CHANNEL_DMA    , &gv100_disp_wndw },
 	},
 };
 
drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c +46 -3

61 lines not on this page · raw message

Signature · 1 line
2.41.0
author
#57 lore raw

PATCH 56/156 drm/nouveau/nvif: output oclass id in object dbg messages

In reply to Ben Skeggs

- useful to know sometimes

---
 drivers/gpu/drm/nouveau/include/nvif/printf.h | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/printf.h +5 -4
index ec524b2faeae..10d8c8c90fa7 100644
@@ -4,10 +4,11 @@
 #include <nvif/client.h>
 #include <nvif/parent.h>
 
-#define NVIF_PRINT(l,o,f,a...) do {                                                                \
-	struct nvif_object *_o = (o);                                                              \
-	struct nvif_parent *_p = _o->parent;                                                       \
-	_p->func->l(_o, "[%s/%08x:%s] "f"\n", _o->client->object.name, _o->handle, _o->name, ##a); \
+#define NVIF_PRINT(l,o,f,a...) do {                                         \
+	struct nvif_object *_o = (o);                                       \
+	struct nvif_parent *_p = _o->parent;                                \
+	_p->func->l(_o, "[%s/%08x:%08x:%s] "f"\n", _o->client->object.name, \
+		    _o->handle, _o->oclass, _o->name, ##a);                 \
 } while(0)
 
 #ifndef NVIF_DEBUG_PRINT_DISABLE
Signature · 1 line
2.41.0
author
#58 lore raw

PATCH 57/156 drm/nouveau/nvif: add alternate version of nvif_object_ctor()

In reply to Ben Skeggs

- callers will transition to new args in upcoming patches
- some macro trickery to avoid temporary renames, will be removed later

---
 drivers/gpu/drm/nouveau/dispnv50/core.c       | 12 ++++++------
 drivers/gpu/drm/nouveau/dispnv50/crc.c        |  4 ++--
 drivers/gpu/drm/nouveau/dispnv50/wndw.c       |  8 ++++----
 drivers/gpu/drm/nouveau/include/nvif/object.h | 12 ++++++++++--
 drivers/gpu/drm/nouveau/nouveau_drm.c         |  4 ++--
 drivers/gpu/drm/nouveau/nv17_fence.c          |  4 ++--
 drivers/gpu/drm/nouveau/nv50_fence.c          |  4 ++--
 drivers/gpu/drm/nouveau/nvif/object.c         | 18 ++++++++++++++++--
 8 files changed, 44 insertions(+), 22 deletions(-)
drivers/gpu/drm/nouveau/dispnv50/core.c +6 -6
index 1864f3e3bbc3..a9c3e53ef909 100644
@@ -84,24 +84,24 @@ nv50_core_new(struct nouveau_drm *drm, struct nv50_core **pcore)
 
 	ret = nvif_object_ctor(&core->chan.base.user, "kmsCoreSyncCtxdma", NV50_DISP_HANDLE_SYNCBUF,
 			       NV_DMA_IN_MEMORY,
-			       &(struct nv_dma_v0) {
+			       (&(struct nv_dma_v0) {
 					.target = NV_DMA_V0_TARGET_VRAM,
 					.access = NV_DMA_V0_ACCESS_RDWR,
 					.start = disp->sync->offset + 0x0000,
-					.limit = disp->sync->offset + 0x0fff,
-			       }, sizeof(struct nv_dma_v0),
+					.limit = disp->sync->offset + 0x0fff
+			       }), sizeof(struct nv_dma_v0),
 			       &core->sync);
 	if (ret)
 		return ret;
 
 	ret = nvif_object_ctor(&core->chan.base.user, "kmsCoreVramCtxdma", NV50_DISP_HANDLE_VRAM,
 			       NV_DMA_IN_MEMORY,
-			       &(struct nv_dma_v0) {
+			       (&(struct nv_dma_v0) {
 					.target = NV_DMA_V0_TARGET_VRAM,
 					.access = NV_DMA_V0_ACCESS_RDWR,
 					.start = 0,
-					.limit = drm->device.info.ram_user - 1,
-			       }, sizeof(struct nv_dma_v0),
+					.limit = drm->device.info.ram_user - 1
+			       }), sizeof(struct nv_dma_v0),
 			       &core->vram);
 	if (ret)
 		return ret;
drivers/gpu/drm/nouveau/dispnv50/crc.c +2 -2
index 9c942fbd836d..0864d36a06f2 100644
@@ -510,13 +510,13 @@ nv50_crc_ctx_init(struct nv50_head *head, struct nvif_mmu *mmu,
 	ret = nvif_object_ctor(&core->chan.base.user, "kmsCrcNtfyCtxDma",
 			       NV50_DISP_HANDLE_CRC_CTX(head, idx),
 			       NV_DMA_IN_MEMORY,
-			       &(struct nv_dma_v0) {
+			       (&(struct nv_dma_v0) {
 					.target = NV_DMA_V0_TARGET_VRAM,
 					.access = NV_DMA_V0_ACCESS_RDWR,
 					.start = ctx->mem.addr,
 					.limit =  ctx->mem.addr
 						+ ctx->mem.size - 1,
-			       }, sizeof(struct nv_dma_v0),
+			       }), sizeof(struct nv_dma_v0),
 			       &ctx->ntfy);
 	if (ret)
 		goto fail_fini;
drivers/gpu/drm/nouveau/dispnv50/wndw.c +4 -4
index 1dbf0e73b5de..19606755daf5 100644
@@ -707,24 +707,24 @@ nv50_wndw_ctor(struct nv50_wndw *wndw)
 
 	ret = nvif_object_ctor(&wndw->wndw.base.user, "kmsWndwSyncCtxDma", NV50_DISP_HANDLE_SYNCBUF,
 			       NV_DMA_IN_MEMORY,
-			       &(struct nv_dma_v0) {
+			       (&(struct nv_dma_v0) {
 					.target = NV_DMA_V0_TARGET_VRAM,
 					.access = NV_DMA_V0_ACCESS_RDWR,
 					.start = disp->sync->offset + 0x0000,
 					.limit = disp->sync->offset + 0x0fff,
-			       }, sizeof(struct nv_dma_v0),
+			       }), sizeof(struct nv_dma_v0),
 			       &wndw->sync);
 	if (ret)
 		return ret;
 
 	ret = nvif_object_ctor(&wndw->wndw.base.user, "kmsWndwVramCtxDma", NV50_DISP_HANDLE_VRAM,
 			       NV_DMA_IN_MEMORY,
-			       &(struct nv_dma_v0) {
+			       (&(struct nv_dma_v0) {
 					.target = NV_DMA_V0_TARGET_VRAM,
 					.access = NV_DMA_V0_ACCESS_RDWR,
 					.start = 0,
 					.limit = drm->device.info.ram_user - 1,
-			       }, sizeof(struct nv_dma_v0),
+			       }), sizeof(struct nv_dma_v0),
 			       &wndw->vram);
 	if (ret)
 		return ret;
drivers/gpu/drm/nouveau/include/nvif/object.h +10 -2
index 8d205b6af46a..a84cdb423471 100644
@@ -28,8 +28,16 @@ nvif_object_constructed(struct nvif_object *object)
 	return object->client != NULL;
 }
 
-int  nvif_object_ctor(struct nvif_object *, const char *name, u32 handle,
-		      s32 oclass, void *, u32, struct nvif_object *);
+int nvif_object_ctor_0(struct nvif_object *, const char *name, u32 handle,
+		       s32 oclass, void *, u32, struct nvif_object *);
+void nvif_object_ctor_1(struct nvif_object *parent, const char *name, u32 handle, s32 oclass,
+			struct nvif_object *);
+
+#define nvif_object_ctor_(A,B,C,D,E,F,G,IMPL,...) IMPL
+#define nvif_object_ctor(A...) nvif_object_ctor_(A, nvif_object_ctor_0, \
+						    nvif_object_ctor__, \
+						    nvif_object_ctor_1)(A)
+
 void nvif_object_dtor(struct nvif_object *);
 int  nvif_object_ioctl(struct nvif_object *, void *, u32, void **);
 int  nvif_object_sclass_get(struct nvif_object *, struct nvif_sclass **);
drivers/gpu/drm/nouveau/nouveau_drm.c +2 -2
index 9caadcdb3c29..9c6df2ba52d5 100644
@@ -420,12 +420,12 @@ nouveau_accel_gr_init(struct nouveau_drm *drm)
 
 		ret = nvif_object_ctor(&drm->channel->user, "drmM2mfNtfy",
 				       NvNotify0, NV_DMA_IN_MEMORY,
-				       &(struct nv_dma_v0) {
+				       (&(struct nv_dma_v0) {
 						.target = NV_DMA_V0_TARGET_VRAM,
 						.access = NV_DMA_V0_ACCESS_RDWR,
 						.start = drm->notify->addr,
 						.limit = drm->notify->addr + 31
-				       }, sizeof(struct nv_dma_v0),
+				       }), sizeof(struct nv_dma_v0),
 				       &drm->ntfy);
 		if (ret) {
 			nouveau_accel_gr_fini(drm);
drivers/gpu/drm/nouveau/nv17_fence.c +2 -2
index 4415a6de680b..5b4ceac49225 100644
@@ -94,12 +94,12 @@ nv17_fence_context_new(struct nouveau_channel *chan)
 
 	ret = nvif_object_ctor(&chan->user, "fenceCtxDma", NvSema,
 			       NV_DMA_FROM_MEMORY,
-			       &(struct nv_dma_v0) {
+			       (&(struct nv_dma_v0) {
 					.target = NV_DMA_V0_TARGET_VRAM,
 					.access = NV_DMA_V0_ACCESS_RDWR,
 					.start = start,
 					.limit = limit,
-			       }, sizeof(struct nv_dma_v0),
+			       }), sizeof(struct nv_dma_v0),
 			       &fctx->sema);
 	if (ret)
 		nv10_fence_context_del(chan);
drivers/gpu/drm/nouveau/nv50_fence.c +2 -2
index 8b76cb227f55..1d8792fdd89b 100644
@@ -53,12 +53,12 @@ nv50_fence_context_new(struct nouveau_channel *chan)
 
 	ret = nvif_object_ctor(&chan->user, "fenceCtxDma", NvSema,
 			       NV_DMA_IN_MEMORY,
-			       &(struct nv_dma_v0) {
+			       (&(struct nv_dma_v0) {
 					.target = NV_DMA_V0_TARGET_VRAM,
 					.access = NV_DMA_V0_ACCESS_RDWR,
 					.start = start,
 					.limit = limit,
-			       }, sizeof(struct nv_dma_v0),
+			       }), sizeof(struct nv_dma_v0),
 			       &fctx->sema);
 	if (ret)
 		nv10_fence_context_del(chan);
drivers/gpu/drm/nouveau/nvif/object.c +16 -2
index 8a2a7bfec2f8..0e8340710c11 100644
@@ -220,9 +220,23 @@ nvif_object_dtor(struct nvif_object *object)
 	object->client = NULL;
 }
 
+void
+nvif_object_ctor_1(struct nvif_object *parent, const char *name, u32 handle, s32 oclass,
+		   struct nvif_object *object)
+{
+	object->parent = parent->parent;
+	object->client = parent->client;
+	object->name = name ?: "nvifObject";
+	object->handle = handle;
+	object->oclass = oclass;
+	object->priv = NULL;
+	object->map.ptr = NULL;
+	object->map.size = 0;
+}
+
 int
-nvif_object_ctor(struct nvif_object *parent, const char *name, u32 handle,
-		 s32 oclass, void *data, u32 size, struct nvif_object *object)
+nvif_object_ctor_0(struct nvif_object *parent, const char *name, u32 handle,
+		   s32 oclass, void *data, u32 size, struct nvif_object *object)
 {
 	struct {
 		struct nvif_ioctl_v0 ioctl;
Signature · 1 line
2.41.0
author
#59 lore raw

PATCH 58/156 drm/nouveau/nvif: add alternate version of nvif_event_ctor()

In reply to Ben Skeggs

- callers will transition to new args in upcoming patches
- some macro trickery to avoid temporary renames, will be removed later

---
 drivers/gpu/drm/nouveau/include/nvif/event.h | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/event.h +16 -2
index 68bf6635841f..1683e138c7f8 100644
@@ -24,12 +24,26 @@ int nvif_event_ctor_(struct nvif_object *, const char *, u32, nvif_event_func, b
 		     struct nvif_event_v0 *, u32, bool, struct nvif_event *);
 
 static inline int
-nvif_event_ctor(struct nvif_object *parent, const char *name, u32 handle, nvif_event_func func,
-		bool wait, struct nvif_event_v0 *args, u32 argc, struct nvif_event *event)
+nvif_event_ctor_0(struct nvif_object *parent, const char *name, u32 handle, nvif_event_func func,
+		  bool wait, struct nvif_event_v0 *args, u32 argc, struct nvif_event *event)
 {
 	return nvif_event_ctor_(parent, name, handle, func, wait, args, argc, true, event);
 }
 
+static inline void
+nvif_event_ctor_1(struct nvif_object *parent, const char *name, u32 handle,
+		  nvif_event_func func, struct nvif_event *event)
+{
+	nvif_object_ctor(parent, name ?: "nvifEvent", handle, 0, &event->object);
+	event->func = func;
+}
+
+#define nvif_event_ctor__(A,B,C,D,E,F,G,H,IMPL,...) IMPL
+#define nvif_event_ctor(A...) nvif_event_ctor__(A, nvif_event_ctor_0, \
+						   nvif_event_ctor__, \
+						   nvif_event_ctor__, \
+						   nvif_event_ctor_1)(A)
+
 void nvif_event_dtor(struct nvif_event *);
 int nvif_event_allow(struct nvif_event *);
 int nvif_event_block(struct nvif_event *);
Signature · 1 line
2.41.0
author
#60 lore raw

PATCH 59/156 drm/nouveau/nvif: move nvif<->nvkm interface definitions to driverif.h

In reply to Ben Skeggs

- "ioctl" interfaces will also be moved here in subsequent patches

---
 drivers/gpu/drm/nouveau/include/nvif/driver.h   | 11 -----------
 drivers/gpu/drm/nouveau/include/nvif/driverif.h | 15 +++++++++++++++
 drivers/gpu/drm/nouveau/nvif/client.c           |  1 +
 drivers/gpu/drm/nouveau/nvif/driver.c           |  1 +
 drivers/gpu/drm/nouveau/nvif/object.c           |  2 +-
 drivers/gpu/drm/nouveau/nvkm/core/driver.c      |  2 +-
 6 files changed, 19 insertions(+), 13 deletions(-)
 create mode 100644 drivers/gpu/drm/nouveau/include/nvif/driverif.h
drivers/gpu/drm/nouveau/include/nvif/driver.h +0 -11
index 7b08ff769039..c31fc66a4765 100644
@@ -4,17 +4,6 @@
 #include <nvif/os.h>
 struct nvif_client;
 
-struct nvif_driver {
-	const char *name;
-	int (*init)(const char *name, u64 device, const char *cfg,
-		    const char *dbg, void **priv);
-	int (*suspend)(void *priv);
-	int (*resume)(void *priv);
-	int (*ioctl)(void *priv, void *data, u32 size, void **hack);
-	void __iomem *(*map)(void *priv, u64 handle, u32 size);
-	void (*unmap)(void *priv, void __iomem *ptr, u32 size);
-};
-
 int nvif_driver_init(const char *drv, const char *cfg, const char *dbg,
 		     const char *name, u64 device, struct nvif_client *);
 
drivers/gpu/drm/nouveau/include/nvif/driverif.h new file +15 -0
new file mode 100644
index 000000000000..c5018452d372
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: MIT */
+#ifndef __NVIF_DRIVERIF_H__
+#define __NVIF_DRIVERIF_H__
+
+struct nvif_driver {
+	const char *name;
+	int (*init)(const char *name, u64 device, const char *cfg,
+		    const char *dbg, void **priv);
+	int (*suspend)(void *priv);
+	int (*resume)(void *priv);
+	int (*ioctl)(void *priv, void *data, u32 size, void **hack);
+	void __iomem *(*map)(void *priv, u64 handle, u32 size);
+	void (*unmap)(void *priv, void __iomem *ptr, u32 size);
+};
+#endif
drivers/gpu/drm/nouveau/nvif/client.c +1 -0
index 098831d92eac..c0f93f4df2bb 100644
@@ -24,6 +24,7 @@
 
 #include <nvif/client.h>
 #include <nvif/driver.h>
+#include <nvif/driverif.h>
 #include <nvif/ioctl.h>
 
 #include <nvif/class.h>
drivers/gpu/drm/nouveau/nvif/driver.c +1 -0
index acb708df2559..4548ed35c31e 100644
@@ -22,6 +22,7 @@
  * Authors: Ben Skeggs
  */
 #include <nvif/driver.h>
+#include <nvif/driverif.h>
 #include <nvif/client.h>
 
 int
drivers/gpu/drm/nouveau/nvif/object.c +1 -1
index 0e8340710c11..a71e000ada91 100644
@@ -24,7 +24,7 @@
 
 #include <nvif/object.h>
 #include <nvif/client.h>
-#include <nvif/driver.h>
+#include <nvif/driverif.h>
 #include <nvif/ioctl.h>
 
 int
drivers/gpu/drm/nouveau/nvkm/core/driver.c +1 -1
index 1f5273ff2225..0777b9af0656 100644
@@ -30,7 +30,7 @@
 #include <core/event.h>
 #include <core/ioctl.h>
 
-#include <nvif/driver.h>
+#include <nvif/driverif.h>
 #include <nvif/event.h>
 
 static void
Signature · 1 line
2.41.0
author
#61 lore raw

PATCH 60/156 drm/nouveau/nvif: rework "new driver" api

In reply to Ben Skeggs

- cleans up init of first nvkm client ("driver")

---
 drivers/gpu/drm/nouveau/include/nvif/client.h |  3 ++
 drivers/gpu/drm/nouveau/include/nvif/driver.h | 11 +++--
 .../gpu/drm/nouveau/include/nvif/driverif.h   | 15 ++++---
 .../drm/nouveau/include/nvkm/core/client.h    | 10 +++--
 .../drm/nouveau/include/nvkm/core/driver.h    |  9 ++++
 .../gpu/drm/nouveau/include/nvkm/core/os.h    |  1 +
 drivers/gpu/drm/nouveau/nouveau_drm.c         |  9 +++-
 drivers/gpu/drm/nouveau/nvif/client.c         | 14 ++++--
 drivers/gpu/drm/nouveau/nvif/driver.c         | 22 +++++-----
 drivers/gpu/drm/nouveau/nvif/object.c         |  6 +--
 drivers/gpu/drm/nouveau/nvkm/core/client.c    | 24 ++++++++---
 drivers/gpu/drm/nouveau/nvkm/core/driver.c    | 43 +++++++++++--------
 drivers/gpu/drm/nouveau/nvkm/device/user.c    |  6 +--
 13 files changed, 112 insertions(+), 61 deletions(-)
 create mode 100644 drivers/gpu/drm/nouveau/include/nvkm/core/driver.h
drivers/gpu/drm/nouveau/include/nvif/client.h +3 -0
index 87dc55f8bde6..f8e4e25d6e86 100644
@@ -5,7 +5,10 @@
 #include <nvif/object.h>
 
 struct nvif_client {
+	const struct nvif_client_impl *impl;
+	struct nvif_client_priv *priv;
 	struct nvif_object object;
+
 	const struct nvif_driver *driver;
 };
 
drivers/gpu/drm/nouveau/include/nvif/driver.h +7 -4
index c31fc66a4765..8ca210b0bca6 100644
@@ -2,10 +2,13 @@
 #ifndef __NVIF_DRIVER_H__
 #define __NVIF_DRIVER_H__
 #include <nvif/os.h>
+struct nvif_parent;
+struct nvif_driver;
+struct nvif_client_impl;
+struct nvif_client_priv;
 struct nvif_client;
 
-int nvif_driver_init(const char *drv, const char *cfg, const char *dbg,
-		     const char *name, u64 device, struct nvif_client *);
-
-extern const struct nvif_driver nvif_driver_nvkm;
+void nvif_driver_ctor(struct nvif_parent *, const struct nvif_driver *, const char *name,
+		      const struct nvif_client_impl *, struct nvif_client_priv *,
+		      struct nvif_client *);
 #endif
drivers/gpu/drm/nouveau/include/nvif/driverif.h +9 -6
index c5018452d372..655bd389044d 100644
@@ -1,15 +1,18 @@
 /* SPDX-License-Identifier: MIT */
 #ifndef __NVIF_DRIVERIF_H__
 #define __NVIF_DRIVERIF_H__
+struct nvif_client_priv;
 
 struct nvif_driver {
 	const char *name;
-	int (*init)(const char *name, u64 device, const char *cfg,
-		    const char *dbg, void **priv);
-	int (*suspend)(void *priv);
-	int (*resume)(void *priv);
+	int (*suspend)(struct nvif_client_priv *);
+	int (*resume)(struct nvif_client_priv *);
 	int (*ioctl)(void *priv, void *data, u32 size, void **hack);
-	void __iomem *(*map)(void *priv, u64 handle, u32 size);
-	void (*unmap)(void *priv, void __iomem *ptr, u32 size);
+	void __iomem *(*map)(struct nvif_client_priv *, u64 handle, u32 size);
+	void (*unmap)(struct nvif_client_priv *, void __iomem *ptr, u32 size);
+};
+
+struct nvif_client_impl {
+	void (*del)(struct nvif_client_priv *);
 };
 #endif
drivers/gpu/drm/nouveau/include/nvkm/core/client.h +7 -3
index f7f195d87838..e35aea7a751f 100644
@@ -3,10 +3,12 @@
 #define __NVKM_CLIENT_H__
 #include <core/object.h>
 
+#include <nvif/driverif.h>
+
 struct nvkm_client {
 	struct nvkm_object object;
 	char name[32];
-	u64 device;
+	struct nvkm_device *device;
 	u32 debug;
 
 	struct rb_root objroot;
@@ -16,8 +18,10 @@ struct nvkm_client {
 	int (*event)(u64 token, void *argv, u32 argc);
 };
 
-int  nvkm_client_new(const char *name, u64 device, const char *cfg, const char *dbg,
-		     int (*)(u64, void *, u32), struct nvkm_client **);
+int nvkm_client_new(const char *name, struct nvkm_device *, int (*event)(u64, void *, u32),
+		    struct nvif_client_priv **);
+
+extern const struct nvif_client_impl nvkm_client_impl;
 
 /* logging for client-facing objects */
 #define nvif_printk(o,l,p,f,a...) do {                                         \
drivers/gpu/drm/nouveau/include/nvkm/core/driver.h new file +9 -0
new file mode 100644
index 000000000000..8ad2278e700a
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: MIT */
+#ifndef __NVKM_DRIVER_H__
+#define __NVKM_DRIVER_H__
+#include <nvif/driverif.h>
+struct nvkm_device;
+
+int nvkm_driver_ctor(struct nvkm_device *, const struct nvif_driver **,
+		     const struct nvif_client_impl **, struct nvif_client_priv **);
+#endif
drivers/gpu/drm/nouveau/include/nvkm/core/os.h +1 -0
index 668338d7bda3..9d16413239d4 100644
@@ -32,4 +32,5 @@ nvkm_blob_dtor(struct nvkm_blob *blob)
 	for (p = nvkm_list_find(p, (h), m, (c)); p; p = nvkm_list_find_next(p, (h), m, (c)))
 
 #define nvkm_uevent nvif_event_priv
+#define nvkm_client nvif_client_priv
 #endif
drivers/gpu/drm/nouveau/nouveau_drm.c +7 -2
index 9c6df2ba52d5..d793afd929c9 100644
@@ -37,6 +37,7 @@
 #include <drm/drm_ioctl.h>
 #include <drm/drm_vblank.h>
 
+#include <core/driver.h>
 #include <core/gpuobj.h>
 #include <core/option.h>
 #include <core/pci.h>
@@ -567,6 +568,9 @@ nouveau_drm_device_init(struct drm_device *dev, struct nvkm_device *nvkm)
 		{}
 	};
 	struct nouveau_drm *drm;
+	const struct nvif_driver *driver;
+	const struct nvif_client_impl *impl;
+	struct nvif_client_priv *priv;
 	int ret;
 
 	if (!(drm = kzalloc(sizeof(*drm), GFP_KERNEL)))
@@ -580,11 +584,12 @@ nouveau_drm_device_init(struct drm_device *dev, struct nvkm_device *nvkm)
 	mutex_init(&drm->client_mutex);
 	drm->_client.object.parent = &drm->parent;
 
-	ret = nvif_driver_init(NULL, nouveau_config, nouveau_debug, "drm", nouveau_name(dev),
-			       &drm->_client);
+	ret = nvkm_driver_ctor(drm->nvkm, &driver, &impl, &priv);
 	if (ret)
 		goto fail_alloc;
 
+	nvif_driver_ctor(&drm->parent, driver, "drm", impl, priv, &drm->_client);
+
 	ret = nvif_device_ctor(&drm->_client, "drmDevice", &drm->device);
 	if (ret) {
 		NV_ERROR(drm, "Device allocation failed: %d\n", ret);
drivers/gpu/drm/nouveau/nvif/client.c +11 -3
index c0f93f4df2bb..4c4a856ab861 100644
@@ -33,19 +33,27 @@
 int
 nvif_client_suspend(struct nvif_client *client)
 {
-	return client->driver->suspend(client->object.priv);
+	return client->driver->suspend(client->priv);
 }
 
 int
 nvif_client_resume(struct nvif_client *client)
 {
-	return client->driver->resume(client->object.priv);
+	return client->driver->resume(client->priv);
 }
 
 void
 nvif_client_dtor(struct nvif_client *client)
 {
-	nvif_object_dtor(&client->object);
+	if (!client->impl) {
+		nvif_object_dtor(&client->object);
+		client->driver = NULL;
+		return;
+	}
+
+	client->impl->del(client->priv);
+	client->impl = NULL;
+	client->object.client = NULL;
 	client->driver = NULL;
 }
 
drivers/gpu/drm/nouveau/nvif/driver.c +11 -11
index 4548ed35c31e..95515f2023f4 100644
@@ -25,17 +25,17 @@
 #include <nvif/driverif.h>
 #include <nvif/client.h>
 
-int
-nvif_driver_init(const char *drv, const char *cfg, const char *dbg,
-		 const char *name, u64 device, struct nvif_client *client)
+void
+nvif_driver_ctor(struct nvif_parent *parent, const struct nvif_driver *driver, const char *name,
+		 const struct nvif_client_impl *impl, struct nvif_client_priv *priv,
+		 struct nvif_client *client)
 {
-	int ret;
+	client->object.parent = parent;
+	client->object.client = client;
 
-	client->driver = &nvif_driver_nvkm;
-
-	ret = client->driver->init(name, device, cfg, dbg, &client->object.priv);
-	if (ret)
-		return ret;
-
-	return nvif_client_ctor(client, name, device, client);
+	nvif_object_ctor(&client->object, name ?: "nvifDriver", 0, 0, &client->object);
+	client->object.priv = priv;
+	client->driver = driver;
+	client->impl = impl;
+	client->priv = priv;
 }
drivers/gpu/drm/nouveau/nvif/object.c +3 -3
index a71e000ada91..f172f632979b 100644
@@ -169,8 +169,8 @@ nvif_object_unmap(struct nvif_object *object)
 	struct nvif_client *client = object->client;
 	if (object->map.ptr) {
 		if (object->map.size) {
-			client->driver->unmap(client, object->map.ptr,
-						      object->map.size);
+			client->driver->unmap(client->object.priv, object->map.ptr,
+								   object->map.size);
 			object->map.size = 0;
 		}
 		object->map.ptr = NULL;
@@ -186,7 +186,7 @@ nvif_object_map(struct nvif_object *object, void *argv, u32 argc)
 	int ret = nvif_object_map_handle(object, argv, argc, &handle, &length);
 	if (ret >= 0) {
 		if (ret) {
-			object->map.ptr = client->driver->map(client,
+			object->map.ptr = client->driver->map(client->object.priv,
 							      handle,
 							      length);
 			if (ret = -ENOMEM, object->map.ptr) {
drivers/gpu/drm/nouveau/nvkm/core/client.c +19 -5
index 7dc425e67dd4..fa8d0795805e 100644
@@ -26,6 +26,7 @@
 #include <core/option.h>
 
 #include <nvif/class.h>
+#include <nvif/driverif.h>
 #include <nvif/event.h>
 #include <nvif/if0000.h>
 #include <nvif/unpack.h>
@@ -42,8 +43,8 @@ nvkm_uclient_new(const struct nvkm_oclass *oclass, void *argv, u32 argc,
 
 	if (!(ret = nvif_unpack(ret, &argv, &argc, args->v0, 0, 0, false))){
 		args->v0.name[sizeof(args->v0.name) - 1] = 0;
-		ret = nvkm_client_new(args->v0.name, args->v0.device, NULL,
-				      NULL, oclass->client->event, &client);
+		ret = nvkm_client_new(args->v0.name, oclass->client->device,
+				      oclass->client->event, &client);
 		if (ret)
 			return ret;
 	} else
@@ -65,6 +66,19 @@ nvkm_uclient_sclass = {
 	.ctor = nvkm_uclient_new,
 };
 
+static void
+nvkm_client_del(struct nvif_client_priv *client)
+{
+	struct nvkm_object *object = &client->object;
+
+	nvkm_object_del(&object);
+}
+
+const struct nvif_client_impl
+nvkm_client_impl = {
+	.del = nvkm_client_del,
+};
+
 static int
 nvkm_client_child_new(const struct nvkm_oclass *oclass,
 		      void *data, u32 size, struct nvkm_object **pobject)
@@ -103,8 +117,8 @@ nvkm_client = {
 };
 
 int
-nvkm_client_new(const char *name, u64 device, const char *cfg, const char *dbg,
-		int (*event)(u64, void *, u32), struct nvkm_client **pclient)
+nvkm_client_new(const char *name, struct nvkm_device *device, int (*event)(u64, void *, u32),
+		struct nvif_client_priv **pclient)
 {
 	struct nvkm_oclass oclass = { .base = nvkm_uclient_sclass };
 	struct nvkm_client *client;
@@ -116,7 +130,7 @@ nvkm_client_new(const char *name, u64 device, const char *cfg, const char *dbg,
 	nvkm_object_ctor(&nvkm_client, &oclass, &client->object);
 	snprintf(client->name, sizeof(client->name), "%s", name);
 	client->device = device;
-	client->debug = nvkm_dbgopt(dbg, "CLIENT");
+	client->debug = NV_DBG_ERROR;
 	client->objroot = RB_ROOT;
 	spin_lock_init(&client->obj_lock);
 	client->event = event;
drivers/gpu/drm/nouveau/nvkm/core/driver.c +24 -19

83 lines not on this page · raw message

drivers/gpu/drm/nouveau/nvkm/device/user.c +1 -5
index af5aa9e1e5ea..b30b2e1c590a 100644
@@ -330,11 +330,7 @@ nvkm_udevice_new(const struct nvkm_oclass *oclass, void *data, u32 size,
 	nvkm_object_ctor(&nvkm_udevice, oclass, &udev->object);
 	*pobject = &udev->object;
 
-	/* find the device that matches what the client requested */
-	udev->device = nvkm_device_find(client->device);
-	if (!udev->device)
-		return -ENODEV;
-
+	udev->device = client->device;
 	return 0;
 }
 
Signature · 1 line
2.41.0
author
#62 lore raw

PATCH 61/156 drm/nouveau/nvkm: remove device list

In reply to Ben Skeggs

- now unused

---
 .../drm/nouveau/include/nvkm/core/device.h    |  3 --
 drivers/gpu/drm/nouveau/nvkm/device/base.c    | 34 -------------------
 2 files changed, 37 deletions(-)
drivers/gpu/drm/nouveau/include/nvkm/core/device.h +0 -3
index 46afb877a296..efe1a0048328 100644
@@ -22,7 +22,6 @@ struct nvkm_device {
 	const char *cfgopt;
 	const char *dbgopt;
 
-	struct list_head head;
 	struct mutex mutex;
 	int refcount;
 
@@ -108,8 +107,6 @@ struct nvkm_device_chip {
 #undef NVKM_LAYOUT_ONCE
 };
 
-struct nvkm_device *nvkm_device_find(u64 name);
-
 /* privileged register interface accessor macros */
 #define nvkm_rd08(d,a) ioread8((d)->pri + (a))
 #define nvkm_rd16(d,a) ioread16_native((d)->pri + (a))
drivers/gpu/drm/nouveau/nvkm/device/base.c +0 -34
index 3ce42de55aa9..036106ed09a5 100644
@@ -29,30 +29,6 @@
 #include <subdev/bios.h>
 #include <subdev/therm.h>
 
-static DEFINE_MUTEX(nv_devices_mutex);
-static LIST_HEAD(nv_devices);
-
-static struct nvkm_device *
-nvkm_device_find_locked(u64 handle)
-{
-	struct nvkm_device *device;
-	list_for_each_entry(device, &nv_devices, head) {
-		if (device->handle == handle)
-			return device;
-	}
-	return NULL;
-}
-
-struct nvkm_device *
-nvkm_device_find(u64 handle)
-{
-	struct nvkm_device *device;
-	mutex_lock(&nv_devices_mutex);
-	device = nvkm_device_find_locked(handle);
-	mutex_unlock(&nv_devices_mutex);
-	return device;
-}
-
 static const struct nvkm_device_chip
 nv4_chipset = {
 	.name = "NV04",
@@ -2946,8 +2922,6 @@ nvkm_device_del(struct nvkm_device **pdevice)
 	struct nvkm_device *device = *pdevice;
 	struct nvkm_subdev *subdev, *subtmp;
 	if (device) {
-		mutex_lock(&nv_devices_mutex);
-
 		nvkm_intr_dtor(device);
 
 		list_for_each_entry_safe_reverse(subdev, subtmp, &device->subdev, head)
@@ -2955,11 +2929,9 @@ nvkm_device_del(struct nvkm_device **pdevice)
 
 		if (device->pri)
 			iounmap(device->pri);
-		list_del(&device->head);
 
 		if (device->func->dtor)
 			*pdevice = device->func->dtor(device);
-		mutex_unlock(&nv_devices_mutex);
 
 		kfree(*pdevice);
 		*pdevice = NULL;
@@ -3010,10 +2982,6 @@ nvkm_device_ctor(const struct nvkm_device_func *func,
 	int ret = -EEXIST, j;
 	unsigned chipset;
 
-	mutex_lock(&nv_devices_mutex);
-	if (nvkm_device_find_locked(handle))
-		goto done;
-
 	device->func = func;
 	device->quirk = quirk;
 	device->dev = dev;
@@ -3022,7 +2990,6 @@ nvkm_device_ctor(const struct nvkm_device_func *func,
 	device->cfgopt = cfg;
 	device->dbgopt = dbg;
 	device->name = name;
-	list_add_tail(&device->head, &nv_devices);
 	device->debug = nvkm_dbgopt(device->dbgopt, "device");
 	INIT_LIST_HEAD(&device->subdev);
 
@@ -3305,6 +3272,5 @@ nvkm_device_ctor(const struct nvkm_device_func *func,
 		iounmap(device->pri);
 		device->pri = NULL;
 	}
-	mutex_unlock(&nv_devices_mutex);
 	return ret;
 }
Signature · 1 line
2.41.0
author
#63 lore raw

PATCH 62/156 drm/nouveau/nvif: rework driver "new client" api

In reply to Ben Skeggs

- transition from "ioctl" interface

---
 drivers/gpu/drm/nouveau/include/nvif/class.h  |  2 -
 drivers/gpu/drm/nouveau/include/nvif/client.h |  3 +-
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  6 +++
 drivers/gpu/drm/nouveau/include/nvif/if0000.h | 11 -----
 .../drm/nouveau/include/nvkm/core/object.h    | 10 ++++
 drivers/gpu/drm/nouveau/nouveau_drm.c         | 28 +----------
 drivers/gpu/drm/nouveau/nvif/client.c         | 26 +++--------
 drivers/gpu/drm/nouveau/nvkm/core/client.c    | 46 ++++++-------------
 drivers/gpu/drm/nouveau/nvkm/core/object.c    | 33 +++++++++++++
 9 files changed, 72 insertions(+), 93 deletions(-)
 delete mode 100644 drivers/gpu/drm/nouveau/include/nvif/if0000.h
drivers/gpu/drm/nouveau/include/nvif/class.h +0 -2
index 824e052dcc25..b6bba7231750 100644
@@ -3,8 +3,6 @@
 #define __NVIF_CLASS_H__
 
 /* these class numbers are made up by us, and not nvidia-assigned */
-#define NVIF_CLASS_CLIENT                            /* if0000.h */ -0x00000000
-
 #define NVIF_CLASS_CONTROL                           /* if0001.h */ -0x00000001
 
 #define NVIF_CLASS_SW_NV04                           /* if0004.h */ -0x00000004
drivers/gpu/drm/nouveau/include/nvif/client.h +1 -2
index f8e4e25d6e86..1659e989df52 100644
@@ -12,8 +12,7 @@ struct nvif_client {
 	const struct nvif_driver *driver;
 };
 
-int  nvif_client_ctor(struct nvif_client *parent, const char *name, u64 device,
-		      struct nvif_client *);
+int  nvif_client_ctor(struct nvif_client *parent, const char *name, struct nvif_client *);
 void nvif_client_dtor(struct nvif_client *);
 int  nvif_client_suspend(struct nvif_client *);
 int  nvif_client_resume(struct nvif_client *);
drivers/gpu/drm/nouveau/include/nvif/driverif.h +6 -0
index 655bd389044d..a6f95c8475b1 100644
@@ -14,5 +14,11 @@ struct nvif_driver {
 
 struct nvif_client_impl {
 	void (*del)(struct nvif_client_priv *);
+
+	struct {
+		int (*new)(struct nvif_client_priv *parent,
+			   const struct nvif_client_impl **, struct nvif_client_priv **,
+			   u64 handle);
+	} client;
 };
 #endif
drivers/gpu/drm/nouveau/include/nvif/if0000.h deleted +0 -11
deleted file mode 100644
index 4b31496b37e1..000000000000
@@ -1,11 +0,0 @@
-/* SPDX-License-Identifier: MIT */
-#ifndef __NVIF_IF0000_H__
-#define __NVIF_IF0000_H__
-
-struct nvif_client_v0 {
-	__u8  version;
-	__u8  pad01[7];
-	__u64 device;
-	char  name[32];
-};
-#endif
drivers/gpu/drm/nouveau/include/nvkm/core/object.h +10 -0
index 10107ef3ca49..9ab163d9a4d0 100644
@@ -58,6 +58,16 @@ int nvkm_object_unmap(struct nvkm_object *);
 int nvkm_object_bind(struct nvkm_object *, struct nvkm_gpuobj *, int align,
 		     struct nvkm_gpuobj **);
 
+void nvkm_object_link_(struct nvif_client_priv *, struct nvkm_object *parent, struct nvkm_object *);
+int nvkm_object_link_rb(struct nvif_client_priv *, struct nvkm_object *parent, u64 handle,
+		        struct nvkm_object *);
+
+static inline void
+nvkm_object_link(struct nvkm_object *parent, struct nvkm_object *object)
+{
+	nvkm_object_link_(parent->client, parent, object);
+}
+
 bool nvkm_object_insert(struct nvkm_object *);
 void nvkm_object_remove(struct nvkm_object *);
 struct nvkm_object *nvkm_object_search(struct nvkm_client *, u64 object,
drivers/gpu/drm/nouveau/nouveau_drm.c +1 -27
index d793afd929c9..5e4c706bf150 100644
@@ -113,30 +113,6 @@ static struct drm_driver driver_stub;
 static struct drm_driver driver_pci;
 static struct drm_driver driver_platform;
 
-static u64
-nouveau_pci_name(struct pci_dev *pdev)
-{
-	u64 name = (u64)pci_domain_nr(pdev->bus) << 32;
-	name |= pdev->bus->number << 16;
-	name |= PCI_SLOT(pdev->devfn) << 8;
-	return name | PCI_FUNC(pdev->devfn);
-}
-
-static u64
-nouveau_platform_name(struct platform_device *platformdev)
-{
-	return platformdev->id;
-}
-
-static u64
-nouveau_name(struct drm_device *dev)
-{
-	if (dev_is_pci(dev->dev))
-		return nouveau_pci_name(to_pci_dev(dev->dev));
-	else
-		return nouveau_platform_name(to_platform_device(dev->dev));
-}
-
 static inline bool
 nouveau_cli_work_ready(struct dma_fence *fence)
 {
@@ -234,7 +210,6 @@ nouveau_cli_init(struct nouveau_drm *drm, const char *sname,
 		{ NVIF_CLASS_VMM_NV04 , -1 },
 		{}
 	};
-	u64 device = nouveau_name(drm->dev);
 	int ret;
 
 	snprintf(cli->name, sizeof(cli->name), "%s", sname);
@@ -246,8 +221,7 @@ nouveau_cli_init(struct nouveau_drm *drm, const char *sname,
 	mutex_init(&cli->lock);
 
 	mutex_lock(&drm->client_mutex);
-	ret = nvif_client_ctor(&drm->_client, cli->name, device,
-			       &cli->base);
+	ret = nvif_client_ctor(&drm->_client, cli->name, &cli->base);
 	mutex_unlock(&drm->client_mutex);
 	if (ret) {
 		NV_PRINTK(err, cli, "Client allocation failed: %d\n", ret);
drivers/gpu/drm/nouveau/nvif/client.c +7 -19
index 4c4a856ab861..0211fa76431f 100644
@@ -26,9 +26,7 @@
 #include <nvif/driver.h>
 #include <nvif/driverif.h>
 #include <nvif/ioctl.h>
-
-#include <nvif/class.h>
-#include <nvif/if0000.h>
+#include <nvif/printf.h>
 
 int
 nvif_client_suspend(struct nvif_client *client)
@@ -45,12 +43,6 @@ nvif_client_resume(struct nvif_client *client)
 void
 nvif_client_dtor(struct nvif_client *client)
 {
-	if (!client->impl) {
-		nvif_object_dtor(&client->object);
-		client->driver = NULL;
-		return;
-	}
-
 	client->impl->del(client->priv);
 	client->impl = NULL;
 	client->object.client = NULL;
@@ -58,22 +50,18 @@ nvif_client_dtor(struct nvif_client *client)
 }
 
 int
-nvif_client_ctor(struct nvif_client *parent, const char *name, u64 device,
-		 struct nvif_client *client)
+nvif_client_ctor(struct nvif_client *parent, const char *name, struct nvif_client *client)
 {
-	struct nvif_client_v0 args = { .device = device };
 	int ret;
 
-	strscpy_pad(args.name, name, sizeof(args.name));
-	ret = nvif_object_ctor(parent != client ? &parent->object : NULL,
-			       name ? name : "nvifClient", 0,
-			       NVIF_CLASS_CLIENT, &args, sizeof(args),
-			       &client->object);
+	ret = parent->impl->client.new(parent->priv, &client->impl, &client->priv,
+				       nvif_handle(&client->object));
+	NVIF_ERRON(ret, &parent->object, "[NEW client]");
 	if (ret)
 		return ret;
 
-	client->object.client = client;
-	client->object.handle = ~0;
+	nvif_object_ctor(&parent->object, name ?: "nvifClient", 0, 0, &client->object);
+	client->object.priv = client->priv;
 	client->driver = parent->driver;
 	return 0;
 }
drivers/gpu/drm/nouveau/nvkm/core/client.c +14 -32

78 lines not on this page · raw message

drivers/gpu/drm/nouveau/nvkm/core/object.c +33 -0
index 390c265cf8af..d34a8ee1a0ae 100644
@@ -247,10 +247,15 @@ void
 nvkm_object_del(struct nvkm_object **pobject)
 {
 	struct nvkm_object *object = *pobject;
+
 	if (object && !WARN_ON(!object->func)) {
 		*pobject = nvkm_object_dtor(object);
 		nvkm_object_remove(object);
+
+		spin_lock_irq(&object->client->obj_lock);
 		list_del(&object->head);
+		spin_unlock_irq(&object->client->obj_lock);
+
 		kfree(*pobject);
 		*pobject = NULL;
 	}
@@ -298,3 +303,31 @@ nvkm_object_new(const struct nvkm_oclass *oclass, void *data, u32 size,
 		oclass->base.func ? oclass->base.func : &nvkm_object_func;
 	return nvkm_object_new_(func, oclass, data, size, pobject);
 }
+
+void
+nvkm_object_link_(struct nvif_client_priv *client, struct nvkm_object *parent,
+		  struct nvkm_object *object)
+{
+	object->client = client;
+
+	spin_lock_irq(&client->obj_lock);
+	list_add_tail(&object->head, &parent->tree);
+	spin_unlock_irq(&client->obj_lock);
+}
+
+int
+nvkm_object_link_rb(struct nvif_client_priv *client, struct nvkm_object *parent, u64 handle,
+		    struct nvkm_object *object)
+{
+	nvkm_object_link_(client, parent, object);
+
+	object->object = handle;
+
+	if (!nvkm_object_insert(object)) {
+		nvkm_object_fini(object, false);
+		nvkm_object_del(&object);
+		return -EEXIST;
+	}
+
+	return 0;
+}
Signature · 1 line
2.41.0
author
#64 lore raw

PATCH 63/156 drm/nouveau/nvif: rework client "new device" api

In reply to Ben Skeggs

- transition from "ioctl" interface

---
 drivers/gpu/drm/nouveau/include/nvif/device.h |  4 +-
 .../gpu/drm/nouveau/include/nvif/driverif.h   | 11 ++++
 .../drm/nouveau/include/nvkm/core/device.h    |  2 -
 drivers/gpu/drm/nouveau/nvif/device.c         | 24 +++++++--
 drivers/gpu/drm/nouveau/nvkm/core/client.c    | 42 ++++++---------
 drivers/gpu/drm/nouveau/nvkm/device/user.c    | 52 ++++++++++++++-----
 drivers/gpu/drm/nouveau/nvkm/device/user.h    |  9 ++++
 7 files changed, 99 insertions(+), 45 deletions(-)
 create mode 100644 drivers/gpu/drm/nouveau/nvkm/device/user.h
drivers/gpu/drm/nouveau/include/nvif/device.h +3 -1
index fec76f4733a4..c0f8920f0e08 100644
@@ -1,12 +1,14 @@
 /* SPDX-License-Identifier: MIT */
 #ifndef __NVIF_DEVICE_H__
 #define __NVIF_DEVICE_H__
-
 #include <nvif/object.h>
 #include <nvif/cl0080.h>
+#include <nvif/driverif.h>
 #include <nvif/user.h>
 
 struct nvif_device {
+	const struct nvif_device_impl *impl;
+	struct nvif_device_priv *priv;
 	struct nvif_object object;
 	struct nv_device_info_v0 info;
 
drivers/gpu/drm/nouveau/include/nvif/driverif.h +11 -0
index a6f95c8475b1..8f56798d6509 100644
@@ -2,6 +2,7 @@
 #ifndef __NVIF_DRIVERIF_H__
 #define __NVIF_DRIVERIF_H__
 struct nvif_client_priv;
+struct nvif_device_priv;
 
 struct nvif_driver {
 	const char *name;
@@ -12,6 +13,10 @@ struct nvif_driver {
 	void (*unmap)(struct nvif_client_priv *, void __iomem *ptr, u32 size);
 };
 
+struct nvif_device_impl {
+	void (*del)(struct nvif_device_priv *);
+};
+
 struct nvif_client_impl {
 	void (*del)(struct nvif_client_priv *);
 
@@ -20,5 +25,11 @@ struct nvif_client_impl {
 			   const struct nvif_client_impl **, struct nvif_client_priv **,
 			   u64 handle);
 	} client;
+
+	struct {
+		int (*new)(struct nvif_client_priv *,
+			   const struct nvif_device_impl **, struct nvif_device_priv **,
+			   u64 handle);
+	} device;
 };
 #endif
drivers/gpu/drm/nouveau/include/nvkm/core/device.h +0 -2
index efe1a0048328..fff0d7dd0e1b 100644
@@ -129,8 +129,6 @@ struct nvkm_device_oclass {
 	struct nvkm_sclass base;
 };
 
-extern const struct nvkm_sclass nvkm_udevice_sclass;
-
 /* device logging */
 #define nvdev_printk_(d,l,p,f,a...) do {                                       \
 	const struct nvkm_device *_device = (d);                               \
drivers/gpu/drm/nouveau/nvif/device.c +21 -3
index 24880931039f..bb95e80f1c81 100644
@@ -23,6 +23,7 @@
  */
 #include <nvif/device.h>
 #include <nvif/client.h>
+#include <nvif/printf.h>
 
 u64
 nvif_device_time(struct nvif_device *device)
@@ -47,23 +48,40 @@ nvif_device_map(struct nvif_device *device)
 void
 nvif_device_dtor(struct nvif_device *device)
 {
+	if (!device->impl)
+		return;
+
 	nvif_user_dtor(device);
 	kfree(device->runlist);
 	device->runlist = NULL;
-	nvif_object_dtor(&device->object);
+
+	device->impl->del(device->priv);
+	device->impl = NULL;
 }
 
 int
 nvif_device_ctor(struct nvif_client *client, const char *name, struct nvif_device *device)
 {
-	int ret = nvif_object_ctor(&client->object, name ? name : "nvifDevice", 0,
-				   0x0080, NULL, 0, &device->object);
+	int ret;
+
 	device->runlist = NULL;
 	device->user.func = NULL;
+
+	ret = client->impl->device.new(client->priv, &device->impl, &device->priv,
+				       nvif_handle(&device->object));
+	NVIF_ERRON(ret, &client->object, "[NEW device]");
+	if (ret)
+		return ret;
+
+	nvif_object_ctor(&client->object, name ?: "nvifDevice", 0, 0, &device->object);
+	device->object.client = client;
+	device->object.priv = device->priv; /*FIXME: used by nvxx_device() */
+
 	if (ret == 0) {
 		device->info.version = 0;
 		ret = nvif_object_mthd(&device->object, NV_DEVICE_V0_INFO,
 				       &device->info, sizeof(device->info));
 	}
+
 	return ret;
 }
drivers/gpu/drm/nouveau/nvkm/core/client.c +17 -25

68 lines not on this page · raw message

drivers/gpu/drm/nouveau/nvkm/device/user.c +38 -14

82 lines not on this page · raw message

drivers/gpu/drm/nouveau/nvkm/device/user.h new file +9 -0
new file mode 100644
index 000000000000..fb3f94a58960
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: MIT */
+#ifndef __NVKM_DEVICE_USER_H__
+#define __NVKM_DEVICE_USER_H__
+#include <core/device.h>
+#include <nvif/driverif.h>
+
+int nvkm_udevice_new(struct nvkm_device *, const struct nvif_device_impl **,
+		     struct nvif_device_priv **, struct nvkm_object **);
+#endif
Signature · 1 line
2.41.0
author
#65 lore raw

PATCH 64/156 drm/nouveau/nvif: remove client from object rb

In reply to Ben Skeggs

- no more users

---
 drivers/gpu/drm/nouveau/include/nvif/driverif.h | 3 +--
 drivers/gpu/drm/nouveau/nvif/client.c           | 3 +--
 drivers/gpu/drm/nouveau/nvkm/core/client.c      | 6 +++---
 3 files changed, 5 insertions(+), 7 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/driverif.h +1 -2
index 8f56798d6509..39e965a184fd 100644
@@ -22,8 +22,7 @@ struct nvif_client_impl {
 
 	struct {
 		int (*new)(struct nvif_client_priv *parent,
-			   const struct nvif_client_impl **, struct nvif_client_priv **,
-			   u64 handle);
+			   const struct nvif_client_impl **, struct nvif_client_priv **);
 	} client;
 
 	struct {
drivers/gpu/drm/nouveau/nvif/client.c +1 -2
index 0211fa76431f..6b3c7b28b212 100644
@@ -54,8 +54,7 @@ nvif_client_ctor(struct nvif_client *parent, const char *name, struct nvif_clien
 {
 	int ret;
 
-	ret = parent->impl->client.new(parent->priv, &client->impl, &client->priv,
-				       nvif_handle(&client->object));
+	ret = parent->impl->client.new(parent->priv, &client->impl, &client->priv);
 	NVIF_ERRON(ret, &parent->object, "[NEW client]");
 	if (ret)
 		return ret;
drivers/gpu/drm/nouveau/nvkm/core/client.c +3 -3
index 1763e863115c..a77014b342c0 100644
@@ -48,8 +48,7 @@ nvkm_client_new_device(struct nvif_client_priv *client,
 
 static int
 nvkm_client_new_client(struct nvif_client_priv *parent,
-		       const struct nvif_client_impl **pimpl, struct nvif_client_priv **ppriv,
-		       u64 handle)
+		       const struct nvif_client_impl **pimpl, struct nvif_client_priv **ppriv)
 {
 	struct nvkm_client *client;
 	int ret;
@@ -61,7 +60,8 @@ nvkm_client_new_client(struct nvif_client_priv *parent,
 	*pimpl = &nvkm_client_impl;
 	*ppriv = client;
 
-	return nvkm_object_link_rb(parent, &parent->object, handle, &client->object);
+	nvkm_object_link_(parent, &parent->object, &client->object);
+	return 0;
 }
 
 static void
Signature · 1 line
2.41.0
author
#66 lore raw

PATCH 65/156 drm/nouveau/nvif: rework device "sclass" api

In reply to Ben Skeggs

- transition from "ioctl" interface

---
 drivers/gpu/drm/nouveau/include/nvif/disp.h   |  3 +-
 .../gpu/drm/nouveau/include/nvif/driverif.h   | 26 +++++
 drivers/gpu/drm/nouveau/nouveau_abi16.c       | 19 +---
 drivers/gpu/drm/nouveau/nouveau_chan.c        | 57 +++++------
 drivers/gpu/drm/nouveau/nouveau_display.c     |  2 +-
 drivers/gpu/drm/nouveau/nouveau_drm.c         | 96 ++++++++-----------
 drivers/gpu/drm/nouveau/nouveau_svm.c         | 23 ++---
 drivers/gpu/drm/nouveau/nvif/disp.c           | 54 +++++------
 drivers/gpu/drm/nouveau/nvif/user.c           | 30 +++---
 drivers/gpu/drm/nouveau/nvkm/device/user.c    | 24 +++++
 .../gpu/drm/nouveau/nvkm/engine/fifo/Kbuild   |  1 +
 .../gpu/drm/nouveau/nvkm/engine/fifo/ufifo.c  | 30 ++++++
 .../gpu/drm/nouveau/nvkm/engine/fifo/ufifo.h  |  8 ++
 13 files changed, 217 insertions(+), 156 deletions(-)
 create mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/fifo/ufifo.c
 create mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/fifo/ufifo.h
drivers/gpu/drm/nouveau/include/nvif/disp.h +1 -2
index 56eb7293e01c..c4f428f268ea 100644
@@ -10,7 +10,6 @@ struct nvif_disp {
 	unsigned long head_mask;
 };
 
-int nvif_disp_ctor(struct nvif_device *, const char *name, s32 oclass,
-		   struct nvif_disp *);
+int nvif_disp_ctor(struct nvif_device *, const char *name, struct nvif_disp *);
 void nvif_disp_dtor(struct nvif_disp *);
 #endif
drivers/gpu/drm/nouveau/include/nvif/driverif.h +26 -0
index 39e965a184fd..9ac4857714c7 100644
@@ -15,6 +15,32 @@ struct nvif_driver {
 
 struct nvif_device_impl {
 	void (*del)(struct nvif_device_priv *);
+
+	struct {
+		s32 oclass;
+	} usermode;
+
+	struct {
+		s32 oclass;
+	} mmu;
+
+	struct {
+		s32 oclass;
+	} faultbuf;
+
+	struct {
+		s32 oclass;
+	} disp;
+
+	struct nvif_device_impl_fifo {
+		struct {
+			s32 oclass;
+		} cgrp;
+
+		struct {
+			s32 oclass;
+		} chan;
+	} fifo;
 };
 
 struct nvif_client_impl {
drivers/gpu/drm/nouveau/nouveau_abi16.c +4 -15
index 2648e42e0496..23f8b448a30a 100644
@@ -223,20 +223,6 @@ nouveau_abi16_fini(struct nouveau_abi16 *abi16)
 	cli->abi16 = NULL;
 }
 
-static inline int
-getparam_dma_ib_max(struct nvif_device *device)
-{
-	const struct nvif_mclass dmas[] = {
-		{ NV03_CHANNEL_DMA, 0 },
-		{ NV10_CHANNEL_DMA, 0 },
-		{ NV17_CHANNEL_DMA, 0 },
-		{ NV40_CHANNEL_DMA, 0 },
-		{}
-	};
-
-	return nvif_mclass(&device->object, dmas) < 0 ? NV50_DMA_IB_MAX : 0;
-}
-
 int
 nouveau_abi16_ioctl_getparam(ABI16_IOCTL_ARGS)
 {
@@ -303,7 +289,10 @@ nouveau_abi16_ioctl_getparam(ABI16_IOCTL_ARGS)
 		getparam->value = nvkm_gr_units(gr);
 		break;
 	case NOUVEAU_GETPARAM_EXEC_PUSH_MAX: {
-		int ib_max = getparam_dma_ib_max(device);
+		int ib_max = 0;
+
+		if (device->impl->fifo.chan.oclass >= NV50_CHANNEL_GPFIFO)
+			ib_max = NV50_DMA_IB_MAX;
 
 		getparam->value = nouveau_exec_push_max_from_ib_max(ib_max);
 		break;
drivers/gpu/drm/nouveau/nouveau_chan.c +29 -28

99 lines not on this page · raw message

drivers/gpu/drm/nouveau/nouveau_display.c +1 -1
index f28f9a857458..27b69032fd9e 100644
@@ -725,7 +725,7 @@ nouveau_display_create(struct drm_device *dev)
 	drm_kms_helper_poll_disable(dev);
 
 	if (nouveau_modeset != 2) {
-		ret = nvif_disp_ctor(&drm->client.device, "kmsDisp", 0, &disp->disp);
+		ret = nvif_disp_ctor(&drm->device, "kmsDisp", &disp->disp);
 		/* no display hw */
 		if (ret == -ENODEV) {
 			ret = 0;
drivers/gpu/drm/nouveau/nouveau_drm.c +42 -54

125 lines not on this page · raw message

drivers/gpu/drm/nouveau/nouveau_svm.c +10 -13
index b4da82ddbb6b..477336672652 100644
@@ -1044,11 +1044,6 @@ nouveau_svm_fini(struct nouveau_drm *drm)
 void
 nouveau_svm_init(struct nouveau_drm *drm)
 {
-	static const struct nvif_mclass buffers[] = {
-		{   VOLTA_FAULT_BUFFER_A, 0 },
-		{ MAXWELL_FAULT_BUFFER_A, 0 },
-		{}
-	};
 	struct nouveau_svm *svm;
 	int ret;
 
@@ -1059,6 +1054,15 @@ nouveau_svm_init(struct nouveau_drm *drm)
 	if (drm->client.device.info.family > NV_DEVICE_INFO_V0_PASCAL)
 		return;
 
+	switch (drm->device.impl->faultbuf.oclass) {
+	case   VOLTA_FAULT_BUFFER_A:
+	case MAXWELL_FAULT_BUFFER_A:
+		break;
+	default:
+		NV_DEBUG(drm, "No supported fault buffer class\n");
+		return;
+	}
+
 	drm->svm = svm = kzalloc(struct_size(drm->svm, buffer, 1), GFP_KERNEL);
 	if (!drm->svm)
 		return;
@@ -1067,14 +1071,7 @@ nouveau_svm_init(struct nouveau_drm *drm)
 	mutex_init(&drm->svm->mutex);
 	INIT_LIST_HEAD(&drm->svm->inst);
 
-	ret = nvif_mclass(&drm->client.device.object, buffers);
-	if (ret < 0) {
-		SVM_DBG(svm, "No supported fault buffer class");
-		nouveau_svm_fini(drm);
-		return;
-	}
-
-	ret = nouveau_svm_fault_buffer_ctor(svm, buffers[ret].oclass, 0);
+	ret = nouveau_svm_fault_buffer_ctor(svm, drm->device.impl->faultbuf.oclass, 0);
 	if (ret) {
 		nouveau_svm_fini(drm);
 		return;
drivers/gpu/drm/nouveau/nvif/disp.c +27 -27

70 lines not on this page · raw message

drivers/gpu/drm/nouveau/nvif/user.c +14 -16
index b648a5e036af..d8d37c1c8169 100644
@@ -21,6 +21,7 @@
  */
 #include <nvif/user.h>
 #include <nvif/device.h>
+#include <nvif/printf.h>
 
 #include <nvif/class.h>
 
@@ -36,32 +37,29 @@ nvif_user_dtor(struct nvif_device *device)
 int
 nvif_user_ctor(struct nvif_device *device, const char *name)
 {
-	struct {
-		s32 oclass;
-		int version;
-		const struct nvif_user_func *func;
-	} users[] = {
-		{ AMPERE_USERMODE_A, -1, &nvif_userc361 },
-		{ TURING_USERMODE_A, -1, &nvif_userc361 },
-		{  VOLTA_USERMODE_A, -1, &nvif_userc361 },
-		{}
-	};
-	int cid, ret;
+	const u32 oclass = device->impl->usermode.oclass;
+	const struct nvif_user_func *func;
+	int ret;
 
 	if (device->user.func)
 		return 0;
 
-	cid = nvif_mclass(&device->object, users);
-	if (cid < 0)
-		return cid;
+	switch (oclass) {
+	case AMPERE_USERMODE_A: func = &nvif_userc361; break;
+	case TURING_USERMODE_A: func = &nvif_userc361; break;
+	case  VOLTA_USERMODE_A: func = &nvif_userc361; break;
+	default:
+		NVIF_DEBUG(&device->object, "[NEW usermode%04x] not supported", oclass);
+		return -ENODEV;
+	}
 
 	ret = nvif_object_ctor(&device->object, name ? name : "nvifUsermode",
-			       0, users[cid].oclass, NULL, 0,
+			       0, oclass, NULL, 0,
 			       &device->user.object);
 	if (ret)
 		return ret;
 
 	nvif_object_map(&device->user.object, NULL, 0);
-	device->user.func = users[cid].func;
+	device->user.func = func;
 	return 0;
 }
drivers/gpu/drm/nouveau/nvkm/device/user.c +24 -0
index a46d448dc244..f55088849a0c 100644
@@ -29,6 +29,8 @@
 #include <subdev/fb.h>
 #include <subdev/instmem.h>
 #include <subdev/timer.h>
+#include <engine/disp/priv.h>
+#include <engine/fifo/ufifo.h>
 
 #include <nvif/class.h>
 #include <nvif/cl0080.h>
@@ -355,6 +357,28 @@ nvkm_udevice_new(struct nvkm_device *device,
 
 	udev->impl = nvkm_udevice_impl;
 
+	if (device->vfn) {
+		udev->impl.usermode.oclass = device->vfn->user.base.oclass;
+	}
+
+	if (device->mmu) {
+		udev->impl.mmu.oclass = device->mmu->user.base.oclass;
+	}
+
+	if (device->fault) {
+		udev->impl.faultbuf.oclass = device->fault->user.base.oclass;
+	}
+
+	if (device->disp) {
+		udev->impl.disp.oclass = device->disp->func->user.root.oclass;
+	}
+
+	if (device->fifo) {
+		if (!WARN_ON(nvkm_subdev_oneinit(&device->fifo->engine.subdev))) {
+			nvkm_ufifo_ctor(device->fifo, &udev->impl.fifo);
+		}
+	}
+
 	*pimpl = &udev->impl;
 	*ppriv = udev;
 	*pobject = &udev->object;
drivers/gpu/drm/nouveau/nvkm/engine/fifo/Kbuild +1 -0
index aff92848abfe..fa61bb128885 100644
@@ -28,5 +28,6 @@ nvkm-y += nvkm/engine/fifo/ga102.o
 
 nvkm-y += nvkm/engine/fifo/r535.o
 
+nvkm-y += nvkm/engine/fifo/ufifo.o
 nvkm-y += nvkm/engine/fifo/ucgrp.o
 nvkm-y += nvkm/engine/fifo/uchan.o
drivers/gpu/drm/nouveau/nvkm/engine/fifo/ufifo.c new file +30 -0
new file mode 100644
index 000000000000..3f0bd70f614e
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved.
+ *
+ * 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 AUTHORS OR COPYRIGHT HOLDERS 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.
+ */
+#include "ufifo.h"
+#include "priv.h"
+
+void
+nvkm_ufifo_ctor(struct nvkm_fifo *fifo, struct nvif_device_impl_fifo *impl)
+{
+	impl->cgrp.oclass = fifo->func->cgrp.user.oclass;
+	impl->chan.oclass = fifo->func->chan.user.oclass;
+}
drivers/gpu/drm/nouveau/nvkm/engine/fifo/ufifo.h new file +8 -0
new file mode 100644
index 000000000000..778e81052502
@@ -0,0 +1,8 @@
+/* SPDX-License-Identifier: MIT */
+#ifndef __NVKM_UFIFO_H__
+#define __NVKM_UFIFO_H__
+#include <engine/fifo.h>
+#include <nvif/driverif.h>
+
+void nvkm_ufifo_ctor(struct nvkm_fifo *, struct nvif_device_impl_fifo *);
+#endif
Signature · 1 line
2.41.0
author
#67 lore raw

PATCH 66/156 drm/nouveau/nvif: rework device "map" api

In reply to Ben Skeggs

- transition from "ioctl" interface

---
 drivers/gpu/drm/nouveau/include/nvif/device.h |  2 +
 .../gpu/drm/nouveau/include/nvif/driverif.h   | 11 +++++
 drivers/gpu/drm/nouveau/include/nvif/object.h |  8 ++++
 drivers/gpu/drm/nouveau/nvif/device.c         |  5 +-
 drivers/gpu/drm/nouveau/nvif/object.c         | 46 +++++++++++++++++++
 drivers/gpu/drm/nouveau/nvkm/device/user.c    | 16 ++-----
 6 files changed, 74 insertions(+), 14 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/device.h +2 -0
index c0f8920f0e08..27526d5811cf 100644
@@ -10,6 +10,8 @@ struct nvif_device {
 	const struct nvif_device_impl *impl;
 	struct nvif_device_priv *priv;
 	struct nvif_object object;
+	struct nvif_map map;
+
 	struct nv_device_info_v0 info;
 
 	struct nvif_fifo_runlist {
drivers/gpu/drm/nouveau/include/nvif/driverif.h +11 -0
index 9ac4857714c7..03c4803f6492 100644
@@ -13,9 +13,20 @@ struct nvif_driver {
 	void (*unmap)(struct nvif_client_priv *, void __iomem *ptr, u32 size);
 };
 
+struct nvif_mapinfo {
+	enum nvif_map_type {
+		NVIF_MAP_IO,
+		NVIF_MAP_VA,
+	} type;
+	u64 handle;
+	u64 length;
+};
+
 struct nvif_device_impl {
 	void (*del)(struct nvif_device_priv *);
 
+	struct nvif_mapinfo map;
+
 	struct {
 		s32 oclass;
 	} usermode;
drivers/gpu/drm/nouveau/include/nvif/object.h +8 -0
index a84cdb423471..b3e66425f310 100644
@@ -22,6 +22,12 @@ struct nvif_object {
 	} map;
 };
 
+struct nvif_map {
+	const struct nvif_mapinfo *impl;
+	struct nvif_object *object;
+	void __iomem *ptr;
+};
+
 static inline bool
 nvif_object_constructed(struct nvif_object *object)
 {
@@ -43,6 +49,8 @@ int  nvif_object_ioctl(struct nvif_object *, void *, u32, void **);
 int  nvif_object_sclass_get(struct nvif_object *, struct nvif_sclass **);
 void nvif_object_sclass_put(struct nvif_sclass **);
 int  nvif_object_mthd(struct nvif_object *, u32, void *, u32);
+int nvif_object_map_cpu(struct nvif_object *, const struct nvif_mapinfo *, struct nvif_map *);
+int nvif_object_unmap_cpu(struct nvif_map *);
 int  nvif_object_map_handle(struct nvif_object *, void *, u32,
 			    u64 *handle, u64 *length);
 void nvif_object_unmap_handle(struct nvif_object *);
drivers/gpu/drm/nouveau/nvif/device.c +4 -1
index bb95e80f1c81..a0bc047ae28d 100644
@@ -42,7 +42,7 @@ nvif_device_time(struct nvif_device *device)
 int
 nvif_device_map(struct nvif_device *device)
 {
-	return nvif_object_map(&device->object, NULL, 0);
+	return nvif_object_map_cpu(&device->object, &device->impl->map, &device->map);
 }
 
 void
@@ -52,9 +52,12 @@ nvif_device_dtor(struct nvif_device *device)
 		return;
 
 	nvif_user_dtor(device);
+
 	kfree(device->runlist);
 	device->runlist = NULL;
 
+	nvif_object_unmap_cpu(&device->map);
+
 	device->impl->del(device->priv);
 	device->impl = NULL;
 }
drivers/gpu/drm/nouveau/nvif/object.c +46 -0

52 lines not on this page · raw message

drivers/gpu/drm/nouveau/nvkm/device/user.c +3 -13
index f55088849a0c..229245b03719 100644
@@ -222,18 +222,6 @@ nvkm_udevice_mthd(struct nvkm_object *object, u32 mthd, void *data, u32 size)
 	return -EINVAL;
 }
 
-static int
-nvkm_udevice_map(struct nvkm_object *object, void *argv, u32 argc,
-		 enum nvkm_object_map *type, u64 *addr, u64 *size)
-{
-	struct nvif_device_priv *udev = container_of(object, typeof(*udev), object);
-	struct nvkm_device *device = udev->device;
-	*type = NVKM_OBJECT_MAP_IO;
-	*addr = device->func->resource_addr(device, 0);
-	*size = device->func->resource_size(device, 0);
-	return 0;
-}
-
 static int
 nvkm_udevice_fini(struct nvkm_object *object, bool suspend)
 {
@@ -333,7 +321,6 @@ nvkm_udevice = {
 	.init = nvkm_udevice_init,
 	.fini = nvkm_udevice_fini,
 	.mthd = nvkm_udevice_mthd,
-	.map = nvkm_udevice_map,
 	.sclass = nvkm_udevice_child_get,
 };
 
@@ -356,6 +343,9 @@ nvkm_udevice_new(struct nvkm_device *device,
 		goto done;
 
 	udev->impl = nvkm_udevice_impl;
+	udev->impl.map.type = NVIF_MAP_IO;
+	udev->impl.map.handle = device->func->resource_addr(device, 0);
+	udev->impl.map.length = device->func->resource_size(device, 0);
 
 	if (device->vfn) {
 		udev->impl.usermode.oclass = device->vfn->user.base.oclass;
Signature · 1 line
2.41.0
author
#68 lore raw

PATCH 67/156 drm/nouveau/nvif: rework device "info v0" api

In reply to Ben Skeggs

- transition from "ioctl" interface

---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  34 +++++
 drivers/gpu/drm/nouveau/nvif/device.c         |  11 +-
 drivers/gpu/drm/nouveau/nvkm/device/user.c    | 135 ++++++++----------
 3 files changed, 106 insertions(+), 74 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/driverif.h +34 -0
index 03c4803f6492..6152eabd4352 100644
@@ -27,6 +27,40 @@ struct nvif_device_impl {
 
 	struct nvif_mapinfo map;
 
+	enum {
+		NVIF_DEVICE_IGP = 0,
+		NVIF_DEVICE_PCI,
+		NVIF_DEVICE_AGP,
+		NVIF_DEVICE_PCIE,
+		NVIF_DEVICE_SOC,
+	} platform;
+
+	u16 chipset; /* from NV_PMC_BOOT_0 */
+	u8 revision; /* from NV_PMC_BOOT_0 */
+
+	enum {
+		NVIF_DEVICE_TNT = 1,
+		NVIF_DEVICE_CELSIUS,
+		NVIF_DEVICE_KELVIN,
+		NVIF_DEVICE_RANKINE,
+		NVIF_DEVICE_CURIE,
+		NVIF_DEVICE_TESLA,
+		NVIF_DEVICE_FERMI,
+		NVIF_DEVICE_KEPLER,
+		NVIF_DEVICE_MAXWELL,
+		NVIF_DEVICE_PASCAL,
+		NVIF_DEVICE_VOLTA,
+		NVIF_DEVICE_TURING,
+		NVIF_DEVICE_AMPERE,
+		NVIF_DEVICE_ADA,
+	} family;
+
+	char chip[16];
+	char name[64];
+
+	u64 ram_size;
+	u64 ram_user;
+
 	struct {
 		s32 oclass;
 	} usermode;
drivers/gpu/drm/nouveau/nvif/device.c +9 -2
index a0bc047ae28d..7c28f9764936 100644
@@ -81,9 +81,16 @@ nvif_device_ctor(struct nvif_client *client, const char *name, struct nvif_devic
 	device->object.priv = device->priv; /*FIXME: used by nvxx_device() */
 
 	if (ret == 0) {
+		/*FIXME: remove after moving users to device->impl */
 		device->info.version = 0;
-		ret = nvif_object_mthd(&device->object, NV_DEVICE_V0_INFO,
-				       &device->info, sizeof(device->info));
+		device->info.platform = device->impl->platform;
+		device->info.chipset = device->impl->chipset;
+		device->info.revision = device->impl->revision;
+		device->info.family = device->impl->family;
+		device->info.ram_size = device->impl->ram_size;
+		device->info.ram_user = device->impl->ram_user;
+		strscpy(device->info.chip, device->impl->chip, sizeof(device->info.chip));
+		strscpy(device->info.name, device->impl->name, sizeof(device->info.name));
 	}
 
 	return ret;
drivers/gpu/drm/nouveau/nvkm/device/user.c +63 -72

157 lines not on this page · raw message

Signature · 1 line
2.41.0
author
#69 lore raw

PATCH 68/156 drm/nouveau/nvif: rework device "info v1" api

In reply to Ben Skeggs

- transition from "ioctl" interfaces

---
 drivers/gpu/drm/nouveau/include/nvif/cl0080.h | 46 ---------
 drivers/gpu/drm/nouveau/include/nvif/device.h |  5 -
 .../gpu/drm/nouveau/include/nvif/driverif.h   | 43 ++++++++
 drivers/gpu/drm/nouveau/include/nvif/fifo.h   |  9 +-
 .../drm/nouveau/include/nvkm/core/subdev.h    |  2 -
 drivers/gpu/drm/nouveau/nouveau_abi16.c       | 14 +--
 drivers/gpu/drm/nouveau/nouveau_chan.c        | 43 ++------
 drivers/gpu/drm/nouveau/nouveau_drm.c         |  7 +-
 drivers/gpu/drm/nouveau/nvif/device.c         |  4 -
 drivers/gpu/drm/nouveau/nvif/fifo.c           | 65 ++----------
 drivers/gpu/drm/nouveau/nvkm/core/engine.c    | 12 ---
 drivers/gpu/drm/nouveau/nvkm/core/subdev.c    |  8 --
 drivers/gpu/drm/nouveau/nvkm/device/user.c    | 58 -----------
 .../gpu/drm/nouveau/nvkm/engine/fifo/base.c   | 73 --------------
 .../gpu/drm/nouveau/nvkm/engine/fifo/ufifo.c  | 99 +++++++++++++++++++
 15 files changed, 174 insertions(+), 314 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/cl0080.h +0 -46
index ea937fa7bc55..f1684dbd8e3b 100644
@@ -37,55 +37,9 @@ struct nv_device_info_v0 {
 	char  name[64];
 };
 
-struct nv_device_info_v1 {
-	__u8  version;
-	__u8  count;
-	__u8  pad02[6];
-	struct nv_device_info_v1_data {
-		__u64 mthd; /* NV_DEVICE_INFO_* (see below). */
-		__u64 data;
-	} data[];
-};
-
 struct nv_device_time_v0 {
 	__u8  version;
 	__u8  pad01[7];
 	__u64 time;
 };
-
-#define NV_DEVICE_INFO_UNIT                               (0xffffffffULL << 32)
-#define NV_DEVICE_INFO(n)                          ((n) | (0x00000000ULL << 32))
-#define NV_DEVICE_HOST(n)                          ((n) | (0x00000001ULL << 32))
-
-/* This will be returned in the mthd field for unsupported queries. */
-#define NV_DEVICE_INFO_INVALID                                           ~0ULL
-
-/* Returns the number of available runlists. */
-#define NV_DEVICE_HOST_RUNLISTS                       NV_DEVICE_HOST(0x00000000)
-/* Returns the number of available channels (0 if per-runlist). */
-#define NV_DEVICE_HOST_CHANNELS                       NV_DEVICE_HOST(0x00000001)
-
-/* Returns a mask of available engine types on runlist(data). */
-#define NV_DEVICE_HOST_RUNLIST_ENGINES                NV_DEVICE_HOST(0x00000100)
-#define NV_DEVICE_HOST_RUNLIST_ENGINES_SW                            0x00000001
-#define NV_DEVICE_HOST_RUNLIST_ENGINES_GR                            0x00000002
-#define NV_DEVICE_HOST_RUNLIST_ENGINES_MPEG                          0x00000004
-#define NV_DEVICE_HOST_RUNLIST_ENGINES_ME                            0x00000008
-#define NV_DEVICE_HOST_RUNLIST_ENGINES_CIPHER                        0x00000010
-#define NV_DEVICE_HOST_RUNLIST_ENGINES_BSP                           0x00000020
-#define NV_DEVICE_HOST_RUNLIST_ENGINES_VP                            0x00000040
-#define NV_DEVICE_HOST_RUNLIST_ENGINES_CE                            0x00000080
-#define NV_DEVICE_HOST_RUNLIST_ENGINES_SEC                           0x00000100
-#define NV_DEVICE_HOST_RUNLIST_ENGINES_MSVLD                         0x00000200
-#define NV_DEVICE_HOST_RUNLIST_ENGINES_MSPDEC                        0x00000400
-#define NV_DEVICE_HOST_RUNLIST_ENGINES_MSPPP                         0x00000800
-#define NV_DEVICE_HOST_RUNLIST_ENGINES_MSENC                         0x00001000
-#define NV_DEVICE_HOST_RUNLIST_ENGINES_VIC                           0x00002000
-#define NV_DEVICE_HOST_RUNLIST_ENGINES_SEC2                          0x00004000
-#define NV_DEVICE_HOST_RUNLIST_ENGINES_NVDEC                         0x00008000
-#define NV_DEVICE_HOST_RUNLIST_ENGINES_NVENC                         0x00010000
-#define NV_DEVICE_HOST_RUNLIST_ENGINES_NVJPG                         0x00020000
-#define NV_DEVICE_HOST_RUNLIST_ENGINES_OFA                           0x00040000
-/* Returns the number of available channels on runlist(data). */
-#define NV_DEVICE_HOST_RUNLIST_CHANNELS               NV_DEVICE_HOST(0x00000101)
 #endif
drivers/gpu/drm/nouveau/include/nvif/device.h +0 -5
index 27526d5811cf..fa8402e575da 100644
@@ -14,11 +14,6 @@ struct nvif_device {
 
 	struct nv_device_info_v0 info;
 
-	struct nvif_fifo_runlist {
-		u64 engines;
-	} *runlist;
-	int runlists;
-
 	struct nvif_user user;
 };
 
drivers/gpu/drm/nouveau/include/nvif/driverif.h +43 -0

49 lines not on this page · raw message

drivers/gpu/drm/nouveau/include/nvif/fifo.h +5 -4
index d351ac890ca1..4e9663848291 100644
@@ -1,16 +1,17 @@
 #ifndef __NVIF_FIFO_H__
 #define __NVIF_FIFO_H__
 #include <nvif/device.h>
+#include <nvif/driverif.h>
 
-/* Returns mask of runlists that support a NV_DEVICE_INFO_RUNLIST_ENGINES_* type. */
-u64 nvif_fifo_runlist(struct nvif_device *, u64 engine);
+/* Returns mask of runlists that support a NVIF_ENGINE_* type. */
+u64 nvif_fifo_runlist(struct nvif_device *, enum nvif_engine_type);
 
 /* CE-supporting runlists (excluding GRCE, if others exist). */
 static inline u64
 nvif_fifo_runlist_ce(struct nvif_device *device)
 {
-	u64 runmgr = nvif_fifo_runlist(device, NV_DEVICE_HOST_RUNLIST_ENGINES_GR);
-	u64 runmce = nvif_fifo_runlist(device, NV_DEVICE_HOST_RUNLIST_ENGINES_CE);
+	u64 runmgr = nvif_fifo_runlist(device, NVIF_ENGINE_GR);
+	u64 runmce = nvif_fifo_runlist(device, NVIF_ENGINE_CE);
 	if (runmce && !(runmce &= ~runmgr))
 		runmce = runmgr;
 	return runmce;
drivers/gpu/drm/nouveau/include/nvkm/core/subdev.h +0 -2
index bce6e1ba09ea..3bce2077072b 100644
@@ -38,7 +38,6 @@ struct nvkm_subdev_func {
 	void *(*dtor)(struct nvkm_subdev *);
 	int (*preinit)(struct nvkm_subdev *);
 	int (*oneinit)(struct nvkm_subdev *);
-	int (*info)(struct nvkm_subdev *, u64 mthd, u64 *data);
 	int (*init)(struct nvkm_subdev *);
 	int (*fini)(struct nvkm_subdev *, bool suspend);
 	void (*intr)(struct nvkm_subdev *);
@@ -66,7 +65,6 @@ int  nvkm_subdev_preinit(struct nvkm_subdev *);
 int  nvkm_subdev_oneinit(struct nvkm_subdev *);
 int  nvkm_subdev_init(struct nvkm_subdev *);
 int  nvkm_subdev_fini(struct nvkm_subdev *, bool suspend);
-int  nvkm_subdev_info(struct nvkm_subdev *, u64, u64 *);
 void nvkm_subdev_intr(struct nvkm_subdev *);
 
 /* subdev logging */
drivers/gpu/drm/nouveau/nouveau_abi16.c +7 -7
index 23f8b448a30a..fdbc982ea566 100644
@@ -338,26 +338,26 @@ nouveau_abi16_ioctl_channel_alloc(ABI16_IOCTL_ARGS)
 	 */
 	__nouveau_cli_disable_uvmm_noinit(cli);
 
-	engine = NV_DEVICE_HOST_RUNLIST_ENGINES_GR;
+	engine = NVIF_ENGINE_GR;
 
 	/* hack to allow channel engine type specification on kepler */
 	if (device->info.family >= NV_DEVICE_INFO_V0_KEPLER) {
 		if (init->fb_ctxdma_handle == ~0) {
 			switch (init->tt_ctxdma_handle) {
 			case NOUVEAU_FIFO_ENGINE_GR:
-				engine = NV_DEVICE_HOST_RUNLIST_ENGINES_GR;
+				engine = NVIF_ENGINE_GR;
 				break;
 			case NOUVEAU_FIFO_ENGINE_VP:
-				engine = NV_DEVICE_HOST_RUNLIST_ENGINES_MSPDEC;
+				engine = NVIF_ENGINE_MSPDEC;
 				break;
 			case NOUVEAU_FIFO_ENGINE_PPP:
-				engine = NV_DEVICE_HOST_RUNLIST_ENGINES_MSPPP;
+				engine = NVIF_ENGINE_MSPPP;
 				break;
 			case NOUVEAU_FIFO_ENGINE_BSP:
-				engine = NV_DEVICE_HOST_RUNLIST_ENGINES_MSVLD;
+				engine = NVIF_ENGINE_MSVLD;
 				break;
 			case NOUVEAU_FIFO_ENGINE_CE:
-				engine = NV_DEVICE_HOST_RUNLIST_ENGINES_CE;
+				engine = NVIF_ENGINE_CE;
 				break;
 			default:
 				return nouveau_abi16_put(abi16, -ENOSYS);
@@ -368,7 +368,7 @@ nouveau_abi16_ioctl_channel_alloc(ABI16_IOCTL_ARGS)
 		}
 	}
 
-	if (engine != NV_DEVICE_HOST_RUNLIST_ENGINES_CE)
+	if (engine != NVIF_ENGINE_CE)
 		runm = nvif_fifo_runlist(device, engine);
 	else
 		runm = nvif_fifo_runlist_ce(device);
drivers/gpu/drm/nouveau/nouveau_chan.c +8 -35

71 lines not on this page · raw message

drivers/gpu/drm/nouveau/nouveau_drm.c +3 -4
index a37e08f0fd77..76990dde1b6a 100644
@@ -295,14 +295,13 @@ nouveau_accel_ce_fini(struct nouveau_drm *drm)
 static void
 nouveau_accel_ce_init(struct nouveau_drm *drm)
 {
-	struct nvif_device *device = &drm->client.device;
 	u64 runm;
 	int ret = 0;
 
 	/* Allocate channel that has access to a (preferably async) copy
 	 * engine, to use for TTM buffer moves.
 	 */
-	runm = nvif_fifo_runlist_ce(device);
+	runm = nvif_fifo_runlist_ce(&drm->device);
 	if (!runm) {
 		NV_DEBUG(drm, "no ce runlist\n");
 		return;
@@ -325,12 +324,12 @@ nouveau_accel_gr_fini(struct nouveau_drm *drm)
 static void
 nouveau_accel_gr_init(struct nouveau_drm *drm)
 {
-	struct nvif_device *device = &drm->client.device;
+	struct nvif_device *device = &drm->device;
 	u64 runm;
 	int ret;
 
 	/* Allocate channel that has access to the graphics engine. */
-	runm = nvif_fifo_runlist(device, NV_DEVICE_HOST_RUNLIST_ENGINES_GR);
+	runm = nvif_fifo_runlist(device, NVIF_ENGINE_GR);
 	if (!runm) {
 		NV_DEBUG(drm, "no gr runlist\n");
 		return;
drivers/gpu/drm/nouveau/nvif/device.c +0 -4
index 7c28f9764936..d4d00a757cd0 100644
@@ -53,9 +53,6 @@ nvif_device_dtor(struct nvif_device *device)
 
 	nvif_user_dtor(device);
 
-	kfree(device->runlist);
-	device->runlist = NULL;
-
 	nvif_object_unmap_cpu(&device->map);
 
 	device->impl->del(device->priv);
@@ -67,7 +64,6 @@ nvif_device_ctor(struct nvif_client *client, const char *name, struct nvif_devic
 {
 	int ret;
 
-	device->runlist = NULL;
 	device->user.func = NULL;
 
 	ret = client->impl->device.new(client->priv, &device->impl, &device->priv,
drivers/gpu/drm/nouveau/nvif/fifo.c +9 -56

75 lines not on this page · raw message

drivers/gpu/drm/nouveau/nvkm/core/engine.c +0 -12
index 36a31e9eea22..7d59a1d43a5b 100644
@@ -86,17 +86,6 @@ nvkm_engine_intr(struct nvkm_subdev *subdev)
 		engine->func->intr(engine);
 }
 
-static int
-nvkm_engine_info(struct nvkm_subdev *subdev, u64 mthd, u64 *data)
-{
-	struct nvkm_engine *engine = nvkm_engine(subdev);
-
-	if (engine->func->info)
-		return engine->func->info(engine, mthd, data);
-
-	return -ENOSYS;
-}
-
 static int
 nvkm_engine_fini(struct nvkm_subdev *subdev, bool suspend)
 {
@@ -157,7 +146,6 @@ nvkm_engine = {
 	.oneinit = nvkm_engine_oneinit,
 	.init = nvkm_engine_init,
 	.fini = nvkm_engine_fini,
-	.info = nvkm_engine_info,
 	.intr = nvkm_engine_intr,
 };
 
drivers/gpu/drm/nouveau/nvkm/core/subdev.c +0 -8
index 6c20e827a069..d8b6d0f31883 100644
@@ -42,14 +42,6 @@ nvkm_subdev_intr(struct nvkm_subdev *subdev)
 		subdev->func->intr(subdev);
 }
 
-int
-nvkm_subdev_info(struct nvkm_subdev *subdev, u64 mthd, u64 *data)
-{
-	if (subdev->func->info)
-		return subdev->func->info(subdev, mthd, data);
-	return -ENOSYS;
-}
-
 int
 nvkm_subdev_fini(struct nvkm_subdev *subdev, bool suspend)
 {
drivers/gpu/drm/nouveau/nvkm/device/user.c +0 -58

70 lines not on this page · raw message

drivers/gpu/drm/nouveau/nvkm/engine/fifo/base.c +0 -73

85 lines not on this page · raw message

drivers/gpu/drm/nouveau/nvkm/engine/fifo/ufifo.c +99 -0

110 lines not on this page · raw message

Signature · 1 line
2.41.0
author
#70 lore raw

PATCH 69/156 drm/nouveau/nvif: rework device "time" api

In reply to Ben Skeggs

- transition from "ioctl" interface

---
 drivers/gpu/drm/nouveau/include/nvif/cl0080.h |  7 ----
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  2 +
 drivers/gpu/drm/nouveau/nvif/device.c         |  9 +---
 drivers/gpu/drm/nouveau/nvkm/device/user.c    | 41 ++-----------------
 4 files changed, 8 insertions(+), 51 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/cl0080.h +0 -7
index f1684dbd8e3b..db096a41dc4f 100644
@@ -3,7 +3,6 @@
 #define __NVIF_CL0080_H__
 
 #define NV_DEVICE_V0_INFO                                                  0x00
-#define NV_DEVICE_V0_TIME                                                  0x01
 
 struct nv_device_info_v0 {
 	__u8  version;
@@ -36,10 +35,4 @@ struct nv_device_info_v0 {
 	char  chip[16];
 	char  name[64];
 };
-
-struct nv_device_time_v0 {
-	__u8  version;
-	__u8  pad01[7];
-	__u64 time;
-};
 #endif
drivers/gpu/drm/nouveau/include/nvif/driverif.h +2 -0
index 54446d38cb91..44064b5da897 100644
@@ -61,6 +61,8 @@ struct nvif_device_impl {
 	u64 ram_size;
 	u64 ram_user;
 
+	u64 (*time)(struct nvif_device_priv *);
+
 	struct {
 		s32 oclass;
 	} usermode;
drivers/gpu/drm/nouveau/nvif/device.c +2 -7
index d4d00a757cd0..7d057691600f 100644
@@ -28,13 +28,8 @@
 u64
 nvif_device_time(struct nvif_device *device)
 {
-	if (!device->user.func) {
-		struct nv_device_time_v0 args = {};
-		int ret = nvif_object_mthd(&device->object, NV_DEVICE_V0_TIME,
-					   &args, sizeof(args));
-		WARN_ON_ONCE(ret != 0);
-		return args.time;
-	}
+	if (!device->user.func)
+		return device->impl->time(device->priv);
 
 	return device->user.func->time(&device->user);
 }
drivers/gpu/drm/nouveau/nvkm/device/user.c +4 -37

68 lines not on this page · raw message

Signature · 1 line
2.41.0
author
#71 lore raw

PATCH 70/156 drm/nouveau/nvif: rework device "new ctrl" api

In reply to Ben Skeggs

- transition from "ioctl" interface

---
 drivers/gpu/drm/nouveau/include/nvif/class.h  |  2 --
 .../gpu/drm/nouveau/include/nvif/driverif.h   | 11 ++++++
 drivers/gpu/drm/nouveau/nouveau_debugfs.c     | 17 +++++----
 drivers/gpu/drm/nouveau/nouveau_debugfs.h     |  2 ++
 drivers/gpu/drm/nouveau/nvkm/device/ctrl.c    | 35 +++++++++++--------
 drivers/gpu/drm/nouveau/nvkm/device/ctrl.h    |  5 ++-
 drivers/gpu/drm/nouveau/nvkm/device/user.c    | 20 +++++++++--
 7 files changed, 66 insertions(+), 26 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/class.h +0 -2
index b6bba7231750..6174999eacd3 100644
@@ -3,8 +3,6 @@
 #define __NVIF_CLASS_H__
 
 /* these class numbers are made up by us, and not nvidia-assigned */
-#define NVIF_CLASS_CONTROL                           /* if0001.h */ -0x00000001
-
 #define NVIF_CLASS_SW_NV04                           /* if0004.h */ -0x00000004
 #define NVIF_CLASS_SW_NV10                           /* if0005.h */ -0x00000005
 #define NVIF_CLASS_SW_NV50                           /* if0005.h */ -0x00000006
drivers/gpu/drm/nouveau/include/nvif/driverif.h +11 -0
index 44064b5da897..aa1061266557 100644
@@ -3,6 +3,7 @@
 #define __NVIF_DRIVERIF_H__
 struct nvif_client_priv;
 struct nvif_device_priv;
+struct nvif_control_priv;
 
 struct nvif_driver {
 	const char *name;
@@ -22,6 +23,10 @@ struct nvif_mapinfo {
 	u64 length;
 };
 
+struct nvif_control_impl {
+	void (*del)(struct nvif_control_priv *);
+};
+
 struct nvif_device_impl {
 	void (*del)(struct nvif_device_priv *);
 
@@ -63,6 +68,12 @@ struct nvif_device_impl {
 
 	u64 (*time)(struct nvif_device_priv *);
 
+	struct {
+		int (*new)(struct nvif_device_priv *,
+			   const struct nvif_control_impl **, struct nvif_control_priv **,
+			   u64 handle);
+	} control;
+
 	struct {
 		s32 oclass;
 	} usermode;
drivers/gpu/drm/nouveau/nouveau_debugfs.c +11 -6
index e83db051e851..e061ef7a1707 100644
@@ -29,7 +29,6 @@
  */
 
 #include <linux/debugfs.h>
-#include <nvif/class.h>
 #include <nvif/if0001.h>
 #include "nouveau_debugfs.h"
 #include "nouveau_drv.h"
@@ -295,20 +294,26 @@ nouveau_drm_debugfs_init(struct drm_minor *minor)
 int
 nouveau_debugfs_init(struct nouveau_drm *drm)
 {
+	int ret;
+
 	drm->debugfs = kzalloc(sizeof(*drm->debugfs), GFP_KERNEL);
 	if (!drm->debugfs)
 		return -ENOMEM;
 
-	return nvif_object_ctor(&drm->client.device.object, "debugfsCtrl", 0,
-				NVIF_CLASS_CONTROL, NULL, 0,
-				&drm->debugfs->ctrl);
+	ret = drm->device.impl->control.new(drm->device.priv, &drm->debugfs->impl,
+					    &drm->debugfs->priv, nvif_handle(&drm->debugfs->ctrl));
+	if (ret)
+		return ret;
+
+	nvif_object_ctor(&drm->device.object, "debugfsCtrl", 0, 0, &drm->debugfs->ctrl);
+	return 0;
 }
 
 void
 nouveau_debugfs_fini(struct nouveau_drm *drm)
 {
-	if (drm->debugfs && drm->debugfs->ctrl.priv)
-		nvif_object_dtor(&drm->debugfs->ctrl);
+	if (drm->debugfs && drm->debugfs->impl)
+		drm->debugfs->impl->del(drm->debugfs->priv);
 
 	kfree(drm->debugfs);
 	drm->debugfs = NULL;
drivers/gpu/drm/nouveau/nouveau_debugfs.h +2 -0
index 77f0323b38ba..197e81f771d5 100644
@@ -9,6 +9,8 @@
 #include "nouveau_drv.h"
 
 struct nouveau_debugfs {
+	const struct nvif_control_impl *impl;
+	struct nvif_control_priv *priv;
 	struct nvif_object ctrl;
 };
 
drivers/gpu/drm/nouveau/nvkm/device/ctrl.c +21 -14
index a74fb78ca7ab..5caa93665cc9 100644
@@ -26,7 +26,6 @@
 #include <core/client.h>
 #include <subdev/clk.h>
 
-#include <nvif/class.h>
 #include <nvif/if0001.h>
 #include <nvif/ioctl.h>
 #include <nvif/unpack.h>
@@ -195,25 +194,33 @@ nvkm_control = {
 	.mthd = nvkm_control_mthd,
 };
 
-static int
-nvkm_control_new(struct nvkm_device *device, const struct nvkm_oclass *oclass,
-		 void *data, u32 size, struct nvkm_object **pobject)
+static void
+nvkm_control_del(struct nvif_control_priv *ctrl)
+{
+	struct nvkm_object *object = &ctrl->object;
+
+	nvkm_object_del(&object);
+}
+
+static const struct nvif_control_impl
+nvkm_control_impl = {
+	.del = nvkm_control_del,
+};
+
+int
+nvkm_control_new(struct nvkm_device *device, const struct nvif_control_impl **pimpl,
+		 struct nvif_control_priv **ppriv, struct nvkm_object **pobject)
 {
 	struct nvif_control_priv *ctrl;
 
 	if (!(ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL)))
 		return -ENOMEM;
-	*pobject = &ctrl->object;
+
+	nvkm_object_ctor(&nvkm_control, &(struct nvkm_oclass) {}, &ctrl->object);
 	ctrl->device = device;
 
-	nvkm_object_ctor(&nvkm_control, oclass, &ctrl->object);
+	*pimpl = &nvkm_control_impl;
+	*ppriv = ctrl;
+	*pobject = &ctrl->object;
 	return 0;
 }
-
-const struct nvkm_device_oclass
-nvkm_control_oclass = {
-	.base.oclass = NVIF_CLASS_CONTROL,
-	.base.minver = -1,
-	.base.maxver = -1,
-	.ctor = nvkm_control_new,
-};
drivers/gpu/drm/nouveau/nvkm/device/ctrl.h +4 -1
index d241329a1e7a..c435ddf0a713 100644
@@ -1,6 +1,9 @@
 /* SPDX-License-Identifier: MIT */
 #ifndef __NVKM_DEVICE_CTRL_H__
 #define __NVKM_DEVICE_CTRL_H__
+#include <core/device.h>
+#include <nvif/driverif.h>
 
-extern const struct nvkm_device_oclass nvkm_control_oclass;
+int nvkm_control_new(struct nvkm_device *, const struct nvif_control_impl **,
+		     struct nvif_control_priv **, struct nvkm_object **);
 #endif
drivers/gpu/drm/nouveau/nvkm/device/user.c +17 -3
index b37c857863b8..14d548c3f6b0 100644
@@ -39,6 +39,21 @@ struct nvif_device_priv {
 	struct nvif_device_impl impl;
 };
 
+static int
+nvkm_udevice_control_new(struct nvif_device_priv *udev,
+			 const struct nvif_control_impl **pimpl, struct nvif_control_priv **ppriv,
+			 u64 handle)
+{
+	struct nvkm_object *object;
+	int ret;
+
+	ret = nvkm_control_new(udev->device, pimpl, ppriv, &object);
+	if (ret)
+		return ret;
+
+	return nvkm_object_link_rb(udev->object.client, &udev->object, handle, object);
+}
+
 static u64
 nvkm_udevice_time(struct nvif_device_priv *udev)
 {
@@ -58,6 +73,7 @@ static const struct nvif_device_impl
 nvkm_udevice_impl = {
 	.del = nvkm_udevice_del,
 	.time = nvkm_udevice_time,
+	.control.new = nvkm_udevice_control_new,
 };
 
 static int
@@ -134,9 +150,7 @@ nvkm_udevice_child_get(struct nvkm_object *object, int index,
 	}
 
 	if (!sclass) {
-		if (index-- == 0)
-			sclass = &nvkm_control_oclass;
-		else if (device->mmu && index-- == 0)
+		if (device->mmu && index-- == 0)
 			sclass = &device->mmu->user;
 		else if (device->fault && index-- == 0)
 			sclass = &device->fault->user;
Signature · 1 line
2.41.0
author
#72 lore raw

PATCH 71/156 drm/nouveau/nvif: rework ctrl "pstate info" api

In reply to Ben Skeggs

- transition from "ioctl" interface

---
 .../gpu/drm/nouveau/include/nvif/driverif.h   | 17 ++++++++
 drivers/gpu/drm/nouveau/include/nvif/if0001.h | 15 -------
 drivers/gpu/drm/nouveau/nouveau_debugfs.c     |  6 +--
 drivers/gpu/drm/nouveau/nvkm/device/ctrl.c    | 40 ++++++-------------
 4 files changed, 32 insertions(+), 46 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/driverif.h +17 -0
index aa1061266557..ba8b5ff9fcd6 100644
@@ -23,8 +23,25 @@ struct nvif_mapinfo {
 	u64 length;
 };
 
+struct nvif_control_pstate_info {
+	u8  version;
+	u8  count; /* out: number of power states */
+#define NVIF_CONTROL_PSTATE_INFO_USTATE_DISABLE                         (-1)
+#define NVIF_CONTROL_PSTATE_INFO_USTATE_PERFMON                         (-2)
+	s8  ustate_ac; /* out: target pstate index */
+	s8  ustate_dc; /* out: target pstate index */
+	s8  pwrsrc; /* out: current power source */
+#define NVIF_CONTROL_PSTATE_INFO_PSTATE_UNKNOWN                         (-1)
+#define NVIF_CONTROL_PSTATE_INFO_PSTATE_PERFMON                         (-2)
+	s8  pstate; /* out: current pstate index */
+};
+
 struct nvif_control_impl {
 	void (*del)(struct nvif_control_priv *);
+
+	struct {
+		void (*info)(struct nvif_control_priv *, struct nvif_control_pstate_info *);
+	} pstate;
 };
 
 struct nvif_device_impl {
drivers/gpu/drm/nouveau/include/nvif/if0001.h +0 -15
index 4ced50e98ced..9bb955500934 100644
@@ -2,24 +2,9 @@
 #ifndef __NVIF_IF0001_H__
 #define __NVIF_IF0001_H__
 
-#define NVIF_CONTROL_PSTATE_INFO                                           0x00
 #define NVIF_CONTROL_PSTATE_ATTR                                           0x01
 #define NVIF_CONTROL_PSTATE_USER                                           0x02
 
-struct nvif_control_pstate_info_v0 {
-	__u8  version;
-	__u8  count; /* out: number of power states */
-#define NVIF_CONTROL_PSTATE_INFO_V0_USTATE_DISABLE                         (-1)
-#define NVIF_CONTROL_PSTATE_INFO_V0_USTATE_PERFMON                         (-2)
-	__s8  ustate_ac; /* out: target pstate index */
-	__s8  ustate_dc; /* out: target pstate index */
-	__s8  pwrsrc; /* out: current power source */
-#define NVIF_CONTROL_PSTATE_INFO_V0_PSTATE_UNKNOWN                         (-1)
-#define NVIF_CONTROL_PSTATE_INFO_V0_PSTATE_PERFMON                         (-2)
-	__s8  pstate; /* out: current pstate index */
-	__u8  pad06[2];
-};
-
 struct nvif_control_pstate_attr_v0 {
 	__u8  version;
 #define NVIF_CONTROL_PSTATE_ATTR_V0_STATE_CURRENT                          (-1)
drivers/gpu/drm/nouveau/nouveau_debugfs.c +2 -4
index e061ef7a1707..caccf99f1d8a 100644
@@ -73,16 +73,14 @@ nouveau_debugfs_pstate_get(struct seq_file *m, void *data)
 	struct drm_device *drm = m->private;
 	struct nouveau_debugfs *debugfs = nouveau_debugfs(drm);
 	struct nvif_object *ctrl;
-	struct nvif_control_pstate_info_v0 info = {};
+	struct nvif_control_pstate_info info = {};
 	int ret, i;
 
 	if (!debugfs)
 		return -ENODEV;
 
 	ctrl = &debugfs->ctrl;
-	ret = nvif_mthd(ctrl, NVIF_CONTROL_PSTATE_INFO, &info, sizeof(info));
-	if (ret)
-		return ret;
+	debugfs->impl->pstate.info(debugfs->priv, &info);
 
 	for (i = 0; i < info.count + 1; i++) {
 		const s32 state = i < info.count ? i :
drivers/gpu/drm/nouveau/nvkm/device/ctrl.c +13 -27
index 5caa93665cc9..ea38592f5557 100644
@@ -37,37 +37,24 @@ struct nvif_control_priv {
 	struct nvkm_device *device;
 };
 
-static int
-nvkm_control_mthd_pstate_info(struct nvkm_control *ctrl, void *data, u32 size)
+static void
+nvkm_control_pstate_info(struct nvif_control_priv *ctrl, struct nvif_control_pstate_info *info)
 {
-	union {
-		struct nvif_control_pstate_info_v0 v0;
-	} *args = data;
 	struct nvkm_clk *clk = ctrl->device->clk;
-	int ret = -ENOSYS;
-
-	nvif_ioctl(&ctrl->object, "control pstate info size %d\n", size);
-	if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
-		nvif_ioctl(&ctrl->object, "control pstate info vers %d\n",
-			   args->v0.version);
-	} else
-		return ret;
 
 	if (clk) {
-		args->v0.count = clk->state_nr;
-		args->v0.ustate_ac = clk->ustate_ac;
-		args->v0.ustate_dc = clk->ustate_dc;
-		args->v0.pwrsrc = clk->pwrsrc;
-		args->v0.pstate = clk->pstate;
+		info->count = clk->state_nr;
+		info->ustate_ac = clk->ustate_ac;
+		info->ustate_dc = clk->ustate_dc;
+		info->pwrsrc = clk->pwrsrc;
+		info->pstate = clk->pstate;
 	} else {
-		args->v0.count = 0;
-		args->v0.ustate_ac = NVIF_CONTROL_PSTATE_INFO_V0_USTATE_DISABLE;
-		args->v0.ustate_dc = NVIF_CONTROL_PSTATE_INFO_V0_USTATE_DISABLE;
-		args->v0.pwrsrc = -ENODEV;
-		args->v0.pstate = NVIF_CONTROL_PSTATE_INFO_V0_PSTATE_UNKNOWN;
+		info->count = 0;
+		info->ustate_ac = NVIF_CONTROL_PSTATE_INFO_USTATE_DISABLE;
+		info->ustate_dc = NVIF_CONTROL_PSTATE_INFO_USTATE_DISABLE;
+		info->pwrsrc = -ENODEV;
+		info->pstate = NVIF_CONTROL_PSTATE_INFO_PSTATE_UNKNOWN;
 	}
-
-	return 0;
 }
 
 static int
@@ -177,8 +164,6 @@ nvkm_control_mthd(struct nvkm_object *object, u32 mthd, void *data, u32 size)
 {
 	struct nvif_control_priv *ctrl = container_of(object, typeof(*ctrl), object);
 	switch (mthd) {
-	case NVIF_CONTROL_PSTATE_INFO:
-		return nvkm_control_mthd_pstate_info(ctrl, data, size);
 	case NVIF_CONTROL_PSTATE_ATTR:
 		return nvkm_control_mthd_pstate_attr(ctrl, data, size);
 	case NVIF_CONTROL_PSTATE_USER:
@@ -205,6 +190,7 @@ nvkm_control_del(struct nvif_control_priv *ctrl)
 static const struct nvif_control_impl
 nvkm_control_impl = {
 	.del = nvkm_control_del,
+	.pstate.info = nvkm_control_pstate_info,
 };
 
 int
Signature · 1 line
2.41.0
author
#73 lore raw

PATCH 72/156 drm/nouveau/nvif: rework ctrl "pstate attr" api

In reply to Ben Skeggs

- transition from "ioctl" interface

---
 .../gpu/drm/nouveau/include/nvif/driverif.h   | 16 ++++++
 drivers/gpu/drm/nouveau/include/nvif/if0001.h | 17 -------
 drivers/gpu/drm/nouveau/nouveau_debugfs.c     | 12 ++---
 drivers/gpu/drm/nouveau/nvkm/device/ctrl.c    | 49 +++++++------------
 4 files changed, 39 insertions(+), 55 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/driverif.h +16 -0
index ba8b5ff9fcd6..bfa22c977323 100644
@@ -23,6 +23,21 @@ struct nvif_mapinfo {
 	u64 length;
 };
 
+struct nvif_control_pstate_attr {
+	u8  version;
+#define NVIF_CONTROL_PSTATE_ATTR_STATE_CURRENT                          (-1)
+	s8  state; /*  in: index of pstate to query
+		    * out: pstate identifier
+		    */
+	u8  index; /*  in: index of attribute to query
+		    * out: index of next attribute, or 0 if no more
+		    */
+	u32 min;
+	u32 max;
+	char  name[32];
+	char  unit[16];
+};
+
 struct nvif_control_pstate_info {
 	u8  version;
 	u8  count; /* out: number of power states */
@@ -41,6 +56,7 @@ struct nvif_control_impl {
 
 	struct {
 		void (*info)(struct nvif_control_priv *, struct nvif_control_pstate_info *);
+		int  (*attr)(struct nvif_control_priv *, struct nvif_control_pstate_attr *);
 	} pstate;
 };
 
drivers/gpu/drm/nouveau/include/nvif/if0001.h +0 -17
index 9bb955500934..b84da0b7d079 100644
@@ -2,25 +2,8 @@
 #ifndef __NVIF_IF0001_H__
 #define __NVIF_IF0001_H__
 
-#define NVIF_CONTROL_PSTATE_ATTR                                           0x01
 #define NVIF_CONTROL_PSTATE_USER                                           0x02
 
-struct nvif_control_pstate_attr_v0 {
-	__u8  version;
-#define NVIF_CONTROL_PSTATE_ATTR_V0_STATE_CURRENT                          (-1)
-	__s8  state; /*  in: index of pstate to query
-		      * out: pstate identifier
-		      */
-	__u8  index; /*  in: index of attribute to query
-		      * out: index of next attribute, or 0 if no more
-		      */
-	__u8  pad03[5];
-	__u32 min;
-	__u32 max;
-	char  name[32];
-	char  unit[16];
-};
-
 struct nvif_control_pstate_user_v0 {
 	__u8  version;
 #define NVIF_CONTROL_PSTATE_USER_V0_STATE_UNKNOWN                          (-1)
drivers/gpu/drm/nouveau/nouveau_debugfs.c +4 -8
index caccf99f1d8a..33a64f95f64f 100644
@@ -72,26 +72,23 @@ nouveau_debugfs_pstate_get(struct seq_file *m, void *data)
 {
 	struct drm_device *drm = m->private;
 	struct nouveau_debugfs *debugfs = nouveau_debugfs(drm);
-	struct nvif_object *ctrl;
 	struct nvif_control_pstate_info info = {};
 	int ret, i;
 
 	if (!debugfs)
 		return -ENODEV;
 
-	ctrl = &debugfs->ctrl;
 	debugfs->impl->pstate.info(debugfs->priv, &info);
 
 	for (i = 0; i < info.count + 1; i++) {
 		const s32 state = i < info.count ? i :
-			NVIF_CONTROL_PSTATE_ATTR_V0_STATE_CURRENT;
-		struct nvif_control_pstate_attr_v0 attr = {
+			NVIF_CONTROL_PSTATE_ATTR_STATE_CURRENT;
+		struct nvif_control_pstate_attr attr = {
 			.state = state,
 			.index = 0,
 		};
 
-		ret = nvif_mthd(ctrl, NVIF_CONTROL_PSTATE_ATTR,
-				&attr, sizeof(attr));
+		ret = debugfs->impl->pstate.attr(debugfs->priv, &attr);
 		if (ret)
 			return ret;
 
@@ -104,8 +101,7 @@ nouveau_debugfs_pstate_get(struct seq_file *m, void *data)
 		attr.index = 0;
 		do {
 			attr.state = state;
-			ret = nvif_mthd(ctrl, NVIF_CONTROL_PSTATE_ATTR,
-					&attr, sizeof(attr));
+			ret = debugfs->impl->pstate.attr(debugfs->priv, &attr);
 			if (ret)
 				return ret;
 
drivers/gpu/drm/nouveau/nvkm/device/ctrl.c +19 -30

99 lines not on this page · raw message

Signature · 1 line
2.41.0