From patchwork Mon Feb 19 14:08:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 203120 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp1305055dyc; Mon, 19 Feb 2024 06:08:36 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXIEkjQOO2ZD7mD9pWVuo4Ie82iIRsheAQnqlE1hEtWzZWRaXPq9WHlBzZq8jop7dzmEDNj1cnR71QE++oT2NHlBnvstg== X-Google-Smtp-Source: AGHT+IE0rpdQC/yGy9bz2h/unFE8v4EsNHpp5zfN6qaEnqQKFVnnirycxfcsgsjLcSEMMl6bJhDz X-Received: by 2002:aa7:c655:0:b0:563:8b25:1659 with SMTP id z21-20020aa7c655000000b005638b251659mr8733736edr.28.1708351716289; Mon, 19 Feb 2024 06:08:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708351716; cv=pass; d=google.com; s=arc-20160816; b=sUhC2p8+dpTpbzGrrbnzMLUQk8oG4V3xO9YNvqgphJzwXrnZxP9Wfa5FN69iM3i9AW Sc/36oLzjQe3rz1jy2gYmP++RxcFtT6G+JH6nqeGdrwoSaDRcdZlOaRUt5LGOnSDWtS9 88HlIVT8CQscAWazkgjHiHhNSQDkTAzuETayFNd7IOLsiKeSbPdXtYzsHf85TMo8CbJD G4j7Mdxu7hVCJSDqJPYbYFu1RW92Wmh5T8Lf0YWviUZnJnH8swEcbQOqAuwNcZ9IR3Ma pjjjsPyrtUg6Dgo1C71v4yRnPE20l4h3jpQbBpeFcg148YBjTx/bjYa03uAiw8W06m7Z NmpA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:precedence:robot-unsubscribe:robot-id :message-id:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:in-reply-to:cc:subject:to:reply-to:sender :from:dkim-signature:dkim-signature:date; bh=LJ15QQb5lo2AdR2SG9y6GMsXz1qi6IFa/UGCYP+exNg=; fh=jpPKxku0PrPGaHAPsjmm5qOvp2tFH+U8+rxPC2c4RRo=; b=iyX+k19blrXWAHOGc3Uu7R84+R8F5+7u3cvUMCh/ymuAvrV/ixnGSbDwQEfGg2rN4i SUqlNQKjhxmSE7F8XuUnr1FFLLj1bElgR8r3JcgAGf1mOWA5KAAkf7WAev0iyhCLbjvu ugVmJHoW/IIW1EBuOdXw+qmFizJzGpZpVADpj5TIXPic5HQT1YDba4SciCSZ9o3Tlui+ 2l/tj0PMKcE289c9L6/XNFsThqXHWWs+clgBqt719jnN7ruBFwlbuy3HDOXGb+5G3puf LMf7CQQGVAkahClc6B6Wd4OOuMksjpDzzZgmz/tK7+eZwxrL4o8uoCCiB4i6SXDafAWw v7eg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=FZfwf83y; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-71455-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71455-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id b25-20020aa7df99000000b00564703ff732si991380edy.494.2024.02.19.06.08.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 06:08:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71455-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=FZfwf83y; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-71455-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71455-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id E1F551F24953 for ; Mon, 19 Feb 2024 14:08:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 98A86374F2; Mon, 19 Feb 2024 14:08:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="FZfwf83y"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="FLn437Wb" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 29117360BA; Mon, 19 Feb 2024 14:08:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708351702; cv=none; b=Zed1I12rCJHiVO2+rFEix9pydc/rgTF95Y6z2OM4YvOixFeUnnAoNxl4w6hXrtxJErh/8XFi/0TZrdqQdTHjXrYwy9ANPkZdTbacqHvouGPSS9duN9uvI/sjdXw+iG3tC9t5RPNFXwHKsLQ35Qlo2g8vaxSq5yXHXuOypaMEgN4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708351702; c=relaxed/simple; bh=O2I250bObo2NNSE+4ut1WpJK2Pce7ig8kJIKAPvMElQ=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=sc1HYt1730ja6Jz8yHwmEOOSJ1/BCwCEjCEhw7uiaZLtRIf68RmSmDRERxI22HQb+1p81CYaxu2hQqLwzmBJJLWZ/qL1h3BEU7AxxA3HqoiJ2h34WgimjRjei21SRZj+0kGGIE028+3BjDuBOB9dZMBFDlVN9dxTxEE4Apy64pY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=FZfwf83y; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=FLn437Wb; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Date: Mon, 19 Feb 2024 14:08:17 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1708351698; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LJ15QQb5lo2AdR2SG9y6GMsXz1qi6IFa/UGCYP+exNg=; b=FZfwf83ypHWycWhnl4ZxH7XYiUmcCenQUZR9KawYT32E8UjI+XWSlkK8pKC72dN2w5EJQq Mt9G0rQueYHfNnh4ZXHCHRXihwkq0sH9lJNLnGXCdf6NH4Jgta84ZI4RICFR3Fzct3ex9M F8uKn9K9V0sK/rJi6ZpnStCScTzfrEWZRmHU+26OCbZ/MVqaHANMacx2GMWB0JfLjs3DJz M6U2boMSWtVD/EKeT11hryFWEjdMxc/pQClA4eY3xeq83e1lSajp2/2mLYRZig16bOlHrx DnFIBnznLFiC+GyCi6VT3PoypMzqk6si1MdssFko7IRIK57gPxLxEHZ85FvQWw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1708351698; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LJ15QQb5lo2AdR2SG9y6GMsXz1qi6IFa/UGCYP+exNg=; b=FLn437WbpgpmXhCwoGJ3NCl1iPy98mW0NLwsqiJPr3q79WUfGDT4avqYpn95+XXhQLNimV eT1nOG6ukxTkekBg== From: "tip-bot2 for Nam Cao" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: irq/urgent] irqchip/sifive-plic: Enable interrupt if needed before EOI Cc: Nam Cao , Thomas Gleixner , Palmer Dabbelt , Paul Walmsley , Samuel Holland , Marc Zyngier , Guo Ren , linux-riscv@lists.infradead.org, , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20240131081933.144512-1-namcao@linutronix.de> References: <20240131081933.144512-1-namcao@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <170835169709.398.11515115809265577283.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791336609321299855 X-GMAIL-MSGID: 1791336609321299855 The following commit has been merged into the irq/urgent branch of tip: Commit-ID: 9c92006b896c767218aabe8947b62026a571cfd0 Gitweb: https://git.kernel.org/tip/9c92006b896c767218aabe8947b62026a571cfd0 Author: Nam Cao AuthorDate: Wed, 31 Jan 2024 09:19:33 +01:00 Committer: Thomas Gleixner CommitterDate: Mon, 19 Feb 2024 15:05:18 +01:00 irqchip/sifive-plic: Enable interrupt if needed before EOI RISC-V PLIC cannot "end-of-interrupt" (EOI) disabled interrupts, as explained in the description of Interrupt Completion in the PLIC spec: "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." Commit 69ea463021be ("irqchip/sifive-plic: Fixup EOI failed when masked") ensured that EOI is successful by enabling interrupt first, before EOI. Commit a1706a1c5062 ("irqchip/sifive-plic: Separate the enable and mask operations") removed the interrupt enabling code from the previous commit, because it assumes that interrupt should already be enabled at the point of EOI. However, this is incorrect: there is a window after a hart claiming an interrupt and before irq_desc->lock getting acquired, interrupt can be disabled during this window. Thus, EOI can be invoked while the interrupt is disabled, effectively nullify this EOI. This results in the interrupt never gets asserted again, and the device who uses this interrupt appears frozen. Make sure that interrupt is really enabled before EOI. Fixes: a1706a1c5062 ("irqchip/sifive-plic: Separate the enable and mask operations") Signed-off-by: Nam Cao Signed-off-by: Thomas Gleixner Cc: Palmer Dabbelt Cc: Paul Walmsley Cc: Samuel Holland Cc: Marc Zyngier Cc: Guo Ren Cc: linux-riscv@lists.infradead.org Cc: Link: https://lore.kernel.org/r/20240131081933.144512-1-namcao@linutronix.de --- drivers/irqchip/irq-sifive-plic.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/irqchip/irq-sifive-plic.c b/drivers/irqchip/irq-sifive-plic.c index 5b7bc4f..bf0b40b 100644 --- a/drivers/irqchip/irq-sifive-plic.c +++ b/drivers/irqchip/irq-sifive-plic.c @@ -148,7 +148,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 (unlikely(irqd_irq_disabled(d))) { + plic_toggle(handler, d->hwirq, 1); + writel(d->hwirq, handler->hart_base + CONTEXT_CLAIM); + plic_toggle(handler, d->hwirq, 0); + } else { + writel(d->hwirq, handler->hart_base + CONTEXT_CLAIM); + } } #ifdef CONFIG_SMP