From patchwork Tue May 30 22:49:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 13261192 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B4C30C77B73 for ; Tue, 30 May 2023 22:53:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date :Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=IXbhaGgSXemPXY0SErZrGxB1AV4NGuEQai6qWwl+HEg=; b=byThGsN4KvZZH8amrV8quHgT+O QV2MNJHrezT9Hei+Q2SRNFQ0Q6rblxYrEDzNJ6NW+/x3bpsLfsiBbkiEtyolVvuZrm4bAVUd/B59i DxfTdjU9OfDCXSa16CzTCudZ7dCtbTSgnQa3ghCT3NSW1qZoaiZESQekvUbZH1ZZ72kVMH3QxwdTB ULyQSLdhAS7MvRN52QKnXj9rwBCerADBWwsmxIoIyAFmSiOSgJueoqCYt34K+ljZ2153Cylt4FvU+ c8gDsleS1i0MVKSxxsfHQhqi0wNmMSYHKInTQv/qmwl2vqoQxeiKVhXpcdctFE9hyDgYOUaN/rTUm XiABZFqw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q48Co-00FNyi-04; Tue, 30 May 2023 22:52:42 +0000 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q48Cj-00FNxI-1q for linux-arm-kernel@lists.infradead.org; Tue, 30 May 2023 22:52:39 +0000 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1b04782fe07so17931815ad.3 for ; Tue, 30 May 2023 15:52:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1685487156; x=1688079156; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=CHxg7TDDksTOHH9Hr1QUGjfXuBtyVKw+a+WQWARiSuk=; b=JkwDMXswaXZB72sVx/iU+h/vKB/WQBNWeGctJJnFlQ0WXvsdLevGxuU1OnVrV1ZQ8h sONlIbXdRfRotTDdXDQxLUcVmsQ7WOcHfOMbAwS6KZ9J6wQFxiidW4PjDtA1KRRAqcSL WE9KbdGvc+dz8t0hfZq39iHhzGo1uDqzzffLk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685487156; x=1688079156; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=CHxg7TDDksTOHH9Hr1QUGjfXuBtyVKw+a+WQWARiSuk=; b=dnd/3RmI5+cnbLMKodvRmxsDA9Aw0CRKzvcIAS7GI0KBSW7EaRV8rlxsMkO9UtJCtq YFiVvzTxUzHdZUXgbP9bbQyz47W7KhP2gzGroZsss8Hy3LynXeEtmHZ9GFrLyTmbJw1Z DKymnoPCelpzKZsCK5v8Is/YVNaRDyOuCRMhGjnVqQuc1Hd79VID5hvZM+TI5XzepwPB BnyMtnkmiZweSO9lYl78Y5ql/cfXZ+IsCtXjrUHnEp9g+fk9olAi7GWWxGVvFkhVFBLo 7X4JKO5AOOuVmKujttvDj1d5iFMzIP8T/3yXto1cy3zwli85ZeQJQ+JXk2ryILp1KMF3 +C+w== X-Gm-Message-State: AC+VfDxMcHt/XSr1A7JnXSfT1TVnoqPVivNQ4Lmh38LxbI2NdUKVfWPi S8P77on+PoYYEKNqJYUwCJqF3Q== X-Google-Smtp-Source: ACHHUZ5WlODrDTtoZX8GEYCbVj1jaRCwAA3DgwgGADMmFo2HRbK/qQRzvL7JF/EDSPcmpXzYCOp4Sw== X-Received: by 2002:a17:903:644:b0:1af:babd:7b6d with SMTP id kh4-20020a170903064400b001afbabd7b6dmr3075052plb.52.1685487156127; Tue, 30 May 2023 15:52:36 -0700 (PDT) Received: from stbirv-lnx-3.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id s3-20020a170902b18300b001a1b66af22fsm10805011plr.62.2023.05.30.15.52.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 May 2023 15:52:35 -0700 (PDT) From: Florian Fainelli To: stable@vger.kernel.org Cc: Pierre Gondois , Sudeep Holla , Florian Fainelli , Catalin Marinas , Will Deacon , Greg Kroah-Hartman , "Rafael J. Wysocki" , Akihiko Odaki , Palmer Dabbelt , Gavin Shan , Jeremy Linton , linux-arm-kernel@lists.infradead.org (moderated list:ARM64 PORT (AARCH64 ARCHITECTURE)), linux-kernel@vger.kernel.org (open list) Subject: [PATCH stable 6.3 1/4] cacheinfo: Add use_arch[|_cache]_info field/function Date: Tue, 30 May 2023 15:49:11 -0700 Message-Id: <20230530224914.1251409-2-florian.fainelli@broadcom.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230530224914.1251409-1-florian.fainelli@broadcom.com> References: <20230530224914.1251409-1-florian.fainelli@broadcom.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230530_155237_612041_D38581B6 X-CRM114-Status: GOOD ( 19.01 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Pierre Gondois commit ef9f643a9f8b62bcbcc51f0e0af8599adc2e17ed upstream The cache information can be extracted from either a Device Tree (DT), the PPTT ACPI table, or arch registers (clidr_el1 for arm64). The clidr_el1 register is used only if DT/ACPI information is not available. It does not states how caches are shared among CPUs. Add a use_arch_cache_info field/function to identify when the DT/ACPI doesn't provide cache information. Use this information to assume L1 caches are privates and L2 and higher are shared among all CPUs. Signed-off-by: Pierre Gondois Link: https://lore.kernel.org/r/20230414081453.244787-5-pierre.gondois@arm.com Signed-off-by: Sudeep Holla Signed-off-by: Florian Fainelli --- drivers/base/cacheinfo.c | 12 ++++++++++-- include/linux/cacheinfo.h | 6 ++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/base/cacheinfo.c b/drivers/base/cacheinfo.c index ea8f416852bd..8120ac1ddbe4 100644 --- a/drivers/base/cacheinfo.c +++ b/drivers/base/cacheinfo.c @@ -28,6 +28,9 @@ static DEFINE_PER_CPU(struct cpu_cacheinfo, ci_cpu_cacheinfo); #define per_cpu_cacheinfo_idx(cpu, idx) \ (per_cpu_cacheinfo(cpu) + (idx)) +/* Set if no cache information is found in DT/ACPI. */ +static bool use_arch_info; + struct cpu_cacheinfo *get_cpu_cacheinfo(unsigned int cpu) { return ci_cacheinfo(cpu); @@ -40,7 +43,8 @@ static inline bool cache_leaves_are_shared(struct cacheinfo *this_leaf, * For non DT/ACPI systems, assume unique level 1 caches, * system-wide shared caches for all other levels. */ - if (!(IS_ENABLED(CONFIG_OF) || IS_ENABLED(CONFIG_ACPI))) + if (!(IS_ENABLED(CONFIG_OF) || IS_ENABLED(CONFIG_ACPI)) || + use_arch_info) return (this_leaf->level != 1) && (sib_leaf->level != 1); if ((sib_leaf->attributes & CACHE_ID) && @@ -343,6 +347,10 @@ static int cache_setup_properties(unsigned int cpu) else if (!acpi_disabled) ret = cache_setup_acpi(cpu); + // Assume there is no cache information available in DT/ACPI from now. + if (ret && use_arch_cache_info()) + use_arch_info = true; + return ret; } @@ -361,7 +369,7 @@ static int cache_shared_cpu_map_setup(unsigned int cpu) * to update the shared cpu_map if the cache attributes were * populated early before all the cpus are brought online */ - if (!last_level_cache_is_valid(cpu)) { + if (!last_level_cache_is_valid(cpu) && !use_arch_info) { ret = cache_setup_properties(cpu); if (ret) return ret; diff --git a/include/linux/cacheinfo.h b/include/linux/cacheinfo.h index 908e19d17f49..b91cc9991c7c 100644 --- a/include/linux/cacheinfo.h +++ b/include/linux/cacheinfo.h @@ -129,4 +129,10 @@ static inline int get_cpu_cacheinfo_id(int cpu, int level) return -1; } +#ifdef CONFIG_ARM64 +#define use_arch_cache_info() (true) +#else +#define use_arch_cache_info() (false) +#endif + #endif /* _LINUX_CACHEINFO_H */