public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <krzk@kernel.org>
To: Michal Simek <michal.simek@amd.com>,
	linux-kernel@vger.kernel.org, monstr@monstr.eu,
	michal.simek@xilinx.com, git@xilinx.com
Cc: Anish Kadamathikuttiyil Karthikeyan Pillai
	<anish.kadamathikuttiyil-karthikeyan-pillai@amd.com>,
	Daniel Lezcano <daniel.lezcano@linaro.org>,
	Lukasz Luba <lukasz.luba@arm.com>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Salih Erim <salih.erim@amd.com>, Zhang Rui <rui.zhang@intel.com>,
	"open list:THERMAL" <linux-pm@vger.kernel.org>
Subject: Re: [PATCH 6/6] thermal: versal-thermal: Support thermal management in AI Engine
Date: Fri, 5 Sep 2025 12:48:06 +0200	[thread overview]
Message-ID: <dc42cadc-bfc9-4473-ad90-aaab88101b49@kernel.org> (raw)
In-Reply-To: <3636099d5d0b31ebf232a5b2e741f0ff7e7e1631.1757061697.git.michal.simek@amd.com>

On 05/09/2025 10:41, Michal Simek wrote:
> +	vti->channel = iio_channel_get(NULL, SYSMON_TEMP_CH_NAME);
> +	if (IS_ERR(vti->channel)) {
> +		vti->num_aie_channels = 0;
> +		versal_thermal_iio_chan_release(vti);
> +		return dev_err_probe(&pdev->dev, PTR_ERR(vti->channel),
> +							"IIO channel %s not found\n",
> +							SYSMON_TEMP_CH_NAME);
> +	}
> +
>  	vti->tzd = devm_thermal_of_zone_register(&pdev->dev, 0, vti, &thermal_zone_ops);
>  	if (IS_ERR(vti->tzd))
>  		return dev_err_probe(&pdev->dev, PTR_ERR(vti->tzd),
>  				     "Thermal zone sensor register failed\n");
>  
> -	return devm_thermal_add_hwmon_sysfs(&pdev->dev, vti->tzd);
> +	ret = devm_thermal_add_hwmon_sysfs(&pdev->dev, vti->tzd);
> +	if (ret)
> +		return dev_err_probe(&pdev->dev, ret,
> +				     "Failed to add hwmon sysfs for sysmon temp\n");
> +
> +	sysmon_node = of_find_node_by_name(NULL, "sysmon");

Undocumented ABI. Please don't do that. sysmon is not an approved name
and for sure can be changed anytime to anything.

Phandles express relationships usually.


> +	if (sysmon_node) {
> +		ret = of_property_read_u32(sysmon_node, "xlnx,numaiechannels",
> +					   &num_aie_channels);
> +		if (ret < 0)
> +			num_aie_channels = 0;
> +	}
> +
> +	if (num_aie_channels > 0) {
> +		aie_temp_chan_names = devm_kcalloc(&pdev->dev, num_aie_channels,
> +						   sizeof(*aie_temp_chan_names),
> +						   GFP_KERNEL);
> +		if (!aie_temp_chan_names)
> +			return -ENOMEM;
> +
> +		for_each_child_of_node(sysmon_node, child_node) {
> +			if (of_property_present(child_node, "xlnx,aie-temp")) {
> +				ret = of_property_read_string(child_node, "xlnx,name",
> +							      &aie_temp_chan_name);
> +				if (ret < 0) {
> +					of_node_put(child_node);
> +					return ret;
> +				}
> +				aie_temp_chan_names[aie_ch_index] = aie_temp_chan_name;
> +				aie_ch_index++;
> +			}
> +		}
> +
> +		/* Allocate memory for the dynamic aie temperature channels */
> +		vti->channel_aie = devm_kcalloc(&pdev->dev, num_aie_channels,
> +						sizeof(*vti->channel_aie), GFP_KERNEL);
> +		if (!vti->channel_aie)
> +			return -ENOMEM;
> +
> +		for (aie_ch_index = 0; aie_ch_index < num_aie_channels; aie_ch_index++) {
> +			vti->channel_aie[aie_ch_index] =
> +			    iio_channel_get(NULL, aie_temp_chan_names[aie_ch_index]);
> +			if (IS_ERR(vti->channel_aie[aie_ch_index])) {
> +				vti->num_aie_channels = aie_ch_index + 1;
> +				versal_thermal_iio_chan_release(vti);
> +				return dev_err_probe(&pdev->dev,
> +						     PTR_ERR(vti->channel_aie[aie_ch_index]),
> +						     "IIO AIE TEMP channel %s not found\n",
> +						     aie_temp_chan_names[aie_ch_index]);
> +			}
> +		}
> +
> +		vti->tzd_aie = devm_thermal_of_zone_register(&pdev->dev, 1, vti,
> +							     &thermal_zone_ops_aie);
> +		if (IS_ERR(vti->tzd_aie))
> +			return dev_err_probe(&pdev->dev, PTR_ERR(vti->tzd_aie),
> +					      "Failed to register thermal zone aie temp\n");
> +
> +		ret = devm_thermal_add_hwmon_sysfs(&pdev->dev, vti->tzd_aie);
> +		if (ret)
> +			return dev_err_probe(&pdev->dev, ret,
> +					     "Failed to add hwmon sysfs for aie temp\n");
> +	}
> +	vti->num_aie_channels = num_aie_channels;
> +	platform_set_drvdata(pdev, vti);
> +	return 0;
> +}
> +
> +static void versal_thermal_remove(struct platform_device *pdev)
> +{
> +	struct versal_thermal_info *vti = platform_get_drvdata(pdev);
> +
> +	versal_thermal_iio_chan_release(vti);

Don't mix non-devm with devm. This should be a proper devm cleanup action.



Best regards,
Krzysztof

      reply	other threads:[~2025-09-05 10:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-05  8:41 [PATCH 0/6] xilinx: Add support for Xilinx Sysmon IP Michal Simek
2025-09-05  8:41 ` [PATCH 4/6] dt-bindings: thermal: versal: Add description for Versal Thermal Michal Simek
2025-09-05 18:30   ` Conor Dooley
2025-09-08  6:39     ` Michal Simek
2025-09-05  8:41 ` [PATCH 5/6] thermal: versal-thermal: Add Versal thermal driver Michal Simek
2025-09-05  8:41 ` [PATCH 6/6] thermal: versal-thermal: Support thermal management in AI Engine Michal Simek
2025-09-05 10:48   ` Krzysztof Kozlowski [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=dc42cadc-bfc9-4473-ad90-aaab88101b49@kernel.org \
    --to=krzk@kernel.org \
    --cc=anish.kadamathikuttiyil-karthikeyan-pillai@amd.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=git@xilinx.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=lukasz.luba@arm.com \
    --cc=michal.simek@amd.com \
    --cc=michal.simek@xilinx.com \
    --cc=monstr@monstr.eu \
    --cc=rafael@kernel.org \
    --cc=rui.zhang@intel.com \
    --cc=salih.erim@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox