Skip to contentSkip to conversation

drm/nouveau/bios/therm: handle vbioses with duplicate entries (mostly nva5)

PATCH In review Martin Peres 3 participants 8 messages Aug 30, 2013 – Sep 8, 2013 5 messages not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 drm/nouveau/bios/therm: handle vbioses with duplicate entries (mostly nva5)

From: Martin Peres <[email protected]>

Some vbioses have extra useless entries after "the end" of the table. This is problematic since all of the vbios I found with this issue redefine the pwm freq divider to insane levels (52750 Hz instead of 2500), thus breaking fan management.

The first solution to solve this mess would be to change the length of the table. The solution I choose was simply to avoid setting the pwm freq twice as the other redefinitions are harmless with our current parser.

---
 drivers/gpu/drm/nouveau/core/subdev/bios/therm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/nouveau/core/subdev/bios/therm.c +2 -1
index 22a2057..22ac6db 100644
@@ -184,7 +184,8 @@ nvbios_therm_fan_parse(struct nouveau_bios *bios,
 			cur_trip->fan_duty = value;
 			break;
 		case 0x26:
-			fan->pwm_freq = value;
+			if (!fan->pwm_freq)
+				fan->pwm_freq = value;
 			break;
 		case 0x3b:
 			fan->bump_period = value;
Signature · 1 line
1.8.4

A message that is not in the archive (sent off-list or not yet received): 1377907131-15099-1-git-send-email-martin.peres-GANU6spQydw@public.gmane.org

#2 lore raw

PATCH 2/2 drm/nv84/therm: ack any pending IRQ at init

From: Martin Peres <[email protected]>

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.

---
 drivers/gpu/drm/nouveau/core/subdev/therm/nv84.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
drivers/gpu/drm/nouveau/core/subdev/therm/nv84.c +18 -1
index 42ba633..8615d62 100644
@@ -209,13 +209,30 @@ nv84_therm_ctor(struct nouveau_object *parent,
 	return nouveau_therm_preinit(&priv->base.base);
 }
 
+static int
+nv84_therm_init(struct nouveau_object *object)
+{
+	struct nv84_therm_priv *priv = (void *)object;
+	int ret;
+
+	ret = nouveau_therm_init(&priv->base.base);
+	if (ret)
+		return ret;
+
+	/* ACK ptherm IRQs */
+	nv_wr32(object, 0x20100, 0xffffffff);
+	nv_wr32(object, 0x1100, 0x10000); /* PBUS */
+
+	return 0;
+}
+
 struct nouveau_oclass
 nv84_therm_oclass = {
 	.handle = NV_SUBDEV(THERM, 0x84),
 	.ofuncs = &(struct nouveau_ofuncs) {
 		.ctor = nv84_therm_ctor,
 		.dtor = _nouveau_therm_dtor,
-		.init = _nouveau_therm_init,
+		.init = nv84_therm_init,
 		.fini = _nouveau_therm_fini,
 	},
 };
Signature · 1 line
1.8.4

A message that is not in the archive (sent off-list or not yet received): 1377907131-15099-2-git-send-email-martin.peres-GANU6spQydw@public.gmane.org

#4 lore raw

PATCH 1/1 drm/nouveau/therm: ack any pending IRQ at init v2

From: Martin Peres <[email protected]>

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+

---
 drivers/gpu/drm/nouveau/core/subdev/therm/nv84.c | 19 ++++++++++++++++++-
 drivers/gpu/drm/nouveau/core/subdev/therm/nva3.c |  4 ++++
 drivers/gpu/drm/nouveau/core/subdev/therm/nvd0.c |  4 ++++
 3 files changed, 26 insertions(+), 1 deletion(-)
drivers/gpu/drm/nouveau/core/subdev/therm/nv84.c +18 -1
index 42ba633..8615d62 100644
@@ -209,13 +209,30 @@ nv84_therm_ctor(struct nouveau_object *parent,
 	return nouveau_therm_preinit(&priv->base.base);
 }
 
+static int
+nv84_therm_init(struct nouveau_object *object)
+{
+	struct nv84_therm_priv *priv = (void *)object;
+	int ret;
+
+	ret = nouveau_therm_init(&priv->base.base);
+	if (ret)
+		return ret;
+
+	/* ACK ptherm IRQs */
+	nv_wr32(object, 0x20100, 0xffffffff);
+	nv_wr32(object, 0x1100, 0x10000); /* PBUS */
+
+	return 0;
+}
+
 struct nouveau_oclass
 nv84_therm_oclass = {
 	.handle = NV_SUBDEV(THERM, 0x84),
 	.ofuncs = &(struct nouveau_ofuncs) {
 		.ctor = nv84_therm_ctor,
 		.dtor = _nouveau_therm_dtor,
-		.init = _nouveau_therm_init,
+		.init = nv84_therm_init,
 		.fini = _nouveau_therm_fini,
 	},
 };
drivers/gpu/drm/nouveau/core/subdev/therm/nva3.c +4 -0
index d11a7c4..f740eeb 100644
@@ -60,6 +60,10 @@ nva3_therm_init(struct nouveau_object *object)
 	}
 	nv_mask(priv, 0x00e720, 0x00000002, 0x00000000);
 
+	/* ACK ptherm IRQs */
+	nv_wr32(object, 0x20100, 0xffffffff);
+	nv_wr32(object, 0x1100, 0x10000); /* PBUS */
+
 	return 0;
 }
 
drivers/gpu/drm/nouveau/core/subdev/therm/nvd0.c +4 -0
index 54c28bd..d9b5103 100644
@@ -114,6 +114,10 @@ nvd0_therm_init(struct nouveau_object *object)
 	}
 	nv_mask(priv, 0x00e720, 0x00000002, 0x00000000);
 
+	/* ACK ptherm IRQs */
+	nv_wr32(object, 0x20100, 0xffffffff);
+	nv_wr32(object, 0x1100, 0x10000); /* PBUS */
+
 	return 0;
 }
 
Signature · 1 line
1.8.4

A message that is not in the archive (sent off-list or not yet received): 1377907571-15301-1-git-send-email-martin.peres-GANU6spQydw@public.gmane.org

#6 lore raw

Re: [PATCH] drm/nouveau/therm: ack any pending IRQ at init v2

Quoted 5 lines · Martin Peres

From: Martin Peres <[email protected]>

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.

Any objections to instead sticking the ACK in a single fini() hook (along with additional code to disable all therm interrupts), and having the IRQ handle silently ignore any non-requested IRQs (see what the copy engine irq handler does, for example)?

Ben.

Quoted 84 lines

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

---
 drivers/gpu/drm/nouveau/core/subdev/therm/nv84.c | 19 ++++++++++++++++++-
 drivers/gpu/drm/nouveau/core/subdev/therm/nva3.c |  4 ++++
 drivers/gpu/drm/nouveau/core/subdev/therm/nvd0.c |  4 ++++
 3 files changed, 26 insertions(+), 1 deletion(-)
drivers/gpu/drm/nouveau/core/subdev/therm/nv84.c +18 -1
index 42ba633..8615d62 100644
@@ -209,13 +209,30 @@ nv84_therm_ctor(struct nouveau_object *parent,
        return nouveau_therm_preinit(&priv->base.base);
 }
 
+static int
+nv84_therm_init(struct nouveau_object *object)
+{
+       struct nv84_therm_priv *priv = (void *)object;
+       int ret;
+
+       ret = nouveau_therm_init(&priv->base.base);
+       if (ret)
+               return ret;
+
+       /* ACK ptherm IRQs */
+       nv_wr32(object, 0x20100, 0xffffffff);
+       nv_wr32(object, 0x1100, 0x10000); /* PBUS */
+
+       return 0;
+}
+
 struct nouveau_oclass
 nv84_therm_oclass = {
        .handle = NV_SUBDEV(THERM, 0x84),
        .ofuncs = &(struct nouveau_ofuncs) {
                .ctor = nv84_therm_ctor,
                .dtor = _nouveau_therm_dtor,
-               .init = _nouveau_therm_init,
+               .init = nv84_therm_init,
                .fini = _nouveau_therm_fini,
        },
 };
drivers/gpu/drm/nouveau/core/subdev/therm/nva3.c +4 -0
index d11a7c4..f740eeb 100644
@@ -60,6 +60,10 @@ nva3_therm_init(struct nouveau_object *object)
        }
        nv_mask(priv, 0x00e720, 0x00000002, 0x00000000);
 
+       /* ACK ptherm IRQs */
+       nv_wr32(object, 0x20100, 0xffffffff);
+       nv_wr32(object, 0x1100, 0x10000); /* PBUS */
+
        return 0;
 }
 
drivers/gpu/drm/nouveau/core/subdev/therm/nvd0.c +4 -1
index 54c28bd..d9b5103 100644
@@ -114,6 +114,10 @@ nvd0_therm_init(struct nouveau_object *object)
        }
        nv_mask(priv, 0x00e720, 0x00000002, 0x00000000);
 
+       /* ACK ptherm IRQs */
+       nv_wr32(object, 0x20100, 0xffffffff);
+       nv_wr32(object, 0x1100, 0x10000); /* PBUS */
+
        return 0;
 }
 
--

1.8.4

_______________________________________________
Nouveau mailing list [email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau

A message that is not in the archive (sent off-list or not yet received): CACAvsv6+9TqeTjMeMPdAwDrxLbbZ1sBJDQFmE7Xum9ryebns7g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#8 lore raw

Re: [PATCH] drm/nouveau/therm: ack any pending IRQ at init v2

Quoted 6 lines · Ben Skeggs
Quoted 5 lines · Martin Peres

From: Martin Peres <[email protected]>

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.

Quoted 6 lines

Any objections to instead sticking the ACK in a single fini() hook (along with additional code to disable all therm interrupts), and having the IRQ handle silently ignore any non-requested IRQs (see what the copy engine irq handler does, for example)?

Ben.

Hi Ben,

Sorry for the late answer. This all perfectly make sense. Please have a look at the patches I've just sent.

#9 lore raw
In reply to a message not in the archive
Quoted 7 lines · Martin Peres

From: Martin Peres <[email protected]>

Some vbioses have extra useless entries after "the end" of the table. This is problematic since all of the vbios I found with this issue redefine the pwm freq divider to insane levels (52750 Hz instead of 2500), thus breaking fan management.

Quoted 5 lines

The first solution to solve this mess would be to change the length of the table. The solution I choose was simply to avoid setting the pwm freq twice as the other redefinitions are harmless with our current parser.

Sorry, the email should be ammended to [email protected] (only one b).

#10 lore raw
In reply to a message not in the archive
Quoted 10 lines · Martin Peres

From: Martin Peres <[email protected]>

Some vbioses have extra useless entries after "the end" of the table. This is problematic since all of the vbios I found with this issue redefine the pwm freq divider to insane levels (52750 Hz instead of 2500), thus breaking fan management.

The first solution to solve this mess would be to change the length of the table. The solution I choose was simply to avoid setting the pwm freq twice as the other redefinitions are harmless with our current parser.

I'm still *really* not convinced we're using the thermal table correctly....

However, this makes sense for our current handling, so, merged.

Thanks,
Ben.

Quoted 29 lines
---
 drivers/gpu/drm/nouveau/core/subdev/bios/therm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/nouveau/core/subdev/bios/therm.c +2 -2
index 22a2057..22ac6db 100644
@@ -184,7 +184,8 @@ nvbios_therm_fan_parse(struct nouveau_bios *bios,
                        cur_trip->fan_duty = value;
                        break;
                case 0x26:
-                       fan->pwm_freq = value;
+                       if (!fan->pwm_freq)
+                               fan->pwm_freq = value;
                        break;
                case 0x3b:
                        fan->bump_period = value;
--

1.8.4

_______________________________________________
Nouveau mailing list [email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau

A message that is not in the archive (sent off-list or not yet received): CACAvsv5VTQvVcQhB0_=GY4Jjx=3-EAd+QMqzemR7qsDeh7KxzA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#12 lore raw
Quoted 11 lines · Ben Skeggs
Quoted 10 lines · Martin Peres

From: Martin Peres <[email protected]>

Some vbioses have extra useless entries after "the end" of the table. This is problematic since all of the vbios I found with this issue redefine the pwm freq divider to insane levels (52750 Hz instead of 2500), thus breaking fan management.

The first solution to solve this mess would be to change the length of the table. The solution I choose was simply to avoid setting the pwm freq twice as the other redefinitions are harmless with our current parser.

Quoted 6 lines

I'm still *really* not convinced we're using the thermal table correctly....

However, this makes sense for our current handling, so, merged.

Thanks,
Ben.

Well, I do agree that the first versions of the vbios table really felt like a script but this isn't the case anymore (not sure how I tested this though as it was more than a year ago).