1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
23b7d1921SEric W. Biederman #ifndef LINUX_MSI_H
33b7d1921SEric W. Biederman #define LINUX_MSI_H
43b7d1921SEric W. Biederman
5ef3350c5SThomas Gleixner /*
6ef3350c5SThomas Gleixner * This header file contains MSI data structures and functions which are
7ef3350c5SThomas Gleixner * only relevant for:
8ef3350c5SThomas Gleixner * - Interrupt core code
9ef3350c5SThomas Gleixner * - PCI/MSI core code
10ef3350c5SThomas Gleixner * - MSI interrupt domain implementations
11ef3350c5SThomas Gleixner * - IOMMU, low level VFIO, NTB and other justified exceptions
12ef3350c5SThomas Gleixner * dealing with low level MSI details.
13ef3350c5SThomas Gleixner *
14ef3350c5SThomas Gleixner * Regular device drivers have no business with any of these functions and
15ef3350c5SThomas Gleixner * especially storing MSI descriptor pointers in random code is considered
166b6941f6SThomas Gleixner * abuse.
176b6941f6SThomas Gleixner *
186b6941f6SThomas Gleixner * Device driver relevant functions are available in <linux/msi_api.h>
19ef3350c5SThomas Gleixner */
20ef3350c5SThomas Gleixner
2122db089aSAhmed S. Darwish #include <linux/irqdomain_defs.h>
223ba1f050SThomas Gleixner #include <linux/cpumask.h>
236b6941f6SThomas Gleixner #include <linux/msi_api.h>
24cd6cf065SThomas Gleixner #include <linux/xarray.h>
25b5f687f9SThomas Gleixner #include <linux/mutex.h>
264aa9bc95SMichael Ellerman #include <linux/list.h>
27ebca4396SThomas Gleixner #include <linux/irq.h>
282d958b02SThomas Gleixner #include <linux/bits.h>
292d958b02SThomas Gleixner
308073c1acSThomas Gleixner #include <asm/msi.h>
314aa9bc95SMichael Ellerman
328073c1acSThomas Gleixner /* Dummy shadow structures if an architecture does not define them */
338073c1acSThomas Gleixner #ifndef arch_msi_msg_addr_lo
348073c1acSThomas Gleixner typedef struct arch_msi_msg_addr_lo {
358073c1acSThomas Gleixner u32 address_lo;
368073c1acSThomas Gleixner } __attribute__ ((packed)) arch_msi_msg_addr_lo_t;
378073c1acSThomas Gleixner #endif
388073c1acSThomas Gleixner
398073c1acSThomas Gleixner #ifndef arch_msi_msg_addr_hi
408073c1acSThomas Gleixner typedef struct arch_msi_msg_addr_hi {
418073c1acSThomas Gleixner u32 address_hi;
428073c1acSThomas Gleixner } __attribute__ ((packed)) arch_msi_msg_addr_hi_t;
438073c1acSThomas Gleixner #endif
448073c1acSThomas Gleixner
458073c1acSThomas Gleixner #ifndef arch_msi_msg_data
468073c1acSThomas Gleixner typedef struct arch_msi_msg_data {
478073c1acSThomas Gleixner u32 data;
488073c1acSThomas Gleixner } __attribute__ ((packed)) arch_msi_msg_data_t;
498073c1acSThomas Gleixner #endif
508073c1acSThomas Gleixner
51bf210f79SJason Gunthorpe #ifndef arch_is_isolated_msi
52bf210f79SJason Gunthorpe #define arch_is_isolated_msi() false
53bf210f79SJason Gunthorpe #endif
54bf210f79SJason Gunthorpe
558073c1acSThomas Gleixner /**
568073c1acSThomas Gleixner * msi_msg - Representation of a MSI message
578073c1acSThomas Gleixner * @address_lo: Low 32 bits of msi message address
588073c1acSThomas Gleixner * @arch_addrlo: Architecture specific shadow of @address_lo
598073c1acSThomas Gleixner * @address_hi: High 32 bits of msi message address
608073c1acSThomas Gleixner * (only used when device supports it)
618073c1acSThomas Gleixner * @arch_addrhi: Architecture specific shadow of @address_hi
628073c1acSThomas Gleixner * @data: MSI message data (usually 16 bits)
638073c1acSThomas Gleixner * @arch_data: Architecture specific shadow of @data
648073c1acSThomas Gleixner */
653b7d1921SEric W. Biederman struct msi_msg {
668073c1acSThomas Gleixner union {
678073c1acSThomas Gleixner u32 address_lo;
688073c1acSThomas Gleixner arch_msi_msg_addr_lo_t arch_addr_lo;
698073c1acSThomas Gleixner };
708073c1acSThomas Gleixner union {
718073c1acSThomas Gleixner u32 address_hi;
728073c1acSThomas Gleixner arch_msi_msg_addr_hi_t arch_addr_hi;
738073c1acSThomas Gleixner };
748073c1acSThomas Gleixner union {
758073c1acSThomas Gleixner u32 data;
768073c1acSThomas Gleixner arch_msi_msg_data_t arch_data;
778073c1acSThomas Gleixner };
783b7d1921SEric W. Biederman };
793b7d1921SEric W. Biederman
8038737d82SYijing Wang extern int pci_msi_ignore_mask;
81c54c1879SSatoru Takeuchi /* Helper functions */
8239431acbSThomas Gleixner struct msi_desc;
8325a98bd4SJiang Liu struct pci_dev;
84c09fcc4bSMarc Zyngier struct platform_msi_priv_data;
85bf5e758fSThomas Gleixner struct device_attribute;
8664258eaaSThomas Gleixner struct irq_domain;
873d393b21SThomas Gleixner struct irq_affinity_desc;
88bf6e054eSThomas Gleixner
892366d06eSBjorn Helgaas void __get_cached_msi_msg(struct msi_desc *entry, struct msi_msg *msg);
902f44e29cSArnd Bergmann #ifdef CONFIG_GENERIC_MSI_IRQ
912366d06eSBjorn Helgaas void get_cached_msi_msg(unsigned int irq, struct msi_msg *msg);
922f44e29cSArnd Bergmann #else
get_cached_msi_msg(unsigned int irq,struct msi_msg * msg)9313e7accbSThomas Gleixner static inline void get_cached_msi_msg(unsigned int irq, struct msi_msg *msg) { }
942f44e29cSArnd Bergmann #endif
95891d4a48SJiang Liu
96c09fcc4bSMarc Zyngier typedef void (*irq_write_msi_msg_t)(struct msi_desc *desc,
97c09fcc4bSMarc Zyngier struct msi_msg *msg);
98c09fcc4bSMarc Zyngier
99c09fcc4bSMarc Zyngier /**
100e58f2259SThomas Gleixner * pci_msi_desc - PCI/MSI specific MSI descriptor data
101e58f2259SThomas Gleixner *
102e58f2259SThomas Gleixner * @msi_mask: [PCI MSI] MSI cached mask bits
103e58f2259SThomas Gleixner * @msix_ctrl: [PCI MSI-X] MSI-X cached per vector control bits
104e58f2259SThomas Gleixner * @is_msix: [PCI MSI/X] True if MSI-X
105e58f2259SThomas Gleixner * @multiple: [PCI MSI/X] log2 num of messages allocated
106e58f2259SThomas Gleixner * @multi_cap: [PCI MSI/X] log2 num of messages supported
107e58f2259SThomas Gleixner * @can_mask: [PCI MSI/X] Masking supported?
108e58f2259SThomas Gleixner * @is_64: [PCI MSI/X] Address size: 0=32bit 1=64bit
109e58f2259SThomas Gleixner * @default_irq:[PCI MSI/X] The default pre-assigned non-MSI irq
110e58f2259SThomas Gleixner * @mask_pos: [PCI MSI] Mask register position
111e58f2259SThomas Gleixner * @mask_base: [PCI MSI-X] Mask register base address
112e58f2259SThomas Gleixner */
113e58f2259SThomas Gleixner struct pci_msi_desc {
114e58f2259SThomas Gleixner union {
115e58f2259SThomas Gleixner u32 msi_mask;
116e58f2259SThomas Gleixner u32 msix_ctrl;
117e58f2259SThomas Gleixner };
118e58f2259SThomas Gleixner struct {
119e58f2259SThomas Gleixner u8 is_msix : 1;
120e58f2259SThomas Gleixner u8 multiple : 3;
121e58f2259SThomas Gleixner u8 multi_cap : 3;
122e58f2259SThomas Gleixner u8 can_mask : 1;
123e58f2259SThomas Gleixner u8 is_64 : 1;
124e58f2259SThomas Gleixner u8 is_virtual : 1;
125e58f2259SThomas Gleixner unsigned default_irq;
126e58f2259SThomas Gleixner } msi_attrib;
127e58f2259SThomas Gleixner union {
128e58f2259SThomas Gleixner u8 mask_pos;
129e58f2259SThomas Gleixner void __iomem *mask_base;
130e58f2259SThomas Gleixner };
131e58f2259SThomas Gleixner };
132e58f2259SThomas Gleixner
133efd42049SThomas Gleixner /**
134efd42049SThomas Gleixner * union msi_domain_cookie - Opaque MSI domain specific data
135efd42049SThomas Gleixner * @value: u64 value store
136efd42049SThomas Gleixner * @ptr: Pointer to domain specific data
137efd42049SThomas Gleixner * @iobase: Domain specific IOmem pointer
138efd42049SThomas Gleixner *
139efd42049SThomas Gleixner * The content of this data is implementation defined and used by the MSI
140efd42049SThomas Gleixner * domain to store domain specific information which is requried for
141efd42049SThomas Gleixner * interrupt chip callbacks.
142efd42049SThomas Gleixner */
143efd42049SThomas Gleixner union msi_domain_cookie {
144efd42049SThomas Gleixner u64 value;
145efd42049SThomas Gleixner void *ptr;
146efd42049SThomas Gleixner void __iomem *iobase;
147efd42049SThomas Gleixner };
148efd42049SThomas Gleixner
149efd42049SThomas Gleixner /**
150efd42049SThomas Gleixner * struct msi_desc_data - Generic MSI descriptor data
151efd42049SThomas Gleixner * @dcookie: Cookie for MSI domain specific data which is required
152efd42049SThomas Gleixner * for irq_chip callbacks
153efd42049SThomas Gleixner * @icookie: Cookie for the MSI interrupt instance provided by
154efd42049SThomas Gleixner * the usage site to the allocation function
155efd42049SThomas Gleixner *
156efd42049SThomas Gleixner * The content of this data is implementation defined, e.g. PCI/IMS
157efd42049SThomas Gleixner * implementations define the meaning of the data. The MSI core ignores
158efd42049SThomas Gleixner * this data completely.
159efd42049SThomas Gleixner */
160efd42049SThomas Gleixner struct msi_desc_data {
161efd42049SThomas Gleixner union msi_domain_cookie dcookie;
162efd42049SThomas Gleixner union msi_instance_cookie icookie;
163efd42049SThomas Gleixner };
164efd42049SThomas Gleixner
165645474e2SThomas Gleixner #define MSI_MAX_INDEX ((unsigned int)USHRT_MAX)
166645474e2SThomas Gleixner
167e58f2259SThomas Gleixner /**
168fc88419cSJiang Liu * struct msi_desc - Descriptor structure for MSI based interrupts
169fc88419cSJiang Liu * @irq: The base interrupt number
170fc88419cSJiang Liu * @nvec_used: The number of vectors used
171fc88419cSJiang Liu * @dev: Pointer to the device which uses this descriptor
172fc88419cSJiang Liu * @msg: The last set MSI message cached for reuse
1730972fa57SThomas Gleixner * @affinity: Optional pointer to a cpu affinity mask for this descriptor
174bf5e758fSThomas Gleixner * @sysfs_attr: Pointer to sysfs device attribute
175fc88419cSJiang Liu *
176d7cc609fSLogan Gunthorpe * @write_msi_msg: Callback that may be called when the MSI message
177d7cc609fSLogan Gunthorpe * address or data changes
178d7cc609fSLogan Gunthorpe * @write_msi_msg_data: Data parameter for the callback.
179d7cc609fSLogan Gunthorpe *
18020c6d424SThomas Gleixner * @msi_index: Index of the msi descriptor
1810f180958SThomas Gleixner * @pci: PCI specific msi descriptor data
182efd42049SThomas Gleixner * @data: Generic MSI descriptor data
183fc88419cSJiang Liu */
1843b7d1921SEric W. Biederman struct msi_desc {
185fc88419cSJiang Liu /* Shared device/bus type independent data */
186fc88419cSJiang Liu unsigned int irq;
187fc88419cSJiang Liu unsigned int nvec_used;
188fc88419cSJiang Liu struct device *dev;
189fc88419cSJiang Liu struct msi_msg msg;
190bec04037SDou Liyang struct irq_affinity_desc *affinity;
191aaebdf8dSJulien Grall #ifdef CONFIG_IRQ_MSI_IOMMU
192aaebdf8dSJulien Grall const void *iommu_cookie;
193aaebdf8dSJulien Grall #endif
194bf5e758fSThomas Gleixner #ifdef CONFIG_SYSFS
195bf5e758fSThomas Gleixner struct device_attribute *sysfs_attrs;
196bf5e758fSThomas Gleixner #endif
1973b7d1921SEric W. Biederman
198d7cc609fSLogan Gunthorpe void (*write_msi_msg)(struct msi_desc *entry, void *data);
199d7cc609fSLogan Gunthorpe void *write_msi_msg_data;
200d7cc609fSLogan Gunthorpe
20120c6d424SThomas Gleixner u16 msi_index;
202efd42049SThomas Gleixner union {
203e58f2259SThomas Gleixner struct pci_msi_desc pci;
204efd42049SThomas Gleixner struct msi_desc_data data;
205efd42049SThomas Gleixner };
2063b7d1921SEric W. Biederman };
2073b7d1921SEric W. Biederman
2081046f71dSThomas Gleixner /*
2091046f71dSThomas Gleixner * Filter values for the MSI descriptor iterators and accessor functions.
2101046f71dSThomas Gleixner */
2111046f71dSThomas Gleixner enum msi_desc_filter {
2121046f71dSThomas Gleixner /* All descriptors */
2131046f71dSThomas Gleixner MSI_DESC_ALL,
2141046f71dSThomas Gleixner /* Descriptors which have no interrupt associated */
2151046f71dSThomas Gleixner MSI_DESC_NOTASSOCIATED,
2161046f71dSThomas Gleixner /* Descriptors which have an interrupt associated */
2171046f71dSThomas Gleixner MSI_DESC_ASSOCIATED,
2181046f71dSThomas Gleixner };
2191046f71dSThomas Gleixner
220f1139f90SThomas Gleixner
221f1139f90SThomas Gleixner /**
222f1139f90SThomas Gleixner * struct msi_dev_domain - The internals of MSI domain info per device
223f1139f90SThomas Gleixner * @store: Xarray for storing MSI descriptor pointers
22464258eaaSThomas Gleixner * @irqdomain: Pointer to a per device interrupt domain
225f1139f90SThomas Gleixner */
226f1139f90SThomas Gleixner struct msi_dev_domain {
227f1139f90SThomas Gleixner struct xarray store;
22864258eaaSThomas Gleixner struct irq_domain *domain;
229f1139f90SThomas Gleixner };
230f1139f90SThomas Gleixner
231013bd8e5SThomas Gleixner /**
232013bd8e5SThomas Gleixner * msi_device_data - MSI per device data
233013bd8e5SThomas Gleixner * @properties: MSI properties which are interesting to drivers
234fc22e7dbSThomas Gleixner * @platform_data: Platform-MSI specific data
235cd6cf065SThomas Gleixner * @mutex: Mutex protecting the MSI descriptor store
236f1139f90SThomas Gleixner * @__domains: Internal data for per device MSI domains
237cd6cf065SThomas Gleixner * @__iter_idx: Index to search the next entry for iterators
238013bd8e5SThomas Gleixner */
239013bd8e5SThomas Gleixner struct msi_device_data {
240013bd8e5SThomas Gleixner unsigned long properties;
241fc22e7dbSThomas Gleixner struct platform_msi_priv_data *platform_data;
242b5f687f9SThomas Gleixner struct mutex mutex;
243f1139f90SThomas Gleixner struct msi_dev_domain __domains[MSI_MAX_DEVICE_IRQDOMAINS];
244cd6cf065SThomas Gleixner unsigned long __iter_idx;
245013bd8e5SThomas Gleixner };
246013bd8e5SThomas Gleixner
247013bd8e5SThomas Gleixner int msi_setup_device_data(struct device *dev);
248013bd8e5SThomas Gleixner
249b5f687f9SThomas Gleixner void msi_lock_descs(struct device *dev);
250b5f687f9SThomas Gleixner void msi_unlock_descs(struct device *dev);
251cf15f43aSThomas Gleixner
25294ff94cfSThomas Gleixner struct msi_desc *msi_domain_first_desc(struct device *dev, unsigned int domid,
25394ff94cfSThomas Gleixner enum msi_desc_filter filter);
2541046f71dSThomas Gleixner
2551046f71dSThomas Gleixner /**
25694ff94cfSThomas Gleixner * msi_first_desc - Get the first MSI descriptor of the default irqdomain
25794ff94cfSThomas Gleixner * @dev: Device to operate on
25894ff94cfSThomas Gleixner * @filter: Descriptor state filter
25994ff94cfSThomas Gleixner *
26094ff94cfSThomas Gleixner * Must be called with the MSI descriptor mutex held, i.e. msi_lock_descs()
26194ff94cfSThomas Gleixner * must be invoked before the call.
26294ff94cfSThomas Gleixner *
26394ff94cfSThomas Gleixner * Return: Pointer to the first MSI descriptor matching the search
26494ff94cfSThomas Gleixner * criteria, NULL if none found.
26594ff94cfSThomas Gleixner */
msi_first_desc(struct device * dev,enum msi_desc_filter filter)26694ff94cfSThomas Gleixner static inline struct msi_desc *msi_first_desc(struct device *dev,
26794ff94cfSThomas Gleixner enum msi_desc_filter filter)
26894ff94cfSThomas Gleixner {
26994ff94cfSThomas Gleixner return msi_domain_first_desc(dev, MSI_DEFAULT_DOMAIN, filter);
27094ff94cfSThomas Gleixner }
27194ff94cfSThomas Gleixner
27294ff94cfSThomas Gleixner struct msi_desc *msi_next_desc(struct device *dev, unsigned int domid,
27394ff94cfSThomas Gleixner enum msi_desc_filter filter);
27494ff94cfSThomas Gleixner
27594ff94cfSThomas Gleixner /**
27694ff94cfSThomas Gleixner * msi_domain_for_each_desc - Iterate the MSI descriptors in a specific domain
27794ff94cfSThomas Gleixner *
27894ff94cfSThomas Gleixner * @desc: struct msi_desc pointer used as iterator
27994ff94cfSThomas Gleixner * @dev: struct device pointer - device to iterate
28094ff94cfSThomas Gleixner * @domid: The id of the interrupt domain which should be walked.
28194ff94cfSThomas Gleixner * @filter: Filter for descriptor selection
28294ff94cfSThomas Gleixner *
28394ff94cfSThomas Gleixner * Notes:
28494ff94cfSThomas Gleixner * - The loop must be protected with a msi_lock_descs()/msi_unlock_descs()
28594ff94cfSThomas Gleixner * pair.
28694ff94cfSThomas Gleixner * - It is safe to remove a retrieved MSI descriptor in the loop.
28794ff94cfSThomas Gleixner */
28894ff94cfSThomas Gleixner #define msi_domain_for_each_desc(desc, dev, domid, filter) \
28994ff94cfSThomas Gleixner for ((desc) = msi_domain_first_desc((dev), (domid), (filter)); (desc); \
29094ff94cfSThomas Gleixner (desc) = msi_next_desc((dev), (domid), (filter)))
29194ff94cfSThomas Gleixner
29294ff94cfSThomas Gleixner /**
29394ff94cfSThomas Gleixner * msi_for_each_desc - Iterate the MSI descriptors in the default irqdomain
2941046f71dSThomas Gleixner *
2951046f71dSThomas Gleixner * @desc: struct msi_desc pointer used as iterator
2961046f71dSThomas Gleixner * @dev: struct device pointer - device to iterate
2971046f71dSThomas Gleixner * @filter: Filter for descriptor selection
2981046f71dSThomas Gleixner *
2991046f71dSThomas Gleixner * Notes:
3001046f71dSThomas Gleixner * - The loop must be protected with a msi_lock_descs()/msi_unlock_descs()
3011046f71dSThomas Gleixner * pair.
3021046f71dSThomas Gleixner * - It is safe to remove a retrieved MSI descriptor in the loop.
3031046f71dSThomas Gleixner */
3041046f71dSThomas Gleixner #define msi_for_each_desc(desc, dev, filter) \
30594ff94cfSThomas Gleixner msi_domain_for_each_desc((desc), (dev), MSI_DEFAULT_DOMAIN, (filter))
3061046f71dSThomas Gleixner
30725a98bd4SJiang Liu #define msi_desc_to_dev(desc) ((desc)->dev)
308d31eb342SJiang Liu
309aaebdf8dSJulien Grall #ifdef CONFIG_IRQ_MSI_IOMMU
msi_desc_get_iommu_cookie(struct msi_desc * desc)310aaebdf8dSJulien Grall static inline const void *msi_desc_get_iommu_cookie(struct msi_desc *desc)
311aaebdf8dSJulien Grall {
312aaebdf8dSJulien Grall return desc->iommu_cookie;
313aaebdf8dSJulien Grall }
314aaebdf8dSJulien Grall
msi_desc_set_iommu_cookie(struct msi_desc * desc,const void * iommu_cookie)315aaebdf8dSJulien Grall static inline void msi_desc_set_iommu_cookie(struct msi_desc *desc,
316aaebdf8dSJulien Grall const void *iommu_cookie)
317aaebdf8dSJulien Grall {
318aaebdf8dSJulien Grall desc->iommu_cookie = iommu_cookie;
319aaebdf8dSJulien Grall }
320aaebdf8dSJulien Grall #else
msi_desc_get_iommu_cookie(struct msi_desc * desc)321aaebdf8dSJulien Grall static inline const void *msi_desc_get_iommu_cookie(struct msi_desc *desc)
322aaebdf8dSJulien Grall {
323aaebdf8dSJulien Grall return NULL;
324aaebdf8dSJulien Grall }
325aaebdf8dSJulien Grall
msi_desc_set_iommu_cookie(struct msi_desc * desc,const void * iommu_cookie)326aaebdf8dSJulien Grall static inline void msi_desc_set_iommu_cookie(struct msi_desc *desc,
327aaebdf8dSJulien Grall const void *iommu_cookie)
328aaebdf8dSJulien Grall {
329aaebdf8dSJulien Grall }
330aaebdf8dSJulien Grall #endif
331aaebdf8dSJulien Grall
332fc8ab388SThomas Gleixner int msi_domain_insert_msi_desc(struct device *dev, unsigned int domid,
333fc8ab388SThomas Gleixner struct msi_desc *init_desc);
334fc8ab388SThomas Gleixner /**
335fc8ab388SThomas Gleixner * msi_insert_msi_desc - Allocate and initialize a MSI descriptor in the
336fc8ab388SThomas Gleixner * default irqdomain and insert it at @init_desc->msi_index
337fc8ab388SThomas Gleixner * @dev: Pointer to the device for which the descriptor is allocated
338fc8ab388SThomas Gleixner * @init_desc: Pointer to an MSI descriptor to initialize the new descriptor
339fc8ab388SThomas Gleixner *
340fc8ab388SThomas Gleixner * Return: 0 on success or an appropriate failure code.
341fc8ab388SThomas Gleixner */
msi_insert_msi_desc(struct device * dev,struct msi_desc * init_desc)342fc8ab388SThomas Gleixner static inline int msi_insert_msi_desc(struct device *dev, struct msi_desc *init_desc)
343fc8ab388SThomas Gleixner {
344fc8ab388SThomas Gleixner return msi_domain_insert_msi_desc(dev, MSI_DEFAULT_DOMAIN, init_desc);
345fc8ab388SThomas Gleixner }
346fc8ab388SThomas Gleixner
347377712c5SThomas Gleixner void msi_domain_free_msi_descs_range(struct device *dev, unsigned int domid,
348377712c5SThomas Gleixner unsigned int first, unsigned int last);
349645474e2SThomas Gleixner
350645474e2SThomas Gleixner /**
351377712c5SThomas Gleixner * msi_free_msi_descs_range - Free a range of MSI descriptors of a device
352377712c5SThomas Gleixner * in the default irqdomain
353377712c5SThomas Gleixner *
354377712c5SThomas Gleixner * @dev: Device for which to free the descriptors
355377712c5SThomas Gleixner * @first: Index to start freeing from (inclusive)
356377712c5SThomas Gleixner * @last: Last index to be freed (inclusive)
357377712c5SThomas Gleixner */
msi_free_msi_descs_range(struct device * dev,unsigned int first,unsigned int last)358377712c5SThomas Gleixner static inline void msi_free_msi_descs_range(struct device *dev, unsigned int first,
359377712c5SThomas Gleixner unsigned int last)
360377712c5SThomas Gleixner {
361377712c5SThomas Gleixner msi_domain_free_msi_descs_range(dev, MSI_DEFAULT_DOMAIN, first, last);
362377712c5SThomas Gleixner }
363377712c5SThomas Gleixner
364377712c5SThomas Gleixner /**
365377712c5SThomas Gleixner * msi_free_msi_descs - Free all MSI descriptors of a device in the default irqdomain
366645474e2SThomas Gleixner * @dev: Device to free the descriptors
367645474e2SThomas Gleixner */
msi_free_msi_descs(struct device * dev)368645474e2SThomas Gleixner static inline void msi_free_msi_descs(struct device *dev)
369645474e2SThomas Gleixner {
3702f2940d1SThomas Gleixner msi_free_msi_descs_range(dev, 0, MSI_MAX_INDEX);
371645474e2SThomas Gleixner }
37260290525SThomas Gleixner
3733b7d1921SEric W. Biederman /*
374077ee78eSThomas Gleixner * The arch hooks to setup up msi irqs. Default functions are implemented
375077ee78eSThomas Gleixner * as weak symbols so that they /can/ be overriden by architecture specific
376b227be0dSMarc Zyngier * code if needed. These hooks can only be enabled by the architecture.
377077ee78eSThomas Gleixner *
378077ee78eSThomas Gleixner * If CONFIG_PCI_MSI_ARCH_FALLBACKS is not selected they are replaced by
379077ee78eSThomas Gleixner * stubs with warnings.
3803b7d1921SEric W. Biederman */
381077ee78eSThomas Gleixner #ifdef CONFIG_PCI_MSI_ARCH_FALLBACKS
382f7feaca7SEric W. Biederman int arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc);
3833b7d1921SEric W. Biederman void arch_teardown_msi_irq(unsigned int irq);
3842366d06eSBjorn Helgaas int arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type);
3852366d06eSBjorn Helgaas void arch_teardown_msi_irqs(struct pci_dev *dev);
386*335b4223SMaximilian Heyne #endif /* CONFIG_PCI_MSI_ARCH_FALLBACKS */
387*335b4223SMaximilian Heyne
388*335b4223SMaximilian Heyne /*
389*335b4223SMaximilian Heyne * Xen uses non-default msi_domain_ops and hence needs a way to populate sysfs
390*335b4223SMaximilian Heyne * entries of MSI IRQs.
391*335b4223SMaximilian Heyne */
392*335b4223SMaximilian Heyne #if defined(CONFIG_PCI_XEN) || defined(CONFIG_PCI_MSI_ARCH_FALLBACKS)
393bf5e758fSThomas Gleixner #ifdef CONFIG_SYSFS
394bf5e758fSThomas Gleixner int msi_device_populate_sysfs(struct device *dev);
395bf5e758fSThomas Gleixner void msi_device_destroy_sysfs(struct device *dev);
396bf5e758fSThomas Gleixner #else /* CONFIG_SYSFS */
msi_device_populate_sysfs(struct device * dev)397bf5e758fSThomas Gleixner static inline int msi_device_populate_sysfs(struct device *dev) { return 0; }
msi_device_destroy_sysfs(struct device * dev)398bf5e758fSThomas Gleixner static inline void msi_device_destroy_sysfs(struct device *dev) { }
399bf5e758fSThomas Gleixner #endif /* !CONFIG_SYSFS */
400*335b4223SMaximilian Heyne #endif /* CONFIG_PCI_XEN || CONFIG_PCI_MSI_ARCH_FALLBACKS */
401077ee78eSThomas Gleixner
402077ee78eSThomas Gleixner /*
403ae72f315SThomas Gleixner * The restore hook is still available even for fully irq domain based
404ae72f315SThomas Gleixner * setups. Courtesy to XEN/X86.
405077ee78eSThomas Gleixner */
406ae72f315SThomas Gleixner bool arch_restore_msi_irqs(struct pci_dev *dev);
4073b7d1921SEric W. Biederman
40813e7accbSThomas Gleixner #ifdef CONFIG_GENERIC_MSI_IRQ
409d9109698SJiang Liu
410aeeb5965SJiang Liu #include <linux/irqhandler.h>
411d9109698SJiang Liu
412f3cf8bb0SJiang Liu struct irq_domain;
413552c494aSMarc Zyngier struct irq_domain_ops;
414f3cf8bb0SJiang Liu struct irq_chip;
415f3cf8bb0SJiang Liu struct device_node;
416be5436c8SMarc Zyngier struct fwnode_handle;
417f3cf8bb0SJiang Liu struct msi_domain_info;
418f3cf8bb0SJiang Liu
419f3cf8bb0SJiang Liu /**
420f3cf8bb0SJiang Liu * struct msi_domain_ops - MSI interrupt domain callbacks
421f3cf8bb0SJiang Liu * @get_hwirq: Retrieve the resulting hw irq number
422f3cf8bb0SJiang Liu * @msi_init: Domain specific init function for MSI interrupts
423f3cf8bb0SJiang Liu * @msi_free: Domain specific function to free a MSI interrupts
424d9109698SJiang Liu * @msi_prepare: Prepare the allocation of the interrupts in the domain
4258f986fd7SThomas Gleixner * @prepare_desc: Optional function to prepare the allocated MSI descriptor
4268f986fd7SThomas Gleixner * in the domain
427d9109698SJiang Liu * @set_desc: Set the msi descriptor for an interrupt
42843e9e705SThomas Gleixner * @domain_alloc_irqs: Optional function to override the default allocation
42943e9e705SThomas Gleixner * function.
43043e9e705SThomas Gleixner * @domain_free_irqs: Optional function to override the default free
43143e9e705SThomas Gleixner * function.
432f6d3486aSThomas Gleixner * @msi_post_free: Optional function which is invoked after freeing
433f6d3486aSThomas Gleixner * all interrupts.
434d9109698SJiang Liu *
4351dd2c6a0SThomas Gleixner * @get_hwirq, @msi_init and @msi_free are callbacks used by the underlying
4361dd2c6a0SThomas Gleixner * irqdomain.
437d9109698SJiang Liu *
4388f986fd7SThomas Gleixner * @msi_check, @msi_prepare, @prepare_desc and @set_desc are callbacks used by the
439f2480e7dSThomas Gleixner * msi_domain_alloc/free_irqs*() variants.
44043e9e705SThomas Gleixner *
44143e9e705SThomas Gleixner * @domain_alloc_irqs, @domain_free_irqs can be used to override the
44243e9e705SThomas Gleixner * default allocation/free functions (__msi_domain_alloc/free_irqs). This
44343e9e705SThomas Gleixner * is initially for a wrapper around XENs seperate MSI universe which can't
44443e9e705SThomas Gleixner * be wrapped into the regular irq domains concepts by mere mortals. This
44543e9e705SThomas Gleixner * allows to universally use msi_domain_alloc/free_irqs without having to
44643e9e705SThomas Gleixner * special case XEN all over the place.
447f3cf8bb0SJiang Liu */
448f3cf8bb0SJiang Liu struct msi_domain_ops {
449aeeb5965SJiang Liu irq_hw_number_t (*get_hwirq)(struct msi_domain_info *info,
450aeeb5965SJiang Liu msi_alloc_info_t *arg);
451f3cf8bb0SJiang Liu int (*msi_init)(struct irq_domain *domain,
452f3cf8bb0SJiang Liu struct msi_domain_info *info,
453f3cf8bb0SJiang Liu unsigned int virq, irq_hw_number_t hwirq,
454aeeb5965SJiang Liu msi_alloc_info_t *arg);
455f3cf8bb0SJiang Liu void (*msi_free)(struct irq_domain *domain,
456f3cf8bb0SJiang Liu struct msi_domain_info *info,
457f3cf8bb0SJiang Liu unsigned int virq);
458d9109698SJiang Liu int (*msi_prepare)(struct irq_domain *domain,
459d9109698SJiang Liu struct device *dev, int nvec,
460d9109698SJiang Liu msi_alloc_info_t *arg);
4618f986fd7SThomas Gleixner void (*prepare_desc)(struct irq_domain *domain, msi_alloc_info_t *arg,
4628f986fd7SThomas Gleixner struct msi_desc *desc);
463d9109698SJiang Liu void (*set_desc)(msi_alloc_info_t *arg,
464d9109698SJiang Liu struct msi_desc *desc);
46543e9e705SThomas Gleixner int (*domain_alloc_irqs)(struct irq_domain *domain,
46643e9e705SThomas Gleixner struct device *dev, int nvec);
46743e9e705SThomas Gleixner void (*domain_free_irqs)(struct irq_domain *domain,
46843e9e705SThomas Gleixner struct device *dev);
469f6d3486aSThomas Gleixner void (*msi_post_free)(struct irq_domain *domain,
470f6d3486aSThomas Gleixner struct device *dev);
471f3cf8bb0SJiang Liu };
472f3cf8bb0SJiang Liu
473f3cf8bb0SJiang Liu /**
474f3cf8bb0SJiang Liu * struct msi_domain_info - MSI interrupt domain data
475aeeb5965SJiang Liu * @flags: Flags to decribe features and capabilities
47622db089aSAhmed S. Darwish * @bus_token: The domain bus token
47761bf992fSThomas Gleixner * @hwsize: The hardware table size or the software index limit.
47861bf992fSThomas Gleixner * If 0 then the size is considered unlimited and
47961bf992fSThomas Gleixner * gets initialized to the maximum software index limit
48061bf992fSThomas Gleixner * by the domain creation code.
481f3cf8bb0SJiang Liu * @ops: The callback data structure
482aeeb5965SJiang Liu * @chip: Optional: associated interrupt chip
483aeeb5965SJiang Liu * @chip_data: Optional: associated interrupt chip data
484aeeb5965SJiang Liu * @handler: Optional: associated interrupt flow handler
485aeeb5965SJiang Liu * @handler_data: Optional: associated interrupt flow handler data
486aeeb5965SJiang Liu * @handler_name: Optional: associated interrupt flow handler name
487aeeb5965SJiang Liu * @data: Optional: domain specific data
488f3cf8bb0SJiang Liu */
489f3cf8bb0SJiang Liu struct msi_domain_info {
490aeeb5965SJiang Liu u32 flags;
49122db089aSAhmed S. Darwish enum irq_domain_bus_token bus_token;
49261bf992fSThomas Gleixner unsigned int hwsize;
493f3cf8bb0SJiang Liu struct msi_domain_ops *ops;
494f3cf8bb0SJiang Liu struct irq_chip *chip;
495aeeb5965SJiang Liu void *chip_data;
496aeeb5965SJiang Liu irq_flow_handler_t handler;
497aeeb5965SJiang Liu void *handler_data;
498aeeb5965SJiang Liu const char *handler_name;
499f3cf8bb0SJiang Liu void *data;
500f3cf8bb0SJiang Liu };
501f3cf8bb0SJiang Liu
502ebca4396SThomas Gleixner /**
503ebca4396SThomas Gleixner * struct msi_domain_template - Template for MSI device domains
504ebca4396SThomas Gleixner * @name: Storage for the resulting name. Filled in by the core.
505ebca4396SThomas Gleixner * @chip: Interrupt chip for this domain
506ebca4396SThomas Gleixner * @ops: MSI domain ops
507ebca4396SThomas Gleixner * @info: MSI domain info data
508ebca4396SThomas Gleixner */
509ebca4396SThomas Gleixner struct msi_domain_template {
510ebca4396SThomas Gleixner char name[48];
511ebca4396SThomas Gleixner struct irq_chip chip;
512ebca4396SThomas Gleixner struct msi_domain_ops ops;
513ebca4396SThomas Gleixner struct msi_domain_info info;
514ebca4396SThomas Gleixner };
515ebca4396SThomas Gleixner
5162d958b02SThomas Gleixner /*
5172d958b02SThomas Gleixner * Flags for msi_domain_info
5182d958b02SThomas Gleixner *
5192d958b02SThomas Gleixner * Bit 0-15: Generic MSI functionality which is not subject to restriction
5202d958b02SThomas Gleixner * by parent domains
5212d958b02SThomas Gleixner *
5222d958b02SThomas Gleixner * Bit 16-31: Functionality which depends on the underlying parent domain and
5232d958b02SThomas Gleixner * can be masked out by msi_parent_ops::init_dev_msi_info() when
5242d958b02SThomas Gleixner * a device MSI domain is initialized.
5252d958b02SThomas Gleixner */
526aeeb5965SJiang Liu enum {
527aeeb5965SJiang Liu /*
528aeeb5965SJiang Liu * Init non implemented ops callbacks with default MSI domain
529aeeb5965SJiang Liu * callbacks.
530aeeb5965SJiang Liu */
531aeeb5965SJiang Liu MSI_FLAG_USE_DEF_DOM_OPS = (1 << 0),
532aeeb5965SJiang Liu /*
533aeeb5965SJiang Liu * Init non implemented chip callbacks with default MSI chip
534aeeb5965SJiang Liu * callbacks.
535aeeb5965SJiang Liu */
536aeeb5965SJiang Liu MSI_FLAG_USE_DEF_CHIP_OPS = (1 << 1),
537f3b0946dSMarc Zyngier /* Needs early activate, required for PCI */
5382d958b02SThomas Gleixner MSI_FLAG_ACTIVATE_EARLY = (1 << 2),
53922d0b12fSThomas Gleixner /*
54022d0b12fSThomas Gleixner * Must reactivate when irq is started even when
54122d0b12fSThomas Gleixner * MSI_FLAG_ACTIVATE_EARLY has been set.
54222d0b12fSThomas Gleixner */
5432d958b02SThomas Gleixner MSI_FLAG_MUST_REACTIVATE = (1 << 3),
544013bd8e5SThomas Gleixner /* Populate sysfs on alloc() and destroy it on free() */
5452d958b02SThomas Gleixner MSI_FLAG_DEV_SYSFS = (1 << 4),
546645474e2SThomas Gleixner /* Allocate simple MSI descriptors */
5472d958b02SThomas Gleixner MSI_FLAG_ALLOC_SIMPLE_MSI_DESCS = (1 << 5),
548645474e2SThomas Gleixner /* Free MSI descriptors */
5492d958b02SThomas Gleixner MSI_FLAG_FREE_MSI_DESCS = (1 << 6),
5502d958b02SThomas Gleixner
5512d958b02SThomas Gleixner /* Mask for the generic functionality */
5522d958b02SThomas Gleixner MSI_GENERIC_FLAGS_MASK = GENMASK(15, 0),
5532d958b02SThomas Gleixner
5542d958b02SThomas Gleixner /* Mask for the domain specific functionality */
5552d958b02SThomas Gleixner MSI_DOMAIN_FLAGS_MASK = GENMASK(31, 16),
5562d958b02SThomas Gleixner
5572d958b02SThomas Gleixner /* Support multiple PCI MSI interrupts */
5582d958b02SThomas Gleixner MSI_FLAG_MULTI_PCI_MSI = (1 << 16),
5592d958b02SThomas Gleixner /* Support PCI MSIX interrupts */
5602d958b02SThomas Gleixner MSI_FLAG_PCI_MSIX = (1 << 17),
5612d958b02SThomas Gleixner /* Is level-triggered capable, using two messages */
5622d958b02SThomas Gleixner MSI_FLAG_LEVEL_CAPABLE = (1 << 18),
5632d958b02SThomas Gleixner /* MSI-X entries must be contiguous */
5642d958b02SThomas Gleixner MSI_FLAG_MSIX_CONTIGUOUS = (1 << 19),
565b834e3c0SThomas Gleixner /* PCI/MSI-X vectors can be dynamically allocated/freed post MSI-X enable */
566b834e3c0SThomas Gleixner MSI_FLAG_PCI_MSIX_ALLOC_DYN = (1 << 20),
567e23d4192SThomas Gleixner /* Support for PCI/IMS */
568e23d4192SThomas Gleixner MSI_FLAG_PCI_IMS = (1 << 21),
569aeeb5965SJiang Liu };
570aeeb5965SJiang Liu
571b78780d9SThomas Gleixner /**
572b78780d9SThomas Gleixner * struct msi_parent_ops - MSI parent domain callbacks and configuration info
573b78780d9SThomas Gleixner *
574b78780d9SThomas Gleixner * @supported_flags: Required: The supported MSI flags of the parent domain
575b78780d9SThomas Gleixner * @prefix: Optional: Prefix for the domain and chip name
576b78780d9SThomas Gleixner * @init_dev_msi_info: Required: Callback for MSI parent domains to setup parent
577b78780d9SThomas Gleixner * domain specific domain flags, domain ops and interrupt chip
578b78780d9SThomas Gleixner * callbacks when a per device domain is created.
579b78780d9SThomas Gleixner */
580b78780d9SThomas Gleixner struct msi_parent_ops {
581b78780d9SThomas Gleixner u32 supported_flags;
582b78780d9SThomas Gleixner const char *prefix;
583b78780d9SThomas Gleixner bool (*init_dev_msi_info)(struct device *dev, struct irq_domain *domain,
584b78780d9SThomas Gleixner struct irq_domain *msi_parent_domain,
585b78780d9SThomas Gleixner struct msi_domain_info *msi_child_info);
586b78780d9SThomas Gleixner };
587b78780d9SThomas Gleixner
588b78780d9SThomas Gleixner bool msi_parent_init_dev_msi_info(struct device *dev, struct irq_domain *domain,
589b78780d9SThomas Gleixner struct irq_domain *msi_parent_domain,
590b78780d9SThomas Gleixner struct msi_domain_info *msi_child_info);
591b78780d9SThomas Gleixner
592f3cf8bb0SJiang Liu int msi_domain_set_affinity(struct irq_data *data, const struct cpumask *mask,
593f3cf8bb0SJiang Liu bool force);
594f3cf8bb0SJiang Liu
595be5436c8SMarc Zyngier struct irq_domain *msi_create_irq_domain(struct fwnode_handle *fwnode,
596f3cf8bb0SJiang Liu struct msi_domain_info *info,
597f3cf8bb0SJiang Liu struct irq_domain *parent);
5984cd5f440SThomas Gleixner
59927a6dea3SThomas Gleixner bool msi_create_device_irq_domain(struct device *dev, unsigned int domid,
60027a6dea3SThomas Gleixner const struct msi_domain_template *template,
60127a6dea3SThomas Gleixner unsigned int hwsize, void *domain_data,
60227a6dea3SThomas Gleixner void *chip_data);
60327a6dea3SThomas Gleixner void msi_remove_device_irq_domain(struct device *dev, unsigned int domid);
60427a6dea3SThomas Gleixner
60526e91b75SThomas Gleixner bool msi_match_device_irq_domain(struct device *dev, unsigned int domid,
60626e91b75SThomas Gleixner enum irq_domain_bus_token bus_token);
60726e91b75SThomas Gleixner
608f2480e7dSThomas Gleixner int msi_domain_alloc_irqs_range_locked(struct device *dev, unsigned int domid,
609f2480e7dSThomas Gleixner unsigned int first, unsigned int last);
610f2480e7dSThomas Gleixner int msi_domain_alloc_irqs_range(struct device *dev, unsigned int domid,
611f2480e7dSThomas Gleixner unsigned int first, unsigned int last);
612f2480e7dSThomas Gleixner int msi_domain_alloc_irqs_all_locked(struct device *dev, unsigned int domid, int nirqs);
613f2480e7dSThomas Gleixner
6143d393b21SThomas Gleixner struct msi_map msi_domain_alloc_irq_at(struct device *dev, unsigned int domid, unsigned int index,
6153d393b21SThomas Gleixner const struct irq_affinity_desc *affdesc,
6163d393b21SThomas Gleixner union msi_instance_cookie *cookie);
617f2480e7dSThomas Gleixner
6184cd5f440SThomas Gleixner void msi_domain_free_irqs_range_locked(struct device *dev, unsigned int domid,
6194cd5f440SThomas Gleixner unsigned int first, unsigned int last);
6204cd5f440SThomas Gleixner void msi_domain_free_irqs_range(struct device *dev, unsigned int domid,
6214cd5f440SThomas Gleixner unsigned int first, unsigned int last);
6224cd5f440SThomas Gleixner void msi_domain_free_irqs_all_locked(struct device *dev, unsigned int domid);
6234cd5f440SThomas Gleixner void msi_domain_free_irqs_all(struct device *dev, unsigned int domid);
6244cd5f440SThomas Gleixner
625f3cf8bb0SJiang Liu struct msi_domain_info *msi_get_domain_info(struct irq_domain *domain);
626f3cf8bb0SJiang Liu
627be5436c8SMarc Zyngier struct irq_domain *platform_msi_create_irq_domain(struct fwnode_handle *fwnode,
628c09fcc4bSMarc Zyngier struct msi_domain_info *info,
629c09fcc4bSMarc Zyngier struct irq_domain *parent);
630c09fcc4bSMarc Zyngier int platform_msi_domain_alloc_irqs(struct device *dev, unsigned int nvec,
631c09fcc4bSMarc Zyngier irq_write_msi_msg_t write_msi_msg);
632c09fcc4bSMarc Zyngier void platform_msi_domain_free_irqs(struct device *dev);
633b2eba39bSMarc Zyngier
634b2eba39bSMarc Zyngier /* When an MSI domain is used as an intermediate domain */
635b2eba39bSMarc Zyngier int msi_domain_prepare_irqs(struct irq_domain *domain, struct device *dev,
636b2eba39bSMarc Zyngier int nvec, msi_alloc_info_t *args);
6372145ac93SMarc Zyngier int msi_domain_populate_irqs(struct irq_domain *domain, struct device *dev,
6382145ac93SMarc Zyngier int virq, int nvec, msi_alloc_info_t *args);
6390fb7fb71SThomas Gleixner void msi_domain_depopulate_descs(struct device *dev, int virq, int nvec);
6400fb7fb71SThomas Gleixner
641552c494aSMarc Zyngier struct irq_domain *
6421f83515bSMarc Zyngier __platform_msi_create_device_domain(struct device *dev,
643552c494aSMarc Zyngier unsigned int nvec,
6441f83515bSMarc Zyngier bool is_tree,
645552c494aSMarc Zyngier irq_write_msi_msg_t write_msi_msg,
646552c494aSMarc Zyngier const struct irq_domain_ops *ops,
647552c494aSMarc Zyngier void *host_data);
6481f83515bSMarc Zyngier
6491f83515bSMarc Zyngier #define platform_msi_create_device_domain(dev, nvec, write, ops, data) \
6501f83515bSMarc Zyngier __platform_msi_create_device_domain(dev, nvec, false, write, ops, data)
6511f83515bSMarc Zyngier #define platform_msi_create_device_tree_domain(dev, nvec, write, ops, data) \
6521f83515bSMarc Zyngier __platform_msi_create_device_domain(dev, nvec, true, write, ops, data)
6531f83515bSMarc Zyngier
6549835cec6SThomas Gleixner int platform_msi_device_domain_alloc(struct irq_domain *domain, unsigned int virq,
655552c494aSMarc Zyngier unsigned int nr_irqs);
6569835cec6SThomas Gleixner void platform_msi_device_domain_free(struct irq_domain *domain, unsigned int virq,
657552c494aSMarc Zyngier unsigned int nvec);
658552c494aSMarc Zyngier void *platform_msi_get_host_data(struct irq_domain *domain);
65917cde5e6SJason Gunthorpe
66017cde5e6SJason Gunthorpe bool msi_device_has_isolated_msi(struct device *dev);
66117cde5e6SJason Gunthorpe #else /* CONFIG_GENERIC_MSI_IRQ */
msi_device_has_isolated_msi(struct device * dev)66217cde5e6SJason Gunthorpe static inline bool msi_device_has_isolated_msi(struct device *dev)
66317cde5e6SJason Gunthorpe {
66417cde5e6SJason Gunthorpe /*
66517cde5e6SJason Gunthorpe * Arguably if the platform does not enable MSI support then it has
66617cde5e6SJason Gunthorpe * "isolated MSI", as an interrupt controller that cannot receive MSIs
667bf210f79SJason Gunthorpe * is inherently isolated by our definition. The default definition for
668bf210f79SJason Gunthorpe * arch_is_isolated_msi() is conservative and returns false anyhow.
66917cde5e6SJason Gunthorpe */
670bf210f79SJason Gunthorpe return arch_is_isolated_msi();
67117cde5e6SJason Gunthorpe }
67213e7accbSThomas Gleixner #endif /* CONFIG_GENERIC_MSI_IRQ */
673f3cf8bb0SJiang Liu
674a474d3fbSThomas Gleixner /* PCI specific interfaces */
675a474d3fbSThomas Gleixner #ifdef CONFIG_PCI_MSI
676a474d3fbSThomas Gleixner struct pci_dev *msi_desc_to_pci_dev(struct msi_desc *desc);
677a474d3fbSThomas Gleixner void pci_write_msi_msg(unsigned int irq, struct msi_msg *msg);
678a474d3fbSThomas Gleixner void __pci_read_msi_msg(struct msi_desc *entry, struct msi_msg *msg);
679a474d3fbSThomas Gleixner void __pci_write_msi_msg(struct msi_desc *entry, struct msi_msg *msg);
680a474d3fbSThomas Gleixner void pci_msi_mask_irq(struct irq_data *data);
681a474d3fbSThomas Gleixner void pci_msi_unmask_irq(struct irq_data *data);
682be5436c8SMarc Zyngier struct irq_domain *pci_msi_create_irq_domain(struct fwnode_handle *fwnode,
6833878eaefSJiang Liu struct msi_domain_info *info,
6843878eaefSJiang Liu struct irq_domain *parent);
685b6eec9b7SDavid Daney u32 pci_msi_domain_get_msi_rid(struct irq_domain *domain, struct pci_dev *pdev);
68654fa97eeSMarc Zyngier struct irq_domain *pci_msi_get_device_domain(struct pci_dev *pdev);
687a474d3fbSThomas Gleixner #else /* CONFIG_PCI_MSI */
pci_msi_get_device_domain(struct pci_dev * pdev)68854fa97eeSMarc Zyngier static inline struct irq_domain *pci_msi_get_device_domain(struct pci_dev *pdev)
68954fa97eeSMarc Zyngier {
69054fa97eeSMarc Zyngier return NULL;
69154fa97eeSMarc Zyngier }
pci_write_msi_msg(unsigned int irq,struct msi_msg * msg)692a474d3fbSThomas Gleixner static inline void pci_write_msi_msg(unsigned int irq, struct msi_msg *msg) { }
693a474d3fbSThomas Gleixner #endif /* !CONFIG_PCI_MSI */
6943878eaefSJiang Liu
6953b7d1921SEric W. Biederman #endif /* LINUX_MSI_H */
696