<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jun 7, 2021 at 2:37 PM Harry Wentland <<a href="mailto:harry.wentland@amd.com">harry.wentland@amd.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 2021-06-07 2:19 p.m., Sean Paul wrote:<br>
> On Tue, May 18, 2021 at 2:58 PM Rodrigo Siqueira<br>
> <<a href="mailto:Rodrigo.Siqueira@amd.com" target="_blank">Rodrigo.Siqueira@amd.com</a>> wrote:<br>
>><br>
>> On 05/14, Mark Yacoub wrote:<br>
>>> On Fri, May 14, 2021 at 12:31 PM Mark Yacoub <<a href="mailto:markyacoub@google.com" target="_blank">markyacoub@google.com</a>> wrote:<br>
>>>><br>
>>>> On Fri, May 14, 2021 at 11:28 AM Harry Wentland <<a href="mailto:harry.wentland@amd.com" target="_blank">harry.wentland@amd.com</a>> wrote:<br>
>>>>><br>
>>>>> On 2021-05-14 7:47 a.m., Rodrigo Siqueira wrote:<br>
>>>>>> A few weeks ago, we saw a two cursor issue in a ChromeOS system. We<br>
>>>>>> fixed it in the commit:<br>
>>>>>><br>
>>>>>>  drm/amd/display: Fix two cursor duplication when using overlay<br>
>>>>>>  (read the commit message for more details)<br>
>>>>>><br>
>>>>>> After this change, we noticed that some IGT subtests related to<br>
>>>>>> kms_plane and kms_plane_scaling started to fail. After investigating<br>
>>>>>> this issue, we noticed that all subtests that fail have a primary plane<br>
>>>>>> covering the overlay plane, which is currently rejected by amdgpu dm.<br>
>>>>>> Fail those IGT tests highlight that our verification was too broad and<br>
>>>>>> compromises the overlay usage in our drive. This patch fixes this issue<br>
>>> nit: s/drive/driver?<br>
>>>>>> by ensuring that we only reject commits where the primary plane is not<br>
>>>>>> fully covered by the overlay when the cursor hardware is enabled. With<br>
>>>>>> this fix, all IGT tests start to pass again, which means our overlay<br>
>>>>>> support works as expected.<br>
>>>>>><br>
>>>>>> Cc: Tianci.Yin <<a href="mailto:tianci.yin@amd.com" target="_blank">tianci.yin@amd.com</a>><br>
>>>>>> Cc: Harry Wentland <<a href="mailto:harry.wentland@amd.com" target="_blank">harry.wentland@amd.com</a>><br>
>>>>>> Cc: Nicholas Choi <<a href="mailto:nicholas.choi@amd.com" target="_blank">nicholas.choi@amd.com</a>><br>
>>>>>> Cc: Bhawanpreet Lakha <<a href="mailto:bhawanpreet.lakha@amd.com" target="_blank">bhawanpreet.lakha@amd.com</a>><br>
>>>>>> Cc: Nicholas Kazlauskas <<a href="mailto:Nicholas.Kazlauskas@amd.com" target="_blank">Nicholas.Kazlauskas@amd.com</a>><br>
>>>>>> Cc: Mark Yacoub <<a href="mailto:markyacoub@google.com" target="_blank">markyacoub@google.com</a>><br>
>>>>>> Cc: Daniel Wheeler <<a href="mailto:daniel.wheeler@amd.com" target="_blank">daniel.wheeler@amd.com</a>><br>
>>>>>><br>
>>>>>> Signed-off-by: Rodrigo Siqueira <<a href="mailto:Rodrigo.Siqueira@amd.com" target="_blank">Rodrigo.Siqueira@amd.com</a>><br>
>>>>>> ---<br>
>>>>>>  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 10 +++++++++-<br>
>>>>>>  1 file changed, 9 insertions(+), 1 deletion(-)<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 ccd67003b120..9c2537a17a7b 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>
>>>>>> @@ -10067,7 +10067,7 @@ static int validate_overlay(struct drm_atomic_state *state)<br>
>>>>>>       int i;<br>
>>>>>>       struct drm_plane *plane;<br>
>>>>>>       struct drm_plane_state *old_plane_state, *new_plane_state;<br>
>>>>>> -     struct drm_plane_state *primary_state, *overlay_state = NULL;<br>
>>>>>> +     struct drm_plane_state *primary_state, *cursor_state, *overlay_state = NULL;<br>
>>>>>><br>
>>>>>>       /* Check if primary plane is contained inside overlay */<br>
>>>>>>       for_each_oldnew_plane_in_state_reverse(state, plane, old_plane_state, new_plane_state, i) {<br>
>>>>>> @@ -10097,6 +10097,14 @@ static int validate_overlay(struct drm_atomic_state *state)<br>
>>>>>>       if (!primary_state->crtc)<br>
>>>>>>               return 0;<br>
>>>>>><br>
>>>>>> +     /* check if cursor plane is enabled */<br>
>>>>>> +     cursor_state = drm_atomic_get_plane_state(state, overlay_state->crtc->cursor);<br>
>>>>>> +     if (IS_ERR(cursor_state))<br>
>>>>>> +             return PTR_ERR(cursor_state);<br>
>>>>>> +<br>
>>>>>> +     if (drm_atomic_plane_disabling(plane->state, cursor_state))<br>
>>>>>> +             return 0;<br>
>>>>>> +<br>
>>>>><br>
>>>>> I thought this breaks Chrome's compositor since it can't handle an atomic commit rejection<br>
>>>>> based solely on whether a cursor is enabled or not.<br>
>>> For context: To use overlays (the old/current async way), Chrome tests<br>
>>> if an overlay strategy will work by doing an atomic commit with a TEST<br>
>>> flag to check if the combination would work. If it works, it flags<br>
>>> this planes configuration as valid. As it's valid, it performs an<br>
>>> atomic page flip (which could also include the cursor).<br>
>>> So to Harry's point, you would pass an atomic test but fail on an<br>
>>> atomic page flip with the exact same configuration that's been flagged<br>
>>> as valid. Failing a pageflip causes Chrome to crash (Reset the GPU<br>
>>> process cause something went horribly wrong when it shouldn't).<br>
>><br>
>> Hi Mark and Sean,<br>
>><br>
>> I don't know if I fully comprehended the scenario which in my patch<br>
>> might cause a ChromeOS crash, but this is what I understood:<br>
>><br>
> <br>
> Chrome compositor only does an atomic test when the layout geometry<br>
> changes (ie: plane is added/removed/resized/moved). This does not take<br>
> into consideration the cursor. Once the atomic test has been validated<br>
> for a given layout geometry (set of planes/fbs along with their sizes<br>
> and locations), Chrome assumes this will continue to be valid.<br>
> <br>
> So the situation I'm envisioning is if the cursor is hidden, an<br>
> overlay-based strategy will pass in the kernel. If at any time the<br>
> cursor becomes visible, the kernel will start failing commits which<br>
> causes Chrome's GPU process to crash.<br>
> <br>
> In general I'm uneasy with using the cursor in the atomic check since<br>
> it feels like it could be racy independent of the issue above. I<br>
> haven't dove into the helper code enough to prove it, just a<br>
> spidey-sense.<br>
> <br>
<br>
Isn't the cursor supposed to be just another plane? If so, shouldn't<br>
adding/removing the cursor trigger an atomic test?<br>
<br></blockquote><div><br></div><div>Chrome is using legacy cursor.</div><div><br></div><div>Yes it will trigger an atomic test in the kernel, and that atomic test will fail. Unfortunately Chrome does not expect a failure so it will crash.</div><div><br></div><div>Sean</div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Is Chrome's compositor doing cursor update through legacy IOCTLs or<br>
through the ATOMIC IOCTL?<br>
<br>
Thanks,<br>
Harry<br>
<br>
> Sean<br>
> <br>
>> There is a chance that we pass the atomic check<br>
>> (DRM_MODE_ATOMIC_TEST_ONLY - TEST) but fails in the atomic page flip<br>
>> because, after use TEST, the compositor might slightly change the commit<br>
>> config by adding the cursor. The reason behind that came from the<br>
>> assumption that adds the cursor in the atomic commit config after the<br>
>> test is harmless. Is my understand correct? Please, correct me if I'm<br>
>> wrong.<br>
>><br>
>> If the above reasoning is correct, I think the compositor should not<br>
>> assume anything extra from what it got from the atomic check.<br>
>><br>
>> Best Regards,<br>
>> Siqueira<br>
>><br>
>>>>><br>
>>>>> Harry<br>
>>>>><br>
>>>>>>       /* Perform the bounds check to ensure the overlay plane covers the primary */<br>
>>>>>>       if (primary_state->crtc_x < overlay_state->crtc_x ||<br>
>>>>>>           primary_state->crtc_y < overlay_state->crtc_y ||<br>
>>>>>><br>
>>>>><br>
>><br>
>> --<br>
>> Rodrigo Siqueira<br>
>> <a href="https://siqueira.tech/" rel="noreferrer" target="_blank" class="cremed">https://siqueira.tech/</a>><br>
</blockquote></div></div>