1 // SPDX-License-Identifier: GPL-2.0-only
3 * POWER Data Stream Control Register (DSCR) sysfs thread test
5 * This test updates the system wide DSCR default value through
6 * sysfs interface which should then update all the CPU specific
7 * DSCR default values which must also be then visible to threads
8 * executing on individual CPUs on the system.
10 * Copyright 2015, Anshuman Khandual, IBM Corporation.
15 static int test_thread_dscr(unsigned long val)
17 unsigned long cur_dscr, cur_dscr_usr;
19 cur_dscr = get_dscr();
20 cur_dscr_usr = get_dscr_usr();
22 if (val != cur_dscr) {
23 printf("[cpu %d] Kernel DSCR should be %ld but is %ld\n",
24 sched_getcpu(), val, cur_dscr);
28 if (val != cur_dscr_usr) {
29 printf("[cpu %d] User DSCR should be %ld but is %ld\n",
30 sched_getcpu(), val, cur_dscr_usr);
36 static int check_cpu_dscr_thread(unsigned long val)
41 for (cpu = 0; cpu < CPU_SETSIZE; cpu++) {
44 if (sched_setaffinity(0, sizeof(mask), &mask))
47 if (test_thread_dscr(val))
54 int dscr_sysfs_thread(void)
56 unsigned long orig_dscr_default;
59 SKIP_IF(!have_hwcap2(PPC_FEATURE2_DSCR));
61 orig_dscr_default = get_default_dscr();
62 for (i = 0; i < COUNT; i++) {
63 for (j = 0; j < DSCR_MAX; j++) {
65 if (check_cpu_dscr_thread(j))
69 set_default_dscr(orig_dscr_default);
72 set_default_dscr(orig_dscr_default);
76 int main(int argc, char *argv[])
78 return test_harness(dscr_sysfs_thread, "dscr_sysfs_thread_test");