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: 4877361 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E31ADC0338 for ; Wed, 10 Sep 2014 13:43:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9D84B201C8 for ; Wed, 10 Sep 2014 13:43:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4C341201C7 for ; Wed, 10 Sep 2014 13:43:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751075AbaIJNnt (ORCPT ); Wed, 10 Sep 2014 09:43:49 -0400 Received: from mail-wg0-f43.google.com ([74.125.82.43]:59174 "EHLO mail-wg0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750989AbaIJNns (ORCPT ); Wed, 10 Sep 2014 09:43:48 -0400 Received: by mail-wg0-f43.google.com with SMTP id x12so5332715wgg.14 for ; Wed, 10 Sep 2014 06:43:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=nm2aezg8YmG3knRodXBNU13aCyI7RnGBwNZ9qMpBnOg=; b=YGdSX7Rt1VFabk4jkYLnjFr/o6OtHqdgMbneL978Pm/J278qisUw6uGqZd7e36tjv4 dVr7LTzDadSDPJ9Qt36xTX+KM7SEfqNwFFsUZUHWQ92fuhkOqq57Qk7WOnXaVwNOwf2s No1SIIqP5VDZZvUxzcfZU7gQPWvFkHrxoIYLGr9Stkb1Nb37AGYqib6Qoa/bbkzNjf4y zr9ORnI19xgU2q/MuuxtR0FP65oxvxs/jE8hqVZTUXOn3tycYo1/BpKPLkMXWIZO1oFr uC2hrhV0oDwdJ0OTYP4ipBm8nYMc9HLPRXi9F7aAJIKBPJp2jwZeKI2uhymPguaDY9c4 HC/Q== X-Gm-Message-State: ALoCoQljr6MLpDB7muvGGK7gw0z3NwIkBHdV3qYoIClbcXMaP7W5kUAIjyQc5h4z2WUV5CjeTktK 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 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-9.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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);