Loading...
1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 * Copyright (C) 2012 Advanced Micro Devices, Inc.
4 * Author: Joerg Roedel <joerg.roedel@amd.com>
5 *
6 * This header file contains the interface of the interrupt remapping code to
7 * the x86 interrupt management code.
8 */
9
10#ifndef __X86_IRQ_REMAPPING_H
11#define __X86_IRQ_REMAPPING_H
12
13#include <asm/irqdomain.h>
14#include <asm/hw_irq.h>
15#include <asm/io_apic.h>
16
17struct msi_msg;
18struct irq_alloc_info;
19
20enum irq_remap_cap {
21 IRQ_POSTING_CAP = 0,
22};
23
24enum {
25 IRQ_REMAP_XAPIC_MODE,
26 IRQ_REMAP_X2APIC_MODE,
27};
28
29struct vcpu_data {
30 u64 pi_desc_addr; /* Physical address of PI Descriptor */
31 u32 vector; /* Guest vector of the interrupt */
32};
33
34#ifdef CONFIG_IRQ_REMAP
35
36extern raw_spinlock_t irq_2_ir_lock;
37
38extern bool irq_remapping_cap(enum irq_remap_cap cap);
39extern void set_irq_remapping_broken(void);
40extern int irq_remapping_prepare(void);
41extern int irq_remapping_enable(void);
42extern void irq_remapping_disable(void);
43extern int irq_remapping_reenable(int);
44extern int irq_remap_enable_fault_handling(void);
45extern void panic_if_irq_remap(const char *msg);
46
47/* Get parent irqdomain for interrupt remapping irqdomain */
48static inline struct irq_domain *arch_get_ir_parent_domain(void)
49{
50 return x86_vector_domain;
51}
52
53#else /* CONFIG_IRQ_REMAP */
54
55static inline bool irq_remapping_cap(enum irq_remap_cap cap) { return 0; }
56static inline void set_irq_remapping_broken(void) { }
57static inline int irq_remapping_prepare(void) { return -ENODEV; }
58static inline int irq_remapping_enable(void) { return -ENODEV; }
59static inline void irq_remapping_disable(void) { }
60static inline int irq_remapping_reenable(int eim) { return -ENODEV; }
61static inline int irq_remap_enable_fault_handling(void) { return -ENODEV; }
62
63static inline void panic_if_irq_remap(const char *msg)
64{
65}
66
67#endif /* CONFIG_IRQ_REMAP */
68#endif /* __X86_IRQ_REMAPPING_H */
1/*
2 * Copyright (C) 2012 Advanced Micro Devices, Inc.
3 * Author: Joerg Roedel <joerg.roedel@amd.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published
7 * by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * This header file contains the interface of the interrupt remapping code to
19 * the x86 interrupt management code.
20 */
21
22#ifndef __X86_IRQ_REMAPPING_H
23#define __X86_IRQ_REMAPPING_H
24
25#include <asm/io_apic.h>
26
27#ifdef CONFIG_IRQ_REMAP
28
29extern int irq_remapping_enabled;
30
31extern void setup_irq_remapping_ops(void);
32extern int irq_remapping_supported(void);
33extern int irq_remapping_prepare(void);
34extern int irq_remapping_enable(void);
35extern void irq_remapping_disable(void);
36extern int irq_remapping_reenable(int);
37extern int irq_remap_enable_fault_handling(void);
38extern int setup_ioapic_remapped_entry(int irq,
39 struct IO_APIC_route_entry *entry,
40 unsigned int destination,
41 int vector,
42 struct io_apic_irq_attr *attr);
43extern int set_remapped_irq_affinity(struct irq_data *data,
44 const struct cpumask *mask,
45 bool force);
46extern void free_remapped_irq(int irq);
47extern void compose_remapped_msi_msg(struct pci_dev *pdev,
48 unsigned int irq, unsigned int dest,
49 struct msi_msg *msg, u8 hpet_id);
50extern int msi_alloc_remapped_irq(struct pci_dev *pdev, int irq, int nvec);
51extern int msi_setup_remapped_irq(struct pci_dev *pdev, unsigned int irq,
52 int index, int sub_handle);
53extern int setup_hpet_msi_remapped(unsigned int irq, unsigned int id);
54
55#else /* CONFIG_IRQ_REMAP */
56
57#define irq_remapping_enabled 0
58
59static inline void setup_irq_remapping_ops(void) { }
60static inline int irq_remapping_supported(void) { return 0; }
61static inline int irq_remapping_prepare(void) { return -ENODEV; }
62static inline int irq_remapping_enable(void) { return -ENODEV; }
63static inline void irq_remapping_disable(void) { }
64static inline int irq_remapping_reenable(int eim) { return -ENODEV; }
65static inline int irq_remap_enable_fault_handling(void) { return -ENODEV; }
66static inline int setup_ioapic_remapped_entry(int irq,
67 struct IO_APIC_route_entry *entry,
68 unsigned int destination,
69 int vector,
70 struct io_apic_irq_attr *attr)
71{
72 return -ENODEV;
73}
74static inline int set_remapped_irq_affinity(struct irq_data *data,
75 const struct cpumask *mask,
76 bool force)
77{
78 return 0;
79}
80static inline void free_remapped_irq(int irq) { }
81static inline void compose_remapped_msi_msg(struct pci_dev *pdev,
82 unsigned int irq, unsigned int dest,
83 struct msi_msg *msg, u8 hpet_id)
84{
85}
86static inline int msi_alloc_remapped_irq(struct pci_dev *pdev, int irq, int nvec)
87{
88 return -ENODEV;
89}
90static inline int msi_setup_remapped_irq(struct pci_dev *pdev, unsigned int irq,
91 int index, int sub_handle)
92{
93 return -ENODEV;
94}
95static inline int setup_hpet_msi_remapped(unsigned int irq, unsigned int id)
96{
97 return -ENODEV;
98}
99#endif /* CONFIG_IRQ_REMAP */
100
101#endif /* __X86_IRQ_REMAPPING_H */