From patchwork Thu Apr 11 23:21:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Douglas Anderson X-Patchwork-Id: 10897059 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E3BF017EF for ; Thu, 11 Apr 2019 23:22:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C573A28B02 for ; Thu, 11 Apr 2019 23:22:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B467528E1E; Thu, 11 Apr 2019 23:22:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5679B28B02 for ; Thu, 11 Apr 2019 23:22:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject: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=B231d5DJynT5QM7q2rQdf85CZEI5xeL+UJ1Z+2FsQgI=; b=pUDrMBDTg6bbP2 vxm2lAWMW590naWTQcQOPOxF3haLMrXA4nsklNFIiGcfQewTZa9lj7y/V3AgV/72COyJIEtRyQdaW s9XfntI/PfnEKquIyNc9kgsUoowqblE8kzUEg65iN86oI8q9ztwFR9GKdLHyOpgvG4TUM9mRpJZzA sBd6r+t7RszNMyinIQEh4uEEn6LuwB0cubwlKgaMgb8u46ajL9VOQenDnKvNRd+8uGlhU9fDZWxsQ 7MhMvlIPz+nI9PZKVWmZgN9quRBn7uV9Mgl9b/PsgrlRg4CSus7OKNZFgxbGGxTfJH0LJiRkmylwY Wrjjslr/UcdHhbjfYXAA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hEj1w-0006ES-I8; Thu, 11 Apr 2019 23:22:52 +0000 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hEj1u-0006Cs-2V for linux-rockchip@lists.infradead.org; Thu, 11 Apr 2019 23:22:51 +0000 Received: by mail-pf1-x443.google.com with SMTP id 10so4177753pfo.5 for ; Thu, 11 Apr 2019 16:22:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=IkgB2Wu06Pd4z96v65dmkLjB7xuMujb7ajfyz6BRah8=; b=N4REOu2PSJZDy8Il/YjNSGOzdd42AawfVoDMOOt6HZp1ngpPBE6CA/t76JpBEwkXBl cAN8r2SyAJ1bLpt011QPNQ8lZnjDMCSXRqEMDkWXr0wmUKdmTRvB3oPXPk0Lz5Opngui 1WEL9Zwqmou9Zs2xgCH45HTwTWINT+X5NCU3E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=IkgB2Wu06Pd4z96v65dmkLjB7xuMujb7ajfyz6BRah8=; b=ZTWZG+q7k0KQ+YbY5BoL14JIeGAXfZ1aOQH+6rFDpT+0uGutoR1tHX84bUmnZmu+ZE 1V6/0MEtJdo5Eak9PX/UqBtjLyKzxzEwmWrbUB1FI4OMP/qVyUTz0IGJNDbxt95+SR8F H0qVfgupPVm44iMIfMRelQhEAy79qH5p/JAtJeefbg4pVNshXh87RspRghvjOKg8cKIN Q724WdMayEcYwnRvEypTRmYwE3IqcRQMMZ8uvRZzyDILxjtyardmfAWFwlCRXGWIh8Kn viJaZtosaeNdDTAJXXxyovkro3hmP5EjkX4Ilci46NCJYy8Ae6pBNhIASvf/oUtj8GE2 9Nbg== X-Gm-Message-State: APjAAAV+h46wMqBf/7sSU71qoXtrq1q+ANU8e/oipyYWYUdzXrKqBHGg gLWPA4JiUvZtePEpt7B9w7aS0g== X-Google-Smtp-Source: APXvYqwIprzlKW2nejCZ3fCZPI0yJSk+LmODFFzKDpPN5QTpEfwTCtsN7TwwhtNqpjpRD3mINi7aMg== X-Received: by 2002:a63:ed48:: with SMTP id m8mr35963091pgk.104.1555024968498; Thu, 11 Apr 2019 16:22:48 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:1:24fa:e766:52c9:e3b2]) by smtp.gmail.com with ESMTPSA id y20sm37288903pfe.188.2019.04.11.16.22.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Apr 2019 16:22:47 -0700 (PDT) From: Douglas Anderson To: Heiko Stuebner , Elaine Zhang Subject: [PATCH 1/5] clk: rockchip: Turn on "aclk_dmac1" for suspend Date: Thu, 11 Apr 2019 16:21:53 -0700 Message-Id: <20190411232157.55125-1-dianders@chromium.org> X-Mailer: git-send-email 2.21.0.392.gf8f6787159e-goog MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190411_162250_141092_B5EB2E77 X-CRM114-Status: GOOD ( 17.77 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: briannorris@chromium.org, amstan@chromium.org, Stephen Boyd , Michael Turquette , dbasehore@chromium.org, Douglas Anderson , linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, mka@chromium.org, ryandcase@chromium.org, Chris Zhong , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Experimentally it can be seen that going into deep sleep (specifically setting PMU_CLR_DMA and PMU_CLR_BUS in RK3288_PMU_PWRMODE_CON1) appears to fail unless "aclk_dmac1" is on. The failure is that the system never signals that it made it into suspend on the GLOBAL_PWROFF pin and it just hangs. NOTE that it's confirmed that it's the actual suspend that fails, not one of the earlier calls to read/write registers. Specifically if you comment out the "PMU_GLOBAL_INT_DISABLE" setting in rk3288_slp_mode_set() and then comment out the "cpu_do_idle()" call in rockchip_lpmode_enter() then you can exercise the whole suspend path without any crashing. This is currently not a problem with suspend upstream because there is no current way to exercise the deep suspend code. However, anyone trying to make it work will run into this issue. This was not a problem on shipping rk3288-based Chromebooks because those devices all ran on an old kernel based on 3.14. On that kernel "aclk_dmac1" appears to be left on all the time. There are several ways to skin this problem. A) We could add "aclk_dmac1" to the list of critical clocks and that apperas to work, but presumably that wastes power. B) We could keep a list of "struct clk" objects to enable at suspend time in clk-rk3288.c and use the standard clock APIs. C) We could make the rk3288-pmu driver keep a list of clocks to enable at suspend time. Presumably this would require a dts and bindings change. D) We could just whack the clock on in the existing syscore suspend function where we whack a bunch of other clocks. This is particularly easy because we know for sure that the clock's only parent ("aclk_cpu") is a critical clock so we don't need to do anything more than ungate it. In this case I have chosen D) because it seemed like the least work, but any of the other options would presumably also work fine. Signed-off-by: Douglas Anderson Reviewed-by: Elaine Zhang --- drivers/clk/rockchip/clk-rk3288.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/clk/rockchip/clk-rk3288.c b/drivers/clk/rockchip/clk-rk3288.c index 5a67b7869960..b245367393cd 100644 --- a/drivers/clk/rockchip/clk-rk3288.c +++ b/drivers/clk/rockchip/clk-rk3288.c @@ -859,6 +859,9 @@ static const int rk3288_saved_cru_reg_ids[] = { RK3288_CLKSEL_CON(10), RK3288_CLKSEL_CON(33), RK3288_CLKSEL_CON(37), + + /* We turn aclk_dmac1 on for suspend; this will restore it */ + RK3288_CLKGATE_CON(10), }; static u32 rk3288_saved_cru_regs[ARRAY_SIZE(rk3288_saved_cru_reg_ids)]; @@ -874,6 +877,14 @@ static int rk3288_clk_suspend(void) readl_relaxed(rk3288_cru_base + reg_id); } + /* + * Going into deep sleep (specifically setting PMU_CLR_DMA in + * RK3288_PMU_PWRMODE_CON1) appears to fail unless + * "aclk_dmac1" is on. + */ + writel_relaxed(1 << (12 + 16), + rk3288_cru_base + RK3288_CLKGATE_CON(10)); + /* * Switch PLLs other than DPLL (for SDRAM) to slow mode to * avoid crashes on resume. The Mask ROM on the system will