From patchwork Mon May 10 22:38:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 433245 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3A01BC43461 for ; Mon, 10 May 2021 22:40:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1A6E56157F for ; Mon, 10 May 2021 22:40:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231402AbhEJWlz (ORCPT ); Mon, 10 May 2021 18:41:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230329AbhEJWly (ORCPT ); Mon, 10 May 2021 18:41:54 -0400 Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C93CC061760; Mon, 10 May 2021 15:40:46 -0700 (PDT) Received: by mail-lj1-x22e.google.com with SMTP id c15so8232179ljr.7; Mon, 10 May 2021 15:40:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=XcXraiNoRPU0G8oGIVhPyNHE4YAr90zRs8GgZNjViE0=; b=gYh5LkV7XvUW4kbi1nokWJ6vRz+twU2SdWZGo7mE/xltMSxuIknFbhivLHS43Ng9N3 0EYG8iP5vnoTAwvsxfrAX6uL0VI7LEyBnNzJR9qTvg41R1bDundCitToynH0TKrXHvHt 6jQTIaXvWkblUArZwZvNjrMqG+vV11Sw7a/CzNcbyT1aQpq4tOKSCPIniXoCLb7eLzle IAI4m/HpyqQc+Y4nk5/vRJhrFr1eTndlcXkYruGtMWZjDyp4dgYOvyjz06OkZr7JOoNt cx2CEvsVikicbkWKXlNILH+J76bPgRh6/GU4v97HDJCOr7lAP4YiEg4YiQDcyZuqLmYN 5x3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XcXraiNoRPU0G8oGIVhPyNHE4YAr90zRs8GgZNjViE0=; b=gswozKegZQpgzL7VshyuNkvQvRI2Au4+4DKLGACHCk78urYjC+rUpIl5Y0jvr9VqpC X9s9IGBPdhFguqC/6auZTlEoNwVZEYPZ2izKkTY32DjHzIhJoavPl84mmvKKg8NMvEUh Xk8X5uY2m7q54oBmp8JJ1y2ojGXlS9JytSNruPb9dXEELrIHiKAST7G5kVlPCWCiuJ8+ l5eHl6Fq1ecOlSD5/d0au47GmkIE4WPZ5XsxRIXNpClliO4VLX5ESbdb6LbRCwYBeEMR wtqo9d044Nu7cs3cJOMy804rFpicBpvCrfbng75bKvmA0wTaunSPQnPK3/r4YkyvuD8z FXlg== X-Gm-Message-State: AOAM531uIkI5U3pUqj7XwgAfjkzDjLgHGdommpC4CyOECnuYN7EWee4O L8R1dkOuUmdf1uywlYBdBHM= X-Google-Smtp-Source: ABdhPJxMRnQ08rEufSrDdsfnq9h0+gYydbKITigZsxcpueb+BNjPzIPY0PgMk2gX53MXWhCZHWisQg== X-Received: by 2002:a2e:a308:: with SMTP id l8mr21664173lje.235.1620686444867; Mon, 10 May 2021 15:40:44 -0700 (PDT) Received: from localhost.localdomain (109-252-193-91.dynamic.spd-mgts.ru. [109.252.193.91]) by smtp.gmail.com with ESMTPSA id g24sm2780698lja.63.2021.05.10.15.40.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 May 2021 15:40:44 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Zhang Rui , Daniel Lezcano , Amit Kucheria , Rob Herring , Andreas Westman Dorcsak , Maxim Schwalm , Svyatoslav Ryhel , Ihor Didenko , Ion Agorria , Matt Merhar , Peter Geis Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org Subject: [PATCH v1 2/7] thermal: thermal_of: Stop zone device before unregistering it Date: Tue, 11 May 2021 01:38:11 +0300 Message-Id: <20210510223816.18565-3-digetx@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210510223816.18565-1-digetx@gmail.com> References: <20210510223816.18565-1-digetx@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Zone device is enabled after thermal_zone_of_sensor_register() completion, but it's not disabled before senors if unregistered, leaving temperature polling active. This results in accessing a disabled zone device and produces a warning about this problem. Stop zone device before unregistering it in order to fix this "use-after-free" problem. Signed-off-by: Dmitry Osipenko --- drivers/thermal/thermal_of.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index 5b76f9a1280d..6379f26a335f 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -559,6 +559,9 @@ void thermal_zone_of_sensor_unregister(struct device *dev, if (!tz) return; + /* stop temperature polling */ + thermal_zone_device_disable(tzd); + mutex_lock(&tzd->lock); tzd->ops->get_temp = NULL; tzd->ops->get_trend = NULL; From patchwork Mon May 10 22:38:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 433244 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 594BFC43616 for ; Mon, 10 May 2021 22:40:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 354FA61585 for ; Mon, 10 May 2021 22:40:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231486AbhEJWl5 (ORCPT ); Mon, 10 May 2021 18:41:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231376AbhEJWly (ORCPT ); Mon, 10 May 2021 18:41:54 -0400 Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A025C061761; Mon, 10 May 2021 15:40:47 -0700 (PDT) Received: by mail-lj1-x22a.google.com with SMTP id y9so22762641ljn.6; Mon, 10 May 2021 15:40:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AqIoL8w6UW8nZZQW4Ci4myc0ad3mcz0KynC5WY0Sz8A=; b=r48gG7FTNk7nvy6c3GhS4mQRFMjpPOaxlsPn3iyHCwsrM23ZPwYyuub+aYQRMg7NTQ /ZfizXIgvSnbAlTCgpMQWOaIJAjJBAgFH5InHz7lyyICJ94qsywnbLinZ6zFz4yWK9vc piVyDQHIydAQD6ucoNZMjmxPcOuDLIH+uCjeMR3zvpv+K45+jHhqb9ie3A5ck8bBZDBO D+aLZUed9CGLaUomAwbedYJFBePrwylBaewSbqN4QuakSkwTHvSRn1P5bL+hosE30ore rwKUhaZzBaJIJBhAdZUQmI3+O4Plq4DsKyai+WOKOFXtAWnlCP+FNyqfmEMS8tj/urF3 MLuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AqIoL8w6UW8nZZQW4Ci4myc0ad3mcz0KynC5WY0Sz8A=; b=gFqPxPaSFeFsa2PkhVBNAIWV4lBxVmW7B/kZ1Ko86aMhPDWv6uAhm+lsQsr+EMHpiM gdAnZdrJ5Bg2JVPV07Z5a/owJlYi08l1nHpV4vQipVgSrsNGXgQlhi9xQv9hJTYkggZd rFDbkbz69oz9JXwQ1/KH5q4NOvDvFwz0QwqMu8HQ+VSKqbipibd8GyzrhcwbD/C6kbtJ q7s+UbS68xA90lYfjbKpA/Og5zEWNfoMdcaskTbE+KXFhQ4EXnHQEDnRRbif92aqrCjw wCdO5E/q9z5WTDVkaJ37tEtJlFA09b5eShKYOIMUdYsoTkCK8NyNvk+W1u0ywaCfIDED 3LJw== X-Gm-Message-State: AOAM532ZptKaSEjG4bARJIvr03c2MKsxx8ZRXEmPtHyWKw7xASTbHV7g vsSgTB8SU3OGCJo+qh/zSK4= X-Google-Smtp-Source: ABdhPJzG8yrER2PU/3DrolB04ZZRRywNSpSErJVJnBgK9UoZ9dRINoVP4bt8DhnMH9ZVXjNER865iQ== X-Received: by 2002:a05:651c:205e:: with SMTP id t30mr15444805ljo.388.1620686445660; Mon, 10 May 2021 15:40:45 -0700 (PDT) Received: from localhost.localdomain (109-252-193-91.dynamic.spd-mgts.ru. [109.252.193.91]) by smtp.gmail.com with ESMTPSA id g24sm2780698lja.63.2021.05.10.15.40.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 May 2021 15:40:45 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Zhang Rui , Daniel Lezcano , Amit Kucheria , Rob Herring , Andreas Westman Dorcsak , Maxim Schwalm , Svyatoslav Ryhel , Ihor Didenko , Ion Agorria , Matt Merhar , Peter Geis Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org Subject: [PATCH v1 3/7] thermal/core: Export thermal_cooling_device_stats_update() Date: Tue, 11 May 2021 01:38:12 +0300 Message-Id: <20210510223816.18565-4-digetx@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210510223816.18565-1-digetx@gmail.com> References: <20210510223816.18565-1-digetx@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org NVIDIA Tegra30 thermal sensor driver has a hardware-controlled CPU cooling feature that halves CPU frequency once a specified trip point is breached. In order to account the hardware state transitions, which are reported by interrupt, the sensor driver needs to report the cooling state transition and this is done by thermal_cooling_device_stats_update(). The sensor driver could be compiled as a loadable driver module, but this API function isn't exported, hence export it. Signed-off-by: Dmitry Osipenko --- drivers/thermal/thermal_sysfs.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.c index 1c4aac8464a7..ab373280f853 100644 --- a/drivers/thermal/thermal_sysfs.c +++ b/drivers/thermal/thermal_sysfs.c @@ -690,6 +690,7 @@ void thermal_cooling_device_stats_update(struct thermal_cooling_device *cdev, unlock: spin_unlock(&stats->lock); } +EXPORT_SYMBOL_GPL(thermal_cooling_device_stats_update); static ssize_t total_trans_show(struct device *dev, struct device_attribute *attr, char *buf) From patchwork Mon May 10 22:38:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 433242 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 73EA7C43460 for ; Mon, 10 May 2021 22:40:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 487D26143B for ; Mon, 10 May 2021 22:40:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231514AbhEJWl5 (ORCPT ); Mon, 10 May 2021 18:41:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231422AbhEJWlz (ORCPT ); Mon, 10 May 2021 18:41:55 -0400 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E30DDC0613ED; Mon, 10 May 2021 15:40:48 -0700 (PDT) Received: by mail-lf1-x134.google.com with SMTP id x19so25775294lfa.2; Mon, 10 May 2021 15:40:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RXKVqH0Gu1PT1WV5SwHA4/xjxYRDYxbiWQf6ubIWKHM=; b=RhpXB8nQiQOFQ4QC2dEKwCVNXiMkG++cX9ObPSa7BqR3qtDa2obxzBvzWihWn8Qnhj kUr2Nl+3V7XPUMhyQM9h0PyD+XkJUxubQsZ++4sw291mxdk/C8KIji7cJY4BoUw8A6LX 1ezABq8RAJqUMXfheG5u7JKvauWFZiqDWa0PFLg1zZejlyZiGCco00PaQ56HjZEaEHuB RgbqhBmQ361M9ufseuAi7FzmwS+AxJLTyYhXMe9RwxYqy2/8o1lh93+eqAFV4Nx733Er 8EVizSk48f2vEj5bzUbyWDDQXEFUisy77Lf0m9yTKl7Io2DMxvLsiz0u7/2XVykYYMxu Zp/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RXKVqH0Gu1PT1WV5SwHA4/xjxYRDYxbiWQf6ubIWKHM=; b=ghxHaFigGFsa002Jgmr4fbGVWIYJLRgAF6H6naXvy9aa1WHGqSAeVvwAK8cWqgAVFm dd1t1sXqTkclnLL+33aTlFz5f45EDdMmAgd2GGm7cKqeI9aWgRlE0+W6fQaCgRDWDN0J XhglcDukI6vElhUk5iyl+xpLk7FIsWeSTefeQtlX01A8fRJN5tesQ79BY+vHZwVANqRf VnivR8KSHdxqELsU7jQPHr2ijhOvxhL4HQmy4IRk0JULyUom0aL3dD7SCA2ExREirnfI +FdicXa+0ZlVzDUB5fcbgW5SfAn8p6TXbL8+LSPuGjie/XaAem8TyLIrPQd36sJ/fqVC i06g== X-Gm-Message-State: AOAM530h+AM7SOOjPY3zmAIUZK0UzZOWC9aScin3kFxa+oF1IR/AElQP I1HoClsv3NB3e50ff5sYY/0= X-Google-Smtp-Source: ABdhPJw4+KNAdGIoq2cCUN+UMGmsEz5RMz1h818IpW1Te5EHVzfhGx9Stm0xsPpuq/G0PiH/r24ZUg== X-Received: by 2002:ac2:4d0d:: with SMTP id r13mr18102156lfi.42.1620686447304; Mon, 10 May 2021 15:40:47 -0700 (PDT) Received: from localhost.localdomain (109-252-193-91.dynamic.spd-mgts.ru. [109.252.193.91]) by smtp.gmail.com with ESMTPSA id g24sm2780698lja.63.2021.05.10.15.40.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 May 2021 15:40:47 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Zhang Rui , Daniel Lezcano , Amit Kucheria , Rob Herring , Andreas Westman Dorcsak , Maxim Schwalm , Svyatoslav Ryhel , Ihor Didenko , Ion Agorria , Matt Merhar , Peter Geis Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org Subject: [PATCH v1 5/7] ARM: tegra_defconfig: Enable CONFIG_TEGRA30_TSENSOR Date: Tue, 11 May 2021 01:38:14 +0300 Message-Id: <20210510223816.18565-6-digetx@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210510223816.18565-1-digetx@gmail.com> References: <20210510223816.18565-1-digetx@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Enable NVIDIA Tegra30 SoC thermal sensor driver in tegra_defconfig. Signed-off-by: Dmitry Osipenko --- arch/arm/configs/tegra_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/configs/tegra_defconfig b/arch/arm/configs/tegra_defconfig index 458b9280224d..581fcea671f8 100644 --- a/arch/arm/configs/tegra_defconfig +++ b/arch/arm/configs/tegra_defconfig @@ -171,6 +171,7 @@ CONFIG_THERMAL_STATISTICS=y CONFIG_CPU_THERMAL=y CONFIG_DEVFREQ_THERMAL=y CONFIG_TEGRA_SOCTHERM=m +CONFIG_TEGRA30_TSENSOR=m CONFIG_WATCHDOG=y CONFIG_MAX77620_WATCHDOG=y CONFIG_TEGRA_WATCHDOG=y From patchwork Mon May 10 22:38:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 433243 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8052FC433ED for ; Mon, 10 May 2021 22:40:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 58E9A6157F for ; Mon, 10 May 2021 22:40:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231544AbhEJWl6 (ORCPT ); Mon, 10 May 2021 18:41:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231451AbhEJWl4 (ORCPT ); Mon, 10 May 2021 18:41:56 -0400 Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69B5BC061574; Mon, 10 May 2021 15:40:50 -0700 (PDT) Received: by mail-lf1-x133.google.com with SMTP id z9so25721536lfu.8; Mon, 10 May 2021 15:40:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tdhxEVn/ApgXUS3G+03myNB4Fqv3j3XN+RFKP4M2N/E=; b=RsbL915Fu3Y2xNkXKX9JU3SsNypKl6RXkXtnRiIChU+o0az3SWAmoffX/z3OEfmK8Z NYM9u/Gb8KBF+27QBcAa/Zw9oLnFc2ylp4SQhuOOmKzx7i0RxfwMoJkOMM0oVgP4jJLa zGhTtv4XzugHTA89Yj744v9hRpI7bYGQTpDZMdpBs9GAz4GUqb+9cLlhL1bOhnYt3gcE MOx6mkqks1JqsUfTamjUPQADx5DTkd2fGCjam5iqlNdt2IeW5CEZo2HmqxkOYOZ15aNl CrOmYV9pm32yzDdrXeTF3AxMKTfR0c9i4nmEZ32SHGuD0f6rv3YNVm3VuopOtFCDszDH Te+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tdhxEVn/ApgXUS3G+03myNB4Fqv3j3XN+RFKP4M2N/E=; b=M3P3wAGZYwG3i0jdAUHFaUkucUmTpV8KrQIo9oAna28UKFy6DxKHyU9UU4Pe+oYf7q XADmeVJYtzJRdk9gZz7RmXFyx2mqPETv9AyygGiAVWCySsHM/emFcNruR/pxJT0/jFy2 rK1Qnx9G2U7IN59WUoih09BPoEWJ+NBm56HHiIzA8tl1tjdN3PG9nvxxVnmvMBqnNYfo 56Vwj2Ww979/Ax6sZ8YpTdgVz9UfLEDa+DG6UY/qFu4iohpoVuidrFe0cuyIlXs4d4i+ gqBxzq4vrmkrgM8dfML5RZ9mB0FNVI4sOlS27iYuzgPI83+1OJyWx26aeGx6B4KnXTaE NLrw== X-Gm-Message-State: AOAM531StHoh+LmqhQShECZmY0oqeL88Gekxb8UNfqi6Fjb7L2E7+hRf ixG04yJrlpj/yrWUvbuor8I= X-Google-Smtp-Source: ABdhPJzz6fepG+GOMZhdHZxCQ+3aYLSrzsog/VZEUaWf70lRQBPXOCIyrLIyWXkrDw6QPJAZS5T4Lg== X-Received: by 2002:a05:6512:1388:: with SMTP id p8mr19368721lfa.269.1620686448932; Mon, 10 May 2021 15:40:48 -0700 (PDT) Received: from localhost.localdomain (109-252-193-91.dynamic.spd-mgts.ru. [109.252.193.91]) by smtp.gmail.com with ESMTPSA id g24sm2780698lja.63.2021.05.10.15.40.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 May 2021 15:40:48 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Zhang Rui , Daniel Lezcano , Amit Kucheria , Rob Herring , Andreas Westman Dorcsak , Maxim Schwalm , Svyatoslav Ryhel , Ihor Didenko , Ion Agorria , Matt Merhar , Peter Geis Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org Subject: [PATCH v1 7/7] ARM: tegra: Add SoC thermal sensor to Tegra30 device-trees Date: Tue, 11 May 2021 01:38:16 +0300 Message-Id: <20210510223816.18565-8-digetx@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210510223816.18565-1-digetx@gmail.com> References: <20210510223816.18565-1-digetx@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Add the on-chip SoC thermal sensor to Tegra30 device-trees. Now CPU temperature reporting and thermal throttling is available on all Tegra30 devices universally. Signed-off-by: Dmitry Osipenko --- arch/arm/boot/dts/tegra30-ouya.dts | 16 +++++ arch/arm/boot/dts/tegra30.dtsi | 93 ++++++++++++++++++++++++++++-- 2 files changed, 105 insertions(+), 4 deletions(-) diff --git a/arch/arm/boot/dts/tegra30-ouya.dts b/arch/arm/boot/dts/tegra30-ouya.dts index f008653d843b..619a4df3f4cd 100644 --- a/arch/arm/boot/dts/tegra30-ouya.dts +++ b/arch/arm/boot/dts/tegra30-ouya.dts @@ -469,6 +469,22 @@ map1 { }; }; }; + + tsensor-channel0 { + trips { + dvfs-alert { + temperature = <70000>; + }; + + cpu-div2-throttle { + temperature = <75000>; + }; + + soc-critical { + temperature = <90000>; + }; + }; + }; }; vdd_12v_in: vdd_12v_in { diff --git a/arch/arm/boot/dts/tegra30.dtsi b/arch/arm/boot/dts/tegra30.dtsi index 576dffdbd0a1..3fe24b6c340d 100644 --- a/arch/arm/boot/dts/tegra30.dtsi +++ b/arch/arm/boot/dts/tegra30.dtsi @@ -5,6 +5,7 @@ #include #include #include +#include #include "tegra30-peripherals-opp.dtsi" @@ -1155,6 +1156,21 @@ fuse@7000f800 { reset-names = "fuse"; }; + tsensor: tsensor@70014000 { + compatible = "nvidia,tegra30-tsensor"; + reg = <0x70014000 0x500>; + interrupts = ; + clocks = <&tegra_car TEGRA30_CLK_TSENSOR>; + resets = <&tegra_car TEGRA30_CLK_TSENSOR>; + + assigned-clocks = <&tegra_car TEGRA30_CLK_TSENSOR>; + assigned-clock-parents = <&tegra_car TEGRA30_CLK_CLK_M>; + assigned-clock-rates = <500000>; + + #thermal-sensor-cells = <1>; + #cooling-cells = <2>; + }; + hda@70030000 { compatible = "nvidia,tegra30-hda"; reg = <0x70030000 0x10000>; @@ -1417,32 +1433,36 @@ cpus { #address-cells = <1>; #size-cells = <0>; - cpu@0 { + cpu0: cpu@0 { device_type = "cpu"; compatible = "arm,cortex-a9"; reg = <0>; clocks = <&tegra_car TEGRA30_CLK_CCLK_G>; + #cooling-cells = <2>; }; - cpu@1 { + cpu1: cpu@1 { device_type = "cpu"; compatible = "arm,cortex-a9"; reg = <1>; clocks = <&tegra_car TEGRA30_CLK_CCLK_G>; + #cooling-cells = <2>; }; - cpu@2 { + cpu2: cpu@2 { device_type = "cpu"; compatible = "arm,cortex-a9"; reg = <2>; clocks = <&tegra_car TEGRA30_CLK_CCLK_G>; + #cooling-cells = <2>; }; - cpu@3 { + cpu3: cpu@3 { device_type = "cpu"; compatible = "arm,cortex-a9"; reg = <3>; clocks = <&tegra_car TEGRA30_CLK_CCLK_G>; + #cooling-cells = <2>; }; }; @@ -1457,4 +1477,69 @@ pmu { <&{/cpus/cpu@2}>, <&{/cpus/cpu@3}>; }; + + thermal-zones { + tsensor-channel0 { + polling-delay-passive = <1000>; /* milliseconds */ + polling-delay = <5000>; /* milliseconds */ + + thermal-sensors = <&tsensor 0>; + + trips { + level1_trip: dvfs-alert { + /* throttle at 67C until temperature drops to 66.8C */ + temperature = <67000>; + hysteresis = <200>; + type = "passive"; + }; + + level2_trip: cpu-div2-throttle { + /* hardware CPU x2 freq throttle at 70C */ + temperature = <70000>; + hysteresis = <200>; + type = "hot"; + }; + + soc-critical { + /* hardware shut down at 80C */ + temperature = <80000>; + hysteresis = <2000>; + type = "critical"; + }; + }; + + cooling-maps { + map0 { + trip = <&level1_trip>; + cooling-device = <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu1 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu2 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu3 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&actmon THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + }; + + map1 { + trip = <&level2_trip>; + cooling-device = <&tsensor THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + }; + }; + }; + + tsensor-channel1 { + status = "disabled"; + + polling-delay-passive = <1000>; /* milliseconds */ + polling-delay = <0>; /* milliseconds */ + + thermal-sensors = <&tsensor 1>; + + trips { + dvfs-alert { + temperature = <80000>; + hysteresis = <200>; + type = "passive"; + }; + }; + }; + }; };