From patchwork Thu Jun 23 01:19:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chanwoo Choi X-Patchwork-Id: 9194311 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 9858B6075A for ; Thu, 23 Jun 2016 01:21:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 86665212D7 for ; Thu, 23 Jun 2016 01:21:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7899528423; Thu, 23 Jun 2016 01:21:31 +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 12A87212D7 for ; Thu, 23 Jun 2016 01:21:31 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bFtIs-00008M-8S; Thu, 23 Jun 2016 01:19:34 +0000 Received: from mailout4.samsung.com ([203.254.224.34]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bFtIp-00006i-6s; Thu, 23 Jun 2016 01:19:32 +0000 MIME-version: 1.0 Received: from epcpsbgr3.samsung.com (u143.gpu120.samsung.co.kr [203.254.230.143]) by mailout4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0O97002BNABV87D0@mailout4.samsung.com>; Thu, 23 Jun 2016 10:19:07 +0900 (KST) Received: from epcpsbgm2new.samsung.com ( [172.20.52.113]) by epcpsbgr3.samsung.com (EPCPMTA) with SMTP id 35.A7.05161.B093B675; Thu, 23 Jun 2016 10:19:07 +0900 (KST) X-AuditID: cbfee68f-f79476d000001429-f7-576b390b046d Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2new.samsung.com (EPCPMTA) with SMTP id 8E.BE.04429.B093B675; Wed, 22 Jun 2016 18:19:07 -0700 (MST) Received: from [10.113.62.212] by mmp2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0O9700H18ABUMP70@mmp2.samsung.com>; Thu, 23 Jun 2016 10:19:07 +0900 (KST) Message-id: <576B390A.3050905@samsung.com> Date: Thu, 23 Jun 2016 10:19:06 +0900 From: Chanwoo Choi User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 To: hl , heiko@sntech.de, mark.yao@rock-chips.com, myungjoo.ham@samsung.com Subject: Re: [RFC PATCH v2 6/6] drm/rockchip: Add dmc notifier in vop driver References: <1465207986-17888-1-git-send-email-hl@rock-chips.com> <1465207986-17888-7-git-send-email-hl@rock-chips.com> <576A3A38.3000306@samsung.com> <576A83A0.3080908@rock-chips.com> In-reply-to: <576A83A0.3080908@rock-chips.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrDIsWRmVeSWpSXmKPExsWyRsSkUJfbMjvcYMpnRYvecyeZLF5t3sNm cXbZQTaLK1/fs1n8f/Sa1eLHhlPMFmeb3rBbbHp8jdXiY889VovLu+awWXx68J/ZYseUA0wW F0+5WtxuXMFm8eNMN4sDv8f7G63sHrMbLrJ4XO7rZfLY/u0Bq8f97uNMHpuX1Hv8nbWfxaNv yypGj+3X5jF7fN4kF8AVxWWTkpqTWZZapG+XwJWx+8Q61oIG/Ypre+ewNjAeUe1i5OCQEDCR mHU7rouRE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EICsxglPrWB2bwCghI/Jt9j 6WLk4GAWkJc4cikbwlSXmDIlt4uRC6j6AaPEqRvnocq1JM5tWgk2kkVAVeLhqmYWEJsNKL7/ xQ02kF5RgQiJ7hOVIGERgQSJqf3fwcqZBXYySXz+Kw9iCwv4SHy4+Z8ZYv4EJonFE+YzgfRy CuhJHFxiOYER6ESE42YhHDcL4bgFjMyrGCVSC5ILipPSc43yUsv1ihNzi0vz0vWS83M3MYLT yTPpHYyHd7kfYhTgYFTi4T0gnB0uxJpYVlyZe4hRgoNZSYR3pTlQiDclsbIqtSg/vqg0J7X4 EKMp0HcTmaVEk/OBqS6vJN7Q2MTMyNLI3NDCyNhcSZz38f91YUIC6YklqdmpqQWpRTB9TByc Ug2MVctDHtiUaof133rMnNFltszOzTCaZ+3Kc4Xv3qtd+6zxda1vwRX7onMe/jUZzu8XLDHc HVfV4H1Ns3CvnkyqZr9L4zVvh+NGG9zOm07SfRWZ9y0sYP5jsdgKzeeHL0kcXLW88RbDum3T 5v79+fbkroDbzpvF5WKezWa6yPPm8Y8F7pE7Pm2er8RSnJFoqMVcVJwIAH+fT/w9AwAA DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160622_181931_408722_5AA9A66F X-CRM114-Status: GOOD ( 22.00 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: 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 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Hi Lin, On 2016년 06월 22일 21:25, hl wrote: > Hi Chanwoo Choi, > > On 2016年06月22日 15:11, Chanwoo Choi wrote: >> Hi, >> >> On 2016년 06월 06일 19:13, Lin Huang wrote: >>> 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. >> If you want to know when ddr frequency is chanaged, >> you can use the DEVFREQ_TRANSITION_NOTIFIER notifier[1] (merged to v4.7-rc1) >> which includes the following notification: >> - DEVFREQ_PRECHANGE >> - DEVFREQ_POSTCHANGE >> >> [1] "PM / devfreq: Add new DEVFREQ_TRANSITION_NOTIFIER notifier" >> - https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=0fe3a66410a3ba96679be903f1e287d7a0a264a9 > Check the code, if the set target fail, it will not send DEVFREQ_POSTCHANGE, but in our case, whether the target > setting sucess or fail, it should send message to vop driver, tell vop driver dmc have finish frequency setting. I check the code when target function is failed. DEVFREQ_TRANSITION_NOTIFIER notifier[1] is missing the error case as you mentioned. So, we would add following patches to fix the problem. Thanks, Chanwoo Choi >> >> Thanks, >> Chanwoo Choi >> >>> 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; >>> >> >> >> > > -- > Lin Huang > diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index 1d6c803804d5..2bd9d4228b7b 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -268,8 +268,10 @@ int update_devfreq(struct devfreq *devfreq) devfreq_notify_transition(devfreq, &freqs, DEVFREQ_PRECHANGE); err = devfreq->profile->target(devfreq->dev.parent, &freq, flags); - if (err) + if (err) { + freqs.new = cur_freq; + devfreq_notify_transition(devfreq, &freqs, DEVFREQ_POSTCHANGE); return err; + } freqs.new = freq; devfreq_notify_transition(devfreq, &freqs, DEVFREQ_POSTCHANGE);