From patchwork Thu Sep 26 06:54:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Hu X-Patchwork-Id: 831443 Received: from mail-il1-f169.google.com (mail-il1-f169.google.com [209.85.166.169]) (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 D89AF18BC21 for ; Thu, 26 Sep 2024 06:55:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727333754; cv=none; b=Hrymhq1xy60/D8ebEAENjgcLnMbDxkckvaQgvdAUJEuD3FIi+vm/bBiYisVW2S+AGxqi148qT8B9gf9xQKF9Gs8rsYiH2VAe6oENcKOZ90lxMDQEu71LNhR9dSjcy4GwcT8R0oqT8qI1232riIX6BrlNk2Mh5DCKMDd5e4mTjKU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727333754; c=relaxed/simple; bh=FBGeqsWhtUXKanzZVpX8tx8GNN2ZBAo6zLyDQdumH5Y=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=AWvt1i/Zj/f3HJku1HyT6RuBqSKU1eLHvu202rs/oLJ5VrVsQELzeTWV2heBGy4VTltiDpRv1Q41OtItKA9xSndHeIGMBdgduNECxjUvjBt4gp/z0FYXC2UDs4N5at2AZa+JO4486U+our/ufpODlnOyZquOmvuJSOUGKTea/PM= 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=BC/yuJOI; arc=none smtp.client-ip=209.85.166.169 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="BC/yuJOI" Received: by mail-il1-f169.google.com with SMTP id e9e14a558f8ab-3a0cdd77dbeso2508845ab.2 for ; Wed, 25 Sep 2024 23:55:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1727333752; x=1727938552; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=dz6nXOQPpHKKg/2POW9sH3ldlFQk4LGlQ9pIvX2kgEo=; b=BC/yuJOI/LdgNCbiAaFwxIatqiKzv1jzovilRe5+LrbqAv+8Rg99WcXpfSerVFm3rE 2L+PiMI79BZU5XNE0GGGSy32xvUp1CbT82/XF07jKd7JaVV3OPs8uCUv0Ntr0yhfcCKU umLqT//XCZYF56KGffTtvdEzFsUnBAiYuvQj1z8Sdv5ykMf/rtyP1LuN5b5+cWBkpMZm LyFfiytW6gR49TARKGSRJBs2IsKuJjdv3kSmR0B64vDLDQOX97B2qJn/VqVe4H9sFEY3 4fTwFQVJycQwwzKzLxHJ4Vy/uN6sZWIrHuI+0nsIl30PA35piKJTFah+IhGvgmdrooCK Z55w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727333752; x=1727938552; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dz6nXOQPpHKKg/2POW9sH3ldlFQk4LGlQ9pIvX2kgEo=; b=CQfluNG+XzJqKXUT+0kfwT0Icbr/Zygy6cH55MQFwrhcJp7VuCMWLYnXvFyO2ELwCh 6RF/yoAe++VHLDXRWiC+ggucP6bE5PMLVH21CxD20QWl9GRPZzlqxYPmnLT/XinAO7SJ xVcAkBLNEDK3mqKLpQe1+EBEps0S0WIdGbQRTlXQrjs5kE8OYsHXYcTjZd5dWcIxVj6E b1NUvXrhVbRaI69a9dmwVkxplGD1ksUxyVD/8bCnIjL45PoGxmAugMxipbT6uav9wPED Di+Y3cM6QbvuGq/4iy0E4y5m58ZqylZN3PFrjgQwgCeHqNeiNXj5aKyEr6zA2aGuvRcG Agkg== X-Forwarded-Encrypted: i=1; AJvYcCXAMIIELmKQinUfiTkHC9/HgikLSMPlw2UQqbIWDCNUjLrXzOb7X1nSSLW65fSQfavavm/bYyjHFw==@vger.kernel.org X-Gm-Message-State: AOJu0YzGg9noH2D/tHkB12UblZ3m15bczfnLEwpg4DIJHq40IM0Pi7Pt 7T29NplJLiZ4ij7Jqk3AiTgBuyW0Kr4t7pZjNd6kBF4n3DN1JiGJ8VVqSWQQJm46sYzdzpOiebA wAZI= X-Google-Smtp-Source: AGHT+IE5HtHveKKLfQie2ZdRESQAIt2gsyCcJcr3zDTArzQG0bYH4n5mBiG2zxUxyKL4arsG6HYvQg== X-Received: by 2002:a05:6e02:1fee:b0:3a0:9ed2:67b8 with SMTP id e9e14a558f8ab-3a26d6fc9a9mr60527305ab.4.1727333751901; Wed, 25 Sep 2024 23:55:51 -0700 (PDT) Received: from hsinchu35-syssw01.internal.sifive.com (59-124-168-89.hinet-ip.hinet.net. [59.124.168.89]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7e6b7c73120sm3592352a12.68.2024.09.25.23.55.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Sep 2024 23:55:51 -0700 (PDT) From: Nick Hu To: greentime.hu@sifive.com, zong.li@sifive.com, Paul Walmsley , Palmer Dabbelt , Albert Ou , "Rafael J. Wysocki" , Pavel Machek , Daniel Lezcano , Thomas Gleixner , Anup Patel , Andrew Jones , Mayuresh Chitale , Conor Dooley , Atish Patra , Samuel Ortiz , Samuel Holland , Nick Hu , Sunil V L , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v2 1/3] riscv: Add csr_read/write_hi_lo support Date: Thu, 26 Sep 2024 14:54:16 +0800 Message-Id: <20240926065422.226518-2-nick.hu@sifive.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240926065422.226518-1-nick.hu@sifive.com> References: <20240926065422.226518-1-nick.hu@sifive.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In RV32, we may have the need to read both low 32 bit and high 32 bit of the CSR. Therefore adding the csr_read_hi_lo() and csr_write_hi_lo() to support such case. Suggested-by: Andrew Jones Suggested-by: Zong Li Signed-off-by: Nick Hu --- arch/riscv/include/asm/csr.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/arch/riscv/include/asm/csr.h b/arch/riscv/include/asm/csr.h index 25966995da04..54198284eb22 100644 --- a/arch/riscv/include/asm/csr.h +++ b/arch/riscv/include/asm/csr.h @@ -501,6 +501,17 @@ __v; \ }) +#if __riscv_xlen < 64 +#define csr_read_hi_lo(csr) \ +({ \ + u32 hi = csr_read(csr##H); \ + u32 lo = csr_read(csr); \ + lo | ((u64)hi << 32); \ +}) +#else +#define csr_read_hi_lo csr_read +#endif + #define csr_write(csr, val) \ ({ \ unsigned long __v = (unsigned long)(val); \ @@ -509,6 +520,17 @@ : "memory"); \ }) +#if __riscv_xlen < 64 +#define csr_write_hi_lo(csr, val) \ +({ \ + u64 _v = (u64)(val); \ + csr_write(csr##H, (_v) >> 32); \ + csr_write(csr, (_v)); \ +}) +#else +#define csr_write_hi_lo csr_write +#endif + #define csr_read_set(csr, val) \ ({ \ unsigned long __v = (unsigned long)(val); \ From patchwork Thu Sep 26 06:54:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Hu X-Patchwork-Id: 830967 Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) (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 0B6AC18DF92 for ; Thu, 26 Sep 2024 06:55:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727333761; cv=none; b=sAnJl9JnMYJujjkWmavfh9Xn9BlQvMPjA0sGrOczl+KzSMBDjh42gz2gtFO1ILzJvHcprKKZYdMFabU3qbOI0T35paY4lCmUisggkm3xiNjdPkAYnfJJ2D99WtwXs2EWTnGKCBBTvp0O2LMWguGOu50A1/NtP7yxhe8FTkUZ+d8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727333761; c=relaxed/simple; bh=XxrBvssQCULF7gJT9QV9ETG1rZxqsygfpT3RAP7F+uU=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=O1GMfEg47Yj3Ij0FO93ExJLXRwD+60a6NaJwfIN170mI8QYPEqd1hb+r4IoTeX7VVbPtQQeipWCi226/+xSueLNZ5jwB97y8QK9aDydTMkawP713O9981gODznYg29YnXmUx1LY4IkDl+j3F8+nBrzVXxdTi2zpBvzXTN9ptipA= 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=CN3HUdxy; arc=none smtp.client-ip=209.85.210.175 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="CN3HUdxy" Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-71b070ff24dso584937b3a.2 for ; Wed, 25 Sep 2024 23:55:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1727333759; x=1727938559; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=mBjlL5kJGWFBAGi9ogPc+NvNpZhpYyzyT9+ZEo8HCi0=; b=CN3HUdxykGrUrbTfLA0xk7l3Ghbfg4zVF7BzeLnUZ8kNAsTpMJXYPWdAYw5+EPVePZ 1ixzNRiif6mkg3AVtIOVRqVmE3wrZGytd5yIjKaV1af/ZTP/BTXgmTZfWDjokad3Hqj3 d5kPOWx5N6q7nPU+Cps9q1q1nM85cOmLrWD6gBPZ48g74z0A47uIglEQcCVmuvbwIlKo rouOaEcIXBa8sPJXLtAFVTsoyGxysJiUL1uBDinIV0WYF3AHFwR3Qf72/jzDgkGEbDOc 4Gq5MZq1nu1RJxf4s+tx0M8DgJNhPm+yPoEaOXtpWCBt4eYII+drJEBNDco2Xy+3Ftjt jhdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727333759; x=1727938559; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mBjlL5kJGWFBAGi9ogPc+NvNpZhpYyzyT9+ZEo8HCi0=; b=T3v4sTswWNS1w7fQK7c3g8VDyRUrMnowtJxTlkmvAhPx0elKV5r5XD4KAB70Y5v/Ol 0wKTAjuQMG63yYR+AzIN/mRhWmM7LCGuSQndo27RB8iZiISFdY+XBOHZg51oPlvLW17l c9OcZ+2gWaTvOPx+ECOkz7qzBzYs2eFy8tOquKOQVyzu7uh9X2vQcqtCmvbBTaAS2jbd PwpxcP5xxf5fIzNYoOSWyuZP2j8o8NEqFTm8rJQNIMDMidCQsogZDIFbaj1KvGtmPIo9 eS5seiqsY/4Lat863xlFqNh5Kfp3iXMivoM70MiGKcQZa1KzNoHGwuADpZDpWvV1+DZk D+KA== X-Forwarded-Encrypted: i=1; AJvYcCXRDQCOfrVUzZLK/7yU9Wyg+AanhLMA8oST5T2aEFDqhHBJeAfIQLS+lBX/yLSIk4hniN4SgqMLkg==@vger.kernel.org X-Gm-Message-State: AOJu0YypgthXiBVDSOVN3lUbc94OTtP4Ki3p/fEcYZD6xIjxP8l28cFn ywbfBEIyTmw3kGoxmOBhz4tBBQ8guLoGEL/im8s8H44XUDWzmwnOTl3UQW0PN+k= X-Google-Smtp-Source: AGHT+IGRVC/omnADRGlsObbkjgi01W+xceim4yTBxK4kFMLlr9FVYoKLagm1JteCLvHw13sLiTwW3Q== X-Received: by 2002:a05:6a00:8315:b0:718:d740:b870 with SMTP id d2e1a72fcca58-71b0aa95107mr5923632b3a.2.1727333759199; Wed, 25 Sep 2024 23:55:59 -0700 (PDT) Received: from hsinchu35-syssw01.internal.sifive.com (59-124-168-89.hinet-ip.hinet.net. [59.124.168.89]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7e6b7c73120sm3592352a12.68.2024.09.25.23.55.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Sep 2024 23:55:58 -0700 (PDT) From: Nick Hu To: greentime.hu@sifive.com, zong.li@sifive.com, Paul Walmsley , Palmer Dabbelt , Albert Ou , "Rafael J. Wysocki" , Pavel Machek , Daniel Lezcano , Thomas Gleixner , Anup Patel , Andrew Jones , Conor Dooley , Mayuresh Chitale , Atish Patra , Samuel Holland , Samuel Ortiz , Nick Hu , Sunil V L , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v2 2/3] riscv: Add stimecmp save and restore Date: Thu, 26 Sep 2024 14:54:17 +0800 Message-Id: <20240926065422.226518-3-nick.hu@sifive.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240926065422.226518-1-nick.hu@sifive.com> References: <20240926065422.226518-1-nick.hu@sifive.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 If the HW support the SSTC extension, we should save and restore the stimecmp register while cpu non retention suspend. Signed-off-by: Nick Hu --- arch/riscv/include/asm/suspend.h | 1 + arch/riscv/kernel/suspend.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/arch/riscv/include/asm/suspend.h b/arch/riscv/include/asm/suspend.h index 4ffb022b097f..4dfdb7134d0e 100644 --- a/arch/riscv/include/asm/suspend.h +++ b/arch/riscv/include/asm/suspend.h @@ -18,6 +18,7 @@ struct suspend_context { unsigned long ie; #ifdef CONFIG_MMU unsigned long satp; + u64 stimecmp; #endif }; diff --git a/arch/riscv/kernel/suspend.c b/arch/riscv/kernel/suspend.c index c8cec0cc5833..5d9036ea6784 100644 --- a/arch/riscv/kernel/suspend.c +++ b/arch/riscv/kernel/suspend.c @@ -30,6 +30,9 @@ void suspend_save_csrs(struct suspend_context *context) */ #ifdef CONFIG_MMU + if (riscv_has_extension_unlikely(RISCV_ISA_EXT_SSTC)) + context->stimecmp = csr_read_hi_lo(CSR_STIMECMP); + context->satp = csr_read(CSR_SATP); #endif } @@ -43,6 +46,9 @@ void suspend_restore_csrs(struct suspend_context *context) csr_write(CSR_IE, context->ie); #ifdef CONFIG_MMU + if (riscv_has_extension_unlikely(RISCV_ISA_EXT_SSTC)) + csr_write_hi_lo(CSR_STIMECMP, context->stimecmp); + csr_write(CSR_SATP, context->satp); #endif } From patchwork Thu Sep 26 06:54:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Hu X-Patchwork-Id: 831442 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 91B5118FC7C for ; Thu, 26 Sep 2024 06:56:07 +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=1727333768; cv=none; b=uNy8/RuyU0kV2iiA3j7umBxq7XNqOYwaT7o5h6fr0L/pKWvE1hdVHumhLGhK6IME6TI+6AbYc5KIuPzejGoT211+2wWZR+hPimCOxejN/iOKqi+N9yHlO6VtOutUSyn8h8XR3/Uw+PMygEjLeVysumHzAsjRVBjgJ7t1xu0Zjfo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727333768; c=relaxed/simple; bh=pkVjMZLZKKCNOFrA3WyyFnCA5HqJGbO5ff4ImnIzRrs=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=XGusfxItzz8da1DWge02W+G4s3e/35mHB5yfNq34nvaspGTi9wqpY/5ljDYmhbByqeZPiMBMX0i2Lf2PdG/3SlR5iP2/y6A4tWdtLb6S8J2Nqfj8ZXyPH3FL+zXg/po2rPeL1Et67EfCLHY0fnz6j7DV+b4ThkyMF/CBqRqCwYU= 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=X6/otQVr; arc=none smtp.client-ip=209.85.215.177 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="X6/otQVr" Received: by mail-pg1-f177.google.com with SMTP id 41be03b00d2f7-7d666fb3fb9so361162a12.0 for ; Wed, 25 Sep 2024 23:56:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1727333767; x=1727938567; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=4Pc22EUqI7DPrVM6a23jwJ8zZFnPa3YTszP9VJN1ZIc=; b=X6/otQVrbfw6RYkKQaKmeW7rz89figng150CmWoyvnHnJeH9sakPbqMWnKGv4X36/s MdmvUMgaCASDT4XAws2The0VsXGKj1aUrxmKLWiS+bFQzC4I+NfeSX9khz6btRz13oAL Vu/9tqMmRbOMcbPqCyVurH+apLC6oXfsgP9Qs8kMLt3b592pxSlmqWxPk4Kb8ZuTL/4J vhCggEXRA5tTu1seU6nxSHzYRmUhdGu4JacBEPb0z8jAsKmBkuMVIQWPKhrznezrkJIg hruCJdkCC0Vw0h304w9x9pNwR37keahe+Z91EB2PXtRKQ9NKa92sw4+ZGxD6koUUO1Zq mFvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727333767; x=1727938567; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4Pc22EUqI7DPrVM6a23jwJ8zZFnPa3YTszP9VJN1ZIc=; b=FWAZphXAam0PFFZ9xqDcv+o3w/3gFb2lGbfZssNbVkKJthSeKRWQq1lZiDtWyK6wEl e/cbvGtCZEb9oalkhHqiIr9Gy3s/mLEJxqzHNL9aNFDR/eXDWyT6VB8dTd609zgo149v UMpWdIa2Nn1e+m1qIVejJLzTKJmBcfQHJoOKbUBX1XIs1S67MIUFdx89Sl5UV9H3wcF8 /ei2lzqp3NcMQxMGAS9pNXs0tbzwS9JMQ/EP7UgDuZCvf2YDg0JVzy8WFK1HmXCpbee+ IpoSeY/pihhM7wjSgjcvaXabzCdMgtTzq5LeDR0E8zAN16/HwPTEYyh0u6/nOPjAwRvO rvfw== X-Forwarded-Encrypted: i=1; AJvYcCVfksuiXrxWH3cRZF17qYL7lVSf1WaynL+r+1eC2gALFRUJ327jcogZa9KPEhwEV3cv+eMcrQGKxw==@vger.kernel.org X-Gm-Message-State: AOJu0Yw/Mog5UtV46GzmyDkRU4wtBFGuRBawHkdnqMNb+Z5oChwrt9nA hbadyHmDzpM7CUioBkYpW9EBE3CmMJ3Qa+QIO59dQWJuuQWb4IQy3cntaiz213k= X-Google-Smtp-Source: AGHT+IEO6HyO9ourHKj89akn4hwO0QEWGH3NS+KxhD+L1x5BptifZgMYW8BoqFjQGO0+rzUQWyRL/Q== X-Received: by 2002:a05:6a20:7490:b0:1cc:e71d:ea10 with SMTP id adf61e73a8af0-1d4ebe73f00mr3514567637.14.1727333766880; Wed, 25 Sep 2024 23:56:06 -0700 (PDT) Received: from hsinchu35-syssw01.internal.sifive.com (59-124-168-89.hinet-ip.hinet.net. [59.124.168.89]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7e6b7c73120sm3592352a12.68.2024.09.25.23.56.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Sep 2024 23:56:06 -0700 (PDT) From: Nick Hu To: greentime.hu@sifive.com, zong.li@sifive.com, Paul Walmsley , Palmer Dabbelt , Albert Ou , "Rafael J. Wysocki" , Pavel Machek , Daniel Lezcano , Thomas Gleixner , Anup Patel , Andrew Jones , Mayuresh Chitale , Conor Dooley , Atish Patra , Nick Hu , Samuel Holland , Samuel Ortiz , Sunil V L , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v2 3/3] clocksource/drivers/timer-riscv: Stop stimecmp when cpu hotplug Date: Thu, 26 Sep 2024 14:54:18 +0800 Message-Id: <20240926065422.226518-4-nick.hu@sifive.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240926065422.226518-1-nick.hu@sifive.com> References: <20240926065422.226518-1-nick.hu@sifive.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Stop the stimecmp when the cpu is going to be off otherwise the timer stimecmp register while cpu non retention suspend. Suggested-by: Anup Patel Link: https://lore.kernel.org/lkml/20240829033904.477200-3-nick.hu@sifive.com/T/#u Signed-off-by: Nick Hu --- drivers/clocksource/timer-riscv.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/clocksource/timer-riscv.c b/drivers/clocksource/timer-riscv.c index 48ce50c5f5e6..166dee14e46b 100644 --- a/drivers/clocksource/timer-riscv.c +++ b/drivers/clocksource/timer-riscv.c @@ -127,6 +127,12 @@ static int riscv_timer_starting_cpu(unsigned int cpu) static int riscv_timer_dying_cpu(unsigned int cpu) { disable_percpu_irq(riscv_clock_event_irq); + /* + * Stop the timer when the cpu is going to be offline otherwise + * the timer interrupt may be pending while performing power-down. + */ + riscv_clock_event_stop(); + return 0; }