From patchwork Thu Mar 7 19:05:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Charlie Jenkins X-Patchwork-Id: 13586225 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 8FFD6C54E58 for ; Thu, 7 Mar 2024 20:06:50 +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:Cc:To:MIME-Version:Message-Id:Date: Subject:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=RH6iYl/P2/6H/X1FUwyaQgrD9gyYyBZEgG1i3ySc1Nk=; b=awsNxAm1lQpehi H/2krmrrgRa3Es+S6oWJqe18gl1OulJKJUPCjiRMXMbpZs7QjsxPxsKOVrRhlQ2+VHtTWmiWbRiMJ u36IEvARprwl41ERYZheTSkaSsFOsYApaH+jh5fJhV7sDmz/l5zt6qbdrzRASH7/VAy0C/mmI3pCe girMEptKjgKQlLsMeQmGzeHaeCLYnZN19RTCzSJRCtG22XrhMv8OtG4bQlZGLQTDjF58yyiMJTzYr unmqopY8UtzJBIDImnNov+/Ol9LfuzdFwWk6rz4xA9ZmorKm81poG85kubxbljuS10zFjZkwjQCdk x+/jsDFzfhvUJi+V7kbw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1riK0q-00000006CxP-0IUy; Thu, 07 Mar 2024 20:06:44 +0000 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1riJ3y-00000005yP5-0J0e for linux-riscv@lists.infradead.org; Thu, 07 Mar 2024 19:05:55 +0000 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1dcad814986so10426675ad.0 for ; Thu, 07 Mar 2024 11:05:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1709838353; x=1710443153; darn=lists.infradead.org; h=cc:to:content-transfer-encoding:mime-version:message-id:date :subject:from:from:to:cc:subject:date:message-id:reply-to; bh=CjtJhyRDCpI19Ewh14cBKwZVOZbV4kYbTUkGrdqq6Zk=; b=T143V/TPL+QmxAemhR8K+lnUZUEIown/CHRqlklvmEEQD8/qQ6M0iBIq7LFQGXgD/e +xmjGC7KWl7i0TNioNrv5doqup+TPFHLalwRCOwB9Wv6dbaaEEvNhNr1ZCo6MPOvrcF9 xxWu3+qLOnhwTUX2VeX0K758Vhv3NQBmP7Kh1zVFS8OJoRh+Quip+Gxu2u7bYnkwGTpO rX8AscUq7r73IVUZvcX2PjRWMr3dcafx/IC+e5tvuPtRYV7/a7sCLnbw++3ibc9gVO2o nA6l89bQedpQm9g5oaiiAdXogz1ubtqYa86GG6GxQgcJuoLqP84QEqLBGaA4Q77QTv4e 8YhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709838353; x=1710443153; h=cc:to:content-transfer-encoding:mime-version:message-id:date :subject:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=CjtJhyRDCpI19Ewh14cBKwZVOZbV4kYbTUkGrdqq6Zk=; b=HCT5hFKKcAR9JWVg+82E8/iFFIRdNP5kAKfBPtbZuBeZTpZXkQM1PbXk1EEPZyh/t0 wALPI4v/c38XO5Oet0XuzQEXwMpDCV2AmG0CBi8Jm/FgX053lbFIQek9gE1ezjB2KASs Hu+/RQa8UcIo2miFP98nGqhAu6rWirjfqJBdDxWurkI4la+uDi1tLHfTAq6UaHwW5sau Zk3CYIOEGd61HQE691tBt8Fr6yw1fBHZlyhjsyieM6zfqypgHsKcwmCgihXXCAlsaDI1 PHUMKBL4IiqECFQfxIcQn5gmXRTMyQNK9TOiSYWIq/YsC1CY0rxYq2gbTAIxLjWbJvpo jajA== X-Gm-Message-State: AOJu0YyiVmuH6544A8U4ImDEM0Hu7zRt68CQZb03fE654UE6c9DvfHa+ PPdxwAeBMjuhg53id1BCw64OEDy7vJTI64IJwFmM1fqYr+jpN+PMMYfpWtsMLgk= X-Google-Smtp-Source: AGHT+IE5B0hugsWDTp99p7N7xEvh7wJEMxFLgTSlvpzLfPeOAcoxplC7fkr6cxVl+tPmkAbvsbASVw== X-Received: by 2002:a17:903:41d0:b0:1dc:a837:7e1b with SMTP id u16-20020a17090341d000b001dca8377e1bmr10394525ple.63.1709838352986; Thu, 07 Mar 2024 11:05:52 -0800 (PST) Received: from charlie.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id h3-20020a170902680300b001dd526af36csm1747338plk.295.2024.03.07.11.05.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Mar 2024 11:05:52 -0800 (PST) From: Charlie Jenkins Subject: [PATCH v8 0/4] riscv: Use Kconfig to set unaligned access speed Date: Thu, 07 Mar 2024 11:05:44 -0800 Message-Id: <20240307-disable_misaligned_probe_config-v8-0-55d696cb398b@rivosinc.com> MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIAAkQ6mUC/43Qy2rDMBAF0F8JWtdF70dW/Y9SjB4jR5BYQSqmJ fjfK2cTUwz2arizOJeZB6pQElR0Pj1QgSnVlMcW9NsJ+YsdB+hSaBlRTDkmjHQhVeuu0N/avKZ hhNDfS3bQ+zzGNHSYMwuWKRENQ025F4jp59nw+dXyJdXvXH6fhRNZtsftiXS4MzoQIcD4YPVHS VOuafTvPt/Qwk/0RVJ8gKSNVMozqR0E5egGydYk3SdZIz3n0ZCImXNyg+Qrksh9kjcyeExAaOK x9RukWJFU7ZOikU5qwTSXQJXdIOWLZEd+KRspCQUXpImc4Q1SrckDh6uF9AZzYkBZ8/+X8zz/A XP2u9vDAgAA To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Jisheng Zhang , Evan Green , =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= , Eric Biggers , Elliot Berman , Charles Lohr , Conor Dooley Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Charlie Jenkins X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1709838351; l=3215; i=charlie@rivosinc.com; s=20231120; h=from:subject:message-id; bh=0lxp9fgkMSqXRqet6QDcLrjZVWsznGOp1aCABxqMD9Y=; b=ljet3jnYOUaIeYRX4kKRcuKAcFbCR+qmASHc8JBY/3sVQhg+/D60OJTG4tT8zR6/GM3X2ycqJ cpnoVXVWNDaCOX8QArrIwQCTUsSTsixQc0rdIuiAJgBeuLDO3pIBxMR X-Developer-Key: i=charlie@rivosinc.com; a=ed25519; pk=t4RSWpMV1q5lf/NWIeR9z58bcje60/dbtxxmoSfBEcs= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240307_110554_360741_E17DB461 X-CRM114-Status: GOOD ( 13.12 ) 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 If the hardware unaligned access speed is known at compile time, it is possible to avoid running the unaligned access speed probe to speedup boot-time. Signed-off-by: Charlie Jenkins --- Changes in v8: - Minor commit message changes (Conor) - Clean up hwprobe_misaligned() (Conor) - Link to v7: https://lore.kernel.org/r/20240306-disable_misaligned_probe_config-v7-0-6c90419e7a96@rivosinc.com Changes in v7: - Fix check_unaligned_access_emulated_all_cpus to return false when any cpu has emulated accesses - Fix wording in Kconfig (Conor) - Link to v6: https://lore.kernel.org/r/20240301-disable_misaligned_probe_config-v6-0-612ebd69f430@rivosinc.com Changes in v6: - Consolidate Kconfig into 4 options (probe, emulated, slow, efficient) - Change the behavior of "emulated" to allow hwprobe to return "slow" if unaligned accesses are not emulated by the kernel - With this consolidation, check_unaligned_access_emulated is able to be moved back into the original file (traps_misaligned.c) - Link to v5: https://lore.kernel.org/r/20240227-disable_misaligned_probe_config-v5-0-b6853846e27a@rivosinc.com Changes in v5: - Clarify Kconfig options from Conor's feedback - Use "unaligned" instead of "misaligned" in introduced file/function. This is a bit hard to standardize because the riscv manual says "misaligned" but the existing Linux configs say "unaligned". - Link to v4: https://lore.kernel.org/r/20240216-disable_misaligned_probe_config-v4-0-dc01e581c0ac@rivosinc.com Changes in v4: - Add additional Kconfig options for the other unaligned access speeds - Link to v3: https://lore.kernel.org/r/20240202-disable_misaligned_probe_config-v3-0-c44f91f03bb6@rivosinc.com Changes in v3: - Revert change to csum (Eric) - Change ifndefs for ifdefs (Eric) - Change config in Makefile (Elliot/Eric) - Link to v2: https://lore.kernel.org/r/20240201-disable_misaligned_probe_config-v2-0-77c368bed7b2@rivosinc.com Changes in v2: - Move around definitions to reduce ifdefs (Clément) - Make RISCV_MISALIGNED depend on !HAVE_EFFICIENT_UNALIGNED_ACCESS (Clément) - Link to v1: https://lore.kernel.org/r/20240131-disable_misaligned_probe_config-v1-0-98d155e9cda8@rivosinc.com --- Charlie Jenkins (4): riscv: lib: Introduce has_fast_unaligned_access() riscv: Only check online cpus for emulated accesses riscv: Decouple emulated unaligned accesses from access speed riscv: Set unaligned access speed at compile time arch/riscv/Kconfig | 60 ++++-- arch/riscv/include/asm/cpufeature.h | 31 ++-- arch/riscv/kernel/Makefile | 4 +- arch/riscv/kernel/cpufeature.c | 255 -------------------------- arch/riscv/kernel/sys_hwprobe.c | 13 ++ arch/riscv/kernel/traps_misaligned.c | 17 +- arch/riscv/kernel/unaligned_access_speed.c | 282 +++++++++++++++++++++++++++++ arch/riscv/lib/csum.c | 7 +- 8 files changed, 376 insertions(+), 293 deletions(-) --- base-commit: 6613476e225e090cc9aad49be7fa504e290dd33d change-id: 20240131-disable_misaligned_probe_config-043aea375f93