From patchwork Wed Sep 10 13:43:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 37206 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f72.google.com (mail-yh0-f72.google.com [209.85.213.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9427C20491 for ; Wed, 10 Sep 2014 13:43:49 +0000 (UTC) Received: by mail-yh0-f72.google.com with SMTP id f73sf11433906yha.3 for ; Wed, 10 Sep 2014 06:43:49 -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:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=nm2aezg8YmG3knRodXBNU13aCyI7RnGBwNZ9qMpBnOg=; b=Nni2oYqYm7gUkC9tDAAcUjXsn0xjwJhYQwqJKiYoNKAHZdZ5S0jBPBkSkhRHJUhNu+ biJWsvPvCCmRdNSSdT25wChTlPGwRHKk1R50iEYcvWP0qzpp2Xom0Z7uBsnQBwKPyfXd mspGqc6nMmaQeLk7BIXbmxX9tnMfVgLKJ7HmqguMzYpnI1W9qF3LOQVdlXpRWwOEI0F3 CakBGzaNA7H5aZR7T4ztRBtZdW1ixrOH8kVN2rnBs6S697/GiDu+B3/EYoD+ngEKZzUl jcjm68MXNoplSlwul9AxuLfH5aQ6xqz3Z/IFzKxjjUjFoeSoHUM/VznAk2MCWvhpBMe6 Zu9Q== X-Gm-Message-State: ALoCoQlIF6R60JEFaak+eLtRXu9SgAgv/MqG3jhQ8Q//mJ+zEbhUKL3crdwCGhWCWU+YXo5vzAKV X-Received: by 10.52.170.204 with SMTP id ao12mr25755532vdc.2.1410356629405; Wed, 10 Sep 2014 06:43:49 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.84.210 with SMTP id l76ls1209359qgd.19.gmail; Wed, 10 Sep 2014 06:43:49 -0700 (PDT) X-Received: by 10.220.74.10 with SMTP id s10mr637995vcj.61.1410356629241; Wed, 10 Sep 2014 06:43:49 -0700 (PDT) Received: from mail-vc0-f169.google.com (mail-vc0-f169.google.com [209.85.220.169]) by mx.google.com with ESMTPS id of10si6303853vcb.105.2014.09.10.06.43.49 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 10 Sep 2014 06:43:49 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.169 as permitted sender) client-ip=209.85.220.169; Received: by mail-vc0-f169.google.com with SMTP id ik5so2051817vcb.14 for ; Wed, 10 Sep 2014 06:43:49 -0700 (PDT) X-Received: by 10.220.97.5 with SMTP id j5mr36559406vcn.16.1410356629169; Wed, 10 Sep 2014 06:43:49 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.221.45.67 with SMTP id uj3csp439619vcb; Wed, 10 Sep 2014 06:43:48 -0700 (PDT) X-Received: by 10.180.207.100 with SMTP id lv4mr9002279wic.53.1410356628269; Wed, 10 Sep 2014 06:43:48 -0700 (PDT) Received: from mail-wg0-f44.google.com (mail-wg0-f44.google.com [74.125.82.44]) by mx.google.com with ESMTPS id r5si20709719wjz.159.2014.09.10.06.43.47 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 10 Sep 2014 06:43:48 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 74.125.82.44 as permitted sender) client-ip=74.125.82.44; Received: by mail-wg0-f44.google.com with SMTP id y10so4152720wgg.27 for ; Wed, 10 Sep 2014 06:43:47 -0700 (PDT) X-Received: by 10.194.216.74 with SMTP id oo10mr2502854wjc.126.1410356627782; Wed, 10 Sep 2014 06:43:47 -0700 (PDT) Received: from localhost.localdomain ([85.235.11.236]) by mx.google.com with ESMTPSA id k5sm2500835wiv.21.2014.09.10.06.43.46 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 10 Sep 2014 06:43:46 -0700 (PDT) From: Ulf Hansson To: Mauro Carvalho Chehab , Philipp Zabel , Kamil Debski Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Ulf Hansson Subject: [PATCH] [media] coda: Improve runtime PM support Date: Wed, 10 Sep 2014 15:43:33 +0200 Message-Id: <1410356613-16811-1-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.9.1 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ulf.hansson@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.220.169 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , For several reasons it's good practice to leave devices in runtime PM active state while those have been probed. In this cases we also want to prevent the device from going inactive, until the firmware has been completely installed, especially when using a PM domain. Signed-off-by: Ulf Hansson --- drivers/media/platform/coda/coda-common.c | 42 ++++++++----------------------- 1 file changed, 11 insertions(+), 31 deletions(-) diff --git a/drivers/media/platform/coda/coda-common.c b/drivers/media/platform/coda/coda-common.c index 0997b5c..361f28d 100644 --- a/drivers/media/platform/coda/coda-common.c +++ b/drivers/media/platform/coda/coda-common.c @@ -1703,39 +1703,16 @@ static void coda_fw_callback(const struct firmware *fw, void *context) memcpy(dev->codebuf.vaddr, fw->data, fw->size); release_firmware(fw); - if (pm_runtime_enabled(&pdev->dev) && pdev->dev.pm_domain) { - /* - * Enabling power temporarily will cause coda_hw_init to be - * called via coda_runtime_resume by the pm domain. - */ - ret = pm_runtime_get_sync(&dev->plat_dev->dev); - if (ret < 0) { - v4l2_err(&dev->v4l2_dev, "failed to power on: %d\n", - ret); - return; - } - - ret = coda_check_firmware(dev); - if (ret < 0) - return; - - pm_runtime_put_sync(&dev->plat_dev->dev); - } else { - /* - * If runtime pm is disabled or pm_domain is not set, - * initialize once manually. - */ - ret = coda_hw_init(dev); - if (ret < 0) { - v4l2_err(&dev->v4l2_dev, "HW initialization failed\n"); - return; - } - - ret = coda_check_firmware(dev); - if (ret < 0) - return; + ret = coda_hw_init(dev); + if (ret < 0) { + v4l2_err(&dev->v4l2_dev, "HW initialization failed\n"); + return; } + ret = coda_check_firmware(dev); + if (ret < 0) + return; + dev->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev); if (IS_ERR(dev->alloc_ctx)) { v4l2_err(&dev->v4l2_dev, "Failed to alloc vb2 context\n"); @@ -1771,6 +1748,7 @@ static void coda_fw_callback(const struct firmware *fw, void *context) v4l2_info(&dev->v4l2_dev, "codec registered as /dev/video[%d-%d]\n", dev->vfd[0].num, dev->vfd[1].num); + pm_runtime_put_sync(&pdev->dev); return; rel_m2m: @@ -1998,6 +1976,8 @@ static int coda_probe(struct platform_device *pdev) platform_set_drvdata(pdev, dev); + pm_runtime_get_noresume(&pdev->dev); + pm_runtime_set_active(&pdev->dev); pm_runtime_enable(&pdev->dev); return coda_firmware_request(dev);