From patchwork Mon Apr 20 12:58:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 47342 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E91562121F for ; Mon, 20 Apr 2015 13:02:42 +0000 (UTC) Received: by lbbrr5 with SMTP id rr5sf37313751lbb.3 for ; Mon, 20 Apr 2015 06:02:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id :in-reply-to:references:cc:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version :content-type:content-transfer-encoding:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list; bh=QiSgjld8cNK+6YqAu6M3tpHofyLGxk4FYDJFZzuYQuo=; b=aQsAt2oJgK6r7o0lDoZKYw7IJtjDGFKqZkPshnzMxIK2uJ5GwEAt2dQhQXynngQqUA N+L9BWCQrp9NMut5crfcmjqVouEr7r/ZTFhTgnQd0lqvzr7Yr9IBz1/1LB4g33lSPKlR Tw4X//UnMjj2Xfc2ZyTEICaClD4Yq/dHhzDDoJKnv7lvycu0/W8wATkOwrYO2/MRPjPV 1BJbah20S/hqD2enfgeum2MqTTvXZyb5SKMR20d+kKBR9+QsLnxfo/rcou4g+E9Za2jY bsUJcCfR8aKUdZsOaB3Wo+IMaeuPVo6pU0aKyKZ2RdDT1KbYdueUVBc1eXPVLr+hEY1k AoVQ== X-Gm-Message-State: ALoCoQkN34x2BNmCyWjtJHtajS3Y+nhH77iML9cVCb450YyRczyXWpRQ+s+Z+maHeLjHvd/0Dd8h X-Received: by 10.152.19.67 with SMTP id c3mr7122204lae.7.1429534961843; Mon, 20 Apr 2015 06:02:41 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.182.228 with SMTP id eh4ls757785lac.45.gmail; Mon, 20 Apr 2015 06:02:41 -0700 (PDT) X-Received: by 10.112.83.135 with SMTP id q7mr15743729lby.13.1429534961698; Mon, 20 Apr 2015 06:02:41 -0700 (PDT) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com. [209.85.215.49]) by mx.google.com with ESMTPS id l9si14964348lam.73.2015.04.20.06.02.41 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Apr 2015 06:02:41 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by labbd9 with SMTP id bd9so126183350lab.2 for ; Mon, 20 Apr 2015 06:02:41 -0700 (PDT) X-Received: by 10.152.87.204 with SMTP id ba12mr15852229lab.35.1429534961555; Mon, 20 Apr 2015 06:02:41 -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.67.65 with SMTP id l1csp7097lbt; Mon, 20 Apr 2015 06:02:40 -0700 (PDT) X-Received: by 10.68.247.168 with SMTP id yf8mr27413311pbc.168.1429534959711; Mon, 20 Apr 2015 06:02:39 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id k3si28239149pdr.65.2015.04.20.06.02.38 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Apr 2015 06:02:39 -0700 (PDT) Received-SPF: none (google.com: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YkBJk-0003LW-Fe; Mon, 20 Apr 2015 13:00:52 +0000 Received: from mail-lb0-f181.google.com ([209.85.217.181]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YkBIg-0001qr-Jj for linux-arm-kernel@lists.infradead.org; Mon, 20 Apr 2015 12:59:47 +0000 Received: by lbbuc2 with SMTP id uc2so129793825lbb.2 for ; Mon, 20 Apr 2015 05:59:24 -0700 (PDT) X-Received: by 10.112.126.136 with SMTP id my8mr15458764lbb.18.1429534764183; Mon, 20 Apr 2015 05:59:24 -0700 (PDT) Received: from localhost.localdomain ([85.235.11.236]) by mx.google.com with ESMTPSA id n10sm4295457laa.40.2015.04.20.05.59.20 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Apr 2015 05:59:23 -0700 (PDT) From: Linus Walleij To: linux-arm-kernel@lists.infradead.org, Mathieu Poirier Subject: [PATCH 04/13 v2] coresight: tpiu: let runtime PM handle core clock Date: Mon, 20 Apr 2015 14:58:57 +0200 Message-Id: <1429534746-3068-4-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1429534746-3068-1-git-send-email-linus.walleij@linaro.org> References: <1429534746-3068-1-git-send-email-linus.walleij@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150420_055946_852112_3C4E4CC8 X-CRM114-Status: GOOD ( 16.70 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.217.181 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.217.181 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders Cc: Ulf Hansson , "Rafael J. Wysocki" , Russell King , Linus Walleij , Trollkarlen Marklund X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: linus.walleij@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.49 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 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 uprepare 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 --- ChangeLog v1->v2: - Rebased on the coresight git tree. - Added Ulf's review tag. --- 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)