Received: by 10.223.148.5 with SMTP id 5csp7699718wrq; Thu, 18 Jan 2018 08:30:22 -0800 (PST) X-Google-Smtp-Source: ACJfBosrbAPyBr50ybjtqtDGT6LX9NV3eyKHD0faKB5MNAnY1ix3XYeKuEnS0saNqNE/RBaGo6mA X-Received: by 10.101.81.7 with SMTP id f7mr38205180pgq.447.1516293022132; Thu, 18 Jan 2018 08:30:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516293022; cv=none; d=google.com; s=arc-20160816; b=W6tw1uo/zgM3dseqPbe79pcVE6SBZ8tDfB9q7SjcfeBHOspkEJePdC36RSP7IA4eTH TsV3t77wtIZZ/TehR4ynmGo1Q8aV2Tq0vSE+CeqoSMXVJVG9hvQkAbr/AgjBn4Y6vGOB 24Tq4OfnNzKgDSS+DAp8T2YgABTHeXSg1hq2ENbXrjl2cjlFoBv6SXiZl8komgNkNCgU mWzKJPljoQVyhqaRVW3PA4MbVPp5/Ow+P8pEE9yInwVgkI1A9e2mtYt6+UbnHUSA/zyH JNOgKHVsbaHrqezsSPF9B74ndqGtwfl3HW7aAzohN5nE3CSQzV1xQyTgDOat1Dy3es3L 1EpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:from:cc:references:in-reply-to :message-id:date:subject:dkim-signature:arc-authentication-results; bh=gdR831jZEnhHiHDNmkiJVw1MXFc7eghSmYFBSY5jUSo=; b=eNceadqyBzzxA0Lq7DLrZktUEWmTWLbt0ObhfTeDFBL1Zp8dfnjw5jElG+xKCxASQx /RUrTnE1wMRjgmWyVEz6jnOLTJDjc46d308TJjIsfMjZpqjraJz4Y8eDpnDh7cSnLk0r tBoP5tQNciQoLMAd7ugsfc/yEsu7Ta5mtBNePnEB5T2mwO7qIBKWnMqwAXl4qUO1gvhk TYjiUN+i6nAxO8ZmSyA90juxZBiKgqxKR758zsW9svIH/6EaPbmsLGUTDdBVT+8XIOX4 pj8O8E5Swb3I5FPRVAsreRM19se+fD8onMzdjgZGercydK4UssM8W/89YsWgyKbZGD8x MsXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=Lt4DKw/N; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u26si2541955pge.210.2018.01.18.08.30.07; Thu, 18 Jan 2018 08:30:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=Lt4DKw/N; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755826AbeARQKd (ORCPT + 99 others); Thu, 18 Jan 2018 11:10:33 -0500 Received: from mail-pg0-f68.google.com ([74.125.83.68]:46689 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933218AbeARQK3 (ORCPT ); Thu, 18 Jan 2018 11:10:29 -0500 Received: by mail-pg0-f68.google.com with SMTP id s9so12794722pgq.13 for ; Thu, 18 Jan 2018 08:10:29 -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=gdR831jZEnhHiHDNmkiJVw1MXFc7eghSmYFBSY5jUSo=; b=Lt4DKw/NP4ACv3TBdJ3MOz1+AIylE2Xu/lmb2NTyRCFI820UCxRtJtnd255VVqew70 0kvHPinZTIxJmasuk2ylolirs0bGyakx5YDMawPk+GtJ0KwEFnoZTLCrvNDc0kzJYPYx XXze8qBug9vbUB50axSndrDzF8FFD8FoTYHSkKECDVsYcV+5vLh5HdFUWoqcfxPZWH9H 8OkIWWbgg9vJv6rV8SyFRJheFVuN9euSabsYIE8V/Qzs/dOqRElKNbTUme1Lku758jkS fsvb7cuTUnXJZdNsop66BEKdaiESlPfx2re9BX/mybApUxsyVFeJYF5l0EOJDqYUuN7/ 0diw== 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=gdR831jZEnhHiHDNmkiJVw1MXFc7eghSmYFBSY5jUSo=; b=aCQ/laY18vuDxvPj540EOTxjNTh1Yrj2eA8Zui1PeNJJDjKMiahE67px46QPVc1SWu yT9Yk3AEyqRMVqGQmkFxSZtwRR5nk76tOGjziCoaJQ9Pk3w9rv8NLnvwuma/UTGmF/d4 /DfBDnlne5pxvvzv5AsMOcnIXw1BmlryitsSgP5Kn7ZQJMK0CZ/BmuMObbP+ewDti51y VPVyNcSIDCIJ+dyKI5OcN2yHQOXfWkUiexRq4LfG4c7nEnEL2jNq6JCWVESljzXLIysv LkwnovYyTmtKC+ptKshrL9TbfOCqSvC2a2srztmo1GFQHhH+9vLorLT9coz4JuWoStx3 sHLQ== X-Gm-Message-State: AKwxytdXZX44TZ6pig0u5DH2LxbrPbFgigA0Z8gnMOgmMfGfz/r+5lrt nQ5je/rpi58f2okTrpYRoX3NwhVB9XE= X-Received: by 10.101.81.141 with SMTP id h13mr22115351pgq.241.1516290064185; Thu, 18 Jan 2018 07:41:04 -0800 (PST) Received: from localhost ([12.206.222.5]) by smtp.gmail.com with ESMTPSA id y19sm10797881pgv.19.2018.01.18.07.41.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Jan 2018 07:41:03 -0800 (PST) Subject: [PATCH 1/2] asm-generic: Add a generic set_handle_irq Date: Thu, 18 Jan 2018 07:40:04 -0800 Message-Id: <20180118154005.24994-2-palmer@sifive.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180118154005.24994-1-palmer@sifive.com> References: <20180118154005.24994-1-palmer@sifive.com> Cc: patches@groups.riscv.org, Palmer Dabbelt From: Palmer Dabbelt To: Arnd Bergmann , Christoph Hellwig , linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Palmer Dabbelt I've copied this from arm64, but it appears to be the same code that's in arm and openrisc. I wanted to use it for RISC-V's interrupt handler as well, so despite this only being a handful of lines of code it seems worth having a generic version -- if it existed when we created our interrupt controller then maybe we would have just started with the generic version. This patch alone is just dead code, further patches actually use this infrastructure. Signed-off-by: Palmer Dabbelt --- include/asm-generic/handle_irq.h | 28 ++++++++++++++++++++++++++++ lib/Kconfig | 3 +++ lib/Makefile | 2 ++ lib/handle_irq.c | 26 ++++++++++++++++++++++++++ 4 files changed, 59 insertions(+) create mode 100644 include/asm-generic/handle_irq.h create mode 100644 lib/handle_irq.c diff --git a/include/asm-generic/handle_irq.h b/include/asm-generic/handle_irq.h new file mode 100644 index 000000000000..2865fa12993a --- /dev/null +++ b/include/asm-generic/handle_irq.h @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 1992 Linus Torvalds + * Modifications for ARM processor Copyright (C) 1995-2000 Russell King. + * Support for Dynamic Tick Timer Copyright (C) 2004-2005 Nokia Corporation. + * Dynamic Tick Timer written by Tony Lindgren and + * Tuukka Tikkanen . + * Copyright (C) 2012 ARM Ltd. + * Copyright (C) 2017 SiFive, Inc + */ + +#ifndef __ASM_GENERIC_IRQ_HANDLER_H +#define __ASM_GENERIC_IRQ_HANDLER_H + +#include +#include + +/* + * 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 *)); + +#endif diff --git a/lib/Kconfig b/lib/Kconfig index c5e84fbcb30b..c74469d44fdc 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -601,3 +601,6 @@ config GENERIC_CMPDI2 config GENERIC_UCMPDI2 bool + +config GENERIC_HANDLE_IRQ + bool diff --git a/lib/Makefile b/lib/Makefile index d11c48ec8ffd..57ae58fde821 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -258,3 +258,5 @@ obj-$(CONFIG_GENERIC_LSHRDI3) += lshrdi3.o obj-$(CONFIG_GENERIC_MULDI3) += muldi3.o obj-$(CONFIG_GENERIC_CMPDI2) += cmpdi2.o obj-$(CONFIG_GENERIC_UCMPDI2) += ucmpdi2.o + +obj-$(CONFIG_GENERIC_HANDLE_IRQ) += handle_irq.o diff --git a/lib/handle_irq.c b/lib/handle_irq.c new file mode 100644 index 000000000000..e732147537f4 --- /dev/null +++ b/lib/handle_irq.c @@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 1992 Linus Torvalds + * Modifications for ARM processor Copyright (C) 1995-2000 Russell King. + * Support for Dynamic Tick Timer Copyright (C) 2004-2005 Nokia Corporation. + * Dynamic Tick Timer written by Tony Lindgren and + * Tuukka Tikkanen . + * Copyright (C) 2012 ARM Ltd. + * Copyright (C) 2017 SiFive, Inc + */ + +#include + +void (*handle_arch_irq)(struct pt_regs *) = NULL; + +int __init set_handle_irq(void (*handle_irq)(struct pt_regs *)) +{ + if (!handle_arch_irq) + handle_arch_irq = handle_irq; + + if (handle_arch_irq != handle_irq) + return -EBUSY; + + return 0; +} + -- 2.13.6