Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Generic cpu hotunplug interrupt migration code copied from the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * arch/arm implementation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * Copyright (C) Russell King
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  * This program is free software; you can redistribute it and/or modify
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  * it under the terms of the GNU General Public License version 2 as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  * published by the Free Software Foundation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/ratelimit.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/irq.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/sched/isolation.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include "internals.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) /* For !GENERIC_IRQ_EFFECTIVE_AFF_MASK this looks at general affinity mask */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) static inline bool irq_needs_fixup(struct irq_data *d)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 	const struct cpumask *m = irq_data_get_effective_affinity_mask(d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 	unsigned int cpu = smp_processor_id();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #ifdef CONFIG_GENERIC_IRQ_EFFECTIVE_AFF_MASK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	 * The cpumask_empty() check is a workaround for interrupt chips,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	 * which do not implement effective affinity, but the architecture has
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	 * enabled the config switch. Use the general affinity mask instead.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	if (cpumask_empty(m))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 		m = irq_data_get_affinity_mask(d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	 * Sanity check. If the mask is not empty when excluding the outgoing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	 * CPU then it must contain at least one online CPU. The outgoing CPU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	 * has been removed from the online mask already.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	if (cpumask_any_but(m, cpu) < nr_cpu_ids &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	    cpumask_any_and(m, cpu_online_mask) >= nr_cpu_ids) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 		 * If this happens then there was a missed IRQ fixup at some
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 		 * point. Warn about it and enforce fixup.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 		pr_debug("Eff. affinity %*pbl of IRQ %u contains only offline CPUs after offlining CPU %u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 			cpumask_pr_args(m), d->irq, cpu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 		return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	return cpumask_test_cpu(cpu, m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) static bool migrate_one_irq(struct irq_desc *desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	struct irq_data *d = irq_desc_get_irq_data(desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	struct irq_chip *chip = irq_data_get_irq_chip(d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	bool maskchip = !irq_can_move_pcntxt(d) && !irqd_irq_masked(d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	const struct cpumask *affinity;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	bool brokeaff = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	 * IRQ chip might be already torn down, but the irq descriptor is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	 * still in the radix tree. Also if the chip has no affinity setter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	 * nothing can be done here.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	if (!chip || !chip->irq_set_affinity) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 		pr_debug("IRQ %u: Unable to migrate away\n", d->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 		return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	 * No move required, if:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	 * - Interrupt is per cpu
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	 * - Interrupt is not started
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	 * - Affinity mask does not include this CPU.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	 * Note: Do not check desc->action as this might be a chained
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	 * interrupt.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	if (irqd_is_per_cpu(d) || !irqd_is_started(d) || !irq_needs_fixup(d)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 		 * If an irq move is pending, abort it if the dying CPU is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 		 * the sole target.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 		irq_fixup_move_pending(desc, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 		return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	 * Complete an eventually pending irq move cleanup. If this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	 * interrupt was moved in hard irq context, then the vectors need
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	 * to be cleaned up. It can't wait until this interrupt actually
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	 * happens and this CPU was involved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	irq_force_complete_move(desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	 * If there is a setaffinity pending, then try to reuse the pending
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	 * mask, so the last change of the affinity does not get lost. If
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	 * there is no move pending or the pending mask does not contain
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	 * any online CPU, use the current affinity mask.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	if (irq_fixup_move_pending(desc, true))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 		affinity = irq_desc_get_pending_mask(desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 		affinity = irq_data_get_affinity_mask(d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	/* Mask the chip for interrupts which cannot move in process context */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	if (maskchip && chip->irq_mask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 		chip->irq_mask(d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	if (cpumask_any_and(affinity, cpu_online_mask) >= nr_cpu_ids) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 		 * If the interrupt is managed, then shut it down and leave
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 		 * the affinity untouched.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 		if (irqd_affinity_is_managed(d)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 			irqd_set_managed_shutdown(d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 			irq_shutdown_and_deactivate(desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 			return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 		affinity = cpu_online_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 		brokeaff = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	 * Do not set the force argument of irq_do_set_affinity() as this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	 * disables the masking of offline CPUs from the supplied affinity
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	 * mask and therefore might keep/reassign the irq to the outgoing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	 * CPU.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	err = irq_do_set_affinity(d, affinity, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 		pr_warn_ratelimited("IRQ%u: set affinity failed(%d).\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 				    d->irq, err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 		brokeaff = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	if (maskchip && chip->irq_unmask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 		chip->irq_unmask(d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	return brokeaff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)  * irq_migrate_all_off_this_cpu - Migrate irqs away from offline cpu
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)  * The current CPU has been marked offline.  Migrate IRQs off this CPU.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)  * If the affinity settings do not allow other CPUs, force them onto any
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)  * available CPU.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)  * Note: we must iterate over all IRQs, whether they have an attached
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)  * action structure or not, as we need to get chained interrupts too.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) void irq_migrate_all_off_this_cpu(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	struct irq_desc *desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	unsigned int irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	for_each_active_irq(irq) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 		bool affinity_broken;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 		desc = irq_to_desc(irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 		raw_spin_lock(&desc->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 		affinity_broken = migrate_one_irq(desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 		raw_spin_unlock(&desc->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 		if (affinity_broken) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 			pr_debug_ratelimited("IRQ %u: no longer affine to CPU%u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 					    irq, smp_processor_id());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) static bool hk_should_isolate(struct irq_data *data, unsigned int cpu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	const struct cpumask *hk_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	if (!housekeeping_enabled(HK_FLAG_MANAGED_IRQ))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 		return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	hk_mask = housekeeping_cpumask(HK_FLAG_MANAGED_IRQ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	if (cpumask_subset(irq_data_get_effective_affinity_mask(data), hk_mask))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 		return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	return cpumask_test_cpu(cpu, hk_mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) static void irq_restore_affinity_of_irq(struct irq_desc *desc, unsigned int cpu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	struct irq_data *data = irq_desc_get_irq_data(desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	const struct cpumask *affinity = irq_data_get_affinity_mask(data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	if (!irqd_affinity_is_managed(data) || !desc->action ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	    !irq_data_get_irq_chip(data) || !cpumask_test_cpu(cpu, affinity))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	if (irqd_is_managed_and_shutdown(data)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 		irq_startup(desc, IRQ_RESEND, IRQ_START_COND);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	 * If the interrupt can only be directed to a single target
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	 * CPU then it is already assigned to a CPU in the affinity
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	 * mask. No point in trying to move it around unless the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	 * isolation mechanism requests to move it to an upcoming
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	 * housekeeping CPU.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	if (!irqd_is_single_target(data) || hk_should_isolate(data, cpu))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 		irq_set_affinity_locked(data, affinity, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215)  * irq_affinity_online_cpu - Restore affinity for managed interrupts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216)  * @cpu:	Upcoming CPU for which interrupts should be restored
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) int irq_affinity_online_cpu(unsigned int cpu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	struct irq_desc *desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	unsigned int irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	irq_lock_sparse();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	for_each_active_irq(irq) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 		desc = irq_to_desc(irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 		raw_spin_lock_irq(&desc->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 		irq_restore_affinity_of_irq(desc, cpu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 		raw_spin_unlock_irq(&desc->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	irq_unlock_sparse();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) }