~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/powerpc/dscr/dscr_sysfs_test.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0-only
  2 /*
  3  * POWER Data Stream Control Register (DSCR) sysfs interface test
  4  *
  5  * This test updates to system wide DSCR default through the sysfs interface
  6  * and then verifies that all the CPU specific DSCR defaults are updated as
  7  * well verified from their sysfs interfaces.
  8  *
  9  * Copyright 2015, Anshuman Khandual, IBM Corporation.
 10  */
 11 #include "dscr.h"
 12 
 13 static int check_cpu_dscr_default(char *file, unsigned long val)
 14 {
 15         unsigned long cpu_dscr;
 16         int err;
 17 
 18         err = read_ulong(file, &cpu_dscr, 16);
 19         if (err)
 20                 return err;
 21 
 22         if (cpu_dscr != val) {
 23                 printf("DSCR match failed: %ld (system) %ld (cpu)\n",
 24                                         val, cpu_dscr);
 25                 return 1;
 26         }
 27         return 0;
 28 }
 29 
 30 static int check_all_cpu_dscr_defaults(unsigned long val)
 31 {
 32         DIR *sysfs;
 33         struct dirent *dp;
 34         char file[LEN_MAX];
 35 
 36         sysfs = opendir(CPU_PATH);
 37         if (!sysfs) {
 38                 perror("opendir() failed");
 39                 return 1;
 40         }
 41 
 42         while ((dp = readdir(sysfs))) {
 43                 int len;
 44 
 45                 if (!(dp->d_type & DT_DIR))
 46                         continue;
 47                 if (!strcmp(dp->d_name, "cpuidle"))
 48                         continue;
 49                 if (!strstr(dp->d_name, "cpu"))
 50                         continue;
 51 
 52                 len = snprintf(file, LEN_MAX, "%s%s/dscr", CPU_PATH, dp->d_name);
 53                 if (len >= LEN_MAX)
 54                         continue;
 55                 if (access(file, F_OK))
 56                         continue;
 57 
 58                 if (check_cpu_dscr_default(file, val)) {
 59                         closedir(sysfs);
 60                         return 1;
 61                 }
 62         }
 63         closedir(sysfs);
 64         return 0;
 65 }
 66 
 67 int dscr_sysfs(void)
 68 {
 69         unsigned long orig_dscr_default;
 70 
 71         SKIP_IF(!have_hwcap2(PPC_FEATURE2_DSCR));
 72 
 73         orig_dscr_default = get_default_dscr();
 74         for (int i = 0; i < DSCR_MAX; i++) {
 75                 set_default_dscr(i);
 76                 if (check_all_cpu_dscr_defaults(i))
 77                         goto fail;
 78         }
 79         set_default_dscr(orig_dscr_default);
 80         return 0;
 81 fail:
 82         set_default_dscr(orig_dscr_default);
 83         return 1;
 84 }
 85 
 86 int main(int argc, char *argv[])
 87 {
 88         return test_harness(dscr_sysfs, "dscr_sysfs_test");
 89 }
 90 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php