1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <cma.h>
#include <fcntl.h>
#include <unistd.h>
#include <strings.h>
#include <errno.h>
#include <time.h>
#include <fm/fmd_api.h>
#include <sys/fm/protocol.h>
#include <sys/bl.h>
#include <sys/processor.h>
int
cma_cpu_blacklist(fmd_hdl_t *hdl, nvlist_t *nvl, nvlist_t *asru,
boolean_t repair)
{
bl_req_t blr;
nvlist_t *fmri;
char *fmribuf;
size_t fmrisz;
int fd, rc, err;
char *class;
/*
* Some platforms have special unums for the E$ DIMMs. If we're dealing
* with a platform that has these unums, one will have been added to the
* fault as the resource. We'll use that for the blacklisting. If we
* can't find a resource, we'll fall back to the ASRU.
*/
if (nvlist_lookup_nvlist(nvl, FM_FAULT_RESOURCE, &fmri) != 0)
fmri = asru;
if ((nvlist_lookup_string(nvl, FM_CLASS, &class) != 0) ||
(class == NULL) || (*class == '\0')) {
fmd_hdl_debug(hdl, "failed to get the fault class name\n");
errno = EINVAL;
return (-1);
}
if ((fd = open("/dev/bl", O_RDONLY)) < 0)
return (-1); /* errno is set for us */
if ((errno = nvlist_size(fmri, &fmrisz, NV_ENCODE_NATIVE)) != 0 ||
(fmribuf = fmd_hdl_alloc(hdl, fmrisz, FMD_SLEEP)) == NULL) {
(void) close(fd);
return (-1); /* errno is set for us */
}
if ((errno = nvlist_pack(fmri, &fmribuf, &fmrisz,
NV_ENCODE_NATIVE, 0)) != 0) {
fmd_hdl_free(hdl, fmribuf, fmrisz);
(void) close(fd);
return (-1); /* errno is set for us */
}
blr.bl_fmri = fmribuf;
blr.bl_fmrisz = fmrisz;
blr.bl_class = class;
rc = ioctl(fd, repair ? BLIOC_DELETE : BLIOC_INSERT, &blr);
err = errno;
fmd_hdl_free(hdl, fmribuf, fmrisz);
(void) close(fd);
if (rc < 0 && err != ENOTSUP) {
errno = err;
return (-1);
}
return (0);
}
/* ARGSUSED */
int
cma_cpu_statechange(fmd_hdl_t *hdl, nvlist_t *asru, const char *uuid,
int cpustate, boolean_t repair)
{
int i;
uint_t cpuid;
if (nvlist_lookup_uint32(asru, FM_FMRI_CPU_ID, &cpuid) != 0) {
fmd_hdl_debug(hdl, "missing '%s'\n", FM_FMRI_CPU_ID);
cma_stats.bad_flts.fmds_value.ui64++;
return (CMA_RA_FAILURE);
}
for (i = 0; i < cma.cma_cpu_tries;
i++, (void) nanosleep(&cma.cma_cpu_delay, NULL)) {
int oldstate;
if ((oldstate = p_online(cpuid, cpustate)) != -1) {
fmd_hdl_debug(hdl, "changed cpu %u state from \"%s\" "
"to \"%s\"\n", cpuid, p_online_state_fmt(oldstate),
p_online_state_fmt(cpustate));
if (repair)
cma_stats.cpu_repairs.fmds_value.ui64++;
else
cma_stats.cpu_flts.fmds_value.ui64++;
return (CMA_RA_SUCCESS);
}
}
fmd_hdl_debug(hdl, "failed to changed cpu %u state to \"%s\": %s\n",
cpuid, p_online_state_fmt(cpustate), strerror(errno));
cma_stats.cpu_fails.fmds_value.ui64++;
return (CMA_RA_FAILURE);
}
|