From patchwork Thu Aug 15 02:07:24 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Martin Peres X-Patchwork-Id: 2844967 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4E6FCBF546 for ; Thu, 15 Aug 2013 05:13:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 259D52049B for ; Thu, 15 Aug 2013 05:13:38 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 9C6762048E for ; Thu, 15 Aug 2013 05:13:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 57D54E6643 for ; Wed, 14 Aug 2013 22:13:36 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from iona.labri.fr (iona.labri.fr [147.210.8.143]) by gabe.freedesktop.org (Postfix) with ESMTP id 23C69E5DE8 for ; Wed, 14 Aug 2013 19:07:14 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by iona.labri.fr (Postfix) with ESMTP id F2D11487A; Thu, 15 Aug 2013 04:07:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=labri.fr; h= content-type:content-type:in-reply-to:references:subject:subject :mime-version:user-agent:from:from:date:date:message-id:received :received; s=mail; t=1376532431; x=1378346832; bh=QACfL95yWtUE2C I2ukuP5+W9ZOv7UngxHvhNnXYHPgo=; b=UyqKfWBPl/MxYUZn1IcUyARutuIWI5 wWDfYuOSDZDoEfJs08GbDuji2Dg1oakJiEOo4IMk3hpAdcrZHkgZfa4xaYgAE5bN aTQkEalssz2I/EO4W9ja++LJg2JvJrbMy/0F7SJ6xL0+EkPUwHPoRePcZNjUCNcs rxbGs1iLBMfxE= X-Virus-Scanned: amavisd-new at labri.fr Received: from iona.labri.fr ([127.0.0.1]) by localhost (iona.labri.fr [127.0.0.1]) (amavisd-new, port 10027) with LMTP id OyVsSl3YP4RL; Thu, 15 Aug 2013 04:07:11 +0200 (CEST) Received: from [10.75.139.106] (CPE001143e6cde7-CMbc14012631f0.cpe.net.cable.rogers.com [99.241.74.27]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by iona.labri.fr (Postfix) with ESMTPSA id 7AA9C366E; Thu, 15 Aug 2013 04:07:10 +0200 (CEST) Message-ID: <520C37DC.90902@labri.fr> Date: Wed, 14 Aug 2013 22:07:24 -0400 From: Martin Peres User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130806 Thunderbird/17.0.8 MIME-Version: 1.0 To: =?UTF-8?B?UGFsaSBSb2jDoXI=?= Subject: Re: nouveau: temperature on nv40 is unavailable since ad40d73ef533ab0ad16b4a1ab2f7870c1f8ab954 References: <1836330.fGgIDqPTNA@pali> <3b367f03-0ab0-4b22-893e-3f03f16a496e@gmail.com> <520A3AD0.5000304@labri.fr> <201308141102.47960@pali> In-Reply-To: <201308141102.47960@pali> X-Mailman-Approved-At: Wed, 14 Aug 2013 22:13:16 -0700 Cc: Ben Skeggs , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On 14/08/2013 05:02, Pali Rohár wrote: > On Tuesday 13 August 2013 15:55:28 Martin Peres wrote: >> On 13/08/2013 09:53, Pali Rohár wrote: >>> On utorok, 13. augusta 2013 15:32:45 CEST, Martin Peres > wrote: >>>> On 13/08/2013 09:23, Pali Rohár wrote: >>>>> On Tuesday 13 August 2013 09:01:19 Martin Peres wrote: >>>> ... >>>> >>>> You can check the temperature by running nvidia-settings. >>>> If you can't see the temperature in it, then nvidia >>>> doesn't support it on your card and >>>> I'm not sure we should :s >>>> >>>> Thanks for the vbios you sent me in private. For the >>>> others, the reason why he doesn't have temperature anymore >>>> is because his vbios lacks sensor calibration values. >>> In nvidia-settings tab "GPU 0 - (GeForce 6600 GT)" --> >>> "Thermal Settings" is: >>> >>> Thermal Sensor Information: >>> ID: 0 >>> Target: GPU >>> Provider: GPU Internal >>> Temperature: 70 C (now) >>> >>> I looked in Windows program SpeedFan. It found Nvidia PCI >>> card and reported "GPU Temp" about 68-70 C. So it looks >>> like both nvidia driver and windows SpeedFan program >>> reading same values. >> Great, I'll cook you a patch in a bit and you'll see what the >> temperature is like. It won't be perfectly accurate but there >> is some kind of default for nvidia cards of this generation. > Ok, send me patch and I can try it if it will work and report > similar values as windows or nvidia driver. > Sorry for the late answer. Please test this patch. Be aware that temperature with nouveau will be higher than with the blob. I only want to see if nouveau reports a temperature. The only way to be sure if the values are good-enough would be to use the blob and run: nvapeek 0x15b0 Please send me the result along with the temperature reported by nvidia at the time of the peek. Martin PS: This patch has only be compile-tested, I don't have access to an nv4x right now. From abe97f1e5de0b7ae5114802fcbc99d6e3408cd00 Mon Sep 17 00:00:00 2001 From: Martin Peres Date: Wed, 14 Aug 2013 22:00:48 -0400 Subject: [PATCH] drm/nv40/therm: set default calibration values if needed Some vbios expose a thermal sensor but do not set default calibration values. As they are almost always the same, let's set some default ones. Signed-off-by: Martin Peres --- .../drm/nouveau/core/include/subdev/bios/therm.h | 1 + drivers/gpu/drm/nouveau/core/subdev/bios/therm.c | 1 + drivers/gpu/drm/nouveau/core/subdev/therm/nv40.c | 36 ++++++++++++++++++---- drivers/gpu/drm/nouveau/core/subdev/therm/temp.c | 5 ++- 4 files changed, 34 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/nouveau/core/include/subdev/bios/therm.h b/drivers/gpu/drm/nouveau/core/include/subdev/bios/therm.h index 083541d..11b7993 100644 --- a/drivers/gpu/drm/nouveau/core/include/subdev/bios/therm.h +++ b/drivers/gpu/drm/nouveau/core/include/subdev/bios/therm.h @@ -10,6 +10,7 @@ struct nvbios_therm_threshold { struct nvbios_therm_sensor { /* diode */ + int has_sensor; s16 slope_mult; s16 slope_div; s16 offset_num; diff --git a/drivers/gpu/drm/nouveau/core/subdev/bios/therm.c b/drivers/gpu/drm/nouveau/core/subdev/bios/therm.c index 22a2057..16b763d 100644 --- a/drivers/gpu/drm/nouveau/core/subdev/bios/therm.c +++ b/drivers/gpu/drm/nouveau/core/subdev/bios/therm.c @@ -95,6 +95,7 @@ nvbios_therm_sensor_parse(struct nouveau_bios *bios, sensor_section++; if (sensor_section == 0) { offset = ((s8) nv_ro08(bios, entry + 2)) / 2; + sensor->has_sensor = 1; sensor->offset_constant = offset; } break; diff --git a/drivers/gpu/drm/nouveau/core/subdev/therm/nv40.c b/drivers/gpu/drm/nouveau/core/subdev/therm/nv40.c index 002e51b..5312bbd 100644 --- a/drivers/gpu/drm/nouveau/core/subdev/therm/nv40.c +++ b/drivers/gpu/drm/nouveau/core/subdev/therm/nv40.c @@ -93,11 +93,6 @@ nv40_temp_get(struct nouveau_therm *therm) } else return -ENODEV; - /* if the slope or the offset is unset, do no use the sensor */ - if (!sensor->slope_div || !sensor->slope_mult || - !sensor->offset_num || !sensor->offset_den) - return -ENODEV; - core_temp = core_temp * sensor->slope_mult / sensor->slope_div; core_temp = core_temp + sensor->offset_num / sensor->offset_den; core_temp = core_temp + sensor->offset_constant - 8; @@ -171,7 +166,7 @@ nv40_therm_intr(struct nouveau_subdev *subdev) struct nouveau_therm *therm = nouveau_therm(subdev); uint32_t stat = nv_rd32(therm, 0x1100); - /* traitement */ + /* TODO: do something? Need more RE first */ /* ack all IRQs */ nv_wr32(therm, 0x1100, 0x70000); @@ -202,11 +197,40 @@ nv40_therm_ctor(struct nouveau_object *parent, return nouveau_therm_preinit(&priv->base.base); } +static void +nv40_therm_temp_safety_checks(struct nouveau_therm *therm) +{ + struct nouveau_therm_priv *priv = (void *)therm; + struct nvbios_therm_sensor *sensor = &priv->bios_sensor; + enum nv40_sensor_style style = nv40_sensor_style(therm); + + /* if the slope or the offset is unset, do no use the sensor */ + if (sensor->has_sensor && (!sensor->slope_div || !sensor->slope_mult || + !sensor->offset_num || !sensor->offset_den)) { + + nv_info(therm, "Invalid sensor calibration values. " + "Set default calibration values\n"); + + if (style == NEW_STYLE) { + sensor->slope_div = 10000; + sensor->slope_mult = 450; + sensor->offset_num = -25000; + sensor->offset_den = 100; + } else if (style == OLD_STYLE) { + sensor->slope_div = 1000; + sensor->slope_mult = 792; + sensor->offset_num = 2306; + sensor->offset_den = 100; + } + } +} + static int nv40_therm_init(struct nouveau_object *object) { struct nouveau_therm *therm = (void *)object; + nv40_therm_temp_safety_checks(therm); nv40_sensor_setup(therm); return _nouveau_therm_init(object); diff --git a/drivers/gpu/drm/nouveau/core/subdev/therm/temp.c b/drivers/gpu/drm/nouveau/core/subdev/therm/temp.c index dde746c..053034e 100644 --- a/drivers/gpu/drm/nouveau/core/subdev/therm/temp.c +++ b/drivers/gpu/drm/nouveau/core/subdev/therm/temp.c @@ -49,9 +49,8 @@ nouveau_therm_temp_set_defaults(struct nouveau_therm *therm) priv->bios_sensor.thrs_shutdown.hysteresis = 5; /*not that it matters */ } - static void -nouveau_therm_temp_safety_checks(struct nouveau_therm *therm) +nouveau_therm_sensor_safety_checks(struct nouveau_therm *therm) { struct nouveau_therm_priv *priv = (void *)therm; struct nvbios_therm_sensor *s = &priv->bios_sensor; @@ -239,7 +238,7 @@ nouveau_therm_sensor_ctor(struct nouveau_therm *therm) if (nvbios_therm_sensor_parse(bios, NVBIOS_THERM_DOMAIN_CORE, &priv->bios_sensor)) nv_error(therm, "nvbios_therm_sensor_parse failed\n"); - nouveau_therm_temp_safety_checks(therm); + nouveau_therm_sensor_safety_checks(therm); return 0; } -- 1.8.3.4