Received: by 2002:a05:7412:8d11:b0:fa:4934:9f with SMTP id bj17csp471129rdb; Mon, 15 Jan 2024 03:28:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IGnJrgyCU4+QiDK6zcSoQTa2RQAFyjDTMwjzJxqy2wMhBY8bL3emsP+AuOGL4TrcEUHdC5f X-Received: by 2002:a17:906:2ac2:b0:a28:d4eb:4286 with SMTP id m2-20020a1709062ac200b00a28d4eb4286mr2468475eje.109.1705318114155; Mon, 15 Jan 2024 03:28:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705318114; cv=none; d=google.com; s=arc-20160816; b=Jl1EAAd9NdjqCrrb+Ub5fAIj9zRTIWqgsg8ey8U+FPE0Fpupl+oavVMVPevkBCtFHj o2lKT7E7vfNduMRGS0hO6sCqtJ/+AbKwLZcpCwQdX6xXw+DHmr+LY616TBHhoXOYO22D EYsOyCRUoeQgKwdU01yzzNbWGXUNxyHfAzTsGSHAQ44myF18UU5Am6YTIxMe7fV+luBz eIkhIvUGlWYvBirfRM5oamHHPT9MkaXGNzks5gHdLUQPFP6z/U5/KAvZOiM6+hWtzO+5 d8n/idM3Z5u7+eYPjaMRIYAkiVNKFApw53eSr6QYoAQt+r3EZXyIAtiwVu95WuweDxbM Q9RQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=ZbQFAVTVEjCC49q0a7Zy/fWPXF3FecClbDxdabgWvIM=; fh=oJPhLn/1jgZp03tr5kp1JODO4YLKGyWKVmBwhTyoZ0w=; b=F67FGPXXOg838gbmvTzysfIhkUQlQVE7YvcB9dM+LpYjdZ5xHer1uO1kf3yDfeeq8g rSFPEjg8yqKdBVr4dm92Ihb3B3D2RVagEHo7Oibu8zJgF22Q9kYZAvGXA7o7TFwWn2c3 vgsaoNtdRVwd5cmPGqE9jXoJKQLUHaaNisB/X6v4E5XxCALxNdDry653/cWVOgzUd8w+ UsJBhT1jCpAHm/junTPWgbrjkwA0MmzB/Zn5ffOpvc6+DtHwEgkFczQn1aSVFJHZv6mo UkE8/cXZdl4bSD3/FmX19unmVLW5jfY8b4/vSD5QquOIeh1CDx0JVwegtenrhT+/X9LM BgJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=McgEaJNp; spf=pass (google.com: domain of linux-kernel+bounces-25921-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-25921-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a5-20020a17090680c500b00a2dc69a6fe1si791025ejx.273.2024.01.15.03.28.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 03:28:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-25921-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=McgEaJNp; spf=pass (google.com: domain of linux-kernel+bounces-25921-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-25921-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 am.mirrors.kernel.org (Postfix) with ESMTPS id ABA891F222D7 for ; Mon, 15 Jan 2024 11:28:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 668D32C68A; Mon, 15 Jan 2024 11:28:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="McgEaJNp" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 9C1C9DF4C for ; Mon, 15 Jan 2024 11:28:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DF4A9C433C7; Mon, 15 Jan 2024 11:28:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705318105; bh=h5IJpMjZyx3Hv96LPVu1lr+n0HvSatz0eWIAf4u7zWU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=McgEaJNpYAqBZQ1UROvwQP8n6TV7E2wwkv+CKdS05NHvexCD52F/dXO9sdey/SJqh 3+rh35Cz0ev4gCNLJHfgf2pbwtjvcQlEKa7IFJUfd9afCzTJUjaLgvbdt3H1t8+slf g8tEe82d28bHd4vdY9w260XPaMMSHjLjpEYRMGlN5vb9fXNDW0S2AIKDyiPQATuwsI 8nYLM9+kLXUtKW+OKH2aZRQ+Eckq8hwzGmYwtAwH3O4oz+1M/8+r7KkC8Lgn4vBv8i jYBulu7M0RDFvEYugY1UQ+RlPywpWeHoYNvpyloGkekYuife1N5n+uoae4kQ7aP3IH fCaul4Tq7mWsA== Date: Mon, 15 Jan 2024 12:28:20 +0100 From: Lorenzo Pieralisi To: Marc Zyngier Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Thomas Gleixner Subject: Re: [PATCH] irqchip/gic-v3-its: Handle non-coherent GICv4 redistributors Message-ID: References: <20240114124429.2433890-1-maz@kernel.org> 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-Disposition: inline In-Reply-To: <20240114124429.2433890-1-maz@kernel.org> On Sun, Jan 14, 2024 at 12:44:29PM +0000, Marc Zyngier wrote: > Although the GICv3 code base has gained some handling of systems > failing to handle the shareability attributes, the GICv4 side of > things has been firmly ignored. > > This is unfortunate, as the new recent addition of the > "dma-noncoherent" is supposed to apply to all of the GICR tables, > and not just the ones that are common to v3 and v4. > > Add some checks to handle the VPROPBASE/VPENDBASE shareability > and cacheability attributes in the same way we deal with the > other GICR_BASE registers, wrapping the flag check in a helper > for improved readability. > > Note that this has been found by inspection only, as I don't > have access to HW that suffers from this particular issue. > > Fixes: 3a0fff0fb6a3 ("irqchip/gic-v3: Enable non-coherent redistributors/ITSes DT probing") > Signed-off-by: Marc Zyngier > --- > drivers/irqchip/irq-gic-v3-its.c | 37 +++++++++++++++++++++----------- > 1 file changed, 25 insertions(+), 12 deletions(-) I missed this, sorry - the bug reports we got were for HW platforms where the v4 side of things would not apply but the Fixes commit above is generic and it must have included this hunk, so apologies. FWIW: Reviewed-by: Lorenzo Pieralisi > diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c > index 9a7a74239eab..bdc2c8330479 100644 > --- a/drivers/irqchip/irq-gic-v3-its.c > +++ b/drivers/irqchip/irq-gic-v3-its.c > @@ -207,6 +207,11 @@ static bool require_its_list_vmovp(struct its_vm *vm, struct its_node *its) > return (gic_rdists->has_rvpeid || vm->vlpi_count[its->list_nr]); > } > > +static bool rdists_support_shareable(void) > +{ > + return !(gic_rdists->flags & RDIST_FLAGS_FORCE_NON_SHAREABLE); > +} > + > static u16 get_its_list(struct its_vm *vm) > { > struct its_node *its; > @@ -2710,10 +2715,12 @@ static u64 inherit_vpe_l1_table_from_its(void) > break; > } > val |= FIELD_PREP(GICR_VPROPBASER_4_1_ADDR, addr >> 12); > - val |= FIELD_PREP(GICR_VPROPBASER_SHAREABILITY_MASK, > - FIELD_GET(GITS_BASER_SHAREABILITY_MASK, baser)); > - val |= FIELD_PREP(GICR_VPROPBASER_INNER_CACHEABILITY_MASK, > - FIELD_GET(GITS_BASER_INNER_CACHEABILITY_MASK, baser)); > + if (rdists_support_shareable()) { > + val |= FIELD_PREP(GICR_VPROPBASER_SHAREABILITY_MASK, > + FIELD_GET(GITS_BASER_SHAREABILITY_MASK, baser)); > + val |= FIELD_PREP(GICR_VPROPBASER_INNER_CACHEABILITY_MASK, > + FIELD_GET(GITS_BASER_INNER_CACHEABILITY_MASK, baser)); > + } > val |= FIELD_PREP(GICR_VPROPBASER_4_1_SIZE, GITS_BASER_NR_PAGES(baser) - 1); > > return val; > @@ -2936,8 +2943,10 @@ static int allocate_vpe_l1_table(void) > WARN_ON(!IS_ALIGNED(pa, psz)); > > val |= FIELD_PREP(GICR_VPROPBASER_4_1_ADDR, pa >> 12); > - val |= GICR_VPROPBASER_RaWb; > - val |= GICR_VPROPBASER_InnerShareable; > + if (rdists_support_shareable()) { > + val |= GICR_VPROPBASER_RaWb; > + val |= GICR_VPROPBASER_InnerShareable; > + } > val |= GICR_VPROPBASER_4_1_Z; > val |= GICR_VPROPBASER_4_1_VALID; > > @@ -3126,7 +3135,7 @@ static void its_cpu_init_lpis(void) > gicr_write_propbaser(val, rbase + GICR_PROPBASER); > tmp = gicr_read_propbaser(rbase + GICR_PROPBASER); > > - if (gic_rdists->flags & RDIST_FLAGS_FORCE_NON_SHAREABLE) > + if (!rdists_support_shareable()) > tmp &= ~GICR_PROPBASER_SHAREABILITY_MASK; > > if ((tmp ^ val) & GICR_PROPBASER_SHAREABILITY_MASK) { > @@ -3153,7 +3162,7 @@ static void its_cpu_init_lpis(void) > gicr_write_pendbaser(val, rbase + GICR_PENDBASER); > tmp = gicr_read_pendbaser(rbase + GICR_PENDBASER); > > - if (gic_rdists->flags & RDIST_FLAGS_FORCE_NON_SHAREABLE) > + if (!rdists_support_shareable()) > tmp &= ~GICR_PENDBASER_SHAREABILITY_MASK; > > if (!(tmp & GICR_PENDBASER_SHAREABILITY_MASK)) { > @@ -3880,14 +3889,18 @@ static void its_vpe_schedule(struct its_vpe *vpe) > val = virt_to_phys(page_address(vpe->its_vm->vprop_page)) & > GENMASK_ULL(51, 12); > val |= (LPI_NRBITS - 1) & GICR_VPROPBASER_IDBITS_MASK; > - val |= GICR_VPROPBASER_RaWb; > - val |= GICR_VPROPBASER_InnerShareable; > + if (rdists_support_shareable()) { > + val |= GICR_VPROPBASER_RaWb; > + val |= GICR_VPROPBASER_InnerShareable; > + } > gicr_write_vpropbaser(val, vlpi_base + GICR_VPROPBASER); > > val = virt_to_phys(page_address(vpe->vpt_page)) & > GENMASK_ULL(51, 16); > - val |= GICR_VPENDBASER_RaWaWb; > - val |= GICR_VPENDBASER_InnerShareable; > + if (rdists_support_shareable()) { > + val |= GICR_VPENDBASER_RaWaWb; > + val |= GICR_VPENDBASER_InnerShareable; > + } > /* > * There is no good way of finding out if the pending table is > * empty as we can race against the doorbell interrupt very > -- > 2.39.2 >