Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp349083rdg; Thu, 12 Oct 2023 07:27:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFjkZt4vEr7sK1drEplmAtL9kppdTRQVTiC/nN1GN3MFgpQaeCZO1Q/LY+5lfcxd95KtP8R X-Received: by 2002:a17:902:e191:b0:1c9:d7f7:486 with SMTP id y17-20020a170902e19100b001c9d7f70486mr2990531pla.59.1697120849846; Thu, 12 Oct 2023 07:27:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697120849; cv=none; d=google.com; s=arc-20160816; b=aLyw0KWp/VqYy7exS1jAfTJxncMFJ0Tp+VpSktfGtKDOAtKxKSypuPBFBnXALyJPzZ hMhw+ie83bzr/cDQ3yPARWM1mXmQAKQFEFnM8VTeWPB5ssEVbLjN9YKDN4fbhiBEwaX+ eoS65l70Drsb1qmLeC29uMD0L2jH1rXcDExjZ0jJAXxLEmrheXCoWOXydZWc0spuTgVC 2qtW0F/e5cpeltDEn3uwgcOvo/creg5XhEfPq/rALVrK1BmjM8QgIeC8RwRxnlIGEluC bWSxwLmMNISe3KKNSVpwmg3NwJ7jiyAfYk/XzPTMvuzVJHlILVQyhzl34LJWYgJKjnqC IOvA== 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=dddzKsIBxUOCa38ou/TzIvqZkyneu8grkiYJUluRmxc=; fh=Nv7NcH2g3txwzj7qewEBNML2WRFRP76CtM09rjNxR/M=; b=qXhubZX4k12BsJ59vQBG6bXqM1qvYzbrWKlFOkapmcD49TyCmleySARKoJIagclTIw qriQpCwQfeOqJqAQUZgShp0BZLtR4o2OPGCholLeWKeM1QkIlISnXSXJkrXCvwI89k7Q fZObY/uqL2e+uWq5OEGvcc7OVJTU83dXF3sXpARYoG5kTycsJ5aVa8qWgcpY8V7URzbO faqGbDspl6eEEVRGso335fwEnXhevlyGwuvlwBi9gkykzg32xWqaRKKQuW1/LO4LxInK 3cWuRRAUhTxDQoJNNagnue4omLuX5vLEYaT8ouLvcHB30UnbcsR+9NYT5ITO2f69Yj83 NoOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aYm5uNnS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id c9-20020a170902d48900b001c362510a4esi2487701plg.613.2023.10.12.07.27.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 07:27:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aYm5uNnS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id 49F51802F680; Thu, 12 Oct 2023 07:27:26 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343993AbjJLO1S (ORCPT + 99 others); Thu, 12 Oct 2023 10:27:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233710AbjJLO1R (ORCPT ); Thu, 12 Oct 2023 10:27:17 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79F3291 for ; Thu, 12 Oct 2023 07:27:16 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80AA1C433C7; Thu, 12 Oct 2023 14:27:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697120836; bh=FHPuVYx77onrE1BKDhkCrW4jZHv+uXzoeFVCq11iTOg=; h=From:To:Cc:Subject:Date:From; b=aYm5uNnSVfHV/ccqtOGe+9g1qSe83cQKd7D0+PJGwoe4v8O4Bo7daTpi2JeIT/a9S NK9Mdu+ihT6zPnEuOct2hMPx2lmp9FbNLLcAhtu0lTX4l2AbfNtc/tgrU/+MT2YFby v93vr4xpdUPQiKCgvS31J7njcy/4H5AzRtz/o2hL7o+O9/iMnOEOBEXn7r8WFqs7vv Tx2PeRlHhx0LC+otsXW8t/pUu4s/Bb3k7r7LkbMf74uiKKGvFnf23izG8LG4/h4uR7 awXnLaQdWgR9CSHKGfMaJVtCwV8PfSVNvFJJx6+JqTZZpWIx+MZYDMWmKdutvpASED slbReTrzJJFeQ== 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 v3 0/2] riscv: errata: thead: use riscv_nonstd_cache_ops for CMO Date: Thu, 12 Oct 2023 22:14:54 +0800 Message-Id: <20231012141456.4078-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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Thu, 12 Oct 2023 07:27:26 -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 v2: - collect Reviewed-by tag - fix typo 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