From patchwork Tue May 7 15:21:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 13657292 Received: from wfhigh8-smtp.messagingengine.com (wfhigh8-smtp.messagingengine.com [64.147.123.159]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E99741635B4; Tue, 7 May 2024 15:22:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.123.159 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715095334; cv=none; b=e4FEAsURbAGbk4W/fN0UgtvTf2d9aYetcpGx0x2iXgvK/5ziXiwQZyU0u/VSzP5Ygcnw+v6O/J4vbZxQMD/4b4sB+z+/Rxz2HG5Heo/fFHBQw1XV8f6e6nwIZ/LgnE1+0H7jANbtKEKPraoTOB1kXcyPl59aJ3eEBP1wJy4r+a8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715095334; c=relaxed/simple; bh=qXXoGV6i4NzNa9jr9/H0yCDHFV+OWy2FwzBUaOEhp5Y=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ugBakTRTrXPuleY4ddawk0sHpxmnvyi+i09KvEpCKCROvmOcJ3RZf8iCojTNbNjODESiHwwQmp8qCD8uZjeaVYmREjKMOmuzxoFqUjP3Sr6AHWD55zG6ZABgzuhzK7mp623jjMoAB/YbNo8Ljod6PsX2AwcUjcju/SdLSblmkd8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=flygoat.com; spf=pass smtp.mailfrom=flygoat.com; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b=sl+zPdoT; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=agEadtly; arc=none smtp.client-ip=64.147.123.159 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=flygoat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flygoat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b="sl+zPdoT"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="agEadtly" Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfhigh.west.internal (Postfix) with ESMTP id 8A87B18000F0; Tue, 7 May 2024 11:22:11 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Tue, 07 May 2024 11:22:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1715095331; x=1715181731; bh=r+qM25PDwQQfzbe2OzFvr0B7xCYpWc9mVVvuKOrfTtY=; b= sl+zPdoT9wWr+w9cwBqrjmNMPk3/sb+NbW+PJXc0HkGMnvuf3tP+Dvs0wvxjP5Kk JasbjiTyDBr9/C00wEnA7ynpMeZTq2uhoSzPvUn/PuDaVR6KufuQIBPHQsLga5hu EXRLxurntl7Dr3OypLlOxiWrZj9d6zrDC7PyOnxI/WsGfPMqKWzgMfKKKm64pmy/ fItbdWUy65kNqSmarrwB+2PeHEYNM4GO/P54bcY0XqtI+19Yd60vha9j+uOCY3Xb oQMWurn7cki/fVY1OAlx77ZqLx1CY/lpmqfB522oX7qZlTTo/+ApknewjYoNYZBo jZ0pPTBJ2NsjaharfBdj8A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1715095331; x= 1715181731; bh=r+qM25PDwQQfzbe2OzFvr0B7xCYpWc9mVVvuKOrfTtY=; b=a gEadtlypw0aLQn1jId3sRG4cwCxH0nMsSID+5y8QFqaS/hW6HeCllw/p00j300zP dVXcPum6B+yHUyJmxE5g2Y1Mztm6gfphM8wRvcK8L85c6Nk4eIiA/j2zwj7WaTeV 0o8OBF8DH7J+ydiPYN4p4fM9lN68AonW+jHxsIDycR5/YQpam3NpthVQgSbCg5cH +kuqgnfmXMQEBOF+enL7VFFdEdZHPCxYKCuwKW8nkRbpFy0tcZGY6nGI9iY4d7KD q4NkdL+IwWTuoSntKVLPRJWj63WRM226cbvh+pF41tkZeOzfZMXv/HClK6rRUnyn fPoNNEJ9ElvTMFIVOO8TQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvddvkedgkeehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdejnecuhfhrohhmpeflihgr gihunhcujggrnhhguceojhhirgiguhhnrdihrghnghesfhhlhihgohgrthdrtghomheqne cuggftrfgrthhtvghrnhepvdekiefhfeevkeeuveetfeelffekgedugefhtdduudeghfeu veegffegudekjeelnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomhepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdrtghomh X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 7 May 2024 11:22:10 -0400 (EDT) From: Jiaxun Yang Date: Tue, 07 May 2024 16:21:59 +0100 Subject: [PATCH 1/3] MIPS: asm/pm.h: Use platform agnostic macros Precedence: bulk X-Mailing-List: linux-mips@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240507-loongson64-suspend-v1-1-534d92a4e09a@flygoat.com> References: <20240507-loongson64-suspend-v1-0-534d92a4e09a@flygoat.com> In-Reply-To: <20240507-loongson64-suspend-v1-0-534d92a4e09a@flygoat.com> To: Thomas Bogendoerfer , Huacai Chen Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Jiaxun Yang X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2278; i=jiaxun.yang@flygoat.com; h=from:subject:message-id; bh=qXXoGV6i4NzNa9jr9/H0yCDHFV+OWy2FwzBUaOEhp5Y=; b=owGbwMvMwCHmXMhTe71c8zDjabUkhjQrd8WKvkvJ7I/f329wqD0u8nNG24UjLzdOXCjH6Vgmx XHCSoupo5SFQYyDQVZMkSVEQKlvQ+PFBdcfZP2BmcPKBDKEgYtTACZSl8TI0OY91yI92ymAt7It SFYkatXid9+cUyTVnn8pvnf0rebuyYwME9rvZyrwbFvi8vf8t6jkv55Ha62mXp9548mnlcvuTBA 9wwIA X-Developer-Key: i=jiaxun.yang@flygoat.com; a=openpgp; fpr=980379BEFEBFBF477EA04EF9C111949073FC0F67 Use platform agnostic macros so it can be compiled on all MIPS platforms. Signed-off-by: Jiaxun Yang --- arch/mips/include/asm/pm.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/arch/mips/include/asm/pm.h b/arch/mips/include/asm/pm.h index 10bb7b640738..7ecd4dfe3846 100644 --- a/arch/mips/include/asm/pm.h +++ b/arch/mips/include/asm/pm.h @@ -17,7 +17,7 @@ /* Save CPU state to stack for suspend to RAM */ .macro SUSPEND_SAVE_REGS - subu sp, PT_SIZE + PTR_SUBU sp, PT_SIZE /* Call preserved GPRs */ LONG_S $16, PT_R16(sp) LONG_S $17, PT_R17(sp) @@ -56,13 +56,13 @@ LONG_L $31, PT_R31(sp) /* Pop and return */ jr ra - addiu sp, PT_SIZE + PTR_ADDIU sp, PT_SIZE .set pop .endm /* Get address of static suspend state into t1 */ .macro LA_STATIC_SUSPEND - la t1, mips_static_suspend_state + PTR_LA t1, mips_static_suspend_state .endm /* Save important CPU state for early restoration to global data */ @@ -72,11 +72,11 @@ * Segment configuration is saved in global data where it can be easily * reloaded without depending on the segment configuration. */ - mfc0 k0, CP0_PAGEMASK, 2 /* SegCtl0 */ + mfc0 k0, CP0_SEGCTL0 LONG_S k0, SSS_SEGCTL0(t1) - mfc0 k0, CP0_PAGEMASK, 3 /* SegCtl1 */ + mfc0 k0, CP0_SEGCTL1 LONG_S k0, SSS_SEGCTL1(t1) - mfc0 k0, CP0_PAGEMASK, 4 /* SegCtl2 */ + mfc0 k0, CP0_SEGCTL2 LONG_S k0, SSS_SEGCTL2(t1) #endif /* save stack pointer (pointing to GPRs) */ @@ -92,11 +92,11 @@ * segments. */ LONG_L k0, SSS_SEGCTL0(t1) - mtc0 k0, CP0_PAGEMASK, 2 /* SegCtl0 */ + mtc0 k0, CP0_SEGCTL0 LONG_L k0, SSS_SEGCTL1(t1) - mtc0 k0, CP0_PAGEMASK, 3 /* SegCtl1 */ + mtc0 k0, CP0_SEGCTL1 LONG_L k0, SSS_SEGCTL2(t1) - mtc0 k0, CP0_PAGEMASK, 4 /* SegCtl2 */ + mtc0 k0, CP0_SEGCTL2 tlbw_use_hazard #endif /* restore stack pointer (pointing to GPRs) */ @@ -105,10 +105,10 @@ /* flush caches to make sure context has reached memory */ .macro SUSPEND_CACHE_FLUSH - .extern __wback_cache_all + .extern __flush_cache_all .set push .set noreorder - la t1, __wback_cache_all + PTR_LA t1, __flush_cache_all LONG_L t0, 0(t1) jalr t0 nop From patchwork Tue May 7 15:22:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 13657293 Received: from wfout5-smtp.messagingengine.com (wfout5-smtp.messagingengine.com [64.147.123.148]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F027F1649CD; Tue, 7 May 2024 15:22:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.123.148 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715095336; cv=none; b=YMcPGGWYZj0Fcekm/IZgJVjBV3xRcAFE1v+Sg2toCY3sJmpiTyAcFhPRq+X1KYq7JrYIqXzsW4KbRogg2w7q4MA3f61ah0XW08Ba3duyAvaBE9XyDqOfiNRVgwKBE0cRePTmG2/OzgRn85FU/2YdOn2IBgVFKbsuSqdpq/aNA0s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715095336; c=relaxed/simple; bh=aCG31ggx5FwnkAw89eRrVEa5H/1D1f/hLv5GcL5wb5w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=M2QQnRwv2UXpnoVMMz6Dwym/ip0K3qE2r1eeovZnllOGdyC4eSBrvuTWDyHTS40Mo0xt62JfVwe//rjxCSm6ua/b2dVB2D9glZPK5Y42Y/rp8iwJo70sqTPDZZGEZjaPDvFzw+LiK0QhvyDucWE1k6aEkLiD06Lq5b+/tOyUxUA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=flygoat.com; spf=pass smtp.mailfrom=flygoat.com; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b=lL8ITcWp; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=Ek4d7dsU; arc=none smtp.client-ip=64.147.123.148 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=flygoat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flygoat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b="lL8ITcWp"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="Ek4d7dsU" Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfout.west.internal (Postfix) with ESMTP id D97331C000E3; Tue, 7 May 2024 11:22:13 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Tue, 07 May 2024 11:22:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1715095333; x=1715181733; bh=TjtLInAZcfnZsukDv2PQiAwljAXLKqwg2HYQT5PZI7k=; b= lL8ITcWpbUaMIEiza+q8ZyNjs5XXZm85axAgbkFYJbahmgHlGESHrRn4f/VjdYD0 TskNcx5G2pFJEdrdirFnCu4rIvFMn0yGzHq3P3ckEedgM+VxGKM5dpy8sYmvuHQ0 H8xfSyEfStsYKB6nYv+vdoC6d6nAO3/KEXMNQAw+tsQvZVlWk/2MpM4jxFujIZ2V 8S6s1+cNCJ11dUVSY0qWxH5q4UcI2NFtj2VwG2YxcJf7+pA+tVeoctK0JS4XQyJn pu8Y2Vje6FbDnsOCfBgFo/NVxHg1rbpaqTJY3p1l8oZlH2Uf1euAR8YNH+cClmyz pA//6k4T8a9hbZNpnKkroA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1715095333; x= 1715181733; bh=TjtLInAZcfnZsukDv2PQiAwljAXLKqwg2HYQT5PZI7k=; b=E k4d7dsU/2VYIWc6w5jlq7qQtAlr6o9VaBM9JYbE3AxpbFMOfJAnMAh2v82hq/YWJ lzC4JHNvKpYWYEsSnp11dn/uH2utDBypFuXISAS/fwlN9TuTck5WQTZk0KLo0Kiy vFoJ7Ty31qPg/FaD8zUb98tLkTwgjSrmwqyCm5dfIZdVJpij3A636FhLd09JrPVg rEbe7bDTQrcXAVtog4pL/D1lGXzesrcWGfHHYurWGb8ZgGAld6iPjvjLOtFeXpnL Stv8afyPHX53he/ZoUw5DkXaKsYqMNRavTpaReLgkixGzMDIvXBpGb8VRfwpIbC5 gZiz4h2JcKd5YcA9a2sxQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvddvkedgkeehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdejnecuhfhrohhmpeflihgr gihunhcujggrnhhguceojhhirgiguhhnrdihrghnghesfhhlhihgohgrthdrtghomheqne cuggftrfgrthhtvghrnhepvdekiefhfeevkeeuveetfeelffekgedugefhtdduudeghfeu veegffegudekjeelnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehmrghilh hfrhhomhepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdrtghomh X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 7 May 2024 11:22:12 -0400 (EDT) From: Jiaxun Yang Date: Tue, 07 May 2024 16:22:00 +0100 Subject: [PATCH 2/3] MIPS: select CPU_PM with SUSPEND Precedence: bulk X-Mailing-List: linux-mips@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240507-loongson64-suspend-v1-2-534d92a4e09a@flygoat.com> References: <20240507-loongson64-suspend-v1-0-534d92a4e09a@flygoat.com> In-Reply-To: <20240507-loongson64-suspend-v1-0-534d92a4e09a@flygoat.com> To: Thomas Bogendoerfer , Huacai Chen Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Jiaxun Yang X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=696; i=jiaxun.yang@flygoat.com; h=from:subject:message-id; bh=aCG31ggx5FwnkAw89eRrVEa5H/1D1f/hLv5GcL5wb5w=; b=owGbwMvMwCHmXMhTe71c8zDjabUkhjQrd0X5P9OzJBusvSOy+CZXX61Sej1HS+Mw08Wj/Vfnd 1rVauzpKGVhEONgkBVTZAkRUOrb0HhxwfUHWX9g5rAygQxh4OIUgIl0WzAy9H46eNDTSden8efz e2rFziefhxx0ElOuSqmdv3uLdh8HMyND8xLrHTuv5vk+i76xSjle62p2NkfThYI7D7QetCmyNte wAAA= X-Developer-Key: i=jiaxun.yang@flygoat.com; a=openpgp; fpr=980379BEFEBFBF477EA04EF9C111949073FC0F67 Functionalities provided by CPU_PM are essential for suspend to work on all platforms. Signed-off-by: Jiaxun Yang --- arch/mips/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index f1aa1bf11166..c5753cb0953d 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -30,7 +30,7 @@ config MIPS select BUILDTIME_TABLE_SORT select CLONE_BACKWARDS select CPU_NO_EFFICIENT_FFS if (TARGET_ISA_REV < 1) - select CPU_PM if CPU_IDLE + select CPU_PM if CPU_IDLE || SUSPEND select GENERIC_ATOMIC64 if !64BIT select GENERIC_CMOS_UPDATE select GENERIC_CPU_AUTOPROBE From patchwork Tue May 7 15:22:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 13657294 Received: from wfhigh8-smtp.messagingengine.com (wfhigh8-smtp.messagingengine.com [64.147.123.159]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DD492168AF8; Tue, 7 May 2024 15:22:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.123.159 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715095338; cv=none; b=uLLHZnEGIYsKV5pBDBMoIDo76YAt03lz0o2w5Tpi6h16BUyF/o0W7coTmHiCzL50hs/COGomjWqkrTzidxmw0YEF/Tc15Ftr/iZkjcpu4ZuVHWKhav5+7uqoDICVbeoja3SIJ8FHqPkcZ30rxB5kfWRhCY9kPii8SvPtdcqC/68= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715095338; c=relaxed/simple; bh=pQz0w1yBfPHUBv/v0nbOyM9aMVNE+JcqduRqxVhK+yQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=RSIPxuPPT9qENnEGefleu9rAwGU/wp/6psvvSJoyBfh+uh2OJoTQUp7OvFAJ9S+qd6IyK+hLdIIXrjEV0ClCG8w+BY15B8SSpu9iJAkOTJCcIY8Vb03LZE0emIHNeveVDVQX5PS6hnuzQDiZqTC/dn303CxHCu1y+tYJa3v8QoY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=flygoat.com; spf=pass smtp.mailfrom=flygoat.com; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b=Pw4ZbWsN; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=MfR7q9PK; arc=none smtp.client-ip=64.147.123.159 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=flygoat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flygoat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b="Pw4ZbWsN"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="MfR7q9PK" Received: from compute7.internal (compute7.nyi.internal [10.202.2.48]) by mailfhigh.west.internal (Postfix) with ESMTP id E623C180013F; Tue, 7 May 2024 11:22:15 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute7.internal (MEProxy); Tue, 07 May 2024 11:22:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1715095335; x=1715181735; bh=3D0GaVF05UsiobMGqr5NYu1yNUERD1Uibyz1tRmG9fM=; b= Pw4ZbWsN/RUod8jQLaOL2WJEEMdQba8MbGhrUKPtnQbZtx04SKiJDdR5tJykk9bz +DUId1bJxG1RJ6xa82TX0dLJc+FbB1a3tZG4g7cfeIkBJe0FWUqyDWcxXdDEX6uH bSwz/zrM5gLY/CUbKX10SNWjbNJObCpdRx0Z+tGKwXohfOqww/nrUGBcW++Iexug uxRMWtqjiLzYi5fUm5xBXcDBZkKo03lI581lER7F5+NoEH4KMvRwbCJELmFxiqFv zwfIPvSLgdLU72Jqouxpmln3P8LAXd39JaVu94E7qTrKmv98ZA8bLyf7IFwWHBgR wVvt8T9g1hALJOmy6COVEw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1715095335; x= 1715181735; bh=3D0GaVF05UsiobMGqr5NYu1yNUERD1Uibyz1tRmG9fM=; b=M fR7q9PKO26AnH9L4CgQLtPo6e8M4TqPOAUFH3anG7GTblZALqimK/FofhuQeUvE9 DPmNokjWTX+yz6LiUHmXLCQvQhSfTWLFbkjBaFECtwRdYm+j8gY60Pr9R1Lv2OlU V/QRRi2clCwSEgGzi10atPdIyuFP3z+8RpTooF96quDhgT6JCJHYskYFWVCdX20G v92TIKjDJVsNLjMorwsykgzFs3NPFl0VUUyq0Dg/ZO2CkmHfndcr4Gompo0EDTYl ZH1UGwmypCWXgKAYn67LWEj4l1l+6fO0X6JhPL/4DTxnlgg8Kb+geWKFTCEL+LsQ 9Z1ldv6U6sqxRw+ALNcDA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvddvkedgkeehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdejnecuhfhrohhmpeflihgr gihunhcujggrnhhguceojhhirgiguhhnrdihrghnghesfhhlhihgohgrthdrtghomheqne cuggftrfgrthhtvghrnhepiefgleeivefgieejhfdvhfdvieeiudehvdevfeetveetieek tdfffedufffhgeehnecuffhomhgrihhnpehslhgvvghpvghrrdhssgenucevlhhushhtvg hrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehjihgrgihunhdrhigrnhhg sehflhihghhorghtrdgtohhm X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 7 May 2024 11:22:14 -0400 (EDT) From: Jiaxun Yang Date: Tue, 07 May 2024 16:22:01 +0100 Subject: [PATCH 3/3] MIPS: Loongson64: Implement PM suspend for LEFI firmware Precedence: bulk X-Mailing-List: linux-mips@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240507-loongson64-suspend-v1-3-534d92a4e09a@flygoat.com> References: <20240507-loongson64-suspend-v1-0-534d92a4e09a@flygoat.com> In-Reply-To: <20240507-loongson64-suspend-v1-0-534d92a4e09a@flygoat.com> To: Thomas Bogendoerfer , Huacai Chen Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Jiaxun Yang X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4701; i=jiaxun.yang@flygoat.com; h=from:subject:message-id; bh=pQz0w1yBfPHUBv/v0nbOyM9aMVNE+JcqduRqxVhK+yQ=; b=owGbwMvMwCHmXMhTe71c8zDjabUkhjQrd8VJbZHfa7xbO1M4Zy16/EJD0fPswri0fG3zug37P h4Vtq/oKGVhEONgkBVTZAkRUOrb0HhxwfUHWX9g5rAygQxh4OIUgInI9zP84cn/Ezpxy+q9R47n 9/zQDLJPDGxd4RoY2Vt+z7b2kVXmZIa/0hN2nbq1675885YLf+OT50Rn2ITHdMUkcHc33TN/a+X GBAA= X-Developer-Key: i=jiaxun.yang@flygoat.com; a=openpgp; fpr=980379BEFEBFBF477EA04EF9C111949073FC0F67 Implement PM suspend for LEFI firmware. Entering STR (Suspend to RAM) is as simple as save our context then go to a firmware vector. Wake is a little bit treaky as we need to setup some CP0 status first, which can be done with smp_slave_setup. Signed-off-by: Jiaxun Yang --- arch/mips/loongson64/Makefile | 2 +- arch/mips/loongson64/pm.c | 88 +++++++++--------------------------------- arch/mips/loongson64/sleeper.S | 17 ++++++++ 3 files changed, 36 insertions(+), 71 deletions(-) diff --git a/arch/mips/loongson64/Makefile b/arch/mips/loongson64/Makefile index e806280bbb85..cbba30dfddf5 100644 --- a/arch/mips/loongson64/Makefile +++ b/arch/mips/loongson64/Makefile @@ -8,7 +8,7 @@ obj-$(CONFIG_MACH_LOONGSON64) += cop2-ex.o dma.o \ obj-$(CONFIG_SMP) += smp.o obj-$(CONFIG_NUMA) += numa.o obj-$(CONFIG_RS780_HPET) += hpet.o -obj-$(CONFIG_SUSPEND) += pm.o +obj-$(CONFIG_SUSPEND) += pm.o sleeper.o obj-$(CONFIG_PCI_QUIRKS) += vbios_quirk.o obj-$(CONFIG_CPU_LOONGSON3_CPUCFG_EMULATION) += cpucfg-emul.o obj-$(CONFIG_SYSFS) += boardinfo.o diff --git a/arch/mips/loongson64/pm.c b/arch/mips/loongson64/pm.c index 7c8556f09781..5f0604af8f13 100644 --- a/arch/mips/loongson64/pm.c +++ b/arch/mips/loongson64/pm.c @@ -6,98 +6,46 @@ * Author: Wu Zhangjin */ #include -#include #include -#include #include #include -static unsigned int __maybe_unused cached_master_mask; /* i8259A */ -static unsigned int __maybe_unused cached_slave_mask; -static unsigned int __maybe_unused cached_bonito_irq_mask; /* bonito */ +asmlinkage void loongson_lefi_sleep(unsigned long sleep_addr); -void arch_suspend_disable_irqs(void) +static int lefi_pm_enter(suspend_state_t state) { - /* disable all mips events */ - local_irq_disable(); - -#ifdef CONFIG_I8259 - /* disable all events of i8259A */ - cached_slave_mask = inb(PIC_SLAVE_IMR); - cached_master_mask = inb(PIC_MASTER_IMR); - - outb(0xff, PIC_SLAVE_IMR); - inb(PIC_SLAVE_IMR); - outb(0xff, PIC_MASTER_IMR); - inb(PIC_MASTER_IMR); -#endif - /* disable all events of bonito */ - cached_bonito_irq_mask = LOONGSON_INTEN; - LOONGSON_INTENCLR = 0xffff; - (void)LOONGSON_INTENCLR; -} - -void arch_suspend_enable_irqs(void) -{ - /* enable all mips events */ - local_irq_enable(); -#ifdef CONFIG_I8259 - /* only enable the cached events of i8259A */ - outb(cached_slave_mask, PIC_SLAVE_IMR); - outb(cached_master_mask, PIC_MASTER_IMR); -#endif - /* enable all cached events of bonito */ - LOONGSON_INTENSET = cached_bonito_irq_mask; - (void)LOONGSON_INTENSET; -} - -/* - * Setup the board-specific events for waking up loongson from wait mode - */ -void __weak setup_wakeup_events(void) -{ -} - -void __weak mach_suspend(void) -{ -} - -void __weak mach_resume(void) -{ -} - -static int loongson_pm_enter(suspend_state_t state) -{ - mach_suspend(); - - mach_resume(); - - return 0; + switch (state) { + case PM_SUSPEND_MEM: + pm_set_suspend_via_firmware(); + loongson_lefi_sleep(loongson_sysconf.suspend_addr); + pm_set_resume_via_firmware(); + return 0; + default: + return -EINVAL; + } } -static int loongson_pm_valid_state(suspend_state_t state) +static int lefi_pm_valid_state(suspend_state_t state) { switch (state) { - case PM_SUSPEND_ON: - case PM_SUSPEND_STANDBY: case PM_SUSPEND_MEM: - return 1; - + return !!loongson_sysconf.suspend_addr; default: return 0; } } -static const struct platform_suspend_ops loongson_pm_ops = { - .valid = loongson_pm_valid_state, - .enter = loongson_pm_enter, +static const struct platform_suspend_ops lefi_pm_ops = { + .valid = lefi_pm_valid_state, + .enter = lefi_pm_enter, }; static int __init loongson_pm_init(void) { - suspend_set_ops(&loongson_pm_ops); + if (loongson_sysconf.fw_interface == LOONGSON_LEFI) + suspend_set_ops(&lefi_pm_ops); return 0; } diff --git a/arch/mips/loongson64/sleeper.S b/arch/mips/loongson64/sleeper.S new file mode 100644 index 000000000000..04874b9bf430 --- /dev/null +++ b/arch/mips/loongson64/sleeper.S @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2024, Jiaxun Yang + * Loongson EFI firmware sleeper routine + */ + +#include +#include + +#include + +LEAF(loongson_lefi_sleep) + SUSPEND_SAVE + jalr a0 + smp_slave_setup + RESUME_RESTORE_REGS_RETURN +END(loongson_lefi_sleep)