[03/27] drm/arc: Actually bother with handling atomic events.
diff mbox

Message ID 1465388359-8070-3-git-send-email-daniel.vetter@ffwll.ch
State New
Headers show

Commit Message

Daniel Vetter June 8, 2016, 12:18 p.m. UTC
The drm core has a nice ready-made helper for exactly the simple case
where it should fire on the next vblank.

Note that arming the vblank event in _begin is probably too early, and
might easily result in the vblank firing too early, before the new set
of planes are actually disabled. But that's kinda a minor issue
compared to just outright hanging userspace.

v2: Be more robust and either arm, when the CRTC is on, or just send
the event out right away.

Cc: Carlos Palminha <palminha@synopsys.com>
Cc: Alexey Brodkin <abrodkin@synopsys.com>
Cc: linux-snps-arc@lists.infradead.org
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 drivers/gpu/drm/arc/arcpgu_crtc.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

Comments

Maarten Lankhorst June 8, 2016, 2:14 p.m. UTC | #1
Op 08-06-16 om 14:18 schreef Daniel Vetter:
> The drm core has a nice ready-made helper for exactly the simple case
> where it should fire on the next vblank.
>
> Note that arming the vblank event in _begin is probably too early, and
> might easily result in the vblank firing too early, before the new set
> of planes are actually disabled. But that's kinda a minor issue
> compared to just outright hanging userspace.
>
> v2: Be more robust and either arm, when the CRTC is on, or just send
> the event out right away.
>
> Cc: Carlos Palminha <palminha@synopsys.com>
> Cc: Alexey Brodkin <abrodkin@synopsys.com>
> Cc: linux-snps-arc@lists.infradead.org
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Wouldn't it be better to do this in atomic_flush then?
Daniel Vetter June 8, 2016, 2:30 p.m. UTC | #2
On Wed, Jun 08, 2016 at 04:14:38PM +0200, Maarten Lankhorst wrote:
> Op 08-06-16 om 14:18 schreef Daniel Vetter:
> > The drm core has a nice ready-made helper for exactly the simple case
> > where it should fire on the next vblank.
> >
> > Note that arming the vblank event in _begin is probably too early, and
> > might easily result in the vblank firing too early, before the new set
> > of planes are actually disabled. But that's kinda a minor issue
> > compared to just outright hanging userspace.
> >
> > v2: Be more robust and either arm, when the CRTC is on, or just send
> > the event out right away.
> >
> > Cc: Carlos Palminha <palminha@synopsys.com>
> > Cc: Alexey Brodkin <abrodkin@synopsys.com>
> > Cc: linux-snps-arc@lists.infradead.org
> > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Wouldn't it be better to do this in atomic_flush then?

I'm not going to fix up other people's drivers completely, just enough to
hopefully not break them. If arc also blocks vblank interrupts with the go
bit, then doing this in _begin is correct. Either way it needs hw-specific
knowledge to asses whether it's correct, since doing the vblank event
stuff in _flush is also racy without some prevention.
-Daniel
Alexey Brodkin June 9, 2016, 10:54 a.m. UTC | #3
Hi Daniel,

On Wed, 2016-06-08 at 16:30 +0200, Daniel Vetter wrote:
> On Wed, Jun 08, 2016 at 04:14:38PM +0200, Maarten Lankhorst wrote:
> > 
> > Op 08-06-16 om 14:18 schreef Daniel Vetter:
> > > 
> > > The drm core has a nice ready-made helper for exactly the simple case
> > > where it should fire on the next vblank.
> > > 
> > > Note that arming the vblank event in _begin is probably too early, and
> > > might easily result in the vblank firing too early, before the new set
> > > of planes are actually disabled. But that's kinda a minor issue
> > > compared to just outright hanging userspace.
> > > 
> > > v2: Be more robust and either arm, when the CRTC is on, or just send
> > > the event out right away.
> > > 
> > > Cc: Carlos Palminha <palminha@synopsys.com>
> > > Cc: Alexey Brodkin <abrodkin@synopsys.com>
> > > Cc: linux-snps-arc@lists.infradead.org
> > > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > Wouldn't it be better to do this in atomic_flush then?
> I'm not going to fix up other people's drivers completely, just enough to
> hopefully not break them. If arc also blocks vblank interrupts with the go
> bit, then doing this in _begin is correct. Either way it needs hw-specific
> knowledge to asses whether it's correct, since doing the vblank event
> stuff in _flush is also racy without some prevention.

Actually in ARC PGU driver that was one of many other copy-pastes from
other drivers. I.e. for me this is another boilerplate and if that's the
same for other drivers as well probably that's a good candidate for
generalization into something like drm_helper_crtc_atomic_check().

-Alexey
Daniel Vetter June 9, 2016, 12:26 p.m. UTC | #4
On Thu, Jun 09, 2016 at 10:54:45AM +0000, Alexey Brodkin wrote:
> Hi Daniel,
> 
> On Wed, 2016-06-08 at 16:30 +0200, Daniel Vetter wrote:
> > On Wed, Jun 08, 2016 at 04:14:38PM +0200, Maarten Lankhorst wrote:
> > > 
> > > Op 08-06-16 om 14:18 schreef Daniel Vetter:
> > > > 
> > > > The drm core has a nice ready-made helper for exactly the simple case
> > > > where it should fire on the next vblank.
> > > > 
> > > > Note that arming the vblank event in _begin is probably too early, and
> > > > might easily result in the vblank firing too early, before the new set
> > > > of planes are actually disabled. But that's kinda a minor issue
> > > > compared to just outright hanging userspace.
> > > > 
> > > > v2: Be more robust and either arm, when the CRTC is on, or just send
> > > > the event out right away.
> > > > 
> > > > Cc: Carlos Palminha <palminha@synopsys.com>
> > > > Cc: Alexey Brodkin <abrodkin@synopsys.com>
> > > > Cc: linux-snps-arc@lists.infradead.org
> > > > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > > Wouldn't it be better to do this in atomic_flush then?
> > I'm not going to fix up other people's drivers completely, just enough to
> > hopefully not break them. If arc also blocks vblank interrupts with the go
> > bit, then doing this in _begin is correct. Either way it needs hw-specific
> > knowledge to asses whether it's correct, since doing the vblank event
> > stuff in _flush is also racy without some prevention.
> 
> Actually in ARC PGU driver that was one of many other copy-pastes from
> other drivers. I.e. for me this is another boilerplate and if that's the
> same for other drivers as well probably that's a good candidate for
> generalization into something like drm_helper_crtc_atomic_check().

I checked them all, you are special with your code here. And this can't be
generalized since you must send out vblank events in a race-free manner
against the actual hw update. This requires deep knowledge of the actual
hw, and it's not something the helpers can take care of you. It is very
much not boilerplate, but crucial for a correct implementation. And most
likely arcpgu is wrong, but since I don't have that hw knowledge I'm not
going to change it more than absolutely required.
-Daniel
Alexey Brodkin June 9, 2016, 12:48 p.m. UTC | #5
Hi Daniel,

On Thu, 2016-06-09 at 14:26 +0200, Daniel Vetter wrote:
> On Thu, Jun 09, 2016 at 10:54:45AM +0000, Alexey Brodkin wrote:
> > 
> > Hi Daniel,
> > 
> > On Wed, 2016-06-08 at 16:30 +0200, Daniel Vetter wrote:
> > > 
> > > On Wed, Jun 08, 2016 at 04:14:38PM +0200, Maarten Lankhorst wrote:
> > > > 
> > > > 
> > > > Op 08-06-16 om 14:18 schreef Daniel Vetter:
> > > > > 
> > > > > 
> > > > > The drm core has a nice ready-made helper for exactly the simple case
> > > > > where it should fire on the next vblank.
> > > > > 
> > > > > Note that arming the vblank event in _begin is probably too early, and
> > > > > might easily result in the vblank firing too early, before the new set
> > > > > of planes are actually disabled. But that's kinda a minor issue
> > > > > compared to just outright hanging userspace.
> > > > > 
> > > > > v2: Be more robust and either arm, when the CRTC is on, or just send
> > > > > the event out right away.
> > > > > 
> > > > > Cc: Carlos Palminha <palminha@synopsys.com>
> > > > > Cc: Alexey Brodkin <abrodkin@synopsys.com>
> > > > > Cc: linux-snps-arc@lists.infradead.org
> > > > > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > > > Wouldn't it be better to do this in atomic_flush then?
> > > I'm not going to fix up other people's drivers completely, just enough to
> > > hopefully not break them. If arc also blocks vblank interrupts with the go
> > > bit, then doing this in _begin is correct. Either way it needs hw-specific
> > > knowledge to asses whether it's correct, since doing the vblank event
> > > stuff in _flush is also racy without some prevention.
> > Actually in ARC PGU driver that was one of many other copy-pastes from
> > other drivers. I.e. for me this is another boilerplate and if that's the
> > same for other drivers as well probably that's a good candidate for
> > generalization into something like drm_helper_crtc_atomic_check().
>
> I checked them all, you are special with your code here. And this can't be
> generalized since you must send out vblank events in a race-free manner
> against the actual hw update. This requires deep knowledge of the actual
> hw, and it's not something the helpers can take care of you. It is very
> much not boilerplate, but crucial for a correct implementation. And most
> likely arcpgu is wrong, but since I don't have that hw knowledge I'm not
> going to change it more than absolutely required.

Well I meant as of today we don't support vblank interrupts and so
arc_pgu_crtc_atomic_begin() barely makes any sense.

Still in the future we do plan to add support of interrupts.

-Alexey
Daniel Vetter June 9, 2016, 1:23 p.m. UTC | #6
On Thu, Jun 09, 2016 at 12:48:31PM +0000, Alexey Brodkin wrote:
> Hi Daniel,
> 
> On Thu, 2016-06-09 at 14:26 +0200, Daniel Vetter wrote:
> > On Thu, Jun 09, 2016 at 10:54:45AM +0000, Alexey Brodkin wrote:
> > > 
> > > Hi Daniel,
> > > 
> > > On Wed, 2016-06-08 at 16:30 +0200, Daniel Vetter wrote:
> > > > 
> > > > On Wed, Jun 08, 2016 at 04:14:38PM +0200, Maarten Lankhorst wrote:
> > > > > 
> > > > > 
> > > > > Op 08-06-16 om 14:18 schreef Daniel Vetter:
> > > > > > 
> > > > > > 
> > > > > > The drm core has a nice ready-made helper for exactly the simple case
> > > > > > where it should fire on the next vblank.
> > > > > > 
> > > > > > Note that arming the vblank event in _begin is probably too early, and
> > > > > > might easily result in the vblank firing too early, before the new set
> > > > > > of planes are actually disabled. But that's kinda a minor issue
> > > > > > compared to just outright hanging userspace.
> > > > > > 
> > > > > > v2: Be more robust and either arm, when the CRTC is on, or just send
> > > > > > the event out right away.
> > > > > > 
> > > > > > Cc: Carlos Palminha <palminha@synopsys.com>
> > > > > > Cc: Alexey Brodkin <abrodkin@synopsys.com>
> > > > > > Cc: linux-snps-arc@lists.infradead.org
> > > > > > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > > > > Wouldn't it be better to do this in atomic_flush then?
> > > > I'm not going to fix up other people's drivers completely, just enough to
> > > > hopefully not break them. If arc also blocks vblank interrupts with the go
> > > > bit, then doing this in _begin is correct. Either way it needs hw-specific
> > > > knowledge to asses whether it's correct, since doing the vblank event
> > > > stuff in _flush is also racy without some prevention.
> > > Actually in ARC PGU driver that was one of many other copy-pastes from
> > > other drivers. I.e. for me this is another boilerplate and if that's the
> > > same for other drivers as well probably that's a good candidate for
> > > generalization into something like drm_helper_crtc_atomic_check().
> >
> > I checked them all, you are special with your code here. And this can't be
> > generalized since you must send out vblank events in a race-free manner
> > against the actual hw update. This requires deep knowledge of the actual
> > hw, and it's not something the helpers can take care of you. It is very
> > much not boilerplate, but crucial for a correct implementation. And most
> > likely arcpgu is wrong, but since I don't have that hw knowledge I'm not
> > going to change it more than absolutely required.
> 
> Well I meant as of today we don't support vblank interrupts and so
> arc_pgu_crtc_atomic_begin() barely makes any sense.
> 
> Still in the future we do plan to add support of interrupts.

If you don't support vblank interrupts you're driver isn't compliant with
atomic. You need to at least fake them.
-Daniel
Alexey Brodkin June 9, 2016, 1:27 p.m. UTC | #7
Hi Daniel,

On Thu, 2016-06-09 at 15:23 +0200, Daniel Vetter wrote:
> On Thu, Jun 09, 2016 at 12:48:31PM +0000, Alexey Brodkin wrote:
> > 
> > Hi Daniel,
> > 
> > On Thu, 2016-06-09 at 14:26 +0200, Daniel Vetter wrote:
> > > 
> > > On Thu, Jun 09, 2016 at 10:54:45AM +0000, Alexey Brodkin wrote:
> > > > 
> > > > 
> > > > Hi Daniel,
> > > > 
> > > > On Wed, 2016-06-08 at 16:30 +0200, Daniel Vetter wrote:
> > > > > 
> > > > > 
> > > > > On Wed, Jun 08, 2016 at 04:14:38PM +0200, Maarten Lankhorst wrote:
> > > > > > 
> > > > > > 
> > > > > > 
> > > > > > Op 08-06-16 om 14:18 schreef Daniel Vetter:
> > > > > > > 
> > > > > > > 
> > > > > > > 
> > > > > > > The drm core has a nice ready-made helper for exactly the simple case
> > > > > > > where it should fire on the next vblank.
> > > > > > > 
> > > > > > > Note that arming the vblank event in _begin is probably too early, and
> > > > > > > might easily result in the vblank firing too early, before the new set
> > > > > > > of planes are actually disabled. But that's kinda a minor issue
> > > > > > > compared to just outright hanging userspace.
> > > > > > > 
> > > > > > > v2: Be more robust and either arm, when the CRTC is on, or just send
> > > > > > > the event out right away.
> > > > > > > 
> > > > > > > Cc: Carlos Palminha <palminha@synopsys.com>
> > > > > > > Cc: Alexey Brodkin <abrodkin@synopsys.com>
> > > > > > > Cc: linux-snps-arc@lists.infradead.org
> > > > > > > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > > > > > Wouldn't it be better to do this in atomic_flush then?
> > > > > I'm not going to fix up other people's drivers completely, just enough to
> > > > > hopefully not break them. If arc also blocks vblank interrupts with the go
> > > > > bit, then doing this in _begin is correct. Either way it needs hw-specific
> > > > > knowledge to asses whether it's correct, since doing the vblank event
> > > > > stuff in _flush is also racy without some prevention.
> > > > Actually in ARC PGU driver that was one of many other copy-pastes from
> > > > other drivers. I.e. for me this is another boilerplate and if that's the
> > > > same for other drivers as well probably that's a good candidate for
> > > > generalization into something like drm_helper_crtc_atomic_check().
> > > I checked them all, you are special with your code here. And this can't be
> > > generalized since you must send out vblank events in a race-free manner
> > > against the actual hw update. This requires deep knowledge of the actual
> > > hw, and it's not something the helpers can take care of you. It is very
> > > much not boilerplate, but crucial for a correct implementation. And most
> > > likely arcpgu is wrong, but since I don't have that hw knowledge I'm not
> > > going to change it more than absolutely required.
> > Well I meant as of today we don't support vblank interrupts and so
> > arc_pgu_crtc_atomic_begin() barely makes any sense.
> > 
> > Still in the future we do plan to add support of interrupts.
> 
>
> If you don't support vblank interrupts you're driver isn't compliant with
> atomic. You need to at least fake them.

Indeed. So my assumption was there are (or could appear) other simple drivers
of the same kind and that fake implementation might be generic.

-Alexey
Daniel Vetter June 9, 2016, 1:52 p.m. UTC | #8
On Thu, Jun 09, 2016 at 01:27:55PM +0000, Alexey Brodkin wrote:
> Hi Daniel,
> 
> On Thu, 2016-06-09 at 15:23 +0200, Daniel Vetter wrote:
> > On Thu, Jun 09, 2016 at 12:48:31PM +0000, Alexey Brodkin wrote:
> > > 
> > > Hi Daniel,
> > > 
> > > On Thu, 2016-06-09 at 14:26 +0200, Daniel Vetter wrote:
> > > > 
> > > > On Thu, Jun 09, 2016 at 10:54:45AM +0000, Alexey Brodkin wrote:
> > > > > 
> > > > > 
> > > > > Hi Daniel,
> > > > > 
> > > > > On Wed, 2016-06-08 at 16:30 +0200, Daniel Vetter wrote:
> > > > > > 
> > > > > > 
> > > > > > On Wed, Jun 08, 2016 at 04:14:38PM +0200, Maarten Lankhorst wrote:
> > > > > > > 
> > > > > > > 
> > > > > > > 
> > > > > > > Op 08-06-16 om 14:18 schreef Daniel Vetter:
> > > > > > > > 
> > > > > > > > 
> > > > > > > > 
> > > > > > > > The drm core has a nice ready-made helper for exactly the simple case
> > > > > > > > where it should fire on the next vblank.
> > > > > > > > 
> > > > > > > > Note that arming the vblank event in _begin is probably too early, and
> > > > > > > > might easily result in the vblank firing too early, before the new set
> > > > > > > > of planes are actually disabled. But that's kinda a minor issue
> > > > > > > > compared to just outright hanging userspace.
> > > > > > > > 
> > > > > > > > v2: Be more robust and either arm, when the CRTC is on, or just send
> > > > > > > > the event out right away.
> > > > > > > > 
> > > > > > > > Cc: Carlos Palminha <palminha@synopsys.com>
> > > > > > > > Cc: Alexey Brodkin <abrodkin@synopsys.com>
> > > > > > > > Cc: linux-snps-arc@lists.infradead.org
> > > > > > > > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > > > > > > Wouldn't it be better to do this in atomic_flush then?
> > > > > > I'm not going to fix up other people's drivers completely, just enough to
> > > > > > hopefully not break them. If arc also blocks vblank interrupts with the go
> > > > > > bit, then doing this in _begin is correct. Either way it needs hw-specific
> > > > > > knowledge to asses whether it's correct, since doing the vblank event
> > > > > > stuff in _flush is also racy without some prevention.
> > > > > Actually in ARC PGU driver that was one of many other copy-pastes from
> > > > > other drivers. I.e. for me this is another boilerplate and if that's the
> > > > > same for other drivers as well probably that's a good candidate for
> > > > > generalization into something like drm_helper_crtc_atomic_check().
> > > > I checked them all, you are special with your code here. And this can't be
> > > > generalized since you must send out vblank events in a race-free manner
> > > > against the actual hw update. This requires deep knowledge of the actual
> > > > hw, and it's not something the helpers can take care of you. It is very
> > > > much not boilerplate, but crucial for a correct implementation. And most
> > > > likely arcpgu is wrong, but since I don't have that hw knowledge I'm not
> > > > going to change it more than absolutely required.
> > > Well I meant as of today we don't support vblank interrupts and so
> > > arc_pgu_crtc_atomic_begin() barely makes any sense.
> > > 
> > > Still in the future we do plan to add support of interrupts.
> > 
> >
> > If you don't support vblank interrupts you're driver isn't compliant with
> > atomic. You need to at least fake them.
> 
> Indeed. So my assumption was there are (or could appear) other simple drivers
> of the same kind and that fake implementation might be generic.

The fake implementation is fundamentally racy, and I don't want to write
helpers which can't be used correctly. Anyway I think without this patch
(or something similar) arcpgu will stall badly with the new nonblocking
helpers, because arcpgu didn't bother at all to implement nonblocking. Can
you pls ack this, or even better, test the entire patch series? The
helpers themselves should work, but in all 5 drivers tested thus far they
discovered some bugs.
-Daniel
Alexey Brodkin June 9, 2016, 2:29 p.m. UTC | #9
Hi Daniel,

On Thu, 2016-06-09 at 15:52 +0200, Daniel Vetter wrote:

> The fake implementation is fundamentally racy, and I don't want to write
> helpers which can't be used correctly. Anyway I think without this patch
> (or something similar) arcpgu will stall badly with the new nonblocking
> helpers, because arcpgu didn't bother at all to implement nonblocking. Can
> you pls ack this, or even better, test the entire patch series? The
> helpers themselves should work, but in all 5 drivers tested thus far they
> discovered some bugs.

Sure I will happily test this series.
The only question then is what should I use as a proper base?

-Alexey
Daniel Vetter June 9, 2016, 2:31 p.m. UTC | #10
On Thu, Jun 9, 2016 at 4:29 PM, Alexey Brodkin
<Alexey.Brodkin@synopsys.com> wrote:
> Hi Daniel,
>
> On Thu, 2016-06-09 at 15:52 +0200, Daniel Vetter wrote:
>>
>> The fake implementation is fundamentally racy, and I don't want to write
>> helpers which can't be used correctly. Anyway I think without this patch
>> (or something similar) arcpgu will stall badly with the new nonblocking
>> helpers, because arcpgu didn't bother at all to implement nonblocking. Can
>> you pls ack this, or even better, test the entire patch series? The
>> helpers themselves should work, but in all 5 drivers tested thus far they
>> discovered some bugs.
>
> Sure I will happily test this series.
> The only question then is what should I use as a proper base?

It should apply on drm-next from Dave.
-Daniel
Daniel Vetter June 9, 2016, 2:37 p.m. UTC | #11
On Thu, Jun 9, 2016 at 4:31 PM, Daniel Vetter <daniel@ffwll.ch> wrote:
> On Thu, Jun 9, 2016 at 4:29 PM, Alexey Brodkin
> <Alexey.Brodkin@synopsys.com> wrote:
>> Hi Daniel,
>>
>> On Thu, 2016-06-09 at 15:52 +0200, Daniel Vetter wrote:
>>>
>>> The fake implementation is fundamentally racy, and I don't want to write
>>> helpers which can't be used correctly. Anyway I think without this patch
>>> (or something similar) arcpgu will stall badly with the new nonblocking
>>> helpers, because arcpgu didn't bother at all to implement nonblocking. Can
>>> you pls ack this, or even better, test the entire patch series? The
>>> helpers themselves should work, but in all 5 drivers tested thus far they
>>> discovered some bugs.
>>
>> Sure I will happily test this series.
>> The only question then is what should I use as a proper base?
>
> It should apply on drm-next from Dave.

And indeed it won't work at all because arcpgu doesn't call
drm_crtc_handle_vblank anywhere. So you need to add your patch to
enable vblank interrupts somewhere. Note that as long as you leave
max_vblank_counter as 0, the only bits you need is drm_vblank_init and
drm_crtc_handle_vblanke() from the irq handler.
-Daniel
Alexey Brodkin June 10, 2016, 1:23 p.m. UTC | #12
Hi Daniel,

On Thu, 2016-06-09 at 16:37 +0200, Daniel Vetter wrote:
> On Thu, Jun 9, 2016 at 4:31 PM, Daniel Vetter <daniel@ffwll.ch> wrote:
> > 
> > On Thu, Jun 9, 2016 at 4:29 PM, Alexey Brodkin
> > <Alexey.Brodkin@synopsys.com> wrote:
> > > 
> > > Hi Daniel,
> > > 
> > > On Thu, 2016-06-09 at 15:52 +0200, Daniel Vetter wrote:
> > > > 
> > > > 
> > > > The fake implementation is fundamentally racy, and I don't want to write
> > > > helpers which can't be used correctly. Anyway I think without this patch
> > > > (or something similar) arcpgu will stall badly with the new nonblocking
> > > > helpers, because arcpgu didn't bother at all to implement nonblocking. Can
> > > > you pls ack this, or even better, test the entire patch series? The
> > > > helpers themselves should work, but in all 5 drivers tested thus far they
> > > > discovered some bugs.
> > > Sure I will happily test this series.
> > > The only question then is what should I use as a proper base?
> > It should apply on drm-next from Dave.
>
> And indeed it won't work at all because arcpgu doesn't call
> drm_crtc_handle_vblank anywhere. So you need to add your patch to
> enable vblank interrupts somewhere. Note that as long as you leave
> max_vblank_counter as 0, the only bits you need is drm_vblank_init and
> drm_crtc_handle_vblanke() from the irq handler.

So is there any sense in testing that series if vblank interrupt is not yet
supported (I'm looking forward to implementing it sometime soon but definitely
I'm not there yet)?

-Alexey
Daniel Vetter June 10, 2016, 2:19 p.m. UTC | #13
On Fri, Jun 10, 2016 at 01:23:22PM +0000, Alexey Brodkin wrote:
> Hi Daniel,
> 
> On Thu, 2016-06-09 at 16:37 +0200, Daniel Vetter wrote:
> > On Thu, Jun 9, 2016 at 4:31 PM, Daniel Vetter <daniel@ffwll.ch> wrote:
> > > 
> > > On Thu, Jun 9, 2016 at 4:29 PM, Alexey Brodkin
> > > <Alexey.Brodkin@synopsys.com> wrote:
> > > > 
> > > > Hi Daniel,
> > > > 
> > > > On Thu, 2016-06-09 at 15:52 +0200, Daniel Vetter wrote:
> > > > > 
> > > > > 
> > > > > The fake implementation is fundamentally racy, and I don't want to write
> > > > > helpers which can't be used correctly. Anyway I think without this patch
> > > > > (or something similar) arcpgu will stall badly with the new nonblocking
> > > > > helpers, because arcpgu didn't bother at all to implement nonblocking. Can
> > > > > you pls ack this, or even better, test the entire patch series? The
> > > > > helpers themselves should work, but in all 5 drivers tested thus far they
> > > > > discovered some bugs.
> > > > Sure I will happily test this series.
> > > > The only question then is what should I use as a proper base?
> > > It should apply on drm-next from Dave.
> >
> > And indeed it won't work at all because arcpgu doesn't call
> > drm_crtc_handle_vblank anywhere. So you need to add your patch to
> > enable vblank interrupts somewhere. Note that as long as you leave
> > max_vblank_counter as 0, the only bits you need is drm_vblank_init and
> > drm_crtc_handle_vblanke() from the irq handler.
> 
> So is there any sense in testing that series if vblank interrupt is not yet
> supported (I'm looking forward to implementing it sometime soon but definitely
> I'm not there yet)?

Well, it might break your driver, so yes. I'm ofc happy to help unbreak it,
but without someone who tests there's not much I can do, so will just go
ahead and apply and hope it works.
-Daniel
Daniel Vetter June 10, 2016, 2:54 p.m. UTC | #14
On Fri, Jun 10, 2016 at 04:19:27PM +0200, Daniel Vetter wrote:
> On Fri, Jun 10, 2016 at 01:23:22PM +0000, Alexey Brodkin wrote:
> > Hi Daniel,
> > 
> > On Thu, 2016-06-09 at 16:37 +0200, Daniel Vetter wrote:
> > > On Thu, Jun 9, 2016 at 4:31 PM, Daniel Vetter <daniel@ffwll.ch> wrote:
> > > > 
> > > > On Thu, Jun 9, 2016 at 4:29 PM, Alexey Brodkin
> > > > <Alexey.Brodkin@synopsys.com> wrote:
> > > > > 
> > > > > Hi Daniel,
> > > > > 
> > > > > On Thu, 2016-06-09 at 15:52 +0200, Daniel Vetter wrote:
> > > > > > 
> > > > > > 
> > > > > > The fake implementation is fundamentally racy, and I don't want to write
> > > > > > helpers which can't be used correctly. Anyway I think without this patch
> > > > > > (or something similar) arcpgu will stall badly with the new nonblocking
> > > > > > helpers, because arcpgu didn't bother at all to implement nonblocking. Can
> > > > > > you pls ack this, or even better, test the entire patch series? The
> > > > > > helpers themselves should work, but in all 5 drivers tested thus far they
> > > > > > discovered some bugs.
> > > > > Sure I will happily test this series.
> > > > > The only question then is what should I use as a proper base?
> > > > It should apply on drm-next from Dave.
> > >
> > > And indeed it won't work at all because arcpgu doesn't call
> > > drm_crtc_handle_vblank anywhere. So you need to add your patch to
> > > enable vblank interrupts somewhere. Note that as long as you leave
> > > max_vblank_counter as 0, the only bits you need is drm_vblank_init and
> > > drm_crtc_handle_vblanke() from the irq handler.
> > 
> > So is there any sense in testing that series if vblank interrupt is not yet
> > supported (I'm looking forward to implementing it sometime soon but definitely
> > I'm not there yet)?
> 
> Well, it might break your driver, so yes. I'm ofc happy to help unbreak it,
> but without someone who tests there's not much I can do, so will just go
> ahead and apply and hope it works.

Ok I went ahead and pushed a slight revised version of that patch which
just unconditionally sends out the event. That's not correct, but at least
that way the nonblocking changes won't totally break arcpgu and I can move
ahead with those.
-Daniel
Alexey Brodkin June 10, 2016, 3:01 p.m. UTC | #15
Hi Daniel,

On Fri, 2016-06-10 at 16:54 +0200, Daniel Vetter wrote:
> On Fri, Jun 10, 2016 at 04:19:27PM +0200, Daniel Vetter wrote:
> > 
> > On Fri, Jun 10, 2016 at 01:23:22PM +0000, Alexey Brodkin wrote:
> > > 
> > > Hi Daniel,
> > > 
> > > On Thu, 2016-06-09 at 16:37 +0200, Daniel Vetter wrote:
> > > > 
> > > > On Thu, Jun 9, 2016 at 4:31 PM, Daniel Vetter <daniel@ffwll.ch> wrote:
> > > > > 
> > > > > 
> > > > > On Thu, Jun 9, 2016 at 4:29 PM, Alexey Brodkin
> > > > > <Alexey.Brodkin@synopsys.com> wrote:
> > > > > > 
> > > > > > 
> > > > > > Hi Daniel,
> > > > > > 
> > > > > > On Thu, 2016-06-09 at 15:52 +0200, Daniel Vetter wrote:
> > > > > > > 
> > > > > > > 
> > > > > > > 
> > > > > > > The fake implementation is fundamentally racy, and I don't want to write
> > > > > > > helpers which can't be used correctly. Anyway I think without this patch
> > > > > > > (or something similar) arcpgu will stall badly with the new nonblocking
> > > > > > > helpers, because arcpgu didn't bother at all to implement nonblocking. Can
> > > > > > > you pls ack this, or even better, test the entire patch series? The
> > > > > > > helpers themselves should work, but in all 5 drivers tested thus far they
> > > > > > > discovered some bugs.
> > > > > > Sure I will happily test this series.
> > > > > > The only question then is what should I use as a proper base?
> > > > > It should apply on drm-next from Dave.
> > > > And indeed it won't work at all because arcpgu doesn't call
> > > > drm_crtc_handle_vblank anywhere. So you need to add your patch to
> > > > enable vblank interrupts somewhere. Note that as long as you leave
> > > > max_vblank_counter as 0, the only bits you need is drm_vblank_init and
> > > > drm_crtc_handle_vblanke() from the irq handler.
> > > So is there any sense in testing that series if vblank interrupt is not yet
> > > supported (I'm looking forward to implementing it sometime soon but definitely
> > > I'm not there yet)?
> > Well, it might break your driver, so yes. I'm ofc happy to help unbreak it,
> > but without someone who tests there's not much I can do, so will just go
> > ahead and apply and hope it works.
>
> Ok I went ahead and pushed a slight revised version of that patch which
> just unconditionally sends out the event. That's not correct, but at least
> that way the nonblocking changes won't totally break arcpgu and I can move
> ahead with those.

Thanks for that.
In the meantime I tried previously sent patches:
--------------->8-------------
9267484 drm/arc: Actually bother with handling atomic events.
cf4a489 drm/arc: Nuke event_list
9c3152e drm/atomic-helper: Massage swap_state signature somewhat
--------------->8-------------
and on both boards (axs103 and nSIM OSCI) video works quite fine.

-Alexey
Daniel Vetter June 10, 2016, 3:09 p.m. UTC | #16
On Fri, Jun 10, 2016 at 03:01:03PM +0000, Alexey Brodkin wrote:
> Hi Daniel,
> 
> On Fri, 2016-06-10 at 16:54 +0200, Daniel Vetter wrote:
> > On Fri, Jun 10, 2016 at 04:19:27PM +0200, Daniel Vetter wrote:
> > > 
> > > On Fri, Jun 10, 2016 at 01:23:22PM +0000, Alexey Brodkin wrote:
> > > > 
> > > > Hi Daniel,
> > > > 
> > > > On Thu, 2016-06-09 at 16:37 +0200, Daniel Vetter wrote:
> > > > > 
> > > > > On Thu, Jun 9, 2016 at 4:31 PM, Daniel Vetter <daniel@ffwll.ch> wrote:
> > > > > > 
> > > > > > 
> > > > > > On Thu, Jun 9, 2016 at 4:29 PM, Alexey Brodkin
> > > > > > <Alexey.Brodkin@synopsys.com> wrote:
> > > > > > > 
> > > > > > > 
> > > > > > > Hi Daniel,
> > > > > > > 
> > > > > > > On Thu, 2016-06-09 at 15:52 +0200, Daniel Vetter wrote:
> > > > > > > > 
> > > > > > > > 
> > > > > > > > 
> > > > > > > > The fake implementation is fundamentally racy, and I don't want to write
> > > > > > > > helpers which can't be used correctly. Anyway I think without this patch
> > > > > > > > (or something similar) arcpgu will stall badly with the new nonblocking
> > > > > > > > helpers, because arcpgu didn't bother at all to implement nonblocking. Can
> > > > > > > > you pls ack this, or even better, test the entire patch series? The
> > > > > > > > helpers themselves should work, but in all 5 drivers tested thus far they
> > > > > > > > discovered some bugs.
> > > > > > > Sure I will happily test this series.
> > > > > > > The only question then is what should I use as a proper base?
> > > > > > It should apply on drm-next from Dave.
> > > > > And indeed it won't work at all because arcpgu doesn't call
> > > > > drm_crtc_handle_vblank anywhere. So you need to add your patch to
> > > > > enable vblank interrupts somewhere. Note that as long as you leave
> > > > > max_vblank_counter as 0, the only bits you need is drm_vblank_init and
> > > > > drm_crtc_handle_vblanke() from the irq handler.
> > > > So is there any sense in testing that series if vblank interrupt is not yet
> > > > supported (I'm looking forward to implementing it sometime soon but definitely
> > > > I'm not there yet)?
> > > Well, it might break your driver, so yes. I'm ofc happy to help unbreak it,
> > > but without someone who tests there's not much I can do, so will just go
> > > ahead and apply and hope it works.
> >
> > Ok I went ahead and pushed a slight revised version of that patch which
> > just unconditionally sends out the event. That's not correct, but at least
> > that way the nonblocking changes won't totally break arcpgu and I can move
> > ahead with those.
> 
> Thanks for that.
> In the meantime I tried previously sent patches:
> --------------->8-------------
> 9267484 drm/arc: Actually bother with handling atomic events.
> cf4a489 drm/arc: Nuke event_list
> 9c3152e drm/atomic-helper: Massage swap_state signature somewhat
> --------------->8-------------
> and on both boards (axs103 and nSIM OSCI) video works quite fine.

The possible breakage only starts when you move further into the series,
up to patch 10. That implements generic nonblocking commit, but that
support relies upon crtc_state->event being signalled. Anyway I'm pulling
it all into drm-misc now, so you can just test that branch (or linux-next
when it's rebuild next week).
-Daniel
Alexey Brodkin June 10, 2016, 3:16 p.m. UTC | #17
Hi Daniel,

On Fri, 2016-06-10 at 17:09 +0200, Daniel Vetter wrote:
> On Fri, Jun 10, 2016 at 03:01:03PM +0000, Alexey Brodkin wrote:
> > 
> > > Ok I went ahead and pushed a slight revised version of that patch which
> > > just unconditionally sends out the event. That's not correct, but at least
> > > that way the nonblocking changes won't totally break arcpgu and I can move
> > > ahead with those.
> > Thanks for that.
> > In the meantime I tried previously sent patches:
> > --------------->8-------------
> > 9267484 drm/arc: Actually bother with handling atomic events.
> > cf4a489 drm/arc: Nuke event_list
> > 9c3152e drm/atomic-helper: Massage swap_state signature somewhat
> > --------------->8-------------
> > and on both boards (axs103 and nSIM OSCI) video works quite fine.
>
> The possible breakage only starts when you move further into the series,
> up to patch 10. That implements generic nonblocking commit, but that
> support relies upon crtc_state->event being signalled. Anyway I'm pulling
> it all into drm-misc now, so you can just test that branch (or linux-next
> when it's rebuild next week).

Ok thanks anyways.
I'll try linux-next once it gets updated with your changes.

-Alexey

Patch
diff mbox

diff --git a/drivers/gpu/drm/arc/arcpgu_crtc.c b/drivers/gpu/drm/arc/arcpgu_crtc.c
index d5ca0c280e68..c9f183b11df9 100644
--- a/drivers/gpu/drm/arc/arcpgu_crtc.c
+++ b/drivers/gpu/drm/arc/arcpgu_crtc.c
@@ -145,16 +145,17 @@  static int arc_pgu_crtc_atomic_check(struct drm_crtc *crtc,
 static void arc_pgu_crtc_atomic_begin(struct drm_crtc *crtc,
 				      struct drm_crtc_state *state)
 {
-	struct arcpgu_drm_private *arcpgu = crtc_to_arcpgu_priv(crtc);
-	unsigned long flags;
-
-	if (crtc->state->event) {
-		struct drm_pending_vblank_event *event = crtc->state->event;
+	struct drm_pending_vblank_event *event = crtc->state->event;
 
+	if (event) {
 		crtc->state->event = NULL;
-		event->pipe = drm_crtc_index(crtc);
 
-		WARN_ON(drm_crtc_vblank_get(crtc) != 0);
+		spin_lock_irq(&crtc->dev->event_lock);
+		if (drm_crtc_vblank_get(crtc) == 0)
+			drm_crtc_arm_vblank_event(crtc, event);
+		else
+			drm_crtc_send_vblank_event(crtc, event);
+		spin_unlock_irq(&crtc->dev->event_lock);
 	}
 }