Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp742687rdb; Sun, 1 Oct 2023 03:47:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IET/TGJYqCQeHKwKmSTsnWl43HyRvHMbdZfURpMDIbk+sa6tQMkF8VUwjYn5Y4zHKehNLzh X-Received: by 2002:a05:6a20:7289:b0:160:97a3:cae9 with SMTP id o9-20020a056a20728900b0016097a3cae9mr10424990pzk.54.1696157236315; Sun, 01 Oct 2023 03:47:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696157236; cv=none; d=google.com; s=arc-20160816; b=iZy/yWH2D+Fj+bXRT04HKPDWZPm37o86mk+N4fawbAvVW32lcEbbUwNAYlbsL0DJoV Fn6+w3HdbZkefTvdlR7fkNif5aJZouWgv2wvbi8XBbB5tCMwEgdDn2Co+EKfRGJnlCH7 QifYeCQfU/WtGsABuQU7YshEaZh7sf2SXo0sWcPfPwa/nskTs5Vyyb1mar4uXm758xpe 4AQ8Ep37L1T/CWc9Wgrx8m0AMdZp1HYz0KcV8nhGTsFLmn1u2FhXqEeXbMtFnDeUfxcY /gw8ltrCUazew7i+XcnhDhtwWEfknh5cjPUNXRsP0M6M6XfNctDPNVom7uAMgA4K3OXR 1oIw== 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 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id u11-20020a6540cb000000b00577d99bd05esi23299939pgp.743.2023.10.01.03.47.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Oct 2023 03:47:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; 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 2620:137:e000::3:5 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 groat.vger.email (Postfix) with ESMTP id 23E848075B19; Sun, 1 Oct 2023 03:47:13 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234841AbjJAKqn (ORCPT + 99 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 Content-Transfer-Encoding: 8bit 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 groat.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 (groat.vger.email [0.0.0.0]); Sun, 01 Oct 2023 03:47:13 -0700 (PDT) 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(-) -- 2.40.1