From mboxrd@z Thu Jan 1 00:00:00 1970 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 EB695C2BBCA for ; Tue, 25 Jun 2024 08:45:47 +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-Type:MIME-Version: References:In-Reply-To:Subject:Cc:To:From:Message-ID:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=jR2cjbywcP+30sxWsnITn7N4EcWEAUwtL17UfRM5zT4=; b=hkdXOegna5FPHp2Q/0twEShgJd sYZKYaABHDEkBWno+Gsi0xr5ur5lJiMrA/C0WlbMLXAqsiY3buIg+/oldH+XkBqtSWrRZSKrIRRiP nLlxFyf8uXT07ETR04dFsU/mog4d2KSg+cqONF9QvewZMI9BjIcDSESF8Nrk8PExlLeCyN9F2ZZv+ ydAcLSrKOFcINXqdECj24SODQh9sJKnFjVaoXSvc5Z03JqGGKeRizTv7XMmTEnGOZIWEkA2D132L4 WMIup5yw2mXnDOWQlsj4P85AGSquMuSLaqbEV+IQvpWn/2t2k/z5jmmc58QGoEXeiM9jV2dLCOUmX 8WnWEgyw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM1o1-000000029uB-0EDb; Tue, 25 Jun 2024 08:45:37 +0000 Received: from sin.source.kernel.org ([145.40.73.55]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM1nv-000000029sk-1Oh1 for linux-arm-kernel@lists.infradead.org; Tue, 25 Jun 2024 08:45:33 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id BB90ECE19B4; Tue, 25 Jun 2024 08:45:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 53173C4AF0B; Tue, 25 Jun 2024 08:45:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719305126; bh=eI9Erle9UcKxqH2WkzFZglnfw0o+JeSD4gtyn2dU42o=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=tPRWSPgM6GX6upuePGBCzptdgPI2BZ128lg0GkgecbL+jqDOc4iul6oDf6MK3S6nk K71bF+LGJe1y71z19LaTlgTJ9ANHt1JFJ8swNLvtqBGKvJG77SiL3UsvjKNnwSVDCB Gxo8cdVIaOtx4UcBhu7+753wXenL0aanp2mRxfZKvypNFfL6dqo45GtYYAv5vq/7/o 4p8zyM8CB9HzL8+QjEBJ+gwAD64ybtRVgHqcHt7q6AGgz3LjS7/WUOkhBvuxgPm+mY oMYZcTyEb6DLyu4U97Ap//yT89Dbp7j6JmXjoakzgAkWhiozw3W+FtRLZGIUUHg9V0 tgwkjogD4xyBw== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1sM1nn-0075QY-V6; Tue, 25 Jun 2024 09:45:24 +0100 Date: Tue, 25 Jun 2024 09:45:22 +0100 Message-ID: <86v81xif6l.wl-maz@kernel.org> From: Marc Zyngier To: Roman Kagan Cc: , Catalin Marinas , Will Deacon , , , , Thomas Gleixner , Jonathan Corbet Subject: Re: [PATCH] irqchip/gicv3-its: Workaround for GIC-700 erratum 2195890 In-Reply-To: <20240624165541.1286227-1-rkagan@amazon.de> References: <20240624165541.1286227-1-rkagan@amazon.de> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/29.2 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: rkagan@amazon.de, linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com, will@kernel.org, nh-open-source@amazon.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, tglx@linutronix.de, corbet@lwn.net X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240625_014531_759196_65C8D409 X-CRM114-Status: GOOD ( 40.98 ) 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 On Mon, 24 Jun 2024 17:55:41 +0100, Roman Kagan wrote: > > 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. Please add a link to the errata document. > > 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. The errata document says a lot more: For physical LPIs the workaround is to issue an INV using GICR_INVLPIR to an unused, in range LPI ID to retrigger the search. This could be done periodically, for example, in line with a residency change, or as part of servicing LPIs. If using LPIs as the event, then the GICR_INVLPIR write could be issued after servicing every LPI. However, it only needs to be issued if: * At least 4 interrupts in the block of 32 are enabled and mapped to the current PE or, if easier, * At least 4 interrupts in the block of 32 are enabled and mapped to any PE > > TT: https://t.corp.amazon.com/D82032616 Gniii???? > Signed-off-by: Elad Rosner > Signed-off-by: Mohamed Mediouni > Signed-off-by: Roman Kagan Who is the author? > --- > 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 Use MSEC_PER_SEC. > +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) { The errata document doesn't say that this need to happen for *every* RD. Can you please clarify this? > + 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); Don't split assignments. > + 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); No synchronisation? How is that supposed to work? Also, if you need to dig into the internals of the driver, extract a helper from __direct_lpi_inv(). > + } > + > + schedule_delayed_work(&its_quirk_gic700_2195890_data.work, > + msecs_to_jiffies(ITS_QUIRK_GIC700_2195890_PERIOD_MSEC)); It would be pretty easy to detect whether an LPI was ack'ed since the last pass, and not issue the invalidate. > +} > + > +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; > +} It is a bit odd to hook this on an ITS being probed when the ITS isn't really involved. Not a big deal, but a bit clumsy. > + > 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, This catches r0p0 and r1p0, but not r0p1 (you require that bits 15:12 are 0). Overall, this requires a bit of rework. Notably, this could be significantly relaxed to match the requirements of the published workaround. Thanks, M. -- Without deviation from the norm, progress is not possible.