From patchwork Tue May 22 21:14:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 918567 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-tegra-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="aTagAb8C"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40r7hX60pTz9s0W for ; Wed, 23 May 2018 07:15:08 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752713AbeEVVPH (ORCPT ); Tue, 22 May 2018 17:15:07 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:53314 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752660AbeEVVPG (ORCPT ); Tue, 22 May 2018 17:15:06 -0400 Received: by mail-wm0-f68.google.com with SMTP id a67-v6so3378936wmf.3; Tue, 22 May 2018 14:15:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=htV+8Ng0/FQkWh0OiOUl0gwFuKZFx2RY4Tfr0cw4IMM=; b=aTagAb8C9hyWmffILsqpnaPnuWcbxrYyTx1eRhMcRG6gZTwCDpcsfcFT/nn9LNax1i 4s/hMNAtSi7e8f12J0r2aLJZcJ07IvrbEvujgBCPawAv1oJkfPJUdexBclJxsmhcSNEq xf85oXSiBa5JtrubxJYuGfXrCqxVuXxWIjNDzSnpdgofCUadEHAduPIJ/yTPC5KNd2Lf FApsIC7xdf89c4X/6io7KG4MnfUEO7lqZ6Sci1cEYgf3ESEoAsG348gsvdIqLa4RXMk1 IcvRf12Lb5q+2BbnL4LH5FxlrYQidtVZj7mKO0I4OW7CIqXceSL4h6EmcKhpmYnvpgpg p5rg== 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=htV+8Ng0/FQkWh0OiOUl0gwFuKZFx2RY4Tfr0cw4IMM=; b=PNMaBSLyyMy4u3/HlEseeiZunyW1JHLUbVV/yzqybAh1kPu1QFE/vfO/xYcFGETc5u RPTIyBzurskj/dUoHoHoo5ML4VLD7O4czBhRJyR7G7vNFCExGIGvXovMk2vJ1KVe45+I czk8zkv5kIWjUI8TptLFF9JSWOnoheh40/qInXsWzQRJ/emFTBHwVqLlH/bOiSkn/lTD LI55bXSYC9w9suGSfJ+MjvIotdaGR+bENERIrKRhrI8C1lG7m5HnSTeDgkOkAe4i6ndr nrlwxoJUyIsb6L8DEO0h3cOgq8bWfu0vnzPkaIpltvHE5yEa4WQjoeYZlx7d1NapCa6s uT8w== X-Gm-Message-State: ALKqPwfNpC18Sn8NG8znq5dCqgbvAPpx/Jg91aMIkTEpi/pYlqym8/tV gThS1e3S0/OnNXBWtCOdaxo= X-Google-Smtp-Source: AB8JxZoxq3uDhh+xGiCgaP7FI3+yHCRR5xd8JiJfa8h+vwtlvaiyGB+mexWI7gd/6QddRJkbzUaq9Q== X-Received: by 2002:a1c:f618:: with SMTP id w24-v6mr24180wmc.147.1527023705150; Tue, 22 May 2018 14:15:05 -0700 (PDT) Received: from localhost.localdomain (109-252-91-41.nat.spd-mgts.ru. [109.252.91.41]) by smtp.gmail.com with ESMTPSA id c7-v6sm889362wrm.87.2018.05.22.14.15.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 May 2018 14:15:04 -0700 (PDT) From: Dmitry Osipenko To: "Rafael J. Wysocki" , Viresh Kumar , Thierry Reding , Jonathan Hunter Cc: linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1] cpufreq: tegra20: Fix imbalanced clock enable count Date: Wed, 23 May 2018 00:14:20 +0300 Message-Id: <20180522211420.2006-1-digetx@gmail.com> X-Mailer: git-send-email 2.17.0 Sender: linux-tegra-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org Tegra20-cpufreq driver missed enabling the CPU clocks. This results in a clock-enable refcount disbalance on PLL_P <-> PLL_X reparent, causing PLL_X to get disabled while it shouldn't. Fix this by enabling the clocks on the driver probe. Signed-off-by: Dmitry Osipenko Acked-by: Viresh Kumar --- CPUFreq maintainers, Please take into account that this patch is made on top of my recent series of patches [0] "Clean up Tegra20 cpufreq driver" that was fully reviewed, but seems not applied yet. Let me know if you prefer to re-spin the [0], including this patch into the series. [0] https://patchwork.ozlabs.org/project/linux-tegra/list/?series=45321 drivers/cpufreq/tegra20-cpufreq.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/cpufreq/tegra20-cpufreq.c b/drivers/cpufreq/tegra20-cpufreq.c index 05f57dcd5215..ca5229265b60 100644 --- a/drivers/cpufreq/tegra20-cpufreq.c +++ b/drivers/cpufreq/tegra20-cpufreq.c @@ -176,6 +176,14 @@ static int tegra20_cpufreq_probe(struct platform_device *pdev) goto put_pll_x; } + err = clk_prepare_enable(cpufreq->pll_x_clk); + if (err) + goto put_pll_p; + + err = clk_prepare_enable(cpufreq->pll_p_clk); + if (err) + goto disable_pll_x; + cpufreq->dev = &pdev->dev; cpufreq->driver.get = cpufreq_generic_get; cpufreq->driver.attr = cpufreq_generic_attr; @@ -192,12 +200,16 @@ static int tegra20_cpufreq_probe(struct platform_device *pdev) err = cpufreq_register_driver(&cpufreq->driver); if (err) - goto put_pll_p; + goto disable_pll_p; platform_set_drvdata(pdev, cpufreq); return 0; +disable_pll_p: + clk_disable_unprepare(cpufreq->pll_p_clk); +disable_pll_x: + clk_disable_unprepare(cpufreq->pll_x_clk); put_pll_p: clk_put(cpufreq->pll_p_clk); put_pll_x: @@ -214,6 +226,8 @@ static int tegra20_cpufreq_remove(struct platform_device *pdev) cpufreq_unregister_driver(&cpufreq->driver); + clk_disable_unprepare(cpufreq->pll_p_clk); + clk_disable_unprepare(cpufreq->pll_x_clk); clk_put(cpufreq->pll_p_clk); clk_put(cpufreq->pll_x_clk); clk_put(cpufreq->cpu_clk);