All of lore.kernel.org
 help / color / mirror / Atom feed
From: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
To: Mahesh Kumar <mahesh1.kumar@intel.com>, intel-gfx@lists.freedesktop.org
Cc: paulo.r.zanoni@intel.com, maarten.lankhorst@intel.com
Subject: Re: [PATCH 11/11] drm/i915/skl+: consider max supported plane pixel rate while scaling
Date: Thu, 11 May 2017 11:48:35 +0200	[thread overview]
Message-ID: <2c8b92b9-13f8-f6f4-b23e-8429c75ad143@linux.intel.com> (raw)
In-Reply-To: <4282cfec-e921-3cac-e7fd-e092e81ccd4d@intel.com>

Op 11-05-17 om 10:36 schreef Mahesh Kumar:
> Hi,
>
> Thanks for review.
>
> On Wednesday 10 May 2017 06:52 PM, Maarten Lankhorst wrote:
>> Op 08-05-17 om 13:49 schreef Mahesh Kumar:
>>> A display resolution is only supported if it meets all the restrictions
>>> below for Maximum Pipe Pixel Rate.
>>>
>>> The display resolution must fit within the maximum pixel rate output
>>> from the pipe. Make sure that the display pipe is able to feed pixels at
>>> a rate required to support the desired resolution.
>>> For each enabled plane on the pipe {
>>>      If plane scaling enabled {
>>>     Horizontal down scale amount = Maximum[1, plane horizontal size /
>>>             scaler horizontal window size]
>>>     Vertical down scale amount = Maximum[1, plane vertical size /
>>>             scaler vertical window size]
>>>     Plane down scale amount = Horizontal down scale amount *
>>>             Vertical down scale amount
>>>     Plane Ratio = 1 / Plane down scale amount
>>>      }
>>>      Else {
>>>     Plane Ratio = 1
>>>      }
>>>      If plane source pixel format is 64 bits per pixel {
>>>     Plane Ratio = Plane Ratio * 8/9
>>>      }
>>> }
>>>
>>> Pipe Ratio = Minimum Plane Ratio of all enabled planes on the pipe
>>>
>>> If pipe scaling is enabled {
>>>      Horizontal down scale amount = Maximum[1, pipe horizontal source size /
>>>         scaler horizontal window size]
>>>      Vertical down scale amount = Maximum[1, pipe vertical source size /
>>>         scaler vertical window size]
>>>      Note: The progressive fetch - interlace display mode is equivalent to a
>>>         2.0 vertical down scale
>>>      Pipe down scale amount = Horizontal down scale amount *
>>>         Vertical down scale amount
>>>      Pipe Ratio = Pipe Ratio / Pipe down scale amount
>>> }
>>>
>>> Pipe maximum pixel rate = CDCLK frequency * Pipe Ratio
>>>
>>> Signed-off-by: Mahesh Kumar <mahesh1.kumar@intel.com>
>>> ---
>>>   drivers/gpu/drm/i915/intel_display.c |  3 ++
>>>   drivers/gpu/drm/i915/intel_drv.h     |  2 +
>>>   drivers/gpu/drm/i915/intel_pm.c      | 87 ++++++++++++++++++++++++++++++++++++
>>>   3 files changed, 92 insertions(+)
>>>
>>> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
>>> index 85b9e2f521a0..d64367e810f8 100644
>>> --- a/drivers/gpu/drm/i915/intel_display.c
>>> +++ b/drivers/gpu/drm/i915/intel_display.c
>>> @@ -10992,6 +10992,9 @@ static int intel_crtc_atomic_check(struct drm_crtc *crtc,
>>>               ret = skl_update_scaler_crtc(pipe_config);
>>>             if (!ret)
>>> +            ret = skl_check_pipe_max_pixel_rate(intel_crtc,
>>> +                                pipe_config);
>>> +        if (!ret)
>>>               ret = intel_atomic_setup_scalers(dev_priv, intel_crtc,
>>>                                pipe_config);
>>>       }
>>> diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
>>> index 54f3ff840812..8323fc2ec4f2 100644
>>> --- a/drivers/gpu/drm/i915/intel_drv.h
>>> +++ b/drivers/gpu/drm/i915/intel_drv.h
>>> @@ -1859,6 +1859,8 @@ bool skl_ddb_allocation_overlaps(const struct skl_ddb_entry **entries,
>>>                    int ignore);
>>>   bool ilk_disable_lp_wm(struct drm_device *dev);
>>>   int sanitize_rc6_option(struct drm_i915_private *dev_priv, int enable_rc6);
>>> +int skl_check_pipe_max_pixel_rate(struct intel_crtc *intel_crtc,
>>> +                  struct intel_crtc_state *cstate);
>>>   static inline int intel_enable_rc6(void)
>>>   {
>>>       return i915.enable_rc6;
>>> diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
>>> index 92600cf42e12..69b1692ffd07 100644
>>> --- a/drivers/gpu/drm/i915/intel_pm.c
>>> +++ b/drivers/gpu/drm/i915/intel_pm.c
>>> @@ -3397,6 +3397,93 @@ skl_plane_downscale_amount(const struct intel_crtc_state *cstate,
>>>       return mul_fixed_16_16(downscale_w, downscale_h);
>>>   }
>>>   +static uint_fixed_16_16_t
>>> +skl_pipe_downscale_amount(const struct intel_crtc_state *config)
>>> +{
>>> +    uint_fixed_16_16_t pipe_downscale = u32_to_fixed_16_16(1);
>>> +
>>> +    if (!config->base.active)
>>> +        return pipe_downscale;
>>> +
>>> +    if (config->pch_pfit.enabled) {
>>> +        uint32_t src_w, src_h, dst_w, dst_h;
>>> +        uint32_t pfit_size = config->pch_pfit.size;
>>> +        uint_fixed_16_16_t fp_w_ratio, fp_h_ratio;
>>> +        uint_fixed_16_16_t downscale_h, downscale_w;
>>> +
>>> +        src_w = config->pipe_src_w;
>>> +        src_h = config->pipe_src_h;
>>> +        dst_w = pfit_size >> 16;
>>> +        dst_h = pfit_size & 0xffff;
>>> +
>>> +        if (!dst_w || !dst_h)
>>> +            return pipe_downscale;
>>> +
>>> +        fp_w_ratio = fixed_16_16_div(src_w, dst_w);
>>> +        fp_h_ratio = fixed_16_16_div(src_h, dst_h);
>>> +        downscale_w = max_fixed_16_16(fp_w_ratio, u32_to_fixed_16_16(1));
>>> +        downscale_h = max_fixed_16_16(fp_h_ratio, u32_to_fixed_16_16(1));
>>> +
>>> +        pipe_downscale = mul_fixed_16_16(downscale_w, downscale_h);
>>> +    }
>>> +
>>> +    return pipe_downscale;
>>> +}
>>> +
>>> +int skl_check_pipe_max_pixel_rate(struct intel_crtc *intel_crtc,
>>> +                  struct intel_crtc_state *cstate)
>>> +{
>>> +    struct drm_crtc_state *crtc_state = &cstate->base;
>>> +    struct drm_atomic_state *state = crtc_state->state;
>>> +    struct drm_plane *plane;
>>> +    const struct drm_plane_state *pstate;
>>> +    struct intel_plane_state *intel_pstate;
>>> +    int crtc_clock, cdclk;
>>> +    uint32_t pipe_max_pixel_rate;
>>> +    uint_fixed_16_16_t pipe_downscale;
>>> +    uint_fixed_16_16_t max_downscale = u32_to_fixed_16_16(1);
>>> +
>>> +    if (cstate->base.active)
>>> +        return 0;
>> ^This check looks buggy, are there any tests?
>>
>> In general we try to do the same for !active as we do with active, so please to remove any !active checks altogether..
> Thanks for catching this, yes it's a bug, during my testing this check was not there but I added this as an extra precaution & screwed-up :P
>>> +    drm_atomic_crtc_state_for_each_plane_state(plane, pstate, crtc_state) {
>>> +        uint_fixed_16_16_t plane_downscale;
>>> +        uint_fixed_16_16_t fp_9_div_8 = fixed_16_16_div(9, 8);
>>> +        int bpp;
>>> +
>>> +        if (!pstate->visible)
>>> +            continue;
>> Best use intel_wm_plane_visible here.
> will do,
>
> -Mahesh
>>> +
>>> +        if (WARN_ON(!pstate->fb))
>>> +            continue;
>>> +
>>> +        intel_pstate = to_intel_plane_state(pstate);
>>> +        plane_downscale = skl_plane_downscale_amount(cstate,
>>> +                                 intel_pstate);
>>> +        bpp = pstate->fb->format->cpp[0] * 8;
>>> +        if (bpp == 64)
>>> +            plane_downscale = mul_fixed_16_16(plane_downscale,
>>> +                              fp_9_div_8);
>>> +
>>> +        max_downscale = max_fixed_16_16(plane_downscale, max_downscale);
>>> +    }
>>> +    pipe_downscale = skl_pipe_downscale_amount(cstate);
>>> +
>>> +    pipe_downscale = mul_fixed_16_16(pipe_downscale, max_downscale);
>>> +
>>> +    crtc_clock = crtc_state->adjusted_mode.crtc_clock;
>>> +    cdclk = to_intel_atomic_state(state)->cdclk.logical.cdclk;
>>> +    pipe_max_pixel_rate = fixed_16_16_div_round_up_u64(cdclk,
>>> +                               pipe_downscale);
>>> +
>>> +    if (pipe_max_pixel_rate < crtc_clock) {
>>> +        DRM_ERROR("Max supported pixel clock with scaling exceeds\n");
>>> +        return -ERANGE; 
Oops, please also only return -EINVAL, definitely not ERANGE.

~Maarten
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2017-05-11  9:48 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-08 11:48 [PATCH 00/11] Implement DDB algorithm and WM cleanup Mahesh Kumar
2017-05-08 11:48 ` [PATCH 01/11] drm/i915: fix naming of fixed_16_16 wrapper Mahesh Kumar
2017-05-12  0:21   ` Matt Roper
2017-05-08 11:48 ` [PATCH 02/11] drm/i915: Add more wrapper for fixed_point_16_16 operations Mahesh Kumar
2017-05-10 12:37   ` Maarten Lankhorst
2017-05-12  0:22   ` Matt Roper
2017-05-12  8:55     ` Mahesh Kumar
2017-05-08 11:48 ` [PATCH 03/11] drm/i915: Use fixed_16_16 wrapper for division operation Mahesh Kumar
2017-05-12  0:22   ` Matt Roper
2017-05-08 11:48 ` [PATCH 04/11] drm/i915/skl+: calculate pixel_rate & relative_data_rate in fixed point Mahesh Kumar
2017-05-12  0:22   ` Matt Roper
2017-05-08 11:48 ` [PATCH 05/11] drm/i915/skl: Fail the flip if no FB for WM calculation Mahesh Kumar
2017-05-08 11:48   ` Lankhorst, Maarten
2017-05-08 12:01     ` Mahesh Kumar
2017-05-12  0:22       ` Matt Roper
2017-05-08 11:48 ` [PATCH 06/11] drm/i915/skl+: no need to memset again Mahesh Kumar
2017-05-12  0:23   ` Matt Roper
2017-05-08 11:48 ` [PATCH 07/11] drm/i915/skl+: Fail the flip if ddb min requirement exceeds pipe allocation Mahesh Kumar
2017-05-08 14:12   ` Ander Conselvan De Oliveira
2017-05-09  7:50     ` Mahesh Kumar
2017-05-09  7:52     ` Mahesh Kumar
2017-05-12  0:23   ` Matt Roper
2017-05-12 13:44     ` Mahesh Kumar
2017-05-08 11:48 ` [PATCH 08/11] drm/i915/skl+: Watermark calculation cleanup Mahesh Kumar
2017-05-12  0:23   ` Matt Roper
2017-05-12 13:47     ` Mahesh Kumar
2017-05-08 11:49 ` [PATCH 09/11] drm/i915/skl+: use linetime latency if ddb size is not available Mahesh Kumar
2017-05-08 11:49 ` [PATCH 10/11] drm/i915/skl: New ddb allocation algorithm Mahesh Kumar
2017-05-12 22:24   ` Matt Roper
2017-05-15  8:15     ` Mahesh Kumar
2017-05-08 11:49 ` [PATCH 11/11] drm/i915/skl+: consider max supported plane pixel rate while scaling Mahesh Kumar
2017-05-10 13:22   ` Maarten Lankhorst
2017-05-11  8:36     ` Mahesh Kumar
2017-05-11  9:48       ` Maarten Lankhorst [this message]
2017-05-11 10:59         ` Mahesh Kumar
2017-05-11 13:05         ` [PATCH v4 " Mahesh Kumar
2017-05-11  9:18     ` [PATCH v2] " Mahesh Kumar
2017-05-08 12:37 ` ✓ Fi.CI.BAT: success for Implement DDB algorithm and WM cleanup (rev2) Patchwork
2017-05-09  8:12 ` ✓ Fi.CI.BAT: success for Implement DDB algorithm and WM cleanup (rev4) Patchwork
2017-05-11  9:35 ` ✓ Fi.CI.BAT: success for Implement DDB algorithm and WM cleanup (rev5) Patchwork
2017-05-11 14:11 ` ✓ Fi.CI.BAT: success for Implement DDB algorithm and WM cleanup (rev6) Patchwork
2017-05-12  0:21 ` [PATCH 00/11] Implement DDB algorithm and WM cleanup Matt Roper
2017-05-12  8:25   ` Mahesh Kumar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2c8b92b9-13f8-f6f4-b23e-8429c75ad143@linux.intel.com \
    --to=maarten.lankhorst@linux.intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=maarten.lankhorst@intel.com \
    --cc=mahesh1.kumar@intel.com \
    --cc=paulo.r.zanoni@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.