From patchwork Wed Mar 7 23:57:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Palmer Dabbelt X-Patchwork-Id: 10265659 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 19E8060211 for ; Wed, 7 Mar 2018 23:59:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 07E8528ADD for ; Wed, 7 Mar 2018 23:59:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EC45128C61; Wed, 7 Mar 2018 23:59:15 +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 7BD3A28AD0 for ; Wed, 7 Mar 2018 23:59:15 +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=fvKQ0scgsNAEu9Rxx5wFgHk/5XtyjIlkeBLQYbIkXgI=; b=rIuHFqMep6mn54 HfPtODoF0Xluu/T+q7RkuXgwMK+XQbkCd0V+bfsK+YnApYJCGYlFyq/iTR33myJBYilLT7vzy2s8n SYfjPLTwzq/TW+/e/+OVg3qQ/iZ0E/GDA/z26lr2xvZS0FG5b4tIFvxxZ/c9aFh0JVIgX1Ag5V1La WF/B63sfAsNzNKSQGS1LVg9wtAo3sLxbc/gzlg0AmTGubaUsMEBiw+0qDaDFVnc1FVT5fzx5VWZEo fq4g717Ms/sSvMIaNFp+/kS/8GtbF9nby8Oz2RMpJZdg6iGwEg07fvf6428/oNq7cbfM1WzGK2g5R wHdUZpzGHpLlkkZhM4BQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1etixc-0008LO-Ix; Wed, 07 Mar 2018 23:59:04 +0000 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1etiwQ-0007e7-Oy for linux-arm-kernel@lists.infradead.org; Wed, 07 Mar 2018 23:57:54 +0000 Received: by mail-pf0-x244.google.com with SMTP id 17so1610016pfw.11 for ; Wed, 07 Mar 2018 15:57:40 -0800 (PST) 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=gKFaHjfObeOoztgwhGaHa0+nmnJnQ0hmuMjk2cnYydo=; b=gJyRPCa0ZhXeBPpKM1bxvn6lEwp5YScWG76Av+BbPiGWuKpX+v4rwxKppEt6szHq1K mmUmo7ybNRiX21jJ+ckUeWck/GcDgFU0hyKHO4LpNX/1CgVifmKKcZPuzHbUGgRUZu+g POCovkXUAy2Tflafw6TOfa2Xx/knyqx+FkvTicI1oujeAr7F2hH4nvpmJ8d6ReXhNKAm x9eGDNF9EPT3wA8hc6SIgQ+gTlYWgRA3PqLGJc0gpSnmao4ReGSaFrok1YokGHpNPvDo Kq6+m9OsYbIlDKqTEnZUuspOgwOGLJz31Z1fPevmlkFIoxaTG+nbcL0vyYxy65vESgI9 xT7A== 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=gKFaHjfObeOoztgwhGaHa0+nmnJnQ0hmuMjk2cnYydo=; b=NZ82VeKjaZ5WPgxNPDcClgw65Y0KT5k4t3Phbg0Hv8Qnybt1ExNQh8lnfegntnbRga +4vajAAdXMkEke0Zxvu1CKgwOBwv6sUH3PKFBkFOhcfIztjZ5gSUh3kGA1Xg9KzGk20p l4TAu0dWdZMlwOW6yxv5I2PeXzp12dMSOFQGHK4vjVFXtrPUOYZAGREP0UvG5u2dSO/U 1T6/qH6J1c4A0EAPR4kHPzw3ppGJwIcwBIIi/X1+GeCdPjR8XkrVDy6HRs1kipEFjZJE fvkYNtRjGRxUlZ4bYo0695xaH0VTX4A9lqiIyfLwdOuCmyiDX/ID1yomc17VYRPVc72h xasQ== X-Gm-Message-State: APf1xPDGy7VdPLkOaL2KQfmmFjHb6fUPCSXYS4JgoAPIGnC8nv0qnZpG ssTw9nGOYMfNUzOzFHM/bWjiVg== X-Google-Smtp-Source: AG47ELvBV5Ea2irvL04doIvWBf3t0+6prKhmB39zsTXN0uXATGNoyI9mC4GLXNKgkl8mYXyA/giNsg== X-Received: by 10.98.28.202 with SMTP id c193mr24358274pfc.109.1520467059997; Wed, 07 Mar 2018 15:57:39 -0800 (PST) Received: from localhost ([12.206.222.5]) by smtp.gmail.com with ESMTPSA id z15sm28480926pgr.68.2018.03.07.15.57.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Mar 2018 15:57:39 -0800 (PST) Subject: [PATCH v3 1/5] irq: Add CONFIG_GENERIC_IRQ_MULTI_HANDLER Date: Wed, 7 Mar 2018 15:57:27 -0800 Message-Id: <20180307235731.22627-2-palmer@sifive.com> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180307235731.22627-1-palmer@sifive.com> References: <20180307235731.22627-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-20180307_155750_981661_F2A14A07 X-CRM114-Status: GOOD ( 20.24 ) 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: Palmer Dabbelt 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_MULTI_IRQ_HANDLER. This patch is currently all dead code, but it will be enabled in the various other architectures in subsequent patches. Signed-off-by: Palmer Dabbelt --- include/linux/irq.h | 18 ++++++++++++++++++ kernel/irq/Kconfig | 5 +++++ kernel/irq/handle.c | 15 +++++++++++++++ 3 files changed, 38 insertions(+) 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..116a6972f124 100644 --- a/kernel/irq/Kconfig +++ b/kernel/irq/Kconfig @@ -132,3 +132,8 @@ config GENERIC_IRQ_DEBUGFS If you don't know what to do here, say N. endmenu + +config GENERIC_IRQ_MULTI_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