|
5 | 5 | #include <linux/export.h>
|
6 | 6 | #include <linux/slab.h>
|
7 | 7 |
|
| 8 | +/** |
| 9 | + * x86_match_vendor_cpu_type - helper function to match the hardware defined |
| 10 | + * cpu-type for a single entry in the x86_cpu_id |
| 11 | + * table. Note, this function does not match the |
| 12 | + * generic cpu-types TOPO_CPU_TYPE_EFFICIENCY and |
| 13 | + * TOPO_CPU_TYPE_PERFORMANCE. |
| 14 | + * @c: Pointer to the cpuinfo_x86 structure of the CPU to match. |
| 15 | + * @m: Pointer to the x86_cpu_id entry to match against. |
| 16 | + * |
| 17 | + * Return: true if the cpu-type matches, false otherwise. |
| 18 | + */ |
| 19 | +static bool x86_match_vendor_cpu_type(struct cpuinfo_x86 *c, const struct x86_cpu_id *m) |
| 20 | +{ |
| 21 | + if (m->type == X86_CPU_TYPE_ANY) |
| 22 | + return true; |
| 23 | + |
| 24 | + /* Hybrid CPUs are special, they are assumed to match all cpu-types */ |
| 25 | + if (cpu_feature_enabled(X86_FEATURE_HYBRID_CPU)) |
| 26 | + return true; |
| 27 | + |
| 28 | + if (c->x86_vendor == X86_VENDOR_INTEL) |
| 29 | + return m->type == c->topo.intel_type; |
| 30 | + if (c->x86_vendor == X86_VENDOR_AMD) |
| 31 | + return m->type == c->topo.amd_type; |
| 32 | + |
| 33 | + return false; |
| 34 | +} |
| 35 | + |
8 | 36 | /**
|
9 | 37 | * x86_match_cpu - match current CPU against an array of x86_cpu_ids
|
10 | 38 | * @match: Pointer to array of x86_cpu_ids. Last entry terminated with
|
@@ -50,6 +78,8 @@ const struct x86_cpu_id *x86_match_cpu(const struct x86_cpu_id *match)
|
50 | 78 | continue;
|
51 | 79 | if (m->feature != X86_FEATURE_ANY && !cpu_has(c, m->feature))
|
52 | 80 | continue;
|
| 81 | + if (!x86_match_vendor_cpu_type(c, m)) |
| 82 | + continue; |
53 | 83 | return m;
|
54 | 84 | }
|
55 | 85 | return NULL;
|
|
0 commit comments