From patchwork Wed Mar 8 06:47:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Song Shuai X-Patchwork-Id: 66034 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp176364wrd; Tue, 7 Mar 2023 22:56:29 -0800 (PST) X-Google-Smtp-Source: AK7set+6otT/be6DYyHaJYKJATYhavE1hw44p6ERrd866rJCEju2ydYbtkTKhQKl+x27u4w4O5S5 X-Received: by 2002:a17:907:9485:b0:8a9:f870:d259 with SMTP id dm5-20020a170907948500b008a9f870d259mr19310796ejc.48.1678258589190; Tue, 07 Mar 2023 22:56:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678258589; cv=none; d=google.com; s=arc-20160816; b=IE96X1GJdoPUKElB6cRtunsDWbu066jvZL0ZNj4BVB1D4N82tY/bUgBA2nv4vFE9O3 IhAFPHAb6JMVyD4D4XVxv3xN+MppRGh2ok8j3twmcaGVmoBydWqLwPOI0kfo6C3RAOaV Bm6IMT0PjRNktQST3JleqWZuSkDvd3Bl4Vbvewuy4oPBelp+m6jiaN2r7UHd1GFr3aR3 /THVRf3AY5s3qg+btwxADHQRNIl93wIvzRTmcZIZV1dIM+3p/6gx9R44Dr9yMI4HIUEy Ex1CuqxiLrji/fNh56m4cX4kddb9a1NFHydMwpUoG1+EPjIaVKTP0jkCl0e14EzQ8Q91 lQMQ== 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:dkim-signature; bh=gG2oN8vtildG2P61+wI9F4PrJ+MvdmYrBhZL9NTK/Uo=; b=Q1suEElNWHi4rY78G/yPzOmKUIdH8rc6yHf0Ai/DNrcP/sdV3YG9cgD85DOmaFIZnK ZbsI2lqiPPsZOtOwgy1qW5VD+Pouj1/dB/FjxUufclwxyTLoCwx0qM4DVvuUauCke408 yPAsHeMrPhQ16LieFrC1lsmvsvW9djElpmsyQ6qG8o2noTaumF3elF0wD1PiqZY40R56 YIi7bnjJjB0U/A+4VDoHkmJg52XJQSphCsViqi8g+MKSA/LVELmFfd7xVziFgFeb2hMI 454ezyUPIomdgumIPUDBm0rNvGJO+xtguT0hH0MjJlfnO/MtfjkHxBjNXvMxpzWX9+T2 NkjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=qrtN7j5A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hd34-20020a17090796a200b008dbc41587a8si2930463ejc.730.2023.03.07.22.56.05; Tue, 07 Mar 2023 22:56:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=qrtN7j5A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229708AbjCHGrs (ORCPT + 99 others); Wed, 8 Mar 2023 01:47:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229501AbjCHGrp (ORCPT ); Wed, 8 Mar 2023 01:47:45 -0500 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72FEA9E668 for ; Tue, 7 Mar 2023 22:47:44 -0800 (PST) Received: by mail-pj1-x1030.google.com with SMTP id p3-20020a17090ad30300b0023a1cd5065fso1074162pju.0 for ; Tue, 07 Mar 2023 22:47:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678258064; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=gG2oN8vtildG2P61+wI9F4PrJ+MvdmYrBhZL9NTK/Uo=; b=qrtN7j5AXKWJsCG3E0PH4oiCMNwLFR6JCjdwKskXS/mauDKDcisfSfVFXcUnjsBlEC ax3etlGwgmryLx5JXpm28/mwLf2AV7y6/B5orDESXqchdDaCntCp7hrjMuxEJdWQv5IT AgCeScSiNGdLQAlN4bi06JOmybvt9w49xghgqxwRID4jZN4j6s3FLjJiNfBKrezBJUtD p6iFalHB5coyIDEkCp8PxdBSaszXHzQcAilmx0+npCC88zVByWDRXfvCkqVbjlL3IbYe Cc0SNWskqmmLHHu8PGumzRfI1SttVg1HYgrUfgJrnBRN0pkvdtNOacd31XdSqldMp0TG qIFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678258064; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=gG2oN8vtildG2P61+wI9F4PrJ+MvdmYrBhZL9NTK/Uo=; b=HhXic7ndzxYFUkFffY0QFS80lHOeAYki7BB5CPOoVqjEhAIfA1kuqHggjHMKwGVVH8 KoTcK8XOjuMTnQ69er/NydIGDqO1Fn5L03LPO6D+wBs8S9BlkJb0qObeU3Cd9FWHclLS VUa3betfbAxw7EPkTAwGTudOMyOaZCb65cAWTr9VmJqVNDSvjamCNXRw04FU8EFB/H/j 97WMirs4ef7R2tDnehZutXdbWDlLAORCKhcGSKeEGTnqWWCoAl9S48rHgfXrwLlzvNMZ rDoZhBBpQOWrldRMh1U9UZNef0cdyqxHl2jNk9hO99P7V78MoxZsvbncD11pz2J6zJiD 9tOA== X-Gm-Message-State: AO0yUKWWyYUP9DC9wUdTxukerdlZAx8mU4IP54F0NQk20MEGNSD23RdI QJ/5FChcaGIjkOitJOz6y3c= X-Received: by 2002:a17:90b:204:b0:23a:2038:bf4b with SMTP id fy4-20020a17090b020400b0023a2038bf4bmr17014620pjb.3.1678258063791; Tue, 07 Mar 2023 22:47:43 -0800 (PST) Received: from localhost.localdomain ([221.226.144.218]) by smtp.gmail.com with ESMTPSA id y20-20020a17090aca9400b0023317104415sm10149201pjt.17.2023.03.07.22.47.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Mar 2023 22:47:43 -0800 (PST) From: Song Shuai To: paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, sudeep.holla@arm.com, pierre.gondois@arm.com, conor.dooley@microchip.com Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Song Shuai Subject: [PATCH] Revert "riscv: Set more data to cacheinfo" Date: Wed, 8 Mar 2023 14:47:34 +0800 Message-Id: <20230308064734.512457-1-suagrfillet@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759781677906040873?= X-GMAIL-MSGID: =?utf-8?q?1759781677906040873?= This reverts commit baf7cbd94b5688f167443a2cc3dcea3300132099. There are some duplicate cache attributes populations executed in both ci_leaf_init() and later cache_setup_properties(). Revert the commit baf7cbd94b56 ("riscv: Set more data to cacheinfo") to setup only the level and type attributes at this early place. Signed-off-by: Song Shuai Acked-by: Sudeep Holla Acked-by: Conor Dooley --- arch/riscv/kernel/cacheinfo.c | 66 ++++++++--------------------------- 1 file changed, 15 insertions(+), 51 deletions(-) diff --git a/arch/riscv/kernel/cacheinfo.c b/arch/riscv/kernel/cacheinfo.c index 3a13113f1b29..305ebbdc780d 100644 --- a/arch/riscv/kernel/cacheinfo.c +++ b/arch/riscv/kernel/cacheinfo.c @@ -64,53 +64,12 @@ uintptr_t get_cache_geometry(u32 level, enum cache_type type) 0; } -static void ci_leaf_init(struct cacheinfo *this_leaf, enum cache_type type, - unsigned int level, unsigned int size, - unsigned int sets, unsigned int line_size) +static void ci_leaf_init(struct cacheinfo *this_leaf, + struct device_node *node, + enum cache_type type, unsigned int level) { this_leaf->level = level; this_leaf->type = type; - this_leaf->size = size; - this_leaf->number_of_sets = sets; - this_leaf->coherency_line_size = line_size; - - /* - * If the cache is fully associative, there is no need to - * check the other properties. - */ - if (sets == 1) - return; - - /* - * Set the ways number for n-ways associative, make sure - * all properties are big than zero. - */ - if (sets > 0 && size > 0 && line_size > 0) - this_leaf->ways_of_associativity = (size / sets) / line_size; -} - -static void fill_cacheinfo(struct cacheinfo **this_leaf, - struct device_node *node, unsigned int level) -{ - unsigned int size, sets, line_size; - - if (!of_property_read_u32(node, "cache-size", &size) && - !of_property_read_u32(node, "cache-block-size", &line_size) && - !of_property_read_u32(node, "cache-sets", &sets)) { - ci_leaf_init((*this_leaf)++, CACHE_TYPE_UNIFIED, level, size, sets, line_size); - } - - if (!of_property_read_u32(node, "i-cache-size", &size) && - !of_property_read_u32(node, "i-cache-sets", &sets) && - !of_property_read_u32(node, "i-cache-block-size", &line_size)) { - ci_leaf_init((*this_leaf)++, CACHE_TYPE_INST, level, size, sets, line_size); - } - - if (!of_property_read_u32(node, "d-cache-size", &size) && - !of_property_read_u32(node, "d-cache-sets", &sets) && - !of_property_read_u32(node, "d-cache-block-size", &line_size)) { - ci_leaf_init((*this_leaf)++, CACHE_TYPE_DATA, level, size, sets, line_size); - } } int populate_cache_leaves(unsigned int cpu) @@ -121,24 +80,29 @@ int populate_cache_leaves(unsigned int cpu) struct device_node *prev = NULL; int levels = 1, level = 1; - /* Level 1 caches in cpu node */ - fill_cacheinfo(&this_leaf, np, level); + if (of_property_read_bool(np, "cache-size")) + ci_leaf_init(this_leaf++, np, CACHE_TYPE_UNIFIED, level); + if (of_property_read_bool(np, "i-cache-size")) + ci_leaf_init(this_leaf++, np, CACHE_TYPE_INST, level); + if (of_property_read_bool(np, "d-cache-size")) + ci_leaf_init(this_leaf++, np, CACHE_TYPE_DATA, level); - /* Next level caches in cache nodes */ prev = np; while ((np = of_find_next_cache_node(np))) { of_node_put(prev); prev = np; - if (!of_device_is_compatible(np, "cache")) break; if (of_property_read_u32(np, "cache-level", &level)) break; if (level <= levels) break; - - fill_cacheinfo(&this_leaf, np, level); - + if (of_property_read_bool(np, "cache-size")) + ci_leaf_init(this_leaf++, np, CACHE_TYPE_UNIFIED, level); + if (of_property_read_bool(np, "i-cache-size")) + ci_leaf_init(this_leaf++, np, CACHE_TYPE_INST, level); + if (of_property_read_bool(np, "d-cache-size")) + ci_leaf_init(this_leaf++, np, CACHE_TYPE_DATA, level); levels = level; } of_node_put(np);