#include <linux/export.h>
 #include <linux/spinlock.h>
 #include <linux/pci_ids.h>
+
 #include <asm/amd_nb.h>
+#include <asm/cpuid.h>
 
 static u32 *flush_words;
 
        if (amd_gart_present())
                amd_northbridges.flags |= AMD_NB_GART;
 
-       /*
-        * Check for L3 cache presence.
-        */
-       if (!cpuid_edx(0x80000006))
+       if (!cpuid_amd_hygon_has_l3_cache())
                return 0;
 
        /*
 
        return i;
 }
 
+/*
+ * AMD/Hygon CPUs may have multiple LLCs if L3 caches exist.
+ */
+
 void cacheinfo_amd_init_llc_id(struct cpuinfo_x86 *c, u16 die_id)
 {
-       /*
-        * We may have multiple LLCs if L3 caches exist, so check if we
-        * have an L3 cache by looking at the L3 cache CPUID leaf.
-        */
-       if (!cpuid_edx(0x80000006))
+       if (!cpuid_amd_hygon_has_l3_cache())
                return;
 
        if (c->x86 < 0x17) {
-               /* LLC is at the node level. */
+               /* Pre-Zen: LLC is at the node level */
                c->topo.llc_id = die_id;
        } else if (c->x86 == 0x17 && c->x86_model <= 0x1F) {
                /*
-                * LLC is at the core complex level.
-                * Core complex ID is ApicId[3] for these processors.
+                * Family 17h up to 1F models: LLC is at the core
+                * complex level.  Core complex ID is ApicId[3].
                 */
                c->topo.llc_id = c->topo.apicid >> 3;
        } else {
                /*
-                * LLC ID is calculated from the number of threads sharing the
-                * cache.
-                * */
+                * Newer families: LLC ID is calculated from the number
+                * of threads sharing the L3 cache.
+                */
                u32 eax, ebx, ecx, edx, num_sharing_cache = 0;
                u32 llc_index = find_num_cache_leaves(c) - 1;
 
 
 void cacheinfo_hygon_init_llc_id(struct cpuinfo_x86 *c)
 {
-       /*
-        * We may have multiple LLCs if L3 caches exist, so check if we
-        * have an L3 cache by looking at the L3 cache CPUID leaf.
-        */
-       if (!cpuid_edx(0x80000006))
+       if (!cpuid_amd_hygon_has_l3_cache())
                return;
 
        /*
-        * LLC is at the core complex level.
-        * Core complex ID is ApicId[3] for these processors.
+        * Hygons are similar to AMD Family 17h up to 1F models: LLC is
+        * at the core complex level.  Core complex ID is ApicId[3].
         */
        c->topo.llc_id = c->topo.apicid >> 3;
 }