Lines Matching refs:desc
61 struct msi_desc *desc = kzalloc(sizeof(*desc), GFP_KERNEL); in msi_alloc_desc() local
63 if (!desc) in msi_alloc_desc()
66 desc->dev = dev; in msi_alloc_desc()
67 desc->nvec_used = nvec; in msi_alloc_desc()
69 desc->affinity = kmemdup(affinity, nvec * sizeof(*desc->affinity), GFP_KERNEL); in msi_alloc_desc()
70 if (!desc->affinity) { in msi_alloc_desc()
71 kfree(desc); in msi_alloc_desc()
75 return desc; in msi_alloc_desc()
78 static void msi_free_desc(struct msi_desc *desc) in msi_free_desc() argument
80 kfree(desc->affinity); in msi_free_desc()
81 kfree(desc); in msi_free_desc()
84 static int msi_insert_desc(struct device *dev, struct msi_desc *desc, in msi_insert_desc() argument
99 ret = xa_alloc(xa, &index, desc, limit, GFP_KERNEL); in msi_insert_desc()
103 desc->msi_index = index; in msi_insert_desc()
111 desc->msi_index = index; in msi_insert_desc()
112 ret = xa_insert(xa, index, desc, GFP_KERNEL); in msi_insert_desc()
118 msi_free_desc(desc); in msi_insert_desc()
135 struct msi_desc *desc; in msi_domain_insert_msi_desc() local
139 desc = msi_alloc_desc(dev, init_desc->nvec_used, init_desc->affinity); in msi_domain_insert_msi_desc()
140 if (!desc) in msi_domain_insert_msi_desc()
144 desc->pci = init_desc->pci; in msi_domain_insert_msi_desc()
146 return msi_insert_desc(dev, desc, domid, init_desc->msi_index); in msi_domain_insert_msi_desc()
149 static bool msi_desc_match(struct msi_desc *desc, enum msi_desc_filter filter) in msi_desc_match() argument
155 return !desc->irq; in msi_desc_match()
157 return !!desc->irq; in msi_desc_match()
182 struct msi_desc *desc; in msi_domain_free_descs() local
192 xa_for_each_range(xa, idx, desc, ctrl->first, ctrl->last) { in msi_domain_free_descs()
196 if (WARN_ON_ONCE(msi_desc_match(desc, MSI_DESC_ASSOCIATED))) in msi_domain_free_descs()
198 msi_free_desc(desc); in msi_domain_free_descs()
230 struct msi_desc *desc; in msi_domain_add_simple_msi_descs() local
240 desc = msi_alloc_desc(dev, 1, NULL); in msi_domain_add_simple_msi_descs()
241 if (!desc) in msi_domain_add_simple_msi_descs()
243 ret = msi_insert_desc(dev, desc, ctrl->domid, idx); in msi_domain_add_simple_msi_descs()
354 struct msi_desc *desc; in msi_find_desc() local
356 xa_for_each_start(xa, md->__iter_idx, desc, md->__iter_idx) { in msi_find_desc()
357 if (msi_desc_match(desc, filter)) in msi_find_desc()
358 return desc; in msi_find_desc()
433 struct msi_desc *desc; in msi_domain_get_virq() local
450 desc = xa_load(xa, pcimsi ? 0 : index); in msi_domain_get_virq()
451 if (desc && desc->irq) { in msi_domain_get_virq()
458 if (index < desc->nvec_used) in msi_domain_get_virq()
459 ret = desc->irq + index; in msi_domain_get_virq()
461 ret = desc->irq; in msi_domain_get_virq()
494 static void msi_sysfs_remove_desc(struct device *dev, struct msi_desc *desc) in msi_sysfs_remove_desc() argument
496 struct device_attribute *attrs = desc->sysfs_attrs; in msi_sysfs_remove_desc()
502 desc->sysfs_attrs = NULL; in msi_sysfs_remove_desc()
503 for (i = 0; i < desc->nvec_used; i++) { in msi_sysfs_remove_desc()
511 static int msi_sysfs_populate_desc(struct device *dev, struct msi_desc *desc) in msi_sysfs_populate_desc() argument
516 attrs = kcalloc(desc->nvec_used, sizeof(*attrs), GFP_KERNEL); in msi_sysfs_populate_desc()
520 desc->sysfs_attrs = attrs; in msi_sysfs_populate_desc()
521 for (i = 0; i < desc->nvec_used; i++) { in msi_sysfs_populate_desc()
523 attrs[i].attr.name = kasprintf(GFP_KERNEL, "%d", desc->irq + i); in msi_sysfs_populate_desc()
541 msi_sysfs_remove_desc(dev, desc); in msi_sysfs_populate_desc()
552 struct msi_desc *desc; in msi_device_populate_sysfs() local
555 msi_for_each_desc(desc, dev, MSI_DESC_ASSOCIATED) { in msi_device_populate_sysfs()
556 if (desc->sysfs_attrs) in msi_device_populate_sysfs()
558 ret = msi_sysfs_populate_desc(dev, desc); in msi_device_populate_sysfs()
572 struct msi_desc *desc; in msi_device_destroy_sysfs() local
574 msi_for_each_desc(desc, dev, MSI_DESC_ALL) in msi_device_destroy_sysfs()
575 msi_sysfs_remove_desc(dev, desc); in msi_device_destroy_sysfs()
580 static inline int msi_sysfs_populate_desc(struct device *dev, struct msi_desc *desc) { return 0; } in msi_sysfs_populate_desc() argument
581 static inline void msi_sysfs_remove_desc(struct device *dev, struct msi_desc *desc) { } in msi_sysfs_remove_desc() argument
750 struct msi_desc *desc) in msi_domain_ops_set_desc() argument
752 arg->desc = desc; in msi_domain_ops_set_desc()
1080 struct msi_desc *desc; in msi_domain_populate_irqs() local
1098 desc = xa_load(xa, virq); in msi_domain_populate_irqs()
1099 desc->irq = virq; in msi_domain_populate_irqs()
1101 ops->set_desc(arg, desc); in msi_domain_populate_irqs()
1106 irq_set_msi_desc(virq, desc); in msi_domain_populate_irqs()
1129 struct msi_desc *desc; in msi_domain_depopulate_descs() local
1137 xa_for_each_range(xa, idx, desc, ctrl.first, ctrl.last) in msi_domain_depopulate_descs()
1138 desc->irq = 0; in msi_domain_depopulate_descs()
1156 struct msi_desc *desc; in msi_check_reservation_mode() local
1178 desc = msi_first_desc(dev, MSI_DESC_ALL); in msi_check_reservation_mode()
1179 return desc->pci.msi_attrib.is_msix || desc->pci.msi_attrib.can_mask; in msi_check_reservation_mode()
1182 static int msi_handle_pci_fail(struct irq_domain *domain, struct msi_desc *desc, in msi_handle_pci_fail() argument
1198 if (desc->nvec_used > 1) in msi_handle_pci_fail()
1255 struct msi_desc *desc; in __msi_domain_alloc_irqs() local
1278 xa_for_each_range(xa, idx, desc, ctrl->first, ctrl->last) { in __msi_domain_alloc_irqs()
1279 if (!msi_desc_match(desc, MSI_DESC_NOTASSOCIATED)) in __msi_domain_alloc_irqs()
1287 ops->prepare_desc(domain, &arg, desc); in __msi_domain_alloc_irqs()
1289 ops->set_desc(&arg, desc); in __msi_domain_alloc_irqs()
1291 virq = __irq_domain_alloc_irqs(domain, -1, desc->nvec_used, in __msi_domain_alloc_irqs()
1293 desc->affinity); in __msi_domain_alloc_irqs()
1295 return msi_handle_pci_fail(domain, desc, allocated); in __msi_domain_alloc_irqs()
1297 for (i = 0; i < desc->nvec_used; i++) { in __msi_domain_alloc_irqs()
1298 irq_set_msi_desc_off(virq, i, desc); in __msi_domain_alloc_irqs()
1305 ret = msi_sysfs_populate_desc(dev, desc); in __msi_domain_alloc_irqs()
1466 struct msi_desc *desc; in msi_domain_alloc_irq_at() local
1476 desc = msi_alloc_desc(dev, 1, affdesc); in msi_domain_alloc_irq_at()
1477 if (!desc) { in msi_domain_alloc_irq_at()
1483 desc->data.icookie = *icookie; in msi_domain_alloc_irq_at()
1485 ret = msi_insert_desc(dev, desc, domid, index); in msi_domain_alloc_irq_at()
1491 ctrl.first = ctrl.last = desc->msi_index; in msi_domain_alloc_irq_at()
1498 map.index = desc->msi_index; in msi_domain_alloc_irq_at()
1499 map.virq = desc->irq; in msi_domain_alloc_irq_at()
1512 struct msi_desc *desc; in __msi_domain_free_irqs() local
1516 xa_for_each_range(xa, idx, desc, ctrl->first, ctrl->last) { in __msi_domain_free_irqs()
1518 if (!msi_desc_match(desc, MSI_DESC_ASSOCIATED)) in __msi_domain_free_irqs()
1522 for (i = 0; i < desc->nvec_used; i++) { in __msi_domain_free_irqs()
1523 irqd = irq_domain_get_irq_data(domain, desc->irq + i); in __msi_domain_free_irqs()
1528 irq_domain_free_irqs(desc->irq, desc->nvec_used); in __msi_domain_free_irqs()
1530 msi_sysfs_remove_desc(dev, desc); in __msi_domain_free_irqs()
1531 desc->irq = 0; in __msi_domain_free_irqs()