Lines Matching +full:interrupt +full:- +full:affinity

1 // SPDX-License-Identifier: GPL-2.0
22 * alloc_msi_entry - Allocate an initialized msi_desc
25 * @affinity: Optional pointer to an affinity mask array size of @nvec
27 * If @affinity is not %NULL then an affinity array[@nvec] is allocated
28 * and the affinity masks and flags from @affinity are copied.
33 const struct irq_affinity_desc *affinity) in alloc_msi_entry() argument
41 INIT_LIST_HEAD(&desc->list); in alloc_msi_entry()
42 desc->dev = dev; in alloc_msi_entry()
43 desc->nvec_used = nvec; in alloc_msi_entry()
44 if (affinity) { in alloc_msi_entry()
45 desc->affinity = kmemdup(affinity, in alloc_msi_entry()
46 nvec * sizeof(*desc->affinity), GFP_KERNEL); in alloc_msi_entry()
47 if (!desc->affinity) { in alloc_msi_entry()
58 kfree(entry->affinity); in free_msi_entry()
64 *msg = entry->msg; in __get_cached_msi_msg()
83 retval = kstrtoul(attr->attr.name, 10, &irq); in msi_mode_show()
89 return -ENODEV; in msi_mode_show()
92 is_msix = entry->msi_attrib.is_msix; in msi_mode_show()
98 * msi_populate_sysfs - Populate msi_irqs sysfs entries for devices
112 int ret = -ENOMEM; in msi_populate_sysfs()
119 num_msi += entry->nvec_used; in msi_populate_sysfs()
126 return ERR_PTR(-ENOMEM); in msi_populate_sysfs()
129 for (i = 0; i < entry->nvec_used; i++) { in msi_populate_sysfs()
133 msi_attrs[count] = &msi_dev_attr->attr; in msi_populate_sysfs()
135 sysfs_attr_init(&msi_dev_attr->attr); in msi_populate_sysfs()
136 msi_dev_attr->attr.name = kasprintf(GFP_KERNEL, "%d", in msi_populate_sysfs()
137 entry->irq + i); in msi_populate_sysfs()
138 if (!msi_dev_attr->attr.name) in msi_populate_sysfs()
140 msi_dev_attr->attr.mode = 0444; in msi_populate_sysfs()
141 msi_dev_attr->show = msi_mode_show; in msi_populate_sysfs()
149 msi_irq_group->name = "msi_irqs"; in msi_populate_sysfs()
150 msi_irq_group->attrs = msi_attrs; in msi_populate_sysfs()
157 ret = sysfs_create_groups(&dev->kobj, msi_irq_groups); in msi_populate_sysfs()
172 kfree(msi_attr->name); in msi_populate_sysfs()
182 * msi_destroy_sysfs - Destroy msi_irqs sysfs entries for devices
193 sysfs_remove_groups(&dev->kobj, msi_irq_groups); in msi_destroy_sysfs()
194 msi_attrs = msi_irq_groups[0]->attrs; in msi_destroy_sysfs()
198 kfree(dev_attr->attr.name); in msi_destroy_sysfs()
212 data->chip->irq_write_msi_msg(data, msg); in irq_chip_write_msi_msg()
217 struct msi_domain_info *info = domain->host_data; in msi_check_level()
221 * not advertized that it is level-capable, signal the breakage. in msi_check_level()
223 WARN_ON(!((info->flags & MSI_FLAG_LEVEL_CAPABLE) && in msi_check_level()
224 (info->chip->flags & IRQCHIP_SUPPORTS_LEVEL_MSI)) && in msi_check_level()
229 * msi_domain_set_affinity - Generic affinity setter function for MSI domains
230 * @irq_data: The irq data associated to the interrupt
231 * @mask: The affinity mask to set
234 * Intended to be used by MSI interrupt controllers which are
242 struct irq_data *parent = irq_data->parent_data; in msi_domain_set_affinity()
246 ret = parent->chip->irq_set_affinity(parent, mask, force); in msi_domain_set_affinity()
249 msi_check_level(irq_data->domain, msg); in msi_domain_set_affinity()
262 msi_check_level(irq_data->domain, msg); in msi_domain_activate()
279 struct msi_domain_info *info = domain->host_data; in msi_domain_alloc()
280 struct msi_domain_ops *ops = info->ops; in msi_domain_alloc()
281 irq_hw_number_t hwirq = ops->get_hwirq(info, arg); in msi_domain_alloc()
285 return -EEXIST; in msi_domain_alloc()
287 if (domain->parent) { in msi_domain_alloc()
294 ret = ops->msi_init(domain, info, virq + i, hwirq + i, arg); in msi_domain_alloc()
296 if (ops->msi_free) { in msi_domain_alloc()
297 for (i--; i > 0; i--) in msi_domain_alloc()
298 ops->msi_free(domain, info, virq + i); in msi_domain_alloc()
311 struct msi_domain_info *info = domain->host_data; in msi_domain_free()
314 if (info->ops->msi_free) { in msi_domain_free()
316 info->ops->msi_free(domain, info, virq + i); in msi_domain_free()
331 return arg->hwirq; in msi_domain_ops_get_hwirq()
344 arg->desc = desc; in msi_domain_ops_set_desc()
352 irq_domain_set_hwirq_and_chip(domain, virq, hwirq, info->chip, in msi_domain_ops_init()
353 info->chip_data); in msi_domain_ops_init()
354 if (info->handler && info->handler_name) { in msi_domain_ops_init()
355 __irq_set_handler(virq, info->handler, 0, info->handler_name); in msi_domain_ops_init()
356 if (info->handler_data) in msi_domain_ops_init()
357 irq_set_handler_data(virq, info->handler_data); in msi_domain_ops_init()
381 struct msi_domain_ops *ops = info->ops; in msi_domain_update_dom_ops()
384 info->ops = &msi_domain_ops_default; in msi_domain_update_dom_ops()
388 if (ops->domain_alloc_irqs == NULL) in msi_domain_update_dom_ops()
389 ops->domain_alloc_irqs = msi_domain_ops_default.domain_alloc_irqs; in msi_domain_update_dom_ops()
390 if (ops->domain_free_irqs == NULL) in msi_domain_update_dom_ops()
391 ops->domain_free_irqs = msi_domain_ops_default.domain_free_irqs; in msi_domain_update_dom_ops()
393 if (!(info->flags & MSI_FLAG_USE_DEF_DOM_OPS)) in msi_domain_update_dom_ops()
396 if (ops->get_hwirq == NULL) in msi_domain_update_dom_ops()
397 ops->get_hwirq = msi_domain_ops_default.get_hwirq; in msi_domain_update_dom_ops()
398 if (ops->msi_init == NULL) in msi_domain_update_dom_ops()
399 ops->msi_init = msi_domain_ops_default.msi_init; in msi_domain_update_dom_ops()
400 if (ops->msi_check == NULL) in msi_domain_update_dom_ops()
401 ops->msi_check = msi_domain_ops_default.msi_check; in msi_domain_update_dom_ops()
402 if (ops->msi_prepare == NULL) in msi_domain_update_dom_ops()
403 ops->msi_prepare = msi_domain_ops_default.msi_prepare; in msi_domain_update_dom_ops()
404 if (ops->set_desc == NULL) in msi_domain_update_dom_ops()
405 ops->set_desc = msi_domain_ops_default.set_desc; in msi_domain_update_dom_ops()
410 struct irq_chip *chip = info->chip; in msi_domain_update_chip_ops()
412 BUG_ON(!chip || !chip->irq_mask || !chip->irq_unmask); in msi_domain_update_chip_ops()
413 if (!chip->irq_set_affinity) in msi_domain_update_chip_ops()
414 chip->irq_set_affinity = msi_domain_set_affinity; in msi_domain_update_chip_ops()
418 * msi_create_irq_domain - Create an MSI interrupt domain
419 * @fwnode: Optional fwnode of the interrupt controller
432 if (info->flags & MSI_FLAG_USE_DEF_CHIP_OPS) in msi_create_irq_domain()
438 if (domain && !domain->name && info->chip) in msi_create_irq_domain()
439 domain->name = info->chip->name; in msi_create_irq_domain()
447 struct msi_domain_info *info = domain->host_data; in msi_domain_prepare_irqs()
448 struct msi_domain_ops *ops = info->ops; in msi_domain_prepare_irqs()
451 ret = ops->msi_check(domain, info, dev); in msi_domain_prepare_irqs()
453 ret = ops->msi_prepare(domain, dev, nvec, arg); in msi_domain_prepare_irqs()
461 struct msi_domain_info *info = domain->host_data; in msi_domain_populate_irqs()
462 struct msi_domain_ops *ops = info->ops; in msi_domain_populate_irqs()
467 /* Don't even try the multi-MSI brain damage. */ in msi_domain_populate_irqs()
468 if (WARN_ON(!desc->irq || desc->nvec_used != 1)) { in msi_domain_populate_irqs()
469 ret = -EINVAL; in msi_domain_populate_irqs()
473 if (!(desc->irq >= virq && desc->irq < (virq + nvec))) in msi_domain_populate_irqs()
476 ops->set_desc(arg, desc); in msi_domain_populate_irqs()
478 ret = irq_domain_alloc_irqs_hierarchy(domain, desc->irq, 1, in msi_domain_populate_irqs()
483 irq_set_msi_desc_off(desc->irq, 0, desc); in msi_domain_populate_irqs()
489 if (!(desc->irq >= virq && desc->irq < (virq + nvec))) in msi_domain_populate_irqs()
492 irq_domain_free_irqs_common(domain, desc->irq, 1); in msi_domain_populate_irqs()
505 * of the hardware could result in a spurious interrupt on the dummy vector
507 * logic will prevent the spurious interrupt and reservation mode can be
516 switch(domain->bus_token) { in msi_check_reservation_mode()
524 if (!(info->flags & MSI_FLAG_MUST_REACTIVATE)) in msi_check_reservation_mode()
535 return desc->msi_attrib.is_msix || desc->msi_attrib.maskbit; in msi_check_reservation_mode()
541 struct msi_domain_info *info = domain->host_data; in __msi_domain_alloc_irqs()
542 struct msi_domain_ops *ops = info->ops; in __msi_domain_alloc_irqs()
554 ops->set_desc(&arg, desc); in __msi_domain_alloc_irqs()
556 virq = __irq_domain_alloc_irqs(domain, -1, desc->nvec_used, in __msi_domain_alloc_irqs()
558 desc->affinity); in __msi_domain_alloc_irqs()
560 ret = -ENOSPC; in __msi_domain_alloc_irqs()
561 if (ops->handle_error) in __msi_domain_alloc_irqs()
562 ret = ops->handle_error(domain, desc, ret); in __msi_domain_alloc_irqs()
563 if (ops->msi_finish) in __msi_domain_alloc_irqs()
564 ops->msi_finish(&arg, ret); in __msi_domain_alloc_irqs()
568 for (i = 0; i < desc->nvec_used; i++) { in __msi_domain_alloc_irqs()
574 if (ops->msi_finish) in __msi_domain_alloc_irqs()
575 ops->msi_finish(&arg, 0); in __msi_domain_alloc_irqs()
584 if (!(info->flags & MSI_FLAG_ACTIVATE_EARLY)) in __msi_domain_alloc_irqs()
588 if (desc->irq == i) { in __msi_domain_alloc_irqs()
589 virq = desc->irq; in __msi_domain_alloc_irqs()
590 dev_dbg(dev, "irq [%d-%d] for MSI\n", in __msi_domain_alloc_irqs()
591 virq, virq + desc->nvec_used - 1); in __msi_domain_alloc_irqs()
597 if (domain->flags & IRQ_DOMAIN_MSI_NOMASK_QUIRK) in __msi_domain_alloc_irqs()
624 * msi_domain_alloc_irqs - Allocate interrupts from a MSI interrupt domain
635 struct msi_domain_info *info = domain->host_data; in msi_domain_alloc_irqs()
636 struct msi_domain_ops *ops = info->ops; in msi_domain_alloc_irqs()
638 return ops->domain_alloc_irqs(domain, dev, nvec); in msi_domain_alloc_irqs()
659 if (desc->irq) { in __msi_domain_free_irqs()
660 irq_domain_free_irqs(desc->irq, desc->nvec_used); in __msi_domain_free_irqs()
661 desc->irq = 0; in __msi_domain_free_irqs()
667 * msi_domain_free_irqs - Free interrupts from a MSI interrupt @domain associated to @dev
674 struct msi_domain_info *info = domain->host_data; in msi_domain_free_irqs()
675 struct msi_domain_ops *ops = info->ops; in msi_domain_free_irqs()
677 return ops->domain_free_irqs(domain, dev); in msi_domain_free_irqs()
681 * msi_get_domain_info - Get the MSI interrupt domain info for @domain
682 * @domain: The interrupt domain to retrieve data from
684 * Return: the pointer to the msi_domain_info stored in @domain->host_data.
688 return (struct msi_domain_info *)domain->host_data; in msi_get_domain_info()