From: Jianchuan Wang <jianchuan.w...@windriver.com>

commit 2b9c1f03278ab7cd421f14ce24dee39091ecb064 upstream

x86: align x86 arch with generic CPU modalias handling

The x86 CPU feature modalias handling existed before it was
reimplemented
generically. This patch aligns the x86 handling so that it
(a) reuses some more code that is now generic;
(b) uses the generic format for the modalias module metadata entry, i.e., it
    now uses 'cpu:type:x86,venVVVVfamFFFFmodMMMM:feature:,XXXX,YYYY' instead of
    the 'x86cpu:vendor:VVVV:family:FFFF:model:MMMM:feature:,XXXX,YYYY' that was
    used before.

Signed-off-by: Ard Biesheuvel <ard.biesheu...@linaro.org>
Acked-by: H. Peter Anvin <h...@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gre...@linuxfoundation.org>
Signed-off-by: Jianchuan Wang <jianchuan.w...@windriver.com>
---
 arch/x86/Kconfig                  |    4 +---
 arch/x86/include/asm/cpufeature.h |    8 ++++++++
 arch/x86/kernel/cpu/match.c       |   41 -------------------------------------
 drivers/base/Kconfig              |    7 +------
 drivers/base/cpu.c                |   12 ++++-------
 include/linux/cpu.h               |    7 -------
 scripts/mod/file2alias.c          |    8 ++++----
 7 files changed, 18 insertions(+), 69 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 0af5250..7fab7e0 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -127,6 +127,7 @@ config X86
        select HAVE_DEBUG_STACKOVERFLOW
        select HAVE_IRQ_EXIT_ON_IRQ_STACK if X86_64
        select HAVE_CC_STACKPROTECTOR
+       select GENERIC_CPU_AUTOPROBE
 
 config INSTRUCTION_DECODER
        def_bool y
@@ -195,9 +196,6 @@ config ARCH_HAS_CPU_RELAX
 config ARCH_HAS_CACHE_LINE_SIZE
        def_bool y
 
-config ARCH_HAS_CPU_AUTOPROBE
-       def_bool y
-
 config HAVE_SETUP_PER_CPU_AREA
        def_bool y
 
diff --git a/arch/x86/include/asm/cpufeature.h 
b/arch/x86/include/asm/cpufeature.h
index e099f95..0b3ba18 100644
--- a/arch/x86/include/asm/cpufeature.h
+++ b/arch/x86/include/asm/cpufeature.h
@@ -541,6 +541,14 @@ static __always_inline __pure bool 
_static_cpu_has_safe(u16 bit)
 #define static_cpu_has_bug(bit)        static_cpu_has((bit))
 #define boot_cpu_has_bug(bit)  cpu_has_bug(&boot_cpu_data, (bit))
 
+#define MAX_CPU_FEATURES        (NCAPINTS * 32)
+#define cpu_have_feature        boot_cpu_has
+#define cpu_feature(x)          ilog2(X86_FEATURE_ ## x) 
+
+#define CPU_FEATURE_TYPEFMT     "x86,ven%04Xfam%04Xmod%04X"
+#define CPU_FEATURE_TYPEVAL     boot_cpu_data.x86_vendor, boot_cpu_data.x86, \
+                                       boot_cpu_data.x86_model
+
 #endif /* defined(__KERNEL__) && !defined(__ASSEMBLY__) */
 
 #endif /* _ASM_X86_CPUFEATURE_H */
diff --git a/arch/x86/kernel/cpu/match.c b/arch/x86/kernel/cpu/match.c
index 3656537..d21b27b 100644
--- a/arch/x86/kernel/cpu/match.c
+++ b/arch/x86/kernel/cpu/match.c
@@ -48,44 +48,3 @@ const struct x86_cpu_id *x86_match_cpu(const struct 
x86_cpu_id *match)
 }
 EXPORT_SYMBOL(x86_match_cpu);
 
-ssize_t arch_print_cpu_modalias(struct device *dev,
-                               struct device_attribute *attr,
-                               char *bufptr)
-{
-       int size = PAGE_SIZE;
-       int i, n;
-       char *buf = bufptr;
-
-       n = snprintf(buf, size, "x86cpu:vendor:%04X:family:%04X:"
-                    "model:%04X:feature:",
-               boot_cpu_data.x86_vendor,
-               boot_cpu_data.x86,
-               boot_cpu_data.x86_model);
-       size -= n;
-       buf += n;
-       size -= 1;
-       for (i = 0; i < NCAPINTS*32; i++) {
-               if (boot_cpu_has(i)) {
-                       n = snprintf(buf, size, ",%04X", i);
-                       if (n >= size) {
-                               WARN(1, "x86 features overflow page\n");
-                               break;
-                       }
-                       size -= n;
-                       buf += n;
-               }
-       }
-       *buf++ = '\n';
-       return buf - bufptr;
-}
-
-int arch_cpu_uevent(struct device *dev, struct kobj_uevent_env *env)
-{
-       char *buf = kzalloc(PAGE_SIZE, GFP_KERNEL);
-       if (buf) {
-               arch_print_cpu_modalias(NULL, NULL, buf);
-               add_uevent_var(env, "MODALIAS=%s", buf);
-               kfree(buf);
-       }
-       return 0;
-}
diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig
index 3f0d373..79f68a5 100644
--- a/drivers/base/Kconfig
+++ b/drivers/base/Kconfig
@@ -185,13 +185,8 @@ config GENERIC_CPU_DEVICES
        bool
        default n
 
-config HAVE_CPU_AUTOPROBE
-       def_bool ARCH_HAS_CPU_AUTOPROBE
-
 config GENERIC_CPU_AUTOPROBE
-       bool
-       depends on !ARCH_HAS_CPU_AUTOPROBE
-       select HAVE_CPU_AUTOPROBE
+        bool
 
 config SOC_BUS
        bool
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index 860e6ff..e898afe 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -285,12 +285,11 @@ static void cpu_device_release(struct device *dev)
         * on the linux-kernel list, you have been warned.
         */
 }
- 
-#ifdef CONFIG_HAVE_CPU_AUTOPROBE
+
 #ifdef CONFIG_GENERIC_CPU_AUTOPROBE
-static ssize_t print_cpu_modalias(struct device *dev,
-                                 struct device_attribute *attr,
-                                 char *buf)
+static ssize_t print_cpu_modalias(struct device *dev, 
+                                struct device_attribute *attr, 
+                                char *buf)
 {
        ssize_t n;
        u32 i;
@@ -309,9 +308,6 @@ static ssize_t print_cpu_modalias(struct device *dev,
        buf[n++] = '\n';
        return n;
 }
-#else
-#define print_cpu_modalias     arch_print_cpu_modalias
-#endif
 
 static int cpu_uevent(struct device *dev, struct kobj_uevent_env *env)
 {
diff --git a/include/linux/cpu.h b/include/linux/cpu.h
index 03e235ad..03e962e 100644
--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -46,13 +46,6 @@ extern ssize_t arch_cpu_release(const char *, size_t);
 #endif
 struct notifier_block;
 
-#ifdef CONFIG_ARCH_HAS_CPU_AUTOPROBE
-extern int arch_cpu_uevent(struct device *dev, struct kobj_uevent_env *env);
-extern ssize_t arch_print_cpu_modalias(struct device *dev,
-                                      struct device_attribute *attr,
-                                      char *bufptr);
-#endif
-
 /*
  * CPU notifier priorities.
  */
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index 506146e..f657fa6 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -1124,10 +1124,10 @@ static int do_x86cpu_entry(const char *filename, void 
*symval,
        DEF_FIELD(symval, x86_cpu_id, model);
        DEF_FIELD(symval, x86_cpu_id, vendor);
 
-       strcpy(alias, "x86cpu:");
-       ADD(alias, "vendor:",  vendor != X86_VENDOR_ANY, vendor);
-       ADD(alias, ":family:", family != X86_FAMILY_ANY, family);
-       ADD(alias, ":model:",  model  != X86_MODEL_ANY,  model);
+       strcpy(alias, "cpu:type:x86,");
+       ADD(alias, "ven", vendor != X86_VENDOR_ANY, vendor);
+       ADD(alias, "fam", family != X86_FAMILY_ANY, family);
+       ADD(alias, "mod", model  != X86_MODEL_ANY,  model);
        strcat(alias, ":feature:*");
        if (feature != X86_FEATURE_ANY)
                sprintf(alias + strlen(alias), "%04X*", feature);
-- 
1.7.9.5

-- 
_______________________________________________
linux-yocto mailing list
linux-yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/linux-yocto

Reply via email to