Skip to content

Commit

Permalink
drm/nouveau/nvif: access PTIMER through usermode class, if available
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
  • Loading branch information
Ben Skeggs committed Apr 7, 2020
1 parent 028a12f commit 58e92b5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
1 change: 1 addition & 0 deletions drivers/gpu/drm/nouveau/include/nvif/user.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ struct nvif_user {

struct nvif_user_func {
void (*doorbell)(struct nvif_user *, u32 token);
u64 (*time)(struct nvif_user *);
};

int nvif_user_init(struct nvif_device *);
Expand Down
14 changes: 9 additions & 5 deletions drivers/gpu/drm/nouveau/nvif/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,15 @@
u64
nvif_device_time(struct nvif_device *device)
{
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) {
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;
}

return device->user.func->time(&device->user);
}

void
Expand Down
14 changes: 14 additions & 0 deletions drivers/gpu/drm/nouveau/nvif/userc361.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,19 @@
*/
#include <nvif/user.h>

static u64
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));

return ((u64)hi << 32 | lo);
}

static void
nvif_userc361_doorbell(struct nvif_user *user, u32 token)
{
Expand All @@ -30,4 +43,5 @@ nvif_userc361_doorbell(struct nvif_user *user, u32 token)
const struct nvif_user_func
nvif_userc361 = {
.doorbell = nvif_userc361_doorbell,
.time = nvif_userc361_time,
};

0 comments on commit 58e92b5

Please sign in to comment.