From: "Mallesh, Koujalagi" <mallesh.koujalagi@intel.com>
To: "Poosa, Karthik" <karthik.poosa@intel.com>,
<igt-dev@lists.freedesktop.org>
Cc: <anshuman.gupta@intel.com>, <badal.nilawar@intel.com>,
<riana.tauro@intel.com>, <raag.jadav@intel.com>
Subject: Re: [PATCH i-g-t v2] tests/intel/hwmon: Check temperature limit in hwmon-read
Date: Fri, 30 Jan 2026 13:49:55 +0530 [thread overview]
Message-ID: <3d1fc545-237b-428c-978c-a3668ff0929f@intel.com> (raw)
In-Reply-To: <9073233a-42bb-418b-bbc8-766619d5fdb0@intel.com>
[-- Attachment #1: Type: text/plain, Size: 2626 bytes --]
On 30-01-2026 11:46 am, Poosa, Karthik wrote:
>
>
> On 28-01-2026 16:07, Mallesh, Koujalagi wrote:
>>
>>
>> On 24-01-2026 12:05 am, Karthik Poosa wrote:
>>> Improve hwmon-read test to check if current temperature
>>> is above critical temperature limit in hwmon-read test.
>>> This will help identify any thermal issues with the
>>> setups during test runs.
>>>
>>> v2:
>>> - Address review comments. (Mallesh)
>>> - Call check_temp_is_valid() only for temperature hwmon entries.
>> Please change check_if_temp_valid() function name
>>> Signed-off-by: Karthik Poosa<karthik.poosa@intel.com>
>>> ---
>>> tests/intel/intel_hwmon.c | 25 +++++++++++++++++++++++++
>>> 1 file changed, 25 insertions(+)
>>>
>>> diff --git a/tests/intel/intel_hwmon.c b/tests/intel/intel_hwmon.c
>>> index 103ae69cd..9deb48a00 100644
>>> --- a/tests/intel/intel_hwmon.c
>>> +++ b/tests/intel/intel_hwmon.c
>>> @@ -26,6 +26,28 @@
>>>
>>> IGT_TEST_DESCRIPTION("Tests for intel hwmon");
>>>
>>> +static void check_if_temp_valid(int hwm, char *sysfs_name)
>>> +{
>>> + char str[32] = {0};
>>> + uint32_t cur_temp = 0;
>>> + uint8_t ch = 0;
>>> + s32 limit = 0;
>>> +
>>> + /* Get the channel number and sysfs entry suffix. */
>>> + igt_assert(sscanf(sysfs_name, "temp%hhu_%s", &ch, str) == 2);
>>
>> Buffer overflow when string length more than 31, we can use
>> "temp%hhu_%31s" as defensive.
>>
> maximum length of hwmon sysfs attribute is 32 Bytes
>
> See: in drivers/hwmon/hwmon.c
>
> #define MAX_SYSFS_ATTR_NAME_LENGTH 32
>
> So existing 32 bytes of str should suffice.
>
Agreed that hwmon sysfs attribute (32 bytes) which makes overflow unlikely.
Thanks,
-/Mallesh
>> Thanks,
>>
>> -/Mallesh
>>
>>> +
>>> + /* If entry is tempX_input, check if it exceeds tempX_crit. */
>>> + if (!strncmp("input", str, 5)) {
>>> + sprintf(str, "temp%hhu_crit", ch);
>>> + if (!faccessat(hwm, str, R_OK, 0)) {
>>> + igt_assert_lt(0, igt_sysfs_scanf(hwm, sysfs_name, "%d", &cur_temp));
>>> + igt_assert_lt(0, igt_sysfs_scanf(hwm, str, "%d", &limit));
>>> + igt_debug("current temp = %d limit = %d\n", cur_temp, limit);
>>> + igt_assert_f(cur_temp <= limit, "current temperature exceeds limit!\n");
>>> + }
>>> + }
>>> +}
>>> +
>>> static void hwmon_read(int hwm)
>>> {
>>> struct dirent *de;
>>> @@ -43,6 +65,9 @@ static void hwmon_read(int hwm)
>>> igt_assert(igt_sysfs_scanf(hwm, de->d_name, "%127s", val) == 1);
>>> igt_debug("'%s': %s\n", de->d_name, val);
>>>
>>> + if (!strncmp(de->d_name, "temp", 4))
>>> + check_if_temp_valid(hwm, de->d_name);
>>> +
>>> }
>>> closedir(dir);
>>> }
[-- Attachment #2: Type: text/html, Size: 4169 bytes --]
prev parent reply other threads:[~2026-01-30 8:20 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-23 18:35 [PATCH i-g-t v2] tests/intel/hwmon: Check temperature limit in hwmon-read Karthik Poosa
2026-01-23 19:09 ` ✓ Xe.CI.BAT: success for tests/intel/hwmon: Check temperature limit in hwmon-read (rev2) Patchwork
2026-01-23 19:21 ` ✓ i915.CI.BAT: " Patchwork
2026-01-24 0:08 ` ✗ i915.CI.Full: failure " Patchwork
2026-01-24 3:41 ` ✗ Xe.CI.Full: " Patchwork
2026-01-28 10:37 ` [PATCH i-g-t v2] tests/intel/hwmon: Check temperature limit in hwmon-read Mallesh, Koujalagi
2026-01-30 6:16 ` Poosa, Karthik
2026-01-30 8:19 ` Mallesh, Koujalagi [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=3d1fc545-237b-428c-978c-a3668ff0929f@intel.com \
--to=mallesh.koujalagi@intel.com \
--cc=anshuman.gupta@intel.com \
--cc=badal.nilawar@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=karthik.poosa@intel.com \
--cc=raag.jadav@intel.com \
--cc=riana.tauro@intel.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