Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e8a70350 authored by Thomas Gleixner's avatar Thomas Gleixner
Browse files

genirq/cpuhotplug: Reorder check logic



Move the checks for a valid irq chip and the irq_set_affinity() callback
right in front of the whole migration logic. No point in doing a gazillion
of other things when the interrupt cannot be migrated at all.

Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Marc Zyngier <marc.zyngier@arm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Keith Busch <keith.busch@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Christoph Hellwig <hch@lst.de>
Link: http://lkml.kernel.org/r/20170619235445.354181630@linutronix.de
parent 735c0952
Loading
Loading
Loading
Loading
+20 −16
Original line number Original line Diff line number Diff line
@@ -17,9 +17,20 @@
static bool migrate_one_irq(struct irq_desc *desc)
static bool migrate_one_irq(struct irq_desc *desc)
{
{
	struct irq_data *d = irq_desc_get_irq_data(desc);
	struct irq_data *d = irq_desc_get_irq_data(desc);
	struct irq_chip *chip = irq_data_get_irq_chip(d);
	const struct cpumask *affinity = d->common->affinity;
	const struct cpumask *affinity = d->common->affinity;
	struct irq_chip *c;
	bool brokeaff = false;
	bool ret = false;
	int err;

	/*
	 * IRQ chip might be already torn down, but the irq descriptor is
	 * still in the radix tree. Also if the chip has no affinity setter,
	 * nothing can be done here.
	 */
	if (!chip || !chip->irq_set_affinity) {
		pr_debug("IRQ %u: Unable to migrate away\n", d->irq);
		return false;
	}


	/*
	/*
	 * If this is a per-CPU interrupt, or the affinity does not
	 * If this is a per-CPU interrupt, or the affinity does not
@@ -31,23 +42,16 @@ static bool migrate_one_irq(struct irq_desc *desc)


	if (cpumask_any_and(affinity, cpu_online_mask) >= nr_cpu_ids) {
	if (cpumask_any_and(affinity, cpu_online_mask) >= nr_cpu_ids) {
		affinity = cpu_online_mask;
		affinity = cpu_online_mask;
		ret = true;
		brokeaff = true;
	}
	}


	c = irq_data_get_irq_chip(d);
	err = irq_do_set_affinity(d, affinity, false);
	if (!c->irq_set_affinity) {
	if (err) {
		pr_debug("IRQ%u: unable to set affinity\n", d->irq);
		ret = false;
	} else {
		int r = irq_do_set_affinity(d, affinity, false);
		if (r) {
		pr_warn_ratelimited("IRQ%u: set affinity failed(%d).\n",
		pr_warn_ratelimited("IRQ%u: set affinity failed(%d).\n",
					    d->irq, r);
				    d->irq, err);
			ret = false;
		return false;
		}
	}
	}

	return brokeaff;
	return ret;
}
}


/**
/**