Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1444686pxb; Thu, 28 Oct 2021 03:57:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvNjYSzw+kxP8oFD7fnweJN5nuFJ8eBAFsZRiPye7Rhe1CmN7/dqye9rahzvta94JxFwTx X-Received: by 2002:a17:902:7892:b0:140:283:6683 with SMTP id q18-20020a170902789200b0014002836683mr3023429pll.19.1635418664945; Thu, 28 Oct 2021 03:57:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635418664; cv=none; d=google.com; s=arc-20160816; b=HQdD1/O9scly+6kuXxw4DIoRO6cxMrAU/tlOyZHT4r28UMMy8Sa+Ebl7M0+z5KTvgk 6xyxk4IjZcmQJlfiCqJm/bmQHy65t//nQZ1kFyyDctwR9clAx8PPmU6JxSozTCE26q0v bQteN3hGDJ89VepT3POwN2vONqZ6XAtL5iUchfcGMsR++lpHII/enhEu6uDK4xuYXAgw YdAbG0+j77GfbrhSgtdVF9z5bkSiDHEJH/Q34Sq84GXF2chPIiexvDcsnX/hFyxeUscO fknydDEX+zdPWHyNCEyoSKkXVDYCSWMhXVjs/U4D0+iHfnVjp8KK63wVzkKybeXoWTuZ LtSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=udSJvaxIUlBbTSQoZiMCrwbkjTdE+UC73DQGiSmy6yc=; b=nMBR01DUsQVh970Ng1CgL9vNMBF5vlt72rfyRDspcw4QAWW5ff5SvCi8T9wV0Vjhiv /uD/NL0K3ShEdA8By62sd0Wy27TznZaogvoIYoieEeFfKsNlWerkotDVoz2KkMft9Ixx 18rREKhimBLzDQz8PdOgA3OWUy0Zorfy4kJnuOKcJ733gkbfufPT3LNVc1O5n/qCDgL2 NzaQMPllGWn5axjemeM66PPv2hUu9E3YjFNN4jFnpE3wbSKcpRkQtuJ4rV/lud15N/Wv nBZ4eJQx2E+a6ooK4EfiG+46WR2wUb25OEks4mkHiFjT2tgTx9JcU/LI3TD9LoMpC9zV MMzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@maquefel.me header.s=mail header.b=THXEc31z; 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 t6si8961382pjw.58.2021.10.28.03.57.32; Thu, 28 Oct 2021 03:57:44 -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=@maquefel.me header.s=mail header.b=THXEc31z; 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 S230222AbhJ1K57 (ORCPT + 99 others); Thu, 28 Oct 2021 06:57:59 -0400 Received: from forward500o.mail.yandex.net ([37.140.190.195]:32998 "EHLO forward500o.mail.yandex.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230157AbhJ1K56 (ORCPT ); Thu, 28 Oct 2021 06:57:58 -0400 Received: from sas1-900f78e25d27.qloud-c.yandex.net (sas1-900f78e25d27.qloud-c.yandex.net [IPv6:2a02:6b8:c14:39a3:0:640:900f:78e2]) by forward500o.mail.yandex.net (Yandex) with ESMTP id 75611941A89; Thu, 28 Oct 2021 13:55:27 +0300 (MSK) Received: from sas2-1cbd504aaa99.qloud-c.yandex.net (2a02:6b8:c14:7101:0:640:1cbd:504a [2a02:6b8:c14:7101:0:640:1cbd:504a]) by sas1-900f78e25d27.qloud-c.yandex.net (mxback/Yandex) with ESMTP id q8kJzHGsh3-tQEuCcFV; Thu, 28 Oct 2021 13:55:27 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=maquefel.me; s=mail; t=1635418527; bh=udSJvaxIUlBbTSQoZiMCrwbkjTdE+UC73DQGiSmy6yc=; h=In-Reply-To:Subject:To:From:References:Date:Message-ID:Cc; b=THXEc31zi9wOb6+7NfBvXlkD2tPknlqjd7xgVKWeiVyTuX40gC8vCIxLBKmODIJA7 PberpMoWg0C/nwZXbhAKRvowUFdPAs5UKF5f8G6KpReOwoeiHEZeHeleXZSIi+Gfc5 q01QApuCzjGmmdQXl8MsBYgfz8Eg2DSJDMxQKT6g= Authentication-Results: sas1-900f78e25d27.qloud-c.yandex.net; dkim=pass header.i=@maquefel.me Received: by sas2-1cbd504aaa99.qloud-c.yandex.net (smtp/Yandex) with ESMTPS id KNJkzVzdNo-tPJWa7sa; Thu, 28 Oct 2021 13:55:26 +0300 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client certificate not present) X-Yandex-Fwd: 2 Date: Thu, 28 Oct 2021 13:55:23 +0300 From: Nikita Shubin To: Marc Zyngier Cc: guoren@kernel.org, anup@brainfault.org, atish.patra@wdc.com, tglx@linutronix.de, palmer@dabbelt.com, heiko@sntech.de, robh@kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Guo Ren Subject: Re: [PATCH V5 3/3] irqchip/sifive-plic: Fixup thead, c900-plic request_threaded_irq with ONESHOT Message-ID: <20211028135523.5cf4b66b@redslave.neermore.group> In-Reply-To: <87a6ixbcse.wl-maz@kernel.org> References: <20211024013303.3499461-1-guoren@kernel.org> <20211024013303.3499461-4-guoren@kernel.org> <87a6ixbcse.wl-maz@kernel.org> X-Mailer: Claws Mail 3.17.7 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Marc and Guo Ren! On Mon, 25 Oct 2021 11:48:33 +0100 Marc Zyngier wrote: > On Sun, 24 Oct 2021 02:33:03 +0100, > guoren@kernel.org wrote: > > > > From: Guo Ren > > > > When using "devm_request_threaded_irq(,,,,IRQF_ONESHOT,,)" in the > > driver, only the first interrupt could be handled, and continue irq > > is blocked by hw. Because the thead,c900-plic couldn't complete > > masked irq source which has been disabled in enable register. Add > > thead_plic_chip which fix up c906-plic irq source completion > > problem by unmask/mask wrapper. > > > > Here is the description of Interrupt Completion in PLIC spec [1]: > > > > The PLIC signals it has completed executing an interrupt handler by > > writing the interrupt ID it received from the claim to the > > claim/complete register. The PLIC does not check whether the > > completion ID is the same as the last claim ID for that target. If > > the completion ID does not match an interrupt source that is > > currently enabled for the target, the ^^ ^^^^^^^^^ ^^^^^^^ > > completion is silently ignored. > > Given this bit of the spec... > > > +static void plic_thead_irq_eoi(struct irq_data *d) > > +{ > > + struct plic_handler *handler = > > this_cpu_ptr(&plic_handlers); + > > + if (irqd_irq_masked(d)) { > > + plic_irq_unmask(d); > > + writel(d->hwirq, handler->hart_base + > > CONTEXT_CLAIM); > > + plic_irq_mask(d); > > + } else { > > + writel(d->hwirq, handler->hart_base + > > CONTEXT_CLAIM); > > + } > > +} > > + > > ... it isn't obvious to me why this cannot happen on an SiFive PLIC. This indeed happens with SiFive PLIC. I am currently tinkering with da9063 RTC on SiFive Unmatched, and ALARM irq fires only once. However with changes proposed by Guo Ren in plic_thead_irq_eoi, everything begins to work fine. May be these change should be propagated to plic_irq_eoi instead of making a new function ? > > And it isn't only for threaded interrupts in oneshot mode. Any driver > can mask an interrupt from its handler after having set the > IRQ_DISABLE_UNLAZY flag, and the interrupt would need the exact same > treatment. > > M. > --- diff --git a/drivers/irqchip/irq-sifive-plic.c b/drivers/irqchip/irq-sifive-plic.c index cf74cfa82045..259065d271ef 100644 --- a/drivers/irqchip/irq-sifive-plic.c +++ b/drivers/irqchip/irq-sifive-plic.c @@ -163,7 +163,13 @@ static void plic_irq_eoi(struct irq_data *d) { struct plic_handler *handler = this_cpu_ptr(&plic_handlers); - writel(d->hwirq, handler->hart_base + CONTEXT_CLAIM); + if (irqd_irq_masked(d)) { + plic_irq_unmask(d); + writel(d->hwirq, handler->hart_base + CONTEXT_CLAIM); + plic_irq_mask(d); + } else { + writel(d->hwirq, handler->hart_base + CONTEXT_CLAIM); + } } static struct irq_chip plic_chip = {