Received: by 2002:a05:7412:9c07:b0:fa:6e18:a558 with SMTP id lr7csp152831rdb; Sat, 27 Jan 2024 00:31:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IFJ2HjyO+0UR875mplS/DX/bP/23UGg3FUyj4BFU9I+JPh6gVHYnWYY+QxhZqGu1yPaOCgA X-Received: by 2002:ac8:5bc8:0:b0:42a:958d:c5d9 with SMTP id b8-20020ac85bc8000000b0042a958dc5d9mr67625qtb.126.1706344288453; Sat, 27 Jan 2024 00:31:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706344288; cv=pass; d=google.com; s=arc-20160816; b=qXZG4bsRtp3efz2ilEtqOvKs/LUkCwyLl4XUUZlMvY1rOG7JakR+fjkeJ99J6Bh6mY +0AL2x2HS5XY/f8OaFh9fV10n0ghIBMmGj5WQ/nwIFgYDtLECXeIpnMnKuWXQgLC/rRJ lpHW6e3IU6tK1yq1NG9uLlv4LybA/d0350np2kiAVoTpghAx6nFWUG/f2vsEu7PePElw wsMcT/888fMsgl0wZJc96S0Z0mRb2LyOU91KI/xhuFQNLBWxu3QNO8D+L9/auvnSLGUZ tYAYJfZ6qbNsOqgq3vb56y50G4MGWESDEzEGjXpEZiBy9q8zj2W8PmMJd1/rBRzCA8F4 RqhA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:dkim-signature:dkim-signature:date; bh=3I7OJx5NKf289xrERaDLT1wF8RTcX1Wk/OCiBAc6Gtk=; fh=hWaIzUluuU4dzxRdMQiz4abHhwoAcf6DBWgVPD7eeT8=; b=A6dQrBUzVCl3WFEayWkh6Zd13hdT2Ulh1dL/S/UwVvTVWnMtatCJ1qW9xQKTv9dM8P DJrp129X+nvu4G7QRmaTsi4Ukms29IuW1Yq+kEA9UapGWpKKC32/82EYz9qs7JFyZEnh RxGZjMuCTn1talxaOPOwlKOQktp3bQBdLrSpxJmahZ4fSlygmt5of7lSfR8b87Ff3wjv gYkeQBE3qqI9m4RnaHFjCq1XvLue36nvJQedqTsR98JNCyu0vrN0D2FV+Z1y6fPprYIL MMoL5USO5i9n8aW7kblT8lOqEBWLu/k2Oo/hUqLlX3UDxZZSwueFAe5B9fg9FmanRUz3 WRoA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=18TQg4Vn; 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-41114-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-41114-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id u30-20020a05622a199e00b0042a94ea60c8si141305qtc.315.2024.01.27.00.31.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Jan 2024 00:31:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-41114-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=18TQg4Vn; 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-41114-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-41114-linux.lists.archive=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 1952E1C2200B for ; Sat, 27 Jan 2024 08:31:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 459111DFCD; Sat, 27 Jan 2024 08:31:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="18TQg4Vn"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="K28Qz48W" 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 BEFE51DDEE; Sat, 27 Jan 2024 08:31:18 +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=1706344280; cv=none; b=a9H1XxjhjP7BKV1tXz++1J63XLe7xHDZa8YxnZTDDtZux6fqbTk+7isDVivjlbqSYzwL0jReSRH62MleEWI+yNAZQcjrw4K/wmHDN7N1kAPujOO4NaR4hvA8PLcg0xG/bKsApTrEAnS0OaPL+CM//wpqxkTc3tMK1g6Sm6agzw4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706344280; c=relaxed/simple; bh=3y97SIJ5xBgVxKMWNJIJ4rLGMAWGOZ3UhyjMU+C2pOU=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Zwc7v2ch8b4voG5mEAw1pUYckhGXXhMfIn5QvV86itIoaLigTw9/TdQHZ4TWgi6JZH/HFtylbM3dJok3YppQFNJ5zBU3TgaPloPBgKhVkn55EiDG6/LsAJXg5T3vS7as87mhUhfX14r2nZSsusPm0ZSyKLw1sKg2wAo7GKt/nNg= 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=18TQg4Vn; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=K28Qz48W; 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: Sat, 27 Jan 2024 09:31:14 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1706344276; h=from:from: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=3I7OJx5NKf289xrERaDLT1wF8RTcX1Wk/OCiBAc6Gtk=; b=18TQg4VnhdAfpujoCis6XXFumAyQY/XA4yICkWbb8vFFLH1DAB1sUTpd8YxIZiAbHbedvo e21QAAwnfmPI6/9+CAm/Xn9JCufaTiu0L0Ob10PBY4smQ6xRQMUIY9YQhbbpZsXsHLG2mD ca1lTz46zkXyMOKoTEhpyR1YGxqPy9Czcp3e9eFiXHvevjuuA11qI62KsROng/er8ga+VP y5H/7VcGB4LMPq4oEEl8Ji0lE0ysdaJecx0NXX4yiOXXMpxm+kUJv51CJ7q8fEAafZpM1Z VMsSktzNAQA4BD4tEtoscvEnEDiIqUadyL/Y1z6d0xQ7C0pGKWKX8yD+0/y2Lw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1706344276; h=from:from: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=3I7OJx5NKf289xrERaDLT1wF8RTcX1Wk/OCiBAc6Gtk=; b=K28Qz48WNcKWSyoQpS/7SybGS3TJtuhaR0/z7bCQ1I/ZdbIBYQJeoXyRKLl4neQzlsKB+H GmpthLsy0/QJZ5Dw== From: Nam Cao To: Samuel Holland Cc: Thomas Gleixner , Palmer Dabbelt , Paul Walmsley , Samuel Holland , Marc Zyngier , linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Guo Ren , stable@vger.kernel.org Subject: Re: [PATCH] irqchip/sifive-plic: enable interrupt if needed before EOI Message-ID: <20240127093114.15fdfa5c@namcao> In-Reply-To: <071142d9-3644-4c62-a99d-40b55bf64406@sifive.com> References: <20240126223836.202321-1-namcao@linutronix.de> <071142d9-3644-4c62-a99d-40b55bf64406@sifive.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Fri, 26 Jan 2024 18:31:19 -0600 Samuel Holland wrote: > On 2024-01-26 4:38 PM, Nam Cao wrote: > > RISC-V PLIC cannot 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 by enabling the interrupt if needed 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 be enabled at the point > > of EOI. However, this is incorrect: there is a small 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. > > > > Make sure that interrupt is really enabled before EOI. > > Could you please try the patch I previously sent for this issue[1]? Unfortunately my system still gets frozen with the patch applied :( I think because the patch doesn't prevent plic_irq_shutdown() from getting called after the hart claiming the interrupt and before irq_desc is locked up. > It should fix the bug without complicating the IRQ hot path. I can add an unlikely() to help that a bit, because from my experience, it is quite rare that EOI happens with interrupt disabled. Best regards, Nam