Re: [PATCH v3 1/4] genirq/irqdomain: Allow partial trimming of irq_data hierarchy

From: Marc Zyngier
Date: Sat Oct 10 2020 - 06:03:53 EST


On Thu, 08 Oct 2020 21:47:29 +0100,
Thomas Gleixner <tglx@xxxxxxxxxxxxx> wrote:
>
> On Thu, Oct 08 2020 at 14:06, Marc Zyngier wrote:
> > On 2020-10-08 12:22, Thomas Gleixner wrote:
> > Here's what I have now, with the pmc driver calling
> > irq_domain_disconnect_hierarchy() at the right spots.
> >
> > static int irq_domain_alloc_irq_data(struct irq_domain *domain,
> > @@ -1362,11 +1442,16 @@ int __irq_domain_alloc_irqs(struct irq_domain
> > *domain, int irq_base,
> > mutex_unlock(&irq_domain_mutex);
> > goto out_free_irq_data;
> > }
> > - for (i = 0; i < nr_irqs; i++)
> > + for (i = 0; i < nr_irqs; i++) {
> > + ret = irq_domain_trim_hierarchy(virq + i);
> > + if (ret)
> > + break;
> > irq_domain_insert_irq(virq + i);
>
> You can't do that in one go because in case of an error you leak the
> already inserted irqs. You need two loops.
>
> for (i = 0; i < nr_irqs; i++) {
> ret = irq_domain_trim_hierarchy(virq + i);
> if (ret) {
> mutex_unlock(&irq_domain_mutex);
> goto out_free_irq_data;
> }
>
> for (i = 0; i < nr_irqs; i++)
> irq_domain_insert_irq(virq + i);
>
> mutex_unlock(&irq_domain_mutex);
> return virq;

Of course you are right. I'll fold that in.

Thanks,

M.

--
Without deviation from the norm, progress is not possible.