)]}'
{
  "commit": "fbb16e243887332dd5754e48ffe5b963378f3cd2",
  "tree": "774bf58f1d23db0c3f167ff30fb6cdeb674d6980",
  "parents": [
    "8b76f46a2db29407fed66cf4aca19d61b3dcb3e1"
  ],
  "author": {
    "name": "Thomas Gleixner",
    "email": "tglx@linutronix.de",
    "time": "Wed Sep 03 00:54:47 2008 +0200"
  },
  "committer": {
    "name": "Linus Torvalds",
    "email": "torvalds@linux-foundation.org",
    "time": "Tue Sep 02 20:35:56 2008 -0700"
  },
  "message": "[x86] Fix TSC calibration issues\n\nLarry Finger reported at http://lkml.org/lkml/2008/9/1/90:\nAn ancient laptop of mine started throwing errors from b43legacy when\nI started using 2.6.27 on it. This has been bisected to commit bfc0f59\n\"x86: merge tsc calibration\".\n\nThe unification of the TSC code adopted mostly the 64bit code, which\nprefers PMTIMER/HPET over the PIT calibration.\n\nLarrys system has an AMD K6 CPU. Such systems are known to have\nPMTIMER incarnations which run at double speed. This results in a\nmiscalibration of the TSC by factor 0.5. So the resulting calibrated\nCPU/TSC speed is half of the real CPU speed, which means that the TSC\nbased delay loop will run half the time it should run. That might\nexplain why the b43legacy driver went berserk.\n\nOn the other hand we know about systems, where the PIT based\ncalibration results in random crap due to heavy SMI/SMM\ndisturbance. On those systems the PMTIMER/HPET based calibration logic\nwith SMI detection shows better results.\n\nAccording to Alok also virtualized systems suffer from the PIT\ncalibration method.\n\nThe solution is to use a more wreckage aware aproach than the current\neither/or decision.\n\n1) reimplement the retry loop which was dropped from the 32bit code\nduring the merge. It repeats the calibration and selects the lowest\nfrequency value as this is probably the closest estimate to the real\nfrequency\n\n2) Monitor the delta of the TSC values in the delay loop which waits\nfor the PIT counter to reach zero. If the maximum value is\nsignificantly different from the minimum, then we have a pretty safe\nindicator that the loop was disturbed by an SMI.\n\n3) keep the pmtimer/hpet reference as a backup solution for systems\nwhere the SMI disturbance is a permanent point of failure for PIT\nbased calibration\n\n4) do the loop iteration for both methods, record the lowest value and\ndecide after all iterations finished.\n\n5) Set a clear preference to PIT based calibration when the result\nmakes sense.\n\nThe implementation does the reference calibration based on\nHPET/PMTIMER around the delay, which is necessary for the PIT anyway,\nbut keeps separate TSC values to ensure the \"independency\" of the\nresulting calibration values.\n\nTested on various 32bit/64bit machines including Geode 266Mhz, AMD K6\n(affected machine with a double speed pmtimer which I grabbed out of\nthe dump), Pentium class machines and AMD/Intel 64 bit boxen.\n\nBisected-by:  Larry Finger \u003cLarry.Finger@lwfinger.net\u003e\nSigned-off-by: Thomas Gleixner \u003ctglx@linutronix.de\u003e\nTested-by: Larry Finger \u003cLarry.Finger@lwfinger.net\u003e\nSigned-off-by: Linus Torvalds \u003ctorvalds@linux-foundation.org\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "8e786b0d665a42e1f24dc7a068ec21fa0a654eeb",
      "old_mode": 33188,
      "old_path": "arch/x86/kernel/tsc.c",
      "new_id": "ac79bd143da8beb524e8881bb88953ae5afa9ada",
      "new_mode": 33188,
      "new_path": "arch/x86/kernel/tsc.c"
    }
  ]
}
