#ifndef _ASM_X86_CACHEINFO_H
 #define _ASM_X86_CACHEINFO_H
 
+/* Kernel controls MTRR and/or PAT MSRs. */
+extern unsigned int memory_caching_control;
+#define CACHE_MTRR 0x01
+#define CACHE_PAT  0x02
+
 void cacheinfo_amd_init_llc_id(struct cpuinfo_x86 *c, int cpu);
 void cacheinfo_hygon_init_llc_id(struct cpuinfo_x86 *c, int cpu);
 
 
 #include <linux/syscore_ops.h>
 #include <linux/rcupdate.h>
 
+#include <asm/cacheinfo.h>
 #include <asm/cpufeature.h>
 #include <asm/e820/api.h>
 #include <asm/mtrr.h>
 }
 
 /*  This function returns the number of variable MTRRs  */
-static void __init set_num_var_ranges(void)
+static void __init set_num_var_ranges(bool use_generic)
 {
        unsigned long config = 0, dummy;
 
-       if (use_intel())
+       if (use_generic)
                rdmsr(MSR_MTRRcap, config, dummy);
        else if (is_cpu(AMD) || is_cpu(HYGON))
                config = 2;
 
        if (mtrr_if) {
                __mtrr_enabled = true;
-               set_num_var_ranges();
+               set_num_var_ranges(mtrr_if == &generic_mtrr_ops);
                init_table();
-               if (use_intel()) {
+               if (mtrr_if == &generic_mtrr_ops) {
                        /* BIOS may override */
                        __mtrr_enabled = get_mtrr_state();
 
-                       if (mtrr_enabled())
+                       if (mtrr_enabled()) {
                                mtrr_bp_pat_init();
+                               memory_caching_control |= CACHE_MTRR | CACHE_PAT;
+                       }
 
                        if (mtrr_cleanup(phys_addr)) {
                                changed_by_mtrr_cleanup = 1;
 
 void mtrr_ap_init(void)
 {
-       if (!mtrr_enabled())
-               return;
-
-       if (!use_intel() || mtrr_aps_delayed_init)
+       if (!memory_caching_control || mtrr_aps_delayed_init)
                return;
 
        /*
 
 void set_mtrr_aps_delayed_init(void)
 {
-       if (!mtrr_enabled())
-               return;
-       if (!use_intel())
+       if (!memory_caching_control)
                return;
 
        mtrr_aps_delayed_init = true;
  */
 void mtrr_aps_init(void)
 {
-       if (!use_intel() || !mtrr_enabled())
+       if (!memory_caching_control)
                return;
 
        /*
 
 void mtrr_bp_restore(void)
 {
-       if (!use_intel() || !mtrr_enabled())
+       if (!memory_caching_control)
                return;
 
        mtrr_if->set_all();
        if (!mtrr_enabled())
                return 0;
 
-       if (use_intel()) {
+       if (memory_caching_control & CACHE_MTRR) {
                if (!changed_by_mtrr_cleanup)
                        mtrr_state_warn();
                return 0;
 
 
 struct mtrr_ops {
        u32     vendor;
-       u32     use_intel_if;
        void    (*set)(unsigned int reg, unsigned long base,
                       unsigned long size, mtrr_type type);
        void    (*set_all)(void);
 extern const struct mtrr_ops *mtrr_if;
 
 #define is_cpu(vnd)    (mtrr_if && mtrr_if->vendor == X86_VENDOR_##vnd)
-#define use_intel()    (mtrr_if && mtrr_if->use_intel_if == 1)
 
 extern unsigned int num_var_ranges;
 extern u64 mtrr_tom2;