From patchwork Thu Oct 24 20:18:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stefan Wahren X-Patchwork-Id: 13849679 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 A79B7D10360 for ; Thu, 24 Oct 2024 20:36:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Message-Id:Date:Subject:Cc:To: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=PtKUSt76TFKjgPtCZaStNyJsHewdsH1Gq+qwbgfGJx8=; b=Owhj8F7cbkGH3/xRLLxKgx7zUB TVJrX14rgPQvLLZPa5RmQ8XsFICw7FSpZ2FlqEbwbiTYqNMPUXlEYHJGmiMwKCWm0h+je0ayT2hVr HcbS0Bou//XlLolpIQgnzPoabMNzJugs/sPEXPmLzArWWxUrJkit6KXXNaQoeGqmxAPeGCbI2Q41s FRcJLaU4A5XWrOXkJ4BMYiMOtTMGkr2maiVSrEbNByVhzK7m+NJULdhHMJYgDIIKxjFdRfnPoyH8Y /Xcd6cxj6jznGecJk4mvghma5b2BaZkGTITi6L6ZUho6SBUfx7yNHTXG7+KJSCo2cRTrG3869UEmm D6BiqcYQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t44Yw-00000001kKy-3W6k; Thu, 24 Oct 2024 20:36:06 +0000 Received: from mout.gmx.net ([212.227.15.19]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t44IJ-00000001iBO-41LI for linux-arm-kernel@lists.infradead.org; Thu, 24 Oct 2024 20:19:00 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.net; s=s31663417; t=1729801124; x=1730405924; i=wahrenst@gmx.net; bh=PtKUSt76TFKjgPtCZaStNyJsHewdsH1Gq+qwbgfGJx8=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:Message-Id: MIME-Version:Content-Type:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=rlrONhmwbFBMDJKoPv7/3S8ucoq8BpWiyXHArNOD0qLSPPtmuOdxfF5EgxBpuKW/ 9J8DJigZKKNrYZEXIRBe3yNMRK7QZ/3IsDgwdCCCzu9qZ/mlk4MyXa2VX6wJMGysh /QzYMnsQWwCIefYg+hkM3LDl1aWPYJUPJBg5daPca9ebtbXurkoK+g7NOCNi9R1gq MrSRcmaGX7uAwM39FYWcpwLG/7T1q9VujvmfSydAaskfkYtE3wW93Z6MsYMUGl8Pp +zJQqun4VaiD5Lswu3XuSLtZmBHbkmfpfAb5nIOcmV5Ota2hk1b76GOGtU56pZ2vo DvQAy9UWLM8c+dRdZw== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from stefanw-SCHENKER ([37.4.248.43]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1N6KUd-1txFAw4ArR-011077; Thu, 24 Oct 2024 22:18:44 +0200 From: Stefan Wahren To: Russell King , Florian Fainelli , Ray Jui , Scott Branden , Vinod Koul , Ulf Hansson , Minas Harutyunyan , Greg Kroah-Hartman Cc: Lukas Wunner , Peter Robinson , linux-arm-kernel@lists.infradead.org, kernel-list@raspberrypi.com, bcm-kernel-feedback-list@broadcom.com, dmaengine@vger.kernel.org, linux-mmc@vger.kernel.org, linux-usb@vger.kernel.org, Stefan Wahren Subject: [PATCH V4 0/9] ARM: bcm2835: Implement initial S2Idle for Raspberry Pi Date: Thu, 24 Oct 2024 22:18:28 +0200 Message-Id: <20241024201837.79927-1-wahrenst@gmx.net> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Provags-ID: V03:K1:rosCn8TgOlNX2wametBtbGfMR3eZDUEXXPwiriDu32upykHIbic fmHLinS3U/6xb+TnrijjccDbOy+PuE0qo0vcUD9UtfC9SmhV9YbRTPes6pCbNTV1hbWQboi xmultiPaTtGtOyJy61yd0l119nB0C0do3BVrwBk82iyWX3nTK+yiTZfrGVYxqo9ejRvrGab 6EPxyxEReps4d5ikwEaWA== UI-OutboundReport: notjunk:1;M01:P0:YfEKRit8jiw=;FeQV+C8u75T71joCCUHYJpSuo6j dVoyWYKoS64cdQrsUzi0FsUvSdGAk/T1M/7fwBroYoNSLEa8CvbGkhN2+kK91aHnbaEJP1cc3 +6ExxHSs9l3GqKSR1Iiu2XQ3nR5gqVuYOAhcLUdqeLwlyvCWr5lhUMOF3GdImaACDmHdFXHqm 8KVM2wa7osHrv0rZ7qIHFwu1SKcDbxL8i/escMhPsDrqWQtqDH1WSiCOgM1GeLsOYtUeW4qHT 70fW0CPWf/gTkkk7cs2UY2V0DYTqoqqO9g1DLnoI48e2b9kjwa9WADZ1JWpJ7iQwq77ApHpYl qV3zzPup9/LVMrMG1CTokPj46b3+jGAwjqMvTtrMRAtYgfnqHLyvWwuT4hO6wp2V5Q6qd8pbd b5fK328iuukzfE+JcB5DEc/QyvfdKGoska/uGfCRQzIRry0IXOK+LOj7T9SDyU9SgxxuVhjT7 og0TKRETaSmIHqkL3TEyEmPqJRevP2Hd3qphEJGPHj92gjF3WrZejLVHD9VjBhF4ReXJ+TLFA OrKqYMwBBHk9eeuBMMskVvZfUn4Faj3PyjM7r8X7S7c1YaK2Uwv34TGLQATfujU8laIrFHnrX M09gxJ2Q3L+Tt8MpImar/ZFxBalNlRLwygr0N5KMGYoJRNm44qo8N9deqlqEYEuaPFY3yiTIe hYz/yvcwu2HRRPi3SRchyJs3n8YcDPRlQl4j3dUGIUprkDkShRDP+AyjEV49CKwE5TZ5vEP35 t6xQN8THJqHtCSsQNADz33RFMbILsmzCSXtn34T9YzAHWiHb3l+ahvRs265N+Ct8L4gNhU0EF oWEiNGofT+7kXgM7XfobRyDA== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241024_131856_464449_C16CFE61 X-CRM114-Status: GOOD ( 19.99 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This series implement the initial S2Idle support for the Raspberry Pi, which was a long time on my TODO list [1]. The changes allow to suspend and resume the Raspberry Pi via debug UART. The focus is on the BCM2835 SoC, because it's less complex than its successors and have enough documentation. Now the VC4 part has been split from the series [4], because of some issues in that part. Cherry-picking of patches should be fine. Test steps: - configure debug console (pl011 or mini UART) as wakeup source - send system to idle state echo freeze > /sys/power/state - wakeup system by console traffic The clock gating must be restored, because otherwise we have a regression on Raspberry Pi 3 B+ . Luckily the disabling of clock gating isn't necessary anymore. Thanks to the rest of the DWC2 patches which based on an idea of Doug Anderson. The USB domain is now powered down and the USB devices are still usable after resume. There might be room for improvements, but at least the system won't freeze forever as before. Here are some figures for the Raspberry Pi 1 (without any devices connected except of a debug UART): running but CPU idle = 1.67 W S2Idle = 1.33 W In comparison with HDMI & USB keyboard connected (but neither active nor wakeup source): running but CPU idle = 1.82 W S2Idle = 1.33 W The series has been successfully tested on the following platforms: Raspberry Pi 1 B Raspberry Pi 3 B+ Changes in V4: - added Reviewed-by from Doug - dropped applied VC4 improvement patches - fix DWC2 register backup - add revert because of Raspberry Pi 3B+ regression - add suspend/resume support for DMA & eMMC to be on the safe side Changes in V3: - added Reviewed-by & Acked-by from Florian & Maíra - dropped applied pmdomain & bcm2835aux patches - address comments by Maíra (patch 3 & 5) - replace old USB recovery patch with canary approach [3], which should work with other platforms Changes in V2: - rebased against todays mainline - added Reviewed-by from Florian - added Acked-by from Minas - dropped "irqchip/bcm2835: Enable SKIP_SET_WAKE and MASK_ON_SUSPEND" because it has been applied by Thomas Gleixner - dropped "pmdomain: raspberrypi-power: Avoid powering down USB" because this workaround has been replaced by patch 14 - use drm_err_once instead of DRM_ERROR and return connector_status_unknown in patch 6 - add new patch in order to clean-up all DRM_ERROR - add new patch to improve raspberrypi-power logging - add new patch to simplify V3D clock retrieval - add new patch 5 to avoid power down of wakeup devices - add new patch 12 to avoid confusion about ACPI ID of BCM283x USB - add new patch 8 & 10 which address the problem that HDMI is not functional after s2idle - add more links and fix typo in patch 13 - add new WIP patch 14 which recover DWC2 register after power down - take care of UART clock in patch 15 as commented by Florian - use SYSTEM_SLEEP_PM_OPS in patch 15 [1] - https://github.com/lategoodbye/rpi-zero/issues/9 [2] - https://bugzilla.redhat.com/show_bug.cgi?id=2283978 [3] - https://lore.kernel.org/linux-usb/CAD=FV=W7sdi1+SHfhY6RrjK32r8iAGe4w+O_u5Sp982vgBU6EQ@mail.gmail.com/ [4] - https://lore.kernel.org/dri-devel/20241003124107.39153-1-wahrenst@gmx.net/ Stefan Wahren (9): Revert "usb: dwc2: Skip clock gating on Broadcom SoCs" dmaengine: bcm2835-dma: add suspend/resume pm support mmc: bcm2835: Fix type of current clock speed mmc: bcm2835: Introduce proper clock handling mmc: bcm2835: add suspend/resume pm support usb: dwc2: gadget: Introduce register restore flags usb: dwc2: Refactor backup/restore of registers usb: dwc2: Implement recovery after PM domain off ARM: bcm2835_defconfig: Enable SUSPEND arch/arm/configs/bcm2835_defconfig | 2 - drivers/dma/bcm2835-dma.c | 30 ++++++++ drivers/mmc/host/bcm2835.c | 56 +++++++++++--- drivers/usb/dwc2/core.c | 1 + drivers/usb/dwc2/core.h | 23 +++++- drivers/usb/dwc2/gadget.c | 116 +++++++++++++++-------------- drivers/usb/dwc2/hcd.c | 99 ++++++++++++------------ drivers/usb/dwc2/params.c | 1 - drivers/usb/dwc2/platform.c | 38 ++++++++++ 9 files changed, 245 insertions(+), 121 deletions(-) --- 2.34.1