dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/core: Fail atomic IOCTL with no CRTC state but with signaling.
@ 2017-06-09 21:30 Andrey Grodzovsky
       [not found] ` <1497043819-28591-1-git-send-email-Andrey.Grodzovsky-5C7GfCeVMHo@public.gmane.org>
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Andrey Grodzovsky @ 2017-06-09 21:30 UTC (permalink / raw)
  To: dri-devel, linux-kernel, intel-gfx, maarten.lankhorst
  Cc: amd-gfx, harry.wentland, Andrey Grodzovsky

Problem:
While running IGT kms_atomic_transition test suite i encountered
a hang in drmHandleEvent immidietly follwoing an atomic_commit.
After dumping the atomic state I relized that in this case there was
not even one CRTC attached to the state and only disabled
planes. This probably due to a commit which hadn't changed any property
which would require attaching crtc state. This means drmHandleEvent
will never wake up from read since without CRTC in atomic state
the event fd will not be singnaled.
This point to a bug in IGT but also DRM should gracefully
fail  such scenario so no hang on user side will happen.

Fix:
Explicitly fail by failing atomic_commit early in
drm_mode_atomic_commit where such problem can be identified.

Signed-off-by: Andrey Grodzovsky <Andrey.Grodzovsky@amd.com>
---
 drivers/gpu/drm/drm_atomic.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index a567310..32eae1c 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -1933,7 +1933,7 @@ static int prepare_crtc_signaling(struct drm_device *dev,
 {
 	struct drm_crtc *crtc;
 	struct drm_crtc_state *crtc_state;
-	int i, ret;
+	int i, c = 0, ret;
 
 	if (arg->flags & DRM_MODE_ATOMIC_TEST_ONLY)
 		return 0;
@@ -1994,8 +1994,17 @@ static int prepare_crtc_signaling(struct drm_device *dev,
 
 			crtc_state->event->base.fence = fence;
 		}
+
+		c++;
 	}
 
+	/*
+	 * Having this flag means user mode pends on event which will never
+	 * reach due to lack of at least one CRTC for signaling
+	 */
+	if (c == 0 && (arg->flags & DRM_MODE_PAGE_FLIP_EVENT))
+		return -EINVAL;
+
 	return 0;
 }
 
@@ -2179,6 +2188,8 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
 		drm_mode_object_unreference(obj);
 	}
 
+
+
 	ret = prepare_crtc_signaling(dev, state, arg, file_priv, &fence_state,
 				     &num_fences);
 	if (ret)
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH] drm/core: Fail atomic IOCTL with no CRTC state but with signaling.
       [not found] ` <1497043819-28591-1-git-send-email-Andrey.Grodzovsky-5C7GfCeVMHo@public.gmane.org>
@ 2017-06-12 11:08   ` Maarten Lankhorst
  2017-06-12 14:12     ` Andrey Grodzovsky
  0 siblings, 1 reply; 14+ messages in thread
From: Maarten Lankhorst @ 2017-06-12 11:08 UTC (permalink / raw)
  To: Andrey Grodzovsky, dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	intel-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
  Cc: harry.wentland-5C7GfCeVMHo,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

Op 09-06-17 om 23:30 schreef Andrey Grodzovsky:
> Problem:
> While running IGT kms_atomic_transition test suite i encountered
> a hang in drmHandleEvent immidietly follwoing an atomic_commit.
> After dumping the atomic state I relized that in this case there was
> not even one CRTC attached to the state and only disabled
> planes. This probably due to a commit which hadn't changed any property
> which would require attaching crtc state. This means drmHandleEvent
> will never wake up from read since without CRTC in atomic state
> the event fd will not be singnaled.
> This point to a bug in IGT but also DRM should gracefully
> fail  such scenario so no hang on user side will happen.
>
> Fix:
> Explicitly fail by failing atomic_commit early in
> drm_mode_atomic_commit where such problem can be identified.
>
> Signed-off-by: Andrey Grodzovsky <Andrey.Grodzovsky@amd.com>
> ---
>  drivers/gpu/drm/drm_atomic.c | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
Patch itself looks sane, but I'm worried about failing with -EINVAL when the same configuration with TEST_ONLY would otherwise succeed on it.
Not sure whether we should fail or not, since sending 0 events could still be considered success.

I don't mind either way, but definitely something that should be discussed before applying.
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] drm/core: Fail atomic IOCTL with no CRTC state but with signaling.
  2017-06-12 11:08   ` Maarten Lankhorst
@ 2017-06-12 14:12     ` Andrey Grodzovsky
  0 siblings, 0 replies; 14+ messages in thread
From: Andrey Grodzovsky @ 2017-06-12 14:12 UTC (permalink / raw)
  To: Maarten Lankhorst, dri-devel, linux-kernel, intel-gfx
  Cc: harry.wentland, amd-gfx



On 06/12/2017 07:08 AM, Maarten Lankhorst wrote:
> Op 09-06-17 om 23:30 schreef Andrey Grodzovsky:
>> Problem:
>> While running IGT kms_atomic_transition test suite i encountered
>> a hang in drmHandleEvent immidietly follwoing an atomic_commit.
>> After dumping the atomic state I relized that in this case there was
>> not even one CRTC attached to the state and only disabled
>> planes. This probably due to a commit which hadn't changed any property
>> which would require attaching crtc state. This means drmHandleEvent
>> will never wake up from read since without CRTC in atomic state
>> the event fd will not be singnaled.
>> This point to a bug in IGT but also DRM should gracefully
>> fail  such scenario so no hang on user side will happen.
>>
>> Fix:
>> Explicitly fail by failing atomic_commit early in
>> drm_mode_atomic_commit where such problem can be identified.
>>
>> Signed-off-by: Andrey Grodzovsky <Andrey.Grodzovsky@amd.com>
>> ---
>>   drivers/gpu/drm/drm_atomic.c | 13 ++++++++++++-
>>   1 file changed, 12 insertions(+), 1 deletion(-)
> Patch itself looks sane, but I'm worried about failing with -EINVAL when the same configuration with TEST_ONLY would otherwise succeed on it.
DRM_MODE_ATOMIC_TEST_ONLY flag is checked later, after this, so if this 
fails , test only will return EINVAL also.
> Not sure whether we should fail or not, since sending 0 events could still be considered success.
>
> I don't mind either way, but definitely something that should be discussed before applying.
Sending 0 events is no problem at all on it's own but if user provides 
DRM_MODE_PAGE_FLIP_EVENT in args
then when it becomes a problem , doesn't it mean he expects to receive 
at least one event ?

Thanks.

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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] drm/core: Fail atomic IOCTL with no CRTC state but with signaling.
  2017-06-09 21:30 [PATCH] drm/core: Fail atomic IOCTL with no CRTC state but with signaling Andrey Grodzovsky
       [not found] ` <1497043819-28591-1-git-send-email-Andrey.Grodzovsky-5C7GfCeVMHo@public.gmane.org>
@ 2017-06-15 20:46 ` Andrey Grodzovsky
  2017-06-19 15:35 ` Harry Wentland
  2 siblings, 0 replies; 14+ messages in thread
From: Andrey Grodzovsky @ 2017-06-15 20:46 UTC (permalink / raw)
  To: dri-devel, linux-kernel, intel-gfx, maarten.lankhorst
  Cc: amd-gfx, harry.wentland

Just a reminder.

Thanks.

On 06/09/2017 05:30 PM, Andrey Grodzovsky wrote:
> Problem:
> While running IGT kms_atomic_transition test suite i encountered
> a hang in drmHandleEvent immidietly follwoing an atomic_commit.
> After dumping the atomic state I relized that in this case there was
> not even one CRTC attached to the state and only disabled
> planes. This probably due to a commit which hadn't changed any property
> which would require attaching crtc state. This means drmHandleEvent
> will never wake up from read since without CRTC in atomic state
> the event fd will not be singnaled.
> This point to a bug in IGT but also DRM should gracefully
> fail  such scenario so no hang on user side will happen.
>
> Fix:
> Explicitly fail by failing atomic_commit early in
> drm_mode_atomic_commit where such problem can be identified.
>
> Signed-off-by: Andrey Grodzovsky <Andrey.Grodzovsky@amd.com>
> ---
>   drivers/gpu/drm/drm_atomic.c | 13 ++++++++++++-
>   1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> index a567310..32eae1c 100644
> --- a/drivers/gpu/drm/drm_atomic.c
> +++ b/drivers/gpu/drm/drm_atomic.c
> @@ -1933,7 +1933,7 @@ static int prepare_crtc_signaling(struct drm_device *dev,
>   {
>   	struct drm_crtc *crtc;
>   	struct drm_crtc_state *crtc_state;
> -	int i, ret;
> +	int i, c = 0, ret;
>   
>   	if (arg->flags & DRM_MODE_ATOMIC_TEST_ONLY)
>   		return 0;
> @@ -1994,8 +1994,17 @@ static int prepare_crtc_signaling(struct drm_device *dev,
>   
>   			crtc_state->event->base.fence = fence;
>   		}
> +
> +		c++;
>   	}
>   
> +	/*
> +	 * Having this flag means user mode pends on event which will never
> +	 * reach due to lack of at least one CRTC for signaling
> +	 */
> +	if (c == 0 && (arg->flags & DRM_MODE_PAGE_FLIP_EVENT))
> +		return -EINVAL;
> +
>   	return 0;
>   }
>   
> @@ -2179,6 +2188,8 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
>   		drm_mode_object_unreference(obj);
>   	}
>   
> +
> +
>   	ret = prepare_crtc_signaling(dev, state, arg, file_priv, &fence_state,
>   				     &num_fences);
>   	if (ret)

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] drm/core: Fail atomic IOCTL with no CRTC state but with signaling.
  2017-06-09 21:30 [PATCH] drm/core: Fail atomic IOCTL with no CRTC state but with signaling Andrey Grodzovsky
       [not found] ` <1497043819-28591-1-git-send-email-Andrey.Grodzovsky-5C7GfCeVMHo@public.gmane.org>
  2017-06-15 20:46 ` Andrey Grodzovsky
@ 2017-06-19 15:35 ` Harry Wentland
       [not found]   ` <0d603149-3fb0-3d48-89e5-77e3f7686415-5C7GfCeVMHo@public.gmane.org>
  2017-06-20 17:57   ` [PATCH v2] " Andrey Grodzovsky
  2 siblings, 2 replies; 14+ messages in thread
From: Harry Wentland @ 2017-06-19 15:35 UTC (permalink / raw)
  To: Andrey Grodzovsky, dri-devel, linux-kernel, intel-gfx,
	maarten.lankhorst
  Cc: amd-gfx

On 2017-06-09 05:30 PM, Andrey Grodzovsky wrote:
> Problem:
> While running IGT kms_atomic_transition test suite i encountered
> a hang in drmHandleEvent immidietly follwoing an atomic_commit.

s/immidietly/immediately/g
s/follwoing/following/g

> After dumping the atomic state I relized that in this case there was
> not even one CRTC attached to the state and only disabled
> planes. This probably due to a commit which hadn't changed any property
> which would require attaching crtc state. This means drmHandleEvent
> will never wake up from read since without CRTC in atomic state
> the event fd will not be singnaled.

s/singnaled/signaled/g

> This point to a bug in IGT but also DRM should gracefully
> fail  such scenario so no hang on user side will happen.
> 

Can we create an IGT fix for this to make sure this won't happen?

> Fix:
> Explicitly fail by failing atomic_commit early in
> drm_mode_atomic_commit where such problem can be identified.
> 

The change seems reasonable to me but I would like to see some input
from someone who's more familiar with the usermode side of things.

> Signed-off-by: Andrey Grodzovsky <Andrey.Grodzovsky@amd.com>
> ---
>  drivers/gpu/drm/drm_atomic.c | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> index a567310..32eae1c 100644
> --- a/drivers/gpu/drm/drm_atomic.c
> +++ b/drivers/gpu/drm/drm_atomic.c
> @@ -1933,7 +1933,7 @@ static int prepare_crtc_signaling(struct drm_device *dev,
>  {
>  	struct drm_crtc *crtc;
>  	struct drm_crtc_state *crtc_state;
> -	int i, ret;
> +	int i, c = 0, ret;
>  
>  	if (arg->flags & DRM_MODE_ATOMIC_TEST_ONLY)
>  		return 0;
> @@ -1994,8 +1994,17 @@ static int prepare_crtc_signaling(struct drm_device *dev,
>  
>  			crtc_state->event->base.fence = fence;
>  		}
> +
> +		c++;

Not sure if intentional, but I like it.

>  	}
>  
> +	/*
> +	 * Having this flag means user mode pends on event which will never
> +	 * reach due to lack of at least one CRTC for signaling
> +	 */
> +	if (c == 0 && (arg->flags & DRM_MODE_PAGE_FLIP_EVENT))
> +		return -EINVAL;
> +
>  	return 0;
>  }
>  
> @@ -2179,6 +2188,8 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
>  		drm_mode_object_unreference(obj);
>  	}
>  
> +
> +

Remove these extraneous newlines.

Harry

>  	ret = prepare_crtc_signaling(dev, state, arg, file_priv, &fence_state,
>  				     &num_fences);
>  	if (ret)
> 
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] drm/core: Fail atomic IOCTL with no CRTC state but with signaling.
       [not found]   ` <0d603149-3fb0-3d48-89e5-77e3f7686415-5C7GfCeVMHo@public.gmane.org>
@ 2017-06-19 19:24     ` Sean Paul
  2017-06-19 20:11       ` Andrey Grodzovsky
  0 siblings, 1 reply; 14+ messages in thread
From: Sean Paul @ 2017-06-19 19:24 UTC (permalink / raw)
  To: Harry Wentland
  Cc: Andrey Grodzovsky, intel-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	maarten.lankhorst-VuQAYsv1563Yd54FQh9/CA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

On Mon, Jun 19, 2017 at 11:35:28AM -0400, Harry Wentland wrote:
> On 2017-06-09 05:30 PM, Andrey Grodzovsky wrote:
> > Problem:
> > While running IGT kms_atomic_transition test suite i encountered
> > a hang in drmHandleEvent immidietly follwoing an atomic_commit.
> 
> s/immidietly/immediately/g
> s/follwoing/following/g
> 
> > After dumping the atomic state I relized that in this case there was
> > not even one CRTC attached to the state and only disabled
> > planes. This probably due to a commit which hadn't changed any property
> > which would require attaching crtc state. This means drmHandleEvent
> > will never wake up from read since without CRTC in atomic state
> > the event fd will not be singnaled.
> 
> s/singnaled/signaled/g
> 
> > This point to a bug in IGT but also DRM should gracefully
> > fail  such scenario so no hang on user side will happen.
> > 
> 
> Can we create an IGT fix for this to make sure this won't happen?
> 
> > Fix:
> > Explicitly fail by failing atomic_commit early in
> > drm_mode_atomic_commit where such problem can be identified.
> > 
> 
> The change seems reasonable to me but I would like to see some input
> from someone who's more familiar with the usermode side of things.

I wonder if there's ever a case where it might be desirable to generate an event
from a commit without a crtc. I don't know if anyone has explicitly said that an
event can only be generated from state with crtc.

I usually don't mind letting userspace shoot itself in the foot, so keep that in
mind :)

Sean


> 
> > Signed-off-by: Andrey Grodzovsky <Andrey.Grodzovsky@amd.com>
> > ---
> >  drivers/gpu/drm/drm_atomic.c | 13 ++++++++++++-
> >  1 file changed, 12 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> > index a567310..32eae1c 100644
> > --- a/drivers/gpu/drm/drm_atomic.c
> > +++ b/drivers/gpu/drm/drm_atomic.c
> > @@ -1933,7 +1933,7 @@ static int prepare_crtc_signaling(struct drm_device *dev,
> >  {
> >  	struct drm_crtc *crtc;
> >  	struct drm_crtc_state *crtc_state;
> > -	int i, ret;
> > +	int i, c = 0, ret;
> >  
> >  	if (arg->flags & DRM_MODE_ATOMIC_TEST_ONLY)
> >  		return 0;
> > @@ -1994,8 +1994,17 @@ static int prepare_crtc_signaling(struct drm_device *dev,
> >  
> >  			crtc_state->event->base.fence = fence;
> >  		}
> > +
> > +		c++;
> 
> Not sure if intentional, but I like it.
> 
> >  	}
> >  
> > +	/*
> > +	 * Having this flag means user mode pends on event which will never
> > +	 * reach due to lack of at least one CRTC for signaling
> > +	 */
> > +	if (c == 0 && (arg->flags & DRM_MODE_PAGE_FLIP_EVENT))
> > +		return -EINVAL;
> > +
> >  	return 0;
> >  }
> >  
> > @@ -2179,6 +2188,8 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
> >  		drm_mode_object_unreference(obj);
> >  	}
> >  
> > +
> > +
> 
> Remove these extraneous newlines.
> 
> Harry
> 
> >  	ret = prepare_crtc_signaling(dev, state, arg, file_priv, &fence_state,
> >  				     &num_fences);
> >  	if (ret)
> > 

-- 
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] drm/core: Fail atomic IOCTL with no CRTC state but with signaling.
  2017-06-19 19:24     ` Sean Paul
@ 2017-06-19 20:11       ` Andrey Grodzovsky
  2017-06-20  9:29         ` Daniel Vetter
  0 siblings, 1 reply; 14+ messages in thread
From: Andrey Grodzovsky @ 2017-06-19 20:11 UTC (permalink / raw)
  To: Sean Paul, Harry Wentland; +Cc: intel-gfx, amd-gfx, linux-kernel, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 3569 bytes --]



On 06/19/2017 03:24 PM, Sean Paul wrote:
> On Mon, Jun 19, 2017 at 11:35:28AM -0400, Harry Wentland wrote:
>> On 2017-06-09 05:30 PM, Andrey Grodzovsky wrote:
>>> Problem:
>>> While running IGT kms_atomic_transition test suite i encountered
>>> a hang in drmHandleEvent immidietly follwoing an atomic_commit.
>> s/immidietly/immediately/g
>> s/follwoing/following/g
>>
>>> After dumping the atomic state I relized that in this case there was
>>> not even one CRTC attached to the state and only disabled
>>> planes. This probably due to a commit which hadn't changed any property
>>> which would require attaching crtc state. This means drmHandleEvent
>>> will never wake up from read since without CRTC in atomic state
>>> the event fd will not be singnaled.
>> s/singnaled/signaled/g
>>
>>> This point to a bug in IGT but also DRM should gracefully
>>> fail  such scenario so no hang on user side will happen.
>>>
>> Can we create an IGT fix for this to make sure this won't happen?
>>
>>> Fix:
>>> Explicitly fail by failing atomic_commit early in
>>> drm_mode_atomic_commit where such problem can be identified.
>>>
>> The change seems reasonable to me but I would like to see some input
>> from someone who's more familiar with the usermode side of things.
> I wonder if there's ever a case where it might be desirable to generate an event
> from a commit without a crtc. I don't know if anyone has explicitly said that an
> event can only be generated from state with crtc.
For a generic event i agree, bit seems to me without active CRTC no way you
can  expect PAGE_FLIP_EVENT to fire.
>
> I usually don't mind letting userspace shoot itself in the foot, so keep that in
> mind :)
>
> Sean

Seems to me you still would try to avoid a bad configuration, returning 
error
will help debugging for user who made a mistake. I also see something 
similar
in drm_mode_atomic_ioctl around line 2122 -

/* can't test and expect an event at the same time. */
if ((arg->flags & DRM_MODE_ATOMIC_TEST_ONLY) &&
(arg->flags & DRM_MODE_PAGE_FLIP_EVENT))
return -EINVAL;

Thanks,
Andrey
>>> Signed-off-by: Andrey Grodzovsky <Andrey.Grodzovsky@amd.com>
>>> ---
>>>   drivers/gpu/drm/drm_atomic.c | 13 ++++++++++++-
>>>   1 file changed, 12 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
>>> index a567310..32eae1c 100644
>>> --- a/drivers/gpu/drm/drm_atomic.c
>>> +++ b/drivers/gpu/drm/drm_atomic.c
>>> @@ -1933,7 +1933,7 @@ static int prepare_crtc_signaling(struct drm_device *dev,
>>>   {
>>>   	struct drm_crtc *crtc;
>>>   	struct drm_crtc_state *crtc_state;
>>> -	int i, ret;
>>> +	int i, c = 0, ret;
>>>   
>>>   	if (arg->flags & DRM_MODE_ATOMIC_TEST_ONLY)
>>>   		return 0;
>>> @@ -1994,8 +1994,17 @@ static int prepare_crtc_signaling(struct drm_device *dev,
>>>   
>>>   			crtc_state->event->base.fence = fence;
>>>   		}
>>> +
>>> +		c++;
>> Not sure if intentional, but I like it.
>>
>>>   	}
>>>   
>>> +	/*
>>> +	 * Having this flag means user mode pends on event which will never
>>> +	 * reach due to lack of at least one CRTC for signaling
>>> +	 */
>>> +	if (c == 0 && (arg->flags & DRM_MODE_PAGE_FLIP_EVENT))
>>> +		return -EINVAL;
>>> +
>>>   	return 0;
>>>   }
>>>   
>>> @@ -2179,6 +2188,8 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
>>>   		drm_mode_object_unreference(obj);
>>>   	}
>>>   
>>> +
>>> +
>> Remove these extraneous newlines.
>>
>> Harry
>>
>>>   	ret = prepare_crtc_signaling(dev, state, arg, file_priv, &fence_state,
>>>   				     &num_fences);
>>>   	if (ret)
>>>


[-- Attachment #1.2: Type: text/html, Size: 5797 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] drm/core: Fail atomic IOCTL with no CRTC state but with signaling.
  2017-06-19 20:11       ` Andrey Grodzovsky
@ 2017-06-20  9:29         ` Daniel Vetter
  0 siblings, 0 replies; 14+ messages in thread
From: Daniel Vetter @ 2017-06-20  9:29 UTC (permalink / raw)
  To: Andrey Grodzovsky
  Cc: intel-gfx, linux-kernel, dri-devel, amd-gfx, Harry Wentland

On Mon, Jun 19, 2017 at 04:11:35PM -0400, Andrey Grodzovsky wrote:
> 
> 
> On 06/19/2017 03:24 PM, Sean Paul wrote:
> > On Mon, Jun 19, 2017 at 11:35:28AM -0400, Harry Wentland wrote:
> > > On 2017-06-09 05:30 PM, Andrey Grodzovsky wrote:
> > > > Problem:
> > > > While running IGT kms_atomic_transition test suite i encountered
> > > > a hang in drmHandleEvent immidietly follwoing an atomic_commit.
> > > s/immidietly/immediately/g
> > > s/follwoing/following/g
> > > 
> > > > After dumping the atomic state I relized that in this case there was
> > > > not even one CRTC attached to the state and only disabled
> > > > planes. This probably due to a commit which hadn't changed any property
> > > > which would require attaching crtc state. This means drmHandleEvent
> > > > will never wake up from read since without CRTC in atomic state
> > > > the event fd will not be singnaled.
> > > s/singnaled/signaled/g
> > > 
> > > > This point to a bug in IGT but also DRM should gracefully
> > > > fail  such scenario so no hang on user side will happen.
> > > > 
> > > Can we create an IGT fix for this to make sure this won't happen?
> > > 
> > > > Fix:
> > > > Explicitly fail by failing atomic_commit early in
> > > > drm_mode_atomic_commit where such problem can be identified.
> > > > 
> > > The change seems reasonable to me but I would like to see some input
> > > from someone who's more familiar with the usermode side of things.
> > I wonder if there's ever a case where it might be desirable to generate an event
> > from a commit without a crtc. I don't know if anyone has explicitly said that an
> > event can only be generated from state with crtc.
> For a generic event i agree, bit seems to me without active CRTC no way you
> can  expect PAGE_FLIP_EVENT to fire.
> > 
> > I usually don't mind letting userspace shoot itself in the foot, so keep that in
> > mind :)
> > 
> > Sean
> 
> Seems to me you still would try to avoid a bad configuration, returning
> error
> will help debugging for user who made a mistake. I also see something
> similar
> in drm_mode_atomic_ioctl around line 2122 -
> 
> /* can't test and expect an event at the same time. */
> if ((arg->flags & DRM_MODE_ATOMIC_TEST_ONLY) &&
> (arg->flags & DRM_MODE_PAGE_FLIP_EVENT))
> return -EINVAL;

Asking for an event without anything changed is a bug imo. We need to fix
the testcases, and even better would be to have an explicit testcase which
does such a no-op atomic ioctl + event and checks that we get the -EINVAL.

Same applies for asking for events when the crtc is off and stays off btw,
but I think we catch that already somewhere. But again would be good to
make sure we have an igt for it.

Thanks, Daniel

> 
> Thanks,
> Andrey
> > > > Signed-off-by: Andrey Grodzovsky <Andrey.Grodzovsky@amd.com>
> > > > ---
> > > >   drivers/gpu/drm/drm_atomic.c | 13 ++++++++++++-
> > > >   1 file changed, 12 insertions(+), 1 deletion(-)
> > > > 
> > > > diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> > > > index a567310..32eae1c 100644
> > > > --- a/drivers/gpu/drm/drm_atomic.c
> > > > +++ b/drivers/gpu/drm/drm_atomic.c
> > > > @@ -1933,7 +1933,7 @@ static int prepare_crtc_signaling(struct drm_device *dev,
> > > >   {
> > > >   	struct drm_crtc *crtc;
> > > >   	struct drm_crtc_state *crtc_state;
> > > > -	int i, ret;
> > > > +	int i, c = 0, ret;
> > > >   	if (arg->flags & DRM_MODE_ATOMIC_TEST_ONLY)
> > > >   		return 0;
> > > > @@ -1994,8 +1994,17 @@ static int prepare_crtc_signaling(struct drm_device *dev,
> > > >   			crtc_state->event->base.fence = fence;
> > > >   		}
> > > > +
> > > > +		c++;
> > > Not sure if intentional, but I like it.
> > > 
> > > >   	}
> > > > +	/*
> > > > +	 * Having this flag means user mode pends on event which will never
> > > > +	 * reach due to lack of at least one CRTC for signaling
> > > > +	 */
> > > > +	if (c == 0 && (arg->flags & DRM_MODE_PAGE_FLIP_EVENT))
> > > > +		return -EINVAL;
> > > > +
> > > >   	return 0;
> > > >   }
> > > > @@ -2179,6 +2188,8 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
> > > >   		drm_mode_object_unreference(obj);
> > > >   	}
> > > > +
> > > > +
> > > Remove these extraneous newlines.
> > > 
> > > Harry
> > > 
> > > >   	ret = prepare_crtc_signaling(dev, state, arg, file_priv, &fence_state,
> > > >   				     &num_fences);
> > > >   	if (ret)
> > > > 
> 

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


-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v2] drm/core: Fail atomic IOCTL with no CRTC state but with signaling.
  2017-06-19 15:35 ` Harry Wentland
       [not found]   ` <0d603149-3fb0-3d48-89e5-77e3f7686415-5C7GfCeVMHo@public.gmane.org>
@ 2017-06-20 17:57   ` Andrey Grodzovsky
       [not found]     ` <1497981426-27203-1-git-send-email-Andrey.Grodzovsky-5C7GfCeVMHo@public.gmane.org>
  1 sibling, 1 reply; 14+ messages in thread
From: Andrey Grodzovsky @ 2017-06-20 17:57 UTC (permalink / raw)
  To: harry.wentland, dri-devel, linux-kernel, intel-gfx,
	maarten.lankhorst
  Cc: amd-gfx, seanpaul, daniel, Andrey Grodzovsky

Problem : While running IGT kms_atomic_transition test suite i encountered
a hang in drmHandleEvent immediately following  an atomic_commit.
After dumping the atomic state I relized that in this case there was
not even one CRTC attached to the state and only disabled
planes. This probably due to a commit which hadn't changed any property
which would require attaching crtc state. This means drmHandleEvent
will never wake up from read since without CRTC in atomic state
the event fd will not be signaled.

Fix: Protect against this issue by failing atomic_commit early in
drm_mode_atomic_commit where such probelm can be identified.

v2:
Fix typos and extra newlines.

Change-Id: I3ee28ffae35fd1e8bfe553146c44da53da02e6f8
Signed-off-by: Andrey Grodzovsky <Andrey.Grodzovsky@amd.com>
---
 drivers/gpu/drm/drm_atomic.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index a567310..48145bf 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -1933,7 +1933,7 @@ static int prepare_crtc_signaling(struct drm_device *dev,
 {
 	struct drm_crtc *crtc;
 	struct drm_crtc_state *crtc_state;
-	int i, ret;
+	int i, c = 0, ret;
 
 	if (arg->flags & DRM_MODE_ATOMIC_TEST_ONLY)
 		return 0;
@@ -1994,8 +1994,17 @@ static int prepare_crtc_signaling(struct drm_device *dev,
 
 			crtc_state->event->base.fence = fence;
 		}
+
+		c++;
 	}
 
+	/*
+	 * Having this flag means user mode pends on event which will never
+	 * reach due to lack of at least one CRTC for signaling
+	 */
+	if (c == 0 && (arg->flags & DRM_MODE_PAGE_FLIP_EVENT))
+		return -EINVAL;
+
 	return 0;
 }
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH v2] drm/core: Fail atomic IOCTL with no CRTC state but with signaling.
       [not found]     ` <1497981426-27203-1-git-send-email-Andrey.Grodzovsky-5C7GfCeVMHo@public.gmane.org>
@ 2017-06-26 19:44       ` Harry Wentland
       [not found]         ` <26571917-afb7-fb53-c002-5869cf8ccdf9-5C7GfCeVMHo@public.gmane.org>
  0 siblings, 1 reply; 14+ messages in thread
From: Harry Wentland @ 2017-06-26 19:44 UTC (permalink / raw)
  To: Andrey Grodzovsky, dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	intel-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	maarten.lankhorst-VuQAYsv1563Yd54FQh9/CA
  Cc: seanpaul-F7+t8E8rja9g9hUCZPvPmw, daniel-/w4YWyX8dFk,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

On 2017-06-20 01:57 PM, Andrey Grodzovsky wrote:
> Problem : While running IGT kms_atomic_transition test suite i encountered
> a hang in drmHandleEvent immediately following  an atomic_commit.
> After dumping the atomic state I relized that in this case there was
> not even one CRTC attached to the state and only disabled
> planes. This probably due to a commit which hadn't changed any property
> which would require attaching crtc state. This means drmHandleEvent
> will never wake up from read since without CRTC in atomic state
> the event fd will not be signaled.
> 
> Fix: Protect against this issue by failing atomic_commit early in
> drm_mode_atomic_commit where such probelm can be identified.
> 
> v2:
> Fix typos and extra newlines.
> 
> Change-Id: I3ee28ffae35fd1e8bfe553146c44da53da02e6f8
> Signed-off-by: Andrey Grodzovsky <Andrey.Grodzovsky@amd.com>

Reviewed-by: Harry Wentland <harry.wentland@amd.com>

Harry

> ---
>  drivers/gpu/drm/drm_atomic.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> index a567310..48145bf 100644
> --- a/drivers/gpu/drm/drm_atomic.c
> +++ b/drivers/gpu/drm/drm_atomic.c
> @@ -1933,7 +1933,7 @@ static int prepare_crtc_signaling(struct drm_device *dev,
>  {
>  	struct drm_crtc *crtc;
>  	struct drm_crtc_state *crtc_state;
> -	int i, ret;
> +	int i, c = 0, ret;
>  
>  	if (arg->flags & DRM_MODE_ATOMIC_TEST_ONLY)
>  		return 0;
> @@ -1994,8 +1994,17 @@ static int prepare_crtc_signaling(struct drm_device *dev,
>  
>  			crtc_state->event->base.fence = fence;
>  		}
> +
> +		c++;
>  	}
>  
> +	/*
> +	 * Having this flag means user mode pends on event which will never
> +	 * reach due to lack of at least one CRTC for signaling
> +	 */
> +	if (c == 0 && (arg->flags & DRM_MODE_PAGE_FLIP_EVENT))
> +		return -EINVAL;
> +
>  	return 0;
>  }
>  
> 
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v2] drm/core: Fail atomic IOCTL with no CRTC state but with signaling.
       [not found]         ` <26571917-afb7-fb53-c002-5869cf8ccdf9-5C7GfCeVMHo@public.gmane.org>
@ 2017-06-27  7:37           ` Daniel Vetter
       [not found]             ` <20170627073740.wz5xix2ecmvh4rbn-dv86pmgwkMBes7Z6vYuT8azUEOm+Xw19@public.gmane.org>
  0 siblings, 1 reply; 14+ messages in thread
From: Daniel Vetter @ 2017-06-27  7:37 UTC (permalink / raw)
  To: Harry Wentland
  Cc: Andrey Grodzovsky, intel-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	maarten.lankhorst-VuQAYsv1563Yd54FQh9/CA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	seanpaul-F7+t8E8rja9g9hUCZPvPmw,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, daniel-/w4YWyX8dFk

On Mon, Jun 26, 2017 at 03:44:07PM -0400, Harry Wentland wrote:
> On 2017-06-20 01:57 PM, Andrey Grodzovsky wrote:
> > Problem : While running IGT kms_atomic_transition test suite i encountered
> > a hang in drmHandleEvent immediately following  an atomic_commit.
> > After dumping the atomic state I relized that in this case there was
> > not even one CRTC attached to the state and only disabled
> > planes. This probably due to a commit which hadn't changed any property
> > which would require attaching crtc state. This means drmHandleEvent
> > will never wake up from read since without CRTC in atomic state
> > the event fd will not be signaled.
> > 
> > Fix: Protect against this issue by failing atomic_commit early in
> > drm_mode_atomic_commit where such probelm can be identified.
> > 
> > v2:
> > Fix typos and extra newlines.
> > 
> > Change-Id: I3ee28ffae35fd1e8bfe553146c44da53da02e6f8
> > Signed-off-by: Andrey Grodzovsky <Andrey.Grodzovsky@amd.com>
> 
> Reviewed-by: Harry Wentland <harry.wentland@amd.com>

Stalling on this hoping for the igt patch. Does it exist already?
-Daniel

> 
> Harry
> 
> > ---
> >  drivers/gpu/drm/drm_atomic.c | 11 ++++++++++-
> >  1 file changed, 10 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> > index a567310..48145bf 100644
> > --- a/drivers/gpu/drm/drm_atomic.c
> > +++ b/drivers/gpu/drm/drm_atomic.c
> > @@ -1933,7 +1933,7 @@ static int prepare_crtc_signaling(struct drm_device *dev,
> >  {
> >  	struct drm_crtc *crtc;
> >  	struct drm_crtc_state *crtc_state;
> > -	int i, ret;
> > +	int i, c = 0, ret;
> >  
> >  	if (arg->flags & DRM_MODE_ATOMIC_TEST_ONLY)
> >  		return 0;
> > @@ -1994,8 +1994,17 @@ static int prepare_crtc_signaling(struct drm_device *dev,
> >  
> >  			crtc_state->event->base.fence = fence;
> >  		}
> > +
> > +		c++;
> >  	}
> >  
> > +	/*
> > +	 * Having this flag means user mode pends on event which will never
> > +	 * reach due to lack of at least one CRTC for signaling
> > +	 */
> > +	if (c == 0 && (arg->flags & DRM_MODE_PAGE_FLIP_EVENT))
> > +		return -EINVAL;
> > +
> >  	return 0;
> >  }
> >  
> > 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v2] drm/core: Fail atomic IOCTL with no CRTC state but with signaling.
       [not found]             ` <20170627073740.wz5xix2ecmvh4rbn-dv86pmgwkMBes7Z6vYuT8azUEOm+Xw19@public.gmane.org>
@ 2017-06-27 14:29               ` Maarten Lankhorst
  2017-06-27 15:01                 ` Daniel Vetter
  0 siblings, 1 reply; 14+ messages in thread
From: Maarten Lankhorst @ 2017-06-27 14:29 UTC (permalink / raw)
  To: Harry Wentland, Andrey Grodzovsky,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	intel-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	seanpaul-F7+t8E8rja9g9hUCZPvPmw

Op 27-06-17 om 09:37 schreef Daniel Vetter:
> On Mon, Jun 26, 2017 at 03:44:07PM -0400, Harry Wentland wrote:
>> On 2017-06-20 01:57 PM, Andrey Grodzovsky wrote:
>>> Problem : While running IGT kms_atomic_transition test suite i encountered
>>> a hang in drmHandleEvent immediately following  an atomic_commit.
>>> After dumping the atomic state I relized that in this case there was
>>> not even one CRTC attached to the state and only disabled
>>> planes. This probably due to a commit which hadn't changed any property
>>> which would require attaching crtc state. This means drmHandleEvent
>>> will never wake up from read since without CRTC in atomic state
>>> the event fd will not be signaled.
>>>
>>> Fix: Protect against this issue by failing atomic_commit early in
>>> drm_mode_atomic_commit where such probelm can be identified.
>>>
>>> v2:
>>> Fix typos and extra newlines.
>>>
>>> Change-Id: I3ee28ffae35fd1e8bfe553146c44da53da02e6f8
>>> Signed-off-by: Andrey Grodzovsky <Andrey.Grodzovsky@amd.com>
>> Reviewed-by: Harry Wentland <harry.wentland@amd.com>
> Stalling on this hoping for the igt patch. Does it exist already?
> -Daniel
>
>> Harry
>>
>>> ---
>>>  drivers/gpu/drm/drm_atomic.c | 11 ++++++++++-
>>>  1 file changed, 10 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
>>> index a567310..48145bf 100644
>>> --- a/drivers/gpu/drm/drm_atomic.c
>>> +++ b/drivers/gpu/drm/drm_atomic.c
>>> @@ -1933,7 +1933,7 @@ static int prepare_crtc_signaling(struct drm_device *dev,
>>>  {
>>>  	struct drm_crtc *crtc;
>>>  	struct drm_crtc_state *crtc_state;
>>> -	int i, ret;
>>> +	int i, c = 0, ret;
>>>  
>>>  	if (arg->flags & DRM_MODE_ATOMIC_TEST_ONLY)
>>>  		return 0;
>>> @@ -1994,8 +1994,17 @@ static int prepare_crtc_signaling(struct drm_device *dev,
>>>  
>>>  			crtc_state->event->base.fence = fence;
>>>  		}
>>> +
>>> +		c++;
>>>  	}
>>>  
>>> +	/*
>>> +	 * Having this flag means user mode pends on event which will never
>>> +	 * reach due to lack of at least one CRTC for signaling
>>> +	 */
>>> +	if (c == 0 && (arg->flags & DRM_MODE_PAGE_FLIP_EVENT))
>>> +		return -EINVAL;
>>> +
>>>  	return 0;
>>>  }
>>>  
>>>
Just do it, and I'll commit this to igt?

diff --git a/tests/kms_atomic.c b/tests/kms_atomic.c
index 6375fede7179..77429b3db384 100644
--- a/tests/kms_atomic.c
+++ b/tests/kms_atomic.c
@@ -1205,6 +1205,15 @@ static void crtc_invalid_params(struct kms_atomic_crtc_state *crtc_old,
 	crtc_commit_atomic(&crtc, plane, req, ATOMIC_RELAX_NONE,
 			   DRM_MODE_ATOMIC_TEST_ONLY);
 
+	/*
+	 * TEST_ONLY cannot be combined with DRM_MODE_PAGE_FLIP_EVENT,
+	 * but DRM_MODE_PAGE_FLIP_EVENT will always generate EINVAL
+	 * without valid crtc, so test it here.
+	 */
+	crtc_commit_atomic_err(&crtc, plane, req, ATOMIC_RELAX_NONE,
+			       DRM_MODE_ATOMIC_TEST_ONLY | DRM_MODE_PAGE_FLIP_EVENT,
+			       EINVAL);
+
 	/* Create a blob which is the wrong size to be a valid mode. */
 	do_or_die(drmModeCreatePropertyBlob(crtc.state->desc->fd,
 					    crtc.mode.data,
@@ -1356,12 +1365,12 @@ static void atomic_invalid_params(struct kms_atomic_crtc_state *crtc,
 	/* Valid pointers, but still should copy nothing. */
 	do_ioctl(desc->fd, DRM_IOCTL_MODE_ATOMIC, &ioc);
 
-	/* Nonsense flags. */
-	ioc.flags = 0xdeadbeef;
+	/* Valid noop, but with event set should fail. */
+	ioc.flags = DRM_MODE_PAGE_FLIP_EVENT;
 	do_ioctl_err(desc->fd, DRM_IOCTL_MODE_ATOMIC, &ioc, EINVAL);
 
-	/* Specifically forbidden combination. */
-	ioc.flags = DRM_MODE_ATOMIC_TEST_ONLY | DRM_MODE_PAGE_FLIP_EVENT;
+	/* Nonsense flags. */
+	ioc.flags = 0xdeadbeef;
 	do_ioctl_err(desc->fd, DRM_IOCTL_MODE_ATOMIC, &ioc, EINVAL);
 
 	ioc.flags = 0;

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH v2] drm/core: Fail atomic IOCTL with no CRTC state but with signaling.
  2017-06-27 14:29               ` Maarten Lankhorst
@ 2017-06-27 15:01                 ` Daniel Vetter
  2017-06-28 10:23                   ` Maarten Lankhorst
  0 siblings, 1 reply; 14+ messages in thread
From: Daniel Vetter @ 2017-06-27 15:01 UTC (permalink / raw)
  To: Maarten Lankhorst; +Cc: intel-gfx, linux-kernel, amd-gfx, dri-devel

On Tue, Jun 27, 2017 at 04:29:44PM +0200, Maarten Lankhorst wrote:
> Op 27-06-17 om 09:37 schreef Daniel Vetter:
> > On Mon, Jun 26, 2017 at 03:44:07PM -0400, Harry Wentland wrote:
> >> On 2017-06-20 01:57 PM, Andrey Grodzovsky wrote:
> >>> Problem : While running IGT kms_atomic_transition test suite i encountered
> >>> a hang in drmHandleEvent immediately following  an atomic_commit.
> >>> After dumping the atomic state I relized that in this case there was
> >>> not even one CRTC attached to the state and only disabled
> >>> planes. This probably due to a commit which hadn't changed any property
> >>> which would require attaching crtc state. This means drmHandleEvent
> >>> will never wake up from read since without CRTC in atomic state
> >>> the event fd will not be signaled.
> >>>
> >>> Fix: Protect against this issue by failing atomic_commit early in
> >>> drm_mode_atomic_commit where such probelm can be identified.
> >>>
> >>> v2:
> >>> Fix typos and extra newlines.
> >>>
> >>> Change-Id: I3ee28ffae35fd1e8bfe553146c44da53da02e6f8
> >>> Signed-off-by: Andrey Grodzovsky <Andrey.Grodzovsky@amd.com>
> >> Reviewed-by: Harry Wentland <harry.wentland@amd.com>
> > Stalling on this hoping for the igt patch. Does it exist already?
> > -Daniel
> >
> >> Harry
> >>
> >>> ---
> >>>  drivers/gpu/drm/drm_atomic.c | 11 ++++++++++-
> >>>  1 file changed, 10 insertions(+), 1 deletion(-)
> >>>
> >>> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> >>> index a567310..48145bf 100644
> >>> --- a/drivers/gpu/drm/drm_atomic.c
> >>> +++ b/drivers/gpu/drm/drm_atomic.c
> >>> @@ -1933,7 +1933,7 @@ static int prepare_crtc_signaling(struct drm_device *dev,
> >>>  {
> >>>  	struct drm_crtc *crtc;
> >>>  	struct drm_crtc_state *crtc_state;
> >>> -	int i, ret;
> >>> +	int i, c = 0, ret;
> >>>  
> >>>  	if (arg->flags & DRM_MODE_ATOMIC_TEST_ONLY)
> >>>  		return 0;
> >>> @@ -1994,8 +1994,17 @@ static int prepare_crtc_signaling(struct drm_device *dev,
> >>>  
> >>>  			crtc_state->event->base.fence = fence;
> >>>  		}
> >>> +
> >>> +		c++;
> >>>  	}
> >>>  
> >>> +	/*
> >>> +	 * Having this flag means user mode pends on event which will never
> >>> +	 * reach due to lack of at least one CRTC for signaling
> >>> +	 */
> >>> +	if (c == 0 && (arg->flags & DRM_MODE_PAGE_FLIP_EVENT))
> >>> +		return -EINVAL;
> >>> +
> >>>  	return 0;
> >>>  }
> >>>  
> >>>
> Just do it, and I'll commit this to igt?

Ack on both the kernel patch and the igt patch, feel free to push them
both with:

Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>

If you do, please add the Testcase: line to the kernel patch.

Thanks, Daniel

> 
> diff --git a/tests/kms_atomic.c b/tests/kms_atomic.c
> index 6375fede7179..77429b3db384 100644
> --- a/tests/kms_atomic.c
> +++ b/tests/kms_atomic.c
> @@ -1205,6 +1205,15 @@ static void crtc_invalid_params(struct kms_atomic_crtc_state *crtc_old,
>  	crtc_commit_atomic(&crtc, plane, req, ATOMIC_RELAX_NONE,
>  			   DRM_MODE_ATOMIC_TEST_ONLY);
>  
> +	/*
> +	 * TEST_ONLY cannot be combined with DRM_MODE_PAGE_FLIP_EVENT,
> +	 * but DRM_MODE_PAGE_FLIP_EVENT will always generate EINVAL
> +	 * without valid crtc, so test it here.
> +	 */
> +	crtc_commit_atomic_err(&crtc, plane, req, ATOMIC_RELAX_NONE,
> +			       DRM_MODE_ATOMIC_TEST_ONLY | DRM_MODE_PAGE_FLIP_EVENT,
> +			       EINVAL);
> +
>  	/* Create a blob which is the wrong size to be a valid mode. */
>  	do_or_die(drmModeCreatePropertyBlob(crtc.state->desc->fd,
>  					    crtc.mode.data,
> @@ -1356,12 +1365,12 @@ static void atomic_invalid_params(struct kms_atomic_crtc_state *crtc,
>  	/* Valid pointers, but still should copy nothing. */
>  	do_ioctl(desc->fd, DRM_IOCTL_MODE_ATOMIC, &ioc);
>  
> -	/* Nonsense flags. */
> -	ioc.flags = 0xdeadbeef;
> +	/* Valid noop, but with event set should fail. */
> +	ioc.flags = DRM_MODE_PAGE_FLIP_EVENT;
>  	do_ioctl_err(desc->fd, DRM_IOCTL_MODE_ATOMIC, &ioc, EINVAL);
>  
> -	/* Specifically forbidden combination. */
> -	ioc.flags = DRM_MODE_ATOMIC_TEST_ONLY | DRM_MODE_PAGE_FLIP_EVENT;
> +	/* Nonsense flags. */
> +	ioc.flags = 0xdeadbeef;
>  	do_ioctl_err(desc->fd, DRM_IOCTL_MODE_ATOMIC, &ioc, EINVAL);
>  
>  	ioc.flags = 0;
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v2] drm/core: Fail atomic IOCTL with no CRTC state but with signaling.
  2017-06-27 15:01                 ` Daniel Vetter
@ 2017-06-28 10:23                   ` Maarten Lankhorst
  0 siblings, 0 replies; 14+ messages in thread
From: Maarten Lankhorst @ 2017-06-28 10:23 UTC (permalink / raw)
  To: Harry Wentland, Andrey Grodzovsky, dri-devel, linux-kernel,
	intel-gfx, amd-gfx, seanpaul

Op 27-06-17 om 17:01 schreef Daniel Vetter:
> On Tue, Jun 27, 2017 at 04:29:44PM +0200, Maarten Lankhorst wrote:
>> Op 27-06-17 om 09:37 schreef Daniel Vetter:
>>> On Mon, Jun 26, 2017 at 03:44:07PM -0400, Harry Wentland wrote:
>>>> On 2017-06-20 01:57 PM, Andrey Grodzovsky wrote:
>>>>> Problem : While running IGT kms_atomic_transition test suite i encountered
>>>>> a hang in drmHandleEvent immediately following  an atomic_commit.
>>>>> After dumping the atomic state I relized that in this case there was
>>>>> not even one CRTC attached to the state and only disabled
>>>>> planes. This probably due to a commit which hadn't changed any property
>>>>> which would require attaching crtc state. This means drmHandleEvent
>>>>> will never wake up from read since without CRTC in atomic state
>>>>> the event fd will not be signaled.
>>>>>
>>>>> Fix: Protect against this issue by failing atomic_commit early in
>>>>> drm_mode_atomic_commit where such probelm can be identified.
>>>>>
>>>>> v2:
>>>>> Fix typos and extra newlines.
>>>>>
>>>>> Change-Id: I3ee28ffae35fd1e8bfe553146c44da53da02e6f8
>>>>> Signed-off-by: Andrey Grodzovsky <Andrey.Grodzovsky@amd.com>
>>>> Reviewed-by: Harry Wentland <harry.wentland@amd.com>
>>> Stalling on this hoping for the igt patch. Does it exist already?
>>> -Daniel
>>>
>>>> Harry
>>>>
>>>>> ---
>>>>>  drivers/gpu/drm/drm_atomic.c | 11 ++++++++++-
>>>>>  1 file changed, 10 insertions(+), 1 deletion(-)
>>>>>
>>>>> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
>>>>> index a567310..48145bf 100644
>>>>> --- a/drivers/gpu/drm/drm_atomic.c
>>>>> +++ b/drivers/gpu/drm/drm_atomic.c
>>>>> @@ -1933,7 +1933,7 @@ static int prepare_crtc_signaling(struct drm_device *dev,
>>>>>  {
>>>>>  	struct drm_crtc *crtc;
>>>>>  	struct drm_crtc_state *crtc_state;
>>>>> -	int i, ret;
>>>>> +	int i, c = 0, ret;
>>>>>  
>>>>>  	if (arg->flags & DRM_MODE_ATOMIC_TEST_ONLY)
>>>>>  		return 0;
>>>>> @@ -1994,8 +1994,17 @@ static int prepare_crtc_signaling(struct drm_device *dev,
>>>>>  
>>>>>  			crtc_state->event->base.fence = fence;
>>>>>  		}
>>>>> +
>>>>> +		c++;
>>>>>  	}
>>>>>  
>>>>> +	/*
>>>>> +	 * Having this flag means user mode pends on event which will never
>>>>> +	 * reach due to lack of at least one CRTC for signaling
>>>>> +	 */
>>>>> +	if (c == 0 && (arg->flags & DRM_MODE_PAGE_FLIP_EVENT))
>>>>> +		return -EINVAL;
>>>>> +
>>>>>  	return 0;
>>>>>  }
>>>>>  
>>>>>
>> Just do it, and I'll commit this to igt?
> Ack on both the kernel patch and the igt patch, feel free to push them
> both with:
>
> Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
>
> If you do, please add the Testcase: line to the kernel patch.
Oops, missed adding the testcase to commit message, but pushed.

I've pushed the IGT testcase as well, after fixing it up to make sure it works as intended.

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

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2017-06-28 10:23 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-09 21:30 [PATCH] drm/core: Fail atomic IOCTL with no CRTC state but with signaling Andrey Grodzovsky
     [not found] ` <1497043819-28591-1-git-send-email-Andrey.Grodzovsky-5C7GfCeVMHo@public.gmane.org>
2017-06-12 11:08   ` Maarten Lankhorst
2017-06-12 14:12     ` Andrey Grodzovsky
2017-06-15 20:46 ` Andrey Grodzovsky
2017-06-19 15:35 ` Harry Wentland
     [not found]   ` <0d603149-3fb0-3d48-89e5-77e3f7686415-5C7GfCeVMHo@public.gmane.org>
2017-06-19 19:24     ` Sean Paul
2017-06-19 20:11       ` Andrey Grodzovsky
2017-06-20  9:29         ` Daniel Vetter
2017-06-20 17:57   ` [PATCH v2] " Andrey Grodzovsky
     [not found]     ` <1497981426-27203-1-git-send-email-Andrey.Grodzovsky-5C7GfCeVMHo@public.gmane.org>
2017-06-26 19:44       ` Harry Wentland
     [not found]         ` <26571917-afb7-fb53-c002-5869cf8ccdf9-5C7GfCeVMHo@public.gmane.org>
2017-06-27  7:37           ` Daniel Vetter
     [not found]             ` <20170627073740.wz5xix2ecmvh4rbn-dv86pmgwkMBes7Z6vYuT8azUEOm+Xw19@public.gmane.org>
2017-06-27 14:29               ` Maarten Lankhorst
2017-06-27 15:01                 ` Daniel Vetter
2017-06-28 10:23                   ` Maarten Lankhorst

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).