From patchwork Mon Jun 24 16:55:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kagan, Roman" X-Patchwork-Id: 13709903 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3C6C1C2BD09 for ; Mon, 24 Jun 2024 16:56:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=48rl6/jKAgjYmkDLF+VIhQW39kVTmSUknBkn3WlF1ZU=; b=c5cw58jEOPjyfTLVRLmo6Kin0+ Tz4tmwyn3d8REV1UqMFf4uKB9vmPUHkRTdWD2cFzTLjT2YEJlgBIMeRpT6cH1FcHwlpWmK9fGLEXZ BpYY5Kwli7MgL86WaJAeDGFJpwxM2DuEAvSCmAu7L89FfSkgLLfL/ni0TV2gMbcqA5nTaEARLRLdc tsRxQ/MRy0dRfkk2gusBUjjv8xymV14DWtGBxRFzsW/OclHu0s1XaM2EHkduJldc0tw0rpAFrBHAp uTEhAH1FDzjly9MqfmmMEzVzthVa6umdfyrgB69ZM/S8dAl4zIcLjz9t808RJpeNAT29Sl5EwcQAb JQ4nu2qQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sLmz7-000000000cQ-34fz; Mon, 24 Jun 2024 16:56:05 +0000 Received: from smtp-fw-6002.amazon.com ([52.95.49.90]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sLmz2-000000000al-0w5U for linux-arm-kernel@lists.infradead.org; Mon, 24 Jun 2024 16:56:02 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1719248160; x=1750784160; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=48rl6/jKAgjYmkDLF+VIhQW39kVTmSUknBkn3WlF1ZU=; b=I4Le/xgJIr6kF74Zrz7MHsqGgiFOTFSb2iiyEP0qyyFkUJDcprsR/DH3 AKUrI4mk5hv+TcS2nZyFmei+7d4mu7kPAoPHNOvYATBuJYKEd4vQ62pZ2 +HVqpAqvj0oHQVCdDbLlSFOX2yEo0lorLaoLkATRpoSmqak31RSjmg2p1 M=; X-IronPort-AV: E=Sophos;i="6.08,262,1712620800"; d="scan'208";a="415421077" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO smtpout.prod.us-east-1.prod.farcaster.email.amazon.dev) ([10.43.8.6]) by smtp-border-fw-6002.iad6.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jun 2024 16:55:50 +0000 Received: from EX19MTAUEB002.ant.amazon.com [10.0.0.204:21076] by smtpin.naws.us-east-1.prod.farcaster.email.amazon.dev [10.0.83.127:2525] with esmtp (Farcaster) id a9289de7-95f6-4105-81ec-4161d19e73db; Mon, 24 Jun 2024 16:55:49 +0000 (UTC) X-Farcaster-Flow-ID: a9289de7-95f6-4105-81ec-4161d19e73db Received: from EX19MTAUEB001.ant.amazon.com (10.252.135.108) by EX19MTAUEB002.ant.amazon.com (10.252.135.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.34; Mon, 24 Jun 2024 16:55:44 +0000 Received: from u40bc5e070a0153.ant.amazon.com (10.106.82.9) by mail-relay.amazon.com (10.252.135.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.34 via Frontend Transport; Mon, 24 Jun 2024 16:55:42 +0000 From: Roman Kagan To: CC: Catalin Marinas , Will Deacon , , , , Thomas Gleixner , Jonathan Corbet , Marc Zyngier Subject: [PATCH] irqchip/gicv3-its: Workaround for GIC-700 erratum 2195890 Date: Mon, 24 Jun 2024 18:55:41 +0200 Message-ID: <20240624165541.1286227-1-rkagan@amazon.de> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240624_095600_606161_F4A26233 X-CRM114-Status: GOOD ( 22.61 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org According to Arm CoreLink GIC-700 erratum 2195890, on GIC revisions r0p0, r0p1, r1p0 under certain conditions LPIs may remain in the Pending Table until one of a number of external events occurs. No LPIs are lost but they may not be delivered in a finite time. The workaround is to issue an INV using GICR_INVLPIR to an unused, in range LPI ID to retrigger the search. Add this workaround to the quirk table. When the quirk is applicable, carve out one LPI ID from the available range and run periodic work to do INV to it, in order to prevent GIC from stalling. TT: https://t.corp.amazon.com/D82032616 Signed-off-by: Elad Rosner Signed-off-by: Mohamed Mediouni Signed-off-by: Roman Kagan --- drivers/irqchip/irq-gic-v3-its.c | 70 ++++++++++++++++++++- Documentation/arch/arm64/silicon-errata.rst | 2 + arch/arm64/Kconfig | 18 ++++++ 3 files changed, 89 insertions(+), 1 deletion(-) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 3c755d5dad6e..53cf50dd8e13 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -49,6 +50,7 @@ #define RD_LOCAL_MEMRESERVE_DONE BIT(2) static u32 lpi_id_bits; +static u32 lpi_id_base __initdata = 8192; /* * We allocate memory for PROPBASE to cover 2 ^ lpi_id_bits LPIs to @@ -2136,7 +2138,7 @@ static int __init its_lpi_init(u32 id_bits) * Initializing the allocator is just the same as freeing the * full range of LPIs. */ - err = free_lpi_range(8192, lpis); + err = free_lpi_range(lpi_id_base, lpis - lpi_id_base + 8192); pr_debug("ITS: Allocator initialized for %u LPIs\n", lpis); return err; } @@ -4763,6 +4765,61 @@ static bool its_set_non_coherent(void *data) return true; } +#define ITS_QUIRK_GIC700_2195890_PERIOD_MSEC 1000 +static struct { + u32 lpi; + struct delayed_work work; +} its_quirk_gic700_2195890_data __maybe_unused; + +static void __maybe_unused its_quirk_gic700_2195890_work_handler(struct work_struct *work) +{ + int cpu; + void __iomem *rdbase; + u64 gicr_invlpir_val; + + for_each_online_cpu(cpu) { + rdbase = gic_data_rdist_cpu(cpu)->rd_base; + if (!rdbase) { + continue; + } + + /* + * Prod the respective GIC with an INV for an otherwise unused + * LPI. This is only to resume the stalled processing, so + * there's no need to wait for invalidation to complete. + */ + gicr_invlpir_val = + FIELD_PREP(GICR_INVLPIR_INTID, + its_quirk_gic700_2195890_data.lpi); + raw_spin_lock(&gic_data_rdist_cpu(cpu)->rd_lock); + gic_write_lpir(gicr_invlpir_val, rdbase + GICR_INVLPIR); + raw_spin_unlock(&gic_data_rdist_cpu(cpu)->rd_lock); + } + + schedule_delayed_work(&its_quirk_gic700_2195890_data.work, + msecs_to_jiffies(ITS_QUIRK_GIC700_2195890_PERIOD_MSEC)); +} + +static bool __maybe_unused its_enable_quirk_gic700_2195890(void *data) +{ + struct its_node *its = data; + + if (its_quirk_gic700_2195890_data.lpi) + return true; + + /* + * Use one LPI INTID from the start of the LPI range for GIC prodding, + * and make it unavailable for regular LPI use later. + */ + its_quirk_gic700_2195890_data.lpi = lpi_id_base++; + + INIT_DELAYED_WORK(&its_quirk_gic700_2195890_data.work, + its_quirk_gic700_2195890_work_handler); + schedule_delayed_work(&its_quirk_gic700_2195890_data.work, 0); + + return true; +} + static const struct gic_quirk its_quirks[] = { #ifdef CONFIG_CAVIUM_ERRATUM_22375 { @@ -4822,6 +4879,17 @@ static const struct gic_quirk its_quirks[] = { .property = "dma-noncoherent", .init = its_set_non_coherent, }, +#ifdef CONFIG_ARM64_ERRATUM_2195890 + { + .desc = "ITS: GIC-700 erratum 2195890", + /* + * Applies to r0p0, r0p1, r1p0: iidr_var(bits 16..19) == 0 or 1 + */ + .iidr = 0x0400043b, + .mask = 0xfffeffff, + .init = its_enable_quirk_gic700_2195890, + }, +#endif { } }; diff --git a/Documentation/arch/arm64/silicon-errata.rst b/Documentation/arch/arm64/silicon-errata.rst index eb8af8032c31..67445075ae88 100644 --- a/Documentation/arch/arm64/silicon-errata.rst +++ b/Documentation/arch/arm64/silicon-errata.rst @@ -169,6 +169,8 @@ stable kernels. +----------------+-----------------+-----------------+-----------------------------+ | ARM | GIC-700 | #2941627 | ARM64_ERRATUM_2941627 | +----------------+-----------------+-----------------+-----------------------------+ +| ARM | GIC-700 | #2195890 | ARM64_ERRATUM_2195890 | ++----------------+-----------------+-----------------+-----------------------------+ +----------------+-----------------+-----------------+-----------------------------+ | Broadcom | Brahma-B53 | N/A | ARM64_ERRATUM_845719 | +----------------+-----------------+-----------------+-----------------------------+ diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 5d91259ee7b5..9c330029131c 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -1279,6 +1279,24 @@ config ROCKCHIP_ERRATUM_3588001 If unsure, say Y. +config ARM64_ERRATUM_2195890 + bool "GIC-700: 2195890: LPIs may be held in Pending Table until specific external events happen" + default y + help + This option adds a workaround for Arm GIC-700 erratum 2195890. + + In affected GIC-700 versions (r0p0, r0p1, r1p0) under certain + conditions LPIs may remain in the Pending Table until one of a number + of external events occurs. + + No LPIs are lost and this can happen on physical or virtual PEs but + this erratum means they may not be delivered in a finite time. + + Work around the issue by inserting an INV command for an unused but + valid LPI INTID every so often to retrigger the search. + + If unsure, say Y. + config SOCIONEXT_SYNQUACER_PREITS bool "Socionext Synquacer: Workaround for GICv3 pre-ITS" default y