Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2005221imm; Thu, 2 Aug 2018 04:52:11 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcWewqQdo2Hj8aHUELfACg8b6kdWOA9QH1V5Xbgn19wyXYyTIht47Z8XlzyKneUu+PueaWE X-Received: by 2002:a17:902:6845:: with SMTP id f5-v6mr2077209pln.173.1533210731666; Thu, 02 Aug 2018 04:52:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533210731; cv=none; d=google.com; s=arc-20160816; b=H03Y21+Bnh/ngqwH5USmiXL6gEluP8TDlXlw+GS7LY+JykQ4mg5Y+MYl4ULeIghOps N0Jdk+FyYwfpCDIuvhyJdT7+HLVDnFdK7E8I8cLIIkCprVK/ek1LjNSdf3vgyzNb5tPY HG8N7DJlycrmhoLar3iUyLnOxfcc8M2gVtCALNHhQMF4ckPoW/U0WFq/8/GBMTvaYtDI gQlxBv0ar7XYeqpnExbUjoa/5sCS9u9aAdIMZr5ser50/da/7NvpXZR9GQwwJNz0cFIw Kgh0nG8rFAM9or9qpIkbLmIC0KXJLozd5/EvOtZamYcuBtVr/T1fv9Wsj+GnBVpNI5kb 3M8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=Y9L6sVyCND3pCUBTkFzMbfyGpy1+MFBmetZ8xMn3P9k=; b=HH7xcKukZy2F1dskYHH0EiDId6r8H6gz0gAXoRDBn0DNpg4XVxBSIQniBB8xLCi6zt sLlrzQnbRZaZfGcVcMsxhJia1fRFzrXQdBQVGXIlHhNgFGzlCxl0N37BBihDER5cKTMS YRV2OEyInAM/AAGUnf0El5E4p222WqYqOsIznvwFpalzzfyRA1hfTp4f0+bXsu1rOkoi BjEj5p1xyzhJjVqv1jg3zps0cVeMAAbS7A4Jjlig9ldBNnwVZWAu9/HFQUnKXG4qvIdp 0wKeoKQ5WlbKeHYneIQ0g8yNnD34qxPPGlD/LXG0JKcR5gVS0claW4IgfQLxeZg2iwJW SP6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b="INUHIF/U"; 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 u4-v6si1931545pgm.454.2018.08.02.04.51.57; Thu, 02 Aug 2018 04:52:11 -0700 (PDT) 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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b="INUHIF/U"; 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 S1732459AbeHBNli (ORCPT + 99 others); Thu, 2 Aug 2018 09:41:38 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:39724 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732252AbeHBNli (ORCPT ); Thu, 2 Aug 2018 09:41:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Y9L6sVyCND3pCUBTkFzMbfyGpy1+MFBmetZ8xMn3P9k=; b=INUHIF/UCO44sb8nkIGMJWbm0 +PsGUotYdtRu48laXUoG+h7nr25WGU1X3f0okR2MjXVBsT2dq91zL1/GYIW9SHp7fCWgtne7cmVRk 3rYn9CO77GHg6Ifh0GLWYgL86nK3gjAZo1crmbHbi35G96GL12Ut1+n5TShXGi8JLq1qTi/0gWaC1 uvllvk6TweMNTjDNnhXlHeRRWjG1n8O97HP+jXym6wAfDO/afLlq2K4fYwlscYQmq54e9EDFKqiQ4 9jwPSYuzNsyyomxU+1nyTRFqts+XbcxTx3GnH2tIk9wl2SwSq2znrI8gTEpQXaneZqcCaLZZbmEPF T4ZYM0hng==; Received: from clnet-p19-102.ikbnet.co.at ([83.175.77.102] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1flC7v-0005QI-Vt; Thu, 02 Aug 2018 11:50:45 +0000 From: Christoph Hellwig To: tglx@linutronix.de, palmer@sifive.com, jason@lakedaemon.net, marc.zyngier@arm.com, robh+dt@kernel.org, mark.rutland@arm.com Cc: anup@brainfault.org, atish.patra@wdc.com, devicetree@vger.kernel.org, aou@eecs.berkeley.edu, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, shorne@gmail.com Subject: [PATCH 08/11] RISC-V: implement low-level interrupt handling Date: Thu, 2 Aug 2018 13:50:05 +0200 Message-Id: <20180802115008.4031-9-hch@lst.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180802115008.4031-1-hch@lst.de> References: <20180802115008.4031-1-hch@lst.de> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add support for a routine that dispatches exceptions with the interrupt flags set to either the IPI or irqdomain code (and the clock source in the future). Loosely based on the irq-riscv-int.c irqchip driver from the RISC-V tree. Signed-off-by: Christoph Hellwig --- arch/riscv/kernel/entry.S | 4 +-- arch/riscv/kernel/irq.c | 52 ++++++++++++++++++++++++++++++++------- 2 files changed, 45 insertions(+), 11 deletions(-) diff --git a/arch/riscv/kernel/entry.S b/arch/riscv/kernel/entry.S index 9aaf6c986771..fa2c08e3c05e 100644 --- a/arch/riscv/kernel/entry.S +++ b/arch/riscv/kernel/entry.S @@ -168,8 +168,8 @@ ENTRY(handle_exception) /* Handle interrupts */ move a0, sp /* pt_regs */ - REG_L a1, handle_arch_irq - jr a1 + move a1, s4 /* scause */ + tail do_IRQ 1: /* Exceptions run with interrupts enabled */ csrs sstatus, SR_SIE diff --git a/arch/riscv/kernel/irq.c b/arch/riscv/kernel/irq.c index 7bcdaed15703..ab5f3e22c7cc 100644 --- a/arch/riscv/kernel/irq.c +++ b/arch/riscv/kernel/irq.c @@ -1,21 +1,55 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) 2012 Regents of the University of California * Copyright (C) 2017 SiFive - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation, version 2. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * Copyright (C) 2018 Christoph Hellwig */ #include #include #include +/* + * Possible interrupt causes: + */ +#define INTERRUPT_CAUSE_SOFTWARE 1 +#define INTERRUPT_CAUSE_TIMER 5 +#define INTERRUPT_CAUSE_EXTERNAL 9 + +/* + * The high order bit of the trap cause register is always set for + * interrupts, which allows us to differentiate them from exceptions + * quickly. The INTERRUPT_CAUSE_* macros don't contain that bit, so we + * need to mask it off. + */ +#define INTERRUPT_CAUSE_FLAG (1UL << (__riscv_xlen - 1)) + +asmlinkage void __irq_entry do_IRQ(struct pt_regs *regs, unsigned long cause) +{ + struct pt_regs *old_regs = set_irq_regs(regs); + + irq_enter(); + switch (cause & ~INTERRUPT_CAUSE_FLAG) { +#ifdef CONFIG_SMP + case INTERRUPT_CAUSE_SOFTWARE: + /* + * We only use software interrupts to pass IPIs, so if a non-SMP + * system gets one, then we don't know what to do. + */ + riscv_software_interrupt(); + break; +#endif + case INTERRUPT_CAUSE_EXTERNAL: + handle_arch_irq(regs); + break; + default: + panic("unexpected interrupt cause"); + } + irq_exit(); + + set_irq_regs(old_regs); +} + void __init init_IRQ(void) { irqchip_init(); -- 2.18.0