drm/nouveau/pmu/gt215-: abstract detection of whether reset is needed
authorBen Skeggs <bskeggs@redhat.com>
Fri, 21 Jul 2017 00:45:32 +0000 (10:45 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Tue, 22 Aug 2017 08:04:31 +0000 (18:04 +1000)
GT215, GF100-GP100, and GP10x are all different.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
13 files changed:
drivers/gpu/drm/nouveau/nvkm/subdev/pmu/base.c
drivers/gpu/drm/nouveau/nvkm/subdev/pmu/gf100.c
drivers/gpu/drm/nouveau/nvkm/subdev/pmu/gf119.c
drivers/gpu/drm/nouveau/nvkm/subdev/pmu/gk104.c
drivers/gpu/drm/nouveau/nvkm/subdev/pmu/gk110.c
drivers/gpu/drm/nouveau/nvkm/subdev/pmu/gk208.c
drivers/gpu/drm/nouveau/nvkm/subdev/pmu/gk20a.c
drivers/gpu/drm/nouveau/nvkm/subdev/pmu/gm107.c
drivers/gpu/drm/nouveau/nvkm/subdev/pmu/gm20b.c
drivers/gpu/drm/nouveau/nvkm/subdev/pmu/gp100.c
drivers/gpu/drm/nouveau/nvkm/subdev/pmu/gp102.c
drivers/gpu/drm/nouveau/nvkm/subdev/pmu/gt215.c
drivers/gpu/drm/nouveau/nvkm/subdev/pmu/priv.h

index 3306f9fe7140c6258106fd52c120dae0f737300f..ce70a193caa7f4db194e2cb68e683b93121bc820 100644 (file)
@@ -75,7 +75,7 @@ nvkm_pmu_reset(struct nvkm_pmu *pmu)
 {
        struct nvkm_device *device = pmu->subdev.device;
 
-       if (!(nvkm_rd32(device, 0x000200) & 0x00002000))
+       if (!pmu->func->enabled(pmu))
                return 0;
 
        /* Inhibit interrupts, and wait for idle. */
index 976a0820544123823b1022de047f597c4d3c0cf6..0b458656e870779d041ab3cd736f567f98d065c0 100644 (file)
@@ -34,12 +34,19 @@ gf100_pmu_reset(struct nvkm_pmu *pmu)
        nvkm_mc_enable(device, NVKM_SUBDEV_PMU);
 }
 
+bool
+gf100_pmu_enabled(struct nvkm_pmu *pmu)
+{
+       return nvkm_mc_enabled(pmu->subdev.device, NVKM_SUBDEV_PMU);
+}
+
 static const struct nvkm_pmu_func
 gf100_pmu = {
        .code.data = gf100_pmu_code,
        .code.size = sizeof(gf100_pmu_code),
        .data.data = gf100_pmu_data,
        .data.size = sizeof(gf100_pmu_data),
+       .enabled = gf100_pmu_enabled,
        .reset = gf100_pmu_reset,
        .init = gt215_pmu_init,
        .fini = gt215_pmu_fini,
index ca3b4dfe18e319c12ceb7aef4a573702ae2e94c8..3dfa79d4fb13a07781791ec0eeb6ab8bac48d68e 100644 (file)
@@ -30,6 +30,7 @@ gf119_pmu = {
        .code.size = sizeof(gf119_pmu_code),
        .data.data = gf119_pmu_data,
        .data.size = sizeof(gf119_pmu_data),
+       .enabled = gf100_pmu_enabled,
        .reset = gf100_pmu_reset,
        .init = gt215_pmu_init,
        .fini = gt215_pmu_fini,
index c26195d5fc3265e38cfb0c0d453291f475e57417..8f7ec10fd2a42609fa407a5a56c4eb5b398880f5 100644 (file)
@@ -109,6 +109,7 @@ gk104_pmu = {
        .code.size = sizeof(gk104_pmu_code),
        .data.data = gk104_pmu_data,
        .data.size = sizeof(gk104_pmu_data),
+       .enabled = gf100_pmu_enabled,
        .reset = gf100_pmu_reset,
        .init = gt215_pmu_init,
        .fini = gt215_pmu_fini,
index aac0258a1babc466a6a27f95178b1981fd406d58..345741d55a56b126665576a7e66fe25977e10841 100644 (file)
@@ -88,6 +88,7 @@ gk110_pmu = {
        .code.size = sizeof(gk110_pmu_code),
        .data.data = gk110_pmu_data,
        .data.size = sizeof(gk110_pmu_data),
+       .enabled = gf100_pmu_enabled,
        .reset = gf100_pmu_reset,
        .init = gt215_pmu_init,
        .fini = gt215_pmu_fini,
index 0efbc0f9fffb38efbb9d0f4d45fa0720b4d2cb18..e4acf7876ea1b541a6c0e9eefa16ef77a857e2b5 100644 (file)
@@ -30,6 +30,7 @@ gk208_pmu = {
        .code.size = sizeof(gk208_pmu_code),
        .data.data = gk208_pmu_data,
        .data.size = sizeof(gk208_pmu_data),
+       .enabled = gf100_pmu_enabled,
        .reset = gf100_pmu_reset,
        .init = gt215_pmu_init,
        .fini = gt215_pmu_fini,
index 14862452a597d65b97353fe6c8e4d257b303766d..05e81855c367f442b8eb0292d8fe793bc9b46a80 100644 (file)
@@ -196,6 +196,7 @@ gk20a_dvfs_data= {
 
 static const struct nvkm_pmu_func
 gk20a_pmu = {
+       .enabled = gf100_pmu_enabled,
        .init = gk20a_pmu_init,
        .fini = gk20a_pmu_fini,
        .reset = gf100_pmu_reset,
index 25e18f2ea0819ba3304f4f9fdcdd8b26c593220b..459df1ef9e70c67d138902a4a521ff8a80ccf3f6 100644 (file)
@@ -32,6 +32,7 @@ gm107_pmu = {
        .code.size = sizeof(gm107_pmu_code),
        .data.data = gm107_pmu_data,
        .data.size = sizeof(gm107_pmu_data),
+       .enabled = gf100_pmu_enabled,
        .reset = gf100_pmu_reset,
        .init = gt215_pmu_init,
        .fini = gt215_pmu_fini,
index 44bef22bce52e3b489ebd8a7fe784d2cdeae20e5..31c843145c7ac0d1f6374744064e38106fd4d159 100644 (file)
@@ -38,6 +38,7 @@ gm20b_pmu_recv(struct nvkm_pmu *pmu)
 
 static const struct nvkm_pmu_func
 gm20b_pmu = {
+       .enabled = gf100_pmu_enabled,
        .intr = gt215_pmu_intr,
        .recv = gm20b_pmu_recv,
 };
index 0e23d5d4bb3416e56e9c8386cc38887d661f5b41..e210cd6af816dd22212084d363f728fe42148806 100644 (file)
@@ -25,6 +25,7 @@
 
 static const struct nvkm_pmu_func
 gp100_pmu = {
+       .enabled = gf100_pmu_enabled,
        .reset = gf100_pmu_reset,
 };
 
index f017352206c9fcd2907564dd1e301c95e2d48a72..98c7a2a8afc4507e998ee129ab90da251e791b0e 100644 (file)
@@ -31,8 +31,15 @@ gp102_pmu_reset(struct nvkm_pmu *pmu)
        nvkm_mask(device, 0x10a3c0, 0x00000001, 0x00000000);
 }
 
+static bool
+gp102_pmu_enabled(struct nvkm_pmu *pmu)
+{
+       return !(nvkm_rd32(pmu->subdev.device, 0x10a3c0) & 0x00000001);
+}
+
 static const struct nvkm_pmu_func
 gp102_pmu = {
+       .enabled = gp102_pmu_enabled,
        .reset = gp102_pmu_reset,
 };
 
index 9b5d97dac5508b4e9437bfcffcbf4b9e9313ec20..e04216daea5812c5b7a5c9e609c3286fce207ab4 100644 (file)
@@ -189,6 +189,12 @@ gt215_pmu_reset(struct nvkm_pmu *pmu)
        nvkm_rd32(device, 0x022210);
 }
 
+static bool
+gt215_pmu_enabled(struct nvkm_pmu *pmu)
+{
+       return nvkm_rd32(pmu->subdev.device, 0x022210) & 0x00000001;
+}
+
 int
 gt215_pmu_init(struct nvkm_pmu *pmu)
 {
@@ -241,6 +247,7 @@ gt215_pmu = {
        .code.size = sizeof(gt215_pmu_code),
        .data.data = gt215_pmu_data,
        .data.size = sizeof(gt215_pmu_data),
+       .enabled = gt215_pmu_enabled,
        .reset = gt215_pmu_reset,
        .init = gt215_pmu_init,
        .fini = gt215_pmu_fini,
index 616641d543a82b9ccbf38d04e32c818fec1a406f..a4c48a10cd47f1292e87279ba87ab0b18a845b4e 100644 (file)
@@ -20,6 +20,7 @@ struct nvkm_pmu_func {
                u32  size;
        } data;
 
+       bool (*enabled)(struct nvkm_pmu *);
        void (*reset)(struct nvkm_pmu *);
        int (*init)(struct nvkm_pmu *);
        void (*fini)(struct nvkm_pmu *);
@@ -36,6 +37,7 @@ void gt215_pmu_intr(struct nvkm_pmu *);
 void gt215_pmu_recv(struct nvkm_pmu *);
 int gt215_pmu_send(struct nvkm_pmu *, u32[2], u32, u32, u32, u32);
 
+bool gf100_pmu_enabled(struct nvkm_pmu *);
 void gf100_pmu_reset(struct nvkm_pmu *);
 
 void gk110_pmu_pgob(struct nvkm_pmu *, bool);