ao_main.c (8d7f0877) ao_main.c (8a40a695)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 29 unchanged lines hidden (view full) ---

38#include <sys/x86_archext.h>
39#include <sys/kmem.h>
40#include <sys/modctl.h>
41#include <sys/mc.h>
42#include <sys/mca_x86.h>
43
44#include "ao.h"
45
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 29 unchanged lines hidden (view full) ---

38#include <sys/x86_archext.h>
39#include <sys/kmem.h>
40#include <sys/modctl.h>
41#include <sys/mc.h>
42#include <sys/mca_x86.h>
43
44#include "ao.h"
45
46static struct ao_chipshared *ao_shared[CHIP_MAX_CHIPS];
47
46/*
48/*
47 * At present this CPU module only supports the features for Athlon64 and
48 * Opteron up to and including the Rev E processor. If we detect Rev F or
49 * later, return ENOTSUP and let the generic x86 CPU module load instead.
50 * Opteron Rev F is currently defined as Family 0xF Model [0x40 .. 0x5F].
49 * This cpu module supports AMD family 0xf revisions B/C/D/E/F/G. If
50 * a family 0xf cpu beyond the rev G model limit is detected then
51 * return ENOTSUP and let the generic x86 CPU module load instead.
51 */
52 */
52uint_t ao_model_limit = 0x40;
53uint_t ao_model_limit = 0x6f;
53
54static int
55ao_init(cpu_t *cp, void **datap)
56{
54
55static int
56ao_init(cpu_t *cp, void **datap)
57{
58 uint_t chipid = chip_plat_get_chipid(CPU);
59 struct ao_chipshared *sp, *osp;
57 ao_data_t *ao;
58 uint64_t cap;
59
60 if (cpuid_getmodel(cp) >= ao_model_limit)
61 return (ENOTSUP);
62
63 if (!(x86_feature & X86_MCA))
64 return (ENOTSUP);
65
66 cap = rdmsr(IA32_MSR_MCG_CAP);
67 if (!(cap & MCG_CAP_CTL_P))
68 return (ENOTSUP);
69
70 ao = *datap = kmem_zalloc(sizeof (ao_data_t), KM_SLEEP);
71 ao->ao_cpu = cp;
72
60 ao_data_t *ao;
61 uint64_t cap;
62
63 if (cpuid_getmodel(cp) >= ao_model_limit)
64 return (ENOTSUP);
65
66 if (!(x86_feature & X86_MCA))
67 return (ENOTSUP);
68
69 cap = rdmsr(IA32_MSR_MCG_CAP);
70 if (!(cap & MCG_CAP_CTL_P))
71 return (ENOTSUP);
72
73 ao = *datap = kmem_zalloc(sizeof (ao_data_t), KM_SLEEP);
74 ao->ao_cpu = cp;
75
76 /*
77 * Allocate the chipshared structure if it appears not to have been
78 * allocated already (by a sibling core). Install the newly
79 * allocated pointer atomically in case a sibling core beats
80 * us to it.
81 */
82 if ((sp = ao_shared[chipid]) == NULL) {
83 sp = kmem_zalloc(sizeof (struct ao_chipshared), KM_SLEEP);
84 osp = atomic_cas_ptr(&ao_shared[chipid], NULL, sp);
85 if (osp != NULL) {
86 kmem_free(sp, sizeof (struct ao_chipshared));
87 sp = osp;
88 }
89 }
90 ao->ao_shared = sp;
91
73 return (0);
74}
75
76/*ARGSUSED*/
77static void
78ao_post_mpstartup(void *data)
79{
80 (void) ddi_install_driver("mc-amd");

--- 71 unchanged lines hidden ---
92 return (0);
93}
94
95/*ARGSUSED*/
96static void
97ao_post_mpstartup(void *data)
98{
99 (void) ddi_install_driver("mc-amd");

--- 71 unchanged lines hidden ---