Lines Matching +full:msi +full:- +full:x
1 // SPDX-License-Identifier: GPL-2.0
3 * PCI Message Signaled Interrupt (MSI) - irqdomain support
9 #include "msi.h"
15 domain = dev_get_msi_domain(&dev->dev); in pci_msi_setup_msi_irqs()
17 return msi_domain_alloc_irqs_all_locked(&dev->dev, MSI_DEFAULT_DOMAIN, nvec); in pci_msi_setup_msi_irqs()
26 domain = dev_get_msi_domain(&dev->dev); in pci_msi_teardown_msi_irqs()
28 msi_domain_free_irqs_all_locked(&dev->dev, MSI_DEFAULT_DOMAIN); in pci_msi_teardown_msi_irqs()
31 msi_free_msi_descs(&dev->dev); in pci_msi_teardown_msi_irqs()
36 * pci_msi_domain_write_msg - Helper to write MSI message to PCI config space
37 * @irq_data: Pointer to interrupt data of the MSI interrupt
45 * For MSI-X desc->irq is always equal to irq_data->irq. For in pci_msi_domain_write_msg()
46 * MSI only the first interrupt of MULTI MSI passes the test. in pci_msi_domain_write_msg()
48 if (desc->irq == irq_data->irq) in pci_msi_domain_write_msg()
53 * pci_msi_domain_calc_hwirq - Generate a unique ID for an MSI source
54 * @desc: Pointer to the MSI descriptor
62 return (irq_hw_number_t)desc->msi_index | in pci_msi_domain_calc_hwirq()
64 ((irq_hw_number_t)(pci_domain_nr(dev->bus) & 0xFFFFFFFF)) << 27; in pci_msi_domain_calc_hwirq()
70 arg->desc = desc; in pci_msi_domain_set_desc()
71 arg->hwirq = pci_msi_domain_calc_hwirq(desc); in pci_msi_domain_set_desc()
80 struct msi_domain_ops *ops = info->ops; in pci_msi_domain_update_dom_ops()
83 info->ops = &pci_msi_domain_ops_default; in pci_msi_domain_update_dom_ops()
85 if (ops->set_desc == NULL) in pci_msi_domain_update_dom_ops()
86 ops->set_desc = pci_msi_domain_set_desc; in pci_msi_domain_update_dom_ops()
92 struct irq_chip *chip = info->chip; in pci_msi_domain_update_chip_ops()
95 if (!chip->irq_write_msi_msg) in pci_msi_domain_update_chip_ops()
96 chip->irq_write_msi_msg = pci_msi_domain_write_msg; in pci_msi_domain_update_chip_ops()
97 if (!chip->irq_mask) in pci_msi_domain_update_chip_ops()
98 chip->irq_mask = pci_msi_mask_irq; in pci_msi_domain_update_chip_ops()
99 if (!chip->irq_unmask) in pci_msi_domain_update_chip_ops()
100 chip->irq_unmask = pci_msi_unmask_irq; in pci_msi_domain_update_chip_ops()
104 * pci_msi_create_irq_domain - Create a MSI interrupt domain
106 * @info: MSI domain info
109 * Updates the domain and chip ops and creates a MSI interrupt domain.
118 if (WARN_ON(info->flags & MSI_FLAG_LEVEL_CAPABLE)) in pci_msi_create_irq_domain()
119 info->flags &= ~MSI_FLAG_LEVEL_CAPABLE; in pci_msi_create_irq_domain()
121 if (info->flags & MSI_FLAG_USE_DEF_DOM_OPS) in pci_msi_create_irq_domain()
123 if (info->flags & MSI_FLAG_USE_DEF_CHIP_OPS) in pci_msi_create_irq_domain()
126 /* Let the core code free MSI descriptors when freeing interrupts */ in pci_msi_create_irq_domain()
127 info->flags |= MSI_FLAG_FREE_MSI_DESCS; in pci_msi_create_irq_domain()
129 info->flags |= MSI_FLAG_ACTIVATE_EARLY | MSI_FLAG_DEV_SYSFS; in pci_msi_create_irq_domain()
131 info->flags |= MSI_FLAG_MUST_REACTIVATE; in pci_msi_create_irq_domain()
133 /* PCI-MSI is oneshot-safe */ in pci_msi_create_irq_domain()
134 info->chip->flags |= IRQCHIP_ONESHOT_SAFE; in pci_msi_create_irq_domain()
136 info->bus_token = DOMAIN_BUS_PCI_MSI; in pci_msi_create_irq_domain()
143 * Per device MSI[-X] domain functionality
147 arg->desc = desc; in pci_device_domain_set_desc()
148 arg->hwirq = desc->msi_index; in pci_device_domain_set_desc()
155 pci_msi_mask(desc, BIT(data->irq - desc->irq)); in pci_irq_mask_msi()
162 pci_msi_unmask(desc, BIT(data->irq - desc->irq)); in pci_irq_unmask_msi()
178 .name = "PCI-MSI",
208 /* Don't fiddle with preallocated MSI descriptors */ in pci_msix_prepare_desc()
209 if (!desc->pci.mask_base) in pci_msix_prepare_desc()
210 msix_prepare_msi_desc(to_pci_dev(desc->dev), desc); in pci_msix_prepare_desc()
215 .name = "PCI-MSIX",
236 return msi_match_device_irq_domain(&pdev->dev, MSI_DEFAULT_DOMAIN, bus_token); in pci_match_device_domain()
242 struct irq_domain *domain = dev_get_msi_domain(&pdev->dev); in pci_create_device_domain()
247 return msi_create_device_irq_domain(&pdev->dev, MSI_DEFAULT_DOMAIN, tmpl, in pci_create_device_domain()
252 * pci_setup_msi_device_domain - Setup a device MSI interrupt domain
257 * - The device does not have a MSI parent irq domain associated,
259 * PCI/MSI domain models working
260 * - The MSI domain exists already
261 * - The MSI domain was successfully allocated
263 * - MSI-X is enabled
264 * - The domain creation fails.
266 * The created MSI domain is preserved until:
267 * - The device is removed
268 * - MSI is disabled and a MSI-X domain is created
272 if (WARN_ON_ONCE(pdev->msix_enabled)) in pci_setup_msi_device_domain()
278 msi_remove_device_irq_domain(&pdev->dev, MSI_DEFAULT_DOMAIN); in pci_setup_msi_device_domain()
284 * pci_setup_msix_device_domain - Setup a device MSI-X interrupt domain
286 * @hwsize: The size of the MSI-X vector table
290 * - The device does not have a MSI parent irq domain associated,
292 * PCI/MSI domain models working
293 * - The MSI-X domain exists already
294 * - The MSI-X domain was successfully allocated
296 * - MSI is enabled
297 * - The domain creation fails.
299 * The created MSI-X domain is preserved until:
300 * - The device is removed
301 * - MSI-X is disabled and a MSI domain is created
305 if (WARN_ON_ONCE(pdev->msi_enabled)) in pci_setup_msix_device_domain()
311 msi_remove_device_irq_domain(&pdev->dev, MSI_DEFAULT_DOMAIN); in pci_setup_msix_device_domain()
317 * pci_msi_domain_supports - Check for support of a particular feature flag
331 domain = dev_get_msi_domain(&pdev->dev); in pci_msi_domain_supports()
341 * For "global" PCI/MSI interrupt domains the associated in pci_msi_domain_supports()
345 info = domain->host_data; in pci_msi_domain_supports()
346 supported = info->flags; in pci_msi_domain_supports()
349 * For MSI parent domains the supported feature set in pci_msi_domain_supports()
353 * expanding the PCI/MSI functionality. in pci_msi_domain_supports()
355 supported = domain->msi_parent_ops->supported_flags; in pci_msi_domain_supports()
362 * pci_create_ims_domain - Create a secondary IMS domain for a PCI device
364 * @template: The MSI info template which describes the domain
373 * - The index space is managed by the core code
375 * - There is no requirement for consecutive index ranges
377 * - The interrupt chip must provide the following callbacks:
378 * - irq_mask()
379 * - irq_unmask()
380 * - irq_write_msi_msg()
382 * - The interrupt chip must provide the following optional callbacks
386 * - irq_bus_lock()
387 * - irq_bus_unlock()
394 * - Interrupt affinity setting is handled by the underlying parent
403 struct irq_domain *domain = dev_get_msi_domain(&pdev->dev); in pci_create_ims_domain()
408 if (template->info.bus_token != DOMAIN_BUS_PCI_DEVICE_IMS || in pci_create_ims_domain()
409 !(template->info.flags & MSI_FLAG_ALLOC_SIMPLE_MSI_DESCS) || in pci_create_ims_domain()
410 !(template->info.flags & MSI_FLAG_FREE_MSI_DESCS) || in pci_create_ims_domain()
411 !template->chip.irq_mask || !template->chip.irq_unmask || in pci_create_ims_domain()
412 !template->chip.irq_write_msi_msg || template->chip.irq_set_affinity) in pci_create_ims_domain()
415 return msi_create_device_irq_domain(&pdev->dev, MSI_SECONDARY_DOMAIN, template, in pci_create_ims_domain()
421 * Users of the generic MSI infrastructure expect a device to have a single ID,
422 * so with DMA aliases we have to pick the least-worst compromise. Devices with
428 * case is that of PCI->PCIe so we should always use the alias RID. This echoes
430 * well enough in practice; in the face of the horrible PCIe<->PCI-X conditions
438 if (pdev->bus->number != bus || PCI_BUS_NUM(alias) != bus) in get_msi_id_cb()
445 * pci_msi_domain_get_msi_rid - Get the MSI requester id (RID)
462 rid = of_node ? of_msi_map_id(&pdev->dev, of_node, rid) : in pci_msi_domain_get_msi_rid()
463 iort_msi_map_id(&pdev->dev, rid); in pci_msi_domain_get_msi_rid()
469 * pci_msi_get_device_domain - Get the MSI domain for a given PCI device
472 * Use the firmware data to find a device-specific MSI domain
475 * Returns: The corresponding MSI domain or NULL if none has been found.
483 dom = of_msi_map_get_device_domain(&pdev->dev, rid, DOMAIN_BUS_PCI_MSI); in pci_msi_get_device_domain()
485 dom = iort_get_device_domain(&pdev->dev, rid, in pci_msi_get_device_domain()