From patchwork Mon Sep 22 16:05:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Zabel X-Patchwork-Id: 37687 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 35AE7202A1 for ; Mon, 22 Sep 2014 16:06:11 +0000 (UTC) Received: by mail-wi0-f200.google.com with SMTP id hi2sf1668053wib.7 for ; Mon, 22 Sep 2014 09:06:09 -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:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=DI/JlnOAwDVu3Q7nKd5PcfU/xIdFthbNGzpN+yZnHWI=; b=aRiWpYkB1ysb8OllVgwW/pcgqwLSAaGFP3bapp/ZP6w7jWx7QAHzITG/ms8/nQZ+zX GwwFX+hTUDMoGAoiZeuw065tlx+nsjfMHhR3jL9Ax0vO8/0sO0Ir4llFGvNrc5ZY6q/L QPeVH4R99kqD/w7cwNcdJj6eJlDcx8VKitkaBwnPl6r2Za5e58uCJtWHjfD+1aGyBuZ/ SbSaMYpEs6zjlL/epRYieLb7fMixFznLkUrxSQsTPQe4yqL10dSXdF4nlDpVNObEBj29 btgYX4u0uuoQorkWYtAvKPHbOSODBF98563HWaM7s0DqnMQfdcJ9r44QWHgGbGFGTeCN jTtA== X-Gm-Message-State: ALoCoQnqfJwEvhCTpZXuKqu9HnxGvKdZ3F/PVM1SW9zjtCaymEnVmMncuwTfjfAVXR0dJMiNodKp X-Received: by 10.112.170.166 with SMTP id an6mr538208lbc.17.1411401969828; Mon, 22 Sep 2014 09:06:09 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.2.194 with SMTP id 2ls551471law.108.gmail; Mon, 22 Sep 2014 09:06:09 -0700 (PDT) X-Received: by 10.112.55.7 with SMTP id n7mr17754620lbp.16.1411401969690; Mon, 22 Sep 2014 09:06:09 -0700 (PDT) Received: from mail-la0-f41.google.com (mail-la0-f41.google.com [209.85.215.41]) by mx.google.com with ESMTPS id n3si4520521lbe.27.2014.09.22.09.06.09 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 22 Sep 2014 09:06:09 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) client-ip=209.85.215.41; Received: by mail-la0-f41.google.com with SMTP id s18so7107906lam.28 for ; Mon, 22 Sep 2014 09:06:09 -0700 (PDT) X-Received: by 10.112.163.103 with SMTP id yh7mr4034659lbb.73.1411401969557; Mon, 22 Sep 2014 09:06:09 -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.130.169 with SMTP id of9csp265660lbb; Mon, 22 Sep 2014 09:06:08 -0700 (PDT) X-Received: by 10.68.139.232 with SMTP id rb8mr25663019pbb.20.1411401967977; Mon, 22 Sep 2014 09:06:07 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id rh9si16328511pdb.147.2014.09.22.09.06.06 for ; Mon, 22 Sep 2014 09:06:07 -0700 (PDT) Received-SPF: none (google.com: linux-media-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753698AbaIVQGE (ORCPT + 2 others); Mon, 22 Sep 2014 12:06:04 -0400 Received: from metis.ext.pengutronix.de ([92.198.50.35]:42828 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752344AbaIVQGD (ORCPT ); Mon, 22 Sep 2014 12:06:03 -0400 Received: from dude.hi.4.pengutronix.de ([10.1.0.7] helo=dude.pengutronix.de.) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1XW67j-0005ZC-Ki; Mon, 22 Sep 2014 18:05:59 +0200 From: Philipp Zabel To: Kamil Debski Cc: linux-media@vger.kernel.org, kernel@pengutronix.de, Ulf Hansson , Philipp Zabel Subject: [PATCH v2] [media] coda: Improve runtime PM support Date: Mon, 22 Sep 2014 18:05:56 +0200 Message-Id: <1411401956-29330-1-git-send-email-p.zabel@pengutronix.de> X-Mailer: git-send-email 2.1.0 X-SA-Exim-Connect-IP: 10.1.0.7 X-SA-Exim-Mail-From: p.zabel@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-media@vger.kernel.org Sender: linux-media-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: p.zabel@pengutronix.de 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.41 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: Ulf Hansson 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 Signed-off-by: Philipp Zabel --- Changes since v1: - Deactivate PM domain on error - Added a comment to runtime PM setup --- drivers/media/platform/coda/coda-common.c | 55 ++++++++++++------------------- 1 file changed, 21 insertions(+), 34 deletions(-) diff --git a/drivers/media/platform/coda/coda-common.c b/drivers/media/platform/coda/coda-common.c index 0997b5c..ced4760 100644 --- a/drivers/media/platform/coda/coda-common.c +++ b/drivers/media/platform/coda/coda-common.c @@ -1688,7 +1688,7 @@ static void coda_fw_callback(const struct firmware *fw, void *context) if (!fw) { v4l2_err(&dev->v4l2_dev, "firmware request failed\n"); - return; + goto put_pm; } /* allocate auxiliary per-device code buffer for the BIT processor */ @@ -1696,50 +1696,27 @@ static void coda_fw_callback(const struct firmware *fw, void *context) dev->debugfs_root); if (ret < 0) { dev_err(&pdev->dev, "failed to allocate code buffer\n"); - return; + goto put_pm; } /* Copy the whole firmware image to the code buffer */ 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"); + goto put_pm; } + ret = coda_check_firmware(dev); + if (ret < 0) + goto put_pm; + 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"); - return; + goto put_pm; } dev->m2m_dev = v4l2_m2m_init(&coda_m2m_ops); @@ -1771,12 +1748,15 @@ 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: v4l2_m2m_release(dev->m2m_dev); rel_ctx: vb2_dma_contig_cleanup_ctx(dev->alloc_ctx); +put_pm: + pm_runtime_put_sync(&pdev->dev); } static int coda_firmware_request(struct coda_dev *dev) @@ -1998,6 +1978,13 @@ static int coda_probe(struct platform_device *pdev) platform_set_drvdata(pdev, dev); + /* + * Start activated so we can directly call coda_hw_init in + * coda_fw_callback regardless of whether CONFIG_PM_RUNTIME is + * enabled or whether the device is associated with a PM domain. + */ + pm_runtime_get_noresume(&pdev->dev); + pm_runtime_set_active(&pdev->dev); pm_runtime_enable(&pdev->dev); return coda_firmware_request(dev);