From patchwork Tue Feb 14 21:01:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 9572891 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 52E2460578 for ; Tue, 14 Feb 2017 21:02:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 41199283F6 for ; Tue, 14 Feb 2017 21:02:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 35F1B2840E; Tue, 14 Feb 2017 21:02:30 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.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 A4C4C283F6 for ; Tue, 14 Feb 2017 21:02:29 +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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=j4fVwgPfaYQvmHQkZDWqm13UVCtaPUpYrXp/YxjG2TQ=; b=TEn U8I3JWdZ8vFhqKZzw0/3RoDl6qbOgJEAn/vN0DrP8MqnTznn68/AjHn4gmvZZm4T5JxFN61wI4Qmj wiZ91XBNnz9/7K4EJGVPufDTu4djLBdWCcHH8ikSJAZmQPNyuJMxMraP23hp5Klp5SoAa2sW6AiGJ WHKhZCwACxfT/AakI5J+HeVwmwNqpy3rG2Yty2FedRjw+WuVDpiwFTO5EaaorF+w9HlQhc2nW/PSs gshghrx5AY6lhhkHYEOPpbDo1VIDamkeUQKEBIpBVz7ZcG8uZ5YcZZwkd61Vc3rdjHZ84gSmXRjNE 0rUqsElBQGs4f7MLNzNTSUk1VDvX70g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cdkEz-0000Ct-Cb; Tue, 14 Feb 2017 21:02:25 +0000 Received: from mail-oi0-x229.google.com ([2607:f8b0:4003:c06::229]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cdkEu-000099-FZ for linux-arm-kernel@lists.infradead.org; Tue, 14 Feb 2017 21:02:23 +0000 Received: by mail-oi0-x229.google.com with SMTP id w204so77679096oiw.0 for ; Tue, 14 Feb 2017 13:01:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id; bh=rHhsSIOGh8j60Zp/rmS3MocLJ3ywg6IGUN4KhzPu/yc=; b=hGxpuPbvN5aIyrthgKpa+o9CcFEE99GJ0PYly5ukuIYP//kgngBuD+dmrMPXRhboSA SxFAjdLClDjFqmuZJ5gBxcvzlWtRYJeQTGgMHM0E2Akj77t+dwvFL5pQ+21eWJR1W+Cs QWs79Aj96/iNNF5dnX5X1+wtPTnPdd+i99ApE= 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; bh=rHhsSIOGh8j60Zp/rmS3MocLJ3ywg6IGUN4KhzPu/yc=; b=BWx39ElDZmjaBOtS5xsN1c4JYK+qr6EpVRXSQOZ93otJVrOsd64abqGcqPLhRgHLdG WWWqBx7BKwDqci97wsnbQHaZAGzCijmH0VUKtb8Y2cotnspVHsRwCn2EZBN2zTSAdJjX hfuetlN7EAELXIu96c2jTu8cDrdm/G7F0d9TbhD4qpzBGfRRFBI+M3E9dFScuHsUhc12 O/rJnqMn/Dz/jvmz3ipMHshmuhMUmt5629/P8mHpZjpfN0jcgZ+KPV9GL+Jy/+KFNF1T de3BtWT9Uf7wm7iGQUpXRg0Y5CxpIN0eT2Nfbidn5tZxoKW2qPpUFU/pvie6YHFpnu07 q+ng== X-Gm-Message-State: AMke39mE7KxCmEGT3uOrm78awcHGGVJhQNF47aO2fjzblCcRlJmYg9qQ/ls7tzn9xixwz+Lf X-Received: by 10.84.133.163 with SMTP id f32mr38439409plf.64.1487106118751; Tue, 14 Feb 2017 13:01:58 -0800 (PST) Received: from tictac.mtv.corp.google.com ([172.22.65.76]) by smtp.gmail.com with ESMTPSA id a1sm2921887pgn.51.2017.02.14.13.01.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 14 Feb 2017 13:01:56 -0800 (PST) From: Douglas Anderson To: Heiko Stuebner Subject: [PATCH] clk: rockchip: Set "ignore unused" for PMU M0 clocks on rk3399 Date: Tue, 14 Feb 2017 13:01:14 -0800 Message-Id: <20170214210114.5846-1-dianders@chromium.org> X-Mailer: git-send-email 2.11.0.483.g087da7b7c-goog X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170214_130220_666256_7F16E36F X-CRM114-Status: GOOD ( 13.18 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: hl@rock-chips.com, zhengxing@rock-chips.com, mturquette@baylibre.com, dbasehore@chromium.org, sboyd@codeaurora.org, Douglas Anderson , linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, jwerner@chromium.org, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The PMU Cortex M0 on rk3399 is intended to be used for things like DDRFreq transitions, suspend/resume, and other things that are the purview of ARM Trusted Firmware and not the kernel. As such, the kernel shouldn't be messing with the clocks. Add CLK_IGNORE_UNUSED to these clocks. Without this change, the following was observed on a Chromebook with a rk3399 (using not-yet-upstream ARM Trusted Firmware code and not-yet-upstream kernel code based on kernel-4.4): 1. We init the clock framework. 2. We start up "DDRFreq", which causes ATF to occasionally fire up the M0 for transitions. Each time ATF fires up the M0 it will turn on these clocks and each time it is done it will turn them off. 3. We finally get to the the part of the kernel that calls clk_disable_unused() and we disables the clocks. You can see the race above. Basically everything is fine as long as ARM Trusted Firmware isn't starting up the M0 at exactly the same time that the kernel is disabling unused clocks. ...but if the race happens then we go boom. Signed-off-by: Douglas Anderson --- drivers/clk/rockchip/clk-rk3399.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/clk/rockchip/clk-rk3399.c b/drivers/clk/rockchip/clk-rk3399.c index 73121b144634..fa3cbef08776 100644 --- a/drivers/clk/rockchip/clk-rk3399.c +++ b/drivers/clk/rockchip/clk-rk3399.c @@ -1477,10 +1477,10 @@ static struct rockchip_clk_branch rk3399_clk_pmu_branches[] __initdata = { GATE(PCLK_UART4_PMU, "pclk_uart4_pmu", "pclk_pmu_src", 0, RK3399_PMU_CLKGATE_CON(1), 14, GFLAGS), GATE(PCLK_WDT_M0_PMU, "pclk_wdt_m0_pmu", "pclk_pmu_src", 0, RK3399_PMU_CLKGATE_CON(1), 15, GFLAGS), - GATE(FCLK_CM0S_PMU, "fclk_cm0s_pmu", "fclk_cm0s_src_pmu", 0, RK3399_PMU_CLKGATE_CON(2), 0, GFLAGS), - GATE(SCLK_CM0S_PMU, "sclk_cm0s_pmu", "fclk_cm0s_src_pmu", 0, RK3399_PMU_CLKGATE_CON(2), 1, GFLAGS), - GATE(HCLK_CM0S_PMU, "hclk_cm0s_pmu", "fclk_cm0s_src_pmu", 0, RK3399_PMU_CLKGATE_CON(2), 2, GFLAGS), - GATE(DCLK_CM0S_PMU, "dclk_cm0s_pmu", "fclk_cm0s_src_pmu", 0, RK3399_PMU_CLKGATE_CON(2), 3, GFLAGS), + GATE(FCLK_CM0S_PMU, "fclk_cm0s_pmu", "fclk_cm0s_src_pmu", CLK_IGNORE_UNUSED, RK3399_PMU_CLKGATE_CON(2), 0, GFLAGS), + GATE(SCLK_CM0S_PMU, "sclk_cm0s_pmu", "fclk_cm0s_src_pmu", CLK_IGNORE_UNUSED, RK3399_PMU_CLKGATE_CON(2), 1, GFLAGS), + GATE(HCLK_CM0S_PMU, "hclk_cm0s_pmu", "fclk_cm0s_src_pmu", CLK_IGNORE_UNUSED, RK3399_PMU_CLKGATE_CON(2), 2, GFLAGS), + GATE(DCLK_CM0S_PMU, "dclk_cm0s_pmu", "fclk_cm0s_src_pmu", CLK_IGNORE_UNUSED, RK3399_PMU_CLKGATE_CON(2), 3, GFLAGS), GATE(HCLK_NOC_PMU, "hclk_noc_pmu", "fclk_cm0s_src_pmu", CLK_IGNORE_UNUSED, RK3399_PMU_CLKGATE_CON(2), 5, GFLAGS), };