source: mainline/kernel/arch/sparc64/src/smp/sun4u/smp.c@ 5110d0a

ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 5110d0a was c5429fe, checked in by Jakub Jermar <jakub@…>, 7 years ago

Disambiguate architecture specific doxygroups

  • Property mode set to 100644
File size: 4.0 KB
Line 
1/*
2 * Copyright (c) 2006 Jakub Jermar
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup kernel_sparc64
30 * @{
31 */
32/** @file
33 */
34
35#include <smp/smp.h>
36#include <genarch/ofw/ofw_tree.h>
37#include <cpu.h>
38#include <arch/cpu_family.h>
39#include <arch/cpu.h>
40#include <arch.h>
41#include <config.h>
42#include <macros.h>
43#include <stdint.h>
44#include <synch/waitq.h>
45#include <log.h>
46#include <arch/cpu_node.h>
47
48/**
49 * This global variable is used to pick-up application processors
50 * from their active loop in start.S. When a processor looping in
51 * start.S sees that this variable contains its MID, it can
52 * proceed with its initialization.
53 *
54 * This variable is modified only by the bootstrap processor.
55 * Other processors access it read-only.
56 */
57volatile uint64_t waking_up_mid = (uint64_t) -1;
58
59/** Determine number of processors. */
60void smp_init(void)
61{
62 ofw_tree_node_t *node;
63 unsigned int cnt = 0;
64
65 if (is_us() || is_us_iii()) {
66 node = ofw_tree_find_child_by_device_type(cpus_parent(), "cpu");
67 while (node) {
68 cnt++;
69 node = ofw_tree_find_peer_by_device_type(node, "cpu");
70 }
71 } else if (is_us_iv()) {
72 node = ofw_tree_find_child(cpus_parent(), "cmp");
73 while (node) {
74 cnt += 2;
75 node = ofw_tree_find_peer_by_name(node, "cmp");
76 }
77 }
78
79 config.cpu_count = max(1, cnt);
80}
81
82/**
83 * Wakes up the CPU which is represented by the "node" OFW tree node.
84 * If "node" represents the current CPU, calling the function has
85 * no effect.
86 */
87static void wakeup_cpu(ofw_tree_node_t *node)
88{
89 uint32_t mid;
90 ofw_tree_property_t *prop;
91
92 /* 'upa-portid' for US, 'portid' for US-III, 'cpuid' for US-IV */
93 prop = ofw_tree_getprop(node, "upa-portid");
94 if ((!prop) || (!prop->value))
95 prop = ofw_tree_getprop(node, "portid");
96 if ((!prop) || (!prop->value))
97 prop = ofw_tree_getprop(node, "cpuid");
98
99 if (!prop || prop->value == NULL)
100 return;
101
102 mid = *((uint32_t *) prop->value);
103 if (CPU->arch.mid == mid)
104 return;
105
106 waking_up_mid = mid;
107
108 if (waitq_sleep_timeout(&ap_completion_wq, 1000000,
109 SYNCH_FLAGS_NONE, NULL) == ETIMEOUT)
110 log(LF_ARCH, LVL_NOTE, "%s: waiting for processor (mid = %" PRIu32
111 ") timed out", __func__, mid);
112}
113
114/** Wake application processors up. */
115void kmp(void *arg)
116{
117 ofw_tree_node_t *node;
118 int i;
119
120 if (is_us() || is_us_iii()) {
121 node = ofw_tree_find_child_by_device_type(cpus_parent(), "cpu");
122 for (i = 0; node;
123 node = ofw_tree_find_peer_by_device_type(node, "cpu"), i++)
124 wakeup_cpu(node);
125 } else if (is_us_iv()) {
126 node = ofw_tree_find_child(cpus_parent(), "cmp");
127 while (node) {
128 wakeup_cpu(ofw_tree_find_child(node, "cpu@0"));
129 wakeup_cpu(ofw_tree_find_child(node, "cpu@1"));
130 node = ofw_tree_find_peer_by_name(node, "cmp");
131 }
132 }
133}
134
135/** @}
136 */
Note: See TracBrowser for help on using the repository browser.