aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorUlf Hansson <ulf.hansson@linaro.org>2014-09-22 12:05:56 -0400
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2014-09-26 05:47:48 -0400
commitc5d28e29833c8bc80d96cb2f46c3cf06b43a8fa4 (patch)
treeb4027406b9aeaa0fa37bbb0d0448064e6ac22e12 /drivers/media
parent7c672812fe230f54e86da0e56cd2917e897fe760 (diff)
[media] coda: Improve runtime PM support
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 <ulf.hansson@linaro.org> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Kamil Debski <k.debski@samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/platform/coda/coda-common.c55
1 files changed, 21 insertions, 34 deletions
diff --git a/drivers/media/platform/coda/coda-common.c b/drivers/media/platform/coda/coda-common.c
index 0997b5c677bd..ced47609f5ef 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)
1688 1688
1689 if (!fw) { 1689 if (!fw) {
1690 v4l2_err(&dev->v4l2_dev, "firmware request failed\n"); 1690 v4l2_err(&dev->v4l2_dev, "firmware request failed\n");
1691 return; 1691 goto put_pm;
1692 } 1692 }
1693 1693
1694 /* allocate auxiliary per-device code buffer for the BIT processor */ 1694 /* 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)
1696 dev->debugfs_root); 1696 dev->debugfs_root);
1697 if (ret < 0) { 1697 if (ret < 0) {
1698 dev_err(&pdev->dev, "failed to allocate code buffer\n"); 1698 dev_err(&pdev->dev, "failed to allocate code buffer\n");
1699 return; 1699 goto put_pm;
1700 } 1700 }
1701 1701
1702 /* Copy the whole firmware image to the code buffer */ 1702 /* Copy the whole firmware image to the code buffer */
1703 memcpy(dev->codebuf.vaddr, fw->data, fw->size); 1703 memcpy(dev->codebuf.vaddr, fw->data, fw->size);
1704 release_firmware(fw); 1704 release_firmware(fw);
1705 1705
1706 if (pm_runtime_enabled(&pdev->dev) && pdev->dev.pm_domain) { 1706 ret = coda_hw_init(dev);
1707 /* 1707 if (ret < 0) {
1708 * Enabling power temporarily will cause coda_hw_init to be 1708 v4l2_err(&dev->v4l2_dev, "HW initialization failed\n");
1709 * called via coda_runtime_resume by the pm domain. 1709 goto put_pm;
1710 */
1711 ret = pm_runtime_get_sync(&dev->plat_dev->dev);
1712 if (ret < 0) {
1713 v4l2_err(&dev->v4l2_dev, "failed to power on: %d\n",
1714 ret);
1715 return;
1716 }
1717
1718 ret = coda_check_firmware(dev);
1719 if (ret < 0)
1720 return;
1721
1722 pm_runtime_put_sync(&dev->plat_dev->dev);
1723 } else {
1724 /*
1725 * If runtime pm is disabled or pm_domain is not set,
1726 * initialize once manually.
1727 */
1728 ret = coda_hw_init(dev);
1729 if (ret < 0) {
1730 v4l2_err(&dev->v4l2_dev, "HW initialization failed\n");
1731 return;
1732 }
1733
1734 ret = coda_check_firmware(dev);
1735 if (ret < 0)
1736 return;
1737 } 1710 }
1738 1711
1712 ret = coda_check_firmware(dev);
1713 if (ret < 0)
1714 goto put_pm;
1715
1739 dev->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev); 1716 dev->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev);
1740 if (IS_ERR(dev->alloc_ctx)) { 1717 if (IS_ERR(dev->alloc_ctx)) {
1741 v4l2_err(&dev->v4l2_dev, "Failed to alloc vb2 context\n"); 1718 v4l2_err(&dev->v4l2_dev, "Failed to alloc vb2 context\n");
1742 return; 1719 goto put_pm;
1743 } 1720 }
1744 1721
1745 dev->m2m_dev = v4l2_m2m_init(&coda_m2m_ops); 1722 dev->m2m_dev = v4l2_m2m_init(&coda_m2m_ops);
@@ -1771,12 +1748,15 @@ static void coda_fw_callback(const struct firmware *fw, void *context)
1771 v4l2_info(&dev->v4l2_dev, "codec registered as /dev/video[%d-%d]\n", 1748 v4l2_info(&dev->v4l2_dev, "codec registered as /dev/video[%d-%d]\n",
1772 dev->vfd[0].num, dev->vfd[1].num); 1749 dev->vfd[0].num, dev->vfd[1].num);
1773 1750
1751 pm_runtime_put_sync(&pdev->dev);
1774 return; 1752 return;
1775 1753
1776rel_m2m: 1754rel_m2m:
1777 v4l2_m2m_release(dev->m2m_dev); 1755 v4l2_m2m_release(dev->m2m_dev);
1778rel_ctx: 1756rel_ctx:
1779 vb2_dma_contig_cleanup_ctx(dev->alloc_ctx); 1757 vb2_dma_contig_cleanup_ctx(dev->alloc_ctx);
1758put_pm:
1759 pm_runtime_put_sync(&pdev->dev);
1780} 1760}
1781 1761
1782static int coda_firmware_request(struct coda_dev *dev) 1762static int coda_firmware_request(struct coda_dev *dev)
@@ -1998,6 +1978,13 @@ static int coda_probe(struct platform_device *pdev)
1998 1978
1999 platform_set_drvdata(pdev, dev); 1979 platform_set_drvdata(pdev, dev);
2000 1980
1981 /*
1982 * Start activated so we can directly call coda_hw_init in
1983 * coda_fw_callback regardless of whether CONFIG_PM_RUNTIME is
1984 * enabled or whether the device is associated with a PM domain.
1985 */
1986 pm_runtime_get_noresume(&pdev->dev);
1987 pm_runtime_set_active(&pdev->dev);
2001 pm_runtime_enable(&pdev->dev); 1988 pm_runtime_enable(&pdev->dev);
2002 1989
2003 return coda_firmware_request(dev); 1990 return coda_firmware_request(dev);