]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/nouveau/pmu/gk20a: use nvkm_pmu_ctor()
authorAlexandre Courbot <acourbot@nvidia.com>
Tue, 13 Dec 2016 08:11:22 +0000 (17:11 +0900)
committerBen Skeggs <bskeggs@redhat.com>
Fri, 17 Feb 2017 05:14:30 +0000 (15:14 +1000)
Use the PMU constructor so that all base members (in particular the
falcon instance) are initialized properly.

Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/nvkm/subdev/pmu/gk20a.c

index f996d90c9f0dc260821d6208c36c91ea7d7177de..e897bbde44f263830b413e661575175e7ed6fd39 100644 (file)
@@ -19,7 +19,7 @@
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  * DEALINGS IN THE SOFTWARE.
  */
-#define gk20a_pmu(p) container_of((p), struct gk20a_pmu, base.subdev)
+#define gk20a_pmu(p) container_of((p), struct gk20a_pmu, base)
 #include "priv.h"
 
 #include <subdev/clk.h>
@@ -166,32 +166,25 @@ resched:
        nvkm_timer_alarm(tmr, 100000000, alarm);
 }
 
-static int
-gk20a_pmu_fini(struct nvkm_subdev *subdev, bool suspend)
-{
-       struct gk20a_pmu *pmu = gk20a_pmu(subdev);
-       nvkm_timer_alarm_cancel(subdev->device->timer, &pmu->alarm);
-       return 0;
-}
-
-static void *
-gk20a_pmu_dtor(struct nvkm_subdev *subdev)
+static void
+gk20a_pmu_fini(struct nvkm_pmu *pmu)
 {
-       return gk20a_pmu(subdev);
+       struct gk20a_pmu *gpmu = gk20a_pmu(pmu);
+       nvkm_timer_alarm_cancel(pmu->subdev.device->timer, &gpmu->alarm);
 }
 
 static int
-gk20a_pmu_init(struct nvkm_subdev *subdev)
+gk20a_pmu_init(struct nvkm_pmu *pmu)
 {
-       struct gk20a_pmu *pmu = gk20a_pmu(subdev);
-       struct nvkm_device *device = pmu->base.subdev.device;
+       struct gk20a_pmu *gpmu = gk20a_pmu(pmu);
+       struct nvkm_device *device = pmu->subdev.device;
 
        /* init pwr perf counter */
        nvkm_wr32(device, 0x10a504 + (BUSY_SLOT * 0x10), 0x00200001);
        nvkm_wr32(device, 0x10a50c + (BUSY_SLOT * 0x10), 0x00000002);
        nvkm_wr32(device, 0x10a50c + (CLK_SLOT * 0x10), 0x00000003);
 
-       nvkm_timer_alarm(device->timer, 2000000000, &pmu->alarm);
+       nvkm_timer_alarm(device->timer, 2000000000, &gpmu->alarm);
        return 0;
 }
 
@@ -202,26 +195,26 @@ gk20a_dvfs_data= {
        .p_smooth = 1,
 };
 
-static const struct nvkm_subdev_func
+static const struct nvkm_pmu_func
 gk20a_pmu = {
        .init = gk20a_pmu_init,
        .fini = gk20a_pmu_fini,
-       .dtor = gk20a_pmu_dtor,
+       .reset = gt215_pmu_reset,
 };
 
 int
 gk20a_pmu_new(struct nvkm_device *device, int index, struct nvkm_pmu **ppmu)
 {
-       static const struct nvkm_pmu_func func = {};
        struct gk20a_pmu *pmu;
 
        if (!(pmu = kzalloc(sizeof(*pmu), GFP_KERNEL)))
                return -ENOMEM;
-       pmu->base.func = &func;
        *ppmu = &pmu->base;
 
-       nvkm_subdev_ctor(&gk20a_pmu, device, index, &pmu->base.subdev);
+       nvkm_pmu_ctor(&gk20a_pmu, device, index, &pmu->base);
+
        pmu->data = &gk20a_dvfs_data;
        nvkm_alarm_init(&pmu->alarm, gk20a_pmu_dvfs_work);
+
        return 0;
 }