From patchwork Tue May 19 16:55:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 48747 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B0F3E2121F for ; Tue, 19 May 2015 16:56:22 +0000 (UTC) Received: by wivs14 with SMTP id s14sf10055137wiv.1 for ; Tue, 19 May 2015 09:56:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=8UgUYMOD45qklgxPoJnTVONUayXcQwMLzXh5jQZ2ofs=; b=U3BfgAV/TBGmr+LG7dXkxs3ooDrK0eejPE3QRjJzRec0uNmAgclJ5+ATRD9WkKf7sC ZnsUk8jny9DUfVUKnVTwYZqyJ6ERPBlV5TuCfaigWUa03L3kHQgx3IkK2GnA5dj0LcbM Bgajt1ALIDyRJvvDE40C9kUM3+dNVeW1V4yaGm9hw3pPopxEQJEgiVqhV/gEwmbxG2z1 8mdpdy+LpzCe3Cb1qNCuVrRYhfi16O3S6Ue1MTw+zoLdavPq+4d2AOrcJAWJ0YE9VPnv pzzsw4FWqMQ9ViTj1zoLrosenI1hhiPef+lS7G9CjREUGcIk/WrmgsnopXjqERnscC0N 4kpQ== X-Gm-Message-State: ALoCoQmtbKCGhuKxQlBm8V0lR2zX9woQLpxp/qasvl5cTdXhaUI5yhdSK6bacIrGjA7MSaNX2QWE X-Received: by 10.180.106.10 with SMTP id gq10mr14724474wib.0.1432054582012; Tue, 19 May 2015 09:56:22 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.27.10 with SMTP id p10ls94084lag.29.gmail; Tue, 19 May 2015 09:56:21 -0700 (PDT) X-Received: by 10.112.204.104 with SMTP id kx8mr22194043lbc.72.1432054581811; Tue, 19 May 2015 09:56:21 -0700 (PDT) Received: from mail-la0-f54.google.com (mail-la0-f54.google.com. [209.85.215.54]) by mx.google.com with ESMTPS id lm6si9419310lac.29.2015.05.19.09.56.21 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 May 2015 09:56:21 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.54 as permitted sender) client-ip=209.85.215.54; Received: by laat2 with SMTP id t2so33801898laa.1 for ; Tue, 19 May 2015 09:56:21 -0700 (PDT) X-Received: by 10.112.161.226 with SMTP id xv2mr23008038lbb.106.1432054581683; Tue, 19 May 2015 09:56:21 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp938454lbb; Tue, 19 May 2015 09:56:20 -0700 (PDT) X-Received: by 10.70.136.67 with SMTP id py3mr56002487pdb.112.1432054579818; Tue, 19 May 2015 09:56:19 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w2si22164137pde.152.2015.05.19.09.56.12; Tue, 19 May 2015 09:56:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751817AbbESQ4B (ORCPT + 28 others); Tue, 19 May 2015 12:56:01 -0400 Received: from mail-pd0-f169.google.com ([209.85.192.169]:33759 "EHLO mail-pd0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750923AbbESQzr (ORCPT ); Tue, 19 May 2015 12:55:47 -0400 Received: by pdbqa5 with SMTP id qa5so33047596pdb.0 for ; Tue, 19 May 2015 09:55:47 -0700 (PDT) X-Received: by 10.70.101.200 with SMTP id fi8mr55509995pdb.161.1432054547114; Tue, 19 May 2015 09:55:47 -0700 (PDT) Received: from t430.cg.shawcable.net ([184.64.168.246]) by mx.google.com with ESMTPSA id rx6sm11817453pbc.54.2015.05.19.09.55.45 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 19 May 2015 09:55:46 -0700 (PDT) From: Mathieu Poirier To: gregkh@linuxfoundation.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, zhang.chunyan@linaro.org, kaixu.xia@linaro.org, mathieu.poirier@linaro.org Subject: [PATCH 05/16] coresight: tpiu: let runtime PM handle core clock Date: Tue, 19 May 2015 10:55:10 -0600 Message-Id: <1432054521-24807-6-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1432054521-24807-1-git-send-email-mathieu.poirier@linaro.org> References: <1432054521-24807-1-git-send-email-mathieu.poirier@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: mathieu.poirier@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.54 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Linus Walleij This uses runtime PM to manage the PCLK ("amba_pclk") instead of screwing around with the framework by going in and taking a copy from the amba device. The amba bus core will unprepare and disable the clock when the device is unused when CONFIG_PM is selected, else the clock will be always on. Prior to this patch, as the AMBA primecell bus code enables the PCLK, it would be left on after probe as the clk_prepare_enable() and clk_disable_unprepare() was called and thus just increase and decreas the refcount by one, without it reaching zero and actually disabling the clock. Now the runtime PM callbacks will make sure the PCLK is properly disabled after probe. Reviewed-by: Ulf Hansson Signed-off-by: Linus Walleij Signed-off-by: Mathieu Poirier --- drivers/hwtracing/coresight/coresight-tpiu.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-tpiu.c b/drivers/hwtracing/coresight/coresight-tpiu.c index 88b6b0c32538..688ba937069e 100644 --- a/drivers/hwtracing/coresight/coresight-tpiu.c +++ b/drivers/hwtracing/coresight/coresight-tpiu.c @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include #include @@ -51,13 +51,11 @@ * @base: memory mapped base address for this component. * @dev: the device entity associated to this component. * @csdev: component vitals needed by the framework. - * @clk: the clock this component is associated to. */ struct tpiu_drvdata { void __iomem *base; struct device *dev; struct coresight_device *csdev; - struct clk *clk; }; static void tpiu_enable_hw(struct tpiu_drvdata *drvdata) @@ -72,12 +70,8 @@ static void tpiu_enable_hw(struct tpiu_drvdata *drvdata) static int tpiu_enable(struct coresight_device *csdev) { struct tpiu_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); - int ret; - - ret = clk_prepare_enable(drvdata->clk); - if (ret) - return ret; + pm_runtime_get_sync(csdev->dev.parent); tpiu_enable_hw(drvdata); dev_info(drvdata->dev, "TPIU enabled\n"); @@ -101,8 +95,7 @@ static void tpiu_disable(struct coresight_device *csdev) struct tpiu_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); tpiu_disable_hw(drvdata); - - clk_disable_unprepare(drvdata->clk); + pm_runtime_put(csdev->dev.parent); dev_info(drvdata->dev, "TPIU disabled\n"); } @@ -118,7 +111,6 @@ static const struct coresight_ops tpiu_cs_ops = { static int tpiu_probe(struct amba_device *adev, const struct amba_id *id) { - int ret; void __iomem *base; struct device *dev = &adev->dev; struct coresight_platform_data *pdata = NULL; @@ -148,15 +140,10 @@ static int tpiu_probe(struct amba_device *adev, const struct amba_id *id) drvdata->base = base; - drvdata->clk = adev->pclk; - ret = clk_prepare_enable(drvdata->clk); - if (ret) - return ret; - /* Disable tpiu to support older devices */ tpiu_disable_hw(drvdata); - clk_disable_unprepare(drvdata->clk); + pm_runtime_put(&adev->dev); desc = devm_kzalloc(dev, sizeof(*desc), GFP_KERNEL); if (!desc)