nouveau.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm
@ 2024-04-16 23:37 Ben Skeggs
  2024-04-16 23:37 ` [PATCH 001/156] drm/nouveau: add nouveau_drm.device/mmu Ben Skeggs
                   ` (157 more replies)
  0 siblings, 158 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:37 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

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

-- 
2.41.0


^ permalink raw reply	[flat|nested] 163+ messages in thread

* [PATCH 001/156] drm/nouveau: add nouveau_drm.device/mmu
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
@ 2024-04-16 23:37 ` Ben Skeggs
  2024-04-16 23:37 ` [PATCH 002/156] drm/nouveau: alias nouveau_drm.client to nouveau_drm.cli Ben Skeggs
                   ` (156 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:37 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- removing nouveau_drm.master, and will transition to these

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/nouveau_drm.c | 25 ++++++++++++++++++++++++-
 drivers/gpu/drm/nouveau/nouveau_drv.h |  3 +++
 2 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index a947e1d5f309..7e651779751d 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -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);
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h
index e239c6bf4afa..a7079efe42f3 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.h
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.h
@@ -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;
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 002/156] drm/nouveau: alias nouveau_drm.client to nouveau_drm.cli
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
  2024-04-16 23:37 ` [PATCH 001/156] drm/nouveau: add nouveau_drm.device/mmu Ben Skeggs
@ 2024-04-16 23:37 ` Ben Skeggs
  2024-04-16 23:37 ` [PATCH 003/156] drm/nouveau: pass drm to nouveau_mem_new(), instead of cli Ben Skeggs
                   ` (155 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:37 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

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

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/nouveau_drm.c | 6 +++---
 drivers/gpu/drm/nouveau/nouveau_drv.h | 5 ++++-
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 7e651779751d..be9088ed273e 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -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);
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h
index a7079efe42f3..8f04f3630936 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.h
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.h
@@ -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;
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 003/156] drm/nouveau: pass drm to nouveau_mem_new(), instead of cli
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
  2024-04-16 23:37 ` [PATCH 001/156] drm/nouveau: add nouveau_drm.device/mmu Ben Skeggs
  2024-04-16 23:37 ` [PATCH 002/156] drm/nouveau: alias nouveau_drm.client to nouveau_drm.cli Ben Skeggs
@ 2024-04-16 23:37 ` Ben Skeggs
  2024-04-16 23:37 ` [PATCH 004/156] drm/nouveau: pass drm to nv50_dmac_create(), rather than device+disp Ben Skeggs
                   ` (154 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:37 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

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

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 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(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_mem.c b/drivers/gpu/drm/nouveau/nouveau_mem.c
index 25f31d5169e5..4d9ac9f30f05 100644
--- a/drivers/gpu/drm/nouveau/nouveau_mem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_mem.c
@@ -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;
 
diff --git a/drivers/gpu/drm/nouveau/nouveau_mem.h b/drivers/gpu/drm/nouveau/nouveau_mem.h
index 5365a3d3a17f..a070ee049f6b 100644
--- a/drivers/gpu/drm/nouveau/nouveau_mem.h
+++ b/drivers/gpu/drm/nouveau/nouveau_mem.h
@@ -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 *);
diff --git a/drivers/gpu/drm/nouveau/nouveau_sgdma.c b/drivers/gpu/drm/nouveau/nouveau_sgdma.c
index b14895f75b3c..172744470bd1 100644
--- a/drivers/gpu/drm/nouveau/nouveau_sgdma.c
+++ b/drivers/gpu/drm/nouveau/nouveau_sgdma.c
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c
index 486f39f31a38..57c7e3ba8e7b 100644
--- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
@@ -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);
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 004/156] drm/nouveau: pass drm to nv50_dmac_create(), rather than device+disp
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (2 preceding siblings ...)
  2024-04-16 23:37 ` [PATCH 003/156] drm/nouveau: pass drm to nouveau_mem_new(), instead of cli Ben Skeggs
@ 2024-04-16 23:37 ` Ben Skeggs
  2024-04-17  6:27   ` Philipp Stanner
  2024-04-16 23:37 ` [PATCH 005/156] drm/nouveau: pass cli to nouveau_channel_new() instead of drm+device Ben Skeggs
                   ` (153 subsequent siblings)
  157 siblings, 1 reply; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:37 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- zero reason to do otherwise

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 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(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv50/base507c.c b/drivers/gpu/drm/nouveau/dispnv50/base507c.c
index 70c62b861276..e36a473f2075 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/base507c.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/base507c.c
@@ -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) {
diff --git a/drivers/gpu/drm/nouveau/dispnv50/core507d.c b/drivers/gpu/drm/nouveau/dispnv50/core507d.c
index e5bb5ca950c8..85845e3dc7ba 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/core507d.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/core507d.c
@@ -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) {
diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c b/drivers/gpu/drm/nouveau/dispnv50/disp.c
index 0c3d88ad0b0e..f8ca57cc7af6 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/disp.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.h b/drivers/gpu/drm/nouveau/dispnv50/disp.h
index 5508a7cfd492..da3add95f354 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/disp.h
+++ b/drivers/gpu/drm/nouveau/dispnv50/disp.h
@@ -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 *);
diff --git a/drivers/gpu/drm/nouveau/dispnv50/ovly507e.c b/drivers/gpu/drm/nouveau/dispnv50/ovly507e.c
index 797c1e4e0eaa..73fcfb27c32c 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/ovly507e.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/ovly507e.c
@@ -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) {
diff --git a/drivers/gpu/drm/nouveau/dispnv50/wimmc37b.c b/drivers/gpu/drm/nouveau/dispnv50/wimmc37b.c
index ee76b091d4ef..8cb5b79bacbf 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/wimmc37b.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/wimmc37b.c
@@ -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) {
diff --git a/drivers/gpu/drm/nouveau/dispnv50/wndwc37e.c b/drivers/gpu/drm/nouveau/dispnv50/wndwc37e.c
index b3deea5aca58..caf40977f455 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/wndwc37e.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/wndwc37e.c
@@ -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) {
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 005/156] drm/nouveau: pass cli to nouveau_channel_new() instead of drm+device
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (3 preceding siblings ...)
  2024-04-16 23:37 ` [PATCH 004/156] drm/nouveau: pass drm to nv50_dmac_create(), rather than device+disp Ben Skeggs
@ 2024-04-16 23:37 ` Ben Skeggs
  2024-04-16 23:37 ` [PATCH 006/156] drm/nouveau: remove nouveau_chan.device Ben Skeggs
                   ` (152 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:37 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- both of these are stored in nouveau_cli already

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 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(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_abi16.c b/drivers/gpu/drm/nouveau/nouveau_abi16.c
index f465fe93b1f7..291107ddc59b 100644
--- a/drivers/gpu/drm/nouveau/nouveau_abi16.c
+++ b/drivers/gpu/drm/nouveau/nouveau_abi16.c
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/nouveau_chan.c b/drivers/gpu/drm/nouveau/nouveau_chan.c
index 7c97b2886807..290523522717 100644
--- a/drivers/gpu/drm/nouveau/nouveau_chan.c
+++ b/drivers/gpu/drm/nouveau/nouveau_chan.c
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/nouveau_chan.h b/drivers/gpu/drm/nouveau/nouveau_chan.h
index 5de2ef4e98c2..260febd634ee 100644
--- a/drivers/gpu/drm/nouveau/nouveau_chan.h
+++ b/drivers/gpu/drm/nouveau/nouveau_chan.h
@@ -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 *);
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index be9088ed273e..da5bb7c51dab 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -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);
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 006/156] drm/nouveau: remove nouveau_chan.device
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (4 preceding siblings ...)
  2024-04-16 23:37 ` [PATCH 005/156] drm/nouveau: pass cli to nouveau_channel_new() instead of drm+device Ben Skeggs
@ 2024-04-16 23:37 ` Ben Skeggs
  2024-04-16 23:37 ` [PATCH 007/156] drm/nouveau: remove chan->drm Ben Skeggs
                   ` (151 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:37 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- not required for anything

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/nouveau_chan.c | 3 +--
 drivers/gpu/drm/nouveau/nouveau_chan.h | 1 -
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_chan.c b/drivers/gpu/drm/nouveau/nouveau_chan.c
index 290523522717..e4065b7f1f9f 100644
--- a/drivers/gpu/drm/nouveau/nouveau_chan.c
+++ b/drivers/gpu/drm/nouveau/nouveau_chan.c
@@ -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;
 
diff --git a/drivers/gpu/drm/nouveau/nouveau_chan.h b/drivers/gpu/drm/nouveau/nouveau_chan.h
index 260febd634ee..18a9cbfef8ca 100644
--- a/drivers/gpu/drm/nouveau/nouveau_chan.h
+++ b/drivers/gpu/drm/nouveau/nouveau_chan.h
@@ -13,7 +13,6 @@ struct nouveau_channel {
 	} chan;
 
 	struct nouveau_cli *cli;
-	struct nvif_device *device;
 	struct nouveau_drm *drm;
 	struct nouveau_vmm *vmm;
 
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 007/156] drm/nouveau: remove chan->drm
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (5 preceding siblings ...)
  2024-04-16 23:37 ` [PATCH 006/156] drm/nouveau: remove nouveau_chan.device Ben Skeggs
@ 2024-04-16 23:37 ` Ben Skeggs
  2024-04-16 23:37 ` [PATCH 008/156] drm/nouveau: replace some void casts with chan->cli Ben Skeggs
                   ` (150 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:37 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

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

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 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(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv04/crtc.c b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
index 4310ad71870b..8f2fd5d9dcb7 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/crtc.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo0039.c b/drivers/gpu/drm/nouveau/nouveau_bo0039.c
index e2ce44adaa5c..2babc6c47241 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo0039.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo0039.c
@@ -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;
 }
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo5039.c b/drivers/gpu/drm/nouveau/nouveau_bo5039.c
index c6cf3629a9f9..0a6b1fce1108 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo5039.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo5039.c
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/nouveau_chan.c b/drivers/gpu/drm/nouveau/nouveau_chan.c
index e4065b7f1f9f..a5eeb6e76ff1 100644
--- a/drivers/gpu/drm/nouveau/nouveau_chan.c
+++ b/drivers/gpu/drm/nouveau/nouveau_chan.c
@@ -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
diff --git a/drivers/gpu/drm/nouveau/nouveau_chan.h b/drivers/gpu/drm/nouveau/nouveau_chan.h
index 18a9cbfef8ca..3ce9832c9528 100644
--- a/drivers/gpu/drm/nouveau/nouveau_chan.h
+++ b/drivers/gpu/drm/nouveau/nouveau_chan.h
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/nouveau_dma.c b/drivers/gpu/drm/nouveau/nouveau_dma.c
index b01c029f3a90..a1f329ef0641 100644
--- a/drivers/gpu/drm/nouveau/nouveau_dma.c
+++ b/drivers/gpu/drm/nouveau/nouveau_dma.c
@@ -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;
 
diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.c b/drivers/gpu/drm/nouveau/nouveau_fence.c
index 93f08f9479d8..ba25ce1294a6 100644
--- a/drivers/gpu/drm/nouveau/nouveau_fence.c
+++ b/drivers/gpu/drm/nouveau/nouveau_fence.c
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
index 5a887d67dc0e..22f4ee483ff3 100644
--- a/drivers/gpu/drm/nouveau/nouveau_gem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
@@ -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");
diff --git a/drivers/gpu/drm/nouveau/nv17_fence.c b/drivers/gpu/drm/nouveau/nv17_fence.c
index 07c2e0878c24..7fa52ec61b30 100644
--- a/drivers/gpu/drm/nouveau/nv17_fence.c
+++ b/drivers/gpu/drm/nouveau/nv17_fence.c
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/nv50_fence.c b/drivers/gpu/drm/nouveau/nv50_fence.c
index ea1e1f480bfe..8b76cb227f55 100644
--- a/drivers/gpu/drm/nouveau/nv50_fence.c
+++ b/drivers/gpu/drm/nouveau/nv50_fence.c
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/nv84_fence.c b/drivers/gpu/drm/nouveau/nv84_fence.c
index 812b8c62eeba..7f62089dc940 100644
--- a/drivers/gpu/drm/nouveau/nv84_fence.c
+++ b/drivers/gpu/drm/nouveau/nv84_fence.c
@@ -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;
 
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 008/156] drm/nouveau: replace some void casts with chan->cli
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (6 preceding siblings ...)
  2024-04-16 23:37 ` [PATCH 007/156] drm/nouveau: remove chan->drm Ben Skeggs
@ 2024-04-16 23:37 ` Ben Skeggs
  2024-04-16 23:37 ` [PATCH 009/156] drm/nouveau: remove nouveau_drm.master Ben Skeggs
                   ` (149 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:37 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- probably a touch safer...

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 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(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv04/crtc.c b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
index 8f2fd5d9dcb7..3535cf571300 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/crtc.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
@@ -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);
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
index 1e2d28fd10dc..e1483fd5d283 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -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;
 
diff --git a/drivers/gpu/drm/nouveau/nouveau_chan.c b/drivers/gpu/drm/nouveau/nouveau_chan.c
index a5eeb6e76ff1..ea8db569bd1a 100644
--- a/drivers/gpu/drm/nouveau/nouveau_chan.c
+++ b/drivers/gpu/drm/nouveau/nouveau_chan.c
@@ -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;
 
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 009/156] drm/nouveau: remove nouveau_drm.master
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (7 preceding siblings ...)
  2024-04-16 23:37 ` [PATCH 008/156] drm/nouveau: replace some void casts with chan->cli Ben Skeggs
@ 2024-04-16 23:37 ` Ben Skeggs
  2024-04-16 23:37 ` [PATCH 010/156] drm/nouveau: always map device Ben Skeggs
                   ` (148 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:37 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- preparation for upcoming api changes

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 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(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index da5bb7c51dab..ad5de7ed48ce 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h
index 8f04f3630936..683600db4ff9 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.h
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.h
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/nouveau_mem.c b/drivers/gpu/drm/nouveau/nouveau_mem.c
index 4d9ac9f30f05..baea74899fcf 100644
--- a/drivers/gpu/drm/nouveau/nouveau_mem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_mem.c
@@ -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;
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 010/156] drm/nouveau: always map device
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (8 preceding siblings ...)
  2024-04-16 23:37 ` [PATCH 009/156] drm/nouveau: remove nouveau_drm.master Ben Skeggs
@ 2024-04-16 23:37 ` Ben Skeggs
  2024-04-16 23:37 ` [PATCH 011/156] drm/nouveau: add nouveau_cli to nouveau_abi16 Ben Skeggs
                   ` (147 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:37 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

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

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 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(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv04/disp.c b/drivers/gpu/drm/nouveau/dispnv04/disp.c
index 13705c5f1497..e8b27bb135e7 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/disp.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/disp.c
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/include/nvif/device.h b/drivers/gpu/drm/nouveau/include/nvif/device.h
index b0e59800a320..64b8e4defc35 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/device.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/device.h
@@ -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*/
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index ad5de7ed48ce..68564c648eda 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -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");
diff --git a/drivers/gpu/drm/nouveau/nvif/device.c b/drivers/gpu/drm/nouveau/nvif/device.c
index 8c3d883f3313..2fef6553a013 100644
--- a/drivers/gpu/drm/nouveau/nvif/device.c
+++ b/drivers/gpu/drm/nouveau/nvif/device.c
@@ -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)
 {
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 011/156] drm/nouveau: add nouveau_cli to nouveau_abi16
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (9 preceding siblings ...)
  2024-04-16 23:37 ` [PATCH 010/156] drm/nouveau: always map device Ben Skeggs
@ 2024-04-16 23:37 ` Ben Skeggs
  2024-04-16 23:37 ` [PATCH 012/156] drm/nouveau: handle limited nvif in abi16 Ben Skeggs
                   ` (146 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:37 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- removes some dubious void casts

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/nouveau_abi16.c | 9 +++++----
 drivers/gpu/drm/nouveau/nouveau_abi16.h | 1 +
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_abi16.c b/drivers/gpu/drm/nouveau/nouveau_abi16.c
index 291107ddc59b..440d92d93acd 100644
--- a/drivers/gpu/drm/nouveau/nouveau_abi16.c
+++ b/drivers/gpu/drm/nouveau/nouveau_abi16.c
@@ -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)
diff --git a/drivers/gpu/drm/nouveau/nouveau_abi16.h b/drivers/gpu/drm/nouveau/nouveau_abi16.h
index 661b901d8ecc..0a9121e63143 100644
--- a/drivers/gpu/drm/nouveau/nouveau_abi16.h
+++ b/drivers/gpu/drm/nouveau/nouveau_abi16.h
@@ -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;
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 012/156] drm/nouveau: handle limited nvif in abi16
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (10 preceding siblings ...)
  2024-04-16 23:37 ` [PATCH 011/156] drm/nouveau: add nouveau_cli to nouveau_abi16 Ben Skeggs
@ 2024-04-16 23:37 ` Ben Skeggs
  2024-04-16 23:37 ` [PATCH 013/156] drm/nouveau: remove abi16->device Ben Skeggs
                   ` (145 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:37 UTC (permalink / raw)
  To: nouveau; +Cc: 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.

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 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

diff --git a/drivers/gpu/drm/nouveau/Kbuild b/drivers/gpu/drm/nouveau/Kbuild
index cf6b3a80c0c8..c3223ec97aff 100644
--- a/drivers/gpu/drm/nouveau/Kbuild
+++ b/drivers/gpu/drm/nouveau/Kbuild
@@ -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
diff --git a/drivers/gpu/drm/nouveau/nouveau_abi16.c b/drivers/gpu/drm/nouveau/nouveau_abi16.c
index 440d92d93acd..5341d96ffc85 100644
--- a/drivers/gpu/drm/nouveau/nouveau_abi16.c
+++ b/drivers/gpu/drm/nouveau/nouveau_abi16.c
@@ -52,6 +52,7 @@ nouveau_abi16(struct drm_file *file_priv)
 
 			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
@@ -88,6 +89,61 @@ nouveau_abi16_put(struct nouveau_abi16 *abi16, int ret)
 	return ret;
 }
 
+struct nouveau_abi16_obj {
+	enum nouveau_abi16_obj_type {
+		DEVICE,
+		ENGOBJ,
+	} type;
+	u64 object;
+
+	union {
+		struct {
+			struct nvif_object object;
+		} engobj;
+	};
+
+	struct list_head head;
+};
+
+static struct nouveau_abi16_obj *
+nouveau_abi16_obj_find(struct nouveau_abi16 *abi16, u64 object)
+{
+	struct nouveau_abi16_obj *obj;
+
+	list_for_each_entry(obj, &abi16->objects, head) {
+		if (obj->object == object)
+			return obj;
+	}
+
+	return NULL;
+}
+
+static void
+nouveau_abi16_obj_del(struct nouveau_abi16_obj *obj)
+{
+	list_del(&obj->head);
+	kfree(obj);
+}
+
+static struct nouveau_abi16_obj *
+nouveau_abi16_obj_new(struct nouveau_abi16 *abi16, enum nouveau_abi16_obj_type type, u64 object)
+{
+	struct nouveau_abi16_obj *obj;
+
+	obj = nouveau_abi16_obj_find(abi16, object);
+	if (obj)
+		return ERR_PTR(-EEXIST);
+
+	obj = kzalloc(sizeof(*obj), GFP_KERNEL);
+	if (!obj)
+		return ERR_PTR(-ENOMEM);
+
+	obj->type = type;
+	obj->object = object;
+	list_add_tail(&obj->head, &abi16->objects);
+	return obj;
+}
+
 s32
 nouveau_abi16_swclass(struct nouveau_drm *drm)
 {
@@ -167,6 +223,12 @@ nouveau_abi16_fini(struct nouveau_abi16 *abi16)
 {
 	struct nouveau_cli *cli = abi16->cli;
 	struct nouveau_abi16_chan *chan, *temp;
+	struct nouveau_abi16_obj *obj, *tmp;
+
+	/* cleanup objects */
+	list_for_each_entry_safe(obj, tmp, &abi16->objects, head) {
+		nouveau_abi16_obj_del(obj);
+	}
 
 	/* cleanup channels */
 	list_for_each_entry_safe(chan, temp, &abi16->channels, head) {
@@ -455,44 +517,6 @@ nouveau_abi16_chan(struct nouveau_abi16 *abi16, int channel)
 	return NULL;
 }
 
-int
-nouveau_abi16_usif(struct drm_file *file_priv, void *data, u32 size)
-{
-	union {
-		struct nvif_ioctl_v0 v0;
-	} *args = data;
-	struct nouveau_abi16_chan *chan;
-	struct nouveau_abi16 *abi16;
-	int ret = -ENOSYS;
-
-	if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) {
-		switch (args->v0.type) {
-		case NVIF_IOCTL_V0_NEW:
-		case NVIF_IOCTL_V0_MTHD:
-		case NVIF_IOCTL_V0_SCLASS:
-			break;
-		default:
-			return -EACCES;
-		}
-	} else
-		return ret;
-
-	if (!(abi16 = nouveau_abi16(file_priv)))
-		return -ENOMEM;
-
-	if (args->v0.token != ~0ULL) {
-		if (!(chan = nouveau_abi16_chan(abi16, args->v0.token)))
-			return -EINVAL;
-		args->v0.object = nvif_handle(&chan->chan->user);
-		args->v0.owner  = NVIF_IOCTL_V0_OWNER_ANY;
-		return 0;
-	}
-
-	args->v0.object = nvif_handle(&abi16->device.object);
-	args->v0.owner  = NVIF_IOCTL_V0_OWNER_ANY;
-	return 0;
-}
-
 int
 nouveau_abi16_ioctl_channel_free(ABI16_IOCTL_ARGS)
 {
@@ -702,3 +726,180 @@ nouveau_abi16_ioctl_gpuobj_free(ABI16_IOCTL_ARGS)
 
 	return nouveau_abi16_put(abi16, ret);
 }
+
+static int
+nouveau_abi16_ioctl_mthd(struct nouveau_abi16 *abi16, struct nvif_ioctl_v0 *ioctl, u32 argc)
+{
+	struct nouveau_cli *cli = abi16->cli;
+	struct nvif_ioctl_mthd_v0 *args;
+	struct nouveau_abi16_obj *obj;
+	struct nv_device_info_v0 *info;
+
+	if (ioctl->route || argc < sizeof(*args))
+		return -EINVAL;
+	args = (void *)ioctl->data;
+	argc -= sizeof(*args);
+
+	obj = nouveau_abi16_obj_find(abi16, ioctl->object);
+	if (!obj || obj->type != DEVICE)
+		return -EINVAL;
+
+	if (args->method != NV_DEVICE_V0_INFO ||
+	    argc != sizeof(*info))
+		return -EINVAL;
+
+	info = (void *)args->data;
+	if (info->version != 0x00)
+		return -EINVAL;
+
+	info = &cli->drm->device.info;
+	memcpy(args->data, info, sizeof(*info));
+	return 0;
+}
+
+static int
+nouveau_abi16_ioctl_del(struct nouveau_abi16 *abi16, struct nvif_ioctl_v0 *ioctl, u32 argc)
+{
+	struct nouveau_abi16_obj *obj;
+
+	if (ioctl->route || argc)
+		return -EINVAL;
+
+	obj = nouveau_abi16_obj_find(abi16, ioctl->object);
+	if (obj)
+		nouveau_abi16_obj_del(obj);
+
+	return 0;
+}
+
+static int
+nouveau_abi16_ioctl_new(struct nouveau_abi16 *abi16, struct nvif_ioctl_v0 *ioctl, u32 argc)
+{
+	struct nvif_ioctl_new_v0 *args;
+	struct nouveau_abi16_chan *chan;
+	struct nouveau_abi16_obj *obj;
+	int ret;
+
+	if (argc < sizeof(*args))
+		return -EINVAL;
+	args = (void *)ioctl->data;
+	argc -= sizeof(*args);
+
+	if (args->version != 0)
+		return -EINVAL;
+
+	if (!ioctl->route) {
+		if (ioctl->object || args->oclass != NV_DEVICE)
+			return -EINVAL;
+
+		obj = nouveau_abi16_obj_new(abi16, DEVICE, args->object);
+		if (IS_ERR(obj))
+			return PTR_ERR(obj);
+
+		return 0;
+	}
+
+	chan = nouveau_abi16_chan(abi16, ioctl->token);
+	if (!chan)
+		return -EINVAL;
+
+	obj = nouveau_abi16_obj_new(abi16, ENGOBJ, args->object);
+	if (IS_ERR(obj))
+		return PTR_ERR(obj);
+
+	ret = nvif_object_ctor(&chan->chan->user, "abi16EngObj", args->handle, args->oclass,
+			       NULL, 0, &obj->engobj.object);
+	if (ret)
+		nouveau_abi16_obj_del(obj);
+
+	return ret;
+}
+
+static int
+nouveau_abi16_ioctl_sclass(struct nouveau_abi16 *abi16, struct nvif_ioctl_v0 *ioctl, u32 argc)
+{
+	struct nvif_ioctl_sclass_v0 *args;
+	struct nouveau_abi16_chan *chan;
+	struct nvif_sclass *sclass;
+	int ret;
+
+	if (!ioctl->route || argc < sizeof(*args))
+		return -EINVAL;
+	args = (void *)ioctl->data;
+	argc -= sizeof(*args);
+
+	if (argc != args->count * sizeof(args->oclass[0]))
+		return -EINVAL;
+
+	chan = nouveau_abi16_chan(abi16, ioctl->token);
+	if (!chan)
+		return -EINVAL;
+
+	ret = nvif_object_sclass_get(&chan->chan->user, &sclass);
+	if (ret < 0)
+		return ret;
+
+	for (int i = 0; i < min_t(u8, args->count, ret); i++) {
+		args->oclass[i].oclass = sclass[i].oclass;
+		args->oclass[i].minver = sclass[i].minver;
+		args->oclass[i].maxver = sclass[i].maxver;
+	}
+	args->count = ret;
+
+	nvif_object_sclass_put(&sclass);
+	return 0;
+}
+
+int
+nouveau_abi16_ioctl(struct drm_file *filp, void __user *user, u32 size)
+{
+	struct nvif_ioctl_v0 *ioctl;
+	struct nouveau_abi16 *abi16;
+	u32 argc = size;
+	int ret;
+
+	if (argc < sizeof(*ioctl))
+		return -EINVAL;
+	argc -= sizeof(*ioctl);
+
+	ioctl = kmalloc(size, GFP_KERNEL);
+	if (!ioctl)
+		return -ENOMEM;
+
+	ret = -EFAULT;
+	if (copy_from_user(ioctl, user, size))
+		goto done_free;
+
+	if (ioctl->version != 0x00 ||
+	    (ioctl->route && ioctl->route != 0xff)) {
+		ret = -EINVAL;
+		goto done_free;
+	}
+
+	abi16 = nouveau_abi16_get(filp);
+	if (unlikely(!abi16)) {
+		ret = -ENOMEM;
+		goto done_free;
+	}
+
+	switch (ioctl->type) {
+	case NVIF_IOCTL_V0_SCLASS: ret = nouveau_abi16_ioctl_sclass(abi16, ioctl, argc); break;
+	case NVIF_IOCTL_V0_NEW   : ret = nouveau_abi16_ioctl_new   (abi16, ioctl, argc); break;
+	case NVIF_IOCTL_V0_DEL   : ret = nouveau_abi16_ioctl_del   (abi16, ioctl, argc); break;
+	case NVIF_IOCTL_V0_MTHD  : ret = nouveau_abi16_ioctl_mthd  (abi16, ioctl, argc); break;
+	default:
+		ret = -EINVAL;
+		break;
+	}
+
+	nouveau_abi16_put(abi16, 0);
+
+	if (ret == 0) {
+		if (copy_to_user(user, ioctl, size))
+			ret = -EFAULT;
+	}
+
+done_free:
+	kfree(ioctl);
+	return ret;
+}
diff --git a/drivers/gpu/drm/nouveau/nouveau_abi16.h b/drivers/gpu/drm/nouveau/nouveau_abi16.h
index 0a9121e63143..75a883a44e04 100644
--- a/drivers/gpu/drm/nouveau/nouveau_abi16.h
+++ b/drivers/gpu/drm/nouveau/nouveau_abi16.h
@@ -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)
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 68564c648eda..c0d74be4c47b 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -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);
diff --git a/drivers/gpu/drm/nouveau/nouveau_nvif.c b/drivers/gpu/drm/nouveau/nouveau_nvif.c
index 1d49ebdfd5dc..9a7e3f64b79f 100644
--- a/drivers/gpu/drm/nouveau/nouveau_nvif.c
+++ b/drivers/gpu/drm/nouveau/nouveau_nvif.c
@@ -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)
diff --git a/drivers/gpu/drm/nouveau/nouveau_usif.c b/drivers/gpu/drm/nouveau/nouveau_usif.c
deleted file mode 100644
index 002d1479ba89..000000000000
--- a/drivers/gpu/drm/nouveau/nouveau_usif.c
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * Copyright 2014 Red Hat Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors: Ben Skeggs <bskeggs@redhat.com>
- */
-
-#include "nouveau_drv.h"
-#include "nouveau_usif.h"
-#include "nouveau_abi16.h"
-
-#include <nvif/unpack.h>
-#include <nvif/client.h>
-#include <nvif/ioctl.h>
-
-#include <nvif/class.h>
-#include <nvif/cl0080.h>
-
-struct usif_object {
-	struct list_head head;
-	u8  route;
-	u64 token;
-};
-
-static void
-usif_object_dtor(struct usif_object *object)
-{
-	list_del(&object->head);
-	kfree(object);
-}
-
-static int
-usif_object_new(struct drm_file *f, void *data, u32 size, void *argv, u32 argc, bool parent_abi16)
-{
-	struct nouveau_cli *cli = nouveau_cli(f);
-	struct nvif_client *client = &cli->base;
-	union {
-		struct nvif_ioctl_new_v0 v0;
-	} *args = data;
-	struct usif_object *object;
-	int ret = -ENOSYS;
-
-	if ((ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true)))
-		return ret;
-
-	switch (args->v0.oclass) {
-	case NV_DMA_FROM_MEMORY:
-	case NV_DMA_TO_MEMORY:
-	case NV_DMA_IN_MEMORY:
-		return -EINVAL;
-	case NV_DEVICE: {
-		union {
-			struct nv_device_v0 v0;
-		} *args = data;
-
-		if ((ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false)))
-			return ret;
-
-		args->v0.priv = false;
-		break;
-	}
-	default:
-		if (!parent_abi16)
-			return -EINVAL;
-		break;
-	}
-
-	if (!(object = kmalloc(sizeof(*object), GFP_KERNEL)))
-		return -ENOMEM;
-	list_add(&object->head, &cli->objects);
-
-	object->route = args->v0.route;
-	object->token = args->v0.token;
-	args->v0.route = NVDRM_OBJECT_USIF;
-	args->v0.token = (unsigned long)(void *)object;
-	ret = nvif_client_ioctl(client, argv, argc);
-	if (ret) {
-		usif_object_dtor(object);
-		return ret;
-	}
-
-	args->v0.token = object->token;
-	args->v0.route = object->route;
-	return 0;
-}
-
-int
-usif_ioctl(struct drm_file *filp, void __user *user, u32 argc)
-{
-	struct nouveau_cli *cli = nouveau_cli(filp);
-	struct nvif_client *client = &cli->base;
-	void *data = kmalloc(argc, GFP_KERNEL);
-	u32   size = argc;
-	union {
-		struct nvif_ioctl_v0 v0;
-	} *argv = data;
-	struct usif_object *object;
-	bool abi16 = false;
-	u8 owner;
-	int ret;
-
-	if (ret = -ENOMEM, !argv)
-		goto done;
-	if (ret = -EFAULT, copy_from_user(argv, user, size))
-		goto done;
-
-	if (!(ret = nvif_unpack(-ENOSYS, &data, &size, argv->v0, 0, 0, true))) {
-		/* block access to objects not created via this interface */
-		owner = argv->v0.owner;
-		if (argv->v0.object == 0ULL &&
-		    argv->v0.type != NVIF_IOCTL_V0_DEL)
-			argv->v0.owner = NVDRM_OBJECT_ANY; /* except client */
-		else
-			argv->v0.owner = NVDRM_OBJECT_USIF;
-	} else
-		goto done;
-
-	/* USIF slightly abuses some return-only ioctl members in order
-	 * to provide interoperability with the older ABI16 objects
-	 */
-	mutex_lock(&cli->mutex);
-	if (argv->v0.route) {
-		if (ret = -EINVAL, argv->v0.route == 0xff)
-			ret = nouveau_abi16_usif(filp, argv, argc);
-		if (ret) {
-			mutex_unlock(&cli->mutex);
-			goto done;
-		}
-
-		abi16 = true;
-	}
-
-	switch (argv->v0.type) {
-	case NVIF_IOCTL_V0_NEW:
-		ret = usif_object_new(filp, data, size, argv, argc, abi16);
-		break;
-	default:
-		ret = nvif_client_ioctl(client, argv, argc);
-		break;
-	}
-	if (argv->v0.route == NVDRM_OBJECT_USIF) {
-		object = (void *)(unsigned long)argv->v0.token;
-		argv->v0.route = object->route;
-		argv->v0.token = object->token;
-		if (ret == 0 && argv->v0.type == NVIF_IOCTL_V0_DEL) {
-			list_del(&object->head);
-			kfree(object);
-		}
-	} else {
-		argv->v0.route = NVIF_IOCTL_V0_ROUTE_HIDDEN;
-		argv->v0.token = 0;
-	}
-	argv->v0.owner = owner;
-	mutex_unlock(&cli->mutex);
-
-	if (copy_to_user(user, argv, argc))
-		ret = -EFAULT;
-done:
-	kfree(argv);
-	return ret;
-}
-
-void
-usif_client_fini(struct nouveau_cli *cli)
-{
-	struct usif_object *object, *otemp;
-
-	list_for_each_entry_safe(object, otemp, &cli->objects, head) {
-		usif_object_dtor(object);
-	}
-}
-
-void
-usif_client_init(struct nouveau_cli *cli)
-{
-	INIT_LIST_HEAD(&cli->objects);
-}
diff --git a/drivers/gpu/drm/nouveau/nouveau_usif.h b/drivers/gpu/drm/nouveau/nouveau_usif.h
deleted file mode 100644
index dc90d4a9d0d9..000000000000
--- a/drivers/gpu/drm/nouveau/nouveau_usif.h
+++ /dev/null
@@ -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
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 013/156] drm/nouveau: remove abi16->device
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (11 preceding siblings ...)
  2024-04-16 23:37 ` [PATCH 012/156] drm/nouveau: handle limited nvif in abi16 Ben Skeggs
@ 2024-04-16 23:37 ` Ben Skeggs
  2024-04-16 23:37 ` [PATCH 014/156] drm/nouveau: remove abi16->handles Ben Skeggs
                   ` (144 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:37 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

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

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/nouveau_abi16.c | 24 ++----------------------
 drivers/gpu/drm/nouveau/nouveau_abi16.h |  1 -
 2 files changed, 2 insertions(+), 23 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_abi16.c b/drivers/gpu/drm/nouveau/nouveau_abi16.c
index 5341d96ffc85..5ebd19ece13b 100644
--- a/drivers/gpu/drm/nouveau/nouveau_abi16.c
+++ b/drivers/gpu/drm/nouveau/nouveau_abi16.c
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/nouveau_abi16.h b/drivers/gpu/drm/nouveau/nouveau_abi16.h
index 75a883a44e04..4743459ea14c 100644
--- a/drivers/gpu/drm/nouveau/nouveau_abi16.h
+++ b/drivers/gpu/drm/nouveau/nouveau_abi16.h
@@ -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;
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 014/156] drm/nouveau: remove abi16->handles
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (12 preceding siblings ...)
  2024-04-16 23:37 ` [PATCH 013/156] drm/nouveau: remove abi16->device Ben Skeggs
@ 2024-04-16 23:37 ` Ben Skeggs
  2024-04-16 23:37 ` [PATCH 015/156] drm/nouveau: store nvkm_device pointer in nouveau_drm Ben Skeggs
                   ` (143 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:37 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- hasn't been needed since 2015...

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/nouveau_abi16.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_abi16.h b/drivers/gpu/drm/nouveau/nouveau_abi16.h
index 4743459ea14c..af6b4e1cefd2 100644
--- a/drivers/gpu/drm/nouveau/nouveau_abi16.h
+++ b/drivers/gpu/drm/nouveau/nouveau_abi16.h
@@ -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;
 };
 
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 015/156] drm/nouveau: store nvkm_device pointer in nouveau_drm
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (13 preceding siblings ...)
  2024-04-16 23:37 ` [PATCH 014/156] drm/nouveau: remove abi16->handles Ben Skeggs
@ 2024-04-16 23:37 ` Ben Skeggs
  2024-04-16 23:37 ` [PATCH 016/156] drm/nouveau: create pci device once Ben Skeggs
                   ` (142 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:37 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

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

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/nouveau_drm.c | 13 +++++--------
 drivers/gpu/drm/nouveau/nouveau_drv.h |  1 +
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index c0d74be4c47b..8d34a4cf2900 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -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;
 
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h
index 683600db4ff9..35dfc95b32ed 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.h
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.h
@@ -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;
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 016/156] drm/nouveau: create pci device once
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (14 preceding siblings ...)
  2024-04-16 23:37 ` [PATCH 015/156] drm/nouveau: store nvkm_device pointer in nouveau_drm Ben Skeggs
@ 2024-04-16 23:37 ` Ben Skeggs
  2024-04-16 23:37 ` [PATCH 017/156] drm/nouveau: remove push pointer from nouveau_channel Ben Skeggs
                   ` (141 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:37 UTC (permalink / raw)
  To: nouveau; +Cc: 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.

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/nouveau_drm.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 8d34a4cf2900..9a4f2b0a8463 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -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)
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 017/156] drm/nouveau: remove push pointer from nouveau_channel
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (15 preceding siblings ...)
  2024-04-16 23:37 ` [PATCH 016/156] drm/nouveau: create pci device once Ben Skeggs
@ 2024-04-16 23:37 ` Ben Skeggs
  2024-04-16 23:37 ` [PATCH 018/156] drm/nouveau/kms: remove a few unused struct members and fn decls Ben Skeggs
                   ` (140 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:37 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

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

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 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(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv04/crtc.c b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
index 3535cf571300..8e8a43b28f71 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/crtc.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
@@ -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)
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo0039.c b/drivers/gpu/drm/nouveau/nouveau_bo0039.c
index 2babc6c47241..0b6758e024a1 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo0039.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo0039.c
@@ -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);
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo5039.c b/drivers/gpu/drm/nouveau/nouveau_bo5039.c
index 0a6b1fce1108..c3de17548d97 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo5039.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo5039.c
@@ -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);
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo74c1.c b/drivers/gpu/drm/nouveau/nouveau_bo74c1.c
index 9b7ba31fae13..e6ef79de2498 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo74c1.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo74c1.c
@@ -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);
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo85b5.c b/drivers/gpu/drm/nouveau/nouveau_bo85b5.c
index a15a38a87a95..c4861d073ad4 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo85b5.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo85b5.c
@@ -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);
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo9039.c b/drivers/gpu/drm/nouveau/nouveau_bo9039.c
index d2bb2687d401..ad82269c7725 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo9039.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo9039.c
@@ -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);
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo90b5.c b/drivers/gpu/drm/nouveau/nouveau_bo90b5.c
index 4618f4f5ab56..5eaeef9d25e4 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo90b5.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo90b5.c
@@ -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);
diff --git a/drivers/gpu/drm/nouveau/nouveau_boa0b5.c b/drivers/gpu/drm/nouveau/nouveau_boa0b5.c
index 07a5c6302c98..dff2ae0e1e45 100644
--- a/drivers/gpu/drm/nouveau/nouveau_boa0b5.c
+++ b/drivers/gpu/drm/nouveau/nouveau_boa0b5.c
@@ -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);
diff --git a/drivers/gpu/drm/nouveau/nouveau_chan.c b/drivers/gpu/drm/nouveau/nouveau_chan.c
index ea8db569bd1a..db86cca9ea37 100644
--- a/drivers/gpu/drm/nouveau/nouveau_chan.c
+++ b/drivers/gpu/drm/nouveau/nouveau_chan.c
@@ -117,24 +117,24 @@ nouveau_channel_del(struct nouveau_channel **pchan)
 static void
 nouveau_channel_kick(struct nvif_push *push)
 {
-	struct nouveau_channel *chan = container_of(push, typeof(*chan), chan._push);
-	chan->dma.cur = chan->dma.cur + (chan->chan._push.cur - chan->chan._push.bgn);
+	struct nouveau_channel *chan = container_of(push, typeof(*chan), chan.push);
+	chan->dma.cur = chan->dma.cur + (chan->chan.push.cur - chan->chan.push.bgn);
 	FIRE_RING(chan);
-	chan->chan._push.bgn = chan->chan._push.cur;
+	chan->chan.push.bgn = chan->chan.push.cur;
 }
 
 static int
 nouveau_channel_wait(struct nvif_push *push, u32 size)
 {
-	struct nouveau_channel *chan = container_of(push, typeof(*chan), chan._push);
+	struct nouveau_channel *chan = container_of(push, typeof(*chan), chan.push);
 	int ret;
-	chan->dma.cur = chan->dma.cur + (chan->chan._push.cur - chan->chan._push.bgn);
+	chan->dma.cur = chan->dma.cur + (chan->chan.push.cur - chan->chan.push.bgn);
 	ret = RING_SPACE(chan, size);
 	if (ret == 0) {
-		chan->chan._push.bgn = chan->chan._push.mem.object.map.ptr;
-		chan->chan._push.bgn = chan->chan._push.bgn + chan->dma.cur;
-		chan->chan._push.cur = chan->chan._push.bgn;
-		chan->chan._push.end = chan->chan._push.bgn + size;
+		chan->chan.push.bgn = chan->chan.push.mem.object.map.ptr;
+		chan->chan.push.bgn = chan->chan.push.bgn + chan->dma.cur;
+		chan->chan.push.cur = chan->chan.push.bgn;
+		chan->chan.push.end = chan->chan.push.bgn + size;
 	}
 	return ret;
 }
@@ -176,13 +176,12 @@ nouveau_channel_prep(struct nouveau_cli *cli,
 		return ret;
 	}
 
-	chan->chan._push.mem.object.parent = cli->base.object.parent;
-	chan->chan._push.mem.object.client = &cli->base;
-	chan->chan._push.mem.object.name = "chanPush";
-	chan->chan._push.mem.object.map.ptr = chan->push.buffer->kmap.virtual;
-	chan->chan._push.wait = nouveau_channel_wait;
-	chan->chan._push.kick = nouveau_channel_kick;
-	chan->chan.push = &chan->chan._push;
+	chan->chan.push.mem.object.parent = cli->base.object.parent;
+	chan->chan.push.mem.object.client = &cli->base;
+	chan->chan.push.mem.object.name = "chanPush";
+	chan->chan.push.mem.object.map.ptr = chan->push.buffer->kmap.virtual;
+	chan->chan.push.wait = nouveau_channel_wait;
+	chan->chan.push.kick = nouveau_channel_kick;
 
 	/* create dma object covering the *entire* memory space that the
 	 * pushbuf lives in, this is because the GEM code requires that
@@ -461,12 +460,12 @@ nouveau_channel_init(struct nouveau_channel *chan, u32 vram, u32 gart)
 	chan->dma.cur = chan->dma.put;
 	chan->dma.free = chan->dma.max - chan->dma.cur;
 
-	ret = PUSH_WAIT(chan->chan.push, NOUVEAU_DMA_SKIPS);
+	ret = PUSH_WAIT(&chan->chan.push, NOUVEAU_DMA_SKIPS);
 	if (ret)
 		return ret;
 
 	for (i = 0; i < NOUVEAU_DMA_SKIPS; i++)
-		PUSH_DATA(chan->chan.push, 0x00000000);
+		PUSH_DATA(&chan->chan.push, 0x00000000);
 
 	/* allocate software object class (used for fences on <= nv05) */
 	if (device->info.family < NV_DEVICE_INFO_V0_CELSIUS) {
@@ -476,12 +475,12 @@ nouveau_channel_init(struct nouveau_channel *chan, u32 vram, u32 gart)
 		if (ret)
 			return ret;
 
-		ret = PUSH_WAIT(chan->chan.push, 2);
+		ret = PUSH_WAIT(&chan->chan.push, 2);
 		if (ret)
 			return ret;
 
-		PUSH_NVSQ(chan->chan.push, NV_SW, 0x0000, chan->nvsw.handle);
-		PUSH_KICK(chan->chan.push);
+		PUSH_NVSQ(&chan->chan.push, NV_SW, 0x0000, chan->nvsw.handle);
+		PUSH_KICK(&chan->chan.push);
 	}
 
 	/* initialise synchronisation */
diff --git a/drivers/gpu/drm/nouveau/nouveau_chan.h b/drivers/gpu/drm/nouveau/nouveau_chan.h
index 3ce9832c9528..016f668c0bc1 100644
--- a/drivers/gpu/drm/nouveau/nouveau_chan.h
+++ b/drivers/gpu/drm/nouveau/nouveau_chan.h
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/nouveau_dmem.c b/drivers/gpu/drm/nouveau/nouveau_dmem.c
index 6fb65b01d778..b2f20e33bf66 100644
--- a/drivers/gpu/drm/nouveau/nouveau_dmem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_dmem.c
@@ -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;
 
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 9a4f2b0a8463..92b347b79919 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -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) {
diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
index 22f4ee483ff3..9ae2cee1c7c5 100644
--- a/drivers/gpu/drm/nouveau/nouveau_gem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
@@ -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);
 		}
 	}
 
diff --git a/drivers/gpu/drm/nouveau/nv04_fence.c b/drivers/gpu/drm/nouveau/nv04_fence.c
index cdbc75e3d1f6..fa5c6029f783 100644
--- a/drivers/gpu/drm/nouveau/nv04_fence.c
+++ b/drivers/gpu/drm/nouveau/nv04_fence.c
@@ -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);
diff --git a/drivers/gpu/drm/nouveau/nv10_fence.c b/drivers/gpu/drm/nouveau/nv10_fence.c
index c6a0db5b9e21..1e45b5fcbf23 100644
--- a/drivers/gpu/drm/nouveau/nv10_fence.c
+++ b/drivers/gpu/drm/nouveau/nv10_fence.c
@@ -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);
diff --git a/drivers/gpu/drm/nouveau/nv17_fence.c b/drivers/gpu/drm/nouveau/nv17_fence.c
index 7fa52ec61b30..4415a6de680b 100644
--- a/drivers/gpu/drm/nouveau/nv17_fence.c
+++ b/drivers/gpu/drm/nouveau/nv17_fence.c
@@ -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;
 
diff --git a/drivers/gpu/drm/nouveau/nv84_fence.c b/drivers/gpu/drm/nouveau/nv84_fence.c
index 7f62089dc940..a9cbea2d1cc0 100644
--- a/drivers/gpu/drm/nouveau/nv84_fence.c
+++ b/drivers/gpu/drm/nouveau/nv84_fence.c
@@ -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);
diff --git a/drivers/gpu/drm/nouveau/nvc0_fence.c b/drivers/gpu/drm/nouveau/nvc0_fence.c
index e1461c0b0779..a5e98d0d4217 100644
--- a/drivers/gpu/drm/nouveau/nvc0_fence.c
+++ b/drivers/gpu/drm/nouveau/nvc0_fence.c
@@ -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,
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 018/156] drm/nouveau/kms: remove a few unused struct members and fn decls
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (16 preceding siblings ...)
  2024-04-16 23:37 ` [PATCH 017/156] drm/nouveau: remove push pointer from nouveau_channel Ben Skeggs
@ 2024-04-16 23:37 ` Ben Skeggs
  2024-04-16 23:37 ` [PATCH 019/156] drm/nouveau/kms: remove push pointer from nv50_dmac Ben Skeggs
                   ` (139 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:37 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- left-overs from the past

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/dispnv50/disp.c | 3 ---
 drivers/gpu/drm/nouveau/dispnv50/disp.h | 9 ---------
 2 files changed, 12 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c b/drivers/gpu/drm/nouveau/dispnv50/disp.c
index f8ca57cc7af6..f4c9399e85ab 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/disp.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.h b/drivers/gpu/drm/nouveau/dispnv50/disp.h
index da3add95f354..b66a30915af2 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/disp.h
+++ b/drivers/gpu/drm/nouveau/dispnv50/disp.h
@@ -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[];
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 019/156] drm/nouveau/kms: remove push pointer from nv50_dmac
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (17 preceding siblings ...)
  2024-04-16 23:37 ` [PATCH 018/156] drm/nouveau/kms: remove a few unused struct members and fn decls Ben Skeggs
@ 2024-04-16 23:37 ` Ben Skeggs
  2024-04-16 23:37 ` [PATCH 020/156] drm/nouveau/kms: move hw ring tracking vars into nvif_push Ben Skeggs
                   ` (138 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:37 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- just use the struct itself

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 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(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv50/base507c.c b/drivers/gpu/drm/nouveau/dispnv50/base507c.c
index e36a473f2075..a431f6c5f6fa 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/base507c.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/base507c.c
@@ -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)))
diff --git a/drivers/gpu/drm/nouveau/dispnv50/base827c.c b/drivers/gpu/drm/nouveau/dispnv50/base827c.c
index 093d4ba6910e..4545cc5f3a14 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/base827c.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/base827c.c
@@ -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)))
diff --git a/drivers/gpu/drm/nouveau/dispnv50/base907c.c b/drivers/gpu/drm/nouveau/dispnv50/base907c.c
index e6b0417c325b..4a2d5a259e15 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/base907c.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/base907c.c
@@ -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)))
diff --git a/drivers/gpu/drm/nouveau/dispnv50/core507d.c b/drivers/gpu/drm/nouveau/dispnv50/core507d.c
index 85845e3dc7ba..ce2cb78bbdd3 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/core507d.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/core507d.c
@@ -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)))
diff --git a/drivers/gpu/drm/nouveau/dispnv50/corec37d.c b/drivers/gpu/drm/nouveau/dispnv50/corec37d.c
index 42f877f2ced2..7f637b8830be 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/corec37d.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/corec37d.c
@@ -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;
 
diff --git a/drivers/gpu/drm/nouveau/dispnv50/corec57d.c b/drivers/gpu/drm/nouveau/dispnv50/corec57d.c
index 53b1e2a569c1..421d0d57e1d8 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/corec57d.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/corec57d.c
@@ -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;
 
diff --git a/drivers/gpu/drm/nouveau/dispnv50/crc907d.c b/drivers/gpu/drm/nouveau/dispnv50/crc907d.c
index f9ad641555b7..a674ba435b05 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/crc907d.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/crc907d.c
@@ -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;
 
diff --git a/drivers/gpu/drm/nouveau/dispnv50/crcc37d.c b/drivers/gpu/drm/nouveau/dispnv50/crcc37d.c
index f10f6c484408..4821ce32f9ed 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/crcc37d.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/crcc37d.c
@@ -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;
 
diff --git a/drivers/gpu/drm/nouveau/dispnv50/crcc57d.c b/drivers/gpu/drm/nouveau/dispnv50/crcc57d.c
index cc0130e3d496..ad591dcb0bc9 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/crcc57d.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/crcc57d.c
@@ -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) |
diff --git a/drivers/gpu/drm/nouveau/dispnv50/dac507d.c b/drivers/gpu/drm/nouveau/dispnv50/dac507d.c
index 09de78d96679..99ae692f219e 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/dac507d.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/dac507d.c
@@ -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;
 
diff --git a/drivers/gpu/drm/nouveau/dispnv50/dac907d.c b/drivers/gpu/drm/nouveau/dispnv50/dac907d.c
index 95efa625b691..74bc9f81e3f1 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/dac907d.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/dac907d.c
@@ -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)))
diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c b/drivers/gpu/drm/nouveau/dispnv50/disp.c
index f4c9399e85ab..b64b283f8e9c 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/disp.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c
@@ -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);
diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.h b/drivers/gpu/drm/nouveau/dispnv50/disp.h
index b66a30915af2..15f9242b72ac 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/disp.h
+++ b/drivers/gpu/drm/nouveau/dispnv50/disp.h
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/dispnv50/head507d.c b/drivers/gpu/drm/nouveau/dispnv50/head507d.c
index 0edd4e520c8e..7fa1e0279d7d 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/head507d.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/head507d.c
@@ -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;
 
diff --git a/drivers/gpu/drm/nouveau/dispnv50/head827d.c b/drivers/gpu/drm/nouveau/dispnv50/head827d.c
index 194d1771c481..1545d576fe9c 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/head827d.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/head827d.c
@@ -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;
 
diff --git a/drivers/gpu/drm/nouveau/dispnv50/head907d.c b/drivers/gpu/drm/nouveau/dispnv50/head907d.c
index 18fe4c1e2d6a..6c9e0438e55c 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/head907d.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/head907d.c
@@ -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;
 
diff --git a/drivers/gpu/drm/nouveau/dispnv50/head917d.c b/drivers/gpu/drm/nouveau/dispnv50/head917d.c
index 4ce47b55f72c..2d9aee050510 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/head917d.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/head917d.c
@@ -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;
 
diff --git a/drivers/gpu/drm/nouveau/dispnv50/headc37d.c b/drivers/gpu/drm/nouveau/dispnv50/headc37d.c
index a4a3b78ea42c..2bcb3790fc10 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/headc37d.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/headc37d.c
@@ -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;
 
diff --git a/drivers/gpu/drm/nouveau/dispnv50/headc57d.c b/drivers/gpu/drm/nouveau/dispnv50/headc57d.c
index 53b1248c40ec..fde4087e7691 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/headc57d.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/headc57d.c
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/dispnv50/ovly507e.c b/drivers/gpu/drm/nouveau/dispnv50/ovly507e.c
index 73fcfb27c32c..654e506f8431 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/ovly507e.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/ovly507e.c
@@ -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)))
diff --git a/drivers/gpu/drm/nouveau/dispnv50/ovly827e.c b/drivers/gpu/drm/nouveau/dispnv50/ovly827e.c
index 02dc02d9260f..a5ae22ed663d 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/ovly827e.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/ovly827e.c
@@ -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)))
diff --git a/drivers/gpu/drm/nouveau/dispnv50/ovly907e.c b/drivers/gpu/drm/nouveau/dispnv50/ovly907e.c
index 645130d18a99..8cf0e18fa596 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/ovly907e.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/ovly907e.c
@@ -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)))
diff --git a/drivers/gpu/drm/nouveau/dispnv50/pior507d.c b/drivers/gpu/drm/nouveau/dispnv50/pior507d.c
index 17d230256bdd..79507d169778 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/pior507d.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/pior507d.c
@@ -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) {
diff --git a/drivers/gpu/drm/nouveau/dispnv50/sor507d.c b/drivers/gpu/drm/nouveau/dispnv50/sor507d.c
index ca73d7710885..08cc9845322e 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/sor507d.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/sor507d.c
@@ -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) {
diff --git a/drivers/gpu/drm/nouveau/dispnv50/sor907d.c b/drivers/gpu/drm/nouveau/dispnv50/sor907d.c
index c86cd8fa61d6..23957cc8f326 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/sor907d.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/sor907d.c
@@ -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)))
diff --git a/drivers/gpu/drm/nouveau/dispnv50/sorc37d.c b/drivers/gpu/drm/nouveau/dispnv50/sorc37d.c
index 9eaef34816da..da05d4614e00 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/sorc37d.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/sorc37d.c
@@ -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)))
diff --git a/drivers/gpu/drm/nouveau/dispnv50/wimmc37b.c b/drivers/gpu/drm/nouveau/dispnv50/wimmc37b.c
index 8cb5b79bacbf..7985da61aaac 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/wimmc37b.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/wimmc37b.c
@@ -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)))
diff --git a/drivers/gpu/drm/nouveau/dispnv50/wndwc37e.c b/drivers/gpu/drm/nouveau/dispnv50/wndwc37e.c
index caf40977f455..50a7b97d37a2 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/wndwc37e.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/wndwc37e.c
@@ -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)))
diff --git a/drivers/gpu/drm/nouveau/dispnv50/wndwc57e.c b/drivers/gpu/drm/nouveau/dispnv50/wndwc57e.c
index 1d214a4b960a..d1ca51aae58c 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/wndwc57e.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/wndwc57e.c
@@ -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)))
diff --git a/drivers/gpu/drm/nouveau/dispnv50/wndwc67e.c b/drivers/gpu/drm/nouveau/dispnv50/wndwc67e.c
index 7a370fa1df20..52af293c98f4 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/wndwc67e.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/wndwc67e.c
@@ -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)))
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 020/156] drm/nouveau/kms: move hw ring tracking vars into nvif_push
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (18 preceding siblings ...)
  2024-04-16 23:37 ` [PATCH 019/156] drm/nouveau/kms: remove push pointer from nv50_dmac Ben Skeggs
@ 2024-04-16 23:37 ` Ben Skeggs
  2024-04-16 23:37 ` [PATCH 021/156] drm/nouveau/kms: move dmac sync/vram ctxdmas to core+wndws Ben Skeggs
                   ` (137 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:37 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

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

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 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(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c b/drivers/gpu/drm/nouveau/dispnv50/disp.c
index b64b283f8e9c..125c33ee251a 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/disp.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c
@@ -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);
 
diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.h b/drivers/gpu/drm/nouveau/dispnv50/disp.h
index 15f9242b72ac..a7a01ae77ff4 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/disp.h
+++ b/drivers/gpu/drm/nouveau/dispnv50/disp.h
@@ -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 {
diff --git a/drivers/gpu/drm/nouveau/include/nvif/push.h b/drivers/gpu/drm/nouveau/include/nvif/push.h
index 6d3a8a3d2087..b88024ef6cc0 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/push.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/push.h
@@ -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
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 021/156] drm/nouveau/kms: move dmac sync/vram ctxdmas to core+wndws
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (19 preceding siblings ...)
  2024-04-16 23:37 ` [PATCH 020/156] drm/nouveau/kms: move hw ring tracking vars into nvif_push Ben Skeggs
@ 2024-04-16 23:37 ` Ben Skeggs
  2024-04-16 23:37 ` [PATCH 022/156] drm/nouveau/nvkm: remove detect/mmio/subdev_mask from device args Ben Skeggs
                   ` (136 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:37 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

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

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 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(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv50/base507c.c b/drivers/gpu/drm/nouveau/dispnv50/base507c.c
index a431f6c5f6fa..0b6fb663d78e 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/base507c.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/base507c.c
@@ -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
diff --git a/drivers/gpu/drm/nouveau/dispnv50/core.c b/drivers/gpu/drm/nouveau/dispnv50/core.c
index f045515696cb..1864f3e3bbc3 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/core.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/core.c
@@ -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;
 }
diff --git a/drivers/gpu/drm/nouveau/dispnv50/core.h b/drivers/gpu/drm/nouveau/dispnv50/core.h
index f75088186fba..a967c66dc7a2 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/core.h
+++ b/drivers/gpu/drm/nouveau/dispnv50/core.h
@@ -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;
 };
 
diff --git a/drivers/gpu/drm/nouveau/dispnv50/core507d.c b/drivers/gpu/drm/nouveau/dispnv50/core507d.c
index ce2cb78bbdd3..c6eee88ae99a 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/core507d.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/core507d.c
@@ -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);
 }
 
diff --git a/drivers/gpu/drm/nouveau/dispnv50/corec37d.c b/drivers/gpu/drm/nouveau/dispnv50/corec37d.c
index 7f637b8830be..9525fd30c8fc 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/corec37d.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/corec37d.c
@@ -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),
diff --git a/drivers/gpu/drm/nouveau/dispnv50/corec57d.c b/drivers/gpu/drm/nouveau/dispnv50/corec57d.c
index 421d0d57e1d8..485892c2e775 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/corec57d.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/corec57d.c
@@ -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),
diff --git a/drivers/gpu/drm/nouveau/dispnv50/curs507a.c b/drivers/gpu/drm/nouveau/dispnv50/curs507a.c
index a95ee5dcc2e3..7292d1554dba 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/curs507a.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/curs507a.c
@@ -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
diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c b/drivers/gpu/drm/nouveau/dispnv50/disp.c
index 125c33ee251a..31b46a62b501 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/disp.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c
@@ -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;
 }
 
diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.h b/drivers/gpu/drm/nouveau/dispnv50/disp.h
index a7a01ae77ff4..9485f8c90cac 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/disp.h
+++ b/drivers/gpu/drm/nouveau/dispnv50/disp.h
@@ -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 {
diff --git a/drivers/gpu/drm/nouveau/dispnv50/head.c b/drivers/gpu/drm/nouveau/dispnv50/head.c
index 83355dbc15ee..007857ac8542 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/head.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/head.c
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/dispnv50/head507d.c b/drivers/gpu/drm/nouveau/dispnv50/head507d.c
index 7fa1e0279d7d..634f6166f38d 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/head507d.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/head507d.c
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/dispnv50/ovly507e.c b/drivers/gpu/drm/nouveau/dispnv50/ovly507e.c
index 654e506f8431..4e109c5b5a1b 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/ovly507e.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/ovly507e.c
@@ -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
diff --git a/drivers/gpu/drm/nouveau/dispnv50/wndw.c b/drivers/gpu/drm/nouveau/dispnv50/wndw.c
index 7a2cceaee6e9..1dbf0e73b5de 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/wndw.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/wndw.c
@@ -181,7 +181,7 @@ nv50_wndw_ntfy_enable(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
 {
 	struct nv50_disp *disp = nv50_disp(wndw->plane.dev);
 
-	asyw->ntfy.handle = wndw->wndw.sync.handle;
+	asyw->ntfy.handle = wndw->sync.handle;
 	asyw->ntfy.offset = wndw->ntfy;
 	asyw->ntfy.awaken = false;
 	asyw->set.ntfy = true;
@@ -406,7 +406,7 @@ nv50_wndw_atomic_check_lut(struct nv50_wndw *wndw,
 	memset(&asyw->xlut, 0x00, sizeof(asyw->xlut));
 	if ((asyw->ilut = wndw->func->ilut ? ilut : NULL)) {
 		wndw->func->ilut(wndw, asyw, drm_color_lut_size(ilut));
-		asyw->xlut.handle = wndw->wndw.vram.handle;
+		asyw->xlut.handle = wndw->vram.handle;
 		asyw->xlut.i.buffer = !asyw->xlut.i.buffer;
 		asyw->set.xlut = true;
 	} else {
@@ -645,6 +645,9 @@ nv50_wndw_destroy(struct drm_plane *plane)
 	}
 
 	nv50_dmac_destroy(&wndw->wimm);
+
+	nvif_object_dtor(&wndw->vram);
+	nvif_object_dtor(&wndw->sync);
 	nv50_dmac_destroy(&wndw->wndw);
 
 	nv50_lut_fini(&wndw->ilut);
@@ -693,7 +696,44 @@ static const u64 nv50_cursor_format_modifiers[] = {
 };
 
 int
-nv50_wndw_new_(const struct nv50_wndw_func *func, struct drm_device *dev,
+nv50_wndw_ctor(struct nv50_wndw *wndw)
+{
+	struct nouveau_drm *drm = nouveau_drm(wndw->plane.dev);
+	struct nv50_disp *disp = nv50_disp(wndw->plane.dev);
+	int ret;
+
+	if (!nvif_object_constructed(&wndw->wndw.base.user))
+		return 0;
+
+	ret = nvif_object_ctor(&wndw->wndw.base.user, "kmsWndwSyncCtxDma", 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),
+			       &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) {
+					.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),
+			       &wndw->vram);
+	if (ret)
+		return ret;
+
+	return 0;
+}
+
+int
+nv50_wndw_prep(const struct nv50_wndw_func *func, struct drm_device *dev,
 	       enum drm_plane_type type, const char *name, int index,
 	       const u32 *format, u32 heads,
 	       enum nv50_disp_interlock_type interlock_type, u32 interlock_data,
diff --git a/drivers/gpu/drm/nouveau/dispnv50/wndw.h b/drivers/gpu/drm/nouveau/dispnv50/wndw.h
index 76a6ae5d5652..66a06e20a6a0 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/wndw.h
+++ b/drivers/gpu/drm/nouveau/dispnv50/wndw.h
@@ -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,
diff --git a/drivers/gpu/drm/nouveau/dispnv50/wndwc37e.c b/drivers/gpu/drm/nouveau/dispnv50/wndwc37e.c
index 50a7b97d37a2..5029dfd98443 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/wndwc37e.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/wndwc37e.c
@@ -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
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 022/156] drm/nouveau/nvkm: remove detect/mmio/subdev_mask from device args
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (20 preceding siblings ...)
  2024-04-16 23:37 ` [PATCH 021/156] drm/nouveau/kms: move dmac sync/vram ctxdmas to core+wndws Ben Skeggs
@ 2024-04-16 23:37 ` Ben Skeggs
  2024-04-16 23:37 ` [PATCH 023/156] drm/nouveau/nvkm: move nouveau_nvif.c to nvkm/core/driver.c Ben Skeggs
                   ` (135 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:37 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- now unused

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 .../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(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/pci.h b/drivers/gpu/drm/nouveau/include/nvkm/core/pci.h
index b4b5df3e1610..7444c4d59e09 100644
--- a/drivers/gpu/drm/nouveau/include/nvkm/core/pci.h
+++ b/drivers/gpu/drm/nouveau/include/nvkm/core/pci.h
@@ -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
diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/tegra.h b/drivers/gpu/drm/nouveau/include/nvkm/core/tegra.h
index ccee53d4e4ec..22f74fc88cd7 100644
--- a/drivers/gpu/drm/nouveau/include/nvkm/core/tegra.h
+++ b/drivers/gpu/drm/nouveau/include/nvkm/core/tegra.h
@@ -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
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 92b347b79919..33883c4e8221 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -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;
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c b/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c
index 31ed3da32fe7..006f01e93b9b 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c
@@ -67,12 +67,6 @@ nvkm_device_list(u64 *name, int size)
 	return nr;
 }
 
-static const struct nvkm_device_chip
-null_chipset = {
-	.name = "NULL",
-	.bios     = { 0x00000001, nvkm_bios_new },
-};
-
 static const struct nvkm_device_chip
 nv4_chipset = {
 	.name = "NV04",
@@ -3104,7 +3098,6 @@ nvkm_device_ctor(const struct nvkm_device_func *func,
 		 const struct nvkm_device_quirk *quirk,
 		 struct device *dev, enum nvkm_device_type type, u64 handle,
 		 const char *name, const char *cfg, const char *dbg,
-		 bool detect, bool mmio, u64 subdev_mask,
 		 struct nvkm_device *device)
 {
 	struct nvkm_subdev *subdev;
@@ -3132,233 +3125,228 @@ nvkm_device_ctor(const struct nvkm_device_func *func,
 	mmio_base = device->func->resource_addr(device, 0);
 	mmio_size = device->func->resource_size(device, 0);
 
-	if (detect || mmio) {
-		device->pri = ioremap(mmio_base, mmio_size);
-		if (device->pri == NULL) {
-			nvdev_error(device, "unable to map PRI\n");
-			ret = -ENOMEM;
-			goto done;
-		}
+	device->pri = ioremap(mmio_base, mmio_size);
+	if (device->pri == NULL) {
+		nvdev_error(device, "unable to map PRI\n");
+		ret = -ENOMEM;
+		goto done;
 	}
 
 	/* identify the chipset, and determine classes of subdev/engines */
-	if (detect) {
-		/* switch mmio to cpu's native endianness */
-		if (!nvkm_device_endianness(device)) {
-			nvdev_error(device,
-				    "Couldn't switch GPU to CPUs endianness\n");
-			ret = -ENOSYS;
-			goto done;
-		}
 
-		boot0 = nvkm_rd32(device, 0x000000);
-
-		/* chipset can be overridden for devel/testing purposes */
-		chipset = nvkm_longopt(device->cfgopt, "NvChipset", 0);
-		if (chipset) {
-			u32 override_boot0;
-
-			if (chipset >= 0x10) {
-				override_boot0  = ((chipset & 0x1ff) << 20);
-				override_boot0 |= 0x000000a1;
-			} else {
-				if (chipset != 0x04)
-					override_boot0 = 0x20104000;
-				else
-					override_boot0 = 0x20004000;
-			}
+	/* switch mmio to cpu's native endianness */
+	if (!nvkm_device_endianness(device)) {
+		nvdev_error(device,
+			    "Couldn't switch GPU to CPUs endianness\n");
+		ret = -ENOSYS;
+		goto done;
+	}
 
-			nvdev_warn(device, "CHIPSET OVERRIDE: %08x -> %08x\n",
-				   boot0, override_boot0);
-			boot0 = override_boot0;
-		}
+	boot0 = nvkm_rd32(device, 0x000000);
 
-		/* determine chipset and derive architecture from it */
-		if ((boot0 & 0x1f000000) > 0) {
-			device->chipset = (boot0 & 0x1ff00000) >> 20;
-			device->chiprev = (boot0 & 0x000000ff);
-			switch (device->chipset & 0x1f0) {
-			case 0x010: {
-				if (0x461 & (1 << (device->chipset & 0xf)))
-					device->card_type = NV_10;
-				else
-					device->card_type = NV_11;
-				device->chiprev = 0x00;
-				break;
-			}
-			case 0x020: device->card_type = NV_20; break;
-			case 0x030: device->card_type = NV_30; break;
-			case 0x040:
-			case 0x060: device->card_type = NV_40; break;
-			case 0x050:
-			case 0x080:
-			case 0x090:
-			case 0x0a0: device->card_type = NV_50; break;
-			case 0x0c0:
-			case 0x0d0: device->card_type = NV_C0; break;
-			case 0x0e0:
-			case 0x0f0:
-			case 0x100: device->card_type = NV_E0; break;
-			case 0x110:
-			case 0x120: device->card_type = GM100; break;
-			case 0x130: device->card_type = GP100; break;
-			case 0x140: device->card_type = GV100; break;
-			case 0x160: device->card_type = TU100; break;
-			case 0x170: device->card_type = GA100; break;
-			case 0x190: device->card_type = AD100; break;
-			default:
-				break;
-			}
-		} else
-		if ((boot0 & 0xff00fff0) == 0x20004000) {
-			if (boot0 & 0x00f00000)
-				device->chipset = 0x05;
+	/* chipset can be overridden for devel/testing purposes */
+	chipset = nvkm_longopt(device->cfgopt, "NvChipset", 0);
+	if (chipset) {
+		u32 override_boot0;
+
+		if (chipset >= 0x10) {
+			override_boot0  = ((chipset & 0x1ff) << 20);
+			override_boot0 |= 0x000000a1;
+		} else {
+			if (chipset != 0x04)
+				override_boot0 = 0x20104000;
 			else
-				device->chipset = 0x04;
-			device->card_type = NV_04;
+				override_boot0 = 0x20004000;
 		}
 
-		switch (device->chipset) {
-		case 0x004: device->chip = &nv4_chipset; break;
-		case 0x005: device->chip = &nv5_chipset; break;
-		case 0x010: device->chip = &nv10_chipset; break;
-		case 0x011: device->chip = &nv11_chipset; break;
-		case 0x015: device->chip = &nv15_chipset; break;
-		case 0x017: device->chip = &nv17_chipset; break;
-		case 0x018: device->chip = &nv18_chipset; break;
-		case 0x01a: device->chip = &nv1a_chipset; break;
-		case 0x01f: device->chip = &nv1f_chipset; break;
-		case 0x020: device->chip = &nv20_chipset; break;
-		case 0x025: device->chip = &nv25_chipset; break;
-		case 0x028: device->chip = &nv28_chipset; break;
-		case 0x02a: device->chip = &nv2a_chipset; break;
-		case 0x030: device->chip = &nv30_chipset; break;
-		case 0x031: device->chip = &nv31_chipset; break;
-		case 0x034: device->chip = &nv34_chipset; break;
-		case 0x035: device->chip = &nv35_chipset; break;
-		case 0x036: device->chip = &nv36_chipset; break;
-		case 0x040: device->chip = &nv40_chipset; break;
-		case 0x041: device->chip = &nv41_chipset; break;
-		case 0x042: device->chip = &nv42_chipset; break;
-		case 0x043: device->chip = &nv43_chipset; break;
-		case 0x044: device->chip = &nv44_chipset; break;
-		case 0x045: device->chip = &nv45_chipset; break;
-		case 0x046: device->chip = &nv46_chipset; break;
-		case 0x047: device->chip = &nv47_chipset; break;
-		case 0x049: device->chip = &nv49_chipset; break;
-		case 0x04a: device->chip = &nv4a_chipset; break;
-		case 0x04b: device->chip = &nv4b_chipset; break;
-		case 0x04c: device->chip = &nv4c_chipset; break;
-		case 0x04e: device->chip = &nv4e_chipset; break;
-		case 0x050: device->chip = &nv50_chipset; break;
-		case 0x063: device->chip = &nv63_chipset; break;
-		case 0x067: device->chip = &nv67_chipset; break;
-		case 0x068: device->chip = &nv68_chipset; break;
-		case 0x084: device->chip = &nv84_chipset; break;
-		case 0x086: device->chip = &nv86_chipset; break;
-		case 0x092: device->chip = &nv92_chipset; break;
-		case 0x094: device->chip = &nv94_chipset; break;
-		case 0x096: device->chip = &nv96_chipset; break;
-		case 0x098: device->chip = &nv98_chipset; break;
-		case 0x0a0: device->chip = &nva0_chipset; break;
-		case 0x0a3: device->chip = &nva3_chipset; break;
-		case 0x0a5: device->chip = &nva5_chipset; break;
-		case 0x0a8: device->chip = &nva8_chipset; break;
-		case 0x0aa: device->chip = &nvaa_chipset; break;
-		case 0x0ac: device->chip = &nvac_chipset; break;
-		case 0x0af: device->chip = &nvaf_chipset; break;
-		case 0x0c0: device->chip = &nvc0_chipset; break;
-		case 0x0c1: device->chip = &nvc1_chipset; break;
-		case 0x0c3: device->chip = &nvc3_chipset; break;
-		case 0x0c4: device->chip = &nvc4_chipset; break;
-		case 0x0c8: device->chip = &nvc8_chipset; break;
-		case 0x0ce: device->chip = &nvce_chipset; break;
-		case 0x0cf: device->chip = &nvcf_chipset; break;
-		case 0x0d7: device->chip = &nvd7_chipset; break;
-		case 0x0d9: device->chip = &nvd9_chipset; break;
-		case 0x0e4: device->chip = &nve4_chipset; break;
-		case 0x0e6: device->chip = &nve6_chipset; break;
-		case 0x0e7: device->chip = &nve7_chipset; break;
-		case 0x0ea: device->chip = &nvea_chipset; break;
-		case 0x0f0: device->chip = &nvf0_chipset; break;
-		case 0x0f1: device->chip = &nvf1_chipset; break;
-		case 0x106: device->chip = &nv106_chipset; break;
-		case 0x108: device->chip = &nv108_chipset; break;
-		case 0x117: device->chip = &nv117_chipset; break;
-		case 0x118: device->chip = &nv118_chipset; break;
-		case 0x120: device->chip = &nv120_chipset; break;
-		case 0x124: device->chip = &nv124_chipset; break;
-		case 0x126: device->chip = &nv126_chipset; break;
-		case 0x12b: device->chip = &nv12b_chipset; break;
-		case 0x130: device->chip = &nv130_chipset; break;
-		case 0x132: device->chip = &nv132_chipset; break;
-		case 0x134: device->chip = &nv134_chipset; break;
-		case 0x136: device->chip = &nv136_chipset; break;
-		case 0x137: device->chip = &nv137_chipset; break;
-		case 0x138: device->chip = &nv138_chipset; break;
-		case 0x13b: device->chip = &nv13b_chipset; break;
-		case 0x140: device->chip = &nv140_chipset; break;
-		case 0x162: device->chip = &nv162_chipset; break;
-		case 0x164: device->chip = &nv164_chipset; break;
-		case 0x166: device->chip = &nv166_chipset; break;
-		case 0x167: device->chip = &nv167_chipset; break;
-		case 0x168: device->chip = &nv168_chipset; break;
-		case 0x172: device->chip = &nv172_chipset; break;
-		case 0x173: device->chip = &nv173_chipset; break;
-		case 0x174: device->chip = &nv174_chipset; break;
-		case 0x176: device->chip = &nv176_chipset; break;
-		case 0x177: device->chip = &nv177_chipset; break;
-		case 0x192: device->chip = &nv192_chipset; break;
-		case 0x193: device->chip = &nv193_chipset; break;
-		case 0x194: device->chip = &nv194_chipset; break;
-		case 0x196: device->chip = &nv196_chipset; break;
-		case 0x197: device->chip = &nv197_chipset; break;
-		default:
-			if (nvkm_boolopt(device->cfgopt, "NvEnableUnsupportedChipsets", false)) {
-				switch (device->chipset) {
-				case 0x170: device->chip = &nv170_chipset; break;
-				default:
-					break;
-				}
-			}
+		nvdev_warn(device, "CHIPSET OVERRIDE: %08x -> %08x\n",
+			   boot0, override_boot0);
+		boot0 = override_boot0;
+	}
 
-			if (!device->chip) {
-				nvdev_error(device, "unknown chipset (%08x)\n", boot0);
-				ret = -ENODEV;
-				goto done;
-			}
+	/* determine chipset and derive architecture from it */
+	if ((boot0 & 0x1f000000) > 0) {
+		device->chipset = (boot0 & 0x1ff00000) >> 20;
+		device->chiprev = (boot0 & 0x000000ff);
+		switch (device->chipset & 0x1f0) {
+		case 0x010: {
+			if (0x461 & (1 << (device->chipset & 0xf)))
+				device->card_type = NV_10;
+			else
+				device->card_type = NV_11;
+			device->chiprev = 0x00;
 			break;
 		}
+		case 0x020: device->card_type = NV_20; break;
+		case 0x030: device->card_type = NV_30; break;
+		case 0x040:
+		case 0x060: device->card_type = NV_40; break;
+		case 0x050:
+		case 0x080:
+		case 0x090:
+		case 0x0a0: device->card_type = NV_50; break;
+		case 0x0c0:
+		case 0x0d0: device->card_type = NV_C0; break;
+		case 0x0e0:
+		case 0x0f0:
+		case 0x100: device->card_type = NV_E0; break;
+		case 0x110:
+		case 0x120: device->card_type = GM100; break;
+		case 0x130: device->card_type = GP100; break;
+		case 0x140: device->card_type = GV100; break;
+		case 0x160: device->card_type = TU100; break;
+		case 0x170: device->card_type = GA100; break;
+		case 0x190: device->card_type = AD100; break;
+		default:
+			break;
+		}
+	} else
+	if ((boot0 & 0xff00fff0) == 0x20004000) {
+		if (boot0 & 0x00f00000)
+			device->chipset = 0x05;
+		else
+			device->chipset = 0x04;
+		device->card_type = NV_04;
+	}
 
-		nvdev_info(device, "NVIDIA %s (%08x)\n",
-			   device->chip->name, boot0);
+	switch (device->chipset) {
+	case 0x004: device->chip = &nv4_chipset; break;
+	case 0x005: device->chip = &nv5_chipset; break;
+	case 0x010: device->chip = &nv10_chipset; break;
+	case 0x011: device->chip = &nv11_chipset; break;
+	case 0x015: device->chip = &nv15_chipset; break;
+	case 0x017: device->chip = &nv17_chipset; break;
+	case 0x018: device->chip = &nv18_chipset; break;
+	case 0x01a: device->chip = &nv1a_chipset; break;
+	case 0x01f: device->chip = &nv1f_chipset; break;
+	case 0x020: device->chip = &nv20_chipset; break;
+	case 0x025: device->chip = &nv25_chipset; break;
+	case 0x028: device->chip = &nv28_chipset; break;
+	case 0x02a: device->chip = &nv2a_chipset; break;
+	case 0x030: device->chip = &nv30_chipset; break;
+	case 0x031: device->chip = &nv31_chipset; break;
+	case 0x034: device->chip = &nv34_chipset; break;
+	case 0x035: device->chip = &nv35_chipset; break;
+	case 0x036: device->chip = &nv36_chipset; break;
+	case 0x040: device->chip = &nv40_chipset; break;
+	case 0x041: device->chip = &nv41_chipset; break;
+	case 0x042: device->chip = &nv42_chipset; break;
+	case 0x043: device->chip = &nv43_chipset; break;
+	case 0x044: device->chip = &nv44_chipset; break;
+	case 0x045: device->chip = &nv45_chipset; break;
+	case 0x046: device->chip = &nv46_chipset; break;
+	case 0x047: device->chip = &nv47_chipset; break;
+	case 0x049: device->chip = &nv49_chipset; break;
+	case 0x04a: device->chip = &nv4a_chipset; break;
+	case 0x04b: device->chip = &nv4b_chipset; break;
+	case 0x04c: device->chip = &nv4c_chipset; break;
+	case 0x04e: device->chip = &nv4e_chipset; break;
+	case 0x050: device->chip = &nv50_chipset; break;
+	case 0x063: device->chip = &nv63_chipset; break;
+	case 0x067: device->chip = &nv67_chipset; break;
+	case 0x068: device->chip = &nv68_chipset; break;
+	case 0x084: device->chip = &nv84_chipset; break;
+	case 0x086: device->chip = &nv86_chipset; break;
+	case 0x092: device->chip = &nv92_chipset; break;
+	case 0x094: device->chip = &nv94_chipset; break;
+	case 0x096: device->chip = &nv96_chipset; break;
+	case 0x098: device->chip = &nv98_chipset; break;
+	case 0x0a0: device->chip = &nva0_chipset; break;
+	case 0x0a3: device->chip = &nva3_chipset; break;
+	case 0x0a5: device->chip = &nva5_chipset; break;
+	case 0x0a8: device->chip = &nva8_chipset; break;
+	case 0x0aa: device->chip = &nvaa_chipset; break;
+	case 0x0ac: device->chip = &nvac_chipset; break;
+	case 0x0af: device->chip = &nvaf_chipset; break;
+	case 0x0c0: device->chip = &nvc0_chipset; break;
+	case 0x0c1: device->chip = &nvc1_chipset; break;
+	case 0x0c3: device->chip = &nvc3_chipset; break;
+	case 0x0c4: device->chip = &nvc4_chipset; break;
+	case 0x0c8: device->chip = &nvc8_chipset; break;
+	case 0x0ce: device->chip = &nvce_chipset; break;
+	case 0x0cf: device->chip = &nvcf_chipset; break;
+	case 0x0d7: device->chip = &nvd7_chipset; break;
+	case 0x0d9: device->chip = &nvd9_chipset; break;
+	case 0x0e4: device->chip = &nve4_chipset; break;
+	case 0x0e6: device->chip = &nve6_chipset; break;
+	case 0x0e7: device->chip = &nve7_chipset; break;
+	case 0x0ea: device->chip = &nvea_chipset; break;
+	case 0x0f0: device->chip = &nvf0_chipset; break;
+	case 0x0f1: device->chip = &nvf1_chipset; break;
+	case 0x106: device->chip = &nv106_chipset; break;
+	case 0x108: device->chip = &nv108_chipset; break;
+	case 0x117: device->chip = &nv117_chipset; break;
+	case 0x118: device->chip = &nv118_chipset; break;
+	case 0x120: device->chip = &nv120_chipset; break;
+	case 0x124: device->chip = &nv124_chipset; break;
+	case 0x126: device->chip = &nv126_chipset; break;
+	case 0x12b: device->chip = &nv12b_chipset; break;
+	case 0x130: device->chip = &nv130_chipset; break;
+	case 0x132: device->chip = &nv132_chipset; break;
+	case 0x134: device->chip = &nv134_chipset; break;
+	case 0x136: device->chip = &nv136_chipset; break;
+	case 0x137: device->chip = &nv137_chipset; break;
+	case 0x138: device->chip = &nv138_chipset; break;
+	case 0x13b: device->chip = &nv13b_chipset; break;
+	case 0x140: device->chip = &nv140_chipset; break;
+	case 0x162: device->chip = &nv162_chipset; break;
+	case 0x164: device->chip = &nv164_chipset; break;
+	case 0x166: device->chip = &nv166_chipset; break;
+	case 0x167: device->chip = &nv167_chipset; break;
+	case 0x168: device->chip = &nv168_chipset; break;
+	case 0x172: device->chip = &nv172_chipset; break;
+	case 0x173: device->chip = &nv173_chipset; break;
+	case 0x174: device->chip = &nv174_chipset; break;
+	case 0x176: device->chip = &nv176_chipset; break;
+	case 0x177: device->chip = &nv177_chipset; break;
+	case 0x192: device->chip = &nv192_chipset; break;
+	case 0x193: device->chip = &nv193_chipset; break;
+	case 0x194: device->chip = &nv194_chipset; break;
+	case 0x196: device->chip = &nv196_chipset; break;
+	case 0x197: device->chip = &nv197_chipset; break;
+	default:
+		if (nvkm_boolopt(device->cfgopt, "NvEnableUnsupportedChipsets", false)) {
+			switch (device->chipset) {
+			case 0x170: device->chip = &nv170_chipset; break;
+			default:
+				break;
+			}
+		}
 
-		/* vGPU detection */
-		boot1 = nvkm_rd32(device, 0x0000004);
-		if (device->card_type >= TU100 && (boot1 & 0x00030000)) {
-			nvdev_info(device, "vGPUs are not supported\n");
+		if (!device->chip) {
+			nvdev_error(device, "unknown chipset (%08x)\n", boot0);
 			ret = -ENODEV;
 			goto done;
 		}
+		break;
+	}
 
-		/* read strapping information */
-		strap = nvkm_rd32(device, 0x101000);
+	nvdev_info(device, "NVIDIA %s (%08x)\n",
+		   device->chip->name, boot0);
 
-		/* determine frequency of timing crystal */
-		if ( device->card_type <= NV_10 || device->chipset < 0x17 ||
-		    (device->chipset >= 0x20 && device->chipset < 0x25))
-			strap &= 0x00000040;
-		else
-			strap &= 0x00400040;
+	/* vGPU detection */
+	boot1 = nvkm_rd32(device, 0x0000004);
+	if (device->card_type >= TU100 && (boot1 & 0x00030000)) {
+		nvdev_info(device, "vGPUs are not supported\n");
+		ret = -ENODEV;
+		goto done;
+	}
 
-		switch (strap) {
-		case 0x00000000: device->crystal = 13500; break;
-		case 0x00000040: device->crystal = 14318; break;
-		case 0x00400000: device->crystal = 27000; break;
-		case 0x00400040: device->crystal = 25000; break;
-		}
-	} else {
-		device->chip = &null_chipset;
+	/* read strapping information */
+	strap = nvkm_rd32(device, 0x101000);
+
+	/* determine frequency of timing crystal */
+	if ( device->card_type <= NV_10 || device->chipset < 0x17 ||
+	    (device->chipset >= 0x20 && device->chipset < 0x25))
+		strap &= 0x00000040;
+	else
+		strap &= 0x00400040;
+
+	switch (strap) {
+	case 0x00000000: device->crystal = 13500; break;
+	case 0x00000040: device->crystal = 14318; break;
+	case 0x00400000: device->crystal = 27000; break;
+	case 0x00400040: device->crystal = 25000; break;
 	}
 
 	if (!device->name)
@@ -3368,7 +3356,7 @@ nvkm_device_ctor(const struct nvkm_device_func *func,
 	nvkm_intr_ctor(device);
 
 #define NVKM_LAYOUT_ONCE(type,data,ptr)                                                      \
-	if (device->chip->ptr.inst && (subdev_mask & (BIT_ULL(type)))) {                     \
+	if (device->chip->ptr.inst) {                                                        \
 		WARN_ON(device->chip->ptr.inst != 0x00000001);                               \
 		ret = device->chip->ptr.ctor(device, (type), -1, &device->ptr);              \
 		subdev = nvkm_device_subdev(device, (type), 0);                              \
@@ -3387,7 +3375,7 @@ nvkm_device_ctor(const struct nvkm_device_func *func,
 #define NVKM_LAYOUT_INST(type,data,ptr,cnt)                                                  \
 	WARN_ON(device->chip->ptr.inst & ~((1 << ARRAY_SIZE(device->ptr)) - 1));             \
 	for (j = 0; device->chip->ptr.inst && j < ARRAY_SIZE(device->ptr); j++) {            \
-		if ((device->chip->ptr.inst & BIT(j)) && (subdev_mask & BIT_ULL(type))) {    \
+		if (device->chip->ptr.inst & BIT(j)) {                                       \
 			ret = device->chip->ptr.ctor(device, (type), (j), &device->ptr[j]);  \
 			subdev = nvkm_device_subdev(device, (type), (j));                    \
 			if (ret) {                                                           \
@@ -3409,7 +3397,7 @@ nvkm_device_ctor(const struct nvkm_device_func *func,
 
 	ret = nvkm_intr_install(device);
 done:
-	if (device->pri && (!mmio || ret)) {
+	if (ret && device->pri) {
 		iounmap(device->pri);
 		device->pri = NULL;
 	}
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/device/pci.c b/drivers/gpu/drm/nouveau/nvkm/engine/device/pci.c
index abccb2bb68a6..3ff6436007fa 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/device/pci.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/device/pci.c
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/device/priv.h b/drivers/gpu/drm/nouveau/nvkm/engine/device/priv.h
index bf3176bec18a..c182d9c3e4fa 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/device/priv.h
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/device/priv.h
@@ -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);
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c b/drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c
index 87caa4a72921..d1c294f00665 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c
@@ -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;
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 023/156] drm/nouveau/nvkm: move nouveau_nvif.c to nvkm/core/driver.c
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (21 preceding siblings ...)
  2024-04-16 23:37 ` [PATCH 022/156] drm/nouveau/nvkm: remove detect/mmio/subdev_mask from device args Ben Skeggs
@ 2024-04-16 23:37 ` Ben Skeggs
  2024-04-16 23:37 ` [PATCH 024/156] drm/nouveau/nvkm: move nvkm/engine/device/ to nvkm/device/ Ben Skeggs
                   ` (134 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:37 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- move to a more appropriate place before making changes

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 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%)

diff --git a/drivers/gpu/drm/nouveau/Kbuild b/drivers/gpu/drm/nouveau/Kbuild
index c3223ec97aff..f99b7b227947 100644
--- a/drivers/gpu/drm/nouveau/Kbuild
+++ b/drivers/gpu/drm/nouveau/Kbuild
@@ -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
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/core/Kbuild b/drivers/gpu/drm/nouveau/nvkm/core/Kbuild
index e40712023c73..7d111a5481d3 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/Kbuild
+++ b/drivers/gpu/drm/nouveau/nvkm/core/Kbuild
@@ -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
diff --git a/drivers/gpu/drm/nouveau/nouveau_nvif.c b/drivers/gpu/drm/nouveau/nvkm/core/driver.c
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
--- a/drivers/gpu/drm/nouveau/nouveau_nvif.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/driver.c
@@ -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,
 };
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 024/156] drm/nouveau/nvkm: move nvkm/engine/device/ to nvkm/device/
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (22 preceding siblings ...)
  2024-04-16 23:37 ` [PATCH 023/156] drm/nouveau/nvkm: move nouveau_nvif.c to nvkm/core/driver.c Ben Skeggs
@ 2024-04-16 23:37 ` Ben Skeggs
  2024-04-16 23:37 ` [PATCH 025/156] drm/nouveau/nvkm: remove perfmon Ben Skeggs
                   ` (133 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:37 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- move to a more appropriate place before making changes

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 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

diff --git a/drivers/gpu/drm/nouveau/nvkm/Kbuild b/drivers/gpu/drm/nouveau/nvkm/Kbuild
index db3ade125fa9..f68c19586b53 100644
--- a/drivers/gpu/drm/nouveau/nvkm/Kbuild
+++ b/drivers/gpu/drm/nouveau/nvkm/Kbuild
@@ -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
diff --git a/drivers/gpu/drm/nouveau/nvkm/device/Kbuild b/drivers/gpu/drm/nouveau/nvkm/device/Kbuild
new file mode 100644
index 000000000000..0e5ce7877b94
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/nvkm/device/Kbuild
@@ -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
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/device/acpi.c b/drivers/gpu/drm/nouveau/nvkm/device/acpi.c
similarity index 100%
rename from drivers/gpu/drm/nouveau/nvkm/engine/device/acpi.c
rename to drivers/gpu/drm/nouveau/nvkm/device/acpi.c
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/device/acpi.h b/drivers/gpu/drm/nouveau/nvkm/device/acpi.h
similarity index 100%
rename from drivers/gpu/drm/nouveau/nvkm/engine/device/acpi.h
rename to drivers/gpu/drm/nouveau/nvkm/device/acpi.h
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c b/drivers/gpu/drm/nouveau/nvkm/device/base.c
similarity index 100%
rename from drivers/gpu/drm/nouveau/nvkm/engine/device/base.c
rename to drivers/gpu/drm/nouveau/nvkm/device/base.c
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/device/ctrl.c b/drivers/gpu/drm/nouveau/nvkm/device/ctrl.c
similarity index 100%
rename from drivers/gpu/drm/nouveau/nvkm/engine/device/ctrl.c
rename to drivers/gpu/drm/nouveau/nvkm/device/ctrl.c
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/device/ctrl.h b/drivers/gpu/drm/nouveau/nvkm/device/ctrl.h
similarity index 100%
rename from drivers/gpu/drm/nouveau/nvkm/engine/device/ctrl.h
rename to drivers/gpu/drm/nouveau/nvkm/device/ctrl.h
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/device/pci.c b/drivers/gpu/drm/nouveau/nvkm/device/pci.c
similarity index 100%
rename from drivers/gpu/drm/nouveau/nvkm/engine/device/pci.c
rename to drivers/gpu/drm/nouveau/nvkm/device/pci.c
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/device/priv.h b/drivers/gpu/drm/nouveau/nvkm/device/priv.h
similarity index 100%
rename from drivers/gpu/drm/nouveau/nvkm/engine/device/priv.h
rename to drivers/gpu/drm/nouveau/nvkm/device/priv.h
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c b/drivers/gpu/drm/nouveau/nvkm/device/tegra.c
similarity index 100%
rename from drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c
rename to drivers/gpu/drm/nouveau/nvkm/device/tegra.c
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/device/user.c b/drivers/gpu/drm/nouveau/nvkm/device/user.c
similarity index 100%
rename from drivers/gpu/drm/nouveau/nvkm/engine/device/user.c
rename to drivers/gpu/drm/nouveau/nvkm/device/user.c
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/Kbuild b/drivers/gpu/drm/nouveau/nvkm/engine/Kbuild
index bfaaff645a34..f9eb68a25de8 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/Kbuild
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/Kbuild
@@ -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
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/device/Kbuild b/drivers/gpu/drm/nouveau/nvkm/engine/device/Kbuild
deleted file mode 100644
index 293c57678dab..000000000000
--- a/drivers/gpu/drm/nouveau/nvkm/engine/device/Kbuild
+++ /dev/null
@@ -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
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 025/156] drm/nouveau/nvkm: remove perfmon
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (23 preceding siblings ...)
  2024-04-16 23:37 ` [PATCH 024/156] drm/nouveau/nvkm: move nvkm/engine/device/ to nvkm/device/ Ben Skeggs
@ 2024-04-16 23:37 ` Ben Skeggs
  2024-04-16 23:37 ` [PATCH 026/156] drm/nouveau/nvkm: remove nvkm_client_search() Ben Skeggs
                   ` (132 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:37 UTC (permalink / raw)
  To: nouveau; +Cc: 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.

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 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

diff --git a/drivers/gpu/drm/nouveau/include/nvif/class.h b/drivers/gpu/drm/nouveau/include/nvif/class.h
index e668ab1664f0..824e052dcc25 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/class.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/class.h
@@ -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
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0002.h b/drivers/gpu/drm/nouveau/include/nvif/if0002.h
deleted file mode 100644
index df2915d6a61e..000000000000
--- a/drivers/gpu/drm/nouveau/include/nvif/if0002.h
+++ /dev/null
@@ -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
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0003.h b/drivers/gpu/drm/nouveau/include/nvif/if0003.h
deleted file mode 100644
index 78467da07c37..000000000000
--- a/drivers/gpu/drm/nouveau/include/nvif/if0003.h
+++ /dev/null
@@ -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
diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/layout.h b/drivers/gpu/drm/nouveau/include/nvkm/core/layout.h
index 30c17db483cb..9d2a1abf64f9 100644
--- a/drivers/gpu/drm/nouveau/include/nvkm/core/layout.h
+++ b/drivers/gpu/drm/nouveau/include/nvkm/core/layout.h
@@ -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)
diff --git a/drivers/gpu/drm/nouveau/include/nvkm/engine/pm.h b/drivers/gpu/drm/nouveau/include/nvkm/engine/pm.h
deleted file mode 100644
index af89d46ea360..000000000000
--- a/drivers/gpu/drm/nouveau/include/nvkm/engine/pm.h
+++ /dev/null
@@ -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
diff --git a/drivers/gpu/drm/nouveau/nvkm/device/base.c b/drivers/gpu/drm/nouveau/nvkm/device/base.c
index 006f01e93b9b..3f827adcb19d 100644
--- a/drivers/gpu/drm/nouveau/nvkm/device/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/device/base.c
@@ -484,7 +484,6 @@ nv40_chipset = {
 	.fifo     = { 0x00000001, nv40_fifo_new },
 	.gr       = { 0x00000001, nv40_gr_new },
 	.mpeg     = { 0x00000001, nv40_mpeg_new },
-	.pm       = { 0x00000001, nv40_pm_new },
 	.sw       = { 0x00000001, nv10_sw_new },
 };
 
@@ -510,7 +509,6 @@ nv41_chipset = {
 	.fifo     = { 0x00000001, nv40_fifo_new },
 	.gr       = { 0x00000001, nv40_gr_new },
 	.mpeg     = { 0x00000001, nv40_mpeg_new },
-	.pm       = { 0x00000001, nv40_pm_new },
 	.sw       = { 0x00000001, nv10_sw_new },
 };
 
@@ -536,7 +534,6 @@ nv42_chipset = {
 	.fifo     = { 0x00000001, nv40_fifo_new },
 	.gr       = { 0x00000001, nv40_gr_new },
 	.mpeg     = { 0x00000001, nv40_mpeg_new },
-	.pm       = { 0x00000001, nv40_pm_new },
 	.sw       = { 0x00000001, nv10_sw_new },
 };
 
@@ -562,7 +559,6 @@ nv43_chipset = {
 	.fifo     = { 0x00000001, nv40_fifo_new },
 	.gr       = { 0x00000001, nv40_gr_new },
 	.mpeg     = { 0x00000001, nv40_mpeg_new },
-	.pm       = { 0x00000001, nv40_pm_new },
 	.sw       = { 0x00000001, nv10_sw_new },
 };
 
@@ -588,7 +584,6 @@ nv44_chipset = {
 	.fifo     = { 0x00000001, nv40_fifo_new },
 	.gr       = { 0x00000001, nv44_gr_new },
 	.mpeg     = { 0x00000001, nv44_mpeg_new },
-	.pm       = { 0x00000001, nv40_pm_new },
 	.sw       = { 0x00000001, nv10_sw_new },
 };
 
@@ -614,7 +609,6 @@ nv45_chipset = {
 	.fifo     = { 0x00000001, nv40_fifo_new },
 	.gr       = { 0x00000001, nv40_gr_new },
 	.mpeg     = { 0x00000001, nv44_mpeg_new },
-	.pm       = { 0x00000001, nv40_pm_new },
 	.sw       = { 0x00000001, nv10_sw_new },
 };
 
@@ -640,7 +634,6 @@ nv46_chipset = {
 	.fifo     = { 0x00000001, nv40_fifo_new },
 	.gr       = { 0x00000001, nv44_gr_new },
 	.mpeg     = { 0x00000001, nv44_mpeg_new },
-	.pm       = { 0x00000001, nv40_pm_new },
 	.sw       = { 0x00000001, nv10_sw_new },
 };
 
@@ -666,7 +659,6 @@ nv47_chipset = {
 	.fifo     = { 0x00000001, nv40_fifo_new },
 	.gr       = { 0x00000001, nv40_gr_new },
 	.mpeg     = { 0x00000001, nv44_mpeg_new },
-	.pm       = { 0x00000001, nv40_pm_new },
 	.sw       = { 0x00000001, nv10_sw_new },
 };
 
@@ -692,7 +684,6 @@ nv49_chipset = {
 	.fifo     = { 0x00000001, nv40_fifo_new },
 	.gr       = { 0x00000001, nv40_gr_new },
 	.mpeg     = { 0x00000001, nv44_mpeg_new },
-	.pm       = { 0x00000001, nv40_pm_new },
 	.sw       = { 0x00000001, nv10_sw_new },
 };
 
@@ -718,7 +709,6 @@ nv4a_chipset = {
 	.fifo     = { 0x00000001, nv40_fifo_new },
 	.gr       = { 0x00000001, nv44_gr_new },
 	.mpeg     = { 0x00000001, nv44_mpeg_new },
-	.pm       = { 0x00000001, nv40_pm_new },
 	.sw       = { 0x00000001, nv10_sw_new },
 };
 
@@ -744,7 +734,6 @@ nv4b_chipset = {
 	.fifo     = { 0x00000001, nv40_fifo_new },
 	.gr       = { 0x00000001, nv40_gr_new },
 	.mpeg     = { 0x00000001, nv44_mpeg_new },
-	.pm       = { 0x00000001, nv40_pm_new },
 	.sw       = { 0x00000001, nv10_sw_new },
 };
 
@@ -770,7 +759,6 @@ nv4c_chipset = {
 	.fifo     = { 0x00000001, nv40_fifo_new },
 	.gr       = { 0x00000001, nv44_gr_new },
 	.mpeg     = { 0x00000001, nv44_mpeg_new },
-	.pm       = { 0x00000001, nv40_pm_new },
 	.sw       = { 0x00000001, nv10_sw_new },
 };
 
@@ -796,7 +784,6 @@ nv4e_chipset = {
 	.fifo     = { 0x00000001, nv40_fifo_new },
 	.gr       = { 0x00000001, nv44_gr_new },
 	.mpeg     = { 0x00000001, nv44_mpeg_new },
-	.pm       = { 0x00000001, nv40_pm_new },
 	.sw       = { 0x00000001, nv10_sw_new },
 };
 
@@ -825,7 +812,6 @@ nv50_chipset = {
 	.fifo     = { 0x00000001, nv50_fifo_new },
 	.gr       = { 0x00000001, nv50_gr_new },
 	.mpeg     = { 0x00000001, nv50_mpeg_new },
-	.pm       = { 0x00000001, nv50_pm_new },
 	.sw       = { 0x00000001, nv50_sw_new },
 };
 
@@ -851,7 +837,6 @@ nv63_chipset = {
 	.fifo     = { 0x00000001, nv40_fifo_new },
 	.gr       = { 0x00000001, nv44_gr_new },
 	.mpeg     = { 0x00000001, nv44_mpeg_new },
-	.pm       = { 0x00000001, nv40_pm_new },
 	.sw       = { 0x00000001, nv10_sw_new },
 };
 
@@ -877,7 +862,6 @@ nv67_chipset = {
 	.fifo     = { 0x00000001, nv40_fifo_new },
 	.gr       = { 0x00000001, nv44_gr_new },
 	.mpeg     = { 0x00000001, nv44_mpeg_new },
-	.pm       = { 0x00000001, nv40_pm_new },
 	.sw       = { 0x00000001, nv10_sw_new },
 };
 
@@ -903,7 +887,6 @@ nv68_chipset = {
 	.fifo     = { 0x00000001, nv40_fifo_new },
 	.gr       = { 0x00000001, nv44_gr_new },
 	.mpeg     = { 0x00000001, nv44_mpeg_new },
-	.pm       = { 0x00000001, nv40_pm_new },
 	.sw       = { 0x00000001, nv10_sw_new },
 };
 
@@ -934,7 +917,6 @@ nv84_chipset = {
 	.fifo     = { 0x00000001, g84_fifo_new },
 	.gr       = { 0x00000001, g84_gr_new },
 	.mpeg     = { 0x00000001, g84_mpeg_new },
-	.pm       = { 0x00000001, g84_pm_new },
 	.sw       = { 0x00000001, nv50_sw_new },
 	.vp       = { 0x00000001, g84_vp_new },
 };
@@ -966,7 +948,6 @@ nv86_chipset = {
 	.fifo     = { 0x00000001, g84_fifo_new },
 	.gr       = { 0x00000001, g84_gr_new },
 	.mpeg     = { 0x00000001, g84_mpeg_new },
-	.pm       = { 0x00000001, g84_pm_new },
 	.sw       = { 0x00000001, nv50_sw_new },
 	.vp       = { 0x00000001, g84_vp_new },
 };
@@ -998,7 +979,6 @@ nv92_chipset = {
 	.fifo     = { 0x00000001, g84_fifo_new },
 	.gr       = { 0x00000001, g84_gr_new },
 	.mpeg     = { 0x00000001, g84_mpeg_new },
-	.pm       = { 0x00000001, g84_pm_new },
 	.sw       = { 0x00000001, nv50_sw_new },
 	.vp       = { 0x00000001, g84_vp_new },
 };
@@ -1030,7 +1010,6 @@ nv94_chipset = {
 	.fifo     = { 0x00000001, g84_fifo_new },
 	.gr       = { 0x00000001, g84_gr_new },
 	.mpeg     = { 0x00000001, g84_mpeg_new },
-	.pm       = { 0x00000001, g84_pm_new },
 	.sw       = { 0x00000001, nv50_sw_new },
 	.vp       = { 0x00000001, g84_vp_new },
 };
@@ -1062,7 +1041,6 @@ nv96_chipset = {
 	.fifo     = { 0x00000001, g84_fifo_new },
 	.gr       = { 0x00000001, g84_gr_new },
 	.mpeg     = { 0x00000001, g84_mpeg_new },
-	.pm       = { 0x00000001, g84_pm_new },
 	.sw       = { 0x00000001, nv50_sw_new },
 	.vp       = { 0x00000001, g84_vp_new },
 };
@@ -1094,7 +1072,6 @@ nv98_chipset = {
 	.mspdec   = { 0x00000001, g98_mspdec_new },
 	.msppp    = { 0x00000001, g98_msppp_new },
 	.msvld    = { 0x00000001, g98_msvld_new },
-	.pm       = { 0x00000001, g84_pm_new },
 	.sec      = { 0x00000001, g98_sec_new },
 	.sw       = { 0x00000001, nv50_sw_new },
 };
@@ -1126,7 +1103,6 @@ nva0_chipset = {
 	.fifo     = { 0x00000001, g84_fifo_new },
 	.gr       = { 0x00000001, gt200_gr_new },
 	.mpeg     = { 0x00000001, g84_mpeg_new },
-	.pm       = { 0x00000001, gt200_pm_new },
 	.sw       = { 0x00000001, nv50_sw_new },
 	.vp       = { 0x00000001, g84_vp_new },
 };
@@ -1148,7 +1124,6 @@ nva3_chipset = {
 	.mmu      = { 0x00000001, g84_mmu_new },
 	.mxm      = { 0x00000001, nv50_mxm_new },
 	.pci      = { 0x00000001, g94_pci_new },
-	.pmu      = { 0x00000001, gt215_pmu_new },
 	.therm    = { 0x00000001, gt215_therm_new },
 	.timer    = { 0x00000001, nv41_timer_new },
 	.volt     = { 0x00000001, nv40_volt_new },
@@ -1161,7 +1136,6 @@ nva3_chipset = {
 	.mspdec   = { 0x00000001, gt215_mspdec_new },
 	.msppp    = { 0x00000001, gt215_msppp_new },
 	.msvld    = { 0x00000001, gt215_msvld_new },
-	.pm       = { 0x00000001, gt215_pm_new },
 	.sw       = { 0x00000001, nv50_sw_new },
 };
 
@@ -1182,7 +1156,6 @@ nva5_chipset = {
 	.mmu      = { 0x00000001, g84_mmu_new },
 	.mxm      = { 0x00000001, nv50_mxm_new },
 	.pci      = { 0x00000001, g94_pci_new },
-	.pmu      = { 0x00000001, gt215_pmu_new },
 	.therm    = { 0x00000001, gt215_therm_new },
 	.timer    = { 0x00000001, nv41_timer_new },
 	.volt     = { 0x00000001, nv40_volt_new },
@@ -1194,7 +1167,6 @@ nva5_chipset = {
 	.mspdec   = { 0x00000001, gt215_mspdec_new },
 	.msppp    = { 0x00000001, gt215_msppp_new },
 	.msvld    = { 0x00000001, gt215_msvld_new },
-	.pm       = { 0x00000001, gt215_pm_new },
 	.sw       = { 0x00000001, nv50_sw_new },
 };
 
@@ -1215,7 +1187,6 @@ nva8_chipset = {
 	.mmu      = { 0x00000001, g84_mmu_new },
 	.mxm      = { 0x00000001, nv50_mxm_new },
 	.pci      = { 0x00000001, g94_pci_new },
-	.pmu      = { 0x00000001, gt215_pmu_new },
 	.therm    = { 0x00000001, gt215_therm_new },
 	.timer    = { 0x00000001, nv41_timer_new },
 	.volt     = { 0x00000001, nv40_volt_new },
@@ -1227,7 +1198,6 @@ nva8_chipset = {
 	.mspdec   = { 0x00000001, gt215_mspdec_new },
 	.msppp    = { 0x00000001, gt215_msppp_new },
 	.msvld    = { 0x00000001, gt215_msvld_new },
-	.pm       = { 0x00000001, gt215_pm_new },
 	.sw       = { 0x00000001, nv50_sw_new },
 };
 
@@ -1258,7 +1228,6 @@ nvaa_chipset = {
 	.mspdec   = { 0x00000001, g98_mspdec_new },
 	.msppp    = { 0x00000001, g98_msppp_new },
 	.msvld    = { 0x00000001, g98_msvld_new },
-	.pm       = { 0x00000001, g84_pm_new },
 	.sec      = { 0x00000001, g98_sec_new },
 	.sw       = { 0x00000001, nv50_sw_new },
 };
@@ -1290,7 +1259,6 @@ nvac_chipset = {
 	.mspdec   = { 0x00000001, g98_mspdec_new },
 	.msppp    = { 0x00000001, g98_msppp_new },
 	.msvld    = { 0x00000001, g98_msvld_new },
-	.pm       = { 0x00000001, g84_pm_new },
 	.sec      = { 0x00000001, g98_sec_new },
 	.sw       = { 0x00000001, nv50_sw_new },
 };
@@ -1312,7 +1280,6 @@ nvaf_chipset = {
 	.mmu      = { 0x00000001, mcp77_mmu_new },
 	.mxm      = { 0x00000001, nv50_mxm_new },
 	.pci      = { 0x00000001, g94_pci_new },
-	.pmu      = { 0x00000001, gt215_pmu_new },
 	.therm    = { 0x00000001, gt215_therm_new },
 	.timer    = { 0x00000001, nv41_timer_new },
 	.volt     = { 0x00000001, nv40_volt_new },
@@ -1324,7 +1291,6 @@ nvaf_chipset = {
 	.mspdec   = { 0x00000001, gt215_mspdec_new },
 	.msppp    = { 0x00000001, gt215_msppp_new },
 	.msvld    = { 0x00000001, mcp89_msvld_new },
-	.pm       = { 0x00000001, gt215_pm_new },
 	.sw       = { 0x00000001, nv50_sw_new },
 };
 
@@ -1347,7 +1313,6 @@ nvc0_chipset = {
 	.mmu      = { 0x00000001, gf100_mmu_new },
 	.mxm      = { 0x00000001, nv50_mxm_new },
 	.pci      = { 0x00000001, gf100_pci_new },
-	.pmu      = { 0x00000001, gf100_pmu_new },
 	.privring = { 0x00000001, gf100_privring_new },
 	.therm    = { 0x00000001, gt215_therm_new },
 	.timer    = { 0x00000001, nv41_timer_new },
@@ -1360,7 +1325,6 @@ nvc0_chipset = {
 	.mspdec   = { 0x00000001, gf100_mspdec_new },
 	.msppp    = { 0x00000001, gf100_msppp_new },
 	.msvld    = { 0x00000001, gf100_msvld_new },
-	.pm       = { 0x00000001, gf100_pm_new },
 	.sw       = { 0x00000001, gf100_sw_new },
 };
 
@@ -1383,7 +1347,6 @@ nvc1_chipset = {
 	.mmu      = { 0x00000001, gf100_mmu_new },
 	.mxm      = { 0x00000001, nv50_mxm_new },
 	.pci      = { 0x00000001, gf106_pci_new },
-	.pmu      = { 0x00000001, gf100_pmu_new },
 	.privring = { 0x00000001, gf100_privring_new },
 	.therm    = { 0x00000001, gt215_therm_new },
 	.timer    = { 0x00000001, nv41_timer_new },
@@ -1396,7 +1359,6 @@ nvc1_chipset = {
 	.mspdec   = { 0x00000001, gf100_mspdec_new },
 	.msppp    = { 0x00000001, gf100_msppp_new },
 	.msvld    = { 0x00000001, gf100_msvld_new },
-	.pm       = { 0x00000001, gf108_pm_new },
 	.sw       = { 0x00000001, gf100_sw_new },
 };
 
@@ -1419,7 +1381,6 @@ nvc3_chipset = {
 	.mmu      = { 0x00000001, gf100_mmu_new },
 	.mxm      = { 0x00000001, nv50_mxm_new },
 	.pci      = { 0x00000001, gf106_pci_new },
-	.pmu      = { 0x00000001, gf100_pmu_new },
 	.privring = { 0x00000001, gf100_privring_new },
 	.therm    = { 0x00000001, gt215_therm_new },
 	.timer    = { 0x00000001, nv41_timer_new },
@@ -1432,7 +1393,6 @@ nvc3_chipset = {
 	.mspdec   = { 0x00000001, gf100_mspdec_new },
 	.msppp    = { 0x00000001, gf100_msppp_new },
 	.msvld    = { 0x00000001, gf100_msvld_new },
-	.pm       = { 0x00000001, gf100_pm_new },
 	.sw       = { 0x00000001, gf100_sw_new },
 };
 
@@ -1455,7 +1415,6 @@ nvc4_chipset = {
 	.mmu      = { 0x00000001, gf100_mmu_new },
 	.mxm      = { 0x00000001, nv50_mxm_new },
 	.pci      = { 0x00000001, gf100_pci_new },
-	.pmu      = { 0x00000001, gf100_pmu_new },
 	.privring = { 0x00000001, gf100_privring_new },
 	.therm    = { 0x00000001, gt215_therm_new },
 	.timer    = { 0x00000001, nv41_timer_new },
@@ -1468,7 +1427,6 @@ nvc4_chipset = {
 	.mspdec   = { 0x00000001, gf100_mspdec_new },
 	.msppp    = { 0x00000001, gf100_msppp_new },
 	.msvld    = { 0x00000001, gf100_msvld_new },
-	.pm       = { 0x00000001, gf100_pm_new },
 	.sw       = { 0x00000001, gf100_sw_new },
 };
 
@@ -1491,7 +1449,6 @@ nvc8_chipset = {
 	.mmu      = { 0x00000001, gf100_mmu_new },
 	.mxm      = { 0x00000001, nv50_mxm_new },
 	.pci      = { 0x00000001, gf100_pci_new },
-	.pmu      = { 0x00000001, gf100_pmu_new },
 	.privring = { 0x00000001, gf100_privring_new },
 	.therm    = { 0x00000001, gt215_therm_new },
 	.timer    = { 0x00000001, nv41_timer_new },
@@ -1504,7 +1461,6 @@ nvc8_chipset = {
 	.mspdec   = { 0x00000001, gf100_mspdec_new },
 	.msppp    = { 0x00000001, gf100_msppp_new },
 	.msvld    = { 0x00000001, gf100_msvld_new },
-	.pm       = { 0x00000001, gf100_pm_new },
 	.sw       = { 0x00000001, gf100_sw_new },
 };
 
@@ -1527,7 +1483,6 @@ nvce_chipset = {
 	.mmu      = { 0x00000001, gf100_mmu_new },
 	.mxm      = { 0x00000001, nv50_mxm_new },
 	.pci      = { 0x00000001, gf100_pci_new },
-	.pmu      = { 0x00000001, gf100_pmu_new },
 	.privring = { 0x00000001, gf100_privring_new },
 	.therm    = { 0x00000001, gt215_therm_new },
 	.timer    = { 0x00000001, nv41_timer_new },
@@ -1540,7 +1495,6 @@ nvce_chipset = {
 	.mspdec   = { 0x00000001, gf100_mspdec_new },
 	.msppp    = { 0x00000001, gf100_msppp_new },
 	.msvld    = { 0x00000001, gf100_msvld_new },
-	.pm       = { 0x00000001, gf100_pm_new },
 	.sw       = { 0x00000001, gf100_sw_new },
 };
 
@@ -1563,7 +1517,6 @@ nvcf_chipset = {
 	.mmu      = { 0x00000001, gf100_mmu_new },
 	.mxm      = { 0x00000001, nv50_mxm_new },
 	.pci      = { 0x00000001, gf106_pci_new },
-	.pmu      = { 0x00000001, gf100_pmu_new },
 	.privring = { 0x00000001, gf100_privring_new },
 	.therm    = { 0x00000001, gt215_therm_new },
 	.timer    = { 0x00000001, nv41_timer_new },
@@ -1576,7 +1529,6 @@ nvcf_chipset = {
 	.mspdec   = { 0x00000001, gf100_mspdec_new },
 	.msppp    = { 0x00000001, gf100_msppp_new },
 	.msvld    = { 0x00000001, gf100_msvld_new },
-	.pm       = { 0x00000001, gf100_pm_new },
 	.sw       = { 0x00000001, gf100_sw_new },
 };
 
@@ -1611,7 +1563,6 @@ nvd7_chipset = {
 	.mspdec   = { 0x00000001, gf100_mspdec_new },
 	.msppp    = { 0x00000001, gf100_msppp_new },
 	.msvld    = { 0x00000001, gf100_msvld_new },
-	.pm       = { 0x00000001, gf117_pm_new },
 	.sw       = { 0x00000001, gf100_sw_new },
 };
 
@@ -1634,7 +1585,6 @@ nvd9_chipset = {
 	.mmu      = { 0x00000001, gf100_mmu_new },
 	.mxm      = { 0x00000001, nv50_mxm_new },
 	.pci      = { 0x00000001, gf106_pci_new },
-	.pmu      = { 0x00000001, gf119_pmu_new },
 	.privring = { 0x00000001, gf117_privring_new },
 	.therm    = { 0x00000001, gf119_therm_new },
 	.timer    = { 0x00000001, nv41_timer_new },
@@ -1647,7 +1597,6 @@ nvd9_chipset = {
 	.mspdec   = { 0x00000001, gf100_mspdec_new },
 	.msppp    = { 0x00000001, gf100_msppp_new },
 	.msvld    = { 0x00000001, gf100_msvld_new },
-	.pm       = { 0x00000001, gf117_pm_new },
 	.sw       = { 0x00000001, gf100_sw_new },
 };
 
@@ -1670,7 +1619,6 @@ nve4_chipset = {
 	.mmu      = { 0x00000001, gk104_mmu_new },
 	.mxm      = { 0x00000001, nv50_mxm_new },
 	.pci      = { 0x00000001, gk104_pci_new },
-	.pmu      = { 0x00000001, gk104_pmu_new },
 	.privring = { 0x00000001, gk104_privring_new },
 	.therm    = { 0x00000001, gk104_therm_new },
 	.timer    = { 0x00000001, nv41_timer_new },
@@ -1684,7 +1632,6 @@ nve4_chipset = {
 	.mspdec   = { 0x00000001, gk104_mspdec_new },
 	.msppp    = { 0x00000001, gf100_msppp_new },
 	.msvld    = { 0x00000001, gk104_msvld_new },
-	.pm       = { 0x00000001, gk104_pm_new },
 	.sw       = { 0x00000001, gf100_sw_new },
 };
 
@@ -1707,7 +1654,6 @@ nve6_chipset = {
 	.mmu      = { 0x00000001, gk104_mmu_new },
 	.mxm      = { 0x00000001, nv50_mxm_new },
 	.pci      = { 0x00000001, gk104_pci_new },
-	.pmu      = { 0x00000001, gk104_pmu_new },
 	.privring = { 0x00000001, gk104_privring_new },
 	.therm    = { 0x00000001, gk104_therm_new },
 	.timer    = { 0x00000001, nv41_timer_new },
@@ -1721,7 +1667,6 @@ nve6_chipset = {
 	.mspdec   = { 0x00000001, gk104_mspdec_new },
 	.msppp    = { 0x00000001, gf100_msppp_new },
 	.msvld    = { 0x00000001, gk104_msvld_new },
-	.pm       = { 0x00000001, gk104_pm_new },
 	.sw       = { 0x00000001, gf100_sw_new },
 };
 
@@ -1744,7 +1689,6 @@ nve7_chipset = {
 	.mmu      = { 0x00000001, gk104_mmu_new },
 	.mxm      = { 0x00000001, nv50_mxm_new },
 	.pci      = { 0x00000001, gk104_pci_new },
-	.pmu      = { 0x00000001, gk104_pmu_new },
 	.privring = { 0x00000001, gk104_privring_new },
 	.therm    = { 0x00000001, gk104_therm_new },
 	.timer    = { 0x00000001, nv41_timer_new },
@@ -1758,7 +1702,6 @@ nve7_chipset = {
 	.mspdec   = { 0x00000001, gk104_mspdec_new },
 	.msppp    = { 0x00000001, gf100_msppp_new },
 	.msvld    = { 0x00000001, gk104_msvld_new },
-	.pm       = { 0x00000001, gk104_pm_new },
 	.sw       = { 0x00000001, gf100_sw_new },
 };
 
@@ -1774,7 +1717,6 @@ nvea_chipset = {
 	.ltc      = { 0x00000001, gk104_ltc_new },
 	.mc       = { 0x00000001, gk20a_mc_new },
 	.mmu      = { 0x00000001, gk20a_mmu_new },
-	.pmu      = { 0x00000001, gk20a_pmu_new },
 	.privring = { 0x00000001, gk20a_privring_new },
 	.timer    = { 0x00000001, gk20a_timer_new },
 	.top      = { 0x00000001, gk104_top_new },
@@ -1783,7 +1725,6 @@ nvea_chipset = {
 	.dma      = { 0x00000001, gf119_dma_new },
 	.fifo     = { 0x00000001, gk20a_fifo_new },
 	.gr       = { 0x00000001, gk20a_gr_new },
-	.pm       = { 0x00000001, gk104_pm_new },
 	.sw       = { 0x00000001, gf100_sw_new },
 };
 
@@ -1806,7 +1747,6 @@ nvf0_chipset = {
 	.mmu      = { 0x00000001, gk104_mmu_new },
 	.mxm      = { 0x00000001, nv50_mxm_new },
 	.pci      = { 0x00000001, gk104_pci_new },
-	.pmu      = { 0x00000001, gk110_pmu_new },
 	.privring = { 0x00000001, gk104_privring_new },
 	.therm    = { 0x00000001, gk104_therm_new },
 	.timer    = { 0x00000001, nv41_timer_new },
@@ -1842,7 +1782,6 @@ nvf1_chipset = {
 	.mmu      = { 0x00000001, gk104_mmu_new },
 	.mxm      = { 0x00000001, nv50_mxm_new },
 	.pci      = { 0x00000001, gk104_pci_new },
-	.pmu      = { 0x00000001, gk110_pmu_new },
 	.privring = { 0x00000001, gk104_privring_new },
 	.therm    = { 0x00000001, gk104_therm_new },
 	.timer    = { 0x00000001, nv41_timer_new },
@@ -1878,7 +1817,6 @@ nv106_chipset = {
 	.mmu      = { 0x00000001, gk104_mmu_new },
 	.mxm      = { 0x00000001, nv50_mxm_new },
 	.pci      = { 0x00000001, gk104_pci_new },
-	.pmu      = { 0x00000001, gk208_pmu_new },
 	.privring = { 0x00000001, gk104_privring_new },
 	.therm    = { 0x00000001, gk104_therm_new },
 	.timer    = { 0x00000001, nv41_timer_new },
@@ -1914,7 +1852,6 @@ nv108_chipset = {
 	.mmu      = { 0x00000001, gk104_mmu_new },
 	.mxm      = { 0x00000001, nv50_mxm_new },
 	.pci      = { 0x00000001, gk104_pci_new },
-	.pmu      = { 0x00000001, gk208_pmu_new },
 	.privring = { 0x00000001, gk104_privring_new },
 	.therm    = { 0x00000001, gk104_therm_new },
 	.timer    = { 0x00000001, nv41_timer_new },
@@ -1950,7 +1887,6 @@ nv117_chipset = {
 	.mmu      = { 0x00000001, gk104_mmu_new },
 	.mxm      = { 0x00000001, nv50_mxm_new },
 	.pci      = { 0x00000001, gk104_pci_new },
-	.pmu      = { 0x00000001, gm107_pmu_new },
 	.privring = { 0x00000001, gk104_privring_new },
 	.therm    = { 0x00000001, gm107_therm_new },
 	.timer    = { 0x00000001, gk20a_timer_new },
@@ -1985,7 +1921,6 @@ nv118_chipset = {
 	.mmu      = { 0x00000001, gk104_mmu_new },
 	.mxm      = { 0x00000001, nv50_mxm_new },
 	.pci      = { 0x00000001, gk104_pci_new },
-	.pmu      = { 0x00000001, gm107_pmu_new },
 	.privring = { 0x00000001, gk104_privring_new },
 	.therm    = { 0x00000001, gm107_therm_new },
 	.timer    = { 0x00000001, gk20a_timer_new },
@@ -2018,7 +1953,6 @@ nv120_chipset = {
 	.mmu      = { 0x00000001, gm200_mmu_new },
 	.mxm      = { 0x00000001, nv50_mxm_new },
 	.pci      = { 0x00000001, gk104_pci_new },
-	.pmu      = { 0x00000001, gm200_pmu_new },
 	.privring = { 0x00000001, gm200_privring_new },
 	.therm    = { 0x00000001, gm200_therm_new },
 	.timer    = { 0x00000001, gk20a_timer_new },
@@ -2053,7 +1987,6 @@ nv124_chipset = {
 	.mmu      = { 0x00000001, gm200_mmu_new },
 	.mxm      = { 0x00000001, nv50_mxm_new },
 	.pci      = { 0x00000001, gk104_pci_new },
-	.pmu      = { 0x00000001, gm200_pmu_new },
 	.privring = { 0x00000001, gm200_privring_new },
 	.therm    = { 0x00000001, gm200_therm_new },
 	.timer    = { 0x00000001, gk20a_timer_new },
@@ -2088,7 +2021,6 @@ nv126_chipset = {
 	.mmu      = { 0x00000001, gm200_mmu_new },
 	.mxm      = { 0x00000001, nv50_mxm_new },
 	.pci      = { 0x00000001, gk104_pci_new },
-	.pmu      = { 0x00000001, gm200_pmu_new },
 	.privring = { 0x00000001, gm200_privring_new },
 	.therm    = { 0x00000001, gm200_therm_new },
 	.timer    = { 0x00000001, gk20a_timer_new },
@@ -2117,7 +2049,6 @@ nv12b_chipset = {
 	.ltc      = { 0x00000001, gm200_ltc_new },
 	.mc       = { 0x00000001, gk20a_mc_new },
 	.mmu      = { 0x00000001, gm20b_mmu_new },
-	.pmu      = { 0x00000001, gm20b_pmu_new },
 	.privring = { 0x00000001, gk20a_privring_new },
 	.timer    = { 0x00000001, gk20a_timer_new },
 	.top      = { 0x00000001, gk104_top_new },
@@ -2148,7 +2079,6 @@ nv130_chipset = {
 	.mmu      = { 0x00000001, gp100_mmu_new },
 	.therm    = { 0x00000001, gp100_therm_new },
 	.pci      = { 0x00000001, gp100_pci_new },
-	.pmu      = { 0x00000001, gm200_pmu_new },
 	.privring = { 0x00000001, gm200_privring_new },
 	.timer    = { 0x00000001, gk20a_timer_new },
 	.top      = { 0x00000001, gk104_top_new },
@@ -2181,7 +2111,6 @@ nv132_chipset = {
 	.mmu      = { 0x00000001, gp100_mmu_new },
 	.therm    = { 0x00000001, gp100_therm_new },
 	.pci      = { 0x00000001, gp100_pci_new },
-	.pmu      = { 0x00000001, gp102_pmu_new },
 	.privring = { 0x00000001, gm200_privring_new },
 	.timer    = { 0x00000001, gk20a_timer_new },
 	.top      = { 0x00000001, gk104_top_new },
@@ -2215,7 +2144,6 @@ nv134_chipset = {
 	.mmu      = { 0x00000001, gp100_mmu_new },
 	.therm    = { 0x00000001, gp100_therm_new },
 	.pci      = { 0x00000001, gp100_pci_new },
-	.pmu      = { 0x00000001, gp102_pmu_new },
 	.privring = { 0x00000001, gm200_privring_new },
 	.timer    = { 0x00000001, gk20a_timer_new },
 	.top      = { 0x00000001, gk104_top_new },
@@ -2249,7 +2177,6 @@ nv136_chipset = {
 	.mmu      = { 0x00000001, gp100_mmu_new },
 	.therm    = { 0x00000001, gp100_therm_new },
 	.pci      = { 0x00000001, gp100_pci_new },
-	.pmu      = { 0x00000001, gp102_pmu_new },
 	.privring = { 0x00000001, gm200_privring_new },
 	.timer    = { 0x00000001, gk20a_timer_new },
 	.top      = { 0x00000001, gk104_top_new },
@@ -2283,7 +2210,6 @@ nv137_chipset = {
 	.mmu      = { 0x00000001, gp100_mmu_new },
 	.therm    = { 0x00000001, gp100_therm_new },
 	.pci      = { 0x00000001, gp100_pci_new },
-	.pmu      = { 0x00000001, gp102_pmu_new },
 	.privring = { 0x00000001, gm200_privring_new },
 	.timer    = { 0x00000001, gk20a_timer_new },
 	.top      = { 0x00000001, gk104_top_new },
@@ -2317,7 +2243,6 @@ nv138_chipset = {
 	.mmu      = { 0x00000001, gp100_mmu_new },
 	.therm    = { 0x00000001, gp100_therm_new },
 	.pci      = { 0x00000001, gp100_pci_new },
-	.pmu      = { 0x00000001, gp102_pmu_new },
 	.privring = { 0x00000001, gm200_privring_new },
 	.timer    = { 0x00000001, gk20a_timer_new },
 	.top      = { 0x00000001, gk104_top_new },
@@ -2344,7 +2269,6 @@ nv13b_chipset = {
 	.ltc      = { 0x00000001, gp10b_ltc_new },
 	.mc       = { 0x00000001, gp10b_mc_new },
 	.mmu      = { 0x00000001, gp10b_mmu_new },
-	.pmu      = { 0x00000001, gp10b_pmu_new },
 	.privring = { 0x00000001, gp10b_privring_new },
 	.timer    = { 0x00000001, gk20a_timer_new },
 	.top      = { 0x00000001, gk104_top_new },
@@ -2374,7 +2298,6 @@ nv140_chipset = {
 	.mc       = { 0x00000001, gp100_mc_new },
 	.mmu      = { 0x00000001, gv100_mmu_new },
 	.pci      = { 0x00000001, gp100_pci_new },
-	.pmu      = { 0x00000001, gp102_pmu_new },
 	.privring = { 0x00000001, gm200_privring_new },
 	.therm    = { 0x00000001, gp100_therm_new },
 	.timer    = { 0x00000001, gk20a_timer_new },
@@ -2409,7 +2332,6 @@ nv162_chipset = {
 	.mc       = { 0x00000001, gp100_mc_new },
 	.mmu      = { 0x00000001, tu102_mmu_new },
 	.pci      = { 0x00000001, gp100_pci_new },
-	.pmu      = { 0x00000001, gp102_pmu_new },
 	.privring = { 0x00000001, gm200_privring_new },
 	.therm    = { 0x00000001, gp100_therm_new },
 	.timer    = { 0x00000001, gk20a_timer_new },
@@ -2444,7 +2366,6 @@ nv164_chipset = {
 	.mc       = { 0x00000001, gp100_mc_new },
 	.mmu      = { 0x00000001, tu102_mmu_new },
 	.pci      = { 0x00000001, gp100_pci_new },
-	.pmu      = { 0x00000001, gp102_pmu_new },
 	.privring = { 0x00000001, gm200_privring_new },
 	.therm    = { 0x00000001, gp100_therm_new },
 	.timer    = { 0x00000001, gk20a_timer_new },
@@ -2479,7 +2400,6 @@ nv166_chipset = {
 	.mc       = { 0x00000001, gp100_mc_new },
 	.mmu      = { 0x00000001, tu102_mmu_new },
 	.pci      = { 0x00000001, gp100_pci_new },
-	.pmu      = { 0x00000001, gp102_pmu_new },
 	.privring = { 0x00000001, gm200_privring_new },
 	.therm    = { 0x00000001, gp100_therm_new },
 	.timer    = { 0x00000001, gk20a_timer_new },
@@ -2514,7 +2434,6 @@ nv167_chipset = {
 	.mc       = { 0x00000001, gp100_mc_new },
 	.mmu      = { 0x00000001, tu102_mmu_new },
 	.pci      = { 0x00000001, gp100_pci_new },
-	.pmu      = { 0x00000001, gp102_pmu_new },
 	.privring = { 0x00000001, gm200_privring_new },
 	.therm    = { 0x00000001, gp100_therm_new },
 	.timer    = { 0x00000001, gk20a_timer_new },
@@ -2549,7 +2468,6 @@ nv168_chipset = {
 	.mc       = { 0x00000001, gp100_mc_new },
 	.mmu      = { 0x00000001, tu102_mmu_new },
 	.pci      = { 0x00000001, gp100_pci_new },
-	.pmu      = { 0x00000001, gp102_pmu_new },
 	.privring = { 0x00000001, gm200_privring_new },
 	.therm    = { 0x00000001, gp100_therm_new },
 	.timer    = { 0x00000001, gk20a_timer_new },
diff --git a/drivers/gpu/drm/nouveau/nvkm/device/priv.h b/drivers/gpu/drm/nouveau/nvkm/device/priv.h
index c182d9c3e4fa..e42b18820a95 100644
--- a/drivers/gpu/drm/nouveau/nvkm/device/priv.h
+++ b/drivers/gpu/drm/nouveau/nvkm/device/priv.h
@@ -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>
diff --git a/drivers/gpu/drm/nouveau/nvkm/device/user.c b/drivers/gpu/drm/nouveau/nvkm/device/user.c
index 7fd4800a876a..d937c54e8dfa 100644
--- a/drivers/gpu/drm/nouveau/nvkm/device/user.c
+++ b/drivers/gpu/drm/nouveau/nvkm/device/user.c
@@ -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;
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/Kbuild b/drivers/gpu/drm/nouveau/nvkm/engine/Kbuild
index f9eb68a25de8..565715db662e 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/Kbuild
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/Kbuild
@@ -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
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/pm/Kbuild b/drivers/gpu/drm/nouveau/nvkm/engine/pm/Kbuild
deleted file mode 100644
index 2cc8a5f6fe0c..000000000000
--- a/drivers/gpu/drm/nouveau/nvkm/engine/pm/Kbuild
+++ /dev/null
@@ -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
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/pm/base.c b/drivers/gpu/drm/nouveau/nvkm/engine/pm/base.c
deleted file mode 100644
index 131db2645f84..000000000000
--- a/drivers/gpu/drm/nouveau/nvkm/engine/pm/base.c
+++ /dev/null
@@ -1,867 +0,0 @@
-/*
- * Copyright 2013 Red Hat Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors: Ben Skeggs
- */
-#include "priv.h"
-
-#include <core/client.h>
-#include <core/option.h>
-
-#include <nvif/class.h>
-#include <nvif/if0002.h>
-#include <nvif/if0003.h>
-#include <nvif/ioctl.h>
-#include <nvif/unpack.h>
-
-static u8
-nvkm_pm_count_perfdom(struct nvkm_pm *pm)
-{
-	struct nvkm_perfdom *dom;
-	u8 domain_nr = 0;
-
-	list_for_each_entry(dom, &pm->domains, head)
-		domain_nr++;
-	return domain_nr;
-}
-
-static u16
-nvkm_perfdom_count_perfsig(struct nvkm_perfdom *dom)
-{
-	u16 signal_nr = 0;
-	int i;
-
-	if (dom) {
-		for (i = 0; i < dom->signal_nr; i++) {
-			if (dom->signal[i].name)
-				signal_nr++;
-		}
-	}
-	return signal_nr;
-}
-
-static struct nvkm_perfdom *
-nvkm_perfdom_find(struct nvkm_pm *pm, int di)
-{
-	struct nvkm_perfdom *dom;
-	int tmp = 0;
-
-	list_for_each_entry(dom, &pm->domains, head) {
-		if (tmp++ == di)
-			return dom;
-	}
-	return NULL;
-}
-
-static struct nvkm_perfsig *
-nvkm_perfsig_find(struct nvkm_pm *pm, u8 di, u8 si, struct nvkm_perfdom **pdom)
-{
-	struct nvkm_perfdom *dom = *pdom;
-
-	if (dom == NULL) {
-		dom = nvkm_perfdom_find(pm, di);
-		if (dom == NULL)
-			return NULL;
-		*pdom = dom;
-	}
-
-	if (!dom->signal[si].name)
-		return NULL;
-	return &dom->signal[si];
-}
-
-static u8
-nvkm_perfsig_count_perfsrc(struct nvkm_perfsig *sig)
-{
-	u8 source_nr = 0, i;
-
-	for (i = 0; i < ARRAY_SIZE(sig->source); i++) {
-		if (sig->source[i])
-			source_nr++;
-	}
-	return source_nr;
-}
-
-static struct nvkm_perfsrc *
-nvkm_perfsrc_find(struct nvkm_pm *pm, struct nvkm_perfsig *sig, int si)
-{
-	struct nvkm_perfsrc *src;
-	bool found = false;
-	int tmp = 1; /* Sources ID start from 1 */
-	u8 i;
-
-	for (i = 0; i < ARRAY_SIZE(sig->source) && sig->source[i]; i++) {
-		if (sig->source[i] == si) {
-			found = true;
-			break;
-		}
-	}
-
-	if (found) {
-		list_for_each_entry(src, &pm->sources, head) {
-			if (tmp++ == si)
-				return src;
-		}
-	}
-
-	return NULL;
-}
-
-static int
-nvkm_perfsrc_enable(struct nvkm_pm *pm, struct nvkm_perfctr *ctr)
-{
-	struct nvkm_subdev *subdev = &pm->engine.subdev;
-	struct nvkm_device *device = subdev->device;
-	struct nvkm_perfdom *dom = NULL;
-	struct nvkm_perfsig *sig;
-	struct nvkm_perfsrc *src;
-	u32 mask, value;
-	int i, j;
-
-	for (i = 0; i < 4; i++) {
-		for (j = 0; j < 8 && ctr->source[i][j]; j++) {
-			sig = nvkm_perfsig_find(pm, ctr->domain,
-						ctr->signal[i], &dom);
-			if (!sig)
-				return -EINVAL;
-
-			src = nvkm_perfsrc_find(pm, sig, ctr->source[i][j]);
-			if (!src)
-				return -EINVAL;
-
-			/* set enable bit if needed */
-			mask = value = 0x00000000;
-			if (src->enable)
-				mask = value = 0x80000000;
-			mask  |= (src->mask << src->shift);
-			value |= ((ctr->source[i][j] >> 32) << src->shift);
-
-			/* enable the source */
-			nvkm_mask(device, src->addr, mask, value);
-			nvkm_debug(subdev,
-				   "enabled source %08x %08x %08x\n",
-				   src->addr, mask, value);
-		}
-	}
-	return 0;
-}
-
-static int
-nvkm_perfsrc_disable(struct nvkm_pm *pm, struct nvkm_perfctr *ctr)
-{
-	struct nvkm_subdev *subdev = &pm->engine.subdev;
-	struct nvkm_device *device = subdev->device;
-	struct nvkm_perfdom *dom = NULL;
-	struct nvkm_perfsig *sig;
-	struct nvkm_perfsrc *src;
-	u32 mask;
-	int i, j;
-
-	for (i = 0; i < 4; i++) {
-		for (j = 0; j < 8 && ctr->source[i][j]; j++) {
-			sig = nvkm_perfsig_find(pm, ctr->domain,
-						ctr->signal[i], &dom);
-			if (!sig)
-				return -EINVAL;
-
-			src = nvkm_perfsrc_find(pm, sig, ctr->source[i][j]);
-			if (!src)
-				return -EINVAL;
-
-			/* unset enable bit if needed */
-			mask = 0x00000000;
-			if (src->enable)
-				mask = 0x80000000;
-			mask |= (src->mask << src->shift);
-
-			/* disable the source */
-			nvkm_mask(device, src->addr, mask, 0);
-			nvkm_debug(subdev, "disabled source %08x %08x\n",
-				   src->addr, mask);
-		}
-	}
-	return 0;
-}
-
-/*******************************************************************************
- * Perfdom object classes
- ******************************************************************************/
-static int
-nvkm_perfdom_init(struct nvkm_perfdom *dom, void *data, u32 size)
-{
-	union {
-		struct nvif_perfdom_init none;
-	} *args = data;
-	struct nvkm_object *object = &dom->object;
-	struct nvkm_pm *pm = dom->perfmon->pm;
-	int ret = -ENOSYS, i;
-
-	nvif_ioctl(object, "perfdom init size %d\n", size);
-	if (!(ret = nvif_unvers(ret, &data, &size, args->none))) {
-		nvif_ioctl(object, "perfdom init\n");
-	} else
-		return ret;
-
-	for (i = 0; i < 4; i++) {
-		if (dom->ctr[i]) {
-			dom->func->init(pm, dom, dom->ctr[i]);
-
-			/* enable sources */
-			nvkm_perfsrc_enable(pm, dom->ctr[i]);
-		}
-	}
-
-	/* start next batch of counters for sampling */
-	dom->func->next(pm, dom);
-	return 0;
-}
-
-static int
-nvkm_perfdom_sample(struct nvkm_perfdom *dom, void *data, u32 size)
-{
-	union {
-		struct nvif_perfdom_sample none;
-	} *args = data;
-	struct nvkm_object *object = &dom->object;
-	struct nvkm_pm *pm = dom->perfmon->pm;
-	int ret = -ENOSYS;
-
-	nvif_ioctl(object, "perfdom sample size %d\n", size);
-	if (!(ret = nvif_unvers(ret, &data, &size, args->none))) {
-		nvif_ioctl(object, "perfdom sample\n");
-	} else
-		return ret;
-	pm->sequence++;
-
-	/* sample previous batch of counters */
-	list_for_each_entry(dom, &pm->domains, head)
-		dom->func->next(pm, dom);
-
-	return 0;
-}
-
-static int
-nvkm_perfdom_read(struct nvkm_perfdom *dom, void *data, u32 size)
-{
-	union {
-		struct nvif_perfdom_read_v0 v0;
-	} *args = data;
-	struct nvkm_object *object = &dom->object;
-	struct nvkm_pm *pm = dom->perfmon->pm;
-	int ret = -ENOSYS, i;
-
-	nvif_ioctl(object, "perfdom read size %d\n", size);
-	if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
-		nvif_ioctl(object, "perfdom read vers %d\n", args->v0.version);
-	} else
-		return ret;
-
-	for (i = 0; i < 4; i++) {
-		if (dom->ctr[i])
-			dom->func->read(pm, dom, dom->ctr[i]);
-	}
-
-	if (!dom->clk)
-		return -EAGAIN;
-
-	for (i = 0; i < 4; i++)
-		if (dom->ctr[i])
-			args->v0.ctr[i] = dom->ctr[i]->ctr;
-	args->v0.clk = dom->clk;
-	return 0;
-}
-
-static int
-nvkm_perfdom_mthd(struct nvkm_object *object, u32 mthd, void *data, u32 size)
-{
-	struct nvkm_perfdom *dom = nvkm_perfdom(object);
-	switch (mthd) {
-	case NVIF_PERFDOM_V0_INIT:
-		return nvkm_perfdom_init(dom, data, size);
-	case NVIF_PERFDOM_V0_SAMPLE:
-		return nvkm_perfdom_sample(dom, data, size);
-	case NVIF_PERFDOM_V0_READ:
-		return nvkm_perfdom_read(dom, data, size);
-	default:
-		break;
-	}
-	return -EINVAL;
-}
-
-static void *
-nvkm_perfdom_dtor(struct nvkm_object *object)
-{
-	struct nvkm_perfdom *dom = nvkm_perfdom(object);
-	struct nvkm_pm *pm = dom->perfmon->pm;
-	int i;
-
-	for (i = 0; i < 4; i++) {
-		struct nvkm_perfctr *ctr = dom->ctr[i];
-		if (ctr) {
-			nvkm_perfsrc_disable(pm, ctr);
-			if (ctr->head.next)
-				list_del(&ctr->head);
-		}
-		kfree(ctr);
-	}
-
-	return dom;
-}
-
-static int
-nvkm_perfctr_new(struct nvkm_perfdom *dom, int slot, u8 domain,
-		 struct nvkm_perfsig *signal[4], u64 source[4][8],
-		 u16 logic_op, struct nvkm_perfctr **pctr)
-{
-	struct nvkm_perfctr *ctr;
-	int i, j;
-
-	if (!dom)
-		return -EINVAL;
-
-	ctr = *pctr = kzalloc(sizeof(*ctr), GFP_KERNEL);
-	if (!ctr)
-		return -ENOMEM;
-
-	ctr->domain   = domain;
-	ctr->logic_op = logic_op;
-	ctr->slot     = slot;
-	for (i = 0; i < 4; i++) {
-		if (signal[i]) {
-			ctr->signal[i] = signal[i] - dom->signal;
-			for (j = 0; j < 8; j++)
-				ctr->source[i][j] = source[i][j];
-		}
-	}
-	list_add_tail(&ctr->head, &dom->list);
-
-	return 0;
-}
-
-static const struct nvkm_object_func
-nvkm_perfdom = {
-	.dtor = nvkm_perfdom_dtor,
-	.mthd = nvkm_perfdom_mthd,
-};
-
-static int
-nvkm_perfdom_new_(struct nvkm_perfmon *perfmon,
-		  const struct nvkm_oclass *oclass, void *data, u32 size,
-		  struct nvkm_object **pobject)
-{
-	union {
-		struct nvif_perfdom_v0 v0;
-	} *args = data;
-	struct nvkm_pm *pm = perfmon->pm;
-	struct nvkm_object *parent = oclass->parent;
-	struct nvkm_perfdom *sdom = NULL;
-	struct nvkm_perfctr *ctr[4] = {};
-	struct nvkm_perfdom *dom;
-	int c, s, m;
-	int ret = -ENOSYS;
-
-	nvif_ioctl(parent, "create perfdom size %d\n", size);
-	if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
-		nvif_ioctl(parent, "create perfdom vers %d dom %d mode %02x\n",
-			   args->v0.version, args->v0.domain, args->v0.mode);
-	} else
-		return ret;
-
-	for (c = 0; c < ARRAY_SIZE(args->v0.ctr); c++) {
-		struct nvkm_perfsig *sig[4] = {};
-		u64 src[4][8] = {};
-
-		for (s = 0; s < ARRAY_SIZE(args->v0.ctr[c].signal); s++) {
-			sig[s] = nvkm_perfsig_find(pm, args->v0.domain,
-						   args->v0.ctr[c].signal[s],
-						   &sdom);
-			if (args->v0.ctr[c].signal[s] && !sig[s])
-				return -EINVAL;
-
-			for (m = 0; m < 8; m++) {
-				src[s][m] = args->v0.ctr[c].source[s][m];
-				if (src[s][m] && !nvkm_perfsrc_find(pm, sig[s],
-							            src[s][m]))
-					return -EINVAL;
-			}
-		}
-
-		ret = nvkm_perfctr_new(sdom, c, args->v0.domain, sig, src,
-				       args->v0.ctr[c].logic_op, &ctr[c]);
-		if (ret)
-			return ret;
-	}
-
-	if (!sdom)
-		return -EINVAL;
-
-	if (!(dom = kzalloc(sizeof(*dom), GFP_KERNEL)))
-		return -ENOMEM;
-	nvkm_object_ctor(&nvkm_perfdom, oclass, &dom->object);
-	dom->perfmon = perfmon;
-	*pobject = &dom->object;
-
-	dom->func = sdom->func;
-	dom->addr = sdom->addr;
-	dom->mode = args->v0.mode;
-	for (c = 0; c < ARRAY_SIZE(ctr); c++)
-		dom->ctr[c] = ctr[c];
-	return 0;
-}
-
-/*******************************************************************************
- * Perfmon object classes
- ******************************************************************************/
-static int
-nvkm_perfmon_mthd_query_domain(struct nvkm_perfmon *perfmon,
-			       void *data, u32 size)
-{
-	union {
-		struct nvif_perfmon_query_domain_v0 v0;
-	} *args = data;
-	struct nvkm_object *object = &perfmon->object;
-	struct nvkm_pm *pm = perfmon->pm;
-	struct nvkm_perfdom *dom;
-	u8 domain_nr;
-	int di, ret = -ENOSYS;
-
-	nvif_ioctl(object, "perfmon query domain size %d\n", size);
-	if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
-		nvif_ioctl(object, "perfmon domain vers %d iter %02x\n",
-			   args->v0.version, args->v0.iter);
-		di = (args->v0.iter & 0xff) - 1;
-	} else
-		return ret;
-
-	domain_nr = nvkm_pm_count_perfdom(pm);
-	if (di >= (int)domain_nr)
-		return -EINVAL;
-
-	if (di >= 0) {
-		dom = nvkm_perfdom_find(pm, di);
-		if (dom == NULL)
-			return -EINVAL;
-
-		args->v0.id         = di;
-		args->v0.signal_nr  = nvkm_perfdom_count_perfsig(dom);
-		strscpy(args->v0.name, dom->name, sizeof(args->v0.name));
-
-		/* Currently only global counters (PCOUNTER) are implemented
-		 * but this will be different for local counters (MP). */
-		args->v0.counter_nr = 4;
-	}
-
-	if (++di < domain_nr) {
-		args->v0.iter = ++di;
-		return 0;
-	}
-
-	args->v0.iter = 0xff;
-	return 0;
-}
-
-static int
-nvkm_perfmon_mthd_query_signal(struct nvkm_perfmon *perfmon,
-			       void *data, u32 size)
-{
-	union {
-		struct nvif_perfmon_query_signal_v0 v0;
-	} *args = data;
-	struct nvkm_object *object = &perfmon->object;
-	struct nvkm_pm *pm = perfmon->pm;
-	struct nvkm_device *device = pm->engine.subdev.device;
-	struct nvkm_perfdom *dom;
-	struct nvkm_perfsig *sig;
-	const bool all = nvkm_boolopt(device->cfgopt, "NvPmShowAll", false);
-	const bool raw = nvkm_boolopt(device->cfgopt, "NvPmUnnamed", all);
-	int ret = -ENOSYS, si;
-
-	nvif_ioctl(object, "perfmon query signal size %d\n", size);
-	if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
-		nvif_ioctl(object,
-			   "perfmon query signal vers %d dom %d iter %04x\n",
-			   args->v0.version, args->v0.domain, args->v0.iter);
-		si = (args->v0.iter & 0xffff) - 1;
-	} else
-		return ret;
-
-	dom = nvkm_perfdom_find(pm, args->v0.domain);
-	if (dom == NULL || si >= (int)dom->signal_nr)
-		return -EINVAL;
-
-	if (si >= 0) {
-		sig = &dom->signal[si];
-		if (raw || !sig->name) {
-			snprintf(args->v0.name, sizeof(args->v0.name),
-				 "/%s/%02x", dom->name, si);
-		} else {
-			strscpy(args->v0.name, sig->name, sizeof(args->v0.name));
-		}
-
-		args->v0.signal = si;
-		args->v0.source_nr = nvkm_perfsig_count_perfsrc(sig);
-	}
-
-	while (++si < dom->signal_nr) {
-		if (all || dom->signal[si].name) {
-			args->v0.iter = ++si;
-			return 0;
-		}
-	}
-
-	args->v0.iter = 0xffff;
-	return 0;
-}
-
-static int
-nvkm_perfmon_mthd_query_source(struct nvkm_perfmon *perfmon,
-			       void *data, u32 size)
-{
-	union {
-		struct nvif_perfmon_query_source_v0 v0;
-	} *args = data;
-	struct nvkm_object *object = &perfmon->object;
-	struct nvkm_pm *pm = perfmon->pm;
-	struct nvkm_perfdom *dom = NULL;
-	struct nvkm_perfsig *sig;
-	struct nvkm_perfsrc *src;
-	u8 source_nr = 0;
-	int si, ret = -ENOSYS;
-
-	nvif_ioctl(object, "perfmon query source size %d\n", size);
-	if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
-		nvif_ioctl(object,
-			   "perfmon source vers %d dom %d sig %02x iter %02x\n",
-			   args->v0.version, args->v0.domain, args->v0.signal,
-			   args->v0.iter);
-		si = (args->v0.iter & 0xff) - 1;
-	} else
-		return ret;
-
-	sig = nvkm_perfsig_find(pm, args->v0.domain, args->v0.signal, &dom);
-	if (!sig)
-		return -EINVAL;
-
-	source_nr = nvkm_perfsig_count_perfsrc(sig);
-	if (si >= (int)source_nr)
-		return -EINVAL;
-
-	if (si >= 0) {
-		src = nvkm_perfsrc_find(pm, sig, sig->source[si]);
-		if (!src)
-			return -EINVAL;
-
-		args->v0.source = sig->source[si];
-		args->v0.mask   = src->mask;
-		strscpy(args->v0.name, src->name, sizeof(args->v0.name));
-	}
-
-	if (++si < source_nr) {
-		args->v0.iter = ++si;
-		return 0;
-	}
-
-	args->v0.iter = 0xff;
-	return 0;
-}
-
-static int
-nvkm_perfmon_mthd(struct nvkm_object *object, u32 mthd, void *data, u32 size)
-{
-	struct nvkm_perfmon *perfmon = nvkm_perfmon(object);
-	switch (mthd) {
-	case NVIF_PERFMON_V0_QUERY_DOMAIN:
-		return nvkm_perfmon_mthd_query_domain(perfmon, data, size);
-	case NVIF_PERFMON_V0_QUERY_SIGNAL:
-		return nvkm_perfmon_mthd_query_signal(perfmon, data, size);
-	case NVIF_PERFMON_V0_QUERY_SOURCE:
-		return nvkm_perfmon_mthd_query_source(perfmon, data, size);
-	default:
-		break;
-	}
-	return -EINVAL;
-}
-
-static int
-nvkm_perfmon_child_new(const struct nvkm_oclass *oclass, void *data, u32 size,
-		       struct nvkm_object **pobject)
-{
-	struct nvkm_perfmon *perfmon = nvkm_perfmon(oclass->parent);
-	return nvkm_perfdom_new_(perfmon, oclass, data, size, pobject);
-}
-
-static int
-nvkm_perfmon_child_get(struct nvkm_object *object, int index,
-		       struct nvkm_oclass *oclass)
-{
-	if (index == 0) {
-		oclass->base.oclass = NVIF_CLASS_PERFDOM;
-		oclass->base.minver = 0;
-		oclass->base.maxver = 0;
-		oclass->ctor = nvkm_perfmon_child_new;
-		return 0;
-	}
-	return -EINVAL;
-}
-
-static void *
-nvkm_perfmon_dtor(struct nvkm_object *object)
-{
-	struct nvkm_perfmon *perfmon = nvkm_perfmon(object);
-	struct nvkm_pm *pm = perfmon->pm;
-	spin_lock(&pm->client.lock);
-	if (pm->client.object == &perfmon->object)
-		pm->client.object = NULL;
-	spin_unlock(&pm->client.lock);
-	return perfmon;
-}
-
-static const struct nvkm_object_func
-nvkm_perfmon = {
-	.dtor = nvkm_perfmon_dtor,
-	.mthd = nvkm_perfmon_mthd,
-	.sclass = nvkm_perfmon_child_get,
-};
-
-static int
-nvkm_perfmon_new(struct nvkm_pm *pm, const struct nvkm_oclass *oclass,
-		 void *data, u32 size, struct nvkm_object **pobject)
-{
-	struct nvkm_perfmon *perfmon;
-
-	if (!(perfmon = kzalloc(sizeof(*perfmon), GFP_KERNEL)))
-		return -ENOMEM;
-	nvkm_object_ctor(&nvkm_perfmon, oclass, &perfmon->object);
-	perfmon->pm = pm;
-	*pobject = &perfmon->object;
-	return 0;
-}
-
-/*******************************************************************************
- * PPM engine/subdev functions
- ******************************************************************************/
-
-static int
-nvkm_pm_oclass_new(struct nvkm_device *device, const struct nvkm_oclass *oclass,
-		   void *data, u32 size, struct nvkm_object **pobject)
-{
-	struct nvkm_pm *pm = nvkm_pm(oclass->engine);
-	int ret;
-
-	ret = nvkm_perfmon_new(pm, oclass, data, size, pobject);
-	if (ret)
-		return ret;
-
-	spin_lock(&pm->client.lock);
-	if (pm->client.object == NULL)
-		pm->client.object = *pobject;
-	ret = (pm->client.object == *pobject) ? 0 : -EBUSY;
-	spin_unlock(&pm->client.lock);
-	return ret;
-}
-
-static const struct nvkm_device_oclass
-nvkm_pm_oclass = {
-	.base.oclass = NVIF_CLASS_PERFMON,
-	.base.minver = -1,
-	.base.maxver = -1,
-	.ctor = nvkm_pm_oclass_new,
-};
-
-static int
-nvkm_pm_oclass_get(struct nvkm_oclass *oclass, int index,
-		   const struct nvkm_device_oclass **class)
-{
-	if (index == 0) {
-		oclass->base = nvkm_pm_oclass.base;
-		*class = &nvkm_pm_oclass;
-		return index;
-	}
-	return 1;
-}
-
-static int
-nvkm_perfsrc_new(struct nvkm_pm *pm, struct nvkm_perfsig *sig,
-		 const struct nvkm_specsrc *spec)
-{
-	const struct nvkm_specsrc *ssrc;
-	const struct nvkm_specmux *smux;
-	struct nvkm_perfsrc *src;
-	u8 source_nr = 0;
-
-	if (!spec) {
-		/* No sources are defined for this signal. */
-		return 0;
-	}
-
-	ssrc = spec;
-	while (ssrc->name) {
-		smux = ssrc->mux;
-		while (smux->name) {
-			bool found = false;
-			u8 source_id = 0;
-			u32 len;
-
-			list_for_each_entry(src, &pm->sources, head) {
-				if (src->addr == ssrc->addr &&
-				    src->shift == smux->shift) {
-					found = true;
-					break;
-				}
-				source_id++;
-			}
-
-			if (!found) {
-				src = kzalloc(sizeof(*src), GFP_KERNEL);
-				if (!src)
-					return -ENOMEM;
-
-				src->addr   = ssrc->addr;
-				src->mask   = smux->mask;
-				src->shift  = smux->shift;
-				src->enable = smux->enable;
-
-				len = strlen(ssrc->name) +
-				      strlen(smux->name) + 2;
-				src->name = kzalloc(len, GFP_KERNEL);
-				if (!src->name) {
-					kfree(src);
-					return -ENOMEM;
-				}
-				snprintf(src->name, len, "%s_%s", ssrc->name,
-					 smux->name);
-
-				list_add_tail(&src->head, &pm->sources);
-			}
-
-			sig->source[source_nr++] = source_id + 1;
-			smux++;
-		}
-		ssrc++;
-	}
-
-	return 0;
-}
-
-int
-nvkm_perfdom_new(struct nvkm_pm *pm, const char *name, u32 mask,
-		 u32 base, u32 size_unit, u32 size_domain,
-		 const struct nvkm_specdom *spec)
-{
-	const struct nvkm_specdom *sdom;
-	const struct nvkm_specsig *ssig;
-	struct nvkm_perfdom *dom;
-	int ret, i;
-
-	for (i = 0; i == 0 || mask; i++) {
-		u32 addr = base + (i * size_unit);
-		if (i && !(mask & (1 << i)))
-			continue;
-
-		sdom = spec;
-		while (sdom->signal_nr) {
-			dom = kzalloc(struct_size(dom, signal, sdom->signal_nr),
-				      GFP_KERNEL);
-			if (!dom)
-				return -ENOMEM;
-
-			if (mask) {
-				snprintf(dom->name, sizeof(dom->name),
-					 "%s/%02x/%02x", name, i,
-					 (int)(sdom - spec));
-			} else {
-				snprintf(dom->name, sizeof(dom->name),
-					 "%s/%02x", name, (int)(sdom - spec));
-			}
-
-			list_add_tail(&dom->head, &pm->domains);
-			INIT_LIST_HEAD(&dom->list);
-			dom->func = sdom->func;
-			dom->addr = addr;
-			dom->signal_nr = sdom->signal_nr;
-
-			ssig = (sdom++)->signal;
-			while (ssig->name) {
-				struct nvkm_perfsig *sig =
-					&dom->signal[ssig->signal];
-				sig->name = ssig->name;
-				ret = nvkm_perfsrc_new(pm, sig, ssig->source);
-				if (ret)
-					return ret;
-				ssig++;
-			}
-
-			addr += size_domain;
-		}
-
-		mask &= ~(1 << i);
-	}
-
-	return 0;
-}
-
-static int
-nvkm_pm_fini(struct nvkm_engine *engine, bool suspend)
-{
-	struct nvkm_pm *pm = nvkm_pm(engine);
-	if (pm->func->fini)
-		pm->func->fini(pm);
-	return 0;
-}
-
-static void *
-nvkm_pm_dtor(struct nvkm_engine *engine)
-{
-	struct nvkm_pm *pm = nvkm_pm(engine);
-	struct nvkm_perfdom *dom, *next_dom;
-	struct nvkm_perfsrc *src, *next_src;
-
-	list_for_each_entry_safe(dom, next_dom, &pm->domains, head) {
-		list_del(&dom->head);
-		kfree(dom);
-	}
-
-	list_for_each_entry_safe(src, next_src, &pm->sources, head) {
-		list_del(&src->head);
-		kfree(src->name);
-		kfree(src);
-	}
-
-	return pm;
-}
-
-static const struct nvkm_engine_func
-nvkm_pm = {
-	.dtor = nvkm_pm_dtor,
-	.fini = nvkm_pm_fini,
-	.base.sclass = nvkm_pm_oclass_get,
-};
-
-int
-nvkm_pm_ctor(const struct nvkm_pm_func *func, struct nvkm_device *device,
-	     enum nvkm_subdev_type type, int inst, struct nvkm_pm *pm)
-{
-	pm->func = func;
-	INIT_LIST_HEAD(&pm->domains);
-	INIT_LIST_HEAD(&pm->sources);
-	spin_lock_init(&pm->client.lock);
-	return nvkm_engine_ctor(&nvkm_pm, device, type, inst, true, &pm->engine);
-}
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/pm/g84.c b/drivers/gpu/drm/nouveau/nvkm/engine/pm/g84.c
deleted file mode 100644
index 0086d00eb162..000000000000
--- a/drivers/gpu/drm/nouveau/nvkm/engine/pm/g84.c
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Copyright 2013 Red Hat Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors: Ben Skeggs
- */
-#include "nv40.h"
-
-const struct nvkm_specsrc
-g84_vfetch_sources[] = {
-	{ 0x400c0c, (const struct nvkm_specmux[]) {
-			{ 0x3, 0, "unk0" },
-			{}
-		}, "pgraph_vfetch_unk0c" },
-	{}
-};
-
-static const struct nvkm_specsrc
-g84_prop_sources[] = {
-	{ 0x408e50, (const struct nvkm_specmux[]) {
-			{ 0x1f, 0, "sel", true },
-			{}
-		}, "pgraph_tpc0_prop_pm_mux" },
-	{}
-};
-
-static const struct nvkm_specsrc
-g84_crop_sources[] = {
-	{ 0x407008, (const struct nvkm_specmux[]) {
-			{ 0xf, 0, "sel0", true },
-			{ 0x7, 16, "sel1", true },
-			{}
-		}, "pgraph_rop0_crop_pm_mux" },
-	{}
-};
-
-static const struct nvkm_specsrc
-g84_tex_sources[] = {
-	{ 0x408808, (const struct nvkm_specmux[]) {
-			{ 0xfffff, 0, "unk0" },
-			{}
-		}, "pgraph_tpc0_tex_unk08" },
-	{}
-};
-
-static const struct nvkm_specdom
-g84_pm[] = {
-	{ 0x20, (const struct nvkm_specsig[]) {
-			{}
-		}, &nv40_perfctr_func },
-	{ 0xf0, (const struct nvkm_specsig[]) {
-			{ 0xbd, "pc01_gr_idle" },
-			{ 0x5e, "pc01_strmout_00" },
-			{ 0x5f, "pc01_strmout_01" },
-			{ 0xd2, "pc01_trast_00" },
-			{ 0xd3, "pc01_trast_01" },
-			{ 0xd4, "pc01_trast_02" },
-			{ 0xd5, "pc01_trast_03" },
-			{ 0xd8, "pc01_trast_04" },
-			{ 0xd9, "pc01_trast_05" },
-			{ 0x5c, "pc01_vattr_00" },
-			{ 0x5d, "pc01_vattr_01" },
-			{ 0x66, "pc01_vfetch_00", g84_vfetch_sources },
-			{ 0x67, "pc01_vfetch_01", g84_vfetch_sources },
-			{ 0x68, "pc01_vfetch_02", g84_vfetch_sources },
-			{ 0x69, "pc01_vfetch_03", g84_vfetch_sources },
-			{ 0x6a, "pc01_vfetch_04", g84_vfetch_sources },
-			{ 0x6b, "pc01_vfetch_05", g84_vfetch_sources },
-			{ 0x6c, "pc01_vfetch_06", g84_vfetch_sources },
-			{ 0x6d, "pc01_vfetch_07", g84_vfetch_sources },
-			{ 0x6e, "pc01_vfetch_08", g84_vfetch_sources },
-			{ 0x6f, "pc01_vfetch_09", g84_vfetch_sources },
-			{ 0x70, "pc01_vfetch_0a", g84_vfetch_sources },
-			{ 0x71, "pc01_vfetch_0b", g84_vfetch_sources },
-			{ 0x72, "pc01_vfetch_0c", g84_vfetch_sources },
-			{ 0x73, "pc01_vfetch_0d", g84_vfetch_sources },
-			{ 0x74, "pc01_vfetch_0e", g84_vfetch_sources },
-			{ 0x75, "pc01_vfetch_0f", g84_vfetch_sources },
-			{ 0x76, "pc01_vfetch_10", g84_vfetch_sources },
-			{ 0x77, "pc01_vfetch_11", g84_vfetch_sources },
-			{ 0x78, "pc01_vfetch_12", g84_vfetch_sources },
-			{ 0x79, "pc01_vfetch_13", g84_vfetch_sources },
-			{ 0x7a, "pc01_vfetch_14", g84_vfetch_sources },
-			{ 0x7b, "pc01_vfetch_15", g84_vfetch_sources },
-			{ 0x7c, "pc01_vfetch_16", g84_vfetch_sources },
-			{ 0x7d, "pc01_vfetch_17", g84_vfetch_sources },
-			{ 0x7e, "pc01_vfetch_18", g84_vfetch_sources },
-			{ 0x7f, "pc01_vfetch_19", g84_vfetch_sources },
-			{ 0x07, "pc01_zcull_00", nv50_zcull_sources },
-			{ 0x08, "pc01_zcull_01", nv50_zcull_sources },
-			{ 0x09, "pc01_zcull_02", nv50_zcull_sources },
-			{ 0x0a, "pc01_zcull_03", nv50_zcull_sources },
-			{ 0x0b, "pc01_zcull_04", nv50_zcull_sources },
-			{ 0x0c, "pc01_zcull_05", nv50_zcull_sources },
-			{ 0xa4, "pc01_unk00" },
-			{ 0xec, "pc01_trailer" },
-			{}
-		}, &nv40_perfctr_func },
-	{ 0xa0, (const struct nvkm_specsig[]) {
-			{ 0x30, "pc02_crop_00", g84_crop_sources },
-			{ 0x31, "pc02_crop_01", g84_crop_sources },
-			{ 0x32, "pc02_crop_02", g84_crop_sources },
-			{ 0x33, "pc02_crop_03", g84_crop_sources },
-			{ 0x00, "pc02_prop_00", g84_prop_sources },
-			{ 0x01, "pc02_prop_01", g84_prop_sources },
-			{ 0x02, "pc02_prop_02", g84_prop_sources },
-			{ 0x03, "pc02_prop_03", g84_prop_sources },
-			{ 0x04, "pc02_prop_04", g84_prop_sources },
-			{ 0x05, "pc02_prop_05", g84_prop_sources },
-			{ 0x06, "pc02_prop_06", g84_prop_sources },
-			{ 0x07, "pc02_prop_07", g84_prop_sources },
-			{ 0x48, "pc02_tex_00", g84_tex_sources },
-			{ 0x49, "pc02_tex_01", g84_tex_sources },
-			{ 0x4a, "pc02_tex_02", g84_tex_sources },
-			{ 0x4b, "pc02_tex_03", g84_tex_sources },
-			{ 0x1a, "pc02_tex_04", g84_tex_sources },
-			{ 0x1b, "pc02_tex_05", g84_tex_sources },
-			{ 0x1c, "pc02_tex_06", g84_tex_sources },
-			{ 0x44, "pc02_zrop_00", nv50_zrop_sources },
-			{ 0x45, "pc02_zrop_01", nv50_zrop_sources },
-			{ 0x46, "pc02_zrop_02", nv50_zrop_sources },
-			{ 0x47, "pc02_zrop_03", nv50_zrop_sources },
-			{ 0x8c, "pc02_trailer" },
-			{}
-		}, &nv40_perfctr_func },
-	{ 0x20, (const struct nvkm_specsig[]) {
-			{}
-		}, &nv40_perfctr_func },
-	{ 0x20, (const struct nvkm_specsig[]) {
-			{}
-		}, &nv40_perfctr_func },
-	{ 0x20, (const struct nvkm_specsig[]) {
-			{}
-		}, &nv40_perfctr_func },
-	{ 0x20, (const struct nvkm_specsig[]) {
-			{}
-		}, &nv40_perfctr_func },
-	{ 0x20, (const struct nvkm_specsig[]) {
-			{}
-		}, &nv40_perfctr_func },
-	{}
-};
-
-int
-g84_pm_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst, struct nvkm_pm **ppm)
-{
-	return nv40_pm_new_(g84_pm, device, type, inst, ppm);
-}
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/pm/gf100.c b/drivers/gpu/drm/nouveau/nvkm/engine/pm/gf100.c
deleted file mode 100644
index 8e02701def8e..000000000000
--- a/drivers/gpu/drm/nouveau/nvkm/engine/pm/gf100.c
+++ /dev/null
@@ -1,243 +0,0 @@
-/*
- * Copyright 2013 Red Hat Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors: Ben Skeggs
- */
-#include "gf100.h"
-
-const struct nvkm_specsrc
-gf100_pbfb_sources[] = {
-	{ 0x10f100, (const struct nvkm_specmux[]) {
-			{ 0x1, 0, "unk0" },
-			{ 0x3f, 4, "unk4" },
-			{}
-		}, "pbfb_broadcast_pm_unk100" },
-	{}
-};
-
-const struct nvkm_specsrc
-gf100_pmfb_sources[] = {
-	{ 0x140028, (const struct nvkm_specmux[]) {
-			{ 0x3fff, 0, "unk0" },
-			{ 0x7, 16, "unk16" },
-			{ 0x3, 24, "unk24" },
-			{ 0x2, 29, "unk29" },
-			{}
-		}, "pmfb0_pm_unk28" },
-	{}
-};
-
-static const struct nvkm_specsrc
-gf100_l1_sources[] = {
-	{ 0x5044a8, (const struct nvkm_specmux[]) {
-			{ 0x3f, 0, "sel", true },
-			{}
-		}, "pgraph_gpc0_tpc0_l1_pm_mux" },
-	{}
-};
-
-static const struct nvkm_specsrc
-gf100_tex_sources[] = {
-	{ 0x5042c0, (const struct nvkm_specmux[]) {
-			{ 0xf, 0, "sel0", true },
-			{ 0x7, 8, "sel1", true },
-			{}
-		}, "pgraph_gpc0_tpc0_tex_pm_mux_c_d" },
-	{}
-};
-
-static const struct nvkm_specsrc
-gf100_unk400_sources[] = {
-	{ 0x50440c, (const struct nvkm_specmux[]) {
-			{ 0x3f, 0, "sel", true },
-			{}
-		}, "pgraph_gpc0_tpc0_unk400_pm_mux" },
-	{}
-};
-
-static const struct nvkm_specdom
-gf100_pm_hub[] = {
-	{}
-};
-
-const struct nvkm_specdom
-gf100_pm_gpc[] = {
-	{ 0xe0, (const struct nvkm_specsig[]) {
-			{ 0x00, "gpc00_l1_00", gf100_l1_sources },
-			{ 0x01, "gpc00_l1_01", gf100_l1_sources },
-			{ 0x02, "gpc00_l1_02", gf100_l1_sources },
-			{ 0x03, "gpc00_l1_03", gf100_l1_sources },
-			{ 0x05, "gpc00_l1_04", gf100_l1_sources },
-			{ 0x06, "gpc00_l1_05", gf100_l1_sources },
-			{ 0x0a, "gpc00_tex_00", gf100_tex_sources },
-			{ 0x0b, "gpc00_tex_01", gf100_tex_sources },
-			{ 0x0c, "gpc00_tex_02", gf100_tex_sources },
-			{ 0x0d, "gpc00_tex_03", gf100_tex_sources },
-			{ 0x0e, "gpc00_tex_04", gf100_tex_sources },
-			{ 0x0f, "gpc00_tex_05", gf100_tex_sources },
-			{ 0x10, "gpc00_tex_06", gf100_tex_sources },
-			{ 0x11, "gpc00_tex_07", gf100_tex_sources },
-			{ 0x12, "gpc00_tex_08", gf100_tex_sources },
-			{ 0x26, "gpc00_unk400_00", gf100_unk400_sources },
-			{}
-		}, &gf100_perfctr_func },
-	{}
-};
-
-static const struct nvkm_specdom
-gf100_pm_part[] = {
-	{ 0xe0, (const struct nvkm_specsig[]) {
-			{ 0x0f, "part00_pbfb_00", gf100_pbfb_sources },
-			{ 0x10, "part00_pbfb_01", gf100_pbfb_sources },
-			{ 0x21, "part00_pmfb_00", gf100_pmfb_sources },
-			{ 0x04, "part00_pmfb_01", gf100_pmfb_sources },
-			{ 0x00, "part00_pmfb_02", gf100_pmfb_sources },
-			{ 0x02, "part00_pmfb_03", gf100_pmfb_sources },
-			{ 0x01, "part00_pmfb_04", gf100_pmfb_sources },
-			{ 0x2e, "part00_pmfb_05", gf100_pmfb_sources },
-			{ 0x2f, "part00_pmfb_06", gf100_pmfb_sources },
-			{ 0x1b, "part00_pmfb_07", gf100_pmfb_sources },
-			{ 0x1c, "part00_pmfb_08", gf100_pmfb_sources },
-			{ 0x1d, "part00_pmfb_09", gf100_pmfb_sources },
-			{ 0x1e, "part00_pmfb_0a", gf100_pmfb_sources },
-			{ 0x1f, "part00_pmfb_0b", gf100_pmfb_sources },
-			{}
-		}, &gf100_perfctr_func },
-	{}
-};
-
-static void
-gf100_perfctr_init(struct nvkm_pm *pm, struct nvkm_perfdom *dom,
-		   struct nvkm_perfctr *ctr)
-{
-	struct nvkm_device *device = pm->engine.subdev.device;
-	u32 log = ctr->logic_op;
-	u32 src = 0x00000000;
-	int i;
-
-	for (i = 0; i < 4; i++)
-		src |= ctr->signal[i] << (i * 8);
-
-	nvkm_wr32(device, dom->addr + 0x09c, 0x00040002 | (dom->mode << 3));
-	nvkm_wr32(device, dom->addr + 0x100, 0x00000000);
-	nvkm_wr32(device, dom->addr + 0x040 + (ctr->slot * 0x08), src);
-	nvkm_wr32(device, dom->addr + 0x044 + (ctr->slot * 0x08), log);
-}
-
-static void
-gf100_perfctr_read(struct nvkm_pm *pm, struct nvkm_perfdom *dom,
-		   struct nvkm_perfctr *ctr)
-{
-	struct nvkm_device *device = pm->engine.subdev.device;
-
-	switch (ctr->slot) {
-	case 0: ctr->ctr = nvkm_rd32(device, dom->addr + 0x08c); break;
-	case 1: ctr->ctr = nvkm_rd32(device, dom->addr + 0x088); break;
-	case 2: ctr->ctr = nvkm_rd32(device, dom->addr + 0x080); break;
-	case 3: ctr->ctr = nvkm_rd32(device, dom->addr + 0x090); break;
-	}
-	dom->clk = nvkm_rd32(device, dom->addr + 0x070);
-}
-
-static void
-gf100_perfctr_next(struct nvkm_pm *pm, struct nvkm_perfdom *dom)
-{
-	struct nvkm_device *device = pm->engine.subdev.device;
-	nvkm_wr32(device, dom->addr + 0x06c, dom->signal_nr - 0x40 + 0x27);
-	nvkm_wr32(device, dom->addr + 0x0ec, 0x00000011);
-}
-
-const struct nvkm_funcdom
-gf100_perfctr_func = {
-	.init = gf100_perfctr_init,
-	.read = gf100_perfctr_read,
-	.next = gf100_perfctr_next,
-};
-
-static void
-gf100_pm_fini(struct nvkm_pm *pm)
-{
-	struct nvkm_device *device = pm->engine.subdev.device;
-	nvkm_mask(device, 0x000200, 0x10000000, 0x00000000);
-	nvkm_mask(device, 0x000200, 0x10000000, 0x10000000);
-}
-
-static const struct nvkm_pm_func
-gf100_pm_ = {
-	.fini = gf100_pm_fini,
-};
-
-int
-gf100_pm_new_(const struct gf100_pm_func *func, struct nvkm_device *device,
-	      enum nvkm_subdev_type type, int inst, struct nvkm_pm **ppm)
-{
-	struct nvkm_pm *pm;
-	u32 mask;
-	int ret;
-
-	if (!(pm = *ppm = kzalloc(sizeof(*pm), GFP_KERNEL)))
-		return -ENOMEM;
-
-	ret = nvkm_pm_ctor(&gf100_pm_, device, type, inst, pm);
-	if (ret)
-		return ret;
-
-	/* HUB */
-	ret = nvkm_perfdom_new(pm, "hub", 0, 0x1b0000, 0, 0x200,
-			       func->doms_hub);
-	if (ret)
-		return ret;
-
-	/* GPC */
-	mask  = (1 << nvkm_rd32(device, 0x022430)) - 1;
-	mask &= ~nvkm_rd32(device, 0x022504);
-	mask &= ~nvkm_rd32(device, 0x022584);
-
-	ret = nvkm_perfdom_new(pm, "gpc", mask, 0x180000,
-			       0x1000, 0x200, func->doms_gpc);
-	if (ret)
-		return ret;
-
-	/* PART */
-	mask  = (1 << nvkm_rd32(device, 0x022438)) - 1;
-	mask &= ~nvkm_rd32(device, 0x022548);
-	mask &= ~nvkm_rd32(device, 0x0225c8);
-
-	ret = nvkm_perfdom_new(pm, "part", mask, 0x1a0000,
-			       0x1000, 0x200, func->doms_part);
-	if (ret)
-		return ret;
-
-	return 0;
-}
-
-static const struct gf100_pm_func
-gf100_pm = {
-	.doms_gpc = gf100_pm_gpc,
-	.doms_hub = gf100_pm_hub,
-	.doms_part = gf100_pm_part,
-};
-
-int
-gf100_pm_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst, struct nvkm_pm **ppm)
-{
-	return gf100_pm_new_(&gf100_pm, device, type, inst, ppm);
-}
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/pm/gf100.h b/drivers/gpu/drm/nouveau/nvkm/engine/pm/gf100.h
deleted file mode 100644
index bc4b014c4e8e..000000000000
--- a/drivers/gpu/drm/nouveau/nvkm/engine/pm/gf100.h
+++ /dev/null
@@ -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
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/pm/gf108.c b/drivers/gpu/drm/nouveau/nvkm/engine/pm/gf108.c
deleted file mode 100644
index 505565866b59..000000000000
--- a/drivers/gpu/drm/nouveau/nvkm/engine/pm/gf108.c
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright 2015 Samuel Pitoiset
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors: Samuel Pitoiset
- */
-#include "gf100.h"
-
-static const struct nvkm_specdom
-gf108_pm_hub[] = {
-	{}
-};
-
-static const struct nvkm_specdom
-gf108_pm_part[] = {
-	{ 0xe0, (const struct nvkm_specsig[]) {
-			{ 0x14, "part00_pbfb_00", gf100_pbfb_sources },
-			{ 0x15, "part00_pbfb_01", gf100_pbfb_sources },
-			{ 0x20, "part00_pbfb_02", gf100_pbfb_sources },
-			{ 0x21, "part00_pbfb_03", gf100_pbfb_sources },
-			{ 0x01, "part00_pmfb_00", gf100_pmfb_sources },
-			{ 0x04, "part00_pmfb_01", gf100_pmfb_sources },
-			{ 0x05, "part00_pmfb_02", gf100_pmfb_sources},
-			{ 0x07, "part00_pmfb_03", gf100_pmfb_sources },
-			{ 0x0d, "part00_pmfb_04", gf100_pmfb_sources },
-			{ 0x12, "part00_pmfb_05", gf100_pmfb_sources },
-			{ 0x13, "part00_pmfb_06", gf100_pmfb_sources },
-			{ 0x2c, "part00_pmfb_07", gf100_pmfb_sources },
-			{ 0x2d, "part00_pmfb_08", gf100_pmfb_sources },
-			{ 0x2e, "part00_pmfb_09", gf100_pmfb_sources },
-			{ 0x2f, "part00_pmfb_0a", gf100_pmfb_sources },
-			{ 0x30, "part00_pmfb_0b", gf100_pmfb_sources },
-			{}
-		}, &gf100_perfctr_func },
-	{}
-};
-
-static const struct gf100_pm_func
-gf108_pm = {
-	.doms_gpc = gf100_pm_gpc,
-	.doms_hub = gf108_pm_hub,
-	.doms_part = gf108_pm_part,
-};
-
-int
-gf108_pm_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst, struct nvkm_pm **ppm)
-{
-	return gf100_pm_new_(&gf108_pm, device, type, inst, ppm);
-}
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/pm/gf117.c b/drivers/gpu/drm/nouveau/nvkm/engine/pm/gf117.c
deleted file mode 100644
index c61e8c010bb3..000000000000
--- a/drivers/gpu/drm/nouveau/nvkm/engine/pm/gf117.c
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright 2015 Samuel Pitoiset
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors: Samuel Pitoiset
- */
-#include "gf100.h"
-
-static const struct nvkm_specsrc
-gf117_pmfb_sources[] = {
-	{ 0x140028, (const struct nvkm_specmux[]) {
-			{ 0x3fff, 0, "unk0" },
-			{ 0x7, 16, "unk16" },
-			{ 0x3, 24, "unk24" },
-			{ 0x2, 28, "unk28" },
-			{}
-		}, "pmfb0_pm_unk28" },
-	{ 0x14125c, (const struct nvkm_specmux[]) {
-			{ 0x3fff, 0, "unk0" },
-			{}
-		}, "pmfb0_subp0_pm_unk25c" },
-	{}
-};
-
-static const struct nvkm_specdom
-gf117_pm_hub[] = {
-	{}
-};
-
-static const struct nvkm_specdom
-gf117_pm_part[] = {
-	{ 0xe0, (const struct nvkm_specsig[]) {
-			{ 0x00, "part00_pbfb_00", gf100_pbfb_sources },
-			{ 0x01, "part00_pbfb_01", gf100_pbfb_sources },
-			{ 0x12, "part00_pmfb_00", gf117_pmfb_sources },
-			{ 0x15, "part00_pmfb_01", gf117_pmfb_sources },
-			{ 0x16, "part00_pmfb_02", gf117_pmfb_sources },
-			{ 0x18, "part00_pmfb_03", gf117_pmfb_sources },
-			{ 0x1e, "part00_pmfb_04", gf117_pmfb_sources },
-			{ 0x23, "part00_pmfb_05", gf117_pmfb_sources },
-			{ 0x24, "part00_pmfb_06", gf117_pmfb_sources },
-			{ 0x0c, "part00_pmfb_07", gf117_pmfb_sources },
-			{ 0x0d, "part00_pmfb_08", gf117_pmfb_sources },
-			{ 0x0e, "part00_pmfb_09", gf117_pmfb_sources },
-			{ 0x0f, "part00_pmfb_0a", gf117_pmfb_sources },
-			{ 0x10, "part00_pmfb_0b", gf117_pmfb_sources },
-			{}
-		}, &gf100_perfctr_func },
-	{}
-};
-
-static const struct gf100_pm_func
-gf117_pm = {
-	.doms_gpc = gf100_pm_gpc,
-	.doms_hub = gf117_pm_hub,
-	.doms_part = gf117_pm_part,
-};
-
-int
-gf117_pm_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst, struct nvkm_pm **ppm)
-{
-	return gf100_pm_new_(&gf117_pm, device, type, inst, ppm);
-}
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/pm/gk104.c b/drivers/gpu/drm/nouveau/nvkm/engine/pm/gk104.c
deleted file mode 100644
index 75bf3df1cb18..000000000000
--- a/drivers/gpu/drm/nouveau/nvkm/engine/pm/gk104.c
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * Copyright 2013 Red Hat Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors: Ben Skeggs
- */
-#include "gf100.h"
-
-static const struct nvkm_specsrc
-gk104_pmfb_sources[] = {
-	{ 0x140028, (const struct nvkm_specmux[]) {
-			{ 0x3fff, 0, "unk0" },
-			{ 0x7, 16, "unk16" },
-			{ 0x3, 24, "unk24" },
-			{ 0x2, 28, "unk28" },
-			{}
-		}, "pmfb0_pm_unk28" },
-	{ 0x14125c, (const struct nvkm_specmux[]) {
-			{ 0x3fff, 0, "unk0" },
-			{}
-		}, "pmfb0_subp0_pm_unk25c" },
-	{ 0x14165c, (const struct nvkm_specmux[]) {
-			{ 0x3fff, 0, "unk0" },
-			{}
-		}, "pmfb0_subp1_pm_unk25c" },
-	{ 0x141a5c, (const struct nvkm_specmux[]) {
-			{ 0x3fff, 0, "unk0" },
-			{}
-		}, "pmfb0_subp2_pm_unk25c" },
-	{ 0x141e5c, (const struct nvkm_specmux[]) {
-			{ 0x3fff, 0, "unk0" },
-			{}
-		}, "pmfb0_subp3_pm_unk25c" },
-	{}
-};
-
-static const struct nvkm_specsrc
-gk104_tex_sources[] = {
-	{ 0x5042c0, (const struct nvkm_specmux[]) {
-			{ 0xf, 0, "sel0", true },
-			{ 0x7, 8, "sel1", true },
-			{}
-		}, "pgraph_gpc0_tpc0_tex_pm_mux_c_d" },
-	{ 0x5042c8, (const struct nvkm_specmux[]) {
-			{ 0x1f, 0, "sel", true },
-			{}
-		}, "pgraph_gpc0_tpc0_tex_pm_unkc8" },
-	{ 0x5042b8, (const struct nvkm_specmux[]) {
-			{ 0xff, 0, "sel", true },
-			{}
-		}, "pgraph_gpc0_tpc0_tex_pm_unkb8" },
-	{}
-};
-
-static const struct nvkm_specdom
-gk104_pm_hub[] = {
-	{ 0x60, (const struct nvkm_specsig[]) {
-			{ 0x47, "hub00_user_0" },
-			{}
-		}, &gf100_perfctr_func },
-	{ 0x40, (const struct nvkm_specsig[]) {
-			{ 0x27, "hub01_user_0" },
-			{}
-		}, &gf100_perfctr_func },
-	{ 0x60, (const struct nvkm_specsig[]) {
-			{ 0x47, "hub02_user_0" },
-			{}
-		}, &gf100_perfctr_func },
-	{ 0x60, (const struct nvkm_specsig[]) {
-			{ 0x47, "hub03_user_0" },
-			{}
-		}, &gf100_perfctr_func },
-	{ 0x40, (const struct nvkm_specsig[]) {
-			{ 0x03, "host_mmio_rd" },
-			{ 0x27, "hub04_user_0" },
-			{}
-		}, &gf100_perfctr_func },
-	{ 0x60, (const struct nvkm_specsig[]) {
-			{ 0x47, "hub05_user_0" },
-			{}
-		}, &gf100_perfctr_func },
-	{ 0xc0, (const struct nvkm_specsig[]) {
-			{ 0x74, "host_fb_rd3x" },
-			{ 0x75, "host_fb_rd3x_2" },
-			{ 0xa7, "hub06_user_0" },
-			{}
-		}, &gf100_perfctr_func },
-	{ 0x60, (const struct nvkm_specsig[]) {
-			{ 0x47, "hub07_user_0" },
-			{}
-		}, &gf100_perfctr_func },
-	{}
-};
-
-static const struct nvkm_specdom
-gk104_pm_gpc[] = {
-	{ 0xe0, (const struct nvkm_specsig[]) {
-			{ 0xc7, "gpc00_user_0" },
-			{}
-		}, &gf100_perfctr_func },
-	{ 0x20, (const struct nvkm_specsig[]) {
-			{}
-		}, &gf100_perfctr_func },
-	{ 0x20, (const struct nvkm_specsig[]) {
-			{ 0x00, "gpc02_tex_00", gk104_tex_sources },
-			{ 0x01, "gpc02_tex_01", gk104_tex_sources },
-			{ 0x02, "gpc02_tex_02", gk104_tex_sources },
-			{ 0x03, "gpc02_tex_03", gk104_tex_sources },
-			{ 0x04, "gpc02_tex_04", gk104_tex_sources },
-			{ 0x05, "gpc02_tex_05", gk104_tex_sources },
-			{ 0x06, "gpc02_tex_06", gk104_tex_sources },
-			{ 0x07, "gpc02_tex_07", gk104_tex_sources },
-			{ 0x08, "gpc02_tex_08", gk104_tex_sources },
-			{ 0x0a, "gpc02_tex_0a", gk104_tex_sources },
-			{ 0x0b, "gpc02_tex_0b", gk104_tex_sources },
-			{ 0x0d, "gpc02_tex_0c", gk104_tex_sources },
-			{ 0x0c, "gpc02_tex_0d", gk104_tex_sources },
-			{ 0x0e, "gpc02_tex_0e", gk104_tex_sources },
-			{ 0x0f, "gpc02_tex_0f", gk104_tex_sources },
-			{ 0x10, "gpc02_tex_10", gk104_tex_sources },
-			{ 0x11, "gpc02_tex_11", gk104_tex_sources },
-			{ 0x12, "gpc02_tex_12", gk104_tex_sources },
-			{}
-		}, &gf100_perfctr_func },
-	{}
-};
-
-static const struct nvkm_specdom
-gk104_pm_part[] = {
-	{ 0x60, (const struct nvkm_specsig[]) {
-			{ 0x00, "part00_pbfb_00", gf100_pbfb_sources },
-			{ 0x01, "part00_pbfb_01", gf100_pbfb_sources },
-			{ 0x0c, "part00_pmfb_00", gk104_pmfb_sources },
-			{ 0x0d, "part00_pmfb_01", gk104_pmfb_sources },
-			{ 0x0e, "part00_pmfb_02", gk104_pmfb_sources },
-			{ 0x0f, "part00_pmfb_03", gk104_pmfb_sources },
-			{ 0x10, "part00_pmfb_04", gk104_pmfb_sources },
-			{ 0x12, "part00_pmfb_05", gk104_pmfb_sources },
-			{ 0x15, "part00_pmfb_06", gk104_pmfb_sources },
-			{ 0x16, "part00_pmfb_07", gk104_pmfb_sources },
-			{ 0x18, "part00_pmfb_08", gk104_pmfb_sources },
-			{ 0x21, "part00_pmfb_09", gk104_pmfb_sources },
-			{ 0x25, "part00_pmfb_0a", gk104_pmfb_sources },
-			{ 0x26, "part00_pmfb_0b", gk104_pmfb_sources },
-			{ 0x27, "part00_pmfb_0c", gk104_pmfb_sources },
-			{ 0x47, "part00_user_0" },
-			{}
-		}, &gf100_perfctr_func },
-	{ 0x60, (const struct nvkm_specsig[]) {
-			{ 0x47, "part01_user_0" },
-			{}
-		}, &gf100_perfctr_func },
-	{}
-};
-
-static const struct gf100_pm_func
-gk104_pm = {
-	.doms_gpc = gk104_pm_gpc,
-	.doms_hub = gk104_pm_hub,
-	.doms_part = gk104_pm_part,
-};
-
-int
-gk104_pm_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst, struct nvkm_pm **ppm)
-{
-	return gf100_pm_new_(&gk104_pm, device, type, inst, ppm);
-}
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/pm/gt200.c b/drivers/gpu/drm/nouveau/nvkm/engine/pm/gt200.c
deleted file mode 100644
index 25874c541486..000000000000
--- a/drivers/gpu/drm/nouveau/nvkm/engine/pm/gt200.c
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright 2015 Nouveau project
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors: Samuel Pitoiset
- */
-#include "nv40.h"
-
-const struct nvkm_specsrc
-gt200_crop_sources[] = {
-	{ 0x407008, (const struct nvkm_specmux[]) {
-			{ 0xf, 0, "sel0", true },
-			{ 0x1f, 16, "sel1", true },
-			{}
-		}, "pgraph_rop0_crop_pm_mux" },
-	{}
-};
-
-const struct nvkm_specsrc
-gt200_prop_sources[] = {
-	{ 0x408750, (const struct nvkm_specmux[]) {
-			{ 0x3f, 0, "sel", true },
-			{}
-		}, "pgraph_tpc0_prop_pm_mux" },
-	{}
-};
-
-const struct nvkm_specsrc
-gt200_tex_sources[] = {
-	{ 0x408508, (const struct nvkm_specmux[]) {
-			{ 0xfffff, 0, "unk0" },
-			{}
-		}, "pgraph_tpc0_tex_unk08" },
-	{}
-};
-
-static const struct nvkm_specdom
-gt200_pm[] = {
-	{ 0x20, (const struct nvkm_specsig[]) {
-			{}
-		}, &nv40_perfctr_func },
-	{ 0xf0, (const struct nvkm_specsig[]) {
-			{ 0xc9, "pc01_gr_idle" },
-			{ 0x84, "pc01_strmout_00" },
-			{ 0x85, "pc01_strmout_01" },
-			{ 0xde, "pc01_trast_00" },
-			{ 0xdf, "pc01_trast_01" },
-			{ 0xe0, "pc01_trast_02" },
-			{ 0xe1, "pc01_trast_03" },
-			{ 0xe4, "pc01_trast_04" },
-			{ 0xe5, "pc01_trast_05" },
-			{ 0x82, "pc01_vattr_00" },
-			{ 0x83, "pc01_vattr_01" },
-			{ 0x46, "pc01_vfetch_00", g84_vfetch_sources },
-			{ 0x47, "pc01_vfetch_01", g84_vfetch_sources },
-			{ 0x48, "pc01_vfetch_02", g84_vfetch_sources },
-			{ 0x49, "pc01_vfetch_03", g84_vfetch_sources },
-			{ 0x4a, "pc01_vfetch_04", g84_vfetch_sources },
-			{ 0x4b, "pc01_vfetch_05", g84_vfetch_sources },
-			{ 0x4c, "pc01_vfetch_06", g84_vfetch_sources },
-			{ 0x4d, "pc01_vfetch_07", g84_vfetch_sources },
-			{ 0x4e, "pc01_vfetch_08", g84_vfetch_sources },
-			{ 0x4f, "pc01_vfetch_09", g84_vfetch_sources },
-			{ 0x50, "pc01_vfetch_0a", g84_vfetch_sources },
-			{ 0x51, "pc01_vfetch_0b", g84_vfetch_sources },
-			{ 0x52, "pc01_vfetch_0c", g84_vfetch_sources },
-			{ 0x53, "pc01_vfetch_0d", g84_vfetch_sources },
-			{ 0x54, "pc01_vfetch_0e", g84_vfetch_sources },
-			{ 0x55, "pc01_vfetch_0f", g84_vfetch_sources },
-			{ 0x56, "pc01_vfetch_10", g84_vfetch_sources },
-			{ 0x57, "pc01_vfetch_11", g84_vfetch_sources },
-			{ 0x58, "pc01_vfetch_12", g84_vfetch_sources },
-			{ 0x59, "pc01_vfetch_13", g84_vfetch_sources },
-			{ 0x5a, "pc01_vfetch_14", g84_vfetch_sources },
-			{ 0x5b, "pc01_vfetch_15", g84_vfetch_sources },
-			{ 0x5c, "pc01_vfetch_16", g84_vfetch_sources },
-			{ 0x5d, "pc01_vfetch_17", g84_vfetch_sources },
-			{ 0x5e, "pc01_vfetch_18", g84_vfetch_sources },
-			{ 0x5f, "pc01_vfetch_19", g84_vfetch_sources },
-			{ 0x07, "pc01_zcull_00", nv50_zcull_sources },
-			{ 0x08, "pc01_zcull_01", nv50_zcull_sources },
-			{ 0x09, "pc01_zcull_02", nv50_zcull_sources },
-			{ 0x0a, "pc01_zcull_03", nv50_zcull_sources },
-			{ 0x0b, "pc01_zcull_04", nv50_zcull_sources },
-			{ 0x0c, "pc01_zcull_05", nv50_zcull_sources },
-
-			{ 0xb0, "pc01_unk00" },
-			{ 0xec, "pc01_trailer" },
-			{}
-		}, &nv40_perfctr_func },
-	{ 0xf0, (const struct nvkm_specsig[]) {
-			{ 0x55, "pc02_crop_00", gt200_crop_sources },
-			{ 0x56, "pc02_crop_01", gt200_crop_sources },
-			{ 0x57, "pc02_crop_02", gt200_crop_sources },
-			{ 0x58, "pc02_crop_03", gt200_crop_sources },
-			{ 0x00, "pc02_prop_00", gt200_prop_sources },
-			{ 0x01, "pc02_prop_01", gt200_prop_sources },
-			{ 0x02, "pc02_prop_02", gt200_prop_sources },
-			{ 0x03, "pc02_prop_03", gt200_prop_sources },
-			{ 0x04, "pc02_prop_04", gt200_prop_sources },
-			{ 0x05, "pc02_prop_05", gt200_prop_sources },
-			{ 0x06, "pc02_prop_06", gt200_prop_sources },
-			{ 0x07, "pc02_prop_07", gt200_prop_sources },
-			{ 0x78, "pc02_tex_00", gt200_tex_sources },
-			{ 0x79, "pc02_tex_01", gt200_tex_sources },
-			{ 0x7a, "pc02_tex_02", gt200_tex_sources },
-			{ 0x7b, "pc02_tex_03", gt200_tex_sources },
-			{ 0x32, "pc02_tex_04", gt200_tex_sources },
-			{ 0x33, "pc02_tex_05", gt200_tex_sources },
-			{ 0x34, "pc02_tex_06", gt200_tex_sources },
-			{ 0x74, "pc02_zrop_00", nv50_zrop_sources },
-			{ 0x75, "pc02_zrop_01", nv50_zrop_sources },
-			{ 0x76, "pc02_zrop_02", nv50_zrop_sources },
-			{ 0x77, "pc02_zrop_03", nv50_zrop_sources },
-			{ 0xec, "pc02_trailer" },
-			{}
-		}, &nv40_perfctr_func },
-	{ 0x20, (const struct nvkm_specsig[]) {
-			{}
-		}, &nv40_perfctr_func },
-	{ 0x20, (const struct nvkm_specsig[]) {
-			{}
-		}, &nv40_perfctr_func },
-	{ 0x20, (const struct nvkm_specsig[]) {
-			{}
-		}, &nv40_perfctr_func },
-	{ 0x20, (const struct nvkm_specsig[]) {
-			{}
-		}, &nv40_perfctr_func },
-	{ 0x20, (const struct nvkm_specsig[]) {
-			{}
-		}, &nv40_perfctr_func },
-	{}
-};
-
-int
-gt200_pm_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst, struct nvkm_pm **ppm)
-{
-	return nv40_pm_new_(gt200_pm, device, type, inst, ppm);
-}
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/pm/gt215.c b/drivers/gpu/drm/nouveau/nvkm/engine/pm/gt215.c
deleted file mode 100644
index 54c23e2b6645..000000000000
--- a/drivers/gpu/drm/nouveau/nvkm/engine/pm/gt215.c
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Copyright 2013 Red Hat Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors: Ben Skeggs
- */
-#include "nv40.h"
-
-static const struct nvkm_specsrc
-gt215_zcull_sources[] = {
-	{ 0x402ca4, (const struct nvkm_specmux[]) {
-			{ 0x7fff, 0, "unk0" },
-			{ 0xff, 24, "unk24" },
-			{}
-		}, "pgraph_zcull_pm_unka4" },
-	{}
-};
-
-static const struct nvkm_specdom
-gt215_pm[] = {
-	{ 0x20, (const struct nvkm_specsig[]) {
-			{}
-		}, &nv40_perfctr_func },
-	{ 0xf0, (const struct nvkm_specsig[]) {
-			{ 0xcb, "pc01_gr_idle" },
-			{ 0x86, "pc01_strmout_00" },
-			{ 0x87, "pc01_strmout_01" },
-			{ 0xe0, "pc01_trast_00" },
-			{ 0xe1, "pc01_trast_01" },
-			{ 0xe2, "pc01_trast_02" },
-			{ 0xe3, "pc01_trast_03" },
-			{ 0xe6, "pc01_trast_04" },
-			{ 0xe7, "pc01_trast_05" },
-			{ 0x84, "pc01_vattr_00" },
-			{ 0x85, "pc01_vattr_01" },
-			{ 0x46, "pc01_vfetch_00", g84_vfetch_sources },
-			{ 0x47, "pc01_vfetch_01", g84_vfetch_sources },
-			{ 0x48, "pc01_vfetch_02", g84_vfetch_sources },
-			{ 0x49, "pc01_vfetch_03", g84_vfetch_sources },
-			{ 0x4a, "pc01_vfetch_04", g84_vfetch_sources },
-			{ 0x4b, "pc01_vfetch_05", g84_vfetch_sources },
-			{ 0x4c, "pc01_vfetch_06", g84_vfetch_sources },
-			{ 0x4d, "pc01_vfetch_07", g84_vfetch_sources },
-			{ 0x4e, "pc01_vfetch_08", g84_vfetch_sources },
-			{ 0x4f, "pc01_vfetch_09", g84_vfetch_sources },
-			{ 0x50, "pc01_vfetch_0a", g84_vfetch_sources },
-			{ 0x51, "pc01_vfetch_0b", g84_vfetch_sources },
-			{ 0x52, "pc01_vfetch_0c", g84_vfetch_sources },
-			{ 0x53, "pc01_vfetch_0d", g84_vfetch_sources },
-			{ 0x54, "pc01_vfetch_0e", g84_vfetch_sources },
-			{ 0x55, "pc01_vfetch_0f", g84_vfetch_sources },
-			{ 0x56, "pc01_vfetch_10", g84_vfetch_sources },
-			{ 0x57, "pc01_vfetch_11", g84_vfetch_sources },
-			{ 0x58, "pc01_vfetch_12", g84_vfetch_sources },
-			{ 0x59, "pc01_vfetch_13", g84_vfetch_sources },
-			{ 0x5a, "pc01_vfetch_14", g84_vfetch_sources },
-			{ 0x5b, "pc01_vfetch_15", g84_vfetch_sources },
-			{ 0x5c, "pc01_vfetch_16", g84_vfetch_sources },
-			{ 0x5d, "pc01_vfetch_17", g84_vfetch_sources },
-			{ 0x5e, "pc01_vfetch_18", g84_vfetch_sources },
-			{ 0x5f, "pc01_vfetch_19", g84_vfetch_sources },
-			{ 0x07, "pc01_zcull_00", gt215_zcull_sources },
-			{ 0x08, "pc01_zcull_01", gt215_zcull_sources },
-			{ 0x09, "pc01_zcull_02", gt215_zcull_sources },
-			{ 0x0a, "pc01_zcull_03", gt215_zcull_sources },
-			{ 0x0b, "pc01_zcull_04", gt215_zcull_sources },
-			{ 0x0c, "pc01_zcull_05", gt215_zcull_sources },
-			{ 0xb2, "pc01_unk00" },
-			{ 0xec, "pc01_trailer" },
-			{}
-		}, &nv40_perfctr_func },
-	{ 0xe0, (const struct nvkm_specsig[]) {
-			{ 0x64, "pc02_crop_00", gt200_crop_sources },
-			{ 0x65, "pc02_crop_01", gt200_crop_sources },
-			{ 0x66, "pc02_crop_02", gt200_crop_sources },
-			{ 0x67, "pc02_crop_03", gt200_crop_sources },
-			{ 0x00, "pc02_prop_00", gt200_prop_sources },
-			{ 0x01, "pc02_prop_01", gt200_prop_sources },
-			{ 0x02, "pc02_prop_02", gt200_prop_sources },
-			{ 0x03, "pc02_prop_03", gt200_prop_sources },
-			{ 0x04, "pc02_prop_04", gt200_prop_sources },
-			{ 0x05, "pc02_prop_05", gt200_prop_sources },
-			{ 0x06, "pc02_prop_06", gt200_prop_sources },
-			{ 0x07, "pc02_prop_07", gt200_prop_sources },
-			{ 0x80, "pc02_tex_00", gt200_tex_sources },
-			{ 0x81, "pc02_tex_01", gt200_tex_sources },
-			{ 0x82, "pc02_tex_02", gt200_tex_sources },
-			{ 0x83, "pc02_tex_03", gt200_tex_sources },
-			{ 0x3a, "pc02_tex_04", gt200_tex_sources },
-			{ 0x3b, "pc02_tex_05", gt200_tex_sources },
-			{ 0x3c, "pc02_tex_06", gt200_tex_sources },
-			{ 0x7c, "pc02_zrop_00", nv50_zrop_sources },
-			{ 0x7d, "pc02_zrop_01", nv50_zrop_sources },
-			{ 0x7e, "pc02_zrop_02", nv50_zrop_sources },
-			{ 0x7f, "pc02_zrop_03", nv50_zrop_sources },
-			{ 0xcc, "pc02_trailer" },
-			{}
-		}, &nv40_perfctr_func },
-	{ 0x20, (const struct nvkm_specsig[]) {
-			{}
-		}, &nv40_perfctr_func },
-	{ 0x20, (const struct nvkm_specsig[]) {
-			{}
-		}, &nv40_perfctr_func },
-	{ 0x20, (const struct nvkm_specsig[]) {
-			{}
-		}, &nv40_perfctr_func },
-	{ 0x20, (const struct nvkm_specsig[]) {
-			{}
-		}, &nv40_perfctr_func },
-	{ 0x20, (const struct nvkm_specsig[]) {
-			{}
-		}, &nv40_perfctr_func },
-	{}
-};
-
-int
-gt215_pm_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst, struct nvkm_pm **ppm)
-{
-	return nv40_pm_new_(gt215_pm, device, type, inst, ppm);
-}
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/pm/nv40.c b/drivers/gpu/drm/nouveau/nvkm/engine/pm/nv40.c
deleted file mode 100644
index eba5b3b79340..000000000000
--- a/drivers/gpu/drm/nouveau/nvkm/engine/pm/nv40.c
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright 2013 Red Hat Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors: Ben Skeggs
- */
-#include "nv40.h"
-
-static void
-nv40_perfctr_init(struct nvkm_pm *pm, struct nvkm_perfdom *dom,
-		  struct nvkm_perfctr *ctr)
-{
-	struct nvkm_device *device = pm->engine.subdev.device;
-	u32 log = ctr->logic_op;
-	u32 src = 0x00000000;
-	int i;
-
-	for (i = 0; i < 4; i++)
-		src |= ctr->signal[i] << (i * 8);
-
-	nvkm_wr32(device, 0x00a7c0 + dom->addr, 0x00000001 | (dom->mode << 4));
-	nvkm_wr32(device, 0x00a400 + dom->addr + (ctr->slot * 0x40), src);
-	nvkm_wr32(device, 0x00a420 + dom->addr + (ctr->slot * 0x40), log);
-}
-
-static void
-nv40_perfctr_read(struct nvkm_pm *pm, struct nvkm_perfdom *dom,
-		  struct nvkm_perfctr *ctr)
-{
-	struct nvkm_device *device = pm->engine.subdev.device;
-
-	switch (ctr->slot) {
-	case 0: ctr->ctr = nvkm_rd32(device, 0x00a700 + dom->addr); break;
-	case 1: ctr->ctr = nvkm_rd32(device, 0x00a6c0 + dom->addr); break;
-	case 2: ctr->ctr = nvkm_rd32(device, 0x00a680 + dom->addr); break;
-	case 3: ctr->ctr = nvkm_rd32(device, 0x00a740 + dom->addr); break;
-	}
-	dom->clk = nvkm_rd32(device, 0x00a600 + dom->addr);
-}
-
-static void
-nv40_perfctr_next(struct nvkm_pm *pm, struct nvkm_perfdom *dom)
-{
-	struct nvkm_device *device = pm->engine.subdev.device;
-	struct nv40_pm *nv40pm = container_of(pm, struct nv40_pm, base);
-
-	if (nv40pm->sequence != pm->sequence) {
-		nvkm_wr32(device, 0x400084, 0x00000020);
-		nv40pm->sequence = pm->sequence;
-	}
-}
-
-const struct nvkm_funcdom
-nv40_perfctr_func = {
-	.init = nv40_perfctr_init,
-	.read = nv40_perfctr_read,
-	.next = nv40_perfctr_next,
-};
-
-static const struct nvkm_pm_func
-nv40_pm_ = {
-};
-
-int
-nv40_pm_new_(const struct nvkm_specdom *doms, struct nvkm_device *device,
-	     enum nvkm_subdev_type type, int inst, struct nvkm_pm **ppm)
-{
-	struct nv40_pm *pm;
-	int ret;
-
-	if (!(pm = kzalloc(sizeof(*pm), GFP_KERNEL)))
-		return -ENOMEM;
-	*ppm = &pm->base;
-
-	ret = nvkm_pm_ctor(&nv40_pm_, device, type, inst, &pm->base);
-	if (ret)
-		return ret;
-
-	return nvkm_perfdom_new(&pm->base, "pc", 0, 0, 0, 4, doms);
-}
-
-static const struct nvkm_specdom
-nv40_pm[] = {
-	{ 0x20, (const struct nvkm_specsig[]) {
-			{}
-		}, &nv40_perfctr_func },
-	{ 0x20, (const struct nvkm_specsig[]) {
-			{}
-		}, &nv40_perfctr_func },
-	{ 0x20, (const struct nvkm_specsig[]) {
-			{}
-		}, &nv40_perfctr_func },
-	{ 0x20, (const struct nvkm_specsig[]) {
-			{}
-		}, &nv40_perfctr_func },
-	{ 0x20, (const struct nvkm_specsig[]) {
-			{}
-		}, &nv40_perfctr_func },
-	{}
-};
-
-int
-nv40_pm_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst, struct nvkm_pm **ppm)
-{
-	return nv40_pm_new_(nv40_pm, device, type, inst, ppm);
-}
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/pm/nv40.h b/drivers/gpu/drm/nouveau/nvkm/engine/pm/nv40.h
deleted file mode 100644
index afb79843723d..000000000000
--- a/drivers/gpu/drm/nouveau/nvkm/engine/pm/nv40.h
+++ /dev/null
@@ -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
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/pm/nv50.c b/drivers/gpu/drm/nouveau/nvkm/engine/pm/nv50.c
deleted file mode 100644
index bbd3404901f9..000000000000
--- a/drivers/gpu/drm/nouveau/nvkm/engine/pm/nv50.c
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * Copyright 2013 Red Hat Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors: Ben Skeggs
- */
-#include "nv40.h"
-
-const struct nvkm_specsrc
-nv50_zcull_sources[] = {
-	{ 0x402ca4, (const struct nvkm_specmux[]) {
-			{ 0x7fff, 0, "unk0" },
-			{}
-		}, "pgraph_zcull_pm_unka4" },
-	{}
-};
-
-const struct nvkm_specsrc
-nv50_zrop_sources[] = {
-	{ 0x40708c, (const struct nvkm_specmux[]) {
-			{ 0xf, 0, "sel0", true },
-			{ 0xf, 16, "sel1", true },
-			{}
-		}, "pgraph_rop0_zrop_pm_mux" },
-	{}
-};
-
-static const struct nvkm_specsrc
-nv50_prop_sources[] = {
-	{ 0x40be50, (const struct nvkm_specmux[]) {
-			{ 0x1f, 0, "sel", true },
-			{}
-		}, "pgraph_tpc3_prop_pm_mux" },
-	{}
-};
-
-static const struct nvkm_specsrc
-nv50_crop_sources[] = {
-        { 0x407008, (const struct nvkm_specmux[]) {
-                        { 0x7, 0, "sel0", true },
-                        { 0x7, 16, "sel1", true },
-                        {}
-                }, "pgraph_rop0_crop_pm_mux" },
-        {}
-};
-
-static const struct nvkm_specsrc
-nv50_tex_sources[] = {
-	{ 0x40b808, (const struct nvkm_specmux[]) {
-			{ 0x3fff, 0, "unk0" },
-			{}
-		}, "pgraph_tpc3_tex_unk08" },
-	{}
-};
-
-static const struct nvkm_specsrc
-nv50_vfetch_sources[] = {
-	{ 0x400c0c, (const struct nvkm_specmux[]) {
-			{ 0x1, 0, "unk0" },
-			{}
-		}, "pgraph_vfetch_unk0c" },
-	{}
-};
-
-static const struct nvkm_specdom
-nv50_pm[] = {
-	{ 0x20, (const struct nvkm_specsig[]) {
-			{}
-		}, &nv40_perfctr_func },
-	{ 0xf0, (const struct nvkm_specsig[]) {
-			{ 0xc8, "pc01_gr_idle" },
-			{ 0x7f, "pc01_strmout_00" },
-			{ 0x80, "pc01_strmout_01" },
-			{ 0xdc, "pc01_trast_00" },
-			{ 0xdd, "pc01_trast_01" },
-			{ 0xde, "pc01_trast_02" },
-			{ 0xdf, "pc01_trast_03" },
-			{ 0xe2, "pc01_trast_04" },
-			{ 0xe3, "pc01_trast_05" },
-			{ 0x7c, "pc01_vattr_00" },
-			{ 0x7d, "pc01_vattr_01" },
-			{ 0x26, "pc01_vfetch_00", nv50_vfetch_sources },
-			{ 0x27, "pc01_vfetch_01", nv50_vfetch_sources },
-			{ 0x28, "pc01_vfetch_02", nv50_vfetch_sources },
-			{ 0x29, "pc01_vfetch_03", nv50_vfetch_sources },
-			{ 0x2a, "pc01_vfetch_04", nv50_vfetch_sources },
-			{ 0x2b, "pc01_vfetch_05", nv50_vfetch_sources },
-			{ 0x2c, "pc01_vfetch_06", nv50_vfetch_sources },
-			{ 0x2d, "pc01_vfetch_07", nv50_vfetch_sources },
-			{ 0x2e, "pc01_vfetch_08", nv50_vfetch_sources },
-			{ 0x2f, "pc01_vfetch_09", nv50_vfetch_sources },
-			{ 0x30, "pc01_vfetch_0a", nv50_vfetch_sources },
-			{ 0x31, "pc01_vfetch_0b", nv50_vfetch_sources },
-			{ 0x32, "pc01_vfetch_0c", nv50_vfetch_sources },
-			{ 0x33, "pc01_vfetch_0d", nv50_vfetch_sources },
-			{ 0x34, "pc01_vfetch_0e", nv50_vfetch_sources },
-			{ 0x35, "pc01_vfetch_0f", nv50_vfetch_sources },
-			{ 0x36, "pc01_vfetch_10", nv50_vfetch_sources },
-			{ 0x37, "pc01_vfetch_11", nv50_vfetch_sources },
-			{ 0x38, "pc01_vfetch_12", nv50_vfetch_sources },
-			{ 0x39, "pc01_vfetch_13", nv50_vfetch_sources },
-			{ 0x3a, "pc01_vfetch_14", nv50_vfetch_sources },
-			{ 0x3b, "pc01_vfetch_15", nv50_vfetch_sources },
-			{ 0x3c, "pc01_vfetch_16", nv50_vfetch_sources },
-			{ 0x3d, "pc01_vfetch_17", nv50_vfetch_sources },
-			{ 0x3e, "pc01_vfetch_18", nv50_vfetch_sources },
-			{ 0x3f, "pc01_vfetch_19", nv50_vfetch_sources },
-			{ 0x20, "pc01_zcull_00", nv50_zcull_sources },
-			{ 0x21, "pc01_zcull_01", nv50_zcull_sources },
-			{ 0x22, "pc01_zcull_02", nv50_zcull_sources },
-			{ 0x23, "pc01_zcull_03", nv50_zcull_sources },
-			{ 0x24, "pc01_zcull_04", nv50_zcull_sources },
-			{ 0x25, "pc01_zcull_05", nv50_zcull_sources },
-			{ 0xae, "pc01_unk00" },
-			{ 0xee, "pc01_trailer" },
-			{}
-		}, &nv40_perfctr_func },
-	{ 0xf0, (const struct nvkm_specsig[]) {
-			{ 0x52, "pc02_crop_00", nv50_crop_sources },
-			{ 0x53, "pc02_crop_01", nv50_crop_sources },
-			{ 0x54, "pc02_crop_02", nv50_crop_sources },
-			{ 0x55, "pc02_crop_03", nv50_crop_sources },
-			{ 0x00, "pc02_prop_00", nv50_prop_sources },
-			{ 0x01, "pc02_prop_01", nv50_prop_sources },
-			{ 0x02, "pc02_prop_02", nv50_prop_sources },
-			{ 0x03, "pc02_prop_03", nv50_prop_sources },
-			{ 0x04, "pc02_prop_04", nv50_prop_sources },
-			{ 0x05, "pc02_prop_05", nv50_prop_sources },
-			{ 0x06, "pc02_prop_06", nv50_prop_sources },
-			{ 0x07, "pc02_prop_07", nv50_prop_sources },
-			{ 0x70, "pc02_tex_00", nv50_tex_sources },
-			{ 0x71, "pc02_tex_01", nv50_tex_sources },
-			{ 0x72, "pc02_tex_02", nv50_tex_sources },
-			{ 0x73, "pc02_tex_03", nv50_tex_sources },
-			{ 0x40, "pc02_tex_04", nv50_tex_sources },
-			{ 0x41, "pc02_tex_05", nv50_tex_sources },
-			{ 0x42, "pc02_tex_06", nv50_tex_sources },
-			{ 0x6c, "pc02_zrop_00", nv50_zrop_sources },
-			{ 0x6d, "pc02_zrop_01", nv50_zrop_sources },
-			{ 0x6e, "pc02_zrop_02", nv50_zrop_sources },
-			{ 0x6f, "pc02_zrop_03", nv50_zrop_sources },
-			{ 0xee, "pc02_trailer" },
-			{}
-		}, &nv40_perfctr_func },
-	{ 0x20, (const struct nvkm_specsig[]) {
-			{}
-		}, &nv40_perfctr_func },
-	{ 0x20, (const struct nvkm_specsig[]) {
-			{}
-		}, &nv40_perfctr_func },
-	{}
-};
-
-int
-nv50_pm_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst, struct nvkm_pm **ppm)
-{
-	return nv40_pm_new_(nv50_pm, device, type, inst, ppm);
-}
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/pm/priv.h b/drivers/gpu/drm/nouveau/nvkm/engine/pm/priv.h
deleted file mode 100644
index c011227f7052..000000000000
--- a/drivers/gpu/drm/nouveau/nvkm/engine/pm/priv.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/* SPDX-License-Identifier: MIT */
-#ifndef __NVKM_PM_PRIV_H__
-#define __NVKM_PM_PRIV_H__
-#define nvkm_pm(p) container_of((p), struct nvkm_pm, engine)
-#include <engine/pm.h>
-
-int nvkm_pm_ctor(const struct nvkm_pm_func *, struct nvkm_device *, enum nvkm_subdev_type, int,
-		 struct nvkm_pm *);
-
-struct nvkm_pm_func {
-	void (*fini)(struct nvkm_pm *);
-};
-
-struct nvkm_perfctr {
-	struct list_head head;
-	u8 domain;
-	u8  signal[4];
-	u64 source[4][8];
-	int slot;
-	u32 logic_op;
-	u32 ctr;
-};
-
-struct nvkm_specmux {
-	u32 mask;
-	u8 shift;
-	const char *name;
-	bool enable;
-};
-
-struct nvkm_specsrc {
-	u32 addr;
-	const struct nvkm_specmux *mux;
-	const char *name;
-};
-
-struct nvkm_perfsrc {
-	struct list_head head;
-	char *name;
-	u32 addr;
-	u32 mask;
-	u8 shift;
-	bool enable;
-};
-
-extern const struct nvkm_specsrc nv50_zcull_sources[];
-extern const struct nvkm_specsrc nv50_zrop_sources[];
-extern const struct nvkm_specsrc g84_vfetch_sources[];
-extern const struct nvkm_specsrc gt200_crop_sources[];
-extern const struct nvkm_specsrc gt200_prop_sources[];
-extern const struct nvkm_specsrc gt200_tex_sources[];
-
-struct nvkm_specsig {
-	u8 signal;
-	const char *name;
-	const struct nvkm_specsrc *source;
-};
-
-struct nvkm_perfsig {
-	const char *name;
-	u8 source[8];
-};
-
-struct nvkm_specdom {
-	u16 signal_nr;
-	const struct nvkm_specsig *signal;
-	const struct nvkm_funcdom *func;
-};
-
-#define nvkm_perfdom(p) container_of((p), struct nvkm_perfdom, object)
-#include <core/object.h>
-
-struct nvkm_perfdom {
-	struct nvkm_object object;
-	struct nvkm_perfmon *perfmon;
-	struct list_head head;
-	struct list_head list;
-	const struct nvkm_funcdom *func;
-	struct nvkm_perfctr *ctr[4];
-	char name[32];
-	u32 addr;
-	u8  mode;
-	u32 clk;
-	u16 signal_nr;
-	struct nvkm_perfsig signal[] __counted_by(signal_nr);
-};
-
-struct nvkm_funcdom {
-	void (*init)(struct nvkm_pm *, struct nvkm_perfdom *,
-		     struct nvkm_perfctr *);
-	void (*read)(struct nvkm_pm *, struct nvkm_perfdom *,
-		     struct nvkm_perfctr *);
-	void (*next)(struct nvkm_pm *, struct nvkm_perfdom *);
-};
-
-int nvkm_perfdom_new(struct nvkm_pm *, const char *, u32, u32, u32, u32,
-		     const struct nvkm_specdom *);
-
-#define nvkm_perfmon(p) container_of((p), struct nvkm_perfmon, object)
-
-struct nvkm_perfmon {
-	struct nvkm_object object;
-	struct nvkm_pm *pm;
-};
-#endif
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 026/156] drm/nouveau/nvkm: remove nvkm_client_search()
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (24 preceding siblings ...)
  2024-04-16 23:37 ` [PATCH 025/156] drm/nouveau/nvkm: remove perfmon Ben Skeggs
@ 2024-04-16 23:37 ` Ben Skeggs
  2024-04-16 23:37 ` [PATCH 027/156] drm/nouveau/nvif: remove support for userspace backends Ben Skeggs
                   ` (131 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:37 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- has been unused for a while now

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/include/nvkm/core/client.h |  1 -
 drivers/gpu/drm/nouveau/nvkm/core/client.c         | 13 -------------
 2 files changed, 14 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/client.h b/drivers/gpu/drm/nouveau/include/nvkm/core/client.h
index 932c9fd0b2d8..15f27fdd877a 100644
--- a/drivers/gpu/drm/nouveau/include/nvkm/core/client.h
+++ b/drivers/gpu/drm/nouveau/include/nvkm/core/client.h
@@ -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 {                                         \
diff --git a/drivers/gpu/drm/nouveau/nvkm/core/client.c b/drivers/gpu/drm/nouveau/nvkm/core/client.c
index c55662937ab2..48416c5039a1 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/client.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/client.c
@@ -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)
 {
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 027/156] drm/nouveau/nvif: remove support for userspace backends
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (25 preceding siblings ...)
  2024-04-16 23:37 ` [PATCH 026/156] drm/nouveau/nvkm: remove nvkm_client_search() Ben Skeggs
@ 2024-04-16 23:37 ` Ben Skeggs
  2024-04-16 23:37 ` [PATCH 028/156] drm/nouveau/nvif: remove route/token Ben Skeggs
                   ` (130 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:37 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- the tools that used libnvkm no longer exist

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/include/nvif/driver.h |  3 --
 drivers/gpu/drm/nouveau/nvif/driver.c         | 32 ++++---------------
 2 files changed, 7 insertions(+), 28 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driver.h b/drivers/gpu/drm/nouveau/include/nvif/driver.h
index 7a3af05f7f98..8d294ce3cf0a 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driver.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driver.h
@@ -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
diff --git a/drivers/gpu/drm/nouveau/nvif/driver.c b/drivers/gpu/drm/nouveau/nvif/driver.c
index 5e00dd07afed..acb708df2559 100644
--- a/drivers/gpu/drm/nouveau/nvif/driver.c
+++ b/drivers/gpu/drm/nouveau/nvif/driver.c
@@ -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);
 }
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 028/156] drm/nouveau/nvif: remove route/token
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (26 preceding siblings ...)
  2024-04-16 23:37 ` [PATCH 027/156] drm/nouveau/nvif: remove support for userspace backends Ben Skeggs
@ 2024-04-16 23:37 ` Ben Skeggs
  2024-04-16 23:37 ` [PATCH 029/156] drm/nouveau/nvif: remove nvxx_object() Ben Skeggs
                   ` (129 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:37 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- these are no longer useful for anything

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 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(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/client.h b/drivers/gpu/drm/nouveau/include/nvif/client.h
index 5d9395e651b6..64b033222c56 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/client.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/client.h
@@ -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,
diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/object.h b/drivers/gpu/drm/nouveau/include/nvkm/core/object.h
index ed1f66360782..d4f1c964ba31 100644
--- a/drivers/gpu/drm/nouveau/include/nvkm/core/object.h
+++ b/drivers/gpu/drm/nouveau/include/nvkm/core/object.h
@@ -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;
 };
diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/oclass.h b/drivers/gpu/drm/nouveau/include/nvkm/core/oclass.h
index 8e1b945d38f3..cad05f0e7948 100644
--- a/drivers/gpu/drm/nouveau/include/nvkm/core/oclass.h
+++ b/drivers/gpu/drm/nouveau/include/nvkm/core/oclass.h
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/nouveau_abi16.c b/drivers/gpu/drm/nouveau/nouveau_abi16.c
index 5ebd19ece13b..2648e42e0496 100644
--- a/drivers/gpu/drm/nouveau/nouveau_abi16.c
+++ b/drivers/gpu/drm/nouveau/nouveau_abi16.c
@@ -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;
 
diff --git a/drivers/gpu/drm/nouveau/nvif/client.c b/drivers/gpu/drm/nouveau/nvif/client.c
index 3a27245f467f..cd5439b73ac7 100644
--- a/drivers/gpu/drm/nouveau/nvif/client.c
+++ b/drivers/gpu/drm/nouveau/nvif/client.c
@@ -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) {
diff --git a/drivers/gpu/drm/nouveau/nvif/object.c b/drivers/gpu/drm/nouveau/nvif/object.c
index 4d1aaee8fe15..2b3e05197846 100644
--- a/drivers/gpu/drm/nouveau/nvif/object.c
+++ b/drivers/gpu/drm/nouveau/nvif/object.c
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/nvkm/core/client.c b/drivers/gpu/drm/nouveau/nvkm/core/client.c
index 48416c5039a1..95cbb5b682f2 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/client.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/client.c
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c b/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c
index 0b33287e43a7..39d5c9700867 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c
@@ -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) {
diff --git a/drivers/gpu/drm/nouveau/nvkm/core/object.c b/drivers/gpu/drm/nouveau/nvkm/core/object.c
index aea3ba72027a..580b8c7f25af 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/object.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/object.c
@@ -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);
diff --git a/drivers/gpu/drm/nouveau/nvkm/core/uevent.c b/drivers/gpu/drm/nouveau/nvkm/core/uevent.c
index ba9d9edaec75..cc254c390a57 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/uevent.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/uevent.c
@@ -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
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 029/156] drm/nouveau/nvif: remove nvxx_object()
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (27 preceding siblings ...)
  2024-04-16 23:37 ` [PATCH 028/156] drm/nouveau/nvif: remove route/token Ben Skeggs
@ 2024-04-16 23:37 ` Ben Skeggs
  2024-04-16 23:37 ` [PATCH 030/156] drm/nouveau/nvif: remove nvxx_client() Ben Skeggs
                   ` (128 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:37 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- no longer used

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 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(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/object.h b/drivers/gpu/drm/nouveau/include/nvif/object.h
index f52399caee82..478cbb8f2dfe 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/object.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/object.h
@@ -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
diff --git a/drivers/gpu/drm/nouveau/include/nvif/os.h b/drivers/gpu/drm/nouveau/include/nvif/os.h
index 429d0106c123..a2eaf3929ac3 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/os.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/os.h
@@ -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
diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/os.h b/drivers/gpu/drm/nouveau/include/nvkm/core/os.h
index 3fd5c007a663..9b05612e6490 100644
--- a/drivers/gpu/drm/nouveau/include/nvkm/core/os.h
+++ b/drivers/gpu/drm/nouveau/include/nvkm/core/os.h
@@ -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;
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 030/156] drm/nouveau/nvif: remove nvxx_client()
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (28 preceding siblings ...)
  2024-04-16 23:37 ` [PATCH 029/156] drm/nouveau/nvif: remove nvxx_object() Ben Skeggs
@ 2024-04-16 23:37 ` Ben Skeggs
  2024-04-16 23:37 ` [PATCH 031/156] drm/nouveau/nvif: remove driver keep/fini Ben Skeggs
                   ` (127 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:37 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

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

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 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(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/client.h b/drivers/gpu/drm/nouveau/include/nvif/client.h
index 64b033222c56..5210007d7669 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/client.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/client.h
@@ -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
diff --git a/drivers/gpu/drm/nouveau/nouveau_chan.c b/drivers/gpu/drm/nouveau/nouveau_chan.c
index db86cca9ea37..7977bb353c92 100644
--- a/drivers/gpu/drm/nouveau/nouveau_chan.c
+++ b/drivers/gpu/drm/nouveau/nouveau_chan.c
@@ -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;
 		}
 	}
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 33883c4e8221..ad2772cf5e23 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -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);
diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.c b/drivers/gpu/drm/nouveau/nouveau_fence.c
index ba25ce1294a6..09686d038d60 100644
--- a/drivers/gpu/drm/nouveau/nouveau_fence.c
+++ b/drivers/gpu/drm/nouveau/nouveau_fence.c
@@ -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)
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 031/156] drm/nouveau/nvif: remove driver keep/fini
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (29 preceding siblings ...)
  2024-04-16 23:37 ` [PATCH 030/156] drm/nouveau/nvif: remove nvxx_client() Ben Skeggs
@ 2024-04-16 23:37 ` Ben Skeggs
  2024-04-16 23:37 ` [PATCH 032/156] drm/nouveau/nvif: remove client version Ben Skeggs
                   ` (126 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:37 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- no longer used

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 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(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driver.h b/drivers/gpu/drm/nouveau/include/nvif/driver.h
index 8d294ce3cf0a..7b08ff769039 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driver.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driver.h
@@ -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,
diff --git a/drivers/gpu/drm/nouveau/nvif/client.c b/drivers/gpu/drm/nouveau/nvif/client.c
index cd5439b73ac7..85ad5091e8e2 100644
--- a/drivers/gpu/drm/nouveau/nvif/client.c
+++ b/drivers/gpu/drm/nouveau/nvif/client.c
@@ -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
diff --git a/drivers/gpu/drm/nouveau/nvkm/core/driver.c b/drivers/gpu/drm/nouveau/nvkm/core/driver.c
index 3494002b40cd..1f5273ff2225 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/driver.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/driver.c
@@ -95,5 +95,4 @@ nvif_driver_nvkm = {
 	.ioctl = nvkm_driver_ioctl,
 	.map = nvkm_driver_map,
 	.unmap = nvkm_driver_unmap,
-	.keep = false,
 };
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 032/156] drm/nouveau/nvif: remove client version
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (30 preceding siblings ...)
  2024-04-16 23:37 ` [PATCH 031/156] drm/nouveau/nvif: remove driver keep/fini Ben Skeggs
@ 2024-04-16 23:37 ` Ben Skeggs
  2024-04-16 23:37 ` [PATCH 033/156] drm/nouveau/nvif: remove client devlist Ben Skeggs
                   ` (125 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:37 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- unused

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 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(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/client.h b/drivers/gpu/drm/nouveau/include/nvif/client.h
index 5210007d7669..87dc55f8bde6 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/client.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/client.h
@@ -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 *);
 
diff --git a/drivers/gpu/drm/nouveau/include/nvif/ioctl.h b/drivers/gpu/drm/nouveau/include/nvif/ioctl.h
index 4e047bb1fc07..1e74245621e0 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/ioctl.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/ioctl.h
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/nvif/client.c b/drivers/gpu/drm/nouveau/nvif/client.c
index 85ad5091e8e2..098831d92eac 100644
--- a/drivers/gpu/drm/nouveau/nvif/client.c
+++ b/drivers/gpu/drm/nouveau/nvif/client.c
@@ -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;
 }
diff --git a/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c b/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c
index 39d5c9700867..584fc43c0d75 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c
@@ -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>
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 033/156] drm/nouveau/nvif: remove client devlist
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (31 preceding siblings ...)
  2024-04-16 23:37 ` [PATCH 032/156] drm/nouveau/nvif: remove client version Ben Skeggs
@ 2024-04-16 23:37 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 034/156] drm/nouveau/nvif: remove client fini Ben Skeggs
                   ` (124 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:37 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- unused

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 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(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0000.h b/drivers/gpu/drm/nouveau/include/nvif/if0000.h
index f7b8f8f48760..4b31496b37e1 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/if0000.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/if0000.h
@@ -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
diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/device.h b/drivers/gpu/drm/nouveau/include/nvkm/core/device.h
index f057d348221e..46afb877a296 100644
--- a/drivers/gpu/drm/nouveau/include/nvkm/core/device.h
+++ b/drivers/gpu/drm/nouveau/include/nvkm/core/device.h
@@ -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))
diff --git a/drivers/gpu/drm/nouveau/nvkm/core/client.c b/drivers/gpu/drm/nouveau/nvkm/core/client.c
index 95cbb5b682f2..3e7049427b06 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/client.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/client.c
@@ -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,
 };
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/device/base.c b/drivers/gpu/drm/nouveau/nvkm/device/base.c
index 3f827adcb19d..3ce42de55aa9 100644
--- a/drivers/gpu/drm/nouveau/nvkm/device/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/device/base.c
@@ -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",
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 034/156] drm/nouveau/nvif: remove client fini
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (32 preceding siblings ...)
  2024-04-16 23:37 ` [PATCH 033/156] drm/nouveau/nvif: remove client devlist Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 035/156] drm/nouveau/nvif: remove device args Ben Skeggs
                   ` (123 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- unused

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/nvkm/core/client.c | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/core/client.c b/drivers/gpu/drm/nouveau/nvkm/core/client.c
index 3e7049427b06..f73d58eb6de6 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/client.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/client.c
@@ -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,
 };
 
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 035/156] drm/nouveau/nvif: remove device args
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (33 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 034/156] drm/nouveau/nvif: remove client fini Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 036/156] drm/nouveau/nvif: remove device rd/wr Ben Skeggs
                   ` (122 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

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

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 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(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/cl0080.h b/drivers/gpu/drm/nouveau/include/nvif/cl0080.h
index fa161b74d967..ea937fa7bc55 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/cl0080.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/cl0080.h
@@ -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
 
diff --git a/drivers/gpu/drm/nouveau/include/nvif/device.h b/drivers/gpu/drm/nouveau/include/nvif/device.h
index 64b8e4defc35..fec76f4733a4 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/device.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/device.h
@@ -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 *);
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index ad2772cf5e23..9caadcdb3c29 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/nvif/device.c b/drivers/gpu/drm/nouveau/nvif/device.c
index 2fef6553a013..24880931039f 100644
--- a/drivers/gpu/drm/nouveau/nvif/device.c
+++ b/drivers/gpu/drm/nouveau/nvif/device.c
@@ -21,8 +21,8 @@
  *
  * Authors: Ben Skeggs <bskeggs@redhat.com>
  */
-
 #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) {
diff --git a/drivers/gpu/drm/nouveau/nvkm/device/user.c b/drivers/gpu/drm/nouveau/nvkm/device/user.c
index d937c54e8dfa..65bd6712bce2 100644
--- a/drivers/gpu/drm/nouveau/nvkm/device/user.c
+++ b/drivers/gpu/drm/nouveau/nvkm/device/user.c
@@ -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;
 
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 036/156] drm/nouveau/nvif: remove device rd/wr
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (34 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 035/156] drm/nouveau/nvif: remove device args Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 037/156] drm/nouveau/nvif: remove disp chan rd/wr Ben Skeggs
                   ` (121 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- device is always mapped now, these are unneeded

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 .../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(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/object.h b/drivers/gpu/drm/nouveau/include/nvkm/core/object.h
index d4f1c964ba31..c91abac44bd6 100644
--- a/drivers/gpu/drm/nouveau/include/nvkm/core/object.h
+++ b/drivers/gpu/drm/nouveau/include/nvkm/core/object.h
@@ -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 **);
diff --git a/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c b/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c
index 584fc43c0d75..95e9537e1d7c 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/nvkm/core/object.c b/drivers/gpu/drm/nouveau/nvkm/core/object.c
index 580b8c7f25af..913c3bae51f7 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/object.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/object.c
@@ -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)
 {
diff --git a/drivers/gpu/drm/nouveau/nvkm/core/oproxy.c b/drivers/gpu/drm/nouveau/nvkm/core/oproxy.c
index 3385528da650..afc10ec256a7 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/oproxy.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/oproxy.c
@@ -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,
diff --git a/drivers/gpu/drm/nouveau/nvkm/device/user.c b/drivers/gpu/drm/nouveau/nvkm/device/user.c
index 65bd6712bce2..d7f75b3a43c8 100644
--- a/drivers/gpu/drm/nouveau/nvkm/device/user.c
+++ b/drivers/gpu/drm/nouveau/nvkm/device/user.c
@@ -202,54 +202,6 @@ nvkm_udevice_mthd(struct nvkm_object *object, u32 mthd, void *data, u32 size)
 	return -EINVAL;
 }
 
-static int
-nvkm_udevice_rd08(struct nvkm_object *object, u64 addr, u8 *data)
-{
-	struct nvkm_udevice *udev = nvkm_udevice(object);
-	*data = nvkm_rd08(udev->device, addr);
-	return 0;
-}
-
-static int
-nvkm_udevice_rd16(struct nvkm_object *object, u64 addr, u16 *data)
-{
-	struct nvkm_udevice *udev = nvkm_udevice(object);
-	*data = nvkm_rd16(udev->device, addr);
-	return 0;
-}
-
-static int
-nvkm_udevice_rd32(struct nvkm_object *object, u64 addr, u32 *data)
-{
-	struct nvkm_udevice *udev = nvkm_udevice(object);
-	*data = nvkm_rd32(udev->device, addr);
-	return 0;
-}
-
-static int
-nvkm_udevice_wr08(struct nvkm_object *object, u64 addr, u8 data)
-{
-	struct nvkm_udevice *udev = nvkm_udevice(object);
-	nvkm_wr08(udev->device, addr, data);
-	return 0;
-}
-
-static int
-nvkm_udevice_wr16(struct nvkm_object *object, u64 addr, u16 data)
-{
-	struct nvkm_udevice *udev = nvkm_udevice(object);
-	nvkm_wr16(udev->device, addr, data);
-	return 0;
-}
-
-static int
-nvkm_udevice_wr32(struct nvkm_object *object, u64 addr, u32 data)
-{
-	struct nvkm_udevice *udev = nvkm_udevice(object);
-	nvkm_wr32(udev->device, addr, data);
-	return 0;
-}
-
 static int
 nvkm_udevice_map(struct nvkm_object *object, void *argv, u32 argc,
 		 enum nvkm_object_map *type, u64 *addr, u64 *size)
@@ -362,12 +314,6 @@ nvkm_udevice = {
 	.fini = nvkm_udevice_fini,
 	.mthd = nvkm_udevice_mthd,
 	.map = nvkm_udevice_map,
-	.rd08 = nvkm_udevice_rd08,
-	.rd16 = nvkm_udevice_rd16,
-	.rd32 = nvkm_udevice_rd32,
-	.wr08 = nvkm_udevice_wr08,
-	.wr16 = nvkm_udevice_wr16,
-	.wr32 = nvkm_udevice_wr32,
 	.sclass = nvkm_udevice_child_get,
 };
 
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 037/156] drm/nouveau/nvif: remove disp chan rd/wr
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (35 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 036/156] drm/nouveau/nvif: remove device rd/wr Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 038/156] drm/nouveau/nvkm: rename struct nvkm_uevent Ben Skeggs
                   ` (120 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- require display channel allocations to use map() instead

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 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(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c b/drivers/gpu/drm/nouveau/dispnv50/disp.c
index 31b46a62b501..4508c24720e2 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/disp.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c
@@ -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;
 			}
diff --git a/drivers/gpu/drm/nouveau/include/nvif/ioctl.h b/drivers/gpu/drm/nouveau/include/nvif/ioctl.h
index 1e74245621e0..e825c8a1d9ca 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/ioctl.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/ioctl.h
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/include/nvif/object.h b/drivers/gpu/drm/nouveau/include/nvif/object.h
index 478cbb8f2dfe..8d205b6af46a 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/object.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/object.h
@@ -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;                                                                 \
diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/object.h b/drivers/gpu/drm/nouveau/include/nvkm/core/object.h
index c91abac44bd6..10107ef3ca49 100644
--- a/drivers/gpu/drm/nouveau/include/nvkm/core/object.h
+++ b/drivers/gpu/drm/nouveau/include/nvkm/core/object.h
@@ -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 **);
 
diff --git a/drivers/gpu/drm/nouveau/nvif/object.c b/drivers/gpu/drm/nouveau/nvif/object.c
index 2b3e05197846..8a2a7bfec2f8 100644
--- a/drivers/gpu/drm/nouveau/nvif/object.c
+++ b/drivers/gpu/drm/nouveau/nvif/object.c
@@ -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)
 {
diff --git a/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c b/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c
index 95e9537e1d7c..45051a1249da 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c
@@ -191,59 +191,14 @@ static int
 nvkm_ioctl_rd(struct nvkm_client *client,
 	      struct nvkm_object *object, void *data, u32 size)
 {
-	union {
-		struct nvif_ioctl_rd_v0 v0;
-	} *args = data;
-	union {
-		u8  b08;
-		u16 b16;
-		u32 b32;
-	} v;
-	int ret = -ENOSYS;
-
-	nvif_ioctl(object, "rd size %d\n", size);
-	if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
-		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 4:
-			ret = nvkm_object_rd32(object, args->v0.addr, &v.b32);
-			args->v0.data = v.b32;
-			break;
-		default:
-			ret = -EINVAL;
-			break;
-		}
-	}
-
-	return ret;
+	return -ENOSYS;
 }
 
 static int
 nvkm_ioctl_wr(struct nvkm_client *client,
 	      struct nvkm_object *object, void *data, u32 size)
 {
-	union {
-		struct nvif_ioctl_wr_v0 v0;
-	} *args = data;
-	int ret = -ENOSYS;
-
-	nvif_ioctl(object, "wr size %d\n", size);
-	if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
-		nvif_ioctl(object,
-			   "wr vers %d size %d addr %016llx data %08x\n",
-			   args->v0.version, args->v0.size, args->v0.addr,
-			   args->v0.data);
-	} else
-		return ret;
-
-	switch (args->v0.size) {
-	case 4: return nvkm_object_wr32(object, args->v0.addr, args->v0.data);
-	default:
-		break;
-	}
-
-	return -EINVAL;
+	return -ENOSYS;
 }
 
 static int
diff --git a/drivers/gpu/drm/nouveau/nvkm/core/object.c b/drivers/gpu/drm/nouveau/nvkm/core/object.c
index 913c3bae51f7..390c265cf8af 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/object.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/object.c
@@ -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)
diff --git a/drivers/gpu/drm/nouveau/nvkm/core/oproxy.c b/drivers/gpu/drm/nouveau/nvkm/core/oproxy.c
index afc10ec256a7..5db80d1780f0 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/oproxy.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/oproxy.c
@@ -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,
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/chan.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/chan.c
index d5e18daed79f..4e43ee383c34 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/chan.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/chan.c
@@ -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,
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 038/156] drm/nouveau/nvkm: rename struct nvkm_uevent
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (36 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 037/156] drm/nouveau/nvif: remove disp chan rd/wr Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 039/156] drm/nouveau/nvkm: remove nvkm_client() Ben Skeggs
                   ` (119 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

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

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 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(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/os.h b/drivers/gpu/drm/nouveau/include/nvkm/core/os.h
index 9b05612e6490..668338d7bda3 100644
--- a/drivers/gpu/drm/nouveau/include/nvkm/core/os.h
+++ b/drivers/gpu/drm/nouveau/include/nvkm/core/os.h
@@ -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
diff --git a/drivers/gpu/drm/nouveau/nvkm/core/uevent.c b/drivers/gpu/drm/nouveau/nvkm/core/uevent.c
index cc254c390a57..900814c9a6bd 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/uevent.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/uevent.c
@@ -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)
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 039/156] drm/nouveau/nvkm: remove nvkm_client()
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (37 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 038/156] drm/nouveau/nvkm: rename struct nvkm_uevent Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 040/156] drm/nouveau/nvkm: rename struct nvkm_udevice Ben Skeggs
                   ` (118 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- preparation for upcoming patches

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 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(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/client.h b/drivers/gpu/drm/nouveau/include/nvkm/core/client.h
index 15f27fdd877a..4045b9f5ef4e 100644
--- a/drivers/gpu/drm/nouveau/include/nvkm/core/client.h
+++ b/drivers/gpu/drm/nouveau/include/nvkm/core/client.h
@@ -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 {
diff --git a/drivers/gpu/drm/nouveau/nvkm/core/client.c b/drivers/gpu/drm/nouveau/nvkm/core/client.c
index f73d58eb6de6..b127676078b1 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/client.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/client.c
@@ -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
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 040/156] drm/nouveau/nvkm: rename struct nvkm_udevice
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (38 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 039/156] drm/nouveau/nvkm: remove nvkm_client() Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 041/156] drm/nouveau/nvkm: rename struct nvkm_control Ben Skeggs
                   ` (117 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

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

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/nvkm/device/user.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/device/user.c b/drivers/gpu/drm/nouveau/nvkm/device/user.c
index d7f75b3a43c8..af5aa9e1e5ea 100644
--- a/drivers/gpu/drm/nouveau/nvkm/device/user.c
+++ b/drivers/gpu/drm/nouveau/nvkm/device/user.c
@@ -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;
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 041/156] drm/nouveau/nvkm: rename struct nvkm_control
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (39 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 040/156] drm/nouveau/nvkm: rename struct nvkm_udevice Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 042/156] drm/nouveau/nvkm: rename struct nvkm_uvfn Ben Skeggs
                   ` (116 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

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

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 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(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/device/ctrl.c b/drivers/gpu/drm/nouveau/nvkm/device/ctrl.c
index ce774579c89d..a74fb78ca7ab 100644
--- a/drivers/gpu/drm/nouveau/nvkm/device/ctrl.c
+++ b/drivers/gpu/drm/nouveau/nvkm/device/ctrl.c
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/nvkm/device/ctrl.h b/drivers/gpu/drm/nouveau/nvkm/device/ctrl.h
index 9f6d7f23af8d..d241329a1e7a 100644
--- a/drivers/gpu/drm/nouveau/nvkm/device/ctrl.h
+++ b/drivers/gpu/drm/nouveau/nvkm/device/ctrl.h
@@ -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
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 042/156] drm/nouveau/nvkm: rename struct nvkm_uvfn
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (40 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 041/156] drm/nouveau/nvkm: rename struct nvkm_control Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 043/156] drm/nouveau/nvkm: rename struct nvkm_ummu Ben Skeggs
                   ` (115 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

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

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/nvkm/subdev/vfn/uvfn.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/vfn/uvfn.c b/drivers/gpu/drm/nouveau/nvkm/subdev/vfn/uvfn.c
index c5460a14c541..fe35024d69ba 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/vfn/uvfn.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/vfn/uvfn.c
@@ -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;
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 043/156] drm/nouveau/nvkm: rename struct nvkm_ummu
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (41 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 042/156] drm/nouveau/nvkm: rename struct nvkm_uvfn Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 044/156] drm/nouveau/nvkm: rename struct nvkm_umem Ben Skeggs
                   ` (114 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

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

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 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(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.c
index e530bb8b3b17..62d69bb7fe90 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.c
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c
index 6870fda4b188..3f008402f451 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c
@@ -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;
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.h b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.h
index 0cd510dcfc68..35ae48758017 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.h
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.h
@@ -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;
 };
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c
index cf490ff2b9f1..bd51cdb1c578 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c
@@ -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;
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 044/156] drm/nouveau/nvkm: rename struct nvkm_umem
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (42 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 043/156] drm/nouveau/nvkm: rename struct nvkm_ummu Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 045/156] drm/nouveau/nvkm: rename struct nvkm_uvmm Ben Skeggs
                   ` (113 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

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

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 .../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(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.c
index 62d69bb7fe90..45ab7e445d58 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.c
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.h b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.h
index d56a594016cc..d2012ab625d3 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.h
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.h
@@ -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
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 045/156] drm/nouveau/nvkm: rename struct nvkm_uvmm
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (43 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 044/156] drm/nouveau/nvkm: rename struct nvkm_umem Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 046/156] drm/nouveau/nvkm: detach user handling from nvkm_fault_buffer Ben Skeggs
                   ` (112 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

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

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 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(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c
index bd51cdb1c578..6f261f81a2ad 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.h b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.h
index 71dab55e18a9..cf0172a320c3 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.h
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.h
@@ -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
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 046/156] drm/nouveau/nvkm: detach user handling from nvkm_fault_buffer
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (44 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 045/156] drm/nouveau/nvkm: rename struct nvkm_uvmm Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 047/156] drm/nouveau/nvkm: detach user handling from nvkm_disp Ben Skeggs
                   ` (111 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

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

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 .../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(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/fault/priv.h b/drivers/gpu/drm/nouveau/nvkm/subdev/fault/priv.h
index a5510332c402..3c26e76d1d3c 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/fault/priv.h
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/fault/priv.h
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/fault/user.c b/drivers/gpu/drm/nouveau/nvkm/subdev/fault/user.c
index c123e5893d76..6c3ede8b0321 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/fault/user.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/fault/user.c
@@ -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;
 }
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 047/156] drm/nouveau/nvkm: detach user handling from nvkm_disp
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (45 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 046/156] drm/nouveau/nvkm: detach user handling from nvkm_fault_buffer Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 048/156] drm/nouveau/nvkm: detach user handling from nvkm_conn Ben Skeggs
                   ` (110 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

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

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 .../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

diff --git a/drivers/gpu/drm/nouveau/include/nvkm/engine/disp.h b/drivers/gpu/drm/nouveau/include/nvkm/engine/disp.h
index 3e8db8280e2a..e954c36630f0 100644
--- a/drivers/gpu/drm/nouveau/include/nvkm/engine/disp.h
+++ b/drivers/gpu/drm/nouveau/include/nvkm/engine/disp.h
@@ -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 **);
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c
index b24eb1e560bc..e93646d53378 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c
@@ -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) {
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/chan.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/chan.c
index 4e43ee383c34..25fe9946957f 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/chan.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/chan.c
@@ -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);
 }
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gv100.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gv100.c
index cfa3698d3a2f..5787fd26e5c7 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gv100.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gv100.c
@@ -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)))
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/priv.h b/drivers/gpu/drm/nouveau/nvkm/engine/disp/priv.h
index a3fd7cb7c488..6f0b119dfd90 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/priv.h
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/priv.h
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uconn.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uconn.c
index 2dab6612c4fc..5e44ec977d42 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uconn.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uconn.c
@@ -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;
 }
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c
index 0268d1d75805..272d6a040a51 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c
@@ -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)
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.h b/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.h
new file mode 100644
index 000000000000..2918ecbca5d3
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.h
@@ -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
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uhead.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uhead.c
index f072cec16040..89e9b61914d6 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uhead.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uhead.c
@@ -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;
 }
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
index 377d0e0cef84..75669d5f8a42 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
@@ -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;
 }
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 048/156] drm/nouveau/nvkm: detach user handling from nvkm_conn
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (46 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 047/156] drm/nouveau/nvkm: detach user handling from nvkm_disp Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 049/156] drm/nouveau/nvkm: detach user handling from nvkm_outp Ben Skeggs
                   ` (109 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

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

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 .../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

diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/conn.h b/drivers/gpu/drm/nouveau/nvkm/engine/disp/conn.h
index 01c3146c7066..0eb15e28d0c8 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/conn.h
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/conn.h
@@ -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 *,
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uconn.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uconn.c
index 5e44ec977d42..773e49e557f8 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uconn.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uconn.c
@@ -19,8 +19,7 @@
  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
  */
-#define nvkm_uconn(p) container_of((p), struct nvkm_conn, object)
-#include "conn.h"
+#include "uconn.h"
 #include "outp.h"
 
 #include <core/client.h>
@@ -30,6 +29,11 @@
 
 #include <nvif/if0011.h>
 
+struct nvif_conn_priv {
+	struct nvkm_object object;
+	struct nvkm_conn *conn;
+};
+
 static int
 nvkm_uconn_uevent_gsp(struct nvkm_object *object, u64 token, u32 bits)
 {
@@ -94,7 +98,7 @@ nvkm_connector_is_dp_dms(u8 type)
 static int
 nvkm_uconn_uevent(struct nvkm_object *object, void *argv, u32 argc, struct nvkm_uevent *uevent)
 {
-	struct nvkm_conn *conn = nvkm_uconn(object);
+	struct nvkm_conn *conn = container_of(object, struct nvif_conn_priv, object)->conn;
 	struct nvkm_disp *disp = conn->disp;
 	struct nvkm_device *device = disp->engine.subdev.device;
 	struct nvkm_outp *outp;
@@ -151,13 +155,13 @@ nvkm_uconn_uevent(struct nvkm_object *object, void *argv, u32 argc, struct nvkm_
 static void *
 nvkm_uconn_dtor(struct nvkm_object *object)
 {
-	struct nvkm_conn *conn = nvkm_uconn(object);
-	struct nvkm_disp *disp = conn->disp;
+	struct nvif_conn_priv *uconn = container_of(object, typeof(*uconn), object);
+	struct nvkm_disp *disp = uconn->conn->disp;
 
 	spin_lock(&disp->user.lock);
-	conn->object.func = NULL;
+	uconn->conn->user = false;
 	spin_unlock(&disp->user.lock);
-	return NULL;
+	return uconn;
 }
 
 static const struct nvkm_object_func
@@ -173,7 +177,7 @@ nvkm_uconn_new(const struct nvkm_oclass *oclass, void *argv, u32 argc, struct nv
 	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;
+	struct nvif_conn_priv *uconn;
 
 	if (argc != sizeof(args->v0) || args->v0.version != 0)
 		return -ENOSYS;
@@ -188,39 +192,46 @@ nvkm_uconn_new(const struct nvkm_oclass *oclass, void *argv, u32 argc, struct nv
 	if (!conn)
 		return -EINVAL;
 
-	ret = -EBUSY;
-	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;
-		case DCB_CONNECTOR_TV_0     :
-		case DCB_CONNECTOR_TV_1     :
-		case DCB_CONNECTOR_TV_3     : args->v0.type = NVIF_CONN_V0_TV; break;
-		case DCB_CONNECTOR_DMS59_0  :
-		case DCB_CONNECTOR_DMS59_1  :
-		case DCB_CONNECTOR_DVI_I    : args->v0.type = NVIF_CONN_V0_DVI_I; break;
-		case DCB_CONNECTOR_DVI_D    : args->v0.type = NVIF_CONN_V0_DVI_D; break;
-		case DCB_CONNECTOR_LVDS     : args->v0.type = NVIF_CONN_V0_LVDS; break;
-		case DCB_CONNECTOR_LVDS_SPWG: args->v0.type = NVIF_CONN_V0_LVDS_SPWG; break;
-		case DCB_CONNECTOR_DMS59_DP0:
-		case DCB_CONNECTOR_DMS59_DP1:
-		case DCB_CONNECTOR_DP       :
-		case DCB_CONNECTOR_mDP      :
-		case DCB_CONNECTOR_USB_C    : args->v0.type = NVIF_CONN_V0_DP; break;
-		case DCB_CONNECTOR_eDP      : args->v0.type = NVIF_CONN_V0_EDP; break;
-		case DCB_CONNECTOR_HDMI_0   :
-		case DCB_CONNECTOR_HDMI_1   :
-		case DCB_CONNECTOR_HDMI_C   : args->v0.type = NVIF_CONN_V0_HDMI; break;
-		default:
-			WARN_ON(1);
-			ret = -EINVAL;
-			break;
-		}
+	switch (conn->info.type) {
+	case DCB_CONNECTOR_VGA      : args->v0.type = NVIF_CONN_V0_VGA; break;
+	case DCB_CONNECTOR_TV_0     :
+	case DCB_CONNECTOR_TV_1     :
+	case DCB_CONNECTOR_TV_3     : args->v0.type = NVIF_CONN_V0_TV; break;
+	case DCB_CONNECTOR_DMS59_0  :
+	case DCB_CONNECTOR_DMS59_1  :
+	case DCB_CONNECTOR_DVI_I    : args->v0.type = NVIF_CONN_V0_DVI_I; break;
+	case DCB_CONNECTOR_DVI_D    : args->v0.type = NVIF_CONN_V0_DVI_D; break;
+	case DCB_CONNECTOR_LVDS     : args->v0.type = NVIF_CONN_V0_LVDS; break;
+	case DCB_CONNECTOR_LVDS_SPWG: args->v0.type = NVIF_CONN_V0_LVDS_SPWG; break;
+	case DCB_CONNECTOR_DMS59_DP0:
+	case DCB_CONNECTOR_DMS59_DP1:
+	case DCB_CONNECTOR_DP       :
+	case DCB_CONNECTOR_mDP      :
+	case DCB_CONNECTOR_USB_C    : args->v0.type = NVIF_CONN_V0_DP; break;
+	case DCB_CONNECTOR_eDP      : args->v0.type = NVIF_CONN_V0_EDP; break;
+	case DCB_CONNECTOR_HDMI_0   :
+	case DCB_CONNECTOR_HDMI_1   :
+	case DCB_CONNECTOR_HDMI_C   : args->v0.type = NVIF_CONN_V0_HDMI; break;
+	default:
+		WARN_ON(1);
+		return -EINVAL;
+	}
 
-		nvkm_object_ctor(&nvkm_uconn, oclass, &conn->object);
-		*pobject = &conn->object;
-		ret = 0;
+	uconn = kzalloc(sizeof(*uconn), GFP_KERNEL);
+	if (!uconn)
+		return -ENOMEM;
+
+	spin_lock(&disp->user.lock);
+	if (conn->user) {
+		spin_unlock(&disp->user.lock);
+		kfree(uconn);
+		return -EBUSY;
 	}
+	conn->user = true;
 	spin_unlock(&disp->user.lock);
-	return ret;
+
+	nvkm_object_ctor(&nvkm_uconn, oclass, &uconn->object);
+	uconn->conn = conn;
+	*pobject = &uconn->object;
+	return 0;
 }
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uconn.h b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uconn.h
new file mode 100644
index 000000000000..f53d151e5b09
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uconn.h
@@ -0,0 +1,6 @@
+/* SPDX-License-Identifier: MIT */
+#ifndef __NVKM_UCONN_H__
+#define __NVKM_UCONN_H__
+#include "conn.h"
+
+#endif
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 049/156] drm/nouveau/nvkm: detach user handling from nvkm_outp
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (47 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 048/156] drm/nouveau/nvkm: detach user handling from nvkm_conn Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 050/156] drm/nouveau/nvkm: detach user handling from nvkm_uhead Ben Skeggs
                   ` (108 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

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

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 .../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

diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.h b/drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.h
index ebd2f499b4b1..1beba54f80eb 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.h
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.h
@@ -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,
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
index 75669d5f8a42..8d39dad73a40 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
@@ -19,8 +19,7 @@
  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
  */
-#define nvkm_uoutp(p) container_of((p), struct nvkm_outp, object)
-#include "outp.h"
+#include "uoutp.h"
 #include "dp.h"
 #include "head.h"
 #include "ior.h"
@@ -29,6 +28,11 @@
 
 #include <nvif/if0012.h>
 
+struct nvif_outp_priv {
+	struct nvkm_object object;
+	struct nvkm_outp *outp;
+};
+
 static int
 nvkm_uoutp_mthd_dp_mst_vcpi(struct nvkm_outp *outp, void *argv, u32 argc)
 {
@@ -543,7 +547,7 @@ nvkm_uoutp_mthd_noacquire(struct nvkm_outp *outp, u32 mthd, void *argv, u32 argc
 static int
 nvkm_uoutp_mthd(struct nvkm_object *object, u32 mthd, void *argv, u32 argc)
 {
-	struct nvkm_outp *outp = nvkm_uoutp(object);
+	struct nvkm_outp *outp = container_of(object, struct nvif_outp_priv, object)->outp;
 	struct nvkm_disp *disp = outp->disp;
 	bool invalid = false;
 	int ret;
@@ -567,13 +571,13 @@ nvkm_uoutp_mthd(struct nvkm_object *object, u32 mthd, void *argv, u32 argc)
 static void *
 nvkm_uoutp_dtor(struct nvkm_object *object)
 {
-	struct nvkm_outp *outp = nvkm_uoutp(object);
-	struct nvkm_disp *disp = outp->disp;
+	struct nvif_outp_priv *uoutp = container_of(object, typeof(*uoutp), object);
+	struct nvkm_disp *disp = uoutp->outp->disp;
 
 	spin_lock(&disp->user.lock);
-	outp->object.func = NULL;
+	uoutp->outp->user = false;
 	spin_unlock(&disp->user.lock);
-	return NULL;
+	return uoutp;
 }
 
 static const struct nvkm_object_func
@@ -589,7 +593,7 @@ nvkm_uoutp_new(const struct nvkm_oclass *oclass, void *argv, u32 argc, struct nv
 	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;
+	struct nvif_outp_priv *uoutp;
 
 	if (argc != sizeof(args->v0) || args->v0.version != 0)
 		return -ENOSYS;
@@ -604,63 +608,68 @@ nvkm_uoutp_new(const struct nvkm_oclass *oclass, void *argv, u32 argc, struct nv
 	if (!outp)
 		return -EINVAL;
 
-	ret = -EBUSY;
-	spin_lock(&disp->user.lock);
-	if (!outp->object.func) {
-		switch (outp->info.type) {
-		case DCB_OUTPUT_ANALOG:
-			args->v0.type = NVIF_OUTP_V0_TYPE_DAC;
-			args->v0.proto = NVIF_OUTP_V0_PROTO_RGB_CRT;
-			args->v0.rgb_crt.freq_max = outp->info.crtconf.maxfreq;
-			break;
-		case DCB_OUTPUT_TMDS:
-			if (!outp->info.location) {
-				args->v0.type = NVIF_OUTP_V0_TYPE_SOR;
-				args->v0.tmds.dual = (outp->info.tmdsconf.sor.link == 3);
-			} else {
-				args->v0.type = NVIF_OUTP_V0_TYPE_PIOR;
-				args->v0.tmds.dual = 0;
-			}
-			args->v0.proto = NVIF_OUTP_V0_PROTO_TMDS;
-			break;
-		case DCB_OUTPUT_LVDS:
+	switch (outp->info.type) {
+	case DCB_OUTPUT_ANALOG:
+		args->v0.type = NVIF_OUTP_V0_TYPE_DAC;
+		args->v0.proto = NVIF_OUTP_V0_PROTO_RGB_CRT;
+		args->v0.rgb_crt.freq_max = outp->info.crtconf.maxfreq;
+		break;
+	case DCB_OUTPUT_TMDS:
+		if (!outp->info.location) {
 			args->v0.type = NVIF_OUTP_V0_TYPE_SOR;
-			args->v0.proto = NVIF_OUTP_V0_PROTO_LVDS;
-			args->v0.lvds.acpi_edid = outp->info.lvdsconf.use_acpi_for_edid;
-			break;
-		case DCB_OUTPUT_DP:
-			if (!outp->info.location) {
-				args->v0.type = NVIF_OUTP_V0_TYPE_SOR;
-				args->v0.dp.aux = outp->info.i2c_index;
-			} else {
-				args->v0.type = NVIF_OUTP_V0_TYPE_PIOR;
-				args->v0.dp.aux = NVKM_I2C_AUX_EXT(outp->info.extdev);
-			}
-			args->v0.proto = NVIF_OUTP_V0_PROTO_DP;
-			args->v0.dp.mst = outp->dp.mst;
-			args->v0.dp.increased_wm = outp->dp.increased_wm;
-			args->v0.dp.link_nr = outp->info.dpconf.link_nr;
-			args->v0.dp.link_bw = outp->info.dpconf.link_bw * 27000;
-			break;
-		default:
-			WARN_ON(1);
-			ret = -EINVAL;
-			goto done;
+			args->v0.tmds.dual = (outp->info.tmdsconf.sor.link == 3);
+		} else {
+			args->v0.type = NVIF_OUTP_V0_TYPE_PIOR;
+			args->v0.tmds.dual = 0;
 		}
+		args->v0.proto = NVIF_OUTP_V0_PROTO_TMDS;
+		break;
+	case DCB_OUTPUT_LVDS:
+		args->v0.type = NVIF_OUTP_V0_TYPE_SOR;
+		args->v0.proto = NVIF_OUTP_V0_PROTO_LVDS;
+		args->v0.lvds.acpi_edid = outp->info.lvdsconf.use_acpi_for_edid;
+		break;
+	case DCB_OUTPUT_DP:
+		if (!outp->info.location) {
+			args->v0.type = NVIF_OUTP_V0_TYPE_SOR;
+			args->v0.dp.aux = outp->info.i2c_index;
+		} else {
+			args->v0.type = NVIF_OUTP_V0_TYPE_PIOR;
+			args->v0.dp.aux = NVKM_I2C_AUX_EXT(outp->info.extdev);
+		}
+		args->v0.proto = NVIF_OUTP_V0_PROTO_DP;
+		args->v0.dp.mst = outp->dp.mst;
+		args->v0.dp.increased_wm = outp->dp.increased_wm;
+		args->v0.dp.link_nr = outp->info.dpconf.link_nr;
+		args->v0.dp.link_bw = outp->info.dpconf.link_bw * 27000;
+		break;
+	default:
+		WARN_ON(1);
+		return -EINVAL;
+	}
 
-		if (outp->info.location)
-			args->v0.ddc = NVKM_I2C_BUS_EXT(outp->info.extdev);
-		else
-			args->v0.ddc = outp->info.i2c_index;
-		args->v0.heads = outp->info.heads;
-		args->v0.conn = outp->info.connector;
+	if (outp->info.location)
+		args->v0.ddc = NVKM_I2C_BUS_EXT(outp->info.extdev);
+	else
+		args->v0.ddc = outp->info.i2c_index;
+	args->v0.heads = outp->info.heads;
+	args->v0.conn = outp->info.connector;
 
-		nvkm_object_ctor(&nvkm_uoutp, oclass, &outp->object);
-		*pobject = &outp->object;
-		ret = 0;
-	}
+	uoutp = kzalloc(sizeof(*uoutp), GFP_KERNEL);
+	if (!uoutp)
+		return -ENOMEM;
 
-done:
+	spin_lock(&disp->user.lock);
+	if (outp->user) {
+		spin_unlock(&disp->user.lock);
+		kfree(uoutp);
+		return -EBUSY;
+	}
+	outp->user = true;
 	spin_unlock(&disp->user.lock);
-	return ret;
+
+	nvkm_object_ctor(&nvkm_uoutp, oclass, &uoutp->object);
+	uoutp->outp = outp;
+	*pobject = &uoutp->object;
+	return 0;
 }
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.h b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.h
new file mode 100644
index 000000000000..37ecd2891a1a
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.h
@@ -0,0 +1,6 @@
+/* SPDX-License-Identifier: MIT */
+#ifndef __NVKM_UOUTP_H__
+#define __NVKM_UOUTP_H__
+#include "outp.h"
+
+#endif
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 050/156] drm/nouveau/nvkm: detach user handling from nvkm_uhead
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (48 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 049/156] drm/nouveau/nvkm: detach user handling from nvkm_outp Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 051/156] drm/nouveau/nvkm: detach user handling from nvkm_disp_chan Ben Skeggs
                   ` (107 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

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

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 .../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

diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/head.h b/drivers/gpu/drm/nouveau/nvkm/engine/disp/head.h
index 856252bf559a..cd60e901d625 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/head.h
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/head.h
@@ -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);
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uhead.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uhead.c
index 89e9b61914d6..3be82e01a59a 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uhead.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uhead.c
@@ -19,18 +19,22 @@
  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
  */
-#define nvkm_uhead(p) container_of((p), struct nvkm_head, object)
-#include "head.h"
+#include "uhead.h"
 #include <core/event.h>
 
 #include <nvif/if0013.h>
 
 #include <nvif/event.h>
 
+struct nvif_head_priv {
+	struct nvkm_object object;
+	struct nvkm_head *head;
+};
+
 static int
 nvkm_uhead_uevent(struct nvkm_object *object, void *argv, u32 argc, struct nvkm_uevent *uevent)
 {
-	struct nvkm_head *head = nvkm_uhead(object);
+	struct nvkm_head *head = container_of(object, struct nvif_head_priv, object)->head;
 	union nvif_head_event_args *args = argv;
 
 	if (!uevent)
@@ -74,7 +78,7 @@ nvkm_uhead_mthd_scanoutpos(struct nvkm_head *head, void *argv, u32 argc)
 static int
 nvkm_uhead_mthd(struct nvkm_object *object, u32 mthd, void *argv, u32 argc)
 {
-	struct nvkm_head *head = nvkm_uhead(object);
+	struct nvkm_head *head = container_of(object, struct nvif_head_priv, object)->head;
 
 	switch (mthd) {
 	case NVIF_HEAD_V0_SCANOUTPOS: return nvkm_uhead_mthd_scanoutpos(head, argv, argc);
@@ -86,13 +90,13 @@ nvkm_uhead_mthd(struct nvkm_object *object, u32 mthd, void *argv, u32 argc)
 static void *
 nvkm_uhead_dtor(struct nvkm_object *object)
 {
-	struct nvkm_head *head = nvkm_uhead(object);
-	struct nvkm_disp *disp = head->disp;
+	struct nvif_head_priv *uhead = container_of(object, struct nvif_head_priv, object);
+	struct nvkm_disp *disp = uhead->head->disp;
 
 	spin_lock(&disp->user.lock);
-	head->object.func = NULL;
+	uhead->head->user = false;
 	spin_unlock(&disp->user.lock);
-	return NULL;
+	return uhead;
 }
 
 static const struct nvkm_object_func
@@ -109,20 +113,28 @@ nvkm_uhead_new(const struct nvkm_oclass *oclass, void *argv, u32 argc, struct nv
 	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;
+	struct nvif_head_priv *uhead;
 
 	if (argc != sizeof(args->v0) || args->v0.version != 0)
 		return -ENOSYS;
 	if (!(head = nvkm_head_find(disp, args->v0.id)))
 		return -EINVAL;
 
-	ret = -EBUSY;
+	uhead = kzalloc(sizeof(*uhead), GFP_KERNEL);
+	if (!uhead)
+		return -ENOMEM;
+
 	spin_lock(&disp->user.lock);
-	if (!head->object.func) {
-		nvkm_object_ctor(&nvkm_uhead, oclass, &head->object);
-		*pobject = &head->object;
-		ret = 0;
+	if (head->user) {
+		spin_unlock(&disp->user.lock);
+		kfree(uhead);
+		return -EBUSY;
 	}
+	head->user = true;
 	spin_unlock(&disp->user.lock);
-	return ret;
+
+	nvkm_object_ctor(&nvkm_uhead, oclass, &uhead->object);
+	uhead->head = head;
+	*pobject = &uhead->object;
+	return 0;
 }
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uhead.h b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uhead.h
new file mode 100644
index 000000000000..f19c9ae33707
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uhead.h
@@ -0,0 +1,6 @@
+/* SPDX-License-Identifier: MIT */
+#ifndef __NVKM_UHEAD_H__
+#define __NVKM_UHEAD_H__
+#include "head.h"
+
+#endif
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 051/156] drm/nouveau/nvkm: detach user handling from nvkm_disp_chan
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (49 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 050/156] drm/nouveau/nvkm: detach user handling from nvkm_uhead Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 052/156] drm/nouveau/nvkm: rename struct nvkm_ucgrp Ben Skeggs
                   ` (106 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

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

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 .../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(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/chan.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/chan.c
index 25fe9946957f..b34615dcc8eb 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/chan.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/chan.c
@@ -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;
 }
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/chan.h b/drivers/gpu/drm/nouveau/nvkm/engine/disp/chan.h
index 020290510157..8c212dde036f 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/chan.h
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/chan.h
@@ -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;
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.c
index 03a5f88a4b99..682628fe5b20 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.c
@@ -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;
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/r535.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/r535.c
index 027867c2a8c5..f94858bc64f9 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/r535.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/r535.c
@@ -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;
 }
 
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 052/156] drm/nouveau/nvkm: rename struct nvkm_ucgrp
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (50 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 051/156] drm/nouveau/nvkm: detach user handling from nvkm_disp_chan Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 053/156] drm/nouveau/nvkm: rename struct nvkm_uchan Ben Skeggs
                   ` (105 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

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

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/nvkm/engine/fifo/ucgrp.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/ucgrp.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/ucgrp.c
index 52c594dfb1b8..7c9a151b03a3 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/ucgrp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/ucgrp.c
@@ -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)
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 053/156] drm/nouveau/nvkm: rename struct nvkm_uchan
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (51 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 052/156] drm/nouveau/nvkm: rename struct nvkm_ucgrp Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 054/156] drm/nouveau/nvkm: move umem list to mmu Ben Skeggs
                   ` (104 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

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

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 .../gpu/drm/nouveau/nvkm/engine/fifo/uchan.c  | 21 +++++++++----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/uchan.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/uchan.c
index 9e56bcc166ed..3dbc424869b3 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/uchan.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/uchan.c
@@ -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;
 
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 054/156] drm/nouveau/nvkm: move umem list to mmu
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (52 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 053/156] drm/nouveau/nvkm: rename struct nvkm_uchan Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 055/156] drm/nouveau/disp: simplify hw user definition Ben Skeggs
                   ` (103 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: 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.

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 .../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(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/client.h b/drivers/gpu/drm/nouveau/include/nvkm/core/client.h
index 4045b9f5ef4e..f7f195d87838 100644
--- a/drivers/gpu/drm/nouveau/include/nvkm/core/client.h
+++ b/drivers/gpu/drm/nouveau/include/nvkm/core/client.h
@@ -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,
diff --git a/drivers/gpu/drm/nouveau/include/nvkm/subdev/mmu.h b/drivers/gpu/drm/nouveau/include/nvkm/subdev/mmu.h
index 935b1cacd528..f2d23bfdf29a 100644
--- a/drivers/gpu/drm/nouveau/include/nvkm/subdev/mmu.h
+++ b/drivers/gpu/drm/nouveau/include/nvkm/subdev/mmu.h
@@ -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 **);
diff --git a/drivers/gpu/drm/nouveau/nvkm/core/client.c b/drivers/gpu/drm/nouveau/nvkm/core/client.c
index b127676078b1..7dc425e67dd4 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/client.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/client.c
@@ -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;
 }
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/chan.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/chan.c
index b34615dcc8eb..d3c0537c08db 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/chan.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/chan.c
@@ -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);
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/uchan.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/uchan.c
index 3dbc424869b3..23d992413442 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/uchan.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/uchan.c
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/base.c
index b67ace7ae93c..7b949a43c372 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/base.c
@@ -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
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.c
index 45ab7e445d58..45f589eb5d78 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.c
@@ -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);
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c
index 6f261f81a2ad..761a50047b42 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c
@@ -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);
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 055/156] drm/nouveau/disp: simplify hw user definition
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (53 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 054/156] drm/nouveau/nvkm: move umem list to mmu Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 056/156] drm/nouveau/nvif: output oclass id in object dbg messages Ben Skeggs
                   ` (102 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- needed for upcoming changes to display channel allocation APIs

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 .../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(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/ad102.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/ad102.c
index 7f300a79aa29..f818828e3f04 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/ad102.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/ad102.c
@@ -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 },
 	},
 };
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c
index e93646d53378..6850c703ff2d 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c
@@ -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;
 	}
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/chan.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/chan.c
index d3c0537c08db..86938c633272 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/chan.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/chan.c
@@ -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;
 		}
 	}
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/g84.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/g84.c
index 1be97a68a83e..1ee61eb1faf2 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/g84.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/g84.c
@@ -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 },
 	},
 };
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/g94.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/g94.c
index 843a2661ce9d..7165b924e514 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/g94.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/g94.c
@@ -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 },
 	},
 };
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/ga102.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/ga102.c
index ab0a85c92430..c6b77e4d08a0 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/ga102.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/ga102.c
@@ -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 },
 	},
 };
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gf119.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gf119.c
index 83a1323600ae..5234edda8306 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gf119.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gf119.c
@@ -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 },
 	},
 };
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gk104.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gk104.c
index a3e2fbadade4..2f22d0cfc8ae 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gk104.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gk104.c
@@ -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 },
 	},
 };
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gk110.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gk110.c
index 1704aa381ee9..205c05ad0306 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gk110.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gk110.c
@@ -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 },
 	},
 };
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gm107.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gm107.c
index 688e123ad482..a57cf832e789 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gm107.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gm107.c
@@ -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 },
 	},
 };
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gm200.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gm200.c
index 511e7831b2f5..350b10d19288 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gm200.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gm200.c
@@ -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 },
 	},
 };
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gp100.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gp100.c
index 4070447bd800..c0a9e18f1ccb 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gp100.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gp100.c
@@ -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 },
 	},
 };
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gp102.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gp102.c
index 07e9aeec5e08..6513d0456749 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gp102.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gp102.c
@@ -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 },
 	},
 };
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gt200.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gt200.c
index 6f69c4e3ade2..b97970800a90 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gt200.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gt200.c
@@ -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 },
 	},
 };
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gt215.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gt215.c
index 6318721b66f6..ea75b23c38b3 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gt215.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gt215.c
@@ -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 },
 	},
 };
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gv100.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gv100.c
index 5787fd26e5c7..7876241e10e7 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gv100.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gv100.c
@@ -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 },
 	},
 };
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/mcp77.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/mcp77.c
index 841e3b69fcaf..3d065b77229b 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/mcp77.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/mcp77.c
@@ -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 },
 	},
 };
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/mcp89.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/mcp89.c
index e0c5fb6df3d7..3b25c147c0c0 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/mcp89.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/mcp89.c
@@ -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 },
 	},
 };
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/nv04.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/nv04.c
index e4cf11a33969..7ba9c84b027c 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/nv04.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/nv04.c
@@ -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
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.c
index 682628fe5b20..0625f35bffec 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.c
@@ -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 },
 	}
 };
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/priv.h b/drivers/gpu/drm/nouveau/nvkm/engine/disp/priv.h
index 6f0b119dfd90..82b16cc9212a 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/priv.h
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/priv.h
@@ -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 *);
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/r535.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/r535.c
index f94858bc64f9..067e5e7177d6 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/r535.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/r535.c
@@ -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)
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/tu102.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/tu102.c
index dcb9f8ba374c..21b945a88823 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/tu102.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/tu102.c
@@ -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 },
 	},
 };
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c
index 272d6a040a51..750db6a1eb44 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c
@@ -20,6 +20,7 @@
  * OTHER DEALINGS IN THE SOFTWARE.
  */
 #include "udisp.h"
+#include "chan.h"
 #include "conn.h"
 #include "head.h"
 #include "outp.h"
@@ -50,9 +51,51 @@ nvkm_udisp_sclass(struct nvkm_object *object, int index, struct nvkm_oclass *scl
 		return 0;
 	}
 
-	if (disp->func->user[index].ctor) {
-		sclass->base = disp->func->user[index].base;
-		sclass->ctor = disp->func->user[index].ctor;
+	if (disp->func->user.caps.oclass && index-- == 0) {
+		sclass->base = (struct nvkm_sclass) { -1, -1, disp->func->user.caps.oclass };
+		sclass->ctor = disp->func->user.caps.ctor;
+		return 0;
+	}
+
+	if (disp->func->user.core.oclass && index-- == 0) {
+		sclass->base = (struct nvkm_sclass) { 0, 0, disp->func->user.core.oclass };
+		sclass->ctor = nvkm_disp_core_new;
+		return 0;
+	}
+
+	if (disp->func->user.base.oclass && index-- == 0) {
+		sclass->base = (struct nvkm_sclass) { 0, 0, disp->func->user.base.oclass };
+		sclass->ctor = nvkm_disp_chan_new;
+		return 0;
+	}
+
+	if (disp->func->user.ovly.oclass && index-- == 0) {
+		sclass->base = (struct nvkm_sclass) { 0, 0, disp->func->user.ovly.oclass };
+		sclass->ctor = nvkm_disp_chan_new;
+		return 0;
+	}
+
+	if (disp->func->user.curs.oclass && index-- == 0) {
+		sclass->base = (struct nvkm_sclass) { 0, 0, disp->func->user.curs.oclass };
+		sclass->ctor = nvkm_disp_chan_new;
+		return 0;
+	}
+
+	if (disp->func->user.oimm.oclass && index-- == 0) {
+		sclass->base = (struct nvkm_sclass) { 0, 0, disp->func->user.oimm.oclass };
+		sclass->ctor = nvkm_disp_chan_new;
+		return 0;
+	}
+
+	if (disp->func->user.wndw.oclass && index-- == 0) {
+		sclass->base = (struct nvkm_sclass) { 0, 0, disp->func->user.wndw.oclass };
+		sclass->ctor = nvkm_disp_wndw_new;
+		return 0;
+	}
+
+	if (disp->func->user.wimm.oclass && index-- == 0) {
+		sclass->base = (struct nvkm_sclass) { 0, 0, disp->func->user.wimm.oclass };
+		sclass->ctor = nvkm_disp_wndw_new;
 		return 0;
 	}
 
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 056/156] drm/nouveau/nvif: output oclass id in object dbg messages
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (54 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 055/156] drm/nouveau/disp: simplify hw user definition Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 057/156] drm/nouveau/nvif: add alternate version of nvif_object_ctor() Ben Skeggs
                   ` (101 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- useful to know sometimes

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/include/nvif/printf.h | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/printf.h b/drivers/gpu/drm/nouveau/include/nvif/printf.h
index ec524b2faeae..10d8c8c90fa7 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/printf.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/printf.h
@@ -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
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 057/156] drm/nouveau/nvif: add alternate version of nvif_object_ctor()
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (55 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 056/156] drm/nouveau/nvif: output oclass id in object dbg messages Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 058/156] drm/nouveau/nvif: add alternate version of nvif_event_ctor() Ben Skeggs
                   ` (100 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

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

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 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(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv50/core.c b/drivers/gpu/drm/nouveau/dispnv50/core.c
index 1864f3e3bbc3..a9c3e53ef909 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/core.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/core.c
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/dispnv50/crc.c b/drivers/gpu/drm/nouveau/dispnv50/crc.c
index 9c942fbd836d..0864d36a06f2 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/crc.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/crc.c
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/dispnv50/wndw.c b/drivers/gpu/drm/nouveau/dispnv50/wndw.c
index 1dbf0e73b5de..19606755daf5 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/wndw.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/wndw.c
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/include/nvif/object.h b/drivers/gpu/drm/nouveau/include/nvif/object.h
index 8d205b6af46a..a84cdb423471 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/object.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/object.h
@@ -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 **);
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 9caadcdb3c29..9c6df2ba52d5 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -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);
diff --git a/drivers/gpu/drm/nouveau/nv17_fence.c b/drivers/gpu/drm/nouveau/nv17_fence.c
index 4415a6de680b..5b4ceac49225 100644
--- a/drivers/gpu/drm/nouveau/nv17_fence.c
+++ b/drivers/gpu/drm/nouveau/nv17_fence.c
@@ -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);
diff --git a/drivers/gpu/drm/nouveau/nv50_fence.c b/drivers/gpu/drm/nouveau/nv50_fence.c
index 8b76cb227f55..1d8792fdd89b 100644
--- a/drivers/gpu/drm/nouveau/nv50_fence.c
+++ b/drivers/gpu/drm/nouveau/nv50_fence.c
@@ -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);
diff --git a/drivers/gpu/drm/nouveau/nvif/object.c b/drivers/gpu/drm/nouveau/nvif/object.c
index 8a2a7bfec2f8..0e8340710c11 100644
--- a/drivers/gpu/drm/nouveau/nvif/object.c
+++ b/drivers/gpu/drm/nouveau/nvif/object.c
@@ -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;
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 058/156] drm/nouveau/nvif: add alternate version of nvif_event_ctor()
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (56 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 057/156] drm/nouveau/nvif: add alternate version of nvif_object_ctor() Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 059/156] drm/nouveau/nvif: move nvif<->nvkm interface definitions to driverif.h Ben Skeggs
                   ` (99 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

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

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/include/nvif/event.h | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/event.h b/drivers/gpu/drm/nouveau/include/nvif/event.h
index 68bf6635841f..1683e138c7f8 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/event.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/event.h
@@ -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 *);
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 059/156] drm/nouveau/nvif: move nvif<->nvkm interface definitions to driverif.h
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (57 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 058/156] drm/nouveau/nvif: add alternate version of nvif_event_ctor() Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 060/156] drm/nouveau/nvif: rework "new driver" api Ben Skeggs
                   ` (98 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

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

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 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

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driver.h b/drivers/gpu/drm/nouveau/include/nvif/driver.h
index 7b08ff769039..c31fc66a4765 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driver.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driver.h
@@ -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 *);
 
diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
new file mode 100644
index 000000000000..c5018452d372
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -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
diff --git a/drivers/gpu/drm/nouveau/nvif/client.c b/drivers/gpu/drm/nouveau/nvif/client.c
index 098831d92eac..c0f93f4df2bb 100644
--- a/drivers/gpu/drm/nouveau/nvif/client.c
+++ b/drivers/gpu/drm/nouveau/nvif/client.c
@@ -24,6 +24,7 @@
 
 #include <nvif/client.h>
 #include <nvif/driver.h>
+#include <nvif/driverif.h>
 #include <nvif/ioctl.h>
 
 #include <nvif/class.h>
diff --git a/drivers/gpu/drm/nouveau/nvif/driver.c b/drivers/gpu/drm/nouveau/nvif/driver.c
index acb708df2559..4548ed35c31e 100644
--- a/drivers/gpu/drm/nouveau/nvif/driver.c
+++ b/drivers/gpu/drm/nouveau/nvif/driver.c
@@ -22,6 +22,7 @@
  * Authors: Ben Skeggs
  */
 #include <nvif/driver.h>
+#include <nvif/driverif.h>
 #include <nvif/client.h>
 
 int
diff --git a/drivers/gpu/drm/nouveau/nvif/object.c b/drivers/gpu/drm/nouveau/nvif/object.c
index 0e8340710c11..a71e000ada91 100644
--- a/drivers/gpu/drm/nouveau/nvif/object.c
+++ b/drivers/gpu/drm/nouveau/nvif/object.c
@@ -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
diff --git a/drivers/gpu/drm/nouveau/nvkm/core/driver.c b/drivers/gpu/drm/nouveau/nvkm/core/driver.c
index 1f5273ff2225..0777b9af0656 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/driver.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/driver.c
@@ -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
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 060/156] drm/nouveau/nvif: rework "new driver" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (58 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 059/156] drm/nouveau/nvif: move nvif<->nvkm interface definitions to driverif.h Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 061/156] drm/nouveau/nvkm: remove device list Ben Skeggs
                   ` (97 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

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

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 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

diff --git a/drivers/gpu/drm/nouveau/include/nvif/client.h b/drivers/gpu/drm/nouveau/include/nvif/client.h
index 87dc55f8bde6..f8e4e25d6e86 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/client.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/client.h
@@ -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;
 };
 
diff --git a/drivers/gpu/drm/nouveau/include/nvif/driver.h b/drivers/gpu/drm/nouveau/include/nvif/driver.h
index c31fc66a4765..8ca210b0bca6 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driver.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driver.h
@@ -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
diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index c5018452d372..655bd389044d 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -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
diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/client.h b/drivers/gpu/drm/nouveau/include/nvkm/core/client.h
index f7f195d87838..e35aea7a751f 100644
--- a/drivers/gpu/drm/nouveau/include/nvkm/core/client.h
+++ b/drivers/gpu/drm/nouveau/include/nvkm/core/client.h
@@ -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 {                                         \
diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/driver.h b/drivers/gpu/drm/nouveau/include/nvkm/core/driver.h
new file mode 100644
index 000000000000..8ad2278e700a
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/include/nvkm/core/driver.h
@@ -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
diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/os.h b/drivers/gpu/drm/nouveau/include/nvkm/core/os.h
index 668338d7bda3..9d16413239d4 100644
--- a/drivers/gpu/drm/nouveau/include/nvkm/core/os.h
+++ b/drivers/gpu/drm/nouveau/include/nvkm/core/os.h
@@ -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
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 9c6df2ba52d5..d793afd929c9 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -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);
diff --git a/drivers/gpu/drm/nouveau/nvif/client.c b/drivers/gpu/drm/nouveau/nvif/client.c
index c0f93f4df2bb..4c4a856ab861 100644
--- a/drivers/gpu/drm/nouveau/nvif/client.c
+++ b/drivers/gpu/drm/nouveau/nvif/client.c
@@ -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;
 }
 
diff --git a/drivers/gpu/drm/nouveau/nvif/driver.c b/drivers/gpu/drm/nouveau/nvif/driver.c
index 4548ed35c31e..95515f2023f4 100644
--- a/drivers/gpu/drm/nouveau/nvif/driver.c
+++ b/drivers/gpu/drm/nouveau/nvif/driver.c
@@ -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;
 }
diff --git a/drivers/gpu/drm/nouveau/nvif/object.c b/drivers/gpu/drm/nouveau/nvif/object.c
index a71e000ada91..f172f632979b 100644
--- a/drivers/gpu/drm/nouveau/nvif/object.c
+++ b/drivers/gpu/drm/nouveau/nvif/object.c
@@ -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) {
diff --git a/drivers/gpu/drm/nouveau/nvkm/core/client.c b/drivers/gpu/drm/nouveau/nvkm/core/client.c
index 7dc425e67dd4..fa8d0795805e 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/client.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/client.c
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/nvkm/core/driver.c b/drivers/gpu/drm/nouveau/nvkm/core/driver.c
index 0777b9af0656..ea00b8724f24 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/driver.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/driver.c
@@ -25,8 +25,8 @@
 /*******************************************************************************
  * NVIF client driver - NVKM directly linked
  ******************************************************************************/
-
 #include <core/client.h>
+#include <core/driver.h>
 #include <core/event.h>
 #include <core/ioctl.h>
 
@@ -34,13 +34,13 @@
 #include <nvif/event.h>
 
 static void
-nvkm_driver_unmap(void *priv, void __iomem *ptr, u32 size)
+nvkm_driver_unmap(struct nvif_client_priv *client, void __iomem *ptr, u32 size)
 {
 	iounmap(ptr);
 }
 
 static void __iomem *
-nvkm_driver_map(void *priv, u64 handle, u32 size)
+nvkm_driver_map(struct nvif_client_priv *client, u64 handle, u32 size)
 {
 	return ioremap(handle, size);
 }
@@ -52,18 +52,14 @@ nvkm_driver_ioctl(void *priv, void *data, u32 size, void **hack)
 }
 
 static int
-nvkm_driver_resume(void *priv)
+nvkm_driver_resume(struct nvif_client_priv *client)
 {
-	struct nvkm_client *client = priv;
-
 	return nvkm_object_init(&client->object);
 }
 
 static int
-nvkm_driver_suspend(void *priv)
+nvkm_driver_suspend(struct nvif_client_priv *client)
 {
-	struct nvkm_client *client = priv;
-
 	return nvkm_object_fini(&client->object, true);
 }
 
@@ -79,20 +75,29 @@ nvkm_driver_event(u64 token, void *repv, u32 repc)
 	return NVKM_EVENT_DROP;
 }
 
-static int
-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_driver_event,
-			       (struct nvkm_client **)ppriv);
-}
-
-const struct nvif_driver
-nvif_driver_nvkm = {
+static const struct nvif_driver
+nvkm_driver = {
 	.name = "nvkm",
-	.init = nvkm_driver_init,
 	.suspend = nvkm_driver_suspend,
 	.resume = nvkm_driver_resume,
 	.ioctl = nvkm_driver_ioctl,
 	.map = nvkm_driver_map,
 	.unmap = nvkm_driver_unmap,
 };
+
+int
+nvkm_driver_ctor(struct nvkm_device *device, const struct nvif_driver **pdrv,
+		 const struct nvif_client_impl **pimpl, struct nvif_client_priv **ppriv)
+{
+	struct nvif_client_priv *client;
+	int ret;
+
+	ret = nvkm_client_new("driver", device, nvkm_driver_event, &client);
+	if (ret)
+		return ret;
+
+	*pdrv = &nvkm_driver;
+	*pimpl = &nvkm_client_impl;
+	*ppriv = client;
+	return 0;
+}
diff --git a/drivers/gpu/drm/nouveau/nvkm/device/user.c b/drivers/gpu/drm/nouveau/nvkm/device/user.c
index af5aa9e1e5ea..b30b2e1c590a 100644
--- a/drivers/gpu/drm/nouveau/nvkm/device/user.c
+++ b/drivers/gpu/drm/nouveau/nvkm/device/user.c
@@ -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;
 }
 
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 061/156] drm/nouveau/nvkm: remove device list
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (59 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 060/156] drm/nouveau/nvif: rework "new driver" api Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 062/156] drm/nouveau/nvif: rework driver "new client" api Ben Skeggs
                   ` (96 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- now unused

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 .../drm/nouveau/include/nvkm/core/device.h    |  3 --
 drivers/gpu/drm/nouveau/nvkm/device/base.c    | 34 -------------------
 2 files changed, 37 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/device.h b/drivers/gpu/drm/nouveau/include/nvkm/core/device.h
index 46afb877a296..efe1a0048328 100644
--- a/drivers/gpu/drm/nouveau/include/nvkm/core/device.h
+++ b/drivers/gpu/drm/nouveau/include/nvkm/core/device.h
@@ -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))
diff --git a/drivers/gpu/drm/nouveau/nvkm/device/base.c b/drivers/gpu/drm/nouveau/nvkm/device/base.c
index 3ce42de55aa9..036106ed09a5 100644
--- a/drivers/gpu/drm/nouveau/nvkm/device/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/device/base.c
@@ -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;
 }
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 062/156] drm/nouveau/nvif: rework driver "new client" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (60 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 061/156] drm/nouveau/nvkm: remove device list Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 063/156] drm/nouveau/nvif: rework client "new device" api Ben Skeggs
                   ` (95 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interface

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 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

diff --git a/drivers/gpu/drm/nouveau/include/nvif/class.h b/drivers/gpu/drm/nouveau/include/nvif/class.h
index 824e052dcc25..b6bba7231750 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/class.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/class.h
@@ -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
diff --git a/drivers/gpu/drm/nouveau/include/nvif/client.h b/drivers/gpu/drm/nouveau/include/nvif/client.h
index f8e4e25d6e86..1659e989df52 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/client.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/client.h
@@ -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 *);
diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 655bd389044d..a6f95c8475b1 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -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
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0000.h b/drivers/gpu/drm/nouveau/include/nvif/if0000.h
deleted file mode 100644
index 4b31496b37e1..000000000000
--- a/drivers/gpu/drm/nouveau/include/nvif/if0000.h
+++ /dev/null
@@ -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
diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/object.h b/drivers/gpu/drm/nouveau/include/nvkm/core/object.h
index 10107ef3ca49..9ab163d9a4d0 100644
--- a/drivers/gpu/drm/nouveau/include/nvkm/core/object.h
+++ b/drivers/gpu/drm/nouveau/include/nvkm/core/object.h
@@ -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,
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index d793afd929c9..5e4c706bf150 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -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);
diff --git a/drivers/gpu/drm/nouveau/nvif/client.c b/drivers/gpu/drm/nouveau/nvif/client.c
index 4c4a856ab861..0211fa76431f 100644
--- a/drivers/gpu/drm/nouveau/nvif/client.c
+++ b/drivers/gpu/drm/nouveau/nvif/client.c
@@ -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;
 }
diff --git a/drivers/gpu/drm/nouveau/nvkm/core/client.c b/drivers/gpu/drm/nouveau/nvkm/core/client.c
index fa8d0795805e..b57cc0d5a148 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/client.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/client.c
@@ -28,43 +28,25 @@
 #include <nvif/class.h>
 #include <nvif/driverif.h>
 #include <nvif/event.h>
-#include <nvif/if0000.h>
 #include <nvif/unpack.h>
 
 static int
-nvkm_uclient_new(const struct nvkm_oclass *oclass, void *argv, u32 argc,
-		 struct nvkm_object **pobject)
+nvkm_client_new_client(struct nvif_client_priv *parent,
+		       const struct nvif_client_impl **pimpl, struct nvif_client_priv **ppriv,
+		       u64 handle)
 {
-	union {
-		struct nvif_client_v0 v0;
-	} *args = argv;
 	struct nvkm_client *client;
-	int ret = -ENOSYS;
-
-	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, oclass->client->device,
-				      oclass->client->event, &client);
-		if (ret)
-			return ret;
-	} else
+	int ret;
+
+	ret = nvkm_client_new("client", parent->device, parent->event, &client);
+	if (ret)
 		return ret;
 
-	client->object.client = oclass->client;
-	client->object.handle = oclass->handle;
-	client->object.object = oclass->object;
-	client->debug = oclass->client->debug;
-	*pobject = &client->object;
-	return 0;
-}
+	*pimpl = &nvkm_client_impl;
+	*ppriv = client;
 
-static const struct nvkm_sclass
-nvkm_uclient_sclass = {
-	.oclass = NVIF_CLASS_CLIENT,
-	.minver = 0,
-	.maxver = 0,
-	.ctor = nvkm_uclient_new,
-};
+	return nvkm_object_link_rb(parent, &parent->object, handle, &client->object);
+}
 
 static void
 nvkm_client_del(struct nvif_client_priv *client)
@@ -77,6 +59,7 @@ nvkm_client_del(struct nvif_client_priv *client)
 const struct nvif_client_impl
 nvkm_client_impl = {
 	.del = nvkm_client_del,
+	.client.new = nvkm_client_new_client,
 };
 
 static int
@@ -93,8 +76,7 @@ nvkm_client_child_get(struct nvkm_object *object, int index,
 	const struct nvkm_sclass *sclass;
 
 	switch (index) {
-	case 0: sclass = &nvkm_uclient_sclass; break;
-	case 1: sclass = &nvkm_udevice_sclass; break;
+	case 0: sclass = &nvkm_udevice_sclass; break;
 	default:
 		return -EINVAL;
 	}
@@ -120,7 +102,7 @@ int
 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_oclass oclass = {};
 	struct nvkm_client *client;
 
 	if (!(client = *pclient = kzalloc(sizeof(*client), GFP_KERNEL)))
diff --git a/drivers/gpu/drm/nouveau/nvkm/core/object.c b/drivers/gpu/drm/nouveau/nvkm/core/object.c
index 390c265cf8af..d34a8ee1a0ae 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/object.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/object.c
@@ -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;
+}
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 063/156] drm/nouveau/nvif: rework client "new device" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (61 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 062/156] drm/nouveau/nvif: rework driver "new client" api Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 064/156] drm/nouveau/nvif: remove client from object rb Ben Skeggs
                   ` (94 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interface

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 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

diff --git a/drivers/gpu/drm/nouveau/include/nvif/device.h b/drivers/gpu/drm/nouveau/include/nvif/device.h
index fec76f4733a4..c0f8920f0e08 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/device.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/device.h
@@ -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;
 
diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index a6f95c8475b1..8f56798d6509 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -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
diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/device.h b/drivers/gpu/drm/nouveau/include/nvkm/core/device.h
index efe1a0048328..fff0d7dd0e1b 100644
--- a/drivers/gpu/drm/nouveau/include/nvkm/core/device.h
+++ b/drivers/gpu/drm/nouveau/include/nvkm/core/device.h
@@ -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);                               \
diff --git a/drivers/gpu/drm/nouveau/nvif/device.c b/drivers/gpu/drm/nouveau/nvif/device.c
index 24880931039f..bb95e80f1c81 100644
--- a/drivers/gpu/drm/nouveau/nvif/device.c
+++ b/drivers/gpu/drm/nouveau/nvif/device.c
@@ -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;
 }
diff --git a/drivers/gpu/drm/nouveau/nvkm/core/client.c b/drivers/gpu/drm/nouveau/nvkm/core/client.c
index b57cc0d5a148..1763e863115c 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/client.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/client.c
@@ -24,12 +24,28 @@
 #include <core/client.h>
 #include <core/device.h>
 #include <core/option.h>
+#include <device/user.h>
 
 #include <nvif/class.h>
 #include <nvif/driverif.h>
 #include <nvif/event.h>
 #include <nvif/unpack.h>
 
+static int
+nvkm_client_new_device(struct nvif_client_priv *client,
+		       const struct nvif_device_impl **pimpl, struct nvif_device_priv **ppriv,
+		       u64 handle)
+{
+	struct nvkm_object *object;
+	int ret;
+
+	ret = nvkm_udevice_new(client->device, pimpl, ppriv, &object);
+	if (ret)
+		return ret;
+
+	return nvkm_object_link_rb(client, &client->object, handle, object);
+}
+
 static int
 nvkm_client_new_client(struct nvif_client_priv *parent,
 		       const struct nvif_client_impl **pimpl, struct nvif_client_priv **ppriv,
@@ -60,32 +76,9 @@ const struct nvif_client_impl
 nvkm_client_impl = {
 	.del = nvkm_client_del,
 	.client.new = nvkm_client_new_client,
+	.device.new = nvkm_client_new_device,
 };
 
-static int
-nvkm_client_child_new(const struct nvkm_oclass *oclass,
-		      void *data, u32 size, struct nvkm_object **pobject)
-{
-	return oclass->base.ctor(oclass, data, size, pobject);
-}
-
-static int
-nvkm_client_child_get(struct nvkm_object *object, int index,
-		      struct nvkm_oclass *oclass)
-{
-	const struct nvkm_sclass *sclass;
-
-	switch (index) {
-	case 0: sclass = &nvkm_udevice_sclass; break;
-	default:
-		return -EINVAL;
-	}
-
-	oclass->ctor = nvkm_client_child_new;
-	oclass->base = *sclass;
-	return 0;
-}
-
 static void *
 nvkm_client_dtor(struct nvkm_object *object)
 {
@@ -95,7 +88,6 @@ nvkm_client_dtor(struct nvkm_object *object)
 static const struct nvkm_object_func
 nvkm_client = {
 	.dtor = nvkm_client_dtor,
-	.sclass = nvkm_client_child_get,
 };
 
 int
diff --git a/drivers/gpu/drm/nouveau/nvkm/device/user.c b/drivers/gpu/drm/nouveau/nvkm/device/user.c
index b30b2e1c590a..a46d448dc244 100644
--- a/drivers/gpu/drm/nouveau/nvkm/device/user.c
+++ b/drivers/gpu/drm/nouveau/nvkm/device/user.c
@@ -21,6 +21,7 @@
  *
  * Authors: Ben Skeggs
  */
+#include "user.h"
 #include "priv.h"
 #include "ctrl.h"
 
@@ -38,6 +39,8 @@
 struct nvif_device_priv {
 	struct nvkm_object object;
 	struct nvkm_device *device;
+
+	struct nvif_device_impl impl;
 };
 
 static int
@@ -187,6 +190,20 @@ nvkm_udevice_time(struct nvkm_udevice *udev, void *data, u32 size)
 	return ret;
 }
 
+static void
+nvkm_udevice_del(struct nvif_device_priv *udev)
+{
+	struct nvkm_object *object = &udev->object;
+
+	nvkm_object_fini(object, false);
+	nvkm_object_del(&object);
+}
+
+static const struct nvif_device_impl
+nvkm_udevice_impl = {
+	.del = nvkm_udevice_del,
+};
+
 static int
 nvkm_udevice_mthd(struct nvkm_object *object, u32 mthd, void *data, u32 size)
 {
@@ -318,26 +335,33 @@ nvkm_udevice = {
 	.sclass = nvkm_udevice_child_get,
 };
 
-static int
-nvkm_udevice_new(const struct nvkm_oclass *oclass, void *data, u32 size,
+int
+nvkm_udevice_new(struct nvkm_device *device,
+		 const struct nvif_device_impl **pimpl, struct nvif_device_priv **ppriv,
 		 struct nvkm_object **pobject)
 {
-	struct nvkm_client *client = oclass->client;
 	struct nvif_device_priv *udev;
+	int ret;
 
 	if (!(udev = kzalloc(sizeof(*udev), GFP_KERNEL)))
 		return -ENOMEM;
-	nvkm_object_ctor(&nvkm_udevice, oclass, &udev->object);
+
+	nvkm_object_ctor(&nvkm_udevice, &(struct nvkm_oclass) {}, &udev->object);
+	udev->device = device;
+
+	ret = nvkm_udevice_init(&udev->object);
+	if (ret)
+		goto done;
+
+	udev->impl = nvkm_udevice_impl;
+
+	*pimpl = &udev->impl;
+	*ppriv = udev;
 	*pobject = &udev->object;
 
-	udev->device = client->device;
-	return 0;
-}
+done:
+	if (ret)
+		nvkm_udevice_del(udev);
 
-const struct nvkm_sclass
-nvkm_udevice_sclass = {
-	.oclass = NV_DEVICE,
-	.minver = 0,
-	.maxver = 0,
-	.ctor = nvkm_udevice_new,
-};
+	return ret;
+}
diff --git a/drivers/gpu/drm/nouveau/nvkm/device/user.h b/drivers/gpu/drm/nouveau/nvkm/device/user.h
new file mode 100644
index 000000000000..fb3f94a58960
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/nvkm/device/user.h
@@ -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
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 064/156] drm/nouveau/nvif: remove client from object rb
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (62 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 063/156] drm/nouveau/nvif: rework client "new device" api Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 065/156] drm/nouveau/nvif: rework device "sclass" api Ben Skeggs
                   ` (93 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- no more users

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 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(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 8f56798d6509..39e965a184fd 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -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 {
diff --git a/drivers/gpu/drm/nouveau/nvif/client.c b/drivers/gpu/drm/nouveau/nvif/client.c
index 0211fa76431f..6b3c7b28b212 100644
--- a/drivers/gpu/drm/nouveau/nvif/client.c
+++ b/drivers/gpu/drm/nouveau/nvif/client.c
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/nvkm/core/client.c b/drivers/gpu/drm/nouveau/nvkm/core/client.c
index 1763e863115c..a77014b342c0 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/client.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/client.c
@@ -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
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 065/156] drm/nouveau/nvif: rework device "sclass" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (63 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 064/156] drm/nouveau/nvif: remove client from object rb Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 066/156] drm/nouveau/nvif: rework device "map" api Ben Skeggs
                   ` (92 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interface

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 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

diff --git a/drivers/gpu/drm/nouveau/include/nvif/disp.h b/drivers/gpu/drm/nouveau/include/nvif/disp.h
index 56eb7293e01c..c4f428f268ea 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/disp.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/disp.h
@@ -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
diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 39e965a184fd..9ac4857714c7 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -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 {
diff --git a/drivers/gpu/drm/nouveau/nouveau_abi16.c b/drivers/gpu/drm/nouveau/nouveau_abi16.c
index 2648e42e0496..23f8b448a30a 100644
--- a/drivers/gpu/drm/nouveau/nouveau_abi16.c
+++ b/drivers/gpu/drm/nouveau/nouveau_abi16.c
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/nouveau_chan.c b/drivers/gpu/drm/nouveau/nouveau_chan.c
index 7977bb353c92..f9592eb0a47b 100644
--- a/drivers/gpu/drm/nouveau/nouveau_chan.c
+++ b/drivers/gpu/drm/nouveau/nouveau_chan.c
@@ -253,42 +253,43 @@ static int
 nouveau_channel_ctor(struct nouveau_cli *cli, bool priv, u64 runm,
 		     struct nouveau_channel **pchan)
 {
-	const struct nvif_mclass hosts[] = {
-		{  AMPERE_CHANNEL_GPFIFO_B, 0 },
-		{  AMPERE_CHANNEL_GPFIFO_A, 0 },
-		{  TURING_CHANNEL_GPFIFO_A, 0 },
-		{   VOLTA_CHANNEL_GPFIFO_A, 0 },
-		{  PASCAL_CHANNEL_GPFIFO_A, 0 },
-		{ MAXWELL_CHANNEL_GPFIFO_A, 0 },
-		{  KEPLER_CHANNEL_GPFIFO_B, 0 },
-		{  KEPLER_CHANNEL_GPFIFO_A, 0 },
-		{   FERMI_CHANNEL_GPFIFO  , 0 },
-		{     G82_CHANNEL_GPFIFO  , 0 },
-		{    NV50_CHANNEL_GPFIFO  , 0 },
-		{    NV40_CHANNEL_DMA     , 0 },
-		{    NV17_CHANNEL_DMA     , 0 },
-		{    NV10_CHANNEL_DMA     , 0 },
-		{    NV03_CHANNEL_DMA     , 0 },
-		{}
-	};
+	struct nvif_device *device = &cli->device;
+	const u32 oclass = device->impl->fifo.chan.oclass;
 	struct {
 		struct nvif_chan_v0 chan;
 		char name[TASK_COMM_LEN+16];
 	} args;
-	struct nvif_device *device = &cli->device;
 	struct nouveau_channel *chan;
 	const u64 plength = 0x10000;
 	const u64 ioffset = plength;
 	const u64 ilength = 0x02000;
 	char name[TASK_COMM_LEN];
-	int cid, ret;
+	int ret;
 	u64 size;
 
-	cid = nvif_mclass(&device->object, hosts);
-	if (cid < 0)
-		return cid;
+	switch (oclass) {
+	case  AMPERE_CHANNEL_GPFIFO_B:
+	case  AMPERE_CHANNEL_GPFIFO_A:
+	case  TURING_CHANNEL_GPFIFO_A:
+	case   VOLTA_CHANNEL_GPFIFO_A:
+	case  PASCAL_CHANNEL_GPFIFO_A:
+	case MAXWELL_CHANNEL_GPFIFO_A:
+	case  KEPLER_CHANNEL_GPFIFO_B:
+	case  KEPLER_CHANNEL_GPFIFO_A:
+	case   FERMI_CHANNEL_GPFIFO  :
+	case     G82_CHANNEL_GPFIFO  :
+	case    NV50_CHANNEL_GPFIFO  :
+	case    NV40_CHANNEL_DMA     :
+	case    NV17_CHANNEL_DMA     :
+	case    NV10_CHANNEL_DMA     :
+	case    NV03_CHANNEL_DMA     :
+		break;
+	default:
+		NV_PRINTK(err, cli, "No supported host channel class (0x%04x)", oclass);
+		return -ENODEV;
+	}
 
-	if (hosts[cid].oclass < NV50_CHANNEL_GPFIFO)
+	if (oclass < NV50_CHANNEL_GPFIFO)
 		size = plength;
 	else
 		size = ioffset + ilength;
@@ -306,14 +307,14 @@ nouveau_channel_ctor(struct nouveau_cli *cli, bool priv, u64 runm,
 	args.chan.runq = 0;
 	args.chan.priv = priv;
 	args.chan.devm = BIT(0);
-	if (hosts[cid].oclass < NV50_CHANNEL_GPFIFO) {
+	if (oclass < NV50_CHANNEL_GPFIFO) {
 		args.chan.vmm = 0;
 		args.chan.ctxdma = nvif_handle(&chan->push.ctxdma);
 		args.chan.offset = chan->push.addr;
 		args.chan.length = 0;
 	} else {
 		args.chan.vmm = nvif_handle(&chan->vmm->vmm.object);
-		if (hosts[cid].oclass < FERMI_CHANNEL_GPFIFO)
+		if (oclass < FERMI_CHANNEL_GPFIFO)
 			args.chan.ctxdma = nvif_handle(&chan->push.ctxdma);
 		else
 			args.chan.ctxdma = 0;
@@ -324,7 +325,7 @@ nouveau_channel_ctor(struct nouveau_cli *cli, bool priv, u64 runm,
 	args.chan.ouserd = 0;
 
 	/* allocate userd */
-	if (hosts[cid].oclass >= VOLTA_CHANNEL_GPFIFO_A) {
+	if (oclass >= VOLTA_CHANNEL_GPFIFO_A) {
 		ret = nvif_mem_ctor(&cli->mmu, "abi16ChanUSERD", NVIF_CLASS_MEM_GF100,
 				    NVIF_MEM_VRAM | NVIF_MEM_COHERENT | NVIF_MEM_MAPPABLE,
 				    0, PAGE_SIZE, NULL, 0, &chan->mem_userd);
@@ -342,7 +343,7 @@ nouveau_channel_ctor(struct nouveau_cli *cli, bool priv, u64 runm,
 	get_task_comm(name, current);
 	snprintf(args.name, sizeof(args.name), "%s[%d]", name, task_pid_nr(current));
 
-	ret = nvif_object_ctor(&device->object, "abi16ChanUser", 0, hosts[cid].oclass,
+	ret = nvif_object_ctor(&device->object, "abi16ChanUser", 0, oclass,
 			       &args, sizeof(args), &chan->user);
 	if (ret) {
 		nouveau_channel_del(pchan);
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c
index f28f9a857458..27b69032fd9e 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 5e4c706bf150..a37e08f0fd77 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -422,9 +422,8 @@ nouveau_accel_fini(struct nouveau_drm *drm)
 static void
 nouveau_accel_init(struct nouveau_drm *drm)
 {
-	struct nvif_device *device = &drm->client.device;
-	struct nvif_sclass *sclass;
-	int ret, i, n;
+	struct nvif_device *device = &drm->device;
+	int ret;
 
 	if (nouveau_noaccel)
 		return;
@@ -434,48 +433,40 @@ nouveau_accel_init(struct nouveau_drm *drm)
 	if (ret)
 		return;
 
-	/*XXX: this is crap, but the fence/channel stuff is a little
-	 *     backwards in some places.  this will be fixed.
-	 */
-	ret = n = nvif_object_sclass_get(&device->object, &sclass);
-	if (ret < 0)
-		return;
-
-	for (ret = -ENOSYS, i = 0; i < n; i++) {
-		switch (sclass[i].oclass) {
-		case NV03_CHANNEL_DMA:
-			ret = nv04_fence_create(drm);
-			break;
-		case NV10_CHANNEL_DMA:
-			ret = nv10_fence_create(drm);
-			break;
-		case NV17_CHANNEL_DMA:
-		case NV40_CHANNEL_DMA:
-			ret = nv17_fence_create(drm);
-			break;
-		case NV50_CHANNEL_GPFIFO:
-			ret = nv50_fence_create(drm);
-			break;
-		case G82_CHANNEL_GPFIFO:
-			ret = nv84_fence_create(drm);
-			break;
-		case FERMI_CHANNEL_GPFIFO:
-		case KEPLER_CHANNEL_GPFIFO_A:
-		case KEPLER_CHANNEL_GPFIFO_B:
-		case MAXWELL_CHANNEL_GPFIFO_A:
-		case PASCAL_CHANNEL_GPFIFO_A:
-		case VOLTA_CHANNEL_GPFIFO_A:
-		case TURING_CHANNEL_GPFIFO_A:
-		case AMPERE_CHANNEL_GPFIFO_A:
-		case AMPERE_CHANNEL_GPFIFO_B:
-			ret = nvc0_fence_create(drm);
-			break;
-		default:
-			break;
-		}
+	switch (device->impl->fifo.chan.oclass) {
+	case NV03_CHANNEL_DMA:
+		ret = nv04_fence_create(drm);
+		break;
+	case NV10_CHANNEL_DMA:
+		ret = nv10_fence_create(drm);
+		break;
+	case NV17_CHANNEL_DMA:
+	case NV40_CHANNEL_DMA:
+		ret = nv17_fence_create(drm);
+		break;
+	case NV50_CHANNEL_GPFIFO:
+		ret = nv50_fence_create(drm);
+		break;
+	case G82_CHANNEL_GPFIFO:
+		ret = nv84_fence_create(drm);
+		break;
+	case FERMI_CHANNEL_GPFIFO:
+	case KEPLER_CHANNEL_GPFIFO_A:
+	case KEPLER_CHANNEL_GPFIFO_B:
+	case MAXWELL_CHANNEL_GPFIFO_A:
+	case PASCAL_CHANNEL_GPFIFO_A:
+	case VOLTA_CHANNEL_GPFIFO_A:
+	case TURING_CHANNEL_GPFIFO_A:
+	case AMPERE_CHANNEL_GPFIFO_A:
+	case AMPERE_CHANNEL_GPFIFO_B:
+		ret = nvc0_fence_create(drm);
+		break;
+	default:
+		WARN_ON(1);
+		ret = -ENODEV;
+		break;
 	}
 
-	nvif_object_sclass_put(&sclass);
 	if (ret) {
 		NV_ERROR(drm, "failed to initialise sync subsystem, %d\n", ret);
 		nouveau_accel_fini(drm);
@@ -534,13 +525,6 @@ nouveau_parent = {
 static int
 nouveau_drm_device_init(struct drm_device *dev, struct nvkm_device *nvkm)
 {
-	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;
 	const struct nvif_driver *driver;
 	const struct nvif_client_impl *impl;
@@ -576,13 +560,17 @@ nouveau_drm_device_init(struct drm_device *dev, struct nvkm_device *nvkm)
 		goto fail_nvif;
 	}
 
-	ret = nvif_mclass(&drm->device.object, mmus);
-	if (ret < 0) {
-		NV_ERROR(drm, "No supported MMU class\n");
+	switch (drm->device.impl->mmu.oclass) {
+	case NVIF_CLASS_MMU_GF100:
+	case NVIF_CLASS_MMU_NV50:
+	case NVIF_CLASS_MMU_NV04:
+		break;
+	default:
+		NV_ERROR(drm, "No supported MMU class (0x%04x)\n", drm->device.impl->mmu.oclass);
 		goto fail_nvif;
 	}
 
-	ret = nvif_mmu_ctor(&drm->device.object, "drmMmu", mmus[ret].oclass, &drm->mmu);
+	ret = nvif_mmu_ctor(&drm->device.object, "drmMmu", drm->device.impl->mmu.oclass, &drm->mmu);
 	if (ret) {
 		NV_ERROR(drm, "MMU allocation failed: %d\n", ret);
 		goto fail_nvif;
diff --git a/drivers/gpu/drm/nouveau/nouveau_svm.c b/drivers/gpu/drm/nouveau/nouveau_svm.c
index b4da82ddbb6b..477336672652 100644
--- a/drivers/gpu/drm/nouveau/nouveau_svm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_svm.c
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/nvif/disp.c b/drivers/gpu/drm/nouveau/nvif/disp.c
index 14da22fa3b5b..875c63877468 100644
--- a/drivers/gpu/drm/nouveau/nvif/disp.c
+++ b/drivers/gpu/drm/nouveau/nvif/disp.c
@@ -33,43 +33,43 @@ nvif_disp_dtor(struct nvif_disp *disp)
 }
 
 int
-nvif_disp_ctor(struct nvif_device *device, const char *name, s32 oclass, struct nvif_disp *disp)
+nvif_disp_ctor(struct nvif_device *device, const char *name, struct nvif_disp *disp)
 {
-	static const struct nvif_mclass disps[] = {
-		{ AD102_DISP, 0 },
-		{ GA102_DISP, 0 },
-		{ TU102_DISP, 0 },
-		{ GV100_DISP, 0 },
-		{ GP102_DISP, 0 },
-		{ GP100_DISP, 0 },
-		{ GM200_DISP, 0 },
-		{ GM107_DISP, 0 },
-		{ GK110_DISP, 0 },
-		{ GK104_DISP, 0 },
-		{ GF110_DISP, 0 },
-		{ GT214_DISP, 0 },
-		{ GT206_DISP, 0 },
-		{ GT200_DISP, 0 },
-		{   G82_DISP, 0 },
-		{  NV50_DISP, 0 },
-		{  NV04_DISP, 0 },
-		{}
-	};
+	const u32 oclass = device->impl->disp.oclass;
 	struct nvif_disp_v0 args;
-	int cid, ret;
+	int ret;
 
-	cid = nvif_sclass(&device->object, disps, oclass);
 	disp->object.client = NULL;
-	if (cid < 0) {
+
+	switch (oclass) {
+	case AD102_DISP:
+	case GA102_DISP:
+	case TU102_DISP:
+	case GV100_DISP:
+	case GP102_DISP:
+	case GP100_DISP:
+	case GM200_DISP:
+	case GM107_DISP:
+	case GK110_DISP:
+	case GK104_DISP:
+	case GF110_DISP:
+	case GT214_DISP:
+	case GT206_DISP:
+	case GT200_DISP:
+	case   G82_DISP:
+	case  NV50_DISP:
+	case  NV04_DISP:
+		break;
+	default:
 		NVIF_DEBUG(&device->object, "[NEW disp%04x] not supported", oclass);
-		return cid;
+		return -ENODEV;
 	}
 
 	args.version = 0;
 
 	ret = nvif_object_ctor(&device->object, name ?: "nvifDisp", 0,
-			       disps[cid].oclass, &args, sizeof(args), &disp->object);
-	NVIF_ERRON(ret, &device->object, "[NEW disp%04x]", disps[cid].oclass);
+			       oclass, &args, sizeof(args), &disp->object);
+	NVIF_ERRON(ret, &device->object, "[NEW disp%04x]", oclass);
 	if (ret)
 		return ret;
 
diff --git a/drivers/gpu/drm/nouveau/nvif/user.c b/drivers/gpu/drm/nouveau/nvif/user.c
index b648a5e036af..d8d37c1c8169 100644
--- a/drivers/gpu/drm/nouveau/nvif/user.c
+++ b/drivers/gpu/drm/nouveau/nvif/user.c
@@ -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;
 }
diff --git a/drivers/gpu/drm/nouveau/nvkm/device/user.c b/drivers/gpu/drm/nouveau/nvkm/device/user.c
index a46d448dc244..f55088849a0c 100644
--- a/drivers/gpu/drm/nouveau/nvkm/device/user.c
+++ b/drivers/gpu/drm/nouveau/nvkm/device/user.c
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/Kbuild b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/Kbuild
index aff92848abfe..fa61bb128885 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/Kbuild
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/Kbuild
@@ -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
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/ufifo.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/ufifo.c
new file mode 100644
index 000000000000..3f0bd70f614e
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/ufifo.c
@@ -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;
+}
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/ufifo.h b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/ufifo.h
new file mode 100644
index 000000000000..778e81052502
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/ufifo.h
@@ -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
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 066/156] drm/nouveau/nvif: rework device "map" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (64 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 065/156] drm/nouveau/nvif: rework device "sclass" api Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 067/156] drm/nouveau/nvif: rework device "info v0" api Ben Skeggs
                   ` (91 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interface

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 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(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/device.h b/drivers/gpu/drm/nouveau/include/nvif/device.h
index c0f8920f0e08..27526d5811cf 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/device.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/device.h
@@ -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 {
diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 9ac4857714c7..03c4803f6492 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/include/nvif/object.h b/drivers/gpu/drm/nouveau/include/nvif/object.h
index a84cdb423471..b3e66425f310 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/object.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/object.h
@@ -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 *);
diff --git a/drivers/gpu/drm/nouveau/nvif/device.c b/drivers/gpu/drm/nouveau/nvif/device.c
index bb95e80f1c81..a0bc047ae28d 100644
--- a/drivers/gpu/drm/nouveau/nvif/device.c
+++ b/drivers/gpu/drm/nouveau/nvif/device.c
@@ -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;
 }
diff --git a/drivers/gpu/drm/nouveau/nvif/object.c b/drivers/gpu/drm/nouveau/nvif/object.c
index f172f632979b..d0f4ddca085e 100644
--- a/drivers/gpu/drm/nouveau/nvif/object.c
+++ b/drivers/gpu/drm/nouveau/nvif/object.c
@@ -178,6 +178,52 @@ nvif_object_unmap(struct nvif_object *object)
 	}
 }
 
+int
+nvif_object_unmap_cpu(struct nvif_map *map)
+{
+	struct nvif_client *client;
+
+	if (!map->ptr || map->impl->type == NVIF_MAP_VA)
+		return 0;
+	if (map->impl->type != NVIF_MAP_IO)
+		return -EINVAL;
+
+	client = map->object->client;
+	client->driver->unmap(client->priv, map->ptr, map->impl->length);
+	map->ptr = NULL;
+	return 0;
+}
+
+int
+nvif_object_map_cpu(struct nvif_object *object,
+		    const struct nvif_mapinfo *impl, struct nvif_map *map)
+{
+	struct nvif_client *client = object->client;
+	void *ptr = NULL;
+
+	switch (impl->type) {
+	case NVIF_MAP_IO:
+		ptr = client->driver->map(client->priv, impl->handle, impl->length);
+		break;
+	case NVIF_MAP_VA:
+		ptr = (void **)(unsigned long)impl->handle;
+		break;
+	default:
+		WARN_ON(1);
+		return -EINVAL;
+	}
+
+	if (!ptr)
+		return -EFAULT;
+
+	map->object = object;
+	map->impl = impl;
+	map->ptr = ptr;
+
+	object->map.ptr = map->ptr; /*FIXME: needed by nvif_rd/wr */
+	return 0;
+}
+
 int
 nvif_object_map(struct nvif_object *object, void *argv, u32 argc)
 {
diff --git a/drivers/gpu/drm/nouveau/nvkm/device/user.c b/drivers/gpu/drm/nouveau/nvkm/device/user.c
index f55088849a0c..229245b03719 100644
--- a/drivers/gpu/drm/nouveau/nvkm/device/user.c
+++ b/drivers/gpu/drm/nouveau/nvkm/device/user.c
@@ -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;
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 067/156] drm/nouveau/nvif: rework device "info v0" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (65 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 066/156] drm/nouveau/nvif: rework device "map" api Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 068/156] drm/nouveau/nvif: rework device "info v1" api Ben Skeggs
                   ` (90 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interface

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 .../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(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 03c4803f6492..6152eabd4352 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/nvif/device.c b/drivers/gpu/drm/nouveau/nvif/device.c
index a0bc047ae28d..7c28f9764936 100644
--- a/drivers/gpu/drm/nouveau/nvif/device.c
+++ b/drivers/gpu/drm/nouveau/nvif/device.c
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/nvkm/device/user.c b/drivers/gpu/drm/nouveau/nvkm/device/user.c
index 229245b03719..589cb31853e6 100644
--- a/drivers/gpu/drm/nouveau/nvkm/device/user.c
+++ b/drivers/gpu/drm/nouveau/nvkm/device/user.c
@@ -80,10 +80,7 @@ nvkm_udevice_info(struct nvkm_udevice *udev, void *data, u32 size)
 {
 	struct nvkm_object *object = &udev->object;
 	struct nvkm_device *device = udev->device;
-	struct nvkm_fb *fb = device->fb;
-	struct nvkm_instmem *imem = device->imem;
 	union {
-		struct nv_device_info_v0 v0;
 		struct nv_device_info_v1 v1;
 	} *args = data;
 	int ret = -ENOSYS, i;
@@ -98,78 +95,9 @@ nvkm_udevice_info(struct nvkm_udevice *udev, void *data, u32 size)
 			return 0;
 		}
 		return -EINVAL;
-	} else
-	if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
-		nvif_ioctl(object, "device info vers %d\n", args->v0.version);
 	} else
 		return ret;
 
-	switch (device->chipset) {
-	case 0x01a:
-	case 0x01f:
-	case 0x04c:
-	case 0x04e:
-	case 0x063:
-	case 0x067:
-	case 0x068:
-	case 0x0aa:
-	case 0x0ac:
-	case 0x0af:
-		args->v0.platform = NV_DEVICE_INFO_V0_IGP;
-		break;
-	default:
-		switch (device->type) {
-		case NVKM_DEVICE_PCI:
-			args->v0.platform = NV_DEVICE_INFO_V0_PCI;
-			break;
-		case NVKM_DEVICE_AGP:
-			args->v0.platform = NV_DEVICE_INFO_V0_AGP;
-			break;
-		case NVKM_DEVICE_PCIE:
-			args->v0.platform = NV_DEVICE_INFO_V0_PCIE;
-			break;
-		case NVKM_DEVICE_TEGRA:
-			args->v0.platform = NV_DEVICE_INFO_V0_SOC;
-			break;
-		default:
-			WARN_ON(1);
-			break;
-		}
-		break;
-	}
-
-	switch (device->card_type) {
-	case NV_04: args->v0.family = NV_DEVICE_INFO_V0_TNT; break;
-	case NV_10:
-	case NV_11: args->v0.family = NV_DEVICE_INFO_V0_CELSIUS; break;
-	case NV_20: args->v0.family = NV_DEVICE_INFO_V0_KELVIN; break;
-	case NV_30: args->v0.family = NV_DEVICE_INFO_V0_RANKINE; break;
-	case NV_40: args->v0.family = NV_DEVICE_INFO_V0_CURIE; break;
-	case NV_50: args->v0.family = NV_DEVICE_INFO_V0_TESLA; break;
-	case NV_C0: args->v0.family = NV_DEVICE_INFO_V0_FERMI; break;
-	case NV_E0: args->v0.family = NV_DEVICE_INFO_V0_KEPLER; break;
-	case GM100: args->v0.family = NV_DEVICE_INFO_V0_MAXWELL; break;
-	case GP100: args->v0.family = NV_DEVICE_INFO_V0_PASCAL; break;
-	case GV100: args->v0.family = NV_DEVICE_INFO_V0_VOLTA; break;
-	case TU100: args->v0.family = NV_DEVICE_INFO_V0_TURING; break;
-	case GA100: args->v0.family = NV_DEVICE_INFO_V0_AMPERE; break;
-	case AD100: args->v0.family = NV_DEVICE_INFO_V0_ADA; break;
-	default:
-		args->v0.family = 0;
-		break;
-	}
-
-	args->v0.chipset  = device->chipset;
-	args->v0.revision = device->chiprev;
-	if (fb && fb->ram)
-		args->v0.ram_size = args->v0.ram_user = fb->ram->size;
-	else
-		args->v0.ram_size = args->v0.ram_user = 0;
-	if (imem && args->v0.ram_size > 0)
-		args->v0.ram_user = args->v0.ram_user - imem->reserved;
-
-	snprintf(args->v0.chip, sizeof(args->v0.chip), "%s", device->chip->name);
-	snprintf(args->v0.name, sizeof(args->v0.name), "%s", device->name);
 	return 0;
 }
 
@@ -347,6 +275,69 @@ nvkm_udevice_new(struct nvkm_device *device,
 	udev->impl.map.handle = device->func->resource_addr(device, 0);
 	udev->impl.map.length = device->func->resource_size(device, 0);
 
+	switch (device->chipset) {
+	case 0x01a:
+	case 0x01f:
+	case 0x04c:
+	case 0x04e:
+	case 0x063:
+	case 0x067:
+	case 0x068:
+	case 0x0aa:
+	case 0x0ac:
+	case 0x0af:
+		udev->impl.platform = NVIF_DEVICE_IGP;
+		break;
+	default:
+		switch (device->type) {
+		case NVKM_DEVICE_PCI  : udev->impl.platform = NVIF_DEVICE_PCI; break;
+		case NVKM_DEVICE_AGP  : udev->impl.platform = NVIF_DEVICE_AGP; break;
+		case NVKM_DEVICE_PCIE : udev->impl.platform = NVIF_DEVICE_PCIE; break;
+		case NVKM_DEVICE_TEGRA: udev->impl.platform = NVIF_DEVICE_SOC; break;
+		default:
+			WARN_ON(1);
+			ret = -EINVAL;
+			goto done;
+		}
+		break;
+	}
+
+	udev->impl.chipset  = device->chipset;
+	udev->impl.revision = device->chiprev;
+
+	switch (device->card_type) {
+	case NV_04: udev->impl.family = NVIF_DEVICE_TNT; break;
+	case NV_10:
+	case NV_11: udev->impl.family = NVIF_DEVICE_CELSIUS; break;
+	case NV_20: udev->impl.family = NVIF_DEVICE_KELVIN; break;
+	case NV_30: udev->impl.family = NVIF_DEVICE_RANKINE; break;
+	case NV_40: udev->impl.family = NVIF_DEVICE_CURIE; break;
+	case NV_50: udev->impl.family = NVIF_DEVICE_TESLA; break;
+	case NV_C0: udev->impl.family = NVIF_DEVICE_FERMI; break;
+	case NV_E0: udev->impl.family = NVIF_DEVICE_KEPLER; break;
+	case GM100: udev->impl.family = NVIF_DEVICE_MAXWELL; break;
+	case GP100: udev->impl.family = NVIF_DEVICE_PASCAL; break;
+	case GV100: udev->impl.family = NVIF_DEVICE_VOLTA; break;
+	case TU100: udev->impl.family = NVIF_DEVICE_TURING; break;
+	case GA100: udev->impl.family = NVIF_DEVICE_AMPERE; break;
+	case AD100: udev->impl.family = NVIF_DEVICE_ADA; break;
+	default:
+		WARN_ON(1);
+		ret = -EINVAL;
+		goto done;
+	}
+
+	snprintf(udev->impl.chip, sizeof(udev->impl.chip), "%s", device->chip->name);
+	snprintf(udev->impl.name, sizeof(udev->impl.name), "%s", device->name);
+
+	if (device->fb && device->fb->ram)
+		udev->impl.ram_size = udev->impl.ram_user = device->fb->ram->size;
+	else
+		udev->impl.ram_size = udev->impl.ram_user = 0;
+
+	if (device->imem && udev->impl.ram_size > 0)
+		udev->impl.ram_user = udev->impl.ram_user - device->imem->reserved;
+
 	if (device->vfn) {
 		udev->impl.usermode.oclass = device->vfn->user.base.oclass;
 	}
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 068/156] drm/nouveau/nvif: rework device "info v1" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (66 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 067/156] drm/nouveau/nvif: rework device "info v0" api Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 069/156] drm/nouveau/nvif: rework device "time" api Ben Skeggs
                   ` (89 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interfaces

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 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(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/cl0080.h b/drivers/gpu/drm/nouveau/include/nvif/cl0080.h
index ea937fa7bc55..f1684dbd8e3b 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/cl0080.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/cl0080.h
@@ -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
diff --git a/drivers/gpu/drm/nouveau/include/nvif/device.h b/drivers/gpu/drm/nouveau/include/nvif/device.h
index 27526d5811cf..fa8402e575da 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/device.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/device.h
@@ -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;
 };
 
diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 6152eabd4352..54446d38cb91 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -78,6 +78,49 @@ struct nvif_device_impl {
 	} disp;
 
 	struct nvif_device_impl_fifo {
+		u8  engine_nr;
+		u8  runl_nr;
+		u16 chan_nr; /* 0 == per-runlist */
+
+		struct nvif_device_impl_engine {
+			enum nvif_engine_type {
+				NVIF_ENGINE_SW,
+				NVIF_ENGINE_GR,
+				NVIF_ENGINE_MPEG,
+				NVIF_ENGINE_ME,
+				NVIF_ENGINE_CIPHER,
+				NVIF_ENGINE_BSP,
+				NVIF_ENGINE_VP,
+				NVIF_ENGINE_CE,
+				NVIF_ENGINE_SEC,
+				NVIF_ENGINE_MSVLD,
+				NVIF_ENGINE_MSPDEC,
+				NVIF_ENGINE_MSPPP,
+				NVIF_ENGINE_MSENC,
+				NVIF_ENGINE_VIC,
+				NVIF_ENGINE_SEC2,
+				NVIF_ENGINE_NVDEC,
+				NVIF_ENGINE_NVENC,
+				NVIF_ENGINE_NVJPG,
+				NVIF_ENGINE_OFA,
+			} type;
+
+			u8  oclass_nr;
+			s32 oclass[64];
+		} engine[8];
+
+		struct nvif_device_impl_runl {
+			u8  id;
+			u16 chan_nr;
+			u8  runq_nr;
+			u8  engn_nr;
+
+			struct {
+				u8 engine;
+				u8 inst;
+			} engn[8];
+		} runl[64];
+
 		struct {
 			s32 oclass;
 		} cgrp;
diff --git a/drivers/gpu/drm/nouveau/include/nvif/fifo.h b/drivers/gpu/drm/nouveau/include/nvif/fifo.h
index d351ac890ca1..4e9663848291 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/fifo.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/fifo.h
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/subdev.h b/drivers/gpu/drm/nouveau/include/nvkm/core/subdev.h
index bce6e1ba09ea..3bce2077072b 100644
--- a/drivers/gpu/drm/nouveau/include/nvkm/core/subdev.h
+++ b/drivers/gpu/drm/nouveau/include/nvkm/core/subdev.h
@@ -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 */
diff --git a/drivers/gpu/drm/nouveau/nouveau_abi16.c b/drivers/gpu/drm/nouveau/nouveau_abi16.c
index 23f8b448a30a..fdbc982ea566 100644
--- a/drivers/gpu/drm/nouveau/nouveau_abi16.c
+++ b/drivers/gpu/drm/nouveau/nouveau_abi16.c
@@ -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);
diff --git a/drivers/gpu/drm/nouveau/nouveau_chan.c b/drivers/gpu/drm/nouveau/nouveau_chan.c
index f9592eb0a47b..636ca1f284f8 100644
--- a/drivers/gpu/drm/nouveau/nouveau_chan.c
+++ b/drivers/gpu/drm/nouveau/nouveau_chan.c
@@ -300,10 +300,12 @@ nouveau_channel_ctor(struct nouveau_cli *cli, bool priv, u64 runm,
 	if (ret)
 		return ret;
 
+	chan->runlist = __ffs64(runm);
+
 	/* create channel object */
 	args.chan.version = 0;
 	args.chan.namelen = sizeof(args.name);
-	args.chan.runlist = __ffs64(runm);
+	args.chan.runlist = cli->drm->device.impl->fifo.runl[chan->runlist].id;
 	args.chan.runq = 0;
 	args.chan.priv = priv;
 	args.chan.devm = BIT(0);
@@ -350,7 +352,6 @@ nouveau_channel_ctor(struct nouveau_cli *cli, bool priv, u64 runm,
 		return ret;
 	}
 
-	chan->runlist = args.chan.runlist;
 	chan->chid = args.chan.chid;
 	chan->inst = args.chan.inst;
 	chan->token = args.chan.token;
@@ -523,46 +524,18 @@ nouveau_channels_fini(struct nouveau_drm *drm)
 int
 nouveau_channels_init(struct nouveau_drm *drm)
 {
-	struct {
-		struct nv_device_info_v1 m;
-		struct {
-			struct nv_device_info_v1_data channels;
-			struct nv_device_info_v1_data runlists;
-		} v;
-	} args = {
-		.m.version = 1,
-		.m.count = sizeof(args.v) / sizeof(args.v.channels),
-		.v.channels.mthd = NV_DEVICE_HOST_CHANNELS,
-		.v.runlists.mthd = NV_DEVICE_HOST_RUNLISTS,
-	};
-	struct nvif_object *device = &drm->client.device.object;
-	int ret, i;
-
-	ret = nvif_object_mthd(device, NV_DEVICE_V0_INFO, &args, sizeof(args));
-	if (ret ||
-	    args.v.runlists.mthd == NV_DEVICE_INFO_INVALID || !args.v.runlists.data ||
-	    args.v.channels.mthd == NV_DEVICE_INFO_INVALID)
-		return -ENODEV;
+	struct nvif_device *device = &drm->device;
+	int i;
 
-	drm->chan_nr = drm->chan_total = args.v.channels.data;
-	drm->runl_nr = fls64(args.v.runlists.data);
+	drm->chan_nr = drm->chan_total = device->impl->fifo.chan_nr;
+	drm->runl_nr = device->impl->fifo.runl_nr;
 	drm->runl = kcalloc(drm->runl_nr, sizeof(*drm->runl), GFP_KERNEL);
 	if (!drm->runl)
 		return -ENOMEM;
 
 	if (drm->chan_nr == 0) {
 		for (i = 0; i < drm->runl_nr; i++) {
-			if (!(args.v.runlists.data & BIT(i)))
-				continue;
-
-			args.v.channels.mthd = NV_DEVICE_HOST_RUNLIST_CHANNELS;
-			args.v.channels.data = i;
-
-			ret = nvif_object_mthd(device, NV_DEVICE_V0_INFO, &args, sizeof(args));
-			if (ret || args.v.channels.mthd == NV_DEVICE_INFO_INVALID)
-				return -ENODEV;
-
-			drm->runl[i].chan_nr = args.v.channels.data;
+			drm->runl[i].chan_nr = device->impl->fifo.runl[i].chan_nr;
 			drm->runl[i].chan_id_base = drm->chan_total;
 			drm->runl[i].context_base = dma_fence_context_alloc(drm->runl[i].chan_nr);
 
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index a37e08f0fd77..76990dde1b6a 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/nvif/device.c b/drivers/gpu/drm/nouveau/nvif/device.c
index 7c28f9764936..d4d00a757cd0 100644
--- a/drivers/gpu/drm/nouveau/nvif/device.c
+++ b/drivers/gpu/drm/nouveau/nvif/device.c
@@ -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,
diff --git a/drivers/gpu/drm/nouveau/nvif/fifo.c b/drivers/gpu/drm/nouveau/nvif/fifo.c
index a463289962b2..34e6fec0f0a3 100644
--- a/drivers/gpu/drm/nouveau/nvif/fifo.c
+++ b/drivers/gpu/drm/nouveau/nvif/fifo.c
@@ -21,66 +21,19 @@
  */
 #include <nvif/fifo.h>
 
-static int
-nvif_fifo_runlists(struct nvif_device *device)
-{
-	struct nvif_object *object = &device->object;
-	struct {
-		struct nv_device_info_v1 m;
-		struct {
-			struct nv_device_info_v1_data runlists;
-			struct nv_device_info_v1_data runlist[64];
-		} v;
-	} *a;
-	int ret, i;
-
-	if (device->runlist)
-		return 0;
-
-	if (!(a = kmalloc(sizeof(*a), GFP_KERNEL)))
-		return -ENOMEM;
-	a->m.version = 1;
-	a->m.count = sizeof(a->v) / sizeof(a->v.runlists);
-	a->v.runlists.mthd = NV_DEVICE_HOST_RUNLISTS;
-	for (i = 0; i < ARRAY_SIZE(a->v.runlist); i++) {
-		a->v.runlist[i].mthd = NV_DEVICE_HOST_RUNLIST_ENGINES;
-		a->v.runlist[i].data = i;
-	}
-
-	ret = nvif_object_mthd(object, NV_DEVICE_V0_INFO, a, sizeof(*a));
-	if (ret)
-		goto done;
-
-	device->runlists = fls64(a->v.runlists.data);
-	device->runlist = kcalloc(device->runlists, sizeof(*device->runlist),
-				  GFP_KERNEL);
-	if (!device->runlist) {
-		ret = -ENOMEM;
-		goto done;
-	}
-
-	for (i = 0; i < device->runlists; i++) {
-		if (a->v.runlist[i].mthd != NV_DEVICE_INFO_INVALID)
-			device->runlist[i].engines = a->v.runlist[i].data;
-	}
-
-done:
-	kfree(a);
-	return ret;
-}
-
 u64
-nvif_fifo_runlist(struct nvif_device *device, u64 engine)
+nvif_fifo_runlist(struct nvif_device *device, enum nvif_engine_type type)
 {
+	const struct nvif_device_impl_fifo *impl = &device->impl->fifo;
 	u64 runm = 0;
-	int ret, i;
-
-	if ((ret = nvif_fifo_runlists(device)))
-		return runm;
 
-	for (i = 0; i < device->runlists; i++) {
-		if (device->runlist[i].engines & engine)
-			runm |= BIT_ULL(i);
+	for (int i = 0; i < impl->runl_nr; i++) {
+		for (int j = 0; j < impl->runl[i].engn_nr; j++) {
+			if (impl->engine[impl->runl[i].engn[j].engine].type == type) {
+				runm |= BIT_ULL(i);
+				continue;
+			}
+		}
 	}
 
 	return runm;
diff --git a/drivers/gpu/drm/nouveau/nvkm/core/engine.c b/drivers/gpu/drm/nouveau/nvkm/core/engine.c
index 36a31e9eea22..7d59a1d43a5b 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/engine.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/engine.c
@@ -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,
 };
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/core/subdev.c b/drivers/gpu/drm/nouveau/nvkm/core/subdev.c
index 6c20e827a069..d8b6d0f31883 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/subdev.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/subdev.c
@@ -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)
 {
diff --git a/drivers/gpu/drm/nouveau/nvkm/device/user.c b/drivers/gpu/drm/nouveau/nvkm/device/user.c
index 589cb31853e6..26ce50fc2aac 100644
--- a/drivers/gpu/drm/nouveau/nvkm/device/user.c
+++ b/drivers/gpu/drm/nouveau/nvkm/device/user.c
@@ -45,62 +45,6 @@ struct nvif_device_priv {
 	struct nvif_device_impl impl;
 };
 
-static int
-nvkm_udevice_info_subdev(struct nvkm_device *device, u64 mthd, u64 *data)
-{
-	struct nvkm_subdev *subdev;
-	enum nvkm_subdev_type type;
-
-	switch (mthd & NV_DEVICE_INFO_UNIT) {
-	case NV_DEVICE_HOST(0): type = NVKM_ENGINE_FIFO; break;
-	default:
-		return -EINVAL;
-	}
-
-	subdev = nvkm_device_subdev(device, type, 0);
-	if (subdev)
-		return nvkm_subdev_info(subdev, mthd, data);
-	return -ENODEV;
-}
-
-static void
-nvkm_udevice_info_v1(struct nvkm_device *device,
-		     struct nv_device_info_v1_data *args)
-{
-	if (args->mthd & NV_DEVICE_INFO_UNIT) {
-		if (nvkm_udevice_info_subdev(device, args->mthd, &args->data))
-			args->mthd = NV_DEVICE_INFO_INVALID;
-		return;
-	}
-	args->mthd = NV_DEVICE_INFO_INVALID;
-}
-
-static int
-nvkm_udevice_info(struct nvkm_udevice *udev, void *data, u32 size)
-{
-	struct nvkm_object *object = &udev->object;
-	struct nvkm_device *device = udev->device;
-	union {
-		struct nv_device_info_v1 v1;
-	} *args = data;
-	int ret = -ENOSYS, i;
-
-	nvif_ioctl(object, "device info size %d\n", size);
-	if (!(ret = nvif_unpack(ret, &data, &size, args->v1, 1, 1, true))) {
-		nvif_ioctl(object, "device info vers %d count %d\n",
-			   args->v1.version, args->v1.count);
-		if (args->v1.count * sizeof(args->v1.data[0]) == size) {
-			for (i = 0; i < args->v1.count; i++)
-				nvkm_udevice_info_v1(device, &args->v1.data[i]);
-			return 0;
-		}
-		return -EINVAL;
-	} else
-		return ret;
-
-	return 0;
-}
-
 static int
 nvkm_udevice_time(struct nvkm_udevice *udev, void *data, u32 size)
 {
@@ -140,8 +84,6 @@ nvkm_udevice_mthd(struct nvkm_object *object, u32 mthd, void *data, u32 size)
 	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:
-		return nvkm_udevice_info(udev, data, size);
 	case NV_DEVICE_V0_TIME:
 		return nvkm_udevice_time(udev, data, size);
 	default:
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/base.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/base.c
index 22443fe4a39f..6bd464da1c96 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/base.c
@@ -165,78 +165,6 @@ nvkm_fifo_init(struct nvkm_engine *engine)
 	return 0;
 }
 
-static int
-nvkm_fifo_info(struct nvkm_engine *engine, u64 mthd, u64 *data)
-{
-	struct nvkm_fifo *fifo = nvkm_fifo(engine);
-	struct nvkm_runl *runl;
-	struct nvkm_engn *engn;
-	int ret;
-
-	ret = nvkm_subdev_oneinit(&fifo->engine.subdev);
-	if (ret)
-		return ret;
-
-	switch (mthd) {
-	case NV_DEVICE_HOST_CHANNELS: *data = fifo->chid ? fifo->chid->nr : 0; return 0;
-	case NV_DEVICE_HOST_RUNLISTS:
-		*data = 0;
-		nvkm_runl_foreach(runl, fifo)
-			*data |= BIT(runl->id);
-		return 0;
-	case NV_DEVICE_HOST_RUNLIST_ENGINES:
-		runl = nvkm_runl_get(fifo, *data, 0);
-		if (runl) {
-			*data = 0;
-			nvkm_runl_foreach_engn(engn, runl) {
-#define CASE(n) case NVKM_ENGINE_##n: *data |= NV_DEVICE_HOST_RUNLIST_ENGINES_##n; break
-				switch (engn->engine->subdev.type) {
-				case NVKM_ENGINE_DMAOBJ:
-					break;
-				CASE(SW    );
-				CASE(GR    );
-				CASE(MPEG  );
-				CASE(ME    );
-				CASE(CIPHER);
-				CASE(BSP   );
-				CASE(VP    );
-				CASE(CE    );
-				CASE(SEC   );
-				CASE(MSVLD );
-				CASE(MSPDEC);
-				CASE(MSPPP );
-				CASE(MSENC );
-				CASE(VIC   );
-				CASE(SEC2  );
-				CASE(NVDEC );
-				CASE(NVENC );
-				CASE(NVJPG );
-				CASE(OFA   );
-				default:
-					WARN_ON(1);
-					break;
-				}
-#undef CASE
-			}
-			return 0;
-		}
-		return -EINVAL;
-	case NV_DEVICE_HOST_RUNLIST_CHANNELS:
-		if (!fifo->chid) {
-			runl = nvkm_runl_get(fifo, *data, 0);
-			if (runl) {
-				*data = runl->chid->nr;
-				return 0;
-			}
-		}
-		return -EINVAL;
-	default:
-		break;
-	}
-
-	return -ENOSYS;
-}
-
 static int
 nvkm_fifo_oneinit(struct nvkm_engine *engine)
 {
@@ -365,7 +293,6 @@ nvkm_fifo = {
 	.dtor = nvkm_fifo_dtor,
 	.preinit = nvkm_fifo_preinit,
 	.oneinit = nvkm_fifo_oneinit,
-	.info = nvkm_fifo_info,
 	.init = nvkm_fifo_init,
 	.fini = nvkm_fifo_fini,
 	.base.sclass = nvkm_fifo_class_get,
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/ufifo.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/ufifo.c
index 3f0bd70f614e..46f60eb0f122 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/ufifo.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/ufifo.c
@@ -20,11 +20,110 @@
  * DEALINGS IN THE SOFTWARE.
  */
 #include "ufifo.h"
+#include "chid.h"
 #include "priv.h"
+#include "runl.h"
 
 void
 nvkm_ufifo_ctor(struct nvkm_fifo *fifo, struct nvif_device_impl_fifo *impl)
 {
+	struct nvkm_runl *runl;
+	struct nvkm_engn *engn;
+	int runi = 0;
+
+	nvkm_runl_foreach(runl, fifo) {
+		bool failed_engines = false;
+		int engi = 0;
+
+		nvkm_runl_foreach_engn(engn, runl) {
+			struct nvkm_engine *engine = engn->engine;
+			enum nvif_engine_type type;
+			int i;
+
+			switch (engine->subdev.type) {
+			case NVKM_ENGINE_SW    : type = NVIF_ENGINE_SW; break;
+			case NVKM_ENGINE_GR    : type = NVIF_ENGINE_GR; break;
+			case NVKM_ENGINE_MPEG  : type = NVIF_ENGINE_MPEG; break;
+			case NVKM_ENGINE_ME    : type = NVIF_ENGINE_ME; break;
+			case NVKM_ENGINE_CIPHER: type = NVIF_ENGINE_CIPHER; break;
+			case NVKM_ENGINE_BSP   : type = NVIF_ENGINE_BSP; break;
+			case NVKM_ENGINE_VP    : type = NVIF_ENGINE_VP; break;
+			case NVKM_ENGINE_CE    : type = NVIF_ENGINE_CE; break;
+			case NVKM_ENGINE_SEC   : type = NVIF_ENGINE_SEC; break;
+			case NVKM_ENGINE_MSVLD : type = NVIF_ENGINE_MSVLD; break;
+			case NVKM_ENGINE_MSPDEC: type = NVIF_ENGINE_MSPDEC; break;
+			case NVKM_ENGINE_MSPPP : type = NVIF_ENGINE_MSPPP; break;
+			case NVKM_ENGINE_MSENC : type = NVIF_ENGINE_MSENC; break;
+			case NVKM_ENGINE_VIC   : type = NVIF_ENGINE_VIC; break;
+			case NVKM_ENGINE_SEC2  : type = NVIF_ENGINE_SEC2; break;
+			case NVKM_ENGINE_NVDEC : type = NVIF_ENGINE_NVDEC; break;
+			case NVKM_ENGINE_NVENC : type = NVIF_ENGINE_NVENC; break;
+			case NVKM_ENGINE_NVJPG : type = NVIF_ENGINE_NVJPG; break;
+			case NVKM_ENGINE_OFA   : type = NVIF_ENGINE_OFA; break;
+			default:
+				failed_engines = true;
+				WARN_ON(1);
+				continue;
+			}
+
+			for (i = 0; i < impl->engine_nr; i++) {
+				if (impl->engine[i].type == type)
+					break;
+			}
+
+			if (i == impl->engine_nr) {
+				int clsi = 0;
+
+				if (WARN_ON(i >= ARRAY_SIZE(impl->engine))) {
+					failed_engines = true;
+					break;
+				}
+
+				impl->engine[i].type = type;
+				impl->engine_nr++;
+
+				for (;;) {
+					struct nvkm_oclass oclass = { .engine = engine };
+
+					if (engine->func->fifo.sclass)
+						engine->func->fifo.sclass(&oclass, clsi);
+					else
+						oclass.base = engine->func->sclass[clsi];
+					if (!oclass.base.oclass)
+						break;
+
+					if (WARN_ON(clsi >= ARRAY_SIZE(impl->engine[i].oclass)))
+						break;
+
+					impl->engine[i].oclass[clsi++] = oclass.base.oclass;
+				}
+
+				impl->engine[i].oclass_nr = clsi;
+			}
+
+			engi = impl->runl[runi].engn_nr;
+
+			if (WARN_ON(engi >= ARRAY_SIZE(impl->runl[runi].engn))) {
+				failed_engines = true;
+				break;
+			}
+
+			impl->runl[runi].engn[engi].engine = i;
+			impl->runl[runi].engn[engi].inst = engine->subdev.inst;
+			impl->runl[runi].engn_nr = ++engi;
+		}
+
+		if (failed_engines ||
+		    WARN_ON(runi >= ARRAY_SIZE(impl->runl)))
+			continue;
+
+		impl->runl[runi].id = runl->id;
+		impl->runl[runi].chan_nr = runl->chid->nr;
+		impl->runl[runi].runq_nr = runl->runq_nr;
+		impl->runl[runi].engn_nr = engi;
+		impl->runl_nr = ++runi;
+	}
+
 	impl->cgrp.oclass = fifo->func->cgrp.user.oclass;
 	impl->chan.oclass = fifo->func->chan.user.oclass;
 }
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 069/156] drm/nouveau/nvif: rework device "time" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (67 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 068/156] drm/nouveau/nvif: rework device "info v1" api Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 070/156] drm/nouveau/nvif: rework device "new ctrl" api Ben Skeggs
                   ` (88 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interface

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 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(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/cl0080.h b/drivers/gpu/drm/nouveau/include/nvif/cl0080.h
index f1684dbd8e3b..db096a41dc4f 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/cl0080.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/cl0080.h
@@ -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
diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 54446d38cb91..44064b5da897 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -61,6 +61,8 @@ struct nvif_device_impl {
 	u64 ram_size;
 	u64 ram_user;
 
+	u64 (*time)(struct nvif_device_priv *);
+
 	struct {
 		s32 oclass;
 	} usermode;
diff --git a/drivers/gpu/drm/nouveau/nvif/device.c b/drivers/gpu/drm/nouveau/nvif/device.c
index d4d00a757cd0..7d057691600f 100644
--- a/drivers/gpu/drm/nouveau/nvif/device.c
+++ b/drivers/gpu/drm/nouveau/nvif/device.c
@@ -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);
 }
diff --git a/drivers/gpu/drm/nouveau/nvkm/device/user.c b/drivers/gpu/drm/nouveau/nvkm/device/user.c
index 26ce50fc2aac..b37c857863b8 100644
--- a/drivers/gpu/drm/nouveau/nvkm/device/user.c
+++ b/drivers/gpu/drm/nouveau/nvkm/device/user.c
@@ -32,12 +32,6 @@
 #include <engine/disp/priv.h>
 #include <engine/fifo/ufifo.h>
 
-#include <nvif/class.h>
-#include <nvif/cl0080.h>
-#include <nvif/unpack.h>
-
-#define nvkm_udevice nvif_device_priv
-
 struct nvif_device_priv {
 	struct nvkm_object object;
 	struct nvkm_device *device;
@@ -45,23 +39,10 @@ struct nvif_device_priv {
 	struct nvif_device_impl impl;
 };
 
-static int
-nvkm_udevice_time(struct nvkm_udevice *udev, void *data, u32 size)
+static u64
+nvkm_udevice_time(struct nvif_device_priv *udev)
 {
-	struct nvkm_object *object = &udev->object;
-	struct nvkm_device *device = udev->device;
-	union {
-		struct nv_device_time_v0 v0;
-	} *args = data;
-	int ret = -ENOSYS;
-
-	nvif_ioctl(object, "device time size %d\n", size);
-	if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
-		nvif_ioctl(object, "device time vers %d\n", args->v0.version);
-		args->v0.time = nvkm_timer_read(device->timer);
-	}
-
-	return ret;
+	return nvkm_timer_read(udev->device->timer);
 }
 
 static void
@@ -76,22 +57,9 @@ nvkm_udevice_del(struct nvif_device_priv *udev)
 static const struct nvif_device_impl
 nvkm_udevice_impl = {
 	.del = nvkm_udevice_del,
+	.time = nvkm_udevice_time,
 };
 
-static int
-nvkm_udevice_mthd(struct nvkm_object *object, u32 mthd, void *data, u32 size)
-{
-	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_TIME:
-		return nvkm_udevice_time(udev, data, size);
-	default:
-		break;
-	}
-	return -EINVAL;
-}
-
 static int
 nvkm_udevice_fini(struct nvkm_object *object, bool suspend)
 {
@@ -190,7 +158,6 @@ 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,
 };
 
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 070/156] drm/nouveau/nvif: rework device "new ctrl" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (68 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 069/156] drm/nouveau/nvif: rework device "time" api Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 071/156] drm/nouveau/nvif: rework ctrl "pstate info" api Ben Skeggs
                   ` (87 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interface

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 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(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/class.h b/drivers/gpu/drm/nouveau/include/nvif/class.h
index b6bba7231750..6174999eacd3 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/class.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/class.h
@@ -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
diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 44064b5da897..aa1061266557 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/nouveau_debugfs.c b/drivers/gpu/drm/nouveau/nouveau_debugfs.c
index e83db051e851..e061ef7a1707 100644
--- a/drivers/gpu/drm/nouveau/nouveau_debugfs.c
+++ b/drivers/gpu/drm/nouveau/nouveau_debugfs.c
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/nouveau_debugfs.h b/drivers/gpu/drm/nouveau/nouveau_debugfs.h
index 77f0323b38ba..197e81f771d5 100644
--- a/drivers/gpu/drm/nouveau/nouveau_debugfs.h
+++ b/drivers/gpu/drm/nouveau/nouveau_debugfs.h
@@ -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;
 };
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/device/ctrl.c b/drivers/gpu/drm/nouveau/nvkm/device/ctrl.c
index a74fb78ca7ab..5caa93665cc9 100644
--- a/drivers/gpu/drm/nouveau/nvkm/device/ctrl.c
+++ b/drivers/gpu/drm/nouveau/nvkm/device/ctrl.c
@@ -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,
-};
diff --git a/drivers/gpu/drm/nouveau/nvkm/device/ctrl.h b/drivers/gpu/drm/nouveau/nvkm/device/ctrl.h
index d241329a1e7a..c435ddf0a713 100644
--- a/drivers/gpu/drm/nouveau/nvkm/device/ctrl.h
+++ b/drivers/gpu/drm/nouveau/nvkm/device/ctrl.h
@@ -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
diff --git a/drivers/gpu/drm/nouveau/nvkm/device/user.c b/drivers/gpu/drm/nouveau/nvkm/device/user.c
index b37c857863b8..14d548c3f6b0 100644
--- a/drivers/gpu/drm/nouveau/nvkm/device/user.c
+++ b/drivers/gpu/drm/nouveau/nvkm/device/user.c
@@ -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;
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 071/156] drm/nouveau/nvif: rework ctrl "pstate info" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (69 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 070/156] drm/nouveau/nvif: rework device "new ctrl" api Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 072/156] drm/nouveau/nvif: rework ctrl "pstate attr" api Ben Skeggs
                   ` (86 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interface

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 .../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(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index aa1061266557..ba8b5ff9fcd6 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -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 {
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0001.h b/drivers/gpu/drm/nouveau/include/nvif/if0001.h
index 4ced50e98ced..9bb955500934 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/if0001.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/if0001.h
@@ -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)
diff --git a/drivers/gpu/drm/nouveau/nouveau_debugfs.c b/drivers/gpu/drm/nouveau/nouveau_debugfs.c
index e061ef7a1707..caccf99f1d8a 100644
--- a/drivers/gpu/drm/nouveau/nouveau_debugfs.c
+++ b/drivers/gpu/drm/nouveau/nouveau_debugfs.c
@@ -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 :
diff --git a/drivers/gpu/drm/nouveau/nvkm/device/ctrl.c b/drivers/gpu/drm/nouveau/nvkm/device/ctrl.c
index 5caa93665cc9..ea38592f5557 100644
--- a/drivers/gpu/drm/nouveau/nvkm/device/ctrl.c
+++ b/drivers/gpu/drm/nouveau/nvkm/device/ctrl.c
@@ -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
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 072/156] drm/nouveau/nvif: rework ctrl "pstate attr" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (70 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 071/156] drm/nouveau/nvif: rework ctrl "pstate info" api Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 073/156] drm/nouveau/nvif: rework ctrl "pstate user" api Ben Skeggs
                   ` (85 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interface

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 .../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(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index ba8b5ff9fcd6..bfa22c977323 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -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;
 };
 
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0001.h b/drivers/gpu/drm/nouveau/include/nvif/if0001.h
index 9bb955500934..b84da0b7d079 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/if0001.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/if0001.h
@@ -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)
diff --git a/drivers/gpu/drm/nouveau/nouveau_debugfs.c b/drivers/gpu/drm/nouveau/nouveau_debugfs.c
index caccf99f1d8a..33a64f95f64f 100644
--- a/drivers/gpu/drm/nouveau/nouveau_debugfs.c
+++ b/drivers/gpu/drm/nouveau/nouveau_debugfs.c
@@ -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;
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/device/ctrl.c b/drivers/gpu/drm/nouveau/nvkm/device/ctrl.c
index ea38592f5557..8c279cb797e9 100644
--- a/drivers/gpu/drm/nouveau/nvkm/device/ctrl.c
+++ b/drivers/gpu/drm/nouveau/nvkm/device/ctrl.c
@@ -58,36 +58,26 @@ nvkm_control_pstate_info(struct nvif_control_priv *ctrl, struct nvif_control_pst
 }
 
 static int
-nvkm_control_mthd_pstate_attr(struct nvkm_control *ctrl, void *data, u32 size)
+nvkm_control_pstate_attr(struct nvif_control_priv *ctrl, struct nvif_control_pstate_attr *attr)
 {
-	union {
-		struct nvif_control_pstate_attr_v0 v0;
-	} *args = data;
 	struct nvkm_clk *clk = ctrl->device->clk;
 	const struct nvkm_domain *domain;
 	struct nvkm_pstate *pstate;
 	struct nvkm_cstate *cstate;
 	int i = 0, j = -1;
 	u32 lo, hi;
-	int ret = -ENOSYS;
 
-	nvif_ioctl(&ctrl->object, "control pstate attr size %d\n", size);
-	if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
-		nvif_ioctl(&ctrl->object,
-			   "control pstate attr vers %d state %d index %d\n",
-			   args->v0.version, args->v0.state, args->v0.index);
-		if (!clk)
-			return -ENODEV;
-		if (args->v0.state < NVIF_CONTROL_PSTATE_ATTR_V0_STATE_CURRENT)
-			return -EINVAL;
-		if (args->v0.state >= clk->state_nr)
-			return -EINVAL;
-	} else
-		return ret;
+	if (!clk)
+		return -ENODEV;
+	if (attr->state < NVIF_CONTROL_PSTATE_ATTR_STATE_CURRENT)
+		return -EINVAL;
+	if (attr->state >= clk->state_nr)
+		return -EINVAL;
+
 	domain = clk->domains;
 
 	while (domain->name != nv_clk_src_max) {
-		if (domain->mname && ++j == args->v0.index)
+		if (domain->mname && ++j == attr->index)
 			break;
 		domain++;
 	}
@@ -95,9 +85,9 @@ nvkm_control_mthd_pstate_attr(struct nvkm_control *ctrl, void *data, u32 size)
 	if (domain->name == nv_clk_src_max)
 		return -EINVAL;
 
-	if (args->v0.state != NVIF_CONTROL_PSTATE_ATTR_V0_STATE_CURRENT) {
+	if (attr->state != NVIF_CONTROL_PSTATE_ATTR_STATE_CURRENT) {
 		list_for_each_entry(pstate, &clk->states, head) {
-			if (i++ == args->v0.state)
+			if (i++ == attr->state)
 				break;
 		}
 
@@ -108,21 +98,21 @@ nvkm_control_mthd_pstate_attr(struct nvkm_control *ctrl, void *data, u32 size)
 			hi = max(hi, cstate->domain[domain->name]);
 		}
 
-		args->v0.state = pstate->pstate;
+		attr->state = pstate->pstate;
 	} else {
 		lo = max(nvkm_clk_read(clk, domain->name), 0);
 		hi = lo;
 	}
 
-	snprintf(args->v0.name, sizeof(args->v0.name), "%s", domain->mname);
-	snprintf(args->v0.unit, sizeof(args->v0.unit), "MHz");
-	args->v0.min = lo / domain->mdiv;
-	args->v0.max = hi / domain->mdiv;
+	snprintf(attr->name, sizeof(attr->name), "%s", domain->mname);
+	snprintf(attr->unit, sizeof(attr->unit), "MHz");
+	attr->min = lo / domain->mdiv;
+	attr->max = hi / domain->mdiv;
 
-	args->v0.index = 0;
+	attr->index = 0;
 	while ((++domain)->name != nv_clk_src_max) {
 		if (domain->mname) {
-			args->v0.index = ++j;
+			attr->index = ++j;
 			break;
 		}
 	}
@@ -164,8 +154,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_ATTR:
-		return nvkm_control_mthd_pstate_attr(ctrl, data, size);
 	case NVIF_CONTROL_PSTATE_USER:
 		return nvkm_control_mthd_pstate_user(ctrl, data, size);
 	default:
@@ -191,6 +179,7 @@ static const struct nvif_control_impl
 nvkm_control_impl = {
 	.del = nvkm_control_del,
 	.pstate.info = nvkm_control_pstate_info,
+	.pstate.attr = nvkm_control_pstate_attr,
 };
 
 int
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 073/156] drm/nouveau/nvif: rework ctrl "pstate user" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (71 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 072/156] drm/nouveau/nvif: rework ctrl "pstate attr" api Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 074/156] drm/nouveau/nvif: remove ctrl from object rb Ben Skeggs
                   ` (84 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interface

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  9 ++++
 drivers/gpu/drm/nouveau/include/nvif/if0001.h | 15 ------
 drivers/gpu/drm/nouveau/nouveau_debugfs.c     | 10 ++--
 drivers/gpu/drm/nouveau/nvkm/device/ctrl.c    | 51 ++++---------------
 4 files changed, 24 insertions(+), 61 deletions(-)
 delete mode 100644 drivers/gpu/drm/nouveau/include/nvif/if0001.h

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index bfa22c977323..e22e0347f623 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -23,6 +23,14 @@ struct nvif_mapinfo {
 	u64 length;
 };
 
+struct nvif_control_pstate_user {
+	u8  version;
+#define NVIF_CONTROL_PSTATE_USER_STATE_UNKNOWN                          (-1)
+#define NVIF_CONTROL_PSTATE_USER_STATE_PERFMON                          (-2)
+	s8  ustate; /*  in: pstate identifier */
+	s8  pwrsrc; /*  in: target power source */
+};
+
 struct nvif_control_pstate_attr {
 	u8  version;
 #define NVIF_CONTROL_PSTATE_ATTR_STATE_CURRENT                          (-1)
@@ -57,6 +65,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 *);
+		int  (*user)(struct nvif_control_priv *, struct nvif_control_pstate_user *);
 	} pstate;
 };
 
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0001.h b/drivers/gpu/drm/nouveau/include/nvif/if0001.h
deleted file mode 100644
index b84da0b7d079..000000000000
--- a/drivers/gpu/drm/nouveau/include/nvif/if0001.h
+++ /dev/null
@@ -1,15 +0,0 @@
-/* SPDX-License-Identifier: MIT */
-#ifndef __NVIF_IF0001_H__
-#define __NVIF_IF0001_H__
-
-#define NVIF_CONTROL_PSTATE_USER                                           0x02
-
-struct nvif_control_pstate_user_v0 {
-	__u8  version;
-#define NVIF_CONTROL_PSTATE_USER_V0_STATE_UNKNOWN                          (-1)
-#define NVIF_CONTROL_PSTATE_USER_V0_STATE_PERFMON                          (-2)
-	__s8  ustate; /*  in: pstate identifier */
-	__s8  pwrsrc; /*  in: target power source */
-	__u8  pad03[5];
-};
-#endif
diff --git a/drivers/gpu/drm/nouveau/nouveau_debugfs.c b/drivers/gpu/drm/nouveau/nouveau_debugfs.c
index 33a64f95f64f..837653ca1753 100644
--- a/drivers/gpu/drm/nouveau/nouveau_debugfs.c
+++ b/drivers/gpu/drm/nouveau/nouveau_debugfs.c
@@ -29,7 +29,6 @@
  */
 
 #include <linux/debugfs.h>
-#include <nvif/if0001.h>
 #include "nouveau_debugfs.h"
 #include "nouveau_drv.h"
 
@@ -138,7 +137,7 @@ nouveau_debugfs_pstate_set(struct file *file, const char __user *ubuf,
 	struct seq_file *m = file->private_data;
 	struct drm_device *drm = m->private;
 	struct nouveau_debugfs *debugfs = nouveau_debugfs(drm);
-	struct nvif_control_pstate_user_v0 args = { .pwrsrc = -EINVAL };
+	struct nvif_control_pstate_user args = { .pwrsrc = -EINVAL };
 	char buf[32] = {}, *tmp, *cur = buf;
 	long value, ret;
 
@@ -164,10 +163,10 @@ nouveau_debugfs_pstate_set(struct file *file, const char __user *ubuf,
 	}
 
 	if (!strcasecmp(cur, "none"))
-		args.ustate = NVIF_CONTROL_PSTATE_USER_V0_STATE_UNKNOWN;
+		args.ustate = NVIF_CONTROL_PSTATE_USER_STATE_UNKNOWN;
 	else
 	if (!strcasecmp(cur, "auto"))
-		args.ustate = NVIF_CONTROL_PSTATE_USER_V0_STATE_PERFMON;
+		args.ustate = NVIF_CONTROL_PSTATE_USER_STATE_PERFMON;
 	else {
 		ret = kstrtol(cur, 16, &value);
 		if (ret)
@@ -181,8 +180,7 @@ nouveau_debugfs_pstate_set(struct file *file, const char __user *ubuf,
 		return ret;
 	}
 
-	ret = nvif_mthd(&debugfs->ctrl, NVIF_CONTROL_PSTATE_USER,
-			&args, sizeof(args));
+	ret = debugfs->impl->pstate.user(debugfs->priv, &args);
 	pm_runtime_put_autosuspend(drm->dev);
 	if (ret < 0)
 		return ret;
diff --git a/drivers/gpu/drm/nouveau/nvkm/device/ctrl.c b/drivers/gpu/drm/nouveau/nvkm/device/ctrl.c
index 8c279cb797e9..4ba1d5934a87 100644
--- a/drivers/gpu/drm/nouveau/nvkm/device/ctrl.c
+++ b/drivers/gpu/drm/nouveau/nvkm/device/ctrl.c
@@ -26,12 +26,6 @@
 #include <core/client.h>
 #include <subdev/clk.h>
 
-#include <nvif/if0001.h>
-#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;
@@ -121,50 +115,26 @@ nvkm_control_pstate_attr(struct nvif_control_priv *ctrl, struct nvif_control_pst
 }
 
 static int
-nvkm_control_mthd_pstate_user(struct nvkm_control *ctrl, void *data, u32 size)
+nvkm_control_pstate_user(struct nvif_control_priv *ctrl, struct nvif_control_pstate_user *user)
 {
-	union {
-		struct nvif_control_pstate_user_v0 v0;
-	} *args = data;
 	struct nvkm_clk *clk = ctrl->device->clk;
-	int ret = -ENOSYS;
-
-	nvif_ioctl(&ctrl->object, "control pstate user size %d\n", size);
-	if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
-		nvif_ioctl(&ctrl->object,
-			   "control pstate user vers %d ustate %d pwrsrc %d\n",
-			   args->v0.version, args->v0.ustate, args->v0.pwrsrc);
-		if (!clk)
-			return -ENODEV;
-	} else
-		return ret;
-
-	if (args->v0.pwrsrc >= 0) {
-		ret |= nvkm_clk_ustate(clk, args->v0.ustate, args->v0.pwrsrc);
+	int ret = 0;
+
+	if (!clk)
+		return -ENODEV;
+
+	if (user->pwrsrc >= 0) {
+		ret |= nvkm_clk_ustate(clk, user->ustate, user->pwrsrc);
 	} else {
-		ret |= nvkm_clk_ustate(clk, args->v0.ustate, 0);
-		ret |= nvkm_clk_ustate(clk, args->v0.ustate, 1);
+		ret |= nvkm_clk_ustate(clk, user->ustate, 0);
+		ret |= nvkm_clk_ustate(clk, user->ustate, 1);
 	}
 
 	return ret;
 }
 
-static int
-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_USER:
-		return nvkm_control_mthd_pstate_user(ctrl, data, size);
-	default:
-		break;
-	}
-	return -EINVAL;
-}
-
 static const struct nvkm_object_func
 nvkm_control = {
-	.mthd = nvkm_control_mthd,
 };
 
 static void
@@ -180,6 +150,7 @@ nvkm_control_impl = {
 	.del = nvkm_control_del,
 	.pstate.info = nvkm_control_pstate_info,
 	.pstate.attr = nvkm_control_pstate_attr,
+	.pstate.user = nvkm_control_pstate_user,
 };
 
 int
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 074/156] drm/nouveau/nvif: remove ctrl from object rb
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (72 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 073/156] drm/nouveau/nvif: rework ctrl "pstate user" api Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 075/156] drm/nouveau/nvif: rework device "new usermode" api Ben Skeggs
                   ` (83 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- no more users

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/include/nvif/driverif.h | 3 +--
 drivers/gpu/drm/nouveau/nouveau_debugfs.c       | 2 +-
 drivers/gpu/drm/nouveau/nvkm/device/user.c      | 6 +++---
 3 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index e22e0347f623..05d69ea0f002 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -112,8 +112,7 @@ struct nvif_device_impl {
 
 	struct {
 		int (*new)(struct nvif_device_priv *,
-			   const struct nvif_control_impl **, struct nvif_control_priv **,
-			   u64 handle);
+			   const struct nvif_control_impl **, struct nvif_control_priv **);
 	} control;
 
 	struct {
diff --git a/drivers/gpu/drm/nouveau/nouveau_debugfs.c b/drivers/gpu/drm/nouveau/nouveau_debugfs.c
index 837653ca1753..0c744a72aff2 100644
--- a/drivers/gpu/drm/nouveau/nouveau_debugfs.c
+++ b/drivers/gpu/drm/nouveau/nouveau_debugfs.c
@@ -293,7 +293,7 @@ nouveau_debugfs_init(struct nouveau_drm *drm)
 		return -ENOMEM;
 
 	ret = drm->device.impl->control.new(drm->device.priv, &drm->debugfs->impl,
-					    &drm->debugfs->priv, nvif_handle(&drm->debugfs->ctrl));
+					    &drm->debugfs->priv);
 	if (ret)
 		return ret;
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/device/user.c b/drivers/gpu/drm/nouveau/nvkm/device/user.c
index 14d548c3f6b0..97d54b812165 100644
--- a/drivers/gpu/drm/nouveau/nvkm/device/user.c
+++ b/drivers/gpu/drm/nouveau/nvkm/device/user.c
@@ -41,8 +41,7 @@ struct nvif_device_priv {
 
 static int
 nvkm_udevice_control_new(struct nvif_device_priv *udev,
-			 const struct nvif_control_impl **pimpl, struct nvif_control_priv **ppriv,
-			 u64 handle)
+			 const struct nvif_control_impl **pimpl, struct nvif_control_priv **ppriv)
 {
 	struct nvkm_object *object;
 	int ret;
@@ -51,7 +50,8 @@ nvkm_udevice_control_new(struct nvif_device_priv *udev,
 	if (ret)
 		return ret;
 
-	return nvkm_object_link_rb(udev->object.client, &udev->object, handle, object);
+	nvkm_object_link(&udev->object, object);
+	return 0;
 }
 
 static u64
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 075/156] drm/nouveau/nvif: rework device "new usermode" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (73 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 074/156] drm/nouveau/nvif: remove ctrl from object rb Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 076/156] drm/nouveau/nvif: rework usermode "map" api Ben Skeggs
                   ` (82 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interface

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  8 +++++
 drivers/gpu/drm/nouveau/include/nvif/user.h   |  5 +++-
 drivers/gpu/drm/nouveau/nouveau_dma.c         |  2 +-
 drivers/gpu/drm/nouveau/nouveau_drm.c         |  2 +-
 drivers/gpu/drm/nouveau/nvif/user.c           | 16 ++++++----
 drivers/gpu/drm/nouveau/nvkm/device/user.c    | 19 ++++++++++--
 .../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    | 29 +++++++++++++++----
 .../gpu/drm/nouveau/nvkm/subdev/vfn/uvfn.h    |  9 ++++++
 10 files changed, 73 insertions(+), 21 deletions(-)
 create mode 100644 drivers/gpu/drm/nouveau/nvkm/subdev/vfn/uvfn.h

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 05d69ea0f002..35a5869eb036 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -4,6 +4,7 @@
 struct nvif_client_priv;
 struct nvif_device_priv;
 struct nvif_control_priv;
+struct nvif_usermode_priv;
 
 struct nvif_driver {
 	const char *name;
@@ -69,6 +70,10 @@ struct nvif_control_impl {
 	} pstate;
 };
 
+struct nvif_usermode_impl {
+	void (*del)(struct nvif_usermode_priv *);
+};
+
 struct nvif_device_impl {
 	void (*del)(struct nvif_device_priv *);
 
@@ -117,6 +122,9 @@ struct nvif_device_impl {
 
 	struct {
 		s32 oclass;
+		int (*new)(struct nvif_device_priv *,
+			   const struct nvif_usermode_impl **, struct nvif_usermode_priv **,
+			   u64 handle);
 	} usermode;
 
 	struct {
diff --git a/drivers/gpu/drm/nouveau/include/nvif/user.h b/drivers/gpu/drm/nouveau/include/nvif/user.h
index 146986a9fe53..51104955c1e3 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/user.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/user.h
@@ -4,8 +4,11 @@
 struct nvif_device;
 
 struct nvif_user {
-	const struct nvif_user_func *func;
+	const struct nvif_usermode_impl *impl;
+	struct nvif_usermode_priv *priv;
 	struct nvif_object object;
+
+	const struct nvif_user_func *func;
 };
 
 struct nvif_user_func {
diff --git a/drivers/gpu/drm/nouveau/nouveau_dma.c b/drivers/gpu/drm/nouveau/nouveau_dma.c
index a1f329ef0641..83eb9c9fa67e 100644
--- a/drivers/gpu/drm/nouveau/nouveau_dma.c
+++ b/drivers/gpu/drm/nouveau/nouveau_dma.c
@@ -72,7 +72,7 @@ void
 nv50_dma_push(struct nouveau_channel *chan, u64 offset, u32 length,
 	      bool no_prefetch)
 {
-	struct nvif_user *user = &chan->cli->drm->client.device.user;
+	struct nvif_user *user = &chan->cli->drm->device.user;
 	struct nouveau_bo *pb = chan->push.buffer;
 	int ip = (chan->dma.ib_put * 2) + chan->dma.ib_base;
 
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 76990dde1b6a..a91ad8e65a0f 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -474,7 +474,7 @@ nouveau_accel_init(struct nouveau_drm *drm)
 
 	/* Volta requires access to a doorbell register for kickoff. */
 	if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_VOLTA) {
-		ret = nvif_user_ctor(device, "drmUsermode");
+		ret = nvif_user_ctor(&drm->device, "drmUsermode");
 		if (ret)
 			return;
 	}
diff --git a/drivers/gpu/drm/nouveau/nvif/user.c b/drivers/gpu/drm/nouveau/nvif/user.c
index d8d37c1c8169..878883aff9c5 100644
--- a/drivers/gpu/drm/nouveau/nvif/user.c
+++ b/drivers/gpu/drm/nouveau/nvif/user.c
@@ -21,6 +21,7 @@
  */
 #include <nvif/user.h>
 #include <nvif/device.h>
+#include <nvif/driverif.h>
 #include <nvif/printf.h>
 
 #include <nvif/class.h>
@@ -28,8 +29,9 @@
 void
 nvif_user_dtor(struct nvif_device *device)
 {
-	if (device->user.func) {
-		nvif_object_dtor(&device->user.object);
+	if (device->user.impl) {
+		device->user.impl->del(device->user.priv);
+		device->user.impl = NULL;
 		device->user.func = NULL;
 	}
 }
@@ -53,13 +55,15 @@ nvif_user_ctor(struct nvif_device *device, const char *name)
 		return -ENODEV;
 	}
 
-	ret = nvif_object_ctor(&device->object, name ? name : "nvifUsermode",
-			       0, oclass, NULL, 0,
-			       &device->user.object);
+	ret = device->impl->usermode.new(device->priv, &device->user.impl, &device->user.priv,
+					 nvif_handle(&device->user.object));
+	NVIF_ERRON(ret, &device->object, "[NEW usermode%04x]", oclass);
 	if (ret)
 		return ret;
 
-	nvif_object_map(&device->user.object, NULL, 0);
+	nvif_object_ctor(&device->object, name ?: "nvifUsermode", 0, oclass, &device->user.object);
 	device->user.func = func;
+
+	nvif_object_map(&device->user.object, NULL, 0);
 	return 0;
 }
diff --git a/drivers/gpu/drm/nouveau/nvkm/device/user.c b/drivers/gpu/drm/nouveau/nvkm/device/user.c
index 97d54b812165..aadd0c0956ee 100644
--- a/drivers/gpu/drm/nouveau/nvkm/device/user.c
+++ b/drivers/gpu/drm/nouveau/nvkm/device/user.c
@@ -29,6 +29,7 @@
 #include <subdev/fb.h>
 #include <subdev/instmem.h>
 #include <subdev/timer.h>
+#include <subdev/vfn/uvfn.h>
 #include <engine/disp/priv.h>
 #include <engine/fifo/ufifo.h>
 
@@ -39,6 +40,20 @@ struct nvif_device_priv {
 	struct nvif_device_impl impl;
 };
 
+static int
+nvkm_udevice_usermode_new(struct nvif_device_priv *udev, const struct nvif_usermode_impl **pimpl,
+			  struct nvif_usermode_priv **ppriv, u64 handle)
+{
+	struct nvkm_object *object;
+	int ret;
+
+	ret = nvkm_uvfn_new(udev->device, pimpl, ppriv, &object);
+	if (ret)
+		return ret;
+
+	return nvkm_object_link_rb(udev->object.client, &udev->object, handle, object);
+}
+
 static int
 nvkm_udevice_control_new(struct nvif_device_priv *udev,
 			 const struct nvif_control_impl **pimpl, struct nvif_control_priv **ppriv)
@@ -74,6 +89,7 @@ nvkm_udevice_impl = {
 	.del = nvkm_udevice_del,
 	.time = nvkm_udevice_time,
 	.control.new = nvkm_udevice_control_new,
+	.usermode.new = nvkm_udevice_usermode_new,
 };
 
 static int
@@ -154,8 +170,6 @@ nvkm_udevice_child_get(struct nvkm_object *object, int index,
 			sclass = &device->mmu->user;
 		else if (device->fault && index-- == 0)
 			sclass = &device->fault->user;
-		else if (device->vfn && index-- == 0)
-			sclass = &device->vfn->user;
 		else
 			return -EINVAL;
 
@@ -263,6 +277,7 @@ nvkm_udevice_new(struct nvkm_device *device,
 
 	if (device->vfn) {
 		udev->impl.usermode.oclass = device->vfn->user.base.oclass;
+		udev->impl.usermode.new = nvkm_udevice_usermode_new;
 	}
 
 	if (device->mmu) {
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/vfn/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/vfn/base.c
index 62e81d551f44..2215de6c4803 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/vfn/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/vfn/base.c
@@ -54,7 +54,6 @@ nvkm_vfn_new_(const struct nvkm_vfn_func *func, struct nvkm_device *device,
 			return ret;
 	}
 
-	vfn->user.ctor = nvkm_uvfn_new;
 	vfn->user.base = func->user.base;
 	return 0;
 }
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/vfn/priv.h b/drivers/gpu/drm/nouveau/nvkm/subdev/vfn/priv.h
index 3a09781ad032..40245777c600 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/vfn/priv.h
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/vfn/priv.h
@@ -24,7 +24,4 @@ int nvkm_vfn_new_(const struct nvkm_vfn_func *, struct nvkm_device *, enum nvkm_
 		  u32 addr, struct nvkm_vfn **);
 
 extern const struct nvkm_intr_func tu102_vfn_intr;
-
-int nvkm_uvfn_new(struct nvkm_device *, const struct nvkm_oclass *, void *, u32,
-		  struct nvkm_object **);
 #endif
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/vfn/uvfn.c b/drivers/gpu/drm/nouveau/nvkm/subdev/vfn/uvfn.c
index fe35024d69ba..6b0ddeb1f568 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/vfn/uvfn.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/vfn/uvfn.c
@@ -19,6 +19,7 @@
  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
  */
+#include "uvfn.h"
 #include "priv.h"
 
 #include <core/object.h>
@@ -26,6 +27,8 @@
 struct nvif_usermode_priv {
 	struct nvkm_object object;
 	struct nvkm_vfn *vfn;
+
+	struct nvif_usermode_impl impl;
 };
 
 static int
@@ -41,26 +44,40 @@ nvkm_uvfn_map(struct nvkm_object *object, void *argv, u32 argc,
 	return 0;
 }
 
+static void
+nvkm_uvfn_del(struct nvif_usermode_priv *uvfn)
+{
+	struct nvkm_object *object = &uvfn->object;
+
+	nvkm_object_del(&object);
+}
+
+static const struct nvif_usermode_impl
+nvkm_uvfn_impl = {
+	.del = nvkm_uvfn_del,
+};
+
 static const struct nvkm_object_func
 nvkm_uvfn = {
 	.map = nvkm_uvfn_map,
 };
 
 int
-nvkm_uvfn_new(struct nvkm_device *device, const struct nvkm_oclass *oclass,
-	      void *argv, u32 argc, struct nvkm_object **pobject)
+nvkm_uvfn_new(struct nvkm_device *device, const struct nvif_usermode_impl **pimpl,
+	      struct nvif_usermode_priv **ppriv, struct nvkm_object **pobject)
 {
 	struct nvif_usermode_priv *uvfn;
 
-	if (argc != 0)
-		return -ENOSYS;
-
 	if (!(uvfn = kzalloc(sizeof(*uvfn), GFP_KERNEL)))
 		return -ENOMEM;
 
-	nvkm_object_ctor(&nvkm_uvfn, oclass, &uvfn->object);
+	nvkm_object_ctor(&nvkm_uvfn, &(struct nvkm_oclass) {}, &uvfn->object);
 	uvfn->vfn = device->vfn;
 
+	uvfn->impl = nvkm_uvfn_impl;
+
+	*pimpl = &uvfn->impl;
+	*ppriv = uvfn;
 	*pobject = &uvfn->object;
 	return 0;
 }
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/vfn/uvfn.h b/drivers/gpu/drm/nouveau/nvkm/subdev/vfn/uvfn.h
new file mode 100644
index 000000000000..23f636eb3b58
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/vfn/uvfn.h
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: MIT */
+#ifndef __NVKM_UVFN_H__
+#define __NVKM_UVFN_H__
+#include <subdev/vfn.h>
+#include <nvif/driverif.h>
+
+int nvkm_uvfn_new(struct nvkm_device *, const struct nvif_usermode_impl **,
+		  struct nvif_usermode_priv **, struct nvkm_object **);
+#endif
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 076/156] drm/nouveau/nvif: rework usermode "map" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (74 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 075/156] drm/nouveau/nvif: rework device "new usermode" api Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 077/156] drm/nouveau/nvif: remove usermode from object rb Ben Skeggs
                   ` (81 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interface

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 .../gpu/drm/nouveau/include/nvif/driverif.h    |  1 +
 drivers/gpu/drm/nouveau/include/nvif/user.h    |  1 +
 drivers/gpu/drm/nouveau/nvif/user.c            |  9 ++++++++-
 drivers/gpu/drm/nouveau/nvif/userc361.c        |  8 ++++----
 drivers/gpu/drm/nouveau/nvkm/subdev/vfn/uvfn.c | 18 ++++--------------
 5 files changed, 18 insertions(+), 19 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 35a5869eb036..3f481d19e7c6 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -72,6 +72,7 @@ struct nvif_control_impl {
 
 struct nvif_usermode_impl {
 	void (*del)(struct nvif_usermode_priv *);
+	struct nvif_mapinfo map;
 };
 
 struct nvif_device_impl {
diff --git a/drivers/gpu/drm/nouveau/include/nvif/user.h b/drivers/gpu/drm/nouveau/include/nvif/user.h
index 51104955c1e3..4214492b617b 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/user.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/user.h
@@ -7,6 +7,7 @@ struct nvif_user {
 	const struct nvif_usermode_impl *impl;
 	struct nvif_usermode_priv *priv;
 	struct nvif_object object;
+	struct nvif_map map;
 
 	const struct nvif_user_func *func;
 };
diff --git a/drivers/gpu/drm/nouveau/nvif/user.c b/drivers/gpu/drm/nouveau/nvif/user.c
index 878883aff9c5..dbeae9f1e6d2 100644
--- a/drivers/gpu/drm/nouveau/nvif/user.c
+++ b/drivers/gpu/drm/nouveau/nvif/user.c
@@ -30,6 +30,8 @@ void
 nvif_user_dtor(struct nvif_device *device)
 {
 	if (device->user.impl) {
+		nvif_object_unmap_cpu(&device->user.map);
+
 		device->user.impl->del(device->user.priv);
 		device->user.impl = NULL;
 		device->user.func = NULL;
@@ -64,6 +66,11 @@ nvif_user_ctor(struct nvif_device *device, const char *name)
 	nvif_object_ctor(&device->object, name ?: "nvifUsermode", 0, oclass, &device->user.object);
 	device->user.func = func;
 
-	nvif_object_map(&device->user.object, NULL, 0);
+	ret = nvif_object_map_cpu(&device->user.object, &device->user.impl->map, &device->user.map);
+	if (ret) {
+		nvif_user_dtor(device);
+		return ret;
+	}
+
 	return 0;
 }
diff --git a/drivers/gpu/drm/nouveau/nvif/userc361.c b/drivers/gpu/drm/nouveau/nvif/userc361.c
index 1116f871b272..2431b162b3c9 100644
--- a/drivers/gpu/drm/nouveau/nvif/userc361.c
+++ b/drivers/gpu/drm/nouveau/nvif/userc361.c
@@ -27,9 +27,9 @@ nvif_userc361_time(struct nvif_user *user)
 	u32 hi, lo;
 
 	do {
-		hi = nvif_rd32(&user->object, 0x084);
-		lo = nvif_rd32(&user->object, 0x080);
-	} while (hi != nvif_rd32(&user->object, 0x084));
+		hi = nvif_rd32(user, 0x084);
+		lo = nvif_rd32(user, 0x080);
+	} while (hi != nvif_rd32(user, 0x084));
 
 	return ((u64)hi << 32 | lo);
 }
@@ -37,7 +37,7 @@ nvif_userc361_time(struct nvif_user *user)
 static void
 nvif_userc361_doorbell(struct nvif_user *user, u32 token)
 {
-	nvif_wr32(&user->object, 0x90, token);
+	nvif_wr32(user, 0x90, token);
 }
 
 const struct nvif_user_func
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/vfn/uvfn.c b/drivers/gpu/drm/nouveau/nvkm/subdev/vfn/uvfn.c
index 6b0ddeb1f568..f00490e5aa7b 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/vfn/uvfn.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/vfn/uvfn.c
@@ -31,19 +31,6 @@ struct nvif_usermode_priv {
 	struct nvif_usermode_impl impl;
 };
 
-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 = 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;
-	*size = vfn->func->user.size;
-	*type = NVKM_OBJECT_MAP_IO;
-	return 0;
-}
-
 static void
 nvkm_uvfn_del(struct nvif_usermode_priv *uvfn)
 {
@@ -59,13 +46,13 @@ nvkm_uvfn_impl = {
 
 static const struct nvkm_object_func
 nvkm_uvfn = {
-	.map = nvkm_uvfn_map,
 };
 
 int
 nvkm_uvfn_new(struct nvkm_device *device, const struct nvif_usermode_impl **pimpl,
 	      struct nvif_usermode_priv **ppriv, struct nvkm_object **pobject)
 {
+	struct nvkm_vfn *vfn = device->vfn;
 	struct nvif_usermode_priv *uvfn;
 
 	if (!(uvfn = kzalloc(sizeof(*uvfn), GFP_KERNEL)))
@@ -75,6 +62,9 @@ nvkm_uvfn_new(struct nvkm_device *device, const struct nvif_usermode_impl **pimp
 	uvfn->vfn = device->vfn;
 
 	uvfn->impl = nvkm_uvfn_impl;
+	uvfn->impl.map.type = NVIF_MAP_IO;
+	uvfn->impl.map.handle = device->func->resource_addr(device, 0) + vfn->addr.user;
+	uvfn->impl.map.length = vfn->func->user.size;
 
 	*pimpl = &uvfn->impl;
 	*ppriv = uvfn;
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 077/156] drm/nouveau/nvif: remove usermode from object rb
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (75 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 076/156] drm/nouveau/nvif: rework usermode "map" api Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 078/156] drm/nouveau/nvif: rework device "new mmu" api Ben Skeggs
                   ` (80 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- no more users

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/include/nvif/driverif.h | 3 +--
 drivers/gpu/drm/nouveau/nvif/user.c             | 3 +--
 drivers/gpu/drm/nouveau/nvkm/device/user.c      | 5 +++--
 3 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 3f481d19e7c6..cd96e9c36f55 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -124,8 +124,7 @@ struct nvif_device_impl {
 	struct {
 		s32 oclass;
 		int (*new)(struct nvif_device_priv *,
-			   const struct nvif_usermode_impl **, struct nvif_usermode_priv **,
-			   u64 handle);
+			   const struct nvif_usermode_impl **, struct nvif_usermode_priv **);
 	} usermode;
 
 	struct {
diff --git a/drivers/gpu/drm/nouveau/nvif/user.c b/drivers/gpu/drm/nouveau/nvif/user.c
index dbeae9f1e6d2..4b955fce8382 100644
--- a/drivers/gpu/drm/nouveau/nvif/user.c
+++ b/drivers/gpu/drm/nouveau/nvif/user.c
@@ -57,8 +57,7 @@ nvif_user_ctor(struct nvif_device *device, const char *name)
 		return -ENODEV;
 	}
 
-	ret = device->impl->usermode.new(device->priv, &device->user.impl, &device->user.priv,
-					 nvif_handle(&device->user.object));
+	ret = device->impl->usermode.new(device->priv, &device->user.impl, &device->user.priv);
 	NVIF_ERRON(ret, &device->object, "[NEW usermode%04x]", oclass);
 	if (ret)
 		return ret;
diff --git a/drivers/gpu/drm/nouveau/nvkm/device/user.c b/drivers/gpu/drm/nouveau/nvkm/device/user.c
index aadd0c0956ee..cd126f5b165a 100644
--- a/drivers/gpu/drm/nouveau/nvkm/device/user.c
+++ b/drivers/gpu/drm/nouveau/nvkm/device/user.c
@@ -42,7 +42,7 @@ struct nvif_device_priv {
 
 static int
 nvkm_udevice_usermode_new(struct nvif_device_priv *udev, const struct nvif_usermode_impl **pimpl,
-			  struct nvif_usermode_priv **ppriv, u64 handle)
+			  struct nvif_usermode_priv **ppriv)
 {
 	struct nvkm_object *object;
 	int ret;
@@ -51,7 +51,8 @@ nvkm_udevice_usermode_new(struct nvif_device_priv *udev, const struct nvif_userm
 	if (ret)
 		return ret;
 
-	return nvkm_object_link_rb(udev->object.client, &udev->object, handle, object);
+	nvkm_object_link(&udev->object, object);
+	return 0;
 }
 
 static int
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 078/156] drm/nouveau/nvif: rework device "new mmu" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (76 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 077/156] drm/nouveau/nvif: remove usermode from object rb Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 079/156] drm/nouveau/nvif: rework mmu "sclass" api Ben Skeggs
                   ` (79 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interfaces

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 .../gpu/drm/nouveau/include/nvif/driverif.h   | 13 ++++++
 drivers/gpu/drm/nouveau/include/nvif/if0008.h |  7 ---
 drivers/gpu/drm/nouveau/include/nvif/mmu.h    |  8 ++--
 drivers/gpu/drm/nouveau/nouveau_drm.c         |  5 +-
 drivers/gpu/drm/nouveau/nouveau_ttm.c         |  4 +-
 drivers/gpu/drm/nouveau/nvif/mmu.c            | 30 ++++++------
 drivers/gpu/drm/nouveau/nvkm/device/user.c    | 22 +++++++--
 .../gpu/drm/nouveau/nvkm/subdev/mmu/base.c    |  1 -
 .../gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c    | 46 ++++++++++++-------
 .../gpu/drm/nouveau/nvkm/subdev/mmu/ummu.h    | 10 ++--
 10 files changed, 94 insertions(+), 52 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index cd96e9c36f55..7bba8c79d71e 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -5,6 +5,7 @@ struct nvif_client_priv;
 struct nvif_device_priv;
 struct nvif_control_priv;
 struct nvif_usermode_priv;
+struct nvif_mmu_priv;
 
 struct nvif_driver {
 	const char *name;
@@ -75,6 +76,16 @@ struct nvif_usermode_impl {
 	struct nvif_mapinfo map;
 };
 
+struct nvif_mmu_impl {
+	void (*del)(struct nvif_mmu_priv *);
+
+	u8 dmabits;
+	u8 heap_nr;
+	u8 type_nr;
+
+	u16 kind_nr;
+};
+
 struct nvif_device_impl {
 	void (*del)(struct nvif_device_priv *);
 
@@ -129,6 +140,8 @@ struct nvif_device_impl {
 
 	struct {
 		s32 oclass;
+		int (*new)(struct nvif_device_priv *, const struct nvif_mmu_impl **,
+			   struct nvif_mmu_priv **, u64 handle);
 	} mmu;
 
 	struct {
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0008.h b/drivers/gpu/drm/nouveau/include/nvif/if0008.h
index c21d09f04f1d..618df13762d3 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/if0008.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/if0008.h
@@ -1,12 +1,5 @@
 #ifndef __NVIF_IF0008_H__
 #define __NVIF_IF0008_H__
-struct nvif_mmu_v0 {
-	__u8  version;
-	__u8  dmabits;
-	__u8  heap_nr;
-	__u8  type_nr;
-	__u16 kind_nr;
-};
 
 #define NVIF_MMU_V0_HEAP                                                   0x00
 #define NVIF_MMU_V0_TYPE                                                   0x01
diff --git a/drivers/gpu/drm/nouveau/include/nvif/mmu.h b/drivers/gpu/drm/nouveau/include/nvif/mmu.h
index 2035ef1d35f5..414caaa2230a 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/mmu.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/mmu.h
@@ -1,10 +1,13 @@
 #ifndef __NVIF_MMU_H__
 #define __NVIF_MMU_H__
 #include <nvif/object.h>
+#include <nvif/driverif.h>
+struct nvif_device;
 
 struct nvif_mmu {
+	const struct nvif_mmu_impl *impl;
+	struct nvif_mmu_priv *priv;
 	struct nvif_object object;
-	u8  dmabits;
 	u8  heap_nr;
 	u8  type_nr;
 	u8  kind_inv;
@@ -31,8 +34,7 @@ struct nvif_mmu {
 	u8 *kind;
 };
 
-int nvif_mmu_ctor(struct nvif_object *, const char *name, s32 oclass,
-		  struct nvif_mmu *);
+int nvif_mmu_ctor(struct nvif_device *, const char *name, struct nvif_mmu *);
 void nvif_mmu_dtor(struct nvif_mmu *);
 
 static inline bool
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index a91ad8e65a0f..1dba64a1e590 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -236,8 +236,7 @@ nouveau_cli_init(struct nouveau_drm *drm, const char *sname,
 
 	cli->device.object.map.ptr = drm->device.object.map.ptr;
 
-	ret = nvif_mmu_ctor(&cli->device.object, "drmMmu", drm->mmu.object.oclass,
-			    &cli->mmu);
+	ret = nvif_mmu_ctor(&cli->device, "drmMmu", &cli->mmu);
 	if (ret) {
 		NV_PRINTK(err, cli, "MMU allocation failed: %d\n", ret);
 		goto done;
@@ -569,7 +568,7 @@ nouveau_drm_device_init(struct drm_device *dev, struct nvkm_device *nvkm)
 		goto fail_nvif;
 	}
 
-	ret = nvif_mmu_ctor(&drm->device.object, "drmMmu", drm->device.impl->mmu.oclass, &drm->mmu);
+	ret = nvif_mmu_ctor(&drm->device, "drmMmu", &drm->mmu);
 	if (ret) {
 		NV_ERROR(drm, "MMU allocation failed: %d\n", ret);
 		goto fail_nvif;
diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c
index 57c7e3ba8e7b..f87ca8a0e6ae 100644
--- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
@@ -302,8 +302,8 @@ nouveau_ttm_init(struct nouveau_drm *drm)
 	ret = ttm_device_init(&drm->ttm.bdev, &nouveau_bo_driver, drm->dev->dev,
 				  dev->anon_inode->i_mapping,
 				  dev->vma_offset_manager,
-				  drm_need_swiotlb(drm->client.mmu.dmabits),
-				  drm->client.mmu.dmabits <= 32);
+				  drm_need_swiotlb(drm->mmu.impl->dmabits),
+				  drm->mmu.impl->dmabits <= 32);
 	if (ret) {
 		NV_ERROR(drm, "error initialising bo driver, %d\n", ret);
 		return ret;
diff --git a/drivers/gpu/drm/nouveau/nvif/mmu.c b/drivers/gpu/drm/nouveau/nvif/mmu.c
index c9dd3cff49a0..cc15cf99462c 100644
--- a/drivers/gpu/drm/nouveau/nvif/mmu.c
+++ b/drivers/gpu/drm/nouveau/nvif/mmu.c
@@ -20,6 +20,8 @@
  * OTHER DEALINGS IN THE SOFTWARE.
  */
 #include <nvif/mmu.h>
+#include <nvif/device.h>
+#include <nvif/printf.h>
 
 #include <nvif/class.h>
 #include <nvif/if0008.h>
@@ -27,18 +29,18 @@
 void
 nvif_mmu_dtor(struct nvif_mmu *mmu)
 {
-	if (!nvif_object_constructed(&mmu->object))
+	if (!mmu->impl)
 		return;
 
 	kfree(mmu->kind);
 	kfree(mmu->type);
 	kfree(mmu->heap);
-	nvif_object_dtor(&mmu->object);
+	mmu->impl->del(mmu->priv);
+	mmu->impl = NULL;
 }
 
 int
-nvif_mmu_ctor(struct nvif_object *parent, const char *name, s32 oclass,
-	      struct nvif_mmu *mmu)
+nvif_mmu_ctor(struct nvif_device *device, const char *name, struct nvif_mmu *mmu)
 {
 	static const struct nvif_mclass mems[] = {
 		{ NVIF_CLASS_MEM_GF100, -1 },
@@ -46,23 +48,25 @@ nvif_mmu_ctor(struct nvif_object *parent, const char *name, s32 oclass,
 		{ NVIF_CLASS_MEM_NV04 , -1 },
 		{}
 	};
-	struct nvif_mmu_v0 args;
+	const s32 oclass = device->impl->mmu.oclass;
 	int ret, i;
 
-	args.version = 0;
+	mmu->impl = NULL;
 	mmu->heap = NULL;
 	mmu->type = NULL;
 	mmu->kind = NULL;
 
-	ret = nvif_object_ctor(parent, name ? name : "nvifMmu", 0, oclass,
-			       &args, sizeof(args), &mmu->object);
+	ret = device->impl->mmu.new(device->priv, &mmu->impl, &mmu->priv,
+				    nvif_handle(&mmu->object));
+	NVIF_ERRON(ret, &device->object, "[NEW mmu%08x]", oclass);
 	if (ret)
-		goto done;
+		return ret;
+
+	nvif_object_ctor(&device->object, name ?: "nvifMmu", 0, oclass, &mmu->object);
 
-	mmu->dmabits = args.dmabits;
-	mmu->heap_nr = args.heap_nr;
-	mmu->type_nr = args.type_nr;
-	mmu->kind_nr = args.kind_nr;
+	mmu->heap_nr = mmu->impl->heap_nr;
+	mmu->type_nr = mmu->impl->type_nr;
+	mmu->kind_nr = mmu->impl->kind_nr;
 
 	ret = nvif_mclass(&mmu->object, mems);
 	if (ret < 0)
diff --git a/drivers/gpu/drm/nouveau/nvkm/device/user.c b/drivers/gpu/drm/nouveau/nvkm/device/user.c
index cd126f5b165a..e9486d9da64b 100644
--- a/drivers/gpu/drm/nouveau/nvkm/device/user.c
+++ b/drivers/gpu/drm/nouveau/nvkm/device/user.c
@@ -29,6 +29,7 @@
 #include <subdev/fb.h>
 #include <subdev/instmem.h>
 #include <subdev/timer.h>
+#include <subdev/mmu/ummu.h>
 #include <subdev/vfn/uvfn.h>
 #include <engine/disp/priv.h>
 #include <engine/fifo/ufifo.h>
@@ -76,6 +77,22 @@ nvkm_udevice_time(struct nvif_device_priv *udev)
 	return nvkm_timer_read(udev->device->timer);
 }
 
+static int
+nvkm_udevice_mmu_new(struct nvif_device_priv *udev,
+		     const struct nvif_mmu_impl **pimpl, struct nvif_mmu_priv **ppriv,
+		     u64 handle)
+{
+	struct nvkm_device *device = udev->device;
+	struct nvkm_object *object;
+	int ret;
+
+	ret = nvkm_ummu_new(device, pimpl, ppriv, &object);
+	if (ret)
+		return ret;
+
+	return nvkm_object_link_rb(udev->object.client, &udev->object, handle, object);
+}
+
 static void
 nvkm_udevice_del(struct nvif_device_priv *udev)
 {
@@ -167,9 +184,7 @@ nvkm_udevice_child_get(struct nvkm_object *object, int index,
 	}
 
 	if (!sclass) {
-		if (device->mmu && index-- == 0)
-			sclass = &device->mmu->user;
-		else if (device->fault && index-- == 0)
+		if (device->fault && index-- == 0)
 			sclass = &device->fault->user;
 		else
 			return -EINVAL;
@@ -283,6 +298,7 @@ nvkm_udevice_new(struct nvkm_device *device,
 
 	if (device->mmu) {
 		udev->impl.mmu.oclass = device->mmu->user.base.oclass;
+		udev->impl.mmu.new = nvkm_udevice_mmu_new;
 	}
 
 	if (device->fault) {
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/base.c
index 7b949a43c372..08ad3ed84631 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/base.c
@@ -426,7 +426,6 @@ nvkm_mmu_ctor(const struct nvkm_mmu_func *func, struct nvkm_device *device,
 	mmu->dma_bits = func->dma_bits;
 	nvkm_mmu_ptc_init(mmu);
 	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);
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c
index 3f008402f451..f97dec6c3309 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c
@@ -129,6 +129,19 @@ nvkm_ummu_kind(struct nvkm_ummu *ummu, void *argv, u32 argc)
 	return 0;
 }
 
+static void
+nvkm_ummu_del(struct nvif_mmu_priv *ummu)
+{
+	struct nvkm_object *object = &ummu->object;
+
+	nvkm_object_del(&object);
+}
+
+static const struct nvif_mmu_impl
+nvkm_ummu_impl = {
+	.del = nvkm_ummu_del,
+};
+
 static int
 nvkm_ummu_mthd(struct nvkm_object *object, u32 mthd, void *argv, u32 argc)
 {
@@ -150,32 +163,31 @@ nvkm_ummu = {
 };
 
 int
-nvkm_ummu_new(struct nvkm_device *device, const struct nvkm_oclass *oclass,
-	      void *argv, u32 argc, struct nvkm_object **pobject)
+nvkm_ummu_new(struct nvkm_device *device, const struct nvif_mmu_impl **pimpl,
+	      struct nvif_mmu_priv **ppriv, struct nvkm_object **pobject)
 {
-	union {
-		struct nvif_mmu_v0 v0;
-	} *args = argv;
 	struct nvkm_mmu *mmu = device->mmu;
 	struct nvif_mmu_priv *ummu;
-	int ret = -ENOSYS, kinds = 0;
+	int kinds = 0;
 	u8 unused = 0;
 
+	if (!(ummu = kzalloc(sizeof(*ummu), GFP_KERNEL)))
+		return -ENOMEM;
+
+	nvkm_object_ctor(&nvkm_ummu, &(struct nvkm_oclass) {}, &ummu->object);
+	ummu->mmu = mmu;
+	ummu->impl = nvkm_ummu_impl;
+
 	if (mmu->func->kind)
 		mmu->func->kind(mmu, &kinds, &unused);
 
-	if (!(ret = nvif_unpack(ret, &argv, &argc, args->v0, 0, 0, false))) {
-		args->v0.dmabits = mmu->dma_bits;
-		args->v0.heap_nr = mmu->heap_nr;
-		args->v0.type_nr = mmu->type_nr;
-		args->v0.kind_nr = kinds;
-	} else
-		return ret;
+	ummu->impl.dmabits = mmu->dma_bits;
+	ummu->impl.heap_nr = mmu->heap_nr;
+	ummu->impl.type_nr = mmu->type_nr;
+	ummu->impl.kind_nr = kinds;
 
-	if (!(ummu = kzalloc(sizeof(*ummu), GFP_KERNEL)))
-		return -ENOMEM;
-	nvkm_object_ctor(&nvkm_ummu, oclass, &ummu->object);
-	ummu->mmu = mmu;
+	*pimpl = &ummu->impl;
+	*ppriv = ummu;
 	*pobject = &ummu->object;
 	return 0;
 }
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.h b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.h
index 35ae48758017..c03563aa4cae 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.h
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.h
@@ -1,15 +1,19 @@
 #ifndef __NVKM_UMMU_H__
 #define __NVKM_UMMU_H__
 #include <core/object.h>
-#include "priv.h"
+struct nvkm_device;
+
+#include <nvif/driverif.h>
 
 #define nvkm_ummu nvif_mmu_priv
 
 struct nvif_mmu_priv {
 	struct nvkm_object object;
 	struct nvkm_mmu *mmu;
+
+	struct nvif_mmu_impl impl;
 };
 
-int nvkm_ummu_new(struct nvkm_device *, const struct nvkm_oclass *,
-		  void *argv, u32 argc, struct nvkm_object **);
+int nvkm_ummu_new(struct nvkm_device *, const struct nvif_mmu_impl **, struct nvif_mmu_priv **,
+		  struct nvkm_object **);
 #endif
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 079/156] drm/nouveau/nvif: rework mmu "sclass" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (77 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 078/156] drm/nouveau/nvif: rework device "new mmu" api Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 080/156] drm/nouveau/nvif: rework mmu "heap" api Ben Skeggs
                   ` (78 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interface

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  8 +++
 drivers/gpu/drm/nouveau/include/nvif/mem.h    |  4 +-
 drivers/gpu/drm/nouveau/include/nvif/mmu.h    |  1 -
 drivers/gpu/drm/nouveau/include/nvif/vmm.h    |  2 +-
 drivers/gpu/drm/nouveau/nouveau_bo.c          | 10 ++--
 drivers/gpu/drm/nouveau/nouveau_chan.c        |  2 +-
 drivers/gpu/drm/nouveau/nouveau_drm.c         | 54 ++++++++-----------
 drivers/gpu/drm/nouveau/nouveau_drv.h         |  2 -
 drivers/gpu/drm/nouveau/nouveau_mem.c         | 10 ++--
 drivers/gpu/drm/nouveau/nouveau_svm.c         |  3 +-
 drivers/gpu/drm/nouveau/nouveau_uvmm.c        |  3 +-
 drivers/gpu/drm/nouveau/nouveau_vmm.c         |  4 +-
 drivers/gpu/drm/nouveau/nouveau_vmm.h         |  2 +-
 drivers/gpu/drm/nouveau/nvif/mem.c            | 10 ++--
 drivers/gpu/drm/nouveau/nvif/mmu.c            | 11 ----
 drivers/gpu/drm/nouveau/nvif/vmm.c            |  4 +-
 .../gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c    |  4 ++
 17 files changed, 60 insertions(+), 74 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 7bba8c79d71e..a1b97bc5e933 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -84,6 +84,14 @@ struct nvif_mmu_impl {
 	u8 type_nr;
 
 	u16 kind_nr;
+
+	struct {
+		s32 oclass;
+	} mem;
+
+	struct {
+		s32 oclass;
+	} vmm;
 };
 
 struct nvif_device_impl {
diff --git a/drivers/gpu/drm/nouveau/include/nvif/mem.h b/drivers/gpu/drm/nouveau/include/nvif/mem.h
index 9e1071dd56a0..217d13126f13 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/mem.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/mem.h
@@ -10,10 +10,10 @@ struct nvif_mem {
 	u64 size;
 };
 
-int nvif_mem_ctor_type(struct nvif_mmu *mmu, const char *name, s32 oclass,
+int nvif_mem_ctor_type(struct nvif_mmu *mmu, const char *name,
 		       int type, u8 page, u64 size, void *argv, u32 argc,
 		       struct nvif_mem *);
-int nvif_mem_ctor(struct nvif_mmu *mmu, const char *name, s32 oclass, u8 type,
+int nvif_mem_ctor(struct nvif_mmu *mmu, const char *name, u8 type,
 		  u8 page, u64 size, void *argv, u32 argc, struct nvif_mem *);
 void nvif_mem_dtor(struct nvif_mem *);
 
diff --git a/drivers/gpu/drm/nouveau/include/nvif/mmu.h b/drivers/gpu/drm/nouveau/include/nvif/mmu.h
index 414caaa2230a..ed5d011f4237 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/mmu.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/mmu.h
@@ -12,7 +12,6 @@ struct nvif_mmu {
 	u8  type_nr;
 	u8  kind_inv;
 	u16 kind_nr;
-	s32 mem;
 
 	struct {
 		u64 size;
diff --git a/drivers/gpu/drm/nouveau/include/nvif/vmm.h b/drivers/gpu/drm/nouveau/include/nvif/vmm.h
index 0ecedd0ee0a5..e8d8fbd56010 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/vmm.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/vmm.h
@@ -36,7 +36,7 @@ struct nvif_vmm {
 	int page_nr;
 };
 
-int nvif_vmm_ctor(struct nvif_mmu *, const char *name, s32 oclass,
+int nvif_vmm_ctor(struct nvif_mmu *, const char *name,
 		  enum nvif_vmm_type, u64 addr, u64 size, void *argv, u32 argc,
 		  struct nvif_vmm *);
 void nvif_vmm_dtor(struct nvif_vmm *);
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
index e1483fd5d283..cbb8f54db83f 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -1158,7 +1158,7 @@ nouveau_ttm_io_mem_free_locked(struct nouveau_drm *drm,
 {
 	struct nouveau_mem *mem = nouveau_mem(reg);
 
-	if (drm->client.mem->oclass >= NVIF_CLASS_MEM_NV50) {
+	if (drm->mmu.impl->mem.oclass >= NVIF_CLASS_MEM_NV50) {
 		switch (reg->mem_type) {
 		case TTM_PL_TT:
 			if (mem->kind)
@@ -1179,7 +1179,7 @@ nouveau_ttm_io_mem_reserve(struct ttm_device *bdev, struct ttm_resource *reg)
 	struct nouveau_drm *drm = nouveau_bdev(bdev);
 	struct nvkm_device *device = nvxx_device(&drm->client.device);
 	struct nouveau_mem *mem = nouveau_mem(reg);
-	struct nvif_mmu *mmu = &drm->client.mmu;
+	struct nvif_mmu *mmu = &drm->mmu;
 	int ret;
 
 	mutex_lock(&drm->ttm.io_reserve_mutex);
@@ -1198,7 +1198,7 @@ nouveau_ttm_io_mem_reserve(struct ttm_device *bdev, struct ttm_resource *reg)
 			reg->bus.caching = ttm_write_combined;
 		}
 #endif
-		if (drm->client.mem->oclass < NVIF_CLASS_MEM_NV50 ||
+		if (mmu->impl->mem.oclass < NVIF_CLASS_MEM_NV50 ||
 		    !mem->kind) {
 			/* untiled */
 			ret = 0;
@@ -1217,7 +1217,7 @@ nouveau_ttm_io_mem_reserve(struct ttm_device *bdev, struct ttm_resource *reg)
 		else
 			reg->bus.caching = ttm_write_combined;
 
-		if (drm->client.mem->oclass >= NVIF_CLASS_MEM_NV50) {
+		if (mmu->impl->mem.oclass >= NVIF_CLASS_MEM_NV50) {
 			union {
 				struct nv50_mem_map_v0 nv50;
 				struct gf100_mem_map_v0 gf100;
@@ -1225,7 +1225,7 @@ nouveau_ttm_io_mem_reserve(struct ttm_device *bdev, struct ttm_resource *reg)
 			u64 handle, length;
 			u32 argc = 0;
 
-			switch (mem->mem.object.oclass) {
+			switch (mmu->impl->mem.oclass) {
 			case NVIF_CLASS_MEM_NV50:
 				args.nv50.version = 0;
 				args.nv50.ro = 0;
diff --git a/drivers/gpu/drm/nouveau/nouveau_chan.c b/drivers/gpu/drm/nouveau/nouveau_chan.c
index 636ca1f284f8..dd4f9915ccaf 100644
--- a/drivers/gpu/drm/nouveau/nouveau_chan.c
+++ b/drivers/gpu/drm/nouveau/nouveau_chan.c
@@ -328,7 +328,7 @@ nouveau_channel_ctor(struct nouveau_cli *cli, bool priv, u64 runm,
 
 	/* allocate userd */
 	if (oclass >= VOLTA_CHANNEL_GPFIFO_A) {
-		ret = nvif_mem_ctor(&cli->mmu, "abi16ChanUSERD", NVIF_CLASS_MEM_GF100,
+		ret = nvif_mem_ctor(&cli->mmu, "abi16ChanUSERD",
 				    NVIF_MEM_VRAM | NVIF_MEM_COHERENT | NVIF_MEM_MAPPABLE,
 				    0, PAGE_SIZE, NULL, 0, &chan->mem_userd);
 		if (ret)
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 1dba64a1e590..8ab6b9e03eb5 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -194,22 +194,6 @@ static int
 nouveau_cli_init(struct nouveau_drm *drm, const char *sname,
 		 struct nouveau_cli *cli)
 {
-	static const struct nvif_mclass
-	mems[] = {
-		{ NVIF_CLASS_MEM_GF100, -1 },
-		{ NVIF_CLASS_MEM_NV50 , -1 },
-		{ NVIF_CLASS_MEM_NV04 , -1 },
-		{}
-	};
-	static const struct nvif_mclass
-	vmms[] = {
-		{ NVIF_CLASS_VMM_GP100, -1 },
-		{ NVIF_CLASS_VMM_GM200, -1 },
-		{ NVIF_CLASS_VMM_GF100, -1 },
-		{ NVIF_CLASS_VMM_NV50 , -1 },
-		{ NVIF_CLASS_VMM_NV04 , -1 },
-		{}
-	};
 	int ret;
 
 	snprintf(cli->name, sizeof(cli->name), "%s", sname);
@@ -242,26 +226,12 @@ nouveau_cli_init(struct nouveau_drm *drm, const char *sname,
 		goto done;
 	}
 
-	ret = nvif_mclass(&cli->mmu.object, vmms);
-	if (ret < 0) {
-		NV_PRINTK(err, cli, "No supported VMM class\n");
-		goto done;
-	}
-
-	ret = nouveau_vmm_init(cli, vmms[ret].oclass, &cli->vmm);
+	ret = nouveau_vmm_init(cli, &cli->vmm);
 	if (ret) {
 		NV_PRINTK(err, cli, "VMM allocation failed: %d\n", ret);
 		goto done;
 	}
 
-	ret = nvif_mclass(&cli->mmu.object, mems);
-	if (ret < 0) {
-		NV_PRINTK(err, cli, "No supported MEM class\n");
-		goto done;
-	}
-
-	cli->mem = &mems[ret];
-
 	/* Don't pass in the (shared) sched_wq in order to let
 	 * nouveau_sched_create() create a dedicated one for VM_BIND jobs.
 	 *
@@ -574,6 +544,28 @@ nouveau_drm_device_init(struct drm_device *dev, struct nvkm_device *nvkm)
 		goto fail_nvif;
 	}
 
+	switch (drm->mmu.impl->mem.oclass) {
+	case NVIF_CLASS_MEM_GF100:
+	case NVIF_CLASS_MEM_NV50:
+	case NVIF_CLASS_MEM_NV04:
+		break;
+	default:
+		NV_ERROR(drm, "No supported MEM class (0x%04x)\n", drm->mmu.impl->mem.oclass);
+		goto fail_nvif;
+	}
+
+	switch (drm->mmu.impl->vmm.oclass) {
+	case NVIF_CLASS_VMM_GP100:
+	case NVIF_CLASS_VMM_GM200:
+	case NVIF_CLASS_VMM_GF100:
+	case NVIF_CLASS_VMM_NV50:
+	case NVIF_CLASS_VMM_NV04:
+		break;
+	default:
+		NV_ERROR(drm, "No supported VMM class (0x%04x)\n", drm->mmu.impl->vmm.oclass);
+		goto fail_nvif;
+	}
+
 	drm->sched_wq = alloc_workqueue("nouveau_sched_wq_shared", 0,
 					WQ_MAX_ACTIVE);
 	if (!drm->sched_wq) {
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h
index 35dfc95b32ed..38d33a4d5c49 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.h
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.h
@@ -100,8 +100,6 @@ struct nouveau_cli {
 
 	struct nouveau_sched *sched;
 
-	const struct nvif_mclass *mem;
-
 	struct list_head head;
 	void *abi16;
 	struct list_head objects;
diff --git a/drivers/gpu/drm/nouveau/nouveau_mem.c b/drivers/gpu/drm/nouveau/nouveau_mem.c
index baea74899fcf..75abd545c92d 100644
--- a/drivers/gpu/drm/nouveau/nouveau_mem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_mem.c
@@ -90,7 +90,6 @@ 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->cli;
 	struct nvif_mmu *mmu = &drm->mmu;
 	struct nvif_mem_ram_v0 args = {};
 	u8 type;
@@ -115,7 +114,7 @@ nouveau_mem_host(struct ttm_resource *reg, struct ttm_tt *tt)
 		args.dma = tt->dma_address;
 
 	mutex_lock(&drm->client_mutex);
-	ret = nvif_mem_ctor_type(mmu, "ttmHostMem", cli->mem->oclass, type, PAGE_SHIFT,
+	ret = nvif_mem_ctor_type(mmu, "ttmHostMem", type, PAGE_SHIFT,
 				 reg->size,
 				 &args, sizeof(args), &mem->mem);
 	mutex_unlock(&drm->client_mutex);
@@ -127,15 +126,14 @@ 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->cli;
 	struct nvif_mmu *mmu = &drm->mmu;
 	u64 size = ALIGN(reg->size, 1 << page);
 	int ret;
 
 	mutex_lock(&drm->client_mutex);
-	switch (cli->mem->oclass) {
+	switch (drm->mmu.impl->mem.oclass) {
 	case NVIF_CLASS_MEM_GF100:
-		ret = nvif_mem_ctor_type(mmu, "ttmVram", cli->mem->oclass,
+		ret = nvif_mem_ctor_type(mmu, "ttmVram",
 					 drm->ttm.type_vram, page, size,
 					 &(struct gf100_mem_v0) {
 						.contig = contig,
@@ -143,7 +141,7 @@ nouveau_mem_vram(struct ttm_resource *reg, bool contig, u8 page)
 					 &mem->mem);
 		break;
 	case NVIF_CLASS_MEM_NV50:
-		ret = nvif_mem_ctor_type(mmu, "ttmVram", cli->mem->oclass,
+		ret = nvif_mem_ctor_type(mmu, "ttmVram",
 					 drm->ttm.type_vram, page, size,
 					 &(struct nv50_mem_v0) {
 						.bankswz = mmu->kind[mem->kind] == 2,
diff --git a/drivers/gpu/drm/nouveau/nouveau_svm.c b/drivers/gpu/drm/nouveau/nouveau_svm.c
index 477336672652..a478b5a9ed0a 100644
--- a/drivers/gpu/drm/nouveau/nouveau_svm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_svm.c
@@ -346,8 +346,7 @@ nouveau_svmm_init(struct drm_device *dev, void *data,
 	 * All future channel/memory allocations will make use of this
 	 * VMM instead of the standard one.
 	 */
-	ret = nvif_vmm_ctor(&cli->mmu, "svmVmm",
-			    cli->vmm.vmm.object.oclass, MANAGED,
+	ret = nvif_vmm_ctor(&cli->mmu, "svmVmm", MANAGED,
 			    args->unmanaged_addr, args->unmanaged_size,
 			    &(struct gp100_vmm_v0) {
 				.fault_replay = true,
diff --git a/drivers/gpu/drm/nouveau/nouveau_uvmm.c b/drivers/gpu/drm/nouveau/nouveau_uvmm.c
index 0a0a11dc9ec0..d35096071c1a 100644
--- a/drivers/gpu/drm/nouveau/nouveau_uvmm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_uvmm.c
@@ -1865,8 +1865,7 @@ nouveau_uvmm_ioctl_vm_init(struct drm_device *dev,
 	/* GPUVM takes care from here on. */
 	drm_gem_object_put(r_obj);
 
-	ret = nvif_vmm_ctor(&cli->mmu, "uvmm",
-			    cli->vmm.vmm.object.oclass, RAW,
+	ret = nvif_vmm_ctor(&cli->mmu, "uvmm", RAW,
 			    init->kernel_managed_addr,
 			    init->kernel_managed_size,
 			    NULL, 0, &uvmm->vmm.vmm);
diff --git a/drivers/gpu/drm/nouveau/nouveau_vmm.c b/drivers/gpu/drm/nouveau/nouveau_vmm.c
index 3dda885df5b2..93807d21ceff 100644
--- a/drivers/gpu/drm/nouveau/nouveau_vmm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_vmm.c
@@ -129,9 +129,9 @@ nouveau_vmm_fini(struct nouveau_vmm *vmm)
 }
 
 int
-nouveau_vmm_init(struct nouveau_cli *cli, s32 oclass, struct nouveau_vmm *vmm)
+nouveau_vmm_init(struct nouveau_cli *cli, struct nouveau_vmm *vmm)
 {
-	int ret = nvif_vmm_ctor(&cli->mmu, "drmVmm", oclass, UNMANAGED,
+	int ret = nvif_vmm_ctor(&cli->mmu, "drmVmm", UNMANAGED,
 				PAGE_SIZE, 0, NULL, 0, &vmm->vmm);
 	if (ret)
 		return ret;
diff --git a/drivers/gpu/drm/nouveau/nouveau_vmm.h b/drivers/gpu/drm/nouveau/nouveau_vmm.h
index 2b98d975f37e..196d8a819617 100644
--- a/drivers/gpu/drm/nouveau/nouveau_vmm.h
+++ b/drivers/gpu/drm/nouveau/nouveau_vmm.h
@@ -28,6 +28,6 @@ struct nouveau_vmm {
 	struct nouveau_svmm *svmm;
 };
 
-int nouveau_vmm_init(struct nouveau_cli *, s32 oclass, struct nouveau_vmm *);
+int nouveau_vmm_init(struct nouveau_cli *, struct nouveau_vmm *);
 void nouveau_vmm_fini(struct nouveau_vmm *);
 #endif
diff --git a/drivers/gpu/drm/nouveau/nvif/mem.c b/drivers/gpu/drm/nouveau/nvif/mem.c
index 0e1b7b4c2e91..0f0b4a7c5e80 100644
--- a/drivers/gpu/drm/nouveau/nvif/mem.c
+++ b/drivers/gpu/drm/nouveau/nvif/mem.c
@@ -28,7 +28,7 @@ int
 nvif_mem_ctor_map(struct nvif_mmu *mmu, const char *name, u8 type, u64 size,
 		  struct nvif_mem *mem)
 {
-	int ret = nvif_mem_ctor(mmu, name, mmu->mem, NVIF_MEM_MAPPABLE | type,
+	int ret = nvif_mem_ctor(mmu, name, NVIF_MEM_MAPPABLE | type,
 				0, size, NULL, 0, mem);
 	if (ret == 0) {
 		ret = nvif_object_map(&mem->object, NULL, 0);
@@ -45,7 +45,7 @@ nvif_mem_dtor(struct nvif_mem *mem)
 }
 
 int
-nvif_mem_ctor_type(struct nvif_mmu *mmu, const char *name, s32 oclass,
+nvif_mem_ctor_type(struct nvif_mmu *mmu, const char *name,
 		   int type, u8 page, u64 size, void *argv, u32 argc,
 		   struct nvif_mem *mem)
 {
@@ -69,7 +69,7 @@ nvif_mem_ctor_type(struct nvif_mmu *mmu, const char *name, s32 oclass,
 	args->size = size;
 	memcpy(args->data, argv, argc);
 
-	ret = nvif_object_ctor(&mmu->object, name ? name : "nvifMem", 0, oclass,
+	ret = nvif_object_ctor(&mmu->object, name ? name : "nvifMem", 0, mmu->impl->mem.oclass,
 			       args, sizeof(*args) + argc, &mem->object);
 	if (ret == 0) {
 		mem->type = mmu->type[type].type;
@@ -85,7 +85,7 @@ nvif_mem_ctor_type(struct nvif_mmu *mmu, const char *name, s32 oclass,
 }
 
 int
-nvif_mem_ctor(struct nvif_mmu *mmu, const char *name, s32 oclass, u8 type,
+nvif_mem_ctor(struct nvif_mmu *mmu, const char *name, u8 type,
 	      u8 page, u64 size, void *argv, u32 argc, struct nvif_mem *mem)
 {
 	int ret = -EINVAL, i;
@@ -94,7 +94,7 @@ nvif_mem_ctor(struct nvif_mmu *mmu, const char *name, s32 oclass, u8 type,
 
 	for (i = 0; ret && i < mmu->type_nr; i++) {
 		if ((mmu->type[i].type & type) == type) {
-			ret = nvif_mem_ctor_type(mmu, name, oclass, i, page,
+			ret = nvif_mem_ctor_type(mmu, name, i, page,
 						 size, argv, argc, mem);
 		}
 	}
diff --git a/drivers/gpu/drm/nouveau/nvif/mmu.c b/drivers/gpu/drm/nouveau/nvif/mmu.c
index cc15cf99462c..7e592a6d8530 100644
--- a/drivers/gpu/drm/nouveau/nvif/mmu.c
+++ b/drivers/gpu/drm/nouveau/nvif/mmu.c
@@ -42,12 +42,6 @@ nvif_mmu_dtor(struct nvif_mmu *mmu)
 int
 nvif_mmu_ctor(struct nvif_device *device, const char *name, struct nvif_mmu *mmu)
 {
-	static const struct nvif_mclass mems[] = {
-		{ NVIF_CLASS_MEM_GF100, -1 },
-		{ NVIF_CLASS_MEM_NV50 , -1 },
-		{ NVIF_CLASS_MEM_NV04 , -1 },
-		{}
-	};
 	const s32 oclass = device->impl->mmu.oclass;
 	int ret, i;
 
@@ -68,11 +62,6 @@ nvif_mmu_ctor(struct nvif_device *device, const char *name, struct nvif_mmu *mmu
 	mmu->type_nr = mmu->impl->type_nr;
 	mmu->kind_nr = mmu->impl->kind_nr;
 
-	ret = nvif_mclass(&mmu->object, mems);
-	if (ret < 0)
-		goto done;
-	mmu->mem = mems[ret].oclass;
-
 	mmu->heap = kmalloc_array(mmu->heap_nr, sizeof(*mmu->heap),
 				  GFP_KERNEL);
 	mmu->type = kmalloc_array(mmu->type_nr, sizeof(*mmu->type),
diff --git a/drivers/gpu/drm/nouveau/nvif/vmm.c b/drivers/gpu/drm/nouveau/nvif/vmm.c
index 99296f03371a..2738ea9229cc 100644
--- a/drivers/gpu/drm/nouveau/nvif/vmm.c
+++ b/drivers/gpu/drm/nouveau/nvif/vmm.c
@@ -196,7 +196,7 @@ nvif_vmm_dtor(struct nvif_vmm *vmm)
 }
 
 int
-nvif_vmm_ctor(struct nvif_mmu *mmu, const char *name, s32 oclass,
+nvif_vmm_ctor(struct nvif_mmu *mmu, const char *name,
 	      enum nvif_vmm_type type, u64 addr, u64 size, void *argv, u32 argc,
 	      struct nvif_vmm *vmm)
 {
@@ -225,7 +225,7 @@ nvif_vmm_ctor(struct nvif_mmu *mmu, const char *name, s32 oclass,
 	memcpy(args->data, argv, argc);
 
 	ret = nvif_object_ctor(&mmu->object, name ? name : "nvifVmm", 0,
-			       oclass, args, argn, &vmm->object);
+			       mmu->impl->vmm.oclass, args, argn, &vmm->object);
 	if (ret)
 		goto done;
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c
index f97dec6c3309..9f44d469b4da 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c
@@ -186,6 +186,10 @@ nvkm_ummu_new(struct nvkm_device *device, const struct nvif_mmu_impl **pimpl,
 	ummu->impl.type_nr = mmu->type_nr;
 	ummu->impl.kind_nr = kinds;
 
+	ummu->impl.mem.oclass = mmu->func->mem.user.oclass;
+
+	ummu->impl.vmm.oclass = mmu->func->vmm.user.oclass;
+
 	*pimpl = &ummu->impl;
 	*ppriv = ummu;
 	*pobject = &ummu->object;
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 080/156] drm/nouveau/nvif: rework mmu "heap" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (78 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 079/156] drm/nouveau/nvif: rework mmu "sclass" api Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 081/156] drm/nouveau/nvif: rework mmu "type" api Ben Skeggs
                   ` (77 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interface

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  4 ++++
 drivers/gpu/drm/nouveau/include/nvif/if0008.h |  8 -------
 drivers/gpu/drm/nouveau/include/nvif/mmu.h    |  5 ----
 drivers/gpu/drm/nouveau/nvif/mmu.c            | 18 +--------------
 .../gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c    | 23 ++-----------------
 5 files changed, 7 insertions(+), 51 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index a1b97bc5e933..9205c2c3b34e 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -85,6 +85,10 @@ struct nvif_mmu_impl {
 
 	u16 kind_nr;
 
+	struct {
+		u64 size;
+	} heap[4];
+
 	struct {
 		s32 oclass;
 	} mem;
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0008.h b/drivers/gpu/drm/nouveau/include/nvif/if0008.h
index 618df13762d3..551bdf49d6e2 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/if0008.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/if0008.h
@@ -1,17 +1,9 @@
 #ifndef __NVIF_IF0008_H__
 #define __NVIF_IF0008_H__
 
-#define NVIF_MMU_V0_HEAP                                                   0x00
 #define NVIF_MMU_V0_TYPE                                                   0x01
 #define NVIF_MMU_V0_KIND                                                   0x02
 
-struct nvif_mmu_heap_v0 {
-	__u8  version;
-	__u8  index;
-	__u8  pad02[6];
-	__u64 size;
-};
-
 struct nvif_mmu_type_v0 {
 	__u8  version;
 	__u8  index;
diff --git a/drivers/gpu/drm/nouveau/include/nvif/mmu.h b/drivers/gpu/drm/nouveau/include/nvif/mmu.h
index ed5d011f4237..ff4938911621 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/mmu.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/mmu.h
@@ -8,15 +8,10 @@ struct nvif_mmu {
 	const struct nvif_mmu_impl *impl;
 	struct nvif_mmu_priv *priv;
 	struct nvif_object object;
-	u8  heap_nr;
 	u8  type_nr;
 	u8  kind_inv;
 	u16 kind_nr;
 
-	struct {
-		u64 size;
-	} *heap;
-
 	struct {
 #define NVIF_MEM_VRAM                                                      0x01
 #define NVIF_MEM_HOST                                                      0x02
diff --git a/drivers/gpu/drm/nouveau/nvif/mmu.c b/drivers/gpu/drm/nouveau/nvif/mmu.c
index 7e592a6d8530..ec5ec8be98c0 100644
--- a/drivers/gpu/drm/nouveau/nvif/mmu.c
+++ b/drivers/gpu/drm/nouveau/nvif/mmu.c
@@ -34,7 +34,6 @@ nvif_mmu_dtor(struct nvif_mmu *mmu)
 
 	kfree(mmu->kind);
 	kfree(mmu->type);
-	kfree(mmu->heap);
 	mmu->impl->del(mmu->priv);
 	mmu->impl = NULL;
 }
@@ -46,7 +45,6 @@ nvif_mmu_ctor(struct nvif_device *device, const char *name, struct nvif_mmu *mmu
 	int ret, i;
 
 	mmu->impl = NULL;
-	mmu->heap = NULL;
 	mmu->type = NULL;
 	mmu->kind = NULL;
 
@@ -58,15 +56,12 @@ nvif_mmu_ctor(struct nvif_device *device, const char *name, struct nvif_mmu *mmu
 
 	nvif_object_ctor(&device->object, name ?: "nvifMmu", 0, oclass, &mmu->object);
 
-	mmu->heap_nr = mmu->impl->heap_nr;
 	mmu->type_nr = mmu->impl->type_nr;
 	mmu->kind_nr = mmu->impl->kind_nr;
 
-	mmu->heap = kmalloc_array(mmu->heap_nr, sizeof(*mmu->heap),
-				  GFP_KERNEL);
 	mmu->type = kmalloc_array(mmu->type_nr, sizeof(*mmu->type),
 				  GFP_KERNEL);
-	if (ret = -ENOMEM, !mmu->heap || !mmu->type)
+	if (ret = -ENOMEM, !mmu->type)
 		goto done;
 
 	mmu->kind = kmalloc_array(mmu->kind_nr, sizeof(*mmu->kind),
@@ -74,17 +69,6 @@ nvif_mmu_ctor(struct nvif_device *device, const char *name, struct nvif_mmu *mmu
 	if (!mmu->kind && mmu->kind_nr)
 		goto done;
 
-	for (i = 0; i < mmu->heap_nr; i++) {
-		struct nvif_mmu_heap_v0 args = { .index = i };
-
-		ret = nvif_object_mthd(&mmu->object, NVIF_MMU_V0_HEAP,
-				       &args, sizeof(args));
-		if (ret)
-			goto done;
-
-		mmu->heap[i].size = args.size;
-	}
-
 	for (i = 0; i < mmu->type_nr; i++) {
 		struct nvif_mmu_type_v0 args = { .index = i };
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c
index 9f44d469b4da..9a42721eabd8 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c
@@ -53,26 +53,6 @@ nvkm_ummu_sclass(struct nvkm_object *object, int index,
 	return -EINVAL;
 }
 
-static int
-nvkm_ummu_heap(struct nvkm_ummu *ummu, void *argv, u32 argc)
-{
-	struct nvkm_mmu *mmu = ummu->mmu;
-	union {
-		struct nvif_mmu_heap_v0 v0;
-	} *args = argv;
-	int ret = -ENOSYS;
-	u8 index;
-
-	if (!(ret = nvif_unpack(ret, &argv, &argc, args->v0, 0, 0, false))) {
-		if ((index = args->v0.index) >= mmu->heap_nr)
-			return -EINVAL;
-		args->v0.size = mmu->heap[index].size;
-	} else
-		return ret;
-
-	return 0;
-}
-
 static int
 nvkm_ummu_type(struct nvkm_ummu *ummu, void *argv, u32 argc)
 {
@@ -147,7 +127,6 @@ nvkm_ummu_mthd(struct nvkm_object *object, u32 mthd, void *argv, u32 argc)
 {
 	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);
 	case NVIF_MMU_V0_KIND: return nvkm_ummu_kind(ummu, argv, argc);
 	default:
@@ -185,6 +164,8 @@ nvkm_ummu_new(struct nvkm_device *device, const struct nvif_mmu_impl **pimpl,
 	ummu->impl.heap_nr = mmu->heap_nr;
 	ummu->impl.type_nr = mmu->type_nr;
 	ummu->impl.kind_nr = kinds;
+	for (int i = 0; i < mmu->heap_nr; i++)
+		ummu->impl.heap[i].size = mmu->heap[i].size;
 
 	ummu->impl.mem.oclass = mmu->func->mem.user.oclass;
 
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 081/156] drm/nouveau/nvif: rework mmu "type" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (79 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 080/156] drm/nouveau/nvif: rework mmu "heap" api Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 082/156] drm/nouveau/nvif: rework mmu "kind" api Ben Skeggs
                   ` (76 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interface

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 .../gpu/drm/nouveau/include/nvif/driverif.h   | 13 ++++++
 drivers/gpu/drm/nouveau/include/nvif/if0008.h | 15 -------
 drivers/gpu/drm/nouveau/include/nvif/mmu.h    | 18 +-------
 drivers/gpu/drm/nouveau/nouveau_bo.c          |  2 +-
 drivers/gpu/drm/nouveau/nouveau_drv.h         |  5 ++-
 drivers/gpu/drm/nouveau/nouveau_mem.c         |  4 +-
 drivers/gpu/drm/nouveau/nvif/mem.c            |  6 +--
 drivers/gpu/drm/nouveau/nvif/mmu.c            | 30 +------------
 .../gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c    | 45 +++++++------------
 9 files changed, 40 insertions(+), 98 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 9205c2c3b34e..fa08478cc38f 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -89,6 +89,19 @@ struct nvif_mmu_impl {
 		u64 size;
 	} heap[4];
 
+	struct {
+#define NVIF_MEM_VRAM     0x01
+#define NVIF_MEM_HOST     0x02
+#define NVIF_MEM_COMP     0x04
+#define NVIF_MEM_DISP     0x08
+#define NVIF_MEM_KIND     0x10
+#define NVIF_MEM_MAPPABLE 0x20
+#define NVIF_MEM_COHERENT 0x40
+#define NVIF_MEM_UNCACHED 0x80
+		u8 type;
+		u8 heap;
+	} type[16];
+
 	struct {
 		s32 oclass;
 	} mem;
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0008.h b/drivers/gpu/drm/nouveau/include/nvif/if0008.h
index 551bdf49d6e2..0413e7e4ca0c 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/if0008.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/if0008.h
@@ -1,23 +1,8 @@
 #ifndef __NVIF_IF0008_H__
 #define __NVIF_IF0008_H__
 
-#define NVIF_MMU_V0_TYPE                                                   0x01
 #define NVIF_MMU_V0_KIND                                                   0x02
 
-struct nvif_mmu_type_v0 {
-	__u8  version;
-	__u8  index;
-	__u8  heap;
-	__u8  vram;
-	__u8  host;
-	__u8  comp;
-	__u8  disp;
-	__u8  kind;
-	__u8  mappable;
-	__u8  coherent;
-	__u8  uncached;
-};
-
 struct nvif_mmu_kind_v0 {
 	__u8  version;
 	__u8  kind_inv;
diff --git a/drivers/gpu/drm/nouveau/include/nvif/mmu.h b/drivers/gpu/drm/nouveau/include/nvif/mmu.h
index ff4938911621..203328a2d611 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/mmu.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/mmu.h
@@ -8,23 +8,9 @@ struct nvif_mmu {
 	const struct nvif_mmu_impl *impl;
 	struct nvif_mmu_priv *priv;
 	struct nvif_object object;
-	u8  type_nr;
 	u8  kind_inv;
 	u16 kind_nr;
 
-	struct {
-#define NVIF_MEM_VRAM                                                      0x01
-#define NVIF_MEM_HOST                                                      0x02
-#define NVIF_MEM_COMP                                                      0x04
-#define NVIF_MEM_DISP                                                      0x08
-#define NVIF_MEM_KIND                                                      0x10
-#define NVIF_MEM_MAPPABLE                                                  0x20
-#define NVIF_MEM_COHERENT                                                  0x40
-#define NVIF_MEM_UNCACHED                                                  0x80
-		u8 type;
-		u8 heap;
-	} *type;
-
 	u8 *kind;
 };
 
@@ -45,8 +31,8 @@ static inline int
 nvif_mmu_type(struct nvif_mmu *mmu, u8 mask)
 {
 	int i;
-	for (i = 0; i < mmu->type_nr; i++) {
-		if ((mmu->type[i].type & mask) == mask)
+	for (i = 0; i < mmu->impl->type_nr; i++) {
+		if ((mmu->impl->type[i].type & mask) == mask)
 			return i;
 	}
 	return -EINVAL;
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
index cbb8f54db83f..08d522aaae38 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -1212,7 +1212,7 @@ nouveau_ttm_io_mem_reserve(struct ttm_device *bdev, struct ttm_resource *reg)
 
 		/* Some BARs do not support being ioremapped WC */
 		if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA &&
-		    mmu->type[drm->ttm.type_vram].type & NVIF_MEM_UNCACHED)
+		    mmu->impl->type[drm->ttm.type_vram].type & NVIF_MEM_UNCACHED)
 			reg->bus.caching = ttm_uncached;
 		else
 			reg->bus.caching = ttm_write_combined;
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h
index 38d33a4d5c49..823fa6d87690 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.h
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.h
@@ -318,8 +318,9 @@ nouveau_drm(struct drm_device *dev)
 static inline bool
 nouveau_drm_use_coherent_gpu_mapping(struct nouveau_drm *drm)
 {
-	struct nvif_mmu *mmu = &drm->client.mmu;
-	return !(mmu->type[drm->ttm.type_host[0]].type & NVIF_MEM_UNCACHED);
+	struct nvif_mmu *mmu = &drm->mmu;
+
+	return !(mmu->impl->type[drm->ttm.type_host[0]].type & NVIF_MEM_UNCACHED);
 }
 
 int nouveau_pmops_suspend(struct device *);
diff --git a/drivers/gpu/drm/nouveau/nouveau_mem.c b/drivers/gpu/drm/nouveau/nouveau_mem.c
index 75abd545c92d..554500a650db 100644
--- a/drivers/gpu/drm/nouveau/nouveau_mem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_mem.c
@@ -100,9 +100,9 @@ nouveau_mem_host(struct ttm_resource *reg, struct ttm_tt *tt)
 	else
 		type = drm->ttm.type_host[0];
 
-	if (mem->kind && !(mmu->type[type].type & NVIF_MEM_KIND))
+	if (mem->kind && !(mmu->impl->type[type].type & NVIF_MEM_KIND))
 		mem->comp = mem->kind = 0;
-	if (mem->comp && !(mmu->type[type].type & NVIF_MEM_COMP)) {
+	if (mem->comp && !(mmu->impl->type[type].type & NVIF_MEM_COMP)) {
 		if (mmu->object.oclass >= NVIF_CLASS_MMU_GF100)
 			mem->kind = mmu->kind[mem->kind];
 		mem->comp = 0;
diff --git a/drivers/gpu/drm/nouveau/nvif/mem.c b/drivers/gpu/drm/nouveau/nvif/mem.c
index 0f0b4a7c5e80..600fe051be11 100644
--- a/drivers/gpu/drm/nouveau/nvif/mem.c
+++ b/drivers/gpu/drm/nouveau/nvif/mem.c
@@ -72,7 +72,7 @@ nvif_mem_ctor_type(struct nvif_mmu *mmu, const char *name,
 	ret = nvif_object_ctor(&mmu->object, name ? name : "nvifMem", 0, mmu->impl->mem.oclass,
 			       args, sizeof(*args) + argc, &mem->object);
 	if (ret == 0) {
-		mem->type = mmu->type[type].type;
+		mem->type = mmu->impl->type[type].type;
 		mem->page = args->page;
 		mem->addr = args->addr;
 		mem->size = args->size;
@@ -92,8 +92,8 @@ nvif_mem_ctor(struct nvif_mmu *mmu, const char *name, u8 type,
 
 	mem->object.client = NULL;
 
-	for (i = 0; ret && i < mmu->type_nr; i++) {
-		if ((mmu->type[i].type & type) == type) {
+	for (i = 0; ret && i < mmu->impl->type_nr; i++) {
+		if ((mmu->impl->type[i].type & type) == type) {
 			ret = nvif_mem_ctor_type(mmu, name, i, page,
 						 size, argv, argc, mem);
 		}
diff --git a/drivers/gpu/drm/nouveau/nvif/mmu.c b/drivers/gpu/drm/nouveau/nvif/mmu.c
index ec5ec8be98c0..e727a6587658 100644
--- a/drivers/gpu/drm/nouveau/nvif/mmu.c
+++ b/drivers/gpu/drm/nouveau/nvif/mmu.c
@@ -33,7 +33,6 @@ nvif_mmu_dtor(struct nvif_mmu *mmu)
 		return;
 
 	kfree(mmu->kind);
-	kfree(mmu->type);
 	mmu->impl->del(mmu->priv);
 	mmu->impl = NULL;
 }
@@ -42,10 +41,9 @@ int
 nvif_mmu_ctor(struct nvif_device *device, const char *name, struct nvif_mmu *mmu)
 {
 	const s32 oclass = device->impl->mmu.oclass;
-	int ret, i;
+	int ret;
 
 	mmu->impl = NULL;
-	mmu->type = NULL;
 	mmu->kind = NULL;
 
 	ret = device->impl->mmu.new(device->priv, &mmu->impl, &mmu->priv,
@@ -56,39 +54,13 @@ nvif_mmu_ctor(struct nvif_device *device, const char *name, struct nvif_mmu *mmu
 
 	nvif_object_ctor(&device->object, name ?: "nvifMmu", 0, oclass, &mmu->object);
 
-	mmu->type_nr = mmu->impl->type_nr;
 	mmu->kind_nr = mmu->impl->kind_nr;
 
-	mmu->type = kmalloc_array(mmu->type_nr, sizeof(*mmu->type),
-				  GFP_KERNEL);
-	if (ret = -ENOMEM, !mmu->type)
-		goto done;
-
 	mmu->kind = kmalloc_array(mmu->kind_nr, sizeof(*mmu->kind),
 				  GFP_KERNEL);
 	if (!mmu->kind && mmu->kind_nr)
 		goto done;
 
-	for (i = 0; i < mmu->type_nr; i++) {
-		struct nvif_mmu_type_v0 args = { .index = i };
-
-		ret = nvif_object_mthd(&mmu->object, NVIF_MMU_V0_TYPE,
-				       &args, sizeof(args));
-		if (ret)
-			goto done;
-
-		mmu->type[i].type = 0;
-		if (args.vram) mmu->type[i].type |= NVIF_MEM_VRAM;
-		if (args.host) mmu->type[i].type |= NVIF_MEM_HOST;
-		if (args.comp) mmu->type[i].type |= NVIF_MEM_COMP;
-		if (args.disp) mmu->type[i].type |= NVIF_MEM_DISP;
-		if (args.kind    ) mmu->type[i].type |= NVIF_MEM_KIND;
-		if (args.mappable) mmu->type[i].type |= NVIF_MEM_MAPPABLE;
-		if (args.coherent) mmu->type[i].type |= NVIF_MEM_COHERENT;
-		if (args.uncached) mmu->type[i].type |= NVIF_MEM_UNCACHED;
-		mmu->type[i].heap = args.heap;
-	}
-
 	if (mmu->kind_nr) {
 		struct nvif_mmu_kind_v0 *kind;
 		size_t argc = struct_size(kind, data, mmu->kind_nr);
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c
index 9a42721eabd8..8be5b1034bc1 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c
@@ -53,35 +53,6 @@ nvkm_ummu_sclass(struct nvkm_object *object, int index,
 	return -EINVAL;
 }
 
-static int
-nvkm_ummu_type(struct nvkm_ummu *ummu, void *argv, u32 argc)
-{
-	struct nvkm_mmu *mmu = ummu->mmu;
-	union {
-		struct nvif_mmu_type_v0 v0;
-	} *args = argv;
-	int ret = -ENOSYS;
-	u8 type, index;
-
-	if (!(ret = nvif_unpack(ret, &argv, &argc, args->v0, 0, 0, false))) {
-		if ((index = args->v0.index) >= mmu->type_nr)
-			return -EINVAL;
-		type = mmu->type[index].type;
-		args->v0.heap = mmu->type[index].heap;
-		args->v0.vram = !!(type & NVKM_MEM_VRAM);
-		args->v0.host = !!(type & NVKM_MEM_HOST);
-		args->v0.comp = !!(type & NVKM_MEM_COMP);
-		args->v0.disp = !!(type & NVKM_MEM_DISP);
-		args->v0.kind = !!(type & NVKM_MEM_KIND);
-		args->v0.mappable = !!(type & NVKM_MEM_MAPPABLE);
-		args->v0.coherent = !!(type & NVKM_MEM_COHERENT);
-		args->v0.uncached = !!(type & NVKM_MEM_UNCACHED);
-	} else
-		return ret;
-
-	return 0;
-}
-
 static int
 nvkm_ummu_kind(struct nvkm_ummu *ummu, void *argv, u32 argc)
 {
@@ -127,7 +98,6 @@ nvkm_ummu_mthd(struct nvkm_object *object, u32 mthd, void *argv, u32 argc)
 {
 	struct nvif_mmu_priv *ummu = container_of(object, typeof(*ummu), object);
 	switch (mthd) {
-	case NVIF_MMU_V0_TYPE: return nvkm_ummu_type(ummu, argv, argc);
 	case NVIF_MMU_V0_KIND: return nvkm_ummu_kind(ummu, argv, argc);
 	default:
 		break;
@@ -164,9 +134,24 @@ nvkm_ummu_new(struct nvkm_device *device, const struct nvif_mmu_impl **pimpl,
 	ummu->impl.heap_nr = mmu->heap_nr;
 	ummu->impl.type_nr = mmu->type_nr;
 	ummu->impl.kind_nr = kinds;
+
 	for (int i = 0; i < mmu->heap_nr; i++)
 		ummu->impl.heap[i].size = mmu->heap[i].size;
 
+	for (int i = 0; i < mmu->type_nr; i++) {
+		u8 type = mmu->type[i].type;
+
+		ummu->impl.type[i].type |= (type & NVKM_MEM_VRAM) ? NVIF_MEM_VRAM : 0;
+		ummu->impl.type[i].type |= (type & NVKM_MEM_HOST) ? NVIF_MEM_HOST : 0;
+		ummu->impl.type[i].type |= (type & NVKM_MEM_COMP) ? NVIF_MEM_COMP : 0;
+		ummu->impl.type[i].type |= (type & NVKM_MEM_DISP) ? NVIF_MEM_DISP : 0;
+		ummu->impl.type[i].type |= (type & NVKM_MEM_KIND) ? NVIF_MEM_KIND : 0;
+		ummu->impl.type[i].type |= (type & NVKM_MEM_MAPPABLE) ? NVIF_MEM_MAPPABLE : 0;
+		ummu->impl.type[i].type |= (type & NVKM_MEM_COHERENT) ? NVIF_MEM_COHERENT : 0;
+		ummu->impl.type[i].type |= (type & NVKM_MEM_UNCACHED) ? NVIF_MEM_UNCACHED : 0;
+		ummu->impl.type[i].heap = mmu->type[i].heap;
+	}
+
 	ummu->impl.mem.oclass = mmu->func->mem.user.oclass;
 
 	ummu->impl.vmm.oclass = mmu->func->vmm.user.oclass;
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 082/156] drm/nouveau/nvif: rework mmu "kind" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (80 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 081/156] drm/nouveau/nvif: rework mmu "type" api Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 083/156] drm/nouveau/nvif: rework mmu "new mem" api Ben Skeggs
                   ` (75 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interface

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  3 ++
 drivers/gpu/drm/nouveau/include/nvif/if0008.h | 12 -----
 drivers/gpu/drm/nouveau/include/nvif/mmu.h    |  6 +--
 drivers/gpu/drm/nouveau/nouveau_bo.c          |  4 +-
 drivers/gpu/drm/nouveau/nouveau_mem.c         |  4 +-
 drivers/gpu/drm/nouveau/nvif/mmu.c            | 31 -----------
 .../gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c    | 53 ++-----------------
 7 files changed, 13 insertions(+), 100 deletions(-)
 delete mode 100644 drivers/gpu/drm/nouveau/include/nvif/if0008.h

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index fa08478cc38f..f387ec622a45 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -83,6 +83,7 @@ struct nvif_mmu_impl {
 	u8 heap_nr;
 	u8 type_nr;
 
+	u8 kind_inv;
 	u16 kind_nr;
 
 	struct {
@@ -102,6 +103,8 @@ struct nvif_mmu_impl {
 		u8 heap;
 	} type[16];
 
+	const u8 *kind;
+
 	struct {
 		s32 oclass;
 	} mem;
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0008.h b/drivers/gpu/drm/nouveau/include/nvif/if0008.h
deleted file mode 100644
index 0413e7e4ca0c..000000000000
--- a/drivers/gpu/drm/nouveau/include/nvif/if0008.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef __NVIF_IF0008_H__
-#define __NVIF_IF0008_H__
-
-#define NVIF_MMU_V0_KIND                                                   0x02
-
-struct nvif_mmu_kind_v0 {
-	__u8  version;
-	__u8  kind_inv;
-	__u16 count;
-	__u8  data[];
-};
-#endif
diff --git a/drivers/gpu/drm/nouveau/include/nvif/mmu.h b/drivers/gpu/drm/nouveau/include/nvif/mmu.h
index 203328a2d611..f1e51a5544da 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/mmu.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/mmu.h
@@ -8,10 +8,6 @@ struct nvif_mmu {
 	const struct nvif_mmu_impl *impl;
 	struct nvif_mmu_priv *priv;
 	struct nvif_object object;
-	u8  kind_inv;
-	u16 kind_nr;
-
-	u8 *kind;
 };
 
 int nvif_mmu_ctor(struct nvif_device *, const char *name, struct nvif_mmu *);
@@ -21,7 +17,7 @@ static inline bool
 nvif_mmu_kind_valid(struct nvif_mmu *mmu, u8 kind)
 {
 	if (kind) {
-		if (kind >= mmu->kind_nr || mmu->kind[kind] == mmu->kind_inv)
+		if (kind >= mmu->impl->kind_nr || mmu->impl->kind[kind] == mmu->impl->kind_inv)
 			return false;
 	}
 	return true;
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
index 08d522aaae38..0d946e31bccd 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -250,7 +250,7 @@ nouveau_bo_alloc(struct nouveau_cli *cli, u64 *size, int *align, u32 domain,
 				return ERR_PTR(-EINVAL);
 			}
 
-			nvbo->comp = mmu->kind[nvbo->kind] != nvbo->kind;
+			nvbo->comp = mmu->impl->kind[nvbo->kind] != nvbo->kind;
 		} else if (cli->device.info.family >= NV_DEVICE_INFO_V0_TESLA) {
 			nvbo->kind = (tile_flags & 0x00007f00) >> 8;
 			nvbo->comp = (tile_flags & 0x00030000) >> 16;
@@ -299,7 +299,7 @@ nouveau_bo_alloc(struct nouveau_cli *cli, u64 *size, int *align, u32 domain,
 		/* Disable compression if suitable settings couldn't be found. */
 		if (nvbo->comp && !vmm->page[pi].comp) {
 			if (mmu->object.oclass >= NVIF_CLASS_MMU_GF100)
-				nvbo->kind = mmu->kind[nvbo->kind];
+				nvbo->kind = mmu->impl->kind[nvbo->kind];
 			nvbo->comp = 0;
 		}
 		nvbo->page = vmm->page[pi].shift;
diff --git a/drivers/gpu/drm/nouveau/nouveau_mem.c b/drivers/gpu/drm/nouveau/nouveau_mem.c
index 554500a650db..872d689db7ba 100644
--- a/drivers/gpu/drm/nouveau/nouveau_mem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_mem.c
@@ -104,7 +104,7 @@ nouveau_mem_host(struct ttm_resource *reg, struct ttm_tt *tt)
 		mem->comp = mem->kind = 0;
 	if (mem->comp && !(mmu->impl->type[type].type & NVIF_MEM_COMP)) {
 		if (mmu->object.oclass >= NVIF_CLASS_MMU_GF100)
-			mem->kind = mmu->kind[mem->kind];
+			mem->kind = mmu->impl->kind[mem->kind];
 		mem->comp = 0;
 	}
 
@@ -144,7 +144,7 @@ nouveau_mem_vram(struct ttm_resource *reg, bool contig, u8 page)
 		ret = nvif_mem_ctor_type(mmu, "ttmVram",
 					 drm->ttm.type_vram, page, size,
 					 &(struct nv50_mem_v0) {
-						.bankswz = mmu->kind[mem->kind] == 2,
+						.bankswz = mmu->impl->kind[mem->kind] == 2,
 						.contig = contig,
 					 }, sizeof(struct nv50_mem_v0),
 					 &mem->mem);
diff --git a/drivers/gpu/drm/nouveau/nvif/mmu.c b/drivers/gpu/drm/nouveau/nvif/mmu.c
index e727a6587658..d1d09e5a6909 100644
--- a/drivers/gpu/drm/nouveau/nvif/mmu.c
+++ b/drivers/gpu/drm/nouveau/nvif/mmu.c
@@ -24,7 +24,6 @@
 #include <nvif/printf.h>
 
 #include <nvif/class.h>
-#include <nvif/if0008.h>
 
 void
 nvif_mmu_dtor(struct nvif_mmu *mmu)
@@ -32,7 +31,6 @@ nvif_mmu_dtor(struct nvif_mmu *mmu)
 	if (!mmu->impl)
 		return;
 
-	kfree(mmu->kind);
 	mmu->impl->del(mmu->priv);
 	mmu->impl = NULL;
 }
@@ -44,7 +42,6 @@ nvif_mmu_ctor(struct nvif_device *device, const char *name, struct nvif_mmu *mmu
 	int ret;
 
 	mmu->impl = NULL;
-	mmu->kind = NULL;
 
 	ret = device->impl->mmu.new(device->priv, &mmu->impl, &mmu->priv,
 				    nvif_handle(&mmu->object));
@@ -53,33 +50,5 @@ nvif_mmu_ctor(struct nvif_device *device, const char *name, struct nvif_mmu *mmu
 		return ret;
 
 	nvif_object_ctor(&device->object, name ?: "nvifMmu", 0, oclass, &mmu->object);
-
-	mmu->kind_nr = mmu->impl->kind_nr;
-
-	mmu->kind = kmalloc_array(mmu->kind_nr, sizeof(*mmu->kind),
-				  GFP_KERNEL);
-	if (!mmu->kind && mmu->kind_nr)
-		goto done;
-
-	if (mmu->kind_nr) {
-		struct nvif_mmu_kind_v0 *kind;
-		size_t argc = struct_size(kind, data, mmu->kind_nr);
-
-		if (ret = -ENOMEM, !(kind = kmalloc(argc, GFP_KERNEL)))
-			goto done;
-		kind->version = 0;
-		kind->count = mmu->kind_nr;
-
-		ret = nvif_object_mthd(&mmu->object, NVIF_MMU_V0_KIND,
-				       kind, argc);
-		if (ret == 0)
-			memcpy(mmu->kind, kind->data, kind->count);
-		mmu->kind_inv = kind->kind_inv;
-		kfree(kind);
-	}
-
-done:
-	if (ret)
-		nvif_mmu_dtor(mmu);
 	return ret;
 }
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c
index 8be5b1034bc1..05ec276facd9 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c
@@ -25,9 +25,6 @@
 
 #include <core/client.h>
 
-#include <nvif/if0008.h>
-#include <nvif/unpack.h>
-
 static int
 nvkm_ummu_sclass(struct nvkm_object *object, int index,
 		 struct nvkm_oclass *oclass)
@@ -53,33 +50,6 @@ nvkm_ummu_sclass(struct nvkm_object *object, int index,
 	return -EINVAL;
 }
 
-static int
-nvkm_ummu_kind(struct nvkm_ummu *ummu, void *argv, u32 argc)
-{
-	struct nvkm_mmu *mmu = ummu->mmu;
-	union {
-		struct nvif_mmu_kind_v0 v0;
-	} *args = argv;
-	const u8 *kind = NULL;
-	int ret = -ENOSYS, count = 0;
-	u8 kind_inv = 0;
-
-	if (mmu->func->kind)
-		kind = mmu->func->kind(mmu, &count, &kind_inv);
-
-	if (!(ret = nvif_unpack(ret, &argv, &argc, args->v0, 0, 0, true))) {
-		if (argc != args->v0.count * sizeof(*args->v0.data))
-			return -EINVAL;
-		if (args->v0.count > count)
-			return -EINVAL;
-		args->v0.kind_inv = kind_inv;
-		memcpy(args->v0.data, kind, args->v0.count);
-	} else
-		return ret;
-
-	return 0;
-}
-
 static void
 nvkm_ummu_del(struct nvif_mmu_priv *ummu)
 {
@@ -93,21 +63,8 @@ nvkm_ummu_impl = {
 	.del = nvkm_ummu_del,
 };
 
-static int
-nvkm_ummu_mthd(struct nvkm_object *object, u32 mthd, void *argv, u32 argc)
-{
-	struct nvif_mmu_priv *ummu = container_of(object, typeof(*ummu), object);
-	switch (mthd) {
-	case NVIF_MMU_V0_KIND: return nvkm_ummu_kind(ummu, argv, argc);
-	default:
-		break;
-	}
-	return -EINVAL;
-}
-
 static const struct nvkm_object_func
 nvkm_ummu = {
-	.mthd = nvkm_ummu_mthd,
 	.sclass = nvkm_ummu_sclass,
 };
 
@@ -118,7 +75,6 @@ nvkm_ummu_new(struct nvkm_device *device, const struct nvif_mmu_impl **pimpl,
 	struct nvkm_mmu *mmu = device->mmu;
 	struct nvif_mmu_priv *ummu;
 	int kinds = 0;
-	u8 unused = 0;
 
 	if (!(ummu = kzalloc(sizeof(*ummu), GFP_KERNEL)))
 		return -ENOMEM;
@@ -127,13 +83,9 @@ nvkm_ummu_new(struct nvkm_device *device, const struct nvif_mmu_impl **pimpl,
 	ummu->mmu = mmu;
 	ummu->impl = nvkm_ummu_impl;
 
-	if (mmu->func->kind)
-		mmu->func->kind(mmu, &kinds, &unused);
-
 	ummu->impl.dmabits = mmu->dma_bits;
 	ummu->impl.heap_nr = mmu->heap_nr;
 	ummu->impl.type_nr = mmu->type_nr;
-	ummu->impl.kind_nr = kinds;
 
 	for (int i = 0; i < mmu->heap_nr; i++)
 		ummu->impl.heap[i].size = mmu->heap[i].size;
@@ -152,6 +104,11 @@ nvkm_ummu_new(struct nvkm_device *device, const struct nvif_mmu_impl **pimpl,
 		ummu->impl.type[i].heap = mmu->type[i].heap;
 	}
 
+	if (mmu->func->kind) {
+		ummu->impl.kind = mmu->func->kind(mmu, &kinds, &ummu->impl.kind_inv);
+		ummu->impl.kind_nr = kinds;
+	}
+
 	ummu->impl.mem.oclass = mmu->func->mem.user.oclass;
 
 	ummu->impl.vmm.oclass = mmu->func->vmm.user.oclass;
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 083/156] drm/nouveau/nvif: rework mmu "new mem" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (81 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 082/156] drm/nouveau/nvif: rework mmu "kind" api Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 084/156] drm/nouveau/nvif: rework mem "map"/"unmap" apis Ben Skeggs
                   ` (74 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interface

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/dispnv50/crc.c        |  6 +--
 drivers/gpu/drm/nouveau/dispnv50/lut.c        |  2 +-
 .../gpu/drm/nouveau/include/nvif/driverif.h   | 11 +++++
 drivers/gpu/drm/nouveau/include/nvif/mem.h    |  8 ++--
 drivers/gpu/drm/nouveau/nouveau_bo.c          | 10 ++--
 drivers/gpu/drm/nouveau/nouveau_mem.c         |  4 +-
 drivers/gpu/drm/nouveau/nouveau_vmm.c         | 10 ++--
 drivers/gpu/drm/nouveau/nvif/mem.c            | 43 +++++++----------
 .../gpu/drm/nouveau/nvkm/subdev/mmu/umem.c    | 47 +++++++++++--------
 .../gpu/drm/nouveau/nvkm/subdev/mmu/umem.h    |  5 +-
 .../gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c    | 23 +++++----
 11 files changed, 92 insertions(+), 77 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv50/crc.c b/drivers/gpu/drm/nouveau/dispnv50/crc.c
index 0864d36a06f2..694c25a19e25 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/crc.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/crc.c
@@ -513,9 +513,9 @@ nv50_crc_ctx_init(struct nv50_head *head, struct nvif_mmu *mmu,
 			       (&(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,
+					.start = ctx->mem.impl->addr,
+					.limit =  ctx->mem.impl->addr
+						+ ctx->mem.impl->size - 1,
 			       }), sizeof(struct nv_dma_v0),
 			       &ctx->ntfy);
 	if (ret)
diff --git a/drivers/gpu/drm/nouveau/dispnv50/lut.c b/drivers/gpu/drm/nouveau/dispnv50/lut.c
index 6b2ad1e6eab9..7d68a7efc1d5 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/lut.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/lut.c
@@ -34,7 +34,7 @@ nv50_lut_load(struct nv50_lut *lut, int buffer, struct drm_property_blob *blob,
 {
 	struct drm_color_lut *in = blob ? blob->data : NULL;
 	void __iomem *mem = lut->mem[buffer].object.map.ptr;
-	const u32 addr = lut->mem[buffer].addr;
+	const u32 addr = lut->mem[buffer].impl->addr;
 	int i;
 
 	if (!in) {
diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index f387ec622a45..de380979e1a4 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -6,6 +6,7 @@ struct nvif_device_priv;
 struct nvif_control_priv;
 struct nvif_usermode_priv;
 struct nvif_mmu_priv;
+struct nvif_mem_priv;
 
 struct nvif_driver {
 	const char *name;
@@ -76,6 +77,14 @@ struct nvif_usermode_impl {
 	struct nvif_mapinfo map;
 };
 
+struct nvif_mem_impl {
+	void (*del)(struct nvif_mem_priv *);
+
+	u8 page;
+	u64 addr;
+	u64 size;
+};
+
 struct nvif_mmu_impl {
 	void (*del)(struct nvif_mmu_priv *);
 
@@ -107,6 +116,8 @@ struct nvif_mmu_impl {
 
 	struct {
 		s32 oclass;
+		int (*new)(struct nvif_mmu_priv *, u8 type, u8 page, u64 size, void *argv, u32 argc,
+			   const struct nvif_mem_impl **, struct nvif_mem_priv **, u64 handle);
 	} mem;
 
 	struct {
diff --git a/drivers/gpu/drm/nouveau/include/nvif/mem.h b/drivers/gpu/drm/nouveau/include/nvif/mem.h
index 217d13126f13..8d432d238b95 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/mem.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/mem.h
@@ -3,11 +3,11 @@
 #include "mmu.h"
 
 struct nvif_mem {
+	const struct nvif_mem_impl *impl;
+	struct nvif_mem_priv *priv;
 	struct nvif_object object;
-	u8  type;
-	u8  page;
-	u64 addr;
-	u64 size;
+
+	u8 type;
 };
 
 int nvif_mem_ctor_type(struct nvif_mmu *mmu, const char *name,
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
index 0d946e31bccd..6c90f853513d 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -835,13 +835,13 @@ nouveau_bo_move_prep(struct nouveau_drm *drm, struct ttm_buffer_object *bo,
 	struct nvif_vmm *vmm = &drm->client.vmm.vmm;
 	int ret;
 
-	ret = nvif_vmm_get(vmm, LAZY, false, old_mem->mem.page, 0,
-			   old_mem->mem.size, &old_mem->vma[0]);
+	ret = nvif_vmm_get(vmm, LAZY, false, old_mem->mem.impl->page, 0,
+			   old_mem->mem.impl->size, &old_mem->vma[0]);
 	if (ret)
 		return ret;
 
-	ret = nvif_vmm_get(vmm, LAZY, false, new_mem->mem.page, 0,
-			   new_mem->mem.size, &old_mem->vma[1]);
+	ret = nvif_vmm_get(vmm, LAZY, false, new_mem->mem.impl->page, 0,
+			   new_mem->mem.impl->size, &old_mem->vma[1]);
 	if (ret)
 		goto done;
 
@@ -1001,7 +1001,7 @@ static void nouveau_bo_move_ntfy(struct ttm_buffer_object *bo,
 	nouveau_bo_del_io_reserve_lru(bo);
 
 	if (mem && new_reg->mem_type != TTM_PL_SYSTEM &&
-	    mem->mem.page == nvbo->page) {
+	    mem->mem.impl->page == nvbo->page) {
 		list_for_each_entry(vma, &nvbo->vma_list, head) {
 			nouveau_vma_map(vma, mem);
 		}
diff --git a/drivers/gpu/drm/nouveau/nouveau_mem.c b/drivers/gpu/drm/nouveau/nouveau_mem.c
index 872d689db7ba..ff67f00c93c5 100644
--- a/drivers/gpu/drm/nouveau/nouveau_mem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_mem.c
@@ -72,7 +72,7 @@ nouveau_mem_map(struct nouveau_mem *mem,
 		return -ENOSYS;
 	}
 
-	return nvif_vmm_map(vmm, vma->addr, mem->mem.size, &args, argc, &mem->mem, 0);
+	return nvif_vmm_map(vmm, vma->addr, mem->mem.impl->size, &args, argc, &mem->mem, 0);
 }
 
 void
@@ -156,7 +156,7 @@ nouveau_mem_vram(struct ttm_resource *reg, bool contig, u8 page)
 	}
 	mutex_unlock(&drm->client_mutex);
 
-	reg->start = mem->mem.addr >> PAGE_SHIFT;
+	reg->start = mem->mem.impl->addr >> PAGE_SHIFT;
 	return ret;
 }
 
diff --git a/drivers/gpu/drm/nouveau/nouveau_vmm.c b/drivers/gpu/drm/nouveau/nouveau_vmm.c
index 93807d21ceff..26a41769551a 100644
--- a/drivers/gpu/drm/nouveau/nouveau_vmm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_vmm.c
@@ -97,17 +97,17 @@ nouveau_vma_new(struct nouveau_bo *nvbo, struct nouveau_vmm *vmm,
 	list_add_tail(&vma->head, &nvbo->vma_list);
 
 	if (nvbo->bo.resource->mem_type != TTM_PL_SYSTEM &&
-	    mem->mem.page == nvbo->page) {
-		ret = nvif_vmm_get(&vmm->vmm, LAZY, false, mem->mem.page, 0,
-				   mem->mem.size, &tmp);
+	    mem->mem.impl->page == nvbo->page) {
+		ret = nvif_vmm_get(&vmm->vmm, LAZY, false, mem->mem.impl->page, 0,
+				   mem->mem.impl->size, &tmp);
 		if (ret)
 			goto done;
 
 		vma->addr = tmp.addr;
 		ret = nouveau_vma_map(vma, mem);
 	} else {
-		ret = nvif_vmm_get(&vmm->vmm, PTES, false, mem->mem.page, 0,
-				   mem->mem.size, &tmp);
+		ret = nvif_vmm_get(&vmm->vmm, PTES, false, mem->mem.impl->page, 0,
+				   mem->mem.impl->size, &tmp);
 		if (ret)
 			goto done;
 
diff --git a/drivers/gpu/drm/nouveau/nvif/mem.c b/drivers/gpu/drm/nouveau/nvif/mem.c
index 600fe051be11..73e66cbfbe43 100644
--- a/drivers/gpu/drm/nouveau/nvif/mem.c
+++ b/drivers/gpu/drm/nouveau/nvif/mem.c
@@ -21,6 +21,8 @@
  */
 #include <nvif/mem.h>
 #include <nvif/client.h>
+#include <nvif/driverif.h>
+#include <nvif/printf.h>
 
 #include <nvif/if000a.h>
 
@@ -41,7 +43,11 @@ nvif_mem_ctor_map(struct nvif_mmu *mmu, const char *name, u8 type, u64 size,
 void
 nvif_mem_dtor(struct nvif_mem *mem)
 {
-	nvif_object_dtor(&mem->object);
+	if (!mem->impl)
+		return;
+
+	mem->impl->del(mem->priv);
+	mem->impl = NULL;
 }
 
 int
@@ -49,38 +55,21 @@ nvif_mem_ctor_type(struct nvif_mmu *mmu, const char *name,
 		   int type, u8 page, u64 size, void *argv, u32 argc,
 		   struct nvif_mem *mem)
 {
-	struct nvif_mem_v0 *args;
-	u8 stack[128];
+	const u32 oclass = mmu->impl->mem.oclass;
 	int ret;
 
-	mem->object.client = NULL;
 	if (type < 0)
 		return -EINVAL;
 
-	if (sizeof(*args) + argc > sizeof(stack)) {
-		if (!(args = kmalloc(sizeof(*args) + argc, GFP_KERNEL)))
-			return -ENOMEM;
-	} else {
-		args = (void *)stack;
-	}
-	args->version = 0;
-	args->type = type;
-	args->page = page;
-	args->size = size;
-	memcpy(args->data, argv, argc);
+	ret = mmu->impl->mem.new(mmu->priv, type, page, size, argv, argc, &mem->impl, &mem->priv,
+				 nvif_handle(&mem->object));
+	NVIF_DEBUG(&mmu->object, "[NEW mem%08x] (ret:%d)", oclass, ret);
+	if (ret)
+		return ret;
 
-	ret = nvif_object_ctor(&mmu->object, name ? name : "nvifMem", 0, mmu->impl->mem.oclass,
-			       args, sizeof(*args) + argc, &mem->object);
-	if (ret == 0) {
-		mem->type = mmu->impl->type[type].type;
-		mem->page = args->page;
-		mem->addr = args->addr;
-		mem->size = args->size;
-	}
-
-	if (args != (void *)stack)
-		kfree(args);
-	return ret;
+	nvif_object_ctor(&mmu->object, name ?: "nvifMem", 0, mmu->impl->mem.oclass, &mem->object);
+	mem->type = mmu->impl->type[type].type;
+	return 0;
 
 }
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.c
index 45f589eb5d78..f1ec0ed8e7c3 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.c
@@ -44,6 +44,8 @@ struct nvif_mem_priv {
 		struct nvkm_vma *bar;
 		void *map;
 	};
+
+	struct nvif_mem_impl impl;
 };
 
 static const struct nvkm_object_func nvkm_umem;
@@ -136,6 +138,19 @@ nvkm_umem_map(struct nvkm_object *object, void *argv, u32 argc,
 	return 0;
 }
 
+static void
+nvkm_umem_del(struct nvif_mem_priv *umem)
+{
+	struct nvkm_object *object = &umem->object;
+
+	nvkm_object_del(&object);
+}
+
+static const struct nvif_mem_impl
+nvkm_umem_impl = {
+	.del = nvkm_umem_del,
+};
+
 static void *
 nvkm_umem_dtor(struct nvkm_object *object)
 {
@@ -156,35 +171,22 @@ nvkm_umem = {
 };
 
 int
-nvkm_umem_new(const struct nvkm_oclass *oclass, void *argv, u32 argc,
+nvkm_umem_new(struct nvkm_mmu *mmu, u8 type, u8 page, u64 size, void *argv, u32 argc,
+	      const struct nvif_mem_impl **pimpl, struct nvif_mem_priv **ppriv,
 	      struct nvkm_object **pobject)
 {
-	struct nvkm_mmu *mmu = container_of(oclass->parent, struct nvif_mmu_priv, object)->mmu;
-	union {
-		struct nvif_mem_v0 v0;
-	} *args = argv;
 	struct nvif_mem_priv *umem;
-	int type, ret = -ENOSYS;
-	u8  page;
-	u64 size;
-
-	if (!(ret = nvif_unpack(ret, &argv, &argc, args->v0, 0, 0, true))) {
-		type = args->v0.type;
-		page = args->v0.page;
-		size = args->v0.size;
-	} else
-		return ret;
+	int ret;
 
 	if (type >= mmu->type_nr)
 		return -EINVAL;
 
 	if (!(umem = kzalloc(sizeof(*umem), GFP_KERNEL)))
 		return -ENOMEM;
-	nvkm_object_ctor(&nvkm_umem, oclass, &umem->object);
+	nvkm_object_ctor(&nvkm_umem, &(struct nvkm_oclass) {}, &umem->object);
 	umem->mmu = mmu;
 	umem->type = mmu->type[type].type;
 	INIT_LIST_HEAD(&umem->head);
-	*pobject = &umem->object;
 
 	if (mmu->type[type].type & NVKM_MEM_MAPPABLE) {
 		page = max_t(u8, page, PAGE_SHIFT);
@@ -200,8 +202,13 @@ nvkm_umem_new(const struct nvkm_oclass *oclass, void *argv, u32 argc,
 	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);
-	args->v0.size = nvkm_memory_size(umem->memory);
+	umem->impl = nvkm_umem_impl;
+	umem->impl.page = nvkm_memory_page(umem->memory);
+	umem->impl.addr = nvkm_memory_addr(umem->memory);
+	umem->impl.size = nvkm_memory_size(umem->memory);
+
+	*pimpl = &umem->impl;
+	*ppriv = umem;
+	*pobject = &umem->object;
 	return 0;
 }
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.h b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.h
index d2012ab625d3..df7017eb98f4 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.h
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.h
@@ -1,7 +1,8 @@
 #ifndef __NVKM_UMEM_H__
 #define __NVKM_UMEM_H__
 #include "mem.h"
+#include <nvif/driverif.h>
 
-int nvkm_umem_new(const struct nvkm_oclass *, void *argv, u32 argc,
-		  struct nvkm_object **);
+int nvkm_umem_new(struct nvkm_mmu *, u8 type, u8 page, u64 size, void *, u32,
+		  const struct nvif_mem_impl **, struct nvif_mem_priv **, struct nvkm_object **);
 #endif
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c
index 05ec276facd9..8458583af0a7 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c
@@ -31,14 +31,6 @@ nvkm_ummu_sclass(struct nvkm_object *object, int index,
 {
 	struct nvkm_mmu *mmu = container_of(object, struct nvif_mmu_priv, object)->mmu;
 
-	if (mmu->func->mem.user.oclass) {
-		if (index-- == 0) {
-			oclass->base = mmu->func->mem.user;
-			oclass->ctor = nvkm_umem_new;
-			return 0;
-		}
-	}
-
 	if (mmu->func->vmm.user.oclass) {
 		if (index-- == 0) {
 			oclass->base = mmu->func->vmm.user;
@@ -50,6 +42,20 @@ nvkm_ummu_sclass(struct nvkm_object *object, int index,
 	return -EINVAL;
 }
 
+static int
+nvkm_ummu_mem_new(struct nvif_mmu_priv *ummu, u8 type, u8 page, u64 size, void *argv, u32 argc,
+		  const struct nvif_mem_impl **pimpl, struct nvif_mem_priv **ppriv, u64 handle)
+{
+	struct nvkm_object *object;
+	int ret;
+
+	ret = nvkm_umem_new(ummu->mmu, type, page, size, argv, argc, pimpl, ppriv, &object);
+	if (ret)
+		return ret;
+
+	return nvkm_object_link_rb(ummu->object.client, &ummu->object, handle, object);
+}
+
 static void
 nvkm_ummu_del(struct nvif_mmu_priv *ummu)
 {
@@ -110,6 +116,7 @@ nvkm_ummu_new(struct nvkm_device *device, const struct nvif_mmu_impl **pimpl,
 	}
 
 	ummu->impl.mem.oclass = mmu->func->mem.user.oclass;
+	ummu->impl.mem.new = nvkm_ummu_mem_new;
 
 	ummu->impl.vmm.oclass = mmu->func->vmm.user.oclass;
 
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 084/156] drm/nouveau/nvif: rework mem "map"/"unmap" apis
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (82 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 083/156] drm/nouveau/nvif: rework mmu "new mem" api Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 085/156] drm/nouveau/nvif: rework mmu "new vmm" api Ben Skeggs
                   ` (73 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interfaces

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/dispnv50/crc.c        |  8 ++--
 drivers/gpu/drm/nouveau/dispnv50/crc.h        |  1 +
 drivers/gpu/drm/nouveau/dispnv50/crc907d.c    |  4 +-
 drivers/gpu/drm/nouveau/dispnv50/crcc37d.c    |  4 +-
 drivers/gpu/drm/nouveau/dispnv50/disp.c       | 14 +++---
 drivers/gpu/drm/nouveau/dispnv50/lut.c        | 12 ++---
 drivers/gpu/drm/nouveau/dispnv50/lut.h        |  5 +-
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  3 ++
 drivers/gpu/drm/nouveau/include/nvif/mem.h    |  6 ++-
 drivers/gpu/drm/nouveau/include/nvif/push.h   |  3 +-
 drivers/gpu/drm/nouveau/nouveau_bo.c          | 21 ++++----
 drivers/gpu/drm/nouveau/nouveau_chan.c        | 31 +++++++-----
 drivers/gpu/drm/nouveau/nouveau_chan.h        |  6 ++-
 drivers/gpu/drm/nouveau/nouveau_dma.c         |  8 ++--
 drivers/gpu/drm/nouveau/nouveau_dma.h         |  2 +-
 drivers/gpu/drm/nouveau/nv10_fence.c          |  2 +-
 drivers/gpu/drm/nouveau/nvif/mem.c            | 48 ++++++++++++++++++-
 .../gpu/drm/nouveau/nvkm/subdev/mmu/umem.c    | 24 ++++------
 18 files changed, 132 insertions(+), 70 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv50/crc.c b/drivers/gpu/drm/nouveau/dispnv50/crc.c
index 694c25a19e25..9482e69c3647 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/crc.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/crc.c
@@ -120,7 +120,7 @@ static void nv50_crc_ctx_flip_work(struct kthread_work *base)
 
 static inline void nv50_crc_reset_ctx(struct nv50_crc_notifier_ctx *ctx)
 {
-	memset_io(ctx->mem.object.map.ptr, 0, ctx->mem.object.map.size);
+	memset_io(ctx->map.ptr, 0, ctx->map.impl->length);
 }
 
 static void
@@ -503,7 +503,7 @@ nv50_crc_ctx_init(struct nv50_head *head, struct nvif_mmu *mmu,
 	struct nv50_core *core = nv50_disp(head->base.base.dev)->core;
 	int ret;
 
-	ret = nvif_mem_ctor_map(mmu, "kmsCrcNtfy", NVIF_MEM_VRAM, len, &ctx->mem);
+	ret = nvif_mem_ctor_map(mmu, "kmsCrcNtfy", NVIF_MEM_VRAM, len, &ctx->mem, &ctx->map);
 	if (ret)
 		return ret;
 
@@ -524,7 +524,7 @@ nv50_crc_ctx_init(struct nv50_head *head, struct nvif_mmu *mmu,
 	return 0;
 
 fail_fini:
-	nvif_mem_dtor(&ctx->mem);
+	nvif_mem_unmap_dtor(&ctx->mem, &ctx->map);
 	return ret;
 }
 
@@ -532,7 +532,7 @@ static inline void
 nv50_crc_ctx_fini(struct nv50_crc_notifier_ctx *ctx)
 {
 	nvif_object_dtor(&ctx->ntfy);
-	nvif_mem_dtor(&ctx->mem);
+	nvif_mem_unmap_dtor(&ctx->mem, &ctx->map);
 }
 
 int nv50_crc_set_source(struct drm_crtc *crtc, const char *source_str)
diff --git a/drivers/gpu/drm/nouveau/dispnv50/crc.h b/drivers/gpu/drm/nouveau/dispnv50/crc.h
index 4823f1fde2dd..48564ceddb97 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/crc.h
+++ b/drivers/gpu/drm/nouveau/dispnv50/crc.h
@@ -40,6 +40,7 @@ enum nv50_crc_source_type {
 
 struct nv50_crc_notifier_ctx {
 	struct nvif_mem mem;
+	struct nvif_map map;
 	struct nvif_object ntfy;
 };
 
diff --git a/drivers/gpu/drm/nouveau/dispnv50/crc907d.c b/drivers/gpu/drm/nouveau/dispnv50/crc907d.c
index a674ba435b05..998978967c4c 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/crc907d.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/crc907d.c
@@ -89,7 +89,7 @@ static u32 crc907d_get_entry(struct nv50_head *head,
 			     struct nv50_crc_notifier_ctx *ctx,
 			     enum nv50_crc_source source, int idx)
 {
-	struct crc907d_notifier __iomem *notifier = ctx->mem.object.map.ptr;
+	struct crc907d_notifier __iomem *notifier = ctx->map.ptr;
 
 	return ioread32_native(&notifier->entries[idx].output_crc[0]);
 }
@@ -98,7 +98,7 @@ static bool crc907d_ctx_finished(struct nv50_head *head,
 				 struct nv50_crc_notifier_ctx *ctx)
 {
 	struct nouveau_drm *drm = nouveau_drm(head->base.base.dev);
-	struct crc907d_notifier __iomem *notifier = ctx->mem.object.map.ptr;
+	struct crc907d_notifier __iomem *notifier = ctx->map.ptr;
 	const u32 status = ioread32_native(&notifier->status);
 	const u32 overflow = status & 0x0000003e;
 
diff --git a/drivers/gpu/drm/nouveau/dispnv50/crcc37d.c b/drivers/gpu/drm/nouveau/dispnv50/crcc37d.c
index 4821ce32f9ed..6af15f3232d9 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/crcc37d.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/crcc37d.c
@@ -67,7 +67,7 @@ int crcc37d_set_ctx(struct nv50_head *head, struct nv50_crc_notifier_ctx *ctx)
 u32 crcc37d_get_entry(struct nv50_head *head, struct nv50_crc_notifier_ctx *ctx,
 		      enum nv50_crc_source source, int idx)
 {
-	struct crcc37d_notifier __iomem *notifier = ctx->mem.object.map.ptr;
+	struct crcc37d_notifier __iomem *notifier = ctx->map.ptr;
 	struct crcc37d_entry __iomem *entry = &notifier->entries[idx];
 	u32 __iomem *crc_addr;
 
@@ -82,7 +82,7 @@ u32 crcc37d_get_entry(struct nv50_head *head, struct nv50_crc_notifier_ctx *ctx,
 bool crcc37d_ctx_finished(struct nv50_head *head, struct nv50_crc_notifier_ctx *ctx)
 {
 	struct nouveau_drm *drm = nouveau_drm(head->base.base.dev);
-	struct crcc37d_notifier __iomem *notifier = ctx->mem.object.map.ptr;
+	struct crcc37d_notifier __iomem *notifier = ctx->map.ptr;
 	const u32 status = ioread32_native(&notifier->status);
 	const u32 overflow = status & 0x0000007e;
 
diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c b/drivers/gpu/drm/nouveau/dispnv50/disp.c
index 4508c24720e2..b89a8f4ee506 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/disp.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c
@@ -124,7 +124,7 @@ nv50_dmac_destroy(struct nv50_dmac *dmac)
 {
 	nv50_chan_destroy(&dmac->base);
 
-	nvif_mem_dtor(&dmac->push.mem);
+	nvif_mem_unmap_dtor(&dmac->push.mem, &dmac->push.map);
 }
 
 static void
@@ -132,7 +132,7 @@ nv50_dmac_kick(struct nvif_push *push)
 {
 	struct nv50_dmac *dmac = container_of(push, typeof(*dmac), push);
 
-	push->hw.cur = push->cur - (u32 __iomem *)dmac->push.mem.object.map.ptr;
+	push->hw.cur = push->cur - (u32 __iomem *)dmac->push.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.
@@ -198,13 +198,13 @@ nv50_dmac_wait(struct nvif_push *push, u32 size)
 	if (WARN_ON(size > push->hw.max))
 		return -EINVAL;
 
-	push->hw.cur = push->cur - (u32 __iomem *)dmac->push.mem.object.map.ptr;
+	push->hw.cur = push->cur - (u32 __iomem *)dmac->push.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 = dmac->push.map.ptr;
 		push->cur = push->cur + push->hw.cur;
 		nv50_dmac_kick(push);
 	}
@@ -217,7 +217,7 @@ nv50_dmac_wait(struct nvif_push *push, u32 size)
 		return -ETIMEDOUT;
 	}
 
-	push->bgn = dmac->push.mem.object.map.ptr;
+	push->bgn = dmac->push.map.ptr;
 	push->bgn = push->bgn + push->hw.cur;
 	push->cur = push->bgn;
 	push->end = push->cur + free;
@@ -253,13 +253,13 @@ 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, &dmac->push.map);
 	if (ret)
 		return ret;
 
 	dmac->push.wait = nv50_dmac_wait;
 	dmac->push.kick = nv50_dmac_kick;
-	dmac->push.bgn = dmac->push.mem.object.map.ptr;
+	dmac->push.bgn = dmac->push.map.ptr;
 	dmac->push.cur = dmac->push.bgn;
 	dmac->push.end = dmac->push.bgn;
 	dmac->push.hw.max = 0x1000/4 - 1;
diff --git a/drivers/gpu/drm/nouveau/dispnv50/lut.c b/drivers/gpu/drm/nouveau/dispnv50/lut.c
index 7d68a7efc1d5..54885e5b3196 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/lut.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/lut.c
@@ -33,8 +33,8 @@ nv50_lut_load(struct nv50_lut *lut, int buffer, struct drm_property_blob *blob,
 	      void (*load)(struct drm_color_lut *, int, void __iomem *))
 {
 	struct drm_color_lut *in = blob ? blob->data : NULL;
-	void __iomem *mem = lut->mem[buffer].object.map.ptr;
-	const u32 addr = lut->mem[buffer].impl->addr;
+	void __iomem *mem = lut->id[buffer].map.ptr;
+	const u32 addr = lut->id[buffer].mem.impl->addr;
 	int i;
 
 	if (!in) {
@@ -59,8 +59,8 @@ void
 nv50_lut_fini(struct nv50_lut *lut)
 {
 	int i;
-	for (i = 0; i < ARRAY_SIZE(lut->mem); i++)
-		nvif_mem_dtor(&lut->mem[i]);
+	for (i = 0; i < ARRAY_SIZE(lut->id); i++)
+		nvif_mem_unmap_dtor(&lut->id[i].mem, &lut->id[i].map);
 }
 
 int
@@ -69,9 +69,9 @@ nv50_lut_init(struct nv50_disp *disp, struct nvif_mmu *mmu,
 {
 	const u32 size = disp->disp->object.oclass < GF110_DISP ? 257 : 1025;
 	int i;
-	for (i = 0; i < ARRAY_SIZE(lut->mem); i++) {
+	for (i = 0; i < ARRAY_SIZE(lut->id); i++) {
 		int ret = nvif_mem_ctor_map(mmu, "kmsLut", NVIF_MEM_VRAM,
-					    size * 8, &lut->mem[i]);
+					    size * 8, &lut->id[i].mem, &lut->id[i].map);
 		if (ret)
 			return ret;
 	}
diff --git a/drivers/gpu/drm/nouveau/dispnv50/lut.h b/drivers/gpu/drm/nouveau/dispnv50/lut.h
index b3b9040cfe9a..a7130c3c7a4a 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/lut.h
+++ b/drivers/gpu/drm/nouveau/dispnv50/lut.h
@@ -6,7 +6,10 @@ struct drm_color_lut;
 struct nv50_disp;
 
 struct nv50_lut {
-	struct nvif_mem mem[2];
+	struct {
+		struct nvif_mem mem;
+		struct nvif_map map;
+	} id[2];
 };
 
 int nv50_lut_init(struct nv50_disp *, struct nvif_mmu *, struct nv50_lut *);
diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index de380979e1a4..2d883125f02b 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -83,6 +83,9 @@ struct nvif_mem_impl {
 	u8 page;
 	u64 addr;
 	u64 size;
+
+	int (*map)(struct nvif_mem_priv *, void *argv, u32 argc, struct nvif_mapinfo *);
+	int (*unmap)(struct nvif_mem_priv *);
 };
 
 struct nvif_mmu_impl {
diff --git a/drivers/gpu/drm/nouveau/include/nvif/mem.h b/drivers/gpu/drm/nouveau/include/nvif/mem.h
index 8d432d238b95..e35cbc6f0ef7 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/mem.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/mem.h
@@ -8,6 +8,7 @@ struct nvif_mem {
 	struct nvif_object object;
 
 	u8 type;
+	struct nvif_mapinfo mapinfo;
 };
 
 int nvif_mem_ctor_type(struct nvif_mmu *mmu, const char *name,
@@ -16,7 +17,10 @@ int nvif_mem_ctor_type(struct nvif_mmu *mmu, const char *name,
 int nvif_mem_ctor(struct nvif_mmu *mmu, const char *name, u8 type,
 		  u8 page, u64 size, void *argv, u32 argc, struct nvif_mem *);
 void nvif_mem_dtor(struct nvif_mem *);
+int nvif_mem_map(struct nvif_mem *, void *argv, u32 argc, struct nvif_map *);
+int nvif_mem_unmap(struct nvif_mem *);
 
 int nvif_mem_ctor_map(struct nvif_mmu *, const char *name, u8 type, u64 size,
-		      struct nvif_mem *);
+		      struct nvif_mem *, struct nvif_map *map);
+int nvif_mem_unmap_dtor(struct nvif_mem *, struct nvif_map *);
 #endif
diff --git a/drivers/gpu/drm/nouveau/include/nvif/push.h b/drivers/gpu/drm/nouveau/include/nvif/push.h
index b88024ef6cc0..8817947a2ea0 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/push.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/push.h
@@ -28,6 +28,7 @@
 
 struct nvif_push {
 	struct nvif_mem mem;
+	struct nvif_map map;
 
 	struct {
 		u32 cur;
@@ -68,7 +69,7 @@ PUSH_KICK(struct nvif_push *push)
 #ifdef CONFIG_NOUVEAU_DEBUG_PUSH
 #define PUSH_PRINTF(p,f,a...) do {                              \
 	struct nvif_push *_ppp = (p);                           \
-	u32 __o = _ppp->cur - (u32 *)_ppp->mem.object.map.ptr;  \
+	u32 __o = _ppp->cur - (u32 *)_ppp->map.ptr;             \
 	NVIF_DEBUG(&_ppp->mem.object, "%08x: "f, __o * 4, ##a); \
 	(void)__o;                                              \
 } while(0)
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
index 6c90f853513d..4c7aced7c398 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -1162,10 +1162,10 @@ nouveau_ttm_io_mem_free_locked(struct nouveau_drm *drm,
 		switch (reg->mem_type) {
 		case TTM_PL_TT:
 			if (mem->kind)
-				nvif_object_unmap_handle(&mem->mem.object);
+				mem->mem.impl->unmap(mem->mem.priv);
 			break;
 		case TTM_PL_VRAM:
-			nvif_object_unmap_handle(&mem->mem.object);
+			mem->mem.impl->unmap(mem->mem.priv);
 			break;
 		default:
 			break;
@@ -1222,7 +1222,7 @@ nouveau_ttm_io_mem_reserve(struct ttm_device *bdev, struct ttm_resource *reg)
 				struct nv50_mem_map_v0 nv50;
 				struct gf100_mem_map_v0 gf100;
 			} args;
-			u64 handle, length;
+			struct nvif_mapinfo mapinfo;
 			u32 argc = 0;
 
 			switch (mmu->impl->mem.oclass) {
@@ -1244,16 +1244,17 @@ nouveau_ttm_io_mem_reserve(struct ttm_device *bdev, struct ttm_resource *reg)
 				break;
 			}
 
-			ret = nvif_object_map_handle(&mem->mem.object,
-						     &args, argc,
-						     &handle, &length);
-			if (ret != 1) {
-				if (WARN_ON(ret == 0))
-					ret = -EINVAL;
+			ret = mem->mem.impl->map(mem->mem.priv, &args, argc, &mapinfo);
+			if (ret)
+				goto out;
+
+			if (WARN_ON(mapinfo.type != NVIF_MAP_IO)) {
+				mem->mem.impl->unmap(mem->mem.priv);
+				ret = -EINVAL;
 				goto out;
 			}
 
-			reg->bus.offset = handle;
+			reg->bus.offset = mapinfo.handle;
 		}
 		ret = 0;
 		break;
diff --git a/drivers/gpu/drm/nouveau/nouveau_chan.c b/drivers/gpu/drm/nouveau/nouveau_chan.c
index dd4f9915ccaf..db6eb3de694e 100644
--- a/drivers/gpu/drm/nouveau/nouveau_chan.c
+++ b/drivers/gpu/drm/nouveau/nouveau_chan.c
@@ -101,8 +101,11 @@ nouveau_channel_del(struct nouveau_channel **pchan)
 		nvif_object_dtor(&chan->gart);
 		nvif_object_dtor(&chan->vram);
 		nvif_event_dtor(&chan->kill);
+		if (!chan->userd.map.impl)
+			chan->userd.map.ptr = NULL;
+		nvif_object_unmap_cpu(&chan->userd.map);
 		nvif_object_dtor(&chan->user);
-		nvif_mem_dtor(&chan->mem_userd);
+		nvif_mem_dtor(&chan->userd.mem);
 		nvif_object_dtor(&chan->push.ctxdma);
 		nouveau_vma_del(&chan->push.vma);
 		nouveau_bo_unmap(chan->push.buffer);
@@ -131,7 +134,7 @@ nouveau_channel_wait(struct nvif_push *push, u32 size)
 	chan->dma.cur = chan->dma.cur + (chan->chan.push.cur - chan->chan.push.bgn);
 	ret = RING_SPACE(chan, size);
 	if (ret == 0) {
-		chan->chan.push.bgn = chan->chan.push.mem.object.map.ptr;
+		chan->chan.push.bgn = chan->chan.push.map.ptr;
 		chan->chan.push.bgn = chan->chan.push.bgn + chan->dma.cur;
 		chan->chan.push.cur = chan->chan.push.bgn;
 		chan->chan.push.end = chan->chan.push.bgn + size;
@@ -179,7 +182,7 @@ nouveau_channel_prep(struct nouveau_cli *cli,
 	chan->chan.push.mem.object.parent = cli->base.object.parent;
 	chan->chan.push.mem.object.client = &cli->base;
 	chan->chan.push.mem.object.name = "chanPush";
-	chan->chan.push.mem.object.map.ptr = chan->push.buffer->kmap.virtual;
+	chan->chan.push.map.ptr = chan->push.buffer->kmap.virtual;
 	chan->chan.push.wait = nouveau_channel_wait;
 	chan->chan.push.kick = nouveau_channel_kick;
 
@@ -330,16 +333,12 @@ nouveau_channel_ctor(struct nouveau_cli *cli, bool priv, u64 runm,
 	if (oclass >= VOLTA_CHANNEL_GPFIFO_A) {
 		ret = nvif_mem_ctor(&cli->mmu, "abi16ChanUSERD",
 				    NVIF_MEM_VRAM | NVIF_MEM_COHERENT | NVIF_MEM_MAPPABLE,
-				    0, PAGE_SIZE, NULL, 0, &chan->mem_userd);
+				    0, PAGE_SIZE, NULL, 0, &chan->userd.mem);
 		if (ret)
 			return ret;
 
-		args.chan.huserd = nvif_handle(&chan->mem_userd.object);
+		args.chan.huserd = nvif_handle(&chan->userd.mem.object);
 		args.chan.ouserd = 0;
-
-		chan->userd = &chan->mem_userd.object;
-	} else {
-		chan->userd = &chan->user;
 	}
 
 	get_task_comm(name, current);
@@ -366,9 +365,17 @@ nouveau_channel_init(struct nouveau_channel *chan, u32 vram, u32 gart)
 	struct nv_dma_v0 args = {};
 	int ret, i;
 
-	ret = nvif_object_map(chan->userd, NULL, 0);
-	if (ret)
-		return ret;
+	if (!chan->userd.mem.impl) {
+		ret = nvif_object_map(&chan->user, NULL, 0);
+		if (ret)
+			return ret;
+
+		chan->userd.map.ptr = chan->user.map.ptr;
+	} else {
+		ret = nvif_mem_map(&chan->userd.mem, NULL, 0, &chan->userd.map);
+		if (ret)
+			return ret;
+	}
 
 	if (chan->user.oclass >= FERMI_CHANNEL_GPFIFO) {
 		struct {
diff --git a/drivers/gpu/drm/nouveau/nouveau_chan.h b/drivers/gpu/drm/nouveau/nouveau_chan.h
index 016f668c0bc1..811271ae6fe1 100644
--- a/drivers/gpu/drm/nouveau/nouveau_chan.h
+++ b/drivers/gpu/drm/nouveau/nouveau_chan.h
@@ -14,8 +14,10 @@ struct nouveau_channel {
 	struct nouveau_cli *cli;
 	struct nouveau_vmm *vmm;
 
-	struct nvif_mem mem_userd;
-	struct nvif_object *userd;
+	struct {
+		struct nvif_mem mem;
+		struct nvif_map map;
+	} userd;
 
 	int runlist;
 	int chid;
diff --git a/drivers/gpu/drm/nouveau/nouveau_dma.c b/drivers/gpu/drm/nouveau/nouveau_dma.c
index 83eb9c9fa67e..43374a04654a 100644
--- a/drivers/gpu/drm/nouveau/nouveau_dma.c
+++ b/drivers/gpu/drm/nouveau/nouveau_dma.c
@@ -42,9 +42,9 @@ READ_GET(struct nouveau_channel *chan, uint64_t *prev_get, int *timeout)
 {
 	uint64_t val;
 
-	val = nvif_rd32(chan->userd, chan->user_get);
+	val = nvif_rd32(&chan->userd, chan->user_get);
         if (chan->user_get_hi)
-		val |= (uint64_t)nvif_rd32(chan->userd, chan->user_get_hi) << 32;
+		val |= (uint64_t)nvif_rd32(&chan->userd, chan->user_get_hi) << 32;
 
 	/* reset counter as long as GET is still advancing, this is
 	 * to avoid misdetecting a GPU lockup if the GPU happens to
@@ -89,7 +89,7 @@ nv50_dma_push(struct nouveau_channel *chan, u64 offset, u32 length,
 	/* Flush writes. */
 	nouveau_bo_rd32(pb, 0);
 
-	nvif_wr32(chan->userd, 0x8c, chan->dma.ib_put);
+	nvif_wr32(&chan->userd, 0x8c, chan->dma.ib_put);
 	if (user->func && user->func->doorbell)
 		user->func->doorbell(user, chan->token);
 	chan->dma.ib_free--;
@@ -101,7 +101,7 @@ nv50_dma_push_wait(struct nouveau_channel *chan, int count)
 	uint32_t cnt = 0, prev_get = 0;
 
 	while (chan->dma.ib_free < count) {
-		uint32_t get = nvif_rd32(chan->userd, 0x88);
+		uint32_t get = nvif_rd32(&chan->userd, 0x88);
 		if (get != prev_get) {
 			prev_get = get;
 			cnt = 0;
diff --git a/drivers/gpu/drm/nouveau/nouveau_dma.h b/drivers/gpu/drm/nouveau/nouveau_dma.h
index c52cda82353e..e5d718844c76 100644
--- a/drivers/gpu/drm/nouveau/nouveau_dma.h
+++ b/drivers/gpu/drm/nouveau/nouveau_dma.h
@@ -84,7 +84,7 @@ OUT_RING(struct nouveau_channel *chan, int data)
 #define WRITE_PUT(val) do {                                                    \
 	mb();                                                   \
 	nouveau_bo_rd32(chan->push.buffer, 0);                                 \
-	nvif_wr32(&chan->user, chan->user_put, ((val) << 2) + chan->push.addr);\
+	nvif_wr32(&chan->userd, chan->user_put, ((val) << 2) + chan->push.addr);\
 } while (0)
 
 static inline void
diff --git a/drivers/gpu/drm/nouveau/nv10_fence.c b/drivers/gpu/drm/nouveau/nv10_fence.c
index 1e45b5fcbf23..cbef6ef4bfb7 100644
--- a/drivers/gpu/drm/nouveau/nv10_fence.c
+++ b/drivers/gpu/drm/nouveau/nv10_fence.c
@@ -52,7 +52,7 @@ nv10_fence_sync(struct nouveau_fence *fence,
 u32
 nv10_fence_read(struct nouveau_channel *chan)
 {
-	return NVIF_RD32(&chan->user, NV06E, REFERENCE);
+	return NVIF_RD32(&chan->userd, NV06E, REFERENCE);
 }
 
 void
diff --git a/drivers/gpu/drm/nouveau/nvif/mem.c b/drivers/gpu/drm/nouveau/nvif/mem.c
index 73e66cbfbe43..91faecc4c080 100644
--- a/drivers/gpu/drm/nouveau/nvif/mem.c
+++ b/drivers/gpu/drm/nouveau/nvif/mem.c
@@ -26,14 +26,56 @@
 
 #include <nvif/if000a.h>
 
+int
+nvif_mem_unmap(struct nvif_mem *mem)
+{
+	if (!mem->mapinfo.length)
+		return 0;
+
+	mem->impl->unmap(mem->priv);
+	mem->mapinfo.length = 0;
+	return 0;
+}
+
+int
+nvif_mem_map(struct nvif_mem *mem, void *argv, u32 argc, struct nvif_map *map)
+{
+	int ret;
+
+	ret = mem->impl->map(mem->priv, argv, argc, &mem->mapinfo);
+	if (ret)
+		return ret;
+
+	ret = nvif_object_map_cpu(&mem->object, &mem->mapinfo, map);
+	if (ret)
+		mem->impl->unmap(mem->priv);
+
+	return ret;
+}
+
+int
+nvif_mem_unmap_dtor(struct nvif_mem *mem, struct nvif_map *map)
+{
+	int ret = 0;
+
+	if (mem->mapinfo.length) {
+		if (map)
+			ret = nvif_object_unmap_cpu(map);
+
+		nvif_mem_unmap(mem);
+	}
+
+	return ret;
+}
+
 int
 nvif_mem_ctor_map(struct nvif_mmu *mmu, const char *name, u8 type, u64 size,
-		  struct nvif_mem *mem)
+		  struct nvif_mem *mem, struct nvif_map *map)
 {
 	int ret = nvif_mem_ctor(mmu, name, NVIF_MEM_MAPPABLE | type,
 				0, size, NULL, 0, mem);
 	if (ret == 0) {
-		ret = nvif_object_map(&mem->object, NULL, 0);
+		ret = nvif_mem_map(mem, NULL, 0, map);
 		if (ret)
 			nvif_mem_dtor(mem);
 	}
@@ -46,6 +88,8 @@ nvif_mem_dtor(struct nvif_mem *mem)
 	if (!mem->impl)
 		return;
 
+	nvif_mem_unmap(mem);
+
 	mem->impl->del(mem->priv);
 	mem->impl = NULL;
 }
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.c
index f1ec0ed8e7c3..6756e3e207d9 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.c
@@ -78,10 +78,8 @@ nvkm_umem_search(struct nvkm_mmu *mmu, struct nvkm_client *client, u64 handle)
 }
 
 static int
-nvkm_umem_unmap(struct nvkm_object *object)
+nvkm_umem_unmap(struct nvif_mem_priv *umem)
 {
-	struct nvif_mem_priv *umem = container_of(object, typeof(*umem), object);
-
 	if (!umem->map)
 		return -EEXIST;
 
@@ -101,10 +99,8 @@ nvkm_umem_unmap(struct nvkm_object *object)
 }
 
 static int
-nvkm_umem_map(struct nvkm_object *object, void *argv, u32 argc,
-	      enum nvkm_object_map *type, u64 *handle, u64 *length)
+nvkm_umem_map(struct nvif_mem_priv *umem, void *argv, u32 argc, struct nvif_mapinfo *map)
 {
-	struct nvif_mem_priv *umem = container_of(object, typeof(*umem), object);
 	struct nvkm_mmu *mmu = umem->mmu;
 
 	if (!umem->mappable)
@@ -117,24 +113,24 @@ nvkm_umem_map(struct nvkm_object *object, void *argv, u32 argc,
 		if (ret)
 			return ret;
 
-		*handle = (unsigned long)(void *)umem->map;
-		*length = nvkm_memory_size(umem->memory);
-		*type = NVKM_OBJECT_MAP_VA;
+		map->handle = (unsigned long)(void *)umem->map;
+		map->length = nvkm_memory_size(umem->memory);
+		map->type = NVIF_MAP_VA;
 		return 0;
 	} else
 	if ((umem->type & NVKM_MEM_VRAM) ||
 	    (umem->type & NVKM_MEM_KIND)) {
 		int ret = mmu->func->mem.umap(mmu, umem->memory, argv, argc,
-					      handle, length, &umem->bar);
+					      &map->handle, &map->length, &umem->bar);
 		if (ret)
 			return ret;
 
-		*type = NVKM_OBJECT_MAP_IO;
+		map->type = NVIF_MAP_IO;
 	} else {
 		return -EINVAL;
 	}
 
-	umem->io = (*type == NVKM_OBJECT_MAP_IO);
+	umem->io = (map->type == NVIF_MAP_IO);
 	return 0;
 }
 
@@ -149,6 +145,8 @@ nvkm_umem_del(struct nvif_mem_priv *umem)
 static const struct nvif_mem_impl
 nvkm_umem_impl = {
 	.del = nvkm_umem_del,
+	.map = nvkm_umem_map,
+	.unmap = nvkm_umem_unmap,
 };
 
 static void *
@@ -166,8 +164,6 @@ nvkm_umem_dtor(struct nvkm_object *object)
 static const struct nvkm_object_func
 nvkm_umem = {
 	.dtor = nvkm_umem_dtor,
-	.map = nvkm_umem_map,
-	.unmap = nvkm_umem_unmap,
 };
 
 int
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 085/156] drm/nouveau/nvif: rework mmu "new vmm" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (83 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 084/156] drm/nouveau/nvif: rework mem "map"/"unmap" apis Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 086/156] drm/nouveau/nvif: remove mmu from object rb Ben Skeggs
                   ` (72 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interface

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 .../gpu/drm/nouveau/include/nvif/driverif.h   | 18 +++++++
 drivers/gpu/drm/nouveau/include/nvif/if000c.h | 12 -----
 drivers/gpu/drm/nouveau/include/nvif/vmm.h    | 12 ++---
 drivers/gpu/drm/nouveau/nouveau_bo.c          |  4 +-
 drivers/gpu/drm/nouveau/nouveau_chan.c        | 10 ++--
 drivers/gpu/drm/nouveau/nouveau_svm.c         |  2 +-
 drivers/gpu/drm/nouveau/nouveau_ttm.c         |  2 +-
 drivers/gpu/drm/nouveau/nouveau_uvmm.c        |  2 +-
 drivers/gpu/drm/nouveau/nouveau_vmm.c         |  2 +-
 drivers/gpu/drm/nouveau/nvif/mmu.c            |  2 +-
 drivers/gpu/drm/nouveau/nvif/vmm.c            | 48 +++++++----------
 .../gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c    | 24 ++++-----
 .../gpu/drm/nouveau/nvkm/subdev/mmu/ummu.h    |  2 -
 .../gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c    | 51 +++++++++++--------
 .../gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.h    |  4 +-
 15 files changed, 94 insertions(+), 101 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 2d883125f02b..4d256a3c3fcf 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -7,6 +7,7 @@ struct nvif_control_priv;
 struct nvif_usermode_priv;
 struct nvif_mmu_priv;
 struct nvif_mem_priv;
+struct nvif_vmm_priv;
 
 struct nvif_driver {
 	const char *name;
@@ -88,6 +89,20 @@ struct nvif_mem_impl {
 	int (*unmap)(struct nvif_mem_priv *);
 };
 
+enum nvif_vmm_type {
+	NVIF_VMM_TYPE_UNMANAGED,
+	NVIF_VMM_TYPE_MANAGED,
+	NVIF_VMM_TYPE_RAW,
+};
+
+struct nvif_vmm_impl {
+	void (*del)(struct nvif_vmm_priv *);
+
+	u64 start;
+	u64 limit;
+	u8 page_nr;
+};
+
 struct nvif_mmu_impl {
 	void (*del)(struct nvif_mmu_priv *);
 
@@ -125,6 +140,9 @@ struct nvif_mmu_impl {
 
 	struct {
 		s32 oclass;
+		int (*new)(struct nvif_mmu_priv *, enum nvif_vmm_type type, u64 addr, u64 size,
+			   void *, u32, const struct nvif_vmm_impl **, struct nvif_vmm_priv **,
+			   u64 handle);
 	} vmm;
 };
 
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if000c.h b/drivers/gpu/drm/nouveau/include/nvif/if000c.h
index a5a182b3c28d..c505c5de0088 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/if000c.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/if000c.h
@@ -1,17 +1,5 @@
 #ifndef __NVIF_IF000C_H__
 #define __NVIF_IF000C_H__
-struct nvif_vmm_v0 {
-	__u8  version;
-	__u8  page_nr;
-#define NVIF_VMM_V0_TYPE_UNMANAGED                                         0x00
-#define NVIF_VMM_V0_TYPE_MANAGED                                           0x01
-#define NVIF_VMM_V0_TYPE_RAW                                               0x02
-	__u8  type;
-	__u8  pad03[5];
-	__u64 addr;
-	__u64 size;
-	__u8  data[];
-};
 
 #define NVIF_VMM_V0_PAGE                                                   0x00
 #define NVIF_VMM_V0_GET                                                    0x01
diff --git a/drivers/gpu/drm/nouveau/include/nvif/vmm.h b/drivers/gpu/drm/nouveau/include/nvif/vmm.h
index e8d8fbd56010..c4b5d53d9bfd 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/vmm.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/vmm.h
@@ -1,15 +1,10 @@
 #ifndef __NVIF_VMM_H__
 #define __NVIF_VMM_H__
 #include <nvif/object.h>
+#include <nvif/driverif.h> /* NVIF_VMM_TYPE */
 struct nvif_mem;
 struct nvif_mmu;
 
-enum nvif_vmm_type {
-	UNMANAGED,
-	MANAGED,
-	RAW,
-};
-
 enum nvif_vmm_get {
 	ADDR,
 	PTES,
@@ -22,9 +17,9 @@ struct nvif_vma {
 };
 
 struct nvif_vmm {
+	const struct nvif_vmm_impl *impl;
+	struct nvif_vmm_priv *priv;
 	struct nvif_object object;
-	u64 start;
-	u64 limit;
 
 	struct {
 		u8 shift;
@@ -33,7 +28,6 @@ struct nvif_vmm {
 		bool host:1;
 		bool comp:1;
 	} *page;
-	int page_nr;
 };
 
 int nvif_vmm_ctor(struct nvif_mmu *, const char *name,
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
index 4c7aced7c398..29e00f8fdd12 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -264,7 +264,7 @@ nouveau_bo_alloc(struct nouveau_cli *cli, u64 *size, int *align, u32 domain,
 		nvbo->mode = tile_mode;
 
 		/* Determine the desirable target GPU page size for the buffer. */
-		for (i = 0; i < vmm->page_nr; i++) {
+		for (i = 0; i < vmm->impl->page_nr; i++) {
 			/* Because we cannot currently allow VMM maps to fail
 			 * during buffer migration, we need to determine page
 			 * size for the buffer up-front, and pre-allocate its
@@ -311,7 +311,7 @@ nouveau_bo_alloc(struct nouveau_cli *cli, u64 *size, int *align, u32 domain,
 			return ERR_PTR(-EINVAL);
 
 		/* Determine the desirable target GPU page size for the buffer. */
-		for (i = 0; i < vmm->page_nr; i++) {
+		for (i = 0; i < vmm->impl->page_nr; i++) {
 			/* Because we cannot currently allow VMM maps to fail
 			 * during buffer migration, we need to determine page
 			 * size for the buffer up-front, and pre-allocate its
diff --git a/drivers/gpu/drm/nouveau/nouveau_chan.c b/drivers/gpu/drm/nouveau/nouveau_chan.c
index db6eb3de694e..27c477ed6b9b 100644
--- a/drivers/gpu/drm/nouveau/nouveau_chan.c
+++ b/drivers/gpu/drm/nouveau/nouveau_chan.c
@@ -208,7 +208,7 @@ nouveau_channel_prep(struct nouveau_cli *cli,
 		args.target = NV_DMA_V0_TARGET_VM;
 		args.access = NV_DMA_V0_ACCESS_VM;
 		args.start = 0;
-		args.limit = chan->vmm->vmm.limit - 1;
+		args.limit = chan->vmm->vmm.impl->limit - 1;
 	} else
 	if (chan->push.buffer->bo.resource->mem_type == TTM_PL_VRAM) {
 		if (device->info.family == NV_DEVICE_INFO_V0_TNT) {
@@ -237,7 +237,7 @@ nouveau_channel_prep(struct nouveau_cli *cli,
 			args.target = NV_DMA_V0_TARGET_VM;
 			args.access = NV_DMA_V0_ACCESS_RDWR;
 			args.start = 0;
-			args.limit = chan->vmm->vmm.limit - 1;
+			args.limit = chan->vmm->vmm.impl->limit - 1;
 		}
 	}
 
@@ -404,7 +404,7 @@ nouveau_channel_init(struct nouveau_channel *chan, u32 vram, u32 gart)
 			args.target = NV_DMA_V0_TARGET_VM;
 			args.access = NV_DMA_V0_ACCESS_VM;
 			args.start = 0;
-			args.limit = chan->vmm->vmm.limit - 1;
+			args.limit = chan->vmm->vmm.impl->limit - 1;
 		} else {
 			args.target = NV_DMA_V0_TARGET_VRAM;
 			args.access = NV_DMA_V0_ACCESS_RDWR;
@@ -422,7 +422,7 @@ nouveau_channel_init(struct nouveau_channel *chan, u32 vram, u32 gart)
 			args.target = NV_DMA_V0_TARGET_VM;
 			args.access = NV_DMA_V0_ACCESS_VM;
 			args.start = 0;
-			args.limit = chan->vmm->vmm.limit - 1;
+			args.limit = chan->vmm->vmm.impl->limit - 1;
 		} else
 		if (drm->agp.bridge) {
 			args.target = NV_DMA_V0_TARGET_AGP;
@@ -433,7 +433,7 @@ nouveau_channel_init(struct nouveau_channel *chan, u32 vram, u32 gart)
 			args.target = NV_DMA_V0_TARGET_VM;
 			args.access = NV_DMA_V0_ACCESS_RDWR;
 			args.start = 0;
-			args.limit = chan->vmm->vmm.limit - 1;
+			args.limit = chan->vmm->vmm.impl->limit - 1;
 		}
 
 		ret = nvif_object_ctor(&chan->user, "abi16ChanGartCtxDma", gart,
diff --git a/drivers/gpu/drm/nouveau/nouveau_svm.c b/drivers/gpu/drm/nouveau/nouveau_svm.c
index a478b5a9ed0a..cf5dfbe63e69 100644
--- a/drivers/gpu/drm/nouveau/nouveau_svm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_svm.c
@@ -346,7 +346,7 @@ nouveau_svmm_init(struct drm_device *dev, void *data,
 	 * All future channel/memory allocations will make use of this
 	 * VMM instead of the standard one.
 	 */
-	ret = nvif_vmm_ctor(&cli->mmu, "svmVmm", MANAGED,
+	ret = nvif_vmm_ctor(&cli->mmu, "svmVmm", NVIF_VMM_TYPE_MANAGED,
 			    args->unmanaged_addr, args->unmanaged_size,
 			    &(struct gp100_vmm_v0) {
 				.fault_replay = true,
diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c
index f87ca8a0e6ae..2d6f1c97db1c 100644
--- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
@@ -326,7 +326,7 @@ nouveau_ttm_init(struct nouveau_drm *drm)
 
 	/* GART init */
 	if (!drm->agp.bridge) {
-		drm->gem.gart_available = drm->client.vmm.vmm.limit;
+		drm->gem.gart_available = drm->cli.vmm.vmm.impl->limit;
 	} else {
 		drm->gem.gart_available = drm->agp.size;
 	}
diff --git a/drivers/gpu/drm/nouveau/nouveau_uvmm.c b/drivers/gpu/drm/nouveau/nouveau_uvmm.c
index d35096071c1a..1340138bbc13 100644
--- a/drivers/gpu/drm/nouveau/nouveau_uvmm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_uvmm.c
@@ -1865,7 +1865,7 @@ nouveau_uvmm_ioctl_vm_init(struct drm_device *dev,
 	/* GPUVM takes care from here on. */
 	drm_gem_object_put(r_obj);
 
-	ret = nvif_vmm_ctor(&cli->mmu, "uvmm", RAW,
+	ret = nvif_vmm_ctor(&cli->mmu, "uvmm", NVIF_VMM_TYPE_RAW,
 			    init->kernel_managed_addr,
 			    init->kernel_managed_size,
 			    NULL, 0, &uvmm->vmm.vmm);
diff --git a/drivers/gpu/drm/nouveau/nouveau_vmm.c b/drivers/gpu/drm/nouveau/nouveau_vmm.c
index 26a41769551a..353c1a3f9714 100644
--- a/drivers/gpu/drm/nouveau/nouveau_vmm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_vmm.c
@@ -131,7 +131,7 @@ nouveau_vmm_fini(struct nouveau_vmm *vmm)
 int
 nouveau_vmm_init(struct nouveau_cli *cli, struct nouveau_vmm *vmm)
 {
-	int ret = nvif_vmm_ctor(&cli->mmu, "drmVmm", UNMANAGED,
+	int ret = nvif_vmm_ctor(&cli->mmu, "drmVmm", NVIF_VMM_TYPE_UNMANAGED,
 				PAGE_SIZE, 0, NULL, 0, &vmm->vmm);
 	if (ret)
 		return ret;
diff --git a/drivers/gpu/drm/nouveau/nvif/mmu.c b/drivers/gpu/drm/nouveau/nvif/mmu.c
index d1d09e5a6909..cf1d27f2678d 100644
--- a/drivers/gpu/drm/nouveau/nvif/mmu.c
+++ b/drivers/gpu/drm/nouveau/nvif/mmu.c
@@ -50,5 +50,5 @@ nvif_mmu_ctor(struct nvif_device *device, const char *name, struct nvif_mmu *mmu
 		return ret;
 
 	nvif_object_ctor(&device->object, name ?: "nvifMmu", 0, oclass, &mmu->object);
-	return ret;
+	return 0;
 }
diff --git a/drivers/gpu/drm/nouveau/nvif/vmm.c b/drivers/gpu/drm/nouveau/nvif/vmm.c
index 2738ea9229cc..35564e9c93ab 100644
--- a/drivers/gpu/drm/nouveau/nvif/vmm.c
+++ b/drivers/gpu/drm/nouveau/nvif/vmm.c
@@ -20,7 +20,9 @@
  * OTHER DEALINGS IN THE SOFTWARE.
  */
 #include <nvif/vmm.h>
+#include <nvif/driverif.h>
 #include <nvif/mem.h>
+#include <nvif/printf.h>
 
 #include <nvif/if000c.h>
 
@@ -191,8 +193,12 @@ nvif_vmm_raw_sparse(struct nvif_vmm *vmm, u64 addr, u64 size, bool ref)
 void
 nvif_vmm_dtor(struct nvif_vmm *vmm)
 {
+	if (!vmm->impl)
+		return;
+
 	kfree(vmm->page);
-	nvif_object_dtor(&vmm->object);
+	vmm->impl->del(vmm->priv);
+	vmm->impl = NULL;
 }
 
 int
@@ -200,47 +206,27 @@ nvif_vmm_ctor(struct nvif_mmu *mmu, const char *name,
 	      enum nvif_vmm_type type, u64 addr, u64 size, void *argv, u32 argc,
 	      struct nvif_vmm *vmm)
 {
-	struct nvif_vmm_v0 *args;
-	u32 argn = sizeof(*args) + argc;
-	int ret = -ENOSYS, i;
+	const u32 oclass = mmu->impl->vmm.oclass;
+	int ret, i;
 
-	vmm->object.client = NULL;
 	vmm->page = NULL;
 
-	if (!(args = kmalloc(argn, GFP_KERNEL)))
-		return -ENOMEM;
-	args->version = 0;
-	args->addr = addr;
-	args->size = size;
-
-	switch (type) {
-	case UNMANAGED: args->type = NVIF_VMM_V0_TYPE_UNMANAGED; break;
-	case MANAGED: args->type = NVIF_VMM_V0_TYPE_MANAGED; break;
-	case RAW: args->type = NVIF_VMM_V0_TYPE_RAW; break;
-	default:
-		WARN_ON(1);
-		return -EINVAL;
-	}
-
-	memcpy(args->data, argv, argc);
-
-	ret = nvif_object_ctor(&mmu->object, name ? name : "nvifVmm", 0,
-			       mmu->impl->vmm.oclass, args, argn, &vmm->object);
+	ret = mmu->impl->vmm.new(mmu->priv, type, addr, size, argv, argc, &vmm->impl, &vmm->priv,
+				 nvif_handle(&vmm->object));
+	NVIF_ERRON(ret, &mmu->object, "[NEW vmm%08x]", oclass);
 	if (ret)
-		goto done;
+		return ret;
 
-	vmm->start = args->addr;
-	vmm->limit = args->size;
+	nvif_object_ctor(&mmu->object, name ?: "nvifVmm", 0, oclass, &vmm->object);
 
-	vmm->page_nr = args->page_nr;
-	vmm->page = kmalloc_array(vmm->page_nr, sizeof(*vmm->page),
+	vmm->page = kmalloc_array(vmm->impl->page_nr, sizeof(*vmm->page),
 				  GFP_KERNEL);
 	if (!vmm->page) {
 		ret = -ENOMEM;
 		goto done;
 	}
 
-	for (i = 0; i < vmm->page_nr; i++) {
+	for (i = 0; i < vmm->impl->page_nr; i++) {
 		struct nvif_vmm_page_v0 args = { .index = i };
 
 		ret = nvif_object_mthd(&vmm->object, NVIF_VMM_V0_PAGE,
@@ -258,6 +244,6 @@ nvif_vmm_ctor(struct nvif_mmu *mmu, const char *name,
 done:
 	if (ret)
 		nvif_vmm_dtor(vmm);
-	kfree(args);
+
 	return ret;
 }
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c
index 8458583af0a7..7afb68dc4bed 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c
@@ -26,20 +26,18 @@
 #include <core/client.h>
 
 static int
-nvkm_ummu_sclass(struct nvkm_object *object, int index,
-		 struct nvkm_oclass *oclass)
+nvkm_ummu_vmm_new(struct nvif_mmu_priv *ummu, enum nvif_vmm_type type, u64 addr, u64 size,
+		  void *argv, u32 argc, const struct nvif_vmm_impl **pimpl,
+		  struct nvif_vmm_priv **ppriv, u64 handle)
 {
-	struct nvkm_mmu *mmu = container_of(object, struct nvif_mmu_priv, object)->mmu;
-
-	if (mmu->func->vmm.user.oclass) {
-		if (index-- == 0) {
-			oclass->base = mmu->func->vmm.user;
-			oclass->ctor = nvkm_uvmm_new;
-			return 0;
-		}
-	}
+	struct nvkm_object *object;
+	int ret;
 
-	return -EINVAL;
+	ret = nvkm_uvmm_new(ummu->mmu, type, addr, size, argv, argc, pimpl, ppriv, &object);
+	if (ret)
+		return ret;
+
+	return nvkm_object_link_rb(ummu->object.client, &ummu->object, handle, object);
 }
 
 static int
@@ -71,7 +69,6 @@ nvkm_ummu_impl = {
 
 static const struct nvkm_object_func
 nvkm_ummu = {
-	.sclass = nvkm_ummu_sclass,
 };
 
 int
@@ -119,6 +116,7 @@ nvkm_ummu_new(struct nvkm_device *device, const struct nvif_mmu_impl **pimpl,
 	ummu->impl.mem.new = nvkm_ummu_mem_new;
 
 	ummu->impl.vmm.oclass = mmu->func->vmm.user.oclass;
+	ummu->impl.vmm.new = nvkm_ummu_vmm_new;
 
 	*pimpl = &ummu->impl;
 	*ppriv = ummu;
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.h b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.h
index c03563aa4cae..d80b2af494dd 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.h
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.h
@@ -5,8 +5,6 @@ struct nvkm_device;
 
 #include <nvif/driverif.h>
 
-#define nvkm_ummu nvif_mmu_priv
-
 struct nvif_mmu_priv {
 	struct nvkm_object object;
 	struct nvkm_mmu *mmu;
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c
index 761a50047b42..28d491a03c59 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c
@@ -34,6 +34,8 @@
 struct nvif_vmm_priv {
 	struct nvkm_object object;
 	struct nvkm_vmm *vmm;
+
+	struct nvif_vmm_impl impl;
 };
 
 static const struct nvkm_object_func nvkm_uvmm;
@@ -521,6 +523,19 @@ nvkm_uvmm_mthd(struct nvkm_object *object, u32 mthd, void *argv, u32 argc)
 	return -EINVAL;
 }
 
+static void
+nvkm_uvmm_del(struct nvif_vmm_priv *uvmm)
+{
+	struct nvkm_object *object = &uvmm->object;
+
+	nvkm_object_del(&object);
+}
+
+static const struct nvif_vmm_impl
+nvkm_uvmm_impl = {
+	.del = nvkm_uvmm_del,
+};
+
 static void *
 nvkm_uvmm_dtor(struct nvkm_object *object)
 {
@@ -537,33 +552,22 @@ nvkm_uvmm = {
 };
 
 int
-nvkm_uvmm_new(const struct nvkm_oclass *oclass, void *argv, u32 argc,
+nvkm_uvmm_new(struct nvkm_mmu *mmu, u8 type, u64 addr, u64 size, void *argv, u32 argc,
+	      const struct nvif_vmm_impl **pimpl, struct nvif_vmm_priv **ppriv,
 	      struct nvkm_object **pobject)
 {
-	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;
-	} *args = argv;
 	const struct nvkm_vmm_page *page;
 	struct nvif_vmm_priv *uvmm;
 	int ret = -ENOSYS;
-	u64 addr, size;
 	bool managed, raw;
 
-	if (!(ret = nvif_unpack(ret, &argv, &argc, args->v0, 0, 0, more))) {
-		managed = args->v0.type == NVIF_VMM_V0_TYPE_MANAGED;
-		raw = args->v0.type == NVIF_VMM_V0_TYPE_RAW;
-		addr = args->v0.addr;
-		size = args->v0.size;
-	} else
-		return ret;
+	managed = type == NVIF_VMM_TYPE_MANAGED;
+	raw = type == NVIF_VMM_TYPE_RAW;
 
 	if (!(uvmm = kzalloc(sizeof(*uvmm), GFP_KERNEL)))
 		return -ENOMEM;
 
-	nvkm_object_ctor(&nvkm_uvmm, oclass, &uvmm->object);
-	*pobject = &uvmm->object;
+	nvkm_object_ctor(&nvkm_uvmm, &(struct nvkm_oclass) {}, &uvmm->object);
 
 	if (!mmu->vmm) {
 		ret = mmu->func->vmm.ctor(mmu, managed || raw, addr, size,
@@ -571,7 +575,7 @@ nvkm_uvmm_new(const struct nvkm_oclass *oclass, void *argv, u32 argc,
 		if (ret)
 			return ret;
 
-		uvmm->vmm->debug = max(uvmm->vmm->debug, oclass->client->debug);
+		uvmm->vmm->debug = NV_DBG_ERROR;
 	} else {
 		if (size)
 			return -EINVAL;
@@ -586,11 +590,16 @@ nvkm_uvmm_new(const struct nvkm_oclass *oclass, void *argv, u32 argc,
 			return ret;
 	}
 
+	uvmm->impl = nvkm_uvmm_impl;
+	uvmm->impl.start = uvmm->vmm->start;
+	uvmm->impl.limit = uvmm->vmm->limit;
+
 	page = uvmm->vmm->func->page;
-	args->v0.page_nr = 0;
 	while (page && (page++)->shift)
-		args->v0.page_nr++;
-	args->v0.addr = uvmm->vmm->start;
-	args->v0.size = uvmm->vmm->limit;
+		uvmm->impl.page_nr++;
+
+	*pimpl = &uvmm->impl;
+	*ppriv = uvmm;
+	*pobject = &uvmm->object;
 	return 0;
 }
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.h b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.h
index cf0172a320c3..51c639cd0ce0 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.h
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.h
@@ -1,7 +1,9 @@
 #ifndef __NVKM_UVMM_H__
 #define __NVKM_UVMM_H__
 #include "vmm.h"
+#include <nvif/driverif.h>
 
-int nvkm_uvmm_new(const struct nvkm_oclass *, void *argv, u32 argc,
+int nvkm_uvmm_new(struct nvkm_mmu *mmu, u8 type, u64 addr, u64 size,
+		  void *, u32, const struct nvif_vmm_impl **, struct nvif_vmm_priv **,
 		  struct nvkm_object **);
 #endif
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 086/156] drm/nouveau/nvif: remove mmu from object rb
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (84 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 085/156] drm/nouveau/nvif: rework mmu "new vmm" api Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 087/156] drm/nouveau/nvif: rework vmm "page" api Ben Skeggs
                   ` (71 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- no more users

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/include/nvif/driverif.h | 2 +-
 drivers/gpu/drm/nouveau/nvif/mmu.c              | 3 +--
 drivers/gpu/drm/nouveau/nvkm/device/user.c      | 6 +++---
 3 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 4d256a3c3fcf..8f1410ab8256 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -201,7 +201,7 @@ struct nvif_device_impl {
 	struct {
 		s32 oclass;
 		int (*new)(struct nvif_device_priv *, const struct nvif_mmu_impl **,
-			   struct nvif_mmu_priv **, u64 handle);
+			   struct nvif_mmu_priv **);
 	} mmu;
 
 	struct {
diff --git a/drivers/gpu/drm/nouveau/nvif/mmu.c b/drivers/gpu/drm/nouveau/nvif/mmu.c
index cf1d27f2678d..b5adf35d9535 100644
--- a/drivers/gpu/drm/nouveau/nvif/mmu.c
+++ b/drivers/gpu/drm/nouveau/nvif/mmu.c
@@ -43,8 +43,7 @@ nvif_mmu_ctor(struct nvif_device *device, const char *name, struct nvif_mmu *mmu
 
 	mmu->impl = NULL;
 
-	ret = device->impl->mmu.new(device->priv, &mmu->impl, &mmu->priv,
-				    nvif_handle(&mmu->object));
+	ret = device->impl->mmu.new(device->priv, &mmu->impl, &mmu->priv);
 	NVIF_ERRON(ret, &device->object, "[NEW mmu%08x]", oclass);
 	if (ret)
 		return ret;
diff --git a/drivers/gpu/drm/nouveau/nvkm/device/user.c b/drivers/gpu/drm/nouveau/nvkm/device/user.c
index e9486d9da64b..e63462188f2a 100644
--- a/drivers/gpu/drm/nouveau/nvkm/device/user.c
+++ b/drivers/gpu/drm/nouveau/nvkm/device/user.c
@@ -79,8 +79,7 @@ nvkm_udevice_time(struct nvif_device_priv *udev)
 
 static int
 nvkm_udevice_mmu_new(struct nvif_device_priv *udev,
-		     const struct nvif_mmu_impl **pimpl, struct nvif_mmu_priv **ppriv,
-		     u64 handle)
+		     const struct nvif_mmu_impl **pimpl, struct nvif_mmu_priv **ppriv)
 {
 	struct nvkm_device *device = udev->device;
 	struct nvkm_object *object;
@@ -90,7 +89,8 @@ nvkm_udevice_mmu_new(struct nvif_device_priv *udev,
 	if (ret)
 		return ret;
 
-	return nvkm_object_link_rb(udev->object.client, &udev->object, handle, object);
+	nvkm_object_link(&udev->object, object);
+	return 0;
 }
 
 static void
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 087/156] drm/nouveau/nvif: rework vmm "page" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (85 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 086/156] drm/nouveau/nvif: remove mmu from object rb Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 088/156] drm/nouveau/nvif: rework vmm "get"/"put" apis Ben Skeggs
                   ` (70 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interfaces

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  8 ++++
 drivers/gpu/drm/nouveau/include/nvif/if000c.h | 12 ------
 drivers/gpu/drm/nouveau/include/nvif/vmm.h    |  8 ----
 drivers/gpu/drm/nouveau/nouveau_bo.c          | 20 +++++-----
 drivers/gpu/drm/nouveau/nvif/vmm.c            | 32 +--------------
 .../gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c    | 40 +++++--------------
 6 files changed, 29 insertions(+), 91 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 8f1410ab8256..7540fe4d02c0 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -101,6 +101,14 @@ struct nvif_vmm_impl {
 	u64 start;
 	u64 limit;
 	u8 page_nr;
+
+	struct {
+		u8 shift;
+		bool sparse;
+		bool vram;
+		bool host;
+		bool comp;
+	} page[8];
 };
 
 struct nvif_mmu_impl {
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if000c.h b/drivers/gpu/drm/nouveau/include/nvif/if000c.h
index c505c5de0088..f554062469c3 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/if000c.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/if000c.h
@@ -1,7 +1,6 @@
 #ifndef __NVIF_IF000C_H__
 #define __NVIF_IF000C_H__
 
-#define NVIF_VMM_V0_PAGE                                                   0x00
 #define NVIF_VMM_V0_GET                                                    0x01
 #define NVIF_VMM_V0_PUT                                                    0x02
 #define NVIF_VMM_V0_MAP                                                    0x03
@@ -11,17 +10,6 @@
 #define NVIF_VMM_V0_RAW                                                    0x07
 #define NVIF_VMM_V0_MTHD(i)                                         ((i) + 0x80)
 
-struct nvif_vmm_page_v0 {
-	__u8  version;
-	__u8  index;
-	__u8  shift;
-	__u8  sparse;
-	__u8  vram;
-	__u8  host;
-	__u8  comp;
-	__u8  pad07[1];
-};
-
 struct nvif_vmm_get_v0 {
 	__u8  version;
 #define NVIF_VMM_GET_V0_ADDR                                               0x00
diff --git a/drivers/gpu/drm/nouveau/include/nvif/vmm.h b/drivers/gpu/drm/nouveau/include/nvif/vmm.h
index c4b5d53d9bfd..3019ddc98782 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/vmm.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/vmm.h
@@ -20,14 +20,6 @@ struct nvif_vmm {
 	const struct nvif_vmm_impl *impl;
 	struct nvif_vmm_priv *priv;
 	struct nvif_object object;
-
-	struct {
-		u8 shift;
-		bool sparse:1;
-		bool vram:1;
-		bool host:1;
-		bool comp:1;
-	} *page;
 };
 
 int nvif_vmm_ctor(struct nvif_mmu *, const char *name,
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
index 29e00f8fdd12..ed81872e2dba 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -273,21 +273,21 @@ nouveau_bo_alloc(struct nouveau_cli *cli, u64 *size, int *align, u32 domain,
 			 * Skip page sizes that can't support needed domains.
 			 */
 			if (cli->device.info.family > NV_DEVICE_INFO_V0_CURIE &&
-			    (domain & NOUVEAU_GEM_DOMAIN_VRAM) && !vmm->page[i].vram)
+			    (domain & NOUVEAU_GEM_DOMAIN_VRAM) && !vmm->impl->page[i].vram)
 				continue;
 			if ((domain & NOUVEAU_GEM_DOMAIN_GART) &&
-			    (!vmm->page[i].host || vmm->page[i].shift > PAGE_SHIFT))
+			    (!vmm->impl->page[i].host || vmm->impl->page[i].shift > PAGE_SHIFT))
 				continue;
 
 			/* Select this page size if it's the first that supports
 			 * the potential memory domains, or when it's compatible
 			 * with the requested compression settings.
 			 */
-			if (pi < 0 || !nvbo->comp || vmm->page[i].comp)
+			if (pi < 0 || !nvbo->comp || vmm->impl->page[i].comp)
 				pi = i;
 
 			/* Stop once the buffer is larger than the current page size. */
-			if (*size >= 1ULL << vmm->page[i].shift)
+			if (*size >= 1ULL << vmm->impl->page[i].shift)
 				break;
 		}
 
@@ -297,12 +297,12 @@ nouveau_bo_alloc(struct nouveau_cli *cli, u64 *size, int *align, u32 domain,
 		}
 
 		/* Disable compression if suitable settings couldn't be found. */
-		if (nvbo->comp && !vmm->page[pi].comp) {
+		if (nvbo->comp && !vmm->impl->page[pi].comp) {
 			if (mmu->object.oclass >= NVIF_CLASS_MMU_GF100)
 				nvbo->kind = mmu->impl->kind[nvbo->kind];
 			nvbo->comp = 0;
 		}
-		nvbo->page = vmm->page[pi].shift;
+		nvbo->page = vmm->impl->page[pi].shift;
 	} else {
 		/* reject other tile flags when in VM mode. */
 		if (tile_mode)
@@ -319,24 +319,24 @@ nouveau_bo_alloc(struct nouveau_cli *cli, u64 *size, int *align, u32 domain,
 			 *
 			 * Skip page sizes that can't support needed domains.
 			 */
-			if ((domain & NOUVEAU_GEM_DOMAIN_VRAM) && !vmm->page[i].vram)
+			if ((domain & NOUVEAU_GEM_DOMAIN_VRAM) && !vmm->impl->page[i].vram)
 				continue;
 			if ((domain & NOUVEAU_GEM_DOMAIN_GART) &&
-			    (!vmm->page[i].host || vmm->page[i].shift > PAGE_SHIFT))
+			    (!vmm->impl->page[i].host || vmm->impl->page[i].shift > PAGE_SHIFT))
 				continue;
 
 			/* pick the last one as it will be smallest. */
 			pi = i;
 
 			/* Stop once the buffer is larger than the current page size. */
-			if (*size >= 1ULL << vmm->page[i].shift)
+			if (*size >= 1ULL << vmm->impl->page[i].shift)
 				break;
 		}
 		if (WARN_ON(pi < 0)) {
 			kfree(nvbo);
 			return ERR_PTR(-EINVAL);
 		}
-		nvbo->page = vmm->page[pi].shift;
+		nvbo->page = vmm->impl->page[pi].shift;
 	}
 
 	nouveau_bo_fixup_align(nvbo, align, size);
diff --git a/drivers/gpu/drm/nouveau/nvif/vmm.c b/drivers/gpu/drm/nouveau/nvif/vmm.c
index 35564e9c93ab..73c63bfd1e38 100644
--- a/drivers/gpu/drm/nouveau/nvif/vmm.c
+++ b/drivers/gpu/drm/nouveau/nvif/vmm.c
@@ -196,7 +196,6 @@ nvif_vmm_dtor(struct nvif_vmm *vmm)
 	if (!vmm->impl)
 		return;
 
-	kfree(vmm->page);
 	vmm->impl->del(vmm->priv);
 	vmm->impl = NULL;
 }
@@ -207,9 +206,7 @@ nvif_vmm_ctor(struct nvif_mmu *mmu, const char *name,
 	      struct nvif_vmm *vmm)
 {
 	const u32 oclass = mmu->impl->vmm.oclass;
-	int ret, i;
-
-	vmm->page = NULL;
+	int ret;
 
 	ret = mmu->impl->vmm.new(mmu->priv, type, addr, size, argv, argc, &vmm->impl, &vmm->priv,
 				 nvif_handle(&vmm->object));
@@ -218,32 +215,5 @@ nvif_vmm_ctor(struct nvif_mmu *mmu, const char *name,
 		return ret;
 
 	nvif_object_ctor(&mmu->object, name ?: "nvifVmm", 0, oclass, &vmm->object);
-
-	vmm->page = kmalloc_array(vmm->impl->page_nr, sizeof(*vmm->page),
-				  GFP_KERNEL);
-	if (!vmm->page) {
-		ret = -ENOMEM;
-		goto done;
-	}
-
-	for (i = 0; i < vmm->impl->page_nr; i++) {
-		struct nvif_vmm_page_v0 args = { .index = i };
-
-		ret = nvif_object_mthd(&vmm->object, NVIF_VMM_V0_PAGE,
-				       &args, sizeof(args));
-		if (ret)
-			break;
-
-		vmm->page[i].shift = args.shift;
-		vmm->page[i].sparse = args.sparse;
-		vmm->page[i].vram = args.vram;
-		vmm->page[i].host = args.host;
-		vmm->page[i].comp = args.comp;
-	}
-
-done:
-	if (ret)
-		nvif_vmm_dtor(vmm);
-
 	return ret;
 }
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c
index 28d491a03c59..15aa6a37060b 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c
@@ -307,34 +307,6 @@ nvkm_uvmm_mthd_get(struct nvkm_uvmm *uvmm, void *argv, u32 argc)
 	return ret;
 }
 
-static int
-nvkm_uvmm_mthd_page(struct nvkm_uvmm *uvmm, void *argv, u32 argc)
-{
-	union {
-		struct nvif_vmm_page_v0 v0;
-	} *args = argv;
-	const struct nvkm_vmm_page *page;
-	int ret = -ENOSYS;
-	u8 type, index, nr;
-
-	page = uvmm->vmm->func->page;
-	for (nr = 0; page[nr].shift; nr++);
-
-	if (!(nvif_unpack(ret, &argv, &argc, args->v0, 0, 0, false))) {
-		if ((index = args->v0.index) >= nr)
-			return -EINVAL;
-		type = page[index].type;
-		args->v0.shift = page[index].shift;
-		args->v0.sparse = !!(type & NVKM_VMM_PAGE_SPARSE);
-		args->v0.vram = !!(type & NVKM_VMM_PAGE_VRAM);
-		args->v0.host = !!(type & NVKM_VMM_PAGE_HOST);
-		args->v0.comp = !!(type & NVKM_VMM_PAGE_COMP);
-	} else
-		return -ENOSYS;
-
-	return 0;
-}
-
 static inline int
 nvkm_uvmm_page_index(struct nvif_vmm_priv *uvmm, u64 size, u8 shift, u8 *refd)
 {
@@ -502,7 +474,6 @@ nvkm_uvmm_mthd(struct nvkm_object *object, u32 mthd, void *argv, u32 argc)
 {
 	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);
 	case NVIF_VMM_V0_PUT   : return nvkm_uvmm_mthd_put   (uvmm, argv, argc);
 	case NVIF_VMM_V0_MAP   : return nvkm_uvmm_mthd_map   (uvmm, argv, argc);
@@ -595,8 +566,17 @@ nvkm_uvmm_new(struct nvkm_mmu *mmu, u8 type, u64 addr, u64 size, void *argv, u32
 	uvmm->impl.limit = uvmm->vmm->limit;
 
 	page = uvmm->vmm->func->page;
-	while (page && (page++)->shift)
+	for (int i = 0; page->shift; i++, page++) {
+		if (WARN_ON(i >= ARRAY_SIZE(uvmm->impl.page)))
+			break;
+
+		uvmm->impl.page[i].shift  = page->shift;
+		uvmm->impl.page[i].sparse = !!(page->type & NVKM_VMM_PAGE_SPARSE);
+		uvmm->impl.page[i].vram   = !!(page->type & NVKM_VMM_PAGE_VRAM);
+		uvmm->impl.page[i].host   = !!(page->type & NVKM_VMM_PAGE_HOST);
+		uvmm->impl.page[i].comp   = !!(page->type & NVKM_VMM_PAGE_COMP);
 		uvmm->impl.page_nr++;
+	}
 
 	*pimpl = &uvmm->impl;
 	*ppriv = uvmm;
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 088/156] drm/nouveau/nvif: rework vmm "get"/"put" apis
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (86 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 087/156] drm/nouveau/nvif: rework vmm "page" api Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 089/156] drm/nouveau/nvif: rework vmm "map"/"unmap" apis Ben Skeggs
                   ` (69 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interfaces

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 .../gpu/drm/nouveau/include/nvif/driverif.h   | 10 ++++
 drivers/gpu/drm/nouveau/include/nvif/if000c.h | 22 ---------
 drivers/gpu/drm/nouveau/include/nvif/vmm.h    | 10 +---
 drivers/gpu/drm/nouveau/nouveau_bo.c          |  4 +-
 drivers/gpu/drm/nouveau/nouveau_ttm.c         |  2 +-
 drivers/gpu/drm/nouveau/nouveau_vmm.c         |  4 +-
 drivers/gpu/drm/nouveau/nvif/vmm.c            | 38 ++++-----------
 .../gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c    | 46 +++++--------------
 8 files changed, 39 insertions(+), 97 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 7540fe4d02c0..673969d46b66 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -95,6 +95,12 @@ enum nvif_vmm_type {
 	NVIF_VMM_TYPE_RAW,
 };
 
+enum nvif_vmm_get_type {
+	NVIF_VMM_GET_ADDR,
+	NVIF_VMM_GET_PTES,
+	NVIF_VMM_GET_LAZY,
+};
+
 struct nvif_vmm_impl {
 	void (*del)(struct nvif_vmm_priv *);
 
@@ -109,6 +115,10 @@ struct nvif_vmm_impl {
 		bool host;
 		bool comp;
 	} page[8];
+
+	int (*get)(struct nvif_vmm_priv *, enum nvif_vmm_get_type, bool sparse, u8 page,
+		   u8 align, u64 size, u64 *addr);
+	int (*put)(struct nvif_vmm_priv *, u64 addr);
 };
 
 struct nvif_mmu_impl {
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if000c.h b/drivers/gpu/drm/nouveau/include/nvif/if000c.h
index f554062469c3..50a834d5eb19 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/if000c.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/if000c.h
@@ -1,8 +1,6 @@
 #ifndef __NVIF_IF000C_H__
 #define __NVIF_IF000C_H__
 
-#define NVIF_VMM_V0_GET                                                    0x01
-#define NVIF_VMM_V0_PUT                                                    0x02
 #define NVIF_VMM_V0_MAP                                                    0x03
 #define NVIF_VMM_V0_UNMAP                                                  0x04
 #define NVIF_VMM_V0_PFNMAP                                                 0x05
@@ -10,26 +8,6 @@
 #define NVIF_VMM_V0_RAW                                                    0x07
 #define NVIF_VMM_V0_MTHD(i)                                         ((i) + 0x80)
 
-struct nvif_vmm_get_v0 {
-	__u8  version;
-#define NVIF_VMM_GET_V0_ADDR                                               0x00
-#define NVIF_VMM_GET_V0_PTES                                               0x01
-#define NVIF_VMM_GET_V0_LAZY	                                           0x02
-	__u8  type;
-	__u8  sparse;
-	__u8  page;
-	__u8  align;
-	__u8  pad05[3];
-	__u64 size;
-	__u64 addr;
-};
-
-struct nvif_vmm_put_v0 {
-	__u8  version;
-	__u8  pad01[7];
-	__u64 addr;
-};
-
 struct nvif_vmm_map_v0 {
 	__u8  version;
 	__u8  pad01[7];
diff --git a/drivers/gpu/drm/nouveau/include/nvif/vmm.h b/drivers/gpu/drm/nouveau/include/nvif/vmm.h
index 3019ddc98782..375d19345482 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/vmm.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/vmm.h
@@ -1,16 +1,10 @@
 #ifndef __NVIF_VMM_H__
 #define __NVIF_VMM_H__
 #include <nvif/object.h>
-#include <nvif/driverif.h> /* NVIF_VMM_TYPE */
+#include <nvif/driverif.h> /* NVIF_VMM_TYPE_*, NVIF_VMM_GET_* */
 struct nvif_mem;
 struct nvif_mmu;
 
-enum nvif_vmm_get {
-	ADDR,
-	PTES,
-	LAZY
-};
-
 struct nvif_vma {
 	u64 addr;
 	u64 size;
@@ -26,7 +20,7 @@ int nvif_vmm_ctor(struct nvif_mmu *, const char *name,
 		  enum nvif_vmm_type, u64 addr, u64 size, void *argv, u32 argc,
 		  struct nvif_vmm *);
 void nvif_vmm_dtor(struct nvif_vmm *);
-int nvif_vmm_get(struct nvif_vmm *, enum nvif_vmm_get, bool sparse,
+int nvif_vmm_get(struct nvif_vmm *, enum nvif_vmm_get_type, bool sparse,
 		 u8 page, u8 align, u64 size, struct nvif_vma *);
 void nvif_vmm_put(struct nvif_vmm *, struct nvif_vma *);
 int nvif_vmm_map(struct nvif_vmm *, u64 addr, u64 size, void *argv, u32 argc,
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
index ed81872e2dba..7db05d6699d8 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -835,12 +835,12 @@ nouveau_bo_move_prep(struct nouveau_drm *drm, struct ttm_buffer_object *bo,
 	struct nvif_vmm *vmm = &drm->client.vmm.vmm;
 	int ret;
 
-	ret = nvif_vmm_get(vmm, LAZY, false, old_mem->mem.impl->page, 0,
+	ret = nvif_vmm_get(vmm, NVIF_VMM_GET_LAZY, false, old_mem->mem.impl->page, 0,
 			   old_mem->mem.impl->size, &old_mem->vma[0]);
 	if (ret)
 		return ret;
 
-	ret = nvif_vmm_get(vmm, LAZY, false, new_mem->mem.impl->page, 0,
+	ret = nvif_vmm_get(vmm, NVIF_VMM_GET_LAZY, false, new_mem->mem.impl->page, 0,
 			   new_mem->mem.impl->size, &old_mem->vma[1]);
 	if (ret)
 		goto done;
diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c
index 2d6f1c97db1c..fc1d6fd94480 100644
--- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
@@ -138,7 +138,7 @@ nv04_gart_manager_new(struct ttm_resource_manager *man,
 
 	mem = nouveau_mem(*res);
 	ttm_resource_init(bo, place, *res);
-	ret = nvif_vmm_get(&drm->cli.vmm.vmm, PTES, false, 12, 0,
+	ret = nvif_vmm_get(&drm->cli.vmm.vmm, NVIF_VMM_GET_PTES, false, 12, 0,
 			   (long)(*res)->size, &mem->vma[0]);
 	if (ret) {
 		nouveau_mem_del(man, *res);
diff --git a/drivers/gpu/drm/nouveau/nouveau_vmm.c b/drivers/gpu/drm/nouveau/nouveau_vmm.c
index 353c1a3f9714..94dd0bf547dc 100644
--- a/drivers/gpu/drm/nouveau/nouveau_vmm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_vmm.c
@@ -98,7 +98,7 @@ nouveau_vma_new(struct nouveau_bo *nvbo, struct nouveau_vmm *vmm,
 
 	if (nvbo->bo.resource->mem_type != TTM_PL_SYSTEM &&
 	    mem->mem.impl->page == nvbo->page) {
-		ret = nvif_vmm_get(&vmm->vmm, LAZY, false, mem->mem.impl->page, 0,
+		ret = nvif_vmm_get(&vmm->vmm, NVIF_VMM_GET_LAZY, false, mem->mem.impl->page, 0,
 				   mem->mem.impl->size, &tmp);
 		if (ret)
 			goto done;
@@ -106,7 +106,7 @@ nouveau_vma_new(struct nouveau_bo *nvbo, struct nouveau_vmm *vmm,
 		vma->addr = tmp.addr;
 		ret = nouveau_vma_map(vma, mem);
 	} else {
-		ret = nvif_vmm_get(&vmm->vmm, PTES, false, mem->mem.impl->page, 0,
+		ret = nvif_vmm_get(&vmm->vmm, NVIF_VMM_GET_PTES, false, mem->mem.impl->page, 0,
 				   mem->mem.impl->size, &tmp);
 		if (ret)
 			goto done;
diff --git a/drivers/gpu/drm/nouveau/nvif/vmm.c b/drivers/gpu/drm/nouveau/nvif/vmm.c
index 73c63bfd1e38..cf00e7af6063 100644
--- a/drivers/gpu/drm/nouveau/nvif/vmm.c
+++ b/drivers/gpu/drm/nouveau/nvif/vmm.c
@@ -66,44 +66,26 @@ nvif_vmm_map(struct nvif_vmm *vmm, u64 addr, u64 size, void *argv, u32 argc,
 void
 nvif_vmm_put(struct nvif_vmm *vmm, struct nvif_vma *vma)
 {
-	if (vma->size) {
-		WARN_ON(nvif_object_mthd(&vmm->object, NVIF_VMM_V0_PUT,
-					 &(struct nvif_vmm_put_v0) {
-						.addr = vma->addr,
-					 }, sizeof(struct nvif_vmm_put_v0)));
+	if (vmm && vma->size) {
+		WARN_ON(vmm->impl->put(vmm->priv, vma->addr));
 		vma->size = 0;
 	}
 }
 
 int
-nvif_vmm_get(struct nvif_vmm *vmm, enum nvif_vmm_get type, bool sparse,
+nvif_vmm_get(struct nvif_vmm *vmm, enum nvif_vmm_get_type type, bool sparse,
 	     u8 page, u8 align, u64 size, struct nvif_vma *vma)
 {
-	struct nvif_vmm_get_v0 args;
 	int ret;
 
-	args.version = vma->size = 0;
-	args.sparse = sparse;
-	args.page = page;
-	args.align = align;
-	args.size = size;
-
-	switch (type) {
-	case ADDR: args.type = NVIF_VMM_GET_V0_ADDR; break;
-	case PTES: args.type = NVIF_VMM_GET_V0_PTES; break;
-	case LAZY: args.type = NVIF_VMM_GET_V0_LAZY; break;
-	default:
-		WARN_ON(1);
-		return -EINVAL;
-	}
+	vma->size = 0;
 
-	ret = nvif_object_mthd(&vmm->object, NVIF_VMM_V0_GET,
-			       &args, sizeof(args));
-	if (ret == 0) {
-		vma->addr = args.addr;
-		vma->size = args.size;
-	}
-	return ret;
+	ret = vmm->impl->get(vmm->priv, type, sparse, page, align, size, &vma->addr);
+	if (ret)
+		return ret;
+
+	vma->size = size;
+	return 0;
 }
 
 int
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c
index 15aa6a37060b..066e068589eb 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c
@@ -238,23 +238,14 @@ nvkm_uvmm_mthd_map(struct nvkm_uvmm *uvmm, void *argv, u32 argc)
 }
 
 static int
-nvkm_uvmm_mthd_put(struct nvkm_uvmm *uvmm, void *argv, u32 argc)
+nvkm_uvmm_put(struct nvif_vmm_priv *uvmm, u64 addr)
 {
-	union {
-		struct nvif_vmm_put_v0 v0;
-	} *args = argv;
 	struct nvkm_vmm *vmm = uvmm->vmm;
 	struct nvkm_vma *vma;
-	int ret = -ENOSYS;
-	u64 addr;
-
-	if (!(ret = nvif_unpack(ret, &argv, &argc, args->v0, 0, 0, false))) {
-		addr = args->v0.addr;
-	} else
-		return ret;
+	int ret;
 
 	mutex_lock(&vmm->mutex.vmm);
-	vma = nvkm_vmm_node_search(vmm, args->v0.addr);
+	vma = nvkm_vmm_node_search(vmm, addr);
 	if (ret = -ENOENT, !vma || vma->addr != addr || vma->part) {
 		VMM_DEBUG(vmm, "lookup %016llx: %016llx %d", addr,
 			  vma ? vma->addr : ~0ULL, vma ? vma->part : 0);
@@ -274,27 +265,14 @@ nvkm_uvmm_mthd_put(struct nvkm_uvmm *uvmm, void *argv, u32 argc)
 }
 
 static int
-nvkm_uvmm_mthd_get(struct nvkm_uvmm *uvmm, void *argv, u32 argc)
+nvkm_uvmm_get(struct nvif_vmm_priv *uvmm, enum nvif_vmm_get_type type, bool sparse,
+	      u8 page, u8 align, u64 size, u64 *addr)
 {
-	union {
-		struct nvif_vmm_get_v0 v0;
-	} *args = argv;
 	struct nvkm_vmm *vmm = uvmm->vmm;
 	struct nvkm_vma *vma;
-	int ret = -ENOSYS;
-	bool getref, mapref, sparse;
-	u8 page, align;
-	u64 size;
-
-	if (!(ret = nvif_unpack(ret, &argv, &argc, args->v0, 0, 0, false))) {
-		getref = args->v0.type == NVIF_VMM_GET_V0_PTES;
-		mapref = args->v0.type == NVIF_VMM_GET_V0_ADDR;
-		sparse = args->v0.sparse;
-		page = args->v0.page;
-		align = args->v0.align;
-		size = args->v0.size;
-	} else
-		return ret;
+	bool getref = type == NVIF_VMM_GET_PTES;
+	bool mapref = type == NVIF_VMM_GET_ADDR;
+	int ret;
 
 	mutex_lock(&vmm->mutex.vmm);
 	ret = nvkm_vmm_get_locked(vmm, getref, mapref, sparse,
@@ -303,8 +281,8 @@ nvkm_uvmm_mthd_get(struct nvkm_uvmm *uvmm, void *argv, u32 argc)
 	if (ret)
 		return ret;
 
-	args->v0.addr = vma->addr;
-	return ret;
+	*addr = vma->addr;
+	return 0;
 }
 
 static inline int
@@ -474,8 +452,6 @@ nvkm_uvmm_mthd(struct nvkm_object *object, u32 mthd, void *argv, u32 argc)
 {
 	struct nvif_vmm_priv *uvmm = container_of(object, typeof(*uvmm), object);
 	switch (mthd) {
-	case NVIF_VMM_V0_GET   : return nvkm_uvmm_mthd_get   (uvmm, argv, argc);
-	case NVIF_VMM_V0_PUT   : return nvkm_uvmm_mthd_put   (uvmm, argv, argc);
 	case NVIF_VMM_V0_MAP   : return nvkm_uvmm_mthd_map   (uvmm, argv, argc);
 	case NVIF_VMM_V0_UNMAP : return nvkm_uvmm_mthd_unmap (uvmm, argv, argc);
 	case NVIF_VMM_V0_PFNMAP: return nvkm_uvmm_mthd_pfnmap(uvmm, argv, argc);
@@ -505,6 +481,8 @@ nvkm_uvmm_del(struct nvif_vmm_priv *uvmm)
 static const struct nvif_vmm_impl
 nvkm_uvmm_impl = {
 	.del = nvkm_uvmm_del,
+	.get = nvkm_uvmm_get,
+	.put = nvkm_uvmm_put,
 };
 
 static void *
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 089/156] drm/nouveau/nvif: rework vmm "map"/"unmap" apis
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (87 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 088/156] drm/nouveau/nvif: rework vmm "get"/"put" apis Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 090/156] drm/nouveau/nvif: rework vmm "pfnmap"/"pfnclr" apis Ben Skeggs
                   ` (68 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interfaces

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  4 ++
 drivers/gpu/drm/nouveau/include/nvif/if000c.h | 18 --------
 drivers/gpu/drm/nouveau/nvif/vmm.c            | 28 +------------
 .../gpu/drm/nouveau/nvkm/subdev/mmu/umem.c    |  9 ++++
 .../gpu/drm/nouveau/nvkm/subdev/mmu/umem.h    |  1 +
 .../gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c    | 41 ++++---------------
 6 files changed, 24 insertions(+), 77 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 673969d46b66..94d0fb23ed2f 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -119,6 +119,10 @@ struct nvif_vmm_impl {
 	int (*get)(struct nvif_vmm_priv *, enum nvif_vmm_get_type, bool sparse, u8 page,
 		   u8 align, u64 size, u64 *addr);
 	int (*put)(struct nvif_vmm_priv *, u64 addr);
+
+	int (*map)(struct nvif_vmm_priv *, u64 addr, u64 size, void *, u32,
+		   struct nvif_mem_priv *, u64 offset);
+	int (*unmap)(struct nvif_vmm_priv *, u64 addr);
 };
 
 struct nvif_mmu_impl {
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if000c.h b/drivers/gpu/drm/nouveau/include/nvif/if000c.h
index 50a834d5eb19..9b979fa5c7ac 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/if000c.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/if000c.h
@@ -1,29 +1,11 @@
 #ifndef __NVIF_IF000C_H__
 #define __NVIF_IF000C_H__
 
-#define NVIF_VMM_V0_MAP                                                    0x03
-#define NVIF_VMM_V0_UNMAP                                                  0x04
 #define NVIF_VMM_V0_PFNMAP                                                 0x05
 #define NVIF_VMM_V0_PFNCLR                                                 0x06
 #define NVIF_VMM_V0_RAW                                                    0x07
 #define NVIF_VMM_V0_MTHD(i)                                         ((i) + 0x80)
 
-struct nvif_vmm_map_v0 {
-	__u8  version;
-	__u8  pad01[7];
-	__u64 addr;
-	__u64 size;
-	__u64 memory;
-	__u64 offset;
-	__u8  data[];
-};
-
-struct nvif_vmm_unmap_v0 {
-	__u8  version;
-	__u8  pad01[7];
-	__u64 addr;
-};
-
 struct nvif_vmm_raw_v0 {
 	__u8 version;
 #define NVIF_VMM_RAW_V0_GET	0x0
diff --git a/drivers/gpu/drm/nouveau/nvif/vmm.c b/drivers/gpu/drm/nouveau/nvif/vmm.c
index cf00e7af6063..6821d8657e12 100644
--- a/drivers/gpu/drm/nouveau/nvif/vmm.c
+++ b/drivers/gpu/drm/nouveau/nvif/vmm.c
@@ -29,38 +29,14 @@
 int
 nvif_vmm_unmap(struct nvif_vmm *vmm, u64 addr)
 {
-	return nvif_object_mthd(&vmm->object, NVIF_VMM_V0_UNMAP,
-				&(struct nvif_vmm_unmap_v0) { .addr = addr },
-				sizeof(struct nvif_vmm_unmap_v0));
+	return vmm->impl->unmap(vmm->priv, addr);
 }
 
 int
 nvif_vmm_map(struct nvif_vmm *vmm, u64 addr, u64 size, void *argv, u32 argc,
 	     struct nvif_mem *mem, u64 offset)
 {
-	struct nvif_vmm_map_v0 *args;
-	u8 stack[48];
-	int ret;
-
-	if (sizeof(*args) + argc > sizeof(stack)) {
-		if (!(args = kmalloc(sizeof(*args) + argc, GFP_KERNEL)))
-			return -ENOMEM;
-	} else {
-		args = (void *)stack;
-	}
-
-	args->version = 0;
-	args->addr = addr;
-	args->size = size;
-	args->memory = nvif_handle(&mem->object);
-	args->offset = offset;
-	memcpy(args->data, argv, argc);
-
-	ret = nvif_object_mthd(&vmm->object, NVIF_VMM_V0_MAP,
-			       args, sizeof(*args) + argc);
-	if (args != (void *)stack)
-		kfree(args);
-	return ret;
+	return vmm->impl->map(vmm->priv, addr, size, argv, argc, mem->priv, offset);
 }
 
 void
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.c
index 6756e3e207d9..0676615093bb 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.c
@@ -48,6 +48,15 @@ struct nvif_mem_priv {
 	struct nvif_mem_impl impl;
 };
 
+struct nvkm_memory *
+nvkm_umem_ref(struct nvif_mem_priv *umem)
+{
+	if (umem)
+		return nvkm_memory_ref(umem->memory);
+
+	return NULL;
+}
+
 static const struct nvkm_object_func nvkm_umem;
 struct nvkm_memory *
 nvkm_umem_search(struct nvkm_mmu *mmu, struct nvkm_client *client, u64 handle)
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.h b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.h
index df7017eb98f4..a548a578758f 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.h
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.h
@@ -5,4 +5,5 @@
 
 int nvkm_umem_new(struct nvkm_mmu *, u8 type, u8 page, u64 size, void *, u32,
 		  const struct nvif_mem_impl **, struct nvif_mem_priv **, struct nvkm_object **);
+struct nvkm_memory *nvkm_umem_ref(struct nvif_mem_priv *);
 #endif
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c
index 066e068589eb..dae965fe2977 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c
@@ -113,20 +113,11 @@ nvkm_uvmm_mthd_pfnmap(struct nvkm_uvmm *uvmm, void *argv, u32 argc)
 }
 
 static int
-nvkm_uvmm_mthd_unmap(struct nvkm_uvmm *uvmm, void *argv, u32 argc)
+nvkm_uvmm_unmap(struct nvif_vmm_priv *uvmm, u64 addr)
 {
-	union {
-		struct nvif_vmm_unmap_v0 v0;
-	} *args = argv;
 	struct nvkm_vmm *vmm = uvmm->vmm;
 	struct nvkm_vma *vma;
-	int ret = -ENOSYS;
-	u64 addr;
-
-	if (!(ret = nvif_unpack(ret, &argv, &argc, args->v0, 0, 0, false))) {
-		addr = args->v0.addr;
-	} else
-		return ret;
+	int ret;
 
 	if (nvkm_vmm_in_managed_range(vmm, addr, 0) && vmm->managed.raw)
 		return -EINVAL;
@@ -157,34 +148,18 @@ nvkm_uvmm_mthd_unmap(struct nvkm_uvmm *uvmm, void *argv, u32 argc)
 }
 
 static int
-nvkm_uvmm_mthd_map(struct nvkm_uvmm *uvmm, void *argv, u32 argc)
+nvkm_uvmm_map(struct nvif_vmm_priv *uvmm, u64 addr, u64 size, void *argv, u32 argc,
+	      struct nvif_mem_priv *mem, u64 offset)
 {
-	struct nvkm_client *client = uvmm->object.client;
-	union {
-		struct nvif_vmm_map_v0 v0;
-	} *args = argv;
-	u64 addr, size, handle, offset;
 	struct nvkm_vmm *vmm = uvmm->vmm;
 	struct nvkm_vma *vma;
 	struct nvkm_memory *memory;
-	int ret = -ENOSYS;
-
-	if (!(ret = nvif_unpack(ret, &argv, &argc, args->v0, 0, 0, true))) {
-		addr = args->v0.addr;
-		size = args->v0.size;
-		handle = args->v0.memory;
-		offset = args->v0.offset;
-	} else
-		return ret;
+	int ret;
 
 	if (nvkm_vmm_in_managed_range(vmm, addr, size) && vmm->managed.raw)
 		return -EINVAL;
 
-	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);
-	}
+	memory = nvkm_umem_ref(mem);
 
 	mutex_lock(&vmm->mutex.vmm);
 	if (ret = -ENOENT, !(vma = nvkm_vmm_node_search(vmm, addr))) {
@@ -452,8 +427,6 @@ nvkm_uvmm_mthd(struct nvkm_object *object, u32 mthd, void *argv, u32 argc)
 {
 	struct nvif_vmm_priv *uvmm = container_of(object, typeof(*uvmm), object);
 	switch (mthd) {
-	case NVIF_VMM_V0_MAP   : return nvkm_uvmm_mthd_map   (uvmm, argv, argc);
-	case NVIF_VMM_V0_UNMAP : return nvkm_uvmm_mthd_unmap (uvmm, argv, argc);
 	case NVIF_VMM_V0_PFNMAP: return nvkm_uvmm_mthd_pfnmap(uvmm, argv, argc);
 	case NVIF_VMM_V0_PFNCLR: return nvkm_uvmm_mthd_pfnclr(uvmm, argv, argc);
 	case NVIF_VMM_V0_RAW   : return nvkm_uvmm_mthd_raw   (uvmm, argv, argc);
@@ -483,6 +456,8 @@ nvkm_uvmm_impl = {
 	.del = nvkm_uvmm_del,
 	.get = nvkm_uvmm_get,
 	.put = nvkm_uvmm_put,
+	.map = nvkm_uvmm_map,
+	.unmap = nvkm_uvmm_unmap,
 };
 
 static void *
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 090/156] drm/nouveau/nvif: rework vmm "pfnmap"/"pfnclr" apis
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (88 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 089/156] drm/nouveau/nvif: rework vmm "map"/"unmap" apis Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 091/156] drm/nouveau/nvif: rework vmm "raw get"/"raw put" apis Ben Skeggs
                   ` (67 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interfaces

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 .../gpu/drm/nouveau/include/nvif/driverif.h   | 12 ++++
 drivers/gpu/drm/nouveau/include/nvif/if000c.h | 27 --------
 drivers/gpu/drm/nouveau/nouveau_dmem.c        |  8 +--
 drivers/gpu/drm/nouveau/nouveau_svm.c         | 64 ++++++++-----------
 .../gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c    | 37 ++---------
 5 files changed, 50 insertions(+), 98 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 94d0fb23ed2f..afca57d53c8c 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -123,6 +123,18 @@ struct nvif_vmm_impl {
 	int (*map)(struct nvif_vmm_priv *, u64 addr, u64 size, void *, u32,
 		   struct nvif_mem_priv *, u64 offset);
 	int (*unmap)(struct nvif_vmm_priv *, u64 addr);
+
+#define NVIF_VMM_PFNMAP_ADDR       0xfffffffffffff000ULL
+#define NVIF_VMM_PFNMAP_ADDR_SHIFT                    12
+#define NVIF_VMM_PFNMAP_APER       0x00000000000000f0ULL
+#define NVIF_VMM_PFNMAP_HOST       0x0000000000000000ULL
+#define NVIF_VMM_PFNMAP_VRAM       0x0000000000000010ULL
+#define NVIF_VMM_PFNMAP_A          0x0000000000000004ULL
+#define NVIF_VMM_PFNMAP_W          0x0000000000000002ULL
+#define NVIF_VMM_PFNMAP_V          0x0000000000000001ULL
+#define NVIF_VMM_PFNMAP_NONE       0x0000000000000000ULL
+	int (*pfnmap)(struct nvif_vmm_priv *, u8 page, u64 addr, u64 size, u64 *phys);
+	int (*pfnclr)(struct nvif_vmm_priv *, u64 addr, u64 size);
 };
 
 struct nvif_mmu_impl {
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if000c.h b/drivers/gpu/drm/nouveau/include/nvif/if000c.h
index 9b979fa5c7ac..709837ffea4e 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/if000c.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/if000c.h
@@ -1,8 +1,6 @@
 #ifndef __NVIF_IF000C_H__
 #define __NVIF_IF000C_H__
 
-#define NVIF_VMM_V0_PFNMAP                                                 0x05
-#define NVIF_VMM_V0_PFNCLR                                                 0x06
 #define NVIF_VMM_V0_RAW                                                    0x07
 #define NVIF_VMM_V0_MTHD(i)                                         ((i) + 0x80)
 
@@ -25,29 +23,4 @@ struct nvif_vmm_raw_v0 {
 	__u64 memory;
 	__u64 argv;
 };
-
-struct nvif_vmm_pfnmap_v0 {
-	__u8  version;
-	__u8  page;
-	__u8  pad02[6];
-	__u64 addr;
-	__u64 size;
-#define NVIF_VMM_PFNMAP_V0_ADDR                           0xfffffffffffff000ULL
-#define NVIF_VMM_PFNMAP_V0_ADDR_SHIFT                                        12
-#define NVIF_VMM_PFNMAP_V0_APER                           0x00000000000000f0ULL
-#define NVIF_VMM_PFNMAP_V0_HOST                           0x0000000000000000ULL
-#define NVIF_VMM_PFNMAP_V0_VRAM                           0x0000000000000010ULL
-#define NVIF_VMM_PFNMAP_V0_A				  0x0000000000000004ULL
-#define NVIF_VMM_PFNMAP_V0_W                              0x0000000000000002ULL
-#define NVIF_VMM_PFNMAP_V0_V                              0x0000000000000001ULL
-#define NVIF_VMM_PFNMAP_V0_NONE                           0x0000000000000000ULL
-	__u64 phys[];
-};
-
-struct nvif_vmm_pfnclr_v0 {
-	__u8  version;
-	__u8  pad01[7];
-	__u64 addr;
-	__u64 size;
-};
 #endif
diff --git a/drivers/gpu/drm/nouveau/nouveau_dmem.c b/drivers/gpu/drm/nouveau/nouveau_dmem.c
index b2f20e33bf66..a2369841353d 100644
--- a/drivers/gpu/drm/nouveau/nouveau_dmem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_dmem.c
@@ -645,10 +645,10 @@ static unsigned long nouveau_dmem_migrate_copy_one(struct nouveau_drm *drm,
 	}
 
 	dpage->zone_device_data = svmm;
-	*pfn = NVIF_VMM_PFNMAP_V0_V | NVIF_VMM_PFNMAP_V0_VRAM |
-		((paddr >> PAGE_SHIFT) << NVIF_VMM_PFNMAP_V0_ADDR_SHIFT);
+	*pfn = NVIF_VMM_PFNMAP_V | NVIF_VMM_PFNMAP_VRAM |
+		((paddr >> PAGE_SHIFT) << NVIF_VMM_PFNMAP_ADDR_SHIFT);
 	if (src & MIGRATE_PFN_WRITE)
-		*pfn |= NVIF_VMM_PFNMAP_V0_W;
+		*pfn |= NVIF_VMM_PFNMAP_W;
 	return migrate_pfn(page_to_pfn(dpage));
 
 out_dma_unmap:
@@ -656,7 +656,7 @@ static unsigned long nouveau_dmem_migrate_copy_one(struct nouveau_drm *drm,
 out_free_page:
 	nouveau_dmem_page_free_locked(drm, dpage);
 out:
-	*pfn = NVIF_VMM_PFNMAP_V0_NONE;
+	*pfn = NVIF_VMM_PFNMAP_NONE;
 	return 0;
 }
 
diff --git a/drivers/gpu/drm/nouveau/nouveau_svm.c b/drivers/gpu/drm/nouveau/nouveau_svm.c
index cf5dfbe63e69..ab02bcc034fb 100644
--- a/drivers/gpu/drm/nouveau/nouveau_svm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_svm.c
@@ -79,9 +79,12 @@ struct nouveau_svm {
 #define SVM_ERR(s,f,a...) NV_WARN((s)->drm, "svm: "f"\n", ##a)
 
 struct nouveau_pfnmap_args {
-	struct nvif_ioctl_v0 i;
-	struct nvif_ioctl_mthd_v0 m;
-	struct nvif_vmm_pfnmap_v0 p;
+	struct {
+		u8 page;
+		u64 addr;
+		u64 size;
+		u64 phys[];
+	} p;
 };
 
 struct nouveau_ivmm {
@@ -239,13 +242,10 @@ nouveau_svmm_join(struct nouveau_svmm *svmm, u64 inst)
 void
 nouveau_svmm_invalidate(struct nouveau_svmm *svmm, u64 start, u64 limit)
 {
-	if (limit > start) {
-		nvif_object_mthd(&svmm->vmm->vmm.object, NVIF_VMM_V0_PFNCLR,
-				 &(struct nvif_vmm_pfnclr_v0) {
-					.addr = start,
-					.size = limit - start,
-				 }, sizeof(struct nvif_vmm_pfnclr_v0));
-	}
+	struct nvif_vmm *vmm = &svmm->vmm->vmm;
+
+	if (limit > start)
+		vmm->impl->pfnclr(vmm->priv, start, limit - start);
 }
 
 static int
@@ -571,14 +571,14 @@ static void nouveau_hmm_convert_pfn(struct nouveau_drm *drm,
 	}
 	if (is_device_private_page(page))
 		args->p.phys[0] = nouveau_dmem_page_addr(page) |
-				NVIF_VMM_PFNMAP_V0_V |
-				NVIF_VMM_PFNMAP_V0_VRAM;
+				NVIF_VMM_PFNMAP_V |
+				NVIF_VMM_PFNMAP_VRAM;
 	else
 		args->p.phys[0] = page_to_phys(page) |
-				NVIF_VMM_PFNMAP_V0_V |
-				NVIF_VMM_PFNMAP_V0_HOST;
+				NVIF_VMM_PFNMAP_V |
+				NVIF_VMM_PFNMAP_HOST;
 	if (range->hmm_pfns[0] & HMM_PFN_WRITE)
-		args->p.phys[0] |= NVIF_VMM_PFNMAP_V0_W;
+		args->p.phys[0] |= NVIF_VMM_PFNMAP_W;
 }
 
 static int nouveau_atomic_range_fault(struct nouveau_svmm *svmm,
@@ -592,6 +592,7 @@ static int nouveau_atomic_range_fault(struct nouveau_svmm *svmm,
 	struct page *page;
 	unsigned long start = args->p.addr;
 	unsigned long notifier_seq;
+	struct nvif_vmm *vmm = &svmm->vmm->vmm;
 	int ret = 0;
 
 	ret = mmu_interval_notifier_insert(&notifier->notifier, mm,
@@ -628,12 +629,12 @@ static int nouveau_atomic_range_fault(struct nouveau_svmm *svmm,
 	args->p.size = PAGE_SIZE;
 	args->p.addr = start;
 	args->p.phys[0] = page_to_phys(page) |
-		NVIF_VMM_PFNMAP_V0_V |
-		NVIF_VMM_PFNMAP_V0_W |
-		NVIF_VMM_PFNMAP_V0_A |
-		NVIF_VMM_PFNMAP_V0_HOST;
+		NVIF_VMM_PFNMAP_V |
+		NVIF_VMM_PFNMAP_W |
+		NVIF_VMM_PFNMAP_A |
+		NVIF_VMM_PFNMAP_HOST;
 
-	ret = nvif_object_ioctl(&svmm->vmm->vmm.object, args, size, NULL);
+	ret = vmm->impl->pfnmap(vmm->priv, args->p.page, args->p.size, args->p.addr, args->p.phys);
 	mutex_unlock(&svmm->mutex);
 
 	unlock_page(page);
@@ -661,6 +662,7 @@ static int nouveau_range_fault(struct nouveau_svmm *svmm,
 		.dev_private_owner = drm->dev,
 	};
 	struct mm_struct *mm = svmm->notifier.mm;
+	struct nvif_vmm *vmm = &svmm->vmm->vmm;
 	int ret;
 
 	ret = mmu_interval_notifier_insert(&notifier->notifier, mm,
@@ -699,7 +701,7 @@ static int nouveau_range_fault(struct nouveau_svmm *svmm,
 
 	nouveau_hmm_convert_pfn(drm, &range, args);
 
-	ret = nvif_object_ioctl(&svmm->vmm->vmm.object, args, size, NULL);
+	ret = vmm->impl->pfnmap(vmm->priv, args->p.page, args->p.addr, args->p.size, args->p.phys);
 	mutex_unlock(&svmm->mutex);
 
 out:
@@ -767,12 +769,6 @@ nouveau_svm_fault(struct work_struct *work)
 	mutex_unlock(&svm->mutex);
 
 	/* Process list of faults. */
-	args.i.i.version = 0;
-	args.i.i.type = NVIF_IOCTL_V0_MTHD;
-	args.i.m.version = 0;
-	args.i.m.method = NVIF_VMM_V0_PFNMAP;
-	args.i.p.version = 0;
-
 	for (fi = 0; fn = fi + 1, fi < buffer->fault_nr; fi = fn) {
 		struct svm_notifier notifier;
 		struct mm_struct *mm;
@@ -850,14 +846,14 @@ nouveau_svm_fault(struct work_struct *work)
 			if (buffer->fault[fn]->svmm != svmm ||
 			    buffer->fault[fn]->addr >= limit ||
 			    (buffer->fault[fi]->access == FAULT_ACCESS_READ &&
-			     !(args.phys[0] & NVIF_VMM_PFNMAP_V0_V)) ||
+			     !(args.phys[0] & NVIF_VMM_PFNMAP_V)) ||
 			    (buffer->fault[fi]->access != FAULT_ACCESS_READ &&
 			     buffer->fault[fi]->access != FAULT_ACCESS_PREFETCH &&
-			     !(args.phys[0] & NVIF_VMM_PFNMAP_V0_W)) ||
+			     !(args.phys[0] & NVIF_VMM_PFNMAP_W)) ||
 			    (buffer->fault[fi]->access != FAULT_ACCESS_READ &&
 			     buffer->fault[fi]->access != FAULT_ACCESS_WRITE &&
 			     buffer->fault[fi]->access != FAULT_ACCESS_PREFETCH &&
-			     !(args.phys[0] & NVIF_VMM_PFNMAP_V0_A)))
+			     !(args.phys[0] & NVIF_VMM_PFNMAP_A)))
 				break;
 		}
 
@@ -902,8 +898,6 @@ nouveau_pfns_alloc(unsigned long npages)
 	if (!args)
 		return NULL;
 
-	args->i.type = NVIF_IOCTL_V0_MTHD;
-	args->m.method = NVIF_VMM_V0_PFNMAP;
 	args->p.page = PAGE_SHIFT;
 
 	return args->p.phys;
@@ -922,15 +916,13 @@ nouveau_pfns_map(struct nouveau_svmm *svmm, struct mm_struct *mm,
 		 unsigned long addr, u64 *pfns, unsigned long npages)
 {
 	struct nouveau_pfnmap_args *args = nouveau_pfns_to_args(pfns);
+	struct nvif_vmm *vmm = &svmm->vmm->vmm;
 
 	args->p.addr = addr;
 	args->p.size = npages << PAGE_SHIFT;
 
 	mutex_lock(&svmm->mutex);
-
-	nvif_object_ioctl(&svmm->vmm->vmm.object, args,
-			  struct_size(args, p.phys, npages), NULL);
-
+	vmm->impl->pfnmap(vmm->priv, args->p.page, args->p.addr, args->p.size, args->p.phys);
 	mutex_unlock(&svmm->mutex);
 }
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c
index dae965fe2977..b1bd1dd3d5dd 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c
@@ -52,20 +52,10 @@ nvkm_uvmm_search(struct nvkm_client *client, u64 handle)
 }
 
 static int
-nvkm_uvmm_mthd_pfnclr(struct nvkm_uvmm *uvmm, void *argv, u32 argc)
+nvkm_uvmm_pfnclr(struct nvif_vmm_priv *uvmm, u64 addr, u64 size)
 {
-	union {
-		struct nvif_vmm_pfnclr_v0 v0;
-	} *args = argv;
 	struct nvkm_vmm *vmm = uvmm->vmm;
-	int ret = -ENOSYS;
-	u64 addr, size;
-
-	if (!(ret = nvif_unpack(ret, &argv, &argc, args->v0, 0, 0, false))) {
-		addr = args->v0.addr;
-		size = args->v0.size;
-	} else
-		return ret;
+	int ret;
 
 	if (nvkm_vmm_in_managed_range(vmm, addr, size) && vmm->managed.raw)
 		return -EINVAL;
@@ -80,25 +70,10 @@ nvkm_uvmm_mthd_pfnclr(struct nvkm_uvmm *uvmm, void *argv, u32 argc)
 }
 
 static int
-nvkm_uvmm_mthd_pfnmap(struct nvkm_uvmm *uvmm, void *argv, u32 argc)
+nvkm_uvmm_pfnmap(struct nvif_vmm_priv *uvmm, u8 page, u64 addr, u64 size, u64 *phys)
 {
-	union {
-		struct nvif_vmm_pfnmap_v0 v0;
-	} *args = argv;
 	struct nvkm_vmm *vmm = uvmm->vmm;
-	int ret = -ENOSYS;
-	u64 addr, size, *phys;
-	u8  page;
-
-	if (!(ret = nvif_unpack(ret, &argv, &argc, args->v0, 0, 0, true))) {
-		page = args->v0.page;
-		addr = args->v0.addr;
-		size = args->v0.size;
-		phys = args->v0.phys;
-		if (argc != (size >> page) * sizeof(args->v0.phys[0]))
-			return -EINVAL;
-	} else
-		return ret;
+	int ret;
 
 	if (nvkm_vmm_in_managed_range(vmm, addr, size) && vmm->managed.raw)
 		return -EINVAL;
@@ -427,8 +402,6 @@ nvkm_uvmm_mthd(struct nvkm_object *object, u32 mthd, void *argv, u32 argc)
 {
 	struct nvif_vmm_priv *uvmm = container_of(object, typeof(*uvmm), object);
 	switch (mthd) {
-	case NVIF_VMM_V0_PFNMAP: return nvkm_uvmm_mthd_pfnmap(uvmm, argv, argc);
-	case NVIF_VMM_V0_PFNCLR: return nvkm_uvmm_mthd_pfnclr(uvmm, argv, argc);
 	case NVIF_VMM_V0_RAW   : return nvkm_uvmm_mthd_raw   (uvmm, argv, argc);
 	case NVIF_VMM_V0_MTHD(0x00) ... NVIF_VMM_V0_MTHD(0x7f):
 		if (uvmm->vmm->func->mthd) {
@@ -458,6 +431,8 @@ nvkm_uvmm_impl = {
 	.put = nvkm_uvmm_put,
 	.map = nvkm_uvmm_map,
 	.unmap = nvkm_uvmm_unmap,
+	.pfnmap = nvkm_uvmm_pfnmap,
+	.pfnclr = nvkm_uvmm_pfnclr,
 };
 
 static void *
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 091/156] drm/nouveau/nvif: rework vmm "raw get"/"raw put" apis
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (89 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 090/156] drm/nouveau/nvif: rework vmm "pfnmap"/"pfnclr" apis Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 092/156] drm/nouveau/nvif: rework vmm "raw map"/"raw unmap" apis Ben Skeggs
                   ` (66 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from ioctl interfaces

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  5 +++++
 drivers/gpu/drm/nouveau/include/nvif/if000c.h |  2 --
 drivers/gpu/drm/nouveau/nvif/vmm.c            | 22 ++-----------------
 .../gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c    | 22 +++++++++----------
 4 files changed, 17 insertions(+), 34 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index afca57d53c8c..65958649f08c 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -135,6 +135,11 @@ struct nvif_vmm_impl {
 #define NVIF_VMM_PFNMAP_NONE       0x0000000000000000ULL
 	int (*pfnmap)(struct nvif_vmm_priv *, u8 page, u64 addr, u64 size, u64 *phys);
 	int (*pfnclr)(struct nvif_vmm_priv *, u64 addr, u64 size);
+
+	struct {
+		int (*get)(struct nvif_vmm_priv *, u8 shift, u64 addr, u64 size);
+		int (*put)(struct nvif_vmm_priv *, u8 shift, u64 addr, u64 size);
+	} raw;
 };
 
 struct nvif_mmu_impl {
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if000c.h b/drivers/gpu/drm/nouveau/include/nvif/if000c.h
index 709837ffea4e..c81fae28395a 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/if000c.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/if000c.h
@@ -6,8 +6,6 @@
 
 struct nvif_vmm_raw_v0 {
 	__u8 version;
-#define NVIF_VMM_RAW_V0_GET	0x0
-#define NVIF_VMM_RAW_V0_PUT	0x1
 #define NVIF_VMM_RAW_V0_MAP	0x2
 #define NVIF_VMM_RAW_V0_UNMAP	0x3
 #define NVIF_VMM_RAW_V0_SPARSE	0x4
diff --git a/drivers/gpu/drm/nouveau/nvif/vmm.c b/drivers/gpu/drm/nouveau/nvif/vmm.c
index 6821d8657e12..d7ca6afaeb04 100644
--- a/drivers/gpu/drm/nouveau/nvif/vmm.c
+++ b/drivers/gpu/drm/nouveau/nvif/vmm.c
@@ -68,31 +68,13 @@ int
 nvif_vmm_raw_get(struct nvif_vmm *vmm, u64 addr, u64 size,
 		 u8 shift)
 {
-	struct nvif_vmm_raw_v0 args = {
-		.version = 0,
-		.op = NVIF_VMM_RAW_V0_GET,
-		.addr = addr,
-		.size = size,
-		.shift = shift,
-	};
-
-	return nvif_object_mthd(&vmm->object, NVIF_VMM_V0_RAW,
-				&args, sizeof(args));
+	return vmm->impl->raw.get(vmm->priv, shift, addr, size);
 }
 
 int
 nvif_vmm_raw_put(struct nvif_vmm *vmm, u64 addr, u64 size, u8 shift)
 {
-	struct nvif_vmm_raw_v0 args = {
-		.version = 0,
-		.op = NVIF_VMM_RAW_V0_PUT,
-		.addr = addr,
-		.size = size,
-		.shift = shift,
-	};
-
-	return nvif_object_mthd(&vmm->object, NVIF_VMM_V0_RAW,
-				&args, sizeof(args));
+	return vmm->impl->raw.put(vmm->priv, shift, addr, size);
 }
 
 int
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c
index b1bd1dd3d5dd..51c7e0fd7876 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c
@@ -260,37 +260,37 @@ nvkm_uvmm_page_index(struct nvif_vmm_priv *uvmm, u64 size, u8 shift, u8 *refd)
 }
 
 static int
-nvkm_uvmm_mthd_raw_get(struct nvkm_uvmm *uvmm, struct nvif_vmm_raw_v0 *args)
+nvkm_uvmm_raw_get(struct nvif_vmm_priv *uvmm, u8 shift, u64 addr, u64 size)
 {
 	struct nvkm_vmm *vmm = uvmm->vmm;
 	u8 refd;
 	int ret;
 
-	if (!nvkm_vmm_in_managed_range(vmm, args->addr, args->size))
+	if (!nvkm_vmm_in_managed_range(vmm, addr, size))
 		return -EINVAL;
 
-	ret = nvkm_uvmm_page_index(uvmm, args->size, args->shift, &refd);
+	ret = nvkm_uvmm_page_index(uvmm, size, shift, &refd);
 	if (ret)
 		return ret;
 
-	return nvkm_vmm_raw_get(vmm, args->addr, args->size, refd);
+	return nvkm_vmm_raw_get(vmm, addr, size, refd);
 }
 
 static int
-nvkm_uvmm_mthd_raw_put(struct nvkm_uvmm *uvmm, struct nvif_vmm_raw_v0 *args)
+nvkm_uvmm_raw_put(struct nvif_vmm_priv *uvmm, u8 shift, u64 addr, u64 size)
 {
 	struct nvkm_vmm *vmm = uvmm->vmm;
 	u8 refd;
 	int ret;
 
-	if (!nvkm_vmm_in_managed_range(vmm, args->addr, args->size))
+	if (!nvkm_vmm_in_managed_range(vmm, addr, size))
 		return -EINVAL;
 
-	ret = nvkm_uvmm_page_index(uvmm, args->size, args->shift, &refd);
+	ret = nvkm_uvmm_page_index(uvmm, size, shift, &refd);
 	if (ret)
 		return ret;
 
-	nvkm_vmm_raw_put(vmm, args->addr, args->size, refd);
+	nvkm_vmm_raw_put(vmm, addr, size, refd);
 
 	return 0;
 }
@@ -382,10 +382,6 @@ nvkm_uvmm_mthd_raw(struct nvkm_uvmm *uvmm, void *argv, u32 argc)
 		return ret;
 
 	switch (args->v0.op) {
-	case NVIF_VMM_RAW_V0_GET:
-		return nvkm_uvmm_mthd_raw_get(uvmm, &args->v0);
-	case NVIF_VMM_RAW_V0_PUT:
-		return nvkm_uvmm_mthd_raw_put(uvmm, &args->v0);
 	case NVIF_VMM_RAW_V0_MAP:
 		return nvkm_uvmm_mthd_raw_map(uvmm, &args->v0);
 	case NVIF_VMM_RAW_V0_UNMAP:
@@ -433,6 +429,8 @@ nvkm_uvmm_impl = {
 	.unmap = nvkm_uvmm_unmap,
 	.pfnmap = nvkm_uvmm_pfnmap,
 	.pfnclr = nvkm_uvmm_pfnclr,
+	.raw.get = nvkm_uvmm_raw_get,
+	.raw.put = nvkm_uvmm_raw_put,
 };
 
 static void *
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 092/156] drm/nouveau/nvif: rework vmm "raw map"/"raw unmap" apis
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (90 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 091/156] drm/nouveau/nvif: rework vmm "raw get"/"raw put" apis Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:38 ` [PATCH 093/156] drm/nouveau/nvif: rework vmm "raw sparse" api Ben Skeggs
                   ` (65 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interfaces

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  3 ++
 drivers/gpu/drm/nouveau/include/nvif/if000c.h |  2 -
 drivers/gpu/drm/nouveau/nvif/vmm.c            | 28 +------------
 .../gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c    | 39 +++++++------------
 4 files changed, 19 insertions(+), 53 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 65958649f08c..1cea0a07b2e8 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -139,6 +139,9 @@ struct nvif_vmm_impl {
 	struct {
 		int (*get)(struct nvif_vmm_priv *, u8 shift, u64 addr, u64 size);
 		int (*put)(struct nvif_vmm_priv *, u8 shift, u64 addr, u64 size);
+		int (*map)(struct nvif_vmm_priv *, u8 shift, u64 addr, u64 size, void *, u32,
+			   struct nvif_mem_priv *, u64 offset);
+		int (*unmap)(struct nvif_vmm_priv *, u8 shift, u64 addr, u64 size, bool sparse);
 	} raw;
 };
 
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if000c.h b/drivers/gpu/drm/nouveau/include/nvif/if000c.h
index c81fae28395a..232cc1142798 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/if000c.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/if000c.h
@@ -6,8 +6,6 @@
 
 struct nvif_vmm_raw_v0 {
 	__u8 version;
-#define NVIF_VMM_RAW_V0_MAP	0x2
-#define NVIF_VMM_RAW_V0_UNMAP	0x3
 #define NVIF_VMM_RAW_V0_SPARSE	0x4
 	__u8  op;
 	__u8  sparse;
diff --git a/drivers/gpu/drm/nouveau/nvif/vmm.c b/drivers/gpu/drm/nouveau/nvif/vmm.c
index d7ca6afaeb04..16c6aaa81326 100644
--- a/drivers/gpu/drm/nouveau/nvif/vmm.c
+++ b/drivers/gpu/drm/nouveau/nvif/vmm.c
@@ -81,38 +81,14 @@ int
 nvif_vmm_raw_map(struct nvif_vmm *vmm, u64 addr, u64 size, u8 shift,
 		 void *argv, u32 argc, struct nvif_mem *mem, u64 offset)
 {
-	struct nvif_vmm_raw_v0 args = {
-		.version = 0,
-		.op = NVIF_VMM_RAW_V0_MAP,
-		.addr = addr,
-		.size = size,
-		.shift = shift,
-		.memory = nvif_handle(&mem->object),
-		.offset = offset,
-		.argv = (u64)(uintptr_t)argv,
-		.argc = argc,
-	};
-
-
-	return nvif_object_mthd(&vmm->object, NVIF_VMM_V0_RAW,
-				&args, sizeof(args));
+	return vmm->impl->raw.map(vmm->priv, shift, addr, size, argv, argc, mem->priv, offset);
 }
 
 int
 nvif_vmm_raw_unmap(struct nvif_vmm *vmm, u64 addr, u64 size,
 		   u8 shift, bool sparse)
 {
-	struct nvif_vmm_raw_v0 args = {
-		.version = 0,
-		.op = NVIF_VMM_RAW_V0_UNMAP,
-		.addr = addr,
-		.size = size,
-		.shift = shift,
-		.sparse = sparse,
-	};
-
-	return nvif_object_mthd(&vmm->object, NVIF_VMM_V0_RAW,
-				&args, sizeof(args));
+	return vmm->impl->raw.unmap(vmm->priv, shift, addr, size, sparse);
 }
 
 int
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c
index 51c7e0fd7876..7c8a7a5dc3f9 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c
@@ -296,40 +296,33 @@ nvkm_uvmm_raw_put(struct nvif_vmm_priv *uvmm, u8 shift, u64 addr, u64 size)
 }
 
 static int
-nvkm_uvmm_mthd_raw_map(struct nvkm_uvmm *uvmm, struct nvif_vmm_raw_v0 *args)
+nvkm_uvmm_raw_map(struct nvif_vmm_priv *uvmm, u8 shift, u64 addr, u64 size, void *argv, u32 argc,
+		  struct nvif_mem_priv *umem, u64 offset)
 {
-	struct nvkm_client *client = uvmm->object.client;
 	struct nvkm_vmm *vmm = uvmm->vmm;
 	struct nvkm_vma vma = {
-		.addr = args->addr,
-		.size = args->size,
+		.addr = addr,
+		.size = size,
 		.used = true,
 		.mapref = false,
 		.no_comp = true,
 	};
 	struct nvkm_memory *memory;
-	void *argv = (void *)(uintptr_t)args->argv;
-	unsigned int argc = args->argc;
-	u64 handle = args->memory;
 	u8 refd;
 	int ret;
 
-	if (!nvkm_vmm_in_managed_range(vmm, args->addr, args->size))
+	if (!nvkm_vmm_in_managed_range(vmm, addr, size))
 		return -EINVAL;
 
-	ret = nvkm_uvmm_page_index(uvmm, args->size, args->shift, &refd);
+	ret = nvkm_uvmm_page_index(uvmm, size, shift, &refd);
 	if (ret)
 		return ret;
 
 	vma.page = vma.refd = refd;
 
-	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);
-	}
+	memory = nvkm_umem_ref(umem);
 
-	ret = nvkm_memory_map(memory, args->offset, vmm, &vma, argv, argc);
+	ret = nvkm_memory_map(memory, offset, vmm, &vma, argv, argc);
 
 	nvkm_memory_unref(&vma.memory);
 	nvkm_memory_unref(&memory);
@@ -337,22 +330,20 @@ nvkm_uvmm_mthd_raw_map(struct nvkm_uvmm *uvmm, struct nvif_vmm_raw_v0 *args)
 }
 
 static int
-nvkm_uvmm_mthd_raw_unmap(struct nvkm_uvmm *uvmm, struct nvif_vmm_raw_v0 *args)
+nvkm_uvmm_raw_unmap(struct nvif_vmm_priv *uvmm, u8 shift, u64 addr, u64 size, bool sparse)
 {
 	struct nvkm_vmm *vmm = uvmm->vmm;
 	u8 refd;
 	int ret;
 
-	if (!nvkm_vmm_in_managed_range(vmm, args->addr, args->size))
+	if (!nvkm_vmm_in_managed_range(vmm, addr, size))
 		return -EINVAL;
 
-	ret = nvkm_uvmm_page_index(uvmm, args->size, args->shift, &refd);
+	ret = nvkm_uvmm_page_index(uvmm, size, shift, &refd);
 	if (ret)
 		return ret;
 
-	nvkm_vmm_raw_unmap(vmm, args->addr, args->size,
-			   args->sparse, refd);
-
+	nvkm_vmm_raw_unmap(vmm, addr, size, sparse, refd);
 	return 0;
 }
 
@@ -382,10 +373,6 @@ nvkm_uvmm_mthd_raw(struct nvkm_uvmm *uvmm, void *argv, u32 argc)
 		return ret;
 
 	switch (args->v0.op) {
-	case NVIF_VMM_RAW_V0_MAP:
-		return nvkm_uvmm_mthd_raw_map(uvmm, &args->v0);
-	case NVIF_VMM_RAW_V0_UNMAP:
-		return nvkm_uvmm_mthd_raw_unmap(uvmm, &args->v0);
 	case NVIF_VMM_RAW_V0_SPARSE:
 		return nvkm_uvmm_mthd_raw_sparse(uvmm, &args->v0);
 	default:
@@ -431,6 +418,8 @@ nvkm_uvmm_impl = {
 	.pfnclr = nvkm_uvmm_pfnclr,
 	.raw.get = nvkm_uvmm_raw_get,
 	.raw.put = nvkm_uvmm_raw_put,
+	.raw.map = nvkm_uvmm_raw_map,
+	.raw.unmap = nvkm_uvmm_raw_unmap,
 };
 
 static void *
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 093/156] drm/nouveau/nvif: rework vmm "raw sparse" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (91 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 092/156] drm/nouveau/nvif: rework vmm "raw map"/"raw unmap" apis Ben Skeggs
@ 2024-04-16 23:38 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 094/156] drm/nouveau/nvif: rework vmm "fault replay"/"fault cancel" apis Ben Skeggs
                   ` (64 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:38 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interface

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  1 +
 drivers/gpu/drm/nouveau/include/nvif/if000c.h | 16 ----------
 drivers/gpu/drm/nouveau/nvif/vmm.c            | 11 +------
 .../gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c    | 32 +++----------------
 4 files changed, 6 insertions(+), 54 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 1cea0a07b2e8..da5760df9e20 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -142,6 +142,7 @@ struct nvif_vmm_impl {
 		int (*map)(struct nvif_vmm_priv *, u8 shift, u64 addr, u64 size, void *, u32,
 			   struct nvif_mem_priv *, u64 offset);
 		int (*unmap)(struct nvif_vmm_priv *, u8 shift, u64 addr, u64 size, bool sparse);
+		int (*sparse)(struct nvif_vmm_priv *, u64 addr, u64 size, bool ref);
 	} raw;
 };
 
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if000c.h b/drivers/gpu/drm/nouveau/include/nvif/if000c.h
index 232cc1142798..61a12396e996 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/if000c.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/if000c.h
@@ -1,22 +1,6 @@
 #ifndef __NVIF_IF000C_H__
 #define __NVIF_IF000C_H__
 
-#define NVIF_VMM_V0_RAW                                                    0x07
 #define NVIF_VMM_V0_MTHD(i)                                         ((i) + 0x80)
 
-struct nvif_vmm_raw_v0 {
-	__u8 version;
-#define NVIF_VMM_RAW_V0_SPARSE	0x4
-	__u8  op;
-	__u8  sparse;
-	__u8  ref;
-	__u8  shift;
-	__u32 argc;
-	__u8  pad01[7];
-	__u64 addr;
-	__u64 size;
-	__u64 offset;
-	__u64 memory;
-	__u64 argv;
-};
 #endif
diff --git a/drivers/gpu/drm/nouveau/nvif/vmm.c b/drivers/gpu/drm/nouveau/nvif/vmm.c
index 16c6aaa81326..c3005f16a32e 100644
--- a/drivers/gpu/drm/nouveau/nvif/vmm.c
+++ b/drivers/gpu/drm/nouveau/nvif/vmm.c
@@ -94,16 +94,7 @@ nvif_vmm_raw_unmap(struct nvif_vmm *vmm, u64 addr, u64 size,
 int
 nvif_vmm_raw_sparse(struct nvif_vmm *vmm, u64 addr, u64 size, bool ref)
 {
-	struct nvif_vmm_raw_v0 args = {
-		.version = 0,
-		.op = NVIF_VMM_RAW_V0_SPARSE,
-		.addr = addr,
-		.size = size,
-		.ref = ref,
-	};
-
-	return nvif_object_mthd(&vmm->object, NVIF_VMM_V0_RAW,
-				&args, sizeof(args));
+	return vmm->impl->raw.sparse(vmm->priv, addr, size, ref);
 }
 
 void
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c
index 7c8a7a5dc3f9..079ebaa64668 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c
@@ -29,8 +29,6 @@
 #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;
@@ -348,36 +346,14 @@ nvkm_uvmm_raw_unmap(struct nvif_vmm_priv *uvmm, u8 shift, u64 addr, u64 size, bo
 }
 
 static int
-nvkm_uvmm_mthd_raw_sparse(struct nvkm_uvmm *uvmm, struct nvif_vmm_raw_v0 *args)
+nvkm_uvmm_raw_sparse(struct nvif_vmm_priv *uvmm, u64 addr, u64 size, bool ref)
 {
 	struct nvkm_vmm *vmm = uvmm->vmm;
 
-	if (!nvkm_vmm_in_managed_range(vmm, args->addr, args->size))
-		return -EINVAL;
-
-	return nvkm_vmm_raw_sparse(vmm, args->addr, args->size, args->ref);
-}
-
-static int
-nvkm_uvmm_mthd_raw(struct nvkm_uvmm *uvmm, void *argv, u32 argc)
-{
-	union {
-		struct nvif_vmm_raw_v0 v0;
-	} *args = argv;
-	int ret = -ENOSYS;
-
-	if (!uvmm->vmm->managed.raw)
+	if (!nvkm_vmm_in_managed_range(vmm, addr, size))
 		return -EINVAL;
 
-	if ((ret = nvif_unpack(ret, &argv, &argc, args->v0, 0, 0, true)))
-		return ret;
-
-	switch (args->v0.op) {
-	case NVIF_VMM_RAW_V0_SPARSE:
-		return nvkm_uvmm_mthd_raw_sparse(uvmm, &args->v0);
-	default:
-		return -EINVAL;
-	};
+	return nvkm_vmm_raw_sparse(vmm, addr, size, ref);
 }
 
 static int
@@ -385,7 +361,6 @@ nvkm_uvmm_mthd(struct nvkm_object *object, u32 mthd, void *argv, u32 argc)
 {
 	struct nvif_vmm_priv *uvmm = container_of(object, typeof(*uvmm), object);
 	switch (mthd) {
-	case NVIF_VMM_V0_RAW   : return nvkm_uvmm_mthd_raw   (uvmm, argv, argc);
 	case NVIF_VMM_V0_MTHD(0x00) ... NVIF_VMM_V0_MTHD(0x7f):
 		if (uvmm->vmm->func->mthd) {
 			return uvmm->vmm->func->mthd(uvmm->vmm,
@@ -420,6 +395,7 @@ nvkm_uvmm_impl = {
 	.raw.put = nvkm_uvmm_raw_put,
 	.raw.map = nvkm_uvmm_raw_map,
 	.raw.unmap = nvkm_uvmm_raw_unmap,
+	.raw.sparse = nvkm_uvmm_raw_sparse,
 };
 
 static void *
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 094/156] drm/nouveau/nvif: rework vmm "fault replay"/"fault cancel" apis
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (92 preceding siblings ...)
  2024-04-16 23:38 ` [PATCH 093/156] drm/nouveau/nvif: rework vmm "raw sparse" api Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 095/156] drm/nouveau/nvif: rework device "new fault buffer" api Ben Skeggs
                   ` (63 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interfaces

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  5 ++
 drivers/gpu/drm/nouveau/include/nvif/if000c.h |  6 --
 drivers/gpu/drm/nouveau/include/nvif/if000d.h |  1 -
 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/nouveau_dmem.c        |  1 -
 drivers/gpu/drm/nouveau/nouveau_svm.c         | 18 ++---
 drivers/gpu/drm/nouveau/nouveau_uvmm.c        |  1 -
 drivers/gpu/drm/nouveau/nvif/vmm.c            |  2 -
 .../gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c    | 43 ++++++------
 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 +-
 17 files changed, 60 insertions(+), 103 deletions(-)
 delete mode 100644 drivers/gpu/drm/nouveau/include/nvif/if000c.h

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index da5760df9e20..425c3184ff14 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -144,6 +144,11 @@ struct nvif_vmm_impl {
 		int (*unmap)(struct nvif_vmm_priv *, u8 shift, u64 addr, u64 size, bool sparse);
 		int (*sparse)(struct nvif_vmm_priv *, u64 addr, u64 size, bool ref);
 	} raw;
+
+	struct {
+		void (*replay)(struct nvif_vmm_priv *);
+		void (*cancel)(struct nvif_vmm_priv *, u64 inst, u8 hub, u8 gpc, u8 client);
+	} fault;
 };
 
 struct nvif_mmu_impl {
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if000c.h b/drivers/gpu/drm/nouveau/include/nvif/if000c.h
deleted file mode 100644
index 61a12396e996..000000000000
--- a/drivers/gpu/drm/nouveau/include/nvif/if000c.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef __NVIF_IF000C_H__
-#define __NVIF_IF000C_H__
-
-#define NVIF_VMM_V0_MTHD(i)                                         ((i) + 0x80)
-
-#endif
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if000d.h b/drivers/gpu/drm/nouveau/include/nvif/if000d.h
index 516ec9401401..dff2d0f838e7 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/if000d.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/if000d.h
@@ -1,6 +1,5 @@
 #ifndef __NVIF_IF000D_H__
 #define __NVIF_IF000D_H__
-#include "if000c.h"
 
 struct nv04_vmm_vn {
 	/* nvif_vmm_vX ... */
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if500d.h b/drivers/gpu/drm/nouveau/include/nvif/if500d.h
index c29a7822b363..c76433af0489 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/if500d.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/if500d.h
@@ -1,6 +1,5 @@
 #ifndef __NVIF_IF500D_H__
 #define __NVIF_IF500D_H__
-#include "if000c.h"
 
 struct nv50_vmm_vn {
 	/* nvif_vmm_vX ... */
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if900d.h b/drivers/gpu/drm/nouveau/include/nvif/if900d.h
index 49aa50583c3d..5a9d798b5619 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/if900d.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/if900d.h
@@ -1,6 +1,5 @@
 #ifndef __NVIF_IF900D_H__
 #define __NVIF_IF900D_H__
-#include "if000c.h"
 
 struct gf100_vmm_vn {
 	/* nvif_vmm_vX ... */
diff --git a/drivers/gpu/drm/nouveau/include/nvif/ifb00d.h b/drivers/gpu/drm/nouveau/include/nvif/ifb00d.h
index a0e419830595..a0aedf37e91d 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/ifb00d.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/ifb00d.h
@@ -1,6 +1,5 @@
 #ifndef __NVIF_IFB00D_H__
 #define __NVIF_IFB00D_H__
-#include "if000c.h"
 
 struct gm200_vmm_vn {
 	/* nvif_vmm_vX ... */
diff --git a/drivers/gpu/drm/nouveau/include/nvif/ifc00d.h b/drivers/gpu/drm/nouveau/include/nvif/ifc00d.h
index 4cabd613a280..700d4ab4369f 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/ifc00d.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/ifc00d.h
@@ -1,6 +1,5 @@
 #ifndef __NVIF_IFC00D_H__
 #define __NVIF_IFC00D_H__
-#include "if000c.h"
 
 struct gp100_vmm_vn {
 	/* nvif_vmm_vX ... */
diff --git a/drivers/gpu/drm/nouveau/nouveau_dmem.c b/drivers/gpu/drm/nouveau/nouveau_dmem.c
index a2369841353d..fed91756846f 100644
--- a/drivers/gpu/drm/nouveau/nouveau_dmem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_dmem.c
@@ -30,7 +30,6 @@
 #include <nvif/class.h>
 #include <nvif/object.h>
 #include <nvif/push906f.h>
-#include <nvif/if000c.h>
 #include <nvif/if500b.h>
 #include <nvif/if900b.h>
 
diff --git a/drivers/gpu/drm/nouveau/nouveau_svm.c b/drivers/gpu/drm/nouveau/nouveau_svm.c
index ab02bcc034fb..07fa00afe5b8 100644
--- a/drivers/gpu/drm/nouveau/nouveau_svm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_svm.c
@@ -379,11 +379,10 @@ nouveau_svmm_init(struct drm_device *dev, void *data,
 static void
 nouveau_svm_fault_replay(struct nouveau_svm *svm)
 {
+	struct nvif_vmm *vmm = &svm->drm->cli.vmm.vmm;
+
 	SVM_DBG(svm, "replay");
-	WARN_ON(nvif_object_mthd(&svm->drm->client.vmm.vmm.object,
-				 GP100_VMM_VN_FAULT_REPLAY,
-				 &(struct gp100_vmm_fault_replay_vn) {},
-				 sizeof(struct gp100_vmm_fault_replay_vn)));
+	vmm->impl->fault.replay(vmm->priv);
 }
 
 /* Cancel a replayable fault that could not be handled.
@@ -395,15 +394,10 @@ static void
 nouveau_svm_fault_cancel(struct nouveau_svm *svm,
 			 u64 inst, u8 hub, u8 gpc, u8 client)
 {
+	struct nvif_vmm *vmm = &svm->drm->cli.vmm.vmm;
+
 	SVM_DBG(svm, "cancel %016llx %d %02x %02x", inst, hub, gpc, client);
-	WARN_ON(nvif_object_mthd(&svm->drm->client.vmm.vmm.object,
-				 GP100_VMM_VN_FAULT_CANCEL,
-				 &(struct gp100_vmm_fault_cancel_v0) {
-					.hub = hub,
-					.gpc = gpc,
-					.client = client,
-					.inst = inst,
-				 }, sizeof(struct gp100_vmm_fault_cancel_v0)));
+	vmm->impl->fault.cancel(vmm->priv, inst, hub, gpc, client);
 }
 
 static void
diff --git a/drivers/gpu/drm/nouveau/nouveau_uvmm.c b/drivers/gpu/drm/nouveau/nouveau_uvmm.c
index 1340138bbc13..9589fdd09e22 100644
--- a/drivers/gpu/drm/nouveau/nouveau_uvmm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_uvmm.c
@@ -29,7 +29,6 @@
 #include <nvif/mem.h>
 
 #include <nvif/class.h>
-#include <nvif/if000c.h>
 #include <nvif/if900d.h>
 
 #define NOUVEAU_VA_SPACE_BITS		47 /* FIXME */
diff --git a/drivers/gpu/drm/nouveau/nvif/vmm.c b/drivers/gpu/drm/nouveau/nvif/vmm.c
index c3005f16a32e..fe342828ce8c 100644
--- a/drivers/gpu/drm/nouveau/nvif/vmm.c
+++ b/drivers/gpu/drm/nouveau/nvif/vmm.c
@@ -24,8 +24,6 @@
 #include <nvif/mem.h>
 #include <nvif/printf.h>
 
-#include <nvif/if000c.h>
-
 int
 nvif_vmm_unmap(struct nvif_vmm *vmm, u64 addr)
 {
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c
index 079ebaa64668..d8e7888410c3 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c
@@ -26,9 +26,6 @@
 #include <core/client.h>
 #include <core/memory.h>
 
-#include <nvif/if000c.h>
-#include <nvif/unpack.h>
-
 struct nvif_vmm_priv {
 	struct nvkm_object object;
 	struct nvkm_vmm *vmm;
@@ -49,6 +46,22 @@ nvkm_uvmm_search(struct nvkm_client *client, u64 handle)
 	return nvkm_vmm_ref(container_of(object, struct nvif_vmm_priv, object)->vmm);
 }
 
+static void
+nvkm_uvmm_fault_cancel(struct nvif_vmm_priv *uvmm, u64 inst, u8 hub, u8 gpc, u8 client)
+{
+	struct nvkm_vmm *vmm = uvmm->vmm;
+
+	vmm->func->fault->cancel(vmm, inst, hub, gpc, client);
+}
+
+static void
+nvkm_uvmm_fault_replay(struct nvif_vmm_priv *uvmm)
+{
+	struct nvkm_vmm *vmm = uvmm->vmm;
+
+	vmm->func->fault->replay(vmm);
+}
+
 static int
 nvkm_uvmm_pfnclr(struct nvif_vmm_priv *uvmm, u64 addr, u64 size)
 {
@@ -356,24 +369,6 @@ nvkm_uvmm_raw_sparse(struct nvif_vmm_priv *uvmm, u64 addr, u64 size, bool ref)
 	return nvkm_vmm_raw_sparse(vmm, addr, size, ref);
 }
 
-static int
-nvkm_uvmm_mthd(struct nvkm_object *object, u32 mthd, void *argv, u32 argc)
-{
-	struct nvif_vmm_priv *uvmm = container_of(object, typeof(*uvmm), object);
-	switch (mthd) {
-	case NVIF_VMM_V0_MTHD(0x00) ... NVIF_VMM_V0_MTHD(0x7f):
-		if (uvmm->vmm->func->mthd) {
-			return uvmm->vmm->func->mthd(uvmm->vmm,
-						     uvmm->object.client,
-						     mthd, argv, argc);
-		}
-		break;
-	default:
-		break;
-	}
-	return -EINVAL;
-}
-
 static void
 nvkm_uvmm_del(struct nvif_vmm_priv *uvmm)
 {
@@ -410,7 +405,6 @@ nvkm_uvmm_dtor(struct nvkm_object *object)
 static const struct nvkm_object_func
 nvkm_uvmm = {
 	.dtor = nvkm_uvmm_dtor,
-	.mthd = nvkm_uvmm_mthd,
 };
 
 int
@@ -469,6 +463,11 @@ nvkm_uvmm_new(struct nvkm_mmu *mmu, u8 type, u64 addr, u64 size, void *argv, u32
 		uvmm->impl.page_nr++;
 	}
 
+	if (uvmm->vmm->replay) {
+		uvmm->impl.fault.replay = nvkm_uvmm_fault_replay;
+		uvmm->impl.fault.cancel = nvkm_uvmm_fault_cancel;
+	}
+
 	*pimpl = &uvmm->impl;
 	*ppriv = uvmm;
 	*pobject = &uvmm->object;
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.h b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.h
index f9bc30cdb2b3..a48ba1c95847 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.h
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.h
@@ -145,8 +145,10 @@ struct nvkm_vmm_func {
 		     struct nvkm_vmm_map *);
 	void (*flush)(struct nvkm_vmm *, int depth);
 
-	int (*mthd)(struct nvkm_vmm *, struct nvkm_client *,
-		    u32 mthd, void *argv, u32 argc);
+	const struct nvkm_vmm_func_fault {
+		void (*replay)(struct nvkm_vmm *);
+		void (*cancel)(struct nvkm_vmm *, u64 inst, u8 hub, u8 gpc, u8 client);
+	} *fault;
 
 	void (*invalidate_pdb)(struct nvkm_vmm *, u64 addr);
 
@@ -249,7 +251,7 @@ int gp100_vmm_new_(const struct nvkm_vmm_func *,
 int gp100_vmm_join(struct nvkm_vmm *, struct nvkm_memory *);
 int gp100_vmm_valid(struct nvkm_vmm *, void *, u32, struct nvkm_vmm_map *);
 void gp100_vmm_flush(struct nvkm_vmm *, int);
-int gp100_vmm_mthd(struct nvkm_vmm *, struct nvkm_client *, u32, void *, u32);
+extern const struct nvkm_vmm_func_fault gp100_vmm_fault;
 void gp100_vmm_invalidate_pdb(struct nvkm_vmm *, u64 addr);
 
 int gv100_vmm_join(struct nvkm_vmm *, struct nvkm_memory *);
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmgp100.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmgp100.c
index bddac77f48f0..36441ffe2e01 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmgp100.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmgp100.c
@@ -482,70 +482,42 @@ gp100_vmm_valid(struct nvkm_vmm *vmm, void *argv, u32 argc,
 	return 0;
 }
 
-static int
-gp100_vmm_fault_cancel(struct nvkm_vmm *vmm, void *argv, u32 argc)
+static void
+gp100_vmm_fault_cancel(struct nvkm_vmm *vmm, u64 inst, u8 hub, u8 gpc, u8 client)
 {
 	struct nvkm_device *device = vmm->mmu->subdev.device;
-	union {
-		struct gp100_vmm_fault_cancel_v0 v0;
-	} *args = argv;
-	int ret = -ENOSYS;
 	u32 aper;
 
-	if ((ret = nvif_unpack(ret, &argv, &argc, args->v0, 0, 0, false)))
-		return ret;
-
 	/* Translate MaxwellFaultBufferA instance pointer to the same
 	 * format as the NV_GR_FECS_CURRENT_CTX register.
 	 */
-	aper = (args->v0.inst >> 8) & 3;
-	args->v0.inst >>= 12;
-	args->v0.inst |= aper << 28;
-	args->v0.inst |= 0x80000000;
+	aper = (inst >> 8) & 3;
+	inst >>= 12;
+	inst |= aper << 28;
+	inst |= 0x80000000;
 
 	if (!WARN_ON(nvkm_gr_ctxsw_pause(device))) {
-		if (nvkm_gr_ctxsw_inst(device) == args->v0.inst) {
-			gf100_vmm_invalidate(vmm, 0x0000001b
-					     /* CANCEL_TARGETED. */ |
-					     (args->v0.hub    << 20) |
-					     (args->v0.gpc    << 15) |
-					     (args->v0.client << 9));
+		if (nvkm_gr_ctxsw_inst(device) == inst) {
+			gf100_vmm_invalidate(vmm, 0x0000001b /* CANCEL_TARGETED. */ |
+					     (hub    << 20) |
+					     (gpc    << 15) |
+					     (client << 9));
 		}
 		WARN_ON(nvkm_gr_ctxsw_resume(device));
 	}
-
-	return 0;
 }
 
-static int
-gp100_vmm_fault_replay(struct nvkm_vmm *vmm, void *argv, u32 argc)
+static void
+gp100_vmm_fault_replay(struct nvkm_vmm *vmm)
 {
-	union {
-		struct gp100_vmm_fault_replay_vn vn;
-	} *args = argv;
-	int ret = -ENOSYS;
-
-	if (!(ret = nvif_unvers(ret, &argv, &argc, args->vn))) {
-		gf100_vmm_invalidate(vmm, 0x0000000b); /* REPLAY_GLOBAL. */
-	}
-
-	return ret;
+	gf100_vmm_invalidate(vmm, 0x0000000b); /* REPLAY_GLOBAL. */
 }
 
-int
-gp100_vmm_mthd(struct nvkm_vmm *vmm,
-	       struct nvkm_client *client, u32 mthd, void *argv, u32 argc)
-{
-	switch (mthd) {
-	case GP100_VMM_VN_FAULT_REPLAY:
-		return gp100_vmm_fault_replay(vmm, argv, argc);
-	case GP100_VMM_VN_FAULT_CANCEL:
-		return gp100_vmm_fault_cancel(vmm, argv, argc);
-	default:
-		break;
-	}
-	return -EINVAL;
-}
+const struct nvkm_vmm_func_fault
+gp100_vmm_fault = {
+	.replay = gp100_vmm_fault_replay,
+	.cancel = gp100_vmm_fault_cancel,
+};
 
 void
 gp100_vmm_invalidate_pdb(struct nvkm_vmm *vmm, u64 addr)
@@ -583,7 +555,7 @@ gp100_vmm = {
 	.aper = gf100_vmm_aper,
 	.valid = gp100_vmm_valid,
 	.flush = gp100_vmm_flush,
-	.mthd = gp100_vmm_mthd,
+	.fault = &gp100_vmm_fault,
 	.invalidate_pdb = gp100_vmm_invalidate_pdb,
 	.page = {
 		{ 47, &gp100_vmm_desc_16[4], NVKM_VMM_PAGE_Sxxx },
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmgp10b.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmgp10b.c
index e081239afe58..d03f3761cb3f 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmgp10b.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmgp10b.c
@@ -28,7 +28,7 @@ gp10b_vmm = {
 	.aper = gk20a_vmm_aper,
 	.valid = gp100_vmm_valid,
 	.flush = gp100_vmm_flush,
-	.mthd = gp100_vmm_mthd,
+	.fault = &gp100_vmm_fault,
 	.invalidate_pdb = gp100_vmm_invalidate_pdb,
 	.page = {
 		{ 47, &gp100_vmm_desc_16[4], NVKM_VMM_PAGE_Sxxx },
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmgv100.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmgv100.c
index f0e21f63253a..a68b7dbe8613 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmgv100.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmgv100.c
@@ -66,7 +66,7 @@ gv100_vmm = {
 	.aper = gf100_vmm_aper,
 	.valid = gp100_vmm_valid,
 	.flush = gp100_vmm_flush,
-	.mthd = gp100_vmm_mthd,
+	.fault = &gp100_vmm_fault,
 	.invalidate_pdb = gp100_vmm_invalidate_pdb,
 	.page = {
 		{ 47, &gp100_vmm_desc_16[4], NVKM_VMM_PAGE_Sxxx },
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmtu102.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmtu102.c
index 8379e72d77ab..21cd1fe999da 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmtu102.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmtu102.c
@@ -57,7 +57,7 @@ tu102_vmm = {
 	.aper = gf100_vmm_aper,
 	.valid = gp100_vmm_valid,
 	.flush = tu102_vmm_flush,
-	.mthd = gp100_vmm_mthd,
+	.fault = &gp100_vmm_fault,
 	.page = {
 		{ 47, &gp100_vmm_desc_16[4], NVKM_VMM_PAGE_Sxxx },
 		{ 38, &gp100_vmm_desc_16[3], NVKM_VMM_PAGE_Sxxx },
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 095/156] drm/nouveau/nvif: rework device "new fault buffer" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (93 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 094/156] drm/nouveau/nvif: rework vmm "fault replay"/"fault cancel" apis Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 096/156] drm/nouveau/nvif: rework fault buffer "map" api Ben Skeggs
                   ` (62 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interfaces

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/include/nvif/clb069.h |  7 ---
 .../gpu/drm/nouveau/include/nvif/driverif.h   | 12 +++++
 drivers/gpu/drm/nouveau/nouveau_svm.c         | 27 ++++++----
 drivers/gpu/drm/nouveau/nvkm/device/user.c    | 28 +++++++----
 .../gpu/drm/nouveau/nvkm/subdev/fault/base.c  |  1 -
 .../gpu/drm/nouveau/nvkm/subdev/fault/priv.h  |  3 --
 .../gpu/drm/nouveau/nvkm/subdev/fault/user.c  | 49 +++++++++++++------
 .../gpu/drm/nouveau/nvkm/subdev/fault/user.h  |  9 ++++
 8 files changed, 91 insertions(+), 45 deletions(-)
 create mode 100644 drivers/gpu/drm/nouveau/nvkm/subdev/fault/user.h

diff --git a/drivers/gpu/drm/nouveau/include/nvif/clb069.h b/drivers/gpu/drm/nouveau/include/nvif/clb069.h
index d7689de35ab2..67bf579ced18 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/clb069.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/clb069.h
@@ -1,12 +1,5 @@
 #ifndef __NVIF_CLB069_H__
 #define __NVIF_CLB069_H__
-struct nvif_clb069_v0 {
-	__u8  version;
-	__u8  pad01[3];
-	__u32 entries;
-	__u32 get;
-	__u32 put;
-};
 
 union nvif_clb069_event_args {
 	struct nvif_clb069_event_vn {
diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 425c3184ff14..a1aab5735146 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -8,6 +8,7 @@ struct nvif_usermode_priv;
 struct nvif_mmu_priv;
 struct nvif_mem_priv;
 struct nvif_vmm_priv;
+struct nvif_faultbuf_priv;
 
 struct nvif_driver {
 	const char *name;
@@ -194,6 +195,14 @@ struct nvif_mmu_impl {
 	} vmm;
 };
 
+struct nvif_faultbuf_impl {
+	void (*del)(struct nvif_faultbuf_priv *);
+
+	u32 entries;
+	u32 get;
+	u32 put;
+};
+
 struct nvif_device_impl {
 	void (*del)(struct nvif_device_priv *);
 
@@ -254,6 +263,9 @@ struct nvif_device_impl {
 
 	struct {
 		s32 oclass;
+		int (*new)(struct nvif_device_priv *,
+			   const struct nvif_faultbuf_impl **, struct nvif_faultbuf_priv **,
+			   u64 handle);
 	} faultbuf;
 
 	struct {
diff --git a/drivers/gpu/drm/nouveau/nouveau_svm.c b/drivers/gpu/drm/nouveau/nouveau_svm.c
index 07fa00afe5b8..83702a86da1d 100644
--- a/drivers/gpu/drm/nouveau/nouveau_svm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_svm.c
@@ -44,8 +44,11 @@ struct nouveau_svm {
 	struct list_head inst;
 
 	struct nouveau_svm_fault_buffer {
-		int id;
+		const struct nvif_faultbuf_impl *impl;
+		struct nvif_faultbuf_priv *priv;
 		struct nvif_object object;
+
+		int id;
 		u32 entries;
 		u32 getaddr;
 		u32 putaddr;
@@ -960,7 +963,11 @@ nouveau_svm_fault_buffer_dtor(struct nouveau_svm *svm, int id)
 	}
 
 	nvif_event_dtor(&buffer->notify);
-	nvif_object_dtor(&buffer->object);
+
+	if (buffer->impl) {
+		buffer->impl->del(buffer->priv);
+		buffer->impl = NULL;
+	}
 }
 
 static int
@@ -968,23 +975,23 @@ nouveau_svm_fault_buffer_ctor(struct nouveau_svm *svm, s32 oclass, int id)
 {
 	struct nouveau_svm_fault_buffer *buffer = &svm->buffer[id];
 	struct nouveau_drm *drm = svm->drm;
-	struct nvif_object *device = &drm->client.device.object;
-	struct nvif_clb069_v0 args = {};
 	int ret;
 
 	buffer->id = id;
 
-	ret = nvif_object_ctor(device, "svmFaultBuffer", 0, oclass, &args,
-			       sizeof(args), &buffer->object);
-	if (ret < 0) {
+	ret = drm->device.impl->faultbuf.new(drm->device.priv, &buffer->impl, &buffer->priv,
+					     nvif_handle(&buffer->object));
+	if (ret) {
 		SVM_ERR(svm, "Fault buffer allocation failed: %d", ret);
 		return ret;
 	}
 
+	nvif_object_ctor(&drm->device.object, "svmFaultBuffer", id, oclass, &buffer->object);
+	buffer->entries = buffer->impl->entries;
+	buffer->getaddr = buffer->impl->get;
+	buffer->putaddr = buffer->impl->put;
+
 	nvif_object_map(&buffer->object, NULL, 0);
-	buffer->entries = args.entries;
-	buffer->getaddr = args.get;
-	buffer->putaddr = args.put;
 	INIT_WORK(&buffer->work, nouveau_svm_fault);
 
 	ret = nvif_event_ctor(&buffer->object, "svmFault", id, nouveau_svm_event, true, NULL, 0,
diff --git a/drivers/gpu/drm/nouveau/nvkm/device/user.c b/drivers/gpu/drm/nouveau/nvkm/device/user.c
index e63462188f2a..b4604ce1fcbb 100644
--- a/drivers/gpu/drm/nouveau/nvkm/device/user.c
+++ b/drivers/gpu/drm/nouveau/nvkm/device/user.c
@@ -26,6 +26,7 @@
 #include "ctrl.h"
 
 #include <core/client.h>
+#include <subdev/fault/user.h>
 #include <subdev/fb.h>
 #include <subdev/instmem.h>
 #include <subdev/timer.h>
@@ -41,6 +42,21 @@ struct nvif_device_priv {
 	struct nvif_device_impl impl;
 };
 
+static int
+nvkm_udevice_fault_new(struct nvif_device_priv *udev,
+		       const struct nvif_faultbuf_impl **pimpl, struct nvif_faultbuf_priv **ppriv,
+		       u64 handle)
+{
+	struct nvkm_object *object;
+	int ret;
+
+	ret = nvkm_ufault_new(udev->device, pimpl, ppriv, &object);
+	if (ret)
+		return ret;
+
+	return nvkm_object_link_rb(udev->object.client, &udev->object, handle, object);
+}
+
 static int
 nvkm_udevice_usermode_new(struct nvif_device_priv *udev, const struct nvif_usermode_impl **pimpl,
 			  struct nvif_usermode_priv **ppriv)
@@ -183,15 +199,8 @@ nvkm_udevice_child_get(struct nvkm_object *object, int index,
 		index -= engine->func->base.sclass(oclass, index, &sclass);
 	}
 
-	if (!sclass) {
-		if (device->fault && index-- == 0)
-			sclass = &device->fault->user;
-		else
-			return -EINVAL;
-
-		oclass->base = sclass->base;
-		oclass->engine = NULL;
-	}
+	if (!sclass)
+		return -EINVAL;
 
 	oclass->ctor = nvkm_udevice_child_new;
 	oclass->priv = sclass;
@@ -303,6 +312,7 @@ nvkm_udevice_new(struct nvkm_device *device,
 
 	if (device->fault) {
 		udev->impl.faultbuf.oclass = device->fault->user.base.oclass;
+		udev->impl.faultbuf.new = nvkm_udevice_fault_new;
 	}
 
 	if (device->disp) {
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/fault/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/fault/base.c
index b53ac9a2552f..68611f83ab8a 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/fault/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/fault/base.c
@@ -160,7 +160,6 @@ nvkm_fault_new_(const struct nvkm_fault_func *func, struct nvkm_device *device,
 		return -ENOMEM;
 	nvkm_subdev_ctor(&nvkm_fault, device, type, inst, &fault->subdev);
 	fault->func = func;
-	fault->user.ctor = nvkm_ufault_new;
 	fault->user.base = func->user.base;
 	return 0;
 }
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/fault/priv.h b/drivers/gpu/drm/nouveau/nvkm/subdev/fault/priv.h
index 3c26e76d1d3c..b49b4e3b7660 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/fault/priv.h
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/fault/priv.h
@@ -52,7 +52,4 @@ void gp100_fault_intr(struct nvkm_fault *);
 u64 gp10b_fault_buffer_pin(struct nvkm_fault_buffer *);
 
 int gv100_fault_oneinit(struct nvkm_fault *);
-
-int nvkm_ufault_new(struct nvkm_device *, const struct nvkm_oclass *,
-		    void *, u32, struct nvkm_object **);
 #endif
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/fault/user.c b/drivers/gpu/drm/nouveau/nvkm/subdev/fault/user.c
index 6c3ede8b0321..e6eb6df1f982 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/fault/user.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/fault/user.c
@@ -19,6 +19,7 @@
  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
  */
+#include "user.h"
 #include "priv.h"
 
 #include <core/memory.h>
@@ -31,6 +32,8 @@
 struct nvif_faultbuf_priv {
 	struct nvkm_object object;
 	struct nvkm_fault_buffer *buffer;
+
+	struct nvif_faultbuf_impl impl;
 };
 
 static int
@@ -60,6 +63,20 @@ nvkm_ufault_map(struct nvkm_object *object, void *argv, u32 argc,
 	return 0;
 }
 
+static void
+nvkm_ufault_del(struct nvif_faultbuf_priv *ufault)
+{
+	struct nvkm_object *object = &ufault->object;
+
+	nvkm_object_fini(object, false);
+	nvkm_object_del(&object);
+}
+
+static const struct nvif_faultbuf_impl
+nvkm_ufault_impl = {
+	.del = nvkm_ufault_del,
+};
+
 static int
 nvkm_ufault_fini(struct nvkm_object *object, bool suspend)
 {
@@ -96,31 +113,33 @@ nvkm_ufault = {
 };
 
 int
-nvkm_ufault_new(struct nvkm_device *device, const struct nvkm_oclass *oclass,
-		void *argv, u32 argc, struct nvkm_object **pobject)
+nvkm_ufault_new(struct nvkm_device *device, const struct nvif_faultbuf_impl **pimpl,
+		struct nvif_faultbuf_priv **ppriv, struct nvkm_object **pobject)
 {
-	union {
-		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;
-
-	if (!(ret = nvif_unpack(ret, &argv, &argc, args->v0, 0, 0, false))) {
-		args->v0.entries = buffer->entries;
-		args->v0.get = buffer->get;
-		args->v0.put = buffer->put;
-	} else
-		return ret;
+	int ret;
 
 	ufault = kzalloc(sizeof(*ufault), GFP_KERNEL);
 	if (!ufault)
 		return -ENOMEM;
 
-	nvkm_object_ctor(&nvkm_ufault, oclass, &ufault->object);
+	nvkm_object_ctor(&nvkm_ufault, &(struct nvkm_oclass) {}, &ufault->object);
 	ufault->buffer = fault->buffer[fault->func->user.rp];
 
+	ret = nvkm_ufault_init(&ufault->object);
+	if (ret) {
+		nvkm_ufault_del(ufault);
+		return ret;
+	}
+
+	ufault->impl = nvkm_ufault_impl;
+	ufault->impl.entries = ufault->buffer->entries;
+	ufault->impl.get = ufault->buffer->get;
+	ufault->impl.put = ufault->buffer->put;
+
+	*pimpl = &ufault->impl;
+	*ppriv = ufault;
 	*pobject = &ufault->object;
 	return 0;
 }
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/fault/user.h b/drivers/gpu/drm/nouveau/nvkm/subdev/fault/user.h
new file mode 100644
index 000000000000..2408aa3ec91c
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/fault/user.h
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: MIT */
+#ifndef __NVKM_UFAULT_H__
+#define __NVKM_UFAULT_H__
+#include <subdev/fault.h>
+#include <nvif/driverif.h>
+
+int nvkm_ufault_new(struct nvkm_device *, const struct nvif_faultbuf_impl **,
+		    struct nvif_faultbuf_priv **, struct nvkm_object **);
+#endif
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 096/156] drm/nouveau/nvif: rework fault buffer "map" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (94 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 095/156] drm/nouveau/nvif: rework device "new fault buffer" api Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 097/156] drm/nouveau/nvif: rework fault buffer "new event" api Ben Skeggs
                   ` (61 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interface

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  1 +
 drivers/gpu/drm/nouveau/nouveau_svm.c         | 26 +++++++++++--------
 .../gpu/drm/nouveau/nvkm/subdev/fault/user.c  | 16 +++---------
 3 files changed, 19 insertions(+), 24 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index a1aab5735146..ba987233ec74 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -198,6 +198,7 @@ struct nvif_mmu_impl {
 struct nvif_faultbuf_impl {
 	void (*del)(struct nvif_faultbuf_priv *);
 
+	struct nvif_mapinfo map;
 	u32 entries;
 	u32 get;
 	u32 put;
diff --git a/drivers/gpu/drm/nouveau/nouveau_svm.c b/drivers/gpu/drm/nouveau/nouveau_svm.c
index 83702a86da1d..43218da5d0f3 100644
--- a/drivers/gpu/drm/nouveau/nouveau_svm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_svm.c
@@ -47,6 +47,7 @@ struct nouveau_svm {
 		const struct nvif_faultbuf_impl *impl;
 		struct nvif_faultbuf_priv *priv;
 		struct nvif_object object;
+		struct nvif_map map;
 
 		int id;
 		u32 entries;
@@ -449,15 +450,14 @@ static void
 nouveau_svm_fault_cache(struct nouveau_svm *svm,
 			struct nouveau_svm_fault_buffer *buffer, u32 offset)
 {
-	struct nvif_object *memory = &buffer->object;
-	const u32 instlo = nvif_rd32(memory, offset + 0x00);
-	const u32 insthi = nvif_rd32(memory, offset + 0x04);
-	const u32 addrlo = nvif_rd32(memory, offset + 0x08);
-	const u32 addrhi = nvif_rd32(memory, offset + 0x0c);
-	const u32 timelo = nvif_rd32(memory, offset + 0x10);
-	const u32 timehi = nvif_rd32(memory, offset + 0x14);
-	const u32 engine = nvif_rd32(memory, offset + 0x18);
-	const u32   info = nvif_rd32(memory, offset + 0x1c);
+	const u32 instlo = nvif_rd32(buffer, offset + 0x00);
+	const u32 insthi = nvif_rd32(buffer, offset + 0x04);
+	const u32 addrlo = nvif_rd32(buffer, offset + 0x08);
+	const u32 addrhi = nvif_rd32(buffer, offset + 0x0c);
+	const u32 timelo = nvif_rd32(buffer, offset + 0x10);
+	const u32 timehi = nvif_rd32(buffer, offset + 0x14);
+	const u32 engine = nvif_rd32(buffer, offset + 0x18);
+	const u32   info = nvif_rd32(buffer, offset + 0x1c);
 	const u64   inst = (u64)insthi << 32 | instlo;
 	const u8     gpc = (info & 0x1f000000) >> 24;
 	const u8     hub = (info & 0x00100000) >> 20;
@@ -468,7 +468,7 @@ nouveau_svm_fault_cache(struct nouveau_svm *svm,
 	if (WARN_ON(!(info & 0x80000000)))
 		return;
 
-	nvif_mask(memory, offset + 0x1c, 0x80000000, 0x00000000);
+	nvif_mask(buffer, offset + 0x1c, 0x80000000, 0x00000000);
 
 	if (!buffer->fault[buffer->fault_nr]) {
 		fault = kmalloc(sizeof(*fault), GFP_KERNEL);
@@ -965,6 +965,7 @@ nouveau_svm_fault_buffer_dtor(struct nouveau_svm *svm, int id)
 	nvif_event_dtor(&buffer->notify);
 
 	if (buffer->impl) {
+		nvif_object_unmap_cpu(&buffer->map);
 		buffer->impl->del(buffer->priv);
 		buffer->impl = NULL;
 	}
@@ -991,7 +992,10 @@ nouveau_svm_fault_buffer_ctor(struct nouveau_svm *svm, s32 oclass, int id)
 	buffer->getaddr = buffer->impl->get;
 	buffer->putaddr = buffer->impl->put;
 
-	nvif_object_map(&buffer->object, NULL, 0);
+	ret = nvif_object_map_cpu(&buffer->object, &buffer->impl->map, &buffer->map);
+	if (ret)
+		return ret;
+
 	INIT_WORK(&buffer->work, nouveau_svm_fault);
 
 	ret = nvif_event_ctor(&buffer->object, "svmFault", id, nouveau_svm_event, true, NULL, 0,
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/fault/user.c b/drivers/gpu/drm/nouveau/nvkm/subdev/fault/user.c
index e6eb6df1f982..de7a79607eff 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/fault/user.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/fault/user.c
@@ -51,18 +51,6 @@ nvkm_ufault_uevent(struct nvkm_object *object, void *argv, u32 argc, struct nvkm
 			       NVKM_FAULT_BUFFER_EVENT_PENDING, NULL);
 }
 
-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 = 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;
-	*size = nvkm_memory_size(buffer->mem);
-	return 0;
-}
-
 static void
 nvkm_ufault_del(struct nvif_faultbuf_priv *ufault)
 {
@@ -108,7 +96,6 @@ nvkm_ufault = {
 	.dtor = nvkm_ufault_dtor,
 	.init = nvkm_ufault_init,
 	.fini = nvkm_ufault_fini,
-	.map = nvkm_ufault_map,
 	.uevent = nvkm_ufault_uevent,
 };
 
@@ -134,6 +121,9 @@ nvkm_ufault_new(struct nvkm_device *device, const struct nvif_faultbuf_impl **pi
 	}
 
 	ufault->impl = nvkm_ufault_impl;
+	ufault->impl.map.type = NVIF_MAP_IO;
+	ufault->impl.map.handle = device->func->resource_addr(device, 3) + ufault->buffer->addr;
+	ufault->impl.map.length = nvkm_memory_size(ufault->buffer->mem);
 	ufault->impl.entries = ufault->buffer->entries;
 	ufault->impl.get = ufault->buffer->get;
 	ufault->impl.put = ufault->buffer->put;
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 097/156] drm/nouveau/nvif: rework fault buffer "new event" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (95 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 096/156] drm/nouveau/nvif: rework fault buffer "map" api Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 098/156] drm/nouveau/nvif: remove fault buffer from object rb Ben Skeggs
                   ` (60 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interface

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/include/nvif/clb069.h |  8 ---
 .../gpu/drm/nouveau/include/nvif/driverif.h   | 12 ++++
 drivers/gpu/drm/nouveau/include/nvif/event.h  |  3 +
 .../gpu/drm/nouveau/include/nvkm/core/event.h |  9 ++-
 drivers/gpu/drm/nouveau/nouveau_svm.c         |  8 ++-
 drivers/gpu/drm/nouveau/nvif/event.c          | 33 ++++++++--
 drivers/gpu/drm/nouveau/nvkm/core/uevent.c    | 65 +++++++++++++++++++
 .../gpu/drm/nouveau/nvkm/subdev/fault/user.c  | 20 ++----
 8 files changed, 126 insertions(+), 32 deletions(-)
 delete mode 100644 drivers/gpu/drm/nouveau/include/nvif/clb069.h

diff --git a/drivers/gpu/drm/nouveau/include/nvif/clb069.h b/drivers/gpu/drm/nouveau/include/nvif/clb069.h
deleted file mode 100644
index 67bf579ced18..000000000000
--- a/drivers/gpu/drm/nouveau/include/nvif/clb069.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef __NVIF_CLB069_H__
-#define __NVIF_CLB069_H__
-
-union nvif_clb069_event_args {
-	struct nvif_clb069_event_vn {
-	} vn;
-};
-#endif
diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index ba987233ec74..81375819c787 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -1,6 +1,7 @@
 /* SPDX-License-Identifier: MIT */
 #ifndef __NVIF_DRIVERIF_H__
 #define __NVIF_DRIVERIF_H__
+struct nvif_event_priv;
 struct nvif_client_priv;
 struct nvif_device_priv;
 struct nvif_control_priv;
@@ -19,6 +20,12 @@ struct nvif_driver {
 	void (*unmap)(struct nvif_client_priv *, void __iomem *ptr, u32 size);
 };
 
+struct nvif_event_impl {
+	void (*del)(struct nvif_event_priv *);
+	int (*allow)(struct nvif_event_priv *);
+	int (*block)(struct nvif_event_priv *);
+};
+
 struct nvif_mapinfo {
 	enum nvif_map_type {
 		NVIF_MAP_IO,
@@ -202,6 +209,11 @@ struct nvif_faultbuf_impl {
 	u32 entries;
 	u32 get;
 	u32 put;
+
+	struct {
+		int (*new)(struct nvif_faultbuf_priv *, u64 token,
+			   const struct nvif_event_impl **, struct nvif_event_priv **);
+	} event;
 };
 
 struct nvif_device_impl {
diff --git a/drivers/gpu/drm/nouveau/include/nvif/event.h b/drivers/gpu/drm/nouveau/include/nvif/event.h
index 1683e138c7f8..338082bdc67c 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/event.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/event.h
@@ -10,7 +10,10 @@ struct nvif_event;
 typedef int (*nvif_event_func)(struct nvif_event *, void *repv, u32 repc);
 
 struct nvif_event {
+	const struct nvif_event_impl *impl;
+	struct nvif_event_priv *priv;
 	struct nvif_object object;
+
 	nvif_event_func func;
 };
 
diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/event.h b/drivers/gpu/drm/nouveau/include/nvkm/core/event.h
index 460459af272d..f31f0f30732a 100644
--- a/drivers/gpu/drm/nouveau/include/nvkm/core/event.h
+++ b/drivers/gpu/drm/nouveau/include/nvkm/core/event.h
@@ -4,7 +4,6 @@
 #include <core/os.h>
 struct nvkm_object;
 struct nvkm_oclass;
-struct nvkm_uevent;
 
 struct nvkm_event {
 	const struct nvkm_event_func *func;
@@ -72,6 +71,12 @@ void nvkm_event_ntfy_block(struct nvkm_event_ntfy *);
 
 typedef int (*nvkm_uevent_func)(struct nvkm_object *, u64 token, u32 bits);
 
+struct nvif_event_impl;
+struct nvif_event_priv;
+int nvkm_uevent_new_(struct nvkm_object *parent, u64 handle, struct nvkm_event *event,
+		     bool wait, int id, u32 bits, nvkm_uevent_func,
+		     const struct nvif_event_impl **, struct nvif_event_priv **);
 int nvkm_uevent_new(const struct nvkm_oclass *, void *argv, u32 argc, struct nvkm_object **);
-int nvkm_uevent_add(struct nvkm_uevent *, struct nvkm_event *, int id, u32 bits, nvkm_uevent_func);
+int nvkm_uevent_add(struct nvif_event_priv *, struct nvkm_event *, int id, u32 bits,
+		    nvkm_uevent_func);
 #endif
diff --git a/drivers/gpu/drm/nouveau/nouveau_svm.c b/drivers/gpu/drm/nouveau/nouveau_svm.c
index 43218da5d0f3..382f886e4130 100644
--- a/drivers/gpu/drm/nouveau/nouveau_svm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_svm.c
@@ -29,7 +29,6 @@
 #include <nvif/vmm.h>
 
 #include <nvif/class.h>
-#include <nvif/clb069.h>
 #include <nvif/ifc00d.h>
 
 #include <linux/sched/mm.h>
@@ -998,11 +997,14 @@ nouveau_svm_fault_buffer_ctor(struct nouveau_svm *svm, s32 oclass, int id)
 
 	INIT_WORK(&buffer->work, nouveau_svm_fault);
 
-	ret = nvif_event_ctor(&buffer->object, "svmFault", id, nouveau_svm_event, true, NULL, 0,
-			      &buffer->notify);
+	ret = buffer->impl->event.new(buffer->priv, nvif_handle(&buffer->notify.object),
+				      &buffer->notify.impl, &buffer->notify.priv);
 	if (ret)
 		return ret;
 
+	nvif_event_ctor(&buffer->object, "svmFaultEvent", buffer->id, nouveau_svm_event,
+			&buffer->notify);
+
 	buffer->fault = kvcalloc(buffer->entries, sizeof(*buffer->fault), GFP_KERNEL);
 	if (!buffer->fault)
 		return -ENOMEM;
diff --git a/drivers/gpu/drm/nouveau/nvif/event.c b/drivers/gpu/drm/nouveau/nvif/event.c
index 61ff4d6eba9f..5b8ec641703b 100644
--- a/drivers/gpu/drm/nouveau/nvif/event.c
+++ b/drivers/gpu/drm/nouveau/nvif/event.c
@@ -20,6 +20,7 @@
  * OTHER DEALINGS IN THE SOFTWARE.
  */
 #include <nvif/event.h>
+#include <nvif/driverif.h>
 #include <nvif/printf.h>
 
 #include <nvif/class.h>
@@ -28,29 +29,51 @@
 int
 nvif_event_block(struct nvif_event *event)
 {
-	if (nvif_event_constructed(event)) {
+	int ret;
+
+	if (!event->impl && nvif_event_constructed(event)) {
 		int ret = nvif_mthd(&event->object, NVIF_EVENT_V0_BLOCK, NULL, 0);
 		NVIF_ERRON(ret, &event->object, "[BLOCK]");
 		return ret;
 	}
-	return 0;
+
+	if (!event->impl)
+		return 0;
+
+	ret = event->impl->block(event->priv);
+	NVIF_ERRON(ret, &event->object, "[BLOCK]");
+	return ret;
 }
 
 int
 nvif_event_allow(struct nvif_event *event)
 {
-	if (nvif_event_constructed(event)) {
+	int ret;
+
+	if (!event->impl && nvif_event_constructed(event)) {
 		int ret = nvif_mthd(&event->object, NVIF_EVENT_V0_ALLOW, NULL, 0);
 		NVIF_ERRON(ret, &event->object, "[ALLOW]");
 		return ret;
 	}
-	return 0;
+
+	if (!event->impl)
+		return 0;
+
+	ret = event->impl->allow(event->priv);
+	NVIF_ERRON(ret, &event->object, "[ALLOW]");
+	return ret;
 }
 
 void
 nvif_event_dtor(struct nvif_event *event)
 {
-	nvif_object_dtor(&event->object);
+	if (!event->impl) {
+		nvif_object_dtor(&event->object);
+		return;
+	}
+
+	event->impl->del(event->priv);
+	event->impl = NULL;
 }
 
 int
diff --git a/drivers/gpu/drm/nouveau/nvkm/core/uevent.c b/drivers/gpu/drm/nouveau/nvkm/core/uevent.c
index 900814c9a6bd..d922eebb689c 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/uevent.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/uevent.c
@@ -22,6 +22,7 @@
 #include <core/event.h>
 #include <core/client.h>
 
+#include <nvif/driverif.h>
 #include <nvif/if000e.h>
 
 struct nvif_event_priv {
@@ -71,6 +72,38 @@ nvkm_uevent_mthd(struct nvkm_object *object, u32 mthd, void *argv, u32 argc)
 	return -EINVAL;
 }
 
+static int
+nvkm_uevent_block(struct nvif_event_priv *uevent)
+{
+	nvkm_event_ntfy_block(&uevent->ntfy);
+	atomic_set(&uevent->allowed, 0);
+	return 0;
+}
+
+static int
+nvkm_uevent_allow(struct nvif_event_priv *uevent)
+{
+	nvkm_event_ntfy_allow(&uevent->ntfy);
+	atomic_set(&uevent->allowed, 1);
+	return 0;
+}
+
+static void
+nvkm_uevent_del(struct nvif_event_priv *uevent)
+{
+	struct nvkm_object *object = &uevent->object;
+
+	nvkm_object_fini(object, false);
+	nvkm_object_del(&object);
+}
+
+static const struct nvif_event_impl
+nvkm_uevent_impl = {
+	.del = nvkm_uevent_del,
+	.allow = nvkm_uevent_allow,
+	.block = nvkm_uevent_block,
+};
+
 static int
 nvkm_uevent_fini(struct nvkm_object *object, bool suspend)
 {
@@ -154,3 +187,35 @@ nvkm_uevent_new(const struct nvkm_oclass *oclass, void *argv, u32 argc,
 	uevent->ntfy.event = NULL;
 	return parent->func->uevent(parent, &args->v0.data, argc - sizeof(args->v0), uevent);
 }
+
+int
+nvkm_uevent_new_(struct nvkm_object *parent, u64 handle, struct nvkm_event *event,
+		 bool wait, int id, u32 bits, nvkm_uevent_func func,
+		 const struct nvif_event_impl **pimpl, struct nvif_event_priv **ppriv)
+{
+	struct nvif_event_priv *uevent;
+	int ret;
+
+	uevent = kzalloc(sizeof(*uevent), GFP_KERNEL);
+	if (!uevent)
+		return -ENOMEM;
+
+	nvkm_object_ctor(&nvkm_uevent, &(struct nvkm_oclass) {}, &uevent->object);
+	uevent->object.object = handle;
+	uevent->parent = parent;
+	uevent->func = NULL;
+	uevent->wait = wait;
+	uevent->ntfy.event = NULL;
+
+	ret = nvkm_uevent_add(uevent, event, id, bits, func);
+	if (ret) {
+		kfree(uevent);
+		return ret;
+	}
+
+	*pimpl = &nvkm_uevent_impl;
+	*ppriv = uevent;
+
+	nvkm_object_link(parent, &uevent->object);
+	return 0;
+}
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/fault/user.c b/drivers/gpu/drm/nouveau/nvkm/subdev/fault/user.c
index de7a79607eff..cbe1ead00a02 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/fault/user.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/fault/user.c
@@ -26,9 +26,6 @@
 #include <core/event.h>
 #include <subdev/mmu.h>
 
-#include <nvif/clb069.h>
-#include <nvif/unpack.h>
-
 struct nvif_faultbuf_priv {
 	struct nvkm_object object;
 	struct nvkm_fault_buffer *buffer;
@@ -37,18 +34,13 @@ struct nvif_faultbuf_priv {
 };
 
 static int
-nvkm_ufault_uevent(struct nvkm_object *object, void *argv, u32 argc, struct nvkm_uevent *uevent)
+nvkm_ufault_event_new(struct nvif_faultbuf_priv *ufault, u64 token,
+		      const struct nvif_event_impl **pimpl, struct nvif_event_priv **ppriv)
 {
-	struct nvkm_fault_buffer *buffer = container_of(object, struct nvif_faultbuf_priv, object)->buffer;
-	union nvif_clb069_event_args *args = argv;
-
-	if (!uevent)
-		return 0;
-	if (argc != sizeof(args->vn))
-		return -ENOSYS;
+	struct nvkm_fault_buffer *buffer = ufault->buffer;
 
-	return nvkm_uevent_add(uevent, &buffer->fault->event, buffer->id,
-			       NVKM_FAULT_BUFFER_EVENT_PENDING, NULL);
+	return nvkm_uevent_new_(&ufault->object, token, &buffer->fault->event, true, buffer->id,
+				NVKM_FAULT_BUFFER_EVENT_PENDING, NULL, pimpl, ppriv);
 }
 
 static void
@@ -63,6 +55,7 @@ nvkm_ufault_del(struct nvif_faultbuf_priv *ufault)
 static const struct nvif_faultbuf_impl
 nvkm_ufault_impl = {
 	.del = nvkm_ufault_del,
+	.event.new = nvkm_ufault_event_new,
 };
 
 static int
@@ -96,7 +89,6 @@ nvkm_ufault = {
 	.dtor = nvkm_ufault_dtor,
 	.init = nvkm_ufault_init,
 	.fini = nvkm_ufault_fini,
-	.uevent = nvkm_ufault_uevent,
 };
 
 int
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 098/156] drm/nouveau/nvif: remove fault buffer from object rb
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (96 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 097/156] drm/nouveau/nvif: rework fault buffer "new event" api Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 099/156] drm/nouveau/nvif: rework device "new disp" api Ben Skeggs
                   ` (59 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- no more users

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/include/nvif/driverif.h | 3 +--
 drivers/gpu/drm/nouveau/nouveau_svm.c           | 3 +--
 drivers/gpu/drm/nouveau/nvkm/device/user.c      | 6 +++---
 3 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 81375819c787..42e6324ddfe3 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -277,8 +277,7 @@ struct nvif_device_impl {
 	struct {
 		s32 oclass;
 		int (*new)(struct nvif_device_priv *,
-			   const struct nvif_faultbuf_impl **, struct nvif_faultbuf_priv **,
-			   u64 handle);
+			   const struct nvif_faultbuf_impl **, struct nvif_faultbuf_priv **);
 	} faultbuf;
 
 	struct {
diff --git a/drivers/gpu/drm/nouveau/nouveau_svm.c b/drivers/gpu/drm/nouveau/nouveau_svm.c
index 382f886e4130..534448f82daa 100644
--- a/drivers/gpu/drm/nouveau/nouveau_svm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_svm.c
@@ -979,8 +979,7 @@ nouveau_svm_fault_buffer_ctor(struct nouveau_svm *svm, s32 oclass, int id)
 
 	buffer->id = id;
 
-	ret = drm->device.impl->faultbuf.new(drm->device.priv, &buffer->impl, &buffer->priv,
-					     nvif_handle(&buffer->object));
+	ret = drm->device.impl->faultbuf.new(drm->device.priv, &buffer->impl, &buffer->priv);
 	if (ret) {
 		SVM_ERR(svm, "Fault buffer allocation failed: %d", ret);
 		return ret;
diff --git a/drivers/gpu/drm/nouveau/nvkm/device/user.c b/drivers/gpu/drm/nouveau/nvkm/device/user.c
index b4604ce1fcbb..eb33ab81d7e1 100644
--- a/drivers/gpu/drm/nouveau/nvkm/device/user.c
+++ b/drivers/gpu/drm/nouveau/nvkm/device/user.c
@@ -44,8 +44,7 @@ struct nvif_device_priv {
 
 static int
 nvkm_udevice_fault_new(struct nvif_device_priv *udev,
-		       const struct nvif_faultbuf_impl **pimpl, struct nvif_faultbuf_priv **ppriv,
-		       u64 handle)
+		       const struct nvif_faultbuf_impl **pimpl, struct nvif_faultbuf_priv **ppriv)
 {
 	struct nvkm_object *object;
 	int ret;
@@ -54,7 +53,8 @@ nvkm_udevice_fault_new(struct nvif_device_priv *udev,
 	if (ret)
 		return ret;
 
-	return nvkm_object_link_rb(udev->object.client, &udev->object, handle, object);
+	nvkm_object_link(&udev->object, object);
+	return 0;
 }
 
 static int
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 099/156] drm/nouveau/nvif: rework device "new disp" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (97 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 098/156] drm/nouveau/nvif: remove fault buffer from object rb Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 100/156] drm/nouveau/nvif: rework disp "sclass" api Ben Skeggs
                   ` (58 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interface

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/include/nvif/disp.h   |  5 ++
 .../gpu/drm/nouveau/include/nvif/driverif.h   | 20 ++++++++
 drivers/gpu/drm/nouveau/include/nvif/if0010.h | 14 -----
 drivers/gpu/drm/nouveau/include/nvif/object.h | 16 ------
 drivers/gpu/drm/nouveau/nvif/disp.c           | 26 +++++-----
 drivers/gpu/drm/nouveau/nvkm/device/user.c    | 20 +++++++-
 .../gpu/drm/nouveau/nvkm/engine/disp/base.c   | 27 ----------
 .../gpu/drm/nouveau/nvkm/engine/disp/priv.h   |  1 -
 .../gpu/drm/nouveau/nvkm/engine/disp/udisp.c  | 51 +++++++++++++------
 .../gpu/drm/nouveau/nvkm/engine/disp/udisp.h  |  6 +++
 10 files changed, 97 insertions(+), 89 deletions(-)
 delete mode 100644 drivers/gpu/drm/nouveau/include/nvif/if0010.h

diff --git a/drivers/gpu/drm/nouveau/include/nvif/disp.h b/drivers/gpu/drm/nouveau/include/nvif/disp.h
index c4f428f268ea..06f56cc63893 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/disp.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/disp.h
@@ -4,7 +4,12 @@
 struct nvif_device;
 
 struct nvif_disp {
+	const struct nvif_disp_impl *impl;
+	struct nvif_disp_priv *priv;
 	struct nvif_object object;
+
+	struct nvif_device *device;
+
 	unsigned long conn_mask;
 	unsigned long outp_mask;
 	unsigned long head_mask;
diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 42e6324ddfe3..e479e8114605 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -10,6 +10,7 @@ struct nvif_mmu_priv;
 struct nvif_mem_priv;
 struct nvif_vmm_priv;
 struct nvif_faultbuf_priv;
+struct nvif_disp_priv;
 
 struct nvif_driver {
 	const char *name;
@@ -216,6 +217,22 @@ struct nvif_faultbuf_impl {
 	} event;
 };
 
+struct nvif_disp_impl {
+	void (*del)(struct nvif_disp_priv *);
+
+	struct {
+		u32 mask;
+	} conn;
+
+	struct {
+		u32 mask;
+	} outp;
+
+	struct {
+		u32 mask;
+	} head;
+};
+
 struct nvif_device_impl {
 	void (*del)(struct nvif_device_priv *);
 
@@ -282,6 +299,9 @@ struct nvif_device_impl {
 
 	struct {
 		s32 oclass;
+		int (*new)(struct nvif_device_priv *,
+			   const struct nvif_disp_impl **, struct nvif_disp_priv **,
+			   u64 handle);
 	} disp;
 
 	struct nvif_device_impl_fifo {
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0010.h b/drivers/gpu/drm/nouveau/include/nvif/if0010.h
deleted file mode 100644
index 4c835bbe6fe3..000000000000
--- a/drivers/gpu/drm/nouveau/include/nvif/if0010.h
+++ /dev/null
@@ -1,14 +0,0 @@
-/* SPDX-License-Identifier: MIT */
-#ifndef __NVIF_IF0010_H__
-#define __NVIF_IF0010_H__
-
-union nvif_disp_args {
-	struct nvif_disp_v0 {
-		__u8 version;
-		__u8 pad01[3];
-		__u32 conn_mask;
-		__u32 outp_mask;
-		__u32 head_mask;
-	} v0;
-};
-#endif
diff --git a/drivers/gpu/drm/nouveau/include/nvif/object.h b/drivers/gpu/drm/nouveau/include/nvif/object.h
index b3e66425f310..819ae1c9729d 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/object.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/object.h
@@ -111,22 +111,6 @@ struct nvif_mclass {
 	ret;                                                                   \
 })
 
-#define nvif_sclass(o,m,u) ({                                                  \
-	const typeof(m[0]) *_mclass = (m);                                     \
-	s32 _oclass = (u);                                                     \
-	int _cid;                                                              \
-	if (_oclass) {                                                         \
-		for (_cid = 0; _mclass[_cid].oclass; _cid++) {                 \
-			if (_mclass[_cid].oclass == _oclass)                   \
-				break;                                         \
-		}                                                              \
-		_cid = _mclass[_cid].oclass ? _cid : -ENOSYS;                  \
-	} else {                                                               \
-		_cid = nvif_mclass((o), _mclass);                              \
-	}                                                                      \
-	_cid;                                                                  \
-})
-
 #define NVIF_RD32_(p,o,dr)   nvif_rd32((p), (o) + (dr))
 #define NVIF_WR32_(p,o,dr,f) nvif_wr32((p), (o) + (dr), (f))
 #define NVIF_RD32(p,A...) DRF_RD(NVIF_RD32_,                  (p), 0, ##A)
diff --git a/drivers/gpu/drm/nouveau/nvif/disp.c b/drivers/gpu/drm/nouveau/nvif/disp.c
index 875c63877468..f3c425daf7d5 100644
--- a/drivers/gpu/drm/nouveau/nvif/disp.c
+++ b/drivers/gpu/drm/nouveau/nvif/disp.c
@@ -24,23 +24,23 @@
 #include <nvif/printf.h>
 
 #include <nvif/class.h>
-#include <nvif/if0010.h>
 
 void
 nvif_disp_dtor(struct nvif_disp *disp)
 {
-	nvif_object_dtor(&disp->object);
+	if (!disp->impl)
+		return;
+
+	disp->impl->del(disp->priv);
+	disp->impl = NULL;
 }
 
 int
 nvif_disp_ctor(struct nvif_device *device, const char *name, struct nvif_disp *disp)
 {
 	const u32 oclass = device->impl->disp.oclass;
-	struct nvif_disp_v0 args;
 	int ret;
 
-	disp->object.client = NULL;
-
 	switch (oclass) {
 	case AD102_DISP:
 	case GA102_DISP:
@@ -65,18 +65,16 @@ nvif_disp_ctor(struct nvif_device *device, const char *name, struct nvif_disp *d
 		return -ENODEV;
 	}
 
-	args.version = 0;
-
-	ret = nvif_object_ctor(&device->object, name ?: "nvifDisp", 0,
-			       oclass, &args, sizeof(args), &disp->object);
+	ret = device->impl->disp.new(device->priv, &disp->impl, &disp->priv,
+				     nvif_handle(&disp->object));
 	NVIF_ERRON(ret, &device->object, "[NEW disp%04x]", oclass);
 	if (ret)
 		return ret;
 
-	NVIF_DEBUG(&disp->object, "[NEW] conn_mask:%08x outp_mask:%08x head_mask:%08x",
-		   args.conn_mask, args.outp_mask, args.head_mask);
-	disp->conn_mask = args.conn_mask;
-	disp->outp_mask = args.outp_mask;
-	disp->head_mask = args.head_mask;
+	nvif_object_ctor(&device->object, name ?: "nvifDisp", 0, oclass, &disp->object);
+	disp->device = device;
+	disp->conn_mask = disp->impl->conn.mask;
+	disp->outp_mask = disp->impl->outp.mask;
+	disp->head_mask = disp->impl->head.mask;
 	return 0;
 }
diff --git a/drivers/gpu/drm/nouveau/nvkm/device/user.c b/drivers/gpu/drm/nouveau/nvkm/device/user.c
index eb33ab81d7e1..3c7c0d1e6adb 100644
--- a/drivers/gpu/drm/nouveau/nvkm/device/user.c
+++ b/drivers/gpu/drm/nouveau/nvkm/device/user.c
@@ -33,6 +33,7 @@
 #include <subdev/mmu/ummu.h>
 #include <subdev/vfn/uvfn.h>
 #include <engine/disp/priv.h>
+#include <engine/disp/udisp.h>
 #include <engine/fifo/ufifo.h>
 
 struct nvif_device_priv {
@@ -93,6 +94,21 @@ nvkm_udevice_time(struct nvif_device_priv *udev)
 	return nvkm_timer_read(udev->device->timer);
 }
 
+static int
+nvkm_udevice_disp_new(struct nvif_device_priv *udev,
+		      const struct nvif_disp_impl **pimpl, struct nvif_disp_priv **ppriv,
+		      u64 handle)
+{
+	struct nvkm_object *object;
+	int ret;
+
+	ret = nvkm_udisp_new(udev->device, pimpl, ppriv, &object);
+	if (ret)
+		return ret;
+
+	return nvkm_object_link_rb(udev->object.client, &udev->object, handle, object);
+}
+
 static int
 nvkm_udevice_mmu_new(struct nvif_device_priv *udev,
 		     const struct nvif_mmu_impl **pimpl, struct nvif_mmu_priv **ppriv)
@@ -185,8 +201,7 @@ nvkm_udevice_child_get(struct nvkm_object *object, int index,
 	struct nvkm_device *device = udev->device;
 	struct nvkm_engine *engine;
 	u64 mask = (1ULL << NVKM_ENGINE_DMAOBJ) |
-		   (1ULL << NVKM_ENGINE_FIFO) |
-		   (1ULL << NVKM_ENGINE_DISP);
+		   (1ULL << NVKM_ENGINE_FIFO);
 	const struct nvkm_device_oclass *sclass = NULL;
 	int i;
 
@@ -317,6 +332,7 @@ nvkm_udevice_new(struct nvkm_device *device,
 
 	if (device->disp) {
 		udev->impl.disp.oclass = device->disp->func->user.root.oclass;
+		udev->impl.disp.new = nvkm_udevice_disp_new;
 	}
 
 	if (device->fifo) {
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c
index 6850c703ff2d..dab603f17e2d 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c
@@ -65,32 +65,6 @@ nvkm_disp_vblank(struct nvkm_disp *disp, int head)
 	nvkm_event_ntfy(&disp->vblank, head, NVKM_DISP_HEAD_EVENT_VBLANK);
 }
 
-static int
-nvkm_disp_class_new(struct nvkm_device *device,
-		    const struct nvkm_oclass *oclass, void *data, u32 size,
-		    struct nvkm_object **pobject)
-{
-	return nvkm_udisp_new(oclass, data, size, pobject);
-}
-
-static const struct nvkm_device_oclass
-nvkm_disp_sclass = {
-	.ctor = nvkm_disp_class_new,
-};
-
-static int
-nvkm_disp_class_get(struct nvkm_oclass *oclass, int index,
-		    const struct nvkm_device_oclass **class)
-{
-	struct nvkm_disp *disp = nvkm_disp(oclass->engine);
-	if (index == 0) {
-		oclass->base = (struct nvkm_sclass) { 0, 0, disp->func->user.root.oclass };
-		*class = &nvkm_disp_sclass;
-		return 0;
-	}
-	return 1;
-}
-
 static void
 nvkm_disp_intr(struct nvkm_engine *engine)
 {
@@ -222,7 +196,6 @@ nvkm_disp = {
 	.init = nvkm_disp_init,
 	.fini = nvkm_disp_fini,
 	.intr = nvkm_disp_intr,
-	.base.sclass = nvkm_disp_class_get,
 };
 
 int
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/priv.h b/drivers/gpu/drm/nouveau/nvkm/engine/disp/priv.h
index 82b16cc9212a..324a7971a0eb 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/priv.h
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/priv.h
@@ -90,7 +90,6 @@ void nv50_disp_chan_uevent_send(struct nvkm_disp *, int);
 extern const struct nvkm_event_func gf119_disp_chan_uevent;
 extern const struct nvkm_event_func gv100_disp_chan_uevent;
 
-int nvkm_udisp_new(const struct nvkm_oclass *, void *, u32, struct nvkm_object **);
 int nvkm_uconn_new(const struct nvkm_oclass *, void *, u32, struct nvkm_object **);
 int nvkm_uoutp_new(const struct nvkm_oclass *, void *, u32, struct nvkm_object **);
 int nvkm_uhead_new(const struct nvkm_oclass *, void *, u32, struct nvkm_object **);
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c
index 750db6a1eb44..06e465edf3e9 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c
@@ -26,7 +26,6 @@
 #include "outp.h"
 
 #include <nvif/class.h>
-#include <nvif/if0010.h>
 
 static int
 nvkm_udisp_sclass(struct nvkm_object *object, int index, struct nvkm_oclass *sclass)
@@ -102,15 +101,32 @@ nvkm_udisp_sclass(struct nvkm_object *object, int index, struct nvkm_oclass *scl
 	return -EINVAL;
 }
 
+static void
+nvkm_udisp_del(struct nvif_disp_priv *udisp)
+{
+	struct nvkm_object *object = &udisp->object;
+
+	nvkm_object_fini(object, false);
+	nvkm_object_del(&object);
+}
+
+static const struct nvif_disp_impl
+nvkm_udisp_impl = {
+	.del = nvkm_udisp_del,
+};
+
 static void *
 nvkm_udisp_dtor(struct nvkm_object *object)
 {
 	struct nvif_disp_priv *udisp = container_of(object, typeof(*udisp), object);
 	struct nvkm_disp *disp = udisp->disp;
+	struct nvkm_engine *engine = &disp->engine;
 
 	spin_lock(&disp->user.lock);
 	disp->user.allocated = false;
 	spin_unlock(&disp->user.lock);
+
+	nvkm_engine_unref(&engine);
 	return udisp;
 }
 
@@ -121,46 +137,51 @@ nvkm_udisp = {
 };
 
 int
-nvkm_udisp_new(const struct nvkm_oclass *oclass, void *argv, u32 argc, struct nvkm_object **pobject)
+nvkm_udisp_new(struct nvkm_device *device, const struct nvif_disp_impl **pimpl,
+	       struct nvif_disp_priv **ppriv, struct nvkm_object **pobject)
 {
-	struct nvkm_disp *disp = nvkm_disp(oclass->engine);
+	struct nvkm_disp *disp = device->disp;
 	struct nvkm_conn *conn;
 	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;
+	struct nvkm_engine *engine;
 
 	udisp = kzalloc(sizeof(*udisp), GFP_KERNEL);
 	if (!udisp)
 		return -ENOMEM;
 
+	engine = nvkm_engine_ref(&disp->engine);
+	if (IS_ERR(engine)) {
+		kfree(udisp);
+		return PTR_ERR(engine);
+	}
+
 	spin_lock(&disp->user.lock);
 	if (disp->user.allocated) {
 		spin_unlock(&disp->user.lock);
+		nvkm_engine_unref(&engine);
 		kfree(udisp);
 		return -EBUSY;
 	}
 	disp->user.allocated = true;
 	spin_unlock(&disp->user.lock);
 
-	nvkm_object_ctor(&nvkm_udisp, oclass, &udisp->object);
+	nvkm_object_ctor(&nvkm_udisp, &(struct nvkm_oclass) {}, &udisp->object);
 	udisp->disp = disp;
-	*pobject = &udisp->object;
+	udisp->impl = nvkm_udisp_impl;
 
-	args->v0.conn_mask = 0;
 	list_for_each_entry(conn, &disp->conns, head)
-		args->v0.conn_mask |= BIT(conn->index);
+		udisp->impl.conn.mask |= BIT(conn->index);
 
-	args->v0.outp_mask = 0;
 	list_for_each_entry(outp, &disp->outps, head)
-		args->v0.outp_mask |= BIT(outp->index);
+		udisp->impl.outp.mask |= BIT(outp->index);
 
-	args->v0.head_mask = 0;
 	list_for_each_entry(head, &disp->heads, head)
-		args->v0.head_mask |= BIT(head->id);
+		udisp->impl.head.mask |= BIT(head->id);
 
+	*pimpl = &udisp->impl;
+	*ppriv = udisp;
+	*pobject = &udisp->object;
 	return 0;
 }
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.h b/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.h
index 2918ecbca5d3..5baf1fe35f88 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.h
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.h
@@ -3,9 +3,15 @@
 #define __NVKM_UDISP_H__
 #include <core/object.h>
 #include "priv.h"
+#include <nvif/driverif.h>
 
 struct nvif_disp_priv {
 	struct nvkm_object object;
 	struct nvkm_disp *disp;
+
+	struct nvif_disp_impl impl;
 };
+
+int nvkm_udisp_new(struct nvkm_device *, const struct nvif_disp_impl **, struct nvif_disp_priv **,
+		   struct nvkm_object **);
 #endif
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 100/156] drm/nouveau/nvif: rework disp "sclass" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (98 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 099/156] drm/nouveau/nvif: rework device "new disp" api Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 101/156] drm/nouveau/nvif: rework disp "new caps" api Ben Skeggs
                   ` (57 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interface

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/dispnv50/base.c       | 33 +++++--------
 drivers/gpu/drm/nouveau/dispnv50/core.c       | 49 ++++++++-----------
 drivers/gpu/drm/nouveau/dispnv50/curs.c       | 35 ++++++-------
 drivers/gpu/drm/nouveau/dispnv50/oimm.c       | 29 +++++------
 drivers/gpu/drm/nouveau/dispnv50/ovly.c       | 32 +++++-------
 drivers/gpu/drm/nouveau/dispnv50/wimm.c       | 25 ++++------
 drivers/gpu/drm/nouveau/dispnv50/wndw.c       | 27 ++++------
 .../gpu/drm/nouveau/include/nvif/driverif.h   | 18 +++++++
 drivers/gpu/drm/nouveau/include/nvif/object.h | 29 -----------
 .../gpu/drm/nouveau/nvkm/engine/disp/udisp.c  | 20 ++++++++
 10 files changed, 129 insertions(+), 168 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv50/base.c b/drivers/gpu/drm/nouveau/dispnv50/base.c
index 7c752acf2b48..db0b42c6243e 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/base.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/base.c
@@ -26,28 +26,21 @@
 int
 nv50_base_new(struct nouveau_drm *drm, int head, struct nv50_wndw **pwndw)
 {
-	struct {
-		s32 oclass;
-		int version;
-		int (*new)(struct nouveau_drm *, int, s32, struct nv50_wndw **);
-	} bases[] = {
-		{ GK110_DISP_BASE_CHANNEL_DMA, 0, base917c_new },
-		{ GK104_DISP_BASE_CHANNEL_DMA, 0, base917c_new },
-		{ GF110_DISP_BASE_CHANNEL_DMA, 0, base907c_new },
-		{ GT214_DISP_BASE_CHANNEL_DMA, 0, base827c_new },
-		{ GT200_DISP_BASE_CHANNEL_DMA, 0, base827c_new },
-		{   G82_DISP_BASE_CHANNEL_DMA, 0, base827c_new },
-		{  NV50_DISP_BASE_CHANNEL_DMA, 0, base507c_new },
-		{}
-	};
-	struct nv50_disp *disp = nv50_disp(drm->dev);
-	int cid;
+	int (*ctor)(struct nouveau_drm *, int, s32, struct nv50_wndw **);
+	struct nvif_disp *disp = nv50_disp(drm->dev)->disp;
 
-	cid = nvif_mclass(&disp->disp->object, bases);
-	if (cid < 0) {
+	switch (disp->impl->chan.base.oclass) {
+	case GK110_DISP_BASE_CHANNEL_DMA: ctor = base917c_new; break;
+	case GK104_DISP_BASE_CHANNEL_DMA: ctor = base917c_new; break;
+	case GF110_DISP_BASE_CHANNEL_DMA: ctor = base907c_new; break;
+	case GT214_DISP_BASE_CHANNEL_DMA: ctor = base827c_new; break;
+	case GT200_DISP_BASE_CHANNEL_DMA: ctor = base827c_new; break;
+	case   G82_DISP_BASE_CHANNEL_DMA: ctor = base827c_new; break;
+	case  NV50_DISP_BASE_CHANNEL_DMA: ctor = base507c_new; break;
+	default:
 		NV_ERROR(drm, "No supported base class\n");
-		return cid;
+		return -ENODEV;
 	}
 
-	return bases[cid].new(drm, head, bases[cid].oclass, pwndw);
+	return ctor(drm, head, disp->impl->chan.base.oclass, pwndw);
 }
diff --git a/drivers/gpu/drm/nouveau/dispnv50/core.c b/drivers/gpu/drm/nouveau/dispnv50/core.c
index a9c3e53ef909..7d5438355715 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/core.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/core.c
@@ -43,41 +43,34 @@ nv50_core_del(struct nv50_core **pcore)
 int
 nv50_core_new(struct nouveau_drm *drm, struct nv50_core **pcore)
 {
-	struct {
-		s32 oclass;
-		int version;
-		int (*new)(struct nouveau_drm *, s32, struct nv50_core **);
-	} cores[] = {
-		{ AD102_DISP_CORE_CHANNEL_DMA, 0, corec57d_new },
-		{ GA102_DISP_CORE_CHANNEL_DMA, 0, corec57d_new },
-		{ TU102_DISP_CORE_CHANNEL_DMA, 0, corec57d_new },
-		{ GV100_DISP_CORE_CHANNEL_DMA, 0, corec37d_new },
-		{ GP102_DISP_CORE_CHANNEL_DMA, 0, core917d_new },
-		{ GP100_DISP_CORE_CHANNEL_DMA, 0, core917d_new },
-		{ GM200_DISP_CORE_CHANNEL_DMA, 0, core917d_new },
-		{ GM107_DISP_CORE_CHANNEL_DMA, 0, core917d_new },
-		{ GK110_DISP_CORE_CHANNEL_DMA, 0, core917d_new },
-		{ GK104_DISP_CORE_CHANNEL_DMA, 0, core917d_new },
-		{ GF110_DISP_CORE_CHANNEL_DMA, 0, core907d_new },
-		{ GT214_DISP_CORE_CHANNEL_DMA, 0, core827d_new },
-		{ GT206_DISP_CORE_CHANNEL_DMA, 0, core827d_new },
-		{ GT200_DISP_CORE_CHANNEL_DMA, 0, core827d_new },
-		{   G82_DISP_CORE_CHANNEL_DMA, 0, core827d_new },
-		{  NV50_DISP_CORE_CHANNEL_DMA, 0, core507d_new },
-		{}
-	};
+	int (*ctor)(struct nouveau_drm *, s32, struct nv50_core **);
 	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) {
+	switch (disp->disp->impl->chan.core.oclass) {
+	case AD102_DISP_CORE_CHANNEL_DMA: ctor = corec57d_new; break;
+	case GA102_DISP_CORE_CHANNEL_DMA: ctor = corec57d_new; break;
+	case TU102_DISP_CORE_CHANNEL_DMA: ctor = corec57d_new; break;
+	case GV100_DISP_CORE_CHANNEL_DMA: ctor = corec37d_new; break;
+	case GP102_DISP_CORE_CHANNEL_DMA: ctor = core917d_new; break;
+	case GP100_DISP_CORE_CHANNEL_DMA: ctor = core917d_new; break;
+	case GM200_DISP_CORE_CHANNEL_DMA: ctor = core917d_new; break;
+	case GM107_DISP_CORE_CHANNEL_DMA: ctor = core917d_new; break;
+	case GK110_DISP_CORE_CHANNEL_DMA: ctor = core917d_new; break;
+	case GK104_DISP_CORE_CHANNEL_DMA: ctor = core917d_new; break;
+	case GF110_DISP_CORE_CHANNEL_DMA: ctor = core907d_new; break;
+	case GT214_DISP_CORE_CHANNEL_DMA: ctor = core827d_new; break;
+	case GT206_DISP_CORE_CHANNEL_DMA: ctor = core827d_new; break;
+	case GT200_DISP_CORE_CHANNEL_DMA: ctor = core827d_new; break;
+	case   G82_DISP_CORE_CHANNEL_DMA: ctor = core827d_new; break;
+	case  NV50_DISP_CORE_CHANNEL_DMA: ctor = core507d_new; break;
+	default:
 		NV_ERROR(drm, "No supported core channel class\n");
-		return cid;
+		return -ENODEV;
 	}
 
-	ret = cores[cid].new(drm, cores[cid].oclass, &core);
+	ret = ctor(drm, disp->disp->impl->chan.core.oclass, &core);
 	*pcore = core;
 	if (ret)
 		return ret;
diff --git a/drivers/gpu/drm/nouveau/dispnv50/curs.c b/drivers/gpu/drm/nouveau/dispnv50/curs.c
index 31d8b2e4791d..8d1026c6baec 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/curs.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/curs.c
@@ -26,29 +26,22 @@
 int
 nv50_curs_new(struct nouveau_drm *drm, int head, struct nv50_wndw **pwndw)
 {
-	struct {
-		s32 oclass;
-		int version;
-		int (*new)(struct nouveau_drm *, int, s32, struct nv50_wndw **);
-	} curses[] = {
-		{ GA102_DISP_CURSOR, 0, cursc37a_new },
-		{ TU102_DISP_CURSOR, 0, cursc37a_new },
-		{ GV100_DISP_CURSOR, 0, cursc37a_new },
-		{ GK104_DISP_CURSOR, 0, curs907a_new },
-		{ GF110_DISP_CURSOR, 0, curs907a_new },
-		{ GT214_DISP_CURSOR, 0, curs507a_new },
-		{   G82_DISP_CURSOR, 0, curs507a_new },
-		{  NV50_DISP_CURSOR, 0, curs507a_new },
-		{}
-	};
-	struct nv50_disp *disp = nv50_disp(drm->dev);
-	int cid;
+	int (*ctor)(struct nouveau_drm *, int, s32, struct nv50_wndw **);
+	struct nvif_disp *disp = nv50_disp(drm->dev)->disp;
 
-	cid = nvif_mclass(&disp->disp->object, curses);
-	if (cid < 0) {
+	switch (disp->impl->chan.curs.oclass) {
+	case GA102_DISP_CURSOR: ctor = cursc37a_new; break;
+	case TU102_DISP_CURSOR: ctor = cursc37a_new; break;
+	case GV100_DISP_CURSOR: ctor = cursc37a_new; break;
+	case GK104_DISP_CURSOR: ctor = curs907a_new; break;
+	case GF110_DISP_CURSOR: ctor = curs907a_new; break;
+	case GT214_DISP_CURSOR: ctor = curs507a_new; break;
+	case   G82_DISP_CURSOR: ctor = curs507a_new; break;
+	case  NV50_DISP_CURSOR: ctor = curs507a_new; break;
+	default:
 		NV_ERROR(drm, "No supported cursor immediate class\n");
-		return cid;
+		return -ENODEV;
 	}
 
-	return curses[cid].new(drm, head, curses[cid].oclass, pwndw);
+	return ctor(drm, head, disp->impl->chan.curs.oclass, pwndw);
 }
diff --git a/drivers/gpu/drm/nouveau/dispnv50/oimm.c b/drivers/gpu/drm/nouveau/dispnv50/oimm.c
index 2a2841d344c8..4a06cd293cb5 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/oimm.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/oimm.c
@@ -26,26 +26,19 @@
 int
 nv50_oimm_init(struct nouveau_drm *drm, struct nv50_wndw *wndw)
 {
-	static const struct {
-		s32 oclass;
-		int version;
-		int (*init)(struct nouveau_drm *, s32, struct nv50_wndw *);
-	} oimms[] = {
-		{ GK104_DISP_OVERLAY, 0, oimm507b_init },
-		{ GF110_DISP_OVERLAY, 0, oimm507b_init },
-		{ GT214_DISP_OVERLAY, 0, oimm507b_init },
-		{   G82_DISP_OVERLAY, 0, oimm507b_init },
-		{  NV50_DISP_OVERLAY, 0, oimm507b_init },
-		{}
-	};
-	struct nv50_disp *disp = nv50_disp(drm->dev);
-	int cid;
+	int (*ctor)(struct nouveau_drm *, s32, struct nv50_wndw *);
+	struct nvif_disp *disp = nv50_disp(drm->dev)->disp;
 
-	cid = nvif_mclass(&disp->disp->object, oimms);
-	if (cid < 0) {
+	switch (disp->impl->chan.oimm.oclass) {
+	case GK104_DISP_OVERLAY: ctor = oimm507b_init; break;
+	case GF110_DISP_OVERLAY: ctor = oimm507b_init; break;
+	case GT214_DISP_OVERLAY: ctor = oimm507b_init; break;
+	case   G82_DISP_OVERLAY: ctor = oimm507b_init; break;
+	case  NV50_DISP_OVERLAY: ctor = oimm507b_init; break;
+	default:
 		NV_ERROR(drm, "No supported overlay immediate class\n");
-		return cid;
+		return -ENODEV;
 	}
 
-	return oimms[cid].init(drm, oimms[cid].oclass, wndw);
+	return ctor(drm, disp->impl->chan.oimm.oclass, wndw);
 }
diff --git a/drivers/gpu/drm/nouveau/dispnv50/ovly.c b/drivers/gpu/drm/nouveau/dispnv50/ovly.c
index 90c246d47604..029c86a53c1f 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/ovly.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/ovly.c
@@ -27,29 +27,23 @@
 int
 nv50_ovly_new(struct nouveau_drm *drm, int head, struct nv50_wndw **pwndw)
 {
-	static const struct {
-		s32 oclass;
-		int version;
-		int (*new)(struct nouveau_drm *, int, s32, struct nv50_wndw **);
-	} ovlys[] = {
-		{ GK104_DISP_OVERLAY_CONTROL_DMA, 0, ovly917e_new },
-		{ GF110_DISP_OVERLAY_CONTROL_DMA, 0, ovly907e_new },
-		{ GT214_DISP_OVERLAY_CHANNEL_DMA, 0, ovly827e_new },
-		{ GT200_DISP_OVERLAY_CHANNEL_DMA, 0, ovly827e_new },
-		{   G82_DISP_OVERLAY_CHANNEL_DMA, 0, ovly827e_new },
-		{  NV50_DISP_OVERLAY_CHANNEL_DMA, 0, ovly507e_new },
-		{}
-	};
-	struct nv50_disp *disp = nv50_disp(drm->dev);
-	int cid, ret;
+	int (*ctor)(struct nouveau_drm *, int, s32, struct nv50_wndw **);
+	struct nvif_disp *disp = nv50_disp(drm->dev)->disp;
+	int ret;
 
-	cid = nvif_mclass(&disp->disp->object, ovlys);
-	if (cid < 0) {
+	switch (disp->impl->chan.ovly.oclass) {
+	case GK104_DISP_OVERLAY_CONTROL_DMA: ctor = ovly917e_new; break;
+	case GF110_DISP_OVERLAY_CONTROL_DMA: ctor = ovly907e_new; break;
+	case GT214_DISP_OVERLAY_CHANNEL_DMA: ctor = ovly827e_new; break;
+	case GT200_DISP_OVERLAY_CHANNEL_DMA: ctor = ovly827e_new; break;
+	case   G82_DISP_OVERLAY_CHANNEL_DMA: ctor = ovly827e_new; break;
+	case  NV50_DISP_OVERLAY_CHANNEL_DMA: ctor = ovly507e_new; break;
+	default:
 		NV_ERROR(drm, "No supported overlay class\n");
-		return cid;
+		return -ENODEV;
 	}
 
-	ret = ovlys[cid].new(drm, head, ovlys[cid].oclass, pwndw);
+	ret = ctor(drm, head, disp->impl->chan.ovly.oclass, pwndw);
 	if (ret)
 		return ret;
 
diff --git a/drivers/gpu/drm/nouveau/dispnv50/wimm.c b/drivers/gpu/drm/nouveau/dispnv50/wimm.c
index 566fbddfc8d7..c94830cf07cb 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/wimm.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/wimm.c
@@ -26,24 +26,17 @@
 int
 nv50_wimm_init(struct nouveau_drm *drm, struct nv50_wndw *wndw)
 {
-	struct {
-		s32 oclass;
-		int version;
-		int (*init)(struct nouveau_drm *, s32, struct nv50_wndw *);
-	} wimms[] = {
-		{ GA102_DISP_WINDOW_IMM_CHANNEL_DMA, 0, wimmc37b_init },
-		{ TU102_DISP_WINDOW_IMM_CHANNEL_DMA, 0, wimmc37b_init },
-		{ GV100_DISP_WINDOW_IMM_CHANNEL_DMA, 0, wimmc37b_init },
-		{}
-	};
-	struct nv50_disp *disp = nv50_disp(drm->dev);
-	int cid;
+	int (*ctor)(struct nouveau_drm *, s32, struct nv50_wndw *);
+	struct nvif_disp *disp = nv50_disp(drm->dev)->disp;
 
-	cid = nvif_mclass(&disp->disp->object, wimms);
-	if (cid < 0) {
+	switch (disp->impl->chan.wimm.oclass) {
+	case GA102_DISP_WINDOW_IMM_CHANNEL_DMA: ctor = wimmc37b_init; break;
+	case TU102_DISP_WINDOW_IMM_CHANNEL_DMA: ctor = wimmc37b_init; break;
+	case GV100_DISP_WINDOW_IMM_CHANNEL_DMA: ctor = wimmc37b_init; break;
+	default:
 		NV_ERROR(drm, "No supported window immediate class\n");
-		return cid;
+		return -ENODEV;
 	}
 
-	return wimms[cid].init(drm, wimms[cid].oclass, wndw);
+	return ctor(drm, disp->impl->chan.wimm.oclass, wndw);
 }
diff --git a/drivers/gpu/drm/nouveau/dispnv50/wndw.c b/drivers/gpu/drm/nouveau/dispnv50/wndw.c
index 19606755daf5..6fb6d2252e15 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/wndw.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/wndw.c
@@ -810,27 +810,20 @@ int
 nv50_wndw_new(struct nouveau_drm *drm, enum drm_plane_type type, int index,
 	      struct nv50_wndw **pwndw)
 {
-	struct {
-		s32 oclass;
-		int version;
-		int (*new)(struct nouveau_drm *, enum drm_plane_type,
-			   int, s32, struct nv50_wndw **);
-	} wndws[] = {
-		{ GA102_DISP_WINDOW_CHANNEL_DMA, 0, wndwc67e_new },
-		{ TU102_DISP_WINDOW_CHANNEL_DMA, 0, wndwc57e_new },
-		{ GV100_DISP_WINDOW_CHANNEL_DMA, 0, wndwc37e_new },
-		{}
-	};
-	struct nv50_disp *disp = nv50_disp(drm->dev);
-	int cid, ret;
+	int (*ctor)(struct nouveau_drm *, enum drm_plane_type, int, s32, struct nv50_wndw **);
+	struct nvif_disp *disp = nv50_disp(drm->dev)->disp;
+	int ret;
 
-	cid = nvif_mclass(&disp->disp->object, wndws);
-	if (cid < 0) {
+	switch (disp->impl->chan.wndw.oclass) {
+	case GA102_DISP_WINDOW_CHANNEL_DMA: ctor = wndwc67e_new; break;
+	case TU102_DISP_WINDOW_CHANNEL_DMA: ctor = wndwc57e_new; break;
+	case GV100_DISP_WINDOW_CHANNEL_DMA: ctor = wndwc37e_new; break;
+	default:
 		NV_ERROR(drm, "No supported window class\n");
-		return cid;
+		return -ENODEV;
 	}
 
-	ret = wndws[cid].new(drm, type, index, wndws[cid].oclass, pwndw);
+	ret = ctor(drm, type, index, disp->impl->chan.wndw.oclass, pwndw);
 	if (ret)
 		return ret;
 
diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index e479e8114605..f96638ce4b12 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -220,6 +220,10 @@ struct nvif_faultbuf_impl {
 struct nvif_disp_impl {
 	void (*del)(struct nvif_disp_priv *);
 
+	struct {
+		u32 oclass;
+	} caps;
+
 	struct {
 		u32 mask;
 	} conn;
@@ -231,6 +235,20 @@ struct nvif_disp_impl {
 	struct {
 		u32 mask;
 	} head;
+
+	struct {
+		struct nvif_disp_impl_core {
+			s32 oclass;
+		} core;
+
+		struct nvif_disp_impl_dmac {
+			s32 oclass;
+		} base, ovly, wndw, wimm;
+
+		struct nvif_disp_impl_pioc {
+			s32 oclass;
+		} curs, oimm;
+	} chan;
 };
 
 struct nvif_device_impl {
diff --git a/drivers/gpu/drm/nouveau/include/nvif/object.h b/drivers/gpu/drm/nouveau/include/nvif/object.h
index 819ae1c9729d..10a8f3e1ea81 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/object.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/object.h
@@ -82,35 +82,6 @@ void nvif_object_unmap(struct nvif_object *);
 
 #define nvif_mthd(a,b,c,d) nvif_object_mthd((a), (b), (c), (d))
 
-struct nvif_mclass {
-	s32 oclass;
-	int version;
-};
-
-#define nvif_mclass(o,m) ({                                                    \
-	struct nvif_object *object = (o);                                      \
-	struct nvif_sclass *sclass;                                            \
-	typeof(m[0]) *mclass = (m);                                            \
-	int ret = -ENODEV;                                                     \
-	int cnt, i, j;                                                         \
-                                                                               \
-	cnt = nvif_object_sclass_get(object, &sclass);                         \
-	if (cnt >= 0) {                                                        \
-		for (i = 0; ret < 0 && mclass[i].oclass; i++) {                \
-			for (j = 0; j < cnt; j++) {                            \
-				if (mclass[i].oclass  == sclass[j].oclass &&   \
-				    mclass[i].version >= sclass[j].minver &&   \
-				    mclass[i].version <= sclass[j].maxver) {   \
-					ret = i;                               \
-					break;                                 \
-				}                                              \
-			}                                                      \
-		}                                                              \
-		nvif_object_sclass_put(&sclass);                               \
-	}                                                                      \
-	ret;                                                                   \
-})
-
 #define NVIF_RD32_(p,o,dr)   nvif_rd32((p), (o) + (dr))
 #define NVIF_WR32_(p,o,dr,f) nvif_wr32((p), (o) + (dr), (f))
 #define NVIF_RD32(p,A...) DRF_RD(NVIF_RD32_,                  (p), 0, ##A)
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c
index 06e465edf3e9..fd8590514c7e 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c
@@ -171,6 +171,10 @@ nvkm_udisp_new(struct nvkm_device *device, const struct nvif_disp_impl **pimpl,
 	udisp->disp = disp;
 	udisp->impl = nvkm_udisp_impl;
 
+	if (disp->func->user.caps.oclass) {
+		udisp->impl.caps.oclass = disp->func->user.caps.oclass;
+	}
+
 	list_for_each_entry(conn, &disp->conns, head)
 		udisp->impl.conn.mask |= BIT(conn->index);
 
@@ -180,6 +184,22 @@ nvkm_udisp_new(struct nvkm_device *device, const struct nvif_disp_impl **pimpl,
 	list_for_each_entry(head, &disp->heads, head)
 		udisp->impl.head.mask |= BIT(head->id);
 
+	if (disp->func->user.core.oclass) {
+		udisp->impl.chan.core.oclass = disp->func->user.core.oclass;
+		udisp->impl.chan.curs.oclass = disp->func->user.curs.oclass;
+
+		if (!disp->func->user.wndw.oclass) {
+			/* EVO */
+			udisp->impl.chan.base.oclass = disp->func->user.base.oclass;
+			udisp->impl.chan.ovly.oclass = disp->func->user.ovly.oclass;
+			udisp->impl.chan.oimm.oclass = disp->func->user.oimm.oclass;
+		} else {
+			/* NVDisplay (GV100-) */
+			udisp->impl.chan.wndw.oclass = disp->func->user.wndw.oclass;
+			udisp->impl.chan.wimm.oclass = disp->func->user.wimm.oclass;
+		}
+	}
+
 	*pimpl = &udisp->impl;
 	*ppriv = udisp;
 	*pobject = &udisp->object;
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 101/156] drm/nouveau/nvif: rework disp "new caps" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (99 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 100/156] drm/nouveau/nvif: rework disp "sclass" api Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 102/156] drm/nouveau/nvif: rework disp "new conn" api Ben Skeggs
                   ` (56 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interface

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/dispnv50/corec37d.c   | 11 +--
 drivers/gpu/drm/nouveau/dispnv50/disp.c       |  3 +-
 drivers/gpu/drm/nouveau/dispnv50/disp.h       |  2 +-
 drivers/gpu/drm/nouveau/include/nvif/disp.h   | 11 +++
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  8 +++
 drivers/gpu/drm/nouveau/nvif/disp.c           | 32 +++++++++
 .../gpu/drm/nouveau/nvkm/engine/disp/Kbuild   |  1 +
 .../gpu/drm/nouveau/nvkm/engine/disp/ad102.c  |  2 +-
 .../gpu/drm/nouveau/nvkm/engine/disp/ga102.c  |  2 +-
 .../gpu/drm/nouveau/nvkm/engine/disp/gv100.c  | 42 ++---------
 .../gpu/drm/nouveau/nvkm/engine/disp/priv.h   |  5 +-
 .../gpu/drm/nouveau/nvkm/engine/disp/tu102.c  |  2 +-
 .../gpu/drm/nouveau/nvkm/engine/disp/ucaps.c  | 70 +++++++++++++++++++
 .../gpu/drm/nouveau/nvkm/engine/disp/ucaps.h  |  9 +++
 .../gpu/drm/nouveau/nvkm/engine/disp/udisp.c  | 23 ++++--
 15 files changed, 161 insertions(+), 62 deletions(-)
 create mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/disp/ucaps.c
 create mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/disp/ucaps.h

diff --git a/drivers/gpu/drm/nouveau/dispnv50/corec37d.c b/drivers/gpu/drm/nouveau/dispnv50/corec37d.c
index 9525fd30c8fc..60535526ac89 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/corec37d.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/corec37d.c
@@ -104,8 +104,7 @@ int corec37d_caps_init(struct nouveau_drm *drm, struct nv50_disp *disp)
 {
 	int ret;
 
-	ret = nvif_object_ctor(&disp->disp->object, "dispCaps", 0,
-			       GV100_DISP_CAPS, NULL, 0, &disp->caps);
+	ret = nvif_disp_caps_ctor(disp->disp, "dispCaps", &disp->caps);
 	if (ret) {
 		NV_ERROR(drm,
 			 "Failed to init notifier caps region: %d\n",
@@ -113,14 +112,6 @@ int corec37d_caps_init(struct nouveau_drm *drm, struct nv50_disp *disp)
 		return ret;
 	}
 
-	ret = nvif_object_map(&disp->caps, NULL, 0);
-	if (ret) {
-		NV_ERROR(drm,
-			 "Failed to map notifier caps region: %d\n",
-			 ret);
-		return ret;
-	}
-
 	return 0;
 }
 
diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c b/drivers/gpu/drm/nouveau/dispnv50/disp.c
index b89a8f4ee506..802dccace624 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/disp.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c
@@ -2788,8 +2788,7 @@ nv50_display_destroy(struct drm_device *dev)
 
 	nv50_audio_component_fini(nouveau_drm(dev));
 
-	nvif_object_unmap(&disp->caps);
-	nvif_object_dtor(&disp->caps);
+	nvif_disp_caps_dtor(&disp->caps);
 	nv50_core_del(&disp->core);
 
 	nouveau_bo_unmap(disp->sync);
diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.h b/drivers/gpu/drm/nouveau/dispnv50/disp.h
index 9485f8c90cac..39aaa385cd6a 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/disp.h
+++ b/drivers/gpu/drm/nouveau/dispnv50/disp.h
@@ -12,7 +12,7 @@ struct nouveau_encoder;
 struct nv50_disp {
 	struct nvif_disp *disp;
 	struct nv50_core *core;
-	struct nvif_object caps;
+	struct nvif_disp_caps caps;
 
 #define NV50_DISP_SYNC(c, o)                                ((c) * 0x040 + (o))
 #define NV50_DISP_CORE_NTFY                       NV50_DISP_SYNC(0      , 0x00)
diff --git a/drivers/gpu/drm/nouveau/include/nvif/disp.h b/drivers/gpu/drm/nouveau/include/nvif/disp.h
index 06f56cc63893..b41ff8c091b1 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/disp.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/disp.h
@@ -17,4 +17,15 @@ struct nvif_disp {
 
 int nvif_disp_ctor(struct nvif_device *, const char *name, struct nvif_disp *);
 void nvif_disp_dtor(struct nvif_disp *);
+
+struct nvif_disp_caps {
+	const struct nvif_disp_caps_impl *impl;
+	struct nvif_disp_caps_priv *priv;
+
+	struct nvif_object object;
+	struct nvif_map map;
+};
+
+int nvif_disp_caps_ctor(struct nvif_disp *, const char *name, struct nvif_disp_caps *);
+void nvif_disp_caps_dtor(struct nvif_disp_caps *);
 #endif
diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index f96638ce4b12..412b2dff3a74 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -11,6 +11,7 @@ struct nvif_mem_priv;
 struct nvif_vmm_priv;
 struct nvif_faultbuf_priv;
 struct nvif_disp_priv;
+struct nvif_disp_caps_priv;
 
 struct nvif_driver {
 	const char *name;
@@ -217,11 +218,18 @@ struct nvif_faultbuf_impl {
 	} event;
 };
 
+struct nvif_disp_caps_impl {
+	void (*del)(struct nvif_disp_caps_priv *);
+	struct nvif_mapinfo map;
+};
+
 struct nvif_disp_impl {
 	void (*del)(struct nvif_disp_priv *);
 
 	struct {
 		u32 oclass;
+		int (*new)(struct nvif_disp_priv *,
+			   const struct nvif_disp_caps_impl **, struct nvif_disp_caps_priv **);
 	} caps;
 
 	struct {
diff --git a/drivers/gpu/drm/nouveau/nvif/disp.c b/drivers/gpu/drm/nouveau/nvif/disp.c
index f3c425daf7d5..d2824e4d29f8 100644
--- a/drivers/gpu/drm/nouveau/nvif/disp.c
+++ b/drivers/gpu/drm/nouveau/nvif/disp.c
@@ -25,6 +25,38 @@
 
 #include <nvif/class.h>
 
+void
+nvif_disp_caps_dtor(struct nvif_disp_caps *caps)
+{
+	if (!caps->impl)
+		return;
+
+	nvif_object_unmap_cpu(&caps->map);
+
+	caps->impl->del(caps->priv);
+	caps->impl = NULL;
+}
+
+int
+nvif_disp_caps_ctor(struct nvif_disp *disp, const char *name, struct nvif_disp_caps *caps)
+{
+	const u32 oclass = disp->impl->caps.oclass;
+	int ret;
+
+	ret = disp->impl->caps.new(disp->priv, &caps->impl, &caps->priv);
+	NVIF_ERRON(ret, &disp->object, "[NEW caps%04x]", oclass);
+	if (ret)
+		return ret;
+
+	nvif_object_ctor(&disp->object, name ?: "nvifDispCaps", 0, oclass, &caps->object);
+
+	ret = nvif_object_map_cpu(&caps->object, &caps->impl->map, &caps->map);
+	if (ret)
+		nvif_disp_caps_dtor(caps);
+
+	return ret;
+}
+
 void
 nvif_disp_dtor(struct nvif_disp *disp)
 {
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/Kbuild b/drivers/gpu/drm/nouveau/nvkm/engine/disp/Kbuild
index e346e924fee8..f0856423af91 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/Kbuild
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/Kbuild
@@ -32,6 +32,7 @@ nvkm-y += nvkm/engine/disp/ad102.o
 nvkm-y += nvkm/engine/disp/r535.o
 
 nvkm-y += nvkm/engine/disp/udisp.o
+nvkm-y += nvkm/engine/disp/ucaps.o
 nvkm-y += nvkm/engine/disp/uconn.o
 nvkm-y += nvkm/engine/disp/uoutp.o
 nvkm-y += nvkm/engine/disp/uhead.o
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/ad102.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/ad102.c
index f818828e3f04..190aa0303fd3 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/ad102.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/ad102.c
@@ -32,7 +32,7 @@ ad102_disp = {
 	.ramht_size = 0x2000,
 	.user = {
 		.root = { AD102_DISP },
-		.caps = { GV100_DISP_CAPS                  ,  gv100_disp_caps_new },
+		.caps = { GV100_DISP_CAPS                  ,  gv100_disp_caps },
 		.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 },
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/ga102.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/ga102.c
index c6b77e4d08a0..7712e6a5caac 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/ga102.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/ga102.c
@@ -135,7 +135,7 @@ ga102_disp = {
 	.ramht_size = 0x2000,
 	.user = {
 		.root = { GA102_DISP },
-		.caps = { GV100_DISP_CAPS                  ,  gv100_disp_caps_new },
+		.caps = { GV100_DISP_CAPS                  ,  gv100_disp_caps },
 		.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 },
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gv100.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gv100.c
index 7876241e10e7..81ebec100d93 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gv100.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gv100.c
@@ -791,45 +791,13 @@ gv100_disp_core = {
 	.mthd = &gv100_disp_core_mthd,
 };
 
-#define gv100_disp_caps(p) container_of((p), struct gv100_disp_caps, object)
-
-struct gv100_disp_caps {
-	struct nvkm_object object;
-	struct nvkm_disp *disp;
-};
-
-static int
-gv100_disp_caps_map(struct nvkm_object *object, void *argv, u32 argc,
-		    enum nvkm_object_map *type, u64 *addr, u64 *size)
+void
+gv100_disp_caps(struct nvkm_disp *disp, u64 *addr, u64 *size)
 {
-	struct gv100_disp_caps *caps = gv100_disp_caps(object);
-	struct nvkm_device *device = caps->disp->engine.subdev.device;
-	*type = NVKM_OBJECT_MAP_IO;
+	struct nvkm_device *device = disp->engine.subdev.device;
+
 	*addr = 0x640000 + device->func->resource_addr(device, 0);
 	*size = 0x1000;
-	return 0;
-}
-
-static const struct nvkm_object_func
-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 = container_of(oclass->parent, struct nvif_disp_priv, object)->disp;
-	struct gv100_disp_caps *caps;
-
-	if (!(caps = kzalloc(sizeof(*caps), GFP_KERNEL)))
-		return -ENOMEM;
-	*pobject = &caps->object;
-
-	nvkm_object_ctor(&gv100_disp_caps, oclass, &caps->object);
-	caps->disp = disp;
-	return 0;
 }
 
 void
@@ -1238,7 +1206,7 @@ gv100_disp = {
 	.ramht_size = 0x2000,
 	.user = {
 		.root = { GV100_DISP },
-		.caps = { GV100_DISP_CAPS                  ,  gv100_disp_caps_new },
+		.caps = { GV100_DISP_CAPS                  ,  gv100_disp_caps },
 		.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 },
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/priv.h b/drivers/gpu/drm/nouveau/nvkm/engine/disp/priv.h
index 324a7971a0eb..822c4ffe5a38 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/priv.h
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/priv.h
@@ -42,8 +42,7 @@ struct nvkm_disp_func {
 
 		struct {
 			s32 oclass;
-			int (*ctor)(const struct nvkm_oclass *, void *argv, u32 argc,
-				    struct nvkm_object **);
+			void (*addr)(struct nvkm_disp *, u64 *addr, u64 *size);
 		} caps;
 
 		struct nvkm_disp_func_chan {
@@ -76,7 +75,7 @@ void gv100_disp_fini(struct nvkm_disp *, bool suspend);
 void gv100_disp_intr(struct nvkm_disp *);
 void gv100_disp_super(struct work_struct *);
 int gv100_disp_wndw_cnt(struct nvkm_disp *, unsigned long *);
-int gv100_disp_caps_new(const struct nvkm_oclass *, void *, u32, struct nvkm_object **);
+void gv100_disp_caps(struct nvkm_disp *, u64 *addr, u64 *size);
 
 int tu102_disp_init(struct nvkm_disp *);
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/tu102.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/tu102.c
index 21b945a88823..6d0806da18ef 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/tu102.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/tu102.c
@@ -221,7 +221,7 @@ tu102_disp = {
 	.ramht_size = 0x2000,
 	.user = {
 		.root = { TU102_DISP },
-		.caps = { GV100_DISP_CAPS                  ,  gv100_disp_caps_new },
+		.caps = { GV100_DISP_CAPS                  ,  gv100_disp_caps },
 		.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 },
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/ucaps.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/ucaps.c
new file mode 100644
index 000000000000..2f22a88cb97b
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/ucaps.c
@@ -0,0 +1,70 @@
+/*
+ * 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 "ucaps.h"
+
+struct nvif_disp_caps_priv {
+	struct nvkm_object object;
+	struct nvkm_disp *disp;
+
+	struct nvif_disp_caps_impl impl;
+};
+
+static void
+nvkm_ucaps_del(struct nvif_disp_caps_priv *ucaps)
+{
+	struct nvkm_object *object = &ucaps->object;
+
+	nvkm_object_del(&object);
+}
+
+static const struct nvif_disp_caps_impl
+nvkm_ucaps_impl = {
+	.del = nvkm_ucaps_del,
+};
+
+static const struct nvkm_object_func
+nvkm_ucaps = {
+};
+
+int
+nvkm_ucaps_new(struct nvkm_disp *disp, const struct nvif_disp_caps_impl **pimpl,
+	       struct nvif_disp_caps_priv **ppriv, struct nvkm_object **pobject)
+{
+	struct nvif_disp_caps_priv *ucaps;
+
+	ucaps = kzalloc(sizeof(*ucaps), GFP_KERNEL);
+	if (!ucaps)
+		return -ENOMEM;
+	*pobject = &ucaps->object;
+
+	nvkm_object_ctor(&nvkm_ucaps, &(struct nvkm_oclass) {}, &ucaps->object);
+	ucaps->disp = disp;
+	ucaps->impl = nvkm_ucaps_impl;
+
+	ucaps->impl.map.type = NVIF_MAP_IO;
+	disp->func->user.caps.addr(disp, &ucaps->impl.map.handle, &ucaps->impl.map.length);
+
+	*pimpl = &ucaps->impl;
+	*ppriv = ucaps;
+	*pobject = &ucaps->object;
+	return 0;
+}
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/ucaps.h b/drivers/gpu/drm/nouveau/nvkm/engine/disp/ucaps.h
new file mode 100644
index 000000000000..690a92930363
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/ucaps.h
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: MIT */
+#ifndef __NVKM_UCAPS_H__
+#define __NVKM_UCAPS_H__
+#include "priv.h"
+#include <nvif/driverif.h>
+
+int nvkm_ucaps_new(struct nvkm_disp *, const struct nvif_disp_caps_impl **,
+		   struct nvif_disp_caps_priv **, struct nvkm_object **);
+#endif
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c
index fd8590514c7e..cef8427cca91 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c
@@ -20,6 +20,7 @@
  * OTHER DEALINGS IN THE SOFTWARE.
  */
 #include "udisp.h"
+#include "ucaps.h"
 #include "chan.h"
 #include "conn.h"
 #include "head.h"
@@ -50,12 +51,6 @@ nvkm_udisp_sclass(struct nvkm_object *object, int index, struct nvkm_oclass *scl
 		return 0;
 	}
 
-	if (disp->func->user.caps.oclass && index-- == 0) {
-		sclass->base = (struct nvkm_sclass) { -1, -1, disp->func->user.caps.oclass };
-		sclass->ctor = disp->func->user.caps.ctor;
-		return 0;
-	}
-
 	if (disp->func->user.core.oclass && index-- == 0) {
 		sclass->base = (struct nvkm_sclass) { 0, 0, disp->func->user.core.oclass };
 		sclass->ctor = nvkm_disp_core_new;
@@ -101,6 +96,21 @@ nvkm_udisp_sclass(struct nvkm_object *object, int index, struct nvkm_oclass *scl
 	return -EINVAL;
 }
 
+static int
+nvkm_udisp_caps_new(struct nvif_disp_priv *udisp,
+		    const struct nvif_disp_caps_impl **pimpl, struct nvif_disp_caps_priv **ppriv)
+{
+	struct nvkm_object *object;
+	int ret;
+
+	ret = nvkm_ucaps_new(udisp->disp, pimpl, ppriv, &object);
+	if (ret)
+		return ret;
+
+	nvkm_object_link(&udisp->object, object);
+	return 0;
+}
+
 static void
 nvkm_udisp_del(struct nvif_disp_priv *udisp)
 {
@@ -173,6 +183,7 @@ nvkm_udisp_new(struct nvkm_device *device, const struct nvif_disp_impl **pimpl,
 
 	if (disp->func->user.caps.oclass) {
 		udisp->impl.caps.oclass = disp->func->user.caps.oclass;
+		udisp->impl.caps.new = nvkm_udisp_caps_new;
 	}
 
 	list_for_each_entry(conn, &disp->conns, head)
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 102/156] drm/nouveau/nvif: rework disp "new conn" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (100 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 101/156] drm/nouveau/nvif: rework disp "new caps" api Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 103/156] drm/nouveau/nvif: rework conn "new event" api Ben Skeggs
                   ` (55 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interface

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/include/nvif/conn.h   | 18 ++-----
 .../gpu/drm/nouveau/include/nvif/driverif.h   | 20 +++++++
 drivers/gpu/drm/nouveau/include/nvif/if0011.h | 18 -------
 drivers/gpu/drm/nouveau/nouveau_connector.c   |  2 +-
 drivers/gpu/drm/nouveau/nvif/conn.c           | 32 +++---------
 .../gpu/drm/nouveau/nvkm/engine/disp/priv.h   |  1 -
 .../gpu/drm/nouveau/nvkm/engine/disp/uconn.c  | 52 ++++++++++++-------
 .../gpu/drm/nouveau/nvkm/engine/disp/uconn.h  |  3 ++
 .../gpu/drm/nouveau/nvkm/engine/disp/udisp.c  | 24 ++++++---
 9 files changed, 87 insertions(+), 83 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/conn.h b/drivers/gpu/drm/nouveau/include/nvif/conn.h
index 406c12a111f9..0f0ca002fe47 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/conn.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/conn.h
@@ -2,26 +2,16 @@
 #ifndef __NVIF_CONN_H__
 #define __NVIF_CONN_H__
 #include <nvif/object.h>
+#include <nvif/driverif.h>
 #include <nvif/event.h>
 struct nvif_disp;
 
 struct nvif_conn {
+	const struct nvif_conn_impl *impl;
+	struct nvif_conn_priv *priv;
 	struct nvif_object object;
-	u32 id;
 
-	struct {
-		enum {
-			NVIF_CONN_VGA,
-			NVIF_CONN_TV,
-			NVIF_CONN_DVI_I,
-			NVIF_CONN_DVI_D,
-			NVIF_CONN_LVDS,
-			NVIF_CONN_LVDS_SPWG,
-			NVIF_CONN_HDMI,
-			NVIF_CONN_DP,
-			NVIF_CONN_EDP,
-		} type;
-	} info;
+	u32 id;
 };
 
 int nvif_conn_ctor(struct nvif_disp *, const char *name, int id, struct nvif_conn *);
diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 412b2dff3a74..fb741c7293f6 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -12,6 +12,7 @@ struct nvif_vmm_priv;
 struct nvif_faultbuf_priv;
 struct nvif_disp_priv;
 struct nvif_disp_caps_priv;
+struct nvif_conn_priv;
 
 struct nvif_driver {
 	const char *name;
@@ -223,6 +224,22 @@ struct nvif_disp_caps_impl {
 	struct nvif_mapinfo map;
 };
 
+struct nvif_conn_impl {
+	void (*del)(struct nvif_conn_priv *);
+
+	enum nvif_conn_type {
+		NVIF_CONN_VGA,
+		NVIF_CONN_TV,
+		NVIF_CONN_DVI_I,
+		NVIF_CONN_DVI_D,
+		NVIF_CONN_HDMI,
+		NVIF_CONN_LVDS,
+		NVIF_CONN_LVDS_SPWG,
+		NVIF_CONN_DP,
+		NVIF_CONN_EDP,
+	} type;
+};
+
 struct nvif_disp_impl {
 	void (*del)(struct nvif_disp_priv *);
 
@@ -234,6 +251,9 @@ struct nvif_disp_impl {
 
 	struct {
 		u32 mask;
+		int (*new)(struct nvif_disp_priv *, u8 id,
+			   const struct nvif_conn_impl **, struct nvif_conn_priv **,
+			   u64 handle);
 	} conn;
 
 	struct {
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0011.h b/drivers/gpu/drm/nouveau/include/nvif/if0011.h
index 3ed0ddd75bd8..6e717445d10a 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/if0011.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/if0011.h
@@ -2,24 +2,6 @@
 #ifndef __NVIF_IF0011_H__
 #define __NVIF_IF0011_H__
 
-union nvif_conn_args {
-	struct nvif_conn_v0 {
-		__u8 version;
-		__u8 id;	/* DCB connector table index. */
-		__u8 pad02[6];
-#define NVIF_CONN_V0_VGA       0x00
-#define NVIF_CONN_V0_TV        0x01
-#define NVIF_CONN_V0_DVI_I     0x02
-#define NVIF_CONN_V0_DVI_D     0x03
-#define NVIF_CONN_V0_LVDS      0x04
-#define NVIF_CONN_V0_LVDS_SPWG 0x05
-#define NVIF_CONN_V0_HDMI      0x06
-#define NVIF_CONN_V0_DP        0x07
-#define NVIF_CONN_V0_EDP       0x08
-		__u8 type;
-	} v0;
-};
-
 union nvif_conn_event_args {
 	struct nvif_conn_event_v0 {
 		__u8 version;
diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c b/drivers/gpu/drm/nouveau/nouveau_connector.c
index 856b3ef5edb8..b1bd8264b703 100644
--- a/drivers/gpu/drm/nouveau/nouveau_connector.c
+++ b/drivers/gpu/drm/nouveau/nouveau_connector.c
@@ -1311,7 +1311,7 @@ nouveau_connector_create(struct drm_device *dev, int index)
 			return ERR_PTR(ret);
 		}
 
-		switch (nv_connector->conn.info.type) {
+		switch (nv_connector->conn.impl->type) {
 		case NVIF_CONN_VGA      : type = DCB_CONNECTOR_VGA; break;
 		case NVIF_CONN_DVI_I    : type = DCB_CONNECTOR_DVI_I; break;
 		case NVIF_CONN_DVI_D    : type = DCB_CONNECTOR_DVI_D; break;
diff --git a/drivers/gpu/drm/nouveau/nvif/conn.c b/drivers/gpu/drm/nouveau/nvif/conn.c
index 9ee18cb99264..48927282a7ce 100644
--- a/drivers/gpu/drm/nouveau/nvif/conn.c
+++ b/drivers/gpu/drm/nouveau/nvif/conn.c
@@ -23,7 +23,6 @@
 #include <nvif/disp.h>
 #include <nvif/printf.h>
 
-#include <nvif/class.h>
 #include <nvif/if0011.h>
 
 int
@@ -48,40 +47,25 @@ nvif_conn_event_ctor(struct nvif_conn *conn, const char *name, nvif_event_func f
 void
 nvif_conn_dtor(struct nvif_conn *conn)
 {
-	nvif_object_dtor(&conn->object);
+	if (!conn->impl)
+		return;
+
+	conn->impl->del(conn->priv);
+	conn->impl = NULL;
 }
 
 int
 nvif_conn_ctor(struct nvif_disp *disp, const char *name, int id, struct nvif_conn *conn)
 {
-	struct nvif_conn_v0 args;
 	int ret;
 
-	args.version = 0;
-	args.id = id;
-
-	ret = nvif_object_ctor(&disp->object, name ?: "nvifConn", id, NVIF_CLASS_CONN,
-			       &args, sizeof(args), &conn->object);
+	ret = disp->impl->conn.new(disp->priv, id, &conn->impl, &conn->priv,
+				   nvif_handle(&conn->object));
 	NVIF_ERRON(ret, &disp->object, "[NEW conn id:%d]", id);
 	if (ret)
 		return ret;
 
+	nvif_object_ctor(&disp->object, name ?: "nvifConn", id, 0, &conn->object);
 	conn->id = id;
-
-	switch (args.type) {
-	case NVIF_CONN_V0_VGA      : conn->info.type = NVIF_CONN_VGA; break;
-	case NVIF_CONN_V0_TV       : conn->info.type = NVIF_CONN_TV; break;
-	case NVIF_CONN_V0_DVI_I    : conn->info.type = NVIF_CONN_DVI_I; break;
-	case NVIF_CONN_V0_DVI_D    : conn->info.type = NVIF_CONN_DVI_D; break;
-	case NVIF_CONN_V0_LVDS     : conn->info.type = NVIF_CONN_LVDS; break;
-	case NVIF_CONN_V0_LVDS_SPWG: conn->info.type = NVIF_CONN_LVDS_SPWG; break;
-	case NVIF_CONN_V0_HDMI     : conn->info.type = NVIF_CONN_HDMI; break;
-	case NVIF_CONN_V0_DP       : conn->info.type = NVIF_CONN_DP; break;
-	case NVIF_CONN_V0_EDP      : conn->info.type = NVIF_CONN_EDP; break;
-	default:
-		break;
-	}
-
 	return 0;
-
 }
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/priv.h b/drivers/gpu/drm/nouveau/nvkm/engine/disp/priv.h
index 822c4ffe5a38..890cfb23da77 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/priv.h
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/priv.h
@@ -89,7 +89,6 @@ void nv50_disp_chan_uevent_send(struct nvkm_disp *, int);
 extern const struct nvkm_event_func gf119_disp_chan_uevent;
 extern const struct nvkm_event_func gv100_disp_chan_uevent;
 
-int nvkm_uconn_new(const struct nvkm_oclass *, void *, u32, struct nvkm_object **);
 int nvkm_uoutp_new(const struct nvkm_oclass *, void *, u32, struct nvkm_object **);
 int nvkm_uhead_new(const struct nvkm_oclass *, void *, u32, struct nvkm_object **);
 #endif
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uconn.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uconn.c
index 773e49e557f8..5f72db9276b8 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uconn.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uconn.c
@@ -32,6 +32,8 @@
 struct nvif_conn_priv {
 	struct nvkm_object object;
 	struct nvkm_conn *conn;
+
+	struct nvif_conn_impl impl;
 };
 
 static int
@@ -152,6 +154,19 @@ nvkm_uconn_uevent(struct nvkm_object *object, void *argv, u32 argc, struct nvkm_
 			       nvkm_uconn_uevent_gpio);
 }
 
+static void
+nvkm_uconn_del(struct nvif_conn_priv *uconn)
+{
+	struct nvkm_object *object = &uconn->object;
+
+	nvkm_object_del(&object);
+}
+
+static const struct nvif_conn_impl
+nvkm_uconn_impl = {
+	.del = nvkm_uconn_del,
+};
+
 static void *
 nvkm_uconn_dtor(struct nvkm_object *object)
 {
@@ -170,20 +185,16 @@ 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)
+nvkm_uconn_new(struct nvkm_disp *disp, u8 id, const struct nvif_conn_impl **pimpl,
+	       struct nvif_conn_priv **ppriv, struct nvkm_object **pobject)
 {
-	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;
 	struct nvif_conn_priv *uconn;
-
-	if (argc != sizeof(args->v0) || args->v0.version != 0)
-		return -ENOSYS;
+	enum nvif_conn_type type;
 
 	list_for_each_entry(cont, &disp->conns, head) {
-		if (cont->index == args->v0.id) {
+		if (cont->index == id) {
 			conn = cont;
 			break;
 		}
@@ -193,25 +204,25 @@ nvkm_uconn_new(const struct nvkm_oclass *oclass, void *argv, u32 argc, struct nv
 		return -EINVAL;
 
 	switch (conn->info.type) {
-	case DCB_CONNECTOR_VGA      : args->v0.type = NVIF_CONN_V0_VGA; break;
+	case DCB_CONNECTOR_VGA      : type = NVIF_CONN_VGA; break;
 	case DCB_CONNECTOR_TV_0     :
 	case DCB_CONNECTOR_TV_1     :
-	case DCB_CONNECTOR_TV_3     : args->v0.type = NVIF_CONN_V0_TV; break;
+	case DCB_CONNECTOR_TV_3     : type = NVIF_CONN_TV; break;
 	case DCB_CONNECTOR_DMS59_0  :
 	case DCB_CONNECTOR_DMS59_1  :
-	case DCB_CONNECTOR_DVI_I    : args->v0.type = NVIF_CONN_V0_DVI_I; break;
-	case DCB_CONNECTOR_DVI_D    : args->v0.type = NVIF_CONN_V0_DVI_D; break;
-	case DCB_CONNECTOR_LVDS     : args->v0.type = NVIF_CONN_V0_LVDS; break;
-	case DCB_CONNECTOR_LVDS_SPWG: args->v0.type = NVIF_CONN_V0_LVDS_SPWG; break;
+	case DCB_CONNECTOR_DVI_I    : type = NVIF_CONN_DVI_I; break;
+	case DCB_CONNECTOR_DVI_D    : type = NVIF_CONN_DVI_D; break;
+	case DCB_CONNECTOR_LVDS     : type = NVIF_CONN_LVDS; break;
+	case DCB_CONNECTOR_LVDS_SPWG: type = NVIF_CONN_LVDS_SPWG; break;
 	case DCB_CONNECTOR_DMS59_DP0:
 	case DCB_CONNECTOR_DMS59_DP1:
 	case DCB_CONNECTOR_DP       :
 	case DCB_CONNECTOR_mDP      :
-	case DCB_CONNECTOR_USB_C    : args->v0.type = NVIF_CONN_V0_DP; break;
-	case DCB_CONNECTOR_eDP      : args->v0.type = NVIF_CONN_V0_EDP; break;
+	case DCB_CONNECTOR_USB_C    : type = NVIF_CONN_DP; break;
+	case DCB_CONNECTOR_eDP      : type = NVIF_CONN_EDP; break;
 	case DCB_CONNECTOR_HDMI_0   :
 	case DCB_CONNECTOR_HDMI_1   :
-	case DCB_CONNECTOR_HDMI_C   : args->v0.type = NVIF_CONN_V0_HDMI; break;
+	case DCB_CONNECTOR_HDMI_C   : type = NVIF_CONN_HDMI; break;
 	default:
 		WARN_ON(1);
 		return -EINVAL;
@@ -230,8 +241,13 @@ nvkm_uconn_new(const struct nvkm_oclass *oclass, void *argv, u32 argc, struct nv
 	conn->user = true;
 	spin_unlock(&disp->user.lock);
 
-	nvkm_object_ctor(&nvkm_uconn, oclass, &uconn->object);
+	nvkm_object_ctor(&nvkm_uconn, &(struct nvkm_oclass) {}, &uconn->object);
+	uconn->impl = nvkm_uconn_impl;
+	uconn->impl.type = type;
 	uconn->conn = conn;
+
+	*pimpl = &uconn->impl;
+	*ppriv = uconn;
 	*pobject = &uconn->object;
 	return 0;
 }
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uconn.h b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uconn.h
index f53d151e5b09..736d24951b12 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uconn.h
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uconn.h
@@ -2,5 +2,8 @@
 #ifndef __NVKM_UCONN_H__
 #define __NVKM_UCONN_H__
 #include "conn.h"
+#include <nvif/driverif.h>
 
+int nvkm_uconn_new(struct nvkm_disp *, u8 id, const struct nvif_conn_impl **,
+		   struct nvif_conn_priv **, struct nvkm_object **);
 #endif
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c
index cef8427cca91..01333ded466b 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c
@@ -22,7 +22,7 @@
 #include "udisp.h"
 #include "ucaps.h"
 #include "chan.h"
-#include "conn.h"
+#include "uconn.h"
 #include "head.h"
 #include "outp.h"
 
@@ -33,12 +33,6 @@ nvkm_udisp_sclass(struct nvkm_object *object, int index, struct nvkm_oclass *scl
 {
 	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 };
-		sclass->ctor = nvkm_uconn_new;
-		return 0;
-	}
-
 	if (index-- == 0) {
 		sclass->base = (struct nvkm_sclass) { 0, 0, NVIF_CLASS_OUTP };
 		sclass->ctor = nvkm_uoutp_new;
@@ -96,6 +90,21 @@ nvkm_udisp_sclass(struct nvkm_object *object, int index, struct nvkm_oclass *scl
 	return -EINVAL;
 }
 
+static int
+nvkm_udisp_conn_new(struct nvif_disp_priv *udisp, u8 id,
+		    const struct nvif_conn_impl **pimpl, struct nvif_conn_priv **ppriv,
+		    u64 handle)
+{
+	struct nvkm_object *object;
+	int ret;
+
+	ret = nvkm_uconn_new(udisp->disp, id, pimpl, ppriv, &object);
+	if (ret)
+		return ret;
+
+	return nvkm_object_link_rb(udisp->object.client, &udisp->object, handle, object);
+}
+
 static int
 nvkm_udisp_caps_new(struct nvif_disp_priv *udisp,
 		    const struct nvif_disp_caps_impl **pimpl, struct nvif_disp_caps_priv **ppriv)
@@ -123,6 +132,7 @@ nvkm_udisp_del(struct nvif_disp_priv *udisp)
 static const struct nvif_disp_impl
 nvkm_udisp_impl = {
 	.del = nvkm_udisp_del,
+	.conn.new = nvkm_udisp_conn_new,
 };
 
 static void *
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 103/156] drm/nouveau/nvif: rework conn "new event" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (101 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 102/156] drm/nouveau/nvif: rework disp "new conn" api Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 104/156] drm/nouveau/nvif: remove conn from object rb Ben Skeggs
                   ` (54 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interface

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/include/nvif/conn.h   |  6 ---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  3 ++
 drivers/gpu/drm/nouveau/nvif/conn.c           | 22 ++++----
 .../gpu/drm/nouveau/nvkm/engine/disp/uconn.c  | 50 ++++++++-----------
 4 files changed, 35 insertions(+), 46 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/conn.h b/drivers/gpu/drm/nouveau/include/nvif/conn.h
index 0f0ca002fe47..40c6424d82bf 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/conn.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/conn.h
@@ -17,12 +17,6 @@ struct nvif_conn {
 int nvif_conn_ctor(struct nvif_disp *, const char *name, int id, struct nvif_conn *);
 void nvif_conn_dtor(struct nvif_conn *);
 
-static inline int
-nvif_conn_id(struct nvif_conn *conn)
-{
-	return conn->object.handle;
-}
-
 int nvif_conn_event_ctor(struct nvif_conn *, const char *name, nvif_event_func, u8 types,
 			 struct nvif_event *);
 #endif
diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index fb741c7293f6..489f50d6ee00 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -238,6 +238,9 @@ struct nvif_conn_impl {
 		NVIF_CONN_DP,
 		NVIF_CONN_EDP,
 	} type;
+
+	int (*event)(struct nvif_conn_priv *, u64 handle, u8 types,
+		     const struct nvif_event_impl **, struct nvif_event_priv **);
 };
 
 struct nvif_disp_impl {
diff --git a/drivers/gpu/drm/nouveau/nvif/conn.c b/drivers/gpu/drm/nouveau/nvif/conn.c
index 48927282a7ce..d4e9f0275d1e 100644
--- a/drivers/gpu/drm/nouveau/nvif/conn.c
+++ b/drivers/gpu/drm/nouveau/nvif/conn.c
@@ -23,25 +23,23 @@
 #include <nvif/disp.h>
 #include <nvif/printf.h>
 
-#include <nvif/if0011.h>
-
 int
 nvif_conn_event_ctor(struct nvif_conn *conn, const char *name, nvif_event_func func, u8 types,
 		     struct nvif_event *event)
 {
-	struct {
-		struct nvif_event_v0 base;
-		struct nvif_conn_event_v0 conn;
-	} args;
 	int ret;
 
-	args.conn.version = 0;
-	args.conn.types = types;
+	if (!conn->impl->event)
+		return -ENODEV;
 
-	ret = nvif_event_ctor_(&conn->object, name ?: "nvifConnHpd", nvif_conn_id(conn),
-			       func, true, &args.base, sizeof(args), false, event);
-	NVIF_DEBUG(&conn->object, "[NEW EVENT:HPD types:%02x]", types);
-	return ret;
+	ret = conn->impl->event(conn->priv, nvif_handle(&event->object), types,
+				&event->impl, &event->priv);
+	NVIF_ERRON(ret, &conn->object, "[NEW EVENT:HPD types:%02x]", types);
+	if (ret)
+		return ret;
+
+	nvif_event_ctor(&conn->object, name ?: "nvifConnHpd", conn->id, func, event);
+	return 0;
 }
 
 void
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uconn.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uconn.c
index 5f72db9276b8..9c7b83c99b80 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uconn.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uconn.c
@@ -98,24 +98,15 @@ nvkm_connector_is_dp_dms(u8 type)
 }
 
 static int
-nvkm_uconn_uevent(struct nvkm_object *object, void *argv, u32 argc, struct nvkm_uevent *uevent)
+nvkm_uconn_event(struct nvif_conn_priv *uconn, u64 handle, u8 types,
+		 const struct nvif_event_impl **pimpl, struct nvif_event_priv **ppriv)
 {
-	struct nvkm_conn *conn = container_of(object, struct nvif_conn_priv, object)->conn;
+	struct nvkm_conn *conn = uconn->conn;
 	struct nvkm_disp *disp = conn->disp;
 	struct nvkm_device *device = disp->engine.subdev.device;
 	struct nvkm_outp *outp;
-	union nvif_conn_event_args *args = argv;
 	u64 bits = 0;
 
-	if (!uevent) {
-		if (!disp->rm.client.gsp && conn->info.hpd == DCB_GPIO_UNUSED)
-			return -ENOSYS;
-		return 0;
-	}
-
-	if (argc != sizeof(args->v0) || args->v0.version != 0)
-		return -ENOSYS;
-
 	list_for_each_entry(outp, &conn->disp->outps, head) {
 		if (outp->info.connector == conn->index)
 			break;
@@ -125,33 +116,34 @@ nvkm_uconn_uevent(struct nvkm_object *object, void *argv, u32 argc, struct nvkm_
 		return -EINVAL;
 
 	if (disp->rm.client.gsp) {
-		if (args->v0.types & NVIF_CONN_EVENT_V0_PLUG  ) bits |= NVKM_DPYID_PLUG;
-		if (args->v0.types & NVIF_CONN_EVENT_V0_UNPLUG) bits |= NVKM_DPYID_UNPLUG;
-		if (args->v0.types & NVIF_CONN_EVENT_V0_IRQ   ) bits |= NVKM_DPYID_IRQ;
+		if (types & NVIF_CONN_EVENT_V0_PLUG  ) bits |= NVKM_DPYID_PLUG;
+		if (types & NVIF_CONN_EVENT_V0_UNPLUG) bits |= NVKM_DPYID_UNPLUG;
+		if (types & NVIF_CONN_EVENT_V0_IRQ   ) bits |= NVKM_DPYID_IRQ;
 
-		return nvkm_uevent_add(uevent, &disp->rm.event, outp->index, bits,
-				       nvkm_uconn_uevent_gsp);
+		return nvkm_uevent_new_(&uconn->object, handle, &disp->rm.event, true,
+					outp->index, bits, nvkm_uconn_uevent_gsp, pimpl, ppriv);
 	}
 
 	if (outp->dp.aux && !outp->info.location) {
-		if (args->v0.types & NVIF_CONN_EVENT_V0_PLUG  ) bits |= NVKM_I2C_PLUG;
-		if (args->v0.types & NVIF_CONN_EVENT_V0_UNPLUG) bits |= NVKM_I2C_UNPLUG;
-		if (args->v0.types & NVIF_CONN_EVENT_V0_IRQ   ) bits |= NVKM_I2C_IRQ;
+		if (types & NVIF_CONN_EVENT_V0_PLUG  ) bits |= NVKM_I2C_PLUG;
+		if (types & NVIF_CONN_EVENT_V0_UNPLUG) bits |= NVKM_I2C_UNPLUG;
+		if (types & NVIF_CONN_EVENT_V0_IRQ   ) bits |= NVKM_I2C_IRQ;
 
-		return nvkm_uevent_add(uevent, &device->i2c->event, outp->dp.aux->id, bits,
-				       nvkm_uconn_uevent_aux);
+		return nvkm_uevent_new_(&uconn->object, handle, &device->i2c->event, true,
+					outp->dp.aux->id, bits, nvkm_uconn_uevent_aux,
+					pimpl, ppriv);
 	}
 
-	if (args->v0.types & NVIF_CONN_EVENT_V0_PLUG  ) bits |= NVKM_GPIO_HI;
-	if (args->v0.types & NVIF_CONN_EVENT_V0_UNPLUG) bits |= NVKM_GPIO_LO;
-	if (args->v0.types & NVIF_CONN_EVENT_V0_IRQ) {
+	if (types & NVIF_CONN_EVENT_V0_PLUG  ) bits |= NVKM_GPIO_HI;
+	if (types & NVIF_CONN_EVENT_V0_UNPLUG) bits |= NVKM_GPIO_LO;
+	if (types & NVIF_CONN_EVENT_V0_IRQ) {
 		/* TODO: support DP IRQ on ANX9805 and remove this hack. */
 		if (!outp->info.location && !nvkm_connector_is_dp_dms(conn->info.type))
 			return -EINVAL;
 	}
 
-	return nvkm_uevent_add(uevent, &device->gpio->event, conn->info.hpd, bits,
-			       nvkm_uconn_uevent_gpio);
+	return nvkm_uevent_new_(&uconn->object, handle, &device->gpio->event, true,
+				conn->info.hpd, bits, nvkm_uconn_uevent_gpio, pimpl, ppriv);
 }
 
 static void
@@ -182,7 +174,6 @@ nvkm_uconn_dtor(struct nvkm_object *object)
 static const struct nvkm_object_func
 nvkm_uconn = {
 	.dtor = nvkm_uconn_dtor,
-	.uevent = nvkm_uconn_uevent,
 };
 
 int
@@ -244,6 +235,9 @@ nvkm_uconn_new(struct nvkm_disp *disp, u8 id, const struct nvif_conn_impl **pimp
 	nvkm_object_ctor(&nvkm_uconn, &(struct nvkm_oclass) {}, &uconn->object);
 	uconn->impl = nvkm_uconn_impl;
 	uconn->impl.type = type;
+	if (disp->rm.client.gsp || conn->info.hpd != DCB_GPIO_UNUSED)
+		uconn->impl.event = nvkm_uconn_event;
+
 	uconn->conn = conn;
 
 	*pimpl = &uconn->impl;
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 104/156] drm/nouveau/nvif: remove conn from object rb
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (102 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 103/156] drm/nouveau/nvif: rework conn "new event" api Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 105/156] drm/nouveau/nvif: rework disp "new outp" api Ben Skeggs
                   ` (53 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- no more users

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/include/nvif/driverif.h  | 3 +--
 drivers/gpu/drm/nouveau/nvif/conn.c              | 3 +--
 drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c | 6 +++---
 3 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 489f50d6ee00..e59d2a4ec4d0 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -255,8 +255,7 @@ struct nvif_disp_impl {
 	struct {
 		u32 mask;
 		int (*new)(struct nvif_disp_priv *, u8 id,
-			   const struct nvif_conn_impl **, struct nvif_conn_priv **,
-			   u64 handle);
+			   const struct nvif_conn_impl **, struct nvif_conn_priv **);
 	} conn;
 
 	struct {
diff --git a/drivers/gpu/drm/nouveau/nvif/conn.c b/drivers/gpu/drm/nouveau/nvif/conn.c
index d4e9f0275d1e..8894f65d6028 100644
--- a/drivers/gpu/drm/nouveau/nvif/conn.c
+++ b/drivers/gpu/drm/nouveau/nvif/conn.c
@@ -57,8 +57,7 @@ nvif_conn_ctor(struct nvif_disp *disp, const char *name, int id, struct nvif_con
 {
 	int ret;
 
-	ret = disp->impl->conn.new(disp->priv, id, &conn->impl, &conn->priv,
-				   nvif_handle(&conn->object));
+	ret = disp->impl->conn.new(disp->priv, id, &conn->impl, &conn->priv);
 	NVIF_ERRON(ret, &disp->object, "[NEW conn id:%d]", id);
 	if (ret)
 		return ret;
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c
index 01333ded466b..65e8b3fec655 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c
@@ -92,8 +92,7 @@ nvkm_udisp_sclass(struct nvkm_object *object, int index, struct nvkm_oclass *scl
 
 static int
 nvkm_udisp_conn_new(struct nvif_disp_priv *udisp, u8 id,
-		    const struct nvif_conn_impl **pimpl, struct nvif_conn_priv **ppriv,
-		    u64 handle)
+		    const struct nvif_conn_impl **pimpl, struct nvif_conn_priv **ppriv)
 {
 	struct nvkm_object *object;
 	int ret;
@@ -102,7 +101,8 @@ nvkm_udisp_conn_new(struct nvif_disp_priv *udisp, u8 id,
 	if (ret)
 		return ret;
 
-	return nvkm_object_link_rb(udisp->object.client, &udisp->object, handle, object);
+	nvkm_object_link(&udisp->object, object);
+	return 0;
 }
 
 static int
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 105/156] drm/nouveau/nvif: rework disp "new outp" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (103 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 104/156] drm/nouveau/nvif: remove conn from object rb Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 106/156] drm/nouveau/nvif: rework outp "detect" api Ben Skeggs
                   ` (52 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/dispnv50/disp.c       | 40 ++++----
 .../gpu/drm/nouveau/include/nvif/driverif.h   | 47 ++++++++++
 drivers/gpu/drm/nouveau/include/nvif/if0012.h | 37 --------
 drivers/gpu/drm/nouveau/include/nvif/outp.h   | 43 +--------
 drivers/gpu/drm/nouveau/nvif/outp.c           | 59 ++----------
 .../gpu/drm/nouveau/nvkm/engine/disp/priv.h   |  1 -
 .../gpu/drm/nouveau/nvkm/engine/disp/udisp.c  | 24 +++--
 .../gpu/drm/nouveau/nvkm/engine/disp/uoutp.c  | 92 +++++++++++--------
 .../gpu/drm/nouveau/nvkm/engine/disp/uoutp.h  |  3 +
 9 files changed, 152 insertions(+), 194 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c b/drivers/gpu/drm/nouveau/dispnv50/disp.c
index 802dccace624..e2d71916326f 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/disp.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c
@@ -1608,7 +1608,7 @@ nv50_sor_dp_watermark_sst(struct nouveau_encoder *outp,
 	u64 NumBlankingLinkClocks;
 	u32 MinHBlank;
 
-	if (outp->outp.info.dp.increased_wm) {
+	if (outp->outp.impl->dp.increased_wm) {
 		watermarkAdjust = DP_CONFIG_INCREASED_WATERMARK_ADJUST;
 		watermarkMinimum = DP_CONFIG_INCREASED_WATERMARK_LIMIT;
 	}
@@ -1822,7 +1822,7 @@ nv50_sor_atomic_enable(struct drm_encoder *encoder, struct drm_atomic_state *sta
 	}
 
 	if (head->func->display_id)
-		head->func->display_id(head, BIT(nv_encoder->outp.id));
+		head->func->display_id(head, BIT(nv_encoder->outp.impl->id));
 
 	nv_encoder->update(nv_encoder, nv_crtc->index, asyh, proto, depth);
 }
@@ -1906,7 +1906,7 @@ nv50_sor_create(struct nouveau_encoder *nv_encoder)
 			nv_encoder->i2c = &nv_connector->aux.ddc;
 		}
 
-		if (nv_connector->type != DCB_CONNECTOR_eDP && nv_encoder->outp.info.dp.mst) {
+		if (nv_connector->type != DCB_CONNECTOR_eDP && nv_encoder->outp.impl->dp.mst) {
 			ret = nv50_mstm_new(nv_encoder, &nv_connector->aux,
 					    16, nv_connector->base.base.id,
 					    &nv_encoder->dp.mstm);
@@ -1914,7 +1914,7 @@ nv50_sor_create(struct nouveau_encoder *nv_encoder)
 				return ret;
 		}
 	} else
-	if (nv_encoder->outp.info.ddc != NVIF_OUTP_DDC_INVALID) {
+	if (nv_encoder->outp.impl->ddc != NVIF_OUTP_DDC_INVALID) {
 		struct nvkm_i2c_bus *bus =
 			nvkm_i2c_bus_find(i2c, dcbe->i2c_index);
 		if (bus)
@@ -2037,12 +2037,12 @@ nv50_pior_create(struct nouveau_encoder *nv_encoder)
 
 	switch (dcbe->type) {
 	case DCB_OUTPUT_TMDS:
-		bus  = nvkm_i2c_bus_find(i2c, nv_encoder->outp.info.ddc);
+		bus  = nvkm_i2c_bus_find(i2c, nv_encoder->outp.impl->ddc);
 		ddc  = bus ? &bus->i2c : NULL;
 		type = DRM_MODE_ENCODER_TMDS;
 		break;
 	case DCB_OUTPUT_DP:
-		aux  = nvkm_i2c_aux_find(i2c, nv_encoder->outp.info.dp.aux);
+		aux  = nvkm_i2c_aux_find(i2c, nv_encoder->outp.impl->dp.aux);
 		ddc  = aux ? &aux->i2c : NULL;
 		type = DRM_MODE_ENCODER_TMDS;
 		break;
@@ -2897,14 +2897,14 @@ nv50_display_create(struct drm_device *dev)
 			continue;
 		}
 
-		connector = nouveau_connector_create(dev, outp->outp.info.conn);
+		connector = nouveau_connector_create(dev, outp->outp.impl->conn);
 		if (IS_ERR(connector)) {
 			nvif_outp_dtor(&outp->outp);
 			kfree(outp);
 			continue;
 		}
 
-		outp->base.base.possible_crtcs = outp->outp.info.heads;
+		outp->base.base.possible_crtcs = outp->outp.impl->heads;
 		outp->base.base.possible_clones = 0;
 		outp->conn = nouveau_connector(connector);
 
@@ -2912,24 +2912,24 @@ nv50_display_create(struct drm_device *dev)
 		if (!outp->dcb)
 			break;
 
-		switch (outp->outp.info.proto) {
+		switch (outp->outp.impl->proto) {
 		case NVIF_OUTP_RGB_CRT:
 			outp->dcb->type = DCB_OUTPUT_ANALOG;
-			outp->dcb->crtconf.maxfreq = outp->outp.info.rgb_crt.freq_max;
+			outp->dcb->crtconf.maxfreq = outp->outp.impl->rgb_crt.freq_max;
 			break;
 		case NVIF_OUTP_TMDS:
 			outp->dcb->type = DCB_OUTPUT_TMDS;
-			outp->dcb->duallink_possible = outp->outp.info.tmds.dual;
+			outp->dcb->duallink_possible = outp->outp.impl->tmds.dual;
 			break;
 		case NVIF_OUTP_LVDS:
 			outp->dcb->type = DCB_OUTPUT_LVDS;
-			outp->dcb->lvdsconf.use_acpi_for_edid = outp->outp.info.lvds.acpi_edid;
+			outp->dcb->lvdsconf.use_acpi_for_edid = outp->outp.impl->lvds.acpi_edid;
 			break;
 		case NVIF_OUTP_DP:
 			outp->dcb->type = DCB_OUTPUT_DP;
-			outp->dcb->dpconf.link_nr = outp->outp.info.dp.link_nr;
-			outp->dcb->dpconf.link_bw = outp->outp.info.dp.link_bw;
-			if (outp->outp.info.dp.mst)
+			outp->dcb->dpconf.link_nr = outp->outp.impl->dp.link_nr;
+			outp->dcb->dpconf.link_bw = outp->outp.impl->dp.link_bw;
+			if (outp->outp.impl->dp.mst)
 				has_mst = true;
 			break;
 		default:
@@ -2937,11 +2937,11 @@ nv50_display_create(struct drm_device *dev)
 			continue;
 		}
 
-		outp->dcb->heads = outp->outp.info.heads;
-		outp->dcb->connector = outp->outp.info.conn;
-		outp->dcb->i2c_index = outp->outp.info.ddc;
+		outp->dcb->heads = outp->outp.impl->heads;
+		outp->dcb->connector = outp->outp.impl->conn;
+		outp->dcb->i2c_index = outp->outp.impl->ddc;
 
-		switch (outp->outp.info.type) {
+		switch (outp->outp.impl->type) {
 		case NVIF_OUTP_DAC : ret = nv50_dac_create(outp); break;
 		case NVIF_OUTP_SOR : ret = nv50_sor_create(outp); break;
 		case NVIF_OUTP_PIOR: ret = nv50_pior_create(outp); break;
@@ -2952,7 +2952,7 @@ nv50_display_create(struct drm_device *dev)
 
 		if (ret) {
 			NV_WARN(drm, "failed to create encoder %d/%d/%d: %d\n",
-				i, outp->outp.info.type, outp->outp.info.proto, ret);
+				i, outp->outp.impl->type, outp->outp.impl->proto, ret);
 		}
 	}
 
diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index e59d2a4ec4d0..8d00ed58323f 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -13,6 +13,7 @@ struct nvif_faultbuf_priv;
 struct nvif_disp_priv;
 struct nvif_disp_caps_priv;
 struct nvif_conn_priv;
+struct nvif_outp_priv;
 
 struct nvif_driver {
 	const char *name;
@@ -243,6 +244,50 @@ struct nvif_conn_impl {
 		     const struct nvif_event_impl **, struct nvif_event_priv **);
 };
 
+struct nvif_outp_impl {
+	void (*del)(struct nvif_outp_priv *);
+
+	u8 id;
+
+	enum nvif_outp_type {
+		NVIF_OUTP_DAC,
+		NVIF_OUTP_SOR,
+		NVIF_OUTP_PIOR,
+	} type;
+
+	enum nvif_outp_proto {
+		NVIF_OUTP_RGB_CRT,
+		NVIF_OUTP_TMDS,
+		NVIF_OUTP_LVDS,
+		NVIF_OUTP_DP,
+	} proto;
+
+	u8 heads;
+#define NVIF_OUTP_DDC_INVALID 0xff
+	u8 ddc;
+	u8 conn;
+
+	struct {
+		u32 freq_max;
+	} rgb_crt;
+
+	struct {
+		u8 dual;
+	} tmds;
+
+	struct {
+		u8 acpi_edid;
+	} lvds;
+
+	struct {
+		u8 aux;
+		u8 mst;
+		u8 increased_wm;
+		u8 link_nr;
+		u32 link_bw;
+	} dp;
+};
+
 struct nvif_disp_impl {
 	void (*del)(struct nvif_disp_priv *);
 
@@ -260,6 +305,8 @@ struct nvif_disp_impl {
 
 	struct {
 		u32 mask;
+		int (*new)(struct nvif_disp_priv *, u8 id,
+			   const struct nvif_outp_impl **, struct nvif_outp_priv **, u64 handle);
 	} outp;
 
 	struct {
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0012.h b/drivers/gpu/drm/nouveau/include/nvif/if0012.h
index bde9bfae8d11..d1e2f0ff8965 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/if0012.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/if0012.h
@@ -4,43 +4,6 @@
 
 #include <drm/display/drm_dp.h>
 
-union nvif_outp_args {
-	struct nvif_outp_v0 {
-		__u8 version;
-		__u8 id;	/* DCB device index. */
-#define NVIF_OUTP_V0_TYPE_DAC  0x00
-#define NVIF_OUTP_V0_TYPE_SOR  0x01
-#define NVIF_OUTP_V0_TYPE_PIOR 0x02
-		__u8 type;
-#define NVIF_OUTP_V0_PROTO_RGB_CRT 0x00
-#define NVIF_OUTP_V0_PROTO_TMDS    0x01
-#define NVIF_OUTP_V0_PROTO_LVDS    0x02
-#define NVIF_OUTP_V0_PROTO_DP      0x03
-	        __u8 proto;
-	        __u8 heads;
-	        __u8 ddc;
-	        __u8 conn;
-		union {
-			struct {
-				__u32 freq_max;
-			} rgb_crt;
-			struct {
-				__u8  dual;
-			} tmds;
-			struct {
-				__u8  acpi_edid;
-			} lvds;
-			struct {
-				__u8  aux;
-				__u8  mst;
-				__u8  increased_wm;
-				__u8  link_nr;
-				__u32 link_bw;
-			} dp;
-		};
-	} v0;
-};
-
 #define NVIF_OUTP_V0_DETECT        0x00
 #define NVIF_OUTP_V0_EDID_GET      0x01
 
diff --git a/drivers/gpu/drm/nouveau/include/nvif/outp.h b/drivers/gpu/drm/nouveau/include/nvif/outp.h
index bc122a5ba7df..56bfbc41a576 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/outp.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/outp.h
@@ -2,52 +2,15 @@
 #ifndef __NVIF_OUTP_H__
 #define __NVIF_OUTP_H__
 #include <nvif/object.h>
+#include <nvif/driverif.h>
 #include <nvif/if0012.h>
 #include <drm/display/drm_dp.h>
 struct nvif_disp;
 
 struct nvif_outp {
+	const struct nvif_outp_impl *impl;
+	struct nvif_outp_priv *priv;
 	struct nvif_object object;
-	u32 id;
-
-	struct {
-		enum {
-			NVIF_OUTP_DAC,
-			NVIF_OUTP_SOR,
-			NVIF_OUTP_PIOR,
-		} type;
-
-		enum {
-			NVIF_OUTP_RGB_CRT,
-			NVIF_OUTP_TMDS,
-			NVIF_OUTP_LVDS,
-			NVIF_OUTP_DP,
-		} proto;
-
-		u8 heads;
-#define NVIF_OUTP_DDC_INVALID 0xff
-		u8 ddc;
-		u8 conn;
-
-		union {
-			struct {
-				u32 freq_max;
-			} rgb_crt;
-			struct {
-				bool dual;
-			} tmds;
-			struct {
-				bool acpi_edid;
-			} lvds;
-			struct {
-				u8   aux;
-				bool mst;
-				bool increased_wm;
-				u8   link_nr;
-				u32  link_bw;
-			} dp;
-		};
-	} info;
 
 	struct {
 		int id;
diff --git a/drivers/gpu/drm/nouveau/nvif/outp.c b/drivers/gpu/drm/nouveau/nvif/outp.c
index 6daeb7f0b09b..a8012a71a50c 100644
--- a/drivers/gpu/drm/nouveau/nvif/outp.c
+++ b/drivers/gpu/drm/nouveau/nvif/outp.c
@@ -492,68 +492,25 @@ nvif_outp_detect(struct nvif_outp *outp)
 void
 nvif_outp_dtor(struct nvif_outp *outp)
 {
-	nvif_object_dtor(&outp->object);
+	if (!outp->impl)
+		return;
+
+	outp->impl->del(outp->priv);
+	outp->impl = NULL;
 }
 
 int
 nvif_outp_ctor(struct nvif_disp *disp, const char *name, int id, struct nvif_outp *outp)
 {
-	struct nvif_outp_v0 args;
 	int ret;
 
-	args.version = 0;
-	args.id = id;
-
-	ret = nvif_object_ctor(&disp->object, name ?: "nvifOutp", id, NVIF_CLASS_OUTP,
-			       &args, sizeof(args), &outp->object);
+	ret = disp->impl->outp.new(disp->priv, id, &outp->impl, &outp->priv,
+				   nvif_handle(&outp->object));
 	NVIF_ERRON(ret, &disp->object, "[NEW outp id:%d]", id);
 	if (ret)
 		return ret;
 
-	outp->id = args.id;
-
-	switch (args.type) {
-	case NVIF_OUTP_V0_TYPE_DAC : outp->info.type = NVIF_OUTP_DAC; break;
-	case NVIF_OUTP_V0_TYPE_SOR : outp->info.type = NVIF_OUTP_SOR; break;
-	case NVIF_OUTP_V0_TYPE_PIOR: outp->info.type = NVIF_OUTP_PIOR; break;
-		break;
-	default:
-		WARN_ON(1);
-		nvif_outp_dtor(outp);
-		return -EINVAL;
-	}
-
-	switch (args.proto) {
-	case NVIF_OUTP_V0_PROTO_RGB_CRT:
-		outp->info.proto = NVIF_OUTP_RGB_CRT;
-		outp->info.rgb_crt.freq_max = args.rgb_crt.freq_max;
-		break;
-	case NVIF_OUTP_V0_PROTO_TMDS:
-		outp->info.proto = NVIF_OUTP_TMDS;
-		outp->info.tmds.dual = args.tmds.dual;
-		break;
-	case NVIF_OUTP_V0_PROTO_LVDS:
-		outp->info.proto = NVIF_OUTP_LVDS;
-		outp->info.lvds.acpi_edid = args.lvds.acpi_edid;
-		break;
-	case NVIF_OUTP_V0_PROTO_DP:
-		outp->info.proto = NVIF_OUTP_DP;
-		outp->info.dp.aux = args.dp.aux;
-		outp->info.dp.mst = args.dp.mst;
-		outp->info.dp.increased_wm = args.dp.increased_wm;
-		outp->info.dp.link_nr = args.dp.link_nr;
-		outp->info.dp.link_bw = args.dp.link_bw;
-		break;
-	default:
-		WARN_ON(1);
-		nvif_outp_dtor(outp);
-		return -EINVAL;
-	}
-
-	outp->info.heads = args.heads;
-	outp->info.ddc = args.ddc;
-	outp->info.conn = args.conn;
-
+	nvif_object_ctor(&disp->object, name ?: "nvifOutp", id, 0, &outp->object);
 	outp->or.id = -1;
 	return 0;
 }
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/priv.h b/drivers/gpu/drm/nouveau/nvkm/engine/disp/priv.h
index 890cfb23da77..0163660f215d 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/priv.h
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/priv.h
@@ -89,6 +89,5 @@ void nv50_disp_chan_uevent_send(struct nvkm_disp *, int);
 extern const struct nvkm_event_func gf119_disp_chan_uevent;
 extern const struct nvkm_event_func gv100_disp_chan_uevent;
 
-int nvkm_uoutp_new(const struct nvkm_oclass *, void *, u32, struct nvkm_object **);
 int nvkm_uhead_new(const struct nvkm_oclass *, void *, u32, struct nvkm_object **);
 #endif
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c
index 65e8b3fec655..678121ab469f 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c
@@ -24,7 +24,7 @@
 #include "chan.h"
 #include "uconn.h"
 #include "head.h"
-#include "outp.h"
+#include "uoutp.h"
 
 #include <nvif/class.h>
 
@@ -33,12 +33,6 @@ nvkm_udisp_sclass(struct nvkm_object *object, int index, struct nvkm_oclass *scl
 {
 	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_OUTP };
-		sclass->ctor = nvkm_uoutp_new;
-		return 0;
-	}
-
 	if (index-- == 0) {
 		sclass->base = (struct nvkm_sclass) { 0, 0, NVIF_CLASS_HEAD };
 		sclass->ctor = nvkm_uhead_new;
@@ -90,6 +84,21 @@ nvkm_udisp_sclass(struct nvkm_object *object, int index, struct nvkm_oclass *scl
 	return -EINVAL;
 }
 
+static int
+nvkm_udisp_outp_new(struct nvif_disp_priv *udisp, u8 id,
+		    const struct nvif_outp_impl **pimpl, struct nvif_outp_priv **ppriv,
+		    u64 handle)
+{
+	struct nvkm_object *object;
+	int ret;
+
+	ret = nvkm_uoutp_new(udisp->disp, id, pimpl, ppriv, &object);
+	if (ret)
+		return ret;
+
+	return nvkm_object_link_rb(udisp->object.client, &udisp->object, handle, object);
+}
+
 static int
 nvkm_udisp_conn_new(struct nvif_disp_priv *udisp, u8 id,
 		    const struct nvif_conn_impl **pimpl, struct nvif_conn_priv **ppriv)
@@ -133,6 +142,7 @@ static const struct nvif_disp_impl
 nvkm_udisp_impl = {
 	.del = nvkm_udisp_del,
 	.conn.new = nvkm_udisp_conn_new,
+	.outp.new = nvkm_udisp_outp_new,
 };
 
 static void *
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
index 8d39dad73a40..b585b781e928 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
@@ -31,6 +31,8 @@
 struct nvif_outp_priv {
 	struct nvkm_object object;
 	struct nvkm_outp *outp;
+
+	struct nvif_outp_impl impl;
 };
 
 static int
@@ -568,6 +570,19 @@ nvkm_uoutp_mthd(struct nvkm_object *object, u32 mthd, void *argv, u32 argc)
 	return ret;
 }
 
+static void
+nvkm_uoutp_del(struct nvif_outp_priv *uoutp)
+{
+	struct nvkm_object *object = &uoutp->object;
+
+	nvkm_object_del(&object);
+}
+
+static const struct nvif_outp_impl
+nvkm_uoutp_impl = {
+	.del = nvkm_uoutp_del,
+};
+
 static void *
 nvkm_uoutp_dtor(struct nvkm_object *object)
 {
@@ -586,20 +601,15 @@ 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)
+nvkm_uoutp_new(struct nvkm_disp *disp, u8 id, const struct nvif_outp_impl **pimpl,
+	       struct nvif_outp_priv **ppriv, struct nvkm_object **pobject)
 {
-	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;
 	struct nvif_outp_priv *uoutp;
 
-	if (argc != sizeof(args->v0) || args->v0.version != 0)
-		return -ENOSYS;
-
 	list_for_each_entry(outt, &disp->outps, head) {
-		if (outt->index == args->v0.id) {
+		if (outt->index == id) {
 			outp = outt;
 			break;
 		}
@@ -608,56 +618,62 @@ nvkm_uoutp_new(const struct nvkm_oclass *oclass, void *argv, u32 argc, struct nv
 	if (!outp)
 		return -EINVAL;
 
+	uoutp = kzalloc(sizeof(*uoutp), GFP_KERNEL);
+	if (!uoutp)
+		return -ENOMEM;
+
+	nvkm_object_ctor(&nvkm_uoutp, &(struct nvkm_oclass) {}, &uoutp->object);
+	uoutp->outp = outp;
+	uoutp->impl = nvkm_uoutp_impl;
+	uoutp->impl.id = id;
+
 	switch (outp->info.type) {
 	case DCB_OUTPUT_ANALOG:
-		args->v0.type = NVIF_OUTP_V0_TYPE_DAC;
-		args->v0.proto = NVIF_OUTP_V0_PROTO_RGB_CRT;
-		args->v0.rgb_crt.freq_max = outp->info.crtconf.maxfreq;
+		uoutp->impl.type = NVIF_OUTP_DAC;
+		uoutp->impl.proto = NVIF_OUTP_RGB_CRT;
+		uoutp->impl.rgb_crt.freq_max = outp->info.crtconf.maxfreq;
 		break;
 	case DCB_OUTPUT_TMDS:
 		if (!outp->info.location) {
-			args->v0.type = NVIF_OUTP_V0_TYPE_SOR;
-			args->v0.tmds.dual = (outp->info.tmdsconf.sor.link == 3);
+			uoutp->impl.type = NVIF_OUTP_SOR;
+			uoutp->impl.tmds.dual = (outp->info.tmdsconf.sor.link == 3);
 		} else {
-			args->v0.type = NVIF_OUTP_V0_TYPE_PIOR;
-			args->v0.tmds.dual = 0;
+			uoutp->impl.type = NVIF_OUTP_PIOR;
+			uoutp->impl.tmds.dual = 0;
 		}
-		args->v0.proto = NVIF_OUTP_V0_PROTO_TMDS;
+		uoutp->impl.proto = NVIF_OUTP_TMDS;
 		break;
 	case DCB_OUTPUT_LVDS:
-		args->v0.type = NVIF_OUTP_V0_TYPE_SOR;
-		args->v0.proto = NVIF_OUTP_V0_PROTO_LVDS;
-		args->v0.lvds.acpi_edid = outp->info.lvdsconf.use_acpi_for_edid;
+		uoutp->impl.type = NVIF_OUTP_SOR;
+		uoutp->impl.proto = NVIF_OUTP_LVDS;
+		uoutp->impl.lvds.acpi_edid = outp->info.lvdsconf.use_acpi_for_edid;
 		break;
 	case DCB_OUTPUT_DP:
 		if (!outp->info.location) {
-			args->v0.type = NVIF_OUTP_V0_TYPE_SOR;
-			args->v0.dp.aux = outp->info.i2c_index;
+			uoutp->impl.type = NVIF_OUTP_SOR;
+			uoutp->impl.dp.aux = outp->info.i2c_index;
 		} else {
-			args->v0.type = NVIF_OUTP_V0_TYPE_PIOR;
-			args->v0.dp.aux = NVKM_I2C_AUX_EXT(outp->info.extdev);
+			uoutp->impl.type = NVIF_OUTP_PIOR;
+			uoutp->impl.dp.aux = NVKM_I2C_AUX_EXT(outp->info.extdev);
 		}
-		args->v0.proto = NVIF_OUTP_V0_PROTO_DP;
-		args->v0.dp.mst = outp->dp.mst;
-		args->v0.dp.increased_wm = outp->dp.increased_wm;
-		args->v0.dp.link_nr = outp->info.dpconf.link_nr;
-		args->v0.dp.link_bw = outp->info.dpconf.link_bw * 27000;
+		uoutp->impl.proto = NVIF_OUTP_DP;
+		uoutp->impl.dp.mst = outp->dp.mst;
+		uoutp->impl.dp.increased_wm = outp->dp.increased_wm;
+		uoutp->impl.dp.link_nr = outp->info.dpconf.link_nr;
+		uoutp->impl.dp.link_bw = outp->info.dpconf.link_bw * 27000;
 		break;
 	default:
 		WARN_ON(1);
+		kfree(uoutp);
 		return -EINVAL;
 	}
 
 	if (outp->info.location)
-		args->v0.ddc = NVKM_I2C_BUS_EXT(outp->info.extdev);
+		uoutp->impl.ddc = NVKM_I2C_BUS_EXT(outp->info.extdev);
 	else
-		args->v0.ddc = outp->info.i2c_index;
-	args->v0.heads = outp->info.heads;
-	args->v0.conn = outp->info.connector;
-
-	uoutp = kzalloc(sizeof(*uoutp), GFP_KERNEL);
-	if (!uoutp)
-		return -ENOMEM;
+		uoutp->impl.ddc = outp->info.i2c_index;
+	uoutp->impl.heads = outp->info.heads;
+	uoutp->impl.conn = outp->info.connector;
 
 	spin_lock(&disp->user.lock);
 	if (outp->user) {
@@ -668,8 +684,8 @@ nvkm_uoutp_new(const struct nvkm_oclass *oclass, void *argv, u32 argc, struct nv
 	outp->user = true;
 	spin_unlock(&disp->user.lock);
 
-	nvkm_object_ctor(&nvkm_uoutp, oclass, &uoutp->object);
-	uoutp->outp = outp;
+	*pimpl = &uoutp->impl;
+	*ppriv = uoutp;
 	*pobject = &uoutp->object;
 	return 0;
 }
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.h b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.h
index 37ecd2891a1a..3455aedd7bbe 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.h
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.h
@@ -2,5 +2,8 @@
 #ifndef __NVKM_UOUTP_H__
 #define __NVKM_UOUTP_H__
 #include "outp.h"
+#include <nvif/driverif.h>
 
+int nvkm_uoutp_new(struct nvkm_disp *, u8 id, const struct nvif_outp_impl **,
+		   struct nvif_outp_priv **, struct nvkm_object **);
 #endif
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 106/156] drm/nouveau/nvif: rework outp "detect" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (104 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 105/156] drm/nouveau/nvif: rework disp "new outp" api Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 107/156] drm/nouveau/nvif: rework outp "edid get" api Ben Skeggs
                   ` (51 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interface

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  8 ++++
 drivers/gpu/drm/nouveau/include/nvif/if0012.h | 11 -----
 drivers/gpu/drm/nouveau/include/nvif/outp.h   |  6 ---
 drivers/gpu/drm/nouveau/nouveau_connector.c   |  6 +--
 drivers/gpu/drm/nouveau/nouveau_dp.c          |  2 +-
 drivers/gpu/drm/nouveau/nvif/outp.c           | 21 ++-------
 .../gpu/drm/nouveau/nvkm/engine/disp/uoutp.c  | 47 ++++++++++++++-----
 7 files changed, 53 insertions(+), 48 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 8d00ed58323f..fd05065374fe 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -244,6 +244,12 @@ struct nvif_conn_impl {
 		     const struct nvif_event_impl **, struct nvif_event_priv **);
 };
 
+enum nvif_outp_detect_status {
+	NVIF_OUTP_DETECT_NOT_PRESENT,
+	NVIF_OUTP_DETECT_PRESENT,
+	NVIF_OUTP_DETECT_UNKNOWN,
+};
+
 struct nvif_outp_impl {
 	void (*del)(struct nvif_outp_priv *);
 
@@ -267,6 +273,8 @@ struct nvif_outp_impl {
 	u8 ddc;
 	u8 conn;
 
+	int (*detect)(struct nvif_outp_priv *, enum nvif_outp_detect_status *);
+
 	struct {
 		u32 freq_max;
 	} rgb_crt;
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0012.h b/drivers/gpu/drm/nouveau/include/nvif/if0012.h
index d1e2f0ff8965..c0c13cb64994 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/if0012.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/if0012.h
@@ -4,7 +4,6 @@
 
 #include <drm/display/drm_dp.h>
 
-#define NVIF_OUTP_V0_DETECT        0x00
 #define NVIF_OUTP_V0_EDID_GET      0x01
 
 #define NVIF_OUTP_V0_INHERIT       0x10
@@ -33,16 +32,6 @@
 #define NVIF_OUTP_V0_DP_MST_ID_PUT 0x77
 #define NVIF_OUTP_V0_DP_MST_VCPI   0x78
 
-union nvif_outp_detect_args {
-	struct nvif_outp_detect_v0 {
-		__u8 version;
-#define NVIF_OUTP_DETECT_V0_NOT_PRESENT 0x00
-#define NVIF_OUTP_DETECT_V0_PRESENT     0x01
-#define NVIF_OUTP_DETECT_V0_UNKNOWN     0x02
-		__u8 status;
-	} v0;
-};
-
 union nvif_outp_edid_get_args {
 	struct nvif_outp_edid_get_v0 {
 		__u8  version;
diff --git a/drivers/gpu/drm/nouveau/include/nvif/outp.h b/drivers/gpu/drm/nouveau/include/nvif/outp.h
index 56bfbc41a576..7a64a7d2ac97 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/outp.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/outp.h
@@ -21,12 +21,6 @@ struct nvif_outp {
 int nvif_outp_ctor(struct nvif_disp *, const char *name, int id, struct nvif_outp *);
 void nvif_outp_dtor(struct nvif_outp *);
 
-enum nvif_outp_detect_status {
-	NOT_PRESENT,
-	PRESENT,
-	UNKNOWN,
-};
-
 enum nvif_outp_detect_status nvif_outp_detect(struct nvif_outp *);
 int nvif_outp_edid_get(struct nvif_outp *, u8 **pedid);
 
diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c b/drivers/gpu/drm/nouveau/nouveau_connector.c
index b1bd8264b703..3063ef792023 100644
--- a/drivers/gpu/drm/nouveau/nouveau_connector.c
+++ b/drivers/gpu/drm/nouveau/nouveau_connector.c
@@ -434,11 +434,11 @@ nouveau_connector_ddc_detect(struct drm_connector *connector)
 			} else {
 				status = nvif_outp_detect(&nv_encoder->outp);
 				switch (status) {
-				case PRESENT:
+				case NVIF_OUTP_DETECT_PRESENT:
 					return nv_encoder;
-				case NOT_PRESENT:
+				case NVIF_OUTP_DETECT_NOT_PRESENT:
 					continue;
-				case UNKNOWN:
+				case NVIF_OUTP_DETECT_UNKNOWN:
 					break;
 				default:
 					WARN_ON(1);
diff --git a/drivers/gpu/drm/nouveau/nouveau_dp.c b/drivers/gpu/drm/nouveau/nouveau_dp.c
index a72c45809484..cf196af96609 100644
--- a/drivers/gpu/drm/nouveau/nouveau_dp.c
+++ b/drivers/gpu/drm/nouveau/nouveau_dp.c
@@ -256,7 +256,7 @@ nouveau_dp_detect(struct nouveau_connector *nv_connector,
 	}
 
 	hpd = nvif_outp_detect(&nv_encoder->outp);
-	if (hpd == NOT_PRESENT) {
+	if (hpd == NVIF_OUTP_DETECT_NOT_PRESENT) {
 		nvif_outp_dp_aux_pwr(&nv_encoder->outp, false);
 		goto out;
 	}
diff --git a/drivers/gpu/drm/nouveau/nvif/outp.c b/drivers/gpu/drm/nouveau/nvif/outp.c
index a8012a71a50c..b704886c1bb6 100644
--- a/drivers/gpu/drm/nouveau/nvif/outp.c
+++ b/drivers/gpu/drm/nouveau/nvif/outp.c
@@ -467,26 +467,15 @@ nvif_outp_edid_get(struct nvif_outp *outp, u8 **pedid)
 enum nvif_outp_detect_status
 nvif_outp_detect(struct nvif_outp *outp)
 {
-	struct nvif_outp_detect_v0 args;
+	enum nvif_outp_detect_status status;
 	int ret;
 
-	args.version = 0;
-
-	ret = nvif_mthd(&outp->object, NVIF_OUTP_V0_DETECT, &args, sizeof(args));
-	NVIF_ERRON(ret, &outp->object, "[DETECT] status:%02x", args.status);
+	ret = outp->impl->detect(outp->priv, &status);
+	NVIF_ERRON(ret, &outp->object, "[DETECT] status:%02x", status);
 	if (ret)
-		return UNKNOWN;
-
-	switch (args.status) {
-	case NVIF_OUTP_DETECT_V0_NOT_PRESENT: return NOT_PRESENT;
-	case NVIF_OUTP_DETECT_V0_PRESENT: return PRESENT;
-	case NVIF_OUTP_DETECT_V0_UNKNOWN: return UNKNOWN;
-	default:
-		WARN_ON(1);
-		break;
-	}
+		return NVIF_OUTP_DETECT_UNKNOWN;
 
-	return UNKNOWN;
+	return status;
 }
 
 void
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
index b585b781e928..2324549787b6 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
@@ -35,6 +35,31 @@ struct nvif_outp_priv {
 	struct nvif_outp_impl impl;
 };
 
+static inline void
+nvkm_uoutp_unlock(struct nvif_outp_priv *uoutp)
+{
+	mutex_unlock(&uoutp->outp->disp->super.mutex);
+}
+
+static inline void
+nvkm_uoutp_lock(struct nvif_outp_priv *uoutp)
+{
+	mutex_lock(&uoutp->outp->disp->super.mutex);
+}
+
+static inline int
+nvkm_uoutp_lock_acquired(struct nvif_outp_priv *uoutp)
+{
+	nvkm_uoutp_lock(uoutp);
+
+	if (!uoutp->outp->ior) {
+		nvkm_uoutp_unlock(uoutp);
+		return -EIO;
+	}
+
+	return 0;
+}
+
 static int
 nvkm_uoutp_mthd_dp_mst_vcpi(struct nvkm_outp *outp, void *argv, u32 argc)
 {
@@ -480,22 +505,20 @@ nvkm_uoutp_mthd_edid_get(struct nvkm_outp *outp, void *argv, u32 argc)
 }
 
 static int
-nvkm_uoutp_mthd_detect(struct nvkm_outp *outp, void *argv, u32 argc)
+nvkm_uoutp_detect(struct nvif_outp_priv *uoutp, enum nvif_outp_detect_status *status)
 {
-	union nvif_outp_detect_args *args = argv;
+	struct nvkm_outp *outp = uoutp->outp;
 	int ret;
 
-	if (argc != sizeof(args->v0) || args->v0.version != 0)
-		return -ENOSYS;
-	if (!outp->func->detect)
-		return -EINVAL;
-
+	nvkm_uoutp_lock(uoutp);
 	ret = outp->func->detect(outp);
+	nvkm_uoutp_unlock(uoutp);
+
 	switch (ret) {
-	case 0: args->v0.status = NVIF_OUTP_DETECT_V0_NOT_PRESENT; break;
-	case 1: args->v0.status = NVIF_OUTP_DETECT_V0_PRESENT; break;
+	case 0: *status = NVIF_OUTP_DETECT_NOT_PRESENT; break;
+	case 1: *status = NVIF_OUTP_DETECT_PRESENT; break;
 	default:
-		args->v0.status = NVIF_OUTP_DETECT_V0_UNKNOWN;
+		*status = NVIF_OUTP_DETECT_UNKNOWN;
 		break;
 	}
 
@@ -528,7 +551,6 @@ static int
 nvkm_uoutp_mthd_noacquire(struct nvkm_outp *outp, u32 mthd, void *argv, u32 argc, bool *invalid)
 {
 	switch (mthd) {
-	case NVIF_OUTP_V0_DETECT     : return nvkm_uoutp_mthd_detect     (outp, argv, argc);
 	case NVIF_OUTP_V0_EDID_GET   : return nvkm_uoutp_mthd_edid_get   (outp, argv, argc);
 	case NVIF_OUTP_V0_INHERIT    : return nvkm_uoutp_mthd_inherit    (outp, argv, argc);
 	case NVIF_OUTP_V0_ACQUIRE    : return nvkm_uoutp_mthd_acquire    (outp, argv, argc);
@@ -627,6 +649,9 @@ nvkm_uoutp_new(struct nvkm_disp *disp, u8 id, const struct nvif_outp_impl **pimp
 	uoutp->impl = nvkm_uoutp_impl;
 	uoutp->impl.id = id;
 
+	if (outp->func->detect)
+		uoutp->impl.detect = nvkm_uoutp_detect;
+
 	switch (outp->info.type) {
 	case DCB_OUTPUT_ANALOG:
 		uoutp->impl.type = NVIF_OUTP_DAC;
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 107/156] drm/nouveau/nvif: rework outp "edid get" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (105 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 106/156] drm/nouveau/nvif: rework outp "detect" api Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 108/156] drm/nouveau/nvif: rework outp "load detect" api Ben Skeggs
                   ` (50 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interface

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  1 +
 drivers/gpu/drm/nouveau/include/nvif/if0012.h | 11 -----------
 drivers/gpu/drm/nouveau/nvif/outp.c           | 19 +++++++++----------
 .../gpu/drm/nouveau/nvkm/engine/disp/uoutp.c  | 19 +++++++++----------
 4 files changed, 19 insertions(+), 31 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index fd05065374fe..966a9bb543d1 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -274,6 +274,7 @@ struct nvif_outp_impl {
 	u8 conn;
 
 	int (*detect)(struct nvif_outp_priv *, enum nvif_outp_detect_status *);
+	int (*edid_get)(struct nvif_outp_priv *, u8 *data, u16 *size);
 
 	struct {
 		u32 freq_max;
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0012.h b/drivers/gpu/drm/nouveau/include/nvif/if0012.h
index c0c13cb64994..80c4da3e8aa5 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/if0012.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/if0012.h
@@ -4,8 +4,6 @@
 
 #include <drm/display/drm_dp.h>
 
-#define NVIF_OUTP_V0_EDID_GET      0x01
-
 #define NVIF_OUTP_V0_INHERIT       0x10
 #define NVIF_OUTP_V0_ACQUIRE       0x11
 #define NVIF_OUTP_V0_RELEASE       0x12
@@ -32,15 +30,6 @@
 #define NVIF_OUTP_V0_DP_MST_ID_PUT 0x77
 #define NVIF_OUTP_V0_DP_MST_VCPI   0x78
 
-union nvif_outp_edid_get_args {
-	struct nvif_outp_edid_get_v0 {
-		__u8  version;
-		__u8  pad01;
-		__u16 size;
-		__u8  data[2048];
-	} v0;
-};
-
 union nvif_outp_load_detect_args {
 	struct nvif_outp_load_detect_v0 {
 		__u8  version;
diff --git a/drivers/gpu/drm/nouveau/nvif/outp.c b/drivers/gpu/drm/nouveau/nvif/outp.c
index b704886c1bb6..56441763e3da 100644
--- a/drivers/gpu/drm/nouveau/nvif/outp.c
+++ b/drivers/gpu/drm/nouveau/nvif/outp.c
@@ -438,29 +438,28 @@ nvif_outp_load_detect(struct nvif_outp *outp, u32 loadval)
 int
 nvif_outp_edid_get(struct nvif_outp *outp, u8 **pedid)
 {
-	struct nvif_outp_edid_get_v0 *args;
+	u16 size = 2048;
+	u8 *data;
 	int ret;
 
-	args = kmalloc(sizeof(*args), GFP_KERNEL);
-	if (!args)
+	data = kmalloc(size, GFP_KERNEL);
+	if (!data)
 		return -ENOMEM;
 
-	args->version = 0;
-
-	ret = nvif_mthd(&outp->object, NVIF_OUTP_V0_EDID_GET, args, sizeof(*args));
-	NVIF_ERRON(ret, &outp->object, "[EDID_GET] size:%d", args->size);
+	ret = outp->impl->edid_get(outp->priv, data, &size);
+	NVIF_ERRON(ret, &outp->object, "[EDID_GET] size:%d", size);
 	if (ret)
 		goto done;
 
-	*pedid = kmemdup(args->data, args->size, GFP_KERNEL);
+	*pedid = kmemdup(data, size, GFP_KERNEL);
 	if (!*pedid) {
 		ret = -ENOMEM;
 		goto done;
 	}
 
-	ret = args->size;
+	ret = size;
 done:
-	kfree(args);
+	kfree(data);
 	return ret;
 }
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
index 2324549787b6..37521fa2cbfe 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
@@ -491,17 +491,15 @@ nvkm_uoutp_mthd_load_detect(struct nvkm_outp *outp, void *argv, u32 argc)
 }
 
 static int
-nvkm_uoutp_mthd_edid_get(struct nvkm_outp *outp, void *argv, u32 argc)
+nvkm_uoutp_edid_get(struct nvif_outp_priv *uoutp, u8 *data, u16 *size)
 {
-	union nvif_outp_edid_get_args *args = argv;
-
-	if (argc != sizeof(args->v0) || args->v0.version != 0)
-		return -ENOSYS;
-	if (!outp->func->edid_get)
-		return -EINVAL;
+	struct nvkm_outp *outp = uoutp->outp;
+	int ret;
 
-	args->v0.size = ARRAY_SIZE(args->v0.data);
-	return outp->func->edid_get(outp, args->v0.data, &args->v0.size);
+	nvkm_uoutp_lock(uoutp);
+	ret = outp->func->edid_get(outp, data, size);
+	nvkm_uoutp_unlock(uoutp);
+	return ret;
 }
 
 static int
@@ -551,7 +549,6 @@ static int
 nvkm_uoutp_mthd_noacquire(struct nvkm_outp *outp, u32 mthd, void *argv, u32 argc, bool *invalid)
 {
 	switch (mthd) {
-	case NVIF_OUTP_V0_EDID_GET   : return nvkm_uoutp_mthd_edid_get   (outp, argv, argc);
 	case NVIF_OUTP_V0_INHERIT    : return nvkm_uoutp_mthd_inherit    (outp, argv, argc);
 	case NVIF_OUTP_V0_ACQUIRE    : return nvkm_uoutp_mthd_acquire    (outp, argv, argc);
 	case NVIF_OUTP_V0_LOAD_DETECT: return nvkm_uoutp_mthd_load_detect(outp, argv, argc);
@@ -651,6 +648,8 @@ nvkm_uoutp_new(struct nvkm_disp *disp, u8 id, const struct nvif_outp_impl **pimp
 
 	if (outp->func->detect)
 		uoutp->impl.detect = nvkm_uoutp_detect;
+	if (outp->func->edid_get)
+		uoutp->impl.edid_get = nvkm_uoutp_edid_get;
 
 	switch (outp->info.type) {
 	case DCB_OUTPUT_ANALOG:
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 108/156] drm/nouveau/nvif: rework outp "load detect" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (106 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 107/156] drm/nouveau/nvif: rework outp "edid get" api Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 109/156] drm/nouveau/nvif: rework outp "inherit" apis Ben Skeggs
                   ` (49 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interface

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/include/nvif/driverif.h  |  2 ++
 drivers/gpu/drm/nouveau/include/nvif/if0012.h    | 11 -----------
 drivers/gpu/drm/nouveau/nvif/outp.c              | 11 ++++-------
 drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c | 15 ++++++++-------
 4 files changed, 14 insertions(+), 25 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 966a9bb543d1..39b0e8d002f8 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -276,6 +276,8 @@ struct nvif_outp_impl {
 	int (*detect)(struct nvif_outp_priv *, enum nvif_outp_detect_status *);
 	int (*edid_get)(struct nvif_outp_priv *, u8 *data, u16 *size);
 
+	int (*load_detect)(struct nvif_outp_priv *, u32 loadval, u8 *load);
+
 	struct {
 		u32 freq_max;
 	} rgb_crt;
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0012.h b/drivers/gpu/drm/nouveau/include/nvif/if0012.h
index 80c4da3e8aa5..586b44fa8814 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/if0012.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/if0012.h
@@ -8,8 +8,6 @@
 #define NVIF_OUTP_V0_ACQUIRE       0x11
 #define NVIF_OUTP_V0_RELEASE       0x12
 
-#define NVIF_OUTP_V0_LOAD_DETECT   0x20
-
 #define NVIF_OUTP_V0_BL_GET        0x30
 #define NVIF_OUTP_V0_BL_SET        0x31
 
@@ -30,15 +28,6 @@
 #define NVIF_OUTP_V0_DP_MST_ID_PUT 0x77
 #define NVIF_OUTP_V0_DP_MST_VCPI   0x78
 
-union nvif_outp_load_detect_args {
-	struct nvif_outp_load_detect_v0 {
-		__u8  version;
-		__u8  load;
-		__u8  pad02[2];
-		__u32 data; /*TODO: move vbios loadval parsing into nvkm */
-	} v0;
-};
-
 union nvif_outp_acquire_args {
 	struct nvif_outp_acquire_v0 {
 		__u8 version;
diff --git a/drivers/gpu/drm/nouveau/nvif/outp.c b/drivers/gpu/drm/nouveau/nvif/outp.c
index 56441763e3da..59499eebc5ac 100644
--- a/drivers/gpu/drm/nouveau/nvif/outp.c
+++ b/drivers/gpu/drm/nouveau/nvif/outp.c
@@ -424,15 +424,12 @@ nvif_outp_inherit_rgb_crt(struct nvif_outp *outp, u8 *proto_out)
 int
 nvif_outp_load_detect(struct nvif_outp *outp, u32 loadval)
 {
-	struct nvif_outp_load_detect_v0 args;
+	u8 load;
 	int ret;
 
-	args.version = 0;
-	args.data = loadval;
-
-	ret = nvif_mthd(&outp->object, NVIF_OUTP_V0_LOAD_DETECT, &args, sizeof(args));
-	NVIF_ERRON(ret, &outp->object, "[LOAD_DETECT data:%08x] load:%02x", args.data, args.load);
-	return ret < 0 ? ret : args.load;
+	ret = outp->impl->load_detect(outp->priv, loadval, &load);
+	NVIF_ERRON(ret, &outp->object, "[LOAD_DETECT data:%08x] load:%02x", loadval, load);
+	return ret < 0 ? ret : load;
 }
 
 int
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
index 37521fa2cbfe..d3f69d6a10f3 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
@@ -468,25 +468,25 @@ nvkm_uoutp_mthd_inherit(struct nvkm_outp *outp, void *argv, u32 argc)
 }
 
 static int
-nvkm_uoutp_mthd_load_detect(struct nvkm_outp *outp, void *argv, u32 argc)
+nvkm_uoutp_load_detect(struct nvif_outp_priv *uoutp, u32 loadval, u8 *load)
 {
-	union nvif_outp_load_detect_args *args = argv;
+	struct nvkm_outp *outp = uoutp->outp;
 	int ret;
 
-	if (argc != sizeof(args->v0) || args->v0.version != 0)
-		return -ENOSYS;
+	nvkm_uoutp_lock(uoutp);
 
 	ret = nvkm_outp_acquire_or(outp, NVKM_OUTP_PRIV, false);
 	if (ret == 0) {
 		if (outp->ior->func->sense) {
-			ret = outp->ior->func->sense(outp->ior, args->v0.data);
-			args->v0.load = ret < 0 ? 0 : ret;
+			ret = outp->ior->func->sense(outp->ior, loadval);
+			*load = ret < 0 ? 0 : ret;
 		} else {
 			ret = -EINVAL;
 		}
 		nvkm_outp_release_or(outp, NVKM_OUTP_PRIV);
 	}
 
+	nvkm_uoutp_unlock(uoutp);
 	return ret;
 }
 
@@ -551,7 +551,6 @@ nvkm_uoutp_mthd_noacquire(struct nvkm_outp *outp, u32 mthd, void *argv, u32 argc
 	switch (mthd) {
 	case NVIF_OUTP_V0_INHERIT    : return nvkm_uoutp_mthd_inherit    (outp, argv, argc);
 	case NVIF_OUTP_V0_ACQUIRE    : return nvkm_uoutp_mthd_acquire    (outp, argv, argc);
-	case NVIF_OUTP_V0_LOAD_DETECT: return nvkm_uoutp_mthd_load_detect(outp, argv, argc);
 	case NVIF_OUTP_V0_BL_GET     : return nvkm_uoutp_mthd_bl_get     (outp, argv, argc);
 	case NVIF_OUTP_V0_BL_SET     : return nvkm_uoutp_mthd_bl_set     (outp, argv, argc);
 	case NVIF_OUTP_V0_DP_AUX_PWR : return nvkm_uoutp_mthd_dp_aux_pwr (outp, argv, argc);
@@ -651,6 +650,8 @@ nvkm_uoutp_new(struct nvkm_disp *disp, u8 id, const struct nvif_outp_impl **pimp
 	if (outp->func->edid_get)
 		uoutp->impl.edid_get = nvkm_uoutp_edid_get;
 
+	uoutp->impl.load_detect = nvkm_uoutp_load_detect;
+
 	switch (outp->info.type) {
 	case DCB_OUTPUT_ANALOG:
 		uoutp->impl.type = NVIF_OUTP_DAC;
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 109/156] drm/nouveau/nvif: rework outp "inherit" apis
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (107 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 108/156] drm/nouveau/nvif: rework outp "load detect" api Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 110/156] drm/nouveau/nvif: rework outp "acquire" api Ben Skeggs
                   ` (48 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interfaces

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  3 ++
 drivers/gpu/drm/nouveau/include/nvif/if0012.h | 23 ---------
 drivers/gpu/drm/nouveau/nvif/outp.c           | 40 +++++++--------
 .../gpu/drm/nouveau/nvkm/engine/disp/uoutp.c  | 50 +++++++++----------
 4 files changed, 45 insertions(+), 71 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 39b0e8d002f8..9ab54de43ba3 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -276,6 +276,9 @@ struct nvif_outp_impl {
 	int (*detect)(struct nvif_outp_priv *, enum nvif_outp_detect_status *);
 	int (*edid_get)(struct nvif_outp_priv *, u8 *data, u16 *size);
 
+	int (*inherit)(struct nvif_outp_priv *, enum nvif_outp_proto,
+		       u8 *or, u8 *link, u8 *head, u8 *proto_evo);
+
 	int (*load_detect)(struct nvif_outp_priv *, u32 loadval, u8 *load);
 
 	struct {
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0012.h b/drivers/gpu/drm/nouveau/include/nvif/if0012.h
index 586b44fa8814..09e2f61673a8 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/if0012.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/if0012.h
@@ -4,7 +4,6 @@
 
 #include <drm/display/drm_dp.h>
 
-#define NVIF_OUTP_V0_INHERIT       0x10
 #define NVIF_OUTP_V0_ACQUIRE       0x11
 #define NVIF_OUTP_V0_RELEASE       0x12
 
@@ -46,28 +45,6 @@ union nvif_outp_acquire_args {
 	} v0;
 };
 
-union nvif_outp_inherit_args {
-	struct nvif_outp_inherit_v0 {
-		__u8 version;
-#define NVIF_OUTP_INHERIT_V0_RGB_CRT 0x00
-#define NVIF_OUTP_INHERIT_V0_TV      0x01
-#define NVIF_OUTP_INHERIT_V0_TMDS    0x02
-#define NVIF_OUTP_INHERIT_V0_LVDS    0x03
-#define NVIF_OUTP_INHERIT_V0_DP      0x04
-		// In/out. Input is one of the above values, output is the actual hw protocol
-		__u8 proto;
-		__u8 or;
-		__u8 link;
-		__u8 head;
-		union {
-			struct {
-				// TODO: Figure out padding, and whether we even want this field
-				__u8 hda;
-			} tmds;
-		};
-	} v0;
-};
-
 union nvif_outp_release_args {
 	struct nvif_outp_release_vn {
 	} vn;
diff --git a/drivers/gpu/drm/nouveau/nvif/outp.c b/drivers/gpu/drm/nouveau/nvif/outp.c
index 59499eebc5ac..c98af48b4b33 100644
--- a/drivers/gpu/drm/nouveau/nvif/outp.c
+++ b/drivers/gpu/drm/nouveau/nvif/outp.c
@@ -354,71 +354,65 @@ nvif_outp_acquire_dac(struct nvif_outp *outp)
 }
 
 static int
-nvif_outp_inherit(struct nvif_outp *outp,
-		  u8 proto,
-		  struct nvif_outp_inherit_v0 *args,
-		  u8 *proto_out)
+nvif_outp_inherit(struct nvif_outp *outp, enum nvif_outp_proto proto, u8 *head, u8 *proto_evo)
 {
+	u8 or, link;
 	int ret;
 
-	args->version = 0;
-	args->proto = proto;
-
-	ret = nvif_mthd(&outp->object, NVIF_OUTP_V0_INHERIT, args, sizeof(*args));
+	ret = outp->impl->inherit(outp->priv, proto, &or, &link, head, proto_evo);
 	if (ret)
 		return ret;
 
-	outp->or.id = args->or;
-	outp->or.link = args->link;
-	*proto_out = args->proto;
+	outp->or.id = or;
+	outp->or.link = link;
 	return 0;
 }
 
 int
 nvif_outp_inherit_lvds(struct nvif_outp *outp, u8 *proto_out)
 {
-	struct nvif_outp_inherit_v0 args;
+	u8 head;
 	int ret;
 
-	ret = nvif_outp_inherit(outp, NVIF_OUTP_INHERIT_V0_LVDS, &args, proto_out);
+	ret = nvif_outp_inherit(outp, NVIF_OUTP_LVDS, &head, proto_out);
 	NVIF_ERRON(ret && ret != -ENODEV, &outp->object, "[INHERIT proto:LVDS] ret:%d", ret);
-	return ret ?: args.head;
+	return ret ?: head;
 }
 
 int
 nvif_outp_inherit_tmds(struct nvif_outp *outp, u8 *proto_out)
 {
-	struct nvif_outp_inherit_v0 args;
+	u8 head;
 	int ret;
 
-	ret = nvif_outp_inherit(outp, NVIF_OUTP_INHERIT_V0_TMDS, &args, proto_out);
+	ret = nvif_outp_inherit(outp, NVIF_OUTP_TMDS, &head, proto_out);
 	NVIF_ERRON(ret && ret != -ENODEV, &outp->object, "[INHERIT proto:TMDS] ret:%d", ret);
-	return ret ?: args.head;
+	return ret ?: head;
 }
 
 int
 nvif_outp_inherit_dp(struct nvif_outp *outp, u8 *proto_out)
 {
-	struct nvif_outp_inherit_v0 args;
+	u8 head;
 	int ret;
 
-	ret = nvif_outp_inherit(outp, NVIF_OUTP_INHERIT_V0_DP, &args, proto_out);
+	ret = nvif_outp_inherit(outp, NVIF_OUTP_DP, &head, proto_out);
 	NVIF_ERRON(ret && ret != -ENODEV, &outp->object, "[INHERIT proto:DP] ret:%d", ret);
 
 	// TODO: Get current link info
 
-	return ret ?: args.head;
+	return ret ?: head;
 }
 
 int
 nvif_outp_inherit_rgb_crt(struct nvif_outp *outp, u8 *proto_out)
 {
-	struct nvif_outp_inherit_v0 args;
+	u8 head;
 	int ret;
 
-	ret = nvif_outp_inherit(outp, NVIF_OUTP_INHERIT_V0_RGB_CRT, &args, proto_out);
+	ret = nvif_outp_inherit(outp, NVIF_OUTP_RGB_CRT, &head, proto_out);
 	NVIF_ERRON(ret && ret != -ENODEV, &outp->object, "[INHERIT proto:RGB_CRT] ret:%d", ret);
-	return ret ?: args.head;
+	return ret ?: head;
 }
 
 int
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
index d3f69d6a10f3..3f242a03f77b 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
@@ -405,44 +405,40 @@ nvkm_uoutp_mthd_acquire(struct nvkm_outp *outp, void *argv, u32 argc)
 }
 
 static int
-nvkm_uoutp_mthd_inherit(struct nvkm_outp *outp, void *argv, u32 argc)
+nvkm_uoutp_inherit(struct nvif_outp_priv *uoutp, enum nvif_outp_proto proto,
+		   u8 *or, u8 *link, u8 *head, u8 *proto_evo)
 {
-	union nvif_outp_inherit_args *args = argv;
+	struct nvkm_outp *outp = uoutp->outp;
 	struct nvkm_ior *ior;
-	int ret = 0;
+	int ret = -ENODEV;
 
-	if (argc != sizeof(args->v0) || args->v0.version != 0)
-		return -ENOSYS;
+	nvkm_uoutp_lock(uoutp);
 
 	/* Ensure an ior is hooked up to this outp already */
 	ior = outp->func->inherit(outp);
 	if (!ior || !ior->arm.head)
-		return -ENODEV;
+		goto done;
 
 	/* With iors, there will be a separate output path for each type of connector - and all of
 	 * them will appear to be hooked up. Figure out which one is actually the one we're using
 	 * based on the protocol we were given over nvif
 	 */
-	switch (args->v0.proto) {
-	case NVIF_OUTP_INHERIT_V0_TMDS:
+	switch (proto) {
+	case NVIF_OUTP_TMDS:
 		if (ior->arm.proto != TMDS)
-			return -ENODEV;
+			goto done;
 		break;
-	case NVIF_OUTP_INHERIT_V0_DP:
+	case NVIF_OUTP_DP:
 		if (ior->arm.proto != DP)
-			return -ENODEV;
+			goto done;
 		break;
-	case NVIF_OUTP_INHERIT_V0_LVDS:
+	case NVIF_OUTP_LVDS:
 		if (ior->arm.proto != LVDS)
-			return -ENODEV;
+			goto done;
 		break;
-	case NVIF_OUTP_INHERIT_V0_TV:
-		if (ior->arm.proto != TV)
-			return -ENODEV;
-		break;
-	case NVIF_OUTP_INHERIT_V0_RGB_CRT:
+	case NVIF_OUTP_RGB_CRT:
 		if (ior->arm.proto != CRT)
-			return -ENODEV;
+			goto done;
 		break;
 	default:
 		ret = -EINVAL;
@@ -452,18 +448,22 @@ nvkm_uoutp_mthd_inherit(struct nvkm_outp *outp, void *argv, u32 argc)
 	/* Make sure that userspace hasn't already acquired this */
 	if (outp->acquired) {
 		OUTP_ERR(outp, "cannot inherit an already acquired (%02x) outp", outp->acquired);
-		return -EBUSY;
+		ret = -EBUSY;
+		goto done;
 	}
 
 	/* Mark the outp acquired by userspace now that we've confirmed it's already active */
 	OUTP_TRACE(outp, "inherit %02x |= %02x %p", outp->acquired, NVKM_OUTP_USER, ior);
 	nvkm_outp_acquire_ior(outp, NVKM_OUTP_USER, ior);
 
-	args->v0.or = ior->id;
-	args->v0.link = ior->arm.link;
-	args->v0.head = ffs(ior->arm.head) - 1;
-	args->v0.proto = ior->arm.proto_evo;
+	*or = ior->id;
+	*link = ior->arm.link;
+	*head = ffs(ior->arm.head) - 1;
+	*proto_evo = ior->arm.proto_evo;
 
+	ret = 0;
+done:
+	nvkm_uoutp_unlock(uoutp);
 	return ret;
 }
 
@@ -549,7 +549,6 @@ static int
 nvkm_uoutp_mthd_noacquire(struct nvkm_outp *outp, u32 mthd, void *argv, u32 argc, bool *invalid)
 {
 	switch (mthd) {
-	case NVIF_OUTP_V0_INHERIT    : return nvkm_uoutp_mthd_inherit    (outp, argv, argc);
 	case NVIF_OUTP_V0_ACQUIRE    : return nvkm_uoutp_mthd_acquire    (outp, argv, argc);
 	case NVIF_OUTP_V0_BL_GET     : return nvkm_uoutp_mthd_bl_get     (outp, argv, argc);
 	case NVIF_OUTP_V0_BL_SET     : return nvkm_uoutp_mthd_bl_set     (outp, argv, argc);
@@ -599,6 +598,7 @@ nvkm_uoutp_del(struct nvif_outp_priv *uoutp)
 static const struct nvif_outp_impl
 nvkm_uoutp_impl = {
 	.del = nvkm_uoutp_del,
+	.inherit = nvkm_uoutp_inherit,
 };
 
 static void *
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 110/156] drm/nouveau/nvif: rework outp "acquire" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (108 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 109/156] drm/nouveau/nvif: rework outp "inherit" apis Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 111/156] drm/nouveau/nvif: rework outp "release" api Ben Skeggs
                   ` (47 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interface

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  1 +
 drivers/gpu/drm/nouveau/include/nvif/if0012.h | 19 ----------
 drivers/gpu/drm/nouveau/nvif/outp.c           | 29 ++++++---------
 .../gpu/drm/nouveau/nvkm/engine/disp/uoutp.c  | 35 ++++++++++---------
 4 files changed, 31 insertions(+), 53 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 9ab54de43ba3..a2e0423f76c2 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -278,6 +278,7 @@ struct nvif_outp_impl {
 
 	int (*inherit)(struct nvif_outp_priv *, enum nvif_outp_proto,
 		       u8 *or, u8 *link, u8 *head, u8 *proto_evo);
+	int (*acquire)(struct nvif_outp_priv *, enum nvif_outp_type, bool hda, u8 *or, u8 *link);
 
 	int (*load_detect)(struct nvif_outp_priv *, u32 loadval, u8 *load);
 
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0012.h b/drivers/gpu/drm/nouveau/include/nvif/if0012.h
index 09e2f61673a8..3cbdb5fc4757 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/if0012.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/if0012.h
@@ -4,7 +4,6 @@
 
 #include <drm/display/drm_dp.h>
 
-#define NVIF_OUTP_V0_ACQUIRE       0x11
 #define NVIF_OUTP_V0_RELEASE       0x12
 
 #define NVIF_OUTP_V0_BL_GET        0x30
@@ -27,24 +26,6 @@
 #define NVIF_OUTP_V0_DP_MST_ID_PUT 0x77
 #define NVIF_OUTP_V0_DP_MST_VCPI   0x78
 
-union nvif_outp_acquire_args {
-	struct nvif_outp_acquire_v0 {
-		__u8 version;
-#define NVIF_OUTP_ACQUIRE_V0_DAC  0x00
-#define NVIF_OUTP_ACQUIRE_V0_SOR  0x01
-#define NVIF_OUTP_ACQUIRE_V0_PIOR 0x02
-		__u8 type;
-		__u8 or;
-		__u8 link;
-		__u8 pad04[4];
-		union {
-			struct {
-				__u8 hda;
-			} sor;
-		};
-	} v0;
-};
-
 union nvif_outp_release_args {
 	struct nvif_outp_release_vn {
 	} vn;
diff --git a/drivers/gpu/drm/nouveau/nvif/outp.c b/drivers/gpu/drm/nouveau/nvif/outp.c
index c98af48b4b33..ddcd2b9d69f3 100644
--- a/drivers/gpu/drm/nouveau/nvif/outp.c
+++ b/drivers/gpu/drm/nouveau/nvif/outp.c
@@ -302,54 +302,47 @@ nvif_outp_release(struct nvif_outp *outp)
 }
 
 static inline int
-nvif_outp_acquire(struct nvif_outp *outp, u8 type, struct nvif_outp_acquire_v0 *args)
+nvif_outp_acquire(struct nvif_outp *outp, enum nvif_outp_type type, bool hda)
 {
+	u8 or, link;
 	int ret;
 
-	args->version = 0;
-	args->type = type;
-
-	ret = nvif_mthd(&outp->object, NVIF_OUTP_V0_ACQUIRE, args, sizeof(*args));
+	ret = outp->impl->acquire(outp->priv, type, hda, &or, &link);
 	if (ret)
 		return ret;
 
-	outp->or.id = args->or;
-	outp->or.link = args->link;
+	outp->or.id = or;
+	outp->or.link = link;
 	return 0;
 }
 
 int
 nvif_outp_acquire_pior(struct nvif_outp *outp)
 {
-	struct nvif_outp_acquire_v0 args;
 	int ret;
 
-	ret = nvif_outp_acquire(outp, NVIF_OUTP_ACQUIRE_V0_PIOR, &args);
-	NVIF_ERRON(ret, &outp->object, "[ACQUIRE PIOR] or:%d", args.or);
+	ret = nvif_outp_acquire(outp, NVIF_OUTP_PIOR, false);
+	NVIF_ERRON(ret, &outp->object, "[ACQUIRE PIOR] or:%d", outp->or.id);
 	return ret;
 }
 
 int
 nvif_outp_acquire_sor(struct nvif_outp *outp, bool hda)
 {
-	struct nvif_outp_acquire_v0 args;
 	int ret;
 
-	args.sor.hda = hda;
-
-	ret = nvif_outp_acquire(outp, NVIF_OUTP_ACQUIRE_V0_SOR, &args);
-	NVIF_ERRON(ret, &outp->object, "[ACQUIRE SOR] or:%d link:%d", args.or, args.link);
+	ret = nvif_outp_acquire(outp, NVIF_OUTP_SOR, hda);
+	NVIF_ERRON(ret, &outp->object, "[ACQUIRE SOR] or:%d link:%d", outp->or.id, outp->or.link);
 	return ret;
 }
 
 int
 nvif_outp_acquire_dac(struct nvif_outp *outp)
 {
-	struct nvif_outp_acquire_v0 args;
 	int ret;
 
-	ret = nvif_outp_acquire(outp, NVIF_OUTP_ACQUIRE_V0_DAC, &args);
-	NVIF_ERRON(ret, &outp->object, "[ACQUIRE DAC] or:%d", args.or);
+	ret = nvif_outp_acquire(outp, NVIF_OUTP_DAC, false);
+	NVIF_ERRON(ret, &outp->object, "[ACQUIRE DAC] or:%d", outp->or.id);
 	return ret;
 }
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
index 3f242a03f77b..46ca915f0206 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
@@ -373,35 +373,38 @@ nvkm_uoutp_mthd_release(struct nvkm_outp *outp, void *argv, u32 argc)
 }
 
 static int
-nvkm_uoutp_mthd_acquire(struct nvkm_outp *outp, void *argv, u32 argc)
+nvkm_uoutp_acquire(struct nvif_outp_priv *uoutp, enum nvif_outp_type type, bool hda,
+		   u8 *or, u8 *link)
 {
-	union nvif_outp_acquire_args *args = argv;
+	struct nvkm_outp *outp = uoutp->outp;
 	int ret;
 
-	if (argc != sizeof(args->v0) || args->v0.version != 0)
-		return -ENOSYS;
-	if (outp->ior && args->v0.type <= NVIF_OUTP_ACQUIRE_V0_PIOR)
+	nvkm_uoutp_lock(uoutp);
+	if (outp->ior) {
+		nvkm_uoutp_unlock(uoutp);
 		return -EBUSY;
+	}
 
-	switch (args->v0.type) {
-	case NVIF_OUTP_ACQUIRE_V0_DAC:
-	case NVIF_OUTP_ACQUIRE_V0_PIOR:
+	switch (type) {
+	case NVIF_OUTP_DAC:
+	case NVIF_OUTP_PIOR:
 		ret = outp->func->acquire(outp, false);
 		break;
-	case NVIF_OUTP_ACQUIRE_V0_SOR:
-		ret = outp->func->acquire(outp, args->v0.sor.hda);
+	case NVIF_OUTP_SOR:
+		ret = outp->func->acquire(outp, hda);
 		break;
 	default:
 		ret = -EINVAL;
 		break;
 	}
 
-	if (ret)
-		return ret;
+	if (ret == 0) {
+		*or = outp->ior->id;
+		*link = outp->ior->asy.link;
+	}
 
-	args->v0.or = outp->ior->id;
-	args->v0.link = outp->ior->asy.link;
-	return 0;
+	nvkm_uoutp_unlock(uoutp);
+	return ret;
 }
 
 static int
@@ -549,7 +552,6 @@ static int
 nvkm_uoutp_mthd_noacquire(struct nvkm_outp *outp, u32 mthd, void *argv, u32 argc, bool *invalid)
 {
 	switch (mthd) {
-	case NVIF_OUTP_V0_ACQUIRE    : return nvkm_uoutp_mthd_acquire    (outp, argv, argc);
 	case NVIF_OUTP_V0_BL_GET     : return nvkm_uoutp_mthd_bl_get     (outp, argv, argc);
 	case NVIF_OUTP_V0_BL_SET     : return nvkm_uoutp_mthd_bl_set     (outp, argv, argc);
 	case NVIF_OUTP_V0_DP_AUX_PWR : return nvkm_uoutp_mthd_dp_aux_pwr (outp, argv, argc);
@@ -599,6 +601,7 @@ static const struct nvif_outp_impl
 nvkm_uoutp_impl = {
 	.del = nvkm_uoutp_del,
 	.inherit = nvkm_uoutp_inherit,
+	.acquire = nvkm_uoutp_acquire,
 };
 
 static void *
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 111/156] drm/nouveau/nvif: rework outp "release" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (109 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 110/156] drm/nouveau/nvif: rework outp "acquire" api Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 112/156] drm/nouveau/nvif: rework outp "bl get"/"bl set" apis Ben Skeggs
                   ` (46 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interface

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/include/nvif/driverif.h  |  1 +
 drivers/gpu/drm/nouveau/include/nvif/if0012.h    |  7 -------
 drivers/gpu/drm/nouveau/nvif/outp.c              |  2 +-
 drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c | 15 ++++++++-------
 4 files changed, 10 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index a2e0423f76c2..2b29ac64e5cd 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -279,6 +279,7 @@ struct nvif_outp_impl {
 	int (*inherit)(struct nvif_outp_priv *, enum nvif_outp_proto,
 		       u8 *or, u8 *link, u8 *head, u8 *proto_evo);
 	int (*acquire)(struct nvif_outp_priv *, enum nvif_outp_type, bool hda, u8 *or, u8 *link);
+	int (*release)(struct nvif_outp_priv *);
 
 	int (*load_detect)(struct nvif_outp_priv *, u32 loadval, u8 *load);
 
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0012.h b/drivers/gpu/drm/nouveau/include/nvif/if0012.h
index 3cbdb5fc4757..1a8f0720c14a 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/if0012.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/if0012.h
@@ -4,8 +4,6 @@
 
 #include <drm/display/drm_dp.h>
 
-#define NVIF_OUTP_V0_RELEASE       0x12
-
 #define NVIF_OUTP_V0_BL_GET        0x30
 #define NVIF_OUTP_V0_BL_SET        0x31
 
@@ -26,11 +24,6 @@
 #define NVIF_OUTP_V0_DP_MST_ID_PUT 0x77
 #define NVIF_OUTP_V0_DP_MST_VCPI   0x78
 
-union nvif_outp_release_args {
-	struct nvif_outp_release_vn {
-	} vn;
-};
-
 union nvif_outp_bl_get_args {
 	struct nvif_outp_bl_get_v0 {
 		__u8  version;
diff --git a/drivers/gpu/drm/nouveau/nvif/outp.c b/drivers/gpu/drm/nouveau/nvif/outp.c
index ddcd2b9d69f3..efdcc1c28874 100644
--- a/drivers/gpu/drm/nouveau/nvif/outp.c
+++ b/drivers/gpu/drm/nouveau/nvif/outp.c
@@ -296,7 +296,7 @@ nvif_outp_bl_get(struct nvif_outp *outp)
 void
 nvif_outp_release(struct nvif_outp *outp)
 {
-	int ret = nvif_mthd(&outp->object, NVIF_OUTP_V0_RELEASE, NULL, 0);
+	int ret = outp->impl->release(outp->priv);
 	NVIF_ERRON(ret, &outp->object, "[RELEASE]");
 	outp->or.id = -1;
 }
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
index 46ca915f0206..f5d3b3647dac 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
@@ -359,16 +359,17 @@ nvkm_uoutp_mthd_bl_get(struct nvkm_outp *outp, void *argv, u32 argc)
 }
 
 static int
-nvkm_uoutp_mthd_release(struct nvkm_outp *outp, void *argv, u32 argc)
+nvkm_uoutp_release(struct nvif_outp_priv *uoutp)
 {
-	union nvif_outp_release_args *args = argv;
+	struct nvkm_outp *outp = uoutp->outp;
+	int ret;
 
-	if (argc != sizeof(args->vn))
-		return -ENOSYS;
-	if (!outp->ior)
-		return -EINVAL;
+	ret = nvkm_uoutp_lock_acquired(uoutp);
+	if (ret)
+		return ret;
 
 	outp->func->release(outp);
+	nvkm_uoutp_unlock(uoutp);
 	return 0;
 }
 
@@ -530,7 +531,6 @@ static int
 nvkm_uoutp_mthd_acquired(struct nvkm_outp *outp, u32 mthd, void *argv, u32 argc)
 {
 	switch (mthd) {
-	case NVIF_OUTP_V0_RELEASE      : return nvkm_uoutp_mthd_release      (outp, argv, argc);
 	case NVIF_OUTP_V0_LVDS         : return nvkm_uoutp_mthd_lvds         (outp, argv, argc);
 	case NVIF_OUTP_V0_HDMI         : return nvkm_uoutp_mthd_hdmi         (outp, argv, argc);
 	case NVIF_OUTP_V0_INFOFRAME    : return nvkm_uoutp_mthd_infoframe    (outp, argv, argc);
@@ -602,6 +602,7 @@ nvkm_uoutp_impl = {
 	.del = nvkm_uoutp_del,
 	.inherit = nvkm_uoutp_inherit,
 	.acquire = nvkm_uoutp_acquire,
+	.release = nvkm_uoutp_release,
 };
 
 static void *
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 112/156] drm/nouveau/nvif: rework outp "bl get"/"bl set" apis
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (110 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 111/156] drm/nouveau/nvif: rework outp "release" api Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 113/156] drm/nouveau/nvif: rework outp "lvds config" api Ben Skeggs
                   ` (45 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interfaces

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  5 +++
 drivers/gpu/drm/nouveau/include/nvif/if0012.h | 17 --------
 drivers/gpu/drm/nouveau/nvif/outp.c           | 18 +++-----
 .../gpu/drm/nouveau/nvkm/engine/disp/uoutp.c  | 43 ++++++++-----------
 4 files changed, 29 insertions(+), 54 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 2b29ac64e5cd..7c4e3df12a8e 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -295,6 +295,11 @@ struct nvif_outp_impl {
 		u8 acpi_edid;
 	} lvds;
 
+	struct {
+		int (*get)(struct nvif_outp_priv *, u8 *level);
+		int (*set)(struct nvif_outp_priv *, u8 level);
+	} bl;
+
 	struct {
 		u8 aux;
 		u8 mst;
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0012.h b/drivers/gpu/drm/nouveau/include/nvif/if0012.h
index 1a8f0720c14a..0bdd8ddc65d3 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/if0012.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/if0012.h
@@ -4,9 +4,6 @@
 
 #include <drm/display/drm_dp.h>
 
-#define NVIF_OUTP_V0_BL_GET        0x30
-#define NVIF_OUTP_V0_BL_SET        0x31
-
 #define NVIF_OUTP_V0_LVDS          0x40
 
 #define NVIF_OUTP_V0_HDMI          0x50
@@ -24,20 +21,6 @@
 #define NVIF_OUTP_V0_DP_MST_ID_PUT 0x77
 #define NVIF_OUTP_V0_DP_MST_VCPI   0x78
 
-union nvif_outp_bl_get_args {
-	struct nvif_outp_bl_get_v0 {
-		__u8  version;
-		__u8  level;
-	} v0;
-};
-
-union nvif_outp_bl_set_args {
-	struct nvif_outp_bl_set_v0 {
-		__u8  version;
-		__u8  level;
-	} v0;
-};
-
 union nvif_outp_lvds_args {
 	struct nvif_outp_lvds_v0 {
 		__u8  version;
diff --git a/drivers/gpu/drm/nouveau/nvif/outp.c b/drivers/gpu/drm/nouveau/nvif/outp.c
index efdcc1c28874..7929dc896b6b 100644
--- a/drivers/gpu/drm/nouveau/nvif/outp.c
+++ b/drivers/gpu/drm/nouveau/nvif/outp.c
@@ -269,28 +269,22 @@ nvif_outp_lvds(struct nvif_outp *outp, bool dual, bool bpc8)
 int
 nvif_outp_bl_set(struct nvif_outp *outp, int level)
 {
-	struct nvif_outp_bl_set_v0 args;
 	int ret;
 
-	args.version = 0;
-	args.level = level;
-
-	ret = nvif_object_mthd(&outp->object, NVIF_OUTP_V0_BL_SET, &args, sizeof(args));
-	NVIF_ERRON(ret, &outp->object, "[BL_SET level:%d]", args.level);
+	ret = outp->impl->bl.set(outp->priv, level);
+	NVIF_ERRON(ret, &outp->object, "[BL_SET level:%d]", level);
 	return ret;
 }
 
 int
 nvif_outp_bl_get(struct nvif_outp *outp)
 {
-	struct nvif_outp_bl_get_v0 args;
+	u8 level;
 	int ret;
 
-	args.version = 0;
-
-	ret = nvif_object_mthd(&outp->object, NVIF_OUTP_V0_BL_GET, &args, sizeof(args));
-	NVIF_ERRON(ret, &outp->object, "[BL_GET level:%d]", args.level);
-	return ret ? ret : args.level;
+	ret = outp->impl->bl.get(outp->priv, &level);
+	NVIF_ERRON(ret, &outp->object, "[BL_GET level:%d]", level);
+	return ret ? ret : level;
 }
 
 void
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
index f5d3b3647dac..5483ca37ca0e 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
@@ -320,39 +320,29 @@ nvkm_uoutp_mthd_lvds(struct nvkm_outp *outp, void *argv, u32 argc)
 }
 
 static int
-nvkm_uoutp_mthd_bl_set(struct nvkm_outp *outp, void *argv, u32 argc)
+nvkm_uoutp_bl_set(struct nvif_outp_priv *uoutp, u8 level)
 {
-	union nvif_outp_bl_get_args *args = argv;
+	struct nvkm_outp *outp = uoutp->outp;
 	int ret;
 
-	if (argc != sizeof(args->v0) || args->v0.version != 0)
-		return -ENOSYS;
-
-	if (outp->func->bl.set)
-		ret = outp->func->bl.set(outp, args->v0.level);
-	else
-		ret = -EINVAL;
-
+	nvkm_uoutp_lock(uoutp);
+	ret = outp->func->bl.set(outp, level);
+	nvkm_uoutp_unlock(uoutp);
 	return ret;
 }
 
 static int
-nvkm_uoutp_mthd_bl_get(struct nvkm_outp *outp, void *argv, u32 argc)
+nvkm_uoutp_bl_get(struct nvif_outp_priv *uoutp, u8 *level)
 {
-	union nvif_outp_bl_get_args *args = argv;
+	struct nvkm_outp *outp = uoutp->outp;
 	int ret;
 
-	if (argc != sizeof(args->v0) || args->v0.version != 0)
-		return -ENOSYS;
-
-	if (outp->func->bl.get) {
-		ret = outp->func->bl.get(outp);
-		if (ret >= 0) {
-			args->v0.level = ret;
-			ret = 0;
-		}
-	} else {
-		ret = -EINVAL;
+	nvkm_uoutp_lock(uoutp);
+	ret = outp->func->bl.get(outp);
+	nvkm_uoutp_unlock(uoutp);
+	if (ret >= 0) {
+		*level = ret;
+		ret = 0;
 	}
 
 	return ret;
@@ -552,8 +542,6 @@ static int
 nvkm_uoutp_mthd_noacquire(struct nvkm_outp *outp, u32 mthd, void *argv, u32 argc, bool *invalid)
 {
 	switch (mthd) {
-	case NVIF_OUTP_V0_BL_GET     : return nvkm_uoutp_mthd_bl_get     (outp, argv, argc);
-	case NVIF_OUTP_V0_BL_SET     : return nvkm_uoutp_mthd_bl_set     (outp, argv, argc);
 	case NVIF_OUTP_V0_DP_AUX_PWR : return nvkm_uoutp_mthd_dp_aux_pwr (outp, argv, argc);
 	case NVIF_OUTP_V0_DP_AUX_XFER: return nvkm_uoutp_mthd_dp_aux_xfer(outp, argv, argc);
 	case NVIF_OUTP_V0_DP_RATES   : return nvkm_uoutp_mthd_dp_rates   (outp, argv, argc);
@@ -704,6 +692,11 @@ nvkm_uoutp_new(struct nvkm_disp *disp, u8 id, const struct nvif_outp_impl **pimp
 	uoutp->impl.heads = outp->info.heads;
 	uoutp->impl.conn = outp->info.connector;
 
+	if (outp->func->bl.get) {
+		uoutp->impl.bl.get = nvkm_uoutp_bl_get;
+		uoutp->impl.bl.set = nvkm_uoutp_bl_set;
+	}
+
 	spin_lock(&disp->user.lock);
 	if (outp->user) {
 		spin_unlock(&disp->user.lock);
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 113/156] drm/nouveau/nvif: rework outp "lvds config" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (111 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 112/156] drm/nouveau/nvif: rework outp "bl get"/"bl set" apis Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 114/156] drm/nouveau/nvif: rework outp "hdmi " Ben Skeggs
                   ` (44 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interface

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  2 ++
 drivers/gpu/drm/nouveau/include/nvif/if0012.h | 10 ----------
 drivers/gpu/drm/nouveau/nvif/outp.c           |  9 ++-------
 .../gpu/drm/nouveau/nvkm/engine/disp/uoutp.c  | 19 ++++++++++---------
 4 files changed, 14 insertions(+), 26 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 7c4e3df12a8e..1eec40976a70 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -293,6 +293,8 @@ struct nvif_outp_impl {
 
 	struct {
 		u8 acpi_edid;
+
+		int (*config)(struct nvif_outp_priv *, bool dual, bool bpc8);
 	} lvds;
 
 	struct {
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0012.h b/drivers/gpu/drm/nouveau/include/nvif/if0012.h
index 0bdd8ddc65d3..d8c6e84cf5ae 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/if0012.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/if0012.h
@@ -4,8 +4,6 @@
 
 #include <drm/display/drm_dp.h>
 
-#define NVIF_OUTP_V0_LVDS          0x40
-
 #define NVIF_OUTP_V0_HDMI          0x50
 
 #define NVIF_OUTP_V0_INFOFRAME     0x60
@@ -21,14 +19,6 @@
 #define NVIF_OUTP_V0_DP_MST_ID_PUT 0x77
 #define NVIF_OUTP_V0_DP_MST_VCPI   0x78
 
-union nvif_outp_lvds_args {
-	struct nvif_outp_lvds_v0 {
-		__u8  version;
-		__u8  dual;
-		__u8  bpc8;
-	} v0;
-};
-
 union nvif_outp_hdmi_args {
 	struct nvif_outp_hdmi_v0 {
 		__u8 version;
diff --git a/drivers/gpu/drm/nouveau/nvif/outp.c b/drivers/gpu/drm/nouveau/nvif/outp.c
index 7929dc896b6b..edcb5598efac 100644
--- a/drivers/gpu/drm/nouveau/nvif/outp.c
+++ b/drivers/gpu/drm/nouveau/nvif/outp.c
@@ -254,15 +254,10 @@ nvif_outp_hdmi(struct nvif_outp *outp, int head, bool enable, u8 max_ac_packet,
 int
 nvif_outp_lvds(struct nvif_outp *outp, bool dual, bool bpc8)
 {
-	struct nvif_outp_lvds_v0 args;
 	int ret;
 
-	args.version = 0;
-	args.dual = dual;
-	args.bpc8 = bpc8;
-
-	ret = nvif_mthd(&outp->object, NVIF_OUTP_V0_LVDS, &args, sizeof(args));
-	NVIF_ERRON(ret, &outp->object, "[LVDS dual:%d 8bpc:%d]", args.dual, args.bpc8);
+	ret = outp->impl->lvds.config(outp->priv, dual, bpc8);
+	NVIF_ERRON(ret, &outp->object, "[LVDS dual:%d 8bpc:%d]", dual, bpc8);
 	return ret;
 }
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
index 5483ca37ca0e..93de3990554e 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
@@ -305,17 +305,18 @@ nvkm_uoutp_mthd_hdmi(struct nvkm_outp *outp, void *argv, u32 argc)
 }
 
 static int
-nvkm_uoutp_mthd_lvds(struct nvkm_outp *outp, void *argv, u32 argc)
+nvkm_uoutp_lvds(struct nvif_outp_priv *uoutp, bool dual, bool bpc8)
 {
-	union nvif_outp_lvds_args *args = argv;
+	struct nvkm_outp *outp = uoutp->outp;
+	int ret;
 
-	if (argc != sizeof(args->v0) || args->v0.version != 0)
-		return -ENOSYS;
-	if (outp->info.type != DCB_OUTPUT_LVDS)
-		return -EINVAL;
+	ret = nvkm_uoutp_lock_acquired(uoutp);
+	if (ret)
+		return ret;
 
-	outp->lvds.dual = !!args->v0.dual;
-	outp->lvds.bpc8 = !!args->v0.bpc8;
+	outp->lvds.dual = dual;
+	outp->lvds.bpc8 = bpc8;
+	nvkm_uoutp_unlock(uoutp);
 	return 0;
 }
 
@@ -521,7 +522,6 @@ static int
 nvkm_uoutp_mthd_acquired(struct nvkm_outp *outp, u32 mthd, void *argv, u32 argc)
 {
 	switch (mthd) {
-	case NVIF_OUTP_V0_LVDS         : return nvkm_uoutp_mthd_lvds         (outp, argv, argc);
 	case NVIF_OUTP_V0_HDMI         : return nvkm_uoutp_mthd_hdmi         (outp, argv, argc);
 	case NVIF_OUTP_V0_INFOFRAME    : return nvkm_uoutp_mthd_infoframe    (outp, argv, argc);
 	case NVIF_OUTP_V0_HDA_ELD      : return nvkm_uoutp_mthd_hda_eld      (outp, argv, argc);
@@ -664,6 +664,7 @@ nvkm_uoutp_new(struct nvkm_disp *disp, u8 id, const struct nvif_outp_impl **pimp
 		uoutp->impl.type = NVIF_OUTP_SOR;
 		uoutp->impl.proto = NVIF_OUTP_LVDS;
 		uoutp->impl.lvds.acpi_edid = outp->info.lvdsconf.use_acpi_for_edid;
+		uoutp->impl.lvds.config = nvkm_uoutp_lvds;
 		break;
 	case DCB_OUTPUT_DP:
 		if (!outp->info.location) {
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 114/156] drm/nouveau/nvif: rework outp "hdmi config" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (112 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 113/156] drm/nouveau/nvif: rework outp "lvds config" api Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 115/156] drm/nouveau/nvif: rework outp "infoframe" api Ben Skeggs
                   ` (43 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interface

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  6 +++
 drivers/gpu/drm/nouveau/include/nvif/if0012.h | 16 -------
 drivers/gpu/drm/nouveau/nvif/outp.c           | 18 ++-----
 .../gpu/drm/nouveau/nvkm/engine/disp/uoutp.c  | 47 ++++++++++++-------
 4 files changed, 39 insertions(+), 48 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 1eec40976a70..6f1ec831b4d7 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -291,6 +291,12 @@ struct nvif_outp_impl {
 		u8 dual;
 	} tmds;
 
+	struct {
+		int (*config)(struct nvif_outp_priv *, u8 head, bool enable, u8 max_ac_packet,
+			      u8 rekey, u32 khz, bool scdc, bool scdc_scrambling,
+			      bool scdc_low_rates);
+	} hdmi;
+
 	struct {
 		u8 acpi_edid;
 
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0012.h b/drivers/gpu/drm/nouveau/include/nvif/if0012.h
index d8c6e84cf5ae..c2a3af721116 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/if0012.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/if0012.h
@@ -4,8 +4,6 @@
 
 #include <drm/display/drm_dp.h>
 
-#define NVIF_OUTP_V0_HDMI          0x50
-
 #define NVIF_OUTP_V0_INFOFRAME     0x60
 #define NVIF_OUTP_V0_HDA_ELD       0x61
 
@@ -19,20 +17,6 @@
 #define NVIF_OUTP_V0_DP_MST_ID_PUT 0x77
 #define NVIF_OUTP_V0_DP_MST_VCPI   0x78
 
-union nvif_outp_hdmi_args {
-	struct nvif_outp_hdmi_v0 {
-		__u8 version;
-		__u8 head;
-		__u8 enable;
-		__u8 max_ac_packet;
-		__u8 rekey;
-		__u8 scdc;
-		__u8 scdc_scrambling;
-		__u8 scdc_low_rates;
-		__u32 khz;
-	} v0;
-};
-
 union nvif_outp_infoframe_args {
 	struct nvif_outp_infoframe_v0 {
 		__u8 version;
diff --git a/drivers/gpu/drm/nouveau/nvif/outp.c b/drivers/gpu/drm/nouveau/nvif/outp.c
index edcb5598efac..99a1e0073166 100644
--- a/drivers/gpu/drm/nouveau/nvif/outp.c
+++ b/drivers/gpu/drm/nouveau/nvif/outp.c
@@ -229,25 +229,15 @@ int
 nvif_outp_hdmi(struct nvif_outp *outp, int head, bool enable, u8 max_ac_packet, u8 rekey,
 	       u32 khz, bool scdc, bool scdc_scrambling, bool scdc_low_rates)
 {
-	struct nvif_outp_hdmi_v0 args;
 	int ret;
 
-	args.version = 0;
-	args.head = head;
-	args.enable = enable;
-	args.max_ac_packet = max_ac_packet;
-	args.rekey = rekey;
-	args.khz = khz;
-	args.scdc = scdc;
-	args.scdc_scrambling = scdc_scrambling;
-	args.scdc_low_rates = scdc_low_rates;
-
-	ret = nvif_mthd(&outp->object, NVIF_OUTP_V0_HDMI, &args, sizeof(args));
+	ret = outp->impl->hdmi.config(outp->priv, head, enable, max_ac_packet, rekey, khz,
+				      scdc, scdc_scrambling, scdc_low_rates);
 	NVIF_ERRON(ret, &outp->object,
 		   "[HDMI head:%d enable:%d max_ac_packet:%d rekey:%d khz:%d scdc:%d "
 		   "scdc_scrambling:%d scdc_low_rates:%d]",
-		   args.head, args.enable, args.max_ac_packet, args.rekey, args.khz,
-		   args.scdc, args.scdc_scrambling, args.scdc_low_rates);
+		   head, enable, max_ac_packet, rekey, khz,
+		   scdc, scdc_scrambling, scdc_low_rates);
 	return ret;
 }
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
index 93de3990554e..325af91075ab 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
@@ -271,36 +271,47 @@ nvkm_uoutp_mthd_infoframe(struct nvkm_outp *outp, void *argv, u32 argc)
 }
 
 static int
-nvkm_uoutp_mthd_hdmi(struct nvkm_outp *outp, void *argv, u32 argc)
+nvkm_uoutp_hdmi(struct nvif_outp_priv *uoutp, u8 head, bool enable, u8 max_ac_packet, u8 rekey,
+	        u32 khz, bool scdc, bool scdc_scrambling, bool scdc_low_rates)
 {
-	union nvif_outp_hdmi_args *args = argv;
-	struct nvkm_ior *ior = outp->ior;
+	struct nvkm_outp *outp = uoutp->outp;
+	struct nvkm_ior *ior;
+	int ret;
 
-	if (argc != sizeof(args->v0) || args->v0.version != 0)
-		return -ENOSYS;
+	ret = nvkm_uoutp_lock_acquired(uoutp);
+	if (ret)
+		return ret;
 
-	if (!(outp->asy.head = nvkm_head_find(outp->disp, args->v0.head)))
+	if (!(outp->asy.head = nvkm_head_find(outp->disp, head))) {
+		nvkm_uoutp_unlock(uoutp);
 		return -EINVAL;
+	}
+
+	ior = outp->ior;
 
 	if (!ior->func->hdmi ||
-	    args->v0.max_ac_packet > 0x1f ||
-	    args->v0.rekey > 0x7f ||
-	    (args->v0.scdc && !ior->func->hdmi->scdc))
+	    max_ac_packet > 0x1f ||
+	    rekey > 0x7f ||
+	    (scdc && !ior->func->hdmi->scdc)) {
+		nvkm_uoutp_unlock(uoutp);
 		return -EINVAL;
+	}
 
-	if (!args->v0.enable) {
-		ior->func->hdmi->infoframe_avi(ior, args->v0.head, NULL, 0);
-		ior->func->hdmi->infoframe_vsi(ior, args->v0.head, NULL, 0);
-		ior->func->hdmi->ctrl(ior, args->v0.head, false, 0, 0);
+	if (!enable) {
+		ior->func->hdmi->infoframe_avi(ior, head, NULL, 0);
+		ior->func->hdmi->infoframe_vsi(ior, head, NULL, 0);
+		ior->func->hdmi->ctrl(ior, head, false, 0, 0);
+		nvkm_uoutp_unlock(uoutp);
 		return 0;
 	}
 
-	ior->func->hdmi->ctrl(ior, args->v0.head, args->v0.enable,
-			      args->v0.max_ac_packet, args->v0.rekey);
+	ior->func->hdmi->ctrl(ior, head, enable,
+			      max_ac_packet, rekey);
 	if (ior->func->hdmi->scdc)
-		ior->func->hdmi->scdc(ior, args->v0.khz, args->v0.scdc, args->v0.scdc_scrambling,
-				      args->v0.scdc_low_rates);
+		ior->func->hdmi->scdc(ior, khz, scdc, scdc_scrambling,
+				      scdc_low_rates);
 
+	nvkm_uoutp_unlock(uoutp);
 	return 0;
 }
 
@@ -522,7 +533,6 @@ static int
 nvkm_uoutp_mthd_acquired(struct nvkm_outp *outp, u32 mthd, void *argv, u32 argc)
 {
 	switch (mthd) {
-	case NVIF_OUTP_V0_HDMI         : return nvkm_uoutp_mthd_hdmi         (outp, argv, argc);
 	case NVIF_OUTP_V0_INFOFRAME    : return nvkm_uoutp_mthd_infoframe    (outp, argv, argc);
 	case NVIF_OUTP_V0_HDA_ELD      : return nvkm_uoutp_mthd_hda_eld      (outp, argv, argc);
 	case NVIF_OUTP_V0_DP_TRAIN     : return nvkm_uoutp_mthd_dp_train     (outp, argv, argc);
@@ -659,6 +669,7 @@ nvkm_uoutp_new(struct nvkm_disp *disp, u8 id, const struct nvif_outp_impl **pimp
 			uoutp->impl.tmds.dual = 0;
 		}
 		uoutp->impl.proto = NVIF_OUTP_TMDS;
+		uoutp->impl.hdmi.config = nvkm_uoutp_hdmi;
 		break;
 	case DCB_OUTPUT_LVDS:
 		uoutp->impl.type = NVIF_OUTP_SOR;
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 115/156] drm/nouveau/nvif: rework outp "infoframe" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (113 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 114/156] drm/nouveau/nvif: rework outp "hdmi " Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 116/156] drm/nouveau/nvif: rework outp "hda eld" api Ben Skeggs
                   ` (42 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interface

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/dispnv50/disp.c       | 18 +++------
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  7 ++++
 drivers/gpu/drm/nouveau/include/nvif/if0012.h | 13 -------
 drivers/gpu/drm/nouveau/include/nvif/outp.h   |  3 +-
 drivers/gpu/drm/nouveau/nvif/outp.c           |  7 ++--
 .../gpu/drm/nouveau/nvkm/engine/disp/uoutp.c  | 38 +++++++++++--------
 6 files changed, 40 insertions(+), 46 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c b/drivers/gpu/drm/nouveau/dispnv50/disp.c
index e2d71916326f..0bac0e813184 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/disp.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c
@@ -755,10 +755,7 @@ nv50_hdmi_enable(struct drm_encoder *encoder, struct nouveau_crtc *nv_crtc,
 	union hdmi_infoframe infoframe = { 0 };
 	const u8 rekey = 56; /* binary driver, and tegra, constant */
 	u32 max_ac_packet;
-	struct {
-		struct nvif_outp_infoframe_v0 infoframe;
-		u8 data[17];
-	} args = { 0 };
+	u8 data[17] = {};
 	int ret, size;
 
 	max_ac_packet  = mode->htotal - mode->hdisplay;
@@ -795,29 +792,26 @@ nv50_hdmi_enable(struct drm_encoder *encoder, struct nouveau_crtc *nv_crtc,
 		return;
 
 	/* AVI InfoFrame. */
-	args.infoframe.version = 0;
-	args.infoframe.head = nv_crtc->index;
-
 	if (!drm_hdmi_avi_infoframe_from_display_mode(&infoframe.avi, &nv_connector->base, mode)) {
 		drm_hdmi_avi_infoframe_quant_range(&infoframe.avi, &nv_connector->base, mode,
 						   HDMI_QUANTIZATION_RANGE_FULL);
 
-		size = hdmi_infoframe_pack(&infoframe, args.data, ARRAY_SIZE(args.data));
+		size = hdmi_infoframe_pack(&infoframe, data, ARRAY_SIZE(data));
 	} else {
 		size = 0;
 	}
 
-	nvif_outp_infoframe(&nv_encoder->outp, NVIF_OUTP_INFOFRAME_V0_AVI, &args.infoframe, size);
+	nvif_outp_infoframe(&nv_encoder->outp, nv_crtc->index, NVIF_OUTP_INFOFRAME_AVI, data, size);
 
 	/* Vendor InfoFrame. */
-	memset(&args.data, 0, sizeof(args.data));
+	memset(data, 0, sizeof(data));
 	if (!drm_hdmi_vendor_infoframe_from_display_mode(&infoframe.vendor.hdmi,
 							 &nv_connector->base, mode))
-		size = hdmi_infoframe_pack(&infoframe, args.data, ARRAY_SIZE(args.data));
+		size = hdmi_infoframe_pack(&infoframe, data, ARRAY_SIZE(data));
 	else
 		size = 0;
 
-	nvif_outp_infoframe(&nv_encoder->outp, NVIF_OUTP_INFOFRAME_V0_VSI, &args.infoframe, size);
+	nvif_outp_infoframe(&nv_encoder->outp, nv_crtc->index, NVIF_OUTP_INFOFRAME_VSI, data, size);
 
 	nv_encoder->hdmi.enabled = true;
 }
diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 6f1ec831b4d7..cef19e04f208 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -244,6 +244,11 @@ struct nvif_conn_impl {
 		     const struct nvif_event_impl **, struct nvif_event_priv **);
 };
 
+enum nvif_outp_infoframe_type {
+	NVIF_OUTP_INFOFRAME_AVI,
+	NVIF_OUTP_INFOFRAME_VSI,
+};
+
 enum nvif_outp_detect_status {
 	NVIF_OUTP_DETECT_NOT_PRESENT,
 	NVIF_OUTP_DETECT_PRESENT,
@@ -295,6 +300,8 @@ struct nvif_outp_impl {
 		int (*config)(struct nvif_outp_priv *, u8 head, bool enable, u8 max_ac_packet,
 			      u8 rekey, u32 khz, bool scdc, bool scdc_scrambling,
 			      bool scdc_low_rates);
+		int (*infoframe)(struct nvif_outp_priv *, u8 head, enum nvif_outp_infoframe_type,
+				 u8 *data, u8 size);
 	} hdmi;
 
 	struct {
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0012.h b/drivers/gpu/drm/nouveau/include/nvif/if0012.h
index c2a3af721116..a045c66fc1ca 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/if0012.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/if0012.h
@@ -4,7 +4,6 @@
 
 #include <drm/display/drm_dp.h>
 
-#define NVIF_OUTP_V0_INFOFRAME     0x60
 #define NVIF_OUTP_V0_HDA_ELD       0x61
 
 #define NVIF_OUTP_V0_DP_AUX_PWR    0x70
@@ -17,18 +16,6 @@
 #define NVIF_OUTP_V0_DP_MST_ID_PUT 0x77
 #define NVIF_OUTP_V0_DP_MST_VCPI   0x78
 
-union nvif_outp_infoframe_args {
-	struct nvif_outp_infoframe_v0 {
-		__u8 version;
-#define NVIF_OUTP_INFOFRAME_V0_AVI 0
-#define NVIF_OUTP_INFOFRAME_V0_VSI 1
-		__u8 type;
-		__u8 head;
-		__u8 pad03[5];
-		__u8 data[];
-	} v0;
-};
-
 union nvif_outp_hda_eld_args {
 	struct nvif_outp_hda_eld_v0 {
 		__u8  version;
diff --git a/drivers/gpu/drm/nouveau/include/nvif/outp.h b/drivers/gpu/drm/nouveau/include/nvif/outp.h
index 7a64a7d2ac97..8be799c88aff 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/outp.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/outp.h
@@ -49,7 +49,8 @@ int nvif_outp_lvds(struct nvif_outp *, bool dual, bool bpc8);
 int nvif_outp_hdmi(struct nvif_outp *, int head, bool enable, u8 max_ac_packet, u8 rekey, u32 khz,
 		   bool scdc, bool scdc_scrambling, bool scdc_low_rates);
 
-int nvif_outp_infoframe(struct nvif_outp *, u8 type, struct nvif_outp_infoframe_v0 *, u32 size);
+int nvif_outp_infoframe(struct nvif_outp *, int head, enum nvif_outp_infoframe_type,
+			u8 *data, u8 size);
 int nvif_outp_hda_eld(struct nvif_outp *, int head, void *data, u32 size);
 
 int nvif_outp_dp_aux_pwr(struct nvif_outp *, bool enable);
diff --git a/drivers/gpu/drm/nouveau/nvif/outp.c b/drivers/gpu/drm/nouveau/nvif/outp.c
index 99a1e0073166..4ecdc44eb84a 100644
--- a/drivers/gpu/drm/nouveau/nvif/outp.c
+++ b/drivers/gpu/drm/nouveau/nvif/outp.c
@@ -214,13 +214,12 @@ nvif_outp_hda_eld(struct nvif_outp *outp, int head, void *data, u32 size)
 }
 
 int
-nvif_outp_infoframe(struct nvif_outp *outp, u8 type, struct nvif_outp_infoframe_v0 *args, u32 size)
+nvif_outp_infoframe(struct nvif_outp *outp, int head, enum nvif_outp_infoframe_type type,
+		    u8 *data, u8 size)
 {
 	int ret;
 
-	args->type = type;
-
-	ret = nvif_mthd(&outp->object, NVIF_OUTP_V0_INFOFRAME, args, sizeof(*args) + size);
+	ret = outp->impl->hdmi.infoframe(outp->priv, head, type, data, size);
 	NVIF_ERRON(ret, &outp->object, "[INFOFRAME type:%d size:%d]", type, size);
 	return ret;
 }
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
index 325af91075ab..a694a43fd495 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
@@ -245,29 +245,35 @@ nvkm_uoutp_mthd_hda_eld(struct nvkm_outp *outp, void *argv, u32 argc)
 }
 
 static int
-nvkm_uoutp_mthd_infoframe(struct nvkm_outp *outp, void *argv, u32 argc)
+nvkm_uoutp_infoframe(struct nvif_outp_priv *uoutp, u8 head,
+		     enum nvif_outp_infoframe_type type, u8 *data, u8 size)
 {
-	struct nvkm_ior *ior = outp->ior;
-	union nvif_outp_infoframe_args *args = argv;
-	ssize_t size = argc - sizeof(*args);
+	struct nvkm_ior *ior;
+	int ret;
 
-	if (argc < sizeof(args->v0) || args->v0.version != 0)
-		return -ENOSYS;
-	if (!nvkm_head_find(outp->disp, args->v0.head))
+	if (!nvkm_head_find(uoutp->outp->disp, head))
 		return -EINVAL;
 
-	switch (ior->func->hdmi ? args->v0.type : 0xff) {
-	case NVIF_OUTP_INFOFRAME_V0_AVI:
-		ior->func->hdmi->infoframe_avi(ior, args->v0.head, &args->v0.data, size);
-		return 0;
-	case NVIF_OUTP_INFOFRAME_V0_VSI:
-		ior->func->hdmi->infoframe_vsi(ior, args->v0.head, &args->v0.data, size);
-		return 0;
+	ret = nvkm_uoutp_lock_acquired(uoutp);
+	if (ret)
+		return ret;
+
+	ior = uoutp->outp->ior;
+
+	switch (ior->func->hdmi ? type : 0xff) {
+	case NVIF_OUTP_INFOFRAME_AVI:
+		ior->func->hdmi->infoframe_avi(ior, head, data, size);
+		break;
+	case NVIF_OUTP_INFOFRAME_VSI:
+		ior->func->hdmi->infoframe_vsi(ior, head, data, size);
+		break;
 	default:
+		ret = -EINVAL;
 		break;
 	}
 
-	return -EINVAL;
+	nvkm_uoutp_unlock(uoutp);
+	return ret;
 }
 
 static int
@@ -533,7 +539,6 @@ static int
 nvkm_uoutp_mthd_acquired(struct nvkm_outp *outp, u32 mthd, void *argv, u32 argc)
 {
 	switch (mthd) {
-	case NVIF_OUTP_V0_INFOFRAME    : return nvkm_uoutp_mthd_infoframe    (outp, argv, argc);
 	case NVIF_OUTP_V0_HDA_ELD      : return nvkm_uoutp_mthd_hda_eld      (outp, argv, argc);
 	case NVIF_OUTP_V0_DP_TRAIN     : return nvkm_uoutp_mthd_dp_train     (outp, argv, argc);
 	case NVIF_OUTP_V0_DP_DRIVE     : return nvkm_uoutp_mthd_dp_drive     (outp, argv, argc);
@@ -670,6 +675,7 @@ nvkm_uoutp_new(struct nvkm_disp *disp, u8 id, const struct nvif_outp_impl **pimp
 		}
 		uoutp->impl.proto = NVIF_OUTP_TMDS;
 		uoutp->impl.hdmi.config = nvkm_uoutp_hdmi;
+		uoutp->impl.hdmi.infoframe = nvkm_uoutp_infoframe;
 		break;
 	case DCB_OUTPUT_LVDS:
 		uoutp->impl.type = NVIF_OUTP_SOR;
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 116/156] drm/nouveau/nvif: rework outp "hda eld" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (114 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 115/156] drm/nouveau/nvif: rework outp "infoframe" api Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 117/156] drm/nouveau/nvif: rework outp "dp aux pwr" api Ben Skeggs
                   ` (41 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interface

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  4 ++
 drivers/gpu/drm/nouveau/include/nvif/if0012.h | 11 -----
 drivers/gpu/drm/nouveau/nvif/outp.c           | 13 +-----
 .../gpu/drm/nouveau/nvkm/engine/disp/uoutp.c  | 45 +++++++++++--------
 4 files changed, 32 insertions(+), 41 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index cef19e04f208..742cf0e1678b 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -304,6 +304,10 @@ struct nvif_outp_impl {
 				 u8 *data, u8 size);
 	} hdmi;
 
+	struct {
+		int (*eld)(struct nvif_outp_priv *, u8 head, u8 *data, u8 size);
+	} hda;
+
 	struct {
 		u8 acpi_edid;
 
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0012.h b/drivers/gpu/drm/nouveau/include/nvif/if0012.h
index a045c66fc1ca..160387dfc2a0 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/if0012.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/if0012.h
@@ -4,8 +4,6 @@
 
 #include <drm/display/drm_dp.h>
 
-#define NVIF_OUTP_V0_HDA_ELD       0x61
-
 #define NVIF_OUTP_V0_DP_AUX_PWR    0x70
 #define NVIF_OUTP_V0_DP_AUX_XFER   0x71
 #define NVIF_OUTP_V0_DP_RATES      0x72
@@ -16,15 +14,6 @@
 #define NVIF_OUTP_V0_DP_MST_ID_PUT 0x77
 #define NVIF_OUTP_V0_DP_MST_VCPI   0x78
 
-union nvif_outp_hda_eld_args {
-	struct nvif_outp_hda_eld_v0 {
-		__u8  version;
-		__u8  head;
-		__u8  pad02[6];
-		__u8  data[];
-	} v0;
-};
-
 union nvif_outp_dp_aux_pwr_args {
 	struct nvif_outp_dp_aux_pwr_v0 {
 		__u8 version;
diff --git a/drivers/gpu/drm/nouveau/nvif/outp.c b/drivers/gpu/drm/nouveau/nvif/outp.c
index 4ecdc44eb84a..cf79c56aae0c 100644
--- a/drivers/gpu/drm/nouveau/nvif/outp.c
+++ b/drivers/gpu/drm/nouveau/nvif/outp.c
@@ -195,20 +195,9 @@ nvif_outp_dp_aux_pwr(struct nvif_outp *outp, bool enable)
 int
 nvif_outp_hda_eld(struct nvif_outp *outp, int head, void *data, u32 size)
 {
-	struct {
-		struct nvif_outp_hda_eld_v0 mthd;
-		u8 data[128];
-	} args;
 	int ret;
 
-	if (WARN_ON(size > ARRAY_SIZE(args.data)))
-		return -EINVAL;
-
-	args.mthd.version = 0;
-	args.mthd.head = head;
-
-	memcpy(args.data, data, size);
-	ret = nvif_mthd(&outp->object, NVIF_OUTP_V0_HDA_ELD, &args, sizeof(args.mthd) + size);
+	ret = outp->impl->hda.eld(outp->priv, head, data, size);
 	NVIF_ERRON(ret, &outp->object, "[HDA_ELD head:%d size:%d]", head, size);
 	return ret;
 }
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
index a694a43fd495..7184f13f39f5 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
@@ -208,39 +208,47 @@ nvkm_uoutp_mthd_dp_aux_pwr(struct nvkm_outp *outp, void *argv, u32 argc)
 }
 
 static int
-nvkm_uoutp_mthd_hda_eld(struct nvkm_outp *outp, void *argv, u32 argc)
+nvkm_uoutp_hda_eld(struct nvif_outp_priv *uoutp, u8 head, u8 *data, u8 size)
 {
-	struct nvkm_ior *ior = outp->ior;
-	union nvif_outp_hda_eld_args *args = argv;
-
-	if (argc < sizeof(args->v0) || args->v0.version != 0)
-		return -ENOSYS;
-	argc -= sizeof(args->v0);
+	struct nvkm_outp *outp = uoutp->outp;
+	struct nvkm_ior *ior;
+	int ret;
 
-	if (!ior->hda || !nvkm_head_find(outp->disp, args->v0.head))
+	if (!nvkm_head_find(outp->disp, head))
 		return -EINVAL;
-	if (argc > 0x60)
+	if (size > 0x60)
 		return -E2BIG;
 
-	if (argc && args->v0.data[0]) {
+	ret = nvkm_uoutp_lock_acquired(uoutp);
+	if (ret)
+		return ret;
+
+	ior = outp->ior;
+	if (!ior->hda) {
+		nvkm_uoutp_unlock(uoutp);
+		return -EINVAL;
+	}
+
+	if (size && data[0]) {
 		if (outp->info.type == DCB_OUTPUT_DP)
-			ior->func->dp->audio(ior, args->v0.head, true);
+			ior->func->dp->audio(ior, head, true);
 		else
 		if (ior->func->hdmi->audio)
-			ior->func->hdmi->audio(ior, args->v0.head, true);
+			ior->func->hdmi->audio(ior, head, true);
 
-		ior->func->hda->hpd(ior, args->v0.head, true);
-		ior->func->hda->eld(ior, args->v0.head, args->v0.data, argc);
+		ior->func->hda->hpd(ior, head, true);
+		ior->func->hda->eld(ior, head, data, size);
 	} else {
-		ior->func->hda->hpd(ior, args->v0.head, false);
+		ior->func->hda->hpd(ior, head, false);
 
 		if (outp->info.type == DCB_OUTPUT_DP)
-			ior->func->dp->audio(ior, args->v0.head, false);
+			ior->func->dp->audio(ior, head, false);
 		else
 		if (ior->func->hdmi->audio)
-			ior->func->hdmi->audio(ior, args->v0.head, false);
+			ior->func->hdmi->audio(ior, head, false);
 	}
 
+	nvkm_uoutp_unlock(uoutp);
 	return 0;
 }
 
@@ -539,7 +547,6 @@ static int
 nvkm_uoutp_mthd_acquired(struct nvkm_outp *outp, u32 mthd, void *argv, u32 argc)
 {
 	switch (mthd) {
-	case NVIF_OUTP_V0_HDA_ELD      : return nvkm_uoutp_mthd_hda_eld      (outp, argv, argc);
 	case NVIF_OUTP_V0_DP_TRAIN     : return nvkm_uoutp_mthd_dp_train     (outp, argv, argc);
 	case NVIF_OUTP_V0_DP_DRIVE     : return nvkm_uoutp_mthd_dp_drive     (outp, argv, argc);
 	case NVIF_OUTP_V0_DP_SST       : return nvkm_uoutp_mthd_dp_sst       (outp, argv, argc);
@@ -676,6 +683,7 @@ nvkm_uoutp_new(struct nvkm_disp *disp, u8 id, const struct nvif_outp_impl **pimp
 		uoutp->impl.proto = NVIF_OUTP_TMDS;
 		uoutp->impl.hdmi.config = nvkm_uoutp_hdmi;
 		uoutp->impl.hdmi.infoframe = nvkm_uoutp_infoframe;
+		uoutp->impl.hda.eld = nvkm_uoutp_hda_eld;
 		break;
 	case DCB_OUTPUT_LVDS:
 		uoutp->impl.type = NVIF_OUTP_SOR;
@@ -692,6 +700,7 @@ nvkm_uoutp_new(struct nvkm_disp *disp, u8 id, const struct nvif_outp_impl **pimp
 			uoutp->impl.dp.aux = NVKM_I2C_AUX_EXT(outp->info.extdev);
 		}
 		uoutp->impl.proto = NVIF_OUTP_DP;
+		uoutp->impl.hda.eld = nvkm_uoutp_hda_eld;
 		uoutp->impl.dp.mst = outp->dp.mst;
 		uoutp->impl.dp.increased_wm = outp->dp.increased_wm;
 		uoutp->impl.dp.link_nr = outp->info.dpconf.link_nr;
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 117/156] drm/nouveau/nvif: rework outp "dp aux pwr" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (115 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 116/156] drm/nouveau/nvif: rework outp "hda eld" api Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 118/156] drm/nouveau/nvif: rework outp "dp aux xfer" api Ben Skeggs
                   ` (40 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interface

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/include/nvif/driverif.h |  2 ++
 drivers/gpu/drm/nouveau/include/nvif/if0012.h   |  9 ---------
 drivers/gpu/drm/nouveau/nvif/outp.c             |  8 ++------
 .../gpu/drm/nouveau/nvkm/engine/disp/uoutp.c    | 17 ++++++++---------
 4 files changed, 12 insertions(+), 24 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 742cf0e1678b..0dd85d4fa9ab 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -325,6 +325,8 @@ struct nvif_outp_impl {
 		u8 increased_wm;
 		u8 link_nr;
 		u32 link_bw;
+
+		int (*aux_pwr)(struct nvif_outp_priv *, bool enable);
 	} dp;
 };
 
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0012.h b/drivers/gpu/drm/nouveau/include/nvif/if0012.h
index 160387dfc2a0..c0981a5f9e87 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/if0012.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/if0012.h
@@ -4,7 +4,6 @@
 
 #include <drm/display/drm_dp.h>
 
-#define NVIF_OUTP_V0_DP_AUX_PWR    0x70
 #define NVIF_OUTP_V0_DP_AUX_XFER   0x71
 #define NVIF_OUTP_V0_DP_RATES      0x72
 #define NVIF_OUTP_V0_DP_TRAIN      0x73
@@ -14,14 +13,6 @@
 #define NVIF_OUTP_V0_DP_MST_ID_PUT 0x77
 #define NVIF_OUTP_V0_DP_MST_VCPI   0x78
 
-union nvif_outp_dp_aux_pwr_args {
-	struct nvif_outp_dp_aux_pwr_v0 {
-		__u8 version;
-		__u8 state;
-		__u8 pad02[6];
-	} v0;
-};
-
 union nvif_outp_dp_aux_xfer_args {
 	struct nvif_outp_dp_aux_xfer_v0 {
 		__u8  version;
diff --git a/drivers/gpu/drm/nouveau/nvif/outp.c b/drivers/gpu/drm/nouveau/nvif/outp.c
index cf79c56aae0c..8b09a7ae9876 100644
--- a/drivers/gpu/drm/nouveau/nvif/outp.c
+++ b/drivers/gpu/drm/nouveau/nvif/outp.c
@@ -181,14 +181,10 @@ nvif_outp_dp_aux_xfer(struct nvif_outp *outp, u8 type, u8 *psize, u32 addr, u8 *
 int
 nvif_outp_dp_aux_pwr(struct nvif_outp *outp, bool enable)
 {
-	struct nvif_outp_dp_aux_pwr_v0 args;
 	int ret;
 
-	args.version = 0;
-	args.state = enable;
-
-	ret = nvif_object_mthd(&outp->object, NVIF_OUTP_V0_DP_AUX_PWR, &args, sizeof(args));
-	NVIF_ERRON(ret, &outp->object, "[DP_AUX_PWR state:%d]", args.state);
+	ret = outp->impl->dp.aux_pwr(outp->priv, enable);
+	NVIF_ERRON(ret, &outp->object, "[DP_AUX_PWR state:%d]", enable);
 	return ret;
 }
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
index 7184f13f39f5..36b4ea9a10fd 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
@@ -195,16 +195,15 @@ nvkm_uoutp_mthd_dp_aux_xfer(struct nvkm_outp *outp, void *argv, u32 argc)
 }
 
 static int
-nvkm_uoutp_mthd_dp_aux_pwr(struct nvkm_outp *outp, void *argv, u32 argc)
+nvkm_uoutp_dp_aux_pwr(struct nvif_outp_priv *uoutp, bool enable)
 {
-	union nvif_outp_dp_aux_pwr_args *args = argv;
-
-	if (argc != sizeof(args->v0) || args->v0.version != 0)
-		return -ENOSYS;
-	if (!outp->func->dp.aux_pwr)
-		return -EINVAL;
+	struct nvkm_outp *outp = uoutp->outp;
+	int ret;
 
-	return outp->func->dp.aux_pwr(outp, !!args->v0.state);
+	nvkm_uoutp_lock(uoutp);
+	ret = outp->func->dp.aux_pwr(outp, enable);
+	nvkm_uoutp_unlock(uoutp);
+	return ret;
 }
 
 static int
@@ -564,7 +563,6 @@ static int
 nvkm_uoutp_mthd_noacquire(struct nvkm_outp *outp, u32 mthd, void *argv, u32 argc, bool *invalid)
 {
 	switch (mthd) {
-	case NVIF_OUTP_V0_DP_AUX_PWR : return nvkm_uoutp_mthd_dp_aux_pwr (outp, argv, argc);
 	case NVIF_OUTP_V0_DP_AUX_XFER: return nvkm_uoutp_mthd_dp_aux_xfer(outp, argv, argc);
 	case NVIF_OUTP_V0_DP_RATES   : return nvkm_uoutp_mthd_dp_rates   (outp, argv, argc);
 	default:
@@ -705,6 +703,7 @@ nvkm_uoutp_new(struct nvkm_disp *disp, u8 id, const struct nvif_outp_impl **pimp
 		uoutp->impl.dp.increased_wm = outp->dp.increased_wm;
 		uoutp->impl.dp.link_nr = outp->info.dpconf.link_nr;
 		uoutp->impl.dp.link_bw = outp->info.dpconf.link_bw * 27000;
+		uoutp->impl.dp.aux_pwr = nvkm_uoutp_dp_aux_pwr;
 		break;
 	default:
 		WARN_ON(1);
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 118/156] drm/nouveau/nvif: rework outp "dp aux xfer" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (116 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 117/156] drm/nouveau/nvif: rework outp "dp aux pwr" api Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 119/156] drm/nouveau/nvif: rework outp "dp rates" api Ben Skeggs
                   ` (39 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interface

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 .../gpu/drm/nouveau/include/nvif/driverif.h    |  1 +
 drivers/gpu/drm/nouveau/include/nvif/if0012.h  | 12 ------------
 drivers/gpu/drm/nouveau/nvif/outp.c            | 14 +++-----------
 .../gpu/drm/nouveau/nvkm/engine/disp/uoutp.c   | 18 ++++++++----------
 4 files changed, 12 insertions(+), 33 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 0dd85d4fa9ab..2069eedde843 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -327,6 +327,7 @@ struct nvif_outp_impl {
 		u32 link_bw;
 
 		int (*aux_pwr)(struct nvif_outp_priv *, bool enable);
+		int (*aux_xfer)(struct nvif_outp_priv *, u8 type, u32 addr, u8 *data, u8 *size);
 	} dp;
 };
 
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0012.h b/drivers/gpu/drm/nouveau/include/nvif/if0012.h
index c0981a5f9e87..b036197aadea 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/if0012.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/if0012.h
@@ -4,7 +4,6 @@
 
 #include <drm/display/drm_dp.h>
 
-#define NVIF_OUTP_V0_DP_AUX_XFER   0x71
 #define NVIF_OUTP_V0_DP_RATES      0x72
 #define NVIF_OUTP_V0_DP_TRAIN      0x73
 #define NVIF_OUTP_V0_DP_DRIVE      0x74
@@ -13,17 +12,6 @@
 #define NVIF_OUTP_V0_DP_MST_ID_PUT 0x77
 #define NVIF_OUTP_V0_DP_MST_VCPI   0x78
 
-union nvif_outp_dp_aux_xfer_args {
-	struct nvif_outp_dp_aux_xfer_v0 {
-		__u8  version;
-		__u8  pad01;
-		__u8  type;
-		__u8  size;
-		__u32 addr;
-		__u8  data[16];
-	} v0;
-};
-
 union nvif_outp_dp_rates_args {
 	struct nvif_outp_dp_rates_v0 {
 		__u8  version;
diff --git a/drivers/gpu/drm/nouveau/nvif/outp.c b/drivers/gpu/drm/nouveau/nvif/outp.c
index 8b09a7ae9876..602362aa0203 100644
--- a/drivers/gpu/drm/nouveau/nvif/outp.c
+++ b/drivers/gpu/drm/nouveau/nvif/outp.c
@@ -157,24 +157,16 @@ nvif_outp_dp_rates(struct nvif_outp *outp, struct nvif_outp_dp_rate *rate, int r
 int
 nvif_outp_dp_aux_xfer(struct nvif_outp *outp, u8 type, u8 *psize, u32 addr, u8 *data)
 {
-	struct nvif_outp_dp_aux_xfer_v0 args;
 	u8 size = *psize;
 	int ret;
 
-	args.version = 0;
-	args.type = type;
-	args.size = size;
-	args.addr = addr;
-	memcpy(args.data, data, size);
-	ret = nvif_object_mthd(&outp->object, NVIF_OUTP_V0_DP_AUX_XFER, &args, sizeof(args));
+	ret = outp->impl->dp.aux_xfer(outp->priv, type, addr, data, &size);
 	NVIF_DEBUG(&outp->object, "[DP_AUX_XFER type:%d size:%d addr:%05x] %d size:%d (ret: %d)",
-		   args.type, size, args.addr, ret, args.size, ret);
+		   type, *psize, addr, ret, size, ret);
 	if (ret < 0)
 		return ret;
 
-	*psize = args.size;
-
-	memcpy(data, args.data, size);
+	*psize = size;
 	return ret;
 }
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
index 36b4ea9a10fd..f7226bcb9ef4 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
@@ -181,17 +181,15 @@ nvkm_uoutp_mthd_dp_rates(struct nvkm_outp *outp, void *argv, u32 argc)
 }
 
 static int
-nvkm_uoutp_mthd_dp_aux_xfer(struct nvkm_outp *outp, void *argv, u32 argc)
+nvkm_uoutp_dp_aux_xfer(struct nvif_outp_priv *uoutp, u8 type, u32 addr, u8 *data, u8 *size)
 {
-	union nvif_outp_dp_aux_xfer_args *args = argv;
-
-	if (argc != sizeof(args->v0) || args->v0.version != 0)
-		return -ENOSYS;
-	if (!outp->func->dp.aux_xfer)
-		return -EINVAL;
+	struct nvkm_outp *outp = uoutp->outp;
+	int ret;
 
-	return outp->func->dp.aux_xfer(outp, args->v0.type, args->v0.addr,
-					     args->v0.data, &args->v0.size);
+	nvkm_uoutp_lock(uoutp);
+	ret = outp->func->dp.aux_xfer(outp, type, addr, data, size);
+	nvkm_uoutp_unlock(uoutp);
+	return ret;
 }
 
 static int
@@ -563,7 +561,6 @@ static int
 nvkm_uoutp_mthd_noacquire(struct nvkm_outp *outp, u32 mthd, void *argv, u32 argc, bool *invalid)
 {
 	switch (mthd) {
-	case NVIF_OUTP_V0_DP_AUX_XFER: return nvkm_uoutp_mthd_dp_aux_xfer(outp, argv, argc);
 	case NVIF_OUTP_V0_DP_RATES   : return nvkm_uoutp_mthd_dp_rates   (outp, argv, argc);
 	default:
 		break;
@@ -704,6 +701,7 @@ nvkm_uoutp_new(struct nvkm_disp *disp, u8 id, const struct nvif_outp_impl **pimp
 		uoutp->impl.dp.link_nr = outp->info.dpconf.link_nr;
 		uoutp->impl.dp.link_bw = outp->info.dpconf.link_bw * 27000;
 		uoutp->impl.dp.aux_pwr = nvkm_uoutp_dp_aux_pwr;
+		uoutp->impl.dp.aux_xfer = nvkm_uoutp_dp_aux_xfer;
 		break;
 	default:
 		WARN_ON(1);
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 119/156] drm/nouveau/nvif: rework outp "dp rates" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (117 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 118/156] drm/nouveau/nvif: rework outp "dp aux xfer" api Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 120/156] drm/nouveau/nvif: rework outp "dp train" api Ben Skeggs
                   ` (38 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interface

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  6 +++
 drivers/gpu/drm/nouveau/include/nvif/if0012.h | 13 -------
 drivers/gpu/drm/nouveau/include/nvif/outp.h   |  5 ---
 drivers/gpu/drm/nouveau/nvif/outp.c           | 17 ++------
 .../gpu/drm/nouveau/nvkm/engine/disp/uoutp.c  | 39 ++++++-------------
 5 files changed, 20 insertions(+), 60 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 2069eedde843..9395ddad65bf 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -255,6 +255,11 @@ enum nvif_outp_detect_status {
 	NVIF_OUTP_DETECT_UNKNOWN,
 };
 
+struct nvif_outp_dp_rate {
+	int dpcd; /* -1 for non-indexed rates */
+	u32 rate;
+};
+
 struct nvif_outp_impl {
 	void (*del)(struct nvif_outp_priv *);
 
@@ -328,6 +333,7 @@ struct nvif_outp_impl {
 
 		int (*aux_pwr)(struct nvif_outp_priv *, bool enable);
 		int (*aux_xfer)(struct nvif_outp_priv *, u8 type, u32 addr, u8 *data, u8 *size);
+		int (*rates)(struct nvif_outp_priv *, struct nvif_outp_dp_rate *, u8 rates);
 	} dp;
 };
 
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0012.h b/drivers/gpu/drm/nouveau/include/nvif/if0012.h
index b036197aadea..327ff9aa3ae0 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/if0012.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/if0012.h
@@ -4,7 +4,6 @@
 
 #include <drm/display/drm_dp.h>
 
-#define NVIF_OUTP_V0_DP_RATES      0x72
 #define NVIF_OUTP_V0_DP_TRAIN      0x73
 #define NVIF_OUTP_V0_DP_DRIVE      0x74
 #define NVIF_OUTP_V0_DP_SST        0x75
@@ -12,18 +11,6 @@
 #define NVIF_OUTP_V0_DP_MST_ID_PUT 0x77
 #define NVIF_OUTP_V0_DP_MST_VCPI   0x78
 
-union nvif_outp_dp_rates_args {
-	struct nvif_outp_dp_rates_v0 {
-		__u8  version;
-		__u8  pad01[6];
-		__u8  rates;
-		struct {
-			__s8  dpcd;
-			__u32 rate;
-		} rate[8];
-	} v0;
-};
-
 union nvif_outp_dp_train_args {
 	struct nvif_outp_dp_train_v0 {
 		__u8  version;
diff --git a/drivers/gpu/drm/nouveau/include/nvif/outp.h b/drivers/gpu/drm/nouveau/include/nvif/outp.h
index 8be799c88aff..7f7620ec1487 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/outp.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/outp.h
@@ -56,11 +56,6 @@ int nvif_outp_hda_eld(struct nvif_outp *, int head, void *data, u32 size);
 int nvif_outp_dp_aux_pwr(struct nvif_outp *, bool enable);
 int nvif_outp_dp_aux_xfer(struct nvif_outp *, u8 type, u8 *size, u32 addr, u8 *data);
 
-struct nvif_outp_dp_rate {
-	int dpcd; /* -1 for non-indexed rates */
-	u32 rate;
-};
-
 int nvif_outp_dp_rates(struct nvif_outp *, struct nvif_outp_dp_rate *rate, int rate_nr);
 int nvif_outp_dp_train(struct nvif_outp *, u8 dpcd[DP_RECEIVER_CAP_SIZE],
 		       u8 lttprs, u8 link_nr, u32 link_bw, bool mst, bool post_lt_adj,
diff --git a/drivers/gpu/drm/nouveau/nvif/outp.c b/drivers/gpu/drm/nouveau/nvif/outp.c
index 602362aa0203..68af891505d1 100644
--- a/drivers/gpu/drm/nouveau/nvif/outp.c
+++ b/drivers/gpu/drm/nouveau/nvif/outp.c
@@ -134,23 +134,12 @@ nvif_outp_dp_train(struct nvif_outp *outp, u8 dpcd[DP_RECEIVER_CAP_SIZE], u8 ltt
 }
 
 int
-nvif_outp_dp_rates(struct nvif_outp *outp, struct nvif_outp_dp_rate *rate, int rate_nr)
+nvif_outp_dp_rates(struct nvif_outp *outp, struct nvif_outp_dp_rate *rate, int rates)
 {
-	struct nvif_outp_dp_rates_v0 args;
 	int ret;
 
-	if (rate_nr > ARRAY_SIZE(args.rate))
-		return -EINVAL;
-
-	args.version = 0;
-	args.rates = rate_nr;
-	for (int i = 0; i < args.rates; i++, rate++) {
-		args.rate[i].dpcd = rate->dpcd;
-		args.rate[i].rate = rate->rate;
-	}
-
-	ret = nvif_object_mthd(&outp->object, NVIF_OUTP_V0_DP_RATES, &args, sizeof(args));
-	NVIF_ERRON(ret, &outp->object, "[DP_RATES rates:%d]", args.rates);
+	ret = outp->impl->dp.rates(outp->priv, rate, rates);
+	NVIF_ERRON(ret, &outp->object, "[DP_RATES rates:%d]", rates);
 	return ret;
 }
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
index f7226bcb9ef4..00b66d400f68 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
@@ -158,25 +158,26 @@ nvkm_uoutp_mthd_dp_train(struct nvkm_outp *outp, void *argv, u32 argc)
 }
 
 static int
-nvkm_uoutp_mthd_dp_rates(struct nvkm_outp *outp, void *argv, u32 argc)
+nvkm_uoutp_dp_rates(struct nvif_outp_priv *uoutp, struct nvif_outp_dp_rate *rate, u8 rates)
 {
-	union nvif_outp_dp_rates_args *args = argv;
+	struct nvkm_outp *outp = uoutp->outp;
 
-	if (argc != sizeof(args->v0) || args->v0.version != 0)
-		return -ENOSYS;
-	if (args->v0.rates > ARRAY_SIZE(outp->dp.rate))
+	if (rates > ARRAY_SIZE(outp->dp.rate))
 		return -EINVAL;
 
-	for (int i = 0; i < args->v0.rates; i++) {
-		outp->dp.rate[i].dpcd = args->v0.rate[i].dpcd;
-		outp->dp.rate[i].rate = args->v0.rate[i].rate;
+	nvkm_uoutp_lock(uoutp);
+
+	for (int i = 0; i < rates; i++) {
+		outp->dp.rate[i].dpcd = rate[i].dpcd;
+		outp->dp.rate[i].rate = rate[i].rate;
 	}
 
-	outp->dp.rates = args->v0.rates;
+	outp->dp.rates = rates;
 
 	if (outp->func->dp.rates)
 		outp->func->dp.rates(outp);
 
+	nvkm_uoutp_unlock(uoutp);
 	return 0;
 }
 
@@ -557,39 +558,20 @@ nvkm_uoutp_mthd_acquired(struct nvkm_outp *outp, u32 mthd, void *argv, u32 argc)
 	return -EINVAL;
 }
 
-static int
-nvkm_uoutp_mthd_noacquire(struct nvkm_outp *outp, u32 mthd, void *argv, u32 argc, bool *invalid)
-{
-	switch (mthd) {
-	case NVIF_OUTP_V0_DP_RATES   : return nvkm_uoutp_mthd_dp_rates   (outp, argv, argc);
-	default:
-		break;
-	}
-
-	*invalid = true;
-	return 0;
-}
-
 static int
 nvkm_uoutp_mthd(struct nvkm_object *object, u32 mthd, void *argv, u32 argc)
 {
 	struct nvkm_outp *outp = container_of(object, struct nvif_outp_priv, object)->outp;
 	struct nvkm_disp *disp = outp->disp;
-	bool invalid = false;
 	int ret;
 
 	mutex_lock(&disp->super.mutex);
 
-	ret = nvkm_uoutp_mthd_noacquire(outp, mthd, argv, argc, &invalid);
-	if (!invalid)
-		goto done;
-
 	if (outp->ior)
 		ret = nvkm_uoutp_mthd_acquired(outp, mthd, argv, argc);
 	else
 		ret = -EIO;
 
-done:
 	mutex_unlock(&disp->super.mutex);
 	return ret;
 }
@@ -702,6 +684,7 @@ nvkm_uoutp_new(struct nvkm_disp *disp, u8 id, const struct nvif_outp_impl **pimp
 		uoutp->impl.dp.link_bw = outp->info.dpconf.link_bw * 27000;
 		uoutp->impl.dp.aux_pwr = nvkm_uoutp_dp_aux_pwr;
 		uoutp->impl.dp.aux_xfer = nvkm_uoutp_dp_aux_xfer;
+		uoutp->impl.dp.rates = nvkm_uoutp_dp_rates;
 		break;
 	default:
 		WARN_ON(1);
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 120/156] drm/nouveau/nvif: rework outp "dp train" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (118 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 119/156] drm/nouveau/nvif: rework outp "dp rates" api Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 121/156] drm/nouveau/nvif: rework outp "dp drive" api Ben Skeggs
                   ` (37 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interface

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  4 +++
 drivers/gpu/drm/nouveau/include/nvif/if0012.h | 14 --------
 drivers/gpu/drm/nouveau/nvif/outp.c           | 16 ++-------
 .../gpu/drm/nouveau/nvkm/engine/disp/uoutp.c  | 33 ++++++++++---------
 4 files changed, 25 insertions(+), 42 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 9395ddad65bf..2660f37c5443 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -1,6 +1,8 @@
 /* SPDX-License-Identifier: MIT */
 #ifndef __NVIF_DRIVERIF_H__
 #define __NVIF_DRIVERIF_H__
+#include <drm/display/drm_dp.h>
+
 struct nvif_event_priv;
 struct nvif_client_priv;
 struct nvif_device_priv;
@@ -334,6 +336,8 @@ struct nvif_outp_impl {
 		int (*aux_pwr)(struct nvif_outp_priv *, bool enable);
 		int (*aux_xfer)(struct nvif_outp_priv *, u8 type, u32 addr, u8 *data, u8 *size);
 		int (*rates)(struct nvif_outp_priv *, struct nvif_outp_dp_rate *, u8 rates);
+		int (*train)(struct nvif_outp_priv *, u8 dpcd[DP_RECEIVER_CAP_SIZE], u8 lttprs,
+			     u8 link_nr, u32 link_bw, bool mst, bool post_lt_adj, bool retrain);
 	} dp;
 };
 
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0012.h b/drivers/gpu/drm/nouveau/include/nvif/if0012.h
index 327ff9aa3ae0..5db1f718e82c 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/if0012.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/if0012.h
@@ -4,26 +4,12 @@
 
 #include <drm/display/drm_dp.h>
 
-#define NVIF_OUTP_V0_DP_TRAIN      0x73
 #define NVIF_OUTP_V0_DP_DRIVE      0x74
 #define NVIF_OUTP_V0_DP_SST        0x75
 #define NVIF_OUTP_V0_DP_MST_ID_GET 0x76
 #define NVIF_OUTP_V0_DP_MST_ID_PUT 0x77
 #define NVIF_OUTP_V0_DP_MST_VCPI   0x78
 
-union nvif_outp_dp_train_args {
-	struct nvif_outp_dp_train_v0 {
-		__u8  version;
-		__u8  retrain;
-		__u8  mst;
-		__u8  lttprs;
-		__u8  post_lt_adj;
-		__u8  link_nr;
-		__u32 link_bw;
-		__u8 dpcd[DP_RECEIVER_CAP_SIZE];
-	} v0;
-};
-
 union nvif_outp_dp_drive_args {
 	struct nvif_outp_dp_drive_v0 {
 		__u8  version;
diff --git a/drivers/gpu/drm/nouveau/nvif/outp.c b/drivers/gpu/drm/nouveau/nvif/outp.c
index 68af891505d1..f20846a7f487 100644
--- a/drivers/gpu/drm/nouveau/nvif/outp.c
+++ b/drivers/gpu/drm/nouveau/nvif/outp.c
@@ -113,23 +113,13 @@ int
 nvif_outp_dp_train(struct nvif_outp *outp, u8 dpcd[DP_RECEIVER_CAP_SIZE], u8 lttprs,
 		   u8 link_nr, u32 link_bw, bool mst, bool post_lt_adj, bool retrain)
 {
-	struct nvif_outp_dp_train_v0 args;
 	int ret;
 
-	args.version = 0;
-	args.retrain = retrain;
-	args.mst = mst;
-	args.lttprs = lttprs;
-	args.post_lt_adj = post_lt_adj;
-	args.link_nr = link_nr;
-	args.link_bw = link_bw;
-	memcpy(args.dpcd, dpcd, sizeof(args.dpcd));
-
-	ret = nvif_object_mthd(&outp->object, NVIF_OUTP_V0_DP_TRAIN, &args, sizeof(args));
+	ret = outp->impl->dp.train(outp->priv, dpcd, lttprs, link_nr, link_bw, mst,
+				   post_lt_adj, retrain);
 	NVIF_ERRON(ret, &outp->object,
 		   "[DP_TRAIN retrain:%d mst:%d lttprs:%d post_lt_adj:%d nr:%d bw:%d]",
-		   args.retrain, args.mst, args.lttprs, args.post_lt_adj, args.link_nr,
-		   args.link_bw);
+		   retrain, mst, lttprs, post_lt_adj, link_nr, link_bw);
 	return ret;
 }
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
index 00b66d400f68..673c8c10c782 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
@@ -136,25 +136,28 @@ nvkm_uoutp_mthd_dp_drive(struct nvkm_outp *outp, void *argv, u32 argc)
 }
 
 static int
-nvkm_uoutp_mthd_dp_train(struct nvkm_outp *outp, void *argv, u32 argc)
+nvkm_uoutp_dp_train(struct nvif_outp_priv *uoutp, u8 dpcd[DP_RECEIVER_CAP_SIZE], u8 lttprs,
+		    u8 link_nr, u32 link_bw, bool mst, bool post_lt_adj, bool retrain)
 {
-	union nvif_outp_dp_train_args *args = argv;
+	struct nvkm_outp *outp = uoutp->outp;
+	int ret;
 
-	if (argc != sizeof(args->v0) || args->v0.version != 0)
-		return -ENOSYS;
-	if (!outp->func->dp.train)
-		return -EINVAL;
+	ret = nvkm_uoutp_lock_acquired(uoutp);
+	if (ret)
+		return ret;
 
-	if (!args->v0.retrain) {
-		memcpy(outp->dp.dpcd, args->v0.dpcd, sizeof(outp->dp.dpcd));
-		outp->dp.lttprs = args->v0.lttprs;
-		outp->dp.lt.nr = args->v0.link_nr;
-		outp->dp.lt.bw = args->v0.link_bw / 27000;
-		outp->dp.lt.mst = args->v0.mst;
-		outp->dp.lt.post_adj = args->v0.post_lt_adj;
+	if (!retrain) {
+		memcpy(outp->dp.dpcd, dpcd, sizeof(outp->dp.dpcd));
+		outp->dp.lttprs = lttprs;
+		outp->dp.lt.nr = link_nr;
+		outp->dp.lt.bw = link_bw / 27000;
+		outp->dp.lt.mst = mst;
+		outp->dp.lt.post_adj = post_lt_adj;
 	}
 
-	return outp->func->dp.train(outp, args->v0.retrain);
+	ret = outp->func->dp.train(outp, retrain);
+	nvkm_uoutp_unlock(uoutp);
+	return ret;
 }
 
 static int
@@ -545,7 +548,6 @@ static int
 nvkm_uoutp_mthd_acquired(struct nvkm_outp *outp, u32 mthd, void *argv, u32 argc)
 {
 	switch (mthd) {
-	case NVIF_OUTP_V0_DP_TRAIN     : return nvkm_uoutp_mthd_dp_train     (outp, argv, argc);
 	case NVIF_OUTP_V0_DP_DRIVE     : return nvkm_uoutp_mthd_dp_drive     (outp, argv, argc);
 	case NVIF_OUTP_V0_DP_SST       : return nvkm_uoutp_mthd_dp_sst       (outp, argv, argc);
 	case NVIF_OUTP_V0_DP_MST_ID_GET: return nvkm_uoutp_mthd_dp_mst_id_get(outp, argv, argc);
@@ -685,6 +687,7 @@ nvkm_uoutp_new(struct nvkm_disp *disp, u8 id, const struct nvif_outp_impl **pimp
 		uoutp->impl.dp.aux_pwr = nvkm_uoutp_dp_aux_pwr;
 		uoutp->impl.dp.aux_xfer = nvkm_uoutp_dp_aux_xfer;
 		uoutp->impl.dp.rates = nvkm_uoutp_dp_rates;
+		uoutp->impl.dp.train = nvkm_uoutp_dp_train;
 		break;
 	default:
 		WARN_ON(1);
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 121/156] drm/nouveau/nvif: rework outp "dp drive" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (119 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 120/156] drm/nouveau/nvif: rework outp "dp train" api Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 122/156] drm/nouveau/nvif: rework outp "dp sst" api Ben Skeggs
                   ` (36 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interface

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 .../gpu/drm/nouveau/include/nvif/driverif.h    |  1 +
 drivers/gpu/drm/nouveau/include/nvif/if0012.h  | 13 -------------
 drivers/gpu/drm/nouveau/nvif/outp.c            | 12 +++---------
 .../gpu/drm/nouveau/nvkm/engine/disp/uoutp.c   | 18 ++++++++++--------
 4 files changed, 14 insertions(+), 30 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 2660f37c5443..db6fb1347b72 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -338,6 +338,7 @@ struct nvif_outp_impl {
 		int (*rates)(struct nvif_outp_priv *, struct nvif_outp_dp_rate *, u8 rates);
 		int (*train)(struct nvif_outp_priv *, u8 dpcd[DP_RECEIVER_CAP_SIZE], u8 lttprs,
 			     u8 link_nr, u32 link_bw, bool mst, bool post_lt_adj, bool retrain);
+		int (*drive)(struct nvif_outp_priv *, u8 lanes, u8 pe[4], u8 vs[4]);
 	} dp;
 };
 
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0012.h b/drivers/gpu/drm/nouveau/include/nvif/if0012.h
index 5db1f718e82c..8b0f90327187 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/if0012.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/if0012.h
@@ -2,24 +2,11 @@
 #ifndef __NVIF_IF0012_H__
 #define __NVIF_IF0012_H__
 
-#include <drm/display/drm_dp.h>
-
-#define NVIF_OUTP_V0_DP_DRIVE      0x74
 #define NVIF_OUTP_V0_DP_SST        0x75
 #define NVIF_OUTP_V0_DP_MST_ID_GET 0x76
 #define NVIF_OUTP_V0_DP_MST_ID_PUT 0x77
 #define NVIF_OUTP_V0_DP_MST_VCPI   0x78
 
-union nvif_outp_dp_drive_args {
-	struct nvif_outp_dp_drive_v0 {
-		__u8  version;
-		__u8  pad01[2];
-		__u8  lanes;
-		__u8  pe[4];
-		__u8  vs[4];
-	} v0;
-};
-
 union nvif_outp_dp_sst_args {
 	struct nvif_outp_dp_sst_v0 {
 		__u8  version;
diff --git a/drivers/gpu/drm/nouveau/nvif/outp.c b/drivers/gpu/drm/nouveau/nvif/outp.c
index f20846a7f487..3d4461e3a2cd 100644
--- a/drivers/gpu/drm/nouveau/nvif/outp.c
+++ b/drivers/gpu/drm/nouveau/nvif/outp.c
@@ -94,18 +94,12 @@ nvif_outp_dp_sst(struct nvif_outp *outp, int head, u32 watermark, u32 hblanksym,
 }
 
 int
-nvif_outp_dp_drive(struct nvif_outp *outp, u8 link_nr, u8 pe[4], u8 vs[4])
+nvif_outp_dp_drive(struct nvif_outp *outp, u8 lanes, u8 pe[4], u8 vs[4])
 {
-	struct nvif_outp_dp_drive_v0 args;
 	int ret;
 
-	args.version = 0;
-	args.lanes   = link_nr;
-	memcpy(args.pe, pe, sizeof(args.pe));
-	memcpy(args.vs, vs, sizeof(args.vs));
-
-	ret = nvif_object_mthd(&outp->object, NVIF_OUTP_V0_DP_DRIVE, &args, sizeof(args));
-	NVIF_ERRON(ret, &outp->object, "[DP_DRIVE lanes:%d]", args.lanes);
+	ret = outp->impl->dp.drive(outp->priv, lanes, pe, vs);
+	NVIF_ERRON(ret, &outp->object, "[DP_DRIVE lanes:%d]", lanes);
 	return ret;
 }
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
index 673c8c10c782..3d5b6cee97bc 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
@@ -123,16 +123,18 @@ nvkm_uoutp_mthd_dp_sst(struct nvkm_outp *outp, void *argv, u32 argc)
 }
 
 static int
-nvkm_uoutp_mthd_dp_drive(struct nvkm_outp *outp, void *argv, u32 argc)
+nvkm_uoutp_dp_drive(struct nvif_outp_priv *uoutp, u8 lanes, u8 pe[4], u8 vs[4])
 {
-	union nvif_outp_dp_drive_args *args = argv;
+	struct nvkm_outp *outp;
+	int ret;
 
-	if (argc != sizeof(args->v0) || args->v0.version != 0)
-		return -ENOSYS;
-	if (!outp->func->dp.drive)
-		return -EINVAL;
+	ret = nvkm_uoutp_lock_acquired(uoutp);
+	if (ret)
+		return ret;
 
-	return outp->func->dp.drive(outp, args->v0.lanes, args->v0.pe, args->v0.vs);
+	ret = outp->func->dp.drive(outp, lanes, pe, vs);
+	nvkm_uoutp_unlock(uoutp);
+	return ret;
 }
 
 static int
@@ -548,7 +550,6 @@ static int
 nvkm_uoutp_mthd_acquired(struct nvkm_outp *outp, u32 mthd, void *argv, u32 argc)
 {
 	switch (mthd) {
-	case NVIF_OUTP_V0_DP_DRIVE     : return nvkm_uoutp_mthd_dp_drive     (outp, argv, argc);
 	case NVIF_OUTP_V0_DP_SST       : return nvkm_uoutp_mthd_dp_sst       (outp, argv, argc);
 	case NVIF_OUTP_V0_DP_MST_ID_GET: return nvkm_uoutp_mthd_dp_mst_id_get(outp, argv, argc);
 	case NVIF_OUTP_V0_DP_MST_ID_PUT: return nvkm_uoutp_mthd_dp_mst_id_put(outp, argv, argc);
@@ -688,6 +689,7 @@ nvkm_uoutp_new(struct nvkm_disp *disp, u8 id, const struct nvif_outp_impl **pimp
 		uoutp->impl.dp.aux_xfer = nvkm_uoutp_dp_aux_xfer;
 		uoutp->impl.dp.rates = nvkm_uoutp_dp_rates;
 		uoutp->impl.dp.train = nvkm_uoutp_dp_train;
+		uoutp->impl.dp.drive = nvkm_uoutp_dp_drive;
 		break;
 	default:
 		WARN_ON(1);
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 122/156] drm/nouveau/nvif: rework outp "dp sst" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (120 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 121/156] drm/nouveau/nvif: rework outp "dp drive" api Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 123/156] drm/nouveau/nvif: rework outp "dp mst id get"/"dp mst id put" apis Ben Skeggs
                   ` (35 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interface

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  2 ++
 drivers/gpu/drm/nouveau/include/nvif/if0012.h | 12 -------
 drivers/gpu/drm/nouveau/nvif/outp.c           | 10 ++----
 .../gpu/drm/nouveau/nvkm/engine/disp/uoutp.c  | 34 ++++++++++++-------
 4 files changed, 25 insertions(+), 33 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index db6fb1347b72..dc103d2a20a9 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -339,6 +339,8 @@ struct nvif_outp_impl {
 		int (*train)(struct nvif_outp_priv *, u8 dpcd[DP_RECEIVER_CAP_SIZE], u8 lttprs,
 			     u8 link_nr, u32 link_bw, bool mst, bool post_lt_adj, bool retrain);
 		int (*drive)(struct nvif_outp_priv *, u8 lanes, u8 pe[4], u8 vs[4]);
+		int (*sst)(struct nvif_outp_priv *, u8 head,
+			   u32 watermark, u32 hblanksym, u32 vblanksym);
 	} dp;
 };
 
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0012.h b/drivers/gpu/drm/nouveau/include/nvif/if0012.h
index 8b0f90327187..92c4988101eb 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/if0012.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/if0012.h
@@ -2,22 +2,10 @@
 #ifndef __NVIF_IF0012_H__
 #define __NVIF_IF0012_H__
 
-#define NVIF_OUTP_V0_DP_SST        0x75
 #define NVIF_OUTP_V0_DP_MST_ID_GET 0x76
 #define NVIF_OUTP_V0_DP_MST_ID_PUT 0x77
 #define NVIF_OUTP_V0_DP_MST_VCPI   0x78
 
-union nvif_outp_dp_sst_args {
-	struct nvif_outp_dp_sst_v0 {
-		__u8  version;
-		__u8  head;
-		__u8  pad02[2];
-		__u32 watermark;
-		__u32 hblanksym;
-		__u32 vblanksym;
-	} v0;
-};
-
 union nvif_outp_dp_mst_id_put_args {
 	struct nvif_outp_dp_mst_id_put_v0 {
 		__u8  version;
diff --git a/drivers/gpu/drm/nouveau/nvif/outp.c b/drivers/gpu/drm/nouveau/nvif/outp.c
index 3d4461e3a2cd..f56485c2ad2c 100644
--- a/drivers/gpu/drm/nouveau/nvif/outp.c
+++ b/drivers/gpu/drm/nouveau/nvif/outp.c
@@ -78,18 +78,12 @@ nvif_outp_dp_mst_id_get(struct nvif_outp *outp, u32 *id)
 int
 nvif_outp_dp_sst(struct nvif_outp *outp, int head, u32 watermark, u32 hblanksym, u32 vblanksym)
 {
-	struct nvif_outp_dp_sst_v0 args;
 	int ret;
 
-	args.version = 0;
-	args.head = head;
-	args.watermark = watermark;
-	args.hblanksym = hblanksym;
-	args.vblanksym = vblanksym;
-	ret = nvif_object_mthd(&outp->object, NVIF_OUTP_V0_DP_SST, &args, sizeof(args));
+	ret = outp->impl->dp.sst(outp->priv, head, watermark, hblanksym, vblanksym);
 	NVIF_ERRON(ret, &outp->object,
 		   "[DP_SST head:%d watermark:%d hblanksym:%d vblanksym:%d]",
-		   args.head, args.watermark, args.hblanksym, args.vblanksym);
+		   head, watermark, hblanksym, vblanksym);
 	return ret;
 }
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
index 3d5b6cee97bc..cfa386c1bbeb 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
@@ -103,23 +103,31 @@ nvkm_uoutp_mthd_dp_mst_id_get(struct nvkm_outp *outp, void *argv, u32 argc)
 }
 
 static int
-nvkm_uoutp_mthd_dp_sst(struct nvkm_outp *outp, void *argv, u32 argc)
+nvkm_uoutp_dp_sst(struct nvif_outp_priv *uoutp, u8 head,
+		  u32 watermark, u32 hblanksym, u32 vblanksym)
 {
-	union nvif_outp_dp_sst_args *args = argv;
+	struct nvkm_outp *outp = uoutp->outp;
 	struct nvkm_disp *disp = outp->disp;
-	struct nvkm_ior *ior = outp->ior;
-
-	if (argc != sizeof(args->v0) || args->v0.version != 0)
-		return -ENOSYS;
+	struct nvkm_ior *ior;
+	int ret;
 
-	if (!ior->func->dp || !nvkm_head_find(disp, args->v0.head))
+	if (!nvkm_head_find(disp, head))
 		return -EINVAL;
-	if (!ior->func->dp->sst)
-		return 0;
 
-	return ior->func->dp->sst(ior, args->v0.head,
-				  outp->dp.dpcd[DPCD_RC02] & DPCD_RC02_ENHANCED_FRAME_CAP,
-				  args->v0.watermark, args->v0.hblanksym, args->v0.vblanksym);
+	ret = nvkm_uoutp_lock_acquired(uoutp);
+	if (ret)
+		return ret;
+
+	ior = outp->ior;
+
+	if (ior->func->dp->sst) {
+		ret = ior->func->dp->sst(ior, head,
+					 outp->dp.dpcd[DPCD_RC02] & DPCD_RC02_ENHANCED_FRAME_CAP,
+					 watermark, hblanksym, vblanksym);
+	}
+
+	nvkm_uoutp_unlock(uoutp);
+	return ret;
 }
 
 static int
@@ -550,7 +558,6 @@ static int
 nvkm_uoutp_mthd_acquired(struct nvkm_outp *outp, u32 mthd, void *argv, u32 argc)
 {
 	switch (mthd) {
-	case NVIF_OUTP_V0_DP_SST       : return nvkm_uoutp_mthd_dp_sst       (outp, argv, argc);
 	case NVIF_OUTP_V0_DP_MST_ID_GET: return nvkm_uoutp_mthd_dp_mst_id_get(outp, argv, argc);
 	case NVIF_OUTP_V0_DP_MST_ID_PUT: return nvkm_uoutp_mthd_dp_mst_id_put(outp, argv, argc);
 	case NVIF_OUTP_V0_DP_MST_VCPI  : return nvkm_uoutp_mthd_dp_mst_vcpi  (outp, argv, argc);
@@ -690,6 +697,7 @@ nvkm_uoutp_new(struct nvkm_disp *disp, u8 id, const struct nvif_outp_impl **pimp
 		uoutp->impl.dp.rates = nvkm_uoutp_dp_rates;
 		uoutp->impl.dp.train = nvkm_uoutp_dp_train;
 		uoutp->impl.dp.drive = nvkm_uoutp_dp_drive;
+		uoutp->impl.dp.sst = nvkm_uoutp_dp_sst;
 		break;
 	default:
 		WARN_ON(1);
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 123/156] drm/nouveau/nvif: rework outp "dp mst id get"/"dp mst id put" apis
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (121 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 122/156] drm/nouveau/nvif: rework outp "dp sst" api Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 124/156] drm/nouveau/nvif: rework outp "dp mst vcpi" api Ben Skeggs
                   ` (34 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interfaces

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  2 +
 drivers/gpu/drm/nouveau/include/nvif/if0012.h | 18 ---------
 drivers/gpu/drm/nouveau/nvif/outp.c           | 19 +++-------
 .../gpu/drm/nouveau/nvkm/engine/disp/uoutp.c  | 38 +++++++++++--------
 4 files changed, 29 insertions(+), 48 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index dc103d2a20a9..e2123ba48fc7 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -341,6 +341,8 @@ struct nvif_outp_impl {
 		int (*drive)(struct nvif_outp_priv *, u8 lanes, u8 pe[4], u8 vs[4]);
 		int (*sst)(struct nvif_outp_priv *, u8 head,
 			   u32 watermark, u32 hblanksym, u32 vblanksym);
+		int (*mst_id_get)(struct nvif_outp_priv *, u32 *id);
+		int (*mst_id_put)(struct nvif_outp_priv *, u32 id);
 	} dp;
 };
 
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0012.h b/drivers/gpu/drm/nouveau/include/nvif/if0012.h
index 92c4988101eb..3c74cd17a3a7 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/if0012.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/if0012.h
@@ -2,26 +2,8 @@
 #ifndef __NVIF_IF0012_H__
 #define __NVIF_IF0012_H__
 
-#define NVIF_OUTP_V0_DP_MST_ID_GET 0x76
-#define NVIF_OUTP_V0_DP_MST_ID_PUT 0x77
 #define NVIF_OUTP_V0_DP_MST_VCPI   0x78
 
-union nvif_outp_dp_mst_id_put_args {
-	struct nvif_outp_dp_mst_id_put_v0 {
-		__u8  version;
-		__u8  pad01[3];
-		__u32 id;
-	} v0;
-};
-
-union nvif_outp_dp_mst_id_get_args {
-	struct nvif_outp_dp_mst_id_get_v0 {
-		__u8  version;
-		__u8  pad01[3];
-		__u32 id;
-	} v0;
-};
-
 union nvif_outp_dp_mst_vcpi_args {
 	struct nvif_outp_dp_mst_vcpi_v0 {
 		__u8  version;
diff --git a/drivers/gpu/drm/nouveau/nvif/outp.c b/drivers/gpu/drm/nouveau/nvif/outp.c
index f56485c2ad2c..cca1c28671f4 100644
--- a/drivers/gpu/drm/nouveau/nvif/outp.c
+++ b/drivers/gpu/drm/nouveau/nvif/outp.c
@@ -49,30 +49,21 @@ nvif_outp_dp_mst_vcpi(struct nvif_outp *outp, int head,
 int
 nvif_outp_dp_mst_id_put(struct nvif_outp *outp, u32 id)
 {
-	struct nvif_outp_dp_mst_id_get_v0 args;
 	int ret;
 
-	args.version = 0;
-	args.id = id;
-	ret = nvif_object_mthd(&outp->object, NVIF_OUTP_V0_DP_MST_ID_PUT, &args, sizeof(args));
-	NVIF_ERRON(ret, &outp->object, "[DP_MST_ID_PUT id:%08x]", args.id);
+	ret = outp->impl->dp.mst_id_put(outp->priv, id);
+	NVIF_ERRON(ret, &outp->object, "[DP_MST_ID_PUT id:%08x]", id);
 	return ret;
 }
 
 int
 nvif_outp_dp_mst_id_get(struct nvif_outp *outp, u32 *id)
 {
-	struct nvif_outp_dp_mst_id_get_v0 args;
 	int ret;
 
-	args.version = 0;
-	ret = nvif_object_mthd(&outp->object, NVIF_OUTP_V0_DP_MST_ID_GET, &args, sizeof(args));
-	NVIF_ERRON(ret, &outp->object, "[DP_MST_ID_GET] id:%08x", args.id);
-	if (ret)
-		return ret;
-
-	*id = args.id;
-	return 0;
+	ret = outp->impl->dp.mst_id_get(outp->priv, id);
+	NVIF_ERRON(ret, &outp->object, "[DP_MST_ID_GET] id:%08x", *id);
+	return ret;
 }
 
 int
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
index cfa386c1bbeb..eead485fe0e2 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
@@ -77,29 +77,33 @@ nvkm_uoutp_mthd_dp_mst_vcpi(struct nvkm_outp *outp, void *argv, u32 argc)
 }
 
 static int
-nvkm_uoutp_mthd_dp_mst_id_put(struct nvkm_outp *outp, void *argv, u32 argc)
+nvkm_uoutp_dp_mst_id_put(struct nvif_outp_priv *uoutp, u32 id)
 {
-	union nvif_outp_dp_mst_id_put_args *args = argv;
+	struct nvkm_outp *outp;
+	int ret;
 
-	if (argc != sizeof(args->v0) || args->v0.version != 0)
-	        return -ENOSYS;
-	if (!outp->func->dp.mst_id_put)
-	        return -EINVAL;
+	ret = nvkm_uoutp_lock_acquired(uoutp);
+	if (ret)
+		return ret;
 
-	return outp->func->dp.mst_id_put(outp, args->v0.id);
+	ret = outp->func->dp.mst_id_put(outp, id);
+	nvkm_uoutp_unlock(uoutp);
+	return ret;
 }
 
 static int
-nvkm_uoutp_mthd_dp_mst_id_get(struct nvkm_outp *outp, void *argv, u32 argc)
+nvkm_uoutp_dp_mst_id_get(struct nvif_outp_priv *uoutp, u32 *id)
 {
-	union nvif_outp_dp_mst_id_get_args *args = argv;
+	struct nvkm_outp *outp;
+	int ret;
 
-	if (argc != sizeof(args->v0) || args->v0.version != 0)
-	        return -ENOSYS;
-	if (!outp->func->dp.mst_id_get)
-	        return -EINVAL;
+	ret = nvkm_uoutp_lock_acquired(uoutp);
+	if (ret)
+		return ret;
 
-	return outp->func->dp.mst_id_get(outp, &args->v0.id);
+	ret = outp->func->dp.mst_id_get(outp, id);
+	nvkm_uoutp_unlock(uoutp);
+	return ret;
 }
 
 static int
@@ -558,8 +562,6 @@ static int
 nvkm_uoutp_mthd_acquired(struct nvkm_outp *outp, u32 mthd, void *argv, u32 argc)
 {
 	switch (mthd) {
-	case NVIF_OUTP_V0_DP_MST_ID_GET: return nvkm_uoutp_mthd_dp_mst_id_get(outp, argv, argc);
-	case NVIF_OUTP_V0_DP_MST_ID_PUT: return nvkm_uoutp_mthd_dp_mst_id_put(outp, argv, argc);
 	case NVIF_OUTP_V0_DP_MST_VCPI  : return nvkm_uoutp_mthd_dp_mst_vcpi  (outp, argv, argc);
 	default:
 		break;
@@ -698,6 +700,10 @@ nvkm_uoutp_new(struct nvkm_disp *disp, u8 id, const struct nvif_outp_impl **pimp
 		uoutp->impl.dp.train = nvkm_uoutp_dp_train;
 		uoutp->impl.dp.drive = nvkm_uoutp_dp_drive;
 		uoutp->impl.dp.sst = nvkm_uoutp_dp_sst;
+		if (outp->func->dp.mst_id_get) {
+			uoutp->impl.dp.mst_id_get = nvkm_uoutp_dp_mst_id_get;
+			uoutp->impl.dp.mst_id_put = nvkm_uoutp_dp_mst_id_put;
+		}
 		break;
 	default:
 		WARN_ON(1);
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 124/156] drm/nouveau/nvif: rework outp "dp mst vcpi" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (122 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 123/156] drm/nouveau/nvif: rework outp "dp mst id get"/"dp mst id put" apis Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 125/156] drm/nouveau/nvif: remove outp from object rb Ben Skeggs
                   ` (33 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interface

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/dispnv50/disp.c       |  1 -
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  2 +
 drivers/gpu/drm/nouveau/include/nvif/if0012.h | 17 ------
 drivers/gpu/drm/nouveau/include/nvif/outp.h   |  1 -
 drivers/gpu/drm/nouveau/nvif/outp.c           | 12 +----
 .../gpu/drm/nouveau/nvkm/engine/disp/uoutp.c  | 54 +++++--------------
 6 files changed, 17 insertions(+), 70 deletions(-)
 delete mode 100644 drivers/gpu/drm/nouveau/include/nvif/if0012.h

diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c b/drivers/gpu/drm/nouveau/dispnv50/disp.c
index 0bac0e813184..5e12de0aabb6 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/disp.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c
@@ -50,7 +50,6 @@
 #include <nvif/class.h>
 #include <nvif/cl0002.h>
 #include <nvif/event.h>
-#include <nvif/if0012.h>
 #include <nvif/if0014.h>
 #include <nvif/timer.h>
 
diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index e2123ba48fc7..f7c7a98089b3 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -343,6 +343,8 @@ struct nvif_outp_impl {
 			   u32 watermark, u32 hblanksym, u32 vblanksym);
 		int (*mst_id_get)(struct nvif_outp_priv *, u32 *id);
 		int (*mst_id_put)(struct nvif_outp_priv *, u32 id);
+		int (*mst_vcpi)(struct nvif_outp_priv *, u8 head,
+				u8 start_slot, u8 num_slots, u16 pbn, u16 aligned_pbn);
 	} dp;
 };
 
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0012.h b/drivers/gpu/drm/nouveau/include/nvif/if0012.h
deleted file mode 100644
index 3c74cd17a3a7..000000000000
--- a/drivers/gpu/drm/nouveau/include/nvif/if0012.h
+++ /dev/null
@@ -1,17 +0,0 @@
-/* SPDX-License-Identifier: MIT */
-#ifndef __NVIF_IF0012_H__
-#define __NVIF_IF0012_H__
-
-#define NVIF_OUTP_V0_DP_MST_VCPI   0x78
-
-union nvif_outp_dp_mst_vcpi_args {
-	struct nvif_outp_dp_mst_vcpi_v0 {
-		__u8  version;
-		__u8  head;
-		__u8  start_slot;
-		__u8  num_slots;
-		__u16 pbn;
-		__u16 aligned_pbn;
-	} v0;
-};
-#endif
diff --git a/drivers/gpu/drm/nouveau/include/nvif/outp.h b/drivers/gpu/drm/nouveau/include/nvif/outp.h
index 7f7620ec1487..ea4d2d4f11f8 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/outp.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/outp.h
@@ -3,7 +3,6 @@
 #define __NVIF_OUTP_H__
 #include <nvif/object.h>
 #include <nvif/driverif.h>
-#include <nvif/if0012.h>
 #include <drm/display/drm_dp.h>
 struct nvif_disp;
 
diff --git a/drivers/gpu/drm/nouveau/nvif/outp.c b/drivers/gpu/drm/nouveau/nvif/outp.c
index cca1c28671f4..f04154e7a7b4 100644
--- a/drivers/gpu/drm/nouveau/nvif/outp.c
+++ b/drivers/gpu/drm/nouveau/nvif/outp.c
@@ -29,20 +29,12 @@ int
 nvif_outp_dp_mst_vcpi(struct nvif_outp *outp, int head,
 		      u8 start_slot, u8 num_slots, u16 pbn, u16 aligned_pbn)
 {
-	struct nvif_outp_dp_mst_vcpi_v0 args;
 	int ret;
 
-	args.version = 0;
-	args.head = head;
-	args.start_slot = start_slot;
-	args.num_slots = num_slots;
-	args.pbn = pbn;
-	args.aligned_pbn = aligned_pbn;
-
-	ret = nvif_object_mthd(&outp->object, NVIF_OUTP_V0_DP_MST_VCPI, &args, sizeof(args));
+	ret = outp->impl->dp.mst_vcpi(outp->priv, head, start_slot, num_slots, pbn, aligned_pbn);
 	NVIF_ERRON(ret, &outp->object,
 		   "[DP_MST_VCPI head:%d start_slot:%02x num_slots:%02x pbn:%04x aligned_pbn:%04x]",
-		   args.head, args.start_slot, args.num_slots, args.pbn, args.aligned_pbn);
+		   head, start_slot, num_slots, pbn, aligned_pbn);
 	return ret;
 }
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
index eead485fe0e2..9d415a71c744 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
@@ -26,8 +26,6 @@
 
 #include <subdev/i2c.h>
 
-#include <nvif/if0012.h>
-
 struct nvif_outp_priv {
 	struct nvkm_object object;
 	struct nvkm_outp *outp;
@@ -61,18 +59,22 @@ nvkm_uoutp_lock_acquired(struct nvif_outp_priv *uoutp)
 }
 
 static int
-nvkm_uoutp_mthd_dp_mst_vcpi(struct nvkm_outp *outp, void *argv, u32 argc)
+nvkm_uoutp_dp_mst_vcpi(struct nvif_outp_priv *uoutp, u8 head,
+		       u8 start_slot, u8 num_slots, u16 pbn, u16 aligned_pbn)
 {
-	struct nvkm_ior *ior = outp->ior;
-	union nvif_outp_dp_mst_vcpi_args *args = argv;
+	struct nvkm_ior *ior;
+	int ret;
 
-	if (argc != sizeof(args->v0) || args->v0.version != 0)
-		return -ENOSYS;
-	if (!ior->func->dp || !ior->func->dp->vcpi || !nvkm_head_find(outp->disp, args->v0.head))
+	if (!nvkm_head_find(uoutp->outp->disp, head))
 		return -EINVAL;
 
-	ior->func->dp->vcpi(ior, args->v0.head, args->v0.start_slot, args->v0.num_slots,
-				 args->v0.pbn, args->v0.aligned_pbn);
+	ret = nvkm_uoutp_lock_acquired(uoutp);
+	if (ret)
+		return ret;
+
+	ior = uoutp->outp->ior;
+	ior->func->dp->vcpi(ior, head, start_slot, num_slots, pbn, aligned_pbn);
+	nvkm_uoutp_unlock(uoutp);
 	return 0;
 }
 
@@ -558,36 +560,6 @@ nvkm_uoutp_detect(struct nvif_outp_priv *uoutp, enum nvif_outp_detect_status *st
 	return 0;
 }
 
-static int
-nvkm_uoutp_mthd_acquired(struct nvkm_outp *outp, u32 mthd, void *argv, u32 argc)
-{
-	switch (mthd) {
-	case NVIF_OUTP_V0_DP_MST_VCPI  : return nvkm_uoutp_mthd_dp_mst_vcpi  (outp, argv, argc);
-	default:
-		break;
-	}
-
-	return -EINVAL;
-}
-
-static int
-nvkm_uoutp_mthd(struct nvkm_object *object, u32 mthd, void *argv, u32 argc)
-{
-	struct nvkm_outp *outp = container_of(object, struct nvif_outp_priv, object)->outp;
-	struct nvkm_disp *disp = outp->disp;
-	int ret;
-
-	mutex_lock(&disp->super.mutex);
-
-	if (outp->ior)
-		ret = nvkm_uoutp_mthd_acquired(outp, mthd, argv, argc);
-	else
-		ret = -EIO;
-
-	mutex_unlock(&disp->super.mutex);
-	return ret;
-}
-
 static void
 nvkm_uoutp_del(struct nvif_outp_priv *uoutp)
 {
@@ -619,7 +591,6 @@ nvkm_uoutp_dtor(struct nvkm_object *object)
 static const struct nvkm_object_func
 nvkm_uoutp = {
 	.dtor = nvkm_uoutp_dtor,
-	.mthd = nvkm_uoutp_mthd,
 };
 
 int
@@ -703,6 +674,7 @@ nvkm_uoutp_new(struct nvkm_disp *disp, u8 id, const struct nvif_outp_impl **pimp
 		if (outp->func->dp.mst_id_get) {
 			uoutp->impl.dp.mst_id_get = nvkm_uoutp_dp_mst_id_get;
 			uoutp->impl.dp.mst_id_put = nvkm_uoutp_dp_mst_id_put;
+			uoutp->impl.dp.mst_vcpi = nvkm_uoutp_dp_mst_vcpi;
 		}
 		break;
 	default:
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 125/156] drm/nouveau/nvif: remove outp from object rb
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (123 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 124/156] drm/nouveau/nvif: rework outp "dp mst vcpi" api Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 126/156] drm/nouveau/nvif: rework disp "new head" api Ben Skeggs
                   ` (32 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- no more users

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/include/nvif/driverif.h  | 2 +-
 drivers/gpu/drm/nouveau/nvif/outp.c              | 3 +--
 drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c | 6 +++---
 3 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index f7c7a98089b3..57ad5022a534 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -366,7 +366,7 @@ struct nvif_disp_impl {
 	struct {
 		u32 mask;
 		int (*new)(struct nvif_disp_priv *, u8 id,
-			   const struct nvif_outp_impl **, struct nvif_outp_priv **, u64 handle);
+			   const struct nvif_outp_impl **, struct nvif_outp_priv **);
 	} outp;
 
 	struct {
diff --git a/drivers/gpu/drm/nouveau/nvif/outp.c b/drivers/gpu/drm/nouveau/nvif/outp.c
index f04154e7a7b4..65c4b8539b55 100644
--- a/drivers/gpu/drm/nouveau/nvif/outp.c
+++ b/drivers/gpu/drm/nouveau/nvif/outp.c
@@ -381,8 +381,7 @@ nvif_outp_ctor(struct nvif_disp *disp, const char *name, int id, struct nvif_out
 {
 	int ret;
 
-	ret = disp->impl->outp.new(disp->priv, id, &outp->impl, &outp->priv,
-				   nvif_handle(&outp->object));
+	ret = disp->impl->outp.new(disp->priv, id, &outp->impl, &outp->priv);
 	NVIF_ERRON(ret, &disp->object, "[NEW outp id:%d]", id);
 	if (ret)
 		return ret;
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c
index 678121ab469f..0be6b28c79b8 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c
@@ -86,8 +86,7 @@ nvkm_udisp_sclass(struct nvkm_object *object, int index, struct nvkm_oclass *scl
 
 static int
 nvkm_udisp_outp_new(struct nvif_disp_priv *udisp, u8 id,
-		    const struct nvif_outp_impl **pimpl, struct nvif_outp_priv **ppriv,
-		    u64 handle)
+		    const struct nvif_outp_impl **pimpl, struct nvif_outp_priv **ppriv)
 {
 	struct nvkm_object *object;
 	int ret;
@@ -96,7 +95,8 @@ nvkm_udisp_outp_new(struct nvif_disp_priv *udisp, u8 id,
 	if (ret)
 		return ret;
 
-	return nvkm_object_link_rb(udisp->object.client, &udisp->object, handle, object);
+	nvkm_object_link(&udisp->object, object);
+	return 0;
 }
 
 static int
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 126/156] drm/nouveau/nvif: rework disp "new head" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (124 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 125/156] drm/nouveau/nvif: remove outp from object rb Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 127/156] drm/nouveau/nvif: rework head "scanoutpos" api Ben Skeggs
                   ` (31 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interface

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  8 ++++++
 drivers/gpu/drm/nouveau/include/nvif/head.h   |  2 ++
 drivers/gpu/drm/nouveau/include/nvif/if0013.h |  8 ------
 drivers/gpu/drm/nouveau/nvif/head.c           | 21 ++++++++------
 .../gpu/drm/nouveau/nvkm/engine/disp/priv.h   |  2 --
 .../gpu/drm/nouveau/nvkm/engine/disp/udisp.c  | 24 +++++++++++-----
 .../gpu/drm/nouveau/nvkm/engine/disp/uhead.c  | 28 +++++++++++++------
 .../gpu/drm/nouveau/nvkm/engine/disp/uhead.h  |  3 ++
 8 files changed, 63 insertions(+), 33 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 57ad5022a534..83acedd108bb 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -16,6 +16,7 @@ struct nvif_disp_priv;
 struct nvif_disp_caps_priv;
 struct nvif_conn_priv;
 struct nvif_outp_priv;
+struct nvif_head_priv;
 
 struct nvif_driver {
 	const char *name;
@@ -348,6 +349,10 @@ struct nvif_outp_impl {
 	} dp;
 };
 
+struct nvif_head_impl {
+	void (*del)(struct nvif_head_priv *);
+};
+
 struct nvif_disp_impl {
 	void (*del)(struct nvif_disp_priv *);
 
@@ -371,6 +376,9 @@ struct nvif_disp_impl {
 
 	struct {
 		u32 mask;
+		int (*new)(struct nvif_disp_priv *, u8 id,
+			   const struct nvif_head_impl **, struct nvif_head_priv **,
+			   u64 handle);
 	} head;
 
 	struct {
diff --git a/drivers/gpu/drm/nouveau/include/nvif/head.h b/drivers/gpu/drm/nouveau/include/nvif/head.h
index 3ec36999e956..fb25cd60987a 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/head.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/head.h
@@ -6,6 +6,8 @@
 struct nvif_disp;
 
 struct nvif_head {
+	const struct nvif_head_impl *impl;
+	struct nvif_head_priv *priv;
 	struct nvif_object object;
 };
 
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0013.h b/drivers/gpu/drm/nouveau/include/nvif/if0013.h
index 6756c7467ae4..751f75bf7e59 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/if0013.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/if0013.h
@@ -2,14 +2,6 @@
 #ifndef __NVIF_IF0013_H__
 #define __NVIF_IF0013_H__
 
-union nvif_head_args {
-	struct nvif_head_v0 {
-		__u8 version;
-		__u8 id;
-		__u8 pad02[6];
-	} v0;
-};
-
 union nvif_head_event_args {
 	struct nvif_head_event_vn {
 	} vn;
diff --git a/drivers/gpu/drm/nouveau/nvif/head.c b/drivers/gpu/drm/nouveau/nvif/head.c
index f00e01d232db..777f12f3236f 100644
--- a/drivers/gpu/drm/nouveau/nvif/head.c
+++ b/drivers/gpu/drm/nouveau/nvif/head.c
@@ -21,6 +21,7 @@
  */
 #include <nvif/head.h>
 #include <nvif/disp.h>
+#include <nvif/driverif.h>
 #include <nvif/printf.h>
 
 #include <nvif/class.h>
@@ -39,20 +40,24 @@ nvif_head_vblank_event_ctor(struct nvif_head *head, const char *name, nvif_event
 void
 nvif_head_dtor(struct nvif_head *head)
 {
-	nvif_object_dtor(&head->object);
+	if (!head->impl)
+		return;
+
+	head->impl->del(head->priv);
+	head->impl = NULL;
 }
 
 int
 nvif_head_ctor(struct nvif_disp *disp, const char *name, int id, struct nvif_head *head)
 {
-	struct nvif_head_v0 args;
 	int ret;
 
-	args.version = 0;
-	args.id = id;
+	ret = disp->impl->head.new(disp->priv, id, &head->impl, &head->priv,
+				   nvif_handle(&head->object));
+	NVIF_ERRON(ret, &disp->object, "[NEW head id:%d]", id);
+	if (ret)
+		return ret;
 
-	ret = nvif_object_ctor(&disp->object, name ? name : "nvifHead", id, NVIF_CLASS_HEAD,
-			       &args, sizeof(args), &head->object);
-	NVIF_ERRON(ret, &disp->object, "[NEW head id:%d]", args.id);
-	return ret;
+	nvif_object_ctor(&disp->object, name ?: "nvifHead", id, 0, &head->object);
+	return 0;
 }
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/priv.h b/drivers/gpu/drm/nouveau/nvkm/engine/disp/priv.h
index 0163660f215d..d16b47b2a9d6 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/priv.h
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/priv.h
@@ -88,6 +88,4 @@ void nv50_disp_chan_uevent_send(struct nvkm_disp *, int);
 
 extern const struct nvkm_event_func gf119_disp_chan_uevent;
 extern const struct nvkm_event_func gv100_disp_chan_uevent;
-
-int nvkm_uhead_new(const struct nvkm_oclass *, void *, u32, struct nvkm_object **);
 #endif
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c
index 0be6b28c79b8..6a65b3bffc19 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c
@@ -23,7 +23,7 @@
 #include "ucaps.h"
 #include "chan.h"
 #include "uconn.h"
-#include "head.h"
+#include "uhead.h"
 #include "uoutp.h"
 
 #include <nvif/class.h>
@@ -33,12 +33,6 @@ nvkm_udisp_sclass(struct nvkm_object *object, int index, struct nvkm_oclass *scl
 {
 	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_HEAD };
-		sclass->ctor = nvkm_uhead_new;
-		return 0;
-	}
-
 	if (disp->func->user.core.oclass && index-- == 0) {
 		sclass->base = (struct nvkm_sclass) { 0, 0, disp->func->user.core.oclass };
 		sclass->ctor = nvkm_disp_core_new;
@@ -84,6 +78,21 @@ nvkm_udisp_sclass(struct nvkm_object *object, int index, struct nvkm_oclass *scl
 	return -EINVAL;
 }
 
+static int
+nvkm_udisp_head_new(struct nvif_disp_priv *udisp, u8 id,
+		    const struct nvif_head_impl **pimpl, struct nvif_head_priv **ppriv,
+		    u64 handle)
+{
+	struct nvkm_object *object;
+	int ret;
+
+	ret = nvkm_uhead_new(udisp->disp, id, pimpl, ppriv, &object);
+	if (ret)
+		return ret;
+
+	return nvkm_object_link_rb(udisp->object.client, &udisp->object, handle, object);
+}
+
 static int
 nvkm_udisp_outp_new(struct nvif_disp_priv *udisp, u8 id,
 		    const struct nvif_outp_impl **pimpl, struct nvif_outp_priv **ppriv)
@@ -143,6 +152,7 @@ nvkm_udisp_impl = {
 	.del = nvkm_udisp_del,
 	.conn.new = nvkm_udisp_conn_new,
 	.outp.new = nvkm_udisp_outp_new,
+	.head.new = nvkm_udisp_head_new,
 };
 
 static void *
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uhead.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uhead.c
index 3be82e01a59a..3456e988f9b3 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uhead.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uhead.c
@@ -87,6 +87,19 @@ nvkm_uhead_mthd(struct nvkm_object *object, u32 mthd, void *argv, u32 argc)
 	}
 }
 
+static void
+nvkm_uhead_del(struct nvif_head_priv *uhead)
+{
+	struct nvkm_object *object = &uhead->object;
+
+	nvkm_object_del(&object);
+}
+
+static const struct nvif_head_impl
+nvkm_uhead_impl = {
+	.del = nvkm_uhead_del,
+};
+
 static void *
 nvkm_uhead_dtor(struct nvkm_object *object)
 {
@@ -106,18 +119,14 @@ 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)
+nvkm_uhead_new(struct nvkm_disp *disp, u8 id, const struct nvif_head_impl **pimpl,
+	       struct nvif_head_priv **ppriv, struct nvkm_object **pobject)
 {
-	struct nvkm_disp *disp = container_of(oclass->parent, struct nvif_disp_priv, object)->disp;
 	struct nvkm_head *head;
-	union nvif_head_args *args = argv;
 	struct nvif_head_priv *uhead;
 
-	if (argc != sizeof(args->v0) || args->v0.version != 0)
-		return -ENOSYS;
-	if (!(head = nvkm_head_find(disp, args->v0.id)))
+	if (!(head = nvkm_head_find(disp, id)))
 		return -EINVAL;
 
 	uhead = kzalloc(sizeof(*uhead), GFP_KERNEL);
@@ -133,8 +142,11 @@ nvkm_uhead_new(const struct nvkm_oclass *oclass, void *argv, u32 argc, struct nv
 	head->user = true;
 	spin_unlock(&disp->user.lock);
 
-	nvkm_object_ctor(&nvkm_uhead, oclass, &uhead->object);
+	nvkm_object_ctor(&nvkm_uhead, &(struct nvkm_oclass) {}, &uhead->object);
 	uhead->head = head;
+
+	*pimpl = &nvkm_uhead_impl;
+	*ppriv = uhead;
 	*pobject = &uhead->object;
 	return 0;
 }
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uhead.h b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uhead.h
index f19c9ae33707..1291f8c3874e 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uhead.h
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uhead.h
@@ -2,5 +2,8 @@
 #ifndef __NVKM_UHEAD_H__
 #define __NVKM_UHEAD_H__
 #include "head.h"
+#include <nvif/driverif.h>
 
+int nvkm_uhead_new(struct nvkm_disp *, u8 id, const struct nvif_head_impl **,
+		   struct nvif_head_priv **, struct nvkm_object **);
 #endif
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 127/156] drm/nouveau/nvif: rework head "scanoutpos" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (125 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 126/156] drm/nouveau/nvif: rework disp "new head" api Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 128/156] drm/nouveau/nvif: rework head "new event" api Ben Skeggs
                   ` (30 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interface

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  4 ++
 drivers/gpu/drm/nouveau/include/nvif/if0013.h | 18 --------
 drivers/gpu/drm/nouveau/nouveau_display.c     | 20 +++++----
 .../gpu/drm/nouveau/nvkm/engine/disp/uhead.c  | 43 +++++++------------
 4 files changed, 30 insertions(+), 55 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 83acedd108bb..927d0d75dd29 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -351,6 +351,10 @@ struct nvif_outp_impl {
 
 struct nvif_head_impl {
 	void (*del)(struct nvif_head_priv *);
+
+	int (*scanoutpos)(struct nvif_head_priv *, s64 time[2],
+			  u16 *vblanks, u16 *vblanke, u16 *vtotal, u16 *vline,
+			  u16 *hblanks, u16 *hblanke, u16 *htotal, u16 *hline);
 };
 
 struct nvif_disp_impl {
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0013.h b/drivers/gpu/drm/nouveau/include/nvif/if0013.h
index 751f75bf7e59..f2b39f86a9cc 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/if0013.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/if0013.h
@@ -6,22 +6,4 @@ union nvif_head_event_args {
 	struct nvif_head_event_vn {
 	} vn;
 };
-
-#define NVIF_HEAD_V0_SCANOUTPOS 0x00
-
-union nvif_head_scanoutpos_args {
-	struct nvif_head_scanoutpos_v0 {
-		__u8  version;
-		__u8  pad01[7];
-		__s64 time[2];
-		__u16 vblanks;
-		__u16 vblanke;
-		__u16 vtotal;
-		__u16 vline;
-		__u16 hblanks;
-		__u16 hblanke;
-		__u16 htotal;
-		__u16 hline;
-	} v0;
-};
 #endif
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c
index 27b69032fd9e..0d2dae7a94d0 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -85,18 +85,20 @@ nouveau_display_scanoutpos_head(struct drm_crtc *crtc, int *vpos, int *hpos,
 {
 	struct drm_vblank_crtc *vblank = &crtc->dev->vblank[drm_crtc_index(crtc)];
 	struct nvif_head *head = &nouveau_crtc(crtc)->head;
-	struct nvif_head_scanoutpos_v0 args;
+	u16 vblanks, vblanke, vtotal, vline;
+	u16 hblanks, hblanke, htotal, hline;
+	s64 time[2];
 	int retry = 20;
 	bool ret = false;
 
-	args.version = 0;
-
 	do {
-		ret = nvif_mthd(&head->object, NVIF_HEAD_V0_SCANOUTPOS, &args, sizeof(args));
+		ret = head->impl->scanoutpos(head->priv, time,
+					     &vblanks, &vblanke, &vtotal, &vline,
+					     &hblanks, &hblanke, &htotal, &hline);
 		if (ret != 0)
 			return false;
 
-		if (args.vline) {
+		if (vline) {
 			ret = true;
 			break;
 		}
@@ -104,10 +106,10 @@ nouveau_display_scanoutpos_head(struct drm_crtc *crtc, int *vpos, int *hpos,
 		if (retry) ndelay(vblank->linedur_ns);
 	} while (retry--);
 
-	*hpos = args.hline;
-	*vpos = calc(args.vblanks, args.vblanke, args.vtotal, args.vline);
-	if (stime) *stime = ns_to_ktime(args.time[0]);
-	if (etime) *etime = ns_to_ktime(args.time[1]);
+	*hpos = hline;
+	*vpos = calc(vblanks, vblanke, vtotal, vline);
+	if (stime) *stime = ns_to_ktime(time[0]);
+	if (etime) *etime = ns_to_ktime(time[1]);
 
 	return ret;
 }
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uhead.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uhead.c
index 3456e988f9b3..ebf72333ae99 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uhead.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uhead.c
@@ -47,46 +47,33 @@ nvkm_uhead_uevent(struct nvkm_object *object, void *argv, u32 argc, struct nvkm_
 }
 
 static int
-nvkm_uhead_mthd_scanoutpos(struct nvkm_head *head, void *argv, u32 argc)
+nvkm_uhead_scanoutpos(struct nvif_head_priv *uhead, s64 time[2],
+		      u16 *vblanks, u16 *vblanke, u16 *vtotal, u16 *vline,
+		      u16 *hblanks, u16 *hblanke, u16 *htotal, u16 *hline)
 {
-	union nvif_head_scanoutpos_args *args = argv;
-
-	if (argc != sizeof(args->v0) || args->v0.version != 0)
-		return -ENOSYS;
+	struct nvkm_head *head = uhead->head;
 
 	head->func->state(head, &head->arm);
-	args->v0.vtotal  = head->arm.vtotal;
-	args->v0.vblanks = head->arm.vblanks;
-	args->v0.vblanke = head->arm.vblanke;
-	args->v0.htotal  = head->arm.htotal;
-	args->v0.hblanks = head->arm.hblanks;
-	args->v0.hblanke = head->arm.hblanke;
+	*vtotal  = head->arm.vtotal;
+	*vblanks = head->arm.vblanks;
+	*vblanke = head->arm.vblanke;
+	*htotal  = head->arm.htotal;
+	*hblanks = head->arm.hblanks;
+	*hblanke = head->arm.hblanke;
 
 	/* We don't support reading htotal/vtotal on pre-NV50 VGA,
 	 * so we have to give up and trigger the timestamping
 	 * fallback in the drm core.
 	 */
-	if (!args->v0.vtotal || !args->v0.htotal)
+	if (!*vtotal || !*htotal)
 		return -ENOTSUPP;
 
-	args->v0.time[0] = ktime_to_ns(ktime_get());
-	head->func->rgpos(head, &args->v0.hline, &args->v0.vline);
-	args->v0.time[1] = ktime_to_ns(ktime_get());
+	time[0] = ktime_to_ns(ktime_get());
+	head->func->rgpos(head, hline, vline);
+	time[1] = ktime_to_ns(ktime_get());
 	return 0;
 }
 
-static int
-nvkm_uhead_mthd(struct nvkm_object *object, u32 mthd, void *argv, u32 argc)
-{
-	struct nvkm_head *head = container_of(object, struct nvif_head_priv, object)->head;
-
-	switch (mthd) {
-	case NVIF_HEAD_V0_SCANOUTPOS: return nvkm_uhead_mthd_scanoutpos(head, argv, argc);
-	default:
-		return -EINVAL;
-	}
-}
-
 static void
 nvkm_uhead_del(struct nvif_head_priv *uhead)
 {
@@ -98,6 +85,7 @@ nvkm_uhead_del(struct nvif_head_priv *uhead)
 static const struct nvif_head_impl
 nvkm_uhead_impl = {
 	.del = nvkm_uhead_del,
+	.scanoutpos = nvkm_uhead_scanoutpos,
 };
 
 static void *
@@ -115,7 +103,6 @@ nvkm_uhead_dtor(struct nvkm_object *object)
 static const struct nvkm_object_func
 nvkm_uhead = {
 	.dtor = nvkm_uhead_dtor,
-	.mthd = nvkm_uhead_mthd,
 	.uevent = nvkm_uhead_uevent,
 };
 
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 128/156] drm/nouveau/nvif: rework head "new event" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (126 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 127/156] drm/nouveau/nvif: rework head "scanoutpos" api Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 129/156] drm/nouveau/nvif: remove head from object rb Ben Skeggs
                   ` (29 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interface

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  3 +++
 drivers/gpu/drm/nouveau/include/nvif/if0013.h |  9 ---------
 drivers/gpu/drm/nouveau/nouveau_display.c     |  1 -
 drivers/gpu/drm/nouveau/nvif/head.c           | 15 +++++++++------
 .../gpu/drm/nouveau/nvkm/engine/disp/uhead.c  | 19 ++++++-------------
 5 files changed, 18 insertions(+), 29 deletions(-)
 delete mode 100644 drivers/gpu/drm/nouveau/include/nvif/if0013.h

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 927d0d75dd29..7aa44e4fe729 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -355,6 +355,9 @@ struct nvif_head_impl {
 	int (*scanoutpos)(struct nvif_head_priv *, s64 time[2],
 			  u16 *vblanks, u16 *vblanke, u16 *vtotal, u16 *vline,
 			  u16 *hblanks, u16 *hblanke, u16 *htotal, u16 *hline);
+
+	int (*vblank)(struct nvif_head_priv *, u64 handle,
+		      const struct nvif_event_impl **, struct nvif_event_priv **);
 };
 
 struct nvif_disp_impl {
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0013.h b/drivers/gpu/drm/nouveau/include/nvif/if0013.h
deleted file mode 100644
index f2b39f86a9cc..000000000000
--- a/drivers/gpu/drm/nouveau/include/nvif/if0013.h
+++ /dev/null
@@ -1,9 +0,0 @@
-/* SPDX-License-Identifier: MIT */
-#ifndef __NVIF_IF0013_H__
-#define __NVIF_IF0013_H__
-
-union nvif_head_event_args {
-	struct nvif_head_event_vn {
-	} vn;
-};
-#endif
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c
index 0d2dae7a94d0..3f75c7f33429 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -42,7 +42,6 @@
 
 #include <nvif/class.h>
 #include <nvif/if0011.h>
-#include <nvif/if0013.h>
 #include <dispnv50/crc.h>
 
 int
diff --git a/drivers/gpu/drm/nouveau/nvif/head.c b/drivers/gpu/drm/nouveau/nvif/head.c
index 777f12f3236f..05f56169e6c3 100644
--- a/drivers/gpu/drm/nouveau/nvif/head.c
+++ b/drivers/gpu/drm/nouveau/nvif/head.c
@@ -24,17 +24,20 @@
 #include <nvif/driverif.h>
 #include <nvif/printf.h>
 
-#include <nvif/class.h>
-#include <nvif/if0013.h>
-
 int
 nvif_head_vblank_event_ctor(struct nvif_head *head, const char *name, nvif_event_func func,
 			    bool wait, struct nvif_event *event)
 {
-	int ret = nvif_event_ctor(&head->object, name ?: "nvifHeadVBlank", nvif_head_id(head),
-				  func, wait, NULL, 0, event);
+	int ret;
+
+	ret = head->impl->vblank(head->priv, nvif_handle(&event->object),
+				 &event->impl, &event->priv);
 	NVIF_ERRON(ret, &head->object, "[NEW EVENT:VBLANK]");
-	return ret;
+	if (ret)
+		return ret;
+
+	nvif_event_ctor(&head->object, name ?: "nvifHeadVblank", nvif_head_id(head), func, event);
+	return 0;
 }
 
 void
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uhead.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uhead.c
index ebf72333ae99..0ad97094a8c7 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uhead.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uhead.c
@@ -22,8 +22,6 @@
 #include "uhead.h"
 #include <core/event.h>
 
-#include <nvif/if0013.h>
-
 #include <nvif/event.h>
 
 struct nvif_head_priv {
@@ -32,18 +30,13 @@ struct nvif_head_priv {
 };
 
 static int
-nvkm_uhead_uevent(struct nvkm_object *object, void *argv, u32 argc, struct nvkm_uevent *uevent)
+nvkm_uhead_vblank(struct nvif_head_priv *uhead, u64 handle,
+		  const struct nvif_event_impl **pimpl, struct nvif_event_priv **ppriv)
 {
-	struct nvkm_head *head = container_of(object, struct nvif_head_priv, object)->head;
-	union nvif_head_event_args *args = argv;
-
-	if (!uevent)
-		return 0;
-	if (argc != sizeof(args->vn))
-		return -ENOSYS;
+	struct nvkm_head *head = uhead->head;
 
-	return nvkm_uevent_add(uevent, &head->disp->vblank, head->id,
-			       NVKM_DISP_HEAD_EVENT_VBLANK, NULL);
+	return nvkm_uevent_new_(&uhead->object, handle, &head->disp->vblank, false, head->id,
+				NVKM_DISP_HEAD_EVENT_VBLANK, NULL, pimpl, ppriv);
 }
 
 static int
@@ -86,6 +79,7 @@ static const struct nvif_head_impl
 nvkm_uhead_impl = {
 	.del = nvkm_uhead_del,
 	.scanoutpos = nvkm_uhead_scanoutpos,
+	.vblank = nvkm_uhead_vblank,
 };
 
 static void *
@@ -103,7 +97,6 @@ nvkm_uhead_dtor(struct nvkm_object *object)
 static const struct nvkm_object_func
 nvkm_uhead = {
 	.dtor = nvkm_uhead_dtor,
-	.uevent = nvkm_uhead_uevent,
 };
 
 int
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 129/156] drm/nouveau/nvif: remove head from object rb
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (127 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 128/156] drm/nouveau/nvif: rework head "new event" api Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 130/156] drm/nouveau/nvif: rework disp "new chan" apis Ben Skeggs
                   ` (28 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- no more users

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/include/nvif/driverif.h  | 3 +--
 drivers/gpu/drm/nouveau/nvif/head.c              | 3 +--
 drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c | 6 +++---
 3 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 7aa44e4fe729..e66d29b3db63 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -384,8 +384,7 @@ struct nvif_disp_impl {
 	struct {
 		u32 mask;
 		int (*new)(struct nvif_disp_priv *, u8 id,
-			   const struct nvif_head_impl **, struct nvif_head_priv **,
-			   u64 handle);
+			   const struct nvif_head_impl **, struct nvif_head_priv **);
 	} head;
 
 	struct {
diff --git a/drivers/gpu/drm/nouveau/nvif/head.c b/drivers/gpu/drm/nouveau/nvif/head.c
index 05f56169e6c3..0800eebb920a 100644
--- a/drivers/gpu/drm/nouveau/nvif/head.c
+++ b/drivers/gpu/drm/nouveau/nvif/head.c
@@ -55,8 +55,7 @@ nvif_head_ctor(struct nvif_disp *disp, const char *name, int id, struct nvif_hea
 {
 	int ret;
 
-	ret = disp->impl->head.new(disp->priv, id, &head->impl, &head->priv,
-				   nvif_handle(&head->object));
+	ret = disp->impl->head.new(disp->priv, id, &head->impl, &head->priv);
 	NVIF_ERRON(ret, &disp->object, "[NEW head id:%d]", id);
 	if (ret)
 		return ret;
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c
index 6a65b3bffc19..dc23fad17b81 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c
@@ -80,8 +80,7 @@ nvkm_udisp_sclass(struct nvkm_object *object, int index, struct nvkm_oclass *scl
 
 static int
 nvkm_udisp_head_new(struct nvif_disp_priv *udisp, u8 id,
-		    const struct nvif_head_impl **pimpl, struct nvif_head_priv **ppriv,
-		    u64 handle)
+		    const struct nvif_head_impl **pimpl, struct nvif_head_priv **ppriv)
 {
 	struct nvkm_object *object;
 	int ret;
@@ -90,7 +89,8 @@ nvkm_udisp_head_new(struct nvif_disp_priv *udisp, u8 id,
 	if (ret)
 		return ret;
 
-	return nvkm_object_link_rb(udisp->object.client, &udisp->object, handle, object);
+	nvkm_object_link(&udisp->object, object);
+	return 0;
 }
 
 static int
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 130/156] drm/nouveau/nvif: rework disp "new chan" apis
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (128 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 129/156] drm/nouveau/nvif: remove head from object rb Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 131/156] drm/nouveau/nvif: remove disp from object rb Ben Skeggs
                   ` (27 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interfaces

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/dispnv50/base507c.c   |  21 +-
 drivers/gpu/drm/nouveau/dispnv50/core.c       |   6 +-
 drivers/gpu/drm/nouveau/dispnv50/core.h       |   4 +-
 drivers/gpu/drm/nouveau/dispnv50/core507d.c   |  27 ++-
 drivers/gpu/drm/nouveau/dispnv50/core907d.c   |   2 +-
 drivers/gpu/drm/nouveau/dispnv50/crc.c        |   2 +-
 drivers/gpu/drm/nouveau/dispnv50/curs507a.c   |  33 +--
 drivers/gpu/drm/nouveau/dispnv50/cursc37a.c   |  12 +-
 drivers/gpu/drm/nouveau/dispnv50/disp.c       | 217 +-----------------
 drivers/gpu/drm/nouveau/dispnv50/disp.h       |  18 --
 drivers/gpu/drm/nouveau/dispnv50/oimm507b.c   |  20 +-
 drivers/gpu/drm/nouveau/dispnv50/ovly507e.c   |  21 +-
 drivers/gpu/drm/nouveau/dispnv50/wimmc37b.c   |  20 +-
 drivers/gpu/drm/nouveau/dispnv50/wndw.c       |  14 +-
 drivers/gpu/drm/nouveau/dispnv50/wndw.h       |  10 +-
 drivers/gpu/drm/nouveau/dispnv50/wndwc37e.c   |  21 +-
 .../gpu/drm/nouveau/include/nvif/dispchan.h   |  21 ++
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  15 ++
 drivers/gpu/drm/nouveau/include/nvif/if0014.h |  13 --
 drivers/gpu/drm/nouveau/include/nvif/push.h   |   5 +-
 drivers/gpu/drm/nouveau/nouveau_chan.c        |   3 +-
 drivers/gpu/drm/nouveau/nvif/Kbuild           |   1 +
 drivers/gpu/drm/nouveau/nvif/dispchan.c       | 205 +++++++++++++++++
 .../gpu/drm/nouveau/nvkm/engine/disp/chan.c   | 132 ++++-------
 .../gpu/drm/nouveau/nvkm/engine/disp/chan.h   |   4 -
 .../gpu/drm/nouveau/nvkm/engine/disp/uchan.h  |  10 +
 .../gpu/drm/nouveau/nvkm/engine/disp/udisp.c  | 139 +++++++----
 27 files changed, 528 insertions(+), 468 deletions(-)
 create mode 100644 drivers/gpu/drm/nouveau/include/nvif/dispchan.h
 delete mode 100644 drivers/gpu/drm/nouveau/include/nvif/if0014.h
 create mode 100644 drivers/gpu/drm/nouveau/nvif/dispchan.c
 create mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/disp/uchan.h

diff --git a/drivers/gpu/drm/nouveau/dispnv50/base507c.c b/drivers/gpu/drm/nouveau/dispnv50/base507c.c
index 0b6fb663d78e..875c013c39b0 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/base507c.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/base507c.c
@@ -21,7 +21,6 @@
  */
 #include "base.h"
 
-#include <nvif/if0014.h>
 #include <nvif/push507c.h>
 #include <nvif/timer.h>
 
@@ -304,10 +303,7 @@ base507c_new_(const struct nv50_wndw_func *func, const u32 *format,
 	      struct nouveau_drm *drm, int head, s32 oclass, u32 interlock_data,
 	      struct nv50_wndw **pwndw)
 {
-	struct nvif_disp_chan_v0 args = {
-		.id = head,
-	};
-	struct nv50_disp *disp50 = nv50_disp(drm->dev);
+	struct nvif_disp *disp = nv50_disp(drm->dev)->disp;
 	struct nv50_wndw *wndw;
 	int ret;
 
@@ -317,9 +313,18 @@ base507c_new_(const struct nv50_wndw_func *func, const u32 *format,
 	if (*pwndw = wndw, ret)
 		return ret;
 
-	ret = nv50_dmac_create(drm,
-			       &oclass, head, &args, sizeof(args),
-			       disp50->sync->offset, &wndw->wndw);
+	ret = nvif_dispchan_ctor(disp, "kmsChanBase", head, oclass, &drm->mmu, &wndw->wndw);
+	if (ret)
+		goto done;
+
+	ret = disp->impl->chan.base.new(disp->priv, head, wndw->wndw.push.mem.priv,
+					&wndw->wndw.impl, &wndw->wndw.priv,
+					nvif_handle(&wndw->wndw.object));
+	if (ret)
+		goto done;
+
+	ret = nvif_dispchan_oneinit(&wndw->wndw);
+done:
 	if (ret) {
 		NV_ERROR(drm, "base%04x allocation failed: %d\n", oclass, ret);
 		return ret;
diff --git a/drivers/gpu/drm/nouveau/dispnv50/core.c b/drivers/gpu/drm/nouveau/dispnv50/core.c
index 7d5438355715..98ccb67fc95b 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/core.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/core.c
@@ -34,7 +34,7 @@ nv50_core_del(struct nv50_core **pcore)
 	if (core) {
 		nvif_object_dtor(&core->sync);
 		nvif_object_dtor(&core->vram);
-		nv50_dmac_destroy(&core->chan);
+		nvif_dispchan_dtor(&core->chan);
 		kfree(*pcore);
 		*pcore = NULL;
 	}
@@ -75,7 +75,7 @@ nv50_core_new(struct nouveau_drm *drm, struct nv50_core **pcore)
 	if (ret)
 		return ret;
 
-	ret = nvif_object_ctor(&core->chan.base.user, "kmsCoreSyncCtxdma", NV50_DISP_HANDLE_SYNCBUF,
+	ret = nvif_object_ctor(&core->chan.object, "kmsCoreSyncCtxdma", NV50_DISP_HANDLE_SYNCBUF,
 			       NV_DMA_IN_MEMORY,
 			       (&(struct nv_dma_v0) {
 					.target = NV_DMA_V0_TARGET_VRAM,
@@ -87,7 +87,7 @@ nv50_core_new(struct nouveau_drm *drm, struct nv50_core **pcore)
 	if (ret)
 		return ret;
 
-	ret = nvif_object_ctor(&core->chan.base.user, "kmsCoreVramCtxdma", NV50_DISP_HANDLE_VRAM,
+	ret = nvif_object_ctor(&core->chan.object, "kmsCoreVramCtxdma", NV50_DISP_HANDLE_VRAM,
 			       NV_DMA_IN_MEMORY,
 			       (&(struct nv_dma_v0) {
 					.target = NV_DMA_V0_TARGET_VRAM,
diff --git a/drivers/gpu/drm/nouveau/dispnv50/core.h b/drivers/gpu/drm/nouveau/dispnv50/core.h
index a967c66dc7a2..1343a1d224c0 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/core.h
+++ b/drivers/gpu/drm/nouveau/dispnv50/core.h
@@ -5,9 +5,11 @@
 #include "crc.h"
 #include <nouveau_encoder.h>
 
+#include <nvif/dispchan.h>
+
 struct nv50_core {
 	const struct nv50_core_func *func;
-	struct nv50_dmac chan;
+	struct nvif_dispchan chan;
 
 	struct nvif_object vram;
 	struct nvif_object sync;
diff --git a/drivers/gpu/drm/nouveau/dispnv50/core507d.c b/drivers/gpu/drm/nouveau/dispnv50/core507d.c
index c6eee88ae99a..dab9fb984765 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/core507d.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/core507d.c
@@ -22,7 +22,6 @@
 #include "core.h"
 #include "head.h"
 
-#include <nvif/if0014.h>
 #include <nvif/push507c.h>
 #include <nvif/timer.h>
 
@@ -115,7 +114,7 @@ core507d_caps_init(struct nouveau_drm *drm, struct nv50_disp *disp)
 	if (ret < 0)
 		return ret;
 
-	time = nvif_msec(core->chan.base.device, 2000ULL,
+	time = nvif_msec(core->chan.disp->device, 2000ULL,
 			 if (NVBO_TD32(bo, NV50_DISP_CORE_NTFY,
 				       NV_DISP_CORE_NOTIFIER_1, CAPABILITIES_1, DONE, ==, TRUE))
 				 break;
@@ -157,8 +156,7 @@ int
 core507d_new_(const struct nv50_core_func *func, struct nouveau_drm *drm,
 	      s32 oclass, struct nv50_core **pcore)
 {
-	struct nvif_disp_chan_v0 args = {};
-	struct nv50_disp *disp = nv50_disp(drm->dev);
+	struct nvif_disp *disp = nv50_disp(drm->dev)->disp;
 	struct nv50_core *core;
 	int ret;
 
@@ -166,15 +164,22 @@ core507d_new_(const struct nv50_core_func *func, struct nouveau_drm *drm,
 		return -ENOMEM;
 	core->func = func;
 
-	ret = nv50_dmac_create(drm,
-			       &oclass, 0, &args, sizeof(args),
-			       disp->sync->offset, &core->chan);
-	if (ret) {
+	ret = nvif_dispchan_ctor(disp, "kmsChanCore", 0, oclass, &drm->mmu, &core->chan);
+	if (ret)
+		goto done;
+
+	ret = disp->impl->chan.core.new(disp->priv, core->chan.push.mem.priv,
+					&core->chan.impl, &core->chan.priv,
+					nvif_handle(&core->chan.object));
+	if (ret)
+		goto done;
+
+	ret = nvif_dispchan_oneinit(&core->chan);
+done:
+	if (ret)
 		NV_ERROR(drm, "core%04x allocation failed: %d\n", oclass, ret);
-		return ret;
-	}
 
-	return 0;
+	return ret;
 }
 
 int
diff --git a/drivers/gpu/drm/nouveau/dispnv50/core907d.c b/drivers/gpu/drm/nouveau/dispnv50/core907d.c
index 8564d4dffaff..0bff54ca5ba1 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/core907d.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/core907d.c
@@ -44,7 +44,7 @@ core907d_caps_init(struct nouveau_drm *drm, struct nv50_disp *disp)
 	if (ret < 0)
 		return ret;
 
-	time = nvif_msec(core->chan.base.device, 2000ULL,
+	time = nvif_msec(core->chan.disp->device, 2000ULL,
 			 if (NVBO_TD32(bo, NV50_DISP_CORE_NTFY,
 				       NV907D_CORE_NOTIFIER_3, CAPABILITIES_4, DONE, ==, TRUE))
 				 break;
diff --git a/drivers/gpu/drm/nouveau/dispnv50/crc.c b/drivers/gpu/drm/nouveau/dispnv50/crc.c
index 9482e69c3647..72ce4ada284f 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/crc.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/crc.c
@@ -507,7 +507,7 @@ nv50_crc_ctx_init(struct nv50_head *head, struct nvif_mmu *mmu,
 	if (ret)
 		return ret;
 
-	ret = nvif_object_ctor(&core->chan.base.user, "kmsCrcNtfyCtxDma",
+	ret = nvif_object_ctor(&core->chan.object, "kmsCrcNtfyCtxDma",
 			       NV50_DISP_HANDLE_CRC_CTX(head, idx),
 			       NV_DMA_IN_MEMORY,
 			       (&(struct nv_dma_v0) {
diff --git a/drivers/gpu/drm/nouveau/dispnv50/curs507a.c b/drivers/gpu/drm/nouveau/dispnv50/curs507a.c
index 7292d1554dba..8017cd0bd636 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/curs507a.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/curs507a.c
@@ -23,7 +23,6 @@
 #include "core.h"
 #include "head.h"
 
-#include <nvif/if0014.h>
 #include <nvif/timer.h>
 
 #include <nvhw/class/cl507a.h>
@@ -35,7 +34,7 @@ bool
 curs507a_space(struct nv50_wndw *wndw)
 {
 	nvif_msec(&nouveau_drm(wndw->plane.dev)->client.device, 100,
-		if (NVIF_TV32(&wndw->wimm.base.user, NV507A, FREE, COUNT, >=, 4))
+		if (NVIF_TV32(&wndw->wimm, NV507A, FREE, COUNT, >=, 4))
 			return true;
 	);
 
@@ -46,10 +45,10 @@ curs507a_space(struct nv50_wndw *wndw)
 static int
 curs507a_update(struct nv50_wndw *wndw, u32 *interlock)
 {
-	struct nvif_object *user = &wndw->wimm.base.user;
-	int ret = nvif_chan_wait(&wndw->wimm, 1);
+	struct nvif_dispchan *chan = &wndw->wimm;
+	int ret = nvif_chan_wait(chan, 1);
 	if (ret == 0) {
-		NVIF_WR32(user, NV507A, UPDATE,
+		NVIF_WR32(chan, NV507A, UPDATE,
 			  NVDEF(NV507A, UPDATE, INTERLOCK_WITH_CORE, DISABLE));
 	}
 	return ret;
@@ -58,10 +57,10 @@ curs507a_update(struct nv50_wndw *wndw, u32 *interlock)
 static int
 curs507a_point(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
 {
-	struct nvif_object *user = &wndw->wimm.base.user;
-	int ret = nvif_chan_wait(&wndw->wimm, 1);
+	struct nvif_dispchan *chan = &wndw->wimm;
+	int ret = nvif_chan_wait(chan, 1);
 	if (ret == 0) {
-		NVIF_WR32(user, NV507A, SET_CURSOR_HOT_SPOT_POINT_OUT,
+		NVIF_WR32(chan, NV507A, SET_CURSOR_HOT_SPOT_POINT_OUT,
 			  NVVAL(NV507A, SET_CURSOR_HOT_SPOT_POINT_OUT, X, asyw->point.x) |
 			  NVVAL(NV507A, SET_CURSOR_HOT_SPOT_POINT_OUT, Y, asyw->point.y));
 	}
@@ -170,10 +169,7 @@ curs507a_new_(const struct nv50_wimm_func *func, struct nouveau_drm *drm,
 	      int head, s32 oclass, u32 interlock_data,
 	      struct nv50_wndw **pwndw)
 {
-	struct nvif_disp_chan_v0 args = {
-		.id = head,
-	};
-	struct nv50_disp *disp = nv50_disp(drm->dev);
+	struct nvif_disp *disp = nv50_disp(drm->dev)->disp;
 	struct nv50_wndw *wndw;
 	int ret;
 
@@ -183,14 +179,21 @@ curs507a_new_(const struct nv50_wimm_func *func, struct nouveau_drm *drm,
 	if (*pwndw = wndw, ret)
 		return ret;
 
-	ret = nvif_object_ctor(&disp->disp->object, "kmsCurs", 0, oclass,
-			       &args, sizeof(args), &wndw->wimm.base.user);
+	ret = nvif_dispchan_ctor(disp, "kmsChanCurs", wndw->id, oclass, NULL, &wndw->wimm);
+	if (ret)
+		goto done;
+
+	ret = disp->impl->chan.curs.new(disp->priv, wndw->id, &wndw->wimm.impl, &wndw->wimm.priv);
+	if (ret)
+		goto done;
+
+	ret = nvif_dispchan_oneinit(&wndw->wimm);
+done:
 	if (ret) {
 		NV_ERROR(drm, "curs%04x allocation failed: %d\n", oclass, ret);
 		return ret;
 	}
 
-	nvif_object_map(&wndw->wimm.base.user, NULL, 0);
 	wndw->immd = func;
 	wndw->ctxdma.parent = NULL;
 	return nv50_wndw_ctor(wndw);
diff --git a/drivers/gpu/drm/nouveau/dispnv50/cursc37a.c b/drivers/gpu/drm/nouveau/dispnv50/cursc37a.c
index e39d08698c63..e2c28c5716a6 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/cursc37a.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/cursc37a.c
@@ -27,20 +27,20 @@
 static int
 cursc37a_update(struct nv50_wndw *wndw, u32 *interlock)
 {
-	struct nvif_object *user = &wndw->wimm.base.user;
-	int ret = nvif_chan_wait(&wndw->wimm, 1);
+	struct nvif_dispchan *chan = &wndw->wimm;
+	int ret = nvif_chan_wait(chan, 1);
 	if (ret == 0)
-		NVIF_WR32(user, NVC37A, UPDATE, 0x00000001);
+		NVIF_WR32(chan, NVC37A, UPDATE, 0x00000001);
 	return ret;
 }
 
 static int
 cursc37a_point(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
 {
-	struct nvif_object *user = &wndw->wimm.base.user;
-	int ret = nvif_chan_wait(&wndw->wimm, 1);
+	struct nvif_dispchan *chan = &wndw->wimm;
+	int ret = nvif_chan_wait(chan, 1);
 	if (ret == 0) {
-		NVIF_WR32(user, NVC37A, SET_CURSOR_HOT_SPOT_POINT_OUT(0),
+		NVIF_WR32(chan, NVC37A, SET_CURSOR_HOT_SPOT_POINT_OUT(0),
 			  NVVAL(NVC37A, SET_CURSOR_HOT_SPOT_POINT_OUT, X, asyw->point.x) |
 			  NVVAL(NVC37A, SET_CURSOR_HOT_SPOT_POINT_OUT, Y, asyw->point.y));
 	}
diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c b/drivers/gpu/drm/nouveau/dispnv50/disp.c
index 5e12de0aabb6..7762469af47b 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/disp.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c
@@ -50,7 +50,6 @@
 #include <nvif/class.h>
 #include <nvif/cl0002.h>
 #include <nvif/event.h>
-#include <nvif/if0014.h>
 #include <nvif/timer.h>
 
 #include <nvhw/class/cl507c.h>
@@ -68,220 +67,6 @@
 #include "nouveau_fence.h"
 #include "nv50_display.h"
 
-/******************************************************************************
- * EVO channel
- *****************************************************************************/
-
-static int
-nv50_chan_create(struct nvif_device *device, struct nvif_object *disp,
-		 const s32 *oclass, u8 head, void *data, u32 size,
-		 struct nv50_chan *chan)
-{
-	struct nvif_sclass *sclass;
-	int ret, i, n;
-
-	chan->device = device;
-
-	ret = n = nvif_object_sclass_get(disp, &sclass);
-	if (ret < 0)
-		return ret;
-
-	while (oclass[0]) {
-		for (i = 0; i < n; i++) {
-			if (sclass[i].oclass == oclass[0]) {
-				ret = nvif_object_ctor(disp, "kmsChan", 0,
-						       oclass[0], data, size,
-						       &chan->user);
-				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;
-			}
-		}
-		oclass++;
-	}
-
-	nvif_object_sclass_put(&sclass);
-	return -ENOSYS;
-}
-
-static void
-nv50_chan_destroy(struct nv50_chan *chan)
-{
-	nvif_object_dtor(&chan->user);
-}
-
-/******************************************************************************
- * DMA EVO channel
- *****************************************************************************/
-
-void
-nv50_dmac_destroy(struct nv50_dmac *dmac)
-{
-	nv50_chan_destroy(&dmac->base);
-
-	nvif_mem_unmap_dtor(&dmac->push.mem, &dmac->push.map);
-}
-
-static void
-nv50_dmac_kick(struct nvif_push *push)
-{
-	struct nv50_dmac *dmac = container_of(push, typeof(*dmac), push);
-
-	push->hw.cur = push->cur - (u32 __iomem *)dmac->push.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.
-		 */
-		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,
-				if (!(nvif_rd32(&device->object, 0x070000) & 0x00000002))
-					break;
-			);
-		}
-
-		NVIF_WV32(&dmac->base.user, NV507C, PUT, PTR, push->hw.cur);
-		push->hw.put = push->hw.cur;
-	}
-
-	push->bgn = push->cur;
-}
-
-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 > 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 (push->hw.put == 0)
-			nv50_dmac_kick(&dmac->push);
-
-		if (nvif_msec(dmac->base.device, 2000,
-			if (NVIF_TV32(&dmac->base.user, NV507C, GET, PTR, >, 0))
-				break;
-		) < 0)
-			return -ETIMEDOUT;
-	}
-
-	PUSH_RSVD(&dmac->push, PUSH_JUMP(&dmac->push, 0));
-	push->hw.cur = 0;
-	return 0;
-}
-
-static int
-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 > push->hw.max))
-		return -EINVAL;
-
-	push->hw.cur = push->cur - (u32 __iomem *)dmac->push.map.ptr;
-	if (push->hw.cur + size >= push->hw.max) {
-		int ret = nv50_dmac_wind(dmac);
-		if (ret)
-			return ret;
-
-		push->cur = dmac->push.map.ptr;
-		push->cur = push->cur + push->hw.cur;
-		nv50_dmac_kick(push);
-	}
-
-	if (nvif_msec(dmac->base.device, 2000,
-		if ((free = nv50_dmac_free(dmac)) >= size)
-			break;
-	) < 0) {
-		WARN_ON(1);
-		return -ETIMEDOUT;
-	}
-
-	push->bgn = dmac->push.map.ptr;
-	push->bgn = push->bgn + push->hw.cur;
-	push->cur = push->bgn;
-	push->end = push->cur + free;
-	return 0;
-}
-
-MODULE_PARM_DESC(kms_vram_pushbuf, "Place EVO/NVD push buffers in VRAM (default: auto)");
-static int nv50_dmac_vram_pushbuf = -1;
-module_param_named(kms_vram_pushbuf, nv50_dmac_vram_pushbuf, int, 0400);
-
-int
-nv50_dmac_create(struct nouveau_drm *drm,
-		 const s32 *oclass, u8 head, void *data, u32 size, s64 syncbuf,
-		 struct nv50_dmac *dmac)
-{
-	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;
-
-	/* Pascal added support for 47-bit physical addresses, but some
-	 * parts of EVO still only accept 40-bit PAs.
-	 *
-	 * To avoid issues on systems with large amounts of RAM, and on
-	 * systems where an IOMMU maps pages at a high address, we need
-	 * to allocate push buffers in VRAM instead.
-	 *
-	 * This appears to match NVIDIA's behaviour on Pascal.
-	 */
-	if ((nv50_dmac_vram_pushbuf > 0) ||
-	    (nv50_dmac_vram_pushbuf < 0 && device->info.family == NV_DEVICE_INFO_V0_PASCAL))
-		type |= NVIF_MEM_VRAM;
-
-	ret = nvif_mem_ctor_map(&drm->mmu, "kmsChanPush", type, 0x1000,
-				&dmac->push.mem, &dmac->push.map);
-	if (ret)
-		return ret;
-
-	dmac->push.wait = nv50_dmac_wait;
-	dmac->push.kick = nv50_dmac_kick;
-	dmac->push.bgn = dmac->push.map.ptr;
-	dmac->push.cur = dmac->push.bgn;
-	dmac->push.end = dmac->push.bgn;
-	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->push.hw.max -= 12;
-
-	args->pushbuf = nvif_handle(&dmac->push.mem.object);
-
-	ret = nv50_chan_create(device, disp, oclass, head, data, size,
-			       &dmac->base);
-	if (ret)
-		return ret;
-
-	if (syncbuf < 0)
-		return 0;
-
-	return ret;
-}
-
 /******************************************************************************
  * Output path helpers
  *****************************************************************************/
@@ -2088,7 +1873,7 @@ nv50_disp_atomic_commit_core(struct drm_atomic_state *state, u32 *interlock)
 	core->func->ntfy_init(disp->sync, NV50_DISP_CORE_NTFY);
 	core->func->update(core, interlock, true);
 	if (core->func->ntfy_wait_done(disp->sync, NV50_DISP_CORE_NTFY,
-				       disp->core->chan.base.device))
+				       disp->core->chan.disp->device))
 		NV_ERROR(drm, "core notifier timeout\n");
 
 	for_each_new_mst_mgr_in_state(state, mgr, mst_state, i) {
diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.h b/drivers/gpu/drm/nouveau/dispnv50/disp.h
index 39aaa385cd6a..db9e4e5070a3 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/disp.h
+++ b/drivers/gpu/drm/nouveau/dispnv50/disp.h
@@ -1,8 +1,6 @@
 #ifndef __NV50_KMS_H__
 #define __NV50_KMS_H__
 #include <linux/workqueue.h>
-#include <nvif/mem.h>
-#include <nvif/push.h>
 
 #include "nouveau_display.h"
 
@@ -54,17 +52,6 @@ void corec37d_ntfy_init(struct nouveau_bo *, u32);
 
 void head907d_olut_load(struct drm_color_lut *, int size, void __iomem *);
 
-struct nv50_chan {
-	struct nvif_object user;
-	struct nvif_device *device;
-};
-
-struct nv50_dmac {
-	struct nv50_chan base;
-
-	struct nvif_push push;
-};
-
 struct nv50_outp_atom {
 	struct list_head head;
 
@@ -81,11 +68,6 @@ struct nv50_outp_atom {
 	} set, clr;
 };
 
-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 *);
-
 /*
  * For normal encoders this just returns the encoder. For active MST encoders,
  * this returns the real outp that's driving displays on the topology.
diff --git a/drivers/gpu/drm/nouveau/dispnv50/oimm507b.c b/drivers/gpu/drm/nouveau/dispnv50/oimm507b.c
index 752318cf3cf1..05b0d42c85c6 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/oimm507b.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/oimm507b.c
@@ -21,26 +21,28 @@
  */
 #include "oimm.h"
 
-#include <nvif/if0014.h>
-
 static int
 oimm507b_init_(const struct nv50_wimm_func *func, struct nouveau_drm *drm,
 	       s32 oclass, struct nv50_wndw *wndw)
 {
-	struct nvif_disp_chan_v0 args = {
-		.id = wndw->id,
-	};
-	struct nv50_disp *disp = nv50_disp(drm->dev);
+	struct nvif_disp *disp = nv50_disp(drm->dev)->disp;
 	int ret;
 
-	ret = nvif_object_ctor(&disp->disp->object, "kmsOvim", 0, oclass,
-			       &args, sizeof(args), &wndw->wimm.base.user);
+	ret = nvif_dispchan_ctor(disp, "kmsChanOvim", wndw->id, oclass, NULL, &wndw->wimm);
+	if (ret)
+		goto done;
+
+	ret = disp->impl->chan.oimm.new(disp->priv, wndw->id, &wndw->wimm.impl, &wndw->wimm.priv);
+	if (ret)
+		goto done;
+
+	ret = nvif_dispchan_oneinit(&wndw->wimm);
+done:
 	if (ret) {
 		NV_ERROR(drm, "oimm%04x allocation failed: %d\n", oclass, ret);
 		return ret;
 	}
 
-	nvif_object_map(&wndw->wimm.base.user, NULL, 0);
 	wndw->immd = func;
 	return 0;
 }
diff --git a/drivers/gpu/drm/nouveau/dispnv50/ovly507e.c b/drivers/gpu/drm/nouveau/dispnv50/ovly507e.c
index 4e109c5b5a1b..458c6f9e63f0 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/ovly507e.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/ovly507e.c
@@ -25,7 +25,6 @@
 #include <drm/drm_atomic_helper.h>
 #include <drm/drm_fourcc.h>
 
-#include <nvif/if0014.h>
 #include <nvif/push507c.h>
 
 #include <nvhw/class/cl507e.h>
@@ -145,10 +144,7 @@ ovly507e_new_(const struct nv50_wndw_func *func, const u32 *format,
 	      struct nouveau_drm *drm, int head, s32 oclass, u32 interlock_data,
 	      struct nv50_wndw **pwndw)
 {
-	struct nvif_disp_chan_v0 args = {
-		.id = head,
-	};
-	struct nv50_disp *disp = nv50_disp(drm->dev);
+	struct nvif_disp *disp = nv50_disp(drm->dev)->disp;
 	struct nv50_wndw *wndw;
 	int ret;
 
@@ -159,9 +155,18 @@ ovly507e_new_(const struct nv50_wndw_func *func, const u32 *format,
 	if (*pwndw = wndw, ret)
 		return ret;
 
-	ret = nv50_dmac_create(drm,
-			       &oclass, 0, &args, sizeof(args),
-			       disp->sync->offset, &wndw->wndw);
+	ret = nvif_dispchan_ctor(disp, "kmsChanOvly", wndw->id, oclass, &drm->mmu, &wndw->wndw);
+	if (ret)
+		goto done;
+
+	ret = disp->impl->chan.ovly.new(disp->priv, wndw->id, wndw->wndw.push.mem.priv,
+					&wndw->wndw.impl, &wndw->wndw.priv,
+					nvif_handle(&wndw->wndw.object));
+	if (ret)
+		goto done;
+
+	ret = nvif_dispchan_oneinit(&wndw->wndw);
+done:
 	if (ret) {
 		NV_ERROR(drm, "ovly%04x allocation failed: %d\n", oclass, ret);
 		return ret;
diff --git a/drivers/gpu/drm/nouveau/dispnv50/wimmc37b.c b/drivers/gpu/drm/nouveau/dispnv50/wimmc37b.c
index 7985da61aaac..2f4f0ad89b5e 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/wimmc37b.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/wimmc37b.c
@@ -23,7 +23,6 @@
 #include "atom.h"
 #include "wndw.h"
 
-#include <nvif/if0014.h>
 #include <nvif/pushc37b.h>
 
 #include <nvhw/class/clc37b.h>
@@ -68,14 +67,21 @@ static int
 wimmc37b_init_(const struct nv50_wimm_func *func, struct nouveau_drm *drm,
 	       s32 oclass, struct nv50_wndw *wndw)
 {
-	struct nvif_disp_chan_v0 args = {
-		.id = wndw->id,
-	};
+	struct nvif_disp *disp = nv50_disp(drm->dev)->disp;
 	int ret;
 
-	ret = nv50_dmac_create(drm,
-			       &oclass, 0, &args, sizeof(args), -1,
-			       &wndw->wimm);
+	ret = nvif_dispchan_ctor(disp, "kmsChanWimm", wndw->id, oclass, &drm->mmu, &wndw->wimm);
+	if (ret)
+		goto done;
+
+	ret = disp->impl->chan.wimm.new(disp->priv, wndw->id, wndw->wimm.push.mem.priv,
+					&wndw->wimm.impl, &wndw->wimm.priv,
+					nvif_handle(&wndw->wimm.object));
+	if (ret)
+		goto done;
+
+	ret = nvif_dispchan_oneinit(&wndw->wimm);
+done:
 	if (ret) {
 		NV_ERROR(drm, "wimm%04x allocation failed: %d\n", oclass, ret);
 		return ret;
diff --git a/drivers/gpu/drm/nouveau/dispnv50/wndw.c b/drivers/gpu/drm/nouveau/dispnv50/wndw.c
index 6fb6d2252e15..9cab8d20bc68 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/wndw.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/wndw.c
@@ -118,7 +118,7 @@ nv50_wndw_wait_armed(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
 	if (asyw->set.ntfy) {
 		return wndw->func->ntfy_wait_begun(disp->sync,
 						   asyw->ntfy.offset,
-						   wndw->wndw.base.device);
+						   wndw->wndw.disp->device);
 	}
 	return 0;
 }
@@ -644,11 +644,11 @@ nv50_wndw_destroy(struct drm_plane *plane)
 		nv50_wndw_ctxdma_del(ctxdma);
 	}
 
-	nv50_dmac_destroy(&wndw->wimm);
+	nvif_dispchan_dtor(&wndw->wimm);
 
 	nvif_object_dtor(&wndw->vram);
 	nvif_object_dtor(&wndw->sync);
-	nv50_dmac_destroy(&wndw->wndw);
+	nvif_dispchan_dtor(&wndw->wndw);
 
 	nv50_lut_fini(&wndw->ilut);
 
@@ -702,10 +702,10 @@ nv50_wndw_ctor(struct nv50_wndw *wndw)
 	struct nv50_disp *disp = nv50_disp(wndw->plane.dev);
 	int ret;
 
-	if (!nvif_object_constructed(&wndw->wndw.base.user))
+	if (!wndw->wndw.impl)
 		return 0;
 
-	ret = nvif_object_ctor(&wndw->wndw.base.user, "kmsWndwSyncCtxDma", NV50_DISP_HANDLE_SYNCBUF,
+	ret = nvif_object_ctor(&wndw->wndw.object, "kmsWndwSyncCtxDma", NV50_DISP_HANDLE_SYNCBUF,
 			       NV_DMA_IN_MEMORY,
 			       (&(struct nv_dma_v0) {
 					.target = NV_DMA_V0_TARGET_VRAM,
@@ -717,7 +717,7 @@ nv50_wndw_ctor(struct nv50_wndw *wndw)
 	if (ret)
 		return ret;
 
-	ret = nvif_object_ctor(&wndw->wndw.base.user, "kmsWndwVramCtxDma", NV50_DISP_HANDLE_VRAM,
+	ret = nvif_object_ctor(&wndw->wndw.object, "kmsWndwVramCtxDma", NV50_DISP_HANDLE_VRAM,
 			       NV_DMA_IN_MEMORY,
 			       (&(struct nv_dma_v0) {
 					.target = NV_DMA_V0_TARGET_VRAM,
@@ -754,7 +754,7 @@ nv50_wndw_prep(const struct nv50_wndw_func *func, struct drm_device *dev,
 	wndw->interlock.type = interlock_type;
 	wndw->interlock.data = interlock_data;
 
-	wndw->ctxdma.parent = &wndw->wndw.base.user;
+	wndw->ctxdma.parent = &wndw->wndw.object;
 	INIT_LIST_HEAD(&wndw->ctxdma.list);
 
 	for (nformat = 0; format[nformat]; nformat++);
diff --git a/drivers/gpu/drm/nouveau/dispnv50/wndw.h b/drivers/gpu/drm/nouveau/dispnv50/wndw.h
index 66a06e20a6a0..68092e6445fa 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/wndw.h
+++ b/drivers/gpu/drm/nouveau/dispnv50/wndw.h
@@ -5,6 +5,8 @@
 #include "atom.h"
 #include "lut.h"
 
+#include <nvif/dispchan.h>
+
 struct nv50_wndw_ctxdma {
 	struct list_head head;
 	struct nvif_object object;
@@ -25,8 +27,8 @@ struct nv50_wndw {
 
 	struct nv50_lut ilut;
 
-	struct nv50_dmac wndw;
-	struct nv50_dmac wimm;
+	struct nvif_dispchan wndw;
+	struct nvif_dispchan wimm;
 
 	struct nvif_object vram;
 	struct nvif_object sync;
@@ -104,9 +106,9 @@ extern const struct nv50_wimm_func curs507a;
 bool curs507a_space(struct nv50_wndw *);
 
 static inline __must_check int
-nvif_chan_wait(struct nv50_dmac *dmac, u32 size)
+nvif_chan_wait(struct nvif_dispchan *chan, u32 size)
 {
-	struct nv50_wndw *wndw = container_of(dmac, typeof(*wndw), wimm);
+	struct nv50_wndw *wndw = container_of(chan, typeof(*wndw), wimm);
 	return curs507a_space(wndw) ? 0 : -ETIMEDOUT;
 }
 
diff --git a/drivers/gpu/drm/nouveau/dispnv50/wndwc37e.c b/drivers/gpu/drm/nouveau/dispnv50/wndwc37e.c
index 5029dfd98443..17751110edae 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/wndwc37e.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/wndwc37e.c
@@ -25,7 +25,6 @@
 #include <drm/drm_atomic_helper.h>
 #include <nouveau_bo.h>
 
-#include <nvif/if0014.h>
 #include <nvif/pushc37b.h>
 
 #include <nvhw/class/clc37e.h>
@@ -350,10 +349,7 @@ wndwc37e_new_(const struct nv50_wndw_func *func, struct nouveau_drm *drm,
 	      enum drm_plane_type type, int index, s32 oclass, u32 heads,
 	      struct nv50_wndw **pwndw)
 {
-	struct nvif_disp_chan_v0 args = {
-		.id = index,
-	};
-	struct nv50_disp *disp = nv50_disp(drm->dev);
+	struct nvif_disp *disp = nv50_disp(drm->dev)->disp;
 	struct nv50_wndw *wndw;
 	int ret;
 
@@ -363,9 +359,18 @@ wndwc37e_new_(const struct nv50_wndw_func *func, struct nouveau_drm *drm,
 	if (*pwndw = wndw, ret)
 		return ret;
 
-	ret = nv50_dmac_create(drm,
-			       &oclass, 0, &args, sizeof(args),
-			       disp->sync->offset, &wndw->wndw);
+	ret = nvif_dispchan_ctor(disp, "kmsChanWndw", wndw->id, oclass, &drm->mmu, &wndw->wndw);
+	if (ret)
+		goto done;
+
+	ret = disp->impl->chan.wndw.new(disp->priv, wndw->id, wndw->wndw.push.mem.priv,
+					&wndw->wndw.impl, &wndw->wndw.priv,
+					nvif_handle(&wndw->wndw.object));
+	if (ret)
+		goto done;
+
+	ret = nvif_dispchan_oneinit(&wndw->wndw);
+done:
 	if (ret) {
 		NV_ERROR(drm, "qndw%04x allocation failed: %d\n", oclass, ret);
 		return ret;
diff --git a/drivers/gpu/drm/nouveau/include/nvif/dispchan.h b/drivers/gpu/drm/nouveau/include/nvif/dispchan.h
new file mode 100644
index 000000000000..b1d3503e054c
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/include/nvif/dispchan.h
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: MIT */
+#ifndef __NVIF_DISPCHAN_H__
+#define __NVIF_DISPCHAN_H__
+#include "disp.h"
+#include "push.h"
+
+struct nvif_dispchan {
+	const struct nvif_disp_chan_impl *impl;
+	struct nvif_disp_chan_priv *priv;
+	struct nvif_object object;
+	struct nvif_map map;
+
+	struct nvif_disp *disp;
+	struct nvif_push push;
+};
+
+int nvif_dispchan_ctor(struct nvif_disp *, const char *name, u32 handle, s32 oclass,
+		       struct nvif_mmu *, struct nvif_dispchan *);
+int nvif_dispchan_oneinit(struct nvif_dispchan *);
+void nvif_dispchan_dtor(struct nvif_dispchan *);
+#endif
diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index e66d29b3db63..60a3529a6594 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -17,6 +17,7 @@ struct nvif_disp_caps_priv;
 struct nvif_conn_priv;
 struct nvif_outp_priv;
 struct nvif_head_priv;
+struct nvif_disp_chan_priv;
 
 struct nvif_driver {
 	const char *name;
@@ -360,6 +361,11 @@ struct nvif_head_impl {
 		      const struct nvif_event_impl **, struct nvif_event_priv **);
 };
 
+struct nvif_disp_chan_impl {
+	void (*del)(struct nvif_disp_chan_priv *);
+	struct nvif_mapinfo map;
+};
+
 struct nvif_disp_impl {
 	void (*del)(struct nvif_disp_priv *);
 
@@ -390,14 +396,23 @@ struct nvif_disp_impl {
 	struct {
 		struct nvif_disp_impl_core {
 			s32 oclass;
+			int (*new)(struct nvif_disp_priv *, struct nvif_mem_priv *,
+				   const struct nvif_disp_chan_impl **,
+				   struct nvif_disp_chan_priv **, u64 handle);
 		} core;
 
 		struct nvif_disp_impl_dmac {
 			s32 oclass;
+			int (*new)(struct nvif_disp_priv *, u8 id, struct nvif_mem_priv *,
+				   const struct nvif_disp_chan_impl **,
+				   struct nvif_disp_chan_priv **, u64 handle);
 		} base, ovly, wndw, wimm;
 
 		struct nvif_disp_impl_pioc {
 			s32 oclass;
+			int (*new)(struct nvif_disp_priv *, u8 id,
+				   const struct nvif_disp_chan_impl **,
+				   struct nvif_disp_chan_priv **);
 		} curs, oimm;
 	} chan;
 };
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0014.h b/drivers/gpu/drm/nouveau/include/nvif/if0014.h
deleted file mode 100644
index be0362805106..000000000000
--- a/drivers/gpu/drm/nouveau/include/nvif/if0014.h
+++ /dev/null
@@ -1,13 +0,0 @@
-/* SPDX-License-Identifier: MIT */
-#ifndef __NVIF_IF0014_H__
-#define __NVIF_IF0014_H__
-
-union nvif_disp_chan_args {
-	struct nvif_disp_chan_v0 {
-		__u8  version;
-		__u8  id;
-		__u8  pad02[6];
-		__u64 pushbuf;
-	} v0;
-};
-#endif
diff --git a/drivers/gpu/drm/nouveau/include/nvif/push.h b/drivers/gpu/drm/nouveau/include/nvif/push.h
index 8817947a2ea0..275bade7fab9 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/push.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/push.h
@@ -42,7 +42,7 @@ struct nvif_push {
 	u32 *end;
 
 	int (*wait)(struct nvif_push *push, u32 size);
-	void (*kick)(struct nvif_push *push);
+	int (*kick)(struct nvif_push *push);
 };
 
 static inline __must_check int
@@ -62,8 +62,7 @@ PUSH_WAIT(struct nvif_push *push, u32 size)
 static inline int
 PUSH_KICK(struct nvif_push *push)
 {
-	push->kick(push);
-	return 0;
+	return push->kick(push);
 }
 
 #ifdef CONFIG_NOUVEAU_DEBUG_PUSH
diff --git a/drivers/gpu/drm/nouveau/nouveau_chan.c b/drivers/gpu/drm/nouveau/nouveau_chan.c
index 27c477ed6b9b..771a4b4b3f1d 100644
--- a/drivers/gpu/drm/nouveau/nouveau_chan.c
+++ b/drivers/gpu/drm/nouveau/nouveau_chan.c
@@ -117,13 +117,14 @@ nouveau_channel_del(struct nouveau_channel **pchan)
 	*pchan = NULL;
 }
 
-static void
+static int
 nouveau_channel_kick(struct nvif_push *push)
 {
 	struct nouveau_channel *chan = container_of(push, typeof(*chan), chan.push);
 	chan->dma.cur = chan->dma.cur + (chan->chan.push.cur - chan->chan.push.bgn);
 	FIRE_RING(chan);
 	chan->chan.push.bgn = chan->chan.push.cur;
+	return 0;
 }
 
 static int
diff --git a/drivers/gpu/drm/nouveau/nvif/Kbuild b/drivers/gpu/drm/nouveau/nvif/Kbuild
index b7963a39dd91..8e3ed36df6b3 100644
--- a/drivers/gpu/drm/nouveau/nvif/Kbuild
+++ b/drivers/gpu/drm/nouveau/nvif/Kbuild
@@ -4,6 +4,7 @@ nvif-y += nvif/client.o
 nvif-y += nvif/conn.o
 nvif-y += nvif/device.o
 nvif-y += nvif/disp.o
+nvif-y += nvif/dispchan.o
 nvif-y += nvif/driver.o
 nvif-y += nvif/event.o
 nvif-y += nvif/fifo.o
diff --git a/drivers/gpu/drm/nouveau/nvif/dispchan.c b/drivers/gpu/drm/nouveau/nvif/dispchan.c
new file mode 100644
index 000000000000..fc4f50da1a43
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/nvif/dispchan.c
@@ -0,0 +1,205 @@
+/*
+ * 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 <nvif/dispchan.h>
+#include <nvif/device.h>
+#include <nvif/driverif.h>
+#include <nvif/push507c.h>
+#include <nvif/timer.h>
+
+#include <nvif/class.h>
+#include <nvhw/class/cl507c.h>
+
+static int
+nvif_dispchan_kick(struct nvif_push *push)
+{
+	struct nvif_dispchan *chan = container_of(push, typeof(*chan), push);
+
+	push->hw.cur = push->cur - (u32 __iomem *)chan->push.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.
+		 */
+		if (chan->push.mem.type & NVIF_MEM_VRAM) {
+			struct nvif_device *device = chan->disp->device;
+
+			nvif_wr32(&device->object, 0x070000, 0x00000001);
+			nvif_msec(device, 2000,
+				if (!(nvif_rd32(&device->object, 0x070000) & 0x00000002))
+					break;
+			);
+		}
+
+		NVIF_WV32(chan, NV507C, PUT, PTR, push->hw.cur);
+		push->hw.put = push->hw.cur;
+	}
+
+	push->bgn = push->cur;
+	return 0;
+}
+
+static int
+nvif_dispchan_free(struct nvif_dispchan *chan)
+{
+	struct nvif_push *push = &chan->push;
+	u32 get;
+
+	get = NVIF_RV32(chan, NV507C, GET, PTR);
+	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
+nvif_dispchan_wind(struct nvif_dispchan *chan)
+{
+	struct nvif_push *push = &chan->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(chan, NV507C, GET, PTR);
+	if (get == 0) {
+		/* Corner-case, HW idle, but non-committed work pending. */
+		if (push->hw.put == 0)
+			nvif_dispchan_kick(&chan->push);
+
+		if (nvif_msec(chan->disp->device, 2000,
+			if (NVIF_TV32(chan, NV507C, GET, PTR, >, 0))
+				break;
+		) < 0)
+			return -ETIMEDOUT;
+	}
+
+	PUSH_RSVD(&chan->push, PUSH_JUMP(&chan->push, 0));
+	push->hw.cur = 0;
+	return 0;
+}
+
+static int
+nvif_dispchan_wait(struct nvif_push *push, u32 size)
+{
+	struct nvif_dispchan *chan = container_of(push, typeof(*chan), push);
+	int free;
+
+	if (WARN_ON(size > push->hw.max))
+		return -EINVAL;
+
+	push->hw.cur = push->cur - (u32 __iomem *)chan->push.map.ptr;
+	if (push->hw.cur + size >= push->hw.max) {
+		int ret = nvif_dispchan_wind(chan);
+		if (ret)
+			return ret;
+
+		push->cur = chan->push.map.ptr;
+		push->cur = push->cur + push->hw.cur;
+		nvif_dispchan_kick(push);
+	}
+
+	if (nvif_msec(chan->disp->device, 2000,
+		if ((free = nvif_dispchan_free(chan)) >= size)
+			break;
+	) < 0) {
+		WARN_ON(1);
+		return -ETIMEDOUT;
+	}
+
+	push->bgn = chan->push.map.ptr;
+	push->bgn = push->bgn + push->hw.cur;
+	push->cur = push->bgn;
+	push->end = push->cur + free;
+	return 0;
+}
+
+void
+nvif_dispchan_dtor(struct nvif_dispchan *chan)
+{
+	if (chan->impl) {
+		chan->impl->del(chan->priv);
+		chan->impl = NULL;
+	}
+
+	nvif_mem_unmap_dtor(&chan->push.mem, &chan->push.map);
+}
+
+int
+nvif_dispchan_oneinit(struct nvif_dispchan *chan)
+{
+	int ret;
+
+	ret = nvif_object_map_cpu(&chan->object, &chan->impl->map, &chan->map);
+	if (ret)
+		return ret;
+
+	return 0;
+}
+
+int
+nvif_dispchan_ctor(struct nvif_disp *disp, const char *name, u32 handle, s32 oclass,
+		   struct nvif_mmu *mmu, struct nvif_dispchan *chan)
+{
+	u8 type = NVIF_MEM_COHERENT;
+	int ret;
+
+	/* PIO channels don't need a push buffer. */
+	chan->push.mem.impl = NULL;
+	chan->impl = NULL;
+	if (!mmu)
+		goto done;
+
+	/* Pascal added support for 47-bit physical addresses, but some
+	 * parts of EVO still only accept 40-bit PAs.
+	 *
+	 * To avoid issues on systems with large amounts of RAM, and on
+	 * systems where an IOMMU maps pages at a high address, we need
+	 * to allocate push buffers in VRAM instead.
+	 *
+	 * This appears to match NVIDIA's behaviour on Pascal.
+	 */
+	if (disp->device->impl->family == NVIF_DEVICE_PASCAL)
+		type |= NVIF_MEM_VRAM;
+
+	ret = nvif_mem_ctor_map(mmu, "nvifDispChanPush", type, 0x1000,
+				&chan->push.mem, &chan->push.map);
+	if (ret)
+		return ret;
+
+	chan->push.hw.cur = 0;
+	chan->push.hw.put = 0;
+	chan->push.hw.max = 0x1000/4 - 1;
+	chan->push.bgn = chan->push.map.ptr;
+	chan->push.cur = chan->push.bgn;
+	chan->push.end = chan->push.bgn;
+	chan->push.wait = nvif_dispchan_wait;
+	chan->push.kick = nvif_dispchan_kick;
+
+	/* 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->object.oclass < GV100_DISP)
+		chan->push.hw.max -= 12;
+
+done:
+	nvif_object_ctor(&disp->object, name ?: "nvifDispChan", handle, oclass, &chan->object);
+	chan->disp = disp;
+	return 0;
+}
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/chan.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/chan.c
index 86938c633272..3a0366420248 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/chan.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/chan.c
@@ -19,17 +19,17 @@
  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
  */
-#include "chan.h"
+#include "uchan.h"
 
 #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;
+
+	struct nvif_disp_chan_impl impl;
 };
 
 static int
@@ -49,20 +49,6 @@ nvkm_disp_chan_ntfy(struct nvkm_object *object, u32 type, struct nvkm_event **pe
 	return -EINVAL;
 }
 
-static int
-nvkm_disp_chan_map(struct nvkm_object *object, void *argv, u32 argc,
-		   enum nvkm_object_map *type, u64 *addr, u64 *size)
-{
-	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);
-
-	*type = NVKM_OBJECT_MAP_IO;
-	*addr = base + chan->func->user(chan, size);
-	return 0;
-}
-
 struct nvkm_disp_chan_object {
 	struct nvkm_oproxy oproxy;
 	struct nvkm_disp *disp;
@@ -136,6 +122,20 @@ nvkm_disp_chan_child_get(struct nvkm_object *object, int index, struct nvkm_ocla
 	return -EINVAL;
 }
 
+static void
+nvkm_disp_chan_del(struct nvif_disp_chan_priv *uchan)
+{
+	struct nvkm_object *object = &uchan->object;
+
+	nvkm_object_fini(object, false);
+	nvkm_object_del(&object);
+}
+
+static const struct nvif_disp_chan_impl
+nvkm_disp_chan_impl = {
+	.del = nvkm_disp_chan_del,
+};
+
 static int
 nvkm_disp_chan_fini(struct nvkm_object *object, bool suspend)
 {
@@ -179,42 +179,20 @@ nvkm_disp_chan = {
 	.init = nvkm_disp_chan_init,
 	.fini = nvkm_disp_chan_fini,
 	.ntfy = nvkm_disp_chan_ntfy,
-	.map = nvkm_disp_chan_map,
 	.sclass = nvkm_disp_chan_child_get,
 };
 
-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)
+int
+nvkm_disp_chan_new(struct nvkm_disp *disp, const struct nvkm_disp_func_chan *func, u8 id,
+		   struct nvkm_memory *memory, const struct nvif_disp_chan_impl **pimpl,
+		   struct nvif_disp_chan_priv **ppriv, 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 nvkm_device *device = disp->engine.subdev.device;
 	struct nvif_disp_chan_priv *uchan;
 	struct nvkm_disp_chan *chan;
-	union nvif_disp_chan_args *args = argv;
-	int ret, i;
-
-	for (i = 0; i < ARRAY_SIZE(chans); i++) {
-		if (chans[i]->oclass == oclass->base.oclass) {
-			user = chans[i]->chan;
-			break;
-		}
-	}
-
-	if (WARN_ON(!user))
-		return -EINVAL;
+	int ret;
 
-	if (argc != sizeof(args->v0) || args->v0.version != 0)
-		return -ENOSYS;
-	if (args->v0.id >= nr || !args->v0.pushbuf != !user->func->push)
+	if (!memory != !func->chan->func->push)
 		return -EINVAL;
 
 	uchan = kzalloc(sizeof(*uchan), GFP_KERNEL);
@@ -222,13 +200,13 @@ nvkm_disp_chan_new_(struct nvkm_disp *disp, int nr, const struct nvkm_oclass *oc
 		return -ENOMEM;
 	chan = &uchan->chan;
 
-	nvkm_object_ctor(&nvkm_disp_chan, oclass, &uchan->object);
-	chan->func = user->func;
-	chan->mthd = user->mthd;
+	nvkm_object_ctor(&nvkm_disp_chan, &(struct nvkm_oclass) {}, &uchan->object);
+	chan->func = func->chan->func;
+	chan->mthd = func->chan->mthd;
 	chan->disp = disp;
-	chan->chid.ctrl = user->ctrl + args->v0.id;
-	chan->chid.user = user->user + args->v0.id;
-	chan->head = args->v0.id;
+	chan->chid.ctrl = func->chan->ctrl + id;
+	chan->chid.user = func->chan->user + id;
+	chan->head = id;
 
 	spin_lock(&disp->user.lock);
 	if (disp->chan[chan->chid.user]) {
@@ -237,48 +215,36 @@ nvkm_disp_chan_new_(struct nvkm_disp *disp, int nr, const struct nvkm_oclass *oc
 		return -EBUSY;
 	}
 	disp->chan[chan->chid.user] = chan;
-	chan->user.oclass = oclass->base.oclass;
+	chan->user.oclass = func->oclass;
 	spin_unlock(&disp->user.lock);
 
 	*pobject = &uchan->object;
 
+	uchan->impl = nvkm_disp_chan_impl;
+	uchan->impl.map.type = NVIF_MAP_IO;
+	uchan->impl.map.handle = device->func->resource_addr(device, 0);
+	uchan->impl.map.handle += chan->func->user(chan, &uchan->impl.map.length);
+
 	if (chan->func->push) {
-		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);
+		chan->memory = nvkm_memory_ref(memory);
 
 		ret = chan->func->push(chan);
-		if (ret)
+		if (ret) {
+			nvkm_object_del(pobject);
 			return ret;
+		}
 	}
 
-	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 = container_of(oclass->parent, struct nvif_disp_priv, object)->disp;
-
-	return nvkm_disp_chan_new_(disp, disp->wndw.nr, oclass, argv, argc, pobject);
-}
-
-int
-nvkm_disp_chan_new(const struct nvkm_oclass *oclass, void *argv, u32 argc,
-		   struct nvkm_object **pobject)
-{
-	struct nvkm_disp *disp = container_of(oclass->parent, struct nvif_disp_priv, object)->disp;
+	ret = nvkm_disp_chan_init(&uchan->object);
+	if (ret)
+		goto done;
 
-	return nvkm_disp_chan_new_(disp, disp->head.nr, oclass, argv, argc, pobject);
-}
+	*pimpl = &uchan->impl;
+	*ppriv = uchan;
 
-int
-nvkm_disp_core_new(const struct nvkm_oclass *oclass, void *argv, u32 argc,
-		   struct nvkm_object **pobject)
-{
-	struct nvkm_disp *disp = container_of(oclass->parent, struct nvif_disp_priv, object)->disp;
+done:
+	if (ret)
+		nvkm_disp_chan_del(uchan);
 
-	return nvkm_disp_chan_new_(disp, 1, oclass, argv, argc, pobject);
+	return ret;
 }
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/chan.h b/drivers/gpu/drm/nouveau/nvkm/engine/disp/chan.h
index 8c212dde036f..b7d7c435b1e2 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/chan.h
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/chan.h
@@ -29,10 +29,6 @@ struct nvkm_disp_chan {
 	} user;
 };
 
-int nvkm_disp_core_new(const struct nvkm_oclass *, void *, u32, struct nvkm_object **);
-int nvkm_disp_chan_new(const struct nvkm_oclass *, void *, u32, struct nvkm_object **);
-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 *);
 	int (*init)(struct nvkm_disp_chan *);
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uchan.h b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uchan.h
new file mode 100644
index 000000000000..f682d2d5e6d3
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uchan.h
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: MIT */
+#ifndef __NVKM_UDISP_CHAN_H__
+#define __NVKM_UDISP_CHAN_H__
+#include "chan.h"
+#include <nvif/driverif.h>
+
+int nvkm_disp_chan_new(struct nvkm_disp *disp, const struct nvkm_disp_func_chan *, u8 id,
+		       struct nvkm_memory *, const struct nvif_disp_chan_impl **,
+		       struct nvif_disp_chan_priv **, struct nvkm_object **);
+#endif
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c
index dc23fad17b81..bc15fe149a86 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c
@@ -21,61 +21,112 @@
  */
 #include "udisp.h"
 #include "ucaps.h"
-#include "chan.h"
+#include "uchan.h"
 #include "uconn.h"
 #include "uhead.h"
 #include "uoutp.h"
+#include <subdev/mmu/umem.h>
 
-#include <nvif/class.h>
+static int
+nvkm_udisp_chan_new(struct nvif_disp_priv *udisp, const struct nvkm_disp_func_chan *func,
+		    u8 nr, u8 id, struct nvif_mem_priv *umem,
+		    const struct nvif_disp_chan_impl **pimpl, struct nvif_disp_chan_priv **ppriv,
+		    u64 handle)
+{
+	struct nvkm_memory *memory = NULL;
+	struct nvkm_object *object;
+	int ret;
+
+	if (id >= nr)
+		return -EINVAL;
+
+	if (umem)
+		memory = nvkm_umem_ref(umem);
+
+	ret = nvkm_disp_chan_new(udisp->disp, func, id, memory, pimpl, ppriv, &object);
+	nvkm_memory_unref(&memory);
+	if (ret)
+		return ret;
+
+	if (handle)
+		return nvkm_object_link_rb(udisp->object.client, &udisp->object, handle, object);
+
+	nvkm_object_link(&udisp->object, object);
+	return 0;
+}
 
 static int
-nvkm_udisp_sclass(struct nvkm_object *object, int index, struct nvkm_oclass *sclass)
+nvkm_udisp_oimm_new(struct nvif_disp_priv *udisp, u8 id,
+		    const struct nvif_disp_chan_impl **pimpl, struct nvif_disp_chan_priv **ppriv)
 {
-	struct nvkm_disp *disp = container_of(object, struct nvif_disp_priv, object)->disp;
+	struct nvkm_disp *disp = udisp->disp;
 
-	if (disp->func->user.core.oclass && index-- == 0) {
-		sclass->base = (struct nvkm_sclass) { 0, 0, disp->func->user.core.oclass };
-		sclass->ctor = nvkm_disp_core_new;
-		return 0;
-	}
+	return nvkm_udisp_chan_new(udisp, &disp->func->user.oimm, disp->head.nr, id, NULL,
+				   pimpl, ppriv, 0);
+}
 
-	if (disp->func->user.base.oclass && index-- == 0) {
-		sclass->base = (struct nvkm_sclass) { 0, 0, disp->func->user.base.oclass };
-		sclass->ctor = nvkm_disp_chan_new;
-		return 0;
-	}
+static int
+nvkm_udisp_curs_new(struct nvif_disp_priv *udisp, u8 id,
+		    const struct nvif_disp_chan_impl **pimpl, struct nvif_disp_chan_priv **ppriv)
+{
+	struct nvkm_disp *disp = udisp->disp;
 
-	if (disp->func->user.ovly.oclass && index-- == 0) {
-		sclass->base = (struct nvkm_sclass) { 0, 0, disp->func->user.ovly.oclass };
-		sclass->ctor = nvkm_disp_chan_new;
-		return 0;
-	}
+	return nvkm_udisp_chan_new(udisp, &disp->func->user.curs, disp->head.nr, id, NULL,
+				   pimpl, ppriv, 0);
+}
 
-	if (disp->func->user.curs.oclass && index-- == 0) {
-		sclass->base = (struct nvkm_sclass) { 0, 0, disp->func->user.curs.oclass };
-		sclass->ctor = nvkm_disp_chan_new;
-		return 0;
-	}
+static int
+nvkm_udisp_wimm_new(struct nvif_disp_priv *udisp, u8 id, struct nvif_mem_priv *umem,
+		    const struct nvif_disp_chan_impl **pimpl, struct nvif_disp_chan_priv **ppriv,
+		    u64 handle)
+{
+	struct nvkm_disp *disp = udisp->disp;
 
-	if (disp->func->user.oimm.oclass && index-- == 0) {
-		sclass->base = (struct nvkm_sclass) { 0, 0, disp->func->user.oimm.oclass };
-		sclass->ctor = nvkm_disp_chan_new;
-		return 0;
-	}
+	return nvkm_udisp_chan_new(udisp, &disp->func->user.wimm, disp->wndw.nr, id, umem,
+				   pimpl, ppriv, 0);
+}
 
-	if (disp->func->user.wndw.oclass && index-- == 0) {
-		sclass->base = (struct nvkm_sclass) { 0, 0, disp->func->user.wndw.oclass };
-		sclass->ctor = nvkm_disp_wndw_new;
-		return 0;
-	}
+static int
+nvkm_udisp_wndw_new(struct nvif_disp_priv *udisp, u8 id, struct nvif_mem_priv *umem,
+		    const struct nvif_disp_chan_impl **pimpl, struct nvif_disp_chan_priv **ppriv,
+		    u64 handle)
+{
+	struct nvkm_disp *disp = udisp->disp;
 
-	if (disp->func->user.wimm.oclass && index-- == 0) {
-		sclass->base = (struct nvkm_sclass) { 0, 0, disp->func->user.wimm.oclass };
-		sclass->ctor = nvkm_disp_wndw_new;
-		return 0;
-	}
+	return nvkm_udisp_chan_new(udisp, &disp->func->user.wndw, disp->wndw.nr, id, umem,
+				   pimpl, ppriv, handle);
+}
+
+static int
+nvkm_udisp_ovly_new(struct nvif_disp_priv *udisp, u8 id, struct nvif_mem_priv *umem,
+		    const struct nvif_disp_chan_impl **pimpl, struct nvif_disp_chan_priv **ppriv,
+		    u64 handle)
+{
+	struct nvkm_disp *disp = udisp->disp;
+
+	return nvkm_udisp_chan_new(udisp, &disp->func->user.ovly, disp->head.nr, id, umem,
+				   pimpl, ppriv, handle);
+}
+
+static int
+nvkm_udisp_base_new(struct nvif_disp_priv *udisp, u8 id, struct nvif_mem_priv *umem,
+		    const struct nvif_disp_chan_impl **pimpl, struct nvif_disp_chan_priv **ppriv,
+		    u64 handle)
+{
+	struct nvkm_disp *disp = udisp->disp;
+
+	return nvkm_udisp_chan_new(udisp, &disp->func->user.base, disp->head.nr, id, umem,
+				   pimpl, ppriv, handle);
+}
+
+static int
+nvkm_udisp_core_new(struct nvif_disp_priv *udisp, struct nvif_mem_priv *umem,
+		    const struct nvif_disp_chan_impl **pimpl, struct nvif_disp_chan_priv **ppriv,
+		    u64 handle)
+{
+	struct nvkm_disp *disp = udisp->disp;
 
-	return -EINVAL;
+	return nvkm_udisp_chan_new(udisp, &disp->func->user.core, 1, 0, umem, pimpl, ppriv, handle);
 }
 
 static int
@@ -173,7 +224,6 @@ nvkm_udisp_dtor(struct nvkm_object *object)
 static const struct nvkm_object_func
 nvkm_udisp = {
 	.dtor = nvkm_udisp_dtor,
-	.sclass = nvkm_udisp_sclass,
 };
 
 int
@@ -227,17 +277,24 @@ nvkm_udisp_new(struct nvkm_device *device, const struct nvif_disp_impl **pimpl,
 
 	if (disp->func->user.core.oclass) {
 		udisp->impl.chan.core.oclass = disp->func->user.core.oclass;
+		udisp->impl.chan.core.new = nvkm_udisp_core_new;
 		udisp->impl.chan.curs.oclass = disp->func->user.curs.oclass;
+		udisp->impl.chan.curs.new = nvkm_udisp_curs_new;
 
 		if (!disp->func->user.wndw.oclass) {
 			/* EVO */
 			udisp->impl.chan.base.oclass = disp->func->user.base.oclass;
+			udisp->impl.chan.base.new = nvkm_udisp_base_new;
 			udisp->impl.chan.ovly.oclass = disp->func->user.ovly.oclass;
+			udisp->impl.chan.ovly.new = nvkm_udisp_ovly_new;
 			udisp->impl.chan.oimm.oclass = disp->func->user.oimm.oclass;
+			udisp->impl.chan.oimm.new = nvkm_udisp_oimm_new;
 		} else {
 			/* NVDisplay (GV100-) */
 			udisp->impl.chan.wndw.oclass = disp->func->user.wndw.oclass;
+			udisp->impl.chan.wndw.new = nvkm_udisp_wndw_new;
 			udisp->impl.chan.wimm.oclass = disp->func->user.wimm.oclass;
+			udisp->impl.chan.wimm.new = nvkm_udisp_wimm_new;
 		}
 	}
 
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 131/156] drm/nouveau/nvif: remove disp from object rb
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (129 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 130/156] drm/nouveau/nvif: rework disp "new chan" apis Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 132/156] drm/nouveau/nvif: rework disp chan "new ctxdma" api Ben Skeggs
                   ` (26 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- no more users

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/include/nvif/driverif.h | 3 +--
 drivers/gpu/drm/nouveau/nvif/disp.c             | 3 +--
 drivers/gpu/drm/nouveau/nvkm/device/user.c      | 6 +++---
 3 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 60a3529a6594..d317fcd29091 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -484,8 +484,7 @@ struct nvif_device_impl {
 	struct {
 		s32 oclass;
 		int (*new)(struct nvif_device_priv *,
-			   const struct nvif_disp_impl **, struct nvif_disp_priv **,
-			   u64 handle);
+			   const struct nvif_disp_impl **, struct nvif_disp_priv **);
 	} disp;
 
 	struct nvif_device_impl_fifo {
diff --git a/drivers/gpu/drm/nouveau/nvif/disp.c b/drivers/gpu/drm/nouveau/nvif/disp.c
index d2824e4d29f8..b0c4fae39b18 100644
--- a/drivers/gpu/drm/nouveau/nvif/disp.c
+++ b/drivers/gpu/drm/nouveau/nvif/disp.c
@@ -97,8 +97,7 @@ nvif_disp_ctor(struct nvif_device *device, const char *name, struct nvif_disp *d
 		return -ENODEV;
 	}
 
-	ret = device->impl->disp.new(device->priv, &disp->impl, &disp->priv,
-				     nvif_handle(&disp->object));
+	ret = device->impl->disp.new(device->priv, &disp->impl, &disp->priv);
 	NVIF_ERRON(ret, &device->object, "[NEW disp%04x]", oclass);
 	if (ret)
 		return ret;
diff --git a/drivers/gpu/drm/nouveau/nvkm/device/user.c b/drivers/gpu/drm/nouveau/nvkm/device/user.c
index 3c7c0d1e6adb..6a3b41004abd 100644
--- a/drivers/gpu/drm/nouveau/nvkm/device/user.c
+++ b/drivers/gpu/drm/nouveau/nvkm/device/user.c
@@ -96,8 +96,7 @@ nvkm_udevice_time(struct nvif_device_priv *udev)
 
 static int
 nvkm_udevice_disp_new(struct nvif_device_priv *udev,
-		      const struct nvif_disp_impl **pimpl, struct nvif_disp_priv **ppriv,
-		      u64 handle)
+		      const struct nvif_disp_impl **pimpl, struct nvif_disp_priv **ppriv)
 {
 	struct nvkm_object *object;
 	int ret;
@@ -106,7 +105,8 @@ nvkm_udevice_disp_new(struct nvif_device_priv *udev,
 	if (ret)
 		return ret;
 
-	return nvkm_object_link_rb(udev->object.client, &udev->object, handle, object);
+	nvkm_object_link(&udev->object, object);
+	return 0;
 }
 
 static int
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 132/156] drm/nouveau/nvif: rework disp chan "new ctxdma" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (130 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 131/156] drm/nouveau/nvif: remove disp from object rb Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 133/156] drm/nouveau/nvif: remove disp chans from object rb Ben Skeggs
                   ` (25 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interface

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/dispnv50/core.c       | 36 ++++----
 drivers/gpu/drm/nouveau/dispnv50/core.h       |  5 +-
 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/crc.c        | 22 +++--
 drivers/gpu/drm/nouveau/dispnv50/crc.h        |  3 +-
 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/curs507a.c   |  2 +-
 drivers/gpu/drm/nouveau/dispnv50/head.c       |  2 +-
 drivers/gpu/drm/nouveau/dispnv50/head507d.c   |  2 +-
 drivers/gpu/drm/nouveau/dispnv50/wndw.c       | 50 +++++------
 drivers/gpu/drm/nouveau/dispnv50/wndw.h       |  8 +-
 drivers/gpu/drm/nouveau/include/nvif/ctxdma.h | 29 ++++++
 .../gpu/drm/nouveau/include/nvif/dispchan.h   |  4 +
 .../gpu/drm/nouveau/include/nvif/driverif.h   | 13 +++
 drivers/gpu/drm/nouveau/nvif/dispchan.c       | 17 ++++
 .../gpu/drm/nouveau/nvkm/engine/disp/chan.c   | 89 ++++++++++---------
 .../gpu/drm/nouveau/nvkm/engine/dma/user.c    |  6 --
 .../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 --
 25 files changed, 181 insertions(+), 144 deletions(-)
 create mode 100644 drivers/gpu/drm/nouveau/include/nvif/ctxdma.h

diff --git a/drivers/gpu/drm/nouveau/dispnv50/core.c b/drivers/gpu/drm/nouveau/dispnv50/core.c
index 98ccb67fc95b..3306220003ac 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/core.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/core.c
@@ -32,8 +32,8 @@ nv50_core_del(struct nv50_core **pcore)
 {
 	struct nv50_core *core = *pcore;
 	if (core) {
-		nvif_object_dtor(&core->sync);
-		nvif_object_dtor(&core->vram);
+		nvif_ctxdma_dtor(&core->vram);
+		nvif_ctxdma_dtor(&core->sync);
 		nvif_dispchan_dtor(&core->chan);
 		kfree(*pcore);
 		*pcore = NULL;
@@ -75,27 +75,23 @@ nv50_core_new(struct nouveau_drm *drm, struct nv50_core **pcore)
 	if (ret)
 		return ret;
 
-	ret = nvif_object_ctor(&core->chan.object, "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);
+	ret = nvif_dispchan_ctxdma_ctor(&core->chan, "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.object, "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);
+	ret = nvif_dispchan_ctxdma_ctor(&core->chan, "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.impl->ram_user - 1,
+					}, sizeof(struct nv_dma_v0), &core->vram);
 	if (ret)
 		return ret;
 
diff --git a/drivers/gpu/drm/nouveau/dispnv50/core.h b/drivers/gpu/drm/nouveau/dispnv50/core.h
index 1343a1d224c0..f9223764a1f5 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/core.h
+++ b/drivers/gpu/drm/nouveau/dispnv50/core.h
@@ -5,14 +5,15 @@
 #include "crc.h"
 #include <nouveau_encoder.h>
 
+#include <nvif/ctxdma.h>
 #include <nvif/dispchan.h>
 
 struct nv50_core {
 	const struct nv50_core_func *func;
 	struct nvif_dispchan chan;
 
-	struct nvif_object vram;
-	struct nvif_object sync;
+	struct nvif_ctxdma sync;
+	struct nvif_ctxdma vram;
 
 	bool assign_windows;
 };
diff --git a/drivers/gpu/drm/nouveau/dispnv50/core507d.c b/drivers/gpu/drm/nouveau/dispnv50/core507d.c
index dab9fb984765..4127bc05ea80 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/core507d.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/core507d.c
@@ -135,7 +135,7 @@ core507d_init(struct nv50_core *core)
 	if ((ret = PUSH_WAIT(push, 2)))
 		return ret;
 
-	PUSH_MTHD(push, NV507D, SET_CONTEXT_DMA_NOTIFIER, core->sync.handle);
+	PUSH_MTHD(push, NV507D, SET_CONTEXT_DMA_NOTIFIER, core->sync.object.handle);
 	return PUSH_KICK(push);
 }
 
diff --git a/drivers/gpu/drm/nouveau/dispnv50/corec37d.c b/drivers/gpu/drm/nouveau/dispnv50/corec37d.c
index 60535526ac89..7e666c07e96a 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/corec37d.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/corec37d.c
@@ -125,7 +125,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->sync.handle);
+	PUSH_MTHD(push, NVC37D, SET_CONTEXT_DMA_NOTIFIER, core->sync.object.handle);
 
 	for (i = 0; i < windows; i++) {
 		PUSH_MTHD(push, NVC37D, WINDOW_SET_WINDOW_FORMAT_USAGE_BOUNDS(i),
diff --git a/drivers/gpu/drm/nouveau/dispnv50/corec57d.c b/drivers/gpu/drm/nouveau/dispnv50/corec57d.c
index 485892c2e775..e522c1e43a64 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/corec57d.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/corec57d.c
@@ -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->sync.handle);
+	PUSH_MTHD(push, NVC57D, SET_CONTEXT_DMA_NOTIFIER, core->sync.object.handle);
 
 	for (i = 0; i < windows; i++) {
 		PUSH_MTHD(push, NVC57D, WINDOW_SET_WINDOW_FORMAT_USAGE_BOUNDS(i),
diff --git a/drivers/gpu/drm/nouveau/dispnv50/crc.c b/drivers/gpu/drm/nouveau/dispnv50/crc.c
index 72ce4ada284f..97905ec648d0 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/crc.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/crc.c
@@ -507,17 +507,15 @@ nv50_crc_ctx_init(struct nv50_head *head, struct nvif_mmu *mmu,
 	if (ret)
 		return ret;
 
-	ret = nvif_object_ctor(&core->chan.object, "kmsCrcNtfyCtxDma",
-			       NV50_DISP_HANDLE_CRC_CTX(head, idx),
-			       NV_DMA_IN_MEMORY,
-			       (&(struct nv_dma_v0) {
-					.target = NV_DMA_V0_TARGET_VRAM,
-					.access = NV_DMA_V0_ACCESS_RDWR,
-					.start = ctx->mem.impl->addr,
-					.limit =  ctx->mem.impl->addr
-						+ ctx->mem.impl->size - 1,
-			       }), sizeof(struct nv_dma_v0),
-			       &ctx->ntfy);
+	ret = nvif_dispchan_ctxdma_ctor(&core->chan, "kmsCrcNtfyCtxDma",
+					NV50_DISP_HANDLE_CRC_CTX(head, idx),
+					NV_DMA_IN_MEMORY, &(struct nv_dma_v0) {
+						.target = NV_DMA_V0_TARGET_VRAM,
+						.access = NV_DMA_V0_ACCESS_RDWR,
+						.start = ctx->mem.impl->addr,
+						.limit = ctx->mem.impl->addr +
+							 ctx->mem.impl->size - 1,
+					}, sizeof(struct nv_dma_v0), &ctx->ntfy);
 	if (ret)
 		goto fail_fini;
 
@@ -531,7 +529,7 @@ nv50_crc_ctx_init(struct nv50_head *head, struct nvif_mmu *mmu,
 static inline void
 nv50_crc_ctx_fini(struct nv50_crc_notifier_ctx *ctx)
 {
-	nvif_object_dtor(&ctx->ntfy);
+	nvif_ctxdma_dtor(&ctx->ntfy);
 	nvif_mem_unmap_dtor(&ctx->mem, &ctx->map);
 }
 
diff --git a/drivers/gpu/drm/nouveau/dispnv50/crc.h b/drivers/gpu/drm/nouveau/dispnv50/crc.h
index 48564ceddb97..2b722135af87 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/crc.h
+++ b/drivers/gpu/drm/nouveau/dispnv50/crc.h
@@ -6,6 +6,7 @@
 #include <drm/drm_crtc.h>
 #include <drm/drm_vblank_work.h>
 
+#include <nvif/ctxdma.h>
 #include <nvif/mem.h>
 #include <nvkm/subdev/bios.h>
 #include "nouveau_encoder.h"
@@ -41,7 +42,7 @@ enum nv50_crc_source_type {
 struct nv50_crc_notifier_ctx {
 	struct nvif_mem mem;
 	struct nvif_map map;
-	struct nvif_object ntfy;
+	struct nvif_ctxdma ntfy;
 };
 
 struct nv50_crc_atom {
diff --git a/drivers/gpu/drm/nouveau/dispnv50/crc907d.c b/drivers/gpu/drm/nouveau/dispnv50/crc907d.c
index 998978967c4c..0da9ed49017e 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/crc907d.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/crc907d.c
@@ -61,7 +61,7 @@ crc907d_set_src(struct nv50_head *head, int or, enum nv50_crc_source_type source
 		return ret;
 
 	if (source) {
-		PUSH_MTHD(push, NV907D, HEAD_SET_CONTEXT_DMA_CRC(i), ctx->ntfy.handle);
+		PUSH_MTHD(push, NV907D, HEAD_SET_CONTEXT_DMA_CRC(i), ctx->ntfy.object.handle);
 		PUSH_MTHD(push, NV907D, HEAD_SET_CRC_CONTROL(i), crc_args);
 	} else {
 		PUSH_MTHD(push, NV907D, HEAD_SET_CRC_CONTROL(i), crc_args);
@@ -81,7 +81,7 @@ crc907d_set_ctx(struct nv50_head *head, struct nv50_crc_notifier_ctx *ctx)
 	if ((ret = PUSH_WAIT(push, 2)))
 		return ret;
 
-	PUSH_MTHD(push, NV907D, HEAD_SET_CONTEXT_DMA_CRC(i), ctx ? ctx->ntfy.handle : 0);
+	PUSH_MTHD(push, NV907D, HEAD_SET_CONTEXT_DMA_CRC(i), ctx ? ctx->ntfy.object.handle : 0);
 	return 0;
 }
 
diff --git a/drivers/gpu/drm/nouveau/dispnv50/crcc37d.c b/drivers/gpu/drm/nouveau/dispnv50/crcc37d.c
index 6af15f3232d9..87d54616cb11 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/crcc37d.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/crcc37d.c
@@ -41,7 +41,7 @@ crcc37d_set_src(struct nv50_head *head, int or, enum nv50_crc_source_type source
 		return ret;
 
 	if (source) {
-		PUSH_MTHD(push, NVC37D, HEAD_SET_CONTEXT_DMA_CRC(i), ctx->ntfy.handle);
+		PUSH_MTHD(push, NVC37D, HEAD_SET_CONTEXT_DMA_CRC(i), ctx->ntfy.object.handle);
 		PUSH_MTHD(push, NVC37D, HEAD_SET_CRC_CONTROL(i), crc_args);
 	} else {
 		PUSH_MTHD(push, NVC37D, HEAD_SET_CRC_CONTROL(i), 0);
@@ -60,7 +60,7 @@ int crcc37d_set_ctx(struct nv50_head *head, struct nv50_crc_notifier_ctx *ctx)
 	if ((ret = PUSH_WAIT(push, 2)))
 		return ret;
 
-	PUSH_MTHD(push, NVC37D, HEAD_SET_CONTEXT_DMA_CRC(i), ctx ? ctx->ntfy.handle : 0);
+	PUSH_MTHD(push, NVC37D, HEAD_SET_CONTEXT_DMA_CRC(i), ctx ? ctx->ntfy.object.handle : 0);
 	return 0;
 }
 
diff --git a/drivers/gpu/drm/nouveau/dispnv50/crcc57d.c b/drivers/gpu/drm/nouveau/dispnv50/crcc57d.c
index ad591dcb0bc9..803275a3dd31 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/crcc57d.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/crcc57d.c
@@ -37,7 +37,7 @@ static int crcc57d_set_src(struct nv50_head *head, int or, enum nv50_crc_source_
 		return ret;
 
 	if (source) {
-		PUSH_MTHD(push, NVC57D, HEAD_SET_CONTEXT_DMA_CRC(i), ctx->ntfy.handle);
+		PUSH_MTHD(push, NVC57D, HEAD_SET_CONTEXT_DMA_CRC(i), ctx->ntfy.object.handle);
 		PUSH_MTHD(push, NVC57D, HEAD_SET_CRC_CONTROL(i), crc_args);
 	} else {
 		PUSH_MTHD(push, NVC57D, HEAD_SET_CRC_CONTROL(i), 0);
diff --git a/drivers/gpu/drm/nouveau/dispnv50/curs507a.c b/drivers/gpu/drm/nouveau/dispnv50/curs507a.c
index 8017cd0bd636..58bfaf036bbb 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/curs507a.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/curs507a.c
@@ -77,7 +77,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->vram.handle;
+	u32 handle = nv50_disp(wndw->plane.dev)->core->vram.object.handle;
 	u32 offset = asyw->image.offset[0];
 	if (asyh->curs.handle != handle || asyh->curs.offset != offset) {
 		asyh->curs.handle = handle;
diff --git a/drivers/gpu/drm/nouveau/dispnv50/head.c b/drivers/gpu/drm/nouveau/dispnv50/head.c
index 007857ac8542..3a192dd8635a 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/head.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/head.c
@@ -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->vram.handle;
+	asyh->olut.handle = disp->core->vram.object.handle;
 	asyh->olut.buffer = !asyh->olut.buffer;
 
 	return 0;
diff --git a/drivers/gpu/drm/nouveau/dispnv50/head507d.c b/drivers/gpu/drm/nouveau/dispnv50/head507d.c
index 634f6166f38d..dc3847f1f1dc 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/head507d.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/head507d.c
@@ -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->vram.handle;
+	asyh->core.handle = disp->core->vram.object.handle;
 	asyh->core.offset = 0;
 	asyh->core.format = NV507D_HEAD_SET_PARAMS_FORMAT_A8R8G8B8;
 	asyh->core.kind = NV507D_HEAD_SET_PARAMS_KIND_KIND_PITCH;
diff --git a/drivers/gpu/drm/nouveau/dispnv50/wndw.c b/drivers/gpu/drm/nouveau/dispnv50/wndw.c
index 9cab8d20bc68..1e6e27782ce8 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/wndw.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/wndw.c
@@ -42,7 +42,7 @@
 static void
 nv50_wndw_ctxdma_del(struct nv50_wndw_ctxdma *ctxdma)
 {
-	nvif_object_dtor(&ctxdma->object);
+	nvif_ctxdma_dtor(&ctxdma->ctxdma);
 	list_del(&ctxdma->head);
 	kfree(ctxdma);
 }
@@ -70,7 +70,7 @@ nv50_wndw_ctxdma_new(struct nv50_wndw *wndw, struct drm_framebuffer *fb)
 	handle = NV50_DISP_HANDLE_WNDW_CTX(kind);
 
 	list_for_each_entry(ctxdma, &wndw->ctxdma.list, head) {
-		if (ctxdma->object.handle == handle)
+		if (ctxdma->ctxdma.object.handle == handle)
 			return ctxdma;
 	}
 
@@ -101,8 +101,8 @@ nv50_wndw_ctxdma_new(struct nv50_wndw *wndw, struct drm_framebuffer *fb)
 		argc += sizeof(args.gf119);
 	}
 
-	ret = nvif_object_ctor(wndw->ctxdma.parent, "kmsFbCtxDma", handle,
-			       NV_DMA_IN_MEMORY, &args, argc, &ctxdma->object);
+	ret = nvif_dispchan_ctxdma_ctor(&wndw->wndw, "kmsFbCtxDma", handle, NV_DMA_IN_MEMORY,
+					&args.base, argc, &ctxdma->ctxdma);
 	if (ret) {
 		nv50_wndw_ctxdma_del(ctxdma);
 		return ERR_PTR(ret);
@@ -181,7 +181,7 @@ nv50_wndw_ntfy_enable(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
 {
 	struct nv50_disp *disp = nv50_disp(wndw->plane.dev);
 
-	asyw->ntfy.handle = wndw->sync.handle;
+	asyw->ntfy.handle = wndw->sync.object.handle;
 	asyw->ntfy.offset = wndw->ntfy;
 	asyw->ntfy.awaken = false;
 	asyw->set.ntfy = true;
@@ -406,7 +406,7 @@ nv50_wndw_atomic_check_lut(struct nv50_wndw *wndw,
 	memset(&asyw->xlut, 0x00, sizeof(asyw->xlut));
 	if ((asyw->ilut = wndw->func->ilut ? ilut : NULL)) {
 		wndw->func->ilut(wndw, asyw, drm_color_lut_size(ilut));
-		asyw->xlut.handle = wndw->vram.handle;
+		asyw->xlut.handle = wndw->vram.object.handle;
 		asyw->xlut.i.buffer = !asyw->xlut.i.buffer;
 		asyw->set.xlut = true;
 	} else {
@@ -557,7 +557,7 @@ nv50_wndw_prepare_fb(struct drm_plane *plane, struct drm_plane_state *state)
 		}
 
 		if (asyw->visible)
-			asyw->image.handle[0] = ctxdma->object.handle;
+			asyw->image.handle[0] = ctxdma->ctxdma.object.handle;
 	}
 
 	ret = drm_gem_plane_helper_prepare_fb(plane, state);
@@ -646,8 +646,8 @@ nv50_wndw_destroy(struct drm_plane *plane)
 
 	nvif_dispchan_dtor(&wndw->wimm);
 
-	nvif_object_dtor(&wndw->vram);
-	nvif_object_dtor(&wndw->sync);
+	nvif_ctxdma_dtor(&wndw->vram);
+	nvif_ctxdma_dtor(&wndw->sync);
 	nvif_dispchan_dtor(&wndw->wndw);
 
 	nv50_lut_fini(&wndw->ilut);
@@ -705,27 +705,23 @@ nv50_wndw_ctor(struct nv50_wndw *wndw)
 	if (!wndw->wndw.impl)
 		return 0;
 
-	ret = nvif_object_ctor(&wndw->wndw.object, "kmsWndwSyncCtxDma", 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),
-			       &wndw->sync);
+	ret = nvif_dispchan_ctxdma_ctor(&wndw->wndw, "kmsWndwSyncCtxdma", 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), &wndw->sync);
 	if (ret)
 		return ret;
 
-	ret = nvif_object_ctor(&wndw->wndw.object, "kmsWndwVramCtxDma", 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),
-			       &wndw->vram);
+	ret = nvif_dispchan_ctxdma_ctor(&wndw->wndw, "kmsWndwVramCtxdma", 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.impl->ram_user - 1,
+					}, sizeof(struct nv_dma_v0), &wndw->vram);
 	if (ret)
 		return ret;
 
diff --git a/drivers/gpu/drm/nouveau/dispnv50/wndw.h b/drivers/gpu/drm/nouveau/dispnv50/wndw.h
index 68092e6445fa..3efad1f3282f 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/wndw.h
+++ b/drivers/gpu/drm/nouveau/dispnv50/wndw.h
@@ -5,11 +5,13 @@
 #include "atom.h"
 #include "lut.h"
 
+#include <nvif/ctxdma.h>
 #include <nvif/dispchan.h>
 
 struct nv50_wndw_ctxdma {
 	struct list_head head;
-	struct nvif_object object;
+
+	struct nvif_ctxdma ctxdma;
 };
 
 struct nv50_wndw {
@@ -30,8 +32,8 @@ struct nv50_wndw {
 	struct nvif_dispchan wndw;
 	struct nvif_dispchan wimm;
 
-	struct nvif_object vram;
-	struct nvif_object sync;
+	struct nvif_ctxdma vram;
+	struct nvif_ctxdma sync;
 
 	u16 ntfy;
 	u16 sema;
diff --git a/drivers/gpu/drm/nouveau/include/nvif/ctxdma.h b/drivers/gpu/drm/nouveau/include/nvif/ctxdma.h
new file mode 100644
index 000000000000..ff80db834bd1
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/include/nvif/ctxdma.h
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: MIT */
+#ifndef __NVIF_CTXDMA_H__
+#define __NVIF_CTXDMA_H__
+#include <nvif/object.h>
+#include <nvif/driverif.h>
+
+struct nvif_ctxdma {
+	const struct nvif_ctxdma_impl *impl;
+	struct nvif_ctxdma_priv *priv;
+	struct nvif_object object;
+};
+
+static inline void
+nvif_ctxdma_ctor(struct nvif_object *parent, const char *name, u32 handle, s32 oclass,
+		 struct nvif_ctxdma *ctxdma)
+{
+	nvif_object_ctor(parent, name, handle, oclass, &ctxdma->object);
+}
+
+static inline void
+nvif_ctxdma_dtor(struct nvif_ctxdma *ctxdma)
+{
+	if (!ctxdma->impl)
+		return;
+
+	ctxdma->impl->del(ctxdma->priv);
+	ctxdma->impl = NULL;
+}
+#endif
diff --git a/drivers/gpu/drm/nouveau/include/nvif/dispchan.h b/drivers/gpu/drm/nouveau/include/nvif/dispchan.h
index b1d3503e054c..d76eb35bc1c6 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/dispchan.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/dispchan.h
@@ -3,6 +3,7 @@
 #define __NVIF_DISPCHAN_H__
 #include "disp.h"
 #include "push.h"
+struct nvif_ctxdma;
 
 struct nvif_dispchan {
 	const struct nvif_disp_chan_impl *impl;
@@ -18,4 +19,7 @@ int nvif_dispchan_ctor(struct nvif_disp *, const char *name, u32 handle, s32 ocl
 		       struct nvif_mmu *, struct nvif_dispchan *);
 int nvif_dispchan_oneinit(struct nvif_dispchan *);
 void nvif_dispchan_dtor(struct nvif_dispchan *);
+
+int nvif_dispchan_ctxdma_ctor(struct nvif_dispchan *, const char *name, u32 handle, s32 oclass,
+			      void *argv, u32 argc, struct nvif_ctxdma *ctxdma);
 #endif
diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index d317fcd29091..8ae50be82a02 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -18,6 +18,7 @@ struct nvif_conn_priv;
 struct nvif_outp_priv;
 struct nvif_head_priv;
 struct nvif_disp_chan_priv;
+struct nvif_ctxdma_priv;
 
 struct nvif_driver {
 	const char *name;
@@ -361,9 +362,21 @@ struct nvif_head_impl {
 		      const struct nvif_event_impl **, struct nvif_event_priv **);
 };
 
+#include <nvif/cl0002.h>
+
+struct nvif_ctxdma_impl {
+	void (*del)(struct nvif_ctxdma_priv *);
+};
+
 struct nvif_disp_chan_impl {
 	void (*del)(struct nvif_disp_chan_priv *);
 	struct nvif_mapinfo map;
+
+	struct {
+		int (*new)(struct nvif_disp_chan_priv *, u32 handle, s32 oclass,
+			   struct nv_dma_v0 *argv, u32 argc,
+			   const struct nvif_ctxdma_impl **, struct nvif_ctxdma_priv **);
+	} ctxdma;
 };
 
 struct nvif_disp_impl {
diff --git a/drivers/gpu/drm/nouveau/nvif/dispchan.c b/drivers/gpu/drm/nouveau/nvif/dispchan.c
index fc4f50da1a43..03738de5d791 100644
--- a/drivers/gpu/drm/nouveau/nvif/dispchan.c
+++ b/drivers/gpu/drm/nouveau/nvif/dispchan.c
@@ -20,6 +20,7 @@
  * DEALINGS IN THE SOFTWARE.
  */
 #include <nvif/dispchan.h>
+#include <nvif/ctxdma.h>
 #include <nvif/device.h>
 #include <nvif/driverif.h>
 #include <nvif/push507c.h>
@@ -28,6 +29,22 @@
 #include <nvif/class.h>
 #include <nvhw/class/cl507c.h>
 
+int
+nvif_dispchan_ctxdma_ctor(struct nvif_dispchan *chan, const char *name, u32 handle, s32 oclass,
+			  void *argv, u32 argc, struct nvif_ctxdma *ctxdma)
+{
+	int ret;
+
+	ret = chan->impl->ctxdma.new(chan->priv, handle, oclass, argv, argc,
+				     &ctxdma->impl, &ctxdma->priv);
+	NVIF_ERRON(ret, &chan->object, "[NEW ctxdma%04x handle:%08x]", oclass, handle);
+	if (ret)
+		return ret;
+
+	nvif_ctxdma_ctor(&chan->object, name ?: "nvifDispChanCtxdma", handle, oclass, ctxdma);
+	return 0;
+}
+
 static int
 nvif_dispchan_kick(struct nvif_push *push)
 {
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/chan.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/chan.c
index 3a0366420248..4a59c187b76c 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/chan.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/chan.c
@@ -49,77 +49,83 @@ nvkm_disp_chan_ntfy(struct nvkm_object *object, u32 type, struct nvkm_event **pe
 	return -EINVAL;
 }
 
-struct nvkm_disp_chan_object {
+struct nvif_ctxdma_priv {
 	struct nvkm_oproxy oproxy;
 	struct nvkm_disp *disp;
 	int hash;
 };
 
 static void
-nvkm_disp_chan_child_del_(struct nvkm_oproxy *base)
+nvkm_disp_chan_ctxdma_del(struct nvif_ctxdma_priv *ctxdma)
 {
-	struct nvkm_disp_chan_object *object = container_of(base, typeof(*object), oproxy);
+	struct nvkm_object *object = &ctxdma->oproxy.base;
+
+	nvkm_object_del(&object);
+}
+
+static const struct nvif_ctxdma_impl
+nvkm_disp_chan_ctxdma_impl = {
+	.del = nvkm_disp_chan_ctxdma_del,
+};
+
+static void
+nvkm_disp_chan_ctxdma_dtor(struct nvkm_oproxy *base)
+{
+	struct nvif_ctxdma_priv *object = container_of(base, typeof(*object), oproxy);
 
 	nvkm_ramht_remove(object->disp->ramht, object->hash);
 }
 
 static const struct nvkm_oproxy_func
-nvkm_disp_chan_child_func_ = {
-	.dtor[0] = nvkm_disp_chan_child_del_,
+nvkm_disp_chan_ctxdma = {
+	.dtor[0] = nvkm_disp_chan_ctxdma_dtor,
 };
 
+#include <engine/dma/priv.h>
+
 static int
-nvkm_disp_chan_child_new(const struct nvkm_oclass *oclass, void *argv, u32 argc,
-			 struct nvkm_object **pobject)
+nvkm_disp_chan_ctxdma_new(struct nvif_disp_chan_priv *uchan, u32 handle, s32 oclass,
+			  struct nv_dma_v0 *args, u32 argc,
+			  const struct nvif_ctxdma_impl **pimpl, struct nvif_ctxdma_priv **ppriv)
 {
-	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;
-	struct nvkm_disp_chan_object *object;
+	struct nvkm_dma *dma = device->dma;
+	struct nvkm_dmaobj *dmaobj;
+	struct nvif_ctxdma_priv *object;
 	int ret;
 
 	if (!(object = kzalloc(sizeof(*object), GFP_KERNEL)))
 		return -ENOMEM;
-	nvkm_oproxy_ctor(&nvkm_disp_chan_child_func_, oclass, &object->oproxy);
+
+	nvkm_oproxy_ctor(&nvkm_disp_chan_ctxdma, &(struct nvkm_oclass) {}, &object->oproxy);
 	object->disp = disp;
-	*pobject = &object->oproxy.base;
 
-	ret = sclass->ctor(device, oclass, argv, argc, &object->oproxy.object);
+	ret = dma->func->class_new(dma, &(struct nvkm_oclass) {
+					.client = uchan->object.client,
+					.base.oclass = oclass
+				   }, args, argc, &dmaobj);
+	object->oproxy.object = &dmaobj->object;
 	if (ret)
-		return ret;
+		goto done;
 
-	object->hash = chan->func->bind(chan, object->oproxy.object, oclass->handle);
-	if (object->hash < 0)
-		return object->hash;
+	object->hash = chan->func->bind(chan, object->oproxy.object, handle);
+	if (object->hash < 0) {
+		ret = object->hash;
+		goto done;
+	}
 
-	return 0;
-}
+	*pimpl = &nvkm_disp_chan_ctxdma_impl;
+	*ppriv = object;
 
-static int
-nvkm_disp_chan_child_get(struct nvkm_object *object, int index, struct nvkm_oclass *sclass)
-{
-	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;
+	nvkm_object_link(&uchan->object, &object->oproxy.base);
 
-	if (chan->func->bind)
-		sclass->engine = nvkm_device_engine(device, NVKM_ENGINE_DMAOBJ, 0);
-	else
-		sclass->engine = NULL;
-
-	if (sclass->engine && sclass->engine->func->base.sclass) {
-		sclass->engine->func->base.sclass(sclass, index, &oclass);
-		if (oclass) {
-			sclass->ctor = nvkm_disp_chan_child_new;
-			sclass->priv = oclass;
-			return 0;
-		}
-	}
+done:
+	if (ret)
+		nvkm_disp_chan_ctxdma_del(object);
 
-	return -EINVAL;
+	return ret;
 }
 
 static void
@@ -179,7 +185,6 @@ nvkm_disp_chan = {
 	.init = nvkm_disp_chan_init,
 	.fini = nvkm_disp_chan_fini,
 	.ntfy = nvkm_disp_chan_ntfy,
-	.sclass = nvkm_disp_chan_child_get,
 };
 
 int
@@ -224,6 +229,8 @@ nvkm_disp_chan_new(struct nvkm_disp *disp, const struct nvkm_disp_func_chan *fun
 	uchan->impl.map.type = NVIF_MAP_IO;
 	uchan->impl.map.handle = device->func->resource_addr(device, 0);
 	uchan->impl.map.handle += chan->func->user(chan, &uchan->impl.map.length);
+	if (chan->func->bind)
+		uchan->impl.ctxdma.new = nvkm_disp_chan_ctxdma_new;
 
 	if (chan->func->push) {
 		chan->memory = nvkm_memory_ref(memory);
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/dma/user.c b/drivers/gpu/drm/nouveau/nvkm/engine/dma/user.c
index 797131ed7d67..463600e4f368 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/dma/user.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/dma/user.c
@@ -71,7 +71,6 @@ nvkm_dmaobj_ctor(const struct nvkm_dmaobj_func *func, struct nvkm_dma *dma,
 	union {
 		struct nv_dma_v0 v0;
 	} *args = *pdata;
-	struct nvkm_object *parent = oclass->parent;
 	void *data = *pdata;
 	u32 size = *psize;
 	int ret = -ENOSYS;
@@ -80,12 +79,7 @@ nvkm_dmaobj_ctor(const struct nvkm_dmaobj_func *func, struct nvkm_dma *dma,
 	dmaobj->func = func;
 	dmaobj->dma = dma;
 
-	nvif_ioctl(parent, "create dma size %d\n", *psize);
 	if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) {
-		nvif_ioctl(parent, "create dma vers %d target %d access %d "
-				   "start %016llx limit %016llx\n",
-			   args->v0.version, args->v0.target, args->v0.access,
-			   args->v0.start, args->v0.limit);
 		dmaobj->target = args->v0.target;
 		dmaobj->access = args->v0.access;
 		dmaobj->start  = args->v0.start;
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/dma/usergf100.c b/drivers/gpu/drm/nouveau/nvkm/engine/dma/usergf100.c
index ef7ac360101e..23f7c275dd3b 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/dma/usergf100.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/dma/usergf100.c
@@ -73,7 +73,6 @@ gf100_dmaobj_new(struct nvkm_dma *dma, const struct nvkm_oclass *oclass,
 	union {
 		struct gf100_dma_v0 v0;
 	} *args;
-	struct nvkm_object *parent = oclass->parent;
 	struct gf100_dmaobj *dmaobj;
 	u32 kind, user, unkn;
 	int ret;
@@ -90,11 +89,7 @@ gf100_dmaobj_new(struct nvkm_dma *dma, const struct nvkm_oclass *oclass,
 	ret  = -ENOSYS;
 	args = data;
 
-	nvif_ioctl(parent, "create gf100 dma size %d\n", size);
 	if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
-		nvif_ioctl(parent,
-			   "create gf100 dma vers %d priv %d kind %02x\n",
-			   args->v0.version, args->v0.priv, args->v0.kind);
 		kind = args->v0.kind;
 		user = args->v0.priv;
 		unkn = 0;
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/dma/usergf119.c b/drivers/gpu/drm/nouveau/nvkm/engine/dma/usergf119.c
index c068cee34588..5b0f3d39c226 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/dma/usergf119.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/dma/usergf119.c
@@ -71,7 +71,6 @@ gf119_dmaobj_new(struct nvkm_dma *dma, const struct nvkm_oclass *oclass,
 	union {
 		struct gf119_dma_v0 v0;
 	} *args;
-	struct nvkm_object *parent = oclass->parent;
 	struct gf119_dmaobj *dmaobj;
 	u32 kind, page;
 	int ret;
@@ -88,11 +87,7 @@ gf119_dmaobj_new(struct nvkm_dma *dma, const struct nvkm_oclass *oclass,
 	ret  = -ENOSYS;
 	args = data;
 
-	nvif_ioctl(parent, "create gf119 dma size %d\n", size);
 	if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
-		nvif_ioctl(parent,
-			   "create gf100 dma vers %d page %d kind %02x\n",
-			   args->v0.version, args->v0.page, args->v0.kind);
 		kind = args->v0.kind;
 		page = args->v0.page;
 	} else
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/dma/usergv100.c b/drivers/gpu/drm/nouveau/nvkm/engine/dma/usergv100.c
index 39eba9fc82be..c027efbcb85b 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/dma/usergv100.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/dma/usergv100.c
@@ -70,7 +70,6 @@ gv100_dmaobj_new(struct nvkm_dma *dma, const struct nvkm_oclass *oclass,
 	union {
 		struct gf119_dma_v0 v0;
 	} *args;
-	struct nvkm_object *parent = oclass->parent;
 	struct gv100_dmaobj *dmaobj;
 	u32 kind, page;
 	int ret;
@@ -87,11 +86,7 @@ gv100_dmaobj_new(struct nvkm_dma *dma, const struct nvkm_oclass *oclass,
 	ret  = -ENOSYS;
 	args = data;
 
-	nvif_ioctl(parent, "create gv100 dma size %d\n", size);
 	if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
-		nvif_ioctl(parent,
-			   "create gv100 dma vers %d page %d kind %02x\n",
-			   args->v0.version, args->v0.page, args->v0.kind);
 		kind = args->v0.kind != 0;
 		page = args->v0.page != 0;
 	} else
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/dma/usernv50.c b/drivers/gpu/drm/nouveau/nvkm/engine/dma/usernv50.c
index 6a85b5dea643..2c3b2e7d3c2e 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/dma/usernv50.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/dma/usernv50.c
@@ -73,7 +73,6 @@ nv50_dmaobj_new(struct nvkm_dma *dma, const struct nvkm_oclass *oclass,
 	union {
 		struct nv50_dma_v0 v0;
 	} *args;
-	struct nvkm_object *parent = oclass->parent;
 	struct nv50_dmaobj *dmaobj;
 	u32 user, part, comp, kind;
 	int ret;
@@ -90,12 +89,7 @@ nv50_dmaobj_new(struct nvkm_dma *dma, const struct nvkm_oclass *oclass,
 	ret  = -ENOSYS;
 	args = data;
 
-	nvif_ioctl(parent, "create nv50 dma size %d\n", size);
 	if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
-		nvif_ioctl(parent, "create nv50 dma vers %d priv %d part %d "
-				   "comp %d kind %02x\n", args->v0.version,
-			   args->v0.priv, args->v0.part, args->v0.comp,
-			   args->v0.kind);
 		user = args->v0.priv;
 		part = args->v0.part;
 		comp = args->v0.comp;
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 133/156] drm/nouveau/nvif: remove disp chans from object rb
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (131 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 132/156] drm/nouveau/nvif: rework disp chan "new ctxdma" api Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 134/156] drm/nouveau/nvif: rework device "new cgrp" api Ben Skeggs
                   ` (24 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- no more users

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/dispnv50/base507c.c   |  3 +-
 drivers/gpu/drm/nouveau/dispnv50/core507d.c   |  3 +-
 drivers/gpu/drm/nouveau/dispnv50/ovly507e.c   |  3 +-
 drivers/gpu/drm/nouveau/dispnv50/wimmc37b.c   |  3 +-
 drivers/gpu/drm/nouveau/dispnv50/wndwc37e.c   |  3 +-
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  4 +--
 .../gpu/drm/nouveau/nvkm/engine/disp/udisp.c  | 35 +++++++------------
 7 files changed, 20 insertions(+), 34 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv50/base507c.c b/drivers/gpu/drm/nouveau/dispnv50/base507c.c
index 875c013c39b0..1cf80535fcfa 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/base507c.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/base507c.c
@@ -318,8 +318,7 @@ base507c_new_(const struct nv50_wndw_func *func, const u32 *format,
 		goto done;
 
 	ret = disp->impl->chan.base.new(disp->priv, head, wndw->wndw.push.mem.priv,
-					&wndw->wndw.impl, &wndw->wndw.priv,
-					nvif_handle(&wndw->wndw.object));
+					&wndw->wndw.impl, &wndw->wndw.priv);
 	if (ret)
 		goto done;
 
diff --git a/drivers/gpu/drm/nouveau/dispnv50/core507d.c b/drivers/gpu/drm/nouveau/dispnv50/core507d.c
index 4127bc05ea80..dae2b9e68ca7 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/core507d.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/core507d.c
@@ -169,8 +169,7 @@ core507d_new_(const struct nv50_core_func *func, struct nouveau_drm *drm,
 		goto done;
 
 	ret = disp->impl->chan.core.new(disp->priv, core->chan.push.mem.priv,
-					&core->chan.impl, &core->chan.priv,
-					nvif_handle(&core->chan.object));
+					&core->chan.impl, &core->chan.priv);
 	if (ret)
 		goto done;
 
diff --git a/drivers/gpu/drm/nouveau/dispnv50/ovly507e.c b/drivers/gpu/drm/nouveau/dispnv50/ovly507e.c
index 458c6f9e63f0..ab011c38b8fb 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/ovly507e.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/ovly507e.c
@@ -160,8 +160,7 @@ ovly507e_new_(const struct nv50_wndw_func *func, const u32 *format,
 		goto done;
 
 	ret = disp->impl->chan.ovly.new(disp->priv, wndw->id, wndw->wndw.push.mem.priv,
-					&wndw->wndw.impl, &wndw->wndw.priv,
-					nvif_handle(&wndw->wndw.object));
+					&wndw->wndw.impl, &wndw->wndw.priv);
 	if (ret)
 		goto done;
 
diff --git a/drivers/gpu/drm/nouveau/dispnv50/wimmc37b.c b/drivers/gpu/drm/nouveau/dispnv50/wimmc37b.c
index 2f4f0ad89b5e..34324b20ee0e 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/wimmc37b.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/wimmc37b.c
@@ -75,8 +75,7 @@ wimmc37b_init_(const struct nv50_wimm_func *func, struct nouveau_drm *drm,
 		goto done;
 
 	ret = disp->impl->chan.wimm.new(disp->priv, wndw->id, wndw->wimm.push.mem.priv,
-					&wndw->wimm.impl, &wndw->wimm.priv,
-					nvif_handle(&wndw->wimm.object));
+					&wndw->wimm.impl, &wndw->wimm.priv);
 	if (ret)
 		goto done;
 
diff --git a/drivers/gpu/drm/nouveau/dispnv50/wndwc37e.c b/drivers/gpu/drm/nouveau/dispnv50/wndwc37e.c
index 17751110edae..c44ea1574863 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/wndwc37e.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/wndwc37e.c
@@ -364,8 +364,7 @@ wndwc37e_new_(const struct nv50_wndw_func *func, struct nouveau_drm *drm,
 		goto done;
 
 	ret = disp->impl->chan.wndw.new(disp->priv, wndw->id, wndw->wndw.push.mem.priv,
-					&wndw->wndw.impl, &wndw->wndw.priv,
-					nvif_handle(&wndw->wndw.object));
+					&wndw->wndw.impl, &wndw->wndw.priv);
 	if (ret)
 		goto done;
 
diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 8ae50be82a02..6161a29fb07f 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -411,14 +411,14 @@ struct nvif_disp_impl {
 			s32 oclass;
 			int (*new)(struct nvif_disp_priv *, struct nvif_mem_priv *,
 				   const struct nvif_disp_chan_impl **,
-				   struct nvif_disp_chan_priv **, u64 handle);
+				   struct nvif_disp_chan_priv **);
 		} core;
 
 		struct nvif_disp_impl_dmac {
 			s32 oclass;
 			int (*new)(struct nvif_disp_priv *, u8 id, struct nvif_mem_priv *,
 				   const struct nvif_disp_chan_impl **,
-				   struct nvif_disp_chan_priv **, u64 handle);
+				   struct nvif_disp_chan_priv **);
 		} base, ovly, wndw, wimm;
 
 		struct nvif_disp_impl_pioc {
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c
index bc15fe149a86..321b5b12515c 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c
@@ -30,8 +30,7 @@
 static int
 nvkm_udisp_chan_new(struct nvif_disp_priv *udisp, const struct nvkm_disp_func_chan *func,
 		    u8 nr, u8 id, struct nvif_mem_priv *umem,
-		    const struct nvif_disp_chan_impl **pimpl, struct nvif_disp_chan_priv **ppriv,
-		    u64 handle)
+		    const struct nvif_disp_chan_impl **pimpl, struct nvif_disp_chan_priv **ppriv)
 {
 	struct nvkm_memory *memory = NULL;
 	struct nvkm_object *object;
@@ -48,9 +47,6 @@ nvkm_udisp_chan_new(struct nvif_disp_priv *udisp, const struct nvkm_disp_func_ch
 	if (ret)
 		return ret;
 
-	if (handle)
-		return nvkm_object_link_rb(udisp->object.client, &udisp->object, handle, object);
-
 	nvkm_object_link(&udisp->object, object);
 	return 0;
 }
@@ -62,7 +58,7 @@ nvkm_udisp_oimm_new(struct nvif_disp_priv *udisp, u8 id,
 	struct nvkm_disp *disp = udisp->disp;
 
 	return nvkm_udisp_chan_new(udisp, &disp->func->user.oimm, disp->head.nr, id, NULL,
-				   pimpl, ppriv, 0);
+				   pimpl, ppriv);
 }
 
 static int
@@ -72,61 +68,56 @@ nvkm_udisp_curs_new(struct nvif_disp_priv *udisp, u8 id,
 	struct nvkm_disp *disp = udisp->disp;
 
 	return nvkm_udisp_chan_new(udisp, &disp->func->user.curs, disp->head.nr, id, NULL,
-				   pimpl, ppriv, 0);
+				   pimpl, ppriv);
 }
 
 static int
 nvkm_udisp_wimm_new(struct nvif_disp_priv *udisp, u8 id, struct nvif_mem_priv *umem,
-		    const struct nvif_disp_chan_impl **pimpl, struct nvif_disp_chan_priv **ppriv,
-		    u64 handle)
+		    const struct nvif_disp_chan_impl **pimpl, struct nvif_disp_chan_priv **ppriv)
 {
 	struct nvkm_disp *disp = udisp->disp;
 
 	return nvkm_udisp_chan_new(udisp, &disp->func->user.wimm, disp->wndw.nr, id, umem,
-				   pimpl, ppriv, 0);
+				   pimpl, ppriv);
 }
 
 static int
 nvkm_udisp_wndw_new(struct nvif_disp_priv *udisp, u8 id, struct nvif_mem_priv *umem,
-		    const struct nvif_disp_chan_impl **pimpl, struct nvif_disp_chan_priv **ppriv,
-		    u64 handle)
+		    const struct nvif_disp_chan_impl **pimpl, struct nvif_disp_chan_priv **ppriv)
 {
 	struct nvkm_disp *disp = udisp->disp;
 
 	return nvkm_udisp_chan_new(udisp, &disp->func->user.wndw, disp->wndw.nr, id, umem,
-				   pimpl, ppriv, handle);
+				   pimpl, ppriv);
 }
 
 static int
 nvkm_udisp_ovly_new(struct nvif_disp_priv *udisp, u8 id, struct nvif_mem_priv *umem,
-		    const struct nvif_disp_chan_impl **pimpl, struct nvif_disp_chan_priv **ppriv,
-		    u64 handle)
+		    const struct nvif_disp_chan_impl **pimpl, struct nvif_disp_chan_priv **ppriv)
 {
 	struct nvkm_disp *disp = udisp->disp;
 
 	return nvkm_udisp_chan_new(udisp, &disp->func->user.ovly, disp->head.nr, id, umem,
-				   pimpl, ppriv, handle);
+				   pimpl, ppriv);
 }
 
 static int
 nvkm_udisp_base_new(struct nvif_disp_priv *udisp, u8 id, struct nvif_mem_priv *umem,
-		    const struct nvif_disp_chan_impl **pimpl, struct nvif_disp_chan_priv **ppriv,
-		    u64 handle)
+		    const struct nvif_disp_chan_impl **pimpl, struct nvif_disp_chan_priv **ppriv)
 {
 	struct nvkm_disp *disp = udisp->disp;
 
 	return nvkm_udisp_chan_new(udisp, &disp->func->user.base, disp->head.nr, id, umem,
-				   pimpl, ppriv, handle);
+				   pimpl, ppriv);
 }
 
 static int
 nvkm_udisp_core_new(struct nvif_disp_priv *udisp, struct nvif_mem_priv *umem,
-		    const struct nvif_disp_chan_impl **pimpl, struct nvif_disp_chan_priv **ppriv,
-		    u64 handle)
+		    const struct nvif_disp_chan_impl **pimpl, struct nvif_disp_chan_priv **ppriv)
 {
 	struct nvkm_disp *disp = udisp->disp;
 
-	return nvkm_udisp_chan_new(udisp, &disp->func->user.core, 1, 0, umem, pimpl, ppriv, handle);
+	return nvkm_udisp_chan_new(udisp, &disp->func->user.core, 1, 0, umem, pimpl, ppriv);
 }
 
 static int
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 134/156] drm/nouveau/nvif: rework device "new cgrp" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (132 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 133/156] drm/nouveau/nvif: remove disp chans from object rb Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 135/156] drm/nouveau/nvif: rework device "new ctxdma" api Ben Skeggs
                   ` (23 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interface

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/include/nvif/cgrp.h   | 17 +++++
 .../gpu/drm/nouveau/include/nvif/driverif.h   | 10 +++
 drivers/gpu/drm/nouveau/include/nvif/if0021.h | 16 -----
 drivers/gpu/drm/nouveau/nvif/Kbuild           |  1 +
 drivers/gpu/drm/nouveau/nvif/cgrp.c           | 52 ++++++++++++++
 drivers/gpu/drm/nouveau/nvkm/device/user.c    | 19 ++++++
 .../gpu/drm/nouveau/nvkm/engine/fifo/base.c   | 14 ----
 .../gpu/drm/nouveau/nvkm/engine/fifo/priv.h   |  2 -
 .../gpu/drm/nouveau/nvkm/engine/fifo/ucgrp.c  | 67 +++++++++++++------
 .../gpu/drm/nouveau/nvkm/engine/fifo/ucgrp.h  |  9 +++
 .../gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c    |  9 +++
 .../gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.h    |  1 +
 12 files changed, 163 insertions(+), 54 deletions(-)
 create mode 100644 drivers/gpu/drm/nouveau/include/nvif/cgrp.h
 delete mode 100644 drivers/gpu/drm/nouveau/include/nvif/if0021.h
 create mode 100644 drivers/gpu/drm/nouveau/nvif/cgrp.c
 create mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/fifo/ucgrp.h

diff --git a/drivers/gpu/drm/nouveau/include/nvif/cgrp.h b/drivers/gpu/drm/nouveau/include/nvif/cgrp.h
new file mode 100644
index 000000000000..337ba67c7695
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/include/nvif/cgrp.h
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: MIT */
+#ifndef __NVIF_CGRP_H__
+#define __NVIF_CGRP_H__
+#include <nvif/object.h>
+#include <nvif/driverif.h>
+struct nvif_device;
+struct nvif_vmm;
+
+struct nvif_cgrp {
+	const struct nvif_cgrp_impl *impl;
+	struct nvif_cgrp_priv *priv;
+	struct nvif_object object;
+};
+
+int nvif_cgrp_ctor(struct nvif_device *, struct nvif_vmm *, int runl, struct nvif_cgrp *);
+void nvif_cgrp_dtor(struct nvif_cgrp *);
+#endif
diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 6161a29fb07f..75168621427a 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -19,6 +19,7 @@ struct nvif_outp_priv;
 struct nvif_head_priv;
 struct nvif_disp_chan_priv;
 struct nvif_ctxdma_priv;
+struct nvif_cgrp_priv;
 
 struct nvif_driver {
 	const char *name;
@@ -430,6 +431,12 @@ struct nvif_disp_impl {
 	} chan;
 };
 
+struct nvif_cgrp_impl {
+	void (*del)(struct nvif_cgrp_priv *);
+
+	u16 id;
+};
+
 struct nvif_device_impl {
 	void (*del)(struct nvif_device_priv *);
 
@@ -546,6 +553,9 @@ struct nvif_device_impl {
 
 		struct {
 			s32 oclass;
+			int (*new)(struct nvif_device_priv *, u8 runl, struct nvif_vmm_priv *,
+				   const char *name, const struct nvif_cgrp_impl **,
+				   struct nvif_cgrp_priv **);
 		} cgrp;
 
 		struct {
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0021.h b/drivers/gpu/drm/nouveau/include/nvif/if0021.h
deleted file mode 100644
index 5013def90455..000000000000
--- a/drivers/gpu/drm/nouveau/include/nvif/if0021.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/* SPDX-License-Identifier: MIT */
-#ifndef __NVIF_IF0021_H__
-#define __NVIF_IF0021_H__
-
-union nvif_cgrp_args {
-	struct nvif_cgrp_v0 {
-		__u8  version;
-		__u8  namelen;
-		__u8  runlist;
-		__u8  pad03[3];
-		__u16 cgid;
-		__u64 vmm;
-		__u8  name[];
-	} v0;
-};
-#endif
diff --git a/drivers/gpu/drm/nouveau/nvif/Kbuild b/drivers/gpu/drm/nouveau/nvif/Kbuild
index 8e3ed36df6b3..50489933655c 100644
--- a/drivers/gpu/drm/nouveau/nvif/Kbuild
+++ b/drivers/gpu/drm/nouveau/nvif/Kbuild
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: MIT
 nvif-y := nvif/object.o
 nvif-y += nvif/client.o
+nvif-y += nvif/cgrp.o
 nvif-y += nvif/conn.o
 nvif-y += nvif/device.o
 nvif-y += nvif/disp.o
diff --git a/drivers/gpu/drm/nouveau/nvif/cgrp.c b/drivers/gpu/drm/nouveau/nvif/cgrp.c
new file mode 100644
index 000000000000..1e968d0c0d5a
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/nvif/cgrp.c
@@ -0,0 +1,52 @@
+/*
+ * 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 <nvif/cgrp.h>
+#include <nvif/device.h>
+#include <nvif/vmm.h>
+
+void
+nvif_cgrp_dtor(struct nvif_cgrp *cgrp)
+{
+	if (!cgrp->impl)
+		return;
+
+	cgrp->impl->del(cgrp->priv);
+	cgrp->impl = NULL;
+}
+
+int
+nvif_cgrp_ctor(struct nvif_device *device, struct nvif_vmm *vmm, int runl, struct nvif_cgrp *cgrp)
+{
+	int ret;
+
+	if (!device->impl->fifo.cgrp.new)
+		return -ENODEV;
+
+	ret = device->impl->fifo.cgrp.new(device->priv, runl, vmm->priv, "nvifCgrp",
+					  &cgrp->impl, &cgrp->priv);
+	if (ret)
+		return ret;
+
+	nvif_object_ctor(&device->object, "nvifCgrp", cgrp->impl->id,
+			 device->impl->fifo.cgrp.oclass, &cgrp->object);
+	return 0;
+}
diff --git a/drivers/gpu/drm/nouveau/nvkm/device/user.c b/drivers/gpu/drm/nouveau/nvkm/device/user.c
index 6a3b41004abd..f76861945cd0 100644
--- a/drivers/gpu/drm/nouveau/nvkm/device/user.c
+++ b/drivers/gpu/drm/nouveau/nvkm/device/user.c
@@ -35,6 +35,7 @@
 #include <engine/disp/priv.h>
 #include <engine/disp/udisp.h>
 #include <engine/fifo/ufifo.h>
+#include <engine/fifo/ucgrp.h>
 
 struct nvif_device_priv {
 	struct nvkm_object object;
@@ -94,6 +95,22 @@ nvkm_udevice_time(struct nvif_device_priv *udev)
 	return nvkm_timer_read(udev->device->timer);
 }
 
+static int
+nvkm_udevice_cgrp_new(struct nvif_device_priv *udev, u8 runl, struct nvif_vmm_priv *uvmm,
+		      const char *name, const struct nvif_cgrp_impl **pimpl,
+		      struct nvif_cgrp_priv **ppriv)
+{
+	struct nvkm_object *object;
+	int ret;
+
+	ret = nvkm_ucgrp_new(udev->device->fifo, runl, uvmm, name, pimpl, ppriv, &object);
+	if (ret)
+		return ret;
+
+	nvkm_object_link(&udev->object, object);
+	return 0;
+}
+
 static int
 nvkm_udevice_disp_new(struct nvif_device_priv *udev,
 		      const struct nvif_disp_impl **pimpl, struct nvif_disp_priv **ppriv)
@@ -338,6 +355,8 @@ nvkm_udevice_new(struct nvkm_device *device,
 	if (device->fifo) {
 		if (!WARN_ON(nvkm_subdev_oneinit(&device->fifo->engine.subdev))) {
 			nvkm_ufifo_ctor(device->fifo, &udev->impl.fifo);
+
+			udev->impl.fifo.cgrp.new = nvkm_udevice_cgrp_new;
 		}
 	}
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/base.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/base.c
index 6bd464da1c96..1894a2075079 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/base.c
@@ -75,9 +75,6 @@ nvkm_fifo_class_new(struct nvkm_device *device, const struct nvkm_oclass *oclass
 {
 	struct nvkm_fifo *fifo = nvkm_fifo(oclass->engine);
 
-	if (oclass->engn == &fifo->func->cgrp.user)
-		return nvkm_ucgrp_new(fifo, oclass, argv, argc, pobject);
-
 	if (oclass->engn == &fifo->func->chan.user)
 		return nvkm_uchan_new(fifo, NULL, oclass, argv, argc, pobject);
 
@@ -94,20 +91,9 @@ static int
 nvkm_fifo_class_get(struct nvkm_oclass *oclass, int index, const struct nvkm_device_oclass **class)
 {
 	struct nvkm_fifo *fifo = nvkm_fifo(oclass->engine);
-	const struct nvkm_fifo_func_cgrp *cgrp = &fifo->func->cgrp;
 	const struct nvkm_fifo_func_chan *chan = &fifo->func->chan;
 	int c = 0;
 
-	/* *_CHANNEL_GROUP_* */
-	if (cgrp->user.oclass) {
-		if (c++ == index) {
-			oclass->base = cgrp->user;
-			oclass->engn = &fifo->func->cgrp.user;
-			*class = &nvkm_fifo_class;
-			return 0;
-		}
-	}
-
 	/* *_CHANNEL_DMA, *_CHANNEL_GPFIFO_* */
 	if (chan->user.oclass) {
 		if (c++ == index) {
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/priv.h b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/priv.h
index a0f3277605a5..d1386d00fc36 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/priv.h
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/priv.h
@@ -208,6 +208,4 @@ extern const struct nvkm_chan_func ga100_chan;
 
 int nvkm_uchan_new(struct nvkm_fifo *, struct nvkm_cgrp *, const struct nvkm_oclass *,
 		   void *argv, u32 argc, struct nvkm_object **);
-int nvkm_ucgrp_new(struct nvkm_fifo *, const struct nvkm_oclass *, void *argv, u32 argc,
-		   struct nvkm_object **);
 #endif
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/ucgrp.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/ucgrp.c
index 7c9a151b03a3..8acfd85cee53 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/ucgrp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/ucgrp.c
@@ -19,17 +19,18 @@
  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
  */
-#include "priv.h"
+#include "ucgrp.h"
 #include "cgrp.h"
+#include "priv.h"
 #include "runl.h"
 
-#include <subdev/mmu.h>
-
-#include <nvif/if0021.h>
+#include <subdev/mmu/uvmm.h>
 
 struct nvif_cgrp_priv {
 	struct nvkm_object object;
 	struct nvkm_cgrp *cgrp;
+
+	struct nvif_cgrp_impl impl;
 };
 
 static int
@@ -61,6 +62,19 @@ nvkm_ucgrp_sclass(struct nvkm_object *object, int index, struct nvkm_oclass *ocl
 	return -EINVAL;
 }
 
+static void
+nvkm_ucgrp_del(struct nvif_cgrp_priv *ucgrp)
+{
+	struct nvkm_object *object = &ucgrp->object;
+
+	nvkm_object_del(&object);
+}
+
+static const struct nvif_cgrp_impl
+nvkm_ucgrp_impl = {
+	.del = nvkm_ucgrp_del,
+};
+
 static void *
 nvkm_ucgrp_dtor(struct nvkm_object *object)
 {
@@ -77,30 +91,24 @@ nvkm_ucgrp = {
 };
 
 int
-nvkm_ucgrp_new(struct nvkm_fifo *fifo, const struct nvkm_oclass *oclass, void *argv, u32 argc,
+nvkm_ucgrp_new(struct nvkm_fifo *fifo, u8 runi, struct nvif_vmm_priv *uvmm, const char *name,
+	       const struct nvif_cgrp_impl **pimpl, struct nvif_cgrp_priv **ppriv,
 	       struct nvkm_object **pobject)
 {
-	union nvif_cgrp_args *args = argv;
 	struct nvkm_runl *runl;
 	struct nvkm_vmm *vmm;
 	struct nvif_cgrp_priv *ucgrp;
+	struct nvkm_engine *engine;
 	int ret;
 
-	if (argc < sizeof(args->v0) || args->v0.version != 0)
-		return -ENOSYS;
-	argc -= sizeof(args->v0);
-
-	if (args->v0.namelen != argc)
-		return -EINVAL;
-
 	/* Lookup objects referenced in args. */
-	runl = nvkm_runl_get(fifo, args->v0.runlist, 0);
+	runl = nvkm_runl_get(fifo, runi, 0);
 	if (!runl)
 		return -EINVAL;
 
-	vmm = nvkm_uvmm_search(oclass->client, args->v0.vmm);
-	if (IS_ERR(vmm))
-		return PTR_ERR(vmm);
+	vmm = nvkm_uvmm_ref(uvmm);
+	if (!vmm)
+		return -EINVAL;
 
 	/* Allocate channel group. */
 	if (!(ucgrp = kzalloc(sizeof(*ucgrp), GFP_KERNEL))) {
@@ -108,17 +116,32 @@ nvkm_ucgrp_new(struct nvkm_fifo *fifo, const struct nvkm_oclass *oclass, void *a
 		goto done;
 	}
 
-	nvkm_object_ctor(&nvkm_ucgrp, oclass, &ucgrp->object);
-	*pobject = &ucgrp->object;
+	engine = nvkm_engine_ref(&fifo->engine);
+	if (IS_ERR(engine)) {
+		ret = PTR_ERR(engine);
+		goto done;
+	}
 
-	ret = nvkm_cgrp_new(runl, args->v0.name, vmm, true, &ucgrp->cgrp);
-	if (ret)
+	ret = nvkm_cgrp_new(runl, name, vmm, true, &ucgrp->cgrp);
+	if (ret) {
+		nvkm_engine_unref(&engine);
 		goto done;
+	}
+
+	nvkm_object_ctor(&nvkm_ucgrp, &(struct nvkm_oclass) { .engine = engine }, &ucgrp->object);
 
 	/* Return channel group info to caller. */
-	args->v0.cgid = ucgrp->cgrp->id;
+	ucgrp->impl = nvkm_ucgrp_impl;
+	ucgrp->impl.id = ucgrp->cgrp->id;
+
+	*pimpl = &ucgrp->impl;
+	*ppriv = ucgrp;
+	*pobject = &ucgrp->object;
 
 done:
+	if (ret)
+		kfree(ucgrp);
+
 	nvkm_vmm_unref(&vmm);
 	return ret;
 }
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/ucgrp.h b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/ucgrp.h
new file mode 100644
index 000000000000..97f3d9eafdfc
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/ucgrp.h
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: MIT */
+#ifndef __NVKM_UCGRP_H__
+#define __NVKM_UCGRP_H__
+#include <engine/fifo.h>
+#include <nvif/driverif.h>
+
+int nvkm_ucgrp_new(struct nvkm_fifo *, u8 runl, struct nvif_vmm_priv *,  const char *name,
+		   const struct nvif_cgrp_impl **, struct nvif_cgrp_priv **, struct nvkm_object **);
+#endif
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c
index d8e7888410c3..5fac19738815 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c
@@ -33,6 +33,15 @@ struct nvif_vmm_priv {
 	struct nvif_vmm_impl impl;
 };
 
+struct nvkm_vmm *
+nvkm_uvmm_ref(struct nvif_vmm_priv *uvmm)
+{
+	if (uvmm)
+		return nvkm_vmm_ref(uvmm->vmm);
+
+	return NULL;
+}
+
 static const struct nvkm_object_func nvkm_uvmm;
 struct nvkm_vmm *
 nvkm_uvmm_search(struct nvkm_client *client, u64 handle)
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.h b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.h
index 51c639cd0ce0..fb2deeb01d56 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.h
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.h
@@ -6,4 +6,5 @@
 int nvkm_uvmm_new(struct nvkm_mmu *mmu, u8 type, u64 addr, u64 size,
 		  void *, u32, const struct nvif_vmm_impl **, struct nvif_vmm_priv **,
 		  struct nvkm_object **);
+struct nvkm_vmm *nvkm_uvmm_ref(struct nvif_vmm_priv *);
 #endif
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 135/156] drm/nouveau/nvif: rework device "new ctxdma" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (133 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 134/156] drm/nouveau/nvif: rework device "new cgrp" api Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 136/156] drm/nouveau/nvif: rework device/cgrp "new chan" apis Ben Skeggs
                   ` (22 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interface

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/include/nvif/device.h |  4 ++
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  6 +++
 drivers/gpu/drm/nouveau/nouveau_chan.c        | 11 +++--
 drivers/gpu/drm/nouveau/nouveau_chan.h        |  3 +-
 drivers/gpu/drm/nouveau/nvif/device.c         | 17 ++++++++
 drivers/gpu/drm/nouveau/nvkm/device/user.c    | 41 ++++++++++++++++++-
 6 files changed, 73 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/device.h b/drivers/gpu/drm/nouveau/include/nvif/device.h
index fa8402e575da..5fb71e6da7cd 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/device.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/device.h
@@ -5,6 +5,7 @@
 #include <nvif/cl0080.h>
 #include <nvif/driverif.h>
 #include <nvif/user.h>
+struct nvif_ctxdma;
 
 struct nvif_device {
 	const struct nvif_device_impl *impl;
@@ -22,6 +23,9 @@ void nvif_device_dtor(struct nvif_device *);
 int  nvif_device_map(struct nvif_device *);
 u64  nvif_device_time(struct nvif_device *);
 
+int nvif_device_ctxdma_ctor(struct nvif_device *, const char *name, s32 oclass,
+			    void *argv, u32 argc, struct nvif_ctxdma *);
+
 /*XXX*/
 #include <subdev/bios.h>
 #include <subdev/fb.h>
diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 75168621427a..c1971b85d927 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -507,6 +507,12 @@ struct nvif_device_impl {
 			   const struct nvif_disp_impl **, struct nvif_disp_priv **);
 	} disp;
 
+	struct {
+		int (*new)(struct nvif_device_priv *, s32 oclass, void *argv, u32 argc,
+			   const struct nvif_ctxdma_impl **, struct nvif_ctxdma_priv **,
+			   u64 handle);
+	} ctxdma;
+
 	struct nvif_device_impl_fifo {
 		u8  engine_nr;
 		u8  runl_nr;
diff --git a/drivers/gpu/drm/nouveau/nouveau_chan.c b/drivers/gpu/drm/nouveau/nouveau_chan.c
index 771a4b4b3f1d..7c57bc48a8af 100644
--- a/drivers/gpu/drm/nouveau/nouveau_chan.c
+++ b/drivers/gpu/drm/nouveau/nouveau_chan.c
@@ -106,7 +106,7 @@ nouveau_channel_del(struct nouveau_channel **pchan)
 		nvif_object_unmap_cpu(&chan->userd.map);
 		nvif_object_dtor(&chan->user);
 		nvif_mem_dtor(&chan->userd.mem);
-		nvif_object_dtor(&chan->push.ctxdma);
+		nvif_ctxdma_dtor(&chan->push.ctxdma);
 		nouveau_vma_del(&chan->push.vma);
 		nouveau_bo_unmap(chan->push.buffer);
 		if (chan->push.buffer && chan->push.buffer->bo.pin_count)
@@ -242,9 +242,8 @@ nouveau_channel_prep(struct nouveau_cli *cli,
 		}
 	}
 
-	ret = nvif_object_ctor(&device->object, "abi16PushCtxDma", 0,
-			       NV_DMA_FROM_MEMORY, &args, sizeof(args),
-			       &chan->push.ctxdma);
+	ret = nvif_device_ctxdma_ctor(device, "abi16PushCtxDma", NV_DMA_FROM_MEMORY,
+				      &args, sizeof(args), &chan->push.ctxdma);
 	if (ret) {
 		nouveau_channel_del(pchan);
 		return ret;
@@ -315,13 +314,13 @@ nouveau_channel_ctor(struct nouveau_cli *cli, bool priv, u64 runm,
 	args.chan.devm = BIT(0);
 	if (oclass < NV50_CHANNEL_GPFIFO) {
 		args.chan.vmm = 0;
-		args.chan.ctxdma = nvif_handle(&chan->push.ctxdma);
+		args.chan.ctxdma = nvif_handle(&chan->push.ctxdma.object);
 		args.chan.offset = chan->push.addr;
 		args.chan.length = 0;
 	} else {
 		args.chan.vmm = nvif_handle(&chan->vmm->vmm.object);
 		if (oclass < FERMI_CHANNEL_GPFIFO)
-			args.chan.ctxdma = nvif_handle(&chan->push.ctxdma);
+			args.chan.ctxdma = nvif_handle(&chan->push.ctxdma.object);
 		else
 			args.chan.ctxdma = 0;
 		args.chan.offset = ioffset + chan->push.addr;
diff --git a/drivers/gpu/drm/nouveau/nouveau_chan.h b/drivers/gpu/drm/nouveau/nouveau_chan.h
index 811271ae6fe1..786c929843d1 100644
--- a/drivers/gpu/drm/nouveau/nouveau_chan.h
+++ b/drivers/gpu/drm/nouveau/nouveau_chan.h
@@ -2,6 +2,7 @@
 #ifndef __NOUVEAU_CHAN_H__
 #define __NOUVEAU_CHAN_H__
 #include <nvif/object.h>
+#include <nvif/ctxdma.h>
 #include <nvif/event.h>
 #include <nvif/push.h>
 struct nvif_device;
@@ -31,7 +32,7 @@ struct nouveau_channel {
 	struct {
 		struct nouveau_bo *buffer;
 		struct nouveau_vma *vma;
-		struct nvif_object ctxdma;
+		struct nvif_ctxdma ctxdma;
 		u64 addr;
 	} push;
 
diff --git a/drivers/gpu/drm/nouveau/nvif/device.c b/drivers/gpu/drm/nouveau/nvif/device.c
index 7d057691600f..555c63e96660 100644
--- a/drivers/gpu/drm/nouveau/nvif/device.c
+++ b/drivers/gpu/drm/nouveau/nvif/device.c
@@ -23,8 +23,25 @@
  */
 #include <nvif/device.h>
 #include <nvif/client.h>
+#include <nvif/ctxdma.h>
 #include <nvif/printf.h>
 
+int
+nvif_device_ctxdma_ctor(struct nvif_device *device, const char *name, s32 oclass,
+			void *argv, u32 argc, struct nvif_ctxdma *ctxdma)
+{
+	int ret;
+
+	ret = device->impl->ctxdma.new(device->priv, oclass, argv, argc,
+				       &ctxdma->impl, &ctxdma->priv, nvif_handle(&ctxdma->object));
+	NVIF_ERRON(ret, &device->object, "[NEW ctxdma%04x]", oclass);
+	if (ret)
+		return ret;
+
+	nvif_ctxdma_ctor(&device->object, name ?: "nvifDeviceCtxDma", 0, oclass, ctxdma);
+	return 0;
+}
+
 u64
 nvif_device_time(struct nvif_device *device)
 {
diff --git a/drivers/gpu/drm/nouveau/nvkm/device/user.c b/drivers/gpu/drm/nouveau/nvkm/device/user.c
index f76861945cd0..fc81d595bdb7 100644
--- a/drivers/gpu/drm/nouveau/nvkm/device/user.c
+++ b/drivers/gpu/drm/nouveau/nvkm/device/user.c
@@ -111,6 +111,42 @@ nvkm_udevice_cgrp_new(struct nvif_device_priv *udev, u8 runl, struct nvif_vmm_pr
 	return 0;
 }
 
+#include <engine/dma/priv.h>
+
+static void
+nvkm_udevice_ctxdma_del(struct nvif_ctxdma_priv *priv)
+{
+	struct nvkm_dmaobj *dmaobj = (void *)priv;
+	struct nvkm_object *object = &dmaobj->object;
+
+	nvkm_object_del(&object);
+}
+
+static const struct nvif_ctxdma_impl
+nvkm_udevice_ctxdma_impl = {
+	.del = nvkm_udevice_ctxdma_del
+};
+
+static int
+nvkm_udevice_ctxdma_new(struct nvif_device_priv *udev, s32 oclass, void *argv, u32 argc,
+			const struct nvif_ctxdma_impl **pimpl, struct nvif_ctxdma_priv **ppriv,
+			u64 handle)
+{
+	struct nvkm_dma *dma = udev->device->dma;
+	struct nvkm_dmaobj *dmaobj;
+	int ret;
+
+	ret = dma->func->class_new(dma, &(struct nvkm_oclass) { .base.oclass = oclass },
+				   argv, argc, &dmaobj);
+	if (ret)
+		return ret;
+
+	*pimpl = &nvkm_udevice_ctxdma_impl;
+	*ppriv = (void *)dmaobj;
+
+	return nvkm_object_link_rb(udev->object.client, &udev->object, handle, &dmaobj->object);
+}
+
 static int
 nvkm_udevice_disp_new(struct nvif_device_priv *udev,
 		      const struct nvif_disp_impl **pimpl, struct nvif_disp_priv **ppriv)
@@ -217,8 +253,7 @@ nvkm_udevice_child_get(struct nvkm_object *object, int index,
 	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) |
-		   (1ULL << NVKM_ENGINE_FIFO);
+	u64 mask = (1ULL << NVKM_ENGINE_FIFO);
 	const struct nvkm_device_oclass *sclass = NULL;
 	int i;
 
@@ -353,6 +388,8 @@ nvkm_udevice_new(struct nvkm_device *device,
 	}
 
 	if (device->fifo) {
+		udev->impl.ctxdma.new = nvkm_udevice_ctxdma_new;
+
 		if (!WARN_ON(nvkm_subdev_oneinit(&device->fifo->engine.subdev))) {
 			nvkm_ufifo_ctor(device->fifo, &udev->impl.fifo);
 
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 136/156] drm/nouveau/nvif: rework device/cgrp "new chan" apis
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (134 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 135/156] drm/nouveau/nvif: rework device "new ctxdma" api Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 137/156] drm/nouveau/nvif: remove mem from object rb Ben Skeggs
                   ` (21 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interfaces

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/include/nvif/chan.h   |  25 ++++
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  31 +++++
 drivers/gpu/drm/nouveau/include/nvif/if0020.h |  32 -----
 drivers/gpu/drm/nouveau/nouveau_abi16.c       |  14 +--
 drivers/gpu/drm/nouveau/nouveau_bo.c          |   2 +-
 drivers/gpu/drm/nouveau/nouveau_chan.c        |  75 +++++------
 drivers/gpu/drm/nouveau/nouveau_chan.h        |   8 +-
 drivers/gpu/drm/nouveau/nouveau_drm.c         |   6 +-
 drivers/gpu/drm/nouveau/nouveau_fence.c       |   3 +-
 drivers/gpu/drm/nouveau/nv17_fence.c          |   2 +-
 drivers/gpu/drm/nouveau/nv50_fence.c          |   2 +-
 drivers/gpu/drm/nouveau/nvif/Kbuild           |   1 +
 drivers/gpu/drm/nouveau/nvif/chan.c           |  45 +++++++
 drivers/gpu/drm/nouveau/nvkm/device/user.c    |  24 ++++
 .../gpu/drm/nouveau/nvkm/engine/fifo/base.c   |  39 ------
 .../gpu/drm/nouveau/nvkm/engine/fifo/priv.h   |   3 -
 .../gpu/drm/nouveau/nvkm/engine/fifo/ucgrp.c  |  40 +++---
 .../gpu/drm/nouveau/nvkm/engine/fifo/uchan.c  | 116 ++++++++++--------
 .../gpu/drm/nouveau/nvkm/engine/fifo/uchan.h  |  11 ++
 19 files changed, 268 insertions(+), 211 deletions(-)
 create mode 100644 drivers/gpu/drm/nouveau/include/nvif/chan.h
 create mode 100644 drivers/gpu/drm/nouveau/nvif/chan.c
 create mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/fifo/uchan.h

diff --git a/drivers/gpu/drm/nouveau/include/nvif/chan.h b/drivers/gpu/drm/nouveau/include/nvif/chan.h
new file mode 100644
index 000000000000..80f7ea8c7268
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/include/nvif/chan.h
@@ -0,0 +1,25 @@
+/* SPDX-License-Identifier: MIT */
+#ifndef __NVIF_CHAN_H__
+#define __NVIF_CHAN_H__
+#include <nvif/object.h>
+#include <nvif/driverif.h>
+#include <nvif/push.h>
+struct nvif_cgrp;
+struct nvif_device;
+
+struct nvif_chan {
+	const struct nvif_chan_impl *impl;
+	struct nvif_chan_priv *priv;
+	struct nvif_object object;
+
+	struct nvif_device *device;
+	u8 runl;
+	u8 runq;
+
+	struct nvif_push push;
+};
+
+void nvif_chan_ctor(struct nvif_device *, struct nvif_cgrp *, const char *name, u8 runl, u8 runq,
+		    struct nvif_chan *);
+void nvif_chan_dtor(struct nvif_chan *);
+#endif
diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index c1971b85d927..cc858955a97b 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -20,6 +20,7 @@ struct nvif_head_priv;
 struct nvif_disp_chan_priv;
 struct nvif_ctxdma_priv;
 struct nvif_cgrp_priv;
+struct nvif_chan_priv;
 
 struct nvif_driver {
 	const char *name;
@@ -431,10 +432,34 @@ struct nvif_disp_impl {
 	} chan;
 };
 
+struct nvif_chan_impl {
+	void (*del)(struct nvif_chan_priv *);
+
+	u16 id;
+	u32 doorbell_token;
+
+	struct {
+		enum {
+			NVIF_CHAN_INST_APER_INST,
+			NVIF_CHAN_INST_APER_VRAM,
+			NVIF_CHAN_INST_APER_HOST,
+			NVIF_CHAN_INST_APER_NCOH,
+		} aper;
+		u64 addr;
+	} inst;
+};
+
 struct nvif_cgrp_impl {
 	void (*del)(struct nvif_cgrp_priv *);
 
 	u16 id;
+
+	struct {
+		int (*new)(struct nvif_cgrp_priv *, u8 runq, bool priv, u16 devm,
+			   u64 gpfifo_offset, u64 gpfifo_length,
+			   struct nvif_mem_priv *userd, u16 userd_offset, const char *name,
+			   const struct nvif_chan_impl **, struct nvif_chan_priv **);
+	} chan;
 };
 
 struct nvif_device_impl {
@@ -566,6 +591,12 @@ struct nvif_device_impl {
 
 		struct {
 			s32 oclass;
+			int (*new)(struct nvif_device_priv *, u8 runl, u8 runq, bool priv, u16 devm,
+				   struct nvif_vmm_priv *, struct nvif_ctxdma_priv *push,
+				   u64 offset, u64 length, struct nvif_mem_priv *userd,
+				   u16 userd_offset, const char *name,
+				   const struct nvif_chan_impl **, struct nvif_chan_priv **,
+				   u64 handle);
 		} chan;
 	} fifo;
 };
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0020.h b/drivers/gpu/drm/nouveau/include/nvif/if0020.h
index 085e0ae8a450..1893b8aa0abb 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/if0020.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/if0020.h
@@ -2,38 +2,6 @@
 #ifndef __NVIF_IF0020_H__
 #define __NVIF_IF0020_H__
 
-union nvif_chan_args {
-	struct nvif_chan_v0 {
-		__u8  version;
-		__u8  namelen;
-		__u8  runlist;
-		__u8  runq;
-		__u8  priv;
-		__u8  pad05;
-		__u16 devm;
-		__u64 vmm;
-
-		__u64 ctxdma;
-		__u64 offset;
-		__u64 length;
-
-		__u64 huserd;
-		__u64 ouserd;
-
-		__u32 token;
-		__u16 chid;
-		__u8  pad3e;
-#define NVIF_CHAN_V0_INST_APER_VRAM 0
-#define NVIF_CHAN_V0_INST_APER_HOST 1
-#define NVIF_CHAN_V0_INST_APER_NCOH 2
-#define NVIF_CHAN_V0_INST_APER_INST 0xff
-		__u8  aper;
-		__u64 inst;
-
-		__u8  name[];
-	} v0;
-};
-
 union nvif_chan_event_args {
 	struct nvif_chan_event_v0 {
 		__u8 version;
diff --git a/drivers/gpu/drm/nouveau/nouveau_abi16.c b/drivers/gpu/drm/nouveau/nouveau_abi16.c
index fdbc982ea566..d7db5c0eeaea 100644
--- a/drivers/gpu/drm/nouveau/nouveau_abi16.c
+++ b/drivers/gpu/drm/nouveau/nouveau_abi16.c
@@ -430,13 +430,13 @@ nouveau_abi16_ioctl_channel_alloc(ABI16_IOCTL_ARGS)
 	 */
 	switch (device->info.family) {
 	case NV_DEVICE_INFO_V0_VOLTA:
-		ret = nvif_object_ctor(&chan->chan->user, "abi16CeWar", 0, VOLTA_DMA_COPY_A,
+		ret = nvif_object_ctor(&chan->chan->chan.object, "abi16CeWar", 0, VOLTA_DMA_COPY_A,
 				       NULL, 0, &chan->ce);
 		if (ret)
 			goto done;
 		break;
 	case NV_DEVICE_INFO_V0_TURING:
-		ret = nvif_object_ctor(&chan->chan->user, "abi16CeWar", 0, TURING_DMA_COPY_A,
+		ret = nvif_object_ctor(&chan->chan->chan.object, "abi16CeWar", 0, TURING_DMA_COPY_A,
 				       NULL, 0, &chan->ce);
 		if (ret)
 			goto done;
@@ -524,7 +524,7 @@ nouveau_abi16_ioctl_grobj_alloc(ABI16_IOCTL_ARGS)
 	if (!chan)
 		return nouveau_abi16_put(abi16, -ENOENT);
 
-	ret = nvif_object_sclass_get(&chan->chan->user, &sclass);
+	ret = nvif_object_sclass_get(&chan->chan->chan.object, &sclass);
 	if (ret < 0)
 		return nouveau_abi16_put(abi16, ret);
 
@@ -583,7 +583,7 @@ nouveau_abi16_ioctl_grobj_alloc(ABI16_IOCTL_ARGS)
 
 	list_add(&ntfy->head, &chan->notifiers);
 
-	ret = nvif_object_ctor(&chan->chan->user, "abi16EngObj", init->handle,
+	ret = nvif_object_ctor(&chan->chan->chan.object, "abi16EngObj", init->handle,
 			       oclass, NULL, 0, &ntfy->object);
 
 	if (ret)
@@ -645,7 +645,7 @@ nouveau_abi16_ioctl_notifierobj_alloc(ABI16_IOCTL_ARGS)
 		args.limit += chan->ntfy->offset;
 	}
 
-	ret = nvif_object_ctor(&chan->chan->user, "abi16Ntfy", info->handle,
+	ret = nvif_object_ctor(&chan->chan->chan.object, "abi16Ntfy", info->handle,
 			       NV_DMA_IN_MEMORY, &args, sizeof(args),
 			       &ntfy->object);
 	if (ret)
@@ -768,7 +768,7 @@ nouveau_abi16_ioctl_new(struct nouveau_abi16 *abi16, struct nvif_ioctl_v0 *ioctl
 	if (IS_ERR(obj))
 		return PTR_ERR(obj);
 
-	ret = nvif_object_ctor(&chan->chan->user, "abi16EngObj", args->handle, args->oclass,
+	ret = nvif_object_ctor(&chan->chan->chan.object, "abi16EngObj", args->handle, args->oclass,
 			       NULL, 0, &obj->engobj.object);
 	if (ret)
 		nouveau_abi16_obj_del(obj);
@@ -796,7 +796,7 @@ nouveau_abi16_ioctl_sclass(struct nouveau_abi16 *abi16, struct nvif_ioctl_v0 *io
 	if (!chan)
 		return -EINVAL;
 
-	ret = nvif_object_sclass_get(&chan->chan->user, &sclass);
+	ret = nvif_object_sclass_get(&chan->chan->chan.object, &sclass);
 	if (ret < 0)
 		return ret;
 
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
index 7db05d6699d8..6c5426fe2007 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -965,7 +965,7 @@ nouveau_bo_move_init(struct nouveau_drm *drm)
 		if (chan == NULL)
 			continue;
 
-		ret = nvif_object_ctor(&chan->user, "ttmBoMove",
+		ret = nvif_object_ctor(&chan->chan.object, "ttmBoMove",
 				       mthd->oclass | (mthd->engine << 16),
 				       mthd->oclass, NULL, 0,
 				       &drm->ttm.copy);
diff --git a/drivers/gpu/drm/nouveau/nouveau_chan.c b/drivers/gpu/drm/nouveau/nouveau_chan.c
index 7c57bc48a8af..21927b817fa8 100644
--- a/drivers/gpu/drm/nouveau/nouveau_chan.c
+++ b/drivers/gpu/drm/nouveau/nouveau_chan.c
@@ -93,7 +93,7 @@ nouveau_channel_del(struct nouveau_channel **pchan)
 		if (chan->fence)
 			nouveau_fence(chan->cli->drm)->context_del(chan);
 
-		if (nvif_object_constructed(&chan->user))
+		if (chan->chan.impl)
 			nouveau_svmm_part(chan->vmm->svmm, chan->inst);
 
 		nvif_object_dtor(&chan->blit);
@@ -104,7 +104,7 @@ nouveau_channel_del(struct nouveau_channel **pchan)
 		if (!chan->userd.map.impl)
 			chan->userd.map.ptr = NULL;
 		nvif_object_unmap_cpu(&chan->userd.map);
-		nvif_object_dtor(&chan->user);
+		nvif_chan_dtor(&chan->chan);
 		nvif_mem_dtor(&chan->userd.mem);
 		nvif_ctxdma_dtor(&chan->push.ctxdma);
 		nouveau_vma_del(&chan->push.vma);
@@ -258,10 +258,6 @@ nouveau_channel_ctor(struct nouveau_cli *cli, bool priv, u64 runm,
 {
 	struct nvif_device *device = &cli->device;
 	const u32 oclass = device->impl->fifo.chan.oclass;
-	struct {
-		struct nvif_chan_v0 chan;
-		char name[TASK_COMM_LEN+16];
-	} args;
 	struct nouveau_channel *chan;
 	const u64 plength = 0x10000;
 	const u64 ioffset = plength;
@@ -269,6 +265,11 @@ nouveau_channel_ctor(struct nouveau_cli *cli, bool priv, u64 runm,
 	char name[TASK_COMM_LEN];
 	int ret;
 	u64 size;
+	struct nvif_vmm_priv *vmm = NULL;
+	struct nvif_ctxdma_priv *ctxdma = NULL;
+	struct nvif_mem_priv *userd = NULL;
+	u64 offset, length = 0;
+	u16 userd_offset = 0;
 
 	switch (oclass) {
 	case  AMPERE_CHANNEL_GPFIFO_B:
@@ -306,28 +307,17 @@ nouveau_channel_ctor(struct nouveau_cli *cli, bool priv, u64 runm,
 	chan->runlist = __ffs64(runm);
 
 	/* create channel object */
-	args.chan.version = 0;
-	args.chan.namelen = sizeof(args.name);
-	args.chan.runlist = cli->drm->device.impl->fifo.runl[chan->runlist].id;
-	args.chan.runq = 0;
-	args.chan.priv = priv;
-	args.chan.devm = BIT(0);
 	if (oclass < NV50_CHANNEL_GPFIFO) {
-		args.chan.vmm = 0;
-		args.chan.ctxdma = nvif_handle(&chan->push.ctxdma.object);
-		args.chan.offset = chan->push.addr;
-		args.chan.length = 0;
+		ctxdma = chan->push.ctxdma.priv;
+		offset = chan->push.addr;
 	} else {
-		args.chan.vmm = nvif_handle(&chan->vmm->vmm.object);
-		if (oclass < FERMI_CHANNEL_GPFIFO)
-			args.chan.ctxdma = nvif_handle(&chan->push.ctxdma.object);
-		else
-			args.chan.ctxdma = 0;
-		args.chan.offset = ioffset + chan->push.addr;
-		args.chan.length = ilength;
+		vmm = chan->vmm->vmm.priv;
+		if (device->impl->fifo.chan.oclass < FERMI_CHANNEL_GPFIFO)
+			ctxdma = chan->push.ctxdma.priv;
+
+		offset = ioffset + chan->push.addr;
+		length = ilength;
 	}
-	args.chan.huserd = 0;
-	args.chan.ouserd = 0;
 
 	/* allocate userd */
 	if (oclass >= VOLTA_CHANNEL_GPFIFO_A) {
@@ -337,23 +327,26 @@ nouveau_channel_ctor(struct nouveau_cli *cli, bool priv, u64 runm,
 		if (ret)
 			return ret;
 
-		args.chan.huserd = nvif_handle(&chan->userd.mem.object);
-		args.chan.ouserd = 0;
+		userd = chan->userd.mem.priv;
 	}
 
 	get_task_comm(name, current);
-	snprintf(args.name, sizeof(args.name), "%s[%d]", name, task_pid_nr(current));
+	snprintf(chan->name, sizeof(chan->name), "%s[%d]", name, task_pid_nr(current));
 
-	ret = nvif_object_ctor(&device->object, "abi16ChanUser", 0, oclass,
-			       &args, sizeof(args), &chan->user);
+	ret = device->impl->fifo.chan.new(device->priv, device->impl->fifo.runl[chan->runlist].id,
+					  0, priv, BIT(0), vmm, ctxdma, offset, length,
+					  userd, userd_offset, chan->name,
+					  &chan->chan.impl, &chan->chan.priv,
+					  nvif_handle(&chan->chan.object));
 	if (ret) {
 		nouveau_channel_del(pchan);
 		return ret;
 	}
 
-	chan->chid = args.chan.chid;
-	chan->inst = args.chan.inst;
-	chan->token = args.chan.token;
+	nvif_chan_ctor(device, NULL, chan->name, chan->runlist, 0, &chan->chan);
+	chan->chid = chan->chan.impl->id;
+	chan->inst = chan->chan.impl->inst.addr;
+	chan->token = chan->chan.impl->doorbell_token;
 	return 0;
 }
 
@@ -366,18 +359,18 @@ nouveau_channel_init(struct nouveau_channel *chan, u32 vram, u32 gart)
 	int ret, i;
 
 	if (!chan->userd.mem.impl) {
-		ret = nvif_object_map(&chan->user, NULL, 0);
+		ret = nvif_object_map(&chan->chan.object, NULL, 0);
 		if (ret)
 			return ret;
 
-		chan->userd.map.ptr = chan->user.map.ptr;
+		chan->userd.map.ptr = chan->chan.object.map.ptr;
 	} else {
 		ret = nvif_mem_map(&chan->userd.mem, NULL, 0, &chan->userd.map);
 		if (ret)
 			return ret;
 	}
 
-	if (chan->user.oclass >= FERMI_CHANNEL_GPFIFO) {
+	if (chan->chan.object.oclass >= FERMI_CHANNEL_GPFIFO) {
 		struct {
 			struct nvif_event_v0 base;
 			struct nvif_chan_event_v0 host;
@@ -386,7 +379,7 @@ nouveau_channel_init(struct nouveau_channel *chan, u32 vram, u32 gart)
 		args.host.version = 0;
 		args.host.type = NVIF_CHAN_EVENT_V0_KILLED;
 
-		ret = nvif_event_ctor(&chan->user, "abi16ChanKilled", chan->chid,
+		ret = nvif_event_ctor(&chan->chan.object, "abi16ChanKilled", chan->chid,
 				      nouveau_channel_killed, false,
 				      &args.base, sizeof(args), &chan->kill);
 		if (ret == 0)
@@ -412,7 +405,7 @@ nouveau_channel_init(struct nouveau_channel *chan, u32 vram, u32 gart)
 			args.limit = device->info.ram_user - 1;
 		}
 
-		ret = nvif_object_ctor(&chan->user, "abi16ChanVramCtxDma", vram,
+		ret = nvif_object_ctor(&chan->chan.object, "abi16ChanVramCtxDma", vram,
 				       NV_DMA_IN_MEMORY, &args, sizeof(args),
 				       &chan->vram);
 		if (ret)
@@ -436,7 +429,7 @@ nouveau_channel_init(struct nouveau_channel *chan, u32 vram, u32 gart)
 			args.limit = chan->vmm->vmm.impl->limit - 1;
 		}
 
-		ret = nvif_object_ctor(&chan->user, "abi16ChanGartCtxDma", gart,
+		ret = nvif_object_ctor(&chan->chan.object, "abi16ChanGartCtxDma", gart,
 				       NV_DMA_IN_MEMORY, &args, sizeof(args),
 				       &chan->gart);
 		if (ret)
@@ -444,7 +437,7 @@ nouveau_channel_init(struct nouveau_channel *chan, u32 vram, u32 gart)
 	}
 
 	/* initialise dma tracking parameters */
-	switch (chan->user.oclass) {
+	switch (chan->chan.object.oclass) {
 	case NV03_CHANNEL_DMA:
 	case NV10_CHANNEL_DMA:
 	case NV17_CHANNEL_DMA:
@@ -478,7 +471,7 @@ nouveau_channel_init(struct nouveau_channel *chan, u32 vram, u32 gart)
 
 	/* allocate software object class (used for fences on <= nv05) */
 	if (device->info.family < NV_DEVICE_INFO_V0_CELSIUS) {
-		ret = nvif_object_ctor(&chan->user, "abi16NvswFence", 0x006e,
+		ret = nvif_object_ctor(&chan->chan.object, "abi16NvswFence", 0x006e,
 				       NVIF_CLASS_SW_NV04,
 				       NULL, 0, &chan->nvsw);
 		if (ret)
diff --git a/drivers/gpu/drm/nouveau/nouveau_chan.h b/drivers/gpu/drm/nouveau/nouveau_chan.h
index 786c929843d1..8f71492e2df3 100644
--- a/drivers/gpu/drm/nouveau/nouveau_chan.h
+++ b/drivers/gpu/drm/nouveau/nouveau_chan.h
@@ -4,13 +4,12 @@
 #include <nvif/object.h>
 #include <nvif/ctxdma.h>
 #include <nvif/event.h>
-#include <nvif/push.h>
+#include <nvif/chan.h>
 struct nvif_device;
 
 struct nouveau_channel {
-	struct {
-		struct nvif_push push;
-	} chan;
+	char name[TASK_COMM_LEN+16];
+	struct nvif_chan chan;
 
 	struct nouveau_cli *cli;
 	struct nouveau_vmm *vmm;
@@ -53,7 +52,6 @@ struct nouveau_channel {
 	u32 user_get;
 	u32 user_put;
 
-	struct nvif_object user;
 	struct nvif_object blit;
 
 	struct nvif_event kill;
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 8ab6b9e03eb5..a2c9e8fa4ebd 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -316,12 +316,12 @@ nouveau_accel_gr_init(struct nouveau_drm *drm)
 	 * on TNT/TNT2 HW that lacks any kind of support in host.
 	 */
 	if (!drm->channel->nvsw.client && device->info.family < NV_DEVICE_INFO_V0_TESLA) {
-		ret = nvif_object_ctor(&drm->channel->user, "drmNvsw",
+		ret = nvif_object_ctor(&drm->channel->chan.object, "drmNvsw",
 				       NVDRM_NVSW, nouveau_abi16_swclass(drm),
 				       NULL, 0, &drm->channel->nvsw);
 
 		if (ret == 0 && device->info.chipset >= 0x11) {
-			ret = nvif_object_ctor(&drm->channel->user, "drmBlit",
+			ret = nvif_object_ctor(&drm->channel->chan.object, "drmBlit",
 					       0x005f, 0x009f,
 					       NULL, 0, &drm->channel->blit);
 		}
@@ -361,7 +361,7 @@ nouveau_accel_gr_init(struct nouveau_drm *drm)
 			return;
 		}
 
-		ret = nvif_object_ctor(&drm->channel->user, "drmM2mfNtfy",
+		ret = nvif_object_ctor(&drm->channel->chan.object, "drmM2mfNtfy",
 				       NvNotify0, NV_DMA_IN_MEMORY,
 				       (&(struct nv_dma_v0) {
 						.target = NV_DMA_V0_TARGET_VRAM,
diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.c b/drivers/gpu/drm/nouveau/nouveau_fence.c
index 09686d038d60..ff31784effeb 100644
--- a/drivers/gpu/drm/nouveau/nouveau_fence.c
+++ b/drivers/gpu/drm/nouveau/nouveau_fence.c
@@ -210,7 +210,8 @@ nouveau_fence_context_new(struct nouveau_channel *chan, struct nouveau_fence_cha
 	args.host.version = 0;
 	args.host.type = NVIF_CHAN_EVENT_V0_NON_STALL_INTR;
 
-	ret = nvif_event_ctor(&chan->user, "fenceNonStallIntr", (chan->runlist << 16) | chan->chid,
+	ret = nvif_event_ctor(&chan->chan.object, "fenceNonStallIntr",
+			      (chan->runlist << 16) | chan->chid,
 			      nouveau_fence_wait_uevent_handler, false,
 			      &args.base, sizeof(args), &fctx->event);
 
diff --git a/drivers/gpu/drm/nouveau/nv17_fence.c b/drivers/gpu/drm/nouveau/nv17_fence.c
index 5b4ceac49225..17ff00b22e9e 100644
--- a/drivers/gpu/drm/nouveau/nv17_fence.c
+++ b/drivers/gpu/drm/nouveau/nv17_fence.c
@@ -92,7 +92,7 @@ nv17_fence_context_new(struct nouveau_channel *chan)
 	fctx->base.read = nv10_fence_read;
 	fctx->base.sync = nv17_fence_sync;
 
-	ret = nvif_object_ctor(&chan->user, "fenceCtxDma", NvSema,
+	ret = nvif_object_ctor(&chan->chan.object, "fenceCtxDma", NvSema,
 			       NV_DMA_FROM_MEMORY,
 			       (&(struct nv_dma_v0) {
 					.target = NV_DMA_V0_TARGET_VRAM,
diff --git a/drivers/gpu/drm/nouveau/nv50_fence.c b/drivers/gpu/drm/nouveau/nv50_fence.c
index 1d8792fdd89b..b418439e6bb1 100644
--- a/drivers/gpu/drm/nouveau/nv50_fence.c
+++ b/drivers/gpu/drm/nouveau/nv50_fence.c
@@ -51,7 +51,7 @@ nv50_fence_context_new(struct nouveau_channel *chan)
 	fctx->base.read = nv10_fence_read;
 	fctx->base.sync = nv17_fence_sync;
 
-	ret = nvif_object_ctor(&chan->user, "fenceCtxDma", NvSema,
+	ret = nvif_object_ctor(&chan->chan.object, "fenceCtxDma", NvSema,
 			       NV_DMA_IN_MEMORY,
 			       (&(struct nv_dma_v0) {
 					.target = NV_DMA_V0_TARGET_VRAM,
diff --git a/drivers/gpu/drm/nouveau/nvif/Kbuild b/drivers/gpu/drm/nouveau/nvif/Kbuild
index 50489933655c..757e10e8dce5 100644
--- a/drivers/gpu/drm/nouveau/nvif/Kbuild
+++ b/drivers/gpu/drm/nouveau/nvif/Kbuild
@@ -2,6 +2,7 @@
 nvif-y := nvif/object.o
 nvif-y += nvif/client.o
 nvif-y += nvif/cgrp.o
+nvif-y += nvif/chan.o
 nvif-y += nvif/conn.o
 nvif-y += nvif/device.o
 nvif-y += nvif/disp.o
diff --git a/drivers/gpu/drm/nouveau/nvif/chan.c b/drivers/gpu/drm/nouveau/nvif/chan.c
new file mode 100644
index 000000000000..cfca4dac5388
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/nvif/chan.c
@@ -0,0 +1,45 @@
+/*
+ * 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 <nvif/chan.h>
+#include <nvif/cgrp.h>
+#include <nvif/device.h>
+
+void
+nvif_chan_dtor(struct nvif_chan *chan)
+{
+	if (!chan->impl)
+		return;
+
+	chan->impl->del(chan->priv);
+	chan->impl = NULL;
+}
+
+void
+nvif_chan_ctor(struct nvif_device *device, struct nvif_cgrp *cgrp, const char *name,
+	       u8 runl, u8 runq, struct nvif_chan *chan)
+{
+	nvif_object_ctor(!cgrp ? &device->object : &cgrp->object, name, chan->impl->id,
+			 device->impl->fifo.chan.oclass, &chan->object);
+	chan->device = device;
+	chan->runl = runl;
+	chan->runq = runq;
+}
diff --git a/drivers/gpu/drm/nouveau/nvkm/device/user.c b/drivers/gpu/drm/nouveau/nvkm/device/user.c
index fc81d595bdb7..c1ccb75db3c1 100644
--- a/drivers/gpu/drm/nouveau/nvkm/device/user.c
+++ b/drivers/gpu/drm/nouveau/nvkm/device/user.c
@@ -31,11 +31,13 @@
 #include <subdev/instmem.h>
 #include <subdev/timer.h>
 #include <subdev/mmu/ummu.h>
+#include <subdev/mmu/uvmm.h>
 #include <subdev/vfn/uvfn.h>
 #include <engine/disp/priv.h>
 #include <engine/disp/udisp.h>
 #include <engine/fifo/ufifo.h>
 #include <engine/fifo/ucgrp.h>
+#include <engine/fifo/uchan.h>
 
 struct nvif_device_priv {
 	struct nvkm_object object;
@@ -95,6 +97,27 @@ nvkm_udevice_time(struct nvif_device_priv *udev)
 	return nvkm_timer_read(udev->device->timer);
 }
 
+static int
+nvkm_udevice_chan_new(struct nvif_device_priv *udev, u8 runl, u8 runq, bool priv, u16 devm,
+		      struct nvif_vmm_priv *uvmm, struct nvif_ctxdma_priv *push,
+		      u64 offset, u64 length, struct nvif_mem_priv *userd, u16 userd_offset,
+		      const char *name, const struct nvif_chan_impl **pimpl,
+		      struct nvif_chan_priv **ppriv, u64 handle)
+{
+	struct nvkm_vmm *vmm = nvkm_uvmm_ref(uvmm);
+	struct nvkm_object *object;
+	int ret;
+
+	ret = nvkm_uchan_new(udev->device, NULL, runl, runq, priv, devm, vmm,
+			     push, offset, length, userd, userd_offset, name,
+			     pimpl, ppriv, &object);
+	nvkm_vmm_unref(&vmm);
+	if (ret)
+		return ret;
+
+	return nvkm_object_link_rb(udev->object.client, &udev->object, handle, object);
+}
+
 static int
 nvkm_udevice_cgrp_new(struct nvif_device_priv *udev, u8 runl, struct nvif_vmm_priv *uvmm,
 		      const char *name, const struct nvif_cgrp_impl **pimpl,
@@ -394,6 +417,7 @@ nvkm_udevice_new(struct nvkm_device *device,
 			nvkm_ufifo_ctor(device->fifo, &udev->impl.fifo);
 
 			udev->impl.fifo.cgrp.new = nvkm_udevice_cgrp_new;
+			udev->impl.fifo.chan.new = nvkm_udevice_chan_new;
 		}
 	}
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/base.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/base.c
index 1894a2075079..181c8cf426ab 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/base.c
@@ -69,44 +69,6 @@ nvkm_fifo_fault(struct nvkm_fifo *fifo, struct nvkm_fault_data *info)
 	return fifo->func->mmu_fault->recover(fifo, info);
 }
 
-static int
-nvkm_fifo_class_new(struct nvkm_device *device, const struct nvkm_oclass *oclass,
-		    void *argv, u32 argc, struct nvkm_object **pobject)
-{
-	struct nvkm_fifo *fifo = nvkm_fifo(oclass->engine);
-
-	if (oclass->engn == &fifo->func->chan.user)
-		return nvkm_uchan_new(fifo, NULL, oclass, argv, argc, pobject);
-
-	WARN_ON(1);
-	return -ENOSYS;
-}
-
-static const struct nvkm_device_oclass
-nvkm_fifo_class = {
-	.ctor = nvkm_fifo_class_new,
-};
-
-static int
-nvkm_fifo_class_get(struct nvkm_oclass *oclass, int index, const struct nvkm_device_oclass **class)
-{
-	struct nvkm_fifo *fifo = nvkm_fifo(oclass->engine);
-	const struct nvkm_fifo_func_chan *chan = &fifo->func->chan;
-	int c = 0;
-
-	/* *_CHANNEL_DMA, *_CHANNEL_GPFIFO_* */
-	if (chan->user.oclass) {
-		if (c++ == index) {
-			oclass->base = chan->user;
-			oclass->engn = &fifo->func->chan.user;
-			*class = &nvkm_fifo_class;
-			return 0;
-		}
-	}
-
-	return c;
-}
-
 static int
 nvkm_fifo_fini(struct nvkm_engine *engine, bool suspend)
 {
@@ -281,7 +243,6 @@ nvkm_fifo = {
 	.oneinit = nvkm_fifo_oneinit,
 	.init = nvkm_fifo_init,
 	.fini = nvkm_fifo_fini,
-	.base.sclass = nvkm_fifo_class_get,
 };
 
 int
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/priv.h b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/priv.h
index d1386d00fc36..cd02f31b601a 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/priv.h
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/priv.h
@@ -205,7 +205,4 @@ extern const struct nvkm_engn_func ga100_engn;
 extern const struct nvkm_engn_func ga100_engn_ce;
 extern const struct nvkm_cgrp_func ga100_cgrp;
 extern const struct nvkm_chan_func ga100_chan;
-
-int nvkm_uchan_new(struct nvkm_fifo *, struct nvkm_cgrp *, const struct nvkm_oclass *,
-		   void *argv, u32 argc, struct nvkm_object **);
 #endif
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/ucgrp.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/ucgrp.c
index 8acfd85cee53..90a85c1c0b56 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/ucgrp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/ucgrp.c
@@ -25,6 +25,7 @@
 #include "runl.h"
 
 #include <subdev/mmu/uvmm.h>
+#include <engine/fifo/uchan.h>
 
 struct nvif_cgrp_priv {
 	struct nvkm_object object;
@@ -34,32 +35,23 @@ struct nvif_cgrp_priv {
 };
 
 static int
-nvkm_ucgrp_chan_new(const struct nvkm_oclass *oclass, void *argv, u32 argc,
-		    struct nvkm_object **pobject)
+nvkm_ucgrp_chan_new(struct nvif_cgrp_priv *ucgrp, u8 runq, bool priv, u16 devm,
+		    u64 gpfifo_offset, u64 gpfifo_length,
+		    struct nvif_mem_priv *userd, u16 userd_offset, const char *name,
+		    const struct nvif_chan_impl **pimpl, struct nvif_chan_priv **ppriv)
 {
-	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);
-}
+	struct nvkm_cgrp *cgrp = ucgrp->cgrp;
+	struct nvkm_object *object;
+	int ret;
 
-static int
-nvkm_ucgrp_sclass(struct nvkm_object *object, int index, struct nvkm_oclass *oclass)
-{
-	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;
-
-	/* *_CHANNEL_GPFIFO_* */
-	if (chan->user.oclass) {
-		if (c++ == index) {
-			oclass->base = chan->user;
-			oclass->ctor = nvkm_ucgrp_chan_new;
-			return 0;
-		}
-	}
+	ret = nvkm_uchan_new(cgrp->runl->fifo->engine.subdev.device, cgrp, cgrp->runl->id,
+			     runq, priv, devm, cgrp->vmm, NULL, gpfifo_offset, gpfifo_length,
+			     userd, userd_offset, name, pimpl, ppriv, &object);
+	if (ret)
+		return ret;
 
-	return -EINVAL;
+	nvkm_object_link(&ucgrp->object, object);
+	return 0;
 }
 
 static void
@@ -73,6 +65,7 @@ nvkm_ucgrp_del(struct nvif_cgrp_priv *ucgrp)
 static const struct nvif_cgrp_impl
 nvkm_ucgrp_impl = {
 	.del = nvkm_ucgrp_del,
+	.chan.new = nvkm_ucgrp_chan_new,
 };
 
 static void *
@@ -87,7 +80,6 @@ nvkm_ucgrp_dtor(struct nvkm_object *object)
 static const struct nvkm_object_func
 nvkm_ucgrp = {
 	.dtor = nvkm_ucgrp_dtor,
-	.sclass = nvkm_ucgrp_sclass,
 };
 
 int
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/uchan.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/uchan.c
index 23d992413442..f21cd52d5ae3 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/uchan.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/uchan.c
@@ -24,10 +24,12 @@
 #include "chan.h"
 #include "chid.h"
 #include "runl.h"
+#include "uchan.h"
 
 #include <core/gpuobj.h>
 #include <core/oproxy.h>
 #include <subdev/mmu.h>
+#include <subdev/mmu/umem.h>
 #include <engine/dma.h>
 
 #include <nvif/if0020.h>
@@ -35,6 +37,8 @@
 struct nvif_chan_priv {
 	struct nvkm_object object;
 	struct nvkm_chan *chan;
+
+	struct nvif_chan_impl impl;
 };
 
 static int
@@ -267,6 +271,20 @@ nvkm_uchan_map(struct nvkm_object *object, void *argv, u32 argc,
 	return 0;
 }
 
+static void
+nvkm_uchan_del(struct nvif_chan_priv *uchan)
+{
+	struct nvkm_object *object = &uchan->object;
+
+	nvkm_object_fini(object, false);
+	nvkm_object_del(&object);
+}
+
+static const struct nvif_chan_impl
+nvkm_uchan_impl = {
+	.del = nvkm_uchan_del,
+};
+
 static int
 nvkm_uchan_fini(struct nvkm_object *object, bool suspend)
 {
@@ -326,92 +344,84 @@ nvkm_uchan_chan(struct nvkm_object *object)
 }
 
 int
-nvkm_uchan_new(struct nvkm_fifo *fifo, struct nvkm_cgrp *cgrp, const struct nvkm_oclass *oclass,
-	       void *argv, u32 argc, struct nvkm_object **pobject)
+nvkm_uchan_new(struct nvkm_device *device, struct nvkm_cgrp *cgrp, u8 runi, u8 runq, bool priv,
+	       u16 devm, struct nvkm_vmm *vmm, struct nvif_ctxdma_priv *upush, u64 offset,
+	       u64 length, struct nvif_mem_priv *uuserd, u16 userd_offset, const char *name,
+	       const struct nvif_chan_impl **pimpl, struct nvif_chan_priv **ppriv,
+	       struct nvkm_object **pobject)
 {
-	union nvif_chan_args *args = argv;
+	struct nvkm_fifo *fifo = device->fifo;
 	struct nvkm_runl *runl;
-	struct nvkm_vmm *vmm = NULL;
-	struct nvkm_dmaobj *ctxdma = NULL;
+	struct nvkm_dmaobj *ctxdma = (void *)upush;
 	struct nvkm_memory *userd = NULL;
 	struct nvif_chan_priv *uchan;
+	struct nvkm_engine *engine;
 	struct nvkm_chan *chan;
 	int ret;
 
-	if (argc < sizeof(args->v0) || args->v0.version != 0)
-		return -ENOSYS;
-	argc -= sizeof(args->v0);
-
-	if (args->v0.namelen != argc)
-		return -EINVAL;
-
 	/* Lookup objects referenced in args. */
-	runl = nvkm_runl_get(fifo, args->v0.runlist, 0);
+	runl = nvkm_runl_get(fifo, runi, 0);
 	if (!runl)
 		return -EINVAL;
 
-	if (args->v0.vmm) {
-		vmm = nvkm_uvmm_search(oclass->client, args->v0.vmm);
-		if (IS_ERR(vmm))
-			return PTR_ERR(vmm);
-	}
+	ctxdma = (void *)upush;
+	userd = nvkm_umem_ref(uuserd);
 
-	if (args->v0.ctxdma) {
-		ctxdma = nvkm_dmaobj_search(oclass->client, args->v0.ctxdma);
-		if (IS_ERR(ctxdma)) {
-			ret = PTR_ERR(ctxdma);
-			goto done;
-		}
+	/* Allocate channel. */
+	uchan = kzalloc(sizeof(*uchan), GFP_KERNEL);
+	if (!uchan) {
+		nvkm_memory_unref(&userd);
+		return -ENOMEM;
 	}
 
-	if (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;
-			goto done;
-		}
+	engine = nvkm_engine_ref(&fifo->engine);
+	if (IS_ERR(engine)) {
+		kfree(uchan);
+		nvkm_memory_unref(&userd);
+		return PTR_ERR(engine);
 	}
 
-	/* Allocate channel. */
-	if (!(uchan = kzalloc(sizeof(*uchan), GFP_KERNEL))) {
-		ret = -ENOMEM;
-		goto done;
-	}
+	nvkm_object_ctor(&nvkm_uchan, &(struct nvkm_oclass) { .engine = engine }, &uchan->object);
 
-	nvkm_object_ctor(&nvkm_uchan, oclass, &uchan->object);
-	*pobject = &uchan->object;
+	ret = nvkm_chan_new_(fifo->func->chan.func, runl, runq, cgrp, name, priv, devm,
+			     vmm, ctxdma, offset, length, userd, userd_offset,
+			     &uchan->chan);
+	if (ret)
+		goto done;
 
-	ret = nvkm_chan_new_(fifo->func->chan.func, runl, args->v0.runq, cgrp, args->v0.name,
-			     args->v0.priv != 0, args->v0.devm, vmm, ctxdma, args->v0.offset,
-			     args->v0.length, userd, args->v0.ouserd, &uchan->chan);
+	ret = nvkm_uchan_init(&uchan->object);
 	if (ret)
 		goto done;
 
 	chan = uchan->chan;
 
 	/* Return channel info to caller. */
+	uchan->impl = nvkm_uchan_impl;
+	uchan->impl.id = chan->id;
 	if (chan->func->doorbell_handle)
-		args->v0.token = chan->func->doorbell_handle(chan);
-	else
-		args->v0.token = ~0;
-
-	args->v0.chid = chan->id;
+		uchan->impl.doorbell_token = chan->func->doorbell_handle(chan);
 
 	switch (nvkm_memory_target(chan->inst->memory)) {
-	case NVKM_MEM_TARGET_INST: args->v0.aper = NVIF_CHAN_V0_INST_APER_INST; break;
-	case NVKM_MEM_TARGET_VRAM: args->v0.aper = NVIF_CHAN_V0_INST_APER_VRAM; break;
-	case NVKM_MEM_TARGET_HOST: args->v0.aper = NVIF_CHAN_V0_INST_APER_HOST; break;
-	case NVKM_MEM_TARGET_NCOH: args->v0.aper = NVIF_CHAN_V0_INST_APER_NCOH; break;
+	case NVKM_MEM_TARGET_INST: uchan->impl.inst.aper = NVIF_CHAN_INST_APER_INST; break;
+	case NVKM_MEM_TARGET_VRAM: uchan->impl.inst.aper = NVIF_CHAN_INST_APER_VRAM; break;
+	case NVKM_MEM_TARGET_HOST: uchan->impl.inst.aper = NVIF_CHAN_INST_APER_HOST; break;
+	case NVKM_MEM_TARGET_NCOH: uchan->impl.inst.aper = NVIF_CHAN_INST_APER_NCOH; break;
 	default:
 		WARN_ON(1);
 		ret = -EFAULT;
-		break;
+		goto done;
 	}
 
-	args->v0.inst = nvkm_memory_addr(chan->inst->memory);
+	uchan->impl.inst.addr = nvkm_memory_addr(chan->inst->memory);
+
+	*pimpl = &uchan->impl;
+	*ppriv = uchan;
+	*pobject = &uchan->object;
+
 done:
+	if (ret)
+		nvkm_uchan_del(uchan);
+
 	nvkm_memory_unref(&userd);
-	nvkm_vmm_unref(&vmm);
 	return ret;
 }
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/uchan.h b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/uchan.h
new file mode 100644
index 000000000000..1ab4047644ef
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/uchan.h
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: MIT */
+#ifndef __NVKM_UCHAN_H__
+#define __NVKM_UCHAN_H__
+#include <engine/fifo.h>
+#include <nvif/driverif.h>
+
+int nvkm_uchan_new(struct nvkm_device *, struct nvkm_cgrp *, u8 runl, u8 runq, bool priv, u16 devm,
+		   struct nvkm_vmm *, struct nvif_ctxdma_priv *push, u64 offset, u64 length,
+		   struct nvif_mem_priv *userd, u16 userd_offset, const char *name,
+		   const struct nvif_chan_impl **, struct nvif_chan_priv **, struct nvkm_object **);
+#endif
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 137/156] drm/nouveau/nvif: remove mem from object rb
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (135 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 136/156] drm/nouveau/nvif: rework device/cgrp "new chan" apis Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 138/156] drm/nouveau/nvif: remove vmm " Ben Skeggs
                   ` (20 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- also removes umem list hack
- no more users

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  2 +-
 .../gpu/drm/nouveau/include/nvkm/subdev/mmu.h |  4 ---
 drivers/gpu/drm/nouveau/nvif/mem.c            |  3 +-
 .../gpu/drm/nouveau/nvkm/subdev/mmu/base.c    |  2 --
 .../gpu/drm/nouveau/nvkm/subdev/mmu/umem.c    | 36 -------------------
 .../gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c    |  5 +--
 6 files changed, 5 insertions(+), 47 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index cc858955a97b..0a460eaaf76b 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -202,7 +202,7 @@ struct nvif_mmu_impl {
 	struct {
 		s32 oclass;
 		int (*new)(struct nvif_mmu_priv *, u8 type, u8 page, u64 size, void *argv, u32 argc,
-			   const struct nvif_mem_impl **, struct nvif_mem_priv **, u64 handle);
+			   const struct nvif_mem_impl **, struct nvif_mem_priv **);
 	} mem;
 
 	struct {
diff --git a/drivers/gpu/drm/nouveau/include/nvkm/subdev/mmu.h b/drivers/gpu/drm/nouveau/include/nvkm/subdev/mmu.h
index f2d23bfdf29a..6a1472b9499f 100644
--- a/drivers/gpu/drm/nouveau/include/nvkm/subdev/mmu.h
+++ b/drivers/gpu/drm/nouveau/include/nvkm/subdev/mmu.h
@@ -109,7 +109,6 @@ 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_mmu *, struct nvkm_client *, u64);
 struct nvkm_vmm *nvkm_uvmm_search(struct nvkm_client *, u64 handle);
 
 struct nvkm_mmu {
@@ -148,9 +147,6 @@ 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 **);
diff --git a/drivers/gpu/drm/nouveau/nvif/mem.c b/drivers/gpu/drm/nouveau/nvif/mem.c
index 91faecc4c080..3aa04ed651c8 100644
--- a/drivers/gpu/drm/nouveau/nvif/mem.c
+++ b/drivers/gpu/drm/nouveau/nvif/mem.c
@@ -105,8 +105,7 @@ nvif_mem_ctor_type(struct nvif_mmu *mmu, const char *name,
 	if (type < 0)
 		return -EINVAL;
 
-	ret = mmu->impl->mem.new(mmu->priv, type, page, size, argv, argc, &mem->impl, &mem->priv,
-				 nvif_handle(&mem->object));
+	ret = mmu->impl->mem.new(mmu->priv, type, page, size, argv, argc, &mem->impl, &mem->priv);
 	NVIF_DEBUG(&mmu->object, "[NEW mem%08x] (ret:%d)", oclass, ret);
 	if (ret)
 		return ret;
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/base.c
index 08ad3ed84631..c7fe7222c3a3 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/base.c
@@ -427,8 +427,6 @@ nvkm_mmu_ctor(const struct nvkm_mmu_func *func, struct nvkm_device *device,
 	nvkm_mmu_ptc_init(mmu);
 	mutex_init(&mmu->mutex);
 	mmu->user.base = func->mmu.user;
-	spin_lock_init(&mmu->umem_lock);
-	INIT_LIST_HEAD(&mmu->umem);
 }
 
 int
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.c
index 0676615093bb..93324d4f9d22 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.c
@@ -57,35 +57,6 @@ nvkm_umem_ref(struct nvif_mem_priv *umem)
 	return NULL;
 }
 
-static const struct nvkm_object_func nvkm_umem;
-struct nvkm_memory *
-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;
-	struct nvkm_object *object;
-	struct nvif_mem_priv *umem;
-
-	object = nvkm_object_search(client, handle, &nvkm_umem);
-	if (IS_ERR(object)) {
-		if (client != master) {
-			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(&mmu->umem_lock);
-		}
-	} else {
-		umem = container_of(object, typeof(*umem), object);
-		memory = nvkm_memory_ref(umem->memory);
-	}
-
-	return memory ? memory : ERR_PTR(-ENOENT);
-}
-
 static int
 nvkm_umem_unmap(struct nvif_mem_priv *umem)
 {
@@ -163,9 +134,6 @@ nvkm_umem_dtor(struct nvkm_object *object)
 {
 	struct nvif_mem_priv *umem = container_of(object, typeof(*umem), object);
 
-	spin_lock(&umem->mmu->umem_lock);
-	list_del_init(&umem->head);
-	spin_unlock(&umem->mmu->umem_lock);
 	nvkm_memory_unref(&umem->memory);
 	return umem;
 }
@@ -203,10 +171,6 @@ nvkm_umem_new(struct nvkm_mmu *mmu, u8 type, u8 page, u64 size, void *argv, u32
 	if (ret)
 		return ret;
 
-	spin_lock(&mmu->umem_lock);
-	list_add(&umem->head, &mmu->umem);
-	spin_unlock(&mmu->umem_lock);
-
 	umem->impl = nvkm_umem_impl;
 	umem->impl.page = nvkm_memory_page(umem->memory);
 	umem->impl.addr = nvkm_memory_addr(umem->memory);
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c
index 7afb68dc4bed..b3883758828d 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c
@@ -42,7 +42,7 @@ nvkm_ummu_vmm_new(struct nvif_mmu_priv *ummu, enum nvif_vmm_type type, u64 addr,
 
 static int
 nvkm_ummu_mem_new(struct nvif_mmu_priv *ummu, u8 type, u8 page, u64 size, void *argv, u32 argc,
-		  const struct nvif_mem_impl **pimpl, struct nvif_mem_priv **ppriv, u64 handle)
+		  const struct nvif_mem_impl **pimpl, struct nvif_mem_priv **ppriv)
 {
 	struct nvkm_object *object;
 	int ret;
@@ -51,7 +51,8 @@ nvkm_ummu_mem_new(struct nvif_mmu_priv *ummu, u8 type, u8 page, u64 size, void *
 	if (ret)
 		return ret;
 
-	return nvkm_object_link_rb(ummu->object.client, &ummu->object, handle, object);
+	nvkm_object_link(&ummu->object, object);
+	return 0;
 }
 
 static void
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 138/156] drm/nouveau/nvif: remove vmm from object rb
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (136 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 137/156] drm/nouveau/nvif: remove mem from object rb Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 139/156] drm/nouveau/nvif: remove ctxdma " Ben Skeggs
                   ` (19 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- no more users

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/include/nvif/driverif.h   |  3 +--
 drivers/gpu/drm/nouveau/include/nvkm/subdev/mmu.h |  2 --
 drivers/gpu/drm/nouveau/nvif/vmm.c                |  3 +--
 drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c    |  5 +++--
 drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c    | 13 -------------
 5 files changed, 5 insertions(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 0a460eaaf76b..de9c55dea9bf 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -208,8 +208,7 @@ struct nvif_mmu_impl {
 	struct {
 		s32 oclass;
 		int (*new)(struct nvif_mmu_priv *, enum nvif_vmm_type type, u64 addr, u64 size,
-			   void *, u32, const struct nvif_vmm_impl **, struct nvif_vmm_priv **,
-			   u64 handle);
+			   void *, u32, const struct nvif_vmm_impl **, struct nvif_vmm_priv **);
 	} vmm;
 };
 
diff --git a/drivers/gpu/drm/nouveau/include/nvkm/subdev/mmu.h b/drivers/gpu/drm/nouveau/include/nvkm/subdev/mmu.h
index 6a1472b9499f..4e68fb5b2d2e 100644
--- a/drivers/gpu/drm/nouveau/include/nvkm/subdev/mmu.h
+++ b/drivers/gpu/drm/nouveau/include/nvkm/subdev/mmu.h
@@ -109,8 +109,6 @@ 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_vmm *nvkm_uvmm_search(struct nvkm_client *, u64 handle);
-
 struct nvkm_mmu {
 	const struct nvkm_mmu_func *func;
 	struct nvkm_subdev subdev;
diff --git a/drivers/gpu/drm/nouveau/nvif/vmm.c b/drivers/gpu/drm/nouveau/nvif/vmm.c
index fe342828ce8c..c12c79e7d9bd 100644
--- a/drivers/gpu/drm/nouveau/nvif/vmm.c
+++ b/drivers/gpu/drm/nouveau/nvif/vmm.c
@@ -113,8 +113,7 @@ nvif_vmm_ctor(struct nvif_mmu *mmu, const char *name,
 	const u32 oclass = mmu->impl->vmm.oclass;
 	int ret;
 
-	ret = mmu->impl->vmm.new(mmu->priv, type, addr, size, argv, argc, &vmm->impl, &vmm->priv,
-				 nvif_handle(&vmm->object));
+	ret = mmu->impl->vmm.new(mmu->priv, type, addr, size, argv, argc, &vmm->impl, &vmm->priv);
 	NVIF_ERRON(ret, &mmu->object, "[NEW vmm%08x]", oclass);
 	if (ret)
 		return ret;
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c
index b3883758828d..2734b75b34f3 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c
@@ -28,7 +28,7 @@
 static int
 nvkm_ummu_vmm_new(struct nvif_mmu_priv *ummu, enum nvif_vmm_type type, u64 addr, u64 size,
 		  void *argv, u32 argc, const struct nvif_vmm_impl **pimpl,
-		  struct nvif_vmm_priv **ppriv, u64 handle)
+		  struct nvif_vmm_priv **ppriv)
 {
 	struct nvkm_object *object;
 	int ret;
@@ -37,7 +37,8 @@ nvkm_ummu_vmm_new(struct nvif_mmu_priv *ummu, enum nvif_vmm_type type, u64 addr,
 	if (ret)
 		return ret;
 
-	return nvkm_object_link_rb(ummu->object.client, &ummu->object, handle, object);
+	nvkm_object_link(&ummu->object, object);
+	return 0;
 }
 
 static int
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c
index 5fac19738815..571f79b90fd3 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c
@@ -42,19 +42,6 @@ nvkm_uvmm_ref(struct nvif_vmm_priv *uvmm)
 	return NULL;
 }
 
-static const struct nvkm_object_func nvkm_uvmm;
-struct nvkm_vmm *
-nvkm_uvmm_search(struct nvkm_client *client, u64 handle)
-{
-	struct nvkm_object *object;
-
-	object = nvkm_object_search(client, handle, &nvkm_uvmm);
-	if (IS_ERR(object))
-		return (void *)object;
-
-	return nvkm_vmm_ref(container_of(object, struct nvif_vmm_priv, object)->vmm);
-}
-
 static void
 nvkm_uvmm_fault_cancel(struct nvif_vmm_priv *uvmm, u64 inst, u8 hub, u8 gpc, u8 client)
 {
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 139/156] drm/nouveau/nvif: remove ctxdma from object rb
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (137 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 138/156] drm/nouveau/nvif: remove vmm " Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 140/156] drm/nouveau/nvif: remove device " Ben Skeggs
                   ` (18 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- no more users

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/include/nvif/driverif.h   |  3 +--
 drivers/gpu/drm/nouveau/include/nvkm/engine/dma.h |  2 --
 drivers/gpu/drm/nouveau/nvif/device.c             |  2 +-
 drivers/gpu/drm/nouveau/nvkm/device/user.c        |  6 +++---
 drivers/gpu/drm/nouveau/nvkm/engine/dma/user.c    | 13 -------------
 5 files changed, 5 insertions(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index de9c55dea9bf..fac23a6ddc6d 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -533,8 +533,7 @@ struct nvif_device_impl {
 
 	struct {
 		int (*new)(struct nvif_device_priv *, s32 oclass, void *argv, u32 argc,
-			   const struct nvif_ctxdma_impl **, struct nvif_ctxdma_priv **,
-			   u64 handle);
+			   const struct nvif_ctxdma_impl **, struct nvif_ctxdma_priv **);
 	} ctxdma;
 
 	struct nvif_device_impl_fifo {
diff --git a/drivers/gpu/drm/nouveau/include/nvkm/engine/dma.h b/drivers/gpu/drm/nouveau/include/nvkm/engine/dma.h
index a003da39fd13..5a7ccdf8ae5c 100644
--- a/drivers/gpu/drm/nouveau/include/nvkm/engine/dma.h
+++ b/drivers/gpu/drm/nouveau/include/nvkm/engine/dma.h
@@ -21,8 +21,6 @@ struct nvkm_dma {
 	struct nvkm_engine engine;
 };
 
-struct nvkm_dmaobj *nvkm_dmaobj_search(struct nvkm_client *, u64 object);
-
 int nv04_dma_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_dma **);
 int nv50_dma_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_dma **);
 int gf100_dma_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_dma **);
diff --git a/drivers/gpu/drm/nouveau/nvif/device.c b/drivers/gpu/drm/nouveau/nvif/device.c
index 555c63e96660..40bb0dd518e9 100644
--- a/drivers/gpu/drm/nouveau/nvif/device.c
+++ b/drivers/gpu/drm/nouveau/nvif/device.c
@@ -33,7 +33,7 @@ nvif_device_ctxdma_ctor(struct nvif_device *device, const char *name, s32 oclass
 	int ret;
 
 	ret = device->impl->ctxdma.new(device->priv, oclass, argv, argc,
-				       &ctxdma->impl, &ctxdma->priv, nvif_handle(&ctxdma->object));
+				       &ctxdma->impl, &ctxdma->priv);
 	NVIF_ERRON(ret, &device->object, "[NEW ctxdma%04x]", oclass);
 	if (ret)
 		return ret;
diff --git a/drivers/gpu/drm/nouveau/nvkm/device/user.c b/drivers/gpu/drm/nouveau/nvkm/device/user.c
index c1ccb75db3c1..efa675c8098f 100644
--- a/drivers/gpu/drm/nouveau/nvkm/device/user.c
+++ b/drivers/gpu/drm/nouveau/nvkm/device/user.c
@@ -152,8 +152,7 @@ nvkm_udevice_ctxdma_impl = {
 
 static int
 nvkm_udevice_ctxdma_new(struct nvif_device_priv *udev, s32 oclass, void *argv, u32 argc,
-			const struct nvif_ctxdma_impl **pimpl, struct nvif_ctxdma_priv **ppriv,
-			u64 handle)
+			const struct nvif_ctxdma_impl **pimpl, struct nvif_ctxdma_priv **ppriv)
 {
 	struct nvkm_dma *dma = udev->device->dma;
 	struct nvkm_dmaobj *dmaobj;
@@ -167,7 +166,8 @@ nvkm_udevice_ctxdma_new(struct nvif_device_priv *udev, s32 oclass, void *argv, u
 	*pimpl = &nvkm_udevice_ctxdma_impl;
 	*ppriv = (void *)dmaobj;
 
-	return nvkm_object_link_rb(udev->object.client, &udev->object, handle, &dmaobj->object);
+	nvkm_object_link(&udev->object, &dmaobj->object);
+	return 0;
 }
 
 static int
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/dma/user.c b/drivers/gpu/drm/nouveau/nvkm/engine/dma/user.c
index 463600e4f368..96634f503310 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/dma/user.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/dma/user.c
@@ -30,19 +30,6 @@
 #include <nvif/cl0002.h>
 #include <nvif/unpack.h>
 
-static const struct nvkm_object_func nvkm_dmaobj_func;
-struct nvkm_dmaobj *
-nvkm_dmaobj_search(struct nvkm_client *client, u64 handle)
-{
-	struct nvkm_object *object;
-
-	object = nvkm_object_search(client, handle, &nvkm_dmaobj_func);
-	if (IS_ERR(object))
-		return (void *)object;
-
-	return nvkm_dmaobj(object);
-}
-
 static int
 nvkm_dmaobj_bind(struct nvkm_object *base, struct nvkm_gpuobj *gpuobj,
 		 int align, struct nvkm_gpuobj **pgpuobj)
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 140/156] drm/nouveau/nvif: remove device from object rb
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (138 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 139/156] drm/nouveau/nvif: remove ctxdma " Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 141/156] drm/nouveau/nvif: rework chan "map" api Ben Skeggs
                   ` (17 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- no more users

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/include/nvif/driverif.h | 3 +--
 drivers/gpu/drm/nouveau/nvif/device.c           | 3 +--
 drivers/gpu/drm/nouveau/nvkm/core/client.c      | 6 +++---
 3 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index fac23a6ddc6d..7dd2b187e6d6 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -609,8 +609,7 @@ struct nvif_client_impl {
 
 	struct {
 		int (*new)(struct nvif_client_priv *,
-			   const struct nvif_device_impl **, struct nvif_device_priv **,
-			   u64 handle);
+			   const struct nvif_device_impl **, struct nvif_device_priv **);
 	} device;
 };
 #endif
diff --git a/drivers/gpu/drm/nouveau/nvif/device.c b/drivers/gpu/drm/nouveau/nvif/device.c
index 40bb0dd518e9..480034b5563b 100644
--- a/drivers/gpu/drm/nouveau/nvif/device.c
+++ b/drivers/gpu/drm/nouveau/nvif/device.c
@@ -78,8 +78,7 @@ nvif_device_ctor(struct nvif_client *client, const char *name, struct nvif_devic
 
 	device->user.func = NULL;
 
-	ret = client->impl->device.new(client->priv, &device->impl, &device->priv,
-				       nvif_handle(&device->object));
+	ret = client->impl->device.new(client->priv, &device->impl, &device->priv);
 	NVIF_ERRON(ret, &client->object, "[NEW device]");
 	if (ret)
 		return ret;
diff --git a/drivers/gpu/drm/nouveau/nvkm/core/client.c b/drivers/gpu/drm/nouveau/nvkm/core/client.c
index a77014b342c0..bcd375a8bc2a 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/client.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/client.c
@@ -33,8 +33,7 @@
 
 static int
 nvkm_client_new_device(struct nvif_client_priv *client,
-		       const struct nvif_device_impl **pimpl, struct nvif_device_priv **ppriv,
-		       u64 handle)
+		       const struct nvif_device_impl **pimpl, struct nvif_device_priv **ppriv)
 {
 	struct nvkm_object *object;
 	int ret;
@@ -43,7 +42,8 @@ nvkm_client_new_device(struct nvif_client_priv *client,
 	if (ret)
 		return ret;
 
-	return nvkm_object_link_rb(client, &client->object, handle, object);
+	nvkm_object_link_(client, &client->object, object);
+	return 0;
 }
 
 static int
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 141/156] drm/nouveau/nvif: rework chan "map" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (139 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 140/156] drm/nouveau/nvif: remove device " Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 142/156] drm/nouveau/nvif: rework chan "sclass" api Ben Skeggs
                   ` (16 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interface

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  2 +
 drivers/gpu/drm/nouveau/include/nvif/ioctl.h  | 17 ----
 drivers/gpu/drm/nouveau/include/nvif/object.h |  5 --
 .../drm/nouveau/include/nvkm/core/object.h    | 11 ---
 drivers/gpu/drm/nouveau/nouveau_chan.c        |  7 +-
 drivers/gpu/drm/nouveau/nvif/object.c         | 77 -------------------
 drivers/gpu/drm/nouveau/nvkm/core/ioctl.c     | 62 ---------------
 drivers/gpu/drm/nouveau/nvkm/core/object.c    | 18 -----
 drivers/gpu/drm/nouveau/nvkm/core/oproxy.c    | 21 -----
 .../gpu/drm/nouveau/nvkm/engine/fifo/uchan.c  | 26 ++-----
 10 files changed, 12 insertions(+), 234 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 7dd2b187e6d6..75861e0327ac 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -446,6 +446,8 @@ struct nvif_chan_impl {
 		} aper;
 		u64 addr;
 	} inst;
+
+	struct nvif_mapinfo map;
 };
 
 struct nvif_cgrp_impl {
diff --git a/drivers/gpu/drm/nouveau/include/nvif/ioctl.h b/drivers/gpu/drm/nouveau/include/nvif/ioctl.h
index e825c8a1d9ca..0eb479695c0a 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/ioctl.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/ioctl.h
@@ -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_MAP                                                  0x07
-#define NVIF_IOCTL_V0_UNMAP                                                0x08
 	__u8  type;
 	__u8  pad02[4];
 #define NVIF_IOCTL_V0_OWNER_NVIF                                           0x00
@@ -57,19 +55,4 @@ struct nvif_ioctl_mthd_v0 {
 	__u8  pad02[6];
 	__u8  data[];		/* method data (class.h) */
 };
-
-struct nvif_ioctl_map_v0 {
-	/* nvif_ioctl ... */
-	__u8  version;
-#define NVIF_IOCTL_MAP_V0_IO                                               0x00
-#define NVIF_IOCTL_MAP_V0_VA                                               0x01
-	__u8  type;
-	__u8  pad02[6];
-	__u64 handle;
-	__u64 length;
-	__u8  data[];
-};
-
-struct nvif_ioctl_unmap {
-};
 #endif
diff --git a/drivers/gpu/drm/nouveau/include/nvif/object.h b/drivers/gpu/drm/nouveau/include/nvif/object.h
index 10a8f3e1ea81..d52d59d9805d 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/object.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/object.h
@@ -51,11 +51,6 @@ 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 *);
-int  nvif_object_map(struct nvif_object *, void *, u32);
-void nvif_object_unmap(struct nvif_object *);
 
 #define nvif_handle(a) (unsigned long)(void *)(a)
 #define nvif_object(a) (a)->object
diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/object.h b/drivers/gpu/drm/nouveau/include/nvkm/core/object.h
index 9ab163d9a4d0..69972b0836e4 100644
--- a/drivers/gpu/drm/nouveau/include/nvkm/core/object.h
+++ b/drivers/gpu/drm/nouveau/include/nvkm/core/object.h
@@ -19,20 +19,12 @@ struct nvkm_object {
 	struct rb_node node;
 };
 
-enum nvkm_object_map {
-	NVKM_OBJECT_MAP_IO,
-	NVKM_OBJECT_MAP_VA
-};
-
 struct nvkm_object_func {
 	void *(*dtor)(struct nvkm_object *);
 	int (*init)(struct nvkm_object *);
 	int (*fini)(struct nvkm_object *, bool suspend);
 	int (*mthd)(struct nvkm_object *, u32 mthd, void *data, u32 size);
 	int (*ntfy)(struct nvkm_object *, u32 mthd, struct nvkm_event **);
-	int (*map)(struct nvkm_object *, void *argv, u32 argc,
-		   enum nvkm_object_map *, u64 *addr, u64 *size);
-	int (*unmap)(struct nvkm_object *);
 	int (*bind)(struct nvkm_object *, struct nvkm_gpuobj *, int align,
 		    struct nvkm_gpuobj **);
 	int (*sclass)(struct nvkm_object *, int index, struct nvkm_oclass *);
@@ -52,9 +44,6 @@ int nvkm_object_init(struct nvkm_object *);
 int nvkm_object_fini(struct nvkm_object *, bool suspend);
 int nvkm_object_mthd(struct nvkm_object *, u32 mthd, void *data, u32 size);
 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_bind(struct nvkm_object *, struct nvkm_gpuobj *, int align,
 		     struct nvkm_gpuobj **);
 
diff --git a/drivers/gpu/drm/nouveau/nouveau_chan.c b/drivers/gpu/drm/nouveau/nouveau_chan.c
index 21927b817fa8..60be87d5fd59 100644
--- a/drivers/gpu/drm/nouveau/nouveau_chan.c
+++ b/drivers/gpu/drm/nouveau/nouveau_chan.c
@@ -101,8 +101,6 @@ nouveau_channel_del(struct nouveau_channel **pchan)
 		nvif_object_dtor(&chan->gart);
 		nvif_object_dtor(&chan->vram);
 		nvif_event_dtor(&chan->kill);
-		if (!chan->userd.map.impl)
-			chan->userd.map.ptr = NULL;
 		nvif_object_unmap_cpu(&chan->userd.map);
 		nvif_chan_dtor(&chan->chan);
 		nvif_mem_dtor(&chan->userd.mem);
@@ -359,11 +357,10 @@ nouveau_channel_init(struct nouveau_channel *chan, u32 vram, u32 gart)
 	int ret, i;
 
 	if (!chan->userd.mem.impl) {
-		ret = nvif_object_map(&chan->chan.object, NULL, 0);
+		ret = nvif_object_map_cpu(&chan->chan.object, &chan->chan.impl->map,
+					  &chan->userd.map);
 		if (ret)
 			return ret;
-
-		chan->userd.map.ptr = chan->chan.object.map.ptr;
 	} else {
 		ret = nvif_mem_map(&chan->userd.mem, NULL, 0, &chan->userd.map);
 		if (ret)
diff --git a/drivers/gpu/drm/nouveau/nvif/object.c b/drivers/gpu/drm/nouveau/nvif/object.c
index d0f4ddca085e..371a3605f537 100644
--- a/drivers/gpu/drm/nouveau/nvif/object.c
+++ b/drivers/gpu/drm/nouveau/nvif/object.c
@@ -126,58 +126,6 @@ nvif_object_mthd(struct nvif_object *object, u32 mthd, void *data, u32 size)
 	return ret;
 }
 
-void
-nvif_object_unmap_handle(struct nvif_object *object)
-{
-	struct {
-		struct nvif_ioctl_v0 ioctl;
-		struct nvif_ioctl_unmap unmap;
-	} args = {
-		.ioctl.type = NVIF_IOCTL_V0_UNMAP,
-	};
-
-	nvif_object_ioctl(object, &args, sizeof(args), NULL);
-}
-
-int
-nvif_object_map_handle(struct nvif_object *object, void *argv, u32 argc,
-		       u64 *handle, u64 *length)
-{
-	struct {
-		struct nvif_ioctl_v0 ioctl;
-		struct nvif_ioctl_map_v0 map;
-	} *args;
-	u32 argn = sizeof(*args) + argc;
-	int ret, maptype;
-
-	if (!(args = kzalloc(argn, GFP_KERNEL)))
-		return -ENOMEM;
-	args->ioctl.type = NVIF_IOCTL_V0_MAP;
-	memcpy(args->map.data, argv, argc);
-
-	ret = nvif_object_ioctl(object, args, argn, NULL);
-	*handle = args->map.handle;
-	*length = args->map.length;
-	maptype = args->map.type;
-	kfree(args);
-	return ret ? ret : (maptype == NVIF_IOCTL_MAP_V0_IO);
-}
-
-void
-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.priv, object->map.ptr,
-								   object->map.size);
-			object->map.size = 0;
-		}
-		object->map.ptr = NULL;
-		nvif_object_unmap_handle(object);
-	}
-}
-
 int
 nvif_object_unmap_cpu(struct nvif_map *map)
 {
@@ -224,30 +172,6 @@ nvif_object_map_cpu(struct nvif_object *object,
 	return 0;
 }
 
-int
-nvif_object_map(struct nvif_object *object, void *argv, u32 argc)
-{
-	struct nvif_client *client = object->client;
-	u64 handle, length;
-	int ret = nvif_object_map_handle(object, argv, argc, &handle, &length);
-	if (ret >= 0) {
-		if (ret) {
-			object->map.ptr = client->driver->map(client->object.priv,
-							      handle,
-							      length);
-			if (ret = -ENOMEM, object->map.ptr) {
-				object->map.size = length;
-				return 0;
-			}
-		} else {
-			object->map.ptr = (void *)(unsigned long)handle;
-			return 0;
-		}
-		nvif_object_unmap_handle(object);
-	}
-	return ret;
-}
-
 void
 nvif_object_dtor(struct nvif_object *object)
 {
@@ -261,7 +185,6 @@ nvif_object_dtor(struct nvif_object *object)
 	if (!nvif_object_constructed(object))
 		return;
 
-	nvif_object_unmap(object);
 	nvif_object_ioctl(object, &args, sizeof(args), NULL);
 	object->client = NULL;
 }
diff --git a/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c b/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c
index 45051a1249da..66f843cac37d 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c
@@ -186,64 +186,6 @@ nvkm_ioctl_mthd(struct nvkm_client *client,
 	return ret;
 }
 
-
-static int
-nvkm_ioctl_rd(struct nvkm_client *client,
-	      struct nvkm_object *object, void *data, u32 size)
-{
-	return -ENOSYS;
-}
-
-static int
-nvkm_ioctl_wr(struct nvkm_client *client,
-	      struct nvkm_object *object, void *data, u32 size)
-{
-	return -ENOSYS;
-}
-
-static int
-nvkm_ioctl_map(struct nvkm_client *client,
-	       struct nvkm_object *object, void *data, u32 size)
-{
-	union {
-		struct nvif_ioctl_map_v0 v0;
-	} *args = data;
-	enum nvkm_object_map type;
-	int ret = -ENOSYS;
-
-	nvif_ioctl(object, "map size %d\n", size);
-	if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) {
-		nvif_ioctl(object, "map vers %d\n", args->v0.version);
-		ret = nvkm_object_map(object, data, size, &type,
-				      &args->v0.handle,
-				      &args->v0.length);
-		if (type == NVKM_OBJECT_MAP_IO)
-			args->v0.type = NVIF_IOCTL_MAP_V0_IO;
-		else
-			args->v0.type = NVIF_IOCTL_MAP_V0_VA;
-	}
-
-	return ret;
-}
-
-static int
-nvkm_ioctl_unmap(struct nvkm_client *client,
-		 struct nvkm_object *object, void *data, u32 size)
-{
-	union {
-		struct nvif_ioctl_unmap none;
-	} *args = data;
-	int ret = -ENOSYS;
-
-	nvif_ioctl(object, "unmap size %d\n", size);
-	if (!(ret = nvif_unvers(ret, &data, &size, args->none))) {
-		nvif_ioctl(object, "unmap\n");
-		ret = nvkm_object_unmap(object);
-	}
-
-	return ret;
-}
-
 static struct {
 	int version;
 	int (*func)(struct nvkm_client *, struct nvkm_object *, void *, u32);
@@ -254,10 +196,6 @@ nvkm_ioctl_v0[] = {
 	{ 0x00, nvkm_ioctl_new },
 	{ 0x00, nvkm_ioctl_del },
 	{ 0x00, nvkm_ioctl_mthd },
-	{ 0x00, nvkm_ioctl_rd },
-	{ 0x00, nvkm_ioctl_wr },
-	{ 0x00, nvkm_ioctl_map },
-	{ 0x00, nvkm_ioctl_unmap },
 };
 
 static int
diff --git a/drivers/gpu/drm/nouveau/nvkm/core/object.c b/drivers/gpu/drm/nouveau/nvkm/core/object.c
index d34a8ee1a0ae..8ad1aff9b8c7 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/object.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/object.c
@@ -115,23 +115,6 @@ nvkm_object_ntfy(struct nvkm_object *object, u32 mthd,
 	return -ENODEV;
 }
 
-int
-nvkm_object_map(struct nvkm_object *object, void *argv, u32 argc,
-		enum nvkm_object_map *type, u64 *addr, u64 *size)
-{
-	if (likely(object->func->map))
-		return object->func->map(object, argv, argc, type, addr, size);
-	return -ENODEV;
-}
-
-int
-nvkm_object_unmap(struct nvkm_object *object)
-{
-	if (likely(object->func->unmap))
-		return object->func->unmap(object);
-	return -ENODEV;
-}
-
 int
 nvkm_object_bind(struct nvkm_object *object, struct nvkm_gpuobj *gpuobj,
 		 int align, struct nvkm_gpuobj **pgpuobj)
@@ -234,7 +217,6 @@ nvkm_object_dtor(struct nvkm_object *object)
 	}
 
 	nvif_debug(object, "destroy running...\n");
-	nvkm_object_unmap(object);
 	if (object->func->dtor)
 		data = object->func->dtor(object);
 	nvkm_engine_unref(&object->engine);
diff --git a/drivers/gpu/drm/nouveau/nvkm/core/oproxy.c b/drivers/gpu/drm/nouveau/nvkm/core/oproxy.c
index 5db80d1780f0..690131104d7b 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/oproxy.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/oproxy.c
@@ -36,25 +36,6 @@ nvkm_oproxy_ntfy(struct nvkm_object *object, u32 mthd,
 	return nvkm_object_ntfy(nvkm_oproxy(object)->object, mthd, pevent);
 }
 
-static int
-nvkm_oproxy_map(struct nvkm_object *object, void *argv, u32 argc,
-		enum nvkm_object_map *type, u64 *addr, u64 *size)
-{
-	struct nvkm_oproxy *oproxy = nvkm_oproxy(object);
-	return nvkm_object_map(oproxy->object, argv, argc, type, addr, size);
-}
-
-static int
-nvkm_oproxy_unmap(struct nvkm_object *object)
-{
-	struct nvkm_oproxy *oproxy = nvkm_oproxy(object);
-
-	if (unlikely(!oproxy->object))
-		return 0;
-
-	return nvkm_object_unmap(oproxy->object);
-}
-
 static int
 nvkm_oproxy_bind(struct nvkm_object *object, struct nvkm_gpuobj *parent,
 		 int align, struct nvkm_gpuobj **pgpuobj)
@@ -159,8 +140,6 @@ nvkm_oproxy_func = {
 	.fini = nvkm_oproxy_fini,
 	.mthd = nvkm_oproxy_mthd,
 	.ntfy = nvkm_oproxy_ntfy,
-	.map = nvkm_oproxy_map,
-	.unmap = nvkm_oproxy_unmap,
 	.bind = nvkm_oproxy_bind,
 	.sclass = nvkm_oproxy_sclass,
 	.uevent = nvkm_oproxy_uevent,
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/uchan.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/uchan.c
index f21cd52d5ae3..e9279902c472 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/uchan.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/uchan.c
@@ -254,23 +254,6 @@ nvkm_uchan_sclass(struct nvkm_object *object, int index, struct nvkm_oclass *ocl
 	return -EINVAL;
 }
 
-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 = 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)
-		return -ENOSYS;
-
-	*type = NVKM_OBJECT_MAP_IO;
-	*addr = device->func->resource_addr(device, chan->func->userd->bar) +
-		chan->func->userd->base + chan->userd.base;
-	*size = chan->func->userd->size;
-	return 0;
-}
-
 static void
 nvkm_uchan_del(struct nvif_chan_priv *uchan)
 {
@@ -329,7 +312,6 @@ nvkm_uchan = {
 	.dtor = nvkm_uchan_dtor,
 	.init = nvkm_uchan_init,
 	.fini = nvkm_uchan_fini,
-	.map = nvkm_uchan_map,
 	.sclass = nvkm_uchan_sclass,
 	.uevent = nvkm_uchan_uevent,
 };
@@ -414,6 +396,14 @@ nvkm_uchan_new(struct nvkm_device *device, struct nvkm_cgrp *cgrp, u8 runi, u8 r
 
 	uchan->impl.inst.addr = nvkm_memory_addr(chan->inst->memory);
 
+	if (chan->func->userd->bar >= 0) {
+		uchan->impl.map.type = NVIF_MAP_IO;
+		uchan->impl.map.handle =
+			device->func->resource_addr(device, chan->func->userd->bar) +
+			chan->func->userd->base + chan->userd.base;
+		uchan->impl.map.length = chan->func->userd->size;
+	}
+
 	*pimpl = &uchan->impl;
 	*ppriv = uchan;
 	*pobject = &uchan->object;
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 142/156] drm/nouveau/nvif: rework chan "sclass" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (140 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 141/156] drm/nouveau/nvif: rework chan "map" api Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 143/156] drm/nouveau/nvif: rework chan "new event" apis Ben Skeggs
                   ` (15 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interfaces

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/include/nvif/fifo.h   |  2 +
 drivers/gpu/drm/nouveau/include/nvif/object.h |  8 --
 drivers/gpu/drm/nouveau/nouveau_abi16.c       | 91 +++++--------------
 drivers/gpu/drm/nouveau/nvif/fifo.c           | 13 +++
 drivers/gpu/drm/nouveau/nvif/object.c         | 51 -----------
 drivers/gpu/drm/nouveau/nvkm/core/ioctl.c     | 27 +-----
 6 files changed, 40 insertions(+), 152 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/fifo.h b/drivers/gpu/drm/nouveau/include/nvif/fifo.h
index 4e9663848291..1a47cf96509f 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/fifo.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/fifo.h
@@ -16,4 +16,6 @@ nvif_fifo_runlist_ce(struct nvif_device *device)
 		runmce = runmgr;
 	return runmce;
 }
+
+s32 nvif_fifo_engine_oclass(struct nvif_device *, enum nvif_engine_type);
 #endif
diff --git a/drivers/gpu/drm/nouveau/include/nvif/object.h b/drivers/gpu/drm/nouveau/include/nvif/object.h
index d52d59d9805d..56308333ef86 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/object.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/object.h
@@ -3,12 +3,6 @@
 #define __NVIF_OBJECT_H__
 #include <nvif/os.h>
 
-struct nvif_sclass {
-	s32 oclass;
-	int minver;
-	int maxver;
-};
-
 struct nvif_object {
 	struct nvif_parent *parent;
 	struct nvif_client *client;
@@ -46,8 +40,6 @@ void nvif_object_ctor_1(struct nvif_object *parent, const char *name, u32 handle
 
 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 **);
 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 *);
diff --git a/drivers/gpu/drm/nouveau/nouveau_abi16.c b/drivers/gpu/drm/nouveau/nouveau_abi16.c
index d7db5c0eeaea..36cf7b035973 100644
--- a/drivers/gpu/drm/nouveau/nouveau_abi16.c
+++ b/drivers/gpu/drm/nouveau/nouveau_abi16.c
@@ -131,25 +131,7 @@ nouveau_abi16_obj_new(struct nouveau_abi16 *abi16, enum nouveau_abi16_obj_type t
 s32
 nouveau_abi16_swclass(struct nouveau_drm *drm)
 {
-	switch (drm->client.device.info.family) {
-	case NV_DEVICE_INFO_V0_TNT:
-		return NVIF_CLASS_SW_NV04;
-	case NV_DEVICE_INFO_V0_CELSIUS:
-	case NV_DEVICE_INFO_V0_KELVIN:
-	case NV_DEVICE_INFO_V0_RANKINE:
-	case NV_DEVICE_INFO_V0_CURIE:
-		return NVIF_CLASS_SW_NV10;
-	case NV_DEVICE_INFO_V0_TESLA:
-		return NVIF_CLASS_SW_NV50;
-	case NV_DEVICE_INFO_V0_FERMI:
-	case NV_DEVICE_INFO_V0_KEPLER:
-	case NV_DEVICE_INFO_V0_MAXWELL:
-	case NV_DEVICE_INFO_V0_PASCAL:
-	case NV_DEVICE_INFO_V0_VOLTA:
-		return NVIF_CLASS_SW_GF100;
-	}
-
-	return 0x0000;
+	return nvif_fifo_engine_oclass(&drm->device, NVIF_ENGINE_SW);
 }
 
 static void
@@ -510,9 +492,8 @@ 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_sclass *sclass;
 	s32 oclass = 0;
-	int ret, i;
+	int ret;
 
 	if (unlikely(!abi16))
 		return -ENOMEM;
@@ -524,56 +505,25 @@ nouveau_abi16_ioctl_grobj_alloc(ABI16_IOCTL_ARGS)
 	if (!chan)
 		return nouveau_abi16_put(abi16, -ENOENT);
 
-	ret = nvif_object_sclass_get(&chan->chan->chan.object, &sclass);
-	if (ret < 0)
-		return nouveau_abi16_put(abi16, ret);
-
 	if ((init->class & 0x00ff) == 0x006e) {
 		/* nvsw: compatibility with older 0x*6e class identifier */
-		for (i = 0; !oclass && i < ret; i++) {
-			switch (sclass[i].oclass) {
-			case NVIF_CLASS_SW_NV04:
-			case NVIF_CLASS_SW_NV10:
-			case NVIF_CLASS_SW_NV50:
-			case NVIF_CLASS_SW_GF100:
-				oclass = sclass[i].oclass;
-				break;
-			default:
-				break;
-			}
-		}
+		oclass = nvif_fifo_engine_oclass(&abi16->cli->drm->device, NVIF_ENGINE_SW);
 	} else
 	if ((init->class & 0x00ff) == 0x00b1) {
 		/* msvld: compatibility with incorrect version exposure */
-		for (i = 0; i < ret; i++) {
-			if ((sclass[i].oclass & 0x00ff) == 0x00b1) {
-				oclass = sclass[i].oclass;
-				break;
-			}
-		}
+		oclass = nvif_fifo_engine_oclass(&abi16->cli->drm->device, NVIF_ENGINE_MSVLD);
 	} else
 	if ((init->class & 0x00ff) == 0x00b2) { /* mspdec */
 		/* mspdec: compatibility with incorrect version exposure */
-		for (i = 0; i < ret; i++) {
-			if ((sclass[i].oclass & 0x00ff) == 0x00b2) {
-				oclass = sclass[i].oclass;
-				break;
-			}
-		}
+		oclass = nvif_fifo_engine_oclass(&abi16->cli->drm->device, NVIF_ENGINE_MSPDEC);
 	} else
 	if ((init->class & 0x00ff) == 0x00b3) { /* msppp */
 		/* msppp: compatibility with incorrect version exposure */
-		for (i = 0; i < ret; i++) {
-			if ((sclass[i].oclass & 0x00ff) == 0x00b3) {
-				oclass = sclass[i].oclass;
-				break;
-			}
-		}
+		oclass = nvif_fifo_engine_oclass(&abi16->cli->drm->device, NVIF_ENGINE_MSPPP);
 	} else {
 		oclass = init->class;
 	}
 
-	nvif_object_sclass_put(&sclass);
 	if (!oclass)
 		return nouveau_abi16_put(abi16, -EINVAL);
 
@@ -779,10 +729,11 @@ nouveau_abi16_ioctl_new(struct nouveau_abi16 *abi16, struct nvif_ioctl_v0 *ioctl
 static int
 nouveau_abi16_ioctl_sclass(struct nouveau_abi16 *abi16, struct nvif_ioctl_v0 *ioctl, u32 argc)
 {
+	const struct nvif_device_impl_fifo *fifo;
+	const struct nvif_device_impl_runl *runl;
 	struct nvif_ioctl_sclass_v0 *args;
 	struct nouveau_abi16_chan *chan;
-	struct nvif_sclass *sclass;
-	int ret;
+	int cnt = 0;
 
 	if (!ioctl->route || argc < sizeof(*args))
 		return -EINVAL;
@@ -796,18 +747,24 @@ nouveau_abi16_ioctl_sclass(struct nouveau_abi16 *abi16, struct nvif_ioctl_v0 *io
 	if (!chan)
 		return -EINVAL;
 
-	ret = nvif_object_sclass_get(&chan->chan->chan.object, &sclass);
-	if (ret < 0)
-		return ret;
+	fifo = &chan->chan->cli->drm->device.impl->fifo;
+	runl = &fifo->runl[chan->chan->chan.runl];
+
+	for (int engi = 0; engi < runl->engn_nr; engi++) {
+		const struct nvif_device_impl_engine *engine =
+			&fifo->engine[runl->engn[engi].engine];
 
-	for (int i = 0; i < min_t(u8, args->count, ret); i++) {
-		args->oclass[i].oclass = sclass[i].oclass;
-		args->oclass[i].minver = sclass[i].minver;
-		args->oclass[i].maxver = sclass[i].maxver;
+		for (int clsi = 0; clsi < engine->oclass_nr; clsi++) {
+			if (cnt < args->count) {
+				args->oclass[cnt].oclass = engine->oclass[clsi];
+				args->oclass[cnt].minver = -1;
+				args->oclass[cnt].maxver = -1;
+			}
+			cnt++;
+		}
 	}
-	args->count = ret;
 
-	nvif_object_sclass_put(&sclass);
+	args->count = cnt;
 	return 0;
 }
 
diff --git a/drivers/gpu/drm/nouveau/nvif/fifo.c b/drivers/gpu/drm/nouveau/nvif/fifo.c
index 34e6fec0f0a3..6bf2c663583f 100644
--- a/drivers/gpu/drm/nouveau/nvif/fifo.c
+++ b/drivers/gpu/drm/nouveau/nvif/fifo.c
@@ -21,6 +21,19 @@
  */
 #include <nvif/fifo.h>
 
+s32
+nvif_fifo_engine_oclass(struct nvif_device *device, enum nvif_engine_type type)
+{
+	const struct nvif_device_impl_fifo *impl = &device->impl->fifo;
+
+	for (int i = 0; i < impl->engine_nr; i++) {
+		if (impl->engine[i].type == type)
+			return impl->engine[i].oclass[0];
+	}
+
+	return 0;
+}
+
 u64
 nvif_fifo_runlist(struct nvif_device *device, enum nvif_engine_type type)
 {
diff --git a/drivers/gpu/drm/nouveau/nvif/object.c b/drivers/gpu/drm/nouveau/nvif/object.c
index 371a3605f537..9887241c5200 100644
--- a/drivers/gpu/drm/nouveau/nvif/object.c
+++ b/drivers/gpu/drm/nouveau/nvif/object.c
@@ -46,57 +46,6 @@ nvif_object_ioctl(struct nvif_object *object, void *data, u32 size, void **hack)
 	return client->driver->ioctl(client->object.priv, data, size, hack);
 }
 
-void
-nvif_object_sclass_put(struct nvif_sclass **psclass)
-{
-	kfree(*psclass);
-	*psclass = NULL;
-}
-
-int
-nvif_object_sclass_get(struct nvif_object *object, struct nvif_sclass **psclass)
-{
-	struct {
-		struct nvif_ioctl_v0 ioctl;
-		struct nvif_ioctl_sclass_v0 sclass;
-	} *args = NULL;
-	int ret, cnt = 0, i;
-	u32 size;
-
-	while (1) {
-		size = sizeof(*args) + cnt * sizeof(args->sclass.oclass[0]);
-		if (!(args = kmalloc(size, GFP_KERNEL)))
-			return -ENOMEM;
-		args->ioctl.version = 0;
-		args->ioctl.type = NVIF_IOCTL_V0_SCLASS;
-		args->sclass.version = 0;
-		args->sclass.count = cnt;
-
-		ret = nvif_object_ioctl(object, args, size, NULL);
-		if (ret == 0 && args->sclass.count <= cnt)
-			break;
-		cnt = args->sclass.count;
-		kfree(args);
-		if (ret != 0)
-			return ret;
-	}
-
-	*psclass = kcalloc(args->sclass.count, sizeof(**psclass), GFP_KERNEL);
-	if (*psclass) {
-		for (i = 0; i < args->sclass.count; i++) {
-			(*psclass)[i].oclass = args->sclass.oclass[i].oclass;
-			(*psclass)[i].minver = args->sclass.oclass[i].minver;
-			(*psclass)[i].maxver = args->sclass.oclass[i].maxver;
-		}
-		ret = args->sclass.count;
-	} else {
-		ret = -ENOMEM;
-	}
-
-	kfree(args);
-	return ret;
-}
-
 int
 nvif_object_mthd(struct nvif_object *object, u32 mthd, void *data, u32 size)
 {
diff --git a/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c b/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c
index 66f843cac37d..b34ed158aa63 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c
@@ -60,32 +60,7 @@ static int
 nvkm_ioctl_sclass(struct nvkm_client *client,
 		  struct nvkm_object *object, void *data, u32 size)
 {
-	union {
-		struct nvif_ioctl_sclass_v0 v0;
-	} *args = data;
-	struct nvkm_oclass oclass = { .client = client };
-	int ret = -ENOSYS, i = 0;
-
-	nvif_ioctl(object, "sclass size %d\n", size);
-	if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) {
-		nvif_ioctl(object, "sclass vers %d count %d\n",
-			   args->v0.version, args->v0.count);
-		if (size != args->v0.count * sizeof(args->v0.oclass[0]))
-			return -EINVAL;
-
-		while (nvkm_ioctl_sclass_(object, i, &oclass) >= 0) {
-			if (i < args->v0.count) {
-				args->v0.oclass[i].oclass = oclass.base.oclass;
-				args->v0.oclass[i].minver = oclass.base.minver;
-				args->v0.oclass[i].maxver = oclass.base.maxver;
-			}
-			i++;
-		}
-
-		args->v0.count = i;
-	}
-
-	return ret;
+	return -ENODEV;
 }
 
 static int
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 143/156] drm/nouveau/nvif: rework chan "new event" apis
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (141 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 142/156] drm/nouveau/nvif: rework chan "sclass" api Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 144/156] drm/nouveau/nvif: rework chan "new ctxdma" api Ben Skeggs
                   ` (14 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interfaces

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/include/nvif/chan.h   |  6 +++
 drivers/gpu/drm/nouveau/include/nvif/class.h  |  1 -
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  7 +++
 drivers/gpu/drm/nouveau/include/nvif/if0020.h | 13 -----
 drivers/gpu/drm/nouveau/nouveau_chan.c        | 15 ++----
 drivers/gpu/drm/nouveau/nouveau_fence.c       | 17 ++----
 drivers/gpu/drm/nouveau/nvif/chan.c           | 17 ++++++
 .../gpu/drm/nouveau/nvkm/engine/fifo/chan.c   |  2 -
 .../gpu/drm/nouveau/nvkm/engine/fifo/uchan.c  | 53 +++++++++----------
 9 files changed, 60 insertions(+), 71 deletions(-)
 delete mode 100644 drivers/gpu/drm/nouveau/include/nvif/if0020.h

diff --git a/drivers/gpu/drm/nouveau/include/nvif/chan.h b/drivers/gpu/drm/nouveau/include/nvif/chan.h
index 80f7ea8c7268..45c82cef6b1d 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/chan.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/chan.h
@@ -3,6 +3,7 @@
 #define __NVIF_CHAN_H__
 #include <nvif/object.h>
 #include <nvif/driverif.h>
+#include <nvif/event.h>
 #include <nvif/push.h>
 struct nvif_cgrp;
 struct nvif_device;
@@ -22,4 +23,9 @@ struct nvif_chan {
 void nvif_chan_ctor(struct nvif_device *, struct nvif_cgrp *, const char *name, u8 runl, u8 runq,
 		    struct nvif_chan *);
 void nvif_chan_dtor(struct nvif_chan *);
+
+int nvif_chan_event_ctor(struct nvif_chan *, const char *name,
+			 int (*ctor)(struct nvif_chan_priv *, u64 token,
+				     const struct nvif_event_impl **, struct nvif_event_priv **),
+			 nvif_event_func, struct nvif_event *);
 #endif
diff --git a/drivers/gpu/drm/nouveau/include/nvif/class.h b/drivers/gpu/drm/nouveau/include/nvif/class.h
index 6174999eacd3..517bac332797 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/class.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/class.h
@@ -33,7 +33,6 @@
 #define NVIF_CLASS_HEAD                              /* if0013.h */  0x80000013
 #define NVIF_CLASS_DISP_CHAN                         /* if0014.h */  0x80000014
 
-#define NVIF_CLASS_CHAN                              /* if0020.h */  0x80000020
 #define NVIF_CLASS_CGRP                              /* if0021.h */  0x80000021
 
 /* the below match nvidia-assigned (either in hw, or sw) class numbers */
diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 75861e0327ac..6e109da67bbe 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -448,6 +448,13 @@ struct nvif_chan_impl {
 	} inst;
 
 	struct nvif_mapinfo map;
+
+	struct {
+		int (*killed)(struct nvif_chan_priv *, u64 token,
+			      const struct nvif_event_impl **, struct nvif_event_priv **);
+		int (*nonstall)(struct nvif_chan_priv *, u64 token,
+				const struct nvif_event_impl **, struct nvif_event_priv **);
+	} event;
 };
 
 struct nvif_cgrp_impl {
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0020.h b/drivers/gpu/drm/nouveau/include/nvif/if0020.h
deleted file mode 100644
index 1893b8aa0abb..000000000000
--- a/drivers/gpu/drm/nouveau/include/nvif/if0020.h
+++ /dev/null
@@ -1,13 +0,0 @@
-/* SPDX-License-Identifier: MIT */
-#ifndef __NVIF_IF0020_H__
-#define __NVIF_IF0020_H__
-
-union nvif_chan_event_args {
-	struct nvif_chan_event_v0 {
-		__u8 version;
-#define NVIF_CHAN_EVENT_V0_NON_STALL_INTR 0x00
-#define NVIF_CHAN_EVENT_V0_KILLED         0x01
-		__u8 type;
-	} v0;
-};
-#endif
diff --git a/drivers/gpu/drm/nouveau/nouveau_chan.c b/drivers/gpu/drm/nouveau/nouveau_chan.c
index 60be87d5fd59..7116d61535f8 100644
--- a/drivers/gpu/drm/nouveau/nouveau_chan.c
+++ b/drivers/gpu/drm/nouveau/nouveau_chan.c
@@ -25,7 +25,6 @@
 
 #include <nvif/class.h>
 #include <nvif/cl0002.h>
-#include <nvif/if0020.h>
 
 #include "nouveau_drv.h"
 #include "nouveau_dma.h"
@@ -368,17 +367,9 @@ nouveau_channel_init(struct nouveau_channel *chan, u32 vram, u32 gart)
 	}
 
 	if (chan->chan.object.oclass >= FERMI_CHANNEL_GPFIFO) {
-		struct {
-			struct nvif_event_v0 base;
-			struct nvif_chan_event_v0 host;
-		} args;
-
-		args.host.version = 0;
-		args.host.type = NVIF_CHAN_EVENT_V0_KILLED;
-
-		ret = nvif_event_ctor(&chan->chan.object, "abi16ChanKilled", chan->chid,
-				      nouveau_channel_killed, false,
-				      &args.base, sizeof(args), &chan->kill);
+		ret = nvif_chan_event_ctor(&chan->chan, "abi16ChanKilled",
+					   chan->chan.impl->event.killed,
+					   nouveau_channel_killed, &chan->kill);
 		if (ret == 0)
 			ret = nvif_event_allow(&chan->kill);
 		if (ret) {
diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.c b/drivers/gpu/drm/nouveau/nouveau_fence.c
index ff31784effeb..9443cbaa8cff 100644
--- a/drivers/gpu/drm/nouveau/nouveau_fence.c
+++ b/drivers/gpu/drm/nouveau/nouveau_fence.c
@@ -29,8 +29,6 @@
 #include <linux/sched/signal.h>
 #include <trace/events/dma_fence.h>
 
-#include <nvif/if0020.h>
-
 #include "nouveau_drv.h"
 #include "nouveau_dma.h"
 #include "nouveau_fence.h"
@@ -184,10 +182,6 @@ nouveau_fence_context_new(struct nouveau_channel *chan, struct nouveau_fence_cha
 	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;
-	} args;
 	int ret;
 
 	INIT_WORK(&fctx->uevent_work, nouveau_fence_uevent_work);
@@ -207,14 +201,9 @@ nouveau_fence_context_new(struct nouveau_channel *chan, struct nouveau_fence_cha
 	if (!priv->uevent)
 		return;
 
-	args.host.version = 0;
-	args.host.type = NVIF_CHAN_EVENT_V0_NON_STALL_INTR;
-
-	ret = nvif_event_ctor(&chan->chan.object, "fenceNonStallIntr",
-			      (chan->runlist << 16) | chan->chid,
-			      nouveau_fence_wait_uevent_handler, false,
-			      &args.base, sizeof(args), &fctx->event);
-
+	ret = nvif_chan_event_ctor(&chan->chan, "fenceNonStallIntr",
+				   chan->chan.impl->event.nonstall,
+				   nouveau_fence_wait_uevent_handler, &fctx->event);
 	WARN_ON(ret);
 }
 
diff --git a/drivers/gpu/drm/nouveau/nvif/chan.c b/drivers/gpu/drm/nouveau/nvif/chan.c
index cfca4dac5388..e8ade9a64d97 100644
--- a/drivers/gpu/drm/nouveau/nvif/chan.c
+++ b/drivers/gpu/drm/nouveau/nvif/chan.c
@@ -23,6 +23,23 @@
 #include <nvif/cgrp.h>
 #include <nvif/device.h>
 
+int
+nvif_chan_event_ctor(struct nvif_chan *chan, const char *name,
+		     int (*ctor)(struct nvif_chan_priv *, u64,
+				 const struct nvif_event_impl **, struct nvif_event_priv **),
+		     nvif_event_func func, struct nvif_event *event)
+{
+	int ret;
+
+	ret = ctor(chan->priv, nvif_handle(&event->object), &event->impl, &event->priv);
+	NVIF_ERRON(ret, &chan->object, "[NEW EVENT]");
+	if (ret)
+		return ret;
+
+	nvif_event_ctor(&chan->object, name ?: "nvifChanEvent", 0, func, event);
+	return 0;
+}
+
 void
 nvif_chan_dtor(struct nvif_chan *chan)
 {
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/chan.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/chan.c
index 7d4716dcd512..920e012d169b 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/chan.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/chan.c
@@ -31,8 +31,6 @@
 #include <subdev/mmu.h>
 #include <engine/dma.h>
 
-#include <nvif/if0020.h>
-
 const struct nvkm_event_func
 nvkm_chan_event = {
 };
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/uchan.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/uchan.c
index e9279902c472..ed1e53b15be4 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/uchan.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/uchan.c
@@ -32,8 +32,6 @@
 #include <subdev/mmu/umem.h>
 #include <engine/dma.h>
 
-#include <nvif/if0020.h>
-
 struct nvif_chan_priv {
 	struct nvkm_object object;
 	struct nvkm_chan *chan;
@@ -41,32 +39,6 @@ struct nvif_chan_priv {
 	struct nvif_chan_impl impl;
 };
 
-static int
-nvkm_uchan_uevent(struct nvkm_object *object, void *argv, u32 argc, struct nvkm_uevent *uevent)
-{
-	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;
-
-	if (!uevent)
-		return 0;
-	if (argc != sizeof(args->v0) || args->v0.version != 0)
-		return -ENOSYS;
-
-	switch (args->v0.type) {
-	case NVIF_CHAN_EVENT_V0_NON_STALL_INTR:
-		return nvkm_uevent_add(uevent, &runl->fifo->nonstall.event, runl->id,
-				       NVKM_FIFO_NONSTALL_EVENT, NULL);
-	case NVIF_CHAN_EVENT_V0_KILLED:
-		return nvkm_uevent_add(uevent, &runl->chid->event, chan->id,
-				       NVKM_CHAN_EVENT_ERRORED, NULL);
-	default:
-		break;
-	}
-
-	return -ENOSYS;
-}
-
 struct nvkm_uobj {
 	struct nvkm_oproxy oproxy;
 	struct nvkm_chan *chan;
@@ -254,6 +226,26 @@ nvkm_uchan_sclass(struct nvkm_object *object, int index, struct nvkm_oclass *ocl
 	return -EINVAL;
 }
 
+static int
+nvkm_uchan_event_nonstall(struct nvif_chan_priv *uchan, u64 token,
+			  const struct nvif_event_impl **pimpl, struct nvif_event_priv **ppriv)
+{
+	struct nvkm_runl *runl = uchan->chan->cgrp->runl;
+
+	return nvkm_uevent_new_(&uchan->object, token, &runl->fifo->nonstall.event, false,
+				runl->id, NVKM_FIFO_NONSTALL_EVENT, NULL, pimpl, ppriv);
+}
+
+static int
+nvkm_uchan_event_killed(struct nvif_chan_priv *uchan, u64 token,
+			const struct nvif_event_impl **pimpl, struct nvif_event_priv **ppriv)
+{
+	struct nvkm_runl *runl = uchan->chan->cgrp->runl;
+
+	return nvkm_uevent_new_(&uchan->object, token, &runl->chid->event, false,
+				uchan->chan->id, NVKM_CHAN_EVENT_ERRORED, NULL, pimpl, ppriv);
+}
+
 static void
 nvkm_uchan_del(struct nvif_chan_priv *uchan)
 {
@@ -266,6 +258,7 @@ nvkm_uchan_del(struct nvif_chan_priv *uchan)
 static const struct nvif_chan_impl
 nvkm_uchan_impl = {
 	.del = nvkm_uchan_del,
+	.event.killed = nvkm_uchan_event_killed,
 };
 
 static int
@@ -313,7 +306,6 @@ nvkm_uchan = {
 	.init = nvkm_uchan_init,
 	.fini = nvkm_uchan_fini,
 	.sclass = nvkm_uchan_sclass,
-	.uevent = nvkm_uchan_uevent,
 };
 
 struct nvkm_chan *
@@ -404,6 +396,9 @@ nvkm_uchan_new(struct nvkm_device *device, struct nvkm_cgrp *cgrp, u8 runi, u8 r
 		uchan->impl.map.length = chan->func->userd->size;
 	}
 
+	if (fifo->func->nonstall)
+		uchan->impl.event.nonstall = nvkm_uchan_event_nonstall;
+
 	*pimpl = &uchan->impl;
 	*ppriv = uchan;
 	*pobject = &uchan->object;
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 144/156] drm/nouveau/nvif: rework chan "new ctxdma" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (142 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 143/156] drm/nouveau/nvif: rework chan "new event" apis Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 145/156] drm/nouveau/nvif: rework chan "new engobj" apis Ben Skeggs
                   ` (13 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interface

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/include/nvif/chan.h   |  4 ++
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  5 ++
 drivers/gpu/drm/nouveau/nouveau_abi16.c       | 15 +++---
 drivers/gpu/drm/nouveau/nouveau_abi16.h       |  3 +-
 drivers/gpu/drm/nouveau/nouveau_bo0039.c      |  4 +-
 drivers/gpu/drm/nouveau/nouveau_bo5039.c      |  6 +--
 drivers/gpu/drm/nouveau/nouveau_chan.c        | 16 +++---
 drivers/gpu/drm/nouveau/nouveau_chan.h        |  4 +-
 drivers/gpu/drm/nouveau/nouveau_drm.c         | 12 ++---
 drivers/gpu/drm/nouveau/nouveau_drv.h         |  3 +-
 drivers/gpu/drm/nouveau/nv10_fence.c          |  2 +-
 drivers/gpu/drm/nouveau/nv10_fence.h          |  2 +-
 drivers/gpu/drm/nouveau/nv17_fence.c          | 13 +++--
 drivers/gpu/drm/nouveau/nv50_fence.c          |  9 ++--
 drivers/gpu/drm/nouveau/nv84_fence.c          |  4 +-
 drivers/gpu/drm/nouveau/nvif/chan.c           | 17 +++++++
 .../gpu/drm/nouveau/nvkm/engine/fifo/uchan.c  | 51 +++++++++++++++++++
 17 files changed, 125 insertions(+), 45 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/chan.h b/drivers/gpu/drm/nouveau/include/nvif/chan.h
index 45c82cef6b1d..1115318f8b9d 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/chan.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/chan.h
@@ -6,6 +6,7 @@
 #include <nvif/event.h>
 #include <nvif/push.h>
 struct nvif_cgrp;
+struct nvif_ctxdma;
 struct nvif_device;
 
 struct nvif_chan {
@@ -28,4 +29,7 @@ int nvif_chan_event_ctor(struct nvif_chan *, const char *name,
 			 int (*ctor)(struct nvif_chan_priv *, u64 token,
 				     const struct nvif_event_impl **, struct nvif_event_priv **),
 			 nvif_event_func, struct nvif_event *);
+
+int nvif_chan_ctxdma_ctor(struct nvif_chan *, const char *name, u32 handle, s32 oclass,
+			  void *argv, u32 argc, struct nvif_ctxdma *);
 #endif
diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 6e109da67bbe..8e805633ded5 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -455,6 +455,11 @@ struct nvif_chan_impl {
 		int (*nonstall)(struct nvif_chan_priv *, u64 token,
 				const struct nvif_event_impl **, struct nvif_event_priv **);
 	} event;
+
+	struct {
+		int (*new)(struct nvif_chan_priv *, u32 handle, s32 oclass, void *argv, u32 argc,
+			   const struct nvif_ctxdma_impl **, struct nvif_ctxdma_priv **);
+	} ctxdma;
 };
 
 struct nvif_cgrp_impl {
diff --git a/drivers/gpu/drm/nouveau/nouveau_abi16.c b/drivers/gpu/drm/nouveau/nouveau_abi16.c
index 36cf7b035973..ff310b48fa34 100644
--- a/drivers/gpu/drm/nouveau/nouveau_abi16.c
+++ b/drivers/gpu/drm/nouveau/nouveau_abi16.c
@@ -138,7 +138,10 @@ static void
 nouveau_abi16_ntfy_fini(struct nouveau_abi16_chan *chan,
 			struct nouveau_abi16_ntfy *ntfy)
 {
-	nvif_object_dtor(&ntfy->object);
+	if (ntfy->ctxdma.impl)
+		nvif_ctxdma_dtor(&ntfy->ctxdma);
+	else
+		nvif_object_dtor(&ntfy->engobj);
 	nvkm_mm_free(&chan->heap, &ntfy->node);
 	list_del(&ntfy->head);
 	kfree(ntfy);
@@ -534,7 +537,7 @@ nouveau_abi16_ioctl_grobj_alloc(ABI16_IOCTL_ARGS)
 	list_add(&ntfy->head, &chan->notifiers);
 
 	ret = nvif_object_ctor(&chan->chan->chan.object, "abi16EngObj", init->handle,
-			       oclass, NULL, 0, &ntfy->object);
+			       oclass, NULL, 0, &ntfy->engobj);
 
 	if (ret)
 		nouveau_abi16_ntfy_fini(chan, ntfy);
@@ -595,9 +598,9 @@ nouveau_abi16_ioctl_notifierobj_alloc(ABI16_IOCTL_ARGS)
 		args.limit += chan->ntfy->offset;
 	}
 
-	ret = nvif_object_ctor(&chan->chan->chan.object, "abi16Ntfy", info->handle,
-			       NV_DMA_IN_MEMORY, &args, sizeof(args),
-			       &ntfy->object);
+	ret = nvif_chan_ctxdma_ctor(&chan->chan->chan, "abi16Ntfy", info->handle,
+				    NV_DMA_IN_MEMORY, &args, sizeof(args),
+				    &ntfy->ctxdma);
 	if (ret)
 		goto done;
 
@@ -628,7 +631,7 @@ nouveau_abi16_ioctl_gpuobj_free(ABI16_IOCTL_ARGS)
 	nouveau_channel_idle(chan->chan);
 
 	list_for_each_entry(ntfy, &chan->notifiers, head) {
-		if (ntfy->object.handle == fini->handle) {
+		if (ntfy->ctxdma.object.handle == fini->handle) {
 			nouveau_abi16_ntfy_fini(chan, ntfy);
 			ret = 0;
 			break;
diff --git a/drivers/gpu/drm/nouveau/nouveau_abi16.h b/drivers/gpu/drm/nouveau/nouveau_abi16.h
index af6b4e1cefd2..fdf239545c41 100644
--- a/drivers/gpu/drm/nouveau/nouveau_abi16.h
+++ b/drivers/gpu/drm/nouveau/nouveau_abi16.h
@@ -13,7 +13,8 @@ int nouveau_abi16_ioctl_notifierobj_alloc(ABI16_IOCTL_ARGS);
 int nouveau_abi16_ioctl_gpuobj_free(ABI16_IOCTL_ARGS);
 
 struct nouveau_abi16_ntfy {
-	struct nvif_object object;
+	struct nvif_ctxdma ctxdma;
+	struct nvif_object engobj;
 	struct list_head head;
 	struct nvkm_mm_node *node;
 };
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo0039.c b/drivers/gpu/drm/nouveau/nouveau_bo0039.c
index 0b6758e024a1..a69fc865bfcd 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo0039.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo0039.c
@@ -40,7 +40,7 @@ nouveau_bo_mem_ctxdma(struct ttm_buffer_object *bo,
 {
 	if (reg->mem_type == TTM_PL_TT)
 		return NvDmaTT;
-	return chan->vram.handle;
+	return chan->vram.object.handle;
 }
 
 int
@@ -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->cli->drm->ntfy.handle);
+	PUSH_MTHD(push, NV039, SET_CONTEXT_DMA_NOTIFIES, chan->cli->drm->ntfy.object.handle);
 	return 0;
 }
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo5039.c b/drivers/gpu/drm/nouveau/nouveau_bo5039.c
index c3de17548d97..9fd03b68d56d 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo5039.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo5039.c
@@ -144,8 +144,8 @@ 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->cli->drm->ntfy.handle,
-				SET_CONTEXT_DMA_BUFFER_IN, chan->vram.handle,
-				SET_CONTEXT_DMA_BUFFER_OUT, chan->vram.handle);
+	PUSH_MTHD(push, NV5039, SET_CONTEXT_DMA_NOTIFY, chan->cli->drm->ntfy.object.handle,
+				SET_CONTEXT_DMA_BUFFER_IN, chan->vram.object.handle,
+				SET_CONTEXT_DMA_BUFFER_OUT, chan->vram.object.handle);
 	return 0;
 }
diff --git a/drivers/gpu/drm/nouveau/nouveau_chan.c b/drivers/gpu/drm/nouveau/nouveau_chan.c
index 7116d61535f8..5ac0756714c1 100644
--- a/drivers/gpu/drm/nouveau/nouveau_chan.c
+++ b/drivers/gpu/drm/nouveau/nouveau_chan.c
@@ -97,8 +97,8 @@ nouveau_channel_del(struct nouveau_channel **pchan)
 
 		nvif_object_dtor(&chan->blit);
 		nvif_object_dtor(&chan->nvsw);
-		nvif_object_dtor(&chan->gart);
-		nvif_object_dtor(&chan->vram);
+		nvif_ctxdma_dtor(&chan->gart);
+		nvif_ctxdma_dtor(&chan->vram);
 		nvif_event_dtor(&chan->kill);
 		nvif_object_unmap_cpu(&chan->userd.map);
 		nvif_chan_dtor(&chan->chan);
@@ -393,9 +393,9 @@ nouveau_channel_init(struct nouveau_channel *chan, u32 vram, u32 gart)
 			args.limit = device->info.ram_user - 1;
 		}
 
-		ret = nvif_object_ctor(&chan->chan.object, "abi16ChanVramCtxDma", vram,
-				       NV_DMA_IN_MEMORY, &args, sizeof(args),
-				       &chan->vram);
+		ret = nvif_chan_ctxdma_ctor(&chan->chan, "abi16ChanVramCtxDma", vram,
+					    NV_DMA_IN_MEMORY, &args, sizeof(args),
+					    &chan->vram);
 		if (ret)
 			return ret;
 
@@ -417,9 +417,9 @@ nouveau_channel_init(struct nouveau_channel *chan, u32 vram, u32 gart)
 			args.limit = chan->vmm->vmm.impl->limit - 1;
 		}
 
-		ret = nvif_object_ctor(&chan->chan.object, "abi16ChanGartCtxDma", gart,
-				       NV_DMA_IN_MEMORY, &args, sizeof(args),
-				       &chan->gart);
+		ret = nvif_chan_ctxdma_ctor(&chan->chan, "abi16ChanGartCtxDma", gart,
+					    NV_DMA_IN_MEMORY, &args, sizeof(args),
+					    &chan->gart);
 		if (ret)
 			return ret;
 	}
diff --git a/drivers/gpu/drm/nouveau/nouveau_chan.h b/drivers/gpu/drm/nouveau/nouveau_chan.h
index 8f71492e2df3..1340c64c4357 100644
--- a/drivers/gpu/drm/nouveau/nouveau_chan.h
+++ b/drivers/gpu/drm/nouveau/nouveau_chan.h
@@ -24,8 +24,8 @@ struct nouveau_channel {
 	u64 inst;
 	u32 token;
 
-	struct nvif_object vram;
-	struct nvif_object gart;
+	struct nvif_ctxdma vram;
+	struct nvif_ctxdma gart;
 	struct nvif_object nvsw;
 
 	struct {
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index a2c9e8fa4ebd..28347aa056b8 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -285,7 +285,7 @@ static void
 nouveau_accel_gr_fini(struct nouveau_drm *drm)
 {
 	nouveau_channel_idle(drm->channel);
-	nvif_object_dtor(&drm->ntfy);
+	nvif_ctxdma_dtor(&drm->ntfy);
 	nvkm_gpuobj_del(&drm->notify);
 	nouveau_channel_del(&drm->channel);
 }
@@ -361,15 +361,15 @@ nouveau_accel_gr_init(struct nouveau_drm *drm)
 			return;
 		}
 
-		ret = nvif_object_ctor(&drm->channel->chan.object, "drmM2mfNtfy",
-				       NvNotify0, NV_DMA_IN_MEMORY,
-				       (&(struct nv_dma_v0) {
+		ret = nvif_chan_ctxdma_ctor(&drm->channel->chan, "drmM2mfNtfy",
+					    NvNotify0, NV_DMA_IN_MEMORY,
+					    &(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),
-				       &drm->ntfy);
+					    }, sizeof(struct nv_dma_v0),
+					    &drm->ntfy);
 		if (ret) {
 			nouveau_accel_gr_fini(drm);
 			return;
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h
index 823fa6d87690..3d661148943c 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.h
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.h
@@ -41,6 +41,7 @@
 #include <linux/notifier.h>
 
 #include <nvif/client.h>
+#include <nvif/ctxdma.h>
 #include <nvif/device.h>
 #include <nvif/ioctl.h>
 #include <nvif/mmu.h>
@@ -271,7 +272,7 @@ struct nouveau_drm {
 	struct nouveau_channel *cechan;
 	struct nouveau_channel *channel;
 	struct nvkm_gpuobj *notify;
-	struct nvif_object ntfy;
+	struct nvif_ctxdma ntfy;
 
 	/* nv10-nv40 tiling regions */
 	struct {
diff --git a/drivers/gpu/drm/nouveau/nv10_fence.c b/drivers/gpu/drm/nouveau/nv10_fence.c
index cbef6ef4bfb7..3e9f184dd4e8 100644
--- a/drivers/gpu/drm/nouveau/nv10_fence.c
+++ b/drivers/gpu/drm/nouveau/nv10_fence.c
@@ -60,7 +60,7 @@ nv10_fence_context_del(struct nouveau_channel *chan)
 {
 	struct nv10_fence_chan *fctx = chan->fence;
 	nouveau_fence_context_del(&fctx->base);
-	nvif_object_dtor(&fctx->sema);
+	nvif_ctxdma_dtor(&fctx->sema);
 	chan->fence = NULL;
 	nouveau_fence_context_free(&fctx->base);
 }
diff --git a/drivers/gpu/drm/nouveau/nv10_fence.h b/drivers/gpu/drm/nouveau/nv10_fence.h
index 300cf3fdbb46..414dfb81e812 100644
--- a/drivers/gpu/drm/nouveau/nv10_fence.h
+++ b/drivers/gpu/drm/nouveau/nv10_fence.h
@@ -7,7 +7,7 @@
 
 struct nv10_fence_chan {
 	struct nouveau_fence_chan base;
-	struct nvif_object sema;
+	struct nvif_ctxdma sema;
 };
 
 struct nv10_fence_priv {
diff --git a/drivers/gpu/drm/nouveau/nv17_fence.c b/drivers/gpu/drm/nouveau/nv17_fence.c
index 17ff00b22e9e..ba499dfb621d 100644
--- a/drivers/gpu/drm/nouveau/nv17_fence.c
+++ b/drivers/gpu/drm/nouveau/nv17_fence.c
@@ -54,7 +54,7 @@ nv17_fence_sync(struct nouveau_fence *fence,
 
 	ret = PUSH_WAIT(ppush, 5);
 	if (!ret) {
-		PUSH_MTHD(ppush, NV176E, SET_CONTEXT_DMA_SEMAPHORE, fctx->sema.handle,
+		PUSH_MTHD(ppush, NV176E, SET_CONTEXT_DMA_SEMAPHORE, fctx->sema.object.handle,
 					 SEMAPHORE_OFFSET, 0,
 					 SEMAPHORE_ACQUIRE, value + 0,
 					 SEMAPHORE_RELEASE, value + 1);
@@ -62,7 +62,7 @@ nv17_fence_sync(struct nouveau_fence *fence,
 	}
 
 	if (!ret && !(ret = PUSH_WAIT(npush, 5))) {
-		PUSH_MTHD(npush, NV176E, SET_CONTEXT_DMA_SEMAPHORE, fctx->sema.handle,
+		PUSH_MTHD(npush, NV176E, SET_CONTEXT_DMA_SEMAPHORE, fctx->sema.object.handle,
 					 SEMAPHORE_OFFSET, 0,
 					 SEMAPHORE_ACQUIRE, value + 1,
 					 SEMAPHORE_RELEASE, value + 2);
@@ -92,15 +92,14 @@ nv17_fence_context_new(struct nouveau_channel *chan)
 	fctx->base.read = nv10_fence_read;
 	fctx->base.sync = nv17_fence_sync;
 
-	ret = nvif_object_ctor(&chan->chan.object, "fenceCtxDma", NvSema,
-			       NV_DMA_FROM_MEMORY,
-			       (&(struct nv_dma_v0) {
+	ret = nvif_chan_ctxdma_ctor(&chan->chan, "fenceCtxDma", NvSema, NV_DMA_FROM_MEMORY,
+				    &(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),
-			       &fctx->sema);
+				    }, sizeof(struct nv_dma_v0),
+				    &fctx->sema);
 	if (ret)
 		nv10_fence_context_del(chan);
 	return ret;
diff --git a/drivers/gpu/drm/nouveau/nv50_fence.c b/drivers/gpu/drm/nouveau/nv50_fence.c
index b418439e6bb1..405a3f8ff4d4 100644
--- a/drivers/gpu/drm/nouveau/nv50_fence.c
+++ b/drivers/gpu/drm/nouveau/nv50_fence.c
@@ -51,15 +51,14 @@ nv50_fence_context_new(struct nouveau_channel *chan)
 	fctx->base.read = nv10_fence_read;
 	fctx->base.sync = nv17_fence_sync;
 
-	ret = nvif_object_ctor(&chan->chan.object, "fenceCtxDma", NvSema,
-			       NV_DMA_IN_MEMORY,
-			       (&(struct nv_dma_v0) {
+	ret = nvif_chan_ctxdma_ctor(&chan->chan, "fenceCtxDma", NvSema, NV_DMA_IN_MEMORY,
+				    &(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),
-			       &fctx->sema);
+				    }, sizeof(struct nv_dma_v0),
+				    &fctx->sema);
 	if (ret)
 		nv10_fence_context_del(chan);
 	return ret;
diff --git a/drivers/gpu/drm/nouveau/nv84_fence.c b/drivers/gpu/drm/nouveau/nv84_fence.c
index a9cbea2d1cc0..0626c24ca065 100644
--- a/drivers/gpu/drm/nouveau/nv84_fence.c
+++ b/drivers/gpu/drm/nouveau/nv84_fence.c
@@ -38,7 +38,7 @@ nv84_fence_emit32(struct nouveau_channel *chan, u64 virtual, u32 sequence)
 	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);
+		PUSH_MTHD(push, NV826F, SET_CONTEXT_DMA_SEMAPHORE, chan->vram.object.handle);
 
 		PUSH_MTHD(push, NV826F, SEMAPHOREA,
 			  NVVAL(NV826F, SEMAPHOREA, OFFSET_UPPER, upper_32_bits(virtual)),
@@ -61,7 +61,7 @@ nv84_fence_sync32(struct nouveau_channel *chan, u64 virtual, u32 sequence)
 	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);
+		PUSH_MTHD(push, NV826F, SET_CONTEXT_DMA_SEMAPHORE, chan->vram.object.handle);
 
 		PUSH_MTHD(push, NV826F, SEMAPHOREA,
 			  NVVAL(NV826F, SEMAPHOREA, OFFSET_UPPER, upper_32_bits(virtual)),
diff --git a/drivers/gpu/drm/nouveau/nvif/chan.c b/drivers/gpu/drm/nouveau/nvif/chan.c
index e8ade9a64d97..78f380ef01b7 100644
--- a/drivers/gpu/drm/nouveau/nvif/chan.c
+++ b/drivers/gpu/drm/nouveau/nvif/chan.c
@@ -21,8 +21,25 @@
  */
 #include <nvif/chan.h>
 #include <nvif/cgrp.h>
+#include <nvif/ctxdma.h>
 #include <nvif/device.h>
 
+int
+nvif_chan_ctxdma_ctor(struct nvif_chan *chan, const char *name, u32 handle, s32 oclass,
+		      void *argv, u32 argc, struct nvif_ctxdma *ctxdma)
+{
+	int ret;
+
+	ret = chan->impl->ctxdma.new(chan->priv, handle, oclass, argv, argc,
+				     &ctxdma->impl, &ctxdma->priv);
+	NVIF_ERRON(ret, &chan->object, "[NEW ctxdma%04x handle:%08x]", oclass, handle);
+	if (ret)
+		return ret;
+
+	nvif_ctxdma_ctor(&chan->object, name ?: "nvifChanCtxDma", handle, oclass, ctxdma);
+	return 0;
+}
+
 int
 nvif_chan_event_ctor(struct nvif_chan *chan, const char *name,
 		     int (*ctor)(struct nvif_chan_priv *, u64,
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/uchan.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/uchan.c
index ed1e53b15be4..f6dfba41da8c 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/uchan.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/uchan.c
@@ -226,6 +226,56 @@ nvkm_uchan_sclass(struct nvkm_object *object, int index, struct nvkm_oclass *ocl
 	return -EINVAL;
 }
 
+static void
+nvkm_uchan_ctxdma_del(struct nvif_ctxdma_priv *priv)
+{
+	struct nvkm_uobj *uobj = (void *)priv;
+	struct nvkm_object *object = &uobj->oproxy.base;
+
+	nvkm_object_del(&object);
+}
+
+static const struct nvif_ctxdma_impl
+nvkm_uchan_ctxdma_impl = {
+	.del = nvkm_uchan_ctxdma_del,
+};
+
+static int
+nvkm_uchan_ctxdma_new(struct nvif_chan_priv *uchan, u32 handle, s32 oclass, void *argv, u32 argc,
+		      const struct nvif_ctxdma_impl **pimpl, struct nvif_ctxdma_priv **ppriv)
+{
+	struct nvkm_dma *dma = uchan->chan->cgrp->runl->fifo->engine.subdev.device->dma;
+	struct nvkm_oclass _oclass = {};
+	struct nvkm_object *object;
+	int i, ret;
+
+	_oclass.client = uchan->object.client;
+	_oclass.parent = &uchan->object;
+	_oclass.engine = &dma->engine;
+	_oclass.handle = handle;
+
+	i = 0;
+	do {
+		_oclass.base.oclass = 0;
+		dma->engine.func->fifo.sclass(&_oclass, i++);
+		if (_oclass.base.oclass == oclass)
+			break;
+	} while (_oclass.base.oclass);
+
+	if (!_oclass.base.oclass)
+		return -EINVAL;
+
+	ret = nvkm_uchan_object_new(&_oclass, argv, argc, &object);
+	if (ret)
+		return ret;
+
+	*pimpl = &nvkm_uchan_ctxdma_impl;
+	*ppriv = (void *)container_of(object, struct nvkm_uobj, oproxy.base);
+
+	nvkm_object_link(&uchan->object, object);
+	return 0;
+}
+
 static int
 nvkm_uchan_event_nonstall(struct nvif_chan_priv *uchan, u64 token,
 			  const struct nvif_event_impl **pimpl, struct nvif_event_priv **ppriv)
@@ -259,6 +309,7 @@ static const struct nvif_chan_impl
 nvkm_uchan_impl = {
 	.del = nvkm_uchan_del,
 	.event.killed = nvkm_uchan_event_killed,
+	.ctxdma.new = nvkm_uchan_ctxdma_new,
 };
 
 static int
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 145/156] drm/nouveau/nvif: rework chan "new engobj" apis
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (143 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 144/156] drm/nouveau/nvif: rework chan "new ctxdma" api Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 146/156] drm/nouveau/nvif: remove chan from object rb Ben Skeggs
                   ` (12 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interfaces

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/dispnv04/disp.c       |   2 +-
 drivers/gpu/drm/nouveau/include/nvif/chan.h   |  10 ++
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  11 ++
 drivers/gpu/drm/nouveau/nouveau_abi16.c       |  31 ++---
 drivers/gpu/drm/nouveau/nouveau_abi16.h       |   4 +-
 drivers/gpu/drm/nouveau/nouveau_bo.c          |   9 +-
 drivers/gpu/drm/nouveau/nouveau_chan.c        |  11 +-
 drivers/gpu/drm/nouveau/nouveau_chan.h        |   4 +-
 drivers/gpu/drm/nouveau/nouveau_dmem.c        |   2 +-
 drivers/gpu/drm/nouveau/nouveau_drm.c         |  18 ++-
 drivers/gpu/drm/nouveau/nouveau_drv.h         |   3 +-
 drivers/gpu/drm/nouveau/nv04_fence.c          |   2 +-
 drivers/gpu/drm/nouveau/nvif/chan.c           |  51 +++++++
 .../gpu/drm/nouveau/nvkm/engine/fifo/uchan.c  | 124 ++++++++++++------
 14 files changed, 200 insertions(+), 82 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv04/disp.c b/drivers/gpu/drm/nouveau/dispnv04/disp.c
index e8b27bb135e7..3e10ba2ed20f 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/disp.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/disp.c
@@ -236,7 +236,7 @@ nv04_display_create(struct drm_device *dev)
 
 	/* Request page flip completion event. */
 	if (drm->channel) {
-		ret = nvif_event_ctor(&drm->channel->nvsw, "kmsFlip", 0, nv04_flip_complete,
+		ret = nvif_event_ctor(&drm->channel->nvsw.object, "kmsFlip", 0, nv04_flip_complete,
 				      true, NULL, 0, &disp->flip);
 		if (ret)
 			return ret;
diff --git a/drivers/gpu/drm/nouveau/include/nvif/chan.h b/drivers/gpu/drm/nouveau/include/nvif/chan.h
index 1115318f8b9d..d43c6ba2a35e 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/chan.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/chan.h
@@ -32,4 +32,14 @@ int nvif_chan_event_ctor(struct nvif_chan *, const char *name,
 
 int nvif_chan_ctxdma_ctor(struct nvif_chan *, const char *name, u32 handle, s32 oclass,
 			  void *argv, u32 argc, struct nvif_ctxdma *);
+
+struct nvif_engobj {
+	const struct nvif_engobj_impl *impl;
+	struct nvif_engobj_priv *priv;
+	struct nvif_object object;
+};
+
+int nvif_engobj_ctor(struct nvif_chan *chan, const char *name, u32 handle, s32 oclass,
+		     struct nvif_engobj *);
+void nvif_engobj_dtor(struct nvif_engobj *);
 #endif
diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 8e805633ded5..69428a879c37 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -21,6 +21,7 @@ struct nvif_disp_chan_priv;
 struct nvif_ctxdma_priv;
 struct nvif_cgrp_priv;
 struct nvif_chan_priv;
+struct nvif_engobj_priv;
 
 struct nvif_driver {
 	const char *name;
@@ -431,6 +432,10 @@ struct nvif_disp_impl {
 	} chan;
 };
 
+struct nvif_engobj_impl {
+	void (*del)(struct nvif_engobj_priv *);
+};
+
 struct nvif_chan_impl {
 	void (*del)(struct nvif_chan_priv *);
 
@@ -460,6 +465,12 @@ struct nvif_chan_impl {
 		int (*new)(struct nvif_chan_priv *, u32 handle, s32 oclass, void *argv, u32 argc,
 			   const struct nvif_ctxdma_impl **, struct nvif_ctxdma_priv **);
 	} ctxdma;
+
+	struct {
+		int (*new)(struct nvif_chan_priv *, u32 handle, u8 engi, s32 oclass,
+			   const struct nvif_engobj_impl **, struct nvif_engobj_priv **,
+			   u64 object);
+	} engobj;
 };
 
 struct nvif_cgrp_impl {
diff --git a/drivers/gpu/drm/nouveau/nouveau_abi16.c b/drivers/gpu/drm/nouveau/nouveau_abi16.c
index ff310b48fa34..8cc7b2410a04 100644
--- a/drivers/gpu/drm/nouveau/nouveau_abi16.c
+++ b/drivers/gpu/drm/nouveau/nouveau_abi16.c
@@ -81,9 +81,7 @@ struct nouveau_abi16_obj {
 	u64 object;
 
 	union {
-		struct {
-			struct nvif_object object;
-		} engobj;
+		struct nvif_engobj engobj;
 	};
 
 	struct list_head head;
@@ -141,7 +139,7 @@ nouveau_abi16_ntfy_fini(struct nouveau_abi16_chan *chan,
 	if (ntfy->ctxdma.impl)
 		nvif_ctxdma_dtor(&ntfy->ctxdma);
 	else
-		nvif_object_dtor(&ntfy->engobj);
+		nvif_engobj_dtor(&ntfy->engobj);
 	nvkm_mm_free(&chan->heap, &ntfy->node);
 	list_del(&ntfy->head);
 	kfree(ntfy);
@@ -179,7 +177,7 @@ nouveau_abi16_chan_fini(struct nouveau_abi16 *abi16,
 
 	/* destroy channel object, all children will be killed too */
 	if (chan->chan) {
-		nvif_object_dtor(&chan->ce);
+		nvif_engobj_dtor(&chan->ce);
 		nouveau_channel_del(&chan->chan);
 	}
 
@@ -400,7 +398,7 @@ nouveau_abi16_ioctl_channel_alloc(ABI16_IOCTL_ARGS)
 	if (device->info.family < NV_DEVICE_INFO_V0_CELSIUS) {
 		init->subchan[0].handle = 0x00000000;
 		init->subchan[0].grclass = 0x0000;
-		init->subchan[1].handle = chan->chan->nvsw.handle;
+		init->subchan[1].handle = chan->chan->nvsw.object.handle;
 		init->subchan[1].grclass = 0x506e;
 		init->nr_subchan = 2;
 	}
@@ -415,14 +413,14 @@ nouveau_abi16_ioctl_channel_alloc(ABI16_IOCTL_ARGS)
 	 */
 	switch (device->info.family) {
 	case NV_DEVICE_INFO_V0_VOLTA:
-		ret = nvif_object_ctor(&chan->chan->chan.object, "abi16CeWar", 0, VOLTA_DMA_COPY_A,
-				       NULL, 0, &chan->ce);
+		ret = nvif_engobj_ctor(&chan->chan->chan, "abi16CeWar", 0, VOLTA_DMA_COPY_A,
+				       &chan->ce);
 		if (ret)
 			goto done;
 		break;
 	case NV_DEVICE_INFO_V0_TURING:
-		ret = nvif_object_ctor(&chan->chan->chan.object, "abi16CeWar", 0, TURING_DMA_COPY_A,
-				       NULL, 0, &chan->ce);
+		ret = nvif_engobj_ctor(&chan->chan->chan, "abi16CeWar", 0, TURING_DMA_COPY_A,
+				       &chan->ce);
 		if (ret)
 			goto done;
 		break;
@@ -536,8 +534,8 @@ nouveau_abi16_ioctl_grobj_alloc(ABI16_IOCTL_ARGS)
 
 	list_add(&ntfy->head, &chan->notifiers);
 
-	ret = nvif_object_ctor(&chan->chan->chan.object, "abi16EngObj", init->handle,
-			       oclass, NULL, 0, &ntfy->engobj);
+	ret = nvif_engobj_ctor(&chan->chan->chan, "abi16EngObj", init->handle, oclass,
+			       &ntfy->engobj);
 
 	if (ret)
 		nouveau_abi16_ntfy_fini(chan, ntfy);
@@ -680,8 +678,11 @@ nouveau_abi16_ioctl_del(struct nouveau_abi16 *abi16, struct nvif_ioctl_v0 *ioctl
 		return -EINVAL;
 
 	obj = nouveau_abi16_obj_find(abi16, ioctl->object);
-	if (obj)
+	if (obj) {
+		if (obj->type == ENGOBJ)
+			nvif_engobj_dtor(&obj->engobj);
 		nouveau_abi16_obj_del(obj);
+	}
 
 	return 0;
 }
@@ -721,8 +722,8 @@ nouveau_abi16_ioctl_new(struct nouveau_abi16 *abi16, struct nvif_ioctl_v0 *ioctl
 	if (IS_ERR(obj))
 		return PTR_ERR(obj);
 
-	ret = nvif_object_ctor(&chan->chan->chan.object, "abi16EngObj", args->handle, args->oclass,
-			       NULL, 0, &obj->engobj.object);
+	ret = nvif_engobj_ctor(&chan->chan->chan, "abi16EngObj", args->handle, args->oclass,
+			       &obj->engobj);
 	if (ret)
 		nouveau_abi16_obj_del(obj);
 
diff --git a/drivers/gpu/drm/nouveau/nouveau_abi16.h b/drivers/gpu/drm/nouveau/nouveau_abi16.h
index fdf239545c41..c37d304e3f5f 100644
--- a/drivers/gpu/drm/nouveau/nouveau_abi16.h
+++ b/drivers/gpu/drm/nouveau/nouveau_abi16.h
@@ -14,7 +14,7 @@ int nouveau_abi16_ioctl_gpuobj_free(ABI16_IOCTL_ARGS);
 
 struct nouveau_abi16_ntfy {
 	struct nvif_ctxdma ctxdma;
-	struct nvif_object engobj;
+	struct nvif_engobj engobj;
 	struct list_head head;
 	struct nvkm_mm_node *node;
 };
@@ -22,7 +22,7 @@ struct nouveau_abi16_ntfy {
 struct nouveau_abi16_chan {
 	struct list_head head;
 	struct nouveau_channel *chan;
-	struct nvif_object ce;
+	struct nvif_engobj ce;
 	struct list_head notifiers;
 	struct nouveau_bo *ntfy;
 	struct nouveau_vma *ntfy_vma;
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
index 6c5426fe2007..a94735ec3a9e 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -965,14 +965,13 @@ nouveau_bo_move_init(struct nouveau_drm *drm)
 		if (chan == NULL)
 			continue;
 
-		ret = nvif_object_ctor(&chan->chan.object, "ttmBoMove",
-				       mthd->oclass | (mthd->engine << 16),
-				       mthd->oclass, NULL, 0,
+		ret = nvif_engobj_ctor(&chan->chan, "ttmBoMove",
+				       (mthd->engine << 16) | mthd->oclass, mthd->oclass,
 				       &drm->ttm.copy);
 		if (ret == 0) {
-			ret = mthd->init(chan, drm->ttm.copy.handle);
+			ret = mthd->init(chan, drm->ttm.copy.object.handle);
 			if (ret) {
-				nvif_object_dtor(&drm->ttm.copy);
+				nvif_engobj_dtor(&drm->ttm.copy);
 				continue;
 			}
 
diff --git a/drivers/gpu/drm/nouveau/nouveau_chan.c b/drivers/gpu/drm/nouveau/nouveau_chan.c
index 5ac0756714c1..80099dfcd3d5 100644
--- a/drivers/gpu/drm/nouveau/nouveau_chan.c
+++ b/drivers/gpu/drm/nouveau/nouveau_chan.c
@@ -95,8 +95,8 @@ nouveau_channel_del(struct nouveau_channel **pchan)
 		if (chan->chan.impl)
 			nouveau_svmm_part(chan->vmm->svmm, chan->inst);
 
-		nvif_object_dtor(&chan->blit);
-		nvif_object_dtor(&chan->nvsw);
+		nvif_engobj_dtor(&chan->blit);
+		nvif_engobj_dtor(&chan->nvsw);
 		nvif_ctxdma_dtor(&chan->gart);
 		nvif_ctxdma_dtor(&chan->vram);
 		nvif_event_dtor(&chan->kill);
@@ -459,9 +459,8 @@ nouveau_channel_init(struct nouveau_channel *chan, u32 vram, u32 gart)
 
 	/* allocate software object class (used for fences on <= nv05) */
 	if (device->info.family < NV_DEVICE_INFO_V0_CELSIUS) {
-		ret = nvif_object_ctor(&chan->chan.object, "abi16NvswFence", 0x006e,
-				       NVIF_CLASS_SW_NV04,
-				       NULL, 0, &chan->nvsw);
+		ret = nvif_engobj_ctor(&chan->chan, "abi16NvswFence", 0x006e,
+				       NVIF_CLASS_SW_NV04, &chan->nvsw);
 		if (ret)
 			return ret;
 
@@ -469,7 +468,7 @@ nouveau_channel_init(struct nouveau_channel *chan, u32 vram, u32 gart)
 		if (ret)
 			return ret;
 
-		PUSH_NVSQ(&chan->chan.push, NV_SW, 0x0000, chan->nvsw.handle);
+		PUSH_NVSQ(&chan->chan.push, NV_SW, 0x0000, chan->nvsw.object.handle);
 		PUSH_KICK(&chan->chan.push);
 	}
 
diff --git a/drivers/gpu/drm/nouveau/nouveau_chan.h b/drivers/gpu/drm/nouveau/nouveau_chan.h
index 1340c64c4357..b1dbffd93894 100644
--- a/drivers/gpu/drm/nouveau/nouveau_chan.h
+++ b/drivers/gpu/drm/nouveau/nouveau_chan.h
@@ -26,7 +26,7 @@ struct nouveau_channel {
 
 	struct nvif_ctxdma vram;
 	struct nvif_ctxdma gart;
-	struct nvif_object nvsw;
+	struct nvif_engobj nvsw;
 
 	struct {
 		struct nouveau_bo *buffer;
@@ -52,7 +52,7 @@ struct nouveau_channel {
 	u32 user_get;
 	u32 user_put;
 
-	struct nvif_object blit;
+	struct nvif_engobj blit;
 
 	struct nvif_event kill;
 	atomic_t killed;
diff --git a/drivers/gpu/drm/nouveau/nouveau_dmem.c b/drivers/gpu/drm/nouveau/nouveau_dmem.c
index fed91756846f..a0c24456e031 100644
--- a/drivers/gpu/drm/nouveau/nouveau_dmem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_dmem.c
@@ -570,7 +570,7 @@ nvc0b5_migrate_clear(struct nouveau_drm *drm, u32 length,
 static int
 nouveau_dmem_migrate_init(struct nouveau_drm *drm)
 {
-	switch (drm->ttm.copy.oclass) {
+	switch (drm->ttm.copy.object.oclass) {
 	case PASCAL_DMA_COPY_A:
 	case PASCAL_DMA_COPY_B:
 	case  VOLTA_DMA_COPY_A:
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 28347aa056b8..ae6b992c32f9 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -257,7 +257,7 @@ static void
 nouveau_accel_ce_fini(struct nouveau_drm *drm)
 {
 	nouveau_channel_idle(drm->cechan);
-	nvif_object_dtor(&drm->ttm.copy);
+	nvif_engobj_dtor(&drm->ttm.copy);
 	nouveau_channel_del(&drm->cechan);
 }
 
@@ -315,15 +315,13 @@ nouveau_accel_gr_init(struct nouveau_drm *drm)
 	 * synchronisation of page flips, as well as to implement fences
 	 * on TNT/TNT2 HW that lacks any kind of support in host.
 	 */
-	if (!drm->channel->nvsw.client && device->info.family < NV_DEVICE_INFO_V0_TESLA) {
-		ret = nvif_object_ctor(&drm->channel->chan.object, "drmNvsw",
-				       NVDRM_NVSW, nouveau_abi16_swclass(drm),
-				       NULL, 0, &drm->channel->nvsw);
+	if (device->info.family < NV_DEVICE_INFO_V0_TESLA) {
+		ret = nvif_engobj_ctor(&drm->channel->chan, "drmNvSw", NVDRM_NVSW,
+				       nouveau_abi16_swclass(drm), &drm->channel->nvsw);
 
 		if (ret == 0 && device->info.chipset >= 0x11) {
-			ret = nvif_object_ctor(&drm->channel->chan.object, "drmBlit",
-					       0x005f, 0x009f,
-					       NULL, 0, &drm->channel->blit);
+			ret = nvif_engobj_ctor(&drm->channel->chan, "drmBlit", 0x005f, 0x009f,
+					       &drm->channel->blit);
 		}
 
 		if (ret == 0) {
@@ -332,12 +330,12 @@ nouveau_accel_gr_init(struct nouveau_drm *drm)
 			ret = PUSH_WAIT(push, 8);
 			if (ret == 0) {
 				if (device->info.chipset >= 0x11) {
-					PUSH_NVSQ(push, NV05F, 0x0000, drm->channel->blit.handle);
+					PUSH_NVSQ(push, NV05F, 0x0000, 0x005f);
 					PUSH_NVSQ(push, NV09F, 0x0120, 0,
 							       0x0124, 1,
 							       0x0128, 2);
 				}
-				PUSH_NVSQ(push, NV_SW, 0x0000, drm->channel->nvsw.handle);
+				PUSH_NVSQ(push, NV_SW, 0x0000, drm->channel->nvsw.object.handle);
 			}
 		}
 
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h
index 3d661148943c..e40416c884a8 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.h
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.h
@@ -40,6 +40,7 @@
 
 #include <linux/notifier.h>
 
+#include <nvif/chan.h>
 #include <nvif/client.h>
 #include <nvif/ctxdma.h>
 #include <nvif/device.h>
@@ -237,7 +238,7 @@ struct nouveau_drm {
 			    struct ttm_buffer_object *,
 			    struct ttm_resource *, struct ttm_resource *);
 		struct nouveau_channel *chan;
-		struct nvif_object copy;
+		struct nvif_engobj copy;
 		int mtrr;
 		int type_vram;
 		int type_host[2];
diff --git a/drivers/gpu/drm/nouveau/nv04_fence.c b/drivers/gpu/drm/nouveau/nv04_fence.c
index fa5c6029f783..802a051428e2 100644
--- a/drivers/gpu/drm/nouveau/nv04_fence.c
+++ b/drivers/gpu/drm/nouveau/nv04_fence.c
@@ -59,7 +59,7 @@ static u32
 nv04_fence_read(struct nouveau_channel *chan)
 {
 	struct nv04_nvsw_get_ref_v0 args = {};
-	WARN_ON(nvif_object_mthd(&chan->nvsw, NV04_NVSW_GET_REF,
+	WARN_ON(nvif_object_mthd(&chan->nvsw.object, NV04_NVSW_GET_REF,
 				 &args, sizeof(args)));
 	return args.ref;
 }
diff --git a/drivers/gpu/drm/nouveau/nvif/chan.c b/drivers/gpu/drm/nouveau/nvif/chan.c
index 78f380ef01b7..ff4485ed0e89 100644
--- a/drivers/gpu/drm/nouveau/nvif/chan.c
+++ b/drivers/gpu/drm/nouveau/nvif/chan.c
@@ -24,6 +24,57 @@
 #include <nvif/ctxdma.h>
 #include <nvif/device.h>
 
+void
+nvif_engobj_dtor(struct nvif_engobj *engobj)
+{
+	if (!engobj->impl)
+		return;
+
+	engobj->impl->del(engobj->priv);
+	engobj->impl = NULL;
+}
+
+int
+nvif_engobj_ctor(struct nvif_chan *chan, const char *name, u32 handle, s32 oclass,
+		 struct nvif_engobj *engobj)
+{
+	const struct nvif_device_impl_fifo *fifo = &chan->device->impl->fifo;
+	const struct nvif_device_impl_runl *runl = &fifo->runl[chan->runl];
+	int ret = -ENODEV, engi;
+
+	for (engi = 0; engi < runl->engn_nr; engi++) {
+		int engine = runl->engn[engi].engine;
+		int runq = 0;
+
+		for (int i = 0; i < fifo->engine[engine].oclass_nr; i++) {
+			if (fifo->engine[engine].oclass[i] == oclass) {
+				if (fifo->engine[engine].type == NVIF_ENGINE_CE) {
+					if (chan->runq != runq++)
+						continue;
+				}
+
+				ret = 0;
+				break;
+			}
+		}
+
+		if (ret == 0)
+			break;
+	}
+
+	if (ret)
+		return ret;
+
+	ret = chan->impl->engobj.new(chan->priv, handle, engi, oclass, &engobj->impl,
+				     &engobj->priv, nvif_handle(&engobj->object));
+	NVIF_ERRON(ret, &chan->object, "[NEW engobj handle:%08x oclass:%08x]", handle, oclass);
+	if (ret)
+		return ret;
+
+	nvif_object_ctor(&chan->object, name ?: "nvifEngObj", handle, oclass, &engobj->object);
+	return 0;
+}
+
 int
 nvif_chan_ctxdma_ctor(struct nvif_chan *chan, const char *name, u32 handle, s32 oclass,
 		      void *argv, u32 argc, struct nvif_ctxdma *ctxdma)
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/uchan.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/uchan.c
index f6dfba41da8c..6e5a0d980446 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/uchan.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/uchan.c
@@ -46,6 +46,21 @@ struct nvkm_uobj {
 	int hash;
 };
 
+static void
+nvkm_uchan_object_del(struct nvif_engobj_priv *priv)
+{
+	struct nvkm_uobj *uobj = (void *)priv;
+	struct nvkm_object *object = &uobj->oproxy.base;
+
+	nvkm_object_fini(object, false);
+	nvkm_object_del(&object);
+}
+
+static const struct nvif_engobj_impl
+nvkm_uchan_object_impl = {
+	.del = nvkm_uchan_object_del,
+};
+
 static int
 nvkm_uchan_object_fini_1(struct nvkm_oproxy *oproxy, bool suspend)
 {
@@ -162,7 +177,7 @@ nvkm_uchan_object_new(const struct nvkm_oclass *oclass, void *argv, u32 argc,
 					.client = oclass->client,
 					.parent = uobj->cctx->vctx->ectx->object ?: oclass->parent,
 					.engine = engn->engine,
-				 }, argv, argc, &uobj->oproxy.object);
+				 }, NULL, 0, &uobj->oproxy.object);
 	if (ret)
 		return ret;
 
@@ -176,54 +191,87 @@ 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)
+nvkm_uchan_engobj_new(struct nvif_chan_priv *uchan, u32 handle, u8 engi, s32 oclass,
+		      const struct nvif_engobj_impl **pimpl, struct nvif_engobj_priv **ppriv,
+		      u64 _handle)
 {
-	struct nvkm_chan *chan = container_of(object, struct nvif_chan_priv, object)->chan;
-	struct nvkm_engn *engn;
-	int ret, runq = 0;
+	struct nvkm_chan *chan = uchan->chan;
+	struct nvkm_runl *runl = chan->cgrp->runl;
+	struct nvkm_engn *engt, *engn = NULL;
+	struct nvkm_engine *engine;
+	struct nvkm_oclass _oclass = {};
+	struct nvkm_object *object = NULL;
+	int ret, i = 0;
 
-	nvkm_runl_foreach_engn(engn, chan->cgrp->runl) {
-		struct nvkm_engine *engine = engn->engine;
-		int c = 0;
+	nvkm_runl_foreach_engn(engt, runl) {
+		if (i++ == engi) {
+			engn = engt;
+			break;
+		}
+	}
+
+	if (!engn)
+		return -EINVAL;
 
-		/* Each runqueue, on runlists with multiple, has its own LCE. */
-		if (engn->runl->func->runqs) {
-			if (engine->subdev.type == NVKM_ENGINE_CE) {
-				if (chan->runq != runq++)
-					continue;
+	engine = engn->engine;
+
+	_oclass.handle = handle;
+	_oclass.client = uchan->object.client;
+	_oclass.parent = &uchan->object;
+	_oclass.engine = engine;
+
+	if (engine->func->fifo.sclass) {
+		i = 0;
+		do {
+			_oclass.base.oclass = 0;
+			engine->func->fifo.sclass(&_oclass, i++);
+			if (_oclass.base.oclass == oclass)
+				break;
+		} while (_oclass.base.oclass);
+	} else {
+		for (i = 0; engine->func->sclass[i].oclass; i++) {
+			if (engine->func->sclass[i].oclass == oclass) {
+				_oclass.base = engine->func->sclass[i];
+				break;
 			}
 		}
+	}
 
-		oclass->engine = engine;
-		oclass->base.oclass = 0;
+	if (!_oclass.base.oclass)
+		return -EINVAL;
 
-		if (engine->func->fifo.sclass) {
-			ret = engine->func->fifo.sclass(oclass, index);
-			if (oclass->base.oclass) {
-				if (!oclass->base.ctor)
-					oclass->base.ctor = nvkm_object_new;
-				oclass->ctor = nvkm_uchan_object_new;
-				return 0;
-			}
+	if (!_oclass.base.ctor)
+		_oclass.base.ctor = nvkm_object_new;
 
-			index -= ret;
-			continue;
-		}
+	if (engine) {
+		_oclass.engine = nvkm_engine_ref(engine);
+		if (IS_ERR(_oclass.engine))
+			return PTR_ERR(_oclass.engine);
+	}
 
-		while (engine->func->sclass[c].oclass) {
-			if (c++ == index) {
-				oclass->base = engine->func->sclass[index];
-				if (!oclass->base.ctor)
-					oclass->base.ctor = nvkm_object_new;
-				oclass->ctor = nvkm_uchan_object_new;
-				return 0;
-			}
-		}
+	ret = nvkm_uchan_object_new(&_oclass, NULL, 0, &object);
+	nvkm_engine_unref(&_oclass.engine);
+	if (ret)
+		goto done;
 
-		index -= c;
+	ret = nvkm_object_init(object);
+	if (ret) {
+		nvkm_object_fini(object, false);
+		goto done;
 	}
 
-	return -EINVAL;
+	*pimpl = &nvkm_uchan_object_impl;
+	*ppriv = (void *)container_of(object, struct nvkm_uobj, oproxy.base);
+
+	ret = nvkm_object_link_rb(uchan->object.client, &uchan->object, _handle, object);
+	if (ret)
+		nvkm_object_fini(object, false);
+
+done:
+	if (ret)
+		nvkm_object_del(&object);
+
+	return ret;
 }
 
 static void
@@ -310,6 +358,7 @@ nvkm_uchan_impl = {
 	.del = nvkm_uchan_del,
 	.event.killed = nvkm_uchan_event_killed,
 	.ctxdma.new = nvkm_uchan_ctxdma_new,
+	.engobj.new = nvkm_uchan_engobj_new,
 };
 
 static int
@@ -356,7 +405,6 @@ nvkm_uchan = {
 	.dtor = nvkm_uchan_dtor,
 	.init = nvkm_uchan_init,
 	.fini = nvkm_uchan_fini,
-	.sclass = nvkm_uchan_sclass,
 };
 
 struct nvkm_chan *
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 146/156] drm/nouveau/nvif: remove chan from object rb
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (144 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 145/156] drm/nouveau/nvif: rework chan "new engobj" apis Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 147/156] drm/nouveau/nvif: rework engobj "mthd" api Ben Skeggs
                   ` (11 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- no more users

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/include/nvif/driverif.h | 3 +--
 drivers/gpu/drm/nouveau/nouveau_chan.c          | 3 +--
 drivers/gpu/drm/nouveau/nvkm/device/user.c      | 5 +++--
 3 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 69428a879c37..b25c91542e66 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -618,8 +618,7 @@ struct nvif_device_impl {
 				   struct nvif_vmm_priv *, struct nvif_ctxdma_priv *push,
 				   u64 offset, u64 length, struct nvif_mem_priv *userd,
 				   u16 userd_offset, const char *name,
-				   const struct nvif_chan_impl **, struct nvif_chan_priv **,
-				   u64 handle);
+				   const struct nvif_chan_impl **, struct nvif_chan_priv **);
 		} chan;
 	} fifo;
 };
diff --git a/drivers/gpu/drm/nouveau/nouveau_chan.c b/drivers/gpu/drm/nouveau/nouveau_chan.c
index 80099dfcd3d5..54816bcca14c 100644
--- a/drivers/gpu/drm/nouveau/nouveau_chan.c
+++ b/drivers/gpu/drm/nouveau/nouveau_chan.c
@@ -333,8 +333,7 @@ nouveau_channel_ctor(struct nouveau_cli *cli, bool priv, u64 runm,
 	ret = device->impl->fifo.chan.new(device->priv, device->impl->fifo.runl[chan->runlist].id,
 					  0, priv, BIT(0), vmm, ctxdma, offset, length,
 					  userd, userd_offset, chan->name,
-					  &chan->chan.impl, &chan->chan.priv,
-					  nvif_handle(&chan->chan.object));
+					  &chan->chan.impl, &chan->chan.priv);
 	if (ret) {
 		nouveau_channel_del(pchan);
 		return ret;
diff --git a/drivers/gpu/drm/nouveau/nvkm/device/user.c b/drivers/gpu/drm/nouveau/nvkm/device/user.c
index efa675c8098f..d7b41b990d56 100644
--- a/drivers/gpu/drm/nouveau/nvkm/device/user.c
+++ b/drivers/gpu/drm/nouveau/nvkm/device/user.c
@@ -102,7 +102,7 @@ nvkm_udevice_chan_new(struct nvif_device_priv *udev, u8 runl, u8 runq, bool priv
 		      struct nvif_vmm_priv *uvmm, struct nvif_ctxdma_priv *push,
 		      u64 offset, u64 length, struct nvif_mem_priv *userd, u16 userd_offset,
 		      const char *name, const struct nvif_chan_impl **pimpl,
-		      struct nvif_chan_priv **ppriv, u64 handle)
+		      struct nvif_chan_priv **ppriv)
 {
 	struct nvkm_vmm *vmm = nvkm_uvmm_ref(uvmm);
 	struct nvkm_object *object;
@@ -115,7 +115,8 @@ nvkm_udevice_chan_new(struct nvif_device_priv *udev, u8 runl, u8 runq, bool priv
 	if (ret)
 		return ret;
 
-	return nvkm_object_link_rb(udev->object.client, &udev->object, handle, object);
+	nvkm_object_link(&udev->object, object);
+	return 0;
 }
 
 static int
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 147/156] drm/nouveau/nvif: rework engobj "mthd" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (145 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 146/156] drm/nouveau/nvif: remove chan from object rb Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 148/156] drm/nouveau/nvif: rework engobj "new event" api Ben Skeggs
                   ` (10 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interface

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/include/nvif/driverif.h  | 1 +
 drivers/gpu/drm/nouveau/nv04_fence.c             | 7 +++++--
 drivers/gpu/drm/nouveau/nvkm/engine/fifo/uchan.c | 9 +++++++++
 drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.c   | 1 -
 4 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index b25c91542e66..d8a30af9eae7 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -434,6 +434,7 @@ struct nvif_disp_impl {
 
 struct nvif_engobj_impl {
 	void (*del)(struct nvif_engobj_priv *);
+	int (*mthd)(struct nvif_engobj_priv *, u32 mthd, void *argv, u32 argc);
 };
 
 struct nvif_chan_impl {
diff --git a/drivers/gpu/drm/nouveau/nv04_fence.c b/drivers/gpu/drm/nouveau/nv04_fence.c
index 802a051428e2..45398b3a825e 100644
--- a/drivers/gpu/drm/nouveau/nv04_fence.c
+++ b/drivers/gpu/drm/nouveau/nv04_fence.c
@@ -59,8 +59,11 @@ static u32
 nv04_fence_read(struct nouveau_channel *chan)
 {
 	struct nv04_nvsw_get_ref_v0 args = {};
-	WARN_ON(nvif_object_mthd(&chan->nvsw.object, NV04_NVSW_GET_REF,
-				 &args, sizeof(args)));
+	int ret;
+
+	ret = chan->nvsw.impl->mthd(chan->nvsw.priv, NV04_NVSW_GET_REF, &args, sizeof(args));
+	WARN_ON(ret);
+
 	return args.ref;
 }
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/uchan.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/uchan.c
index 6e5a0d980446..6682245e4928 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/uchan.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/uchan.c
@@ -46,6 +46,14 @@ struct nvkm_uobj {
 	int hash;
 };
 
+static int
+nvkm_uchan_object_mthd(struct nvif_engobj_priv *priv, u32 mthd, void *argv, u32 argc)
+{
+	struct nvkm_uobj *uobj = (void *)priv;
+
+	return nvkm_object_mthd(&uobj->oproxy.base, mthd, argv, argc);
+}
+
 static void
 nvkm_uchan_object_del(struct nvif_engobj_priv *priv)
 {
@@ -59,6 +67,7 @@ nvkm_uchan_object_del(struct nvif_engobj_priv *priv)
 static const struct nvif_engobj_impl
 nvkm_uchan_object_impl = {
 	.del = nvkm_uchan_object_del,
+	.mthd = nvkm_uchan_object_mthd,
 };
 
 static int
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.c b/drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.c
index 986e8d547c94..8ecc53ff6487 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.c
@@ -230,7 +230,6 @@ gf100_fermi_mthd_zbc_depth(struct nvkm_object *object, void *data, u32 size)
 static int
 gf100_fermi_mthd(struct nvkm_object *object, u32 mthd, void *data, u32 size)
 {
-	nvif_ioctl(object, "fermi mthd %08x\n", mthd);
 	switch (mthd) {
 	case FERMI_A_ZBC_COLOR:
 		return gf100_fermi_mthd_zbc_color(object, data, size);
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 148/156] drm/nouveau/nvif: rework engobj "new event" api
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (146 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 147/156] drm/nouveau/nvif: rework engobj "mthd" api Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 149/156] drm/nouveau/nvif: remove engobj from object rb Ben Skeggs
                   ` (9 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- transition from "ioctl" interface

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/dispnv04/disp.c       |  8 ++-
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  5 ++
 drivers/gpu/drm/nouveau/include/nvif/event.h  | 21 +------
 drivers/gpu/drm/nouveau/include/nvif/if000e.h | 26 --------
 drivers/gpu/drm/nouveau/include/nvif/object.h |  3 -
 .../gpu/drm/nouveau/include/nvkm/core/event.h |  1 -
 .../drm/nouveau/include/nvkm/core/object.h    |  6 +-
 .../gpu/drm/nouveau/include/nvkm/core/os.h    |  1 -
 drivers/gpu/drm/nouveau/nvif/event.c          | 46 +-------------
 drivers/gpu/drm/nouveau/nvif/object.c         | 29 ---------
 drivers/gpu/drm/nouveau/nvkm/core/ioctl.c     | 32 +---------
 drivers/gpu/drm/nouveau/nvkm/core/oproxy.c    | 13 ----
 drivers/gpu/drm/nouveau/nvkm/core/uevent.c    | 62 -------------------
 .../gpu/drm/nouveau/nvkm/engine/fifo/uchan.c  | 13 ++++
 drivers/gpu/drm/nouveau/nvkm/engine/sw/nvsw.c | 14 ++---
 15 files changed, 36 insertions(+), 244 deletions(-)
 delete mode 100644 drivers/gpu/drm/nouveau/include/nvif/if000e.h

diff --git a/drivers/gpu/drm/nouveau/dispnv04/disp.c b/drivers/gpu/drm/nouveau/dispnv04/disp.c
index 3e10ba2ed20f..3d564512b0f6 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/disp.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/disp.c
@@ -236,10 +236,14 @@ nv04_display_create(struct drm_device *dev)
 
 	/* Request page flip completion event. */
 	if (drm->channel) {
-		ret = nvif_event_ctor(&drm->channel->nvsw.object, "kmsFlip", 0, nv04_flip_complete,
-				      true, NULL, 0, &disp->flip);
+		ret = drm->channel->nvsw.impl->event.new(drm->channel->nvsw.priv,
+							 nvif_handle(&disp->flip.object),
+							 &disp->flip.impl, &disp->flip.priv);
 		if (ret)
 			return ret;
+
+		nvif_event_ctor(&drm->channel->nvsw.object, "kmsFlip", 0, nv04_flip_complete,
+				&disp->flip);
 	}
 
 	nouveau_hw_save_vga_fonts(dev, 1);
diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index d8a30af9eae7..244024c19206 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -435,6 +435,11 @@ struct nvif_disp_impl {
 struct nvif_engobj_impl {
 	void (*del)(struct nvif_engobj_priv *);
 	int (*mthd)(struct nvif_engobj_priv *, u32 mthd, void *argv, u32 argc);
+
+	struct {
+		int (*new)(struct nvif_engobj_priv *, u64 token,
+			   const struct nvif_event_impl **, struct nvif_event_priv **);
+	} event;
 };
 
 struct nvif_chan_impl {
diff --git a/drivers/gpu/drm/nouveau/include/nvif/event.h b/drivers/gpu/drm/nouveau/include/nvif/event.h
index 338082bdc67c..42c2d0b5f66b 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/event.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/event.h
@@ -2,7 +2,6 @@
 #ifndef __NVIF_EVENT_H__
 #define __NVIF_EVENT_H__
 #include <nvif/object.h>
-#include <nvif/if000e.h>
 struct nvif_event;
 
 #define NVIF_EVENT_KEEP 0
@@ -23,30 +22,14 @@ nvif_event_constructed(struct nvif_event *event)
 	return nvif_object_constructed(&event->object);
 }
 
-int nvif_event_ctor_(struct nvif_object *, const char *, u32, nvif_event_func, bool,
-		     struct nvif_event_v0 *, u32, bool, struct nvif_event *);
-
-static inline int
-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_event_ctor(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 *);
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if000e.h b/drivers/gpu/drm/nouveau/include/nvif/if000e.h
deleted file mode 100644
index 90a936cb1766..000000000000
--- a/drivers/gpu/drm/nouveau/include/nvif/if000e.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/* SPDX-License-Identifier: MIT */
-#ifndef __NVIF_IF000E_H__
-#define __NVIF_IF000E_H__
-
-union nvif_event_args {
-	struct nvif_event_v0 {
-		__u8 version;
-		__u8 wait;
-		__u8 pad02[6];
-		__u8 data[];
-	} v0;
-};
-
-#define NVIF_EVENT_V0_ALLOW 0x00
-#define NVIF_EVENT_V0_BLOCK 0x01
-
-union nvif_event_allow_args {
-	struct nvif_event_allow_vn {
-	} vn;
-};
-
-union nvif_event_block_args {
-	struct nvif_event_block_vn {
-	} vn;
-};
-#endif
diff --git a/drivers/gpu/drm/nouveau/include/nvif/object.h b/drivers/gpu/drm/nouveau/include/nvif/object.h
index 56308333ef86..98a8bba8f0ee 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/object.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/object.h
@@ -40,7 +40,6 @@ void nvif_object_ctor_1(struct nvif_object *parent, const char *name, u32 handle
 
 void nvif_object_dtor(struct nvif_object *);
 int  nvif_object_ioctl(struct nvif_object *, void *, u32, void **);
-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 *);
 
@@ -67,8 +66,6 @@ int nvif_object_unmap_cpu(struct nvif_map *);
 	_data;                                                                 \
 })
 
-#define nvif_mthd(a,b,c,d) nvif_object_mthd((a), (b), (c), (d))
-
 #define NVIF_RD32_(p,o,dr)   nvif_rd32((p), (o) + (dr))
 #define NVIF_WR32_(p,o,dr,f) nvif_wr32((p), (o) + (dr), (f))
 #define NVIF_RD32(p,A...) DRF_RD(NVIF_RD32_,                  (p), 0, ##A)
diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/event.h b/drivers/gpu/drm/nouveau/include/nvkm/core/event.h
index f31f0f30732a..76e05c8da979 100644
--- a/drivers/gpu/drm/nouveau/include/nvkm/core/event.h
+++ b/drivers/gpu/drm/nouveau/include/nvkm/core/event.h
@@ -76,7 +76,6 @@ struct nvif_event_priv;
 int nvkm_uevent_new_(struct nvkm_object *parent, u64 handle, struct nvkm_event *event,
 		     bool wait, int id, u32 bits, nvkm_uevent_func,
 		     const struct nvif_event_impl **, struct nvif_event_priv **);
-int nvkm_uevent_new(const struct nvkm_oclass *, void *argv, u32 argc, struct nvkm_object **);
 int nvkm_uevent_add(struct nvif_event_priv *, struct nvkm_event *, int id, u32 bits,
 		    nvkm_uevent_func);
 #endif
diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/object.h b/drivers/gpu/drm/nouveau/include/nvkm/core/object.h
index 69972b0836e4..de8bf1cc95d8 100644
--- a/drivers/gpu/drm/nouveau/include/nvkm/core/object.h
+++ b/drivers/gpu/drm/nouveau/include/nvkm/core/object.h
@@ -4,7 +4,8 @@
 #include <core/oclass.h>
 struct nvkm_event;
 struct nvkm_gpuobj;
-struct nvkm_uevent;
+struct nvif_event_impl;
+struct nvif_event_priv;
 
 struct nvkm_object {
 	const struct nvkm_object_func *func;
@@ -28,7 +29,8 @@ struct nvkm_object_func {
 	int (*bind)(struct nvkm_object *, struct nvkm_gpuobj *, int align,
 		    struct nvkm_gpuobj **);
 	int (*sclass)(struct nvkm_object *, int index, struct nvkm_oclass *);
-	int (*uevent)(struct nvkm_object *, void *argv, u32 argc, struct nvkm_uevent *);
+	int (*uevent)(struct nvkm_object *, u64 token,
+		      const struct nvif_event_impl **, struct nvif_event_priv **);
 };
 
 void nvkm_object_ctor(const struct nvkm_object_func *,
diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/os.h b/drivers/gpu/drm/nouveau/include/nvkm/core/os.h
index 9d16413239d4..056f182d9b0b 100644
--- a/drivers/gpu/drm/nouveau/include/nvkm/core/os.h
+++ b/drivers/gpu/drm/nouveau/include/nvkm/core/os.h
@@ -31,6 +31,5 @@ nvkm_blob_dtor(struct nvkm_blob *blob)
 #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
 #define nvkm_client nvif_client_priv
 #endif
diff --git a/drivers/gpu/drm/nouveau/nvif/event.c b/drivers/gpu/drm/nouveau/nvif/event.c
index 5b8ec641703b..2974ec8e13af 100644
--- a/drivers/gpu/drm/nouveau/nvif/event.c
+++ b/drivers/gpu/drm/nouveau/nvif/event.c
@@ -23,20 +23,11 @@
 #include <nvif/driverif.h>
 #include <nvif/printf.h>
 
-#include <nvif/class.h>
-#include <nvif/if000e.h>
-
 int
 nvif_event_block(struct nvif_event *event)
 {
 	int ret;
 
-	if (!event->impl && nvif_event_constructed(event)) {
-		int ret = nvif_mthd(&event->object, NVIF_EVENT_V0_BLOCK, NULL, 0);
-		NVIF_ERRON(ret, &event->object, "[BLOCK]");
-		return ret;
-	}
-
 	if (!event->impl)
 		return 0;
 
@@ -50,12 +41,6 @@ nvif_event_allow(struct nvif_event *event)
 {
 	int ret;
 
-	if (!event->impl && nvif_event_constructed(event)) {
-		int ret = nvif_mthd(&event->object, NVIF_EVENT_V0_ALLOW, NULL, 0);
-		NVIF_ERRON(ret, &event->object, "[ALLOW]");
-		return ret;
-	}
-
 	if (!event->impl)
 		return 0;
 
@@ -67,38 +52,9 @@ nvif_event_allow(struct nvif_event *event)
 void
 nvif_event_dtor(struct nvif_event *event)
 {
-	if (!event->impl) {
-		nvif_object_dtor(&event->object);
+	if (!event->impl)
 		return;
-	}
 
 	event->impl->del(event->priv);
 	event->impl = NULL;
 }
-
-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, bool warn,
-		 struct nvif_event *event)
-{
-	struct nvif_event_v0 _args;
-	int ret;
-
-	if (!args) {
-		args = &_args;
-		argc = sizeof(_args);
-	}
-
-	args->version = 0;
-	args->wait = wait;
-
-	ret = nvif_object_ctor(parent, name ?: "nvifEvent", handle,
-			       NVIF_CLASS_EVENT, args, argc, &event->object);
-	NVIF_ERRON(ret && warn, parent, "[NEW EVENT wait:%d size:%zd]",
-		   args->wait, argc - sizeof(*args));
-	if (ret)
-		return ret;
-
-	event->func = func;
-	return 0;
-}
diff --git a/drivers/gpu/drm/nouveau/nvif/object.c b/drivers/gpu/drm/nouveau/nvif/object.c
index 9887241c5200..3379580463e6 100644
--- a/drivers/gpu/drm/nouveau/nvif/object.c
+++ b/drivers/gpu/drm/nouveau/nvif/object.c
@@ -46,35 +46,6 @@ nvif_object_ioctl(struct nvif_object *object, void *data, u32 size, void **hack)
 	return client->driver->ioctl(client->object.priv, data, size, hack);
 }
 
-int
-nvif_object_mthd(struct nvif_object *object, u32 mthd, void *data, u32 size)
-{
-	struct {
-		struct nvif_ioctl_v0 ioctl;
-		struct nvif_ioctl_mthd_v0 mthd;
-	} *args;
-	u8 stack[128];
-	int ret;
-
-	if (sizeof(*args) + size > sizeof(stack)) {
-		if (!(args = kmalloc(sizeof(*args) + size, GFP_KERNEL)))
-			return -ENOMEM;
-	} else {
-		args = (void *)stack;
-	}
-	args->ioctl.version = 0;
-	args->ioctl.type = NVIF_IOCTL_V0_MTHD;
-	args->mthd.version = 0;
-	args->mthd.method = mthd;
-
-	memcpy(args->mthd.data, data, size);
-	ret = nvif_object_ioctl(object, args, sizeof(*args) + size, NULL);
-	memcpy(data, args->mthd.data, size);
-	if (args != (void *)stack)
-		kfree(args);
-	return ret;
-}
-
 int
 nvif_object_unmap_cpu(struct nvif_map *map)
 {
diff --git a/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c b/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c
index b34ed158aa63..50e9a6d51c05 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c
@@ -24,7 +24,6 @@
 #include <core/ioctl.h>
 #include <core/client.h>
 #include <core/engine.h>
-#include <core/event.h>
 
 #include <nvif/unpack.h>
 #include <nvif/ioctl.h>
@@ -41,15 +40,6 @@ nvkm_ioctl_nop(struct nvkm_client *client,
 static int
 nvkm_ioctl_sclass_(struct nvkm_object *object, int index, struct nvkm_oclass *oclass)
 {
-	if ( object->func->uevent &&
-	    !object->func->uevent(object, NULL, 0, NULL) && index-- == 0) {
-		oclass->ctor = nvkm_uevent_new;
-		oclass->base.minver = 0;
-		oclass->base.maxver = 0;
-		oclass->base.oclass = NVIF_CLASS_EVENT;
-		return 0;
-	}
-
 	if (object->func->sclass)
 		return object->func->sclass(object, index, oclass);
 
@@ -82,7 +72,7 @@ nvkm_ioctl_new(struct nvkm_client *client,
 	} else
 		return ret;
 
-	if (!parent->func->sclass && !parent->func->uevent) {
+	if (!parent->func->sclass) {
 		nvif_ioctl(parent, "cannot have children\n");
 		return -EINVAL;
 	}
@@ -142,25 +132,6 @@ nvkm_ioctl_del(struct nvkm_client *client,
 	return ret ? ret : 1;
 }
 
-static int
-nvkm_ioctl_mthd(struct nvkm_client *client,
-		struct nvkm_object *object, void *data, u32 size)
-{
-	union {
-		struct nvif_ioctl_mthd_v0 v0;
-	} *args = data;
-	int ret = -ENOSYS;
-
-	nvif_ioctl(object, "mthd size %d\n", size);
-	if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) {
-		nvif_ioctl(object, "mthd vers %d mthd %02x\n",
-			   args->v0.version, args->v0.method);
-		ret = nvkm_object_mthd(object, args->v0.method, data, size);
-	}
-
-	return ret;
-}
-
 static struct {
 	int version;
 	int (*func)(struct nvkm_client *, struct nvkm_object *, void *, u32);
@@ -170,7 +141,6 @@ nvkm_ioctl_v0[] = {
 	{ 0x00, nvkm_ioctl_sclass },
 	{ 0x00, nvkm_ioctl_new },
 	{ 0x00, nvkm_ioctl_del },
-	{ 0x00, nvkm_ioctl_mthd },
 };
 
 static int
diff --git a/drivers/gpu/drm/nouveau/nvkm/core/oproxy.c b/drivers/gpu/drm/nouveau/nvkm/core/oproxy.c
index 690131104d7b..890532836c03 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/oproxy.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/oproxy.c
@@ -55,18 +55,6 @@ nvkm_oproxy_sclass(struct nvkm_object *object, int index,
 	return oproxy->object->func->sclass(oproxy->object, index, oclass);
 }
 
-static int
-nvkm_oproxy_uevent(struct nvkm_object *object, void *argv, u32 argc,
-		   struct nvkm_uevent *uevent)
-{
-	struct nvkm_oproxy *oproxy = nvkm_oproxy(object);
-
-	if (!oproxy->object->func->uevent)
-		return -ENOSYS;
-
-	return oproxy->object->func->uevent(oproxy->object, argv, argc, uevent);
-}
-
 static int
 nvkm_oproxy_fini(struct nvkm_object *object, bool suspend)
 {
@@ -142,7 +130,6 @@ nvkm_oproxy_func = {
 	.ntfy = nvkm_oproxy_ntfy,
 	.bind = nvkm_oproxy_bind,
 	.sclass = nvkm_oproxy_sclass,
-	.uevent = nvkm_oproxy_uevent,
 };
 
 void
diff --git a/drivers/gpu/drm/nouveau/nvkm/core/uevent.c b/drivers/gpu/drm/nouveau/nvkm/core/uevent.c
index d922eebb689c..365e41134f3d 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/uevent.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/uevent.c
@@ -23,7 +23,6 @@
 #include <core/client.h>
 
 #include <nvif/driverif.h>
-#include <nvif/if000e.h>
 
 struct nvif_event_priv {
 	struct nvkm_object object;
@@ -35,43 +34,6 @@ struct nvif_event_priv {
 	atomic_t allowed;
 };
 
-static int
-nvkm_uevent_mthd_block(struct nvkm_uevent *uevent, union nvif_event_block_args *args, u32 argc)
-{
-	if (argc != sizeof(args->vn))
-		return -ENOSYS;
-
-	nvkm_event_ntfy_block(&uevent->ntfy);
-	atomic_set(&uevent->allowed, 0);
-	return 0;
-}
-
-static int
-nvkm_uevent_mthd_allow(struct nvkm_uevent *uevent, union nvif_event_allow_args *args, u32 argc)
-{
-	if (argc != sizeof(args->vn))
-		return -ENOSYS;
-
-	nvkm_event_ntfy_allow(&uevent->ntfy);
-	atomic_set(&uevent->allowed, 1);
-	return 0;
-}
-
-static int
-nvkm_uevent_mthd(struct nvkm_object *object, u32 mthd, void *argv, u32 argc)
-{
-	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);
-	case NVIF_EVENT_V0_BLOCK: return nvkm_uevent_mthd_block(uevent, argv, argc);
-	default:
-		break;
-	}
-
-	return -EINVAL;
-}
-
 static int
 nvkm_uevent_block(struct nvif_event_priv *uevent)
 {
@@ -138,7 +100,6 @@ nvkm_uevent = {
 	.dtor = nvkm_uevent_dtor,
 	.init = nvkm_uevent_init,
 	.fini = nvkm_uevent_fini,
-	.mthd = nvkm_uevent_mthd,
 };
 
 static int
@@ -165,29 +126,6 @@ nvkm_uevent_add(struct nvif_event_priv *uevent, struct nvkm_event *event, int id
 	return 0;
 }
 
-int
-nvkm_uevent_new(const struct nvkm_oclass *oclass, void *argv, u32 argc,
-		struct nvkm_object **pobject)
-{
-	struct nvkm_object *parent = oclass->parent;
-	struct nvif_event_priv *uevent;
-	union nvif_event_args *args = argv;
-
-	if (argc < sizeof(args->v0) || args->v0.version != 0)
-		return -ENOSYS;
-
-	if (!(uevent = kzalloc(sizeof(*uevent), GFP_KERNEL)))
-		return -ENOMEM;
-	*pobject = &uevent->object;
-
-	nvkm_object_ctor(&nvkm_uevent, oclass, &uevent->object);
-	uevent->parent = parent;
-	uevent->func = NULL;
-	uevent->wait = args->v0.wait;
-	uevent->ntfy.event = NULL;
-	return parent->func->uevent(parent, &args->v0.data, argc - sizeof(args->v0), uevent);
-}
-
 int
 nvkm_uevent_new_(struct nvkm_object *parent, u64 handle, struct nvkm_event *event,
 		 bool wait, int id, u32 bits, nvkm_uevent_func func,
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/uchan.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/uchan.c
index 6682245e4928..281994235c5f 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/uchan.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/uchan.c
@@ -46,6 +46,18 @@ struct nvkm_uobj {
 	int hash;
 };
 
+static int
+nvkm_uchan_object_event_new(struct nvif_engobj_priv *priv, u64 token,
+			    const struct nvif_event_impl **pimpl, struct nvif_event_priv **ppriv)
+{
+	struct nvkm_uobj *uobj = (void *)priv;
+
+	if (!uobj->oproxy.object->func->uevent)
+		return -ENODEV;
+
+	return uobj->oproxy.object->func->uevent(uobj->oproxy.object, token, pimpl, ppriv);
+}
+
 static int
 nvkm_uchan_object_mthd(struct nvif_engobj_priv *priv, u32 mthd, void *argv, u32 argc)
 {
@@ -68,6 +80,7 @@ static const struct nvif_engobj_impl
 nvkm_uchan_object_impl = {
 	.del = nvkm_uchan_object_del,
 	.mthd = nvkm_uchan_object_mthd,
+	.event.new = nvkm_uchan_object_event_new,
 };
 
 static int
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/sw/nvsw.c b/drivers/gpu/drm/nouveau/nvkm/engine/sw/nvsw.c
index f5affa1c8f34..6786882b5f7f 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/sw/nvsw.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/sw/nvsw.c
@@ -27,17 +27,11 @@
 #include <nvif/if0004.h>
 
 static int
-nvkm_nvsw_uevent(struct nvkm_object *object, void *argv, u32 argc, struct nvkm_uevent *uevent)
+nvkm_nvsw_uevent(struct nvkm_object *object, u64 token,
+		 const struct nvif_event_impl **pimpl, struct nvif_event_priv **ppriv)
 {
-	union nv04_nvsw_event_args *args = argv;
-
-	if (!uevent)
-		return 0;
-	if (argc != sizeof(args->vn))
-		return -ENOSYS;
-
-	return nvkm_uevent_add(uevent, &nvkm_nvsw(object)->chan->event, 0,
-			       NVKM_SW_CHAN_EVENT_PAGE_FLIP, NULL);
+	return nvkm_uevent_new_(object, token, &nvkm_nvsw(object)->chan->event, true, 0,
+				NVKM_SW_CHAN_EVENT_PAGE_FLIP, NULL, pimpl, ppriv);
 }
 
 static int
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 149/156] drm/nouveau/nvif: remove engobj from object rb
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (147 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 148/156] drm/nouveau/nvif: rework engobj "new event" api Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 150/156] drm/nouveau/nvkm: switch nvkm_object to non-irqsafe spinlock Ben Skeggs
                   ` (8 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- no more users

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |   4 +-
 drivers/gpu/drm/nouveau/include/nvif/object.h |  13 +-
 .../drm/nouveau/include/nvkm/core/client.h    |   1 -
 .../gpu/drm/nouveau/include/nvkm/core/ioctl.h |   8 -
 .../drm/nouveau/include/nvkm/core/object.h    |   8 -
 drivers/gpu/drm/nouveau/nvif/chan.c           |   2 +-
 drivers/gpu/drm/nouveau/nvif/client.c         |   1 -
 drivers/gpu/drm/nouveau/nvif/driver.c         |   1 -
 drivers/gpu/drm/nouveau/nvif/object.c         |  78 +------
 drivers/gpu/drm/nouveau/nvkm/core/Kbuild      |   1 -
 drivers/gpu/drm/nouveau/nvkm/core/driver.c    |   8 -
 drivers/gpu/drm/nouveau/nvkm/core/ioctl.c     | 196 ------------------
 drivers/gpu/drm/nouveau/nvkm/core/object.c    |  92 --------
 .../gpu/drm/nouveau/nvkm/engine/fifo/uchan.c  |   7 +-
 14 files changed, 8 insertions(+), 412 deletions(-)
 delete mode 100644 drivers/gpu/drm/nouveau/include/nvkm/core/ioctl.h
 delete mode 100644 drivers/gpu/drm/nouveau/nvkm/core/ioctl.c

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 244024c19206..04d488eb3ad5 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -27,7 +27,6 @@ struct nvif_driver {
 	const char *name;
 	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)(struct nvif_client_priv *, u64 handle, u32 size);
 	void (*unmap)(struct nvif_client_priv *, void __iomem *ptr, u32 size);
 };
@@ -474,8 +473,7 @@ struct nvif_chan_impl {
 
 	struct {
 		int (*new)(struct nvif_chan_priv *, u32 handle, u8 engi, s32 oclass,
-			   const struct nvif_engobj_impl **, struct nvif_engobj_priv **,
-			   u64 object);
+			   const struct nvif_engobj_impl **, struct nvif_engobj_priv **);
 	} engobj;
 };
 
diff --git a/drivers/gpu/drm/nouveau/include/nvif/object.h b/drivers/gpu/drm/nouveau/include/nvif/object.h
index 98a8bba8f0ee..94722ded1d68 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/object.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/object.h
@@ -28,18 +28,9 @@ nvif_object_constructed(struct nvif_object *object)
 	return object->client != NULL;
 }
 
-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_ctor(struct nvif_object *parent, const char *name, u32 handle, s32 oclass,
+		      struct nvif_object *);
 void nvif_object_dtor(struct nvif_object *);
-int  nvif_object_ioctl(struct nvif_object *, void *, u32, void **);
 int nvif_object_map_cpu(struct nvif_object *, const struct nvif_mapinfo *, struct nvif_map *);
 int nvif_object_unmap_cpu(struct nvif_map *);
 
diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/client.h b/drivers/gpu/drm/nouveau/include/nvkm/core/client.h
index e35aea7a751f..21d75783c258 100644
--- a/drivers/gpu/drm/nouveau/include/nvkm/core/client.h
+++ b/drivers/gpu/drm/nouveau/include/nvkm/core/client.h
@@ -36,5 +36,4 @@ extern const struct nvif_client_impl nvkm_client_impl;
 #define nvif_debug(o,f,a...) nvif_printk((o), DEBUG, INFO, f, ##a)
 #define nvif_trace(o,f,a...) nvif_printk((o), TRACE, INFO, f, ##a)
 #define nvif_info(o,f,a...)  nvif_printk((o),  INFO, INFO, f, ##a)
-#define nvif_ioctl(o,f,a...) nvif_trace((o), "ioctl: "f, ##a)
 #endif
diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/ioctl.h b/drivers/gpu/drm/nouveau/include/nvkm/core/ioctl.h
deleted file mode 100644
index f52918a43246..000000000000
--- a/drivers/gpu/drm/nouveau/include/nvkm/core/ioctl.h
+++ /dev/null
@@ -1,8 +0,0 @@
-/* SPDX-License-Identifier: MIT */
-#ifndef __NVKM_IOCTL_H__
-#define __NVKM_IOCTL_H__
-#include <core/os.h>
-struct nvkm_client;
-
-int nvkm_ioctl(struct nvkm_client *, void *, u32, void **);
-#endif
diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/object.h b/drivers/gpu/drm/nouveau/include/nvkm/core/object.h
index de8bf1cc95d8..18d56fd3de72 100644
--- a/drivers/gpu/drm/nouveau/include/nvkm/core/object.h
+++ b/drivers/gpu/drm/nouveau/include/nvkm/core/object.h
@@ -17,7 +17,6 @@ struct nvkm_object {
 	struct list_head head;
 	struct list_head tree;
 	u64 object;
-	struct rb_node node;
 };
 
 struct nvkm_object_func {
@@ -50,17 +49,10 @@ 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,
-				       const struct nvkm_object_func *);
 #endif
diff --git a/drivers/gpu/drm/nouveau/nvif/chan.c b/drivers/gpu/drm/nouveau/nvif/chan.c
index ff4485ed0e89..79c40bb2cbb6 100644
--- a/drivers/gpu/drm/nouveau/nvif/chan.c
+++ b/drivers/gpu/drm/nouveau/nvif/chan.c
@@ -66,7 +66,7 @@ nvif_engobj_ctor(struct nvif_chan *chan, const char *name, u32 handle, s32 oclas
 		return ret;
 
 	ret = chan->impl->engobj.new(chan->priv, handle, engi, oclass, &engobj->impl,
-				     &engobj->priv, nvif_handle(&engobj->object));
+				     &engobj->priv);
 	NVIF_ERRON(ret, &chan->object, "[NEW engobj handle:%08x oclass:%08x]", handle, oclass);
 	if (ret)
 		return ret;
diff --git a/drivers/gpu/drm/nouveau/nvif/client.c b/drivers/gpu/drm/nouveau/nvif/client.c
index 6b3c7b28b212..2a66b23c9d1d 100644
--- a/drivers/gpu/drm/nouveau/nvif/client.c
+++ b/drivers/gpu/drm/nouveau/nvif/client.c
@@ -60,7 +60,6 @@ nvif_client_ctor(struct nvif_client *parent, const char *name, struct nvif_clien
 		return ret;
 
 	nvif_object_ctor(&parent->object, name ?: "nvifClient", 0, 0, &client->object);
-	client->object.priv = client->priv;
 	client->driver = parent->driver;
 	return 0;
 }
diff --git a/drivers/gpu/drm/nouveau/nvif/driver.c b/drivers/gpu/drm/nouveau/nvif/driver.c
index 95515f2023f4..54263ff7c7e6 100644
--- a/drivers/gpu/drm/nouveau/nvif/driver.c
+++ b/drivers/gpu/drm/nouveau/nvif/driver.c
@@ -34,7 +34,6 @@ nvif_driver_ctor(struct nvif_parent *parent, const struct nvif_driver *driver, c
 	client->object.client = 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;
diff --git a/drivers/gpu/drm/nouveau/nvif/object.c b/drivers/gpu/drm/nouveau/nvif/object.c
index 3379580463e6..6044634f20b8 100644
--- a/drivers/gpu/drm/nouveau/nvif/object.c
+++ b/drivers/gpu/drm/nouveau/nvif/object.c
@@ -25,26 +25,6 @@
 #include <nvif/object.h>
 #include <nvif/client.h>
 #include <nvif/driverif.h>
-#include <nvif/ioctl.h>
-
-int
-nvif_object_ioctl(struct nvif_object *object, void *data, u32 size, void **hack)
-{
-	struct nvif_client *client = object->client;
-	union {
-		struct nvif_ioctl_v0 v0;
-	} *args = data;
-
-	if (size >= sizeof(*args) && args->v0.version == 0) {
-		if (object != &client->object)
-			args->v0.object = nvif_handle(object);
-		else
-			args->v0.object = 0;
-	} else
-		return -ENOSYS;
-
-	return client->driver->ioctl(client->object.priv, data, size, hack);
-}
 
 int
 nvif_object_unmap_cpu(struct nvif_map *map)
@@ -95,23 +75,15 @@ nvif_object_map_cpu(struct nvif_object *object,
 void
 nvif_object_dtor(struct nvif_object *object)
 {
-	struct {
-		struct nvif_ioctl_v0 ioctl;
-		struct nvif_ioctl_del del;
-	} args = {
-		.ioctl.type = NVIF_IOCTL_V0_DEL,
-	};
-
 	if (!nvif_object_constructed(object))
 		return;
 
-	nvif_object_ioctl(object, &args, sizeof(args), NULL);
 	object->client = NULL;
 }
 
 void
-nvif_object_ctor_1(struct nvif_object *parent, const char *name, u32 handle, s32 oclass,
-		   struct nvif_object *object)
+nvif_object_ctor(struct nvif_object *parent, const char *name, u32 handle, s32 oclass,
+		 struct nvif_object *object)
 {
 	object->parent = parent->parent;
 	object->client = parent->client;
@@ -122,49 +94,3 @@ nvif_object_ctor_1(struct nvif_object *parent, const char *name, u32 handle, s32
 	object->map.ptr = NULL;
 	object->map.size = 0;
 }
-
-int
-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;
-		struct nvif_ioctl_new_v0 new;
-	} *args;
-	int ret = 0;
-
-	object->client = NULL;
-	object->name = name ? name : "nvifObject";
-	object->handle = handle;
-	object->oclass = oclass;
-	object->map.ptr = NULL;
-	object->map.size = 0;
-
-	if (parent) {
-		if (!(args = kmalloc(sizeof(*args) + size, GFP_KERNEL))) {
-			nvif_object_dtor(object);
-			return -ENOMEM;
-		}
-
-		object->parent = parent->parent;
-
-		args->ioctl.version = 0;
-		args->ioctl.type = NVIF_IOCTL_V0_NEW;
-		args->new.version = 0;
-		args->new.object = nvif_handle(object);
-		args->new.handle = handle;
-		args->new.oclass = oclass;
-
-		memcpy(args->new.data, data, size);
-		ret = nvif_object_ioctl(parent, args, sizeof(*args) + size,
-					&object->priv);
-		memcpy(data, args->new.data, size);
-		kfree(args);
-		if (ret == 0)
-			object->client = parent->client;
-	}
-
-	if (ret)
-		nvif_object_dtor(object);
-	return ret;
-}
diff --git a/drivers/gpu/drm/nouveau/nvkm/core/Kbuild b/drivers/gpu/drm/nouveau/nvkm/core/Kbuild
index 7d111a5481d3..50ff041ecdf0 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/Kbuild
+++ b/drivers/gpu/drm/nouveau/nvkm/core/Kbuild
@@ -7,7 +7,6 @@ nvkm-y += nvkm/core/event.o
 nvkm-y += nvkm/core/firmware.o
 nvkm-y += nvkm/core/gpuobj.o
 nvkm-y += nvkm/core/intr.o
-nvkm-y += nvkm/core/ioctl.o
 nvkm-y += nvkm/core/memory.o
 nvkm-y += nvkm/core/mm.o
 nvkm-y += nvkm/core/object.o
diff --git a/drivers/gpu/drm/nouveau/nvkm/core/driver.c b/drivers/gpu/drm/nouveau/nvkm/core/driver.c
index ea00b8724f24..37d7fa8f9760 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/driver.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/driver.c
@@ -28,7 +28,6 @@
 #include <core/client.h>
 #include <core/driver.h>
 #include <core/event.h>
-#include <core/ioctl.h>
 
 #include <nvif/driverif.h>
 #include <nvif/event.h>
@@ -45,12 +44,6 @@ nvkm_driver_map(struct nvif_client_priv *client, u64 handle, u32 size)
 	return ioremap(handle, size);
 }
 
-static int
-nvkm_driver_ioctl(void *priv, void *data, u32 size, void **hack)
-{
-	return nvkm_ioctl(priv, data, size, hack);
-}
-
 static int
 nvkm_driver_resume(struct nvif_client_priv *client)
 {
@@ -80,7 +73,6 @@ nvkm_driver = {
 	.name = "nvkm",
 	.suspend = nvkm_driver_suspend,
 	.resume = nvkm_driver_resume,
-	.ioctl = nvkm_driver_ioctl,
 	.map = nvkm_driver_map,
 	.unmap = nvkm_driver_unmap,
 };
diff --git a/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c b/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c
deleted file mode 100644
index 50e9a6d51c05..000000000000
--- a/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * Copyright 2014 Red Hat Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors: Ben Skeggs <bskeggs@redhat.com>
- */
-#include <core/ioctl.h>
-#include <core/client.h>
-#include <core/engine.h>
-
-#include <nvif/unpack.h>
-#include <nvif/ioctl.h>
-
-static int
-nvkm_ioctl_nop(struct nvkm_client *client,
-	       struct nvkm_object *object, void *data, u32 size)
-{
-	return -ENOSYS;
-}
-
-#include <nvif/class.h>
-
-static int
-nvkm_ioctl_sclass_(struct nvkm_object *object, int index, struct nvkm_oclass *oclass)
-{
-	if (object->func->sclass)
-		return object->func->sclass(object, index, oclass);
-
-	return -ENOSYS;
-}
-
-static int
-nvkm_ioctl_sclass(struct nvkm_client *client,
-		  struct nvkm_object *object, void *data, u32 size)
-{
-	return -ENODEV;
-}
-
-static int
-nvkm_ioctl_new(struct nvkm_client *client,
-	       struct nvkm_object *parent, void *data, u32 size)
-{
-	union {
-		struct nvif_ioctl_new_v0 v0;
-	} *args = data;
-	struct nvkm_object *object = NULL;
-	struct nvkm_oclass oclass;
-	int ret = -ENOSYS, i = 0;
-
-	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 object %016llx\n",
-			   args->v0.version, args->v0.handle, args->v0.oclass,
-			   args->v0.object);
-	} else
-		return ret;
-
-	if (!parent->func->sclass) {
-		nvif_ioctl(parent, "cannot have children\n");
-		return -EINVAL;
-	}
-
-	do {
-		memset(&oclass, 0x00, sizeof(oclass));
-		oclass.handle = args->v0.handle;
-		oclass.object = args->v0.object;
-		oclass.client = client;
-		oclass.parent = parent;
-		ret = nvkm_ioctl_sclass_(parent, i++, &oclass);
-		if (ret)
-			return ret;
-	} while (oclass.base.oclass != args->v0.oclass);
-
-	if (oclass.engine) {
-		oclass.engine = nvkm_engine_ref(oclass.engine);
-		if (IS_ERR(oclass.engine))
-			return PTR_ERR(oclass.engine);
-	}
-
-	ret = oclass.ctor(&oclass, data, size, &object);
-	nvkm_engine_unref(&oclass.engine);
-	if (ret == 0) {
-		ret = nvkm_object_init(object);
-		if (ret == 0) {
-			list_add_tail(&object->head, &parent->tree);
-			if (nvkm_object_insert(object)) {
-				client->data = object;
-				return 0;
-			}
-			ret = -EEXIST;
-		}
-		nvkm_object_fini(object, false);
-	}
-
-	nvkm_object_del(&object);
-	return ret;
-}
-
-static int
-nvkm_ioctl_del(struct nvkm_client *client,
-	       struct nvkm_object *object, void *data, u32 size)
-{
-	union {
-		struct nvif_ioctl_del none;
-	} *args = data;
-	int ret = -ENOSYS;
-
-	nvif_ioctl(object, "delete size %d\n", size);
-	if (!(ret = nvif_unvers(ret, &data, &size, args->none))) {
-		nvif_ioctl(object, "delete\n");
-		nvkm_object_fini(object, false);
-		nvkm_object_del(&object);
-	}
-
-	return ret ? ret : 1;
-}
-
-static struct {
-	int version;
-	int (*func)(struct nvkm_client *, struct nvkm_object *, void *, u32);
-}
-nvkm_ioctl_v0[] = {
-	{ 0x00, nvkm_ioctl_nop },
-	{ 0x00, nvkm_ioctl_sclass },
-	{ 0x00, nvkm_ioctl_new },
-	{ 0x00, nvkm_ioctl_del },
-};
-
-static int
-nvkm_ioctl_path(struct nvkm_client *client, u64 handle, u32 type,
-		void *data, u32 size)
-{
-	struct nvkm_object *object;
-	int ret;
-
-	object = nvkm_object_search(client, handle, NULL);
-	if (IS_ERR(object)) {
-		nvif_ioctl(&client->object, "object not found\n");
-		return PTR_ERR(object);
-	}
-
-	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);
-	}
-
-	return ret;
-}
-
-int
-nvkm_ioctl(struct nvkm_client *client, void *data, u32 size, void **hack)
-{
-	struct nvkm_object *object = &client->object;
-	union {
-		struct nvif_ioctl_v0 v0;
-	} *args = data;
-	int ret = -ENOSYS;
-
-	nvif_ioctl(object, "size %d\n", size);
-
-	if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) {
-		nvif_ioctl(object,
-			   "vers %d type %02x object %016llx owner %02x\n",
-			   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);
-	}
-
-	if (ret != 1) {
-		nvif_ioctl(object, "return %d\n", ret);
-		if (hack) {
-			*hack = client->data;
-			client->data = NULL;
-		}
-	}
-
-	return ret;
-}
diff --git a/drivers/gpu/drm/nouveau/nvkm/core/object.c b/drivers/gpu/drm/nouveau/nvkm/core/object.c
index 8ad1aff9b8c7..5645dd51abd5 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/object.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/object.c
@@ -25,79 +25,6 @@
 #include <core/client.h>
 #include <core/engine.h>
 
-struct nvkm_object *
-nvkm_object_search(struct nvkm_client *client, u64 handle,
-		   const struct nvkm_object_func *func)
-{
-	struct nvkm_object *object;
-	unsigned long flags;
-
-	if (handle) {
-		spin_lock_irqsave(&client->obj_lock, flags);
-		struct rb_node *node = client->objroot.rb_node;
-		while (node) {
-			object = rb_entry(node, typeof(*object), node);
-			if (handle < object->object)
-				node = node->rb_left;
-			else
-			if (handle > object->object)
-				node = node->rb_right;
-			else {
-				spin_unlock_irqrestore(&client->obj_lock, flags);
-				goto done;
-			}
-		}
-		spin_unlock_irqrestore(&client->obj_lock, flags);
-		return ERR_PTR(-ENOENT);
-	} else {
-		object = &client->object;
-	}
-
-done:
-	if (unlikely(func && object->func != func))
-		return ERR_PTR(-EINVAL);
-	return object;
-}
-
-void
-nvkm_object_remove(struct nvkm_object *object)
-{
-	unsigned long flags;
-
-	spin_lock_irqsave(&object->client->obj_lock, flags);
-	if (!RB_EMPTY_NODE(&object->node))
-		rb_erase(&object->node, &object->client->objroot);
-	spin_unlock_irqrestore(&object->client->obj_lock, flags);
-}
-
-bool
-nvkm_object_insert(struct nvkm_object *object)
-{
-	struct rb_node **ptr;
-	struct rb_node *parent = NULL;
-	unsigned long flags;
-
-	spin_lock_irqsave(&object->client->obj_lock, flags);
-	ptr = &object->client->objroot.rb_node;
-	while (*ptr) {
-		struct nvkm_object *this = rb_entry(*ptr, typeof(*this), node);
-		parent = *ptr;
-		if (object->object < this->object) {
-			ptr = &parent->rb_left;
-		} else if (object->object > this->object) {
-			ptr = &parent->rb_right;
-		} else {
-			spin_unlock_irqrestore(&object->client->obj_lock, flags);
-			return false;
-		}
-	}
-
-	rb_link_node(&object->node, parent, ptr);
-	rb_insert_color(&object->node, &object->client->objroot);
-	spin_unlock_irqrestore(&object->client->obj_lock, flags);
-	return true;
-}
-
 int
 nvkm_object_mthd(struct nvkm_object *object, u32 mthd, void *data, u32 size)
 {
@@ -232,7 +159,6 @@ nvkm_object_del(struct nvkm_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);
@@ -255,7 +181,6 @@ nvkm_object_ctor(const struct nvkm_object_func *func,
 	object->object = oclass->object;
 	INIT_LIST_HEAD(&object->head);
 	INIT_LIST_HEAD(&object->tree);
-	RB_CLEAR_NODE(&object->node);
 	WARN_ON(IS_ERR(object->engine));
 }
 
@@ -296,20 +221,3 @@ nvkm_object_link_(struct nvif_client_priv *client, struct nvkm_object *parent,
 	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;
-}
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/uchan.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/uchan.c
index 281994235c5f..e691853000fb 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/uchan.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/uchan.c
@@ -214,8 +214,7 @@ nvkm_uchan_object_new(const struct nvkm_oclass *oclass, void *argv, u32 argc,
 
 static int
 nvkm_uchan_engobj_new(struct nvif_chan_priv *uchan, u32 handle, u8 engi, s32 oclass,
-		      const struct nvif_engobj_impl **pimpl, struct nvif_engobj_priv **ppriv,
-		      u64 _handle)
+		      const struct nvif_engobj_impl **pimpl, struct nvif_engobj_priv **ppriv)
 {
 	struct nvkm_chan *chan = uchan->chan;
 	struct nvkm_runl *runl = chan->cgrp->runl;
@@ -285,9 +284,7 @@ nvkm_uchan_engobj_new(struct nvif_chan_priv *uchan, u32 handle, u8 engi, s32 ocl
 	*pimpl = &nvkm_uchan_object_impl;
 	*ppriv = (void *)container_of(object, struct nvkm_uobj, oproxy.base);
 
-	ret = nvkm_object_link_rb(uchan->object.client, &uchan->object, _handle, object);
-	if (ret)
-		nvkm_object_fini(object, false);
+	nvkm_object_link(&uchan->object, object);
 
 done:
 	if (ret)
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 150/156] drm/nouveau/nvkm: switch nvkm_object to non-irqsafe spinlock
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (148 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 149/156] drm/nouveau/nvif: remove engobj from object rb Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 151/156] drm/nouveau: remove client_mutex Ben Skeggs
                   ` (7 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- nvkm_object_search() no longer exists to be called from irq context

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/nvkm/core/object.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/core/object.c b/drivers/gpu/drm/nouveau/nvkm/core/object.c
index 5645dd51abd5..f3cf39fb3567 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/object.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/object.c
@@ -160,9 +160,9 @@ nvkm_object_del(struct nvkm_object **pobject)
 	if (object && !WARN_ON(!object->func)) {
 		*pobject = nvkm_object_dtor(object);
 
-		spin_lock_irq(&object->client->obj_lock);
+		spin_lock(&object->client->obj_lock);
 		list_del(&object->head);
-		spin_unlock_irq(&object->client->obj_lock);
+		spin_unlock(&object->client->obj_lock);
 
 		kfree(*pobject);
 		*pobject = NULL;
@@ -217,7 +217,7 @@ nvkm_object_link_(struct nvif_client_priv *client, struct nvkm_object *parent,
 {
 	object->client = client;
 
-	spin_lock_irq(&client->obj_lock);
+	spin_lock(&client->obj_lock);
 	list_add_tail(&object->head, &parent->tree);
-	spin_unlock_irq(&client->obj_lock);
+	spin_unlock(&client->obj_lock);
 }
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 151/156] drm/nouveau: remove client_mutex
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (149 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 150/156] drm/nouveau/nvkm: switch nvkm_object to non-irqsafe spinlock Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 152/156] drm/nouveau: move nvxx_* definitions to nouveau_drv.h Ben Skeggs
                   ` (6 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- this protected the drm.master object rb, which no longer exists

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/nouveau_drm.c | 7 -------
 drivers/gpu/drm/nouveau/nouveau_drv.h | 1 -
 drivers/gpu/drm/nouveau/nouveau_mem.c | 6 ------
 3 files changed, 14 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index ae6b992c32f9..aac9e57d0204 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -185,9 +185,7 @@ nouveau_cli_fini(struct nouveau_cli *cli)
 	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);
-	mutex_unlock(&cli->drm->client_mutex);
 }
 
 static int
@@ -204,9 +202,7 @@ nouveau_cli_init(struct nouveau_drm *drm, const char *sname,
 	INIT_LIST_HEAD(&cli->worker);
 	mutex_init(&cli->lock);
 
-	mutex_lock(&drm->client_mutex);
 	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);
 		goto done;
@@ -505,7 +501,6 @@ nouveau_drm_device_init(struct drm_device *dev, struct nvkm_device *nvkm)
 
 	nvif_parent_ctor(&nouveau_parent, &drm->parent);
 
-	mutex_init(&drm->client_mutex);
 	drm->_client.object.parent = &drm->parent;
 
 	ret = nvkm_driver_ctor(drm->nvkm, &driver, &impl, &priv);
@@ -641,7 +636,6 @@ nouveau_drm_device_init(struct drm_device *dev, struct nvkm_device *nvkm)
 	nvif_device_dtor(&drm->device);
 	nvif_client_dtor(&drm->_client);
 fail_alloc:
-	mutex_destroy(&drm->client_mutex);
 	nvif_parent_dtor(&drm->parent);
 	kfree(drm);
 	return ret;
@@ -696,7 +690,6 @@ nouveau_drm_device_fini(struct drm_device *dev)
 	destroy_workqueue(drm->sched_wq);
 	nvif_mmu_dtor(&drm->mmu);
 	nvif_device_dtor(&drm->device);
-	mutex_destroy(&drm->client_mutex);
 	nvif_parent_dtor(&drm->parent);
 	mutex_destroy(&drm->clients_lock);
 	kfree(drm);
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h
index e40416c884a8..046f219328bc 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.h
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.h
@@ -203,7 +203,6 @@ u_memcpya(uint64_t user, unsigned int nmemb, unsigned int size)
 struct nouveau_drm {
 	struct nvkm_device *nvkm;
 	struct nvif_parent parent;
-	struct mutex client_mutex;
 	struct nvif_client _client;
 	struct nvif_device device;
 	struct nvif_mmu mmu;
diff --git a/drivers/gpu/drm/nouveau/nouveau_mem.c b/drivers/gpu/drm/nouveau/nouveau_mem.c
index ff67f00c93c5..aa0503d13cbe 100644
--- a/drivers/gpu/drm/nouveau/nouveau_mem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_mem.c
@@ -80,9 +80,7 @@ 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->client_mutex);
 	nvif_mem_dtor(&mem->mem);
-	mutex_unlock(&mem->drm->client_mutex);
 }
 
 int
@@ -113,11 +111,9 @@ nouveau_mem_host(struct ttm_resource *reg, struct ttm_tt *tt)
 	else
 		args.dma = tt->dma_address;
 
-	mutex_lock(&drm->client_mutex);
 	ret = nvif_mem_ctor_type(mmu, "ttmHostMem", type, PAGE_SHIFT,
 				 reg->size,
 				 &args, sizeof(args), &mem->mem);
-	mutex_unlock(&drm->client_mutex);
 	return ret;
 }
 
@@ -130,7 +126,6 @@ nouveau_mem_vram(struct ttm_resource *reg, bool contig, u8 page)
 	u64 size = ALIGN(reg->size, 1 << page);
 	int ret;
 
-	mutex_lock(&drm->client_mutex);
 	switch (drm->mmu.impl->mem.oclass) {
 	case NVIF_CLASS_MEM_GF100:
 		ret = nvif_mem_ctor_type(mmu, "ttmVram",
@@ -154,7 +149,6 @@ nouveau_mem_vram(struct ttm_resource *reg, bool contig, u8 page)
 		WARN_ON(1);
 		break;
 	}
-	mutex_unlock(&drm->client_mutex);
 
 	reg->start = mem->mem.impl->addr >> PAGE_SHIFT;
 	return ret;
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 152/156] drm/nouveau: move nvxx_* definitions to nouveau_drv.h
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (150 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 151/156] drm/nouveau: remove client_mutex Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:39 ` [PATCH 153/156] drm/nouveau: pass nouveau_drm to nvxx_* Ben Skeggs
                   ` (5 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- move out of nvif

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/include/nvif/device.h | 33 -------------------
 drivers/gpu/drm/nouveau/nouveau_bios.h        |  1 +
 drivers/gpu/drm/nouveau/nouveau_drv.h         | 32 ++++++++++++++++++
 3 files changed, 33 insertions(+), 33 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/device.h b/drivers/gpu/drm/nouveau/include/nvif/device.h
index 5fb71e6da7cd..0ec8d80133c7 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/device.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/device.h
@@ -25,37 +25,4 @@ u64  nvif_device_time(struct nvif_device *);
 
 int nvif_device_ctxdma_ctor(struct nvif_device *, const char *name, s32 oclass,
 			    void *argv, u32 argc, struct nvif_ctxdma *);
-
-/*XXX*/
-#include <subdev/bios.h>
-#include <subdev/fb.h>
-#include <subdev/bar.h>
-#include <subdev/gpio.h>
-#include <subdev/clk.h>
-#include <subdev/i2c.h>
-#include <subdev/timer.h>
-#include <subdev/therm.h>
-#include <subdev/pci.h>
-
-#define nvxx_device(a) ({                                                      \
-	struct nvif_device *_device = (a);                                     \
-	struct {                                                               \
-		struct nvkm_object object;                                     \
-		struct nvkm_device *device;                                    \
-	} *_udevice = _device->object.priv;                                    \
-	_udevice->device;                                                      \
-})
-#define nvxx_bios(a) nvxx_device(a)->bios
-#define nvxx_fb(a) nvxx_device(a)->fb
-#define nvxx_gpio(a) nvxx_device(a)->gpio
-#define nvxx_clk(a) nvxx_device(a)->clk
-#define nvxx_i2c(a) nvxx_device(a)->i2c
-#define nvxx_iccsense(a) nvxx_device(a)->iccsense
-#define nvxx_therm(a) nvxx_device(a)->therm
-#define nvxx_volt(a) nvxx_device(a)->volt
-
-#include <engine/fifo.h>
-#include <engine/gr.h>
-
-#define nvxx_gr(a) nvxx_device(a)->gr
 #endif
diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.h b/drivers/gpu/drm/nouveau/nouveau_bios.h
index 18eb061ccafb..62b5f5889041 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bios.h
+++ b/drivers/gpu/drm/nouveau/nouveau_bios.h
@@ -48,6 +48,7 @@ struct bit_entry {
 
 int bit_table(struct drm_device *, u8 id, struct bit_entry *);
 
+#include <subdev/bios.h>
 #include <subdev/bios/dcb.h>
 #include <subdev/bios/conn.h>
 
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h
index 046f219328bc..b4069d2b31f9 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.h
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.h
@@ -362,4 +362,36 @@ void nouveau_drm_device_remove(struct drm_device *dev);
 
 extern int nouveau_modeset;
 
+/*XXX*/
+#include <subdev/bios.h>
+#include <subdev/fb.h>
+#include <subdev/bar.h>
+#include <subdev/gpio.h>
+#include <subdev/clk.h>
+#include <subdev/i2c.h>
+#include <subdev/timer.h>
+#include <subdev/therm.h>
+#include <subdev/pci.h>
+
+#define nvxx_device(a) ({                        \
+	struct nvif_device *_device = (a);       \
+	struct {                                 \
+		struct nvkm_object object;       \
+		struct nvkm_device *device;      \
+	} *_udevice = _device->object.priv;      \
+	_udevice->device;                        \
+})
+#define nvxx_bios(a) nvxx_device(a)->bios
+#define nvxx_fb(a) nvxx_device(a)->fb
+#define nvxx_gpio(a) nvxx_device(a)->gpio
+#define nvxx_clk(a) nvxx_device(a)->clk
+#define nvxx_i2c(a) nvxx_device(a)->i2c
+#define nvxx_iccsense(a) nvxx_device(a)->iccsense
+#define nvxx_therm(a) nvxx_device(a)->therm
+#define nvxx_volt(a) nvxx_device(a)->volt
+
+#include <engine/fifo.h>
+#include <engine/gr.h>
+
+#define nvxx_gr(a) nvxx_device(a)->gr
 #endif
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 153/156] drm/nouveau: pass nouveau_drm to nvxx_*
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (151 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 152/156] drm/nouveau: move nvxx_* definitions to nouveau_drv.h Ben Skeggs
@ 2024-04-16 23:39 ` Ben Skeggs
  2024-04-16 23:40 ` [PATCH 154/156] drm/nouveau: remove remaining usage of nvif_device.info Ben Skeggs
                   ` (4 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:39 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- removes usage of nvif_object.priv

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/dispnv04/crtc.c       |  4 +-
 drivers/gpu/drm/nouveau/dispnv04/dac.c        |  2 +-
 drivers/gpu/drm/nouveau/dispnv04/dfp.c        |  2 +-
 drivers/gpu/drm/nouveau/dispnv04/disp.c       |  2 +-
 drivers/gpu/drm/nouveau/dispnv04/disp.h       |  2 +-
 drivers/gpu/drm/nouveau/dispnv04/hw.c         |  9 ++--
 drivers/gpu/drm/nouveau/dispnv04/tvnv04.c     |  4 +-
 drivers/gpu/drm/nouveau/dispnv04/tvnv17.c     |  6 +--
 drivers/gpu/drm/nouveau/dispnv50/disp.c       |  6 +--
 drivers/gpu/drm/nouveau/include/nvif/object.h |  1 -
 drivers/gpu/drm/nouveau/nouveau_abi16.c       |  4 +-
 drivers/gpu/drm/nouveau/nouveau_bios.c        |  4 +-
 drivers/gpu/drm/nouveau/nouveau_bo.c          |  8 ++--
 drivers/gpu/drm/nouveau/nouveau_chan.c        |  3 +-
 drivers/gpu/drm/nouveau/nouveau_drm.c         |  3 +-
 drivers/gpu/drm/nouveau/nouveau_drv.h         |  4 +-
 drivers/gpu/drm/nouveau/nouveau_hwmon.c       | 46 +++++++++----------
 drivers/gpu/drm/nouveau/nouveau_led.c         |  2 +-
 drivers/gpu/drm/nouveau/nouveau_ttm.c         |  4 +-
 drivers/gpu/drm/nouveau/nvif/device.c         |  1 -
 drivers/gpu/drm/nouveau/nvif/object.c         |  1 -
 21 files changed, 56 insertions(+), 62 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv04/crtc.c b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
index 8e8a43b28f71..90e549541981 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/crtc.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
@@ -118,8 +118,8 @@ static void nv_crtc_calc_state_ext(struct drm_crtc *crtc, struct drm_display_mod
 {
 	struct drm_device *dev = crtc->dev;
 	struct nouveau_drm *drm = nouveau_drm(dev);
-	struct nvkm_bios *bios = nvxx_bios(&drm->client.device);
-	struct nvkm_clk *clk = nvxx_clk(&drm->client.device);
+	struct nvkm_bios *bios = nvxx_bios(drm);
+	struct nvkm_clk *clk = nvxx_clk(drm);
 	struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
 	struct nv04_mode_state *state = &nv04_display(dev)->mode_reg;
 	struct nv04_crtc_reg *regp = &state->crtc_reg[nv_crtc->index];
diff --git a/drivers/gpu/drm/nouveau/dispnv04/dac.c b/drivers/gpu/drm/nouveau/dispnv04/dac.c
index d6b8e0cce2ac..2e12bf136607 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/dac.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/dac.c
@@ -237,7 +237,7 @@ uint32_t nv17_dac_sample_load(struct drm_encoder *encoder)
 	struct drm_device *dev = encoder->dev;
 	struct nouveau_drm *drm = nouveau_drm(dev);
 	struct nvif_object *device = &nouveau_drm(dev)->client.device.object;
-	struct nvkm_gpio *gpio = nvxx_gpio(&drm->client.device);
+	struct nvkm_gpio *gpio = nvxx_gpio(drm);
 	struct dcb_output *dcb = nouveau_encoder(encoder)->dcb;
 	uint32_t sample, testval, regoffset = nv04_dac_output_offset(encoder);
 	uint32_t saved_powerctrl_2 = 0, saved_powerctrl_4 = 0, saved_routput,
diff --git a/drivers/gpu/drm/nouveau/dispnv04/dfp.c b/drivers/gpu/drm/nouveau/dispnv04/dfp.c
index d5b129dc623b..504c421aa176 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/dfp.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/dfp.c
@@ -626,7 +626,7 @@ static void nv04_tmds_slave_init(struct drm_encoder *encoder)
 	struct drm_device *dev = encoder->dev;
 	struct dcb_output *dcb = nouveau_encoder(encoder)->dcb;
 	struct nouveau_drm *drm = nouveau_drm(dev);
-	struct nvkm_i2c *i2c = nvxx_i2c(&drm->client.device);
+	struct nvkm_i2c *i2c = nvxx_i2c(drm);
 	struct nvkm_i2c_bus *bus = nvkm_i2c_bus_find(i2c, NVKM_I2C_BUS_PRI);
 	struct nvkm_i2c_bus_probe info[] = {
 		{
diff --git a/drivers/gpu/drm/nouveau/dispnv04/disp.c b/drivers/gpu/drm/nouveau/dispnv04/disp.c
index 3d564512b0f6..1ccd78d270b3 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/disp.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/disp.c
@@ -211,7 +211,7 @@ int
 nv04_display_create(struct drm_device *dev)
 {
 	struct nouveau_drm *drm = nouveau_drm(dev);
-	struct nvkm_i2c *i2c = nvxx_i2c(&drm->client.device);
+	struct nvkm_i2c *i2c = nvxx_i2c(drm);
 	struct dcb_table *dcb = &drm->vbios.dcb;
 	struct drm_connector *connector, *ct;
 	struct drm_encoder *encoder;
diff --git a/drivers/gpu/drm/nouveau/dispnv04/disp.h b/drivers/gpu/drm/nouveau/dispnv04/disp.h
index 11a6663758ec..85ec0f534392 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/disp.h
+++ b/drivers/gpu/drm/nouveau/dispnv04/disp.h
@@ -176,7 +176,7 @@ static inline void
 nouveau_bios_run_init_table(struct drm_device *dev, u16 table,
 			    struct dcb_output *outp, int crtc)
 {
-	nvbios_init(&nvxx_bios(&nouveau_drm(dev)->client.device)->subdev, table,
+	nvbios_init(&nvxx_bios(nouveau_drm(dev))->subdev, table,
 		init.outp = outp;
 		init.head = crtc;
 	);
diff --git a/drivers/gpu/drm/nouveau/dispnv04/hw.c b/drivers/gpu/drm/nouveau/dispnv04/hw.c
index f7d35657aa64..8b376f9c8746 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/hw.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/hw.c
@@ -166,7 +166,7 @@ nouveau_hw_get_pllvals(struct drm_device *dev, enum nvbios_pll_type plltype,
 {
 	struct nouveau_drm *drm = nouveau_drm(dev);
 	struct nvif_object *device = &drm->client.device.object;
-	struct nvkm_bios *bios = nvxx_bios(&drm->client.device);
+	struct nvkm_bios *bios = nvxx_bios(drm);
 	uint32_t reg1, pll1, pll2 = 0;
 	struct nvbios_pll pll_lim;
 	int ret;
@@ -258,9 +258,8 @@ nouveau_hw_fix_bad_vpll(struct drm_device *dev, int head)
 	 */
 
 	struct nouveau_drm *drm = nouveau_drm(dev);
-	struct nvif_device *device = &drm->client.device;
-	struct nvkm_clk *clk = nvxx_clk(device);
-	struct nvkm_bios *bios = nvxx_bios(device);
+	struct nvkm_clk *clk = nvxx_clk(drm);
+	struct nvkm_bios *bios = nvxx_bios(drm);
 	struct nvbios_pll pll_lim;
 	struct nvkm_pll_vals pv;
 	enum nvbios_pll_type pll = head ? PLL_VPLL1 : PLL_VPLL0;
@@ -470,7 +469,7 @@ nv_load_state_ramdac(struct drm_device *dev, int head,
 		     struct nv04_mode_state *state)
 {
 	struct nouveau_drm *drm = nouveau_drm(dev);
-	struct nvkm_clk *clk = nvxx_clk(&drm->client.device);
+	struct nvkm_clk *clk = nvxx_clk(drm);
 	struct nv04_crtc_reg *regp = &state->crtc_reg[head];
 	uint32_t pllreg = head ? NV_RAMDAC_VPLL2 : NV_PRAMDAC_VPLL_COEFF;
 	int i;
diff --git a/drivers/gpu/drm/nouveau/dispnv04/tvnv04.c b/drivers/gpu/drm/nouveau/dispnv04/tvnv04.c
index de3ea731d6e6..d3014027a812 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/tvnv04.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/tvnv04.c
@@ -53,7 +53,7 @@ static struct nvkm_i2c_bus_probe nv04_tv_encoder_info[] = {
 int nv04_tv_identify(struct drm_device *dev, int i2c_index)
 {
 	struct nouveau_drm *drm = nouveau_drm(dev);
-	struct nvkm_i2c *i2c = nvxx_i2c(&drm->client.device);
+	struct nvkm_i2c *i2c = nvxx_i2c(drm);
 	struct nvkm_i2c_bus *bus = nvkm_i2c_bus_find(i2c, i2c_index);
 	if (bus) {
 		return nvkm_i2c_bus_probe(bus, "TV encoder",
@@ -205,7 +205,7 @@ nv04_tv_create(struct drm_connector *connector, struct dcb_output *entry)
 	struct drm_encoder *encoder;
 	struct drm_device *dev = connector->dev;
 	struct nouveau_drm *drm = nouveau_drm(dev);
-	struct nvkm_i2c *i2c = nvxx_i2c(&drm->client.device);
+	struct nvkm_i2c *i2c = nvxx_i2c(drm);
 	struct nvkm_i2c_bus *bus = nvkm_i2c_bus_find(i2c, entry->i2c_index);
 	int type, ret;
 
diff --git a/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c b/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c
index 670c9739e5e1..c11f58033018 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c
@@ -47,7 +47,7 @@ static uint32_t nv42_tv_sample_load(struct drm_encoder *encoder)
 {
 	struct drm_device *dev = encoder->dev;
 	struct nouveau_drm *drm = nouveau_drm(dev);
-	struct nvkm_gpio *gpio = nvxx_gpio(&drm->client.device);
+	struct nvkm_gpio *gpio = nvxx_gpio(drm);
 	uint32_t testval, regoffset = nv04_dac_output_offset(encoder);
 	uint32_t gpio0, gpio1, fp_htotal, fp_hsync_start, fp_hsync_end,
 		fp_control, test_ctrl, dacclk, ctv_14, ctv_1c, ctv_6c;
@@ -131,7 +131,7 @@ static bool
 get_tv_detect_quirks(struct drm_device *dev, uint32_t *pin_mask)
 {
 	struct nouveau_drm *drm = nouveau_drm(dev);
-	struct nvkm_device *device = nvxx_device(&drm->client.device);
+	struct nvkm_device *device = nvxx_device(drm);
 
 	if (device->quirk && device->quirk->tv_pin_mask) {
 		*pin_mask = device->quirk->tv_pin_mask;
@@ -363,7 +363,7 @@ static void  nv17_tv_dpms(struct drm_encoder *encoder, int mode)
 {
 	struct drm_device *dev = encoder->dev;
 	struct nouveau_drm *drm = nouveau_drm(dev);
-	struct nvkm_gpio *gpio = nvxx_gpio(&drm->client.device);
+	struct nvkm_gpio *gpio = nvxx_gpio(drm);
 	struct nv17_tv_state *regs = &to_tv_enc(encoder)->state;
 	struct nv17_tv_norm_params *tv_norm = get_tv_norm(encoder);
 
diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c b/drivers/gpu/drm/nouveau/dispnv50/disp.c
index 7762469af47b..a23e1d264294 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/disp.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c
@@ -318,7 +318,7 @@ nv50_dac_create(struct nouveau_encoder *nv_encoder)
 {
 	struct drm_connector *connector = &nv_encoder->conn->base;
 	struct nouveau_drm *drm = nouveau_drm(connector->dev);
-	struct nvkm_i2c *i2c = nvxx_i2c(&drm->client.device);
+	struct nvkm_i2c *i2c = nvxx_i2c(drm);
 	struct nvkm_i2c_bus *bus;
 	struct drm_encoder *encoder;
 	struct dcb_output *dcbe = nv_encoder->dcb;
@@ -1638,7 +1638,7 @@ nv50_sor_create(struct nouveau_encoder *nv_encoder)
 	struct drm_connector *connector = &nv_encoder->conn->base;
 	struct nouveau_connector *nv_connector = nouveau_connector(connector);
 	struct nouveau_drm *drm = nouveau_drm(connector->dev);
-	struct nvkm_i2c *i2c = nvxx_i2c(&drm->client.device);
+	struct nvkm_i2c *i2c = nvxx_i2c(drm);
 	struct drm_encoder *encoder;
 	struct dcb_output *dcbe = nv_encoder->dcb;
 	struct nv50_disp *disp = nv50_disp(connector->dev);
@@ -1805,7 +1805,7 @@ nv50_pior_create(struct nouveau_encoder *nv_encoder)
 	struct drm_device *dev = connector->dev;
 	struct nouveau_drm *drm = nouveau_drm(dev);
 	struct nv50_disp *disp = nv50_disp(dev);
-	struct nvkm_i2c *i2c = nvxx_i2c(&drm->client.device);
+	struct nvkm_i2c *i2c = nvxx_i2c(drm);
 	struct nvkm_i2c_bus *bus = NULL;
 	struct nvkm_i2c_aux *aux = NULL;
 	struct i2c_adapter *ddc;
diff --git a/drivers/gpu/drm/nouveau/include/nvif/object.h b/drivers/gpu/drm/nouveau/include/nvif/object.h
index 94722ded1d68..7a90eab48eec 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/object.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/object.h
@@ -9,7 +9,6 @@ struct nvif_object {
 	const char *name;
 	u32 handle;
 	s32 oclass;
-	void *priv; /*XXX: hack */
 	struct {
 		void __iomem *ptr;
 		u64 size;
diff --git a/drivers/gpu/drm/nouveau/nouveau_abi16.c b/drivers/gpu/drm/nouveau/nouveau_abi16.c
index 8cc7b2410a04..ef668f20111a 100644
--- a/drivers/gpu/drm/nouveau/nouveau_abi16.c
+++ b/drivers/gpu/drm/nouveau/nouveau_abi16.c
@@ -212,8 +212,8 @@ nouveau_abi16_ioctl_getparam(ABI16_IOCTL_ARGS)
 	struct nouveau_cli *cli = nouveau_cli(file_priv);
 	struct nouveau_drm *drm = nouveau_drm(dev);
 	struct nvif_device *device = &drm->client.device;
-	struct nvkm_device *nvkm_device = nvxx_device(&drm->client.device);
-	struct nvkm_gr *gr = nvxx_gr(device);
+	struct nvkm_device *nvkm_device = nvxx_device(drm);
+	struct nvkm_gr *gr = nvxx_gr(drm);
 	struct drm_nouveau_getparam *getparam = data;
 	struct pci_dev *pdev = to_pci_dev(dev->dev);
 
diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
index 479effcf607e..829e98da56d0 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bios.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
@@ -2019,7 +2019,7 @@ uint8_t *nouveau_bios_embedded_edid(struct drm_device *dev)
 static bool NVInitVBIOS(struct drm_device *dev)
 {
 	struct nouveau_drm *drm = nouveau_drm(dev);
-	struct nvkm_bios *bios = nvxx_bios(&drm->client.device);
+	struct nvkm_bios *bios = nvxx_bios(drm);
 	struct nvbios *legacy = &drm->vbios;
 
 	memset(legacy, 0, sizeof(struct nvbios));
@@ -2090,7 +2090,7 @@ nouveau_bios_init(struct drm_device *dev)
 
 	/* only relevant for PCI devices */
 	if (!dev_is_pci(dev->dev) ||
-	    nvkm_gsp_rm(nvxx_device(&drm->client.device)->gsp))
+	    nvkm_gsp_rm(nvxx_device(drm)->gsp))
 		return 0;
 
 	if (!NVInitVBIOS(dev))
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
index a94735ec3a9e..60ce4b46a3a4 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -58,7 +58,7 @@ nv10_bo_update_tile_region(struct drm_device *dev, struct nouveau_drm_tile *reg,
 {
 	struct nouveau_drm *drm = nouveau_drm(dev);
 	int i = reg - drm->tile.reg;
-	struct nvkm_fb *fb = nvxx_fb(&drm->client.device);
+	struct nvkm_fb *fb = nvxx_fb(drm);
 	struct nvkm_fb_tile *tile = &fb->tile.region[i];
 
 	nouveau_fence_unref(&reg->fence);
@@ -109,7 +109,7 @@ nv10_bo_set_tiling(struct drm_device *dev, u32 addr,
 		   u32 size, u32 pitch, u32 zeta)
 {
 	struct nouveau_drm *drm = nouveau_drm(dev);
-	struct nvkm_fb *fb = nvxx_fb(&drm->client.device);
+	struct nvkm_fb *fb = nvxx_fb(drm);
 	struct nouveau_drm_tile *tile, *found = NULL;
 	int i;
 
@@ -1176,7 +1176,7 @@ static int
 nouveau_ttm_io_mem_reserve(struct ttm_device *bdev, struct ttm_resource *reg)
 {
 	struct nouveau_drm *drm = nouveau_bdev(bdev);
-	struct nvkm_device *device = nvxx_device(&drm->client.device);
+	struct nvkm_device *device = nvxx_device(drm);
 	struct nouveau_mem *mem = nouveau_mem(reg);
 	struct nvif_mmu *mmu = &drm->mmu;
 	int ret;
@@ -1297,7 +1297,7 @@ vm_fault_t nouveau_ttm_fault_reserve_notify(struct ttm_buffer_object *bo)
 {
 	struct nouveau_drm *drm = nouveau_bdev(bo->bdev);
 	struct nouveau_bo *nvbo = nouveau_bo(bo);
-	struct nvkm_device *device = nvxx_device(&drm->client.device);
+	struct nvkm_device *device = nvxx_device(drm);
 	u32 mappable = device->func->resource_size(device, 1) >> PAGE_SHIFT;
 	int i, ret;
 
diff --git a/drivers/gpu/drm/nouveau/nouveau_chan.c b/drivers/gpu/drm/nouveau/nouveau_chan.c
index 54816bcca14c..1cd8953740f5 100644
--- a/drivers/gpu/drm/nouveau/nouveau_chan.c
+++ b/drivers/gpu/drm/nouveau/nouveau_chan.c
@@ -216,8 +216,7 @@ nouveau_channel_prep(struct nouveau_cli *cli,
 			 */
 			args.target = NV_DMA_V0_TARGET_PCI;
 			args.access = NV_DMA_V0_ACCESS_RDWR;
-			args.start = nvxx_device(device)->func->
-				resource_addr(nvxx_device(device), 1);
+			args.start = nvxx_device(drm)->func->resource_addr(nvxx_device(drm), 1);
 			args.limit = args.start + device->info.ram_user - 1;
 		} else {
 			args.target = NV_DMA_V0_TARGET_VRAM;
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index aac9e57d0204..fb01f51fd689 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -347,8 +347,7 @@ nouveau_accel_gr_init(struct nouveau_drm *drm)
 	 * any GPU where it's possible we'll end up using M2MF for BO moves.
 	 */
 	if (device->info.family < NV_DEVICE_INFO_V0_FERMI) {
-		ret = nvkm_gpuobj_new(nvxx_device(device), 32, 0, false, NULL,
-				      &drm->notify);
+		ret = nvkm_gpuobj_new(nvxx_device(drm), 32, 0, false, NULL, &drm->notify);
 		if (ret) {
 			NV_ERROR(drm, "failed to allocate notifier, %d\n", ret);
 			nouveau_accel_gr_fini(drm);
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h
index b4069d2b31f9..12c9ac68a23e 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.h
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.h
@@ -374,11 +374,11 @@ extern int nouveau_modeset;
 #include <subdev/pci.h>
 
 #define nvxx_device(a) ({                        \
-	struct nvif_device *_device = (a);       \
+	struct nouveau_drm *_drm = (a);          \
 	struct {                                 \
 		struct nvkm_object object;       \
 		struct nvkm_device *device;      \
-	} *_udevice = _device->object.priv;      \
+	} *_udevice = (void *)_drm->device.priv; \
 	_udevice->device;                        \
 })
 #define nvxx_bios(a) nvxx_device(a)->bios
diff --git a/drivers/gpu/drm/nouveau/nouveau_hwmon.c b/drivers/gpu/drm/nouveau/nouveau_hwmon.c
index db30a4c2cd4d..5c07a9ee8b77 100644
--- a/drivers/gpu/drm/nouveau/nouveau_hwmon.c
+++ b/drivers/gpu/drm/nouveau/nouveau_hwmon.c
@@ -52,7 +52,7 @@ nouveau_hwmon_temp1_auto_point1_temp(struct device *d,
 {
 	struct drm_device *dev = dev_get_drvdata(d);
 	struct nouveau_drm *drm = nouveau_drm(dev);
-	struct nvkm_therm *therm = nvxx_therm(&drm->client.device);
+	struct nvkm_therm *therm = nvxx_therm(drm);
 
 	return sysfs_emit(buf, "%d\n",
 			  therm->attr_get(therm, NVKM_THERM_ATTR_THRS_FAN_BOOST) * 1000);
@@ -64,7 +64,7 @@ nouveau_hwmon_set_temp1_auto_point1_temp(struct device *d,
 {
 	struct drm_device *dev = dev_get_drvdata(d);
 	struct nouveau_drm *drm = nouveau_drm(dev);
-	struct nvkm_therm *therm = nvxx_therm(&drm->client.device);
+	struct nvkm_therm *therm = nvxx_therm(drm);
 	long value;
 
 	if (kstrtol(buf, 10, &value))
@@ -85,7 +85,7 @@ nouveau_hwmon_temp1_auto_point1_temp_hyst(struct device *d,
 {
 	struct drm_device *dev = dev_get_drvdata(d);
 	struct nouveau_drm *drm = nouveau_drm(dev);
-	struct nvkm_therm *therm = nvxx_therm(&drm->client.device);
+	struct nvkm_therm *therm = nvxx_therm(drm);
 
 	return sysfs_emit(buf, "%d\n",
 			  therm->attr_get(therm, NVKM_THERM_ATTR_THRS_FAN_BOOST_HYST) * 1000);
@@ -97,7 +97,7 @@ nouveau_hwmon_set_temp1_auto_point1_temp_hyst(struct device *d,
 {
 	struct drm_device *dev = dev_get_drvdata(d);
 	struct nouveau_drm *drm = nouveau_drm(dev);
-	struct nvkm_therm *therm = nvxx_therm(&drm->client.device);
+	struct nvkm_therm *therm = nvxx_therm(drm);
 	long value;
 
 	if (kstrtol(buf, 10, &value))
@@ -118,7 +118,7 @@ nouveau_hwmon_get_pwm1_max(struct device *d,
 {
 	struct drm_device *dev = dev_get_drvdata(d);
 	struct nouveau_drm *drm = nouveau_drm(dev);
-	struct nvkm_therm *therm = nvxx_therm(&drm->client.device);
+	struct nvkm_therm *therm = nvxx_therm(drm);
 	int ret;
 
 	ret = therm->attr_get(therm, NVKM_THERM_ATTR_FAN_MAX_DUTY);
@@ -134,7 +134,7 @@ nouveau_hwmon_get_pwm1_min(struct device *d,
 {
 	struct drm_device *dev = dev_get_drvdata(d);
 	struct nouveau_drm *drm = nouveau_drm(dev);
-	struct nvkm_therm *therm = nvxx_therm(&drm->client.device);
+	struct nvkm_therm *therm = nvxx_therm(drm);
 	int ret;
 
 	ret = therm->attr_get(therm, NVKM_THERM_ATTR_FAN_MIN_DUTY);
@@ -150,7 +150,7 @@ nouveau_hwmon_set_pwm1_min(struct device *d, struct device_attribute *a,
 {
 	struct drm_device *dev = dev_get_drvdata(d);
 	struct nouveau_drm *drm = nouveau_drm(dev);
-	struct nvkm_therm *therm = nvxx_therm(&drm->client.device);
+	struct nvkm_therm *therm = nvxx_therm(drm);
 	long value;
 	int ret;
 
@@ -173,7 +173,7 @@ nouveau_hwmon_set_pwm1_max(struct device *d, struct device_attribute *a,
 {
 	struct drm_device *dev = dev_get_drvdata(d);
 	struct nouveau_drm *drm = nouveau_drm(dev);
-	struct nvkm_therm *therm = nvxx_therm(&drm->client.device);
+	struct nvkm_therm *therm = nvxx_therm(drm);
 	long value;
 	int ret;
 
@@ -247,7 +247,7 @@ static umode_t
 nouveau_power_is_visible(const void *data, u32 attr, int channel)
 {
 	struct nouveau_drm *drm = nouveau_drm((struct drm_device *)data);
-	struct nvkm_iccsense *iccsense = nvxx_iccsense(&drm->client.device);
+	struct nvkm_iccsense *iccsense = nvxx_iccsense(drm);
 
 	if (!iccsense || !iccsense->data_valid || list_empty(&iccsense->rails))
 		return 0;
@@ -272,7 +272,7 @@ static umode_t
 nouveau_temp_is_visible(const void *data, u32 attr, int channel)
 {
 	struct nouveau_drm *drm = nouveau_drm((struct drm_device *)data);
-	struct nvkm_therm *therm = nvxx_therm(&drm->client.device);
+	struct nvkm_therm *therm = nvxx_therm(drm);
 
 	if (!therm || !therm->attr_get || nvkm_therm_temp_get(therm) < 0)
 		return 0;
@@ -296,7 +296,7 @@ static umode_t
 nouveau_pwm_is_visible(const void *data, u32 attr, int channel)
 {
 	struct nouveau_drm *drm = nouveau_drm((struct drm_device *)data);
-	struct nvkm_therm *therm = nvxx_therm(&drm->client.device);
+	struct nvkm_therm *therm = nvxx_therm(drm);
 
 	if (!therm || !therm->attr_get || !therm->fan_get ||
 	    therm->fan_get(therm) < 0)
@@ -315,7 +315,7 @@ static umode_t
 nouveau_input_is_visible(const void *data, u32 attr, int channel)
 {
 	struct nouveau_drm *drm = nouveau_drm((struct drm_device *)data);
-	struct nvkm_volt *volt = nvxx_volt(&drm->client.device);
+	struct nvkm_volt *volt = nvxx_volt(drm);
 
 	if (!volt || nvkm_volt_get(volt) < 0)
 		return 0;
@@ -335,7 +335,7 @@ static umode_t
 nouveau_fan_is_visible(const void *data, u32 attr, int channel)
 {
 	struct nouveau_drm *drm = nouveau_drm((struct drm_device *)data);
-	struct nvkm_therm *therm = nvxx_therm(&drm->client.device);
+	struct nvkm_therm *therm = nvxx_therm(drm);
 
 	if (!therm || !therm->attr_get || nvkm_therm_fan_sense(therm) < 0)
 		return 0;
@@ -367,7 +367,7 @@ nouveau_temp_read(struct device *dev, u32 attr, int channel, long *val)
 {
 	struct drm_device *drm_dev = dev_get_drvdata(dev);
 	struct nouveau_drm *drm = nouveau_drm(drm_dev);
-	struct nvkm_therm *therm = nvxx_therm(&drm->client.device);
+	struct nvkm_therm *therm = nvxx_therm(drm);
 	int ret;
 
 	if (!therm || !therm->attr_get)
@@ -416,7 +416,7 @@ nouveau_fan_read(struct device *dev, u32 attr, int channel, long *val)
 {
 	struct drm_device *drm_dev = dev_get_drvdata(dev);
 	struct nouveau_drm *drm = nouveau_drm(drm_dev);
-	struct nvkm_therm *therm = nvxx_therm(&drm->client.device);
+	struct nvkm_therm *therm = nvxx_therm(drm);
 
 	if (!therm)
 		return -EOPNOTSUPP;
@@ -439,7 +439,7 @@ nouveau_in_read(struct device *dev, u32 attr, int channel, long *val)
 {
 	struct drm_device *drm_dev = dev_get_drvdata(dev);
 	struct nouveau_drm *drm = nouveau_drm(drm_dev);
-	struct nvkm_volt *volt = nvxx_volt(&drm->client.device);
+	struct nvkm_volt *volt = nvxx_volt(drm);
 	int ret;
 
 	if (!volt)
@@ -470,7 +470,7 @@ nouveau_pwm_read(struct device *dev, u32 attr, int channel, long *val)
 {
 	struct drm_device *drm_dev = dev_get_drvdata(dev);
 	struct nouveau_drm *drm = nouveau_drm(drm_dev);
-	struct nvkm_therm *therm = nvxx_therm(&drm->client.device);
+	struct nvkm_therm *therm = nvxx_therm(drm);
 
 	if (!therm || !therm->attr_get || !therm->fan_get)
 		return -EOPNOTSUPP;
@@ -496,7 +496,7 @@ nouveau_power_read(struct device *dev, u32 attr, int channel, long *val)
 {
 	struct drm_device *drm_dev = dev_get_drvdata(dev);
 	struct nouveau_drm *drm = nouveau_drm(drm_dev);
-	struct nvkm_iccsense *iccsense = nvxx_iccsense(&drm->client.device);
+	struct nvkm_iccsense *iccsense = nvxx_iccsense(drm);
 
 	if (!iccsense)
 		return -EOPNOTSUPP;
@@ -525,7 +525,7 @@ nouveau_temp_write(struct device *dev, u32 attr, int channel, long val)
 {
 	struct drm_device *drm_dev = dev_get_drvdata(dev);
 	struct nouveau_drm *drm = nouveau_drm(drm_dev);
-	struct nvkm_therm *therm = nvxx_therm(&drm->client.device);
+	struct nvkm_therm *therm = nvxx_therm(drm);
 
 	if (!therm || !therm->attr_set)
 		return -EOPNOTSUPP;
@@ -559,7 +559,7 @@ nouveau_pwm_write(struct device *dev, u32 attr, int channel, long val)
 {
 	struct drm_device *drm_dev = dev_get_drvdata(dev);
 	struct nouveau_drm *drm = nouveau_drm(drm_dev);
-	struct nvkm_therm *therm = nvxx_therm(&drm->client.device);
+	struct nvkm_therm *therm = nvxx_therm(drm);
 
 	if (!therm || !therm->attr_set)
 		return -EOPNOTSUPP;
@@ -664,9 +664,9 @@ nouveau_hwmon_init(struct drm_device *dev)
 {
 #if defined(CONFIG_HWMON) || (defined(MODULE) && defined(CONFIG_HWMON_MODULE))
 	struct nouveau_drm *drm = nouveau_drm(dev);
-	struct nvkm_iccsense *iccsense = nvxx_iccsense(&drm->client.device);
-	struct nvkm_therm *therm = nvxx_therm(&drm->client.device);
-	struct nvkm_volt *volt = nvxx_volt(&drm->client.device);
+	struct nvkm_iccsense *iccsense = nvxx_iccsense(drm);
+	struct nvkm_therm *therm = nvxx_therm(drm);
+	struct nvkm_volt *volt = nvxx_volt(drm);
 	const struct attribute_group *special_groups[N_ATTR_GROUPS];
 	struct nouveau_hwmon *hwmon;
 	struct device *hwmon_dev;
diff --git a/drivers/gpu/drm/nouveau/nouveau_led.c b/drivers/gpu/drm/nouveau/nouveau_led.c
index 2c5e0628da12..ac950518a820 100644
--- a/drivers/gpu/drm/nouveau/nouveau_led.c
+++ b/drivers/gpu/drm/nouveau/nouveau_led.c
@@ -78,7 +78,7 @@ int
 nouveau_led_init(struct drm_device *dev)
 {
 	struct nouveau_drm *drm = nouveau_drm(dev);
-	struct nvkm_gpio *gpio = nvxx_gpio(&drm->client.device);
+	struct nvkm_gpio *gpio = nvxx_gpio(drm);
 	struct dcb_gpio_func logo_led;
 	int ret;
 
diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c
index fc1d6fd94480..36f5be963851 100644
--- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
@@ -261,7 +261,7 @@ nouveau_ttm_fini_gtt(struct nouveau_drm *drm)
 int
 nouveau_ttm_init(struct nouveau_drm *drm)
 {
-	struct nvkm_device *device = nvxx_device(&drm->client.device);
+	struct nvkm_device *device = nvxx_device(drm);
 	struct nvkm_pci *pci = device->pci;
 	struct nvif_mmu *mmu = &drm->client.mmu;
 	struct drm_device *dev = drm->dev;
@@ -348,7 +348,7 @@ nouveau_ttm_init(struct nouveau_drm *drm)
 void
 nouveau_ttm_fini(struct nouveau_drm *drm)
 {
-	struct nvkm_device *device = nvxx_device(&drm->client.device);
+	struct nvkm_device *device = nvxx_device(drm);
 
 	nouveau_ttm_fini_vram(drm);
 	nouveau_ttm_fini_gtt(drm);
diff --git a/drivers/gpu/drm/nouveau/nvif/device.c b/drivers/gpu/drm/nouveau/nvif/device.c
index 480034b5563b..131286239b51 100644
--- a/drivers/gpu/drm/nouveau/nvif/device.c
+++ b/drivers/gpu/drm/nouveau/nvif/device.c
@@ -85,7 +85,6 @@ nvif_device_ctor(struct nvif_client *client, const char *name, struct nvif_devic
 
 	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) {
 		/*FIXME: remove after moving users to device->impl */
diff --git a/drivers/gpu/drm/nouveau/nvif/object.c b/drivers/gpu/drm/nouveau/nvif/object.c
index 6044634f20b8..8d4d7a93b92f 100644
--- a/drivers/gpu/drm/nouveau/nvif/object.c
+++ b/drivers/gpu/drm/nouveau/nvif/object.c
@@ -90,7 +90,6 @@ nvif_object_ctor(struct nvif_object *parent, const char *name, u32 handle, s32 o
 	object->name = name ?: "nvifObject";
 	object->handle = handle;
 	object->oclass = oclass;
-	object->priv = NULL;
 	object->map.ptr = NULL;
 	object->map.size = 0;
 }
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 154/156] drm/nouveau: remove remaining usage of nvif_device.info
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (152 preceding siblings ...)
  2024-04-16 23:39 ` [PATCH 153/156] drm/nouveau: pass nouveau_drm to nvxx_* Ben Skeggs
@ 2024-04-16 23:40 ` Ben Skeggs
  2024-04-16 23:40 ` [PATCH 155/156] drm/nouveau: remove remaining usage of nvif_device.object.map Ben Skeggs
                   ` (3 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:40 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- complete the switch to nvif_device.impl

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/dispnv04/arb.c        |  7 +-
 drivers/gpu/drm/nouveau/dispnv04/crtc.c       | 34 +++++-----
 drivers/gpu/drm/nouveau/dispnv04/cursor.c     |  2 +-
 drivers/gpu/drm/nouveau/dispnv04/dac.c        |  6 +-
 drivers/gpu/drm/nouveau/dispnv04/dfp.c        |  8 +--
 drivers/gpu/drm/nouveau/dispnv04/disp.h       |  4 +-
 drivers/gpu/drm/nouveau/dispnv04/hw.c         | 66 +++++++++----------
 drivers/gpu/drm/nouveau/dispnv04/hw.h         | 25 ++++---
 drivers/gpu/drm/nouveau/dispnv04/overlay.c    | 13 ++--
 drivers/gpu/drm/nouveau/dispnv04/tvnv17.c     | 10 +--
 drivers/gpu/drm/nouveau/dispnv50/disp.c       |  2 +-
 drivers/gpu/drm/nouveau/dispnv50/wndw.c       | 12 ++--
 drivers/gpu/drm/nouveau/include/nvif/device.h |  3 -
 drivers/gpu/drm/nouveau/nouveau_abi16.c       | 50 ++++++++------
 drivers/gpu/drm/nouveau/nouveau_backlight.c   | 22 +++----
 drivers/gpu/drm/nouveau/nouveau_bios.c        | 12 ++--
 drivers/gpu/drm/nouveau/nouveau_bo.c          | 38 +++++------
 drivers/gpu/drm/nouveau/nouveau_chan.c        | 20 +++---
 drivers/gpu/drm/nouveau/nouveau_connector.c   | 22 +++----
 drivers/gpu/drm/nouveau/nouveau_display.c     | 27 ++++----
 drivers/gpu/drm/nouveau/nouveau_dmem.c        |  2 +-
 drivers/gpu/drm/nouveau/nouveau_drm.c         | 14 ++--
 drivers/gpu/drm/nouveau/nouveau_gem.c         | 13 ++--
 drivers/gpu/drm/nouveau/nouveau_sgdma.c       |  2 +-
 drivers/gpu/drm/nouveau/nouveau_svm.c         |  2 +-
 drivers/gpu/drm/nouveau/nouveau_ttm.c         | 21 +++---
 drivers/gpu/drm/nouveau/nouveau_vga.c         |  8 +--
 drivers/gpu/drm/nouveau/nv84_fence.c          |  2 +-
 drivers/gpu/drm/nouveau/nvif/device.c         | 14 ----
 29 files changed, 224 insertions(+), 237 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv04/arb.c b/drivers/gpu/drm/nouveau/dispnv04/arb.c
index 1d3542d6006b..8a56b0868128 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/arb.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/arb.c
@@ -193,8 +193,7 @@ static void
 nv04_update_arb(struct drm_device *dev, int VClk, int bpp,
 		int *burst, int *lwm)
 {
-	struct nouveau_drm *drm = nouveau_drm(dev);
-	struct nvif_object *device = &nouveau_drm(dev)->client.device.object;
+	struct nvif_device *device = &nouveau_drm(dev)->device;
 	struct nv_fifo_info fifo_data;
 	struct nv_sim_state sim_data;
 	int MClk = nouveau_hw_get_clock(dev, PLL_MEMORY);
@@ -226,7 +225,7 @@ nv04_update_arb(struct drm_device *dev, int VClk, int bpp,
 		sim_data.mem_page_miss = ((cfg1 >> 4) & 0xf) + ((cfg1 >> 31) & 0x1);
 	}
 
-	if (drm->client.device.info.family == NV_DEVICE_INFO_V0_TNT)
+	if (device->impl->family == NVIF_DEVICE_TNT)
 		nv04_calc_arb(&fifo_data, &sim_data);
 	else
 		nv10_calc_arb(&fifo_data, &sim_data);
@@ -254,7 +253,7 @@ nouveau_calc_arb(struct drm_device *dev, int vclk, int bpp, int *burst, int *lwm
 	struct nouveau_drm *drm = nouveau_drm(dev);
 	struct pci_dev *pdev = to_pci_dev(dev->dev);
 
-	if (drm->client.device.info.family < NV_DEVICE_INFO_V0_KELVIN)
+	if (drm->device.impl->family < NVIF_DEVICE_KELVIN)
 		nv04_update_arb(dev, vclk, bpp, burst, lwm);
 	else if ((pdev->device & 0xfff0) == 0x0240 /*CHIPSET_C51*/ ||
 		 (pdev->device & 0xfff0) == 0x03d0 /*CHIPSET_C512*/) {
diff --git a/drivers/gpu/drm/nouveau/dispnv04/crtc.c b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
index 90e549541981..7f83927ddf96 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/crtc.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
@@ -143,7 +143,7 @@ static void nv_crtc_calc_state_ext(struct drm_crtc *crtc, struct drm_display_mod
 	 * has yet been observed in allowing the use a single stage pll on all
 	 * nv43 however.  the behaviour of single stage use is untested on nv40
 	 */
-	if (drm->client.device.info.chipset > 0x40 && dot_clock <= (pll_lim.vco1.max_freq / 2))
+	if (drm->device.impl->chipset > 0x40 && dot_clock <= (pll_lim.vco1.max_freq / 2))
 		memset(&pll_lim.vco2, 0, sizeof(pll_lim.vco2));
 
 
@@ -153,10 +153,10 @@ static void nv_crtc_calc_state_ext(struct drm_crtc *crtc, struct drm_display_mod
 	state->pllsel &= PLLSEL_VPLL1_MASK | PLLSEL_VPLL2_MASK | PLLSEL_TV_MASK;
 
 	/* The blob uses this always, so let's do the same */
-	if (drm->client.device.info.family == NV_DEVICE_INFO_V0_CURIE)
+	if (drm->device.impl->family == NVIF_DEVICE_CURIE)
 		state->pllsel |= NV_PRAMDAC_PLL_COEFF_SELECT_USE_VPLL2_TRUE;
 	/* again nv40 and some nv43 act more like nv3x as described above */
-	if (drm->client.device.info.chipset < 0x41)
+	if (drm->device.impl->chipset < 0x41)
 		state->pllsel |= NV_PRAMDAC_PLL_COEFF_SELECT_SOURCE_PROG_MPLL |
 				 NV_PRAMDAC_PLL_COEFF_SELECT_SOURCE_PROG_NVPLL;
 	state->pllsel |= nv_crtc->index ? PLLSEL_VPLL2_MASK : PLLSEL_VPLL1_MASK;
@@ -275,7 +275,7 @@ nv_crtc_mode_set_vga(struct drm_crtc *crtc, struct drm_display_mode *mode)
 		horizEnd = horizTotal - 2;
 		horizBlankEnd = horizTotal + 4;
 #if 0
-		if (dev->overlayAdaptor && drm->client.device.info.family >= NV_DEVICE_INFO_V0_CELSIUS)
+		if (dev->overlayAdaptor && drm->device.impl->family >= NVIF_DEVICE_CELSIUS)
 			/* This reportedly works around some video overlay bandwidth problems */
 			horizTotal += 2;
 #endif
@@ -510,7 +510,7 @@ nv_crtc_mode_set_regs(struct drm_crtc *crtc, struct drm_display_mode * mode)
 	regp->cursor_cfg = NV_PCRTC_CURSOR_CONFIG_CUR_LINES_64 |
 			     NV_PCRTC_CURSOR_CONFIG_CUR_PIXELS_64 |
 			     NV_PCRTC_CURSOR_CONFIG_ADDRESS_SPACE_PNVM;
-	if (drm->client.device.info.chipset >= 0x11)
+	if (drm->device.impl->chipset >= 0x11)
 		regp->cursor_cfg |= NV_PCRTC_CURSOR_CONFIG_CUR_BPP_32;
 	if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
 		regp->cursor_cfg |= NV_PCRTC_CURSOR_CONFIG_DOUBLE_SCAN_ENABLE;
@@ -551,26 +551,26 @@ nv_crtc_mode_set_regs(struct drm_crtc *crtc, struct drm_display_mode * mode)
 	 * 1 << 30 on 0x60.830), for no apparent reason */
 	regp->CRTC[NV_CIO_CRE_59] = off_chip_digital;
 
-	if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_RANKINE)
+	if (drm->device.impl->family >= NVIF_DEVICE_RANKINE)
 		regp->CRTC[0x9f] = off_chip_digital ? 0x11 : 0x1;
 
 	regp->crtc_830 = mode->crtc_vdisplay - 3;
 	regp->crtc_834 = mode->crtc_vdisplay - 1;
 
-	if (drm->client.device.info.family == NV_DEVICE_INFO_V0_CURIE)
+	if (drm->device.impl->family == NVIF_DEVICE_CURIE)
 		/* This is what the blob does */
 		regp->crtc_850 = NVReadCRTC(dev, 0, NV_PCRTC_850);
 
-	if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_RANKINE)
+	if (drm->device.impl->family >= NVIF_DEVICE_RANKINE)
 		regp->gpio_ext = NVReadCRTC(dev, 0, NV_PCRTC_GPIO_EXT);
 
-	if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_CELSIUS)
+	if (drm->device.impl->family >= NVIF_DEVICE_CELSIUS)
 		regp->crtc_cfg = NV10_PCRTC_CONFIG_START_ADDRESS_HSYNC;
 	else
 		regp->crtc_cfg = NV04_PCRTC_CONFIG_START_ADDRESS_HSYNC;
 
 	/* Some misc regs */
-	if (drm->client.device.info.family == NV_DEVICE_INFO_V0_CURIE) {
+	if (drm->device.impl->family == NVIF_DEVICE_CURIE) {
 		regp->CRTC[NV_CIO_CRE_85] = 0xFF;
 		regp->CRTC[NV_CIO_CRE_86] = 0x1;
 	}
@@ -582,7 +582,7 @@ nv_crtc_mode_set_regs(struct drm_crtc *crtc, struct drm_display_mode * mode)
 
 	/* Generic PRAMDAC regs */
 
-	if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_CELSIUS)
+	if (drm->device.impl->family >= NVIF_DEVICE_CELSIUS)
 		/* Only bit that bios and blob set. */
 		regp->nv10_cursync = (1 << 25);
 
@@ -591,7 +591,7 @@ nv_crtc_mode_set_regs(struct drm_crtc *crtc, struct drm_display_mode * mode)
 				NV_PRAMDAC_GENERAL_CONTROL_PIXMIX_ON;
 	if (fb->format->depth == 16)
 		regp->ramdac_gen_ctrl |= NV_PRAMDAC_GENERAL_CONTROL_ALT_MODE_SEL;
-	if (drm->client.device.info.chipset >= 0x11)
+	if (drm->device.impl->chipset >= 0x11)
 		regp->ramdac_gen_ctrl |= NV_PRAMDAC_GENERAL_CONTROL_PIPE_LONG;
 
 	regp->ramdac_630 = 0; /* turn off green mode (tv test pattern?) */
@@ -655,7 +655,7 @@ nv_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mode,
 
 	nv_crtc_mode_set_vga(crtc, adjusted_mode);
 	/* calculated in nv04_dfp_prepare, nv40 needs it written before calculating PLLs */
-	if (drm->client.device.info.family == NV_DEVICE_INFO_V0_CURIE)
+	if (drm->device.impl->family == NVIF_DEVICE_CURIE)
 		NVWriteRAMDAC(dev, 0, NV_PRAMDAC_SEL_CLK, nv04_display(dev)->mode_reg.sel_clk);
 	nv_crtc_mode_set_regs(crtc, adjusted_mode);
 	nv_crtc_calc_state_ext(crtc, mode, adjusted_mode->clock);
@@ -716,7 +716,7 @@ static void nv_crtc_prepare(struct drm_crtc *crtc)
 
 	/* Some more preparation. */
 	NVWriteCRTC(dev, nv_crtc->index, NV_PCRTC_CONFIG, NV_PCRTC_CONFIG_START_ADDRESS_NON_VGA);
-	if (drm->client.device.info.family == NV_DEVICE_INFO_V0_CURIE) {
+	if (drm->device.impl->family == NVIF_DEVICE_CURIE) {
 		uint32_t reg900 = NVReadRAMDAC(dev, nv_crtc->index, NV_PRAMDAC_900);
 		NVWriteRAMDAC(dev, nv_crtc->index, NV_PRAMDAC_900, reg900 & ~0x10000);
 	}
@@ -892,7 +892,7 @@ nv04_crtc_do_mode_set_base(struct drm_crtc *crtc,
 	crtc_wr_cio_state(crtc, regp, NV_CIO_CRE_FF_INDEX);
 	crtc_wr_cio_state(crtc, regp, NV_CIO_CRE_FFLWM__INDEX);
 
-	if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_KELVIN) {
+	if (drm->device.impl->family >= NVIF_DEVICE_KELVIN) {
 		regp->CRTC[NV_CIO_CRE_47] = arb_lwm >> 8;
 		crtc_wr_cio_state(crtc, regp, NV_CIO_CRE_47);
 	}
@@ -965,7 +965,7 @@ static void nv11_cursor_upload(struct drm_device *dev, struct nouveau_bo *src,
 		{
 			struct nouveau_drm *drm = nouveau_drm(dev);
 
-			if (drm->client.device.info.chipset == 0x11) {
+			if (drm->device.impl->chipset == 0x11) {
 				pixel = ((pixel & 0x000000ff) << 24) |
 					((pixel & 0x0000ff00) << 8) |
 					((pixel & 0x00ff0000) >> 8) |
@@ -1006,7 +1006,7 @@ nv04_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv,
 	if (ret)
 		goto out;
 
-	if (drm->client.device.info.chipset >= 0x11)
+	if (drm->device.impl->chipset >= 0x11)
 		nv11_cursor_upload(dev, cursor, nv_crtc->cursor.nvbo);
 	else
 		nv04_cursor_upload(dev, cursor, nv_crtc->cursor.nvbo);
diff --git a/drivers/gpu/drm/nouveau/dispnv04/cursor.c b/drivers/gpu/drm/nouveau/dispnv04/cursor.c
index 4c6440d29c3f..625c66da3367 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/cursor.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/cursor.c
@@ -55,7 +55,7 @@ nv04_cursor_set_offset(struct nouveau_crtc *nv_crtc, uint32_t offset)
 	crtc_wr_cio_state(crtc, regp, NV_CIO_CRE_HCUR_ADDR0_INDEX);
 	crtc_wr_cio_state(crtc, regp, NV_CIO_CRE_HCUR_ADDR1_INDEX);
 	crtc_wr_cio_state(crtc, regp, NV_CIO_CRE_HCUR_ADDR2_INDEX);
-	if (drm->client.device.info.family == NV_DEVICE_INFO_V0_CURIE)
+	if (drm->device.impl->family == NVIF_DEVICE_CURIE)
 		nv_fix_nv40_hw_cursor(dev, nv_crtc->index);
 }
 
diff --git a/drivers/gpu/drm/nouveau/dispnv04/dac.c b/drivers/gpu/drm/nouveau/dispnv04/dac.c
index 2e12bf136607..4d8e34274c4e 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/dac.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/dac.c
@@ -236,7 +236,7 @@ uint32_t nv17_dac_sample_load(struct drm_encoder *encoder)
 {
 	struct drm_device *dev = encoder->dev;
 	struct nouveau_drm *drm = nouveau_drm(dev);
-	struct nvif_object *device = &nouveau_drm(dev)->client.device.object;
+	struct nvif_device *device = &nouveau_drm(dev)->device;
 	struct nvkm_gpio *gpio = nvxx_gpio(drm);
 	struct dcb_output *dcb = nouveau_encoder(encoder)->dcb;
 	uint32_t sample, testval, regoffset = nv04_dac_output_offset(encoder);
@@ -288,7 +288,7 @@ uint32_t nv17_dac_sample_load(struct drm_encoder *encoder)
 	/* nv driver and nv31 use 0xfffffeee, nv34 and 6600 use 0xfffffece */
 	routput = (saved_routput & 0xfffffece) | head << 8;
 
-	if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_CURIE) {
+	if (device->impl->family >= NVIF_DEVICE_CURIE) {
 		if (dcb->type == DCB_OUTPUT_TV)
 			routput |= 0x1a << 16;
 		else
@@ -403,7 +403,7 @@ static void nv04_dac_mode_set(struct drm_encoder *encoder,
 	}
 
 	/* This could use refinement for flatpanels, but it should work this way */
-	if (drm->client.device.info.chipset < 0x44)
+	if (drm->device.impl->chipset < 0x44)
 		NVWriteRAMDAC(dev, 0, NV_PRAMDAC_TEST_CONTROL + nv04_dac_output_offset(encoder), 0xf0000000);
 	else
 		NVWriteRAMDAC(dev, 0, NV_PRAMDAC_TEST_CONTROL + nv04_dac_output_offset(encoder), 0x00100000);
diff --git a/drivers/gpu/drm/nouveau/dispnv04/dfp.c b/drivers/gpu/drm/nouveau/dispnv04/dfp.c
index 504c421aa176..da2a759dbaab 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/dfp.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/dfp.c
@@ -282,7 +282,7 @@ static void nv04_dfp_mode_set(struct drm_encoder *encoder,
 			      struct drm_display_mode *adjusted_mode)
 {
 	struct drm_device *dev = encoder->dev;
-	struct nvif_object *device = &nouveau_drm(dev)->client.device.object;
+	struct nvif_device *device = &nouveau_drm(dev)->device;
 	struct nouveau_drm *drm = nouveau_drm(dev);
 	struct nouveau_crtc *nv_crtc = nouveau_crtc(encoder->crtc);
 	struct nv04_crtc_reg *regp = &nv04_display(dev)->mode_reg.crtc_reg[nv_crtc->index];
@@ -418,7 +418,7 @@ static void nv04_dfp_mode_set(struct drm_encoder *encoder,
 	if ((nv_connector->dithering_mode == DITHERING_MODE_ON) ||
 	    (nv_connector->dithering_mode == DITHERING_MODE_AUTO &&
 	     fb->format->depth > connector->display_info.bpc * 3)) {
-		if (drm->client.device.info.chipset == 0x11)
+		if (device->impl->chipset == 0x11)
 			regp->dither = savep->dither | 0x00010000;
 		else {
 			int i;
@@ -429,7 +429,7 @@ static void nv04_dfp_mode_set(struct drm_encoder *encoder,
 			}
 		}
 	} else {
-		if (drm->client.device.info.chipset != 0x11) {
+		if (device->impl->chipset != 0x11) {
 			/* reset them */
 			int i;
 			for (i = 0; i < 3; i++) {
@@ -465,7 +465,7 @@ static void nv04_dfp_commit(struct drm_encoder *encoder)
 		NVReadRAMDAC(dev, head, NV_PRAMDAC_FP_TG_CONTROL);
 
 	/* This could use refinement for flatpanels, but it should work this way */
-	if (drm->client.device.info.chipset < 0x44)
+	if (drm->device.impl->chipset < 0x44)
 		NVWriteRAMDAC(dev, 0, NV_PRAMDAC_TEST_CONTROL + nv04_dac_output_offset(encoder), 0xf0000000);
 	else
 		NVWriteRAMDAC(dev, 0, NV_PRAMDAC_TEST_CONTROL + nv04_dac_output_offset(encoder), 0x00100000);
diff --git a/drivers/gpu/drm/nouveau/dispnv04/disp.h b/drivers/gpu/drm/nouveau/dispnv04/disp.h
index 85ec0f534392..8eba76ab880e 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/disp.h
+++ b/drivers/gpu/drm/nouveau/dispnv04/disp.h
@@ -135,7 +135,7 @@ nv_two_heads(struct drm_device *dev)
 	struct nouveau_drm *drm = nouveau_drm(dev);
 	const int impl = to_pci_dev(dev->dev)->device & 0x0ff0;
 
-	if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_CELSIUS && impl != 0x0100 &&
+	if (drm->device.impl->family >= NVIF_DEVICE_CELSIUS && impl != 0x0100 &&
 	    impl != 0x0150 && impl != 0x01a0 && impl != 0x0200)
 		return true;
 
@@ -154,7 +154,7 @@ nv_two_reg_pll(struct drm_device *dev)
 	struct nouveau_drm *drm = nouveau_drm(dev);
 	const int impl = to_pci_dev(dev->dev)->device & 0x0ff0;
 
-	if (impl == 0x0310 || impl == 0x0340 || drm->client.device.info.family >= NV_DEVICE_INFO_V0_CURIE)
+	if (impl == 0x0310 || impl == 0x0340 || drm->device.impl->family >= NVIF_DEVICE_CURIE)
 		return true;
 	return false;
 }
diff --git a/drivers/gpu/drm/nouveau/dispnv04/hw.c b/drivers/gpu/drm/nouveau/dispnv04/hw.c
index 8b376f9c8746..ab240df4d85c 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/hw.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/hw.c
@@ -89,7 +89,7 @@ NVSetOwner(struct drm_device *dev, int owner)
 	if (owner == 1)
 		owner *= 3;
 
-	if (drm->client.device.info.chipset == 0x11) {
+	if (drm->device.impl->chipset == 0x11) {
 		/* This might seem stupid, but the blob does it and
 		 * omitting it often locks the system up.
 		 */
@@ -100,7 +100,7 @@ NVSetOwner(struct drm_device *dev, int owner)
 	/* CR44 is always changed on CRTC0 */
 	NVWriteVgaCrtc(dev, 0, NV_CIO_CRE_44, owner);
 
-	if (drm->client.device.info.chipset == 0x11) {	/* set me harder */
+	if (drm->device.impl->chipset == 0x11) {	/* set me harder */
 		NVWriteVgaCrtc(dev, 0, NV_CIO_CRE_2E, owner);
 		NVWriteVgaCrtc(dev, 0, NV_CIO_CRE_2E, owner);
 	}
@@ -149,7 +149,7 @@ nouveau_hw_decode_pll(struct drm_device *dev, uint32_t reg1, uint32_t pll1,
 		pllvals->NM1 = pll1 & 0xffff;
 		if (nv_two_reg_pll(dev) && pll2 & NV31_RAMDAC_ENABLE_VCO2)
 			pllvals->NM2 = pll2 & 0xffff;
-		else if (drm->client.device.info.chipset == 0x30 || drm->client.device.info.chipset == 0x35) {
+		else if (drm->device.impl->chipset == 0x30 || drm->device.impl->chipset == 0x35) {
 			pllvals->M1 &= 0xf; /* only 4 bits */
 			if (pll1 & NV30_RAMDAC_ENABLE_VCO2) {
 				pllvals->M2 = (pll1 >> 4) & 0x7;
@@ -165,7 +165,7 @@ nouveau_hw_get_pllvals(struct drm_device *dev, enum nvbios_pll_type plltype,
 		       struct nvkm_pll_vals *pllvals)
 {
 	struct nouveau_drm *drm = nouveau_drm(dev);
-	struct nvif_object *device = &drm->client.device.object;
+	struct nvif_device *device = &drm->device;
 	struct nvkm_bios *bios = nvxx_bios(drm);
 	uint32_t reg1, pll1, pll2 = 0;
 	struct nvbios_pll pll_lim;
@@ -184,7 +184,7 @@ nouveau_hw_get_pllvals(struct drm_device *dev, enum nvbios_pll_type plltype,
 		pll2 = nvif_rd32(device, reg2);
 	}
 
-	if (drm->client.device.info.family == NV_DEVICE_INFO_V0_CELSIUS && reg1 >= NV_PRAMDAC_VPLL_COEFF) {
+	if (device->impl->family == NVIF_DEVICE_CELSIUS && reg1 >= NV_PRAMDAC_VPLL_COEFF) {
 		uint32_t ramdac580 = NVReadRAMDAC(dev, 0, NV_PRAMDAC_580);
 
 		/* check whether vpll has been forced into single stage mode */
@@ -397,21 +397,21 @@ nv_save_state_ramdac(struct drm_device *dev, int head,
 	struct nv04_crtc_reg *regp = &state->crtc_reg[head];
 	int i;
 
-	if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_CELSIUS)
+	if (drm->device.impl->family >= NVIF_DEVICE_CELSIUS)
 		regp->nv10_cursync = NVReadRAMDAC(dev, head, NV_RAMDAC_NV10_CURSYNC);
 
 	nouveau_hw_get_pllvals(dev, head ? PLL_VPLL1 : PLL_VPLL0, &regp->pllvals);
 	state->pllsel = NVReadRAMDAC(dev, 0, NV_PRAMDAC_PLL_COEFF_SELECT);
 	if (nv_two_heads(dev))
 		state->sel_clk = NVReadRAMDAC(dev, 0, NV_PRAMDAC_SEL_CLK);
-	if (drm->client.device.info.chipset == 0x11)
+	if (drm->device.impl->chipset == 0x11)
 		regp->dither = NVReadRAMDAC(dev, head, NV_RAMDAC_DITHER_NV11);
 
 	regp->ramdac_gen_ctrl = NVReadRAMDAC(dev, head, NV_PRAMDAC_GENERAL_CONTROL);
 
 	if (nv_gf4_disp_arch(dev))
 		regp->ramdac_630 = NVReadRAMDAC(dev, head, NV_PRAMDAC_630);
-	if (drm->client.device.info.chipset >= 0x30)
+	if (drm->device.impl->chipset >= 0x30)
 		regp->ramdac_634 = NVReadRAMDAC(dev, head, NV_PRAMDAC_634);
 
 	regp->tv_setup = NVReadRAMDAC(dev, head, NV_PRAMDAC_TV_SETUP);
@@ -453,7 +453,7 @@ nv_save_state_ramdac(struct drm_device *dev, int head,
 	if (nv_gf4_disp_arch(dev))
 		regp->ramdac_8c0 = NVReadRAMDAC(dev, head, NV_PRAMDAC_8C0);
 
-	if (drm->client.device.info.family == NV_DEVICE_INFO_V0_CURIE) {
+	if (drm->device.impl->family == NVIF_DEVICE_CURIE) {
 		regp->ramdac_a20 = NVReadRAMDAC(dev, head, NV_PRAMDAC_A20);
 		regp->ramdac_a24 = NVReadRAMDAC(dev, head, NV_PRAMDAC_A24);
 		regp->ramdac_a34 = NVReadRAMDAC(dev, head, NV_PRAMDAC_A34);
@@ -474,21 +474,21 @@ nv_load_state_ramdac(struct drm_device *dev, int head,
 	uint32_t pllreg = head ? NV_RAMDAC_VPLL2 : NV_PRAMDAC_VPLL_COEFF;
 	int i;
 
-	if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_CELSIUS)
+	if (drm->device.impl->family >= NVIF_DEVICE_CELSIUS)
 		NVWriteRAMDAC(dev, head, NV_RAMDAC_NV10_CURSYNC, regp->nv10_cursync);
 
 	clk->pll_prog(clk, pllreg, &regp->pllvals);
 	NVWriteRAMDAC(dev, 0, NV_PRAMDAC_PLL_COEFF_SELECT, state->pllsel);
 	if (nv_two_heads(dev))
 		NVWriteRAMDAC(dev, 0, NV_PRAMDAC_SEL_CLK, state->sel_clk);
-	if (drm->client.device.info.chipset == 0x11)
+	if (drm->device.impl->chipset == 0x11)
 		NVWriteRAMDAC(dev, head, NV_RAMDAC_DITHER_NV11, regp->dither);
 
 	NVWriteRAMDAC(dev, head, NV_PRAMDAC_GENERAL_CONTROL, regp->ramdac_gen_ctrl);
 
 	if (nv_gf4_disp_arch(dev))
 		NVWriteRAMDAC(dev, head, NV_PRAMDAC_630, regp->ramdac_630);
-	if (drm->client.device.info.chipset >= 0x30)
+	if (drm->device.impl->chipset >= 0x30)
 		NVWriteRAMDAC(dev, head, NV_PRAMDAC_634, regp->ramdac_634);
 
 	NVWriteRAMDAC(dev, head, NV_PRAMDAC_TV_SETUP, regp->tv_setup);
@@ -525,7 +525,7 @@ nv_load_state_ramdac(struct drm_device *dev, int head,
 	if (nv_gf4_disp_arch(dev))
 		NVWriteRAMDAC(dev, head, NV_PRAMDAC_8C0, regp->ramdac_8c0);
 
-	if (drm->client.device.info.family == NV_DEVICE_INFO_V0_CURIE) {
+	if (drm->device.impl->family == NVIF_DEVICE_CURIE) {
 		NVWriteRAMDAC(dev, head, NV_PRAMDAC_A20, regp->ramdac_a20);
 		NVWriteRAMDAC(dev, head, NV_PRAMDAC_A24, regp->ramdac_a24);
 		NVWriteRAMDAC(dev, head, NV_PRAMDAC_A34, regp->ramdac_a34);
@@ -606,10 +606,10 @@ nv_save_state_ext(struct drm_device *dev, int head,
 	rd_cio_state(dev, head, regp, NV_CIO_CRE_FFLWM__INDEX);
 	rd_cio_state(dev, head, regp, NV_CIO_CRE_21);
 
-	if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_KELVIN)
+	if (drm->device.impl->family >= NVIF_DEVICE_KELVIN)
 		rd_cio_state(dev, head, regp, NV_CIO_CRE_47);
 
-	if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_RANKINE)
+	if (drm->device.impl->family >= NVIF_DEVICE_RANKINE)
 		rd_cio_state(dev, head, regp, 0x9f);
 
 	rd_cio_state(dev, head, regp, NV_CIO_CRE_49);
@@ -618,14 +618,14 @@ nv_save_state_ext(struct drm_device *dev, int head,
 	rd_cio_state(dev, head, regp, NV_CIO_CRE_HCUR_ADDR2_INDEX);
 	rd_cio_state(dev, head, regp, NV_CIO_CRE_ILACE__INDEX);
 
-	if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_CELSIUS) {
+	if (drm->device.impl->family >= NVIF_DEVICE_CELSIUS) {
 		regp->crtc_830 = NVReadCRTC(dev, head, NV_PCRTC_830);
 		regp->crtc_834 = NVReadCRTC(dev, head, NV_PCRTC_834);
 
-		if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_RANKINE)
+		if (drm->device.impl->family >= NVIF_DEVICE_RANKINE)
 			regp->gpio_ext = NVReadCRTC(dev, head, NV_PCRTC_GPIO_EXT);
 
-		if (drm->client.device.info.family == NV_DEVICE_INFO_V0_CURIE)
+		if (drm->device.impl->family == NVIF_DEVICE_CURIE)
 			regp->crtc_850 = NVReadCRTC(dev, head, NV_PCRTC_850);
 
 		if (nv_two_heads(dev))
@@ -637,7 +637,7 @@ nv_save_state_ext(struct drm_device *dev, int head,
 
 	rd_cio_state(dev, head, regp, NV_CIO_CRE_SCRATCH3__INDEX);
 	rd_cio_state(dev, head, regp, NV_CIO_CRE_SCRATCH4__INDEX);
-	if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_CELSIUS) {
+	if (drm->device.impl->family >= NVIF_DEVICE_CELSIUS) {
 		rd_cio_state(dev, head, regp, NV_CIO_CRE_EBR_INDEX);
 		rd_cio_state(dev, head, regp, NV_CIO_CRE_CSB);
 		rd_cio_state(dev, head, regp, NV_CIO_CRE_4B);
@@ -666,12 +666,12 @@ nv_load_state_ext(struct drm_device *dev, int head,
 		  struct nv04_mode_state *state)
 {
 	struct nouveau_drm *drm = nouveau_drm(dev);
-	struct nvif_object *device = &drm->client.device.object;
+	struct nvif_device *device = &drm->device;
 	struct nv04_crtc_reg *regp = &state->crtc_reg[head];
 	uint32_t reg900;
 	int i;
 
-	if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_CELSIUS) {
+	if (device->impl->family >= NVIF_DEVICE_CELSIUS) {
 		if (nv_two_heads(dev))
 			/* setting ENGINE_CTRL (EC) *must* come before
 			 * CIO_CRE_LCD, as writing CRE_LCD sets bits 16 & 17 in
@@ -683,20 +683,20 @@ nv_load_state_ext(struct drm_device *dev, int head,
 		nvif_wr32(device, NV_PVIDEO_INTR_EN, 0);
 		nvif_wr32(device, NV_PVIDEO_OFFSET_BUFF(0), 0);
 		nvif_wr32(device, NV_PVIDEO_OFFSET_BUFF(1), 0);
-		nvif_wr32(device, NV_PVIDEO_LIMIT(0), drm->client.device.info.ram_size - 1);
-		nvif_wr32(device, NV_PVIDEO_LIMIT(1), drm->client.device.info.ram_size - 1);
-		nvif_wr32(device, NV_PVIDEO_UVPLANE_LIMIT(0), drm->client.device.info.ram_size - 1);
-		nvif_wr32(device, NV_PVIDEO_UVPLANE_LIMIT(1), drm->client.device.info.ram_size - 1);
+		nvif_wr32(device, NV_PVIDEO_LIMIT(0), device->impl->ram_size - 1);
+		nvif_wr32(device, NV_PVIDEO_LIMIT(1), device->impl->ram_size - 1);
+		nvif_wr32(device, NV_PVIDEO_UVPLANE_LIMIT(0), device->impl->ram_size - 1);
+		nvif_wr32(device, NV_PVIDEO_UVPLANE_LIMIT(1), device->impl->ram_size - 1);
 		nvif_wr32(device, NV_PBUS_POWERCTRL_2, 0);
 
 		NVWriteCRTC(dev, head, NV_PCRTC_CURSOR_CONFIG, regp->cursor_cfg);
 		NVWriteCRTC(dev, head, NV_PCRTC_830, regp->crtc_830);
 		NVWriteCRTC(dev, head, NV_PCRTC_834, regp->crtc_834);
 
-		if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_RANKINE)
+		if (device->impl->family >= NVIF_DEVICE_RANKINE)
 			NVWriteCRTC(dev, head, NV_PCRTC_GPIO_EXT, regp->gpio_ext);
 
-		if (drm->client.device.info.family == NV_DEVICE_INFO_V0_CURIE) {
+		if (device->impl->family == NVIF_DEVICE_CURIE) {
 			NVWriteCRTC(dev, head, NV_PCRTC_850, regp->crtc_850);
 
 			reg900 = NVReadRAMDAC(dev, head, NV_PRAMDAC_900);
@@ -719,23 +719,23 @@ nv_load_state_ext(struct drm_device *dev, int head,
 	wr_cio_state(dev, head, regp, NV_CIO_CRE_FF_INDEX);
 	wr_cio_state(dev, head, regp, NV_CIO_CRE_FFLWM__INDEX);
 
-	if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_KELVIN)
+	if (device->impl->family >= NVIF_DEVICE_KELVIN)
 		wr_cio_state(dev, head, regp, NV_CIO_CRE_47);
 
-	if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_RANKINE)
+	if (device->impl->family >= NVIF_DEVICE_RANKINE)
 		wr_cio_state(dev, head, regp, 0x9f);
 
 	wr_cio_state(dev, head, regp, NV_CIO_CRE_49);
 	wr_cio_state(dev, head, regp, NV_CIO_CRE_HCUR_ADDR0_INDEX);
 	wr_cio_state(dev, head, regp, NV_CIO_CRE_HCUR_ADDR1_INDEX);
 	wr_cio_state(dev, head, regp, NV_CIO_CRE_HCUR_ADDR2_INDEX);
-	if (drm->client.device.info.family == NV_DEVICE_INFO_V0_CURIE)
+	if (device->impl->family == NVIF_DEVICE_CURIE)
 		nv_fix_nv40_hw_cursor(dev, head);
 	wr_cio_state(dev, head, regp, NV_CIO_CRE_ILACE__INDEX);
 
 	wr_cio_state(dev, head, regp, NV_CIO_CRE_SCRATCH3__INDEX);
 	wr_cio_state(dev, head, regp, NV_CIO_CRE_SCRATCH4__INDEX);
-	if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_CELSIUS) {
+	if (device->impl->family >= NVIF_DEVICE_CELSIUS) {
 		wr_cio_state(dev, head, regp, NV_CIO_CRE_EBR_INDEX);
 		wr_cio_state(dev, head, regp, NV_CIO_CRE_CSB);
 		wr_cio_state(dev, head, regp, NV_CIO_CRE_4B);
@@ -743,7 +743,7 @@ nv_load_state_ext(struct drm_device *dev, int head,
 	}
 	/* NV11 and NV20 stop at 0x52. */
 	if (nv_gf4_disp_arch(dev)) {
-		if (drm->client.device.info.family < NV_DEVICE_INFO_V0_KELVIN) {
+		if (device->impl->family < NVIF_DEVICE_KELVIN) {
 			/* Not waiting for vertical retrace before modifying
 			   CRE_53/CRE_54 causes lockups. */
 			nvif_msec(&drm->client.device, 650,
@@ -815,7 +815,7 @@ void nouveau_hw_save_state(struct drm_device *dev, int head,
 {
 	struct nouveau_drm *drm = nouveau_drm(dev);
 
-	if (drm->client.device.info.chipset == 0x11)
+	if (drm->device.impl->chipset == 0x11)
 		/* NB: no attempt is made to restore the bad pll later on */
 		nouveau_hw_fix_bad_vpll(dev, head);
 	nv_save_state_ramdac(dev, head, state);
diff --git a/drivers/gpu/drm/nouveau/dispnv04/hw.h b/drivers/gpu/drm/nouveau/dispnv04/hw.h
index 6987e1766cd2..b565cd34ed67 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/hw.h
+++ b/drivers/gpu/drm/nouveau/dispnv04/hw.h
@@ -164,13 +164,12 @@ static inline uint8_t NVReadVgaCrtc5758(struct drm_device *dev, int head, uint8_
 static inline uint8_t NVReadPRMVIO(struct drm_device *dev,
 					int head, uint32_t reg)
 {
-	struct nvif_object *device = &nouveau_drm(dev)->client.device.object;
-	struct nouveau_drm *drm = nouveau_drm(dev);
+	struct nvif_device *device = &nouveau_drm(dev)->device;
 	uint8_t val;
 
 	/* Only NV4x have two pvio ranges; other twoHeads cards MUST call
 	 * NVSetOwner for the relevant head to be programmed */
-	if (head && drm->client.device.info.family == NV_DEVICE_INFO_V0_CURIE)
+	if (head && device->impl->family == NVIF_DEVICE_CURIE)
 		reg += NV_PRMVIO_SIZE;
 
 	val = nvif_rd08(device, reg);
@@ -180,12 +179,11 @@ static inline uint8_t NVReadPRMVIO(struct drm_device *dev,
 static inline void NVWritePRMVIO(struct drm_device *dev,
 					int head, uint32_t reg, uint8_t value)
 {
-	struct nvif_object *device = &nouveau_drm(dev)->client.device.object;
-	struct nouveau_drm *drm = nouveau_drm(dev);
+	struct nvif_device *device = &nouveau_drm(dev)->device;
 
 	/* Only NV4x have two pvio ranges; other twoHeads cards MUST call
 	 * NVSetOwner for the relevant head to be programmed */
-	if (head && drm->client.device.info.family == NV_DEVICE_INFO_V0_CURIE)
+	if (head && device->impl->family == NVIF_DEVICE_CURIE)
 		reg += NV_PRMVIO_SIZE;
 
 	nvif_wr08(device, reg, value);
@@ -258,10 +256,9 @@ static inline void NVVgaProtect(struct drm_device *dev, int head, bool protect)
 static inline bool
 nv_heads_tied(struct drm_device *dev)
 {
-	struct nvif_object *device = &nouveau_drm(dev)->client.device.object;
-	struct nouveau_drm *drm = nouveau_drm(dev);
+	struct nvif_device *device = &nouveau_drm(dev)->device;
 
-	if (drm->client.device.info.chipset == 0x11)
+	if (device->impl->chipset == 0x11)
 		return !!(nvif_rd32(device, NV_PBUS_DEBUG_1) & (1 << 28));
 
 	return NVReadVgaCrtc(dev, 0, NV_CIO_CRE_44) & 0x4;
@@ -317,7 +314,7 @@ NVLockVgaCrtcs(struct drm_device *dev, bool lock)
 	NVWriteVgaCrtc(dev, 0, NV_CIO_SR_LOCK_INDEX,
 		       lock ? NV_CIO_SR_LOCK_VALUE : NV_CIO_SR_UNLOCK_RW_VALUE);
 	/* NV11 has independently lockable extended crtcs, except when tied */
-	if (drm->client.device.info.chipset == 0x11 && !nv_heads_tied(dev))
+	if (drm->device.impl->chipset == 0x11 && !nv_heads_tied(dev))
 		NVWriteVgaCrtc(dev, 1, NV_CIO_SR_LOCK_INDEX,
 			       lock ? NV_CIO_SR_LOCK_VALUE :
 				      NV_CIO_SR_UNLOCK_RW_VALUE);
@@ -334,7 +331,7 @@ static inline int nv_cursor_width(struct drm_device *dev)
 {
 	struct nouveau_drm *drm = nouveau_drm(dev);
 
-	return drm->client.device.info.family >= NV_DEVICE_INFO_V0_CELSIUS ? NV10_CURSOR_SIZE : NV04_CURSOR_SIZE;
+	return drm->device.impl->family >= NVIF_DEVICE_CELSIUS ? NV10_CURSOR_SIZE : NV04_CURSOR_SIZE;
 }
 
 static inline void
@@ -356,7 +353,7 @@ nv_set_crtc_base(struct drm_device *dev, int head, uint32_t offset)
 
 	NVWriteCRTC(dev, head, NV_PCRTC_START, offset);
 
-	if (drm->client.device.info.family == NV_DEVICE_INFO_V0_TNT) {
+	if (drm->device.impl->family == NVIF_DEVICE_TNT) {
 		/*
 		 * Hilarious, the 24th bit doesn't want to stick to
 		 * PCRTC_START...
@@ -381,7 +378,7 @@ nv_show_cursor(struct drm_device *dev, int head, bool show)
 		*curctl1 &= ~MASK(NV_CIO_CRE_HCUR_ADDR1_ENABLE);
 	NVWriteVgaCrtc(dev, head, NV_CIO_CRE_HCUR_ADDR1_INDEX, *curctl1);
 
-	if (drm->client.device.info.family == NV_DEVICE_INFO_V0_CURIE)
+	if (drm->device.impl->family == NVIF_DEVICE_CURIE)
 		nv_fix_nv40_hw_cursor(dev, head);
 }
 
@@ -397,7 +394,7 @@ nv_pitch_align(struct drm_device *dev, uint32_t width, int bpp)
 		bpp = 8;
 
 	/* Alignment requirements taken from the Haiku driver */
-	if (drm->client.device.info.family == NV_DEVICE_INFO_V0_TNT)
+	if (drm->device.impl->family == NVIF_DEVICE_TNT)
 		mask = 128 / bpp - 1;
 	else
 		mask = 512 / bpp - 1;
diff --git a/drivers/gpu/drm/nouveau/dispnv04/overlay.c b/drivers/gpu/drm/nouveau/dispnv04/overlay.c
index 33f29736024a..103b6dddfac4 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/overlay.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/overlay.c
@@ -118,7 +118,7 @@ nv10_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
 		  struct drm_modeset_acquire_ctx *ctx)
 {
 	struct nouveau_drm *drm = nouveau_drm(plane->dev);
-	struct nvif_object *dev = &drm->client.device.object;
+	struct nvif_device *dev = &drm->device;
 	struct nouveau_plane *nv_plane =
 		container_of(plane, struct nouveau_plane, base);
 	struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
@@ -127,7 +127,7 @@ nv10_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
 	bool flip = nv_plane->flip;
 	int soff = NV_PCRTC0_SIZE * nv_crtc->index;
 	int soff2 = NV_PCRTC0_SIZE * !nv_crtc->index;
-	unsigned shift = drm->client.device.info.chipset >= 0x30 ? 1 : 3;
+	unsigned shift = dev->impl->chipset >= 0x30 ? 1 : 3;
 	unsigned format = 0;
 	int ret;
 
@@ -286,7 +286,7 @@ nv10_overlay_init(struct drm_device *device)
 	if (!plane)
 		return;
 
-	switch (drm->client.device.info.chipset) {
+	switch (drm->device.impl->chipset) {
 	case 0x10:
 	case 0x11:
 	case 0x15:
@@ -511,9 +511,10 @@ nv04_overlay_init(struct drm_device *device)
 void
 nouveau_overlay_init(struct drm_device *device)
 {
-	struct nvif_device *dev = &nouveau_drm(device)->client.device;
-	if (dev->info.chipset < 0x10)
+	struct nvif_device *dev = &nouveau_drm(device)->device;
+
+	if (dev->impl->chipset < 0x10)
 		nv04_overlay_init(device);
-	else if (dev->info.chipset <= 0x40)
+	else if (dev->impl->chipset <= 0x40)
 		nv10_overlay_init(device);
 }
diff --git a/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c b/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c
index c11f58033018..1119c087d52f 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c
@@ -155,8 +155,8 @@ nv17_tv_detect(struct drm_encoder *encoder, struct drm_connector *connector)
 		return connector_status_disconnected;
 
 	if (reliable) {
-		if (drm->client.device.info.chipset == 0x42 ||
-		    drm->client.device.info.chipset == 0x43)
+		if (drm->device.impl->chipset == 0x42 ||
+		    drm->device.impl->chipset == 0x43)
 			tv_enc->pin_mask =
 				nv42_tv_sample_load(encoder) >> 28 & 0xe;
 		else
@@ -436,7 +436,7 @@ static void nv17_tv_prepare(struct drm_encoder *encoder)
 	/* Set the DACCLK register */
 	dacclk = (NVReadRAMDAC(dev, 0, dacclk_off) & ~0x30) | 0x1;
 
-	if (drm->client.device.info.family == NV_DEVICE_INFO_V0_CURIE)
+	if (drm->device.impl->family == NVIF_DEVICE_CURIE)
 		dacclk |= 0x1a << 16;
 
 	if (tv_norm->kind == CTV_ENC_MODE) {
@@ -493,7 +493,7 @@ static void nv17_tv_mode_set(struct drm_encoder *encoder,
 			tv_regs->ptv_614 = 0x13;
 		}
 
-		if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_RANKINE) {
+		if (drm->device.impl->family >= NVIF_DEVICE_RANKINE) {
 			tv_regs->ptv_500 = 0xe8e0;
 			tv_regs->ptv_504 = 0x1710;
 			tv_regs->ptv_604 = 0x0;
@@ -588,7 +588,7 @@ static void nv17_tv_commit(struct drm_encoder *encoder)
 	nv17_tv_state_load(dev, &to_tv_enc(encoder)->state);
 
 	/* This could use refinement for flatpanels, but it should work */
-	if (drm->client.device.info.chipset < 0x44)
+	if (drm->device.impl->chipset < 0x44)
 		NVWriteRAMDAC(dev, 0, NV_PRAMDAC_TEST_CONTROL +
 					nv04_dac_output_offset(encoder),
 					0xf0000000);
diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c b/drivers/gpu/drm/nouveau/dispnv50/disp.c
index a23e1d264294..36547f3b6111 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/disp.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c
@@ -2637,7 +2637,7 @@ nv50_display_create(struct drm_device *dev)
 	if (disp->disp->object.oclass >= TU102_DISP)
 		nouveau_display(dev)->format_modifiers = wndwc57e_modifiers;
 	else
-	if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_FERMI)
+	if (drm->device.impl->family >= NVIF_DEVICE_FERMI)
 		nouveau_display(dev)->format_modifiers = disp90xx_modifiers;
 	else
 		nouveau_display(dev)->format_modifiers = disp50xx_modifiers;
diff --git a/drivers/gpu/drm/nouveau/dispnv50/wndw.c b/drivers/gpu/drm/nouveau/dispnv50/wndw.c
index 1e6e27782ce8..38853dbe57c5 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/wndw.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/wndw.c
@@ -81,18 +81,18 @@ nv50_wndw_ctxdma_new(struct nv50_wndw *wndw, struct drm_framebuffer *fb)
 	args.base.target = NV_DMA_V0_TARGET_VRAM;
 	args.base.access = NV_DMA_V0_ACCESS_RDWR;
 	args.base.start  = 0;
-	args.base.limit  = drm->client.device.info.ram_user - 1;
+	args.base.limit  = drm->device.impl->ram_user - 1;
 
-	if (drm->client.device.info.chipset < 0x80) {
+	if (drm->device.impl->chipset < 0x80) {
 		args.nv50.part = NV50_DMA_V0_PART_256;
 		argc += sizeof(args.nv50);
 	} else
-	if (drm->client.device.info.chipset < 0xc0) {
+	if (drm->device.impl->chipset < 0xc0) {
 		args.nv50.part = NV50_DMA_V0_PART_256;
 		args.nv50.kind = kind;
 		argc += sizeof(args.nv50);
 	} else
-	if (drm->client.device.info.chipset < 0xd0) {
+	if (drm->device.impl->chipset < 0xd0) {
 		args.gf100.kind = kind;
 		argc += sizeof(args.gf100);
 	} else {
@@ -295,7 +295,7 @@ nv50_wndw_atomic_check_acquire(struct nv50_wndw *wndw, bool modeset,
 
 		if (asyw->image.kind) {
 			asyw->image.layout = NV507C_SURFACE_SET_STORAGE_MEMORY_LAYOUT_BLOCKLINEAR;
-			if (drm->client.device.info.chipset >= 0xc0)
+			if (drm->device.impl->chipset >= 0xc0)
 				asyw->image.blockh = tile_mode >> 4;
 			else
 				asyw->image.blockh = tile_mode;
@@ -666,7 +666,7 @@ static bool nv50_plane_format_mod_supported(struct drm_plane *plane,
 	struct nouveau_drm *drm = nouveau_drm(plane->dev);
 	uint8_t i;
 
-	if (drm->client.device.info.chipset < 0xc0) {
+	if (drm->device.impl->chipset < 0xc0) {
 		const struct drm_format_info *info = drm_format_info(format);
 		const uint8_t kind = (modifier >> 12) & 0xff;
 
diff --git a/drivers/gpu/drm/nouveau/include/nvif/device.h b/drivers/gpu/drm/nouveau/include/nvif/device.h
index 0ec8d80133c7..8947edd9b25b 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/device.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/device.h
@@ -2,7 +2,6 @@
 #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_ctxdma;
@@ -13,8 +12,6 @@ struct nvif_device {
 	struct nvif_object object;
 	struct nvif_map map;
 
-	struct nv_device_info_v0 info;
-
 	struct nvif_user user;
 };
 
diff --git a/drivers/gpu/drm/nouveau/nouveau_abi16.c b/drivers/gpu/drm/nouveau/nouveau_abi16.c
index ef668f20111a..bf0b6d427364 100644
--- a/drivers/gpu/drm/nouveau/nouveau_abi16.c
+++ b/drivers/gpu/drm/nouveau/nouveau_abi16.c
@@ -27,6 +27,7 @@
 #include <nvif/ioctl.h>
 #include <nvif/class.h>
 #include <nvif/cl0002.h>
+#include <nvif/cl0080.h>
 #include <nvif/unpack.h>
 
 #include "nouveau_drv.h"
@@ -211,7 +212,7 @@ nouveau_abi16_ioctl_getparam(ABI16_IOCTL_ARGS)
 {
 	struct nouveau_cli *cli = nouveau_cli(file_priv);
 	struct nouveau_drm *drm = nouveau_drm(dev);
-	struct nvif_device *device = &drm->client.device;
+	struct nvif_device *device = &drm->device;
 	struct nvkm_device *nvkm_device = nvxx_device(drm);
 	struct nvkm_gr *gr = nvxx_gr(drm);
 	struct drm_nouveau_getparam *getparam = data;
@@ -219,27 +220,27 @@ nouveau_abi16_ioctl_getparam(ABI16_IOCTL_ARGS)
 
 	switch (getparam->param) {
 	case NOUVEAU_GETPARAM_CHIPSET_ID:
-		getparam->value = device->info.chipset;
+		getparam->value = device->impl->chipset;
 		break;
 	case NOUVEAU_GETPARAM_PCI_VENDOR:
-		if (device->info.platform != NV_DEVICE_INFO_V0_SOC)
+		if (device->impl->platform != NVIF_DEVICE_SOC)
 			getparam->value = pdev->vendor;
 		else
 			getparam->value = 0;
 		break;
 	case NOUVEAU_GETPARAM_PCI_DEVICE:
-		if (device->info.platform != NV_DEVICE_INFO_V0_SOC)
+		if (device->impl->platform != NVIF_DEVICE_SOC)
 			getparam->value = pdev->device;
 		else
 			getparam->value = 0;
 		break;
 	case NOUVEAU_GETPARAM_BUS_TYPE:
-		switch (device->info.platform) {
-		case NV_DEVICE_INFO_V0_AGP : getparam->value = 0; break;
-		case NV_DEVICE_INFO_V0_PCI : getparam->value = 1; break;
-		case NV_DEVICE_INFO_V0_PCIE: getparam->value = 2; break;
-		case NV_DEVICE_INFO_V0_SOC : getparam->value = 3; break;
-		case NV_DEVICE_INFO_V0_IGP :
+		switch (device->impl->platform) {
+		case NVIF_DEVICE_AGP : getparam->value = 0; break;
+		case NVIF_DEVICE_PCI : getparam->value = 1; break;
+		case NVIF_DEVICE_PCIE: getparam->value = 2; break;
+		case NVIF_DEVICE_SOC : getparam->value = 3; break;
+		case NVIF_DEVICE_IGP :
 			if (!pci_is_pcie(pdev))
 				getparam->value = 1;
 			else
@@ -324,7 +325,7 @@ nouveau_abi16_ioctl_channel_alloc(ABI16_IOCTL_ARGS)
 	engine = NVIF_ENGINE_GR;
 
 	/* hack to allow channel engine type specification on kepler */
-	if (device->info.family >= NV_DEVICE_INFO_V0_KEPLER) {
+	if (device->impl->family >= NVIF_DEVICE_KEPLER) {
 		if (init->fb_ctxdma_handle == ~0) {
 			switch (init->tt_ctxdma_handle) {
 			case NOUVEAU_FIFO_ENGINE_GR:
@@ -386,7 +387,7 @@ nouveau_abi16_ioctl_channel_alloc(ABI16_IOCTL_ARGS)
 
 	init->channel = chan->chan->chid;
 
-	if (device->info.family >= NV_DEVICE_INFO_V0_TESLA)
+	if (device->impl->family >= NVIF_DEVICE_TESLA)
 		init->pushbuf_domains = NOUVEAU_GEM_DOMAIN_VRAM |
 					NOUVEAU_GEM_DOMAIN_GART;
 	else
@@ -395,7 +396,7 @@ nouveau_abi16_ioctl_channel_alloc(ABI16_IOCTL_ARGS)
 	else
 		init->pushbuf_domains = NOUVEAU_GEM_DOMAIN_GART;
 
-	if (device->info.family < NV_DEVICE_INFO_V0_CELSIUS) {
+	if (device->impl->family < NVIF_DEVICE_CELSIUS) {
 		init->subchan[0].handle = 0x00000000;
 		init->subchan[0].grclass = 0x0000;
 		init->subchan[1].handle = chan->chan->nvsw.object.handle;
@@ -411,14 +412,14 @@ nouveau_abi16_ioctl_channel_alloc(ABI16_IOCTL_ARGS)
 	 *
 	 * Userspace was fixed prior to adding Ampere support.
 	 */
-	switch (device->info.family) {
-	case NV_DEVICE_INFO_V0_VOLTA:
+	switch (device->impl->family) {
+	case NVIF_DEVICE_VOLTA:
 		ret = nvif_engobj_ctor(&chan->chan->chan, "abi16CeWar", 0, VOLTA_DMA_COPY_A,
 				       &chan->ce);
 		if (ret)
 			goto done;
 		break;
-	case NV_DEVICE_INFO_V0_TURING:
+	case NVIF_DEVICE_TURING:
 		ret = nvif_engobj_ctor(&chan->chan->chan, "abi16CeWar", 0, TURING_DMA_COPY_A,
 				       &chan->ce);
 		if (ret)
@@ -437,7 +438,7 @@ nouveau_abi16_ioctl_channel_alloc(ABI16_IOCTL_ARGS)
 	if (ret)
 		goto done;
 
-	if (device->info.family >= NV_DEVICE_INFO_V0_TESLA) {
+	if (device->impl->family >= NVIF_DEVICE_TESLA) {
 		ret = nouveau_vma_new(chan->ntfy, chan->chan->vmm,
 				      &chan->ntfy_vma);
 		if (ret)
@@ -558,7 +559,7 @@ nouveau_abi16_ioctl_notifierobj_alloc(ABI16_IOCTL_ARGS)
 		return -ENOMEM;
 
 	/* completely unnecessary for these chipsets... */
-	if (unlikely(device->info.family >= NV_DEVICE_INFO_V0_FERMI))
+	if (unlikely(device->impl->family >= NVIF_DEVICE_FERMI))
 		return nouveau_abi16_put(abi16, -EINVAL);
 
 	chan = nouveau_abi16_chan(abi16, info->channel);
@@ -578,7 +579,7 @@ nouveau_abi16_ioctl_notifierobj_alloc(ABI16_IOCTL_ARGS)
 
 	args.start = ntfy->node->offset;
 	args.limit = ntfy->node->offset + ntfy->node->length - 1;
-	if (device->info.family >= NV_DEVICE_INFO_V0_TESLA) {
+	if (device->impl->family >= NVIF_DEVICE_TESLA) {
 		args.target = NV_DMA_V0_TARGET_VM;
 		args.access = NV_DMA_V0_ACCESS_VM;
 		args.start += chan->ntfy_vma->addr;
@@ -643,6 +644,7 @@ static int
 nouveau_abi16_ioctl_mthd(struct nouveau_abi16 *abi16, struct nvif_ioctl_v0 *ioctl, u32 argc)
 {
 	struct nouveau_cli *cli = abi16->cli;
+	struct nvif_device *device = &cli->drm->device;
 	struct nvif_ioctl_mthd_v0 *args;
 	struct nouveau_abi16_obj *obj;
 	struct nv_device_info_v0 *info;
@@ -664,8 +666,14 @@ nouveau_abi16_ioctl_mthd(struct nouveau_abi16 *abi16, struct nvif_ioctl_v0 *ioct
 	if (info->version != 0x00)
 		return -EINVAL;
 
-	info = &cli->drm->device.info;
-	memcpy(args->data, info, sizeof(*info));
+	info->platform = device->impl->platform;
+	info->chipset = device->impl->chipset;
+	info->revision = device->impl->revision;
+	info->family = device->impl->family;
+	info->ram_size = device->impl->ram_size;
+	info->ram_user = device->impl->ram_user;
+	strscpy(info->chip, device->impl->chip, sizeof(info->chip));
+	strscpy(info->name, device->impl->name, sizeof(info->name));
 	return 0;
 }
 
diff --git a/drivers/gpu/drm/nouveau/nouveau_backlight.c b/drivers/gpu/drm/nouveau/nouveau_backlight.c
index d47442125fa1..925856f3b21b 100644
--- a/drivers/gpu/drm/nouveau/nouveau_backlight.c
+++ b/drivers/gpu/drm/nouveau/nouveau_backlight.c
@@ -292,7 +292,7 @@ nouveau_backlight_init(struct drm_connector *connector)
 	struct nouveau_drm *drm = nouveau_drm(connector->dev);
 	struct nouveau_backlight *bl;
 	struct nouveau_encoder *nv_encoder = NULL;
-	struct nvif_device *device = &drm->client.device;
+	struct nvif_device *device = &drm->device;
 	char backlight_name[BL_NAME_SIZE];
 	struct backlight_properties props = {0};
 	const struct backlight_ops *ops;
@@ -317,18 +317,18 @@ nouveau_backlight_init(struct drm_connector *connector)
 	if (!bl)
 		return -ENOMEM;
 
-	switch (device->info.family) {
-	case NV_DEVICE_INFO_V0_CURIE:
+	switch (device->impl->family) {
+	case NVIF_DEVICE_CURIE:
 		ret = nv40_backlight_init(nv_encoder, &props, &ops);
 		break;
-	case NV_DEVICE_INFO_V0_TESLA:
-	case NV_DEVICE_INFO_V0_FERMI:
-	case NV_DEVICE_INFO_V0_KEPLER:
-	case NV_DEVICE_INFO_V0_MAXWELL:
-	case NV_DEVICE_INFO_V0_PASCAL:
-	case NV_DEVICE_INFO_V0_VOLTA:
-	case NV_DEVICE_INFO_V0_TURING:
-	case NV_DEVICE_INFO_V0_AMPERE: //XXX: not confirmed
+	case NVIF_DEVICE_TESLA:
+	case NVIF_DEVICE_FERMI:
+	case NVIF_DEVICE_KEPLER:
+	case NVIF_DEVICE_MAXWELL:
+	case NVIF_DEVICE_PASCAL:
+	case NVIF_DEVICE_VOLTA:
+	case NVIF_DEVICE_TURING:
+	case NVIF_DEVICE_AMPERE: //XXX: not confirmed
 		ret = nv50_backlight_init(bl, nouveau_connector(connector),
 					  nv_encoder, &props, &ops);
 		break;
diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
index 829e98da56d0..c9c68416d558 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bios.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
@@ -322,7 +322,7 @@ static int
 get_fp_strap(struct drm_device *dev, struct nvbios *bios)
 {
 	struct nouveau_drm *drm = nouveau_drm(dev);
-	struct nvif_object *device = &drm->client.device.object;
+	struct nvif_device *device = &drm->device;
 
 	/*
 	 * The fp strap is normally dictated by the "User Strap" in
@@ -336,10 +336,10 @@ get_fp_strap(struct drm_device *dev, struct nvbios *bios)
 	if (bios->major_version < 5 && bios->data[0x48] & 0x4)
 		return NVReadVgaCrtc5758(dev, 0, 0xf) & 0xf;
 
-	if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_MAXWELL)
+	if (device->impl->family >= NVIF_DEVICE_MAXWELL)
 		return nvif_rd32(device, 0x001800) & 0x0000000f;
 	else
-	if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA)
+	if (device->impl->family >= NVIF_DEVICE_TESLA)
 		return (nvif_rd32(device, NV_PEXTDEV_BOOT_0) >> 24) & 0xf;
 	else
 		return (nvif_rd32(device, NV_PEXTDEV_BOOT_0) >> 16) & 0xf;
@@ -1255,7 +1255,7 @@ olddcb_table(struct drm_device *dev)
 	struct nouveau_drm *drm = nouveau_drm(dev);
 	u8 *dcb = NULL;
 
-	if (drm->client.device.info.family > NV_DEVICE_INFO_V0_TNT)
+	if (drm->device.impl->family > NVIF_DEVICE_TNT)
 		dcb = ROMPTR(dev, drm->vbios.data[0x36]);
 	if (!dcb) {
 		NV_WARN(drm, "No DCB data found in VBIOS\n");
@@ -2070,7 +2070,7 @@ nouveau_bios_posted(struct drm_device *dev)
 	struct nouveau_drm *drm = nouveau_drm(dev);
 	unsigned htotal;
 
-	if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA)
+	if (drm->device.impl->family >= NVIF_DEVICE_TESLA)
 		return true;
 
 	htotal  = NVReadVgaCrtc(dev, 0, 0x06);
@@ -2096,7 +2096,7 @@ nouveau_bios_init(struct drm_device *dev)
 	if (!NVInitVBIOS(dev))
 		return -ENODEV;
 
-	if (drm->client.device.info.family < NV_DEVICE_INFO_V0_TESLA) {
+	if (drm->device.impl->family < NVIF_DEVICE_TESLA) {
 		ret = parse_dcb_table(dev, bios);
 		if (ret)
 			return ret;
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
index 60ce4b46a3a4..523464cfea9e 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -175,23 +175,23 @@ static void
 nouveau_bo_fixup_align(struct nouveau_bo *nvbo, int *align, u64 *size)
 {
 	struct nouveau_drm *drm = nouveau_bdev(nvbo->bo.bdev);
-	struct nvif_device *device = &drm->client.device;
+	struct nvif_device *device = &drm->device;
 
-	if (device->info.family < NV_DEVICE_INFO_V0_TESLA) {
+	if (device->impl->family < NVIF_DEVICE_TESLA) {
 		if (nvbo->mode) {
-			if (device->info.chipset >= 0x40) {
+			if (device->impl->chipset >= 0x40) {
 				*align = 65536;
 				*size = roundup_64(*size, 64 * nvbo->mode);
 
-			} else if (device->info.chipset >= 0x30) {
+			} else if (device->impl->chipset >= 0x30) {
 				*align = 32768;
 				*size = roundup_64(*size, 64 * nvbo->mode);
 
-			} else if (device->info.chipset >= 0x20) {
+			} else if (device->impl->chipset >= 0x20) {
 				*align = 16384;
 				*size = roundup_64(*size, 64 * nvbo->mode);
 
-			} else if (device->info.chipset >= 0x10) {
+			} else if (device->impl->chipset >= 0x10) {
 				*align = 16384;
 				*size = roundup_64(*size, 32 * nvbo->mode);
 			}
@@ -243,7 +243,7 @@ nouveau_bo_alloc(struct nouveau_cli *cli, u64 *size, int *align, u32 domain,
 	nvbo->contig = !(tile_flags & NOUVEAU_GEM_TILE_NONCONTIG);
 	if (!nouveau_cli_uvmm(cli) || internal) {
 		/* for BO noVM allocs, don't assign kinds */
-		if (cli->device.info.family >= NV_DEVICE_INFO_V0_FERMI) {
+		if (drm->device.impl->family >= NVIF_DEVICE_FERMI) {
 			nvbo->kind = (tile_flags & 0x0000ff00) >> 8;
 			if (!nvif_mmu_kind_valid(mmu, nvbo->kind)) {
 				kfree(nvbo);
@@ -251,7 +251,7 @@ nouveau_bo_alloc(struct nouveau_cli *cli, u64 *size, int *align, u32 domain,
 			}
 
 			nvbo->comp = mmu->impl->kind[nvbo->kind] != nvbo->kind;
-		} else if (cli->device.info.family >= NV_DEVICE_INFO_V0_TESLA) {
+		} else if (drm->device.impl->family >= NVIF_DEVICE_TESLA) {
 			nvbo->kind = (tile_flags & 0x00007f00) >> 8;
 			nvbo->comp = (tile_flags & 0x00030000) >> 16;
 			if (!nvif_mmu_kind_valid(mmu, nvbo->kind)) {
@@ -272,7 +272,7 @@ nouveau_bo_alloc(struct nouveau_cli *cli, u64 *size, int *align, u32 domain,
 			 *
 			 * Skip page sizes that can't support needed domains.
 			 */
-			if (cli->device.info.family > NV_DEVICE_INFO_V0_CURIE &&
+			if (drm->device.impl->family > NVIF_DEVICE_CURIE &&
 			    (domain & NOUVEAU_GEM_DOMAIN_VRAM) && !vmm->impl->page[i].vram)
 				continue;
 			if ((domain & NOUVEAU_GEM_DOMAIN_GART) &&
@@ -408,10 +408,10 @@ static void
 set_placement_range(struct nouveau_bo *nvbo, uint32_t domain)
 {
 	struct nouveau_drm *drm = nouveau_bdev(nvbo->bo.bdev);
-	u64 vram_size = drm->client.device.info.ram_size;
+	u64 vram_size = drm->device.impl->ram_size;
 	unsigned i, fpfn, lpfn;
 
-	if (drm->client.device.info.family == NV_DEVICE_INFO_V0_CELSIUS &&
+	if (drm->device.impl->family == NVIF_DEVICE_CELSIUS &&
 	    nvbo->mode && (domain & NOUVEAU_GEM_DOMAIN_VRAM) &&
 	    nvbo->bo.base.size < vram_size / 4) {
 		/*
@@ -476,7 +476,7 @@ int nouveau_bo_pin_locked(struct nouveau_bo *nvbo, uint32_t domain, bool contig)
 
 	dma_resv_assert_held(bo->base.resv);
 
-	if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA &&
+	if (drm->device.impl->family >= NVIF_DEVICE_TESLA &&
 	    domain == NOUVEAU_GEM_DOMAIN_VRAM && contig) {
 		if (!nvbo->contig) {
 			nvbo->contig = true;
@@ -873,7 +873,7 @@ nouveau_bo_move_m2mf(struct ttm_buffer_object *bo, int evict,
 	 * old nvkm_mem node, these will get cleaned up after ttm has
 	 * destroyed the ttm_resource
 	 */
-	if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) {
+	if (drm->device.impl->family >= NVIF_DEVICE_TESLA) {
 		ret = nouveau_bo_move_prep(drm, bo, new_reg);
 		if (ret)
 			return ret;
@@ -1034,7 +1034,7 @@ nouveau_bo_vm_bind(struct ttm_buffer_object *bo, struct ttm_resource *new_reg,
 	if (new_reg->mem_type != TTM_PL_VRAM)
 		return 0;
 
-	if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_CELSIUS) {
+	if (drm->device.impl->family >= NVIF_DEVICE_CELSIUS) {
 		*new_tile = nv10_bo_set_tiling(dev, offset, bo->base.size,
 					       nvbo->mode, nvbo->zeta);
 	}
@@ -1087,7 +1087,7 @@ nouveau_bo_move(struct ttm_buffer_object *bo, bool evict,
 	if (ret)
 		goto out_ntfy;
 
-	if (drm->client.device.info.family < NV_DEVICE_INFO_V0_TESLA) {
+	if (drm->device.impl->family < NVIF_DEVICE_TESLA) {
 		ret = nouveau_bo_vm_bind(bo, new_reg, &new_tile);
 		if (ret)
 			goto out_ntfy;
@@ -1137,7 +1137,7 @@ nouveau_bo_move(struct ttm_buffer_object *bo, bool evict,
 	}
 
 out:
-	if (drm->client.device.info.family < NV_DEVICE_INFO_V0_TESLA) {
+	if (drm->device.impl->family < NVIF_DEVICE_TESLA) {
 		if (ret)
 			nouveau_bo_vm_cleanup(bo, NULL, &new_tile);
 		else
@@ -1210,7 +1210,7 @@ nouveau_ttm_io_mem_reserve(struct ttm_device *bdev, struct ttm_resource *reg)
 		reg->bus.is_iomem = true;
 
 		/* Some BARs do not support being ioremapped WC */
-		if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA &&
+		if (drm->device.impl->family >= NVIF_DEVICE_TESLA &&
 		    mmu->impl->type[drm->ttm.type_vram].type & NVIF_MEM_UNCACHED)
 			reg->bus.caching = ttm_uncached;
 		else
@@ -1305,7 +1305,7 @@ vm_fault_t nouveau_ttm_fault_reserve_notify(struct ttm_buffer_object *bo)
 	 * nothing to do here.
 	 */
 	if (bo->resource->mem_type != TTM_PL_VRAM) {
-		if (drm->client.device.info.family < NV_DEVICE_INFO_V0_TESLA ||
+		if (drm->device.impl->family < NVIF_DEVICE_TESLA ||
 		    !nvbo->kind)
 			return 0;
 
@@ -1316,7 +1316,7 @@ vm_fault_t nouveau_ttm_fault_reserve_notify(struct ttm_buffer_object *bo)
 
 	} else {
 		/* make sure bo is in mappable vram */
-		if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA ||
+		if (drm->device.impl->family >= NVIF_DEVICE_TESLA ||
 		    bo->resource->start + PFN_UP(bo->resource->size) < mappable)
 			return 0;
 
diff --git a/drivers/gpu/drm/nouveau/nouveau_chan.c b/drivers/gpu/drm/nouveau/nouveau_chan.c
index 1cd8953740f5..cb5b75bc53d5 100644
--- a/drivers/gpu/drm/nouveau/nouveau_chan.c
+++ b/drivers/gpu/drm/nouveau/nouveau_chan.c
@@ -190,7 +190,7 @@ nouveau_channel_prep(struct nouveau_cli *cli,
 	 */
 	chan->push.addr = chan->push.buffer->offset;
 
-	if (device->info.family >= NV_DEVICE_INFO_V0_TESLA) {
+	if (device->impl->family >= NVIF_DEVICE_TESLA) {
 		ret = nouveau_vma_new(chan->push.buffer, chan->vmm,
 				      &chan->push.vma);
 		if (ret) {
@@ -200,7 +200,7 @@ nouveau_channel_prep(struct nouveau_cli *cli,
 
 		chan->push.addr = chan->push.vma->addr;
 
-		if (device->info.family >= NV_DEVICE_INFO_V0_FERMI)
+		if (device->impl->family >= NVIF_DEVICE_FERMI)
 			return 0;
 
 		args.target = NV_DMA_V0_TARGET_VM;
@@ -209,7 +209,7 @@ nouveau_channel_prep(struct nouveau_cli *cli,
 		args.limit = chan->vmm->vmm.impl->limit - 1;
 	} else
 	if (chan->push.buffer->bo.resource->mem_type == TTM_PL_VRAM) {
-		if (device->info.family == NV_DEVICE_INFO_V0_TNT) {
+		if (device->impl->family == NVIF_DEVICE_TNT) {
 			/* nv04 vram pushbuf hack, retarget to its location in
 			 * the framebuffer bar rather than direct vram access..
 			 * nfi why this exists, it came from the -nv ddx.
@@ -217,12 +217,12 @@ nouveau_channel_prep(struct nouveau_cli *cli,
 			args.target = NV_DMA_V0_TARGET_PCI;
 			args.access = NV_DMA_V0_ACCESS_RDWR;
 			args.start = nvxx_device(drm)->func->resource_addr(nvxx_device(drm), 1);
-			args.limit = args.start + device->info.ram_user - 1;
+			args.limit = args.start + device->impl->ram_user - 1;
 		} else {
 			args.target = NV_DMA_V0_TARGET_VRAM;
 			args.access = NV_DMA_V0_ACCESS_RDWR;
 			args.start = 0;
-			args.limit = device->info.ram_user - 1;
+			args.limit = device->impl->ram_user - 1;
 		}
 	} else {
 		if (drm->agp.bridge) {
@@ -378,8 +378,8 @@ nouveau_channel_init(struct nouveau_channel *chan, u32 vram, u32 gart)
 	}
 
 	/* allocate dma objects to cover all allowed vram, and gart */
-	if (device->info.family < NV_DEVICE_INFO_V0_FERMI) {
-		if (device->info.family >= NV_DEVICE_INFO_V0_TESLA) {
+	if (device->impl->family < NVIF_DEVICE_FERMI) {
+		if (device->impl->family >= NVIF_DEVICE_TESLA) {
 			args.target = NV_DMA_V0_TARGET_VM;
 			args.access = NV_DMA_V0_ACCESS_VM;
 			args.start = 0;
@@ -388,7 +388,7 @@ nouveau_channel_init(struct nouveau_channel *chan, u32 vram, u32 gart)
 			args.target = NV_DMA_V0_TARGET_VRAM;
 			args.access = NV_DMA_V0_ACCESS_RDWR;
 			args.start = 0;
-			args.limit = device->info.ram_user - 1;
+			args.limit = device->impl->ram_user - 1;
 		}
 
 		ret = nvif_chan_ctxdma_ctor(&chan->chan, "abi16ChanVramCtxDma", vram,
@@ -397,7 +397,7 @@ nouveau_channel_init(struct nouveau_channel *chan, u32 vram, u32 gart)
 		if (ret)
 			return ret;
 
-		if (device->info.family >= NV_DEVICE_INFO_V0_TESLA) {
+		if (device->impl->family >= NVIF_DEVICE_TESLA) {
 			args.target = NV_DMA_V0_TARGET_VM;
 			args.access = NV_DMA_V0_ACCESS_VM;
 			args.start = 0;
@@ -456,7 +456,7 @@ nouveau_channel_init(struct nouveau_channel *chan, u32 vram, u32 gart)
 		PUSH_DATA(&chan->chan.push, 0x00000000);
 
 	/* allocate software object class (used for fences on <= nv05) */
-	if (device->info.family < NV_DEVICE_INFO_V0_CELSIUS) {
+	if (device->impl->family < NVIF_DEVICE_CELSIUS) {
 		ret = nvif_engobj_ctor(&chan->chan, "abi16NvswFence", 0x006e,
 				       NVIF_CLASS_SW_NV04, &chan->nvsw);
 		if (ret)
diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c b/drivers/gpu/drm/nouveau/nouveau_connector.c
index 3063ef792023..a8e5f01ba9dd 100644
--- a/drivers/gpu/drm/nouveau/nouveau_connector.c
+++ b/drivers/gpu/drm/nouveau/nouveau_connector.c
@@ -513,13 +513,13 @@ nouveau_connector_set_encoder(struct drm_connector *connector,
 		return;
 	nv_connector->detected_encoder = nv_encoder;
 
-	if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) {
+	if (drm->device.impl->family >= NVIF_DEVICE_TESLA) {
 		if (nv_encoder->dcb->type == DCB_OUTPUT_DP)
 			connector->interlace_allowed =
 				nv_encoder->caps.dp_interlace;
 		else
 			connector->interlace_allowed =
-				drm->client.device.info.family < NV_DEVICE_INFO_V0_VOLTA;
+				drm->device.impl->family < NVIF_DEVICE_VOLTA;
 		connector->doublescan_allowed = true;
 	} else
 	if (nv_encoder->dcb->type == DCB_OUTPUT_LVDS ||
@@ -528,8 +528,8 @@ nouveau_connector_set_encoder(struct drm_connector *connector,
 		connector->interlace_allowed = false;
 	} else {
 		connector->doublescan_allowed = true;
-		if (drm->client.device.info.family == NV_DEVICE_INFO_V0_KELVIN ||
-		    (drm->client.device.info.family == NV_DEVICE_INFO_V0_CELSIUS &&
+		if (drm->device.impl->family == NVIF_DEVICE_KELVIN ||
+		    (drm->device.impl->family == NVIF_DEVICE_CELSIUS &&
 		     (pdev->device & 0x0ff0) != 0x0100 &&
 		     (pdev->device & 0x0ff0) != 0x0150))
 			/* HW is broken */
@@ -1045,7 +1045,7 @@ get_tmds_link_bandwidth(struct drm_connector *connector)
 		/* Note: these limits are conservative, some Fermi's
 		 * can do 297 MHz. Unclear how this can be determined.
 		 */
-		if (drm->client.device.info.chipset >= 0x120) {
+		if (drm->device.impl->chipset >= 0x120) {
 			const int max_tmds_clock =
 				info->hdmi.scdc.scrambling.supported ?
 				594000 : 340000;
@@ -1053,18 +1053,18 @@ get_tmds_link_bandwidth(struct drm_connector *connector)
 				min(info->max_tmds_clock, max_tmds_clock) :
 				max_tmds_clock;
 		}
-		if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_KEPLER)
+		if (drm->device.impl->family >= NVIF_DEVICE_KEPLER)
 			return 297000;
-		if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_FERMI)
+		if (drm->device.impl->family >= NVIF_DEVICE_FERMI)
 			return 225000;
 	}
 
 	if (dcb->location != DCB_LOC_ON_CHIP ||
-	    drm->client.device.info.chipset >= 0x46)
+	    drm->device.impl->chipset >= 0x46)
 		return 165000 * duallink_scale;
-	else if (drm->client.device.info.chipset >= 0x40)
+	else if (drm->device.impl->chipset >= 0x40)
 		return 155000 * duallink_scale;
-	else if (drm->client.device.info.chipset >= 0x18)
+	else if (drm->device.impl->chipset >= 0x18)
 		return 135000 * duallink_scale;
 	else
 		return 112000 * duallink_scale;
@@ -1348,7 +1348,7 @@ nouveau_connector_create(struct drm_device *dev, int index)
 		 * figure out something suitable ourselves
 		 */
 		if (nv_connector->type == DCB_CONNECTOR_NONE &&
-		    !WARN_ON(drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA)) {
+		    !WARN_ON(drm->device.impl->family >= NVIF_DEVICE_TESLA)) {
 			struct dcb_table *dcbt = &drm->vbios.dcb;
 			u32 encoders = 0;
 			int i;
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c
index 3f75c7f33429..f6fb4e6ab4f6 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -155,7 +155,7 @@ nouveau_decode_mod(struct nouveau_drm *drm,
 		*tile_mode = (uint32_t)(modifier & 0xF);
 		*kind = (uint8_t)((modifier >> 12) & 0xFF);
 
-		if (drm->client.device.info.chipset >= 0xc0)
+		if (drm->device.impl->chipset >= 0xc0)
 			*tile_mode <<= 4;
 	}
 }
@@ -196,9 +196,8 @@ nouveau_validate_decode_mod(struct nouveau_drm *drm,
 	struct nouveau_display *disp = nouveau_display(drm->dev);
 	int mod;
 
-	if (drm->client.device.info.family < NV_DEVICE_INFO_V0_TESLA) {
+	if (drm->device.impl->family < NVIF_DEVICE_TESLA)
 		return -EINVAL;
-	}
 
 	BUG_ON(!disp->format_modifiers);
 
@@ -240,9 +239,9 @@ nouveau_get_height_in_blocks(struct nouveau_drm *drm,
 	uint32_t log_gob_height;
 	uint32_t log_block_height;
 
-	BUG_ON(drm->client.device.info.family < NV_DEVICE_INFO_V0_TESLA);
+	BUG_ON(drm->device.impl->family < NVIF_DEVICE_TESLA);
 
-	if (drm->client.device.info.family < NV_DEVICE_INFO_V0_FERMI)
+	if (drm->device.impl->family < NVIF_DEVICE_FERMI)
 		log_gob_height = 2;
 	else
 		log_gob_height = 3;
@@ -260,9 +259,9 @@ nouveau_check_bl_size(struct nouveau_drm *drm, struct nouveau_bo *nvbo,
 	uint32_t gob_size, bw, bh;
 	uint64_t bl_size;
 
-	BUG_ON(drm->client.device.info.family < NV_DEVICE_INFO_V0_TESLA);
+	BUG_ON(drm->device.impl->family < NVIF_DEVICE_TESLA);
 
-	if (drm->client.device.info.chipset >= 0xc0) {
+	if (drm->device.impl->chipset >= 0xc0) {
 		if (tile_mode & 0xF)
 			return -EINVAL;
 		tile_mode >>= 4;
@@ -271,7 +270,7 @@ nouveau_check_bl_size(struct nouveau_drm *drm, struct nouveau_bo *nvbo,
 	if (tile_mode & 0xFFFFFFF0)
 		return -EINVAL;
 
-	if (drm->client.device.info.family < NV_DEVICE_INFO_V0_FERMI)
+	if (drm->device.impl->family < NVIF_DEVICE_FERMI)
 		gob_size = 256;
 	else
 		gob_size = 512;
@@ -307,7 +306,7 @@ nouveau_framebuffer_new(struct drm_device *dev,
 	int ret;
 
         /* YUV overlays have special requirements pre-NV50 */
-	if (drm->client.device.info.family < NV_DEVICE_INFO_V0_TESLA &&
+	if (drm->device.impl->family < NVIF_DEVICE_TESLA &&
 
 	    (mode_cmd->pixel_format == DRM_FORMAT_YUYV ||
 	     mode_cmd->pixel_format == DRM_FORMAT_UYVY ||
@@ -698,15 +697,15 @@ nouveau_display_create(struct drm_device *dev)
 
 	dev->mode_config.min_width = 0;
 	dev->mode_config.min_height = 0;
-	if (drm->client.device.info.family < NV_DEVICE_INFO_V0_CELSIUS) {
+	if (drm->device.impl->family < NVIF_DEVICE_CELSIUS) {
 		dev->mode_config.max_width = 2048;
 		dev->mode_config.max_height = 2048;
 	} else
-	if (drm->client.device.info.family < NV_DEVICE_INFO_V0_TESLA) {
+	if (drm->device.impl->family < NVIF_DEVICE_TESLA) {
 		dev->mode_config.max_width = 4096;
 		dev->mode_config.max_height = 4096;
 	} else
-	if (drm->client.device.info.family < NV_DEVICE_INFO_V0_FERMI) {
+	if (drm->device.impl->family < NVIF_DEVICE_FERMI) {
 		dev->mode_config.max_width = 8192;
 		dev->mode_config.max_height = 8192;
 	} else {
@@ -717,7 +716,7 @@ nouveau_display_create(struct drm_device *dev)
 	dev->mode_config.preferred_depth = 24;
 	dev->mode_config.prefer_shadow = 1;
 
-	if (drm->client.device.info.chipset < 0x11)
+	if (drm->device.impl->chipset < 0x11)
 		dev->mode_config.async_page_flip = false;
 	else
 		dev->mode_config.async_page_flip = true;
@@ -854,7 +853,7 @@ nouveau_display_dumb_create(struct drm_file *file_priv, struct drm_device *dev,
 	args->size = roundup(args->size, PAGE_SIZE);
 
 	/* Use VRAM if there is any ; otherwise fallback to system memory */
-	if (nouveau_drm(dev)->client.device.info.ram_size != 0)
+	if (nouveau_drm(dev)->device.impl->ram_size != 0)
 		domain = NOUVEAU_GEM_DOMAIN_VRAM;
 	else
 		domain = NOUVEAU_GEM_DOMAIN_GART;
diff --git a/drivers/gpu/drm/nouveau/nouveau_dmem.c b/drivers/gpu/drm/nouveau/nouveau_dmem.c
index a0c24456e031..2cb06f0a217f 100644
--- a/drivers/gpu/drm/nouveau/nouveau_dmem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_dmem.c
@@ -591,7 +591,7 @@ nouveau_dmem_init(struct nouveau_drm *drm)
 	int ret;
 
 	/* This only make sense on PASCAL or newer */
-	if (drm->client.device.info.family < NV_DEVICE_INFO_V0_PASCAL)
+	if (drm->device.impl->family < NVIF_DEVICE_PASCAL)
 		return;
 
 	if (!(drm->dmem = kzalloc(sizeof(*drm->dmem), GFP_KERNEL)))
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index fb01f51fd689..6c4469f31c53 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -311,11 +311,11 @@ nouveau_accel_gr_init(struct nouveau_drm *drm)
 	 * synchronisation of page flips, as well as to implement fences
 	 * on TNT/TNT2 HW that lacks any kind of support in host.
 	 */
-	if (device->info.family < NV_DEVICE_INFO_V0_TESLA) {
+	if (device->impl->family < NVIF_DEVICE_TESLA) {
 		ret = nvif_engobj_ctor(&drm->channel->chan, "drmNvSw", NVDRM_NVSW,
 				       nouveau_abi16_swclass(drm), &drm->channel->nvsw);
 
-		if (ret == 0 && device->info.chipset >= 0x11) {
+		if (ret == 0 && device->impl->chipset >= 0x11) {
 			ret = nvif_engobj_ctor(&drm->channel->chan, "drmBlit", 0x005f, 0x009f,
 					       &drm->channel->blit);
 		}
@@ -325,7 +325,7 @@ nouveau_accel_gr_init(struct nouveau_drm *drm)
 
 			ret = PUSH_WAIT(push, 8);
 			if (ret == 0) {
-				if (device->info.chipset >= 0x11) {
+				if (device->impl->chipset >= 0x11) {
 					PUSH_NVSQ(push, NV05F, 0x0000, 0x005f);
 					PUSH_NVSQ(push, NV09F, 0x0120, 0,
 							       0x0124, 1,
@@ -346,7 +346,7 @@ nouveau_accel_gr_init(struct nouveau_drm *drm)
 	 * even if notification is never requested, so, allocate a ctxdma on
 	 * any GPU where it's possible we'll end up using M2MF for BO moves.
 	 */
-	if (device->info.family < NV_DEVICE_INFO_V0_FERMI) {
+	if (device->impl->family < NVIF_DEVICE_FERMI) {
 		ret = nvkm_gpuobj_new(nvxx_device(drm), 32, 0, false, NULL, &drm->notify);
 		if (ret) {
 			NV_ERROR(drm, "failed to allocate notifier, %d\n", ret);
@@ -435,7 +435,7 @@ nouveau_accel_init(struct nouveau_drm *drm)
 	}
 
 	/* Volta requires access to a doorbell register for kickoff. */
-	if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_VOLTA) {
+	if (device->impl->family >= NVIF_DEVICE_VOLTA) {
 		ret = nvif_user_ctor(&drm->device, "drmUsermode");
 		if (ret)
 			return;
@@ -577,7 +577,7 @@ nouveau_drm_device_init(struct drm_device *dev, struct nvkm_device *nvkm)
 	 * nosnoop capability.  hopefully won't cause issues until a
 	 * better fix is found - assuming there is one...
 	 */
-	if (drm->client.device.info.chipset == 0xc1)
+	if (drm->device.impl->chipset == 0xc1)
 		nvif_mask(&drm->client.device.object, 0x00088080, 0x00000800, 0x00000000);
 
 	nouveau_vga_init(drm);
@@ -799,7 +799,7 @@ static int nouveau_drm_probe(struct pci_dev *pdev,
 	if (ret)
 		goto fail_drm_dev_init;
 
-	if (nouveau_drm(drm_dev)->client.device.info.ram_size <= 32 * 1024 * 1024)
+	if (nouveau_drm(drm_dev)->device.impl->ram_size <= 32 * 1024 * 1024)
 		drm_fbdev_generic_setup(drm_dev, 8);
 	else
 		drm_fbdev_generic_setup(drm_dev, 32);
diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
index 9ae2cee1c7c5..ede2bf30ebc2 100644
--- a/drivers/gpu/drm/nouveau/nouveau_gem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
@@ -286,7 +286,7 @@ nouveau_gem_new(struct nouveau_cli *cli, u64 size, int align, uint32_t domain,
 	 */
 	nvbo->valid_domains = NOUVEAU_GEM_DOMAIN_VRAM |
 			      NOUVEAU_GEM_DOMAIN_GART;
-	if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA)
+	if (drm->device.impl->family >= NVIF_DEVICE_TESLA)
 		nvbo->valid_domains &= domain;
 
 	if (nvbo->no_share) {
@@ -305,6 +305,7 @@ nouveau_gem_info(struct drm_file *file_priv, struct drm_gem_object *gem,
 	struct nouveau_cli *cli = nouveau_cli(file_priv);
 	struct nouveau_bo *nvbo = nouveau_gem_object(gem);
 	struct nouveau_vmm *vmm = nouveau_cli_vmm(cli);
+	struct nouveau_drm *drm = cli->drm;
 	struct nouveau_vma *vma;
 
 	if (is_power_of_2(nvbo->valid_domains))
@@ -328,10 +329,10 @@ nouveau_gem_info(struct drm_file *file_priv, struct drm_gem_object *gem,
 	rep->map_handle = drm_vma_node_offset_addr(&nvbo->bo.base.vma_node);
 	rep->tile_mode = nvbo->mode;
 	rep->tile_flags = nvbo->contig ? 0 : NOUVEAU_GEM_TILE_NONCONTIG;
-	if (cli->device.info.family >= NV_DEVICE_INFO_V0_FERMI)
+	if (drm->device.impl->family >= NVIF_DEVICE_FERMI)
 		rep->tile_flags |= nvbo->kind << 8;
 	else
-	if (cli->device.info.family >= NV_DEVICE_INFO_V0_TESLA)
+	if (drm->device.impl->family >= NVIF_DEVICE_TESLA)
 		rep->tile_flags |= nvbo->kind << 8 | nvbo->comp << 16;
 	else
 		rep->tile_flags |= nvbo->zeta;
@@ -600,7 +601,7 @@ validate_list(struct nouveau_channel *chan,
 			return ret;
 		}
 
-		if (drm->client.device.info.family < NV_DEVICE_INFO_V0_TESLA) {
+		if (drm->device.impl->family < NVIF_DEVICE_TESLA) {
 			if (nvbo->offset == b->presumed.offset &&
 			    ((nvbo->bo.resource->mem_type == TTM_PL_VRAM &&
 			      b->presumed.domain & NOUVEAU_GEM_DOMAIN_VRAM) ||
@@ -870,7 +871,7 @@ nouveau_gem_ioctl_pushbuf(struct drm_device *dev, void *data,
 			nv50_dma_push(chan, addr, length, no_prefetch);
 		}
 	} else
-	if (drm->client.device.info.chipset >= 0x25) {
+	if (drm->device.impl->chipset >= 0x25) {
 		ret = PUSH_WAIT(&chan->chan.push, req->nr_push * 2);
 		if (ret) {
 			NV_PRINTK(err, cli, "cal_space: %d\n", ret);
@@ -965,7 +966,7 @@ nouveau_gem_ioctl_pushbuf(struct drm_device *dev, void *data,
 		req->suffix0 = 0x00000000;
 		req->suffix1 = 0x00000000;
 	} else
-	if (drm->client.device.info.chipset >= 0x25) {
+	if (drm->device.impl->chipset >= 0x25) {
 		req->suffix0 = 0x00020000;
 		req->suffix1 = 0x00000000;
 	} else {
diff --git a/drivers/gpu/drm/nouveau/nouveau_sgdma.c b/drivers/gpu/drm/nouveau/nouveau_sgdma.c
index 172744470bd1..e90d8b47be47 100644
--- a/drivers/gpu/drm/nouveau/nouveau_sgdma.c
+++ b/drivers/gpu/drm/nouveau/nouveau_sgdma.c
@@ -42,7 +42,7 @@ nouveau_sgdma_bind(struct ttm_device *bdev, struct ttm_tt *ttm, struct ttm_resou
 	if (ret)
 		return ret;
 
-	if (drm->client.device.info.family < NV_DEVICE_INFO_V0_TESLA) {
+	if (drm->device.impl->family < NVIF_DEVICE_TESLA) {
 		ret = nouveau_mem_map(mem, &drm->cli.vmm.vmm, &mem->vma[0]);
 		if (ret) {
 			nouveau_mem_fini(mem);
diff --git a/drivers/gpu/drm/nouveau/nouveau_svm.c b/drivers/gpu/drm/nouveau/nouveau_svm.c
index 534448f82daa..55895e746003 100644
--- a/drivers/gpu/drm/nouveau/nouveau_svm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_svm.c
@@ -1048,7 +1048,7 @@ nouveau_svm_init(struct nouveau_drm *drm)
 	 * otherwise clients will have a trivial way to trash the GPU
 	 * for everyone.
 	 */
-	if (drm->client.device.info.family > NV_DEVICE_INFO_V0_PASCAL)
+	if (drm->device.impl->family > NVIF_DEVICE_PASCAL)
 		return;
 
 	switch (drm->device.impl->faultbuf.oclass) {
diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c
index 36f5be963851..5b0f78e48cc7 100644
--- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
@@ -70,7 +70,7 @@ nouveau_vram_manager_new(struct ttm_resource_manager *man,
 	struct nouveau_drm *drm = nouveau_bdev(bo->bdev);
 	int ret;
 
-	if (drm->client.device.info.ram_size == 0)
+	if (drm->device.impl->ram_size == 0)
 		return -ENOMEM;
 
 	ret = nouveau_mem_new(drm, nvbo->kind, nvbo->comp, res);
@@ -180,7 +180,7 @@ nouveau_ttm_init_host(struct nouveau_drm *drm, u8 kind)
 static int
 nouveau_ttm_init_vram(struct nouveau_drm *drm)
 {
-	if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) {
+	if (drm->device.impl->family >= NVIF_DEVICE_TESLA) {
 		struct ttm_resource_manager *man = kzalloc(sizeof(*man), GFP_KERNEL);
 
 		if (!man)
@@ -204,7 +204,7 @@ nouveau_ttm_fini_vram(struct nouveau_drm *drm)
 {
 	struct ttm_resource_manager *man = ttm_manager_type(&drm->ttm.bdev, TTM_PL_VRAM);
 
-	if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) {
+	if (drm->device.impl->family >= NVIF_DEVICE_TESLA) {
 		ttm_resource_manager_set_used(man, false);
 		ttm_resource_manager_evict_all(&drm->ttm.bdev, man);
 		ttm_resource_manager_cleanup(man);
@@ -221,7 +221,7 @@ nouveau_ttm_init_gtt(struct nouveau_drm *drm)
 	unsigned long size_pages = drm->gem.gart_available >> PAGE_SHIFT;
 	const struct ttm_resource_manager_func *func = NULL;
 
-	if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA)
+	if (drm->device.impl->family >= NVIF_DEVICE_TESLA)
 		func = &nouveau_gart_manager;
 	else if (!drm->agp.bridge)
 		func = &nv04_gart_manager;
@@ -246,8 +246,7 @@ nouveau_ttm_fini_gtt(struct nouveau_drm *drm)
 {
 	struct ttm_resource_manager *man = ttm_manager_type(&drm->ttm.bdev, TTM_PL_TT);
 
-	if (drm->client.device.info.family < NV_DEVICE_INFO_V0_TESLA &&
-	    drm->agp.bridge)
+	if (drm->device.impl->family < NVIF_DEVICE_TESLA && drm->agp.bridge)
 		ttm_range_man_fini(&drm->ttm.bdev, TTM_PL_TT);
 	else {
 		ttm_resource_manager_set_used(man, false);
@@ -271,15 +270,15 @@ nouveau_ttm_init(struct nouveau_drm *drm)
 	if (ret)
 		return ret;
 
-	if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA &&
-	    drm->client.device.info.chipset != 0x50) {
+	if (drm->device.impl->family >= NVIF_DEVICE_TESLA &&
+	    drm->device.impl->chipset != 0x50) {
 		ret = nouveau_ttm_init_host(drm, NVIF_MEM_KIND);
 		if (ret)
 			return ret;
 	}
 
-	if (drm->client.device.info.platform != NV_DEVICE_INFO_V0_SOC &&
-	    drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) {
+	if (drm->device.impl->platform != NVIF_DEVICE_SOC &&
+	    drm->device.impl->family >= NVIF_DEVICE_TESLA) {
 		typei = nvif_mmu_type(mmu, NVIF_MEM_VRAM | NVIF_MEM_MAPPABLE |
 					   NVIF_MEM_KIND |
 					   NVIF_MEM_COMP |
@@ -310,7 +309,7 @@ nouveau_ttm_init(struct nouveau_drm *drm)
 	}
 
 	/* VRAM init */
-	drm->gem.vram_available = drm->client.device.info.ram_user;
+	drm->gem.vram_available = drm->device.impl->ram_user;
 
 	arch_io_reserve_memtype_wc(device->func->resource_addr(device, 1),
 				   device->func->resource_size(device, 1));
diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
index f8bf0ec26844..ff7aeafb068b 100644
--- a/drivers/gpu/drm/nouveau/nouveau_vga.c
+++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
@@ -12,13 +12,13 @@ static unsigned int
 nouveau_vga_set_decode(struct pci_dev *pdev, bool state)
 {
 	struct nouveau_drm *drm = nouveau_drm(pci_get_drvdata(pdev));
-	struct nvif_object *device = &drm->client.device.object;
+	struct nvif_device *device = &drm->device;
 
-	if (drm->client.device.info.family == NV_DEVICE_INFO_V0_CURIE &&
-	    drm->client.device.info.chipset >= 0x4c)
+	if (device->impl->family == NVIF_DEVICE_CURIE &&
+	    device->impl->chipset >= 0x4c)
 		nvif_wr32(device, 0x088060, state);
 	else
-	if (drm->client.device.info.chipset >= 0x40)
+	if (device->impl->chipset >= 0x40)
 		nvif_wr32(device, 0x088054, state);
 	else
 		nvif_wr32(device, 0x001854, state);
diff --git a/drivers/gpu/drm/nouveau/nv84_fence.c b/drivers/gpu/drm/nouveau/nv84_fence.c
index 0626c24ca065..4b107c1a5686 100644
--- a/drivers/gpu/drm/nouveau/nv84_fence.c
+++ b/drivers/gpu/drm/nouveau/nv84_fence.c
@@ -215,7 +215,7 @@ nv84_fence_create(struct nouveau_drm *drm)
 	mutex_init(&priv->mutex);
 
 	/* Use VRAM if there is any ; otherwise fallback to system memory */
-	domain = drm->client.device.info.ram_size != 0 ?
+	domain = drm->device.impl->ram_size != 0 ?
 		NOUVEAU_GEM_DOMAIN_VRAM :
 		 /*
 		  * fences created in sysmem must be non-cached or we
diff --git a/drivers/gpu/drm/nouveau/nvif/device.c b/drivers/gpu/drm/nouveau/nvif/device.c
index 131286239b51..7c2b57d562a4 100644
--- a/drivers/gpu/drm/nouveau/nvif/device.c
+++ b/drivers/gpu/drm/nouveau/nvif/device.c
@@ -85,19 +85,5 @@ nvif_device_ctor(struct nvif_client *client, const char *name, struct nvif_devic
 
 	nvif_object_ctor(&client->object, name ?: "nvifDevice", 0, 0, &device->object);
 	device->object.client = client;
-
-	if (ret == 0) {
-		/*FIXME: remove after moving users to device->impl */
-		device->info.version = 0;
-		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;
 }
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 155/156] drm/nouveau: remove remaining usage of nvif_device.object.map
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (153 preceding siblings ...)
  2024-04-16 23:40 ` [PATCH 154/156] drm/nouveau: remove remaining usage of nvif_device.info Ben Skeggs
@ 2024-04-16 23:40 ` Ben Skeggs
  2024-04-16 23:40 ` [PATCH 156/156] drm/nouveau: remove remaining usage of nouveau_drm.client Ben Skeggs
                   ` (2 subsequent siblings)
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:40 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- accesses to PRI are now via nvif_device.map

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/dispnv04/dac.c        | 10 +++++-----
 drivers/gpu/drm/nouveau/dispnv04/dfp.c        |  2 +-
 drivers/gpu/drm/nouveau/dispnv04/hw.c         |  8 ++++----
 drivers/gpu/drm/nouveau/dispnv04/hw.h         | 20 +++++++++----------
 drivers/gpu/drm/nouveau/dispnv04/overlay.c    |  8 ++++----
 drivers/gpu/drm/nouveau/dispnv04/tvnv17.h     | 10 ++++++----
 drivers/gpu/drm/nouveau/dispnv50/crc.c        |  2 +-
 drivers/gpu/drm/nouveau/dispnv50/curs507a.c   |  2 +-
 drivers/gpu/drm/nouveau/include/nvif/object.h | 10 ++++------
 drivers/gpu/drm/nouveau/nouveau_backlight.c   |  8 +++-----
 drivers/gpu/drm/nouveau/nouveau_bios.c        |  6 +++---
 drivers/gpu/drm/nouveau/nouveau_debugfs.c     |  2 +-
 drivers/gpu/drm/nouveau/nouveau_drm.c         |  8 ++------
 drivers/gpu/drm/nouveau/nouveau_led.c         |  4 ++--
 drivers/gpu/drm/nouveau/nouveau_svm.c         |  4 ++--
 drivers/gpu/drm/nouveau/nvif/dispchan.c       |  4 ++--
 drivers/gpu/drm/nouveau/nvif/object.c         |  4 ----
 17 files changed, 51 insertions(+), 61 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv04/dac.c b/drivers/gpu/drm/nouveau/dispnv04/dac.c
index 4d8e34274c4e..c68e94de7b37 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/dac.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/dac.c
@@ -66,7 +66,7 @@ int nv04_dac_output_offset(struct drm_encoder *encoder)
 static int sample_load_twice(struct drm_device *dev, bool sense[2])
 {
 	struct nouveau_drm *drm = nouveau_drm(dev);
-	struct nvif_object *device = &drm->client.device.object;
+	struct nvif_device *device = &drm->device;
 	int i;
 
 	for (i = 0; i < 2; i++) {
@@ -80,19 +80,19 @@ static int sample_load_twice(struct drm_device *dev, bool sense[2])
 		 * use a 10ms timeout (guards against crtc being inactive, in
 		 * which case blank state would never change)
 		 */
-		if (nvif_msec(&drm->client.device, 10,
+		if (nvif_msec(device, 10,
 			if (!(nvif_rd32(device, NV_PRMCIO_INP0__COLOR) & 1))
 				break;
 		) < 0)
 			return -EBUSY;
 
-		if (nvif_msec(&drm->client.device, 10,
+		if (nvif_msec(device, 10,
 			if ( (nvif_rd32(device, NV_PRMCIO_INP0__COLOR) & 1))
 				break;
 		) < 0)
 			return -EBUSY;
 
-		if (nvif_msec(&drm->client.device, 10,
+		if (nvif_msec(device, 10,
 			if (!(nvif_rd32(device, NV_PRMCIO_INP0__COLOR) & 1))
 				break;
 		) < 0)
@@ -133,7 +133,7 @@ static enum drm_connector_status nv04_dac_detect(struct drm_encoder *encoder,
 						 struct drm_connector *connector)
 {
 	struct drm_device *dev = encoder->dev;
-	struct nvif_object *device = &nouveau_drm(dev)->client.device.object;
+	struct nvif_device *device = &nouveau_drm(dev)->device;
 	struct nouveau_drm *drm = nouveau_drm(dev);
 	uint8_t saved_seq1, saved_pi, saved_rpc1, saved_cr_mode;
 	uint8_t saved_palette0[3], saved_palette_mask;
diff --git a/drivers/gpu/drm/nouveau/dispnv04/dfp.c b/drivers/gpu/drm/nouveau/dispnv04/dfp.c
index da2a759dbaab..0eff4235cdf1 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/dfp.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/dfp.c
@@ -487,7 +487,7 @@ static void nv04_dfp_update_backlight(struct drm_encoder *encoder, int mode)
 {
 #ifdef __powerpc__
 	struct drm_device *dev = encoder->dev;
-	struct nvif_object *device = &nouveau_drm(dev)->client.device.object;
+	struct nvif_device *device = &nouveau_drm(dev)->device;
 	struct pci_dev *pdev = to_pci_dev(dev->dev);
 
 	/* BIOS scripts usually take care of the backlight, thanks
diff --git a/drivers/gpu/drm/nouveau/dispnv04/hw.c b/drivers/gpu/drm/nouveau/dispnv04/hw.c
index ab240df4d85c..316d4b5265d6 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/hw.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/hw.c
@@ -746,11 +746,11 @@ nv_load_state_ext(struct drm_device *dev, int head,
 		if (device->impl->family < NVIF_DEVICE_KELVIN) {
 			/* Not waiting for vertical retrace before modifying
 			   CRE_53/CRE_54 causes lockups. */
-			nvif_msec(&drm->client.device, 650,
+			nvif_msec(device, 650,
 				if ( (nvif_rd32(device, NV_PRMCIO_INP0__COLOR) & 8))
 					break;
 			);
-			nvif_msec(&drm->client.device, 650,
+			nvif_msec(device, 650,
 				if (!(nvif_rd32(device, NV_PRMCIO_INP0__COLOR) & 8))
 					break;
 			);
@@ -776,7 +776,7 @@ static void
 nv_save_state_palette(struct drm_device *dev, int head,
 		      struct nv04_mode_state *state)
 {
-	struct nvif_object *device = &nouveau_drm(dev)->client.device.object;
+	struct nvif_device *device = &nouveau_drm(dev)->device;
 	int head_offset = head * NV_PRMDIO_SIZE, i;
 
 	nvif_wr08(device, NV_PRMDIO_PIXEL_MASK + head_offset,
@@ -795,7 +795,7 @@ void
 nouveau_hw_load_state_palette(struct drm_device *dev, int head,
 			      struct nv04_mode_state *state)
 {
-	struct nvif_object *device = &nouveau_drm(dev)->client.device.object;
+	struct nvif_device *device = &nouveau_drm(dev)->device;
 	int head_offset = head * NV_PRMDIO_SIZE, i;
 
 	nvif_wr08(device, NV_PRMDIO_PIXEL_MASK + head_offset,
diff --git a/drivers/gpu/drm/nouveau/dispnv04/hw.h b/drivers/gpu/drm/nouveau/dispnv04/hw.h
index b565cd34ed67..4a051b676a58 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/hw.h
+++ b/drivers/gpu/drm/nouveau/dispnv04/hw.h
@@ -59,7 +59,7 @@ extern void nouveau_calc_arb(struct drm_device *, int vclk, int bpp,
 static inline uint32_t NVReadCRTC(struct drm_device *dev,
 					int head, uint32_t reg)
 {
-	struct nvif_object *device = &nouveau_drm(dev)->client.device.object;
+	struct nvif_device *device = &nouveau_drm(dev)->device;
 	uint32_t val;
 	if (head)
 		reg += NV_PCRTC0_SIZE;
@@ -70,7 +70,7 @@ static inline uint32_t NVReadCRTC(struct drm_device *dev,
 static inline void NVWriteCRTC(struct drm_device *dev,
 					int head, uint32_t reg, uint32_t val)
 {
-	struct nvif_object *device = &nouveau_drm(dev)->client.device.object;
+	struct nvif_device *device = &nouveau_drm(dev)->device;
 	if (head)
 		reg += NV_PCRTC0_SIZE;
 	nvif_wr32(device, reg, val);
@@ -79,7 +79,7 @@ static inline void NVWriteCRTC(struct drm_device *dev,
 static inline uint32_t NVReadRAMDAC(struct drm_device *dev,
 					int head, uint32_t reg)
 {
-	struct nvif_object *device = &nouveau_drm(dev)->client.device.object;
+	struct nvif_device *device = &nouveau_drm(dev)->device;
 	uint32_t val;
 	if (head)
 		reg += NV_PRAMDAC0_SIZE;
@@ -90,7 +90,7 @@ static inline uint32_t NVReadRAMDAC(struct drm_device *dev,
 static inline void NVWriteRAMDAC(struct drm_device *dev,
 					int head, uint32_t reg, uint32_t val)
 {
-	struct nvif_object *device = &nouveau_drm(dev)->client.device.object;
+	struct nvif_device *device = &nouveau_drm(dev)->device;
 	if (head)
 		reg += NV_PRAMDAC0_SIZE;
 	nvif_wr32(device, reg, val);
@@ -119,7 +119,7 @@ static inline void nv_write_tmds(struct drm_device *dev,
 static inline void NVWriteVgaCrtc(struct drm_device *dev,
 					int head, uint8_t index, uint8_t value)
 {
-	struct nvif_object *device = &nouveau_drm(dev)->client.device.object;
+	struct nvif_device *device = &nouveau_drm(dev)->device;
 	nvif_wr08(device, NV_PRMCIO_CRX__COLOR + head * NV_PRMCIO_SIZE, index);
 	nvif_wr08(device, NV_PRMCIO_CR__COLOR + head * NV_PRMCIO_SIZE, value);
 }
@@ -127,7 +127,7 @@ static inline void NVWriteVgaCrtc(struct drm_device *dev,
 static inline uint8_t NVReadVgaCrtc(struct drm_device *dev,
 					int head, uint8_t index)
 {
-	struct nvif_object *device = &nouveau_drm(dev)->client.device.object;
+	struct nvif_device *device = &nouveau_drm(dev)->device;
 	uint8_t val;
 	nvif_wr08(device, NV_PRMCIO_CRX__COLOR + head * NV_PRMCIO_SIZE, index);
 	val = nvif_rd08(device, NV_PRMCIO_CR__COLOR + head * NV_PRMCIO_SIZE);
@@ -191,14 +191,14 @@ static inline void NVWritePRMVIO(struct drm_device *dev,
 
 static inline void NVSetEnablePalette(struct drm_device *dev, int head, bool enable)
 {
-	struct nvif_object *device = &nouveau_drm(dev)->client.device.object;
+	struct nvif_device *device = &nouveau_drm(dev)->device;
 	nvif_rd08(device, NV_PRMCIO_INP0__COLOR + head * NV_PRMCIO_SIZE);
 	nvif_wr08(device, NV_PRMCIO_ARX + head * NV_PRMCIO_SIZE, enable ? 0 : 0x20);
 }
 
 static inline bool NVGetEnablePalette(struct drm_device *dev, int head)
 {
-	struct nvif_object *device = &nouveau_drm(dev)->client.device.object;
+	struct nvif_device *device = &nouveau_drm(dev)->device;
 	nvif_rd08(device, NV_PRMCIO_INP0__COLOR + head * NV_PRMCIO_SIZE);
 	return !(nvif_rd08(device, NV_PRMCIO_ARX + head * NV_PRMCIO_SIZE) & 0x20);
 }
@@ -206,7 +206,7 @@ static inline bool NVGetEnablePalette(struct drm_device *dev, int head)
 static inline void NVWriteVgaAttr(struct drm_device *dev,
 					int head, uint8_t index, uint8_t value)
 {
-	struct nvif_object *device = &nouveau_drm(dev)->client.device.object;
+	struct nvif_device *device = &nouveau_drm(dev)->device;
 	if (NVGetEnablePalette(dev, head))
 		index &= ~0x20;
 	else
@@ -220,7 +220,7 @@ static inline void NVWriteVgaAttr(struct drm_device *dev,
 static inline uint8_t NVReadVgaAttr(struct drm_device *dev,
 					int head, uint8_t index)
 {
-	struct nvif_object *device = &nouveau_drm(dev)->client.device.object;
+	struct nvif_device *device = &nouveau_drm(dev)->device;
 	uint8_t val;
 	if (NVGetEnablePalette(dev, head))
 		index &= ~0x20;
diff --git a/drivers/gpu/drm/nouveau/dispnv04/overlay.c b/drivers/gpu/drm/nouveau/dispnv04/overlay.c
index 103b6dddfac4..c367f292cfef 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/overlay.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/overlay.c
@@ -192,7 +192,7 @@ static int
 nv10_disable_plane(struct drm_plane *plane,
 		   struct drm_modeset_acquire_ctx *ctx)
 {
-	struct nvif_object *dev = &nouveau_drm(plane->dev)->client.device.object;
+	struct nvif_device *dev = &nouveau_drm(plane->dev)->device;
 	struct nouveau_plane *nv_plane =
 		container_of(plane, struct nouveau_plane, base);
 
@@ -216,7 +216,7 @@ nv_destroy_plane(struct drm_plane *plane)
 static void
 nv10_set_params(struct nouveau_plane *plane)
 {
-	struct nvif_object *dev = &nouveau_drm(plane->base.dev)->client.device.object;
+	struct nvif_device *dev = &nouveau_drm(plane->base.dev)->device;
 	u32 luma = (plane->brightness - 512) << 16 | plane->contrast;
 	u32 chroma = ((sin_mul(plane->hue, plane->saturation) & 0xffff) << 16) |
 		(cos_mul(plane->hue, plane->saturation) & 0xffff);
@@ -368,7 +368,7 @@ nv04_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
 		  uint32_t src_w, uint32_t src_h,
 		  struct drm_modeset_acquire_ctx *ctx)
 {
-	struct nvif_object *dev = &nouveau_drm(plane->dev)->client.device.object;
+	struct nvif_device *dev = &nouveau_drm(plane->dev)->device;
 	struct nouveau_plane *nv_plane =
 		container_of(plane, struct nouveau_plane, base);
 	struct nouveau_bo *cur = nv_plane->cur;
@@ -443,7 +443,7 @@ static int
 nv04_disable_plane(struct drm_plane *plane,
 		   struct drm_modeset_acquire_ctx *ctx)
 {
-	struct nvif_object *dev = &nouveau_drm(plane->dev)->client.device.object;
+	struct nvif_device *dev = &nouveau_drm(plane->dev)->device;
 	struct nouveau_plane *nv_plane =
 		container_of(plane, struct nouveau_plane, base);
 
diff --git a/drivers/gpu/drm/nouveau/dispnv04/tvnv17.h b/drivers/gpu/drm/nouveau/dispnv04/tvnv17.h
index 29773b325bd9..38599435169c 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/tvnv17.h
+++ b/drivers/gpu/drm/nouveau/dispnv04/tvnv17.h
@@ -130,14 +130,16 @@ void nv17_ctv_update_rescaler(struct drm_encoder *encoder);
 static inline void nv_write_ptv(struct drm_device *dev, uint32_t reg,
 				uint32_t val)
 {
-	struct nvif_device *device = &nouveau_drm(dev)->client.device;
-	nvif_wr32(&device->object, reg, val);
+	struct nvif_device *device = &nouveau_drm(dev)->device;
+
+	nvif_wr32(device, reg, val);
 }
 
 static inline uint32_t nv_read_ptv(struct drm_device *dev, uint32_t reg)
 {
-	struct nvif_device *device = &nouveau_drm(dev)->client.device;
-	return nvif_rd32(&device->object, reg);
+	struct nvif_device *device = &nouveau_drm(dev)->device;
+
+	return nvif_rd32(device, reg);
 }
 
 static inline void nv_write_tv_enc(struct drm_device *dev, uint8_t reg,
diff --git a/drivers/gpu/drm/nouveau/dispnv50/crc.c b/drivers/gpu/drm/nouveau/dispnv50/crc.c
index 97905ec648d0..6d1395b8c597 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/crc.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/crc.c
@@ -223,7 +223,7 @@ static void nv50_crc_wait_ctx_finished(struct nv50_head *head,
 	struct nouveau_drm *drm = nouveau_drm(dev);
 	s64 ret;
 
-	ret = nvif_msec(&drm->client.device, 50,
+	ret = nvif_msec(&drm->device, 50,
 			if (func->ctx_finished(head, ctx)) break;);
 	if (ret == -ETIMEDOUT)
 		NV_ERROR(drm,
diff --git a/drivers/gpu/drm/nouveau/dispnv50/curs507a.c b/drivers/gpu/drm/nouveau/dispnv50/curs507a.c
index 58bfaf036bbb..bf46bca8a149 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/curs507a.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/curs507a.c
@@ -33,7 +33,7 @@
 bool
 curs507a_space(struct nv50_wndw *wndw)
 {
-	nvif_msec(&nouveau_drm(wndw->plane.dev)->client.device, 100,
+	nvif_msec(&nouveau_drm(wndw->plane.dev)->device, 100,
 		if (NVIF_TV32(&wndw->wimm, NV507A, FREE, COUNT, >=, 4))
 			return true;
 	);
diff --git a/drivers/gpu/drm/nouveau/include/nvif/object.h b/drivers/gpu/drm/nouveau/include/nvif/object.h
index 7a90eab48eec..4a60156f0229 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/object.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/object.h
@@ -9,10 +9,6 @@ struct nvif_object {
 	const char *name;
 	u32 handle;
 	s32 oclass;
-	struct {
-		void __iomem *ptr;
-		u64 size;
-	} map;
 };
 
 struct nvif_map {
@@ -37,11 +33,13 @@ int nvif_object_unmap_cpu(struct nvif_map *);
 #define nvif_object(a) (a)->object
 
 #define nvif_rd(a,f,b,c) ({                                                    \
-	u32 _data = f((u8 __iomem *)(a)->map.ptr + (c));                       \
+	struct nvif_map *_map = &(a)->map;                                     \
+	u32 _data = f((u8 __iomem *)_map->ptr + (c));                          \
 	_data;                                                                 \
 })
 #define nvif_wr(a,f,b,c,d) ({                                                  \
-	f((d), (u8 __iomem *)(a)->map.ptr + (c));                              \
+	struct nvif_map *_map = &(a)->map;                                     \
+	f((d), (u8 __iomem *)_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))); })
diff --git a/drivers/gpu/drm/nouveau/nouveau_backlight.c b/drivers/gpu/drm/nouveau/nouveau_backlight.c
index 925856f3b21b..3d63c90247a0 100644
--- a/drivers/gpu/drm/nouveau/nouveau_backlight.c
+++ b/drivers/gpu/drm/nouveau/nouveau_backlight.c
@@ -65,8 +65,7 @@ nv40_get_intensity(struct backlight_device *bd)
 {
 	struct nouveau_encoder *nv_encoder = bl_get_data(bd);
 	struct nouveau_drm *drm = nouveau_drm(nv_encoder->base.base.dev);
-	struct nvif_object *device = &drm->client.device.object;
-	int val = (nvif_rd32(device, NV40_PMC_BACKLIGHT) &
+	int val = (nvif_rd32(&drm->device, NV40_PMC_BACKLIGHT) &
 		   NV40_PMC_BACKLIGHT_MASK) >> 16;
 
 	return val;
@@ -77,7 +76,7 @@ nv40_set_intensity(struct backlight_device *bd)
 {
 	struct nouveau_encoder *nv_encoder = bl_get_data(bd);
 	struct nouveau_drm *drm = nouveau_drm(nv_encoder->base.base.dev);
-	struct nvif_object *device = &drm->client.device.object;
+	struct nvif_device *device = &drm->device;
 	int val = bd->props.brightness;
 	int reg = nvif_rd32(device, NV40_PMC_BACKLIGHT);
 
@@ -99,9 +98,8 @@ nv40_backlight_init(struct nouveau_encoder *encoder,
 		    const struct backlight_ops **ops)
 {
 	struct nouveau_drm *drm = nouveau_drm(encoder->base.base.dev);
-	struct nvif_object *device = &drm->client.device.object;
 
-	if (!(nvif_rd32(device, NV40_PMC_BACKLIGHT) & NV40_PMC_BACKLIGHT_MASK))
+	if (!(nvif_rd32(&drm->device, NV40_PMC_BACKLIGHT) & NV40_PMC_BACKLIGHT_MASK))
 		return -ENODEV;
 
 	props->max_brightness = 31;
diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
index c9c68416d558..6623aab96e25 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bios.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
@@ -218,7 +218,7 @@ int call_lvds_script(struct drm_device *dev, struct dcb_output *dcbent, int head
 	 */
 
 	struct nouveau_drm *drm = nouveau_drm(dev);
-	struct nvif_object *device = &drm->client.device.object;
+	struct nvif_device *device = &drm->device;
 	struct nvbios *bios = &drm->vbios;
 	uint8_t lvds_ver = bios->data[bios->fp.lvdsmanufacturerpointer];
 	uint32_t sel_clk_binding, sel_clk;
@@ -638,7 +638,7 @@ int run_tmds_table(struct drm_device *dev, struct dcb_output *dcbent, int head,
 	 */
 
 	struct nouveau_drm *drm = nouveau_drm(dev);
-	struct nvif_object *device = &drm->client.device.object;
+	struct nvif_device *device = &drm->device;
 	struct nvbios *bios = &drm->vbios;
 	int cv = bios->chip_version;
 	uint16_t clktable = 0, scriptptr;
@@ -1925,7 +1925,7 @@ static int load_nv17_hwsq_ucode_entry(struct drm_device *dev, struct nvbios *bio
 	 */
 
 	struct nouveau_drm *drm = nouveau_drm(dev);
-	struct nvif_object *device = &drm->client.device.object;
+	struct nvif_device *device = &drm->device;
 	uint8_t bytes_to_write;
 	uint16_t hwsq_entry_offset;
 	int i;
diff --git a/drivers/gpu/drm/nouveau/nouveau_debugfs.c b/drivers/gpu/drm/nouveau/nouveau_debugfs.c
index 0c744a72aff2..213a01914746 100644
--- a/drivers/gpu/drm/nouveau/nouveau_debugfs.c
+++ b/drivers/gpu/drm/nouveau/nouveau_debugfs.c
@@ -58,7 +58,7 @@ nouveau_debugfs_strap_peek(struct seq_file *m, void *data)
 	}
 
 	seq_printf(m, "0x%08x\n",
-		   nvif_rd32(&drm->client.device.object, 0x101000));
+		   nvif_rd32(&drm->device, 0x101000));
 
 	pm_runtime_mark_last_busy(drm->dev->dev);
 	pm_runtime_put_autosuspend(drm->dev->dev);
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 6c4469f31c53..26a89ab6d462 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -183,7 +183,6 @@ 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);
 	nvif_client_dtor(&cli->base);
 }
@@ -214,8 +213,6 @@ 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, "drmMmu", &cli->mmu);
 	if (ret) {
 		NV_PRINTK(err, cli, "MMU allocation failed: %d\n", ret);
@@ -578,7 +575,7 @@ nouveau_drm_device_init(struct drm_device *dev, struct nvkm_device *nvkm)
 	 * better fix is found - assuming there is one...
 	 */
 	if (drm->device.impl->chipset == 0xc1)
-		nvif_mask(&drm->client.device.object, 0x00088080, 0x00000800, 0x00000000);
+		nvif_mask(&drm->device, 0x00088080, 0x00000800, 0x00000000);
 
 	nouveau_vga_init(drm);
 
@@ -1037,7 +1034,6 @@ nouveau_pmops_runtime_resume(struct device *dev)
 	struct pci_dev *pdev = to_pci_dev(dev);
 	struct drm_device *drm_dev = pci_get_drvdata(pdev);
 	struct nouveau_drm *drm = nouveau_drm(drm_dev);
-	struct nvif_device *device = &nouveau_drm(drm_dev)->client.device;
 	int ret;
 
 	if (!nouveau_pmops_runtime()) {
@@ -1059,7 +1055,7 @@ nouveau_pmops_runtime_resume(struct device *dev)
 	}
 
 	/* do magic */
-	nvif_mask(&device->object, 0x088488, (1 << 25), (1 << 25));
+	nvif_mask(&drm->device, 0x088488, (1 << 25), (1 << 25));
 	drm_dev->switch_power_state = DRM_SWITCH_POWER_ON;
 
 	/* Monitors may have been connected / disconnected during suspend */
diff --git a/drivers/gpu/drm/nouveau/nouveau_led.c b/drivers/gpu/drm/nouveau/nouveau_led.c
index ac950518a820..0a6a247a42e7 100644
--- a/drivers/gpu/drm/nouveau/nouveau_led.c
+++ b/drivers/gpu/drm/nouveau/nouveau_led.c
@@ -38,7 +38,7 @@ nouveau_led_get_brightness(struct led_classdev *led)
 {
 	struct drm_device *drm_dev = container_of(led, struct nouveau_led, led)->dev;
 	struct nouveau_drm *drm = nouveau_drm(drm_dev);
-	struct nvif_object *device = &drm->client.device.object;
+	struct nvif_device *device = &drm->device;
 	u32 div, duty;
 
 	div =  nvif_rd32(device, 0x61c880) & 0x00ffffff;
@@ -55,7 +55,7 @@ nouveau_led_set_brightness(struct led_classdev *led, enum led_brightness value)
 {
 	struct drm_device *drm_dev = container_of(led, struct nouveau_led, led)->dev;
 	struct nouveau_drm *drm = nouveau_drm(drm_dev);
-	struct nvif_object *device = &drm->client.device.object;
+	struct nvif_device *device = &drm->device;
 
 	u32 input_clk = 27e6; /* PDISPLAY.SOR[1].PWM is connected to the crystal */
 	u32 freq = 100; /* this is what nvidia uses and it should be good-enough */
diff --git a/drivers/gpu/drm/nouveau/nouveau_svm.c b/drivers/gpu/drm/nouveau/nouveau_svm.c
index 55895e746003..5b94f6e3a39d 100644
--- a/drivers/gpu/drm/nouveau/nouveau_svm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_svm.c
@@ -711,7 +711,7 @@ nouveau_svm_fault(struct work_struct *work)
 {
 	struct nouveau_svm_fault_buffer *buffer = container_of(work, typeof(*buffer), work);
 	struct nouveau_svm *svm = container_of(buffer, typeof(*svm), buffer[buffer->id]);
-	struct nvif_object *device = &svm->drm->client.device.object;
+	struct nvif_device *device = &svm->drm->device;
 	struct nouveau_svmm *svmm;
 	struct {
 		struct nouveau_pfnmap_args i;
@@ -935,7 +935,7 @@ static int
 nouveau_svm_fault_buffer_init(struct nouveau_svm *svm, int id)
 {
 	struct nouveau_svm_fault_buffer *buffer = &svm->buffer[id];
-	struct nvif_object *device = &svm->drm->client.device.object;
+	struct nvif_device *device = &svm->drm->device;
 
 	buffer->get = nvif_rd32(device, buffer->getaddr);
 	buffer->put = nvif_rd32(device, buffer->putaddr);
diff --git a/drivers/gpu/drm/nouveau/nvif/dispchan.c b/drivers/gpu/drm/nouveau/nvif/dispchan.c
index 03738de5d791..9b84dab6b625 100644
--- a/drivers/gpu/drm/nouveau/nvif/dispchan.c
+++ b/drivers/gpu/drm/nouveau/nvif/dispchan.c
@@ -58,9 +58,9 @@ nvif_dispchan_kick(struct nvif_push *push)
 		if (chan->push.mem.type & NVIF_MEM_VRAM) {
 			struct nvif_device *device = chan->disp->device;
 
-			nvif_wr32(&device->object, 0x070000, 0x00000001);
+			nvif_wr32(device, 0x070000, 0x00000001);
 			nvif_msec(device, 2000,
-				if (!(nvif_rd32(&device->object, 0x070000) & 0x00000002))
+				if (!(nvif_rd32(device, 0x070000) & 0x00000002))
 					break;
 			);
 		}
diff --git a/drivers/gpu/drm/nouveau/nvif/object.c b/drivers/gpu/drm/nouveau/nvif/object.c
index 8d4d7a93b92f..ce2f8c30f98a 100644
--- a/drivers/gpu/drm/nouveau/nvif/object.c
+++ b/drivers/gpu/drm/nouveau/nvif/object.c
@@ -67,8 +67,6 @@ nvif_object_map_cpu(struct nvif_object *object,
 	map->object = object;
 	map->impl = impl;
 	map->ptr = ptr;
-
-	object->map.ptr = map->ptr; /*FIXME: needed by nvif_rd/wr */
 	return 0;
 }
 
@@ -90,6 +88,4 @@ nvif_object_ctor(struct nvif_object *parent, const char *name, u32 handle, s32 o
 	object->name = name ?: "nvifObject";
 	object->handle = handle;
 	object->oclass = oclass;
-	object->map.ptr = NULL;
-	object->map.size = 0;
 }
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* [PATCH 156/156] drm/nouveau: remove remaining usage of nouveau_drm.client
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (154 preceding siblings ...)
  2024-04-16 23:40 ` [PATCH 155/156] drm/nouveau: remove remaining usage of nvif_device.object.map Ben Skeggs
@ 2024-04-16 23:40 ` Ben Skeggs
  2024-04-17  4:15 ` [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Dave Airlie
  2024-04-17 22:24 ` Danilo Krummrich
  157 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-16 23:40 UTC (permalink / raw)
  To: nouveau; +Cc: Ben Skeggs

- complete the switch to nouveau_drm.cli
- renames drm._client to drm.client

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/dispnv04/crtc.c |  2 +-
 drivers/gpu/drm/nouveau/dispnv50/crc.c  |  2 +-
 drivers/gpu/drm/nouveau/dispnv50/disp.c |  2 +-
 drivers/gpu/drm/nouveau/dispnv50/head.c |  2 +-
 drivers/gpu/drm/nouveau/dispnv50/wndw.c |  2 +-
 drivers/gpu/drm/nouveau/nouveau_bo.c    |  2 +-
 drivers/gpu/drm/nouveau/nouveau_dmem.c  |  2 +-
 drivers/gpu/drm/nouveau/nouveau_drm.c   | 14 +++++++-------
 drivers/gpu/drm/nouveau/nouveau_drv.h   | 25 +++++++++++--------------
 drivers/gpu/drm/nouveau/nouveau_prime.c |  2 +-
 drivers/gpu/drm/nouveau/nouveau_ttm.c   |  4 ++--
 drivers/gpu/drm/nouveau/nv17_fence.c    |  2 +-
 drivers/gpu/drm/nouveau/nv50_fence.c    |  2 +-
 drivers/gpu/drm/nouveau/nv84_fence.c    |  2 +-
 14 files changed, 31 insertions(+), 34 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv04/crtc.c b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
index 7f83927ddf96..225716d47c56 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/crtc.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
@@ -1317,7 +1317,7 @@ nv04_crtc_create(struct drm_device *dev, int crtc_num)
 	drm_crtc_helper_add(&nv_crtc->base, &nv04_crtc_helper_funcs);
 	drm_mode_crtc_set_gamma_size(&nv_crtc->base, 256);
 
-	ret = nouveau_bo_new(&nouveau_drm(dev)->client, 64*64*4, 0x100,
+	ret = nouveau_bo_new(&nouveau_drm(dev)->cli, 64*64*4, 0x100,
 			     NOUVEAU_GEM_DOMAIN_VRAM, 0, 0x0000, NULL, NULL,
 			     &nv_crtc->cursor.nvbo);
 	if (!ret) {
diff --git a/drivers/gpu/drm/nouveau/dispnv50/crc.c b/drivers/gpu/drm/nouveau/dispnv50/crc.c
index 6d1395b8c597..fd3360b096b4 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/crc.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/crc.c
@@ -541,7 +541,7 @@ int nv50_crc_set_source(struct drm_crtc *crtc, const char *source_str)
 	struct nv50_head *head = nv50_head(crtc);
 	struct nv50_crc *crc = &head->crc;
 	const struct nv50_crc_func *func = nv50_disp(dev)->core->func->crc;
-	struct nvif_mmu *mmu = &nouveau_drm(dev)->client.mmu;
+	struct nvif_mmu *mmu = &nouveau_drm(dev)->cli.mmu;
 	struct nv50_head_atom *asyh;
 	struct drm_crtc_state *crtc_state;
 	enum nv50_crc_source source;
diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c b/drivers/gpu/drm/nouveau/dispnv50/disp.c
index 36547f3b6111..45ef47b1997d 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/disp.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c
@@ -2604,7 +2604,7 @@ nv50_display_create(struct drm_device *dev)
 	dev->mode_config.normalize_zpos = true;
 
 	/* small shared memory area we use for notifiers and semaphores */
-	ret = nouveau_bo_new(&drm->client, 4096, 0x1000,
+	ret = nouveau_bo_new(&drm->cli, 4096, 0x1000,
 			     NOUVEAU_GEM_DOMAIN_VRAM,
 			     0, 0x0000, NULL, NULL, &disp->sync);
 	if (!ret) {
diff --git a/drivers/gpu/drm/nouveau/dispnv50/head.c b/drivers/gpu/drm/nouveau/dispnv50/head.c
index 3a192dd8635a..187feceb300a 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/head.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/head.c
@@ -618,7 +618,7 @@ nv50_head_create(struct drm_device *dev, int index)
 				   head->func->olut_size);
 
 	if (head->func->olut_set) {
-		ret = nv50_lut_init(disp, &drm->client.mmu, &head->olut);
+		ret = nv50_lut_init(disp, &drm->cli.mmu, &head->olut);
 		if (ret) {
 			nv50_head_destroy(crtc);
 			return ERR_PTR(ret);
diff --git a/drivers/gpu/drm/nouveau/dispnv50/wndw.c b/drivers/gpu/drm/nouveau/dispnv50/wndw.c
index 38853dbe57c5..8f6f431d682a 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/wndw.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/wndw.c
@@ -736,7 +736,7 @@ nv50_wndw_prep(const struct nv50_wndw_func *func, struct drm_device *dev,
 	       struct nv50_wndw **pwndw)
 {
 	struct nouveau_drm *drm = nouveau_drm(dev);
-	struct nvif_mmu *mmu = &drm->client.mmu;
+	struct nvif_mmu *mmu = &drm->cli.mmu;
 	struct nv50_disp *disp = nv50_disp(dev);
 	struct nv50_wndw *wndw;
 	const u64 *format_modifiers;
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
index 523464cfea9e..c4e420b9deef 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -832,7 +832,7 @@ nouveau_bo_move_prep(struct nouveau_drm *drm, struct ttm_buffer_object *bo,
 {
 	struct nouveau_mem *old_mem = nouveau_mem(bo->resource);
 	struct nouveau_mem *new_mem = nouveau_mem(reg);
-	struct nvif_vmm *vmm = &drm->client.vmm.vmm;
+	struct nvif_vmm *vmm = &drm->cli.vmm.vmm;
 	int ret;
 
 	ret = nvif_vmm_get(vmm, NVIF_VMM_GET_LAZY, false, old_mem->mem.impl->page, 0,
diff --git a/drivers/gpu/drm/nouveau/nouveau_dmem.c b/drivers/gpu/drm/nouveau/nouveau_dmem.c
index 2cb06f0a217f..43c5b583caef 100644
--- a/drivers/gpu/drm/nouveau/nouveau_dmem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_dmem.c
@@ -254,7 +254,7 @@ nouveau_dmem_chunk_alloc(struct nouveau_drm *drm, struct page **ppage)
 	chunk->pagemap.ops = &nouveau_dmem_pagemap_ops;
 	chunk->pagemap.owner = drm->dev;
 
-	ret = nouveau_bo_new(&drm->client, DMEM_CHUNK_SIZE, 0,
+	ret = nouveau_bo_new(&drm->cli, DMEM_CHUNK_SIZE, 0,
 			     NOUVEAU_GEM_DOMAIN_VRAM, 0, 0, NULL, NULL,
 			     &chunk->bo);
 	if (ret)
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 26a89ab6d462..98085bb9eb78 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -201,7 +201,7 @@ nouveau_cli_init(struct nouveau_drm *drm, const char *sname,
 	INIT_LIST_HEAD(&cli->worker);
 	mutex_init(&cli->lock);
 
-	ret = nvif_client_ctor(&drm->_client, cli->name, &cli->base);
+	ret = nvif_client_ctor(&drm->client, cli->name, &cli->base);
 	if (ret) {
 		NV_PRINTK(err, cli, "Client allocation failed: %d\n", ret);
 		goto done;
@@ -497,15 +497,15 @@ nouveau_drm_device_init(struct drm_device *dev, struct nvkm_device *nvkm)
 
 	nvif_parent_ctor(&nouveau_parent, &drm->parent);
 
-	drm->_client.object.parent = &drm->parent;
+	drm->client.object.parent = &drm->parent;
 
 	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);
+	nvif_driver_ctor(&drm->parent, driver, "drm", impl, priv, &drm->client);
 
-	ret = nvif_device_ctor(&drm->_client, "drmDevice", &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;
@@ -630,7 +630,7 @@ nouveau_drm_device_init(struct drm_device *dev, struct nvkm_device *nvkm)
 fail_nvif:
 	nvif_mmu_dtor(&drm->mmu);
 	nvif_device_dtor(&drm->device);
-	nvif_client_dtor(&drm->_client);
+	nvif_client_dtor(&drm->client);
 fail_alloc:
 	nvif_parent_dtor(&drm->parent);
 	kfree(drm);
@@ -886,7 +886,7 @@ nouveau_do_suspend(struct drm_device *dev, bool runtime)
 	}
 
 	NV_DEBUG(drm, "suspending object tree...\n");
-	ret = nvif_client_suspend(&drm->_client);
+	ret = nvif_client_suspend(&drm->client);
 	if (ret)
 		goto fail_client;
 
@@ -911,7 +911,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->_client);
+	ret = nvif_client_resume(&drm->client);
 	if (ret) {
 		NV_ERROR(drm, "Client resume failed with error: %d\n", ret);
 		return ret;
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h
index 12c9ac68a23e..bf11f30da77c 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.h
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.h
@@ -203,14 +203,11 @@ u_memcpya(uint64_t user, unsigned int nmemb, unsigned int size)
 struct nouveau_drm {
 	struct nvkm_device *nvkm;
 	struct nvif_parent parent;
-	struct nvif_client _client;
+	struct nvif_client client;
 	struct nvif_device device;
 	struct nvif_mmu mmu;
 
-	union {
-		struct nouveau_cli client;
-		struct nouveau_cli cli;
-	};
+	struct nouveau_cli cli;
 	struct drm_device *dev;
 
 	struct list_head clients;
@@ -340,25 +337,25 @@ void nouveau_drm_device_remove(struct drm_device *dev);
 	dev_##l(_cli->drm->dev->dev, "%s: "f, _cli->name, ##a);                \
 } while(0)
 
-#define NV_FATAL(drm,f,a...) NV_PRINTK(crit, &(drm)->client, f, ##a)
-#define NV_ERROR(drm,f,a...) NV_PRINTK(err, &(drm)->client, f, ##a)
-#define NV_WARN(drm,f,a...) NV_PRINTK(warn, &(drm)->client, f, ##a)
-#define NV_INFO(drm,f,a...) NV_PRINTK(info, &(drm)->client, f, ##a)
+#define NV_FATAL(drm,f,a...) NV_PRINTK(crit, &(drm)->cli, f, ##a)
+#define NV_ERROR(drm,f,a...) NV_PRINTK(err, &(drm)->cli, f, ##a)
+#define NV_WARN(drm,f,a...) NV_PRINTK(warn, &(drm)->cli, f, ##a)
+#define NV_INFO(drm,f,a...) NV_PRINTK(info, &(drm)->cli, f, ##a)
 
 #define NV_DEBUG(drm,f,a...) do {                                              \
 	if (drm_debug_enabled(DRM_UT_DRIVER))                                  \
-		NV_PRINTK(info, &(drm)->client, f, ##a);                       \
+		NV_PRINTK(info, &(drm)->cli, f, ##a);                       \
 } while(0)
 #define NV_ATOMIC(drm,f,a...) do {                                             \
 	if (drm_debug_enabled(DRM_UT_ATOMIC))                                  \
-		NV_PRINTK(info, &(drm)->client, f, ##a);                       \
+		NV_PRINTK(info, &(drm)->cli, f, ##a);                       \
 } while(0)
 
 #define NV_PRINTK_ONCE(l,c,f,a...) NV_PRINTK(l##_once,c,f, ##a)
 
-#define NV_ERROR_ONCE(drm,f,a...) NV_PRINTK_ONCE(err, &(drm)->client, f, ##a)
-#define NV_WARN_ONCE(drm,f,a...) NV_PRINTK_ONCE(warn, &(drm)->client, f, ##a)
-#define NV_INFO_ONCE(drm,f,a...) NV_PRINTK_ONCE(info, &(drm)->client, f, ##a)
+#define NV_ERROR_ONCE(drm,f,a...) NV_PRINTK_ONCE(err, &(drm)->cli, f, ##a)
+#define NV_WARN_ONCE(drm,f,a...) NV_PRINTK_ONCE(warn, &(drm)->cli, f, ##a)
+#define NV_INFO_ONCE(drm,f,a...) NV_PRINTK_ONCE(info, &(drm)->cli, f, ##a)
 
 extern int nouveau_modeset;
 
diff --git a/drivers/gpu/drm/nouveau/nouveau_prime.c b/drivers/gpu/drm/nouveau/nouveau_prime.c
index b58ab595faf8..df29c6805f4e 100644
--- a/drivers/gpu/drm/nouveau/nouveau_prime.c
+++ b/drivers/gpu/drm/nouveau/nouveau_prime.c
@@ -49,7 +49,7 @@ struct drm_gem_object *nouveau_gem_prime_import_sg_table(struct drm_device *dev,
 	int ret;
 
 	dma_resv_lock(robj, NULL);
-	nvbo = nouveau_bo_alloc(&drm->client, &size, &align,
+	nvbo = nouveau_bo_alloc(&drm->cli, &size, &align,
 				NOUVEAU_GEM_DOMAIN_GART, 0, 0, true);
 	if (IS_ERR(nvbo)) {
 		obj = ERR_CAST(nvbo);
diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c
index 5b0f78e48cc7..f4224ebb38b2 100644
--- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
@@ -159,7 +159,7 @@ const struct ttm_resource_manager_func nv04_gart_manager = {
 static int
 nouveau_ttm_init_host(struct nouveau_drm *drm, u8 kind)
 {
-	struct nvif_mmu *mmu = &drm->client.mmu;
+	struct nvif_mmu *mmu = &drm->cli.mmu;
 	int typei;
 
 	typei = nvif_mmu_type(mmu, NVIF_MEM_HOST | NVIF_MEM_MAPPABLE |
@@ -262,7 +262,7 @@ nouveau_ttm_init(struct nouveau_drm *drm)
 {
 	struct nvkm_device *device = nvxx_device(drm);
 	struct nvkm_pci *pci = device->pci;
-	struct nvif_mmu *mmu = &drm->client.mmu;
+	struct nvif_mmu *mmu = &drm->cli.mmu;
 	struct drm_device *dev = drm->dev;
 	int typei, ret;
 
diff --git a/drivers/gpu/drm/nouveau/nv17_fence.c b/drivers/gpu/drm/nouveau/nv17_fence.c
index ba499dfb621d..94975d988002 100644
--- a/drivers/gpu/drm/nouveau/nv17_fence.c
+++ b/drivers/gpu/drm/nouveau/nv17_fence.c
@@ -129,7 +129,7 @@ nv17_fence_create(struct nouveau_drm *drm)
 	priv->base.context_del = nv10_fence_context_del;
 	spin_lock_init(&priv->lock);
 
-	ret = nouveau_bo_new(&drm->client, 4096, 0x1000,
+	ret = nouveau_bo_new(&drm->cli, 4096, 0x1000,
 			     NOUVEAU_GEM_DOMAIN_VRAM,
 			     0, 0x0000, NULL, NULL, &priv->bo);
 	if (!ret) {
diff --git a/drivers/gpu/drm/nouveau/nv50_fence.c b/drivers/gpu/drm/nouveau/nv50_fence.c
index 405a3f8ff4d4..f34ce93ff2ab 100644
--- a/drivers/gpu/drm/nouveau/nv50_fence.c
+++ b/drivers/gpu/drm/nouveau/nv50_fence.c
@@ -80,7 +80,7 @@ nv50_fence_create(struct nouveau_drm *drm)
 	priv->base.context_del = nv10_fence_context_del;
 	spin_lock_init(&priv->lock);
 
-	ret = nouveau_bo_new(&drm->client, 4096, 0x1000,
+	ret = nouveau_bo_new(&drm->cli, 4096, 0x1000,
 			     NOUVEAU_GEM_DOMAIN_VRAM,
 			     0, 0x0000, NULL, NULL, &priv->bo);
 	if (!ret) {
diff --git a/drivers/gpu/drm/nouveau/nv84_fence.c b/drivers/gpu/drm/nouveau/nv84_fence.c
index 4b107c1a5686..c4ff1d2c9823 100644
--- a/drivers/gpu/drm/nouveau/nv84_fence.c
+++ b/drivers/gpu/drm/nouveau/nv84_fence.c
@@ -222,7 +222,7 @@ nv84_fence_create(struct nouveau_drm *drm)
 		  * will lose CPU/GPU coherency!
 		  */
 		NOUVEAU_GEM_DOMAIN_GART | NOUVEAU_GEM_DOMAIN_COHERENT;
-	ret = nouveau_bo_new(&drm->client, 16 * drm->chan_total, 0,
+	ret = nouveau_bo_new(&drm->cli, 16 * drm->chan_total, 0,
 			     domain, 0, 0, NULL, NULL, &priv->bo);
 	if (ret == 0) {
 		ret = nouveau_bo_pin(priv->bo, domain, false);
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 163+ messages in thread

* Re: [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (155 preceding siblings ...)
  2024-04-16 23:40 ` [PATCH 156/156] drm/nouveau: remove remaining usage of nouveau_drm.client Ben Skeggs
@ 2024-04-17  4:15 ` Dave Airlie
  2024-04-18 12:52   ` Ben Skeggs
  2024-04-17 22:24 ` Danilo Krummrich
  157 siblings, 1 reply; 163+ messages in thread
From: Dave Airlie @ 2024-04-17  4:15 UTC (permalink / raw)
  To: Ben Skeggs; +Cc: nouveau

On Wed, 17 Apr 2024 at 10:57, Ben Skeggs <bskeggs@nvidia.com> wrote:
>
> 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.

Welcome back!

Do you have a git tree with this in it, since I think at least patch
25 got stuck in moderation.

Have you tested nouveau GL and nvk on top of this?

Dave.

^ permalink raw reply	[flat|nested] 163+ messages in thread

* Re: [PATCH 004/156] drm/nouveau: pass drm to nv50_dmac_create(), rather than device+disp
  2024-04-16 23:37 ` [PATCH 004/156] drm/nouveau: pass drm to nv50_dmac_create(), rather than device+disp Ben Skeggs
@ 2024-04-17  6:27   ` Philipp Stanner
  0 siblings, 0 replies; 163+ messages in thread
From: Philipp Stanner @ 2024-04-17  6:27 UTC (permalink / raw)
  To: Ben Skeggs, nouveau

On Wed, 2024-04-17 at 09:37 +1000, Ben Skeggs wrote:
> - 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.

> 
> Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
> ---
>  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(-)
> 
> diff --git a/drivers/gpu/drm/nouveau/dispnv50/base507c.c
> b/drivers/gpu/drm/nouveau/dispnv50/base507c.c
> index 70c62b861276..e36a473f2075 100644
> --- a/drivers/gpu/drm/nouveau/dispnv50/base507c.c
> +++ b/drivers/gpu/drm/nouveau/dispnv50/base507c.c
> @@ -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) {
> diff --git a/drivers/gpu/drm/nouveau/dispnv50/core507d.c
> b/drivers/gpu/drm/nouveau/dispnv50/core507d.c
> index e5bb5ca950c8..85845e3dc7ba 100644
> --- a/drivers/gpu/drm/nouveau/dispnv50/core507d.c
> +++ b/drivers/gpu/drm/nouveau/dispnv50/core507d.c
> @@ -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) {
> diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c
> b/drivers/gpu/drm/nouveau/dispnv50/disp.c
> index 0c3d88ad0b0e..f8ca57cc7af6 100644
> --- a/drivers/gpu/drm/nouveau/dispnv50/disp.c
> +++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c
> @@ -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;
> diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.h
> b/drivers/gpu/drm/nouveau/dispnv50/disp.h
> index 5508a7cfd492..da3add95f354 100644
> --- a/drivers/gpu/drm/nouveau/dispnv50/disp.h
> +++ b/drivers/gpu/drm/nouveau/dispnv50/disp.h
> @@ -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 *);
> diff --git a/drivers/gpu/drm/nouveau/dispnv50/ovly507e.c
> b/drivers/gpu/drm/nouveau/dispnv50/ovly507e.c
> index 797c1e4e0eaa..73fcfb27c32c 100644
> --- a/drivers/gpu/drm/nouveau/dispnv50/ovly507e.c
> +++ b/drivers/gpu/drm/nouveau/dispnv50/ovly507e.c
> @@ -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) {
> diff --git a/drivers/gpu/drm/nouveau/dispnv50/wimmc37b.c
> b/drivers/gpu/drm/nouveau/dispnv50/wimmc37b.c
> index ee76b091d4ef..8cb5b79bacbf 100644
> --- a/drivers/gpu/drm/nouveau/dispnv50/wimmc37b.c
> +++ b/drivers/gpu/drm/nouveau/dispnv50/wimmc37b.c
> @@ -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) {
> diff --git a/drivers/gpu/drm/nouveau/dispnv50/wndwc37e.c
> b/drivers/gpu/drm/nouveau/dispnv50/wndwc37e.c
> index b3deea5aca58..caf40977f455 100644
> --- a/drivers/gpu/drm/nouveau/dispnv50/wndwc37e.c
> +++ b/drivers/gpu/drm/nouveau/dispnv50/wndwc37e.c
> @@ -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) {


^ permalink raw reply	[flat|nested] 163+ messages in thread

* Re: [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm
  2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
                   ` (156 preceding siblings ...)
  2024-04-17  4:15 ` [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Dave Airlie
@ 2024-04-17 22:24 ` Danilo Krummrich
  2024-04-18 14:03   ` Ben Skeggs
  157 siblings, 1 reply; 163+ messages in thread
From: Danilo Krummrich @ 2024-04-17 22:24 UTC (permalink / raw)
  To: Ben Skeggs; +Cc: nouveau

Hi Ben,

Welcome back from my side as well!

On Wed, Apr 17, 2024 at 09:37:26AM +1000, Ben Skeggs wrote:
> 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).

That sounds like a great and welcome simplification.

> 
> 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.

I just had a very brief look on the rework of the VMM bits to get a rough idea
how the new interface looks like.

I think I will get the full picture, once I can apply all the patches to a tree
and don't need to look at the changes scattered throughout patches.

However, I wonder if we need another indirection (such as nvif_vmm_impl) instead
of just calling the corresponding functions directly? Or even more crazy, what
if we'd try to rip out nvif entirely?

Maybe it would be good to sketch up some example code of how the interface works
and include it in the cover letter? This way we could see / discuss whether we
can even simplify it more or why it needs the indirections you have chosen.

> 
> 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):

Wow! That's a lot of work - very much appreciated. However, I think it would
have been better to share your ideas and / or example code regarding this rework
early, such that discussions can happen in advance.

We could have been discussing the (new) interface, get to an agreement and then
work through it in several patch series.

This has multiple advantages:

  1. It makes things much easier to review; bulky patch series, such as this
     one, are hard to review.
  2. It potentially provides different perspectives for improvements ahead of
     time and potentially saves a lot of your time compared to working through
     the feedback afterwards.
  3. It better involves the community. Wouldn't it be great if someone, due to a
     previous discussion, voluntarily picked up some of the effort?

Can you please resend patch 25 with a corresponding '--in-reply-to='? Also, as
Dave already mentioned, I'd be great if you could provide a branch containing
the patches.

- Danilo

>   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
> 
> -- 
> 2.41.0
> 

^ permalink raw reply	[flat|nested] 163+ messages in thread

* Re: [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm
  2024-04-17  4:15 ` [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Dave Airlie
@ 2024-04-18 12:52   ` Ben Skeggs
  0 siblings, 0 replies; 163+ messages in thread
From: Ben Skeggs @ 2024-04-18 12:52 UTC (permalink / raw)
  To: Dave Airlie; +Cc: nouveau

On 17/4/24 14:15, Dave Airlie wrote:

> On Wed, 17 Apr 2024 at 10:57, Ben Skeggs <bskeggs@nvidia.com> wrote:
>> 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.
> Welcome back!

Hey!  Thank you :)


>
> Do you have a git tree with this in it, since I think at least patch
> 25 got stuck in moderation.

I've pushed a tree to 
https://gitlab.freedesktop.org/bskeggs/nouveau/-/tree/remove-ioctl


>
> Have you tested nouveau GL and nvk on top of this?

Yes I have, nvk mostly via zink (and vkcube ;)).


Ben.

>
> Dave.

^ permalink raw reply	[flat|nested] 163+ messages in thread

* Re: [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm
  2024-04-17 22:24 ` Danilo Krummrich
@ 2024-04-18 14:03   ` Ben Skeggs
  2024-04-22  9:28     ` Danilo Krummrich
  0 siblings, 1 reply; 163+ messages in thread
From: Ben Skeggs @ 2024-04-18 14:03 UTC (permalink / raw)
  To: Danilo Krummrich; +Cc: nouveau

On 18/4/24 08:24, Danilo Krummrich wrote:

> Hi Ben,
>
> Welcome back from my side as well!

Hey Danilo,

Thanks!

>
> On Wed, Apr 17, 2024 at 09:37:26AM +1000, Ben Skeggs wrote:
>> 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).
> That sounds like a great and welcome simplification.
>
>> 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.
> I just had a very brief look on the rework of the VMM bits to get a rough idea
> how the new interface looks like.
>
> I think I will get the full picture, once I can apply all the patches to a tree
> and don't need to look at the changes scattered throughout patches.
>
> However, I wonder if we need another indirection (such as nvif_vmm_impl) instead
> of just calling the corresponding functions directly? Or even more crazy, what
> if we'd try to rip out nvif entirely?

I'm opposed to removing NVIF.  HW has always had a quite strong 
priv/user separation (it's been designed for usermode submission from 
the beginning, even before DMA channels were a thing), and many many 
years ago now I made the decision to split nouveau along those same 
boundaries.

It also happens to (basically) mirror the interface GSP-RM provides to 
the kernel driver.  Had I not split nouveau the way I did, and had the 
code to manage the priv/user parts of the GPU mingled together, adding 
support for GSP-RM would have been a lot more painful than it was.


>
> Maybe it would be good to sketch up some example code of how the interface works
> and include it in the cover letter? This way we could see / discuss whether we
> can even simplify it more or why it needs the indirections you have chosen.

I tried to make this clear in the cover letter, but this isn't an 
attempt at designing a new interface.  This is the old one, and works in 
nearly the same way as it did before, just with a whole bunch of middle 
layers ripped out.

A patch series I've been pondering writing if/when this one is merged, 
would be to directly implement GSP-RM on top of the "new" interfaces, so 
that it doesn't need to awkwardly integrate with NVKM's other 
abstractions that are only really relevant when running on top of HW 
directly.

There is (almost) be a 1-1 mapping between NVIF function pointer and RM 
alloc/control call (this was already the case before this series).  The 
GSP-supporting code in NVKM could be cleaned up significantly.


>
>> 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):
> Wow! That's a lot of work - very much appreciated. However, I think it would
> have been better to share your ideas and / or example code regarding this rework
> early, such that discussions can happen in advance.
>
> We could have been discussing the (new) interface, get to an agreement and then
> work through it in several patch series.

I don't disagree that discussion should be had over new interfaces, but 
as I said above, this series isn't an attempt at that.  It's attempting 
to remove a whole bunch of cruft that makes it hard to make changes to 
the APIs, a whole bunch of memcpy(), and hacks around awkward locking 
problems (like the linked-list of all memory allocations to avoid object 
tree locking issues).


Thank you,

Ben.

>
> This has multiple advantages:
>
>    1. It makes things much easier to review; bulky patch series, such as this
>       one, are hard to review.
>    2. It potentially provides different perspectives for improvements ahead of
>       time and potentially saves a lot of your time compared to working through
>       the feedback afterwards.
>    3. It better involves the community. Wouldn't it be great if someone, due to a
>       previous discussion, voluntarily picked up some of the effort?
>
> Can you please resend patch 25 with a corresponding '--in-reply-to='? Also, as
> Dave already mentioned, I'd be great if you could provide a branch containing
> the patches.
>
> - Danilo
>
>>    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
>>
>> --
>> 2.41.0
>>

^ permalink raw reply	[flat|nested] 163+ messages in thread

* Re: [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm
  2024-04-18 14:03   ` Ben Skeggs
@ 2024-04-22  9:28     ` Danilo Krummrich
  0 siblings, 0 replies; 163+ messages in thread
From: Danilo Krummrich @ 2024-04-22  9:28 UTC (permalink / raw)
  To: Ben Skeggs; +Cc: nouveau, dakr

On Fri, Apr 19, 2024 at 12:03:41AM +1000, Ben Skeggs wrote:
> On 18/4/24 08:24, Danilo Krummrich wrote:
> 
> > Hi Ben,
> > 
> > Welcome back from my side as well!
> 
> Hey Danilo,
> 
> Thanks!
> 
> > 
> > On Wed, Apr 17, 2024 at 09:37:26AM +1000, Ben Skeggs wrote:
> > > 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).
> > That sounds like a great and welcome simplification.
> > 
> > > 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.
> > I just had a very brief look on the rework of the VMM bits to get a rough idea
> > how the new interface looks like.
> > 
> > I think I will get the full picture, once I can apply all the patches to a tree
> > and don't need to look at the changes scattered throughout patches.
> > 
> > However, I wonder if we need another indirection (such as nvif_vmm_impl) instead
> > of just calling the corresponding functions directly? Or even more crazy, what
> > if we'd try to rip out nvif entirely?
> 
> I'm opposed to removing NVIF.  HW has always had a quite strong priv/user
> separation (it's been designed for usermode submission from the beginning,
> even before DMA channels were a thing), and many many years ago now I made
> the decision to split nouveau along those same boundaries.

I don't see why we'd need NVIF to keep this separation. I'm also not saying we
have to get rid of it either though. But I think we should simplify this as much
as possible.

> 
> It also happens to (basically) mirror the interface GSP-RM provides to the
> kernel driver.  Had I not split nouveau the way I did, and had the code to
> manage the priv/user parts of the GPU mingled together, adding support for
> GSP-RM would have been a lot more painful than it was.

This wouldn't really change by ripping out NVIF and just directly call nvkm_*
functions, right?

It would give us a bit more flexibility though, especially in terms of locking
architecture, which, with asynchronous VM_BIND, needs to be aligned closely
between layers to not break dma_fence rules.

In IRC you already mentioned you'd like to rip out the VMM parts and move them
to the "DRM side" of the driver. That'd already be a huge step into this
direction I think.

However, Dave and me had a brief look at how to do that as well, and it seemed
quite difficult in terms of where to "draw the line". We need to avoid that the#
ripped out VMM code still depends on NVKM layers that have their own (isolated)
locking architecture. Having a more flexible interface, that does not hide data
structures, might help.

> 
> 
> > 
> > Maybe it would be good to sketch up some example code of how the interface works
> > and include it in the cover letter? This way we could see / discuss whether we
> > can even simplify it more or why it needs the indirections you have chosen.
> 
> I tried to make this clear in the cover letter, but this isn't an attempt at
> designing a new interface.  This is the old one, and works in nearly the
> same way as it did before, just with a whole bunch of middle layers ripped
> out.
> 
> A patch series I've been pondering writing if/when this one is merged, would
> be to directly implement GSP-RM on top of the "new" interfaces, so that it
> doesn't need to awkwardly integrate with NVKM's other abstractions that are
> only really relevant when running on top of HW directly.
> 
> There is (almost) be a 1-1 mapping between NVIF function pointer and RM
> alloc/control call (this was already the case before this series).  The
> GSP-supporting code in NVKM could be cleaned up significantly.

Can you put some examples please? Afaics, most of the GSP code is called from
device probe / init, isn't it?

> 
> 
> > 
> > > 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):
> > Wow! That's a lot of work - very much appreciated. However, I think it would
> > have been better to share your ideas and / or example code regarding this rework
> > early, such that discussions can happen in advance.
> > 
> > We could have been discussing the (new) interface, get to an agreement and then
> > work through it in several patch series.
> 
> I don't disagree that discussion should be had over new interfaces, but as I
> said above, this series isn't an attempt at that.  It's attempting to remove
> a whole bunch of cruft that makes it hard to make changes to the APIs, a
> whole bunch of memcpy(), and hacks around awkward locking problems (like the
> linked-list of all memory allocations to avoid object tree locking issues).

Yes, I'm aware of that. But still, it's a rather huge change and all the points
below still apply.

> 
> 
> Thank you,
> 
> Ben.
> 
> > 
> > This has multiple advantages:
> > 
> >    1. It makes things much easier to review; bulky patch series, such as this
> >       one, are hard to review.
> >    2. It potentially provides different perspectives for improvements ahead of
> >       time and potentially saves a lot of your time compared to working through
> >       the feedback afterwards.
> >    3. It better involves the community. Wouldn't it be great if someone, due to a
> >       previous discussion, voluntarily picked up some of the effort?
> > 
> > Can you please resend patch 25 with a corresponding '--in-reply-to='? Also, as
> > Dave already mentioned, I'd be great if you could provide a branch containing
> > the patches.
> > 
> > - Danilo
> > 
> > >    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
> > > 
> > > --
> > > 2.41.0
> > > 

^ permalink raw reply	[flat|nested] 163+ messages in thread

end of thread, other threads:[~2024-04-22  9:29 UTC | newest]

Thread overview: 163+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-16 23:37 [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Ben Skeggs
2024-04-16 23:37 ` [PATCH 001/156] drm/nouveau: add nouveau_drm.device/mmu Ben Skeggs
2024-04-16 23:37 ` [PATCH 002/156] drm/nouveau: alias nouveau_drm.client to nouveau_drm.cli Ben Skeggs
2024-04-16 23:37 ` [PATCH 003/156] drm/nouveau: pass drm to nouveau_mem_new(), instead of cli Ben Skeggs
2024-04-16 23:37 ` [PATCH 004/156] drm/nouveau: pass drm to nv50_dmac_create(), rather than device+disp Ben Skeggs
2024-04-17  6:27   ` Philipp Stanner
2024-04-16 23:37 ` [PATCH 005/156] drm/nouveau: pass cli to nouveau_channel_new() instead of drm+device Ben Skeggs
2024-04-16 23:37 ` [PATCH 006/156] drm/nouveau: remove nouveau_chan.device Ben Skeggs
2024-04-16 23:37 ` [PATCH 007/156] drm/nouveau: remove chan->drm Ben Skeggs
2024-04-16 23:37 ` [PATCH 008/156] drm/nouveau: replace some void casts with chan->cli Ben Skeggs
2024-04-16 23:37 ` [PATCH 009/156] drm/nouveau: remove nouveau_drm.master Ben Skeggs
2024-04-16 23:37 ` [PATCH 010/156] drm/nouveau: always map device Ben Skeggs
2024-04-16 23:37 ` [PATCH 011/156] drm/nouveau: add nouveau_cli to nouveau_abi16 Ben Skeggs
2024-04-16 23:37 ` [PATCH 012/156] drm/nouveau: handle limited nvif in abi16 Ben Skeggs
2024-04-16 23:37 ` [PATCH 013/156] drm/nouveau: remove abi16->device Ben Skeggs
2024-04-16 23:37 ` [PATCH 014/156] drm/nouveau: remove abi16->handles Ben Skeggs
2024-04-16 23:37 ` [PATCH 015/156] drm/nouveau: store nvkm_device pointer in nouveau_drm Ben Skeggs
2024-04-16 23:37 ` [PATCH 016/156] drm/nouveau: create pci device once Ben Skeggs
2024-04-16 23:37 ` [PATCH 017/156] drm/nouveau: remove push pointer from nouveau_channel Ben Skeggs
2024-04-16 23:37 ` [PATCH 018/156] drm/nouveau/kms: remove a few unused struct members and fn decls Ben Skeggs
2024-04-16 23:37 ` [PATCH 019/156] drm/nouveau/kms: remove push pointer from nv50_dmac Ben Skeggs
2024-04-16 23:37 ` [PATCH 020/156] drm/nouveau/kms: move hw ring tracking vars into nvif_push Ben Skeggs
2024-04-16 23:37 ` [PATCH 021/156] drm/nouveau/kms: move dmac sync/vram ctxdmas to core+wndws Ben Skeggs
2024-04-16 23:37 ` [PATCH 022/156] drm/nouveau/nvkm: remove detect/mmio/subdev_mask from device args Ben Skeggs
2024-04-16 23:37 ` [PATCH 023/156] drm/nouveau/nvkm: move nouveau_nvif.c to nvkm/core/driver.c Ben Skeggs
2024-04-16 23:37 ` [PATCH 024/156] drm/nouveau/nvkm: move nvkm/engine/device/ to nvkm/device/ Ben Skeggs
2024-04-16 23:37 ` [PATCH 025/156] drm/nouveau/nvkm: remove perfmon Ben Skeggs
2024-04-16 23:37 ` [PATCH 026/156] drm/nouveau/nvkm: remove nvkm_client_search() Ben Skeggs
2024-04-16 23:37 ` [PATCH 027/156] drm/nouveau/nvif: remove support for userspace backends Ben Skeggs
2024-04-16 23:37 ` [PATCH 028/156] drm/nouveau/nvif: remove route/token Ben Skeggs
2024-04-16 23:37 ` [PATCH 029/156] drm/nouveau/nvif: remove nvxx_object() Ben Skeggs
2024-04-16 23:37 ` [PATCH 030/156] drm/nouveau/nvif: remove nvxx_client() Ben Skeggs
2024-04-16 23:37 ` [PATCH 031/156] drm/nouveau/nvif: remove driver keep/fini Ben Skeggs
2024-04-16 23:37 ` [PATCH 032/156] drm/nouveau/nvif: remove client version Ben Skeggs
2024-04-16 23:37 ` [PATCH 033/156] drm/nouveau/nvif: remove client devlist Ben Skeggs
2024-04-16 23:38 ` [PATCH 034/156] drm/nouveau/nvif: remove client fini Ben Skeggs
2024-04-16 23:38 ` [PATCH 035/156] drm/nouveau/nvif: remove device args Ben Skeggs
2024-04-16 23:38 ` [PATCH 036/156] drm/nouveau/nvif: remove device rd/wr Ben Skeggs
2024-04-16 23:38 ` [PATCH 037/156] drm/nouveau/nvif: remove disp chan rd/wr Ben Skeggs
2024-04-16 23:38 ` [PATCH 038/156] drm/nouveau/nvkm: rename struct nvkm_uevent Ben Skeggs
2024-04-16 23:38 ` [PATCH 039/156] drm/nouveau/nvkm: remove nvkm_client() Ben Skeggs
2024-04-16 23:38 ` [PATCH 040/156] drm/nouveau/nvkm: rename struct nvkm_udevice Ben Skeggs
2024-04-16 23:38 ` [PATCH 041/156] drm/nouveau/nvkm: rename struct nvkm_control Ben Skeggs
2024-04-16 23:38 ` [PATCH 042/156] drm/nouveau/nvkm: rename struct nvkm_uvfn Ben Skeggs
2024-04-16 23:38 ` [PATCH 043/156] drm/nouveau/nvkm: rename struct nvkm_ummu Ben Skeggs
2024-04-16 23:38 ` [PATCH 044/156] drm/nouveau/nvkm: rename struct nvkm_umem Ben Skeggs
2024-04-16 23:38 ` [PATCH 045/156] drm/nouveau/nvkm: rename struct nvkm_uvmm Ben Skeggs
2024-04-16 23:38 ` [PATCH 046/156] drm/nouveau/nvkm: detach user handling from nvkm_fault_buffer Ben Skeggs
2024-04-16 23:38 ` [PATCH 047/156] drm/nouveau/nvkm: detach user handling from nvkm_disp Ben Skeggs
2024-04-16 23:38 ` [PATCH 048/156] drm/nouveau/nvkm: detach user handling from nvkm_conn Ben Skeggs
2024-04-16 23:38 ` [PATCH 049/156] drm/nouveau/nvkm: detach user handling from nvkm_outp Ben Skeggs
2024-04-16 23:38 ` [PATCH 050/156] drm/nouveau/nvkm: detach user handling from nvkm_uhead Ben Skeggs
2024-04-16 23:38 ` [PATCH 051/156] drm/nouveau/nvkm: detach user handling from nvkm_disp_chan Ben Skeggs
2024-04-16 23:38 ` [PATCH 052/156] drm/nouveau/nvkm: rename struct nvkm_ucgrp Ben Skeggs
2024-04-16 23:38 ` [PATCH 053/156] drm/nouveau/nvkm: rename struct nvkm_uchan Ben Skeggs
2024-04-16 23:38 ` [PATCH 054/156] drm/nouveau/nvkm: move umem list to mmu Ben Skeggs
2024-04-16 23:38 ` [PATCH 055/156] drm/nouveau/disp: simplify hw user definition Ben Skeggs
2024-04-16 23:38 ` [PATCH 056/156] drm/nouveau/nvif: output oclass id in object dbg messages Ben Skeggs
2024-04-16 23:38 ` [PATCH 057/156] drm/nouveau/nvif: add alternate version of nvif_object_ctor() Ben Skeggs
2024-04-16 23:38 ` [PATCH 058/156] drm/nouveau/nvif: add alternate version of nvif_event_ctor() Ben Skeggs
2024-04-16 23:38 ` [PATCH 059/156] drm/nouveau/nvif: move nvif<->nvkm interface definitions to driverif.h Ben Skeggs
2024-04-16 23:38 ` [PATCH 060/156] drm/nouveau/nvif: rework "new driver" api Ben Skeggs
2024-04-16 23:38 ` [PATCH 061/156] drm/nouveau/nvkm: remove device list Ben Skeggs
2024-04-16 23:38 ` [PATCH 062/156] drm/nouveau/nvif: rework driver "new client" api Ben Skeggs
2024-04-16 23:38 ` [PATCH 063/156] drm/nouveau/nvif: rework client "new device" api Ben Skeggs
2024-04-16 23:38 ` [PATCH 064/156] drm/nouveau/nvif: remove client from object rb Ben Skeggs
2024-04-16 23:38 ` [PATCH 065/156] drm/nouveau/nvif: rework device "sclass" api Ben Skeggs
2024-04-16 23:38 ` [PATCH 066/156] drm/nouveau/nvif: rework device "map" api Ben Skeggs
2024-04-16 23:38 ` [PATCH 067/156] drm/nouveau/nvif: rework device "info v0" api Ben Skeggs
2024-04-16 23:38 ` [PATCH 068/156] drm/nouveau/nvif: rework device "info v1" api Ben Skeggs
2024-04-16 23:38 ` [PATCH 069/156] drm/nouveau/nvif: rework device "time" api Ben Skeggs
2024-04-16 23:38 ` [PATCH 070/156] drm/nouveau/nvif: rework device "new ctrl" api Ben Skeggs
2024-04-16 23:38 ` [PATCH 071/156] drm/nouveau/nvif: rework ctrl "pstate info" api Ben Skeggs
2024-04-16 23:38 ` [PATCH 072/156] drm/nouveau/nvif: rework ctrl "pstate attr" api Ben Skeggs
2024-04-16 23:38 ` [PATCH 073/156] drm/nouveau/nvif: rework ctrl "pstate user" api Ben Skeggs
2024-04-16 23:38 ` [PATCH 074/156] drm/nouveau/nvif: remove ctrl from object rb Ben Skeggs
2024-04-16 23:38 ` [PATCH 075/156] drm/nouveau/nvif: rework device "new usermode" api Ben Skeggs
2024-04-16 23:38 ` [PATCH 076/156] drm/nouveau/nvif: rework usermode "map" api Ben Skeggs
2024-04-16 23:38 ` [PATCH 077/156] drm/nouveau/nvif: remove usermode from object rb Ben Skeggs
2024-04-16 23:38 ` [PATCH 078/156] drm/nouveau/nvif: rework device "new mmu" api Ben Skeggs
2024-04-16 23:38 ` [PATCH 079/156] drm/nouveau/nvif: rework mmu "sclass" api Ben Skeggs
2024-04-16 23:38 ` [PATCH 080/156] drm/nouveau/nvif: rework mmu "heap" api Ben Skeggs
2024-04-16 23:38 ` [PATCH 081/156] drm/nouveau/nvif: rework mmu "type" api Ben Skeggs
2024-04-16 23:38 ` [PATCH 082/156] drm/nouveau/nvif: rework mmu "kind" api Ben Skeggs
2024-04-16 23:38 ` [PATCH 083/156] drm/nouveau/nvif: rework mmu "new mem" api Ben Skeggs
2024-04-16 23:38 ` [PATCH 084/156] drm/nouveau/nvif: rework mem "map"/"unmap" apis Ben Skeggs
2024-04-16 23:38 ` [PATCH 085/156] drm/nouveau/nvif: rework mmu "new vmm" api Ben Skeggs
2024-04-16 23:38 ` [PATCH 086/156] drm/nouveau/nvif: remove mmu from object rb Ben Skeggs
2024-04-16 23:38 ` [PATCH 087/156] drm/nouveau/nvif: rework vmm "page" api Ben Skeggs
2024-04-16 23:38 ` [PATCH 088/156] drm/nouveau/nvif: rework vmm "get"/"put" apis Ben Skeggs
2024-04-16 23:38 ` [PATCH 089/156] drm/nouveau/nvif: rework vmm "map"/"unmap" apis Ben Skeggs
2024-04-16 23:38 ` [PATCH 090/156] drm/nouveau/nvif: rework vmm "pfnmap"/"pfnclr" apis Ben Skeggs
2024-04-16 23:38 ` [PATCH 091/156] drm/nouveau/nvif: rework vmm "raw get"/"raw put" apis Ben Skeggs
2024-04-16 23:38 ` [PATCH 092/156] drm/nouveau/nvif: rework vmm "raw map"/"raw unmap" apis Ben Skeggs
2024-04-16 23:38 ` [PATCH 093/156] drm/nouveau/nvif: rework vmm "raw sparse" api Ben Skeggs
2024-04-16 23:39 ` [PATCH 094/156] drm/nouveau/nvif: rework vmm "fault replay"/"fault cancel" apis Ben Skeggs
2024-04-16 23:39 ` [PATCH 095/156] drm/nouveau/nvif: rework device "new fault buffer" api Ben Skeggs
2024-04-16 23:39 ` [PATCH 096/156] drm/nouveau/nvif: rework fault buffer "map" api Ben Skeggs
2024-04-16 23:39 ` [PATCH 097/156] drm/nouveau/nvif: rework fault buffer "new event" api Ben Skeggs
2024-04-16 23:39 ` [PATCH 098/156] drm/nouveau/nvif: remove fault buffer from object rb Ben Skeggs
2024-04-16 23:39 ` [PATCH 099/156] drm/nouveau/nvif: rework device "new disp" api Ben Skeggs
2024-04-16 23:39 ` [PATCH 100/156] drm/nouveau/nvif: rework disp "sclass" api Ben Skeggs
2024-04-16 23:39 ` [PATCH 101/156] drm/nouveau/nvif: rework disp "new caps" api Ben Skeggs
2024-04-16 23:39 ` [PATCH 102/156] drm/nouveau/nvif: rework disp "new conn" api Ben Skeggs
2024-04-16 23:39 ` [PATCH 103/156] drm/nouveau/nvif: rework conn "new event" api Ben Skeggs
2024-04-16 23:39 ` [PATCH 104/156] drm/nouveau/nvif: remove conn from object rb Ben Skeggs
2024-04-16 23:39 ` [PATCH 105/156] drm/nouveau/nvif: rework disp "new outp" api Ben Skeggs
2024-04-16 23:39 ` [PATCH 106/156] drm/nouveau/nvif: rework outp "detect" api Ben Skeggs
2024-04-16 23:39 ` [PATCH 107/156] drm/nouveau/nvif: rework outp "edid get" api Ben Skeggs
2024-04-16 23:39 ` [PATCH 108/156] drm/nouveau/nvif: rework outp "load detect" api Ben Skeggs
2024-04-16 23:39 ` [PATCH 109/156] drm/nouveau/nvif: rework outp "inherit" apis Ben Skeggs
2024-04-16 23:39 ` [PATCH 110/156] drm/nouveau/nvif: rework outp "acquire" api Ben Skeggs
2024-04-16 23:39 ` [PATCH 111/156] drm/nouveau/nvif: rework outp "release" api Ben Skeggs
2024-04-16 23:39 ` [PATCH 112/156] drm/nouveau/nvif: rework outp "bl get"/"bl set" apis Ben Skeggs
2024-04-16 23:39 ` [PATCH 113/156] drm/nouveau/nvif: rework outp "lvds config" api Ben Skeggs
2024-04-16 23:39 ` [PATCH 114/156] drm/nouveau/nvif: rework outp "hdmi " Ben Skeggs
2024-04-16 23:39 ` [PATCH 115/156] drm/nouveau/nvif: rework outp "infoframe" api Ben Skeggs
2024-04-16 23:39 ` [PATCH 116/156] drm/nouveau/nvif: rework outp "hda eld" api Ben Skeggs
2024-04-16 23:39 ` [PATCH 117/156] drm/nouveau/nvif: rework outp "dp aux pwr" api Ben Skeggs
2024-04-16 23:39 ` [PATCH 118/156] drm/nouveau/nvif: rework outp "dp aux xfer" api Ben Skeggs
2024-04-16 23:39 ` [PATCH 119/156] drm/nouveau/nvif: rework outp "dp rates" api Ben Skeggs
2024-04-16 23:39 ` [PATCH 120/156] drm/nouveau/nvif: rework outp "dp train" api Ben Skeggs
2024-04-16 23:39 ` [PATCH 121/156] drm/nouveau/nvif: rework outp "dp drive" api Ben Skeggs
2024-04-16 23:39 ` [PATCH 122/156] drm/nouveau/nvif: rework outp "dp sst" api Ben Skeggs
2024-04-16 23:39 ` [PATCH 123/156] drm/nouveau/nvif: rework outp "dp mst id get"/"dp mst id put" apis Ben Skeggs
2024-04-16 23:39 ` [PATCH 124/156] drm/nouveau/nvif: rework outp "dp mst vcpi" api Ben Skeggs
2024-04-16 23:39 ` [PATCH 125/156] drm/nouveau/nvif: remove outp from object rb Ben Skeggs
2024-04-16 23:39 ` [PATCH 126/156] drm/nouveau/nvif: rework disp "new head" api Ben Skeggs
2024-04-16 23:39 ` [PATCH 127/156] drm/nouveau/nvif: rework head "scanoutpos" api Ben Skeggs
2024-04-16 23:39 ` [PATCH 128/156] drm/nouveau/nvif: rework head "new event" api Ben Skeggs
2024-04-16 23:39 ` [PATCH 129/156] drm/nouveau/nvif: remove head from object rb Ben Skeggs
2024-04-16 23:39 ` [PATCH 130/156] drm/nouveau/nvif: rework disp "new chan" apis Ben Skeggs
2024-04-16 23:39 ` [PATCH 131/156] drm/nouveau/nvif: remove disp from object rb Ben Skeggs
2024-04-16 23:39 ` [PATCH 132/156] drm/nouveau/nvif: rework disp chan "new ctxdma" api Ben Skeggs
2024-04-16 23:39 ` [PATCH 133/156] drm/nouveau/nvif: remove disp chans from object rb Ben Skeggs
2024-04-16 23:39 ` [PATCH 134/156] drm/nouveau/nvif: rework device "new cgrp" api Ben Skeggs
2024-04-16 23:39 ` [PATCH 135/156] drm/nouveau/nvif: rework device "new ctxdma" api Ben Skeggs
2024-04-16 23:39 ` [PATCH 136/156] drm/nouveau/nvif: rework device/cgrp "new chan" apis Ben Skeggs
2024-04-16 23:39 ` [PATCH 137/156] drm/nouveau/nvif: remove mem from object rb Ben Skeggs
2024-04-16 23:39 ` [PATCH 138/156] drm/nouveau/nvif: remove vmm " Ben Skeggs
2024-04-16 23:39 ` [PATCH 139/156] drm/nouveau/nvif: remove ctxdma " Ben Skeggs
2024-04-16 23:39 ` [PATCH 140/156] drm/nouveau/nvif: remove device " Ben Skeggs
2024-04-16 23:39 ` [PATCH 141/156] drm/nouveau/nvif: rework chan "map" api Ben Skeggs
2024-04-16 23:39 ` [PATCH 142/156] drm/nouveau/nvif: rework chan "sclass" api Ben Skeggs
2024-04-16 23:39 ` [PATCH 143/156] drm/nouveau/nvif: rework chan "new event" apis Ben Skeggs
2024-04-16 23:39 ` [PATCH 144/156] drm/nouveau/nvif: rework chan "new ctxdma" api Ben Skeggs
2024-04-16 23:39 ` [PATCH 145/156] drm/nouveau/nvif: rework chan "new engobj" apis Ben Skeggs
2024-04-16 23:39 ` [PATCH 146/156] drm/nouveau/nvif: remove chan from object rb Ben Skeggs
2024-04-16 23:39 ` [PATCH 147/156] drm/nouveau/nvif: rework engobj "mthd" api Ben Skeggs
2024-04-16 23:39 ` [PATCH 148/156] drm/nouveau/nvif: rework engobj "new event" api Ben Skeggs
2024-04-16 23:39 ` [PATCH 149/156] drm/nouveau/nvif: remove engobj from object rb Ben Skeggs
2024-04-16 23:39 ` [PATCH 150/156] drm/nouveau/nvkm: switch nvkm_object to non-irqsafe spinlock Ben Skeggs
2024-04-16 23:39 ` [PATCH 151/156] drm/nouveau: remove client_mutex Ben Skeggs
2024-04-16 23:39 ` [PATCH 152/156] drm/nouveau: move nvxx_* definitions to nouveau_drv.h Ben Skeggs
2024-04-16 23:39 ` [PATCH 153/156] drm/nouveau: pass nouveau_drm to nvxx_* Ben Skeggs
2024-04-16 23:40 ` [PATCH 154/156] drm/nouveau: remove remaining usage of nvif_device.info Ben Skeggs
2024-04-16 23:40 ` [PATCH 155/156] drm/nouveau: remove remaining usage of nvif_device.object.map Ben Skeggs
2024-04-16 23:40 ` [PATCH 156/156] drm/nouveau: remove remaining usage of nouveau_drm.client Ben Skeggs
2024-04-17  4:15 ` [PATCH 000/156] drm/nouveau: replace "ioctl" interface between drm/nvkm Dave Airlie
2024-04-18 12:52   ` Ben Skeggs
2024-04-17 22:24 ` Danilo Krummrich
2024-04-18 14:03   ` Ben Skeggs
2024-04-22  9:28     ` Danilo Krummrich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).