Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1464719

Re: [PATCH v6 8/8] drm/rockchip: Add dmc notifier in vop driver

From hl <hl@rock-chips.com>
Newsgroups linux.kernel
Subject Re: [PATCH v6 8/8] drm/rockchip: Add dmc notifier in vop driver
Date 2016-08-17 21:00 +0200
Message-ID <s7eee-4TR-33@gated-at.bofh.it> (permalink)
References <s6VbA-DV-15@gated-at.bofh.it> <s6VbB-DV-53@gated-at.bofh.it> <s7dBw-4DV-35@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Hi,

On 2016年08月18日 02:14, Sean Paul wrote:
> On Tue, Aug 16, 2016 at 3:36 PM, Lin Huang <hl@rock-chips.com> wrote:
>> when in ddr frequency scaling process, vop can not do
>> enable or disable operation, since dcf will base on vop vblank
>> time to do frequency scaling and need to get vop irq if there
>> have vop enabled.
> I'm a little confused by this. Does this mean you need vblank irq to
> be enabled all the time when vop is enabled? We regularly disable it
> when there aren't new fbs coming in.
     maybe the commit message lead to misunderstanding, in dcf it will
     read the vop register to check whether is it in vblank status, if 
not, it
     will wait until it into vblank status. When vop enable, we need the vop
     clock enable, so we can read the vop register.
>
>
>> So need register to devfreq notifier, and we can
>> get the dmc status.
>> Also, when there have two vop enabled, we need
>> to disable dmc, since dcf only base on one vop vblank time, so the
>> other panel will flicker when do ddr frequency scaling.
>>
>> Signed-off-by: Lin Huang <hl@rock-chips.com>
>> Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
>> ---
>> Changes in v6:
>> - fix a build error
>>
>> Changes in v5:
>> - improve some nits
>>
>> Changes in v4:
>> - register notifier to devfreq_register_notifier
>> - use DEVFREQ_PRECHANGE and DEVFREQ_POSTCHANGE to get dmc status
>> - when two vop enable, disable dmc
>> - when two vop back to one vop, enable dmc
>>
>> Changes in v3:
>> - when do vop eanble/disable, dmc will wait until it finish
>>
>> Changes in v2:
>> - None
>>
>> Changes in v1:
>> - use wait_event instead usleep
>>
>>   drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 121 +++++++++++++++++++++++++++-
>>   1 file changed, 119 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
>> index 31744fe..199529e 100644
>> --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
>> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
>> @@ -12,6 +12,8 @@
>>    * GNU General Public License for more details.
>>    */
>>
>> +#include <linux/devfreq.h>
>> +#include <linux/devfreq-event.h>
>>   #include <drm/drm.h>
>>   #include <drm/drmP.h>
>>   #include <drm/drm_atomic.h>
>> @@ -118,6 +120,13 @@ struct vop {
>>
>>          const struct vop_data *data;
>>
>> +       struct devfreq *devfreq;
>> +       struct devfreq_event_dev *devfreq_event_dev;
>> +       struct notifier_block dmc_nb;
>> +       int dmc_in_process;
>> +       int vop_switch_status;
>> +       wait_queue_head_t wait_dmc_queue;
>> +       wait_queue_head_t wait_vop_switch_queue;
>>          uint32_t *regsbak;
>>          void __iomem *regs;
>>
>> @@ -428,21 +437,56 @@ 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 == DEVFREQ_PRECHANGE) {
>> +               /*
>> +                * check if vop in enable or disable process,
>> +                * if yes, wait until it finishes, use 200ms as
>> +                * timeout.
>> +                */
>> +               if (!wait_event_timeout(vop->wait_vop_switch_queue,
>> +                                       !vop->vop_switch_status, HZ / 5))
>> +                       dev_warn(vop->dev,
>> +                                "Timeout waiting for vop swtich status\n");
>> +               vop->dmc_in_process = 1;
>> +       } else if (event == DEVFREQ_POSTCHANGE) {
>> +               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);
>> +       int num_enabled_crtc = 0;
>>          int ret;
>>
>> +       /*
>> +        * if in dmc scaling frequency process, wait until it finishes
>> +        * use 100ms as timeout time.
>> +        */
>> +       if (!wait_event_timeout(vop->wait_dmc_queue,
>> +                               !vop->dmc_in_process, HZ / 5))
>> +               dev_warn(vop->dev,
>> +                        "Timeout waiting for dmc when vop enable\n");
>> +
>> +       vop->vop_switch_status = 1;
>>          ret = pm_runtime_get_sync(vop->dev);
>>          if (ret < 0) {
>>                  dev_err(vop->dev, "failed to get pm runtime: %d\n", ret);
>> -               return;
>> +               goto err;
>>          }
>>
>>          ret = clk_enable(vop->hclk);
>>          if (ret < 0) {
>>                  dev_err(vop->dev, "failed to enable hclk - %d\n", ret);
>> -               return;
>> +               goto err;
>>          }
>>
>>          ret = clk_enable(vop->dclk);
>> @@ -485,6 +529,21 @@ static void vop_enable(struct drm_crtc *crtc)
>>
>>          drm_crtc_vblank_on(crtc);
>>
>> +       vop->vop_switch_status = 0;
>> +       wake_up(&vop->wait_vop_switch_queue);
>> +
>> +       /* check how many vop we use now */
>> +       drm_for_each_crtc(crtc, vop->drm_dev) {
>> +               if (crtc->state->enable)
>> +                       num_enabled_crtc++;
>> +       }
>> +
>> +       /* if enable two vop, need to disable dmc */
>> +       if ((num_enabled_crtc > 1) && vop->devfreq) {
>> +               if (vop->devfreq_event_dev)
>> +                       devfreq_event_disable_edev(vop->devfreq_event_dev);
>> +               devfreq_suspend_device(vop->devfreq);
>> +       }
>>          return;
>>
>>   err_disable_aclk:
>> @@ -493,16 +552,32 @@ err_disable_dclk:
>>          clk_disable(vop->dclk);
>>   err_disable_hclk:
>>          clk_disable(vop->hclk);
>> +err:
>> +       vop->vop_switch_status = 0;
>> +       wake_up(&vop->wait_vop_switch_queue);
>> +       return;
>>   }
>>
>>   static void vop_crtc_disable(struct drm_crtc *crtc)
>>   {
>>          struct vop *vop = to_vop(crtc);
>> +       int num_enabled_crtc = 0;
>>          int i;
>>
>>          WARN_ON(vop->event);
>>
>>          /*
>> +        * if in dmc scaling frequency process, wait until it finish
>> +        * use 100ms as timeout time.
>> +        */
>> +       if (!wait_event_timeout(vop->wait_dmc_queue,
>> +                               !vop->dmc_in_process, HZ / 5))
>> +               dev_warn(vop->dev,
>> +                        "Timeout waiting for dmc when vop disable\n");
>> +
>> +       vop->vop_switch_status = 1;
>> +
>> +       /*
>>           * 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.
>> @@ -559,6 +634,25 @@ static void vop_crtc_disable(struct drm_crtc *crtc)
>>
>>                  crtc->state->event = NULL;
>>          }
>> +
>> +       vop->vop_switch_status = 0;
>> +       wake_up(&vop->wait_vop_switch_queue);
>> +
>> +       /* check how many vop use now */
>> +       drm_for_each_crtc(crtc, vop->drm_dev) {
>> +               if (crtc->state->enable)
>> +                       num_enabled_crtc++;
>> +       }
>> +
>> +       /*
>> +        * if num_enabled_crtc = 1 now, it means 2 vop enabled
>> +        * change to 1 vop enabled  need to enable dmc again.
>> +        */
>> +       if ((num_enabled_crtc == 1) && vop->devfreq) {
>> +               if (vop->devfreq_event_dev)
>> +                       devfreq_event_enable_edev(vop->devfreq_event_dev);
>> +               devfreq_resume_device(vop->devfreq);
>> +       }
>>   }
>>
>>   static void vop_plane_destroy(struct drm_plane *plane)
>> @@ -1406,6 +1500,8 @@ static int vop_bind(struct device *dev, struct device *master, void *data)
>>          struct drm_device *drm_dev = data;
>>          struct vop *vop;
>>          struct resource *res;
>> +       struct devfreq *devfreq;
>> +       struct devfreq_event_dev *event_dev;
>>          size_t alloc_size;
>>          int ret, irq;
>>
>> @@ -1467,6 +1563,27 @@ static int vop_bind(struct device *dev, struct device *master, void *data)
>>                  return ret;
>>
>>          pm_runtime_enable(&pdev->dev);
>> +
>> +       init_waitqueue_head(&vop->wait_vop_switch_queue);
>> +       vop->vop_switch_status = 0;
>> +       init_waitqueue_head(&vop->wait_dmc_queue);
>> +       vop->dmc_in_process = 0;
>> +
>> +       devfreq = devfreq_get_devfreq_by_phandle(dev, 0);
>> +       if (IS_ERR(devfreq))
>> +               goto out;
>> +
>> +       vop->devfreq = devfreq;
>> +       vop->dmc_nb.notifier_call = dmc_notify;
>> +       devfreq_register_notifier(vop->devfreq, &vop->dmc_nb,
>> +                                 DEVFREQ_TRANSITION_NOTIFIER);
>> +
>> +       event_dev = devfreq_event_get_edev_by_phandle(vop->devfreq->dev.parent,
>> +                                                     0);
>> +       if (IS_ERR(event_dev))
>> +               goto out;
>> +       vop->devfreq_event_dev = event_dev;
>> +out:
>>          return 0;
>>   }
>>
>> --
>> 2.6.6
>>
>
>

-- 
Lin Huang

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH v6 0/8] rk3399 support ddr frequency scaling Lin Huang <hl@rock-chips.com> - 2016-08-17 00:40 +0200
  [PATCH v6 2/8] clk: rockchip: rk3399: add SCLK_DDRCLK ID for ddrc Lin Huang <hl@rock-chips.com> - 2016-08-17 00:40 +0200
  [PATCH v6 5/8] PM / devfreq: event: support rockchip dfi controller Lin Huang <hl@rock-chips.com> - 2016-08-17 00:40 +0200
  [PATCH v6 7/8] PM / devfreq: rockchip: add devfreq driver for rk3399 dmc Lin Huang <hl@rock-chips.com> - 2016-08-17 00:40 +0200
    Re: [PATCH v6 7/8] PM / devfreq: rockchip: add devfreq driver for  rk3399 dmc Chanwoo Choi <cw00.choi@samsung.com> - 2016-08-17 02:40 +0200
  [PATCH v6 6/8] Documentation: bindings: add dt documentation for rk3399 dmc Lin Huang <hl@rock-chips.com> - 2016-08-17 00:40 +0200
    Re: [PATCH v6 6/8] Documentation: bindings: add dt documentation for  rk3399 dmc Chanwoo Choi <cw00.choi@samsung.com> - 2016-08-17 07:00 +0200
      Re: [PATCH v6 6/8] Documentation: bindings: add dt documentation for  rk3399 dmc hl <hl@rock-chips.com> - 2016-08-22 00:20 +0200
        Re: [PATCH v6 6/8] Documentation: bindings: add dt documentation for  rk3399 dmc Chanwoo Choi <cw00.choi@samsung.com> - 2016-08-23 07:10 +0200
          Re: [PATCH v6 6/8] Documentation: bindings: add dt documentation for  rk3399 dmc hl <hl@rock-chips.com> - 2016-08-23 21:00 +0200
  [PATCH v6 1/8] clk: rockchip: add new clock-type for the ddrclk Lin Huang <hl@rock-chips.com> - 2016-08-17 00:40 +0200
    Re: [PATCH v6 1/8] clk: rockchip: add new clock-type for the ddrclk Heiko Stuebner <heiko@sntech.de> - 2016-08-19 13:40 +0200
  [PATCH v6 3/8] clk: rockchip: rk3399: add ddrc clock support Lin Huang <hl@rock-chips.com> - 2016-08-17 00:40 +0200
    Re: [PATCH v6 3/8] clk: rockchip: rk3399: add ddrc clock support Heiko Stuebner <heiko@sntech.de> - 2016-08-19 14:30 +0200
  [PATCH v6 4/8] Documentation: bindings: add dt documentation for dfi controller Lin Huang <hl@rock-chips.com> - 2016-08-17 00:40 +0200
    Re: [PATCH v6 4/8] Documentation: bindings: add dt documentation for  dfi controller Chanwoo Choi <cw00.choi@samsung.com> - 2016-08-17 02:40 +0200
      Re: [PATCH v6 4/8] Documentation: bindings: add dt documentation for  dfi controller Chanwoo Choi <cw00.choi@samsung.com> - 2016-08-17 03:20 +0200
  [PATCH v6 8/8] drm/rockchip: Add dmc notifier in vop driver Lin Huang <hl@rock-chips.com> - 2016-08-17 00:40 +0200
    Re: [PATCH v6 8/8] drm/rockchip: Add dmc notifier in vop driver Sean Paul <seanpaul@chromium.org> - 2016-08-17 20:20 +0200
      Re: [PATCH v6 8/8] drm/rockchip: Add dmc notifier in vop driver hl <hl@rock-chips.com> - 2016-08-17 21:00 +0200

csiph-web