summaryrefslogtreecommitdiff
path: root/src/sna/sna_cpu.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2013-03-26 15:44:42 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2013-03-26 15:44:42 +0000
commit9620f419076202ebc89b4c7f1c06374fb2554f28 (patch)
treeb5959a87c396c16a14b38528440a242b1b347a4a /src/sna/sna_cpu.c
parentda2bd82b0e10f8a263f7ab4fb49b440349d97ace (diff)
sna: Fix AVX2 detection
It requires use of the cpuid feature eax=7:ecx=0, so it requires the extended version of __cpuid to pass in the subfeature. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src/sna/sna_cpu.c')
-rw-r--r--src/sna/sna_cpu.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/sna/sna_cpu.c b/src/sna/sna_cpu.c
index 13869884..ab4942b6 100644
--- a/src/sna/sna_cpu.c
+++ b/src/sna/sna_cpu.c
@@ -41,10 +41,12 @@
unsigned sna_cpu_detect(void)
{
+ unsigned max = __get_cpuid_max(false, 0);
unsigned int eax, ebx, ecx, edx;
unsigned features = 0;
- if (__get_cpuid(1, &eax, &ebx, &ecx, &edx)) {
+ if (max >= 1) {
+ __cpuid(1, eax, ebx, ecx, edx);
if (ecx & bit_SSE3)
features |= SSE3;
@@ -70,7 +72,8 @@ unsigned sna_cpu_detect(void)
features |= SSE2;
}
- if (__get_cpuid(7, &eax, &ebx, &ecx, &edx)) {
+ if (max >= 7) {
+ __cpuid_count(7, 0, eax, ebx, ecx, edx);
if (ebx & bit_AVX2)
features |= AVX2;
}