From patchwork Tue Feb 27 23:13:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Charlie Jenkins X-Patchwork-Id: 21058 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp3019992dyb; Tue, 27 Feb 2024 15:16:39 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXrTTFFkoLzQoVpQmK/yG636zgTptdz+5ihUG2oOWCilDcN/Cc7O5RpNUIi4nuBwb2Me9k+VVNm/YYrtfxRUNrSYuZ6gQ== X-Google-Smtp-Source: AGHT+IGuK3Uz4dyJOWhi6r8oA8xxIv4EXuZC0z4GGhw7wxYIGG98LNNZokdpzMmdmTncSFix0wyC X-Received: by 2002:a05:6358:2a1:b0:178:c7e1:52ba with SMTP id w33-20020a05635802a100b00178c7e152bamr13809138rwj.20.1709075799523; Tue, 27 Feb 2024 15:16:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709075799; cv=pass; d=google.com; s=arc-20160816; b=ThluhGos4xxHCN/AmLPKN6k0bgW/71IJrAIuaORzivGfknmEAtfcGoTgoPWtXmTcIB ymb0JsCGsbX3lm2+Df/qo6KR/fr/YvS72Y2fvqA8p812Q3B8PUGtCq9PMg+BZicSrodz uS3aw3rnJaRE1pk7u8YvU32GEmNxSlrK4DVqOSFzXPUSKe9dyBs2Cfspe7HhuXV91rf+ l92n3+UrpHGXxTUFSmIXMDCC7FeUPazihXzeJkN2B+S9z50z7pJV7XlP9ioXJ+8vTcjB ssD3XbysH992F+kUi+4XlXiltERfTFgSmI9+QO5shXcwXgUBdV0PLLM4duEcFkWtiZt/ I8AQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:from :dkim-signature; bh=iOwhG/07dg+gcX9xrTrFROvlLzGJhL4J2NDKYOWOnRM=; fh=1AF/4yN3fvjWS40fe7rayeMIPaTQTX+3zsrmiDTwpyo=; b=vJXu+cKuc2h7nmm9bP0+/NI2+gLY44gVy2hxdS/bBZP2O5nB0JcHUtyjwaD8EthgSr d8uPKAzpYZpTP72tS88pW5tX8n3zNKiZHbrsIlhyOwHdoKBkVuZt2i8xj75kP6NTxKWY xbd4o6O5c01bShzGADdr3gscVhRRECJaDxXtFRUfgHSKsc7eaKzrF3SXO+kqW7e0svyI xSQSCsTMqdjOVL3OHXIc0B62w3hdcsCpGNqjdd2dMFXRL5bO8TQcdey3btvo0tqip0bk TS3hQsLEHVaFTlVZlo/QZbIYPPxAcCXAGHqO3bML6D08XID96KE3do2SudRO3Dx6pfls rYrw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=mzvh7WgO; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-84182-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84182-ouuuleilei=gmail.com@vger.kernel.org" Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id js7-20020a0562142aa700b0068fe8496480si8408306qvb.233.2024.02.27.15.16.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 15:16:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-84182-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=mzvh7WgO; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-84182-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84182-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 1D5D61C2037E for ; Tue, 27 Feb 2024 23:15:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 060395789E; Tue, 27 Feb 2024 23:14:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b="mzvh7WgO" Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6BF4D57863 for ; Tue, 27 Feb 2024 23:14:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709075685; cv=none; b=ZFXtozy9IFiLuwDDY9SAvn9WoKO528OIbW6NKHldZmJOXSY10bwkFezy5Bt2o/hWwWKiw7kOlNohRAJrlEcTsBesyIcGKibT8X35Vony0ryIOGh5m261ryk1QbNZ5hNqQBZFWAAjoLlbmgGjP6nzjGp3Gj3pYwcKwao3xtQQdwI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709075685; c=relaxed/simple; bh=V19HUq/JemRqcELPHFwcZliVz8Klrd9nqh2ouMM+iVQ=; h=From:Subject:Date:Message-Id:MIME-Version:Content-Type:To:Cc; b=TTiCqWxV+iCBr0V7/b2CjuOwx/a9O858yNPSujVDskrSexSxCBp9foR4zF4yLHp1bXN8RdG+8lwO1iE2/ZdVp/DH0+n1MgeJXseOBoekoFkUtbD7f9gP6bAUoisO7Q+HwtnU+Wap7vB3XXBCqq2SPtJ19GsV6MMywYcNf9MU5RI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com; spf=pass smtp.mailfrom=rivosinc.com; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b=mzvh7WgO; arc=none smtp.client-ip=209.85.215.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rivosinc.com Received: by mail-pg1-f177.google.com with SMTP id 41be03b00d2f7-5dbf7b74402so3899488a12.0 for ; Tue, 27 Feb 2024 15:14:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1709075683; x=1709680483; darn=vger.kernel.org; h=cc:to:content-transfer-encoding:mime-version:message-id:date :subject:from:from:to:cc:subject:date:message-id:reply-to; bh=iOwhG/07dg+gcX9xrTrFROvlLzGJhL4J2NDKYOWOnRM=; b=mzvh7WgOci9K3fVMGmudX17syZPpkcgNcp4Vz073PnD/hY/UapmBLYthjIFzGtscWI mxpBT5S6V6pXJf/asXD8NcTbJix2rOJkS2wdAashFsH0YtwN2/gn+I6Ryrinue5npyFz eblalI5bABSblUmfh72kDv8wcRX5/ACYRjxEjE1yb2UheSqfmlgm0l0c4igJQh/CZlxF H9aVBe2PtLjSfy4n/wmx/z8amiQkZHipGIIjtS1ph/lWV3DXYmjK+iZC4Pxl8muZx7cU YLlZRQwWOX6yd0EEQLCrq24J7kyc2dh4+HJ3A6ifbwHLhlC+zye8P0MDuJ3bnbOZsdC6 Jc6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709075683; x=1709680483; 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=iOwhG/07dg+gcX9xrTrFROvlLzGJhL4J2NDKYOWOnRM=; b=dsrxIaMKHDWP0hr6W2gl2YIn8yFKTN/9B40cY7q8WaB6552qQ1qe34tR9JkjUegHUJ ReA/7QiYGQdS1O1AmFhfyy0GyIC4+ZyWYfwe4tjG67Bq4VZhUPByklvsfgA8FTHnknmZ liRemMiBECBaaUfHn6mvQ15Zhe7zjkJorc9HXfoHNLskIAEO3tXbpNkVehUh9EnV6APK ayaTJ3aVdoFmUpSlI23Az2CcT4R3xuuhd+J4AfHXuxQntg2kYuJvYBqymA2m0cZfp+Uf gmref/vnjeaPA9Z27YxNS8kp8M8FwRt1/CLtbXL1U8sT/y0nGmurh7pIoaidZwadwWgq scaw== X-Forwarded-Encrypted: i=1; AJvYcCWMQbhK6x7g4QC4C7lmy3im673nI73IkfKGVUG4Bj9WtcXYdjhZwnZUUshyQkgnIMRv/OaN7qqqXW0SWUGPZxajyEjQSc94KfsBZzSb X-Gm-Message-State: AOJu0Yw2zNzFGvO19OCE8WgYkcEm1V/9tlTSv2Cp/rWXUfYunFDgDP6B dipmZ+skW8gdviS9abwidnT/RPDRugP5IeslTLUF9e3QL1XXvZFc+Rb46hLdGMU= X-Received: by 2002:a05:6a20:c68e:b0:1a0:df5f:99cb with SMTP id gq14-20020a056a20c68e00b001a0df5f99cbmr3609699pzb.27.1709075682714; Tue, 27 Feb 2024 15:14:42 -0800 (PST) Received: from charlie.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id l9-20020a635709000000b005ce998b9391sm5455645pgb.67.2024.02.27.15.14.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 15:14:41 -0800 (PST) From: Charlie Jenkins Subject: [PATCH v5 0/2] riscv: Use Kconfig to set unaligned access speed Date: Tue, 27 Feb 2024 15:13:12 -0800 Message-Id: <20240227-disable_misaligned_probe_config-v5-0-b6853846e27a@rivosinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIAIhs3mUC/43NzWpDIRCG4VsJrmvx9/x01fso5aDjeDKQaNAiL eHce002DSWQrIZ3Fs93ZhULYWVvuzMr2KhSTj3sy47B3qUVOYXeTAllhNSSB6rOH3A59nugNWF YTiV7XCCnSCsXRjt0erRx1qwrp4KRvq8LH5+991S/cvm5DjZ5+T5vN8kFn6cgrcUZgpveC7VcK cEr5CO78E39kUo8QapOjiPoYfIYRq/ukPqWVI9J3UkwJs4yCu39cIc0N6QcHpOmkwGERDtJEA7 +kdu2/QJF4sz9ygEAAA== 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=1709075681; l=2131; i=charlie@rivosinc.com; s=20231120; h=from:subject:message-id; bh=V19HUq/JemRqcELPHFwcZliVz8Klrd9nqh2ouMM+iVQ=; b=voRMT+T4E4Amqngh/Ts1I/w5hpMDAjgLL2GVHpkeTAn1nZRTQZ+YySoYOa3gUGKJ8BeDXxAAc c8IpIXzHWJ3CglX0o3xFRdHHGMAZrzC5AKHY2vPZBx7ByVdiyiiAyqa X-Developer-Key: i=charlie@rivosinc.com; a=ed25519; pk=t4RSWpMV1q5lf/NWIeR9z58bcje60/dbtxxmoSfBEcs= X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792095865441968604 X-GMAIL-MSGID: 1792095865441968604 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 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 (2): riscv: lib: Introduce has_fast_unaligned_access function riscv: Set unaligned access speed at compile time arch/riscv/Kconfig | 47 +++++- arch/riscv/include/asm/cpufeature.h | 43 ++++- arch/riscv/kernel/Makefile | 6 +- arch/riscv/kernel/cpufeature.c | 255 ------------------------------ arch/riscv/kernel/probe_emulated_access.c | 64 ++++++++ arch/riscv/kernel/sys_hwprobe.c | 23 +++ arch/riscv/kernel/traps_misaligned.c | 54 +------ arch/riscv/lib/csum.c | 7 +- 8 files changed, 173 insertions(+), 326 deletions(-) --- base-commit: 6613476e225e090cc9aad49be7fa504e290dd33d change-id: 20240131-disable_misaligned_probe_config-043aea375f93