Skip to content

Commit 7e14cde

Browse files
jgross1bostrovs
authored andcommitted
xen/events: make struct irq_info private to events_base.c
The struct irq_info of Xen's event handling is used only for two evtchn_ops functions outside of events_base.c. Those two functions can easily be switched to avoid that usage. This allows to make struct irq_info and its related access functions private to events_base.c. Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Jan Beulich <jbeulich@suse.com> Link: https://lore.kernel.org/r/20201022094907.28560-3-jgross@suse.com Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
1 parent 5894048 commit 7e14cde

4 files changed

Lines changed: 73 additions & 73 deletions

File tree

drivers/xen/events/events_2l.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,11 @@ static unsigned evtchn_2l_max_channels(void)
4747
return EVTCHN_2L_NR_CHANNELS;
4848
}
4949

50-
static void evtchn_2l_bind_to_cpu(struct irq_info *info, unsigned cpu)
50+
static void evtchn_2l_bind_to_cpu(evtchn_port_t evtchn, unsigned int cpu,
51+
unsigned int old_cpu)
5152
{
52-
clear_bit(info->evtchn, BM(per_cpu(cpu_evtchn_mask, info->cpu)));
53-
set_bit(info->evtchn, BM(per_cpu(cpu_evtchn_mask, cpu)));
53+
clear_bit(evtchn, BM(per_cpu(cpu_evtchn_mask, old_cpu)));
54+
set_bit(evtchn, BM(per_cpu(cpu_evtchn_mask, cpu)));
5455
}
5556

5657
static void evtchn_2l_clear_pending(evtchn_port_t port)

drivers/xen/events/events_base.c

Lines changed: 57 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,57 @@
7070
#undef MODULE_PARAM_PREFIX
7171
#define MODULE_PARAM_PREFIX "xen."
7272

73+
/* Interrupt types. */
74+
enum xen_irq_type {
75+
IRQT_UNBOUND = 0,
76+
IRQT_PIRQ,
77+
IRQT_VIRQ,
78+
IRQT_IPI,
79+
IRQT_EVTCHN
80+
};
81+
82+
/*
83+
* Packed IRQ information:
84+
* type - enum xen_irq_type
85+
* event channel - irq->event channel mapping
86+
* cpu - cpu this event channel is bound to
87+
* index - type-specific information:
88+
* PIRQ - vector, with MSB being "needs EIO", or physical IRQ of the HVM
89+
* guest, or GSI (real passthrough IRQ) of the device.
90+
* VIRQ - virq number
91+
* IPI - IPI vector
92+
* EVTCHN -
93+
*/
94+
struct irq_info {
95+
struct list_head list;
96+
struct list_head eoi_list;
97+
short refcnt;
98+
short spurious_cnt;
99+
enum xen_irq_type type; /* type */
100+
unsigned irq;
101+
evtchn_port_t evtchn; /* event channel */
102+
unsigned short cpu; /* cpu bound */
103+
unsigned short eoi_cpu; /* EOI must happen on this cpu-1 */
104+
unsigned int irq_epoch; /* If eoi_cpu valid: irq_epoch of event */
105+
u64 eoi_time; /* Time in jiffies when to EOI. */
106+
107+
union {
108+
unsigned short virq;
109+
enum ipi_vector ipi;
110+
struct {
111+
unsigned short pirq;
112+
unsigned short gsi;
113+
unsigned char vector;
114+
unsigned char flags;
115+
uint16_t domid;
116+
} pirq;
117+
} u;
118+
};
119+
120+
#define PIRQ_NEEDS_EOI (1 << 0)
121+
#define PIRQ_SHAREABLE (1 << 1)
122+
#define PIRQ_MSI_GROUP (1 << 2)
123+
73124
static uint __read_mostly event_loop_timeout = 2;
74125
module_param(event_loop_timeout, uint, 0644);
75126

@@ -110,7 +161,7 @@ static DEFINE_PER_CPU(int [NR_VIRQS], virq_to_irq) = {[0 ... NR_VIRQS-1] = -1};
110161
/* IRQ <-> IPI mapping */
111162
static DEFINE_PER_CPU(int [XEN_NR_IPIS], ipi_to_irq) = {[0 ... XEN_NR_IPIS-1] = -1};
112163

113-
int **evtchn_to_irq;
164+
static int **evtchn_to_irq;
114165
#ifdef CONFIG_X86
115166
static unsigned long *pirq_eoi_map;
116167
#endif
@@ -190,7 +241,7 @@ int get_evtchn_to_irq(evtchn_port_t evtchn)
190241
}
191242

192243
/* Get info for IRQ */
193-
struct irq_info *info_for_irq(unsigned irq)
244+
static struct irq_info *info_for_irq(unsigned irq)
194245
{
195246
if (irq < nr_legacy_irqs())
196247
return legacy_info_ptrs[irq];
@@ -228,7 +279,7 @@ static int xen_irq_info_common_setup(struct irq_info *info,
228279

229280
irq_clear_status_flags(irq, IRQ_NOREQUEST|IRQ_NOAUTOEN);
230281

231-
return xen_evtchn_port_setup(info);
282+
return xen_evtchn_port_setup(evtchn);
232283
}
233284

234285
static int xen_irq_info_evtchn_setup(unsigned irq,
@@ -351,7 +402,7 @@ static enum xen_irq_type type_from_irq(unsigned irq)
351402
return info_for_irq(irq)->type;
352403
}
353404

354-
unsigned cpu_from_irq(unsigned irq)
405+
static unsigned cpu_from_irq(unsigned irq)
355406
{
356407
return info_for_irq(irq)->cpu;
357408
}
@@ -391,7 +442,7 @@ static void bind_evtchn_to_cpu(evtchn_port_t evtchn, unsigned int cpu)
391442
#ifdef CONFIG_SMP
392443
cpumask_copy(irq_get_affinity_mask(irq), cpumask_of(cpu));
393444
#endif
394-
xen_evtchn_port_bind_to_cpu(info, cpu);
445+
xen_evtchn_port_bind_to_cpu(evtchn, cpu, info->cpu);
395446

396447
info->cpu = cpu;
397448
}
@@ -745,7 +796,7 @@ static unsigned int __startup_pirq(unsigned int irq)
745796
info->evtchn = evtchn;
746797
bind_evtchn_to_cpu(evtchn, 0);
747798

748-
rc = xen_evtchn_port_setup(info);
799+
rc = xen_evtchn_port_setup(evtchn);
749800
if (rc)
750801
goto err;
751802

drivers/xen/events/events_fifo.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,8 @@ static void init_array_page(event_word_t *array_page)
138138
array_page[i] = 1 << EVTCHN_FIFO_MASKED;
139139
}
140140

141-
static int evtchn_fifo_setup(struct irq_info *info)
141+
static int evtchn_fifo_setup(evtchn_port_t port)
142142
{
143-
evtchn_port_t port = info->evtchn;
144143
unsigned new_array_pages;
145144
int ret;
146145

@@ -186,7 +185,8 @@ static int evtchn_fifo_setup(struct irq_info *info)
186185
return ret;
187186
}
188187

189-
static void evtchn_fifo_bind_to_cpu(struct irq_info *info, unsigned cpu)
188+
static void evtchn_fifo_bind_to_cpu(evtchn_port_t evtchn, unsigned int cpu,
189+
unsigned int old_cpu)
190190
{
191191
/* no-op */
192192
}

drivers/xen/events/events_internal.h

Lines changed: 9 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -7,65 +7,15 @@
77
#ifndef __EVENTS_INTERNAL_H__
88
#define __EVENTS_INTERNAL_H__
99

10-
/* Interrupt types. */
11-
enum xen_irq_type {
12-
IRQT_UNBOUND = 0,
13-
IRQT_PIRQ,
14-
IRQT_VIRQ,
15-
IRQT_IPI,
16-
IRQT_EVTCHN
17-
};
18-
19-
/*
20-
* Packed IRQ information:
21-
* type - enum xen_irq_type
22-
* event channel - irq->event channel mapping
23-
* cpu - cpu this event channel is bound to
24-
* index - type-specific information:
25-
* PIRQ - vector, with MSB being "needs EIO", or physical IRQ of the HVM
26-
* guest, or GSI (real passthrough IRQ) of the device.
27-
* VIRQ - virq number
28-
* IPI - IPI vector
29-
* EVTCHN -
30-
*/
31-
struct irq_info {
32-
struct list_head list;
33-
struct list_head eoi_list;
34-
short refcnt;
35-
short spurious_cnt;
36-
enum xen_irq_type type; /* type */
37-
unsigned irq;
38-
evtchn_port_t evtchn; /* event channel */
39-
unsigned short cpu; /* cpu bound */
40-
unsigned short eoi_cpu; /* EOI must happen on this cpu */
41-
unsigned int irq_epoch; /* If eoi_cpu valid: irq_epoch of event */
42-
u64 eoi_time; /* Time in jiffies when to EOI. */
43-
44-
union {
45-
unsigned short virq;
46-
enum ipi_vector ipi;
47-
struct {
48-
unsigned short pirq;
49-
unsigned short gsi;
50-
unsigned char vector;
51-
unsigned char flags;
52-
uint16_t domid;
53-
} pirq;
54-
} u;
55-
};
56-
57-
#define PIRQ_NEEDS_EOI (1 << 0)
58-
#define PIRQ_SHAREABLE (1 << 1)
59-
#define PIRQ_MSI_GROUP (1 << 2)
60-
6110
struct evtchn_loop_ctrl;
6211

6312
struct evtchn_ops {
6413
unsigned (*max_channels)(void);
6514
unsigned (*nr_channels)(void);
6615

67-
int (*setup)(struct irq_info *info);
68-
void (*bind_to_cpu)(struct irq_info *info, unsigned cpu);
16+
int (*setup)(evtchn_port_t port);
17+
void (*bind_to_cpu)(evtchn_port_t evtchn, unsigned int cpu,
18+
unsigned int old_cpu);
6919

7020
void (*clear_pending)(evtchn_port_t port);
7121
void (*set_pending)(evtchn_port_t port);
@@ -83,12 +33,9 @@ struct evtchn_ops {
8333

8434
extern const struct evtchn_ops *evtchn_ops;
8535

86-
extern int **evtchn_to_irq;
8736
int get_evtchn_to_irq(evtchn_port_t evtchn);
8837
void handle_irq_for_port(evtchn_port_t port, struct evtchn_loop_ctrl *ctrl);
8938

90-
struct irq_info *info_for_irq(unsigned irq);
91-
unsigned cpu_from_irq(unsigned irq);
9239
unsigned int cpu_from_evtchn(evtchn_port_t evtchn);
9340

9441
static inline unsigned xen_evtchn_max_channels(void)
@@ -100,17 +47,18 @@ static inline unsigned xen_evtchn_max_channels(void)
10047
* Do any ABI specific setup for a bound event channel before it can
10148
* be unmasked and used.
10249
*/
103-
static inline int xen_evtchn_port_setup(struct irq_info *info)
50+
static inline int xen_evtchn_port_setup(evtchn_port_t evtchn)
10451
{
10552
if (evtchn_ops->setup)
106-
return evtchn_ops->setup(info);
53+
return evtchn_ops->setup(evtchn);
10754
return 0;
10855
}
10956

110-
static inline void xen_evtchn_port_bind_to_cpu(struct irq_info *info,
111-
unsigned cpu)
57+
static inline void xen_evtchn_port_bind_to_cpu(evtchn_port_t evtchn,
58+
unsigned int cpu,
59+
unsigned int old_cpu)
11260
{
113-
evtchn_ops->bind_to_cpu(info, cpu);
61+
evtchn_ops->bind_to_cpu(evtchn, cpu, old_cpu);
11462
}
11563

11664
static inline void clear_evtchn(evtchn_port_t port)

0 commit comments

Comments
 (0)