Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp877581rdh; Thu, 26 Oct 2023 20:10:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE7xCiKnNYB9sXRTEbDVNRVbNzhYX+10D95N5pZtGMeSj+Jw6KwgGaYPpOrgGdFG8xDNGM1 X-Received: by 2002:a81:a984:0:b0:5a7:c00b:dc70 with SMTP id g126-20020a81a984000000b005a7c00bdc70mr7810630ywh.1.1698376240607; Thu, 26 Oct 2023 20:10:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698376240; cv=none; d=google.com; s=arc-20160816; b=TUJhBhmNviikPWJ/jFV+j8WIS2DCdxU/HiGvE8o7XuhQP5aYxFx2F6VSsDN7Pv/RQo i3CJRJhNLb08DD7grEoDDVlCkgPYxBw1bXA5579xdD64eA1KYv45wt2kGx3XdyNxiPGb +HDiakbsEmGuffEz2gEzCYJtJbyZA788AIpj3hE6Dk82I4eTwfAn0qoDwgqTzrr9GhSf p53u83t1T0FEpcj6+M4BVlm/CSMUrDx2mh/OKUaI61aaUHe23eG7WQ3KN2dz7FUbhm45 P7NZcLiJBhm7hlM6sJkRinwRUAdrpWlecvynLNbhPwI1ezDsIgcaEgLZoVsTUB3i+rIG E8AQ== 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=ttqpNdAmJMQJwcpolwcmf5wDpG3lA6a764I13m0nw7w=; fh=FCJaJr5Zz+vH7Pc7M04UxdhmSKwgUsIUuRWcQIFmTQs=; b=RtQdBFlCrl+BcGkNSwBC675ssZRLd+ZAy3S29HJglPCL0Qu5cuN7UtFU2nM4bVC3rS UlSg2LuP0TmH8spWQqu+jmKCoSJ2wA/XslaOYSq/wM6iOYiCFbhHV2y8crzupkRpSJS/ KVQKdLgsHO0oBBWAINJcrjYPy7zlf/TKFEybFNMMlwQyrJPMcpltzxp8bNRGn3N0/n13 WPOqIKhR+lyt8eEH6jVDLMVVbpg3lTYrTsuZQP3OFE9XQ2hjtqK2ogAzfpLIRVDN2Xgm 3zdaIpMU6JCMbidsXSCrhN19smz7GE7ZoDxxj1yryrkg8IUTP/fg0rrpynMB8E8rGphG xL4w== 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 n5-20020a0dcb05000000b005869cf4fe20si1199708ywd.76.2023.10.26.20.10.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 20:10:40 -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 E3B628276C08; Thu, 26 Oct 2023 20:10:37 -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 S229644AbjJ0DKX (ORCPT + 99 others); Thu, 26 Oct 2023 23:10:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229437AbjJ0DKU (ORCPT ); Thu, 26 Oct 2023 23:10:20 -0400 Received: from outboundhk.mxmail.xiaomi.com (outboundhk.mxmail.xiaomi.com [207.226.244.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6C366129 for ; Thu, 26 Oct 2023 20:10:17 -0700 (PDT) X-IronPort-AV: E=Sophos;i="6.03,255,1694707200"; d="scan'208";a="94522298" From: Fang Xiang To: , , , CC: Subject: [PATCH v2] irqchip/gic-v3-its: Flush ITS tables before writing GITS_BASER registers in non-coherent GIC designs. Date: Fri, 27 Oct 2023 11:10:07 +0800 Message-ID: <20231027031007.2088-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.22] X-ClientProxiedBy: BJ-MBX02.mioffice.cn (10.237.8.122) 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]); Thu, 26 Oct 2023 20:10:38 -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. And hoist the quirked non-shareable attributes earlier to save effort in tables setup. Signed-off-by: Fang Xiang Link to v1: https://lore.kernel.org/all/20231026020116.4238-1-fangxiang3@xiaomi.com/ 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