Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2953954rdb; Tue, 13 Feb 2024 02:18:45 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX8YuL/Vlr000qyVU1WMZR807yrIUtDMeZRwXZ7uOjEo9Ivtj/fZyN8j+QctVO8wJkRiyZzro7lEPoAFTZpfDjb6/LmTUobMgF79lvOFQ== X-Google-Smtp-Source: AGHT+IESURN221EpBnmE/9wHBl9h4irXiscufbTKUgIdT0TVEmH2eU5WSqMZTo4o+fPKfmONo3hM X-Received: by 2002:a05:6a20:4c10:b0:19e:aaba:a7cb with SMTP id fm16-20020a056a204c1000b0019eaabaa7cbmr6435054pzb.39.1707819525084; Tue, 13 Feb 2024 02:18:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707819525; cv=pass; d=google.com; s=arc-20160816; b=EWkWX8L9JMhL5osk2LBDxC15GG8g77dGgw+QuFN4b6UMhRoJyeK2pn/xHsUckioGSG nahOHacZNB9al58wbBhPFGPDj32e+Iu42o+c083oJ0r+yKbpSPerAlHIbCwNc9Hc7aNW pW0SY13lrDNCmvzVkc6fMrjaKhsNwFYkWnKurVWA5KJ5TRc9Qbc+pYP5XwHIzsrn3ZUv lJejjLIPPv3Tb+muI1inWA64bGaGzOiABKJkjYlxnWrjjzsAsKr9FNAkxo4v6BXM58Ep XKdTXiSwfPvXCHZ1kWdyyY1QbZQV7bPPzDJOegIPgNL7z8M0gZ4dvNFV7dpzmSnZNzwg SL/w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=6U0Tjjqp+dzO49dPmOW+kfC6hB+LvtqDbOS7L9vqNAc=; fh=wPAsHvpX8UB54AzKd3YlUR3bibOKDo/fzAM59eLnEmg=; b=zybnjurPkZ4WUKXsGRSLm4/mtmJw3IkSpYtpPQaidOJYAnP2zNgFsLGaqRYKeioAa8 DsR46ezITxmmZqgd+3XuSkvxZLb6msQl+Bu3I2j709fly52wAo8w2emj+yXm6Rfq4r4g WD8Ma1KcE5J79PV83ZA08Zy6dSZvhIpDDtfgc/bAo8Fkh1cfC0a6kv1Z8+kcHD7cnAgT IJu5R40rFjbpf7l70IjDvZR/+/qMqQqXO3NpkXBZ6j8ITbRhjpGg/2aGKTTBk927sOB9 ObI89sStmUDXZRw2nPMLS7eKj7rFKKl/Sh1HztBPdHMhRE7IUdEfTfuxzciWYpwTCO4R S3fw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZJ0LpLUr; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-63316-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63316-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCXb6MH+zlXG8atW4qOtS3zt+yQRn2KQqeTqP1AKK9lmu5qbSFPgkJMZ4wh01H24NGoH8dJVXnYLCx3foqxRlQNuR1VQz/Oke5edSGp8qA== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id h24-20020a170902ac9800b001d98c856c67si1762216plr.222.2024.02.13.02.18.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 02:18:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-63316-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZJ0LpLUr; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-63316-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63316-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 6B74C289B3E for ; Tue, 13 Feb 2024 10:12:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 36C1222625; Tue, 13 Feb 2024 10:12:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZJ0LpLUr" 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 54C88225A4 for ; Tue, 13 Feb 2024 10:12:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707819133; cv=none; b=Ur7wSYb5olNG3Y8mWZXT0y7pGTC3xVJd4GXiT4QwgpkkinO31gLXJv+mjlQLGaW2CULx74edipNiZGcQY7wey2j17tPHtg0E53aP2ibU5VguOUoJ1Q+5ohxnx94dKHXyN3FYBjAsnnnyzuR2Cc0LiCkaRXiy96+Ggw5iga6tGjs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707819133; c=relaxed/simple; bh=y6fOsCJvWITZP3N0edq1izJAfFOb77a1S9SDSCyM6wY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Gi54KEnYiWxzKIeLv0sphVlW7wLHHbiF3lJ0BmSt+sbiIDuOXB4Ywh6hWl0Vt0EuDyA8hu+WB2+6Rb6kxfBezkO6qig+c3/n0WtiGbRl6Ty0Aif4bzJCxgW5Xj0tjyDa56LW+4sgDsi+h0A1TFqI0KOjEVADUHUJQ4BMGclhjfg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZJ0LpLUr; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E7200C433F1; Tue, 13 Feb 2024 10:12:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707819133; bh=y6fOsCJvWITZP3N0edq1izJAfFOb77a1S9SDSCyM6wY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZJ0LpLUr63UODRUhWz1ZbnYp3RArl4C4JFIPR6YNtfFjeKb99s3F712N1VrsbRe7W Ny315lBS9w7sLBMdvWvy1plBsF8kv6CIIlvV9fxzEy85MMHCS2loEC+vw9okIWsDOK 07UEdH3z7WNC373CcSSYPoFy1uU1/vmSJg2ReB8df16n5lD2pgUGlUzKFblYyv6Ulc E4OjnzrjZFOD3PKcHrKddqgmoilc1NqSyGGf80+SAFAYAxRDt54O+We20tMNl+sZAN UZ1ONZBDQhndJccDrT19N4nSRIpcPcVrxUXsAyTIxP+p+Uh14qQnw/RPwHwyqzlJTe akVVFK+NNdi/g== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1rZplq-002j7r-Uv; Tue, 13 Feb 2024 10:12:11 +0000 From: Marc Zyngier To: Thomas Gleixner Cc: Kunkun Jiang , Lorenzo Pieralisi , Zenghui Yu , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] irqchip/gic-v3-its: Handle non-coherent GICv4 redistributors Date: Tue, 13 Feb 2024 10:12:04 +0000 Message-Id: <20240213101206.2137483-2-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213101206.2137483-1-maz@kernel.org> References: <20240213101206.2137483-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-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: tglx@linutronix.de, jiangkunkun@huawei.com, lpieralisi@kernel.org, yuzenghui@huawei.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false 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") Reviewed-by: Lorenzo Pieralisi Signed-off-by: Marc Zyngier --- drivers/irqchip/irq-gic-v3-its.c | 37 +++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index d097001c1e3e..fec1b58470df 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