Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2287067iof; Wed, 8 Jun 2022 01:28:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+y21vuZJskFmTlcLuTjYbHvyZzPp2rW82Gd23UDZ0HQwraOABlp/PlfpAiLpCflxrju7X X-Received: by 2002:a17:90b:390c:b0:1e2:d499:8899 with SMTP id ob12-20020a17090b390c00b001e2d4998899mr58137173pjb.161.1654676923797; Wed, 08 Jun 2022 01:28:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654676923; cv=none; d=google.com; s=arc-20160816; b=I1e02QNE0JQUAtPTKDYMWl3ShFowusFq8m8tj44ViecWLpPkOUjjhGhiL+UFrdE1Q0 c3GbCGZAWG4+ulKLiWxgdrDFX3jE1JOV2hJRxJMlWHHu2gIRlozOjfrlZzUep4KPIwi0 lS3uLMJSXnRhmHgbdHbriIqtoNqbyeQfbuA9wFiy1o+ML5qsoojppgATAVfSnBrmpZBu MM+mrblhruAeEywbwOIsJ5GE61GxzhkFW5o4zcrj5QMdwuglo733sa/LFCsIwi1NoJmf Y7crF6pHblGBxh4GfDwKvCyg+EoqI6bPKxnQSSMmvlj2Zld7YqWQXBDHPMB7RgA+FU14 DOWQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=VPwbB9C1Bg2LTnU+YjRUyOZOdpHy4RzhVhBj7TFRQ9s=; b=gbEHhflskhAWWpOy7kQJMifI+haZe2Ya0h3HElfv6pCsdRNeTgZrjZIp7qgOoMQaA/ cGgvuQNLltH2W+JuIPBuo01GSofBuFQgrdgqF+Mq2lnatJ8t3ftAadVgz/Rm+eWfFELH /Ojma5Gx3RRssWRouH/t2P5qrFUTSXSQWuCVhWl2JM/lrYyUynuKOCitT4hrVVOEJk6J v3mxv9iUvHGc0aRbpPyt4g8lLNpreHWe7RtzLaLpVFswEVSj4YMapCdrILq5PuJ9MA8g nvXCTyS0XobyG368OgJvSqxC1bZRH8LuN23Ci2mv/Gb0VDPoXCgeox7P+MAxtyhKNOYO q59w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BqKxSava; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id 7-20020a621707000000b005184f87b172si23539067pfx.268.2022.06.08.01.28.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 01:28:43 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BqKxSava; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 29572EE8DF; Wed, 8 Jun 2022 00:57:53 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354772AbiFGS4p (ORCPT + 99 others); Tue, 7 Jun 2022 14:56:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352412AbiFGSRI (ORCPT ); Tue, 7 Jun 2022 14:17:08 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD54123BFB; Tue, 7 Jun 2022 10:51:55 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 7859BB8233E; Tue, 7 Jun 2022 17:51:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D7433C385A5; Tue, 7 Jun 2022 17:51:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654624313; bh=bdTf4FTALcawS8wv1YqA5rcTqD7jngUd2l9/EAtZxqQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BqKxSavaaQIzx3LPWgPQZO6HU60sJXPBUpm620ndKQJZxgtYBUIGsSQKAsVS4jAsx 1+ihRp7sS4k5BK2yBUmpVMQr9xW2n4Wxb9v9GKD/XI9SFAAj99bPfv7Zp3eCnGRRZ3 0SPeO7DN0naUHQmbXAUnTgWiKlo0zHNCzOJ0CTog= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daniel Thompson , Ard Biesheuvel , Marc Zyngier , Sasha Levin Subject: [PATCH 5.15 282/667] irqchip/exiu: Fix acknowledgment of edge triggered interrupts Date: Tue, 7 Jun 2022 18:59:07 +0200 Message-Id: <20220607164943.241495557@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607164934.766888869@linuxfoundation.org> References: <20220607164934.766888869@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Daniel Thompson [ Upstream commit 4efc851c36e389f7ed432edac0149acc5f94b0c7 ] Currently the EXIU uses the fasteoi interrupt flow that is configured by it's parent (irq-gic-v3.c). With this flow the only chance to clear the interrupt request happens during .irq_eoi() and (obviously) this happens after the interrupt handler has run. EXIU requires edge triggered interrupts to be acked prior to interrupt handling. Without this we risk incorrect interrupt dismissal when a new interrupt is delivered after the handler reads and acknowledges the peripheral but before the irq_eoi() takes place. Fix this by clearing the interrupt request from .irq_ack() if we are configured for edge triggered interrupts. This requires adopting the fasteoi-ack flow instead of the fasteoi to ensure the ack gets called. These changes have been tested using the power button on a Developerbox/SC2A11 combined with some hackery in gpio-keys so I can play with the different trigger mode [and an mdelay(500) so I can can check what happens on a double click in both modes]. Fixes: 706cffc1b912 ("irqchip/exiu: Add support for Socionext Synquacer EXIU controller") Signed-off-by: Daniel Thompson Reviewed-by: Ard Biesheuvel Signed-off-by: Marc Zyngier Link: https://lore.kernel.org/r/20220503134541.2566457-1-daniel.thompson@linaro.org Signed-off-by: Sasha Levin --- arch/arm64/Kconfig.platforms | 1 + drivers/irqchip/irq-sni-exiu.c | 25 ++++++++++++++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/arch/arm64/Kconfig.platforms b/arch/arm64/Kconfig.platforms index b0ce18d4cc98..d7772a4c34fe 100644 --- a/arch/arm64/Kconfig.platforms +++ b/arch/arm64/Kconfig.platforms @@ -259,6 +259,7 @@ config ARCH_INTEL_SOCFPGA config ARCH_SYNQUACER bool "Socionext SynQuacer SoC Family" + select IRQ_FASTEOI_HIERARCHY_HANDLERS config ARCH_TEGRA bool "NVIDIA Tegra SoC Family" diff --git a/drivers/irqchip/irq-sni-exiu.c b/drivers/irqchip/irq-sni-exiu.c index abd011fcecf4..c7db617e1a2f 100644 --- a/drivers/irqchip/irq-sni-exiu.c +++ b/drivers/irqchip/irq-sni-exiu.c @@ -37,11 +37,26 @@ struct exiu_irq_data { u32 spi_base; }; -static void exiu_irq_eoi(struct irq_data *d) +static void exiu_irq_ack(struct irq_data *d) { struct exiu_irq_data *data = irq_data_get_irq_chip_data(d); writel(BIT(d->hwirq), data->base + EIREQCLR); +} + +static void exiu_irq_eoi(struct irq_data *d) +{ + struct exiu_irq_data *data = irq_data_get_irq_chip_data(d); + + /* + * Level triggered interrupts are latched and must be cleared during + * EOI or the interrupt will be jammed on. Of course if a level + * triggered interrupt is still asserted then the write will not clear + * the interrupt. + */ + if (irqd_is_level_type(d)) + writel(BIT(d->hwirq), data->base + EIREQCLR); + irq_chip_eoi_parent(d); } @@ -91,10 +106,13 @@ static int exiu_irq_set_type(struct irq_data *d, unsigned int type) writel_relaxed(val, data->base + EILVL); val = readl_relaxed(data->base + EIEDG); - if (type == IRQ_TYPE_LEVEL_LOW || type == IRQ_TYPE_LEVEL_HIGH) + if (type == IRQ_TYPE_LEVEL_LOW || type == IRQ_TYPE_LEVEL_HIGH) { val &= ~BIT(d->hwirq); - else + irq_set_handler_locked(d, handle_fasteoi_irq); + } else { val |= BIT(d->hwirq); + irq_set_handler_locked(d, handle_fasteoi_ack_irq); + } writel_relaxed(val, data->base + EIEDG); writel_relaxed(BIT(d->hwirq), data->base + EIREQCLR); @@ -104,6 +122,7 @@ static int exiu_irq_set_type(struct irq_data *d, unsigned int type) static struct irq_chip exiu_irq_chip = { .name = "EXIU", + .irq_ack = exiu_irq_ack, .irq_eoi = exiu_irq_eoi, .irq_enable = exiu_irq_enable, .irq_mask = exiu_irq_mask, -- 2.35.1