Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1348799imm; Sat, 4 Aug 2018 01:24:56 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdHG0UwreyDGfoMPCaigRUAwMccwG3uUUPJvHYiKXfD5SfRj0qoCPqBIZWTrG2sVpmpFls+ X-Received: by 2002:a62:a6db:: with SMTP id r88-v6mr8165435pfl.60.1533371095982; Sat, 04 Aug 2018 01:24:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533371095; cv=none; d=google.com; s=arc-20160816; b=OfxZFNp6OAJaBTWFGQzNt+jrth3fHUww8F2fvFpfKwPJKuWQe9G0qNkfCO7mYfNcyX gvd9877/tYaktVTWMsL4kzOx+mxOR6r0VMtC/FyPx9PMqQVWXFjbAnYeX8WnW3Ds1bcg VWoimto/127R9BK49BkhdMqSs4o+7pt27bTu8XF6T1Wy0d7N5Xh4XjkAgz6g2ejuL7pf lntySopZNJUIuzU2z9OakK4hgrtFz2GGZLjcl/D5/0itmlcbHmuMZm0vfC97NmW2om9b u7FqvcF7agx1rGdq8i8dfn6DXrsbZAUBoHSKFM6bBD6J9Yk3uM7hHQfjZ8UyMCcOiRDB yhyw== 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=KKA+OnlD99HlDXIsN3TVyVlAyXyEK67QZr3NZYI3RbdLP8Hp2cuiBqywwtqj+fc2k4 g4UJc/LIfjPGLL5izchGdJGksnCUH7ohU7xGovhWEhY7cWM4kOKPCCtPv04jjWLTQGXI 3hV6o6zBJQPnJKqtaLN2SaVjJSaoo6bdLUtbwnYyS1OBQGifvULdcGKBNjfRoPRPmLXg c51ShjEQ8CK7z8DlRW6/2FJfMJf5MjoxVsrcEGUWM7nlEo03us7Tf/hKb4f2mnE2tieT klDVryB0uc2rUNr1kf+867awoPy8TU6bfxD4V47MURP0i3z6A46t2R32Ja5C85uRem7i qwjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=n5n1Q4Cy; 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 j11-v6si5126465pll.234.2018.08.04.01.24.41; Sat, 04 Aug 2018 01:24:55 -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=n5n1Q4Cy; 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 S1729060AbeHDKXe (ORCPT + 99 others); Sat, 4 Aug 2018 06:23:34 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:37392 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726055AbeHDKXe (ORCPT ); Sat, 4 Aug 2018 06:23:34 -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=n5n1Q4CypWK1AbLxXcdoRmqQJ 7BXglkB+j8UQ6B5+MEU+F8NI8k4vFVdnGFqPXy/3y3LYyCtyrYxYYgvwFot2E9+sufdTcyrbqw8F8 0SijbLm2AtXiNXDH/7fdIYc2IpGFYOOGa4Qac5M3EIZ+5W2b+Q+i6sSf7w/EnxulLUr09GttExzwJ CumyNZF0uWpQVx+l3bI98gKOf/f1Etmg5dJD8J+RyI7ZkQnnm0UGTr1mNFoG7ACmhFIxtPWDyhj7y 22vi0GV5TyLNustcQD/9vrecVwQ4MvbgYufVVOfT/I+fZxoBlpeTg/4RU2mH1seXw6zDsULmngtUa y7l6nuopg==; Received: from [46.125.249.69] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1flrqc-0003jY-Sh; Sat, 04 Aug 2018 08:23:39 +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 5/8] RISC-V: implement low-level interrupt handling Date: Sat, 4 Aug 2018 10:23:16 +0200 Message-Id: <20180804082319.5711-6-hch@lst.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180804082319.5711-1-hch@lst.de> References: <20180804082319.5711-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