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>
22e1b6705bSYury Norov #include <linux/cpumask_types.h>
236b6941f6SThomas Gleixner #include <linux/msi_api.h>
24ebca4396SThomas Gleixner #include <linux/irq.h>
252d958b02SThomas Gleixner
268073c1acSThomas Gleixner #include <asm/msi.h>
274aa9bc95SMichael Ellerman
288073c1acSThomas Gleixner /* Dummy shadow structures if an architecture does not define them */
298073c1acSThomas Gleixner #ifndef arch_msi_msg_addr_lo
308073c1acSThomas Gleixner typedef struct arch_msi_msg_addr_lo {
318073c1acSThomas Gleixner u32 address_lo;
328073c1acSThomas Gleixner } __attribute__ ((packed)) arch_msi_msg_addr_lo_t;
338073c1acSThomas Gleixner #endif
348073c1acSThomas Gleixner
358073c1acSThomas Gleixner #ifndef arch_msi_msg_addr_hi
368073c1acSThomas Gleixner typedef struct arch_msi_msg_addr_hi {
378073c1acSThomas Gleixner u32 address_hi;
388073c1acSThomas Gleixner } __attribute__ ((packed)) arch_msi_msg_addr_hi_t;
398073c1acSThomas Gleixner #endif
408073c1acSThomas Gleixner
418073c1acSThomas Gleixner #ifndef arch_msi_msg_data
428073c1acSThomas Gleixner typedef struct arch_msi_msg_data {
438073c1acSThomas Gleixner u32 data;
448073c1acSThomas Gleixner } __attribute__ ((packed)) arch_msi_msg_data_t;
458073c1acSThomas Gleixner #endif
468073c1acSThomas Gleixner
47bf210f79SJason Gunthorpe #ifndef arch_is_isolated_msi
48bf210f79SJason Gunthorpe #define arch_is_isolated_msi() false
49bf210f79SJason Gunthorpe #endif
50bf210f79SJason Gunthorpe
518073c1acSThomas Gleixner /**
528073c1acSThomas Gleixner * msi_msg - Representation of a MSI message
538073c1acSThomas Gleixner * @address_lo: Low 32 bits of msi message address
548073c1acSThomas Gleixner * @arch_addrlo: Architecture specific shadow of @address_lo
558073c1acSThomas Gleixner * @address_hi: High 32 bits of msi message address
568073c1acSThomas Gleixner * (only used when device supports it)
578073c1acSThomas Gleixner * @arch_addrhi: Architecture specific shadow of @address_hi
588073c1acSThomas Gleixner * @data: MSI message data (usually 16 bits)
598073c1acSThomas Gleixner * @arch_data: Architecture specific shadow of @data
608073c1acSThomas Gleixner */
613b7d1921SEric W. Biederman struct msi_msg {
628073c1acSThomas Gleixner union {
638073c1acSThomas Gleixner u32 address_lo;
648073c1acSThomas Gleixner arch_msi_msg_addr_lo_t arch_addr_lo;
658073c1acSThomas Gleixner };
668073c1acSThomas Gleixner union {
678073c1acSThomas Gleixner u32 address_hi;
688073c1acSThomas Gleixner arch_msi_msg_addr_hi_t arch_addr_hi;
698073c1acSThomas Gleixner };
708073c1acSThomas Gleixner union {
718073c1acSThomas Gleixner u32 data;
728073c1acSThomas Gleixner arch_msi_msg_data_t arch_data;
738073c1acSThomas Gleixner };
743b7d1921SEric W. Biederman };
753b7d1921SEric W. Biederman
76c54c1879SSatoru Takeuchi /* Helper functions */
7739431acbSThomas Gleixner struct msi_desc;
7825a98bd4SJiang Liu struct pci_dev;
79bf5e758fSThomas Gleixner struct device_attribute;
8064258eaaSThomas Gleixner struct irq_domain;
813d393b21SThomas Gleixner struct irq_affinity_desc;
82bf6e054eSThomas Gleixner
83*112e43e9SLinus Torvalds void __get_cached_msi_msg(struct msi_desc *entry, struct msi_msg *msg);
842f44e29cSArnd Bergmann #ifdef CONFIG_GENERIC_MSI_IRQ
852366d06eSBjorn Helgaas void get_cached_msi_msg(unsigned int irq, struct msi_msg *msg);
862f44e29cSArnd Bergmann #else
get_cached_msi_msg(unsigned int irq,struct msi_msg * msg)8713e7accbSThomas Gleixner static inline void get_cached_msi_msg(unsigned int irq, struct msi_msg *msg) { }
882f44e29cSArnd Bergmann #endif
89891d4a48SJiang Liu
90c09fcc4bSMarc Zyngier typedef void (*irq_write_msi_msg_t)(struct msi_desc *desc,
91c09fcc4bSMarc Zyngier struct msi_msg *msg);
92c09fcc4bSMarc Zyngier
93c09fcc4bSMarc Zyngier /**
94e58f2259SThomas Gleixner * pci_msi_desc - PCI/MSI specific MSI descriptor data
95e58f2259SThomas Gleixner *
96e58f2259SThomas Gleixner * @msi_mask: [PCI MSI] MSI cached mask bits
97e58f2259SThomas Gleixner * @msix_ctrl: [PCI MSI-X] MSI-X cached per vector control bits
98e58f2259SThomas Gleixner * @is_msix: [PCI MSI/X] True if MSI-X
99e58f2259SThomas Gleixner * @multiple: [PCI MSI/X] log2 num of messages allocated
100e58f2259SThomas Gleixner * @multi_cap: [PCI MSI/X] log2 num of messages supported
101e58f2259SThomas Gleixner * @can_mask: [PCI MSI/X] Masking supported?
102e58f2259SThomas Gleixner * @is_64: [PCI MSI/X] Address size: 0=32bit 1=64bit
103e58f2259SThomas Gleixner * @default_irq:[PCI MSI/X] The default pre-assigned non-MSI irq
104e58f2259SThomas Gleixner * @mask_pos: [PCI MSI] Mask register position
105e58f2259SThomas Gleixner * @mask_base: [PCI MSI-X] Mask register base address
106e58f2259SThomas Gleixner */
107e58f2259SThomas Gleixner struct pci_msi_desc {
108e58f2259SThomas Gleixner union {
109e58f2259SThomas Gleixner u32 msi_mask;
110e58f2259SThomas Gleixner u32 msix_ctrl;
111e58f2259SThomas Gleixner };
112e58f2259SThomas Gleixner struct {
113e58f2259SThomas Gleixner u8 is_msix : 1;
114e58f2259SThomas Gleixner u8 multiple : 3;
115e58f2259SThomas Gleixner u8 multi_cap : 3;
116e58f2259SThomas Gleixner u8 can_mask : 1;
117e58f2259SThomas Gleixner u8 is_64 : 1;
118e58f2259SThomas Gleixner u8 is_virtual : 1;
119e58f2259SThomas Gleixner unsigned default_irq;
120e58f2259SThomas Gleixner } msi_attrib;
121e58f2259SThomas Gleixner union {
122e58f2259SThomas Gleixner u8 mask_pos;
123e58f2259SThomas Gleixner void __iomem *mask_base;
124e58f2259SThomas Gleixner };
125e58f2259SThomas Gleixner };
126e58f2259SThomas Gleixner
127efd42049SThomas Gleixner /**
128efd42049SThomas Gleixner * union msi_domain_cookie - Opaque MSI domain specific data
129efd42049SThomas Gleixner * @value: u64 value store
130efd42049SThomas Gleixner * @ptr: Pointer to domain specific data
131efd42049SThomas Gleixner * @iobase: Domain specific IOmem pointer
132efd42049SThomas Gleixner *
133efd42049SThomas Gleixner * The content of this data is implementation defined and used by the MSI
134efd42049SThomas Gleixner * domain to store domain specific information which is requried for
135efd42049SThomas Gleixner * interrupt chip callbacks.
136efd42049SThomas Gleixner */
137efd42049SThomas Gleixner union msi_domain_cookie {
138efd42049SThomas Gleixner u64 value;
139efd42049SThomas Gleixner void *ptr;
140efd42049SThomas Gleixner void __iomem *iobase;
141efd42049SThomas Gleixner };
142efd42049SThomas Gleixner
143efd42049SThomas Gleixner /**
144efd42049SThomas Gleixner * struct msi_desc_data - Generic MSI descriptor data
145efd42049SThomas Gleixner * @dcookie: Cookie for MSI domain specific data which is required
146efd42049SThomas Gleixner * for irq_chip callbacks
147efd42049SThomas Gleixner * @icookie: Cookie for the MSI interrupt instance provided by
148efd42049SThomas Gleixner * the usage site to the allocation function
149efd42049SThomas Gleixner *
150efd42049SThomas Gleixner * The content of this data is implementation defined, e.g. PCI/IMS
151efd42049SThomas Gleixner * implementations define the meaning of the data. The MSI core ignores
152efd42049SThomas Gleixner * this data completely.
153efd42049SThomas Gleixner */
154efd42049SThomas Gleixner struct msi_desc_data {
155efd42049SThomas Gleixner union msi_domain_cookie dcookie;
156efd42049SThomas Gleixner union msi_instance_cookie icookie;
157efd42049SThomas Gleixner };
158efd42049SThomas Gleixner
159645474e2SThomas Gleixner #define MSI_MAX_INDEX ((unsigned int)USHRT_MAX)
160645474e2SThomas Gleixner
161e58f2259SThomas Gleixner /**
162fc88419cSJiang Liu * struct msi_desc - Descriptor structure for MSI based interrupts
163fc88419cSJiang Liu * @irq: The base interrupt number
164fc88419cSJiang Liu * @nvec_used: The number of vectors used
165fc88419cSJiang Liu * @dev: Pointer to the device which uses this descriptor
166fc88419cSJiang Liu * @msg: The last set MSI message cached for reuse
1670972fa57SThomas Gleixner * @affinity: Optional pointer to a cpu affinity mask for this descriptor
1681f7df3a6SJason Gunthorpe * @iommu_msi_iova: Optional shifted IOVA from the IOMMU to override the msi_addr.
1691f7df3a6SJason Gunthorpe * Only used if iommu_msi_shift != 0
1701f7df3a6SJason Gunthorpe * @iommu_msi_shift: Indicates how many bits of the original address should be
1711f7df3a6SJason Gunthorpe * preserved when using iommu_msi_iova.
172bf5e758fSThomas Gleixner * @sysfs_attr: Pointer to sysfs device attribute
173fc88419cSJiang Liu *
174d7cc609fSLogan Gunthorpe * @write_msi_msg: Callback that may be called when the MSI message
175d7cc609fSLogan Gunthorpe * address or data changes
176d7cc609fSLogan Gunthorpe * @write_msi_msg_data: Data parameter for the callback.
177d7cc609fSLogan Gunthorpe *
17820c6d424SThomas Gleixner * @msi_index: Index of the msi descriptor
1790f180958SThomas Gleixner * @pci: PCI specific msi descriptor data
180efd42049SThomas Gleixner * @data: Generic MSI descriptor data
181fc88419cSJiang Liu */
1823b7d1921SEric W. Biederman struct msi_desc {
183fc88419cSJiang Liu /* Shared device/bus type independent data */
184fc88419cSJiang Liu unsigned int irq;
185fc88419cSJiang Liu unsigned int nvec_used;
186fc88419cSJiang Liu struct device *dev;
187fc88419cSJiang Liu struct msi_msg msg;
188bec04037SDou Liyang struct irq_affinity_desc *affinity;
189aaebdf8dSJulien Grall #ifdef CONFIG_IRQ_MSI_IOMMU
1901f7df3a6SJason Gunthorpe u64 iommu_msi_iova : 58;
1911f7df3a6SJason Gunthorpe u64 iommu_msi_shift : 6;
192aaebdf8dSJulien Grall #endif
193bf5e758fSThomas Gleixner #ifdef CONFIG_SYSFS
194bf5e758fSThomas Gleixner struct device_attribute *sysfs_attrs;
195bf5e758fSThomas Gleixner #endif
1963b7d1921SEric W. Biederman
197d7cc609fSLogan Gunthorpe void (*write_msi_msg)(struct msi_desc *entry, void *data);
198d7cc609fSLogan Gunthorpe void *write_msi_msg_data;
199d7cc609fSLogan Gunthorpe
20020c6d424SThomas Gleixner u16 msi_index;
201efd42049SThomas Gleixner union {
202e58f2259SThomas Gleixner struct pci_msi_desc pci;
203efd42049SThomas Gleixner struct msi_desc_data data;
204efd42049SThomas Gleixner };
2053b7d1921SEric W. Biederman };
2063b7d1921SEric W. Biederman
2071046f71dSThomas Gleixner /*
2081046f71dSThomas Gleixner * Filter values for the MSI descriptor iterators and accessor functions.
2091046f71dSThomas Gleixner */
2101046f71dSThomas Gleixner enum msi_desc_filter {
2111046f71dSThomas Gleixner /* All descriptors */
2121046f71dSThomas Gleixner MSI_DESC_ALL,
2131046f71dSThomas Gleixner /* Descriptors which have no interrupt associated */
2141046f71dSThomas Gleixner MSI_DESC_NOTASSOCIATED,
2151046f71dSThomas Gleixner /* Descriptors which have an interrupt associated */
2161046f71dSThomas Gleixner MSI_DESC_ASSOCIATED,
2171046f71dSThomas Gleixner };
2181046f71dSThomas Gleixner
219f1139f90SThomas Gleixner
220f1139f90SThomas Gleixner /**
221f1139f90SThomas Gleixner * struct msi_dev_domain - The internals of MSI domain info per device
222f1139f90SThomas Gleixner * @store: Xarray for storing MSI descriptor pointers
22364258eaaSThomas Gleixner * @irqdomain: Pointer to a per device interrupt domain
224f1139f90SThomas Gleixner */
225f1139f90SThomas Gleixner struct msi_dev_domain {
226f1139f90SThomas Gleixner struct xarray store;
22764258eaaSThomas Gleixner struct irq_domain *domain;
228f1139f90SThomas Gleixner };
229f1139f90SThomas Gleixner
230013bd8e5SThomas Gleixner int msi_setup_device_data(struct device *dev);
231013bd8e5SThomas Gleixner
232*112e43e9SLinus Torvalds void msi_lock_descs(struct device *dev);
233*112e43e9SLinus Torvalds void msi_unlock_descs(struct device *dev);
2345c99e022SThomas Gleixner
23594ff94cfSThomas Gleixner struct msi_desc *msi_domain_first_desc(struct device *dev, unsigned int domid,
23694ff94cfSThomas Gleixner enum msi_desc_filter filter);
2371046f71dSThomas Gleixner
2381046f71dSThomas Gleixner /**
23994ff94cfSThomas Gleixner * msi_first_desc - Get the first MSI descriptor of the default irqdomain
24094ff94cfSThomas Gleixner * @dev: Device to operate on
24194ff94cfSThomas Gleixner * @filter: Descriptor state filter
24294ff94cfSThomas Gleixner *
24394ff94cfSThomas Gleixner * Must be called with the MSI descriptor mutex held, i.e. msi_lock_descs()
24494ff94cfSThomas Gleixner * must be invoked before the call.
24594ff94cfSThomas Gleixner *
24694ff94cfSThomas Gleixner * Return: Pointer to the first MSI descriptor matching the search
24794ff94cfSThomas Gleixner * criteria, NULL if none found.
24894ff94cfSThomas Gleixner */
msi_first_desc(struct device * dev,enum msi_desc_filter filter)24994ff94cfSThomas Gleixner static inline struct msi_desc *msi_first_desc(struct device *dev,
25094ff94cfSThomas Gleixner enum msi_desc_filter filter)
25194ff94cfSThomas Gleixner {
25294ff94cfSThomas Gleixner return msi_domain_first_desc(dev, MSI_DEFAULT_DOMAIN, filter);
25394ff94cfSThomas Gleixner }
25494ff94cfSThomas Gleixner
25594ff94cfSThomas Gleixner struct msi_desc *msi_next_desc(struct device *dev, unsigned int domid,
25694ff94cfSThomas Gleixner enum msi_desc_filter filter);
25794ff94cfSThomas Gleixner
25894ff94cfSThomas Gleixner /**
25994ff94cfSThomas Gleixner * msi_domain_for_each_desc - Iterate the MSI descriptors in a specific domain
26094ff94cfSThomas Gleixner *
26194ff94cfSThomas Gleixner * @desc: struct msi_desc pointer used as iterator
26294ff94cfSThomas Gleixner * @dev: struct device pointer - device to iterate
26394ff94cfSThomas Gleixner * @domid: The id of the interrupt domain which should be walked.
26494ff94cfSThomas Gleixner * @filter: Filter for descriptor selection
26594ff94cfSThomas Gleixner *
26694ff94cfSThomas Gleixner * Notes:
26794ff94cfSThomas Gleixner * - The loop must be protected with a msi_lock_descs()/msi_unlock_descs()
26894ff94cfSThomas Gleixner * pair.
26994ff94cfSThomas Gleixner * - It is safe to remove a retrieved MSI descriptor in the loop.
27094ff94cfSThomas Gleixner */
27194ff94cfSThomas Gleixner #define msi_domain_for_each_desc(desc, dev, domid, filter) \
27294ff94cfSThomas Gleixner for ((desc) = msi_domain_first_desc((dev), (domid), (filter)); (desc); \
27394ff94cfSThomas Gleixner (desc) = msi_next_desc((dev), (domid), (filter)))
27494ff94cfSThomas Gleixner
27594ff94cfSThomas Gleixner /**
27694ff94cfSThomas Gleixner * msi_for_each_desc - Iterate the MSI descriptors in the default irqdomain
2771046f71dSThomas Gleixner *
2781046f71dSThomas Gleixner * @desc: struct msi_desc pointer used as iterator
2791046f71dSThomas Gleixner * @dev: struct device pointer - device to iterate
2801046f71dSThomas Gleixner * @filter: Filter for descriptor selection
2811046f71dSThomas Gleixner *
2821046f71dSThomas Gleixner * Notes:
2831046f71dSThomas Gleixner * - The loop must be protected with a msi_lock_descs()/msi_unlock_descs()
2841046f71dSThomas Gleixner * pair.
2851046f71dSThomas Gleixner * - It is safe to remove a retrieved MSI descriptor in the loop.
2861046f71dSThomas Gleixner */
2871046f71dSThomas Gleixner #define msi_for_each_desc(desc, dev, filter) \
28894ff94cfSThomas Gleixner msi_domain_for_each_desc((desc), (dev), MSI_DEFAULT_DOMAIN, (filter))
2891046f71dSThomas Gleixner
29025a98bd4SJiang Liu #define msi_desc_to_dev(desc) ((desc)->dev)
291d31eb342SJiang Liu
msi_desc_set_iommu_msi_iova(struct msi_desc * desc,u64 msi_iova,unsigned int msi_shift)2921f7df3a6SJason Gunthorpe static inline void msi_desc_set_iommu_msi_iova(struct msi_desc *desc, u64 msi_iova,
2931f7df3a6SJason Gunthorpe unsigned int msi_shift)
2941f7df3a6SJason Gunthorpe {
295aaebdf8dSJulien Grall #ifdef CONFIG_IRQ_MSI_IOMMU
2961f7df3a6SJason Gunthorpe desc->iommu_msi_iova = msi_iova >> msi_shift;
2971f7df3a6SJason Gunthorpe desc->iommu_msi_shift = msi_shift;
298aaebdf8dSJulien Grall #endif
299aaebdf8dSJulien Grall }
300aaebdf8dSJulien Grall
3019349887eSJason Gunthorpe /**
3029349887eSJason Gunthorpe * msi_msg_set_addr() - Set MSI address in an MSI message
3039349887eSJason Gunthorpe *
3049349887eSJason Gunthorpe * @desc: MSI descriptor that may carry an IOVA base address for MSI via @iommu_msi_iova/shift
3059349887eSJason Gunthorpe * @msg: Target MSI message to set its address_hi and address_lo
3069349887eSJason Gunthorpe * @msi_addr: Physical address to set the MSI message
3079349887eSJason Gunthorpe *
3089349887eSJason Gunthorpe * Notes:
3099349887eSJason Gunthorpe * - Override @msi_addr using the IOVA base address in the @desc if @iommu_msi_shift is set
3109349887eSJason Gunthorpe * - Otherwise, simply set @msi_addr to @msg
3119349887eSJason Gunthorpe */
msi_msg_set_addr(struct msi_desc * desc,struct msi_msg * msg,phys_addr_t msi_addr)3129349887eSJason Gunthorpe static inline void msi_msg_set_addr(struct msi_desc *desc, struct msi_msg *msg,
3139349887eSJason Gunthorpe phys_addr_t msi_addr)
314aaebdf8dSJulien Grall {
3159349887eSJason Gunthorpe #ifdef CONFIG_IRQ_MSI_IOMMU
3169349887eSJason Gunthorpe if (desc->iommu_msi_shift) {
3179349887eSJason Gunthorpe u64 msi_iova = desc->iommu_msi_iova << desc->iommu_msi_shift;
318aaebdf8dSJulien Grall
3199349887eSJason Gunthorpe msg->address_hi = upper_32_bits(msi_iova);
3209349887eSJason Gunthorpe msg->address_lo = lower_32_bits(msi_iova) |
3219349887eSJason Gunthorpe (msi_addr & ((1 << desc->iommu_msi_shift) - 1));
3229349887eSJason Gunthorpe return;
323aaebdf8dSJulien Grall }
324aaebdf8dSJulien Grall #endif
3259349887eSJason Gunthorpe msg->address_hi = upper_32_bits(msi_addr);
3269349887eSJason Gunthorpe msg->address_lo = lower_32_bits(msi_addr);
3279349887eSJason Gunthorpe }
328aaebdf8dSJulien Grall
329fc8ab388SThomas Gleixner int msi_domain_insert_msi_desc(struct device *dev, unsigned int domid,
330fc8ab388SThomas Gleixner struct msi_desc *init_desc);
331fc8ab388SThomas Gleixner /**
332fc8ab388SThomas Gleixner * msi_insert_msi_desc - Allocate and initialize a MSI descriptor in the
333fc8ab388SThomas Gleixner * default irqdomain and insert it at @init_desc->msi_index
334fc8ab388SThomas Gleixner * @dev: Pointer to the device for which the descriptor is allocated
335fc8ab388SThomas Gleixner * @init_desc: Pointer to an MSI descriptor to initialize the new descriptor
336fc8ab388SThomas Gleixner *
337fc8ab388SThomas Gleixner * Return: 0 on success or an appropriate failure code.
338fc8ab388SThomas Gleixner */
msi_insert_msi_desc(struct device * dev,struct msi_desc * init_desc)339fc8ab388SThomas Gleixner static inline int msi_insert_msi_desc(struct device *dev, struct msi_desc *init_desc)
340fc8ab388SThomas Gleixner {
341fc8ab388SThomas Gleixner return msi_domain_insert_msi_desc(dev, MSI_DEFAULT_DOMAIN, init_desc);
342fc8ab388SThomas Gleixner }
343fc8ab388SThomas Gleixner
344377712c5SThomas Gleixner void msi_domain_free_msi_descs_range(struct device *dev, unsigned int domid,
345377712c5SThomas Gleixner unsigned int first, unsigned int last);
346645474e2SThomas Gleixner
347645474e2SThomas Gleixner /**
348377712c5SThomas Gleixner * msi_free_msi_descs_range - Free a range of MSI descriptors of a device
349377712c5SThomas Gleixner * in the default irqdomain
350377712c5SThomas Gleixner *
351377712c5SThomas Gleixner * @dev: Device for which to free the descriptors
352377712c5SThomas Gleixner * @first: Index to start freeing from (inclusive)
353377712c5SThomas Gleixner * @last: Last index to be freed (inclusive)
354377712c5SThomas Gleixner */
msi_free_msi_descs_range(struct device * dev,unsigned int first,unsigned int last)355377712c5SThomas Gleixner static inline void msi_free_msi_descs_range(struct device *dev, unsigned int first,
356377712c5SThomas Gleixner unsigned int last)
357377712c5SThomas Gleixner {
358377712c5SThomas Gleixner msi_domain_free_msi_descs_range(dev, MSI_DEFAULT_DOMAIN, first, last);
359377712c5SThomas Gleixner }
360377712c5SThomas Gleixner
361377712c5SThomas Gleixner /**
362377712c5SThomas Gleixner * msi_free_msi_descs - Free all MSI descriptors of a device in the default irqdomain
363645474e2SThomas Gleixner * @dev: Device to free the descriptors
364645474e2SThomas Gleixner */
msi_free_msi_descs(struct device * dev)365645474e2SThomas Gleixner static inline void msi_free_msi_descs(struct device *dev)
366645474e2SThomas Gleixner {
3672f2940d1SThomas Gleixner msi_free_msi_descs_range(dev, 0, MSI_MAX_INDEX);
368645474e2SThomas Gleixner }
36960290525SThomas Gleixner
3703b7d1921SEric W. Biederman /*
371077ee78eSThomas Gleixner * The arch hooks to setup up msi irqs. Default functions are implemented
372077ee78eSThomas Gleixner * as weak symbols so that they /can/ be overriden by architecture specific
373b227be0dSMarc Zyngier * code if needed. These hooks can only be enabled by the architecture.
374077ee78eSThomas Gleixner *
375077ee78eSThomas Gleixner * If CONFIG_PCI_MSI_ARCH_FALLBACKS is not selected they are replaced by
376077ee78eSThomas Gleixner * stubs with warnings.
3773b7d1921SEric W. Biederman */
378077ee78eSThomas Gleixner #ifdef CONFIG_PCI_MSI_ARCH_FALLBACKS
379f7feaca7SEric W. Biederman int arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc);
3803b7d1921SEric W. Biederman void arch_teardown_msi_irq(unsigned int irq);
3812366d06eSBjorn Helgaas int arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type);
3822366d06eSBjorn Helgaas void arch_teardown_msi_irqs(struct pci_dev *dev);
383335b4223SMaximilian Heyne #endif /* CONFIG_PCI_MSI_ARCH_FALLBACKS */
384335b4223SMaximilian Heyne
385335b4223SMaximilian Heyne /*
386335b4223SMaximilian Heyne * Xen uses non-default msi_domain_ops and hence needs a way to populate sysfs
387335b4223SMaximilian Heyne * entries of MSI IRQs.
388335b4223SMaximilian Heyne */
389335b4223SMaximilian Heyne #if defined(CONFIG_PCI_XEN) || defined(CONFIG_PCI_MSI_ARCH_FALLBACKS)
390bf5e758fSThomas Gleixner #ifdef CONFIG_SYSFS
391bf5e758fSThomas Gleixner int msi_device_populate_sysfs(struct device *dev);
392bf5e758fSThomas Gleixner void msi_device_destroy_sysfs(struct device *dev);
393bf5e758fSThomas Gleixner #else /* CONFIG_SYSFS */
msi_device_populate_sysfs(struct device * dev)394bf5e758fSThomas Gleixner static inline int msi_device_populate_sysfs(struct device *dev) { return 0; }
msi_device_destroy_sysfs(struct device * dev)395bf5e758fSThomas Gleixner static inline void msi_device_destroy_sysfs(struct device *dev) { }
396bf5e758fSThomas Gleixner #endif /* !CONFIG_SYSFS */
397335b4223SMaximilian Heyne #endif /* CONFIG_PCI_XEN || CONFIG_PCI_MSI_ARCH_FALLBACKS */
398077ee78eSThomas Gleixner
399077ee78eSThomas Gleixner /*
400ae72f315SThomas Gleixner * The restore hook is still available even for fully irq domain based
401ae72f315SThomas Gleixner * setups. Courtesy to XEN/X86.
402077ee78eSThomas Gleixner */
403ae72f315SThomas Gleixner bool arch_restore_msi_irqs(struct pci_dev *dev);
4043b7d1921SEric W. Biederman
40513e7accbSThomas Gleixner #ifdef CONFIG_GENERIC_MSI_IRQ
406d9109698SJiang Liu
407aeeb5965SJiang Liu #include <linux/irqhandler.h>
408d9109698SJiang Liu
409f3cf8bb0SJiang Liu struct irq_domain;
410552c494aSMarc Zyngier struct irq_domain_ops;
411f3cf8bb0SJiang Liu struct irq_chip;
4129c78c1a8SThomas Gleixner struct irq_fwspec;
413f3cf8bb0SJiang Liu struct device_node;
414be5436c8SMarc Zyngier struct fwnode_handle;
415f3cf8bb0SJiang Liu struct msi_domain_info;
416f3cf8bb0SJiang Liu
417f3cf8bb0SJiang Liu /**
418f3cf8bb0SJiang Liu * struct msi_domain_ops - MSI interrupt domain callbacks
419f3cf8bb0SJiang Liu * @get_hwirq: Retrieve the resulting hw irq number
420f3cf8bb0SJiang Liu * @msi_init: Domain specific init function for MSI interrupts
421f3cf8bb0SJiang Liu * @msi_free: Domain specific function to free a MSI interrupts
422d9109698SJiang Liu * @msi_prepare: Prepare the allocation of the interrupts in the domain
4238f986fd7SThomas Gleixner * @prepare_desc: Optional function to prepare the allocated MSI descriptor
4248f986fd7SThomas Gleixner * in the domain
425d9109698SJiang Liu * @set_desc: Set the msi descriptor for an interrupt
42643e9e705SThomas Gleixner * @domain_alloc_irqs: Optional function to override the default allocation
42743e9e705SThomas Gleixner * function.
42843e9e705SThomas Gleixner * @domain_free_irqs: Optional function to override the default free
42943e9e705SThomas Gleixner * function.
430f6d3486aSThomas Gleixner * @msi_post_free: Optional function which is invoked after freeing
431f6d3486aSThomas Gleixner * all interrupts.
4329c78c1a8SThomas Gleixner * @msi_translate: Optional translate callback to support the odd wire to
4339c78c1a8SThomas Gleixner * MSI bridges, e.g. MBIGEN
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);
4719c78c1a8SThomas Gleixner int (*msi_translate)(struct irq_domain *domain, struct irq_fwspec *fwspec,
4729c78c1a8SThomas Gleixner irq_hw_number_t *hwirq, unsigned int *type);
473f3cf8bb0SJiang Liu };
474f3cf8bb0SJiang Liu
475f3cf8bb0SJiang Liu /**
476f3cf8bb0SJiang Liu * struct msi_domain_info - MSI interrupt domain data
477aeeb5965SJiang Liu * @flags: Flags to decribe features and capabilities
47822db089aSAhmed S. Darwish * @bus_token: The domain bus token
47961bf992fSThomas Gleixner * @hwsize: The hardware table size or the software index limit.
48061bf992fSThomas Gleixner * If 0 then the size is considered unlimited and
48161bf992fSThomas Gleixner * gets initialized to the maximum software index limit
48261bf992fSThomas Gleixner * by the domain creation code.
483f3cf8bb0SJiang Liu * @ops: The callback data structure
484aeeb5965SJiang Liu * @chip: Optional: associated interrupt chip
485aeeb5965SJiang Liu * @chip_data: Optional: associated interrupt chip data
486aeeb5965SJiang Liu * @handler: Optional: associated interrupt flow handler
487aeeb5965SJiang Liu * @handler_data: Optional: associated interrupt flow handler data
488aeeb5965SJiang Liu * @handler_name: Optional: associated interrupt flow handler name
489aeeb5965SJiang Liu * @data: Optional: domain specific data
490f3cf8bb0SJiang Liu */
491f3cf8bb0SJiang Liu struct msi_domain_info {
492aeeb5965SJiang Liu u32 flags;
49322db089aSAhmed S. Darwish enum irq_domain_bus_token bus_token;
49461bf992fSThomas Gleixner unsigned int hwsize;
495f3cf8bb0SJiang Liu struct msi_domain_ops *ops;
496f3cf8bb0SJiang Liu struct irq_chip *chip;
497aeeb5965SJiang Liu void *chip_data;
498aeeb5965SJiang Liu irq_flow_handler_t handler;
499aeeb5965SJiang Liu void *handler_data;
500aeeb5965SJiang Liu const char *handler_name;
501f3cf8bb0SJiang Liu void *data;
502f3cf8bb0SJiang Liu };
503f3cf8bb0SJiang Liu
504ebca4396SThomas Gleixner /**
505ebca4396SThomas Gleixner * struct msi_domain_template - Template for MSI device domains
506ebca4396SThomas Gleixner * @name: Storage for the resulting name. Filled in by the core.
507ebca4396SThomas Gleixner * @chip: Interrupt chip for this domain
508ebca4396SThomas Gleixner * @ops: MSI domain ops
509ebca4396SThomas Gleixner * @info: MSI domain info data
510ebca4396SThomas Gleixner */
511ebca4396SThomas Gleixner struct msi_domain_template {
512ebca4396SThomas Gleixner char name[48];
513ebca4396SThomas Gleixner struct irq_chip chip;
514ebca4396SThomas Gleixner struct msi_domain_ops ops;
515ebca4396SThomas Gleixner struct msi_domain_info info;
516ebca4396SThomas Gleixner };
517ebca4396SThomas Gleixner
5182d958b02SThomas Gleixner /*
5192d958b02SThomas Gleixner * Flags for msi_domain_info
5202d958b02SThomas Gleixner *
5212d958b02SThomas Gleixner * Bit 0-15: Generic MSI functionality which is not subject to restriction
5222d958b02SThomas Gleixner * by parent domains
5232d958b02SThomas Gleixner *
5242d958b02SThomas Gleixner * Bit 16-31: Functionality which depends on the underlying parent domain and
5252d958b02SThomas Gleixner * can be masked out by msi_parent_ops::init_dev_msi_info() when
5262d958b02SThomas Gleixner * a device MSI domain is initialized.
5272d958b02SThomas Gleixner */
528aeeb5965SJiang Liu enum {
529aeeb5965SJiang Liu /*
530aeeb5965SJiang Liu * Init non implemented ops callbacks with default MSI domain
531aeeb5965SJiang Liu * callbacks.
532aeeb5965SJiang Liu */
533aeeb5965SJiang Liu MSI_FLAG_USE_DEF_DOM_OPS = (1 << 0),
534aeeb5965SJiang Liu /*
535aeeb5965SJiang Liu * Init non implemented chip callbacks with default MSI chip
536aeeb5965SJiang Liu * callbacks.
537aeeb5965SJiang Liu */
538aeeb5965SJiang Liu MSI_FLAG_USE_DEF_CHIP_OPS = (1 << 1),
539f3b0946dSMarc Zyngier /* Needs early activate, required for PCI */
5402d958b02SThomas Gleixner MSI_FLAG_ACTIVATE_EARLY = (1 << 2),
54122d0b12fSThomas Gleixner /*
54222d0b12fSThomas Gleixner * Must reactivate when irq is started even when
54322d0b12fSThomas Gleixner * MSI_FLAG_ACTIVATE_EARLY has been set.
54422d0b12fSThomas Gleixner */
5452d958b02SThomas Gleixner MSI_FLAG_MUST_REACTIVATE = (1 << 3),
546013bd8e5SThomas Gleixner /* Populate sysfs on alloc() and destroy it on free() */
5472d958b02SThomas Gleixner MSI_FLAG_DEV_SYSFS = (1 << 4),
548645474e2SThomas Gleixner /* Allocate simple MSI descriptors */
5492d958b02SThomas Gleixner MSI_FLAG_ALLOC_SIMPLE_MSI_DESCS = (1 << 5),
550645474e2SThomas Gleixner /* Free MSI descriptors */
5512d958b02SThomas Gleixner MSI_FLAG_FREE_MSI_DESCS = (1 << 6),
5529d1c58c8SThomas Gleixner /* Use dev->fwnode for MSI device domain creation */
5539d1c58c8SThomas Gleixner MSI_FLAG_USE_DEV_FWNODE = (1 << 7),
5549bbe13a5SThomas Gleixner /* Set parent->dev into domain->pm_dev on device domain creation */
5559bbe13a5SThomas Gleixner MSI_FLAG_PARENT_PM_DEV = (1 << 8),
5567d189c77SShivamurthy Shastri /* Support for parent mask/unmask */
5577d189c77SShivamurthy Shastri MSI_FLAG_PCI_MSI_MASK_PARENT = (1 << 9),
5582d958b02SThomas Gleixner
5592d958b02SThomas Gleixner /* Mask for the generic functionality */
5602d958b02SThomas Gleixner MSI_GENERIC_FLAGS_MASK = GENMASK(15, 0),
5612d958b02SThomas Gleixner
5622d958b02SThomas Gleixner /* Mask for the domain specific functionality */
5632d958b02SThomas Gleixner MSI_DOMAIN_FLAGS_MASK = GENMASK(31, 16),
5642d958b02SThomas Gleixner
5652d958b02SThomas Gleixner /* Support multiple PCI MSI interrupts */
5662d958b02SThomas Gleixner MSI_FLAG_MULTI_PCI_MSI = (1 << 16),
5672d958b02SThomas Gleixner /* Support PCI MSIX interrupts */
5682d958b02SThomas Gleixner MSI_FLAG_PCI_MSIX = (1 << 17),
5692d958b02SThomas Gleixner /* Is level-triggered capable, using two messages */
5702d958b02SThomas Gleixner MSI_FLAG_LEVEL_CAPABLE = (1 << 18),
5712d958b02SThomas Gleixner /* MSI-X entries must be contiguous */
5722d958b02SThomas Gleixner MSI_FLAG_MSIX_CONTIGUOUS = (1 << 19),
573b834e3c0SThomas Gleixner /* PCI/MSI-X vectors can be dynamically allocated/freed post MSI-X enable */
574b834e3c0SThomas Gleixner MSI_FLAG_PCI_MSIX_ALLOC_DYN = (1 << 20),
5755297bba5SMarek Vasut /* PCI MSIs cannot be steered separately to CPU cores */
5765297bba5SMarek Vasut MSI_FLAG_NO_AFFINITY = (1 << 21),
577c3164d2eSRoger Pau Monne /* Inhibit usage of entry masking */
578c3164d2eSRoger Pau Monne MSI_FLAG_NO_MASK = (1 << 22),
579aeeb5965SJiang Liu };
580aeeb5965SJiang Liu
5811c000dcaSThomas Gleixner /*
5821c000dcaSThomas Gleixner * Flags for msi_parent_ops::chip_flags
5831c000dcaSThomas Gleixner */
5841c000dcaSThomas Gleixner enum {
5851c000dcaSThomas Gleixner MSI_CHIP_FLAG_SET_EOI = (1 << 0),
5861c000dcaSThomas Gleixner MSI_CHIP_FLAG_SET_ACK = (1 << 1),
5871c000dcaSThomas Gleixner };
5881c000dcaSThomas Gleixner
589b78780d9SThomas Gleixner /**
590b78780d9SThomas Gleixner * struct msi_parent_ops - MSI parent domain callbacks and configuration info
591b78780d9SThomas Gleixner *
592b78780d9SThomas Gleixner * @supported_flags: Required: The supported MSI flags of the parent domain
593ac81e94aSThomas Gleixner * @required_flags: Optional: The required MSI flags of the parent MSI domain
5941c000dcaSThomas Gleixner * @chip_flags: Optional: Select MSI chip callbacks to update with defaults
5951c000dcaSThomas Gleixner * in msi_lib_init_dev_msi_info().
596ac81e94aSThomas Gleixner * @bus_select_token: Optional: The bus token of the real parent domain for
597ac81e94aSThomas Gleixner * irq_domain::select()
598ac81e94aSThomas Gleixner * @bus_select_mask: Optional: A mask of supported BUS_DOMAINs for
599ac81e94aSThomas Gleixner * irq_domain::select()
600b78780d9SThomas Gleixner * @prefix: Optional: Prefix for the domain and chip name
601b78780d9SThomas Gleixner * @init_dev_msi_info: Required: Callback for MSI parent domains to setup parent
602b78780d9SThomas Gleixner * domain specific domain flags, domain ops and interrupt chip
603b78780d9SThomas Gleixner * callbacks when a per device domain is created.
604b78780d9SThomas Gleixner */
605b78780d9SThomas Gleixner struct msi_parent_ops {
606b78780d9SThomas Gleixner u32 supported_flags;
607ac81e94aSThomas Gleixner u32 required_flags;
6081c000dcaSThomas Gleixner u32 chip_flags;
609ac81e94aSThomas Gleixner u32 bus_select_token;
610ac81e94aSThomas Gleixner u32 bus_select_mask;
611b78780d9SThomas Gleixner const char *prefix;
612b78780d9SThomas Gleixner bool (*init_dev_msi_info)(struct device *dev, struct irq_domain *domain,
613b78780d9SThomas Gleixner struct irq_domain *msi_parent_domain,
614b78780d9SThomas Gleixner struct msi_domain_info *msi_child_info);
615b78780d9SThomas Gleixner };
616b78780d9SThomas Gleixner
617b78780d9SThomas Gleixner bool msi_parent_init_dev_msi_info(struct device *dev, struct irq_domain *domain,
618b78780d9SThomas Gleixner struct irq_domain *msi_parent_domain,
619b78780d9SThomas Gleixner struct msi_domain_info *msi_child_info);
620b78780d9SThomas Gleixner
621f3cf8bb0SJiang Liu int msi_domain_set_affinity(struct irq_data *data, const struct cpumask *mask,
622f3cf8bb0SJiang Liu bool force);
623f3cf8bb0SJiang Liu
624be5436c8SMarc Zyngier struct irq_domain *msi_create_irq_domain(struct fwnode_handle *fwnode,
625f3cf8bb0SJiang Liu struct msi_domain_info *info,
626f3cf8bb0SJiang Liu struct irq_domain *parent);
6274cd5f440SThomas Gleixner
62827a6dea3SThomas Gleixner bool msi_create_device_irq_domain(struct device *dev, unsigned int domid,
62927a6dea3SThomas Gleixner const struct msi_domain_template *template,
63027a6dea3SThomas Gleixner unsigned int hwsize, void *domain_data,
63127a6dea3SThomas Gleixner void *chip_data);
63227a6dea3SThomas Gleixner void msi_remove_device_irq_domain(struct device *dev, unsigned int domid);
63327a6dea3SThomas Gleixner
63426e91b75SThomas Gleixner bool msi_match_device_irq_domain(struct device *dev, unsigned int domid,
63526e91b75SThomas Gleixner enum irq_domain_bus_token bus_token);
63626e91b75SThomas Gleixner
637*112e43e9SLinus Torvalds int msi_domain_alloc_irqs_range_locked(struct device *dev, unsigned int domid,
638*112e43e9SLinus Torvalds unsigned int first, unsigned int last);
639f2480e7dSThomas Gleixner int msi_domain_alloc_irqs_range(struct device *dev, unsigned int domid,
640f2480e7dSThomas Gleixner unsigned int first, unsigned int last);
641f2480e7dSThomas Gleixner int msi_domain_alloc_irqs_all_locked(struct device *dev, unsigned int domid, int nirqs);
642f2480e7dSThomas Gleixner
6433d393b21SThomas Gleixner struct msi_map msi_domain_alloc_irq_at(struct device *dev, unsigned int domid, unsigned int index,
6443d393b21SThomas Gleixner const struct irq_affinity_desc *affdesc,
6453d393b21SThomas Gleixner union msi_instance_cookie *cookie);
646f2480e7dSThomas Gleixner
647*112e43e9SLinus Torvalds void msi_domain_free_irqs_range_locked(struct device *dev, unsigned int domid,
648*112e43e9SLinus Torvalds unsigned int first, unsigned int last);
6494cd5f440SThomas Gleixner void msi_domain_free_irqs_range(struct device *dev, unsigned int domid,
6504cd5f440SThomas Gleixner unsigned int first, unsigned int last);
6514cd5f440SThomas Gleixner void msi_domain_free_irqs_all_locked(struct device *dev, unsigned int domid);
6524cd5f440SThomas Gleixner void msi_domain_free_irqs_all(struct device *dev, unsigned int domid);
6534cd5f440SThomas Gleixner
654f3cf8bb0SJiang Liu struct msi_domain_info *msi_get_domain_info(struct irq_domain *domain);
655f3cf8bb0SJiang Liu
656c88f9110SThomas Gleixner /* Per device platform MSI */
657c88f9110SThomas Gleixner int platform_device_msi_init_and_alloc_irqs(struct device *dev, unsigned int nvec,
658c88f9110SThomas Gleixner irq_write_msi_msg_t write_msi_msg);
659c88f9110SThomas Gleixner void platform_device_msi_free_irqs_all(struct device *dev);
66017cde5e6SJason Gunthorpe
66117cde5e6SJason Gunthorpe bool msi_device_has_isolated_msi(struct device *dev);
66206fe8fd6SNipun Gupta
msi_domain_alloc_irqs(struct device * dev,unsigned int domid,int nirqs)66306fe8fd6SNipun Gupta static inline int msi_domain_alloc_irqs(struct device *dev, unsigned int domid, int nirqs)
66406fe8fd6SNipun Gupta {
66506fe8fd6SNipun Gupta return msi_domain_alloc_irqs_range(dev, domid, 0, nirqs - 1);
66606fe8fd6SNipun Gupta }
66706fe8fd6SNipun Gupta
66817cde5e6SJason Gunthorpe #else /* CONFIG_GENERIC_MSI_IRQ */
msi_device_has_isolated_msi(struct device * dev)66917cde5e6SJason Gunthorpe static inline bool msi_device_has_isolated_msi(struct device *dev)
67017cde5e6SJason Gunthorpe {
67117cde5e6SJason Gunthorpe /*
67217cde5e6SJason Gunthorpe * Arguably if the platform does not enable MSI support then it has
67317cde5e6SJason Gunthorpe * "isolated MSI", as an interrupt controller that cannot receive MSIs
674bf210f79SJason Gunthorpe * is inherently isolated by our definition. The default definition for
675bf210f79SJason Gunthorpe * arch_is_isolated_msi() is conservative and returns false anyhow.
67617cde5e6SJason Gunthorpe */
677bf210f79SJason Gunthorpe return arch_is_isolated_msi();
67817cde5e6SJason Gunthorpe }
67913e7accbSThomas Gleixner #endif /* CONFIG_GENERIC_MSI_IRQ */
680f3cf8bb0SJiang Liu
681a474d3fbSThomas Gleixner /* PCI specific interfaces */
682a474d3fbSThomas Gleixner #ifdef CONFIG_PCI_MSI
683a474d3fbSThomas Gleixner struct pci_dev *msi_desc_to_pci_dev(struct msi_desc *desc);
684a474d3fbSThomas Gleixner void pci_write_msi_msg(unsigned int irq, struct msi_msg *msg);
685a474d3fbSThomas Gleixner void __pci_read_msi_msg(struct msi_desc *entry, struct msi_msg *msg);
686a474d3fbSThomas Gleixner void __pci_write_msi_msg(struct msi_desc *entry, struct msi_msg *msg);
687a474d3fbSThomas Gleixner void pci_msi_mask_irq(struct irq_data *data);
688a474d3fbSThomas Gleixner void pci_msi_unmask_irq(struct irq_data *data);
689be5436c8SMarc Zyngier struct irq_domain *pci_msi_create_irq_domain(struct fwnode_handle *fwnode,
6903878eaefSJiang Liu struct msi_domain_info *info,
6913878eaefSJiang Liu struct irq_domain *parent);
692b6eec9b7SDavid Daney u32 pci_msi_domain_get_msi_rid(struct irq_domain *domain, struct pci_dev *pdev);
69354fa97eeSMarc Zyngier struct irq_domain *pci_msi_get_device_domain(struct pci_dev *pdev);
694a474d3fbSThomas Gleixner #else /* CONFIG_PCI_MSI */
pci_msi_get_device_domain(struct pci_dev * pdev)69554fa97eeSMarc Zyngier static inline struct irq_domain *pci_msi_get_device_domain(struct pci_dev *pdev)
69654fa97eeSMarc Zyngier {
69754fa97eeSMarc Zyngier return NULL;
69854fa97eeSMarc Zyngier }
pci_write_msi_msg(unsigned int irq,struct msi_msg * msg)699a474d3fbSThomas Gleixner static inline void pci_write_msi_msg(unsigned int irq, struct msi_msg *msg) { }
700a474d3fbSThomas Gleixner #endif /* !CONFIG_PCI_MSI */
7013878eaefSJiang Liu
7023b7d1921SEric W. Biederman #endif /* LINUX_MSI_H */
703