Skip to contentSkip to conversation

x86_64: remove check for CONSTANT_TSC from time.c

PATCH In review Joerg Roedel 3 participants 4 messages Jun 4, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86_64: remove check for CONSTANT_TSC from time.c

From: Joerg Roedel <[email protected]>

This patch removes the check for the CONSTANT_TSC cpu flag from time.c on the x86_64 architecture. At the time this flag is checked at boot the cpu init code was yet not executed and thus the check fails. At this point the check for VENDOR_AMD and cpu family 0x10 is sufficient.

Signature · 6 lines
           |           AMD Saxony Limited Liability Company & Co. KG
 Operating |         Wilschdorfer Landstr. 101, 01109 Dresden, Germany
 System    |                  Register Court Dresden: HRA 4896
 Research  |              General Partner authorized to represent:
 Center    |             AMD Saxony LLC (Wilmington, Delaware, US)
           | General Manager of AMD Saxony LLC: Dr. Hans-R. Deppe, Thomas McCoy
arch/x86_64/kernel/time.c +2 -2
index 4a0895b..8b29928 100644
@@ -394,9 +394,9 @@ void __init time_init(void)
 	}
 
 	cpu_khz = tsc_khz;
-	if (cpu_has(&boot_cpu_data, X86_FEATURE_CONSTANT_TSC) &&
-		boot_cpu_data.x86_vendor == X86_VENDOR_AMD &&
+	if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD &&
 		boot_cpu_data.x86 == 16)
+		/* AMD Family 0x10 processors have a constant tsc */
 		cpu_khz = tsc_calibrate_cpu_khz();
 
 	if (unsynchronized_tsc())
#1 lore raw
Quoted 6 lines · Joerg Roedel

From: Joerg Roedel <[email protected]>

This patch removes the check for the CONSTANT_TSC cpu flag from time.c on the x86_64 architecture. At the time this flag is checked at boot the cpu init code was yet not executed and thus the check fails. At this point the check for VENDOR_AMD and cpu family 0x10 is sufficient.

Wrong fix. The bit just needs to be set earlier in early cpu detect. Otherwise there is a problem again with the next constant TSC AMD CPU.
I will do that.

-Andi

#2 lore raw
Quoted 8 lines · Andi Kleen
Quoted 6 lines · Joerg Roedel

From: Joerg Roedel <[email protected]>

This patch removes the check for the CONSTANT_TSC cpu flag from time.c on the x86_64 architecture. At the time this flag is checked at boot the cpu init code was yet not executed and thus the check fails. At this point the check for VENDOR_AMD and cpu family 0x10 is sufficient.

Quoted 5 lines

Wrong fix. The bit just needs to be set earlier in early cpu detect. Otherwise there is a problem again with the next constant TSC AMD CPU.
I will do that.

-Andi

Ok. But I assume you are meaning something like the attached diff?

Signature · 6 lines
           |           AMD Saxony Limited Liability Company & Co. KG
 Operating |         Wilschdorfer Landstr. 101, 01109 Dresden, Germany
 System    |                  Register Court Dresden: HRA 4896
 Research  |              General Partner authorized to represent:
 Center    |             AMD Saxony LLC (Wilmington, Delaware, US)
           | General Manager of AMD Saxony LLC: Dr. Hans-R. Deppe, Thomas McCoy
arch/x86_64/kernel/setup.c +7 -0
index eb6524f..d16f7c2 100644
@@ -806,6 +806,7 @@ void __cpuinit early_identify_cpu(struct cpuinfo_x86 *c)
 			c->x86_model += ((tfms >> 16) & 0xF) << 4;
 		if (c->x86_capability[0] & (1<<19)) 
 			c->x86_clflush_size = ((misc >> 8) & 0xff) * 8;
+		c->extended_cpuid_level = cpuid_eax(0x80000000);
 	} else {
 		/* Have CPUID level 0 only - unheard of */
 		c->x86 = 4;
@@ -814,6 +815,12 @@ void __cpuinit early_identify_cpu(struct cpuinfo_x86 *c)
 #ifdef CONFIG_SMP
 	c->phys_proc_id = (cpuid_ebx(1) >> 24) & 0xff;
 #endif
+
+	/* power flags are 8000_0007 edx. Bit 8 is constant TSC */
+	if ((c->x86_vendor == X86_VENDOR_AMD) &&
+	    (c->extended_cpuid_level >= 0x80000007) &&
+	    (cpuid_edx(0x80000007) & (1<<8)))
+		set_bit(X86_FEATURE_CONSTANT_TSC, &c->x86_capability);
 }
 
 /*
#3 lore raw

Yes, the attached patch works for me. Andi, is this patch acceptable?

Regards,
--
Bhavana Nagendra
AMD, Inc

-----Original Message-----
From: Joerg Roedel [mailto:[email protected]]
Sent: Monday, June 04, 2007 4:42 PM
To: Andi Kleen
Cc: [email protected]; Deguara, Joachim; Nagendra, Bhavana
Subject: Re: [PATCH] x86_64: remove check for CONSTANT_TSC from time.c

Quoted 4 lines · Andi Kleen
Quoted 3 lines · Joerg Roedel

From: Joerg Roedel <[email protected]>

This patch removes the check for the CONSTANT_TSC cpu flag from

time.c

Quoted 1 line
Quoted 1 line

on the x86_64 architecture. At the time this flag is checked at boot

the

Quoted 4 lines
Quoted 2 lines

cpu init code was yet not executed and thus the check fails. At this point the check for VENDOR_AMD and cpu family 0x10 is sufficient.

Wrong fix. The bit just needs to be set earlier in early cpu detect.

Otherwise

Quoted 4 lines

there is a problem again with the next constant TSC AMD CPU. I will do that.

-Andi

Ok. But I assume you are meaning something like the attached diff?

Signature · 7 lines
           |           AMD Saxony Limited Liability Company & Co. KG
 Operating |         Wilschdorfer Landstr. 101, 01109 Dresden, Germany
 System    |                  Register Court Dresden: HRA 4896
 Research  |              General Partner authorized to represent:
 Center    |             AMD Saxony LLC (Wilmington, Delaware, US)
           | General Manager of AMD Saxony LLC: Dr. Hans-R. Deppe,
Thomas McCoy