drm/nouveau/therm: ack any pending IRQ at init
authorMartin Peres <martin.peres@labri.fr>
Sun, 8 Sep 2013 22:43:27 +0000 (00:43 +0200)
committerBen Skeggs <bskeggs@redhat.com>
Fri, 8 Nov 2013 05:37:43 +0000 (15:37 +1000)
This is safe because ptherm hasn't been configured yet and will be a
little further down the initialization path. Ptherm should be safe
regarding to runtime reconfiguration.

v2:
  - do not limit this patch to nv84-a3 and make it nv84+

v3:
  - move the ack to fini()
  - disable IRQs on fini()
  - silently ignore un-requested IRQs

Signed-off-by: Martin Peres <martin.peres@labri.fr>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/core/subdev/therm/nv84.c
drivers/gpu/drm/nouveau/core/subdev/therm/nva3.c
drivers/gpu/drm/nouveau/core/subdev/therm/nvd0.c
drivers/gpu/drm/nouveau/core/subdev/therm/priv.h

index 42ba633..1d15c52 100644 (file)
@@ -126,7 +126,7 @@ nv84_therm_intr(struct nouveau_subdev *subdev)
 
        spin_lock_irqsave(&priv->sensor.alarm_program_lock, flags);
 
-       intr = nv_rd32(therm, 0x20100);
+       intr = nv_rd32(therm, 0x20100) & 0x3ff;
 
        /* THRS_4: downclock */
        if (intr & 0x002) {
@@ -209,6 +209,19 @@ nv84_therm_ctor(struct nouveau_object *parent,
        return nouveau_therm_preinit(&priv->base.base);
 }
 
+int
+nv84_therm_fini(struct nouveau_object *object, bool suspend)
+{
+       /* Disable PTherm IRQs */
+       nv_wr32(object, 0x20000, 0x00000000);
+
+       /* ACK all PTherm IRQs */
+       nv_wr32(object, 0x20100, 0xffffffff);
+       nv_wr32(object, 0x1100, 0x10000); /* PBUS */
+
+       return _nouveau_therm_fini(object, suspend);
+}
+
 struct nouveau_oclass
 nv84_therm_oclass = {
        .handle = NV_SUBDEV(THERM, 0x84),
@@ -216,6 +229,6 @@ nv84_therm_oclass = {
                .ctor = nv84_therm_ctor,
                .dtor = _nouveau_therm_dtor,
                .init = _nouveau_therm_init,
-               .fini = _nouveau_therm_fini,
+               .fini = nv84_therm_fini,
        },
 };
index d11a7c4..3b2c458 100644 (file)
@@ -94,6 +94,6 @@ nva3_therm_oclass = {
                .ctor = nva3_therm_ctor,
                .dtor = _nouveau_therm_dtor,
                .init = nva3_therm_init,
-               .fini = _nouveau_therm_fini,
+               .fini = nv84_therm_fini,
        },
 };
index 54c28bd..4dd4f81 100644 (file)
@@ -148,6 +148,6 @@ nvd0_therm_oclass = {
                .ctor = nvd0_therm_ctor,
                .dtor = _nouveau_therm_dtor,
                .init = nvd0_therm_init,
-               .fini = _nouveau_therm_fini,
+               .fini = nv84_therm_fini,
        },
 };
index dd38529..508b1ec 100644 (file)
@@ -144,6 +144,7 @@ int nv50_fan_pwm_get(struct nouveau_therm *, int, u32 *, u32 *);
 int nv50_fan_pwm_set(struct nouveau_therm *, int, u32, u32);
 int nv50_fan_pwm_clock(struct nouveau_therm *);
 int nv84_temp_get(struct nouveau_therm *therm);
+int nv84_therm_fini(struct nouveau_object *object, bool suspend);
 
 int nva3_therm_fan_sense(struct nouveau_therm *);