<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<meta content="text/html; charset=UTF-8">
<style type="text/css" style="">
<!--
p
        {margin-top:0;
        margin-bottom:0}
-->
</style>
<div dir="ltr">
<div id="x_divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:#000000; font-family:Calibri,Helvetica,sans-serif">
<p><span style="color:rgb(33,33,33); font-family:wf_segoe-ui_normal,"Segoe UI","Segoe WP",Tahoma,Arial,sans-serif,serif,EmojiFont; font-size:13.3333px">>> v2: - plane_id -> plane->id(Ville Syrjälä)</span><br style="color:rgb(33,33,33); font-family:wf_segoe-ui_normal,"Segoe UI","Segoe WP",Tahoma,Arial,sans-serif,serif,EmojiFont; font-size:13.3333px">
<br style="color:rgb(33,33,33); font-family:wf_segoe-ui_normal,"Segoe UI","Segoe WP",Tahoma,Arial,sans-serif,serif,EmojiFont; font-size:13.3333px">
<span style="color:rgb(33,33,33); font-family:wf_segoe-ui_normal,"Segoe UI","Segoe WP",Tahoma,Arial,sans-serif,serif,EmojiFont; font-size:13.3333px">>When did I say that? Can't find a previous review of this patch.</span><br style="color:rgb(33,33,33); font-family:wf_segoe-ui_normal,"Segoe UI","Segoe WP",Tahoma,Arial,sans-serif,serif,EmojiFont; font-size:13.3333px">
<span style="color:rgb(33,33,33); font-family:wf_segoe-ui_normal,"Segoe UI","Segoe WP",Tahoma,Arial,sans-serif,serif,EmojiFont; font-size:13.3333px">>Anywyas, that change seems to cause a lot of needless noise into the</span><br style="color:rgb(33,33,33); font-family:wf_segoe-ui_normal,"Segoe UI","Segoe WP",Tahoma,Arial,sans-serif,serif,EmojiFont; font-size:13.3333px">
<span style="color:rgb(33,33,33); font-family:wf_segoe-ui_normal,"Segoe UI","Segoe WP",Tahoma,Arial,sans-serif,serif,EmojiFont; font-size:13.3333px">>patch, and atm I can't see why we'd require it.</span><br>
</p>
<p><span style="color:rgb(33,33,33); font-family:wf_segoe-ui_normal,"Segoe UI","Segoe WP",Tahoma,Arial,sans-serif,serif,EmojiFont; font-size:13.3333px"><br>
</span></p>
<p><span style="color:rgb(33,33,33); font-family:wf_segoe-ui_normal,"Segoe UI","Segoe WP",Tahoma,Arial,sans-serif,serif,EmojiFont; font-size:13.3333px">Your comment was in <a href="https://patchwork.freedesktop.org/patch/345025/?series=68028&rev=14" class="x_OWAAutoLink" id="LPlnk516825">https://patchwork.freedesktop.org/patch/345025/?series=68028&rev=14</a>,</span></p>
<p>however I seem to have wrongly interpreted it. I think my motivation to switch</p>
<p>to plane based iteration was because its way easier to call skl_plane_wm_level</p>
<p>function then, because it takes plane itself as a parameter, also as it had already</p>
<p>an id, thought it is also better that way, rather than keeping one more variable</p>
<p>instead. Whatever.. I'm fine with both, that is not critical anyways.</p>
<p><br>
</p>
<div id="x_Signature">
<div style="font-family:Tahoma; font-size:13px"><font size="2"><span style="font-size:10pt">Stan</span></font></div>
</div>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Ville Syrjälä <ville.syrjala@linux.intel.com><br>
<b>Sent:</b> Thursday, February 27, 2020 5:51:52 PM<br>
<b>To:</b> Lisovskiy, Stanislav<br>
<b>Cc:</b> intel-gfx@lists.freedesktop.org; Ausmus, James; Saarinen, Jani; Roper, Matthew D<br>
<b>Subject:</b> Re: [PATCH v18 2/8] drm/i915: Introduce skl_plane_wm_level accessor.</font>
<div> </div>
</div>
</div>
<font size="2"><span style="font-size:10pt;">
<div class="PlainText">On Mon, Feb 24, 2020 at 05:32:34PM +0200, Stanislav Lisovskiy wrote:<br>
> For future Gen12 SAGV implementation we need to<br>
> seemlessly alter wm levels calculated, depending<br>
> on whether we are allowed to enable SAGV or not.<br>
> <br>
> So this accessor will give additional flexibility<br>
> to do that.<br>
> <br>
> Currently this accessor is still simply working<br>
> as "pass-through" function. This will be changed<br>
> in next coming patches from this series.<br>
> <br>
> v2: - plane_id -> plane->id(Ville Syrjälä)<br>
<br>
When did I say that? Can't find a previous review of this patch.<br>
Anywyas, that change seems to cause a lot of needless noise into the<br>
patch, and atm I can't see why we'd require it.<br>
<br>
>     - Moved wm_level var to have more local scope<br>
>       (Ville Syrjälä)<br>
>     - Renamed yuv to color_plane(Ville Syrjälä) in<br>
>       skl_plane_wm_level<br>
> <br>
> Signed-off-by: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com><br>
> ---<br>
>  drivers/gpu/drm/i915/intel_pm.c | 120 +++++++++++++++++++++-----------<br>
>  1 file changed, 81 insertions(+), 39 deletions(-)<br>
> <br>
> diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c<br>
> index d6933e382657..e1d167429489 100644<br>
> --- a/drivers/gpu/drm/i915/intel_pm.c<br>
> +++ b/drivers/gpu/drm/i915/intel_pm.c<br>
> @@ -4548,6 +4548,18 @@ icl_get_total_relative_data_rate(struct intel_crtc_state *crtc_state,<br>
>        return total_data_rate;<br>
>  }<br>
>  <br>
> +static const struct skl_wm_level *<br>
> +skl_plane_wm_level(struct intel_plane *plane,<br>
> +                const struct intel_crtc_state *crtc_state,<br>
<br>
nit: I'd put the crtc_state as the first parameter as that's the thing<br>
we're operating on. The other stuff just specifies which piece we want<br>
to dig out.<br>
<br>
> +                int level,<br>
> +                int color_plane)<br>
> +{<br>
> +     const struct skl_plane_wm *wm =<br>
> +             &crtc_state->wm.skl.optimal.planes[plane->id];<br>
> +<br>
> +     return color_plane ? &wm->uv_wm[level] : &wm->wm[level];<br>
> +}<br>
> +<br>
>  static int<br>
>  skl_allocate_pipe_ddb(struct intel_crtc_state *crtc_state)<br>
>  {<br>
> @@ -4560,7 +4572,7 @@ skl_allocate_pipe_ddb(struct intel_crtc_state *crtc_state)<br>
>        u16 total[I915_MAX_PLANES] = {};<br>
>        u16 uv_total[I915_MAX_PLANES] = {};<br>
>        u64 total_data_rate;<br>
> -     enum plane_id plane_id;<br>
> +     struct intel_plane *plane;<br>
>        int num_active;<br>
>        u64 plane_data_rate[I915_MAX_PLANES] = {};<br>
>        u64 uv_plane_data_rate[I915_MAX_PLANES] = {};<br>
> @@ -4612,22 +4624,28 @@ skl_allocate_pipe_ddb(struct intel_crtc_state *crtc_state)<br>
>         */<br>
>        for (level = ilk_wm_max_level(dev_priv); level >= 0; level--) {<br>
>                blocks = 0;<br>
> -             for_each_plane_id_on_crtc(intel_crtc, plane_id) {<br>
> -                     const struct skl_plane_wm *wm =<br>
> -                             &crtc_state->wm.skl.optimal.planes[plane_id];<br>
>  <br>
> -                     if (plane_id == PLANE_CURSOR) {<br>
> -                             if (wm->wm[level].min_ddb_alloc > total[PLANE_CURSOR]) {<br>
> +             for_each_intel_plane_on_crtc(&dev_priv->drm, intel_crtc, plane) {<br>
> +                     const struct skl_wm_level *wm_level;<br>
> +                     const struct skl_wm_level *wm_uv_level;<br>
> +<br>
> +                     wm_level = skl_plane_wm_level(plane, crtc_state,<br>
> +                                                   level, false);<br>
> +                     wm_uv_level = skl_plane_wm_level(plane, crtc_state,<br>
> +                                                      level, true);<br>
<br>
false/true aren't particularly sensible color plane indices.<br>
<br>
> +<br>
> +                     if (plane->id == PLANE_CURSOR) {<br>
> +                             if (wm_level->min_ddb_alloc > total[PLANE_CURSOR]) {<br>
>                                        drm_WARN_ON(&dev_priv->drm,<br>
> -                                                 wm->wm[level].min_ddb_alloc != U16_MAX);<br>
> +                                                 wm_level->min_ddb_alloc != U16_MAX);<br>
>                                        blocks = U32_MAX;<br>
>                                        break;<br>
>                                }<br>
>                                continue;<br>
>                        }<br>
>  <br>
> -                     blocks += wm->wm[level].min_ddb_alloc;<br>
> -                     blocks += wm->uv_wm[level].min_ddb_alloc;<br>
> +                     blocks += wm_level->min_ddb_alloc;<br>
> +                     blocks += wm_uv_level->min_ddb_alloc;<br>
>                }<br>
>  <br>
>                if (blocks <= alloc_size) {<br>
> @@ -4649,13 +4667,18 @@ skl_allocate_pipe_ddb(struct intel_crtc_state *crtc_state)<br>
>         * watermark level, plus an extra share of the leftover blocks<br>
>         * proportional to its relative data rate.<br>
>         */<br>
> -     for_each_plane_id_on_crtc(intel_crtc, plane_id) {<br>
> -             const struct skl_plane_wm *wm =<br>
> -                     &crtc_state->wm.skl.optimal.planes[plane_id];<br>
> +     for_each_intel_plane_on_crtc(&dev_priv->drm, intel_crtc, plane) {<br>
> +             const struct skl_wm_level *wm_level;<br>
> +             const struct skl_wm_level *wm_uv_level;<br>
>                u64 rate;<br>
>                u16 extra;<br>
>  <br>
> -             if (plane_id == PLANE_CURSOR)<br>
> +             wm_level = skl_plane_wm_level(plane, crtc_state,<br>
> +                                           level, false);<br>
> +             wm_uv_level = skl_plane_wm_level(plane, crtc_state,<br>
> +                                              level, true);<br>
> +<br>
> +             if (plane->id == PLANE_CURSOR)<br>
>                        continue;<br>
>  <br>
>                /*<br>
> @@ -4665,22 +4688,22 @@ skl_allocate_pipe_ddb(struct intel_crtc_state *crtc_state)<br>
>                if (total_data_rate == 0)<br>
>                        break;<br>
>  <br>
> -             rate = plane_data_rate[plane_id];<br>
> +             rate = plane_data_rate[plane->id];<br>
>                extra = min_t(u16, alloc_size,<br>
>                              DIV64_U64_ROUND_UP(alloc_size * rate,<br>
>                                                 total_data_rate));<br>
> -             total[plane_id] = wm->wm[level].min_ddb_alloc + extra;<br>
> +             total[plane->id] = wm_level->min_ddb_alloc + extra;<br>
>                alloc_size -= extra;<br>
>                total_data_rate -= rate;<br>
>  <br>
>                if (total_data_rate == 0)<br>
>                        break;<br>
>  <br>
> -             rate = uv_plane_data_rate[plane_id];<br>
> +             rate = uv_plane_data_rate[plane->id];<br>
>                extra = min_t(u16, alloc_size,<br>
>                              DIV64_U64_ROUND_UP(alloc_size * rate,<br>
>                                                 total_data_rate));<br>
> -             uv_total[plane_id] = wm->uv_wm[level].min_ddb_alloc + extra;<br>
> +             uv_total[plane->id] = wm_uv_level->min_ddb_alloc + extra;<br>
>                alloc_size -= extra;<br>
>                total_data_rate -= rate;<br>
>        }<br>
> @@ -4688,29 +4711,29 @@ skl_allocate_pipe_ddb(struct intel_crtc_state *crtc_state)<br>
>  <br>
>        /* Set the actual DDB start/end points for each plane */<br>
>        start = alloc->start;<br>
> -     for_each_plane_id_on_crtc(intel_crtc, plane_id) {<br>
> +     for_each_intel_plane_on_crtc(&dev_priv->drm, intel_crtc, plane) {<br>
>                struct skl_ddb_entry *plane_alloc =<br>
> -                     &crtc_state->wm.skl.plane_ddb_y[plane_id];<br>
> +                     &crtc_state->wm.skl.plane_ddb_y[plane->id];<br>
>                struct skl_ddb_entry *uv_plane_alloc =<br>
> -                     &crtc_state->wm.skl.plane_ddb_uv[plane_id];<br>
> +                     &crtc_state->wm.skl.plane_ddb_uv[plane->id];<br>
>  <br>
> -             if (plane_id == PLANE_CURSOR)<br>
> +             if (plane->id == PLANE_CURSOR)<br>
>                        continue;<br>
>  <br>
>                /* Gen11+ uses a separate plane for UV watermarks */<br>
>                drm_WARN_ON(&dev_priv->drm,<br>
> -                         INTEL_GEN(dev_priv) >= 11 && uv_total[plane_id]);<br>
> +                         INTEL_GEN(dev_priv) >= 11 && uv_total[plane->id]);<br>
>  <br>
>                /* Leave disabled planes at (0,0) */<br>
> -             if (total[plane_id]) {<br>
> +             if (total[plane->id]) {<br>
>                        plane_alloc->start = start;<br>
> -                     start += total[plane_id];<br>
> +                     start += total[plane->id];<br>
>                        plane_alloc->end = start;<br>
>                }<br>
>  <br>
> -             if (uv_total[plane_id]) {<br>
> +             if (uv_total[plane->id]) {<br>
>                        uv_plane_alloc->start = start;<br>
> -                     start += uv_total[plane_id];<br>
> +                     start += uv_total[plane->id];<br>
>                        uv_plane_alloc->end = start;<br>
>                }<br>
>        }<br>
> @@ -4722,9 +4745,16 @@ skl_allocate_pipe_ddb(struct intel_crtc_state *crtc_state)<br>
>         * that aren't actually possible.<br>
>         */<br>
>        for (level++; level <= ilk_wm_max_level(dev_priv); level++) {<br>
> -             for_each_plane_id_on_crtc(intel_crtc, plane_id) {<br>
> +             for_each_intel_plane_on_crtc(&dev_priv->drm, intel_crtc, plane) {<br>
> +                     const struct skl_wm_level *wm_level;<br>
> +                     const struct skl_wm_level *wm_uv_level;<br>
>                        struct skl_plane_wm *wm =<br>
> -                             &crtc_state->wm.skl.optimal.planes[plane_id];<br>
> +                             &crtc_state->wm.skl.optimal.planes[plane->id];<br>
> +<br>
> +                     wm_level = skl_plane_wm_level(plane, crtc_state,<br>
> +                                                   level, false);<br>
> +                     wm_uv_level = skl_plane_wm_level(plane, crtc_state,<br>
> +                                                      level, true);<br>
>  <br>
>                        /*<br>
>                         * We only disable the watermarks for each plane if<br>
> @@ -4738,9 +4768,10 @@ skl_allocate_pipe_ddb(struct intel_crtc_state *crtc_state)<br>
>                         *  planes must be enabled before the level will be used."<br>
>                         * So this is actually safe to do.<br>
>                         */<br>
> -                     if (wm->wm[level].min_ddb_alloc > total[plane_id] ||<br>
> -                         wm->uv_wm[level].min_ddb_alloc > uv_total[plane_id])<br>
> -                             memset(&wm->wm[level], 0, sizeof(wm->wm[level]));<br>
> +                     if (wm_level->min_ddb_alloc > total[plane->id] ||<br>
> +                         wm_uv_level->min_ddb_alloc > uv_total[plane->id])<br>
> +                             memset(&wm->wm[level], 0,<br>
> +                                    sizeof(struct skl_wm_level));<br>
>  <br>
>                        /*<br>
>                         * Wa_1408961008:icl, ehl<br>
> @@ -4748,9 +4779,14 @@ skl_allocate_pipe_ddb(struct intel_crtc_state *crtc_state)<br>
>                         */<br>
>                        if (IS_GEN(dev_priv, 11) &&<br>
>                            level == 1 && wm->wm[0].plane_en) {<br>
> -                             wm->wm[level].plane_res_b = wm->wm[0].plane_res_b;<br>
> -                             wm->wm[level].plane_res_l = wm->wm[0].plane_res_l;<br>
> -                             wm->wm[level].ignore_lines = wm->wm[0].ignore_lines;<br>
> +                             wm_level = skl_plane_wm_level(plane, crtc_state,<br>
> +                                                           0, false);<br>
> +                             wm->wm[level].plane_res_b =<br>
> +                                     wm_level->plane_res_b;<br>
> +                             wm->wm[level].plane_res_l =<br>
> +                                     wm_level->plane_res_l;<br>
> +                             wm->wm[level].ignore_lines =<br>
> +                                     wm_level->ignore_lines;<br>
>                        }<br>
>                }<br>
>        }<br>
> @@ -4759,11 +4795,11 @@ skl_allocate_pipe_ddb(struct intel_crtc_state *crtc_state)<br>
>         * Go back and disable the transition watermark if it turns out we<br>
>         * don't have enough DDB blocks for it.<br>
>         */<br>
> -     for_each_plane_id_on_crtc(intel_crtc, plane_id) {<br>
> +     for_each_intel_plane_on_crtc(&dev_priv->drm, intel_crtc, plane) {<br>
>                struct skl_plane_wm *wm =<br>
> -                     &crtc_state->wm.skl.optimal.planes[plane_id];<br>
> +                     &crtc_state->wm.skl.optimal.planes[plane->id];<br>
>  <br>
> -             if (wm->trans_wm.plane_res_b >= total[plane_id])<br>
> +             if (wm->trans_wm.plane_res_b >= total[plane->id])<br>
>                        memset(&wm->trans_wm, 0, sizeof(wm->trans_wm));<br>
>        }<br>
>  <br>
> @@ -5354,10 +5390,13 @@ void skl_write_plane_wm(struct intel_plane *plane,<br>
>                &crtc_state->wm.skl.plane_ddb_y[plane_id];<br>
>        const struct skl_ddb_entry *ddb_uv =<br>
>                &crtc_state->wm.skl.plane_ddb_uv[plane_id];<br>
> +     const struct skl_wm_level *wm_level;<br>
<br>
These can be in tighter scope.<br>
>  <br>
>        for (level = 0; level <= max_level; level++) {<br>
> +             wm_level = skl_plane_wm_level(plane, crtc_state, level, false);<br>
> +<br>
>                skl_write_wm_level(dev_priv, PLANE_WM(pipe, plane_id, level),<br>
> -                                &wm->wm[level]);<br>
> +                                wm_level);<br>
>        }<br>
>        skl_write_wm_level(dev_priv, PLANE_WM_TRANS(pipe, plane_id),<br>
>                           &wm->trans_wm);<br>
> @@ -5388,10 +5427,13 @@ void skl_write_cursor_wm(struct intel_plane *plane,<br>
>                &crtc_state->wm.skl.optimal.planes[plane_id];<br>
>        const struct skl_ddb_entry *ddb =<br>
>                &crtc_state->wm.skl.plane_ddb_y[plane_id];<br>
> +     const struct skl_wm_level *wm_level;<br>
>  <br>
>        for (level = 0; level <= max_level; level++) {<br>
> +             wm_level = skl_plane_wm_level(plane, crtc_state, level, false);<br>
> +<br>
>                skl_write_wm_level(dev_priv, CUR_WM(pipe, level),<br>
> -                                &wm->wm[level]);<br>
> +                                wm_level);<br>
>        }<br>
>        skl_write_wm_level(dev_priv, CUR_WM_TRANS(pipe), &wm->trans_wm);<br>
>  <br>
> -- <br>
> 2.24.1.485.gad05a3d8e5<br>
<br>
-- <br>
Ville Syrjälä<br>
Intel<br>
</div>
</span></font>
</body>
</html>