Skip to contentSkip to conversation

rfim: add new test for verifying RFIM sysfs interface

PATCH Superseded Piotr Kubaj 2 participants 2 messages Jun 18

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 rfim: add new test for verifying RFIM sysfs interface

Validate presence and permissions of the RFIM attributes exposed by the Intel processor_thermal driver under the proc_thermal PCI device.

The kernel creates the dvfs, fivr and dlvr attribute groups independently, each gated on its own per-device feature bit, so the test detects which of the three groups the hardware presents and checks only those. This covers platforms that expose both FIVR and DLVR (e.g. Meteor Lake) as well as those with FIVR but no DVFS (e.g. Tiger Lake).

Read-only attributes (mode 0444) must accept O_RDONLY and reject a write open with EACCES; read-write attributes (mode 0644) must accept O_RDWR. The open() itself is what exercises access, since sysfs can refuse it in kernfs even when the mode bits would allow it.

The test works only on Intel platforms with RFIM and needs root for the read-write attributes, whose write bit is owner-only.

---
Address feedback.
Additionaly:
1. I found that there are machines without DVFS, so don't require it.
2. It's possible for both FIVR and DLVR to be present, so don't assume they are exclusive.

Regarding TST_EXP_FAIL(), I found that TST_EXP_FD() and TST_EXP_FAIL2() fit better here.

 runtest/power_management_tests               |   1 +
 testcases/kernel/power_management/.gitignore |   1 +
 testcases/kernel/power_management/rfim01.c   | 163 +++++++++++++++++++
 3 files changed, 165 insertions(+)
 create mode 100644 testcases/kernel/power_management/rfim01.c
runtest/power_management_tests +1 -0
index 4da57ee72..d05c95608 100644
@@ -1,5 +1,6 @@
 #POWER_MANAGEMENT
 high_freq_hwp_cap_cppc high_freq_hwp_cap_cppc
+rfim01 rfim01
 runpwtests03 runpwtests03.sh
 runpwtests04 runpwtests04.sh
 runpwtests06 runpwtests06.sh
testcases/kernel/power_management/.gitignore +1 -0
index 03f0c83e4..74f6df14f 100644
@@ -1 +1,2 @@
 high_freq_hwp_cap_cppc
+rfim01
testcases/kernel/power_management/rfim01.c new file +163 -0

163 lines not on this page · raw message

Signature · 13 lines
2.47.3

---------------------------------------------------------------------
Intel Technology Poland sp. z o.o.
ul. Slowackiego 173 | 80-298 Gdansk | Sad Rejonowy Gdansk Polnoc | VII Wydzial Gospodarczy Krajowego Rejestru Sadowego - KRS 101882 | NIP 957-07-52-316 | Kapital zakladowy 200.000 PLN.
Spolka oswiadcza, ze posiada status duzego przedsiebiorcy w rozumieniu ustawy z dnia 8 marca 2013 r. o przeciwdzialaniu nadmiernym opoznieniom w transakcjach handlowych.

Ta wiadomosc wraz z zalacznikami jest przeznaczona dla okreslonego adresata i moze zawierac informacje poufne. W razie przypadkowego otrzymania tej wiadomosci, prosimy o powiadomienie nadawcy oraz trwale jej usuniecie; jakiekolwiek przegladanie lub rozpowszechnianie jest zabronione.
This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). If you are not the intended recipient, please contact the sender and delete all copies; any review or distribution by others is strictly prohibited.


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

Hi Piotr,

Quoted 3 lines · Piotr Kubaj

rfim: add new test for verifying RFIM sysfs interface

+#define RFIM_ROOT "/sys/bus/pci/devices/0000:00:04.0"

The PCI BDF is hardcoded here. The proc_thermal driver matches by PCI device ID (PCI_DEVICE_ID_INTEL_*_THERMAL), not by slot. While 00:04.0 is the typical BDF on current Intel client SoCs, could this be discovered dynamically instead -- e.g. by scanning /sys/bus/pci/devices/*/driver for a proc_thermal link, or by looking up the device via its class or vendor:device pair?

This would prevent a silent TCONF on any future platform where the thermal device appears at a different BDF.

testcases/kernel/power_management/rfim01.c line 108

Quoted 6 lines
testcases/kernel/power_management/rfim01.c new file +6 -0
+static void check_read_only(const char *path)
+{
+	int fd = TST_EXP_FD(open(path, O_RDONLY));
+
+	if (fd >= 0)
+		SAFE_CLOSE(fd);

LTP convention is to use "fd != -1" rather than "fd >= 0" for fd validity checks. Same applies in check_read_write().

Verdict - Needs revision

---
Note:

The agent can sometimes produce false positives although often its findings are genuine. If you find issues with the review, please comment this email or ignore the suggestions.

Regards,
LTP AI Reviewer

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp