Merge branches 'pm-domains', 'pm-avs' and 'powercap'
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 3 Jul 2017 12:22:34 +0000 (14:22 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 3 Jul 2017 12:22:34 +0000 (14:22 +0200)
* pm-domains:
  PM / Domains: Fix missing default_power_down_ok comment
  PM / Domains: Fix unsafe iteration over modified list of domains
  PM / Domains: Fix unsafe iteration over modified list of domain providers
  PM / Domains: Fix unsafe iteration over modified list of device links
  PM / Domains: Handle safely genpd_syscore_switch() call on non-genpd device
  PM / Domains: Call driver's noirq callbacks
  PM / Domains: Constify genpd pointer
  PM / Domains: pdd->dev can't be NULL in genpd_dev_pm_qos_notifier()

* pm-avs:
  PM / AVS: rockchip-io: add io selectors and supplies for rk3228

* powercap:
  powercap/RAPL: prevent overridding bits outside of the mask

117 files changed:
Documentation/admin-guide/pm/cpufreq.rst
Documentation/admin-guide/pm/intel_pstate.rst
Documentation/devicetree/bindings/opp/opp.txt
MAINTAINERS
arch/s390/include/asm/sysinfo.h
arch/s390/kernel/sysinfo.c
arch/x86/include/asm/msr-index.h
arch/x86/include/asm/suspend_64.h
arch/x86/kernel/acpi/cstate.c
arch/x86/kernel/cpu/Makefile
arch/x86/kernel/cpu/aperfmperf.c [new file with mode: 0644]
arch/x86/kernel/cpu/proc.c
arch/x86/power/hibernate_64.c
block/partitions/ldm.c
block/partitions/ldm.h
drivers/acpi/acpi_extlog.c
drivers/acpi/apei/ghes.c
drivers/acpi/bus.c
drivers/acpi/nfit/core.c
drivers/acpi/nfit/nfit.h
drivers/acpi/utils.c
drivers/base/power/domain.c
drivers/base/power/domain_governor.c
drivers/base/power/main.c
drivers/base/power/opp/core.c
drivers/base/power/opp/debugfs.c
drivers/base/power/opp/of.c
drivers/base/power/sysfs.c
drivers/base/power/wakeup.c
drivers/char/tpm/tpm_crb.c
drivers/char/tpm/tpm_ppi.c
drivers/cpufreq/cppc_cpufreq.c
drivers/cpufreq/cpufreq-dt-platdev.c
drivers/cpufreq/cpufreq.c
drivers/cpufreq/exynos5440-cpufreq.c
drivers/cpufreq/imx6q-cpufreq.c
drivers/cpufreq/intel_pstate.c
drivers/cpufreq/sfi-cpufreq.c
drivers/cpuidle/Kconfig.arm
drivers/cpuidle/cpuidle-arm.c
drivers/cpuidle/governors/menu.c
drivers/gpu/drm/i915/intel_acpi.c
drivers/gpu/drm/nouveau/nouveau_acpi.c
drivers/gpu/drm/nouveau/nvkm/subdev/mxm/base.c
drivers/hid/i2c-hid/i2c-hid.c
drivers/idle/intel_idle.c
drivers/iommu/dmar.c
drivers/md/md.c
drivers/mmc/host/sdhci-pci-core.c
drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c
drivers/nvdimm/btt_devs.c
drivers/nvme/host/fabrics.c
drivers/nvme/host/fabrics.h
drivers/nvme/host/fc.c
drivers/nvme/target/nvmet.h
drivers/pci/pci-acpi.c
drivers/pci/pci-label.c
drivers/powercap/intel_rapl.c
drivers/scsi/scsi_debug.c
drivers/thermal/int340x_thermal/int3400_thermal.c
drivers/usb/dwc3/dwc3-pci.c
drivers/usb/host/xhci-pci.c
drivers/usb/misc/ucsi.c
drivers/usb/typec/typec_wcove.c
drivers/xen/tmem.c
fs/afs/cmservice.c
fs/afs/internal.h
fs/afs/main.c
fs/ext4/super.c
fs/f2fs/super.c
fs/gfs2/ops_fstype.c
fs/gfs2/sys.c
fs/nfsd/export.c
fs/ocfs2/super.c
fs/overlayfs/copy_up.c
fs/overlayfs/namei.c
fs/overlayfs/overlayfs.h
fs/xfs/Makefile
fs/xfs/uuid.c [deleted file]
fs/xfs/uuid.h [deleted file]
fs/xfs/xfs_inode_item.c
fs/xfs/xfs_linux.h
fs/xfs/xfs_log_recover.c
fs/xfs/xfs_mount.c
include/acpi/acpi_bus.h
include/linux/acpi.h
include/linux/cleancache.h
include/linux/cpufreq.h
include/linux/fs.h
include/linux/genhd.h
include/linux/nvme-fc.h
include/linux/nvme.h
include/linux/pci-acpi.h
include/linux/pm_opp.h
include/linux/uuid.h
include/uapi/linux/uuid.h
kernel/power/hibernate.c
kernel/power/snapshot.c
kernel/sysctl_binary.c
lib/test_uuid.c
lib/uuid.c
lib/vsprintf.c
mm/cleancache.c
mm/shmem.c
security/integrity/evm/evm_crypto.c
security/integrity/ima/ima_policy.c
sound/soc/intel/skylake/skl-nhlt.c
tools/power/cpupower/utils/helpers/amd.c
tools/power/cpupower/utils/helpers/helpers.h
tools/power/cpupower/utils/helpers/misc.c
tools/power/x86/turbostat/turbostat.c
tools/power/x86/x86_energy_perf_policy/Makefile
tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.8
tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c
tools/testing/nvdimm/test/iomap.c
tools/testing/nvdimm/test/nfit.c
tools/testing/nvdimm/test/nfit_test.h

index 09aa2e9497875acec984dc68727e14139c5d23ad..463cf7e73db80b3bf3f8a36afe91bcf3d7f0d429 100644 (file)
@@ -269,16 +269,16 @@ are the following:
 ``scaling_cur_freq``
        Current frequency of all of the CPUs belonging to this policy (in kHz).
 
-       For the majority of scaling drivers, this is the frequency of the last
-       P-state requested by the driver from the hardware using the scaling
+       In the majority of cases, this is the frequency of the last P-state
+       requested by the scaling driver from the hardware using the scaling
        interface provided by it, which may or may not reflect the frequency
        the CPU is actually running at (due to hardware design and other
        limitations).
 
-       Some scaling drivers (e.g. |intel_pstate|) attempt to provide
-       information more precisely reflecting the current CPU frequency through
-       this attribute, but that still may not be the exact current CPU
-       frequency as seen by the hardware at the moment.
+       Some architectures (e.g. ``x86``) may attempt to provide information
+       more precisely reflecting the current CPU frequency through this
+       attribute, but that still may not be the exact current CPU frequency as
+       seen by the hardware at the moment.
 
 ``scaling_driver``
        The scaling driver currently in use.
index 33d703989ea80b3b6cf6ee3abcc57576185d987c..1d6249825efc81947955c4b677b7e8e2607ee5aa 100644 (file)
@@ -157,10 +157,8 @@ Without HWP, this P-state selection algorithm is always the same regardless of
 the processor model and platform configuration.
 
 It selects the maximum P-state it is allowed to use, subject to limits set via
-``sysfs``, every time the P-state selection computations are carried out by the
-driver's utilization update callback for the given CPU (that does not happen
-more often than every 10 ms), but the hardware configuration will not be changed
-if the new P-state is the same as the current one.
+``sysfs``, every time the driver configuration for the given CPU is updated
+(e.g. via ``sysfs``).
 
 This is the default P-state selection algorithm if the
 :c:macro:`CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE` kernel configuration option
index 63725498bd2068664a4254d26996be388705e00c..e36d261b9ba6427518487b2f7fcbc4692a80a648 100644 (file)
@@ -186,20 +186,20 @@ Example 1: Single cluster Dual-core ARM cortex A9, switch DVFS states together.
                compatible = "operating-points-v2";
                opp-shared;
 
-               opp@1000000000 {
+               opp-1000000000 {
                        opp-hz = /bits/ 64 <1000000000>;
                        opp-microvolt = <975000 970000 985000>;
                        opp-microamp = <70000>;
                        clock-latency-ns = <300000>;
                        opp-suspend;
                };
-               opp@1100000000 {
+               opp-1100000000 {
                        opp-hz = /bits/ 64 <1100000000>;
                        opp-microvolt = <1000000 980000 1010000>;
                        opp-microamp = <80000>;
                        clock-latency-ns = <310000>;
                };
-               opp@1200000000 {
+               opp-1200000000 {
                        opp-hz = /bits/ 64 <1200000000>;
                        opp-microvolt = <1025000>;
                        clock-latency-ns = <290000>;
@@ -265,20 +265,20 @@ independently.
                 * independently.
                 */
 
-               opp@1000000000 {
+               opp-1000000000 {
                        opp-hz = /bits/ 64 <1000000000>;
                        opp-microvolt = <975000 970000 985000>;
                        opp-microamp = <70000>;
                        clock-latency-ns = <300000>;
                        opp-suspend;
                };
-               opp@1100000000 {
+               opp-1100000000 {
                        opp-hz = /bits/ 64 <1100000000>;
                        opp-microvolt = <1000000 980000 1010000>;
                        opp-microamp = <80000>;
                        clock-latency-ns = <310000>;
                };
-               opp@1200000000 {
+               opp-1200000000 {
                        opp-hz = /bits/ 64 <1200000000>;
                        opp-microvolt = <1025000>;
                        opp-microamp = <90000;
@@ -341,20 +341,20 @@ DVFS state together.
                compatible = "operating-points-v2";
                opp-shared;
 
-               opp@1000000000 {
+               opp-1000000000 {
                        opp-hz = /bits/ 64 <1000000000>;
                        opp-microvolt = <975000 970000 985000>;
                        opp-microamp = <70000>;
                        clock-latency-ns = <300000>;
                        opp-suspend;
                };
-               opp@1100000000 {
+               opp-1100000000 {
                        opp-hz = /bits/ 64 <1100000000>;
                        opp-microvolt = <1000000 980000 1010000>;
                        opp-microamp = <80000>;
                        clock-latency-ns = <310000>;
                };
-               opp@1200000000 {
+               opp-1200000000 {
                        opp-hz = /bits/ 64 <1200000000>;
                        opp-microvolt = <1025000>;
                        opp-microamp = <90000>;
@@ -367,20 +367,20 @@ DVFS state together.
                compatible = "operating-points-v2";
                opp-shared;
 
-               opp@1300000000 {
+               opp-1300000000 {
                        opp-hz = /bits/ 64 <1300000000>;
                        opp-microvolt = <1050000 1045000 1055000>;
                        opp-microamp = <95000>;
                        clock-latency-ns = <400000>;
                        opp-suspend;
                };
-               opp@1400000000 {
+               opp-1400000000 {
                        opp-hz = /bits/ 64 <1400000000>;
                        opp-microvolt = <1075000>;
                        opp-microamp = <100000>;
                        clock-latency-ns = <400000>;
                };
-               opp@1500000000 {
+               opp-1500000000 {
                        opp-hz = /bits/ 64 <1500000000>;
                        opp-microvolt = <1100000 1010000 1110000>;
                        opp-microamp = <95000>;
@@ -409,7 +409,7 @@ Example 4: Handling multiple regulators
                compatible = "operating-points-v2";
                opp-shared;
 
-               opp@1000000000 {
+               opp-1000000000 {
                        opp-hz = /bits/ 64 <1000000000>;
                        opp-microvolt = <970000>, /* Supply 0 */
                                        <960000>, /* Supply 1 */
@@ -422,7 +422,7 @@ Example 4: Handling multiple regulators
 
                /* OR */
 
-               opp@1000000000 {
+               opp-1000000000 {
                        opp-hz = /bits/ 64 <1000000000>;
                        opp-microvolt = <975000 970000 985000>, /* Supply 0 */
                                        <965000 960000 975000>, /* Supply 1 */
@@ -435,7 +435,7 @@ Example 4: Handling multiple regulators
 
                /* OR */
 
-               opp@1000000000 {
+               opp-1000000000 {
                        opp-hz = /bits/ 64 <1000000000>;
                        opp-microvolt = <975000 970000 985000>, /* Supply 0 */
                                        <965000 960000 975000>, /* Supply 1 */
@@ -467,7 +467,7 @@ Example 5: opp-supported-hw
                status = "okay";
                opp-shared;
 
-               opp@600000000 {
+               opp-600000000 {
                        /*
                         * Supports all substrate and process versions for 0xF
                         * cuts, i.e. only first four cuts.
@@ -478,7 +478,7 @@ Example 5: opp-supported-hw
                        ...
                };
 
-               opp@800000000 {
+               opp-800000000 {
                        /*
                         * Supports:
                         * - cuts: only one, 6th cut (represented by 6th bit).
@@ -510,7 +510,7 @@ Example 6: opp-microvolt-<name>, opp-microamp-<name>:
                compatible = "operating-points-v2";
                opp-shared;
 
-               opp@1000000000 {
+               opp-1000000000 {
                        opp-hz = /bits/ 64 <1000000000>;
                        opp-microvolt-slow = <915000 900000 925000>;
                        opp-microvolt-fast = <975000 970000 985000>;
@@ -518,7 +518,7 @@ Example 6: opp-microvolt-<name>, opp-microamp-<name>:
                        opp-microamp-fast =  <71000>;
                };
 
-               opp@1200000000 {
+               opp-1200000000 {
                        opp-hz = /bits/ 64 <1200000000>;
                        opp-microvolt-slow = <915000 900000 925000>, /* Supply vcc0 */
                                              <925000 910000 935000>; /* Supply vcc1 */
index 09b5ab6a8a5ce8fd66bed85f30b9ca7db26c14c2..8b9b56d5806587b065fe4599e2ceec05bafe7004 100644 (file)
@@ -13462,6 +13462,17 @@ W:     http://en.wikipedia.org/wiki/Util-linux
 T:     git git://git.kernel.org/pub/scm/utils/util-linux/util-linux.git
 S:     Maintained
 
+UUID HELPERS
+M:     Christoph Hellwig <hch@lst.de>
+R:     Andy Shevchenko <andriy.shevchenko@linux.intel.com>
+L:     linux-kernel@vger.kernel.org
+T:     git git://git.infradead.org/users/hch/uuid.git
+F:     lib/uuid.c
+F:     lib/test_uuid.c
+F:     include/linux/uuid.h
+F:     include/uapi/linux/uuid.h
+S:     Maintained
+
 UVESAFB DRIVER
 M:     Michal Januszewski <spock@gentoo.org>
 L:     linux-fbdev@vger.kernel.org
index e784bed6ed7ffb24cabb02eb92a1d90494e3b7e1..2b498e58b91424b30d1f832aaf9eb1bda2fdf60a 100644 (file)
@@ -109,7 +109,7 @@ struct sysinfo_2_2_2 {
        unsigned short cpus_shared;
        char reserved_4[3];
        unsigned char vsne;
-       uuid_be uuid;
+       uuid_t uuid;
        char reserved_5[160];
        char ext_name[256];
 };
@@ -134,7 +134,7 @@ struct sysinfo_3_2_2 {
                char reserved_1[3];
                unsigned char evmne;
                unsigned int reserved_2;
-               uuid_be uuid;
+               uuid_t uuid;
        } vm[8];
        char reserved_3[1504];
        char ext_names[8][256];
index eefcb54872a59326e9178978fcff4b0814a97432..fb869b10382567d3be66c1c73e7beaa06876f942 100644 (file)
@@ -242,7 +242,7 @@ static void print_ext_name(struct seq_file *m, int lvl,
 
 static void print_uuid(struct seq_file *m, int i, struct sysinfo_3_2_2 *info)
 {
-       if (!memcmp(&info->vm[i].uuid, &NULL_UUID_BE, sizeof(uuid_be)))
+       if (uuid_is_null(&info->vm[i].uuid))
                return;
        seq_printf(m, "VM%02d UUID:            %pUb\n", i, &info->vm[i].uuid);
 }
index 673f9ac50f6d12612612e8efcce4eab0ef98bcbb..d8638e2419cc922208357b133e432dff09fb0916 100644 (file)
 #define HWP_MIN_PERF(x)                (x & 0xff)
 #define HWP_MAX_PERF(x)                ((x & 0xff) << 8)
 #define HWP_DESIRED_PERF(x)            ((x & 0xff) << 16)
-#define HWP_ENERGY_PERF_PREFERENCE(x)  ((x & 0xff) << 24)
-#define HWP_ACTIVITY_WINDOW(x)         ((x & 0xff3) << 32)
-#define HWP_PACKAGE_CONTROL(x)         ((x & 0x1) << 42)
+#define HWP_ENERGY_PERF_PREFERENCE(x)  (((unsigned long long) x & 0xff) << 24)
+#define HWP_EPP_PERFORMANCE            0x00
+#define HWP_EPP_BALANCE_PERFORMANCE    0x80
+#define HWP_EPP_BALANCE_POWERSAVE      0xC0
+#define HWP_EPP_POWERSAVE              0xFF
+#define HWP_ACTIVITY_WINDOW(x)         ((unsigned long long)(x & 0xff3) << 32)
+#define HWP_PACKAGE_CONTROL(x)         ((unsigned long long)(x & 0x1) << 42)
 
 /* IA32_HWP_STATUS */
 #define HWP_GUARANTEED_CHANGE(x)       (x & 0x1)
 #define MSR_MISC_PWR_MGMT              0x000001aa
 
 #define MSR_IA32_ENERGY_PERF_BIAS      0x000001b0
-#define ENERGY_PERF_BIAS_PERFORMANCE   0
-#define ENERGY_PERF_BIAS_NORMAL                6
-#define ENERGY_PERF_BIAS_POWERSAVE     15
+#define ENERGY_PERF_BIAS_PERFORMANCE           0
+#define ENERGY_PERF_BIAS_BALANCE_PERFORMANCE   4
+#define ENERGY_PERF_BIAS_NORMAL                        6
+#define ENERGY_PERF_BIAS_BALANCE_POWERSAVE     8
+#define ENERGY_PERF_BIAS_POWERSAVE             15
 
 #define MSR_IA32_PACKAGE_THERM_STATUS          0x000001b1
 
index 6136a18152af28bb4cdb72b652a6161c85b20e51..2bd96b4df1409cf75d168027dbf416da37d3fb9b 100644 (file)
@@ -42,8 +42,7 @@ struct saved_context {
        set_debugreg((thread)->debugreg##register, register)
 
 /* routines for saving/restoring kernel state */
-extern int acpi_save_state_mem(void);
-extern char core_restore_code;
-extern char restore_registers;
+extern char core_restore_code[];
+extern char restore_registers[];
 
 #endif /* _ASM_X86_SUSPEND_64_H */
index 8233a630280f52052ffb9a5f7c89f273cedf0425..dde437f5d14ff828dccff19275033ff2330acc60 100644 (file)
@@ -167,7 +167,8 @@ static int __init ffh_cstate_init(void)
 {
        struct cpuinfo_x86 *c = &boot_cpu_data;
 
-       if (c->x86_vendor != X86_VENDOR_INTEL)
+       if (c->x86_vendor != X86_VENDOR_INTEL &&
+           c->x86_vendor != X86_VENDOR_AMD)
                return -1;
 
        cpu_cstate_entry = alloc_percpu(struct cstate_entry);
index 52000010c62ebaaf60939186128d44af757d2226..cdf82492b77003c3b98bbdfe216dc5c1c3408336 100644 (file)
@@ -21,6 +21,7 @@ obj-y                 += common.o
 obj-y                  += rdrand.o
 obj-y                  += match.o
 obj-y                  += bugs.o
+obj-$(CONFIG_CPU_FREQ) += aperfmperf.o
 
 obj-$(CONFIG_PROC_FS)  += proc.o
 obj-$(CONFIG_X86_FEATURE_NAMES) += capflags.o powerflags.o
diff --git a/arch/x86/kernel/cpu/aperfmperf.c b/arch/x86/kernel/cpu/aperfmperf.c
new file mode 100644 (file)
index 0000000..d869c86
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * x86 APERF/MPERF KHz calculation for
+ * /sys/.../cpufreq/scaling_cur_freq
+ *
+ * Copyright (C) 2017 Intel Corp.
+ * Author: Len Brown <len.brown@intel.com>
+ *
+ * This file is licensed under GPLv2.
+ */
+
+#include <linux/jiffies.h>
+#include <linux/math64.h>
+#include <linux/percpu.h>
+#include <linux/smp.h>
+
+struct aperfmperf_sample {
+       unsigned int    khz;
+       unsigned long   jiffies;
+       u64     aperf;
+       u64     mperf;
+};
+
+static DEFINE_PER_CPU(struct aperfmperf_sample, samples);
+
+/*
+ * aperfmperf_snapshot_khz()
+ * On the current CPU, snapshot APERF, MPERF, and jiffies
+ * unless we already did it within 10ms
+ * calculate kHz, save snapshot
+ */
+static void aperfmperf_snapshot_khz(void *dummy)
+{
+       u64 aperf, aperf_delta;
+       u64 mperf, mperf_delta;
+       struct aperfmperf_sample *s = this_cpu_ptr(&samples);
+
+       /* Don't bother re-computing within 10 ms */
+       if (time_before(jiffies, s->jiffies + HZ/100))
+               return;
+
+       rdmsrl(MSR_IA32_APERF, aperf);
+       rdmsrl(MSR_IA32_MPERF, mperf);
+
+       aperf_delta = aperf - s->aperf;
+       mperf_delta = mperf - s->mperf;
+
+       /*
+        * There is no architectural guarantee that MPERF
+        * increments faster than we can read it.
+        */
+       if (mperf_delta == 0)
+               return;
+
+       /*
+        * if (cpu_khz * aperf_delta) fits into ULLONG_MAX, then
+        *      khz = (cpu_khz * aperf_delta) / mperf_delta
+        */
+       if (div64_u64(ULLONG_MAX, cpu_khz) > aperf_delta)
+               s->khz = div64_u64((cpu_khz * aperf_delta), mperf_delta);
+       else    /* khz = aperf_delta / (mperf_delta / cpu_khz) */
+               s->khz = div64_u64(aperf_delta,
+                       div64_u64(mperf_delta, cpu_khz));
+       s->jiffies = jiffies;
+       s->aperf = aperf;
+       s->mperf = mperf;
+}
+
+unsigned int arch_freq_get_on_cpu(int cpu)
+{
+       if (!cpu_khz)
+               return 0;
+
+       if (!static_cpu_has(X86_FEATURE_APERFMPERF))
+               return 0;
+
+       smp_call_function_single(cpu, aperfmperf_snapshot_khz, NULL, 1);
+
+       return per_cpu(samples.khz, cpu);
+}
index 6df621ae62a7c00cb4f95dbf5c41ec83e5397f71..218f79825b3c802d9da17fd937320da3ce4456cc 100644 (file)
@@ -2,7 +2,6 @@
 #include <linux/timex.h>
 #include <linux/string.h>
 #include <linux/seq_file.h>
-#include <linux/cpufreq.h>
 
 /*
  *     Get CPU information for use by the procfs.
@@ -76,14 +75,9 @@ static int show_cpuinfo(struct seq_file *m, void *v)
        if (c->microcode)
                seq_printf(m, "microcode\t: 0x%x\n", c->microcode);
 
-       if (cpu_has(c, X86_FEATURE_TSC)) {
-               unsigned int freq = cpufreq_quick_get(cpu);
-
-               if (!freq)
-                       freq = cpu_khz;
+       if (cpu_has(c, X86_FEATURE_TSC))
                seq_printf(m, "cpu MHz\t\t: %u.%03u\n",
-                          freq / 1000, (freq % 1000));
-       }
+                          cpu_khz / 1000, (cpu_khz % 1000));
 
        /* Cache size */
        if (c->x86_cache_size >= 0)
index a6e21fee22ea2e5fb5ba6e46b09637ec88ec26f6..2ab1c5059a61f97aa8caedebfdfe938109f875ab 100644 (file)
@@ -147,7 +147,7 @@ static int relocate_restore_code(void)
        if (!relocated_restore_code)
                return -ENOMEM;
 
-       memcpy((void *)relocated_restore_code, &core_restore_code, PAGE_SIZE);
+       memcpy((void *)relocated_restore_code, core_restore_code, PAGE_SIZE);
 
        /* Make the page containing the relocated code executable */
        pgd = (pgd_t *)__va(read_cr3()) + pgd_index(relocated_restore_code);
@@ -292,8 +292,8 @@ int arch_hibernation_header_save(void *addr, unsigned int max_size)
 
        if (max_size < sizeof(struct restore_data_record))
                return -EOVERFLOW;
-       rdr->jump_address = (unsigned long)&restore_registers;
-       rdr->jump_address_phys = __pa_symbol(&restore_registers);
+       rdr->jump_address = (unsigned long)restore_registers;
+       rdr->jump_address_phys = __pa_symbol(restore_registers);
        rdr->cr3 = restore_cr3;
        rdr->magic = RESTORE_MAGIC;
 
index edcea70674c9de501b6d26b9082ddd780ecc5bea..2a365c756648ca66f55274a49cf1aaad2d1c96e8 100644 (file)
@@ -115,7 +115,7 @@ static bool ldm_parse_privhead(const u8 *data, struct privhead *ph)
                ldm_error("PRIVHEAD disk size doesn't match real disk size");
                return false;
        }
-       if (uuid_be_to_bin(data + 0x0030, (uuid_be *)ph->disk_id)) {
+       if (uuid_parse(data + 0x0030, &ph->disk_id)) {
                ldm_error("PRIVHEAD contains an invalid GUID.");
                return false;
        }
@@ -234,7 +234,7 @@ static bool ldm_compare_privheads (const struct privhead *ph1,
                (ph1->logical_disk_size  == ph2->logical_disk_size)     &&
                (ph1->config_start       == ph2->config_start)          &&
                (ph1->config_size        == ph2->config_size)           &&
-               !memcmp (ph1->disk_id, ph2->disk_id, GUID_SIZE));
+               uuid_equal(&ph1->disk_id, &ph2->disk_id));
 }
 
 /**
@@ -557,7 +557,7 @@ static struct vblk * ldm_get_disk_objid (const struct ldmdb *ldb)
 
        list_for_each (item, &ldb->v_disk) {
                struct vblk *v = list_entry (item, struct vblk, list);
-               if (!memcmp (v->vblk.disk.disk_id, ldb->ph.disk_id, GUID_SIZE))
+               if (uuid_equal(&v->vblk.disk.disk_id, &ldb->ph.disk_id))
                        return v;
        }
 
@@ -892,7 +892,7 @@ static bool ldm_parse_dsk3 (const u8 *buffer, int buflen, struct vblk *vb)
        disk = &vb->vblk.disk;
        ldm_get_vstr (buffer + 0x18 + r_diskid, disk->alt_name,
                sizeof (disk->alt_name));
-       if (uuid_be_to_bin(buffer + 0x19 + r_name, (uuid_be *)disk->disk_id))
+       if (uuid_parse(buffer + 0x19 + r_name, &disk->disk_id))
                return false;
 
        return true;
@@ -927,7 +927,7 @@ static bool ldm_parse_dsk4 (const u8 *buffer, int buflen, struct vblk *vb)
                return false;
 
        disk = &vb->vblk.disk;
-       memcpy (disk->disk_id, buffer + 0x18 + r_name, GUID_SIZE);
+       uuid_copy(&disk->disk_id, (uuid_t *)(buffer + 0x18 + r_name));
        return true;
 }
 
index 374242c0971a671addd9d111ac64cade9cb22e50..f4c6055df9563892a991ac5f8c7c2fff12ce3e4b 100644 (file)
@@ -112,8 +112,6 @@ struct frag {                               /* VBLK Fragment handling */
 
 /* In memory LDM database structures. */
 
-#define GUID_SIZE              16
-
 struct privhead {                      /* Offsets and sizes are in sectors. */
        u16     ver_major;
        u16     ver_minor;
@@ -121,7 +119,7 @@ struct privhead {                   /* Offsets and sizes are in sectors. */
        u64     logical_disk_size;
        u64     config_start;
        u64     config_size;
-       u8      disk_id[GUID_SIZE];
+       uuid_t  disk_id;
 };
 
 struct tocblock {                      /* We have exactly two bitmaps. */
@@ -154,7 +152,7 @@ struct vblk_dgrp {                  /* VBLK Disk Group */
 };
 
 struct vblk_disk {                     /* VBLK Disk */
-       u8      disk_id[GUID_SIZE];
+       uuid_t  disk_id;
        u8      alt_name[128];
 };
 
index 502ea4dc208060d4daa2d1c296bf1b3545b4278a..560fdae8cc59015d78b13a73b377343e96495257 100644 (file)
@@ -141,9 +141,9 @@ static int extlog_print(struct notifier_block *nb, unsigned long val,
        int     cpu = mce->extcpu;
        struct acpi_hest_generic_status *estatus, *tmp;
        struct acpi_hest_generic_data *gdata;
-       const uuid_le *fru_id = &NULL_UUID_LE;
+       const guid_t *fru_id = &guid_null;
        char *fru_text = "";
-       uuid_le *sec_type;
+       guid_t *sec_type;
        static u32 err_seq;
 
        estatus = extlog_elog_entry_check(cpu, bank);
@@ -165,11 +165,11 @@ static int extlog_print(struct notifier_block *nb, unsigned long val,
        err_seq++;
        gdata = (struct acpi_hest_generic_data *)(tmp + 1);
        if (gdata->validation_bits & CPER_SEC_VALID_FRU_ID)
-               fru_id = (uuid_le *)gdata->fru_id;
+               fru_id = (guid_t *)gdata->fru_id;
        if (gdata->validation_bits & CPER_SEC_VALID_FRU_TEXT)
                fru_text = gdata->fru_text;
-       sec_type = (uuid_le *)gdata->section_type;
-       if (!uuid_le_cmp(*sec_type, CPER_SEC_PLATFORM_MEM)) {
+       sec_type = (guid_t *)gdata->section_type;
+       if (guid_equal(sec_type, &CPER_SEC_PLATFORM_MEM)) {
                struct cper_sec_mem_err *mem = (void *)(gdata + 1);
                if (gdata->error_data_length >= sizeof(*mem))
                        trace_extlog_mem_event(mem, err_seq, fru_id, fru_text,
@@ -182,17 +182,17 @@ out:
 
 static bool __init extlog_get_l1addr(void)
 {
-       u8 uuid[16];
+       guid_t guid;
        acpi_handle handle;
        union acpi_object *obj;
 
-       acpi_str_to_uuid(extlog_dsm_uuid, uuid);
-
+       if (guid_parse(extlog_dsm_uuid, &guid))
+               return false;
        if (ACPI_FAILURE(acpi_get_handle(NULL, "\\_SB", &handle)))
                return false;
-       if (!acpi_check_dsm(handle, uuid, EXTLOG_DSM_REV, 1 << EXTLOG_FN_ADDR))
+       if (!acpi_check_dsm(handle, &guid, EXTLOG_DSM_REV, 1 << EXTLOG_FN_ADDR))
                return false;
-       obj = acpi_evaluate_dsm_typed(handle, uuid, EXTLOG_DSM_REV,
+       obj = acpi_evaluate_dsm_typed(handle, &guid, EXTLOG_DSM_REV,
                                      EXTLOG_FN_ADDR, NULL, ACPI_TYPE_INTEGER);
        if (!obj) {
                return false;
index d0855c09f32f36491026e750e64d0a824129e6dc..980515e029fae538de8889782226f7b284fbd727 100644 (file)
@@ -431,12 +431,13 @@ static void ghes_do_proc(struct ghes *ghes,
 {
        int sev, sec_sev;
        struct acpi_hest_generic_data *gdata;
+       guid_t *sec_type;
 
        sev = ghes_severity(estatus->error_severity);
        apei_estatus_for_each_section(estatus, gdata) {
+               sec_type = (guid_t *)gdata->section_type;
                sec_sev = ghes_severity(gdata->error_severity);
-               if (!uuid_le_cmp(*(uuid_le *)gdata->section_type,
-                                CPER_SEC_PLATFORM_MEM)) {
+               if (guid_equal(sec_type, &CPER_SEC_PLATFORM_MEM)) {
                        struct cper_sec_mem_err *mem_err;
                        mem_err = (struct cper_sec_mem_err *)(gdata+1);
                        ghes_edac_report_mem_error(ghes, sev, mem_err);
@@ -445,8 +446,7 @@ static void ghes_do_proc(struct ghes *ghes,
                        ghes_handle_memory_failure(gdata, sev);
                }
 #ifdef CONFIG_ACPI_APEI_PCIEAER
-               else if (!uuid_le_cmp(*(uuid_le *)gdata->section_type,
-                                     CPER_SEC_PCIE)) {
+               else if (guid_equal(sec_type, &CPER_SEC_PCIE)) {
                        struct cper_sec_pcie *pcie_err;
                        pcie_err = (struct cper_sec_pcie *)(gdata+1);
                        if (sev == GHES_SEV_RECOVERABLE &&
index 784bda663d162d36d1e4bdc47ce8a6b5b595be8a..5a6fbe0fcaf2b82db279c40bd031abac2b4b6125 100644 (file)
@@ -196,42 +196,19 @@ static void acpi_print_osc_error(acpi_handle handle,
        pr_debug("\n");
 }
 
-acpi_status acpi_str_to_uuid(char *str, u8 *uuid)
-{
-       int i;
-       static int opc_map_to_uuid[16] = {6, 4, 2, 0, 11, 9, 16, 14, 19, 21,
-               24, 26, 28, 30, 32, 34};
-
-       if (strlen(str) != 36)
-               return AE_BAD_PARAMETER;
-       for (i = 0; i < 36; i++) {
-               if (i == 8 || i == 13 || i == 18 || i == 23) {
-                       if (str[i] != '-')
-                               return AE_BAD_PARAMETER;
-               } else if (!isxdigit(str[i]))
-                       return AE_BAD_PARAMETER;
-       }
-       for (i = 0; i < 16; i++) {
-               uuid[i] = hex_to_bin(str[opc_map_to_uuid[i]]) << 4;
-               uuid[i] |= hex_to_bin(str[opc_map_to_uuid[i] + 1]);
-       }
-       return AE_OK;
-}
-EXPORT_SYMBOL_GPL(acpi_str_to_uuid);
-
 acpi_status acpi_run_osc(acpi_handle handle, struct acpi_osc_context *context)
 {
        acpi_status status;
        struct acpi_object_list input;
        union acpi_object in_params[4];
        union acpi_object *out_obj;
-       u8 uuid[16];
+       guid_t guid;
        u32 errors;
        struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER, NULL};
 
        if (!context)
                return AE_ERROR;
-       if (ACPI_FAILURE(acpi_str_to_uuid(context->uuid_str, uuid)))
+       if (guid_parse(context->uuid_str, &guid))
                return AE_ERROR;
        context->ret.length = ACPI_ALLOCATE_BUFFER;
        context->ret.pointer = NULL;
@@ -241,7 +218,7 @@ acpi_status acpi_run_osc(acpi_handle handle, struct acpi_osc_context *context)
        input.pointer = in_params;
        in_params[0].type               = ACPI_TYPE_BUFFER;
        in_params[0].buffer.length      = 16;
-       in_params[0].buffer.pointer     = uuid;
+       in_params[0].buffer.pointer     = (u8 *)&guid;
        in_params[1].type               = ACPI_TYPE_INTEGER;
        in_params[1].integer.value      = context->rev;
        in_params[2].type               = ACPI_TYPE_INTEGER;
index 656acb5d71660a6dfffaecc877bb46d76af08fb3..097eff0b963d5b6d1685809a16980efeaf406975 100644 (file)
@@ -74,11 +74,11 @@ struct nfit_table_prev {
        struct list_head flushes;
 };
 
-static u8 nfit_uuid[NFIT_UUID_MAX][16];
+static guid_t nfit_uuid[NFIT_UUID_MAX];
 
-const u8 *to_nfit_uuid(enum nfit_uuids id)
+const guid_t *to_nfit_uuid(enum nfit_uuids id)
 {
-       return nfit_uuid[id];
+       return &nfit_uuid[id];
 }
 EXPORT_SYMBOL(to_nfit_uuid);
 
@@ -222,7 +222,7 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm,
        u32 offset, fw_status = 0;
        acpi_handle handle;
        unsigned int func;
-       const u8 *uuid;
+       const guid_t *guid;
        int rc, i;
 
        func = cmd;
@@ -245,7 +245,7 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm,
                cmd_mask = nvdimm_cmd_mask(nvdimm);
                dsm_mask = nfit_mem->dsm_mask;
                desc = nd_cmd_dimm_desc(cmd);
-               uuid = to_nfit_uuid(nfit_mem->family);
+               guid = to_nfit_uuid(nfit_mem->family);
                handle = adev->handle;
        } else {
                struct acpi_device *adev = to_acpi_dev(acpi_desc);
@@ -254,7 +254,7 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm,
                cmd_mask = nd_desc->cmd_mask;
                dsm_mask = cmd_mask;
                desc = nd_cmd_bus_desc(cmd);
-               uuid = to_nfit_uuid(NFIT_DEV_BUS);
+               guid = to_nfit_uuid(NFIT_DEV_BUS);
                handle = adev->handle;
                dimm_name = "bus";
        }
@@ -289,7 +289,7 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm,
                        in_buf.buffer.pointer,
                        min_t(u32, 256, in_buf.buffer.length), true);
 
-       out_obj = acpi_evaluate_dsm(handle, uuid, 1, func, &in_obj);
+       out_obj = acpi_evaluate_dsm(handle, guid, 1, func, &in_obj);
        if (!out_obj) {
                dev_dbg(dev, "%s:%s _DSM failed cmd: %s\n", __func__, dimm_name,
                                cmd_name);
@@ -409,7 +409,7 @@ int nfit_spa_type(struct acpi_nfit_system_address *spa)
        int i;
 
        for (i = 0; i < NFIT_UUID_MAX; i++)
-               if (memcmp(to_nfit_uuid(i), spa->range_guid, 16) == 0)
+               if (guid_equal(to_nfit_uuid(i), (guid_t *)&spa->range_guid))
                        return i;
        return -1;
 }
@@ -1415,7 +1415,7 @@ static int acpi_nfit_add_dimm(struct acpi_nfit_desc *acpi_desc,
        struct acpi_device *adev, *adev_dimm;
        struct device *dev = acpi_desc->dev;
        unsigned long dsm_mask;
-       const u8 *uuid;
+       const guid_t *guid;
        int i;
        int family = -1;
 
@@ -1444,7 +1444,7 @@ static int acpi_nfit_add_dimm(struct acpi_nfit_desc *acpi_desc,
        /*
         * Until standardization materializes we need to consider 4
         * different command sets.  Note, that checking for function0 (bit0)
-        * tells us if any commands are reachable through this uuid.
+        * tells us if any commands are reachable through this GUID.
         */
        for (i = NVDIMM_FAMILY_INTEL; i <= NVDIMM_FAMILY_MSFT; i++)
                if (acpi_check_dsm(adev_dimm->handle, to_nfit_uuid(i), 1, 1))
@@ -1474,9 +1474,9 @@ static int acpi_nfit_add_dimm(struct acpi_nfit_desc *acpi_desc,
                return 0;
        }
 
-       uuid = to_nfit_uuid(nfit_mem->family);
+       guid = to_nfit_uuid(nfit_mem->family);
        for_each_set_bit(i, &dsm_mask, BITS_PER_LONG)
-               if (acpi_check_dsm(adev_dimm->handle, uuid, 1, 1ULL << i))
+               if (acpi_check_dsm(adev_dimm->handle, guid, 1, 1ULL << i))
                        set_bit(i, &nfit_mem->dsm_mask);
 
        return 0;
@@ -1611,7 +1611,7 @@ static int acpi_nfit_register_dimms(struct acpi_nfit_desc *acpi_desc)
 static void acpi_nfit_init_dsms(struct acpi_nfit_desc *acpi_desc)
 {
        struct nvdimm_bus_descriptor *nd_desc = &acpi_desc->nd_desc;
-       const u8 *uuid = to_nfit_uuid(NFIT_DEV_BUS);
+       const guid_t *guid = to_nfit_uuid(NFIT_DEV_BUS);
        struct acpi_device *adev;
        int i;
 
@@ -1621,7 +1621,7 @@ static void acpi_nfit_init_dsms(struct acpi_nfit_desc *acpi_desc)
                return;
 
        for (i = ND_CMD_ARS_CAP; i <= ND_CMD_CLEAR_ERROR; i++)
-               if (acpi_check_dsm(adev->handle, uuid, 1, 1ULL << i))
+               if (acpi_check_dsm(adev->handle, guid, 1, 1ULL << i))
                        set_bit(i, &nd_desc->cmd_mask);
 }
 
@@ -3051,19 +3051,19 @@ static __init int nfit_init(void)
        BUILD_BUG_ON(sizeof(struct acpi_nfit_control_region) != 80);
        BUILD_BUG_ON(sizeof(struct acpi_nfit_data_region) != 40);
 
-       acpi_str_to_uuid(UUID_VOLATILE_MEMORY, nfit_uuid[NFIT_SPA_VOLATILE]);
-       acpi_str_to_uuid(UUID_PERSISTENT_MEMORY, nfit_uuid[NFIT_SPA_PM]);
-       acpi_str_to_uuid(UUID_CONTROL_REGION, nfit_uuid[NFIT_SPA_DCR]);
-       acpi_str_to_uuid(UUID_DATA_REGION, nfit_uuid[NFIT_SPA_BDW]);
-       acpi_str_to_uuid(UUID_VOLATILE_VIRTUAL_DISK, nfit_uuid[NFIT_SPA_VDISK]);
-       acpi_str_to_uuid(UUID_VOLATILE_VIRTUAL_CD, nfit_uuid[NFIT_SPA_VCD]);
-       acpi_str_to_uuid(UUID_PERSISTENT_VIRTUAL_DISK, nfit_uuid[NFIT_SPA_PDISK]);
-       acpi_str_to_uuid(UUID_PERSISTENT_VIRTUAL_CD, nfit_uuid[NFIT_SPA_PCD]);
-       acpi_str_to_uuid(UUID_NFIT_BUS, nfit_uuid[NFIT_DEV_BUS]);
-       acpi_str_to_uuid(UUID_NFIT_DIMM, nfit_uuid[NFIT_DEV_DIMM]);
-       acpi_str_to_uuid(UUID_NFIT_DIMM_N_HPE1, nfit_uuid[NFIT_DEV_DIMM_N_HPE1]);
-       acpi_str_to_uuid(UUID_NFIT_DIMM_N_HPE2, nfit_uuid[NFIT_DEV_DIMM_N_HPE2]);
-       acpi_str_to_uuid(UUID_NFIT_DIMM_N_MSFT, nfit_uuid[NFIT_DEV_DIMM_N_MSFT]);
+       guid_parse(UUID_VOLATILE_MEMORY, &nfit_uuid[NFIT_SPA_VOLATILE]);
+       guid_parse(UUID_PERSISTENT_MEMORY, &nfit_uuid[NFIT_SPA_PM]);
+       guid_parse(UUID_CONTROL_REGION, &nfit_uuid[NFIT_SPA_DCR]);
+       guid_parse(UUID_DATA_REGION, &nfit_uuid[NFIT_SPA_BDW]);
+       guid_parse(UUID_VOLATILE_VIRTUAL_DISK, &nfit_uuid[NFIT_SPA_VDISK]);
+       guid_parse(UUID_VOLATILE_VIRTUAL_CD, &nfit_uuid[NFIT_SPA_VCD]);
+       guid_parse(UUID_PERSISTENT_VIRTUAL_DISK, &nfit_uuid[NFIT_SPA_PDISK]);
+       guid_parse(UUID_PERSISTENT_VIRTUAL_CD, &nfit_uuid[NFIT_SPA_PCD]);
+       guid_parse(UUID_NFIT_BUS, &nfit_uuid[NFIT_DEV_BUS]);
+       guid_parse(UUID_NFIT_DIMM, &nfit_uuid[NFIT_DEV_DIMM]);
+       guid_parse(UUID_NFIT_DIMM_N_HPE1, &nfit_uuid[NFIT_DEV_DIMM_N_HPE1]);
+       guid_parse(UUID_NFIT_DIMM_N_HPE2, &nfit_uuid[NFIT_DEV_DIMM_N_HPE2]);
+       guid_parse(UUID_NFIT_DIMM_N_MSFT, &nfit_uuid[NFIT_DEV_DIMM_N_MSFT]);
 
        nfit_wq = create_singlethread_workqueue("nfit");
        if (!nfit_wq)
index 58fb7d68e04a3219eb77dafa12f06fe49292ec9f..29bdd959517f806aedab452586654ab7b996a089 100644 (file)
@@ -18,7 +18,6 @@
 #include <linux/libnvdimm.h>
 #include <linux/ndctl.h>
 #include <linux/types.h>
-#include <linux/uuid.h>
 #include <linux/acpi.h>
 #include <acpi/acuuid.h>
 
@@ -237,7 +236,7 @@ static inline struct acpi_nfit_desc *to_acpi_desc(
        return container_of(nd_desc, struct acpi_nfit_desc, nd_desc);
 }
 
-const u8 *to_nfit_uuid(enum nfit_uuids id);
+const guid_t *to_nfit_uuid(enum nfit_uuids id);
 int acpi_nfit_init(struct acpi_nfit_desc *acpi_desc, void *nfit, acpi_size sz);
 void acpi_nfit_shutdown(void *data);
 void __acpi_nfit_notify(struct device *dev, acpi_handle handle, u32 event);
index 27d0dcfcf47d6895a0f05963152172f87da0e7c8..b9d956c916f5e65ca737b5c02c45d266c65e00d1 100644 (file)
@@ -613,19 +613,19 @@ acpi_status acpi_evaluate_lck(acpi_handle handle, int lock)
 /**
  * acpi_evaluate_dsm - evaluate device's _DSM method
  * @handle: ACPI device handle
- * @uuid: UUID of requested functions, should be 16 bytes
+ * @guid: GUID of requested functions, should be 16 bytes
  * @rev: revision number of requested function
  * @func: requested function number
  * @argv4: the function specific parameter
  *
- * Evaluate device's _DSM method with specified UUID, revision id and
+ * Evaluate device's _DSM method with specified GUID, revision id and
  * function number. Caller needs to free the returned object.
  *
  * Though ACPI defines the fourth parameter for _DSM should be a package,
  * some old BIOSes do expect a buffer or an integer etc.
  */
 union acpi_object *
-acpi_evaluate_dsm(acpi_handle handle, const u8 *uuid, u64 rev, u64 func,
+acpi_evaluate_dsm(acpi_handle handle, const guid_t *guid, u64 rev, u64 func,
                  union acpi_object *argv4)
 {
        acpi_status ret;
@@ -638,7 +638,7 @@ acpi_evaluate_dsm(acpi_handle handle, const u8 *uuid, u64 rev, u64 func,
 
        params[0].type = ACPI_TYPE_BUFFER;
        params[0].buffer.length = 16;
-       params[0].buffer.pointer = (char *)uuid;
+       params[0].buffer.pointer = (u8 *)guid;
        params[1].type = ACPI_TYPE_INTEGER;
        params[1].integer.value = rev;
        params[2].type = ACPI_TYPE_INTEGER;
@@ -666,7 +666,7 @@ EXPORT_SYMBOL(acpi_evaluate_dsm);
 /**
  * acpi_check_dsm - check if _DSM method supports requested functions.
  * @handle: ACPI device handle
- * @uuid: UUID of requested functions, should be 16 bytes at least
+ * @guid: GUID of requested functions, should be 16 bytes at least
  * @rev: revision number of requested functions
  * @funcs: bitmap of requested functions
  *
@@ -674,7 +674,7 @@ EXPORT_SYMBOL(acpi_evaluate_dsm);
  * functions. Currently only support 64 functions at maximum, should be
  * enough for now.
  */
-bool acpi_check_dsm(acpi_handle handle, const u8 *uuid, u64 rev, u64 funcs)
+bool acpi_check_dsm(acpi_handle handle, const guid_t *guid, u64 rev, u64 funcs)
 {
        int i;
        u64 mask = 0;
@@ -683,7 +683,7 @@ bool acpi_check_dsm(acpi_handle handle, const u8 *uuid, u64 rev, u64 funcs)
        if (funcs == 0)
                return false;
 
-       obj = acpi_evaluate_dsm(handle, uuid, rev, 0, NULL);
+       obj = acpi_evaluate_dsm(handle, guid, rev, 0, NULL);
        if (!obj)
                return false;
 
@@ -697,7 +697,7 @@ bool acpi_check_dsm(acpi_handle handle, const u8 *uuid, u64 rev, u64 funcs)
 
        /*
         * Bit 0 indicates whether there's support for any functions other than
-        * function 0 for the specified UUID and revision.
+        * function 0 for the specified GUID and revision.
         */
        if ((mask & 0x1) && (mask & funcs) == funcs)
                return true;
index da49a8383dc30b074d28463e3b2771cd2ebd8adb..b8e4b966c74dc393b473da4f0074b802b8add5f8 100644 (file)
@@ -126,7 +126,7 @@ static const struct genpd_lock_ops genpd_spin_ops = {
 #define genpd_is_always_on(genpd)      (genpd->flags & GENPD_FLAG_ALWAYS_ON)
 
 static inline bool irq_safe_dev_in_no_sleep_domain(struct device *dev,
-               struct generic_pm_domain *genpd)
+               const struct generic_pm_domain *genpd)
 {
        bool ret;
 
@@ -181,12 +181,14 @@ static struct generic_pm_domain *dev_to_genpd(struct device *dev)
        return pd_to_genpd(dev->pm_domain);
 }
 
-static int genpd_stop_dev(struct generic_pm_domain *genpd, struct device *dev)
+static int genpd_stop_dev(const struct generic_pm_domain *genpd,
+                         struct device *dev)
 {
        return GENPD_DEV_CALLBACK(genpd, int, stop, dev);
 }
 
-static int genpd_start_dev(struct generic_pm_domain *genpd, struct device *dev)
+static int genpd_start_dev(const struct generic_pm_domain *genpd,
+                          struct device *dev)
 {
        return GENPD_DEV_CALLBACK(genpd, int, start, dev);
 }
@@ -443,7 +445,7 @@ static int genpd_dev_pm_qos_notifier(struct notifier_block *nb,
 
                pdd = dev->power.subsys_data ?
                                dev->power.subsys_data->domain_data : NULL;
-               if (pdd && pdd->dev) {
+               if (pdd) {
                        to_gpd_data(pdd)->td.constraint_changed = true;
                        genpd = dev_to_genpd(dev);
                } else {
@@ -738,7 +740,7 @@ static bool pm_genpd_present(const struct generic_pm_domain *genpd)
 
 #ifdef CONFIG_PM_SLEEP
 
-static bool genpd_dev_active_wakeup(struct generic_pm_domain *genpd,
+static bool genpd_dev_active_wakeup(const struct generic_pm_domain *genpd,
                                    struct device *dev)
 {
        return GENPD_DEV_CALLBACK(genpd, bool, active_wakeup, dev);
@@ -840,7 +842,8 @@ static void genpd_sync_power_on(struct generic_pm_domain *genpd, bool use_lock,
  * signal remote wakeup from the system's working state as needed by runtime PM.
  * Return 'true' in either of the above cases.
  */
-static bool resume_needed(struct device *dev, struct generic_pm_domain *genpd)
+static bool resume_needed(struct device *dev,
+                         const struct generic_pm_domain *genpd)
 {
        bool active_wakeup;
 
@@ -899,19 +902,19 @@ static int pm_genpd_prepare(struct device *dev)
 }
 
 /**
- * pm_genpd_suspend_noirq - Completion of suspend of device in an I/O PM domain.
+ * genpd_finish_suspend - Completion of suspend or hibernation of device in an
+ *   I/O pm domain.
  * @dev: Device to suspend.
+ * @poweroff: Specifies if this is a poweroff_noirq or suspend_noirq callback.
  *
  * Stop the device and remove power from the domain if all devices in it have
  * been stopped.
  */
-static int pm_genpd_suspend_noirq(struct device *dev)
+static int genpd_finish_suspend(struct device *dev, bool poweroff)
 {
        struct generic_pm_domain *genpd;
        int ret;
 
-       dev_dbg(dev, "%s()\n", __func__);
-
        genpd = dev_to_genpd(dev);
        if (IS_ERR(genpd))
                return -EINVAL;
@@ -919,6 +922,13 @@ static int pm_genpd_suspend_noirq(struct device *dev)
        if (dev->power.wakeup_path && genpd_dev_active_wakeup(genpd, dev))
                return 0;
 
+       if (poweroff)
+               ret = pm_generic_poweroff_noirq(dev);
+       else
+               ret = pm_generic_suspend_noirq(dev);
+       if (ret)
+               return ret;
+
        if (genpd->dev_ops.stop && genpd->dev_ops.start) {
                ret = pm_runtime_force_suspend(dev);
                if (ret)
@@ -933,6 +943,20 @@ static int pm_genpd_suspend_noirq(struct device *dev)
        return 0;
 }
 
+/**
+ * pm_genpd_suspend_noirq - Completion of suspend of device in an I/O PM domain.
+ * @dev: Device to suspend.
+ *
+ * Stop the device and remove power from the domain if all devices in it have
+ * been stopped.
+ */
+static int pm_genpd_suspend_noirq(struct device *dev)
+{
+       dev_dbg(dev, "%s()\n", __func__);
+
+       return genpd_finish_suspend(dev, false);
+}
+
 /**
  * pm_genpd_resume_noirq - Start of resume of device in an I/O PM domain.
  * @dev: Device to resume.
@@ -961,6 +985,10 @@ static int pm_genpd_resume_noirq(struct device *dev)
        if (genpd->dev_ops.stop && genpd->dev_ops.start)
                ret = pm_runtime_force_resume(dev);
 
+       ret = pm_generic_resume_noirq(dev);
+       if (ret)
+               return ret;
+
        return ret;
 }
 
@@ -975,7 +1003,7 @@ static int pm_genpd_resume_noirq(struct device *dev)
  */
 static int pm_genpd_freeze_noirq(struct device *dev)
 {
-       struct generic_pm_domain *genpd;
+       const struct generic_pm_domain *genpd;
        int ret = 0;
 
        dev_dbg(dev, "%s()\n", __func__);
@@ -984,6 +1012,10 @@ static int pm_genpd_freeze_noirq(struct device *dev)
        if (IS_ERR(genpd))
                return -EINVAL;
 
+       ret = pm_generic_freeze_noirq(dev);
+       if (ret)
+               return ret;
+
        if (genpd->dev_ops.stop && genpd->dev_ops.start)
                ret = pm_runtime_force_suspend(dev);
 
@@ -999,7 +1031,7 @@ static int pm_genpd_freeze_noirq(struct device *dev)
  */
 static int pm_genpd_thaw_noirq(struct device *dev)
 {
-       struct generic_pm_domain *genpd;
+       const struct generic_pm_domain *genpd;
        int ret = 0;
 
        dev_dbg(dev, "%s()\n", __func__);
@@ -1008,10 +1040,28 @@ static int pm_genpd_thaw_noirq(struct device *dev)
        if (IS_ERR(genpd))
                return -EINVAL;
 
-       if (genpd->dev_ops.stop && genpd->dev_ops.start)
+       if (genpd->dev_ops.stop && genpd->dev_ops.start) {
                ret = pm_runtime_force_resume(dev);
+               if (ret)
+                       return ret;
+       }
 
-       return ret;
+       return pm_generic_thaw_noirq(dev);
+}
+
+/**
+ * pm_genpd_poweroff_noirq - Completion of hibernation of device in an
+ *   I/O PM domain.
+ * @dev: Device to poweroff.
+ *
+ * Stop the device and remove power from the domain if all devices in it have
+ * been stopped.
+ */
+static int pm_genpd_poweroff_noirq(struct device *dev)
+{
+       dev_dbg(dev, "%s()\n", __func__);
+
+       return genpd_finish_suspend(dev, true);
 }
 
 /**
@@ -1048,10 +1098,13 @@ static int pm_genpd_restore_noirq(struct device *dev)
        genpd_sync_power_on(genpd, true, 0);
        genpd_unlock(genpd);
 
-       if (genpd->dev_ops.stop && genpd->dev_ops.start)
+       if (genpd->dev_ops.stop && genpd->dev_ops.start) {
                ret = pm_runtime_force_resume(dev);
+               if (ret)
+                       return ret;
+       }
 
-       return ret;
+       return pm_generic_restore_noirq(dev);
 }
 
 /**
@@ -1095,8 +1148,8 @@ static void genpd_syscore_switch(struct device *dev, bool suspend)
 {
        struct generic_pm_domain *genpd;
 
-       genpd = dev_to_genpd(dev);
-       if (!pm_genpd_present(genpd))
+       genpd = genpd_lookup_dev(dev);
+       if (!genpd)
                return;
 
        if (suspend) {
@@ -1393,7 +1446,7 @@ EXPORT_SYMBOL_GPL(pm_genpd_add_subdomain);
 int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd,
                              struct generic_pm_domain *subdomain)
 {
-       struct gpd_link *link;
+       struct gpd_link *l, *link;
        int ret = -EINVAL;
 
        if (IS_ERR_OR_NULL(genpd) || IS_ERR_OR_NULL(subdomain))
@@ -1409,7 +1462,7 @@ int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd,
                goto out;
        }
 
-       list_for_each_entry(link, &genpd->master_links, master_node) {
+       list_for_each_entry_safe(link, l, &genpd->master_links, master_node) {
                if (link->slave != subdomain)
                        continue;
 
@@ -1493,7 +1546,7 @@ int pm_genpd_init(struct generic_pm_domain *genpd,
        genpd->domain.ops.resume_noirq = pm_genpd_resume_noirq;
        genpd->domain.ops.freeze_noirq = pm_genpd_freeze_noirq;
        genpd->domain.ops.thaw_noirq = pm_genpd_thaw_noirq;
-       genpd->domain.ops.poweroff_noirq = pm_genpd_suspend_noirq;
+       genpd->domain.ops.poweroff_noirq = pm_genpd_poweroff_noirq;
        genpd->domain.ops.restore_noirq = pm_genpd_restore_noirq;
        genpd->domain.ops.complete = pm_genpd_complete;
 
@@ -1780,12 +1833,12 @@ EXPORT_SYMBOL_GPL(of_genpd_add_provider_onecell);
  */
 void of_genpd_del_provider(struct device_node *np)
 {
-       struct of_genpd_provider *cp;
+       struct of_genpd_provider *cp, *tmp;
        struct generic_pm_domain *gpd;
 
        mutex_lock(&gpd_list_lock);
        mutex_lock(&of_genpd_mutex);
-       list_for_each_entry(cp, &of_genpd_providers, link) {
+       list_for_each_entry_safe(cp, tmp, &of_genpd_providers, link) {
                if (cp->node == np) {
                        /*
                         * For each PM domain associated with the
@@ -1925,14 +1978,14 @@ EXPORT_SYMBOL_GPL(of_genpd_add_subdomain);
  */
 struct generic_pm_domain *of_genpd_remove_last(struct device_node *np)
 {
-       struct generic_pm_domain *gpd, *genpd = ERR_PTR(-ENOENT);
+       struct generic_pm_domain *gpd, *tmp, *genpd = ERR_PTR(-ENOENT);
        int ret;
 
        if (IS_ERR_OR_NULL(np))
                return ERR_PTR(-EINVAL);
 
        mutex_lock(&gpd_list_lock);
-       list_for_each_entry(gpd, &gpd_list, gpd_list_node) {
+       list_for_each_entry_safe(gpd, tmp, &gpd_list, gpd_list_node) {
                if (gpd->provider == &np->fwnode) {
                        ret = genpd_remove(gpd);
                        genpd = ret ? ERR_PTR(ret) : gpd;
index 2e0fce711135cd68d5c6ee72e23b62eaa1825b69..281f949c5ffeb22828e0363c6c4c302c7635eb92 100644 (file)
@@ -92,12 +92,6 @@ static bool default_suspend_ok(struct device *dev)
        return td->cached_suspend_ok;
 }
 
-/**
- * default_power_down_ok - Default generic PM domain power off governor routine.
- * @pd: PM domain to check.
- *
- * This routine must be executed under the PM domain's lock.
- */
 static bool __default_power_down_ok(struct dev_pm_domain *pd,
                                     unsigned int state)
 {
@@ -187,6 +181,12 @@ static bool __default_power_down_ok(struct dev_pm_domain *pd,
        return true;
 }
 
+/**
+ * default_power_down_ok - Default generic PM domain power off governor routine.
+ * @pd: PM domain to check.
+ *
+ * This routine must be executed under the PM domain's lock.
+ */
 static bool default_power_down_ok(struct dev_pm_domain *pd)
 {
        struct generic_pm_domain *genpd = pd_to_genpd(pd);
index 9faee1c893e53c8dea6e14d472a73a8b7131bf96..6add28799f6df0e580bb21ff7a25675793bf89ed 100644 (file)
@@ -62,7 +62,7 @@ static pm_message_t pm_transition;
 
 static int async_error;
 
-static char *pm_verb(int event)
+static const char *pm_verb(int event)
 {
        switch (event) {
        case PM_EVENT_SUSPEND:
@@ -208,7 +208,8 @@ static ktime_t initcall_debug_start(struct device *dev)
 }
 
 static void initcall_debug_report(struct device *dev, ktime_t calltime,
-                                 int error, pm_message_t state, char *info)
+                                 int error, pm_message_t state,
+                                 const char *info)
 {
        ktime_t rettime;
        s64 nsecs;
@@ -403,21 +404,22 @@ static pm_callback_t pm_noirq_op(const struct dev_pm_ops *ops, pm_message_t stat
        return NULL;
 }
 
-static void pm_dev_dbg(struct device *dev, pm_message_t state, char *info)
+static void pm_dev_dbg(struct device *dev, pm_message_t state, const char *info)
 {
        dev_dbg(dev, "%s%s%s\n", info, pm_verb(state.event),
                ((state.event & PM_EVENT_SLEEP) && device_may_wakeup(dev)) ?
                ", may wakeup" : "");
 }
 
-static void pm_dev_err(struct device *dev, pm_message_t state, char *info,
+static void pm_dev_err(struct device *dev, pm_message_t state, const char *info,
                        int error)
 {
        printk(KERN_ERR "PM: Device %s failed to %s%s: error %d\n",
                dev_name(dev), pm_verb(state.event), info, error);
 }
 
-static void dpm_show_time(ktime_t starttime, pm_message_t state, char *info)
+static void dpm_show_time(ktime_t starttime, pm_message_t state,
+                         const char *info)
 {
        ktime_t calltime;
        u64 usecs64;
@@ -435,7 +437,7 @@ static void dpm_show_time(ktime_t starttime, pm_message_t state, char *info)
 }
 
 static int dpm_run_callback(pm_callback_t cb, struct device *dev,
-                           pm_message_t state, char *info)
+                           pm_message_t state, const char *info)
 {
        ktime_t calltime;
        int error;
@@ -535,7 +537,7 @@ static void dpm_watchdog_clear(struct dpm_watchdog *wd)
 static int device_resume_noirq(struct device *dev, pm_message_t state, bool async)
 {
        pm_callback_t callback = NULL;
-       char *info = NULL;
+       const char *info = NULL;
        int error = 0;
 
        TRACE_DEVICE(dev);
@@ -665,7 +667,7 @@ void dpm_resume_noirq(pm_message_t state)
 static int device_resume_early(struct device *dev, pm_message_t state, bool async)
 {
        pm_callback_t callback = NULL;
-       char *info = NULL;
+       const char *info = NULL;
        int error = 0;
 
        TRACE_DEVICE(dev);
@@ -793,7 +795,7 @@ EXPORT_SYMBOL_GPL(dpm_resume_start);
 static int device_resume(struct device *dev, pm_message_t state, bool async)
 {
        pm_callback_t callback = NULL;
-       char *info = NULL;
+       const char *info = NULL;
        int error = 0;
        DECLARE_DPM_WATCHDOG_ON_STACK(wd);
 
@@ -955,7 +957,7 @@ void dpm_resume(pm_message_t state)
 static void device_complete(struct device *dev, pm_message_t state)
 {
        void (*callback)(struct device *) = NULL;
-       char *info = NULL;
+       const char *info = NULL;
 
        if (dev->power.syscore)
                return;
@@ -1080,7 +1082,7 @@ static pm_message_t resume_event(pm_message_t sleep_state)
 static int __device_suspend_noirq(struct device *dev, pm_message_t state, bool async)
 {
        pm_callback_t callback = NULL;
-       char *info = NULL;
+       const char *info = NULL;
        int error = 0;
 
        TRACE_DEVICE(dev);
@@ -1225,7 +1227,7 @@ int dpm_suspend_noirq(pm_message_t state)
 static int __device_suspend_late(struct device *dev, pm_message_t state, bool async)
 {
        pm_callback_t callback = NULL;
-       char *info = NULL;
+       const char *info = NULL;
        int error = 0;
 
        TRACE_DEVICE(dev);
@@ -1384,7 +1386,7 @@ EXPORT_SYMBOL_GPL(dpm_suspend_end);
  */
 static int legacy_suspend(struct device *dev, pm_message_t state,
                          int (*cb)(struct device *dev, pm_message_t state),
-                         char *info)
+                         const char *info)
 {
        int error;
        ktime_t calltime;
@@ -1426,7 +1428,7 @@ static void dpm_clear_suppliers_direct_complete(struct device *dev)
 static int __device_suspend(struct device *dev, pm_message_t state, bool async)
 {
        pm_callback_t callback = NULL;
-       char *info = NULL;
+       const char *info = NULL;
        int error = 0;
        DECLARE_DPM_WATCHDOG_ON_STACK(wd);
 
index dae61720b31402be9f666063de5ad7c6361f147a..a8cc14fd8ae49ff92cb2fc3dd593273aefd6e10d 100644 (file)
@@ -180,7 +180,7 @@ unsigned long dev_pm_opp_get_max_volt_latency(struct device *dev)
 {
        struct opp_table *opp_table;
        struct dev_pm_opp *opp;
-       struct regulator *reg, **regulators;
+       struct regulator *reg;
        unsigned long latency_ns = 0;
        int ret, i, count;
        struct {
@@ -198,15 +198,9 @@ unsigned long dev_pm_opp_get_max_volt_latency(struct device *dev)
        if (!count)
                goto put_opp_table;
 
-       regulators = kmalloc_array(count, sizeof(*regulators), GFP_KERNEL);
-       if (!regulators)
-               goto put_opp_table;
-
        uV = kmalloc_array(count, sizeof(*uV), GFP_KERNEL);
        if (!uV)
-               goto free_regulators;
-
-       memcpy(regulators, opp_table->regulators, count * sizeof(*regulators));
+               goto put_opp_table;
 
        mutex_lock(&opp_table->lock);
 
@@ -232,15 +226,13 @@ unsigned long dev_pm_opp_get_max_volt_latency(struct device *dev)
         * isn't freed, while we are executing this routine.
         */
        for (i = 0; i < count; i++) {
-               reg = regulators[i];
+               reg = opp_table->regulators[i];
                ret = regulator_set_voltage_time(reg, uV[i].min, uV[i].max);
                if (ret > 0)
                        latency_ns += ret * 1000;
        }
 
        kfree(uV);
-free_regulators:
-       kfree(regulators);
 put_opp_table:
        dev_pm_opp_put_opp_table(opp_table);
 
@@ -543,17 +535,18 @@ _generic_set_opp_clk_only(struct device *dev, struct clk *clk,
        return ret;
 }
 
-static int _generic_set_opp(struct dev_pm_set_opp_data *data)
+static int _generic_set_opp_regulator(const struct opp_table *opp_table,
+                                     struct device *dev,
+                                     unsigned long old_freq,
+                                     unsigned long freq,
+                                     struct dev_pm_opp_supply *old_supply,
+                                     struct dev_pm_opp_supply *new_supply)
 {
-       struct dev_pm_opp_supply *old_supply = data->old_opp.supplies;
-       struct dev_pm_opp_supply *new_supply = data->new_opp.supplies;
-       unsigned long old_freq = data->old_opp.rate, freq = data->new_opp.rate;
-       struct regulator *reg = data->regulators[0];
-       struct device *dev= data->dev;
+       struct regulator *reg = opp_table->regulators[0];
        int ret;
 
        /* This function only supports single regulator per device */
-       if (WARN_ON(data->regulator_count > 1)) {
+       if (WARN_ON(opp_table->regulator_count > 1)) {
                dev_err(dev, "multiple regulators are not supported\n");
                return -EINVAL;
        }
@@ -566,7 +559,7 @@ static int _generic_set_opp(struct dev_pm_set_opp_data *data)
        }
 
        /* Change frequency */
-       ret = _generic_set_opp_clk_only(dev, data->clk, old_freq, freq);
+       ret = _generic_set_opp_clk_only(dev, opp_table->clk, old_freq, freq);
        if (ret)
                goto restore_voltage;
 
@@ -580,12 +573,12 @@ static int _generic_set_opp(struct dev_pm_set_opp_data *data)
        return 0;
 
 restore_freq:
-       if (_generic_set_opp_clk_only(dev, data->clk, freq, old_freq))
+       if (_generic_set_opp_clk_only(dev, opp_table->clk, freq, old_freq))
                dev_err(dev, "%s: failed to restore old-freq (%lu Hz)\n",
                        __func__, old_freq);
 restore_voltage:
        /* This shouldn't harm even if the voltages weren't updated earlier */
-       if (old_supply->u_volt)
+       if (old_supply)
                _set_opp_voltage(dev, reg, old_supply);
 
        return ret;
@@ -603,10 +596,7 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq)
 {
        struct opp_table *opp_table;
        unsigned long freq, old_freq;
-       int (*set_opp)(struct dev_pm_set_opp_data *data);
        struct dev_pm_opp *old_opp, *opp;
-       struct regulator **regulators;
-       struct dev_pm_set_opp_data *data;
        struct clk *clk;
        int ret, size;
 
@@ -661,38 +651,35 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq)
        dev_dbg(dev, "%s: switching OPP: %lu Hz --> %lu Hz\n", __func__,
                old_freq, freq);
 
-       regulators = opp_table->regulators;
-
        /* Only frequency scaling */
-       if (!regulators) {
+       if (!opp_table->regulators) {
                ret = _generic_set_opp_clk_only(dev, clk, old_freq, freq);
-               goto put_opps;
-       }
+       } else if (!opp_table->set_opp) {
+               ret = _generic_set_opp_regulator(opp_table, dev, old_freq, freq,
+                                                IS_ERR(old_opp) ? NULL : old_opp->supplies,
+                                                opp->supplies);
+       } else {
+               struct dev_pm_set_opp_data *data;
 
-       if (opp_table->set_opp)
-               set_opp = opp_table->set_opp;
-       else
-               set_opp = _generic_set_opp;
-
-       data = opp_table->set_opp_data;
-       data->regulators = regulators;
-       data->regulator_count = opp_table->regulator_count;
-       data->clk = clk;
-       data->dev = dev;
-
-       data->old_opp.rate = old_freq;
-       size = sizeof(*opp->supplies) * opp_table->regulator_count;
-       if (IS_ERR(old_opp))
-               memset(data->old_opp.supplies, 0, size);
-       else
-               memcpy(data->old_opp.supplies, old_opp->supplies, size);
+               data = opp_table->set_opp_data;
+               data->regulators = opp_table->regulators;
+               data->regulator_count = opp_table->regulator_count;
+               data->clk = clk;
+               data->dev = dev;
 
-       data->new_opp.rate = freq;
-       memcpy(data->new_opp.supplies, opp->supplies, size);
+               data->old_opp.rate = old_freq;
+               size = sizeof(*opp->supplies) * opp_table->regulator_count;
+               if (IS_ERR(old_opp))
+                       memset(data->old_opp.supplies, 0, size);
+               else
+                       memcpy(data->old_opp.supplies, old_opp->supplies, size);
 
-       ret = set_opp(data);
+               data->new_opp.rate = freq;
+               memcpy(data->new_opp.supplies, opp->supplies, size);
+
+               ret = opp_table->set_opp(data);
+       }
 
-put_opps:
        dev_pm_opp_put(opp);
 put_old_opp:
        if (!IS_ERR(old_opp))
@@ -1375,6 +1362,73 @@ void dev_pm_opp_put_regulators(struct opp_table *opp_table)
 }
 EXPORT_SYMBOL_GPL(dev_pm_opp_put_regulators);
 
+/**
+ * dev_pm_opp_set_clkname() - Set clk name for the device
+ * @dev: Device for which clk name is being set.
+ * @name: Clk name.
+ *
+ * In order to support OPP switching, OPP layer needs to get pointer to the
+ * clock for the device. Simple cases work fine without using this routine (i.e.
+ * by passing connection-id as NULL), but for a device with multiple clocks
+ * available, the OPP core needs to know the exact name of the clk to use.
+ *
+ * This must be called before any OPPs are initialized for the device.
+ */
+struct opp_table *dev_pm_opp_set_clkname(struct device *dev, const char *name)
+{
+       struct opp_table *opp_table;
+       int ret;
+
+       opp_table = dev_pm_opp_get_opp_table(dev);
+       if (!opp_table)
+               return ERR_PTR(-ENOMEM);
+
+       /* This should be called before OPPs are initialized */
+       if (WARN_ON(!list_empty(&opp_table->opp_list))) {
+               ret = -EBUSY;
+               goto err;
+       }
+
+       /* Already have default clk set, free it */
+       if (!IS_ERR(opp_table->clk))
+               clk_put(opp_table->clk);
+
+       /* Find clk for the device */
+       opp_table->clk = clk_get(dev, name);
+       if (IS_ERR(opp_table->clk)) {
+               ret = PTR_ERR(opp_table->clk);
+               if (ret != -EPROBE_DEFER) {
+                       dev_err(dev, "%s: Couldn't find clock: %d\n", __func__,
+                               ret);
+               }
+               goto err;
+       }
+
+       return opp_table;
+
+err:
+       dev_pm_opp_put_opp_table(opp_table);
+
+       return ERR_PTR(ret);
+}
+EXPORT_SYMBOL_GPL(dev_pm_opp_set_clkname);
+
+/**
+ * dev_pm_opp_put_clkname() - Releases resources blocked for clk.
+ * @opp_table: OPP table returned from dev_pm_opp_set_clkname().
+ */
+void dev_pm_opp_put_clkname(struct opp_table *opp_table)
+{
+       /* Make sure there are no concurrent readers while updating opp_table */
+       WARN_ON(!list_empty(&opp_table->opp_list));
+
+       clk_put(opp_table->clk);
+       opp_table->clk = ERR_PTR(-EINVAL);
+
+       dev_pm_opp_put_opp_table(opp_table);
+}
+EXPORT_SYMBOL_GPL(dev_pm_opp_put_clkname);
+
 /**
  * dev_pm_opp_register_set_opp_helper() - Register custom set OPP helper
  * @dev: Device for which the helper is getting registered.
index 95f433db4ac709bdf003b5a52e28008c77a75425..81cf120fcf4338c838218a4f7e2eea3e0af8170b 100644 (file)
@@ -40,11 +40,10 @@ static bool opp_debug_create_supplies(struct dev_pm_opp *opp,
                                      struct dentry *pdentry)
 {
        struct dentry *d;
-       int i = 0;
+       int i;
        char *name;
 
-       /* Always create at least supply-0 directory */
-       do {
+       for (i = 0; i < opp_table->regulator_count; i++) {
                name = kasprintf(GFP_KERNEL, "supply-%d", i);
 
                /* Create per-opp directory */
@@ -70,7 +69,7 @@ static bool opp_debug_create_supplies(struct dev_pm_opp *opp,
                if (!debugfs_create_ulong("u_amp", S_IRUGO, d,
                                          &opp->supplies[i].u_amp))
                        return false;
-       } while (++i < opp_table->regulator_count);
+       }
 
        return true;
 }
index 779428676f63c07e8f0e05982e6354d623b4a821..57eec1ca056977bef29dd73c6a2de95e6a4c8e6a 100644 (file)
@@ -131,8 +131,14 @@ static int opp_parse_supplies(struct dev_pm_opp *opp, struct device *dev,
                prop = of_find_property(opp->np, name, NULL);
 
                /* Missing property isn't a problem, but an invalid entry is */
-               if (!prop)
-                       return 0;
+               if (!prop) {
+                       if (!opp_table->regulator_count)
+                               return 0;
+
+                       dev_err(dev, "%s: opp-microvolt missing although OPP managing regulators\n",
+                               __func__);
+                       return -EINVAL;
+               }
        }
 
        vcount = of_property_count_u32_elems(opp->np, name);
index 33b4b902741aa3933a72afb7cb49252d65289911..185a52581cfae3294f92bcb94a7de5277bbec751 100644 (file)
@@ -607,7 +607,7 @@ static struct attribute *power_attrs[] = {
 #endif /* CONFIG_PM_ADVANCED_DEBUG */
        NULL,
 };
-static struct attribute_group pm_attr_group = {
+static const struct attribute_group pm_attr_group = {
        .name   = power_group_name,
        .attrs  = power_attrs,
 };
@@ -629,7 +629,7 @@ static struct attribute *wakeup_attrs[] = {
 #endif
        NULL,
 };
-static struct attribute_group pm_wakeup_attr_group = {
+static const struct attribute_group pm_wakeup_attr_group = {
        .name   = power_group_name,
        .attrs  = wakeup_attrs,
 };
@@ -644,7 +644,7 @@ static struct attribute *runtime_attrs[] = {
        &dev_attr_autosuspend_delay_ms.attr,
        NULL,
 };
-static struct attribute_group pm_runtime_attr_group = {
+static const struct attribute_group pm_runtime_attr_group = {
        .name   = power_group_name,
        .attrs  = runtime_attrs,
 };
@@ -653,7 +653,7 @@ static struct attribute *pm_qos_resume_latency_attrs[] = {
        &dev_attr_pm_qos_resume_latency_us.attr,
        NULL,
 };
-static struct attribute_group pm_qos_resume_latency_attr_group = {
+static const struct attribute_group pm_qos_resume_latency_attr_group = {
        .name   = power_group_name,
        .attrs  = pm_qos_resume_latency_attrs,
 };
@@ -662,7 +662,7 @@ static struct attribute *pm_qos_latency_tolerance_attrs[] = {
        &dev_attr_pm_qos_latency_tolerance_us.attr,
        NULL,
 };
-static struct attribute_group pm_qos_latency_tolerance_attr_group = {
+static const struct attribute_group pm_qos_latency_tolerance_attr_group = {
        .name   = power_group_name,
        .attrs  = pm_qos_latency_tolerance_attrs,
 };
@@ -672,7 +672,7 @@ static struct attribute *pm_qos_flags_attrs[] = {
        &dev_attr_pm_qos_remote_wakeup.attr,
        NULL,
 };
-static struct attribute_group pm_qos_flags_attr_group = {
+static const struct attribute_group pm_qos_flags_attr_group = {
        .name   = power_group_name,
        .attrs  = pm_qos_flags_attrs,
 };
index c313b600d356260fd9b98fe4848340f9cbdcf9ae..994bbf8b1476ffcb5d686275c1ee19f1f69980c4 100644 (file)
@@ -60,6 +60,8 @@ static LIST_HEAD(wakeup_sources);
 
 static DECLARE_WAIT_QUEUE_HEAD(wakeup_count_wait_queue);
 
+DEFINE_STATIC_SRCU(wakeup_srcu);
+
 static struct wakeup_source deleted_ws = {
        .name = "deleted",
        .lock =  __SPIN_LOCK_UNLOCKED(deleted_ws.lock),
@@ -198,7 +200,7 @@ void wakeup_source_remove(struct wakeup_source *ws)
        spin_lock_irqsave(&events_lock, flags);
        list_del_rcu(&ws->entry);
        spin_unlock_irqrestore(&events_lock, flags);
-       synchronize_rcu();
+       synchronize_srcu(&wakeup_srcu);
 }
 EXPORT_SYMBOL_GPL(wakeup_source_remove);
 
@@ -332,12 +334,12 @@ void device_wakeup_detach_irq(struct device *dev)
 void device_wakeup_arm_wake_irqs(void)
 {
        struct wakeup_source *ws;
+       int srcuidx;
 
-       rcu_read_lock();
+       srcuidx = srcu_read_lock(&wakeup_srcu);
        list_for_each_entry_rcu(ws, &wakeup_sources, entry)
                dev_pm_arm_wake_irq(ws->wakeirq);
-
-       rcu_read_unlock();
+       srcu_read_unlock(&wakeup_srcu, srcuidx);
 }
 
 /**
@@ -348,12 +350,12 @@ void device_wakeup_arm_wake_irqs(void)
 void device_wakeup_disarm_wake_irqs(void)
 {
        struct wakeup_source *ws;
+       int srcuidx;
 
-       rcu_read_lock();
+       srcuidx = srcu_read_lock(&wakeup_srcu);
        list_for_each_entry_rcu(ws, &wakeup_sources, entry)
                dev_pm_disarm_wake_irq(ws->wakeirq);
-
-       rcu_read_unlock();
+       srcu_read_unlock(&wakeup_srcu, srcuidx);
 }
 
 /**
@@ -804,10 +806,10 @@ EXPORT_SYMBOL_GPL(pm_wakeup_dev_event);
 void pm_print_active_wakeup_sources(void)
 {
        struct wakeup_source *ws;
-       int active = 0;
+       int srcuidx, active = 0;
        struct wakeup_source *last_activity_ws = NULL;
 
-       rcu_read_lock();
+       srcuidx = srcu_read_lock(&wakeup_srcu);
        list_for_each_entry_rcu(ws, &wakeup_sources, entry) {
                if (ws->active) {
                        pr_debug("active wakeup source: %s\n", ws->name);
@@ -823,7 +825,7 @@ void pm_print_active_wakeup_sources(void)
        if (!active && last_activity_ws)
                pr_debug("last active wakeup source: %s\n",
                        last_activity_ws->name);
-       rcu_read_unlock();
+       srcu_read_unlock(&wakeup_srcu, srcuidx);
 }
 EXPORT_SYMBOL_GPL(pm_print_active_wakeup_sources);
 
@@ -950,8 +952,9 @@ void pm_wakep_autosleep_enabled(bool set)
 {
        struct wakeup_source *ws;
        ktime_t now = ktime_get();
+       int srcuidx;
 
-       rcu_read_lock();
+       srcuidx = srcu_read_lock(&wakeup_srcu);
        list_for_each_entry_rcu(ws, &wakeup_sources, entry) {
                spin_lock_irq(&ws->lock);
                if (ws->autosleep_enabled != set) {
@@ -965,7 +968,7 @@ void pm_wakep_autosleep_enabled(bool set)
                }
                spin_unlock_irq(&ws->lock);
        }
-       rcu_read_unlock();
+       srcu_read_unlock(&wakeup_srcu, srcuidx);
 }
 #endif /* CONFIG_PM_AUTOSLEEP */
 
@@ -1026,15 +1029,16 @@ static int print_wakeup_source_stats(struct seq_file *m,
 static int wakeup_sources_stats_show(struct seq_file *m, void *unused)
 {
        struct wakeup_source *ws;
+       int srcuidx;
 
        seq_puts(m, "name\t\tactive_count\tevent_count\twakeup_count\t"
                "expire_count\tactive_since\ttotal_time\tmax_time\t"
                "last_change\tprevent_suspend_time\n");
 
-       rcu_read_lock();
+       srcuidx = srcu_read_lock(&wakeup_srcu);
        list_for_each_entry_rcu(ws, &wakeup_sources, entry)
                print_wakeup_source_stats(m, ws);
-       rcu_read_unlock();
+       srcu_read_unlock(&wakeup_srcu, srcuidx);
 
        print_wakeup_source_stats(m, &deleted_ws);
 
index b917b9d5f71021fcc433e6ca4e1552974750f237..c378c7b15d497a1c153b45892e572410c1898b42 100644 (file)
 
 #define ACPI_SIG_TPM2 "TPM2"
 
-static const u8 CRB_ACPI_START_UUID[] = {
-       /* 0000 */ 0xAB, 0x6C, 0xBF, 0x6B, 0x63, 0x54, 0x14, 0x47,
-       /* 0008 */ 0xB7, 0xCD, 0xF0, 0x20, 0x3C, 0x03, 0x68, 0xD4
-};
+static const guid_t crb_acpi_start_guid =
+       GUID_INIT(0x6BBF6CAB, 0x5463, 0x4714,
+                 0xB7, 0xCD, 0xF0, 0x20, 0x3C, 0x03, 0x68, 0xD4);
 
 enum crb_defaults {
        CRB_ACPI_START_REVISION_ID = 1,
@@ -266,7 +265,7 @@ static int crb_do_acpi_start(struct tpm_chip *chip)
        int rc;
 
        obj = acpi_evaluate_dsm(chip->acpi_dev_handle,
-                               CRB_ACPI_START_UUID,
+                               &crb_acpi_start_guid,
                                CRB_ACPI_START_REVISION_ID,
                                CRB_ACPI_START_INDEX,
                                NULL);
index 692a2c6ae036635da19ce4427aa86aacf6bef8d5..86dd8521feef5e2d2ee0ef6392ea3a0d13875d39 100644 (file)
 #define PPI_VS_REQ_START       128
 #define PPI_VS_REQ_END         255
 
-static const u8 tpm_ppi_uuid[] = {
-       0xA6, 0xFA, 0xDD, 0x3D,
-       0x1B, 0x36,
-       0xB4, 0x4E,
-       0xA4, 0x24,
-       0x8D, 0x10, 0x08, 0x9D, 0x16, 0x53
-};
+static const guid_t tpm_ppi_guid =
+       GUID_INIT(0x3DDDFAA6, 0x361B, 0x4EB4,
+                 0xA4, 0x24, 0x8D, 0x10, 0x08, 0x9D, 0x16, 0x53);
 
 static inline union acpi_object *
 tpm_eval_dsm(acpi_handle ppi_handle, int func, acpi_object_type type,
             union acpi_object *argv4)
 {
        BUG_ON(!ppi_handle);
-       return acpi_evaluate_dsm_typed(ppi_handle, tpm_ppi_uuid,
+       return acpi_evaluate_dsm_typed(ppi_handle, &tpm_ppi_guid,
                                       TPM_PPI_REVISION_ID,
                                       func, argv4, type);
 }
@@ -107,7 +103,7 @@ static ssize_t tpm_store_ppi_request(struct device *dev,
         * is updated with function index from SUBREQ to SUBREQ2 since PPI
         * version 1.1
         */
-       if (acpi_check_dsm(chip->acpi_dev_handle, tpm_ppi_uuid,
+       if (acpi_check_dsm(chip->acpi_dev_handle, &tpm_ppi_guid,
                           TPM_PPI_REVISION_ID, 1 << TPM_PPI_FN_SUBREQ2))
                func = TPM_PPI_FN_SUBREQ2;
 
@@ -268,7 +264,7 @@ static ssize_t show_ppi_operations(acpi_handle dev_handle, char *buf, u32 start,
                "User not required",
        };
 
-       if (!acpi_check_dsm(dev_handle, tpm_ppi_uuid, TPM_PPI_REVISION_ID,
+       if (!acpi_check_dsm(dev_handle, &tpm_ppi_guid, TPM_PPI_REVISION_ID,
                            1 << TPM_PPI_FN_GETOPR))
                return -EPERM;
 
@@ -341,12 +337,12 @@ void tpm_add_ppi(struct tpm_chip *chip)
        if (!chip->acpi_dev_handle)
                return;
 
-       if (!acpi_check_dsm(chip->acpi_dev_handle, tpm_ppi_uuid,
+       if (!acpi_check_dsm(chip->acpi_dev_handle, &tpm_ppi_guid,
                            TPM_PPI_REVISION_ID, 1 << TPM_PPI_FN_VERSION))
                return;
 
        /* Cache PPI version string. */
-       obj = acpi_evaluate_dsm_typed(chip->acpi_dev_handle, tpm_ppi_uuid,
+       obj = acpi_evaluate_dsm_typed(chip->acpi_dev_handle, &tpm_ppi_guid,
                                      TPM_PPI_REVISION_ID, TPM_PPI_FN_VERSION,
                                      NULL, ACPI_TYPE_STRING);
        if (obj) {
index e82bb3c30b923c085c981bf517d689b414646c09..10be285c9055791d7e54927da62666c394dc6dc0 100644 (file)
@@ -144,10 +144,23 @@ static int cppc_cpufreq_cpu_init(struct cpufreq_policy *policy)
 
        cppc_dmi_max_khz = cppc_get_dmi_max_khz();
 
-       policy->min = cpu->perf_caps.lowest_perf * cppc_dmi_max_khz / cpu->perf_caps.highest_perf;
+       /*
+        * Set min to lowest nonlinear perf to avoid any efficiency penalty (see
+        * Section 8.4.7.1.1.5 of ACPI 6.1 spec)
+        */
+       policy->min = cpu->perf_caps.lowest_nonlinear_perf * cppc_dmi_max_khz /
+               cpu->perf_caps.highest_perf;
        policy->max = cppc_dmi_max_khz;
-       policy->cpuinfo.min_freq = policy->min;
-       policy->cpuinfo.max_freq = policy->max;
+
+       /*
+        * Set cpuinfo.min_freq to Lowest to make the full range of performance
+        * available if userspace wants to use any perf between lowest & lowest
+        * nonlinear perf
+        */
+       policy->cpuinfo.min_freq = cpu->perf_caps.lowest_perf * cppc_dmi_max_khz /
+               cpu->perf_caps.highest_perf;
+       policy->cpuinfo.max_freq = cppc_dmi_max_khz;
+
        policy->cpuinfo.transition_latency = cppc_get_transition_latency(cpu_num);
        policy->shared_type = cpu->shared_type;
 
index 921b4a6c3d16bece3177b1e407883c8df9bcfa4a..1c262923fe588256e4ee1c48212f2742340ebf4a 100644 (file)
@@ -31,6 +31,7 @@ static const struct of_device_id machines[] __initconst = {
        { .compatible = "arm,integrator-ap", },
        { .compatible = "arm,integrator-cp", },
 
+       { .compatible = "hisilicon,hi3660", },
        { .compatible = "hisilicon,hi6220", },
 
        { .compatible = "fsl,imx27", },
index 26b643d57847de0fca4afc099f4bec49d6326be9..6e7424d12de95e2fb66584350cebe1999eea5b84 100644 (file)
@@ -632,11 +632,21 @@ show_one(cpuinfo_transition_latency, cpuinfo.transition_latency);
 show_one(scaling_min_freq, min);
 show_one(scaling_max_freq, max);
 
+__weak unsigned int arch_freq_get_on_cpu(int cpu)
+{
+       return 0;
+}
+
 static ssize_t show_scaling_cur_freq(struct cpufreq_policy *policy, char *buf)
 {
        ssize_t ret;
+       unsigned int freq;
 
-       if (cpufreq_driver && cpufreq_driver->setpolicy && cpufreq_driver->get)
+       freq = arch_freq_get_on_cpu(policy->cpu);
+       if (freq)
+               ret = sprintf(buf, "%u\n", freq);
+       else if (cpufreq_driver && cpufreq_driver->setpolicy &&
+                       cpufreq_driver->get)
                ret = sprintf(buf, "%u\n", cpufreq_driver->get(policy->cpu));
        else
                ret = sprintf(buf, "%u\n", policy->cur);
index 9180d34cc9fce09be6255559e8d85b03be5c35a6..b6b369c2227265640b606fbf4c9d8a4c43dda1db 100644 (file)
@@ -173,12 +173,12 @@ static void exynos_enable_dvfs(unsigned int cur_frequency)
        /* Enable PSTATE Change Event */
        tmp = __raw_readl(dvfs_info->base + XMU_PMUEVTEN);
        tmp |= (1 << PSTATE_CHANGED_EVTEN_SHIFT);
-        __raw_writel(tmp, dvfs_info->base + XMU_PMUEVTEN);
+       __raw_writel(tmp, dvfs_info->base + XMU_PMUEVTEN);
 
        /* Enable PSTATE Change IRQ */
        tmp = __raw_readl(dvfs_info->base + XMU_PMUIRQEN);
        tmp |= (1 << PSTATE_CHANGED_IRQEN_SHIFT);
-        __raw_writel(tmp, dvfs_info->base + XMU_PMUIRQEN);
+       __raw_writel(tmp, dvfs_info->base + XMU_PMUIRQEN);
 
        /* Set initial performance index */
        cpufreq_for_each_entry(pos, freq_table)
@@ -330,7 +330,7 @@ static int exynos_cpufreq_probe(struct platform_device *pdev)
        struct resource res;
        unsigned int cur_frequency;
 
-       np =  pdev->dev.of_node;
+       np = pdev->dev.of_node;
        if (!np)
                return -ENODEV;
 
index 9c13f097fd8c9a96adba12cccc8e7eda523a57e3..b6edd3ccaa55b3e59c272b580796193f266f9ed4 100644 (file)
@@ -101,7 +101,8 @@ static int imx6q_set_target(struct cpufreq_policy *policy, unsigned int index)
         *  - Reprogram pll1_sys_clk and reparent pll1_sw_clk back to it
         *  - Disable pll2_pfd2_396m_clk
         */
-       if (of_machine_is_compatible("fsl,imx6ul")) {
+       if (of_machine_is_compatible("fsl,imx6ul") ||
+           of_machine_is_compatible("fsl,imx6ull")) {
                /*
                 * When changing pll1_sw_clk's parent to pll1_sys_clk,
                 * CPU may run at higher than 528MHz, this will lead to
@@ -215,7 +216,8 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev)
                goto put_clk;
        }
 
-       if (of_machine_is_compatible("fsl,imx6ul")) {
+       if (of_machine_is_compatible("fsl,imx6ul") ||
+           of_machine_is_compatible("fsl,imx6ull")) {
                pll2_bus_clk = clk_get(cpu_dev, "pll2_bus");
                secondary_sel_clk = clk_get(cpu_dev, "secondary_sel");
                if (IS_ERR(pll2_bus_clk) || IS_ERR(secondary_sel_clk)) {
index eb1158532de31e7aee418162135a7495b10f9860..48a98f11a84ee79b9ccabcff6c6865a0c51a6e26 100644 (file)
@@ -231,10 +231,8 @@ struct global_params {
  * @prev_cummulative_iowait: IO Wait time difference from last and
  *                     current sample
  * @sample:            Storage for storing last Sample data
- * @min_perf:          Minimum capacity limit as a fraction of the maximum
- *                     turbo P-state capacity.
- * @max_perf:          Maximum capacity limit as a fraction of the maximum
- *                     turbo P-state capacity.
+ * @min_perf_ratio:    Minimum capacity in terms of PERF or HWP ratios
+ * @max_perf_ratio:    Maximum capacity in terms of PERF or HWP ratios
  * @acpi_perf_data:    Stores ACPI perf information read from _PSS
  * @valid_pss_table:   Set to true for valid ACPI _PSS entries found
  * @epp_powersave:     Last saved HWP energy performance preference
@@ -266,8 +264,8 @@ struct cpudata {
        u64     prev_tsc;
        u64     prev_cummulative_iowait;
        struct sample sample;
-       int32_t min_perf;
-       int32_t max_perf;
+       int32_t min_perf_ratio;
+       int32_t max_perf_ratio;
 #ifdef CONFIG_ACPI
        struct acpi_processor_performance acpi_perf_data;
        bool valid_pss_table;
@@ -653,6 +651,12 @@ static const char * const energy_perf_strings[] = {
        "power",
        NULL
 };
+static const unsigned int epp_values[] = {
+       HWP_EPP_PERFORMANCE,
+       HWP_EPP_BALANCE_PERFORMANCE,
+       HWP_EPP_BALANCE_POWERSAVE,
+       HWP_EPP_POWERSAVE
+};
 
 static int intel_pstate_get_energy_pref_index(struct cpudata *cpu_data)
 {
@@ -664,17 +668,14 @@ static int intel_pstate_get_energy_pref_index(struct cpudata *cpu_data)
                return epp;
 
        if (static_cpu_has(X86_FEATURE_HWP_EPP)) {
-               /*
-                * Range:
-                *      0x00-0x3F       :       Performance
-                *      0x40-0x7F       :       Balance performance
-                *      0x80-0xBF       :       Balance power
-                *      0xC0-0xFF       :       Power
-                * The EPP is a 8 bit value, but our ranges restrict the
-                * value which can be set. Here only using top two bits
-                * effectively.
-                */
-               index = (epp >> 6) + 1;
+               if (epp == HWP_EPP_PERFORMANCE)
+                       return 1;
+               if (epp <= HWP_EPP_BALANCE_PERFORMANCE)
+                       return 2;
+               if (epp <= HWP_EPP_BALANCE_POWERSAVE)
+                       return 3;
+               else
+                       return 4;
        } else if (static_cpu_has(X86_FEATURE_EPB)) {
                /*
                 * Range:
@@ -712,15 +713,8 @@ static int intel_pstate_set_energy_pref_index(struct cpudata *cpu_data,
 
                value &= ~GENMASK_ULL(31, 24);
 
-               /*
-                * If epp is not default, convert from index into
-                * energy_perf_strings to epp value, by shifting 6
-                * bits left to use only top two bits in epp.
-                * The resultant epp need to shifted by 24 bits to
-                * epp position in MSR_HWP_REQUEST.
-                */
                if (epp == -EINVAL)
-                       epp = (pref_index - 1) << 6;
+                       epp = epp_values[pref_index - 1];
 
                value |= (u64)epp << 24;
                ret = wrmsrl_on_cpu(cpu_data->cpu, MSR_HWP_REQUEST, value);
@@ -794,25 +788,32 @@ static struct freq_attr *hwp_cpufreq_attrs[] = {
        NULL,
 };
 
-static void intel_pstate_hwp_set(unsigned int cpu)
+static void intel_pstate_get_hwp_max(unsigned int cpu, int *phy_max,
+                                    int *current_max)
 {
-       struct cpudata *cpu_data = all_cpu_data[cpu];
-       int min, hw_min, max, hw_max;
-       u64 value, cap;
-       s16 epp;
+       u64 cap;
 
        rdmsrl_on_cpu(cpu, MSR_HWP_CAPABILITIES, &cap);
-       hw_min = HWP_LOWEST_PERF(cap);
        if (global.no_turbo)
-               hw_max = HWP_GUARANTEED_PERF(cap);
+               *current_max = HWP_GUARANTEED_PERF(cap);
        else
-               hw_max = HWP_HIGHEST_PERF(cap);
+               *current_max = HWP_HIGHEST_PERF(cap);
+
+       *phy_max = HWP_HIGHEST_PERF(cap);
+}
+
+static void intel_pstate_hwp_set(unsigned int cpu)
+{
+       struct cpudata *cpu_data = all_cpu_data[cpu];
+       int max, min;
+       u64 value;
+       s16 epp;
+
+       max = cpu_data->max_perf_ratio;
+       min = cpu_data->min_perf_ratio;
 
-       max = fp_ext_toint(hw_max * cpu_data->max_perf);
        if (cpu_data->policy == CPUFREQ_POLICY_PERFORMANCE)
                min = max;
-       else
-               min = fp_ext_toint(hw_max * cpu_data->min_perf);
 
        rdmsrl_on_cpu(cpu, MSR_HWP_REQUEST, &value);
 
@@ -1528,8 +1529,7 @@ static void intel_pstate_max_within_limits(struct cpudata *cpu)
 
        update_turbo_state();
        pstate = intel_pstate_get_base_pstate(cpu);
-       pstate = max(cpu->pstate.min_pstate,
-                    fp_ext_toint(pstate * cpu->max_perf));
+       pstate = max(cpu->pstate.min_pstate, cpu->max_perf_ratio);
        intel_pstate_set_pstate(cpu, pstate);
 }
 
@@ -1616,9 +1616,6 @@ static inline int32_t get_target_pstate_use_cpu_load(struct cpudata *cpu)
        int32_t busy_frac, boost;
        int target, avg_pstate;
 
-       if (cpu->policy == CPUFREQ_POLICY_PERFORMANCE)
-               return cpu->pstate.turbo_pstate;
-
        busy_frac = div_fp(sample->mperf, sample->tsc);
 
        boost = cpu->iowait_boost;
@@ -1655,9 +1652,6 @@ static inline int32_t get_target_pstate_use_performance(struct cpudata *cpu)
        int32_t perf_scaled, max_pstate, current_pstate, sample_ratio;
        u64 duration_ns;
 
-       if (cpu->policy == CPUFREQ_POLICY_PERFORMANCE)
-               return cpu->pstate.turbo_pstate;
-
        /*
         * perf_scaled is the ratio of the average P-state during the last
         * sampling period to the P-state requested last time (in percent).
@@ -1695,9 +1689,8 @@ static int intel_pstate_prepare_request(struct cpudata *cpu, int pstate)
        int max_pstate = intel_pstate_get_base_pstate(cpu);
        int min_pstate;
 
-       min_pstate = max(cpu->pstate.min_pstate,
-                        fp_ext_toint(max_pstate * cpu->min_perf));
-       max_pstate = max(min_pstate, fp_ext_toint(max_pstate * cpu->max_perf));
+       min_pstate = max(cpu->pstate.min_pstate, cpu->min_perf_ratio);
+       max_pstate = max(min_pstate, cpu->max_perf_ratio);
        return clamp_t(int, pstate, min_pstate, max_pstate);
 }
 
@@ -1733,16 +1726,6 @@ static void intel_pstate_adjust_pstate(struct cpudata *cpu, int target_pstate)
                fp_toint(cpu->iowait_boost * 100));
 }
 
-static void intel_pstate_update_util_hwp(struct update_util_data *data,
-                                        u64 time, unsigned int flags)
-{
-       struct cpudata *cpu = container_of(data, struct cpudata, update_util);
-       u64 delta_ns = time - cpu->sample.time;
-
-       if ((s64)delta_ns >= INTEL_PSTATE_HWP_SAMPLING_INTERVAL)
-               intel_pstate_sample(cpu, time);
-}
-
 static void intel_pstate_update_util_pid(struct update_util_data *data,
                                         u64 time, unsigned int flags)
 {
@@ -1934,6 +1917,9 @@ static void intel_pstate_set_update_util_hook(unsigned int cpu_num)
 {
        struct cpudata *cpu = all_cpu_data[cpu_num];
 
+       if (hwp_active)
+               return;
+
        if (cpu->update_util_set)
                return;
 
@@ -1967,52 +1953,61 @@ static void intel_pstate_update_perf_limits(struct cpufreq_policy *policy,
 {
        int max_freq = intel_pstate_get_max_freq(cpu);
        int32_t max_policy_perf, min_policy_perf;
+       int max_state, turbo_max;
 
-       max_policy_perf = div_ext_fp(policy->max, max_freq);
-       max_policy_perf = clamp_t(int32_t, max_policy_perf, 0, int_ext_tofp(1));
+       /*
+        * HWP needs some special consideration, because on BDX the
+        * HWP_REQUEST uses abstract value to represent performance
+        * rather than pure ratios.
+        */
+       if (hwp_active) {
+               intel_pstate_get_hwp_max(cpu->cpu, &turbo_max, &max_state);
+       } else {
+               max_state = intel_pstate_get_base_pstate(cpu);
+               turbo_max = cpu->pstate.turbo_pstate;
+       }
+
+       max_policy_perf = max_state * policy->max / max_freq;
        if (policy->max == policy->min) {
                min_policy_perf = max_policy_perf;
        } else {
-               min_policy_perf = div_ext_fp(policy->min, max_freq);
+               min_policy_perf = max_state * policy->min / max_freq;
                min_policy_perf = clamp_t(int32_t, min_policy_perf,
                                          0, max_policy_perf);
        }
 
+       pr_debug("cpu:%d max_state %d min_policy_perf:%d max_policy_perf:%d\n",
+                policy->cpu, max_state,
+                min_policy_perf, max_policy_perf);
+
        /* Normalize user input to [min_perf, max_perf] */
        if (per_cpu_limits) {
-               cpu->min_perf = min_policy_perf;
-               cpu->max_perf = max_policy_perf;
+               cpu->min_perf_ratio = min_policy_perf;
+               cpu->max_perf_ratio = max_policy_perf;
        } else {
                int32_t global_min, global_max;
 
                /* Global limits are in percent of the maximum turbo P-state. */
-               global_max = percent_ext_fp(global.max_perf_pct);
-               global_min = percent_ext_fp(global.min_perf_pct);
-               if (max_freq != cpu->pstate.turbo_freq) {
-                       int32_t turbo_factor;
-
-                       turbo_factor = div_ext_fp(cpu->pstate.turbo_pstate,
-                                                 cpu->pstate.max_pstate);
-                       global_min = mul_ext_fp(global_min, turbo_factor);
-                       global_max = mul_ext_fp(global_max, turbo_factor);
-               }
+               global_max = DIV_ROUND_UP(turbo_max * global.max_perf_pct, 100);
+               global_min = DIV_ROUND_UP(turbo_max * global.min_perf_pct, 100);
                global_min = clamp_t(int32_t, global_min, 0, global_max);
 
-               cpu->min_perf = max(min_policy_perf, global_min);
-               cpu->min_perf = min(cpu->min_perf, max_policy_perf);
-               cpu->max_perf = min(max_policy_perf, global_max);
-               cpu->max_perf = max(min_policy_perf, cpu->max_perf);
+               pr_debug("cpu:%d global_min:%d global_max:%d\n", policy->cpu,
+                        global_min, global_max);
 
-               /* Make sure min_perf <= max_perf */
-               cpu->min_perf = min(cpu->min_perf, cpu->max_perf);
-       }
+               cpu->min_perf_ratio = max(min_policy_perf, global_min);
+               cpu->min_perf_ratio = min(cpu->min_perf_ratio, max_policy_perf);
+               cpu->max_perf_ratio = min(max_policy_perf, global_max);
+               cpu->max_perf_ratio = max(min_policy_perf, cpu->max_perf_ratio);
 
-       cpu->max_perf = round_up(cpu->max_perf, EXT_FRAC_BITS);
-       cpu->min_perf = round_up(cpu->min_perf, EXT_FRAC_BITS);
+               /* Make sure min_perf <= max_perf */
+               cpu->min_perf_ratio = min(cpu->min_perf_ratio,
+                                         cpu->max_perf_ratio);
 
-       pr_debug("cpu:%d max_perf_pct:%d min_perf_pct:%d\n", policy->cpu,
-                fp_ext_toint(cpu->max_perf * 100),
-                fp_ext_toint(cpu->min_perf * 100));
+       }
+       pr_debug("cpu:%d max_perf_ratio:%d min_perf_ratio:%d\n", policy->cpu,
+                cpu->max_perf_ratio,
+                cpu->min_perf_ratio);
 }
 
 static int intel_pstate_set_policy(struct cpufreq_policy *policy)
@@ -2039,10 +2034,10 @@ static int intel_pstate_set_policy(struct cpufreq_policy *policy)
                 */
                intel_pstate_clear_update_util_hook(policy->cpu);
                intel_pstate_max_within_limits(cpu);
+       } else {
+               intel_pstate_set_update_util_hook(policy->cpu);
        }
 
-       intel_pstate_set_update_util_hook(policy->cpu);
-
        if (hwp_active)
                intel_pstate_hwp_set(policy->cpu);
 
@@ -2115,8 +2110,8 @@ static int __intel_pstate_cpu_init(struct cpufreq_policy *policy)
 
        cpu = all_cpu_data[policy->cpu];
 
-       cpu->max_perf = int_ext_tofp(1);
-       cpu->min_perf = 0;
+       cpu->max_perf_ratio = 0xFF;
+       cpu->min_perf_ratio = 0;
 
        policy->min = cpu->pstate.min_pstate * cpu->pstate.scaling;
        policy->max = cpu->pstate.turbo_pstate * cpu->pstate.scaling;
@@ -2558,7 +2553,6 @@ static int __init intel_pstate_init(void)
                } else {
                        hwp_active++;
                        intel_pstate.attr = hwp_cpufreq_attrs;
-                       pstate_funcs.update_util = intel_pstate_update_util_hwp;
                        goto hwp_cpu_matched;
                }
        } else {
index 992ce6f9abecdacf256e9d61c16a9e0d6742b767..3779742f86e3c08efbd9f18479ad61432f35d21e 100644 (file)
@@ -24,7 +24,7 @@
 
 #include <asm/msr.h>
 
-struct cpufreq_frequency_table *freq_table;
+static struct cpufreq_frequency_table *freq_table;
 static struct sfi_freq_table_entry *sfi_cpufreq_array;
 static int num_freq_table_entries;
 
index 21340e0be73e7c045dcf878a7ad759713ae026e9..f52144808455b28766e12cde86cdc557aeb5ebce 100644 (file)
@@ -4,6 +4,7 @@
 config ARM_CPUIDLE
         bool "Generic ARM/ARM64 CPU idle Driver"
         select DT_IDLE_STATES
+       select CPU_IDLE_MULTIPLE_DRIVERS
         help
           Select this to enable generic cpuidle driver for ARM.
           It provides a generic idle driver whose idle states are configured
index f440d385ed3471a3abd0ff5ce63d133c5f46785f..7080c384ad5de656e8c345a336167624b236a2bb 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/slab.h>
+#include <linux/topology.h>
 
 #include <asm/cpuidle.h>
 
@@ -44,7 +45,7 @@ static int arm_enter_idle_state(struct cpuidle_device *dev,
        return CPU_PM_CPU_IDLE_ENTER(arm_cpuidle_suspend, idx);
 }
 
-static struct cpuidle_driver arm_idle_driver = {
+static struct cpuidle_driver arm_idle_driver __initdata = {
        .name = "arm_idle",
        .owner = THIS_MODULE,
        /*
@@ -80,30 +81,42 @@ static const struct of_device_id arm_idle_state_match[] __initconst = {
 static int __init arm_idle_init(void)
 {
        int cpu, ret;
-       struct cpuidle_driver *drv = &arm_idle_driver;
+       struct cpuidle_driver *drv;
        struct cpuidle_device *dev;
 
-       /*
-        * Initialize idle states data, starting at index 1.
-        * This driver is DT only, if no DT idle states are detected (ret == 0)
-        * let the driver initialization fail accordingly since there is no
-        * reason to initialize the idle driver if only wfi is supported.
-        */
-       ret = dt_init_idle_driver(drv, arm_idle_state_match, 1);
-       if (ret <= 0)
-               return ret ? : -ENODEV;
-
-       ret = cpuidle_register_driver(drv);
-       if (ret) {
-               pr_err("Failed to register cpuidle driver\n");
-               return ret;
-       }
-
-       /*
-        * Call arch CPU operations in order to initialize
-        * idle states suspend back-end specific data
-        */
        for_each_possible_cpu(cpu) {
+
+               drv = kmemdup(&arm_idle_driver, sizeof(*drv), GFP_KERNEL);
+               if (!drv) {
+                       ret = -ENOMEM;
+                       goto out_fail;
+               }
+
+               drv->cpumask = (struct cpumask *)cpumask_of(cpu);
+
+               /*
+                * Initialize idle states data, starting at index 1.  This
+                * driver is DT only, if no DT idle states are detected (ret
+                * == 0) let the driver initialization fail accordingly since
+                * there is no reason to initialize the idle driver if only
+                * wfi is supported.
+                */
+               ret = dt_init_idle_driver(drv, arm_idle_state_match, 1);
+               if (ret <= 0) {
+                       ret = ret ? : -ENODEV;
+                       goto out_fail;
+               }
+
+               ret = cpuidle_register_driver(drv);
+               if (ret) {
+                       pr_err("Failed to register cpuidle driver\n");
+                       goto out_fail;
+               }
+
+               /*
+                * Call arch CPU operations in order to initialize
+                * idle states suspend back-end specific data
+                */
                ret = arm_cpuidle_init(cpu);
 
                /*
@@ -141,10 +154,11 @@ out_fail:
                dev = per_cpu(cpuidle_devices, cpu);
                cpuidle_unregister_device(dev);
                kfree(dev);
+               drv = cpuidle_get_driver();
+               cpuidle_unregister_driver(drv);
+               kfree(drv);
        }
 
-       cpuidle_unregister_driver(drv);
-
        return ret;
 }
 device_initcall(arm_idle_init);
index b2330fd69e3464bbb5713a6b5dceadeba3421f0d..61b64c2b2cb869d9e6c494af5b6878471f2ce5ac 100644 (file)
@@ -286,6 +286,8 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev)
        struct device *device = get_cpu_device(dev->cpu);
        int latency_req = pm_qos_request(PM_QOS_CPU_DMA_LATENCY);
        int i;
+       int first_idx;
+       int idx;
        unsigned int interactivity_req;
        unsigned int expected_interval;
        unsigned long nr_iowaiters, cpu_load;
@@ -335,11 +337,11 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev)
                if (data->next_timer_us > polling_threshold &&
                    latency_req > s->exit_latency && !s->disabled &&
                    !dev->states_usage[CPUIDLE_DRIVER_STATE_START].disable)
-                       data->last_state_idx = CPUIDLE_DRIVER_STATE_START;
+                       first_idx = CPUIDLE_DRIVER_STATE_START;
                else
-                       data->last_state_idx = CPUIDLE_DRIVER_STATE_START - 1;
+                       first_idx = CPUIDLE_DRIVER_STATE_START - 1;
        } else {
-               data->last_state_idx = CPUIDLE_DRIVER_STATE_START;
+               first_idx = 0;
        }
 
        /*
@@ -359,20 +361,28 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev)
         * Find the idle state with the lowest power while satisfying
         * our constraints.
         */
-       for (i = data->last_state_idx + 1; i < drv->state_count; i++) {
+       idx = -1;
+       for (i = first_idx; i < drv->state_count; i++) {
                struct cpuidle_state *s = &drv->states[i];
                struct cpuidle_state_usage *su = &dev->states_usage[i];
 
                if (s->disabled || su->disable)
                        continue;
+               if (idx == -1)
+                       idx = i; /* first enabled state */
                if (s->target_residency > data->predicted_us)
                        break;
                if (s->exit_latency > latency_req)
                        break;
 
-               data->last_state_idx = i;
+               idx = i;
        }
 
+       if (idx == -1)
+               idx = 0; /* No states enabled. Must use 0. */
+
+       data->last_state_idx = idx;
+
        return data->last_state_idx;
 }
 
index eb638a1e69d20c985263398e89928d218d30531e..42fb436f6cdc9dc410681d4af0d5f4148b58dc07 100644 (file)
@@ -15,13 +15,9 @@ static struct intel_dsm_priv {
        acpi_handle dhandle;
 } intel_dsm_priv;
 
-static const u8 intel_dsm_guid[] = {
-       0xd3, 0x73, 0xd8, 0x7e,
-       0xd0, 0xc2,
-       0x4f, 0x4e,
-       0xa8, 0x54,
-       0x0f, 0x13, 0x17, 0xb0, 0x1c, 0x2c
-};
+static const guid_t intel_dsm_guid =
+       GUID_INIT(0x7ed873d3, 0xc2d0, 0x4e4f,
+                 0xa8, 0x54, 0x0f, 0x13, 0x17, 0xb0, 0x1c, 0x2c);
 
 static char *intel_dsm_port_name(u8 id)
 {
@@ -80,7 +76,7 @@ static void intel_dsm_platform_mux_info(void)
        int i;
        union acpi_object *pkg, *connector_count;
 
-       pkg = acpi_evaluate_dsm_typed(intel_dsm_priv.dhandle, intel_dsm_guid,
+       pkg = acpi_evaluate_dsm_typed(intel_dsm_priv.dhandle, &intel_dsm_guid,
                        INTEL_DSM_REVISION_ID, INTEL_DSM_FN_PLATFORM_MUX_INFO,
                        NULL, ACPI_TYPE_PACKAGE);
        if (!pkg) {
@@ -118,7 +114,7 @@ static bool intel_dsm_pci_probe(struct pci_dev *pdev)
        if (!dhandle)
                return false;
 
-       if (!acpi_check_dsm(dhandle, intel_dsm_guid, INTEL_DSM_REVISION_ID,
+       if (!acpi_check_dsm(dhandle, &intel_dsm_guid, INTEL_DSM_REVISION_ID,
                            1 << INTEL_DSM_FN_PLATFORM_MUX_INFO)) {
                DRM_DEBUG_KMS("no _DSM method for intel device\n");
                return false;
index 39468c2180277618caddceb0681d1bdd39f53140..7459ef9943ec10bb2925854e9a11378b2e093bf7 100644 (file)
@@ -60,15 +60,13 @@ bool nouveau_is_v1_dsm(void) {
 }
 
 #ifdef CONFIG_VGA_SWITCHEROO
-static const char nouveau_dsm_muid[] = {
-       0xA0, 0xA0, 0x95, 0x9D, 0x60, 0x00, 0x48, 0x4D,
-       0xB3, 0x4D, 0x7E, 0x5F, 0xEA, 0x12, 0x9F, 0xD4,
-};
+static const guid_t nouveau_dsm_muid =
+       GUID_INIT(0x9D95A0A0, 0x0060, 0x4D48,
+                 0xB3, 0x4D, 0x7E, 0x5F, 0xEA, 0x12, 0x9F, 0xD4);
 
-static const char nouveau_op_dsm_muid[] = {
-       0xF8, 0xD8, 0x86, 0xA4, 0xDA, 0x0B, 0x1B, 0x47,
-       0xA7, 0x2B, 0x60, 0x42, 0xA6, 0xB5, 0xBE, 0xE0,
-};
+static const guid_t nouveau_op_dsm_muid =
+       GUID_INIT(0xA486D8F8, 0x0BDA, 0x471B,
+                 0xA7, 0x2B, 0x60, 0x42, 0xA6, 0xB5, 0xBE, 0xE0);
 
 static int nouveau_optimus_dsm(acpi_handle handle, int func, int arg, uint32_t *result)
 {
@@ -86,7 +84,7 @@ static int nouveau_optimus_dsm(acpi_handle handle, int func, int arg, uint32_t *
                args_buff[i] = (arg >> i * 8) & 0xFF;
 
        *result = 0;
-       obj = acpi_evaluate_dsm_typed(handle, nouveau_op_dsm_muid, 0x00000100,
+       obj = acpi_evaluate_dsm_typed(handle, &nouveau_op_dsm_muid, 0x00000100,
                                      func, &argv4, ACPI_TYPE_BUFFER);
        if (!obj) {
                acpi_handle_info(handle, "failed to evaluate _DSM\n");
@@ -138,7 +136,7 @@ static int nouveau_dsm(acpi_handle handle, int func, int arg)
                .integer.value = arg,
        };
 
-       obj = acpi_evaluate_dsm_typed(handle, nouveau_dsm_muid, 0x00000102,
+       obj = acpi_evaluate_dsm_typed(handle, &nouveau_dsm_muid, 0x00000102,
                                      func, &argv4, ACPI_TYPE_INTEGER);
        if (!obj) {
                acpi_handle_info(handle, "failed to evaluate _DSM\n");
@@ -259,7 +257,7 @@ static void nouveau_dsm_pci_probe(struct pci_dev *pdev, acpi_handle *dhandle_out
        if (!acpi_has_method(dhandle, "_DSM"))
                return;
 
-       supports_mux = acpi_check_dsm(dhandle, nouveau_dsm_muid, 0x00000102,
+       supports_mux = acpi_check_dsm(dhandle, &nouveau_dsm_muid, 0x00000102,
                                      1 << NOUVEAU_DSM_POWER);
        optimus_funcs = nouveau_dsm_get_optimus_functions(dhandle);
 
index e3e2f5e838152bfc5f6f0eaa6b6b4fe1cbc15a84..f44682d62f750dcb5311505f67dc8691472e6463 100644 (file)
@@ -81,10 +81,9 @@ mxm_shadow_dsm(struct nvkm_mxm *mxm, u8 version)
 {
        struct nvkm_subdev *subdev = &mxm->subdev;
        struct nvkm_device *device = subdev->device;
-       static char muid[] = {
-               0x00, 0xA4, 0x04, 0x40, 0x7D, 0x91, 0xF2, 0x4C,
-               0xB8, 0x9C, 0x79, 0xB6, 0x2F, 0xD5, 0x56, 0x65
-       };
+       static guid_t muid =
+               GUID_INIT(0x4004A400, 0x917D, 0x4CF2,
+                         0xB8, 0x9C, 0x79, 0xB6, 0x2F, 0xD5, 0x56, 0x65);
        u32 mxms_args[] = { 0x00000000 };
        union acpi_object argv4 = {
                .buffer.type = ACPI_TYPE_BUFFER,
@@ -105,7 +104,7 @@ mxm_shadow_dsm(struct nvkm_mxm *mxm, u8 version)
         * unless you pass in exactly the version it supports..
         */
        rev = (version & 0xf0) << 4 | (version & 0x0f);
-       obj = acpi_evaluate_dsm(handle, muid, rev, 0x00000010, &argv4);
+       obj = acpi_evaluate_dsm(handle, &muid, rev, 0x00000010, &argv4);
        if (!obj) {
                nvkm_debug(subdev, "DSM MXMS failed\n");
                return false;
index fb55fb4c39fcfecaca55c0b8720d28d2f9717678..04015032a35a204b10593f71faac6812b82e45e8 100644 (file)
@@ -872,10 +872,9 @@ static int i2c_hid_fetch_hid_descriptor(struct i2c_hid *ihid)
 static int i2c_hid_acpi_pdata(struct i2c_client *client,
                struct i2c_hid_platform_data *pdata)
 {
-       static u8 i2c_hid_guid[] = {
-               0xF7, 0xF6, 0xDF, 0x3C, 0x67, 0x42, 0x55, 0x45,
-               0xAD, 0x05, 0xB3, 0x0A, 0x3D, 0x89, 0x38, 0xDE,
-       };
+       static guid_t i2c_hid_guid =
+               GUID_INIT(0x3CDFF6F7, 0x4267, 0x4555,
+                         0xAD, 0x05, 0xB3, 0x0A, 0x3D, 0x89, 0x38, 0xDE);
        union acpi_object *obj;
        struct acpi_device *adev;
        acpi_handle handle;
@@ -884,7 +883,7 @@ static int i2c_hid_acpi_pdata(struct i2c_client *client,
        if (!handle || acpi_bus_get_device(handle, &adev))
                return -ENODEV;
 
-       obj = acpi_evaluate_dsm_typed(handle, i2c_hid_guid, 1, 1, NULL,
+       obj = acpi_evaluate_dsm_typed(handle, &i2c_hid_guid, 1, 1, NULL,
                                      ACPI_TYPE_INTEGER);
        if (!obj) {
                dev_err(&client->dev, "device _DSM execution failed\n");
index 216d7ec88c0c7d55eca7ef198a53fb754da3c182..c2ae819a871cb6d8f09412702e46463397f9fc0f 100644 (file)
@@ -51,6 +51,8 @@
 /* un-comment DEBUG to enable pr_debug() statements */
 #define DEBUG
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/kernel.h>
 #include <linux/cpuidle.h>
 #include <linux/tick.h>
@@ -65,7 +67,6 @@
 #include <asm/msr.h>
 
 #define INTEL_IDLE_VERSION "0.4.1"
-#define PREFIX "intel_idle: "
 
 static struct cpuidle_driver intel_idle_driver = {
        .name = "intel_idle",
@@ -1111,7 +1112,7 @@ static int __init intel_idle_probe(void)
        const struct x86_cpu_id *id;
 
        if (max_cstate == 0) {
-               pr_debug(PREFIX "disabled\n");
+               pr_debug("disabled\n");
                return -EPERM;
        }
 
@@ -1119,8 +1120,8 @@ static int __init intel_idle_probe(void)
        if (!id) {
                if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL &&
                    boot_cpu_data.x86 == 6)
-                       pr_debug(PREFIX "does not run on family %d model %d\n",
-                               boot_cpu_data.x86, boot_cpu_data.x86_model);
+                       pr_debug("does not run on family %d model %d\n",
+                                boot_cpu_data.x86, boot_cpu_data.x86_model);
                return -ENODEV;
        }
 
@@ -1134,13 +1135,13 @@ static int __init intel_idle_probe(void)
            !mwait_substates)
                        return -ENODEV;
 
-       pr_debug(PREFIX "MWAIT substates: 0x%x\n", mwait_substates);
+       pr_debug("MWAIT substates: 0x%x\n", mwait_substates);
 
        icpu = (const struct idle_cpu *)id->driver_data;
        cpuidle_state_table = icpu->state_table;
 
-       pr_debug(PREFIX "v" INTEL_IDLE_VERSION
-               " model 0x%X\n", boot_cpu_data.x86_model);
+       pr_debug("v" INTEL_IDLE_VERSION " model 0x%X\n",
+                boot_cpu_data.x86_model);
 
        return 0;
 }
@@ -1340,8 +1341,7 @@ static void __init intel_idle_cpuidle_driver_init(void)
                        break;
 
                if (cstate + 1 > max_cstate) {
-                       printk(PREFIX "max_cstate %d reached\n",
-                               max_cstate);
+                       pr_info("max_cstate %d reached\n", max_cstate);
                        break;
                }
 
@@ -1358,8 +1358,8 @@ static void __init intel_idle_cpuidle_driver_init(void)
 
                /* if state marked as disabled, skip it */
                if (cpuidle_state_table[cstate].disabled != 0) {
-                       pr_debug(PREFIX "state %s is disabled",
-                               cpuidle_state_table[cstate].name);
+                       pr_debug("state %s is disabled\n",
+                                cpuidle_state_table[cstate].name);
                        continue;
                }
 
@@ -1395,7 +1395,7 @@ static int intel_idle_cpu_init(unsigned int cpu)
        dev->cpu = cpu;
 
        if (cpuidle_register_device(dev)) {
-               pr_debug(PREFIX "cpuidle_register_device %d failed!\n", cpu);
+               pr_debug("cpuidle_register_device %d failed!\n", cpu);
                return -EIO;
        }
 
@@ -1447,8 +1447,8 @@ static int __init intel_idle_init(void)
        retval = cpuidle_register_driver(&intel_idle_driver);
        if (retval) {
                struct cpuidle_driver *drv = cpuidle_get_driver();
-               printk(KERN_DEBUG PREFIX "intel_idle yielding to %s",
-                       drv ? drv->name : "none");
+               printk(KERN_DEBUG pr_fmt("intel_idle yielding to %s\n"),
+                      drv ? drv->name : "none");
                goto init_driver_fail;
        }
 
@@ -1460,8 +1460,8 @@ static int __init intel_idle_init(void)
        if (retval < 0)
                goto hp_setup_fail;
 
-       pr_debug(PREFIX "lapic_timer_reliable_states 0x%x\n",
-               lapic_timer_reliable_states);
+       pr_debug("lapic_timer_reliable_states 0x%x\n",
+                lapic_timer_reliable_states);
 
        return 0;
 
index cbf7763d8091035deb45d2c36a7fc7201e6b4ab0..c8b0329c85d2801e1cd99c74c9959f03ee1790d2 100644 (file)
@@ -1808,10 +1808,9 @@ IOMMU_INIT_POST(detect_intel_iommu);
  * for Directed-IO Architecture Specifiction, Rev 2.2, Section 8.8
  * "Remapping Hardware Unit Hot Plug".
  */
-static u8 dmar_hp_uuid[] = {
-       /* 0000 */    0xA6, 0xA3, 0xC1, 0xD8, 0x9B, 0xBE, 0x9B, 0x4C,
-       /* 0008 */    0x91, 0xBF, 0xC3, 0xCB, 0x81, 0xFC, 0x5D, 0xAF
-};
+static guid_t dmar_hp_guid =
+       GUID_INIT(0xD8C1A3A6, 0xBE9B, 0x4C9B,
+                 0x91, 0xBF, 0xC3, 0xCB, 0x81, 0xFC, 0x5D, 0xAF);
 
 /*
  * Currently there's only one revision and BIOS will not check the revision id,
@@ -1824,7 +1823,7 @@ static u8 dmar_hp_uuid[] = {
 
 static inline bool dmar_detect_dsm(acpi_handle handle, int func)
 {
-       return acpi_check_dsm(handle, dmar_hp_uuid, DMAR_DSM_REV_ID, 1 << func);
+       return acpi_check_dsm(handle, &dmar_hp_guid, DMAR_DSM_REV_ID, 1 << func);
 }
 
 static int dmar_walk_dsm_resource(acpi_handle handle, int func,
@@ -1843,7 +1842,7 @@ static int dmar_walk_dsm_resource(acpi_handle handle, int func,
        if (!dmar_detect_dsm(handle, func))
                return 0;
 
-       obj = acpi_evaluate_dsm_typed(handle, dmar_hp_uuid, DMAR_DSM_REV_ID,
+       obj = acpi_evaluate_dsm_typed(handle, &dmar_hp_guid, DMAR_DSM_REV_ID,
                                      func, NULL, ACPI_TYPE_BUFFER);
        if (!obj)
                return -ENODEV;
index 87edc342ccb3d5c51bb45313f1218f9839528917..84e76ebac4d4eac844850f7b1b37e12d2d0d72f2 100644 (file)
@@ -825,7 +825,7 @@ fail:
        return -EINVAL;
 }
 
-static int uuid_equal(mdp_super_t *sb1, mdp_super_t *sb2)
+static int md_uuid_equal(mdp_super_t *sb1, mdp_super_t *sb2)
 {
        return  sb1->set_uuid0 == sb2->set_uuid0 &&
                sb1->set_uuid1 == sb2->set_uuid1 &&
@@ -833,7 +833,7 @@ static int uuid_equal(mdp_super_t *sb1, mdp_super_t *sb2)
                sb1->set_uuid3 == sb2->set_uuid3;
 }
 
-static int sb_equal(mdp_super_t *sb1, mdp_super_t *sb2)
+static int md_sb_equal(mdp_super_t *sb1, mdp_super_t *sb2)
 {
        int ret;
        mdp_super_t *tmp1, *tmp2;
@@ -1025,12 +1025,12 @@ static int super_90_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor
        } else {
                __u64 ev1, ev2;
                mdp_super_t *refsb = page_address(refdev->sb_page);
-               if (!uuid_equal(refsb, sb)) {
+               if (!md_uuid_equal(refsb, sb)) {
                        pr_warn("md: %s has different UUID to %s\n",
                                b, bdevname(refdev->bdev,b2));
                        goto abort;
                }
-               if (!sb_equal(refsb, sb)) {
+               if (!md_sb_equal(refsb, sb)) {
                        pr_warn("md: %s has same UUID but different superblock to %s\n",
                                b, bdevname(refdev->bdev, b2));
                        goto abort;
index 92fc3f7c538d73e9e496aacfeae45f37cd3c1a96..9577beb278e7d51fc1ed08db0f52053abebec1ec 100644 (file)
@@ -404,10 +404,9 @@ struct intel_host {
        bool    d3_retune;
 };
 
-const u8 intel_dsm_uuid[] = {
-       0xA5, 0x3E, 0xC1, 0xF6, 0xCD, 0x65, 0x1F, 0x46,
-       0xAB, 0x7A, 0x29, 0xF7, 0xE8, 0xD5, 0xBD, 0x61,
-};
+const guid_t intel_dsm_guid =
+       GUID_INIT(0xF6C13EA5, 0x65CD, 0x461F,
+                 0xAB, 0x7A, 0x29, 0xF7, 0xE8, 0xD5, 0xBD, 0x61);
 
 static int __intel_dsm(struct intel_host *intel_host, struct device *dev,
                       unsigned int fn, u32 *result)
@@ -416,7 +415,7 @@ static int __intel_dsm(struct intel_host *intel_host, struct device *dev,
        int err = 0;
        size_t len;
 
-       obj = acpi_evaluate_dsm(ACPI_HANDLE(dev), intel_dsm_uuid, 0, fn, NULL);
+       obj = acpi_evaluate_dsm(ACPI_HANDLE(dev), &intel_dsm_guid, 0, fn, NULL);
        if (!obj)
                return -EOPNOTSUPP;
 
index e13aa064a8e943da7c9538e88bc425f299e944ca..6b15a507999c42749165482aa5e7d26a4d3dcf1c 100644 (file)
@@ -29,10 +29,9 @@ enum _dsm_rst_type {
        HNS_ROCE_RESET_FUNC     = 0x7,
 };
 
-const u8 hns_dsaf_acpi_dsm_uuid[] = {
-       0x1A, 0xAA, 0x85, 0x1A, 0x93, 0xE2, 0x5E, 0x41,
-       0x8E, 0x28, 0x8D, 0x69, 0x0A, 0x0F, 0x82, 0x0A
-};
+const guid_t hns_dsaf_acpi_dsm_guid =
+       GUID_INIT(0x1A85AA1A, 0xE293, 0x415E,
+                 0x8E, 0x28, 0x8D, 0x69, 0x0A, 0x0F, 0x82, 0x0A);
 
 static void dsaf_write_sub(struct dsaf_device *dsaf_dev, u32 reg, u32 val)
 {
@@ -151,7 +150,7 @@ static void hns_dsaf_acpi_srst_by_port(struct dsaf_device *dsaf_dev, u8 op_type,
        argv4.package.elements = obj_args;
 
        obj = acpi_evaluate_dsm(ACPI_HANDLE(dsaf_dev->dev),
-                               hns_dsaf_acpi_dsm_uuid, 0, op_type, &argv4);
+                               &hns_dsaf_acpi_dsm_guid, 0, op_type, &argv4);
        if (!obj) {
                dev_warn(dsaf_dev->dev, "reset port_type%d port%d fail!",
                         port_type, port);
@@ -434,7 +433,7 @@ static phy_interface_t hns_mac_get_phy_if_acpi(struct hns_mac_cb *mac_cb)
        argv4.package.elements = &obj_args,
 
        obj = acpi_evaluate_dsm(ACPI_HANDLE(mac_cb->dev),
-                               hns_dsaf_acpi_dsm_uuid, 0,
+                               &hns_dsaf_acpi_dsm_guid, 0,
                                HNS_OP_GET_PORT_TYPE_FUNC, &argv4);
 
        if (!obj || obj->type != ACPI_TYPE_INTEGER)
@@ -474,7 +473,7 @@ int hns_mac_get_sfp_prsnt_acpi(struct hns_mac_cb *mac_cb, int *sfp_prsnt)
        argv4.package.elements = &obj_args,
 
        obj = acpi_evaluate_dsm(ACPI_HANDLE(mac_cb->dev),
-                               hns_dsaf_acpi_dsm_uuid, 0,
+                               &hns_dsaf_acpi_dsm_guid, 0,
                                HNS_OP_GET_SFP_STAT_FUNC, &argv4);
 
        if (!obj || obj->type != ACPI_TYPE_INTEGER)
@@ -565,7 +564,7 @@ hns_mac_config_sds_loopback_acpi(struct hns_mac_cb *mac_cb, bool en)
        argv4.package.elements = obj_args;
 
        obj = acpi_evaluate_dsm(ACPI_HANDLE(mac_cb->dsaf_dev->dev),
-                               hns_dsaf_acpi_dsm_uuid, 0,
+                               &hns_dsaf_acpi_dsm_guid, 0,
                                HNS_OP_SERDES_LP_FUNC, &argv4);
        if (!obj) {
                dev_warn(mac_cb->dsaf_dev->dev, "set port%d serdes lp fail!",
index ae00dc0d97917392cd3f447d1e3bb937a1a67253..4c989bb9a8a03fea2f76f1c0ad49cbfb842d7fc3 100644 (file)
@@ -222,13 +222,6 @@ struct device *nd_btt_create(struct nd_region *nd_region)
        return dev;
 }
 
-static bool uuid_is_null(u8 *uuid)
-{
-       static const u8 null_uuid[16];
-
-       return (memcmp(uuid, null_uuid, 16) == 0);
-}
-
 /**
  * nd_btt_arena_is_valid - check if the metadata layout is valid
  * @nd_btt:    device with BTT geometry and backing device info
@@ -249,7 +242,7 @@ bool nd_btt_arena_is_valid(struct nd_btt *nd_btt, struct btt_sb *super)
        if (memcmp(super->signature, BTT_SIG, BTT_SIG_LEN) != 0)
                return false;
 
-       if (!uuid_is_null(super->parent_uuid))
+       if (!guid_is_null((guid_t *)&super->parent_uuid))
                if (memcmp(super->parent_uuid, parent_uuid, 16) != 0)
                        return false;
 
index 990e6fb32a636201078da585372d6ddfed97c9bd..c190d7e36900175f41110e97b8c327f93fc47fdd 100644 (file)
@@ -58,7 +58,7 @@ static struct nvmf_host *nvmf_host_add(const char *hostnqn)
 
        kref_init(&host->ref);
        memcpy(host->nqn, hostnqn, NVMF_NQN_SIZE);
-       uuid_be_gen(&host->id);
+       uuid_gen(&host->id);
 
        list_add_tail(&host->list, &nvmf_hosts);
 out_unlock:
@@ -75,7 +75,7 @@ static struct nvmf_host *nvmf_host_default(void)
                return NULL;
 
        kref_init(&host->ref);
-       uuid_be_gen(&host->id);
+       uuid_gen(&host->id);
        snprintf(host->nqn, NVMF_NQN_SIZE,
                "nqn.2014-08.org.nvmexpress:NVMf:uuid:%pUb", &host->id);
 
@@ -395,7 +395,7 @@ int nvmf_connect_admin_queue(struct nvme_ctrl *ctrl)
        if (!data)
                return -ENOMEM;
 
-       memcpy(&data->hostid, &ctrl->opts->host->id, sizeof(uuid_be));
+       uuid_copy(&data->hostid, &ctrl->opts->host->id);
        data->cntlid = cpu_to_le16(0xffff);
        strncpy(data->subsysnqn, ctrl->opts->subsysnqn, NVMF_NQN_SIZE);
        strncpy(data->hostnqn, ctrl->opts->host->nqn, NVMF_NQN_SIZE);
@@ -454,7 +454,7 @@ int nvmf_connect_io_queue(struct nvme_ctrl *ctrl, u16 qid)
        if (!data)
                return -ENOMEM;
 
-       memcpy(&data->hostid, &ctrl->opts->host->id, sizeof(uuid_be));
+       uuid_copy(&data->hostid, &ctrl->opts->host->id);
        data->cntlid = cpu_to_le16(ctrl->cntlid);
        strncpy(data->subsysnqn, ctrl->opts->subsysnqn, NVMF_NQN_SIZE);
        strncpy(data->hostnqn, ctrl->opts->host->nqn, NVMF_NQN_SIZE);
index f5a9c1fb186f2d5278ecd72eeaf93b1b7d75e6e8..29be7600689d41ed5549d5fc070c070cb1d8f7ae 100644 (file)
@@ -36,7 +36,7 @@ struct nvmf_host {
        struct kref             ref;
        struct list_head        list;
        char                    nqn[NVMF_NQN_SIZE];
-       uuid_be                 id;
+       uuid_                 id;
 };
 
 /**
index 92964cef0f4be5795bed3e874407c74a3e3cc725..5ee4c71d168d182b4b48aff8c71827ae3b38e472 100644 (file)
@@ -878,8 +878,7 @@ nvme_fc_connect_admin_queue(struct nvme_fc_ctrl *ctrl,
        assoc_rqst->assoc_cmd.sqsize = cpu_to_be16(qsize);
        /* Linux supports only Dynamic controllers */
        assoc_rqst->assoc_cmd.cntlid = cpu_to_be16(0xffff);
-       memcpy(&assoc_rqst->assoc_cmd.hostid, &ctrl->ctrl.opts->host->id,
-               min_t(size_t, FCNVME_ASSOC_HOSTID_LEN, sizeof(uuid_be)));
+       uuid_copy(&assoc_rqst->assoc_cmd.hostid, &ctrl->ctrl.opts->host->id);
        strncpy(assoc_rqst->assoc_cmd.hostnqn, ctrl->ctrl.opts->host->nqn,
                min(FCNVME_ASSOC_HOSTNQN_LEN, NVMF_NQN_SIZE));
        strncpy(assoc_rqst->assoc_cmd.subnqn, ctrl->ctrl.opts->subsysnqn,
index cfc5c7fb0ab78411f8d6e96ab7ffaaad241b6244..8ff6e430b30afe14730355e2ffd029a482aef578 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/percpu-refcount.h>
 #include <linux/list.h>
 #include <linux/mutex.h>
+#include <linux/uuid.h>
 #include <linux/nvme.h>
 #include <linux/configfs.h>
 #include <linux/rcupdate.h>
index 001860361434623fcf84de1c2533df03835de8a0..47070cff508c4496e51060e1167d33d426ad1e93 100644 (file)
 #include "pci.h"
 
 /*
- * The UUID is defined in the PCI Firmware Specification available here:
+ * The GUID is defined in the PCI Firmware Specification available here:
  * https://www.pcisig.com/members/downloads/pcifw_r3_1_13Dec10.pdf
  */
-const u8 pci_acpi_dsm_uuid[] = {
-       0xd0, 0x37, 0xc9, 0xe5, 0x53, 0x35, 0x7a, 0x4d,
-       0x91, 0x17, 0xea, 0x4d, 0x19, 0xc3, 0x43, 0x4d
-};
+const guid_t pci_acpi_dsm_guid =
+       GUID_INIT(0xe5c937d0, 0x3553, 0x4d7a,
+                 0x91, 0x17, 0xea, 0x4d, 0x19, 0xc3, 0x43, 0x4d);
 
 #if defined(CONFIG_PCI_QUIRKS) && defined(CONFIG_ARM64)
 static int acpi_get_rc_addr(struct acpi_device *adev, struct resource *res)
@@ -680,7 +679,7 @@ void acpi_pci_add_bus(struct pci_bus *bus)
        if (!pci_is_root_bus(bus))
                return;
 
-       obj = acpi_evaluate_dsm(ACPI_HANDLE(bus->bridge), pci_acpi_dsm_uuid, 3,
+       obj = acpi_evaluate_dsm(ACPI_HANDLE(bus->bridge), &pci_acpi_dsm_guid, 3,
                                RESET_DELAY_DSM, NULL);
        if (!obj)
                return;
@@ -745,7 +744,7 @@ static void pci_acpi_optimize_delay(struct pci_dev *pdev,
        if (bridge->ignore_reset_delay)
                pdev->d3cold_delay = 0;
 
-       obj = acpi_evaluate_dsm(handle, pci_acpi_dsm_uuid, 3,
+       obj = acpi_evaluate_dsm(handle, &pci_acpi_dsm_guid, 3,
                                FUNCTION_DELAY_DSM, NULL);
        if (!obj)
                return;
index 51357377efbce65d4ad8454ffd678fc4df8de7a2..2d8db3ead6e82f91106db1ae883d354e2fdb5c71 100644 (file)
@@ -172,7 +172,7 @@ static int dsm_get_label(struct device *dev, char *buf,
        if (!handle)
                return -1;
 
-       obj = acpi_evaluate_dsm(handle, pci_acpi_dsm_uuid, 0x2,
+       obj = acpi_evaluate_dsm(handle, &pci_acpi_dsm_guid, 0x2,
                                DEVICE_LABEL_DSM, NULL);
        if (!obj)
                return -1;
@@ -212,7 +212,7 @@ static bool device_has_dsm(struct device *dev)
        if (!handle)
                return false;
 
-       return !!acpi_check_dsm(handle, pci_acpi_dsm_uuid, 0x2,
+       return !!acpi_check_dsm(handle, &pci_acpi_dsm_guid, 0x2,
                                1 << DEVICE_LABEL_DSM);
 }
 
index 9ddad0815ba909a7c77de8f93db06e7bc712d246..d1694f1def7278d17249bbbc23e0a64b3704ba5d 100644 (file)
@@ -874,7 +874,9 @@ static int rapl_write_data_raw(struct rapl_domain *rd,
 
        cpu = rd->rp->lead_cpu;
        bits = rapl_unit_xlate(rd, rp->unit, value, 1);
-       bits |= bits << rp->shift;
+       bits <<= rp->shift;
+       bits &= rp->mask;
+
        memset(&ma, 0, sizeof(ma));
 
        ma.msr_no = rd->msrs[rp->id];
index dc095a292c61b4ad64f63fcd9685d9e047acf7b6..3be980d472681a4410d681e99d649b99cddb3cea 100644 (file)
@@ -245,7 +245,7 @@ struct sdebug_dev_info {
        unsigned int channel;
        unsigned int target;
        u64 lun;
-       uuid_be lu_name;
+       uuid_t lu_name;
        struct sdebug_host_info *sdbg_host;
        unsigned long uas_bm[1];
        atomic_t num_in_q;
@@ -965,7 +965,7 @@ static const u64 naa3_comp_c = 0x3111111000000000ULL;
 static int inquiry_vpd_83(unsigned char *arr, int port_group_id,
                          int target_dev_id, int dev_id_num,
                          const char *dev_id_str, int dev_id_str_len,
-                         const uuid_be *lu_name)
+                         const uuid_t *lu_name)
 {
        int num, port_a;
        char b[32];
@@ -3568,7 +3568,7 @@ static void sdebug_q_cmd_wq_complete(struct work_struct *work)
 }
 
 static bool got_shared_uuid;
-static uuid_be shared_uuid;
+static uuid_t shared_uuid;
 
 static struct sdebug_dev_info *sdebug_device_create(
                        struct sdebug_host_info *sdbg_host, gfp_t flags)
@@ -3578,12 +3578,12 @@ static struct sdebug_dev_info *sdebug_device_create(
        devip = kzalloc(sizeof(*devip), flags);
        if (devip) {
                if (sdebug_uuid_ctl == 1)
-                       uuid_be_gen(&devip->lu_name);
+                       uuid_gen(&devip->lu_name);
                else if (sdebug_uuid_ctl == 2) {
                        if (got_shared_uuid)
                                devip->lu_name = shared_uuid;
                        else {
-                               uuid_be_gen(&shared_uuid);
+                               uuid_gen(&shared_uuid);
                                got_shared_uuid = true;
                                devip->lu_name = shared_uuid;
                        }
index 9413c4abf0b93cca1681e2e3a46d083219cf5a5c..a9ec94ed7a425a303280c3cdba589d71b642011c 100644 (file)
@@ -23,7 +23,7 @@ enum int3400_thermal_uuid {
        INT3400_THERMAL_MAXIMUM_UUID,
 };
 
-static u8 *int3400_thermal_uuids[INT3400_THERMAL_MAXIMUM_UUID] = {
+static char *int3400_thermal_uuids[INT3400_THERMAL_MAXIMUM_UUID] = {
        "42A441D6-AE6A-462b-A84B-4A8CE79027D3",
        "3A95C389-E4B8-4629-A526-C52C88626BAE",
        "97C68AE7-15FA-499c-B8C9-5DA81D606E0A",
@@ -141,10 +141,10 @@ static int int3400_thermal_get_uuids(struct int3400_thermal_priv *priv)
                }
 
                for (j = 0; j < INT3400_THERMAL_MAXIMUM_UUID; j++) {
-                       u8 uuid[16];
+                       guid_t guid;
 
-                       acpi_str_to_uuid(int3400_thermal_uuids[j], uuid);
-                       if (!strncmp(uuid, objb->buffer.pointer, 16)) {
+                       guid_parse(int3400_thermal_uuids[j], &guid);
+                       if (guid_equal((guid_t *)objb->buffer.pointer, &guid)) {
                                priv->uuid_bitmap |= (1 << j);
                                break;
                        }
index 84a2cebfc712023182dbb4622cbc355b3545310d..fe851544d7fbaad82d3fdadc397da734d0a5bf4b 100644 (file)
@@ -42,7 +42,7 @@
 #define PCI_DEVICE_ID_INTEL_CNPLP              0x9dee
 #define PCI_DEVICE_ID_INTEL_CNPH               0xa36e
 
-#define PCI_INTEL_BXT_DSM_UUID         "732b85d5-b7a7-4a1b-9ba0-4bbd00ffd511"
+#define PCI_INTEL_BXT_DSM_GUID         "732b85d5-b7a7-4a1b-9ba0-4bbd00ffd511"
 #define PCI_INTEL_BXT_FUNC_PMU_PWR     4
 #define PCI_INTEL_BXT_STATE_D0         0
 #define PCI_INTEL_BXT_STATE_D3         3
  * struct dwc3_pci - Driver private structure
  * @dwc3: child dwc3 platform_device
  * @pci: our link to PCI bus
- * @uuid: _DSM UUID
+ * @guid: _DSM GUID
  * @has_dsm_for_pm: true for devices which need to run _DSM on runtime PM
  */
 struct dwc3_pci {
        struct platform_device *dwc3;
        struct pci_dev *pci;
 
-       u8 uuid[16];
+       guid_t guid;
 
        unsigned int has_dsm_for_pm:1;
 };
@@ -120,7 +120,7 @@ static int dwc3_pci_quirks(struct dwc3_pci *dwc)
 
                if (pdev->device == PCI_DEVICE_ID_INTEL_BXT ||
                                pdev->device == PCI_DEVICE_ID_INTEL_BXT_M) {
-                       acpi_str_to_uuid(PCI_INTEL_BXT_DSM_UUID, dwc->uuid);
+                       guid_parse(PCI_INTEL_BXT_DSM_GUID, &dwc->guid);
                        dwc->has_dsm_for_pm = true;
                }
 
@@ -292,7 +292,7 @@ static int dwc3_pci_dsm(struct dwc3_pci *dwc, int param)
        tmp.type = ACPI_TYPE_INTEGER;
        tmp.integer.value = param;
 
-       obj = acpi_evaluate_dsm(ACPI_HANDLE(&dwc->pci->dev), dwc->uuid,
+       obj = acpi_evaluate_dsm(ACPI_HANDLE(&dwc->pci->dev), &dwc->guid,
                        1, PCI_INTEL_BXT_FUNC_PMU_PWR, &argv4);
        if (!obj) {
                dev_err(&dwc->pci->dev, "failed to evaluate _DSM\n");
index 1bcf971141c09a69f3cd1674cca282bcc6ec8d46..783e6687bf4a528404523d04330d2655a0a512ce 100644 (file)
@@ -216,13 +216,12 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
 #ifdef CONFIG_ACPI
 static void xhci_pme_acpi_rtd3_enable(struct pci_dev *dev)
 {
-       static const u8 intel_dsm_uuid[] = {
-               0xb7, 0x0c, 0x34, 0xac, 0x01, 0xe9, 0xbf, 0x45,
-               0xb7, 0xe6, 0x2b, 0x34, 0xec, 0x93, 0x1e, 0x23,
-       };
+       static const guid_t intel_dsm_guid =
+               GUID_INIT(0xac340cb7, 0xe901, 0x45bf,
+                         0xb7, 0xe6, 0x2b, 0x34, 0xec, 0x93, 0x1e, 0x23);
        union acpi_object *obj;
 
-       obj = acpi_evaluate_dsm(ACPI_HANDLE(&dev->dev), intel_dsm_uuid, 3, 1,
+       obj = acpi_evaluate_dsm(ACPI_HANDLE(&dev->dev), &intel_dsm_guid, 3, 1,
                                NULL);
        ACPI_FREE(obj);
 }
index 07397bddefa3b76fc0a5e0fbd68ad9d9bb8e8ea8..81251aaa20f92043f7a3ddbf2fe6c8103407a84c 100644 (file)
@@ -55,13 +55,13 @@ struct ucsi {
 
 static int ucsi_acpi_cmd(struct ucsi *ucsi, struct ucsi_control *ctrl)
 {
-       uuid_le uuid = UUID_LE(0x6f8398c2, 0x7ca4, 0x11e4,
-                              0xad, 0x36, 0x63, 0x10, 0x42, 0xb5, 0x00, 0x8f);
+       guid_t guid = GUID_INIT(0x6f8398c2, 0x7ca4, 0x11e4,
+                               0xad, 0x36, 0x63, 0x10, 0x42, 0xb5, 0x00, 0x8f);
        union acpi_object *obj;
 
        ucsi->data->ctrl.raw_cmd = ctrl->raw_cmd;
 
-       obj = acpi_evaluate_dsm(ACPI_HANDLE(ucsi->dev), uuid.b, 1, 1, NULL);
+       obj = acpi_evaluate_dsm(ACPI_HANDLE(ucsi->dev), &guid, 1, 1, NULL);
        if (!obj) {
                dev_err(ucsi->dev, "%s: failed to evaluate _DSM\n", __func__);
                return -EIO;
index d5a7b21fa3f198ef43598d170cd61f7494ac4826..c2ce252890277464538a6139773a4ffb7b9bf65b 100644 (file)
@@ -105,8 +105,8 @@ enum wcove_typec_role {
        WCOVE_ROLE_DEVICE,
 };
 
-static uuid_le uuid = UUID_LE(0x482383f0, 0x2876, 0x4e49,
-                             0x86, 0x85, 0xdb, 0x66, 0x21, 0x1a, 0xf0, 0x37);
+static guid_t guid = GUID_INIT(0x482383f0, 0x2876, 0x4e49,
+                              0x86, 0x85, 0xdb, 0x66, 0x21, 0x1a, 0xf0, 0x37);
 
 static int wcove_typec_func(struct wcove_typec *wcove,
                            enum wcove_typec_func func, int param)
@@ -118,7 +118,7 @@ static int wcove_typec_func(struct wcove_typec *wcove,
        tmp.type = ACPI_TYPE_INTEGER;
        tmp.integer.value = param;
 
-       obj = acpi_evaluate_dsm(ACPI_HANDLE(wcove->dev), uuid.b, 1, func,
+       obj = acpi_evaluate_dsm(ACPI_HANDLE(wcove->dev), &guid, 1, func,
                                &argv4);
        if (!obj) {
                dev_err(wcove->dev, "%s: failed to evaluate _DSM\n", __func__);
@@ -314,7 +314,7 @@ static int wcove_typec_probe(struct platform_device *pdev)
        if (ret)
                return ret;
 
-       if (!acpi_check_dsm(ACPI_HANDLE(&pdev->dev), uuid.b, 0, 0x1f)) {
+       if (!acpi_check_dsm(ACPI_HANDLE(&pdev->dev), &guid, 0, 0x1f)) {
                dev_err(&pdev->dev, "Missing _DSM functions\n");
                return -ENODEV;
        }
index 4ac2ca8a76561952798f7c49bdd292719d0439a8..bf13d1ec51f3bee0c92e9f9c968c21c13bd72173 100644 (file)
@@ -233,12 +233,12 @@ static int tmem_cleancache_init_fs(size_t pagesize)
        return xen_tmem_new_pool(uuid_private, 0, pagesize);
 }
 
-static int tmem_cleancache_init_shared_fs(char *uuid, size_t pagesize)
+static int tmem_cleancache_init_shared_fs(uuid_t *uuid, size_t pagesize)
 {
        struct tmem_pool_uuid shared_uuid;
 
-       shared_uuid.uuid_lo = *(u64 *)uuid;
-       shared_uuid.uuid_hi = *(u64 *)(&uuid[8]);
+       shared_uuid.uuid_lo = *(u64 *)&uuid->b[0];
+       shared_uuid.uuid_hi = *(u64 *)&uuid->b[8];
        return xen_tmem_new_pool(shared_uuid, TMEM_POOL_SHARED, pagesize);
 }
 
index 3062cceb5c2aebcc4a15e3c52d1b26ecea82f20d..782d4d05a53ba332e2115891e343d41612cb1aa0 100644 (file)
@@ -350,7 +350,7 @@ static int afs_deliver_cb_init_call_back_state3(struct afs_call *call)
 {
        struct sockaddr_rxrpc srx;
        struct afs_server *server;
-       struct uuid_v1 *r;
+       struct afs_uuid *r;
        unsigned loop;
        __be32 *b;
        int ret;
@@ -380,7 +380,7 @@ static int afs_deliver_cb_init_call_back_state3(struct afs_call *call)
                }
 
                _debug("unmarshall UUID");
-               call->request = kmalloc(sizeof(struct uuid_v1), GFP_KERNEL);
+               call->request = kmalloc(sizeof(struct afs_uuid), GFP_KERNEL);
                if (!call->request)
                        return -ENOMEM;
 
@@ -453,7 +453,7 @@ static int afs_deliver_cb_probe(struct afs_call *call)
 static void SRXAFSCB_ProbeUuid(struct work_struct *work)
 {
        struct afs_call *call = container_of(work, struct afs_call, work);
-       struct uuid_v1 *r = call->request;
+       struct afs_uuid *r = call->request;
 
        struct {
                __be32  match;
@@ -476,7 +476,7 @@ static void SRXAFSCB_ProbeUuid(struct work_struct *work)
  */
 static int afs_deliver_cb_probe_uuid(struct afs_call *call)
 {
-       struct uuid_v1 *r;
+       struct afs_uuid *r;
        unsigned loop;
        __be32 *b;
        int ret;
@@ -502,15 +502,15 @@ static int afs_deliver_cb_probe_uuid(struct afs_call *call)
                }
 
                _debug("unmarshall UUID");
-               call->request = kmalloc(sizeof(struct uuid_v1), GFP_KERNEL);
+               call->request = kmalloc(sizeof(struct afs_uuid), GFP_KERNEL);
                if (!call->request)
                        return -ENOMEM;
 
                b = call->buffer;
                r = call->request;
-               r->time_low                     = b[0];
-               r->time_mid                     = htons(ntohl(b[1]));
-               r->time_hi_and_version          = htons(ntohl(b[2]));
+               r->time_low                     = ntohl(b[0]);
+               r->time_mid                     = ntohl(b[1]);
+               r->time_hi_and_version          = ntohl(b[2]);
                r->clock_seq_hi_and_reserved    = ntohl(b[3]);
                r->clock_seq_low                = ntohl(b[4]);
 
index 393672997cc23d4e5688dc77421ae81b0df95b48..4e25566066238d896b11108a7621a100a266bb40 100644 (file)
@@ -410,6 +410,15 @@ struct afs_interface {
        unsigned        mtu;            /* MTU of interface */
 };
 
+struct afs_uuid {
+       __be32          time_low;                       /* low part of timestamp */
+       __be16          time_mid;                       /* mid part of timestamp */
+       __be16          time_hi_and_version;            /* high part of timestamp and version  */
+       __u8            clock_seq_hi_and_reserved;      /* clock seq hi and variant */
+       __u8            clock_seq_low;                  /* clock seq low */
+       __u8            node[6];                        /* spatially unique node ID (MAC addr) */
+};
+
 /*****************************************************************************/
 /*
  * cache.c
@@ -544,7 +553,7 @@ extern int afs_drop_inode(struct inode *);
  * main.c
  */
 extern struct workqueue_struct *afs_wq;
-extern struct uuid_v1 afs_uuid;
+extern struct afs_uuid afs_uuid;
 
 /*
  * misc.c
index 51d7d17bca5756b9e4dbbb05408689e2d936a477..9944770849da20613af2c315d3f682f068d5f6c7 100644 (file)
@@ -31,7 +31,7 @@ static char *rootcell;
 module_param(rootcell, charp, 0);
 MODULE_PARM_DESC(rootcell, "root AFS cell name and VL server IP addr list");
 
-struct uuid_v1 afs_uuid;
+struct afs_uuid afs_uuid;
 struct workqueue_struct *afs_wq;
 
 /*
index d37c81f327e790cc4a309fd0a12baef0dc2ff4ac..9006cb5857b802e301fa5923feafb8a3e87db884 100644 (file)
@@ -3950,7 +3950,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
                sb->s_qcop = &ext4_qctl_operations;
        sb->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP | QTYPE_MASK_PRJ;
 #endif
-       memcpy(sb->s_uuid, es->s_uuid, sizeof(es->s_uuid));
+       memcpy(&sb->s_uuid, es->s_uuid, sizeof(es->s_uuid));
 
        INIT_LIST_HEAD(&sbi->s_orphan); /* unlinked but open files */
        mutex_init(&sbi->s_orphan_lock);
index 83355ec4a92cdeb86d4be8d4630e01e7b0c96a28..0b89b0b7b9f75701e3a5f85680761181ce64f3df 100644 (file)
@@ -1937,7 +1937,7 @@ try_onemore:
        sb->s_time_gran = 1;
        sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
                (test_opt(sbi, POSIX_ACL) ? MS_POSIXACL : 0);
-       memcpy(sb->s_uuid, raw_super->uuid, sizeof(raw_super->uuid));
+       memcpy(&sb->s_uuid, raw_super->uuid, sizeof(raw_super->uuid));
 
        /* init f2fs-specific super block info */
        sbi->valid_super_block = valid_super_block;
index ed67548b286ccc58d84732d00af5ca281772bd39..b92135c202c25cc409812d095ac5b7ea4936d5dc 100644 (file)
@@ -203,7 +203,7 @@ static void gfs2_sb_in(struct gfs2_sbd *sdp, const void *buf)
 
        memcpy(sb->sb_lockproto, str->sb_lockproto, GFS2_LOCKNAME_LEN);
        memcpy(sb->sb_locktable, str->sb_locktable, GFS2_LOCKNAME_LEN);
-       memcpy(s->s_uuid, str->sb_uuid, 16);
+       memcpy(&s->s_uuid, str->sb_uuid, 16);
 }
 
 /**
index 7a515345610c28dc4b35e8aa15f4b5061754c060..e77bc52b468f24b407bb19a4783959ce981be163 100644 (file)
@@ -71,25 +71,14 @@ static ssize_t fsname_show(struct gfs2_sbd *sdp, char *buf)
        return snprintf(buf, PAGE_SIZE, "%s\n", sdp->sd_fsname);
 }
 
-static int gfs2_uuid_valid(const u8 *uuid)
-{
-       int i;
-
-       for (i = 0; i < 16; i++) {
-               if (uuid[i])
-                       return 1;
-       }
-       return 0;
-}
-
 static ssize_t uuid_show(struct gfs2_sbd *sdp, char *buf)
 {
        struct super_block *s = sdp->sd_vfs;
-       const u8 *uuid = s->s_uuid;
+
        buf[0] = '\0';
-       if (!gfs2_uuid_valid(uuid))
+       if (uuid_is_null(&s->s_uuid))
                return 0;
-       return snprintf(buf, PAGE_SIZE, "%pUB\n", uuid);
+       return snprintf(buf, PAGE_SIZE, "%pUB\n", &s->s_uuid);
 }
 
 static ssize_t freeze_show(struct gfs2_sbd *sdp, char *buf)
@@ -712,14 +701,13 @@ static int gfs2_uevent(struct kset *kset, struct kobject *kobj,
 {
        struct gfs2_sbd *sdp = container_of(kobj, struct gfs2_sbd, sd_kobj);
        struct super_block *s = sdp->sd_vfs;
-       const u8 *uuid = s->s_uuid;
 
        add_uevent_var(env, "LOCKTABLE=%s", sdp->sd_table_name);
        add_uevent_var(env, "LOCKPROTO=%s", sdp->sd_proto_name);
        if (!test_bit(SDF_NOJOURNALID, &sdp->sd_flags))
                add_uevent_var(env, "JOURNALID=%d", sdp->sd_lockstruct.ls_jid);
-       if (gfs2_uuid_valid(uuid))
-               add_uevent_var(env, "UUID=%pUB", uuid);
+       if (!uuid_is_null(&s->s_uuid))
+               add_uevent_var(env, "UUID=%pUB", &s->s_uuid);
        return 0;
 }
 
index e71f11b1a180c4c0ff0d3ea30d21b568e3c11511..3bc08c394a3f9525620b256466f4222a9133080e 100644 (file)
@@ -486,7 +486,7 @@ secinfo_parse(char **mesg, char *buf, struct svc_export *exp) { return 0; }
 #endif
 
 static inline int
-uuid_parse(char **mesg, char *buf, unsigned char **puuid)
+nfsd_uuid_parse(char **mesg, char *buf, unsigned char **puuid)
 {
        int len;
 
@@ -586,7 +586,7 @@ static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen)
                        if (strcmp(buf, "fsloc") == 0)
                                err = fsloc_parse(&mesg, buf, &exp.ex_fslocs);
                        else if (strcmp(buf, "uuid") == 0)
-                               err = uuid_parse(&mesg, buf, &exp.ex_uuid);
+                               err = nfsd_uuid_parse(&mesg, buf, &exp.ex_uuid);
                        else if (strcmp(buf, "secinfo") == 0)
                                err = secinfo_parse(&mesg, buf, &exp);
                        else
index ca1646fbcaefe7daf0e205620ca3344a4cf2a44a..83005f486451eaaa211614f22247fb885f24d229 100644 (file)
@@ -2062,7 +2062,7 @@ static int ocfs2_initialize_super(struct super_block *sb,
        cbits = le32_to_cpu(di->id2.i_super.s_clustersize_bits);
        bbits = le32_to_cpu(di->id2.i_super.s_blocksize_bits);
        sb->s_maxbytes = ocfs2_max_file_offset(bbits, cbits);
-       memcpy(sb->s_uuid, di->id2.i_super.s_uuid,
+       memcpy(&sb->s_uuid, di->id2.i_super.s_uuid,
               sizeof(di->id2.i_super.s_uuid));
 
        osb->osb_dx_mask = (1 << (cbits - bbits)) - 1;
index 7a44533f4bbf24134a95bdc030bde5779f28457a..33fe6ca929f726adb912814985e534af3e3fa159 100644 (file)
@@ -233,7 +233,7 @@ int ovl_set_attr(struct dentry *upperdentry, struct kstat *stat)
        return err;
 }
 
-static struct ovl_fh *ovl_encode_fh(struct dentry *lower, uuid_be *uuid)
+static struct ovl_fh *ovl_encode_fh(struct dentry *lower, uuid_t *uuid)
 {
        struct ovl_fh *fh;
        int fh_type, fh_len, dwords;
@@ -284,7 +284,6 @@ static int ovl_set_origin(struct dentry *dentry, struct dentry *lower,
                          struct dentry *upper)
 {
        struct super_block *sb = lower->d_sb;
-       uuid_be *uuid = (uuid_be *) &sb->s_uuid;
        const struct ovl_fh *fh = NULL;
        int err;
 
@@ -294,8 +293,8 @@ static int ovl_set_origin(struct dentry *dentry, struct dentry *lower,
         * up and a pure upper inode.
         */
        if (sb->s_export_op && sb->s_export_op->fh_to_dentry &&
-           uuid_be_cmp(*uuid, NULL_UUID_BE)) {
-               fh = ovl_encode_fh(lower, uuid);
+           !uuid_is_null(&sb->s_uuid)) {
+               fh = ovl_encode_fh(lower, &sb->s_uuid);
                if (IS_ERR(fh))
                        return PTR_ERR(fh);
        }
index f3136c31e72af24cbb9949449a12d292fc3bf11b..de0d4f742f36eb67ce84456be47bbef977fe1320 100644 (file)
@@ -135,7 +135,7 @@ static struct dentry *ovl_get_origin(struct dentry *dentry,
         * Make sure that the stored uuid matches the uuid of the lower
         * layer where file handle will be decoded.
         */
-       if (uuid_be_cmp(fh->uuid, *(uuid_be *) &mnt->mnt_sb->s_uuid))
+       if (!uuid_equal(&fh->uuid, &mnt->mnt_sb->s_uuid))
                goto out;
 
        origin = exportfs_decode_fh(mnt, (struct fid *)fh->fid,
index 0623cebeefff8661d49d65a228ceec6290cee877..10863b4105fa21d89f9fdc560a46287f7ffe2f44 100644 (file)
@@ -56,7 +56,7 @@ struct ovl_fh {
        u8 len;         /* size of this header + size of fid */
        u8 flags;       /* OVL_FH_FLAG_* */
        u8 type;        /* fid_type of fid */
-       uuid_be uuid;   /* uuid of filesystem */
+       uuid_t uuid;    /* uuid of filesystem */
        u8 fid[0];      /* file identifier */
 } __packed;
 
index 5c90f82b8f6b88d4f93a3f7f33b3c0e1b8ec4b20..a6e955bfead852d3cd5a42d6a0785d497f8d8e4e 100644 (file)
@@ -98,8 +98,7 @@ xfs-y                         += xfs_aops.o \
                                   xfs_sysfs.o \
                                   xfs_trans.o \
                                   xfs_xattr.o \
-                                  kmem.o \
-                                  uuid.o
+                                  kmem.o
 
 # low-level transaction/log code
 xfs-y                          += xfs_log.o \
diff --git a/fs/xfs/uuid.c b/fs/xfs/uuid.c
deleted file mode 100644 (file)
index b83f76b..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- */
-#include <xfs.h>
-
-/* IRIX interpretation of an uuid_t */
-typedef struct {
-       __be32  uu_timelow;
-       __be16  uu_timemid;
-       __be16  uu_timehi;
-       __be16  uu_clockseq;
-       __be16  uu_node[3];
-} xfs_uu_t;
-
-/*
- * uuid_getnodeuniq - obtain the node unique fields of a UUID.
- *
- * This is not in any way a standard or condoned UUID function;
- * it just something that's needed for user-level file handles.
- */
-void
-uuid_getnodeuniq(uuid_t *uuid, int fsid [2])
-{
-       xfs_uu_t *uup = (xfs_uu_t *)uuid;
-
-       fsid[0] = (be16_to_cpu(uup->uu_clockseq) << 16) |
-                  be16_to_cpu(uup->uu_timemid);
-       fsid[1] = be32_to_cpu(uup->uu_timelow);
-}
-
-int
-uuid_is_nil(uuid_t *uuid)
-{
-       int     i;
-       char    *cp = (char *)uuid;
-
-       if (uuid == NULL)
-               return 0;
-       /* implied check of version number here... */
-       for (i = 0; i < sizeof *uuid; i++)
-               if (*cp++) return 0;    /* not nil */
-       return 1;       /* is nil */
-}
-
-int
-uuid_equal(uuid_t *uuid1, uuid_t *uuid2)
-{
-       return memcmp(uuid1, uuid2, sizeof(uuid_t)) ? 0 : 1;
-}
diff --git a/fs/xfs/uuid.h b/fs/xfs/uuid.h
deleted file mode 100644 (file)
index 104db0f..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- */
-#ifndef __XFS_SUPPORT_UUID_H__
-#define __XFS_SUPPORT_UUID_H__
-
-typedef struct {
-       unsigned char   __u_bits[16];
-} uuid_t;
-
-extern int uuid_is_nil(uuid_t *uuid);
-extern int uuid_equal(uuid_t *uuid1, uuid_t *uuid2);
-extern void uuid_getnodeuniq(uuid_t *uuid, int fsid [2]);
-
-static inline void
-uuid_copy(uuid_t *dst, uuid_t *src)
-{
-       memcpy(dst, src, sizeof(uuid_t));
-}
-
-#endif /* __XFS_SUPPORT_UUID_H__ */
index 08cb7d1a4a3a40ebc5f456c3767d998f433c8ed4..013cc78d7daf46ce69427dd05830be65182d71da 100644 (file)
@@ -834,9 +834,7 @@ xfs_inode_item_format_convert(
                in_f->ilf_dsize = in_f32->ilf_dsize;
                in_f->ilf_ino = in_f32->ilf_ino;
                /* copy biggest field of ilf_u */
-               memcpy(in_f->ilf_u.ilfu_uuid.__u_bits,
-                      in_f32->ilf_u.ilfu_uuid.__u_bits,
-                      sizeof(uuid_t));
+               uuid_copy(&in_f->ilf_u.ilfu_uuid, &in_f32->ilf_u.ilfu_uuid);
                in_f->ilf_blkno = in_f32->ilf_blkno;
                in_f->ilf_len = in_f32->ilf_len;
                in_f->ilf_boffset = in_f32->ilf_boffset;
@@ -851,9 +849,7 @@ xfs_inode_item_format_convert(
                in_f->ilf_dsize = in_f64->ilf_dsize;
                in_f->ilf_ino = in_f64->ilf_ino;
                /* copy biggest field of ilf_u */
-               memcpy(in_f->ilf_u.ilfu_uuid.__u_bits,
-                      in_f64->ilf_u.ilfu_uuid.__u_bits,
-                      sizeof(uuid_t));
+               uuid_copy(&in_f->ilf_u.ilfu_uuid, &in_f64->ilf_u.ilfu_uuid);
                in_f->ilf_blkno = in_f64->ilf_blkno;
                in_f->ilf_len = in_f64->ilf_len;
                in_f->ilf_boffset = in_f64->ilf_boffset;
index 044fb0e15390c7c5538514ec2f49b72fa5942ade..2d167fe643ece8a3a4bf1a9a6c0a83d7751c82fd 100644 (file)
@@ -19,6 +19,7 @@
 #define __XFS_LINUX__
 
 #include <linux/types.h>
+#include <linux/uuid.h>
 
 /*
  * Kernel specific type declarations for XFS
@@ -42,7 +43,6 @@ typedef __u32                 xfs_nlink_t;
 
 #include "kmem.h"
 #include "mrlock.h"
-#include "uuid.h"
 
 #include <linux/semaphore.h>
 #include <linux/mm.h>
index cd0b077deb354b6de5dda287cffaeb351e0e8cce..8cec1e5505a4bf921f953ee285a3c0f2b2e8516e 100644 (file)
@@ -352,13 +352,13 @@ xlog_header_check_mount(
 {
        ASSERT(head->h_magicno == cpu_to_be32(XLOG_HEADER_MAGIC_NUM));
 
-       if (uuid_is_nil(&head->h_fs_uuid)) {
+       if (uuid_is_null(&head->h_fs_uuid)) {
                /*
                 * IRIX doesn't write the h_fs_uuid or h_fmt fields. If
-                * h_fs_uuid is nil, we assume this log was last mounted
+                * h_fs_uuid is null, we assume this log was last mounted
                 * by IRIX and continue.
                 */
-               xfs_warn(mp, "nil uuid in log - IRIX style log");
+               xfs_warn(mp, "null uuid in log - IRIX style log");
        } else if (unlikely(!uuid_equal(&mp->m_sb.sb_uuid, &head->h_fs_uuid))) {
                xfs_warn(mp, "log has mismatched uuid - can't recover");
                xlog_header_check_dump(mp, head);
index 2eaf8185916610ee115ebd98f8869f2df59b5fe9..d249546da15ef0b2e847f8a2a6c354c94d4600b6 100644 (file)
@@ -74,20 +74,19 @@ xfs_uuid_mount(
        int                     hole, i;
 
        /* Publish UUID in struct super_block */
-       BUILD_BUG_ON(sizeof(mp->m_super->s_uuid) != sizeof(uuid_t));
-       memcpy(&mp->m_super->s_uuid, uuid, sizeof(uuid_t));
+       uuid_copy(&mp->m_super->s_uuid, uuid);
 
        if (mp->m_flags & XFS_MOUNT_NOUUID)
                return 0;
 
-       if (uuid_is_nil(uuid)) {
-               xfs_warn(mp, "Filesystem has nil UUID - can't mount");
+       if (uuid_is_null(uuid)) {
+               xfs_warn(mp, "Filesystem has null UUID - can't mount");
                return -EINVAL;
        }
 
        mutex_lock(&xfs_uuid_table_mutex);
        for (i = 0, hole = -1; i < xfs_uuid_table_size; i++) {
-               if (uuid_is_nil(&xfs_uuid_table[i])) {
+               if (uuid_is_null(&xfs_uuid_table[i])) {
                        hole = i;
                        continue;
                }
@@ -124,7 +123,7 @@ xfs_uuid_unmount(
 
        mutex_lock(&xfs_uuid_table_mutex);
        for (i = 0; i < xfs_uuid_table_size; i++) {
-               if (uuid_is_nil(&xfs_uuid_table[i]))
+               if (uuid_is_null(&xfs_uuid_table[i]))
                        continue;
                if (!uuid_equal(uuid, &xfs_uuid_table[i]))
                        continue;
@@ -793,7 +792,10 @@ xfs_mountfs(
         *  Copies the low order bits of the timestamp and the randomly
         *  set "sequence" number out of a UUID.
         */
-       uuid_getnodeuniq(&sbp->sb_uuid, mp->m_fixedfsid);
+       mp->m_fixedfsid[0] =
+               (get_unaligned_be16(&sbp->sb_uuid.b[8]) << 16) |
+                get_unaligned_be16(&sbp->sb_uuid.b[4]);
+       mp->m_fixedfsid[1] = get_unaligned_be32(&sbp->sb_uuid.b[0]);
 
        mp->m_dmevmask = 0;     /* not persistent; set after each mount */
 
index 408c7820e200f99e50d978c342dd67cc55166d0c..c1b163cb68b12d1fa48cdae119596378b7627fdf 100644 (file)
@@ -61,17 +61,18 @@ bool acpi_ata_match(acpi_handle handle);
 bool acpi_bay_match(acpi_handle handle);
 bool acpi_dock_match(acpi_handle handle);
 
-bool acpi_check_dsm(acpi_handle handle, const u8 *uuid, u64 rev, u64 funcs);
-union acpi_object *acpi_evaluate_dsm(acpi_handle handle, const u8 *uuid,
+bool acpi_check_dsm(acpi_handle handle, const guid_t *guid, u64 rev, u64 funcs);
+union acpi_object *acpi_evaluate_dsm(acpi_handle handle, const guid_t *guid,
                        u64 rev, u64 func, union acpi_object *argv4);
 
 static inline union acpi_object *
-acpi_evaluate_dsm_typed(acpi_handle handle, const u8 *uuid, u64 rev, u64 func,
-                       union acpi_object *argv4, acpi_object_type type)
+acpi_evaluate_dsm_typed(acpi_handle handle, const guid_t *guid, u64 rev,
+                       u64 func, union acpi_object *argv4,
+                       acpi_object_type type)
 {
        union acpi_object *obj;
 
-       obj = acpi_evaluate_dsm(handle, uuid, rev, func, argv4);
+       obj = acpi_evaluate_dsm(handle, guid, rev, func, argv4);
        if (obj && obj->type != type) {
                ACPI_FREE(obj);
                obj = NULL;
index 137e4a3d89c5225dc6a9535265f13e874bdbb8eb..cafdfb84ca28e0bb0b7096532f349472523262e2 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/resource_ext.h>
 #include <linux/device.h>
 #include <linux/property.h>
+#include <linux/uuid.h>
 
 #ifndef _LINUX
 #define _LINUX
@@ -457,7 +458,6 @@ struct acpi_osc_context {
        struct acpi_buffer ret;         /* free by caller if success */
 };
 
-acpi_status acpi_str_to_uuid(char *str, u8 *uuid);
 acpi_status acpi_run_osc(acpi_handle handle, struct acpi_osc_context *context);
 
 /* Indexes into _OSC Capabilities Buffer (DWORDs 2 & 3 are device-specific) */
@@ -741,7 +741,7 @@ static inline bool acpi_driver_match_device(struct device *dev,
 }
 
 static inline union acpi_object *acpi_evaluate_dsm(acpi_handle handle,
-                                                  const u8 *uuid,
+                                                  const guid_t *guid,
                                                   int rev, int func,
                                                   union acpi_object *argv4)
 {
index fccf7f44139dd67c2bae6db1799e2517bcd9cd00..bbb3712dd8923feca7e8239cf044ef5ef041d7c0 100644 (file)
@@ -27,7 +27,7 @@ struct cleancache_filekey {
 
 struct cleancache_ops {
        int (*init_fs)(size_t);
-       int (*init_shared_fs)(char *uuid, size_t);
+       int (*init_shared_fs)(uuid_t *uuid, size_t);
        int (*get_page)(int, struct cleancache_filekey,
                        pgoff_t, struct page *);
        void (*put_page)(int, struct cleancache_filekey,
index a5ce0bbeadb5de5a1d28bb085258d6e4ae94abbf..905117bd5012060ecb1b0520f9a729f69ad12cdb 100644 (file)
@@ -883,6 +883,8 @@ static inline bool policy_has_boost_freq(struct cpufreq_policy *policy)
 }
 #endif
 
+extern unsigned int arch_freq_get_on_cpu(int cpu);
+
 /* the following are really really optional */
 extern struct freq_attr cpufreq_freq_attr_scaling_available_freqs;
 extern struct freq_attr cpufreq_freq_attr_scaling_boost_freqs;
index 803e5a9b265422d2c2034678331b6d4dd353d1de..3e68cabb8457e5a9ae5b53bd9d7aa0f844ee99fa 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/percpu-rwsem.h>
 #include <linux/workqueue.h>
 #include <linux/delayed_call.h>
+#include <linux/uuid.h>
 
 #include <asm/byteorder.h>
 #include <uapi/linux/fs.h>
@@ -1328,8 +1329,8 @@ struct super_block {
 
        struct sb_writers       s_writers;
 
-       char s_id[32];                          /* Informational name */
-       u8 s_uuid[16];                          /* UUID */
+       char                    s_id[32];       /* Informational name */
+       uuid_t                  s_uuid;         /* UUID */
 
        void                    *s_fs_info;     /* Filesystem private info */
        unsigned int            s_max_links;
index acff9437e5c3776e48a9357af40291165719416d..e619fae2f0375e073e5f3216fd764676ae1340b8 100644 (file)
@@ -219,12 +219,6 @@ static inline struct gendisk *part_to_disk(struct hd_struct *part)
        return NULL;
 }
 
-static inline int blk_part_pack_uuid(const u8 *uuid_str, u8 *to)
-{
-       uuid_be_to_bin(uuid_str, (uuid_be *)to);
-       return 0;
-}
-
 static inline int disk_max_parts(struct gendisk *disk)
 {
        if (disk->flags & GENHD_FL_EXT_DEVT)
@@ -736,11 +730,6 @@ static inline dev_t blk_lookup_devt(const char *name, int partno)
        dev_t devt = MKDEV(0, 0);
        return devt;
 }
-
-static inline int blk_part_pack_uuid(const u8 *uuid_str, u8 *to)
-{
-       return -EINVAL;
-}
 #endif /* CONFIG_BLOCK */
 
 #endif /* _LINUX_GENHD_H */
index e997c4a49a8884e3b1167a830e7fdf0431365a3d..bc711a10be05c2d8354a9ba2eff382bc992314b1 100644 (file)
@@ -177,7 +177,6 @@ struct fcnvme_lsdesc_rjt {
 };
 
 
-#define FCNVME_ASSOC_HOSTID_LEN                16
 #define FCNVME_ASSOC_HOSTNQN_LEN       256
 #define FCNVME_ASSOC_SUBNQN_LEN                256
 
@@ -191,7 +190,7 @@ struct fcnvme_lsdesc_cr_assoc_cmd {
        __be16  cntlid;
        __be16  sqsize;
        __be32  rsvd52;
-       u8      hostid[FCNVME_ASSOC_HOSTID_LEN];
+       uuid_t  hostid;
        u8      hostnqn[FCNVME_ASSOC_HOSTNQN_LEN];
        u8      subnqn[FCNVME_ASSOC_SUBNQN_LEN];
        u8      rsvd632[384];
index b625bacf37efaabd84e8735b2b304401cdb195fd..e400a69fa1d324acf3a2bce7ba25d6c24054b449 100644 (file)
@@ -16,6 +16,7 @@
 #define _LINUX_NVME_H
 
 #include <linux/types.h>
+#include <linux/uuid.h>
 
 /* NQN names in commands fields specified one size */
 #define NVMF_NQN_FIELD_LEN     256
@@ -843,7 +844,7 @@ struct nvmf_connect_command {
 };
 
 struct nvmf_connect_data {
-       __u8            hostid[16];
+       uuid_t          hostid;
        __le16          cntlid;
        char            resv4[238];
        char            subsysnqn[NVMF_NQN_FIELD_LEN];
index 7a4e83a8c89ca8d960c75b6002aeff547fa2890e..dd86c97f2454b25746552c26e0e985363c18d352 100644 (file)
@@ -105,7 +105,7 @@ static inline void acpiphp_remove_slots(struct pci_bus *bus) { }
 static inline void acpiphp_check_host_bridge(struct acpi_device *adev) { }
 #endif
 
-extern const u8 pci_acpi_dsm_uuid[];
+extern const guid_t pci_acpi_dsm_guid;
 #define DEVICE_LABEL_DSM       0x07
 #define RESET_DELAY_DSM                0x08
 #define FUNCTION_DELAY_DSM     0x09
index a6685b3dde269f9c60eccaf9f20fd2ff3ab4876e..51ec727b48249db35c72c8652117fcddcc8feea8 100644 (file)
@@ -121,6 +121,8 @@ struct opp_table *dev_pm_opp_set_prop_name(struct device *dev, const char *name)
 void dev_pm_opp_put_prop_name(struct opp_table *opp_table);
 struct opp_table *dev_pm_opp_set_regulators(struct device *dev, const char * const names[], unsigned int count);
 void dev_pm_opp_put_regulators(struct opp_table *opp_table);
+struct opp_table *dev_pm_opp_set_clkname(struct device *dev, const char * name);
+void dev_pm_opp_put_clkname(struct opp_table *opp_table);
 struct opp_table *dev_pm_opp_register_set_opp_helper(struct device *dev, int (*set_opp)(struct dev_pm_set_opp_data *data));
 void dev_pm_opp_register_put_opp_helper(struct opp_table *opp_table);
 int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq);
@@ -257,6 +259,13 @@ static inline struct opp_table *dev_pm_opp_set_regulators(struct device *dev, co
 
 static inline void dev_pm_opp_put_regulators(struct opp_table *opp_table) {}
 
+static inline struct opp_table *dev_pm_opp_set_clkname(struct device *dev, const char * name)
+{
+       return ERR_PTR(-ENOTSUPP);
+}
+
+static inline void dev_pm_opp_put_clkname(struct opp_table *opp_table) {}
+
 static inline int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq)
 {
        return -ENOTSUPP;
index 4dff73a8975836dab9e49ce57ddcb1d6a2e79782..75f7182d5360bf5b58688ea349b54c218679ff58 100644 (file)
 
 #include <uapi/linux/uuid.h>
 
-/*
- * V1 (time-based) UUID definition [RFC 4122].
- * - the timestamp is a 60-bit value, split 32/16/12, and goes in 100ns
- *   increments since midnight 15th October 1582
- *   - add AFS_UUID_TO_UNIX_TIME to convert unix time in 100ns units to UUID
- *     time
- * - the clock sequence is a 14-bit counter to avoid duplicate times
- */
-struct uuid_v1 {
-       __be32          time_low;                       /* low part of timestamp */
-       __be16          time_mid;                       /* mid part of timestamp */
-       __be16          time_hi_and_version;            /* high part of timestamp and version  */
-#define UUID_TO_UNIX_TIME      0x01b21dd213814000ULL
-#define UUID_TIMEHI_MASK       0x0fff
-#define UUID_VERSION_TIME      0x1000  /* time-based UUID */
-#define UUID_VERSION_NAME      0x3000  /* name-based UUID */
-#define UUID_VERSION_RANDOM    0x4000  /* (pseudo-)random generated UUID */
-       u8              clock_seq_hi_and_reserved;      /* clock seq hi and variant */
-#define UUID_CLOCKHI_MASK      0x3f
-#define UUID_VARIANT_STD       0x80
-       u8              clock_seq_low;                  /* clock seq low */
-       u8              node[6];                        /* spatially unique node ID (MAC addr) */
-};
+typedef struct {
+       __u8 b[16];
+} uuid_t;
+
+#define UUID_INIT(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7)                     \
+((uuid_t)                                                              \
+{{ ((a) >> 24) & 0xff, ((a) >> 16) & 0xff, ((a) >> 8) & 0xff, (a) & 0xff, \
+   ((b) >> 8) & 0xff, (b) & 0xff,                                      \
+   ((c) >> 8) & 0xff, (c) & 0xff,                                      \
+   (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) }})
 
 /*
  * The length of a UUID string ("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee")
@@ -48,27 +35,73 @@ struct uuid_v1 {
  */
 #define        UUID_STRING_LEN         36
 
-static inline int uuid_le_cmp(const uuid_le u1, const uuid_le u2)
+extern const guid_t guid_null;
+extern const uuid_t uuid_null;
+
+static inline bool guid_equal(const guid_t *u1, const guid_t *u2)
+{
+       return memcmp(u1, u2, sizeof(guid_t)) == 0;
+}
+
+static inline void guid_copy(guid_t *dst, const guid_t *src)
+{
+       memcpy(dst, src, sizeof(guid_t));
+}
+
+static inline bool guid_is_null(guid_t *guid)
+{
+       return guid_equal(guid, &guid_null);
+}
+
+static inline bool uuid_equal(const uuid_t *u1, const uuid_t *u2)
+{
+       return memcmp(u1, u2, sizeof(uuid_t)) == 0;
+}
+
+static inline void uuid_copy(uuid_t *dst, const uuid_t *src)
 {
-       return memcmp(&u1, &u2, sizeof(uuid_le));
+       memcpy(dst, src, sizeof(uuid_t));
 }
 
-static inline int uuid_be_cmp(const uuid_be u1, const uuid_be u2)
+static inline bool uuid_is_null(uuid_t *uuid)
 {
-       return memcmp(&u1, &u2, sizeof(uuid_be));
+       return uuid_equal(uuid, &uuid_null);
 }
 
 void generate_random_uuid(unsigned char uuid[16]);
 
-extern void uuid_le_gen(uuid_le *u);
-extern void uuid_be_gen(uuid_be *u);
+extern void guid_gen(guid_t *u);
+extern void uuid_gen(uuid_t *u);
 
 bool __must_check uuid_is_valid(const char *uuid);
 
-extern const u8 uuid_le_index[16];
-extern const u8 uuid_be_index[16];
+extern const u8 guid_index[16];
+extern const u8 uuid_index[16];
+
+int guid_parse(const char *uuid, guid_t *u);
+int uuid_parse(const char *uuid, uuid_t *u);
+
+/* backwards compatibility, don't use in new code */
+typedef uuid_t uuid_be;
+#define UUID_BE(a, _b, c, d0, d1, d2, d3, d4, d5, d6, d7) \
+       UUID_INIT(a, _b, c, d0, d1, d2, d3, d4, d5, d6, d7)
+#define NULL_UUID_BE                                                   \
+       UUID_BE(0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00,     \
+            0x00, 0x00, 0x00, 0x00)
 
-int uuid_le_to_bin(const char *uuid, uuid_le *u);
-int uuid_be_to_bin(const char *uuid, uuid_be *u);
+#define uuid_le_gen(u)         guid_gen(u)
+#define uuid_be_gen(u)         uuid_gen(u)
+#define uuid_le_to_bin(guid, u)        guid_parse(guid, u)
+#define uuid_be_to_bin(uuid, u)        uuid_parse(uuid, u)
+
+static inline int uuid_le_cmp(const guid_t u1, const guid_t u2)
+{
+       return memcmp(&u1, &u2, sizeof(guid_t));
+}
+
+static inline int uuid_be_cmp(const uuid_t u1, const uuid_t u2)
+{
+       return memcmp(&u1, &u2, sizeof(uuid_t));
+}
 
 #endif
index 3738e5fb6a4de8c3e06946a3798d4d30f21ca82c..8ef82f433877a53fe1d4fd7cc3f3cd4e27e1a062 100644 (file)
 
 typedef struct {
        __u8 b[16];
-} uuid_le;
+} guid_t;
 
-typedef struct {
-       __u8 b[16];
-} uuid_be;
-
-#define UUID_LE(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7)               \
-((uuid_le)                                                             \
+#define GUID_INIT(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7)                     \
+((guid_t)                                                              \
 {{ (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, ((a) >> 24) & 0xff, \
    (b) & 0xff, ((b) >> 8) & 0xff,                                      \
    (c) & 0xff, ((c) >> 8) & 0xff,                                      \
    (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) }})
 
-#define UUID_BE(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7)               \
-((uuid_be)                                                             \
-{{ ((a) >> 24) & 0xff, ((a) >> 16) & 0xff, ((a) >> 8) & 0xff, (a) & 0xff, \
-   ((b) >> 8) & 0xff, (b) & 0xff,                                      \
-   ((c) >> 8) & 0xff, (c) & 0xff,                                      \
-   (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) }})
-
+/* backwards compatibility, don't use in new code */
+typedef guid_t uuid_le;
+#define UUID_LE(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7)               \
+       GUID_INIT(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7)
 #define NULL_UUID_LE                                                   \
        UUID_LE(0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00,     \
-               0x00, 0x00, 0x00, 0x00)
-
-#define NULL_UUID_BE                                                   \
-       UUID_BE(0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00,     \
-               0x00, 0x00, 0x00, 0x00)
-
+            0x00, 0x00, 0x00, 0x00)
 
 #endif /* _UAPI_LINUX_UUID_H_ */
index a8b978c35a6a9392c3d4721e12f68c9794ac620b..e1914c7b85b180e7683eed48738e14443dbadc62 100644 (file)
@@ -1108,7 +1108,7 @@ static struct attribute * g[] = {
 };
 
 
-static struct attribute_group attr_group = {
+static const struct attribute_group attr_group = {
        .attrs = g,
 };
 
index fa46606f33565613d2ef13a1e948f2bae0dfaa8b..b7708e319941baed24eb447e12d58750ade3cd4a 100644 (file)
 #include <asm/pgtable.h>
 #include <asm/tlbflush.h>
 #include <asm/io.h>
-#ifdef CONFIG_STRICT_KERNEL_RWX
+#ifdef CONFIG_ARCH_HAS_SET_MEMORY
 #include <asm/set_memory.h>
 #endif
 
 #include "power.h"
 
-#ifdef CONFIG_STRICT_KERNEL_RWX
+#if defined(CONFIG_STRICT_KERNEL_RWX) && defined(CONFIG_ARCH_HAS_SET_MEMORY)
 static bool hibernate_restore_protection;
 static bool hibernate_restore_protection_active;
 
@@ -77,7 +77,7 @@ static inline void hibernate_restore_protection_begin(void) {}
 static inline void hibernate_restore_protection_end(void) {}
 static inline void hibernate_restore_protect_page(void *page_address) {}
 static inline void hibernate_restore_unprotect_page(void *page_address) {}
-#endif /* CONFIG_STRICT_KERNEL_RWX */
+#endif /* CONFIG_STRICT_KERNEL_RWX  && CONFIG_ARCH_HAS_SET_MEMORY */
 
 static int swsusp_page_is_free(struct page *);
 static void swsusp_set_page_forbidden(struct page *);
@@ -1929,8 +1929,7 @@ static inline unsigned int alloc_highmem_pages(struct memory_bitmap *bm,
  * also be located in the high memory, because of the way in which
  * copy_data_pages() works.
  */
-static int swsusp_alloc(struct memory_bitmap *orig_bm,
-                       struct memory_bitmap *copy_bm,
+static int swsusp_alloc(struct memory_bitmap *copy_bm,
                        unsigned int nr_pages, unsigned int nr_highmem)
 {
        if (nr_highmem > 0) {
@@ -1976,7 +1975,7 @@ asmlinkage __visible int swsusp_save(void)
                return -ENOMEM;
        }
 
-       if (swsusp_alloc(&orig_bm, &copy_bm, nr_pages, nr_highmem)) {
+       if (swsusp_alloc(&copy_bm, nr_pages, nr_highmem)) {
                printk(KERN_ERR "PM: Memory allocation failed\n");
                return -ENOMEM;
        }
index ece4b177052baa8a2ba9a5aded7f9694594eb4e5..939a158eab11d2b2cca4f8412f0423449f964efd 100644 (file)
@@ -1119,7 +1119,7 @@ static ssize_t bin_uuid(struct file *file,
        /* Only supports reads */
        if (oldval && oldlen) {
                char buf[UUID_STRING_LEN + 1];
-               uuid_be uuid;
+               uuid_t uuid;
 
                result = kernel_read(file, 0, buf, sizeof(buf) - 1);
                if (result < 0)
@@ -1128,7 +1128,7 @@ static ssize_t bin_uuid(struct file *file,
                buf[result] = '\0';
 
                result = -EIO;
-               if (uuid_be_to_bin(buf, &uuid))
+               if (uuid_parse(buf, &uuid))
                        goto out;
 
                if (oldlen > 16)
index 547d3127a3cf06f98514e7e8f9ed9e3198c81663..478c049630b5cb8e09a57c5ccd012d51b5c4be97 100644 (file)
 
 struct test_uuid_data {
        const char *uuid;
-       uuid_le le;
-       uuid_be be;
+       guid_t le;
+       uuid_t be;
 };
 
 static const struct test_uuid_data test_uuid_test_data[] = {
        {
                .uuid = "c33f4995-3701-450e-9fbf-206a2e98e576",
-               .le = UUID_LE(0xc33f4995, 0x3701, 0x450e, 0x9f, 0xbf, 0x20, 0x6a, 0x2e, 0x98, 0xe5, 0x76),
-               .be = UUID_BE(0xc33f4995, 0x3701, 0x450e, 0x9f, 0xbf, 0x20, 0x6a, 0x2e, 0x98, 0xe5, 0x76),
+               .le = GUID_INIT(0xc33f4995, 0x3701, 0x450e, 0x9f, 0xbf, 0x20, 0x6a, 0x2e, 0x98, 0xe5, 0x76),
+               .be = UUID_INIT(0xc33f4995, 0x3701, 0x450e, 0x9f, 0xbf, 0x20, 0x6a, 0x2e, 0x98, 0xe5, 0x76),
        },
        {
                .uuid = "64b4371c-77c1-48f9-8221-29f054fc023b",
-               .le = UUID_LE(0x64b4371c, 0x77c1, 0x48f9, 0x82, 0x21, 0x29, 0xf0, 0x54, 0xfc, 0x02, 0x3b),
-               .be = UUID_BE(0x64b4371c, 0x77c1, 0x48f9, 0x82, 0x21, 0x29, 0xf0, 0x54, 0xfc, 0x02, 0x3b),
+               .le = GUID_INIT(0x64b4371c, 0x77c1, 0x48f9, 0x82, 0x21, 0x29, 0xf0, 0x54, 0xfc, 0x02, 0x3b),
+               .be = UUID_INIT(0x64b4371c, 0x77c1, 0x48f9, 0x82, 0x21, 0x29, 0xf0, 0x54, 0xfc, 0x02, 0x3b),
        },
        {
                .uuid = "0cb4ddff-a545-4401-9d06-688af53e7f84",
-               .le = UUID_LE(0x0cb4ddff, 0xa545, 0x4401, 0x9d, 0x06, 0x68, 0x8a, 0xf5, 0x3e, 0x7f, 0x84),
-               .be = UUID_BE(0x0cb4ddff, 0xa545, 0x4401, 0x9d, 0x06, 0x68, 0x8a, 0xf5, 0x3e, 0x7f, 0x84),
+               .le = GUID_INIT(0x0cb4ddff, 0xa545, 0x4401, 0x9d, 0x06, 0x68, 0x8a, 0xf5, 0x3e, 0x7f, 0x84),
+               .be = UUID_INIT(0x0cb4ddff, 0xa545, 0x4401, 0x9d, 0x06, 0x68, 0x8a, 0xf5, 0x3e, 0x7f, 0x84),
        },
 };
 
@@ -61,28 +61,28 @@ static void __init test_uuid_failed(const char *prefix, bool wrong, bool be,
 
 static void __init test_uuid_test(const struct test_uuid_data *data)
 {
-       uuid_le le;
-       uuid_be be;
+       guid_t le;
+       uuid_t be;
        char buf[48];
 
        /* LE */
        total_tests++;
-       if (uuid_le_to_bin(data->uuid, &le))
+       if (guid_parse(data->uuid, &le))
                test_uuid_failed("conversion", false, false, data->uuid, NULL);
 
        total_tests++;
-       if (uuid_le_cmp(data->le, le)) {
+       if (!guid_equal(&data->le, &le)) {
                sprintf(buf, "%pUl", &le);
                test_uuid_failed("cmp", false, false, data->uuid, buf);
        }
 
        /* BE */
        total_tests++;
-       if (uuid_be_to_bin(data->uuid, &be))
+       if (uuid_parse(data->uuid, &be))
                test_uuid_failed("conversion", false, true, data->uuid, NULL);
 
        total_tests++;
-       if (uuid_be_cmp(data->be, be)) {
+       if (uuid_equal(&data->be, &be)) {
                sprintf(buf, "%pUb", &be);
                test_uuid_failed("cmp", false, true, data->uuid, buf);
        }
@@ -90,17 +90,17 @@ static void __init test_uuid_test(const struct test_uuid_data *data)
 
 static void __init test_uuid_wrong(const char *data)
 {
-       uuid_le le;
-       uuid_be be;
+       guid_t le;
+       uuid_t be;
 
        /* LE */
        total_tests++;
-       if (!uuid_le_to_bin(data, &le))
+       if (!guid_parse(data, &le))
                test_uuid_failed("negative", true, false, data, NULL);
 
        /* BE */
        total_tests++;
-       if (!uuid_be_to_bin(data, &be))
+       if (!uuid_parse(data, &be))
                test_uuid_failed("negative", true, true, data, NULL);
 }
 
index 37687af77ff847aeb47f88c8ea5d9b6cda8ac5b3..680b9fb9ba098243a2b51f81fa65c20d7ae69bd8 100644 (file)
 #include <linux/uuid.h>
 #include <linux/random.h>
 
-const u8 uuid_le_index[16] = {3,2,1,0,5,4,7,6,8,9,10,11,12,13,14,15};
-EXPORT_SYMBOL(uuid_le_index);
-const u8 uuid_be_index[16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
-EXPORT_SYMBOL(uuid_be_index);
+const guid_t guid_null;
+EXPORT_SYMBOL(guid_null);
+const uuid_t uuid_null;
+EXPORT_SYMBOL(uuid_null);
+
+const u8 guid_index[16] = {3,2,1,0,5,4,7,6,8,9,10,11,12,13,14,15};
+const u8 uuid_index[16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
 
 /***************************************************************
  * Random UUID interface
@@ -53,21 +56,21 @@ static void __uuid_gen_common(__u8 b[16])
        b[8] = (b[8] & 0x3F) | 0x80;
 }
 
-void uuid_le_gen(uuid_le *lu)
+void guid_gen(guid_t *lu)
 {
        __uuid_gen_common(lu->b);
        /* version 4 : random generation */
        lu->b[7] = (lu->b[7] & 0x0F) | 0x40;
 }
-EXPORT_SYMBOL_GPL(uuid_le_gen);
+EXPORT_SYMBOL_GPL(guid_gen);
 
-void uuid_be_gen(uuid_be *bu)
+void uuid_gen(uuid_t *bu)
 {
        __uuid_gen_common(bu->b);
        /* version 4 : random generation */
        bu->b[6] = (bu->b[6] & 0x0F) | 0x40;
 }
-EXPORT_SYMBOL_GPL(uuid_be_gen);
+EXPORT_SYMBOL_GPL(uuid_gen);
 
 /**
   * uuid_is_valid - checks if UUID string valid
@@ -97,7 +100,7 @@ bool uuid_is_valid(const char *uuid)
 }
 EXPORT_SYMBOL(uuid_is_valid);
 
-static int __uuid_to_bin(const char *uuid, __u8 b[16], const u8 ei[16])
+static int __uuid_parse(const char *uuid, __u8 b[16], const u8 ei[16])
 {
        static const u8 si[16] = {0,2,4,6,9,11,14,16,19,21,24,26,28,30,32,34};
        unsigned int i;
@@ -115,14 +118,14 @@ static int __uuid_to_bin(const char *uuid, __u8 b[16], const u8 ei[16])
        return 0;
 }
 
-int uuid_le_to_bin(const char *uuid, uuid_le *u)
+int guid_parse(const char *uuid, guid_t *u)
 {
-       return __uuid_to_bin(uuid, u->b, uuid_le_index);
+       return __uuid_parse(uuid, u->b, guid_index);
 }
-EXPORT_SYMBOL(uuid_le_to_bin);
+EXPORT_SYMBOL(guid_parse);
 
-int uuid_be_to_bin(const char *uuid, uuid_be *u)
+int uuid_parse(const char *uuid, uuid_t *u)
 {
-       return __uuid_to_bin(uuid, u->b, uuid_be_index);
+       return __uuid_parse(uuid, u->b, uuid_index);
 }
-EXPORT_SYMBOL(uuid_be_to_bin);
+EXPORT_SYMBOL(uuid_parse);
index 2d41de3f98a1c9a0e0883b3d73b6980b0110cff1..9f37d6208e99fdcfa768319772935b92124dd9e0 100644 (file)
@@ -1308,14 +1308,14 @@ char *uuid_string(char *buf, char *end, const u8 *addr,
        char uuid[UUID_STRING_LEN + 1];
        char *p = uuid;
        int i;
-       const u8 *index = uuid_be_index;
+       const u8 *index = uuid_index;
        bool uc = false;
 
        switch (*(++fmt)) {
        case 'L':
                uc = true;              /* fall-through */
        case 'l':
-               index = uuid_le_index;
+               index = guid_index;
                break;
        case 'B':
                uc = true;
index ba5d8f3e6d68a3769589c372adc3183b4addfb40..f7b9fdc79d97c15cc6790566469b6614c686aa90 100644 (file)
@@ -130,7 +130,7 @@ void __cleancache_init_shared_fs(struct super_block *sb)
        int pool_id = CLEANCACHE_NO_BACKEND_SHARED;
 
        if (cleancache_ops) {
-               pool_id = cleancache_ops->init_shared_fs(sb->s_uuid, PAGE_SIZE);
+               pool_id = cleancache_ops->init_shared_fs(&sb->s_uuid, PAGE_SIZE);
                if (pool_id < 0)
                        pool_id = CLEANCACHE_NO_POOL;
        }
index e67d6ba4e98e73210c8046e82612180fca220e89..391f2dcca72782051cf2dfc5b71b7af11c73f2c9 100644 (file)
@@ -75,6 +75,7 @@ static struct vfsmount *shm_mnt;
 #include <uapi/linux/memfd.h>
 #include <linux/userfaultfd_k.h>
 #include <linux/rmap.h>
+#include <linux/uuid.h>
 
 #include <linux/uaccess.h>
 #include <asm/pgtable.h>
@@ -3761,6 +3762,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
 #ifdef CONFIG_TMPFS_POSIX_ACL
        sb->s_flags |= MS_POSIXACL;
 #endif
+       uuid_gen(&sb->s_uuid);
 
        inode = shmem_get_inode(sb, NULL, S_IFDIR | sbinfo->mode, 0, VM_NORESERVE);
        if (!inode)
index d7f282d75cc16efa1d21274e42145280a2f69468..1d32cd20009a3bd35cf77bc11027354c00eb8812 100644 (file)
@@ -164,7 +164,7 @@ static void hmac_add_misc(struct shash_desc *desc, struct inode *inode,
        hmac_misc.mode = inode->i_mode;
        crypto_shash_update(desc, (const u8 *)&hmac_misc, sizeof(hmac_misc));
        if (evm_hmac_attrs & EVM_ATTR_FSUUID)
-               crypto_shash_update(desc, inode->i_sb->s_uuid,
+               crypto_shash_update(desc, &inode->i_sb->s_uuid.b[0],
                                    sizeof(inode->i_sb->s_uuid));
        crypto_shash_final(desc, digest);
 }
index 3ab1067db624d860f9303a5e3ea8587ebbed699b..6f885fab9d84a1476eacaf5d1905b4546d964fd6 100644 (file)
@@ -61,7 +61,7 @@ struct ima_rule_entry {
        enum ima_hooks func;
        int mask;
        unsigned long fsmagic;
-       u8 fsuuid[16];
+       uuid_t fsuuid;
        kuid_t uid;
        kuid_t fowner;
        bool (*uid_op)(kuid_t, kuid_t);    /* Handlers for operators       */
@@ -244,7 +244,7 @@ static bool ima_match_rules(struct ima_rule_entry *rule, struct inode *inode,
            && rule->fsmagic != inode->i_sb->s_magic)
                return false;
        if ((rule->flags & IMA_FSUUID) &&
-           memcmp(rule->fsuuid, inode->i_sb->s_uuid, sizeof(rule->fsuuid)))
+           !uuid_equal(&rule->fsuuid, &inode->i_sb->s_uuid))
                return false;
        if ((rule->flags & IMA_UID) && !rule->uid_op(cred->uid, rule->uid))
                return false;
@@ -711,14 +711,12 @@ static int ima_parse_rule(char *rule, struct ima_rule_entry *entry)
                case Opt_fsuuid:
                        ima_log_string(ab, "fsuuid", args[0].from);
 
-                       if (memchr_inv(entry->fsuuid, 0x00,
-                                      sizeof(entry->fsuuid))) {
+                       if (uuid_is_null(&entry->fsuuid)) {
                                result = -EINVAL;
                                break;
                        }
 
-                       result = blk_part_pack_uuid(args[0].from,
-                                                   entry->fsuuid);
+                       result = uuid_parse(args[0].from, &entry->fsuuid);
                        if (!result)
                                entry->flags |= IMA_FSUUID;
                        break;
@@ -1087,7 +1085,7 @@ int ima_policy_show(struct seq_file *m, void *v)
        }
 
        if (entry->flags & IMA_FSUUID) {
-               seq_printf(m, "fsuuid=%pU", entry->fsuuid);
+               seq_printf(m, "fsuuid=%pU", &entry->fsuuid);
                seq_puts(m, " ");
        }
 
index e3f06672fd6df3268be67eb5790edcf91fa27585..e7d766d56c8e7dc60d12b39172f63c3a54f27b49 100644 (file)
@@ -21,8 +21,9 @@
 #include "skl.h"
 
 /* Unique identification for getting NHLT blobs */
-static u8 OSC_UUID[16] = {0x6E, 0x88, 0x9F, 0xA6, 0xEB, 0x6C, 0x94, 0x45,
-                               0xA4, 0x1F, 0x7B, 0x5D, 0xCE, 0x24, 0xC5, 0x53};
+static guid_t osc_guid =
+       GUID_INIT(0xA69F886E, 0x6CEB, 0x4594,
+                 0xA4, 0x1F, 0x7B, 0x5D, 0xCE, 0x24, 0xC5, 0x53);
 
 struct nhlt_acpi_table *skl_nhlt_init(struct device *dev)
 {
@@ -37,7 +38,7 @@ struct nhlt_acpi_table *skl_nhlt_init(struct device *dev)
                return NULL;
        }
 
-       obj = acpi_evaluate_dsm(handle, OSC_UUID, 1, 1, NULL);
+       obj = acpi_evaluate_dsm(handle, &osc_guid, 1, 1, NULL);
        if (obj && obj->type == ACPI_TYPE_BUFFER) {
                nhlt_ptr = (struct nhlt_resource_desc  *)obj->buffer.pointer;
                nhlt_table = (struct nhlt_acpi_table *)
index 6437ef39aeea61fe592d11d5a022730a8b46a6dd..5fd5c5b8c7b8c1fc29597490abc827898f2fcb77 100644 (file)
@@ -26,6 +26,15 @@ union msr_pstate {
                unsigned res3:21;
                unsigned en:1;
        } bits;
+       struct {
+               unsigned fid:8;
+               unsigned did:6;
+               unsigned vid:8;
+               unsigned iddval:8;
+               unsigned idddiv:2;
+               unsigned res1:30;
+               unsigned en:1;
+       } fam17h_bits;
        unsigned long long val;
 };
 
@@ -35,6 +44,8 @@ static int get_did(int family, union msr_pstate pstate)
 
        if (family == 0x12)
                t = pstate.val & 0xf;
+       else if (family == 0x17)
+               t = pstate.fam17h_bits.did;
        else
                t = pstate.bits.did;
 
@@ -44,16 +55,20 @@ static int get_did(int family, union msr_pstate pstate)
 static int get_cof(int family, union msr_pstate pstate)
 {
        int t;
-       int fid, did;
+       int fid, did, cof;
 
        did = get_did(family, pstate);
-
-       t = 0x10;
-       fid = pstate.bits.fid;
-       if (family == 0x11)
-               t = 0x8;
-
-       return (100 * (fid + t)) >> did;
+       if (family == 0x17) {
+               fid = pstate.fam17h_bits.fid;
+               cof = 200 * fid / did;
+       } else {
+               t = 0x10;
+               fid = pstate.bits.fid;
+               if (family == 0x11)
+                       t = 0x8;
+               cof = (100 * (fid + t)) >> did;
+       }
+       return cof;
 }
 
 /* Needs:
index afb66f80554ecda25e139ddacb74d3a6443e8322..799a18be60aa4628b2dbaa47e8484a802769b558 100644 (file)
@@ -70,6 +70,8 @@ enum cpupower_cpu_vendor {X86_VENDOR_UNKNOWN = 0, X86_VENDOR_INTEL,
 #define CPUPOWER_CAP_IS_SNB            0x00000020
 #define CPUPOWER_CAP_INTEL_IDA         0x00000040
 
+#define CPUPOWER_AMD_CPBDIS            0x02000000
+
 #define MAX_HW_PSTATES 10
 
 struct cpupower_cpu_info {
index 1609243f5c64d16cb19f04fb1805b855c5c9fc57..601d719d4e60dfba6f4d104edbf4568691143cd5 100644 (file)
@@ -2,11 +2,14 @@
 
 #include "helpers/helpers.h"
 
+#define MSR_AMD_HWCR   0xc0010015
+
 int cpufreq_has_boost_support(unsigned int cpu, int *support, int *active,
                        int *states)
 {
        struct cpupower_cpu_info cpu_info;
        int ret;
+       unsigned long long val;
 
        *support = *active = *states = 0;
 
@@ -16,10 +19,22 @@ int cpufreq_has_boost_support(unsigned int cpu, int *support, int *active,
 
        if (cpupower_cpu_info.caps & CPUPOWER_CAP_AMD_CBP) {
                *support = 1;
-               amd_pci_get_num_boost_states(active, states);
-               if (ret <= 0)
-                       return ret;
-               *support = 1;
+
+               /* AMD Family 0x17 does not utilize PCI D18F4 like prior
+                * families and has no fixed discrete boost states but
+                * has Hardware determined variable increments instead.
+                */
+
+               if (cpu_info.family == 0x17) {
+                       if (!read_msr(cpu, MSR_AMD_HWCR, &val)) {
+                               if (!(val & CPUPOWER_AMD_CPBDIS))
+                                       *active = 1;
+                       }
+               } else {
+                       ret = amd_pci_get_num_boost_states(active, states);
+                       if (ret)
+                               return ret;
+               }
        } else if (cpupower_cpu_info.caps & CPUPOWER_CAP_INTEL_IDA)
                *support = *active = 1;
        return 0;
index b11294730771bed6766f77138460813f8abbfce8..0dafba2c1e7d28c4eda6904274baf7537ee3062c 100644 (file)
@@ -57,7 +57,6 @@ unsigned int list_header_only;
 unsigned int dump_only;
 unsigned int do_snb_cstates;
 unsigned int do_knl_cstates;
-unsigned int do_skl_residency;
 unsigned int do_slm_cstates;
 unsigned int use_c1_residency_msr;
 unsigned int has_aperf;
@@ -93,6 +92,7 @@ unsigned int do_ring_perf_limit_reasons;
 unsigned int crystal_hz;
 unsigned long long tsc_hz;
 int base_cpu;
+int do_migrate;
 double discover_bclk(unsigned int family, unsigned int model);
 unsigned int has_hwp;  /* IA32_PM_ENABLE, IA32_HWP_CAPABILITIES */
                        /* IA32_HWP_REQUEST, IA32_HWP_STATUS */
@@ -151,6 +151,8 @@ size_t cpu_present_setsize, cpu_affinity_setsize, cpu_subset_size;
 #define MAX_ADDED_COUNTERS 16
 
 struct thread_data {
+       struct timeval tv_begin;
+       struct timeval tv_end;
        unsigned long long tsc;
        unsigned long long aperf;
        unsigned long long mperf;
@@ -301,6 +303,9 @@ int for_all_cpus(int (func)(struct thread_data *, struct core_data *, struct pkg
 
 int cpu_migrate(int cpu)
 {
+       if (!do_migrate)
+               return 0;
+
        CPU_ZERO_S(cpu_affinity_setsize, cpu_affinity_set);
        CPU_SET_S(cpu, cpu_affinity_setsize, cpu_affinity_set);
        if (sched_setaffinity(0, cpu_affinity_setsize, cpu_affinity_set) == -1)
@@ -384,8 +389,14 @@ struct msr_counter bic[] = {
        { 0x0, "CPU" },
        { 0x0, "Mod%c6" },
        { 0x0, "sysfs" },
+       { 0x0, "Totl%C0" },
+       { 0x0, "Any%C0" },
+       { 0x0, "GFX%C0" },
+       { 0x0, "CPUGFX%" },
 };
 
+
+
 #define MAX_BIC (sizeof(bic) / sizeof(struct msr_counter))
 #define        BIC_Package     (1ULL << 0)
 #define        BIC_Avg_MHz     (1ULL << 1)
@@ -426,6 +437,10 @@ struct msr_counter bic[] = {
 #define        BIC_CPU         (1ULL << 36)
 #define        BIC_Mod_c6      (1ULL << 37)
 #define        BIC_sysfs       (1ULL << 38)
+#define        BIC_Totl_c0     (1ULL << 39)
+#define        BIC_Any_c0      (1ULL << 40)
+#define        BIC_GFX_c0      (1ULL << 41)
+#define        BIC_CPUGFX      (1ULL << 42)
 
 unsigned long long bic_enabled = 0xFFFFFFFFFFFFFFFFULL;
 unsigned long long bic_present = BIC_sysfs;
@@ -521,6 +536,8 @@ void print_header(char *delim)
        struct msr_counter *mp;
        int printed = 0;
 
+       if (debug)
+               outp += sprintf(outp, "usec %s", delim);
        if (DO_BIC(BIC_Package))
                outp += sprintf(outp, "%sPackage", (printed++ ? delim : ""));
        if (DO_BIC(BIC_Core))
@@ -599,12 +616,14 @@ void print_header(char *delim)
        if (DO_BIC(BIC_GFXMHz))
                outp += sprintf(outp, "%sGFXMHz", (printed++ ? delim : ""));
 
-       if (do_skl_residency) {
+       if (DO_BIC(BIC_Totl_c0))
                outp += sprintf(outp, "%sTotl%%C0", (printed++ ? delim : ""));
+       if (DO_BIC(BIC_Any_c0))
                outp += sprintf(outp, "%sAny%%C0", (printed++ ? delim : ""));
+       if (DO_BIC(BIC_GFX_c0))
                outp += sprintf(outp, "%sGFX%%C0", (printed++ ? delim : ""));
+       if (DO_BIC(BIC_CPUGFX))
                outp += sprintf(outp, "%sCPUGFX%%", (printed++ ? delim : ""));
-       }
 
        if (DO_BIC(BIC_Pkgpc2))
                outp += sprintf(outp, "%sPkg%%pc2", (printed++ ? delim : ""));
@@ -771,6 +790,14 @@ int format_counters(struct thread_data *t, struct core_data *c,
                (cpu_subset && !CPU_ISSET_S(t->cpu_id, cpu_subset_size, cpu_subset)))
                return 0;
 
+       if (debug) {
+               /* on each row, print how many usec each timestamp took to gather */
+               struct timeval tv;
+
+               timersub(&t->tv_end, &t->tv_begin, &tv);
+               outp += sprintf(outp, "%5ld\t", tv.tv_sec * 1000000 + tv.tv_usec);
+       }
+
        interval_float = tv_delta.tv_sec + tv_delta.tv_usec/1000000.0;
 
        tsc = t->tsc * tsc_tweak;
@@ -912,12 +939,14 @@ int format_counters(struct thread_data *t, struct core_data *c,
                outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), p->gfx_mhz);
 
        /* Totl%C0, Any%C0 GFX%C0 CPUGFX% */
-       if (do_skl_residency) {
+       if (DO_BIC(BIC_Totl_c0))
                outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pkg_wtd_core_c0/tsc);
+       if (DO_BIC(BIC_Any_c0))
                outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pkg_any_core_c0/tsc);
+       if (DO_BIC(BIC_GFX_c0))
                outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pkg_any_gfxe_c0/tsc);
+       if (DO_BIC(BIC_CPUGFX))
                outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pkg_both_core_gfxe_c0/tsc);
-       }
 
        if (DO_BIC(BIC_Pkgpc2))
                outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pc2/tsc);
@@ -1038,12 +1067,16 @@ delta_package(struct pkg_data *new, struct pkg_data *old)
        int i;
        struct msr_counter *mp;
 
-       if (do_skl_residency) {
+
+       if (DO_BIC(BIC_Totl_c0))
                old->pkg_wtd_core_c0 = new->pkg_wtd_core_c0 - old->pkg_wtd_core_c0;
+       if (DO_BIC(BIC_Any_c0))
                old->pkg_any_core_c0 = new->pkg_any_core_c0 - old->pkg_any_core_c0;
+       if (DO_BIC(BIC_GFX_c0))
                old->pkg_any_gfxe_c0 = new->pkg_any_gfxe_c0 - old->pkg_any_gfxe_c0;
+       if (DO_BIC(BIC_CPUGFX))
                old->pkg_both_core_gfxe_c0 = new->pkg_both_core_gfxe_c0 - old->pkg_both_core_gfxe_c0;
-       }
+
        old->pc2 = new->pc2 - old->pc2;
        if (DO_BIC(BIC_Pkgpc3))
                old->pc3 = new->pc3 - old->pc3;
@@ -1292,12 +1325,14 @@ int sum_counters(struct thread_data *t, struct core_data *c,
        if (!(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE))
                return 0;
 
-       if (do_skl_residency) {
+       if (DO_BIC(BIC_Totl_c0))
                average.packages.pkg_wtd_core_c0 += p->pkg_wtd_core_c0;
+       if (DO_BIC(BIC_Any_c0))
                average.packages.pkg_any_core_c0 += p->pkg_any_core_c0;
+       if (DO_BIC(BIC_GFX_c0))
                average.packages.pkg_any_gfxe_c0 += p->pkg_any_gfxe_c0;
+       if (DO_BIC(BIC_CPUGFX))
                average.packages.pkg_both_core_gfxe_c0 += p->pkg_both_core_gfxe_c0;
-       }
 
        average.packages.pc2 += p->pc2;
        if (DO_BIC(BIC_Pkgpc3))
@@ -1357,12 +1392,14 @@ void compute_average(struct thread_data *t, struct core_data *c,
        average.cores.c7 /= topo.num_cores;
        average.cores.mc6_us /= topo.num_cores;
 
-       if (do_skl_residency) {
+       if (DO_BIC(BIC_Totl_c0))
                average.packages.pkg_wtd_core_c0 /= topo.num_packages;
+       if (DO_BIC(BIC_Any_c0))
                average.packages.pkg_any_core_c0 /= topo.num_packages;
+       if (DO_BIC(BIC_GFX_c0))
                average.packages.pkg_any_gfxe_c0 /= topo.num_packages;
+       if (DO_BIC(BIC_CPUGFX))
                average.packages.pkg_both_core_gfxe_c0 /= topo.num_packages;
-       }
 
        average.packages.pc2 /= topo.num_packages;
        if (DO_BIC(BIC_Pkgpc3))
@@ -1482,6 +1519,9 @@ int get_counters(struct thread_data *t, struct core_data *c, struct pkg_data *p)
        struct msr_counter *mp;
        int i;
 
+
+       gettimeofday(&t->tv_begin, (struct timezone *)NULL);
+
        if (cpu_migrate(cpu)) {
                fprintf(outf, "Could not migrate to CPU %d\n", cpu);
                return -1;
@@ -1565,7 +1605,7 @@ retry:
 
        /* collect core counters only for 1st thread in core */
        if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE))
-               return 0;
+               goto done;
 
        if (DO_BIC(BIC_CPU_c3) && !do_slm_cstates && !do_knl_cstates) {
                if (get_msr(cpu, MSR_CORE_C3_RESIDENCY, &c->c3))
@@ -1601,15 +1641,21 @@ retry:
 
        /* collect package counters only for 1st core in package */
        if (!(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE))
-               return 0;
+               goto done;
 
-       if (do_skl_residency) {
+       if (DO_BIC(BIC_Totl_c0)) {
                if (get_msr(cpu, MSR_PKG_WEIGHTED_CORE_C0_RES, &p->pkg_wtd_core_c0))
                        return -10;
+       }
+       if (DO_BIC(BIC_Any_c0)) {
                if (get_msr(cpu, MSR_PKG_ANY_CORE_C0_RES, &p->pkg_any_core_c0))
                        return -11;
+       }
+       if (DO_BIC(BIC_GFX_c0)) {
                if (get_msr(cpu, MSR_PKG_ANY_GFXE_C0_RES, &p->pkg_any_gfxe_c0))
                        return -12;
+       }
+       if (DO_BIC(BIC_CPUGFX)) {
                if (get_msr(cpu, MSR_PKG_BOTH_CORE_GFXE_C0_RES, &p->pkg_both_core_gfxe_c0))
                        return -13;
        }
@@ -1688,6 +1734,8 @@ retry:
                if (get_mp(cpu, mp, &p->counter[i]))
                        return -10;
        }
+done:
+       gettimeofday(&t->tv_end, (struct timezone *)NULL);
 
        return 0;
 }
@@ -3895,6 +3943,9 @@ void decode_misc_enable_msr(void)
 {
        unsigned long long msr;
 
+       if (!genuine_intel)
+               return;
+
        if (!get_msr(base_cpu, MSR_IA32_MISC_ENABLE, &msr))
                fprintf(outf, "cpu%d: MSR_IA32_MISC_ENABLE: 0x%08llx (%sTCC %sEIST %sMWAIT %sPREFETCH %sTURBO)\n",
                        base_cpu, msr,
@@ -4198,7 +4249,12 @@ void process_cpuid()
                BIC_PRESENT(BIC_Pkgpc10);
        }
        do_irtl_hsw = has_hsw_msrs(family, model);
-       do_skl_residency = has_skl_msrs(family, model);
+       if (has_skl_msrs(family, model)) {
+               BIC_PRESENT(BIC_Totl_c0);
+               BIC_PRESENT(BIC_Any_c0);
+               BIC_PRESENT(BIC_GFX_c0);
+               BIC_PRESENT(BIC_CPUGFX);
+       }
        do_slm_cstates = is_slm(family, model);
        do_knl_cstates  = is_knl(family, model);
 
@@ -4578,7 +4634,7 @@ int get_and_dump_counters(void)
 }
 
 void print_version() {
-       fprintf(outf, "turbostat version 17.04.12"
+       fprintf(outf, "turbostat version 17.06.23"
                " - Len Brown <lenb@kernel.org>\n");
 }
 
@@ -4951,6 +5007,7 @@ void cmdline(int argc, char **argv)
                {"hide",        required_argument,      0, 'H'},        // meh, -h taken by --help
                {"Joules",      no_argument,            0, 'J'},
                {"list",        no_argument,            0, 'l'},
+               {"migrate",     no_argument,            0, 'm'},
                {"out",         required_argument,      0, 'o'},
                {"quiet",       no_argument,            0, 'q'},
                {"show",        required_argument,      0, 's'},
@@ -4962,7 +5019,7 @@ void cmdline(int argc, char **argv)
 
        progname = argv[0];
 
-       while ((opt = getopt_long_only(argc, argv, "+C:c:Ddhi:JM:m:o:qST:v",
+       while ((opt = getopt_long_only(argc, argv, "+C:c:Ddhi:Jmo:qST:v",
                                long_options, &option_index)) != -1) {
                switch (opt) {
                case 'a':
@@ -5005,6 +5062,9 @@ void cmdline(int argc, char **argv)
                        list_header_only++;
                        quiet++;
                        break;
+               case 'm':
+                       do_migrate = 1;
+                       break;
                case 'o':
                        outf = fopen_or_die(optarg, "w");
                        break;
index 971c9ffdcb504ad8172758849aa5f0156f010bd9..a711eec0c8953f6c8693de17f7c6dc382c3e262a 100644 (file)
@@ -1,10 +1,27 @@
-DESTDIR ?=
+CC             = $(CROSS_COMPILE)gcc
+BUILD_OUTPUT    := $(CURDIR)
+PREFIX         := /usr
+DESTDIR                :=
+
+ifeq ("$(origin O)", "command line")
+       BUILD_OUTPUT := $(O)
+endif
 
 x86_energy_perf_policy : x86_energy_perf_policy.c
+CFLAGS +=      -Wall
+CFLAGS +=      -DMSRHEADER='"../../../../arch/x86/include/asm/msr-index.h"'
+
+%: %.c
+       @mkdir -p $(BUILD_OUTPUT)
+       $(CC) $(CFLAGS) $< -o $(BUILD_OUTPUT)/$@
 
+.PHONY : clean
 clean :
-       rm -f x86_energy_perf_policy
+       @rm -f $(BUILD_OUTPUT)/x86_energy_perf_policy
+
+install : x86_energy_perf_policy
+       install -d  $(DESTDIR)$(PREFIX)/bin
+       install $(BUILD_OUTPUT)/x86_energy_perf_policy $(DESTDIR)$(PREFIX)/bin/x86_energy_perf_policy
+       install -d  $(DESTDIR)$(PREFIX)/share/man/man8
+       install x86_energy_perf_policy.8 $(DESTDIR)$(PREFIX)/share/man/man8
 
-install :
-       install x86_energy_perf_policy ${DESTDIR}/usr/bin/
-       install x86_energy_perf_policy.8 ${DESTDIR}/usr/share/man/man8/
index 8eaaad648cdb92743e373adaacb8a16bbdc8f551..17db1c3af4d0bb3901482bbfed9e2cff8bc8cb6f 100644 (file)
-.\"  This page Copyright (C) 2010 Len Brown <len.brown@intel.com>
+.\"  This page Copyright (C) 2010 - 2015 Len Brown <len.brown@intel.com>
 .\"  Distributed under the GPL, Copyleft 1994.
 .TH X86_ENERGY_PERF_POLICY 8
 .SH NAME
-x86_energy_perf_policy \- read or write MSR_IA32_ENERGY_PERF_BIAS
+x86_energy_perf_policy \- Manage Energy vs. Performance Policy via x86 Model Specific Registers
 .SH SYNOPSIS
-.ft B
 .B x86_energy_perf_policy
-.RB [ "\-c cpu" ]
-.RB [ "\-v" ]
-.RB "\-r"
+.RB "[ options ] [ scope ] [field \ value]"
 .br
-.B x86_energy_perf_policy
-.RB [ "\-c cpu" ]
-.RB [ "\-v" ]
-.RB 'performance'
+.RB "scope: \-\-cpu\ cpu-list | \-\-pkg\ pkg-list"
 .br
-.B x86_energy_perf_policy
-.RB [ "\-c cpu" ]
-.RB [ "\-v" ]
-.RB 'normal'
+.RB "cpu-list, pkg-list: # | #,# | #-# | all"
 .br
-.B x86_energy_perf_policy
-.RB [ "\-c cpu" ]
-.RB [ "\-v" ]
-.RB 'powersave'
+.RB "field: \-\-all | \-\-epb | \-\-hwp-epp | \-\-hwp-min | \-\-hwp-max | \-\-hwp-desired"
 .br
-.B x86_energy_perf_policy
-.RB [ "\-c cpu" ]
-.RB [ "\-v" ]
-.RB n
+.RB "other: (\-\-force | \-\-hwp-enable | \-\-turbo-enable)  value)"
 .br
+.RB "value: # | default | performance | balance-performance | balance-power | power"
 .SH DESCRIPTION
 \fBx86_energy_perf_policy\fP
-allows software to convey
-its policy for the relative importance of performance
-versus energy savings to the processor.
+displays and updates energy-performance policy settings specific to
+Intel Architecture Processors.  Settings are accessed via Model Specific Register (MSR)
+updates, no matter if the Linux cpufreq sub-system is enabled or not.
 
-The processor uses this information in model-specific ways
-when it must select trade-offs between performance and
-energy efficiency.
+Policy in MSR_IA32_ENERGY_PERF_BIAS (EPB)
+may affect a wide range of hardware decisions,
+such as how aggressively the hardware enters and exits CPU idle states (C-states)
+and Processor Performance States (P-states).
+This policy hint does not replace explicit OS C-state and P-state selection.
+Rather, it tells the hardware how aggressively to implement those selections.
+Further, it allows the OS to influence energy/performance trade-offs where there
+is no software interface, such as in the opportunistic "turbo-mode" P-state range.
+Note that MSR_IA32_ENERGY_PERF_BIAS is defined per CPU,
+but some implementations
+share a single MSR among all CPUs in each processor package.
+On those systems, a write to EPB on one processor will
+be visible, and will have an effect, on all CPUs
+in the same processor package.
 
-This policy hint does not supersede Processor Performance states
-(P-states) or CPU Idle power states (C-states), but allows
-software to have influence where it would otherwise be unable
-to express a preference.
+Hardware P-States (HWP) are effectively an expansion of hardware
+P-state control from the opportunistic turbo-mode P-state range
+to include the entire range of available P-states.
+On Broadwell Xeon, the initial HWP implementation, EBP influenced HWP.
+That influence was removed in subsequent generations,
+where it was moved to the
+Energy_Performance_Preference (EPP) field in
+a pair of dedicated MSRs -- MSR_IA32_HWP_REQUEST and MSR_IA32_HWP_REQUEST_PKG.
 
-For example, this setting may tell the hardware how
-aggressively or conservatively to control frequency
-in the "turbo range" above the explicitly OS-controlled
-P-state frequency range.  It may also tell the hardware
-how aggressively is should enter the OS requested C-states.
+EPP is the most commonly managed knob in HWP mode,
+but MSR_IA32_HWP_REQUEST also allows the user to specify
+minimum-frequency for Quality-of-Service,
+and maximum-frequency for power-capping.
+MSR_IA32_HWP_REQUEST is defined per-CPU.
 
-Support for this feature is indicated by CPUID.06H.ECX.bit3
-per the Intel Architectures Software Developer's Manual.
+MSR_IA32_HWP_REQUEST_PKG has the same capability as MSR_IA32_HWP_REQUEST,
+but it can simultaneously set the default policy for all CPUs within a package.
+A bit in per-CPU MSR_IA32_HWP_REQUEST indicates whether it is
+over-ruled-by or exempt-from MSR_IA32_HWP_REQUEST_PKG.
 
-.SS Options
-\fB-c\fP limits operation to a single CPU.
-The default is to operate on all CPUs.
-Note that MSR_IA32_ENERGY_PERF_BIAS is defined per
-logical processor, but that the initial implementations
-of the MSR were shared among all processors in each package.
-.PP
-\fB-v\fP increases verbosity.  By default
-x86_energy_perf_policy is silent.
-.PP
-\fB-r\fP is for "read-only" mode - the unchanged state
-is read and displayed.
+MSR_HWP_CAPABILITIES shows the default values for the fields
+in MSR_IA32_HWP_REQUEST.  It is displayed when no values
+are being written.
+
+.SS SCOPE OPTIONS
 .PP
-.I performance
-Set a policy where performance is paramount.
-The processor will be unwilling to sacrifice any performance
-for the sake of energy saving. This is the hardware default.
+\fB-c, --cpu\fP Operate on the MSR_IA32_HWP_REQUEST for each CPU in a CPU-list.
+The CPU-list may be comma-separated CPU numbers, with dash for range
+or the string "all".  Eg. '--cpu 1,4,6-8' or '--cpu all'.
+When --cpu is used, \fB--hwp-use-pkg\fP is available, which specifies whether the per-cpu
+MSR_IA32_HWP_REQUEST should be over-ruled by MSR_IA32_HWP_REQUEST_PKG (1),
+or exempt from MSR_IA32_HWP_REQUEST_PKG (0).
+
+\fB-p, --pkg\fP Operate on the MSR_IA32_HWP_REQUEST_PKG for each package in the package-list.
+The list is a string of individual package numbers separated
+by commas, and or ranges of package numbers separated by a dash,
+or the string "all".
+For example '--pkg 1,3' or '--pkg all'
+
+.SS VALUE OPTIONS
 .PP
-.I normal
+.I normal | default
 Set a policy with a normal balance between performance and energy efficiency.
 The processor will tolerate minor performance compromise
 for potentially significant energy savings.
-This reasonable default for most desktops and servers.
+This is a reasonable default for most desktops and servers.
+"default" is a synonym for "normal".
 .PP
-.I powersave
+.I performance
+Set a policy for maximum performance,
+accepting no performance sacrifice for the benefit of energy efficiency.
+.PP
+.I balance-performance
+Set a policy with a high priority on performance,
+but allowing some performance loss to benefit energy efficiency.
+.PP
+.I balance-power
+Set a policy where the performance and power are balanced.
+This is the default.
+.PP
+.I power
 Set a policy where the processor can accept
-a measurable performance hit to maximize energy efficiency.
+a measurable performance impact to maximize energy efficiency.
+
 .PP
-.I n
-Set MSR_IA32_ENERGY_PERF_BIAS to the specified number.
-The range of valid numbers is 0-15, where 0 is maximum
-performance and 15 is maximum energy efficiency.
+The following table shows the mapping from the value strings above to actual MSR values.
+This mapping is defined in the Linux-kernel header, msr-index.h.
 
+.nf
+VALUE STRING           EPB     EPP
+performance            0       0
+balance-performance    4       128
+normal, default                6       128
+balance-power          8       192
+power                  15      255
+.fi
+.PP
+For MSR_IA32_HWP_REQUEST performance fields
+(--hwp-min, --hwp-max, --hwp-desired), the value option
+is in units of 100 MHz, Eg. 12 signifies 1200 MHz.
+
+.SS FIELD OPTIONS
+\fB-a, --all value-string\fP Sets all EPB and EPP and HWP limit fields to the value associated with
+the value-string.  In addition, enables turbo-mode and HWP-mode, if they were previous disabled.
+Thus "--all normal" will set a system without cpufreq into a well known configuration.
+.PP
+\fB-B, --epb\fP set EPB per-core or per-package.
+See value strings in the table above.
+.PP
+\fB-d, --debug\fP debug increases verbosity.  By default
+x86_energy_perf_policy is silent for updates,
+and verbose for read-only mode.
+.PP
+\fB-P, --hwp-epp\fP set HWP.EPP per-core or per-package.
+See value strings in the table above.
+.PP
+\fB-m, --hwp-min\fP request HWP to not go below the specified core/bus ratio.
+The "default" is the value found in IA32_HWP_CAPABILITIES.min.
+.PP
+\fB-M, --hwp-max\fP request HWP not exceed a the specified core/bus ratio.
+The "default" is the value found in IA32_HWP_CAPABILITIES.max.
+.PP
+\fB-D, --hwp-desired\fP request HWP 'desired' frequency.
+The "normal" setting is 0, which
+corresponds to 'full autonomous' HWP control.
+Non-zero performance values request a specific performance
+level on this processor, specified in multiples of 100 MHz.
+.PP
+\fB-w, --hwp-window\fP specify integer number of microsec
+in the sliding window that HWP uses to maintain average frequency.
+This parameter is meaningful only when the "desired" field above is non-zero.
+Default is 0, allowing the HW to choose.
+.SH OTHER OPTIONS
+.PP
+\fB-f, --force\fP writes the specified values without bounds checking.
+.PP
+\fB-U, --hwp-use-pkg\fP (0 | 1), when used in conjunction with --cpu,
+indicates whether the per-CPU MSR_IA32_HWP_REQUEST should be overruled (1)
+or exempt (0) from per-Package MSR_IA32_HWP_REQUEST_PKG settings.
+The default is exempt.
+.PP
+\fB-H, --hwp-enable\fP enable HardWare-P-state (HWP) mode.  Once enabled, system RESET is required to disable HWP mode.
+.PP
+\fB-t, --turbo-enable\fP enable (1) or disable (0) turbo mode.
+.PP
+\fB-v, --version\fP print version and exit.
+.PP
+If no request to change policy is made,
+the default behavior is to read
+and display the current system state,
+including the default capabilities.
+.SH WARNING
+.PP
+This utility writes directly to Model Specific Registers.
+There is no locking or coordination should this utility
+be used to modify HWP limit fields at the same time that
+intel_pstate's sysfs attributes access the same MSRs.
+.PP
+Note that --hwp-desired and --hwp-window are considered experimental.
+Future versions of Linux reserve the right to access these
+fields internally -- potentially conflicting with user-space access.
+.SH EXAMPLE
+.nf
+# sudo x86_energy_perf_policy
+cpu0: EPB 6
+cpu0: HWP_REQ: min 6 max 35 des 0 epp 128 window 0x0 (0*10^0us) use_pkg 0
+cpu0: HWP_CAP: low 1 eff 8 guar 27 high 35
+cpu1: EPB 6
+cpu1: HWP_REQ: min 6 max 35 des 0 epp 128 window 0x0 (0*10^0us) use_pkg 0
+cpu1: HWP_CAP: low 1 eff 8 guar 27 high 35
+cpu2: EPB 6
+cpu2: HWP_REQ: min 6 max 35 des 0 epp 128 window 0x0 (0*10^0us) use_pkg 0
+cpu2: HWP_CAP: low 1 eff 8 guar 27 high 35
+cpu3: EPB 6
+cpu3: HWP_REQ: min 6 max 35 des 0 epp 128 window 0x0 (0*10^0us) use_pkg 0
+cpu3: HWP_CAP: low 1 eff 8 guar 27 high 35
+.fi
 .SH NOTES
-.B "x86_energy_perf_policy "
+.B "x86_energy_perf_policy"
 runs only as root.
 .SH FILES
 .ta
 .nf
 /dev/cpu/*/msr
 .fi
-
 .SH "SEE ALSO"
+.nf
 msr(4)
+Intel(R) 64 and IA-32 Architectures Software Developer's Manual
+.fi
 .PP
 .SH AUTHORS
 .nf
-Written by Len Brown <len.brown@intel.com>
+Len Brown
index 40b3e5482f8ab745efdd39c58e5a6238ab6fc31b..65bbe627a425f6361d1249642ad29847abae0575 100644 (file)
  * policy preference bias on recent X86 processors.
  */
 /*
- * Copyright (c) 2010, Intel Corporation.
+ * Copyright (c) 2010 - 2017 Intel Corporation.
  * Len Brown <len.brown@intel.com>
  *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ * This program is released under GPL v2
  */
 
+#define _GNU_SOURCE
+#include MSRHEADER
 #include <stdio.h>
 #include <unistd.h>
 #include <sys/types.h>
+#include <sched.h>
 #include <sys/stat.h>
 #include <sys/resource.h>
+#include <getopt.h>
+#include <err.h>
 #include <fcntl.h>
 #include <signal.h>
 #include <sys/time.h>
+#include <limits.h>
 #include <stdlib.h>
 #include <string.h>
+#include <cpuid.h>
+#include <errno.h>
+
+#define        OPTARG_NORMAL                   (INT_MAX - 1)
+#define        OPTARG_POWER                    (INT_MAX - 2)
+#define        OPTARG_BALANCE_POWER            (INT_MAX - 3)
+#define        OPTARG_BALANCE_PERFORMANCE      (INT_MAX - 4)
+#define        OPTARG_PERFORMANCE              (INT_MAX - 5)
+
+struct msr_hwp_cap {
+       unsigned char highest;
+       unsigned char guaranteed;
+       unsigned char efficient;
+       unsigned char lowest;
+};
 
-unsigned int verbose;          /* set with -v */
-unsigned int read_only;                /* set with -r */
+struct msr_hwp_request {
+       unsigned char hwp_min;
+       unsigned char hwp_max;
+       unsigned char hwp_desired;
+       unsigned char hwp_epp;
+       unsigned int hwp_window;
+       unsigned char hwp_use_pkg;
+} req_update;
+
+unsigned int debug;
+unsigned int verbose;
+unsigned int force;
 char *progname;
-unsigned long long new_bias;
-int cpu = -1;
+int base_cpu;
+unsigned char update_epb;
+unsigned long long new_epb;
+unsigned char turbo_is_enabled;
+unsigned char update_turbo;
+unsigned char turbo_update_value;
+unsigned char update_hwp_epp;
+unsigned char update_hwp_min;
+unsigned char update_hwp_max;
+unsigned char update_hwp_desired;
+unsigned char update_hwp_window;
+unsigned char update_hwp_use_pkg;
+unsigned char update_hwp_enable;
+#define hwp_update_enabled() (update_hwp_enable | update_hwp_epp | update_hwp_max | update_hwp_min | update_hwp_desired | update_hwp_window | update_hwp_use_pkg)
+int max_cpu_num;
+int max_pkg_num;
+#define MAX_PACKAGES 64
+unsigned int first_cpu_in_pkg[MAX_PACKAGES];
+unsigned long long pkg_present_set;
+unsigned long long pkg_selected_set;
+cpu_set_t *cpu_present_set;
+cpu_set_t *cpu_selected_set;
+int genuine_intel;
+
+size_t cpu_setsize;
+
+char *proc_stat = "/proc/stat";
+
+unsigned int has_epb;  /* MSR_IA32_ENERGY_PERF_BIAS */
+unsigned int has_hwp;  /* IA32_PM_ENABLE, IA32_HWP_CAPABILITIES */
+                       /* IA32_HWP_REQUEST, IA32_HWP_STATUS */
+unsigned int has_hwp_notify;           /* IA32_HWP_INTERRUPT */
+unsigned int has_hwp_activity_window;  /* IA32_HWP_REQUEST[bits 41:32] */
+unsigned int has_hwp_epp;      /* IA32_HWP_REQUEST[bits 31:24] */
+unsigned int has_hwp_request_pkg;      /* IA32_HWP_REQUEST_PKG */
+
+unsigned int bdx_highest_ratio;
 
 /*
- * Usage:
- *
- * -c cpu: limit action to a single CPU (default is all CPUs)
- * -v: verbose output (can invoke more than once)
- * -r: read-only, don't change any settings
- *
- *  performance
- *     Performance is paramount.
- *     Unwilling to sacrifice any performance
- *     for the sake of energy saving. (hardware default)
- *
- *  normal
- *     Can tolerate minor performance compromise
- *     for potentially significant energy savings.
- *     (reasonable default for most desktops and servers)
- *
- *  powersave
- *     Can tolerate significant performance hit
- *     to maximize energy savings.
- *
- * n
- *     a numerical value to write to the underlying MSR.
+ * maintain compatibility with original implementation, but don't document it:
  */
 void usage(void)
 {
-       printf("%s: [-c cpu] [-v] "
-               "(-r | 'performance' | 'normal' | 'powersave' | n)\n",
-               progname);
+       fprintf(stderr, "%s [options] [scope][field value]\n", progname);
+       fprintf(stderr, "scope: --cpu cpu-list [--hwp-use-pkg #] | --pkg pkg-list\n");
+       fprintf(stderr, "field: --all | --epb | --hwp-epp | --hwp-min | --hwp-max | --hwp-desired\n");
+       fprintf(stderr, "other: --hwp-enable | --turbo-enable (0 | 1) | --help | --force\n");
+       fprintf(stderr,
+               "value: ( # | \"normal\" | \"performance\" | \"balance-performance\" | \"balance-power\"| \"power\")\n");
+       fprintf(stderr, "--hwp-window usec\n");
+
+       fprintf(stderr, "Specify only Energy Performance BIAS (legacy usage):\n");
+       fprintf(stderr, "%s: [-c cpu] [-v] (-r | policy-value )\n", progname);
+
        exit(1);
 }
 
-#define MSR_IA32_ENERGY_PERF_BIAS      0x000001b0
+/*
+ * If bdx_highest_ratio is set,
+ * then we must translate between MSR format and simple ratio
+ * used on the cmdline.
+ */
+int ratio_2_msr_perf(int ratio)
+{
+       int msr_perf;
+
+       if (!bdx_highest_ratio)
+               return ratio;
+
+       msr_perf = ratio * 255 / bdx_highest_ratio;
+
+       if (debug)
+               fprintf(stderr, "%d = ratio_to_msr_perf(%d)\n", msr_perf, ratio);
+
+       return msr_perf;
+}
+int msr_perf_2_ratio(int msr_perf)
+{
+       int ratio;
+       double d;
+
+       if (!bdx_highest_ratio)
+               return msr_perf;
+
+       d = (double)msr_perf * (double) bdx_highest_ratio / 255.0;
+       d = d + 0.5;    /* round */
+       ratio = (int)d;
+
+       if (debug)
+               fprintf(stderr, "%d = msr_perf_ratio(%d) {%f}\n", ratio, msr_perf, d);
+
+       return ratio;
+}
+int parse_cmdline_epb(int i)
+{
+       if (!has_epb)
+               errx(1, "EPB not enabled on this platform");
+
+       update_epb = 1;
+
+       switch (i) {
+       case OPTARG_POWER:
+               return ENERGY_PERF_BIAS_POWERSAVE;
+       case OPTARG_BALANCE_POWER:
+               return ENERGY_PERF_BIAS_BALANCE_POWERSAVE;
+       case OPTARG_NORMAL:
+               return ENERGY_PERF_BIAS_NORMAL;
+       case OPTARG_BALANCE_PERFORMANCE:
+               return ENERGY_PERF_BIAS_BALANCE_PERFORMANCE;
+       case OPTARG_PERFORMANCE:
+               return ENERGY_PERF_BIAS_PERFORMANCE;
+       }
+       if (i < 0 || i > ENERGY_PERF_BIAS_POWERSAVE)
+               errx(1, "--epb must be from 0 to 15");
+       return i;
+}
+
+#define HWP_CAP_LOWEST 0
+#define HWP_CAP_HIGHEST 255
+
+/*
+ * "performance" changes hwp_min to cap.highest
+ * All others leave it at cap.lowest
+ */
+int parse_cmdline_hwp_min(int i)
+{
+       update_hwp_min = 1;
+
+       switch (i) {
+       case OPTARG_POWER:
+       case OPTARG_BALANCE_POWER:
+       case OPTARG_NORMAL:
+       case OPTARG_BALANCE_PERFORMANCE:
+               return HWP_CAP_LOWEST;
+       case OPTARG_PERFORMANCE:
+               return HWP_CAP_HIGHEST;
+       }
+       return i;
+}
+/*
+ * "power" changes hwp_max to cap.lowest
+ * All others leave it at cap.highest
+ */
+int parse_cmdline_hwp_max(int i)
+{
+       update_hwp_max = 1;
+
+       switch (i) {
+       case OPTARG_POWER:
+               return HWP_CAP_LOWEST;
+       case OPTARG_NORMAL:
+       case OPTARG_BALANCE_POWER:
+       case OPTARG_BALANCE_PERFORMANCE:
+       case OPTARG_PERFORMANCE:
+               return HWP_CAP_HIGHEST;
+       }
+       return i;
+}
+/*
+ * for --hwp-des, all strings leave it in autonomous mode
+ * If you want to change it, you need to explicitly pick a value
+ */
+int parse_cmdline_hwp_desired(int i)
+{
+       update_hwp_desired = 1;
+
+       switch (i) {
+       case OPTARG_POWER:
+       case OPTARG_BALANCE_POWER:
+       case OPTARG_BALANCE_PERFORMANCE:
+       case OPTARG_NORMAL:
+       case OPTARG_PERFORMANCE:
+               return 0;       /* autonomous */
+       }
+       return i;
+}
+
+int parse_cmdline_hwp_window(int i)
+{
+       unsigned int exponent;
+
+       update_hwp_window = 1;
+
+       switch (i) {
+       case OPTARG_POWER:
+       case OPTARG_BALANCE_POWER:
+       case OPTARG_NORMAL:
+       case OPTARG_BALANCE_PERFORMANCE:
+       case OPTARG_PERFORMANCE:
+               return 0;
+       }
+       if (i < 0 || i > 1270000000) {
+               fprintf(stderr, "--hwp-window: 0 for auto; 1 - 1270000000 usec for window duration\n");
+               usage();
+       }
+       for (exponent = 0; ; ++exponent) {
+               if (debug)
+                       printf("%d 10^%d\n", i, exponent);
+
+               if (i <= 127)
+                       break;
+
+               i = i / 10;
+       }
+       if (debug)
+               fprintf(stderr, "%d*10^%d: 0x%x\n", i, exponent, (exponent << 7) | i);
+
+       return (exponent << 7) | i;
+}
+int parse_cmdline_hwp_epp(int i)
+{
+       update_hwp_epp = 1;
+
+       switch (i) {
+       case OPTARG_POWER:
+               return HWP_EPP_POWERSAVE;
+       case OPTARG_BALANCE_POWER:
+               return HWP_EPP_BALANCE_POWERSAVE;
+       case OPTARG_NORMAL:
+       case OPTARG_BALANCE_PERFORMANCE:
+               return HWP_EPP_BALANCE_PERFORMANCE;
+       case OPTARG_PERFORMANCE:
+               return HWP_EPP_PERFORMANCE;
+       }
+       if (i < 0 || i > 0xff) {
+               fprintf(stderr, "--hwp-epp must be from 0 to 0xff\n");
+               usage();
+       }
+       return i;
+}
+int parse_cmdline_turbo(int i)
+{
+       update_turbo = 1;
+
+       switch (i) {
+       case OPTARG_POWER:
+               return 0;
+       case OPTARG_NORMAL:
+       case OPTARG_BALANCE_POWER:
+       case OPTARG_BALANCE_PERFORMANCE:
+       case OPTARG_PERFORMANCE:
+               return 1;
+       }
+       if (i < 0 || i > 1) {
+               fprintf(stderr, "--turbo-enable: 1 to enable, 0 to disable\n");
+               usage();
+       }
+       return i;
+}
+
+int parse_optarg_string(char *s)
+{
+       int i;
+       char *endptr;
+
+       if (!strncmp(s, "default", 7))
+               return OPTARG_NORMAL;
+
+       if (!strncmp(s, "normal", 6))
+               return OPTARG_NORMAL;
+
+       if (!strncmp(s, "power", 9))
+               return OPTARG_POWER;
+
+       if (!strncmp(s, "balance-power", 17))
+               return OPTARG_BALANCE_POWER;
+
+       if (!strncmp(s, "balance-performance", 19))
+               return OPTARG_BALANCE_PERFORMANCE;
+
+       if (!strncmp(s, "performance", 11))
+               return OPTARG_PERFORMANCE;
+
+       i = strtol(s, &endptr, 0);
+       if (s == endptr) {
+               fprintf(stderr, "no digits in \"%s\"\n", s);
+               usage();
+       }
+       if (i == LONG_MIN || i == LONG_MAX)
+               errx(-1, "%s", s);
+
+       if (i > 0xFF)
+               errx(-1, "%d (0x%x) must be < 256", i, i);
+
+       if (i < 0)
+               errx(-1, "%d (0x%x) must be >= 0", i, i);
+       return i;
+}
+
+void parse_cmdline_all(char *s)
+{
+       force++;
+       update_hwp_enable = 1;
+       req_update.hwp_min = parse_cmdline_hwp_min(parse_optarg_string(s));
+       req_update.hwp_max = parse_cmdline_hwp_max(parse_optarg_string(s));
+       req_update.hwp_epp = parse_cmdline_hwp_epp(parse_optarg_string(s));
+       if (has_epb)
+               new_epb = parse_cmdline_epb(parse_optarg_string(s));
+       turbo_update_value = parse_cmdline_turbo(parse_optarg_string(s));
+       req_update.hwp_desired = parse_cmdline_hwp_desired(parse_optarg_string(s));
+       req_update.hwp_window = parse_cmdline_hwp_window(parse_optarg_string(s));
+}
+
+void validate_cpu_selected_set(void)
+{
+       int cpu;
+
+       if (CPU_COUNT_S(cpu_setsize, cpu_selected_set) == 0)
+               errx(0, "no CPUs requested");
+
+       for (cpu = 0; cpu <= max_cpu_num; ++cpu) {
+               if (CPU_ISSET_S(cpu, cpu_setsize, cpu_selected_set))
+                       if (!CPU_ISSET_S(cpu, cpu_setsize, cpu_present_set))
+                               errx(1, "Requested cpu% is not present", cpu);
+       }
+}
+
+void parse_cmdline_cpu(char *s)
+{
+       char *startp, *endp;
+       int cpu = 0;
+
+       if (pkg_selected_set) {
+               usage();
+               errx(1, "--cpu | --pkg");
+       }
+       cpu_selected_set = CPU_ALLOC((max_cpu_num + 1));
+       if (cpu_selected_set == NULL)
+               err(1, "cpu_selected_set");
+       CPU_ZERO_S(cpu_setsize, cpu_selected_set);
+
+       for (startp = s; startp && *startp;) {
+
+               if (*startp == ',') {
+                       startp++;
+                       continue;
+               }
+
+               if (*startp == '-') {
+                       int end_cpu;
 
-#define        BIAS_PERFORMANCE                0
-#define BIAS_BALANCE                   6
-#define        BIAS_POWERSAVE                  15
+                       startp++;
+                       end_cpu = strtol(startp, &endp, 10);
+                       if (startp == endp)
+                               continue;
+
+                       while (cpu <= end_cpu) {
+                               if (cpu > max_cpu_num)
+                                       errx(1, "Requested cpu%d exceeds max cpu%d", cpu, max_cpu_num);
+                               CPU_SET_S(cpu, cpu_setsize, cpu_selected_set);
+                               cpu++;
+                       }
+                       startp = endp;
+                       continue;
+               }
+
+               if (strncmp(startp, "all", 3) == 0) {
+                       for (cpu = 0; cpu <= max_cpu_num; cpu += 1) {
+                               if (CPU_ISSET_S(cpu, cpu_setsize, cpu_present_set))
+                                       CPU_SET_S(cpu, cpu_setsize, cpu_selected_set);
+                       }
+                       startp += 3;
+                       if (*startp == 0)
+                               break;
+               }
+               /* "--cpu even" is not documented */
+               if (strncmp(startp, "even", 4) == 0) {
+                       for (cpu = 0; cpu <= max_cpu_num; cpu += 2) {
+                               if (CPU_ISSET_S(cpu, cpu_setsize, cpu_present_set))
+                                       CPU_SET_S(cpu, cpu_setsize, cpu_selected_set);
+                       }
+                       startp += 4;
+                       if (*startp == 0)
+                               break;
+               }
+
+               /* "--cpu odd" is not documented */
+               if (strncmp(startp, "odd", 3) == 0) {
+                       for (cpu = 1; cpu <= max_cpu_num; cpu += 2) {
+                               if (CPU_ISSET_S(cpu, cpu_setsize, cpu_present_set))
+                                       CPU_SET_S(cpu, cpu_setsize, cpu_selected_set);
+                       }
+                       startp += 3;
+                       if (*startp == 0)
+                               break;
+               }
+
+               cpu = strtol(startp, &endp, 10);
+               if (startp == endp)
+                       errx(1, "--cpu cpu-set: confused by '%s'", startp);
+               if (cpu > max_cpu_num)
+                       errx(1, "Requested cpu%d exceeds max cpu%d", cpu, max_cpu_num);
+               CPU_SET_S(cpu, cpu_setsize, cpu_selected_set);
+               startp = endp;
+       }
+
+       validate_cpu_selected_set();
+
+}
+
+void parse_cmdline_pkg(char *s)
+{
+       char *startp, *endp;
+       int pkg = 0;
+
+       if (cpu_selected_set) {
+               usage();
+               errx(1, "--pkg | --cpu");
+       }
+       pkg_selected_set = 0;
+
+       for (startp = s; startp && *startp;) {
+
+               if (*startp == ',') {
+                       startp++;
+                       continue;
+               }
+
+               if (*startp == '-') {
+                       int end_pkg;
+
+                       startp++;
+                       end_pkg = strtol(startp, &endp, 10);
+                       if (startp == endp)
+                               continue;
+
+                       while (pkg <= end_pkg) {
+                               if (pkg > max_pkg_num)
+                                       errx(1, "Requested pkg%d exceeds max pkg%d", pkg, max_pkg_num);
+                               pkg_selected_set |= 1 << pkg;
+                               pkg++;
+                       }
+                       startp = endp;
+                       continue;
+               }
+
+               if (strncmp(startp, "all", 3) == 0) {
+                       pkg_selected_set = pkg_present_set;
+                       return;
+               }
+
+               pkg = strtol(startp, &endp, 10);
+               if (pkg > max_pkg_num)
+                       errx(1, "Requested pkg%d Exceeds max pkg%d", pkg, max_pkg_num);
+               pkg_selected_set |= 1 << pkg;
+               startp = endp;
+       }
+}
+
+void for_packages(unsigned long long pkg_set, int (func)(int))
+{
+       int pkg_num;
+
+       for (pkg_num = 0; pkg_num <= max_pkg_num; ++pkg_num) {
+               if (pkg_set & (1UL << pkg_num))
+                       func(pkg_num);
+       }
+}
+
+void print_version(void)
+{
+       printf("x86_energy_perf_policy 17.05.11 (C) Len Brown <len.brown@intel.com>\n");
+}
 
 void cmdline(int argc, char **argv)
 {
        int opt;
+       int option_index = 0;
+
+       static struct option long_options[] = {
+               {"all",         required_argument,      0, 'a'},
+               {"cpu",         required_argument,      0, 'c'},
+               {"pkg",         required_argument,      0, 'p'},
+               {"debug",       no_argument,            0, 'd'},
+               {"hwp-desired", required_argument,      0, 'D'},
+               {"epb", required_argument,      0, 'B'},
+               {"force",       no_argument,    0, 'f'},
+               {"hwp-enable",  no_argument,    0, 'e'},
+               {"help",        no_argument,    0, 'h'},
+               {"hwp-epp",     required_argument,      0, 'P'},
+               {"hwp-min",     required_argument,      0, 'm'},
+               {"hwp-max",     required_argument,      0, 'M'},
+               {"read",        no_argument,            0, 'r'},
+               {"turbo-enable",        required_argument,      0, 't'},
+               {"hwp-use-pkg", required_argument,      0, 'u'},
+               {"version",     no_argument,            0, 'v'},
+               {"hwp-window",  required_argument,      0, 'w'},
+               {0,             0,                      0, 0 }
+       };
 
        progname = argv[0];
 
-       while ((opt = getopt(argc, argv, "+rvc:")) != -1) {
+       while ((opt = getopt_long_only(argc, argv, "+a:c:dD:E:e:f:m:M:rt:u:vw",
+                               long_options, &option_index)) != -1) {
                switch (opt) {
+               case 'a':
+                       parse_cmdline_all(optarg);
+                       break;
+               case 'B':
+                       new_epb = parse_cmdline_epb(parse_optarg_string(optarg));
+                       break;
                case 'c':
-                       cpu = atoi(optarg);
+                       parse_cmdline_cpu(optarg);
+                       break;
+               case 'e':
+                       update_hwp_enable = 1;
+                       break;
+               case 'h':
+                       usage();
+                       break;
+               case 'd':
+                       debug++;
+                       verbose++;
+                       break;
+               case 'f':
+                       force++;
+                       break;
+               case 'D':
+                       req_update.hwp_desired = parse_cmdline_hwp_desired(parse_optarg_string(optarg));
+                       break;
+               case 'm':
+                       req_update.hwp_min = parse_cmdline_hwp_min(parse_optarg_string(optarg));
+                       break;
+               case 'M':
+                       req_update.hwp_max = parse_cmdline_hwp_max(parse_optarg_string(optarg));
+                       break;
+               case 'p':
+                       parse_cmdline_pkg(optarg);
+                       break;
+               case 'P':
+                       req_update.hwp_epp = parse_cmdline_hwp_epp(parse_optarg_string(optarg));
                        break;
                case 'r':
-                       read_only = 1;
+                       /* v1 used -r to specify read-only mode, now the default */
+                       break;
+               case 't':
+                       turbo_update_value = parse_cmdline_turbo(parse_optarg_string(optarg));
+                       break;
+               case 'u':
+                       update_hwp_use_pkg++;
+                       if (atoi(optarg) == 0)
+                               req_update.hwp_use_pkg = 0;
+                       else
+                               req_update.hwp_use_pkg = 1;
                        break;
                case 'v':
-                       verbose++;
+                       print_version();
+                       exit(0);
+                       break;
+               case 'w':
+                       req_update.hwp_window = parse_cmdline_hwp_window(parse_optarg_string(optarg));
                        break;
                default:
                        usage();
                }
        }
-       /* if -r, then should be no additional optind */
-       if (read_only && (argc > optind))
-               usage();
-
        /*
-        * if no -r , then must be one additional optind
+        * v1 allowed "performance"|"normal"|"power" with no policy specifier
+        * to update BIAS.  Continue to support that, even though no longer documented.
         */
-       if (!read_only) {
+       if (argc == optind + 1)
+               new_epb = parse_cmdline_epb(parse_optarg_string(argv[optind]));
 
-               if (argc != optind + 1) {
-                       printf("must supply -r or policy param\n");
-                       usage();
-                       }
+       if (argc > optind + 1) {
+               fprintf(stderr, "stray parameter '%s'\n", argv[optind + 1]);
+               usage();
+       }
+}
 
-               if (!strcmp("performance", argv[optind])) {
-                       new_bias = BIAS_PERFORMANCE;
-               } else if (!strcmp("normal", argv[optind])) {
-                       new_bias = BIAS_BALANCE;
-               } else if (!strcmp("powersave", argv[optind])) {
-                       new_bias = BIAS_POWERSAVE;
-               } else {
-                       char *endptr;
-
-                       new_bias = strtoull(argv[optind], &endptr, 0);
-                       if (endptr == argv[optind] ||
-                               new_bias > BIAS_POWERSAVE) {
-                                       fprintf(stderr, "invalid value: %s\n",
-                                               argv[optind]);