Message ID | 20231114131514.89031-1-angelogioacchino.delregno@collabora.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp1849561vqg; Tue, 14 Nov 2023 05:15:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IGe40utKrG+r3AtfFrV0O5lH5vGkjQrixWcqzfR7gyQpN2J0rP3/XhSoNV6onJuI3i9zlkt X-Received: by 2002:a17:902:ec92:b0:1cc:5835:9634 with SMTP id x18-20020a170902ec9200b001cc58359634mr2453894plg.15.1699967748860; Tue, 14 Nov 2023 05:15:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699967748; cv=none; d=google.com; s=arc-20160816; b=x0SCi4gtTwzaWowkorbigAbZXuUWC9+JnmznFPk0I7r3NuYYHkHI9DXJQUpsyAKG8a B8HxsVdNUVFOvySCDBXqJk5ajw8cnjKpacMBPZuHSL6EWqFzdKOlg0bDRU/dh67Du3Y9 n2T3GHb6DgMK/rMElGXkmAv7UGZ1WwGxoWPOceslt2vY+nHH9/tk8aKdxBghFdXOk9qU 6G37W6El7s3d96DvfyE9ZKzslosdSQDNovWGrv6eosEVTrurzfxUcUcbSxUAY80bhELu 8SXsHIYKTW27c5e5QYhwtw52sqeog6ZOYHEJnwHhvMtv2+Kcwe1rY1i5mFX/IwRzx8KM fPKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=khkCJKehjJ4i8zoPd8V+V309r1d0y3GBiUDUK2iOj2k=; fh=bm4NQDO4SnEcEbYHRP3HFmD+xGwEoed5DZkU5D4NwEc=; b=gfHzFwL/awV7DwiBTWnfUqeqGH03yGtqUT2RmOHTumMDbeo5xXTUKYnMqIompS8mkW fmBIp4nneGDVV8xk26vtjF+d7eXhSlDajfcd/n0UOtGD3YVQMfNnbe5NoKZz9nqMMOZJ RnoS4llzOjBpf3uTqDghDhl5kA3bIM4yoan+WcuwqlZC8DE62PbwKeoELr0AiZssuGKb fpG20mfM6cEvGU8Om0nJ1PWF/rh80mosZ/7fRoNGTvw8v3v0Z9u/mMNeeEikKLAIOLbb lW8rYH5QeAPzsSCP4XNU2UyqD3TvUYl/6icBfOkHaYguJELxDh93vp33GQ2TZhL0o0/5 +B6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=EJwO2E7Z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id jh14-20020a170903328e00b001c77916e87dsi7435774plb.591.2023.11.14.05.15.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Nov 2023 05:15:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=EJwO2E7Z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 74CCF80A9AB5; Tue, 14 Nov 2023 05:15:45 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233121AbjKNNPa (ORCPT <rfc822;lhua1029@gmail.com> + 29 others); Tue, 14 Nov 2023 08:15:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231878AbjKNNP2 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 14 Nov 2023 08:15:28 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C26319E; Tue, 14 Nov 2023 05:15:24 -0800 (PST) Received: from IcarusMOD.eternityproject.eu (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: kholk11) by madras.collabora.co.uk (Postfix) with ESMTPSA id 7AB1866056D1; Tue, 14 Nov 2023 13:15:21 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1699967722; bh=wkyZXR0pDVigGvjTTrpa2k75BnWvcEsTzWQCeC+T0TQ=; h=From:To:Cc:Subject:Date:From; b=EJwO2E7ZcNEWgXrHa6s2Fwz5H8PwfFpgtjoen3y3DCAK8y6opy3clzOmS/y2FXRN+ MQMSYrsGraSDINBcY0ySX2+GYvYcqhHVYzkVZ5vL85q91EZLwv0+RWIA1v1gf92uq1 MPz1YvqP74cUNnRRy6KLLs5lmYOn8KeK9VujjnoCrWMD+kNiOys51cbCrotmTCOHjM Sc2I9gpwRMmHJOxKBca8ijyHUG5zwBzWVIHi0G3I0bZkGf9f8pcV89kOlyqBNQlPhG sdozIUjBgJHFzdM9hK618yH7gwUOvr9N/n9KHVNp4v+WtRGseTjEqKdrM+501A/+bw DISDIdSBRbSag== From: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> To: rafael@kernel.org Cc: daniel.lezcano@linaro.org, rui.zhang@intel.com, lukasz.luba@arm.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@collabora.com, wenst@chromium.org, AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Subject: [PATCH] thermal: Add support for device tree thermal zones consumers Date: Tue, 14 Nov 2023 14:15:14 +0100 Message-ID: <20231114131514.89031-1-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 14 Nov 2023 05:15:45 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782545382251014828 X-GMAIL-MSGID: 1782545382251014828 |
Series |
thermal: Add support for device tree thermal zones consumers
|
|
Commit Message
AngeloGioacchino Del Regno
Nov. 14, 2023, 1:15 p.m. UTC
Add helpers to support retrieving thermal zones from device tree nodes:
this will allow a device tree consumer to specify phandles to specific
thermal zone(s), including support for specifying thermal-zone-names.
This is useful, for example, for smart voltage scaling drivers that
need to adjust CPU/GPU/other voltages based on temperature, and for
battery charging drivers that need to scale current based on various
aggregated temperature sensor readings which are board-dependant.
Example:
smart-scaling-driver@10000000 {
[...]
thermal-zones = <&cluster_big_tz>, <&gpu_tz>, <&vpu_tz>;
thermal-zone-names = "cpu", "gpu", "vpu";
[...]
}
battery-charger@20000000 {
[...]
thermal-zones = <&battery_temp>, <&device_skin_temp>;
thermal-zone-names = "batt-ext-sensor", "skin";
[...]
}
Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
---
Background story: while I was cleaning up the MediaTek Smart Voltage Scaling
(SVS) driver, I've found out that there's a lot of commonization to be done.
After a rewrite of "this and that" in that driver, I came across a barrier
that didn't allow me to remove another ~100 lines of code, and that was also
anyway breaking the driver, because the thermal zone names are different
from what was originally intended.
I've been looking for thermal zone handle retrieval around the kernel and
found that there currently are at least four other drivers that could make
use this as a cleanup: charger-manager, which is retrieving a thermal zone
to look for with a "cm-thermal-zone" string property, gpu/drm/tiny/repaper.c
that does the same by checking a "pervasive,thermal-zone" string property,
and ab8500_temp and sdhci-omap which are simply hardcoding a "cpu_thermal"
and "battery-thermal" thermal zone names respectively.
There are a number of other devices (mostly embedded, mostly smartphones)
that don't have an upstream driver and that could make use of this as well.
Cheers!
drivers/thermal/thermal_of.c | 91 ++++++++++++++++++++++++++++++++++++
include/linux/thermal.h | 13 ++++++
2 files changed, 104 insertions(+)
Comments
Hi AngeloGioacchino, kernel test robot noticed the following build errors: [auto build test ERROR on rafael-pm/thermal] [also build test ERROR on linus/master v6.7-rc1 next-20231115] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/AngeloGioacchino-Del-Regno/thermal-Add-support-for-device-tree-thermal-zones-consumers/20231114-211656 base: https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git thermal patch link: https://lore.kernel.org/r/20231114131514.89031-1-angelogioacchino.delregno%40collabora.com patch subject: [PATCH] thermal: Add support for device tree thermal zones consumers config: x86_64-rhel-8.3 (https://download.01.org/0day-ci/archive/20231115/202311152230.nzJVHaeG-lkp@intel.com/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231115/202311152230.nzJVHaeG-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202311152230.nzJVHaeG-lkp@intel.com/ All errors (new ones prefixed by >>): ld: arch/x86/kernel/acpi/cppc.o: in function `thermal_of_get_zone_by_index': >> include/linux/thermal.h:282: multiple definition of `thermal_of_get_zone_by_index'; arch/x86/kernel/acpi/boot.o:include/linux/thermal.h:282: first defined here ld: arch/x86/kernel/acpi/cppc.o: in function `thermal_of_get_zone': >> include/linux/thermal.h:287: multiple definition of `thermal_of_get_zone'; arch/x86/kernel/acpi/boot.o:include/linux/thermal.h:287: first defined here ld: arch/x86/kernel/acpi/cstate.o: in function `thermal_of_get_zone_by_index': >> include/linux/thermal.h:282: multiple definition of `thermal_of_get_zone_by_index'; arch/x86/kernel/acpi/boot.o:include/linux/thermal.h:282: first defined here ld: arch/x86/kernel/acpi/cstate.o: in function `thermal_of_get_zone': >> include/linux/thermal.h:287: multiple definition of `thermal_of_get_zone'; arch/x86/kernel/acpi/boot.o:include/linux/thermal.h:287: first defined here ld: drivers/idle/intel_idle.o: in function `thermal_of_get_zone_by_index': >> include/linux/thermal.h:282: multiple definition of `thermal_of_get_zone_by_index'; arch/x86/kernel/acpi/boot.o:include/linux/thermal.h:282: first defined here ld: drivers/idle/intel_idle.o: in function `thermal_of_get_zone': >> include/linux/thermal.h:287: multiple definition of `thermal_of_get_zone'; arch/x86/kernel/acpi/boot.o:include/linux/thermal.h:287: first defined here ld: drivers/acpi/acpi_processor.o: in function `thermal_of_get_zone_by_index': >> include/linux/thermal.h:282: multiple definition of `thermal_of_get_zone_by_index'; arch/x86/kernel/acpi/boot.o:include/linux/thermal.h:282: first defined here ld: drivers/acpi/acpi_processor.o: in function `thermal_of_get_zone': >> include/linux/thermal.h:287: multiple definition of `thermal_of_get_zone'; arch/x86/kernel/acpi/boot.o:include/linux/thermal.h:287: first defined here ld: drivers/acpi/processor_core.o: in function `thermal_of_get_zone_by_index': >> include/linux/thermal.h:282: multiple definition of `thermal_of_get_zone_by_index'; arch/x86/kernel/acpi/boot.o:include/linux/thermal.h:282: first defined here ld: drivers/acpi/processor_core.o: in function `thermal_of_get_zone': >> include/linux/thermal.h:287: multiple definition of `thermal_of_get_zone'; arch/x86/kernel/acpi/boot.o:include/linux/thermal.h:287: first defined here ld: drivers/acpi/processor_pdc.o: in function `thermal_of_get_zone_by_index': >> include/linux/thermal.h:282: multiple definition of `thermal_of_get_zone_by_index'; arch/x86/kernel/acpi/boot.o:include/linux/thermal.h:282: first defined here ld: drivers/acpi/processor_pdc.o: in function `thermal_of_get_zone': >> include/linux/thermal.h:287: multiple definition of `thermal_of_get_zone'; arch/x86/kernel/acpi/boot.o:include/linux/thermal.h:287: first defined here ld: drivers/acpi/fan_core.o: in function `thermal_of_get_zone_by_index': >> include/linux/thermal.h:282: multiple definition of `thermal_of_get_zone_by_index'; arch/x86/kernel/acpi/boot.o:include/linux/thermal.h:282: first defined here ld: drivers/acpi/fan_core.o: in function `thermal_of_get_zone': >> include/linux/thermal.h:287: multiple definition of `thermal_of_get_zone'; arch/x86/kernel/acpi/boot.o:include/linux/thermal.h:287: first defined here ld: drivers/acpi/processor_driver.o: in function `thermal_of_get_zone_by_index': >> include/linux/thermal.h:282: multiple definition of `thermal_of_get_zone_by_index'; arch/x86/kernel/acpi/boot.o:include/linux/thermal.h:282: first defined here ld: drivers/acpi/processor_driver.o: in function `thermal_of_get_zone': >> include/linux/thermal.h:287: multiple definition of `thermal_of_get_zone'; arch/x86/kernel/acpi/boot.o:include/linux/thermal.h:287: first defined here ld: drivers/acpi/processor_thermal.o: in function `thermal_of_get_zone_by_index': >> include/linux/thermal.h:282: multiple definition of `thermal_of_get_zone_by_index'; arch/x86/kernel/acpi/boot.o:include/linux/thermal.h:282: first defined here ld: drivers/acpi/processor_thermal.o: in function `thermal_of_get_zone': >> include/linux/thermal.h:287: multiple definition of `thermal_of_get_zone'; arch/x86/kernel/acpi/boot.o:include/linux/thermal.h:287: first defined here ld: drivers/acpi/processor_idle.o: in function `thermal_of_get_zone_by_index': >> include/linux/thermal.h:282: multiple definition of `thermal_of_get_zone_by_index'; arch/x86/kernel/acpi/boot.o:include/linux/thermal.h:282: first defined here ld: drivers/acpi/processor_idle.o: in function `thermal_of_get_zone': >> include/linux/thermal.h:287: multiple definition of `thermal_of_get_zone'; arch/x86/kernel/acpi/boot.o:include/linux/thermal.h:287: first defined here ld: drivers/acpi/processor_throttling.o: in function `thermal_of_get_zone_by_index': include/linux/thermal.h:282: multiple definition of `thermal_of_get_zone_by_index'; arch/x86/kernel/acpi/boot.o:include/linux/thermal.h:282: first defined here ld: drivers/acpi/processor_throttling.o: in function `thermal_of_get_zone': include/linux/thermal.h:287: multiple definition of `thermal_of_get_zone'; arch/x86/kernel/acpi/boot.o:include/linux/thermal.h:287: first defined here ld: drivers/acpi/processor_perflib.o: in function `thermal_of_get_zone_by_index': include/linux/thermal.h:282: multiple definition of `thermal_of_get_zone_by_index'; arch/x86/kernel/acpi/boot.o:include/linux/thermal.h:282: first defined here ld: drivers/acpi/processor_perflib.o: in function `thermal_of_get_zone': include/linux/thermal.h:287: multiple definition of `thermal_of_get_zone'; arch/x86/kernel/acpi/boot.o:include/linux/thermal.h:287: first defined here ld: drivers/acpi/thermal.o: in function `thermal_of_get_zone_by_index': include/linux/thermal.h:282: multiple definition of `thermal_of_get_zone_by_index'; arch/x86/kernel/acpi/boot.o:include/linux/thermal.h:282: first defined here ld: drivers/acpi/thermal.o: in function `thermal_of_get_zone': include/linux/thermal.h:287: multiple definition of `thermal_of_get_zone'; arch/x86/kernel/acpi/boot.o:include/linux/thermal.h:287: first defined here ld: drivers/acpi/cppc_acpi.o: in function `thermal_of_get_zone_by_index': include/linux/thermal.h:282: multiple definition of `thermal_of_get_zone_by_index'; arch/x86/kernel/acpi/boot.o:include/linux/thermal.h:282: first defined here ld: drivers/acpi/cppc_acpi.o: in function `thermal_of_get_zone': include/linux/thermal.h:287: multiple definition of `thermal_of_get_zone'; arch/x86/kernel/acpi/boot.o:include/linux/thermal.h:287: first defined here ld: drivers/power/supply/power_supply_core.o: in function `thermal_of_get_zone_by_index': include/linux/thermal.h:282: multiple definition of `thermal_of_get_zone_by_index'; arch/x86/kernel/acpi/boot.o:include/linux/thermal.h:282: first defined here ld: drivers/power/supply/power_supply_core.o: in function `thermal_of_get_zone': include/linux/thermal.h:287: multiple definition of `thermal_of_get_zone'; arch/x86/kernel/acpi/boot.o:include/linux/thermal.h:287: first defined here ld: drivers/hwmon/hwmon.o: in function `thermal_of_get_zone_by_index': include/linux/thermal.h:282: multiple definition of `thermal_of_get_zone_by_index'; arch/x86/kernel/acpi/boot.o:include/linux/thermal.h:282: first defined here ld: drivers/hwmon/hwmon.o: in function `thermal_of_get_zone': include/linux/thermal.h:287: multiple definition of `thermal_of_get_zone'; arch/x86/kernel/acpi/boot.o:include/linux/thermal.h:287: first defined here ld: drivers/thermal/thermal_core.o: in function `thermal_of_get_zone_by_index': include/linux/thermal.h:282: multiple definition of `thermal_of_get_zone_by_index'; arch/x86/kernel/acpi/boot.o:include/linux/thermal.h:282: first defined here ld: drivers/thermal/thermal_core.o: in function `thermal_of_get_zone': include/linux/thermal.h:287: multiple definition of `thermal_of_get_zone'; arch/x86/kernel/acpi/boot.o:include/linux/thermal.h:287: first defined here ld: drivers/thermal/thermal_sysfs.o: in function `thermal_of_get_zone_by_index': include/linux/thermal.h:282: multiple definition of `thermal_of_get_zone_by_index'; arch/x86/kernel/acpi/boot.o:include/linux/thermal.h:282: first defined here ld: drivers/thermal/thermal_sysfs.o: in function `thermal_of_get_zone': include/linux/thermal.h:287: multiple definition of `thermal_of_get_zone'; arch/x86/kernel/acpi/boot.o:include/linux/thermal.h:287: first defined here ld: drivers/thermal/thermal_trip.o: in function `thermal_of_get_zone_by_index': include/linux/thermal.h:282: multiple definition of `thermal_of_get_zone_by_index'; arch/x86/kernel/acpi/boot.o:include/linux/thermal.h:282: first defined here ld: drivers/thermal/thermal_trip.o: in function `thermal_of_get_zone': include/linux/thermal.h:287: multiple definition of `thermal_of_get_zone'; arch/x86/kernel/acpi/boot.o:include/linux/thermal.h:287: first defined here ld: drivers/thermal/thermal_helpers.o: in function `thermal_of_get_zone_by_index': include/linux/thermal.h:282: multiple definition of `thermal_of_get_zone_by_index'; arch/x86/kernel/acpi/boot.o:include/linux/thermal.h:282: first defined here ld: drivers/thermal/thermal_helpers.o: in function `thermal_of_get_zone': include/linux/thermal.h:287: multiple definition of `thermal_of_get_zone'; arch/x86/kernel/acpi/boot.o:include/linux/thermal.h:287: first defined here ld: drivers/thermal/thermal_hwmon.o: in function `thermal_of_get_zone_by_index': include/linux/thermal.h:282: multiple definition of `thermal_of_get_zone_by_index'; arch/x86/kernel/acpi/boot.o:include/linux/thermal.h:282: first defined here ld: drivers/thermal/thermal_hwmon.o: in function `thermal_of_get_zone': include/linux/thermal.h:287: multiple definition of `thermal_of_get_zone'; arch/x86/kernel/acpi/boot.o:include/linux/thermal.h:287: first defined here ld: drivers/thermal/thermal_acpi.o: in function `thermal_of_get_zone_by_index': include/linux/thermal.h:282: multiple definition of `thermal_of_get_zone_by_index'; arch/x86/kernel/acpi/boot.o:include/linux/thermal.h:282: first defined here ld: drivers/thermal/thermal_acpi.o: in function `thermal_of_get_zone': include/linux/thermal.h:287: multiple definition of `thermal_of_get_zone'; arch/x86/kernel/acpi/boot.o:include/linux/thermal.h:287: first defined here ld: drivers/thermal/gov_fair_share.o: in function `thermal_of_get_zone_by_index': include/linux/thermal.h:282: multiple definition of `thermal_of_get_zone_by_index'; arch/x86/kernel/acpi/boot.o:include/linux/thermal.h:282: first defined here ld: drivers/thermal/gov_fair_share.o: in function `thermal_of_get_zone': include/linux/thermal.h:287: multiple definition of `thermal_of_get_zone'; arch/x86/kernel/acpi/boot.o:include/linux/thermal.h:287: first defined here ld: drivers/thermal/gov_bang_bang.o: in function `thermal_of_get_zone_by_index': include/linux/thermal.h:282: multiple definition of `thermal_of_get_zone_by_index'; arch/x86/kernel/acpi/boot.o:include/linux/thermal.h:282: first defined here ld: drivers/thermal/gov_bang_bang.o: in function `thermal_of_get_zone': include/linux/thermal.h:287: multiple definition of `thermal_of_get_zone'; arch/x86/kernel/acpi/boot.o:include/linux/thermal.h:287: first defined here ld: drivers/thermal/gov_step_wise.o: in function `thermal_of_get_zone_by_index': include/linux/thermal.h:282: multiple definition of `thermal_of_get_zone_by_index'; arch/x86/kernel/acpi/boot.o:include/linux/thermal.h:282: first defined here ld: drivers/thermal/gov_step_wise.o: in function `thermal_of_get_zone': include/linux/thermal.h:287: multiple definition of `thermal_of_get_zone'; arch/x86/kernel/acpi/boot.o:include/linux/thermal.h:287: first defined here ld: drivers/thermal/gov_user_space.o: in function `thermal_of_get_zone_by_index': include/linux/thermal.h:282: multiple definition of `thermal_of_get_zone_by_index'; arch/x86/kernel/acpi/boot.o:include/linux/thermal.h:282: first defined here ld: drivers/thermal/gov_user_space.o: in function `thermal_of_get_zone': include/linux/thermal.h:287: multiple definition of `thermal_of_get_zone'; arch/x86/kernel/acpi/boot.o:include/linux/thermal.h:287: first defined here ld: drivers/cpufreq/cpufreq.o: in function `thermal_of_get_zone_by_index': include/linux/thermal.h:282: multiple definition of `thermal_of_get_zone_by_index'; arch/x86/kernel/acpi/boot.o:include/linux/thermal.h:282: first defined here ld: drivers/cpufreq/cpufreq.o: in function `thermal_of_get_zone': include/linux/thermal.h:287: multiple definition of `thermal_of_get_zone'; arch/x86/kernel/acpi/boot.o:include/linux/thermal.h:287: first defined here ld: drivers/cpufreq/intel_pstate.o: in function `thermal_of_get_zone_by_index': include/linux/thermal.h:282: multiple definition of `thermal_of_get_zone_by_index'; arch/x86/kernel/acpi/boot.o:include/linux/thermal.h:282: first defined here ld: drivers/cpufreq/intel_pstate.o: in function `thermal_of_get_zone': include/linux/thermal.h:287: multiple definition of `thermal_of_get_zone'; arch/x86/kernel/acpi/boot.o:include/linux/thermal.h:287: first defined here vim +282 include/linux/thermal.h 280 281 struct thermal_zone_device *thermal_of_get_zone_by_index(struct device *dev, int index) > 282 { 283 return ERR_PTR(-EOPNOTSUPP); 284 } 285 286 struct thermal_zone_device *thermal_of_get_zone(struct device *dev, const char *name) > 287 { 288 return ERR_PTR(-EOPNOTSUPP); 289 } 290 #endif 291
Il 15/11/23 15:37, kernel test robot ha scritto: > Hi AngeloGioacchino, > > kernel test robot noticed the following build errors: > > [auto build test ERROR on rafael-pm/thermal] > [also build test ERROR on linus/master v6.7-rc1 next-20231115] > [If your patch is applied to the wrong git tree, kindly drop us a note. > And when submitting patch, we suggest to use '--base' as documented in > https://git-scm.com/docs/git-format-patch#_base_tree_information] > > url: https://github.com/intel-lab-lkp/linux/commits/AngeloGioacchino-Del-Regno/thermal-Add-support-for-device-tree-thermal-zones-consumers/20231114-211656 > base: https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git thermal > patch link: https://lore.kernel.org/r/20231114131514.89031-1-angelogioacchino.delregno%40collabora.com > patch subject: [PATCH] thermal: Add support for device tree thermal zones consumers > config: x86_64-rhel-8.3 (https://download.01.org/0day-ci/archive/20231115/202311152230.nzJVHaeG-lkp@intel.com/config) > compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231115/202311152230.nzJVHaeG-lkp@intel.com/reproduce) > > If you fix the issue in a separate patch/commit (i.e. not just a new version of > the same patch/commit), kindly add following tags > | Reported-by: kernel test robot <lkp@intel.com> > | Closes: https://lore.kernel.org/oe-kbuild-all/202311152230.nzJVHaeG-lkp@intel.com/ ..snip.. > > > vim +282 include/linux/thermal.h > > 280 That's right, I forgot to add "static inline" :-) Fixing and sending a v2. > 281 struct thermal_zone_device *thermal_of_get_zone_by_index(struct device *dev, int index) > > 282 { > 283 return ERR_PTR(-EOPNOTSUPP); > 284 } > 285 > 286 struct thermal_zone_device *thermal_of_get_zone(struct device *dev, const char *name) > > 287 { > 288 return ERR_PTR(-EOPNOTSUPP); > 289 } > 290 #endif > 291 >
Hi AngeloGioacchino, kernel test robot noticed the following build errors: [auto build test ERROR on rafael-pm/thermal] [also build test ERROR on linus/master v6.7-rc1 next-20231115] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/AngeloGioacchino-Del-Regno/thermal-Add-support-for-device-tree-thermal-zones-consumers/20231114-211656 base: https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git thermal patch link: https://lore.kernel.org/r/20231114131514.89031-1-angelogioacchino.delregno%40collabora.com patch subject: [PATCH] thermal: Add support for device tree thermal zones consumers config: arm-randconfig-004-20231115 (https://download.01.org/0day-ci/archive/20231115/202311152213.NNF5X5wd-lkp@intel.com/config) compiler: arm-linux-gnueabi-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231115/202311152213.NNF5X5wd-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202311152213.NNF5X5wd-lkp@intel.com/ All errors (new ones prefixed by >>): arm-linux-gnueabi-ld: drivers/power/supply/power_supply_core.o: in function `thermal_of_get_zone_by_index': >> power_supply_core.c:(.text+0x167c): multiple definition of `thermal_of_get_zone_by_index'; drivers/soc/qcom/qcom_aoss.o:qcom_aoss.c:(.text+0x5a4): first defined here arm-linux-gnueabi-ld: drivers/power/supply/power_supply_core.o: in function `thermal_of_get_zone': >> power_supply_core.c:(.text+0x1684): multiple definition of `thermal_of_get_zone'; drivers/soc/qcom/qcom_aoss.o:qcom_aoss.c:(.text+0x5ac): first defined here arm-linux-gnueabi-ld: drivers/hwmon/hwmon.o: in function `thermal_of_get_zone_by_index': hwmon.c:(.text+0x9cc): multiple definition of `thermal_of_get_zone_by_index'; drivers/soc/qcom/qcom_aoss.o:qcom_aoss.c:(.text+0x5a4): first defined here arm-linux-gnueabi-ld: drivers/hwmon/hwmon.o: in function `thermal_of_get_zone': hwmon.c:(.text+0x9d4): multiple definition of `thermal_of_get_zone'; drivers/soc/qcom/qcom_aoss.o:qcom_aoss.c:(.text+0x5ac): first defined here arm-linux-gnueabi-ld: drivers/hwmon/tc654.o: in function `thermal_of_get_zone_by_index': tc654.c:(.text+0x5c8): multiple definition of `thermal_of_get_zone_by_index'; drivers/soc/qcom/qcom_aoss.o:qcom_aoss.c:(.text+0x5a4): first defined here arm-linux-gnueabi-ld: drivers/hwmon/tc654.o: in function `thermal_of_get_zone': tc654.c:(.text+0x5d0): multiple definition of `thermal_of_get_zone'; drivers/soc/qcom/qcom_aoss.o:qcom_aoss.c:(.text+0x5ac): first defined here arm-linux-gnueabi-ld: drivers/hwmon/mlxreg-fan.o: in function `thermal_of_get_zone_by_index': mlxreg-fan.c:(.text+0x3f0): multiple definition of `thermal_of_get_zone_by_index'; drivers/soc/qcom/qcom_aoss.o:qcom_aoss.c:(.text+0x5a4): first defined here arm-linux-gnueabi-ld: drivers/hwmon/mlxreg-fan.o: in function `thermal_of_get_zone': mlxreg-fan.c:(.text+0x3f8): multiple definition of `thermal_of_get_zone'; drivers/soc/qcom/qcom_aoss.o:qcom_aoss.c:(.text+0x5ac): first defined here arm-linux-gnueabi-ld: drivers/hwmon/pwm-fan.o: in function `thermal_of_get_zone_by_index': pwm-fan.c:(.text+0x9c): multiple definition of `thermal_of_get_zone_by_index'; drivers/soc/qcom/qcom_aoss.o:qcom_aoss.c:(.text+0x5a4): first defined here arm-linux-gnueabi-ld: drivers/hwmon/pwm-fan.o: in function `thermal_of_get_zone': pwm-fan.c:(.text+0xa4): multiple definition of `thermal_of_get_zone'; drivers/soc/qcom/qcom_aoss.o:qcom_aoss.c:(.text+0x5ac): first defined here arm-linux-gnueabi-ld: drivers/cpufreq/cpufreq.o: in function `thermal_of_get_zone_by_index': cpufreq.c:(.text+0x1a7c): multiple definition of `thermal_of_get_zone_by_index'; drivers/soc/qcom/qcom_aoss.o:qcom_aoss.c:(.text+0x5a4): first defined here arm-linux-gnueabi-ld: drivers/cpufreq/cpufreq.o: in function `thermal_of_get_zone': cpufreq.c:(.text+0x1a84): multiple definition of `thermal_of_get_zone'; drivers/soc/qcom/qcom_aoss.o:qcom_aoss.c:(.text+0x5ac): first defined here
Hi AngeloGioacchino, kernel test robot noticed the following build warnings: [auto build test WARNING on rafael-pm/thermal] [also build test WARNING on linus/master v6.7-rc1 next-20231115] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/AngeloGioacchino-Del-Regno/thermal-Add-support-for-device-tree-thermal-zones-consumers/20231114-211656 base: https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git thermal patch link: https://lore.kernel.org/r/20231114131514.89031-1-angelogioacchino.delregno%40collabora.com patch subject: [PATCH] thermal: Add support for device tree thermal zones consumers config: x86_64-rhel-8.3-rust (https://download.01.org/0day-ci/archive/20231115/202311152242.dch1tAh5-lkp@intel.com/config) compiler: clang version 16.0.4 (https://github.com/llvm/llvm-project.git ae42196bc493ffe877a7e3dff8be32035dea4d07) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231115/202311152242.dch1tAh5-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202311152242.dch1tAh5-lkp@intel.com/ All warnings (new ones prefixed by >>): In file included from drivers/cpufreq/cpufreq.c:19: In file included from include/linux/cpu_cooling.h:17: >> include/linux/thermal.h:281:29: warning: no previous prototype for function 'thermal_of_get_zone_by_index' [-Wmissing-prototypes] struct thermal_zone_device *thermal_of_get_zone_by_index(struct device *dev, int index) ^ include/linux/thermal.h:281:1: note: declare 'static' if the function is not intended to be used outside of this translation unit struct thermal_zone_device *thermal_of_get_zone_by_index(struct device *dev, int index) ^ static >> include/linux/thermal.h:286:29: warning: no previous prototype for function 'thermal_of_get_zone' [-Wmissing-prototypes] struct thermal_zone_device *thermal_of_get_zone(struct device *dev, const char *name) ^ include/linux/thermal.h:286:1: note: declare 'static' if the function is not intended to be used outside of this translation unit struct thermal_zone_device *thermal_of_get_zone(struct device *dev, const char *name) ^ static 2 warnings generated. vim +/thermal_of_get_zone_by_index +281 include/linux/thermal.h 280 > 281 struct thermal_zone_device *thermal_of_get_zone_by_index(struct device *dev, int index) 282 { 283 return ERR_PTR(-EOPNOTSUPP); 284 } 285 > 286 struct thermal_zone_device *thermal_of_get_zone(struct device *dev, const char *name) 287 { 288 return ERR_PTR(-EOPNOTSUPP); 289 } 290 #endif 291
diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index 1e0655b63259..d8ead456993e 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -538,6 +538,97 @@ static struct thermal_zone_device *thermal_of_zone_register(struct device_node * return ERR_PTR(ret); } +/** + * __thermal_of_get_zone_by_index() - Get thermal zone handle from the DT + * thermal-zones index + * @dev: Pointer to the consumer device + * @index: Index of thermal-zones + * + * This function will search for a thermal zone in the thermal-zones phandle + * array corresponding to the specified index, then will search for its name + * into the registered thermal zones through thermal_zone_get_zone_by_name() + * + * Please note that this function is for internal use only and expects that + * all of the sanity checks are performed by its caller. + * + * Return: thermal_zone_device pointer on success, ERR_PTR() on error or NULL + * when the API is disabled or the "thermal-zones" DT property is missing. + */ +static struct thermal_zone_device +*__thermal_of_get_zone_by_index(struct device *dev, int index) +{ + struct thermal_zone_device *tzd; + struct device_node *np; + + np = of_parse_phandle(dev->of_node, "thermal-zones", index); + if (!np) + return NULL; + + tzd = thermal_zone_get_zone_by_name(np->name); + of_node_put(np); + + return tzd; +} + +/** + * thermal_of_get_zone_by_index() - Get thermal zone handle from a DT node + * based on index + * @dev: Pointer to the consumer device + * @index: Index of thermal-zones + * + * Return: thermal_zone_device pointer on success, ERR_PTR() on error or NULL + * when the API is disabled or the "thermal-zones" DT property is missing. + */ +struct thermal_zone_device *thermal_of_get_zone_by_index(struct device *dev, int index) +{ + if (!dev || !dev->of_node) + return ERR_PTR(-ENODEV); + + if (!of_property_present(dev->of_node, "thermal-zones")) + return NULL; + + return __thermal_of_get_zone_by_index(dev, index); +} + +/** + * thermal_of_get_zone() - Get thermal zone handle from a DT node based + * on name, or the first handle in list + * @dev: Pointer to the consumer device + * @name: Name as found in thermal-zone-names or NULL + * + * This function will search for a thermal zone in the thermal-zones phandle + * array corresponding to the index of that in the thermal-zone-names array. + * If the name is not specified (NULL), it will return the first thermal zone + * in the thermal-zones phandle array. + * + * Return: thermal_zone_device pointer on success, ERR_PTR() on error or NULL + * when the API is disabled or the "thermal-zones" DT property is missing. + */ +struct thermal_zone_device *thermal_of_get_zone(struct device *dev, const char *name) +{ + int index; + + if (!dev || !dev->of_node) + return ERR_PTR(-ENODEV); + + if (!of_property_present(dev->of_node, "thermal-zones")) { + pr_err("thermal zones property not present\n"); + return NULL; + } + + if (name) { + index = of_property_match_string(dev->of_node, "thermal-zone-names", name); + if (index < 0) { + pr_err("thermal zone names property not present\n"); + return ERR_PTR(index); + } + } else { + index = 0; + } + + return __thermal_of_get_zone_by_index(dev, index); +} + static void devm_thermal_of_zone_release(struct device *dev, void *res) { thermal_of_zone_unregister(*(struct thermal_zone_device **)res); diff --git a/include/linux/thermal.h b/include/linux/thermal.h index cee814d5d1ac..ad70fd55ec23 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -261,6 +261,9 @@ struct thermal_zone_device *devm_thermal_of_zone_register(struct device *dev, in void devm_thermal_of_zone_unregister(struct device *dev, struct thermal_zone_device *tz); +struct thermal_zone_device *thermal_of_get_zone_by_index(struct device *dev, int index); +struct thermal_zone_device *thermal_of_get_zone(struct device *dev, const char *name); + #else static inline @@ -274,6 +277,16 @@ static inline void devm_thermal_of_zone_unregister(struct device *dev, struct thermal_zone_device *tz) { } + +struct thermal_zone_device *thermal_of_get_zone_by_index(struct device *dev, int index) +{ + return ERR_PTR(-EOPNOTSUPP); +} + +struct thermal_zone_device *thermal_of_get_zone(struct device *dev, const char *name) +{ + return ERR_PTR(-EOPNOTSUPP); +} #endif int __thermal_zone_get_trip(struct thermal_zone_device *tz, int trip_id,