<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">>> @@ -5829,6 +6068,10 @@ skl_compute_wm(struct intel_atomic_state *state)</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">>>                        return ret;</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">>>        }</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">>> </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">>> +     ret = intel_compute_sagv_mask(state);</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">>> +     if (ret)</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">>> +             return ret;</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">> This seems too early. We haven't even computed the ddb yet.</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"><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">I was thinking about our discussion last week and actually I think there are simply two ways how</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">to do it.</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"><br>
</span></p>
<p><font color="#212121" face="wf_segoe-ui_normal, Segoe UI, Segoe WP, Tahoma, Arial, sans-serif, serif, EmojiFont"><span style="font-size:13.3333px">1) What I do here is: calculate minimum amount required to fit SAGV wm levels into ddb and </span></font></p>
<p><font color="#212121" face="wf_segoe-ui_normal, Segoe UI, Segoe WP, Tahoma, Arial, sans-serif, serif, EmojiFont"><span style="font-size:13.3333px">based on that do the ddb allocation accordingly. I.e it is not to early because actually we have</span></font></p>
<p><font color="#212121" face="wf_segoe-ui_normal, Segoe UI, Segoe WP, Tahoma, Arial, sans-serif, serif, EmojiFont"><span style="font-size:13.3333px">already wm levels for sagv and non-sagv calculated - we already can check if it can fit into L0</span></font></p>
<p><font color="#212121" face="wf_segoe-ui_normal, Segoe UI, Segoe WP, Tahoma, Arial, sans-serif, serif, EmojiFont"><span style="font-size:13.3333px">and then act accordingly. </span></font></p>
<p><font color="#212121" face="wf_segoe-ui_normal, Segoe UI, Segoe WP, Tahoma, Arial, sans-serif, serif, EmojiFont"><span style="font-size:13.3333px">However one thing to consider here: as you said besides the minimal requirements for each plane</span></font></p>
<p><font color="#212121" face="wf_segoe-ui_normal, Segoe UI, Segoe WP, Tahoma, Arial, sans-serif, serif, EmojiFont"><span style="font-size:13.3333px">(with or without sagv) there is an extra space being allocated in proportion to plane data rate,</span></font></p>
<p><font color="#212121" face="wf_segoe-ui_normal, Segoe UI, Segoe WP, Tahoma, Arial, sans-serif, serif, EmojiFont"><span style="font-size:13.3333px">however here we are actually hitting the prioritization issue - i.e we need to decide whether </span></font></p>
<p><font color="#212121" face="wf_segoe-ui_normal, Segoe UI, Segoe WP, Tahoma, Arial, sans-serif, serif, EmojiFont"><span style="font-size:13.3333px">it is more important to have SAGV or to have more extra space allocated to different planes</span></font></p>
<p><font color="#212121" face="wf_segoe-ui_normal, Segoe UI, Segoe WP, Tahoma, Arial, sans-serif, serif, EmojiFont"><span style="font-size:13.3333px">proportionally to their needs.</span></font></p>
<p><font color="#212121" face="wf_segoe-ui_normal, Segoe UI, Segoe WP, Tahoma, Arial, sans-serif, serif, EmojiFont"><span style="font-size:13.3333px">So in this first approach we always first determine if we fit into minimum SAGV reqs, turn it </span></font></p>
<p><font color="#212121" face="wf_segoe-ui_normal, Segoe UI, Segoe WP, Tahoma, Arial, sans-serif, serif, EmojiFont"><span style="font-size:13.3333px">on if we do and then rest of extra space is allocated among the planes in proportion to data rate.</span></font></p>
<p><font color="#212121" face="wf_segoe-ui_normal, Segoe UI, Segoe WP, Tahoma, Arial, sans-serif, serif, EmojiFont"><span style="font-size:13.3333px">So that way we would be more often power efficient but but planes get less extra ddb space.</span></font></p>
<p><font color="#212121" face="wf_segoe-ui_normal, Segoe UI, Segoe WP, Tahoma, Arial, sans-serif, serif, EmojiFont"><span style="font-size:13.3333px"><br>
</span></font></p>
<p><font color="#212121" face="wf_segoe-ui_normal, Segoe UI, Segoe WP, Tahoma, Arial, sans-serif, serif, EmojiFont"><span style="font-size:13.3333px">2) In your approach we should calculate ddb first, allocate extra space proportionally to plane</span></font></p>
<p><font color="#212121" face="wf_segoe-ui_normal, Segoe UI, Segoe WP, Tahoma, Arial, sans-serif, serif, EmojiFont"><span style="font-size:13.3333px">data rate needs and only then check if all planes got enough space for L0 SAGV wm after that.</span></font></p>
<p><font color="#212121" face="wf_segoe-ui_normal, Segoe UI, Segoe WP, Tahoma, Arial, sans-serif, serif, EmojiFont"><span style="font-size:13.3333px">Then we actually don't even need skl_plane_wm_level accessor, because we first would be allocating</span></font></p>
<p><font color="#212121" face="wf_segoe-ui_normal, Segoe UI, Segoe WP, Tahoma, Arial, sans-serif, serif, EmojiFont"><span style="font-size:13.3333px">using normal wm levels + extra ddb and only then check if all planes fit into SAGV requirement -</span></font></p>
<p><font color="#212121" face="wf_segoe-ui_normal, Segoe UI, Segoe WP, Tahoma, Arial, sans-serif, serif, EmojiFont"><span style="font-size:13.3333px">because that extra space is not actually distributed evenly but in proportion to data rate of each</span></font></p>
<p><font color="#212121" face="wf_segoe-ui_normal, Segoe UI, Segoe WP, Tahoma, Arial, sans-serif, serif, EmojiFont"><span style="font-size:13.3333px">plane, which means that some planes might lack space for SAGV theoretically, because some might be</span></font></p>
<p><font color="#212121" face="wf_segoe-ui_normal, Segoe UI, Segoe WP, Tahoma, Arial, sans-serif, serif, EmojiFont"><span style="font-size:13.3333px">getting more or less depending on the data_rate/total_data_rate ratio.</span></font></p>
<p><font color="#212121" face="wf_segoe-ui_normal, Segoe UI, Segoe WP, Tahoma, Arial, sans-serif, serif, EmojiFont"><span style="font-size:13.3333px"><br>
</span></font></p>
<p><font color="#212121" face="wf_segoe-ui_normal, Segoe UI, Segoe WP, Tahoma, Arial, sans-serif, serif, EmojiFont"><span style="font-size:13.3333px">My position is such that I'm really not like "my approach should always win" here, but more searching for</span></font></p>
<p><font color="#212121" face="wf_segoe-ui_normal, Segoe UI, Segoe WP, Tahoma, Arial, sans-serif, serif, EmojiFont"><span style="font-size:13.3333px">solution which is more correct from product point of view.</span></font></p>
<p><font color="#212121" face="wf_segoe-ui_normal, Segoe UI, Segoe WP, Tahoma, Arial, sans-serif, serif, EmojiFont"><span style="font-size:13.3333px"><br>
</span></font></p>
<p><font color="#212121" face="wf_segoe-ui_normal, Segoe UI, Segoe WP, Tahoma, Arial, sans-serif, serif, EmojiFont"><span style="font-size:13.3333px">Also could be that it doesn't really matter which approach we do take now,,</span></font><span style="font-size:13.3333px; color:rgb(33,33,33); font-family:wf_segoe-ui_normal,"Segoe UI","Segoe WP",Tahoma,Arial,sans-serif,serif,EmojiFont"> </span><span style="font-size:13.3333px; color:rgb(33,33,33); font-family:wf_segoe-ui_normal,"Segoe UI","Segoe WP",Tahoma,Arial,sans-serif,serif,EmojiFont">but
 matter more like</span></p>
<p><font color="#212121" face="wf_segoe-ui_normal, Segoe UI, Segoe WP, Tahoma, Arial, sans-serif, serif, EmojiFont"><span style="font-size:13.3333px">that how fast we deliver.  B</span></font><span style="font-size:13.3333px; color:rgb(33,33,33); font-family:wf_segoe-ui_normal,"Segoe UI","Segoe WP",Tahoma,Arial,sans-serif,serif,EmojiFont">ecause
 the actual outcome difference between two</span><font color="#212121" face="wf_segoe-ui_normal, Segoe UI, Segoe WP, Tahoma, Arial, sans-serif, serif, EmojiFont"><span style="font-size:13.3333px"></p>
<p style="font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:16px">
<font color="#212121" face="wf_segoe-ui_normal, Segoe UI, Segoe WP, Tahoma, Arial, sans-serif, serif, EmojiFont"><span style="font-size:13.3333px">might be minor, while time overhead for changing the approach could be major.</span></font></p>
</span></font>
<p></p>
<p><br>
</p>
<div id="x_Signature">
<div style="font-family:Tahoma; font-size:13px"><font size="2"><span style="font-size:10pt">Best Regards,<br>
<br>
Lisovskiy Stanislav <br>
</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> Wednesday, March 11, 2020 6:31:30 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 v19 4/8] drm/i915: Refactor intel_can_enable_sagv</font>
<div> </div>
</div>
</div>
<font size="2"><span style="font-size:10pt;">
<div class="PlainText">On Mon, Mar 09, 2020 at 06:12:00PM +0200, Stanislav Lisovskiy wrote:<br>
> Currently intel_can_enable_sagv function contains<br>
> a mix of workarounds for different platforms<br>
> some of them are not valid for gens >= 11 already,<br>
> so lets split it into separate functions.<br>
> <br>
> v2:<br>
>     - Rework watermark calculation algorithm to<br>
>       attempt to calculate Level 0 watermark<br>
>       with added sagv block time latency and<br>
>       check if it fits in DBuf in order to<br>
>       determine if SAGV can be enabled already<br>
>       at this stage, just as BSpec 49325 states.<br>
>       if that fails rollback to usual Level 0<br>
>       latency and disable SAGV.<br>
>     - Remove unneeded tabs(James Ausmus)<br>
> <br>
> v3: Rebased the patch<br>
> <br>
> v4: - Added back interlaced check for Gen12 and<br>
>       added separate function for TGL SAGV check<br>
>       (thanks to James Ausmus for spotting)<br>
>     - Removed unneeded gen check<br>
>     - Extracted Gen12 SAGV decision making code<br>
>       to a separate function from skl_compute_wm<br>
> <br>
> v5: - Added SAGV global state to dev_priv, because<br>
>       we need to track all pipes, not only those<br>
>       in atomic state. Each pipe has now correspondent<br>
>       bit mask reflecting, whether it can tolerate<br>
>       SAGV or not(thanks to Ville Syrjala for suggestions).<br>
>     - Now using active flag instead of enable in crc<br>
>       usage check.<br>
> <br>
> v6: - Fixed rebase conflicts<br>
> <br>
> v7: - kms_cursor_legacy seems to get broken because of multiple memcpy<br>
>       calls when copying level 0 water marks for enabled SAGV, to<br>
>       fix this now simply using that field right away, without copying,<br>
>       for that introduced a new wm_level accessor which decides which<br>
>       wm_level to return based on SAGV state.<br>
> <br>
> v8: - Protect crtc_sagv_mask same way as we do for other global state<br>
>       changes: i.e check if changes are needed, then grab all crtc locks<br>
>       to serialize the changes(Ville Syrjälä)<br>
>     - Add crtc_sagv_mask caching in order to avoid needless recalculations<br>
>       (Matthew Roper)<br>
>     - Put back Gen12 SAGV switch in order to get it enabled in separate<br>
>       patch(Matthew Roper)<br>
>     - Rename *_set_sagv_mask to *_compute_sagv_mask(Matthew Roper)<br>
>     - Check if there are no active pipes in intel_can_enable_sagv<br>
>       instead of platform specific functions(Matthew Roper), same<br>
>       for intel_has_sagv check.<br>
> <br>
> v9  - Switched to u8 for crtc_sagv_mask(Ville Syrjälä)<br>
>     - crtc_sagv_mask now is pipe_sagv_mask(Ville Syrjälä)<br>
>     - Extracted sagv checking logic from skl/icl/tgl_compute_sagv_mask<br>
>     - Extracted skl_plane_wm_level function and passing latency to<br>
>       separate patches(Ville Syrjälä)<br>
>     - Removed part of unneeded copy-paste from tgl_check_pipe_fits_sagv_wm<br>
>       (Ville Syrjälä)<br>
>     - Now using simple assignment for sagv_wm0 as it contains only<br>
>       pod types and no pointers(Ville Syrjälä)<br>
>     - Fixed intel_can_enable_sagv not to do double duty, now it only<br>
>       check SAGV bits by ANDing those between local and global state.<br>
>       The SAGV masks are now computed after watermarks are available,<br>
>       in order to be able to figure out if ddb ranges are fitting nicely.<br>
>       (Ville Syrjälä)<br>
>     - Now having uv_sagv_wm0 and sagv_wm0, otherwise we have wrong logic<br>
>       when using skl_plane_wm_level accessor, as we had previously for<br>
>       Gen11+ color plane and regular wm levels, so probably both<br>
>       has to be recalculated with additional SAGV block time for Level 0.<br>
> <br>
> v10: - Starting to use new global state for storing pipe_sagv_mask<br>
> <br>
> v11: - Fixed rebase conflict with recent drm-tip<br>
>      - Check if we really need to recalculate SAGV mask, otherwise<br>
>        bail out without making any changes.<br>
>      - Use cached SAGV result, instead of recalculating it everytime,<br>
>        if bw_state hasn't changed.<br>
> <br>
> v12: - Removed WARN from intel_can_enable_sagv, in some of the commits<br>
>        if we don't recalculated watermarks, bw_state is not recalculated,<br>
>        thus leading to SAGV state not recalculated by the commit state,<br>
>        which is still calling intel_can_enable_sagv function. Fix that<br>
>        by just analyzing the current global bw_state object - because<br>
>        we simply have no other objects related to that.<br>
> <br>
> v13: - Rebased, fixed warnings regarding long lines<br>
>      - Changed function call sites from intel_atomic_bw* to<br>
>        intel_wb_* as was suggested.(Jani Nikula)<br>
>      - Taken ddb_state_changed and bw_state_changed into use.<br>
> <br>
> v14: - total_affected_planes is no longer needed to check for ddb changes,<br>
>        just as active_pipe_changes.<br>
> <br>
> v15: - Fixed stupid mistake with uninitialized crtc in<br>
>        skl_compute_sagv_mask.<br>
> <br>
> v16: - Convert pipe_sagv_mask to pipe_sagv_reject and now using inverted<br>
>        flag to indicate SAGV readiness for the pipe(Ville Syrjälä)<br>
>      - Added return value to intel_compute_sagv_mask which call<br>
>        intel_atomic_serialize_global_state in order to properly<br>
>        propagate EDEADLCK to drm.<br>
>      - Based on the discussion with Ville, removed active_pipe_changes<br>
>        check and also there seems to be no need for checking ddb_state_changes<br>
>        as well. Instead we just iterate through crtcs in state - having<br>
>        crtc in a state already guarantees that it is at least read-locked<br>
>        Having additional flag to check if there actually were some plane<br>
>        wm/ddb changes would be probably added later as an optimization.<br>
>      - We can't get parent atomic state from crtc_state at commit stage<br>
>        (nice drm feature), also propagating state through function call<br>
>        chain seems to be overkill and not possible(cursor legacy updates)<br>
>        Querying for bw_state object from global state is not possible as<br>
>        it might get swapped with other global state.<br>
>        So... just sticked can_sagv boolean into wm crtc state.<br>
> <br>
> Signed-off-by: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com><br>
> Cc: Ville Syrjälä <ville.syrjala@intel.com><br>
> Cc: James Ausmus <james.ausmus@intel.com><br>
> ---<br>
>  drivers/gpu/drm/i915/display/intel_bw.h       |  18 +<br>
>  drivers/gpu/drm/i915/display/intel_display.c  |  23 +-<br>
>  .../drm/i915/display/intel_display_types.h    |   3 +<br>
>  drivers/gpu/drm/i915/intel_pm.c               | 314 ++++++++++++++++--<br>
>  drivers/gpu/drm/i915/intel_pm.h               |   1 +<br>
>  5 files changed, 318 insertions(+), 41 deletions(-)<br>
> <br>
> diff --git a/drivers/gpu/drm/i915/display/intel_bw.h b/drivers/gpu/drm/i915/display/intel_bw.h<br>
> index b5f61463922f..4083adf4b432 100644<br>
> --- a/drivers/gpu/drm/i915/display/intel_bw.h<br>
> +++ b/drivers/gpu/drm/i915/display/intel_bw.h<br>
> @@ -18,6 +18,24 @@ struct intel_crtc_state;<br>
>  struct intel_bw_state {<br>
>        struct intel_global_state base;<br>
>  <br>
> +     /*<br>
> +      * Contains a bit mask, used to determine, whether correspondent<br>
> +      * pipe allows SAGV or not.<br>
> +      */<br>
> +     u8 pipe_sagv_reject;<br>
> +<br>
> +     /*<br>
> +      * Used to determine if we already had calculated<br>
> +      * SAGV mask for this state once.<br>
> +      */<br>
> +     bool sagv_calculated;<br>
<br>
Why would we even attempt to calculate it many times?<br>
<br>
> +<br>
> +     /*<br>
> +      * Contains final SAGV decision based on current mask,<br>
> +      * to prevent doing the same job over and over again.<br>
> +      */<br>
> +     bool can_sagv;<br>
<br>
This is redundant since it's just sagv_reject==0.<br>
<br>
> +<br>
>        unsigned int data_rate[I915_MAX_PIPES];<br>
>        u8 num_active_planes[I915_MAX_PIPES];<br>
>  };<br>
> diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c<br>
> index 8f23c4d51c33..9e0058a78ea6 100644<br>
> --- a/drivers/gpu/drm/i915/display/intel_display.c<br>
> +++ b/drivers/gpu/drm/i915/display/intel_display.c<br>
> @@ -14010,7 +14010,10 @@ static void verify_wm_state(struct intel_crtc *crtc,<br>
>                /* Watermarks */<br>
>                for (level = 0; level <= max_level; level++) {<br>
>                        if (skl_wm_level_equals(&hw_plane_wm->wm[level],<br>
> -                                             &sw_plane_wm->wm[level]))<br>
> +                                             &sw_plane_wm->wm[level]) ||<br>
> +                        (skl_wm_level_equals(&hw_plane_wm->wm[level],<br>
> +                                             &sw_plane_wm->sagv_wm0) &&<br>
> +                        (level == 0)))<br>
<br>
Pointless parens. Also we should do the check as<br>
'level == 0 && wm_equals(sagv)' to skip the pointless comparison when<br>
level != 0.<br>
<br>
I guess we can't read out sagv state due to the silly pcode interface?<br>
<br>
>                                continue;<br>
>  <br>
>                        drm_err(&dev_priv->drm,<br>
> @@ -14065,7 +14068,10 @@ static void verify_wm_state(struct intel_crtc *crtc,<br>
>                /* Watermarks */<br>
>                for (level = 0; level <= max_level; level++) {<br>
>                        if (skl_wm_level_equals(&hw_plane_wm->wm[level],<br>
> -                                             &sw_plane_wm->wm[level]))<br>
> +                                             &sw_plane_wm->wm[level]) ||<br>
> +                        (skl_wm_level_equals(&hw_plane_wm->wm[level],<br>
> +                                             &sw_plane_wm->sagv_wm0) &&<br>
> +                        (level == 0)))<br>
>                                continue;<br>
>  <br>
>                        drm_err(&dev_priv->drm,<br>
> @@ -15544,8 +15550,10 @@ static void intel_atomic_commit_tail(struct intel_atomic_state *state)<br>
>                 * SKL workaround: bspec recommends we disable the SAGV when we<br>
>                 * have more then one pipe enabled<br>
>                 */<br>
> -             if (!intel_can_enable_sagv(state))<br>
> -                     intel_disable_sagv(dev_priv);<br>
> +             if (INTEL_GEN(dev_priv) < 11) {<br>
> +                     if (!intel_can_enable_sagv(state))<br>
> +                             intel_disable_sagv(dev_priv);<br>
> +             }<br>
>  <br>
>                intel_modeset_verify_disabled(dev_priv, state);<br>
>        }<br>
> @@ -15645,8 +15653,10 @@ static void intel_atomic_commit_tail(struct intel_atomic_state *state)<br>
>        if (state->modeset)<br>
>                intel_verify_planes(state);<br>
>  <br>
> -     if (state->modeset && intel_can_enable_sagv(state))<br>
> -             intel_enable_sagv(dev_priv);<br>
> +     if (INTEL_GEN(dev_priv) < 11) {<br>
> +             if (state->modeset && intel_can_enable_sagv(state))<br>
> +                     intel_enable_sagv(dev_priv);<br>
> +     }<br>
>  <br>
>        drm_atomic_helper_commit_hw_done(&state->base);<br>
>  <br>
> @@ -15798,7 +15808,6 @@ static int intel_atomic_commit(struct drm_device *dev,<br>
>  <br>
>        if (state->global_state_changed) {<br>
>                assert_global_state_locked(dev_priv);<br>
> -<br>
>                dev_priv->active_pipes = state->active_pipes;<br>
>        }<br>
>  <br>
> diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h<br>
> index 5e00e611f077..da0308b87dad 100644<br>
> --- a/drivers/gpu/drm/i915/display/intel_display_types.h<br>
> +++ b/drivers/gpu/drm/i915/display/intel_display_types.h<br>
> @@ -669,11 +669,14 @@ struct skl_plane_wm {<br>
>        struct skl_wm_level wm[8];<br>
>        struct skl_wm_level uv_wm[8];<br>
>        struct skl_wm_level trans_wm;<br>
> +     struct skl_wm_level sagv_wm0;<br>
> +     struct skl_wm_level uv_sagv_wm0;<br>
>        bool is_planar;<br>
>  };<br>
>  <br>
>  struct skl_pipe_wm {<br>
>        struct skl_plane_wm planes[I915_MAX_PLANES];<br>
> +     bool can_sagv;<br>
>  };<br>
>  <br>
>  enum vlv_wm_level {<br>
> diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c<br>
> index c72fa59a8302..f598b55f4abc 100644<br>
> --- a/drivers/gpu/drm/i915/intel_pm.c<br>
> +++ b/drivers/gpu/drm/i915/intel_pm.c<br>
> @@ -43,6 +43,7 @@<br>
>  #include "i915_fixed.h"<br>
>  #include "i915_irq.h"<br>
>  #include "i915_trace.h"<br>
> +#include "display/intel_bw.h"<br>
>  #include "intel_pm.h"<br>
>  #include "intel_sideband.h"<br>
>  #include "../../../platform/x86/intel_ips.h"<br>
> @@ -3634,7 +3635,7 @@ static bool skl_needs_memory_bw_wa(struct drm_i915_private *dev_priv)<br>
>        return IS_GEN9_BC(dev_priv) || IS_BROXTON(dev_priv);<br>
>  }<br>
>  <br>
> -static bool<br>
> +bool<br>
>  intel_has_sagv(struct drm_i915_private *dev_priv)<br>
>  {<br>
>        /* HACK! */<br>
> @@ -3757,39 +3758,25 @@ intel_disable_sagv(struct drm_i915_private *dev_priv)<br>
>        return 0;<br>
>  }<br>
>  <br>
> -bool intel_can_enable_sagv(struct intel_atomic_state *state)<br>
> +static bool skl_can_enable_sagv_on_pipe(struct intel_crtc_state *crtc_state)<br>
<br>
This extraction looks to be trivially done as a separate patch.<br>
<br>
>  {<br>
> -     struct drm_device *dev = state->base.dev;<br>
> +     struct drm_device *dev = crtc_state->uapi.crtc->dev;<br>
>        struct drm_i915_private *dev_priv = to_i915(dev);<br>
> +     struct intel_atomic_state *state = to_intel_atomic_state(crtc_state->uapi.state);<br>
>        struct intel_crtc *crtc;<br>
>        struct intel_plane *plane;<br>
> -     struct intel_crtc_state *crtc_state;<br>
> -     enum pipe pipe;<br>
>        int level, latency;<br>
>  <br>
> -     if (!intel_has_sagv(dev_priv))<br>
> -             return false;<br>
> -<br>
> -     /*<br>
> -      * If there are no active CRTCs, no additional checks need be performed<br>
> -      */<br>
> -     if (hweight8(state->active_pipes) == 0)<br>
> -             return true;<br>
> +     crtc = to_intel_crtc(crtc_state->uapi.crtc);<br>
>  <br>
> -     /*<br>
> -      * SKL+ workaround: bspec recommends we disable SAGV when we have<br>
> -      * more then one pipe enabled<br>
> -      */<br>
> -     if (hweight8(state->active_pipes) > 1)<br>
> +     if ((INTEL_GEN(dev_priv) <= 9) && (hweight8(state->active_pipes) > 1))<br>
>                return false;<br>
>  <br>
> -     /* Since we're now guaranteed to only have one active CRTC... */<br>
> -     pipe = ffs(state->active_pipes) - 1;<br>
> -     crtc = intel_get_crtc_for_pipe(dev_priv, pipe);<br>
> -     crtc_state = to_intel_crtc_state(crtc->base.state);<br>
> -<br>
> -     if (crtc_state->hw.adjusted_mode.flags & DRM_MODE_FLAG_INTERLACE)<br>
> +     if (crtc_state->hw.adjusted_mode.flags & DRM_MODE_FLAG_INTERLACE) {<br>
> +             DRM_DEBUG_KMS("No SAGV for interlaced mode on pipe %c\n",<br>
> +                           pipe_name(crtc->pipe));<br>
>                return false;<br>
> +     }<br>
>  <br>
>        for_each_intel_plane_on_crtc(dev, crtc, plane) {<br>
>                struct skl_plane_wm *wm =<br>
> @@ -3816,13 +3803,145 @@ bool intel_can_enable_sagv(struct intel_atomic_state *state)<br>
>                 * incur memory latencies higher than sagv_block_time_us we<br>
>                 * can't enable SAGV.<br>
>                 */<br>
> -             if (latency < dev_priv->sagv_block_time_us)<br>
> +             if (latency < dev_priv->sagv_block_time_us) {<br>
> +                     DRM_DEBUG_KMS("Latency %d < sagv block time %d, no SAGV for pipe %c\n",<br>
> +                                   latency, dev_priv->sagv_block_time_us, pipe_name(crtc->pipe));<br>
>                        return false;<br>
> +             }<br>
>        }<br>
>  <br>
>        return true;<br>
>  }<br>
>  <br>
> +static bool<br>
> +tgl_can_enable_sagv_on_pipe(struct intel_crtc_state *crtc_state);<br>
> +<br>
> +static bool intel_calculate_sagv_result(struct intel_bw_state *bw_state)<br>
> +{<br>
> +     return bw_state->pipe_sagv_reject == 0;<br>
> +}<br>
> +<br>
> +static int intel_compute_sagv_mask(struct intel_atomic_state *state)<br>
> +{<br>
> +     int ret;<br>
> +     struct drm_device *dev = state->base.dev;<br>
> +     struct drm_i915_private *dev_priv = to_i915(dev);<br>
> +     struct intel_crtc *crtc;<br>
> +     struct intel_crtc_state *new_crtc_state;<br>
> +     struct intel_bw_state *new_bw_state = NULL;<br>
> +     struct intel_bw_state *old_bw_state = NULL;<br>
> +     int i;<br>
> +<br>
> +     /*<br>
> +      * If SAGV is not supported we just can't do anything<br>
> +      * not even set or reject SAGV points - just bail out.<br>
> +      * Thus avoid needless calculations.<br>
> +      */<br>
> +     if (!intel_has_sagv(dev_priv))<br>
> +             return 0;<br>
> +<br>
> +     for_each_new_intel_crtc_in_state(state, crtc,<br>
> +                                      new_crtc_state, i) {<br>
> +             bool pipe_sagv_enable;<br>
> +<br>
> +             new_bw_state = intel_bw_get_state(state);<br>
> +             old_bw_state = intel_bw_get_old_state(state);<br>
> +<br>
> +             if (IS_ERR_OR_NULL(new_bw_state) || IS_ERR_OR_NULL(old_bw_state)) {a<br>
> +                     WARN(1, "Could not get bw_state\n");<br>
> +                     return -EINVAL;<br>
<br>
What is this?<br>
<br>
> +             }<br>
> +<br>
> +             new_bw_state->sagv_calculated = false;<br>
> +<br>
> +             if (INTEL_GEN(dev_priv) >= 12)<br>
> +                     pipe_sagv_enable = tgl_can_enable_sagv_on_pipe(new_crtc_state);<br>
> +             else<br>
> +                     pipe_sagv_enable = skl_can_enable_sagv_on_pipe(new_crtc_state);<br>
> +<br>
> +             if (pipe_sagv_enable)<br>
> +                     new_bw_state->pipe_sagv_reject &= ~BIT(crtc->pipe);<br>
> +             else<br>
> +                     new_bw_state->pipe_sagv_reject |= BIT(crtc->pipe);<br>
> +     }<br>
> +<br>
> +     if (!new_bw_state || !old_bw_state)<br>
> +             return 0;<br>
> +<br>
> +     new_bw_state->can_sagv = intel_calculate_sagv_result(new_bw_state);<br>
> +     new_bw_state->sagv_calculated = true;<br>
> +<br>
> +     for_each_new_intel_crtc_in_state(state, crtc,<br>
> +                                      new_crtc_state, i) {<br>
> +             struct skl_pipe_wm *pipe_wm = &new_crtc_state->wm.skl.optimal;<br>
> +<br>
> +             /*<br>
> +              * Due to drm limitation at commit state, when<br>
> +              * changes are written the whole atomic state is<br>
> +              * zeroed away => which prevents from using it,<br>
> +              * so just sticking it into pipe wm state for<br>
> +              * keeping it simple - anyway this is related to wm.<br>
> +              * Proper way in ideal universe would be of course not<br>
> +              * to lose parent atomic state object from child crtc_state,<br>
> +              * and stick to OOP programming principles, which had been<br>
> +              * scientifically proven to work.<br>
> +              */<br>
> +             pipe_wm->can_sagv = new_bw_state->can_sagv;<br>
<br>
I would probably name that wm->can_sagv as wm->use_sagv_wm so it's clear<br>
what it does.<br>
<br>
> +     }<br>
> +<br>
> +     /*<br>
> +      * For SAGV we need to account all the pipes,<br>
> +      * not only the ones which are in state currently.<br>
> +      * Grab all locks if we detect that we are actually<br>
> +      * going to do something.<br>
> +      */<br>
> +     if (new_bw_state->pipe_sagv_reject != old_bw_state->pipe_sagv_reject) {<br>
> +             DRM_DEBUG_KMS("State %p: old sagv mask 0x%x, new sagv mask 0x%x\n",<br>
> +                           state,<br>
> +                           old_bw_state->pipe_sagv_reject,<br>
> +                           new_bw_state->pipe_sagv_reject);<br>
> +<br>
> +             ret = intel_atomic_serialize_global_state(&new_bw_state->base);<br>
> +             if (ret) {<br>
> +                     DRM_DEBUG_KMS("Could not serialize global state\n");<br>
> +                     return ret;<br>
> +             }<br>
> +     }<br>
> +<br>
> +     return 0;<br>
> +}<br>
> +<br>
> +/*<br>
> + * This function to be used before swap state<br>
> + */<br>
> +bool intel_can_enable_sagv(struct intel_atomic_state *state)<br>
> +{<br>
> +     struct drm_device *dev = state->base.dev;<br>
> +     struct drm_i915_private *dev_priv = to_i915(dev);<br>
> +     struct intel_bw_state *bw_state;<br>
> +<br>
> +     if (!intel_has_sagv(dev_priv)) {<br>
> +             DRM_DEBUG_KMS("No SAGV support detected\n");<br>
> +             return false;<br>
> +     }<br>
> +<br>
> +     bw_state = intel_bw_get_state(state);<br>
> +<br>
> +     if (IS_ERR_OR_NULL(bw_state)) {<br>
<br>
It can't be NULL. And if you get an error you must propagate it upwards.<br>
<br>
> +             WARN(1, "Could not get bw_state\n");<br>
> +             return false;<br>
> +     }<br>
> +<br>
> +     if (bw_state->sagv_calculated)<br>
> +             goto out;<br>
> +<br>
> +     bw_state->can_sagv = intel_calculate_sagv_result(bw_state);<br>
> +     bw_state->sagv_calculated = true;<br>
> +<br>
> +out:<br>
> +     return bw_state->can_sagv;<br>
> +}<br>
> +<br>
>  /*<br>
>   * Calculate initial DBuf slice offset, based on slice size<br>
>   * and mask(i.e if slice size is 1024 and second slice is enabled<br>
> @@ -4042,6 +4161,7 @@ skl_cursor_allocation(const struct intel_crtc_state *crtc_state,<br>
>                u32 latency = dev_priv->wm.skl_latency[level];<br>
>  <br>
>                skl_compute_plane_wm(crtc_state, level, latency, &wp, &wm, &wm);<br>
> +<br>
<br>
Spurious whitespace.<br>
<br>
>                if (wm.min_ddb_alloc == U16_MAX)<br>
>                        break;<br>
>  <br>
> @@ -4556,9 +4676,83 @@ skl_plane_wm_level(const struct intel_crtc_state *crtc_state,<br>
>        const struct skl_plane_wm *wm =<br>
>                &crtc_state->wm.skl.optimal.planes[plane_id];<br>
>  <br>
> +     if (!level) {<br>
> +             const struct skl_pipe_wm *pipe_wm = &crtc_state->wm.skl.optimal;<br>
<br>
Why is this here when &crtc_state->wm.skl.optimal is already being used<br>
higher up?<br>
<br>
> +<br>
> +             if (pipe_wm->can_sagv)<br>
> +                     return color_plane == 0 ? &wm->sagv_wm0 : &wm->uv_sagv_wm0;<br>
> +     }<br>
> +<br>
>        return color_plane == 0 ? &wm->wm[level] : &wm->uv_wm[level];<br>
>  }<br>
>  <br>
> +static bool<br>
> +tgl_can_enable_sagv_on_pipe(struct intel_crtc_state *crtc_state)<br>
> +{<br>
> +     struct drm_crtc *crtc = crtc_state->uapi.crtc;<br>
<br>
Pls don't use the annoying drm_ types.<br>
<br>
> +     struct drm_i915_private *dev_priv = to_i915(crtc->dev);<br>
> +     struct intel_crtc *intel_crtc = to_intel_crtc(crtc);<br>
> +     struct skl_ddb_entry *alloc = &crtc_state->wm.skl.ddb;<br>
> +     u16 alloc_size;<br>
> +     u64 total_data_rate;<br>
> +     enum plane_id plane_id;<br>
> +     int num_active;<br>
> +     u64 plane_data_rate[I915_MAX_PLANES] = {};<br>
> +     u32 blocks;<br>
> +<br>
> +     /*<br>
> +      * If pipe is not active it can't affect SAGV rejection<br>
> +      * Checking it here is needed to leave only cases when<br>
> +      * alloc_size is 0 for any other reasons, except inactive<br>
> +      * pipe. As inactive pipe is fine, however having no ddb<br>
> +      * space available is already problematic - so need to<br>
> +      * to separate those.<br>
> +      */<br>
<br>
Can't figure out what this comment is trying to say or why it's here.<br>
<br>
> +     if (!crtc_state->hw.active)<br>
> +             return true;<br>
> +<br>
> +     /*<br>
> +      * No need to check gen here, we call this only for gen12<br>
> +      */<br>
> +     total_data_rate =<br>
> +             icl_get_total_relative_data_rate(crtc_state,<br>
> +                                              plane_data_rate);<br>
> +<br>
> +     skl_ddb_get_pipe_allocation_limits(dev_priv, crtc_state,<br>
> +                                        total_data_rate,<br>
> +                                        alloc, &num_active);<br>
> +     alloc_size = skl_ddb_entry_size(alloc);<br>
<br>
Don't we already have this in the crtc state?<br>
<br>
> +     if (alloc_size == 0)<br>
> +             return false;<br>
<br>
I don't think that can happen.<br>
<br>
> +<br>
> +     /*<br>
> +      * Do check if we can fit L0 + sagv_block_time and<br>
> +      * disable SAGV if we can't.<br>
> +      */<br>
> +     blocks = 0;<br>
> +     for_each_plane_id_on_crtc(intel_crtc, plane_id) {<br>
> +             /*<br>
> +              * The only place, where we can't use skl_plane_wm_level<br>
> +              * accessor, because if actually calls intel_can_enable_sagv<br>
> +              * which depends on that function.<br>
> +              */<br>
> +             const struct skl_plane_wm *wm =<br>
> +                     &crtc_state->wm.skl.optimal.planes[plane_id];<br>
> +<br>
> +             blocks += wm->sagv_wm0.min_ddb_alloc;<br>
> +             blocks += wm->uv_sagv_wm0.min_ddb_alloc;<br>
> +<br>
> +             if (blocks > alloc_size) {<br>
> +                     DRM_DEBUG_KMS("Not enough ddb blocks(%d<%d) for SAGV on pipe %c\n",<br>
> +                                   alloc_size, blocks, pipe_name(intel_crtc->pipe));<br>
> +                     return false;<br>
> +             }<br>
> +     }<br>
> +     DRM_DEBUG_KMS("%d total blocks required for SAGV, ddb entry size %d\n",<br>
> +                   blocks, alloc_size);<br>
> +     return true;<br>
> +}<br>
> +<br>
>  static int<br>
>  skl_allocate_pipe_ddb(struct intel_crtc_state *crtc_state)<br>
>  {<br>
> @@ -5140,11 +5334,19 @@ static void skl_compute_plane_wm(const struct intel_crtc_state *crtc_state,<br>
>  static void<br>
>  skl_compute_wm_levels(const struct intel_crtc_state *crtc_state,<br>
>                      const struct skl_wm_params *wm_params,<br>
> -                   struct skl_wm_level *levels)<br>
> +                   struct skl_plane_wm *plane_wm,<br>
> +                   bool yuv)<br>
>  {<br>
>        struct drm_i915_private *dev_priv = to_i915(crtc_state->uapi.crtc->dev);<br>
>        int level, max_level = ilk_wm_max_level(dev_priv);<br>
> +     /*<br>
> +      * Check which kind of plane is it and based on that calculate<br>
> +      * correspondent WM levels.<br>
> +      */<br>
> +     struct skl_wm_level *levels = yuv ? plane_wm->uv_wm : plane_wm->wm;<br>
>        struct skl_wm_level *result_prev = &levels[0];<br>
> +     struct skl_wm_level *sagv_wm = yuv ?<br>
> +                             &plane_wm->uv_sagv_wm0 : &plane_wm->sagv_wm0;<br>
>  <br>
>        for (level = 0; level <= max_level; level++) {<br>
>                struct skl_wm_level *result = &levels[level];<br>
> @@ -5155,6 +5357,27 @@ skl_compute_wm_levels(const struct intel_crtc_state *crtc_state,<br>
>  <br>
>                result_prev = result;<br>
>        }<br>
> +     /*<br>
> +      * For Gen12 if it is an L0 we need to also<br>
> +      * consider sagv_block_time when calculating<br>
> +      * L0 watermark - we will need that when making<br>
> +      * a decision whether enable SAGV or not.<br>
> +      * For older gens we agreed to copy L0 value for<br>
> +      * compatibility.<br>
> +      */<br>
> +     if ((INTEL_GEN(dev_priv) >= 12)) {<br>
> +             u32 latency = dev_priv->wm.skl_latency[0];<br>
> +<br>
> +             latency += dev_priv->sagv_block_time_us;<br>
> +             skl_compute_plane_wm(crtc_state, 0, latency,<br>
> +                                  wm_params, &levels[0],<br>
> +                                  sagv_wm);<br>
> +             DRM_DEBUG_KMS("%d L0 blocks required for SAGV vs %d for non-SAGV\n",<br>
> +                           sagv_wm->min_ddb_alloc, levels[0].min_ddb_alloc);<br>
> +     } else {<br>
> +             /* Since all members are POD */<br>
> +             *sagv_wm = levels[0];<br>
> +     }<br>
<br>
I was thinking more along the lines of<br>
<br>
  skl_compute_wm_levels();<br>
  skl_compute_transition_wm();<br>
+ skl_compute_sagv_wm();<br>
<br>
<br>
>  }<br>
>  <br>
>  static void skl_compute_transition_wm(const struct intel_crtc_state *crtc_state,<br>
> @@ -5237,7 +5460,7 @@ static int skl_build_plane_wm_single(struct intel_crtc_state *crtc_state,<br>
>        if (ret)<br>
>                return ret;<br>
>  <br>
> -     skl_compute_wm_levels(crtc_state, &wm_params, wm->wm);<br>
> +     skl_compute_wm_levels(crtc_state, &wm_params, wm, false);<br>
>        skl_compute_transition_wm(crtc_state, &wm_params, wm);<br>
>  <br>
>        return 0;<br>
> @@ -5259,7 +5482,7 @@ static int skl_build_plane_wm_uv(struct intel_crtc_state *crtc_state,<br>
>        if (ret)<br>
>                return ret;<br>
>  <br>
> -     skl_compute_wm_levels(crtc_state, &wm_params, wm->uv_wm);<br>
> +     skl_compute_wm_levels(crtc_state, &wm_params, wm, true);<br>
>  <br>
>        return 0;<br>
>  }<br>
> @@ -5598,9 +5821,25 @@ skl_print_wm_changes(struct intel_atomic_state *state)<br>
>                for_each_intel_plane_on_crtc(&dev_priv->drm, crtc, plane) {<br>
>                        enum plane_id plane_id = plane->id;<br>
>                        const struct skl_plane_wm *old_wm, *new_wm;<br>
> +                     const struct skl_wm_level *old_wm_level, *new_wm_level;<br>
> +                     u16 old_plane_res_l, new_plane_res_l;<br>
> +                     u8  old_plane_res_b, new_plane_res_b;<br>
> +                     u16 old_min_ddb_alloc, new_min_ddb_alloc;<br>
> +                     int color_plane = 0;<br>
>  <br>
>                        old_wm = &old_pipe_wm->planes[plane_id];<br>
>                        new_wm = &new_pipe_wm->planes[plane_id];<br>
> +                     old_wm_level = skl_plane_wm_level(old_crtc_state, plane_id, 0, color_plane);<br>
> +                     new_wm_level = skl_plane_wm_level(new_crtc_state, plane_id, 0, color_plane);<br>
> +<br>
> +                     old_plane_res_l = old_wm_level->plane_res_l;<br>
> +                     old_plane_res_b = old_wm_level->plane_res_b;<br>
> +<br>
> +                     new_plane_res_l = new_wm_level->plane_res_l;<br>
> +                     new_plane_res_b = new_wm_level->plane_res_b;<br>
> +<br>
> +                     old_min_ddb_alloc = old_wm_level->min_ddb_alloc;<br>
> +                     new_min_ddb_alloc = new_wm_level->min_ddb_alloc;<br>
>  <br>
>                        if (skl_plane_wm_equals(dev_priv, old_wm, new_wm))<br>
>                                continue;<br>
> @@ -5624,7 +5863,7 @@ skl_print_wm_changes(struct intel_atomic_state *state)<br>
>                                    "[PLANE:%d:%s]   lines %c%3d,%c%3d,%c%3d,%c%3d,%c%3d,%c%3d,%c%3d,%c%3d,%c%3d"<br>
>                                      " -> %c%3d,%c%3d,%c%3d,%c%3d,%c%3d,%c%3d,%c%3d,%c%3d,%c%3d\n",<br>
>                                    plane->base.base.id, plane->base.name,<br>
> -                                 enast(old_wm->wm[0].ignore_lines), old_wm->wm[0].plane_res_l,<br>
> +                                 enast(old_wm->wm[0].ignore_lines), old_plane_res_l,<br>
>                                    enast(old_wm->wm[1].ignore_lines), old_wm->wm[1].plane_res_l,<br>
>                                    enast(old_wm->wm[2].ignore_lines), old_wm->wm[2].plane_res_l,<br>
>                                    enast(old_wm->wm[3].ignore_lines), old_wm->wm[3].plane_res_l,<br>
> @@ -5634,7 +5873,7 @@ skl_print_wm_changes(struct intel_atomic_state *state)<br>
>                                    enast(old_wm->wm[7].ignore_lines), old_wm->wm[7].plane_res_l,<br>
>                                    enast(old_wm->trans_wm.ignore_lines), old_wm->trans_wm.plane_res_l,<br>
>  <br>
> -                                 enast(new_wm->wm[0].ignore_lines), new_wm->wm[0].plane_res_l,<br>
> +                                 enast(new_wm->wm[0].ignore_lines), new_plane_res_l,<br>
>                                    enast(new_wm->wm[1].ignore_lines), new_wm->wm[1].plane_res_l,<br>
>                                    enast(new_wm->wm[2].ignore_lines), new_wm->wm[2].plane_res_l,<br>
>                                    enast(new_wm->wm[3].ignore_lines), new_wm->wm[3].plane_res_l,<br>
> @@ -5648,12 +5887,12 @@ skl_print_wm_changes(struct intel_atomic_state *state)<br>
>                                    "[PLANE:%d:%s]  blocks %4d,%4d,%4d,%4d,%4d,%4d,%4d,%4d,%4d"<br>
>                                    " -> %4d,%4d,%4d,%4d,%4d,%4d,%4d,%4d,%4d\n",<br>
>                                    plane->base.base.id, plane->base.name,<br>
> -                                 old_wm->wm[0].plane_res_b, old_wm->wm[1].plane_res_b,<br>
> +                                 old_plane_res_b, old_wm->wm[1].plane_res_b,<br>
>                                    old_wm->wm[2].plane_res_b, old_wm->wm[3].plane_res_b,<br>
>                                    old_wm->wm[4].plane_res_b, old_wm->wm[5].plane_res_b,<br>
>                                    old_wm->wm[6].plane_res_b, old_wm->wm[7].plane_res_b,<br>
>                                    old_wm->trans_wm.plane_res_b,<br>
> -                                 new_wm->wm[0].plane_res_b, new_wm->wm[1].plane_res_b,<br>
> +                                 new_plane_res_b, new_wm->wm[1].plane_res_b,<br>
>                                    new_wm->wm[2].plane_res_b, new_wm->wm[3].plane_res_b,<br>
>                                    new_wm->wm[4].plane_res_b, new_wm->wm[5].plane_res_b,<br>
>                                    new_wm->wm[6].plane_res_b, new_wm->wm[7].plane_res_b,<br>
> @@ -5663,12 +5902,12 @@ skl_print_wm_changes(struct intel_atomic_state *state)<br>
>                                    "[PLANE:%d:%s] min_ddb %4d,%4d,%4d,%4d,%4d,%4d,%4d,%4d,%4d"<br>
>                                    " -> %4d,%4d,%4d,%4d,%4d,%4d,%4d,%4d,%4d\n",<br>
>                                    plane->base.base.id, plane->base.name,<br>
> -                                 old_wm->wm[0].min_ddb_alloc, old_wm->wm[1].min_ddb_alloc,<br>
> +                                 old_min_ddb_alloc, old_wm->wm[1].min_ddb_alloc,<br>
>                                    old_wm->wm[2].min_ddb_alloc, old_wm->wm[3].min_ddb_alloc,<br>
>                                    old_wm->wm[4].min_ddb_alloc, old_wm->wm[5].min_ddb_alloc,<br>
>                                    old_wm->wm[6].min_ddb_alloc, old_wm->wm[7].min_ddb_alloc,<br>
>                                    old_wm->trans_wm.min_ddb_alloc,<br>
> -                                 new_wm->wm[0].min_ddb_alloc, new_wm->wm[1].min_ddb_alloc,<br>
> +                                 new_min_ddb_alloc, new_wm->wm[1].min_ddb_alloc,<br>
>                                    new_wm->wm[2].min_ddb_alloc, new_wm->wm[3].min_ddb_alloc,<br>
>                                    new_wm->wm[4].min_ddb_alloc, new_wm->wm[5].min_ddb_alloc,<br>
>                                    new_wm->wm[6].min_ddb_alloc, new_wm->wm[7].min_ddb_alloc,<br>
<br>
Here too I think the sagv wm should be treated more or less like the<br>
transition wm (ie. just printed as an extra).<br>
<br>
> @@ -5829,6 +6068,10 @@ skl_compute_wm(struct intel_atomic_state *state)<br>
>                        return ret;<br>
>        }<br>
>  <br>
> +     ret = intel_compute_sagv_mask(state);<br>
> +     if (ret)<br>
> +             return ret;<br>
<br>
This seems too early. We haven't even computed the ddb yet.<br>
<br>
> +<br>
>        ret = skl_compute_ddb(state);<br>
>        if (ret)<br>
>                return ret;<br>
> @@ -5960,6 +6203,9 @@ void skl_pipe_wm_get_hw_state(struct intel_crtc *crtc,<br>
>                                val = I915_READ(CUR_WM(pipe, level));<br>
>  <br>
>                        skl_wm_level_from_reg_val(val, &wm->wm[level]);<br>
> +                     if (level == 0)<br>
> +                             memcpy(&wm->sagv_wm0, &wm->wm[level],<br>
> +                                    sizeof(struct skl_wm_level));<br>
>                }<br>
>  <br>
>                if (plane_id != PLANE_CURSOR)<br>
> diff --git a/drivers/gpu/drm/i915/intel_pm.h b/drivers/gpu/drm/i915/intel_pm.h<br>
> index d60a85421c5a..65743a4cbcf6 100644<br>
> --- a/drivers/gpu/drm/i915/intel_pm.h<br>
> +++ b/drivers/gpu/drm/i915/intel_pm.h<br>
> @@ -42,6 +42,7 @@ void skl_pipe_wm_get_hw_state(struct intel_crtc *crtc,<br>
>  void g4x_wm_sanitize(struct drm_i915_private *dev_priv);<br>
>  void vlv_wm_sanitize(struct drm_i915_private *dev_priv);<br>
>  bool intel_can_enable_sagv(struct intel_atomic_state *state);<br>
> +bool intel_has_sagv(struct drm_i915_private *dev_priv);<br>
>  int intel_enable_sagv(struct drm_i915_private *dev_priv);<br>
>  int intel_disable_sagv(struct drm_i915_private *dev_priv);<br>
>  bool skl_wm_level_equals(const struct skl_wm_level *l1,<br>
> -- <br>
> 2.24.1.485.gad05a3d8e5<br>
<br>
-- <br>
Ville Syrjälä<br>
Intel<br>
</div>
</span></font>
</body>
</html>