Skip to contentSkip to conversation

rfim: add new test for verifying RFIM sysfs interface

PATCH Superseded Piotr Kubaj 3 participants 3 messages Jun 23 – Jun 30

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v4 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.

---

Add rfi_disable, ddr_data_rate and rfi_restriction.

 runtest/power_management_tests               |   1 +
 testcases/kernel/power_management/.gitignore |   1 +
 testcases/kernel/power_management/rfim01.c   | 166 +++++++++++++++++++
 3 files changed, 168 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 +166 -0

166 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 1 line · Piotr Kubaj

rfim: add new test for verifying RFIM sysfs interface

Verdict - Reviewed

---
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
#2 lore raw
In reply to Piotr Kubaj

Hi Piotr,

Quoted 40 lines
testcases/kernel/power_management/rfim01.c new file +40 -0
+#include "tst_test.h"
+
+#define RFIM_ROOT "/sys/bus/pci/devices/0000:00:04.0"
+
+static bool have_dvfs, have_fivr, have_dlvr;
+
+static const char * const fivr_nodes[] = {
+	RFIM_ROOT "/fivr/vco_ref_code_lo",
+	RFIM_ROOT "/fivr/vco_ref_code_hi",
+	RFIM_ROOT "/fivr/spread_spectrum_pct",
+	RFIM_ROOT "/fivr/spread_spectrum_clk_enable",
+	RFIM_ROOT "/fivr/rfi_vco_ref_code",
+	RFIM_ROOT "/fivr/fivr_fffc_rev",
+	NULL
+};
+
+static const char * const ro_dvfs_nodes[] = {
+	RFIM_ROOT "/dvfs/ddr_data_rate_point_0",
+	RFIM_ROOT "/dvfs/ddr_data_rate_point_1",
+	RFIM_ROOT "/dvfs/ddr_data_rate_point_2",
+	RFIM_ROOT "/dvfs/ddr_data_rate_point_3",
+	RFIM_ROOT "/dvfs/ddr_data_rate",
+	NULL
+};
+
+static const char * const ro_dlvr_nodes[] = {
+	RFIM_ROOT "/dlvr/dlvr_hardware_rev",
+	RFIM_ROOT "/dlvr/dlvr_freq_mhz",
+	RFIM_ROOT "/dlvr/dlvr_pll_busy",
+	NULL
+};
+
+static const char * const rw_dlvr_nodes[] = {
+	RFIM_ROOT "/dlvr/dlvr_freq_select",
+	RFIM_ROOT "/dlvr/dlvr_rfim_enable",
+	RFIM_ROOT "/dlvr/dlvr_spread_spectrum_pct",
+	RFIM_ROOT "/dlvr/dlvr_control_mode",
+	RFIM_ROOT "/dlvr/dlvr_control_lock",
+	NULL
+};

testcases/kernel/power_management/rfim01.c line 75

Quoted 10 lines
testcases/kernel/power_management/rfim01.c new file +10 -0
+
+static const char * const rw_dvfs_nodes[] = {
+	RFIM_ROOT "/dvfs/rfi_restriction_run_busy",
+	RFIM_ROOT "/dvfs/rfi_restriction_err_code",
+	RFIM_ROOT "/dvfs/rfi_restriction_data_rate_base",
+	RFIM_ROOT "/dvfs/rfi_restriction_data_rate",
+	RFIM_ROOT "/dvfs/rfi_restriction",
+	RFIM_ROOT "/dvfs/rfi_disable",
+	NULL
+};

I was thinking that we can make it easier now. Instead of verifying RW on different functions, we can simply create a .tcase structure where we assign to each sysfs patch a specific read or write flag. And according to that, we simply make a check inside the run() function.

static struct tcase {
	const char *path;

int read;
int write;
} tcases[] = {
...
};

static run(unsigned int i)

{
	static struct *tc = &tcases[i];
  if (tc->read && !tc->write) {
    /* open with read -> pass */
    /* open with write -> fail */
  } else if (!tc->read && tc->write) {
    /* open with read -> fail */
    /* open with write -> pass */
  } else if (tc->read && tc->write) {
    /* open with read/write -> pass */
  } else {
    /* TBROK */

}
}

Something like this. Feel free to optimize it, it's just a draft.

Regards,
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]

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