From patchwork Sun Oct 1 10:34:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 14776 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp807165vqb; Sun, 1 Oct 2023 03:48:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFoE/vdWy8WbpCFbGzlPAIvBc0r12G+43IarBnV76WSlh8z+9DOdpqkpzWLsdtqGgY4RC1t X-Received: by 2002:a17:90a:b117:b0:26b:c5b:bb44 with SMTP id z23-20020a17090ab11700b0026b0c5bbb44mr7885251pjq.13.1696157292472; Sun, 01 Oct 2023 03:48:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696157292; cv=none; d=google.com; s=arc-20160816; b=IeG5hUZuTyt01dx35ilms2ekcpomL5XwRAuWM+65LbXXokTQYvHA6rwVURTmrG5rib MbGoUA8h5lomJiPOlKJj0X3e2/iZUgcZNNriMrnSh/L60UzCfIklACmGmPdA6nEvuYui 87Q2jy8jOPtA8c181yJ0jKuFe0Sf9N0+mEojoZ0MCjV6tORqhToPPbUptXQiT0Qyd5Oq FVJXYZKWrXD/dBlTW7g2ooA883Ecq2IJUciElBBw0skrOn8PilZX53zEZKRwKmgyHQ5u So4YE1Pg3d/H2QfM2nLfixqsOrFMvXLcvgGHQMGh6dGpDjwzZHAI1D3ItPC7tK65Mfl6 +gxA== 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=4KN0NrKfoLfRNT60ppkvrffjQxdIp6YNPmHYg/ITboU=; fh=Nv7NcH2g3txwzj7qewEBNML2WRFRP76CtM09rjNxR/M=; b=EkwcsgYppdjuI1VQdBgQsd/ajniLizwnMu3S0XTRvkyYXO0A+eAlVCm8yXiWNP5UiJ 1DSWsxutA50SSd0PNWDHCDlxfoAtS7rJS43NlcmG0+41RBEI4QrcW9DmSZr66WTyeBjs kmFeQXVH3mWeZv7kqN94WhVSkFyajR/VqjsKLHk9IwFSH4GbZE5Dv2VyQ/8qbSsm59kO QNIHoYvw3rkvjMBmrNRIPlaZB6FDgZ4nG2XAwEQ4oXBIu/+H7MVWTVq3fJk8Z32nqOCu hrSJaEgl/sR9hhNDGsNwNsqKq4LUk7ldI//pyN7I8+fKcz+oGWLccJMLEEHN8fGEdANo CpRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ayp3oWp1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id m68-20020a632647000000b00578db71453esi27166146pgm.468.2023.10.01.03.48.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Oct 2023 03:48:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ayp3oWp1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 328868022EA2; Sun, 1 Oct 2023 03:47:05 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234848AbjJAKqn (ORCPT + 19 others); Sun, 1 Oct 2023 06:46:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234823AbjJAKqn (ORCPT ); Sun, 1 Oct 2023 06:46:43 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4CBEB7 for ; Sun, 1 Oct 2023 03:46:37 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DFDBFC433C8; Sun, 1 Oct 2023 10:46:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696157197; bh=Qc8baE61nIrx4p5gOOJ9fZRmaPcr5o9GjWZTqePwzB0=; h=From:To:Cc:Subject:Date:From; b=Ayp3oWp1d5Au2ddMvfCneg0I6IIFxFLxy+JL8OJuz5IfbY5NZ5xvxgw0/fMjYrQso 6MKCegM44n+W0L1Qdchy7QUMaxh+lPHklXt/DurQoQ8pvm5sHQ/fppnSzZBdDXs08A DsL/TmlW3Jh33NuN/NOQRjhvJl8IchvFVqEf8J3CraMbh2SspqpoRqoaCNWGEYqJV+ toDnZYpoE1MZjrbYSnXwNusvQbQfD42zT7x3vswJdKXP5Ws65HlY24aEjAPkxsVeLh RGgv9De+PksXIcHu4S41HGlvPv77ycILX0oTLE8rbgcXZD3pQ3RDFIHUVx55zommax b7cUED9R6Iyvw== From: Jisheng Zhang To: Paul Walmsley , Palmer Dabbelt , Albert Ou Cc: Guo Ren , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 0/2] riscv: errata: thead: use riscv_nonstd_cache_ops for CMO Date: Sun, 1 Oct 2023 18:34:31 +0800 Message-Id: <20231001103433.3187-1-jszhang@kernel.org> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 pete.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 (pete.vger.email [0.0.0.0]); Sun, 01 Oct 2023 03:47:05 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778549777761765480 X-GMAIL-MSGID: 1778549828918473223 Previously, we use alternative mechanism to dynamically patch the CMO operations for THEAD C906/C910 during boot for performance reason. But as pointed out by Arnd, "there is already a significant cost in accessing the invalidated cache lines afterwards, which is likely going to be much higher than the cost of an indirect branch". And indeed, there's no performance difference with GMAC and EMMC per my test on Sipeed Lichee Pi 4A board. Use riscv_nonstd_cache_ops for THEAD C906/C910 CMO to simplify the alternative code, and to acchieve Arnd's goal -- "I think moving the THEAD ops at the same level as all nonstandard operations makes sense, but I'd still leave CMO as an explicit fast path that avoids the indirect branch. This seems like the right thing to do both for readability and for platforms on which the indirect branch has a noticeable overhead." To make bisect easy, I use two patches here: patch1 does the conversion which just mimics current CMO behavior via. riscv_nonstd_cache_ops, I assume no functionalities changes. patch2 uses T-HEAD PA based CMO instructions so that we don't need to covert PA to VA. Hi Guo, I didn't use wback_inv for wback as you suggested during v1 reviewing, this can be left as future optimizations. Thanks since v1: - collect Tested-by tag - add patch2 to use T-HEAD PA based CMO instructions. Jisheng Zhang (2): riscv: errata: thead: use riscv_nonstd_cache_ops for CMO riscv: errata: thead: use pa based instructions for CMO arch/riscv/Kconfig.errata | 1 + arch/riscv/errata/thead/errata.c | 69 +++++++++++++++++++++++++++- arch/riscv/include/asm/errata_list.h | 50 +++----------------- 3 files changed, 74 insertions(+), 46 deletions(-)