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.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
36 #include <fm/fmd_api.h>
37 #include <sys/fm/protocol.h>
39 #include <sys/processor.h>
42 cma_cpu_blacklist(fmd_hdl_t
*hdl
, nvlist_t
*nvl
, nvlist_t
*asru
,
53 * Some platforms have special unums for the E$ DIMMs. If we're dealing
54 * with a platform that has these unums, one will have been added to the
55 * fault as the resource. We'll use that for the blacklisting. If we
56 * can't find a resource, we'll fall back to the ASRU.
58 if (nvlist_lookup_nvlist(nvl
, FM_FAULT_RESOURCE
, &fmri
) != 0)
61 if ((nvlist_lookup_string(nvl
, FM_CLASS
, &class) != 0) ||
62 (class == NULL
) || (*class == '\0')) {
63 fmd_hdl_debug(hdl
, "failed to get the fault class name\n");
68 if ((fd
= open("/dev/bl", O_RDONLY
)) < 0)
69 return (-1); /* errno is set for us */
71 if ((errno
= nvlist_size(fmri
, &fmrisz
, NV_ENCODE_NATIVE
)) != 0 ||
72 (fmribuf
= fmd_hdl_alloc(hdl
, fmrisz
, FMD_SLEEP
)) == NULL
) {
74 return (-1); /* errno is set for us */
77 if ((errno
= nvlist_pack(fmri
, &fmribuf
, &fmrisz
,
78 NV_ENCODE_NATIVE
, 0)) != 0) {
79 fmd_hdl_free(hdl
, fmribuf
, fmrisz
);
81 return (-1); /* errno is set for us */
84 blr
.bl_fmri
= fmribuf
;
85 blr
.bl_fmrisz
= fmrisz
;
88 rc
= ioctl(fd
, repair
? BLIOC_DELETE
: BLIOC_INSERT
, &blr
);
91 fmd_hdl_free(hdl
, fmribuf
, fmrisz
);
94 if (rc
< 0 && err
!= ENOTSUP
) {
104 cma_cpu_statechange(fmd_hdl_t
*hdl
, nvlist_t
*asru
, const char *uuid
,
105 int cpustate
, boolean_t repair
)
110 if (nvlist_lookup_uint32(asru
, FM_FMRI_CPU_ID
, &cpuid
) != 0) {
111 fmd_hdl_debug(hdl
, "missing '%s'\n", FM_FMRI_CPU_ID
);
112 cma_stats
.bad_flts
.fmds_value
.ui64
++;
113 return (CMA_RA_FAILURE
);
116 for (i
= 0; i
< cma
.cma_cpu_tries
;
117 i
++, (void) nanosleep(&cma
.cma_cpu_delay
, NULL
)) {
119 if ((oldstate
= p_online(cpuid
, cpustate
)) != -1) {
120 fmd_hdl_debug(hdl
, "changed cpu %u state from \"%s\" "
121 "to \"%s\"\n", cpuid
, p_online_state_fmt(oldstate
),
122 p_online_state_fmt(cpustate
));
124 cma_stats
.cpu_repairs
.fmds_value
.ui64
++;
126 cma_stats
.cpu_flts
.fmds_value
.ui64
++;
127 return (CMA_RA_SUCCESS
);
131 fmd_hdl_debug(hdl
, "failed to changed cpu %u state to \"%s\": %s\n",
132 cpuid
, p_online_state_fmt(cpustate
), strerror(errno
));
133 cma_stats
.cpu_fails
.fmds_value
.ui64
++;
134 return (CMA_RA_FAILURE
);