From patchwork Mon Feb 2 05:36:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abhilash Kesavan X-Patchwork-Id: 5759311 X-Patchwork-Delegate: rui.zhang@intel.com Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D19B19F380 for ; Mon, 2 Feb 2015 05:36:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 468DC201E4 for ; Mon, 2 Feb 2015 05:36:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C00CE201FB for ; Mon, 2 Feb 2015 05:36:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751458AbbBBFgr (ORCPT ); Mon, 2 Feb 2015 00:36:47 -0500 Received: from mail-qg0-f54.google.com ([209.85.192.54]:42692 "EHLO mail-qg0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751219AbbBBFgq (ORCPT ); Mon, 2 Feb 2015 00:36:46 -0500 Received: by mail-qg0-f54.google.com with SMTP id q108so46108485qgd.13; Sun, 01 Feb 2015 21:36:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=in/HSFdmjGnDQjF0p96oKGWmQdhyDeH0hc0PcDkz4gQ=; b=LV/WjC7wSrfIC4EoG4p2qkC+NpF6B+2Qqnms6Li9y6TKzKfK00iiUEzdt4U9E9J830 Ydu1hcfvxbYobLeW74clqXdkzexuEMC32bCWsWqdDgiGkkidL3OSmTLFirXshSKN4043 6sm77Q2o/IWlreE4wJeJg16MK5YrPUy33UVeR7fTcL1nD6CrLLTbPRJ75hvPbQs0wJ+v 2dBXupQRgJmYkrQiSarl7D2bUdON539iznw58JokMctK6BQttGa1ejdNyHu/2eS1D1B1 5IcC2J8SWXOBtl7JJRghNB1eJHqq4Q58XxDvTdvmjMqxuCMf3KcyUasvJ1jRlRD8+QnO tRVw== MIME-Version: 1.0 X-Received: by 10.224.98.143 with SMTP id q15mr37435027qan.29.1422855405491; Sun, 01 Feb 2015 21:36:45 -0800 (PST) Received: by 10.229.169.197 with HTTP; Sun, 1 Feb 2015 21:36:45 -0800 (PST) In-Reply-To: References: <1421667844-13627-1-git-send-email-l.majewski@samsung.com> <1421667844-13627-2-git-send-email-l.majewski@samsung.com> <20150122100124.65e7a19e@amdc2363> <20150129230616.GJ29837@developer.amazonguestwifi.org> <20150130091422.669930c8@amdc2363> Date: Mon, 2 Feb 2015 11:06:45 +0530 Message-ID: Subject: Re: [PATCH 1/2] thermal: exynos: Reorder exynos_map_dt_data() function From: Abhilash Kesavan To: Lukasz Majewski Cc: Eduardo Valentin , Zhang Rui , Kukjin Kim , Kukjin Kim , Linux PM list , "linux-samsung-soc@vger.kernel.org" , Bartlomiej Zolnierkiewicz , Lukasz Majewski , Amit Daniel Kachhap , Kyungmin Park , Chanwoo Choi Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, 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 Hi Lukasz, On Fri, Jan 30, 2015 at 8:36 PM, Abhilash Kesavan wrote: > Hi Lukasz, > > On Fri, Jan 30, 2015 at 1:44 PM, Lukasz Majewski wrote: >> Hi Eduardo, Abhilash, >> >>> On Thu, Jan 22, 2015 at 06:02:07PM +0530, Abhilash Kesavan wrote: >>> > Hi Lukasz, >>> > >>> > On Thu, Jan 22, 2015 at 2:31 PM, Lukasz Majewski >>> > wrote: >>> > > Hi Abhilash, >>> > > >>> > >> Hi Lukasz, >>> > >> >>> > >> On Mon, Jan 19, 2015 at 5:14 PM, Lukasz Majewski >>> > >> wrote: >>> > >> > The exynos_map_dt_data() function must be called before >>> > >> > thermal_zone_of_sensor_register(), and hence provide tmu_read() >>> > >> > function, before it is needed. >>> > >> > >>> > >> > This change is driven by adding support for enabling >>> > >> > thermal_zoneX when it is properly initialized. >>> > >> > >>> > >> > One can read the mode of operation >>> > >> > at /sys/class/thermal/thermal_zone0/mode Such functionality was >>> > >> > missing in the of-thermal.c code. >>> > >> > >>> > >> > Reported-by: Abhilash Kesavan >>> > >> > Signed-off-by: Lukasz Majewski >>> > >> > --- >>> > >> > drivers/thermal/samsung/exynos_tmu.c | 7 ++++--- >>> > >> > 1 file changed, 4 insertions(+), 3 deletions(-) >>> > >> > >>> > >> > diff --git a/drivers/thermal/samsung/exynos_tmu.c >>> > >> > b/drivers/thermal/samsung/exynos_tmu.c index 9d2d685..5d946ab >>> > >> > 100644 --- a/drivers/thermal/samsung/exynos_tmu.c >>> > >> > +++ b/drivers/thermal/samsung/exynos_tmu.c >>> > >> > @@ -975,15 +975,16 @@ static int exynos_tmu_probe(struct >>> > >> > platform_device *pdev) platform_set_drvdata(pdev, data); >>> > >> > mutex_init(&data->lock); >>> > >> > >>> > >> > + ret = exynos_map_dt_data(pdev); >>> > >> > + if (ret) >>> > >> > + goto err_sensor; >>> > >> > + >>> > >> > data->tzd = >>> > >> > thermal_zone_of_sensor_register(&pdev->dev, 0, data, >>> > >> > &exynos_sensor_ops); if (IS_ERR(data->tzd)) { >>> > >> > pr_err("thermal: tz: %p ERROR\n", data->tzd); >>> > >> > return PTR_ERR(data->tzd); >>> > >> > } >>> > >> > - ret = exynos_map_dt_data(pdev); >>> > >> > - if (ret) >>> > >> > - goto err_sensor; >>> > >> > >>> > >> > pdata = data->pdata; >>> > >> >>> > >> I have been testing this along with your v5 patch set and am >>> > >> seeing incorrect temperature being reported at boot-up on >>> > >> exynos7. >>> > > >>> > > Does it show a maximal temperature value (0x1FF)? >>> > >>> > I did not print the current temperature register, but I remember the >>> > message showing ~105C. Will give you the register value when I test >>> > with more debug prints tomorrow. >>> > >>> > > >>> > >> It looks >>> > >> like exynos_tmu_read gets called from >>> > >> thermal_zone_of_device_update during boot-up, now that we have >>> > >> it populated early. However, as the tmu initialization function >>> > >> has not been called yet it returns a wrong value. Does that >>> > >> sound correct ? >>> > > >>> > > No, this is a mistake. However, I'm wondering why on Exynos4/5 >>> > > this error didn't show up... >>> > >>> > I have been lowering the software trip point temperature in the >>> > exynos7 dts file (to 55C) for testing purposes. Hence, when the >>> > temperature is read incorrectly as ~105C the board trips at boot-up >> >> ^^^^ this is a very unusual >> value - I had problems with >> reading 0xFF values with >> similar symptom (but this was >> caused by lack of vtmu). >> >>> > itself. Maybe for exynos4/5 the incorrect value read during boot-up >>> > is in the non-tripping range and once the tmu is initialized later >>> > it continues to function properly thereafter ? >>> > >>> > > >>> > > The reordering is needed to be able to call set_mode callback at >>> > > of-thermal.c to set the mode. >>> > > >>> > > If this change causes problems, then another solution (probably >>> > > not so neat) must be found. >>> > >>> > Please let me know if you need any further details. >> >> Abhilash, could you provide more details (like relevant output from >> dmesg) and point me a list of patches which shall I apply to test this >> issue on Exynos4/5? > Sorry, I have not had the time to re-check this and provide you with > the current temperature register value. I will definitely do so on > Monday and also provide you the dmesg output. I applied the following > patches on linux-next: > > bbf872d thermal: exynos: Add TMU support for Exynos7 SoC > b8190ac dts: Documentation: Add documentation for Exynos7 SoC thermal bindings > 9330ec1 thermal: exynos: Reorder exynos_map_dt_data() function > 4dd41c4 thermal: exynos: dts: Provide device tree bindings identical > to the one in exynos_tmu_data.c > a7b80b9 thermal: dts: exynos: Trip points and sensor configuration > data for Exynos5440 > 77d072e thermal: exynos: dts: Define default thermal-zones for Exynos4 > 964dd36 thermal: dts: Default trip points definition for Exynos5420 SoCs > c1d2f97 thermal: exynos: dts: Add default definition of the TMU sensor parameter > 02a4496 arm: dts: Adding CPU cooling binding for Exynos SoCs > bfadff0 arm: dts: odroid: Enable TMU at Exynos4412 based Odroid U3 device > 862764c arm: dts: odroid: Add LDO10 regulator node necessary for TMU on Odroid > c064731 arm: dts: trats: Enable TMU on the Exynos4210 trats device > > Along with the above list I have a patch which adds the dt changes > required for exynos7 on similar lines as done for exynos4/exynos5. In > the exyno7 trip point dts file I have modified the cpu-crit-0 > temperature to a low value of 55C for testing purposes. > >> >>> >>> What is the status of this patch? Is it still required? >> >> It is strange, since on Exynos4/5 this works and some problems show up >> when run on Exynos7. > > I would have expected the issue to show up on Exynos4/5 too. I will > test this on the 5420 based board I have on Monday. I tested this on a 5420 based chromebook that I have (Peach Pit) and observed similar results as that on Exynos7. Following are the patches applied on next-20150130: 5b1194d thermal: exynos: Reorder exynos_map_dt_data() function 30c6165 thermal: exynos: dts: Provide device tree bindings identical to the one in exynos_tmu_data.c d94c248 thermal: dts: exynos: Trip points and sensor configuration data for Exynos5440 aac8b3a thermal: exynos: dts: Define default thermal-zones for Exynos4 5e8cf52 thermal: dts: Default trip points definition for Exynos5420 SoCs 17ec9c2 thermal: exynos: dts: Add default definition of the TMU sensor parameter 36e247b arm: dts: Adding CPU cooling binding for Exynos SoCs 7aa1bb1 arm: dts: odroid: Enable TMU at Exynos4412 based Odroid U3 device 8884a76 arm: dts: odroid: Add LDO10 regulator node necessary for TMU on Odroid aae2e51 arm: dts: trats: Enable TMU on the Exynos4210 trats device 827e3bd Add linux-next specific files for 20150130 On top of these patches, I have the following diff for debugging/testing pruposes: Also, I noticed a typo (an extra zero) in cpu-crit-0 temperature above. Following is the relevant boot-up log: [ 3.160126] TPS65090_RAILSLDO2: supplied by vbat-supply [ 3.343421] thermal thermal_zone5: last_temperature=0, current_temperature=25900 [ 3.349365] sbs-battery 20-000b: sbs-battery: battery gas gauge device registered [ 3.374280] 10060000.tmu supply vtmu not found, using dummy regulator [ 3.379408] [ 3.379408] exynos4412_tmu_read: Reading the current temperature register value: 0x36 [ 3.379408] [ 3.390026] temp_code is 54, err1 is 0, trim is 25, temp is 79 [ 3.395827] temperature is 79000 [ 3.399053] thermal thermal_zone0: last_temperature=0, current_temperature=79000 [ 3.406429] thermal thermal_zone0: critical temperature reached(79 C),shutting down [ 3.414241] reboot: Failed to start orderly shutdown: forcing the issue [ 3.420690] usb 5-1: new high-speed USB device number 2 using exynos-ehci [ 3.427819] 10064000.tmu supply vtmu not found, using dummy regulator [ 3.434011] Emergency Sync complete [ 3.434355] [ 3.434355] exynos4412_tmu_read: Reading the current temperature register value: 0x3 [ 3.434355] [ 3.434367] temp_code is 3, err1 is 0, trim is 25, temp is 28 [ 3.434373] temperature is 28000 [ 3.434393] thermal thermal_zone1: last_temperature=0, current_temperature=28000 [ 3.434744] 10068000.tmu supply vtmu not found, using dummy regulator [ 3.435069] [ 3.435069] exynos4412_tmu_read: Reading the current temperature register value: 0x2 [ 3.435069] [ 3.435080] temp_code is 2, err1 is 0, trim is 25, temp is 27 [ 3.435086] temperature is 27000 [ 3.435103] thermal thermal_zone2: last_temperature=0, current_temperature=27000 [ 3.435427] 1006c000.tmu supply vtmu not found, using dummy regulator [ 3.435762] [ 3.435762] exynos4412_tmu_read: Reading the current temperature register value: 0x2 [ 3.435762] [ 3.435772] temp_code is 2, err1 is 0, trim is 25, temp is 27 [ 3.435778] temperature is 27000 [ 3.435794] thermal thermal_zone3: last_temperature=0, current_temperature=27000 [ 3.436112] 100a0000.tmu supply vtmu not found, using dummy regulator [ 3.436464] [ 3.436464] exynos4412_tmu_read: Reading the current temperature register value: 0x33 [ 3.436464] [ 3.436475] temp_code is 51, err1 is 0, trim is 25, temp is 76 [ 3.436480] temperature is 76000 [ 3.436496] thermal thermal_zone4: last_temperature=0, current_temperature=76000 [ 3.436527] thermal thermal_zone4: critical temperature reached(76 C),shutting down From the log, thermal_zone0 and thermal_zone4 show incorrect temperatures. It looks like the first point trim error1 would need to be intialized before we do a read ? Please let me know if you need any more details. Regards, Abhilash --- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/arm/boot/dts/exynos5420-trip-points.dtsi b/arch/arm/boot/dts/exynos5420-trip-points.dtsi index 09d6c56..ac8b6a0 100644 --- a/arch/arm/boot/dts/exynos5420-trip-points.dtsi +++ b/arch/arm/boot/dts/exynos5420-trip-points.dtsi @@ -13,22 +13,22 @@ polling-delay-passive = <0>; polling-delay = <0>; trips { cpu-alert-0 { - temperature = <85000>; /* millicelsius */ + temperature = <55000>; /* millicelsius */ hysteresis = <10000>; /* millicelsius */ type = "active"; }; cpu-alert-1 { - temperature = <103000>; /* millicelsius */ + temperature = <63000>; /* millicelsius */ hysteresis = <10000>; /* millicelsius */ type = "active"; }; cpu-alert-2 { - temperature = <110000>; /* millicelsius */ + temperature = <70000>; /* millicelsius */ hysteresis = <10000>; /* millicelsius */ type = "active"; }; cpu-crit-0 { - temperature = <1200000>; /* millicelsius */ + temperature = <75000>; /* millicelsius */ hysteresis = <0>; /* millicelsius */ type = "critical"; }; diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index 852e622..7281581 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -237,6 +237,7 @@ static int code_to_temp(struct exynos_tmu_data *data, u8 temp_code) break; case TYPE_ONE_POINT_TRIMMING: temp = temp_code - data->temp_error1 + pdata->first_point_trim; + printk("temp_code is %d, err1 is %d, trim is %d, temp is %d\n", temp_code, data->temp_error1, pdata->first_point_trim, temp); break; default: temp = temp_code - pdata->default_temp_offset; @@ -585,6 +586,7 @@ static int exynos_get_temp(void *p, long *temp) *temp = code_to_temp(data, data->tmu_read(data)) * MCELSIUS; + printk("temperature is %ld\n", *temp); clk_disable(data->clk); mutex_unlock(&data->lock); @@ -675,6 +677,7 @@ static int exynos4210_tmu_read(struct exynos_tmu_data *data) static int exynos4412_tmu_read(struct exynos_tmu_data *data) { + printk("\n%s: Reading the current temperature register value: 0x%x\n\n", __func__, readb(data->base + EXYNOS_TMU_REG_CURRENT_TEMP)); return readb(data->base + EXYNOS_TMU_REG_CURRENT_TEMP); } diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 48491d1..981fc99 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -469,7 +469,7 @@ static void update_temperature(struct thermal_zone_device *tz) mutex_unlock(&tz->lock); trace_thermal_temperature(tz); - dev_dbg(&tz->device, "last_temperature=%d, current_temperature=%d\n", + dev_err(&tz->device, "last_temperature=%d, current_temperature=%d\n", tz->last_temperature, tz->temperature); }