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()
153 struct msi_domain_info *info = data->domain->host_data; in cond_mask_parent()
155 if (unlikely(info->flags & MSI_FLAG_PCI_MSI_MASK_PARENT)) in cond_mask_parent()
161 struct msi_domain_info *info = data->domain->host_data; in cond_unmask_parent()
163 if (unlikely(info->flags & MSI_FLAG_PCI_MSI_MASK_PARENT)) in cond_unmask_parent()
171 pci_msi_mask(desc, BIT(data->irq - desc->irq)); in pci_irq_mask_msi()
180 pci_msi_unmask(desc, BIT(data->irq - desc->irq)); in pci_irq_unmask_msi()
196 .name = "PCI-MSI",
228 /* Don't fiddle with preallocated MSI descriptors */ in pci_msix_prepare_desc()
229 if (!desc->pci.mask_base) in pci_msix_prepare_desc()
230 msix_prepare_msi_desc(to_pci_dev(desc->dev), desc); in pci_msix_prepare_desc()
235 .name = "PCI-MSIX",
256 return msi_match_device_irq_domain(&pdev->dev, MSI_DEFAULT_DOMAIN, bus_token); in pci_match_device_domain()
262 struct irq_domain *domain = dev_get_msi_domain(&pdev->dev); in pci_create_device_domain()
267 return msi_create_device_irq_domain(&pdev->dev, MSI_DEFAULT_DOMAIN, tmpl, in pci_create_device_domain()
272 * pci_setup_msi_device_domain - Setup a device MSI interrupt domain
277 * - The device does not have a MSI parent irq domain associated,
279 * PCI/MSI domain models working
280 * - The MSI domain exists already
281 * - The MSI domain was successfully allocated
283 * - MSI-X is enabled
284 * - The domain creation fails.
286 * The created MSI domain is preserved until:
287 * - The device is removed
288 * - MSI is disabled and a MSI-X domain is created
292 if (WARN_ON_ONCE(pdev->msix_enabled)) in pci_setup_msi_device_domain()
298 msi_remove_device_irq_domain(&pdev->dev, MSI_DEFAULT_DOMAIN); in pci_setup_msi_device_domain()
304 * pci_setup_msix_device_domain - Setup a device MSI-X interrupt domain
306 * @hwsize: The size of the MSI-X vector table
310 * - The device does not have a MSI parent irq domain associated,
312 * PCI/MSI domain models working
313 * - The MSI-X domain exists already
314 * - The MSI-X domain was successfully allocated
316 * - MSI is enabled
317 * - The domain creation fails.
319 * The created MSI-X domain is preserved until:
320 * - The device is removed
321 * - MSI-X is disabled and a MSI domain is created
325 if (WARN_ON_ONCE(pdev->msi_enabled)) in pci_setup_msix_device_domain()
331 msi_remove_device_irq_domain(&pdev->dev, MSI_DEFAULT_DOMAIN); in pci_setup_msix_device_domain()
337 * pci_msi_domain_supports - Check for support of a particular feature flag
351 domain = dev_get_msi_domain(&pdev->dev); in pci_msi_domain_supports()
358 * For "global" PCI/MSI interrupt domains the associated in pci_msi_domain_supports()
362 info = domain->host_data; in pci_msi_domain_supports()
363 supported = info->flags; in pci_msi_domain_supports()
366 * For MSI parent domains the supported feature set in pci_msi_domain_supports()
370 * expanding the PCI/MSI functionality. in pci_msi_domain_supports()
372 supported = domain->msi_parent_ops->supported_flags; in pci_msi_domain_supports()
379 * Users of the generic MSI infrastructure expect a device to have a single ID,
380 * so with DMA aliases we have to pick the least-worst compromise. Devices with
386 * case is that of PCI->PCIe so we should always use the alias RID. This echoes
388 * well enough in practice; in the face of the horrible PCIe<->PCI-X conditions
396 if (pdev->bus->number != bus || PCI_BUS_NUM(alias) != bus) in get_msi_id_cb()
403 * pci_msi_domain_get_msi_rid - Get the MSI requester id (RID)
420 rid = of_node ? of_msi_map_id(&pdev->dev, of_node, rid) : in pci_msi_domain_get_msi_rid()
421 iort_msi_map_id(&pdev->dev, rid); in pci_msi_domain_get_msi_rid()
427 * pci_msi_get_device_domain - Get the MSI domain for a given PCI device
430 * Use the firmware data to find a device-specific MSI domain
433 * Returns: The corresponding MSI domain or NULL if none has been found.
441 dom = of_msi_map_get_device_domain(&pdev->dev, rid, DOMAIN_BUS_PCI_MSI); in pci_msi_get_device_domain()
443 dom = iort_get_device_domain(&pdev->dev, rid, in pci_msi_get_device_domain()