Commit 58e92b5ee8743ebb77b824cce3330521f049bbac

Authored by Ben Skeggs
1 parent 028a12f5aa

drm/nouveau/nvif: access PTIMER through usermode class, if available

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

Showing 3 changed files with 24 additions and 5 deletions Side-by-side Diff

drivers/gpu/drm/nouveau/include/nvif/user.h
... ... @@ -10,6 +10,7 @@
10 10  
11 11 struct nvif_user_func {
12 12 void (*doorbell)(struct nvif_user *, u32 token);
  13 + u64 (*time)(struct nvif_user *);
13 14 };
14 15  
15 16 int nvif_user_init(struct nvif_device *);
drivers/gpu/drm/nouveau/nvif/device.c
... ... @@ -27,11 +27,15 @@
27 27 u64
28 28 nvif_device_time(struct nvif_device *device)
29 29 {
30   - struct nv_device_time_v0 args = {};
31   - int ret = nvif_object_mthd(&device->object, NV_DEVICE_V0_TIME,
32   - &args, sizeof(args));
33   - WARN_ON_ONCE(ret != 0);
34   - return args.time;
  30 + if (!device->user.func) {
  31 + struct nv_device_time_v0 args = {};
  32 + int ret = nvif_object_mthd(&device->object, NV_DEVICE_V0_TIME,
  33 + &args, sizeof(args));
  34 + WARN_ON_ONCE(ret != 0);
  35 + return args.time;
  36 + }
  37 +
  38 + return device->user.func->time(&device->user);
35 39 }
36 40  
37 41 void
drivers/gpu/drm/nouveau/nvif/userc361.c
... ... @@ -21,6 +21,19 @@
21 21 */
22 22 #include <nvif/user.h>
23 23  
  24 +static u64
  25 +nvif_userc361_time(struct nvif_user *user)
  26 +{
  27 + u32 hi, lo;
  28 +
  29 + do {
  30 + hi = nvif_rd32(&user->object, 0x084);
  31 + lo = nvif_rd32(&user->object, 0x080);
  32 + } while (hi != nvif_rd32(&user->object, 0x084));
  33 +
  34 + return ((u64)hi << 32 | lo);
  35 +}
  36 +
24 37 static void
25 38 nvif_userc361_doorbell(struct nvif_user *user, u32 token)
26 39 {
... ... @@ -30,5 +43,6 @@
30 43 const struct nvif_user_func
31 44 nvif_userc361 = {
32 45 .doorbell = nvif_userc361_doorbell,
  46 + .time = nvif_userc361_time,
33 47 };