Skip to content

Commit 58e92b5

Browse files
author
Ben Skeggs
committed
drm/nouveau/nvif: access PTIMER through usermode class, if available
Signed-off-by: Ben Skeggs <[email protected]>
1 parent 028a12f commit 58e92b5

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

drivers/gpu/drm/nouveau/include/nvif/user.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ struct nvif_user {
1010

1111
struct nvif_user_func {
1212
void (*doorbell)(struct nvif_user *, u32 token);
13+
u64 (*time)(struct nvif_user *);
1314
};
1415

1516
int nvif_user_init(struct nvif_device *);

drivers/gpu/drm/nouveau/nvif/device.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,15 @@
2727
u64
2828
nvif_device_time(struct nvif_device *device)
2929
{
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);
3539
}
3640

3741
void

drivers/gpu/drm/nouveau/nvif/userc361.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,19 @@
2121
*/
2222
#include <nvif/user.h>
2323

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+
2437
static void
2538
nvif_userc361_doorbell(struct nvif_user *user, u32 token)
2639
{
@@ -30,4 +43,5 @@ nvif_userc361_doorbell(struct nvif_user *user, u32 token)
3043
const struct nvif_user_func
3144
nvif_userc361 = {
3245
.doorbell = nvif_userc361_doorbell,
46+
.time = nvif_userc361_time,
3347
};

0 commit comments

Comments
 (0)