Merge tag 'irq-urgent-2023-03-05' of git://git.kernel.org/pub/scm/linux/kernel/git...
[platform/kernel/linux-rpi.git] / kernel / irq / msi.c
index d0f0389..7a97bcb 100644 (file)
@@ -830,11 +830,8 @@ static struct irq_domain *__msi_create_irq_domain(struct fwnode_handle *fwnode,
        domain = irq_domain_create_hierarchy(parent, flags | IRQ_DOMAIN_FLAG_MSI, 0,
                                             fwnode, &msi_domain_ops, info);
 
-       if (domain) {
-               if (!domain->name && info->chip)
-                       domain->name = info->chip->name;
+       if (domain)
                irq_domain_update_bus_token(domain, info->bus_token);
-       }
 
        return domain;
 }
@@ -1084,10 +1081,13 @@ int msi_domain_populate_irqs(struct irq_domain *domain, struct device *dev,
        struct xarray *xa;
        int ret, virq;
 
-       if (!msi_ctrl_valid(dev, &ctrl))
-               return -EINVAL;
-
        msi_lock_descs(dev);
+
+       if (!msi_ctrl_valid(dev, &ctrl)) {
+               ret = -EINVAL;
+               goto unlock;
+       }
+
        ret = msi_domain_add_simple_msi_descs(dev, &ctrl);
        if (ret)
                goto unlock;
@@ -1109,14 +1109,35 @@ int msi_domain_populate_irqs(struct irq_domain *domain, struct device *dev,
        return 0;
 
 fail:
-       for (--virq; virq >= virq_base; virq--)
+       for (--virq; virq >= virq_base; virq--) {
+               msi_domain_depopulate_descs(dev, virq, 1);
                irq_domain_free_irqs_common(domain, virq, 1);
+       }
        msi_domain_free_descs(dev, &ctrl);
 unlock:
        msi_unlock_descs(dev);
        return ret;
 }
 
+void msi_domain_depopulate_descs(struct device *dev, int virq_base, int nvec)
+{
+       struct msi_ctrl ctrl = {
+               .domid  = MSI_DEFAULT_DOMAIN,
+               .first  = virq_base,
+               .last   = virq_base + nvec - 1,
+       };
+       struct msi_desc *desc;
+       struct xarray *xa;
+       unsigned long idx;
+
+       if (!msi_ctrl_valid(dev, &ctrl))
+               return;
+
+       xa = &dev->msi.data->__domains[ctrl.domid].store;
+       xa_for_each_range(xa, idx, desc, ctrl.first, ctrl.last)
+               desc->irq = 0;
+}
+
 /*
  * Carefully check whether the device can use reservation mode. If
  * reservation mode is enabled then the early activation will assign a