Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp6426958rwj; Wed, 21 Dec 2022 15:40:17 -0800 (PST) X-Google-Smtp-Source: AMrXdXv6Ps1udFmqU7bk7lWmRvxDfICINIsYufyErEN4yYIxySk4YzMKiSjiv6T369NXf7Ov6D/3 X-Received: by 2002:a05:6a20:1455:b0:af:e13e:cd67 with SMTP id a21-20020a056a20145500b000afe13ecd67mr6014835pzi.6.1671666017735; Wed, 21 Dec 2022 15:40:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671666017; cv=none; d=google.com; s=arc-20160816; b=U6JJO1hvqe7RBqGFOenkstDel/Hm1/OultzXM7qlCGsBvUhLk+5ux/e++cG9Bbe3lv YpfMk/S/QZ8+v9vhyuNP2Jt6leDUaKxke555zrEoC7bj5cVwhWfBL+dMJp+xZ87K442M xWuEHrfIM4CX5sdpSYgJGCP4+SFkPbyrLoMSk0Uf799/E1t+ynzEDp+UJScyertllsV9 C0uyZ66wZ+h7prHuSMtA135UDbhKDwxzntkXDv0Hw96b/C/aheCp1po8YKu1pY0ipYzN K88egoR789YmNQPOdTtEWktjSFEC2UwZELtY1704jZfyI6cCGT0Uw/Gejz1ZzOd9S0ox 7m7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=HofYv7xJ+vW3IU3jOCsnTPsQMm9c2W5ouTH6LK996gQ=; b=RrOWoZqigiMl1tzogj1mo3Mb+qgY+e/7MP7BK/bHJlOW2yMT82Zu4v4jnSpX7oBnL5 qQzwYd2n5CQMxx2/BxNC4qgiBSD26wKpEjSsqWacTzO8jgOTwkoLtFSIFJ4q7p87XqJ1 EPY2/2j+Xkmo2V+ldPTckRKs4aoYrbidbbQTep9Y8KFgl6saFXboI5pQyLZeberzrb/g o4QiXqkgl9wpt4Rr5O47HU1+chn3ILmafYN0TiYt7Ay5UvaOYQ7xAyMb+baPkAYDGGMv hwnBvpJ4ivT2lN7wHmA3cg9wPafx54IDzrUTIMely5BIZqIDOw3EPqOxSsMv0tznFckv rUwQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d20-20020a621d14000000b00575d6a4ba9bsi16422939pfd.307.2022.12.21.15.40.07; Wed, 21 Dec 2022 15:40:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234763AbiLUWoY convert rfc822-to-8bit (ORCPT + 68 others); Wed, 21 Dec 2022 17:44:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229578AbiLUWoW (ORCPT ); Wed, 21 Dec 2022 17:44:22 -0500 X-Greylist: delayed 521 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Wed, 21 Dec 2022 14:44:19 PST Received: from cae.in-ulm.de (cae.in-ulm.de [217.10.14.231]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3048B1DA42 for ; Wed, 21 Dec 2022 14:44:19 -0800 (PST) Received: by cae.in-ulm.de (Postfix, from userid 1000) id EDFBF140119; Wed, 21 Dec 2022 23:35:36 +0100 (CET) Date: Wed, 21 Dec 2022 23:35:36 +0100 From: "Christian A. Ehrhardt" To: Thomas Gleixner Cc: Dave Hansen , Peter Zijlstra , Rishabh Agrawal , LKML , len.brown@intel.com, drake@endlessm.com, rafael.j.wysocki@intel.com, mingo@redhat.com, vaibhav.shankar@intel.com, biernacki@google.com, zwisler@google.com, mattedavis@google.com, Borislav Petkov , Dave Hansen , Feng Tang , Greg Kroah-Hartman , "H. Peter Anvin" , x86@kernel.org Subject: Re: [PATCH v2] Add hardcoded crystal clock for KabyLake Message-ID: References: <20221018190124.v2.1.I918ccc908c5c836c1e21e01d2cf6f59b0157bcc3@changeid> <3d65c4cc-c002-9e6a-c6ea-fd776968a178@intel.com> <87y1sdqh1t.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8BIT In-Reply-To: <87y1sdqh1t.ffs@tglx> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Mon, Nov 14, 2022 at 11:58:54PM +0100, Thomas Gleixner wrote: > On Thu, Oct 20 2022 at 10:18, Dave Hansen wrote: > > On 10/20/22 10:13, Peter Zijlstra wrote: > >> And why, pray *WHY* can't Intel simply write the correct information in > >> CPUID leaf 15h. I mean, they defined the leaf, might as well use it, no? > > > > Is the data that's in the leaf just wrong? Doesn't that mean that the > > CPUID leaf on these models is violating the architecture contract? That > > sounds like something that deserves an erratum. > > > > Is there a documented erratum? > > I don't know. The code has this comment: > > /* > * Some Intel SoCs like Skylake and Kabylake don't report the crystal > * clock, but we can easily calculate it to a high degree of accuracy > * by considering the crystal ratio and the CPU speed. > */ Latest (April 2022) version of the SDM clearly states that the above comment is wrong. CPUID.16h has the following note: | Data is returned from this interface in accordance with the processor's | specification and does not reflect actual values. Suitable use of this | data includes the display of processor information in like manner to the | processor brand string and for determining the appropriate range to use | when displaying processor information e.g. frequency history graphs. The | returned information should not be used for any other purpose as the | returned information does not accurately correlate to information / | counters returned by other processor interfaces. Thus using CPUID.16h to determine the crystal clock frequency is wrong. This difference is significant. I have one Kaby Lake latop where the CPUID.16h reported frequency is 1900MHz but the real frequency is only 1896MHz. This amounts to a time drift of about 8s/hour if the wrong TSC frequency is used for time keeping. Basically, I think this commit: 604dc9170 (x86/tsc: Use CPUID.0x16 to calculate ...) needs to be reverted. > so those SoCs fail to expose clock in leaf 15h and then the information > in leaf 16h is so inaccurate that the calculation is off. > > Sigh. It's 2022 and we are still relying on crystalball mechanisms to > figure out the damned crystal frequency. > > The specification of leaf 15h is: > > 15H Time Stamp Counter and Nominal Core Crystal Clock Information Leaf > NOTES: > If EBX[31:0] is 0, the TSC/”core crystal clock” ratio is not enumerated. > If ECX is 0, the nominal core crystal clock frequency is not enumerated. > > IOW, this CPUID leaf is defined to be useless and leaves it up to the > SoC integration to provide this information or not. It needs even two > fields to chose from to make it useless... The SDM (now?) has some hints on how to do this. This is hidden here: Vol.3 Chapter 19.7.3: Determining the Processor Base Frequency This chapter contains a table that lists the correct crystal clock frequencies for CPU models that do not enumerate it via CPUID.15h. regards Christian