Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp2589607rdh; Mon, 30 Oct 2023 01:33:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFIocNCzKcsFqhej1BDNor3VW+VS6uI4/PkwHDIfOABSuJ3hW+FWhvgHU/im/BwdF9mU3yS X-Received: by 2002:a17:902:ce81:b0:1cc:5306:e8a3 with SMTP id f1-20020a170902ce8100b001cc5306e8a3mr1892771plg.3.1698654807295; Mon, 30 Oct 2023 01:33:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698654807; cv=none; d=google.com; s=arc-20160816; b=bPEU2h2yY1YMbNRVyqnyojfdZag4uIy+KdTQGAhj6rAVPwSqmaUUm+3J8nc4YM8KGv Y5uRm5UVaiTNmc4H72zAxiBlyMtiUXeEmrjlv/Lf4R5YIliXSXWM8azJavYJOKtQZnFE XWDwikwM9bDsh5/PgyuPEUHyP0HflVVj13YPofL8/psYIw68v/w7jg0rtZEFH9Zzm879 w5fGreWN4ZxZVzXUtvaxFAxmeZEiYPUflz9DEFfV/NhIWKkThhQuAZy1vteXCIiRAsdd cl0RxyaO3gqeUyWYxe6TSspDLcJRz/nH3M2Lqz/tYAK4ZWbRFKvRnypFE4w5ZtZV1ezM b9wA== 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=jHlSnXpSveqodKV98kCvRlmhUS+VD/Lgyy8G0OjrF5E=; fh=FCJaJr5Zz+vH7Pc7M04UxdhmSKwgUsIUuRWcQIFmTQs=; b=IWXxmHjsE7VgF2VxeKX03eIg8/9/hbRHB83QxXrHj9Ai8+ymgeHyTtD+zmFyjZY78h zFkiK/2cM5gcjDS70OGbuJpixQGYOzPB4BhfuiP0q6bu6MjjQucsDn0WIsQuZjEvU3R/ 24wEi0WhDKnbvm+3XoGCX1Gafnl4jhY8DHy8KqX0qlXgb7fBwhF/k0eBHg38EfIQ1qnS d0FXOhjLX6Fcjq9nRKPzfYe0s3nfvqgdlsJ6I09MwT3dNk10KYQDYSqcjd0sBTJyDOj5 Y49eLFdVplSZGk5TlIIl+KoqN7qnss/UHXUb0+36Jxbq/Q6XWOjV2oXP3PWV23vwQlsj vJAg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id a13-20020a170902eccd00b001b9d180fd9asi4079063plh.121.2023.10.30.01.33.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 01:33:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id C4FB5809B6C5; Mon, 30 Oct 2023 01:33:24 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232089AbjJ3IdQ (ORCPT + 99 others); Mon, 30 Oct 2023 04:33:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229517AbjJ3IdP (ORCPT ); Mon, 30 Oct 2023 04:33:15 -0400 Received: from outboundhk.mxmail.xiaomi.com (outboundhk.mxmail.xiaomi.com [207.226.244.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2DB8BAB for ; Mon, 30 Oct 2023 01:33:11 -0700 (PDT) X-IronPort-AV: E=Sophos;i="6.03,263,1694707200"; d="scan'208";a="94816215" From: Fang Xiang To: , , , CC: Subject: [PATCH v4] irqchip/gic-v3-its: Flush ITS tables before writing GITS_BASER registers in non-coherent GIC designs. Date: Mon, 30 Oct 2023 16:32:56 +0800 Message-ID: <20231030083256.4345-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.21] X-ClientProxiedBy: bj-mbx09.mioffice.cn (10.237.8.129) 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 fry.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 (fry.vger.email [0.0.0.0]); Mon, 30 Oct 2023 01:33:25 -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. Suggested-by: Marc Zyngier Signed-off-by: Fang Xiang Tested-by: Fang Xiang --- Link to v3: https://lore.kernel.org/all/20231030070020.3689-1-fangxiang3@xiaomi.com/ 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/ v3-> v4: - Change 'Signed-off-by' trailer to 'Suggested-by' for original author Marc - Fix the format of commit message 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