Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp2556278rdh; Mon, 30 Oct 2023 00:01:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEuFF01sjbJWTVcoX0Z7MJT6W9pV5jkjERvMLvDRdcWFtCYs6dmjgLCAsRb9z9IcDMMR1p/ X-Received: by 2002:a05:6a00:1143:b0:6b2:69c:346a with SMTP id b3-20020a056a00114300b006b2069c346amr10097533pfm.19.1698649307262; Mon, 30 Oct 2023 00:01:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698649307; cv=none; d=google.com; s=arc-20160816; b=A2XzYsNDLS5BgYINX/6jijX2Suucj9H8dpfZib1NfOzMYAtabY9glKrmAvwFDOy0SY tAGpTB52NOV16lKeFQHbZVJDap5lMjicgTeEtpqk/BemsX44f70fDIZ0XP/TVVmmaxaB azazZZ9dZaNreJF9kXCJDxRNG4xMNl2CokrBbADnfeHTicbgPTZsL2I8uQ5hdPYN3mhQ J+X7vOd/lwLrAqlK5hd2lkt6i9N6gYwwWF2Lf/zRKTXP3edegw5Vx7VmF9LJfFrJKAp6 0oZmHYMpGwkNvX3LvXhSc5moVMRykCJfAmqs4kXwE0LfGuOqpijIl4REZkDdk5nuM2Zd oS9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=hUq9oqIOA/v8UPVul1PtrMosLgw8n7K5SuYbYLJr06o=; fh=FCJaJr5Zz+vH7Pc7M04UxdhmSKwgUsIUuRWcQIFmTQs=; b=gw+wZn3B1CXbiqMDkbg+TDqKGjLEWJ1ihmW2NVnq67lPpN9dbt+Pqu8tGFBkiRNmyi kGnhMk+olfMDwUr/Cyhy+Gu6zEFI8ZvaI9XDnj4WNsHbF81BHnUbMwjyYOFcl03iVhBj jAmYbh/qS9FQUzoSz+VTZplSiBxnEJYOYcy3wXiXDTmJDD/9KgaKpn47H0qJ3ouuC9Rr 9iehXSJtxdML4sWTAGuyA1yFJmrFz1L9jSIPcfcz/rnmEXcHPcC1uDG7tzzLM4Tt9U2E dGUvV9gYSB1zclUT60qlWmEB2y2ObxQH7HGeZoE+ZfKW1H5fStfobDtRxJQg+eNBGwZ2 Cm5Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=xiaomi.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id j7-20020a056a00174700b006b4642308d0si4540316pfc.232.2023.10.30.00.01.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 00:01:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=xiaomi.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id F1D6C80AA275; Mon, 30 Oct 2023 00:01:40 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231583AbjJ3HBe (ORCPT + 99 others); Mon, 30 Oct 2023 03:01:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231612AbjJ3HBb (ORCPT ); Mon, 30 Oct 2023 03:01:31 -0400 Received: from outboundhk.mxmail.xiaomi.com (outboundhk.mxmail.xiaomi.com [207.226.244.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2806CC4 for ; Mon, 30 Oct 2023 00:01:25 -0700 (PDT) X-IronPort-AV: E=Sophos;i="6.03,262,1694707200"; d="scan'208";a="94799117" From: Fang Xiang To: , , , CC: Subject: [PATCH v3] irqchip/gic-v3-its: Flush ITS tables before writing GITS_BASER registers in non-coherent GIC designs. Date: Mon, 30 Oct 2023 15:00:20 +0800 Message-ID: <20231030070020.3689-1-fangxiang3@xiaomi.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.237.8.18] X-ClientProxiedBy: BJ-MBX15.mioffice.cn (10.237.8.135) To BJ-MBX15.mioffice.cn (10.237.8.135) X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 30 Oct 2023 00:01:41 -0700 (PDT) In non-coherent GIC design, ITS tables should be clean and flushed to the PoV of the ITS before writing GITS_BASER registers, otherwise the ITS would read dirty tables and lead to UNPREDICTABLE behaviors. The ITS always got clean tables in initialization with this fix, by observing the signals from GIC. Furthermore, hoist the quirked non-shareable attributes earlier to save effort in tables setup. Signed-off-by: Marc Zyngier Signed-off-by: Fang Xiang Tested-by: Fang Xiang Link to v2: https://lore.kernel.org/all/20231027031007.2088-1-fangxiang3@xiaomi.com/ Link to v1: https://lore.kernel.org/all/20231026020116.4238-1-fangxiang3@xiaomi.com/ v2 -> v3: - Add 'Signed-off-by' trailer for original author Marc - Expand commit message with testing result v1 -> v2: - Flush ITS tables before writing GITS_BASER registers - Hoist the quirked non-shareable attributes earlier --- drivers/irqchip/irq-gic-v3-its.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 75a2dd550625..d76d44ea2de1 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -2379,12 +2379,12 @@ static int its_setup_baser(struct its_node *its, struct its_baser *baser, break; } + if (!shr) + gic_flush_dcache_to_poc(base, PAGE_ORDER_TO_SIZE(order)); + its_write_baser(its, baser, val); tmp = baser->val; - if (its->flags & ITS_FLAGS_FORCE_NON_SHAREABLE) - tmp &= ~GITS_BASER_SHAREABILITY_MASK; - if ((val ^ tmp) & GITS_BASER_SHAREABILITY_MASK) { /* * Shareability didn't stick. Just use @@ -2394,10 +2394,9 @@ static int its_setup_baser(struct its_node *its, struct its_baser *baser, * non-cacheable as well. */ shr = tmp & GITS_BASER_SHAREABILITY_MASK; - if (!shr) { + if (!shr) cache = GITS_BASER_nC; - gic_flush_dcache_to_poc(base, PAGE_ORDER_TO_SIZE(order)); - } + goto retry_baser; } @@ -2609,6 +2608,11 @@ static int its_alloc_tables(struct its_node *its) /* erratum 24313: ignore memory access type */ cache = GITS_BASER_nCnB; + if (its->flags & ITS_FLAGS_FORCE_NON_SHAREABLE) { + cache = GITS_BASER_nC; + shr = 0; + } + for (i = 0; i < GITS_BASER_NR_REGS; i++) { struct its_baser *baser = its->tables + i; u64 val = its_read_baser(its, baser); -- 2.34.1