| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Code to handle x86 style IRQs plus some generic interrupt stuff. |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 6 | 7 | * Copyright (C) 1999 SuSE GmbH (Philipp Rumpf, prumpf@tux.org) |
|---|
| 7 | 8 | * Copyright (C) 1999-2000 Grant Grundler |
|---|
| 8 | 9 | * Copyright (c) 2005 Matthew Wilcox |
|---|
| 9 | | - * |
|---|
| 10 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 11 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 12 | | - * the Free Software Foundation; either version 2, or (at your option) |
|---|
| 13 | | - * any later version. |
|---|
| 14 | | - * |
|---|
| 15 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 16 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 17 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 18 | | - * GNU General Public License for more details. |
|---|
| 19 | | - * |
|---|
| 20 | | - * You should have received a copy of the GNU General Public License |
|---|
| 21 | | - * along with this program; if not, write to the Free Software |
|---|
| 22 | | - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|---|
| 23 | 10 | */ |
|---|
| 24 | 11 | #include <linux/bitops.h> |
|---|
| 25 | 12 | #include <linux/errno.h> |
|---|
| .. | .. |
|---|
| 117 | 104 | return -EINVAL; |
|---|
| 118 | 105 | |
|---|
| 119 | 106 | /* whatever mask they set, we just allow one CPU */ |
|---|
| 120 | | - cpu_dest = cpumask_first_and(dest, cpu_online_mask); |
|---|
| 107 | + cpu_dest = cpumask_next_and(d->irq & (num_online_cpus()-1), |
|---|
| 108 | + dest, cpu_online_mask); |
|---|
| 109 | + if (cpu_dest >= nr_cpu_ids) |
|---|
| 110 | + cpu_dest = cpumask_first_and(dest, cpu_online_mask); |
|---|
| 121 | 111 | |
|---|
| 122 | 112 | return cpu_dest; |
|---|
| 123 | 113 | } |
|---|
| .. | .. |
|---|
| 175 | 165 | # endif |
|---|
| 176 | 166 | #endif |
|---|
| 177 | 167 | #ifdef CONFIG_SMP |
|---|
| 178 | | - seq_printf(p, "%*s: ", prec, "RES"); |
|---|
| 179 | | - for_each_online_cpu(j) |
|---|
| 180 | | - seq_printf(p, "%10u ", irq_stats(j)->irq_resched_count); |
|---|
| 181 | | - seq_puts(p, " Rescheduling interrupts\n"); |
|---|
| 168 | + if (num_online_cpus() > 1) { |
|---|
| 169 | + seq_printf(p, "%*s: ", prec, "RES"); |
|---|
| 170 | + for_each_online_cpu(j) |
|---|
| 171 | + seq_printf(p, "%10u ", irq_stats(j)->irq_resched_count); |
|---|
| 172 | + seq_puts(p, " Rescheduling interrupts\n"); |
|---|
| 173 | + seq_printf(p, "%*s: ", prec, "CAL"); |
|---|
| 174 | + for_each_online_cpu(j) |
|---|
| 175 | + seq_printf(p, "%10u ", irq_stats(j)->irq_call_count); |
|---|
| 176 | + seq_puts(p, " Function call interrupts\n"); |
|---|
| 177 | + } |
|---|
| 182 | 178 | #endif |
|---|
| 183 | 179 | seq_printf(p, "%*s: ", prec, "UAH"); |
|---|
| 184 | 180 | for_each_online_cpu(j) |
|---|
| .. | .. |
|---|
| 568 | 564 | goto out; |
|---|
| 569 | 565 | } |
|---|
| 570 | 566 | |
|---|
| 571 | | -static struct irqaction timer_action = { |
|---|
| 572 | | - .handler = timer_interrupt, |
|---|
| 573 | | - .name = "timer", |
|---|
| 574 | | - .flags = IRQF_TIMER | IRQF_PERCPU | IRQF_IRQPOLL, |
|---|
| 575 | | -}; |
|---|
| 576 | | - |
|---|
| 577 | | -#ifdef CONFIG_SMP |
|---|
| 578 | | -static struct irqaction ipi_action = { |
|---|
| 579 | | - .handler = ipi_interrupt, |
|---|
| 580 | | - .name = "IPI", |
|---|
| 581 | | - .flags = IRQF_PERCPU, |
|---|
| 582 | | -}; |
|---|
| 583 | | -#endif |
|---|
| 584 | | - |
|---|
| 585 | 567 | static void claim_cpu_irqs(void) |
|---|
| 586 | 568 | { |
|---|
| 569 | + unsigned long flags = IRQF_TIMER | IRQF_PERCPU | IRQF_IRQPOLL; |
|---|
| 587 | 570 | int i; |
|---|
| 571 | + |
|---|
| 588 | 572 | for (i = CPU_IRQ_BASE; i <= CPU_IRQ_MAX; i++) { |
|---|
| 589 | 573 | irq_set_chip_and_handler(i, &cpu_interrupt_type, |
|---|
| 590 | 574 | handle_percpu_irq); |
|---|
| 591 | 575 | } |
|---|
| 592 | 576 | |
|---|
| 593 | 577 | irq_set_handler(TIMER_IRQ, handle_percpu_irq); |
|---|
| 594 | | - setup_irq(TIMER_IRQ, &timer_action); |
|---|
| 578 | + if (request_irq(TIMER_IRQ, timer_interrupt, flags, "timer", NULL)) |
|---|
| 579 | + pr_err("Failed to register timer interrupt\n"); |
|---|
| 595 | 580 | #ifdef CONFIG_SMP |
|---|
| 596 | 581 | irq_set_handler(IPI_IRQ, handle_percpu_irq); |
|---|
| 597 | | - setup_irq(IPI_IRQ, &ipi_action); |
|---|
| 582 | + if (request_irq(IPI_IRQ, ipi_interrupt, IRQF_PERCPU, "IPI", NULL)) |
|---|
| 583 | + pr_err("Failed to register IPI interrupt\n"); |
|---|
| 598 | 584 | #endif |
|---|
| 599 | 585 | } |
|---|
| 600 | 586 | |
|---|