From patchwork Mon Jun 6 10:13:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: huang lin X-Patchwork-Id: 9157717 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 A4C2060467 for ; Mon, 6 Jun 2016 10:14:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 93EC325E13 for ; Mon, 6 Jun 2016 10:14:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 879FB26C9B; Mon, 6 Jun 2016 10:14:55 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3FF4025E13 for ; Mon, 6 Jun 2016 10:14:55 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1b9rYc-0004PN-PZ; Mon, 06 Jun 2016 10:14:54 +0000 Received: from mail-pa0-f68.google.com ([209.85.220.68]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1b9rXt-0003WK-GZ; Mon, 06 Jun 2016 10:14:10 +0000 Received: by mail-pa0-f68.google.com with SMTP id gp3so11526182pac.2; Mon, 06 Jun 2016 03:13:48 -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:in-reply-to :references; bh=mz9eFc/DG34OdQf+BuHCLwy+LsVkbOb7LQrAl4JcGi0=; b=Nf7PSpe1pxeVBsJVuWHjt72gVd2QoP77RQ4JwclBs71m1HAH0yeQhryYcAjx63ygLJ lID8JsrVW2ZvLp1M2ahg2SOdsyM4ox86JbvGNgU7brB04iBYob5gEN9jFURdDp0QJ+th Yg1yHtDUXs7d3oOR3AF3dgpTpZftTNCnUlLBhvgb35q5Cu+bbVjeKWWmb54y/6mDR91y 4AJ2e3SGmKkUtB6OT/Xt5YLU4YxqBYoHL8wvBN3l9yJq+tGN3eqmnP1q0dfwaw0q0j/R RyV3DVie69le95R9TTb2qn+Gz2OVIP7Udzb+3+neWszK2YY5hy0g3P2+KamBesZIC/sg apyg== X-Gm-Message-State: ALyK8tLb1alBBdEupWXH65RkjdwU2NhU0fPZOpFBQGBsOp6GXt/DBRH5KDaQ+vH4P4vK5g== X-Received: by 10.66.22.134 with SMTP id d6mr23896475paf.35.1465208027589; Mon, 06 Jun 2016 03:13:47 -0700 (PDT) Received: from localhost.localdomain ([103.29.142.67]) by smtp.gmail.com with ESMTPSA id t65sm26421423pfb.37.2016.06.06.03.13.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 06 Jun 2016 03:13:46 -0700 (PDT) From: Lin Huang To: heiko@sntech.de, mark.yao@rock-chips.com, myungjoo.ham@samsung.com Subject: [RFC PATCH v2 6/6] drm/rockchip: Add dmc notifier in vop driver Date: Mon, 6 Jun 2016 18:13:06 +0800 Message-Id: <1465207986-17888-7-git-send-email-hl@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1465207986-17888-1-git-send-email-hl@rock-chips.com> References: <1465207986-17888-1-git-send-email-hl@rock-chips.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160606_031409_709084_65A7407D X-CRM114-Status: GOOD ( 16.44 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lin Huang , cw00.choi@samsung.com, airlied@linux.ie, mturquette@baylibre.com, dbasehore@chromium.org, sboyd@codeaurora.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, dianders@chromium.org, linux-rockchip@lists.infradead.org, kyungmin.park@samsung.com, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org 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 when in ddr frequency scaling process, vop can not do enable or disable operate, since dcf will base on vop vblank time to do frequency scaling and need to get vop irq if there have vop enabled. So need register to dmc notifier, and we can get the dmc status. Signed-off-by: Lin Huang --- Changes in v2: - None Changes in v1: - use wait_event instead usleep drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 43 +++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c index 1c4d5b5..8286048 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c @@ -31,6 +31,8 @@ #include #include +#include + #include "rockchip_drm_drv.h" #include "rockchip_drm_gem.h" #include "rockchip_drm_fb.h" @@ -116,6 +118,10 @@ struct vop { const struct vop_data *data; + struct notifier_block dmc_nb; + int dmc_in_process; + wait_queue_head_t wait_dmc_queue; + uint32_t *regsbak; void __iomem *regs; @@ -426,6 +432,21 @@ static void vop_dsp_hold_valid_irq_disable(struct vop *vop) spin_unlock_irqrestore(&vop->irq_lock, flags); } +static int dmc_notify(struct notifier_block *nb, unsigned long event, + void *data) +{ + struct vop *vop = container_of(nb, struct vop, dmc_nb); + + if (event == DMCFREQ_ADJUST) { + vop->dmc_in_process = 1; + } else if (event == DMCFREQ_FINISH) { + vop->dmc_in_process = 0; + wake_up(&vop->wait_dmc_queue); + } + + return NOTIFY_OK; +} + static void vop_enable(struct drm_crtc *crtc) { struct vop *vop = to_vop(crtc); @@ -434,6 +455,13 @@ static void vop_enable(struct drm_crtc *crtc) if (vop->is_enabled) return; + /* + * if in dmc scaling frequency process, wait until it finish + * use 100ms as timeout time. + */ + wait_event_timeout(vop->wait_dmc_queue, + !vop->dmc_in_process, HZ / 10); + ret = pm_runtime_get_sync(vop->dev); if (ret < 0) { dev_err(vop->dev, "failed to get pm runtime: %d\n", ret); @@ -485,6 +513,7 @@ static void vop_enable(struct drm_crtc *crtc) enable_irq(vop->irq); drm_crtc_vblank_on(crtc); + rockchip_dmc_get(&vop->dmc_nb); return; @@ -505,6 +534,13 @@ static void vop_crtc_disable(struct drm_crtc *crtc) return; /* + * if in dmc scaling frequency process, wait until it finish + * use 100ms as timeout time. + */ + wait_event_timeout(vop->wait_dmc_queue, + !vop->dmc_in_process, HZ / 10); + + /* * We need to make sure that all windows are disabled before we * disable that crtc. Otherwise we might try to scan from a destroyed * buffer later. @@ -517,7 +553,7 @@ static void vop_crtc_disable(struct drm_crtc *crtc) VOP_WIN_SET(vop, win, enable, 0); spin_unlock(&vop->reg_lock); } - + rockchip_dmc_put(&vop->dmc_nb); drm_crtc_vblank_off(crtc); /* @@ -1243,7 +1279,7 @@ static int vop_create_crtc(struct vop *vop) ret = -ENOENT; goto err_cleanup_crtc; } - + vop->dmc_nb.notifier_call = dmc_notify; init_completion(&vop->dsp_hold_completion); init_completion(&vop->wait_update_complete); crtc->port = port; @@ -1465,6 +1501,9 @@ static int vop_bind(struct device *dev, struct device *master, void *data) /* IRQ is initially disabled; it gets enabled in power_on */ disable_irq(vop->irq); + init_waitqueue_head(&vop->wait_dmc_queue); + vop->dmc_in_process = 0; + ret = vop_create_crtc(vop); if (ret) return ret;