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 D29C7C2BBCA for ; Tue, 25 Jun 2024 13:55:05 +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:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:CC:To:From: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=oGCfWHyy2ugxDFebpY3wrACjPmfk419vbwqJZjgreDg=; b=D0colYhSWcO0A6JxebVVSPbj6d cToDbzFJcRAh/E0Uqw+nql3OVJLubfRu2EgWG4Lvno82bbmgfHoIpEiZemM8LgVbY0qtZ3TaQN93o qQoHjhIMOl1RXhOJ+Vsh6X5qPdxlTctKs2CcfuRmO6HepPP7OK5uFT8lsq26s0olomQluN+B1ZDZm 99zPrmIX0bIrNjZd3i1ls8GL6e0/bGJZxtzSc/crds2y5ZX5vjakq/GfR7lmvyJyRvw/bmoQiJfI9 o5+QS0ojFuNQIgOOUw3rTjuuh0Bdp3YqueiKA6Vz8l293W4aoT6MDcNc5y2/njQrPvtAl7lEzCbPK bC0pqXUw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM6dI-000000034V5-2lJh; Tue, 25 Jun 2024 13:54:52 +0000 Received: from smtp-fw-2101.amazon.com ([72.21.196.25]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM6dC-000000034SU-0EJr for linux-arm-kernel@lists.infradead.org; Tue, 25 Jun 2024 13:54:47 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1719323687; x=1750859687; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=oGCfWHyy2ugxDFebpY3wrACjPmfk419vbwqJZjgreDg=; b=cJYcvvu+21w4B92gcANFTKpnzwWlgYKMvTU+EYc13Bl1p4Ze5ReGYeYO geEviw9c28b+j7RMAh3h1ATc3bRICWvtoiM9SFUzdxKXls8vB/ROjLT5R gArII5uPq3Lnwh20Qu3tstLh+kOhZwOf6aCwvkbuUrZjggxU4ameyYXAn E=; X-IronPort-AV: E=Sophos;i="6.08,264,1712620800"; d="scan'208";a="410016268" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO smtpout.prod.us-west-2.prod.farcaster.email.amazon.dev) ([10.43.8.6]) by smtp-border-fw-2101.iad2.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jun 2024 13:54:42 +0000 Received: from EX19MTAEUA001.ant.amazon.com [10.0.17.79:57826] by smtpin.naws.eu-west-1.prod.farcaster.email.amazon.dev [10.0.41.15:2525] with esmtp (Farcaster) id 5e7838ba-3b35-4f22-af46-8afabcdb3ea2; Tue, 25 Jun 2024 13:54:40 +0000 (UTC) X-Farcaster-Flow-ID: 5e7838ba-3b35-4f22-af46-8afabcdb3ea2 Received: from EX19D033EUC004.ant.amazon.com (10.252.61.133) by EX19MTAEUA001.ant.amazon.com (10.252.50.192) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.34; Tue, 25 Jun 2024 13:54:37 +0000 Received: from u40bc5e070a0153.ant.amazon.com (10.106.82.20) by EX19D033EUC004.ant.amazon.com (10.252.61.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.34; Tue, 25 Jun 2024 13:54:34 +0000 Date: Tue, 25 Jun 2024 15:54:28 +0200 From: Roman Kagan To: Marc Zyngier CC: , Catalin Marinas , Will Deacon , , , , Thomas Gleixner , Jonathan Corbet Subject: Re: [PATCH] irqchip/gicv3-its: Workaround for GIC-700 erratum 2195890 Message-ID: Mail-Followup-To: Roman Kagan , Marc Zyngier , linux-arm-kernel@lists.infradead.org, Catalin Marinas , Will Deacon , nh-open-source@amazon.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Thomas Gleixner , Jonathan Corbet References: <20240624165541.1286227-1-rkagan@amazon.de> <86v81xif6l.wl-maz@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <86v81xif6l.wl-maz@kernel.org> X-Originating-IP: [10.106.82.20] X-ClientProxiedBy: EX19D038UWB001.ant.amazon.com (10.13.139.148) To EX19D033EUC004.ant.amazon.com (10.252.61.133) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240625_065446_349486_310C0CA7 X-CRM114-Status: GOOD ( 41.51 ) 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 Tue, Jun 25, 2024 at 09:45:22AM +0100, Marc Zyngier wrote: > 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. https://developer.arm.com/documentation/SDEN-1769194/ Will include when respinning. > > > > 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 > It didn't feel like worth optimizing for. I'll reconsider. > > TT: https://t.corp.amazon.com/D82032616 > > Gniii???? Indeed Q-/ > > Signed-off-by: Elad Rosner > > Signed-off-by: Mohamed Mediouni > > Signed-off-by: Roman Kagan > > Who is the author? Joint effort aka inherited ownership. Will fix according to the process doc. > > +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? (Digging out a year-old comms with ARM) > > In multi-chip GIC system, does this write have to happen in each > > chip or would a write to a single GICR trigger the search in all > > GICDs? > The write needs to occur for each physical PE - in other words, to > each individual GICR that the search needs to be re-triggered for. > > + 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(). ACK > > + } > > + > > + 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. Makes sense, will look into it. Overall, do you think this approach with a global work looping over cpus is the right one, or we should better try and implement something per-cpu? > > +} > > + > > +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. True, but the LPI allocation lives in this file so it looked easier to wire it all up here. Where do you think it's more appropriate? > > 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). Ouch, right. Given the erratum exact wording > Fault Status: Present in: r0p0, r0p1, r1p0 Fixed in: r2p0 I guess I should match everything below r2p0 and allow arbitrary bits 15:12 (i.e. set the third nibble in the mask to 0). > Overall, this requires a bit of rework. Notably, this could be > significantly relaxed to match the requirements of the published > workaround. Thanks for the propmpt review! Will rework and respin. Roman. Amazon Web Services Development Center Germany GmbH Krausenstr. 38 10117 Berlin Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss Eingetragen am Amtsgericht Charlottenburg unter HRB 257764 B Sitz: Berlin Ust-ID: DE 365 538 597