From patchwork Thu Feb 9 15:26:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jones X-Patchwork-Id: 13134741 X-Patchwork-Delegate: palmer@dabbelt.com 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 40952C61DA4 for ; Thu, 9 Feb 2023 15:26:48 +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-Transfer-Encoding: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-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=lLJ9EEhHsunDc+WJ100hoicqJRYxRyx6/MEyf7CpG4Y=; b=oO4Z/W+lXMCbL+ tErDAmH5F/iuZgWU7T22pxTDRRhkCmv8pKgYxut8h+ou9785WbXfWaSSYLTXZTDWwSyq/J38M2GSH gBe99ztBW3F/l6uEkWyOLQ2WIHgHQyYxsUX7qLWeWvcohnMU0tENfZtpkzzlgAPBmC3kRBEYKvzOa Hfov7150TOOeLeOc+IlpArkDbrztuBSAPuKp7reFKlqnDmqvbimXPxooxzoQdJQrBiQvrKgLT8VCt AVRrS5N2kMIrXAME5puuVxc6AOxMSg22zZprXhLRZJ6WCUHhdqLxHeOT51Ez6ZXpkv73qnQ+SaxfI 0O9KeUH5yuItrmvnHdeA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQ8oo-002Cb3-5J; Thu, 09 Feb 2023 15:26:38 +0000 Received: from mail-ej1-x636.google.com ([2a00:1450:4864:20::636]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQ8ol-002CZn-CC for linux-riscv@lists.infradead.org; Thu, 09 Feb 2023 15:26:37 +0000 Received: by mail-ej1-x636.google.com with SMTP id p26so7348029ejx.13 for ; Thu, 09 Feb 2023 07:26:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=K7rGW7hYEauj0lEHNx054QYhURQUQQG6A8fMOX9HH84=; b=kuIJXFR63EQ+fYmP7C1wA1MzvOqIjuDSDqVG2N1SeYPvzknN2OX74nqtDcH5iQ4O4w oH3qSb7v0I+VZZd/CjCOYvBRZGYgp+zK1T9sv0ApvXDRvAzfOC2Ben/6jkogWxMXNQz0 aetA/zZlAd9PoTpsYYheKpSlwBx6yuvDMyf2kubQPduawwIVE+SKBmPTtrOuHwoCyJYE D9Hk44LVUDlBKqNHQkNL4QjmKOVvinr4QsUH8f91xeqLHLXX1aG8FIhlflTVILQxtqFV F2SQZlhfZWkvt56hm5lOjbDCbpyh1FbyAyMwa3BMCZNyvDHX72oopJvRu2+Ktd6cuYrq GbdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding: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=K7rGW7hYEauj0lEHNx054QYhURQUQQG6A8fMOX9HH84=; b=sT1nJ5wV0C6JKO32XivXugzAGxZkmZXcP3p5WeCEqNomRqaeFra6edhghxCc/PBDAQ DE7nDaMsJ1F9Z+U94PSBj/b+Fn60BK5XMbhf3RzOEB6obkK1WxEc/pgGKB3f1bDClCr5 G7huwNyy6U5cciZltFgXIuJndt+Vsyxuzoo2gohcD4slko7RQQf681OeK46vyNyZBWMR HTIOyQHj5xUo1ugSB6pCCzoJ8SiZwRaJBFd2ZDyjyD9cCxVGEpwB0ba9JymCUOMNgPMm PTfPJuqvZ8s1zi1Nf5N7B2r36w2XdMU/8swRMxGNPM4193YijZzeTmaon3a56BtnXHeK 6RJQ== X-Gm-Message-State: AO0yUKWVYyodEZUMBNBdJz5eJrx4w6cQNNh6jaYmoShYPDSYaAkZS6JA nU/0ovlhQ3coTlVm+TN0zYJ0VsrUP+C8yO1X X-Google-Smtp-Source: AK7set9+Nl/jBXYA+zwzA2NVsfR8qmH3lTKNUYYH8/tWdL/5pN+drLs1/B01bKiO1aUH0oDc9xAR9A== X-Received: by 2002:a17:906:34cf:b0:88a:673e:3669 with SMTP id h15-20020a17090634cf00b0088a673e3669mr14582760ejb.15.1675956393820; Thu, 09 Feb 2023 07:26:33 -0800 (PST) Received: from localhost (cst2-173-16.cust.vodafone.cz. [31.30.173.16]) by smtp.gmail.com with ESMTPSA id ch9-20020a170906c2c900b0088dc98e4510sm999864ejb.112.2023.02.09.07.26.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Feb 2023 07:26:33 -0800 (PST) From: Andrew Jones To: linux-riscv@lists.infradead.org, kvm-riscv@lists.infradead.org, devicetree@vger.kernel.org Cc: 'Anup Patel ' , 'Palmer Dabbelt ' , 'Paul Walmsley ' , 'Krzysztof Kozlowski ' , 'Atish Patra ' , 'Heiko Stuebner ' , 'Jisheng Zhang ' , 'Rob Herring ' , 'Albert Ou ' , 'Conor Dooley ' Subject: [PATCH v4 2/8] RISC-V: Factor out body of riscv_init_cbom_blocksize loop Date: Thu, 9 Feb 2023 16:26:22 +0100 Message-Id: <20230209152628.129914-3-ajones@ventanamicro.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230209152628.129914-1-ajones@ventanamicro.com> References: <20230209152628.129914-1-ajones@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230209_072635_435144_DC7AC4A5 X-CRM114-Status: GOOD ( 10.86 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Refactor riscv_init_cbom_blocksize() to prepare for it to be used for both cbom block size and cboz block size. Signed-off-by: Andrew Jones Reviewed-by: Heiko Stuebner Reviewed-by: Conor Dooley --- arch/riscv/mm/cacheflush.c | 45 +++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/arch/riscv/mm/cacheflush.c b/arch/riscv/mm/cacheflush.c index 3cc07ed45aeb..eaf23fc14966 100644 --- a/arch/riscv/mm/cacheflush.c +++ b/arch/riscv/mm/cacheflush.c @@ -98,34 +98,39 @@ void flush_icache_pte(pte_t pte) unsigned int riscv_cbom_block_size; EXPORT_SYMBOL_GPL(riscv_cbom_block_size); +static void cbo_get_block_size(struct device_node *node, + const char *name, u32 *block_size, + unsigned long *first_hartid) +{ + unsigned long hartid; + u32 val; + + if (riscv_of_processor_hartid(node, &hartid)) + return; + + if (of_property_read_u32(node, name, &val)) + return; + + if (!*block_size) { + *block_size = val; + *first_hartid = hartid; + } else if (*block_size != val) { + pr_warn("%s mismatched between harts %lu and %lu\n", + name, *first_hartid, hartid); + } +} + void riscv_init_cbom_blocksize(void) { struct device_node *node; unsigned long cbom_hartid; - u32 val, probed_block_size; - int ret; + u32 probed_block_size; probed_block_size = 0; for_each_of_cpu_node(node) { - unsigned long hartid; - - ret = riscv_of_processor_hartid(node, &hartid); - if (ret) - continue; - /* set block-size for cbom extension if available */ - ret = of_property_read_u32(node, "riscv,cbom-block-size", &val); - if (ret) - continue; - - if (!probed_block_size) { - probed_block_size = val; - cbom_hartid = hartid; - } else { - if (probed_block_size != val) - pr_warn("cbom-block-size mismatched between harts %lu and %lu\n", - cbom_hartid, hartid); - } + cbo_get_block_size(node, "riscv,cbom-block-size", + &probed_block_size, &cbom_hartid); } if (probed_block_size)