Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp411665pxb; Thu, 21 Oct 2021 01:55:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyI56oQTICPqKYwKzmhaBPvuTlI9BYCRMtkIwjjQcSfzh1KXss0ttvAcCJ6MwD1ZDmHPdDq X-Received: by 2002:a63:db41:: with SMTP id x1mr3429721pgi.474.1634806542099; Thu, 21 Oct 2021 01:55:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634806542; cv=none; d=google.com; s=arc-20160816; b=XL7seaKH5dPjWLqul+FoVsIVWzs/5GixKxoOvI6o+FicGe3UOFblAy8iYzVPMnkKhk pikVlRCpmbD5Rt1jU/clINktcUGkZ0gJqMSOoJyOUfruicbWKoZu4Nqn2jnxNFfaJr6s kMdYW3at91Z0kTu5OUoc9ua3/RNOIdFdOwonk3MEt1gn/s1oSGuBSTeD0xgk1Jtxsd81 8TIHdgqKZOSphWG2Exza/z1zhYRZK0P8TbGIsmmkxneR1zrM2bCVXQgLlu6aXhfxW9sJ bcSB6in5AF1wRDQohvPZO3W+xUKX8Tnp+QY3bT8OV17YgLwi1LlLtX8Is0f0BdSZSn6T F53A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=tGw01pNXJUufCrr4acIUk3r0qyL+eWaqqb1eza62Y9o=; b=eZb7mepnn0ZgIGCjT/79qhTYQAjn1uqS6ohqf3hxDfrZVnaF454fb+o5p068UUBMbi uEx1tSLj1T3BOMt2mi/dnKGIxq1ofpt8ldM1C9ROWGLv2u4ESMK7PcSY6Ak3qp4kaiRj iQDNIxmHmP/+1qtM+CvffYS4ucSR39xl5Zqx3LG7hqxxQsCu7U2zy5miOy6mM/zPs9/O Nf9fwnK+6J9vjKnRd19gQBAzdsQNq2Vo5Jo399+TjmfCeodba2fmkeqrfTsajVVTm3co L4pEqbCH+XIb8EMr8GNh4H+ngiIxLx1usl5HO1BtKm43gToLeJtPbhtqirrbH3Sm561r /oJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20210112.gappssmtp.com header.s=20210112 header.b=nyNMrCzR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h2si7029949plf.219.2021.10.21.01.55.24; Thu, 21 Oct 2021 01:55:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@brainfault-org.20210112.gappssmtp.com header.s=20210112 header.b=nyNMrCzR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231153AbhJUIzH (ORCPT + 99 others); Thu, 21 Oct 2021 04:55:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231560AbhJUIyo (ORCPT ); Thu, 21 Oct 2021 04:54:44 -0400 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AA91C061765 for ; Thu, 21 Oct 2021 01:52:28 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id r10so844352wra.12 for ; Thu, 21 Oct 2021 01:52:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=tGw01pNXJUufCrr4acIUk3r0qyL+eWaqqb1eza62Y9o=; b=nyNMrCzRilIzJNfoYZK1SkOHJcOoZzmVG37b5O1KzvTx0SYRYGXPWnje00xg2XFOOy o3hEXMvRkIr8gaRI2O+VpECQ2q6zMzK46HaXNfUtrdCNFH3NJ6prA5M//JPHgGXUbG8i 2CbnORwx0W4IZamOhgZGIQjJNoIUEXCrTJj/mCzsVBZvm3zUs2UF9q4SYMNeE4K8POXn 1Q47Kc/IC1fMZo6JKhn2o6S10tXcTqzFaLJXIEI1RzriLtZ7nccDyJRegU4cFlox8fx8 h5jlmIRVOvGsGX50MXxmeUieAGcQDLgamtf4XkBV0L48j1+cTPpztv3b7MUvaD0B0va9 t/fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=tGw01pNXJUufCrr4acIUk3r0qyL+eWaqqb1eza62Y9o=; b=hRbx1y71hzzj6B6LjnzDe9TJnKw1o/ruoaJMODwpA8+QYdb2j/xazPztwECyfeOEpD kO6OPpZb2zeqji8jSoAE25IIiPiNZ2EhlXMRGprbnShFTLTnvgbkeR6d1ViORvCJSgi+ hW969c5rSQSUOfKzLCapSzUeXTEFuSnVGLOTI9/XpZS8s4dpnBmsvjk5ckRLqChAN7eR MX4aTn1HrhtlGNLkKCbXmUULzelLA3mw0D3byPW9EEitpNdqFBH0emN59wVxUhTVPbWJ Hmp22nLbF8crshKbQL36mg+RhIECKmucCyUsmS1Kks0+gl/XPG8bXzsZlJdnaV/Fg8at kVew== X-Gm-Message-State: AOAM5306mrDuvHEn5dsYMqQk0ltWzy7wKvFbuSHQ78FikOXLfh4kV57o vuJAF+cl7VADeCPzrsNEIpQaCJlFQwrABh0vSTz3SA== X-Received: by 2002:a5d:614d:: with SMTP id y13mr1672261wrt.199.1634806346598; Thu, 21 Oct 2021 01:52:26 -0700 (PDT) MIME-Version: 1.0 References: <20211016032200.2869998-1-guoren@kernel.org> <20211016032200.2869998-2-guoren@kernel.org> <8be1bdbd-365d-cd28-79d7-b924908f9e39@sholland.org> <8735oxuxlq.wl-maz@kernel.org> <875ytrddma.wl-maz@kernel.org> <871r4fd996.wl-maz@kernel.org> <87y26nbq1l.wl-maz@kernel.org> In-Reply-To: <87y26nbq1l.wl-maz@kernel.org> From: Anup Patel Date: Thu, 21 Oct 2021 14:22:15 +0530 Message-ID: Subject: Re: [PATCH V4 1/3] irqchip/sifive-plic: Add thead,c900-plic support To: Marc Zyngier Cc: Guo Ren , Samuel Holland , Atish Patra , Thomas Gleixner , Palmer Dabbelt , =?UTF-8?Q?Heiko_St=C3=BCbner?= , Rob Herring , Linux Kernel Mailing List , linux-riscv , Guo Ren Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 20, 2021 at 10:18 PM Marc Zyngier wrote: > > On Wed, 20 Oct 2021 17:08:36 +0100, > Anup Patel wrote: > > > > On Wed, Oct 20, 2021 at 8:38 PM Marc Zyngier wrote: > > > > > > On Wed, 20 Oct 2021 15:33:49 +0100, > > > Anup Patel wrote: > > > > > > > > On Wed, Oct 20, 2021 at 7:04 PM Marc Zyngier wrote: > > > > > > > > > > On Tue, 19 Oct 2021 14:27:02 +0100, > > > > > Guo Ren wrote: > > > > > > > > > > > > On Tue, Oct 19, 2021 at 6:18 PM Marc Zyngier wrote: > > > > > > > > > > > > > > On Tue, 19 Oct 2021 10:33:49 +0100, > > > > > > > Guo Ren wrote: > > > > > > > > > > > > > > > > If you have an 'automask' behavior and yet the HW doesn't record this > > > > > > > > > in a separate bit, then you need to track this by yourself in the > > > > > > > > > irq_eoi() callback instead. I guess that you would skip the write to > > > > > > > > > the CLAIM register in this case, though I have no idea whether this > > > > > > > > > breaks > > > > > > > > > the HW interrupt state or not. > > > > > > > > The problem is when enable bit is 0 for that irq_number, > > > > > > > > "writel(d->hwirq, handler->hart_base + CONTEXT_CLAIM)" wouldn't affect > > > > > > > > the hw state machine. Then this irq would enter in ack state and no > > > > > > > > continues irqs could come in. > > > > > > > > > > > > > > Really? This means that you cannot mask an interrupt while it is being > > > > > > > handled? How great... > > > > > > If the completion ID does not match an interrupt source that is > > > > > > currently enabled for the target, the completion is silently ignored. > > > > > > So, C9xx completion depends on enable-bit. > > > > > > > > > > Is that what the PLIC spec says? Or what your implementation does? I > > > > > can understand that one implementation would be broken, but if the > > > > > PLIC architecture itself is broken, that's far more concerning. > > > > > > > > Yes, we are dealing with a broken/non-compliant PLIC > > > > implementation. > > > > > > > > The RISC-V PLIC spec defines a very different behaviour for the > > > > interrupt claim (i.e. readl(claim)) and interrupt completion (i.e. > > > > writel(claim)). The T-HEAD PLIC implementation does things > > > > different from what the RISC-V PLIC spec says because it will > > > > mask an interrupt upon interrupt claim whereas PLIC spec says > > > > it should only clear the interrupt pending bit (not mask the interrupt). > > > > > > > > Quoting interrupt claim process (chapter 9) from PLIC spec: > > > > "The PLIC can perform an interrupt claim by reading the claim/complete > > > > register, which returns the ID of the highest priority pending interrupt or > > > > zero if there is no pending interrupt. A successful claim will also atomically > > > > clear the corresponding pending bit on the interrupt source." > > > > > > > > Refer, https://github.com/riscv/riscv-plic-spec/blob/master/riscv-plic.adoc > > > > > > That's not the point I'm making. According to Guo, the PLIC (any > > > implementation of it) will ignore a write to claim on a masked > > > interrupt. > > > > Yes, write to claim on a masked interrupt is certainly ignored but > > read to claim does not automatically mask the interrupt. > > > > > > > > If that's indeed correct, then a sequence such as: > > > > > > (1) irq = read(claim) > > > > This will return highest priority pending interrupt and clear the > > pending bit as-per RISC-V PLIC spec. > > > > > (2) mask from the interrupt handler with the right flags so that it > > > isn't done lazily > > > (3) write(irq, claim) > > > > > > will result in an interrupt blocked in ack state (and probably no more > > > interrupt for this CPU at this priority). That would be an interesting > > > bug in the current code, but also a pretty bad architectural choice. > > > > The interrupt claim/completion is for each interrupt and not at CPU > > level so if an interrupt is masked then only that interrupt is blocked > > for all CPUs but other interrupts can still be raised. > > Do you mean that another interrupt of the same priority will be able > to be taken on *this* CPU, despite the completion being silently > ignored? This part is not clear in the RISC-V PLIC spec so I will request for adding clarification. Regards, Anup > > M. > > -- > Without deviation from the norm, progress is not possible.