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
|
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (C) 2021 Western Digital Corporation or its affiliates.
* Copyright (C) 2022 Ventana Micro Systems Inc.
*/
#ifndef _IRQ_RISCV_IMSIC_STATE_H
#define _IRQ_RISCV_IMSIC_STATE_H
#include <linux/irqchip/riscv-imsic.h>
#include <linux/irqdomain.h>
#include <linux/fwnode.h>
#include <linux/timer.h>
#define IMSIC_IPI_ID 1
#define IMSIC_NR_IPI 8
struct imsic_vector {
/* Fixed details of the vector */
unsigned int cpu;
unsigned int local_id;
/* Details saved by driver in the vector */
unsigned int hwirq;
/* Details accessed using local lock held */
bool enable;
struct imsic_vector *move;
};
struct imsic_local_priv {
/* Local lock to protect vector enable/move variables and dirty bitmap */
raw_spinlock_t lock;
/* Local dirty bitmap for synchronization */
unsigned long *dirty_bitmap;
#ifdef CONFIG_SMP
/* Local timer for synchronization */
struct timer_list timer;
#endif
/* Local vector table */
struct imsic_vector *vectors;
};
struct imsic_priv {
/* Device details */
struct fwnode_handle *fwnode;
/* Global configuration common for all HARTs */
struct imsic_global_config global;
/* Per-CPU state */
struct imsic_local_priv __percpu *lpriv;
/* State of IRQ matrix allocator */
raw_spinlock_t matrix_lock;
struct irq_matrix *matrix;
/* IRQ domains (created by platform driver) */
struct irq_domain *base_domain;
};
extern struct imsic_priv *imsic;
void __imsic_eix_update(unsigned long base_id, unsigned long num_id, bool pend, bool val);
static inline void __imsic_id_set_enable(unsigned long id)
{
__imsic_eix_update(id, 1, false, true);
}
static inline void __imsic_id_clear_enable(unsigned long id)
{
__imsic_eix_update(id, 1, false, false);
}
void imsic_local_sync_all(void);
void imsic_local_delivery(bool enable);
void imsic_vector_mask(struct imsic_vector *vec);
void imsic_vector_unmask(struct imsic_vector *vec);
static inline bool imsic_vector_isenabled(struct imsic_vector *vec)
{
return READ_ONCE(vec->enable);
}
static inline struct imsic_vector *imsic_vector_get_move(struct imsic_vector *vec)
{
return READ_ONCE(vec->move);
}
void imsic_vector_move(struct imsic_vector *old_vec, struct imsic_vector *new_vec);
struct imsic_vector *imsic_vector_from_local_id(unsigned int cpu, unsigned int local_id);
struct imsic_vector *imsic_vector_alloc(unsigned int hwirq, const struct cpumask *mask);
void imsic_vector_free(struct imsic_vector *vector);
void imsic_vector_debug_show(struct seq_file *m, struct imsic_vector *vec, int ind);
void imsic_vector_debug_show_summary(struct seq_file *m, int ind);
void imsic_state_online(void);
void imsic_state_offline(void);
int imsic_setup_state(struct fwnode_handle *fwnode, void *opaque);
int imsic_irqdomain_init(void);
#endif
|