Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/x86/x86 Compute Core/SMT-IDs for AMD family 17h (Ry...



details:   https://anonhg.NetBSD.org/src/rev/ca8d5a00e42e
branches:  trunk
changeset: 829391:ca8d5a00e42e
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Sun Jan 28 16:32:43 2018 +0000

description:
Compute Core/SMT-IDs for AMD family 17h (Ryzen).

diffstat:

 sys/arch/x86/x86/cpu_topology.c |  14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diffs (35 lines):

diff -r 3c6bce9af9af -r ca8d5a00e42e sys/arch/x86/x86/cpu_topology.c
--- a/sys/arch/x86/x86/cpu_topology.c   Sun Jan 28 16:15:41 2018 +0000
+++ b/sys/arch/x86/x86/cpu_topology.c   Sun Jan 28 16:32:43 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu_topology.c,v 1.12 2018/01/28 16:15:41 mlelstv Exp $        */
+/*     $NetBSD: cpu_topology.c,v 1.13 2018/01/28 16:32:43 mlelstv Exp $        */
 
 /*-
  * Copyright (c) 2009 Mindaugas Rasiukevicius <rmind at NetBSD org>,
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu_topology.c,v 1.12 2018/01/28 16:15:41 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_topology.c,v 1.13 2018/01/28 16:32:43 mlelstv Exp $");
 
 #include <sys/param.h>
 #include <sys/bitops.h>
@@ -151,6 +151,16 @@
                }
        }
 
+       /* Family 0x17 supports SMT */
+       if (cpu_vendor == CPUVENDOR_AMD && cpu_family == 0x17) { /* XXX */
+               x86_cpuid(0x8000001e, descs);
+               const u_int threads = ((descs[1] >> 8) & 0xff) + 1;
+
+               KASSERT(smt_bits == 0 && smt_bits <= core_bits);
+               smt_bits = ilog2(threads);
+               core_bits -= smt_bits;
+       }
+
        if (smt_bits + core_bits) {
                if (smt_bits + core_bits < sizeof(apic_id) * NBBY)
                        ci->ci_package_id = apic_id >> (smt_bits + core_bits);



Home | Main Index | Thread Index | Old Index