From patchwork Wed Jun 1 09:35:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: huang lin X-Patchwork-Id: 9148903 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 A05DE60467 for ; Thu, 2 Jun 2016 00:28:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 91F582714B for ; Thu, 2 Jun 2016 00:28:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 86A6827224; Thu, 2 Jun 2016 00:28:54 +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=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3714D2714F for ; Thu, 2 Jun 2016 00:28:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1052C6EAE4; Thu, 2 Jun 2016 00:28:47 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf0-f194.google.com (mail-pf0-f194.google.com [209.85.192.194]) by gabe.freedesktop.org (Postfix) with ESMTPS id 391C16E930 for ; Wed, 1 Jun 2016 09:36:18 +0000 (UTC) Received: by mail-pf0-f194.google.com with SMTP id f144so2898519pfa.2 for ; Wed, 01 Jun 2016 02:36:18 -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=C1jx8NhLJFCZ0IvF4yv80YXkXWZGpK5rACvvUrGrA1k=; b=WaR59txrVgLBWf7EUvV9JHja3LdV7p+ANkGj63ixS/jVAVuc20p3S/mYiULAXtOYXn 1V4zCFR4OY/Cvp53y8Ei58c+vTAQYoL+xYtvhLs/guc4hUbX5osn3TDioKN6lh8mP95s m/DDG0K9+Yn4gGUWjXOZgflGT3ePtqQkd3ueaaxRiHrHNLT3aBOnD9kNoSKreRRGGfYW xNV9QTgx56UR2DKZFefTzseKFwvRi2K2NtygHLvzREYJ91qfu7IeUAFgk7sDYw5GstPM A6DzVdX0sdcYyIoOHE8fRoBJJ5pswUI4BhNj3VLe2tcqpMp7A21VRP9uHNkfv56Kj7Nx FbFA== X-Gm-Message-State: ALyK8tKk53Qh3fNaymsZqdbDRcn4g34kNrcgMA3i3asYCoAXlpbFzHMCSDtaSzuIurvWgQ== X-Received: by 10.98.193.5 with SMTP id i5mr6761742pfg.64.1464773777361; Wed, 01 Jun 2016 02:36:17 -0700 (PDT) Received: from localhost.localdomain ([103.29.142.67]) by smtp.gmail.com with ESMTPSA id q127sm18173335pfb.34.2016.06.01.02.36.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 01 Jun 2016 02:36:16 -0700 (PDT) From: Lin Huang To: heiko@sntech.de, mark.yao@rock-chips.com, myungjoo.ham@samsung.com Subject: [RFC PATCH 4/4] drm/rockchip: Add dmc notifier in vop driver Date: Wed, 1 Jun 2016 17:35:39 +0800 Message-Id: <1464773739-18152-5-git-send-email-hl@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1464773739-18152-1-git-send-email-hl@rock-chips.com> References: <1464773739-18152-1-git-send-email-hl@rock-chips.com> X-Mailman-Approved-At: Thu, 02 Jun 2016 00:28:26 +0000 Cc: Lin Huang , 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 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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 --- drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 51 +++++++++++++++++++++++++++-- 1 file changed, 49 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..7ee0cd0 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,9 @@ struct vop { const struct vop_data *data; + struct notifier_block dmc_nb; + int dmc_in_process; + uint32_t *regsbak; void __iomem *regs; @@ -426,14 +431,41 @@ 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; + + return NOTIFY_OK; +} + static void vop_enable(struct drm_crtc *crtc) { struct vop *vop = to_vop(crtc); int ret; + int timeout_count = 500; + int timeout_loop = 0; if (vop->is_enabled) return; + /* + * if in dmc scaling frequency process, wait until it finish + * use 100ms as timeout time. + */ + while (timeout_loop < timeout_count) { + if (vop->dmc_in_process == 0) + break; + + timeout_loop++; + usleep_range(150, 200); + } + ret = pm_runtime_get_sync(vop->dev); if (ret < 0) { dev_err(vop->dev, "failed to get pm runtime: %d\n", ret); @@ -485,6 +517,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; @@ -500,11 +533,25 @@ static void vop_crtc_disable(struct drm_crtc *crtc) { struct vop *vop = to_vop(crtc); int i; + int timeout_count = 500; + int timeout_loop = 0; if (!vop->is_enabled) return; /* + * if in dmc scaling frequency process, wait until it finish + * use 100ms as timeout time. + */ + while (timeout_loop < timeout_count) { + if (vop->dmc_in_process == 0) + break; + + timeout_loop++; + usleep_range(150, 200); + } + + /* * 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 +564,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 +1290,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;