<div dir="auto">There are a few cases when the flags can change, for example DCC can be disabled due to a hw limitation in the 3d engine. Modifiers give the misleading impression that they help with that, but they don't. They don't really help with anything.<div dir="auto"><br></div><div dir="auto">Marek</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon., Aug. 10, 2020, 08:30 Christian König, <<a href="mailto:ckoenig.leichtzumerken@gmail.com">ckoenig.leichtzumerken@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Am 10.08.20 um 14:25 schrieb Daniel Vetter:<br>
> On Fri, Aug 07, 2020 at 10:29:09AM -0400, Kazlauskas, Nicholas wrote:<br>
>> On 2020-08-07 4:30 a.m., <a href="mailto:daniel@ffwll.ch" target="_blank" rel="noreferrer">daniel@ffwll.ch</a> wrote:<br>
>>> On Thu, Jul 30, 2020 at 04:36:38PM -0400, Nicholas Kazlauskas wrote:<br>
>>>> [Why]<br>
>>>> We're racing with userspace as the flags could potentially change<br>
>>>> from when we acquired and validated them in commit_check.<br>
>>> Uh ... I didn't know these could change. I think my comments on Bas'<br>
>>> series are even more relevant now. I think long term would be best to bake<br>
>>> these flags in at addfb time when modifiers aren't set. And otherwise<br>
>>> always use the modifiers flag, and completely ignore the legacy flags<br>
>>> here.<br>
>>> -Daniel<br>
>>><br>
>> There's a set tiling/mod flags IOCTL that can be called after addfb happens,<br>
>> so unless there's some sort of driver magic preventing this from working<br>
>> when it's already been pinned for scanout then I don't see anything stopping<br>
>> this from happening.<br>
>><br>
>> I still need to review the modifiers series in a little more detail but that<br>
>> looks like a good approach to fixing these kind of issues.<br>
> Yeah we had the same model for i915, but it's awkward and can surprise<br>
> compositors (since the client could change the tiling mode from underneath<br>
> the compositor). So freezing the tiling mode at addfb time is the right<br>
> thing to do, and anyway how things work with modifiers.<br>
><br>
> Ofc maybe good to audit the -amd driver, but hopefully it doesn't do<br>
> anything silly with changed tiling. If it does, it's kinda sad day.<br>
<br>
Marek should know this right away, but I think we only set the tilling <br>
flags once while exporting the BO and then never change them.<br>
<br>
Regards,<br>
Christian.<br>
<br>
><br>
> Btw for i915 we even went a step further, and made the set_tiling ioctl<br>
> return an error if a framebuffer for that gem_bo existed. Just to make<br>
> sure we don't ever accidentally break this.<br>
><br>
> Cheers, Daniel<br>
><br>
>> Regards,<br>
>> Nicholas Kazlauskas<br>
>><br>
>>>> [How]<br>
>>>> We unfortunately can't drop this function in its entirety from<br>
>>>> prepare_planes since we don't know the afb->address at commit_check<br>
>>>> time yet.<br>
>>>><br>
>>>> So instead of querying new tiling_flags and tmz_surface use the ones<br>
>>>> from the plane_state directly.<br>
>>>><br>
>>>> While we're at it, also update the force_disable_dcc option based<br>
>>>> on the state from atomic check.<br>
>>>><br>
>>>> Cc: Bhawanpreet Lakha <<a href="mailto:Bhawanpreet.Lakha@amd.com" target="_blank" rel="noreferrer">Bhawanpreet.Lakha@amd.com</a>><br>
>>>> Cc: Rodrigo Siqueira <<a href="mailto:Rodrigo.Siqueira@amd.com" target="_blank" rel="noreferrer">Rodrigo.Siqueira@amd.com</a>><br>
>>>> Signed-off-by: Nicholas Kazlauskas <<a href="mailto:nicholas.kazlauskas@amd.com" target="_blank" rel="noreferrer">nicholas.kazlauskas@amd.com</a>><br>
>>>> ---<br>
>>>>    .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 36 ++++++++++---------<br>
>>>>    1 file changed, 19 insertions(+), 17 deletions(-)<br>
>>>><br>
>>>> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c<br>
>>>> index bf1881bd492c..f78c09c9585e 100644<br>
>>>> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c<br>
>>>> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c<br>
>>>> @@ -5794,14 +5794,8 @@ static int dm_plane_helper_prepare_fb(struct drm_plane *plane,<br>
>>>>            struct list_head list;<br>
>>>>            struct ttm_validate_buffer tv;<br>
>>>>            struct ww_acquire_ctx ticket;<br>
>>>> -  uint64_t tiling_flags;<br>
>>>>            uint32_t domain;<br>
>>>>            int r;<br>
>>>> -  bool tmz_surface = false;<br>
>>>> -  bool force_disable_dcc = false;<br>
>>>> -<br>
>>>> -  dm_plane_state_old = to_dm_plane_state(plane->state);<br>
>>>> -  dm_plane_state_new = to_dm_plane_state(new_state);<br>
>>>>            if (!new_state->fb) {<br>
>>>>                    DRM_DEBUG_DRIVER("No FB bound\n");<br>
>>>> @@ -5845,27 +5839,35 @@ static int dm_plane_helper_prepare_fb(struct drm_plane *plane,<br>
>>>>                    return r;<br>
>>>>            }<br>
>>>> -  amdgpu_bo_get_tiling_flags(rbo, &tiling_flags);<br>
>>>> -<br>
>>>> -  tmz_surface = amdgpu_bo_encrypted(rbo);<br>
>>>> -<br>
>>>>            ttm_eu_backoff_reservation(&ticket, &list);<br>
>>>>            afb->address = amdgpu_bo_gpu_offset(rbo);<br>
>>>>            amdgpu_bo_ref(rbo);<br>
>>>> +  /**<br>
>>>> +   * We don't do surface updates on planes that have been newly created,<br>
>>>> +   * but we also don't have the afb->address during atomic check.<br>
>>>> +   *<br>
>>>> +   * Fill in buffer attributes depending on the address here, but only on<br>
>>>> +   * newly created planes since they're not being used by DC yet and this<br>
>>>> +   * won't modify global state.<br>
>>>> +   */<br>
>>>> +  dm_plane_state_old = to_dm_plane_state(plane->state);<br>
>>>> +  dm_plane_state_new = to_dm_plane_state(new_state);<br>
>>>> +<br>
>>>>            if (dm_plane_state_new->dc_state &&<br>
>>>> -                  dm_plane_state_old->dc_state != dm_plane_state_new->dc_state) {<br>
>>>> -          struct dc_plane_state *plane_state = dm_plane_state_new->dc_state;<br>
>>>> +      dm_plane_state_old->dc_state != dm_plane_state_new->dc_state) {<br>
>>>> +          struct dc_plane_state *plane_state =<br>
>>>> +                  dm_plane_state_new->dc_state;<br>
>>>> +          bool force_disable_dcc = !plane_state->dcc.enable;<br>
>>>> -          force_disable_dcc = adev->asic_type == CHIP_RAVEN && adev->in_suspend;<br>
>>>>                    fill_plane_buffer_attributes(<br>
>>>>                            adev, afb, plane_state->format, plane_state->rotation,<br>
>>>> -                  tiling_flags, &plane_state->tiling_info,<br>
>>>> -                  &plane_state->plane_size, &plane_state->dcc,<br>
>>>> -                  &plane_state->address, tmz_surface,<br>
>>>> -                  force_disable_dcc);<br>
>>>> +                  dm_plane_state_new->tiling_flags,<br>
>>>> +                  &plane_state->tiling_info, &plane_state->plane_size,<br>
>>>> +                  &plane_state->dcc, &plane_state->address,<br>
>>>> +                  dm_plane_state_new->tmz_surface, force_disable_dcc);<br>
>>>>            }<br>
>>>>            return 0;<br>
>>>> -- <br>
>>>> 2.25.1<br>
>>>><br>
>>>> _______________________________________________<br>
>>>> dri-devel mailing list<br>
>>>> <a href="mailto:dri-devel@lists.freedesktop.org" target="_blank" rel="noreferrer">dri-devel@lists.freedesktop.org</a><br>
>>>> <a href="https://lists.freedesktop.org/mailman/listinfo/dri-devel" rel="noreferrer noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/dri-devel</a><br>
<br>
_______________________________________________<br>
amd-gfx mailing list<br>
<a href="mailto:amd-gfx@lists.freedesktop.org" target="_blank" rel="noreferrer">amd-gfx@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx" rel="noreferrer noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a><br>
</blockquote></div>