From patchwork Fri Apr 14 12:57:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 13211442 X-Patchwork-Delegate: daniel.lezcano@linaro.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D227C77B79 for ; Fri, 14 Apr 2023 12:57:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229964AbjDNM5u (ORCPT ); Fri, 14 Apr 2023 08:57:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230097AbjDNM5p (ORCPT ); Fri, 14 Apr 2023 08:57:45 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E01AAF25; Fri, 14 Apr 2023 05:57:29 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id v20-20020a05600c471400b003ed8826253aso5109076wmo.0; Fri, 14 Apr 2023 05:57:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681477047; x=1684069047; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Uhi30Q6rsEgaICi18lwEGWgCxy7hCcC5QmVwAwqnB3w=; b=gFHAVrMr5QyDTdSy7jXt1PKsFnm78z5XB+Kj5Kajz5W1rZ5p+tRe0XT9QZiE3UliTd m+cZ0zh2ZDqWBjqrwsS5Tea6G054FgfER2x0UAvFWzEWYo1JAhEoM5/Vq+B7pHBW54Ub JXXhOhjilluwh2q0LH5iQVVZY8yc5sFsw2axD1THyB7lQ+sEyqH4gZdt3wSl+JZvFD2Z i3+NoTlQd2imzSMnK+Aw7yhQMWPjMxKfnEF/wG2uQSzI9QJuY8xZtKV3FArb2bfXda2/ 64M6fBWlX+ybSrl16F/70m+qbIKFpHViv2EkrR8kkMZYegEfQiDaMKNtNIywsCwO1b2x ohYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681477047; x=1684069047; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Uhi30Q6rsEgaICi18lwEGWgCxy7hCcC5QmVwAwqnB3w=; b=MHaM5y7znGKBxub6CobdQhn5gRG0wY6uHe+ggldWTrgrBYjn5mr4glDoZ+XNB9JB7q VHm3SxveOkhA9Vvi7N4FI32/tvj7+OJMl3u7UVfiE5Fngk/FzQxli8nG/WDBV56b1pV1 9XioQte6DlYG+xsRSa8ary4N+WNjwxxCpJJb5d82lycIxaF8UsUPvwF4KHcdSMQhSD6y tyh60V3W4Do+X9lIV5tf9+3PSNLJvV5/OBF8XjyarvGQ6Ig/jqmTEof90yuMBG1r1Wzh EfjKj+rLe7Jtlsl08kQDtnt/B9TUWdGWDFDLi2QXLtfcM6EEQ4BbnLhpluMqBrSBY7DY 02ig== X-Gm-Message-State: AAQBX9fTmEuBKX9VbXsEZ3nenlmniIEC4tQQCntgh5Yndi19y8d8JCCf Ga6/O+EWRMr3yufcZuFza0U= X-Google-Smtp-Source: AKy350aTQaoponEEHe8Mkagx3IV+LVByNgodyyyixEiBKdBvTr44JLiUxm/SSPCLdpPxJH4qJaes7A== X-Received: by 2002:a7b:c7c8:0:b0:3ed:b094:3c93 with SMTP id z8-20020a7bc7c8000000b003edb0943c93mr4143506wmk.23.1681477047069; Fri, 14 Apr 2023 05:57:27 -0700 (PDT) Received: from localhost (p200300e41f1c0800f22f74fffe1f3a53.dip0.t-ipconnect.de. [2003:e4:1f1c:800:f22f:74ff:fe1f:3a53]) by smtp.gmail.com with ESMTPSA id x2-20020a05600c21c200b003f149715cb6sm719240wmj.10.2023.04.14.05.57.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 05:57:26 -0700 (PDT) From: Thierry Reding To: Daniel Lezcano , "Rafael J . Wysocki" , Thierry Reding , Rob Herring , Krzysztof Kozlowski Cc: Amit Kucheria , Zhang Rui , Jon Hunter , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-tegra@vger.kernel.org Subject: [PATCH 01/10] dt-bindings: thermal: tegra: Document throttle temperature Date: Fri, 14 Apr 2023 14:57:12 +0200 Message-Id: <20230414125721.1043589-2-thierry.reding@gmail.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230414125721.1043589-1-thierry.reding@gmail.com> References: <20230414125721.1043589-1-thierry.reding@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Thierry Reding Each throttling configuration needs to specify the temperature threshold at which it should start throttling. Previously this was tied to a given trip point as a cooling device and used the temperature specified for that trip point. This doesn't work well because the throttling mechanism is not a cooling device in the traditional sense. Instead, allow device trees to specify the throttle temperature in the throttle configuration directly so that the throttle doesn't need to be exposed as a cooling device. Signed-off-by: Thierry Reding --- .../bindings/thermal/nvidia,tegra124-soctherm.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Documentation/devicetree/bindings/thermal/nvidia,tegra124-soctherm.yaml b/Documentation/devicetree/bindings/thermal/nvidia,tegra124-soctherm.yaml index 4677ad6645a5..37dac851f486 100644 --- a/Documentation/devicetree/bindings/thermal/nvidia,tegra124-soctherm.yaml +++ b/Documentation/devicetree/bindings/thermal/nvidia,tegra124-soctherm.yaml @@ -120,6 +120,13 @@ properties: # high (85%, TEGRA_SOCTHERM_THROT_LEVEL_HIGH) - 3 + temperature: + $ref: /schemas/types.yaml#/definitions/int32 + minimum: -273000 + maximum: 200000 + description: The temperature threshold (in millicelsius) that, + when crossed, will trigger the configured automatic throttling. + # optional # Tegra210 specific and valid only for OCx throttle events nvidia,count-threshold: From patchwork Fri Apr 14 12:57:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 13211443 X-Patchwork-Delegate: daniel.lezcano@linaro.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8FB26C77B76 for ; Fri, 14 Apr 2023 12:57:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230092AbjDNM5x (ORCPT ); Fri, 14 Apr 2023 08:57:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230126AbjDNM5v (ORCPT ); Fri, 14 Apr 2023 08:57:51 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C1E46A54; Fri, 14 Apr 2023 05:57:30 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id o29so6332661wro.0; Fri, 14 Apr 2023 05:57:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681477048; x=1684069048; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FWRCCo7e9zhmeyr03ikjpoBsiwneIsZ2XSJhGD0NG/E=; b=oPUnZdYo4Q20XERJMMEVSo9veXiRUqXlmnDDWb+ywp9Vc55fIwWE0C28R2+cV3SBNK IHR7IVToSNUbpre/qPO7dPdiIK5u/dEyD5snys/cy0tr7Z1n54t6MfS2pcRs/L0CbSJm I47ES0iQKY4Ni0U6/hxYgcn5O0VmK1CJrct4zvTRQsNlsJdLsgHHHEGsv2p/xHCNsWqf ZcOcmlTnI4semMPq8YyH4GImQfLXh0hrp8bt+4OkqNCZXpBu+wRKgGYJA/gEU+lwtGAY aCfM5nYRHguNTym1rM+Wb9+azq9SG4GPabZ2UsfsyFfQ2pRO7icWRVdhkm10yRGhQgVj YowQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681477048; x=1684069048; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FWRCCo7e9zhmeyr03ikjpoBsiwneIsZ2XSJhGD0NG/E=; b=iw1vOISIaVaZ8/nUiZfNacoVCjfrP5wSyBsQowLDzCH7Lp47mEAWSB0f3CvOYAUznq iqC7Ydjb09Kpoz2T+Er+LZH5q7Xzn+l5F/T4gWcXjDiPsW2mhHTORaGEOejBJgjMiwVn yxD7ixd+IHYNBd0e71cKVWpa3GRPmsZkR++TdfxoSlBohrol5B1pDZ+0ab8gukMYZrIX URctyc7P5zmdZFjWEwBGWY7eSQJidkSAjU1TBBq1Rn/JkhznBIDShwefFiT30CD3BY9j GsLay9zVUpLSo94rzOLScEObqwsHqWV4JBK3jmdgAe4cBdpxpWD746B3t4ZYIpel/73q 33tg== X-Gm-Message-State: AAQBX9eBuJlBI7HOMhH0afvP3vO6dgxjDqJZC9VVdz20jjyhPP/ZIjj3 6n1/giSFTucwXfQkj2+EmArn+Ps6vfw= X-Google-Smtp-Source: AKy350aqhmoi2suhBCJPX/21m9QKtTo8YErs48A71ScakfHzO+HGVZxmQ3vDvr6hovAcFKfu7ziqdw== X-Received: by 2002:adf:f58b:0:b0:2ef:b3e6:8293 with SMTP id f11-20020adff58b000000b002efb3e68293mr4375975wro.9.1681477048343; Fri, 14 Apr 2023 05:57:28 -0700 (PDT) Received: from localhost (p200300e41f1c0800f22f74fffe1f3a53.dip0.t-ipconnect.de. [2003:e4:1f1c:800:f22f:74ff:fe1f:3a53]) by smtp.gmail.com with ESMTPSA id k15-20020a05600c1c8f00b003ede2c59a54sm8003639wms.37.2023.04.14.05.57.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 05:57:28 -0700 (PDT) From: Thierry Reding To: Daniel Lezcano , "Rafael J . Wysocki" , Thierry Reding , Rob Herring , Krzysztof Kozlowski Cc: Amit Kucheria , Zhang Rui , Jon Hunter , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-tegra@vger.kernel.org Subject: [PATCH 02/10] thermal: tegra: Use driver-private data consistently Date: Fri, 14 Apr 2023 14:57:13 +0200 Message-Id: <20230414125721.1043589-3-thierry.reding@gmail.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230414125721.1043589-1-thierry.reding@gmail.com> References: <20230414125721.1043589-1-thierry.reding@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Thierry Reding Instead of passing around platform and plain devices and figuring out the driver-private data within each helper, directly pass around the driver-private data when it's available. Also store a pointer to the parent device in the main driver-private data structure for easier access. Signed-off-by: Thierry Reding --- drivers/thermal/tegra/soctherm.c | 213 ++++++++++++++----------------- 1 file changed, 95 insertions(+), 118 deletions(-) diff --git a/drivers/thermal/tegra/soctherm.c b/drivers/thermal/tegra/soctherm.c index ea66cba09e56..ca39340cd93f 100644 --- a/drivers/thermal/tegra/soctherm.c +++ b/drivers/thermal/tegra/soctherm.c @@ -299,7 +299,6 @@ static const char *const throt_names[] = { struct tegra_soctherm; struct tegra_thermctl_zone { void __iomem *reg; - struct device *dev; struct tegra_soctherm *ts; struct thermal_zone_device *tz; const struct tegra_tsensor_group *sg; @@ -327,6 +326,7 @@ struct soctherm_throt_cfg { }; struct tegra_soctherm { + struct device *dev; struct reset_control *reset; struct clk *clock_tsensor; struct clk *clock_soctherm; @@ -444,14 +444,15 @@ static int tegra_thermctl_get_temp(struct thermal_zone_device *tz, int *out_temp * * Return: The precision adjusted capped temperature in millicelsius. */ -static int enforce_temp_range(struct device *dev, int trip_temp) +static int enforce_temp_range(struct tegra_soctherm *ts, int trip_temp) { int temp; temp = clamp_val(trip_temp, min_low_temp, max_high_temp); if (temp != trip_temp) - dev_dbg(dev, "soctherm: trip temperature %d forced to %d\n", + dev_dbg(ts->dev, "trip temperature %d forced to %d\n", trip_temp, temp); + return temp; } @@ -471,18 +472,17 @@ static int enforce_temp_range(struct device *dev, int trip_temp) * * Return: 0 upon success, or %-EINVAL upon failure. */ -static int thermtrip_program(struct device *dev, +static int thermtrip_program(struct tegra_soctherm *ts, const struct tegra_tsensor_group *sg, int trip_temp) { - struct tegra_soctherm *ts = dev_get_drvdata(dev); int temp; u32 r; if (!sg || !sg->thermtrip_threshold_mask) return -EINVAL; - temp = enforce_temp_range(dev, trip_temp) / ts->soc->thresh_grain; + temp = enforce_temp_range(ts, trip_temp) / ts->soc->thresh_grain; r = readl(ts->regs + THERMCTL_THERMTRIP_CTL); r = REG_SET_MASK(r, sg->thermtrip_threshold_mask, temp); @@ -496,7 +496,7 @@ static int thermtrip_program(struct device *dev, /** * throttrip_program() - Configures the hardware to throttle the * pulse if a given sensor group reaches a given temperature - * @dev: ptr to the struct device for the SOC_THERM IP block + * @ts: pointer to a struct tegra_soctherm * @sg: pointer to the sensor group to set the thermtrip temperature for * @stc: pointer to the throttle need to be triggered * @trip_temp: the temperature in millicelsius to trigger the thermal trip at @@ -510,12 +510,11 @@ static int thermtrip_program(struct device *dev, * * Return: 0 upon success, or %-EINVAL upon failure. */ -static int throttrip_program(struct device *dev, +static int throttrip_program(struct tegra_soctherm *ts, const struct tegra_tsensor_group *sg, struct soctherm_throt_cfg *stc, int trip_temp) { - struct tegra_soctherm *ts = dev_get_drvdata(dev); int temp, cpu_throt, gpu_throt; unsigned int throt; u32 r, reg_off; @@ -523,7 +522,7 @@ static int throttrip_program(struct device *dev, if (!sg || !stc || !stc->init) return -EINVAL; - temp = enforce_temp_range(dev, trip_temp) / ts->soc->thresh_grain; + temp = enforce_temp_range(ts, trip_temp) / ts->soc->thresh_grain; /* Hardcode LIGHT on LEVEL1 and HEAVY on LEVEL2 */ throt = stc->id; @@ -536,7 +535,7 @@ static int throttrip_program(struct device *dev, cpu_throt = THERMCTL_LVL0_CPU0_CPU_THROT_HEAVY; gpu_throt = THERMCTL_LVL0_CPU0_GPU_THROT_HEAVY; if (throt != THROTTLE_HEAVY) - dev_warn(dev, + dev_warn(ts->dev, "invalid throt id %d - assuming HEAVY", throt); } @@ -588,7 +587,6 @@ static int tegra_thermctl_set_trip_temp(struct thermal_zone_device *tz, int trip struct tegra_soctherm *ts = zone->ts; struct thermal_trip trip; const struct tegra_tsensor_group *sg = zone->sg; - struct device *dev = zone->dev; int ret; if (!tz) @@ -605,7 +603,7 @@ static int tegra_thermctl_set_trip_temp(struct thermal_zone_device *tz, int trip * if not, program critical trip to HW. */ if (min_low_temp == tsensor_group_thermtrip_get(ts, sg->id)) - return thermtrip_program(dev, sg, temp); + return thermtrip_program(ts, sg, temp); else return 0; @@ -625,7 +623,7 @@ static int tegra_thermctl_set_trip_temp(struct thermal_zone_device *tz, int trip else continue; - return throttrip_program(dev, sg, stc, temp); + return throttrip_program(ts, sg, stc, temp); } } @@ -667,9 +665,9 @@ static int tegra_thermctl_set_trips(struct thermal_zone_device *tz, int lo, int r = REG_SET_MASK(r, THERMCTL_LVL0_CPU0_EN_MASK, 0); writel(r, zone->ts->regs + zone->sg->thermctl_lvl0_offset); - lo = enforce_temp_range(zone->dev, lo) / zone->ts->soc->thresh_grain; - hi = enforce_temp_range(zone->dev, hi) / zone->ts->soc->thresh_grain; - dev_dbg(zone->dev, "%s hi:%d, lo:%d\n", __func__, hi, lo); + lo = enforce_temp_range(zone->ts, lo) / zone->ts->soc->thresh_grain; + hi = enforce_temp_range(zone->ts, hi) / zone->ts->soc->thresh_grain; + dev_dbg(zone->ts->dev, "%s hi:%d, lo:%d\n", __func__, hi, lo); r = REG_SET_MASK(r, zone->sg->thermctl_lvl0_up_thresh_mask, hi); r = REG_SET_MASK(r, zone->sg->thermctl_lvl0_dn_thresh_mask, lo); @@ -731,11 +729,10 @@ static int get_hot_temp(struct thermal_zone_device *tz, int *trip_id, int *temp) * this one appears on the serial console: * ""throttrip: will throttle when sensor group XXX reaches YYYYYY mC" */ -static int tegra_soctherm_set_hwtrips(struct device *dev, +static int tegra_soctherm_set_hwtrips(struct tegra_soctherm *ts, const struct tegra_tsensor_group *sg, struct thermal_zone_device *tz) { - struct tegra_soctherm *ts = dev_get_drvdata(dev); struct soctherm_throt_cfg *stc; int i, trip, temperature, ret; @@ -745,18 +742,19 @@ static int tegra_soctherm_set_hwtrips(struct device *dev, if (thermal_zone_get_crit_temp(tz, &temperature)) temperature = max_high_temp; - ret = thermtrip_program(dev, sg, temperature); + ret = thermtrip_program(ts, sg, temperature); if (ret) { - dev_err(dev, "thermtrip: %s: error during enable\n", sg->name); + dev_err(ts->dev, "thermtrip: %s: error during enable\n", + sg->name); return ret; } - dev_info(dev, "thermtrip: will shut down when %s reaches %d mC\n", + dev_info(ts->dev, "thermtrip: will shut down when %s reaches %d mC\n", sg->name, temperature); ret = get_hot_temp(tz, &trip, &temperature); if (ret) { - dev_info(dev, "throttrip: %s: missing hot temperature\n", + dev_info(ts->dev, "throttrip: %s: missing hot temperature\n", sg->name); return 0; } @@ -773,21 +771,21 @@ static int tegra_soctherm_set_hwtrips(struct device *dev, else continue; - ret = throttrip_program(dev, sg, stc, temperature); + ret = throttrip_program(ts, sg, stc, temperature); if (ret) { - dev_err(dev, "throttrip: %s: error during enable\n", + dev_err(ts->dev, "throttrip: %s: error during enable\n", sg->name); return ret; } - dev_info(dev, + dev_info(ts->dev, "throttrip: will throttle when %s reaches %d mC\n", sg->name, temperature); break; } if (i == THROTTLE_SIZE) - dev_info(dev, "throttrip: %s: missing throttle cdev\n", + dev_info(ts->dev, "throttrip: %s: missing throttle cdev\n", sg->name); return 0; @@ -1253,8 +1251,7 @@ static int soctherm_oc_int_init(struct device_node *np, int num_irqs) #ifdef CONFIG_DEBUG_FS static int regs_show(struct seq_file *s, void *data) { - struct platform_device *pdev = s->private; - struct tegra_soctherm *ts = platform_get_drvdata(pdev); + struct tegra_soctherm *ts = s->private; const struct tegra_tsensor *tsensors = ts->soc->tsensors; const struct tegra_tsensor_group **ttgs = ts->soc->ttgs; u32 r, state; @@ -1449,24 +1446,24 @@ static int regs_show(struct seq_file *s, void *data) DEFINE_SHOW_ATTRIBUTE(regs); -static void soctherm_debug_init(struct platform_device *pdev) +static void soctherm_debug_init(struct tegra_soctherm *tegra) { - struct tegra_soctherm *tegra = platform_get_drvdata(pdev); struct dentry *root; root = debugfs_create_dir("soctherm", NULL); tegra->debugfs_dir = root; - debugfs_create_file("reg_contents", 0644, root, pdev, ®s_fops); + debugfs_create_file("reg_contents", 0644, root, tegra, ®s_fops); } #else -static inline void soctherm_debug_init(struct platform_device *pdev) {} +static inline void soctherm_debug_init(struct tegra_soctherm *ts) +{ +} #endif -static int soctherm_clk_enable(struct platform_device *pdev, bool enable) +static int soctherm_clk_enable(struct tegra_soctherm *tegra, bool enable) { - struct tegra_soctherm *tegra = platform_get_drvdata(pdev); int err; if (!tegra->clock_soctherm || !tegra->clock_tsensor) @@ -1531,10 +1528,8 @@ static const struct thermal_cooling_device_ops throt_cooling_ops = { .set_cur_state = throt_set_cdev_state, }; -static int soctherm_thermtrips_parse(struct platform_device *pdev) +static int soctherm_thermtrips_parse(struct tegra_soctherm *ts) { - struct device *dev = &pdev->dev; - struct tegra_soctherm *ts = dev_get_drvdata(dev); struct tsensor_group_thermtrips *tt = ts->soc->thermtrips; const int max_num_prop = ts->soc->num_ttgs * 2; u32 *tlb; @@ -1543,22 +1538,22 @@ static int soctherm_thermtrips_parse(struct platform_device *pdev) if (!tt) return -ENOMEM; - n = of_property_count_u32_elems(dev->of_node, "nvidia,thermtrips"); + n = of_property_count_u32_elems(ts->dev->of_node, "nvidia,thermtrips"); if (n <= 0) { - dev_info(dev, + dev_info(ts->dev, "missing thermtrips, will use critical trips as shut down temp\n"); return n; } n = min(max_num_prop, n); - tlb = devm_kcalloc(&pdev->dev, max_num_prop, sizeof(u32), GFP_KERNEL); + tlb = devm_kcalloc(ts->dev, max_num_prop, sizeof(u32), GFP_KERNEL); if (!tlb) return -ENOMEM; - ret = of_property_read_u32_array(dev->of_node, "nvidia,thermtrips", + ret = of_property_read_u32_array(ts->dev->of_node, "nvidia,thermtrips", tlb, n); if (ret) { - dev_err(dev, "invalid num ele: thermtrips:%d\n", ret); + dev_err(ts->dev, "invalid num ele: thermtrips:%d\n", ret); return ret; } @@ -1575,9 +1570,9 @@ static int soctherm_thermtrips_parse(struct platform_device *pdev) return 0; } -static void soctherm_oc_cfg_parse(struct device *dev, - struct device_node *np_oc, - struct soctherm_throt_cfg *stc) +static void soctherm_oc_cfg_parse(struct tegra_soctherm *tegra, + struct device_node *np_oc, + struct soctherm_throt_cfg *stc) { u32 val; @@ -1601,19 +1596,20 @@ static void soctherm_oc_cfg_parse(struct device *dev, stc->oc_cfg.mode = OC_THROTTLE_MODE_BRIEF; } -static int soctherm_throt_cfg_parse(struct device *dev, +static int soctherm_throt_cfg_parse(struct tegra_soctherm *ts, struct device_node *np, struct soctherm_throt_cfg *stc) { - struct tegra_soctherm *ts = dev_get_drvdata(dev); int ret; u32 val; ret = of_property_read_u32(np, "nvidia,priority", &val); if (ret) { - dev_err(dev, "throttle-cfg: %s: invalid priority\n", stc->name); + dev_err(ts->dev, "throttle-cfg: %s: invalid priority\n", + stc->name); return -EINVAL; } + stc->priority = val; ret = of_property_read_u32(np, ts->soc->use_ccroc ? @@ -1640,7 +1636,7 @@ static int soctherm_throt_cfg_parse(struct device *dev, return 0; err: - dev_err(dev, "throttle-cfg: %s: no throt prop or invalid prop\n", + dev_err(ts->dev, "throttle-cfg: %s: no throt prop or invalid prop\n", stc->name); return -EINVAL; } @@ -1648,25 +1644,23 @@ static int soctherm_throt_cfg_parse(struct device *dev, /** * soctherm_init_hw_throt_cdev() - Parse the HW throttle configurations * and register them as cooling devices. - * @pdev: Pointer to platform_device struct + * @tegra: pointer to Tegra soctherm structure */ -static void soctherm_init_hw_throt_cdev(struct platform_device *pdev) +static void soctherm_init_hw_throt_cdev(struct tegra_soctherm *tegra) { - struct device *dev = &pdev->dev; - struct tegra_soctherm *ts = dev_get_drvdata(dev); struct device_node *np_stc, *np_stcc; const char *name; int i; for (i = 0; i < THROTTLE_SIZE; i++) { - ts->throt_cfgs[i].name = throt_names[i]; - ts->throt_cfgs[i].id = i; - ts->throt_cfgs[i].init = false; + tegra->throt_cfgs[i].name = throt_names[i]; + tegra->throt_cfgs[i].id = i; + tegra->throt_cfgs[i].init = false; } - np_stc = of_get_child_by_name(dev->of_node, "throttle-cfgs"); + np_stc = of_get_child_by_name(tegra->dev->of_node, "throttle-cfgs"); if (!np_stc) { - dev_info(dev, + dev_info(tegra->dev, "throttle-cfg: no throttle-cfgs - not enabling\n"); return; } @@ -1677,33 +1671,34 @@ static void soctherm_init_hw_throt_cdev(struct platform_device *pdev) int err; name = np_stcc->name; - stc = find_throttle_cfg_by_name(ts, name); + stc = find_throttle_cfg_by_name(tegra, name); if (!stc) { - dev_err(dev, - "throttle-cfg: could not find %s\n", name); + dev_err(tegra->dev, "throttle-cfg: could not find %s\n", + name); continue; } if (stc->init) { - dev_err(dev, "throttle-cfg: %s: redefined!\n", name); + dev_err(tegra->dev, "throttle-cfg: %s: redefined!\n", + name); of_node_put(np_stcc); break; } - err = soctherm_throt_cfg_parse(dev, np_stcc, stc); + err = soctherm_throt_cfg_parse(tegra, np_stcc, stc); if (err) continue; if (stc->id >= THROTTLE_OC1) { - soctherm_oc_cfg_parse(dev, np_stcc, stc); + soctherm_oc_cfg_parse(tegra, np_stcc, stc); stc->init = true; } else { tcd = thermal_of_cooling_device_register(np_stcc, - (char *)name, ts, + (char *)name, tegra, &throt_cooling_ops); if (IS_ERR_OR_NULL(tcd)) { - dev_err(dev, + dev_err(tegra->dev, "throttle-cfg: %s: failed to register cooling device\n", name); continue; @@ -1711,7 +1706,6 @@ static void soctherm_init_hw_throt_cdev(struct platform_device *pdev) stc->cdev = tcd; stc->init = true; } - } of_node_put(np_stc); @@ -1931,9 +1925,8 @@ static void soctherm_throttle_program(struct tegra_soctherm *ts, writel(r, ts->regs + THROT_PRIORITY_LOCK); } -static void tegra_soctherm_throttle(struct device *dev) +static void tegra_soctherm_throttle(struct tegra_soctherm *ts) { - struct tegra_soctherm *ts = dev_get_drvdata(dev); u32 v; int i; @@ -1969,43 +1962,29 @@ static void tegra_soctherm_throttle(struct device *dev) writel(v, ts->regs + THERMCTL_STATS_CTL); } -static int soctherm_interrupts_init(struct platform_device *pdev, - struct tegra_soctherm *tegra) +static int soctherm_interrupts_init(struct tegra_soctherm *tegra) { - struct device_node *np = pdev->dev.of_node; int ret; - ret = soctherm_oc_int_init(np, TEGRA_SOC_OC_IRQ_MAX); + ret = soctherm_oc_int_init(tegra->dev->of_node, TEGRA_SOC_OC_IRQ_MAX); if (ret < 0) { - dev_err(&pdev->dev, "soctherm_oc_int_init failed\n"); + dev_err(tegra->dev, "soctherm_oc_int_init failed\n"); return ret; } - tegra->thermal_irq = platform_get_irq(pdev, 0); - if (tegra->thermal_irq < 0) { - dev_dbg(&pdev->dev, "get 'thermal_irq' failed.\n"); - return 0; - } - - tegra->edp_irq = platform_get_irq(pdev, 1); - if (tegra->edp_irq < 0) { - dev_dbg(&pdev->dev, "get 'edp_irq' failed.\n"); - return 0; - } - - ret = devm_request_threaded_irq(&pdev->dev, + ret = devm_request_threaded_irq(tegra->dev, tegra->thermal_irq, soctherm_thermal_isr, soctherm_thermal_isr_thread, IRQF_ONESHOT, - dev_name(&pdev->dev), + dev_name(tegra->dev), tegra); if (ret < 0) { - dev_err(&pdev->dev, "request_irq 'thermal_irq' failed.\n"); + dev_err(tegra->dev, "failed to request thermal IRQ: %d\n", ret); return ret; } - ret = devm_request_threaded_irq(&pdev->dev, + ret = devm_request_threaded_irq(tegra->dev, tegra->edp_irq, soctherm_edp_isr, soctherm_edp_isr_thread, @@ -2013,16 +1992,15 @@ static int soctherm_interrupts_init(struct platform_device *pdev, "soctherm_edp", tegra); if (ret < 0) { - dev_err(&pdev->dev, "request_irq 'edp_irq' failed.\n"); + dev_err(tegra->dev, "failed to request EDP IRQ: %d\n", ret); return ret; } return 0; } -static void soctherm_init(struct platform_device *pdev) +static void soctherm_init(struct tegra_soctherm *tegra) { - struct tegra_soctherm *tegra = platform_get_drvdata(pdev); const struct tegra_tsensor_group **ttgs = tegra->soc->ttgs; int i; u32 pdiv, hotspot; @@ -2048,7 +2026,7 @@ static void soctherm_init(struct platform_device *pdev) writel(hotspot, tegra->regs + SENSOR_HOTSPOT_OFF); /* Configure hw throttle */ - tegra_soctherm_throttle(&pdev->dev); + tegra_soctherm_throttle(tegra); } static const struct of_device_id tegra_soctherm_of_match[] = { @@ -2096,9 +2074,9 @@ static int tegra_soctherm_probe(struct platform_device *pdev) if (!tegra) return -ENOMEM; - mutex_init(&tegra->thermctl_lock); dev_set_drvdata(&pdev->dev, tegra); - + mutex_init(&tegra->thermctl_lock); + tegra->dev = &pdev->dev; tegra->soc = soc; tegra->regs = devm_platform_ioremap_resource_byname(pdev, "soctherm-reg"); @@ -2121,6 +2099,9 @@ static int tegra_soctherm_probe(struct platform_device *pdev) } } + tegra->thermal_irq = platform_get_irq(pdev, 0); + tegra->edp_irq = platform_get_irq(pdev, 1); + tegra->reset = devm_reset_control_get(&pdev->dev, "soctherm"); if (IS_ERR(tegra->reset)) { dev_err(&pdev->dev, "can't get soctherm reset\n"); @@ -2165,15 +2146,15 @@ static int tegra_soctherm_probe(struct platform_device *pdev) if (!tegra->thermctl_tzs) return -ENOMEM; - err = soctherm_clk_enable(pdev, true); + err = soctherm_clk_enable(tegra, true); if (err) return err; - soctherm_thermtrips_parse(pdev); + soctherm_thermtrips_parse(tegra); - soctherm_init_hw_throt_cdev(pdev); + soctherm_init_hw_throt_cdev(tegra); - soctherm_init(pdev); + soctherm_init(tegra); for (i = 0; i < soc->num_ttgs; ++i) { struct tegra_thermctl_zone *zone = @@ -2184,7 +2165,6 @@ static int tegra_soctherm_probe(struct platform_device *pdev) } zone->reg = tegra->regs + soc->ttgs[i]->sensor_temp_offset; - zone->dev = &pdev->dev; zone->sg = soc->ttgs[i]; zone->ts = tegra; @@ -2202,19 +2182,19 @@ static int tegra_soctherm_probe(struct platform_device *pdev) tegra->thermctl_tzs[soc->ttgs[i]->id] = z; /* Configure hw trip points */ - err = tegra_soctherm_set_hwtrips(&pdev->dev, soc->ttgs[i], z); + err = tegra_soctherm_set_hwtrips(tegra, soc->ttgs[i], z); if (err) goto disable_clocks; } - err = soctherm_interrupts_init(pdev, tegra); + err = soctherm_interrupts_init(tegra); - soctherm_debug_init(pdev); + soctherm_debug_init(tegra); return 0; disable_clocks: - soctherm_clk_enable(pdev, false); + soctherm_clk_enable(tegra, false); return err; } @@ -2225,44 +2205,41 @@ static int tegra_soctherm_remove(struct platform_device *pdev) debugfs_remove_recursive(tegra->debugfs_dir); - soctherm_clk_enable(pdev, false); + soctherm_clk_enable(tegra, false); return 0; } static int __maybe_unused soctherm_suspend(struct device *dev) { - struct platform_device *pdev = to_platform_device(dev); + struct tegra_soctherm *tegra = dev_get_drvdata(dev); - soctherm_clk_enable(pdev, false); + soctherm_clk_enable(tegra, false); return 0; } static int __maybe_unused soctherm_resume(struct device *dev) { - struct platform_device *pdev = to_platform_device(dev); - struct tegra_soctherm *tegra = platform_get_drvdata(pdev); + struct tegra_soctherm *tegra = dev_get_drvdata(dev); struct tegra_soctherm_soc *soc = tegra->soc; int err, i; - err = soctherm_clk_enable(pdev, true); + err = soctherm_clk_enable(tegra, true); if (err) { - dev_err(&pdev->dev, - "Resume failed: enable clocks failed\n"); + dev_err(dev, "Resume failed: enable clocks failed\n"); return err; } - soctherm_init(pdev); + soctherm_init(tegra); for (i = 0; i < soc->num_ttgs; ++i) { struct thermal_zone_device *tz; tz = tegra->thermctl_tzs[soc->ttgs[i]->id]; - err = tegra_soctherm_set_hwtrips(dev, soc->ttgs[i], tz); + err = tegra_soctherm_set_hwtrips(tegra, soc->ttgs[i], tz); if (err) { - dev_err(&pdev->dev, - "Resume failed: set hwtrips failed\n"); + dev_err(dev, "Resume failed: set hwtrips failed\n"); return err; } } From patchwork Fri Apr 14 12:57:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 13211444 X-Patchwork-Delegate: daniel.lezcano@linaro.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D688CC77B79 for ; Fri, 14 Apr 2023 12:57:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230115AbjDNM5y (ORCPT ); Fri, 14 Apr 2023 08:57:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229579AbjDNM5x (ORCPT ); Fri, 14 Apr 2023 08:57:53 -0400 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFCA7AF3C; Fri, 14 Apr 2023 05:57:32 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id n9-20020a05600c4f8900b003f05f617f3cso16486411wmq.2; Fri, 14 Apr 2023 05:57:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681477049; x=1684069049; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eaBrk11q48i3/r1oBLKd+aJHK6utmrPZfM1ILPoyDxo=; b=kE7ONyWMVeJ8IBCgWHtKCiutF5wISIzLPbZhfS1L5mUADDpCBvGFiZ3QPlw//GsvsS VwnBtUcOqDaXLtchHNMb/Qwu/8uY5Zw98dYaOYWzd0C5dhkfaiTGKoPrhUGPuJwNH+OA flZJCxUojDgcJ5WXT7aoBtANYHvkWxWrIcGbjycvjv4CtEntzdv7FwdRzkCEXEdwTy9O OVAws2QDJnyPBnDz2Pw5uI+FjXwNf3cEOazZs4dn6HZ5GJP5eKzYE+Q8RQw45cNYucIr esckSbLv1Eyhn1yF6RU4OWQuLXzRsYSuSIect0EuXGBq8YCumNVDazwiTV1kUP2YIz0m JgQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681477049; x=1684069049; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eaBrk11q48i3/r1oBLKd+aJHK6utmrPZfM1ILPoyDxo=; b=UfG1bcOnSXBIfhAdX66hDNJL5zJkCMzCVK040vsGMXcl0S7668IxIwdH1wmRrJUUfH DwXDBbnglmfS+eMDx6i5Br5uuEQMwwgMk4oijdiKV70/zq1l8jkYwA2p96Xzip+rYqgT 58HZ/WT+Q1gOOJjGGuSe0iy6jEwCI4732R2IN7ZwAHDDBhLINQ7o4pSeWbvgHYtBh9nK w7FjDUeY6Udb1MwEMAHE5M7S0tx4FYQX2EKyOear3IDaQ/4YalgBqeSzLAyPlZQcJFIB QrhrIkUghp92ecdNdU2zjd11NU4t2eLbahIDK9HTloLX4H/wGEI/hWMyP4dHVN165XvG ur2A== X-Gm-Message-State: AAQBX9diCNfJ5PeWgVvhJ6BGQg9Xcx4BSwIHMCtxc/9Qcm1+vlT9//1d 9LxK3ZhVpMyviRGEZMlFvE7Nbc1ydJ8= X-Google-Smtp-Source: AKy350bUkqvi535j/o/A+l1Bp6n2sbue+DdWT0BMcuK0ZIXlUvY/H1F+SpyPnhwkvgR01kBM9ytsZQ== X-Received: by 2002:a7b:c8ce:0:b0:3f0:ad5a:d69f with SMTP id f14-20020a7bc8ce000000b003f0ad5ad69fmr3493364wml.25.1681477049436; Fri, 14 Apr 2023 05:57:29 -0700 (PDT) Received: from localhost (p200300e41f1c0800f22f74fffe1f3a53.dip0.t-ipconnect.de. [2003:e4:1f1c:800:f22f:74ff:fe1f:3a53]) by smtp.gmail.com with ESMTPSA id m14-20020a056000008e00b002c71b4d476asm3498377wrx.106.2023.04.14.05.57.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 05:57:29 -0700 (PDT) From: Thierry Reding To: Daniel Lezcano , "Rafael J . Wysocki" , Thierry Reding , Rob Herring , Krzysztof Kozlowski Cc: Amit Kucheria , Zhang Rui , Jon Hunter , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-tegra@vger.kernel.org Subject: [PATCH 03/10] thermal: tegra: Constify SoC-specific data Date: Fri, 14 Apr 2023 14:57:14 +0200 Message-Id: <20230414125721.1043589-4-thierry.reding@gmail.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230414125721.1043589-1-thierry.reding@gmail.com> References: <20230414125721.1043589-1-thierry.reding@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Thierry Reding The SoC-specific parameter structure is read-only data, so consistently use const to mark it as such. Signed-off-by: Thierry Reding --- drivers/thermal/tegra/soctherm.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/thermal/tegra/soctherm.c b/drivers/thermal/tegra/soctherm.c index ca39340cd93f..958fa10de516 100644 --- a/drivers/thermal/tegra/soctherm.c +++ b/drivers/thermal/tegra/soctherm.c @@ -339,7 +339,7 @@ struct tegra_soctherm { u32 *calib; struct thermal_zone_device **thermctl_tzs; - struct tegra_soctherm_soc *soc; + const struct tegra_soctherm_soc *soc; struct soctherm_throt_cfg throt_cfgs[THROTTLE_SIZE]; @@ -2054,19 +2054,15 @@ MODULE_DEVICE_TABLE(of, tegra_soctherm_of_match); static int tegra_soctherm_probe(struct platform_device *pdev) { - const struct of_device_id *match; struct tegra_soctherm *tegra; struct thermal_zone_device *z; struct tsensor_shared_calib shared_calib; - struct tegra_soctherm_soc *soc; + const struct tegra_soctherm_soc *soc; unsigned int i; int err; - match = of_match_node(tegra_soctherm_of_match, pdev->dev.of_node); - if (!match) - return -ENODEV; + soc = device_get_match_data(&pdev->dev); - soc = (struct tegra_soctherm_soc *)match->data; if (soc->num_ttgs > TEGRA124_SOCTHERM_SENSOR_NUM) return -EINVAL; @@ -2222,7 +2218,7 @@ static int __maybe_unused soctherm_suspend(struct device *dev) static int __maybe_unused soctherm_resume(struct device *dev) { struct tegra_soctherm *tegra = dev_get_drvdata(dev); - struct tegra_soctherm_soc *soc = tegra->soc; + const struct tegra_soctherm_soc *soc = tegra->soc; int err, i; err = soctherm_clk_enable(tegra, true); From patchwork Fri Apr 14 12:57:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 13211449 X-Patchwork-Delegate: daniel.lezcano@linaro.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 28128C7EE20 for ; Fri, 14 Apr 2023 12:58:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230313AbjDNM6B (ORCPT ); Fri, 14 Apr 2023 08:58:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230229AbjDNM56 (ORCPT ); Fri, 14 Apr 2023 08:57:58 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D82DBB46F; Fri, 14 Apr 2023 05:57:33 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id w24so7805103wra.10; Fri, 14 Apr 2023 05:57:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681477051; x=1684069051; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9FjuQyxE6PbfpJxzLBZ3ivqNaKU/XIl3CzS5rxOJdxk=; b=oalyN7EcFY8cdMg1zKCRVPOZh1XVXojCezIfjmO25M7pXXKm0qCI18bfUaFhOtyUhO 8I2L/S6A/POwTVz0UekwWjyeygexm8kjHU2NrVnDCBsCxz2zwguAajmxOGr04HAxZFB0 wZ2p8HUBHetBGpjvH7/QIQ+iq/oEbaTq6GEGo8K13unP4wIHPXRlA+bIiyhAjZfv/Qxg cwo5e1265Jc4ppa5jMT46FNvY678ruu1HjMC6R9FOh6s+lQyDMza9834krYk0Owzcwvk O1QJzIN5kF0tz+vYrcLq/Ar+4Hz1n0/faCAMv+0+RtImkYy5wRKXk6Mx+dwNFiBwqVcd WiRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681477051; x=1684069051; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9FjuQyxE6PbfpJxzLBZ3ivqNaKU/XIl3CzS5rxOJdxk=; b=KRRxwuB5ne/mUtNmrt5fZh5BICVl0D8qM/VEgzqUFs7PM+zsXFLpre4r/svVhnGoG8 JyAV0Rv98qazypLjslLXuO949Lym/CXqsBDmKmRhk4Ctxc+CqWIE1/PDnXflKE3mnuxi NZ+7JBSO4CXe+ddUHJn8sr+XUa79jaJngTIWxod7sTjCvH2jeJFxbDNSSgIh2zodElvG ueoJUeom07mpy9s9IJ+m84IZxh+eGcHdKLFnJmduSJe+e8TOqO2at+4PlSSM2OhPoTCn hU6StW2WofZBFhyZlIPnGV5Ia6YyWubXy7I0n+8z61w6BYpfvGwQ6EQd3gCqvnjpeEhy mvHw== X-Gm-Message-State: AAQBX9c6qeOeke94om2UfqkC1oSuWbHeBnmY7PoyPPclUsKVhYU/6F5y 9awB7okllWiRAgWsM9Phpac= X-Google-Smtp-Source: AKy350aNl4zMXNHIJD6sXK33P90cQPuQcvk3Lzbzli80+Ki9sXMlkX4qI1z1PzCQ2b+U7W6mnCM7ow== X-Received: by 2002:adf:e5cc:0:b0:2ef:b6e6:5985 with SMTP id a12-20020adfe5cc000000b002efb6e65985mr4388493wrn.58.1681477050774; Fri, 14 Apr 2023 05:57:30 -0700 (PDT) Received: from localhost (p200300e41f1c0800f22f74fffe1f3a53.dip0.t-ipconnect.de. [2003:e4:1f1c:800:f22f:74ff:fe1f:3a53]) by smtp.gmail.com with ESMTPSA id s9-20020a5d6a89000000b002cf1c435afcsm3532875wru.11.2023.04.14.05.57.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 05:57:30 -0700 (PDT) From: Thierry Reding To: Daniel Lezcano , "Rafael J . Wysocki" , Thierry Reding , Rob Herring , Krzysztof Kozlowski Cc: Amit Kucheria , Zhang Rui , Jon Hunter , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-tegra@vger.kernel.org Subject: [PATCH 04/10] thermal: tegra: Do not register cooling device Date: Fri, 14 Apr 2023 14:57:15 +0200 Message-Id: <20230414125721.1043589-5-thierry.reding@gmail.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230414125721.1043589-1-thierry.reding@gmail.com> References: <20230414125721.1043589-1-thierry.reding@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Thierry Reding The SOCTHERM's built-in throttling mechanism doesn't map well to the concept of a cooling device because it will automatically start to throttle when the programmed temperature threshold is crossed. Remove the cooling device implementation and instead unconditionally program the throttling for the CPU and GPU thermal zones. Signed-off-by: Thierry Reding --- drivers/thermal/tegra/soctherm.c | 148 +++------------------- drivers/thermal/tegra/soctherm.h | 1 + drivers/thermal/tegra/tegra124-soctherm.c | 4 + drivers/thermal/tegra/tegra132-soctherm.c | 4 + drivers/thermal/tegra/tegra210-soctherm.c | 4 + 5 files changed, 33 insertions(+), 128 deletions(-) diff --git a/drivers/thermal/tegra/soctherm.c b/drivers/thermal/tegra/soctherm.c index 958fa10de516..eb12e8cc0a2f 100644 --- a/drivers/thermal/tegra/soctherm.c +++ b/drivers/thermal/tegra/soctherm.c @@ -317,11 +317,11 @@ struct soctherm_throt_cfg { const char *name; unsigned int id; u8 priority; + int temperature; u8 cpu_throt_level; u32 cpu_throt_depth; u32 gpu_throt_level; struct soctherm_oc_cfg oc_cfg; - struct thermal_cooling_device *cdev; bool init; }; @@ -606,25 +606,6 @@ static int tegra_thermctl_set_trip_temp(struct thermal_zone_device *tz, int trip return thermtrip_program(ts, sg, temp); else return 0; - - } else if (trip.type == THERMAL_TRIP_HOT) { - int i; - - for (i = 0; i < THROTTLE_SIZE; i++) { - struct thermal_cooling_device *cdev; - struct soctherm_throt_cfg *stc; - - if (!ts->throt_cfgs[i].init) - continue; - - cdev = ts->throt_cfgs[i].cdev; - if (get_thermal_instance(tz, cdev, trip_id)) - stc = find_throttle_cfg_by_name(ts, cdev->type); - else - continue; - - return throttrip_program(ts, sg, stc, temp); - } } return 0; @@ -685,26 +666,6 @@ static const struct thermal_zone_device_ops tegra_of_thermal_ops = { .set_trips = tegra_thermctl_set_trips, }; -static int get_hot_temp(struct thermal_zone_device *tz, int *trip_id, int *temp) -{ - int i, ret; - struct thermal_trip trip; - - for (i = 0; i < thermal_zone_get_num_trips(tz); i++) { - - ret = thermal_zone_get_trip(tz, i, &trip); - if (ret) - return -EINVAL; - - if (trip.type == THERMAL_TRIP_HOT) { - *trip_id = i; - return 0; - } - } - - return -EINVAL; -} - /** * tegra_soctherm_set_hwtrips() - set HW trip point from DT data * @dev: struct device * of the SOC_THERM instance @@ -734,7 +695,7 @@ static int tegra_soctherm_set_hwtrips(struct tegra_soctherm *ts, struct thermal_zone_device *tz) { struct soctherm_throt_cfg *stc; - int i, trip, temperature, ret; + int temperature, ret; /* Get thermtrips. If missing, try to get critical trips. */ temperature = tsensor_group_thermtrip_get(ts, sg->id); @@ -752,42 +713,19 @@ static int tegra_soctherm_set_hwtrips(struct tegra_soctherm *ts, dev_info(ts->dev, "thermtrip: will shut down when %s reaches %d mC\n", sg->name, temperature); - ret = get_hot_temp(tz, &trip, &temperature); - if (ret) { - dev_info(ts->dev, "throttrip: %s: missing hot temperature\n", - sg->name); - return 0; - } - - for (i = 0; i < THROTTLE_OC1; i++) { - struct thermal_cooling_device *cdev; - - if (!ts->throt_cfgs[i].init) - continue; - - cdev = ts->throt_cfgs[i].cdev; - if (get_thermal_instance(tz, cdev, trip)) - stc = find_throttle_cfg_by_name(ts, cdev->type); - else - continue; - - ret = throttrip_program(ts, sg, stc, temperature); - if (ret) { - dev_err(ts->dev, "throttrip: %s: error during enable\n", - sg->name); - return ret; + /* if configured, program the pulse skipper for CPU and GPU zones */ + if (sg->can_throttle) { + stc = find_throttle_cfg_by_name(ts, "heavy"); + if (stc && stc->init) { + ret = throttrip_program(ts, sg, stc, temperature); + if (ret) { + dev_err(ts->dev, + "throttrip: %s: failed to enable: %d\n", + sg->name, ret); + } } - - dev_info(ts->dev, - "throttrip: will throttle when %s reaches %d mC\n", - sg->name, temperature); - break; } - if (i == THROTTLE_SIZE) - dev_info(ts->dev, "throttrip: %s: missing throttle cdev\n", - sg->name); - return 0; } @@ -1494,40 +1432,6 @@ static int soctherm_clk_enable(struct tegra_soctherm *tegra, bool enable) return 0; } -static int throt_get_cdev_max_state(struct thermal_cooling_device *cdev, - unsigned long *max_state) -{ - *max_state = 1; - return 0; -} - -static int throt_get_cdev_cur_state(struct thermal_cooling_device *cdev, - unsigned long *cur_state) -{ - struct tegra_soctherm *ts = cdev->devdata; - u32 r; - - r = readl(ts->regs + THROT_STATUS); - if (REG_GET_MASK(r, THROT_STATUS_STATE_MASK)) - *cur_state = 1; - else - *cur_state = 0; - - return 0; -} - -static int throt_set_cdev_state(struct thermal_cooling_device *cdev, - unsigned long cur_state) -{ - return 0; -} - -static const struct thermal_cooling_device_ops throt_cooling_ops = { - .get_max_state = throt_get_cdev_max_state, - .get_cur_state = throt_get_cdev_cur_state, - .set_cur_state = throt_set_cdev_state, -}; - static int soctherm_thermtrips_parse(struct tegra_soctherm *ts) { struct tsensor_group_thermtrips *tt = ts->soc->thermtrips; @@ -1633,6 +1537,10 @@ static int soctherm_throt_cfg_parse(struct tegra_soctherm *ts, else goto err; + ret = of_property_read_u32(np, "temperature", &stc->temperature); + if (ret < 0) + goto err; + return 0; err: @@ -1642,14 +1550,12 @@ static int soctherm_throt_cfg_parse(struct tegra_soctherm *ts, } /** - * soctherm_init_hw_throt_cdev() - Parse the HW throttle configurations - * and register them as cooling devices. + * soctherm_init_hw_throttling() - parse the HW throttle configurations * @tegra: pointer to Tegra soctherm structure */ -static void soctherm_init_hw_throt_cdev(struct tegra_soctherm *tegra) +static void soctherm_init_hw_throttling(struct tegra_soctherm *tegra) { struct device_node *np_stc, *np_stcc; - const char *name; int i; for (i = 0; i < THROTTLE_SIZE; i++) { @@ -1666,11 +1572,10 @@ static void soctherm_init_hw_throt_cdev(struct tegra_soctherm *tegra) } for_each_child_of_node(np_stc, np_stcc) { + const char *name = np_stcc->name; struct soctherm_throt_cfg *stc; - struct thermal_cooling_device *tcd; int err; - name = np_stcc->name; stc = find_throttle_cfg_by_name(tegra, name); if (!stc) { dev_err(tegra->dev, "throttle-cfg: could not find %s\n", @@ -1692,19 +1597,6 @@ static void soctherm_init_hw_throt_cdev(struct tegra_soctherm *tegra) if (stc->id >= THROTTLE_OC1) { soctherm_oc_cfg_parse(tegra, np_stcc, stc); stc->init = true; - } else { - - tcd = thermal_of_cooling_device_register(np_stcc, - (char *)name, tegra, - &throt_cooling_ops); - if (IS_ERR_OR_NULL(tcd)) { - dev_err(tegra->dev, - "throttle-cfg: %s: failed to register cooling device\n", - name); - continue; - } - stc->cdev = tcd; - stc->init = true; } } @@ -2148,7 +2040,7 @@ static int tegra_soctherm_probe(struct platform_device *pdev) soctherm_thermtrips_parse(tegra); - soctherm_init_hw_throt_cdev(tegra); + soctherm_init_hw_throttling(tegra); soctherm_init(tegra); diff --git a/drivers/thermal/tegra/soctherm.h b/drivers/thermal/tegra/soctherm.h index 70501e73d586..894bee5d96c5 100644 --- a/drivers/thermal/tegra/soctherm.h +++ b/drivers/thermal/tegra/soctherm.h @@ -83,6 +83,7 @@ struct tegra_tsensor_group { u16 thermctl_lvl0_offset; u32 thermctl_lvl0_up_thresh_mask; u32 thermctl_lvl0_dn_thresh_mask; + bool can_throttle; }; struct tegra_tsensor_configuration { diff --git a/drivers/thermal/tegra/tegra124-soctherm.c b/drivers/thermal/tegra/tegra124-soctherm.c index 20ad27f4d1a1..7b11fa8fb533 100644 --- a/drivers/thermal/tegra/tegra124-soctherm.c +++ b/drivers/thermal/tegra/tegra124-soctherm.c @@ -60,6 +60,7 @@ static const struct tegra_tsensor_group tegra124_tsensor_group_cpu = { .thermctl_lvl0_offset = THERMCTL_LEVEL0_GROUP_CPU, .thermctl_lvl0_up_thresh_mask = TEGRA124_THERMCTL_LVL0_UP_THRESH_MASK, .thermctl_lvl0_dn_thresh_mask = TEGRA124_THERMCTL_LVL0_DN_THRESH_MASK, + .can_throttle = true, }; static const struct tegra_tsensor_group tegra124_tsensor_group_gpu = { @@ -79,6 +80,7 @@ static const struct tegra_tsensor_group tegra124_tsensor_group_gpu = { .thermctl_lvl0_offset = THERMCTL_LEVEL0_GROUP_GPU, .thermctl_lvl0_up_thresh_mask = TEGRA124_THERMCTL_LVL0_UP_THRESH_MASK, .thermctl_lvl0_dn_thresh_mask = TEGRA124_THERMCTL_LVL0_DN_THRESH_MASK, + .can_throttle = true, }; static const struct tegra_tsensor_group tegra124_tsensor_group_pll = { @@ -96,6 +98,7 @@ static const struct tegra_tsensor_group tegra124_tsensor_group_pll = { .thermctl_lvl0_offset = THERMCTL_LEVEL0_GROUP_TSENSE, .thermctl_lvl0_up_thresh_mask = TEGRA124_THERMCTL_LVL0_UP_THRESH_MASK, .thermctl_lvl0_dn_thresh_mask = TEGRA124_THERMCTL_LVL0_DN_THRESH_MASK, + .can_throttle = false, }; static const struct tegra_tsensor_group tegra124_tsensor_group_mem = { @@ -115,6 +118,7 @@ static const struct tegra_tsensor_group tegra124_tsensor_group_mem = { .thermctl_lvl0_offset = THERMCTL_LEVEL0_GROUP_MEM, .thermctl_lvl0_up_thresh_mask = TEGRA124_THERMCTL_LVL0_UP_THRESH_MASK, .thermctl_lvl0_dn_thresh_mask = TEGRA124_THERMCTL_LVL0_DN_THRESH_MASK, + .can_throttle = false, }; static const struct tegra_tsensor_group *tegra124_tsensor_groups[] = { diff --git a/drivers/thermal/tegra/tegra132-soctherm.c b/drivers/thermal/tegra/tegra132-soctherm.c index b76308fdad9e..304561fe9110 100644 --- a/drivers/thermal/tegra/tegra132-soctherm.c +++ b/drivers/thermal/tegra/tegra132-soctherm.c @@ -60,6 +60,7 @@ static const struct tegra_tsensor_group tegra132_tsensor_group_cpu = { .thermctl_lvl0_offset = THERMCTL_LEVEL0_GROUP_CPU, .thermctl_lvl0_up_thresh_mask = TEGRA132_THERMCTL_LVL0_UP_THRESH_MASK, .thermctl_lvl0_dn_thresh_mask = TEGRA132_THERMCTL_LVL0_DN_THRESH_MASK, + .can_throttle = true, }; static const struct tegra_tsensor_group tegra132_tsensor_group_gpu = { @@ -79,6 +80,7 @@ static const struct tegra_tsensor_group tegra132_tsensor_group_gpu = { .thermctl_lvl0_offset = THERMCTL_LEVEL0_GROUP_GPU, .thermctl_lvl0_up_thresh_mask = TEGRA132_THERMCTL_LVL0_UP_THRESH_MASK, .thermctl_lvl0_dn_thresh_mask = TEGRA132_THERMCTL_LVL0_DN_THRESH_MASK, + .can_throttle = true, }; static const struct tegra_tsensor_group tegra132_tsensor_group_pll = { @@ -96,6 +98,7 @@ static const struct tegra_tsensor_group tegra132_tsensor_group_pll = { .thermctl_lvl0_offset = THERMCTL_LEVEL0_GROUP_TSENSE, .thermctl_lvl0_up_thresh_mask = TEGRA132_THERMCTL_LVL0_UP_THRESH_MASK, .thermctl_lvl0_dn_thresh_mask = TEGRA132_THERMCTL_LVL0_DN_THRESH_MASK, + .can_throttle = false, }; static const struct tegra_tsensor_group tegra132_tsensor_group_mem = { @@ -115,6 +118,7 @@ static const struct tegra_tsensor_group tegra132_tsensor_group_mem = { .thermctl_lvl0_offset = THERMCTL_LEVEL0_GROUP_MEM, .thermctl_lvl0_up_thresh_mask = TEGRA132_THERMCTL_LVL0_UP_THRESH_MASK, .thermctl_lvl0_dn_thresh_mask = TEGRA132_THERMCTL_LVL0_DN_THRESH_MASK, + .can_throttle = false, }; static const struct tegra_tsensor_group *tegra132_tsensor_groups[] = { diff --git a/drivers/thermal/tegra/tegra210-soctherm.c b/drivers/thermal/tegra/tegra210-soctherm.c index d0ff793f18c5..6277a8e12b8a 100644 --- a/drivers/thermal/tegra/tegra210-soctherm.c +++ b/drivers/thermal/tegra/tegra210-soctherm.c @@ -61,6 +61,7 @@ static const struct tegra_tsensor_group tegra210_tsensor_group_cpu = { .thermctl_lvl0_offset = THERMCTL_LEVEL0_GROUP_CPU, .thermctl_lvl0_up_thresh_mask = TEGRA210_THERMCTL_LVL0_UP_THRESH_MASK, .thermctl_lvl0_dn_thresh_mask = TEGRA210_THERMCTL_LVL0_DN_THRESH_MASK, + .can_throttle = true, }; static const struct tegra_tsensor_group tegra210_tsensor_group_gpu = { @@ -80,6 +81,7 @@ static const struct tegra_tsensor_group tegra210_tsensor_group_gpu = { .thermctl_lvl0_offset = THERMCTL_LEVEL0_GROUP_GPU, .thermctl_lvl0_up_thresh_mask = TEGRA210_THERMCTL_LVL0_UP_THRESH_MASK, .thermctl_lvl0_dn_thresh_mask = TEGRA210_THERMCTL_LVL0_DN_THRESH_MASK, + .can_throttle = true, }; static const struct tegra_tsensor_group tegra210_tsensor_group_pll = { @@ -97,6 +99,7 @@ static const struct tegra_tsensor_group tegra210_tsensor_group_pll = { .thermctl_lvl0_offset = THERMCTL_LEVEL0_GROUP_TSENSE, .thermctl_lvl0_up_thresh_mask = TEGRA210_THERMCTL_LVL0_UP_THRESH_MASK, .thermctl_lvl0_dn_thresh_mask = TEGRA210_THERMCTL_LVL0_DN_THRESH_MASK, + .can_throttle = false, }; static const struct tegra_tsensor_group tegra210_tsensor_group_mem = { @@ -116,6 +119,7 @@ static const struct tegra_tsensor_group tegra210_tsensor_group_mem = { .thermctl_lvl0_offset = THERMCTL_LEVEL0_GROUP_MEM, .thermctl_lvl0_up_thresh_mask = TEGRA210_THERMCTL_LVL0_UP_THRESH_MASK, .thermctl_lvl0_dn_thresh_mask = TEGRA210_THERMCTL_LVL0_DN_THRESH_MASK, + .can_throttle = false, }; static const struct tegra_tsensor_group *tegra210_tsensor_groups[] = { From patchwork Fri Apr 14 12:57:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 13211445 X-Patchwork-Delegate: daniel.lezcano@linaro.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2C9CC77B77 for ; Fri, 14 Apr 2023 12:58:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230211AbjDNM6A (ORCPT ); Fri, 14 Apr 2023 08:58:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230225AbjDNM56 (ORCPT ); Fri, 14 Apr 2023 08:57:58 -0400 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7A48B46E; Fri, 14 Apr 2023 05:57:33 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id l18so17339582wrb.9; Fri, 14 Apr 2023 05:57:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681477052; x=1684069052; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=V9pPG1OjYyEL7kO5yYxLJmvkbxiHIdIeQSpBsx+hCOU=; b=kQaJ7QgsbOqWgtJ15q+8DkBZ+48TChGVap0TBGLSr+8s5PWnQvaSUKoA7WF+EEPhev ObIcpXsum6Lt74A4JULtF1jrzPgMVxsb0l/INe6rypOMY5ynTO5omcZYLtvhYpNQCocp fQqV0aBeqwlFSz1c7S2LjlMXjwbLb/N82xg+bmI2Fc7k44DIR2QFRqst6UK2qbuR7/od Aj22785Z6lAoo8u2ojgjX74u7slvAp43i9gYaAjelfdJdgGoJZlKxT1Vsymnr6GM0k47 4DNDY8kUE9IAQiWIMVvB+lzG1DhOzNt27kmrPY03oG+MugIZYLLGHkx5Nc5GzQ4ykbUM Ne+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681477052; x=1684069052; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=V9pPG1OjYyEL7kO5yYxLJmvkbxiHIdIeQSpBsx+hCOU=; b=h+RWRTYoXHMpyNzixXQ96OD9+0Ql7onjMV9CZYNcTtwsySdI4HXmRjqPKnG7w/lkaP jM4XHPJDth8swR3r4a7z9rGTymdwQW1Bk/AOvtXb6vrZNPJpclAapxsoWX0JKfoK3aXG FrQMuKToNTHePwzSMBsMkxar2YKJWziOQSkhON832Q5mMa6PeuzqbGfUgYwlPxrY9o8t p1qae2vAPEtwIDIYLt6NEorYrETie+HdpljDUHwqSedhXrfQLE0Ux2fDN4ALutSbP4ls noOOjwXWaPpCV8/8rO9teeIwO3S9qvNmK9Aw9+cDnLJT6/udt52bpx+Et14og4JcVEz0 CGcA== X-Gm-Message-State: AAQBX9cZaNimF1EG8iMkjA+vnA0sxxTKAHRVdyhK3COig8OAd1y1ausI 4oa5AO0VcC8UCLYHPXEbOK8= X-Google-Smtp-Source: AKy350a4O9nfwcQIEYjlFeCGsF4GeEnqQdrpDwxUqdbib6eeOfAvfYgoy4cB0c/A70Uktqsmcvdc8A== X-Received: by 2002:a5d:45c7:0:b0:2e5:1da2:2a06 with SMTP id b7-20020a5d45c7000000b002e51da22a06mr4065996wrs.5.1681477051751; Fri, 14 Apr 2023 05:57:31 -0700 (PDT) Received: from localhost (p200300e41f1c0800f22f74fffe1f3a53.dip0.t-ipconnect.de. [2003:e4:1f1c:800:f22f:74ff:fe1f:3a53]) by smtp.gmail.com with ESMTPSA id b15-20020adfe64f000000b002f00793bd7asm3512111wrn.27.2023.04.14.05.57.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 05:57:31 -0700 (PDT) From: Thierry Reding To: Daniel Lezcano , "Rafael J . Wysocki" , Thierry Reding , Rob Herring , Krzysztof Kozlowski Cc: Amit Kucheria , Zhang Rui , Jon Hunter , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-tegra@vger.kernel.org Subject: [PATCH 05/10] thermal: tegra: Use unsigned int where appropriate Date: Fri, 14 Apr 2023 14:57:16 +0200 Message-Id: <20230414125721.1043589-6-thierry.reding@gmail.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230414125721.1043589-1-thierry.reding@gmail.com> References: <20230414125721.1043589-1-thierry.reding@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Thierry Reding Use unsigned integers more consistently, which helps to make it more explicit about what values can be expected. Signed-off-by: Thierry Reding --- drivers/thermal/tegra/soctherm.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/drivers/thermal/tegra/soctherm.c b/drivers/thermal/tegra/soctherm.c index eb12e8cc0a2f..730b034004cb 100644 --- a/drivers/thermal/tegra/soctherm.c +++ b/drivers/thermal/tegra/soctherm.c @@ -565,8 +565,9 @@ find_throttle_cfg_by_name(struct tegra_soctherm *ts, const char *name) static int tsensor_group_thermtrip_get(struct tegra_soctherm *ts, int id) { - int i, temp = min_low_temp; struct tsensor_group_thermtrips *tt = ts->soc->thermtrips; + int temp = min_low_temp; + unsigned int i; if (id >= TEGRA124_SOCTHERM_SENSOR_NUM) return temp; @@ -1436,33 +1437,34 @@ static int soctherm_thermtrips_parse(struct tegra_soctherm *ts) { struct tsensor_group_thermtrips *tt = ts->soc->thermtrips; const int max_num_prop = ts->soc->num_ttgs * 2; + unsigned int i, j, count; u32 *tlb; - int i, j, n, ret; + int ret; if (!tt) return -ENOMEM; - n = of_property_count_u32_elems(ts->dev->of_node, "nvidia,thermtrips"); - if (n <= 0) { + ret = of_property_count_u32_elems(ts->dev->of_node, "nvidia,thermtrips"); + if (ret <= 0) { dev_info(ts->dev, - "missing thermtrips, will use critical trips as shut down temp\n"); - return n; + "missing thermtrips, will use critical trips as shut down temperature\n"); + return ret; } - n = min(max_num_prop, n); + count = min_t(unsigned int, ret, ts->soc->num_ttgs * 2); tlb = devm_kcalloc(ts->dev, max_num_prop, sizeof(u32), GFP_KERNEL); if (!tlb) return -ENOMEM; + ret = of_property_read_u32_array(ts->dev->of_node, "nvidia,thermtrips", - tlb, n); + tlb, count); if (ret) { dev_err(ts->dev, "invalid num ele: thermtrips:%d\n", ret); return ret; } - i = 0; - for (j = 0; j < n; j = j + 2) { + for (i = 0, j = 0; j < count; j = j + 2) { if (tlb[j] >= TEGRA124_SOCTHERM_SENSOR_NUM) continue; @@ -1556,7 +1558,7 @@ static int soctherm_throt_cfg_parse(struct tegra_soctherm *ts, static void soctherm_init_hw_throttling(struct tegra_soctherm *tegra) { struct device_node *np_stc, *np_stcc; - int i; + unsigned int i; for (i = 0; i < THROTTLE_SIZE; i++) { tegra->throt_cfgs[i].name = throt_names[i]; @@ -1819,8 +1821,8 @@ static void soctherm_throttle_program(struct tegra_soctherm *ts, static void tegra_soctherm_throttle(struct tegra_soctherm *ts) { + unsigned int i; u32 v; - int i; /* configure LOW, MED and HIGH levels for CCROC NV_THERM */ if (ts->soc->use_ccroc) { @@ -1894,8 +1896,8 @@ static int soctherm_interrupts_init(struct tegra_soctherm *tegra) static void soctherm_init(struct tegra_soctherm *tegra) { const struct tegra_tsensor_group **ttgs = tegra->soc->ttgs; - int i; u32 pdiv, hotspot; + unsigned int i; /* Initialize raw sensors */ for (i = 0; i < tegra->soc->num_tsensors; ++i) From patchwork Fri Apr 14 12:57:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 13211446 X-Patchwork-Delegate: daniel.lezcano@linaro.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2A25DC77B78 for ; Fri, 14 Apr 2023 12:58:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230286AbjDNM6B (ORCPT ); Fri, 14 Apr 2023 08:58:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229847AbjDNM57 (ORCPT ); Fri, 14 Apr 2023 08:57:59 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CBFAB741; Fri, 14 Apr 2023 05:57:35 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id bd13-20020a05600c1f0d00b003f14c42cc99so536961wmb.2; Fri, 14 Apr 2023 05:57:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681477053; x=1684069053; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=R1g6kj74AkM9jNZdPSLLTF4OlvwI6sCwkaDV/qucOx0=; b=TLLnDGHtgAPw/ZieA+Dxx6OioK5HZByNOO7b8+Rhxc4N2VW5fxeTLsRIo3iE7Oq3Z9 e/eHXgoydknFyFHu5ncrc6yeTdRwYL6O7ZMiPCRIcHKg+RXOIwMc2YkhVIxleVWwtbda ln1S5+Cxh1fKe42e3DK+GEXp4j2gH/PnxU2yOFwCqTyjtlFG3ePYncp0alKdKaSvQ1sI sgwQruKi6+8Ge6RL3wteUfcSGA4GkURqPUkwusI/rfsL4l1VVRe/qqxuMIqbvFaWGtYy aNUgrrqBYAdVId8qSr7rMPmPlg9ALnH0bYB3t5vE+OcwJA3gtCIVG4f4/bWURNoVHCxT ktQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681477053; x=1684069053; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=R1g6kj74AkM9jNZdPSLLTF4OlvwI6sCwkaDV/qucOx0=; b=c3sqdqCSl9r093CxLcYHpJhLqn4OTO0XNFYhmhUp7C6GL9KJQR5Bacrm6cpuCrzhKb PPrTRO2ucjDMhQFEbrLAZgZRKOEsUbRDO/YKJLeYiGc0tcLu2WdFw/qjpffc2u60xy5s LqjhN2YelmdV45ZLb1ZuJ1D6H6zj3e2hNC9ZYO9qGg+9laLniK07ulSeoxCmxy0n0mg2 idx+qYylhGyEXLV2B2f+JrkF2Hj9jEZJjDw17mtn71qpC4M1ftN+qvu0Xo/v+Oq86Eqv bsbWoLtp+D0uxrjgeIq3ZGGUM6xJJIujw69CsShI+lGyKA9+jOPCNzeZ5eG+kNSRelWZ +GLw== X-Gm-Message-State: AAQBX9c/JKJOFGfShtzhx41VlVJJXQkuThTUPhhChq11gQQ3x5noXwck MIQFm5hPw1Ev9ri50S4OdHw= X-Google-Smtp-Source: AKy350a1j6nYJKAO6kuCTeMuQbSJOYukzAlO5dyg/KS+FnEP7KGHzLv4EdmH3zh989LpEDkDbCRgcA== X-Received: by 2002:a7b:c008:0:b0:3dc:5b88:e6dd with SMTP id c8-20020a7bc008000000b003dc5b88e6ddmr4475239wmb.10.1681477052743; Fri, 14 Apr 2023 05:57:32 -0700 (PDT) Received: from localhost (p200300e41f1c0800f22f74fffe1f3a53.dip0.t-ipconnect.de. [2003:e4:1f1c:800:f22f:74ff:fe1f:3a53]) by smtp.gmail.com with ESMTPSA id c8-20020a05600c0a4800b003ee5fa61f45sm8044218wmq.3.2023.04.14.05.57.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 05:57:32 -0700 (PDT) From: Thierry Reding To: Daniel Lezcano , "Rafael J . Wysocki" , Thierry Reding , Rob Herring , Krzysztof Kozlowski Cc: Amit Kucheria , Zhang Rui , Jon Hunter , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-tegra@vger.kernel.org Subject: [PATCH 06/10] thermal: tegra: Avoid over-allocation of temporary array Date: Fri, 14 Apr 2023 14:57:17 +0200 Message-Id: <20230414125721.1043589-7-thierry.reding@gmail.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230414125721.1043589-1-thierry.reding@gmail.com> References: <20230414125721.1043589-1-thierry.reding@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Thierry Reding The code will attempt to read "count" entries from DT, but the code allocates the maximum number that is possible, potentially over- allocating the array. Use the actual number of entries when allocating. Signed-off-by: Thierry Reding --- drivers/thermal/tegra/soctherm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/tegra/soctherm.c b/drivers/thermal/tegra/soctherm.c index 730b034004cb..16fa00fa0839 100644 --- a/drivers/thermal/tegra/soctherm.c +++ b/drivers/thermal/tegra/soctherm.c @@ -1436,7 +1436,6 @@ static int soctherm_clk_enable(struct tegra_soctherm *tegra, bool enable) static int soctherm_thermtrips_parse(struct tegra_soctherm *ts) { struct tsensor_group_thermtrips *tt = ts->soc->thermtrips; - const int max_num_prop = ts->soc->num_ttgs * 2; unsigned int i, j, count; u32 *tlb; int ret; @@ -1453,7 +1452,7 @@ static int soctherm_thermtrips_parse(struct tegra_soctherm *ts) count = min_t(unsigned int, ret, ts->soc->num_ttgs * 2); - tlb = devm_kcalloc(ts->dev, max_num_prop, sizeof(u32), GFP_KERNEL); + tlb = devm_kcalloc(ts->dev, count, sizeof(u32), GFP_KERNEL); if (!tlb) return -ENOMEM; @@ -1473,6 +1472,8 @@ static int soctherm_thermtrips_parse(struct tegra_soctherm *ts) i++; } + devm_kfree(ts->dev, tlb); + return 0; } From patchwork Fri Apr 14 12:57:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 13211447 X-Patchwork-Delegate: daniel.lezcano@linaro.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0323BC77B7F for ; Fri, 14 Apr 2023 12:58:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230348AbjDNM6C (ORCPT ); Fri, 14 Apr 2023 08:58:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230316AbjDNM6B (ORCPT ); Fri, 14 Apr 2023 08:58:01 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7DE22AF3E; Fri, 14 Apr 2023 05:57:35 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id q6so5940736wrc.3; Fri, 14 Apr 2023 05:57:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681477054; x=1684069054; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9tgm3k/JiwpNenl3OoVPG2vmqD9LEJ/mJhxEqONmm5Y=; b=F4b1zNjwqh/Arkm8TkJlrCyxNkBjTVRAO7IF9pLG3xI5fpFifQyZYCGuV+XVjACN1M 0ijwtm8q8WfmiA3OqODMOcSlJaQnIKQlO/3fDYXUaSHaV95Fh118qTW9S9kpxCpfnpbT zpZ4UiNqHBdg/mnt/tUrqyErmuAAz7b7RDrJ/eaYLwVpJxexh1+iL7o1k4oOUC66g3UP XUr3qyi0qk38atgWJc6VCcDeG8XHKWzmZiTin+zzNmm9H3PQOh2XX7PXq1irexL0snci X305g2RDgAyJM2OBpSLb/gJ55/ohUdAbdoXILhVvdz/OQK8TaMcWmgvxum0v4Kx1B7/7 SQqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681477054; x=1684069054; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9tgm3k/JiwpNenl3OoVPG2vmqD9LEJ/mJhxEqONmm5Y=; b=LEbjISG20j9YgUQqJf+I6y2kE7/iwJibpcYaCQWlOILNrgg7YCuy6/LolpqQlTwBx+ Mn4qtF0naBpggzVVFCXAEZE6YPn2ndDbtxcO/BQ0V2iWyfBG6kIV+p85s7AqdmZFFPZq c6bTqoDBNgjIMEqhMq3BK6NtOQoAHYnxehuOAavDKBgVR+AdiGK1mVoALRBLfIEKGbsO AULXmYMnNobsCOdWhfZOucBHBFZ8Cmc+/Vm4elSJaJAQAKVMJ0homySRe2znkb8Iy3sW L3rkCxtCuogzY2KqVv8czd5Wt10zI63VDxlUUGhoJA4cvsYOIE0xyQR3P5LbMkD02YVN Rk0Q== X-Gm-Message-State: AAQBX9fJWaEA17LJQZ1pYLzCRLIP91gTWcPTcD1RtdGC9UDcL6dSGgQq WSPkg8bNaWz4FhdUF9xQvt8= X-Google-Smtp-Source: AKy350ZRIXZaqYaswFy2+vnD2nmYKjbjlF45hQSBOeh9aqpEdozYlbR4qfh5xTtml2DFRUTbeIJHcg== X-Received: by 2002:a5d:640b:0:b0:2f6:4c9c:6b2a with SMTP id z11-20020a5d640b000000b002f64c9c6b2amr3466419wru.0.1681477053697; Fri, 14 Apr 2023 05:57:33 -0700 (PDT) Received: from localhost (p200300e41f1c0800f22f74fffe1f3a53.dip0.t-ipconnect.de. [2003:e4:1f1c:800:f22f:74ff:fe1f:3a53]) by smtp.gmail.com with ESMTPSA id p13-20020a5d4e0d000000b002f4cf72fce6sm3529473wrt.46.2023.04.14.05.57.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 05:57:33 -0700 (PDT) From: Thierry Reding To: Daniel Lezcano , "Rafael J . Wysocki" , Thierry Reding , Rob Herring , Krzysztof Kozlowski Cc: Amit Kucheria , Zhang Rui , Jon Hunter , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-tegra@vger.kernel.org Subject: [PATCH 07/10] thermal: tegra: Remove gratuitous error assignment Date: Fri, 14 Apr 2023 14:57:18 +0200 Message-Id: <20230414125721.1043589-8-thierry.reding@gmail.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230414125721.1043589-1-thierry.reding@gmail.com> References: <20230414125721.1043589-1-thierry.reding@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Thierry Reding Interrupts are optional, so errors during their initialization are ignored. However, the code confusingly stores the error code and makes it looks like it is somehow relevant. Remove the gratuitous assignment to make it clearer that these errors are being purposefully ignored. Signed-off-by: Thierry Reding --- drivers/thermal/tegra/soctherm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/thermal/tegra/soctherm.c b/drivers/thermal/tegra/soctherm.c index 16fa00fa0839..b6e61393fb8f 100644 --- a/drivers/thermal/tegra/soctherm.c +++ b/drivers/thermal/tegra/soctherm.c @@ -2078,8 +2078,7 @@ static int tegra_soctherm_probe(struct platform_device *pdev) goto disable_clocks; } - err = soctherm_interrupts_init(tegra); - + soctherm_interrupts_init(tegra); soctherm_debug_init(tegra); return 0; From patchwork Fri Apr 14 12:57:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 13211448 X-Patchwork-Delegate: daniel.lezcano@linaro.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0037C77B6E for ; Fri, 14 Apr 2023 12:58:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230364AbjDNM6D (ORCPT ); Fri, 14 Apr 2023 08:58:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230229AbjDNM6C (ORCPT ); Fri, 14 Apr 2023 08:58:02 -0400 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DEA0269E; Fri, 14 Apr 2023 05:57:36 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id he11-20020a05600c540b00b003ef6d684102so8198448wmb.3; Fri, 14 Apr 2023 05:57:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681477054; x=1684069054; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lZSnA9V82lqicVJGiNFqWTCI4618K2puWAelw0l2AMA=; b=eGQKkP65wDojg6CW+4mQy90XuO5RjVA/nIqhc55r9E7GHARoNDdSczIP5Aba23zkno BCSYC9Fo1Lj6vcTEiUo1FIrBK7b3cgYx8nlMXv6m7/gVAew4ibtRx3AUaN6kr3OLO5v2 kme0o7cG+d7oKiOR7TDNENGui1Kb1/VF/BQCzQKw0fRzb+VbxFIvUbSuUzGB8Cd+p1JC F8Cv9oPKv50hoHKeofD6jEyvJFIjqPy+sVdOhLyhCVGZ74FeGNZdtwBXrJRKR2crqK+0 7a8Sq83vz9MVvkBEIXNdTv2SoUNiaEPvJIGrliL98jKmW45yql7v62q6wBm1HUkWRZKV VkWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681477054; x=1684069054; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lZSnA9V82lqicVJGiNFqWTCI4618K2puWAelw0l2AMA=; b=DRhnOtG9RtAumcxneeSx8JWt33/LozDXWWTarRBVgz+LxNpQu6jY7wC+ZdiwHbpYJ6 z8vjZQkbdUQ5+eSNRFbmc66e/7UJKN+GYYaUefAVlpwdWg5YLkEtge6OGNKkC1IjheXy JLPKbp5OixhT72DUIjjt3cWFmAl4vgH3nPtH5yBB2kw1kRKZbAgkW2Kqc+W2+UfkUnQv mxLPkG4Rle5Nm5ic5iIgAa8HXuiULxzVuPNNuPmTIMCZxUfqn5IY8HYImW3H+9gjghd5 TdgZoUdgR00PwD754/VaYGRkw7lNI2EzPXx5D95e3K2L0gwMoOlOsAhNP1iOj4YG5hRZ zWlg== X-Gm-Message-State: AAQBX9ebZ71AGO6mVQWSYTt6qiZAMTLdy4CyRY5ae51Hxag1kF3vxevJ jO89dQHqef5bj6ETMAjKrPs= X-Google-Smtp-Source: AKy350bunq95HazkEFvBWGKoHsHyRQ8ZmABKuw3+odFHdf4DWvKThsba/WB7Y+wEObgFe8YN2VHvmg== X-Received: by 2002:a05:600c:330a:b0:3f0:9fec:a5c2 with SMTP id q10-20020a05600c330a00b003f09feca5c2mr4330365wmp.15.1681477054560; Fri, 14 Apr 2023 05:57:34 -0700 (PDT) Received: from localhost (p200300e41f1c0800f22f74fffe1f3a53.dip0.t-ipconnect.de. [2003:e4:1f1c:800:f22f:74ff:fe1f:3a53]) by smtp.gmail.com with ESMTPSA id i4-20020a5d55c4000000b002f74578f494sm1130398wrw.41.2023.04.14.05.57.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 05:57:34 -0700 (PDT) From: Thierry Reding To: Daniel Lezcano , "Rafael J . Wysocki" , Thierry Reding , Rob Herring , Krzysztof Kozlowski Cc: Amit Kucheria , Zhang Rui , Jon Hunter , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-tegra@vger.kernel.org Subject: [PATCH 08/10] thermal: tegra: Minor stylistic cleanups Date: Fri, 14 Apr 2023 14:57:19 +0200 Message-Id: <20230414125721.1043589-9-thierry.reding@gmail.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230414125721.1043589-1-thierry.reding@gmail.com> References: <20230414125721.1043589-1-thierry.reding@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Thierry Reding Fix up some whitespace (padding, identation) issues and reword an unreadable comment. Signed-off-by: Thierry Reding --- drivers/thermal/tegra/soctherm.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/thermal/tegra/soctherm.c b/drivers/thermal/tegra/soctherm.c index b6e61393fb8f..ba93ea1486f6 100644 --- a/drivers/thermal/tegra/soctherm.c +++ b/drivers/thermal/tegra/soctherm.c @@ -1459,7 +1459,9 @@ static int soctherm_thermtrips_parse(struct tegra_soctherm *ts) ret = of_property_read_u32_array(ts->dev->of_node, "nvidia,thermtrips", tlb, count); if (ret) { - dev_err(ts->dev, "invalid num ele: thermtrips:%d\n", ret); + dev_err(ts->dev, + "failed to read \"nvidia,thermtrips\" property: %d\n", + ret); return ret; } @@ -1756,7 +1758,7 @@ static void throttlectl_gpu_level_select(struct tegra_soctherm *ts, } static int soctherm_oc_cfg_program(struct tegra_soctherm *ts, - enum soctherm_throttle_id throt) + enum soctherm_throttle_id throt) { u32 r; struct soctherm_oc_cfg *oc = &ts->throt_cfgs[throt].oc_cfg; @@ -2048,8 +2050,9 @@ static int tegra_soctherm_probe(struct platform_device *pdev) soctherm_init(tegra); for (i = 0; i < soc->num_ttgs; ++i) { - struct tegra_thermctl_zone *zone = - devm_kzalloc(&pdev->dev, sizeof(*zone), GFP_KERNEL); + struct tegra_thermctl_zone *zone; + + zone = devm_kzalloc(&pdev->dev, sizeof(*zone), GFP_KERNEL); if (!zone) { err = -ENOMEM; goto disable_clocks; From patchwork Fri Apr 14 12:57:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 13211450 X-Patchwork-Delegate: daniel.lezcano@linaro.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB683C7EE26 for ; Fri, 14 Apr 2023 12:58:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230332AbjDNM6E (ORCPT ); Fri, 14 Apr 2023 08:58:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229847AbjDNM6D (ORCPT ); Fri, 14 Apr 2023 08:58:03 -0400 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11547B440; Fri, 14 Apr 2023 05:57:37 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id eo6-20020a05600c82c600b003ee5157346cso11863124wmb.1; Fri, 14 Apr 2023 05:57:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681477055; x=1684069055; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=r9jnq8O0akNCWZMABiiTnkNejKYtKjmdQ2nEC4Lqzp0=; b=cA8fDJ+JgnHhvSPxA06aLZSDb0khbYbV2M+mrSDtzvxjZY+5F2un5hx+d1r1q5ehlo SnqifMdCJ8xHyJMiISIPIl5EwjzO0M9lWrQ31H1XMmoohjavupmRFaN5oBnSUcMGVFkH I1aEtW41IzkThWHHCwLCFrlmPoFqN4amueFMULBGd37eVpcJJ2gUgP1EmEOmNSNhmCDC Pn4NyU+YIUfMOSYR5vN1Pb2dG2XkTFqYtanXsATbmuWpUNaBe9xg60KZGRBQkJhot8f9 8b7ssQZDRopfldzitwj4t4sgJtNWH4yWBP/CtyJVT2vvp0WmsnwS+lmxuU2+Ur+pKnGw oRSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681477055; x=1684069055; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=r9jnq8O0akNCWZMABiiTnkNejKYtKjmdQ2nEC4Lqzp0=; b=WLeBlr7Bf5K8vNY9QRDbK4HD9+VxMbb6+dRl/rXALE9HX0BfYpUpYBragdj1xCvPxS CyftvVSJG/37Z3Qz1mcESIOASOrzgen54U/Heu1ecBzDFllSYS6k472KxAmuwOy03f5q bI1DAInqAv/JbYauL92oc16kznxEDjUovZbpaAGV//NeoOXQEblYIRn9+8zAIPltLJ9G vh3U2cIlgsovvDrNzzDSBCYZDD07z70WiY3G3iEiJIphHvbB47dCUIrPnade7x7zzr6W 2Z2N/rlFQWW1crOMfF0ChufGwgLq6jWCh/TSf22dxy6Qsi+nTWABBqBAy+gegKoKXGvU YZzQ== X-Gm-Message-State: AAQBX9eFYDt1fEv/KLpRmHSv+/9BY+0oFv3tJAFK7RFzwh1J+AzZDW4T GtrRPKQm+MUOX1mRYVojUok= X-Google-Smtp-Source: AKy350a9Rr1bUDeCJa6T9WaGvNXmh3sJHwl53o03Rjd5QeZNjD26b0HeTFHgqn0XQhSbUNS1f0ctBA== X-Received: by 2002:a7b:ce10:0:b0:3ed:2606:d236 with SMTP id m16-20020a7bce10000000b003ed2606d236mr4504790wmc.38.1681477055469; Fri, 14 Apr 2023 05:57:35 -0700 (PDT) Received: from localhost (p200300e41f1c0800f22f74fffe1f3a53.dip0.t-ipconnect.de. [2003:e4:1f1c:800:f22f:74ff:fe1f:3a53]) by smtp.gmail.com with ESMTPSA id k7-20020a05600c1c8700b003ee1acdaf95sm8033494wms.36.2023.04.14.05.57.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 05:57:35 -0700 (PDT) From: Thierry Reding To: Daniel Lezcano , "Rafael J . Wysocki" , Thierry Reding , Rob Herring , Krzysztof Kozlowski Cc: Amit Kucheria , Zhang Rui , Jon Hunter , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-tegra@vger.kernel.org Subject: [PATCH 09/10] arm64: tegra: Rework SOCTHERM on Tegra132 and Tegra210 Date: Fri, 14 Apr 2023 14:57:20 +0200 Message-Id: <20230414125721.1043589-10-thierry.reding@gmail.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230414125721.1043589-1-thierry.reding@gmail.com> References: <20230414125721.1043589-1-thierry.reding@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Thierry Reding The "heavy throttle" cooling device that SOCTHERM uses isn't a cooling device in the traditional sense. It's an automatic mechanism that cannot be actively controlled. Do not expose it as a cooling device and instead of tying it to a specific trip point, hard-code the temperature at which the automatic throttling will begin. While at it, clean up the trip point names to reflect the names used by the thermal device tree bindings. Signed-off-by: Thierry Reding --- arch/arm64/boot/dts/nvidia/tegra132.dtsi | 63 +++++------------- arch/arm64/boot/dts/nvidia/tegra210.dtsi | 83 +++++++----------------- 2 files changed, 39 insertions(+), 107 deletions(-) diff --git a/arch/arm64/boot/dts/nvidia/tegra132.dtsi b/arch/arm64/boot/dts/nvidia/tegra132.dtsi index 8b78be8f4f9d..11ebf7517df1 100644 --- a/arch/arm64/boot/dts/nvidia/tegra132.dtsi +++ b/arch/arm64/boot/dts/nvidia/tegra132.dtsi @@ -876,11 +876,10 @@ soctherm: thermal-sensor@700e2000 { #thermal-sensor-cells = <1>; throttle-cfgs { - throttle_heavy: heavy { + heavy { nvidia,priority = <100>; nvidia,cpu-throt-level = ; - - #cooling-cells = <2>; + temperature = <102000>; }; }; }; @@ -1136,114 +1135,84 @@ cpu-thermal { polling-delay-passive = <1000>; polling-delay = <0>; - thermal-sensors = - <&soctherm TEGRA124_SOCTHERM_SENSOR_CPU>; + thermal-sensors = <&soctherm TEGRA124_SOCTHERM_SENSOR_CPU>; trips { - cpu_shutdown_trip { + critical { temperature = <105000>; hysteresis = <1000>; type = "critical"; }; - cpu_throttle_trip: throttle-trip { + hot { temperature = <102000>; hysteresis = <1000>; type = "hot"; }; }; - - cooling-maps { - map0 { - trip = <&cpu_throttle_trip>; - cooling-device = <&throttle_heavy 1 1>; - }; - }; }; mem-thermal { polling-delay-passive = <0>; polling-delay = <0>; - thermal-sensors = - <&soctherm TEGRA124_SOCTHERM_SENSOR_MEM>; + thermal-sensors = <&soctherm TEGRA124_SOCTHERM_SENSOR_MEM>; trips { - mem_shutdown_trip { + critical { temperature = <101000>; hysteresis = <1000>; type = "critical"; }; - mem_throttle_trip { + + hot { temperature = <99000>; hysteresis = <1000>; type = "hot"; }; }; - - cooling-maps { - /* - * There are currently no cooling maps, - * because there are no cooling devices. - */ - }; }; gpu-thermal { polling-delay-passive = <1000>; polling-delay = <0>; - thermal-sensors = - <&soctherm TEGRA124_SOCTHERM_SENSOR_GPU>; + thermal-sensors = <&soctherm TEGRA124_SOCTHERM_SENSOR_GPU>; trips { - gpu_shutdown_trip { + critical { temperature = <101000>; hysteresis = <1000>; type = "critical"; }; - gpu_throttle_trip: throttle-trip { + hot { temperature = <99000>; hysteresis = <1000>; type = "hot"; }; }; - - cooling-maps { - map0 { - trip = <&gpu_throttle_trip>; - cooling-device = <&throttle_heavy 1 1>; - }; - }; }; pllx-thermal { polling-delay-passive = <0>; polling-delay = <0>; - thermal-sensors = - <&soctherm TEGRA124_SOCTHERM_SENSOR_PLLX>; + thermal-sensors = <&soctherm TEGRA124_SOCTHERM_SENSOR_PLLX>; trips { - pllx_shutdown_trip { + critical { temperature = <105000>; hysteresis = <1000>; type = "critical"; }; - pllx_throttle_trip { + + hot { temperature = <99000>; hysteresis = <1000>; type = "hot"; }; }; - - cooling-maps { - /* - * There are currently no cooling maps, - * because there are no cooling devices. - */ - }; }; }; diff --git a/arch/arm64/boot/dts/nvidia/tegra210.dtsi b/arch/arm64/boot/dts/nvidia/tegra210.dtsi index 0e463b3cbe01..af5460c74184 100644 --- a/arch/arm64/boot/dts/nvidia/tegra210.dtsi +++ b/arch/arm64/boot/dts/nvidia/tegra210.dtsi @@ -1331,12 +1331,11 @@ soctherm: thermal-sensor@700e2000 { #thermal-sensor-cells = <1>; throttle-cfgs { - throttle_heavy: heavy { + heavy { nvidia,priority = <100>; nvidia,cpu-throt-percent = <85>; nvidia,gpu-throt-level = ; - - #cooling-cells = <2>; + temperature = <98500>; }; }; }; @@ -2032,73 +2031,53 @@ cpu-thermal { polling-delay-passive = <1000>; polling-delay = <0>; - thermal-sensors = - <&soctherm TEGRA124_SOCTHERM_SENSOR_CPU>; + thermal-sensors = <&soctherm TEGRA124_SOCTHERM_SENSOR_CPU>; trips { - cpu-shutdown-trip { + critical { temperature = <102500>; hysteresis = <0>; type = "critical"; }; - cpu_throttle_trip: throttle-trip { + hot { temperature = <98500>; hysteresis = <1000>; type = "hot"; }; }; - - cooling-maps { - map0 { - trip = <&cpu_throttle_trip>; - cooling-device = <&throttle_heavy 1 1>; - }; - }; }; mem-thermal { polling-delay-passive = <0>; polling-delay = <0>; - thermal-sensors = - <&soctherm TEGRA124_SOCTHERM_SENSOR_MEM>; + thermal-sensors = <&soctherm TEGRA124_SOCTHERM_SENSOR_MEM>; trips { - dram_nominal: mem-nominal-trip { - temperature = <50000>; - hysteresis = <1000>; - type = "passive"; - }; - - dram_throttle: mem-throttle-trip { - temperature = <70000>; - hysteresis = <1000>; - type = "active"; + critical { + temperature = <103000>; + hysteresis = <0>; + type = "critical"; }; - mem-hot-trip { + hot { temperature = <100000>; hysteresis = <1000>; type = "hot"; }; - mem-shutdown-trip { - temperature = <103000>; - hysteresis = <0>; - type = "critical"; + emc_throttle_trip: passive { + temperature = <95000>; + hysteresis = <2000>; + type = "passive"; }; }; cooling-maps { - dram-passive { - cooling-device = <&emc 0 0>; - trip = <&dram_nominal>; - }; - - dram-active { + passive { cooling-device = <&emc 1 1>; - trip = <&dram_throttle>; + trip = <&emc_throttle_trip>; }; }; }; @@ -2107,58 +2086,42 @@ gpu-thermal { polling-delay-passive = <1000>; polling-delay = <0>; - thermal-sensors = - <&soctherm TEGRA124_SOCTHERM_SENSOR_GPU>; + thermal-sensors = <&soctherm TEGRA124_SOCTHERM_SENSOR_GPU>; trips { - gpu-shutdown-trip { + critical { temperature = <103000>; hysteresis = <0>; type = "critical"; }; - gpu_throttle_trip: throttle-trip { + hot { temperature = <100000>; hysteresis = <1000>; type = "hot"; }; }; - - cooling-maps { - map0 { - trip = <&gpu_throttle_trip>; - cooling-device = <&throttle_heavy 1 1>; - }; - }; }; pllx-thermal { polling-delay-passive = <0>; polling-delay = <0>; - thermal-sensors = - <&soctherm TEGRA124_SOCTHERM_SENSOR_PLLX>; + thermal-sensors = <&soctherm TEGRA124_SOCTHERM_SENSOR_PLLX>; trips { - pllx-shutdown-trip { + critical { temperature = <103000>; hysteresis = <0>; type = "critical"; }; - pllx-throttle-trip { + hot { temperature = <100000>; hysteresis = <1000>; type = "hot"; }; }; - - cooling-maps { - /* - * There are currently no cooling maps, - * because there are no cooling devices. - */ - }; }; }; From patchwork Fri Apr 14 12:57:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 13211451 X-Patchwork-Delegate: daniel.lezcano@linaro.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6743CC77B77 for ; Fri, 14 Apr 2023 12:58:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230229AbjDNM6L (ORCPT ); Fri, 14 Apr 2023 08:58:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230370AbjDNM6I (ORCPT ); Fri, 14 Apr 2023 08:58:08 -0400 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 860D8B46A; Fri, 14 Apr 2023 05:57:38 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id j16so2866935wms.0; Fri, 14 Apr 2023 05:57:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681477056; x=1684069056; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IMs4htTs+n807Qxv9wy5B+iV59lczbMdJjiqtA7CgWY=; b=H4dMMARGwEbB3rtkUy3jrLYXf8TheuPZeauo1lHhG8NiBviIOmrfDrlJ2kbzoLJcTl EIqSZFCUv+EmTdTT4jvm8nghBTiJHkRFc6l4ZvRStEOu0DqqMaPgz+P2N4SSjxUMlZ4f PFoSG1TwnMZx+bRkwbqb2Rzpc14rMnwu0Qai+BGQqpxX4ep3+VR032qdrzBVbZpm00vd +tOiW2+Qs4Z23MXhVtD6LB03xNAyQ7t9nmExn+fC3GZnqVdWPMtPzkPXUDcLsAcpgwyI plQs5rwcDLgzvyosLab9bs0+lXVSPnH8vQeDAYWN4V7kI92ipqZQz7/8jKmNt7lZUX3r TeKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681477056; x=1684069056; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IMs4htTs+n807Qxv9wy5B+iV59lczbMdJjiqtA7CgWY=; b=XQUKJzj+Pz1dzpZ/tDFT9YhyMeLM0nBI4dkTG+HEfAu3P3NkvvgAO4UzNickHJyoHt PUlmNl7DBYhe3qbzG1oUoC0em5UO7Z2xj1PjH3SOfhLdgPtSBtkMTMq1+2ZA6kfm7WKe iOv0lrZZdoRN8r3nfraUHR8WklNLZy3UVwICh3laUDdc70p+qHdA9L7mhzNxtxzIHIQ+ Cvxqh5lLR504mPpic+DiVXQYhEF/Ky/dj+SUh/u4qwn6q3C3qTJlVgnO5k4I+meVq+rX MIad3lk+LM1U5PUjHjojwBZPuJVS+Rb37xI/g53zFXODmnJNMhf2dC59/2fCPyS3x7m5 BFBQ== X-Gm-Message-State: AAQBX9fWs+stuXoD4+GsO2C5BFKbtne94+ihqKChlcy7umuj3RJO1e/3 jJm+0aZpipA6cfLpvbbz8S8= X-Google-Smtp-Source: AKy350btVpQD6kyqa52bpUzBZoidiHySS9CWllmEGLe/YsZ90XPXR+tH7RIO5dErD1F+JlLYJyhHJg== X-Received: by 2002:a05:600c:3788:b0:3f0:a08e:811b with SMTP id o8-20020a05600c378800b003f0a08e811bmr4580876wmr.13.1681477056509; Fri, 14 Apr 2023 05:57:36 -0700 (PDT) Received: from localhost (p200300e41f1c0800f22f74fffe1f3a53.dip0.t-ipconnect.de. [2003:e4:1f1c:800:f22f:74ff:fe1f:3a53]) by smtp.gmail.com with ESMTPSA id u15-20020a05600c19cf00b003ede3f5c81fsm7932788wmq.41.2023.04.14.05.57.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 05:57:36 -0700 (PDT) From: Thierry Reding To: Daniel Lezcano , "Rafael J . Wysocki" , Thierry Reding , Rob Herring , Krzysztof Kozlowski Cc: Amit Kucheria , Zhang Rui , Jon Hunter , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-tegra@vger.kernel.org Subject: [PATCH 10/10] ARM: tegra: Rework SOCTHERM on Tegra124 Date: Fri, 14 Apr 2023 14:57:21 +0200 Message-Id: <20230414125721.1043589-11-thierry.reding@gmail.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230414125721.1043589-1-thierry.reding@gmail.com> References: <20230414125721.1043589-1-thierry.reding@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Thierry Reding The "heavy throttle" cooling device that SOCTHERM uses isn't a cooling device in the traditional sense. It's an automatic mechanism that cannot be actively controlled. Do not expose it as a cooling device and instead of tying it to a specific trip point, hard-code the temperature at which the automatic throttling will begin. While at it, clean up the trip point names to reflect the names used by the thermal device tree bindings. Signed-off-by: Thierry Reding --- arch/arm/boot/dts/tegra124.dtsi | 65 +++++++++------------------------ 1 file changed, 18 insertions(+), 47 deletions(-) diff --git a/arch/arm/boot/dts/tegra124.dtsi b/arch/arm/boot/dts/tegra124.dtsi index b3fbecf5c818..656361b4ac01 100644 --- a/arch/arm/boot/dts/tegra124.dtsi +++ b/arch/arm/boot/dts/tegra124.dtsi @@ -932,12 +932,11 @@ soctherm: thermal-sensor@700e2000 { #thermal-sensor-cells = <1>; throttle-cfgs { - throttle_heavy: heavy { + heavy { nvidia,priority = <100>; nvidia,cpu-throt-percent = <85>; nvidia,gpu-throt-level = ; - - #cooling-cells = <2>; + temperature = <100000>; }; }; }; @@ -1242,112 +1241,84 @@ cpu-thermal { polling-delay-passive = <1000>; polling-delay = <1000>; - thermal-sensors = - <&soctherm TEGRA124_SOCTHERM_SENSOR_CPU>; + thermal-sensors = <&soctherm TEGRA124_SOCTHERM_SENSOR_CPU>; trips { - cpu-shutdown-trip { + critical { temperature = <103000>; hysteresis = <0>; type = "critical"; }; - cpu_throttle_trip: throttle-trip { + + hot { temperature = <100000>; hysteresis = <1000>; type = "hot"; }; }; - - cooling-maps { - map0 { - trip = <&cpu_throttle_trip>; - cooling-device = <&throttle_heavy 1 1>; - }; - }; }; mem-thermal { polling-delay-passive = <1000>; polling-delay = <1000>; - thermal-sensors = - <&soctherm TEGRA124_SOCTHERM_SENSOR_MEM>; + thermal-sensors = <&soctherm TEGRA124_SOCTHERM_SENSOR_MEM>; trips { - mem-shutdown-trip { + critical { temperature = <103000>; hysteresis = <0>; type = "critical"; }; - mem-throttle-trip { + + hot { temperature = <99000>; hysteresis = <1000>; type = "hot"; }; }; - - cooling-maps { - /* - * There are currently no cooling maps, - * because there are no cooling devices. - */ - }; }; gpu-thermal { polling-delay-passive = <1000>; polling-delay = <1000>; - thermal-sensors = - <&soctherm TEGRA124_SOCTHERM_SENSOR_GPU>; + thermal-sensors = <&soctherm TEGRA124_SOCTHERM_SENSOR_GPU>; trips { - gpu-shutdown-trip { + critical { temperature = <101000>; hysteresis = <0>; type = "critical"; }; - gpu_throttle_trip: throttle-trip { + + hot { temperature = <99000>; hysteresis = <1000>; type = "hot"; }; }; - - cooling-maps { - map0 { - trip = <&gpu_throttle_trip>; - cooling-device = <&throttle_heavy 1 1>; - }; - }; }; pllx-thermal { polling-delay-passive = <1000>; polling-delay = <1000>; - thermal-sensors = - <&soctherm TEGRA124_SOCTHERM_SENSOR_PLLX>; + thermal-sensors = <&soctherm TEGRA124_SOCTHERM_SENSOR_PLLX>; trips { - pllx-shutdown-trip { + critical { temperature = <103000>; hysteresis = <0>; type = "critical"; }; - pllx-throttle-trip { + + hot { temperature = <99000>; hysteresis = <1000>; type = "hot"; }; }; - - cooling-maps { - /* - * There are currently no cooling maps, - * because there are no cooling devices. - */ - }; }; };