Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp133426ybv; Tue, 18 Feb 2020 19:30:33 -0800 (PST) X-Google-Smtp-Source: APXvYqyLgK8EEzEHS3xjXG9mNiAmPooLlVHLWY6mYTkQbf0XjRVnoRdPxQdRotv4tIwwLrsoYUHL X-Received: by 2002:a05:6830:1689:: with SMTP id k9mr19140342otr.311.1582083033671; Tue, 18 Feb 2020 19:30:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582083033; cv=none; d=google.com; s=arc-20160816; b=mPJGkQPzhyuQDQCnhzv8AltYt2UBdtDSZQUA7Bo+sIP4vi671JUys/0ihyr3JxNQds uhDave/ot4PRTvKYjxVCkh0d5UMkJ1PxGBoNkrIeyYwywAhejY0Uuh3uxq0KqnmBD5R7 Lu1rwYzapJ3k/JoNn/KXlRvMJlUUwgsIsSdxYWtjLQf47C54z65CA5akcQni1WCZq68Y cp9n5FaFEMX0j0m9f5ZybbqD7HIXIFd4Y7TKr2qi+Se+33cO19YBib27T9wqJkcIMZvK Zz1xwiE487+BTxve2UCDLhnQI/RnX4KfyAk1PdlIwZrZ8a+av9W58+61pn/icHbZkWxx X5mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=PFrPzzwmpyAD/udwXE359rvjJD5ZEgk+K9aOBrdRGe4=; b=SBHYd2P/EVqy2FI3Ch5yvK7jDxToRs/XdSVKMFy696Z1OQ4ZPvKbkOcr8yc378QJdy l6UlmYJZPTJ81COzxwFqXnXDw0Vv000cHz0ykQa+vvtb7VUJ+iRK41SjHupnn4i/7tTM oTF3O5a2rLSVT08eopidmRmjHxJJe6wp16vuxuWmPexcqvjDH+N9X1RdE2MAIMm2ojcv 7MVD6GIRl6zwQRtZipRrzc3VOTSncMVvA0fcKrS5lJw+yPK8WWo8tv0/wxswCq95F2Oz CGYIGU5s2yaEP8fL7H88q5qDIrF3PTtqvJPRvDG5txQpwvB45B3RFNZ8ej8Ua/TbYski qE8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=ZTcpg9Zv; 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 j70si9688364oib.219.2020.02.18.19.30.21; Tue, 18 Feb 2020 19:30:33 -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=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=ZTcpg9Zv; 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 S1726703AbgBSD2w (ORCPT + 99 others); Tue, 18 Feb 2020 22:28:52 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:36087 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726346AbgBSD2v (ORCPT ); Tue, 18 Feb 2020 22:28:51 -0500 Received: by mail-wm1-f66.google.com with SMTP id p17so5153080wma.1 for ; Tue, 18 Feb 2020 19:28:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=PFrPzzwmpyAD/udwXE359rvjJD5ZEgk+K9aOBrdRGe4=; b=ZTcpg9Zvzm2Ac6+wAF372I1lGI//y+yRBrSU5kW2wA6VNPv3yptFR4gnP4NusurYX5 E0Cyoe8S7d6FO50mtLaC/cDuQY9YtxgAglsLaKO+DuxNfOuBfuWUTfpxOFZn4Cnc39dk zlwhIpXITMnDYQuHmMuU5piaWl2f36nsUSq5cl6kr72sVhr4RZLDzsrHXidZCV9UrBYq seqSSXu1TEksjZLUk2AKA6e7vl7vJL8cfJGP3xLCpsEg+hVjCS0RQczc3Yfot+LKTh96 p7p6ePUP+BwF2yl4uIDAY1g9zyOq1kn9ib/TbSTt1qSMHIgoqNWwT+93OKlkbsyKyqoq WDmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=PFrPzzwmpyAD/udwXE359rvjJD5ZEgk+K9aOBrdRGe4=; b=PVt6F4s9/GDTe+/EoKJmA7rW0mUmMTzfPiib9L944vx/eHpEvyR2lndy4uYzmE48aj gY67yRyoUTnVP7oJFkKr9aPgi+s4p+Z+zZIRJtQrwftmtJgVAhNiOqaQs/3VOmcuUdGU bS8ctIStaGh4F743ECN/V1I21Uvhol1YHyC4sAPXRo8P9Yk6uq87jHEY9yQYcSScWyAf 6dR6+6z1FIHQdnjahcCvF+bKzZYZHBb8QLBWnANQgaTeznn1SeQt8yWE+WySFcKxxPsZ xWXVWftNvYwmTrQTVBeNBK/AKck0uCI1+tUmnt8HJ7ISVxz0ZsZhfXt69O3Pk3xQQ5bW Ok0w== X-Gm-Message-State: APjAAAUrmPlb/+jOoBy6RWGqKbW7Rv8XJVKKthZQWKOPZc0IIbc0p9L2 PclZiB131q8HRlrmq7afnbe3aBaSOJEbHO7yyaLUyg== X-Received: by 2002:a05:600c:285:: with SMTP id 5mr6773557wmk.120.1582082929545; Tue, 18 Feb 2020 19:28:49 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Anup Patel Date: Wed, 19 Feb 2020 08:58:38 +0530 Message-ID: Subject: Re: [PATCH] RISC-V: Don't enable all interrupts in trap_init() To: Palmer Dabbelt Cc: Atish Patra , Anup Patel , Paul Walmsley , Damien Le Moal , "linux-kernel@vger.kernel.org List" , stable@vger.kernel.org, Atish Patra , Alistair Francis , linux-riscv , Christoph Hellwig Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 19, 2020 at 12:06 AM Palmer Dabbelt wrote: > > On Sun, 02 Feb 2020 03:48:18 PST (-0800), atishp@atishpatra.org wrote: > > On Sun, Feb 2, 2020 at 3:06 AM Anup Patel wrote: > >> > >> Historically, we have been enabling all interrupts for each > >> HART in trap_init(). Ideally, we should only enable M-mode > >> interrupts for M-mode kernel and S-mode interrupts for S-mode > >> kernel in trap_init(). > >> > >> Currently, we get suprious S-mode interrupts on Kendryte K210 > >> board running M-mode NO-MMU kernel because we are enabling all > >> interrupts in trap_init(). To fix this, we only enable software > >> and external interrupt in trap_init(). In future, trap_init() > >> will only enable software interrupt and PLIC driver will enable > >> external interrupt using CPU notifiers. > > I think we should add a proper interrupt controller driver for the per-hart > interrupt controllers, as doing this within the other drivers is ugly -- for > example, there's no reason an MMIO timer or interrupt controller driver should > be toggling these bits. I have always been in support of having per-hart interrupt controller driver. I will rebase my RISC-V INTC driver upon latest kernel and send it again. Of course, now the situation has changed the RISC-V INTC driver will have to consider NOMMU kernel as well. The last version of RISC-V INTC driver can be found in riscv_intc_v2 branch of https://github.com/avpatel/linux.git > > >> Cc: stable@vger.kernel.org > >> Fixes: 76d2a0493a17 ("RISC-V: Init and Halt Code) > > I'd argue this actually fixes the M-mode stuff, since that's the first place > this issue shows up. I've queued this with > > Fixes: a4c3733d32a7 ("riscv: abstract out CSR names for supervisor vs machine mode") > > instead, as that's the first commit that will actually write to MIE and > therefor the first commit that will actually exhibit bad behavior. It also has > the advantage of making the patch apply on older trees, which should make life > easier for the stable folks. Sure, no problem. > > >> Signed-off-by: Anup Patel > >> --- > >> arch/riscv/kernel/traps.c | 4 ++-- > >> 1 file changed, 2 insertions(+), 2 deletions(-) > >> > >> diff --git a/arch/riscv/kernel/traps.c b/arch/riscv/kernel/traps.c > >> index f4cad5163bf2..ffb3d94bf0cc 100644 > >> --- a/arch/riscv/kernel/traps.c > >> +++ b/arch/riscv/kernel/traps.c > >> @@ -156,6 +156,6 @@ void __init trap_init(void) > >> csr_write(CSR_SCRATCH, 0); > >> /* Set the exception vector address */ > >> csr_write(CSR_TVEC, &handle_exception); > >> - /* Enable all interrupts */ > >> - csr_write(CSR_IE, -1); > >> + /* Enable interrupts */ > >> + csr_write(CSR_IE, IE_SIE | IE_EIE); > >> } > >> -- > >> 2.17.1 > >> > >> > > > > Looks good. > > Reviewed-by: Atish Patra > > Tested-by: Palmer Dabbelt [QMEU virt machine with SMP] > Reviewed-by: Palmer Dabbelt > > I consider this a bugfix, so I'm targeting it for RCs. It's on fixes and > should go up this week. > > Thanks! Thanks, Anup