From patchwork Tue Mar 27 16:19:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Palmer Dabbelt X-Patchwork-Id: 10310623 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BB4946037D for ; Tue, 27 Mar 2018 16:21:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AA4CD29A2E for ; Tue, 27 Mar 2018 16:21:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9F38E29A33; Tue, 27 Mar 2018 16:21:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1932B29A2E for ; Tue, 27 Mar 2018 16:21:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:To:From:References: In-Reply-To:Message-Id:Date:Subject:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=cphyDajIUWMAyfsI0cjjbenXbIzeAwECPlgQeAraSds=; b=XACQV1Klf0K05O Ik290xTbKPp69L5bSXK5fN9Cv9L7PFFEFTBJ9YY7roz/UzlGz3jxl/CBiiXiHJwACoIbyJB4zmxOG I6wunE9guucP9mCl3pbdxMWMtR9D/zuGgXjm/Wb/hkJHG8ve7iOUWvK5j/UOmHi3H1yghJuTv9X9r wELnafTtGurP0R3Qfft5pTS6MapZe5pvRUPTEvKocFdwO8Ucmn/RfMvIbnaRArnXnLoyMnxT8LivN F6J6Yj+Yy7DFIutQW22zurVw2KDo22/3vYoTudSmX3HAThAdwWsOmADtO/Jyb+9anTmshvBswLCJ7 3vbzBGwPRjBcReim+wfQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1f0rLy-0001dO-U7; Tue, 27 Mar 2018 16:21:42 +0000 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f0rJz-00073m-VV for linux-arm-kernel@lists.infradead.org; Tue, 27 Mar 2018 16:19:45 +0000 Received: by mail-pf0-x241.google.com with SMTP id a11so5687908pff.8 for ; Tue, 27 Mar 2018 09:19:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=subject:date:message-id:in-reply-to:references:cc:from:to; bh=xvJ/8lT3P+V2CoUcTZZf6YY8y+trcE3GpJunQwvoBi0=; b=FWP9JuEZHq4dVN6Y/4N5V5e6fUBjXgv4uaW/jmJpu6QzTHyBPlSZiN9wjYZ7+jTWvV xcoQYd/Nxa1xwJKz8w9Hq6BYSmZJKVAj0tvAzoHW2rZiLno6vxsInr8q8Ck6eYnRS4cI aILE6aUfFObrwjNBAj9cSMs5waXvgIC/pyMjfdXrRcN0PxARfC/HbvMaLnUKNgQmZdOb 2Ye0sBsWqz65+FLZ/LTQNtkb+ykURBDBhTMkmkDbQJOAnDOQDjcrVjIjPSFdVQRarh+E FvLiV6mYQNhwJRdUsomIUwvdBfrIKRMiupBB9Ez1XNw7I7nFzzrflThymktFHU2/SN9I +TCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:date:message-id:in-reply-to:references :cc:from:to; bh=xvJ/8lT3P+V2CoUcTZZf6YY8y+trcE3GpJunQwvoBi0=; b=IzQsFK1Wgw9rd13l1RYEd/wlB/aIPEjXByrTJqNTRIMhccT6uVSaN1WX5GaRcvkJng IkM7NZKLYCi9CtDYSEY1g7my7iyyCZbaDX2ku8SH1szfZUfG46iVFCaYR+LICmj7bMO0 vWc5QTh9wBSdKv6dey3q+HDlrKvGcnjU6HqulhNk6+ItP7rT0Ka54PO5Gc7Kw3K0weeU shq8WH1NRN1axoTEoiwQ0A1cy7U2JO3lsV5iR+flF7r1B4/MFZkGj1GMp0aGyrtwuupx ZszmNr9ZpK0ttpvaj+tSHfN2l0wFzfwoyrmal1g5Vnzdj2wymvgfWQML0ouCeTV4ZKw0 Ad/A== X-Gm-Message-State: AElRT7F3FgDe9td/H2PWWl2z7u+35Xgzr14ECkCeC/INd7K2XZV8OwTP jcuMAH63urBf4TcQc5UbwH1p6w== X-Google-Smtp-Source: AG47ELuIbscDtV2ttrQYn4DW43lFHOj5sbCQGP2Ru/fcQDyqTVaGoKCm8OoRYFoT/Y4S7x1HCNWo9Q== X-Received: by 10.98.35.90 with SMTP id j87mr24859256pfj.59.1522167569081; Tue, 27 Mar 2018 09:19:29 -0700 (PDT) Received: from localhost ([12.206.222.5]) by smtp.gmail.com with ESMTPSA id y6sm4144253pfg.71.2018.03.27.09.19.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Mar 2018 09:19:28 -0700 (PDT) Subject: [PATCH v4 3/8] irq: Add CONFIG_GENERIC_IRQ_MULTI_HANDLER Date: Tue, 27 Mar 2018 09:19:06 -0700 Message-Id: <20180327161911.14086-4-palmer@sifive.com> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180327161911.14086-1-palmer@sifive.com> References: <20180327161911.14086-1-palmer@sifive.com> From: Palmer Dabbelt To: linux@armlinux.org.uk, catalin.marinas@arm.com, Will Deacon , jonas@southpole.se, stefan.kristiansson@saunalahti.fi, shorne@gmail.com, tglx@linutronix.de, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, openrisc@lists.librecores.org, linux-riscv@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180327_091940_011878_A6828A69 X-CRM114-Status: GOOD ( 18.42 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Shea Levy , Palmer Dabbelt , Arnd Bergmann MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP It looks like the arm irqchip registration mechanism has been copied into a handful of ports, including arm64 and openrisc. I want to use this in the RISC-V port, so I thought it would be good to make this generic instead. This patch copies the arm definition of CONFIG_MULTI_IRQ_HANDLER into kernel/irq under CONFIG_GENERIC_IRQ_MULTI_HANDLER. This patch is currently all dead code, but it will be enabled in the various other architectures in subsequent patches. GENERIC_IRQ_MULTI_HANDLER is incompatible with MULTI_IRQ_HANDLER because they define the same symbols. Multiple generic irqchip drivers select MULTI_IRQ_HANDLER, which is now defined on all architectures that provide set_handle_irq(). This patch selects GENERIC_IRQ_MULTI_HANDLER for all drivers that used to select MULTI_IRQ_HANDLER, but only when MULTI_IRQ_HANDLER doesn't exist. I'll then convert every architecture over from MULTI_IRQ_HANDLER to GENERIC_IRQ_MULTI_HANDLER before removing the extra MULTI_IRQ_HANDLER scaffolding. CC: Shea Levy CC: Arnd Bergmann Signed-off-by: Palmer Dabbelt --- drivers/irqchip/Kconfig | 8 ++++++++ include/linux/irq.h | 18 ++++++++++++++++++ kernel/irq/Kconfig | 6 ++++++ kernel/irq/handle.c | 15 +++++++++++++++ 4 files changed, 47 insertions(+) diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig index d913aec85109..5af28ac6ce35 100644 --- a/drivers/irqchip/Kconfig +++ b/drivers/irqchip/Kconfig @@ -9,6 +9,7 @@ config ARM_GIC select IRQ_DOMAIN select IRQ_DOMAIN_HIERARCHY select MULTI_IRQ_HANDLER + select GENERIC_IRQ_MULTI_HANDLER if !MULTI_IRQ_HANDLER select GENERIC_IRQ_EFFECTIVE_AFF_MASK config ARM_GIC_PM @@ -35,6 +36,7 @@ config ARM_GIC_V3 bool select IRQ_DOMAIN select MULTI_IRQ_HANDLER + select GENERIC_IRQ_MULTI_HANDLER if !MULTI_IRQ_HANDLER select IRQ_DOMAIN_HIERARCHY select PARTITION_PERCPU select GENERIC_IRQ_EFFECTIVE_AFF_MASK @@ -61,6 +63,7 @@ config ARM_VIC bool select IRQ_DOMAIN select MULTI_IRQ_HANDLER + select GENERIC_IRQ_MULTI_HANDLER if !MULTI_IRQ_HANDLER config ARM_VIC_NR int @@ -88,6 +91,7 @@ config ATMEL_AIC_IRQ select GENERIC_IRQ_CHIP select IRQ_DOMAIN select MULTI_IRQ_HANDLER + select GENERIC_IRQ_MULTI_HANDLER if !MULTI_IRQ_HANDLER select SPARSE_IRQ config ATMEL_AIC5_IRQ @@ -95,6 +99,7 @@ config ATMEL_AIC5_IRQ select GENERIC_IRQ_CHIP select IRQ_DOMAIN select MULTI_IRQ_HANDLER + select GENERIC_IRQ_MULTI_HANDLER if !MULTI_IRQ_HANDLER select SPARSE_IRQ config I8259 @@ -132,6 +137,7 @@ config FARADAY_FTINTC010 bool select IRQ_DOMAIN select MULTI_IRQ_HANDLER + select GENERIC_IRQ_MULTI_HANDLER if !MULTI_IRQ_HANDLER select SPARSE_IRQ config HISILICON_IRQ_MBIGEN @@ -157,6 +163,7 @@ config CLPS711X_IRQCHIP depends on ARCH_CLPS711X select IRQ_DOMAIN select MULTI_IRQ_HANDLER + select GENERIC_IRQ_MULTI_HANDLER if !MULTI_IRQ_HANDLER select SPARSE_IRQ default y @@ -176,6 +183,7 @@ config ORION_IRQCHIP bool select IRQ_DOMAIN select MULTI_IRQ_HANDLER + select GENERIC_IRQ_MULTI_HANDLER if !MULTI_IRQ_HANDLER config PIC32_EVIC bool diff --git a/include/linux/irq.h b/include/linux/irq.h index a0231e96a578..77e97872a13e 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -1170,4 +1170,22 @@ int __ipi_send_mask(struct irq_desc *desc, const struct cpumask *dest); int ipi_send_single(unsigned int virq, unsigned int cpu); int ipi_send_mask(unsigned int virq, const struct cpumask *dest); +#ifdef CONFIG_GENERIC_IRQ_MULTI_HANDLER +/* + * Registers a generic IRQ handling function as the top-level IRQ handler in + * the system, which is generally the first C code called from an assembly + * architecture-specific interrupt handler. + * + * Returns 0 on success, or -EBUSY if an IRQ handler has already been + * registered. + */ +int __init set_handle_irq(void (*handle_irq)(struct pt_regs *)); + +/* + * Allows interrupt handlers to find the irqchip that's been registered as the + * top-level IRQ handler. + */ +extern void (*handle_arch_irq)(struct pt_regs *) __ro_after_init; +#endif + #endif /* _LINUX_IRQ_H */ diff --git a/kernel/irq/Kconfig b/kernel/irq/Kconfig index 6fc87ccda1d7..8596baa8e53d 100644 --- a/kernel/irq/Kconfig +++ b/kernel/irq/Kconfig @@ -132,3 +132,9 @@ config GENERIC_IRQ_DEBUGFS If you don't know what to do here, say N. endmenu + +config GENERIC_IRQ_MULTI_HANDLER + depends on !MULTI_IRQ_HANDLER + bool + help + Allow each machine to specify it's own IRQ handler at run time. diff --git a/kernel/irq/handle.c b/kernel/irq/handle.c index 79f987b942b8..3570c715c3e7 100644 --- a/kernel/irq/handle.c +++ b/kernel/irq/handle.c @@ -20,6 +20,10 @@ #include "internals.h" +#ifdef CONFIG_GENERIC_IRQ_MULTI_HANDLER +void (*handle_arch_irq)(struct pt_regs *) __ro_after_init; +#endif + /** * handle_bad_irq - handle spurious and unhandled irqs * @desc: description of the interrupt @@ -207,3 +211,14 @@ irqreturn_t handle_irq_event(struct irq_desc *desc) irqd_clear(&desc->irq_data, IRQD_IRQ_INPROGRESS); return ret; } + +#ifdef CONFIG_GENERIC_IRQ_MULTI_HANDLER +int __init set_handle_irq(void (*handle_irq)(struct pt_regs *)) +{ + if (handle_arch_irq) + return -EBUSY; + + handle_arch_irq = handle_irq; + return 0; +} +#endif