drm/nouveau/nvif: device time mthd
authorBen Skeggs <bskeggs@redhat.com>
Thu, 20 Aug 2015 04:54:16 +0000 (14:54 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Fri, 28 Aug 2015 02:40:33 +0000 (12:40 +1000)
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/include/nvif/class.h
drivers/gpu/drm/nouveau/include/nvif/device.h
drivers/gpu/drm/nouveau/nvif/device.c
drivers/gpu/drm/nouveau/nvkm/engine/device/user.c

index e11b5acb35e7856292cb6f4a834db05d355f370e..d52b27ac33ff1bc1bbe5efdc683bacf6243ec4c0 100644 (file)
@@ -129,6 +129,7 @@ struct nv_device_v0 {
 };
 
 #define NV_DEVICE_V0_INFO                                                  0x00
+#define NV_DEVICE_V0_TIME                                                  0x01
 
 struct nv_device_info_v0 {
        __u8  version;
@@ -157,6 +158,12 @@ struct nv_device_info_v0 {
        char  name[64];
 };
 
+struct nv_device_time_v0 {
+       __u8  version;
+       __u8  pad01[7];
+       __u64 time;
+};
+
 
 /*******************************************************************************
  * context dma
index 68b431b24ae6efb4dfca8149f895413a89f76729..68196f4874f8e37fc34fbbbd637d8cdfc7db7b6c 100644 (file)
@@ -57,7 +57,6 @@ u64  nvif_device_time(struct nvif_device *);
 #define nvxx_gpio(a) nvkm_gpio(nvxx_device(a))
 #define nvxx_clk(a) nvkm_clk(nvxx_device(a))
 #define nvxx_i2c(a) nvkm_i2c(nvxx_device(a))
-#define nvxx_timer(a) nvkm_timer(nvxx_device(a))
 #define nvxx_therm(a) nvkm_therm(nvxx_device(a))
 
 #include <core/device.h>
index 561fb9d7b15508eefb9b50189a46a196cef1373b..252d8c33215bb44591add83fd05d5f65c325aa9e 100644 (file)
 u64
 nvif_device_time(struct nvif_device *device)
 {
-       return nvxx_timer(device)->read(nvxx_timer(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;
 }
 
 void
index e44d60739b56ee3e3127a331c0218816f855da69..cb3f3deefb01825b3fbce6653a44bee0ff8cf494 100644 (file)
@@ -26,6 +26,7 @@
 #include <core/client.h>
 #include <subdev/fb.h>
 #include <subdev/instmem.h>
+#include <subdev/timer.h>
 
 #include <nvif/class.h>
 #include <nvif/unpack.h>
@@ -111,12 +112,32 @@ nvkm_udevice_info(struct nvkm_object *object, void *data, u32 size)
        return 0;
 }
 
+static int
+nvkm_udevice_time(struct nvkm_object *object, void *data, u32 size)
+{
+       struct nvkm_udevice *udev = (void *)object;
+       struct nvkm_device *device = udev->device;
+       struct nvkm_timer *tmr = device->timer;
+       union {
+               struct nv_device_time_v0 v0;
+       } *args = data;
+       int ret;
+
+       if (nvif_unpack(args->v0, 0, 0, false)) {
+               args->v0.time = tmr->read(tmr);
+       }
+
+       return ret;
+}
+
 static int
 nvkm_udevice_mthd(struct nvkm_object *object, u32 mthd, void *data, u32 size)
 {
        switch (mthd) {
        case NV_DEVICE_V0_INFO:
                return nvkm_udevice_info(object, data, size);
+       case NV_DEVICE_V0_TIME:
+               return nvkm_udevice_time(object, data, size);
        default:
                break;
        }