From patchwork Wed Apr 5 08:29:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeffy Chen X-Patchwork-Id: 9663547 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EE2F4602B8 for ; Wed, 5 Apr 2017 09:30:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EC0212684F for ; Wed, 5 Apr 2017 09:30:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E0D5F2859A; Wed, 5 Apr 2017 09:30:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8ABC42684F for ; Wed, 5 Apr 2017 09:30:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=n9/OdY0vyVrHwkDStMtpwAJN9BLy/6ggICaxtbJAOcs=; b=F9laR6mIyD+ubFaoYNskGIwffX h7t83ZaTFue8iXusdiV6NSAHJBChAlto0gIve7wdKRlbgJNtUiXA3IA76XP3S38FixdmgIXQiRvYM E8GMrCUgP5ijbLD1atUHFr7+vEUBWihjO6NyXM8/ctZTT8u3KGNX7afqJEKh+gWRO+oSJflIMqPNu mBYBTAijL3LGVc2kO+tK15mOPx7GALFeW5iU4s0ftFEG1TOquJYDuzlOcZzPU62nGe/ohGrLbnKKf B7v4le89VdCeuX8HVplug1AIuIWfScICs9Bmjbs2rXWj5rmLFAPZtuuYtpE3qQaqAEgvojECktDou 6e2W5myQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cvhGO-0001co-NY; Wed, 05 Apr 2017 09:30:04 +0000 Received: from merlin.infradead.org ([2001:4978:20e::2]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cvgx9-0008EO-JE; Wed, 05 Apr 2017 09:10:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=BOknEJSRzZRbO1fckyHLTdz5ftdcbFC9DPkKYM5OqOg=; b=XQaEBIwk2STLad5MhhuMh5eyF fbAsQYD4qCDmT1+ETbI6TtnMm9zK6epz0cBXxHctIHAF+mEDIzGcEv/8Wezi1yhNJXTHXarUhAwiy dpGugOIsclTUR8Eq7rI8EmFjJ7qbdgW6nNu6FwMf+4QfEHiQJDgR6p5T6OijlpvvRFGDXR3DEH/6g Gnx7Yo+bdN6QJ1raFxfh2b3eZHY7Ojne1BTD5ZudYLw0TX4EjT6eVeHTck+S+5L9bFozQ5/33VcH/ B+BoX36SRuD+k6Td+jMTFhRm2M9UjtFjTMw+aeVt4OQCsdBVtkI2NZsl5ZKyuiOHTYS2RZd1GHEmb RELz5pU2w==; Received: from regular1.263xmail.com ([211.150.99.133]) by merlin.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cvgLc-0002CL-Dz; Wed, 05 Apr 2017 08:31:25 +0000 Received: from jeffy.chen?rock-chips.com (unknown [192.168.165.252]) by regular1.263xmail.com (Postfix) with ESMTP id 65967908C; Wed, 5 Apr 2017 16:30:58 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-KSVirus-check: 0 X-ABS-CHECKED: 4 Received: from smtp.263.net (sg-smtp01.263.net [54.255.195.220]) by smtp.263.net (Postfix) with ESMTP id 997454A3; Wed, 5 Apr 2017 16:30:22 +0800 (CST) Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.263.net (Postfix) with ESMTP id 52105DF304; Wed, 5 Apr 2017 16:30:11 +0800 (CST) X-RL-SENDER: jeffy.chen@rock-chips.com X-FST-TO: linux-kernel@vger.kernel.org X-SENDER-IP: 103.29.142.67 X-LOGIN-NAME: jeffy.chen@rock-chips.com X-UNIQUE-TAG: <52458fa89d749f79fe477539c018410f> X-ATTACHMENT-NUM: 0 X-SENDER: cjf@rock-chips.com X-DNS-TYPE: 0 Received: from localhost (unknown [103.29.142.67]) by smtp.263.net (Postfix) whith ESMTP id 14308VOVJFH; Wed, 05 Apr 2017 16:30:13 +0800 (CST) From: Jeffy Chen To: linux-kernel@vger.kernel.org Subject: [PATCH v3 5/9] drm/rockchip: vop: Enable pm domain before vop_initial Date: Wed, 5 Apr 2017 16:29:23 +0800 Message-Id: <1491380967-28570-6-git-send-email-jeffy.chen@rock-chips.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1491380967-28570-1-git-send-email-jeffy.chen@rock-chips.com> References: <1491380967-28570-1-git-send-email-jeffy.chen@rock-chips.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170405_043125_025602_E537B805 X-CRM114-Status: GOOD ( 10.96 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jeffy Chen , Heiko Stuebner , David Airlie , briannorris@chromium.org, dianders@chromium.org, dri-devel@lists.freedesktop.org, tfiga@chromium.org, linux-rockchip@lists.infradead.org, seanpaul@chromium.org, zyw@rock-chips.com, linux-arm-kernel@lists.infradead.org, mark.yao@rock-chips.com MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP We're trying to access vop registers here, so need to make sure the pm domain is on. Normally it should be enabled by the bootloader, but there's no guarantee of it. And if we wanna do unbind/bind, it would also cause the device to hang. And this patch also does these: 1/ move vop_initial to the end of vop_bind for eaiser error handling. 2/ correct the err_put_pm_runtime of vop_enable. Signed-off-by: Jeffy Chen --- Changes in v3: Address Sean Paul 's comments. Update commit message. Changes in v2: None drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c index 2151e1c..b65b296 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c @@ -506,7 +506,7 @@ static int vop_enable(struct drm_crtc *crtc) ret = pm_runtime_get_sync(vop->dev); if (ret < 0) { dev_err(vop->dev, "failed to get pm runtime: %d\n", ret); - goto err_put_pm_runtime; + return ret; } ret = clk_enable(vop->hclk); @@ -1405,10 +1405,16 @@ static int vop_initial(struct vop *vop) return PTR_ERR(vop->dclk); } + ret = pm_runtime_get_sync(vop->dev); + if (ret < 0) { + dev_err(vop->dev, "failed to get pm runtime: %d\n", ret); + return ret; + } + ret = clk_prepare(vop->dclk); if (ret < 0) { dev_err(vop->dev, "failed to prepare dclk\n"); - return ret; + goto err_put_pm_runtime; } /* Enable both the hclk and aclk to setup the vop */ @@ -1468,6 +1474,8 @@ static int vop_initial(struct vop *vop) vop->is_enabled = false; + pm_runtime_put_sync(vop->dev); + return 0; err_disable_aclk: @@ -1476,6 +1484,8 @@ static int vop_initial(struct vop *vop) clk_disable_unprepare(vop->hclk); err_unprepare_dclk: clk_unprepare(vop->dclk); +err_put_pm_runtime: + pm_runtime_put_sync(vop->dev); return ret; } @@ -1576,12 +1586,6 @@ static int vop_bind(struct device *dev, struct device *master, void *data) if (!vop->regsbak) return -ENOMEM; - ret = vop_initial(vop); - if (ret < 0) { - dev_err(&pdev->dev, "cannot initial vop dev - err %d\n", ret); - return ret; - } - irq = platform_get_irq(pdev, 0); if (irq < 0) { dev_err(dev, "cannot find irq for vop\n"); @@ -1608,8 +1612,17 @@ static int vop_bind(struct device *dev, struct device *master, void *data) pm_runtime_enable(&pdev->dev); + ret = vop_initial(vop); + if (ret < 0) { + dev_err(&pdev->dev, "cannot initial vop dev - err %d\n", ret); + goto err_disable_pm_runtime; + } + return 0; +err_disable_pm_runtime: + pm_runtime_disable(&pdev->dev); + vop_destroy_crtc(vop); err_enable_irq: enable_irq(vop->irq); /* To balance out the disable_irq above */ return ret;