genirq: Split irq_set_affinity() so it can be called with lock held.
The .irq_cpu_online() and .irq_cpu_offline() functions may need to
adjust affinity, but they are called with the descriptor lock held.
Create __irq_set_affinity_locked() which is called with the lock held.
Make irq_set_affinity() just a wrapper that acquires the lock.
[ tglx: Changed the argument to irq_data, added a !desc check and
        moved the !irq_set_affinity check where it belongs ]
Signed-off-by: David Daney <ddaney@caviumnetworks.com>
Cc: linux-mips@linux-mips.org
Cc: ralf@linux-mips.org
LKML-Reference: <1301081931-11240-4-git-send-email-ddaney@caviumnetworks.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
	
	
This commit is contained in:
		
					parent
					
						
							
								b3d422329f
							
						
					
				
			
			
				commit
				
					
						c2d0c555c2
					
				
			
		
					 2 changed files with 37 additions and 24 deletions
				
			
		| 
						 | 
				
			
			@ -382,6 +382,7 @@ extern void remove_irq(unsigned int irq, struct irqaction *act);
 | 
			
		|||
 | 
			
		||||
extern void irq_cpu_online(void);
 | 
			
		||||
extern void irq_cpu_offline(void);
 | 
			
		||||
extern int __irq_set_affinity_locked(struct irq_data *data,  const struct cpumask *cpumask);
 | 
			
		||||
 | 
			
		||||
#ifdef CONFIG_GENERIC_HARDIRQS
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -139,6 +139,39 @@ static inline void
 | 
			
		|||
irq_get_pending(struct cpumask *mask, struct irq_desc *desc) { }
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
int __irq_set_affinity_locked(struct irq_data *data, const struct cpumask *mask)
 | 
			
		||||
{
 | 
			
		||||
	struct irq_chip *chip = irq_data_get_irq_chip(data);
 | 
			
		||||
	struct irq_desc *desc = irq_data_to_desc(data);
 | 
			
		||||
	int ret = 0;
 | 
			
		||||
 | 
			
		||||
	if (!chip || !chip->irq_set_affinity)
 | 
			
		||||
		return -EINVAL;
 | 
			
		||||
 | 
			
		||||
	if (irqd_can_move_in_process_context(data)) {
 | 
			
		||||
		ret = chip->irq_set_affinity(data, mask, false);
 | 
			
		||||
		switch (ret) {
 | 
			
		||||
		case IRQ_SET_MASK_OK:
 | 
			
		||||
			cpumask_copy(data->affinity, mask);
 | 
			
		||||
		case IRQ_SET_MASK_OK_NOCOPY:
 | 
			
		||||
			irq_set_thread_affinity(desc);
 | 
			
		||||
			ret = 0;
 | 
			
		||||
		}
 | 
			
		||||
	} else {
 | 
			
		||||
		irqd_set_move_pending(data);
 | 
			
		||||
		irq_copy_pending(desc, mask);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (desc->affinity_notify) {
 | 
			
		||||
		kref_get(&desc->affinity_notify->kref);
 | 
			
		||||
		schedule_work(&desc->affinity_notify->work);
 | 
			
		||||
	}
 | 
			
		||||
	irq_compat_set_affinity(desc);
 | 
			
		||||
	irqd_set(data, IRQD_AFFINITY_SET);
 | 
			
		||||
 | 
			
		||||
	return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 *	irq_set_affinity - Set the irq affinity of a given irq
 | 
			
		||||
 *	@irq:		Interrupt to set affinity
 | 
			
		||||
| 
						 | 
				
			
			@ -148,35 +181,14 @@ irq_get_pending(struct cpumask *mask, struct irq_desc *desc) { }
 | 
			
		|||
int irq_set_affinity(unsigned int irq, const struct cpumask *mask)
 | 
			
		||||
{
 | 
			
		||||
	struct irq_desc *desc = irq_to_desc(irq);
 | 
			
		||||
	struct irq_chip *chip = desc->irq_data.chip;
 | 
			
		||||
	unsigned long flags;
 | 
			
		||||
	int ret = 0;
 | 
			
		||||
	int ret;
 | 
			
		||||
 | 
			
		||||
	if (!chip->irq_set_affinity)
 | 
			
		||||
	if (!desc)
 | 
			
		||||
		return -EINVAL;
 | 
			
		||||
 | 
			
		||||
	raw_spin_lock_irqsave(&desc->lock, flags);
 | 
			
		||||
 | 
			
		||||
	if (irq_can_move_pcntxt(desc)) {
 | 
			
		||||
		ret = chip->irq_set_affinity(&desc->irq_data, mask, false);
 | 
			
		||||
		switch (ret) {
 | 
			
		||||
		case IRQ_SET_MASK_OK:
 | 
			
		||||
			cpumask_copy(desc->irq_data.affinity, mask);
 | 
			
		||||
		case IRQ_SET_MASK_OK_NOCOPY:
 | 
			
		||||
			irq_set_thread_affinity(desc);
 | 
			
		||||
			ret = 0;
 | 
			
		||||
		}
 | 
			
		||||
	} else {
 | 
			
		||||
		irqd_set_move_pending(&desc->irq_data);
 | 
			
		||||
		irq_copy_pending(desc, mask);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (desc->affinity_notify) {
 | 
			
		||||
		kref_get(&desc->affinity_notify->kref);
 | 
			
		||||
		schedule_work(&desc->affinity_notify->work);
 | 
			
		||||
	}
 | 
			
		||||
	irq_compat_set_affinity(desc);
 | 
			
		||||
	irqd_set(&desc->irq_data, IRQD_AFFINITY_SET);
 | 
			
		||||
	ret =  __irq_set_affinity_locked(irq_desc_get_irq_data(desc), mask);
 | 
			
		||||
	raw_spin_unlock_irqrestore(&desc->lock, flags);
 | 
			
		||||
	return ret;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue