Received: by 10.213.65.68 with SMTP id h4csp1762915imn; Mon, 19 Mar 2018 12:34:18 -0700 (PDT) X-Google-Smtp-Source: AG47ELsWUH4YdeCIcQdP3/G0IUWABY4ksYpnS1BRayaCAPLrX6Y2OxgIA2riTOYJjlA/GzQmRgQx X-Received: by 10.101.88.4 with SMTP id g4mr9921319pgr.146.1521488058022; Mon, 19 Mar 2018 12:34:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521488057; cv=none; d=google.com; s=arc-20160816; b=PkvvrV+sjwWDqmOF0A7edFoXCAJbjvBI9lgRySf9dVDHa3QAAkmbfZ/RCKeRYqrLY6 hsGxfrxU9MiKWc043BDfxh9T+p9g3GP2KNDh/mhIMBIYUxbmYo+f+/9qotPUIWjyAOKs blVulGI+owK4GHNQVxjECHmbMlJDNbnAGX53coGydcYeGKfyZ0mrnfTBAD96o4WfipKq AkMelfogHl89ZRhccc6rNfLyuS7i5qQV2rMTqcbWjRWGVz1HE9/z/Sok7XwCzt57jQd4 /lVz8THW8Vg0qrsb5Ty7Wlf4zVoqCFmVHn1Oboii7GtP6OsUYix2/ThOubvzTatomalR dhng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=cSBwTDfjV0Lm6yQEuE4jviKlw+EW32nXoa43ZLFxwnw=; b=XSgOzwXSlYwMc2vz4pdr4dlbxJWK5uzHtEzuh/F/qqLGaHH5YG82NiQ71e67d6FPmd +dgO9iuOJKru7E9d8oaILkE+WGWzMkPjIcJw2v3+ekdlJOk6D1zpXX0XFBPOBvL5fKYg 2nOvlR59DUIjuPjcMcF8E5W5Eh9qvgCVCj8WLCRhk72pFlsj2YBEAzRG8KWcmhqthzos w/Q9O6WUcMAOBL1rTpmmLh9cLmLjQCVlWccifutGm7L3T+ZwYZ2xOCF6LqSwugZOSZda mJuIoY/EfMuvATV3P2c93EHjRsLmBWEpJjsP+MmAKhFF6qUeIX4GeMSP+Jz24ZcdNaew +f4g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v41-v6si491213plg.686.2018.03.19.12.34.04; Mon, 19 Mar 2018 12:34:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031441AbeCSSXd (ORCPT + 99 others); Mon, 19 Mar 2018 14:23:33 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:49294 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031410AbeCSSXZ (ORCPT ); Mon, 19 Mar 2018 14:23:25 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id AAA4AD09; Mon, 19 Mar 2018 18:23:24 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jeffy Chen , Sean Paul , Sasha Levin Subject: [PATCH 4.9 123/241] drm/rockchip: vop: Enable pm domain before vop_initial Date: Mon, 19 Mar 2018 19:06:28 +0100 Message-Id: <20180319180756.292330703@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180319180751.172155436@linuxfoundation.org> References: <20180319180751.172155436@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jeffy Chen [ Upstream commit 5e570373c015b60a68828b1cd9d475cb33d3be4b ] 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 Signed-off-by: Sean Paul Link: http://patchwork.freedesktop.org/patch/msgid/1491481885-13775-8-git-send-email-jeffy.chen@rock-chips.com Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 29 ++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c @@ -503,7 +503,7 @@ static int vop_enable(struct drm_crtc *c 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); @@ -1348,10 +1348,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 */ @@ -1411,6 +1417,8 @@ static int vop_initial(struct vop *vop) vop->is_enabled = false; + pm_runtime_put_sync(vop->dev); + return 0; err_disable_aclk: @@ -1419,6 +1427,8 @@ err_disable_hclk: clk_disable_unprepare(vop->hclk); err_unprepare_dclk: clk_unprepare(vop->dclk); +err_put_pm_runtime: + pm_runtime_put_sync(vop->dev); return ret; } @@ -1519,12 +1529,6 @@ static int vop_bind(struct device *dev, 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"); @@ -1551,8 +1555,17 @@ static int vop_bind(struct device *dev, 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;