Re: [patch V3 21/33] genirq/msi: Provide msi_domain_alloc_irq_at()
From: Thomas Gleixner
Date: Mon Nov 28 2022 - 09:39:39 EST
On Fri, Nov 25 2022 at 00:26, Thomas Gleixner wrote:
> +struct msi_map msi_domain_alloc_irq_at(struct device *dev, unsigned int domid, unsigned int index,
> + const struct irq_affinity_desc *affdesc,
> + union msi_instance_cookie *icookie)
> +{
> + struct msi_ctrl ctrl = { .domid = domid, .nirqs = 1, };
> + struct msi_domain_info *info;
Remove
> + struct irq_domain *domain;
> + struct msi_map map = { };
> + struct msi_desc *desc;
> + int ret;
> +
> + msi_lock_descs(dev);
> + domain = msi_get_device_domain(dev, domid);
> + if (!domain) {
> + map.index = -ENODEV;
> + goto unlock;
> + }
> +
> + desc = msi_alloc_desc(dev, 1, affdesc);
> + if (!desc) {
> + map.index = -ENOMEM;
> + goto unlock;
> + }
> +
> + if (icookie)
> + desc->data.icookie = *icookie;
> +
> + ret = msi_insert_desc(dev, desc, domid, index);
> + if (ret) {
> + map.index = ret;
> + goto unlock;
> + }
> +
> + ctrl.first = ctrl.last = desc->msi_index;
> + info = domain->host_data;
Pointless
> + ret = __msi_domain_alloc_irqs(dev, domain, &ctrl);
> + if (ret) {
> + map.index = ret;
> + msi_domain_free_locked(dev, &ctrl);
> + } else {
> + map.index = desc->msi_index;
> + map.virq = desc->irq;
> + }
> +unlock:
> + msi_unlock_descs(dev);
> + return map;
> +}
> +
> static void __msi_domain_free_irqs(struct device *dev, struct irq_domain *domain,
> struct msi_ctrl *ctrl)
> {