Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1300809lql; Tue, 12 Mar 2024 12:57:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXpwCw3vOSbTMPOCy+QjuU0GiYDJTdCg6Y3xiW0VWkdL5zd2eXNuRiPvsjT6uL4BxVeVJlasF5Rb5eiRd6RJ2EkwOBjT9m1VpJjK0c6jw== X-Google-Smtp-Source: AGHT+IHZReS4BaLRkyf0fJlE94NqNNJ3LCRUv72J/i+aMLgjipO68wfn+yQuXOw/ORUVeuL8NdsM X-Received: by 2002:a17:907:a095:b0:a46:139e:45be with SMTP id hu21-20020a170907a09500b00a46139e45bemr2247295ejc.12.1710273470813; Tue, 12 Mar 2024 12:57:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710273470; cv=pass; d=google.com; s=arc-20160816; b=FTxmgiDnWyocwX66VlXRppFAp2mKdF0ui+ub3m2AXnRN41J/0RLHXfmB0w0Ee9+6uc q5TK4P8HX82sTXmPbfJvh8pd/fTwjkZxnoAV8QqVRO6mqpDgcG1nvY+pdsTZlTjY2tWx cAupenIGiG/3TPezkTV0JKWGt1ArJBCXJ6XiXwxjXLmrSQRMSYWFlWYZBByCwWHxitMx QMGUPYEwJFNt0DT1dXkD+1MG3wCV25ufMvE70oruNflNvEOBfvpS+/2bRUiTzaWpq0HL Xz1dSOPhWfgpSvgdnUOrXxuXgF+dtwYuQzpSguNz/QTxFelcUmf2qNYmV89a8NR6MV7l cYxg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=vxEx3iDsM3WrZG2Ndd+J9E+wXDu/hB2Os8/24Q1t3OY=; fh=LKg4NnTvIxK/4kFMsyN8Luto5neXAAZnKtsbvyx7lsk=; b=brBQPc5eE4lU0b44WhNaCimSCbgVXE9qz/UQkx1UKCRHX1jyUmvcZoPIBZjEd9MBPD kJRx/OR8EQ8fYUq124lfJ4UcLwHgIyZiLmq2w+69uUzH44g1KWWeCK0DbCsXglUNAyN+ XEJmv+Wv5LHiywxDx1IfyUq67P1j1arbwhBNJb+sovzvcc2cpb3b4LJo5B1tLs/dvxDQ tVKZ5IjmwX1EO0IpeQyiYuX7xAx/odqpbKU8K1zSlYFih2X/N7/O49g0DBoZ1Hlhhhoa 881EjvNW0dehlKsKzdAE9CnyoFcQwZR2AjrQT7OqjWmzmC8NxlLn7Eusvs/18GY9V33b mi2Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=QZI1LJ2R; arc=pass (i=1 spf=pass spfdomain=sifive.com dkim=pass dkdomain=sifive.com dmarc=pass fromdomain=sifive.com); spf=pass (google.com: domain of linux-kernel+bounces-100731-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-100731-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id du15-20020a17090772cf00b00a437f3234f2si4055223ejc.110.2024.03.12.12.57.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 12:57:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-100731-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=QZI1LJ2R; arc=pass (i=1 spf=pass spfdomain=sifive.com dkim=pass dkdomain=sifive.com dmarc=pass fromdomain=sifive.com); spf=pass (google.com: domain of linux-kernel+bounces-100731-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-100731-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 21C251F22783 for ; Tue, 12 Mar 2024 19:56:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 974D714265A; Tue, 12 Mar 2024 19:56:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="QZI1LJ2R" Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (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 EC81C1E53F for ; Tue, 12 Mar 2024 19:56:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710273406; cv=none; b=jL30MJ4/LNdgeHsf8uXZ3vpzrwDAwVW5xaIX2W8Ljr1c3KSc+MX2NJ/7AsTFlHyEDvll7gXAOMLnFSxlDuI+rqHqLjhuya7kxb1ok6xPNO1Jgj+S8s/l2UvZTNdHH6eUU+hYwuMwpR+DZRUgLWu6xScMmXcDSYWi/orz1nblc74= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710273406; c=relaxed/simple; bh=NfuMaH7Y/8CSMgzfmLwCZoP8iZSzw8HM7XZf9JY3qEA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=u/yV06rUzZBrvDOI3wHb0QsEivxdfPF0q7OXd529p8Ipwk82+4yX39e55hP4DNnAgEd6Gv9GS22wokrsbzNSfLtAu61C/Q7mDoaO3DPn63oFNXZ+NlCXoFpNhfTBkgSRUXAZpeN3XklrBrQRu2n5H78ksk5jU1cDRh5jigY+tPM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com; spf=pass smtp.mailfrom=sifive.com; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b=QZI1LJ2R; arc=none smtp.client-ip=209.85.214.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sifive.com Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-1dd8f7d50c6so1674475ad.0 for ; Tue, 12 Mar 2024 12:56:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1710273403; x=1710878203; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=vxEx3iDsM3WrZG2Ndd+J9E+wXDu/hB2Os8/24Q1t3OY=; b=QZI1LJ2REYGo1Bsc+3/Zqq2HkKct0LVwKXwjvtRUVdoTYpnvFrLuLNk5jJaNBmF8hP KgG7HxYJuYs1yT5N46OP5XurGkntOyZ+8UVrpWeNxRGEbFpLnV95CD91uYzN3tNv2xX2 +E50mP7/BOglB3SmJVyEH/o7VpJ1OXjbGXeXM2oa6f04MrW69uFJWgL0H6enqnkCSVj/ ApcqOgCuz+BFQQTLt6oRG/ryyK6ZygjUHNVZ1keJVcmndWfHEZ09gggSeZgokmXR8vi9 Rxkapb02l9ucsKxnRass5RMvSHXbto/4tsRUyyluvKsNX1xCrgnB5G0Gcq94FOIrQRc0 CICg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710273403; x=1710878203; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=vxEx3iDsM3WrZG2Ndd+J9E+wXDu/hB2Os8/24Q1t3OY=; b=ZocujWaapQCG6b8kpdHTOkjx7jtS8nOaXTwHZvcQgVqqIY2PNhEK2GA1nXGCi9YV1E axkrwvvboCwW2ZI4MbPOifYyrZt62dT05fS3jserVEqTnzTKVmR8YIvMHNq7dMGU9fNX Njtj+9eh0Tc8ojzOj02l2KYYmN4DoXXTsCfgLQmp4HnqaAfxdqBgW/v846gbznaNStcH 4Hsx7hHj4uhbA6/qI5uz0PLz/kgbkt3MaHj5pOiKPre5lFuBPwdKeXzmFscjtkzSMMSZ GKl47tt9MFX0QetdWrgR6CK4NpwIqi2K++0G5GziBim9/REcYLCITUiVUSpBI7Lx1YA+ eseg== X-Forwarded-Encrypted: i=1; AJvYcCXzNEy5ep3iyLnlx9OC0DXJX6y8tPRsm7dmCeqNSZt//Y7MSR6K80RCr2RSf7netKhhzVtj1AZY/9YfFnfT2WdlxNqnTzaHFJsJL++L X-Gm-Message-State: AOJu0YyMy1s02HJ+rztIUoRIW8NniGltX4sy4iby8HUYyJxen4ugASRb 53kbda5NUOS9jvLlWFGQVAVT5iWspWYdTfeTKZlToCIsk8VUDUC/ziRaRB3WjR4= X-Received: by 2002:a17:90a:e54f:b0:29b:c49b:eb13 with SMTP id ei15-20020a17090ae54f00b0029bc49beb13mr628731pjb.24.1710273403142; Tue, 12 Mar 2024 12:56:43 -0700 (PDT) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id hi23-20020a17090b30d700b0029bed0e75dbsm4708774pjb.17.2024.03.12.12.56.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 12:56:42 -0700 (PDT) From: Samuel Holland To: Palmer Dabbelt , linux-riscv@lists.infradead.org Cc: Samuel Holland , Albert Ou , Andrew Jones , Conor Dooley , Ley Foon Tan , Paul Walmsley , Pavel Machek , "Rafael J. Wysocki" , Sia Jee Heng , linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH] riscv: Do not save the scratch CSR during suspend Date: Tue, 12 Mar 2024 12:56:38 -0700 Message-ID: <20240312195641.1830521-1-samuel.holland@sifive.com> X-Mailer: git-send-email 2.43.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit While the processor is executing kernel code, the value of the scratch CSR is always zero, so there is no need to save the value. Continue to write the CSR during the resume flow, so we do not rely on firmware to initialize it. Signed-off-by: Samuel Holland --- arch/riscv/include/asm/suspend.h | 1 - arch/riscv/kernel/suspend.c | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/arch/riscv/include/asm/suspend.h b/arch/riscv/include/asm/suspend.h index 491296a335d0..6569eefacf38 100644 --- a/arch/riscv/include/asm/suspend.h +++ b/arch/riscv/include/asm/suspend.h @@ -13,7 +13,6 @@ struct suspend_context { /* Saved and restored by low-level functions */ struct pt_regs regs; /* Saved and restored by high-level functions */ - unsigned long scratch; unsigned long envcfg; unsigned long tvec; unsigned long ie; diff --git a/arch/riscv/kernel/suspend.c b/arch/riscv/kernel/suspend.c index 299795341e8a..3d306d8a253d 100644 --- a/arch/riscv/kernel/suspend.c +++ b/arch/riscv/kernel/suspend.c @@ -14,7 +14,6 @@ void suspend_save_csrs(struct suspend_context *context) { - context->scratch = csr_read(CSR_SCRATCH); if (riscv_cpu_has_extension_unlikely(smp_processor_id(), RISCV_ISA_EXT_XLINUXENVCFG)) context->envcfg = csr_read(CSR_ENVCFG); context->tvec = csr_read(CSR_TVEC); @@ -37,7 +36,7 @@ void suspend_save_csrs(struct suspend_context *context) void suspend_restore_csrs(struct suspend_context *context) { - csr_write(CSR_SCRATCH, context->scratch); + csr_write(CSR_SCRATCH, 0); if (riscv_cpu_has_extension_unlikely(smp_processor_id(), RISCV_ISA_EXT_XLINUXENVCFG)) csr_write(CSR_ENVCFG, context->envcfg); csr_write(CSR_TVEC, context->tvec); -- 2.43.1