Guest User

FreeBSD-11 AMD cpufreq patch

a guest
Aug 19th, 2016
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 3.67 KB | None | 0 0
  1. diff --git a/sys/x86/cpufreq/hwpstate.c b/sys/x86/cpufreq/hwpstate.c
  2. index d4c70b7..326d967 100644
  3. --- a/sys/x86/cpufreq/hwpstate.c
  4. +++ b/sys/x86/cpufreq/hwpstate.c
  5. @@ -408,25 +408,27 @@ hwpstate_get_info_from_msr(device_t dev)
  6.         hwpstate_set = sc->hwpstate_settings;
  7.         for (i = 0; i < sc->cfnum; i++) {
  8.                 msr = rdmsr(MSR_AMD_10H_11H_CONFIG + i);
  9. -               if ((msr & ((uint64_t)1 << 63)) != ((uint64_t)1 << 63)) {
  10. +               if ((msr & ((uint64_t)1 << 63)) == 0) {
  11.                         HWPSTATE_DEBUG(dev, "msr is not valid.\n");
  12.                         return (ENXIO);
  13.                 }
  14.                 did = AMD_10H_11H_CUR_DID(msr);
  15.                 fid = AMD_10H_11H_CUR_FID(msr);
  16. +               /* fid/did to frequency */
  17.                 switch(family) {
  18.                 case 0x11:
  19. -                       /* fid/did to frequency */
  20. -                       hwpstate_set[i].freq = 100 * (fid + 0x08) / (1 << did);
  21. +                       hwpstate_set[i].freq = (100 * (fid + 0x08)) >> did;
  22.                         break;
  23.                 case 0x10:
  24. -                       /* fid/did to frequency */
  25. -                       hwpstate_set[i].freq = 100 * (fid + 0x10) / (1 << did);
  26. +               case 0x12:
  27. +               case 0x14:
  28. +               case 0x15:
  29. +               case 0x16:
  30. +                       hwpstate_set[i].freq = (100 * (fid + 0x10)) >> did;
  31.                         break;
  32.                 default:
  33. -                       HWPSTATE_DEBUG(dev, "get_info_from_msr: AMD family %d CPU's are not implemented yet. sorry.\n", family);
  34. +                       HWPSTATE_DEBUG(dev, "get_info_from_msr: AMD family 0x%02x CPU's are not implemented yet. sorry.\n", family);
  35.                         return (ENXIO);
  36. -                       break;
  37.                 }
  38.                 hwpstate_set[i].pstate_id = i;
  39.                 /* There was volts calculation, but deleted it. */
  40. diff --git a/sys/x86/cpufreq/powernow.c b/sys/x86/cpufreq/powernow.c
  41. index cc62e87..355bde8 100644
  42. --- a/sys/x86/cpufreq/powernow.c
  43. +++ b/sys/x86/cpufreq/powernow.c
  44. @@ -866,17 +866,22 @@ static void
  45.  pn_identify(driver_t *driver, device_t parent)
  46.  {
  47.  
  48. -       if ((amd_pminfo & AMDPM_FID) == 0 || (amd_pminfo & AMDPM_VID) == 0)
  49. +       if ((amd_pminfo & AMDPM_FID) == 0 || (amd_pminfo & AMDPM_VID) == 0) {
  50. +               printf("powernow: pn_identify: amd_pminfo=0x%04x .\n", amd_pminfo);
  51.                 return;
  52. +       }
  53.         switch (cpu_id & 0xf00) {
  54.         case 0x600:
  55.         case 0xf00:
  56.                 break;
  57.         default:
  58. +               printf("powernow: pn_identify: cpu_id=0x%04x.\n", cpu_id);
  59.                 return;
  60.         }
  61. -       if (device_find_child(parent, "powernow", -1) != NULL)
  62. +       if (device_find_child(parent, "powernow", -1) != NULL) {
  63. +               printf("powernow: pn_identify: No \"powernow\"device found.\n");
  64.                 return;
  65. +       }
  66.         if (BUS_ADD_CHILD(parent, 10, "powernow", -1) == NULL)
  67.                 device_printf(parent, "powernow: add child failed\n");
  68.  }
  69. @@ -895,8 +900,10 @@ pn_probe(device_t dev)
  70.         status = rdmsr(MSR_AMDK7_FIDVID_STATUS);
  71.  
  72.         pc = cpu_get_pcpu(dev);
  73. -       if (pc == NULL)
  74. +       if (pc == NULL) {
  75. +               printf("powernow: cpu_get_pcpu() returned NULL.\n");
  76.                 return (ENODEV);
  77. +       }
  78.  
  79.         cpu_est_clockrate(pc->pc_cpuid, &rate);
  80.  
  81. @@ -936,6 +943,7 @@ pn_probe(device_t dev)
  82.                         device_set_desc(dev, "Cool`n'Quiet K8");
  83.                 break;
  84.         default:
  85. +               printf("powernow: cpuid 0x%04x & 0xf00 not matched.\n", cpu_id);
  86.                 return (ENODEV);
  87.         }
Add Comment
Please, Sign In to add comment