x86/intel_rdt: Move special case code for Haswell to a quirk function

No functional change, but lay the ground work for other per-model
quirks.

Signed-off-by: Tony Luck <tony.luck@intel.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Fenghua" <fenghua.yu@intel.com>
Cc: Ravi V" <ravi.v.shankar@intel.com>
Cc: "Peter Zijlstra" <peterz@infradead.org>
Cc: "Stephane Eranian" <eranian@google.com>
Cc: "Andi Kleen" <ak@linux.intel.com>
Cc: "David Carrillo-Cisneros" <davidcc@google.com>
Cc: Vikas Shivappa <vikas.shivappa@linux.intel.com>
Link: http://lkml.kernel.org/r/f195a83751b5f8b1d8a78bd3c1914300c8fa3142.1503512900.git.tony.luck@intel.com

authored by

Tony Luck and committed by
Thomas Gleixner
0576113a 5707b46a

+28 -24
+28 -24
arch/x86/kernel/cpu/intel_rdt.c
··· 172 * is always 20 on hsw server parts. The minimum cache bitmask length 173 * allowed for HSW server is always 2 bits. Hardcode all of them. 174 */ 175 - static inline bool cache_alloc_hsw_probe(void) 176 { 177 - if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL && 178 - boot_cpu_data.x86 == 6 && 179 - boot_cpu_data.x86_model == INTEL_FAM6_HASWELL_X) { 180 - struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_L3]; 181 - u32 l, h, max_cbm = BIT_MASK(20) - 1; 182 183 - if (wrmsr_safe(IA32_L3_CBM_BASE, max_cbm, 0)) 184 - return false; 185 - rdmsr(IA32_L3_CBM_BASE, l, h); 186 187 - /* If all the bits were set in MSR, return success */ 188 - if (l != max_cbm) 189 - return false; 190 191 - r->num_closid = 4; 192 - r->default_ctrl = max_cbm; 193 - r->cache.cbm_len = 20; 194 - r->cache.shareable_bits = 0xc0000; 195 - r->cache.min_cbm_bits = 2; 196 - r->alloc_capable = true; 197 - r->alloc_enabled = true; 198 199 - return true; 200 - } 201 - 202 - return false; 203 } 204 205 /* ··· 641 { 642 bool ret = false; 643 644 - if (cache_alloc_hsw_probe()) 645 return true; 646 647 if (!boot_cpu_has(X86_FEATURE_RDT_A)) ··· 683 return !rdt_get_mon_l3_config(&rdt_resources_all[RDT_RESOURCE_L3]); 684 } 685 686 static __init bool get_rdt_resources(void) 687 { 688 rdt_alloc_capable = get_rdt_alloc_resources(); 689 rdt_mon_capable = get_rdt_mon_resources(); 690
··· 172 * is always 20 on hsw server parts. The minimum cache bitmask length 173 * allowed for HSW server is always 2 bits. Hardcode all of them. 174 */ 175 + static inline void cache_alloc_hsw_probe(void) 176 { 177 + struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_L3]; 178 + u32 l, h, max_cbm = BIT_MASK(20) - 1; 179 180 + if (wrmsr_safe(IA32_L3_CBM_BASE, max_cbm, 0)) 181 + return; 182 + rdmsr(IA32_L3_CBM_BASE, l, h); 183 184 + /* If all the bits were set in MSR, return success */ 185 + if (l != max_cbm) 186 + return; 187 188 + r->num_closid = 4; 189 + r->default_ctrl = max_cbm; 190 + r->cache.cbm_len = 20; 191 + r->cache.shareable_bits = 0xc0000; 192 + r->cache.min_cbm_bits = 2; 193 + r->alloc_capable = true; 194 + r->alloc_enabled = true; 195 196 + rdt_alloc_capable = true; 197 } 198 199 /* ··· 647 { 648 bool ret = false; 649 650 + if (rdt_alloc_capable) 651 return true; 652 653 if (!boot_cpu_has(X86_FEATURE_RDT_A)) ··· 689 return !rdt_get_mon_l3_config(&rdt_resources_all[RDT_RESOURCE_L3]); 690 } 691 692 + static __init void rdt_quirks(void) 693 + { 694 + switch (boot_cpu_data.x86_model) { 695 + case INTEL_FAM6_HASWELL_X: 696 + cache_alloc_hsw_probe(); 697 + break; 698 + } 699 + } 700 + 701 static __init bool get_rdt_resources(void) 702 { 703 + rdt_quirks(); 704 rdt_alloc_capable = get_rdt_alloc_resources(); 705 rdt_mon_capable = get_rdt_mon_resources(); 706