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
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
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]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 #include <sys/machsystm.h>
27 #include <sys/cpu.h>
28 #include <sys/intreg.h>
29 #include <sys/machcpuvar.h>
30 #include <vm/hat_sfmmu.h>
31 #include <sys/error.h>
32 #include <sys/hypervisor_api.h>
33
34 void
35 cpu_intrq_register(struct cpu *cpu)
36 {
37 struct machcpu *mcpup = &cpu->cpu_m;
38 uint64_t ret;
39
40 ret = hv_cpu_qconf(INTR_CPU_Q, mcpup->cpu_q_base_pa, cpu_q_entries);
41 if (ret != H_EOK)
42 cmn_err(CE_PANIC, "cpu%d: cpu_mondo queue configuration "
43 "failed, error %lu", cpu->cpu_id, ret);
44
45 ret = hv_cpu_qconf(INTR_DEV_Q, mcpup->dev_q_base_pa, dev_q_entries);
81 cpu->cpu_id);
82 return (ENOMEM);
83 }
84 /*
85 * va_to_pa() is too expensive to call for every crosscall
86 * so we do it here at init time and save it in machcpu.
87 */
88 mcpup->mondo_data_ra = va_to_pa(mcpup->mondo_data);
89
90 /*
91 * Allocate a per-cpu list of ncpu_guest_max for xcalls
92 */
93 size = ncpu_guest_max * sizeof (uint16_t);
94 if (size < INTR_REPORT_SIZE)
95 size = INTR_REPORT_SIZE;
96
97 /*
98 * contig_mem_alloc() requires size to be a power of 2.
99 * Increase size to a power of 2 if necessary.
100 */
101 if ((size & (size - 1)) != 0) {
102 size = 1 << highbit(size);
103 }
104
105 mcpup->cpu_list = contig_mem_alloc(size);
106
107 if (mcpup->cpu_list == NULL) {
108 cmn_err(CE_NOTE, "cpu%d: cpu cpu_list allocation failed",
109 cpu->cpu_id);
110 return (ENOMEM);
111 }
112 mcpup->cpu_list_ra = va_to_pa(mcpup->cpu_list);
113
114 /*
115 * Allocate sun4v interrupt and error queues.
116 */
117 size = cpu_q_entries * INTR_REPORT_SIZE;
118
119 mcpup->cpu_q_va = contig_mem_alloc(size);
120
121 if (mcpup->cpu_q_va == NULL) {
191 /*
192 * Free mondo data for xcalls.
193 */
194 if (mcpup->mondo_data) {
195 contig_mem_free(mcpup->mondo_data, INTR_REPORT_SIZE);
196 mcpup->mondo_data = NULL;
197 mcpup->mondo_data_ra = NULL;
198 }
199
200 /*
201 * Free per-cpu list of ncpu_guest_max for xcalls
202 */
203 cpu_list_size = ncpu_guest_max * sizeof (uint16_t);
204 if (cpu_list_size < INTR_REPORT_SIZE)
205 cpu_list_size = INTR_REPORT_SIZE;
206
207 /*
208 * contig_mem_alloc() requires size to be a power of 2.
209 * Increase size to a power of 2 if necessary.
210 */
211 if ((cpu_list_size & (cpu_list_size - 1)) != 0) {
212 cpu_list_size = 1 << highbit(cpu_list_size);
213 }
214
215 if (mcpup->cpu_list) {
216 contig_mem_free(mcpup->cpu_list, cpu_list_size);
217 mcpup->cpu_list = NULL;
218 mcpup->cpu_list_ra = NULL;
219 }
220
221 /*
222 * Free sun4v interrupt and error queues.
223 */
224 if (mcpup->cpu_q_va) {
225 cpu_q_size = cpu_q_entries * INTR_REPORT_SIZE;
226 contig_mem_free(mcpup->cpu_q_va, cpu_q_size);
227 mcpup->cpu_q_va = NULL;
228 mcpup->cpu_q_base_pa = NULL;
229 mcpup->cpu_q_size = 0;
230 }
231
|
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
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
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]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 #include <sys/sysmacros.h>
27 #include <sys/machsystm.h>
28 #include <sys/cpu.h>
29 #include <sys/intreg.h>
30 #include <sys/machcpuvar.h>
31 #include <vm/hat_sfmmu.h>
32 #include <sys/error.h>
33 #include <sys/hypervisor_api.h>
34
35 void
36 cpu_intrq_register(struct cpu *cpu)
37 {
38 struct machcpu *mcpup = &cpu->cpu_m;
39 uint64_t ret;
40
41 ret = hv_cpu_qconf(INTR_CPU_Q, mcpup->cpu_q_base_pa, cpu_q_entries);
42 if (ret != H_EOK)
43 cmn_err(CE_PANIC, "cpu%d: cpu_mondo queue configuration "
44 "failed, error %lu", cpu->cpu_id, ret);
45
46 ret = hv_cpu_qconf(INTR_DEV_Q, mcpup->dev_q_base_pa, dev_q_entries);
82 cpu->cpu_id);
83 return (ENOMEM);
84 }
85 /*
86 * va_to_pa() is too expensive to call for every crosscall
87 * so we do it here at init time and save it in machcpu.
88 */
89 mcpup->mondo_data_ra = va_to_pa(mcpup->mondo_data);
90
91 /*
92 * Allocate a per-cpu list of ncpu_guest_max for xcalls
93 */
94 size = ncpu_guest_max * sizeof (uint16_t);
95 if (size < INTR_REPORT_SIZE)
96 size = INTR_REPORT_SIZE;
97
98 /*
99 * contig_mem_alloc() requires size to be a power of 2.
100 * Increase size to a power of 2 if necessary.
101 */
102 if (!ISP2(size)) {
103 size = 1 << highbit(size);
104 }
105
106 mcpup->cpu_list = contig_mem_alloc(size);
107
108 if (mcpup->cpu_list == NULL) {
109 cmn_err(CE_NOTE, "cpu%d: cpu cpu_list allocation failed",
110 cpu->cpu_id);
111 return (ENOMEM);
112 }
113 mcpup->cpu_list_ra = va_to_pa(mcpup->cpu_list);
114
115 /*
116 * Allocate sun4v interrupt and error queues.
117 */
118 size = cpu_q_entries * INTR_REPORT_SIZE;
119
120 mcpup->cpu_q_va = contig_mem_alloc(size);
121
122 if (mcpup->cpu_q_va == NULL) {
192 /*
193 * Free mondo data for xcalls.
194 */
195 if (mcpup->mondo_data) {
196 contig_mem_free(mcpup->mondo_data, INTR_REPORT_SIZE);
197 mcpup->mondo_data = NULL;
198 mcpup->mondo_data_ra = NULL;
199 }
200
201 /*
202 * Free per-cpu list of ncpu_guest_max for xcalls
203 */
204 cpu_list_size = ncpu_guest_max * sizeof (uint16_t);
205 if (cpu_list_size < INTR_REPORT_SIZE)
206 cpu_list_size = INTR_REPORT_SIZE;
207
208 /*
209 * contig_mem_alloc() requires size to be a power of 2.
210 * Increase size to a power of 2 if necessary.
211 */
212 if (!ISP2(cpu_list_size)) {
213 cpu_list_size = 1 << highbit(cpu_list_size);
214 }
215
216 if (mcpup->cpu_list) {
217 contig_mem_free(mcpup->cpu_list, cpu_list_size);
218 mcpup->cpu_list = NULL;
219 mcpup->cpu_list_ra = NULL;
220 }
221
222 /*
223 * Free sun4v interrupt and error queues.
224 */
225 if (mcpup->cpu_q_va) {
226 cpu_q_size = cpu_q_entries * INTR_REPORT_SIZE;
227 contig_mem_free(mcpup->cpu_q_va, cpu_q_size);
228 mcpup->cpu_q_va = NULL;
229 mcpup->cpu_q_base_pa = NULL;
230 mcpup->cpu_q_size = 0;
231 }
232
|