Files

140 lines
3.6 KiB
C
Raw Permalink Normal View History

// SPDX-License-Identifier: GPL-2.0
2006-03-25 03:07:36 -08:00
#include <linux/irq.h>
#include <linux/interrupt.h>
#include "internals.h"
2006-03-25 03:07:36 -08:00
2017-06-20 01:37:19 +02:00
/**
* irq_fixup_move_pending - Cleanup irq move pending from a dying CPU
* @desc: Interrupt descriptor to clean up
2017-06-20 01:37:19 +02:00
* @force_clear: If set clear the move pending bit unconditionally.
* If not set, clear it only when the dying CPU is the
* last one in the pending mask.
*
* Returns true if the pending bit was set and the pending mask contains an
* online CPU other than the dying CPU.
*/
bool irq_fixup_move_pending(struct irq_desc *desc, bool force_clear)
{
struct irq_data *data = irq_desc_get_irq_data(desc);
if (!irqd_is_setaffinity_pending(data))
return false;
/*
* The outgoing CPU might be the last online target in a pending
* interrupt move. If that's the case clear the pending move bit.
*/
2024-09-06 20:01:40 +03:00
if (!cpumask_intersects(desc->pending_mask, cpu_online_mask)) {
2017-06-20 01:37:19 +02:00
irqd_clr_move_pending(data);
return false;
}
if (force_clear)
irqd_clr_move_pending(data);
return true;
}
void irq_force_complete_move(struct irq_desc *desc)
{
for (struct irq_data *d = irq_desc_get_irq_data(desc); d; d = irqd_get_parent_data(d)) {
if (d->chip && d->chip->irq_force_complete_move) {
d->chip->irq_force_complete_move(d);
return;
}
}
}
void irq_move_masked_irq(struct irq_data *idata)
2006-03-25 03:07:36 -08:00
{
struct irq_desc *desc = irq_data_to_desc(idata);
struct irq_data *data = &desc->irq_data;
struct irq_chip *chip = data->chip;
2006-03-25 03:07:36 -08:00
if (likely(!irqd_is_setaffinity_pending(data)))
2006-03-25 03:07:36 -08:00
return;
irqd_clr_move_pending(data);
/*
* Paranoia: cpu-local interrupts shouldn't be calling in here anyway.
*/
if (irqd_is_per_cpu(data)) {
WARN_ON(1);
return;
}
if (unlikely(cpumask_empty(desc->pending_mask)))
2006-03-25 03:07:36 -08:00
return;
if (!chip->irq_set_affinity)
2006-03-25 03:07:36 -08:00
return;
assert_raw_spin_locked(&desc->lock);
2006-03-25 03:07:36 -08:00
/*
* If there was a valid mask to work with, please
* do the disable, re-program, enable sequence.
* This is *not* particularly important for level triggered
* but in a edge trigger case, we might be setting rte
2011-03-30 22:57:33 -03:00
* when an active trigger is coming in. This could
2006-03-25 03:07:36 -08:00
* cause some ioapics to mal-function.
* Being paranoid i guess!
2006-10-04 02:16:29 -07:00
*
* For correct operation this depends on the caller
* masking the irqs.
2006-03-25 03:07:36 -08:00
*/
2024-09-06 20:01:40 +03:00
if (cpumask_intersects(desc->pending_mask, cpu_online_mask)) {
int ret;
ret = irq_do_set_affinity(data, desc->pending_mask, false);
/*
* If the there is a cleanup pending in the underlying
* vector management, reschedule the move for the next
* interrupt. Leave desc->pending_mask intact.
*/
if (ret == -EBUSY) {
irqd_set_move_pending(data);
return;
}
}
cpumask_clear(desc->pending_mask);
2006-03-25 03:07:36 -08:00
}
2006-10-04 02:16:29 -07:00
void __irq_move_irq(struct irq_data *idata)
{
2011-01-28 08:47:15 +01:00
bool masked;
2006-10-04 02:16:29 -07:00
2015-06-01 16:05:11 +08:00
/*
* Get top level irq_data when CONFIG_IRQ_DOMAIN_HIERARCHY is enabled,
* and it should be optimized away when CONFIG_IRQ_DOMAIN_HIERARCHY is
* disabled. So we avoid an "#ifdef CONFIG_IRQ_DOMAIN_HIERARCHY" here.
*/
idata = irq_desc_get_irq_data(irq_data_to_desc(idata));
if (unlikely(irqd_irq_disabled(idata)))
return;
2006-10-04 02:16:29 -07:00
2011-01-28 08:47:15 +01:00
/*
* Be careful vs. already masked interrupts. If this is a
* threaded interrupt with ONESHOT set, we can end up with an
* interrupt storm.
*/
masked = irqd_irq_masked(idata);
2011-01-28 08:47:15 +01:00
if (!masked)
idata->chip->irq_mask(idata);
irq_move_masked_irq(idata);
2011-01-28 08:47:15 +01:00
if (!masked)
idata->chip->irq_unmask(idata);
}
bool irq_can_move_in_process_context(struct irq_data *data)
{
/*
* Get the top level irq_data in the hierarchy, which is optimized
* away when CONFIG_IRQ_DOMAIN_HIERARCHY is disabled.
*/
data = irq_desc_get_irq_data(irq_data_to_desc(data));
return irq_can_move_pcntxt(data);
}