blob: 0cd6195cc3753c06db38bd5b6ba935f2bc038182 [file] [log] [blame]
Joerg Roedel736baef2012-03-30 11:47:00 -07001/*
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
Suresh Siddha8a8f4222012-03-30 11:47:08 -070022#ifndef __X86_IRQ_REMAPPING_H
23#define __X86_IRQ_REMAPPING_H
Joerg Roedel736baef2012-03-30 11:47:00 -070024
Jiang Liu947045a2015-04-13 14:11:30 +080025#include <linux/irqdomain.h>
26#include <asm/hw_irq.h>
Suresh Siddha399988e2012-05-08 00:08:52 -070027#include <asm/io_apic.h>
Joerg Roedel736baef2012-03-30 11:47:00 -070028
Joerg Roedel35d3d812013-04-19 20:34:55 +020029struct IO_APIC_route_entry;
30struct io_apic_irq_attr;
31struct irq_chip;
32struct msi_msg;
33struct pci_dev;
34struct irq_cfg;
Jiang Liu947045a2015-04-13 14:11:30 +080035struct irq_alloc_info;
Joerg Roedel35d3d812013-04-19 20:34:55 +020036
Suresh Siddha399988e2012-05-08 00:08:52 -070037#ifdef CONFIG_IRQ_REMAP
Joerg Roedel0c3f1732012-03-30 11:47:02 -070038
Neil Horman03bbcb22013-04-16 16:38:32 -040039extern void set_irq_remapping_broken(void);
Suresh Siddha95a02e92012-03-30 11:47:07 -070040extern 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 int setup_ioapic_remapped_entry(int irq,
46 struct IO_APIC_route_entry *entry,
47 unsigned int destination,
48 int vector,
49 struct io_apic_irq_attr *attr);
Suresh Siddha95a02e92012-03-30 11:47:07 -070050extern void free_remapped_irq(int irq);
51extern void compose_remapped_msi_msg(struct pci_dev *pdev,
52 unsigned int irq, unsigned int dest,
53 struct msi_msg *msg, u8 hpet_id);
Suresh Siddha95a02e92012-03-30 11:47:07 -070054extern int setup_hpet_msi_remapped(unsigned int irq, unsigned int id);
Joerg Roedel6a9f5de2012-09-26 12:44:41 +020055extern void panic_if_irq_remap(const char *msg);
Joerg Roedel2976fd82012-09-26 12:44:48 +020056extern bool setup_remapped_irq(int irq,
57 struct irq_cfg *cfg,
58 struct irq_chip *chip);
Joerg Roedel736baef2012-03-30 11:47:00 -070059
Joerg Roedel9b1b0e42012-09-26 12:44:45 +020060void irq_remap_modify_chip_defaults(struct irq_chip *chip);
61
Jiang Liu947045a2015-04-13 14:11:30 +080062extern struct irq_domain *
63irq_remapping_get_ir_irq_domain(struct irq_alloc_info *info);
64extern struct irq_domain *
65irq_remapping_get_irq_domain(struct irq_alloc_info *info);
66extern void irq_remapping_print_chip(struct irq_data *data, struct seq_file *p);
67
68/* Create PCI MSI/MSIx irqdomain, use @parent as the parent irqdomain. */
69static inline struct irq_domain *
70arch_create_msi_irq_domain(struct irq_domain *parent)
71{
72 return NULL;
73}
74
75/* Get parent irqdomain for interrupt remapping irqdomain */
76static inline struct irq_domain *arch_get_ir_parent_domain(void)
77{
78 return x86_vector_domain;
79}
80
Joerg Roedel736baef2012-03-30 11:47:00 -070081#else /* CONFIG_IRQ_REMAP */
82
Neil Horman03bbcb22013-04-16 16:38:32 -040083static inline void set_irq_remapping_broken(void) { }
Suresh Siddha95a02e92012-03-30 11:47:07 -070084static inline int irq_remapping_prepare(void) { return -ENODEV; }
85static inline int irq_remapping_enable(void) { return -ENODEV; }
86static inline void irq_remapping_disable(void) { }
87static inline int irq_remapping_reenable(int eim) { return -ENODEV; }
88static inline int irq_remap_enable_fault_handling(void) { return -ENODEV; }
89static inline int setup_ioapic_remapped_entry(int irq,
90 struct IO_APIC_route_entry *entry,
91 unsigned int destination,
92 int vector,
93 struct io_apic_irq_attr *attr)
Joerg Roedel0c3f1732012-03-30 11:47:02 -070094{
95 return -ENODEV;
96}
Suresh Siddha95a02e92012-03-30 11:47:07 -070097static inline void free_remapped_irq(int irq) { }
98static inline void compose_remapped_msi_msg(struct pci_dev *pdev,
99 unsigned int irq, unsigned int dest,
100 struct msi_msg *msg, u8 hpet_id)
Joerg Roedel5e2b9302012-03-30 11:47:05 -0700101{
102}
Suresh Siddha95a02e92012-03-30 11:47:07 -0700103static inline int setup_hpet_msi_remapped(unsigned int irq, unsigned int id)
Joerg Roedel5e2b9302012-03-30 11:47:05 -0700104{
105 return -ENODEV;
106}
Joerg Roedel6a9f5de2012-09-26 12:44:41 +0200107
108static inline void panic_if_irq_remap(const char *msg)
109{
110}
Joerg Roedel9b1b0e42012-09-26 12:44:45 +0200111
Joerg Roedel9b1b0e42012-09-26 12:44:45 +0200112static inline void irq_remap_modify_chip_defaults(struct irq_chip *chip)
113{
114}
115
Joerg Roedel2976fd82012-09-26 12:44:48 +0200116static inline bool setup_remapped_irq(int irq,
117 struct irq_cfg *cfg,
118 struct irq_chip *chip)
119{
120 return false;
121}
Jiang Liu947045a2015-04-13 14:11:30 +0800122
123static inline struct irq_domain *
124irq_remapping_get_ir_irq_domain(struct irq_alloc_info *info)
125{
126 return NULL;
127}
128
129static inline struct irq_domain *
130irq_remapping_get_irq_domain(struct irq_alloc_info *info)
131{
132 return NULL;
133}
134
135#define irq_remapping_print_chip NULL
Joerg Roedel736baef2012-03-30 11:47:00 -0700136#endif /* CONFIG_IRQ_REMAP */
137
Jiang Liua62b32c2015-04-13 14:11:29 +0800138extern int dmar_alloc_hwirq(void);
139extern void dmar_free_hwirq(int irq);
Thomas Gleixnera553b142014-05-07 15:44:11 +0000140
Suresh Siddha8a8f4222012-03-30 11:47:08 -0700141#endif /* __X86_IRQ_REMAPPING_H */