Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp776355imu; Mon, 5 Nov 2018 08:36:58 -0800 (PST) X-Google-Smtp-Source: AJdET5fPiDFe5IG3jKMlCsEG2QX35Lq7P1ZwiNq6eNGe3tFkg4vCAURF+Ac88XLEFPduBxaXv8Fy X-Received: by 2002:a17:902:a9:: with SMTP id a38-v6mr11259536pla.7.1541435818047; Mon, 05 Nov 2018 08:36:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541435818; cv=none; d=google.com; s=arc-20160816; b=b7L7ODr4D7XH37MK9c4fEz4MzQWptHZFc3AvOgOBLTLfkL9FsEiTigWO5ba7yK8JBt edlLdrUrCJU3u6DHVWIJ+he3FwtqpIYhXisjw29fifnbDPFU4Dz2mYTA9R7jjSVd/Myx a9JqX+5Nw3F46mpydmcsUzE+Z0N5un+R2yw6Ej16P7PVbMEbD0R21tJMrIQnzLAg9O37 tAWgXwl6oIGNpj+MNVD6RfjTSe+06R/46cjMFMrEqKMwNPCjbmEJWtHrx+0sA7bmKh/c Y1riT+cbv4NenE3ZWK0vvVCuX5aFn40L7E/C04qcS/muTgrcUIusRFmfP1mgHFHJ+ZW8 seBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:cc:to:subject:dkim-signature:dkim-filter; bh=H0/PBL2NbtjRtladzOXaXnMEvJHQ3q7TKIWl3omDj70=; b=L7zfwiOvjIbNgJmSrCGd6M7IThkiz8X0gUGgMPAxO99wEsJAbSHEuKDlUcVotjxRrf oTr7zxh49461lrU0vvmTAxu1ztf1hdvCvJ5BoKfRCTfy+9XzcBwS0EpnfqmbDnuTKpA4 7ZJAWSJmlQw9D/oSu9cxSPqO42AgZH5nXwP05g2AqvTZVjs/vwn6kH2ms/1lH6ZUE6/l 8jdNGyIoSstdxREibwJtXYomRQxkf5xenALh3vM37kMuuu2qs0xgyhGeMsNZ4dzOnaMT XPX4SwnpN3nEs2G36q0nBGpbp2VXNHOzle5hA3EoJ4NhoLGBggXwctP8SLTtqUMgaStH k5fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=gnqOttu6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u23si8114638pgb.66.2018.11.05.08.36.40; Mon, 05 Nov 2018 08:36:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=gnqOttu6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387491AbeKFB4b (ORCPT + 99 others); Mon, 5 Nov 2018 20:56:31 -0500 Received: from mailout2.w1.samsung.com ([210.118.77.12]:34194 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387420AbeKFB4b (ORCPT ); Mon, 5 Nov 2018 20:56:31 -0500 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20181105163600euoutp02338f9e198eb98294ca0f0a6e7567e70a~kR6gppdiO0762707627euoutp02C for ; Mon, 5 Nov 2018 16:36:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20181105163600euoutp02338f9e198eb98294ca0f0a6e7567e70a~kR6gppdiO0762707627euoutp02C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1541435760; bh=H0/PBL2NbtjRtladzOXaXnMEvJHQ3q7TKIWl3omDj70=; h=Subject:To:Cc:From:Date:In-Reply-To:References:From; b=gnqOttu6iviqbJYCm/Sn5OYfQVy1394jf8foktKFhljtVquiugYc+grs8xbQ7c+vF ZCOhhTgP/3efptfEaVm8YQs+OXWbvs72G2n0xmHtqKJIdtZS4q8UhD5oWXmL31FCG5 iuSDC3WstwpL32S5CfBj5H+O9vzXjFVmcxQsPtZA= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20181105163558eucas1p216334856de567ec5f6324f8a9f67b1e6~kR6foTCef2469224692eucas1p2-; Mon, 5 Nov 2018 16:35:58 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id E2.30.04441.E6170EB5; Mon, 5 Nov 2018 16:35:58 +0000 (GMT) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20181105163557eucas1p160168ea4ccd52bd8cea53fb843ff06e7~kR6eqjkTH2968229682eucas1p1e; Mon, 5 Nov 2018 16:35:57 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20181105163557eusmtrp12d5662bdd88910a1a8a50d853eb99493~kR6eZUnFp2213022130eusmtrp1b; Mon, 5 Nov 2018 16:35:57 +0000 (GMT) X-AuditID: cbfec7f2-5e3ff70000001159-8b-5be0716e377b Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 6D.DE.04128.D6170EB5; Mon, 5 Nov 2018 16:35:57 +0000 (GMT) Received: from [106.120.53.102] (unknown [106.120.53.102]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20181105163556eusmtip19ec32e31c84c52c72bdba74d5afe498f~kR6drg-960720907209eusmtip1N; Mon, 5 Nov 2018 16:35:56 +0000 (GMT) Subject: Re: [PATCH v2 00/17] thermal: enable+check sensor after its setup is finished To: Zhang Rui Cc: Eduardo Valentin , Amit kucheria , Eric Anholt , Stefan Wahren , Markus Mayer , bcm-kernel-feedback-list@broadcom.com, Heiko Stuebner , Thierry Reding , Jonathan Hunter , Keerthy , Masahiro Yamada , Jun Nie , Baoyou Xie , Shawn Guo , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org From: Bartlomiej Zolnierkiewicz Message-ID: Date: Mon, 5 Nov 2018 17:35:55 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: <1541387097.2124.9.camel@intel.com> Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA01Sa1BMYRj27Tl79mwcvl2ZXvdpNUxmSAbzuUwYzTgzxmXMNC4xWnVmNWrL HrmOEdVilYSx2lzLKpES6SKjiW27ukWzg2zSCCHZXGoM2s42/Hve93me733edz6WUn+Rj2Ij 9VsFg14bpWG86FtVPQ+n6Le0hE67ccePJMRnychblx2RvBQbTc49bZKTin2NiPxp7ZCT2uL9 MpJoyaTJxbbXCtJYdpohrpT7iJz+/EJB2l4fYci7mz6kMMfBkJ6yszS588qFFqj4/Z1VDG9x NjB8qaVZwRc9n8lnlb+X8YW5hxj+ZVM5w6ckfGb44qazFF9t/kHzdkexjHcVjlsxZK3XvAgh KnKbYAgICvPaVJcdEJs5f8dv4wEmHl0OMCElC3gGGMu+KEzIi1XjHATltl5GKroRPLtw3cO4 ENSkOWQDFseF2x5VNoKSU7/6CTXuRNBmCXLj4Xg15Oc8kbuxN54AmQ+KkNtA4UYaehPMtJtg 8BxIO5CL3JjDQeBMze430NgP3iQ/6uuz7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ChhITJm9FKyGWUBd4s+8S8wQtrxE89bZzBMY BWchaZmFpGwWkrIFjMyrGEVSS4tz03OLjfSKE3OLS/PS9ZLzczcxAmN927GfW3Ywdr0LPsQo wMGoxMPLUfAgWog1say4MvcQowQHs5IIrxIbUIg3JbGyKrUoP76oNCe1+BCjKdATE5mlRJPz gWkoryTe0NTQ3MLS0NzY3NjMQkmc97xBZZSQQHpiSWp2ampBahFMHxMHp1QDo8jMFWoP2c7m h80SiGzdobhiY2jA38N7Io0tNBlmPvfl/eylLHRYJ3kGH5Mw50ROV/6z/44GnxcPKXxT9oGj 5Ve0sMBR5vqFJdMmXj0UXtTMW3hlg7SIyvFLqp5n1kzdIissq/L0YNd0devcJIObkv6cQlVa 1S65k0UnM889WR/9rHMzU22fEktxRqKhFnNRcSIATOA/nwsDAAA= X-CMS-MailID: 20181105163557eucas1p160168ea4ccd52bd8cea53fb843ff06e7 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20181017155314epcas2p4a5aa24978b36354a2ccb2f9b0fb6f0f6 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20181017155314epcas2p4a5aa24978b36354a2ccb2f9b0fb6f0f6 References: <1539791563-5959-1-git-send-email-b.zolnierkie@samsung.com> <1541387097.2124.9.camel@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/05/2018 04:04 AM, Zhang Rui wrote: > Hi, Bartlomiej, Hi Rui, > Interesting, I'm about to bring this issue to Linux Plumber Conference > this year for discussion, and I'm also proposing a solution to fix the > issues, but only with thermal core part finished yet. > can you please take a look at it? > https://patchwork.kernel.org/project/linux-pm/list/?series=38181 Thank you for the patches but they seem to be far from being a complete solution for issues fixed by my patchset. Even thermal core part is not finished yet as it doesn't provide a way to register disabled sensors for DT thermal drivers (only for platform ones).. Why not simply apply my patchset now and incrementally work on top of it to implement fixes for issues your patchset is addressing? My patchset may not be a perfect solution but IMO it is good enough and it has been practically ready since v1 posted in April (v2 fixes all issues requested by Eduardo's review from September).. > thanks, > rui > > On δΈ‰, 2018-10-17 at 17:52 +0200, Bartlomiej Zolnierkiewicz wrote: >> Hi, >> >> [devm]_thermal_zone_of_sensor_register() is used to register >> thermal sensor by thermal drivers using DeviceTree. Besides >> registering sensor this function also immediately: >> >> - enables it: >> >> tzd->ops->set_mode(tzd, THERMAL_DEVICE_ENABLED) >> (->set_mode is set to of_thermal_set_mode() in of-thermal.c) >> >> - checks it (indirectly by using of_thermal_set_mode()): >> >> thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED); >> (which in turn ends up using ->get_temp method). >> >> For many DT thermal drivers this causes a problem because: >> >> - [devm]_thermal_zone_of_sensor_register() need to be called in >> order to obtain data about thermal trips which are then used to >> finish hardware sensor setup (only after which ->get_temp can >> be used) >> >> There is also related issue for DT thermal drivers that support >> IRQ (i.e. exynos and rockchip ones): >> >> - sensor hardware should be enabled only after IRQ handler is >> requested (because otherwise we might get IRQs that we can't >> handle) >> >> - IRQ handler needs tzd structure which is obtained from >> [devm_]thermal_zone_of_sensor_register() >> >> - after [devm_]thermal_zone_of_sensor_register() call core >> thermal code assumes that sensor is enabled and ready to use >> (i.e. that IRQ handler has been requested and sensor hardware >> has been enabled) >> >> In order to fix all abovementioned issues sensor registration, >> enable and check operations are separated in the core DT thermal >> code and corresponding DT thermal drivers are modified to do sensor >> setup correctly. >> >> Changes since v1: >> - rebased on the current -next kernel (next-20181015) >> - enhanced patch descriptions and cover letter >> - renamed thermal_zone_device_toggler() to thermal_zone_set_mode() >> - converted thermal_zone_set_mode() to use enum thermal_device_mode >> - added CONFIG_THERMAL=n stubs for thermal_zone_set_mode() and >> thermal_zone_device_check() >> - fixed uses of [devm]_thermal_zone_of_sensor_register() outside of >> drivers/thermal/ >> - changed ordering between patch #2 and #3 in order to add all >> needed core helpers first before fixing sensor setup code >> - changed ordering between patch #3 and #4 in order to simplify them >> - renamed patch #3 to "thermal: separate sensor enable and check >> operations" >> - renamed patch #4 to "thermal: separate sensor registration and >> enable+check operations" >> >> Best regards, >> -- >> Bartlomiej Zolnierkiewicz >> Samsung R&D Institute Poland >> Samsung Electronics >> >> >> Bartlomiej Zolnierkiewicz (17): >> thermal: add thermal_zone_set_mode() helper >> thermal: add thermal_zone_device_check() helper >> thermal: separate sensor enable and check operations >> thermal: separate sensor registration and enable+check operations >> thermal: bcm2835: enable+check sensor after its setup is finished >> thermal: brcmstb: enable+check sensor after its setup is finished >> thermal: hisi_thermal: enable+check sensor after its setup is >> finished >> thermal: qcom: tsens: enable+check sensor after its setup is >> finished >> thermal: qoriq: enable+check sensor after its setup is finished >> thermal: rcar_gen3_thermal: enable+check sensor after its setup is >> finished >> thermal: rockchip_thermal: enable+check sensor after its setup is >> finished >> thermal: exynos: enable+check sensor after its setup is finished >> thermal: tegra: enable+check sensor after its setup is finished >> thermal: ti-soc-thermal: enable+check sensor after its setup is >> finished >> thermal: uniphier: enable+check sensor after its setup is finished >> thermal: zx2967: enable+check sensor after its setup is finished >> thermal: warn on attempts to read temperature on disabled sensors >> >> drivers/acpi/thermal.c | 5 +-- >> drivers/ata/ahci_imx.c | 10 ++++-- >> drivers/hwmon/hwmon.c | 5 +++ >> drivers/hwmon/ntc_thermistor.c | 4 +++ >> drivers/hwmon/scpi-hwmon.c | 4 +++ >> drivers/iio/adc/sun4i-gpadc-iio.c | 5 +++ >> drivers/input/touchscreen/sun4i-ts.c | 8 ++++- >> drivers/net/ethernet/mellanox/mlxsw/core_thermal.c | 1 - >> drivers/platform/x86/acerhdf.c | 6 +++- >> drivers/regulator/max8973-regulator.c | 6 ++-- >> drivers/thermal/armada_thermal.c | 3 ++ >> drivers/thermal/broadcom/bcm2835_thermal.c | 3 ++ >> drivers/thermal/broadcom/brcmstb_thermal.c | 3 ++ >> drivers/thermal/broadcom/ns-thermal.c | 3 ++ >> drivers/thermal/da9062-thermal.c | 7 ++-- >> drivers/thermal/db8500_thermal.c | 5 ++- >> drivers/thermal/hisi_thermal.c | 22 ++++------ >> --- >> drivers/thermal/imx_thermal.c | 3 +- >> drivers/thermal/int340x_thermal/int3400_thermal.c | 1 + >> drivers/thermal/intel_bxt_pmic_thermal.c | 3 +- >> drivers/thermal/intel_soc_dts_iosf.c | 3 +- >> drivers/thermal/max77620_thermal.c | 6 ++-- >> drivers/thermal/mtk_thermal.c | 3 ++ >> drivers/thermal/of-thermal.c | 6 ++-- >> drivers/thermal/qcom-spmi-temp-alarm.c | 5 ++- >> drivers/thermal/qcom/tsens.c | 6 ++++ >> drivers/thermal/qoriq_thermal.c | 3 ++ >> drivers/thermal/rcar_gen3_thermal.c | 7 ++-- >> drivers/thermal/rcar_thermal.c | 7 ++-- >> drivers/thermal/rockchip_thermal.c | 38 +++++++++++- >> ---------- >> drivers/thermal/samsung/exynos_tmu.c | 7 +++- >> drivers/thermal/st/st_thermal_memmap.c | 3 +- >> drivers/thermal/tango_thermal.c | 5 +++ >> drivers/thermal/tegra/soctherm.c | 3 ++ >> drivers/thermal/tegra/tegra-bpmp-thermal.c | 3 ++ >> drivers/thermal/thermal-generic-adc.c | 3 ++ >> drivers/thermal/thermal_core.c | 14 ++++---- >> drivers/thermal/thermal_helpers.c | 32 >> ++++++++++++++++++ >> drivers/thermal/thermal_sysfs.c | 17 ++++++---- >> drivers/thermal/ti-soc-thermal/ti-thermal-common.c | 7 +++- >> drivers/thermal/uniphier_thermal.c | 6 +++- >> drivers/thermal/x86_pkg_temp_thermal.c | 2 +- >> drivers/thermal/zx2967_thermal.c | 3 ++ >> include/linux/thermal.h | 11 +++++++ >> 44 files changed, 220 insertions(+), 87 deletions(-) Best regards, -- Bartlomiej Zolnierkiewicz Samsung R&D Institute Poland Samsung Electronics