source: mainline/kernel/arch/sparc64/src/trap/sun4v/interrupt.c@ 05882233

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 05882233 was 05882233, checked in by Jiří Zárevúcky <jiri.zarevucky@…>, 7 years ago

Unify various barrier includes into <barrier.h>

  • Property mode set to 100644
File size: 3.8 KB
Line 
1/*
2 * Copyright (c) 2009 Pavel Rimsky
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 sparc64interrupt
30 * @{
31 */
32/** @file
33 */
34
35#include <arch/interrupt.h>
36#include <arch/trap/interrupt.h>
37#include <arch/sparc64.h>
38#include <interrupt.h>
39#include <ddi/irq.h>
40#include <stdint.h>
41#include <debug.h>
42#include <arch/asm.h>
43#include <barrier.h>
44#include <log.h>
45#include <arch.h>
46#include <mm/tlb.h>
47#include <config.h>
48#include <synch/spinlock.h>
49#include <arch/sun4v/hypercall.h>
50
51/** number of uint64_t-s in one CPU mondo message */
52#define CPU_MONDO_ENTRY_SIZE 8
53
54/** number of entries (messages) in the CPU mondo queue */
55#define CPU_MONDO_NENTRIES 8
56
57/** number of uint64_t-s in the CPU mondo queue */
58#define CPU_MONDO_QUEUE_SIZE ((CPU_MONDO_NENTRIES) * (CPU_MONDO_ENTRY_SIZE))
59
60/** used to identify CPU mondo queue in the hypercall */
61#define CPU_MONDO_QUEUE_ID 0x3c
62
63/** ASI for reading/writing CPU mondo head/tail registers */
64#define ASI_QUEUE 0x25
65
66/** VA for reading the CPU mondo tail */
67#define VA_CPU_MONDO_QUEUE_TAIL 0x3c8
68
69/** VA for reading/writing the CPU mondo head */
70#define VA_CPU_MONDO_QUEUE_HEAD 0x3c0
71
72/**
73 * array which contains CPU mondo queue for every CPU
74 */
75uint64_t cpu_mondo_queues[MAX_NUM_STRANDS][CPU_MONDO_QUEUE_SIZE]
76 __attribute__((aligned(CPU_MONDO_QUEUE_SIZE * sizeof(uint64_t))));
77
78/**
79 * Initializes CPU mondo queue for the current CPU.
80 */
81void sun4v_ipi_init(void)
82{
83 if (__hypercall_fast3(
84 CPU_QCONF,
85 CPU_MONDO_QUEUE_ID,
86 KA2PA(cpu_mondo_queues[CPU->id]),
87 CPU_MONDO_NENTRIES) != HV_EOK)
88 panic("Initializing mondo queue failed on CPU %" PRIu64 ".\n",
89 CPU->arch.id);
90}
91
92/**
93 * Handler of the CPU Mondo trap. Reads the message queue, updates the head
94 * register and processes the message (invokes a function call).
95 */
96void cpu_mondo(unsigned int tt, istate_t *istate)
97{
98#ifdef CONFIG_SMP
99 unsigned int tail = asi_u64_read(ASI_QUEUE, VA_CPU_MONDO_QUEUE_TAIL);
100 unsigned int head = asi_u64_read(ASI_QUEUE, VA_CPU_MONDO_QUEUE_HEAD);
101
102 while (head != tail) {
103 uint64_t data1 = cpu_mondo_queues[CPU->id][0];
104
105 head = (head + CPU_MONDO_ENTRY_SIZE * sizeof(uint64_t)) %
106 (CPU_MONDO_QUEUE_SIZE * sizeof(uint64_t));
107 asi_u64_write(ASI_QUEUE, VA_CPU_MONDO_QUEUE_HEAD, head);
108
109 if (data1 == (uintptr_t) tlb_shootdown_ipi_recv) {
110 ((void (*)(void)) data1)();
111 } else {
112 log(LF_ARCH, LVL_DEBUG, "Spurious interrupt on %" PRIu64
113 ", data = %" PRIx64 ".", CPU->arch.id, data1);
114 }
115 }
116#endif
117}
118
119/** @}
120 */
Note: See TracBrowser for help on using the repository browser.