PATCH: cpufreq(4) support for modern AMD processors (git format)

Anthony Jenkins Scoobi_doo at yahoo.com
Fri Sep 25 16:58:27 UTC 2015


sys/x86/cpufreq/hwpstate.c provides support for AMD CPUs, but only
supports families up to 0x11.  The latest AMD CPU family is 0x16.  This
patch adds support for newer AMD CPUs.  (The patch to
sys/x86/cpufreq/powernow.c is cosmetic/superfluous.)  Sources: BIOS and
Kernel Developer's Guide for AMD Family (10h|11h|12h|14h Models *|15h
Models *|16h Models *) Processors

I'm still looking into the occasional 'hwpstate0: set freq failed, err
6' error.  hwpstate0 reports "error: loop is not enough" when attempting
to set the P-state on my cores.

        CPU_FOREACH(i) {
                /* Bind to each cpu. */
                thread_lock(curthread);
                sched_bind(curthread, i);
                thread_unlock(curthread);
                /* wait loop (100*100 usec is enough ?) */
                for(j = 0; j < 100; j++){
                        /* get the result. not assure msr=id */
                        msr = rdmsr(MSR_AMD_10H_11H_STATUS);
                        if(msr == id){
                                break;
                        }
                        DELAY(100);
                }
                HWPSTATE_DEBUG(dev, "result  P%d-state on cpu%d\n",
                    (int)msr, PCPU_GET(cpuid));
                if (msr != id) {
                        HWPSTATE_DEBUG(dev, "error: loop is not enough.\n");
                        error = ENXIO;
                }
        }

I haven't figured out a more deterministic way of knowing when to read
the MSR after requesting the new P-state...still wading through the AMD
CPU manuals.

-- 
Anthony Jenkins
Software Engineer
Zenterio, Inc. USA

-------------- next part --------------
A non-text attachment was scrubbed...
Name: amd_hwpstate_support.patch
Type: text/x-patch
Size: 2836 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-mobile/attachments/20150925/c552c242/attachment.bin>


More information about the freebsd-mobile mailing list